[
  {
    "path": ".github/workflows/check_build.yml",
    "content": "name: Check.Build\n\non: [push]\n\njobs:\n  build_linux:\n\n    runs-on: ubuntu-latest\n\n    steps:\n    - uses: actions/checkout@v1\n    - name: Install Qt\n      uses: jurplel/install-qt-action@v2\n      with:\n        version: 6.2.4\n    - name: Configure build\n      run: ./configure\n    - name: Build sources\n      run: make -j4\n    - name: Install\n      run: sudo make install\n      \n#  build_win64:\n#\n#    runs-on: windows-latest\n#\n#    steps:\n#    - uses: actions/checkout@v1\n#    - name: Setup MSBuild\n#      uses: microsoft/setup-msbuild@v1\n#    - name: Install Qt\n#      uses: jurplel/install-qt-action@v2\n#      with:\n#        version: 6.2.4\n#    - name: Build sources\n#      run: |\n#        $Env:PYTHON_DIR = $Env:RUNNER_TOOL_CACHE/Python/\n#        $Env:QTDIR = $Env:Qt5_Dir\n#        msbuild -m:4 -p:Configuration=Release -p:Platform=x64 Kactus2_Solution_vs2017.sln\n"
  },
  {
    "path": ".github/workflows/code_analysis.yml",
    "content": "name: Code.Analysis\n\non: [push]\n\njobs:\n  test_and_sonar_analysis:\n    \n    runs-on: ubuntu-latest\n\n    steps:\n    - uses: actions/checkout@v2\n    - name: Install Qt\n      uses: jurplel/install-qt-action@v2\n      with:\n        version: 6.2.4\n    - name: Setup sonar-scanner\n      uses: Warchant/setup-sonar-scanner@v3\n      with:\n        # Sonar-scanner version\n        version: 4.2.0.1873\n    - name: Setup build wrapper for sonar-scanner\n      run: |\n        wget https://sonarcloud.io/static/cpp/build-wrapper-linux-x86.zip\n        unzip build-wrapper-linux-x86\n    - name: Configure build\n      run: ./configure\n    - name: Build sources\n      run: build-wrapper-linux-x86/build-wrapper-linux-x86-64 --out-dir bw-output make -j4\n    - name: Install shared libraries\n      run: |\n        sudo make -j 4 -C IPXACTmodels install\n        sudo make -j 4 -C KactusAPI install\n        sudo bash -c 'echo /usr/lib64/ > /etc/ld.so.conf.d/kactus2.conf; ldconfig'\n    - name: Build tests\n      # Build without -j to avoid colliding on compiling objects shared between tests.\n      run: |\n        cd tests\n        qmake test_all.pro\n        make\n    - name: Run tests\n      run : make -C tests check \n    # - name: Run sonar-scanner\n    #   run: |\n    #     echo 'SONARQUBE_LOGIN=${{ secrets.SONAR_LOGIN }}' >> $GITHUB_ENV\n    #     echo 'GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }}' >> $GITHUB_ENV\n    #     sonar-scanner -Dsonar.cfamily.threads=2 -Dsonar.projectKey=kactus2 -Dsonar.organization=\"epekkar-github\" -Dsonar.host.url=\"https://sonarcloud.io\" -Dsonar.login=${{env.SONARQUBE_LOGIN}}} -Dsonar.language=c++ -Dsonar.cxx.suffixes.sources=.cxx,.cpp,.cc,.c,.inl -Dsonar.sources=. -Dsonar.cfamily.build-wrapper-output=bw-output -Dsonar.exclusions=**/qrc_*,tests/**/*,**/?eneratedFiles/**/*\n\n    \n"
  },
  {
    "path": ".github/workflows/deploy_docs.yml",
    "content": "name: Generate and deploy docs\non:\n    push:\n      branches:\n        - main\nenv:\n  DOXYGEN_VERSION: '1.13.2'\n  DOXYFILE_PATH: ./kactus2dev/Administrative/docs/Doxyfile\n  \njobs:\n  generate-docs:\n    runs-on: ubuntu-latest\n\n    steps:\n      - name: Set up Doxygen\n        run: |\n              echo $(pwd)\n              sudo apt install -y wget\n              wget -nv https://www.doxygen.nl/files/doxygen-$DOXYGEN_VERSION.linux.bin.tar.gz\n              tar -xzf doxygen-$DOXYGEN_VERSION.linux.bin.tar.gz\n              echo \"$(pwd)/doxygen-$DOXYGEN_VERSION/bin\" >> $GITHUB_PATH\n\n      - name: Checkout kactus2 repository\n        uses: actions/checkout@v4\n        with:\n          repository: kactus2/kactus2dev\n          token: ${{ secrets.GITHUB_TOKEN }}\n          path: kactus2dev\n\n      - name: Generate Doxygen documentation\n        run: doxygen $DOXYFILE_PATH\n  \n      - name: Checkout target repo\n        uses: actions/checkout@v4\n        with:\n          repository: kactus2/kactus2.github.io\n          token: ${{ secrets.PAGES_REPO_PAT }}\n          path: kactus2.github.io\n        \n      - name: Copy documentation to target repository\n        run: |\n            cd kactus2.github.io\n            git rm -rf .\n            git clean -fxd\n            touch .nojekyll\n            cd ..\n            mkdir kactus2.github.io/reference-guide\n            cp -r docs/html/* kactus2.github.io/reference-guide\n            cp kactus2dev/Administrative/docs/index.html kactus2.github.io\n            \n      - name: Commit and push changes\n        run: |\n            cd kactus2.github.io\n            echo \"Checking for changes...\"\n            \n            git config --global user.name 'github-actions[bot]'\n            git config --global user.email 'github-actions[bot]@users.noreply.github.com'\n            git add .\n\n            if git diff --cached --quiet; then\n              echo \"No changes detected, aborting push\"\n            else\n              echo \"Changes detected, proceeding with commit and push.\"\n              git commit -m 'Update Doxygen documentation'\n              git push\n            fi\n        shell: bash\n\n      # - name: Publish pages\n      #   uses: actions/github-pages\n"
  },
  {
    "path": ".gitignore",
    "content": "# Ignore all generated project files in tests\ntests/**/*.vcxproj\ntests/**/*.vcxproj.filters\ntests/**/*.vcxproj.user\ntests/**/debug/\ntests/**/.vs\ntests/**/release\n\nPlugins/**/Debug\nPlugins/**/Release\nPlugins/**/x64\nPlugins/**/*.vcxproj.user\n\nx64/\nKactusAPI/x64/\nIPXACTmodels/x64/\nIPXACTmodels/GeneratedFiles\nPythonAPI/x64/\nGeneratedFiles/\n.vs\n\n.qtc_clangd\nmoc_*\n*.o\n*.obj\n*.tlog"
  },
  {
    "path": ".qmake.conf",
    "content": "# Change LOCAL_INSTALL_DIR to set user-specific installation directory.\n# If empty, will be considered as an installation for all users, requiring admin-privileges.\nLOCAL_INSTALL_DIR=\"\"\n\n#\n# Python configuration:\n#\n\nPYTHON_CONFIG=python3-config\n# Change PYTHON_C_FLAGS and PYTHON_LIBS below only, if setting PYTHON_CONFIG on the line above\n# does not work.\n\n# PYTHON_C_FLAGS contains the compiler flags needed to compile with references to Python.\n# Here only the include directories are included in the flags, but you may need to change this,\n# if the compilation fails.\n# PYTHON_LIBS contains the library names and locations (-l and -L flags) needed in linking\n# with Python.\nPYTHON_C_FLAGS=$$system($$PYTHON_CONFIG --cflags --embed | grep -o -e \"-I[^[:space:]]*\" | uniq)\nPYTHON_LIBS=$$system($$PYTHON_CONFIG --ldflags --embed | grep -o -e \"-[lL][^[:space:]]*\")\n\n\n#\n# Install location details:\n#\nisEmpty(LOCAL_INSTALL_DIR) {\n\n    # Select paths for binaries in accordance with convention according to system bitness.\n    bin_path = /usr/bin\n\n    lib_path = /usr/lib\n    UNAME = $$system(uname -m)\n    equals(UNAME, x86_64): lib_path = /usr/lib64\n\n    plugin_path = /usr/share/kactus2/plugins\n\n    # Files and destination path for possible settings file upgrades.\n    unix:upgrade.path = /usr/share/kactus2\n    \n    # Files and destination path for documentation files other than the manual.\n    unix:doc.path = /usr/share/kactus2/doc\n    \n    # Files and destination path for the manual.\n    unix:help.path = /usr/share/kactus2/help\n    \n    # Files and destination path for the IP-XACT files coming with an installation.\n    unix:library.path = /usr/share/kactus2/library\n    \n    # Files and destination path for the icons.\n    unix:icons.path = /usr/share/pixmaps\n    \n    # Files and destination path for the desktop shortcut.\n    unix:desktop.path = /usr/share/applications\n\n    # Destination path for default configuration.\n    unix:config.path = /etc/xdg/TUT\n\n} else {\n    # Binaries shall be located in the root of the target installation directory.\n    bin_path = $$LOCAL_INSTALL_DIR\n    lib_path = $$LOCAL_INSTALL_DIR\n    plugin_path = $$LOCAL_INSTALL_DIR/Plugins\n\n    # Files and destination path for possible settings file upgrades.\n    unix:upgrade.path = $$LOCAL_INSTALL_DIR\n\n    # Files and destination path for documentation files other than the manual.\n    unix:doc.path = $$LOCAL_INSTALL_DIR\n\n    # Files and destination path for the manual.\n    unix:help.path = $$LOCAL_INSTALL_DIR/Help\n\n    # Files and destination path for the IP-XACT files coming with an installation.\n    unix:library.path = $$LOCAL_INSTALL_DIR/Library\n\n    # Files and destination path for the icons.\n    unix:icons.path = $$LOCAL_INSTALL_DIR/pixmaps\n\n    # Files and destination path for the desktop shortcut.\n    unix:desktop.path = ~/.local/share/applications\n\n    # Destination path for default configuration.\n    unix:config.path = ~/.config/\n}\n\n# Do not change the files definitions below.\nunix:upgrade.files = ./Administrative/releaseFiles/upgrade.cfg\nunix:doc.files = ./Administrative/releaseFiles/*.txt\nunix:help.files = ./Help/Kactus2Help.qch ./Help/Kactus2Help.qhc\nunix:library.files = ./Administrative/releaseFiles/Library/*\nunix:icons.files = ./Administrative/releaseFiles/kactus2.xpm ./Administrative/releaseFiles/kactus2.png\nunix:desktop.files = ./Administrative/releaseFiles/kactus2.desktop\n\n"
  },
  {
    "path": "Administrative/Qt64/Qt64 Build Instructions.txt",
    "content": "In order to build 64-bit version of Kactus2, 64-bit compiled version of Qt libraries\r\nis needed. 64-bit precompiled binaries are not available for VS2010 at Qt site (http://qt-project.org/downloads).\r\nThis file explains the procedure of building 64-bit Qt with VS2010.\r\n\r\n-------------\r\nPrerequisites\r\n-------------\r\n\r\nIn order to build 64-bit version of Qt 5.x, install the prerequisites in the following order:\r\n\r\n* Visual Studio 2010 SP1\r\n\r\n* Windows SDK 7.1\r\n\r\n* Visual C++ 2010 SP1 Compiler Update for Windows SDK 7.1\r\n  http://www.microsoft.com/en-us/download/details.aspx?id=4422\r\n\r\n* DirectX SDK (June 2010)\r\n\r\n* Strawberry Perl (zip version)\r\n\r\n* Python 2.7.3\r\n\r\n* ICU libraries Win64\r\n  http://site.icu-project.org/download/50#TOC-ICU4C-Download\r\n\r\nAfter installation, add the following folders to PATH:\r\nPERL_LOCATION\\bin\r\nPERL_LOCATION\\site\\bin\r\nICU_LOCATION\\bin64\r\nPYTHON_LOCATION\r\nPYTHON_LOCATION\\DLLs\r\n\r\n-----------\r\nCompilation\r\n-----------\r\n\r\n1. Download (http://qt-project.org/downloads) and unpack the source version of Qt.\r\n\r\n2. Copy qt_configure_vs2010.bat to the root folder of the unpacked source.\r\n\r\n3. Start up Visual Studio 2010 x64 Win64 Command Prompt:\r\n   Start > Programs > Microsoft Visual Studio 2010 > Visual Studio Tools\r\n         > Visual Studio 2010 x64 Win64 Command Prompt (2010)\r\n\r\n4. Go to the source root folder.\r\n\r\n5. Run the following commands:\r\n     qt64_configure_vs2010\r\n     nmake\r\n\r\n\r\nIn case of problems, please refer to:\r\nhttp://www.holoborodko.com/pavel/2011/02/01/how-to-compile-qt-4-7-with-visual-studio-2010/"
  },
  {
    "path": "Administrative/Qt64/qt64_configure_vs2010.bat",
    "content": "@echo off\r\nset QTDIR=%CD%\\qtbase\r\nset QMAKESPEC=win32-msvc2010\r\nset PATH=%QTDIR%\\bin;%PATH%\r\nconfigure -debug-and-release -opensource -platform win32-msvc2010 -mp -make examples -make tools"
  },
  {
    "path": "Administrative/development/FolderStructure.txt",
    "content": "This document describes the high level directory organization of Kactus2.\r\n\r\nThe root directory (trunk) is organized as follows:\r\nAdministrative\t\t\tDocumentation, guidelines for development and release files.\r\ncommon\t\t\t\t\tFiles meant for application-wide use.\r\ndebug*\t\t\t\t\tGenerated files for 32-bit debug build.\r\ndesignEditors\t\t\tEditors for designs e.g. HW design.\r\neditors\t\t\t\t\tEditors for manipulating e.g. Component Editor.\r\nexecutable\t\t\t\tBinaries and libraries for 32-bit build.\r\nGeneratedFiles*\t\t\tGenerated files for Qt MOC objects.\r\nHelp\t\t\t\t\tHelp system and help pages.\r\nipch*\t\t\t\t\tVisual Studio generated iPCH headers.\r\nIPXACTmodels\t\t\tImplementation of IP-XACT components.\r\nkactusGenerators\t\tKactus2 specific generators.\r\nlibrary\t\t\t\t\tComponent library.\r\nmainwindow\t\t\t\tThe application main window.\r\nPlugins\t\t\t\t\tPlugin system and Kactus2 default plugins.\r\nrelease*\t\t\t\tGenerated files for 32-bit release build.\r\nsettings\t\t\t\tApplication-wide settings.\r\nwizards\t\t\t\t\tAssistant wizards e.g. for component creation.\r\nx64*\t\t\t\t\tGenerated files for 64-bit build.\r\n\r\nFolders marked with an asterisk (*) are used mostly for build and can be deleted by user\r\nif not needed.\r\n\r\nThe directories may contain subdirectories named common for sharing files within the directory. \r\nFor example designEditors/common contains editors used by HW, SW and System design."
  },
  {
    "path": "Administrative/docs/Doxyfile",
    "content": "# Doxyfile 1.12.0\n\n#---------------------------------------------------------------------------\n# Project related configuration options\n#---------------------------------------------------------------------------\nDOXYFILE_ENCODING      = UTF-8\nPROJECT_NAME           = \"Kactus2\"\nPROJECT_NUMBER         =\nPROJECT_BRIEF          = \"Kactus2 reference guide\"\nPROJECT_LOGO           = ./kactus2dev/common/graphics/appicon.png\nPROJECT_ICON           = ./kactus2dev/appicon.ico\nOUTPUT_DIRECTORY       = ./docs\nCREATE_SUBDIRS         = NO\nCREATE_SUBDIRS_LEVEL   = 8\nALLOW_UNICODE_NAMES    = NO\nOUTPUT_LANGUAGE        = English\nBRIEF_MEMBER_DESC      = YES\nREPEAT_BRIEF           = YES\nABBREVIATE_BRIEF       = \"The $name class\" \\\n                         \"The $name widget\" \\\n                         \"The $name file\" \\\n                         is \\\n                         provides \\\n                         specifies \\\n                         contains \\\n                         represents \\\n                         a \\\n                         an \\\n                         the\nALWAYS_DETAILED_SEC    = NO\nINLINE_INHERITED_MEMB  = NO\nFULL_PATH_NAMES        = YES\nSTRIP_FROM_PATH        =\nSTRIP_FROM_INC_PATH    =\nSHORT_NAMES            = NO\nJAVADOC_AUTOBRIEF      = NO\nJAVADOC_BANNER         = NO\nQT_AUTOBRIEF           = NO\nMULTILINE_CPP_IS_BRIEF = YES\nPYTHON_DOCSTRING       = YES\nINHERIT_DOCS           = YES\nSEPARATE_MEMBER_PAGES  = NO\nTAB_SIZE               = 4\nALIASES                =\nOPTIMIZE_OUTPUT_FOR_C  = NO\nOPTIMIZE_OUTPUT_JAVA   = NO\nOPTIMIZE_FOR_FORTRAN   = NO\nOPTIMIZE_OUTPUT_VHDL   = NO\nOPTIMIZE_OUTPUT_SLICE  = NO\nEXTENSION_MAPPING      =\nMARKDOWN_SUPPORT       = YES\nTOC_INCLUDE_HEADINGS   = 6\nMARKDOWN_ID_STYLE      = DOXYGEN\nAUTOLINK_SUPPORT       = YES\nBUILTIN_STL_SUPPORT    = NO\nCPP_CLI_SUPPORT        = YES\nSIP_SUPPORT            = NO\nIDL_PROPERTY_SUPPORT   = YES\nDISTRIBUTE_GROUP_DOC   = NO\nGROUP_NESTED_COMPOUNDS = NO\nSUBGROUPING            = YES\nINLINE_GROUPED_CLASSES = NO\nINLINE_SIMPLE_STRUCTS  = NO\nTYPEDEF_HIDES_STRUCT   = NO\nLOOKUP_CACHE_SIZE      = 0\nNUM_PROC_THREADS       = 1\nTIMESTAMP              = NO\n#---------------------------------------------------------------------------\n# Build related configuration options\n#---------------------------------------------------------------------------\nEXTRACT_ALL            = YES\nEXTRACT_PRIVATE        = NO\nEXTRACT_PRIV_VIRTUAL   = NO\nEXTRACT_PACKAGE        = NO\nEXTRACT_STATIC         = NO\nEXTRACT_LOCAL_CLASSES  = YES\nEXTRACT_LOCAL_METHODS  = NO\nEXTRACT_ANON_NSPACES   = NO\nRESOLVE_UNNAMED_PARAMS = YES\nHIDE_UNDOC_MEMBERS     = NO\nHIDE_UNDOC_CLASSES     = NO\nHIDE_FRIEND_COMPOUNDS  = NO\nHIDE_IN_BODY_DOCS      = NO\nINTERNAL_DOCS          = NO\nCASE_SENSE_NAMES       = SYSTEM\nHIDE_SCOPE_NAMES       = NO\nHIDE_COMPOUND_REFERENCE= NO\nSHOW_HEADERFILE        = YES\nSHOW_INCLUDE_FILES     = YES\nSHOW_GROUPED_MEMB_INC  = NO\nFORCE_LOCAL_INCLUDES   = NO\nINLINE_INFO            = YES\nSORT_MEMBER_DOCS       = YES\nSORT_BRIEF_DOCS        = YES\nSORT_MEMBERS_CTORS_1ST = YES\nSORT_GROUP_NAMES       = NO\nSORT_BY_SCOPE_NAME     = NO\nSTRICT_PROTO_MATCHING  = NO\nGENERATE_TODOLIST      = YES\nGENERATE_TESTLIST      = YES\nGENERATE_BUGLIST       = YES\nGENERATE_DEPRECATEDLIST= YES\nENABLED_SECTIONS       =\nMAX_INITIALIZER_LINES  = 30\nSHOW_USED_FILES        = YES\nSHOW_FILES             = YES\nSHOW_NAMESPACES        = YES\nFILE_VERSION_FILTER    =\nLAYOUT_FILE            = ./kactus2dev/Administrative/docs/DoxygenLayout.xml\nCITE_BIB_FILES         =\nEXTERNAL_TOOL_PATH     =\n#---------------------------------------------------------------------------\n# Configuration options related to warning and progress messages\n#---------------------------------------------------------------------------\nQUIET                  = NO\nWARNINGS               = YES\nWARN_IF_UNDOCUMENTED   = YES\nWARN_IF_DOC_ERROR      = YES\nWARN_IF_INCOMPLETE_DOC = YES\nWARN_NO_PARAMDOC       = NO\nWARN_IF_UNDOC_ENUM_VAL = NO\nWARN_AS_ERROR          = NO\nWARN_FORMAT            = \"$file:$line: $text\"\nWARN_LINE_FORMAT       = \"at line $line of file $file\"\nWARN_LOGFILE           =\n#---------------------------------------------------------------------------\n# Configuration options related to the input files\n#---------------------------------------------------------------------------\nINPUT                  = ./kactus2dev/KactusAPI/include \\\n                         ./kactus2dev/PythonAPI \\\n                         ./kactus2dev/Administrative/docs/Kactus2-docs.md \\\n                         ./kactus2dev/Administrative/docs/Python-examples.md\nINPUT_ENCODING         = UTF-8\nINPUT_FILE_ENCODING    =\nFILE_PATTERNS          = *.c \\\n                         *.cc \\\n                         *.cxx \\\n                         *.cxxm \\\n                         *.cpp \\\n                         *.cppm \\\n                         *.ccm \\\n                         *.c++ \\\n                         *.c++m \\\n                         *.java \\\n                         *.ii \\\n                         *.ixx \\\n                         *.ipp \\\n                         *.i++ \\\n                         *.inl \\\n                         *.idl \\\n                         *.ddl \\\n                         *.odl \\\n                         *.h \\\n                         *.hh \\\n                         *.hxx \\\n                         *.hpp \\\n                         *.h++ \\\n                         *.ixx \\\n                         *.l \\\n                         *.cs \\\n                         *.d \\\n                         *.php \\\n                         *.php4 \\\n                         *.php5 \\\n                         *.phtml \\\n                         *.inc \\\n                         *.m \\\n                         *.markdown \\\n                         *.md \\\n                         *.mm \\\n                         *.dox \\\n                         *.py \\\n                         *.pyw \\\n                         *.f90 \\\n                         *.f95 \\\n                         *.f03 \\\n                         *.f08 \\\n                         *.f18 \\\n                         *.f \\\n                         *.for \\\n                         *.vhd \\\n                         *.vhdl \\\n                         *.ucf \\\n                         *.qsf \\\n                         *.ice\nRECURSIVE              = NO\nEXCLUDE                = ./kactus2dev/PythonAPI/xml \\\n                         ./kactus2dev/PythonAPI/html \\\n                         ./kactus2dev/PythonAPI/PythonAPI_wrap.cxx \\\n                         ./kactus2dev/PythonAPI/ExampleScripts \\\n                         ./kactus2dev/PythonAPI/InterfaceFiles \\\n                         ./kactus2dev/PythonAPI/ipmm_core_pkg \\\n                         ./kactus2dev/PythonAPI/python-3.10.6-embed-amd64 \\\n                         ./kactus2dev/PythonAPI/constructPythonComponent.py \\\n                         ./kactus2dev/PythonAPI/runPythonAPI.py \\\n                         ./kactus2dev/PythonAPI/pythonHelps.py \\\nEXCLUDE_SYMLINKS       = NO\nEXCLUDE_PATTERNS       =\nEXCLUDE_SYMBOLS        =\nEXAMPLE_PATH           =\nEXAMPLE_PATTERNS       = *\nEXAMPLE_RECURSIVE      = NO\nIMAGE_PATH             = ./kactus2dev/Administrative/docs/img\nINPUT_FILTER           =\nFILTER_PATTERNS        =\nFILTER_SOURCE_FILES    = NO\nFILTER_SOURCE_PATTERNS =\nUSE_MDFILE_AS_MAINPAGE = ./kactus2dev/Administrative/docs/Kactus2-docs.md\nFORTRAN_COMMENT_AFTER  = 72\n#---------------------------------------------------------------------------\n# Configuration options related to source browsing\n#---------------------------------------------------------------------------\nSOURCE_BROWSER         = YES\nINLINE_SOURCES         = NO\nSTRIP_CODE_COMMENTS    = YES\nREFERENCED_BY_RELATION = NO\nREFERENCES_RELATION    = NO\nREFERENCES_LINK_SOURCE = YES\nSOURCE_TOOLTIPS        = YES\nUSE_HTAGS              = NO\nVERBATIM_HEADERS       = YES\nCLANG_ASSISTED_PARSING = NO\nCLANG_ADD_INC_PATHS    = YES\nCLANG_OPTIONS          =\nCLANG_DATABASE_PATH    =\n#---------------------------------------------------------------------------\n# Configuration options related to the alphabetical class index\n#---------------------------------------------------------------------------\nALPHABETICAL_INDEX     = YES\nIGNORE_PREFIX          =\n#---------------------------------------------------------------------------\n# Configuration options related to the HTML output\n#---------------------------------------------------------------------------\nGENERATE_HTML          = YES\nHTML_OUTPUT            = html\nHTML_FILE_EXTENSION    = .html\nHTML_HEADER            = ./kactus2dev/Administrative/docs/header.html\nHTML_FOOTER            =\nHTML_STYLESHEET        =\nHTML_EXTRA_STYLESHEET  = ./kactus2dev/Administrative/docs/doxygen-awesome.css\nHTML_EXTRA_FILES       = ./kactus2dev/Administrative/docs/doxygen-awesome-darkmode-toggle.js\nHTML_COLORSTYLE        = LIGHT\nHTML_COLORSTYLE_HUE    = 220\nHTML_COLORSTYLE_SAT    = 100\nHTML_COLORSTYLE_GAMMA  = 80\nHTML_DYNAMIC_MENUS     = YES\nHTML_DYNAMIC_SECTIONS  = NO\nHTML_CODE_FOLDING      = YES\nHTML_COPY_CLIPBOARD    = YES\nHTML_PROJECT_COOKIE    =\nHTML_INDEX_NUM_ENTRIES = 100\nGENERATE_DOCSET        = NO\nDOCSET_FEEDNAME        = \"Doxygen generated docs\"\nDOCSET_FEEDURL         =\nDOCSET_BUNDLE_ID       = org.doxygen.Project\nDOCSET_PUBLISHER_ID    = org.doxygen.Publisher\nDOCSET_PUBLISHER_NAME  = Publisher\nGENERATE_HTMLHELP      = NO\nCHM_FILE               =\nHHC_LOCATION           =\nGENERATE_CHI           = NO\nCHM_INDEX_ENCODING     =\nBINARY_TOC             = NO\nTOC_EXPAND             = NO\nSITEMAP_URL            =\nGENERATE_QHP           = NO\nQCH_FILE               =\nQHP_NAMESPACE          = org.doxygen.Project\nQHP_VIRTUAL_FOLDER     = doc\nQHP_CUST_FILTER_NAME   =\nQHP_CUST_FILTER_ATTRS  =\nQHP_SECT_FILTER_ATTRS  =\nQHG_LOCATION           =\nGENERATE_ECLIPSEHELP   = NO\nECLIPSE_DOC_ID         = org.doxygen.Project\nDISABLE_INDEX          = NO\nGENERATE_TREEVIEW      = YES\nFULL_SIDEBAR           = NO\nENUM_VALUES_PER_LINE   = 4\nSHOW_ENUM_VALUES       = NO\nTREEVIEW_WIDTH         = 250\nEXT_LINKS_IN_WINDOW    = NO\nOBFUSCATE_EMAILS       = YES\nHTML_FORMULA_FORMAT    = png\nFORMULA_FONTSIZE       = 10\nFORMULA_MACROFILE      =\nUSE_MATHJAX            = NO\nMATHJAX_VERSION        = MathJax_2\nMATHJAX_FORMAT         = HTML-CSS\nMATHJAX_RELPATH        =\nMATHJAX_EXTENSIONS     =\nMATHJAX_CODEFILE       =\nSEARCHENGINE           = YES\nSERVER_BASED_SEARCH    = NO\nEXTERNAL_SEARCH        = NO\nSEARCHENGINE_URL       =\nSEARCHDATA_FILE        = searchdata.xml\nEXTERNAL_SEARCH_ID     =\nEXTRA_SEARCH_MAPPINGS  =\n#---------------------------------------------------------------------------\n# Configuration options related to the LaTeX output\n#---------------------------------------------------------------------------\nGENERATE_LATEX         = NO\nLATEX_OUTPUT           = latex\nLATEX_CMD_NAME         =\nMAKEINDEX_CMD_NAME     = makeindex\nLATEX_MAKEINDEX_CMD    = makeindex\nCOMPACT_LATEX          = NO\nPAPER_TYPE             = a4\nEXTRA_PACKAGES         =\nLATEX_HEADER           =\nLATEX_FOOTER           =\nLATEX_EXTRA_STYLESHEET =\nLATEX_EXTRA_FILES      =\nPDF_HYPERLINKS         = YES\nUSE_PDFLATEX           = YES\nLATEX_BATCHMODE        = NO\nLATEX_HIDE_INDICES     = NO\nLATEX_BIB_STYLE        = plain\nLATEX_EMOJI_DIRECTORY  =\n#---------------------------------------------------------------------------\n# Configuration options related to the RTF output\n#---------------------------------------------------------------------------\nGENERATE_RTF           = NO\nRTF_OUTPUT             = rtf\nCOMPACT_RTF            = NO\nRTF_HYPERLINKS         = NO\nRTF_STYLESHEET_FILE    =\nRTF_EXTENSIONS_FILE    =\nRTF_EXTRA_FILES        =\n#---------------------------------------------------------------------------\n# Configuration options related to the man page output\n#---------------------------------------------------------------------------\nGENERATE_MAN           = NO\nMAN_OUTPUT             = man\nMAN_EXTENSION          = .3\nMAN_SUBDIR             =\nMAN_LINKS              = NO\n#---------------------------------------------------------------------------\n# Configuration options related to the XML output\n#---------------------------------------------------------------------------\nGENERATE_XML           = NO\nXML_OUTPUT             = xml\nXML_PROGRAMLISTING     = YES\nXML_NS_MEMB_FILE_SCOPE = NO\n#---------------------------------------------------------------------------\n# Configuration options related to the DOCBOOK output\n#---------------------------------------------------------------------------\nGENERATE_DOCBOOK       = NO\nDOCBOOK_OUTPUT         = docbook\n#---------------------------------------------------------------------------\n# Configuration options for the AutoGen Definitions output\n#---------------------------------------------------------------------------\nGENERATE_AUTOGEN_DEF   = NO\n#---------------------------------------------------------------------------\n# Configuration options related to Sqlite3 output\n#---------------------------------------------------------------------------\nGENERATE_SQLITE3       = NO\nSQLITE3_OUTPUT         = sqlite3\nSQLITE3_RECREATE_DB    = YES\n#---------------------------------------------------------------------------\n# Configuration options related to the Perl module output\n#---------------------------------------------------------------------------\nGENERATE_PERLMOD       = NO\nPERLMOD_LATEX          = NO\nPERLMOD_PRETTY         = YES\nPERLMOD_MAKEVAR_PREFIX =\n#---------------------------------------------------------------------------\n# Configuration options related to the preprocessor\n#---------------------------------------------------------------------------\nENABLE_PREPROCESSING   = YES\nMACRO_EXPANSION        = NO\nEXPAND_ONLY_PREDEF     = NO\nSEARCH_INCLUDES        = YES\nINCLUDE_PATH           =\nINCLUDE_FILE_PATTERNS  =\nPREDEFINED             =\nEXPAND_AS_DEFINED      =\nSKIP_FUNCTION_MACROS   = YES\n#---------------------------------------------------------------------------\n# Configuration options related to external references\n#---------------------------------------------------------------------------\nTAGFILES               =\nGENERATE_TAGFILE       =\nALLEXTERNALS           = NO\nEXTERNAL_GROUPS        = YES\nEXTERNAL_PAGES         = YES\n#---------------------------------------------------------------------------\n# Configuration options related to diagram generator tools\n#---------------------------------------------------------------------------\nHIDE_UNDOC_RELATIONS   = YES\nHAVE_DOT               = NO\nDOT_NUM_THREADS        = 0\nDOT_COMMON_ATTR        = \"fontname=Helvetica,fontsize=10\"\nDOT_EDGE_ATTR          = \"labelfontname=Helvetica,labelfontsize=10\"\nDOT_NODE_ATTR          = \"shape=box,height=0.2,width=0.4\"\nDOT_FONTPATH           =\nCLASS_GRAPH            = YES\nCOLLABORATION_GRAPH    = YES\nGROUP_GRAPHS           = YES\nUML_LOOK               = NO\nUML_LIMIT_NUM_FIELDS   = 10\nDOT_UML_DETAILS        = NO\nDOT_WRAP_THRESHOLD     = 17\nTEMPLATE_RELATIONS     = NO\nINCLUDE_GRAPH          = YES\nINCLUDED_BY_GRAPH      = YES\nCALL_GRAPH             = NO\nCALLER_GRAPH           = NO\nGRAPHICAL_HIERARCHY    = YES\nDIRECTORY_GRAPH        = YES\nDIR_GRAPH_MAX_DEPTH    = 1\nDOT_IMAGE_FORMAT       = png\nINTERACTIVE_SVG        = NO\nDOT_PATH               =\nDOTFILE_DIRS           =\nDIA_PATH               =\nDIAFILE_DIRS           =\nPLANTUML_JAR_PATH      =\nPLANTUML_CFG_FILE      =\nPLANTUML_INCLUDE_PATH  =\nDOT_GRAPH_MAX_NODES    = 50\nMAX_DOT_GRAPH_DEPTH    = 0\nDOT_MULTI_TARGETS      = NO\nGENERATE_LEGEND        = YES\nDOT_CLEANUP            = YES\nMSCGEN_TOOL            =\nMSCFILE_DIRS           ="
  },
  {
    "path": "Administrative/docs/DoxygenLayout.xml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<doxygenlayout version=\"1.0\">\n  <!-- Generated by doxygen 1.12.0 -->\n  <!-- Navigation index tabs for HTML output -->\n  <navindex>\n    <tab type=\"mainpage\" visible=\"yes\" title=\"\"/>\n    <!-- <tab type=\"pages\" visible=\"yes\" title=\"\" intro=\"\"/>\n    <tab type=\"topics\" visible=\"yes\" title=\"\" intro=\"\"/> -->\n    <tab type=\"modules\" visible=\"no\" title=\"\" intro=\"\">\n      <tab type=\"modulelist\" visible=\"yes\" title=\"\" intro=\"\"/>\n      <tab type=\"modulemembers\" visible=\"yes\" title=\"\" intro=\"\"/>\n    </tab>\n    \n    <tab type=\"user\" url=\"@ref examples\" title=\"Examples\"/>\n\n    <tab type=\"usergroup\" url=\"\" title=\"API Reference\">\n      <tab type=\"namespaces\" visible=\"yes\" title=\"\">\n        <tab type=\"namespacelist\" visible=\"yes\" title=\"\" intro=\"\"/>\n        <tab type=\"namespacemembers\" visible=\"yes\" title=\"\" intro=\"\"/>\n      </tab>\n      <tab type=\"concepts\" visible=\"no\" title=\"\">\n      </tab>\n      <tab type=\"interfaces\" visible=\"no\" title=\"\">\n        <tab type=\"interfacelist\" visible=\"yes\" title=\"\" intro=\"\"/>\n        <tab type=\"interfaceindex\" visible=\"$ALPHABETICAL_INDEX\" title=\"\"/>\n        <tab type=\"interfacehierarchy\" visible=\"yes\" title=\"\" intro=\"\"/>\n      </tab>\n      <tab type=\"classes\" visible=\"yes\" title=\"\">\n        <tab type=\"classlist\" visible=\"yes\" title=\"\" intro=\"\"/>\n        <tab type=\"classindex\" visible=\"$ALPHABETICAL_INDEX\" title=\"\"/>\n        <tab type=\"hierarchy\" visible=\"yes\" title=\"\" intro=\"\"/>\n        <tab type=\"classmembers\" visible=\"yes\" title=\"\" intro=\"\"/>\n      </tab>\n      <tab type=\"structs\" visible=\"no\" title=\"\">\n        <tab type=\"structlist\" visible=\"yes\" title=\"\" intro=\"\"/>\n        <tab type=\"structindex\" visible=\"$ALPHABETICAL_INDEX\" title=\"\"/>\n      </tab>\n      <tab type=\"exceptions\" visible=\"no\" title=\"\">\n        <tab type=\"exceptionlist\" visible=\"yes\" title=\"\" intro=\"\"/>\n        <tab type=\"exceptionindex\" visible=\"$ALPHABETICAL_INDEX\" title=\"\"/>\n        <tab type=\"exceptionhierarchy\" visible=\"yes\" title=\"\" intro=\"\"/>\n      </tab>\n      <tab type=\"files\" visible=\"yes\" title=\"\">\n        <tab type=\"filelist\" visible=\"yes\" title=\"\" intro=\"\"/>\n        <tab type=\"globals\" visible=\"yes\" title=\"\" intro=\"\"/>\n      </tab>\n      <tab type=\"examples\" visible=\"no\" title=\"\" intro=\"\"/>\n    </tab>\n  </navindex>\n\n  <!-- Layout definition for a class page -->\n  <class>\n    <briefdescription visible=\"yes\"/>\n    <includes visible=\"$SHOW_HEADERFILE\"/>\n    <inheritancegraph visible=\"yes\"/>\n    <collaborationgraph visible=\"yes\"/>\n    <memberdecl>\n      <nestedclasses visible=\"yes\" title=\"\"/>\n      <publictypes title=\"\"/>\n      <services title=\"\"/>\n      <interfaces title=\"\"/>\n      <publicslots title=\"\"/>\n      <signals title=\"\"/>\n      <publicmethods title=\"\"/>\n      <publicstaticmethods title=\"\"/>\n      <publicattributes title=\"\"/>\n      <publicstaticattributes title=\"\"/>\n      <protectedtypes title=\"\"/>\n      <protectedslots title=\"\"/>\n      <protectedmethods title=\"\"/>\n      <protectedstaticmethods title=\"\"/>\n      <protectedattributes title=\"\"/>\n      <protectedstaticattributes title=\"\"/>\n      <packagetypes title=\"\"/>\n      <packagemethods title=\"\"/>\n      <packagestaticmethods title=\"\"/>\n      <packageattributes title=\"\"/>\n      <packagestaticattributes title=\"\"/>\n      <properties title=\"\"/>\n      <events title=\"\"/>\n      <privatetypes title=\"\"/>\n      <privateslots title=\"\"/>\n      <privatemethods title=\"\"/>\n      <privatestaticmethods title=\"\"/>\n      <privateattributes title=\"\"/>\n      <privatestaticattributes title=\"\"/>\n      <friends title=\"\"/>\n      <related title=\"\" subtitle=\"\"/>\n      <membergroups visible=\"yes\"/>\n    </memberdecl>\n    <detaileddescription title=\"\"/>\n    <memberdef>\n      <inlineclasses title=\"\"/>\n      <typedefs title=\"\"/>\n      <enums title=\"\"/>\n      <services title=\"\"/>\n      <interfaces title=\"\"/>\n      <constructors title=\"\"/>\n      <functions title=\"\"/>\n      <related title=\"\"/>\n      <variables title=\"\"/>\n      <properties title=\"\"/>\n      <events title=\"\"/>\n    </memberdef>\n    <allmemberslink visible=\"yes\"/>\n    <usedfiles visible=\"$SHOW_USED_FILES\"/>\n    <authorsection visible=\"yes\"/>\n  </class>\n\n  <!-- Layout definition for a namespace page -->\n  <namespace>\n    <briefdescription visible=\"yes\"/>\n    <memberdecl>\n      <nestednamespaces visible=\"yes\" title=\"\"/>\n      <constantgroups visible=\"yes\" title=\"\"/>\n      <interfaces visible=\"yes\" title=\"\"/>\n      <classes visible=\"yes\" title=\"\"/>\n      <concepts visible=\"yes\" title=\"\"/>\n      <structs visible=\"yes\" title=\"\"/>\n      <exceptions visible=\"yes\" title=\"\"/>\n      <typedefs title=\"\"/>\n      <sequences title=\"\"/>\n      <dictionaries title=\"\"/>\n      <enums title=\"\"/>\n      <functions title=\"\"/>\n      <variables title=\"\"/>\n      <properties title=\"\"/>\n      <membergroups visible=\"yes\"/>\n    </memberdecl>\n    <detaileddescription title=\"\"/>\n    <memberdef>\n      <inlineclasses title=\"\"/>\n      <typedefs title=\"\"/>\n      <sequences title=\"\"/>\n      <dictionaries title=\"\"/>\n      <enums title=\"\"/>\n      <functions title=\"\"/>\n      <variables title=\"\"/>\n      <properties title=\"\"/>\n    </memberdef>\n    <authorsection visible=\"yes\"/>\n  </namespace>\n\n  <!-- Layout definition for a concept page -->\n  <concept>\n    <briefdescription visible=\"yes\"/>\n    <includes visible=\"$SHOW_HEADERFILE\"/>\n    <definition visible=\"yes\" title=\"\"/>\n    <detaileddescription title=\"\"/>\n    <authorsection visible=\"yes\"/>\n  </concept>\n\n  <!-- Layout definition for a file page -->\n  <file>\n    <briefdescription visible=\"yes\"/>\n    <includes visible=\"$SHOW_INCLUDE_FILES\"/>\n    <includegraph visible=\"yes\"/>\n    <includedbygraph visible=\"yes\"/>\n    <sourcelink visible=\"yes\"/>\n    <memberdecl>\n      <interfaces visible=\"yes\" title=\"\"/>\n      <classes visible=\"yes\" title=\"\"/>\n      <structs visible=\"yes\" title=\"\"/>\n      <exceptions visible=\"yes\" title=\"\"/>\n      <namespaces visible=\"yes\" title=\"\"/>\n      <concepts visible=\"yes\" title=\"\"/>\n      <constantgroups visible=\"yes\" title=\"\"/>\n      <defines title=\"\"/>\n      <typedefs title=\"\"/>\n      <sequences title=\"\"/>\n      <dictionaries title=\"\"/>\n      <enums title=\"\"/>\n      <functions title=\"\"/>\n      <variables title=\"\"/>\n      <properties title=\"\"/>\n      <membergroups visible=\"yes\"/>\n    </memberdecl>\n    <detaileddescription title=\"\"/>\n    <memberdef>\n      <inlineclasses title=\"\"/>\n      <defines title=\"\"/>\n      <typedefs title=\"\"/>\n      <sequences title=\"\"/>\n      <dictionaries title=\"\"/>\n      <enums title=\"\"/>\n      <functions title=\"\"/>\n      <variables title=\"\"/>\n      <properties title=\"\"/>\n    </memberdef>\n    <authorsection/>\n  </file>\n\n  <!-- Layout definition for a group page -->\n  <group>\n    <briefdescription visible=\"yes\"/>\n    <groupgraph visible=\"yes\"/>\n    <memberdecl>\n      <nestedgroups visible=\"yes\" title=\"\"/>\n      <modules visible=\"yes\" title=\"\"/>\n      <dirs visible=\"yes\" title=\"\"/>\n      <files visible=\"yes\" title=\"\"/>\n      <namespaces visible=\"yes\" title=\"\"/>\n      <concepts visible=\"yes\" title=\"\"/>\n      <classes visible=\"yes\" title=\"\"/>\n      <defines title=\"\"/>\n      <typedefs title=\"\"/>\n      <sequences title=\"\"/>\n      <dictionaries title=\"\"/>\n      <enums title=\"\"/>\n      <enumvalues title=\"\"/>\n      <functions title=\"\"/>\n      <variables title=\"\"/>\n      <signals title=\"\"/>\n      <publicslots title=\"\"/>\n      <protectedslots title=\"\"/>\n      <privateslots title=\"\"/>\n      <events title=\"\"/>\n      <properties title=\"\"/>\n      <friends title=\"\"/>\n      <membergroups visible=\"yes\"/>\n    </memberdecl>\n    <detaileddescription title=\"\"/>\n    <memberdef>\n      <pagedocs/>\n      <inlineclasses title=\"\"/>\n      <defines title=\"\"/>\n      <typedefs title=\"\"/>\n      <sequences title=\"\"/>\n      <dictionaries title=\"\"/>\n      <enums title=\"\"/>\n      <enumvalues title=\"\"/>\n      <functions title=\"\"/>\n      <variables title=\"\"/>\n      <signals title=\"\"/>\n      <publicslots title=\"\"/>\n      <protectedslots title=\"\"/>\n      <privateslots title=\"\"/>\n      <events title=\"\"/>\n      <properties title=\"\"/>\n      <friends title=\"\"/>\n    </memberdef>\n    <authorsection visible=\"yes\"/>\n  </group>\n\n  <!-- Layout definition for a C++20 module page -->\n  <module>\n    <briefdescription visible=\"yes\"/>\n    <exportedmodules visible=\"yes\"/>\n    <memberdecl>\n      <concepts visible=\"yes\" title=\"\"/>\n      <classes visible=\"yes\" title=\"\"/>\n      <enums title=\"\"/>\n      <typedefs title=\"\"/>\n      <functions title=\"\"/>\n      <variables title=\"\"/>\n      <membergroups title=\"\"/>\n    </memberdecl>\n    <detaileddescription title=\"\"/>\n    <memberdecl>\n      <files visible=\"yes\"/>\n    </memberdecl>\n  </module>\n\n  <!-- Layout definition for a directory page -->\n  <directory>\n    <briefdescription visible=\"yes\"/>\n    <directorygraph visible=\"yes\"/>\n    <memberdecl>\n      <dirs visible=\"yes\"/>\n      <files visible=\"yes\"/>\n    </memberdecl>\n    <detaileddescription title=\"\"/>\n  </directory>\n</doxygenlayout>\n"
  },
  {
    "path": "Administrative/docs/Kactus2-docs.md",
    "content": "# Kactus2 reference guide {#home}\n\nWelcome to the Kactus2 reference page. Here you can find the API reference for the PythonAPI as well as the reference for the supporting KactusAPI module.\n\n## PythonAPI\n\nThe PythonAPI is a Python module that enables scripting support for Kactus2 using Python. The library uses SWIG to wrap the PythonAPI C++ class into a Python module. This reference guide contains the C++ descriptions for the PythonAPI class and its methods.\n\nThe PythonAPI contains classes and methods to manipulate Kactus2 IP-XACT objects. Everything is designed to be accessed through the PythonAPI class, which contains methods to access the underlying KactusAPI interfaces, which in turn do the heavy lifting in interfacing with the IP-XACT models. The SWIG wrapper isn't perfect and thus some KactusAPI interfaces wrapped for Python might contain methods that are not meant to be called from a Python script. For example, any functions either returning Qt-types or taking them as paremeters should not be called using Python.\n\nThe PythonAPI currently contains the following functionality:\n- Creating and modifying components (including component memory maps, address blocks, etc., as well as bus interfaces)\n- Creating and modifying designs (including adding/removing component instances and connections)\n- Launching generators and importers\n\n### PythonAPI usage\n\nPythonAPI is not a standalone module and must be used in tandem with Kactus2 either inside the Kactus2 GUI in the \"Script editor\" window or on the command line Python interpreter by starting Kactus2 with the -c (--no-gui) option. Running ready-made scripts on the CLI can be done with `exec(open(<file path>).read())`.\n\n### Usable KactusAPI interfaces\n\nThe PythonAPI automatically initializes and provides methods to access the following KactusAPI interfaces, which can be used to modify component sub-elements:\n\n- PortsInterface for modifying component ports\n- ParametersInterface for modifying component parameters\n- MemoryMapInterface for modifying component memory maps\n- FileSetInterface for modifying component file sets\n- BusInterfaceInterface for modifying component bus interfaces\n\nAbove interfaces may contain sub-interfaces that give further access to sub-elements, for example the address blocks for a memory map can be accessed via the AddressBlockInterface which in turn can be accessed with MemoryMapInterface::getAddressBlockInterface. Some sub-interfaces may need additional configuration before use, examples of this can be found in the [scripting examples](#examples).\n"
  },
  {
    "path": "Administrative/docs/Python-examples.md",
    "content": "# Kactus2 scripting examples {#examples}\n[TOC]\n\nHere are some simple examples on how to use Kactus2 via Python scripting.\n\n\\note After running scripts in GUI, changes made to documents (components, designs) won't be visible until the document is refreshed in the GUI.\n\n## Setting up IP-XACT libraries\n\nIP-XACT libraries can be set either in the GUI or via Python. Currently configured library paths can be listed with PythonAPI::getAllLibraryPaths or PythonAPI::getActiveLibraryPaths, and PythonAPI::getDefaultLibraryPath (for the current default), e.g.;\n```py\nfrom pythonAPI import PythonAPI\n\nkactus2py = PythonAPI()\nprint(kactus2py.getAllLibraryPaths()) # Lists all configured paths\nprint(kactus2py.getActiveLibraryPaths()) # Lists paths currently set active = where Kactus2 looks for IP-XACT files \nprint(kactus2py.getDefaultLibraryPath()) # Lists the current default library path\n```\n\nLibraries can be added with PythonAPI::addLibraryPath and removed with PythonAPI::removeLibraryPath. Libraries can be set in bulk with PythonAPI::setLibraryPaths, which will add and set active all paths that are given as a list in the function arguments. PythonAPI::setDefaultLibraryPath sets the default location.\n\n```py\nkactus2py.addLibraryPath(\"C:/some/path\", False) # optional second argument sets active (True) or inactive (False), active by default\nkactus2py.setDefaultLibraryPath(\"C:/some/path\")\nkactus2py.setLibraryPathActive(\"C:/some/path\", True) # set the earlier path active\n...\nkactus2py.setLibraryPaths(['C:/some/new/path', 'C:/another/new/path']) # Replaces the active library paths and also sets the first listed path as default\n```\n\n## Creating a component\n\nCreating a component is done with PythonAPI::createComponent. As parameters, it takes the VLNV (vendor, library, name, version) of the component to be created, one parameter each, and the IP-XACT standard revision to use (PythonAPI::StdRev). Example:\n\n```py\n# Create component with VLNV Company:Lib:ComponentName:1.0 using IP-XACT 2014\nvendor = \"Company\"\nlibrary = \"Lib\"\nname = \"ComponentName\"\nversion = \"1.0\"\n\nkactus2py.createComponent(vendor, library, name, version, kactus2py.Std14)\n```\n\nThe created component will be placed in the **default library path**. \n\n\\note Supported standard revisions are Std14 and Std22 and the default value is Std22.\n\nThe IP-XACT standard revision of a component can be checked with PythonAPI::getComponentStdRevision :\n```py\nrevision = kactus2py.getComponentStdRevision() # Returns \"1685-2014\" in this case\n```\n\n## Creating a design and adding a component instance\n\nSimilarly to creating components, a design can be created with PythonAPI::createDesign:\n\n```py\ndesignName = \"AwesomeDesign\"\ndesignVersion = \"1.0\"\n\nkactus2py.createDesign(vendor, library, designName, designVersion, kactus2py.Std14)\n```\n\nThe IP-XACT standard revision of a design can also be checked with PythonAPI::getDesignStdRevision.\n\nCreating a design will create 1) The design itself and 2) A top-level component for the design. The top-level component VLNV will become vendor:library:name:version and the design VLNV will become vendor:library:name.design:version. The design will be created in the default library.\n\nThe component can then be instantiated and added to the design. Creating a design will automatically set it as active, but in any other case the design must be set active with PythonAPI::openDesign, which takes the design VLNV as a vlnvString (vendor:library:name:version).\n\nThe component can be instantiated and added to the design with PythonAPI::addComponentInstance, which also takes a vlnvstring and the instance name:\n\n```py\nkactus2py.openDesign(\":\".join([vendor, library, designName + \".design\", designVersion]))\nkactus2py.addComponentInstance(\":\".join([vendor, library, name, version]), \"NewInstance\")\n```\n\nChanges to a design are saved with PythonAPI::saveDesign, which will write the changes to disk. The currently open design can be closed with PythonAPI::closeOpenDesign:\n\n```py\nkactus2py.saveDesign()\nkactus2py.closeOpenDesign()\n```\n\n## Modifying components\n\nModifying a component requires that the component is opened first:\n```py\nkactus2py.openComponent(\":\".join([vendor, library, name, version])) # open Company:Lib:ComponentName:1.0\n```\n\nNow any changes made will be made to the opened component. \n\n\\note The following code examples generally don't include any error checks. Most setters return a boolean value, which can be used for detecting errors. \n\n### Modifying component memory maps\n\nAny modifications to component memory maps are made through KactusAPI interfaces. Memory maps can be modified via MemoryMapInterface, and it can be accessed with PythonAPI::getMapInterface. Address blocks, registers and fields can be modified in a similar way.\n\n#### Creating a memory map\n\nA new map can be added with MemoryMapInterface::addMemoryMap. It takes an index as first parameter and the name as the second parameter. The index can be in the range [0, number of memory maps in the component], the easiest thing to do is always use index 0.\n\n```py\nmapInterface = kactus2py.getMapInterface()\nmapInterface.addMemoryMap(0, \"NewMemoryMap\")\n```\n\nThe memory map can then be modified with the different functions of MemoryMapInterface, e.g. to set the address unit bits:\n```py\nmapAubOk = mapInterface.setAddressUnitBits(\"NewMemoryMap\", \"8\") # returns True, if operation was successful, otherwise False\n```\n\n#### Adding address blocks\n\nThe address block interface can be accessed with MemoryMapInterface::getAddressBlockInterface. The interface must first be pointed to the memory map whose address blocks are to be edited:\n```py\nkactus2py.setBlocksForInterface(\"NewMemoryMap\")\nblockInterface = mapInterface.getAddressBlockInterface()\n```\n\nA new address block can be added with AddressBlockInterface::addBlock. Its properties can be accessed in the same way as with memory maps:\n```py\nblockInterface.addBlock(0, \"NewAddressBlock\")\nwidthOk = blockInterface.setWidth(\"NewAddressBlock\", \"32\")\n...\nblockInterface.getWidth(\"NewAddressBlock\") # returns \"32\"\n```\n\n#### Adding registers and fields\n\nRegister and field interfaces are accessed through AddressBlockInterface::getSubInterface and RegisterInterface::getSubInterface respectively. Apart from that they work as the previous interfaces. First, the available registers (the registers of the created address block) must be set for the register interface:\n\n```py\nkactus2py.setRegistersForInterface(\"NewMemoryMap\", \"NewAddressBlock\")\nregInterface = blockInterface.getSubInterface()\n```\n\nThen the register properties can be manipulated:\n```py\nregInterface.addRegister(0, 0, \"NewRegister\")\nregInterface.setSize(\"NewRegister\", \"16\")\n```\n\nField editing is done in a similar fashion. First, the available fields must be set for the interface:\n```py\nkactus2py.setFieldsForInterface(\"NewMemoryMap\", \"NewAddressBlock\", \"NewRegister\") # now editing fields of \"NewRegister\"\n``` \n\nAfter that fields can be edited through the field interface:\n```py\nfieldInterface = regInterface.getSubInterface()\nfieldInterface.addField(0, \"NewField\")\nnewWidthOk = fieldInterface.setWidth(\"NewField\", \"8\") # most setters return a boolean value for checking if operation was successful\nwidthNotOk = fieldInterface.setWidth(\"non-existing-field\", \"8\") # this would return false in this example\n```\n\n### Modifying component bus interfaces\n\nThe components bus interfaces are directly accessible through the BusInterfaceInterface class, after PythonAPI::openComponent has been called.\n\nIn this example, we'll first create some ports for our component. Then, we'll create a bus interface and some portmaps for it. For mapping ports, we need a bus- and abstraction definition, which cannot be created via the python API, but can be created in the GUI.\n\nThe bus definition created for this example is not modified in any way and its VLNV is Company:Lib:TestBus:1.0. The abstraction defintion is Company:Lib:TestBus.absDef:1.0. Here's the abstraction definition used:\n![Example abstraction definition](testAbsDef.png)\n\nLet's start by creating the physical component ports:\n```py\nportsInterface = kactus2py.getPortsInterface()\nportsInterface.addWirePort(\"some_rx\")\nportsInterface.setDirection(\"some_rx\", \"in\")\nportsInterface.setWidth(\"some_rx\", \"1\")\n\nportsInterface.addWirePort(\"some_tx\")\nportsInterface.setDirection(\"some_tx\", \"out\")\nportsInterface.setWidth(\"some_tx\", \"1\")\n\n# Let's add some unmapped ports as well\nportsInterface.addWirePort(\"otherPort1\")\nportsInterface.setDirection(\"otherPort1\", \"inout\")\nportsInterface.addWirePort(\"otherPort2\")\nportsInterface.setDirection(\"otherPort2\", \"inout\")\n\n# Not setting any port bounds results in the port having width 1, which we want in this case\n```\n\nNow, let's create the bus interface:\n```py\nbusInterfaceInterface = kactus2py.getBusInterface() # gets the BusInterfaceInterface object\nbusInterfaceInterface.addBusInterface(0, \"NewBusInterface\") # Index doesn't really matter, as bus interfaces (should) have unique names\nbusInterfaceInterface.setMode(\"NewBusInterface\", \"master\")\n```\n\nBefore creating portmaps, the bus interface needs a bus type and at least one abstraction type. These are references to the bus definition and abstraction definition. In this example we'll use Company:Lib:TestBus:1.0 and Company:Lib:TestBus.absDef:1.0 :\n\n```py\nbusInterfaceInterface.setupSubInterfaces(\"NewBusInterface\") # prepare subinterfaces for use\nbusInterfaceInterface.setBusType(\"NewBusInterface\", \"Company\", \"Lib\", \"TestBus\", \"1.0\")\nbusInterfaceInterface.addAbstractionType(\"NewBusInterface\", \"Company\", \"Lib\", \"TestBus.absDef\", \"1.0\")\n```\n\nThen, let's setup the portmaps. We'll simply map the logical \"some_rx\" to physical and the same with \"some_tx\". First, we need to setup the AbstractionTypeInterface, through which portmaps can be accessed. Abstraction types and portmaps don't have names, so indices are used to select the wanted abstraction type or portmap:\n\n```py\nabstractionInterface = busInterfaceInterface.getAbstractionTypeInterface()\n\n# Map only master mode ports with this master mode bus interface:\nabstractionInterface.setBusMode(\"master\")\n\n# Setup portmaps and abstraction definition reference for wanted abstraction type. \n# Ours is the first so it's found with index 0. Available abstraction types can be listed in the order of their index with AbstractionTypeInterface::getItemNames.\nabstractionInterface.setupAbstractionTypeForPortMapInterface(0)\n\nportMapInterface = abstractionInterface.getPortMapInterface()\n\n# We need two port mappings: one for some_tx and one for some_rx\n\n# The new portmap should be added to the end of the portmap list so that indices don't get messed up (though in this case it is just 0)\nnewPortMapIndex = portMapInterface.itemCount()\nportMapInterface.addPortMap(newPortMapIndex)\n\n# Map some_tx\nportMapInterface.setLogicalPort(newPortMapIndex, \"some_tx\") # here \"some_tx\" refers to the logical port name set in the abstraction definition\nportMapInterface.setPhysicalPort(newPortMapIndex, \"some_tx\")\n\n# Add new port mapping for some_rx\nnewPortMapIndex = portMapInterface.itemCount()\nportMapInterface.addPortMap(newPortMapIndex)\n\n# Map some_rx\nportMapInterface.setLogicalPort(newPortMapIndex, \"some_rx\")\nportMapInterface.setPhysicalPort(newPortMapIndex, \"some_rx\")\n\n# If no port mapping bounds are set, then the whole logical and physical ports will be used.\n```\n\nResulting ports shown in GUI after running script:\n![Created ports](result_ports.png)\n\nThe created bus interface:\n![Created bus interface](result_bus.png)\n\nAnd the portmaps:\n![Created portmaps](result_portmaps.png)\n\n### Practical example: Getting physical ports used in bus interface\n\nAssuming we have a component with a bus interface with portmaps (like in the previous example), to print information of the physical ports a bus interface is using, we can do the following:\n\n```py\n# Assume component has already been opened, and the component has the bus interface \"NewBusInterface\"\n\n# Set up the sub-interfaces\nbusInterfaceInterface = kactus2py.getBusInterface()\nbusInterfaceInterface.setupSubInterfaces(\"NewBusInterface\")\nabstractionInterface = busInterfaceInterface.getAbstractionTypeInterface()\nabstractionInterface.setupAbstractionTypeForPortMapInterface(0)\nportMapInterface = abstractionInterface.getPortMapInterface()\n\nnumPortMaps = portMapInterface.itemCount()\nfoundPorts = []\n\nfor i in range(0, numPortMaps):\n    currentPhysical = portMapInterface.getPhysicalPortName()\n    print(currentPhysical)\n    foundPorts.append(currentPhysical)\n```\n\nThen the individual ports can be accessed with KactusAPI::PortsInterface:\n```py\nportsInterface = kactus2py.getPortsInterface()\n\nfor i in range(0, numPortMaps):\n    print(portsInterface.getWidth(foundPorts[i]))\n```\nWith the previous example, the above should print\n```\nsome_tx\n1\nsome_rx\n1\n```\n\nNotice how the previously added extra ports `otherPort1` and `otherPort2` don't show up, because they weren't mapped to any logical signals.\n"
  },
  {
    "path": "Administrative/docs/doxygen-awesome-darkmode-toggle.js",
    "content": "/**\n\nDoxygen Awesome\nhttps://github.com/jothepro/doxygen-awesome-css\n\nMIT License\n\nCopyright (c) 2021 - 2023 jothepro\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n\n*/\n\nclass DoxygenAwesomeDarkModeToggle extends HTMLElement {\n    // SVG icons from https://fonts.google.com/icons\n    // Licensed under the Apache 2.0 license:\n    // https://www.apache.org/licenses/LICENSE-2.0.html\n    static lightModeIcon = `<svg xmlns=\"http://www.w3.org/2000/svg\" enable-background=\"new 0 0 24 24\" height=\"24px\" viewBox=\"0 0 24 24\" width=\"24px\" fill=\"#FCBF00\"><rect fill=\"none\" height=\"24\" width=\"24\"/><circle cx=\"12\" cy=\"12\" opacity=\".3\" r=\"3\"/><path d=\"M12,9c1.65,0,3,1.35,3,3s-1.35,3-3,3s-3-1.35-3-3S10.35,9,12,9 M12,7c-2.76,0-5,2.24-5,5s2.24,5,5,5s5-2.24,5-5 S14.76,7,12,7L12,7z M2,13l2,0c0.55,0,1-0.45,1-1s-0.45-1-1-1l-2,0c-0.55,0-1,0.45-1,1S1.45,13,2,13z M20,13l2,0c0.55,0,1-0.45,1-1 s-0.45-1-1-1l-2,0c-0.55,0-1,0.45-1,1S19.45,13,20,13z M11,2v2c0,0.55,0.45,1,1,1s1-0.45,1-1V2c0-0.55-0.45-1-1-1S11,1.45,11,2z M11,20v2c0,0.55,0.45,1,1,1s1-0.45,1-1v-2c0-0.55-0.45-1-1-1C11.45,19,11,19.45,11,20z M5.99,4.58c-0.39-0.39-1.03-0.39-1.41,0 c-0.39,0.39-0.39,1.03,0,1.41l1.06,1.06c0.39,0.39,1.03,0.39,1.41,0s0.39-1.03,0-1.41L5.99,4.58z M18.36,16.95 c-0.39-0.39-1.03-0.39-1.41,0c-0.39,0.39-0.39,1.03,0,1.41l1.06,1.06c0.39,0.39,1.03,0.39,1.41,0c0.39-0.39,0.39-1.03,0-1.41 L18.36,16.95z M19.42,5.99c0.39-0.39,0.39-1.03,0-1.41c-0.39-0.39-1.03-0.39-1.41,0l-1.06,1.06c-0.39,0.39-0.39,1.03,0,1.41 s1.03,0.39,1.41,0L19.42,5.99z M7.05,18.36c0.39-0.39,0.39-1.03,0-1.41c-0.39-0.39-1.03-0.39-1.41,0l-1.06,1.06 c-0.39,0.39-0.39,1.03,0,1.41s1.03,0.39,1.41,0L7.05,18.36z\"/></svg>`\n    static darkModeIcon = `<svg xmlns=\"http://www.w3.org/2000/svg\" enable-background=\"new 0 0 24 24\" height=\"24px\" viewBox=\"0 0 24 24\" width=\"24px\" fill=\"#FE9700\"><rect fill=\"none\" height=\"24\" width=\"24\"/><path d=\"M9.37,5.51C9.19,6.15,9.1,6.82,9.1,7.5c0,4.08,3.32,7.4,7.4,7.4c0.68,0,1.35-0.09,1.99-0.27 C17.45,17.19,14.93,19,12,19c-3.86,0-7-3.14-7-7C5,9.07,6.81,6.55,9.37,5.51z\" opacity=\".3\"/><path d=\"M9.37,5.51C9.19,6.15,9.1,6.82,9.1,7.5c0,4.08,3.32,7.4,7.4,7.4c0.68,0,1.35-0.09,1.99-0.27C17.45,17.19,14.93,19,12,19 c-3.86,0-7-3.14-7-7C5,9.07,6.81,6.55,9.37,5.51z M12,3c-4.97,0-9,4.03-9,9s4.03,9,9,9s9-4.03,9-9c0-0.46-0.04-0.92-0.1-1.36 c-0.98,1.37-2.58,2.26-4.4,2.26c-2.98,0-5.4-2.42-5.4-5.4c0-1.81,0.89-3.42,2.26-4.4C12.92,3.04,12.46,3,12,3L12,3z\"/></svg>`\n    static title = \"Toggle Light/Dark Mode\"\n\n    static prefersLightModeInDarkModeKey = \"prefers-light-mode-in-dark-mode\"\n    static prefersDarkModeInLightModeKey = \"prefers-dark-mode-in-light-mode\"\n\n    static _staticConstructor = function() {\n        DoxygenAwesomeDarkModeToggle.enableDarkMode(DoxygenAwesomeDarkModeToggle.userPreference)\n        // Update the color scheme when the browsers preference changes\n        // without user interaction on the website.\n        window.matchMedia('(prefers-color-scheme: dark)').addEventListener('change', event => {\n            DoxygenAwesomeDarkModeToggle.onSystemPreferenceChanged()\n        })\n        // Update the color scheme when the tab is made visible again.\n        // It is possible that the appearance was changed in another tab \n        // while this tab was in the background.\n        document.addEventListener(\"visibilitychange\", visibilityState => {\n            if (document.visibilityState === 'visible') {\n                DoxygenAwesomeDarkModeToggle.onSystemPreferenceChanged()\n            }\n        });\n    }()\n\n    static init() {\n        $(function() {\n            $(document).ready(function() {\n                const toggleButton = document.createElement('doxygen-awesome-dark-mode-toggle')\n                toggleButton.title = DoxygenAwesomeDarkModeToggle.title\n                toggleButton.updateIcon()\n\n                window.matchMedia('(prefers-color-scheme: dark)').addEventListener('change', event => {\n                    toggleButton.updateIcon()\n                })\n                document.addEventListener(\"visibilitychange\", visibilityState => {\n                    if (document.visibilityState === 'visible') {\n                        toggleButton.updateIcon()\n                    }\n                });\n\n                $(document).ready(function(){\n                    document.getElementById(\"MSearchBox\").parentNode.appendChild(toggleButton)\n                })\n                $(window).resize(function(){\n                    document.getElementById(\"MSearchBox\").parentNode.appendChild(toggleButton)\n                })\n            })\n        })\n    }\n\n    constructor() {\n        super();\n        this.onclick=this.toggleDarkMode\n    }\n\n    /**\n     * @returns `true` for dark-mode, `false` for light-mode system preference\n     */\n    static get systemPreference() {\n        return window.matchMedia('(prefers-color-scheme: dark)').matches\n    }\n\n    /**\n     * @returns `true` for dark-mode, `false` for light-mode user preference\n     */\n    static get userPreference() {\n        return (!DoxygenAwesomeDarkModeToggle.systemPreference && localStorage.getItem(DoxygenAwesomeDarkModeToggle.prefersDarkModeInLightModeKey)) || \n        (DoxygenAwesomeDarkModeToggle.systemPreference && !localStorage.getItem(DoxygenAwesomeDarkModeToggle.prefersLightModeInDarkModeKey))\n    }\n\n    static set userPreference(userPreference) {\n        DoxygenAwesomeDarkModeToggle.darkModeEnabled = userPreference\n        if(!userPreference) {\n            if(DoxygenAwesomeDarkModeToggle.systemPreference) {\n                localStorage.setItem(DoxygenAwesomeDarkModeToggle.prefersLightModeInDarkModeKey, true)\n            } else {\n                localStorage.removeItem(DoxygenAwesomeDarkModeToggle.prefersDarkModeInLightModeKey)\n            }\n        } else {\n            if(!DoxygenAwesomeDarkModeToggle.systemPreference) {\n                localStorage.setItem(DoxygenAwesomeDarkModeToggle.prefersDarkModeInLightModeKey, true)\n            } else {\n                localStorage.removeItem(DoxygenAwesomeDarkModeToggle.prefersLightModeInDarkModeKey)\n            }\n        }\n        DoxygenAwesomeDarkModeToggle.onUserPreferenceChanged()\n    }\n\n    static enableDarkMode(enable) {\n        if(enable) {\n            DoxygenAwesomeDarkModeToggle.darkModeEnabled = true\n            document.documentElement.classList.add(\"dark-mode\")\n            document.documentElement.classList.remove(\"light-mode\")\n        } else {\n            DoxygenAwesomeDarkModeToggle.darkModeEnabled = false\n            document.documentElement.classList.remove(\"dark-mode\")\n            document.documentElement.classList.add(\"light-mode\")\n        }\n    }\n\n    static onSystemPreferenceChanged() {\n        DoxygenAwesomeDarkModeToggle.darkModeEnabled = DoxygenAwesomeDarkModeToggle.userPreference\n        DoxygenAwesomeDarkModeToggle.enableDarkMode(DoxygenAwesomeDarkModeToggle.darkModeEnabled)\n    }\n\n    static onUserPreferenceChanged() {\n        DoxygenAwesomeDarkModeToggle.enableDarkMode(DoxygenAwesomeDarkModeToggle.darkModeEnabled)\n    }\n\n    toggleDarkMode() {\n        DoxygenAwesomeDarkModeToggle.userPreference = !DoxygenAwesomeDarkModeToggle.userPreference\n        this.updateIcon()\n    }\n\n    updateIcon() {\n        if(DoxygenAwesomeDarkModeToggle.darkModeEnabled) {\n            this.innerHTML = DoxygenAwesomeDarkModeToggle.darkModeIcon\n        } else {\n            this.innerHTML = DoxygenAwesomeDarkModeToggle.lightModeIcon\n        }\n    }\n}\n\ncustomElements.define(\"doxygen-awesome-dark-mode-toggle\", DoxygenAwesomeDarkModeToggle);\n"
  },
  {
    "path": "Administrative/docs/doxygen-awesome.css",
    "content": "/**\n\nDoxygen Awesome\nhttps://github.com/jothepro/doxygen-awesome-css\n\nMIT License\n\nCopyright (c) 2021 - 2023 jothepro\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n\n*/\n\nhtml {\n    /* primary theme color. This will affect the entire websites color scheme: links, arrows, labels, ... */\n    --primary-color: #1779c4;\n    --primary-dark-color: #335c80;\n    --primary-light-color: #70b1e9;\n\n    /* page base colors */\n    --page-background-color: #ffffff;\n    --page-foreground-color: #2f4153;\n    --page-secondary-foreground-color: #6f7e8e;\n\n    /* color for all separators on the website: hr, borders, ... */\n    --separator-color: #dedede;\n\n    /* border radius for all rounded components. Will affect many components, like dropdowns, memitems, codeblocks, ... */\n    --border-radius-large: 8px;\n    --border-radius-small: 4px;\n    --border-radius-medium: 6px;\n\n    /* default spacings. Most components reference these values for spacing, to provide uniform spacing on the page. */\n    --spacing-small: 5px;\n    --spacing-medium: 10px;\n    --spacing-large: 16px;\n\n    /* default box shadow used for raising an element above the normal content. Used in dropdowns, search result, ... */\n    --box-shadow: 0 2px 8px 0 rgba(0,0,0,.075);\n\n    --odd-color: rgba(0,0,0,.028);\n\n    /* font-families. will affect all text on the website\n     * font-family: the normal font for text, headlines, menus\n     * font-family-monospace: used for preformatted text in memtitle, code, fragments\n     */\n    --font-family: -apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen,Ubuntu,Cantarell,Fira Sans,Droid Sans,Helvetica Neue,sans-serif;\n    --font-family-monospace: ui-monospace,SFMono-Regular,SF Mono,Menlo,Consolas,Liberation Mono,monospace;\n\n    /* font sizes */\n    --page-font-size: 15.6px;\n    --navigation-font-size: 14.4px;\n    --toc-font-size: 13.4px;\n    --code-font-size: 14px; /* affects code, fragment */\n    --title-font-size: 22px;\n\n    /* content text properties. These only affect the page content, not the navigation or any other ui elements */\n    --content-line-height: 27px;\n    /* The content is centered and constraint in it's width. To make the content fill the whole page, set the variable to auto.*/\n    --content-maxwidth: 1050px;\n    --table-line-height: 24px;\n    --toc-sticky-top: var(--spacing-medium);\n    --toc-width: 200px;\n    --toc-max-height: calc(100vh - 2 * var(--spacing-medium) - 85px);\n\n    /* colors for various content boxes: @warning, @note, @deprecated @bug */\n    --warning-color: #faf3d8;\n    --warning-color-dark: #f3a600;\n    --warning-color-darker: #5f4204;\n    --note-color: #e4f3ff;\n    --note-color-dark: #1879C4;\n    --note-color-darker: #274a5c;\n    --todo-color: #e4dafd;\n    --todo-color-dark: #5b2bdd;\n    --todo-color-darker: #2a0d72;\n    --deprecated-color: #ecf0f3;\n    --deprecated-color-dark: #5b6269;\n    --deprecated-color-darker: #43454a;\n    --bug-color: #f8d1cc;\n    --bug-color-dark: #b61825;\n    --bug-color-darker: #75070f;\n    --invariant-color: #d8f1e3;\n    --invariant-color-dark: #44b86f;\n    --invariant-color-darker: #265532;\n\n    /* blockquote colors */\n    --blockquote-background: #f8f9fa;\n    --blockquote-foreground: #636568;\n\n    /* table colors */\n    --tablehead-background: #f1f1f1;\n    --tablehead-foreground: var(--page-foreground-color);\n\n    /* menu-display: block | none\n     * Visibility of the top navigation on screens >= 768px. On smaller screen the menu is always visible.\n     * `GENERATE_TREEVIEW` MUST be enabled!\n     */\n    --menu-display: block;\n\n    --menu-focus-foreground: var(--page-background-color);\n    --menu-focus-background: var(--primary-color);\n    --menu-selected-background: rgba(0,0,0,.05);\n\n\n    --header-background: var(--page-background-color);\n    --header-foreground: var(--page-foreground-color);\n\n    /* searchbar colors */\n    --searchbar-background: var(--side-nav-background);\n    --searchbar-foreground: var(--page-foreground-color);\n\n    /* searchbar size\n     * (`searchbar-width` is only applied on screens >= 768px.\n     * on smaller screens the searchbar will always fill the entire screen width) */\n    --searchbar-height: 33px;\n    --searchbar-width: 210px;\n    --searchbar-border-radius: var(--searchbar-height);\n\n    /* code block colors */\n    --code-background: #f5f5f5;\n    --code-foreground: var(--page-foreground-color);\n\n    /* fragment colors */\n    --fragment-background: #F8F9FA;\n    --fragment-foreground: #37474F;\n    --fragment-keyword: #bb6bb2;\n    --fragment-keywordtype: #8258b3;\n    --fragment-keywordflow: #d67c3b;\n    --fragment-token: #438a59;\n    --fragment-comment: #969696;\n    --fragment-link: #5383d6;\n    --fragment-preprocessor: #46aaa5;\n    --fragment-linenumber-color: #797979;\n    --fragment-linenumber-background: #f4f4f5;\n    --fragment-linenumber-border: #e3e5e7;\n    --fragment-lineheight: 20px;\n\n    /* sidebar navigation (treeview) colors */\n    --side-nav-background: #fbfbfb;\n    --side-nav-foreground: var(--page-foreground-color);\n    --side-nav-arrow-opacity: 0;\n    --side-nav-arrow-hover-opacity: 0.9;\n\n    --toc-background: var(--side-nav-background);\n    --toc-foreground: var(--side-nav-foreground);\n\n    /* height of an item in any tree / collapsible table */\n    --tree-item-height: 30px;\n\n    --memname-font-size: var(--code-font-size);\n    --memtitle-font-size: 18px;\n\n    --webkit-scrollbar-size: 7px;\n    --webkit-scrollbar-padding: 4px;\n    --webkit-scrollbar-color: var(--separator-color);\n\n    --animation-duration: .12s\n}\n\n@media screen and (max-width: 767px) {\n    html {\n        --page-font-size: 16px;\n        --navigation-font-size: 16px;\n        --toc-font-size: 15px;\n        --code-font-size: 15px; /* affects code, fragment */\n        --title-font-size: 22px;\n    }\n}\n\n@media (prefers-color-scheme: dark) {\n    html:not(.light-mode) {\n        color-scheme: dark;\n\n        --primary-color: #1982d2;\n        --primary-dark-color: #86a9c4;\n        --primary-light-color: #4779ac;\n\n        --box-shadow: 0 2px 8px 0 rgba(0,0,0,.35);\n\n        --odd-color: rgba(100,100,100,.06);\n\n        --menu-selected-background: rgba(0,0,0,.4);\n\n        --page-background-color: #1C1D1F;\n        --page-foreground-color: #d2dbde;\n        --page-secondary-foreground-color: #859399;\n        --separator-color: #38393b;\n        --side-nav-background: #252628;\n\n        --code-background: #2a2c2f;\n\n        --tablehead-background: #2a2c2f;\n    \n        --blockquote-background: #222325;\n        --blockquote-foreground: #7e8c92;\n\n        --warning-color: #3b2e04;\n        --warning-color-dark: #f1b602;\n        --warning-color-darker: #ceb670;\n        --note-color: #163750;\n        --note-color-dark: #1982D2;\n        --note-color-darker: #dcf0fa;\n        --todo-color: #2a2536;\n        --todo-color-dark: #7661b3;\n        --todo-color-darker: #ae9ed6;\n        --deprecated-color: #2e323b;\n        --deprecated-color-dark: #738396;\n        --deprecated-color-darker: #abb0bd;\n        --bug-color: #2e1917;\n        --bug-color-dark: #ad2617;\n        --bug-color-darker: #f5b1aa;\n        --invariant-color: #303a35;\n        --invariant-color-dark: #76ce96;\n        --invariant-color-darker: #cceed5;\n\n        --fragment-background: #282c34;\n        --fragment-foreground: #dbe4eb;\n        --fragment-keyword: #cc99cd;\n        --fragment-keywordtype: #ab99cd;\n        --fragment-keywordflow: #e08000;\n        --fragment-token: #7ec699;\n        --fragment-comment: #999999;\n        --fragment-link: #98c0e3;\n        --fragment-preprocessor: #65cabe;\n        --fragment-linenumber-color: #cccccc;\n        --fragment-linenumber-background: #35393c;\n        --fragment-linenumber-border: #1f1f1f;\n    }\n}\n\n/* dark mode variables are defined twice, to support both the dark-mode without and with doxygen-awesome-darkmode-toggle.js */\nhtml.dark-mode {\n    color-scheme: dark;\n\n    --primary-color: #1982d2;\n    --primary-dark-color: #86a9c4;\n    --primary-light-color: #4779ac;\n\n    --box-shadow: 0 2px 8px 0 rgba(0,0,0,.30);\n\n    --odd-color: rgba(100,100,100,.06);\n\n    --menu-selected-background: rgba(0,0,0,.4);\n\n    --page-background-color: #1C1D1F;\n    --page-foreground-color: #d2dbde;\n    --page-secondary-foreground-color: #859399;\n    --separator-color: #38393b;\n    --side-nav-background: #252628;\n\n    --code-background: #2a2c2f;\n\n    --tablehead-background: #2a2c2f;\n\n    --blockquote-background: #222325;\n    --blockquote-foreground: #7e8c92;\n\n    --warning-color: #3b2e04;\n    --warning-color-dark: #f1b602;\n    --warning-color-darker: #ceb670;\n    --note-color: #163750;\n    --note-color-dark: #1982D2;\n    --note-color-darker: #dcf0fa;\n    --todo-color: #2a2536;\n    --todo-color-dark: #7661b3;\n    --todo-color-darker: #ae9ed6;\n    --deprecated-color: #2e323b;\n    --deprecated-color-dark: #738396;\n    --deprecated-color-darker: #abb0bd;\n    --bug-color: #2e1917;\n    --bug-color-dark: #ad2617;\n    --bug-color-darker: #f5b1aa;\n    --invariant-color: #303a35;\n    --invariant-color-dark: #76ce96;\n    --invariant-color-darker: #cceed5;\n\n    --fragment-background: #282c34;\n    --fragment-foreground: #dbe4eb;\n    --fragment-keyword: #cc99cd;\n    --fragment-keywordtype: #ab99cd;\n    --fragment-keywordflow: #e08000;\n    --fragment-token: #7ec699;\n    --fragment-comment: #999999;\n    --fragment-link: #98c0e3;\n    --fragment-preprocessor: #65cabe;\n    --fragment-linenumber-color: #cccccc;\n    --fragment-linenumber-background: #35393c;\n    --fragment-linenumber-border: #1f1f1f;\n}\n\nbody {\n    color: var(--page-foreground-color);\n    background-color: var(--page-background-color);\n    font-size: var(--page-font-size);\n}\n\nbody, table, div, p, dl, #nav-tree .label, .title,\n.sm-dox a, .sm-dox a:hover, .sm-dox a:focus, #projectname,\n.SelectItem, #MSearchField, .navpath li.navelem a,\n.navpath li.navelem a:hover, p.reference, p.definition, div.toc li, div.toc h3 {\n    font-family: var(--font-family);\n}\n\nh1, h2, h3, h4, h5 {\n    margin-top: 1em;\n    font-weight: 600;\n    line-height: initial;\n}\n\np, div, table, dl, p.reference, p.definition {\n    font-size: var(--page-font-size);\n}\n\np.reference, p.definition {\n    color: var(--page-secondary-foreground-color);\n}\n\na:link, a:visited, a:hover, a:focus, a:active {\n    color: var(--primary-color) !important;\n    font-weight: 500;\n    background: none;\n}\n\na.anchor {\n    scroll-margin-top: var(--spacing-large);\n    display: block;\n}\n\n/*\n Title and top navigation\n */\n\n#top {\n    background: var(--header-background);\n    border-bottom: 1px solid var(--separator-color);\n}\n\n@media screen and (min-width: 768px) {\n    #top {\n        display: flex;\n        flex-wrap: wrap;\n        justify-content: space-between;\n        align-items: center;\n    }\n}\n\n#main-nav {\n    flex-grow: 5;\n    padding: var(--spacing-small) var(--spacing-medium);\n}\n\n#titlearea {\n    width: auto;\n    padding: var(--spacing-medium) var(--spacing-large);\n    background: none;\n    color: var(--header-foreground);\n    border-bottom: none;\n}\n\n@media screen and (max-width: 767px) {\n    #titlearea {\n        padding-bottom: var(--spacing-small);\n    }\n}\n\n#titlearea table tbody tr {\n    height: auto !important;\n}\n\n#projectname {\n    font-size: var(--title-font-size);\n    font-weight: 600;\n}\n\n#projectnumber {\n    font-family: inherit;\n    font-size: 60%;\n}\n\n#projectbrief {\n    font-family: inherit;\n    font-size: 80%;\n}\n\n#projectlogo {\n    vertical-align: middle;\n}\n\n#projectlogo img {\n    max-height: calc(var(--title-font-size) * 2);\n    margin-right: var(--spacing-small);\n}\n\n.sm-dox, .tabs, .tabs2, .tabs3 {\n    background: none;\n    padding: 0;\n}\n\n.tabs, .tabs2, .tabs3 {\n    border-bottom: 1px solid var(--separator-color);\n    margin-bottom: -1px;\n}\n\n.main-menu-btn-icon, .main-menu-btn-icon:before, .main-menu-btn-icon:after {\n    background: var(--page-secondary-foreground-color);\n}\n\n@media screen and (max-width: 767px) {\n    .sm-dox a span.sub-arrow {\n        background: var(--code-background);\n    }\n\n    #main-menu a.has-submenu span.sub-arrow {\n        color: var(--page-secondary-foreground-color);\n        border-radius: var(--border-radius-medium);\n    }\n\n    #main-menu a.has-submenu:hover span.sub-arrow {\n        color: var(--page-foreground-color);\n    }\n}\n\n@media screen and (min-width: 768px) {\n    .sm-dox li, .tablist li {\n        display: var(--menu-display);\n    }\n\n    .sm-dox a span.sub-arrow {\n        border-color: var(--header-foreground) transparent transparent transparent;\n    }\n\n    .sm-dox a:hover span.sub-arrow {\n        border-color: var(--menu-focus-foreground) transparent transparent transparent;\n    }\n\n    .sm-dox ul a span.sub-arrow {\n        border-color: transparent transparent transparent var(--page-foreground-color);\n    }\n\n    .sm-dox ul a:hover span.sub-arrow {\n        border-color: transparent transparent transparent var(--menu-focus-foreground);\n    }\n}\n\n.sm-dox ul {\n    background: var(--page-background-color);\n    box-shadow: var(--box-shadow);\n    border: 1px solid var(--separator-color);\n    border-radius: var(--border-radius-medium) !important;\n    padding: var(--spacing-small);\n    animation: ease-out 150ms slideInMenu;\n}\n\n@keyframes slideInMenu {\n    from {\n        opacity: 0;\n        transform: translate(0px, -2px);\n    }\n\n    to {\n        opacity: 1;\n        transform: translate(0px, 0px);\n    }\n}\n\n.sm-dox ul a {\n    color: var(--page-foreground-color) !important;\n    background: var(--page-background-color);\n    font-size: var(--navigation-font-size);\n}\n\n.sm-dox>li>ul:after {\n    border-bottom-color: var(--page-background-color) !important;\n}\n\n.sm-dox>li>ul:before {\n    border-bottom-color: var(--separator-color) !important;\n}\n\n.sm-dox ul a:hover, .sm-dox ul a:active, .sm-dox ul a:focus {\n    font-size: var(--navigation-font-size) !important;\n    color: var(--menu-focus-foreground) !important;\n    text-shadow: none;\n    background-color: var(--menu-focus-background);\n    border-radius: var(--border-radius-small) !important;\n}\n\n.sm-dox a, .sm-dox a:focus, .tablist li, .tablist li a, .tablist li.current a {\n    text-shadow: none;\n    background: transparent;\n    background-image: none !important;\n    color: var(--header-foreground) !important;\n    font-weight: normal;\n    font-size: var(--navigation-font-size);\n    border-radius: var(--border-radius-small) !important;\n}\n\n.sm-dox a:focus {\n    outline: auto;\n}\n\n.sm-dox a:hover, .sm-dox a:active, .tablist li a:hover {\n    text-shadow: none;\n    font-weight: normal;\n    background: var(--menu-focus-background);\n    color: var(--menu-focus-foreground) !important;\n    border-radius: var(--border-radius-small) !important;\n    font-size: var(--navigation-font-size);\n}\n\n.tablist li.current {\n    border-radius: var(--border-radius-small);\n    background: var(--menu-selected-background);\n}\n\n.tablist li {\n    margin: var(--spacing-small) 0 var(--spacing-small) var(--spacing-small);\n}\n\n.tablist a {\n    padding: 0 var(--spacing-large);\n}\n\n\n/*\n Search box\n */\n\n#MSearchBox {\n    height: var(--searchbar-height);\n    background: var(--searchbar-background);\n    border-radius: var(--searchbar-border-radius);\n    border: 1px solid var(--separator-color);\n    overflow: hidden;\n    width: var(--searchbar-width);\n    position: relative;\n    box-shadow: none;\n    display: block;\n    margin-top: 0;\n}\n\n/* until Doxygen 1.9.4 */\n.left img#MSearchSelect {\n    left: 0;\n    user-select: none;\n    padding-left: 8px;\n}\n\n/* Doxygen 1.9.5 */\n.left span#MSearchSelect {\n    left: 0;\n    user-select: none;\n    margin-left: 8px;\n    padding: 0;\n}\n\n.left #MSearchSelect[src$=\".png\"] {\n    padding-left: 0\n}\n\n.SelectionMark {\n    user-select: none;\n}\n\n.tabs .left #MSearchSelect {\n    padding-left: 0;\n}\n\n.tabs #MSearchBox {\n    position: absolute;\n    right: var(--spacing-medium);\n}\n\n@media screen and (max-width: 767px) {\n    .tabs #MSearchBox {\n        position: relative;\n        right: 0;\n        margin-left: var(--spacing-medium);\n        margin-top: 0;\n    }\n}\n\n#MSearchSelectWindow, #MSearchResultsWindow {\n    z-index: 9999;\n}\n\n#MSearchBox.MSearchBoxActive {\n    border-color: var(--primary-color);\n    box-shadow: inset 0 0 0 1px var(--primary-color);\n}\n\n#main-menu > li:last-child {\n    margin-right: 0;\n}\n\n@media screen and (max-width: 767px) {\n    #main-menu > li:last-child {\n        height: 50px;\n    }\n}\n\n#MSearchField {\n    font-size: var(--navigation-font-size);\n    height: calc(var(--searchbar-height) - 2px);\n    background: transparent;\n    width: calc(var(--searchbar-width) - 64px);\n}\n\n.MSearchBoxActive #MSearchField {\n    color: var(--searchbar-foreground);\n}\n\n#MSearchSelect {\n    top: calc(calc(var(--searchbar-height) / 2) - 11px);\n}\n\n#MSearchBox span.left, #MSearchBox span.right {\n    background: none;\n    background-image: none;\n}\n\n#MSearchBox span.right {\n    padding-top: calc(calc(var(--searchbar-height) / 2) - 12px);\n    position: absolute;\n    right: var(--spacing-small);\n}\n\n.tabs #MSearchBox span.right {\n    top: calc(calc(var(--searchbar-height) / 2) - 12px);\n}\n\n@keyframes slideInSearchResults {\n    from {\n        opacity: 0;\n        transform: translate(0, 15px);\n    }\n\n    to {\n        opacity: 1;\n        transform: translate(0, 20px);\n    }\n}\n\n#MSearchResultsWindow {\n    left: auto !important;\n    right: var(--spacing-medium);\n    border-radius: var(--border-radius-large);\n    border: 1px solid var(--separator-color);\n    transform: translate(0, 20px);\n    box-shadow: var(--box-shadow);\n    animation: ease-out 280ms slideInSearchResults;\n    background: var(--page-background-color);\n}\n\niframe#MSearchResults {\n    margin: 4px;\n}\n\niframe {\n    color-scheme: normal;\n}\n\n@media (prefers-color-scheme: dark) {\n    html:not(.light-mode) iframe#MSearchResults {\n        filter: invert() hue-rotate(180deg);\n    }\n}\n\nhtml.dark-mode iframe#MSearchResults {\n    filter: invert() hue-rotate(180deg);\n}\n\n#MSearchResults .SRPage {\n    background-color: transparent;\n}\n\n#MSearchResults .SRPage .SREntry {\n    font-size: 10pt;\n    padding: var(--spacing-small) var(--spacing-medium);\n}\n\n#MSearchSelectWindow {\n    border: 1px solid var(--separator-color);\n    border-radius: var(--border-radius-medium);\n    box-shadow: var(--box-shadow);\n    background: var(--page-background-color);\n    padding-top: var(--spacing-small);\n    padding-bottom: var(--spacing-small);\n}\n\n#MSearchSelectWindow a.SelectItem {\n    font-size: var(--navigation-font-size);\n    line-height: var(--content-line-height);\n    margin: 0 var(--spacing-small);\n    border-radius: var(--border-radius-small);\n    color: var(--page-foreground-color) !important;\n    font-weight: normal;\n}\n\n#MSearchSelectWindow a.SelectItem:hover {\n    background: var(--menu-focus-background);\n    color: var(--menu-focus-foreground) !important;\n}\n\n@media screen and (max-width: 767px) {\n    #MSearchBox {\n        margin-top: var(--spacing-medium);\n        margin-bottom: var(--spacing-medium);\n        width: calc(100vw - 30px);\n    }\n\n    #main-menu > li:last-child {\n        float: none !important;\n    }\n\n    #MSearchField {\n        width: calc(100vw - 110px);\n    }\n\n    @keyframes slideInSearchResultsMobile {\n        from {\n            opacity: 0;\n            transform: translate(0, 15px);\n        }\n\n        to {\n            opacity: 1;\n            transform: translate(0, 20px);\n        }\n    }\n\n    #MSearchResultsWindow {\n        left: var(--spacing-medium) !important;\n        right: var(--spacing-medium);\n        overflow: auto;\n        transform: translate(0, 20px);\n        animation: ease-out 280ms slideInSearchResultsMobile;\n        width: auto !important;\n    }\n\n    /*\n     * Overwrites for fixing the searchbox on mobile in doxygen 1.9.2\n     */\n    label.main-menu-btn ~ #searchBoxPos1 {\n        top: 3px !important;\n        right: 6px !important;\n        left: 45px;\n        display: flex;\n    }\n\n    label.main-menu-btn ~ #searchBoxPos1 > #MSearchBox {\n        margin-top: 0;\n        margin-bottom: 0;\n        flex-grow: 2;\n        float: left;\n    }\n}\n\n/*\n Tree view\n */\n\n#side-nav {\n    padding: 0 !important;\n    background: var(--side-nav-background);\n    min-width: 8px;\n    max-width: 50vw;\n}\n\n@media screen and (max-width: 767px) {\n    #side-nav {\n        display: none;\n    }\n\n    #doc-content {\n        margin-left: 0 !important;\n    }\n}\n\n#nav-tree {\n    background: transparent;\n    margin-right: 1px;\n}\n\n#nav-tree .label {\n    font-size: var(--navigation-font-size);\n}\n\n#nav-tree .item {\n    height: var(--tree-item-height);\n    line-height: var(--tree-item-height);\n    overflow: hidden;\n    text-overflow: ellipsis;\n}\n\n#nav-tree .item > a:focus {\n    outline: none;\n}\n\n#nav-sync {\n    bottom: 12px;\n    right: 12px;\n    top: auto !important;\n    user-select: none;\n}\n\n#nav-tree .selected {\n    text-shadow: none;\n    background-image: none;\n    background-color: transparent;\n    position: relative;\n    color: var(--primary-color) !important;\n    font-weight: 500;\n}\n\n#nav-tree .selected::after {\n    content: \"\";\n    position: absolute;\n    top: 1px;\n    bottom: 1px;\n    left: 0;\n    width: 4px;\n    border-radius: 0 var(--border-radius-small) var(--border-radius-small) 0;\n    background: var(--primary-color);\n}\n\n\n#nav-tree a {\n    color: var(--side-nav-foreground) !important;\n    font-weight: normal;\n}\n\n#nav-tree a:focus {\n    outline-style: auto;\n}\n\n#nav-tree .arrow {\n    opacity: var(--side-nav-arrow-opacity);\n    background: none;\n}\n\n.arrow {\n    color: inherit;\n    cursor: pointer;\n    font-size: 45%;\n    vertical-align: middle;\n    margin-right: 2px;\n    font-family: serif;\n    height: auto;\n    text-align: right;\n}\n\n#nav-tree div.item:hover .arrow, #nav-tree a:focus .arrow {\n    opacity: var(--side-nav-arrow-hover-opacity);\n}\n\n#nav-tree .selected a {\n    color: var(--primary-color) !important;\n    font-weight: bolder;\n    font-weight: 600;\n}\n\n.ui-resizable-e {\n    width: 4px;\n    background: transparent;\n    box-shadow: inset -1px 0 0 0 var(--separator-color);\n}\n\n/*\n Contents\n */\n\ndiv.header {\n    border-bottom: 1px solid var(--separator-color);\n    background-color: var(--page-background-color);\n    background-image: none;\n}\n\n@media screen and (min-width: 1000px) {\n    #doc-content > div > div.contents,\n    .PageDoc > div.contents {\n        display: flex;\n        flex-direction: row-reverse;\n        flex-wrap: nowrap;\n        align-items: flex-start;\n    }\n    \n    div.contents .textblock {\n        min-width: 200px;\n        flex-grow: 1;\n    }\n}\n\ndiv.contents, div.header .title, div.header .summary {\n    max-width: var(--content-maxwidth);\n}\n\ndiv.contents, div.header .title  {\n    line-height: initial;\n    margin: calc(var(--spacing-medium) + .2em) auto var(--spacing-medium) auto;\n}\n\ndiv.header .summary {\n    margin: var(--spacing-medium) auto 0 auto;\n}\n\ndiv.headertitle {\n    padding: 0;\n}\n\ndiv.header .title {\n    font-weight: 600;\n    font-size: 225%;\n    padding: var(--spacing-medium) var(--spacing-large);\n    word-break: break-word;\n}\n\ndiv.header .summary {\n    width: auto;\n    display: block;\n    float: none;\n    padding: 0 var(--spacing-large);\n}\n\ntd.memSeparator {\n    border-color: var(--separator-color);\n}\n\nspan.mlabel {\n    background: var(--primary-color);\n    border: none;\n    padding: 4px 9px;\n    border-radius: 12px;\n    margin-right: var(--spacing-medium);\n}\n\nspan.mlabel:last-of-type {\n    margin-right: 2px;\n}\n\ndiv.contents {\n    padding: 0 var(--spacing-large);\n}\n\ndiv.contents p, div.contents li {\n    line-height: var(--content-line-height);\n}\n\ndiv.contents div.dyncontent {\n    margin: var(--spacing-medium) 0;\n}\n\n@media (prefers-color-scheme: dark) {\n    html:not(.light-mode) div.contents div.dyncontent img,\n    html:not(.light-mode) div.contents center img,\n    html:not(.light-mode) div.contents > table img,\n    html:not(.light-mode) div.contents div.dyncontent iframe,\n    html:not(.light-mode) div.contents center iframe,\n    html:not(.light-mode) div.contents table iframe,\n    html:not(.light-mode) div.contents .dotgraph iframe {\n        filter: brightness(89%) hue-rotate(180deg) invert();\n    }\n}\n\nhtml.dark-mode div.contents div.dyncontent img,\nhtml.dark-mode div.contents center img,\nhtml.dark-mode div.contents > table img,\nhtml.dark-mode div.contents div.dyncontent iframe,\nhtml.dark-mode div.contents center iframe,\nhtml.dark-mode div.contents table iframe,\nhtml.dark-mode div.contents .dotgraph iframe\n {\n    filter: brightness(89%) hue-rotate(180deg) invert();\n}\n\nh2.groupheader {\n    border-bottom: 0px;\n    color: var(--page-foreground-color);\n    box-shadow: \n        100px 0 var(--page-background-color), \n        -100px 0 var(--page-background-color),\n        100px 0.75px var(--separator-color),\n        -100px 0.75px var(--separator-color),\n        500px 0 var(--page-background-color), \n        -500px 0 var(--page-background-color),\n        500px 0.75px var(--separator-color),\n        -500px 0.75px var(--separator-color),\n        900px 0 var(--page-background-color), \n        -900px 0 var(--page-background-color),\n        900px 0.75px var(--separator-color),\n        -900px 0.75px var(--separator-color),\n        1400px 0 var(--page-background-color),\n        -1400px 0 var(--page-background-color), \n        1400px 0.75px var(--separator-color),\n        -1400px 0.75px var(--separator-color),\n        1900px 0 var(--page-background-color),\n        -1900px 0 var(--page-background-color),\n        1900px 0.75px var(--separator-color),\n        -1900px 0.75px var(--separator-color);\n}\n\nblockquote {\n    margin: 0 var(--spacing-medium) 0 var(--spacing-medium);\n    padding: var(--spacing-small) var(--spacing-large);\n    background: var(--blockquote-background);\n    color: var(--blockquote-foreground);\n    border-left: 0;\n    overflow: visible;\n    border-radius: var(--border-radius-medium);\n    overflow: visible;\n    position: relative;\n}\n\nblockquote::before, blockquote::after {\n    font-weight: bold;\n    font-family: serif;\n    font-size: 360%;\n    opacity: .15;\n    position: absolute;\n}\n\nblockquote::before {\n    content: \"“\";\n    left: -10px;\n    top: 4px;\n}\n\nblockquote::after {\n    content: \"”\";\n    right: -8px;\n    bottom: -25px;\n}\n\nblockquote p {\n    margin: var(--spacing-small) 0 var(--spacing-medium) 0;\n}\n.paramname, .paramname em {\n    font-weight: 600;\n    color: var(--primary-dark-color);\n}\n\n.paramname > code {\n    border: 0;\n}\n\ntable.params .paramname {\n    font-weight: 600;\n    font-family: var(--font-family-monospace);\n    font-size: var(--code-font-size);\n    padding-right: var(--spacing-small);\n    line-height: var(--table-line-height);\n}\n\nh1.glow, h2.glow, h3.glow, h4.glow, h5.glow, h6.glow {\n    text-shadow: 0 0 15px var(--primary-light-color);\n}\n\n.alphachar a {\n    color: var(--page-foreground-color);\n}\n\n.dotgraph {\n    max-width: 100%;\n    overflow-x: scroll;\n}\n\n.dotgraph .caption {\n    position: sticky;\n    left: 0;\n}\n\n/* Wrap Graphviz graphs with the `interactive_dotgraph` class if `INTERACTIVE_SVG = YES` */\n.interactive_dotgraph .dotgraph iframe {\n    max-width: 100%;\n}\n\n/*\n Table of Contents\n */\n\ndiv.contents .toc {\n    max-height: var(--toc-max-height);\n    min-width: var(--toc-width);\n    border: 0;\n    border-left: 1px solid var(--separator-color);\n    border-radius: 0;\n    background-color: var(--page-background-color);\n    box-shadow: none;\n    position: sticky;\n    top: var(--toc-sticky-top);\n    padding: 0 var(--spacing-large);\n    margin: var(--spacing-small) 0 var(--spacing-large) var(--spacing-large);\n}\n\ndiv.toc h3 {\n    color: var(--toc-foreground);\n    font-size: var(--navigation-font-size);\n    margin: var(--spacing-large) 0 var(--spacing-medium) 0;\n}\n\ndiv.toc li {\n    padding: 0;\n    background: none;\n    line-height: var(--toc-font-size);\n    margin: var(--toc-font-size) 0 0 0;\n}\n\ndiv.toc li::before {\n    display: none;\n}\n\ndiv.toc ul {\n    margin-top: 0\n}\n\ndiv.toc li a {\n    font-size: var(--toc-font-size);\n    color: var(--page-foreground-color) !important;\n    text-decoration: none;\n}\n\ndiv.toc li a:hover, div.toc li a.active {\n    color: var(--primary-color) !important;\n}\n\ndiv.toc li a.aboveActive {\n    color: var(--page-secondary-foreground-color) !important;\n}\n\n\n@media screen and (max-width: 999px) {\n    div.contents .toc {\n        max-height: 45vh;\n        float: none;\n        width: auto;\n        margin: 0 0 var(--spacing-medium) 0;\n        position: relative;\n        top: 0;\n        position: relative;\n        border: 1px solid var(--separator-color);\n        border-radius: var(--border-radius-medium);\n        background-color: var(--toc-background);\n        box-shadow: var(--box-shadow);\n    }\n\n    div.contents .toc.interactive {\n        max-height: calc(var(--navigation-font-size) + 2 * var(--spacing-large));\n        overflow: hidden;\n    }\n\n    div.contents .toc > h3 {\n        -webkit-tap-highlight-color: transparent;\n        cursor: pointer;\n        position: sticky;\n        top: 0;\n        background-color: var(--toc-background);\n        margin: 0;\n        padding: var(--spacing-large) 0;\n        display: block;\n    }\n\n    div.contents .toc.interactive > h3::before {\n        content: \"\";\n        width: 0; \n        height: 0; \n        border-left: 4px solid transparent;\n        border-right: 4px solid transparent;\n        border-top: 5px solid var(--primary-color);\n        display: inline-block;\n        margin-right: var(--spacing-small);\n        margin-bottom: calc(var(--navigation-font-size) / 4);\n        transform: rotate(-90deg);\n        transition: transform var(--animation-duration) ease-out;\n    }\n\n    div.contents .toc.interactive.open > h3::before {\n        transform: rotate(0deg);\n    }\n\n    div.contents .toc.interactive.open {\n        max-height: 45vh;\n        overflow: auto;\n        transition: max-height 0.2s ease-in-out;\n    }\n\n    div.contents .toc a, div.contents .toc a.active {\n        color: var(--primary-color) !important;\n    }\n\n    div.contents .toc a:hover {\n        text-decoration: underline;\n    }\n}\n\n/*\n Code & Fragments\n */\n\ncode, div.fragment, pre.fragment {\n    border-radius: var(--border-radius-small);\n    border: 1px solid var(--separator-color);\n    overflow: hidden;\n}\n\ncode {\n    display: inline;\n    background: var(--code-background);\n    color: var(--code-foreground);\n    padding: 2px 6px;\n}\n\ndiv.fragment, pre.fragment {\n    margin: var(--spacing-medium) 0;\n    padding: calc(var(--spacing-large) - (var(--spacing-large) / 6)) var(--spacing-large);\n    background: var(--fragment-background);\n    color: var(--fragment-foreground);\n    overflow-x: auto;\n}\n\n@media screen and (max-width: 767px) {\n    div.fragment, pre.fragment {\n        border-top-right-radius: 0;\n        border-bottom-right-radius: 0;\n        border-right: 0;\n    }\n\n    .contents > div.fragment,\n    .textblock > div.fragment,\n    .textblock > pre.fragment,\n    .textblock > .tabbed > ul > li > div.fragment,\n    .textblock > .tabbed > ul > li > pre.fragment,\n    .contents > .doxygen-awesome-fragment-wrapper > div.fragment,\n    .textblock > .doxygen-awesome-fragment-wrapper > div.fragment,\n    .textblock > .doxygen-awesome-fragment-wrapper > pre.fragment,\n    .textblock > .tabbed > ul > li > .doxygen-awesome-fragment-wrapper > div.fragment,\n    .textblock > .tabbed > ul > li > .doxygen-awesome-fragment-wrapper > pre.fragment {\n        margin: var(--spacing-medium) calc(0px - var(--spacing-large));\n        border-radius: 0;\n        border-left: 0;\n    }\n\n    .textblock li > .fragment,\n    .textblock li > .doxygen-awesome-fragment-wrapper > .fragment {\n        margin: var(--spacing-medium) calc(0px - var(--spacing-large));\n    }\n\n    .memdoc li > .fragment,\n    .memdoc li > .doxygen-awesome-fragment-wrapper > .fragment {\n        margin: var(--spacing-medium) calc(0px - var(--spacing-medium));\n    }\n\n    .textblock ul, .memdoc ul {\n        overflow: initial;\n    }\n\n    .memdoc > div.fragment,\n    .memdoc > pre.fragment,\n    dl dd > div.fragment,\n    dl dd pre.fragment,\n    .memdoc > .doxygen-awesome-fragment-wrapper > div.fragment,\n    .memdoc > .doxygen-awesome-fragment-wrapper > pre.fragment,\n    dl dd > .doxygen-awesome-fragment-wrapper > div.fragment,\n    dl dd .doxygen-awesome-fragment-wrapper > pre.fragment {\n        margin: var(--spacing-medium) calc(0px - var(--spacing-medium));\n        border-radius: 0;\n        border-left: 0;\n    }\n}\n\ncode, code a, pre.fragment, div.fragment, div.fragment .line, div.fragment span, div.fragment .line a, div.fragment .line span {\n    font-family: var(--font-family-monospace);\n    font-size: var(--code-font-size) !important;\n}\n\ndiv.line:after {\n    margin-right: var(--spacing-medium);\n}\n\ndiv.fragment .line, pre.fragment {\n    white-space: pre;\n    word-wrap: initial;\n    line-height: var(--fragment-lineheight);\n}\n\ndiv.fragment span.keyword {\n    color: var(--fragment-keyword);\n}\n\ndiv.fragment span.keywordtype {\n    color: var(--fragment-keywordtype);\n}\n\ndiv.fragment span.keywordflow {\n    color: var(--fragment-keywordflow);\n}\n\ndiv.fragment span.stringliteral {\n    color: var(--fragment-token)\n}\n\ndiv.fragment span.comment {\n    color: var(--fragment-comment);\n}\n\ndiv.fragment a.code {\n    color: var(--fragment-link) !important;\n}\n\ndiv.fragment span.preprocessor {\n    color: var(--fragment-preprocessor);\n}\n\ndiv.fragment span.lineno {\n    display: inline-block;\n    width: 27px;\n    border-right: none;\n    background: var(--fragment-linenumber-background);\n    color: var(--fragment-linenumber-color);\n}\n\ndiv.fragment span.lineno a {\n    background: none;\n    color: var(--fragment-link) !important;\n}\n\ndiv.fragment > .line:first-child .lineno {\n    box-shadow: -999999px 0px 0 999999px var(--fragment-linenumber-background), -999998px 0px 0 999999px var(--fragment-linenumber-border);\n    background-color: var(--fragment-linenumber-background) !important;\n}\n\ndiv.line {\n    border-radius: var(--border-radius-small);\n}\n\ndiv.line.glow {\n    background-color: var(--primary-light-color);\n    box-shadow: none;\n}\n\n/*\n dl warning, attention, note, deprecated, bug, ...\n */\n\ndl.bug dt a, dl.deprecated dt a, dl.todo dt a {\n    font-weight: bold !important;\n}\n\ndl.warning, dl.attention, dl.note, dl.deprecated, dl.bug, dl.invariant, dl.pre, dl.post, dl.todo, dl.remark {\n    padding: var(--spacing-medium);\n    margin: var(--spacing-medium) 0;\n    color: var(--page-background-color);\n    overflow: hidden;\n    margin-left: 0;\n    border-radius: var(--border-radius-small);\n}\n\ndl.section dd {\n    margin-bottom: 2px;\n}\n\ndl.warning, dl.attention {\n    background: var(--warning-color);\n    border-left: 8px solid var(--warning-color-dark);\n    color: var(--warning-color-darker);\n}\n\ndl.warning dt, dl.attention dt {\n    color: var(--warning-color-dark);\n}\n\ndl.note, dl.remark {\n    background: var(--note-color);\n    border-left: 8px solid var(--note-color-dark);\n    color: var(--note-color-darker);\n}\n\ndl.note dt, dl.remark dt {\n    color: var(--note-color-dark);\n}\n\ndl.todo {\n    background: var(--todo-color);\n    border-left: 8px solid var(--todo-color-dark);\n    color: var(--todo-color-darker);\n}\n\ndl.todo dt a {\n    color: var(--todo-color-dark) !important;\n}\n\ndl.bug dt a {\n    color: var(--todo-color-dark) !important;\n}\n\ndl.bug {\n    background: var(--bug-color);\n    border-left: 8px solid var(--bug-color-dark);\n    color: var(--bug-color-darker);\n}\n\ndl.bug dt a {\n    color: var(--bug-color-dark) !important;\n}\n\ndl.deprecated {\n    background: var(--deprecated-color);\n    border-left: 8px solid var(--deprecated-color-dark);\n    color: var(--deprecated-color-darker);\n}\n\ndl.deprecated dt a {\n    color: var(--deprecated-color-dark) !important;\n}\n\ndl.section dd, dl.bug dd, dl.deprecated dd, dl.todo dd {\n    margin-inline-start: 0px;\n}\n\ndl.invariant, dl.pre, dl.post {\n    background: var(--invariant-color);\n    border-left: 8px solid var(--invariant-color-dark);\n    color: var(--invariant-color-darker);\n}\n\ndl.invariant dt, dl.pre dt, dl.post dt {\n    color: var(--invariant-color-dark);\n}\n\n/*\n memitem\n */\n\ndiv.memdoc, div.memproto, h2.memtitle {\n    box-shadow: none;\n    background-image: none;\n    border: none;\n}\n\ndiv.memdoc {\n    padding: 0 var(--spacing-medium);\n    background: var(--page-background-color);\n}\n\nh2.memtitle, div.memitem {\n    border: 1px solid var(--separator-color);\n    box-shadow: var(--box-shadow);\n}\n\nh2.memtitle {\n    box-shadow: 0px var(--spacing-medium) 0 -1px var(--fragment-background), var(--box-shadow);\n}\n\ndiv.memitem {\n    transition: none;\n}\n\ndiv.memproto, h2.memtitle {\n    background: var(--fragment-background);\n}\n\nh2.memtitle {\n    font-weight: 500;\n    font-size: var(--memtitle-font-size);\n    font-family: var(--font-family-monospace);\n    border-bottom: none;\n    border-top-left-radius: var(--border-radius-medium);\n    border-top-right-radius: var(--border-radius-medium);\n    word-break: break-all;\n    position: relative;\n}\n\nh2.memtitle:after {\n    content: \"\";\n    display: block;\n    background: var(--fragment-background);\n    height: var(--spacing-medium);\n    bottom: calc(0px - var(--spacing-medium));\n    left: 0;\n    right: -14px;\n    position: absolute;\n    border-top-right-radius: var(--border-radius-medium);\n}\n\nh2.memtitle > span.permalink {\n    font-size: inherit;\n}\n\nh2.memtitle > span.permalink > a {\n    text-decoration: none;\n    padding-left: 3px;\n    margin-right: -4px;\n    user-select: none;\n    display: inline-block;\n    margin-top: -6px;\n}\n\nh2.memtitle > span.permalink > a:hover {\n    color: var(--primary-dark-color) !important;\n}\n\na:target + h2.memtitle, a:target + h2.memtitle + div.memitem {\n    border-color: var(--primary-light-color);\n}\n\ndiv.memitem {\n    border-top-right-radius: var(--border-radius-medium);\n    border-bottom-right-radius: var(--border-radius-medium);\n    border-bottom-left-radius: var(--border-radius-medium);\n    overflow: hidden;\n    display: block !important;\n}\n\ndiv.memdoc {\n    border-radius: 0;\n}\n\ndiv.memproto {\n    border-radius: 0 var(--border-radius-small) 0 0;\n    overflow: auto;\n    border-bottom: 1px solid var(--separator-color);\n    padding: var(--spacing-medium);\n    margin-bottom: -1px;\n}\n\ndiv.memtitle {\n    border-top-right-radius: var(--border-radius-medium);\n    border-top-left-radius: var(--border-radius-medium);\n}\n\ndiv.memproto table.memname {\n    font-family: var(--font-family-monospace);\n    color: var(--page-foreground-color);\n    font-size: var(--memname-font-size);\n    text-shadow: none;\n}\n\ndiv.memproto div.memtemplate {\n    font-family: var(--font-family-monospace);\n    color: var(--primary-dark-color);\n    font-size: var(--memname-font-size);\n    margin-left: 2px;\n    text-shadow: none;\n}\n\ntable.mlabels, table.mlabels > tbody {\n    display: block;\n}\n\ntd.mlabels-left {\n    width: auto;\n}\n\ntd.mlabels-right {\n    margin-top: 3px;\n    position: sticky;\n    left: 0;\n}\n\ntable.mlabels > tbody > tr:first-child {\n    display: flex;\n    justify-content: space-between;\n    flex-wrap: wrap;\n}\n\n.memname, .memitem span.mlabels {\n    margin: 0\n}\n\n/*\n reflist\n */\n\ndl.reflist {\n    box-shadow: var(--box-shadow);\n    border-radius: var(--border-radius-medium);\n    border: 1px solid var(--separator-color);\n    overflow: hidden;\n    padding: 0;\n}\n\n\ndl.reflist dt, dl.reflist dd {\n    box-shadow: none;\n    text-shadow: none;\n    background-image: none;\n    border: none;\n    padding: 12px;\n}\n\n\ndl.reflist dt {\n    font-weight: 500;\n    border-radius: 0;\n    background: var(--code-background);\n    border-bottom: 1px solid var(--separator-color);\n    color: var(--page-foreground-color)\n}\n\n\ndl.reflist dd {\n    background: none;\n}\n\n/*\n Table\n */\n\n.contents table:not(.memberdecls):not(.mlabels):not(.fieldtable):not(.memname),\n.contents table:not(.memberdecls):not(.mlabels):not(.fieldtable):not(.memname) tbody {\n    display: inline-block;\n    max-width: 100%;\n}\n\n.contents > table:not(.memberdecls):not(.mlabels):not(.fieldtable):not(.memname):not(.classindex) {\n    margin-left: calc(0px - var(--spacing-large));\n    margin-right: calc(0px - var(--spacing-large));\n    max-width: calc(100% + 2 * var(--spacing-large));\n}\n\ntable.fieldtable,\ntable.markdownTable tbody,\ntable.doxtable tbody {\n    border: none;\n    margin: var(--spacing-medium) 0;\n    box-shadow: 0 0 0 1px var(--separator-color);\n    border-radius: var(--border-radius-small);\n}\n\ntable.markdownTable, table.doxtable, table.fieldtable {\n    padding: 1px;\n}\n\ntable.doxtable caption {\n    display: block;\n}\n\ntable.fieldtable {\n    border-collapse: collapse;\n    width: 100%;\n}\n\nth.markdownTableHeadLeft,\nth.markdownTableHeadRight,\nth.markdownTableHeadCenter,\nth.markdownTableHeadNone,\ntable.doxtable th {\n    background: var(--tablehead-background);\n    color: var(--tablehead-foreground);\n    font-weight: 600;\n    font-size: var(--page-font-size);\n}\n\nth.markdownTableHeadLeft:first-child,\nth.markdownTableHeadRight:first-child,\nth.markdownTableHeadCenter:first-child,\nth.markdownTableHeadNone:first-child,\ntable.doxtable tr th:first-child {\n    border-top-left-radius: var(--border-radius-small);\n}\n\nth.markdownTableHeadLeft:last-child,\nth.markdownTableHeadRight:last-child,\nth.markdownTableHeadCenter:last-child,\nth.markdownTableHeadNone:last-child,\ntable.doxtable tr th:last-child {\n    border-top-right-radius: var(--border-radius-small);\n}\n\ntable.markdownTable td,\ntable.markdownTable th,\ntable.fieldtable td,\ntable.fieldtable th,\ntable.doxtable td,\ntable.doxtable th {\n    border: 1px solid var(--separator-color);\n    padding: var(--spacing-small) var(--spacing-medium);\n}\n\ntable.markdownTable td:last-child,\ntable.markdownTable th:last-child,\ntable.fieldtable td:last-child,\ntable.fieldtable th:last-child,\ntable.doxtable td:last-child,\ntable.doxtable th:last-child {\n    border-right: none;\n}\n\ntable.markdownTable td:first-child,\ntable.markdownTable th:first-child,\ntable.fieldtable td:first-child,\ntable.fieldtable th:first-child,\ntable.doxtable td:first-child,\ntable.doxtable th:first-child {\n    border-left: none;\n}\n\ntable.markdownTable tr:first-child td,\ntable.markdownTable tr:first-child th,\ntable.fieldtable tr:first-child td,\ntable.fieldtable tr:first-child th,\ntable.doxtable tr:first-child td,\ntable.doxtable tr:first-child th {\n    border-top: none;\n}\n\ntable.markdownTable tr:last-child td,\ntable.markdownTable tr:last-child th,\ntable.fieldtable tr:last-child td,\ntable.fieldtable tr:last-child th,\ntable.doxtable tr:last-child td,\ntable.doxtable tr:last-child th {\n    border-bottom: none;\n}\n\ntable.markdownTable tr, table.doxtable tr {\n    border-bottom: 1px solid var(--separator-color);\n}\n\ntable.markdownTable tr:last-child, table.doxtable tr:last-child {\n    border-bottom: none;\n}\n\n.full_width_table table:not(.memberdecls):not(.mlabels):not(.fieldtable):not(.memname) {\n    display: block;\n}\n\n.full_width_table table:not(.memberdecls):not(.mlabels):not(.fieldtable):not(.memname) tbody {\n    display: table;\n    width: 100%;\n}\n\ntable.fieldtable th {\n    font-size: var(--page-font-size);\n    font-weight: 600;\n    background-image: none;\n    background-color: var(--tablehead-background);\n    color: var(--tablehead-foreground);\n}\n\ntable.fieldtable td.fieldtype, .fieldtable td.fieldname, .fieldtable td.fieldinit, .fieldtable td.fielddoc, .fieldtable th {\n    border-bottom: 1px solid var(--separator-color);\n    border-right: 1px solid var(--separator-color);\n}\n\ntable.fieldtable tr:last-child td:first-child {\n    border-bottom-left-radius: var(--border-radius-small);\n}\n\ntable.fieldtable tr:last-child td:last-child {\n    border-bottom-right-radius: var(--border-radius-small);\n}\n\n.memberdecls td.glow, .fieldtable tr.glow {\n    background-color: var(--primary-light-color);\n    box-shadow: none;\n}\n\ntable.memberdecls {\n    display: block;\n    -webkit-tap-highlight-color: transparent;\n}\n\ntable.memberdecls tr[class^='memitem'] {\n    font-family: var(--font-family-monospace);\n    font-size: var(--code-font-size);\n}\n\ntable.memberdecls tr[class^='memitem'] .memTemplParams {\n    font-family: var(--font-family-monospace);\n    font-size: var(--code-font-size);\n    color: var(--primary-dark-color);\n    white-space: normal;\n}\n\ntable.memberdecls .memItemLeft,\ntable.memberdecls .memItemRight,\ntable.memberdecls .memTemplItemLeft,\ntable.memberdecls .memTemplItemRight,\ntable.memberdecls .memTemplParams {\n    transition: none;\n    padding-top: var(--spacing-small);\n    padding-bottom: var(--spacing-small);\n    border-top: 1px solid var(--separator-color);\n    border-bottom: 1px solid var(--separator-color);\n    background-color: var(--fragment-background);\n}\n\ntable.memberdecls .memTemplItemLeft,\ntable.memberdecls .memTemplItemRight {\n    padding-top: 2px;\n}\n\ntable.memberdecls .memTemplParams {\n    border-bottom: 0;\n    border-left: 1px solid var(--separator-color);\n    border-right: 1px solid var(--separator-color);\n    border-radius: var(--border-radius-small) var(--border-radius-small) 0 0;\n    padding-bottom: var(--spacing-small);\n}\n\ntable.memberdecls .memTemplItemLeft {\n    border-radius: 0 0 0 var(--border-radius-small);\n    border-left: 1px solid var(--separator-color);\n    border-top: 0;\n}\n\ntable.memberdecls .memTemplItemRight {\n    border-radius: 0 0 var(--border-radius-small) 0;\n    border-right: 1px solid var(--separator-color);\n    padding-left: 0;\n    border-top: 0;\n}\n\ntable.memberdecls .memItemLeft {\n    border-radius: var(--border-radius-small) 0 0 var(--border-radius-small);\n    border-left: 1px solid var(--separator-color);\n    padding-left: var(--spacing-medium);\n    padding-right: 0;\n}\n\ntable.memberdecls .memItemRight  {\n    border-radius: 0 var(--border-radius-small) var(--border-radius-small) 0;\n    border-right: 1px solid var(--separator-color);\n    padding-right: var(--spacing-medium);\n    padding-left: 0;\n\n}\n\ntable.memberdecls .mdescLeft, table.memberdecls .mdescRight {\n    background: none;\n    color: var(--page-foreground-color);\n    padding: var(--spacing-small) 0;\n}\n\ntable.memberdecls .memItemLeft,\ntable.memberdecls .memTemplItemLeft {\n    padding-right: var(--spacing-medium);\n}\n\ntable.memberdecls .memSeparator {\n    background: var(--page-background-color);\n    height: var(--spacing-large);\n    border: 0;\n    transition: none;\n}\n\ntable.memberdecls .groupheader {\n    margin-bottom: var(--spacing-large);\n}\n\ntable.memberdecls .inherit_header td {\n    padding: 0 0 var(--spacing-medium) 0;\n    text-indent: -12px;\n    color: var(--page-secondary-foreground-color);\n}\n\ntable.memberdecls img[src=\"closed.png\"],\ntable.memberdecls img[src=\"open.png\"],\ndiv.dynheader img[src=\"open.png\"],\ndiv.dynheader img[src=\"closed.png\"] {\n    width: 0; \n    height: 0; \n    border-left: 4px solid transparent;\n    border-right: 4px solid transparent;\n    border-top: 5px solid var(--primary-color);\n    margin-top: 8px;\n    display: block;\n    float: left;\n    margin-left: -10px;\n    transition: transform var(--animation-duration) ease-out;\n}\n\ntable.memberdecls img {\n    margin-right: 10px;\n}\n\ntable.memberdecls img[src=\"closed.png\"],\ndiv.dynheader img[src=\"closed.png\"] {\n    transform: rotate(-90deg);\n    \n}\n\n.compoundTemplParams {\n    font-family: var(--font-family-monospace);\n    color: var(--primary-dark-color);\n    font-size: var(--code-font-size);\n}\n\n@media screen and (max-width: 767px) {\n\n    table.memberdecls .memItemLeft,\n    table.memberdecls .memItemRight,\n    table.memberdecls .mdescLeft,\n    table.memberdecls .mdescRight,\n    table.memberdecls .memTemplItemLeft,\n    table.memberdecls .memTemplItemRight,\n    table.memberdecls .memTemplParams {\n        display: block;\n        text-align: left;\n        padding-left: var(--spacing-large);\n        margin: 0 calc(0px - var(--spacing-large)) 0 calc(0px - var(--spacing-large));\n        border-right: none;\n        border-left: none;\n        border-radius: 0;\n        white-space: normal;\n    }\n\n    table.memberdecls .memItemLeft,\n    table.memberdecls .mdescLeft,\n    table.memberdecls .memTemplItemLeft {\n        border-bottom: 0;\n        padding-bottom: 0;\n    }\n\n    table.memberdecls .memTemplItemLeft {\n        padding-top: 0;\n    }\n\n    table.memberdecls .mdescLeft {\n        margin-bottom: calc(0px - var(--page-font-size));\n    }\n\n    table.memberdecls .memItemRight, \n    table.memberdecls .mdescRight,\n    table.memberdecls .memTemplItemRight {\n        border-top: 0;\n        padding-top: 0;\n        padding-right: var(--spacing-large);\n        overflow-x: auto;\n    }\n\n    table.memberdecls tr[class^='memitem']:not(.inherit) {\n        display: block;\n        width: calc(100vw - 2 * var(--spacing-large));\n    }\n\n    table.memberdecls .mdescRight {\n        color: var(--page-foreground-color);\n    }\n\n    table.memberdecls tr.inherit {\n        visibility: hidden;\n    }\n\n    table.memberdecls tr[style=\"display: table-row;\"] {\n        display: block !important;\n        visibility: visible;\n        width: calc(100vw - 2 * var(--spacing-large));\n        animation: fade .5s;\n    }\n\n    @keyframes fade {\n        0% {\n            opacity: 0;\n            max-height: 0;\n        }\n\n        100% {\n            opacity: 1;\n            max-height: 200px;\n        }\n    }\n}\n\n\n/*\n Horizontal Rule\n */\n\nhr {\n    margin-top: var(--spacing-large);\n    margin-bottom: var(--spacing-large);\n    height: 1px;\n    background-color: var(--separator-color);\n    border: 0;\n}\n\n.contents hr {\n    box-shadow: 100px 0 var(--separator-color),\n                -100px 0 var(--separator-color),\n                500px 0 var(--separator-color),\n                -500px 0 var(--separator-color),\n                900px 0 var(--separator-color),\n                -900px 0 var(--separator-color),\n                1400px 0 var(--separator-color),\n                -1400px 0 var(--separator-color),\n                1900px 0 var(--separator-color),\n                -1900px 0 var(--separator-color);       \n}\n\n.contents img, .contents .center, .contents center, .contents div.image object {\n    max-width: 100%;\n    overflow: auto;\n}\n\n@media screen and (max-width: 767px) {\n    .contents .dyncontent > .center, .contents > center {\n        margin-left: calc(0px - var(--spacing-large));\n        margin-right: calc(0px - var(--spacing-large));\n        max-width: calc(100% + 2 * var(--spacing-large));\n    }\n}\n\n/*\n Directories\n */\ndiv.directory {\n    border-top: 1px solid var(--separator-color);\n    border-bottom: 1px solid var(--separator-color);\n    width: auto;\n}\n\ntable.directory {\n    font-family: var(--font-family);\n    font-size: var(--page-font-size);\n    font-weight: normal;\n    width: 100%;\n}\n\ntable.directory td.entry, table.directory td.desc {\n    padding: calc(var(--spacing-small) / 2) var(--spacing-small);\n    line-height: var(--table-line-height);\n}\n\ntable.directory tr.even td:last-child {\n    border-radius: 0 var(--border-radius-small) var(--border-radius-small) 0;\n}\n\ntable.directory tr.even td:first-child {\n    border-radius: var(--border-radius-small) 0 0 var(--border-radius-small);\n}\n\ntable.directory tr.even:last-child td:last-child {\n    border-radius: 0 var(--border-radius-small) 0 0;\n}\n\ntable.directory tr.even:last-child td:first-child {\n    border-radius: var(--border-radius-small) 0 0 0;\n}\n\ntable.directory td.desc {\n    min-width: 250px;\n}\n\ntable.directory tr.even {\n    background-color: var(--odd-color);\n}\n\ntable.directory tr.odd {\n    background-color: transparent;\n}\n\n.icona {\n    width: auto;\n    height: auto;\n    margin: 0 var(--spacing-small);\n}\n\n.icon {\n    background: var(--primary-color);\n    border-radius: var(--border-radius-small);\n    font-size: var(--page-font-size);\n    padding: calc(var(--page-font-size) / 5);\n    line-height: var(--page-font-size);\n    transform: scale(0.8);\n    height: auto;\n    width: var(--page-font-size);\n    user-select: none;\n}\n\n.iconfopen, .icondoc, .iconfclosed {\n    background-position: center;\n    margin-bottom: 0;\n    height: var(--table-line-height);\n}\n\n.icondoc {\n    filter: saturate(0.2);\n}\n\n@media screen and (max-width: 767px) {\n    div.directory {\n        margin-left: calc(0px - var(--spacing-large));\n        margin-right: calc(0px - var(--spacing-large));\n    }\n}\n\n@media (prefers-color-scheme: dark) {\n    html:not(.light-mode) .iconfopen, html:not(.light-mode) .iconfclosed {\n        filter: hue-rotate(180deg) invert();\n    }\n}\n\nhtml.dark-mode .iconfopen, html.dark-mode .iconfclosed {\n    filter: hue-rotate(180deg) invert();\n}\n\n/*\n Class list\n */\n\n.classindex dl.odd {\n    background: var(--odd-color);\n    border-radius: var(--border-radius-small);\n}\n\n.classindex dl.even {\n    background-color: transparent;\n}\n\n/* \n Class Index Doxygen 1.8 \n*/\n\ntable.classindex {\n    margin-left: 0;\n    margin-right: 0;\n    width: 100%;\n}\n\ntable.classindex table div.ah {\n    background-image: none;\n    background-color: initial;\n    border-color: var(--separator-color);\n    color: var(--page-foreground-color);\n    box-shadow: var(--box-shadow);\n    border-radius: var(--border-radius-large);\n    padding: var(--spacing-small);\n}\n\ndiv.qindex {\n    background-color: var(--odd-color);\n    border-radius: var(--border-radius-small);\n    border: 1px solid var(--separator-color);\n    padding: var(--spacing-small) 0;\n}\n\n/*\n  Footer and nav-path\n */\n\n#nav-path {\n    width: 100%;\n}\n\n#nav-path ul {\n    background-image: none;\n    background: var(--page-background-color);\n    border: none;\n    border-top: 1px solid var(--separator-color);\n    border-bottom: 1px solid var(--separator-color);\n    border-bottom: 0;\n    box-shadow: 0 0.75px 0 var(--separator-color);\n    font-size: var(--navigation-font-size);\n}\n\nimg.footer {\n    width: 60px;\n}\n\n.navpath li.footer {\n    color: var(--page-secondary-foreground-color);\n}\n\naddress.footer {\n    color: var(--page-secondary-foreground-color);\n    margin-bottom: var(--spacing-large);\n}\n\n#nav-path li.navelem {\n    background-image: none;\n    display: flex;\n    align-items: center;\n}\n\n.navpath li.navelem a {\n    text-shadow: none;\n    display: inline-block;\n    color: var(--primary-color) !important;\n}\n\n.navpath li.navelem b {\n    color: var(--primary-dark-color);\n    font-weight: 500;\n}\n\nli.navelem {\n    padding: 0;\n    margin-left: -8px;\n}\n\nli.navelem:first-child {\n    margin-left: var(--spacing-large);\n}\n\nli.navelem:first-child:before {\n    display: none;\n}\n\n#nav-path li.navelem:after {\n    content: '';\n    border: 5px solid var(--page-background-color);\n    border-bottom-color: transparent;\n    border-right-color: transparent;\n    border-top-color: transparent;\n    transform: translateY(-1px) scaleY(4.2);\n    z-index: 10;\n    margin-left: 6px;\n}\n\n#nav-path li.navelem:before {\n    content: '';\n    border: 5px solid var(--separator-color);\n    border-bottom-color: transparent;\n    border-right-color: transparent;\n    border-top-color: transparent;\n    transform: translateY(-1px) scaleY(3.2);\n    margin-right: var(--spacing-small);\n}\n\n.navpath li.navelem a:hover {\n    color: var(--primary-color);\n}\n\n/*\n Scrollbars for Webkit\n*/\n\n#nav-tree::-webkit-scrollbar,\ndiv.fragment::-webkit-scrollbar,\npre.fragment::-webkit-scrollbar,\ndiv.memproto::-webkit-scrollbar,\n.contents center::-webkit-scrollbar,\n.contents .center::-webkit-scrollbar,\n.contents table:not(.memberdecls):not(.mlabels):not(.fieldtable):not(.memname) tbody::-webkit-scrollbar,\ndiv.contents .toc::-webkit-scrollbar,\n.contents .dotgraph::-webkit-scrollbar,\n.contents .tabs-overview-container::-webkit-scrollbar {\n    background: transparent;\n    width: calc(var(--webkit-scrollbar-size) + var(--webkit-scrollbar-padding) + var(--webkit-scrollbar-padding));\n    height: calc(var(--webkit-scrollbar-size) + var(--webkit-scrollbar-padding) + var(--webkit-scrollbar-padding));\n}\n\n#nav-tree::-webkit-scrollbar-thumb,\ndiv.fragment::-webkit-scrollbar-thumb,\npre.fragment::-webkit-scrollbar-thumb,\ndiv.memproto::-webkit-scrollbar-thumb,\n.contents center::-webkit-scrollbar-thumb,\n.contents .center::-webkit-scrollbar-thumb,\n.contents table:not(.memberdecls):not(.mlabels):not(.fieldtable):not(.memname) tbody::-webkit-scrollbar-thumb,\ndiv.contents .toc::-webkit-scrollbar-thumb,\n.contents .dotgraph::-webkit-scrollbar-thumb,\n.contents .tabs-overview-container::-webkit-scrollbar-thumb {\n    background-color: transparent;\n    border: var(--webkit-scrollbar-padding) solid transparent;\n    border-radius: calc(var(--webkit-scrollbar-padding) + var(--webkit-scrollbar-padding));\n    background-clip: padding-box;  \n}\n\n#nav-tree:hover::-webkit-scrollbar-thumb,\ndiv.fragment:hover::-webkit-scrollbar-thumb,\npre.fragment:hover::-webkit-scrollbar-thumb,\ndiv.memproto:hover::-webkit-scrollbar-thumb,\n.contents center:hover::-webkit-scrollbar-thumb,\n.contents .center:hover::-webkit-scrollbar-thumb,\n.contents table:not(.memberdecls):not(.mlabels):not(.fieldtable):not(.memname) tbody:hover::-webkit-scrollbar-thumb,\ndiv.contents .toc:hover::-webkit-scrollbar-thumb,\n.contents .dotgraph:hover::-webkit-scrollbar-thumb,\n.contents .tabs-overview-container:hover::-webkit-scrollbar-thumb {\n    background-color: var(--webkit-scrollbar-color);\n}\n\n#nav-tree::-webkit-scrollbar-track,\ndiv.fragment::-webkit-scrollbar-track,\npre.fragment::-webkit-scrollbar-track,\ndiv.memproto::-webkit-scrollbar-track,\n.contents center::-webkit-scrollbar-track,\n.contents .center::-webkit-scrollbar-track,\n.contents table:not(.memberdecls):not(.mlabels):not(.fieldtable):not(.memname) tbody::-webkit-scrollbar-track,\ndiv.contents .toc::-webkit-scrollbar-track,\n.contents .dotgraph::-webkit-scrollbar-track,\n.contents .tabs-overview-container::-webkit-scrollbar-track {\n    background: transparent;\n}\n\n#nav-tree::-webkit-scrollbar-corner {\n    background-color: var(--side-nav-background);\n}\n\n#nav-tree,\ndiv.fragment,\npre.fragment,\ndiv.memproto,\n.contents center,\n.contents .center,\n.contents table:not(.memberdecls):not(.mlabels):not(.fieldtable):not(.memname) tbody,\ndiv.contents .toc {\n    overflow-x: auto;\n    overflow-x: overlay;\n}\n\n#nav-tree {\n    overflow-x: auto;\n    overflow-y: auto;\n    overflow-y: overlay;\n}\n\n/*\n Scrollbars for Firefox\n*/\n\n#nav-tree,\ndiv.fragment,\npre.fragment,\ndiv.memproto,\n.contents center,\n.contents .center,\n.contents table:not(.memberdecls):not(.mlabels):not(.fieldtable):not(.memname) tbody,\ndiv.contents .toc,\n.contents .dotgraph,\n.contents .tabs-overview-container {\n    scrollbar-width: thin;\n}\n\n/*\n  Optional Dark mode toggle button\n*/\n\ndoxygen-awesome-dark-mode-toggle {\n    display: inline-block;\n    margin: 0 0 0 var(--spacing-small);\n    padding: 0;\n    width: var(--searchbar-height);\n    height: var(--searchbar-height);\n    background: none;\n    border: none;\n    border-radius: var(--searchbar-height);\n    vertical-align: middle;\n    text-align: center;\n    line-height: var(--searchbar-height);\n    font-size: 22px;\n    display: flex;\n    align-items: center;\n    justify-content: center;\n    user-select: none;\n    cursor: pointer;\n}\n\ndoxygen-awesome-dark-mode-toggle > svg {\n    transition: transform var(--animation-duration) ease-in-out;\n}\n\ndoxygen-awesome-dark-mode-toggle:active > svg {\n    transform: scale(.5);\n}\n\ndoxygen-awesome-dark-mode-toggle:hover {\n    background-color: rgba(0,0,0,.03);\n}\n\nhtml.dark-mode doxygen-awesome-dark-mode-toggle:hover {\n    background-color: rgba(0,0,0,.18);\n}\n\n/*\n Optional fragment copy button\n*/\n.doxygen-awesome-fragment-wrapper {\n    position: relative;\n}\n\ndoxygen-awesome-fragment-copy-button {\n    opacity: 0;\n    background: var(--fragment-background);\n    width: 28px;\n    height: 28px;\n    position: absolute;\n    right: calc(var(--spacing-large) - (var(--spacing-large) / 2.5));\n    top: calc(var(--spacing-large) - (var(--spacing-large) / 2.5));\n    border: 1px solid var(--fragment-foreground);\n    cursor: pointer;\n    border-radius: var(--border-radius-small);\n    display: flex;\n    justify-content: center;\n    align-items: center;\n}\n\n.doxygen-awesome-fragment-wrapper:hover doxygen-awesome-fragment-copy-button, doxygen-awesome-fragment-copy-button.success {\n    opacity: .28;\n}\n\ndoxygen-awesome-fragment-copy-button:hover, doxygen-awesome-fragment-copy-button.success {\n    opacity: 1 !important;\n}\n\ndoxygen-awesome-fragment-copy-button:active:not([class~=success]) svg {\n    transform: scale(.91);\n}\n\ndoxygen-awesome-fragment-copy-button svg {\n    fill: var(--fragment-foreground);\n    width: 18px;\n    height: 18px;\n}\n\ndoxygen-awesome-fragment-copy-button.success svg {\n    fill: rgb(14, 168, 14);\n}\n\ndoxygen-awesome-fragment-copy-button.success {\n    border-color: rgb(14, 168, 14);\n}\n\n@media screen and (max-width: 767px) {\n    .textblock > .doxygen-awesome-fragment-wrapper > doxygen-awesome-fragment-copy-button,\n    .textblock li > .doxygen-awesome-fragment-wrapper > doxygen-awesome-fragment-copy-button,\n    .memdoc li > .doxygen-awesome-fragment-wrapper > doxygen-awesome-fragment-copy-button,\n    .memdoc > .doxygen-awesome-fragment-wrapper > doxygen-awesome-fragment-copy-button,\n    dl dd > .doxygen-awesome-fragment-wrapper > doxygen-awesome-fragment-copy-button {\n        right: 0;\n    }\n}\n\n/*\n Optional paragraph link button\n*/\n\na.anchorlink {\n    font-size: 90%;\n    margin-left: var(--spacing-small);\n    color: var(--page-foreground-color) !important;\n    text-decoration: none;\n    opacity: .15;\n    display: none;\n    transition: opacity var(--animation-duration) ease-in-out, color var(--animation-duration) ease-in-out;\n}\n\na.anchorlink svg {\n    fill: var(--page-foreground-color);\n}\n\nh3 a.anchorlink svg, h4 a.anchorlink svg {\n    margin-bottom: -3px;\n    margin-top: -4px;\n}\n\na.anchorlink:hover {\n    opacity: .45;\n}\n\nh2:hover a.anchorlink, h1:hover a.anchorlink, h3:hover a.anchorlink, h4:hover a.anchorlink  {\n    display: inline-block;\n}\n\n/*\n Optional tab feature\n*/\n\n.tabbed > ul {\n    padding-inline-start: 0px;\n    margin: 0;\n    padding: var(--spacing-small) 0;\n}\n\n.tabbed > ul > li {\n    display: none;\n}\n\n.tabbed > ul > li.selected {\n    display: block;\n}\n\n.tabs-overview-container {\n    overflow-x: auto;\n    display: block;\n    overflow-y: visible;\n}\n\n.tabs-overview {\n    border-bottom: 1px solid var(--separator-color);\n    display: flex;\n    flex-direction: row;\n}\n\n@media screen and (max-width: 767px) {\n    .tabs-overview-container {\n        margin: 0 calc(0px - var(--spacing-large));\n    }\n    .tabs-overview {\n        padding: 0 var(--spacing-large)\n    }\n}\n\n.tabs-overview button.tab-button {\n    color: var(--page-foreground-color);\n    margin: 0;\n    border: none;\n    background: transparent;\n    padding: calc(var(--spacing-large) / 2) 0;\n    display: inline-block;\n    font-size: var(--page-font-size);\n    cursor: pointer;\n    box-shadow: 0 1px 0 0 var(--separator-color);\n    position: relative;\n    \n    -webkit-tap-highlight-color: transparent;\n}\n\n.tabs-overview button.tab-button .tab-title::before {\n    display: block;\n    content: attr(title);\n    font-weight: 600;\n    height: 0;\n    overflow: hidden;\n    visibility: hidden;\n}\n\n.tabs-overview button.tab-button .tab-title {\n    float: left;\n    white-space: nowrap;\n    font-weight: normal;\n    padding: calc(var(--spacing-large) / 2) var(--spacing-large);\n    border-radius: var(--border-radius-medium);\n    transition: background-color var(--animation-duration) ease-in-out, font-weight var(--animation-duration) ease-in-out;\n}\n\n.tabs-overview button.tab-button:not(:last-child) .tab-title {\n    box-shadow: 8px 0 0 -7px var(--separator-color);\n}\n\n.tabs-overview button.tab-button:hover .tab-title {\n    background: var(--separator-color);\n    box-shadow: none;\n}\n\n.tabs-overview button.tab-button.active .tab-title {\n    font-weight: 600;\n}\n\n.tabs-overview button.tab-button::after {\n    content: '';\n    display: block;\n    position: absolute;\n    left: 0;\n    bottom: 0;\n    right: 0;\n    height: 0;\n    width: 0%;\n    margin: 0 auto;\n    border-radius: var(--border-radius-small) var(--border-radius-small) 0 0;\n    background-color: var(--primary-color);\n    transition: width var(--animation-duration) ease-in-out, height var(--animation-duration) ease-in-out;\n}\n\n.tabs-overview button.tab-button.active::after {\n    width: 100%;\n    box-sizing: border-box;\n    height: 3px;\n}\n\n\n/*\n Navigation Buttons\n*/\n\n.section_buttons:not(:empty) {\n    margin-top: calc(var(--spacing-large) * 3);\n}\n\n.section_buttons table.markdownTable {\n    display: block;\n    width: 100%;\n}\n\n.section_buttons table.markdownTable tbody {\n    display: table !important;\n    width: 100%;\n    box-shadow: none;\n    border-spacing: 10px;\n}\n\n.section_buttons table.markdownTable td {\n    padding: 0;\n}\n\n.section_buttons table.markdownTable th {\n    display: none;\n}\n\n.section_buttons table.markdownTable tr.markdownTableHead {\n    border: none;\n}\n\n.section_buttons tr th, .section_buttons tr td {\n    background: none;\n    border: none;\n    padding: var(--spacing-large) 0 var(--spacing-small);\n}\n\n.section_buttons a {\n    display: inline-block;\n    border: 1px solid var(--separator-color);\n    border-radius: var(--border-radius-medium);\n    color: var(--page-secondary-foreground-color) !important;\n    text-decoration: none;\n    transition: color var(--animation-duration) ease-in-out, background-color var(--animation-duration) ease-in-out;\n}\n\n.section_buttons a:hover {\n    color: var(--page-foreground-color) !important;\n    background-color: var(--odd-color);\n}\n\n.section_buttons tr td.markdownTableBodyLeft a {\n    padding: var(--spacing-medium) var(--spacing-large) var(--spacing-medium) calc(var(--spacing-large) / 2);\n}\n\n.section_buttons tr td.markdownTableBodyRight a {\n    padding: var(--spacing-medium) calc(var(--spacing-large) / 2) var(--spacing-medium) var(--spacing-large);\n}\n\n.section_buttons tr td.markdownTableBodyLeft a::before,\n.section_buttons tr td.markdownTableBodyRight a::after {\n    color: var(--page-secondary-foreground-color) !important;\n    display: inline-block;\n    transition: color .08s ease-in-out, transform .09s ease-in-out;\n}\n\n.section_buttons tr td.markdownTableBodyLeft a::before {\n    content: '〈';\n    padding-right: var(--spacing-large);\n}\n\n\n.section_buttons tr td.markdownTableBodyRight a::after {\n    content: '〉';\n    padding-left: var(--spacing-large);\n}\n\n\n.section_buttons tr td.markdownTableBodyLeft a:hover::before {\n    color: var(--page-foreground-color) !important;\n    transform: translateX(-3px);\n}\n\n.section_buttons tr td.markdownTableBodyRight a:hover::after {\n    color: var(--page-foreground-color) !important;\n    transform: translateX(3px);\n}\n\n@media screen and (max-width: 450px) {\n    .section_buttons a {\n        width: 100%;\n        box-sizing: border-box;\n    }\n\n    .section_buttons tr td:nth-of-type(1).markdownTableBodyLeft a {\n        border-radius: var(--border-radius-medium) 0 0 var(--border-radius-medium);\n        border-right: none;\n    }\n\n    .section_buttons tr td:nth-of-type(2).markdownTableBodyRight a {\n        border-radius: 0 var(--border-radius-medium) var(--border-radius-medium) 0;\n    }\n}\n"
  },
  {
    "path": "Administrative/docs/header.html",
    "content": "<!-- HTML header for doxygen 1.13.2-->\n<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n<html xmlns=\"http://www.w3.org/1999/xhtml\" lang=\"$langISO\">\n<head>\n<meta http-equiv=\"Content-Type\" content=\"text/xhtml;charset=UTF-8\"/>\n<meta http-equiv=\"X-UA-Compatible\" content=\"IE=11\"/>\n<meta name=\"generator\" content=\"Doxygen $doxygenversion\"/>\n<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\"/>\n<!--BEGIN PROJECT_NAME--><title>$projectname: $title</title><!--END PROJECT_NAME-->\n<!--BEGIN !PROJECT_NAME--><title>$title</title><!--END !PROJECT_NAME-->\n<!--BEGIN PROJECT_ICON-->\n<link rel=\"icon\" href=\"$relpath^$projecticon\" type=\"image/x-icon\" />\n<!--END PROJECT_ICON-->\n<link href=\"$relpath^tabs.css\" rel=\"stylesheet\" type=\"text/css\"/>\n<!--BEGIN DISABLE_INDEX-->\n  <!--BEGIN FULL_SIDEBAR-->\n<script type=\"text/javascript\">var page_layout=1;</script>\n  <!--END FULL_SIDEBAR-->\n<!--END DISABLE_INDEX-->\n<script type=\"text/javascript\" src=\"$relpath^jquery.js\"></script>\n<script type=\"text/javascript\" src=\"$relpath^dynsections.js\"></script>\n<!--BEGIN COPY_CLIPBOARD-->\n<script type=\"text/javascript\" src=\"$relpath^clipboard.js\"></script>\n<!--END COPY_CLIPBOARD-->\n$treeview\n$search\n$mathjax\n$darkmode\n<link href=\"$relpath^$stylesheet\" rel=\"stylesheet\" type=\"text/css\" />\n$extrastylesheet\n<script type=\"text/javascript\" src=\"$relpath^doxygen-awesome-darkmode-toggle.js\"></script>\n<script type=\"text/javascript\">\n    DoxygenAwesomeDarkModeToggle.init()\n</script>\n</head>\n<body>\n<!--BEGIN DISABLE_INDEX-->\n  <!--BEGIN FULL_SIDEBAR-->\n<div id=\"side-nav\" class=\"ui-resizable side-nav-resizable\"><!-- do not remove this div, it is closed by doxygen! -->\n  <!--END FULL_SIDEBAR-->\n<!--END DISABLE_INDEX-->\n\n<div id=\"top\"><!-- do not remove this div, it is closed by doxygen! -->\n\n<!--BEGIN TITLEAREA-->\n<div id=\"titlearea\">\n<table cellspacing=\"0\" cellpadding=\"0\">\n <tbody>\n <tr id=\"projectrow\">\n  <!--BEGIN PROJECT_LOGO-->\n  <td id=\"projectlogo\"><img alt=\"Logo\" src=\"$relpath^$projectlogo\"$logosize/></td>\n  <!--END PROJECT_LOGO-->\n  <!--BEGIN PROJECT_NAME-->\n  <td id=\"projectalign\">\n   <div id=\"projectname\">$projectname<!--BEGIN PROJECT_NUMBER--><span id=\"projectnumber\">&#160;$projectnumber</span><!--END PROJECT_NUMBER-->\n   </div>\n   <!--BEGIN PROJECT_BRIEF--><div id=\"projectbrief\">$projectbrief</div><!--END PROJECT_BRIEF-->\n  </td>\n  <!--END PROJECT_NAME-->\n  <!--BEGIN !PROJECT_NAME-->\n   <!--BEGIN PROJECT_BRIEF-->\n    <td>\n    <div id=\"projectbrief\">$projectbrief</div>\n    </td>\n   <!--END PROJECT_BRIEF-->\n  <!--END !PROJECT_NAME-->\n  <!--BEGIN DISABLE_INDEX-->\n   <!--BEGIN SEARCHENGINE-->\n     <!--BEGIN !FULL_SIDEBAR-->\n    <td>$searchbox</td>\n     <!--END !FULL_SIDEBAR-->\n   <!--END SEARCHENGINE-->\n  <!--END DISABLE_INDEX-->\n </tr>\n  <!--BEGIN SEARCHENGINE-->\n   <!--BEGIN FULL_SIDEBAR-->\n   <tr><td colspan=\"2\">$searchbox</td></tr>\n   <!--END FULL_SIDEBAR-->\n  <!--END SEARCHENGINE-->\n </tbody>\n</table>\n</div>\n<!--END TITLEAREA-->\n<!-- end header part -->\n"
  },
  {
    "path": "Administrative/docs/index.html",
    "content": "<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n    <meta charset=\"UTF-8\">\n    <meta http-equiv=\"refresh\" content=\"0; url=reference-guide/index.html\">\n    <title>Redirecting...</title>\n</head>\n<body>\n    <p>If you are not redirected automatically, <a href=\"reference-guide/index.html\">click here</a>.</p>\n</body>\n</html>"
  },
  {
    "path": "Administrative/releaseFiles/DefaultSettingsWin.ini",
    "content": "[Platform]\r\nPluginsPath=Plugins\r\nHelpPath=Help\r\n\r\n[Library]\r\nLocations=Library\r\nDefaultLocation=Library\r\n\r\n[FilterWidget]\r\nHidden=false\r\n\r\n[Policies]\r\nInstanceNames=$ComponentName$_$InstanceNumber$\r\nHWViewNames=hierarchical, structural\r\nSWViewNames=software\r\nSysViewNames=system\r\n\r\n[Editor]\r\nIndentWidth=4\r\nIndentStyle=1\r\nFont=@Variant(\\0\\0\\0@\\0\\0\\0\\x16\\0\\x43\\0o\\0u\\0r\\0i\\0\\x65\\0r\\0 \\0N\\0\\x65\\0w@$\\0\\0\\0\\0\\0\\0\\xff\\xff\\xff\\xff\\x5\\x1\\0\\x32\\x10)\r\nHighlight\\Keywords=@Variant(\\0\\0\\0\\x7f\\0\\0\\0\\x13HighlightStyleDesc\\0\\x1\\xff\\xff\\0\\0\\0\\0\\xff\\xff\\0\\0\\0\\0)\r\nHighlight\\Preprocessor=@Variant(\\0\\0\\0\\x7f\\0\\0\\0\\x13HighlightStyleDesc\\0\\x1\\xff\\xff\\0\\0\\0\\0\\xff\\xff\\0\\0\\0\\0)\r\nHighlight\\Strings=@Variant(\\0\\0\\0\\x7f\\0\\0\\0\\x13HighlightStyleDesc\\0\\x1\\xff\\xff\\xa3\\xa3\\0\\0\\0\\0\\0\\0\\0\\0)\r\nHighlight\\SinglelineComments=@Variant(\\0\\0\\0\\x7f\\0\\0\\0\\x13HighlightStyleDesc\\0\\x1\\xff\\xff\\0\\0\\xaa\\xaa\\0\\0\\0\\0\\0\\0)\r\nHighlight\\MultilineComments=@Variant(\\0\\0\\0\\x7f\\0\\0\\0\\x13HighlightStyleDesc\\0\\x1\\xff\\xff\\0\\0\\xaa\\xaa\\0\\0\\0\\0\\0\\0)\r\nHighlight\\APITypes=@Variant(\\0\\0\\0\\x7f\\0\\0\\0\\x13HighlightStyleDesc\\0\\x1\\xff\\xff\\0\\0\\0\\0\\xff\\xff\\0\\0\\0\\0)\r\nHighlight\\APIFunc=@Variant(\\0\\0\\0\\x7f\\0\\0\\0\\x13HighlightStyleDesc\\0\\x1\\xff\\xff\\xaa\\xaa\\0\\0\\x7f\\x7f\\0\\0\\x1\\0)\r\n\r\n\r\n[Workspaces]\r\nDefault\\WindowState=@ByteArray(\\0\\0\\0\\xff\\0\\0\\0\\0\\xfd\\0\\0\\0\\x4\\0\\0\\0\\0\\0\\0\\x1H\\0\\0\\x4\\x33\\xfc\\x2\\0\\0\\0\\x2\\xfb\\0\\0\\0\\xe\\0L\\0i\\0\\x62\\0r\\0\\x61\\0r\\0y\\x1\\0\\0\\0g\\0\\0\\x3Y\\0\\0\\x1\\\\\\0\\xff\\xff\\xff\\xfb\\0\\0\\0 \\0\\x43\\0o\\0m\\0p\\0o\\0n\\0\\x65\\0n\\0t\\0P\\0r\\0\\x65\\0v\\0i\\0\\x65\\0w\\x1\\0\\0\\x3\\xc4\\0\\0\\0\\xd6\\0\\0\\0\\x8e\\0\\xff\\xff\\xff\\0\\0\\0\\x1\\0\\0\\x1&\\0\\0\\x4\\x33\\xfc\\x2\\0\\0\\0\\x6\\xfb\\0\\0\\0\\x1e\\0I\\0n\\0s\\0t\\0\\x61\\0n\\0\\x63\\0\\x65\\0 \\0\\x45\\0\\x64\\0i\\0t\\0o\\0r\\0\\0\\0\\0g\\0\\0\\0\\x14\\0\\0\\0\\x14\\0\\0\\0\\x14\\xfb\\0\\0\\0\\\"\\0\\x41\\0\\x64\\0-\\0h\\0o\\0\\x63\\0 \\0V\\0i\\0s\\0i\\0\\x62\\0i\\0l\\0i\\0t\\0y\\0\\0\\0\\0\\x7f\\0\\0\\0\\x14\\0\\0\\0\\x14\\0\\0\\0\\x14\\xfb\\0\\0\\0(\\0\\x43\\0o\\0n\\0\\x66\\0i\\0g\\0u\\0r\\0\\x61\\0t\\0i\\0o\\0n\\0 \\0\\x65\\0\\x64\\0i\\0t\\0o\\0r\\0\\0\\0\\0\\x97\\0\\0\\x2\\xd0\\0\\0\\0\\xc5\\0\\xff\\xff\\xff\\xfb\\0\\0\\0\\x32\\0H\\0W\\0 \\0M\\0\\x61\\0p\\0p\\0i\\0n\\0g\\0 \\0\\x44\\0\\x65\\0t\\0\\x61\\0i\\0l\\0s\\0 \\0\\x45\\0\\x64\\0i\\0t\\0o\\0r\\0\\0\\0\\x3k\\0\\0\\0\\xff\\0\\0\\0\\xff\\0\\xff\\xff\\xff\\xfb\\0\\0\\0 \\0I\\0n\\0t\\0\\x65\\0r\\0\\x66\\0\\x61\\0\\x63\\0\\x65\\0 \\0\\x45\\0\\x64\\0i\\0t\\0o\\0r\\0\\0\\0\\x4n\\0\\0\\0\\x14\\0\\0\\0\\x14\\0\\0\\0\\x14\\xfb\\0\\0\\0\\\"\\0\\x43\\0o\\0n\\0n\\0\\x65\\0\\x63\\0t\\0i\\0o\\0n\\0 \\0\\x45\\0\\x64\\0i\\0t\\0o\\0r\\0\\0\\0\\x4\\x86\\0\\0\\0\\x14\\0\\0\\0\\x14\\0\\0\\0\\x14\\0\\0\\0\\x2\\0\\0\\x6@\\0\\0\\0\\x63\\xfc\\x1\\0\\0\\0\\x1\\xfb\\0\\0\\0\\b\\0M\\0\\x65\\0n\\0u\\x1\\0\\0\\0\\0\\0\\0\\x6@\\0\\0\\0\\0\\0\\xff\\xff\\xff\\0\\0\\0\\x3\\0\\0\\x4\\xf4\\0\\0\\0\\xd6\\xfc\\x1\\0\\0\\0\\x3\\xfb\\0\\0\\0\\f\\0O\\0u\\0t\\0p\\0u\\0t\\x1\\0\\0\\x1L\\0\\0\\x3\\x82\\0\\0\\0P\\0\\xff\\xff\\xff\\xfb\\0\\0\\0\\x18\\0\\x43\\0o\\0n\\0t\\0\\x65\\0x\\0t\\0 \\0H\\0\\x65\\0l\\0p\\x1\\0\\0\\x4\\xd2\\0\\0\\x1n\\0\\0\\0P\\0\\xff\\xff\\xff\\xfb\\0\\0\\0\\x1c\\0\\x41\\0\\x64\\0\\x64\\0r\\0\\x65\\0s\\0s\\0 \\0\\x45\\0\\x64\\0i\\0t\\0o\\0r\\0\\0\\0\\0\\0\\xff\\xff\\xff\\xff\\0\\0\\x1*\\0\\xff\\xff\\xff\\0\\0\\x4\\xf4\\0\\0\\x3Y\\0\\0\\0\\x4\\0\\0\\0\\x4\\0\\0\\0\\x1\\0\\0\\0\\x2\\xfc\\0\\0\\0\\0)\r\nDefault\\Geometry=@ByteArray(\\x1\\xd9\\xd0\\xcb\\0\\x1\\0\\0\\xff\\xff\\xff\\xf8\\xff\\xff\\xff\\xf8\\0\\0\\x6G\\0\\0\\x4\\xb7\\0\\0\\x1 \\0\\0\\0\\xe3\\0\\0\\x5\\x1f\\0\\0\\x3\\xe2\\0\\0\\0\\0\\x2\\0)\r\nDefault\\WindowPosition=@Point(-8 -8)\r\nDefault\\ConfigurationVisibility=true\r\nDefault\\SystemDetailsVisibility=true\r\nDefault\\ConnectionVisibility=true\r\nDefault\\InstanceVisibility=true\r\nDefault\\AdHocVisibility=true\r\nDefault\\AddressVisibility=false\r\nDefault\\InterfaceVisibility=true\r\nDefault\\LibraryVisibility=true\r\nDefault\\OutputVisibility=true\r\nDefault\\ContextHelpVisibility=true\r\nDefault\\PreviewVisibility=true\r\nDesign\\WindowState=@ByteArray(\\0\\0\\0\\xff\\0\\0\\0\\0\\xfd\\0\\0\\0\\x4\\0\\0\\0\\0\\0\\0\\x1H\\0\\0\\x4\\x33\\xfc\\x2\\0\\0\\0\\x2\\xfb\\0\\0\\0\\xe\\0L\\0i\\0\\x62\\0r\\0\\x61\\0r\\0y\\x1\\0\\0\\0g\\0\\0\\x3Y\\0\\0\\x1\\\\\\0\\xff\\xff\\xff\\xfb\\0\\0\\0 \\0\\x43\\0o\\0m\\0p\\0o\\0n\\0\\x65\\0n\\0t\\0P\\0r\\0\\x65\\0v\\0i\\0\\x65\\0w\\x1\\0\\0\\x3\\xc4\\0\\0\\0\\xd6\\0\\0\\0\\x8e\\0\\xff\\xff\\xff\\0\\0\\0\\x1\\0\\0\\x1&\\0\\0\\x4\\x33\\xfc\\x2\\0\\0\\0\\x6\\xfb\\0\\0\\0(\\0\\x43\\0o\\0n\\0\\x66\\0i\\0g\\0u\\0r\\0\\x61\\0t\\0i\\0o\\0n\\0 \\0\\x65\\0\\x64\\0i\\0t\\0o\\0r\\0\\0\\0\\0g\\0\\0\\x1\\xb5\\0\\0\\0\\xc5\\0\\xff\\xff\\xff\\xfb\\0\\0\\0\\x1e\\0I\\0n\\0s\\0t\\0\\x61\\0n\\0\\x63\\0\\x65\\0 \\0\\x45\\0\\x64\\0i\\0t\\0o\\0r\\0\\0\\0\\x2 \\0\\0\\0\\x14\\0\\0\\0\\x14\\0\\0\\0\\x14\\xfb\\0\\0\\0 \\0I\\0n\\0t\\0\\x65\\0r\\0\\x66\\0\\x61\\0\\x63\\0\\x65\\0 \\0\\x45\\0\\x64\\0i\\0t\\0o\\0r\\0\\0\\0\\x2\\x38\\0\\0\\0\\x14\\0\\0\\0\\x14\\0\\0\\0\\x14\\xfb\\0\\0\\0\\\"\\0\\x43\\0o\\0n\\0n\\0\\x65\\0\\x63\\0t\\0i\\0o\\0n\\0 \\0\\x45\\0\\x64\\0i\\0t\\0o\\0r\\0\\0\\0\\x2P\\0\\0\\0\\x14\\0\\0\\0\\x14\\0\\0\\0\\x14\\xfb\\0\\0\\0\\x32\\0H\\0W\\0 \\0M\\0\\x61\\0p\\0p\\0i\\0n\\0g\\0 \\0\\x44\\0\\x65\\0t\\0\\x61\\0i\\0l\\0s\\0 \\0\\x45\\0\\x64\\0i\\0t\\0o\\0r\\0\\0\\0\\x2h\\0\\0\\x2\\x32\\0\\0\\0\\xff\\0\\xff\\xff\\xff\\xfb\\0\\0\\0\\\"\\0\\x41\\0\\x64\\0-\\0h\\0o\\0\\x63\\0 \\0V\\0i\\0s\\0i\\0\\x62\\0i\\0l\\0i\\0t\\0y\\0\\0\\0\\x2\\xe3\\0\\0\\x1\\x87\\0\\0\\0\\x14\\0\\0\\0\\x14\\0\\0\\0\\x2\\0\\0\\x6@\\0\\0\\0\\x63\\xfc\\x1\\0\\0\\0\\x1\\xfb\\0\\0\\0\\b\\0M\\0\\x65\\0n\\0u\\x1\\0\\0\\0\\0\\0\\0\\x6@\\0\\0\\0\\0\\0\\xff\\xff\\xff\\0\\0\\0\\x3\\0\\0\\x4\\xf4\\0\\0\\0\\xd6\\xfc\\x1\\0\\0\\0\\x3\\xfb\\0\\0\\0\\f\\0O\\0u\\0t\\0p\\0u\\0t\\x1\\0\\0\\x1L\\0\\0\\x3&\\0\\0\\0P\\0\\xff\\xff\\xff\\xfb\\0\\0\\0\\x18\\0\\x43\\0o\\0n\\0t\\0\\x65\\0x\\0t\\0 \\0H\\0\\x65\\0l\\0p\\x1\\0\\0\\x4v\\0\\0\\x1\\xca\\0\\0\\0P\\0\\xff\\xff\\xff\\xfb\\0\\0\\0\\x1c\\0\\x41\\0\\x64\\0\\x64\\0r\\0\\x65\\0s\\0s\\0 \\0\\x45\\0\\x64\\0i\\0t\\0o\\0r\\0\\0\\0\\0\\0\\xff\\xff\\xff\\xff\\0\\0\\x1*\\0\\xff\\xff\\xff\\0\\0\\x4\\xf4\\0\\0\\x3Y\\0\\0\\0\\x4\\0\\0\\0\\x4\\0\\0\\0\\x1\\0\\0\\0\\x2\\xfc\\0\\0\\0\\0)\r\nDesign\\Geometry=@ByteArray(\\x1\\xd9\\xd0\\xcb\\0\\x1\\0\\0\\xff\\xff\\xff\\xf8\\xff\\xff\\xff\\xf8\\0\\0\\x6G\\0\\0\\x4\\xb7\\0\\0\\x1 \\0\\0\\0\\xe3\\0\\0\\x5\\x1f\\0\\0\\x3\\xe2\\0\\0\\0\\0\\x2\\0)\r\nDesign\\WindowPosition=@Point(-8 -8)\r\nDesign\\ConfigurationVisibility=true\r\nDesign\\SystemDetailsVisibility=true\r\nDesign\\ConnectionVisibility=true\r\nDesign\\InstanceVisibility=true\r\nDesign\\AdHocVisibility=false\r\nDesign\\AddressVisibility=false\r\nDesign\\InterfaceVisibility=true\r\nDesign\\LibraryVisibility=true\r\nDesign\\OutputVisibility=true\r\nDesign\\ContextHelpVisibility=true\r\nDesign\\PreviewVisibility=true\r\nCurrentWorkspace=Default\r\n"
  },
  {
    "path": "Administrative/releaseFiles/Kactus2.ini",
    "content": "[Platform]\r\nPluginsPath=/usr/share/kactus2/plugins\r\nHelpPath=/usr/share/kactus2/help\r\n\r\n[Library]\r\nLocations=/usr/share/kactus2/library\r\n\r\n[FilterWidget]\r\nHidden=false\r\n\r\n[Policies]\r\nInstanceNames=$ComponentName$_$InstanceNumber$\r\nHWViewNames=hierarchical, structural\r\nSWViewNames=software\r\nSysViewNames=system\r\n\r\n[Editor]\r\nIndentWidth=4\r\nIndentStyle=1\r\nFont=@Variant(\\0\\0\\0@\\0\\0\\0\\x16\\0\\x43\\0o\\0u\\0r\\0i\\0\\x65\\0r\\0 \\0N\\0\\x65\\0w@$\\0\\0\\0\\0\\0\\0\\xff\\xff\\xff\\xff\\x5\\x1\\0\\x32\\x10)\r\nHighlight\\Keywords=@Variant(\\0\\0\\0\\x7f\\0\\0\\0\\x13HighlightStyleDesc\\0\\x1\\xff\\xff\\0\\0\\0\\0\\xff\\xff\\0\\0\\0\\0)\r\nHighlight\\Preprocessor=@Variant(\\0\\0\\0\\x7f\\0\\0\\0\\x13HighlightStyleDesc\\0\\x1\\xff\\xff\\0\\0\\0\\0\\xff\\xff\\0\\0\\0\\0)\r\nHighlight\\Strings=@Variant(\\0\\0\\0\\x7f\\0\\0\\0\\x13HighlightStyleDesc\\0\\x1\\xff\\xff\\xa3\\xa3\\0\\0\\0\\0\\0\\0\\0\\0)\r\nHighlight\\SinglelineComments=@Variant(\\0\\0\\0\\x7f\\0\\0\\0\\x13HighlightStyleDesc\\0\\x1\\xff\\xff\\0\\0\\xaa\\xaa\\0\\0\\0\\0\\0\\0)\r\nHighlight\\MultilineComments=@Variant(\\0\\0\\0\\x7f\\0\\0\\0\\x13HighlightStyleDesc\\0\\x1\\xff\\xff\\0\\0\\xaa\\xaa\\0\\0\\0\\0\\0\\0)\r\nHighlight\\APITypes=@Variant(\\0\\0\\0\\x7f\\0\\0\\0\\x13HighlightStyleDesc\\0\\x1\\xff\\xff\\0\\0\\0\\0\\xff\\xff\\0\\0\\0\\0)\r\nHighlight\\APIFunc=@Variant(\\0\\0\\0\\x7f\\0\\0\\0\\x13HighlightStyleDesc\\0\\x1\\xff\\xff\\xaa\\xaa\\0\\0\\x7f\\x7f\\0\\0\\x1\\0)\r\n\r\n[Workspaces]\r\nDefault\\WindowState=@ByteArray(\\0\\0\\0\\xff\\0\\0\\0\\0\\xfd\\0\\0\\0\\x4\\0\\0\\0\\0\\0\\0\\x1H\\0\\0\\x4\\x33\\xfc\\x2\\0\\0\\0\\x2\\xfb\\0\\0\\0\\xe\\0L\\0i\\0\\x62\\0r\\0\\x61\\0r\\0y\\x1\\0\\0\\0g\\0\\0\\x3Y\\0\\0\\x1\\\\\\0\\xff\\xff\\xff\\xfb\\0\\0\\0 \\0\\x43\\0o\\0m\\0p\\0o\\0n\\0\\x65\\0n\\0t\\0P\\0r\\0\\x65\\0v\\0i\\0\\x65\\0w\\x1\\0\\0\\x3\\xc4\\0\\0\\0\\xd6\\0\\0\\0\\x8e\\0\\xff\\xff\\xff\\0\\0\\0\\x1\\0\\0\\x1&\\0\\0\\x4\\x33\\xfc\\x2\\0\\0\\0\\x6\\xfb\\0\\0\\0\\x1e\\0I\\0n\\0s\\0t\\0\\x61\\0n\\0\\x63\\0\\x65\\0 \\0\\x45\\0\\x64\\0i\\0t\\0o\\0r\\0\\0\\0\\0g\\0\\0\\0\\x14\\0\\0\\0\\x14\\0\\0\\0\\x14\\xfb\\0\\0\\0\\\"\\0\\x41\\0\\x64\\0-\\0h\\0o\\0\\x63\\0 \\0V\\0i\\0s\\0i\\0\\x62\\0i\\0l\\0i\\0t\\0y\\0\\0\\0\\0\\x7f\\0\\0\\0\\x14\\0\\0\\0\\x14\\0\\0\\0\\x14\\xfb\\0\\0\\0(\\0\\x43\\0o\\0n\\0\\x66\\0i\\0g\\0u\\0r\\0\\x61\\0t\\0i\\0o\\0n\\0 \\0\\x65\\0\\x64\\0i\\0t\\0o\\0r\\0\\0\\0\\0\\x97\\0\\0\\x2\\xd0\\0\\0\\0\\xc5\\0\\xff\\xff\\xff\\xfb\\0\\0\\0\\x32\\0H\\0W\\0 \\0M\\0\\x61\\0p\\0p\\0i\\0n\\0g\\0 \\0\\x44\\0\\x65\\0t\\0\\x61\\0i\\0l\\0s\\0 \\0\\x45\\0\\x64\\0i\\0t\\0o\\0r\\0\\0\\0\\x3k\\0\\0\\0\\xff\\0\\0\\0\\xff\\0\\xff\\xff\\xff\\xfb\\0\\0\\0 \\0I\\0n\\0t\\0\\x65\\0r\\0\\x66\\0\\x61\\0\\x63\\0\\x65\\0 \\0\\x45\\0\\x64\\0i\\0t\\0o\\0r\\0\\0\\0\\x4n\\0\\0\\0\\x14\\0\\0\\0\\x14\\0\\0\\0\\x14\\xfb\\0\\0\\0\\\"\\0\\x43\\0o\\0n\\0n\\0\\x65\\0\\x63\\0t\\0i\\0o\\0n\\0 \\0\\x45\\0\\x64\\0i\\0t\\0o\\0r\\0\\0\\0\\x4\\x86\\0\\0\\0\\x14\\0\\0\\0\\x14\\0\\0\\0\\x14\\0\\0\\0\\x2\\0\\0\\x6@\\0\\0\\0\\x63\\xfc\\x1\\0\\0\\0\\x1\\xfb\\0\\0\\0\\b\\0M\\0\\x65\\0n\\0u\\x1\\0\\0\\0\\0\\0\\0\\x6@\\0\\0\\0\\0\\0\\xff\\xff\\xff\\0\\0\\0\\x3\\0\\0\\x4\\xf4\\0\\0\\0\\xd6\\xfc\\x1\\0\\0\\0\\x3\\xfb\\0\\0\\0\\f\\0O\\0u\\0t\\0p\\0u\\0t\\x1\\0\\0\\x1L\\0\\0\\x3\\x82\\0\\0\\0P\\0\\xff\\xff\\xff\\xfb\\0\\0\\0\\x18\\0\\x43\\0o\\0n\\0t\\0\\x65\\0x\\0t\\0 \\0H\\0\\x65\\0l\\0p\\x1\\0\\0\\x4\\xd2\\0\\0\\x1n\\0\\0\\0P\\0\\xff\\xff\\xff\\xfb\\0\\0\\0\\x1c\\0\\x41\\0\\x64\\0\\x64\\0r\\0\\x65\\0s\\0s\\0 \\0\\x45\\0\\x64\\0i\\0t\\0o\\0r\\0\\0\\0\\0\\0\\xff\\xff\\xff\\xff\\0\\0\\x1*\\0\\xff\\xff\\xff\\0\\0\\x4\\xf4\\0\\0\\x3Y\\0\\0\\0\\x4\\0\\0\\0\\x4\\0\\0\\0\\x1\\0\\0\\0\\x2\\xfc\\0\\0\\0\\0)\r\nDefault\\Geometry=@ByteArray(\\x1\\xd9\\xd0\\xcb\\0\\x1\\0\\0\\xff\\xff\\xff\\xf8\\xff\\xff\\xff\\xf8\\0\\0\\x6G\\0\\0\\x4\\xb7\\0\\0\\x1 \\0\\0\\0\\xe3\\0\\0\\x5\\x1f\\0\\0\\x3\\xe2\\0\\0\\0\\0\\x2\\0)\r\nDefault\\WindowPosition=@Point(-8 -8)\r\nDefault\\ConfigurationVisibility=true\r\nDefault\\SystemDetailsVisibility=true\r\nDefault\\ConnectionVisibility=true\r\nDefault\\InstanceVisibility=true\r\nDefault\\AdHocVisibility=true\r\nDefault\\AddressVisibility=false\r\nDefault\\InterfaceVisibility=true\r\nDefault\\LibraryVisibility=true\r\nDefault\\OutputVisibility=true\r\nDefault\\ContextHelpVisibility=true\r\nDefault\\PreviewVisibility=true\r\nDesign\\WindowState=@ByteArray(\\0\\0\\0\\xff\\0\\0\\0\\0\\xfd\\0\\0\\0\\x4\\0\\0\\0\\0\\0\\0\\x1H\\0\\0\\x4\\x33\\xfc\\x2\\0\\0\\0\\x2\\xfb\\0\\0\\0\\xe\\0L\\0i\\0\\x62\\0r\\0\\x61\\0r\\0y\\x1\\0\\0\\0g\\0\\0\\x3Y\\0\\0\\x1\\\\\\0\\xff\\xff\\xff\\xfb\\0\\0\\0 \\0\\x43\\0o\\0m\\0p\\0o\\0n\\0\\x65\\0n\\0t\\0P\\0r\\0\\x65\\0v\\0i\\0\\x65\\0w\\x1\\0\\0\\x3\\xc4\\0\\0\\0\\xd6\\0\\0\\0\\x8e\\0\\xff\\xff\\xff\\0\\0\\0\\x1\\0\\0\\x1&\\0\\0\\x4\\x33\\xfc\\x2\\0\\0\\0\\x6\\xfb\\0\\0\\0(\\0\\x43\\0o\\0n\\0\\x66\\0i\\0g\\0u\\0r\\0\\x61\\0t\\0i\\0o\\0n\\0 \\0\\x65\\0\\x64\\0i\\0t\\0o\\0r\\0\\0\\0\\0g\\0\\0\\x1\\xb5\\0\\0\\0\\xc5\\0\\xff\\xff\\xff\\xfb\\0\\0\\0\\x1e\\0I\\0n\\0s\\0t\\0\\x61\\0n\\0\\x63\\0\\x65\\0 \\0\\x45\\0\\x64\\0i\\0t\\0o\\0r\\0\\0\\0\\x2 \\0\\0\\0\\x14\\0\\0\\0\\x14\\0\\0\\0\\x14\\xfb\\0\\0\\0 \\0I\\0n\\0t\\0\\x65\\0r\\0\\x66\\0\\x61\\0\\x63\\0\\x65\\0 \\0\\x45\\0\\x64\\0i\\0t\\0o\\0r\\0\\0\\0\\x2\\x38\\0\\0\\0\\x14\\0\\0\\0\\x14\\0\\0\\0\\x14\\xfb\\0\\0\\0\\\"\\0\\x43\\0o\\0n\\0n\\0\\x65\\0\\x63\\0t\\0i\\0o\\0n\\0 \\0\\x45\\0\\x64\\0i\\0t\\0o\\0r\\0\\0\\0\\x2P\\0\\0\\0\\x14\\0\\0\\0\\x14\\0\\0\\0\\x14\\xfb\\0\\0\\0\\x32\\0H\\0W\\0 \\0M\\0\\x61\\0p\\0p\\0i\\0n\\0g\\0 \\0\\x44\\0\\x65\\0t\\0\\x61\\0i\\0l\\0s\\0 \\0\\x45\\0\\x64\\0i\\0t\\0o\\0r\\0\\0\\0\\x2h\\0\\0\\x2\\x32\\0\\0\\0\\xff\\0\\xff\\xff\\xff\\xfb\\0\\0\\0\\\"\\0\\x41\\0\\x64\\0-\\0h\\0o\\0\\x63\\0 \\0V\\0i\\0s\\0i\\0\\x62\\0i\\0l\\0i\\0t\\0y\\0\\0\\0\\x2\\xe3\\0\\0\\x1\\x87\\0\\0\\0\\x14\\0\\0\\0\\x14\\0\\0\\0\\x2\\0\\0\\x6@\\0\\0\\0\\x63\\xfc\\x1\\0\\0\\0\\x1\\xfb\\0\\0\\0\\b\\0M\\0\\x65\\0n\\0u\\x1\\0\\0\\0\\0\\0\\0\\x6@\\0\\0\\0\\0\\0\\xff\\xff\\xff\\0\\0\\0\\x3\\0\\0\\x4\\xf4\\0\\0\\0\\xd6\\xfc\\x1\\0\\0\\0\\x3\\xfb\\0\\0\\0\\f\\0O\\0u\\0t\\0p\\0u\\0t\\x1\\0\\0\\x1L\\0\\0\\x3&\\0\\0\\0P\\0\\xff\\xff\\xff\\xfb\\0\\0\\0\\x18\\0\\x43\\0o\\0n\\0t\\0\\x65\\0x\\0t\\0 \\0H\\0\\x65\\0l\\0p\\x1\\0\\0\\x4v\\0\\0\\x1\\xca\\0\\0\\0P\\0\\xff\\xff\\xff\\xfb\\0\\0\\0\\x1c\\0\\x41\\0\\x64\\0\\x64\\0r\\0\\x65\\0s\\0s\\0 \\0\\x45\\0\\x64\\0i\\0t\\0o\\0r\\0\\0\\0\\0\\0\\xff\\xff\\xff\\xff\\0\\0\\x1*\\0\\xff\\xff\\xff\\0\\0\\x4\\xf4\\0\\0\\x3Y\\0\\0\\0\\x4\\0\\0\\0\\x4\\0\\0\\0\\x1\\0\\0\\0\\x2\\xfc\\0\\0\\0\\0)\r\nDesign\\Geometry=@ByteArray(\\x1\\xd9\\xd0\\xcb\\0\\x1\\0\\0\\xff\\xff\\xff\\xf8\\xff\\xff\\xff\\xf8\\0\\0\\x6G\\0\\0\\x4\\xb7\\0\\0\\x1 \\0\\0\\0\\xe3\\0\\0\\x5\\x1f\\0\\0\\x3\\xe2\\0\\0\\0\\0\\x2\\0)\r\nDesign\\WindowPosition=@Point(-8 -8)\r\nDesign\\ConfigurationVisibility=true\r\nDesign\\SystemDetailsVisibility=true\r\nDesign\\ConnectionVisibility=true\r\nDesign\\InstanceVisibility=true\r\nDesign\\AdHocVisibility=false\r\nDesign\\AddressVisibility=false\r\nDesign\\InterfaceVisibility=true\r\nDesign\\LibraryVisibility=true\r\nDesign\\OutputVisibility=true\r\nDesign\\ContextHelpVisibility=true\r\nDesign\\PreviewVisibility=true\r\nCurrentWorkspace=Default\r\n"
  },
  {
    "path": "Administrative/releaseFiles/Library/tut.fi/global.communication/iptlm/1.1/TLMW.1.1.xml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<kactus2:comDefinition xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:ipxact=\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014\" xmlns:kactus2=\"http://kactus2.cs.tut.fi\" xsi:schemaLocation=\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/ http://www.accellera.org/XMLSchema/IPXACT/1685-2014/index.xsd\">\n\t<ipxact:vendor>tut.fi</ipxact:vendor>\n\t<ipxact:library>global.communication</ipxact:library>\n\t<ipxact:name>TLMW</ipxact:name>\n\t<ipxact:version>1.1</ipxact:version>\n\t<kactus2:transferTypes/>\n\t<kactus2:properties>\n\t\t<kactus2:property name=\"max_transfer_size\" required=\"true\" propertyType=\"integer\" defaultValue=\"128\" description=\"Maximum size of a single transfer\"/>\n\t\t<kactus2:property name=\"default_transfer_delay\" required=\"true\" propertyType=\"integer\" defaultValue=\"1\" description=\"Default duration of transfers via port\"/>\n\t\t<kactus2:property name=\"default_transfer_time_unit\" required=\"true\" propertyType=\"time unit\" defaultValue=\"ns\" description=\"Time unit of the delay\"/>\n\t</kactus2:properties>\n\t<ipxact:vendorExtensions/>\n</kactus2:comDefinition>\n"
  },
  {
    "path": "Administrative/releaseFiles/Library/tut.fi/global.communication/mcapi/1.063/mcapi.1.063.xml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<kactus2:comDefinition xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:ipxact=\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014\" xmlns:kactus2=\"http://kactus2.cs.tut.fi\" xsi:schemaLocation=\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/ http://www.accellera.org/XMLSchema/IPXACT/1685-2014/index.xsd\">\n\t<ipxact:vendor>tut.fi</ipxact:vendor>\n\t<ipxact:library>global.communication</ipxact:library>\n\t<ipxact:name>mcapi</ipxact:name>\n\t<ipxact:version>1.063</ipxact:version>\n\t<kactus2:transferTypes>\n\t\t<kactus2:transferType name=\"message\"/>\n\t\t<kactus2:transferType name=\"scalar\"/>\n\t\t<kactus2:transferType name=\"packet\"/>\n\t</kactus2:transferTypes>\n\t<kactus2:properties>\n\t\t<kactus2:property name=\"port_id\" required=\"true\" propertyType=\"integer\" defaultValue=\"0\" description=\"\"/>\n\t\t<kactus2:property name=\"remote_endpoint_name\" required=\"true\" propertyType=\"string\" defaultValue=\"\" description=\"\"/>\n\t\t<kactus2:property name=\"handle_name\" required=\"true\" propertyType=\"string\" defaultValue=\"\" description=\"\"/>\n\t</kactus2:properties>\n\t<ipxact:vendorExtensions/>\n</kactus2:comDefinition>\n"
  },
  {
    "path": "Administrative/releaseFiles/Library/tut.fi/global.communication/mcapi/2.015/mcapi.2.015.xml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<kactus2:comDefinition xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:ipxact=\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014\" xmlns:kactus2=\"http://kactus2.cs.tut.fi\" xsi:schemaLocation=\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/ http://www.accellera.org/XMLSchema/IPXACT/1685-2014/index.xsd\">\n\t<ipxact:vendor>tut.fi</ipxact:vendor>\n\t<ipxact:library>global.communication</ipxact:library>\n\t<ipxact:name>mcapi</ipxact:name>\n\t<ipxact:version>2.015</ipxact:version>\n\t<kactus2:transferTypes>\n\t\t<kactus2:transferType name=\"message\"/>\n\t\t<kactus2:transferType name=\"scalar\"/>\n\t\t<kactus2:transferType name=\"packet\"/>\n\t</kactus2:transferTypes>\n\t<kactus2:properties>\n\t\t<kactus2:property name=\"port_id\" required=\"true\" propertyType=\"integer\" defaultValue=\"0\" description=\"\"/>\n\t\t<kactus2:property name=\"remote_endpoint_name\" required=\"true\" propertyType=\"string\" defaultValue=\"\" description=\"\"/>\n\t\t<kactus2:property name=\"handle_name\" required=\"true\" propertyType=\"string\" defaultValue=\"\" description=\"\"/>\n\t\t<kactus2:property name=\"scalar_size\" required=\"true\" propertyType=\"integer\" defaultValue=\"\" description=\"\"/>\n\t</kactus2:properties>\n\t<ipxact:vendorExtensions/>\n</kactus2:comDefinition>\n"
  },
  {
    "path": "Administrative/releaseFiles/Library/tut.fi/ip.swp.api/IPTLM.apiDef/1.1/TLMW.apiDef.1.1.xml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<kactus2:apiDefinition xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:ipxact=\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014\" xmlns:kactus2=\"http://kactus2.cs.tut.fi\" xsi:schemaLocation=\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/ http://www.accellera.org/XMLSchema/IPXACT/1685-2014/index.xsd\">\n\t<ipxact:vendor>tut.fi</ipxact:vendor>\n\t<ipxact:library>ip.swp.api</ipxact:library>\n\t<ipxact:name>TLMW.apiDef</ipxact:name>\n\t<ipxact:version>1.1</ipxact:version>\n\t<kactus2:comDefinitionRef vendor=\"tut.fi\" library=\"global.communication\" name=\"TLMW\" version=\"1.1\"/>\n\t<kactus2:dataTypes/>\n\t<kactus2:functions/>\n\t<ipxact:vendorExtensions/>\n</kactus2:apiDefinition>\n"
  },
  {
    "path": "Administrative/releaseFiles/Library/tut.fi/ip.swp.api/mcapi.apiDef/1.063/mcapi.apiDef.1.063.xml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<kactus2:apiDefinition xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:ipxact=\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014\" xmlns:kactus2=\"http://kactus2.cs.tut.fi\" xsi:schemaLocation=\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/ http://www.accellera.org/XMLSchema/IPXACT/1685-2014/index.xsd\">\n\t<ipxact:vendor>tut.fi</ipxact:vendor>\n\t<ipxact:library>ip.swp.api</ipxact:library>\n\t<ipxact:name>mcapi.apiDef</ipxact:name>\n\t<ipxact:version>1.063</ipxact:version>\n\t<kactus2:comDefinitionRef vendor=\"tut.fi\" library=\"global.communication\" name=\"mcapi\" version=\"1.063\"/>\n\t<kactus2:dataTypes>\n\t\t<kactus2:dataType name=\"mcapi_int_t\"/>\n\t\t<kactus2:dataType name=\"mcapi_uint_t\"/>\n\t\t<kactus2:dataType name=\"mcapi_uint8_t\"/>\n\t\t<kactus2:dataType name=\"mcapi_uint16_t\"/>\n\t\t<kactus2:dataType name=\"mcapi_uint32_t\"/>\n\t\t<kactus2:dataType name=\"mcapi_uint64_t\"/>\n\t\t<kactus2:dataType name=\"mcapi_boolean_t\"/>\n\t\t<kactus2:dataType name=\"mcapi_endpoint_t\"/>\n\t\t<kactus2:dataType name=\"mcapi_node_t\"/>\n\t\t<kactus2:dataType name=\"mcapi_port_t\"/>\n\t\t<kactus2:dataType name=\"mcapi_version_t\"/>\n\t\t<kactus2:dataType name=\"mcapi_status_t\"/>\n\t\t<kactus2:dataType name=\"mcapi_request_t\"/>\n\t\t<kactus2:dataType name=\"mcapi_priority_t\"/>\n\t\t<kactus2:dataType name=\"mcapi_timeout_t\"/>\n\t\t<kactus2:dataType name=\"mcapi_pktchan_recv_hndl_t\"/>\n\t\t<kactus2:dataType name=\"mcapi_pktchan_send_hndl_t\"/>\n\t\t<kactus2:dataType name=\"mcapi_sclchan_recv_hndl_t\"/>\n\t\t<kactus2:dataType name=\"mcapi_sclchan_send_hndl_t\"/>\n\t</kactus2:dataTypes>\n\t<kactus2:functions>\n\t\t<kactus2:function name=\"mcapi_initialize\" description=\"Initializes the MCAPI implementation.\">\n\t\t\t<kactus2:returnValue type=\"void\" description=\"\"/>\n\t\t\t<kactus2:functionParameter name=\"node_id\" type=\"mcapi_node_t\" transferType=\"\" contentSource=\"\" dependentParamIndex=\"-1\" description=\"Unique node identifier.\"/>\n\t\t\t<kactus2:functionParameter name=\"mcapi_version\" type=\"mcapi_version_t*\" transferType=\"\" contentSource=\"\" dependentParamIndex=\"-1\" description=\"The used MCAPI version.\"/>\n\t\t\t<kactus2:functionParameter name=\"mcapi_status\" type=\"mcapi_status_t*\" transferType=\"\" contentSource=\"\" dependentParamIndex=\"-1\" description=\"Pointer to status variable for checking against errors.\"/>\n\t\t</kactus2:function>\n\t\t<kactus2:function name=\"mcapi_finalize\" description=\"Finalizes the MCAPI implementation.\">\n\t\t\t<kactus2:returnValue type=\"void\" description=\"\"/>\n\t\t\t<kactus2:functionParameter name=\"mcapi_status\" type=\"mcapi_status_t*\" transferType=\"\" contentSource=\"\" dependentParamIndex=\"-1\" description=\"Pointer to status variable for checking against errors.\"/>\n\t\t</kactus2:function>\n\t\t<kactus2:function name=\"mcapi_get_node_id\" description=\"Returns the node number associated with the local node.\">\n\t\t\t<kactus2:returnValue type=\"mcapi_uint_t\" description=\"The node id associated with the local node.\"/>\n\t\t\t<kactus2:functionParameter name=\"mcapi_status\" type=\"mcapi_status_t*\" transferType=\"\" contentSource=\"\" dependentParamIndex=\"-1\" description=\"Pointer to status variable for checking against errors.\"/>\n\t\t</kactus2:function>\n\t\t<kactus2:function name=\"mcapi_create_endpoint\" description=\"Creates an endpoint.\">\n\t\t\t<kactus2:returnValue type=\"mcapi_endpoint_t\" description=\"The created endpoint, if successfull. MCAPI_NULL if errors.\"/>\n\t\t\t<kactus2:functionParameter name=\"port_id\" type=\"mcapi_port_t\" transferType=\"any\" contentSource=\"port_id\" dependentParamIndex=\"-1\" description=\"The port id for the endpoint.\"/>\n\t\t\t<kactus2:functionParameter name=\"mcapi_status\" type=\"mcapi_status_t*\" transferType=\"\" contentSource=\"\" dependentParamIndex=\"-1\" description=\"Pointer to status variable for checking against errors.\"/>\n\t\t</kactus2:function>\n\t\t<kactus2:function name=\"mcapi_get_endpoint_i\" description=\"Obtains the endpoint associated with the given tuple.\">\n\t\t\t<kactus2:returnValue type=\"void\" description=\"\"/>\n\t\t\t<kactus2:functionParameter name=\"node_id\" type=\"mcapi_node_t\" transferType=\"\" contentSource=\"\" dependentParamIndex=\"-1\" description=\"The node id of the node that owns the endpoint being obtained.\"/>\n\t\t\t<kactus2:functionParameter name=\"port_id\" type=\"mcapi_port_t\" transferType=\"\" contentSource=\"\" dependentParamIndex=\"-1\" description=\"The port id of the endpoint to obtain.\"/>\n\t\t\t<kactus2:functionParameter name=\"endpoint\" type=\"mcapi_endpoint_t*\" transferType=\"\" contentSource=\"\" dependentParamIndex=\"-1\" description=\"The retrieved endpoint.\"/>\n\t\t\t<kactus2:functionParameter name=\"request\" type=\"mcapi_request_t*\" transferType=\"\" contentSource=\"\" dependentParamIndex=\"-1\" description=\"Pointer to request status for asynchronous operation.\"/>\n\t\t\t<kactus2:functionParameter name=\"mcapi_status\" type=\"mcapi_status_t*\" transferType=\"\" contentSource=\"\" dependentParamIndex=\"-1\" description=\"Pointer to status variable for checking against errors.\"/>\n\t\t</kactus2:function>\n\t\t<kactus2:function name=\"mcapi_get_endpoint\" description=\"Obtains the endpoint associated with the given tuple.\">\n\t\t\t<kactus2:returnValue type=\"void\" description=\"\"/>\n\t\t\t<kactus2:functionParameter name=\"node_id\" type=\"mcapi_node_t\" transferType=\"\" contentSource=\"\" dependentParamIndex=\"-1\" description=\"The node id of the node that owns the endpoint being obtained.\"/>\n\t\t\t<kactus2:functionParameter name=\"port_id\" type=\"mcapi_port_t\" transferType=\"\" contentSource=\"\" dependentParamIndex=\"-1\" description=\"The port id of the endpoint to obtain.\"/>\n\t\t\t<kactus2:functionParameter name=\"mcapi_status\" type=\"mcapi_status_t*\" transferType=\"\" contentSource=\"\" dependentParamIndex=\"-1\" description=\"Pointer to status variable for checking against errors.\"/>\n\t\t</kactus2:function>\n\t\t<kactus2:function name=\"mcapi_delete_endpoint\" description=\"Deletes an endpoint.\">\n\t\t\t<kactus2:returnValue type=\"void\" description=\"\"/>\n\t\t\t<kactus2:functionParameter name=\"endpoint\" type=\"mcapi_endpoint_t\" transferType=\"\" contentSource=\"Name\" dependentParamIndex=\"-1\" description=\"The endpoint to delete.\"/>\n\t\t\t<kactus2:functionParameter name=\"mcapi_status\" type=\"mcapi_status_t*\" transferType=\"\" contentSource=\"\" dependentParamIndex=\"-1\" description=\"Pointer to status variable for checking against errors.\"/>\n\t\t</kactus2:function>\n\t\t<kactus2:function name=\"mcapi_get_endpoint_attribute\" description=\"Retrieves endpoint attributes.\">\n\t\t\t<kactus2:returnValue type=\"void\" description=\"\"/>\n\t\t\t<kactus2:functionParameter name=\"endpoint\" type=\"mcapi_endpoint_t\" transferType=\"\" contentSource=\"Name\" dependentParamIndex=\"-1\" description=\"The endpoint whose attributes to retrieve.\"/>\n\t\t\t<kactus2:functionParameter name=\"attribute_num\" type=\"mcapi_uint_t\" transferType=\"\" contentSource=\"\" dependentParamIndex=\"-1\" description=\"The attribute number.\"/>\n\t\t\t<kactus2:functionParameter name=\"attribute\" type=\"void*\" transferType=\"\" contentSource=\"\" dependentParamIndex=\"-1\" description=\"The retrieved attribute value.\"/>\n\t\t\t<kactus2:functionParameter name=\"attribute_size\" type=\"size_t\" transferType=\"\" contentSource=\"\" dependentParamIndex=\"-1\" description=\"The size of the retrieved attribute value.\"/>\n\t\t\t<kactus2:functionParameter name=\"mcapi_status\" type=\"mcapi_status_t*\" transferType=\"\" contentSource=\"\" dependentParamIndex=\"-1\" description=\"Pointer to status variable for checking against errors.\"/>\n\t\t</kactus2:function>\n\t\t<kactus2:function name=\"mcapi_set_endpoint_attribute\" description=\"Sets endpoint attributes.\">\n\t\t\t<kactus2:returnValue type=\"void\" description=\"\"/>\n\t\t\t<kactus2:functionParameter name=\"endpoint\" type=\"mcapi_endpoint_t\" transferType=\"\" contentSource=\"Name\" dependentParamIndex=\"-1\" description=\"The endpoint whose attribute to set.\"/>\n\t\t\t<kactus2:functionParameter name=\"attribute_num\" type=\"mcapi_uint_t\" transferType=\"\" contentSource=\"\" dependentParamIndex=\"-1\" description=\"The attribute number.\"/>\n\t\t\t<kactus2:functionParameter name=\"attribute\" type=\"const void*\" transferType=\"\" contentSource=\"\" dependentParamIndex=\"-1\" description=\"The attribute value to set.\"/>\n\t\t\t<kactus2:functionParameter name=\"attribute_size\" type=\"size_t\" transferType=\"\" contentSource=\"\" dependentParamIndex=\"-1\" description=\"The size of the attribute value.\"/>\n\t\t\t<kactus2:functionParameter name=\"mcapi_status\" type=\"mcapi_status_t*\" transferType=\"\" contentSource=\"\" dependentParamIndex=\"-1\" description=\"Pointer to status variable for checking against errors.\"/>\n\t\t</kactus2:function>\n\t\t<kactus2:function name=\"mcapi_msg_send_i\" description=\"Sends a connectionless message from a send endpoint to a receive endpoint.\">\n\t\t\t<kactus2:returnValue type=\"void\" description=\"\"/>\n\t\t\t<kactus2:functionParameter name=\"send_endpoint\" type=\"mcapi_endpoint_t\" transferType=\"message\" comDirection=\"out\" contentSource=\"Name\" dependentParamIndex=\"-1\" description=\"The send endpoint (local).\"/>\n\t\t\t<kactus2:functionParameter name=\"receive_endpoint\" type=\"mcapi_endpoint_t\" transferType=\"message\" comDirection=\"in\" contentSource=\"remote_endpoint_name\" dependentParamIndex=\"0\" description=\"The receive endpoint (remote).\"/>\n\t\t\t<kactus2:functionParameter name=\"buffer\" type=\"void*\" transferType=\"\" contentSource=\"\" dependentParamIndex=\"-1\" description=\"The data to send.\"/>\n\t\t\t<kactus2:functionParameter name=\"buffer_size\" type=\"size_t\" transferType=\"\" contentSource=\"\" dependentParamIndex=\"-1\" description=\"The buffer size in bytes.\"/>\n\t\t\t<kactus2:functionParameter name=\"priority\" type=\"mcapi_priority_t\" transferType=\"\" contentSource=\"\" dependentParamIndex=\"-1\" description=\"The message priority.\"/>\n\t\t\t<kactus2:functionParameter name=\"request\" type=\"mcapi_request_t*\" transferType=\"\" contentSource=\"\" dependentParamIndex=\"-1\" description=\"Pointer to request status for asynchronous operation.\"/>\n\t\t\t<kactus2:functionParameter name=\"mcapi_status\" type=\"mcapi_status_t*\" transferType=\"\" contentSource=\"\" dependentParamIndex=\"-1\" description=\"Pointer to status variable for checking against errors.\"/>\n\t\t</kactus2:function>\n\t\t<kactus2:function name=\"mcapi_msg_send\" description=\"Sends a connectionless message from a send endpoint to a receive endpoint.\">\n\t\t\t<kactus2:returnValue type=\"void\" description=\"\"/>\n\t\t\t<kactus2:functionParameter name=\"send_endpoint\" type=\"mcapi_endpoint_t\" transferType=\"message\" comDirection=\"out\" contentSource=\"Name\" dependentParamIndex=\"-1\" description=\"The send endpoint (local).\"/>\n\t\t\t<kactus2:functionParameter name=\"receive_endpoint\" type=\"mcapi_endpoint_t\" transferType=\"message\" comDirection=\"in\" contentSource=\"remote_endpoint_name\" dependentParamIndex=\"0\" description=\"The receive endpoint (remote).\"/>\n\t\t\t<kactus2:functionParameter name=\"buffer\" type=\"void*\" transferType=\"\" contentSource=\"\" dependentParamIndex=\"-1\" description=\"The data to send.\"/>\n\t\t\t<kactus2:functionParameter name=\"buffer_size\" type=\"size_t\" transferType=\"\" contentSource=\"\" dependentParamIndex=\"-1\" description=\"The buffer size in bytes.\"/>\n\t\t\t<kactus2:functionParameter name=\"priority\" type=\"mcapi_priority_t\" transferType=\"\" contentSource=\"\" dependentParamIndex=\"-1\" description=\"The message priority.\"/>\n\t\t\t<kactus2:functionParameter name=\"mcapi_status\" type=\"mcapi_status_t*\" transferType=\"\" contentSource=\"\" dependentParamIndex=\"-1\" description=\"Pointer to status variable for checking against errors.\"/>\n\t\t</kactus2:function>\n\t\t<kactus2:function name=\"mcapi_msg_recv_i\" description=\"Receives a connectionless message from a receive endpoint.\">\n\t\t\t<kactus2:returnValue type=\"void\" description=\"\"/>\n\t\t\t<kactus2:functionParameter name=\"receive_endpoint\" type=\"mcapi_endpoint_t\" transferType=\"message\" comDirection=\"in\" contentSource=\"Name\" dependentParamIndex=\"-1\" description=\"The receive endpoint (local).\"/>\n\t\t\t<kactus2:functionParameter name=\"buffer\" type=\"void*\" transferType=\"\" contentSource=\"\" dependentParamIndex=\"-1\" description=\"The buffer for incoming data.\"/>\n\t\t\t<kactus2:functionParameter name=\"buffer_size\" type=\"size_t\" transferType=\"\" contentSource=\"\" dependentParamIndex=\"-1\" description=\"The buffer size in bytes.\"/>\n\t\t\t<kactus2:functionParameter name=\"request\" type=\"mcapi_request_t*\" transferType=\"\" contentSource=\"\" dependentParamIndex=\"-1\" description=\"Used to determined if the receive operation has completed.\"/>\n\t\t\t<kactus2:functionParameter name=\"mcapi_status\" type=\"mcapi_status_t*\" transferType=\"\" contentSource=\"\" dependentParamIndex=\"-1\" description=\"Pointer to status variable for checking against errors.\"/>\n\t\t</kactus2:function>\n\t\t<kactus2:function name=\"mcapi_msg_recv\" description=\"Receives a connectionless message from a receive endpoint.\">\n\t\t\t<kactus2:returnValue type=\"void\" description=\"\"/>\n\t\t\t<kactus2:functionParameter name=\"receive_endpoint\" type=\"mcapi_endpoint_t\" transferType=\"message\" comDirection=\"in\" contentSource=\"Name\" dependentParamIndex=\"-1\" description=\"The receive endpoint (local).\"/>\n\t\t\t<kactus2:functionParameter name=\"buffer\" type=\"void*\" transferType=\"\" contentSource=\"\" dependentParamIndex=\"-1\" description=\"The buffer for incoming data.\"/>\n\t\t\t<kactus2:functionParameter name=\"buffer_size\" type=\"size_t\" transferType=\"\" contentSource=\"\" dependentParamIndex=\"-1\" description=\"The buffer size in bytes.\"/>\n\t\t\t<kactus2:functionParameter name=\"received_size\" type=\"size_t*\" transferType=\"\" contentSource=\"\" dependentParamIndex=\"-1\" description=\"The actual size of the received message.\"/>\n\t\t\t<kactus2:functionParameter name=\"mcapi_status\" type=\"mcapi_status_t*\" transferType=\"\" contentSource=\"\" dependentParamIndex=\"-1\" description=\"Pointer to status variable for checking against errors.\"/>\n\t\t</kactus2:function>\n\t\t<kactus2:function name=\"mcapi_msg_available\" description=\"Checks if messages are available on a receive endpoint.\">\n\t\t\t<kactus2:returnValue type=\"mcapi_uint_t\" description=\"The number of messages available.\"/>\n\t\t\t<kactus2:functionParameter name=\"receive_endpoint\" type=\"mcapi_endpoint_t\" transferType=\"message\" comDirection=\"in\" contentSource=\"Name\" dependentParamIndex=\"-1\" description=\"The receive endpoint (local).\"/>\n\t\t\t<kactus2:functionParameter name=\"mcapi_status\" type=\"mcapi_status_t*\" transferType=\"\" contentSource=\"\" dependentParamIndex=\"-1\" description=\"Pointer to status variable for checking against errors.\"/>\n\t\t</kactus2:function>\n\t\t<kactus2:function name=\"mcapi_connect_pktchan_i\" description=\"Connects a pair of endpoints into a unidirectional FIFO channel.\">\n\t\t\t<kactus2:returnValue type=\"void\" description=\"\"/>\n\t\t\t<kactus2:functionParameter name=\"send_endpoint\" type=\"mcapi_endpoint_t\" transferType=\"packet\" comDirection=\"out\" contentSource=\"Name\" dependentParamIndex=\"-1\" description=\"The send endpoint.\"/>\n\t\t\t<kactus2:functionParameter name=\"receive_endpoint\" type=\"mcapi_endpoint_t\" transferType=\"packet\" comDirection=\"in\" contentSource=\"remote_endpoint_name\" dependentParamIndex=\"0\" description=\"The receive endpoint.\"/>\n\t\t\t<kactus2:functionParameter name=\"request\" type=\"mcapi_request_t*\" transferType=\"\" contentSource=\"\" dependentParamIndex=\"-1\" description=\"Pointer to request status for asynchronous operation.\"/>\n\t\t\t<kactus2:functionParameter name=\"mcapi_status\" type=\"mcapi_status_t*\" transferType=\"\" contentSource=\"\" dependentParamIndex=\"-1\" description=\"Pointer to status variable for checking against errors.\"/>\n\t\t</kactus2:function>\n\t\t<kactus2:function name=\"mcapi_open_pktchan_recv_i\" description=\"Creates a typed, local representation of the channel.\">\n\t\t\t<kactus2:returnValue type=\"void\" description=\"\"/>\n\t\t\t<kactus2:functionParameter name=\"recv_handle\" type=\"mcapi_pktchan_recv_hndl_t*\" transferType=\"packet\" comDirection=\"in\" contentSource=\"handle_name\" dependentParamIndex=\"-1\" description=\"The created receive handle.\"/>\n\t\t\t<kactus2:functionParameter name=\"recv_endpoint\" type=\"mcapi_endpoint_t\" transferType=\"packet\" comDirection=\"in\" contentSource=\"Name\" dependentParamIndex=\"0\" description=\"The corresponding receive endpoint.\"/>\n\t\t\t<kactus2:functionParameter name=\"request\" type=\"mcapi_request_t*\" transferType=\"\" contentSource=\"\" dependentParamIndex=\"-1\" description=\"Pointer to request status for asynchronous operation.\"/>\n\t\t\t<kactus2:functionParameter name=\"mcapi_status\" type=\"mcapi_status_t*\" transferType=\"\" contentSource=\"\" dependentParamIndex=\"-1\" description=\"Pointer to status variable for checking against errors.\"/>\n\t\t</kactus2:function>\n\t\t<kactus2:function name=\"mcapi_open_pktchan_send_i\" description=\"Opens the send end of a packet channel.\">\n\t\t\t<kactus2:returnValue type=\"void\" description=\"\"/>\n\t\t\t<kactus2:functionParameter name=\"send_handle\" type=\"mcapi_pktchan_send_hndl_t*\" transferType=\"packet\" comDirection=\"out\" contentSource=\"handle_name\" dependentParamIndex=\"-1\" description=\"The send handle.\"/>\n\t\t\t<kactus2:functionParameter name=\"send_endpoint\" type=\"mcapi_endpoint_t\" transferType=\"packet\" comDirection=\"out\" contentSource=\"Name\" dependentParamIndex=\"0\" description=\"The corresponding send endpoint.\"/>\n\t\t\t<kactus2:functionParameter name=\"request\" type=\"mcapi_request_t*\" transferType=\"\" contentSource=\"\" dependentParamIndex=\"-1\" description=\"Pointer to request status for asynchronous operation.\"/>\n\t\t\t<kactus2:functionParameter name=\"mcapi_status\" type=\"mcapi_status_t*\" transferType=\"\" contentSource=\"\" dependentParamIndex=\"-1\" description=\"Pointer to status variable for checking against errors.\"/>\n\t\t</kactus2:function>\n\t\t<kactus2:function name=\"mcapi_pktchan_send_i\" description=\"Sends a (connected) packet on a channel.\">\n\t\t\t<kactus2:returnValue type=\"void\" description=\"\"/>\n\t\t\t<kactus2:functionParameter name=\"send_handle\" type=\"mcapi_pktchan_send_hndl_t*\" transferType=\"packet\" comDirection=\"out\" contentSource=\"handle_name\" dependentParamIndex=\"-1\" description=\"The send handle.\"/>\n\t\t\t<kactus2:functionParameter name=\"buffer\" type=\"void*\" transferType=\"\" contentSource=\"\" dependentParamIndex=\"-1\" description=\"The buffer containing the data to send.\"/>\n\t\t\t<kactus2:functionParameter name=\"buffer_size\" type=\"size_t\" transferType=\"\" contentSource=\"\" dependentParamIndex=\"-1\" description=\"The buffer size in bytes.\"/>\n\t\t\t<kactus2:functionParameter name=\"request\" type=\"mcapi_request_t*\" transferType=\"\" contentSource=\"\" dependentParamIndex=\"-1\" description=\"Pointer to request status for asynchronous operation.\"/>\n\t\t\t<kactus2:functionParameter name=\"mcapi_status\" type=\"mcapi_status_t*\" transferType=\"\" contentSource=\"\" dependentParamIndex=\"-1\" description=\"Pointer to status variable for checking against errors.\"/>\n\t\t</kactus2:function>\n\t\t<kactus2:function name=\"mcapi_pktchan_send\" description=\"Sends a (connected) packet on a channel.\">\n\t\t\t<kactus2:returnValue type=\"void\" description=\"\"/>\n\t\t\t<kactus2:functionParameter name=\"send_handle\" type=\"mcapi_pktchan_send_hndl_t*\" transferType=\"packet\" comDirection=\"out\" contentSource=\"handle_name\" dependentParamIndex=\"-1\" description=\"The send handle.\"/>\n\t\t\t<kactus2:functionParameter name=\"buffer\" type=\"void*\" transferType=\"\" contentSource=\"\" dependentParamIndex=\"-1\" description=\"The buffer containing the data to send.\"/>\n\t\t\t<kactus2:functionParameter name=\"buffer_size\" type=\"size_t\" transferType=\"\" contentSource=\"\" dependentParamIndex=\"-1\" description=\"The buffer size in bytes.\"/>\n\t\t\t<kactus2:functionParameter name=\"mcapi_status\" type=\"mcapi_status_t*\" transferType=\"\" contentSource=\"\" dependentParamIndex=\"-1\" description=\"Pointer to status variable for checking against errors.\"/>\n\t\t</kactus2:function>\n\t\t<kactus2:function name=\"mcapi_pktchan_recv_i\" description=\"Receives a (connected) packet on a channel.\">\n\t\t\t<kactus2:returnValue type=\"void\" description=\"\"/>\n\t\t\t<kactus2:functionParameter name=\"recv_handle\" type=\"mcapi_pktchan_recv_hndl_t*\" transferType=\"packet\" comDirection=\"in\" contentSource=\"handle_name\" dependentParamIndex=\"-1\" description=\"The receive handle.\"/>\n\t\t\t<kactus2:functionParameter name=\"buffer\" type=\"void**\" transferType=\"\" contentSource=\"\" dependentParamIndex=\"-1\" description=\"Address of the system-supplied buffer containing the incoming data.\"/>\n\t\t\t<kactus2:functionParameter name=\"request\" type=\"mcapi_request_t*\" transferType=\"\" contentSource=\"\" dependentParamIndex=\"-1\" description=\"Pointer to request status for asynchronous operation.\"/>\n\t\t\t<kactus2:functionParameter name=\"mcapi_status\" type=\"mcapi_status_t*\" transferType=\"\" contentSource=\"\" dependentParamIndex=\"-1\" description=\"Pointer to status variable for checking against errors.\"/>\n\t\t</kactus2:function>\n\t\t<kactus2:function name=\"mcapi_pktchan_recv\" description=\"\">\n\t\t\t<kactus2:returnValue type=\"void\" description=\"\"/>\n\t\t\t<kactus2:functionParameter name=\"recv_handle\" type=\"mcapi_pktchan_recv_hndl_t*\" transferType=\"packet\" comDirection=\"in\" contentSource=\"handle_name\" dependentParamIndex=\"-1\" description=\"The receive handle.\"/>\n\t\t\t<kactus2:functionParameter name=\"buffer\" type=\"void**\" transferType=\"\" contentSource=\"\" dependentParamIndex=\"-1\" description=\"Address of the system-supplied buffer containing the incoming data.\"/>\n\t\t\t<kactus2:functionParameter name=\"received_size\" type=\"size_t*\" transferType=\"\" contentSource=\"\" dependentParamIndex=\"-1\" description=\"The actual size of the received packet.\"/>\n\t\t\t<kactus2:functionParameter name=\"mcapi_status\" type=\"mcapi_status_t*\" transferType=\"\" contentSource=\"\" dependentParamIndex=\"-1\" description=\"Pointer to status variable for checking against errors.\"/>\n\t\t</kactus2:function>\n\t\t<kactus2:function name=\"mcapi_pktchan_available\" description=\"Checks if packets are available on a receive endpoint.\">\n\t\t\t<kactus2:returnValue type=\"mcapi_uint_t\" description=\"The number of packets available.\"/>\n\t\t\t<kactus2:functionParameter name=\"recv_handle\" type=\"mcapi_pktchan_recv_hndl_t*\" transferType=\"packet\" comDirection=\"in\" contentSource=\"handle_name\" dependentParamIndex=\"-1\" description=\"The receive handle.\"/>\n\t\t\t<kactus2:functionParameter name=\"mcapi_status\" type=\"mcapi_status_t*\" transferType=\"\" contentSource=\"\" dependentParamIndex=\"-1\" description=\"Pointer to status variable for checking against errors.\"/>\n\t\t</kactus2:function>\n\t\t<kactus2:function name=\"mcapi_pktchan_free\" description=\"Releases a packet buffer obtains from a mcapi_pktchan_recv() call.\">\n\t\t\t<kactus2:returnValue type=\"void\" description=\"\"/>\n\t\t\t<kactus2:functionParameter name=\"buffer\" type=\"void*\" transferType=\"\" contentSource=\"\" dependentParamIndex=\"-1\" description=\"The buffer to free.\"/>\n\t\t\t<kactus2:functionParameter name=\"mcapi_status\" type=\"mcapi_status_t*\" transferType=\"\" contentSource=\"\" dependentParamIndex=\"-1\" description=\"Pointer to status variable for checking against errors.\"/>\n\t\t</kactus2:function>\n\t\t<kactus2:function name=\"mcapi_pktchan_recv_close_i\" description=\"Closes channel on a receive endpoint.\">\n\t\t\t<kactus2:returnValue type=\"void\" description=\"\"/>\n\t\t\t<kactus2:functionParameter name=\"recv_handle\" type=\"mcapi_pktchan_recv_hndl_t*\" transferType=\"packet\" comDirection=\"in\" contentSource=\"handle_name\" dependentParamIndex=\"-1\" description=\"The receive handle.\"/>\n\t\t\t<kactus2:functionParameter name=\"request\" type=\"mcapi_request_t*\" transferType=\"\" contentSource=\"\" dependentParamIndex=\"-1\" description=\"Pointer to request status for asynchronous operation.\"/>\n\t\t\t<kactus2:functionParameter name=\"mcapi_status\" type=\"mcapi_status_t*\" transferType=\"\" contentSource=\"\" dependentParamIndex=\"-1\" description=\"Pointer to status variable for checking against errors.\"/>\n\t\t</kactus2:function>\n\t\t<kactus2:function name=\"mcapi_pktchan_send_close_i\" description=\"Closes channel on a send endpoint.\">\n\t\t\t<kactus2:returnValue type=\"void\" description=\"\"/>\n\t\t\t<kactus2:functionParameter name=\"send_handle\" type=\"mcapi_pktchan_send_hndl_t*\" transferType=\"packet\" comDirection=\"out\" contentSource=\"handle_name\" dependentParamIndex=\"-1\" description=\"The send handle.\"/>\n\t\t\t<kactus2:functionParameter name=\"request\" type=\"mcapi_request_t*\" transferType=\"\" contentSource=\"\" dependentParamIndex=\"-1\" description=\"Pointer to request status for asynchronous operation.\"/>\n\t\t\t<kactus2:functionParameter name=\"mcapi_status\" type=\"mcapi_status_t*\" transferType=\"\" contentSource=\"\" dependentParamIndex=\"-1\" description=\"Pointer to status variable for checking against errors.\"/>\n\t\t</kactus2:function>\n\t\t<kactus2:function name=\"mcapi_connect_sclchan_i\" description=\"Connects a pair of scalar channel endpoints.\">\n\t\t\t<kactus2:returnValue type=\"void\" description=\"\"/>\n\t\t\t<kactus2:functionParameter name=\"send_endpoint\" type=\"mcapi_endpoint_t\" transferType=\"scalar\" comDirection=\"out\" contentSource=\"Name\" dependentParamIndex=\"-1\" description=\"The send endpoint.\"/>\n\t\t\t<kactus2:functionParameter name=\"receive_endpoint\" type=\"mcapi_endpoint_t\" transferType=\"scalar\" comDirection=\"in\" contentSource=\"remote_endpoint_name\" dependentParamIndex=\"0\" description=\"The receive endpoint.\"/>\n\t\t\t<kactus2:functionParameter name=\"request\" type=\"mcapi_request_t*\" transferType=\"\" contentSource=\"\" dependentParamIndex=\"-1\" description=\"Pointer to request status for asynchronous operation.\"/>\n\t\t\t<kactus2:functionParameter name=\"mcapi_status\" type=\"mcapi_status_t*\" transferType=\"\" contentSource=\"\" dependentParamIndex=\"-1\" description=\"Pointer to status variable for checking against errors.\"/>\n\t\t</kactus2:function>\n\t\t<kactus2:function name=\"mcapi_open_sclchan_recv_i\" description=\"Creates a typed, local representation of a scalar channel.\">\n\t\t\t<kactus2:returnValue type=\"void\" description=\"\"/>\n\t\t\t<kactus2:functionParameter name=\"recv_handle\" type=\"mcapi_sclchan_recv_hndl_t*\" transferType=\"scalar\" comDirection=\"in\" contentSource=\"handle_name\" dependentParamIndex=\"-1\" description=\"The created receive handle.\"/>\n\t\t\t<kactus2:functionParameter name=\"recv_endpoint\" type=\"mcapi_endpoint_t\" transferType=\"scalar\" comDirection=\"in\" contentSource=\"Name\" dependentParamIndex=\"0\" description=\"The corresponding receive endpoint.\"/>\n\t\t\t<kactus2:functionParameter name=\"request\" type=\"mcapi_request_t*\" transferType=\"\" contentSource=\"\" dependentParamIndex=\"-1\" description=\"Pointer to request status for asynchronous operation.\"/>\n\t\t\t<kactus2:functionParameter name=\"mcapi_status\" type=\"mcapi_status_t*\" transferType=\"\" contentSource=\"\" dependentParamIndex=\"-1\" description=\"Pointer to status variable for checking against errors.\"/>\n\t\t</kactus2:function>\n\t\t<kactus2:function name=\"mcapi_open_sclchan_send_i\" description=\"\">\n\t\t\t<kactus2:returnValue type=\"void\" description=\"\"/>\n\t\t\t<kactus2:functionParameter name=\"send_handle\" type=\"mcapi_sclchan_send_hndl_t*\" transferType=\"message\" comDirection=\"out\" contentSource=\"handle_name\" dependentParamIndex=\"-1\" description=\"The send handle.\"/>\n\t\t\t<kactus2:functionParameter name=\"send_endpoint\" type=\"mcapi_endpoint_t\" transferType=\"message\" comDirection=\"out\" contentSource=\"Name\" dependentParamIndex=\"0\" description=\"The corresponding send endpoint.\"/>\n\t\t\t<kactus2:functionParameter name=\"request\" type=\"mcapi_request_t*\" transferType=\"\" contentSource=\"\" dependentParamIndex=\"-1\" description=\"Pointer to request status for asynchronous operation.\"/>\n\t\t\t<kactus2:functionParameter name=\"mcapi_status\" type=\"mcapi_status_t*\" transferType=\"\" contentSource=\"\" dependentParamIndex=\"-1\" description=\"Pointer to status variable for checking against errors.\"/>\n\t\t</kactus2:function>\n\t\t<kactus2:function name=\"mcapi_sclchan_send_uint64\" description=\"Sends a (connected) 64-bit scalar on a channel.\">\n\t\t\t<kactus2:returnValue type=\"void\" description=\"\"/>\n\t\t\t<kactus2:functionParameter name=\"send_handle\" type=\"mcapi_sclchan_send_hndl_t*\" transferType=\"scalar\" comDirection=\"out\" contentSource=\"handle_name\" dependentParamIndex=\"-1\" description=\"The send handle.\"/>\n\t\t\t<kactus2:functionParameter name=\"dataword\" type=\"mcapi_uint64_t\" transferType=\"\" contentSource=\"\" dependentParamIndex=\"-1\" description=\"The scalar to send.\"/>\n\t\t\t<kactus2:functionParameter name=\"mcapi_status\" type=\"mcapi_status_t*\" transferType=\"\" contentSource=\"\" dependentParamIndex=\"-1\" description=\"Pointer to status variable for checking against errors.\"/>\n\t\t</kactus2:function>\n\t\t<kactus2:function name=\"mcapi_sclchan_send_uint32\" description=\"Sends a (connected) 32-bit scalar on a channel.\">\n\t\t\t<kactus2:returnValue type=\"void\" description=\"\"/>\n\t\t\t<kactus2:functionParameter name=\"send_handle\" type=\"mcapi_sclchan_send_hndl_t*\" transferType=\"scalar\" comDirection=\"out\" contentSource=\"handle_name\" dependentParamIndex=\"-1\" description=\"The send handle.\"/>\n\t\t\t<kactus2:functionParameter name=\"dataword\" type=\"mcapi_uint32_t\" transferType=\"\" contentSource=\"\" dependentParamIndex=\"-1\" description=\"The scalar to send.\"/>\n\t\t\t<kactus2:functionParameter name=\"mcapi_status\" type=\"mcapi_status_t*\" transferType=\"\" contentSource=\"\" dependentParamIndex=\"-1\" description=\"Pointer to status variable for checking against errors.\"/>\n\t\t</kactus2:function>\n\t\t<kactus2:function name=\"mcapi_sclchan_send_uint16\" description=\"Sends a (connected) 16-bit scalar on a channel.\">\n\t\t\t<kactus2:returnValue type=\"void\" description=\"\"/>\n\t\t\t<kactus2:functionParameter name=\"send_handle\" type=\"mcapi_sclchan_send_hndl_t*\" transferType=\"scalar\" comDirection=\"out\" contentSource=\"handle_name\" dependentParamIndex=\"-1\" description=\"The send handle.\"/>\n\t\t\t<kactus2:functionParameter name=\"dataword\" type=\"mcapi_uint16_t\" transferType=\"\" contentSource=\"\" dependentParamIndex=\"-1\" description=\"The scalar to send.\"/>\n\t\t\t<kactus2:functionParameter name=\"mcapi_status\" type=\"mcapi_status_t*\" transferType=\"\" contentSource=\"\" dependentParamIndex=\"-1\" description=\"Pointer to status variable for checking against errors.\"/>\n\t\t</kactus2:function>\n\t\t<kactus2:function name=\"mcapi_sclchan_send_uint8\" description=\"Sends a (connected) 8-bit scalar on a channel.\">\n\t\t\t<kactus2:returnValue type=\"void\" description=\"\"/>\n\t\t\t<kactus2:functionParameter name=\"send_handle\" type=\"mcapi_sclchan_send_hndl_t*\" transferType=\"scalar\" comDirection=\"out\" contentSource=\"handle_name\" dependentParamIndex=\"-1\" description=\"The send handle.\"/>\n\t\t\t<kactus2:functionParameter name=\"dataword\" type=\"mcapi_uint8_t\" transferType=\"\" contentSource=\"\" dependentParamIndex=\"-1\" description=\"The scalar to send.\"/>\n\t\t\t<kactus2:functionParameter name=\"mcapi_status\" type=\"mcapi_status_t*\" transferType=\"\" contentSource=\"\" dependentParamIndex=\"-1\" description=\"Pointer to status variable for checking against errors.\"/>\n\t\t</kactus2:function>\n\t\t<kactus2:function name=\"mcapi_sclchan_recv_uint64\" description=\"Receives a (connected) 64-bit scalar on a channel.\">\n\t\t\t<kactus2:returnValue type=\"mcapi_uint64_t\" description=\"The received dataword.\"/>\n\t\t\t<kactus2:functionParameter name=\"recv_handle\" type=\"mcapi_sclchan_recv_hndl_t*\" transferType=\"scalar\" comDirection=\"in\" contentSource=\"handle_name\" dependentParamIndex=\"-1\" description=\"The receive handle.\"/>\n\t\t\t<kactus2:functionParameter name=\"mcapi_status\" type=\"mcapi_status_t*\" transferType=\"\" contentSource=\"\" dependentParamIndex=\"-1\" description=\"Pointer to status variable for checking against errors.\"/>\n\t\t</kactus2:function>\n\t\t<kactus2:function name=\"mcapi_sclchan_recv_uint32\" description=\"Receives a (connected) 32-bit scalar on a channel.\">\n\t\t\t<kactus2:returnValue type=\"mcapi_uint32_t\" description=\"The received dataword.\"/>\n\t\t\t<kactus2:functionParameter name=\"recv_handle\" type=\"mcapi_sclchan_recv_hndl_t*\" transferType=\"scalar\" comDirection=\"in\" contentSource=\"handle_name\" dependentParamIndex=\"-1\" description=\"The receive handle.\"/>\n\t\t\t<kactus2:functionParameter name=\"mcapi_status\" type=\"mcapi_status_t*\" transferType=\"\" contentSource=\"\" dependentParamIndex=\"-1\" description=\"Pointer to status variable for checking against errors.\"/>\n\t\t</kactus2:function>\n\t\t<kactus2:function name=\"mcapi_sclchan_recv_uint16\" description=\"Receives a (connected) 16-bit scalar on a channel.\">\n\t\t\t<kactus2:returnValue type=\"mcapi_uint16_t\" description=\"The received dataword.\"/>\n\t\t\t<kactus2:functionParameter name=\"recv_handle\" type=\"mcapi_sclchan_recv_hndl_t*\" transferType=\"scalar\" comDirection=\"in\" contentSource=\"handle_name\" dependentParamIndex=\"-1\" description=\"The receive handle.\"/>\n\t\t\t<kactus2:functionParameter name=\"mcapi_status\" type=\"mcapi_status_t*\" transferType=\"\" contentSource=\"\" dependentParamIndex=\"-1\" description=\"Pointer to status variable for checking against errors.\"/>\n\t\t</kactus2:function>\n\t\t<kactus2:function name=\"mcapi_sclchan_recv_uint8\" description=\"Receives a (connected) 8-bit scalar on a channel.\">\n\t\t\t<kactus2:returnValue type=\"mcapi_uint8_t\" description=\"The received dataword.\"/>\n\t\t\t<kactus2:functionParameter name=\"recv_handle\" type=\"mcapi_sclchan_recv_hndl_t*\" transferType=\"scalar\" comDirection=\"in\" contentSource=\"handle_name\" dependentParamIndex=\"-1\" description=\"The receive handle.\"/>\n\t\t\t<kactus2:functionParameter name=\"mcapi_status\" type=\"mcapi_status_t*\" transferType=\"\" contentSource=\"\" dependentParamIndex=\"-1\" description=\"Pointer to status variable for checking against errors.\"/>\n\t\t</kactus2:function>\n\t\t<kactus2:function name=\"mcapi_sclchan_available\" description=\"Checks if scalars are available on a receive endpoint.\">\n\t\t\t<kactus2:returnValue type=\"mcapi_uint_t\" description=\"The number of scalars available.\"/>\n\t\t\t<kactus2:functionParameter name=\"recv_handle\" type=\"mcapi_sclchan_recv_hndl_t*\" transferType=\"scalar\" comDirection=\"in\" contentSource=\"handle_name\" dependentParamIndex=\"-1\" description=\"The receive handle.\"/>\n\t\t\t<kactus2:functionParameter name=\"mcapi_status\" type=\"mcapi_status_t*\" transferType=\"\" contentSource=\"\" dependentParamIndex=\"-1\" description=\"Pointer to status variable for checking against errors.\"/>\n\t\t</kactus2:function>\n\t\t<kactus2:function name=\"mcapi_sclchan_recv_close_i\" description=\"Closes a channel on a receive endpoint.\">\n\t\t\t<kactus2:returnValue type=\"void\" description=\"\"/>\n\t\t\t<kactus2:functionParameter name=\"recv_handle\" type=\"mcapi_sclchan_recv_hndl_t*\" transferType=\"scalar\" comDirection=\"in\" contentSource=\"handle_name\" dependentParamIndex=\"-1\" description=\"The receive handle.\"/>\n\t\t\t<kactus2:functionParameter name=\"request\" type=\"mcapi_request_t*\" transferType=\"\" contentSource=\"\" dependentParamIndex=\"-1\" description=\"Pointer to request status for asynchronous operation.\"/>\n\t\t\t<kactus2:functionParameter name=\"mcapi_status\" type=\"mcapi_status_t*\" transferType=\"\" contentSource=\"\" dependentParamIndex=\"-1\" description=\"Pointer to status variable for checking against errors.\"/>\n\t\t</kactus2:function>\n\t\t<kactus2:function name=\"mcapi_sclchan_send_close_i\" description=\"Closes a channel on a send endpoint.\">\n\t\t\t<kactus2:returnValue type=\"void\" description=\"\"/>\n\t\t\t<kactus2:functionParameter name=\"send_handle\" type=\"mcapi_sclchan_send_hndl_t*\" transferType=\"scalar\" comDirection=\"out\" contentSource=\"handle_name\" dependentParamIndex=\"-1\" description=\"The send handle.\"/>\n\t\t\t<kactus2:functionParameter name=\"request\" type=\"mcapi_request_t*\" transferType=\"\" contentSource=\"\" dependentParamIndex=\"-1\" description=\"Pointer to request status for asynchronous operation.\"/>\n\t\t\t<kactus2:functionParameter name=\"mcapi_status\" type=\"mcapi_status_t*\" transferType=\"\" contentSource=\"\" dependentParamIndex=\"-1\" description=\"Pointer to status variable for checking against errors.\"/>\n\t\t</kactus2:function>\n\t\t<kactus2:function name=\"mcapi_test\" description=\"Tests if a non-blocking operation has completed.\">\n\t\t\t<kactus2:returnValue type=\"mcapi_boolean_t\" description=\"MCAPI_TRUE on success. MCAPI_FALSE if errors or not complete.\"/>\n\t\t\t<kactus2:functionParameter name=\"request\" type=\"mcapi_request_t*\" transferType=\"\" contentSource=\"\" dependentParamIndex=\"-1\" description=\"Pointer to request status.\"/>\n\t\t\t<kactus2:functionParameter name=\"size\" type=\"size_t*\" transferType=\"\" contentSource=\"\" dependentParamIndex=\"-1\" description=\"The number of bytes sent/received.\"/>\n\t\t\t<kactus2:functionParameter name=\"mcapi_status\" type=\"mcapi_status_t*\" transferType=\"\" contentSource=\"\" dependentParamIndex=\"-1\" description=\"Pointer to status variable for checking against errors.\"/>\n\t\t</kactus2:function>\n\t\t<kactus2:function name=\"mcapi_wait\" description=\"Waits for a non-blocking operation to complete.\">\n\t\t\t<kactus2:returnValue type=\"mcapi_boolean_t\" description=\"MCAPI_TRUE on success. MCAPI_FALSE if errors.\"/>\n\t\t\t<kactus2:functionParameter name=\"request\" type=\"mcapi_request_t*\" transferType=\"\" contentSource=\"\" dependentParamIndex=\"-1\" description=\"Pointer to request status.\"/>\n\t\t\t<kactus2:functionParameter name=\"size\" type=\"size_t*\" transferType=\"\" contentSource=\"\" dependentParamIndex=\"-1\" description=\"The number of bytes sent/received.\"/>\n\t\t\t<kactus2:functionParameter name=\"mcapi_status\" type=\"mcapi_status_t*\" transferType=\"\" contentSource=\"\" dependentParamIndex=\"-1\" description=\"Pointer to status variable for checking against errors.\"/>\n\t\t\t<kactus2:functionParameter name=\"timeout\" type=\"mcapi_timeout_t\" transferType=\"\" contentSource=\"\" dependentParamIndex=\"-1\" description=\"The delay for timeout.\"/>\n\t\t</kactus2:function>\n\t\t<kactus2:function name=\"mcapi_wait_any\" description=\"Waits for any non-blocking operation in a list to complete.\">\n\t\t\t<kactus2:returnValue type=\"mcapi_int_t\" description=\"The index into the request array of the mcapi_request_t identifier that has completed or has been canceled. On error, MCAPI_NULL is returned.\"/>\n\t\t\t<kactus2:functionParameter name=\"number\" type=\"size_t\" transferType=\"\" contentSource=\"\" dependentParamIndex=\"-1\" description=\"The number of requests in the array.\"/>\n\t\t\t<kactus2:functionParameter name=\"requests\" type=\"mcapi_request_t**\" transferType=\"\" contentSource=\"\" dependentParamIndex=\"-1\" description=\"The requests array.\"/>\n\t\t\t<kactus2:functionParameter name=\"size\" type=\"size_t*\" transferType=\"\" contentSource=\"\" dependentParamIndex=\"-1\" description=\"The number of bytes sent/received.\"/>\n\t\t\t<kactus2:functionParameter name=\"mcapi_status\" type=\"mcapi_status_t*\" transferType=\"\" contentSource=\"\" dependentParamIndex=\"-1\" description=\"Pointer to status variable for checking against errors.\"/>\n\t\t\t<kactus2:functionParameter name=\"timeout\" type=\"mcapi_timeout_t\" transferType=\"\" contentSource=\"\" dependentParamIndex=\"-1\" description=\"The delay for timeout.\"/>\n\t\t</kactus2:function>\n\t\t<kactus2:function name=\"mcapi_cancel\" description=\"Cancels an outstanding non-blocking operation.\">\n\t\t\t<kactus2:returnValue type=\"void\" description=\"\"/>\n\t\t\t<kactus2:functionParameter name=\"request\" type=\"mcapi_request_t*\" transferType=\"\" contentSource=\"\" dependentParamIndex=\"-1\" description=\"Pointer to request status.\"/>\n\t\t\t<kactus2:functionParameter name=\"mcapi_status\" type=\"mcapi_status_t*\" transferType=\"\" contentSource=\"\" dependentParamIndex=\"-1\" description=\"Pointer to status variable for checking against errors.\"/>\n\t\t</kactus2:function>\n\t</kactus2:functions>\n\t<ipxact:vendorExtensions/>\n</kactus2:apiDefinition>\n"
  },
  {
    "path": "Administrative/releaseFiles/Library/tut.fi/ip.swp.api/mcapi.apiDef/2.015/mcapi.apiDef.2.015.xml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<kactus2:apiDefinition xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:ipxact=\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014\" xmlns:kactus2=\"http://kactus2.cs.tut.fi\" xsi:schemaLocation=\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/ http://www.accellera.org/XMLSchema/IPXACT/1685-2014/index.xsd\">\n\t<ipxact:vendor>tut.fi</ipxact:vendor>\n\t<ipxact:library>ip.swp.api</ipxact:library>\n\t<ipxact:name>mcapi.apiDef</ipxact:name>\n\t<ipxact:version>2.015</ipxact:version>\n\t<kactus2:comDefinitionRef vendor=\"tut.fi\" library=\"global.communication\" name=\"mcapi\" version=\"2.015\"/>\n\t<kactus2:dataTypes>\n\t\t<kactus2:dataType name=\"mcapi_int_t\"/>\n\t\t<kactus2:dataType name=\"mcapi_uint_t\"/>\n\t\t<kactus2:dataType name=\"mcapi_uint8_t\"/>\n\t\t<kactus2:dataType name=\"mcapi_uint16_t\"/>\n\t\t<kactus2:dataType name=\"mcapi_uint32_t\"/>\n\t\t<kactus2:dataType name=\"mcapi_uint64_t\"/>\n\t\t<kactus2:dataType name=\"mcapi_boolean_t\"/>\n\t\t<kactus2:dataType name=\"mcapi_domain_t\"/>\n\t\t<kactus2:dataType name=\"mcapi_endpoint_t\"/>\n\t\t<kactus2:dataType name=\"mcapi_node_t\"/>\n\t\t<kactus2:dataType name=\"mcapi_port_t\"/>\n\t\t<kactus2:dataType name=\"mcapi_version_t\"/>\n\t\t<kactus2:dataType name=\"mcapi_status_t\"/>\n\t\t<kactus2:dataType name=\"mcapi_request_t\"/>\n\t\t<kactus2:dataType name=\"mcapi_priority_t\"/>\n\t\t<kactus2:dataType name=\"mcapi_timeout_t\"/>\n\t\t<kactus2:dataType name=\"mcapi_pktchan_recv_hndl_t\"/>\n\t\t<kactus2:dataType name=\"mcapi_pktchan_send_hndl_t\"/>\n\t\t<kactus2:dataType name=\"mcapi_sclchan_recv_hndl_t\"/>\n\t\t<kactus2:dataType name=\"mcapi_sclchan_send_hndl_t\"/>\n\t\t<kactus2:dataType name=\"mcapi_info_t\"/>\n\t\t<kactus2:dataType name=\"mcapi_node_attributes_t\"/>\n\t</kactus2:dataTypes>\n\t<kactus2:functions>\n\t\t<kactus2:function name=\"mcapi_initialize\" description=\"Initializes the MCAPI implementation.\">\n\t\t\t<kactus2:returnValue type=\"void\" description=\"\"/>\n\t\t\t<kactus2:functionParameter name=\"domain_id\" type=\"mcapi_domain_t\" transferType=\"\" contentSource=\"\" dependentParamIndex=\"-1\" description=\"Domain identifier.\"/>\n\t\t\t<kactus2:functionParameter name=\"node_id\" type=\"mcapi_node_t\" transferType=\"\" contentSource=\"\" dependentParamIndex=\"-1\" description=\"Unique node identifier.\"/>\n\t\t\t<kactus2:functionParameter name=\"mcapi_node_attributes\" type=\"mcapi_node_attributes_t*\" transferType=\"\" contentSource=\"\" dependentParamIndex=\"-1\" description=\"Pointer to domain attributes\"/>\n\t\t\t<kactus2:functionParameter name=\"mcapi_info\" type=\"mcapi_info_t*\" transferType=\"\" contentSource=\"\" dependentParamIndex=\"-1\" description=\"Pointer to implementation information.\"/>\n\t\t\t<kactus2:functionParameter name=\"mcapi_status\" type=\"mcapi_status_t*\" transferType=\"\" contentSource=\"\" dependentParamIndex=\"-1\" description=\"Pointer to status variable for checking against errors.\"/>\n\t\t</kactus2:function>\n\t\t<kactus2:function name=\"mcapi_finalize\" description=\"Finalizes the MCAPI implementation.\">\n\t\t\t<kactus2:returnValue type=\"void\" description=\"\"/>\n\t\t\t<kactus2:functionParameter name=\"mcapi_status\" type=\"mcapi_status_t*\" transferType=\"\" contentSource=\"\" dependentParamIndex=\"-1\" description=\"Pointer to status variable for checking against errors.\"/>\n\t\t</kactus2:function>\n\t\t<kactus2:function name=\"mcapi_domain_id_get\" description=\"Returns the domain ID associated with the local node.\">\n\t\t\t<kactus2:returnValue type=\"mcapi_domain_t\" description=\"The domain id associated with the domain of the local node.\"/>\n\t\t\t<kactus2:functionParameter name=\"mcapi_status\" type=\"mcapi_status_t*\" transferType=\"\" contentSource=\"\" dependentParamIndex=\"-1\" description=\"Pointer to status variable for checking against errors.\"/>\n\t\t</kactus2:function>\n\t\t<kactus2:function name=\"mcapi_node_id_get\" description=\"Returns the node number associated with the local node.\">\n\t\t\t<kactus2:returnValue type=\"mcapi_uint_t\" description=\"The node id associated with the local node.\"/>\n\t\t\t<kactus2:functionParameter name=\"mcapi_status\" type=\"mcapi_status_t*\" transferType=\"\" contentSource=\"\" dependentParamIndex=\"-1\" description=\"Pointer to status variable for checking against errors.\"/>\n\t\t</kactus2:function>\n\t\t<kactus2:function name=\"mcapi_node_init_attributes\" description=\"This function initializes the values of an mcapi_node_attributes_t structure.\">\n\t\t\t<kactus2:returnValue type=\"void\" description=\"\"/>\n\t\t\t<kactus2:functionParameter name=\"mcapi_node_attributes\" type=\"mcapi_node_attributes_t*\" transferType=\"\" contentSource=\"\" dependentParamIndex=\"-1\" description=\"Pointer to the attributes needing initializing.\"/>\n\t\t\t<kactus2:functionParameter name=\"mcapi_status\" type=\"mcapi_status_t*\" transferType=\"\" contentSource=\"\" dependentParamIndex=\"-1\" description=\"Pointer to status variable for checking against errors.\"/>\n\t\t</kactus2:function>\n\t\t<kactus2:function name=\"mcapi_node_set_attribute\" description=\"\">\n\t\t\t<kactus2:returnValue type=\"void\" description=\"\"/>\n\t\t\t<kactus2:functionParameter name=\"mcapi_node_attributes\" type=\"mcapi_node_attributes_t*\" transferType=\"\" contentSource=\"\" dependentParamIndex=\"-1\" description=\"Pointer to the attributes set.\"/>\n\t\t\t<kactus2:functionParameter name=\"attribute_num\" type=\"mcapi_uint_t\" transferType=\"\" contentSource=\"\" dependentParamIndex=\"-1\" description=\"The attribute number.\"/>\n\t\t\t<kactus2:functionParameter name=\"attribute\" type=\"const void*\" transferType=\"\" contentSource=\"\" dependentParamIndex=\"-1\" description=\"The attribute value to set.\"/>\n\t\t\t<kactus2:functionParameter name=\"attribute_size\" type=\"size_t\" transferType=\"\" contentSource=\"\" dependentParamIndex=\"-1\" description=\"The size of the attribute value.\"/>\n\t\t\t<kactus2:functionParameter name=\"mcapi_status\" type=\"mcapi_status_t*\" transferType=\"\" contentSource=\"\" dependentParamIndex=\"-1\" description=\"Pointer to status variable for checking against errors.\"/>\n\t\t</kactus2:function>\n\t\t<kactus2:function name=\"mcapi_node_get_attribute\" description=\"\">\n\t\t\t<kactus2:returnValue type=\"void\" description=\"\"/>\n\t\t\t<kactus2:functionParameter name=\"domain_id\" type=\"mcapi_domain_t\" transferType=\"\" contentSource=\"\" dependentParamIndex=\"-1\" description=\"Domain identifier.\"/>\n\t\t\t<kactus2:functionParameter name=\"node_id\" type=\"mcapi_node_t\" transferType=\"\" contentSource=\"\" dependentParamIndex=\"-1\" description=\"Unique node identifier.\"/>\n\t\t\t<kactus2:functionParameter name=\"attribute_num\" type=\"mcapi_uint_t\" transferType=\"\" contentSource=\"\" dependentParamIndex=\"-1\" description=\"The attribute number.\"/>\n\t\t\t<kactus2:functionParameter name=\"attribute\" type=\"void*\" transferType=\"\" contentSource=\"\" dependentParamIndex=\"-1\" description=\"The retrieved attribute value.\"/>\n\t\t\t<kactus2:functionParameter name=\"attribute_size\" type=\"size_t\" transferType=\"\" contentSource=\"\" dependentParamIndex=\"-1\" description=\"The size of the retrieved attribute value.\"/>\n\t\t\t<kactus2:functionParameter name=\"mcapi_status\" type=\"mcapi_status_t*\" transferType=\"\" contentSource=\"\" dependentParamIndex=\"-1\" description=\"Pointer to status variable for checking against errors.\"/>\n\t\t</kactus2:function>\n\t\t<kactus2:function name=\"mcapi_endpoint_create\" description=\"Creates an endpoint.\">\n\t\t\t<kactus2:returnValue type=\"mcapi_endpoint_t\" description=\"The created endpoint, if successfull. MCAPI_NULL if errors.\"/>\n\t\t\t<kactus2:functionParameter name=\"port_id\" type=\"mcapi_port_t\" transferType=\"any\" contentSource=\"port_id\" dependentParamIndex=\"-1\" description=\"The port id for the endpoint.\"/>\n\t\t\t<kactus2:functionParameter name=\"mcapi_status\" type=\"mcapi_status_t*\" transferType=\"\" contentSource=\"\" dependentParamIndex=\"-1\" description=\"Pointer to status variable for checking against errors.\"/>\n\t\t</kactus2:function>\n\t\t<kactus2:function name=\"mcapi_endpoint_get_i\" description=\"Obtains the endpoint associated with the given tuple.\">\n\t\t\t<kactus2:returnValue type=\"void\" description=\"\"/>\n\t\t\t<kactus2:functionParameter name=\"domain_id\" type=\"mcapi_domain_t\" transferType=\"\" contentSource=\"\" dependentParamIndex=\"-1\" description=\"The domain id of the node that owns the endpoint being obtained..\"/>\n\t\t\t<kactus2:functionParameter name=\"node_id\" type=\"mcapi_node_t\" transferType=\"\" contentSource=\"\" dependentParamIndex=\"-1\" description=\"The node id of the node that owns the endpoint being obtained.\"/>\n\t\t\t<kactus2:functionParameter name=\"port_id\" type=\"mcapi_port_t\" transferType=\"\" contentSource=\"\" dependentParamIndex=\"-1\" description=\"The port id of the endpoint to obtain.\"/>\n\t\t\t<kactus2:functionParameter name=\"endpoint\" type=\"mcapi_endpoint_t*\" transferType=\"\" contentSource=\"\" dependentParamIndex=\"-1\" description=\"The retrieved endpoint.\"/>\n\t\t\t<kactus2:functionParameter name=\"request\" type=\"mcapi_request_t*\" transferType=\"\" contentSource=\"\" dependentParamIndex=\"-1\" description=\"Pointer to request status for asynchronous operation.\"/>\n\t\t\t<kactus2:functionParameter name=\"mcapi_status\" type=\"mcapi_status_t*\" transferType=\"\" contentSource=\"\" dependentParamIndex=\"-1\" description=\"Pointer to status variable for checking against errors.\"/>\n\t\t</kactus2:function>\n\t\t<kactus2:function name=\"mcapi_endpoint_get\" description=\"Obtains the endpoint associated with the given tuple.\">\n\t\t\t<kactus2:returnValue type=\"void\" description=\"\"/>\n\t\t\t<kactus2:functionParameter name=\"domain_id\" type=\"mcapi_domain_t\" transferType=\"\" contentSource=\"\" dependentParamIndex=\"-1\" description=\"The domain id of the node that owns the endpoint being obtained..\"/>\n\t\t\t<kactus2:functionParameter name=\"node_id\" type=\"mcapi_node_t\" transferType=\"\" contentSource=\"\" dependentParamIndex=\"-1\" description=\"The node id of the node that owns the endpoint being obtained.\"/>\n\t\t\t<kactus2:functionParameter name=\"port_id\" type=\"mcapi_port_t\" transferType=\"\" contentSource=\"\" dependentParamIndex=\"-1\" description=\"The port id of the endpoint to obtain.\"/>\n\t\t\t<kactus2:functionParameter name=\"timeout\" type=\"mcapi_timeout_t\" transferType=\"\" contentSource=\"\" dependentParamIndex=\"-1\" description=\"The delay for timeout.\"/>\n\t\t\t<kactus2:functionParameter name=\"mcapi_status\" type=\"mcapi_status_t*\" transferType=\"\" contentSource=\"\" dependentParamIndex=\"-1\" description=\"Pointer to status variable for checking against errors.\"/>\n\t\t</kactus2:function>\n\t\t<kactus2:function name=\"mcapi_endpoint_delete\" description=\"Deletes an endpoint.\">\n\t\t\t<kactus2:returnValue type=\"void\" description=\"\"/>\n\t\t\t<kactus2:functionParameter name=\"endpoint\" type=\"mcapi_endpoint_t\" transferType=\"\" contentSource=\"Name\" dependentParamIndex=\"-1\" description=\"The endpoint to delete.\"/>\n\t\t\t<kactus2:functionParameter name=\"mcapi_status\" type=\"mcapi_status_t*\" transferType=\"\" contentSource=\"\" dependentParamIndex=\"-1\" description=\"Pointer to status variable for checking against errors.\"/>\n\t\t</kactus2:function>\n\t\t<kactus2:function name=\"mcapi_endpoint_get_attribute\" description=\"Retrieves endpoint attributes.\">\n\t\t\t<kactus2:returnValue type=\"void\" description=\"\"/>\n\t\t\t<kactus2:functionParameter name=\"endpoint\" type=\"mcapi_endpoint_t\" transferType=\"\" contentSource=\"Name\" dependentParamIndex=\"-1\" description=\"The endpoint whose attributes to retrieve.\"/>\n\t\t\t<kactus2:functionParameter name=\"attribute_num\" type=\"mcapi_uint_t\" transferType=\"\" contentSource=\"\" dependentParamIndex=\"-1\" description=\"The attribute number.\"/>\n\t\t\t<kactus2:functionParameter name=\"attribute\" type=\"void*\" transferType=\"\" contentSource=\"\" dependentParamIndex=\"-1\" description=\"The retrieved attribute value.\"/>\n\t\t\t<kactus2:functionParameter name=\"attribute_size\" type=\"size_t\" transferType=\"\" contentSource=\"\" dependentParamIndex=\"-1\" description=\"The size of the retrieved attribute value.\"/>\n\t\t\t<kactus2:functionParameter name=\"mcapi_status\" type=\"mcapi_status_t*\" transferType=\"\" contentSource=\"\" dependentParamIndex=\"-1\" description=\"Pointer to status variable for checking against errors.\"/>\n\t\t</kactus2:function>\n\t\t<kactus2:function name=\"mcapi_endpoint_set_attribute\" description=\"Sets endpoint attributes.\">\n\t\t\t<kactus2:returnValue type=\"void\" description=\"\"/>\n\t\t\t<kactus2:functionParameter name=\"endpoint\" type=\"mcapi_endpoint_t\" transferType=\"\" contentSource=\"Name\" dependentParamIndex=\"-1\" description=\"The endpoint whose attribute to set.\"/>\n\t\t\t<kactus2:functionParameter name=\"attribute_num\" type=\"mcapi_uint_t\" transferType=\"\" contentSource=\"\" dependentParamIndex=\"-1\" description=\"The attribute number.\"/>\n\t\t\t<kactus2:functionParameter name=\"attribute\" type=\"const void*\" transferType=\"\" contentSource=\"\" dependentParamIndex=\"-1\" description=\"The attribute value to set.\"/>\n\t\t\t<kactus2:functionParameter name=\"attribute_size\" type=\"size_t\" transferType=\"\" contentSource=\"\" dependentParamIndex=\"-1\" description=\"The size of the attribute value.\"/>\n\t\t\t<kactus2:functionParameter name=\"mcapi_status\" type=\"mcapi_status_t*\" transferType=\"\" contentSource=\"\" dependentParamIndex=\"-1\" description=\"Pointer to status variable for checking against errors.\"/>\n\t\t</kactus2:function>\n\t\t<kactus2:function name=\"mcapi_msg_send_i\" description=\"Sends a connectionless message from a send endpoint to a receive endpoint.\">\n\t\t\t<kactus2:returnValue type=\"void\" description=\"\"/>\n\t\t\t<kactus2:functionParameter name=\"send_endpoint\" type=\"mcapi_endpoint_t\" transferType=\"message\" comDirection=\"out\" contentSource=\"Name\" dependentParamIndex=\"-1\" description=\"The send endpoint (local).\"/>\n\t\t\t<kactus2:functionParameter name=\"receive_endpoint\" type=\"mcapi_endpoint_t\" transferType=\"message\" comDirection=\"in\" contentSource=\"remote_endpoint_name\" dependentParamIndex=\"0\" description=\"The receive endpoint (remote).\"/>\n\t\t\t<kactus2:functionParameter name=\"buffer\" type=\"void*\" transferType=\"\" contentSource=\"\" dependentParamIndex=\"-1\" description=\"The data to send.\"/>\n\t\t\t<kactus2:functionParameter name=\"buffer_size\" type=\"size_t\" transferType=\"\" contentSource=\"\" dependentParamIndex=\"-1\" description=\"The buffer size in bytes.\"/>\n\t\t\t<kactus2:functionParameter name=\"priority\" type=\"mcapi_priority_t\" transferType=\"\" contentSource=\"\" dependentParamIndex=\"-1\" description=\"The message priority.\"/>\n\t\t\t<kactus2:functionParameter name=\"request\" type=\"mcapi_request_t*\" transferType=\"\" contentSource=\"\" dependentParamIndex=\"-1\" description=\"Pointer to request status for asynchronous operation.\"/>\n\t\t\t<kactus2:functionParameter name=\"mcapi_status\" type=\"mcapi_status_t*\" transferType=\"\" contentSource=\"\" dependentParamIndex=\"-1\" description=\"Pointer to status variable for checking against errors.\"/>\n\t\t</kactus2:function>\n\t\t<kactus2:function name=\"mcapi_msg_send\" description=\"Sends a connectionless message from a send endpoint to a receive endpoint.\">\n\t\t\t<kactus2:returnValue type=\"void\" description=\"\"/>\n\t\t\t<kactus2:functionParameter name=\"send_endpoint\" type=\"mcapi_endpoint_t\" transferType=\"message\" comDirection=\"out\" contentSource=\"Name\" dependentParamIndex=\"-1\" description=\"The send endpoint (local).\"/>\n\t\t\t<kactus2:functionParameter name=\"receive_endpoint\" type=\"mcapi_endpoint_t\" transferType=\"message\" comDirection=\"in\" contentSource=\"remote_endpoint_name\" dependentParamIndex=\"0\" description=\"The receive endpoint (remote).\"/>\n\t\t\t<kactus2:functionParameter name=\"buffer\" type=\"void*\" transferType=\"\" contentSource=\"\" dependentParamIndex=\"-1\" description=\"The data to send.\"/>\n\t\t\t<kactus2:functionParameter name=\"buffer_size\" type=\"size_t\" transferType=\"\" contentSource=\"\" dependentParamIndex=\"-1\" description=\"The buffer size in bytes.\"/>\n\t\t\t<kactus2:functionParameter name=\"priority\" type=\"mcapi_priority_t\" transferType=\"\" contentSource=\"\" dependentParamIndex=\"-1\" description=\"The message priority.\"/>\n\t\t\t<kactus2:functionParameter name=\"mcapi_status\" type=\"mcapi_status_t*\" transferType=\"\" contentSource=\"\" dependentParamIndex=\"-1\" description=\"Pointer to status variable for checking against errors.\"/>\n\t\t</kactus2:function>\n\t\t<kactus2:function name=\"mcapi_msg_recv_i\" description=\"Receives a connectionless message from a receive endpoint.\">\n\t\t\t<kactus2:returnValue type=\"void\" description=\"\"/>\n\t\t\t<kactus2:functionParameter name=\"receive_endpoint\" type=\"mcapi_endpoint_t\" transferType=\"message\" comDirection=\"in\" contentSource=\"Name\" dependentParamIndex=\"-1\" description=\"The receive endpoint (local).\"/>\n\t\t\t<kactus2:functionParameter name=\"buffer\" type=\"void*\" transferType=\"\" contentSource=\"\" dependentParamIndex=\"-1\" description=\"The buffer for incoming data.\"/>\n\t\t\t<kactus2:functionParameter name=\"buffer_size\" type=\"size_t\" transferType=\"\" contentSource=\"\" dependentParamIndex=\"-1\" description=\"The buffer size in bytes.\"/>\n\t\t\t<kactus2:functionParameter name=\"request\" type=\"mcapi_request_t*\" transferType=\"\" contentSource=\"\" dependentParamIndex=\"-1\" description=\"Used to determined if the receive operation has completed.\"/>\n\t\t\t<kactus2:functionParameter name=\"mcapi_status\" type=\"mcapi_status_t*\" transferType=\"\" contentSource=\"\" dependentParamIndex=\"-1\" description=\"Pointer to status variable for checking against errors.\"/>\n\t\t</kactus2:function>\n\t\t<kactus2:function name=\"mcapi_msg_recv\" description=\"Receives a connectionless message from a receive endpoint.\">\n\t\t\t<kactus2:returnValue type=\"void\" description=\"\"/>\n\t\t\t<kactus2:functionParameter name=\"receive_endpoint\" type=\"mcapi_endpoint_t\" transferType=\"message\" comDirection=\"in\" contentSource=\"Name\" dependentParamIndex=\"-1\" description=\"The receive endpoint (local).\"/>\n\t\t\t<kactus2:functionParameter name=\"buffer\" type=\"void*\" transferType=\"\" contentSource=\"\" dependentParamIndex=\"-1\" description=\"The buffer for incoming data.\"/>\n\t\t\t<kactus2:functionParameter name=\"buffer_size\" type=\"size_t\" transferType=\"\" contentSource=\"\" dependentParamIndex=\"-1\" description=\"The buffer size in bytes.\"/>\n\t\t\t<kactus2:functionParameter name=\"received_size\" type=\"size_t*\" transferType=\"\" contentSource=\"\" dependentParamIndex=\"-1\" description=\"The actual size of the received message.\"/>\n\t\t\t<kactus2:functionParameter name=\"mcapi_status\" type=\"mcapi_status_t*\" transferType=\"\" contentSource=\"\" dependentParamIndex=\"-1\" description=\"Pointer to status variable for checking against errors.\"/>\n\t\t</kactus2:function>\n\t\t<kactus2:function name=\"mcapi_msg_available\" description=\"Checks if messages are available on a receive endpoint.\">\n\t\t\t<kactus2:returnValue type=\"mcapi_uint_t\" description=\"The number of messages available.\"/>\n\t\t\t<kactus2:functionParameter name=\"receive_endpoint\" type=\"mcapi_endpoint_t\" transferType=\"message\" comDirection=\"in\" contentSource=\"Name\" dependentParamIndex=\"-1\" description=\"The receive endpoint (local).\"/>\n\t\t\t<kactus2:functionParameter name=\"mcapi_status\" type=\"mcapi_status_t*\" transferType=\"\" contentSource=\"\" dependentParamIndex=\"-1\" description=\"Pointer to status variable for checking against errors.\"/>\n\t\t</kactus2:function>\n\t\t<kactus2:function name=\"mcapi_pktchan_connect_i\" description=\"Connects a pair of endpoints into a unidirectional FIFO channel.\">\n\t\t\t<kactus2:returnValue type=\"void\" description=\"\"/>\n\t\t\t<kactus2:functionParameter name=\"send_endpoint\" type=\"mcapi_endpoint_t\" transferType=\"packet\" comDirection=\"out\" contentSource=\"Name\" dependentParamIndex=\"-1\" description=\"The send endpoint.\"/>\n\t\t\t<kactus2:functionParameter name=\"receive_endpoint\" type=\"mcapi_endpoint_t\" transferType=\"packet\" comDirection=\"in\" contentSource=\"remote_endpoint_name\" dependentParamIndex=\"0\" description=\"The receive endpoint.\"/>\n\t\t\t<kactus2:functionParameter name=\"request\" type=\"mcapi_request_t*\" transferType=\"\" contentSource=\"\" dependentParamIndex=\"-1\" description=\"Pointer to request status for asynchronous operation.\"/>\n\t\t\t<kactus2:functionParameter name=\"mcapi_status\" type=\"mcapi_status_t*\" transferType=\"\" contentSource=\"\" dependentParamIndex=\"-1\" description=\"Pointer to status variable for checking against errors.\"/>\n\t\t</kactus2:function>\n\t\t<kactus2:function name=\"mcapi_pktchan_recv_open_i\" description=\"Creates a typed, local representation of the channel.\">\n\t\t\t<kactus2:returnValue type=\"void\" description=\"\"/>\n\t\t\t<kactus2:functionParameter name=\"receive_handle\" type=\"mcapi_pktchan_recv_hndl_t*\" transferType=\"packet\" comDirection=\"in\" contentSource=\"handle_name\" dependentParamIndex=\"-1\" description=\"The created receive handle.\"/>\n\t\t\t<kactus2:functionParameter name=\"recv_endpoint\" type=\"mcapi_endpoint_t\" transferType=\"packet\" comDirection=\"in\" contentSource=\"Name\" dependentParamIndex=\"0\" description=\"The corresponding receive endpoint.\"/>\n\t\t\t<kactus2:functionParameter name=\"request\" type=\"mcapi_request_t*\" transferType=\"\" contentSource=\"\" dependentParamIndex=\"-1\" description=\"Pointer to request status for asynchronous operation.\"/>\n\t\t\t<kactus2:functionParameter name=\"mcapi_status\" type=\"mcapi_status_t*\" transferType=\"\" contentSource=\"\" dependentParamIndex=\"-1\" description=\"Pointer to status variable for checking against errors.\"/>\n\t\t</kactus2:function>\n\t\t<kactus2:function name=\"mcapi_pktchan_send_open_i\" description=\"Opens the send end of a packet channel.\">\n\t\t\t<kactus2:returnValue type=\"void\" description=\"\"/>\n\t\t\t<kactus2:functionParameter name=\"send_handle\" type=\"mcapi_pktchan_send_hndl_t*\" transferType=\"packet\" comDirection=\"out\" contentSource=\"handle_name\" dependentParamIndex=\"-1\" description=\"The send handle.\"/>\n\t\t\t<kactus2:functionParameter name=\"send_endpoint\" type=\"mcapi_endpoint_t\" transferType=\"packet\" comDirection=\"out\" contentSource=\"Name\" dependentParamIndex=\"0\" description=\"The corresponding send endpoint.\"/>\n\t\t\t<kactus2:functionParameter name=\"request\" type=\"mcapi_request_t*\" transferType=\"\" contentSource=\"\" dependentParamIndex=\"-1\" description=\"Pointer to request status for asynchronous operation.\"/>\n\t\t\t<kactus2:functionParameter name=\"mcapi_status\" type=\"mcapi_status_t*\" transferType=\"\" contentSource=\"\" dependentParamIndex=\"-1\" description=\"Pointer to status variable for checking against errors.\"/>\n\t\t</kactus2:function>\n\t\t<kactus2:function name=\"mcapi_pktchan_send_i\" description=\"Sends a (connected) packet on a channel.\">\n\t\t\t<kactus2:returnValue type=\"void\" description=\"\"/>\n\t\t\t<kactus2:functionParameter name=\"send_handle\" type=\"mcapi_pktchan_send_hndl_t*\" transferType=\"packet\" comDirection=\"out\" contentSource=\"handle_name\" dependentParamIndex=\"-1\" description=\"The send handle.\"/>\n\t\t\t<kactus2:functionParameter name=\"buffer\" type=\"void*\" transferType=\"\" contentSource=\"\" dependentParamIndex=\"-1\" description=\"The buffer containing the data to send.\"/>\n\t\t\t<kactus2:functionParameter name=\"buffer_size\" type=\"size_t\" transferType=\"\" contentSource=\"\" dependentParamIndex=\"-1\" description=\"The buffer size in bytes.\"/>\n\t\t\t<kactus2:functionParameter name=\"request\" type=\"mcapi_request_t*\" transferType=\"\" contentSource=\"\" dependentParamIndex=\"-1\" description=\"Pointer to request status for asynchronous operation.\"/>\n\t\t\t<kactus2:functionParameter name=\"mcapi_status\" type=\"mcapi_status_t*\" transferType=\"\" contentSource=\"\" dependentParamIndex=\"-1\" description=\"Pointer to status variable for checking against errors.\"/>\n\t\t</kactus2:function>\n\t\t<kactus2:function name=\"mcapi_pktchan_send\" description=\"Sends a (connected) packet on a channel.\">\n\t\t\t<kactus2:returnValue type=\"void\" description=\"\"/>\n\t\t\t<kactus2:functionParameter name=\"send_handle\" type=\"mcapi_pktchan_send_hndl_t*\" transferType=\"packet\" comDirection=\"out\" contentSource=\"handle_name\" dependentParamIndex=\"-1\" description=\"The send handle.\"/>\n\t\t\t<kactus2:functionParameter name=\"buffer\" type=\"void*\" transferType=\"\" contentSource=\"\" dependentParamIndex=\"-1\" description=\"The buffer containing the data to send.\"/>\n\t\t\t<kactus2:functionParameter name=\"buffer_size\" type=\"size_t\" transferType=\"\" contentSource=\"\" dependentParamIndex=\"-1\" description=\"The buffer size in bytes.\"/>\n\t\t\t<kactus2:functionParameter name=\"mcapi_status\" type=\"mcapi_status_t*\" transferType=\"\" contentSource=\"\" dependentParamIndex=\"-1\" description=\"Pointer to status variable for checking against errors.\"/>\n\t\t</kactus2:function>\n\t\t<kactus2:function name=\"mcapi_pktchan_recv_i\" description=\"Receives a (connected) packet on a channel.\">\n\t\t\t<kactus2:returnValue type=\"void\" description=\"\"/>\n\t\t\t<kactus2:functionParameter name=\"receive_handle\" type=\"mcapi_pktchan_recv_hndl_t*\" transferType=\"packet\" comDirection=\"in\" contentSource=\"handle_name\" dependentParamIndex=\"-1\" description=\"The receive handle.\"/>\n\t\t\t<kactus2:functionParameter name=\"buffer\" type=\"void**\" transferType=\"\" contentSource=\"\" dependentParamIndex=\"-1\" description=\"Address of the system-supplied buffer containing the incoming data.\"/>\n\t\t\t<kactus2:functionParameter name=\"request\" type=\"mcapi_request_t*\" transferType=\"\" contentSource=\"\" dependentParamIndex=\"-1\" description=\"Pointer to request status for asynchronous operation.\"/>\n\t\t\t<kactus2:functionParameter name=\"mcapi_status\" type=\"mcapi_status_t*\" transferType=\"\" contentSource=\"\" dependentParamIndex=\"-1\" description=\"Pointer to status variable for checking against errors.\"/>\n\t\t</kactus2:function>\n\t\t<kactus2:function name=\"mcapi_pktchan_recv\" description=\"\">\n\t\t\t<kactus2:returnValue type=\"void\" description=\"\"/>\n\t\t\t<kactus2:functionParameter name=\"receive_handle\" type=\"mcapi_pktchan_recv_hndl_t*\" transferType=\"packet\" comDirection=\"in\" contentSource=\"handle_name\" dependentParamIndex=\"-1\" description=\"The receive handle.\"/>\n\t\t\t<kactus2:functionParameter name=\"buffer\" type=\"void**\" transferType=\"\" contentSource=\"\" dependentParamIndex=\"-1\" description=\"Address of the system-supplied buffer containing the incoming data.\"/>\n\t\t\t<kactus2:functionParameter name=\"received_size\" type=\"size_t*\" transferType=\"\" contentSource=\"\" dependentParamIndex=\"-1\" description=\"The actual size of the received packet.\"/>\n\t\t\t<kactus2:functionParameter name=\"mcapi_status\" type=\"mcapi_status_t*\" transferType=\"\" contentSource=\"\" dependentParamIndex=\"-1\" description=\"Pointer to status variable for checking against errors.\"/>\n\t\t</kactus2:function>\n\t\t<kactus2:function name=\"mcapi_pktchan_available\" description=\"Checks if packets are available on a receive endpoint.\">\n\t\t\t<kactus2:returnValue type=\"mcapi_uint_t\" description=\"The number of packets available.\"/>\n\t\t\t<kactus2:functionParameter name=\"receive_handle\" type=\"mcapi_pktchan_recv_hndl_t*\" transferType=\"packet\" comDirection=\"in\" contentSource=\"handle_name\" dependentParamIndex=\"-1\" description=\"The receive handle.\"/>\n\t\t\t<kactus2:functionParameter name=\"mcapi_status\" type=\"mcapi_status_t*\" transferType=\"\" contentSource=\"\" dependentParamIndex=\"-1\" description=\"Pointer to status variable for checking against errors.\"/>\n\t\t</kactus2:function>\n\t\t<kactus2:function name=\"mcapi_pktchan_release\" description=\"Releases a packet buffer obtains from a mcapi_pktchan_recv() call.\">\n\t\t\t<kactus2:returnValue type=\"void\" description=\"\"/>\n\t\t\t<kactus2:functionParameter name=\"buffer\" type=\"void*\" transferType=\"\" contentSource=\"\" dependentParamIndex=\"-1\" description=\"The buffer to release.\"/>\n\t\t\t<kactus2:functionParameter name=\"mcapi_status\" type=\"mcapi_status_t*\" transferType=\"\" contentSource=\"\" dependentParamIndex=\"-1\" description=\"Pointer to status variable for checking against errors.\"/>\n\t\t</kactus2:function>\n\t\t<kactus2:function name=\"mcapi_pktchan_release_test\" description=\"Checks if a packet buffer obtained from a mcapi_pktchan_recv() has been released with &#10;mcapi_pktchan_release by the receiver.\">\n\t\t\t<kactus2:returnValue type=\"mcapi_boolean_t\" description=\"On success, MCAPI_TRUE is returned and *mcapi_status is set to MCAPI_SUCCESS.\"/>\n\t\t\t<kactus2:functionParameter name=\"buffer\" type=\"void*\" transferType=\"\" contentSource=\"\" dependentParamIndex=\"-1\" description=\"The buffer to check.\"/>\n\t\t\t<kactus2:functionParameter name=\"mcapi_status\" type=\"mcapi_status_t*\" transferType=\"\" contentSource=\"\" dependentParamIndex=\"-1\" description=\"Pointer to status variable for checking against errors.\"/>\n\t\t</kactus2:function>\n\t\t<kactus2:function name=\"mcapi_pktchan_recv_close_i\" description=\"Closes channel on a receive endpoint.\">\n\t\t\t<kactus2:returnValue type=\"void\" description=\"\"/>\n\t\t\t<kactus2:functionParameter name=\"receive_handle\" type=\"mcapi_pktchan_recv_hndl_t*\" transferType=\"packet\" comDirection=\"in\" contentSource=\"handle_name\" dependentParamIndex=\"-1\" description=\"The receive handle.\"/>\n\t\t\t<kactus2:functionParameter name=\"request\" type=\"mcapi_request_t*\" transferType=\"\" contentSource=\"\" dependentParamIndex=\"-1\" description=\"Pointer to request status for asynchronous operation.\"/>\n\t\t\t<kactus2:functionParameter name=\"mcapi_status\" type=\"mcapi_status_t*\" transferType=\"\" contentSource=\"\" dependentParamIndex=\"-1\" description=\"Pointer to status variable for checking against errors.\"/>\n\t\t</kactus2:function>\n\t\t<kactus2:function name=\"mcapi_pktchan_send_close_i\" description=\"Closes channel on a send endpoint.\">\n\t\t\t<kactus2:returnValue type=\"void\" description=\"\"/>\n\t\t\t<kactus2:functionParameter name=\"send_handle\" type=\"mcapi_pktchan_send_hndl_t*\" transferType=\"packet\" comDirection=\"out\" contentSource=\"handle_name\" dependentParamIndex=\"-1\" description=\"The send handle.\"/>\n\t\t\t<kactus2:functionParameter name=\"request\" type=\"mcapi_request_t*\" transferType=\"\" contentSource=\"\" dependentParamIndex=\"-1\" description=\"Pointer to request status for asynchronous operation.\"/>\n\t\t\t<kactus2:functionParameter name=\"mcapi_status\" type=\"mcapi_status_t*\" transferType=\"\" contentSource=\"\" dependentParamIndex=\"-1\" description=\"Pointer to status variable for checking against errors.\"/>\n\t\t</kactus2:function>\n\t\t<kactus2:function name=\"mcapi_sclchan_connect_i\" description=\"Connects a pair of scalar channel endpoints.\">\n\t\t\t<kactus2:returnValue type=\"void\" description=\"\"/>\n\t\t\t<kactus2:functionParameter name=\"send_endpoint\" type=\"mcapi_endpoint_t\" transferType=\"scalar\" comDirection=\"out\" contentSource=\"Name\" dependentParamIndex=\"-1\" description=\"The send endpoint.\"/>\n\t\t\t<kactus2:functionParameter name=\"receive_endpoint\" type=\"mcapi_endpoint_t\" transferType=\"scalar\" comDirection=\"in\" contentSource=\"remote_endpoint_name\" dependentParamIndex=\"0\" description=\"The receive endpoint.\"/>\n\t\t\t<kactus2:functionParameter name=\"request\" type=\"mcapi_request_t*\" transferType=\"\" contentSource=\"\" dependentParamIndex=\"-1\" description=\"Pointer to request status for asynchronous operation.\"/>\n\t\t\t<kactus2:functionParameter name=\"mcapi_status\" type=\"mcapi_status_t*\" transferType=\"\" contentSource=\"\" dependentParamIndex=\"-1\" description=\"Pointer to status variable for checking against errors.\"/>\n\t\t</kactus2:function>\n\t\t<kactus2:function name=\"mcapi_sclchan_recv_open_i\" description=\"Creates a typed, local representation of a scalar channel.\">\n\t\t\t<kactus2:returnValue type=\"void\" description=\"\"/>\n\t\t\t<kactus2:functionParameter name=\"receive_handle\" type=\"mcapi_sclchan_recv_hndl_t*\" transferType=\"scalar\" comDirection=\"in\" contentSource=\"handle_name\" dependentParamIndex=\"-1\" description=\"The created receive handle.\"/>\n\t\t\t<kactus2:functionParameter name=\"recv_endpoint\" type=\"mcapi_endpoint_t\" transferType=\"scalar\" comDirection=\"in\" contentSource=\"Name\" dependentParamIndex=\"0\" description=\"The corresponding receive endpoint.\"/>\n\t\t\t<kactus2:functionParameter name=\"request\" type=\"mcapi_request_t*\" transferType=\"\" contentSource=\"\" dependentParamIndex=\"-1\" description=\"Pointer to request status for asynchronous operation.\"/>\n\t\t\t<kactus2:functionParameter name=\"mcapi_status\" type=\"mcapi_status_t*\" transferType=\"\" contentSource=\"\" dependentParamIndex=\"-1\" description=\"Pointer to status variable for checking against errors.\"/>\n\t\t</kactus2:function>\n\t\t<kactus2:function name=\"mcapi_sclchan_send_open_i\" description=\"\">\n\t\t\t<kactus2:returnValue type=\"void\" description=\"\"/>\n\t\t\t<kactus2:functionParameter name=\"send_handle\" type=\"mcapi_sclchan_send_hndl_t*\" transferType=\"message\" comDirection=\"out\" contentSource=\"handle_name\" dependentParamIndex=\"-1\" description=\"The send handle.\"/>\n\t\t\t<kactus2:functionParameter name=\"send_endpoint\" type=\"mcapi_endpoint_t\" transferType=\"message\" comDirection=\"out\" contentSource=\"Name\" dependentParamIndex=\"0\" description=\"The corresponding send endpoint.\"/>\n\t\t\t<kactus2:functionParameter name=\"request\" type=\"mcapi_request_t*\" transferType=\"\" contentSource=\"\" dependentParamIndex=\"-1\" description=\"Pointer to request status for asynchronous operation.\"/>\n\t\t\t<kactus2:functionParameter name=\"mcapi_status\" type=\"mcapi_status_t*\" transferType=\"\" contentSource=\"\" dependentParamIndex=\"-1\" description=\"Pointer to status variable for checking against errors.\"/>\n\t\t</kactus2:function>\n\t\t<kactus2:function name=\"mcapi_sclchan_send_uint64\" description=\"Sends a (connected) 64-bit scalar on a channel.\">\n\t\t\t<kactus2:returnValue type=\"void\" description=\"\"/>\n\t\t\t<kactus2:functionParameter name=\"send_handle\" type=\"mcapi_sclchan_send_hndl_t*\" transferType=\"scalar\" comDirection=\"out\" contentSource=\"handle_name\" dependentParamIndex=\"-1\" description=\"The send handle.\"/>\n\t\t\t<kactus2:functionParameter name=\"dataword\" type=\"mcapi_uint64_t\" transferType=\"\" contentSource=\"\" dependentParamIndex=\"-1\" description=\"The scalar to send.\"/>\n\t\t\t<kactus2:functionParameter name=\"mcapi_status\" type=\"mcapi_status_t*\" transferType=\"\" contentSource=\"\" dependentParamIndex=\"-1\" description=\"Pointer to status variable for checking against errors.\"/>\n\t\t</kactus2:function>\n\t\t<kactus2:function name=\"mcapi_sclchan_send_uint32\" description=\"Sends a (connected) 32-bit scalar on a channel.\">\n\t\t\t<kactus2:returnValue type=\"void\" description=\"\"/>\n\t\t\t<kactus2:functionParameter name=\"send_handle\" type=\"mcapi_sclchan_send_hndl_t*\" transferType=\"scalar\" comDirection=\"out\" contentSource=\"handle_name\" dependentParamIndex=\"-1\" description=\"The send handle.\"/>\n\t\t\t<kactus2:functionParameter name=\"dataword\" type=\"mcapi_uint32_t\" transferType=\"\" contentSource=\"\" dependentParamIndex=\"-1\" description=\"The scalar to send.\"/>\n\t\t\t<kactus2:functionParameter name=\"mcapi_status\" type=\"mcapi_status_t*\" transferType=\"\" contentSource=\"\" dependentParamIndex=\"-1\" description=\"Pointer to status variable for checking against errors.\"/>\n\t\t</kactus2:function>\n\t\t<kactus2:function name=\"mcapi_sclchan_send_uint16\" description=\"Sends a (connected) 16-bit scalar on a channel.\">\n\t\t\t<kactus2:returnValue type=\"void\" description=\"\"/>\n\t\t\t<kactus2:functionParameter name=\"send_handle\" type=\"mcapi_sclchan_send_hndl_t*\" transferType=\"scalar\" comDirection=\"out\" contentSource=\"handle_name\" dependentParamIndex=\"-1\" description=\"The send handle.\"/>\n\t\t\t<kactus2:functionParameter name=\"dataword\" type=\"mcapi_uint16_t\" transferType=\"\" contentSource=\"\" dependentParamIndex=\"-1\" description=\"The scalar to send.\"/>\n\t\t\t<kactus2:functionParameter name=\"mcapi_status\" type=\"mcapi_status_t*\" transferType=\"\" contentSource=\"\" dependentParamIndex=\"-1\" description=\"Pointer to status variable for checking against errors.\"/>\n\t\t</kactus2:function>\n\t\t<kactus2:function name=\"mcapi_sclchan_send_uint8\" description=\"Sends a (connected) 8-bit scalar on a channel.\">\n\t\t\t<kactus2:returnValue type=\"void\" description=\"\"/>\n\t\t\t<kactus2:functionParameter name=\"send_handle\" type=\"mcapi_sclchan_send_hndl_t*\" transferType=\"scalar\" comDirection=\"out\" contentSource=\"handle_name\" dependentParamIndex=\"-1\" description=\"The send handle.\"/>\n\t\t\t<kactus2:functionParameter name=\"dataword\" type=\"mcapi_uint8_t\" transferType=\"\" contentSource=\"\" dependentParamIndex=\"-1\" description=\"The scalar to send.\"/>\n\t\t\t<kactus2:functionParameter name=\"mcapi_status\" type=\"mcapi_status_t*\" transferType=\"\" contentSource=\"\" dependentParamIndex=\"-1\" description=\"Pointer to status variable for checking against errors.\"/>\n\t\t</kactus2:function>\n\t\t<kactus2:function name=\"mcapi_sclchan_recv_uint64\" description=\"Receives a (connected) 64-bit scalar on a channel.\">\n\t\t\t<kactus2:returnValue type=\"mcapi_uint64_t\" description=\"The received dataword.\"/>\n\t\t\t<kactus2:functionParameter name=\"receive_handle\" type=\"mcapi_sclchan_recv_hndl_t*\" transferType=\"scalar\" comDirection=\"in\" contentSource=\"handle_name\" dependentParamIndex=\"-1\" description=\"The receive handle.\"/>\n\t\t\t<kactus2:functionParameter name=\"mcapi_status\" type=\"mcapi_status_t*\" transferType=\"\" contentSource=\"\" dependentParamIndex=\"-1\" description=\"Pointer to status variable for checking against errors.\"/>\n\t\t</kactus2:function>\n\t\t<kactus2:function name=\"mcapi_sclchan_recv_uint32\" description=\"Receives a (connected) 32-bit scalar on a channel.\">\n\t\t\t<kactus2:returnValue type=\"mcapi_uint32_t\" description=\"The received dataword.\"/>\n\t\t\t<kactus2:functionParameter name=\"receive_handle\" type=\"mcapi_sclchan_recv_hndl_t*\" transferType=\"scalar\" comDirection=\"in\" contentSource=\"handle_name\" dependentParamIndex=\"-1\" description=\"The receive handle.\"/>\n\t\t\t<kactus2:functionParameter name=\"mcapi_status\" type=\"mcapi_status_t*\" transferType=\"\" contentSource=\"\" dependentParamIndex=\"-1\" description=\"Pointer to status variable for checking against errors.\"/>\n\t\t</kactus2:function>\n\t\t<kactus2:function name=\"mcapi_sclchan_recv_uint16\" description=\"Receives a (connected) 16-bit scalar on a channel.\">\n\t\t\t<kactus2:returnValue type=\"mcapi_uint16_t\" description=\"The received dataword.\"/>\n\t\t\t<kactus2:functionParameter name=\"receive_handle\" type=\"mcapi_sclchan_recv_hndl_t*\" transferType=\"scalar\" comDirection=\"in\" contentSource=\"handle_name\" dependentParamIndex=\"-1\" description=\"The receive handle.\"/>\n\t\t\t<kactus2:functionParameter name=\"mcapi_status\" type=\"mcapi_status_t*\" transferType=\"\" contentSource=\"\" dependentParamIndex=\"-1\" description=\"Pointer to status variable for checking against errors.\"/>\n\t\t</kactus2:function>\n\t\t<kactus2:function name=\"mcapi_sclchan_recv_uint8\" description=\"Receives a (connected) 8-bit scalar on a channel.\">\n\t\t\t<kactus2:returnValue type=\"mcapi_uint8_t\" description=\"The received dataword.\"/>\n\t\t\t<kactus2:functionParameter name=\"receive_handle\" type=\"mcapi_sclchan_recv_hndl_t*\" transferType=\"scalar\" comDirection=\"in\" contentSource=\"handle_name\" dependentParamIndex=\"-1\" description=\"The receive handle.\"/>\n\t\t\t<kactus2:functionParameter name=\"mcapi_status\" type=\"mcapi_status_t*\" transferType=\"\" contentSource=\"\" dependentParamIndex=\"-1\" description=\"Pointer to status variable for checking against errors.\"/>\n\t\t</kactus2:function>\n\t\t<kactus2:function name=\"mcapi_sclchan_available\" description=\"Checks if scalars are available on a receive endpoint.\">\n\t\t\t<kactus2:returnValue type=\"mcapi_uint_t\" description=\"The number of scalars available.\"/>\n\t\t\t<kactus2:functionParameter name=\"receive_handle\" type=\"mcapi_sclchan_recv_hndl_t*\" transferType=\"scalar\" comDirection=\"in\" contentSource=\"handle_name\" dependentParamIndex=\"-1\" description=\"The receive handle.\"/>\n\t\t\t<kactus2:functionParameter name=\"mcapi_status\" type=\"mcapi_status_t*\" transferType=\"\" contentSource=\"\" dependentParamIndex=\"-1\" description=\"Pointer to status variable for checking against errors.\"/>\n\t\t</kactus2:function>\n\t\t<kactus2:function name=\"mcapi_sclchan_recv_close_i\" description=\"Closes a channel on a receive endpoint.\">\n\t\t\t<kactus2:returnValue type=\"void\" description=\"\"/>\n\t\t\t<kactus2:functionParameter name=\"receive_handle\" type=\"mcapi_sclchan_recv_hndl_t*\" transferType=\"scalar\" comDirection=\"in\" contentSource=\"handle_name\" dependentParamIndex=\"-1\" description=\"The receive handle.\"/>\n\t\t\t<kactus2:functionParameter name=\"request\" type=\"mcapi_request_t*\" transferType=\"\" contentSource=\"\" dependentParamIndex=\"-1\" description=\"Pointer to request status for asynchronous operation.\"/>\n\t\t\t<kactus2:functionParameter name=\"mcapi_status\" type=\"mcapi_status_t*\" transferType=\"\" contentSource=\"\" dependentParamIndex=\"-1\" description=\"Pointer to status variable for checking against errors.\"/>\n\t\t</kactus2:function>\n\t\t<kactus2:function name=\"mcapi_sclchan_send_close_i\" description=\"Closes a channel on a send endpoint.\">\n\t\t\t<kactus2:returnValue type=\"void\" description=\"\"/>\n\t\t\t<kactus2:functionParameter name=\"send_handle\" type=\"mcapi_sclchan_send_hndl_t*\" transferType=\"scalar\" comDirection=\"out\" contentSource=\"handle_name\" dependentParamIndex=\"-1\" description=\"The send handle.\"/>\n\t\t\t<kactus2:functionParameter name=\"request\" type=\"mcapi_request_t*\" transferType=\"\" contentSource=\"\" dependentParamIndex=\"-1\" description=\"Pointer to request status for asynchronous operation.\"/>\n\t\t\t<kactus2:functionParameter name=\"mcapi_status\" type=\"mcapi_status_t*\" transferType=\"\" contentSource=\"\" dependentParamIndex=\"-1\" description=\"Pointer to status variable for checking against errors.\"/>\n\t\t</kactus2:function>\n\t\t<kactus2:function name=\"mcapi_test\" description=\"Tests if a non-blocking operation has completed.\">\n\t\t\t<kactus2:returnValue type=\"mcapi_boolean_t\" description=\"MCAPI_TRUE on success. MCAPI_FALSE if errors or not complete.\"/>\n\t\t\t<kactus2:functionParameter name=\"request\" type=\"mcapi_request_t*\" transferType=\"\" contentSource=\"\" dependentParamIndex=\"-1\" description=\"Pointer to request status.\"/>\n\t\t\t<kactus2:functionParameter name=\"size\" type=\"size_t*\" transferType=\"\" contentSource=\"\" dependentParamIndex=\"-1\" description=\"The number of bytes sent/received.\"/>\n\t\t\t<kactus2:functionParameter name=\"mcapi_status\" type=\"mcapi_status_t*\" transferType=\"\" contentSource=\"\" dependentParamIndex=\"-1\" description=\"Pointer to status variable for checking against errors.\"/>\n\t\t</kactus2:function>\n\t\t<kactus2:function name=\"mcapi_wait\" description=\"Waits for a non-blocking operation to complete.\">\n\t\t\t<kactus2:returnValue type=\"mcapi_boolean_t\" description=\"MCAPI_TRUE on success. MCAPI_FALSE if errors.\"/>\n\t\t\t<kactus2:functionParameter name=\"request\" type=\"mcapi_request_t*\" transferType=\"\" contentSource=\"\" dependentParamIndex=\"-1\" description=\"Pointer to request status.\"/>\n\t\t\t<kactus2:functionParameter name=\"size\" type=\"size_t*\" transferType=\"\" contentSource=\"\" dependentParamIndex=\"-1\" description=\"The number of bytes sent/received.\"/>\n\t\t\t<kactus2:functionParameter name=\"timeout\" type=\"mcapi_timeout_t\" transferType=\"\" contentSource=\"\" dependentParamIndex=\"-1\" description=\"The delay for timeout.\"/>\n\t\t\t<kactus2:functionParameter name=\"mcapi_status\" type=\"mcapi_status_t*\" transferType=\"\" contentSource=\"\" dependentParamIndex=\"-1\" description=\"Pointer to status variable for checking against errors.\"/>\n\t\t</kactus2:function>\n\t\t<kactus2:function name=\"mcapi_wait_any\" description=\"Waits for any non-blocking operation in a list to complete.\">\n\t\t\t<kactus2:returnValue type=\"mcapi_int_t\" description=\"The index into the request array of the mcapi_request_t identifier that has completed or has been canceled. On error, MCAPI_NULL is returned.\"/>\n\t\t\t<kactus2:functionParameter name=\"number\" type=\"size_t\" transferType=\"\" contentSource=\"\" dependentParamIndex=\"-1\" description=\"The number of requests in the array.\"/>\n\t\t\t<kactus2:functionParameter name=\"requests\" type=\"mcapi_request_t**\" transferType=\"\" contentSource=\"\" dependentParamIndex=\"-1\" description=\"The requests array.\"/>\n\t\t\t<kactus2:functionParameter name=\"size\" type=\"size_t*\" transferType=\"\" contentSource=\"\" dependentParamIndex=\"-1\" description=\"The number of bytes sent/received.\"/>\n\t\t\t<kactus2:functionParameter name=\"mcapi_status\" type=\"mcapi_status_t*\" transferType=\"\" contentSource=\"\" dependentParamIndex=\"-1\" description=\"Pointer to status variable for checking against errors.\"/>\n\t\t\t<kactus2:functionParameter name=\"timeout\" type=\"mcapi_timeout_t\" transferType=\"\" contentSource=\"\" dependentParamIndex=\"-1\" description=\"The delay for timeout.\"/>\n\t\t</kactus2:function>\n\t\t<kactus2:function name=\"mcapi_cancel\" description=\"Cancels an outstanding non-blocking operation.\">\n\t\t\t<kactus2:returnValue type=\"void\" description=\"\"/>\n\t\t\t<kactus2:functionParameter name=\"request\" type=\"mcapi_request_t*\" transferType=\"\" contentSource=\"\" dependentParamIndex=\"-1\" description=\"Pointer to request status.\"/>\n\t\t\t<kactus2:functionParameter name=\"mcapi_status\" type=\"mcapi_status_t*\" transferType=\"\" contentSource=\"\" dependentParamIndex=\"-1\" description=\"Pointer to status variable for checking against errors.\"/>\n\t\t</kactus2:function>\n\t</kactus2:functions>\n</kactus2:apiDefinition>\n"
  },
  {
    "path": "Administrative/releaseFiles/gpl2.txt",
    "content": "                    GNU GENERAL PUBLIC LICENSE\n                       Version 2, June 1991\n\n Copyright (C) 1989, 1991 Free Software Foundation, Inc.,\n 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA\n Everyone is permitted to copy and distribute verbatim copies\n of this license document, but changing it is not allowed.\n\n                            Preamble\n\n  The licenses for most software are designed to take away your\nfreedom to share and change it.  By contrast, the GNU General Public\nLicense is intended to guarantee your freedom to share and change free\nsoftware--to make sure the software is free for all its users.  This\nGeneral Public License applies to most of the Free Software\nFoundation's software and to any other program whose authors commit to\nusing it.  (Some other Free Software Foundation software is covered by\nthe GNU Lesser General Public License instead.)  You can apply it to\nyour programs, too.\n\n  When we speak of free software, we are referring to freedom, not\nprice.  Our General Public Licenses are designed to make sure that you\nhave the freedom to distribute copies of free software (and charge for\nthis service if you wish), that you receive source code or can get it\nif you want it, that you can change the software or use pieces of it\nin new free programs; and that you know you can do these things.\n\n  To protect your rights, we need to make restrictions that forbid\nanyone to deny you these rights or to ask you to surrender the rights.\nThese restrictions translate to certain responsibilities for you if you\ndistribute copies of the software, or if you modify it.\n\n  For example, if you distribute copies of such a program, whether\ngratis or for a fee, you must give the recipients all the rights that\nyou have.  You must make sure that they, too, receive or can get the\nsource code.  And you must show them these terms so they know their\nrights.\n\n  We protect your rights with two steps: (1) copyright the software, and\n(2) offer you this license which gives you legal permission to copy,\ndistribute and/or modify the software.\n\n  Also, for each author's protection and ours, we want to make certain\nthat everyone understands that there is no warranty for this free\nsoftware.  If the software is modified by someone else and passed on, we\nwant its recipients to know that what they have is not the original, so\nthat any problems introduced by others will not reflect on the original\nauthors' reputations.\n\n  Finally, any free program is threatened constantly by software\npatents.  We wish to avoid the danger that redistributors of a free\nprogram will individually obtain patent licenses, in effect making the\nprogram proprietary.  To prevent this, we have made it clear that any\npatent must be licensed for everyone's free use or not licensed at all.\n\n  The precise terms and conditions for copying, distribution and\nmodification follow.\n\n                    GNU GENERAL PUBLIC LICENSE\n   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION\n\n  0. This License applies to any program or other work which contains\na notice placed by the copyright holder saying it may be distributed\nunder the terms of this General Public License.  The \"Program\", below,\nrefers to any such program or work, and a \"work based on the Program\"\nmeans either the Program or any derivative work under copyright law:\nthat is to say, a work containing the Program or a portion of it,\neither verbatim or with modifications and/or translated into another\nlanguage.  (Hereinafter, translation is included without limitation in\nthe term \"modification\".)  Each licensee is addressed as \"you\".\n\nActivities other than copying, distribution and modification are not\ncovered by this License; they are outside its scope.  The act of\nrunning the Program is not restricted, and the output from the Program\nis covered only if its contents constitute a work based on the\nProgram (independent of having been made by running the Program).\nWhether that is true depends on what the Program does.\n\n  1. You may copy and distribute verbatim copies of the Program's\nsource code as you receive it, in any medium, provided that you\nconspicuously and appropriately publish on each copy an appropriate\ncopyright notice and disclaimer of warranty; keep intact all the\nnotices that refer to this License and to the absence of any warranty;\nand give any other recipients of the Program a copy of this License\nalong with the Program.\n\nYou may charge a fee for the physical act of transferring a copy, and\nyou may at your option offer warranty protection in exchange for a fee.\n\n  2. You may modify your copy or copies of the Program or any portion\nof it, thus forming a work based on the Program, and copy and\ndistribute such modifications or work under the terms of Section 1\nabove, provided that you also meet all of these conditions:\n\n    a) You must cause the modified files to carry prominent notices\n    stating that you changed the files and the date of any change.\n\n    b) You must cause any work that you distribute or publish, that in\n    whole or in part contains or is derived from the Program or any\n    part thereof, to be licensed as a whole at no charge to all third\n    parties under the terms of this License.\n\n    c) If the modified program normally reads commands interactively\n    when run, you must cause it, when started running for such\n    interactive use in the most ordinary way, to print or display an\n    announcement including an appropriate copyright notice and a\n    notice that there is no warranty (or else, saying that you provide\n    a warranty) and that users may redistribute the program under\n    these conditions, and telling the user how to view a copy of this\n    License.  (Exception: if the Program itself is interactive but\n    does not normally print such an announcement, your work based on\n    the Program is not required to print an announcement.)\n\nThese requirements apply to the modified work as a whole.  If\nidentifiable sections of that work are not derived from the Program,\nand can be reasonably considered independent and separate works in\nthemselves, then this License, and its terms, do not apply to those\nsections when you distribute them as separate works.  But when you\ndistribute the same sections as part of a whole which is a work based\non the Program, the distribution of the whole must be on the terms of\nthis License, whose permissions for other licensees extend to the\nentire whole, and thus to each and every part regardless of who wrote it.\n\nThus, it is not the intent of this section to claim rights or contest\nyour rights to work written entirely by you; rather, the intent is to\nexercise the right to control the distribution of derivative or\ncollective works based on the Program.\n\nIn addition, mere aggregation of another work not based on the Program\nwith the Program (or with a work based on the Program) on a volume of\na storage or distribution medium does not bring the other work under\nthe scope of this License.\n\n  3. You may copy and distribute the Program (or a work based on it,\nunder Section 2) in object code or executable form under the terms of\nSections 1 and 2 above provided that you also do one of the following:\n\n    a) Accompany it with the complete corresponding machine-readable\n    source code, which must be distributed under the terms of Sections\n    1 and 2 above on a medium customarily used for software interchange; or,\n\n    b) Accompany it with a written offer, valid for at least three\n    years, to give any third party, for a charge no more than your\n    cost of physically performing source distribution, a complete\n    machine-readable copy of the corresponding source code, to be\n    distributed under the terms of Sections 1 and 2 above on a medium\n    customarily used for software interchange; or,\n\n    c) Accompany it with the information you received as to the offer\n    to distribute corresponding source code.  (This alternative is\n    allowed only for noncommercial distribution and only if you\n    received the program in object code or executable form with such\n    an offer, in accord with Subsection b above.)\n\nThe source code for a work means the preferred form of the work for\nmaking modifications to it.  For an executable work, complete source\ncode means all the source code for all modules it contains, plus any\nassociated interface definition files, plus the scripts used to\ncontrol compilation and installation of the executable.  However, as a\nspecial exception, the source code distributed need not include\nanything that is normally distributed (in either source or binary\nform) with the major components (compiler, kernel, and so on) of the\noperating system on which the executable runs, unless that component\nitself accompanies the executable.\n\nIf distribution of executable or object code is made by offering\naccess to copy from a designated place, then offering equivalent\naccess to copy the source code from the same place counts as\ndistribution of the source code, even though third parties are not\ncompelled to copy the source along with the object code.\n\n  4. You may not copy, modify, sublicense, or distribute the Program\nexcept as expressly provided under this License.  Any attempt\notherwise to copy, modify, sublicense or distribute the Program is\nvoid, and will automatically terminate your rights under this License.\nHowever, parties who have received copies, or rights, from you under\nthis License will not have their licenses terminated so long as such\nparties remain in full compliance.\n\n  5. You are not required to accept this License, since you have not\nsigned it.  However, nothing else grants you permission to modify or\ndistribute the Program or its derivative works.  These actions are\nprohibited by law if you do not accept this License.  Therefore, by\nmodifying or distributing the Program (or any work based on the\nProgram), you indicate your acceptance of this License to do so, and\nall its terms and conditions for copying, distributing or modifying\nthe Program or works based on it.\n\n  6. Each time you redistribute the Program (or any work based on the\nProgram), the recipient automatically receives a license from the\noriginal licensor to copy, distribute or modify the Program subject to\nthese terms and conditions.  You may not impose any further\nrestrictions on the recipients' exercise of the rights granted herein.\nYou are not responsible for enforcing compliance by third parties to\nthis License.\n\n  7. If, as a consequence of a court judgment or allegation of patent\ninfringement or for any other reason (not limited to patent issues),\nconditions are imposed on you (whether by court order, agreement or\notherwise) that contradict the conditions of this License, they do not\nexcuse you from the conditions of this License.  If you cannot\ndistribute so as to satisfy simultaneously your obligations under this\nLicense and any other pertinent obligations, then as a consequence you\nmay not distribute the Program at all.  For example, if a patent\nlicense would not permit royalty-free redistribution of the Program by\nall those who receive copies directly or indirectly through you, then\nthe only way you could satisfy both it and this License would be to\nrefrain entirely from distribution of the Program.\n\nIf any portion of this section is held invalid or unenforceable under\nany particular circumstance, the balance of the section is intended to\napply and the section as a whole is intended to apply in other\ncircumstances.\n\nIt is not the purpose of this section to induce you to infringe any\npatents or other property right claims or to contest validity of any\nsuch claims; this section has the sole purpose of protecting the\nintegrity of the free software distribution system, which is\nimplemented by public license practices.  Many people have made\ngenerous contributions to the wide range of software distributed\nthrough that system in reliance on consistent application of that\nsystem; it is up to the author/donor to decide if he or she is willing\nto distribute software through any other system and a licensee cannot\nimpose that choice.\n\nThis section is intended to make thoroughly clear what is believed to\nbe a consequence of the rest of this License.\n\n  8. If the distribution and/or use of the Program is restricted in\ncertain countries either by patents or by copyrighted interfaces, the\noriginal copyright holder who places the Program under this License\nmay add an explicit geographical distribution limitation excluding\nthose countries, so that distribution is permitted only in or among\ncountries not thus excluded.  In such case, this License incorporates\nthe limitation as if written in the body of this License.\n\n  9. The Free Software Foundation may publish revised and/or new versions\nof the General Public License from time to time.  Such new versions will\nbe similar in spirit to the present version, but may differ in detail to\naddress new problems or concerns.\n\nEach version is given a distinguishing version number.  If the Program\nspecifies a version number of this License which applies to it and \"any\nlater version\", you have the option of following the terms and conditions\neither of that version or of any later version published by the Free\nSoftware Foundation.  If the Program does not specify a version number of\nthis License, you may choose any version ever published by the Free Software\nFoundation.\n\n  10. If you wish to incorporate parts of the Program into other free\nprograms whose distribution conditions are different, write to the author\nto ask for permission.  For software which is copyrighted by the Free\nSoftware Foundation, write to the Free Software Foundation; we sometimes\nmake exceptions for this.  Our decision will be guided by the two goals\nof preserving the free status of all derivatives of our free software and\nof promoting the sharing and reuse of software generally.\n\n                            NO WARRANTY\n\n  11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY\nFOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW.  EXCEPT WHEN\nOTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES\nPROVIDE THE PROGRAM \"AS IS\" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED\nOR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\nMERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.  THE ENTIRE RISK AS\nTO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU.  SHOULD THE\nPROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,\nREPAIR OR CORRECTION.\n\n  12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING\nWILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR\nREDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,\nINCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING\nOUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED\nTO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY\nYOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER\nPROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE\nPOSSIBILITY OF SUCH DAMAGES.\n\n                     END OF TERMS AND CONDITIONS\n\n            How to Apply These Terms to Your New Programs\n\n  If you develop a new program, and you want it to be of the greatest\npossible use to the public, the best way to achieve this is to make it\nfree software which everyone can redistribute and change under these terms.\n\n  To do so, attach the following notices to the program.  It is safest\nto attach them to the start of each source file to most effectively\nconvey the exclusion of warranty; and each file should have at least\nthe \"copyright\" line and a pointer to where the full notice is found.\n\n    <one line to give the program's name and a brief idea of what it does.>\n    Copyright (C) <year>  <name of author>\n\n    This program is free software; you can redistribute it and/or modify\n    it under the terms of the GNU General Public License as published by\n    the Free Software Foundation; either version 2 of the License, or\n    (at your option) any later version.\n\n    This program is distributed in the hope that it will be useful,\n    but WITHOUT ANY WARRANTY; without even the implied warranty of\n    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n    GNU General Public License for more details.\n\n    You should have received a copy of the GNU General Public License along\n    with this program; if not, write to the Free Software Foundation, Inc.,\n    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.\n\nAlso add information on how to contact you by electronic and paper mail.\n\nIf the program is interactive, make it output a short notice like this\nwhen it starts in an interactive mode:\n\n    Gnomovision version 69, Copyright (C) year name of author\n    Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.\n    This is free software, and you are welcome to redistribute it\n    under certain conditions; type `show c' for details.\n\nThe hypothetical commands `show w' and `show c' should show the appropriate\nparts of the General Public License.  Of course, the commands you use may\nbe called something other than `show w' and `show c'; they could even be\nmouse-clicks or menu items--whatever suits your program.\n\nYou should also get your employer (if you work as a programmer) or your\nschool, if any, to sign a \"copyright disclaimer\" for the program, if\nnecessary.  Here is a sample; alter the names:\n\n  Yoyodyne, Inc., hereby disclaims all copyright interest in the program\n  `Gnomovision' (which makes passes at compilers) written by James Hacker.\n\n  <signature of Ty Coon>, 1 April 1989\n  Ty Coon, President of Vice\n\nThis General Public License does not permit incorporating your program into\nproprietary programs.  If your program is a subroutine library, you may\nconsider it more useful to permit linking proprietary applications with the\nlibrary.  If this is what you want to do, use the GNU Lesser General\nPublic License instead of this License.\n"
  },
  {
    "path": "Administrative/releaseFiles/kactus2.desktop",
    "content": "[Desktop Entry]\nVersion=1.0\nType=Application\nName=Kactus2\nComment=The most user-friendly IP-XACT based EDA tool ever!\nTryExec=kactus2\nExec=kactus2\nIcon=/usr/share/pixmaps/kactus2.png\nTerminal=false\nStartupNotify=true\nCategories=Development;\n"
  },
  {
    "path": "Administrative/releaseFiles/kactus2.xpm",
    "content": "/* XPM */\nstatic char *kactus_[] = {\n/* columns rows colors chars-per-pixel */\n\"32 32 235 2\",\n\"   c #080B00\",\n\".  c #121401\",\n\"X  c #191D00\",\n\"o  c #1A1F09\",\n\"O  c #1D2201\",\n\"+  c #1F220A\",\n\"@  c #212602\",\n\"#  c #292F04\",\n\"$  c #262D0B\",\n\"%  c #282E0C\",\n\"&  c #2B3204\",\n\"*  c #2F3805\",\n\"=  c #2B330D\",\n\"-  c #323B06\",\n\";  c #343D0B\",\n\":  c #2C3410\",\n\">  c #303516\",\n\",  c #343C12\",\n\"<  c #383F11\",\n\"1  c #30351A\",\n\"2  c #374007\",\n\"3  c #374108\",\n\"4  c #3A440C\",\n\"5  c #3F490B\",\n\"6  c #374013\",\n\"7  c #3B4514\",\n\"8  c #3E4915\",\n\"9  c #3D451C\",\n\"0  c #3A4024\",\n\"q  c #3B4233\",\n\"w  c #424E0C\",\n\"e  c #4E5A00\",\n\"r  c #46530D\",\n\"t  c #49550D\",\n\"y  c #4E5B0D\",\n\"u  c #515B00\",\n\"i  c #505E0D\",\n\"p  c #424C15\",\n\"a  c #444F18\",\n\"s  c #455115\",\n\"d  c #495511\",\n\"f  c #4E5B13\",\n\"g  c #465218\",\n\"h  c #495519\",\n\"j  c #4D5A1A\",\n\"k  c #515F14\",\n\"l  c #515E1B\",\n\"z  c #556314\",\n\"x  c #586714\",\n\"c  c #5C6C15\",\n\"v  c #55631C\",\n\"b  c #58671E\",\n\"n  c #5B6A1D\",\n\"m  c #606F17\",\n\"M  c #414922\",\n\"N  c #444C2A\",\n\"B  c #4C5722\",\n\"V  c #4C553A\",\n\"C  c #545F37\",\n\"Z  c #546025\",\n\"A  c #596624\",\n\"S  c #5D6C21\",\n\"D  c #556135\",\n\"F  c #5B6730\",\n\"G  c #5D6932\",\n\"H  c #5B673A\",\n\"J  c #627221\",\n\"K  c #6D7C2C\",\n\"L  c #647135\",\n\"P  c #687630\",\n\"I  c #6A7A31\",\n\"U  c #6B7A3F\",\n\"Y  c #4C5648\",\n\"T  c #535D41\",\n\"R  c #545D4F\",\n\"E  c #4E5751\",\n\"W  c #555F57\",\n\"Q  c #535F5D\",\n\"!  c #556042\",\n\"~  c #616C4B\",\n\"^  c #687644\",\n\"/  c #6C7A47\",\n\"(  c #65734C\",\n\")  c #6D7B4D\",\n\"_  c #626F51\",\n\"`  c #6D7C51\",\n\"'  c #6F7D5A\",\n\"]  c #6B7862\",\n\"[  c #69776F\",\n\"{  c #6C796A\",\n\"}  c #70803F\",\n\"|  c #728247\",\n\" . c #72814E\",\n\".. c #778653\",\n\"X. c #7D8C52\",\n\"o. c #738259\",\n\"O. c #77895C\",\n\"+. c #738664\",\n\"@. c #7F8D65\",\n\"#. c #74816E\",\n\"$. c #7B8A6F\",\n\"%. c #7F9564\",\n\"&. c #769068\",\n\"*. c #7E8E74\",\n\"=. c #778378\",\n\"-. c #788778\",\n\";. c #7F8E7B\",\n\":. c #859765\",\n\">. c #83936D\",\n\",. c #889A6A\",\n\"<. c #808D7B\",\n\"1. c #859575\",\n\"2. c #8B9D75\",\n\"3. c #88967F\",\n\"4. c #91A275\",\n\"5. c #92A57F\",\n\"6. c #6D828A\",\n\"7. c #788985\",\n\"8. c #7E928E\",\n\"9. c #788B91\",\n\"0. c #4BADF7\",\n\"q. c #46ABFA\",\n\"w. c #4BAEFA\",\n\"e. c #52AFF7\",\n\"r. c #50AFF8\",\n\"t. c #4DB0FD\",\n\"y. c #56B2F7\",\n\"u. c #59B3F7\",\n\"i. c #54B3FB\",\n\"p. c #5BB6FA\",\n\"a. c #5DB8FE\",\n\"s. c #63B8F7\",\n\"d. c #61B7F9\",\n\"f. c #64BAFC\",\n\"g. c #6BBDFB\",\n\"h. c #72BFF7\",\n\"j. c #71BFF9\",\n\"k. c #6DC0FE\",\n\"l. c #76C1F7\",\n\"z. c #78C1F7\",\n\"x. c #75C2FB\",\n\"c. c #7BC5FB\",\n\"v. c #7EC9FF\",\n\"b. c #8B9B85\",\n\"n. c #88978E\",\n\"m. c #819B8A\",\n\"M. c #839593\",\n\"N. c #839894\",\n\"B. c #87969D\",\n\"V. c #899D9F\",\n\"C. c #8EA684\",\n\"Z. c #90A280\",\n\"A. c #99AC86\",\n\"S. c #93A78E\",\n\"D. c #97A98E\",\n\"F. c #99AD93\",\n\"G. c #99A998\",\n\"H. c #8CAFAC\",\n\"J. c #94A3AA\",\n\"K. c #9EB3A2\",\n\"L. c #92ABB3\",\n\"P. c #9CBDBD\",\n\"I. c #A0B1A3\",\n\"U. c #A1B5AF\",\n\"Y. c #A4BCB4\",\n\"T. c #A8BBB4\",\n\"R. c #A9BFB8\",\n\"E. c #ABC0B5\",\n\"W. c #BACEBB\",\n\"Q. c #95B1C2\",\n\"!. c #9EBCCB\",\n\"~. c #9CBED3\",\n\"^. c #A6BCC7\",\n\"/. c #ABBCC5\",\n\"(. c #A4BFCD\",\n\"). c #96C4D5\",\n\"_. c #AEC8CD\",\n\"`. c #B3C7C7\",\n\"'. c #BBCEC1\",\n\"]. c #B4CDCE\",\n\"[. c #B8CCCB\",\n\"{. c #A5C2D4\",\n\"}. c #ACCAD0\",\n\"|. c #A4CADE\",\n\" X c #B1CDD3\",\n\".X c #BCCFD3\",\n\"XX c #B2CBD9\",\n\"oX c #91C6E6\",\n\"OX c #97CDED\",\n\"+X c #82C7FA\",\n\"@X c #84CAFE\",\n\"#X c #8BCDFD\",\n\"$X c #92CFFC\",\n\"%X c #8ED1FF\",\n\"&X c #94D1FE\",\n\"*X c #9AD4FE\",\n\"=X c #97D8FF\",\n\"-X c #9ED9FF\",\n\";X c #A4CBE6\",\n\":X c #AACFE8\",\n\">X c #AFD4EF\",\n\",X c #B4D3E3\",\n\"<X c #BCD8E4\",\n\"1X c #B2D2E9\",\n\"2X c #B8D9ED\",\n\"3X c #A1D0F2\",\n\"4X c #AFD7F0\",\n\"5X c #A0D6FD\",\n\"6X c #ADD7F8\",\n\"7X c #A3DAFF\",\n\"8X c #ABDDFE\",\n\"9X c #B7DBF5\",\n\"0X c #BBDCF2\",\n\"qX c #B4DFFE\",\n\"wX c #ADE0FF\",\n\"eX c #BFE0F6\",\n\"rX c #B4E2FF\",\n\"tX c #BAE3FF\",\n\"yX c #BDE8FF\",\n\"uX c #D1E7DF\",\n\"iX c #CCDEE3\",\n\"pX c #CADFEB\",\n\"aX c #CBE4F4\",\n\"sX c #C4E5FB\",\n\"dX c #C9E6FD\",\n\"fX c #C1E9FF\",\n\"gX c #CBECFF\",\n\"hX c #D4EDFD\",\n\"jX c #CDF1FF\",\n\"kX c #DFF5F7\",\n\"lX c #D3F1FF\",\n\"zX c #D9F5FF\",\n\"xX c #DDF9FF\",\n\"cX c #E2FBFF\",\n\"vX c #ECFFFF\",\n/* pixels */\n\"@X@X@X@Xv.@Xc.c.c.v.&XyX:.c J K <X-Xv.k.g.k.k.g.g.g.f.f.f.f.f.a.\",\n\"+Xc.c.c.c.c.c.c.z.c.$XtX:.c J c E.8X+Xg.g.g.g.x.x.k.g.f.f.p.a.p.\",\n\"v.c.c.z.c.x.l.l.x.v.&XtX,.c J c Z.rX#Xh.g.x.x.@X#Xv.x.f.s.p.p.p.\",\n\"v.v.+Xv.c.v.x.v.x.c.%XtX2.c J c :.tX#Xx.g.v.#X).&.oX@Xg.f.a.a.a.\",\n\"c.l.c.l.l.x.l.l.x.x.#XrX5.x S n P ,X&Xz.h.+X7X%.u m.*Xh.s.p.p.u.\",\n\"v.v.v.v.v.x.c.v.x.c.#XrXD.x n n n ].7Xc.c.$X4XI i +.8Xv.f.a.a.a.\",\n\"c.l.l.x.l.x.x.l.x.h.+X8XK.z n S x U.8Xc.x.*X}.n f ` 8Xc.s.y.u.y.\",\n\"v.c.v.@X@X%Xv.c.c.c.#XrXR.z b b z S.wX@X+X7XY.z f ` qX@Xf.a.a.a.\",\n\"l.l.c.#X&XOX&X+Xz.z.#XtX`.v b b k >.qX#X+X8XF.y t ' qXc.s.u.u.u.\",\n\"x.v.@X-XH.I |.*X%X#X7XaXiXA v v k  .qX$X#XrX2.y r $.rXv.f.a.a.i.\",\n\"c.z.#XwX+.e Z.8X&X-XP.P b.L v Z k L 0X*X&XtX..k c 1.tX+Xf.p.i.u.\",\n\"x.z.#XrX( t | sX6XrXO.i 6 h v l l A ,X5X5X0XL v c G 4X#Xf.y.a.i.\",\n\"x.c.$XtX( r A <XtXsX/ f , 8 v j l l _.qXrX].x b j 8 !.%Xg.p.i.i.\",\n\"x.l.#XtX~ w k T.gXdX^ f 6 6 v j l r T.dXgXD.f v h 3 L.*Xg.y.i.y.\",\n\"x.x.%XyX~ w w S.jXhX) d 7 , l j h w G.cXhX| z h s * L.*Xg.a.i.i.\",\n\"k.l.#XrX] 5 w >.lXlXo.d p : j h h w b.kX4.x l g 7 % L.*Xg.y.e.i.\",\n\"k.x.#XrX-.; w ^ hXzX1.t g : j h h g D U z v j p 7 % Q.=Xk.i.i.i.\",\n\"g.h.+XrXn.- p Z pXzXG.d j : h g g g p d h 8 8 8 , = !.%Xs.i.i.t.\",\n\"k.k.v.8XL.; p d [.zX`.f v , p g g p p p ; T D 3 : 1 :X#Xs.i.t.i.\",\n\"g.g.c.5X(.4 8 5 I.lXaXG j , p p p p 8 < =.pXC ; & q 6Xv.p.y.t.t.\",\n\"g.g.l.&X1X0 8 4 1.hXgX*.w 7 8 p p 8 8 /.vX.X6 : @ W 8Xx.p.t.t.0.\",\n\"f.g.x.#XtXT 3 4 ( gXyXXXp 8 8 p p h n A.uX;.& : X 9.7Xg.i.i.t.i.\",\n\"f.f.g.c.rX{ * 7 B <XqXfX{ 2 8 p h l A z Z , : $ + ).#Xa.i.0.0.0.\",\n\"k.f.g.v.wXV.& 8 5 R.tX8X1XN ; 7 8 h h h ; = % . Q 8Xx.a.i.t.i.t.\",\n\"s.s.s.x.&X{., 6 2 *.yX*XrX^.9 8 : % 7 ; # O . q ;X@Xd.e.0.0.w.w.\",\n\"f.f.f.k.#XqXV ; 4 C 0X7X5XgX#.- , o . Y R E 6.3X%Xg.a.i.t.t.t.t.\",\n\"a.p.d.s.c.8X7.& 7 4 U.yX6XgX;.* 7 ,   J.xXrX=Xv.f.p.0.w.0.q.q.q.\",\n\"s.f.f.f.j.&X|., < 4 H aXjXcXn.& , , O B.yX@Xg.a.i.i.i.w.t.t.t.w.\",\n\"s.d.p.p.f.+XqX[ & 7 4 o.'.W.o.< , 6 # M.8Xg.y.r.0.t.0.t.q.q.q.q.\",\n\"a.p.p.p.d.g.%X:X0 ; 8 p f z v j 7 , * N.-Xg.i.t.t.t.w.q.q.t.w.q.\",\n\"a.a.a.a.p.f.x.-XQ.: - g h j j h 8 , # 8.-Xg.i.t.t.w.t.t.q.q.q.q.\",\n\"p.u.u.p.p.u.f.x.-X~.Y = 8 8 8 , : , # 8.-Xg.r.0.q.q.q.q.q.q.q.q.\"\n};\n"
  },
  {
    "path": "Administrative/releaseFiles/release_notes.txt",
    "content": "===============================================================================\r\n                            RELEASE NOTES : Kactus2\r\n                  Copyright (c) 2012-2025 Tampere University\r\n                 https://research.tuni.fi/system-on-chip/tools\r\n===============================================================================\r\n              + Improvement or feature added\r\n              - Bug fix or something removed\r\n              * Changed or Information\r\n===============================================================================\r\n\r\n08/01/2026 3.14.0\r\n----------------------------------------------------\r\n+ Added first version of interconnect generator (for HW designs)\r\n  + For generating IP-XACT interconnect components and corresponding RTL automatically (RTL generation is experimental)\r\n  + More info can be found in help pages\r\n+ Python scripts can be run on CLI startup with option -i\r\n+ Desired system view can be selected when opening a system design\r\n+ Changed save functions to be under a single button\r\n+ Enabled memory map header generator for IP-XACT 2022\r\n+ Improved bus interface editor\r\n+ Improved port map auto connector prefixes\r\n+ Improved the path searching algorithm\r\n+ Updated structured port validation and writing\r\n+ Enabled existing path search algorithms for memory map header generator\r\n- Changes to ports and bus interfaces in component editor do not delete connections in HW design\r\n- Fixes to expression parser\r\n- Fixes to verilog, VHDL and memory map header generators\r\n- Fixed VLNV editor crash in some situations\r\n- Fixes to SW design editor\r\n- Fixed documents containing the same components to not overwrite changes\r\n- Fixed meta component parameter parsing\r\n- Fixed Verilog importer port parsing\r\n* Changed File naming in VHDL / Verilog generator\r\n* Changed memory designer address range visualization when connection and item share ranges\r\n\r\n08/05/2025 3.13.5\r\n----------------------------------------------------\r\n- Fixed bug introduced in 3.13.4 where rows couldn't be removed in some table editors\r\n- Fixed a crash when creating a register inside a register file inside another register file\r\n* Changed default AUB for CPUs and address spaces to 8 bits\r\n\r\n24/04/2025 3.13.4\r\n----------------------------------------------------\r\n* Reworked memory designer to correctly show memory connections\r\n  * Designer now shows each address space as separate connection sets\r\n  * Items can be displayed in multiple connections\r\n  * Target-initiator path search now finds multiple paths instead of just the shortest\r\n  * Simple view of the designer excludes connections that are out of bounds (of connected address space)\r\n* Simplified file dependency scanning. File dependencies are no longer stored in IP-XACT files, except if manually created.\r\n+ Added option to toggle memory overlap on and off in memory designer\r\n+ Added ability to create IP-XACT 2022 components and designs through the Python API\r\n- Fixed Verilog and VHDL dependency scanning. Only file set files are scanned for dependencies, other dependencies are marked as external.\r\n- Fixed removal of multiple non-contiguous rows in tables\r\n- Fixed writing tied value of ad-hoc port with direction out (Verilog generator)\r\n\r\n14/10/2024 3.13.3\r\n----------------------------------------------------\r\n* Document lock made optional. Can be changed in settings, locking is disabled by default.\r\n+ Added parameter editors to abstraction definition editor and bus definition editor, added expression support to port abstractions\r\n+ Added HW Designer tool shortcuts\r\n+ Added ability to open referenced bus and abstraction definitions in bus interfaces by right-clicking in the component editor tree\r\n+ Improved validation in the component editor\r\n+ Improved windows installer\r\n- Fixed launching Kactus2 in CLI mode on Windows\r\n- Fixed design parameter dock window disappearing when switching tabs\r\n- Fixed changes made in component editor not reflecting in edited design (bus interfaces, ports)\r\n- Fixed issue with expression editors scrambling expression when overwriting current expression or a section of it\r\n- Fixed parsing unary minuses in systemverilog expressions\r\n- Fixed component mode condition validation\r\n- Fixed various bugs leading to crashes\r\n\r\n23/04/2024 3.13.2\r\n----------------------------------------------------\r\n+ HW Design improvements\r\n  * Added interconnection highlighting when hovered over\r\n  * Widened interconnection hitboxes to make them easier to select\r\n  * Added checks for double connections between component instances\r\n  * Reworked component instance auto connector tool to enable editing existing connections between component instances\r\n* Reworked memory designer\r\n- Fixed source importers not detecting filetype of files with absolute paths\r\n- Fixed creating new design configurations in the HW design configuration editor\r\n- Fixed AUB editors in memory map to accept expressions, AUB defaults to 8 bits when empty\r\n- Fixed crash in bus interface wizard caused by non-existent abstraction definition\r\n- Fixed the created bus interface from bus interface wizard not appearing in the editor\r\n- Fixed validation in abstraction definition ports editor\r\n- Fixed coloring of mirrored initiator interfaces\r\n- Fixed logical port creation for abstraction definitions in bus interface wizard\r\n\r\n13/02/2024 3.13.1\r\n----------------------------------------------------\r\n+ Prevent drag & drop between cross-standard revision components, designs etc.\r\n- Fixed missing fields in memory map visualizer on linux\r\n- Fixed crash when adding generated files to fileset when using specific generators\r\n- Fixed modelsim generator crashing in rare cases when changing generation output directory\r\n- Fixed portmap editor for 2022 standard\r\n- Fixed connectivity graph for 2022 standard\r\n\r\n08/12/2023 3.13.0\r\n----------------------------------------------------\r\n+ Added IP-XACT 2022 standard support for existing Kactus2 workflows\r\n  * Now possible to create and edit IP-XACT components compliant with the new 2022 IP-XACT standard\r\n  * Old 2014 standard is still supported\r\n  * IPs can be filtered by standard revision in the library\r\n  * Power domains added as a new feature of the IP-XACT 2022 standard\r\n\r\n- Fixed memory map visualization not showing overlap in some cases\r\n- Other fixes and tweaks in memory map visualization\r\n- Fixed Linux build issues (community contribution)\r\n- Fixed crashing when starting PythonAPI from Python\r\n\r\n07/06/2023 3.12.0\r\n----------------------------------------------------\r\n+ Updated user interface visuals\r\n  * Changed only one side editor to be visible on left and right\r\n  * Added sidebars for controlling side editor visibilities\r\n\t* Updated side editor colors\r\n  * Updated library layout and filters\r\n  * Updated lots of icons\r\n  * Updated Component editor navigation tree to show modified elements\r\n  * Updated Design editor column and grid color\r\n  * Relocated script editor from side editor to the right side of main window\r\n  * Relocated Component preview to LibraryWidget\r\n  * Relocated all generator plugins under one button in toolbar\r\n+ Improved documentation generation\r\n  * Added markdown format\r\n  * Added register files\r\n  * Added table of registers for each address block\r\n  * Added field enumerations\r\n  * Updated formatting for both HTML and markdown\r\n+ Added validity check results in Component editor general page\r\n+ Added new editor for selecting channels, abstraction types and file sets\r\n+ Added Renode platform description generator as a plugin\r\n  * Added generation of platform description files (.repl) for CPUs, peripherals and memories\r\n  * Added configuration file for generation\r\n\r\n- Fixed port ad-hoc status after importing from CSV file\r\n- Fixed updating address space visualization when local memory map changes\r\n- Fixed Design editor crashing with ad-hoc connection referencing non-existent port as endpoint\r\n- Fixed library filters not being saved in settings\r\n- Fixed crashing on Verilog generation (community contribution)\r\n- Fixed generated indexing in Verilog when many interfaces map to the same physical port\r\n- Fixed VHDL importing failing with last port on specific conditions\r\n- Fixed reset mask default value in SVD generation\r\n\r\n* Separated Abstraction Definition editor from Bus Definition editor \r\n* Combined ad-hoc visibility and ad-hoc tieoff editor into one\r\n* Changed build target directory to executable in Visual Studio\r\n* Removed x86 build configurations in Visual Studio\r\n\r\n17/01/2023 3.11.1\r\n----------------------------------------------------\r\n* Added missing Windows vista style library\r\n\r\n12/01/2023 3.11.0\r\n----------------------------------------------------\r\n* Migrated to Qt 6.2.4, Qt5 build is no longer supported\r\n\r\n+ Updated choice editor\r\n+ Added line editor for expressions\r\n+ Added doxygen flag to swig for better documentation of functions\r\n+ Added undo/redo in Python script editor\r\n+ Added support for ternary opertor (?:) in SystemVerilog expressions (community contribution)\r\n+ Added width for port default values in generated Verilog (community contribution)\r\n+ Added register dimensions in SVD generation\r\n\r\n- Changed configurable element values of a component instance to use table instead of a tree view\r\n- Improved port editor performance\r\n- Improved configuration and help generation in Linux (community contribution)\r\n- Fixed disappearing component remap states \r\n- Fixed application settings losing code editor settings on startup\r\n- Fixed Python script editor visibility to persist between documents\r\n- Fixed Python interpreter thread not quiting at application shutdown\r\n- Fixed component editor crashing after removing last memory map\r\n- Fixed component editor crashing after removing memory remaps\r\n- Fixed SVD generator crashing on sticky note with assosiaction\r\n- Removed win32 build configurations for VS\r\n\r\n* Migrated to VS2022\r\n* Windows installer now embeds Python version 3.10.6\r\n\r\n21/06/2022 3.10.0\r\n----------------------------------------------------\r\n+ Added bus interfaces in Python API\r\n+ Added subspace maps to memory maps visualization\r\n+ Replaced Python console in GUI with a text editor\r\n+ Increased editor title sizes and marked Kactus2 extensions with an icon\r\n+ Added automatic expansion of hierarchy for lone items in library views and \r\n  component editor tree.\r\n+ Added register dimension indexing in SVD generator\r\n+ Added checks and formatting for address-cells and size-cells in Linux Device \r\n  Tree Generator\r\n\r\n- Removed file modification watches for XML files so changes on the disk are no\r\n  shown to user. The implementation was incompatible with standalone Python \r\n  script runs\r\n- Removed exit screen\r\n- Fixed crashing when creating connection in design with draft bus interface\r\n- Fixed crashing for incorrect indexing with memory remaps\r\n- Fixed crashing when reading invalid XML file\r\n- Fixed design editor reordering component bus interfaces in XML\r\n- Fixed Verilog generator parameter order\r\n- Fixed Verilog generator module parameter values\r\n- Fixed VHDL generics import stopping on semicolon in a comment\r\n\r\n* Relocated common functions and library handling to new KactusAPI shared \r\n  library\r\n* Changed port map editor tree format to a table format\r\n* Migrated to Qt 5.15.2\r\n* Kactus2 will migrate to Qt6 in version 3.11.\r\n\r\n06/04/2022 3.9.333\r\n----------------------------------------------------\r\n+ Added subspace maps to memory maps\r\n- Fixed configurable element value usage in design instantiations\r\n\r\n19/01/2022 3.9.171\r\n----------------------------------------------------\r\n- Fixed inclusion of plugins to installer\r\n- Fixed rare crashing in adding memory remaps\r\n\r\n07/12/2021 3.9.168\r\n----------------------------------------------------\r\n+ Embedded Python 3.8 to Kactus2\r\n+ Added SVD generation to Python interpreter\r\n+ Updated Verilog generator path selection and file renaming\r\n+ Ports can be created from bus interface abstraction definition\r\n+ Added basic design handling to Python interpreter\r\n\t* Component instances can be added and removed\r\n\t* Interconnections can be created between bus interfaces\r\n\t* Ad hoc connections can be created between ports\r\n+ Updated Linux Device Tree Generator\r\n\t* Added channels\r\n\t* Added address blocks\r\n\t* Added calculation for address and size cells\r\n\t* Generates files for each found CPU\r\n+ Added warning symbols for bus interfaces without connected port maps in HW design\r\n\r\n24/06/2021 3.9.0\r\n----------------------------------------------------\r\n\r\n+ Added PythonAPI to provide access to Kactus2 through python code\r\n\t* PythonAPI is separated from Qt\r\n\t* PythonAPI folder contains example scripts\r\n\t* PythonAPI can also use some generators (VHDL, Verilog, Linux device tree and Makefile)\r\n+ Added KactusAPI class to provide library and utilities to PythonAPI\r\n+ Added a console in GUI for interpreting python scripts\r\n\t* Allows multiline code to be executed in Python on Windows console mode\r\n\t* Added script history, run file and save function\r\n+ Separated Kactus2 editor models into interfaces\r\n\t* Ports\r\n\t* Parameters\r\n\t* Fields\r\n\t* Field resets\r\n\t* Registers\r\n\t* Address block\r\n\t* Memory maps\r\n\t* Files\r\n\t* File sets\r\n\t* Component instantiations\r\n\t* Port maps\r\n\t* Port abstractions\r\n\t* Bus interfaces\r\n\r\n+ Added CMSIS System View Description (SVD) generator plugin\r\n\t* SVD files can be created from a HW design\r\n+ Added extend port abstractions to abstraction definition editor\r\n+ Added depenency analysis for (system) Verilog module instantiations\r\n\r\n- Fixed parameter string value parsing in Verilog import\r\n- Fixed right port boundary in ConnectionEditor\r\n- Fixed port map tables with non-existing ports\r\n- Fixed document writing pointer sharing\r\n- Fixed memory visualization\r\n\t* Changed fields and field gaps for faster updates\r\n\t* Fixed label resizing, positioning and clipping\r\n\t* Fixed visualization on expanding items\r\n\t* Fixed updating register files\r\n\t* Updated visualization to correctly display over 32-bit long address ranges\r\n- Fixed crashing when re-importing a file to a Component\r\n\r\n13/11/2019 3.8.0\r\n----------------------------------------------------\r\n\r\n+ Improved support for Transactional ports\r\n    * Added editor in Component Editor\r\n\t* Added transactional connections and interfaces in Design schematic\r\n\t* Removed transactional ports from generated Verilog files\r\n+ Added tags for component categorization and searchs in library\r\n+ Improved RTL import\r\n    * Added option to browse for files outside file sets\r\n\t* Added option to select one module/entity from a file containing multiple definitions\r\n+ Added support for file set references in slave bus interfaces\r\n+ Improved editing options for Other Clock Driver timing values\r\n\r\n- Fixed an issue where \"Save as...\" on locked bus definition caused the application to crash\r\n- Fixed Linux Device Tree Generator Plugin to correctly format one device tree instead of multiple  \r\n\r\n29/03/2019 3.7.0\r\n----------------------------------------------------\r\n\r\n+ Added auto connector tool for component instances in a design\r\n+ Added editor for Vendor Extensions in Component and Design\r\n+ Added support for register files\r\n+ Added support for multiple reset values for register fields\r\n+ Added scrolling to design view when items are dragged\r\n+ Improved memory map visualization and library loading performance\r\n+ Improved expression parsing\r\n    * Added support for bitwise operations\r\n    * Improved expression solving performance\r\n+ Improved VHDL and Verilog support\r\n    * Fixed array and vector boundary handling\r\n    * Include Verilog file parameters are imported\r\n    * Imported parameter type is set based on the data type in VHDL\r\n+ Improved HW design editor to accept connections between extended bus definitions\r\n\r\n- Fixed an issue where removing an item in library did not remove the file on disk\r\n- Fixed an issue where removing items in memory maps would cause the application to crash\r\n- Fixed an issue where setting an empty bus interface mode would cause the application to crash\r\n- Fixed an issue where design active views were cleared on save\r\n- Fixed an issue where plugin details were incorrectly displayed in the settings\r\n- Fixed an issue where component instance parameter override was incorrectly displayed when\r\n  using parameter choices \r\n- Fixed an issue where multiline description was not correctly CSV imported/exported\r\n\r\n\r\n29/06/2018 3.6.50\r\n----------------------------------------------------\r\n\r\n+ Added editor for AbstractionDefinition transactional ports\r\n+ Added option to extend BusDefinitions\r\n+ Added editor for field reserved-value\r\n+ Added SystemVerilog files to be included in generated Quartus projects\r\n\r\n- Fixed an issue where modifying/removing files outside Kactus2 caused the application to crash\r\n- Fixed an issue where editing AbstractionDefinition port properties affected all modes\r\n\r\n12/06/2018 3.6.0\r\n----------------------------------------------------\r\n\r\n+ Added support to run Kactus2 from command-line without GUI\r\n+ Added editor for port type definitions\r\n+ Added support for multiple abstraction definitions in a bus interface\r\n+ Improvements to Memory Designer\r\n    * Improved item scaling in non-compressed mode\r\n    * Improved search through hierarchies\r\n    * Improved visulization for multiple address spaces connected to one memory map\r\n+ Added feature to save HW, System and Memory Designer view as a PNG, JPG or SVG image\r\n+ Improved expression parsing\r\n    * Support for exp, pow and sqrt functions\r\n    * Better suppport for string expressions and their comparison\r\n    * Faster parsing algorithm\r\n+ Added Linux Device Tree Generator plugin\r\n+ IP-XACT library handling improved for better performance and readability\r\n+ HW and System design area size now adjusts to contents\r\n\r\n- Restored automatic item selection in library view when component instance is selected\r\n- Fixed addressSpaceRef-attribute parsing and writing\r\n- Fixed export dialog from hierarchy view\r\n- Fixed missing type information in VHDL generation\r\n- Fixed error in entity parsing in VHDL import\r\n- Fixed a crash when creating a new HW Design\r\n- Fixed a crash in saving user settings for code editor\r\n- Fixed an issue where Component file set directories were lost on refresh\r\n\r\n* Changed binary name to kactus2 (previously Kactus2) in Linux\r\n* Enabled C++11 by default in Linux compilation\r\n* Improved Linux installation in user-specified directory\r\n* Migrated to Qt 5.10.1\r\n* Migrated to VS2017\r\n\r\n23/11/2017 3.5.0\r\n----------------------------------------------------\r\n\r\n+ Graphical user interface visual update:\r\n    * All icons updated\r\n    * Instruction labels added in dialogs\r\n    * Colors centralized in KactusColors.h\r\n+ Added feature to show the directory icons provided by OS for library paths \r\n  which shows version controlled items in Windows\r\n+ Added feature to automatically update library view when file changes on disk\r\n+ Added feature to select the which HW design to open for an IP-XACT component\r\n  with multiple designs\r\n+ Added editor for indirect interfaces in component\r\n+ Added editor for component instantiation parameters\r\n+ Added editor for design configuration instantiation parameters\r\n+ Added editor for design configuration instantiation configurable elements\r\n+ Added editor for design instantiation configurable elements\r\n+ Added feature to define prefix in port map auto-connect for better matching\r\n+ Added editor for design parameters\r\n+ Improved performance on drawing connections in design\r\n+ Added delete in context menu in design view\r\n+ Improvements in  Memory Designer:\r\n    * Added support for multiple items accessing the same memory map\r\n    * Improved layout for items\r\n+ Improvements in HTML generation:\r\n    * Added writing register and field reset values in HTML\r\n    * Added writing instantiations within a component in HTML\r\n\r\n- Fixed error in XML schema location writing\r\n- Fixed C source editor refresh\r\n- Fixed port size parsign in PADS part generator which previously caused the\r\n  plugin to crash\r\n- TLMW generator plugin removed from build\r\n\r\n* Software component instance merged to component instance\r\n* Changed VHDL import to create component parameters and retains references in\r\n  port boundaries\r\n* Moved VHDL generator from core to a separate plugin\r\n* ModelSim generator plugin moved to same framework as Verilog generator\r\n\r\n22/03/2017 3.4.0\r\n----------------------------------------------------\r\n\r\n+ Enhanced features for Memory Designer:\r\n    * Added feature to visualize overlapping memory items    \r\n    * Added feature to open the containing component and the editor for the selected item\r\n    * Added feature to visualize local memory maps\r\n    * Changed the visual look of a connection through a bridge\r\n    * Changed display name to be shown instead of element name, if defined\r\n+ Improvements to Verilog generation:\r\n    * Added preview for generated files\r\n    * Added message console for reporting generation status\r\n    * Improved port assignment and vector boundary generation logic\r\n+ Fixed error in importing Verilog ports\r\n+ Added editor for Catalogs\r\n+ Component editor layout updated for most editors\r\n+ Enabled expressions in parameter value when using a choice\r\n+ Added isPresent-property to memory maps, address blocks, address spaces and segments\r\n+ Improved completion help for fileset filetypes and groups \r\n+ Enabled CSV import/export of files in a fileset\r\n+ Added feature to hide immediate values from configurable element values\r\n+ Enabled keyboard navigation in VLNV tree view\r\n+ Added expand/collapse options in VLNV tree view context menu\r\n+ Help and tooltips updated\r\n+ Custom XML namespaces are retained in XML files\r\n\r\n- Removed address space reference and base address from mirrored-master bus interface\r\n- Fixed crashing when adding port maps in component\r\n- Fixed a referencing issue with configurable element values when changing active view\r\n- Fixed crashing when a design did not have a configuration\r\n- Fixed crashing when closing a design in specific cases\r\n- Fixed modifications to design connections while the document was unlocked\r\n- Fixed CSV import/export of signal definitions in abstraction definition\r\n- Fixed missing component editor visibility options\r\n\r\n* System mode bus interface coloring changed from red to purple to avoid confusion with invalid interfaces\r\n* Changed \"frozen column\" in editors to use vertical headers instead of a separate table\r\n* Toolbar \"Check intergrity\" changed to show listing of all errors within the library\r\n  in separate window.\r\n* Exit screen is displayed longer\r\n\r\n09/12/2016 3.3.0\r\n----------------------------------------------------\r\n\r\n+ Enhanced features for Memory Designer:\r\n    * Register fields added \r\n    * Compression of items to minimize the required space\r\n    * Multiple address spaces can now be shown as part of the same connection\r\n    * Filtering options added\r\n+ Memory connectivity analysis now manages also instances with identical names\r\n+ File paths within filesets now accept URI expressions\r\n+ Files can be drag-dropped to filesets from the file system\r\n+ Memory map visualization items have now bigger area for expand/collapse\r\n+ Port direction is now checked when a default value is set\r\n+ Port map invert and tieoff are now also shown on the top level of tree hierarchy\r\n+ Zooming now follows mouse location in design\r\n+ Enhanced usage of drafts in design:\r\n    * Bus interface definitions copying when connecting hierarchical draft interface fixed\r\n    * Bus interface definitions copying when connecting non-hierarchical draft interface removed\r\n    * Bus interface definitions and port copying to draft instances changed to take place on\r\n      packaging of the containing draft component instance\r\n    * Copy-paste of bus interface to a draft component instance changed to copy only the name and \r\n      the mode of the interface\r\n+ Notification on trying to read XML files of previous standard versions added\r\n+ Improvements to Verilog generation:\r\n    * Generation setup dialog simplified\r\n    * Register definition creation set as optional\r\n    * Module name is correctly used for component instances\r\n    * Environmental identifier created by the generator changed\r\n+ Improvements to Verilog import:\r\n    * Port type parsing improved for Verilog-2001 style ports\r\n    * Parameter parsing improved for lists of parameters\r\n    * Environmental identifier created by the import changed\r\n+ Improved features for MakefileGenerator:\r\n    * Conflicting file selection added\r\n    * Launcher script creation set to optional\r\n    \r\n- Bus interface creation wizard fixed from preventing user to proceed from the general\r\n  settings page due to missing port maps\r\n- Component instance replace in design changed to better preserve existing connections\r\n- Port bounds for ad-hoc connections in design fixed\r\n- Author information read from XML fixed\r\n- Symbolic file link usage for XML files fixed\r\n- Toolbar placement at the bottom of main window fixed\r\n- Software views are replaced by views and component instantiations\r\n\r\n* Community guidelines included in manual\r\n* Settings file path is now shown on the General page of Settings\r\n* Automatic port mapping changed to less aggressively connect ports\r\n* Component instance architecture changed to be correctly set by VHDL generator\r\n\r\nKNOWN UNRESOLVED ISSUES:\r\n* UI issue: paste command does not update usage count of referenced parameters\r\n\r\n05/10/2016 3.2.35\r\n----------------------------------------------------\r\n\r\n+ Enabled URIs to be used in filepaths for files within filesets\r\n+ Improved memory design layout of items\r\n\r\n- Fixed bug preventing signal renaming in Abstraction Defintions\r\n\r\nKNOWN UNRESOLVED ISSUES:\r\n* UI issue: paste command does not update usage count of referenced parameters.\r\n\r\n23/09/2016 3.2.0\r\n----------------------------------------------------\r\n\r\n+ Added preliminary version of memory designer:\r\n    * Address spaces and Memory maps within design hierarchy are visualized with their\r\n      addressing information\r\n    * Connectivity between spaces and maps are visualized\r\n+ Added preliminary version of memory connectivity analysis within designs\r\n    * Added plugin for generating memory listing in CSV format\r\n+ Improvements to Verilog generation\r\n+ Added \"Getting started\" section to help\r\n+ Fixed performance issues\r\n\r\n- Fixed crashing when opening a bus interface without abstraction definition\r\n\r\n* ModelSim Generator moved from core to a separate plugin\r\n\r\nKNOWN UNRESOLVED ISSUES:\r\n* UI issue: paste command does not update usage count of referenced parameters.\r\n\r\n17/06/2016 3.1.0\r\n----------------------------------------------------\r\n\r\n+ New design for port map editor:\r\n    * Added feature to auto-connect logical and physical ports\r\n    * Logical and physical bounds are now easily editable\r\n+ Added support for tieoff values in design and port maps\r\n+ Added feature to copy memory-elements along with their sub-elements\r\n+ Improved expression support:\r\n    * Basic comparison operators are now accepted\r\n    * Values true/false are now accepted\r\n+ System group names are now visible and editable in Bus editor\r\n+ Generated Verilog parameters are now correctly ordered for references\r\n+ Performance improvements\r\n\r\n* ModelSim Generator moved from core to a separate plugin\r\n* XML processing instructions are now retained in IP-XACT files\r\n* Added option for Linux installation without admin privilidges\r\n\r\nKNOWN UNRESOLVED ISSUES:\r\n* UI issue: paste command does not update usage count of referenced parameters.\r\n\r\n22/04/2016 3.0.0\r\n----------------------------------------------------\r\n\r\n+ Updated all IP-XACT elements to 2014 standard\r\n+ Improved validation for many IP-XACT elements\r\n+ Updated Verilog generation for one-to-many ad-hoc connections.\r\n+ Added new view related editors for component editor:\r\n    * Component instantiations\r\n    * Design instantiations\r\n    * Design configuration instantiations.\r\n+ Updated port editor to accept ports without defined left and right bounds as ports with a width of 1.\r\n+ Updated parameter referencing.\r\n+ Updated expression parser.\r\n+ Updated component editor memory map visualization.\r\n+ In component editor, changed cut command to copy and remove selected cells of a table.\r\n+ Updated HW design editor:\r\n    * Updated component instance creation.\r\n    * Updated component instance removing.\r\n    * Updated component instance replacing.\r\n    * Updated connection removing.\r\n    * Invalid ad-hoc interfaces and ports are displayed with a red colour.\r\n    * Enabled deleting of invalid ad-hoc interfaces and ports.\r\n+ Usability fixing.\r\n\r\nKNOWN UNRESOLVED ISSUES:\r\n* UI issue: paste command does not update usage count of referenced parameters.\r\n\r\n18/03/2016 3.0.0 RC2\r\n----------------------------------------------------\r\n\r\n+ Fixed Linux compilation\r\n+ Added support for expressions in file build command flag replace\r\n+ Improved element validation with large numbers\r\n+ Improved expression evaluation performance\r\n+ Other minor improvements to usability\r\n\r\n- Corrected loading sticky notes in design editor\r\n\r\nKNOWN UNRESOLVED ISSUES:\r\n* Memory map header generation from a system design does not work properly.\r\n* SystemVerilog expressions are not supported by some features including generators.\r\n  If expressions or references have been used, it may cause at least the following issues:\r\n    * VHDL generator will generate wrong values.\r\n    * Port maps will not automatically adjust to changes in port size.\r\n* VHDL import does not preserve references to model parameters.\r\n* In ports editor, creating a bus interface through ports is not possible for name column.\r\n* VHDL generator crashes unexpectedly during run\r\n\r\n\r\n29/02/2016 3.0.0 RC1\r\n----------------------------------------------------\r\n\r\n+ Updated all IP-XACT elements to 2014 standard\r\n+ Improved validation for many IP-XACT elements\r\n\r\nKNOWN UNRESOLVED ISSUES:\r\n* Memory map header generation from a system design does not work properly.\r\n* Parameters created with version 2.7.0 may not work with the latest release due to \r\n  change in id formatting. The fastest way to fix this is to re-create the parameters.\r\n* SystemVerilog expressions are not supported by some features including generators.\r\n  If expressions or references have been used, it may cause at least the following issues:\r\n    * VHDL generator will generate wrong values.\r\n    * Port maps will not automatically adjust to changes in port size.\r\n* VHDL import does not preserve references to model parameters.\r\n* In ports editor, creating a bus interface through ports is not possible for name column.\r\n* VHDL generator crashes unexpectedly during run\r\n\r\n15/06/2015 2.8.0\r\n----------------------------------------------------\r\n\r\n+ Added feature to import parameters from include files.\r\n+ Improved configurable element variables editor\r\n    * Synchronizes with the enhanced model parameter definition.\r\n    * The parameters of the top component can be used in the configurable element variables.\r\n    * Variables are now grouped according to their location in the component.\r\n+ Added editors for IP-XACT elements remapState and memoryRemap.\r\n+ Added support for expressions in memory map elements.\r\n+ Added support for parameter references in generated header files.\r\n+ Added feature to save new versions of design configurations and designs.\r\n+ Added support for module parameters to hierarchical views.\r\n\r\nKNOWN UNRESOLVED ISSUES:\r\n* Memory map header generation from a system design does not work properly.\r\n* Parameters created with version 2.7.0 may not work with the latest release due to \r\n  change in id formatting. The fastest way to fix this is to re-create the parameters.\r\n* SystemVerilog expressions are not supported by some features including generators.\r\n  If expressions or references have been used, it may cause at least the following issues:\r\n    * VHDL generator will generate wrong values.\r\n    * Port maps will not automatically adjust to changes in port size.\r\n* VHDL import does not preserve references to model parameters.\r\n* In ports editor, creating a bus interface through ports is not possible for name column.\r\n\r\n13/05/2015 2.7.970\r\n----------------------------------------------------\r\n\r\n+ Added support for SystemVerilog expressions in memory map and address space visualization\r\n+ Added register dimensions in memory map visualization\r\n+ Added remaps for memory maps\r\n+ Added support for SystemVerilog expressions in generated memory map header files\r\n  excluding generation from a system design\r\n+ Improvements in memory map editor user interface\r\n\r\nKNOWN UNRESOLVED ISSUES:\r\n* Memory map header generation from a system design does not work properly.\r\n* Parameters created with version 2.7.0 may not work with the latest release due to \r\n  change in id formatting. The fastest way to fix this is to re-create the parameters.\r\n* SystemVerilog expressions are not supported by some features including generators.\r\n  If expressions or references have been used, it may cause at least the following issues:\r\n    * VHDL generator will generate wrong values.\r\n    * Port maps will not automatically adjust to changes in port size.\r\n* VHDL import does not preserve references to model parameters.\r\n\r\n09/04/2015 2.7.572\r\n----------------------------------------------------\r\n\r\n+ Added import for Verilog defines as component parameters\r\n+ Added dependency analysis for Verilog include directives\r\n+ Added grouping of configurable element values according to location in component\r\n+ Added placeholder for remap states in component editor\r\n\r\n* Changed types in Plugin and Source analyzer plugin interfaces\r\n\r\nKNOWN UNRESOLVED ISSUES:\r\n* Parameters created with version 2.7.0 may not work with the latest release due to \r\n  change in id formatting. The fastest way to fix this is to re-create the parameters.\r\n* SystemVerilog expressions are not supported by some features including generators.\r\n  If expressions or references have been used, it may cause at least the following issues:\r\n    * Memory map header generator will generate wrong offsets for registers.\r\n    * Memory maps visualization shows wrong offset for register and aligns them wrong.\r\n    * VHDL generator will generate wrong values.\r\n    * Port maps will not automatically adjust to changes in port size.\r\n* VHDL import does not preserve references to model parameters.\r\n\r\n27/03/2015 2.7.463\r\n----------------------------------------------------\r\n\r\n+ Added support for referencing parameters in top component of a design.\r\n+ Added new editor for parameter values in an array.\r\n+ Improved validation of configurable element values:\r\n    * Minimum, maximum and type restrictions are enforced.\r\n    * Choices can be selected from drop-down list.\r\n    * Arrays can be edited in similar fashion to component editor.\r\n+ Added support for enabling/disabling register fields.\r\n+ Added support for expressions in AddressBlock base addrss, range and width.\r\n+ Added validity checks and separate display for referenced designs in hierarchical views. \r\n\r\n* Configurable element values are now stored by default in Design Configuration instead of Design.\r\n* Renamed hierarchy level \"Global\" to \"Flat\".\r\n* Changed Quartus Pin Import plugin to conform with Import plugin interface.\r\n\r\nKNOWN UNRESOLVED ISSUES:\r\n* Parameters created with version 2.7.0 may not work with the latest release due to \r\n  change in id formatting. The fastest way to fix this is to re-create the parameters.\r\n* SystemVerilog expressions are not supported by some features including generators.\r\n  If expressions or references have been used, it may cause at least the following issues:\r\n    * Memory map header generator will generate wrong offsets for registers.\r\n    * Memory maps visualization shows wrong offset for register and aligns them wrong.\r\n    * VHDL generator will generate wrong values.\r\n    * Port maps will not automatically adjust to changes in port size.\r\n* VHDL import does not preserve references to model parameters.\r\n\r\n06/03/2015 2.7.192\r\n----------------------------------------------------\r\n\r\n+ Added support for references in Verilog generator.\r\n+ Verilog importer accepts semicolons in comments.\r\n+ Added memory maps and registers to html documentation.\r\n+ Added support for references in import wizard.\r\n    * Replaced evaluated value with IDs in Verilog import.\r\n+ Improved usability of expression editor.\r\n+ Added support for references in document generator.\r\n+ Implemented module parameters in views.\r\n+ Added name as a frozen column to parameters, model parameters and module parameters.\r\n    * Name and port number columns were frozen in port table.\r\n+ Where expressions are used, changed the table to show the expression by default.\r\n    * The tooltip now shows the evaluated value.\r\n+ Register reset value and reset mask can now be inserted as a bit type value.\r\n+ Arrays can be insterted as a value for parameters.\r\n\r\nKNOWN UNRESOLVED ISSUES:\r\n* Parameters created with version 2.7.0 may not work with the latest release due to \r\n  change in id formatting. The fastest way to fix this is to re-create the parameters.\r\n* SystemVerilog expressions are not supported by some features including generators.\r\n  If expressions or references have been used, it may cause at least the following issues:\r\n    * Memory map header generator will generate wrong offsets for registers.\r\n    * Memory maps visualization shows wrong offset for register and aligns them wrong.\r\n    * VHDL generator will generate wrong values.\r\n    * Port maps will not automatically adjust to changes in port size.\r\n* VHDL import does not preserve references to model parameters.\r\n\r\n06/02/2015 2.7.0\r\n----------------------------------------------------\r\n\r\n+ Added support for SystemVerilog expressions in\r\n    * component parameter and model parameter value,\r\n    * component port bounds and default value,\r\n    * component register offset, size and dimension and\r\n    * design configurable element values.\r\n+ Added support for referencing parameter and model parameter values in expressions.\r\n+ Added autocomplete feature for available parameter names in expressions.\r\n+ Added feature to view all elements referencing a parameter or model parameter.\r\n+ Configurable element values editor now automatically shows the configurable \r\n  elements in component instance, their current and default value.\r\n+ Added feature to show/hide elements of a component in component editor.\r\n+ Added support for component choices.\r\n+ Enabled different signal widths for master and slave modes in abstraction definition. \r\n+ Improved ribbon toolbar.\r\n\r\nKNOWN UNRESOLVED ISSUES:\r\n* SystemVerilog expressions are not supported by some features including generators.\r\n  If expressions or references have been used, it may cause at least the following issues:\r\n    * Memory map header generator will generate wrong offsets for registers.\r\n    * Memory maps visualization shows wrong offset for register and aligns them wrong.\r\n    * VHDL and Verilog generator will generate wrong values.\r\n    * Port maps will not automatically adjust to changes in port size.\r\n* VHDL import does not preserve references to model parameters.\r\n\r\n31/10/2014 2.6.0\r\n----------------------------------------------------\r\n\r\n+ New plugin interface for file import.\r\n+ New plugins:\r\n    * Verilog import.\r\n    * Verilog generator for components and designs.\r\n    * Makefile generator.\r\n+ Added feature to run import from component editor.\r\n+ Added editing of views to component wizard.\r\n+ Added feature to sort port list by port number.\r\n\r\n* Moved VHDL import tool to import plugin.\r\n* Updated MCAPI to version 2.015.\r\n* Updated MCAPI generator.\r\n\r\n08/07/2014 2.5.0\r\n----------------------------------------------------\r\n\r\n+ All vendor extensions are conserved in IP-XACT documents.\r\n+ Added feature to insert notes in designs.\r\n+ Added feature to run files e.g. script files from Filesets.\r\n+ Added feature to define default run executable for file types.\r\n+ Improved lock operation: Enables browsing of tabs while the document is locked.\r\n+ Added design column for memories.\r\n+ Improved opening of hierarchical components in design.\r\n+ Added feature to reorder bus interfaces in component editor.\r\n\r\n- Fixed library crashing with Abstractor objects.\r\n- Fixed other minor bugs and usability issues.\r\n\r\n07/02/2014 2.4.17\r\n----------------------------------------------------\r\n\r\n+ Added PadsPartGenerator and QuartusPinImport plugins.\r\n\r\n30/1/2014 2.4.0\r\n----------------------------------------------------\r\n\r\n+ Improved Editor for port maps.\r\n    - Improved visualization of port maps.\r\n    - Added bit-by-bit port map creation.\r\n+ Added Bus interface generation wizard.\r\n    - New Bus and Abstraction definition generation based on ports in a \r\n      component.\r\n    - Bus interface and port map generation to component using the\r\n      generatarted or existing Bus and Abstraction definitions.\r\n+ Added help page for keyboard and mouse shortcuts.\r\n\r\n- Fixed numerous non-critical bugs and usability issues.\r\n\r\n* Migrated to Qt 5.2.0.\r\n* Separated plugin system from Kactus2 core.\r\n\r\n20/09/2013 2.3.0\r\n----------------------------------------------------\r\n\r\n+ Added copy-paste to all designs allowing copying of component instances,\r\n  interfaces and whole columns excluding connections.\r\n+ Added multi-selection capability for copy-paste and deletion to all designs.\r\n+ Added VLNV drag & drop support to summary tables in the component editor.\r\n+ Added the possibility to rearrange the default positions of component's\r\n  interfaces in the general page of the component editor.\r\n+ Added a tooltip to show memory map size in AUB for each address block and\r\n  segment in the memory map and address space editors.\r\n+ Added a check box to enable/disable local memory map.\r\n+ Added Browse button to New dialog pages in order to have more convenient\r\n  directory selection if the automatically suggested location does not \r\n  suffice.\r\n+ Added 'Select All' to the right-click context menu in design editors.\r\n+ Added library filter selections to be saved as a part of the workspace.\r\n\r\n- Fixed numerous bugs, both critical and non-critical ones.\r\n- Fixed a bug causing the port maps dialog to open when using the off-page\r\n  connection tool.\r\n- Fixed API/COM interface deletion to also delete the underlying interface\r\n  metadata from the SW component.\r\n- Fixed an issue of ad-hoc ports not disappearing when a bus interface\r\n  containing the corresponding ports is deleted.\r\n- Removed the 'Parameterizable' firmness attribute option.\r\n\r\n* Migrated to Qt 5.1.1.\r\n* Improved routing of connections in all designs with automatic overlap\r\n  avoidance.\r\n* Improved memory map visualization with the following changes:\r\n    - Memory block widths are now scaled acccording to the window size.\r\n    - Changes to colors, fonts and alignment to improve readability.\r\n    - Visualization of overlapping addresses and violations.\r\n* Improved address spaces visualization.\r\n* SW designs are now shown in the library and they can be mapped to\r\n  the CPU's SW view by dragging from the library.\r\n* Bus interface port maps editor now shows also the port directions.\r\n* Component editor now highlights the used sections in the tree view.\r\n* Name conflicts are now checked in all tables in the component editor.\r\n  This concerns also copy-paste to the tables.\r\n* Changed the sorting in port and generic editors to case-insensitive.\r\n* Renamed 'Add Signals to Bus' to 'New Abstraction Definition' to prevent\r\n  confusion with the Add signals option in the bus editor.\r\n* Changed the order of HW views in the component editor to list hierarchical\r\n  views before non-hierarchical ones. Hierarchical views now also show an\r\n  icon.\r\n\r\n\r\n\r\n05/07/2013 2.2.0\r\n----------------------------------------------------\r\n\r\n+ NEW: Component creation wizard, including a VHDL import tool.\r\n+ NEW: Dependency analysis tool with enhanced file set editing features.\r\n+ NEW: Generator plugins.\r\n    * Memory map header generator.\r\n    * Altera BSP generator.\r\n+ NEW: Source analyzer plugins for dependency analysis.\r\n    * VHDL source analyzer.\r\n    * C/C++ source analyzer.\r\n+ Added printing of library summary report to the output window after the\r\n  library scan.\r\n+ Added COM interface implementation reference to be able to specify an\r\n  implementing driver for each COM interface in the components.\r\n+ Added editing features for HW view reference and file set references\r\n  to the system view editor in the component editor.\r\n+ Added file set references, build commands, BSP build tools and environment\r\n  variables to software views in the component editor.\r\n+ Added half-automatic port creation for draft interfaces.\r\n+ Added copy-paste for bus interfaces in the HW design editor.\r\n+ Added UUIDs to be used to identify component instances in the designs\r\n  (especially in system designs).\r\n+ Added the ability to launch shell scripts for components.\r\n\r\n- Fixed performance issues with large libraries causing unnecessary slowdowns\r\n  in the library window and the component editor.\r\n- Removed the possibility to create new components/objects from scratch in the\r\n  library window.\r\n- Bus editor now shows width field as empty instead of an invalid -1 when the\r\n  optional width value is not specified in the abstraction definition.\r\n- Unnecessary errors about URL file paths are no longer shown.\r\n- Fixed the missing yellow color in the mandatory file type field in the file \r\n  set editor.\r\n- Fixed the bus interface editor showing master interface settings by default\r\n  even though the interface mode is undefined.\r\n- Fixed the issue of an ad-hoc port not being hidden in a design after the\r\n  ad-hoc visibility has been unchecked in the component editor and saved.\r\n- Fixed a crash when trying to auto-assign addresses in the address editor\r\n  when the selected component instance has no bus interfaces that would\r\n  be shown in the editor.\r\n\r\n* Migrated to Qt 5.1.0.\r\n* Changed the naming of library context menu New items.\r\n* Replaced the old list editor with a better collection editor.\r\n* Disabled the instantiation of template components to designs.\r\n* Updated context-sensitive help content.\r\n* Fixed the issue of the component editor tree view not being updated\r\n  when making changes through the actual editor pages.\r\n* Added more detailed information to be generated at the beginning of the\r\n  generated files.\r\n* Generated VHDL is now formatted to max 80 character lines.\r\n* Enhanced editing of ports in the component editor.\r\n\r\n\r\n\r\n12/02/2013 2.1 (Build 194)\r\n----------------------------------------------------\r\n\r\n+ Menu ribbon remade completely with better scaling behaviour. This also\r\n  fixes the blackout bug present in the previous version.\r\n+ Added the possibility to select which library locations are currently active.\r\n\r\n- Fixed missing prints from the library integrity check.\r\n- Fixed the problem of context help not working due to a missing Qt DLL.\r\n- Removed any dependencies to GCF framework.\r\n\r\n* Migrated to Qt 5.0.1.\r\n\r\n\r\n\r\n06/02/2013 2.1\r\n----------------------------------------------------\r\n\r\n+ Designs can be opened through component editor by double clicking a\r\n  hierarchical view.\r\n+ Linux desktop integration added.\r\n+ Added info column to memory maps editor displaying which bus interfaces the\r\n  memory map in binded to.\r\n+ Support for local memory map within address spaces added.\r\n+ Added visualization of memory maps to component editor.\r\n+ Added visualization of adress space to component editor.\r\n+ Added XML header editor to component editor for user to create custom headers\r\n  to XML IP-XACT files.\r\n\r\n- Fixed compilation flags on Kactus2.pro project file to support 64-bit Linux.\r\n- Fixed bug when drag & dropping abstraction definition to bus interface within\r\n  component editor.\r\n- Fixed bug when exporting SW in system design.\r\n- Fixed bugs in CSV import and export.\r\n- Fixed VLNV editor content assist bugs.\r\n\r\n* Migrated to Qt 5.0.\r\n* Changed colors of API and COM connections within system designs.\r\n\r\n\r\n\r\n10/09/2012 2.0\r\n----------------------------------------------------\r\n\r\n+ Added address editor for setting memory addresses in HW designs.\r\n+ Added context-sensitive help system (help pages are still work-in-progress).\r\n+ Added support for memory maps and registers to the component editor.\r\n+ Added Show Errors feature to the library in order to enumerate errors of a \r\n  specific library item in a dialog.\r\n+ Added naming policies to the settings dialog.\r\n\r\n- Fixed the crash after library refresh.\r\n\r\n* The hierarchical library view now shows also the designs.\r\n* Changed icons in the library view.\r\n* Kactus2 settings are now saved to an INI file in the user's AppData folder.\r\n* VLNV tree does not sort library items according to the item type anymore.\r\n\r\n\r\n\r\n13/07/2012 2.0 RC\r\n----------------------------------------------------\r\n\r\n+ NEW: Fully revised system design architecture.\r\n+ NEW: Experimental C++ plugin API for creating component generators.\r\n+ Added design editing feature that allows component replacement using\r\n  drag'n'drop both from the library and within a design.\r\n+ Added rubberband connections to new system designs.\r\n+ Added auto-suggestion of possible generic names.\r\n+ Added refresh button to the ribbon.\r\n+ Added two new document types (extensions): COM definition and API definition.\r\n+ Added CSV import for generics.\r\n+ Added contact information to Kactus2-generated XML files.\r\n\r\n- Removed internal IP-XACT objects that are no longer needed with the new\r\n  system designs.\r\n\r\n* Connection bullets now indicate also the direction of the connection.\r\n* Broken/invalid connections and missing interfaces are now visualized in\r\n  red in designs.\r\n* Component instances referencing IP-XACT components that are not found in the\r\n  library are now kept in the design and visualized in red.\r\n* Drafted designs can now be saved without packetizing the draft components.\r\n* Added more information to tool tip texts shown in the library and design\r\n  editors.\r\n\r\nKNOWN UNRESOLVED ISSUES:\r\n* Kactus2 may crash when the library is refreshed after Plain IP-XACT library\r\n  view has been used.\r\n\r\n\r\n\r\n28/03/2012 1.3 (Build 27)\r\n----------------------------------------------------\r\n\r\n+ Added shortcuts: Ctrl+Tab for switching tabs, Ctrl+W for closing tabs,\r\n  F5 for refreshing the documents and Ctrl+Space for switching protection mode.\r\n\r\n- Fixed a critical crash in system designs and components having CPU elements.\r\n\r\n\r\n\r\n22/03/2012 1.3 (Build 1)\r\n----------------------------------------------------\r\n\r\n+ NEW CORE FEATURE: Added support for ad-hoc connections and setting ad-hoc\r\n  visibility for each port separately.\r\n+ Added better validity checking for IP-Xact objects.\r\n+ Added usage instructions to lists that are editable by double clicking.\r\n+ Added address space editor and CPU editing features to the component editor.\r\n\r\n- Fixed an incorrect connection of Qt signals in HW designs.\r\n- Fixed a scroll bar issue in New dialog when using larger fonts in Windows.\r\n- Fixed the scaling issue of the component editor's left pane.\r\n- Fixed a crash when saving a design with a packetized draft component.\r\n- Fixed a regression bug of workspaces working incorrectly with Qt 4.8.0.\r\n- Removed the unnecessary dependencies to Qt ActiveX modules.\r\n\r\n* Migrated to Qt 4.8.0.\r\n* The library locations are now scanned automatically on program start or\r\n  when the library locations are changed.\r\n* Enhanced the error messages coming from the Quartus generator.\r\n* Enhanced the error messages when saving an incomplete component.\r\n* Error messages from the library check are now indented.\r\n* Library check now prints more detailed error summary.\r\n* Also the MCAPI channel connection function calls are now automatically\r\n  generated to sender side application code.\r\n* A flat view is now automatically added to drafted components when they\r\n  are packetized.\r\n* Changed the component instance numbering to start from zero instead of one.\r\n* Abstraction definition is not compulsory anymore in the component editor,\r\n  but is auto-filled when using bus and abstraction definitions created with\r\n  Kactus2.\r\n\r\n\r\n\r\n03/02/2012 1.2 (Build 396)\r\n----------------------------------------------------\r\n\r\n+ Added more detailed error reporting to the library's check integrity tool.\r\n+ Added workspaces for managing different window layouts easily.\r\n+ Added bus width display for connections (can be shown/hidden using\r\n  visibility control).\r\n+ Added automatic association of bus definitions and abstraction definitions\r\n  when drag'n'dropping bus definitions from the library to a HW design.\r\n+ Added dot graphics for visualizing connected bus intersections.\r\n+ Added undercrossing graphics for visualizing bus intersections which are\r\n  separate (i.e., not connected with each other).\r\n\r\n- Fixed a crash when trying to remove files that were already moved on the\r\n  disk.\r\n\r\n* Kactus2 now saves the paths to library locations, not the direct paths\r\n  to the XML files.\r\n* Changed the plain IP-XACT view so that it is not reset when items\r\n  are added or removed. Also the VLNV dialer now keeps it's contents\r\n  regardless of the tree updates.\r\n* New component properties are automatically named to 'unnamed' instead of\r\n  having no name set.\r\n\r\n\r\n\r\n19/01/2012 1.2 (Build 1)\r\n----------------------------------------------------\r\n\r\n+ Added possibility to select the name of the generated ModelSim file with\r\n  an extension.\r\n+ Added more thorough error printing for invalid/incomplete IP-XACT documents.\r\n+ Added off-page connectors with rubber-band routing mode for often used\r\n  interfaces/ports to achieve more readable designs by auto-hiding the rubber-\r\n  band connections when they are not edited.\r\n+ Added the ability to execute ModelSim generator through the component editor.\r\n+ Added the possibility to select which C source file to open through the\r\n  system design editor when right-clicking an application component.\r\n+ Added the SW component type visualization in the component editor.\r\n+ Kactus2 now remembers the filter settings that were set on a previous run\r\n  of the program.\r\n\r\n- Fixed the modelsim generator to use the correct syntax for vmake call.\r\n- Fixed the inability to scroll the port map list when a bus interface is\r\n  selected.\r\n- Fixed the problem of opening the component editor by a double-click when a\r\n  view is not selected.\r\n- Fixed the out-of-sync problem of editing the same component simultaneously\r\n  in the component editor and design editor.\r\n- Fixed the crash when editing endpoints in the SW design editor.\r\n- Fixed the regular expression problem in the MCAPI code assist.\r\n- Fixed various small bugs in the system design editor.\r\n\r\n* Made the protection feature more user-friendly by not always asking\r\n  the confirmation whether the user wants to unlock the document.\r\n* Simplified some list input boxes by removing explicit add/remove buttons.\r\n* Reorganized the file information view in the component editor.\r\n* Decreased the VLNV fields area on the docking windows.\r\n* Moved the XML file writing order so that the general description is written\r\n  at the beginning part of the file.\r\n* Double-clicking an SW platform component in the platform stack editor now\r\n  opens up the hierarchy if it exists and the component editor only if it\r\n  does not exists (meaning a flat component).\r\n* Removed the always repeating question of whether the user wants to add\r\n  the generated VHDL-file to IP-XACT meta-data if it already exists there.\r\n* Docking windows are now kept visible based on the user's selection of\r\n  what windows to show/hide.\r\n\r\n\r\n\r\n25/11/2011 1.1 (Build 1)\r\n----------------------------------------------------\r\n\r\n+ Added undo/redo support for system designs.\r\n+ Added SW design editor for editing SW that will be mapped directly to HW\r\n  components.\r\n+ Added a connection editor for HW designs.\r\n+ Added VHDL template generation for drafted HW components.\r\n+ Added comment generation to the vHDL generator.\r\n+ Added user modifiable code areas to generated VHDL.\r\n+ Added an option to create a new HW design based on an old one.\r\n+ Added component port default value support to the vHDL generator.\r\n+ Added component port type column to the component editor.\r\n+ Default programs set in the operating system are now used to open\r\n  the files in the component editor.\r\n+ Added entity name setting support for the VHDL generator.\r\n+ Added automatic creation of views for HW components (RTL view for IP and SoC\r\n  level components, \"hierarchical\" view for Chip, Board and Product level\r\n  designs and a fla t view for same lvel components).\r\n+ Added IP-XACT object path to be visible in the component editor's general\r\n  view.\r\n+ Added more information about ports and model parameters to the generated\r\n  documentation.\r\n+ Added the possibility to select which windows are shown and which are hidden.\r\n+ Added a component interface editor for HW designs. \r\n\r\n- Added missing internal bus definitions for MCAPI and SW to the program's\r\n  own internal library.\r\n- Fixed the VLNV editor crash after a library refresh.\r\n- IP-XACT namespace fields are now correctly writted to the generated XML files.\r\n- All created VLNVs are now checked for existence when creating a new object\r\n  through the New dialog to prevent overwrite errors.\r\n- Fixed content assist visibility problem on Linux.\r\n- Fixed the filtering of API/bus definitions according to SW/HW.\r\n- Fixed the crash when scrolling a locked empty design.\r\n- Fixed the error of changes being applied without saving when editing\r\n  hierarchical interfaces of a design.\r\n- Inout ports are now directly mapped to component instance ports as opposed\r\n  to using signals which did not work as expected.\r\n\r\n* General page is now shown by default in the component editor.\r\n* Designs can now be browsed and component details previewed even if\r\n  the document is locked.\r\n* Appropriate editor windows on the right side are now automatically\r\n  shown/hidden when an element is selected or deselected on a design.\r\n* Configuration editor is now hidden for other editors than the HW design\r\n  editor.\r\n* Unnecessary ribbon groups are now hidden automatically based on the open\r\n  editor.\r\n* Changed the report generator to categorize ports under bus interfaces\r\n  instead of one long list.\r\n\r\n\r\n\r\n04/10/2011 1.0 (Build 1)\r\n----------------------------------------------------\r\n\r\n* Public release\r\n* System designs and MCAPI editing are not fully featured in this release.\r\n  Upcoming system design features include undo/redo support, enhanced code\r\n  generation & validation and Makefile generation.\r\n"
  },
  {
    "path": "Administrative/releaseFiles/setupx64.nsi",
    "content": "; Script generated by the HM NIS Edit Script Wizard.\r\n\r\n; HM NIS Edit Wizard helper defines\r\n!define PRODUCT_NAME \"Kactus2\"\r\n!define PRODUCT_VERSION \"3.14.0 64-bit\"\r\n!define PRODUCT_PUBLISHER \"TUNI\"\r\n!define PRODUCT_DIR_REGKEY \"Software\\Microsoft\\Windows\\CurrentVersion\\App Paths\\Kactus2.exe\"\r\n!define PRODUCT_UNINST_KEY \"Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\${PRODUCT_NAME}\"\r\n!define PRODUCT_UNINST_ROOT_KEY \"HKLM\"\r\n\r\nSetCompressor bzip2\r\n\r\n!define MULTIUSER_EXECUTIONLEVEL Highest\r\n!define MULTIUSER_MUI\r\n!define MULTIUSER_INSTALLMODE_COMMANDLINE\r\n!include \"MultiUser.nsh\"\r\n!include \"MUI2.nsh\"\r\n!include \"x64.nsh\"\r\n\r\n; MUI Settings\r\n!define MUI_ABORTWARNING\r\n!define MUI_ICON \"${NSISDIR}\\Contrib\\Graphics\\Icons\\modern-install.ico\"\r\n!define MUI_UNICON \"${NSISDIR}\\Contrib\\Graphics\\Icons\\modern-uninstall.ico\"\r\n\r\n; Welcome page\r\n!insertmacro MUI_PAGE_WELCOME\r\n; License page\r\n!insertmacro MUI_PAGE_LICENSE \"gpl2.txt\"\r\n; Multiuser page\r\n!insertmacro MULTIUSER_PAGE_INSTALLMODE\r\n; Directory page\r\n!insertmacro MUI_PAGE_DIRECTORY\r\n; Instfiles page\r\n!insertmacro MUI_PAGE_INSTFILES\r\n; Finish page\r\n!define MUI_FINISHPAGE_RUN \"$INSTDIR\\Kactus2.exe\"\r\n!insertmacro MUI_PAGE_FINISH\r\n\r\n; Uninstaller pages\r\n!insertmacro MUI_UNPAGE_INSTFILES\r\n\r\n; Language files\r\n!insertmacro MUI_LANGUAGE \"English\"\r\n\r\n; Reserve files\r\n;!insertmacro MUI_RESERVEFILE_INSTALLOPTIONS\r\n\r\n; MUI end ------\r\n\r\nName \"${PRODUCT_NAME}\"\r\nOutFile \"Kactus2SetupWin64bit.exe\"\r\nInstallDir \"$PROGRAMFILES64\\Kactus2\"\r\nInstallDirRegKey HKLM \"${PRODUCT_DIR_REGKEY}\" \"\"\r\nShowInstDetails show\r\nShowUnInstDetails show\r\n\r\nSection \"MainSection\" SEC01\r\n  SetOutPath \"$INSTDIR\"\r\n  SetOverwrite on\r\n  File \"..\\..\\executable\\Qt6Core.dll\"\r\n  File \"..\\..\\executable\\Qt6Gui.dll\"\r\n  File \"..\\..\\executable\\Qt6Help.dll\"\r\n  File \"..\\..\\executable\\Qt6PrintSupport.dll\"\r\n  File \"..\\..\\executable\\Qt6Sql.dll\"\r\n  File \"..\\..\\executable\\Qt6Widgets.dll\"\r\n  File \"..\\..\\executable\\Qt6Xml.dll\"\r\n  File \"..\\..\\executable\\Qt6Svg.dll\"\r\n  File \"..\\..\\executable\\opengl32sw.dll\"\r\n  File \"..\\..\\executable\\D3Dcompiler_47.dll\"\r\n  File \"..\\..\\executable\\IPXACTmodels.dll\"\r\n  File \"..\\..\\PythonAPI\\pythonAPI.py\"\r\n  File \"..\\..\\PythonAPI\\_pythonAPI.pyd\"\r\n  File \"..\\..\\executable\\KactusAPI.dll\"\r\n  File \"..\\..\\executable\\Kactus2.exe\"\r\n  File \"gpl2.txt\"\r\n  File \"release_notes.txt\"\r\n  File \"..\\..\\README.md\"\r\n  File \"..\\..\\executable\\upgrade.cfg\"\r\n  File /oname=DefaultSettings.ini \"DefaultSettingsWin.ini\"\r\n  File \"..\\..\\PythonAPI\\python-3.10.6-embed-amd64\\python310.dll\"\r\n  File \"..\\..\\PythonAPI\\python-3.10.6-embed-amd64\\_asyncio.pyd\"\r\n  File \"..\\..\\PythonAPI\\python-3.10.6-embed-amd64\\_bz2.pyd\"\r\n  File \"..\\..\\PythonAPI\\python-3.10.6-embed-amd64\\_ctypes.pyd\"\r\n  File \"..\\..\\PythonAPI\\python-3.10.6-embed-amd64\\_decimal.pyd\"\r\n  File \"..\\..\\PythonAPI\\python-3.10.6-embed-amd64\\_elementtree.pyd\"\r\n  File \"..\\..\\PythonAPI\\python-3.10.6-embed-amd64\\_hashlib.pyd\"\r\n  File \"..\\..\\PythonAPI\\python-3.10.6-embed-amd64\\_lzma.pyd\"\r\n  File \"..\\..\\PythonAPI\\python-3.10.6-embed-amd64\\_msi.pyd\"\r\n  File \"..\\..\\PythonAPI\\python-3.10.6-embed-amd64\\_multiprocessing.pyd\"\r\n  File \"..\\..\\PythonAPI\\python-3.10.6-embed-amd64\\_overlapped.pyd\"\r\n  File \"..\\..\\PythonAPI\\python-3.10.6-embed-amd64\\_queue.pyd\"\r\n  File \"..\\..\\PythonAPI\\python-3.10.6-embed-amd64\\_socket.pyd\"\r\n  File \"..\\..\\PythonAPI\\python-3.10.6-embed-amd64\\_sqlite3.pyd\"\r\n  File \"..\\..\\PythonAPI\\python-3.10.6-embed-amd64\\_ssl.pyd\"\r\n  File \"..\\..\\PythonAPI\\python-3.10.6-embed-amd64\\_uuid.pyd\"\r\n  File \"..\\..\\PythonAPI\\python-3.10.6-embed-amd64\\_zoneinfo.pyd\"\r\n  File \"..\\..\\PythonAPI\\python-3.10.6-embed-amd64\\libcrypto-1_1.dll\"\r\n  File \"..\\..\\PythonAPI\\python-3.10.6-embed-amd64\\libffi-7.dll\"\r\n  File \"..\\..\\PythonAPI\\python-3.10.6-embed-amd64\\libssl-1_1.dll\"\r\n  File \"..\\..\\PythonAPI\\python-3.10.6-embed-amd64\\LICENSE.txt\"\r\n  File \"..\\..\\PythonAPI\\python-3.10.6-embed-amd64\\pyexpat.pyd\"\r\n  File \"..\\..\\PythonAPI\\python-3.10.6-embed-amd64\\python.cat\"\r\n  File \"..\\..\\PythonAPI\\python-3.10.6-embed-amd64\\python.exe\"\r\n  File \"..\\..\\PythonAPI\\python-3.10.6-embed-amd64\\python3.dll\"\r\n  File \"..\\..\\PythonAPI\\python-3.10.6-embed-amd64\\python310._pth\"\r\n  File \"..\\..\\PythonAPI\\python-3.10.6-embed-amd64\\python310.zip\"\r\n  File \"..\\..\\PythonAPI\\python-3.10.6-embed-amd64\\pythonw.exe\"\r\n  File \"..\\..\\PythonAPI\\python-3.10.6-embed-amd64\\select.pyd\"\r\n  File \"..\\..\\PythonAPI\\python-3.10.6-embed-amd64\\sqlite3.dll\"\r\n  File \"..\\..\\PythonAPI\\python-3.10.6-embed-amd64\\unicodedata.pyd\"\r\n  File \"..\\..\\PythonAPI\\python-3.10.6-embed-amd64\\vcruntime140.dll\"\r\n  File \"..\\..\\PythonAPI\\python-3.10.6-embed-amd64\\vcruntime140_1.dll\"\r\n  File \"..\\..\\PythonAPI\\python-3.10.6-embed-amd64\\winsound.pyd\"\r\n\r\n#  SetOutPath \"$INSTDIR\\Python\"\r\n#  SetOverwrite on\r\n\r\n  SetOutPath \"$INSTDIR\\platforms\"\r\n  SetOverwrite on\r\n  File \"..\\..\\executable\\platforms\\qwindows.dll\"\r\n  \r\n  SetOutPath \"$INSTDIR\\sqldrivers\"\r\n  SetOverwrite on\r\n  File \"..\\..\\executable\\sqldrivers\\qsqlite.dll\"\r\n\r\n  SetOutPath \"$INSTDIR\\styles\"\r\n  SetOverwrite on\r\n  File \"..\\..\\executable\\styles\\qwindowsvistastyle.dll\"\r\n\r\n  SetOutPath \"$INSTDIR\\imageformats\"\r\n  SetOverwrite on\r\n  File \"..\\..\\executable\\imageformats\\qjpeg.dll\"\r\n\r\n  SetOutPath \"$INSTDIR\\Plugins\"\r\n  SetOverwrite on\r\n  File \"..\\..\\executable\\Plugins\\MCAPICodeGenerator.dll\"\r\n  File \"..\\..\\executable\\Plugins\\CppSourceAnalyzer.dll\"\r\n  File \"..\\..\\executable\\Plugins\\VHDLSourceAnalyzer.dll\"\r\n  File \"..\\..\\executable\\Plugins\\AlteraBSPGenerator.dll\"\r\n  File \"..\\..\\executable\\Plugins\\MemoryMapHeaderGenerator.dll\"\r\n  File \"..\\..\\executable\\Plugins\\PadsPartGenerator.dll\"\r\n  File \"..\\..\\executable\\Plugins\\QuartusPinImportPlugin.dll\"\r\n  File \"..\\..\\executable\\Plugins\\QuartusProjectGenerator.dll\"\r\n  File \"..\\..\\executable\\Plugins\\MakefileGenerator.dll\"\r\n  File \"..\\..\\executable\\Plugins\\ModelSimGenerator.dll\"\r\n  File \"..\\..\\executable\\Plugins\\VerilogGeneratorPlugin.dll\"\r\n  File \"..\\..\\executable\\Plugins\\VerilogImport.dll\"\r\n  File \"..\\..\\executable\\Plugins\\VHDLGenerator.dll\"\r\n  File \"..\\..\\executable\\Plugins\\VerilogIncludeImport.dll\"\r\n  File \"..\\..\\executable\\Plugins\\VerilogSourceAnalyzer.dll\"\r\n  File \"..\\..\\executable\\Plugins\\VHDLImport.dll\"\r\n  #File \"..\\..\\executable\\Plugins\\MemoryViewGenerator.dll\"\r\n  File \"..\\..\\executable\\Plugins\\LinuxDeviceTreeGenerator.dll\"\r\n  File \"..\\..\\executable\\Plugins\\SVDGeneratorPlugin.dll\"\r\n  File \"..\\..\\executable\\Plugins\\RenodeGeneratorPlugin.dll\"\r\n\r\n  SetOutPath \"$INSTDIR\\Help\"\r\n  SetOverwrite on\r\n  File \"..\\..\\Help\\Kactus2Help.qhc\"\r\n  File \"..\\..\\Help\\Kactus2Help.qch\"\r\n\r\n  SetOutPath \"$INSTDIR\\ExampleScripts\"\r\n  SetOverwrite on\r\n  File \"..\\..\\PythonAPI\\ExampleScripts\\createComponent.py\"\r\n  File \"..\\..\\PythonAPI\\ExampleScripts\\createComponentItems.py\"\r\n  File \"..\\..\\PythonAPI\\ExampleScripts\\createComponentItems.py\"\r\n  File \"..\\..\\PythonAPI\\ExampleScripts\\listRegisters.py\"\r\n  File \"..\\..\\PythonAPI\\ExampleScripts\\parameterUsage.py\"\r\n  File \"..\\..\\PythonAPI\\ExampleScripts\\verilogGenerator.py\"\r\n  \r\n  SetOutPath \"$APPDATA\\TUT\"\r\n  SetOverwrite off\r\n  File /oname=Kactus2.ini \"DefaultSettingsWin.ini\"\r\n  \r\n  SetOutPath \"$INSTDIR\\Library\\tut.fi\\global.communication\\mcapi\\1.063\"\r\n  SetOverwrite on\r\n  File \"Library\\tut.fi\\global.communication\\mcapi\\1.063\\mcapi.1.063.xml\"\r\n\r\n  SetOutPath \"$INSTDIR\\Library\\tut.fi\\ip.swp.api\\mcapi.apiDef\\1.063\"\r\n  SetOverwrite on\r\n  File \"Library\\tut.fi\\ip.swp.api\\mcapi.apiDef\\1.063\\mcapi.apiDef.1.063.xml\"\r\n\r\n  SetOutPath \"$INSTDIR\\Library\\tut.fi\\global.communication\\mcapi\\2.015\"\r\n  SetOverwrite on\r\n  File \"Library\\tut.fi\\global.communication\\mcapi\\2.015\\mcapi.2.015.xml\"\r\n\r\n  SetOutPath \"$INSTDIR\\Library\\tut.fi\\ip.swp.api\\mcapi.apiDef\\2.015\"\r\n  SetOverwrite on\r\n  File \"Library\\tut.fi\\ip.swp.api\\mcapi.apiDef\\2.015\\mcapi.apiDef.2.015.xml\"\r\n\r\n  SetOutPath \"$INSTDIR\\Library\\tut.fi\\global.communication\\iptlm\\1.1\"\r\n  SetOverwrite on\r\n  File \"Library\\tut.fi\\global.communication\\iptlm\\1.1\\TLMW.1.1.xml\"\r\n\r\n  SetOutPath \"$INSTDIR\\Library\\tut.fi\\ip.swp.api\\IPTLM.apidef\\1.1\"\r\n  SetOverwrite on\r\n  File \"Library\\tut.fi\\ip.swp.api\\IPTLM.apidef\\1.1\\TLMW.apiDef.1.1.xml\"\r\n  \r\n  SetOutPath \"$INSTDIR\"\r\n  CreateDirectory \"$SMPROGRAMS\\Kactus2\"\r\n  CreateShortCut \"$SMPROGRAMS\\Kactus2\\Kactus2.lnk\" \"$INSTDIR\\Kactus2.exe\"\r\n  CreateShortCut \"$SMPROGRAMS\\Kactus2\\License.lnk\" \"$INSTDIR\\gpl2.txt\"\r\n  CreateShortCut \"$SMPROGRAMS\\Kactus2\\Release Notes.lnk\" \"$INSTDIR\\release_notes.txt\"\r\n  CreateShortCut \"$SMPROGRAMS\\Kactus2\\Readme.lnk\" \"$INSTDIR\\readme.txt\"\r\n  CreateShortCut \"$DESKTOP\\Kactus2.lnk\" \"$INSTDIR\\Kactus2.exe\"\r\nSectionEnd\r\n\r\nSection \"DependencySection\" SEC02\r\n  SetOutPath \"$TEMP\\Kactus2Installer\"\r\n  SetOverwrite ifnewer\r\n  File \"..\\..\\executable\\vc_redist.x64.exe\"\r\n  ExecWait '\"$OUTDIR\\vc_redist.x64.exe\" /q /norestart'\r\n  SetOutPath \"$INSTDIR\"\r\n  RMDir /r \"$TEMP\\Kactus2Installer\"\r\nSectionEnd\r\n\r\nSection -AdditionalIcons\r\n  CreateShortCut \"$SMPROGRAMS\\Kactus2\\Uninstall.lnk\" \"$INSTDIR\\uninst.exe\"\r\nSectionEnd\r\n\r\nSection -Post\r\n  WriteUninstaller \"$INSTDIR\\uninst.exe\"\r\n  WriteRegStr HKLM \"${PRODUCT_DIR_REGKEY}\" \"\" \"$INSTDIR\\Kactus2.exe\"\r\n  WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} \"${PRODUCT_UNINST_KEY}\" \"DisplayName\" \"$(^Name)\"\r\n  WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} \"${PRODUCT_UNINST_KEY}\" \"UninstallString\" \"$INSTDIR\\uninst.exe\"\r\n  WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} \"${PRODUCT_UNINST_KEY}\" \"DisplayIcon\" \"$INSTDIR\\Kactus2.exe\"\r\n  WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} \"${PRODUCT_UNINST_KEY}\" \"DisplayVersion\" \"${PRODUCT_VERSION}\"\r\n  WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} \"${PRODUCT_UNINST_KEY}\" \"Publisher\" \"${PRODUCT_PUBLISHER}\"\r\nSectionEnd\r\n\r\n\r\nFunction .onInit\r\n  !insertmacro MULTIUSER_INIT\r\n  ${IfNot} ${RunningX64}\r\n     MessageBox MB_OK \"This program requires a 64-bit version of Windows. Setup will now exit.\"\r\n     Abort\r\n  ${EndIf}\r\n  ${DisableX64FSRedirection}\r\n  SetRegView 64\r\nFunctionEnd\r\n\r\nFunction un.onUninstSuccess\r\n  HideWindow\r\n  MessageBox MB_ICONINFORMATION|MB_OK \"$(^Name) was successfully removed from your computer.\"\r\nFunctionEnd\r\n\r\nFunction un.onInit\r\n  !insertmacro MULTIUSER_UNINIT\r\n  MessageBox MB_ICONQUESTION|MB_YESNO|MB_DEFBUTTON2 \"Are you sure you want to completely remove $(^Name) and all of its components?\" IDYES +2\r\n  Abort\r\nFunctionEnd\r\n\r\nSection Uninstall\r\n  Delete \"$INSTDIR\\uninst.exe\"\r\n  Delete \"$INSTDIR\\Library\\tut.fi\\ip.swp.api\\IPTLM.apiDef\\1.1\\TLMW.apiDef.1.1.xml\"\r\n  Delete \"$INSTDIR\\Library\\tut.fi\\global.communication\\iptlm\\1.1\\TLMW.1.1.xml\"\r\n  Delete \"$INSTDIR\\Library\\tut.fi\\global.communication\\mcapi\\2.015\\mcapi.2.015.xml\"\r\n  Delete \"$INSTDIR\\Library\\tut.fi\\ip.swp.api\\mcapi.apiDef\\2.015\\mcapi.apiDef.2.015.xml\"\r\n  Delete \"$INSTDIR\\Library\\tut.fi\\global.communication\\mcapi\\1.063\\mcapi.1.063.xml\"\r\n  Delete \"$INSTDIR\\Library\\tut.fi\\ip.swp.api\\mcapi.apiDef\\1.063\\mcapi.apiDef.1.063.xml\"\r\n  Delete \"$INSTDIR\\Help\\Kactus2Help.qch\"\r\n  Delete \"$INSTDIR\\Help\\Kactus2Help.qhc\"\r\n  Delete \"$INSTDIR\\Plugins\\SVDGeneratorPlugin.dll\"\r\n  Delete \"$INSTDIR\\Plugins\\VHDLImport.dll\"\r\n  Delete \"$INSTDIR\\Plugins\\RenodeGeneratorPlugin.dll\"\r\n  Delete \"$INSTDIR\\Plugins\\LinuxDeviceTreeGenerator.dll\"\r\n  Delete \"$INSTDIR\\Plugins\\MemoryViewGenerator.dll\"\r\n  Delete \"$INSTDIR\\Plugins\\VerilogImport.dll\"\r\n  Delete \"$INSTDIR\\Plugins\\VHDLGenerator.dll\"\r\n  Delete \"$INSTDIR\\Plugins\\VerilogSourceAnalyzer.dll\"\r\n  Delete \"$INSTDIR\\Plugins\\VerilogIncludeImport.dll\"\r\n  Delete \"$INSTDIR\\Plugins\\VerilogGeneratorPlugin.dll\"\r\n  Delete \"$INSTDIR\\Plugins\\MakefileGenerator.dll\"\r\n  Delete \"$INSTDIR\\Plugins\\QuartusProjectGenerator.dll\"\r\n  Delete \"$INSTDIR\\Plugins\\QuartusPinImportPlugin.dll\"\r\n  Delete \"$INSTDIR\\Plugins\\PadsPartGenerator.dll\"\r\n  Delete \"$INSTDIR\\Plugins\\ModelSimGenerator.dll\"\r\n  Delete \"$INSTDIR\\Plugins\\MemoryMapHeaderGenerator.dll\"\r\n  Delete \"$INSTDIR\\Plugins\\AlteraBSPGenerator.dll\"\r\n  Delete \"$INSTDIR\\Plugins\\VHDLSourceAnalyzer.dll\"\r\n  Delete \"$INSTDIR\\Plugins\\CppSourceAnalyzer.dll\"\r\n  Delete \"$INSTDIR\\Plugins\\MCAPICodeGenerator.dll\"\r\n  Delete \"$INSTDIR\\styles\\qwindowsvistastyle.dll\"\r\n  Delete \"$INSTDIR\\sqldrivers\\qsqlite.dll\"\r\n  Delete \"$INSTDIR\\platforms\\qwindows.dll\"\r\n  Delete \"$INSTDIR\\imageformats\\qjpeg.dll\"\r\n  Delete \"$INSTDIR\\DefaultSettings.ini\"\r\n  Delete \"$INSTDIR\\upgrade.cfg\"\r\n  Delete \"$INSTDIR\\README.md\"\r\n  Delete \"$INSTDIR\\release_notes.txt\"\r\n  Delete \"$INSTDIR\\gpl2.txt\"\r\n  Delete \"$INSTDIR\\Kactus2.exe\"\r\n  Delete \"$INSTDIR\\KactusAPI.dll\"\r\n  Delete \"$INSTDIR\\_pythonAPI.pyd\"\r\n  Delete \"$INSTDIR\\pythonAPI.py\"\r\n  Delete \"$INSTDIR\\IPXACTmodels.dll\"\r\n  Delete \"$INSTDIR\\D3Dcompiler_47.dll\"\r\n  Delete \"$INSTDIR\\opengl32sw.dll\"\r\n  Delete \"$INSTDIR\\Qt6Svg.dll\"\r\n  Delete \"$INSTDIR\\Qt6Xml.dll\"\r\n  Delete \"$INSTDIR\\Qt6Widgets.dll\"\r\n  Delete \"$INSTDIR\\Qt6Sql.dll\"\r\n  Delete \"$INSTDIR\\Qt6PrintSupport.dll\"\r\n  Delete \"$INSTDIR\\Qt6Help.dll\"\r\n  Delete \"$INSTDIR\\Qt6Gui.dll\"\r\n  Delete \"$INSTDIR\\Qt6Core.dll\"\r\n  Delete \"$INSTDIR\\python310.dll\"\r\n  Delete \"$INSTDIR\\_asyncio.pyd\"\r\n  Delete \"$INSTDIR\\_bz2.pyd\"\r\n  Delete \"$INSTDIR\\_ctypes.pyd\"\r\n  Delete \"$INSTDIR\\_decimal.pyd\"\r\n  Delete \"$INSTDIR\\_elementtree.pyd\"\r\n  Delete \"$INSTDIR\\_hashlib.pyd\"\r\n  Delete \"$INSTDIR\\_lzma.pyd\"\r\n  Delete \"$INSTDIR\\_msi.pyd\"\r\n  Delete \"$INSTDIR\\_multiprocessing.pyd\"\r\n  Delete \"$INSTDIR\\_overlapped.pyd\"\r\n  Delete \"$INSTDIR\\_queue.pyd\"\r\n  Delete \"$INSTDIR\\_socket.pyd\"\r\n  Delete \"$INSTDIR\\_sqlite3.pyd\"\r\n  Delete \"$INSTDIR\\_ssl.pyd\"\r\n  Delete \"$INSTDIR\\_uuid.pyd\"\r\n  Delete \"$INSTDIR\\_zoneinfo.pyd\"\r\n  Delete \"$INSTDIR\\libcrypto-1_1.dll\"\r\n  Delete \"$INSTDIR\\libffi-7.dll\"\r\n  Delete \"$INSTDIR\\libssl-1_1.dll\"\r\n  Delete \"$INSTDIR\\LICENSE.txt\"\r\n  Delete \"$INSTDIR\\pyexpat.pyd\"\r\n  Delete \"$INSTDIR\\python.cat\"\r\n  Delete \"$INSTDIR\\python.exe\"\r\n  Delete \"$INSTDIR\\python3.dll\"\r\n  Delete \"$INSTDIR\\python310._pth\"\r\n  Delete \"$INSTDIR\\python310.zip\"\r\n  Delete \"$INSTDIR\\pythonw.exe\"\r\n  Delete \"$INSTDIR\\select.pyd\"\r\n  Delete \"$INSTDIR\\sqlite3.dll\"\r\n  Delete \"$INSTDIR\\unicodedata.pyd\"\r\n  Delete \"$INSTDIR\\vcruntime140.dll\"\r\n  Delete \"$INSTDIR\\vcruntime140_1.dll\"\r\n  Delete \"$INSTDIR\\winsound.pyd\"\r\n\r\n  Delete \"$SMPROGRAMS\\Kactus2\\Uninstall.lnk\"\r\n  Delete \"$DESKTOP\\Kactus2.lnk\"\r\n  Delete \"$SMPROGRAMS\\Kactus2\\Readme.lnk\"\r\n  Delete \"$SMPROGRAMS\\Kactus2\\Release Notes.lnk\"\r\n  Delete \"$SMPROGRAMS\\Kactus2\\License.lnk\"\r\n  Delete \"$SMPROGRAMS\\Kactus2\\Kactus2.lnk\"\r\n\r\n  Delete \"$INSTDIR\\ExampleScripts\\createComponent.py\"\r\n  Delete \"$INSTDIR\\ExampleScripts\\createComponentItems.py\"\r\n  Delete \"$INSTDIR\\ExampleScripts\\createComponentItems.py\"\r\n  Delete \"$INSTDIR\\ExampleScripts\\listRegisters.py\"\r\n  Delete \"$INSTDIR\\ExampleScripts\\parameterUsage.py\"\r\n  Delete \"$INSTDIR\\ExampleScripts\\verilogGenerator.py\"\r\n  \r\n  RMDir \"$SMPROGRAMS\\Kactus2\"\r\n  RMDir \"$INSTDIR\\Help\"\r\n  RMDir \"$INSTDIR\\Plugins\"\r\n  RMDir \"$INSTDIR\\styles\"\r\n  RMDir \"$INSTDIR\\sqldrivers\"\r\n  RMDir \"$INSTDIR\\platforms\"\r\n  RMDir \"$INSTDIR\\imageformats\"\r\n  RMDir \"$INSTDIR\\ExampleScripts\"\r\n  RMDir \"$INSTDIR\\__pycache__\"\r\n  RMDir \"$INSTDIR\\Library\\tut.fi\\ip.swp.api\\IPTLM.apiDef\\1.1\"\r\n  RMDir \"$INSTDIR\\Library\\tut.fi\\ip.swp.api\\IPTLM.apiDef\"\r\n  RMDir \"$INSTDIR\\Library\\tut.fi\\ip.swp.api\\mcapi.apiDef\\2.015\"\r\n  RMDir \"$INSTDIR\\Library\\tut.fi\\ip.swp.api\\mcapi.apiDef\\1.063\"\r\n  RMDir \"$INSTDIR\\Library\\tut.fi\\ip.swp.api\\mcapi.apiDef\"\r\n  RMDir \"$INSTDIR\\Library\\tut.fi\\ip.swp.api\"\r\n  RMDir \"$INSTDIR\\Library\\tut.fi\\global.communication\\iptlm\\1.1\"\r\n  RMDir \"$INSTDIR\\Library\\tut.fi\\global.communication\\iptlm\"\r\n  RMDir \"$INSTDIR\\Library\\tut.fi\\global.communication\\mcapi\\2.015\"\r\n  RMDir \"$INSTDIR\\Library\\tut.fi\\global.communication\\mcapi\\1.063\"\r\n  RMDir \"$INSTDIR\\Library\\tut.fi\\global.communication\\mcapi\"\r\n  RMDir \"$INSTDIR\\Library\\tut.fi\\global.communication\"\r\n  RMDir \"$INSTDIR\\Library\\tut.fi\"\r\n  RMDir \"$INSTDIR\\Library\"\r\n  RMDir \"$INSTDIR\"\r\n\r\n  DeleteRegKey ${PRODUCT_UNINST_ROOT_KEY} \"${PRODUCT_UNINST_KEY}\"\r\n  DeleteRegKey HKLM \"${PRODUCT_DIR_REGKEY}\"\r\n  SetAutoClose true\r\nSectionEnd"
  },
  {
    "path": "Administrative/releaseFiles/upgrade.cfg",
    "content": "// DO NOT MODIFY!\n// Upgrade configuration for Linux\nVERSION 2.0.1.0\nADD Platform/PluginsPath String /usr/share/kactus2/plugins\nADD Platform/HelpPath String Help\nADD Library/Locations StringList Library, /usr/share/kactus2/library\nADD Library/DefaultLocation String Library\nADD FilterWidget/Hidden Boolean false\nADD Policies/InstanceNames String $ComponentName$_$InstanceNumber$\nADD Policies/HWViewNames StringList hierarchical,structural\nADD Policies/SWViewNames StringList software\nADD Policies/SysViewNames StringList system\nADD Editor/IndentWidth Integer 4\nADD Editor/IndentStyle Integer 1\nADD Editor/Font Font Courier New,10\nADD Editor/Highlight/Keywords HighlightStyle blue\nADD Editor/Highlight/Preprocessor HighlightStyle blue\nADD Editor/Highlight/Strings HighlightStyle #a30000\nADD Editor/Highlight/SinglelineComments HighlightStyle green\nADD Editor/Highlight/MultilineComments HighlightStyle green\nADD Editor/Highlight/APITypes HighlightStyle blue\nADD Editor/Highlight/APIFunc HighlightStyle purple,bold\nADD Workspaces/Default/WindowState ByteArray \\0\\0\\0\\xff\\0\\0\\0\\0\\xfd\\0\\0\\0\\x4\\0\\0\\0\\0\\0\\0\\x1H\\0\\0\\x4\\x33\\xfc\\x2\\0\\0\\0\\x2\\xfb\\0\\0\\0\\xe\\0L\\0i\\0\\x62\\0r\\0\\x61\\0r\\0y\\x1\\0\\0\\0g\\0\\0\\x3Y\\0\\0\\x1\\\\\\0\\xff\\xff\\xff\\xfb\\0\\0\\0 \\0\\x43\\0o\\0m\\0p\\0o\\0n\\0\\x65\\0n\\0t\\0P\\0r\\0\\x65\\0v\\0i\\0\\x65\\0w\\x1\\0\\0\\x3\\xc4\\0\\0\\0\\xd6\\0\\0\\0\\x8e\\0\\xff\\xff\\xff\\0\\0\\0\\x1\\0\\0\\x1&\\0\\0\\x4\\x33\\xfc\\x2\\0\\0\\0\\x6\\xfb\\0\\0\\0\\x1e\\0I\\0n\\0s\\0t\\0\\x61\\0n\\0\\x63\\0\\x65\\0 \\0\\x45\\0\\x64\\0i\\0t\\0o\\0r\\0\\0\\0\\0g\\0\\0\\0\\x14\\0\\0\\0\\x14\\0\\0\\0\\x14\\xfb\\0\\0\\0\\\"\\0\\x41\\0\\x64\\0-\\0h\\0o\\0\\x63\\0 \\0V\\0i\\0s\\0i\\0\\x62\\0i\\0l\\0i\\0t\\0y\\0\\0\\0\\0\\x7f\\0\\0\\0\\x14\\0\\0\\0\\x14\\0\\0\\0\\x14\\xfb\\0\\0\\0(\\0\\x43\\0o\\0n\\0\\x66\\0i\\0g\\0u\\0r\\0\\x61\\0t\\0i\\0o\\0n\\0 \\0\\x65\\0\\x64\\0i\\0t\\0o\\0r\\0\\0\\0\\0\\x97\\0\\0\\x2\\xd0\\0\\0\\0\\xc5\\0\\xff\\xff\\xff\\xfb\\0\\0\\0\\x32\\0H\\0W\\0 \\0M\\0\\x61\\0p\\0p\\0i\\0n\\0g\\0 \\0\\x44\\0\\x65\\0t\\0\\x61\\0i\\0l\\0s\\0 \\0\\x45\\0\\x64\\0i\\0t\\0o\\0r\\0\\0\\0\\x3k\\0\\0\\0\\xff\\0\\0\\0\\xff\\0\\xff\\xff\\xff\\xfb\\0\\0\\0 \\0I\\0n\\0t\\0\\x65\\0r\\0\\x66\\0\\x61\\0\\x63\\0\\x65\\0 \\0\\x45\\0\\x64\\0i\\0t\\0o\\0r\\0\\0\\0\\x4n\\0\\0\\0\\x14\\0\\0\\0\\x14\\0\\0\\0\\x14\\xfb\\0\\0\\0\\\"\\0\\x43\\0o\\0n\\0n\\0\\x65\\0\\x63\\0t\\0i\\0o\\0n\\0 \\0\\x45\\0\\x64\\0i\\0t\\0o\\0r\\0\\0\\0\\x4\\x86\\0\\0\\0\\x14\\0\\0\\0\\x14\\0\\0\\0\\x14\\0\\0\\0\\x2\\0\\0\\x6@\\0\\0\\0\\x63\\xfc\\x1\\0\\0\\0\\x1\\xfb\\0\\0\\0\\b\\0M\\0\\x65\\0n\\0u\\x1\\0\\0\\0\\0\\0\\0\\x6@\\0\\0\\0\\0\\0\\xff\\xff\\xff\\0\\0\\0\\x3\\0\\0\\x4\\xf4\\0\\0\\0\\xd6\\xfc\\x1\\0\\0\\0\\x3\\xfb\\0\\0\\0\\f\\0O\\0u\\0t\\0p\\0u\\0t\\x1\\0\\0\\x1L\\0\\0\\x3\\x82\\0\\0\\0P\\0\\xff\\xff\\xff\\xfb\\0\\0\\0\\x18\\0\\x43\\0o\\0n\\0t\\0\\x65\\0x\\0t\\0 \\0H\\0\\x65\\0l\\0p\\x1\\0\\0\\x4\\xd2\\0\\0\\x1n\\0\\0\\0P\\0\\xff\\xff\\xff\\xfb\\0\\0\\0\\x1c\\0\\x41\\0\\x64\\0\\x64\\0r\\0\\x65\\0s\\0s\\0 \\0\\x45\\0\\x64\\0i\\0t\\0o\\0r\\0\\0\\0\\0\\0\\xff\\xff\\xff\\xff\\0\\0\\x1*\\0\\xff\\xff\\xff\\0\\0\\x4\\xf4\\0\\0\\x3Y\\0\\0\\0\\x4\\0\\0\\0\\x4\\0\\0\\0\\x1\\0\\0\\0\\x2\\xfc\\0\\0\\0\\0\nADD Workspaces/Default/Geometry ByteArray \\x1\\xd9\\xd0\\xcb\\0\\x1\\0\\0\\xff\\xff\\xff\\xf8\\xff\\xff\\xff\\xf8\\0\\0\\x6G\\0\\0\\x4\\xb7\\0\\0\\x1 \\0\\0\\0\\xe3\\0\\0\\x5\\x1f\\0\\0\\x3\\xe2\\0\\0\\0\\0\\x2\\0\nADD Workspaces/Default/WindowPosition Point -8 -8\nADD Workspaces/Default/ConfigurationVisibility Boolean true\nADD Workspaces/Default/SystemDetailsVisibility Boolean true\nADD Workspaces/Default/ConnectionVisibility Boolean true\nADD Workspaces/Default/InstanceVisibility Boolean true\nADD Workspaces/Default/AdHocVisibility Boolean true\nADD Workspaces/Default/AddressVisibility Boolean false\nADD Workspaces/Default/InterfaceVisibility Boolean true\nADD Workspaces/Default/LibraryVisibility Boolean true\nADD Workspaces/Default/OutputVisibility Boolean true\nADD Workspaces/Default/ContextHelpVisibility Boolean true\nADD Workspaces/Default/PreviewVisibility Boolean true\nADD Workspaces/Default/DesignParameterVisibility Boolean true\nADD Workspaces/Design/WindowState ByteArray \\0\\0\\0\\xff\\0\\0\\0\\0\\xfd\\0\\0\\0\\x4\\0\\0\\0\\0\\0\\0\\x1H\\0\\0\\x4\\x33\\xfc\\x2\\0\\0\\0\\x2\\xfb\\0\\0\\0\\xe\\0L\\0i\\0\\x62\\0r\\0\\x61\\0r\\0y\\x1\\0\\0\\0g\\0\\0\\x3Y\\0\\0\\x1\\\\\\0\\xff\\xff\\xff\\xfb\\0\\0\\0 \\0\\x43\\0o\\0m\\0p\\0o\\0n\\0\\x65\\0n\\0t\\0P\\0r\\0\\x65\\0v\\0i\\0\\x65\\0w\\x1\\0\\0\\x3\\xc4\\0\\0\\0\\xd6\\0\\0\\0\\x8e\\0\\xff\\xff\\xff\\0\\0\\0\\x1\\0\\0\\x1&\\0\\0\\x4\\x33\\xfc\\x2\\0\\0\\0\\x6\\xfb\\0\\0\\0(\\0\\x43\\0o\\0n\\0\\x66\\0i\\0g\\0u\\0r\\0\\x61\\0t\\0i\\0o\\0n\\0 \\0\\x65\\0\\x64\\0i\\0t\\0o\\0r\\0\\0\\0\\0g\\0\\0\\x1\\xb5\\0\\0\\0\\xc5\\0\\xff\\xff\\xff\\xfb\\0\\0\\0\\x1e\\0I\\0n\\0s\\0t\\0\\x61\\0n\\0\\x63\\0\\x65\\0 \\0\\x45\\0\\x64\\0i\\0t\\0o\\0r\\0\\0\\0\\x2 \\0\\0\\0\\x14\\0\\0\\0\\x14\\0\\0\\0\\x14\\xfb\\0\\0\\0 \\0I\\0n\\0t\\0\\x65\\0r\\0\\x66\\0\\x61\\0\\x63\\0\\x65\\0 \\0\\x45\\0\\x64\\0i\\0t\\0o\\0r\\0\\0\\0\\x2\\x38\\0\\0\\0\\x14\\0\\0\\0\\x14\\0\\0\\0\\x14\\xfb\\0\\0\\0\\\"\\0\\x43\\0o\\0n\\0n\\0\\x65\\0\\x63\\0t\\0i\\0o\\0n\\0 \\0\\x45\\0\\x64\\0i\\0t\\0o\\0r\\0\\0\\0\\x2P\\0\\0\\0\\x14\\0\\0\\0\\x14\\0\\0\\0\\x14\\xfb\\0\\0\\0\\x32\\0H\\0W\\0 \\0M\\0\\x61\\0p\\0p\\0i\\0n\\0g\\0 \\0\\x44\\0\\x65\\0t\\0\\x61\\0i\\0l\\0s\\0 \\0\\x45\\0\\x64\\0i\\0t\\0o\\0r\\0\\0\\0\\x2h\\0\\0\\x2\\x32\\0\\0\\0\\xff\\0\\xff\\xff\\xff\\xfb\\0\\0\\0\\\"\\0\\x41\\0\\x64\\0-\\0h\\0o\\0\\x63\\0 \\0V\\0i\\0s\\0i\\0\\x62\\0i\\0l\\0i\\0t\\0y\\0\\0\\0\\x2\\xe3\\0\\0\\x1\\x87\\0\\0\\0\\x14\\0\\0\\0\\x14\\0\\0\\0\\x2\\0\\0\\x6@\\0\\0\\0\\x63\\xfc\\x1\\0\\0\\0\\x1\\xfb\\0\\0\\0\\b\\0M\\0\\x65\\0n\\0u\\x1\\0\\0\\0\\0\\0\\0\\x6@\\0\\0\\0\\0\\0\\xff\\xff\\xff\\0\\0\\0\\x3\\0\\0\\x4\\xf4\\0\\0\\0\\xd6\\xfc\\x1\\0\\0\\0\\x3\\xfb\\0\\0\\0\\f\\0O\\0u\\0t\\0p\\0u\\0t\\x1\\0\\0\\x1L\\0\\0\\x3&\\0\\0\\0P\\0\\xff\\xff\\xff\\xfb\\0\\0\\0\\x18\\0\\x43\\0o\\0n\\0t\\0\\x65\\0x\\0t\\0 \\0H\\0\\x65\\0l\\0p\\x1\\0\\0\\x4v\\0\\0\\x1\\xca\\0\\0\\0P\\0\\xff\\xff\\xff\\xfb\\0\\0\\0\\x1c\\0\\x41\\0\\x64\\0\\x64\\0r\\0\\x65\\0s\\0s\\0 \\0\\x45\\0\\x64\\0i\\0t\\0o\\0r\\0\\0\\0\\0\\0\\xff\\xff\\xff\\xff\\0\\0\\x1*\\0\\xff\\xff\\xff\\0\\0\\x4\\xf4\\0\\0\\x3Y\\0\\0\\0\\x4\\0\\0\\0\\x4\\0\\0\\0\\x1\\0\\0\\0\\x2\\xfc\\0\\0\\0\\0\nADD Workspaces/Design/Geometry ByteArray \\x1\\xd9\\xd0\\xcb\\0\\x1\\0\\0\\xff\\xff\\xff\\xf8\\xff\\xff\\xff\\xf8\\0\\0\\x6G\\0\\0\\x4\\xb7\\0\\0\\x1 \\0\\0\\0\\xe3\\0\\0\\x5\\x1f\\0\\0\\x3\\xe2\\0\\0\\0\\0\\x2\\0\nADD Workspaces/Design/WindowPosition Point -8 -8\nADD Workspaces/Design/ConfigurationVisibility Boolean true\nADD Workspaces/Design/SystemDetailsVisibility Boolean true\nADD Workspaces/Design/ConnectionVisibility Boolean true\nADD Workspaces/Design/InstanceVisibility Boolean true\nADD Workspaces/Design/AdHocVisibility Boolean false\nADD Workspaces/Design/AddressVisibility Boolean false\nADD Workspaces/Design/InterfaceVisibility Boolean true\nADD Workspaces/Design/LibraryVisibility Boolean true\nADD Workspaces/Design/OutputVisibility Boolean true\nADD Workspaces/Design/ContextHelpVisibility Boolean true\nADD Workspaces/Design/PreviewVisibility Boolean true\nADD Workspaces/Design/DesignParameterVisibility Boolean true\nADD Workspaces/CurrentWorkspace String Default\n\nVERSION 2.1.172.0\nCOPY Library/Locations Library/ActiveLocations\n\nVERSION 2.1.376.0\nADD FileTypes/cSource String c;h\nADD FileTypes/cppSource String cpp;hpp;cxx;hxx;cc;hh;h\nADD FileTypes/vhdlSource String vhdl;vhd\nADD FileTypes/asmSource String s;asm\nADD FileTypes/eSource String \nADD FileTypes/sopcInfoFile String sopcinfo\nADD FileTypes/OVASource String\nADD FileTypes/perlSource String pl\nADD FileTypes/pslSource String\nADD FileTypes/vhdlSource-87 String\nADD FileTypes/vhdlSource-93 String\nADD FileTypes/systemVerilogSource String sv\nADD FileTypes/systemVerilogSource-3.0 String\nADD FileTypes/systemVerilogSource-3.1 String\nADD FileTypes/systemVerilogSource-3.1a String\nADD FileTypes/verilogSource String v\nADD FileTypes/verilogSource-95 String\nADD FileTypes/verilogSource-2001 String\nADD FileTypes/SVASource String\nADD FileTypes/tclSource String tcl\nADD FileTypes/veraSource String \nADD FileTypes/systemCSource String\nADD FileTypes/systemCSource-2.0 String\nADD FileTypes/systemCSource-2.0.1 String\nADD FileTypes/systemCSource-2.1 String\nADD FileTypes/systemCSource-2.2 String\nADD FileTypes/unknown String\nADD FileTypes/SDC String sdc\nADD FileTypes/unelaboratedHdl String\nADD FileTypes/swObject String elf\nADD FileTypes/swObjectLibrary String\nADD FileTypes/executableHdl String sof\nADD FileTypes/verilogBinaryLibrary String\nADD FileTypes/vhdlBinaryLibrary String\nADD FileTypes/htmlFile String htm;html\nADD FileTypes/picture String png;gif;jpg;jpeg\nADD FileTypes/makefile String\nADD FileTypes/shellScript String sh\nADD FileTypes/pdfFile String pdf\nADD FileTypes/textFile String txt\nADD FileTypes/BSPFile String bsp\nADD FileTypes/ModelsimScript String do\n\nVERSION 2.3.0.0\nADD Workspaces/Design/LibraryFilters/Type/ShowComponents Boolean true\nADD Workspaces/Design/LibraryFilters/Type/ShowBuses Boolean true\nADD Workspaces/Design/LibraryFilters/Type/ShowAdvanced Boolean false\nADD Workspaces/Design/LibraryFilters/Implementation/ShowHW Boolean true\nADD Workspaces/Design/LibraryFilters/Implementation/ShowSW Boolean true\nADD Workspaces/Design/LibraryFilters/Implementation/ShowSystem Boolean true\nADD Workspaces/Design/LibraryFilters/Hierarchy/ShowGlobal Boolean true\nADD Workspaces/Design/LibraryFilters/Hierarchy/ShowProduct Boolean true\nADD Workspaces/Design/LibraryFilters/Hierarchy/ShowBoard Boolean true\nADD Workspaces/Design/LibraryFilters/Hierarchy/ShowChip Boolean true\nADD Workspaces/Design/LibraryFilters/Hierarchy/ShowSoC Boolean true\nADD Workspaces/Design/LibraryFilters/Hierarchy/ShowIP Boolean true\nADD Workspaces/Design/LibraryFilters/Firmness/ShowTemplates Boolean true\nADD Workspaces/Design/LibraryFilters/Firmness/ShowMutable Boolean true\nADD Workspaces/Design/LibraryFilters/Firmness/ShowFixed Boolean true\nADD Workspaces/Default/LibraryFilters/Type/ShowComponents Boolean true\nADD Workspaces/Default/LibraryFilters/Type/ShowBuses Boolean true\nADD Workspaces/Default/LibraryFilters/Type/ShowAdvanced Boolean false\nADD Workspaces/Default/LibraryFilters/Implementation/ShowHW Boolean true\nADD Workspaces/Default/LibraryFilters/Implementation/ShowSW Boolean true\nADD Workspaces/Default/LibraryFilters/Implementation/ShowSystem Boolean true\nADD Workspaces/Default/LibraryFilters/Hierarchy/ShowGlobal Boolean true\nADD Workspaces/Default/LibraryFilters/Hierarchy/ShowProduct Boolean true\nADD Workspaces/Default/LibraryFilters/Hierarchy/ShowBoard Boolean true\nADD Workspaces/Default/LibraryFilters/Hierarchy/ShowChip Boolean true\nADD Workspaces/Default/LibraryFilters/Hierarchy/ShowSoC Boolean true\nADD Workspaces/Default/LibraryFilters/Hierarchy/ShowIP Boolean true\nADD Workspaces/Default/LibraryFilters/Firmness/ShowTemplates Boolean true\nADD Workspaces/Default/LibraryFilters/Firmness/ShowMutable Boolean true\nADD Workspaces/Default/LibraryFilters/Firmness/ShowFixed Boolean true\n\nVERSION 2.4.0.0\nADD FileTypes/padsPart String p\nADD FileTypes/padsCAEDecal String c\nADD FileTypes/padsPCBDecal String d\n\nVERSION 2.4.17.0\nADD FileTypes/quartusPinFile String pin\nADD FileTypes/quartusProjectFile String qsf\n\nVERSION 2.5.0.0\nRENAME FileTypes/cSource FileTypes/cSource/Extensions\nRENAME FileTypes/cppSource FileTypes/cppSource/Extensions\nRENAME FileTypes/vhdlSource FileTypes/vhdlSource/Extensions\nRENAME FileTypes/asmSource FileTypes/asmSource/Extensions\nRENAME FileTypes/eSource FileTypes/eSource/Extensions\nRENAME FileTypes/sopcInfoFile FileTypes/sopcInfoFile/Extensions\nRENAME FileTypes/OVASource FileTypes/OVASource/Extensions\nRENAME FileTypes/perlSource FileTypes/perlSource/Extensions\nRENAME FileTypes/pslSource FileTypes/pslSource/Extensions\nRENAME FileTypes/vhdlSource-87 FileTypes/vhdlSource-87/Extensions\nRENAME FileTypes/vhdlSource-93 FileTypes/vhdlSource-93/Extensions\nRENAME FileTypes/systemVerilogSource FileTypes/systemVerilogSource/Extensions\nRENAME FileTypes/systemVerilogSource-3.0 FileTypes/systemVerilogSource-3.0/Extensions\nRENAME FileTypes/systemVerilogSource-3.1 FileTypes/systemVerilogSource-3.1/Extensions\nRENAME FileTypes/systemVerilogSource-3.1a FileTypes/systemVerilogSource-3.1a/Extensions\nRENAME FileTypes/verilogSource FileTypes/verilogSource/Extensions\nRENAME FileTypes/verilogSource-95 FileTypes/verilogSource-95/Extensions\nRENAME FileTypes/verilogSource-2001 FileTypes/verilogSource-2001/Extensions\nRENAME FileTypes/SVASource FileTypes/SVASource/Extensions\nRENAME FileTypes/tclSource FileTypes/tclSource/Extensions\nRENAME FileTypes/veraSource FileTypes/veraSource/Extensions\nRENAME FileTypes/systemCSource FileTypes/systemCSource/Extensions\nRENAME FileTypes/systemCSource-2.0 FileTypes/systemCSource-2.0/Extensions\nRENAME FileTypes/systemCSource-2.0.1 FileTypes/systemCSource-2.0.1/Extensions\nRENAME FileTypes/systemCSource-2.1 FileTypes/systemCSource-2.1/Extensions\nRENAME FileTypes/systemCSource-2.2 FileTypes/systemCSource-2.2/Extensions\nRENAME FileTypes/unknown FileTypes/unknown/Extensions\nRENAME FileTypes/SDC FileTypes/SDC/Extensions\nRENAME FileTypes/unelaboratedHdl FileTypes/unelaboratedHdl/Extensions\nRENAME FileTypes/swObject FileTypes/swObject/Extensions\nRENAME FileTypes/swObjectLibrary FileTypes/swObjectLibrary/Extensions\nRENAME FileTypes/executableHdl FileTypes/executableHdl/Extensions\nRENAME FileTypes/verilogBinaryLibrary FileTypes/verilogBinaryLibrary/Extensions\nRENAME FileTypes/vhdlBinaryLibrary FileTypes/vhdlBinaryLibrary/Extensions\nRENAME FileTypes/htmlFile FileTypes/htmlFile/Extensions\nRENAME FileTypes/picture FileTypes/picture/Extensions\nRENAME FileTypes/makefile FileTypes/makefile/Extensions\nRENAME FileTypes/shellScript FileTypes/shellScript/Extensions\nRENAME FileTypes/pdfFile FileTypes/pdfFile/Extensions\nRENAME FileTypes/textFile FileTypes/textFile/Extensions\nRENAME FileTypes/BSPFile FileTypes/BSPFile/Extensions\nRENAME FileTypes/ModelsimScript FileTypes/ModelsimScript/Extensions\nRENAME FileTypes/padsPart FileTypes/padsPart/Extensions\nRENAME FileTypes/padsCAEDecal FileTypes/padsCAEDecal/Extensions\nRENAME FileTypes/padsPCBDecal FileTypes/padsPCBDecal/Extensions\nRENAME FileTypes/quartusPinFile FileTypes/quartusPinFile/Extensions\nRENAME FileTypes/quartusProjectFile FileTypes/quartusProjectFile/Extensions\nADD FileTypes/cSource/Executable String\nADD FileTypes/cppSource/Executable String\nADD FileTypes/vhdlSource/Executable String\nADD FileTypes/asmSource/Executable String\nADD FileTypes/eSource/Executable String\nADD FileTypes/sopcInfoFile/Executable String\nADD FileTypes/OVASource/Executable String\nADD FileTypes/perlSource/Executable String\nADD FileTypes/pslSource/Executable String\nADD FileTypes/vhdlSource-87/Executable String\nADD FileTypes/vhdlSource-93/Executable String\nADD FileTypes/systemVerilogSource/Executable String\nADD FileTypes/systemVerilogSource-3.0/Executable String\nADD FileTypes/systemVerilogSource-3.1/Executable String\nADD FileTypes/systemVerilogSource-3.1a/Executable String\nADD FileTypes/verilogSource/Executable String\nADD FileTypes/verilogSource-95/Executable String\nADD FileTypes/verilogSource-2001/Executable String\nADD FileTypes/SVASource/Executable String\nADD FileTypes/tclSource/Executable String\nADD FileTypes/veraSource/Executable String\nADD FileTypes/systemCSource/Executable String\nADD FileTypes/systemCSource-2.0/Executable String\nADD FileTypes/systemCSource-2.0.1/Executable String\nADD FileTypes/systemCSource-2.1/Executable String\nADD FileTypes/systemCSource-2.2/Executable String\nADD FileTypes/unknown/Executable String\nADD FileTypes/SDC/Executable String\nADD FileTypes/unelaboratedHdl/Executable String\nADD FileTypes/swObject/Executable String\nADD FileTypes/swObjectLibrary/Executable String\nADD FileTypes/executableHdl/Executable String\nADD FileTypes/verilogBinaryLibrary/Executable String\nADD FileTypes/vhdlBinaryLibrary/Executable String\nADD FileTypes/htmlFile/Executable String\nADD FileTypes/picture/Executable String\nADD FileTypes/makefile/Executable String\nADD FileTypes/shellScript/Executable String\nADD FileTypes/pdfFile/Executable String\nADD FileTypes/textFile/Executable String\nADD FileTypes/BSPFile/Executable String bsp\nADD FileTypes/ModelsimScript/Executable String\nADD FileTypes/padsPart/Executable String\nADD FileTypes/padsCAEDecal/Executable String\nADD FileTypes/padsPCBDecal/Executable String\nADD FileTypes/quartusPinFile/Executable String\nADD FileTypes/quartusProjectFile/Executable String\n\nVERSION 2.6.842.0\nADD Workspaces/Default/ComponentEditorFilters/HW/Global/File_sets Boolean true\nADD Workspaces/Default/ComponentEditorFilters/HW/Global/Choices Boolean true\nADD Workspaces/Default/ComponentEditorFilters/HW/Global/Model_parameters Boolean true\nADD Workspaces/Default/ComponentEditorFilters/HW/Global/Parameters Boolean true\nADD Workspaces/Default/ComponentEditorFilters/HW/Global/Memory_maps Boolean true\nADD Workspaces/Default/ComponentEditorFilters/HW/Global/Address_spaces Boolean true\nADD Workspaces/Default/ComponentEditorFilters/HW/Global/Views Boolean true\nADD Workspaces/Default/ComponentEditorFilters/HW/Global/Software_views Boolean true\nADD Workspaces/Default/ComponentEditorFilters/HW/Global/System_views Boolean true\nADD Workspaces/Default/ComponentEditorFilters/HW/Global/Ports Boolean true\nADD Workspaces/Default/ComponentEditorFilters/HW/Global/Bus_interfaces Boolean true\nADD Workspaces/Default/ComponentEditorFilters/HW/Global/Channels Boolean true\nADD Workspaces/Default/ComponentEditorFilters/HW/Global/Cpus Boolean true\nADD Workspaces/Default/ComponentEditorFilters/HW/Global/Other_clock_drivers Boolean true\nADD Workspaces/Default/ComponentEditorFilters/HW/Global/COM_interfaces Boolean true\nADD Workspaces/Default/ComponentEditorFilters/HW/Global/Software_properties Boolean true\nADD Workspaces/Default/ComponentEditorFilters/HW/Product/File_sets Boolean true\nADD Workspaces/Default/ComponentEditorFilters/HW/Product/Choices Boolean true\nADD Workspaces/Default/ComponentEditorFilters/HW/Product/Model_parameters Boolean true\nADD Workspaces/Default/ComponentEditorFilters/HW/Product/Parameters Boolean true\nADD Workspaces/Default/ComponentEditorFilters/HW/Product/Memory_maps Boolean true\nADD Workspaces/Default/ComponentEditorFilters/HW/Product/Address_spaces Boolean true\nADD Workspaces/Default/ComponentEditorFilters/HW/Product/Views Boolean true\nADD Workspaces/Default/ComponentEditorFilters/HW/Product/Software_views Boolean true\nADD Workspaces/Default/ComponentEditorFilters/HW/Product/System_views Boolean true\nADD Workspaces/Default/ComponentEditorFilters/HW/Product/Ports Boolean true\nADD Workspaces/Default/ComponentEditorFilters/HW/Product/Bus_interfaces Boolean true\nADD Workspaces/Default/ComponentEditorFilters/HW/Product/Channels Boolean true\nADD Workspaces/Default/ComponentEditorFilters/HW/Product/Cpus Boolean true\nADD Workspaces/Default/ComponentEditorFilters/HW/Product/Other_clock_drivers Boolean true\nADD Workspaces/Default/ComponentEditorFilters/HW/Product/COM_interfaces Boolean true\nADD Workspaces/Default/ComponentEditorFilters/HW/Product/Software_properties Boolean true\nADD Workspaces/Default/ComponentEditorFilters/HW/Board/File_sets Boolean true\nADD Workspaces/Default/ComponentEditorFilters/HW/Board/Choices Boolean true\nADD Workspaces/Default/ComponentEditorFilters/HW/Board/Model_parameters Boolean true\nADD Workspaces/Default/ComponentEditorFilters/HW/Board/Parameters Boolean true\nADD Workspaces/Default/ComponentEditorFilters/HW/Board/Memory_maps Boolean true\nADD Workspaces/Default/ComponentEditorFilters/HW/Board/Address_spaces Boolean true\nADD Workspaces/Default/ComponentEditorFilters/HW/Board/Views Boolean true\nADD Workspaces/Default/ComponentEditorFilters/HW/Board/Software_views Boolean true\nADD Workspaces/Default/ComponentEditorFilters/HW/Board/System_views Boolean true\nADD Workspaces/Default/ComponentEditorFilters/HW/Board/Ports Boolean true\nADD Workspaces/Default/ComponentEditorFilters/HW/Board/Bus_interfaces Boolean true\nADD Workspaces/Default/ComponentEditorFilters/HW/Board/Channels Boolean true\nADD Workspaces/Default/ComponentEditorFilters/HW/Board/Cpus Boolean true\nADD Workspaces/Default/ComponentEditorFilters/HW/Board/Other_clock_drivers Boolean true\nADD Workspaces/Default/ComponentEditorFilters/HW/Board/COM_interfaces Boolean true\nADD Workspaces/Default/ComponentEditorFilters/HW/Board/Software_properties Boolean true\nADD Workspaces/Default/ComponentEditorFilters/HW/Chip/File_sets Boolean true\nADD Workspaces/Default/ComponentEditorFilters/HW/Chip/Choices Boolean true\nADD Workspaces/Default/ComponentEditorFilters/HW/Chip/Model_parameters Boolean true\nADD Workspaces/Default/ComponentEditorFilters/HW/Chip/Parameters Boolean true\nADD Workspaces/Default/ComponentEditorFilters/HW/Chip/Memory_maps Boolean true\nADD Workspaces/Default/ComponentEditorFilters/HW/Chip/Address_spaces Boolean true\nADD Workspaces/Default/ComponentEditorFilters/HW/Chip/Views Boolean true\nADD Workspaces/Default/ComponentEditorFilters/HW/Chip/Software_views Boolean true\nADD Workspaces/Default/ComponentEditorFilters/HW/Chip/System_views Boolean true\nADD Workspaces/Default/ComponentEditorFilters/HW/Chip/Ports Boolean true\nADD Workspaces/Default/ComponentEditorFilters/HW/Chip/Bus_interfaces Boolean true\nADD Workspaces/Default/ComponentEditorFilters/HW/Chip/Channels Boolean true\nADD Workspaces/Default/ComponentEditorFilters/HW/Chip/Cpus Boolean true\nADD Workspaces/Default/ComponentEditorFilters/HW/Chip/Other_clock_drivers Boolean true\nADD Workspaces/Default/ComponentEditorFilters/HW/Chip/COM_interfaces Boolean true\nADD Workspaces/Default/ComponentEditorFilters/HW/Chip/Software_properties Boolean true\nADD Workspaces/Default/ComponentEditorFilters/HW/Soc/File_sets Boolean true\nADD Workspaces/Default/ComponentEditorFilters/HW/Soc/Choices Boolean true\nADD Workspaces/Default/ComponentEditorFilters/HW/Soc/Model_parameters Boolean true\nADD Workspaces/Default/ComponentEditorFilters/HW/Soc/Parameters Boolean true\nADD Workspaces/Default/ComponentEditorFilters/HW/Soc/Memory_maps Boolean true\nADD Workspaces/Default/ComponentEditorFilters/HW/Soc/Address_spaces Boolean true\nADD Workspaces/Default/ComponentEditorFilters/HW/Soc/Views Boolean true\nADD Workspaces/Default/ComponentEditorFilters/HW/Soc/Software_views Boolean true\nADD Workspaces/Default/ComponentEditorFilters/HW/Soc/System_views Boolean true\nADD Workspaces/Default/ComponentEditorFilters/HW/Soc/Ports Boolean true\nADD Workspaces/Default/ComponentEditorFilters/HW/Soc/Bus_interfaces Boolean true\nADD Workspaces/Default/ComponentEditorFilters/HW/Soc/Channels Boolean true\nADD Workspaces/Default/ComponentEditorFilters/HW/Soc/Cpus Boolean true\nADD Workspaces/Default/ComponentEditorFilters/HW/Soc/Other_clock_drivers Boolean true\nADD Workspaces/Default/ComponentEditorFilters/HW/Soc/COM_interfaces Boolean true\nADD Workspaces/Default/ComponentEditorFilters/HW/Soc/Software_properties Boolean true\nADD Workspaces/Default/ComponentEditorFilters/HW/IP/File_sets Boolean true\nADD Workspaces/Default/ComponentEditorFilters/HW/IP/Choices Boolean true\nADD Workspaces/Default/ComponentEditorFilters/HW/IP/Model_parameters Boolean true\nADD Workspaces/Default/ComponentEditorFilters/HW/IP/Parameters Boolean true\nADD Workspaces/Default/ComponentEditorFilters/HW/IP/Memory_maps Boolean true\nADD Workspaces/Default/ComponentEditorFilters/HW/IP/Address_spaces Boolean true\nADD Workspaces/Default/ComponentEditorFilters/HW/IP/Views Boolean true\nADD Workspaces/Default/ComponentEditorFilters/HW/IP/Software_views Boolean true\nADD Workspaces/Default/ComponentEditorFilters/HW/IP/System_views Boolean true\nADD Workspaces/Default/ComponentEditorFilters/HW/IP/Ports Boolean true\nADD Workspaces/Default/ComponentEditorFilters/HW/IP/Bus_interfaces Boolean true\nADD Workspaces/Default/ComponentEditorFilters/HW/IP/Channels Boolean true\nADD Workspaces/Default/ComponentEditorFilters/HW/IP/Cpus Boolean true\nADD Workspaces/Default/ComponentEditorFilters/HW/IP/Other_clock_drivers Boolean true\nADD Workspaces/Default/ComponentEditorFilters/HW/IP/COM_interfaces Boolean true\nADD Workspaces/Default/ComponentEditorFilters/HW/IP/Software_properties Boolean true\nADD Workspaces/Default/ComponentEditorFilters/HW/Prodhier_count/File_sets Boolean true\nADD Workspaces/Default/ComponentEditorFilters/HW/Prodhier_count/Choices Boolean true\nADD Workspaces/Default/ComponentEditorFilters/HW/Prodhier_count/Model_parameters Boolean true\nADD Workspaces/Default/ComponentEditorFilters/HW/Prodhier_count/Parameters Boolean true\nADD Workspaces/Default/ComponentEditorFilters/HW/Prodhier_count/Memory_maps Boolean true\nADD Workspaces/Default/ComponentEditorFilters/HW/Prodhier_count/Address_spaces Boolean true\nADD Workspaces/Default/ComponentEditorFilters/HW/Prodhier_count/Views Boolean true\nADD Workspaces/Default/ComponentEditorFilters/HW/Prodhier_count/Software_views Boolean true\nADD Workspaces/Default/ComponentEditorFilters/HW/Prodhier_count/System_views Boolean true\nADD Workspaces/Default/ComponentEditorFilters/HW/Prodhier_count/Ports Boolean true\nADD Workspaces/Default/ComponentEditorFilters/HW/Prodhier_count/Bus_interfaces Boolean true\nADD Workspaces/Default/ComponentEditorFilters/HW/Prodhier_count/Channels Boolean true\nADD Workspaces/Default/ComponentEditorFilters/HW/Prodhier_count/Cpus Boolean true\nADD Workspaces/Default/ComponentEditorFilters/HW/Prodhier_count/Other_clock_drivers Boolean true\nADD Workspaces/Default/ComponentEditorFilters/HW/Prodhier_count/COM_interfaces Boolean true\nADD Workspaces/Default/ComponentEditorFilters/HW/Prodhier_count/Software_properties Boolean true\nADD Workspaces/Default/ComponentEditorFilters/SW/File_sets Boolean true\nADD Workspaces/Default/ComponentEditorFilters/SW/Choices Boolean true\nADD Workspaces/Default/ComponentEditorFilters/SW/Parameters Boolean true\nADD Workspaces/Default/ComponentEditorFilters/SW/Software_views Boolean true\nADD Workspaces/Default/ComponentEditorFilters/SW/COM_interfaces Boolean true\nADD Workspaces/Default/ComponentEditorFilters/SW/API_interfaces Boolean true\nADD Workspaces/Default/ComponentEditorFilters/SW/Software_properties Boolean true\nADD Workspaces/Design/ComponentEditorFilters/HW/Global/File_sets Boolean true\nADD Workspaces/Design/ComponentEditorFilters/HW/Global/Choices Boolean true\nADD Workspaces/Design/ComponentEditorFilters/HW/Global/Model_parameters Boolean true\nADD Workspaces/Design/ComponentEditorFilters/HW/Global/Parameters Boolean true\nADD Workspaces/Design/ComponentEditorFilters/HW/Global/Memory_maps Boolean true\nADD Workspaces/Design/ComponentEditorFilters/HW/Global/Address_spaces Boolean true\nADD Workspaces/Design/ComponentEditorFilters/HW/Global/Views Boolean true\nADD Workspaces/Design/ComponentEditorFilters/HW/Global/Software_views Boolean true\nADD Workspaces/Design/ComponentEditorFilters/HW/Global/System_views Boolean true\nADD Workspaces/Design/ComponentEditorFilters/HW/Global/Ports Boolean true\nADD Workspaces/Design/ComponentEditorFilters/HW/Global/Bus_interfaces Boolean true\nADD Workspaces/Design/ComponentEditorFilters/HW/Global/Channels Boolean true\nADD Workspaces/Design/ComponentEditorFilters/HW/Global/Cpus Boolean true\nADD Workspaces/Design/ComponentEditorFilters/HW/Global/Other_clock_drivers Boolean true\nADD Workspaces/Design/ComponentEditorFilters/HW/Global/COM_interfaces Boolean true\nADD Workspaces/Design/ComponentEditorFilters/HW/Global/Software_properties Boolean true\nADD Workspaces/Design/ComponentEditorFilters/HW/Product/File_sets Boolean true\nADD Workspaces/Design/ComponentEditorFilters/HW/Product/Choices Boolean true\nADD Workspaces/Design/ComponentEditorFilters/HW/Product/Model_parameters Boolean true\nADD Workspaces/Design/ComponentEditorFilters/HW/Product/Parameters Boolean true\nADD Workspaces/Design/ComponentEditorFilters/HW/Product/Memory_maps Boolean true\nADD Workspaces/Design/ComponentEditorFilters/HW/Product/Address_spaces Boolean true\nADD Workspaces/Design/ComponentEditorFilters/HW/Product/Views Boolean true\nADD Workspaces/Design/ComponentEditorFilters/HW/Product/Software_views Boolean true\nADD Workspaces/Design/ComponentEditorFilters/HW/Product/System_views Boolean true\nADD Workspaces/Design/ComponentEditorFilters/HW/Product/Ports Boolean true\nADD Workspaces/Design/ComponentEditorFilters/HW/Product/Bus_interfaces Boolean true\nADD Workspaces/Design/ComponentEditorFilters/HW/Product/Channels Boolean true\nADD Workspaces/Design/ComponentEditorFilters/HW/Product/Cpus Boolean true\nADD Workspaces/Design/ComponentEditorFilters/HW/Product/Other_clock_drivers Boolean true\nADD Workspaces/Design/ComponentEditorFilters/HW/Product/COM_interfaces Boolean true\nADD Workspaces/Design/ComponentEditorFilters/HW/Product/Software_properties Boolean true\nADD Workspaces/Design/ComponentEditorFilters/HW/Board/File_sets Boolean true\nADD Workspaces/Design/ComponentEditorFilters/HW/Board/Choices Boolean true\nADD Workspaces/Design/ComponentEditorFilters/HW/Board/Model_parameters Boolean true\nADD Workspaces/Design/ComponentEditorFilters/HW/Board/Parameters Boolean true\nADD Workspaces/Design/ComponentEditorFilters/HW/Board/Memory_maps Boolean true\nADD Workspaces/Design/ComponentEditorFilters/HW/Board/Address_spaces Boolean true\nADD Workspaces/Design/ComponentEditorFilters/HW/Board/Views Boolean true\nADD Workspaces/Design/ComponentEditorFilters/HW/Board/Software_views Boolean true\nADD Workspaces/Design/ComponentEditorFilters/HW/Board/System_views Boolean true\nADD Workspaces/Design/ComponentEditorFilters/HW/Board/Ports Boolean true\nADD Workspaces/Design/ComponentEditorFilters/HW/Board/Bus_interfaces Boolean true\nADD Workspaces/Design/ComponentEditorFilters/HW/Board/Channels Boolean true\nADD Workspaces/Design/ComponentEditorFilters/HW/Board/Cpus Boolean true\nADD Workspaces/Design/ComponentEditorFilters/HW/Board/Other_clock_drivers Boolean true\nADD Workspaces/Design/ComponentEditorFilters/HW/Board/COM_interfaces Boolean true\nADD Workspaces/Design/ComponentEditorFilters/HW/Board/Software_properties Boolean true\nADD Workspaces/Design/ComponentEditorFilters/HW/Chip/File_sets Boolean true\nADD Workspaces/Design/ComponentEditorFilters/HW/Chip/Choices Boolean true\nADD Workspaces/Design/ComponentEditorFilters/HW/Chip/Model_parameters Boolean true\nADD Workspaces/Design/ComponentEditorFilters/HW/Chip/Parameters Boolean true\nADD Workspaces/Design/ComponentEditorFilters/HW/Chip/Memory_maps Boolean true\nADD Workspaces/Design/ComponentEditorFilters/HW/Chip/Address_spaces Boolean true\nADD Workspaces/Design/ComponentEditorFilters/HW/Chip/Views Boolean true\nADD Workspaces/Design/ComponentEditorFilters/HW/Chip/Software_views Boolean true\nADD Workspaces/Design/ComponentEditorFilters/HW/Chip/System_views Boolean true\nADD Workspaces/Design/ComponentEditorFilters/HW/Chip/Ports Boolean true\nADD Workspaces/Design/ComponentEditorFilters/HW/Chip/Bus_interfaces Boolean true\nADD Workspaces/Design/ComponentEditorFilters/HW/Chip/Channels Boolean true\nADD Workspaces/Design/ComponentEditorFilters/HW/Chip/Cpus Boolean true\nADD Workspaces/Design/ComponentEditorFilters/HW/Chip/Other_clock_drivers Boolean true\nADD Workspaces/Design/ComponentEditorFilters/HW/Chip/COM_interfaces Boolean true\nADD Workspaces/Design/ComponentEditorFilters/HW/Chip/Software_properties Boolean true\nADD Workspaces/Design/ComponentEditorFilters/HW/Soc/File_sets Boolean true\nADD Workspaces/Design/ComponentEditorFilters/HW/Soc/Choices Boolean true\nADD Workspaces/Design/ComponentEditorFilters/HW/Soc/Model_parameters Boolean true\nADD Workspaces/Design/ComponentEditorFilters/HW/Soc/Parameters Boolean true\nADD Workspaces/Design/ComponentEditorFilters/HW/Soc/Memory_maps Boolean true\nADD Workspaces/Design/ComponentEditorFilters/HW/Soc/Address_spaces Boolean true\nADD Workspaces/Design/ComponentEditorFilters/HW/Soc/Views Boolean true\nADD Workspaces/Design/ComponentEditorFilters/HW/Soc/Software_views Boolean true\nADD Workspaces/Design/ComponentEditorFilters/HW/Soc/System_views Boolean true\nADD Workspaces/Design/ComponentEditorFilters/HW/Soc/Ports Boolean true\nADD Workspaces/Design/ComponentEditorFilters/HW/Soc/Bus_interfaces Boolean true\nADD Workspaces/Design/ComponentEditorFilters/HW/Soc/Channels Boolean true\nADD Workspaces/Design/ComponentEditorFilters/HW/Soc/Cpus Boolean true\nADD Workspaces/Design/ComponentEditorFilters/HW/Soc/Other_clock_drivers Boolean true\nADD Workspaces/Design/ComponentEditorFilters/HW/Soc/COM_interfaces Boolean true\nADD Workspaces/Design/ComponentEditorFilters/HW/Soc/Software_properties Boolean true\nADD Workspaces/Design/ComponentEditorFilters/HW/IP/File_sets Boolean true\nADD Workspaces/Design/ComponentEditorFilters/HW/IP/Choices Boolean true\nADD Workspaces/Design/ComponentEditorFilters/HW/IP/Model_parameters Boolean true\nADD Workspaces/Design/ComponentEditorFilters/HW/IP/Parameters Boolean true\nADD Workspaces/Design/ComponentEditorFilters/HW/IP/Memory_maps Boolean true\nADD Workspaces/Design/ComponentEditorFilters/HW/IP/Address_spaces Boolean true\nADD Workspaces/Design/ComponentEditorFilters/HW/IP/Views Boolean true\nADD Workspaces/Design/ComponentEditorFilters/HW/IP/Software_views Boolean true\nADD Workspaces/Design/ComponentEditorFilters/HW/IP/System_views Boolean true\nADD Workspaces/Design/ComponentEditorFilters/HW/IP/Ports Boolean true\nADD Workspaces/Design/ComponentEditorFilters/HW/IP/Bus_interfaces Boolean true\nADD Workspaces/Design/ComponentEditorFilters/HW/IP/Channels Boolean true\nADD Workspaces/Design/ComponentEditorFilters/HW/IP/Cpus Boolean true\nADD Workspaces/Design/ComponentEditorFilters/HW/IP/Other_clock_drivers Boolean true\nADD Workspaces/Design/ComponentEditorFilters/HW/IP/COM_interfaces Boolean true\nADD Workspaces/Design/ComponentEditorFilters/HW/IP/Software_properties Boolean true\nADD Workspaces/Design/ComponentEditorFilters/HW/Prodhier_count/File_sets Boolean true\nADD Workspaces/Design/ComponentEditorFilters/HW/Prodhier_count/Choices Boolean true\nADD Workspaces/Design/ComponentEditorFilters/HW/Prodhier_count/Model_parameters Boolean true\nADD Workspaces/Design/ComponentEditorFilters/HW/Prodhier_count/Parameters Boolean true\nADD Workspaces/Design/ComponentEditorFilters/HW/Prodhier_count/Memory_maps Boolean true\nADD Workspaces/Design/ComponentEditorFilters/HW/Prodhier_count/Address_spaces Boolean true\nADD Workspaces/Design/ComponentEditorFilters/HW/Prodhier_count/Views Boolean true\nADD Workspaces/Design/ComponentEditorFilters/HW/Prodhier_count/Software_views Boolean true\nADD Workspaces/Design/ComponentEditorFilters/HW/Prodhier_count/System_views Boolean true\nADD Workspaces/Design/ComponentEditorFilters/HW/Prodhier_count/Ports Boolean true\nADD Workspaces/Design/ComponentEditorFilters/HW/Prodhier_count/Bus_interfaces Boolean true\nADD Workspaces/Design/ComponentEditorFilters/HW/Prodhier_count/Channels Boolean true\nADD Workspaces/Design/ComponentEditorFilters/HW/Prodhier_count/Cpus Boolean true\nADD Workspaces/Design/ComponentEditorFilters/HW/Prodhier_count/Other_clock_drivers Boolean true\nADD Workspaces/Design/ComponentEditorFilters/HW/Prodhier_count/COM_interfaces Boolean true\nADD Workspaces/Design/ComponentEditorFilters/HW/Prodhier_count/Software_properties Boolean true\nADD Workspaces/Design/ComponentEditorFilters/SW/File_sets Boolean true\nADD Workspaces/Design/ComponentEditorFilters/SW/Choices Boolean true\nADD Workspaces/Design/ComponentEditorFilters/SW/Parameters Boolean true\nADD Workspaces/Design/ComponentEditorFilters/SW/Software_views Boolean true\nADD Workspaces/Design/ComponentEditorFilters/SW/COM_interfaces Boolean true\nADD Workspaces/Design/ComponentEditorFilters/SW/API_interfaces Boolean true\nADD Workspaces/Design/ComponentEditorFilters/SW/Software_properties Boolean true\n\nVERSION 2.7.219.0\nRENAME Workspaces/Default/ComponentEditorFilters/HW/Global/File_sets Workspaces/Default/ComponentEditorFilters/HW/Flat/File_sets\nRENAME Workspaces/Default/ComponentEditorFilters/HW/Global/Choices Workspaces/Default/ComponentEditorFilters/HW/Flat/Choices\nRENAME Workspaces/Default/ComponentEditorFilters/HW/Global/Model_parameters Workspaces/Default/ComponentEditorFilters/HW/Flat/Model_parameters\nRENAME Workspaces/Default/ComponentEditorFilters/HW/Global/Parameters Workspaces/Default/ComponentEditorFilters/HW/Flat/Parameters\nRENAME Workspaces/Default/ComponentEditorFilters/HW/Global/Memory_maps Workspaces/Default/ComponentEditorFilters/HW/Flat/Memory_maps\nRENAME Workspaces/Default/ComponentEditorFilters/HW/Global/Address_spaces Workspaces/Default/ComponentEditorFilters/HW/Flat/Address_spaces\nRENAME Workspaces/Default/ComponentEditorFilters/HW/Global/Views Boolean Workspaces/Default/ComponentEditorFilters/HW/Flat/Views Boolean\nRENAME Workspaces/Default/ComponentEditorFilters/HW/Global/Software_views Workspaces/Default/ComponentEditorFilters/HW/Flat/Software_views\nRENAME Workspaces/Default/ComponentEditorFilters/HW/Global/System_views Workspaces/Default/ComponentEditorFilters/HW/Flat/System_views\nRENAME Workspaces/Default/ComponentEditorFilters/HW/Global/Ports Workspaces/Default/ComponentEditorFilters/HW/Flat/Ports\nRENAME Workspaces/Default/ComponentEditorFilters/HW/Global/Bus_interfaces Workspaces/Default/ComponentEditorFilters/HW/Flat/Bus_interfaces\nRENAME Workspaces/Default/ComponentEditorFilters/HW/Global/Channels Boolean Workspaces/Default/ComponentEditorFilters/HW/Flat/Channels Boolean\nRENAME Workspaces/Default/ComponentEditorFilters/HW/Global/Cpus Workspaces/Default/ComponentEditorFilters/HW/Flat/Cpus\nRENAME Workspaces/Default/ComponentEditorFilters/HW/Global/Other_clock_drivers Workspaces/Default/ComponentEditorFilters/HW/Flat/Other_clock_drivers\nRENAME Workspaces/Default/ComponentEditorFilters/HW/Global/COM_interfaces Workspaces/Default/ComponentEditorFilters/HW/Flat/COM_interfaces\nRENAME Workspaces/Default/ComponentEditorFilters/HW/Global/Software_properties Workspaces/Default/ComponentEditorFilters/HW/Flat/Software_properties\nRENAME Workspaces/Design/ComponentEditorFilters/HW/Global/File_sets Workspaces/Design/ComponentEditorFilters/HW/Flat/File_sets\nRENAME Workspaces/Design/ComponentEditorFilters/HW/Global/Choices Workspaces/Design/ComponentEditorFilters/HW/Flat/Choices\nRENAME Workspaces/Design/ComponentEditorFilters/HW/Global/Model_parameters Workspaces/Design/ComponentEditorFilters/HW/Flat/Model_parameters\nRENAME Workspaces/Design/ComponentEditorFilters/HW/Global/Parameters Workspaces/Design/ComponentEditorFilters/HW/Flat/Parameters\nRENAME Workspaces/Design/ComponentEditorFilters/HW/Global/Memory_maps Workspaces/Design/ComponentEditorFilters/HW/Flat/Memory_maps\nRENAME Workspaces/Design/ComponentEditorFilters/HW/Global/Address_spaces Workspaces/Design/ComponentEditorFilters/HW/Flat/Address_spaces\nRENAME Workspaces/Design/ComponentEditorFilters/HW/Global/Views Boolean Workspaces/Design/ComponentEditorFilters/HW/Flat/Views Boolean\nRENAME Workspaces/Design/ComponentEditorFilters/HW/Global/Software_views Workspaces/Design/ComponentEditorFilters/HW/Flat/Software_views\nRENAME Workspaces/Design/ComponentEditorFilters/HW/Global/System_views Workspaces/Design/ComponentEditorFilters/HW/Flat/System_views\nRENAME Workspaces/Design/ComponentEditorFilters/HW/Global/Ports Workspaces/Design/ComponentEditorFilters/HW/Flat/Ports\nRENAME Workspaces/Design/ComponentEditorFilters/HW/Global/Bus_interfaces Workspaces/Design/ComponentEditorFilters/HW/Flat/Bus_interfaces\nRENAME Workspaces/Design/ComponentEditorFilters/HW/Global/Channels Boolean Workspaces/Design/ComponentEditorFilters/HW/Flat/Channels Boolean\nRENAME Workspaces/Design/ComponentEditorFilters/HW/Global/Cpus Workspaces/Design/ComponentEditorFilters/HW/Flat/Cpus\nRENAME Workspaces/Design/ComponentEditorFilters/HW/Global/Other_clock_drivers Workspaces/Design/ComponentEditorFilters/HW/Flat/Other_clock_drivers\nRENAME Workspaces/Design/ComponentEditorFilters/HW/Global/COM_interfaces Workspaces/Design/ComponentEditorFilters/HW/Flat/COM_interfaces\nRENAME Workspaces/Design/ComponentEditorFilters/HW/Global/Software_properties Workspaces/Design/ComponentEditorFilters/HW/Flat/Software_properties\n\nVERSION 2.7.615.0\nADD Workspaces/Default/ComponentEditorFilters/HW/Flat/Remap_states Boolean true\nADD Workspaces/Default/ComponentEditorFilters/HW/Product/Remap_states Boolean true\nADD Workspaces/Default/ComponentEditorFilters/HW/Board/Remap_states Boolean true\nADD Workspaces/Default/ComponentEditorFilters/HW/Chip/Remap_states Boolean true\nADD Workspaces/Default/ComponentEditorFilters/HW/Soc/Remap_states Boolean true\nADD Workspaces/Default/ComponentEditorFilters/HW/IP/Remap_states Boolean true\nADD Workspaces/Design/ComponentEditorFilters/HW/Flat/Remap_states Boolean true\nADD Workspaces/Design/ComponentEditorFilters/HW/Product/Remap_states Boolean true\nADD Workspaces/Design/ComponentEditorFilters/HW/Board/Remap_states Boolean true\nADD Workspaces/Design/ComponentEditorFilters/HW/Chip/Remap_states Boolean true\nADD Workspaces/Design/ComponentEditorFilters/HW/Soc/Remap_states Boolean true\nADD Workspaces/Design/ComponentEditorFilters/HW/IP/Remap_states Boolean true\n\nVERSION 2.8.0.0\nADD General/showExitScreen Boolean true\n\nVERSION 2.8.630.0\nREMOVE Workspaces/Default/ComponentEditorFilters/HW/Flat/Model_parameters\nREMOVE Workspaces/Default/ComponentEditorFilters/HW/Product/Model_parameters\nREMOVE Workspaces/Default/ComponentEditorFilters/HW/Board/Model_parameters\nREMOVE Workspaces/Default/ComponentEditorFilters/HW/Chip/Model_parameters\nREMOVE Workspaces/Default/ComponentEditorFilters/HW/Soc/Model_parameters\nREMOVE Workspaces/Default/ComponentEditorFilters/HW/IP/Model_parameters\nREMOVE Workspaces/Design/ComponentEditorFilters/HW/Flat/Model_parameters\nREMOVE Workspaces/Design/ComponentEditorFilters/HW/Product/Model_parameters\nREMOVE Workspaces/Design/ComponentEditorFilters/HW/Board/Model_parameters\nREMOVE Workspaces/Design/ComponentEditorFilters/HW/Chip/Model_parameters\nREMOVE Workspaces/Design/ComponentEditorFilters/HW/Soc/Model_parameters\nREMOVE Workspaces/Design/ComponentEditorFilters/HW/IP/Model_parameters\nADD Workspaces/Default/ComponentEditorFilters/HW/Flat/Instantiations Boolean true\nADD Workspaces/Default/ComponentEditorFilters/HW/Product/Instantiations Boolean true\nADD Workspaces/Default/ComponentEditorFilters/HW/Board/Instantiations Boolean true\nADD Workspaces/Default/ComponentEditorFilters/HW/Chip/Instantiations Boolean true\nADD Workspaces/Default/ComponentEditorFilters/HW/Soc/Instantiations Boolean true\nADD Workspaces/Default/ComponentEditorFilters/HW/IP/Instantiations Boolean true\nADD Workspaces/Design/ComponentEditorFilters/HW/Flat/Instantiations Boolean true\nADD Workspaces/Design/ComponentEditorFilters/HW/Product/Instantiations Boolean true\nADD Workspaces/Design/ComponentEditorFilters/HW/Board/Instantiations Boolean true\nADD Workspaces/Design/ComponentEditorFilters/HW/Chip/Instantiations Boolean true\nADD Workspaces/Design/ComponentEditorFilters/HW/Soc/Instantiations Boolean true\nADD Workspaces/Design/ComponentEditorFilters/HW/IP/Instantiations Boolean true\n\nVERSION 3.0.30.0\nADD Workspaces/Default/AdHocEditorVisibility Boolean true\nADD Workspaces/Design/AdHocEditorVisibility Boolean true\n\nVERSION 3.3.340.0\nADD Workspaces/Default/LibraryFilters/Type/ShowCatalogs Boolean true\nADD Workspaces/Design/LibraryFilters/Type/ShowCatalogs Boolean true\nADD Workspaces/Default/LibraryFilters/Type/ShowApis Boolean true\nADD Workspaces/Design/LibraryFilters/Type/ShowApis Boolean true\n\nVERSION 3.3.780.0\nADD Workspaces/Default/ComponentEditorFilters/HW/Flat/Instantiations Boolean true\nADD Workspaces/Default/ComponentEditorFilters/HW/Product/Instantiations Boolean true\nADD Workspaces/Default/ComponentEditorFilters/HW/Board/Instantiations Boolean true\nADD Workspaces/Default/ComponentEditorFilters/HW/Chip/Instantiations Boolean true\nADD Workspaces/Default/ComponentEditorFilters/HW/Soc/Instantiations Boolean true\nADD Workspaces/Default/ComponentEditorFilters/HW/IP/Instantiations Boolean true\nADD Workspaces/Design/ComponentEditorFilters/HW/Flat/Instantiations Boolean true\nADD Workspaces/Design/ComponentEditorFilters/HW/Product/Instantiations Boolean true\nADD Workspaces/Design/ComponentEditorFilters/HW/Board/Instantiations Boolean true\nADD Workspaces/Design/ComponentEditorFilters/HW/Chip/Instantiations Boolean true\nADD Workspaces/Design/ComponentEditorFilters/HW/Soc/Instantiations Boolean true\nADD Workspaces/Design/ComponentEditorFilters/HW/IP/Instantiations Boolean true\nADD Workspaces/Default/ComponentEditorFilters/SW/Instantiations Boolean true\nADD Workspaces/Design/ComponentEditorFilters/SW/Instantiations Boolean true\nADD Workspaces/Default/ComponentEditorFilters/HW/Flat/Views Boolean true\nADD Workspaces/Default/ComponentEditorFilters/HW/Product/Views Boolean true\nADD Workspaces/Default/ComponentEditorFilters/HW/Board/Views Boolean true\nADD Workspaces/Default/ComponentEditorFilters/HW/Chip/Views Boolean true\nADD Workspaces/Default/ComponentEditorFilters/HW/Soc/Views Boolean true\nADD Workspaces/Default/ComponentEditorFilters/HW/IP/Views Boolean true\nADD Workspaces/Design/ComponentEditorFilters/HW/Flat/Views Boolean true\nADD Workspaces/Design/ComponentEditorFilters/HW/Product/Views Boolean true\nADD Workspaces/Design/ComponentEditorFilters/HW/Board/Views Boolean true\nADD Workspaces/Design/ComponentEditorFilters/HW/Chip/Views Boolean true\nADD Workspaces/Design/ComponentEditorFilters/HW/Soc/Views Boolean true\nADD Workspaces/Design/ComponentEditorFilters/HW/IP/Views Boolean true\nADD Workspaces/Default/ComponentEditorFilters/HW/Flat/Channels Boolean true\nADD Workspaces/Default/ComponentEditorFilters/HW/Product/Channels Boolean true\nADD Workspaces/Default/ComponentEditorFilters/HW/Board/Channels Boolean true\nADD Workspaces/Default/ComponentEditorFilters/HW/Chip/Channels Boolean true\nADD Workspaces/Default/ComponentEditorFilters/HW/Soc/Channels Boolean true\nADD Workspaces/Default/ComponentEditorFilters/HW/IP/Channels Boolean true\nADD Workspaces/Design/ComponentEditorFilters/HW/Flat/Channels Boolean true\nADD Workspaces/Design/ComponentEditorFilters/HW/Product/Channels Boolean true\nADD Workspaces/Design/ComponentEditorFilters/HW/Board/Channels Boolean true\nADD Workspaces/Design/ComponentEditorFilters/HW/Chip/Channels Boolean true\nADD Workspaces/Design/ComponentEditorFilters/HW/Soc/Channels Boolean true\nADD Workspaces/Design/ComponentEditorFilters/HW/IP/Channels Boolean true\nADD Workspaces/Default/ComponentEditorFilters/HW/Flat/Remap_states Boolean true\nADD Workspaces/Default/ComponentEditorFilters/HW/Product/Remap_states Boolean true\nADD Workspaces/Default/ComponentEditorFilters/HW/Board/Remap_states Boolean true\nADD Workspaces/Default/ComponentEditorFilters/HW/Chip/Remap_states Boolean true\nADD Workspaces/Default/ComponentEditorFilters/HW/Soc/Remap_states Boolean true\nADD Workspaces/Default/ComponentEditorFilters/HW/IP/Remap_states Boolean true\nADD Workspaces/Design/ComponentEditorFilters/HW/Flat/Remap_states Boolean true\nADD Workspaces/Design/ComponentEditorFilters/HW/Product/Remap_states Boolean true\nADD Workspaces/Design/ComponentEditorFilters/HW/Board/Remap_states Boolean true\nADD Workspaces/Design/ComponentEditorFilters/HW/Chip/Remap_states Boolean true\nADD Workspaces/Design/ComponentEditorFilters/HW/Soc/Remap_states Boolean true\nADD Workspaces/Design/ComponentEditorFilters/HW/IP/Remap_states Boolean true\nADD Workspaces/Default/ComponentEditorFilters/SW/Views Boolean true\nADD Workspaces/Design/ComponentEditorFilters/SW/Views Boolean true\nREMOVE Workspaces/Default/ComponentEditorFilters/HW/Flat/Software_views\nREMOVE Workspaces/Default/ComponentEditorFilters/HW/Product/Software_views \nREMOVE Workspaces/Default/ComponentEditorFilters/HW/Board/Software_views\nREMOVE Workspaces/Default/ComponentEditorFilters/HW/Chip/Software_views\nREMOVE Workspaces/Default/ComponentEditorFilters/HW/Soc/Software_views\nREMOVE Workspaces/Default/ComponentEditorFilters/HW/IP/Software_views\nREMOVE Workspaces/Design/ComponentEditorFilters/HW/Flat/Software_views \nREMOVE Workspaces/Design/ComponentEditorFilters/HW/Product/Software_views\nREMOVE Workspaces/Design/ComponentEditorFilters/HW/Board/Software_views\nREMOVE Workspaces/Design/ComponentEditorFilters/HW/Chip/Software_views\nREMOVE Workspaces/Design/ComponentEditorFilters/HW/Soc/Software_views\nREMOVE Workspaces/Design/ComponentEditorFilters/HW/IP/Software_views\nREMOVE Workspaces/Default/ComponentEditorFilters/SW/Software_views\nREMOVE Workspaces/Design/ComponentEditorFilters/SW/Software_views\n\nVERSION 3.4.116.0\nADD Workspaces/Default/ComponentEditorFilters/HW/Flat/Indirect_interfaces Boolean true\nADD Workspaces/Default/ComponentEditorFilters/HW/Product/Indirect_interfaces Boolean true\nADD Workspaces/Default/ComponentEditorFilters/HW/Board/Indirect_interfaces Boolean true\nADD Workspaces/Default/ComponentEditorFilters/HW/Chip/Indirect_interfaces Boolean true\nADD Workspaces/Default/ComponentEditorFilters/HW/Soc/Indirect_interfaces Boolean true\nADD Workspaces/Default/ComponentEditorFilters/HW/IP/Indirect_interfaces Boolean true\nADD Workspaces/Design/ComponentEditorFilters/HW/Flat/Indirect_interfaces Boolean true\nADD Workspaces/Design/ComponentEditorFilters/HW/Product/Indirect_interfaces Boolean true\nADD Workspaces/Design/ComponentEditorFilters/HW/Board/Indirect_interfaces Boolean true\nADD Workspaces/Design/ComponentEditorFilters/HW/Chip/Indirect_interfaces Boolean true\nADD Workspaces/Design/ComponentEditorFilters/HW/Soc/Indirect_interfaces Boolean true\nADD Workspaces/Design/ComponentEditorFilters/HW/IP/Indirect_interfaces Boolean true\n\nVERSION 3.6.120.0\nADD Workspaces/Default/VendorExtensionVisibility Boolean false\nADD Workspaces/Design/VendorExtensionVisibility Boolean false\n\nVERSION 3.6.180.0\nADD Workspaces/Default/ComponentEditorFilters/HW/Flat/Reset_types Boolean true\nADD Workspaces/Default/ComponentEditorFilters/HW/Product/Reset_types Boolean true\nADD Workspaces/Default/ComponentEditorFilters/HW/Board/Reset_types Boolean true\nADD Workspaces/Default/ComponentEditorFilters/HW/Chip/Reset_types Boolean true\nADD Workspaces/Default/ComponentEditorFilters/HW/Soc/Reset_types Boolean true\nADD Workspaces/Default/ComponentEditorFilters/HW/IP/Reset_types Boolean true\nADD Workspaces/Design/ComponentEditorFilters/HW/Flat/Reset_types Boolean true\nADD Workspaces/Design/ComponentEditorFilters/HW/Product/Reset_types Boolean true\nADD Workspaces/Design/ComponentEditorFilters/HW/Board/Reset_types Boolean true\nADD Workspaces/Design/ComponentEditorFilters/HW/Chip/Reset_types Boolean true\nADD Workspaces/Design/ComponentEditorFilters/HW/Soc/Reset_types Boolean true\nADD Workspaces/Design/ComponentEditorFilters/HW/IP/Reset_types Boolean true\n\nVERSION 3.8.595\nADD Workspaces/Default/ScriptVisibility Boolean true\nADD Workspaces/Design/ScriptVisibility Boolean true\n\nVERSION 3.9.571.0\nREMOVE General/showExitScreen\n\nVERSION 3.11.269.0\nREMOVE Workspaces/Default/AdHocVisibility\nREMOVE Workspaces/Design/AdHocVisibility\n\nVERSION 3.11.355.0\nREMOVE Workspaces/Default/PreviewVisibility\nREMOVE Workspaces/Design/PreviewVisibility\n\nVERSION 3.11.392.0\nADD PreviewWidget/Hidden Boolean false\n\nVERSION 3.11.422.0\nREMOVE Workspaces/Default/ScriptVisibility\nREMOVE Workspaces/Design/ScriptVisibility\n\nVERSION 3.12.24.0\nADD FileTypes/vhdlSource2002 String vhdl;vhd\nADD FileTypes/vhdlSource2008 String vhdl;vhd\nADD FileTypes/systemVerilogSource-2009 String sv\nADD FileTypes/systemVerilogSource-2012 String sv\nADD FileTypes/systemVerilogSource-2017 String sv\nADD FileTypes/vhdlAmsSource String\nADD FileTypes/verilogAmsSource String\nADD FileTypes/systemCAmsSource String\nADD FileTypes/libertySource String\nADD FileTypes/spiceSource String\nADD FileTypes/systemRDL String\nADD FileTypes/systemRDL-1.0 String\nADD FileTypes/systemRDL-2.0 String\nADD FileTypes/systemCSource-2.3 String\nADD FileTypes/systemCSourceBinaryLibrary String\n\nVERSION 3.12.102.0\nADD General/Revision String 1685-2022\n\nVERSION 3.12.672.0\nADD Workspaces/Default/LibraryFilters/Validity/ShowValid Boolean true\nADD Workspaces/Default/LibraryFilters/Validity/ShowErrors Boolean true\nADD Workspaces/Design/LibraryFilters/Validity/ShowValid Boolean true\nADD Workspaces/Design/LibraryFilters/Validity/ShowErrors Boolean true\n\nVERSION 3.12.1134.0\nADD Workspaces/Default/LibraryFilters/Revision/ShowStd14 Boolean true\nADD Workspaces/Default/LibraryFilters/Revision/ShowStd22 Boolean true\nADD Workspaces/Design/LibraryFilters/Revision/ShowStd14 Boolean true\nADD Workspaces/Design/LibraryFilters/Revision/ShowStd22 Boolean true\n\nVERSION 3.13.79\nADD General/EditorLocking Boolean false\n\nVERSION 3.13.525.0\nADD Workspaces/Default/ComponentEditorFilters/HW/Flat/Power_domains Boolean true\nADD Workspaces/Default/ComponentEditorFilters/HW/Product/Power_domains Boolean true\nADD Workspaces/Default/ComponentEditorFilters/HW/Board/Power_domains Boolean true\nADD Workspaces/Default/ComponentEditorFilters/HW/Chip/Power_domains Boolean true\nADD Workspaces/Default/ComponentEditorFilters/HW/Soc/Power_domains Boolean true\nADD Workspaces/Default/ComponentEditorFilters/HW/IP/Power_domains Boolean true\nADD Workspaces/Design/ComponentEditorFilters/HW/Flat/Power_domains Boolean true\nADD Workspaces/Design/ComponentEditorFilters/HW/Product/Power_domains Boolean true\nADD Workspaces/Design/ComponentEditorFilters/HW/Board/Power_domains Boolean true\nADD Workspaces/Design/ComponentEditorFilters/HW/Chip/Power_domains Boolean true\nADD Workspaces/Design/ComponentEditorFilters/HW/Soc/Power_domains Boolean true\nADD Workspaces/Design/ComponentEditorFilters/HW/IP/Power_domains Boolean true\n\nADD Workspaces/Default/ComponentEditorFilters/HW/Flat/Modes Boolean true\nADD Workspaces/Default/ComponentEditorFilters/HW/Product/Modes Boolean true\nADD Workspaces/Default/ComponentEditorFilters/HW/Board/Modes Boolean true\nADD Workspaces/Default/ComponentEditorFilters/HW/Chip/Modes Boolean true\nADD Workspaces/Default/ComponentEditorFilters/HW/Soc/Modes Boolean true\nADD Workspaces/Default/ComponentEditorFilters/HW/IP/Modes Boolean true\nADD Workspaces/Design/ComponentEditorFilters/HW/Flat/Modes Boolean true\nADD Workspaces/Design/ComponentEditorFilters/HW/Product/Modes Boolean true\nADD Workspaces/Design/ComponentEditorFilters/HW/Board/Modes Boolean true\nADD Workspaces/Design/ComponentEditorFilters/HW/Chip/Modes Boolean true\nADD Workspaces/Design/ComponentEditorFilters/HW/Soc/Modes Boolean true\nADD Workspaces/Design/ComponentEditorFilters/HW/IP/Modes Boolean true\n\nADD Workspaces/Default/ComponentEditorFilters/HW/Flat/Type_definitions Boolean true\nADD Workspaces/Default/ComponentEditorFilters/HW/Product/Type_definitions Boolean true\nADD Workspaces/Default/ComponentEditorFilters/HW/Board/Type_definitions Boolean true\nADD Workspaces/Default/ComponentEditorFilters/HW/Chip/Type_definitions Boolean true\nADD Workspaces/Default/ComponentEditorFilters/HW/Soc/Type_definitions Boolean true\nADD Workspaces/Default/ComponentEditorFilters/HW/IP/Type_definitions Boolean true\nADD Workspaces/Design/ComponentEditorFilters/HW/Flat/Type_definitions Boolean true\nADD Workspaces/Design/ComponentEditorFilters/HW/Product/Type_definitions Boolean true\nADD Workspaces/Design/ComponentEditorFilters/HW/Board/Type_definitions Boolean true\nADD Workspaces/Design/ComponentEditorFilters/HW/Chip/Type_definitions Boolean true\nADD Workspaces/Design/ComponentEditorFilters/HW/Soc/Type_definitions Boolean true\nADD Workspaces/Design/ComponentEditorFilters/HW/IP/Type_definitions Boolean true"
  },
  {
    "path": "CreateHelp.bat",
    "content": "REM\r\nREM Bind HTML pages to context helps. If you modify help texts, you\r\nREM don't need recompilation, if you run this script.\r\nREM Joni-Matti Määttä, Aug 2012\r\nREM\r\n@echo off\r\nqhelpgenerator Help/kactus2help.qhcp -o Help/Kactus2Help.qhc\r\nxcopy /Y Help\\Kactus2Help.qhc executable\\Help\\\r\nxcopy /Y Help\\Kactus2Help.qch executable\\Help\\"
  },
  {
    "path": "Help/HelpSystem/ContextHelpBrowser.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ContextHelpBrowser.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Joni-Matti Maatta\r\n// Date: 6.8.2012\r\n//\r\n// Description:\r\n// Context help browser.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"ContextHelpBrowser.h\"\r\n\r\n#include <QHelpContentWidget>\r\n#include <QCoreApplication>\r\n#include <QDesktopServices>\r\n#include <QApplication>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ContextHelpBrowser::ContextHelpBrowser()\r\n//-----------------------------------------------------------------------------\r\nContextHelpBrowser::ContextHelpBrowser(QHelpEngine* engine,QString const& urlPrefix, QWidget* parent):\r\nQTextBrowser(parent),\r\n    engine_(engine),\r\n    urlPrefix_(urlPrefix)\r\n{\r\n    \r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ContextHelpBrowser::~ContextHelpBrowser()\r\n//-----------------------------------------------------------------------------\r\nContextHelpBrowser::~ContextHelpBrowser()\r\n{\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ContextHelpBrowser::loadResource()\r\n//-----------------------------------------------------------------------------\r\nQVariant ContextHelpBrowser::loadResource(int type, QUrl const& url)\r\n{\r\n    if (url.scheme() == \"qthelp\")\r\n    {\r\n        return QVariant(engine_->fileData(url));\r\n    }\r\n    else\r\n    {\r\n        return QTextBrowser::loadResource(type, url);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ContextHelpBrowser::setSource()\r\n//-----------------------------------------------------------------------------\r\nvoid ContextHelpBrowser::setSource(QUrl const& url)\r\n{\r\n    if (url.scheme() == \"http\" || url.scheme() == \"https\")\r\n    {\r\n        QDesktopServices::openUrl(url);\r\n    }\r\n    else\r\n    {\r\n        QTextBrowser::setSource(url);\r\n    }    \r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ContextHelpBrowser::onHelpRequested()\r\n//-----------------------------------------------------------------------------\r\nvoid ContextHelpBrowser::onHelpRequested(QString const& url)\r\n{\r\n    setSource(QUrl(urlPrefix_ + \"/\" + url));\r\n}\r\n"
  },
  {
    "path": "Help/HelpSystem/ContextHelpBrowser.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ContextHelpBrowser.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Joni-Matti Maatta\r\n// Date: 6.8.2012\r\n//\r\n// Description:\r\n// Context help browser.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef CONTEXTHELPBROWSER_H\r\n#define CONTEXTHELPBROWSER_H\r\n\r\n#include <QHelpEngine>\r\n#include <QTextBrowser>\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Context-based help browser.\r\n//-----------------------------------------------------------------------------\r\nclass ContextHelpBrowser : public QTextBrowser\r\n{\r\n    Q_OBJECT\r\n\r\npublic:\r\n    /*!\r\n     *  Constructor.\r\n     *\r\n     *    @param [in] engine     The help engine containing the documentation.\r\n     *    @param [in] urlPrefix  A prefix used automatically for all URLs.\r\n     *    @param [in] parent     The parent widget.\r\n     */\r\n    ContextHelpBrowser(QHelpEngine* engine, QString const& urlPrefix, QWidget* parent = 0);\r\n\r\n    /*!\r\n     *  Destructor.\r\n     */\r\n    virtual ~ContextHelpBrowser();\r\n\r\n    /*!\r\n     *  Loads the resource at the given URL.\r\n     */\r\n    virtual QVariant loadResource(int type, QUrl const& url);\r\n\r\n    /*!\r\n     *  Sets the content for the browser.\r\n     *\r\n     *    @param [in] url   The url to the content to set.\r\n     */\r\n    virtual void setSource(QUrl const& url);\r\n\r\npublic slots:\r\n    /*!\r\n     *  Shows the given help page.\r\n     *\r\n     *    @param [in] url The URL of the page to show. This will be appended to the given URL prefix.\r\n     */\r\n    void onHelpRequested(QString const& url);\r\n\r\nprivate:\r\n    // Disable copying.\r\n    ContextHelpBrowser(ContextHelpBrowser const& rhs);\r\n    ContextHelpBrowser& operator=(ContextHelpBrowser const& rhs);\r\n\r\n\r\n    //! The help engine.\r\n    QHelpEngine* engine_;\r\n\r\n    //! The URL prefix.\r\n    QString urlPrefix_;\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n\r\n#endif // CONTEXTHELPBROWSER_H\r\n"
  },
  {
    "path": "Help/HelpSystem/HelpSearchWidget.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: HelpSearchWidget.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Joni-Matti Maatta\r\n// Date: 8.8.2012\r\n//\r\n// Description:\r\n// Help search widget.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"HelpSearchWidget.h\"\r\n\r\n#include <QVBoxLayout>\r\n#include <QHelpSearchQueryWidget>\r\n#include <QHelpSearchResultWidget>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HelpSearchWidget::HelpSearchWidget()\r\n//-----------------------------------------------------------------------------\r\nHelpSearchWidget::HelpSearchWidget(QHelpSearchEngine* searchEngine, QWidget* parent /*= 0*/)\r\n    : QWidget(parent),\r\n      searchEngine_(searchEngine)\r\n{\r\n    QVBoxLayout* layout = new QVBoxLayout(this);\r\n    layout->addWidget(searchEngine->queryWidget());\r\n    layout->addWidget(searchEngine->resultWidget(), 1);\r\n\r\n    connect(searchEngine->queryWidget(), SIGNAL(search()), this, SLOT(onSearch()), Qt::UniqueConnection);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HelpSearchWidget::~HelpSearchWidget()\r\n//-----------------------------------------------------------------------------\r\nHelpSearchWidget::~HelpSearchWidget()\r\n{\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HelpSearchWidget::onSearch()\r\n//-----------------------------------------------------------------------------\r\nvoid HelpSearchWidget::onSearch()\r\n{\r\n    auto query = searchEngine_->queryWidget()->searchInput();\r\n    searchEngine_->search(query);\r\n}\r\n"
  },
  {
    "path": "Help/HelpSystem/HelpSearchWidget.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: HelpSearchWidget.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Joni-Matti Maatta\r\n// Date: 8.8.2012\r\n//\r\n// Description:\r\n// Help search widget.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef HELPSEARCHWIDGET_H\r\n#define HELPSEARCHWIDGET_H\r\n\r\n#include <QHelpSearchEngine>\r\n#include <QWidget>\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Help search widget.\r\n//-----------------------------------------------------------------------------\r\nclass HelpSearchWidget : public QWidget\r\n{\r\n    Q_OBJECT\r\n\r\npublic:\r\n    /*!\r\n     *  Constructor.\r\n     */\r\n    HelpSearchWidget(QHelpSearchEngine* searchEngine, QWidget* parent = 0);\r\n\r\n    /*!\r\n     *  Destructor.\r\n     */\r\n    ~HelpSearchWidget();\r\n\r\nprivate slots:\r\n    void onSearch();\r\n\r\nprivate:\r\n    // Disable copying.\r\n    HelpSearchWidget(HelpSearchWidget const& rhs);\r\n    HelpSearchWidget& operator=(HelpSearchWidget const& rhs);\r\n    \r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! The help search engine.\r\n    QHelpSearchEngine* searchEngine_;\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n\r\n#endif // HELPSEARCHWIDGET_H\r\n"
  },
  {
    "path": "Help/HelpSystem/HelpWindow.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: HelpWindow.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Joni-Matti Maatta\r\n// Date: 7.8.2012\r\n//\r\n// Description:\r\n// Help window that allows browsing the documentation through table of\r\n// contents and index.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"HelpWindow.h\"\r\n\r\n#include \"ContextHelpBrowser.h\"\r\n#include \"HelpSearchWidget.h\"\r\n\r\n#include <QHelpContentWidget>\r\n#include <QHelpIndexWidget>\r\n#include <QHelpSearchQueryWidget>\r\n#include <QHelpSearchResultWidget>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HelpWindow::HelpWindow()\r\n//-----------------------------------------------------------------------------\r\nHelpWindow::HelpWindow(QHelpEngine* engine, QWidget* parent): QMainWindow(parent),\r\n    engine_(engine),\r\n    menu_(new QMenuBar(this)),\r\n    tocDock_(new QDockWidget(tr(\"Contents\"), this)),\r\n    browser_(new ContextHelpBrowser(engine, \"qthelp://fi.tuni.kactus2/doc\", this))\r\n{\r\n    setWindowTitle(tr(\"Kactus2 Help\"));\r\n    resize(800, 500);\r\n\r\n    // Create the menu bar and all its menus and actions.\r\n    QMenu* fileMenu = menu_->addMenu(tr(\"File\"));\r\n    fileMenu->addAction(tr(\"Close\"), this, SLOT(close()));\r\n\r\n    setMenuBar(menu_);\r\n\r\n    // Add the table of contents dock.\r\n    tocDock_->setWidget(engine_->contentWidget());\r\n    tocDock_->setFeatures(QDockWidget::NoDockWidgetFeatures);\r\n    addDockWidget(Qt::LeftDockWidgetArea, tocDock_);\r\n\r\n    setCentralWidget(browser_);\r\n    setCorner(Qt::TopLeftCorner, Qt::LeftDockWidgetArea);\r\n\r\n    connect(engine_->indexWidget(), SIGNAL(linkActivated(QUrl const&, QString const&)),\r\n            browser_, SLOT(setSource(QUrl const&)), Qt::UniqueConnection);\r\n\r\n    connect(engine_->contentWidget(), SIGNAL(linkActivated(QUrl const&)),\r\n            browser_, SLOT(setSource(QUrl const&)), Qt::UniqueConnection);\r\n\r\n    connect(engine_->searchEngine()->resultWidget(), SIGNAL(requestShowLink(QUrl const&)),\r\n            browser_, SLOT(setSource(QUrl const&)), Qt::UniqueConnection);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HelpWindow::~HelpWindow()\r\n//-----------------------------------------------------------------------------\r\nHelpWindow::~HelpWindow()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HelpWindow::showEvent()\r\n//-----------------------------------------------------------------------------\r\nvoid HelpWindow::showEvent(QShowEvent* /*event*/)\r\n{\r\n    browser_->onHelpRequested(\"index.html\");\r\n    engine_->contentWidget()->expandToDepth(0);\r\n}\r\n"
  },
  {
    "path": "Help/HelpSystem/HelpWindow.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: HelpWindow.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Joni-Matti Maatta\r\n// Date: 7.8.2012\r\n//\r\n// Description:\r\n// Help window that allows browsing the documentation through table of\r\n// contents and index.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef HELPWINDOW_H\r\n#define HELPWINDOW_H\r\n\r\n#include <QHelpEngine>\r\n#include <QDockWidget>\r\n#include <QMainWindow>\r\n#include <QMenuBar>\r\n\r\nclass ContextHelpBrowser;\r\nclass HelpSearchWidget;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Help window that allows browsing the documentation through table of\r\n//! contents and index.\r\n//-----------------------------------------------------------------------------\r\nclass HelpWindow : public QMainWindow\r\n{\r\npublic:\r\n    /*!\r\n     *  Constructor.\r\n     *\r\n     *    @param [in] engine  The help engine.\r\n     *    @param [in] parent  The parent widget.\r\n     */\r\n    HelpWindow(QHelpEngine* engine, QWidget* parent = 0);\r\n\r\n    /*!\r\n     *  Destructor.\r\n     */\r\n    ~HelpWindow();\r\n\r\nprotected:\r\n    virtual void showEvent(QShowEvent* event);\r\n\r\nprivate:\r\n    // Disable copying.\r\n    HelpWindow(HelpWindow const& rhs);\r\n    HelpWindow& operator=(HelpWindow const& rhs);\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! The used help engine.\r\n    QHelpEngine* engine_;\r\n\r\n    //! The menu bar for the help window.\r\n    QMenuBar* menu_;\r\n\r\n    //! Dock widget for table of contents.\r\n    QDockWidget* tocDock_;\r\n\r\n    //! The help browser.\r\n    ContextHelpBrowser* browser_;\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n\r\n#endif // HELPWINDOW_H\r\n"
  },
  {
    "path": "Help/communityGuideLines.html",
    "content": "<html>\r\n<head>\r\n    <link href=\"style.css\" rel=\"stylesheet\" type=\"text/css\">\r\n</head>\r\n<body>\r\n    <h2>Community Guidelines</h2>\r\n    <p>\r\n        Issues should be reported at Kactus2 project Github\r\n\t\t<a href=\"https://github.com/kactus2/kactus2dev\">https://github.com/kactus2/kactus2dev</a>\r\n    </p>\r\n    <p>\r\n        Otherwise support is provided by email: kactus2@tuni.fi\r\n    </p>\r\n    <p>\r\n    When contributing to Kactus2, you should see the wiki at the project management site.\r\n    It will guide on essentials like building with Visual Studio and plugin development.\r\n    Contributions to Kactus2 core, the IP-XACTmodels library, and the plugins provided by Tampere University will not make to\r\n    a release unless we accept them and you agree to transfer the copyrights of the changes to Tampere University.\r\n    </p>\r\n     <p>When creating a plugin, you may keep it closed or open source, and the copyright stays with you.</p>\r\n</body>\r\n</html>\r\n"
  },
  {
    "path": "Help/componenteditor/addressblock.html",
    "content": "﻿<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01//EN\" \"http://www.w3.org/TR/html4/strict.dtd\">\n<html>\n<head>\n    <meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">\n    <link href=\"../style.css\" rel=\"Stylesheet\" type=\"text/css\">\n    <title>Address block editor</title>\n</head>\n<body>\n    <h2>Address block editor</h2>\n    <p>\n        Address block editor is used to edit the details of an address block and the registers\n        contained within it.\n    </p>\n    <p>\n        <b>Name</b> is a mandatory identifier for the <i>address block</i>. The name must\n        be unique within all the <i>address blocks</i> of the containing <i>memory map</i>.\n    </p>\n    <p>\n        <b>Display name</b> is an optional and used for a more user-friendly identifier.\n    </p>\n    <p>\n        <b>Description</b> is an optional field for textual description of the <i>address block</i>.\n    </p>\n    <p>\n        <b>Base address</b> is mandatory and specifies the starting address for the <i>address\n            block</i> in address unit bits.\n    </p>\n    <p>\n        <b>Range</b> is mandatory and specifies the size of the block in <i>address units bits</i>.\n    </p>\n    <p>\n        <b>Width</b> is mandatory and defines the data width of a row in the <i>address block</i>.\n        The width value is given in bits.\n    </p>\n\n\t<p>\n        <b>Is present</b> is optional and allows enabling/disabling of a <i>address block</i>\n        presence in a <i>memory map</i>. Value 1 indicates that the <i>address block</i>\n        is present in the <i>memory map</i> whereas value 0 marks the address block to be\n        treated as if it does not exist. Is present can be given as a SystemVerilog expression,\n        but it must evaluate to 1 or 0.</p>\n\t<p>\n\n    <p>\n        <b>Usage</b> is a mandatory value to specify the usage of the address block and\n        may have one of the following values:\n    </p>\n    <ul>\n        <li><b>Memory</b> The <i>address block</i> is ROM, RAM or write-only memory as defined\n            by <b>access</b>. Registers and register files within will be considered virtual.</li>\n        <li><b>Register</b> The <i>address block</i> range may contain registers.</li>\n        <li><b>Reserved</b> The <i>address block</i> is reserved for other usage and shall not\n            contain registers or register files. </li>\n    </ul>\n    <p>\n        <b>Access</b> is optional and specifies the accessability of the address block.\n        The possible values are:\n    </p>\n    <ul>\n        <li><b>read-write</b>. Both read and write transactions may have an effect on this <i>\n            address block</i>.</li>\n        <li><b>read-only</b>. Only read transactions are allowed in this <i>address block</i>.</li>\n        <li><b>write-only</b>. Only write transactions are allowed in this <i>address block</i>.</li>\n        <li><b>read-writeOnce</b>. Read actions and the first write action may have an effect\n            on this <i>address block</i>.</li>\n        <li><b>writeOnce</b>. Only the first write action affects the contents of this <i>address\n            block</i>.</li>\n    </ul>\n    <p>\n        <b>Volatile</b> is optional and indicates whether the stored value may change without\n        the master's write operation or not.\n    </p>\n\n    <h3>Registers table</h3>\n    <p>\n        The register table enables the user to define <i>registers</i> for the <i>address block</i>,\n        with each row representing a single register. Each register must also contain at\n        least one bit <i>field</i>.\n    </p>\n\n    <p>\n        <b>Name</b> is a mandatory identifier for the <i>register</i>.</p>\n    <p>\n        <b>Offset</b> is mandatory and specifies the location of the <i>register</i> from\n        the start of the containing <i>address block</i> expressed as number of addressing\n        units. The actual address of the <i>register</i> is the sum of <i>address block</i>'s\n        base address and the <i>register</i> offset. E.g. if the base address is 'h100 and\n        the register offset is 'h4, the register's address is 'h104. Offset can be given\n        as a SystemVerilog expression.\n    </p>\n    <p>\n        <b>Size</b> is mandatory and defines the number of data bits the <i>register</i>\n        contains. Size must be less than or equal to the width of the containing <i>address\n            block</i>.\n    </p>\n    <p>\n        <b>Dimension</b> is optional and assigns an array dimension to the <i>register</i>.\n        The <i>register</i> will be repeated in the <i>address block</i> as many times as\n        indicated by the dimension value. By default, the dimension is presumed to be 0.\n        Dimension 0 means that the <i>register</i> is not an array and will appear exactly\n        once.\n    </p>\n    <p>\n        <b>Volatile</b> is optional and indicates whether the <i>register</i> value may\n        change without a write operation to it, i.e. by an interrupt event, or not.\n    </p>\n    <p>\n        <b>Access</b> is optional and specifies the accessibility of the <i>register</i>.\n        The possible values are:\n    </p>\n    <ul>\n        <li><b>read-write</b>. Both read and write transactions may have an effect on this <i>\n            register</i>.</li>\n        <li><b>read-only</b>. Only read transactions are allowed in this <i>register</i>.</li>\n        <li><b>write-only</b>. Only write transactions are allowed in this <i>register</i>.</li>\n        <li><b>read-writeOnce</b>. Both read and write transactions may have an effect on this\n            <i>register</i>. Only the first write transaction, after an event that caused the\n            reset value of the <i>register</i> to be loaded, may affet the contents of the <i>register</i>,\n            and read transactions return a value related to the values in the <i>register</i>.</li>\n        <li><b>writeOnce</b>. Only the first write transaction affects the contents of the <i>\n            register</i>.</li>\n    </ul>\n    <p>\n        <b>Is present</b> is optional and allows enabling/disabling of a <i>register</i>\n        presence in an <i>address block</i>. Value 1 indicates that the <i>register</i>\n        is present in the <i>address block</i> whereas value 0 marks the register to be\n        treated as if it does not exist. Is present can be given as a SystemVerilog expression,\n        but it must evaluate to 1 or 0.</p>\n    <p>\n        <b>Description</b> is an optional field for textual description of the <i>register</i>.\n    </p>\n\n\t<h3>Register files table</h3>\n    <p>\n        The register files table enables the user to define <i>register files</i> for the\n\t\t<i>address block</i> where each row represents a single register file.\n\t\tRegister files are used to group together <i>registers</i>.\n    </p>\n\n    <p>\n        <b>Name</b> is a mandatory identifier for the <i>register file</i>.</p>\n    <p>\n        <b>Offset</b> is mandatory and specifies the location of the <i>register file</i> from\n        the start of the containing <i>address block</i> expressed as number of addressing\n        units. Offset can be given as a SystemVerilog expression.\n    </p>\n    <p>\n\t   <b>Range</b> is mandatory and specifies the size of the <i>register file</i> in address\n\t   unit bits.\n    </p>\n    <p>\n        <b>Dimension</b> is optional and assigns an array dimension to the <i>register file</i>.\n        The <i>register file</i> will be repeated in the <i>address block</i> as many times as\n        indicated by the dimension value. By default, the dimension is presumed to be 0.\n        Dimension 0 means that the <i>register file</i> is not an array and will appear exactly\n        once.\n    </p>\n\n\t<p>\n        <b>Is present</b> is optional and allows enabling/disabling of a <i>register file</i>\n        presence in an <i>address block</i>. Value 1 indicates that the <i>register file</i>\n        is present in the <i>address block</i> whereas value 0 marks the register to be\n        treated as if it does not exist. Is present can be given as a SystemVerilog expression,\n        but it must evaluate to 1 or 0.</p>\n    <p>\n        <b>Description</b> is an optional field for textual description of the <i>register file</i>.\n    </p>\n</body>\n</html>\n"
  },
  {
    "path": "Help/componenteditor/addressblock2022.html",
    "content": "﻿<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01//EN\" \"http://www.w3.org/TR/html4/strict.dtd\">\n<html>\n<head>\n    <meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">\n    <link href=\"../style.css\" rel=\"Stylesheet\" type=\"text/css\">\n    <title>Address block editor</title>\n</head>\n<body>\n    <h2>Address block editor</h2>\n    <p>\n        Address block editor is used to edit the details of an address block and the registers\n        contained within it.\n    </p>\n    <p>\n        <b>Name</b> is a mandatory identifier for the <i>address block</i>. The name must\n        be unique within all the <i>address blocks</i> of the containing <i>memory map</i>.\n    </p>\n    <p>\n        <b>Display name</b> is an optional and used for a more user-friendly identifier.\n    </p>\n    <p>\n        <b>Short description</b> is an optional field for compact description of the <i>address block</i>.\n    </p>\n    <p>\n        <b>Description</b> is an optional field for textual description of the <i>address block</i>.\n    </p>\n    <p>\n        <b>Base address</b> is mandatory and specifies the starting address for the <i>address\n            block</i> in address unit bits.\n    </p>\n    <p>\n        <b>Range</b> is mandatory and specifies the size of the block in <i>address units bits</i>.\n    </p>\n    <p>\n        <b>Width</b> is mandatory and defines the data width of a row in the <i>address block</i>.\n        The width value is given in bits.\n    </p>\n\n    <p>\n        <b>Usage</b> is a mandatory value to specify the usage of the address block and\n        may have one of the following values:\n    </p>\n    <ul>\n        <li>\n            <b>Memory</b> The <i>address block</i> is ROM, RAM or write-only memory as defined\n            by <b>access policies</b>. Registers and register files within will be considered virtual.\n        </li>\n        <li>\n            <b>Register</b> The <i>address block</i> range may contain registers.\n        </li>\n        <li>\n            <b>Reserved</b> The <i>address block</i> is reserved for other usage and shall not\n            contain registers or register files.\n        </li>\n    </ul>\n    \n    <p>\n        <b>Volatile</b> is optional and indicates whether the stored value may change without\n        the master's write operation or not.\n    </p>\n    \n    <p>\n        <b>Access policies</b> are optional and specify the accessability of the address block data for different operating modes,\n        specified by mode references. If no mode reference is present, then the access policy applies to all modes not already \n        referenced by other access policies (i.e. only one access policy without mode references may exist).\n        \n        The possible access values for an access policy are:\n    </p>\n    <ul>\n        <li>\n            <b>read-write</b>. Both read and write transactions may have an effect on this <i>\n            address block</i>.\n        </li>\n        <li>\n            <b>read-only</b>. Only read transactions are allowed in this <i>address block</i>.\n        </li>\n        <li>\n            <b>write-only</b>. Only write transactions are allowed in this <i>address block</i>.\n        </li>\n        <li>\n            <b>read-writeOnce</b>. Read actions and the first write action may have an effect\n            on this <i>address block</i>.\n        </li>\n        <li>\n            <b>writeOnce</b>. Only the first write action affects the contents of this <i>address\n            block</i>.\n        </li>\n    </ul>\n\n    <h3>Registers table</h3>\n    <p>\n        The register table enables the user to define <i>registers</i> for the <i>address block</i>,\n        with each row representing a single register. Each register must also contain at\n        least one bit <i>field</i>.\n    </p>\n\n    <p>\n        <b>Name</b> is a mandatory identifier for the <i>register</i>.</p>\n    <p>\n        <b>Offset</b> is mandatory and specifies the location of the <i>register</i> from\n        the start of the containing <i>address block</i> expressed as number of addressing\n        units. The actual address of the <i>register</i> is the sum of <i>address block</i>'s\n        base address and the <i>register</i> offset. E.g. if the base address is 'h100 and\n        the register offset is 'h4, the register's address is 'h104. Offset can be given\n        as a SystemVerilog expression.\n    </p>\n    <p>\n        <b>Size</b> is mandatory and defines the number of data bits the <i>register</i>\n        contains. Size must be less than or equal to the width of the containing <i>address block</i>.\n    </p>\n    <p>\n        <b>Dimension</b> is optional and assigns an array dimension to the <i>register</i>.\n        The <i>register</i> will be repeated in the <i>address block</i> as many times as\n        indicated by the dimension value. If empty (default) or 1, the register will appear\n        exactly once.\n    </p>\n    <p>\n        <b>Volatile</b> is optional and indicates whether the <i>register</i> value may\n        change without a write operation to it, i.e. by an interrupt event, or not.\n    </p>\n    <p>\n        <b>Access</b> is optional and specifies the accessibility of the <i>register</i> by modifying\n        the first access policy of the register. If multiple <i>access policies</i> exist, then the access value \n        cannot be edited here and must be edited for each access policy separately in the register editor. \n        If no access policy exists, then one will be created for the register when the access is edited here.\n\n        The possible access values are:\n    </p>\n    <ul>\n        <li><b>read-write</b>. Both read and write transactions may have an effect on this <i>\n            register</i>.</li>\n        <li><b>read-only</b>. Only read transactions are allowed in this <i>register</i>.</li>\n        <li><b>write-only</b>. Only write transactions are allowed in this <i>register</i>.</li>\n        <li><b>read-writeOnce</b>. Both read and write transactions may have an effect on this\n            <i>register</i>. Only the first write transaction, after an event that caused the\n            reset value of the <i>register</i> to be loaded, may affet the contents of the <i>register</i>,\n            and read transactions return a value related to the values in the <i>register</i>.</li>\n        <li><b>writeOnce</b>. Only the first write transaction affects the contents of the <i>\n            register</i>.</li>\n    </ul>\n\n    <p>\n        <b>Description</b> is an optional field for textual description of the <i>register</i>.\n    </p>\n\n\t<h3>Register files table</h3>\n    <p>\n        The register files table enables the user to define <i>register files</i> for the\n\t\t<i>address block</i> where each row represents a single register file.\n\t\tRegister files are used to group together <i>registers</i>.\n    </p>\n\n    <p>\n        <b>Name</b> is a mandatory identifier for the <i>register file</i>.</p>\n    <p>\n        <b>Offset</b> is mandatory and specifies the location of the <i>register file</i> from\n        the start of the containing <i>address block</i> expressed as number of addressing\n        units. Offset can be given as a SystemVerilog expression.\n    </p>\n    <p>\n\t   <b>Range</b> is mandatory and specifies the size of the <i>register file</i> in address\n\t   unit bits.\n    </p>\n    <p>\n        <b>Dimension</b> is optional and assigns an array dimension to the <i>register file</i>.\n        The <i>register file</i> will be repeated in the <i>address block</i> as many times as\n        indicated by the dimension value. If empty (default) or 1, the register file will appear\n        exactly once.\n    </p>\n\n    <p>\n        <b>Description</b> is an optional field for textual description of the <i>register file</i>.\n    </p>\n</body>\n</html>\n"
  },
  {
    "path": "Help/componenteditor/addressspace.html",
    "content": "﻿<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01//EN\" \"http://www.w3.org/TR/html4/strict.dtd\">\n<html>\n  <head>\n    <meta http-equiv=\"Content-Type\"content=\"text/html; charset=utf-8\">\n    <link href=\"../style.css\" rel=\"Stylesheet\" type=\"text/css\">\n    <title>Address space editor</title>\n  </head>\n  <body>\n    <h2>Address space editor</h2>\n    <p>\n      Address space editor can be used to edit the details of an\n      address space within component.  <i>Address space</i> defines a\n      logical address space seen by a master <i>bus interface</i>. It can be\n      split into smaller <i>sgements</i>.\n    </p>\n    <p>\n      On the left side are the editor fields that can be used to set\n      the details of an address space. The right side contains a\n      visualization displaying the address space in its current state and\n\t  automatically updates on changes.\n\t  It displays how the segments are positioned within the address space. \n\t  Mismatches, e.g. sum of segment ranges being greater than address block range, can \n      be easily spotted from the visualization.\n    </p>\n\t<p>\n\t    <b>Name</b> is a mandatory identifier for the <i>address space</i>.\n    </p>\n    <p>\n        <b>Display name</b> is an optional and used for a more user-friendly identifier.\n    </p>\n    <p>\n        <b>Description</b> is an optional field for textual description of the <i>address space</i>.\t\t\n    </p>\n    <p>\n        <b>Addressable unit bits</b> (AUB) specifies the number of bits each address increment contains, \n        e.g. 8 bits or 32 bits. The AUB is mandatory if the address space contains a local memory map.\n    </p>\n    <p>\n      <b>Range</b> is the size of the address space expressed as addressable units, i.e. the number of\n      separate addresses.\n    </p>\n    <p>\n      <b>Width</b> is the data width of a row in bits. It defines the maximum size for a single transfer.\n    </p>\n\t<p>\n        <b>Is present</b> is optional and allows enabling/disabling of a <i>address space</i>\n        presence in a <i>component</i>. Value 1 indicates that the <i>address space</i>\n        is present in the <i>component</i> whereas value 0 marks the address space to be\n        treated as if it does not exist. Is present can be given as a SystemVerilog expression,\n        but it must evaluate to 1 or 0.</p>\n\t<p>\n    <p>\n      <b>Master interface binding</b> shows the master <i>bus interfaces</i> bound to the address space. \n\t  The binding can be set in the bus interface editor.\n    </p>\n\t\n    <h3>Segments</h3>\n    <p>\n      <b>Segments</b> editor can be used to describe sections of the address space, i.e. split it into smaller\n        segments.\n    </p>\n\t<p>\n\t    <b>Name</b> is a mandatory identifier for the <i>segment</i>.\n    </p>\n    <p>\n      <b>Offset</b> is mandatory and defines the starting address of the <i>segment</i> in address unit bits.\n\t</p>\n\t<p>\n\t\t<b>Range</b> is mandatory and defines the size of the <i>segment</i> in address unit bits.\n    </p>\n\t\t<p>\n        <b>Is present</b> is optional and allows enabling/disabling of a <i>segment</i>\n        presence in an <i>address space</i>. Value 1 indicates that the <i>segment</i>\n        is present in the <i>address space</i> whereas value 0 marks the segment to be\n        treated as if it does not exist. Is present can be given as a SystemVerilog expression,\n        but it must evaluate to 1 or 0.</p>\n\t<p>\n\t <p>\n        <b>Description</b> is an optional field for textual description of the <i>segment</i>.\t\t\n    </p>\n\n    <h3>Local memory map</h3>\n    <p>\n      <b>Local memory map</b> is optional but some processors require specifying a memory map that is local\n      to the component. It consists of <i>address blocks</i> similarly to the <i>memory map</i> of a slave\n      <i>bus interface</i>.\n\t  Hence, the address blocks can contain either memory or registers, and registers can contain bit fields.\n    </p>\n    <p>\n      Local memory map is useful for storing the programmer's view to interrupts registers, timers,\n      and other local things. The overall address space of a component is a concatenation of local memory map\n      (e.g. timers) and the memory maps of other units (e.g. registers of accelerator A, registers of\n      accelerator B etc.)\n    </p>\n\t\n  </body>\n</html>\n"
  },
  {
    "path": "Help/componenteditor/addressspace2022.html",
    "content": "﻿<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01//EN\" \"http://www.w3.org/TR/html4/strict.dtd\">\n<html>\n  <head>\n    <meta http-equiv=\"Content-Type\"content=\"text/html; charset=utf-8\">\n    <link href=\"../style.css\" rel=\"Stylesheet\" type=\"text/css\">\n    <title>Address space editor</title>\n  </head>\n  <body>\n    <h2>Address space editor</h2>\n    <p>\n      Address space editor can be used to edit the details of an\n      address space within component.  <i>Address space</i> defines a\n      logical address space seen by a initiator <i>bus interface</i>. It can be\n      split into smaller <i>sgements</i>.\n    </p>\n    <p>\n      On the left side are the editor fields that can be used to set\n      the details of an address space. The right side contains a\n      visualization displaying the address space in its current state and\n\t    automatically updates on changes.\n\t    It displays how the segments are positioned within the address space. \n\t    Mismatches, e.g. sum of segment ranges being greater than address block range, can \n      be easily spotted from the visualization.\n    </p>\n\t<p>\n\t    <b>Name</b> is a mandatory identifier for the <i>address space</i>.\n    </p>\n    <p>\n        <b>Display name</b> is an optional and used for a more user-friendly identifier.\n    </p>\n    <p>\n      <b>Short description</b> is an optional field for a short, textual description of the <i>address space</i>.\t\t\n    </p>\n    <p>\n        <b>Description</b> is an optional field for textual description of the <i>address space</i>.\t\t\n    </p>\n    <p>\n        <b>Addressable unit bits</b> (AUB) specifies the number of bits each address increment contains, \n        e.g. 8 bits or 32 bits. The AUB is mandatory if the address space contains a local memory map.\n    </p>\n    <p>\n      <b>Range</b> is the size of the address space expressed as addressable units, i.e. the number of\n      separate addresses.\n    </p>\n    <p>\n      <b>Width</b> is the data width of a row in bits. It defines the maximum size for a single transfer.\n    </p>\n    <p>\n      <b>Initiator interface binding</b> shows the initiator <i>bus interfaces</i> bound to the address space. \n\t    The binding can be set in the bus interface editor.\n    </p>\n\t\n    <h3>Segments</h3>\n    <p>\n      <b>Segments</b> editor can be used to describe sections of the address space, i.e. split it into smaller\n        segments.\n    </p>\n\t<p>\n\t    <b>Name</b> is a mandatory identifier for the <i>segment</i>.\n    </p>\n    <p>\n      <b>Offset</b> is mandatory and defines the starting address of the <i>segment</i> in address unit bits.\n\t</p>\n\t<p>\n\t\t<b>Range</b> is mandatory and defines the size of the <i>segment</i> in address unit bits.\n    </p>\n\t <p>\n        <b>Description</b> is an optional field for textual description of the <i>segment</i>.\t\t\n    </p>\n\n    <h3>Local memory map</h3>\n    <p>\n      <b>Local memory map</b> is optional but some processors require specifying a memory map that is local\n      to the component. It consists of <i>address blocks</i> similarly to the <i>memory map</i> of a target\n      <i>bus interface</i>.\n\t  Hence, the address blocks can contain either memory or registers, and registers can contain bit fields.\n    </p>\n    <p>\n      Local memory map is useful for storing the programmer's view to interrupts registers, timers,\n      and other local things. The overall address space of a component is a concatenation of local memory map\n      (e.g. timers) and the memory maps of other units (e.g. registers of accelerator A, registers of\n      accelerator B etc.)\n    </p>\n\t\n  </body>\n</html>\n"
  },
  {
    "path": "Help/componenteditor/addressspaces.html",
    "content": "﻿<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01//EN\" \"http://www.w3.org/TR/html4/strict.dtd\">\n<html>\n  <head>\n    <meta http-equiv=\"Content-Type\"content=\"text/html; charset=utf-8\">\n    <link href=\"../style.css\" rel=\"Stylesheet\" type=\"text/css\">\n    <title>Address spaces editor</title>\n  </head>\n  <body>\n    <h2>Address spaces editor</h2>\n    <p>\n      Address spaces editor contains the summary of the address spaces\n      of the component. This editor can be used to add and remove\n      address spaces to the containing component. \n    </p>\n    <p>\n      <b>Address space</b> defines the addressable memory space that can be accessed through\n\t  a master <i>bus interface</i>. It is the programmer's view to the rest of the system.\n      <br />Note: Address spaces are actually instance-specific concepts (what other units are \n      there and what are their addresses) rather than component-specific. Nevertheless, IP-XACT standard \n      defines address space inside a component, although it is seldom a reusable element.\n    </p>\n\t<p>\n\t    <b>Name</b> is a mandatory identifier for the <i>address space</i>.\n    </p>\n    <p>\n      <b>Addressable unit bits</b> specifies the number of bits each address increment contains, \n      e.g. 8 bits or 32 bits. The AUB is mandatory if the address space contains a <i>local memory map</i>. \n\t  AUB is 8 by default.\n    </p>\n    <p>\n      <b>Range</b> is mandatory and defines the size of the address space in addressable units. In other \n      words, it is the number of separate addresses in the address space.\n    </p>\n    <p>\n      <b>Width</b> is mandatory and defines the data width of a row in bits thus\n\t  defining the maximum size for a single transfer.\n    </p>\n    <p>\n      <b>Master interface binding</b> shows the master <i>bus interfaces</i> bound to the address space. \n\t  The binding can be set in the bus interface editor.\n    </p>\n\t\n\t<p>\n        <b>Is present</b> is optional and allows enabling/disabling of a <i>address space</i>\n        presence in a <i>component</i>. Value 1 indicates that the <i>address space</i>\n        is present in the <i>component</i> whereas value 0 marks the address space to be\n        treated as if it does not exist. Is present can be given as a SystemVerilog expression,\n        but it must evaluate to 1 or 0.</p>\n\t<p>\n\t\n\t<p>\n        <b>Description</b> is an optional field for textual description of the <i>address space</i>.\t\t\n    </p>\n    <p>\n      Address spaces editor contains a context menu (right mouse button) providing following options:\n    </p>\n    <ul>\n      <li>Add new address space (Add row)</li>\n      <li>Remove address space (Remove row)</li>\n      <li>Clear the selected cells</li>\n      <li>Copy the contents of the selected cells to clipboard</li>\n      <li>Paste the contents of the clipboard to the selected cells</li>\n      <li>Import a csv-file to the editor</li>\n      <li>Export the contents of the editor to a csv-file</li>\n    </ul>\n\t<hr>\n\t<p>\n\t\tEXAMPLE. The address space AS0 defines the available address space of the whole system\n\t\twhen accessed through bus interface MainIF. This is what the component CPU0 requires\n\t\tof the system, but the components connected to MainIF may be different.\n\t\t<br>\n\t\t<img src=\"../images/addr_space.png\" alt=\"addr space's idea\">\n    </p>\n  </body>\n</html>\n"
  },
  {
    "path": "Help/componenteditor/addressspaces2022.html",
    "content": "﻿<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01//EN\" \"http://www.w3.org/TR/html4/strict.dtd\">\n<html>\n  <head>\n    <meta http-equiv=\"Content-Type\"content=\"text/html; charset=utf-8\">\n    <link href=\"../style.css\" rel=\"Stylesheet\" type=\"text/css\">\n    <title>Address spaces editor</title>\n  </head>\n  <body>\n    <h2>Address spaces editor</h2>\n    <p>\n      Address spaces editor contains the summary of the address spaces\n      of the component. This editor can be used to add and remove\n      address spaces to the containing component. \n    </p>\n    <p>\n      <b>Address space</b> defines the addressable memory space that can be accessed through\n\t  a master <i>bus interface</i>. It is the programmer's view to the rest of the system.\n      <br />Note: Address spaces are actually instance-specific concepts (what other units are \n      there and what are their addresses) rather than component-specific. Nevertheless, IP-XACT standard \n      defines address space inside a component, although it is seldom a reusable element.\n    </p>\n\t<p>\n\t    <b>Name</b> is a mandatory identifier for the <i>address space</i>.\n    </p>\n    <p>\n      <b>Addressable unit bits</b> specifies the number of bits each address increment contains, \n      e.g. 8 bits or 32 bits. The AUB is mandatory if the address space contains a <i>local memory map</i>. \n\t  AUB is 8 by default.\n    </p>\n    <p>\n      <b>Range</b> is mandatory and defines the size of the address space in addressable units. In other \n      words, it is the number of separate addresses in the address space.\n    </p>\n    <p>\n      <b>Width</b> is mandatory and defines the data width of a row in bits thus\n\t  defining the maximum size for a single transfer.\n    </p>\n    <p>\n      <b>Initiator interface binding</b> shows the initiator <i>bus interfaces</i> bound to the address space. \n\t    The binding can be set in the bus interface editor.\n    </p>\n\t\n\t  <p>\n      <b>Description</b> is an optional field for textual description of the <i>address space</i>.\t\t\n    </p>\n    <p>\n      Address spaces editor contains a context menu (right mouse button) providing following options:\n    </p>\n    <ul>\n      <li>Add new address space (Add row)</li>\n      <li>Remove address space (Remove row)</li>\n      <li>Clear the selected cells</li>\n      <li>Copy the contents of the selected cells to clipboard</li>\n      <li>Paste the contents of the clipboard to the selected cells</li>\n      <li>Import a csv-file to the editor</li>\n      <li>Export the contents of the editor to a csv-file</li>\n    </ul>\n\t<hr>\n\t<p>\n\t\tEXAMPLE. The address space AS0 defines the available address space of the whole system\n\t\twhen accessed through bus interface MainIF. This is what the component CPU0 requires\n\t\tof the system, but the components connected to MainIF may be different.\n\t\t<br>\n\t\t<img src=\"../images/addr_space.png\" alt=\"addr space's idea\">\n    </p>\n  </body>\n</html>\n"
  },
  {
    "path": "Help/componenteditor/apiinterface.html",
    "content": "<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01//EN\" \"http://www.w3.org/TR/html4/strict.dtd\">\n<html>\n  <head>\n    <meta http-equiv=\"Content-Type\"content=\"text/html; charset=utf-8\">\n    <link href=\"../style.css\" rel=\"Stylesheet\" type=\"text/css\">\n    <title>API interface editor</title>\n  </head>\n  <body>\n    <h2>API interface editor</h2>\n    <p>\n    <p>\n      This is Kactus2 extension <br><img\n      src=\"../images/appicon.png\"><br> Each API interface has a\n      mandatory <b>name</b>. <b>Display name</b> is optional and\n      typically a few words providing a more detailed and/or\n      user-friendly name for display. Optional <b>description</b>\n      contains a textual description of the interface.\n    </p>\n    <p>\n      Optional <b>API definition</b> is an XML document that captures\n      the interface properties. It lists all the function calls, their\n      parameters, and return values. You can type the VLNV or\n      drag-drop an API definition from the library.\n    </p>\n    <p>\n      <b>Details</b> section includes <b>dependency</b> which is\n      either 'provider' or 'requester'. A <i>provider</i> means that\n      this SW components implements the API and other SW components\n      call its functions. <i>Requester</i> means that this SW\n      components calls functions defined in the API and some other SW\n      component must implement (provide) them.\n    </p>\n  </body>\n</html>\n"
  },
  {
    "path": "Help/componenteditor/apiinterfaces.html",
    "content": "<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01//EN\" \"http://www.w3.org/TR/html4/strict.dtd\">\n<html>\n  <head>\n    <meta http-equiv=\"Content-Type\"content=\"text/html; charset=utf-8\">\n    <link href=\"../style.css\" rel=\"Stylesheet\" type=\"text/css\">\n    <title>API interfaces editor</title>\n  </head>\n  <body>\n    <h2>API interfaces editor</h2>\n    <p>\n      This is Kactus2 extension <br><img\n      src=\"../images/appicon.png\"><br><br> <i>API interface</i>\n      (application programming interface) means the protocol that SW\n      components use to communicate, in practice it is set of function\n      calls. Purpose is to increase portability by abstacting the\n      details of underlying HW. These are a lower level concept than\n      COM interfaces and cannot appear in HW components. API\n      interfaces make rather tight coupling between SW components, and\n      often both the sender and receiver are mapped on the same CPU.\n      COM interfaces are meant for communication between application\n      modules, whereas API interfaces are mainly between application\n      and platform (OS, drivers) and inside the platform.  </p>\n    <p>\n      For example, a SW component could have API interfaces 'lower'\n      and 'upper'. It <i>requests</i> the 'lower' one, DMA driver,\n      i.e. calls its functions. At the same, this component 'provides'\n      the 'upper' interface, MCAPI, i.e. other SW components can call\n      its functions.<br> <img src=\"../images/api_interfaces.png\"\n      alt=\"screen_cap\"><br>\n    </p>\n\n  </body>\n</html>\n"
  },
  {
    "path": "Help/componenteditor/businterfacegeneral.html",
    "content": "﻿<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01//EN\" \"http://www.w3.org/TR/html4/strict.dtd\">\n<html>\n  <head>\n    <meta http-equiv=\"Content-Type\"content=\"text/html; charset=utf-8\">\n    <link href=\"../style.css\" rel=\"Stylesheet\" type=\"text/css\">\n    <title>Bus interface editor</title>\n  </head>\n  <body>\n    <h2>Bus interface editor</h2>\n    <p>\n      Bus interface editor is used to edit the details of a single\n      <i>bus interface</i>. A bus interface is used to group ports\n      together to form an interface that fulfills the requirements\n      for a bus protocol. The editor has two tabs: the\n      <b>general</b> tab which is used to set the details of\n      the bus interface, and the <b>port maps</b> tab which is used to\n      group the ports to the bus interface.\n    </p>\n\t<p>\n\t    <b>Name</b> is a mandatory identifier for the <i>bus interface</i>.\n    </p>\n    <p>\n        <b>Display name</b> is an optional and used for a more user-friendly identifier.\n    </p>\n    <p>\n        <b>Description</b> is an optional field for textual description of the <i>bus interface</i>.\t\t\n    </p>\n\n   <h3>General settings</h3>\n     <p>\n       <b>Interface mode</b> is mandatory and has 7 possible choices:\n    </p>\n    <ul>\n        <li><b>Master</b> for initiating transactions.</li>\n        <li><b>Slave</b> for responding to transactions.</li>\n        <li><b>System</b> for defining interfaces not belonging to either master or slave interface modes.\n        They are categorized by a system group instead.</li>\n        <li><b>MirroredMaster</b> is the mirrored version of a master interface.</li>\n        <li><b>MirroredSlave</b> is the mirrored version of a slave interface.</li>\n        <li><b>MirroredSystem</b> is the mirrored version of a system interface.</li>\n        <li><b>Monitor</b> for verification.</li>\n    </ul>\n    <p>\n        Settings below the general section are mode-specific and change when the mode changes.\n        The different modes are detailed in their respective sections below. \n    </p>        \n    <p>\n      <b>Addressable unit size</b> defines how many bits are included in the least addressable unit of the bus \n      interface. The default setting is byte addressable (8 bits).\n    </p>\n    <p>\n      <b>Bit steering</b>='on' implies that the interface is able to dynamically align data on different byte \n      channels in case of addressable interfaces. The default setting when the bit steering is not set is off.\n      Bit steering is not allowed in mirrored-master, system or mirrored-system interface modes.\n    </p>\n    <p>\n      <b>Endianness</b> indicates whether the interface is 'big-endian' or 'little-endian' (default).\n    </p>\n    <p>\n      <b>Connection required</b> indicates that when instantiated in a design, this interface must be connected \n      to some other interface and cannot be left unconnected.\n    </p>\n\n    <h3>Master</h3>\n    <p>\n        <b>Address space</b> defines the <i>address space</i> available for transactions on\n        the bus interface. <i>Address space</i> is optional, but, if defined,  \n        <i>base address</i> becomes mandatory as well.\n    </p>\n    <p>\n        <b>Base address</b> is defines the starting address of the <i>address space</i>. Typically\n        base address is 0.\n    </p>\n\n    <h3>Mirrored master</h3>\n    <p>\n\t\tMirrored master has no mode-specific options.\n\t</p>\n\t\n    <h3>Slave</h3>\n    <p> A slave bus interface may have access to a <i>memory map</i> or a master bus interface.\n        Access to a master bus interface is called a <i>transparent bridge</i>. Access is \n        optional, but mutually exclusive i.e. a slave bus interface may only access a memory map, \n        a transparent bridge or neither.\n    </p>\n    <p>\n        <b>Memory map</b> is optional and defines the <i>memory map</i> accessible through\n        the bus interface. If a <i>memory map</i> has been defined, <i>transparent bridge</i>\n        cannot be defined.\n    </p>\n    <p>\n        <b>Transparent bridge(s)</b> are optional and define the master <i>bus interface(s)</i> that\n        all transactions to this <i>bus interface</i> are directed out of. \n        If <i>transparent bridges</i> have been defined, <i>memory map</i> cannot be defined.\n    </p>\n    <!--\n    <p>\n        <b>isPresent</b> not implemented.\n    </p>\n    -->\n    <p>\n        <b>File set references</b> define the associated <i>file sets</i> for the slave bus\n        interface. For example, the file set could contain the interface implementation or\n        a software driver.\n    </p>\n     \n    <h3>Mirrored slave</h3>\n    <p>\n        <b>Remap address</b> defines an address offset for the slave <i>bus interface</i>\n        conneted to this interface. <i>Remap address</i>is optional,\n        but, if defined, <i>range</i> becomes mandatory as well.\n    </p>\n    <!--\n    <p>\n        <b>State</b> not implemented.\n    </p>\n    -->\n    <p>\n        <b>Range</b> defines the address range available for the connected slave <i>bus interface</i>.\n    </p>\n\n    <h3>System and mirrored system</h3>\n    <p>\n        <b>System group</b> defines the group this <i>bus interface</i> is part of. The available system\n        groups are defined in the referenced <i>bus definition</i> (see below).\n    </p>\n        \n    <h3>Monitor</h3>\n    <p>\n        <b>Interface mode</b> is mandatory and defines the interface mode the monitor can be connected to.\n    </p>\n    <p>\n        <b>Group</b> defines the group this <i>bus interface</i> is part of when system or\n        mirrored system interface mode is selected. For other modes group has no effect.\n    </p>\n    \n    <h3>Bus definition</h3>\n    <p>\n      <b>Bus definition</b> is mandatory and contains a <i>VLNV</i>-reference to the <i>bus definition</i>\n      document that defines the qualities that the <i>bus interface</i> must meet.\n    </p>\n\n    <h3>Abstraction definition</h3>\n    <p>     \n      <b>Abstraction definition</b> contains an optional <i>VLNV</i>-reference to \n      the <i>abstraction definition</i> document that defines the logical signals\n      on the bus. If multiple abstraction definitions are defined, <b>view references</b>\n\t    specify which view(s) the abstraction is applied to. All views are considered,\n\t    if the view reference is empty.\n\t</p>\n\t<p>\n\t  <i>Port maps</i> on the other tab define how the logical signals in the <b>abstraction\n\t  definition</b> are connected to the physical ports on the component.\n    </p>\n    <h3>Parameters</h3>\n    <p>\n      <b>Parameters</b> are optional and can specify any parameter data value(s) specific for this bus interface.\n      For more information on parameters, see the component parameter editor.\n    </p>\n  </body>\n</html>\n"
  },
  {
    "path": "Help/componenteditor/businterfacegeneral2022.html",
    "content": "﻿<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01//EN\" \"http://www.w3.org/TR/html4/strict.dtd\">\n<html>\n  <head>\n    <meta http-equiv=\"Content-Type\"content=\"text/html; charset=utf-8\">\n    <link href=\"../style.css\" rel=\"Stylesheet\" type=\"text/css\">\n    <title>Bus interface editor</title>\n  </head>\n  <body>\n    <h2>Bus interface editor</h2>\n    <p>\n      Bus interface editor is used to edit the details of a single\n      <i>bus interface</i>. A bus interface is used to group ports\n      together to form an interface that fulfills the requirements\n      for a bus protocol. The editor has two tabs: the\n      <b>general</b> tab which is used to set the details of\n      the bus interface, and the <b>port maps</b> tab which is used to\n      group the ports to the bus interface.\n    </p>\n\t<p>\n\t    <b>Name</b> is a mandatory identifier for the <i>bus interface</i>.\n    </p>\n    <p>\n        <b>Display name</b> is an optional and used for a more user-friendly identifier.\n    </p> \n    <p>\n      <b>Short description</b> is an optional field for compact description of the <i>bus interface</i>.\n    </p>\n    <p>\n        <b>Description</b> is an optional field for textual description of the <i>bus interface</i>.\t\t\n    </p>\n\n   <h3>General settings</h3>\n     <p>\n       <b>Interface mode</b> is mandatory and has 7 possible choices:\n    </p>\n    <ul>\n        <li><b>Initiator</b> for initiating transactions.</li>\n        <li><b>Target</b> for responding to transactions.</li>\n        <li><b>System</b> for defining interfaces not belonging to either initiator or target interface modes.\n        They are categorized by a system group instead.</li>\n        <li><b>MirroredInitiator</b> is the mirrored version of an initiator interface.</li>\n        <li><b>MirroredTarget</b> is the mirrored version of a target interface.</li>\n        <li><b>MirroredSystem</b> is the mirrored version of a system interface.</li>\n        <li><b>Monitor</b> for verification.</li>\n    </ul>\n    <p>\n        Settings below the general section are mode-specific and change when the mode changes.\n        The different modes are detailed in their respective sections below. \n    </p>        \n    <p>\n      <b>Addressable unit size</b> defines how many bits are included in the least addressable unit of the bus \n      interface. The default setting is byte addressable (8 bits).\n    </p>\n    <p>\n      <b>Bit steering</b> evaluating to value '1' implies that the interface is able to dynamically align data on different byte \n      channels in case of addressable interfaces. The default setting when the bit steering is not set is 0.\n      Bit steering is not allowed in mirrored-initiator, system or mirrored-system interface modes.\n    </p>\n    <p>\n      <b>Endianness</b> indicates whether the interface is 'big-endian' or 'little-endian' (default).\n    </p>\n    <p>\n      <b>Connection required</b> indicates that when instantiated in a design, this interface must be connected \n      to some other interface and cannot be left unconnected.\n    </p>\n\n    <h3>Initiator</h3>\n    <p>\n        <b>Address space</b> defines the <i>address space</i> available for transactions on\n        the bus interface. <i>Address space</i> is optional, but, if defined,  \n        <i>base address</i> becomes mandatory as well.\n    </p>\n    <p>\n        <b>Base address</b> is defines the starting address of the <i>address space</i>. Typically\n        base address is 0.\n    </p>\n\n    <h3>Mirrored initiator</h3>\n    <p>\n\t\tMirrored initiator has no mode-specific options.\n\t</p>\n\t\n    <h3>Target</h3>\n    <p> A target bus interface may have access to a <i>memory map</i> or an initiator bus interface.\n      Access to a initiator bus interface is called a <i>transparent bridge</i>. Access is \n      optional, but mutually exclusive i.e. a target bus interface may only access a memory map, \n      a transparent bridge or neither.\n  </p>\n  <p>\n      <b>Memory map</b> is optional and defines the <i>memory map</i> accessible through\n      the bus interface. If a <i>memory map</i> has been defined, <i>transparent bridge</i>\n      cannot be defined.\n  </p>\n  <p>\n      <b>Transparent bridge(s)</b> are optional and define the initiator <i>bus interface(s)</i> that\n      all transactions to this <i>bus interface</i> are directed out of. \n      If <i>transparent bridges</i> have been defined, <i>memory map</i> cannot be defined.\n  </p>\n    <p>\n        <b>File set references</b> define the associated <i>file sets</i> for the target bus\n        interface. For example, the file set could contain the interface implementation or\n        a software driver.\n    </p>\n     \n    <h3>Mirrored target</h3>\n    <p>\n        <b>Remap address</b> defines an address offset for the target <i>bus interface</i>\n        conneted to this interface. <i>Remap address</i>is optional,\n        but, if defined, <i>range</i> becomes mandatory as well.\n    </p>\n    <!--\n    <p>\n        <b>Modes</b> not implemented yet.\n    </p>\n    -->\n    <p>\n        <b>Range</b> defines the address range available for the connected target <i>bus interface</i>.\n    </p>\n\n    <h3>System and mirrored system</h3>\n    <p>\n        <b>System group</b> defines the group this <i>bus interface</i> is part of. The available system\n        groups are defined in the referenced <i>bus definition</i> (see below).\n    </p>\n        \n    <h3>Monitor</h3>\n    <p>\n        <b>Interface mode</b> is mandatory and defines the interface mode the monitor can be connected to.\n    </p>\n    <p>\n        <b>Group</b> defines the group this <i>bus interface</i> is part of when system or\n        mirrored system interface mode is selected. For other modes group has no effect.\n    </p>\n    \n    <h3>Bus definition</h3>\n    <p>\n      <b>Bus definition</b> is mandatory and contains a <i>VLNV</i>-reference to the <i>bus definition</i>\n      document that defines the qualities that the <i>bus interface</i> must meet.\n    </p>\n\n    <h3>Abstraction definition</h3>\n    <p>     \n      <b>Abstraction definition</b> contains an optional <i>VLNV</i>-reference to \n      the <i>abstraction definition</i> document that defines the logical signals\n      on the bus. If multiple abstraction definitions are defined, <b>view references</b>\n\t    specify which view(s) the abstraction is applied to. All views are considered,\n\t    if the view reference is empty.\n\t</p>\n\t<p>\n\t  <i>Port maps</i> on the other tab define how the logical signals in the <b>abstraction\n\t  definition</b> are connected to the physical ports on the component.\n    </p>\n    <h3>Parameters</h3>\n    <p>\n      <b>Parameters</b> are optional and can specify any parameter data value(s) specific for this bus interface.\n      For more information on parameters, see the component parameter editor.\n    </p>\n  </body>\n</html>\n"
  },
  {
    "path": "Help/componenteditor/businterfaces.html",
    "content": "﻿<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01//EN\" \"http://www.w3.org/TR/html4/strict.dtd\">\n<html>\n  <head>\n    <meta http-equiv=\"Content-Type\"content=\"text/html; charset=utf-8\">\n    <link href=\"../style.css\" rel=\"Stylesheet\" type=\"text/css\">\n    <title>Bus interfaces editor</title>\n  </head>\n  <body>\n    <h2>Bus interfaces editor</h2>\n    <p>\n      The bus interfaces editor displays a summary of the bus\n      interfaces of a component. A <i>bus interface</i> groups\n      <i>ports</i> together to form an interface that fulfills\n      requirements for a bus protocol. Connecting two matching\n      interfaces means connecting multiple ports (up to tens or even\n      hundreds of bits) together very easily. This editor is used to\n      add and remove bus interfaces in a component\n\t  <br />\n\t   <img src=\"../images/portmap.png\" alt=\"interface_example\"><br />\n    </p>\n    <p>\n      Bus interface has a mandatory <b>name</b> and optional textual <b>description</b>.\n    </p>\n    <p>\n      <b>Bus definition</b> and <b>abstraction definition</b> columns display the <i>VLNV</i>-identifiers of the\n      IP-XACT documents that define qualities of the interface. These\n      fields must be set in the bus interface-specific editor.\n    </p>\n    <p> \n      <b>Interface mode</b> has 7 different choices (3 modes and 2\n      flavors of each, plus 1 extra):\n    </p>\n    <dl>\n      <dt>1. <b>Master</b> initiates transactions, e.g. a write or read. \n\t  A master may have an <i>address space</i> which captures the programmer's view of the system.</dt>\n      \n      <dt>2. <b>Slave</b> responds to transactions, e.g. accepts the written value or provides the read value.\n\t  A slave may have a <i>memory map</i> which captures information about the accessible registers inside this component.</dt>\n      \n      <dt>3. <b>System</b> can be used for some interfaces that do not fit into the master or slave category.</dt>\n      \n      <dt>4-6. <b>Mirrored master, mirrored slave, mirrored system</b> are the <i>mirrored</i> versions of the\n\t  above modes.\n\t  They have similar ports as normal interfaces, but the directions of the ports are reversed. \n\t  For example, if a <i>master</i> interface has data \n    output, then a <i>mirrored master</i> has data as input.\n\t  It is not allowed to connect to mirrored interfaces together. \n\t  The main usage of mirrored interfaces is at bus interconnects, such as AMBA AHB/APB or HIBI,\n\t  since they allow constructing a memory map of the whole system, whereas regular IP \n      components mainly utilize direct interfaces.</dt>\n      \n      <dt>7. <b>Monitor</b> is an interface that can be used for verification process. \n\t  It gathers data from other interfaces, i.e. non-intrusive observation and hence all logical port are inputs</dt>\n    </dl>\n\n    <p> \n      IP-XACT allows three kinds of connections\n    </p>\n    <ol>\n      <li>Direct master to slave: Point-to-point connection. Complex cases require using bus interconnect\n      component containing <i>bridge(s)</i>, such as multillayer AHB bus. </li>\n      \n      <li>Direct-mirrored: master to mirrored master, mirrored slave to slave, system to mirrored system. \n      Point-to-point connection. Complex cases require using bus interconnect component containing \n      <i>channel(s)</i> </li>\n      \n      <li>Monitor: any type except monitor to monitor. Many monitors can be connected to single interface</li>\n    </ol>\n    <hr>\n    <p>    \n      EXAMPLE. Component Sender writes data through its master interface MIF to\n      mirrored master interface MMIF in interconnect. On the receiving side,\n      interconnect's mirrored slave interface MSIF writes the data to\n      Receiver's slave interface SIF.  \n      <br />\n      <img src=\"../images/busInterfaces.png\" alt=\"interfaces_example\"><br />\n     </p>\n    </p>\n    \n  </body>\n</html>\n"
  },
  {
    "path": "Help/componenteditor/businterfaces2022.html",
    "content": "﻿<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01//EN\" \"http://www.w3.org/TR/html4/strict.dtd\">\n<html>\n  <head>\n    <meta http-equiv=\"Content-Type\"content=\"text/html; charset=utf-8\">\n    <link href=\"../style.css\" rel=\"Stylesheet\" type=\"text/css\">\n    <title>Bus interfaces editor</title>\n  </head>\n  <body>\n    <h2>Bus interfaces editor</h2>\n    <p>\n      The bus interfaces editor displays a summary of the bus\n      interfaces of a component. A <i>bus interface</i> groups\n      <i>ports</i> together to form an interface that fulfills\n      requirements for a bus protocol. Connecting two matching\n      interfaces means connecting multiple ports (up to tens or even\n      hundreds of bits) together very easily. This editor is used to\n      add and remove bus interfaces in a component\n\t  <br />\n\t   <img src=\"../images/portmap2022.png\" alt=\"interface_example\"><br />\n    </p>\n    <p>\n      Bus interface has a mandatory <b>name</b> and optional textual <b>description</b>.\n    </p>\n    <p>\n      <b>Bus definition</b> and <b>abstraction definition</b> columns display the <i>VLNV</i>-identifiers of the\n      IP-XACT documents that define qualities of the interface. These\n      fields must be set in the bus interface-specific editor.\n    </p>\n    <p> \n      <b>Interface mode</b> has 7 different choices (3 modes and 2\n      flavors of each, plus 1 extra):\n    </p>\n    <dl>\n      <dt>1. <b>Initiator</b> initiates transactions, e.g. a write or read. \n\t  An initiator may have an <i>address space</i> which captures the programmer's view of the system.</dt>\n      \n      <dt>2. <b>Target</b> responds to transactions, e.g. accepts the written value or provides the read value.\n\t  A target may have a <i>memory map</i> which captures information about the accessible registers inside this component.</dt>\n      \n      <dt>3. <b>System</b> can be used for some interfaces that do not fit into the initiator or target category.</dt>\n      \n      <dt>4-6. <b>Mirrored initiator, mirrored target, mirrored system</b> are the <i>mirrored</i> versions of the\n\t  above modes.\n\t  They have similar ports as normal interfaces, but the directions of the ports are reversed. \n\t  For example, if an <i>initiator</i> interface has data \n    output, then a <i>mirrored initiator</i> has data as input.\n\t  It is not allowed to connect to mirrored interfaces together. \n\t  The main usage of mirrored interfaces is at bus interconnects, such as AMBA AHB/APB or HIBI,\n\t  since they allow constructing a memory map of the whole system, whereas regular IP \n      components mainly utilize direct interfaces.</dt>\n      \n      <dt>7. <b>Monitor</b> is an interface that can be used for verification process. \n\t  It gathers data from other interfaces, i.e. non-intrusive observation and hence all logical port are inputs</dt>\n    </dl>\n\n    <p> \n      IP-XACT allows three kinds of connections\n    </p>\n    <ol>\n      <li>Direct initiator to target: Point-to-point connection. Complex cases require using bus interconnect\n      component containing <i>bridge(s)</i>, such as multillayer AHB bus. </li>\n      \n      <li>Direct-mirrored: initiator to mirrored initiator, mirrored target to target, system to mirrored system. \n      Point-to-point connection. Complex cases require using bus interconnect component containing \n      <i>channel(s)</i> </li>\n      \n      <li>Monitor: any type except monitor to monitor. Many monitors can be connected to single interface</li>\n    </ol>\n    <hr>\n    <p>    \n      EXAMPLE. Component Sender writes data through its initiator interface IIF to\n      mirrored initiator interface MIIF in interconnect. On the receiving side,\n      interconnect's mirrored target interface MTIF writes the data to\n      Receiver's target interface TIF.  \n      <br />\n      <img src=\"../images/busInterfaces2022.png\" alt=\"interfaces_example\"><br />\n     </p>\n    </p>\n    \n  </body>\n</html>\n"
  },
  {
    "path": "Help/componenteditor/channels.html",
    "content": "﻿<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01//EN\" \"http://www.w3.org/TR/html4/strict.dtd\">\n<html>\n  <head>\n    <meta http-equiv=\"Content-Type\"content=\"text/html; charset=utf-8\">\n    <link href=\"../style.css\" rel=\"Stylesheet\" type=\"text/css\">\n    <title>Channels editor</title>\n  </head>\n  <body>\n    <h2>Channels editor</h2>\n    <p>\n      Channels editor provides a summary of the channels contained in\n      the bus component. <i>Channel</i> is used within a bus\n      component to describe which bus interfaces are connected\n      together. This editor can be used to add, edit and remove\n      channels.\n    </p>\n    <p>\n\t    <b>Name</b> is a mandatory identifier for the <i>channel</i>.\n    </p>\n    <p>\n        <b>Display name</b> is an optional and used for a more user-friendly identifier.\n    </p> \n    <p>\n      <b>Interface references</b> contain the names of the mirrored <i>bus interfaces</i> \n      that are grouped to the same channel. All the <i>bus interfaces</i> in the group are\n      interconnected. \n    </p>\n    <p>\n        <b>Description</b> is an optional field for textual description of the <i>channel</i>.\t\t\n    </p>\n    <hr>\n    <p>\n\t  The figure below illustrates the connections between mirrored bus interfaces. All four\n    mirrored bus interfaces are included in the same channel.\n\t  <br>\n\t  <img src=\"../images/ChannelVisualization.png\" alt=\"A Channel\n      connecting bus interfaces within a component\"><br>\n    </p>\n  </body>\n</html>\n"
  },
  {
    "path": "Help/componenteditor/channels2022.html",
    "content": "﻿<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01//EN\" \"http://www.w3.org/TR/html4/strict.dtd\">\n<html>\n  <head>\n    <meta http-equiv=\"Content-Type\"content=\"text/html; charset=utf-8\">\n    <link href=\"../style.css\" rel=\"Stylesheet\" type=\"text/css\">\n    <title>Channels editor</title>\n  </head>\n  <body>\n    <h2>Channels editor</h2>\n    <p>\n      Channels editor provides a summary of the channels contained in\n      the bus component. <i>Channel</i> is used within a bus\n      component to describe which bus interfaces are connected\n      together. This editor can be used to add, edit and remove\n      channels.\n    </p>\n    <p>\n\t    <b>Name</b> is a mandatory identifier for the <i>channel</i>.\n    </p>\n    <p>\n        <b>Display name</b> is an optional and used for a more user-friendly identifier.\n    </p> \n    <p>\n      <b>Interface references</b> contain the names of the mirrored <i>bus interfaces</i> \n      that are grouped to the same channel. All the <i>bus interfaces</i> in the group are\n      interconnected. \n    </p>\n    <p>\n        <b>Short description</b> is an optional field for compact description of the <i>channel</i>.\n    </p>\n    <p>\n        <b>Description</b> is an optional field for textual description of the <i>channel</i>.\t\t\n    </p>\n    <hr>\n    <p>\n\t  The figure below illustrates the connections between mirrored bus interfaces. All four\n    mirrored bus interfaces are included in the same channel.\n\t  <br>\n\t  <img src=\"../images/ChannelVisualization.png\" alt=\"A Channel\n      connecting bus interfaces within a component\"><br>\n    </p>\n  </body>\n</html>\n"
  },
  {
    "path": "Help/componenteditor/choices.html",
    "content": "﻿<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01//EN\" \"http://www.w3.org/TR/html4/strict.dtd\">\n<html>\n  <head>\n    <meta http-equiv=\"Content-Type\"content=\"text/html; charset=utf-8\">\n    <link href=\"../style.css\" rel=\"Stylesheet\" type=\"text/css\">\n    <title>Choices editor</title>\n  </head>\n  <body>\n    <h2>Choices editor</h2>\n    <p>\n      The choices editor lists the configuration elements of the component. A choice provides a set of \n      possible values for parameters, module parameters and other configurable elements within the \n      containing component.\n    </p>\n    <p>\n      Choices are identified by a mandatory <b>name</b> in the Choice list.\n    </p>\n    <p>\n      Each choice must have at least one <b>enumeration</b> defined. An <b>enumeration</b> has \n\t  a mandatory <b>value</b>, an optional <b>text</b> to display instead \n      of the value and an optional <b>description</b>. When the value of e.g. a parameter refers to the\n      choice, the possible model parameter value is selected from the set of enumerations in that choice.\n    </p>\n    <hr>\n\t<p>\n      EXAMPLE. The choice is used to limit the possible parameter values to 8, 16 or 32 (bits).<br>\n      <img src=\"../images/choiceExample.png\" alt=\"screen cap\">\n\t</p>\n  </body>\n</html>\n"
  },
  {
    "path": "Help/componenteditor/cominterface.html",
    "content": "<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01//EN\" \"http://www.w3.org/TR/html4/strict.dtd\">\n<html>\n  <head>\n    <meta http-equiv=\"Content-Type\"content=\"text/html; charset=utf-8\">\n    <link href=\"../style.css\" rel=\"Stylesheet\" type=\"text/css\">\n    <title>COM interface editor</title>\n  </head>\n  <body>\n    <h2>COM interface editor</h2>\n    <p>\n      This is Kactus2 extension <br><img\n      src=\"../images/appicon.png\"><br> Each interface has a mandatory\n      <b>name</b>. <b>Display name</b> is optional and typically a few\n      words providing a more detailed and/or user-friendly name for\n      display. Optional <b>description</b> contains a textual\n      description of the interface.\n    </p>\n    <p>\n      Optional <b>COM definition</b> is a XML document that captures\n      the interface properties, similarly to bus interfaces in regular\n      HW components. You can type the VLNV or drag-drop a COM\n      definition from the library.\n    </p>\n    <p>\n      <b>Details</b> are settings that are specific to selected COM\n      definition. Optional <b>transfer type</b> denotes what kind of\n      data is transmitted through the interface. The allowed values\n      depend on the selected COM definition, e.g. in MCAPI they are\n      'message', 'packet', and 'scalar'. At least MCAPI has also a\n      <b>Direction</b> (in, out, inout).\n    </p>\n    <p>\n      <b>Property values</b> define values for the parameters as\n      name-value pairs. For example in MCAPI, each endpoint must have\n      a 'port_id'.\n    </p>\n  </body>\n</html>\n"
  },
  {
    "path": "Help/componenteditor/cominterfaces.html",
    "content": "<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01//EN\" \"http://www.w3.org/TR/html4/strict.dtd\">\n<html>\n  <head>\n    <meta http-equiv=\"Content-Type\"content=\"text/html; charset=utf-8\">\n    <link href=\"../style.css\" rel=\"Stylesheet\" type=\"text/css\">\n    <title>COM interfaces editor</title>\n  </head>\n  <body>\n    <h2>COM interfaces editor</h2>\n    <p>\n      This is Kactus2 extension <br><img\n      src=\"../images/appicon.png\"><br><br> <i>COM interface</i> means\n      that component supports an optional \"high-level\" communication\n      mechanism, such as MCAPI. Purpose is to increase portability by\n      abstacting the details of communication. COM interfaces are\n      connected together in <b>system view</b> of the Kactus. Usually,\n      these interfaces a part of a SW component, but some HW\n      components can support them also. COM interfaces makes only\n      loose coupling between SW components, and consequently the\n      receiver can be mapped on different CPU than sender. COM\n      interfaces are meant for communication between application\n      modules, whereas API interfaces are mainly between application\n      and platform (OS, drivers) and inside the platform.\n    </p>\n    <p>\n      Each interface has a mandatory <b>name</b> and <b>direction</b>\n      (in, out, inout). Optional <b>COM definition</b> is an XML\n      document that captures the interface properties, similarly to\n      bus interfaces in regular HW components. Note that this\n      information is just shown here and can be edited on interface\n      editor.  Optional <b>transfer type</b> denotes what kind of data\n      is transmitted through the interface. The allowed values depend\n      on the selected COM definition.\n    </p>\n    <p>\n      For example, a SW component could have an input COM interface\n      'data_in' and output called 'result_out'. Then depending of how\n      the channels are conencted in system design, the imput data can\n      come from, say, UART or CPU. Similarly, the result can be\n      directed to, say, memory or VGA. Here both interfaces correspond\n      to MCAPI endpoints and transmit 'MCAPI messages'.<br> <img\n      src=\"../images/com_interfaces.png\" alt=\"screen_cap\"><br>\n    </p>\n  </body>\n</html>\n"
  },
  {
    "path": "Help/componenteditor/componentInstantiation.html",
    "content": "﻿<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01//EN\" \"http://www.w3.org/TR/html4/strict.dtd\">\r\n<html>\r\n  <head>\r\n    <meta http-equiv=\"Content-Type\"content=\"text/html; charset=utf-8\">\r\n    <link href=\"../style.css\" rel=\"Stylesheet\" type=\"text/css\">\r\n    <title>Component instantiation editor</title>\r\n  </head>\r\n  <body>\r\n    <h2>Component instantiation editor</h2>\r\n    <p>\r\n        <b>Component instantiation</b> defines how a specific component instance is associated with a <i>view</i>.\r\n        This editor can be used to edit the details of a component instantiation.\r\n    </p>\r\n    <p>\r\n\t    <b>Name</b> is a mandatory identifier for the <i>component instantiation</i>.\r\n    </p>\r\n    <p>\r\n        <b>Display name</b> is an optional and used for a more user-friendly identifier.\r\n    </p>\r\n    <p>\r\n        <b>Description</b> is an optional field for textual description of the <i>component instantiation</i>.\t\t\r\n    </p>\r\n    <h3>Implementation details</h3>\r\n    <p>\r\n        <b>Language</b> specifies the HDL used for a specific instantiation, for example, verilog or vhdl. \n\t\t<b>Strict</b> determines if the language shall be strictly enforced.\r\n    </p>\r\n    <p>\r\n        <b>Library</b> specifies the library name in which the model should be compiled.\r\n    </p>\r\n    <p>\r\n        <b>Package</b> describes the VHDL package containing the interface of the model. Defaults to the component \r\n        VLNV name concatenated with the postfix _cmp_pkg, which stands for component package.\r\n    </p>\r\n    <p>\r\n        <b>Module name</b> describes the Verilog, SystemVerilog or SystemC module name or the VHDL entity name.\r\n        Defaults to the component VLNV name.\r\n    </p>\r\n    <p>\r\n        <b>Architecture</b> describes the VHDL architecture name. Defaults to rtl.\r\n    </p>\r\n    <p>\r\n        <b>Configuration</b> describes the Verilog, SystemVerilog or VHDL configuration name. Defaults to the \r\n        design configuration VLNV name of the design configuration referenced in the view, or to the component \r\n        VLNV name concatenated with the postfix _rtl_cfg.\r\n    </p>\r\n\t\r\n    <h3>File set references</h3>\r\n    <p>\r\n        File set references is an optional list of <i>file set</i> names that are associated with the\r\n\t\t<i>component instance</i>. For example, the file set containing the RTL implementation file(s)\r\n\t\tof the module detailed in Implementation details could be referenced.\r\n    </p>\r\n\r\n    <h3>Default file build commands</h3>\r\n    <p>\r\n        <b>Default file build commands</b> is a list of build options for the <b>file sets</b> \r\n        referenced in the containing <b>view</b>.\r\n    </p>\r\n    <p>\r\n        <b>File type</b> defines which files are build by the given command.\r\n    </p>\r\n    <p>\r\n        <b>Build command</b> defines how to build the files within the file set by e.g. \n\t\trunning 'gcc' for C files or 'vcom' for VHDL.\r\n    </p>\r\n    <p>\r\n        <b>Flags</b> define the command line options for the command e.g. '-Wall'.\r\n    </p>\r\n    <p>\r\n        <b>Replace default flags</b> selects whether the given flags override the flags \n\t\tdefined in the target <i>file</i> or are they \r\n        appended to them. Replace default flags can be given as an expression, \n\t\tbut it must evaluate to 1 or 0.\r\n    </p>\r\n    <p>\r\n        The defult file build commands contains a context menu, with the following functionalities:\r\n    </p>\r\n    <ul>\r\n      <li>Add new build command (Add row)</li>\r\n      <li>Remove build command (Remove row)</li>\r\n      <li>Clear the selected cells</li>\r\n      <li>Copy the contents of the selected cells to clipboard</li>\r\n      <li>Paste the contents of the clipboard to the selected cells</li>\r\n    </ul>\r\n    <h3>Module parameters</h3>\r\n    <p>\r\n        Module parameters editor can be used to add, remove and modify module parameters. Module parameters are \r\n        often used in HDL to configure component instances. They represent e.g VHDL  generics and Verilog \r\n        parameters.\r\n    </p>\r\n    <p>\r\n        All columns of the editor are editable.  Double-clicking an empty space adds a new row.\r\n    </p>\r\n    <p>\r\n        <b>Name</b> column is mandatory. <b>Display name</b> provides a more user-friendly name for the module \r\n        parameter. <b>Description</b> is free text for further details.\r\n    </p>\r\n\t<p>\r\n        Legal <b>data type</b> depends on the language of the model. For  example in VHDL this could be 'integer' \r\n        or 'std_logic', whereas in C-language int or 'char*' could be used. \r\n\t</p>\r\n    <p>\r\n        <b>Type</b> is an optional constraint for the type to which the module parameter value resolves. \r\n        Possible types are:\r\n    </p>\r\n    <ul>\r\n        <li><b>bit</b> indicates that the value shall resolve to a System Verilog bit, which by default is \r\n        resolved to a 1-bit value, unless a vector size has been specified.</li>\r\n\r\n        <li><b>byte</b> indicates that the value shall resolve to a System Verilog byte, which is resolved to an \r\n        8-bit integer value.</li>\r\n\r\n        <li><b>shortint</b> indicates that the value shall resolve to a System Verilog shortint, which is resolved \r\n        to a 16-bit integer value.</li>\r\n\t\t\r\n\t\t<li><b>int</b> indicates that the value shall resolve to a System Verilog int, which is resolved to a \r\n        32-bit integer value.</li>\r\n\t\t\r\n\t\t<li><b>longint</b> indicates that the value shall resolve to a System Verilog longint, which is resolved \r\n        to a 64-bit integer value.</li>\r\n\t\t\r\n\t\t<li><b>shortreal</b> indicates that the value shall resolve to a System Verilog shorint, which is resolved \r\n        to a 32-bit floating point value. Both standard and scientific format (e.g 0.002 and 2e-3) are supported. \r\n        This type applies also to <b>minimum value</b> and <b>maximum value</b>.</li>\r\n\t\t\r\n\t\t<li><b>real</b> indicates that the value shall resolve to a System Verilog shortreal, which is resolved \r\n        to a 64-bit floating point value. Both standard and scientific format (e.g. 0.002 and 2e-3) are supported. \r\n        This type applies also to <b>minimum value</b> and <b>maximum value</b>.</li>\r\n\t\t\r\n\t\t<li><b>string</b> indicates that the value shall contain text.</li>\r\n    </ul>\r\n    <p>\r\n        <b>Value</b> contains the mandatory default value of the module parameter. This value can be overridden in \r\n        a design that instantiates this component. The value is given in SystemVerilog format and may be given as \r\n        an expression. Any other text must be enclosed within quotes e.g. \"Any text\".\r\n    </p>\r\n    <p>\r\n        By selecting a <b>choice</b>, the user can restrict the allowed module parameter values to a set of \r\n        predefined values. Possible values are defined in the choices of the containing component.\r\n    </p>\r\n    <p>\r\n        <b>Minimum value</b> and <b>maximum value</b> define the lower and upper boundary for the module parameter \r\n        value. If the selected type is <b>bit</b> or <b>string</b>, these fields have no effect.\r\n    </p>\r\n\t<p>\r\n\t    <b>OO usage</b> specifies how this model parameter is used. Default is 'non-typed' since such parameters \r\n        are found in all languages, i.e. all VHDL types are non-typed. 'Typed' parameters appear in \r\n        object-oriented languages, i.e. in C++.\r\n    </p>\r\n    <p>\r\n        <b>Resolve</b> specifies the configuration of the model parameter. Possible resolve values are:\r\n    </p>\r\n        <ul>\r\n        <li><b>immediate</b> indicates that the the value is defined within the containing component. The value \r\n        cannot be overridden by the user or a generator in design configuration. This is the default value</li>\r\n\r\n        <li><b>user</b> indicates that the user can override the default value in design configuration. Generators \r\n        are not allowed to change the value.</li>\r\n\r\n        <li><b>generated</b> indicates that the a generator can override the default value in design configuration.\r\n        </li>\r\n    </ul>\r\n    <p>\r\n        <b>Bit vector left</b> and <b>bit vector right</b> define the left and right bounds of the bit vector.\r\n        These are valid only for a bit type parameter. A valid bit vector requires both the left and the right bit \r\n        vector values.\r\n    </p>\r\n    <p>\r\n        <b>Array left</b> and <b>Array right</b> specify the left and right sides of array dimension for the \r\n        parameter in an output language e.g. Verilog. Both of these are vendor attributes. The values can be given \r\n        as an expression, but they must resolve into a decimal number. In order to get a valid array, both \r\n        <b>array left</b> and <b>array right</b> values must be given.\r\n    </p>\r\n\t<p>\r\n\t    <b>Usage count</b> displays the number of references made to this module parameter. Selecting the usage \r\n        count of a module parameter displays a reference analysis for it. The usage count can not be changed \r\n        manually.\r\n\t</p>\r\n    <p>\r\n        Module parameters editor contains a context menu (rigth mouse button) that has the following options:\r\n    </p>\r\n    <ul>\r\n      <li>Add new module parameter (Add row)</li>\r\n      <li>Remove module parameter (Remove row)</li>\r\n      <li>Clear the selected cells</li>\r\n      <li>Copy the contents of the selected cells to clipboard</li>\r\n      <li>Paste the contents of the clipboard to the selected cells</li>\r\n    </ul>\r\n    <h3>Parameters</h3>\r\n    <p>\r\n      <b>Parameters</b> are optional and can specify any parameter data value(s) specific for this component instantiation.\r\n      These parameters do <b>not</b> have direct connection to HDL, but may be used to configure IP-XACT elements, including the module parameters.\r\n      For more information on parameters, see the component parameter editor.\r\n    </p>\r\n    <hr/>\r\n  </body>\r\n</html>\r\n"
  },
  {
    "path": "Help/componenteditor/componentInstantiation2022.html",
    "content": "﻿<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01//EN\" \"http://www.w3.org/TR/html4/strict.dtd\">\n<html>\n  <head>\n    <meta http-equiv=\"Content-Type\"content=\"text/html; charset=utf-8\">\n    <link href=\"../style.css\" rel=\"Stylesheet\" type=\"text/css\">\n    <title>Component instantiation editor</title>\n  </head>\n  <body>\n    <h2>Component instantiation editor</h2>\n    <p>\n        <b>Component instantiation</b> defines how a specific component instance is associated with a <i>view</i>.\n        This editor can be used to edit the details of a component instantiation.\n    </p>\n    <p>\n\t    <b>Name</b> is a mandatory identifier for the <i>component instantiation</i>.\n    </p>\n    <p>\n        <b>Display name</b> is an optional and used for a more user-friendly identifier.\n    </p>\n    <p>\n        <b>Short description</b> is an optional field for a short description of the <i>component instantiation</i>.\t\t\n    </p>\n    <p>\n        <b>Description</b> is an optional field for textual description of the <i>component instantiation</i>.\t\t\n    </p>\n    <h3>Implementation details</h3>\n    <p>\n        <b>Language</b> specifies the HDL used for a specific instantiation, for example, verilog or vhdl. \n\t\t<b>Strict</b> determines if the language shall be strictly enforced.\n    </p>\n    <p>\n        <b>Library</b> specifies the library name in which the model should be compiled.\n    </p>\n    <p>\n        <b>Package</b> describes the VHDL package containing the interface of the model. Defaults to the component \n        VLNV name concatenated with the postfix _cmp_pkg, which stands for component package.\n    </p>\n    <p>\n        <b>Module name</b> describes the Verilog, SystemVerilog or SystemC module name or the VHDL entity name.\n        Defaults to the component VLNV name.\n    </p>\n    <p>\n        <b>Architecture</b> describes the VHDL architecture name. Defaults to rtl.\n    </p>\n    <p>\n        <b>Configuration</b> describes the Verilog, SystemVerilog or VHDL configuration name. Defaults to the \n        design configuration VLNV name of the design configuration referenced in the view, or to the component \n        VLNV name concatenated with the postfix _rtl_cfg.\n    </p>\n\t\n    <h3>File set references</h3>\n    <p>\n        File set references is an optional list of <i>file set</i> names that are associated with the\n\t\t<i>component instance</i>. For example, the file set containing the RTL implementation file(s)\n\t\tof the module detailed in Implementation details could be referenced.\n    </p>\n\n    <h3>Default file build commands</h3>\n    <p>\n        <b>Default file build commands</b> is a list of build options for the <b>file sets</b> \n        referenced in the containing <b>view</b>.\n    </p>\n    <p>\n        <b>File type</b> defines which files are build by the given command.\n    </p>\n    <p>\n        <b>Build command</b> defines how to build the files within the file set by e.g. \n\t\trunning 'gcc' for C files or 'vcom' for VHDL.\n    </p>\n    <p>\n        <b>Flags</b> define the command line options for the command e.g. '-Wall'.\n    </p>\n    <p>\n        <b>Replace default flags</b> selects whether the given flags override the flags \n\t\tdefined in the target <i>file</i> or are they \n        appended to them. Replace default flags can be given as an expression, \n\t\tbut it must evaluate to 1 or 0.\n    </p>\n    <p>\n        The defult file build commands contains a context menu, with the following functionalities:\n    </p>\n    <ul>\n      <li>Add new build command (Add row)</li>\n      <li>Remove build command (Remove row)</li>\n      <li>Clear the selected cells</li>\n      <li>Copy the contents of the selected cells to clipboard</li>\n      <li>Paste the contents of the clipboard to the selected cells</li>\n    </ul>\n    <h3>Module parameters</h3>\n    <p>\n        Module parameters editor can be used to add, remove and modify module parameters. Module parameters are \n        often used in HDL to configure component instances. They represent e.g VHDL  generics and Verilog \n        parameters.\n    </p>\n    <p>\n        All columns of the editor are editable.  Double-clicking an empty space adds a new row.\n    </p>\n    <p>\n        <b>Name</b> column is mandatory. <b>Display name</b> provides a more user-friendly name for the module \n        parameter. <b>Description</b> is free text for further details.\n    </p>\n\t<p>\n        Legal <b>data type</b> depends on the language of the model. For  example in VHDL this could be 'integer' \n        or 'std_logic', whereas in C-language int or 'char*' could be used. \n\t</p>\n    <p>\n        <b>Type</b> is an optional constraint for the type to which the module parameter value resolves. \n        Possible types are:\n    </p>\n    <ul>\n        <li><b>bit</b> indicates that the value shall resolve to a System Verilog bit, which by default is \n        resolved to a 1-bit value, unless a vector size has been specified.</li>\n\n        <li><b>byte</b> indicates that the value shall resolve to a System Verilog byte, which is resolved to an \n        8-bit integer value.</li>\n\n        <li><b>shortint</b> indicates that the value shall resolve to a System Verilog shortint, which is resolved \n        to a 16-bit integer value.</li>\n\t\t\n\t\t<li><b>int</b> indicates that the value shall resolve to a System Verilog int, which is resolved to a \n        32-bit integer value.</li>\n\t\t\n\t\t<li><b>longint</b> indicates that the value shall resolve to a System Verilog longint, which is resolved \n        to a 64-bit integer value.</li>\n\t\t\n\t\t<li><b>shortreal</b> indicates that the value shall resolve to a System Verilog shorint, which is resolved \n        to a 32-bit floating point value. Both standard and scientific format (e.g 0.002 and 2e-3) are supported. \n        This type applies also to <b>minimum value</b> and <b>maximum value</b>.</li>\n\t\t\n\t\t<li><b>real</b> indicates that the value shall resolve to a System Verilog shortreal, which is resolved \n        to a 64-bit floating point value. Both standard and scientific format (e.g. 0.002 and 2e-3) are supported. \n        This type applies also to <b>minimum value</b> and <b>maximum value</b>.</li>\n\t\t\n\t\t<li><b>string</b> indicates that the value shall contain text.</li>\n    </ul>\n    <p>\n        <b>Value</b> contains the mandatory default value of the module parameter. This value can be overridden in \n        a design that instantiates this component. The value is given in SystemVerilog format and may be given as \n        an expression. Any other text must be enclosed within quotes e.g. \"Any text\".\n    </p>\n    <p>\n        By selecting a <b>choice</b>, the user can restrict the allowed module parameter values to a set of \n        predefined values. Possible values are defined in the choices of the containing component.\n    </p>\n    <p>\n        <b>Minimum value</b> and <b>maximum value</b> define the lower and upper boundary for the module parameter \n        value. If the selected type is <b>bit</b> or <b>string</b>, these fields have no effect.\n    </p>\n\t<p>\n\t    <b>OO usage</b> specifies how this model parameter is used. Default is 'non-typed' since such parameters \n        are found in all languages, i.e. all VHDL types are non-typed. 'Typed' parameters appear in \n        object-oriented languages, i.e. in C++. 'Runtime' parameters are parameters, whose value is set at run-time.\n    </p>\n    <p>\n        <b>Resolve</b> specifies the configuration of the model parameter. Possible resolve values are:\n    </p>\n        <ul>\n        <li><b>immediate</b> indicates that the the value is defined within the containing component. The value \n        cannot be overridden by the user or a generator in design configuration. This is the default value</li>\n\n        <li><b>user</b> indicates that the user can override the default value in design configuration. Generators \n        are not allowed to change the value.</li>\n\n        <li><b>generated</b> indicates that the a generator can override the default value in design configuration.\n        </li>\n    </ul>\n    <p>\n        <b>Bit vector left</b> and <b>bit vector right</b> define the left and right bounds of the bit vector.\n        These are valid only for a bit type parameter. A valid bit vector requires both the left and the right bit \n        vector values.\n    </p>\n    <p>\n        <b>Array left</b> and <b>Array right</b> specify the left and right sides of array dimension for the \n        parameter in an output language e.g. Verilog. Both of these are vendor attributes. The values can be given \n        as an expression, but they must resolve into a decimal number. In order to get a valid array, both \n        <b>array left</b> and <b>array right</b> values must be given.\n    </p>\n\t<p>\n\t    <b>Usage count</b> displays the number of references made to this module parameter. Selecting the usage \n        count of a module parameter displays a reference analysis for it. The usage count can not be changed \n        manually.\n\t</p>\n    <p>\n        Module parameters editor contains a context menu (rigth mouse button) that has the following options:\n    </p>\n    <ul>\n      <li>Add new module parameter (Add row)</li>\n      <li>Remove module parameter (Remove row)</li>\n      <li>Clear the selected cells</li>\n      <li>Copy the contents of the selected cells to clipboard</li>\n      <li>Paste the contents of the clipboard to the selected cells</li>\n    </ul>\n    <h3>Parameters</h3>\n    <p>\n      <b>Parameters</b> are optional and can specify any parameter data value(s) specific for this component instantiation.\n      These parameters do <b>not</b> have direct connection to HDL, but may be used to configure IP-XACT elements, including the module parameters.\n      For more information on parameters, see the component parameter editor.\n    </p>\n    <hr/>\n  </body>\n</html>\n"
  },
  {
    "path": "Help/componenteditor/componentInstantiations.html",
    "content": "﻿<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01//EN\" \"http://www.w3.org/TR/html4/strict.dtd\">\n<html>\n  <head>\n    <meta http-equiv=\"Content-Type\"content=\"text/html; charset=utf-8\">\n    <link href=\"../style.css\" rel=\"Stylesheet\" type=\"text/css\">\n    <title>Component instantiations editor</title>\n  </head>\n  <body>\n    <h2>Component instantiations editor</h2>\n    <p>\n        <b>Component instantiations</b> define how a specific component instance is associated with a <i>view</i>.\n        This editor can be used to add and remove component instantiations.\n    </p>\n    <p>\n        Each component instantiation contains a mandatory, unique <b>name</b>, a <b>display name</b> and a \n        textual <b>description</b> to identify the component instantiations.\n    </p>\n    <p>\n        <b>Language</b> specifies the HDL used for a specific instantiation, for example, verilog or vhdl.\n    </p>\n    <p>\n        Component instantiations editor contains a context menu (right mouse button) providing following options:\n    </p>\n    <ul>\n      <li>Add new instantiation (Add row)</li>\n      <li>Remove instantiation (Remove row)</li>\n      <li>Clear the selected cells</li>\n      <li>Copy the contents of the selected cells to clipboard</li>\n      <li>Paste the contents of the clipboard to the selected cells</li>\n    </ul>\n  </body>\n</html>\n"
  },
  {
    "path": "Help/componenteditor/componenteditor.html",
    "content": "<!DOCTYPE html> \n<html lang=\"en\">\n<head>\n    <meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">\n    <title>Component</title>\n    <link href=\"style.css\" rel=\"stylesheet\" type=\"text/css\">\n</head>\n<body>\n\n<h2>Component</h2>\n\n<p>An IP-XACT component describes data of any component, both flat and hierarchical, hardware and software. Most importantly it describes components external interface, such as ports and parameters, but also internal features, such as remap state and memory maps. On the other hand, many properties are parametrizable, and thus tied to the external interface.</p>\n\n<p>A component may also refer to non-IP-XACT files, such as HDL source files and documentation. Thus components are vital for integration with non-IP-XACT tools and formats.</p>\n\n</body>\n</html>"
  },
  {
    "path": "Help/componenteditor/cpu.html",
    "content": "﻿<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01//EN\" \"http://www.w3.org/TR/html4/strict.dtd\">\n<html>\n  <head>\n    <meta http-equiv=\"Content-Type\"content=\"text/html; charset=utf-8\">\n    <link href=\"../style.css\" rel=\"Stylesheet\" type=\"text/css\">\n    <title>CPU editor</title>\n  </head>\n  <body>\n    <h2>CPU editor</h2>\n    <p>\n      The cpu editor can be used to edit the details of a cpu within a component.\n    </p>\n\t<p>\n\t    <b>Name</b> is a mandatory identifier for the <i>cpu</i>.\n    </p>\n    <p>\n        <b>Display name</b> is an optional and used for a more user-friendly identifier.\n    </p>\n    <p>\n      <b>Description</b> is an optional field for textual description of the <i>cpu</i>.\t\t\n    </p>\n    \n    <h3>General settings</h3>\n\n    <p>\n      <b>Is present</b> is optional and allows the enabling/disabling of a <i>cpu</i> presence \n      in the <i>component</i>. Value 1 indicates that the <i>cpu</i> is present in the \n      <i>component</i> whereas value 0 marks the <i>cpu</i> to be treated as if it does not exist. \n      Is present can be given as a SystemVerilog expression, but it must evaluate to 1 or 0.\n    </p>\n\n    <p>\n      <b>Address spaces</b> specify the logical address space(s) of the cpu.\n        When a master <i>bus interface</i>\n        of a component references the same address spaces, there's a\n        link link between the programmable core and the interface. This\n        information helps in generating a board support\n        package (BSP) and picking appropriate programmable components\n        into system design. CPU definition should not be repeated on a\n        higher level component (one that instantiates a CPU).\n    </p>\n\n  </body>\n</html>\n"
  },
  {
    "path": "Help/componenteditor/cpu2022.html",
    "content": "﻿<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01//EN\" \"http://www.w3.org/TR/html4/strict.dtd\">\n<html>\n  <head>\n    <meta http-equiv=\"Content-Type\"content=\"text/html; charset=utf-8\">\n    <link href=\"../style.css\" rel=\"Stylesheet\" type=\"text/css\">\n    <title>CPU editor</title>\n  </head>\n  <body>\n    <h2>CPU editor</h2>\n    <p>\n      The cpu editor can be used to edit the details of a cpu within a component.\n    </p>\n\t<p>\n\t    <b>Name</b> is a mandatory identifier for the <i>cpu</i>.\n    </p>\n    <p>\n        <b>Display name</b> is an optional and used for a more user-friendly identifier.\n    </p>\n    <p>\n      <b>Short description</b> is an optional field for compact description of the <i>cpu</i>.\n    </p>\n    <p>\n      <b>Description</b> is an optional field for textual description of the <i>cpu</i>.\t\t\n    </p>\n    \n    <h3>General settings</h3>\n\n    <p>\n      <b>Memory map</b> is mandatory and maps the address space defined by range and \n      width to a <i>memory map</i> in the <i>component</i>.\n    </p>\n\n    <p>\n      <b>Range</b> is mandatory and defines the address range in the memory map\n      accessible by the <i>cpu</i>.\n    </p>\n      \n    <p>\n      <b>Width</b> is mandatory and defines the bit width of a row in the memory\n      map for the <i>cpu</i>.\n    </p>\n\n    <p>\n      <b>Address unit bits</b> (AUB)  is an optinal field that defines the number \n      of data bits each address increment in the address space contains. \n      The default setting for a <i>cpu</i> address space is byte addressable (8 bits).\n    </p>\n\n    <h3>Regions</h3>\n    <p>\n      Regions editor can be used to describe sections of the address space available\n      for the <i>cpu</i> by splitting it into smaller <i>regions</i>.\n    </p>\n\n    <p>\n\t    <b>Name</b> is a mandatory identifier for the <i>region</i>.\n    </p>\n    <p>\n        <b>Display name</b> is an optional and used for a more user-friendly identifier.\n    </p>\n    <p>\n      <b>Short description</b> is an optional field for compact description of the <i>region</i>.\n    </p>\n    <p>\n      <b>Offset</b> is mandatory and defines the starting address of the <i>region</i> in address unit bits.\n\t</p>\n\t<p>\n\t\t<b>Range</b> is mandatory and defines the size of the <i>region</i> in address unit bits.\n    </p>\n    <p>\n      <b>Description</b> is an optional field for textual description of the <i>region</i>.\t\t\n    </p>\n\n    <p>\n      Regions editor provides a context menu (right mouse button) with\n      the following options:\n    </p>\n    <ul>\n      <li>Add new region (Add row)</li>\n      <li>Remove region (Remove row)</li>\n      <li>Clear the selected cells</li>\n      <li>Copy the contents of the selected cells to clipboard</li>\n      <li>Paste the contents of the clipboard to the selected cells</li>\n      <li>Copy selected element to clipboard (Copy elements)</li>\n      <li>Paste the element from the clipboard (Paste elements)</li>\t  \n      <li>Import a csv-file to the editor</li>\n      <li>Export the contents of the editor to a csv-file</li>\n    </ul>\n\n  </body>\n</html>\n"
  },
  {
    "path": "Help/componenteditor/cpus.html",
    "content": "﻿<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01//EN\" \"http://www.w3.org/TR/html4/strict.dtd\">\n<html>\n  <head>\n    <meta http-equiv=\"Content-Type\"content=\"text/html; charset=utf-8\">\n    <link href=\"../style.css\" rel=\"Stylesheet\" type=\"text/css\">\n    <title>CPUs editor</title>\n  </head>\n  <body>\n    <h2>CPUs editor</h2>\n    <p>\n      The cpus editor lists the programmable cores the component\n      contains. This way the tools can recognize them and distinguish\n      from hardwired components. One component can have multiple cores.\n    </p>\n\t<p>\n\t    <b>Name</b> is a mandatory identifier for the <i>cpu</i>.\n    </p>\n    <p>\n        <b>Display name</b> is an optional and used for a more user-friendly identifier.\n    </p>\n    <p>\n\t  <b>Address space references</b> specify the logical address space of the cpu. \n      When a master <i>bus interface</i> of a component references the same address \n      spaces, there's a link link between the programmable core and the interface.\n      This information helps in generating a board support\n      package (BSP) and picking appropriate programmable components\n      into system design. CPU definition should not be repeated on a\n      higher level component (one that instantiates a CPU).\n    </p>\n\t<p>\n        <b>Description</b> is an optional field for textual description of the <i>cpu</i>.\t\t\n    </p>\n    <p>\n      Cpus editor provides a context menu (right mouse button) with\n      the following options:\n    </p>\n    <ul>\n      <li>Add new cpu (Add row)</li>\n      <li>Remove cpu (Remove row)</li>\n      <li>Clear the selected cells</li>\n      <li>Copy the contents of the selected cells to clipboard</li>\n      <li>Paste the contents of the clipboard to the selected cells</li>\n      <li>Import a csv-file to the editor</li>\n      <li>Export the contents of the editor to a csv-file</li>\n    </ul>\n    <hr>\n    <p>\n      EXAMPLE.\n      Example SoC has two CPUs and both refer to an address space. \n      The first CPU is bound to a master bus interface through address space \n      AS0 whereas the second has only a local memory map in AS1. \n      Consequently, cpuA has access to the global address space of \n      the master bus interface and cpuB does not.<br>\n      <img src=\"../images/cpus.png\" alt=\"example\">\n    </p>\n  </body>\n</html>\n"
  },
  {
    "path": "Help/componenteditor/cpus2022.html",
    "content": "﻿<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01//EN\" \"http://www.w3.org/TR/html4/strict.dtd\">\n<html>\n  <head>\n    <meta http-equiv=\"Content-Type\"content=\"text/html; charset=utf-8\">\n    <link href=\"../style.css\" rel=\"Stylesheet\" type=\"text/css\">\n    <title>CPUs editor</title>\n  </head>\n  <body>\n    <h2>CPUs editor</h2>\n    <p>\n      The cpus editor lists the programmable cores the component\n      contains. This way the tools can recognize them and distinguish\n      from hardwired components. One component can have multiple cores.\n    </p>\n\t<p>\n\t    <b>Name</b> is a mandatory identifier for the <i>cpu</i>.\n    </p>\n    <p>\n        <b>Display name</b> is an optional and used for a more user-friendly identifier.\n    </p>\n    <p>\n      <b>Short description</b> is an optional field for compact description of the <i>cpu</i>.\n    </p>\n    <p>\n      <b>Memory map reference</b> is mandatory and maps the address space defined \n      by range and width to a <i>memory map</i> in the <i>component</i>.\n    </p>\n    <p>\n      <b>Range</b> </b> is mandatory and defines the address range in the memory\n      map accessible by the <i>cpu</i>.\n    </p>\n    <p>\n      <b>Width</b> is mandatory and defines the bit width of a row in the memory\n      map for the <i>cpu</i>.\n    </p>\n    <p>\n      <b>Address unit bits</b> (AUB) is an optinal field that defines the number \n      of data bits each address increment in the address space contains. \n      The default setting for a <i>cpu</i> address space is byte addressable (8 bits).\n    </p>\n\t<p>\n        <b>Description</b> is an optional field for textual description of the <i>cpu</i>.\t\t\n    </p>\n    <p>\n      Cpus editor provides a context menu (right mouse button) with\n      the following options:\n    </p>\n    <ul>\n      <li>Add new cpu (Add row)</li>\n      <li>Remove cpu (Remove row)</li>\n      <li>Clear the selected cells</li>\n      <li>Copy the contents of the selected cells to clipboard</li>\n      <li>Paste the contents of the clipboard to the selected cells</li>\n      <li>Import a csv-file to the editor</li>\n      <li>Export the contents of the editor to a csv-file</li>\n    </ul>\n    <hr>\n    <p>\n      EXAMPLE.\n      Example SoC has two CPUs and both refer to a memory map. \n      The first memory map is bound to an initiator bus interface using\n      a subspace map whereas the second has only a memory map with registers. \n      Consequently, cpuA has access to the global address space of the \n      initiator bus interface and cpuB does not.<br>\n      <img src=\"../images/cpus22.png\" alt=\"example\">\n    </p>\n  </body>\n</html>\n"
  },
  {
    "path": "Help/componenteditor/designConfigurationInstantiation.html",
    "content": "﻿<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01//EN\" \"http://www.w3.org/TR/html4/strict.dtd\">\n<html>\n  <head>\n    <meta http-equiv=\"Content-Type\"content=\"text/html; charset=utf-8\">\n    <link href=\"../style.css\" rel=\"Stylesheet\" type=\"text/css\">\n    <title>Design configuration instantiation editor</title>\n  </head>\n  <body>\n    <h2>Design configuration instantiation editor</h2>\n    <p>\n        <b>Design configuration instantiations</b> detail how a specific design configuration instance is \n        associated with a <i>view</i>. This editor can be used to edit the details of a single design configuration \n        instantiation.\n    </p>\n    <p>\n\t    <b>Name</b> is a mandatory identifier for the <i>design configuration instantiation</i>.\n    </p>\n    <p>\n        <b>Display name</b> is an optional and used for a more user-friendly identifier.\n    </p>\n    <p>\n      <b>Description</b> is an optional field for textual description of the <i>design configuration instantiation</i>.\t\t\n    </p>\n    <p>\n        <b>Design configuration reference</b> specifies the used design configuration.\n    </p>\n     <p>\n        <b>Configurable element values</b>\n        are instance-specific configuration options. It shows all the design configuration <i>parameters</i>.\n        The <b>value</b> can be set to override the <b>default value</b> in the design configuration.\n        The value is editable only, if the parameter resolve-property is set to 'user' or 'generated' within\n        the design configuration. By default parameters that cannot be \n        edited are filtered out, but will be shown when <b>Show immediate values</b> is selected.\n    </p>\n    <p>\n      <b>Parameters</b> are optional and can specify any parameter data value(s) specific for this design configuration instantiation.\n      For more information on parameters, see the component parameter editor.\n    </p>\n  </body>\n</html>\n"
  },
  {
    "path": "Help/componenteditor/designConfigurationInstantiation2022.html",
    "content": "﻿<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01//EN\" \"http://www.w3.org/TR/html4/strict.dtd\">\n<html>\n  <head>\n    <meta http-equiv=\"Content-Type\"content=\"text/html; charset=utf-8\">\n    <link href=\"../style.css\" rel=\"Stylesheet\" type=\"text/css\">\n    <title>Design configuration instantiation editor</title>\n  </head>\n  <body>\n    <h2>Design configuration instantiation editor</h2>\n    <p>\n        <b>Design configuration instantiations</b> detail how a specific design configuration instance is \n        associated with a <i>view</i>. This editor can be used to edit the details of a single design configuration \n        instantiation.\n    </p>\n    <p>\n\t    <b>Name</b> is a mandatory identifier for the <i>design configuration instantiation</i>.\n    </p>\n    <p>\n        <b>Display name</b> is an optional and used for a more user-friendly identifier.\n    </p>\n    <p>\n      <b>Short description</b> is an optional field for compact description of the <i>design configuration instantiation</i>.\n    </p>\n    <p>\n      <b>Description</b> is an optional field for textual description of the <i>design configuration instantiation</i>.\t\t\n    </p>\n    <p>\n        <b>Design configuration reference</b> specifies the used design configuration.\n    </p>\n     <p>\n        <b>Configurable element values</b>\n        are instance-specific configuration options. It shows all the design configuration <i>parameters</i>.\n        The <b>value</b> can be set to override the <b>default value</b> in the design configuration.\n        The value is editable only, if the parameter resolve-property is set to 'user' or 'generated' within\n        the design configuration. By default parameters that cannot be \n        edited are filtered out, but will be shown when <b>Show immediate values</b> is selected.\n    </p>\n    <p>\n      <b>Parameters</b> are optional and can specify any parameter data value(s) specific for this design configuration instantiation.\n      For more information on parameters, see the component parameter editor.\n    </p>\n  </body>\n</html>\n"
  },
  {
    "path": "Help/componenteditor/designConfigurationInstantiations.html",
    "content": "﻿<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01//EN\" \"http://www.w3.org/TR/html4/strict.dtd\">\n<html>\n  <head>\n    <meta http-equiv=\"Content-Type\"content=\"text/html; charset=utf-8\">\n    <link href=\"../style.css\" rel=\"Stylesheet\" type=\"text/css\">\n    <title>Design configuration instantiations editor</title>\n  </head>\n  <body>\n    <h2>Design configuration instantiations editor</h2>\n    <p>\n        <b>Design configuration instantiations</b> detail how a specific design configuration instance is \n        associated with a <i>view</i>. This editor can be used to add and remove design configuration \n        instantiations.\n    </p>\n    <p>\n        Each design configuration instantiation contains a mandatory, unique <b>name</b>, a \n        <b>display name</b> and a textual <b>description</b> to identify the design configuration instantiations.\n    </p>\n    <p>\n        <b>Design configuration reference</b> specifies the used design configuration.\n    </p>\n    <p>\n        Design configuration instantiations editor contains a context menu (right mouse button) providing \n        following options:\n    </p>\n    <ul>\n      <li>Add new instantiation (Add row)</li>\n      <li>Remove instantiation (Remove row)</li>\n      <li>Clear the selected cells</li>\n      <li>Copy the contents of the selected cells to clipboard</li>\n      <li>Paste the contents of the clipboard to the selected cells</li>\n    </ul>\n  </body>\n</html>\n"
  },
  {
    "path": "Help/componenteditor/designInstantiation.html",
    "content": "﻿<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01//EN\" \"http://www.w3.org/TR/html4/strict.dtd\">\n<html>\n  <head>\n    <meta http-equiv=\"Content-Type\"content=\"text/html; charset=utf-8\">\n    <link href=\"../style.css\" rel=\"Stylesheet\" type=\"text/css\">\n    <title>Design instantiation editor</title>\n  </head>\n  <body>\n    <h2>Design instantiation editor</h2>\n    <p>\n        <b>Design instantiations</b> specify how a specific design instance is associated with a view. This editor \n        can be used to edit the details of a single design instantiation.\n    </p>\n    <p>\n\t    <b>Name</b> is a mandatory identifier for the <i>design instantiation</i>.\n    </p>\n    <p>\n        <b>Display name</b> is an optional and used for a more user-friendly identifier.\n    </p>\n    <p>\n      <b>Description</b> is an optional field for textual description of the <i>design instantiation</i>.\t\t\n    </p>\n    <p>\n        <b>Design reference</b> details the design description and configuration values applied to it.\n    </p>\n    <p>\n        <b>Configurable element values</b>\n        are instance-specific configuration options. It shows all the design <i>parameters</i>.\n        The <b>value</b> can be set to override the <b>default value</b> in the design.\n        The value is editable only, if the parameter resolve-property is set to 'user' or 'generated' within\n        the design. By default parameters that cannot be \n        edited are filtered out, but will be shown when <b>Show immediate values</b> is selected.\n    </p>\n  </body>\n</html>\n"
  },
  {
    "path": "Help/componenteditor/designInstantiation2022.html",
    "content": "﻿<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01//EN\" \"http://www.w3.org/TR/html4/strict.dtd\">\n<html>\n  <head>\n    <meta http-equiv=\"Content-Type\"content=\"text/html; charset=utf-8\">\n    <link href=\"../style.css\" rel=\"Stylesheet\" type=\"text/css\">\n    <title>Design instantiation editor</title>\n  </head>\n  <body>\n    <h2>Design instantiation editor</h2>\n    <p>\n        <b>Design instantiations</b> specify how a specific design instance is associated with a view. This editor \n        can be used to edit the details of a single design instantiation.\n    </p>\n    <p>\n\t    <b>Name</b> is a mandatory identifier for the <i>design instantiation</i>.\n    </p>\n    <p>\n        <b>Display name</b> is an optional and used for a more user-friendly identifier.\n    </p>\n    <p>\n      <b>Short description</b> is an optional field for compact description of the <i>design instantiation</i>.\n    </p>\n    <p>\n      <b>Description</b> is an optional field for textual description of the <i>design instantiation</i>.\t\t\n    </p>\n    <p>\n        <b>Design reference</b> details the design description and configuration values applied to it.\n    </p>\n    <p>\n        <b>Configurable element values</b>\n        are instance-specific configuration options. It shows all the design <i>parameters</i>.\n        The <b>value</b> can be set to override the <b>default value</b> in the design.\n        The value is editable only, if the parameter resolve-property is set to 'user' or 'generated' within\n        the design. By default parameters that cannot be \n        edited are filtered out, but will be shown when <b>Show immediate values</b> is selected.\n    </p>\n  </body>\n</html>\n"
  },
  {
    "path": "Help/componenteditor/designInstantiations.html",
    "content": "﻿<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01//EN\" \"http://www.w3.org/TR/html4/strict.dtd\">\n<html>\n  <head>\n    <meta http-equiv=\"Content-Type\"content=\"text/html; charset=utf-8\">\n    <link href=\"../style.css\" rel=\"Stylesheet\" type=\"text/css\">\n    <title>Design instantiations editor</title>\n  </head>\n  <body>\n    <h2>Design instantiations editor</h2>\n    <p>\n        <b>Design instantiations</b> specify how a specific design instance is associated with a view. This \n        editor can be used to add and remove design instantiations.\n    </p>\n    <p>\n        Each design instantiation contains a mandatory, unique <b>name</b>, a <b>display name</b> and a \n        textual <b>description</b> to identify the design instantiations.\n    </p>\n    <p>\n        <b>Design reference</b> details the design description and configuration values applied to it.\n    </p>\n    <p>\n        Design instantiations editor contains a context menu (right mouse button) providing following options:\n    </p>\n    <ul>\n      <li>Add new instantiation (Add row)</li>\n      <li>Remove instantiation (Remove row)</li>\n      <li>Clear the selected cells</li>\n      <li>Copy the contents of the selected cells to clipboard</li>\n      <li>Paste the contents of the clipboard to the selected cells</li>\n    </ul>\n  </body>\n</html>\n"
  },
  {
    "path": "Help/componenteditor/field.html",
    "content": "﻿<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01//EN\" \"http://www.w3.org/TR/html4/strict.dtd\">\n<html>\n<head>\n    <meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />\n    <link href=\"../style.css\" rel=\"Stylesheet\" type=\"text/css\" />\n    <title>Field editor</title>\n</head>\n<body>\n    <h2>Field editor</h2>\n\n    <p>\n        The field editor is used to edit the details of a <i>field<i>. For example user may\n            define <i>enumerated values</i> that define the legal bit patterns of the <i>field<i>.\n    </p>\n\n    <p>\n        <b>Name</b> is a mandatory identifier for the <i>field</i>. The name must be unique\n        within all the <i>fields</i> of the containing <i>register</i>.\n    </p>\n    <p>\n        <b>Display name</b> is an optional and used for a more user-friendly identifier.\n    </p>\n    <p>\n        <b>Description</b> is an optional field for textual description of the <i>field</i>.\n    </p>\n\n    <h3>Field definition</h3>\n    <p>\n        <b>Offset</b> is mandatory and describes the starting bit of the <i>field</i> within\n        the containing <i>register</i>.\n    </p>\n    <p>\n        <b>Width</b> is mandatory and speficies how many bits are included in the <i>field</i>.\n    </p>\n    <p>\n        <b>Is present</b> is optional and enables/disables a <i>field</i> presence in a\n        <i>register</i>. Value 1 indicates that the <i>field</i> is present in the <i>register</i>\n        whereas value 0 marks the <i>field</i> to be treated as if it does not exist. Is\n        present can be given as a SystemVerilog expression, but it must evaluate to 1 or\n        0.\n    </p>\n    <p>\n        <b>Field ID</b> is optional identifier for the <i>field</i>. Fields can be referenced\n        in <i>indirect interfaces</i> using this identifier.\n    </p>\n\n    <h3>Field constraints</h3>\n    <p>\n        <b>Volatile</b> is optional and indicates that the <i>field</i> may change its value\n        without write operations.\n    </p>\n    <p>\n        <b>Access</b> is optional and specifies the accessability of the <i>field</i>. The\n        possible values are:\n    </p>\n    <ul>\n        <li><b>read-write</b>. Both read and write transactions may have an effect on this <i>\n            field</i>. Write transactions may affect the contents of the <i>field</i>, and read\n            transactions return a value related to the <i>field</i>.</li>\n        <li><b>read-only</b>. A read transaction to this <i>field</i> returns a value related\n            to the value in the <i>field</i>. A write transaction to this <i>field</i> has undefined\n            results.</li>\n        <li><b>write-only</b>. A write transaction to this address affects the contents of the\n            <i>field</i>. A read transaction to this <i>field</i> has undefined results.</li>\n        <li><b>read-writeOnce</b>. Both read and write transactions may have an effect on this\n            <i>field</i>. Only the first write transaction may affect the contents of the <i>field</i>,\n            and read transactions return a value related to the values in the <i>field</i>.</li>\n        <li><b>writeOnce</b>. Only the first write transaction affects the contents of this\n            <i>field</i>.</li>\n    </ul>\n    <p>\n        <b>Modified write value</b> is optional and describes how the data in the <i>field</i>\n        is manipulated on a write operation. The basic operation without any setting is\n        to store the written value 'as is'. Moreover, both bitwise and field-wise set/clear/toggle\n        is also possible. The possible values are:\n    </p>\n    <ul>\n        <li><b>oneToClear</b>. Each written '1' bit will assign the corresponding bit to '0'.</li>\n        <li><b>oneToSet</b>. Each written '1' bit will assign the corresponding bit to '1'.</li>\n        <li><b>oneToToggle</b>. Each written '1' bit will toggle the corresponding bit.</li>\n        <li><b>zeroToClear, zeroToSet, zeroToToggle</b>. Similar to previous ones, except that\n            written '0' bit triggers the action.</li>\n        <li><b>clear</b>. Each write operation will clear all bits in the <i>field</i> to '0'.</li>\n        <li><b>set</b>. Each write operation will set all bits in the <i>field</i> to '1'.</li>\n        <li><b>modify</b>. Indicates that after a write operation, all bits in the <i>field</i>\n            can be modified.</li>\n        <li><b>'&nbsp; ' (empty setting)</b>. Indicates that the value written to a <i>field</i>\n            is the value stored in the <i>field</i>. This is the default value.</li>\n    </ul>\n    <p>\n        <b>Read action</b> is optional and specifies if some action happens to the <i>field</i>\n        after a read operation. By default the <i>field</i> is unmodified. The possible\n        values are:\n    </p>\n    <ul>\n        <li><b>clear</b>. All bits in the <i>field</i> are cleared to '0' after a read operation.</li>\n        <li><b>set</b>. All bits in the <i>field</i> are set to '1' after a read operation.</li>\n        <li><b>modify</b>. Indicates that the bits of the <i>field</i> are modified in some\n            way after a read operation.</li>\n        <li><b>'&nbsp; ' (empty setting)</b>. Indicates that the <i>field</i> is not modified\n            after a read operation. This is the default.</li>\n    </ul>\n    <p>\n        <b>Testable</b> is optional and specifies if the <i>field</i> is testable by an\n        automated register test.\n    </p>\n    <p>\n        <b>Test constraint</b> is optional and specifies the constaints for the automated\n        tests for the <i>field</i>. The possible values are:\n    </p>\n    <ul>\n        <li><b>unConstrained</b>. There are no constraints for the written or read data. This\n            is the default setting.</li>\n        <li><b>Restore</b>. The <i>field</i> value must be restored to its original value before\n            accessing another register. </li>\n        <li><b>WriteAsRead</b>. The data written to a <i>field</i> must be same that was read\n            previously from the <i>field</i></li>\n        <li><b>ReadOnly</b>. Indicates that the <i>field</i> can only be read.</li>\n    </ul>\n    <p>\n        The <b>write value constraint</b>s are used to define what are the legal values\n        user may write to a <i>field</i>. The possible values are:\n        <ul>\n            <li><b>No constraints</b>. Indicates that there are no constraints to values to be written.</li>\n            <li><b>Write as read</b>. Inidcates that only legal values to be written are the same\n                that were previously read from the field.</li>\n            <li><b>Use enumerated values</b>. Indicates that the defined enumerated values are the\n                only legal values that can be written.</li>\n            <li><b>Set minimum and maximum limits</b>. Indicates that the minimum and maximum limits\n                can be set for the value written to the <i>field</i>.</li>\n        </ul>\n    </p>\n\n\t<h3>Resets</h3>\n\t<p>\n\t\t<i>Resets</i> describe the reset values of the <i>field</i>. Each reset has the following subelements:\n\t\t<ul>\n\t\t\t<li><b>Reset type reference</b>. Identifies the defined reset. This should correspond to a\n\t\t\t\tuser-defined reset type element. Default value is HARD, and only one reset can be defined as that.</li>\n\t\t\t<li><b>Reset value</b> is mandatory and defines the actual reset value on reset. Reset value uses\n\t\t\t\tSystemVerilog syntax for binary values. The number of bits must be equal to the <i>field</i> size.</li>\n\t\t\t<li><b>Reset mask</b> is optional and defines the bits that have a known reset value. Bit\n\t\t\t\tvalue of 1 means that the corresponding bit has a known reset value whereas 0 means that\n\t\t\t\tthe value is unknown. Reset mask uses SystemVerilog syntax for binary values e.g. 'b1011,\n\t\t\t\t4'b1011, and 4'b10_11 are all valid values. The number of bits must be equal to the <i>field</i> size.</li>\n\t\t</ul>\n\t</p>\n\t\n    <h3>Enumerations table</h3>\n    <p>\n        The enumerated values table enables the defining of bit patterns that can be identified\n        by a name. This can be used to define the legal bit patterns for a field or to define\n        some default settings to help configuration of the field.\n    </p>\n\n    <p>\n        Each enumeration contains a unique <b>name</b> of the enumeration (mandatory), an\n        optional <b>display name</b> and <b>description</b>.\n    </p>\n    <p>\n        <b>Value</b> defines the value to assign to the specified name (mandatory).\n    </p>\n    <p>\n        <b>Usage</b> defines the software access condition under which this name value pair\n        is valid. Possible values are: <i>read</i>, <i>write</i> and <i>read-write</i>.\n    </p>\n</body>\n</html>\n"
  },
  {
    "path": "Help/componenteditor/field2022.html",
    "content": "﻿<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01//EN\" \"http://www.w3.org/TR/html4/strict.dtd\">\n<html>\n<head>\n    <meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />\n    <link href=\"../style.css\" rel=\"Stylesheet\" type=\"text/css\" />\n    <title>Field editor</title>\n</head>\n<body>\n    <h2>Field editor</h2>\n\n    <p>\n        The field editor is used to edit the details of a <i>field<i>. For example user may \n        define <i>enumerated values</i> that define the legal bit patterns of the <i>field<i>.\n    </p>\n\n    <p>\n        <b>Name</b> is a mandatory identifier for the <i>field</i>. The name must be unique\n        within all the <i>fields</i> of the containing <i>register</i>.\n    </p>\n    <p>\n        <b>Display name</b> is an optional and used for a more user-friendly identifier.\n    </p>\n    <p>\n        <b>Short description</b> is an optional field for compact description of the <i>field</i>.\n    </p>\n    <p>\n        <b>Description</b> is an optional field for textual description of the <i>field</i>.\n    </p>\n\n    <h3>Field definition</h3>\n    <p>\n        <b>Offset</b> is mandatory and describes the starting bit of the <i>field</i> within\n        the containing <i>register</i>.\n    </p>\n    <p>\n        <b>Width</b> is mandatory and speficies how many bits are included in the <i>field</i>.\n    </p>\n    <p>\n        <b>Volatile</b> is optional and indicates that the <i>field</i> may change its value\n        without write operations.\n    </p>\n\n    \n\t<h3>Resets</h3>\n\t<p>\n        <i>Resets</i> describe the reset values of the <i>field</i>. Each reset has the following subelements:\n\t\t<ul>\n            <li><b>Reset type reference</b>. Identifies the defined reset. This should correspond to a\n\t\t\t\tuser-defined reset type element. Default value is HARD, and only one reset can be defined as that.</li>\n                <li><b>Reset value</b> is mandatory and defines the actual reset value on reset. Reset value uses\n\t\t\t\tSystemVerilog syntax for binary values. The number of bits must be equal to the <i>field</i> size.</li>\n                <li><b>Reset mask</b> is optional and defines the bits that have a known reset value. Bit\n\t\t\t\tvalue of 1 means that the corresponding bit has a known reset value whereas 0 means that\n\t\t\t\tthe value is unknown. Reset mask uses SystemVerilog syntax for binary values e.g. 'b1011,\n\t\t\t\t4'b1011, and 4'b10_11 are all valid values. The number of bits must be equal to the <i>field</i> size.</li>\n            </ul>\n\t</p>\n\t\n    <h3>Enumerations table</h3>\n    <p>\n        The enumerated values table enables the defining of bit patterns that can be identified\n        by a name. This can be used to define the legal bit patterns for a field or to define\n        some default settings to help configuration of the field.\n    </p>\n    \n    <p>\n        Each enumeration contains a unique <b>name</b> of the enumeration (mandatory), an\n        optional <b>display name</b> and <b>description</b>.\n    </p>\n    <p>\n        <b>Value</b> defines the value to assign to the specified name (mandatory).\n    </p>\n    <p>\n        <b>Usage</b> defines the software access condition under which this name value pair\n        is valid. Possible values are: <i>read</i>, <i>write</i> and <i>read-write</i>.\n    </p>\n\n    <h3>Field access policies table</h3>\n\n    <p>Field access policies define field access properties for different operating modes.</p>\n\n    <p>\n        <b>Mode(s)</b> contains references to component modes. It is optional, and defines for which \n        component modes the field access policy is active. If a field access policy contains no mode references, \n        it is active for all component modes not already referenced by other field access policies \n        (i.e. only one field access policy without mode references may exist).\n\n        A field access policy is active, if it references an active mode and has the highest <i>priority</i>\n        (i.e. the lowest priority value) among the field access policies of the field.\n    </p>\n    <p>\n        <b>Access</b> is optional and specifies the accessability of the <i>field</i> when that field \n        access policy is active. The possible values are:\n    </p>\n    <ul>\n        <li><b>read-write</b>. Both read and write transactions may have an effect on this <i>\n            field</i>. Write transactions may affect the contents of the <i>field</i>, and read\n            transactions return a value related to the <i>field</i>.</li>\n        <li><b>read-only</b>. A read transaction to this <i>field</i> returns a value related\n            to the value in the <i>field</i>. A write transaction to this <i>field</i> has undefined\n            results.</li>\n        <li><b>write-only</b>. A write transaction to this address affects the contents of the\n            <i>field</i>. A read transaction to this <i>field</i> has undefined results.</li>\n        <li><b>read-writeOnce</b>. Both read and write transactions may have an effect on this\n            <i>field</i>. Only the first write transaction may affect the contents of the <i>field</i>,\n            and read transactions return a value related to the values in the <i>field</i>.</li>\n        <li><b>writeOnce</b>. Only the first write transaction affects the contents of this\n            <i>field</i>.</li>\n    </ul>\n    <p>\n        <b>Read action</b> is optional and specifies if some action happens to the <i>field</i>\n        after a read operation. By default the <i>field</i> is unmodified. The possible\n        values are:\n    </p>\n    <ul>\n        <li><b>clear</b>. All bits in the <i>field</i> are cleared to '0' after a read operation.</li>\n        <li><b>set</b>. All bits in the <i>field</i> are set to '1' after a read operation.</li>\n        <li><b>modify</b>. Indicates that the bits of the <i>field</i> are modified in some\n            way after a read operation.</li>\n        <li><b>'&nbsp; ' (empty setting)</b>. Indicates that the <i>field</i> is not modified\n            after a read operation. This is the default.</li>\n    </ul>\n    <p>\n        <b>Read response</b> is optional and describes the expected read value of the field in a \n        certain mode. If not present, then the reset value is expected to be read.\n    </p>\n    <p>\n        <b>Testable</b> is optional and specifies if the <i>field</i> is testable by an\n        automated register test.\n    </p>\n    <p>\n        <b>Test constraint</b> is optional and specifies the constaints for the automated\n        tests for the <i>field</i>. Can be set only when testable is set to true. The possible values are:\n    </p>\n    <ul>\n        <li><b>unConstrained</b>. There are no constraints for the written or read data. This\n            is the default setting.</li>\n        <li><b>Restore</b>. The <i>field</i> value must be restored to its original value before\n            accessing another register. </li>\n        <li><b>WriteAsRead</b>. The data written to a <i>field</i> must be same that was read\n            previously from the <i>field</i></li>\n        <li><b>ReadOnly</b>. Indicates that the <i>field</i> can only be read.</li>\n    </ul>\n\n    <p>\n        <b>Reserved</b> is optional and indicates if the field is reserved for other use.\n    </p>\n\n    <p>\n        <b>Modified write value</b> is optional and describes how the data in the <i>field</i>\n        is manipulated on a write operation. The basic operation without any setting is\n        to store the written value 'as is'. Moreover, both bitwise and field-wise set/clear/toggle\n        is also possible. The possible values are:\n    </p>\n    <ul>\n        <li><b>oneToClear</b>. Each written '1' bit will assign the corresponding bit to '0'.</li>\n        <li><b>oneToSet</b>. Each written '1' bit will assign the corresponding bit to '1'.</li>\n        <li><b>oneToToggle</b>. Each written '1' bit will toggle the corresponding bit.</li>\n        <li><b>zeroToClear, zeroToSet, zeroToToggle</b>. Similar to previous ones, except that\n            written '0' bit triggers the action.</li>\n        <li><b>clear</b>. Each write operation will clear all bits in the <i>field</i> to '0'.</li>\n        <li><b>set</b>. Each write operation will set all bits in the <i>field</i> to '1'.</li>\n        <li><b>modify</b>. Indicates that after a write operation, all bits in the <i>field</i>\n            can be modified.</li>\n        <li><b>'&nbsp; ' (empty setting)</b>. Indicates that the value written to a <i>field</i>\n            is the value stored in the <i>field</i>. This is the default value.</li>\n    </ul>\n    <p>\n        The <b>write value constraint</b>s are used to define what are the legal values\n        user may write to a <i>field</i>. The possible values are:\n        <ul>\n            <li><b>No constraints</b>. Indicates that there are no constraints to values to be written.</li>\n            <li><b>Write as read</b>. Inidcates that only legal values to be written are the same\n                that were previously read from the field.</li>\n            <li><b>Use enumerated values</b>. Indicates that the defined enumerated values are the\n                only legal values that can be written.</li>\n            <li><b>Set minimum and maximum limits</b>. Indicates that the minimum and maximum limits\n                can be set for the value written to the <i>field</i>.</li>\n        </ul>\n    </p>\n</body>\n</html>\n"
  },
  {
    "path": "Help/componenteditor/filegeneral.html",
    "content": "﻿<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01//EN\" \"http://www.w3.org/TR/html4/strict.dtd\">\n<html>\n  <head>\n    <meta http-equiv=\"Content-Type\"content=\"text/html; charset=utf-8\">\n    <link href=\"../style.css\" rel=\"Stylesheet\" type=\"text/css\">\n    <title>File editor</title>\n  </head>\n  <body>\n    <h2>File editor</h2>\n    <p>\n      File editor can be used to edit the details of a single file within a file set.\n    </p>\n\n    <p>\n      <b>Name</b> field contains the relative file path from the containing component XML-file to this file.\n      The name can be changed in the file set editor.\n    </p>\n    <p>\n      <b>Description</b> shows a used given description regarding the currently active file.\n    </p>\n    <p>\n      <b>File types</b> list specifies the type of the file. File type can be used i.e. when specifying\n      build commands for a group of files. A file can have multiple file types.         \n    </p>\n\n    <h3>General options</h3>\n    <p>\n      <b>Logical name</b> specifies e.g. a VHDL library where the VHDL-file will be compiled to.<br />\n      <b>Generators can override logical name </b> defines if the logical name can be \n        overridden by another process.\n    </p>\n    <p>\n      <b>File is structural RTL</b> indicates if the file contains only a structural\n        Register Transfer Level (RTL) description i.e. no behavioral code.\n    </p>\n    <p>\n      <b>File is include file </b> indicates if the file is an include file e.g. C-header file.\n    </p>\n    <p>\n      <b>File contains external declarations</b> can be used to indicate that the file contains \n       external declarations and is needed by other files in this file set.\n    </p>\n\n    <h3>Build command</h3>\n    <p>\n      <b>Target file</b> specifies a path to the file that is derived from this file when build process is \n      run. A new file path can be entered or an existing file can be searched with \"Browse...\".\n    </p>\n    <p>\n      <b>Build command</b> can be used to define a build <b>command</b> and <b>flags</b> specific to this file.\n\t  For example, a C-source file could have a build command 'gcc' with flags '-O2'.\n    </p>\n    <p>\n      Flags can either <b>replace default flags</b> (e.g. those specified for this file type) \n      in the build script or be appended to them. The value can be given as an \n      expression, but must evaluate to 1 or 0.\n    </p>\n\n    <h3>External dependencies and defines </h3>\n    <p>\n      <b>Exported names</b> contains a list names defined within the file that can be \n\t  referenced externally.\n    </p>\n    <p>\n      <b>Image types</b> contains a list of the current files relations to executable image types in \n      the design.\n    </p>\n    <p>\n      <b>Dependent directories</b> contains a list of directory paths containing (include) files on which the \n      file depends.\n    </p>\n\t</body>\n</html>\n"
  },
  {
    "path": "Help/componenteditor/fileset.html",
    "content": "﻿<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01//EN\" \"http://www.w3.org/TR/html4/strict.dtd\">\n<html>\n  <head>\n    <meta http-equiv=\"Content-Type\"content=\"text/html; charset=utf-8\">\n    <link href=\"../style.css\" rel=\"Stylesheet\" type=\"text/css\">\n    <title>File set editor</title>\n  </head>\n  <body>\n    <h2>File set editor</h2>\n    <p>\n      File set editor can be used to edit the details of a single file set. These file sets can be used to \n      group files together to be referenced by other sections of a component.\n    </p>\n    <p>\n        <b>Name</b> is a mandatory identifier for the <i>file set</i>.\n    </p>\n    <p>\n        <b>Display name</b> is an optional and used for a more user-friendly identifier.\n    </p>\n    <p>\n        <b>Description</b> is an optional field for textual description of the <i>file set</i>.\n    </p>\n    <p>\n      <b>Group identifier</b> can be used to describe the function or purpose of the file set with a single\n      unbounded word. <i>Group identifiers</i> can contain several identifiers and the number of possible \n      identifiers is not limited. However, the editor suggests the following options:\n    </p>\n    <ul>\n      <li>diagnostics</li>\n      <li>documentation</li>\n      <li>projectFiles</li>\n      <li>simulation</li>\n      <li>sourceFiles</li>\n    </ul>\n\n    <h3>Files</h3>\n    <p>\n      Files editor lists the files contained within the file set.\n\t</p>\n\t<p>\n      Each <i>file</i> has a <b>file name</b> identifying the file. The name is mandatory and it is \n\t  determined automatically from the file path.\n    </p>\n    <p>\n      <b>File path</b> is mandatory and defined as relative to the component XML-file, \n\t  as an absolute path or as an external URI. If an URI is used, the schema must be explicitly \n\t  defined (e.g. http://...).\n    </p>\n    <p>\n      <b>File type</b> is mandatory and helps categorize the file and links files to their build command (see below). \n\t  A file can have more than one type.\n    </p>\n    <p>\n      <b>Description</b> is a freely formatted text describing a single file.\n    </p>\n    <p>\n      New files can be added by creating new rows, browsing the files using the context menu option described below\n      or by drag-dropping the files onto the editor. If the order of files is important for e.g. compilation then \n      the files should be listed in the required order. The order of the files can be changed by dragging the rows.\n    </p>\n    <p>\n      The files box also contains a context menu (right mouse button) that has the following options:\n    </p>\n    <ul>\n      <li>Add new files to the file set by browsing the file system (Add file(s)...)</li>\n      <li>Add new file to the file set (Add row)</li>\n      <li>Remove file from file set (Remove row)</li>\n      <li>Clear the selected cells</li>\n      <li>Copy the contents of the selected cells to clipboard</li>\n      <li>Paste the contents of the clipboard to the selected cells</li>\n      <li>Import a csv-file to the editor</li>\n      <li>Export the contents of the editor to a csv-file</li>\t  \n    </ul>\n    \n    <h3>Default build commands</h3>\n    <p>\n      <b>Default build command</b> defines how to build the files within the file set by e.g. running gcc\n      for C files or vcom for VHDL.\n    </p>\n    <p>\n      <b>File type</b> defines which files are build by the given <i>command</i>.\n    </p>\n    <p>\n      <b>Flags</b> define the command line options for the <i>command</i> e.g. -Wall.\n    </p>\n    <p>\n      The defined command can either <b>replace default flags</b> defined in the target <i>file</i> or be \n      appended to it. The value can be given as an expression, but must evaluate to 1 or 0.\n    </p>\n\n    <h3>Dependent directories</h3>\n    <p>\n      <b>Dependent directories</b> can specify a freetext list of paths to directories on which this file\n      set depends, e.g. directories of include files.\n    </p>\n\n  </body>\n</html>"
  },
  {
    "path": "Help/componenteditor/fileset2022.html",
    "content": "﻿<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01//EN\" \"http://www.w3.org/TR/html4/strict.dtd\">\n<html>\n  <head>\n    <meta http-equiv=\"Content-Type\"content=\"text/html; charset=utf-8\">\n    <link href=\"../style.css\" rel=\"Stylesheet\" type=\"text/css\">\n    <title>File set editor</title>\n  </head>\n  <body>\n    <h2>File set editor</h2>\n    <p>\n      File set editor can be used to edit the details of a single file set. These file sets can be used to \n      group files together to be referenced by other sections of a component.\n    </p>\n    <p>\n        <b>Name</b> is a mandatory identifier for the <i>file set</i>.\n    </p>\n    <p>\n        <b>Display name</b> is an optional and used for a more user-friendly identifier.\n    </p>\n    <p>\n      <b>Short description</b> is an optional field for compact description of the <i>file set</i>.\n    </p>\n    <p>\n        <b>Description</b> is an optional field for textual description of the <i>file set</i>.\n    </p>\n    <p>\n      <b>Group identifier</b> can be used to describe the function or purpose of the file set with a single\n      unbounded word. <i>Group identifiers</i> can contain several identifiers and the number of possible \n      identifiers is not limited. However, the editor suggests the following options:\n    </p>\n    <ul>\n      <li>diagnostics</li>\n      <li>documentation</li>\n      <li>projectFiles</li>\n      <li>simulation</li>\n      <li>sourceFiles</li>\n    </ul>\n\n    <h3>Files</h3>\n    <p>\n      Files editor lists the files contained within the file set.\n\t</p>\n\t<p>\n      Each <i>file</i> has a <b>file name</b> identifying the file. The name is mandatory and it is \n\t  determined automatically from the file path.\n    </p>\n    <p>\n      <b>File path</b> is mandatory and defined as relative to the component XML-file, \n\t  as an absolute path or as an external URI. If an URI is used, the schema must be explicitly \n\t  defined (e.g. http://...).\n    </p>\n    <p>\n      <b>File type</b> is mandatory and helps categorize the file and links files to their build command (see below). \n\t  A file can have more than one type.\n    </p>\n    <p>\n      <b>Description</b> is a freely formatted text describing a single file.\n    </p>\n    <p>\n      New files can be added by creating new rows, browsing the files using the context menu option described below\n      or by drag-dropping the files onto the editor. If the order of files is important for e.g. compilation then \n      the files should be listed in the required order. The order of the files can be changed by dragging the rows.\n    </p>\n    <p>\n      The files box also contains a context menu (right mouse button) that has the following options:\n    </p>\n    <ul>\n      <li>Add new files to the file set by browsing the file system (Add file(s)...)</li>\n      <li>Add new file to the file set (Add row)</li>\n      <li>Remove file from file set (Remove row)</li>\n      <li>Clear the selected cells</li>\n      <li>Copy the contents of the selected cells to clipboard</li>\n      <li>Paste the contents of the clipboard to the selected cells</li>\n      <li>Import a csv-file to the editor</li>\n      <li>Export the contents of the editor to a csv-file</li>\t  \n    </ul>\n    \n    <h3>Default build commands</h3>\n    <p>\n      <b>Default build command</b> defines how to build the files within the file set by e.g. running gcc\n      for C files or vcom for VHDL.\n    </p>\n    <p>\n      <b>File type</b> defines which files are build by the given <i>command</i>.\n    </p>\n    <p>\n      <b>Flags</b> define the command line options for the <i>command</i> e.g. -Wall.\n    </p>\n    <p>\n      The defined command can either <b>replace default flags</b> defined in the target <i>file</i> or be \n      appended to it. The value can be given as an expression, but must evaluate to 1 or 0.\n    </p>\n\n    <h3>Dependent directories</h3>\n    <p>\n      <b>Dependent directories</b> can specify a freetext list of paths to directories on which this file\n      set depends, e.g. directories of include files.\n    </p>\n\n  </body>\n</html>"
  },
  {
    "path": "Help/componenteditor/filesets.html",
    "content": "﻿<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01//EN\" \"http://www.w3.org/TR/html4/strict.dtd\">\n<html>\n  <head>\n    <meta http-equiv=\"Content-Type\"content=\"text/html; charset=utf-8\">\n    <link href=\"../style.css\" rel=\"Stylesheet\" type=\"text/css\">\n    <title>File sets editor</title>\n  </head>\n  <body>\n    <h2>File sets editor</h2>\n    <p>\n      File sets editor contains a summary table regarding each <i>file set</i> within the component. \n      This table can be used to add and remove file sets.\n    </p>\n\t<p>\n      <b>Name</b> is a mandatory identifier for the file set.\n    </p>\n    <p>\n\t  <b>Group identifiers</b> are optional and can be used to describe the function or purpose of \n\t  the file with a single word. <i>Group identifiers</i> can contain multiple identifiers and \n\t  the possible words are not limited. However, the editor suggests the following options:\n\t    <ul>\n\t      <li>diagnostics</li>\n\t      <li>documentation</li>\n\t      <li>projectFiles</li>\n\t      <li>simulation</li>\n\t      <li>sourceFiles</li>\n\t    </ul>\n    </p>\n\t<p>\n      <b>Description</b> is optional field for detailed description of the file set.\n\t</p>\n    <p>\n      Right clicking an item in the editor provides a context menu that can be used to:\n    </p>\n    <ul>\n      <li>Add a new file set to the component (Add row)</li>\n      <li>Remove a file set (Remove row)</li>\n      <li>Clear the selected cells</li>\n      <li>Copy the contents of the selected cells to clipboard</li>\n      <li>Paste the contents of the clipboard to the selected cells</li>\n      <li>Import a csv-file to the editor</li>\n      <li>Export the contents of the editor to a csv-file</li>\n    </ul>\n\t \n    <h3>File dependencies</h3>\n    <br />\n    <img src=\"../images/appicon.png\" width=\"25pix\" alt=\"Kactus-extension\" />\n\t<br />\n    <p>\n      Below the file sets editor is a dependency table to display the dependencies between the \n      files within all the file sets. File dependencies are typically introduced by include \n\t  directives (e.g. in C) or instantiation of other modules (e.g. sub-modules in Verilog).\n\t  Kactus2 uses plugins to automatically analyse dependencies based on the file types.\n    </p>\n\t <p>\n      <b>Status</b> shows if the file has changed since the last dependency analysis.\n    </p>\n    <p>\n\t  <b>Path</b> identifies the file.\n    </p>\n    <p>\n\t  <b>Filesets</b> shows the fileset(s) containing the file.\n    </p>\n    <p>\n\t  <b>#</b> column is used create custom dependencies. The first left-click on the mouse \n\t  starts the dependency from the file on the clicked line and the second click ends the \n\t  dependency to the file on the line. The first file is now dependent on the second file.\n    </p>\n    <p>\n\t  <b>Dependencies</b> show the dependencies for the file. A file dependent on another has a \n\t  round end point of the arrow on the line whereas the required file has an arrow head on the \n\t  line. Automatically created dependencies are denoted in black and user created dependencies\n\t  in magenta. A file can have arbitrary number of depenedencies. Clicking on the arrow shows \n\t  additional  information about the dependency in the Dependency Information below.\n\t</p>\n\t \n    <h3>File set source directories</h3>\n  \t<p>\n      Kactus2 will search the directories defined here for files to be automatically\n      added into the component file sets.\n    </p>\n\n\t<h3>Dependency information</h3>\n  \t<p>\n      <b>Description</b> displays the description of the file dependency.\n    </p>\n    <p>\n\t  <b>Bidirectional</b> indicates that both of the files are dependent on each other.\n    </p>\n    <p>\n\t  <b>Locked</b> can be set to protect the depencendy from being changed without explicitly\n\t  re-opening the lock.\n    </p>\n\t<p>\n\t   <b>Reverse Direction</b> changes the dependent and prerequisite file relation to the\n\t   opposite of the current state.\n\t</p>\n    <hr>\n    <p>\n      EXAMPLE. The names of filesets do not need to be same as directories\n      (vhdlSource vs. vhd/) but they can be (e.g. syn). <br>\n      <img src=\"../images/filesets.png\" alt=\"screen cap\">\n    </p>\n  </body>\n</html>\n"
  },
  {
    "path": "Help/componenteditor/general.html",
    "content": "﻿<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01//EN\" \"http://www.w3.org/TR/html4/strict.dtd\">\n<html>\n  <head>\n    <meta http-equiv=\"Content-Type\"content=\"text/html; charset=utf-8\">\n    <link href=\"../style.css\" rel=\"Stylesheet\" type=\"text/css\">\n    <title>General editor</title>\n  </head>\n  <body>\n    <h2>General editor</h2>\n    <p>\n      General editor contains the general information of a <i>component</i>.\n    </p>\n    <p>      \n      <i>VLNV</i>-identifier and the file path to the xml-file are\n      shown on top. These fields cannot be modified after\n      creation. Changes require that the component must be saved as\n      new component with new VLNV.\n    </p>\n\t<p>\n\t\t<b>Compatibility</b> shows the <i>component</i> IP-XACT revision compatibility.\n\t</p>\n\t<p>\n\t\t<b>Description</b> text box can store a textual description of the <i>component</i>.\n\t</p>\n\t  \n\t<h3>Kactus attributes</h3>\n    <br/>\n    <img src=\"../images/appicon.png\" width=\"25pix\" alt=\"Kactus-extension\" />\n\t<br />\n    <p>\n      <b>Kactus attributes</b> help to classify and categorize one's\n      IPs. They are Kactus2-specific extension to the IP-XACT standard\n      and describe the level (single IP vs. system), implementation\n      style, and whether modification is allowed. Only the\n      implementation style applies for SW components.<br>\n  </p>\n    <table border=\"1\">\n\t<tr>\n\t  <th>Attribute name</th>\n\t  <th>Attribute value</th>\n\t  <th>Value description</th>\n\t</tr>\n\t<tr>\n\t  <td rowspan=\"6\">Product hierarchy</td>\n\t  <td>Product</td>\n\t  <td>Whole product, which may contain multiple boards and\n\t  computers.</td>\n\t</tr>\n\t<tr>\n\t  <td>Board</td>\n\t  <td>Represents circuit board, e.g. develoment- or final\n\t  hardware platform.</td>\n\t</tr>\n\t<tr>\n\t  <td>Chip</td>\n\t  <td>Represents a physical chip i.e. some specific\n\t  FPGA-chip.</td>\n\t</tr>\n\t<tr>\n\t  <td>SoC</td>\n\t  <td>A system on chip, set of intercconected IPs.</td>\n\t</tr>\n\t<tr>\n\t  <td>IP</td>\n\t  <td>A single IP-block (which might be hierarchical)</td>\n\t</tr>\n\t<tr>\n\t\t<td>Flat</td>\n\t\t<td>Does not fit into any other category.</td>\n\t  </tr>\n  \t<tr>\n\t  <td rowspan=\"3\"> Firmness</td> <td>Template</td> <td>Used as\n\t  a base for creating new components, but must not be used as\n\t  such. It should be copied and then saved with new VLNV.</td>\n\t</tr>\n\t<tr>\n\t  <td>Mutable</td>\n\t  <td>Component is fully modifiable.</td>\n\t</tr>\n\t<tr>\n\t  <td>Fixed</td> <td>Component cannot be configured in any way\n\t  and it is frozen to it's final state.</td>\n\t</tr>\n\t<tr>\n\t  <td rowspan=\"3\">Implementation <br>(cannot be modified\n\t  after creation)</td> <td>HW</td> <td>Hardware\n\t  implementation, such as VHDL or Verilog</td>\n\t</tr>\n\t<tr>\n\t  <td>SW</td>\n\t  <td>Software implementation, such as C</td>\n\t</tr>\n\t<tr>\n\t  <td>SYS</td> <td>Contains information about the SW component\n\t  mapping to the underlying HW platform.</td>\n\t</tr>\n    </table>\n    <p>\n\t\t<b>Tags</b> is an optional set of user-defined categorizations for the <i>component</i>. \n\t\tEach tag has a name and a color. Tags can be used to filter items in the IP-XACT library\n\t\tview.\n\t</p>\n\t\n\t<h3>Copyright information</h3>\t\n    <br/>\n    <img src=\"../images/appicon.png\" width=\"25pix\" alt=\"Kactus-extension\" />\n\t<br/>\n    <p>\n        <b>Author</b> is an optional field for the author of the component.\n    </p>\n\t\n    <p>\n        <b>License</b> is an optional field for identifying the license applicable to the component.\n    </p>\n\t\t\n\t\t\n\t<h3>XML header</h3>\n    <p>\n      <b>XML header</b> shows and allows editing the comment lines in\n      the beginning of XML file, i.e. those inside tags &lt;!-- and\n      --&gt;.\n    </p>\n\t\n\t\n\t<h3>Component preview</h3>\n    <p>\n      <b>Component preview</b> box on the right of the editor displays how the component will look like when\n      instantiated in a design. The preview displays the <i>bus interfaces</i> of the component and also the\n      <i>ports</i> that are marked as <i>ad-hoc</i>.\n    </p>\n  </body>\n</html>\n"
  },
  {
    "path": "Help/componenteditor/general2022.html",
    "content": "﻿<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01//EN\" \"http://www.w3.org/TR/html4/strict.dtd\">\n<html>\n  <head>\n    <meta http-equiv=\"Content-Type\"content=\"text/html; charset=utf-8\">\n    <link href=\"../style.css\" rel=\"Stylesheet\" type=\"text/css\">\n    <title>General editor</title>\n  </head>\n  <body>\n    <h2>General editor</h2>\n    <p>\n      General editor contains the general information of a <i>component</i>.\n    </p>\n    <p>      \n      <i>VLNV</i>-identifier and the file path to the xml-file are\n      shown on top. These fields cannot be modified after\n      creation. Changes require that the component must be saved as\n      new component with new VLNV.\n    </p>\n\t<p>\n\t\t<b>Compatibility</b> shows the <i>component</i> IP-XACT revision compatibility.\n\t</p>\n    <p>\n        <b>Display name</b> is an optional field and used for a more user-friendly identifier.\n    </p>\n    <p>\n      <b>Short description</b> is an optional field for compact description of the <i>component</i>.\n    </p>\n\t<p>\n\t\t<b>Description</b> text box can store a textual description of the <i>component</i>.\n\t</p>\n\t  \n\t<h3>Kactus attributes</h3>\n    <br/>\n    <img src=\"../images/appicon.png\" width=\"25pix\" alt=\"Kactus-extension\" />\n\t<br />\n    <p>\n      <b>Kactus attributes</b> help to classify and categorize one's\n      IPs. They are Kactus2-specific extension to the IP-XACT standard\n      and describe the level (single IP vs. system), implementation\n      style, and whether modification is allowed. Only the\n      implementation style applies for SW components.<br>\n  </p>\n    <table border=\"1\">\n\t<tr>\n\t  <th>Attribute name</th>\n\t  <th>Attribute value</th>\n\t  <th>Value description</th>\n\t</tr>\n\t<tr>\n\t  <td rowspan=\"6\">Product hierarchy</td>\n\t  <td>Product</td>\n\t  <td>Whole product, which may contain multiple boards and\n\t  computers.</td>\n\t</tr>\n\t<tr>\n\t  <td>Board</td>\n\t  <td>Represents circuit board, e.g. develoment- or final\n\t  hardware platform.</td>\n\t</tr>\n\t<tr>\n\t  <td>Chip</td>\n\t  <td>Represents a physical chip i.e. some specific\n\t  FPGA-chip.</td>\n\t</tr>\n\t<tr>\n\t  <td>SoC</td>\n\t  <td>A system on chip, set of intercconected IPs.</td>\n\t</tr>\n\t<tr>\n\t  <td>IP</td>\n\t  <td>A single IP-block (which might be hierarchical)</td>\n\t</tr>\n\t<tr>\n\t\t<td>Flat</td>\n\t\t<td>Does not fit into any other category.</td>\n\t</tr>\n  \t<tr>\n\t  <td rowspan=\"3\"> Firmness</td> <td>Template</td> <td>Used as\n\t  a base for creating new components, but must not be used as\n\t  such. It should be copied and then saved with new VLNV.</td>\n\t</tr>\n\t<tr>\n\t  <td>Mutable</td>\n\t  <td>Component is fully modifiable.</td>\n\t</tr>\n\t<tr>\n\t  <td>Fixed</td> <td>Component cannot be configured in any way\n\t  and it is frozen to it's final state.</td>\n\t</tr>\n\t<tr>\n\t  <td rowspan=\"3\">Implementation <br>(cannot be modified\n\t  after creation)</td> <td>HW</td> <td>Hardware\n\t  implementation, such as VHDL or Verilog</td>\n\t</tr>\n\t<tr>\n\t  <td>SW</td>\n\t  <td>Software implementation, such as C</td>\n\t</tr>\n\t<tr>\n\t  <td>SYS</td> <td>Contains information about the SW component\n\t  mapping to the underlying HW platform.</td>\n\t</tr>\n    </table>\n    <p>\n\t\t<b>Tags</b> is an optional set of user-defined categorizations for the <i>component</i>. \n\t\tEach tag has a name and a color. Tags can be used to filter items in the IP-XACT library\n\t\tview.\n\t</p>\n\t\n\t<h3>Copyright information</h3>\t\n    <br/>\n    <img src=\"../images/appicon.png\" width=\"25pix\" alt=\"Kactus-extension\" />\n\t<br/>\n    <p>\n        <b>Author</b> is an optional field for the author of the component.\n    </p>\n\t\n    <p>\n        <b>License</b> is an optional field for identifying the license applicable to the component.\n    </p>\n\t\t\n\t\t\n\t<h3>XML header</h3>\n    <p>\n      <b>XML header</b> shows and allows editing the comment lines in\n      the beginning of XML file, i.e. those inside tags &lt;!-- and\n      --&gt;.\n    </p>\n\t\n\t<h3>Validation</h3>\n    <p>\n\t\t\n    </p>\n\n\t<h3>Component preview</h3>\n    <p>\n      <b>Component preview</b> box on the right of the editor displays how the component will look like when\n      instantiated in a design. The preview displays the <i>bus interfaces</i> of the component and also the\n      <i>ports</i> that are marked as <i>ad-hoc</i>.\n    </p>\n  </body>\n</html>\n"
  },
  {
    "path": "Help/componenteditor/indirectInterface.html",
    "content": "﻿<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01//EN\" \"http://www.w3.org/TR/html4/strict.dtd\">\n<html>\n<head>\n    <meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />\n    <link href=\"../style.css\" rel=\"Stylesheet\" type=\"text/css\" />\n    <title>Field editor</title>\n</head>\n<body>\n    <h2>Indirect interface editor</h2>\n\n    <p>\n      Indirect interface editor is used to edit the details of a single indirect interface. \n      An <i>indirect interface</i> defines access to <i>memory maps</i> that are not directly \n      accessible through a standard <i>bus interface</i>. The indirect <i>memory map</i>\n      is either a <i>memory map</i> within the containing <i>component</i> or accessed through\n      a master <i>bus interface</i> of this component using a <i>transparent bridge</i>.\n    </p>\n\n    <p>\n      <b>Name</b> is a mandatory identifier for the <i>indirect interface</i>. The name must be unique\n      within all the <i>indirect interface</i> of the containing <i>component</i>.\n    </p>\n    <p>\n      <b>Display name</b> is an optional and used for a more user-friendly identifier.\n    </p>\n    <p>\n      <b>Description</b> is an optional field for textual description of the <i>indirect interface</i>.\n    </p>\n        \n    <h3>General</h3>\n\n    <p>\n      <b>Indirect address field</b> is mandatory and defines the bit field used for\n      addressing in the <i>indirect interface</i>.\n    </p>\n    <p>\n        <b>Indirect data field</b> is mandatory and defines the bit field used for\n        data in read/write operations in the <i>indirect interface</i>.\n    </p>\n    <p>\n        <b>Bits in Lau</b> is optional and defines the number of bits addressable by\n        the least significant address bit.\n    </p>\n    <p>\n      <b>Endianness</b> is optional and indicates whether the interface is 'big-endian' or    \n      'little-endian' (default).\n    </p>\n\n    <h3>Indirect access target</h3>\n    <p>\n        <b>Memory map</b> defines the indirectly accessible <i>memory map</i> for     \n        the <i>indirect interface</i>. If a <i>memory map</i> has been defined,\n        <i>transparent bridges</i> must be left empty.\n    </p>\n    <p>\n        <b>Transparent bridge(s)</b> define the master <i>bus interface(s)</i> that\n        all transactions through this <i>indirect interface</i> are directed out of. \n        If <i>transparent bridges</i> have been defined, <i>memory map</i> must be left empty.\n    </p>\n\n    <h3>Parameters</h3>\n    <p>\n      <b>Parameters</b> are optional and can specify any parameter data value(s) specific for this <i>indirect interface</i>.\n      For more information on parameters, see the component parameter editor.\n    </p>\n\n</body>\n</html>\n"
  },
  {
    "path": "Help/componenteditor/indirectInterface2022.html",
    "content": "﻿<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01//EN\" \"http://www.w3.org/TR/html4/strict.dtd\">\n<html>\n<head>\n    <meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />\n    <link href=\"../style.css\" rel=\"Stylesheet\" type=\"text/css\" />\n    <title>Field editor</title>\n</head>\n<body>\n    <h2>Indirect interface editor</h2>\n\n    <p>\n      Indirect interface editor is used to edit the details of a single indirect interface. \n      An <i>indirect interface</i> defines access to <i>memory maps</i> that are not directly \n      accessible through a standard <i>bus interface</i>. The indirect <i>memory map</i>\n      is either a <i>memory map</i> within the containing <i>component</i> or accessed through\n      a master <i>bus interface</i> of this component using a <i>transparent bridge</i>.\n    </p>\n\n    <p>\n      <b>Name</b> is a mandatory identifier for the <i>indirect interface</i>. The name must be unique\n      within all the <i>indirect interface</i> of the containing <i>component</i>.\n    </p>\n    <p>\n      <b>Display name</b> is an optional and used for a more user-friendly identifier.\n    </p>\n    <p>\n      <b>Short description</b> is an optional field for compact description of the <i>indirect interface</i>.\n  </p>\n    <p>\n      <b>Description</b> is an optional field for textual description of the <i>indirect interface</i>.\n    </p>\n        \n    <h3>General</h3>\n\n    <p>\n      <b>Indirect address field</b> is mandatory and defines the bit field used for\n      addressing in the <i>indirect interface</i>.\n    </p>\n    <p>\n        <b>Indirect data field</b> is mandatory and defines the bit field used for\n        data in read/write operations in the <i>indirect interface</i>.\n    </p>\n    <p>\n        <b>Bits in Lau</b> is optional and defines the number of bits addressable by\n        the least significant address bit.\n    </p>\n    <p>\n      <b>Endianness</b> is optional and indicates whether the interface is 'big-endian' or    \n      'little-endian' (default).\n    </p>\n\n    <h3>Indirect access target</h3>\n    <p>\n        <b>Memory map</b> defines the indirectly accessible <i>memory map</i> for     \n        the <i>indirect interface</i>. If a <i>memory map</i> has been defined,\n        <i>transparent bridges</i> must be left empty.\n    </p>\n    <p>\n        <b>Transparent bridge(s)</b> define the master <i>bus interface(s)</i> that\n        all transactions through this <i>indirect interface</i> are directed out of. \n        If <i>transparent bridges</i> have been defined, <i>memory map</i> must be left empty.\n    </p>\n\n    <h3>Parameters</h3>\n    <p>\n      <b>Parameters</b> are optional and can specify any parameter data value(s) specific for this <i>indirect interface</i>.\n      For more information on parameters, see the component parameter editor.\n    </p>\n\n</body>\n</html>\n"
  },
  {
    "path": "Help/componenteditor/indirectInterfaces.html",
    "content": "﻿<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01//EN\" \"http://www.w3.org/TR/html4/strict.dtd\">\n<html>\n<head>\n    <meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />\n    <link href=\"../style.css\" rel=\"Stylesheet\" type=\"text/css\" />\n    <title>Field editor</title>\n</head>\n<body>\n    <h2>Indirect interfaces editor</h2>\n\n    <p>\n      Indirect interfaces editor contains the summary of the <i>indirect interfaces</i>\n      of the component. An <i>indirect interface</i> is used to define access to\n      <i>memory maps</i> that are not directly accessible through a <i>bus interface</i>.\n      This editor can be used to add and remove indirect interfaces to the containing component. \n    </p>\n\n    <p>\n        <b>Name</b> is a mandatory identifier for the <i>indirect interface</i>. The name must be unique\n        within all the <i>indirect interface</i> of the containing <i>component</i>.\n    </p>\n    <p>\n        <b>Display name</b> is an optional and used for a more user-friendly identifier.\n    </p>\n    <p>\n        <b>Indirect address field</b> is mandatory and defines the bit field used for\n        addressing in the <i>indirect interface</i>. A field ID must be defined for\n\t\tthe field to be considered a valid option here.\n    </p>\n    <p>\n        <b>Indirect data field</b> is mandatory and defines the bit field used for\n        data in read/write operations in the <i>indirect interface</i>.\n\t\tA field ID must be defined for the field to be considered a valid option here.\n    </p>\n    <p>\n        <b>Memory map</b> defines the indirectly accessible <i>memory map</i> for     \n        the <i>indirect interface</i>. If a <i>memory map</i> has been defined,\n        <i>transparent bridges</i> must be left empty.\n    </p>\n    <p>\n        <b>Transparent bridges</b> define the master <i>bus interface(s)</i> that\n        all transactions through this <i>indirect interface</i> are directed out of. \n        If <i>transparent bridges</i> have been defined, <i>memory map</i> must be left empty.\n        <i>Transparent bridges</i> are shown here, but must be edited in the \n        editor of the respective <i>indirect interface</i>.\n    </p>\n    <p>\n        <b>Description</b> is an optional field for textual description of the <i>indirect interface</i>.\n    </p>\n    <hr>\n    <p>\n    EXAMPLE 1. The memory map MM0 is accessible through slave bus interface accessIF.\n    Indirect interface II0 identifies bitfields data and address in registers r0 and\n    r1 which are used to access memory map MM1. The access to memory map\n    MM1 occurs at the memory location defined by the content of the address field and\n    the content of the field data is either written into register r6 in a write operation\n    or read from r6 into field data in a read operation. \n    <br>\n    <img src=\"../images/indirectMemoryMap.png\" alt=\"addr space's idea\">\n  </p>\n\n  <p>\n    EXAMPLE 2. The memory map MM0 is accessible through slave bus interface accessIF.\n    Indirect interface II0 identifies bitfields data and address in registers r0 and\n    r1 which are used to access other components through master bus interface outIF.       \n    <br>\n    <img src=\"../images/indirectBridge.png\" alt=\"addr space's idea\">\n  </p>\n  \n</body>\n</html>\n"
  },
  {
    "path": "Help/componenteditor/instantiations.html",
    "content": "﻿<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01//EN\" \"http://www.w3.org/TR/html4/strict.dtd\">\n<html>\n  <head>\n    <meta http-equiv=\"Content-Type\"content=\"text/html; charset=utf-8\">\n    <link href=\"../style.css\" rel=\"Stylesheet\" type=\"text/css\">\n    <title>Instantiations editor</title>\n  </head>\n  <body>\n    <h2>Instantiations editor</h2>\n    <p>\n      Instantiations editor provides a summary of the different\n\t  instantiations of the component. Instantiations are\n\t  used in <i>views</i> to represent different aspects\n\t  of the view. Instantiations contain a mandatory, unique <b>name</b>, a <b>display name</b> and a textual\n      description to identify the instantiations.\n\t  This editor can be used to add and remove instantiations.\n\t</p>\n\t\n\t<p>\n\t  A <i>component instantiation</i> describes the details of instantiating the component in a hardware \n      description <b>language</b>, for example, verilog or vhdl. This editor can be used to add and remove \n      component instantiations.\n\t</p>\n\t\n    <p>\n        A <i>design configuration instantiation</i> details how a specific design configuration instance is \n        associated with a <i>view</i>. This editor can be used to add and remove design configuration \n        instantiations.\n        <br /><b>Design configuration reference</b> specifies the used design configuration.\n    </p>\n\t\n    <p>\n        A <i>design instantiation</i> specifies how a specific design instance is associated with a view. This \n        editor can be used to add and remove design instantiations.\n        <br /><b>Design reference</b> details the design description and configuration values applied to it.\n    </p>\n    \n    <p>\n      The editor contains a context menu that contains following options:\n    </p>\n    <ul>\n      <li>Add a new instantiation (Add row)</li>\n      <li>Remove an instantiation (Remove row)</li>\n      <li>Clear the selected cells</li>\n      <li>Copy the contents of the selected cells to clipboard</li>\n      <li>Paste the contents of the clipboard to the selected cells</li>\n      <li>Import a csv-file to the editor</li>\n      <li>Export the contents of the editor to a csv-file</li>\n    </ul>\n    <hr>\n\n  </body>\n</html>\n"
  },
  {
    "path": "Help/componenteditor/memorymap.html",
    "content": "﻿<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01//EN\" \"http://www.w3.org/TR/html4/strict.dtd\">\n<html>\n<head>\n    <meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">\n    <link href=\"../style.css\" rel=\"Stylesheet\" type=\"text/css\">\n    <title>Memory map editor</title>\n</head>\n<body>\n    <h2>Memory map editor</h2>\n    <p>\n        Memory map editor can be used to edit the details of a <i>memory map</i>.\n    </p>\n    <p>\n        Memory maps visualization is shown on the right of the editor. The visualization\n        can be expandped and minimized by clicking the expand arrow\n        <img src=\"../images/triangle_arrow_right.png\" alt=\"expand\">\n        and the minimize arrow\n        <img src=\"../images/triangle_arrow_down.png\" alt=\"minimize\">. Selecting any part\n        of the visualization will open the editor set for that item. The visualization can\n        be resized by dragging the border between the editor and the visualization. Holding\n        Ctrl-key while scrolling with the mouse wheel increases/decreases the width of the\n        items.\n    </p>\n\n    <p>\n        <b>Name</b> is a mandatory identifier for the <i>memory map</i>.\n    </p>\n    <p>\n        <b>Display name</b> is an optional and used for a more user-friendly identifier.\n    </p>\n    <p>\n        <b>Description</b> is an optional field for textual description of the <i>memory map</i>.\n    </p>\n    <p>\n        <b>Address unit bits</b> (AUB) defines the number of data bits each address increment\n        of the <i>memory map</i> contains, e.g. 8b or 32b. The default setting for a <i>memory map</i>\n        is byte addressable (8 bits). E.g. if AUB=8, then 32-bit registers are at addresses\n        0x0, 0x4, 0x8... If AUB=32, they are in addresses 0x0, 0x1, 0x2... AUB is the unit\n        for base addresses and ranges within the address map.</p><p>\n\n\t\t<p>\n        <b>Is present</b> is optional and allows enabling/disabling of a <i>memory map</i>\n        presence in a <i>component</i>. Value 1 indicates that the <i>memory map</i>\n        is present in the <i>component</i> whereas value 0 marks the memory map to be\n        treated as if it does not exist. Is present can be given as a SystemVerilog expression,\n        but it must evaluate to 1 or 0.</p>\n\t\t<p>\n\n        <b>Remap state</b> identifies the name of the <i>remap state</i> for which the optional\n        <i>memory map</i> elements are active. <i>Memory maps</i> are labeled with a default remap\n        state, while <i>memory remaps</i> must be given a <i>remap state</i>. For more information\n        on the <i>remap states</i>, see the remap states editor.\n    </p>\n    <p>\n\n        <b>Slave interface binding</b> shows which slave <i>bus interfaces</i> are used to access\n        the <i>memory map</i>. The binding can only be set in the bus interface editor, but is\n        shown here for convenience.\n    </p>\n\n    <h3>Address blocks table</h3>\n    <p>\n        <b>Address block</b> specifies a single contiguous block, either a set of registers\n        or a block of memory. Registers within the <i>address block</i> are further divided\n        into bit <i>fields</i>. (IP-XACT allows <i>bank</i> or <i>subspaceMap</i> elements\n        within the <i>address block</i>, but they are not yet supported by Kactus2 (v3.3,\n        December 2016)).\n    </p>\n    <p>\n        <b>Name</b> is a mandatory identifier for the <i>address block</i>.\n    </p>\n    <p>\n        <b>Base address</b> is mandatory and specifies the starting address for the <i>address block</i>.\n        It is expressed as address unit bits as defined in the containing <i>memory map</i>,\n\t\te.g. 8 or 32 bits.</p><p>\n\n        <b>Range</b> is mandatory and specifies the size of the block in address unit bits.\n    </p>\n    <p>\n\n        <b>Width</b> is mandatory and specifies the data width in bits of a row in the\n\t\t<i>address block</i>. It sets the\n        maximum allowed size of a single transfer and also defines the maximum size of a\n        single register. Register can be smaller but not wider than the value.\n    </p>\n    <p>\n        <b>Usage</b> is optional and is used to categorize the usage of the <i>address block</i>. The\n        possible values are:\n    </p>\n    <ul>\n        <li><b>Memory</b> specifies the <i>address block</i> as memory.\n\t\tA memory <i>address block</i> cannot contain registers.</li>\n        <li><b>Register</b> specifies the entire <i>address block</i> to contain registers.</li>\n        <li><b>Reserved</b> specifies the entire <i>address block</i> as reserved for usage\n\t\tthat is unknown to IP-XACT. A reserved <i>address block</i> cannot include registers.</li>\n    </ul>\n    <p>\n        <b>Access</b> is optional and is used to specify the accessibility of the <i>address block</i>.\n\t\tThe possible values are:\n    </p>\n    <ul>\n        <li><b>read-write</b>. Both read and write transactions may have an effect on this address\n            block.</li>\n        <li><b>read-only</b>. Only read transactions are allowed in this register.</li>\n        <li><b>write-only</b>. Only write transactions are allowed in this register.</li>\n        <li><b>read-writeOnce</b>. Read actions are allowed and the first write action may have\n            an effect on this address block.</li>\n        <li><b>writeOnce</b>. Only the first write action affects the contents of this address\n            block.</li>\n    </ul>\n    <p>\n        <b>Volatile</b> is optional and indicates that the stored value may change without master's\n        write operation. For example, the timer value gets updated automatically and master\n        must always issue a read to get the latest value.\n    </p>\n\n\t<p>\n        <b>Is present</b> is optional and allows enabling/disabling of a <i>address block</i>\n        presence in a <i>memory map</i>. Value 1 indicates that the <i>address block</i>\n        is present in the <i>memory map</i> whereas value 0 marks the memory map to be\n        treated as if it does not exist. Is present can be given as a SystemVerilog expression,\n        but it must evaluate to 1 or 0.</p>\n\t<p>\n\n    <p>\n        <b>Description</b> is an optional field for textual description of the <i>address block</i>.\n    </p>\n\n    <h3>Subspace maps table</h3>\n\n    <p>\n    <b>Name</b> is a mandatory identifier for the <i>subspace map</i>.\n  </p>\n  <p>\n      <b>Base address</b> is mandatory and specifies the starting address for the <i>subspace\n          map</i> in address unit bits. The range is equal to the referenced <i>address\n          space</i> or <i>segment</i>.\n  </p>\n    <p>\n        <b>Master interface</b> is a mandatory identifier for the bridged master <i>bus interface</i>\n        that is accessed by the subspace map.\n    </p>\n    <p>\n        <b>Segment</b> is an optional reference to a <i>segment</i> within the\n          referenced master <i>bus interface</i>. If a <i>segment</i> is defined,\n          the access is limited to the specified segment instead of the whole\n          <i>address space</i>.\n    </p>\n  <p>\n        <b>Is present</b> is optional and allows enabling/disabling of a <i>subspace map</i>\n        presence in a <i>memory map</i>. Value 1 indicates that the <i>subspace map</i>\n        is present in the <i>memory map</i> whereas value 0 marks the subspace map to be\n        treated as if it does not exist. Is present can be given as a SystemVerilog expression,\n        but it must evaluate to 1 or 0.\n      </p>\n\n    <hr>\n    <p>\n        EXAMPLE 1. A simple IP could have 1 memory map, 1 address block inside it, and three\n        32-bit registers: ctrl, data_in, and data_out. Ctrl allows both read and write accesses,\n        data_in is write-only, and data_out is read-only. The lower part of ctrl register\n        is divided into two 8-bit fields and designer can describe how they are used. The\n        upper bits are not used. Data registers do not have field definitions.\n        <br>\n        <br>\n        Number of Addresss unit bits(AUB) of the memory map is set to 8 bits. There are\n        3 registers with identical size (32b), Hence, range = 12 = 3 * 32/AUB = 3 * 32/8\n        = 3 * 4. Let's assume base address=0x100. Since address block has 12 Bytes in total,\n        it reserves the (byte) addresses 0x100-0x10B. It is good to set the width of the\n        address block 32 b so that full register can be accessed at once. Smaller accesses\n        (e.g. 1 byte at a time) are also allowed.\n        <br>\n        <img src=\"../images/mem_map_visualization.png\" alt=\"screen_cap_of_mem_map_visualization\">\n    </p>\n\n    <p>\n        EXAMPLE 2. An opaque bridge provides access from a slave interface\n        to a master interface through a specific memory region i.e. a subspace map.\n        The address space and any memory maps connected to the master interface\n        remain obscured (opaque) behind the subspace map.\n        <br>\n        <br>\n        The slave bus interface accessIF provides access to memory map MM0 which contains\n        an address block ab0 and a subspace map ssm0. The subspace map refers master bus\n        interface outIF indicating that any access to memory locations within ssm0 are redirected\n        out of bus interface outIF. The subspace map size will match the address space AS0 range\n        (or segment range, if segment is specified) referenced in master interface outIF.\n        Any interface connected to accessIF will have visibility only to ab0 and ssm0 within the\n        memory map MM0 and no visibility to AS0 while still being able to transfer data to\n        components connected to outIF.\n        <br>\n        <img src=\"../images/subspace_map.png\" alt=\"subspace map visual\">\n    </p>\n</body>\n</html>\n"
  },
  {
    "path": "Help/componenteditor/memorymap2022.html",
    "content": "﻿<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01//EN\" \"http://www.w3.org/TR/html4/strict.dtd\">\n<html>\n<head>\n    <meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">\n    <link href=\"../style.css\" rel=\"Stylesheet\" type=\"text/css\">\n    <title>Memory map editor</title>\n</head>\n<body>\n    <h2>Memory map editor</h2>\n    <p>\n        Memory map editor can be used to edit the details of a <i>memory map</i>.\n    </p>\n    <p>\n        Memory maps visualization is shown on the right of the editor. The visualization\n        can be expandped and minimized by clicking the expand arrow\n        <img src=\"../images/triangle_arrow_right.png\" alt=\"expand\">\n        and the minimize arrow\n        <img src=\"../images/triangle_arrow_down.png\" alt=\"minimize\">. Selecting any part\n        of the visualization will open the editor set for that item. The visualization can\n        be resized by dragging the border between the editor and the visualization. Holding\n        Ctrl-key while scrolling with the mouse wheel increases/decreases the width of the\n        items.\n    </p>\n\n    <p>\n        <b>Name</b> is a mandatory identifier for the <i>memory map</i>.\n    </p>\n    <p>\n        <b>Display name</b> is an optional and used for a more user-friendly identifier.\n    </p>\n    <p>\n        <b>Short description</b> is an optional field for compact description of the <i>memory map</i>.\n    </p>\n    <p>\n        <b>Description</b> is an optional field for textual description of the <i>memory map</i>.\n    </p>\n    <p>\n        <b>Address unit bits</b> (AUB) defines the number of data bits each address increment\n        of the <i>memory map</i> contains, e.g. 8b or 32b. The default setting for a <i>memory map</i>\n        is byte addressable (8 bits). E.g. if AUB=8, then 32-bit registers are at addresses\n        0x0, 0x4, 0x8... If AUB=32, they are in addresses 0x0, 0x1, 0x2... AUB is the unit\n        for base addresses and ranges within the address map.\n    </p>\n    <p>\n        <b>Target interface binding</b> shows which target <i>bus interfaces</i> are used to access\n        the <i>memory map</i>. The binding can only be set in the bus interface editor, but is\n        shown here for convenience.\n    </p>\n    \n    <p>\n        <b>Mode references</b> identify operating modes for which a memory remap is active. <i>Memory maps</i> do not contain <i>mode references</i>,\n        while <i>memory remaps</i> must be given at least one <i>mode reference</i> paired with a <i>priority</i> value. Each <i>mode reference</i>\n        value must be unique within the containing memory map, while <i>priorities</i> do not have such limitations.\n    </p>\n\n    <h3>Address blocks table</h3>\n    <p>\n        <b>Address block</b> specifies a single contiguous block, either a set of registers\n        or a block of memory. Registers within the <i>address block</i> are further divided\n        into bit <i>fields</i>.\n    </p>\n    <p>\n        <b>Name</b> is a mandatory identifier for the <i>address block</i>.\n    </p>\n    <p>\n        <b>Base address</b> is mandatory and specifies the starting address for the <i>address block</i>.\n        It is expressed as address unit bits as defined in the containing <i>memory map</i>,\n\t\te.g. 8 or 32 bits.\n    </p>\n    <p>\n        <b>Range</b> is mandatory and specifies the size of the block in address unit bits.\n    </p>\n    <p>\n        <b>Width</b> is mandatory and specifies the data width in bits of a row in the\n\t\t<i>address block</i>. It sets the\n        maximum allowed size of a single transfer and also defines the maximum size of a\n        single register. Register can be smaller but not wider than the value.\n    </p>\n    <p>\n        <b>Usage</b> is optional and is used to categorize the usage of the <i>address block</i>. The\n        possible values are:\n    </p>\n    <ul>\n        <li><b>Memory</b> specifies the <i>address block</i> as memory.\n\t\tA memory <i>address block</i> cannot contain registers.</li>\n        <li><b>Register</b> specifies the entire <i>address block</i> to contain registers.</li>\n        <li><b>Reserved</b> specifies the entire <i>address block</i> as reserved for usage\n\t\tthat is unknown to IP-XACT. A reserved <i>address block</i> cannot include registers.</li>\n    </ul>\n    <p>\n        <b>Access</b> is optional and specifies the accessibility of the <i>address block</i> by modifying\n        the first <i>access policy</i> of the <i>address block</i>. If multiple <i>access policies</i> exist, then the access value \n        cannot be edited here and must be edited for each access policy separately in the address block editor. \n        If no access policy exists, then one will be created for the address block when the access value is \n        edited here. The possible access values are:\n    </p>\n    <ul>\n        <li><b>read-write</b>. Both read and write transactions may have an effect on this address\n            block.</li>\n        <li><b>read-only</b>. Only read transactions are allowed in this register.</li>\n        <li><b>write-only</b>. Only write transactions are allowed in this register.</li>\n        <li><b>read-writeOnce</b>. Read actions are allowed and the first write action may have\n            an effect on this address block.</li>\n        <li><b>writeOnce</b>. Only the first write action affects the contents of this address\n            block.</li>\n    </ul>\n    <p>\n        <b>Volatile</b> is optional and indicates that the stored value may change without initiator's\n        write operation. For example, the timer value gets updated automatically and initiator\n        must always issue a read to get the latest value.\n    </p>\n    <p>\n        <b>Description</b> is an optional field for textual description of the <i>address block</i>.\n    </p>\n\n    <h3>Subspace maps table</h3>\n\n    <p>\n    <b>Name</b> is a mandatory identifier for the <i>subspace map</i>.\n    </p>\n    <p>\n        <b>Base address</b> is mandatory and specifies the starting address for the <i>subspace\n        map</i> in address unit bits. The range is equal to the referenced <i>address\n        space</i> or <i>segment</i>.\n    </p>\n    <p>\n        <b>Initiator interface</b> is a mandatory identifier for the bridged initiator <i>bus interface</i>\n        that is accessed by the subspace map.\n    </p>\n    <p>\n        <b>Segment</b> is an optional reference to a <i>segment</i> within the\n        referenced initiator <i>bus interface</i>. If a <i>segment</i> is defined,\n        the access is limited to the specified segment instead of the whole\n        <i>address space</i>.\n    </p>\n    <p>\n        <b>Description</b> is an optional field for textual description of the <i>subspace map</i>.\n    </p>\n\n    <hr>\n    <p>\n        EXAMPLE 1. A simple IP could have 1 memory map, 1 address block inside it, and three\n        32-bit registers: ctrl, data_in, and data_out. Ctrl allows both read and write accesses,\n        data_in is write-only, and data_out is read-only. The lower part of ctrl register\n        is divided into two 8-bit fields and designer can describe how they are used. The\n        upper bits are not used. Data registers do not have field definitions.\n        <br>\n        <br>\n        Number of Addresss unit bits(AUB) of the memory map is set to 8 bits. There are\n        3 registers with identical size (32b), Hence, range = 12 = 3 * 32/AUB = 3 * 32/8\n        = 3 * 4. Let's assume base address=0x100. Since address block has 12 Bytes in total,\n        it reserves the (byte) addresses 0x100-0x10B. It is good to set the width of the\n        address block 32 b so that full register can be accessed at once. Smaller accesses\n        (e.g. 1 byte at a time) are also allowed.\n        <br>\n        <img src=\"../images/mem_map_visualization.png\" alt=\"screen_cap_of_mem_map_visualization\">\n    </p>\n\n    <p>\n        EXAMPLE 2. An opaque bridge provides access from a target interface\n        to an initiator interface through a specific memory region i.e. a subspace map.\n        The address space and any memory maps connected to the initiator interface\n        remain obscured (opaque) behind the subspace map.\n        <br>\n        <br>\n        The target bus interface accessIF provides access to memory map MM0 which contains\n        an address block ab0 and a subspace map ssm0. The subspace map refers initiator bus\n        interface outIF indicating that any access to memory locations within ssm0 are redirected\n        out of bus interface outIF. The subspace map size will match the address space AS0 range\n        (or segment range, if segment is specified) referenced in initiator interface outIF.\n        Any interface connected to accessIF will have visibility only to ab0 and ssm0 within the\n        memory map MM0 and no visibility to AS0 while still being able to transfer data to\n        components connected to outIF.\n        <br>\n        <img src=\"../images/subspace_map.png\" alt=\"subspace map visual\">\n    </p>\n</body>\n</html>\n"
  },
  {
    "path": "Help/componenteditor/memorymaps.html",
    "content": "﻿<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01//EN\" \"http://www.w3.org/TR/html4/strict.dtd\">\n<html>\n  <head>\n    <meta http-equiv=\"Content-Type\"content=\"text/html; charset=utf-8\">\n    <link href=\"../style.css\" rel=\"Stylesheet\" type=\"text/css\">\n    <title>Memory maps editor</title>\n  </head>\n  <body>\n    <h2>Memory maps editor</h2>\n    <p>\n      Memory maps editor contains the summary of the <i>memory maps</i> and <i>memory remaps</i> contained in the\n      component and can be used to add, remove and edit them.\n    </p>\n\t<p>\n        Memory maps visualization is shown on the right of the editor. The visualization can be expandped\n        and minimized by clicking the expand arrow <img src=\"../images/triangle_arrow_right.png\" alt=\"expand\"> \n        and the minimize arrow <img src=\"../images/triangle_arrow_down.png\" alt=\"minimize\">. Selecting any part\n        of the visualization will open the editor set for that item. The visualization can be resized by dragging \n\t\tthe border between the editor and the visualization.\n\t\tHolding Ctrl-key while scrolling with the mouse wheel increases/decreases the width of the items.\n\t</p>\n\t\n     <p>\n\t   <b>Memory map</b> specifies the addressable area seen through a slave <i>bus interface</i>, e.g. the data and\n       control register.</p><p>\n       <b>Memory remap</b> describes additional memory map items that are mapped on the referencing slave \n\t   <i>bus interface</i> in a specific <i>remap state</i>. If multiple <i>memory remaps</i> or <i>remap state</i> \n\t   attributes are active, then the first <i>memory remap</i> listed shall be selected.\n    </p>\n    <h3>Memory map</h3>\n    <p>\n      <b>Name</b> is a mandatory identifier for the memory map.</p>\n\t  \t  \t  \n\t  <p>\n      <b>Remap state</b> is always 'default' for memory maps and cannot be changed. It applies only to memory\n\t  remaps.</p><p>\n\t  \n\t  <p>\n      <b>Address unit bits</b> (AUB) defines the number of data bits each address increment of the memory map\n      contains, e.g. 8b or 32b. The default setting for a <i>memory maps</i> is byte addressable (8 bits).\n\t  E.g. if AUB=8,\n      then 32-bit registers are at addresses 0x0, 0x4, 0x8... If AUB=32, they are in addresses 0x0, 0x1, 0x2...\n      AUB is the unit for base addresses and ranges within the address map.</p>\n\t  <p>\n\t  \n      <b>Slave interface binding</b> shows which slave bus interfaces are used to access the memory map.\n\t  The binding can only be set in the bus interface editor, but is shown here for convenience.</p>\n    \n\t  <p>\n        <b>Is present</b> is optional and allows enabling/disabling of a <i>memory map</i>\n        presence in a <i>component</i>. Value 1 indicates that the <i>memory map</i>\n        is present in the <i>component</i> whereas value 0 marks the memory map to be\n        treated as if it does not exist. Is present can be given as a SystemVerilog expression,\n        but it must evaluate to 1 or 0.</p>\n\t  <p>\n\t\n\t  <b>Description</b> is an optional field for textual description of the memory map.\n\n    <h3>Memory remap</h3>\n    <p>\n      <b>Name</b> is a mandatory identifier for the memory remap.</p><p>\n\t  Memory remaps use the <b>address unit bits</b> and <b>interface binding</b> of the parent memory map.</p><p>\n      <b>Remap state</b> identifies the name of the <i>remap state</i> for which the optional memory remap\n      elements are active. See remap states for further information on remap states. \n\t  <b>Description</b> is an optional field for textual description of the memory remap.\n    </p>\n\t\n    <h3>Context menu</h3>\n    <p>\n      Memory maps editor contains a context menu (right mouse button)\n      providing following options:\n    </p>\n    <ul>\n      <li>Add new memory map (Add memory map)</li>\n      <li>Add a new memory remap to the selected memory map (Add memory remap)</li>\n      <li>Remove memory map (Remove row)</li>\n      <li>Clear the selected cells</li>\n      <li>Copy the contents of the selected cells to clipboard</li>\n      <li>Paste the contents of the clipboard to the selected cells</li> \n      <li>Copy selected element to clipboard (Copy elements)</li>\n      <li>Paste the element from the clipboard along with its sub-elements (Paste elements)</li>\t  \n      <li>Import a csv-file to the editor</li>\n      <li>Export the contents of the editor to a csv-file</li>\n    </ul>  \n\n    <hr>\n    <p> \n      EXAMPLE. Component AccelA has two memory maps MM0 and MM1 that are accessible through\n      bus interface RegsIF. MM0 defines the hardware registers for read/write operations and\n      MM1 provides a random-access memory block.\n    </p>\n    <p>\n      <img src=\"../images/mem_map.png\" alt=\"mem map's idea\">\n    </p>\n  </body>\n</html>\n"
  },
  {
    "path": "Help/componenteditor/memorymaps2022.html",
    "content": "﻿<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01//EN\" \"http://www.w3.org/TR/html4/strict.dtd\">\n<html>\n  <head>\n    <meta http-equiv=\"Content-Type\"content=\"text/html; charset=utf-8\">\n    <link href=\"../style.css\" rel=\"Stylesheet\" type=\"text/css\">\n    <title>Memory maps editor</title>\n  </head>\n  <body>\n    <h2>Memory maps editor</h2>\n    <p>\n      Memory maps editor contains the summary of the <i>memory maps</i> and <i>memory remaps</i> contained in the\n      component and can be used to add, remove and edit them.\n    </p>\n\t<p>\n    Memory maps visualization is shown on the right of the editor. The visualization can be expandped\n    and minimized by clicking the expand arrow <img src=\"../images/triangle_arrow_right.png\" alt=\"expand\"> \n    and the minimize arrow <img src=\"../images/triangle_arrow_down.png\" alt=\"minimize\">. Selecting any part\n    of the visualization will open the editor set for that item. The visualization can be resized by dragging \n    the border between the editor and the visualization.\n    Holding Ctrl-key while scrolling with the mouse wheel increases/decreases the width of the items.\n\t</p>\n\t\n    <p>\n\t    <b>Memory map</b> specifies the addressable area seen through a target <i>bus interface</i>, e.g. the data and\n      control register.\n    </p>\n    <p>\n      <b>Memory remap</b> describes additional memory map items that are mapped on the referencing target \n\t    <i>bus interface</i> in a specific <i>mode</i>. If multiple <i>memory remaps</i> or <i>mode</i> \n\t    attributes are active, then the first <i>memory remap</i> listed shall be selected.\n    </p>\n    \n    <h3>Memory map</h3>\n    <p>\n      <b>Name</b> is a mandatory identifier for the memory map.\n    </p>\n\t  \t  \t  \n\t  <p>\n      <b>Mode reference</b> applies only to memory remaps and can be edited in the memory remap editor.\n    </p>\n    \t  \n\t  <p>\n      <b>Address unit bits</b> (AUB) defines the number of data bits each address increment of the memory map\n      contains, e.g. 8b or 32b. The default setting for a <i>memory maps</i> is byte addressable (8 bits).\n\t  E.g. if AUB=8,\n      then 32-bit registers are at addresses 0x0, 0x4, 0x8... If AUB=32, they are in addresses 0x0, 0x1, 0x2...\n      AUB is the unit for base addresses and ranges within the address map.\n    </p>\n\t  \n    <p>\n      <b>Target interface binding</b> shows which target bus interfaces are used to access the memory map.\n      The binding can only be set in the bus interface editor, but is shown here for convenience.\n    </p>\n    \n\t  <p>\n\t    <b>Description</b> is an optional field for textual description of the memory map.\n    </p>\n\n    <h3>Memory remap</h3>\n    <p>\n      <b>Name</b> is a mandatory identifier for the memory remap.\n    </p>\n    <p>\n\t    Memory remaps use the <b>address unit bits</b> and <b>interface binding</b> of the parent memory map.\n    </p>\n    \n    <p>\n      <b>Mode reference</b> identifies the name of the <i>mode reference</i> for which the optional memory remap\n      element is active. Displays the mode reference value, if only one exists, otherwise the displayed value is either '[multiple]' or 'None'.\n      The <i>mode references</i> can be edited in the memory remap editor. \n    </p>\n\n\t  <p>\n      <b>Description</b> is an optional field for textual description of the memory remap.\n    </p>\n\t\n    <h3>Context menu</h3>\n    <p>\n      Memory maps editor contains a context menu (right mouse button)\n      providing following options:\n    </p>\n    <ul>\n      <li>Add new memory map (Add memory map)</li>\n      <li>Add a new memory remap to the selected memory map (Add memory remap)</li>\n      <li>Remove memory map (Remove row)</li>\n      <li>Clear the selected cells</li>\n      <li>Copy the contents of the selected cells to clipboard</li>\n      <li>Paste the contents of the clipboard to the selected cells</li> \n      <li>Copy selected element to clipboard (Copy elements)</li>\n      <li>Paste the element from the clipboard along with its sub-elements (Paste elements)</li>\t  \n      <li>Import a csv-file to the editor</li>\n      <li>Export the contents of the editor to a csv-file</li>\n    </ul>  \n\n    <hr>\n    <p> \n      EXAMPLE. Component AccelA has two memory maps MM0 and MM1 that are accessible through\n      bus interface RegsIF. MM0 defines the hardware registers for read/write operations and\n      MM1 provides a random-access memory block.\n    </p>\n    <p>\n      <img src=\"../images/mem_map.png\" alt=\"mem map's idea\">\n    </p>\n  </body>\n</html>\n"
  },
  {
    "path": "Help/componenteditor/mode2022.html",
    "content": "﻿<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01//EN\" \"http://www.w3.org/TR/html4/strict.dtd\">\n<html>\n  <head>\n    <meta http-equiv=\"Content-Type\"content=\"text/html; charset=utf-8\">\n    <link href=\"../style.css\" rel=\"Stylesheet\" type=\"text/css\">\n    <title>Mode editor</title>\n  </head>\n  <body>\n    <h2>Mode editor</h2>\n    <p>\n      The mode editor can be used to edit the details of a component mode.\n    </p>\n\t  <p>\n\t    <b>Name</b> is a mandatory identifier for the <i>mode</i>.\n    </p>\n    <p>\n        <b>Display name</b> is an optional and used for a more user-friendly identifier.\n    </p>\n    <p>\n      <b>Short description</b> is an optional field for compact description of the <i>mode</i>.\n    </p>\n    <p>\n      <b>Description</b> is an optional field for textual description of the <i>mode</i>.\t\t\n    </p>\n\n    <h3>Condition</h3>\n    <p>\n      The condition defines when the mode is active. If the condition expression evaluates\n      to true, the component is operating in the defined mode. The condition may depend\n      on run-time value of a port, register field and other modes. The expression accepts\n      the following special functions:\n      <ul>\n        <li><b>$ipxact_port_value</b>( [port slice name] )</li>\n        <li><b>$ipxact_field_value</b>( [field slice name] )</li>\n        <li><b>$ipxact_mode_condition</b>( [mode name] )</li>\n      </ul>\n      The functions refer to a port input value, a value stored in a bitfield or\n      another mode condition value, respectively. The port slices and field slices\n      are defined below.\n    </p>\n\n    <h3>Condition ports</h3>\n    <p>\n      The condition ports can be referenced in the condition to check for their value\n      in the mode. \n    </p>\n\t  <p>\n\t    <b>Name</b> is a mandatory identifier for the <i>port reference</i>.\n    </p>\n    <p>\n\t    <b>Physical port</b> is a mandatory and identifies the <i>port</i> in the \n      component whose value may be checked in the condition.\n    </p>\n    <!--\n    <p>\n\t    <b>Sub port</b> not supported yet.\n    </p>\n    -->\n    <p>\n      <b>Left</b> and <b>right bounds</b> are optional for selecting a range of\n      bits in the port. If no indices are defined, the whole port is selected.\n    </p>\n    <p>\n      <b>Description</b> is an optional field for textual description of the <i>port</i>.\t\t\n    </p>\n\n    <h3>Condition fields</h3>\n    <p>\n      The condition fields can be referenced in the condition to check for their bit\n      pattern in the mode. \n    </p>\n\t  <p>\n\t    <b>Name</b> is a mandatory identifier for the <i>field reference</i>.\n    </p>\n    <p>\n\t    <b>Field</b> is a mandatory and identifies the <i>field</i> in the \n      component whose bit pattern may be checked in the condition.\n    </p>\n    <p>\n      <b>Leftmost bit</b> and <b>rightmost bit</b> are optional for selecting a range of\n      bits in the field. If no indices are defined, the whole field is selected.\n    </p>\n    <p>\n      <b>Description</b> is an optional field for textual description of the <i>port</i>.\t\t\n    </p>\n\n    <hr>\n    <p>\n    EXAMPLE. The mode named reset is active when the value of the bit 0 in the physical port\n    button_in i.e. button_in[0:0] is equal to 1. \n    <br>\n    <br>\n    <img src=\"../images/modeExample.png\" alt=\"Example of a reset condition\">\n  </p>\n  </body>\n</html>\n"
  },
  {
    "path": "Help/componenteditor/modes2022.html",
    "content": "﻿<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01//EN\" \"http://www.w3.org/TR/html4/strict.dtd\">\n<html>\n  <head>\n    <meta http-equiv=\"Content-Type\"content=\"text/html; charset=utf-8\">\n    <link href=\"../style.css\" rel=\"Stylesheet\" type=\"text/css\">\n    <title>Modes editor</title>\n  </head>\n  <body>\n    <h2>Modes editor</h2>\n    <p>\n      The modes editor lists the operating modes of the component.\n    </p>\n\t<p>\n\t    <b>Name</b> is a mandatory identifier for the <i>mode</i>.\n    </p>\n    <p>\n        <b>Display name</b> is an optional and used for a more user-friendly identifier.\n    </p>\n    <p>\n      <b>Short description</b> is an optional field for compact description of the <i>mode</i>.\n    </p>\n\t<p>\n        <b>Description</b> is an optional field for textual description of the <i>cpu</i>.\t\t\n    </p>\n    <p>\n      Modes editor provides a context menu (right mouse button) with\n      the following options:\n    </p>\n    <ul>\n      <li>Add new mode (Add row)</li>\n      <li>Remove mode (Remove row)</li>\n      <li>Clear the selected cells</li>\n      <li>Copy the contents of the selected cells to clipboard</li>\n      <li>Paste the contents of the clipboard to the selected cells</li>\n      <li>Import a csv-file to the editor</li>\n      <li>Export the contents of the editor to a csv-file</li>\n    </ul>\n  </body>\n</html>\n"
  },
  {
    "path": "Help/componenteditor/otherclockdrivers.html",
    "content": "﻿<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01//EN\" \"http://www.w3.org/TR/html4/strict.dtd\">\n<html>\n  <head>\n    <meta http-equiv=\"Content-Type\"content=\"text/html; charset=utf-8\">\n    <link href=\"../style.css\" rel=\"Stylesheet\" type=\"text/css\">\n    <title>Other clock drivers editor</title>\n  </head>\n  <body>\n    <h2>Other clock drivers editor</h2>\n    <p>\n      Other clock drivers-editor shows the clocks within the component\n      that are not directly associated with a top-level port.  This\n      kind of clocks could be i.e. virtual clocks or generated clocks.\n    </p>\n    <p>\n      The mandatory <b>clock name</b> identifies the other clock driver.\n    </p>\n    <p>\n      <b>Clock source</b> is optional and defines the physical path and name of the clock generation cell. \n      E.g. a component instantiated in VHDL and its output, like 'i_clkGen/clk1'. The waveform of the clock signal \n      has 4 parameters. Time units are either <strong>ps</strong> (picosecond) or <strong>ns</strong> (nanosecond).\n    </p>\n    <p>\n      <b>Clock period</b> defines the length of one cycle of clock pulse, e.g. 10 ns.\n    </p>\n    <p>\n      <b>Pulse offset</b> describes the time delay from start of the cycle to the first transition.\n    </p>\n    <p>\n      <b>Pulse value</b> defines the logic value which the first transition is made to, either 0 or 1.\n    </p>\n    <p>\n      <b>Pulse duration</b> specifies how long the value defined in pulse value is held, e.g. 5 ns.\n    </p>\n    <p>\n      Other clock drivers editor provides a context menu (right mouse\n      button) with the following options:\n    </p>\n    <ul>\n      <li>Add new clock (Add row)</li>\n      <li>Remove clock (Remove row)</li>\n      <li>Clear the selected cells</li>\n      <li>Copy the contents of the selected cells to clipboard</li>\n      <li>Paste the contents of the clipboard to the selected cells</li>\n      <li>Import a csv-file to the editor</li>\n      <li>Export the contents of the editor to a csv-file</li>\n    </ul>\n\n    <hr>\n    <p>\n      EXAMPLE. Component Foo has a regular clock input port ClkIn and two additional\n      clock sources clk0 and clk1 generated by instantiation clk_gen.\n    </p>    \n    <p>\n        <img src=\"../images/clk_drivers.png\" alt\"clk_example\"><br>\n    </p>\n  </body>\n</html>\n"
  },
  {
    "path": "Help/componenteditor/params.html",
    "content": "﻿<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01//EN\" \"http://www.w3.org/TR/html4/strict.dtd\">\r\n<html>\r\n  <head>\r\n    <meta http-equiv=\"Content-Type\"content=\"text/html; charset=utf-8\">\r\n    <link href=\"../style.css\" rel=\"Stylesheet\" type=\"text/css\">\r\n    <title>Parameters editor</title>\r\n  </head>\r\n  <body>\r\n    <h2>Parameters editor</h2>\r\n    <p>\r\n      Parameters editor can be used to add, remove and modify\r\n      parameters of a component. Parameters are name-value pairs to\r\n      configure or hold information related to the containing\r\n      component. Note that these are not equivalent of VHDL generics or\r\n\t  Verilog parameters.\r\n\t  In the columns, f(x) means that the value can be given as an expression.\r\n    </p>\r\n    <p>\r\n      Each parameter contains a mandatory <b>name</b> and an optional\r\n      <b>display name</b> for more user-friendly identifier. \r\n\t  <b>Description</b> is free text for further details.\r\n    </p>\r\n    <p>\r\n      <b>Type</b> is an optional constraint for the type to which the parameter value resolves. \r\n      Possible types are:\r\n    </p>\r\n    <ul>\r\n        <li><b>bit</b> indicates that the value shall resolve to a System Verilog bit,\r\n\t\twhich by default is resolved to a 1-bit value, unless a vector size has been \r\n\t\tspecified.</li>\r\n\r\n        <li><b>byte</b> indicates that the value shall resolve to a System Verilog byte,\r\n\t\twhich is resolved to an 8-bit integer value.</li>\r\n\r\n        <li><b>shortint</b> indicates that the value shall resolve to a System Verilog shortint,\r\n\t\twhich is resolved to a 16-bit integer value.</li>\r\n\t\t\r\n\t\t<li><b>int</b> indicates that the value shall resolve to a System Verilog int, which\r\n\t\tis resolved to a 32-bit integer value.</li>\r\n\t\t\r\n\t\t<li><b>longint</b> indicates that the value shall resolve to a System Verilog longint,\r\n\t\twhich is resolved to a 64-bit integer value.</li>\r\n\t\t\r\n\t\t<li><b>shortreal</b> indicates that the value shall resolve to a System Verilog\r\n\t\tshortint, which is resolved to a 32-bit floating point value. Both standard and \r\n\t\tscientific format (e.g 0.002 and 2e-3) are supported. This type applies also to\r\n\t\t<b>minimum value</b> and <b>maximum value</b>.</li>\r\n\t\t\r\n\t\t<li><b>real</b> indicates that the value shall resolve to a System Verilog real,\r\n\t\twhich is resolved to a 64-bit floating point value. Both standard and scientific \r\n\t\tformat (e.g. 0.002 and 2e-3) are supported. This type applies also to \r\n\t\t<b>minimum value</b> and <b>maximum value</b>.</li>\r\n\t\t\r\n\t\t<li><b>string</b> indicates that the value shall contain any text.</li>\r\n    </ul>\r\n    <p>\r\n      <b>Value</b> contains the mandatory default value of the parameter. This \r\n\t  value can be overridden in a design that instantiates this component.\r\n\t  The value is given in SystemVerilog format and may be given as an expression.\r\n      Any other text must be enclosed within quotes e.g. \"Any text\".\r\n    </p>\r\n\t<p>\r\n      By selecting a <b>choice</b>, the user can restrict the allowed parameter \r\n\t  values to a set of predefined values. Possible values are defined in the\r\n\t  choices of the containing component.\r\n    </p>\r\n    <p>\r\n      <b>Minimum value</b> and <b>maximum value</b> define the lower and upper\r\n      boundary for the parameter value. If the selected type is <b>bit</b> or \r\n\t  <b>string</b>, these fields have no effect.\r\n    </p>\r\n    <p>\r\n      <b>Resolve</b> specifies the configuration of the parameter. \r\n      Possible resolve values are:\r\n    </p>\r\n        <ul>\r\n        <li><b>immediate</b> indicates that the the value is defined\r\n        within the containing component. The value cannot be overridden\r\n        by the user or a generator in design configuration. This is the \r\n\t\tdefault value, when no resolve has been set.</li>\r\n\r\n        <li><b>user</b> indicates that the user can override the\r\n        default value in design configuration. Generators are not \r\n        allowed to change the value.</li>\r\n\r\n        <li><b>generated</b> indicates that a generator can\r\n        override the default value in a design configuration.</li>\r\n    </ul>\r\n    <p>\r\n      <b>Bit vector left</b> and <b>bit vector right</b> define the boundaries of a bit vector.\r\n      These values can only be set to bit type parameters.\r\n    </p>\r\n    <p>\r\n      <b>Array left</b> and <b>Array right</b> specify the left and right sides of array\r\n      dimension for the parameter in an output language e.g. Verilog. Both of these are\r\n      vendor attributes. The values can be given as an expression, but must resolve to\r\n      a decimal number. In order to get a valid array, both <i>Array left</i> and\r\n      <i>Array right</i> must be given.\r\n    </p>\r\n\t<p>\r\n\t  <b>Usage count</b> displays the number of references made to this parameter. Selecting \r\n      the usage count opens a reference analysis of the parameter. The usage count is automatically \r\n      updated to display the number of references made to the parameter.\r\n    </p>\r\n    <p>\r\n      Parameters editor contains a context menu (right mouse button)\r\n      that provides following options:\r\n    </p>\r\n    <ul>\r\n      <li>Add new parameter (Add row)</li>\r\n      <li>Remove parameter (Remove row)</li>\r\n      <li>Clear the selected cells</li>\r\n      <li>Copy the contents of the selected cells to clipboard</li>\r\n      <li>Paste the contents of the clipboard to the selected cells</li>\r\n      <li>Import a csv-file to the editor</li>\r\n      <li>Export the contents of the editor to a csv-file</li>\r\n    </ul>\r\n  </body>\r\n</html>\r\n"
  },
  {
    "path": "Help/componenteditor/portmaps.html",
    "content": "﻿<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01//EN\" \"http://www.w3.org/TR/html4/strict.dtd\">\n<html>\n  <head>\n    <meta http-equiv=\"Content-Type\"content=\"text/html; charset=utf-8\">\n    <link href=\"../style.css\" rel=\"Stylesheet\" type=\"text/css\">\n    <title>Port maps editor</title>\n  </head>\n  <body>\n    <h2>Port maps editor</h2> \n    <p>\n        User can map the <i>logical signals</i> of a bus interface to the physical <i>ports</i> of the component.\n        The physical ports are located in the top table, while the logical signals and port maps are located in\n        the bottom table.\n    </p>    \n\n    <h3>Creating a port map</h3>\n    <ul>\n        <li>\n            <b>Drag & Drop.</b> A <i>physical port</i> can be dragged over a <i>logical signal</i> to create a\n            port map connecting the selected physical port to the selected logical signal. Multiple physical ports\n            can be dragged simultaneously to the selected logical signal to create multiple port maps.\n        </li>\n        <li>\n            <b>Selecting a port.</b> A <i>physical port</i> can be selected for the logical signal from the\n            physical port column. This creates a port map connecting the selected physical port to the logical\n            signal.\n        </li>\n        <li>\n            <b>Context menu.</b> Right clicking on a logical port opens a context menu, through which it is\n            possible to create a new port map. This port map can then be filled with the desired data.\n        </li>\n        <li>\n            <b>Auto connect.</b> Creates a single port map for each logical signal that does not have a port map.\n            A suitable physical port is selected by matching the direction, type, size and the name of the logical\n            signal to physical ports. If <b>Physical port prefix</b> has been set, physical ports starting with the\n            given string will be prioritized in the connections. For example using prefix \"master\" will connect\n            logical port 'CLK' to physical port 'master_clk' over ports 'clk', 'slave_clk' etc.\n        </li>\n    </ul>\n\n    <h3>Removing a port map</h3>\n    <ul>\n        <li>\n            <b>Context menu.</b> A <i>port map</i> can be removed throught the context menu. Right click on the\n            selected port map to open the menu. From there, select remove port map.\n            <br />Opening the context menu on a <i>logical signal</i> allows the removing of all the port maps\n            connected to the logical signal.\n        </li>\n        <li>\n            <b>Remove all.</b> Clicking the <i>Remove all</i> button removes all the port maps from this bus\n            interface.\n        </li>\n    </ul>\n    \n    <h3>Physical port filters</h3>\n    <ul>\n        <li>\n            <b>Name</b> allows regular expressions to filter ports not matching the given expression.\n        </li>\n        <li>\n            <b>Type</b> selects whether to display wire ports or transactional ports.\n        </li>\n        <li>\n            <b>Direction</b> allows the selection of a port direction and filtering all the other ports with\n            different directions.\n        </li>\n        <li>\n            Connected ports can also be hidden through option <b>Hide connected</b>. By default, this filter is on,\n            but can be changed.\n        </li>\n    </ul>\n\t\n    <h3>Port maps</h3>\n    <p>\n        The port maps table consists of both the <i>logical signals</i> and the <i>port maps</i> referencing\n        logical signals. The table is constructed as a tree, where the port maps are child items of a logical\n        signal. Values for columns with an f(x) symbol can be given as expressions.\n        <br />If a logical signal has been referenced only once in the port maps of the bus interface, information\n        of the port map is displayed on the same row as the logical signal.\n        <br />If a single physical port is referenced in all the port maps referencing the logical signal, the\n        physical port name is displayed on the same row as the logical signal. If multiple port maps referencing\n        the same logical signal contain different physical ports, the name is displayed as [multiple].\n    </p>\n    <p>\n        The <i>logical signal</i> of a port map can be changed from the <b>logical port</b> column. This moves the\n        selected port map from its current position to the selected logical signal.\n        <br />The <i>physical port</i> can be changed from the <b>physical port</b> column.\n    </p>\n    <p>\n        A port map can be defined by giving ranges for the logical and physical sides. These ranges determine how\n        many and which bits are connected between the port and signal. These can be defined in the columns for the\n        <b>logical left</b>, <b>logical right</b>, <b>physical left</b> and <b>physical right</b>.\n    </p>\n    <p>\n        <b>Requirement</b> informs the user of the port map requirement of the logical signal. The requirement is\n        set in the abstraction definition of a bus definition, and cannot be edited here. The possible values are:\n    </p>\n    <ul>\n        <li>\n            <b>Illegal.</b> <i>Logical signal</i> may not be refereneced in a port map.\n        </li>\n        <li>\n            <b>Required.</b> <i>Logical signal</i> must be referenced in a port map.\n        </li>\n        <li>\n            <b>Optional.</b> The default value. Port maps can be created referencing the <i>logical signal</i>.\n        </li>\n    </ul>\n    <p>\n        <b>Tie off</b> displays the possible logical tie off of the port map. A port map must contain either a\n        reference to a physical port, or a logical tie off. The logical tie off indicates thate the physical\n        connection for this logical port is the specified value.\n    </p>\n    <p>\n        <b>Informative</b> specifies that the portMap is used only for information purposes.\n    </p>\n    <p>\n        <b>Invert</b> specifies that connections to the physical port are logically inverted.\n    </p>\n\n    <h4>Port maps context menu (right mouse button)</h4>\n    <ul>\n        <li>\n            <b>Add port map</b> (logical signal / port map). Add a port map to the selected logical signal.\n        </li>\n        <li>\n            <b>Remove port map</b> (port map). Remove the selected port map.\n        </li>\n        <li>\n            <b>Remove all port maps</b> (logical signal). Remove all the port maps referencing the selected\n            logical signal.\n        </li>\n        <li>\n            <b>Auto connect</b> (port map). Automatically tries to connect the selected port by locating a suitable\n            physical port matching the direction, type, size and the name of the logical signal to physical ports.\n        </li>\n        <li>\n            <b>Expand all.</b> Show the port maps connected to each logical signal.\n        </li>\n        <li>\n            <b>Collapse all.</b> Hide the port maps connected to each logical signal.\n        </li>\n    </ul>\n    \n    <hr>\n    <h3>Details</h3>\n    <p>\n        The port maps tab of a bus interface editor is used to group the physical ports of the containing component\n        to the logical signals listed in the associated abstraction definition.\n    </p>\n    <p>\n        The lower table contains the <i>logical signals</i> that were defined in the associated\n        <i>abstraction definition</i>. The upper table contains a list of the physical <i>ports</i> in the\n        component. The bottom table displays the mappings between logical signals and physical ports. The mapped\n        physical ports are removed from the physical ports table unless <b>Hide connected ports</b> is unchecked.\n    </p>\n\t<p>\n        The port directions are shown using the following icons:\n        <ul>\n            <li><img src=\"../images/input.png\"></img> in</li>\n            <li><img src=\"../images/output.png\"></img> out</li>\n            <li><img src=\"../images/inout.png\"> inout</img></li>\n\t\t\t<li><img src=\"../images/phantom.png\"> phantom</img></li>\n        </ul>\n    </p>\n    <p>\n        Picture below depicts how the physical ports between two component instances are connected through their\n        bus interfaces.<br> <img src=\"../images/PortmapVisualization.png\"\n        alt=\"The association between physical ports and logical signals\"><br> The physical ports of the component\n        A are on the left and those of component B on the right. Logical signals are in the middle and the lines\n        denote port mappings.  For example component A has mapped its port 'comm_out' to the logical signal 'COMM'\n        and component B has mapped its port comm_in to it.  When user connects these interfaces together in a\n        design, the physical ports get connected.\n        <br>\n        All ports of the component do not need to be mapped in the interface nor do all the logical signals of the\n        abstraction definition need to be associated with a physical port. Abstraction definition defines the\n        directions of the signals in different interface modes thus making it possible to validate connections so\n        that two output ports are not accidentally connected to each other. In the figure above the abstraction\n        definition could have defined the DATA signal to have direction out in master interfaces and in at slave\n        interfaces.\n    </p>\n    <p>\n        A vectored physical port can be sliced to connect only part of it by assigning left and right bounds in the\n        mapping table. Picture below depicts how a part of the physical port can be connected.\n        <br> <img src=\"../images/portSlicingVisualization.png\"\n        alt=\"Connecting only a part of a vectored port in port map\"><br>\n    </p>\n  </body>\n</html>\n"
  },
  {
    "path": "Help/componenteditor/portmaps2022.html",
    "content": "﻿<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01//EN\" \"http://www.w3.org/TR/html4/strict.dtd\">\n<html>\n  <head>\n    <meta http-equiv=\"Content-Type\"content=\"text/html; charset=utf-8\">\n    <link href=\"../style.css\" rel=\"Stylesheet\" type=\"text/css\">\n    <title>Port maps editor</title>\n  </head>\n  <body>\n    <h2>Port maps editor</h2> \n    <p>\n        User can map the <i>logical signals</i> of a bus interface to the physical <i>ports</i> of the component.\n        The physical ports are located in the top table, while the logical signals and port maps are located in\n        the bottom table.\n    </p>    \n\n    <h3>Creating a port map</h3>\n    <ul>\n        <li>\n            <b>Drag & Drop.</b> A <i>physical port</i> can be dragged over a <i>logical signal</i> to create a\n            port map connecting the selected physical port to the selected logical signal. Multiple physical ports\n            can be dragged simultaneously to the selected logical signal to create multiple port maps.\n        </li>\n        <li>\n            <b>Selecting a port.</b> A <i>physical port</i> can be selected for the logical signal from the\n            physical port column. This creates a port map connecting the selected physical port to the logical\n            signal.\n        </li>\n        <li>\n            <b>Context menu.</b> Right clicking on a logical port opens a context menu, through which it is\n            possible to create a new port map. This port map can then be filled with the desired data.\n        </li>\n        <li>\n            <b>Auto connect.</b> Creates a single port map for each logical signal that does not have a port map.\n            A suitable physical port is selected by matching the direction, type, size and the name of the logical\n            signal to physical ports. If <b>Physical port prefix</b> has been set, physical ports starting with the\n            given string will be prioritized in the connections. For example using prefix \"initiator\" will connect\n            logical port 'CLK' to physical port 'initiator_clk' over ports 'clk', 'target_clk' etc.\n        </li>\n    </ul>\n\n    <h3>Removing a port map</h3>\n    <ul>\n        <li>\n            <b>Context menu.</b> A <i>port map</i> can be removed throught the context menu. Right click on the\n            selected port map to open the menu. From there, select remove port map.\n            <br />Opening the context menu on a <i>logical signal</i> allows the removing of all the port maps\n            connected to the logical signal.\n        </li>\n        <li>\n            <b>Remove all.</b> Clicking the <i>Remove all</i> button removes all the port maps from this bus\n            interface.\n        </li>\n    </ul>\n    \n    <h3>Physical port filters</h3>\n    <ul>\n        <li>\n            <b>Name</b> allows regular expressions to filter ports not matching the given expression.\n        </li>\n        <li>\n            <b>Type</b> selects whether to display wire ports or transactional ports.\n        </li>\n        <li>\n            <b>Direction</b> allows the selection of a port direction and filtering all the other ports with\n            different directions.\n        </li>\n        <li>\n            Connected ports can also be hidden through option <b>Hide connected</b>. By default, this filter is on,\n            but can be changed.\n        </li>\n    </ul>\n\t\n    <h3>Port maps</h3>\n    <p>\n        The port maps table consists of both the <i>logical signals</i> and the <i>port maps</i> referencing\n        logical signals. The table is constructed as a tree, where the port maps are child items of a logical\n        signal. Values for columns with an f(x) symbol can be given as expressions.\n        <br />If a logical signal has been referenced only once in the port maps of the bus interface, information\n        of the port map is displayed on the same row as the logical signal.\n        <br />If a single physical port is referenced in all the port maps referencing the logical signal, the\n        physical port name is displayed on the same row as the logical signal. If multiple port maps referencing\n        the same logical signal contain different physical ports, the name is displayed as [multiple].\n    </p>\n    <p>\n        The <i>logical signal</i> of a port map can be changed from the <b>logical port</b> column. This moves the\n        selected port map from its current position to the selected logical signal.\n        <br />The <i>physical port</i> can be changed from the <b>physical port</b> column.\n    </p>\n    <p>\n        A port map can be defined by giving ranges for the logical and physical sides. These ranges determine how\n        many and which bits are connected between the port and signal. These can be defined in the columns for the\n        <b>logical left</b>, <b>logical right</b>, <b>physical left</b> and <b>physical right</b>.\n    </p>\n    <p>\n        <b>Requirement</b> informs the user of the port map requirement of the logical signal. The requirement is\n        set in the abstraction definition of a bus definition, and cannot be edited here. The possible values are:\n    </p>\n    <ul>\n        <li>\n            <b>Illegal.</b> <i>Logical signal</i> may not be refereneced in a port map.\n        </li>\n        <li>\n            <b>Required.</b> <i>Logical signal</i> must be referenced in a port map.\n        </li>\n        <li>\n            <b>Optional.</b> The default value. Port maps can be created referencing the <i>logical signal</i>.\n        </li>\n    </ul>\n    <p>\n        <b>Tie off</b> displays the possible logical tie off of the port map. A port map must contain either a\n        reference to a physical port, or a logical tie off. The logical tie off indicates thate the physical\n        connection for this logical port is the specified value.\n    </p>\n    <p>\n        <b>Informative</b> specifies that the portMap is used only for information purposes.\n    </p>\n    <p>\n        <b>Invert</b> specifies that connections to the physical port are logically inverted.\n    </p>\n\n    <h4>Port maps context menu (right mouse button)</h4>\n    <ul>\n        <li>\n            <b>Add port map</b> (logical signal / port map). Add a port map to the selected logical signal.\n        </li>\n        <li>\n            <b>Remove port map</b> (port map). Remove the selected port map.\n        </li>\n        <li>\n            <b>Remove all port maps</b> (logical signal). Remove all the port maps referencing the selected\n            logical signal.\n        </li>\n        <li>\n            <b>Auto connect</b> (port map). Automatically tries to connect the selected port by locating a suitable\n            physical port matching the direction, type, size and the name of the logical signal to physical ports.\n        </li>\n        <li>\n            <b>Expand all.</b> Show the port maps connected to each logical signal.\n        </li>\n        <li>\n            <b>Collapse all.</b> Hide the port maps connected to each logical signal.\n        </li>\n    </ul>\n    \n    <hr>\n    <h3>Details</h3>\n    <p>\n        The port maps tab of a bus interface editor is used to group the physical ports of the containing component\n        to the logical signals listed in the associated abstraction definition.\n    </p>\n    <p>\n        The lower table contains the <i>logical signals</i> that were defined in the associated\n        <i>abstraction definition</i>. The upper table contains a list of the physical <i>ports</i> in the\n        component. The bottom table displays the mappings between logical signals and physical ports. The mapped\n        physical ports are removed from the physical ports table unless <b>Hide connected ports</b> is unchecked.\n    </p>\n\t<p>\n        The port directions are shown using the following icons:\n        <ul>\n            <li><img src=\"../images/input.png\"></img> in</li>\n            <li><img src=\"../images/output.png\"></img> out</li>\n            <li><img src=\"../images/inout.png\"> inout</img></li>\n\t\t\t<li><img src=\"../images/phantom.png\"> phantom</img></li>\n        </ul>\n    </p>\n    <p>\n        Picture below depicts how the physical ports between two component instances are connected through their\n        bus interfaces (note: in this picture the interface mode names used are of the old 2014 standard).<br>\n        <img src=\"../images/PortmapVisualization.png\" alt=\"The association between physical ports and logical signals\"><br>\n        The physical ports of the component A are on the left and those of component B on the right. Logical signals are in the middle and the lines\n        denote port mappings. For example component A has mapped its port 'comm_out' to the logical signal 'COMM'\n        and component B has mapped its port comm_in to it.  When user connects these interfaces together in a\n        design, the physical ports get connected.\n        <br>\n        All ports of the component do not need to be mapped in the interface nor do all the logical signals of the\n        abstraction definition need to be associated with a physical port. Abstraction definition defines the\n        directions of the signals in different interface modes thus making it possible to validate connections so\n        that two output ports are not accidentally connected to each other. In the figure above the abstraction\n        definition could have defined the DATA signal to have direction out in initiator interfaces and in at target \n        interfaces.\n    </p>\n    <p>\n        A vectored physical port can be sliced to connect only part of it by assigning left and right bounds in the\n        mapping table. Picture below depicts how a part of the physical port can be connected.\n        <br> <img src=\"../images/portSlicingVisualization.png\"\n        alt=\"Connecting only a part of a vectored port in port map\"><br>\n    </p>\n  </body>\n</html>\n"
  },
  {
    "path": "Help/componenteditor/ports.html",
    "content": "﻿<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01//EN\" \"http://www.w3.org/TR/html4/strict.dtd\">\n<html>\n  <head>\n    <meta http-equiv=\"Content-Type\"content=\"text/html; charset=utf-8\">\n    <link href=\"../style.css\" rel=\"Stylesheet\" type=\"text/css\">\n    <title>Ports editor</title>\n  </head>\n  <body>\n    <h2>Ports editor</h2>\n    <p>\n      Ports editor provides a table containing all the ports of a component. This editor is used\n      to view, add, remove and edit the ports. The port details can be edited in the Wires and\n      Transactionals section.\n    </p>\n    <p>\n      <b>Port name</b> is a unique identifier and must match the name of the port in the implementation language.\n    </p>\n    <p>\n      <b>Type</b> shows the kind of the port. The type is set when the port is created and cannot be changed here.\n    </p>\n    <ul>\n      <li><strong>wire</strong> port carries binary value(s) and are used in RTL.</li>\n      <li><strong>transactional</strong> port is used for all other kind of ports, especially in TLM.</li>\n    </ul>\n    <p>\n        <b>Port tags</b> column displays the optional tags for a port. These can be used to group ports together \n        to, for example, create bus interfaces.\n\t\t<br><img src=\"../images/appicon.png\" alt=\"Kactus-extension\">\n    </p>\n    <p>\n      <b>Ad-hoc</b> column is a Kactus2-specific extension which is used in the graphical user interface of a\n        hierarchical design. Ad-hoc determines whether the port is shown as an ad-hoc port when the component is\n        instantiated in a design.\n        <br><img src=\"../images/appicon.png\" alt=\"Kactus-extension\">\n    </p>\n    <p>\n      <b>Description</b> is an optional free text for further details.\n    </p>\n    <p>\n      Ports editor provides a context menu (right mouse button) that contains following options:\n    </p>\n    <ul>\n      <li>Add new wire port (Add wire)</li>\n      <li>Add new transactional port (Add transactional)</li>\n      <li>Remove port (Remove row)</li>\n      <li>Clear the selected cells</li>\n      <li>Copy the contents of the selected cells to clipboard</li>\n      <li>Paste the contents of the clipboard to the selected cells</li>\n    </ul>\n  </body>\n</html>\n"
  },
  {
    "path": "Help/componenteditor/powerdomains2022.html",
    "content": "﻿<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01//EN\" \"http://www.w3.org/TR/html4/strict.dtd\">\n<html>\n  <head>\n    <meta http-equiv=\"Content-Type\"content=\"text/html; charset=utf-8\">\n    <link href=\"../style.css\" rel=\"Stylesheet\" type=\"text/css\">\n    <title>Power domains editor</title>\n  </head>\n  <body>\n    <h2>Power domains editor</h2>\n    <p>\n      The power domains editor lists the applicable power domains of the \n      component. \n    </p>\n\t<p>\n\t    <b>Name</b> is a mandatory identifier for the <i>power domain</i>.\n    </p>\n    <p>\n        <b>Display name</b> is an optional and used for a more user-friendly identifier.\n    </p>\n    <p>\n      <b>Always on</b> </b> is optional and determines if the <i>power domain</i> \n      is always powered on (value 1) or not (value 0).\n      Always on can be given as a SystemVerilog expression, but it must evaluate to 1 or 0.\n    </p>\n    <p>\n      <b>Subdomain of</b> is optional and defines this power domain as a part of\n      another <i>power domain</i>.\n    </p>\n    <p>\n      <b>Short description</b> is an optional field for compact description of the <i>power domain</i>.\n    </p>\n\t  <p>\n        <b>Description</b> is an optional field for textual description of the <i>power domain</i>.\t\t\n    </p>\n    <p>\n      Power domains editor provides a context menu (right mouse button) with\n      the following options:\n    </p>\n    <ul>\n      <li>Add new power domain (Add row)</li>\n      <li>Remove power domain (Remove row)</li>\n      <li>Clear the selected cells</li>\n      <li>Copy the contents of the selected cells to clipboard</li>\n      <li>Paste the contents of the clipboard to the selected cells</li>\n      <li>Import a csv-file to the editor</li>\n      <li>Export the contents of the editor to a csv-file</li>\n    </ul>\n  </body>\n</html>\n"
  },
  {
    "path": "Help/componenteditor/register.html",
    "content": "﻿<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01//EN\" \"http://www.w3.org/TR/html4/strict.dtd\">\n<html>\n  <head>\n    <meta http-equiv=\"Content-Type\"content=\"text/html; charset=utf-8\">\n    <link href=\"../style.css\" rel=\"Stylesheet\" type=\"text/css\">\n    <title>Register editor</title>\n  </head>\n  <body>\n    <h2>Register editor</h2>\n    <p>\n      Register editor is used to edit the details of a single <i>register</i> and the possible \n\t  bit <i>fields</i> within the <i>register</i>. A bit field may contain just one bit, \n\t  the whole register or something in between.      \n    </p>\n\t\n\t<p>\n\t    <b>Name</b> is a mandatory identifier for the <i>register</i>. The name must be unique within \n\t\tall the <i>registers</i> of the containing <i>address block</i>.\n     </p>\n     <p>\n        <b>Display name</b> is an optional field and used for a more user-friendly identifier.\n     </p>\n     <p>\n        <b>Description</b> is an optional field for textual description of the <i>register</i>.\t\t\n    </p>\n\n    <p>\n      <b>Offset</b> is a mandatory value to specify the location of the <i>register</i> from the start of the\n      containing <i>address block</i> expressed as address units.</p><p>\n\n      <b>Size</b> is mandatory and defines the number of data bits the <i>register</i> contains. \n      Size must be less or equal to the width of the containing <i>address block</i>.\n    </p>\n    <p>\n      <b>Dimension</b> is optional and assigns an array dimension to the <i>register</i>. \n      The <i>register</i> will be repeated in the\n      <i>address block</i> as many times as indicated by the dimension value. An empty dimension (default)\n      or a dimension with value 1 means that the register is not an array and will appear exactly once.\n  </p>\n    <p>\n\t    <b>Is present</b> is optional and allows the enabling/disabling of a <i>register</i> presence \n\t\tin an <i>address block</i>. Value 1 indicates that the <i>register</i> is present in the \n\t\t<i>address block</i> whereas value 0 marks the <i>register</i> \n        to be treated as if it does not exist. Is present can be given as a SystemVerilog expression, but \n        it must evaluate to 1 or 0.\n    </p>\n    <p>\n      <b>Volatile</b> is optional and indicates whether the <i>register</i> value may change without \n\t  a write operation to it.\n   </p>\n   <p>\n      <b>Access</b> is optional and specifies the accessability of the register.\n\t  The possible values are:\n    </p>\n    <ul>\n        <li><b>read-write</b>. Both read and write transactions may have an effect on this <i>register</i>.</li>\n        <li><b>read-only</b>. Only read transactions are allowed in this <i>register</i>.</li>\n        <li><b>write-only</b>. Only write transactions are allowed in this <i>register</i>.</li>\n        <li><b>read-writeOnce</b>. Both read and write transactions may have an effect on this <i>register</i>. Only the\n            first write transaction, after an event that caused the reset value of the <i>register</i> to be loaded, may\n            affet the contents of the <i>register</i>, and read transactions return a value related to the values in the\n            <i>register</i>.</li>\n        <li><b>writeOnce</b>. Only the first write transaction affects the contents of the <i>register</i>.</li>\n    </ul>\n\t\n    <h3>Fields table</h3>\n    <p>\n      The fields table enables the user to define the <i>register</i> bit <i>fields</i>.\n\t  A <i>register</i> must contain at least one field.\n    </p>\n    <p>\n\t  <b>Name</b> is a mandatory identifier for the <i>field</i>.\n    </p>\n    <p>\n      <b>Offset</b> is a mandatory value to specify the starting bit of the <i>field</i> \n\t  within the <i>register</i>.\n   </p>\n   <p>\n      <b>Width</b> is a mandatory value to specify how many bits are included in the <i>field</i>.\n   </p>\n   <p>\n\t\t<b>Resets</b> defines the reset values of the field. The reset values must be edited in the field editor.\n\t\tIf a field only has one reset value, it is displayed here. If a field contains multiple reset values, they\n\t\tare displayed with a [multiple] tag. A tooltip provides basic information on the resets, displaying the reset type and value.\n   </p>\n   <p>\n      <b>Access</b> is optional and specifies the accessibility of the <i>field</i>. The possible values are:\n    </p>\n    <ul>\n        <li><b>read-write</b>. Both read and write transactions may have an effect on this <i>field</i>. Write\n            transactions may affect the contents of the <i>field</i>, and read transactions return a value related to\n            the <i>field</i>.</li>\n        <li><b>read-only</b>. A read transaction to this <i>field</i> returns a value related to the value in the <i>field</i>.\n            A write transaction to this <i>field</i> has undefined results.</li>\n        <li><b>write-only</b>. A write transaction to this address affects the contents of the <i>field</i>. A read\n            transaction to this <i>field</i> has undefined results.</li>\n        <li><b>read-writeOnce</b>. Both read and write transactions may have an effect on this <i>field</i>. Only the\n            first write transaction may affect the contents of the <i>field</i>, and read transactions return a value\n            related to the values in the <i>field</i>.</li>\n        <li><b>writeOnce</b>. Only the first write transaction affects the contents of this <i>field</i>.</li>\n    </ul>\n    <p>\n        <b>Modified write value</b> is optional anddescribes how the data in the <i>field</i> \n\t\tis manipulated on a write operation. \n        The basic operation without any setting is to store the written value 'as is'. Moreover, both bitwise \n        and field-wise set/clear/toggle is also possbile. The possible values are:\n    </p>\n    <ul>\n      <li><b>oneToClear</b>. Each written '1' bit will assign the corresponding bit to '0'.</li>\n      <li><b>oneToSet</b>. Each written '1' bit will assign the corresponding bit to '1'.</li>\n      <li><b>oneToToggle</b>. Each written '1' bit will toggle the corresponding bit.</li>\n      <li><b>zeroToClear, zeroToSet, zeroToToggle</b>. Similar to previous ones, except that written '0' bit\n        triggers the action.</li>\n      <li><b>clear</b>. Each write operation will clear all bits in the <i>field</i> to '0'.</li>\n      <li><b>set</b>. Each write operation will set all bits in the <i>field</i> to '1'.</li>\n      <li><b>modify</b>. Indicates that after a write operation all bits in the <i>field</i> can be modified.</li>\n      <li><b>'&nbsp; ' (empty setting)</i>. Indicates that the value written to a <i>field</i> is the value stored in the\n        <i>field</i>. This is the default.</li>\n    </ul>\n    <p>\n      <b>Read action</b> specifies if some action happens to the\n      <i>field</i> after a read operation. By default the register is\n      unmodified. The possible values are:\n    </p>\n    <ul>\n      <li><b>clear</b>. All bits in the <i>field</i> are cleared to '0' after a read operation.</li>\n      <li><b>set</b>. All bits in the <i>field</i> are set to '1' after a read operation.</li>\n      <li><b>modify</b>. Indicates that the bits in the <i>field</i> are modified in some way after a read operation.</li>\n      <li><b>'&nbsp; ' (empty setting)</b>. Indicates that <i>field</i> is not modified after a read operation. This is\n        the default.</li>\n    </ul>\n    <p>\n      <b>Testable</b> is optional and specifies if the <i>field</i> is testable by an automated register test.\n    </p>\n    <p>\n      <b>Test constraint</b> is optional and specifies the constraints for the automated tests for the <i>field</i>. \n      The possible constraint values are:\n    </p>\n    <ul>\n        <li><b>unConstrained</b>. There are no constrains for the written or read data. This is the default\n            setting.</li>\n        <li><b>restore</b>. The <i>field</i> value must be restored to its original value before accessing another\n            register.</li>\n        <li><b>writeAsRead</b>. The data written to a <i>field</i> must be the same that was read previously from the\n            <i>field</i>.</li>\n        <li><b>readOnly</b>. Indicates that the <i>field</i> can only be read.</li>\n    </ul>\n    <p>\n        <b>Is present</b> is optional and enables/disables a <i>field</i>'s presence in a register. Value 1 indicates that the field \n        is present in the register whereas value 0 marks the field to be treated as if it did not exist. Is \n        present can be given as a SystemVerilog expression, but it must evaluate to 1 or 0.\n    </p>\n    <p>    \n\t\t<b>Description</b> is an optional field for textual description of the <i>field</i>.\n  </body>\n</html>\n"
  },
  {
    "path": "Help/componenteditor/register2022.html",
    "content": "﻿<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01//EN\" \"http://www.w3.org/TR/html4/strict.dtd\">\n<html>\n  <head>\n    <meta http-equiv=\"Content-Type\"content=\"text/html; charset=utf-8\">\n    <link href=\"../style.css\" rel=\"Stylesheet\" type=\"text/css\">\n    <title>Register editor</title>\n  </head>\n  <body>\n    <h2>Register editor</h2>\n    <p>\n      Register editor is used to edit the details of a single <i>register</i> and the possible \n\t    bit <i>fields</i> within the <i>register</i>. A bit field may contain just one bit, \n\t    the whole register or something in between.      \n    </p>\n\t\n    <p>\n      <b>Name</b> is a mandatory identifier for the <i>register</i>. The name must be unique within \n      all the <i>registers</i> of the containing <i>address block</i>.\n    </p>\n    <p>\n      <b>Display name</b> is an optional and used for a more user-friendly identifier.\n    </p>\n    <p>\n      <b>Short description</b> is an optional field for compact description of the <i>register</i>.\n    </p>\n    <p>\n      <b>Description</b> is an optional field for textual description of the <i>register</i>.\t\t\n    </p>\n\n    <p>\n      <b>Offset</b> is a mandatory value to specify the location of the <i>register</i> from the start of the\n      containing <i>address block</i> expressed as address units.</p><p>\n\n      <b>Size</b> is mandatory and defines the number of data bits the <i>register</i> contains. \n      Size must be less or equal to the width of the containing <i>address block</i>.\n    </p>\n    <p>\n      <b>Dimension</b> is optional and assigns an array dimension to the <i>register</i>. \n\t    The <i>register</i> will be repeated in the\n      <i>address block</i> as many times as indicated by the dimension value. An empty dimension (default)\n      or a dimension with value 1 means that the register is not an array and will appear exactly once.\n    </p>\n    <p>\n      <b>Volatile</b> is optional and indicates whether the <i>register</i> value may change without \n\t    a write operation to it.\n   </p>\n   <p>\n      <b>Access policies</b> are optional and specify the accessability of the register data for different operating modes,\n      specified by mode references. If no mode reference is present, then the access policy applies to all modes not already \n      referenced by other access policies (i.e. only one access policy without mode references may exist).\n      \n      The possible access values for an access policy are:\n    </p>\n    <ul>\n      <li><b>read-write</b>. Both read and write transactions may have an effect on this <i>register</i>.</li>\n      <li><b>read-only</b>. Only read transactions are allowed in this <i>register</i>.</li>\n      <li><b>write-only</b>. Only write transactions are allowed in this <i>register</i>.</li>\n      <li><b>read-writeOnce</b>. Both read and write transactions may have an effect on this <i>register</i>. Only the\n          first write transaction, after an event that caused the reset value of the <i>register</i> to be loaded, may\n          affect the contents of the <i>register</i>, and read transactions return a value related to the values in the\n          <i>register</i>.</li>\n      <li><b>writeOnce</b>. Only the first write transaction affects the contents of the <i>register</i>.</li>\n    </ul>\n\t\n    <h3>Fields table</h3>\n    <p>\n      The fields table enables the user to define the <i>register</i> bit <i>fields</i>.\n      A <i>register</i> must contain at least one field.\n    </p>\n    <p>\n\t    <b>Name</b> is a mandatory identifier for the <i>field</i>.\n    </p>\n    <p>\n      <b>Offset</b> is a mandatory value to specify the starting bit of the <i>field</i> \n\t    within the <i>register</i>.\n    </p>\n    <p>\n      <b>Width</b> is a mandatory value to specify how many bits are included in the <i>field</i>.\n    </p>\n    <p>\n      <b>Resets</b> defines the reset values of the field. The reset values must be edited in the field editor.\n      If a field only has one reset value, it is displayed here. If a field contains multiple reset values, they\n      are displayed with a [multiple] tag. A tooltip provides basic information on the resets, displaying the reset type and value.\n    </p>\n    <p>\n      <b>Volatile</b> is optional and indicates whether the <i>field</i> value may change without \n\t    a write operation to it.\n   </p>\n    <p>\n      <b>Access</b> modifies the first field access policy of the field. If multiple field access policy exists, then the access \n      cannot be edited here and must be edited for each field access policy separately in the field editor. \n      If no field access policy exists, then one will be created for the field when the access is edited here. The possible access values are:\n    </p>\n    <ul>\n      <li>\n        <b>read-write</b>. Both read and write transactions may have an effect on this <i>field</i>. Write\n          transactions may affect the contents of the <i>field</i>, and read transactions return a value related to\n          the <i>field</i>.\n        </li>\n      <li>\n        <b>read-only</b>. A read transaction to this <i>field</i> returns a value related to the value in the <i>field</i>.\n          A write transaction to this <i>field</i> has undefined results.\n        </li>\n      <li>\n        <b>write-only</b>. A write transaction to this address affects the contents of the <i>field</i>. A read\n          transaction to this <i>field</i> has undefined results.\n        </li>\n      <li>\n        <b>read-writeOnce</b>. Both read and write transactions may have an effect on this <i>field</i>. Only the\n          first write transaction may affect the contents of the <i>field</i>, and read transactions return a value\n          related to the values in the <i>field</i>.\n        </li>\n      <li>\n        <b>writeOnce</b>. Only the first write transaction affects the contents of this <i>field</i>.\n      </li>\n    </ul>\n    <p>    \n\t\t  <b>Description</b> is an optional field for textual description of the <i>field</i>.\n    </p>\n  </body>\n</html>\n"
  },
  {
    "path": "Help/componenteditor/registerFile.html",
    "content": "﻿<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01//EN\" \"http://www.w3.org/TR/html4/strict.dtd\">\n<html>\n  <head>\n    <meta http-equiv=\"Content-Type\"content=\"text/html; charset=utf-8\">\n    <link href=\"../style.css\" rel=\"Stylesheet\" type=\"text/css\">\n    <title>Register file editor</title>\n  </head>\n  <body>\n    <h2>Register file editor</h2>\n    <p>\n      Register file editor is used to edit the details of a single <i>register file</i> and the \n\t    <i>registers</i> and <i>register files</i> within the <i>register file</i>.\n    </p>\n\t\n\t  <p>\n\t    <b>Name</b> is a mandatory identifier for the <i>register file</i>. The name must be unique within \n\t\t  all the <i>registers</i> or <i>register files</i> of the containing <i>address block</i> or <i>register file</i>.\n    </p>\n    <p>\n      <b>Display name</b> is an optional and used for a more user-friendly identifier.\n    </p>\n    <p>\n      <b>Description</b> is an optional field for textual description of the <i>register file</i>.\t\t\n    </p>\n\n    <p>\n      <b>Offset</b> is a mandatory value to specify the location of the <i>register file</i> from the start of the\n      containing <i>address block</i> or <i>register file</i> expressed as address units.\n    </p>\n    <p>\n      <b>Range</b> is mandatory and specifies the size of the register file in <i>address units bits</i>.\n    </p>\n    <p>\n      <b>Dimension</b> is optional and assigns an array dimension to the <i>register file</i>. \n\t    The <i>register file</i> will be repeated in the containing \n      <i>address block</i> or <i>register file</i> as many times as indicated by the dimension value. An empty dimension (default)\n      or a dimension with value 1 means that the register file is not an array and will appear exactly once.\n    </p>\n    <p>\n\t    <b>Is present</b> is optional and allows the enabling/disabling of a <i>register file</i> presence \n      in a containing <i>address block</i> or <i>register file</i>. Value 1 indicates that the <i>register file</i> is present in the \n      containing element whereas value 0 marks the <i>register file</i> \n      to be treated as if it does not exist. Is present can be given as a SystemVerilog expression, but \n      it must evaluate to 1 or 0.\n    </p>\n    <p>\n      <b>Access</b> is optional and specifies the accessability of the register file.\n\t    The possible values are:\n    </p>\n    <ul>\n        <li><b>read-write</b>. Both read and write transactions may have an effect on this <i>register file</i>.</li>\n        <li><b>read-only</b>. Only read transactions are allowed in this <i>register file</i>.</li>\n        <li><b>write-only</b>. Only write transactions are allowed in this <i>register file</i>.</li>\n        <li><b>read-writeOnce</b>. Both read and write transactions may have an effect on this <i>register file</i>. Only the\n            first write transaction, after an event that caused the reset value of the <i>register file</i> to be loaded, may\n            affet the contents of the <i>register file</i>, and read transactions return a value related to the values in the\n            <i>register file</i>.</li>\n        <li><b>writeOnce</b>. Only the first write transaction affects the contents of the <i>register file</i>.</li>\n    </ul>\n\t\n    <h3>Registers table</h3>\n    <p>\n      The registers table enables the user to define and edit <i>registers</i> of the <i>register file</i>.\n    </p>\n    <p>\n\t  <b>Name</b> is a mandatory identifier for the <i>register</i>.\n    </p>\n    <p>\n      <b>Offset</b> is a mandatory value to specify the location of the <i>register</i> \n\t    within the <i>register file</i> expressed as address units.\n    </p>\n    <p>\n      <b>Size</b> is mandatory and defines the number of data bits the <i>register</i> contains. \n      Size must be less or equal to the width of the containing <i>address block</i>.\n    </p>\n    <p>\n      <b>Dimension</b> is optional and assigns an array dimension to the <i>register</i>. \n      The <i>register</i> will be repeated in the containing\n      <i>register file</i> as many times as indicated by the dimension value. An empty dimension (default)\n      or a dimension with value 1 means that the register is not an array and will appear exactly once.\n    </p>\n    <p>\n      <b>Volatile</b> is optional and indicates whether the <i>register</i> value may change without \n      a write operation to it.\n    </p>\n    <p>\n      <b>Access</b> is optional and specifies the accessability of the register.\n\t  The possible values are:\n    </p>\n    <ul>\n        <li><b>read-write</b>. Both read and write transactions may have an effect on this <i>register</i>.</li>\n        <li><b>read-only</b>. Only read transactions are allowed in this <i>register</i>.</li>\n        <li><b>write-only</b>. Only write transactions are allowed in this <i>register</i>.</li>\n        <li><b>read-writeOnce</b>. Both read and write transactions may have an effect on this <i>register</i>. Only the\n            first write transaction, after an event that caused the reset value of the <i>register</i> to be loaded, may\n            affet the contents of the <i>register</i>, and read transactions return a value related to the values in the\n            <i>register</i>.</li>\n        <li><b>writeOnce</b>. Only the first write transaction affects the contents of the <i>register</i>.</li>\n    </ul>\n    <p>\n      <b>Is present</b> is optional and enables/disables a <i>register</i>'s presence in the register file. Value 1 indicates that the register \n      is present in the register file whereas value 0 marks the register to be treated as if it did not exist. Is \n      present can be given as a SystemVerilog expression, but it must evaluate to 1 or 0.\n    </p>\n    <p>    \n\t\t  <b>Description</b> is an optional field for textual description of the <i>register</i>.\n    </p>\n\n    <h3>Register files table</h3>\n    <p>\n      The register files table enables the user to define and edit <i>register files</i> within the <i>register file</i>.\n    </p>\n    <p>\n\t  <b>Name</b> is a mandatory identifier for the <i>register file</i>.\n    </p>\n    <p>\n      <b>Offset</b> is a mandatory value to specify the location of the <i>register file</i> \n\t    within the containing <i>register file</i> expressed as address units.\n    </p>\n    <p>\n      <b>Range</b> is mandatory and specifies the size of the <i>register file</i> in <i>address units bits</i>.\n    </p>\n    <p>\n      <b>Dimension</b> is optional and assigns an array dimension to the <i>register file</i>. \n      The <i>register file</i> will be repeated in the\n      containing <i>register file</i> as many times as indicated by the dimension value. An empty dimension (default)\n      or a dimension with value 1 means that the register file is not an array and will appear exactly once.\n    </p>\n    <p>\n      <b>Is present</b> is optional and enables/disables a <i>register</i>'s presence in the register file. Value 1 indicates that the register \n      is present in the register file whereas value 0 marks the register to be treated as if it did not exist. Is \n      present can be given as a SystemVerilog expression, but it must evaluate to 1 or 0.\n    </p>\n    <p>    \n\t\t  <b>Description</b> is an optional field for textual description of the <i>register</i>.\n    </p>\n  </body>\n</html>\n"
  },
  {
    "path": "Help/componenteditor/registerFile2022.html",
    "content": "﻿<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01//EN\" \"http://www.w3.org/TR/html4/strict.dtd\">\n<html>\n  <head>\n    <meta http-equiv=\"Content-Type\"content=\"text/html; charset=utf-8\">\n    <link href=\"../style.css\" rel=\"Stylesheet\" type=\"text/css\">\n    <title>Register file editor</title>\n  </head>\n  <body>\n    <h2>Register file editor</h2>\n    <p>\n      Register file editor is used to edit the details of a single <i>register file</i> and the \n\t    <i>registers</i> and <i>register files</i> within the <i>register file</i>.\n    </p>\n\t\n\t  <p>\n\t    <b>Name</b> is a mandatory identifier for the <i>register file</i>. The name must be unique within \n\t\t  all the <i>registers</i> or <i>register files</i> of the containing <i>address block</i> or <i>register file</i>.\n    </p>\n    <p>\n      <b>Display name</b> is an optional and used for a more user-friendly identifier.\n    </p>\n    <p>\n      <b>Short description</b> is a compact description of the register file.\n    </p>\n    <p>\n      <b>Description</b> is an optional field for textual description of the <i>register file</i>.\t\t\n    </p>\n\n    <p>\n      <b>Offset</b> is a mandatory value to specify the location of the <i>register file</i> from the start of the\n      containing <i>address block</i> or <i>register file</i> expressed as address units.\n    </p>\n    <p>\n      <b>Range</b> is mandatory and specifies the size of the register file in <i>address units bits</i>.\n    </p>\n    <p>\n      <b>Dimension</b> is optional and assigns an array dimension to the <i>register file</i>. \n\t    The <i>register file</i> will be repeated in the containing \n      <i>address block</i> or <i>register file</i> as many times as indicated by the dimension value. An empty dimension (default)\n      or a dimension with value 1 means that the register file is not an array and will appear exactly once.\n    </p>\n    <p>\n      <b>Access policies</b> are optional and specify the accessability of the register file data for different operating modes,\n      specified by mode references. If no mode reference is present, then the access policy applies to all modes not already \n      referenced by other access policies (i.e. only one access policy without mode references may exist).\n      \n      The possible access values for an access policy are:\n    </p>\n    <ul>\n      <li><b>read-write</b>. Both read and write transactions may have an effect on this <i>register file</i>.</li>\n      <li><b>read-only</b>. Only read transactions are allowed in this <i>register file</i>.</li>\n      <li><b>write-only</b>. Only write transactions are allowed in this <i>register file</i>.</li>\n      <li><b>read-writeOnce</b>. Both read and write transactions may have an effect on this <i>register file</i>. Only the\n          first write transaction, after an event that caused the reset value of the <i>register file</i> to be loaded, may\n          affect the contents of the <i>register file</i>, and read transactions return a value related to the values in the\n          <i>register file</i>.</li>\n      <li><b>writeOnce</b>. Only the first write transaction affects the contents of the <i>register file</i>.</li>\n    </ul>\n\t\n    <h3>Registers table</h3>\n    <p>\n      The registers table enables the user to define and edit <i>registers</i> of the <i>register file</i>.\n    </p>\n    <p>\n\t  <b>Name</b> is a mandatory identifier for the <i>register</i>.\n    </p>\n    <p>\n      <b>Offset</b> is a mandatory value to specify the location of the <i>register</i> \n\t    within the <i>register file</i> expressed as address units.\n    </p>\n    <p>\n      <b>Size</b> is mandatory and defines the number of data bits the <i>register</i> contains. \n      Size must be less or equal to the width of the containing <i>address block</i>.\n    </p>\n    <p>\n      <b>Dimension</b> is optional and assigns an array dimension to the <i>register</i>. \n      The <i>register</i> will be repeated in the containing\n      <i>register file</i> as many times as indicated by the dimension value. An empty dimension (default)\n      or a dimension with value 1 means that the register is not an array and will appear exactly once.\n    </p>\n    <p>\n      <b>Volatile</b> is optional and indicates whether the <i>register</i> value may change without \n      a write operation to it.\n    </p>\n    <p>\n      <b>Access</b> is optional and specifies the accessibility of the <i>register</i> by modifying\n      the first access policy of the register. If multiple <i>access policies</i> exist, then the access value \n      cannot be edited here and must be edited for each access policy separately in the register editor. \n      If no access policy exists, then one will be created for the register when the access is edited here.\n    \n      The possible access values are:\n    </p>\n    <ul>\n      <li><b>read-write</b>. Both read and write transactions may have an effect on this <i>\n          register</i>.</li>\n      <li><b>read-only</b>. Only read transactions are allowed in this <i>register</i>.</li>\n      <li><b>write-only</b>. Only write transactions are allowed in this <i>register</i>.</li>\n      <li><b>read-writeOnce</b>. Both read and write transactions may have an effect on this\n          <i>register</i>. Only the first write transaction, after an event that caused the\n          reset value of the <i>register</i> to be loaded, may affet the contents of the <i>register</i>,\n          and read transactions return a value related to the values in the <i>register</i>.</li>\n      <li><b>writeOnce</b>. Only the first write transaction affects the contents of the <i>\n          register</i>.</li>\n    </ul>\n    <p>    \n\t\t  <b>Description</b> is an optional field for textual description of the <i>register</i>.\n    </p>\n\n    <h3>Register files table</h3>\n    <p>\n      The register files table enables the user to define and edit <i>register files</i> within the <i>register file</i>.\n    </p>\n    <p>\n\t    <b>Name</b> is a mandatory identifier for the <i>register file</i>.\n    </p>\n    <p>\n      <b>Offset</b> is a mandatory value to specify the location of the <i>register file</i> \n\t    within the containing <i>register file</i> expressed as address units.\n    </p>\n    <p>\n      <b>Range</b> is mandatory and specifies the size of the <i>register file</i> in <i>address units bits</i>.\n    </p>\n    <p>\n      <b>Dimension</b> is optional and assigns an array dimension to the <i>register file</i>. \n      The <i>register file</i> will be repeated in the\n      containing <i>register file</i> as many times as indicated by the dimension value. An empty dimension (default)\n      or a dimension with value 1 means that the register file is not an array and will appear exactly once.\n    </p>\n    <p>    \n\t\t  <b>Description</b> is an optional field for textual description of the <i>register</i>.\n    </p>\n  </body>\n</html>\n"
  },
  {
    "path": "Help/componenteditor/remapStates.html",
    "content": "﻿<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01//EN\" \"http://www.w3.org/TR/html4/strict.dtd\">\n<html>\n  <head>\n    <meta http-equiv=\"Content-Type\"content=\"text/html; charset=utf-8\">\n    <link href=\"../style.css\" rel=\"Stylesheet\" type=\"text/css\">\n    <title>Remap states editor</title>\n  </head>\n  <body>\n    <h2>Remap states editor</h2>\n    <p>\n      The Remap states editor displays a summary of the remap states of a component.\n    </p>\n\t<p>\n\t    <b>Name</b> is a mandatory identifier for the <i>remap state</i>.\n    </p>\n    <p>\n        <b>Display name</b> is an optional and used for a more user-friendly identifier.\n    </p>\n    <p>\n        <b>Description</b> is an optional field for textual description of the <i>remap state</i>.\t\t\n    </p>\n  \n    <p>\n      Right clicking an item in the editor provides a context menu that can be used to:\n    </p>\n    <ul>\n      <li>Add a new <i>remap state</i> to the component (Add row).</li>\n      <li>Remove a <i>remap state</i> from the component (Remove row).</li>\n      <li>Clear the selected cells (Clear).</li>\n      <li>Copy the contents of the selected cells to clipboard (Copy).</li>\n      <li>Paste the contents of the clipboard to the selected cells (Paste).</li>\n    </ul>\n  </body>\n</html>\n"
  },
  {
    "path": "Help/componenteditor/resetTypes.html",
    "content": "<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01//EN\" \"http://www.w3.org/TR/html4/strict.dtd\">\n<html>\n<head>\n    <meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />\n    <link href=\"../style.css\" rel=\"Stylesheet\" type=\"text/css\" />\n    <title>Reset types editor</title>\n</head>\n<body>\n    <h2>Reset types editor</h2>\n\n    <p>\n        The Reset types editor is used to edit the details of a <i>reset type</i>.\n\t\tThe reset types describe any user-defined reset types referenced within field reset elements.\n\t\tThe default reset type for a field is HARD, and should be treated as pre-defined.\n    </p>\n\n    <p>\n        <b>Name</b> is a mandatory identifier for the <i>reset type</i>.\n\t\tThe name must be unique, and can not be the pre-defined default value HARD.\n    </p>\n    <p>\n        <b>Display name</b> is an optional and used for a more user-friendly identifier.\n    </p>\n    <p>\n        <b>Description</b> is an optional field for textual description of the <i>reset type</i>.\n    </p>\n</body>\n</html>\n"
  },
  {
    "path": "Help/componenteditor/resetTypes2022.html",
    "content": "<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01//EN\" \"http://www.w3.org/TR/html4/strict.dtd\">\n<html>\n<head>\n    <meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />\n    <link href=\"../style.css\" rel=\"Stylesheet\" type=\"text/css\" />\n    <title>Reset types editor</title>\n</head>\n<body>\n    <h2>Reset types editor</h2>\n\n    <p>\n        The Reset types editor is used to edit the details of a <i>reset type</i>.\n\t\tThe reset types describe any user-defined reset types referenced within field reset elements.\n\t\tThe default reset type for a field is HARD, and should be treated as pre-defined.\n    </p>\n\n    <p>\n        <b>Name</b> is a mandatory identifier for the <i>reset type</i>.\n\t\tThe name must be unique, and can not be the pre-defined default value HARD.\n    </p>\n    <p>\n        <b>Display name</b> is an optional and used for a more user-friendly identifier.\n    </p>\n    <p>\n        <b>Short description</b> is an optional field for compact description of the <i>reset type</i>.\n    </p>\n    <p>\n        <b>Description</b> is an optional field for textual description of the <i>reset type</i>.\n    </p>\n</body>\n</html>\n"
  },
  {
    "path": "Help/componenteditor/singleRemapState.html",
    "content": "﻿<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01//EN\" \"http://www.w3.org/TR/html4/strict.dtd\">\n<html>\n  <head>\n    <meta http-equiv=\"Content-Type\"content=\"text/html; charset=utf-8\">\n    <link href=\"../style.css\" rel=\"Stylesheet\" type=\"text/css\">\n    <title>Single remap state editor</title>\n  </head>\n  <body>\n    <h2>Single remap state editor</h2>\n    <p>\n      Remap state editor is used to edit the details of a single remap state.\n      A <i>remap state</i> defines a conditional state which\n      is conditioned by a remap port.\n      A <i>remap state</i> element does not specify the remapping addresses. Instead, they\n      are defined by the <b>memory remap</b> element (in a <b>memory map</b> element),\n\t  and its state attribute refers the <b>remap state</b> by name.\n    </p>\n\t<p>\n\t    <b>Name</b> is a mandatory identifier for the <i>remap state</i>.\n    </p>\n    <p>\n        <b>Display name</b> is an optional and used for a more user-friendly identifier.\n    </p>\n    <p>\n        <b>Description</b> is an optional field for textual description of the <i>remap state</i>.\t\t\n    </p>\n\t\n\t<h3>Remap State Condition</h3>\n    <p>\n      In addition to the name group, a remap state contains a remap state condition,\n      which is specified with the <b>remap port</b> elements. These elements make up the\n      condition for this remap state. All elements must be true for the remap state to\n      be enabled.\n    </p>\n    <p>\n      <b>Port</b> contains the names of the selected remap ports. These remap ports are\n      selected among the components ports. No port can be selected twice.\n    </p>\n    <p>\n      <b>Left bound</b> shows the left bound value of the selected port.\n      This value cannot be given, as it is read using the selected port. Together with\n      the value of the right bound column, this value is used to calculate the width of the port.\n    </p>\n    <p>\n      <b>Right bound</b> shows the right bound value of the selected port.\n      This value cannot be given, as it is read using the selected port. Together with\n      the value of the left bound column, this value is used to calculate the width of the port.\n    </p>\n    <p>\n      <b>Value</b> contains the value necessary so the specified port activates the\n      <i>remap state</i>. Depending on the width of the port, the remap condition value may be given as a single\n      expression for the whole port, or as separate expressions for each bit of the port. A port with a width of 1\n      is only allowed to receive a single expression.\n    </p>\n  </body>\n</html>\n"
  },
  {
    "path": "Help/componenteditor/subspacemap.html",
    "content": "﻿<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01//EN\" \"http://www.w3.org/TR/html4/strict.dtd\">\n<html>\n<head>\n    <meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">\n    <link href=\"../style.css\" rel=\"Stylesheet\" type=\"text/css\">\n    <title>Subspace map editor</title>\n</head>\n<body>\n    <h2>Subspace map editor</h2>\n    <p>\n        Subspace map editor is used to edit the details of a subspace map. Subspaces\n        are used for opaque bridges to define access from a memory map to an\n        address space of a master interface.\n    </p>\n    <p>\n    <b>Name</b> is a mandatory identifier for the <i>subspace map</i>.\n  </p>\n  <p>\n      <b>Display name</b> is an optional and used for a more user-friendly identifier.\n  </p>\n  <p>\n      <b>Description</b> is an optional field for textual description of the <i>subspace map</i>.\n  </p>\n\n      <p>\n          <b>Base address</b> is mandatory and specifies the starting address for the <i>subspace\n              map</i> in address unit bits. The range is equal to the referenced <i>address\n              space</i> or <i>segment</i>.\n      </p>\n\n    <p>\n         <b>MasterRef</b> is a mandatory identifier for the bridged master <i>bus interface</i>\n           that is accessed by the subspace map.\n    </p>\n    <p>\n        <b>SegmentRef</b> is an optional reference to a <i>segment</i> within the\n          referenced master <i>bus interface</i>. If a <i>segment</i> is defined,\n          the access is limited to the specified segment instead of the whole\n          <i>address space</i>.\n    </p>\n  \t<p>\n          <b>Is present</b> is optional and allows enabling/disabling of a <i>subspace map</i>\n          presence in a <i>memory map</i>. Value 1 indicates that the <i>subspace map</i>\n          is present in the <i>memory map</i> whereas value 0 marks the subspace map to be\n          treated as if it does not exist. Is present can be given as a SystemVerilog expression,\n          but it must evaluate to 1 or 0.\n    </p>\n</body>\n</html>\n"
  },
  {
    "path": "Help/componenteditor/subspacemap2022.html",
    "content": "﻿<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01//EN\" \"http://www.w3.org/TR/html4/strict.dtd\">\n<html>\n<head>\n    <meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">\n    <link href=\"../style.css\" rel=\"Stylesheet\" type=\"text/css\">\n    <title>Subspace map editor</title>\n</head>\n<body>\n    <h2>Subspace map editor</h2>\n    <p>\n        Subspace map editor is used to edit the details of a subspace map. Subspaces\n        are used for opaque bridges to define access from a memory map to an\n        address space of a initiator interface.\n    </p>\n    <p>\n        <b>Name</b> is a mandatory identifier for the <i>subspace map</i>.\n    </p>\n    <p>\n        <b>Display name</b> is an optional and used for a more user-friendly identifier.\n    </p>\n    <p>\n        <b>Short description</b> is an optional field for compact description of the <i>subspace map</i>.\n    </p>\n    <p>\n        <b>Description</b> is an optional field for textual description of the <i>subspace map</i>.\n    </p>\n\n    <p>\n        <b>Base address</b> is mandatory and specifies the starting address for the <i>subspace\n        map</i> in address unit bits. The range is equal to the referenced <i>address\n        space</i> or <i>segment</i>.\n    </p>\n\n    <p>\n        <b>Initiator reference</b> is a mandatory identifier for the bridged initiator <i>bus interface</i>\n        that is accessed by the subspace map.\n    </p>\n    <p>\n        <b>SegmentRef</b> is an optional reference to a <i>segment</i> within the\n        referenced initiator <i>bus interface</i>. If a <i>segment</i> is defined,\n        the access is limited to the specified segment instead of the whole\n        <i>address space</i>.\n    </p>\n</body>\n</html>\n"
  },
  {
    "path": "Help/componenteditor/swproperties.html",
    "content": "<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01//EN\" \"http://www.w3.org/TR/html4/strict.dtd\">\n<html>\n  <head>\n    <meta http-equiv=\"Content-Type\"content=\"text/html; charset=utf-8\">\n    <link href=\"../style.css\" rel=\"Stylesheet\" type=\"text/css\">\n    <title>Software properties editor</title>\n  </head>\n  <body>\n    <h2>Software properties editor</h2>\n    <p>\n      This is Kactus2 extension <br><img\n      src=\"../images/appicon.png\"><br><br> These allow defining\n      parameters for software. The usage is similar to <i>model\n      parameters</i>, first define the available parameters and then\n      give them actual values upon component instantiation. However,\n      these are separated, since other tools do not have such concept\n      and that might lead confusion which are HW parameters and and\n      which are SW parameters.  </p>\n    <p> \n      Each SW property has mandatory <b>name</b> and <b>type</b>\n      (string, integer, IP address). Moreover, sometimes the value\n      definition is <b>required</b> on each instance. Optional\n      <b>default value</b> is used, if instance does not specify the\n      value. Textual <b>desciption</b> is also optional.\n    </p>\n    <p>\n      For example, MCAPI nodes necessiate that user sets the 'node_id'\n      which is done through SW property. Similarly, some SW may need\n      the IP address of itself or other device and it can be also set\n      here.\n    </p>\n  </body>\n</html>\n"
  },
  {
    "path": "Help/componenteditor/systemview.html",
    "content": "<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01//EN\" \"http://www.w3.org/TR/html4/strict.dtd\">\n<html>\n  <head>\n    <meta http-equiv=\"Content-Type\"content=\"text/html; charset=utf-8\">\n    <link href=\"../style.css\" rel=\"Stylesheet\" type=\"text/css\">\n    <title>System view editor</title>\n  </head>\n  <body>\n    <h2>System view editor</h2>\n    <p>\n      This is Kactus2 extension <img src=\"../images/appicon.png\"><br>\n      Each system view has a mandatory <b>name</b>. <b>Display\n      name</b> is optional and typically a few words providing a more\n      detailed and/or user-friendly name for display. Optional\n      <b>description</b> contains a textual description of the\n      interface.\n    </p>\n    <p> <b>Hierarchy reference</b> is the VLNV of <i>system design</i>\n    which also a Kactus-extension.  It captures the mapping\n    informationand is saved in its own XML file. You can type the VLNV\n    or drag-drop a SW design from the library. Note that a system view\n    is always hierarchical, unlike regular <i>view</i>.\n    </p>\n  </body>\n</html>\n"
  },
  {
    "path": "Help/componenteditor/systemviews.html",
    "content": "﻿<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01//EN\" \"http://www.w3.org/TR/html4/strict.dtd\">\n<html>\n  <head>\n    <meta http-equiv=\"Content-Type\"content=\"text/html; charset=utf-8\">\n    <link href=\"../style.css\" rel=\"Stylesheet\" type=\"text/css\">\n    <title>System views editor</title>\n  </head>\n  <body>\n    <h2>System views editor</h2>\n    <p>\n      This is Kactus2 extension <br><img\n      src=\"../images/appicon.png\"><br><br> <i>System view</i> is a\n      usually associated with a component including multiple CPUs. It\n      is hierarchical reference to <i>system design</i> which is also\n      a Kactus-extension and defines the mapping of SW onto HW\n      resources.  One component, such as multiprocessor SoC (MPSoC),\n      can have multiple system views, i.e. multiple stored mappings,\n      and hence it is easy to switch between them. System design\n      defines how SW is mapped onto CPUs and it shows all HW\n      components that include a <i>CPU definition</i>. Mapping is\n      necessary if there are multiple CPUs or HW accelerators that\n      support the optional COM interfaces.\n    </p>\n    <p>\n      Each system view has mandatory <b>name</b> and <b>hierarchy\n      reference</b>. Note that the latter cannot be edited here, but\n      in view's own editor. Note also that a system view is always\n      hierarchical, unlike regular <i>view</i>.<b>Display name</b> is\n      optional and typically a few words providing a more detailed\n      and/or user-friendly name for display. Optional\n      <b>description</b> contains a textual description of the\n      interface.\n      </p>\n    <hr>\n    <p>EXAMPLE. A product includes two programmable CPUS: Nios on FPGA\n    and a regular PC. One system design performs the application\n    mapping so that discrete cosine transfrom (dct) is executed on PC\n    whereas the main function H.263 video encoder is on\n    Nios. Communication between these is done using MCAPI endpoints\n    and channels. Therefore Nios also includes the MCAPI SW component.\n    We notice that interface symbols are different in COM interfaces\n    (main - dct) and API interfaces (main - mcapi). Note also that\n    system design shows CPUs together although they appear on\n    different levels of product's hiearchy. <br><img\n    src=\"../images/system_views.png\" alt=\"example\">\n    </p>\n  </body>\n</html>\n"
  },
  {
    "path": "Help/componenteditor/transactionalPorts.html",
    "content": "﻿<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01//EN\" \"http://www.w3.org/TR/html4/strict.dtd\">\n<html>\n  <head>\n    <meta http-equiv=\"Content-Type\"content=\"text/html; charset=utf-8\">\n    <link href=\"../style.css\" rel=\"Stylesheet\" type=\"text/css\">\n    <title>Transactional ports editor</title>\n  </head>\n  <body>\n    <h2>Transactional ports editor</h2>\n    <p>\n      Transactional ports editor provides a table containing all the <i>transactional ports</i> of a component.\n        This editor is used to add, remove and edit the transactional ports.\n    </p>\n    <p>\n      <b>Port name</b> is a unique identifier and must match the name of the port in the implementation language.\n        For example, the ports listed in the VHDL entity declaration are listed here.\n    </p>\n    <p>\n        <b>Width</b> specifies the data width in bits. Can be given as an expression.\n    </p>\n    <p>\n      <b>Initiative</b> defines the type of access. Initiative has four options:\n    </p>\n    <ul>\n      <li><strong>requires</strong> defines an initiative requirement of the port.</li>\n      <li><strong>provides</strong> defines a provider port for initiative.</li>\n      <li><strong>both</strong> defines the type of access as both requires and provides.</li>\n      <li><strong>phantom</strong> for ports that exist on the IP-XACT component but not on the implementation.</li>\n    </ul>\n      <p>\n          <b>Kind</b> defines the ports type. Kind has four options, in addition to a custom type.\n          <ul>\n              <li><strong>tlm_port</strong> should only be used for TLM1 notation</li>\n              <li><strong>tlm_socket</strong></li>\n              <li><strong>simple_socket</strong></li>\n              <li><strong>multi_socket</strong></li>\n          </ul>\n      </p>\n      <p>\n          <b>Protocol</b> characterizes the information transportation method of the port. Currently not supported\n          in Kactus2.\n      </p>\n    <p>\n      The port <b>type</b> is optional together with a <b>type definition</b> that an optional language specific\n        reference to where the type is defined, e.g. package or header file. In SystemC, the type definition is \n\t\tthe include file name, e.g. 'systemc.h'. The type definition has no effect if type is not set. \n\t\tThe type can be applied to specific view(s) or all views.\n    </p>\n    <p>\n      <b>Array left</b> and <b>array right</b> are optional and define the indices of an array port. The values\n        can be given as an equation, but it must resolve into a decimal number. If either left or right value is\n        given, the port is considered to be of an array type.\n    </p>\n    <p>\n        <b>Port tags</b> column displays the optional tags for a port. These can be used to group ports together \n        to, for example, create bus interfaces.\n\t\t<br><img src=\"../images/appicon.png\" alt=\"Kactus-extension\">\n    </p>\n      <p>\n          <b>Max connections</b> and <b>Min connections</b> define the number of legal connections that can be made\n          to this port. <i>Max connceionts</i> indicates the maximum number of supported connections, while\n          <i>Min connections</i> indicates the minimum number of supported connections. These values can be given\n          as expressions.\n      </p>\n\t  <p>\n\t  <b>Ad-hoc</b> column is a Kactus2-specific extension which is used in the graphical user interface of a\n        hierarchical design. Ad-hoc determines whether the port is shown as an ad-hoc port when the component is\n        instantiated in a design.\n\t  <br><img src=\"../images/appicon.png\" alt=\"Kactus-extension\">\n\t  </p>\n    <p>\n      <b>Description</b> is an optional free text for further details.\n    </p>\n    <p>\n      Transactional ports editor provides a context menu (right mouse button) that contains following options:\n    </p>\n    <ul>\n      <li>Add new port (Add row)</li>\n      <li>Remove port (Remove row)</li>\n      <li>Clear the selected cells</li>\n      <li>Copy the contents of the selected cells to clipboard</li>\n      <li>Paste the contents of the clipboard to the selected cells</li>\n      <li>New Bus Interface creates a new bus interface in the component using the currently selected ports</li>\n      <li>Import a csv-file to the editor</li>\n      <li>Export the contents of the editor to a csv-file</li>\n    </ul>  \n  </body>\n</html>\n"
  },
  {
    "path": "Help/componenteditor/view.html",
    "content": "﻿<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01//EN\" \"http://www.w3.org/TR/html4/strict.dtd\">\n<html>\n  <head>\n    <meta http-equiv=\"Content-Type\"content=\"text/html; charset=utf-8\">\n    <link href=\"../style.css\" rel=\"Stylesheet\" type=\"text/css\">\n    <title>View editor</title>\n  </head>\n  <body>\n    <h2>View editor</h2>\n    <p>\n        <i>View</i> specifies a representation level of a component, e.g. there might be different views for \n        simulation and synthesis. This editor is used to edit the details of single view.\n    </p>\n\t<p>\n\t    <b>Name</b> is a mandatory identifier for the <i>view</i>.\n    </p>\n    <p>\n        <b>Display name</b> is an optional and used for a more user-friendly identifier.\n    </p>\n    <p>\n        <b>Description</b> is an optional field for textual description of the <i>view</i>.\t\t\n    </p>\n\t\n    <h3>Environment identifiers</h3>\n    <p>\n        Environment identifiers is optional textual information about how this view is deployed in \n        different tool environments.\n    </p>\n    <p>\n\t\t<b>Language</b> indicates this view may be compatible with a particular tool, but only if that \n        language is supported in that tool, e.g., different versions of some simulators may support two or \n        more languages.\n    </p>\n    <p>\n          <b>Tool</b> indicates that this view contains tool-information, e.g., HDL models that use \n          simulator-specific extensions. This should contain tool name and company name, separated by dots\n          e.g. 'designcompiler.designcompany.com'. Alternatively, the tool can have a generic value\n          such as '*Simulation' or '*Synthesis'.\n    </p>\n    <p>\n          <b>VendorSpecific</b> can further qualify tool and language compatibility, e.g. if some \n          appropriate simulator mode must be enabled. \n    </p>\n\t\n    <h3>Instantiations</h3>\n    <p>\n        <b>Component instantiation</b> is optional and specifies the <i>component instantiation</i>\n\t\tcontaining all the implementation details for the component with this view. For convenience, \n        details of the component instantiation are shown in the view editor if a <i>component instantiation</i> \n\t\thas been selected. \n\t\tFor more information on the  component instantiation, see the component instantiation editor.\n    </p>\n    <p>\n        <b>Design configuration instantiation</b> is optional and specifies the referenced <i>design configuration \n        instantiation</i>. For convenience, the referenced <i>design configuration</i> is shown in the view \n\t\teditor if a <i>design configuration instantiation</i> has been selected.\n\t\tWhen this view is active, this <i>design configuration</i> should be used to\n\t\tconfigure the component structure. \n\t\tFor more information on the design configuration instantiation, see the design configuration \n        instantiation editor.\n    </p>\n    <p>\n        <b>Design instantiation</b> is optional and specifies the referenced <i>design instantiation</i>. \t\t\n\t\tFor convenience, the referenced <i>design</i> is shown in the view \n\t\teditor if a <i>design instantiation</i> has been selected.\n\t\tWhen this view is active, this <i>design</i> should be used to\n\t\tdescribe the component structure. \n\t\tFor more information on the design instantiation, see the design instantiation editor.\n    </p>\n    \n  </body>\n</html>\n"
  },
  {
    "path": "Help/componenteditor/view2022.html",
    "content": "﻿<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01//EN\" \"http://www.w3.org/TR/html4/strict.dtd\">\n<html>\n  <head>\n    <meta http-equiv=\"Content-Type\"content=\"text/html; charset=utf-8\">\n    <link href=\"../style.css\" rel=\"Stylesheet\" type=\"text/css\">\n    <title>View editor</title>\n  </head>\n  <body>\n    <h2>View editor</h2>\n    <p>\n        <i>View</i> specifies a representation level of a component, e.g. there might be different views for \n        simulation and synthesis. This editor is used to edit the details of single view.\n    </p>\n\t<p>\n\t    <b>Name</b> is a mandatory identifier for the <i>view</i>.\n    </p>\n    <p>\n        <b>Display name</b> is an optional and used for a more user-friendly identifier.\n    </p>\n    <p>\n        <b>Short description</b> is an optional field for compact description of the <i>view</i>.\n    </p>\n    <p>\n        <b>Description</b> is an optional field for textual description of the <i>view</i>.\t\t\n    </p>\n\t\n    <h3>Environment identifiers</h3>\n    <p>\n        Environment identifiers is optional textual information about how this view is deployed in \n        different tool environments.\n    </p>\n    <p>\n\t\t<b>Language</b> indicates this view may be compatible with a particular tool, but only if that \n        language is supported in that tool, e.g., different versions of some simulators may support two or \n        more languages.\n    </p>\n    <p>\n          <b>Tool</b> indicates that this view contains tool-information, e.g., HDL models that use \n          simulator-specific extensions. This should contain tool name and company name, separated by dots\n          e.g. 'designcompiler.designcompany.com'. Alternatively, the tool can have a generic value\n          such as '*Simulation' or '*Synthesis'.\n    </p>\n    <p>\n          <b>VendorSpecific</b> can further qualify tool and language compatibility, e.g. if some \n          appropriate simulator mode must be enabled. \n    </p>\n\t\n    <h3>Instantiations</h3>\n    <p>\n        <b>Component instantiation</b> is optional and specifies the <i>component instantiation</i>\n\t\tcontaining all the implementation details for the component with this view. For convenience, \n        details of the component instantiation are shown in the view editor if a <i>component instantiation</i> \n\t\thas been selected. \n\t\tFor more information on the  component instantiation, see the component instantiation editor.\n    </p>\n    <p>\n        <b>Design configuration instantiation</b> is optional and specifies the referenced <i>design configuration \n        instantiation</i>. For convenience, the referenced <i>design configuration</i> is shown in the view \n\t\teditor if a <i>design configuration instantiation</i> has been selected.\n\t\tWhen this view is active, this <i>design configuration</i> should be used to\n\t\tconfigure the component structure. \n\t\tFor more information on the design configuration instantiation, see the design configuration \n        instantiation editor.\n    </p>\n    <p>\n        <b>Design instantiation</b> is optional and specifies the referenced <i>design instantiation</i>. \t\t\n\t\tFor convenience, the referenced <i>design</i> is shown in the view \n\t\teditor if a <i>design instantiation</i> has been selected.\n\t\tWhen this view is active, this <i>design</i> should be used to\n\t\tdescribe the component structure. \n\t\tFor more information on the design instantiation, see the design instantiation editor.\n    </p>\n    \n  </body>\n</html>\n"
  },
  {
    "path": "Help/componenteditor/views.html",
    "content": "﻿<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01//EN\" \"http://www.w3.org/TR/html4/strict.dtd\">\n<html>\n  <head>\n    <meta http-equiv=\"Content-Type\"content=\"text/html; charset=utf-8\">\n    <link href=\"../style.css\" rel=\"Stylesheet\" type=\"text/css\">\n    <title>Views editor</title>\n  </head>\n  <body>\n    <h2>Views editor</h2>\n    <p>\n      Views editor provides a summary of the views of the\n      component. The editor can be used to add and remove views.\n    </p>\n    <p>\n      A <i>view</i> specifies a representation level of a component,\n      e.g. there might be different views for simulation and\n      synthesis. A component can have multiple views and one of them \n      is selected as active when component is instantiated in a <i>design</i>.\n    </p>\n    <p>\n        <b>Name</b> is a mandatory identifier for the <i>view</i>.\n    </p>\n    <p>\n        <b>View type</b> is automatically determined by the view definition. \n        A non-hierarchical view defines an independent one-level representation of \n        the component. A hierarchical view implies there is a <i>design</i> \n        describing the sub-components that together compose this component.\n    </p>\n    <p>\n        <b>Description</b> is an optional field for textual description of the <i>view</i>.\n    </p>\n    <p>\n      The editor contains a context menu that contains following options:\n    </p>\n    <ul>\n      <li>Add new view (Add row)</li>\n      <li>Remove view (Remove row)</li>\n      <li>Clear the selected cells</li>\n      <li>Copy the contents of the selected cells to clipboard</li>\n      <li>Paste the contents of the clipboard to the selected cells</li>\n      <li>Import a csv-file to the editor</li>\n      <li>Export the contents of the editor to a csv-file</li>\n    </ul>\n\n    <hr>\n    <p>\n    A view specifies the instantiations composing the representation of the\n    component. Implementation specific details such as filesets and module \n    parameters are defined in a <i>component instantiation</i> whereas\n    <i>design instantiation</i> and <i>design configuration instantiation</i>\n    are used to identify the design describing the internal structure of\n    the component. A view can define any combination of the three\n    different instantiations.\n    <br>\n    <img src=\"../images/view.png\" alt=\"view's idea and composition\">\n    </p>\n  </body>\n</html>\n"
  },
  {
    "path": "Help/componenteditor/wirePorts.html",
    "content": "﻿<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01//EN\" \"http://www.w3.org/TR/html4/strict.dtd\">\n<html>\n  <head>\n    <meta http-equiv=\"Content-Type\"content=\"text/html; charset=utf-8\">\n    <link href=\"../style.css\" rel=\"Stylesheet\" type=\"text/css\">\n    <title>Wire ports editor</title>\n  </head>\n  <body>\n    <h2>Wire ports editor</h2>\n    <p>\n      Wire ports editor provides a table containing all the <i>wire ports</i> of a component. This editor is used\n      to add, remove and edit the wire ports.\n    </p>\n    <p>\n      <b>Port name</b> is a unique identifier and must match the name of the port in the implementation language.\n        For example, the ports listed in the VHDL entity declaration are listed here.\n    </p>\n    <p>\n      <b>Direction</b> has four options:\n    </p>\n    <ul>\n      <li><strong>in</strong> for input ports.</li>\n      <li><strong>out</strong> for output ports.</li>\n      <li><strong>inout</strong> for bidirectional and tri-state ports.</li>\n      <li><strong>phantom</strong> for ports that exist on the IP-XACT component but not on the implementation.\n        </li>\n    </ul>\n    <p>\n      <b>Left</b> and <b>right bounds</b> define the indices of a vectored port. The <b>width</b> of the port is\n        higher bound - lower bound + 1, e.g. 3 downto 0 requires 4 bits. For scalar ports\n        <i>left bound = right bound</i>. If either left bound or right bound is an expression, width cannot be set\n        manually.\n    </p>\n    <p>\n      The port <b>type</b> is optional together with a <b>type definition</b> that an optional language specific\n        reference to where the type is defined, e.g. package or header file. Typical values in VHDL are 'std_logic'\n        for scalar ports (i.e. 1 bit) and 'std_logic_vector' for vectored ports (multibit). In VHDL, 'std_logic'\n        types are defined in 'IEEE.std_logic_1164.all' ('all' means that the whole package is included). In\n        SystemC, the type definition is the include file name, e.g. 'systemc.h'. The type definition has no effect\n        if type is not set. The type can be applied to specific view(s) or all views.\n    </p>\n    <p>\n      <b>Default value</b> is optional and can be used to assign a value for an unconnected (input) port. This is\n        used, for example, when generating a structural top-level VHDL for the hierarchical component where some\n        input ports are not connected to any other port in the design.\n    </p>\n    <p>\n      <b>Array left</b> and <b>array right</b> are optional and define the indices of an array port. The values\n        can be given as an equation, but must resolve into a decimal number. If either left or right value is\n        given, the port is considered to be of an array type.\n    </p>\n    <p>\n        <b>Port tags</b> column displays the optional tags for a port. These can be used to group ports together \n        to, for example, create bus interfaces.\n\t\t<br><img src=\"../images/appicon.png\" alt=\"Kactus-extension\">\n    </p>\n    <p>\n      <b>Ad-hoc</b> column is a Kactus2-specific extension which is used in the graphical user interface of a\n        hierarchical design. Ad-hoc determines whether the port is shown as an ad-hoc port when the component is\n        instantiated in a design.\n\t  <br><img src=\"../images/appicon.png\" alt=\"Kactus-extension\">\n      <br> EXAMPLE: The component instances are drawn as rectangles and their external interfaces are drawn to the\n        edges of the rectangle. There are different symbols for different directions. The example instance in\n        figure has 5 <i>bus interfaces</i>: clk, led, rst_n, from_hibi and pkt_codec. Each interface includes 1 or\n        multiple ports, and the interface definition has its own VLNV. Moreover, user can select that some ports\n        are shown as <i>Ad-hoc</i>, e.g. if they are not necessarily associated in any bus interface.  Example\n        figure displays 2 ad-hoc ports: rx_av_in and led_out.\n      <br> <img src=\"../images/adHocPorts.PNG\" alt=\"Component instance with ad-Hoc ports\">\n    </p>\n    <p>\n      <b>Description</b> is an optional free text for further details.\n    </p>\n    <p>\n      Wire ports editor provides a context menu (right mouse button) that contains following options:\n    </p>\n    <ul>\n      <li>Add new port (Add row)</li>\n      <li>Remove port (Remove row)</li>\n      <li>Clear the selected cells</li>\n      <li>Copy the contents of the selected cells to clipboard</li>\n      <li>Paste the contents of the clipboard to the selected cells</li>\n      <li>New Bus Interface creates a new bus interface in the component\n        using the currently selected ports</li>\n      <li>Import a csv-file to the editor</li>\n      <li>Export the contents of the editor to a csv-file</li>\n    </ul>\n    <hr>\n    <p>\n      EXAMPLE. The figure shows the relation between VHDL source code and the port editor. The names, directions,\n        and bounds are obvious. Width is derived from the bounds, if given, but otherwise set to 1 to denote a\n        scalar port. The type of the ports is std_logic for clk and rst_n, and std_logic_vector for data_in and\n        data_out. For data_out, the type is defined only for view flat. In other ports no view is defined so the\n        same type is applied for all views (not shown in the figure below). The type definition is\n        IEEE.std_logic_1164.all for each port.\n\t  <br>\n      <img src=\"../images/ports.png\" alt=\"VHDL and screen_cap\">\n    </p>\n  </body>\n</html>\n"
  },
  {
    "path": "Help/definitions/abstractiondefinition.html",
    "content": "<html>\n<head>\n    <link href=\"../style.css\" rel=\"stylesheet\" type=\"text/css\">\n</head>\n<body>\n    <h2>Abstraction Definition</h2>\n    <p>\n    <p>\n        An abstraction definition can also be linked with a bus definition to provide additional validation\n        for bus connections. Abstraction definition defines what logical signals must be present in the bus\n        interface in order for the bus connection with such abstraction definition to be valid. A logical\n        signal can be either a wire signal or a transactional signal.\n    </p>\n\n    <p>\n        Logical signal editor contains a context menu (right mouse button) that provides following options:\n    </p>\n    <ul>\n        <li>Add master signal interface mode</li>\n        <li>Add slave signal interface mode</li>\n        <li>Add system signal interface mode</li>\n        <li>Add all unconnected system signals from the bus definition system group</li>\n        <li>Reset extended ports to reload the signals that have been extended from the extended abstraction definition </li>\n        <li>Add new logical signal (Add row)</li>\n        <li>Remove logical signal (Remove row)</li>\n        <li>Clear the selected cells</li>\n        <li>Copy the contents of the selected cells to clipboard</li>\n        <li>Paste the contents of the clipboard to the selected cells</li>\n        <li>Import a csv-file to the editor</li>\n        <li>Export the contents of the editor to a csv-file</li>\n    </ul>\n\n    <h4>Extended abstraction definition</h4>\n    <p>\n        Allows the creation of a family of interconnectable abstraction definitions. The extending abstraction\n        definition must have a bus type that extends the bus type of the extended abstraction definition. The\n        logical signals of the extended abstraction definition can be used and the following elements can be\n        edited:\n        <ul>\n            <li>Presence</li>\n            <li>Width</li>\n            <li>Default value</li>\n            <li>Driver</li>\n            <li>System group</li>\n        </ul>\n    </p>\n\n    <h3>Logical signal properties</h3>\n    <p>\n        <b>Name</b> is a mandatory unique identifier for the logical signal.\n    </p>\n\n    <p>\n        <b>Mode</b> defines for which interface mode the settings apply.\n    </p>\n    <ul>\n        <li>\n            <b>master</b> defines constraints for this signal when present in a master bus interface.\n        </li>\n        <li>\n            <b>slave</b> defines constraints for this signal when present in a slave bus interface.\n        </li>\n        <li>\n            <b>system</b> defines constraints for this signal when present in a system bus interface with a\n            matching group name.\n        </li>\n    </ul>\n\n    <p>\n        <b>Presence</b> is an optional restriction for the logical signal presence in a bus interface. It can\n        have one of the following three values:\n    </p>\n    <ul>\n        <li>\n            <b>required</b> indicates that the logical signal must appear in the connected bus interface.\n        </li>\n        <li>\n            <b>illegal</b> indicates that the logical signal must not appear in the connected bus interface.\n        </li>\n        <li>\n            <b>optional</b> does not apply any restrictions. This is the default value.\n        </li>\n    </ul>\n\n    <p>\n        <b>Qualifier</b> is an optional indicator for what kind of information the the signal carries. It can\n        have one of the following five values:\n    </p>\n    <ul>\n        <li>\n            <b>address</b> indicates that the signal carries address information.\n        </li>\n        <li>\n            <b>data</b> indicates that the signal carries data.\n        </li>\n        <li>\n            <b>empty</b> indicates that the signal may carry any information.\n        </li>\n    </ul>\n    <p>\n        <b>System group</b> helps identify the system interface the signal belongs to. System group is\n        mandatory for system mode and illegal for other modes.\n    </p>\n    <p>\n        <b>Description</b> is an optional free text for further details.\n    </p>\n\n    <h3>Wire properties</h3>\n    <p>\n        <b>Direction</b> is an optional restriction for the logical signal direction in the connected bus\n        interface. Direction can have one of the following values:\n    </p>\n    <ul>\n        <li>\n            <b>in</b>\n        </li>\n        <li>\n            <b>out</b>\n        </li>\n        <li>\n            <b>inout</b>\n        </li>\n    </ul>\n    <p>\n        <b>Width</b> is an optional definition of the number of bits in the logical signal. If not specified,\n        the number of bits in the connected physical port is used.\n    </p>\n    <p>\n        <b>Default value</b> is an optional value that is applied when the logical signal is not connected in\n        a connected bus interface.\n    </p>\n    <p>\n        <b>Driver</b> is an optional setting for defining what kind of a driver the logical signal requires in\n        a complete design. The possible values are the following:\n    </p>\n    <ul>\n        <li>\n            <b>any</b> indicates that any logical signal or value is valid for driving the signal. This is the\n            default value.\n        </li>\n        <li>\n            <b>clock</b> indicates that a repeating waveform is required.\n        </li>\n        <li>\n            <b>singleshot</b> indicates that a non-repeating waveform is required.\n        </li>\n        <li>\n            <b>none</b> indicates that no driver is required.\n        </li>\n    </ul>\n    <p>\n        Wire ports have additional values for <b>Qualifier</b>:\n    </p>\n    <ul>\n        <li>\n            <b>address</b> indicates that the signal carries address information.\n        </li>\n        <li>\n            <b>data</b> indicates that the signal carries data.\n        </li>\n        <li>\n            <b>clock</b> indicates that the signal is a repeating clock signal for the bus interface.\n        </li>\n        <li>\n            <b>reset</b> indicates that the signal is a reset signal for the bus interface and is used to set\n            the interface into a know valid state.\n        </li>\n    </ul>\n\n    <h3>Transactional properties</h3>\n    <p>\n        <b>Initiative</b> optional definition of the access type. Initiative can have any of the folowing\n        values:\n    </p>\n    <ul>\n        <li>\n            <b>requires</b>\n        </li>\n        <li>\n            <b>provides</b>\n        </li>\n        <li>\n            <b>requires/provides</b>\n        </li>\n    </ul>\n    <p>\n        <b>Kind</b> specifies the type of the transactional port. It can be one of the following values, though\n        tlm_port should be used for TLM1 notation, while others whould be used for TLM2:\n    </p>\n    <ul>\n        <li>\n            <b>tlm_port</b>\n        </li>\n        <li>\n            <b>tlm_socket</b>\n        </li>\n        <li>\n            <b>simple_socket</b>\n        </li>\n        <li>\n            <b>multi_socket</b>\n        </li>\n        <li>\n            <b>custom</b> name\n        </li>\n    </ul>\n    <p>\n        <b>Bus width</b> specifies the data width in bits.\n    </p>\n    <p>\n        <b>Protocol type</b> characterizes the communication protocol. Type can be one of these values:\n    </p>\n    <ul>\n        <li>\n            <b>tlm</b>\n        </li>\n        <li>\n            <b>custom</b>\n        </li>\n    </ul>\n    <p>\n        Protocol can contain a <b>payload</b> specifying the way information is transported. Payload has the\n        following sub elements:\n    </p>\n    <ul>\n        <li>\n            <b>Name</b>, specifying the payload's name.\n        </li>\n        <li>\n            <b>Type</b> mandatory specification of typing. Can have either of the two values:\n            <ul>\n                <li>\n                    generic\n                </li>\n                <li>\n                    specific\n                </li>\n            </ul>\n        </li>\n        <li>\n            <b>Extension</b> determines an extension for the payload.\n        </li>\n    </ul>\n\n    </p>\n</body>\n</html>\n"
  },
  {
    "path": "Help/definitions/abstractiondefinition2022.html",
    "content": "<html>\n<head>\n    <link href=\"../style.css\" rel=\"stylesheet\" type=\"text/css\">\n</head>\n<body>\n    <h2>Abstraction Definition</h2>\n    <p>\n    <p>\n        An abstraction definition can also be linked with a bus definition to provide additional validation\n        for bus connections. Abstraction definition defines what logical signals must be present in the bus\n        interface in order for the bus connection with such abstraction definition to be valid. A logical\n        signal can be either a wire signal or a transactional signal.\n    </p>\n\n    <p>\n        Logical signal editor contains a context menu (right mouse button) that provides following options:\n    </p>\n    <ul>\n        <li>Add initiator signal interface mode</li>\n        <li>Add target signal interface mode</li>\n        <li>Add system signal interface mode</li>\n        <li>Add all unconnected system signals from the bus definition system group</li>\n        <li>Reset extended ports to reload the signals that have been extended from the extended abstraction definition </li>\n        <li>Add new logical signal (Add row)</li>\n        <li>Remove logical signal (Remove row)</li>\n        <li>Clear the selected cells</li>\n        <li>Copy the contents of the selected cells to clipboard</li>\n        <li>Paste the contents of the clipboard to the selected cells</li>\n        <li>Import a csv-file to the editor</li>\n        <li>Export the contents of the editor to a csv-file</li>\n    </ul>\n\n    <h4>Extended abstraction definition</h4>\n    <p>\n        Allows the creation of a family of interconnectable abstraction definitions. The extending abstraction\n        definition must have a bus type that extends the bus type of the extended abstraction definition. The\n        logical signals of the extended abstraction definition can be used and the following elements can be\n        edited:\n        <ul>\n            <li>Presence</li>\n            <li>Width</li>\n            <li>Default value</li>\n            <li>Driver</li>\n            <li>System group</li>\n        </ul>\n    </p>\n\n    <h3>Logical signal properties</h3>\n    <p>\n        <b>Name</b> is a mandatory unique identifier for the logical signal.\n    </p>\n\n    <p>\n        <b>Mode</b> defines for which interface mode the settings apply.\n    </p>\n    <ul>\n        <li>\n            <b>initiator</b> defines constraints for this signal when present in an initiator bus interface.\n        </li>\n        <li>\n            <b>target</b> defines constraints for this signal when present in a target bus interface.\n        </li>\n        <li>\n            <b>system</b> defines constraints for this signal when present in a system bus interface with a\n            matching group name.\n        </li>\n    </ul>\n\n    <p>\n        <b>Presence</b> is an optional restriction for the logical signal presence in a bus interface. It can\n        have one of the following three values:\n    </p>\n    <ul>\n        <li>\n            <b>required</b> indicates that the logical signal must appear in the connected bus interface.\n        </li>\n        <li>\n            <b>illegal</b> indicates that the logical signal must not appear in the connected bus interface.\n        </li>\n        <li>\n            <b>optional</b> does not apply any restrictions. This is the default value.\n        </li>\n    </ul>\n\n    <p>\n        <b>Qualifier</b> is an optional indicator for what kind of information the the signal carries. It can\n        have any combination of the following values:\n    </p>\n    <ul>\n        <li>\n            <b>address</b> indicates that the signal carries address information.\n        </li>\n        <li>\n            <b>data</b> indicates that the signal carries data.\n        </li>\n        <li>\n            <b>clock</b> indicates that the signal carries clock information.\n        </li>\n        <li>\n            <b>reset</b> indicates that the signal is a reset signal for the bus interface and is used to set\n            the interface into a know valid state. The reset level can also be specified either as low or high or undefined.\n        </li>\n        <li>\n            <b>valid</b> indicates that the data on the interface is currently valid.\n        </li>\n        <li>\n            <b>interrupt</b> indicates that the signal carries reset interrupt information.\n        </li>\n        <li>\n            <b>clock enable</b> indicates that the signal carries clock enable information. Clock enable level can be set in a similar manner as reset level.\n        </li>\n        <li>\n            <b>power enable</b> indicates that the signal carries power enable information. Power enable level can be set in a similar manner as reset level.\n        </li>\n        <li>\n            <b>opcode</b> indicates that the signal carries opcode information.\n        </li>\n        <li>\n            <b>protection</b> indicates that the signal carries protection or security information.\n        </li>\n        <li>\n            <b>flow control</b> indicates that the signal carries flow control information. Additionally, the flow type can be specified.\n        </li>\n        <li>\n            <b>user</b> indicates that the signal carries user-defined information.\n        </li>\n        <li>\n            <b>request</b> indicates that the signal carries request information.\n        </li>\n        <li>\n            <b>response</b> indicates that the signal carries response information.\n        </li>\n    </ul>\n    \n    <p>\n        <b>Port match</b> specifies that the ports on both sides of the connection need to be present if set to true.\n    </p>\n\n    <p>\n        <b>System group</b> helps identify the system interface the signal belongs to. System group is\n        mandatory for system mode and illegal for other modes.\n    </p>\n    <p>\n        <b>Description</b> is an optional free text for further details.\n    </p>\n\n    <h3>Wire properties</h3>\n    <p>\n        <b>Direction</b> is an optional restriction for the logical signal direction in the connected bus\n        interface. Direction can have one of the following values:\n    </p>\n    <ul>\n        <li>\n            <b>in</b>\n        </li>\n        <li>\n            <b>out</b>\n        </li>\n        <li>\n            <b>inout</b>\n        </li>\n    </ul>\n    <p>\n        <b>Width</b> is an optional definition of the number of bits in the logical signal. If not specified,\n        the number of bits in the connected physical port is used.\n    </p>\n    <p>\n        <b>Default value</b> is an optional value that is applied when the logical signal is not connected in\n        a connected bus interface.\n    </p>\n    <p>\n        <b>Driver</b> is an optional setting for defining what kind of a driver the logical signal requires in\n        a complete design. The possible values are the following:\n    </p>\n    <ul>\n        <li>\n            <b>any</b> indicates that any logical signal or value is valid for driving the signal. This is the\n            default value.\n        </li>\n        <li>\n            <b>clock</b> indicates that a repeating waveform is required.\n        </li>\n        <li>\n            <b>singleshot</b> indicates that a non-repeating waveform is required.\n        </li>\n        <li>\n            <b>none</b> indicates that no driver is required.\n        </li>\n    </ul>\n\n    <h3>Transactional properties</h3>\n    <p>\n        <b>Initiative</b> optional definition of the access type. Initiative can have any of the folowing\n        values:\n    </p>\n    <ul>\n        <li>\n            <b>requires</b>\n        </li>\n        <li>\n            <b>provides</b>\n        </li>\n        <li>\n            <b>requires/provides</b>\n        </li>\n    </ul>\n    <p>\n        <b>Kind</b> specifies the type of the transactional port. It can be one of the following values, though\n        tlm_port should be used for TLM1 notation, while others whould be used for TLM2:\n    </p>\n    <ul>\n        <li>\n            <b>tlm_port</b>\n        </li>\n        <li>\n            <b>tlm_socket</b>\n        </li>\n        <li>\n            <b>simple_socket</b>\n        </li>\n        <li>\n            <b>multi_socket</b>\n        </li>\n        <li>\n            <b>custom</b> name\n        </li>\n    </ul>\n    <p>\n        <b>Bus width</b> specifies the data width in bits.\n    </p>\n    <p>\n        <b>Protocol type</b> characterizes the communication protocol. Type can be one of these values:\n    </p>\n    <ul>\n        <li>\n            <b>tlm</b>\n        </li>\n        <li>\n            <b>custom</b>\n        </li>\n    </ul>\n    <p>\n        Protocol can contain a <b>payload</b> specifying the way information is transported. Payload has the\n        following sub elements:\n    </p>\n    <ul>\n        <li>\n            <b>Name</b>, specifying the payload's name.\n        </li>\n        <li>\n            <b>Type</b> mandatory specification of typing. Can have either of the two values:\n            <ul>\n                <li>\n                    generic\n                </li>\n                <li>\n                    specific\n                </li>\n            </ul>\n        </li>\n        <li>\n            <b>Extension</b> determines an extension for the payload.\n        </li>\n    </ul>\n\n    </p>\n</body>\n</html>\n"
  },
  {
    "path": "Help/definitions/apidefinition.html",
    "content": "<html>\r\n<head>\r\n    <link href=\"../style.css\" rel=\"stylesheet\" type=\"text/css\">\r\n</head>\r\n<body>\r\n    <h2>API Definition</h2>\r\n    <p>\r\n        API definitions are used to define API dependencies between SW components in more detail.\r\n        API definition wraps an SW library or other API to offer more thorough validation for or\r\n        both software and system designs and to provide context-sensitive content assistance in\r\n        the code editor. API definition consists of three types of information:\r\n    </p>\r\n    <p>\r\n        <b>COM definition reference</b> can be used to reference a COM definition in order to\r\n        use its transfer types and properties in the function definitions so that the content\r\n        assist in the code editor can give more detailed assistance.\r\n    </p>\r\n    <p>\r\n        <b>Data types</b> define all data types the API makes available for use in the code.\r\n    </p>\r\n    <p>\r\n        <b>Functions</b> list is filled with all functions that the API contains. For each\r\n        function, all its parameters are defined in detail, including any restrictions that\r\n        depend on the referenced COM definition.\r\n    </p>\r\n</body>\r\n</html>\r\n"
  },
  {
    "path": "Help/definitions/busdefinition.html",
    "content": "<html>\r\n<head>\r\n    <link href=\"../style.css\" rel=\"stylesheet\" type=\"text/css\">\r\n</head>\r\n<body>\r\n    <h2>Bus Definition</h2>\r\n    <p>\r\n        Bus definitions are used to define bus connections in HW designs. Each bus interface of a component\r\n        must refer to a bus definition and connected bus interfaces must refer to the same bus definition.\r\n\r\n    <p>\r\n        <b>Allow direct connections</b> defines if a bus interface can be directly connected to\r\n        a non-mirrored bus interface. If unselected, a bus interface can be connected only to\r\n        a mirrored bus interface of the same type e.g. master to mirrored-master and system to mirrored-system.\r\n    </p>\r\n\r\n    <p>\r\n        <b>Support broadcast</b> defines if a bus interface can be <b>directly</b> connected to more\r\n        than one opposing interface i.e. supports one-to-many connections.\r\n        Notice that bridges and mirrored connections are possible even when broadcasts are not supported.\r\n    </p>\r\n\r\n    <p>\r\n        <b>Addressable bus</b> defines if the bus has addressing information <b>and</b>\r\n        a memory map can be traced through a bus interface.\r\n    </p>\r\n\r\n    <p>\r\n        <b>Max masters on bus</b> defines the maximum number of master bus interfaces connected to\r\n        the bus. If unspecified, the number of masters is unbound.\r\n    </p>\r\n\r\n    <p>\r\n        <b>Max slaves on bus</b> defines the maximum number of slaves bus interfaces connected to\r\n        the bus. If unspecified, the number of slaves is unbound.\r\n    </p>\r\n\r\n    <p>\r\n        <b>System group names</b> defines the group names available for signals with the system mode.\r\n        In bus interface the selected system group limits the logical signals to those with the\r\n        matching system group name.\r\n    </p>\r\n\r\n    <p>\r\n        <b>Description</b> is a text that describes further details, such as the purpose of the bus\r\n        and link to the specification.\r\n    </p>\r\n    <p>\r\n        <b>Extended bus definition</b> allows the creation of a family of interconnectable bus definitions.\r\n        The following values of the bus interface are set to match the extended bus interface:\r\n    </p>\r\n    <ul>\r\n        <li>Allow non-mirrored connections</li>\r\n        <li>Support broadcast</li>\r\n        <li>Addressable bus</li>\r\n        <li>\r\n            System group names are modified to include the names given in the extended bus interface.\r\n            These cannot be removed or renamed in the bus definition.\r\n        </li>\r\n        <li>In addition, a placeholder for the description is given from the extended bus definition.</li>\r\n    </ul>\r\n\r\n    </p>\r\n</body>\r\n</html>\r\n"
  },
  {
    "path": "Help/definitions/busdefinition2022.html",
    "content": "<html>\n<head>\n    <link href=\"../style.css\" rel=\"stylesheet\" type=\"text/css\">\n</head>\n<body>\n    <h2>Bus Definition</h2>\n    <p>\n        Bus definitions are used to define bus connections in HW designs. Each bus interface of a component\n        must refer to a bus definition and connected bus interfaces must refer to the same bus definition.\n    \n    <p>\n        <b>Display name</b> is a short descriptive text for the bus definition. Can be used as an\n        identifier in GUI applications, for instance.\n    </p>\n    \n    <p>\n        <b>Short description</b> is a compact description of the bus definition.\n    </p>\n\n    <p>\n        <b>Description</b> is a text that describes further details, such as the purpose of the bus\n        and link to the specification.\n    </p>\n    \n    <p>\n        <b>Allow direct connections</b> defines if a bus interface can be directly connected to\n        a non-mirrored bus interface. If unselected, a bus interface can be connected only to\n        a mirrored bus interface of the same type e.g. initiator to mirrored-initiator and system to mirrored-system.\n    </p>\n\n    <p>\n        <b>Support broadcast</b> defines if a bus interface can be <b>directly</b> connected to more\n        than one opposing interface i.e. supports one-to-many connections.\n        Notice that bridges and mirrored connections are possible even when broadcasts are not supported.\n    </p>\n\n    <p>\n        <b>Addressable bus</b> defines if the bus has addressing information <b>and</b>\n        a memory map can be traced through a bus interface.\n    </p>\n\n    <p>\n        <b>Max initiators on bus</b> defines the maximum number of initiator bus interfaces connected to\n        the bus. If unspecified, the number of initiators is unbound.\n    </p>\n\n    <p>\n        <b>Max targets on bus</b> defines the maximum number of target bus interfaces connected to\n        the bus. If unspecified, the number of targets is unbound.\n    </p>\n\n    <p>\n        <b>System group names</b> defines the group names available for signals with the system mode.\n        In bus interface the selected system group limits the logical signals to those with the\n        matching system group name.\n    </p>\n\n    <p>\n        <b>Extended bus definition</b> allows the creation of a family of interconnectable bus definitions.\n        The following values of the bus interface are set to match the extended bus interface:\n    </p>\n    <ul>\n        <li>Allow non-mirrored connections</li>\n        <li>Support broadcast</li>\n        <li>Addressable bus</li>\n        <li>\n            System group names are modified to include the names given in the extended bus interface.\n            These cannot be removed or renamed in the bus definition.\n        </li>\n        <li>In addition, a placeholder for the description is given from the extended bus definition.</li>\n    </ul>\n\n    </p>\n</body>\n</html>\n"
  },
  {
    "path": "Help/definitions/catalog.html",
    "content": "<html>\n<head>\n    <link href=\"../style.css\" rel=\"stylesheet\" type=\"text/css\">\n</head>\n<body>\n    <h2>Catalog</h2>\n    <p>\n        Catalogs are used to group together IP-XACT documents that are somehow related.\n        For example, a catalog could list all the IP-XACT documents i.e. <i>components</i>,\n        <i>designs</i> and <i>design configurations</i> required in composing a specific\n        product. Catalogs can also include other catalogs.\n    </p>\n    <p>\n        <b>Description</b> is an optional field for textual description of the <i>catalog</i>.\n    </p>\n\n    <h3>Catalog files</h3>\n    <p>\n        Catalog files lists the IP-XACT document files contained within catalog. All the\n        files are categorized according to the document type i.e. <i>Components</i> and\n        <i>Designs</i> are listed in separate sections. Items can be added by drag-dropping\n        from the IP-XACT library or creating new rows from the context menu (right mouse\n        button).\n    </p>\n    <p>\n        <b>Vendor</b>, <b>Library</b>, <b>Name</b> and <b>Version</b> together identify the IP-XACT\n        document in the catalog.\n    </p>\n    <p>\n        <b>Path</b> is mandatory and defines the path to the IP-XACT document XML file.\n        Path must be defined as relative to the catalog XML-file, as an absolute path or\n        as an external URI. If an URI is used, the schema must be explicitly defined (e.g.\n        http://...).\n    </p>\n    <p>\n        The Catalog files editor also contains a context menu (right mouse button) that\n        has the following options:\n    </p>\n    <ul>\n        <li>Opens the selected item (Catalog, Component or Bus) in separate editor. (Open)</li>\n        <li>Add new file to the catalog (Add row)</li>\n        <li>Remove file from catalog (Remove row)</li>\n        <li>Cut the selected cell content to clipboard(Cut)</li>\n        <li>Copy the contents of the selected cells to clipboard</li>\n        <li>Paste the contents of the clipboard to the selected cells</li>\n        <li>Clear the selected cells</li>\n        <li>Expand all categories to show all files (Expand all)</li>\n        <li>Collapse all categories to hide all files (Collapse all)</li>\n    </ul>\n</body>\n</html>\n"
  },
  {
    "path": "Help/definitions/catalog2022.html",
    "content": "<html>\n<head>\n    <link href=\"../style.css\" rel=\"stylesheet\" type=\"text/css\">\n</head>\n<body>\n    <h2>Catalog</h2>\n    <p>\n        Catalogs are used to group together IP-XACT documents that are somehow related.\n        For example, a catalog could list all the IP-XACT documents i.e. <i>components</i>,\n        <i>designs</i> and <i>design configurations</i> required in composing a specific\n        product. Catalogs can also include other catalogs.\n    </p>\n    <p>\n        <b>Display name</b> is a short descriptive text for the <i>catalog</i>. Can be used as an\n        identifier in GUI applications, for instance.\n    </p>\n    <p>\n        <b>Short description</b> is a compact description of the <i>catalog</i>.\n    </p>\n    <p>\n        <b>Description</b> is an optional field for textual description of the <i>catalog</i>.\n    </p>\n\n    <h3>Catalog files</h3>\n    <p>\n        Catalog files lists the IP-XACT document files contained within catalog. All the\n        files are categorized according to the document type i.e. <i>Components</i> and\n        <i>Designs</i> are listed in separate sections. Items can be added by drag-dropping\n        from the IP-XACT library or creating new rows from the context menu (right mouse\n        button).\n    </p>\n    <p>\n        <b>Vendor</b>, <b>Library</b>, <b>Name</b> and <b>Version</b> together identify the IP-XACT\n        document in the catalog.\n    </p>\n    <p>\n        <b>Path</b> is mandatory and defines the path to the IP-XACT document XML file.\n        Path must be defined as relative to the catalog XML-file, as an absolute path or\n        as an external URI. If an URI is used, the schema must be explicitly defined (e.g.\n        http://...).\n    </p>\n    <p>\n        The Catalog files editor also contains a context menu (right mouse button) that\n        has the following options:\n    </p>\n    <ul>\n        <li>Opens the selected item (Catalog, Component or Bus) in separate editor. (Open)</li>\n        <li>Add new file to the catalog (Add row)</li>\n        <li>Remove file from catalog (Remove row)</li>\n        <li>Cut the selected cell content to clipboard(Cut)</li>\n        <li>Copy the contents of the selected cells to clipboard</li>\n        <li>Paste the contents of the clipboard to the selected cells</li>\n        <li>Clear the selected cells</li>\n        <li>Expand all categories to show all files (Expand all)</li>\n        <li>Collapse all categories to hide all files (Collapse all)</li>\n    </ul>\n</body>\n</html>\n"
  },
  {
    "path": "Help/definitions/comdefinition.html",
    "content": "<html>\r\n<head>\r\n    <link href=\"../style.css\" rel=\"stylesheet\" type=\"text/css\">\r\n</head>\r\n<body>\r\n    <h2>COM Definition</h2>\r\n    <p>\r\n        COM definitions are used to define more strictly the connections that relate to higher-level communication between HW/SW components in a system design.\r\n\t\tCOM definition consists of two types of information: <b>transfer types</b> and <b>properties</b>.\r\n    </p>\r\n\t<p>\r\n\t   <b>Transfer types</b> is an enumeration of possible data types that define what kind of data can be communicated between components via connections that are based on this COM definition.\r\n\t   The used transfer type for each COM interface in a component is selected in the component editor.\r\n\t</p>\r\n\t<p>\r\n\t   <b>Properties</b> offer a way to define certain variables whose value must be set for each COM interface.\r\n\t   Properties can be either required or optional. COM definition defines the data type and default value for each of the properties.\r\n\t</p>\r\n</body>\r\n</html>\r\n"
  },
  {
    "path": "Help/general/colors.html",
    "content": "﻿<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01//EN\" \"http://www.w3.org/TR/html4/strict.dtd\">\n<html>\n  <head>\n    <meta http-equiv=\"Content-Type\"content=\"text/html; charset=utf-8\">\n    <link href=\"../style.css\" rel=\"Stylesheet\" type=\"text/css\">\n    <title>Colors</title>\n  </head>\n  <body>\n    <h2>Colors</h2>\n    <p>\n    In Kactus2, elements that are currently in an invalid\n\tstate are displayed in <font color=\"red\">red</font>. Mandatory fields have <span style=\"background-color: #FFFACD\">lemon chiffon</span> background. Disabled fields have <span style=\"background-color: #F5F5F5\">light grey</span> background.\n    </p>\n    <p>\n    Likewise, in console error messages are displayed in <font color=\"red\">red</font> and regular messages are displayed in \n    <font color=\"blue\">blue</font>.\n    </p>\n  </body>\n</html>"
  },
  {
    "path": "Help/general/defaultApplication.html",
    "content": "﻿<!DOCTYPE html> \n<html lang=\"en\">\n<head>\n    <meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">\n    <title>Default Application</title>\n    <link href=\"style.css\" rel=\"stylesheet\" type=\"text/css\">\n</head>\n<body>\r\n\r\n<h2>Default Application</h2>\n\n<p>You may select the default application for each file type within Kactus2. For instance, this could be the default text editor for makefiles.</p>\n\n<ol>\n<li>Open settings.</li>\n<li>Select <i>Environment variables</i>.</li>\n<li>Double click to create a new row, set the name for the new variable, and set field <i>value</i> as the path to the program.</li>\n</ol>\r\n\n<p>\n\n<img alt=\"EnvironmentVariables\" src=\"../images/EnvironmentVariables.png\">\n\n<ol>\n<li>Open settings.</li>\n<li>Select <i>File Types</i>.</li>\n<li>Go to the row of the desired file type. Set field <i>Executed with</i> as the variable in format <i>$(VARIABLE_NAME)</i>.</li>\n<li>You may also opt to edit the file type within the built-in text editor of Kactus2, although this should be considered mostly as a fall-back.</li>\n</ol>\n\n<p>\n\n<img alt=\"FileTypes\" src=\"../images/FileTypes.png\">\n\r\n</body>\n</html>"
  },
  {
    "path": "Help/general/expressions.html",
    "content": "<!DOCTYPE html> \r\n<html lang=\"en\">\r\n<head> \r\n    <meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">\r\n    <title>Expressions</title>\r\n    <link href=\"style.css\" rel=\"stylesheet\" type=\"text/css\">\r\n</head>\r\n<body>\r\n\r\n<h2>Expressions</h2>\r\n\r\n<p>Many fields within Kactus2 accept expresions as their input value for easy\r\nand fast configuration. The function sign <em>f(x)</em> is used to identify\r\nthese fields. The input should conform to the SystemVerilog\r\nsyntax to be acceptable.\r\n</p>\r\n\r\n<h3>Constant values</h3>\r\n<p>\r\nConstant numeric values can be given as decimal values (e.g. 15) or by explicitly\r\ndefining the base (e.g. 'h0F for 15 in hexadecimal). The possible bases are\r\n<strong>'b</strong> (binary), <strong>'o</strong> (octal), \r\n<strong>'d</strong> (decimal) and <strong>'h</strong> (hexadecimal).\r\nAlso fractional numbers (e.g. 0.25) can be used where applicable.\r\nOther numeric formats, e.g. 0x000F and 0b0010, will not be accepted.\r\n</p>\r\n\r\n<p>\r\nString values must be given within double quotes e.g. \"This is a string value\".\r\n</p>\r\n\r\n<p>\r\nBoolean true and false are accepted and will be interpret as 1 and 0, respectively.\r\n</p>\r\n\t\r\n<h3>Operations</h3>\r\n<p>Kactus2 supports the following operations:</p>    \r\n<table border=\"1\">\r\n\t<tr>\r\n\t  <th>Operator(s)</th>\r\n\t  <th>Description</th>\r\n\t  <th>Example</th>\t  \r\n\t</tr>\r\n\t<tr>\r\n\t  <td>+,-,*,/</td>\r\n\t  <td>Basic arithmetic operations</td>\r\n\t  <td>2*4 (8)</td>\r\n\t</tr>\r\n\t<tr>\r\n\t  <td>&&,||</td>\r\n\t  <td>Basic logical operations: AND,OR</td>\r\n\t  <td>1 || 0 (true)</td>\r\n\t</tr>\r\n\t<tr>\r\n\t  <td>&,|,^,~</td>\r\n\t  <td>Bitwise logical operations: AND,OR,XOR,NOT</td>\r\n\t  <td>4'b0011 & 4'b0110 (2)</td>\r\n\t</tr>\r\n\t<tr>\r\n\t  <td>&lt;&lt;,&gt;&gt;</td>\r\n\t  <td>Shift operations</td>\r\n\t  <td>4'b0011 &lt;&lt; 1 (6)</td>\r\n\t</tr>\r\n\t<tr>\r\n\t  <td>**</td>\r\n\t  <td>Power operation</td>\r\n\t  <td>2**4 (16)</td>\r\n\t</tr>\r\n\t<tr>\r\n\t  <td>&lt;,&gt;,&lt;=,&gt;=,==,!=</td>\r\n\t  <td>Comparison of two values</td>\r\n\t  <td>4 &gt;= 2 (true)</td>\r\n\t</tr>\r\n\t<tr>\r\n\t  <td>==,!=</td>\r\n\t  <td>Comparison of string values</td>\r\n\t  <td>\"abc\" != \"bcd\" (true)</td>\r\n\t</tr>\r\n\t<tr>\r\n\t  <td>$clog2()</td>\r\n\t  <td>Ceiling of logarithm of base 2</td>\r\n\t  <td>$clog(9) (4)</td>\r\n\t</tr>\r\n        <tr>\r\n          <td>$exp()</td>\r\n          <td>Exponential function</td>\r\n          <td>$exp(2) (0.135335)</td>\r\n        </tr>\r\n        <tr>\r\n          <td>$pow()</td>\r\n          <td>Power function</td>\r\n          <td>$pow(2, 4) (16)</td>\r\n        </tr>\r\n        <tr>\r\n          <td>$sqrt()</td>\r\n          <td>Square root</td>\r\n          <td>$sqrt(9) (3)</td>\r\n        </tr>\r\n\t\t<tr>\r\n\t<td>?:</td>\r\n\t  <td>Conditional (ternary) operator</td>\r\n\t  <td>1?2:0 (2)</td>\r\n\t</tr>\r\n</table>\r\n\r\n<p></p>\r\n\r\n</body>\r\n</html>\r\n"
  },
  {
    "path": "Help/general/libraryNavigation.html",
    "content": "<!DOCTYPE html> \n<html lang=\"en\">\n<head>\n    <meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">\n    <title>Library Navigation</title>\n    <link href=\"style.css\" rel=\"stylesheet\" type=\"text/css\">\n</head>\n<body>\n\n<h2>Library Navigation</h2>\n\n<p>How to access IP-XACT documents and open them for editors.</p>\n    \n<h3>VLNV Tree</h3>\n\n<p>Documents are sorted to VLNV tree based on the VLNV tuple of a document.</p>\n\n<div id=\"vlnvtree\">\n<ol>\n<li>Select VLNV tree.</li>\n<li>Browse to the desired document, double click to open.</li>\n<li>Right click for context menu. The additional options include opening and creating designs.</li>\n<li>The external interfaces and ad-hoc ports are illustrated in the preview.</li>\n</ol>\n\n<p></p>\n\n<img alt=\"VLNVtree\" src=\"../images/VLNVtree.png\">\n\n</div>\n\n<h3>Hierarchy Navigation</h3>\n\n<p>Documents are sorted to hierarchy display based on their position in designs and sub designs.</p>\n\n<ol>\n<li>Select hierarchy.</li>\n<li>Hierarchical components are expandable, displaying the associated designs and the components that have instances in the design.</li>\n<li>Hierarchical navigation is recursive, so that a design within a design is also expandable.</li>\n<li>This column displays how many instances in the design use the component.</li>\n</ol>\n\n<p></p>\n\n<img alt=\"ProtectionLocation\" src=\"../images/HierarchyNavigation.png\">\n\n\n<h3>Library Filters</h3>\n\n<p>You may limit the number of displayed IP-XACT documents using filters:</p>\n\n<ol>\n<li>Hide/show filters</li>\n<li>Only documents which type is checked are displayed. Advanced stands for designs and design configurations.</li>\n<li>Hide documents that do not match the implementation. For instance, unchecking HW hides all hardware components and buses.</li>\n<li>Hide components that do not match any checked hierarchy level.</li>\n<li>Hide components that do not match any checked firmness level.</li>\n<li>Hide documents that have no errors or do have errors.</li>\n<li>Hide documents that do not have the tags listed here.</li>\n</ol>\n\n<p></p>\n\n<img alt=\"Filters\" src=\"../images/LibraryFilter.png\">\n\n</body>\n</html>"
  },
  {
    "path": "Help/general/shortcuts.html",
    "content": "<html>\n<head>\n    <link href=\"style.css\" rel=\"stylesheet\" type=\"text/css\">\n</head>\n<body>\n    <h2>Kactus2 shortcuts</h2>\n\t<p>\n      Kactus2 uses the following shortcuts.\n    </p>    \n    <table border=\"1\">\n\t<tr>\n\t  <th>Key sequence</th>\n\t  <th>Description</th>\n\t</tr>\n\t<tr>\n\t  <td>CTRL + L</td>\n\t  <td>Lock/Unlock document.</td>\n\t</tr>\n\t<tr>\n\t  <td>CTRL + {Z, X, C, V, A}</td>\n\t  <td>Usual shortcuts for editing</td>\n\t</tr>\n\t<tr>\n\t  <td>F2</td>\n\t  <td>Edit item.</td>\n\t</tr>\n\t<tr>\n\t  <td>CTRL + TAB</td>\n\t  <td>Move to the next tab.</td>\n\t</tr>\n\t<tr>\n\t  <td>CTRL + SHIFT + Tab</td>\n\t  <td>Move to the previous tab.</td>\n\t</tr>\n\t<tr>\n\t  <td>SHIFT + RETURN</td>\n\t  <td>Add a row to table.</td>\n\t</tr>\n\t<tr>\n\t  <td>SHIFT + DEL</td>\n\t  <td>Remove selected row(s) from table.</td>\n\t</tr>\n    </table>\n</body>\n</html>\n"
  },
  {
    "path": "Help/general/toolbarsAndViews.html",
    "content": "<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01//EN\" \"http://www.w3.org/TR/html4/strict.dtd\">\n<html>\n  <head>\n    <meta http-equiv=\"Content-Type\"content=\"text/html; charset=utf-8\">\n    <link href=\"../style.css\" rel=\"Stylesheet\" type=\"text/css\">\n    <title>Toolbar</title>\n  </head>\n  <body>\n    <h1>Toolbars and views</h1>\n    <h2>Toolbars</h2>\n    <p>\n    The Kactus2 main window contains a toolbar at the top and sidebars on both sides. The toolbar contains actions for\n    performing common actions within the Kactus2.\n    </p>\n    <p>\n    The toolbar adapts to the size of the window. If the window gets too small for the\n    toolbar, two buttons for scrolling left and right will be made visible.\n    Scrolling can also be done by using the mouse wheel.\n    </p>\n    <p>\n    The toolbar hides actions that are not available in the current environment. For example,\n    generators are not show when no component or design has been selected.\n    </p>\n    <p>\n    UI views can be docked to a sidebar. Multiple views can be docked\n    to the same sidebar and the active view can be hidden by clicking its icon in the sidebar, or changed \n    by clicking the icon of another view.\n    </p>\n    <h3>The toolbar groups</h3>\n    <p>\n    The <b>File</b> group contains functions for controlling the files of the component.\n        <ul>\n            <li>\n            <img src=\"../images/file-new.png\"><br/><b>New.</b> Creates a new component, design, system,\n            bus, COM definition or API definition.\n            <br>\n            </li>\n            <li>\n            <img src=\"../images/file-save.png\"><br/><b>Save.</b> Saves the active document with its\n            current name and location. Activates when a document has been edited.\n            </li>\n            <br>\n            <li>\n            <img src=\"../images/file-save-as.png\"><br><b>Save As.</b> Saves the document with a new name\n            and location.\n            </li>\n            <br>\n            <li>\n            <img src=\"../images/file-save_all.png\"><br><b>Save all.</b> Saves all open documents.\n            </li>\n            <br />\n            <li>\n            <img src=\"../images/file-print.png\"><br><b>Print.</b> Prints the currently open design.\n            </li>\n            <br />\n            <li>\n                <img src=\"../images/export.png\"><br/><b>Export image.</b> Export an image of the currently open\n                design document. Possible image formats are SVG, JPG and PNG.\n            </li>\n            <br>\n            <li>\n                <img src=\"../images/import.png\"><br><b>Import File to Component.</b> Imports elements from a\n                source file e.g. VHDL or verilog to the active component.\n            </li>\n        </ul>\n    </p>\n    <p>\n    The <b>Library</b> group contains functions for maintaining the IP-XACT libraries used by the Kactus2.\n        <ul>\n            <li>\n            <img src=\"../images/library-config.png\"><br><b>Configure libraries.</b> Select the\n            libraries used in Kactus2. The libraries can be set as default and active.\n            </li>\n            <br>\n            <li>\n            <img src=\"../images/library-refresh.png\"><br><b>Refresh libraries.</b> Refresh the currently\n            active libraries.\n            </li>\n            <br>\n            <li>\n            <img src=\"../images/checkIntegrity.png\"><br><b>View Library Integrity Report.</b> Shows\n\t\t\ta report of errors within all library items. This operation may take a long time with\n\t\t\tlarge libraries.\n            </li>\n        </ul>\n    </p>\n    <p>\n    The <b>Protection</b> group shows the current documents editability. The lock status can be changed with\n    this button.\n        <ul>\n            <li>\n            <img src=\"../images/protection-locked.png\"><br><b>Locked.</b> While locked, no changes can be\n            made to the document.\n            </li>\n            <br>\n            <li>\n            <img src=\"../images/protection-unlocked.png\"><br><b>Unlocked.</b> While unlocked, the documents\n            can be edited and saved.\n            </li>\n        </ul>\n    </p>\n    <p>\n    The <b>Generation</b> group shows all the available generator plugins underneath Run generator:\n        <ul>\n            <li>\n            <img src=\"../images/automation.png\"><br><b>Run generator</b>\n            Runs a chosen generator for the active component. If the active document is a design, all component\n            instances are included in documentation generation.\n            </li>\n        </ul>\n    </p>\n    <p>\n    The <b>Diagram Tools</b> group consist of tools related to the design editors of Kactus2. This group is only\n    visible to the HW, SW and system design editors.\n        <ul>\n            <li>\n                <img src=\"../images/diagram-add-column.png\" /><br />\n                <b>Add Column.</b> Creates a new column to the design. In HW design, the type of the possible\n                items in the new column can be customized.\n            </li>\n            <br />\n            <li>\n                <img src=\"../images/tool-select.png\" /><br />\n                <b>Select Tool.</b> Allows the selection of items within the HW design. Information regarding the\n                selected item is show on the different editors of the des.\n            </li>\n            <br />\n            <li>\n                <img src=\"../images/tool-interconnection.png\" /><br />\n                <b>Interconnection Tool.</b> Allows the creation of interconnections between the interfaces of\n                component instances. After selecting the starting point, the possible ending points for the\n                connection are highlighted in the design. An interconnection cannot be dragged from the starting\n                point to the ending point. Both points must be selected separately.\n            </li>\n            <br />\n            <li>\n                <img src=\"../images/tool-interface.png\" /><br />\n                <b>Interface Tool.</b> Draft interfaces can be to the component containing the currently opening\n                design. These interfaces must be placed within columns allowing interface items.\n            </li>\n            <br />\n            <li>\n                <img src=\"../images/tool-drafting.png\" /><br />\n                <b>Drafting Tool.</b> Allows the creation of draft component instances and interfaces. The drafted\n                component instances must be placed in columns allowing component instances. Interfaces can be\n                placed either into the component containing the design, or any of the drafted component instances.\n            </li>\n            <br />\n            <li>\n                <img src=\"../images/tool-toggle_offpage.png\" /><br />\n                <b>Toggle Off-Page Tool.</b> Changes the selected connections from regular to off-page, and from\n                off-page to regular. Off-page connections are displayed as squares near an interface, and the\n                connected point is displayed when an off-page point is selected.\n            </li>\n            <br />\n            <li>\n                <img src=\"../images/balloon.png\" /><br />\n                <b>Sticky Note Tool.</b> Create notes regarding the currently open design. Notes can be associated\n                with an item contained within the design. This can be achieved through the button located at the\n                top right corner of the note.\n            </li>\n        </ul>\n    </p>\n\t<p>\n    The <b>Filtering Tools</b> group has actions for filtering and adjusting the visualization of the memory\n\tlayout for current component hierarchy. Available only in the Memory Designer.\n        <ul>\n\t\t    <li>\n                <img src=\"../images/filterSegments.png\" /><br />\n                <b>Filter Segments.</b> Show/hide the segments within the address spaces.\n            </li>\n\t\t\t<br />\n\t\t\t<li>\n                <img src=\"../images/filterAddressBlocks.png\" /><br />\n                <b>Filter Address Blocks.</b> Show/hide the address blocks within the memory maps.\n            </li>\n\t\t\t<br />\n\t\t\t<li>\n                <img src=\"../images/filterRegisters.png\" /><br />\n                <b>Filter Registers.</b> Show/hide the registers within the address blocks.\n            </li>\n\t\t\t<br />\n\t\t\t<li>\n                <img src=\"../images/filterFields.png\" /><br />\n                <b>Filter Fields.</b> Show/hide the bit fields within the registers.\n            </li>\n\t\t\t<br />\n            <li>\n                <img src=\"../images/addressSpaceFilter.png\" /><br />\n                <b>Address Space Filter.</b> Show/hide the address space items on the path\n\t\t\t\tfrom the furthest address space to the connected memory maps.\n            </li>\n\t\t\t<br />\n            <li>\n                <img src=\"../images/filterUnconnectedMemoryItems.png\" /><br />\n                <b>Unconnected items filter</b> Show/hide unconnected memory items.\n            </li>\n\t\t\t<br />\n\t\t\t<li>\n                <img src=\"../images/compressMemoryItems.png\" /><br />\n                <b>Compress Memory Items.</b> Minimize the vertical space taken by the\n\t\t\t\tmemory items. When disabled, the item height is relative to the contained address range.\n            </li>\n\t\t\t<br />\n\t\t\t<li>\n                <img src=\"../images/compressFields.png\" /><br />\n                <b>Compress Field Items.</b> Minimize the horizontal space taken by the bit field items.\n            </li>\n            <br />\n\t\t\t<li>\n                <img src=\"../images/extendFields.png\" /><br />\n                <b>Extend Field Items.</b> Extend the horizontal space taken by the bit field items.\n\t\t\t\tThis ensures the full name is visible for every item.\n            </li>\n            <br />\n        </ul>\n    </p>\n    <p>\n    The <b>View</b> group has actions for defining the view of the current design. Visible Windows -button\n    is always available.\n        <ul>\n            <li>\n            <img src=\"../images/view-zoom_in.png\"><br><b>Zoom In.</b> Enlarge the display of the active\n            design.\n            </li>\n            <br>\n            <li>\n            <img src=\"../images/view-zoom_out.png\"><br><b>Zoom Out.</b> Reduce the display of the active\n            design.\n            </li>\n            <br>\n            <li>\n            <img src=\"../images/view-zoom_original.png\"><br><b>Original 1:1 Zoom.</b> Return the display\n            to original size.\n            </li>\n            <br>\n            <li>\n            <img src=\"../images/view-fit_best.png\"><br><b>Fit Document to View.</b> Fit the currently\n            active document to the available view.\n            </li>\n            <br>\n            <li>\n            <img src=\"../images/dockSelect.png\"><br><b>Visible Windows.</b> Allows changing the\n            visibilities of the available windows.\n            </li>\n            <br>\n            <li>\n            <img src=\"../images/visibility.png\"><br><b>Visibilities.</b> Change the visibilities of\n            design items.\n            </li>\n        </ul>\n    </p>\n    <p>\n        The <b>Configuration</b> group contains actions related to configuring the currently open document.\n        <ul>\n            <li>\n                <img src=\"../images/viewConfiguration.png\"><br><b>View Configuration.</b> Configure the views used\n                in the currently open document. The items are constructed recursively, so that the contained items\n                within a component with a hierarchical view are displayed below said item. This allows the display\n                of all the items contained within the currently active document.\n            </li>\n            <br />\n            <li>\n                <img src=\"../images/memoryDesigner.png\"><br><b>Open Memory Designer.</b> Opens a view of the memory\n                layout of the underlying component hierarchy. Available only in Hardware Design view.\n            </li>\n        </ul>\n    </p>\n    <p>\n    The <b>Workspace</b> group shows the currently selected workspace.\n        <ul>\n            <li>\n            <img src=\"../images/workspace.png\"><br><b>Workspace.</b> Select, delete or create other \n            workspaces. Only non-active, non-default workspaces can be deleted.\n            </li>\n        </ul>\n    </p>\n    <p>\n    The <b>System</b> group contains actions related to the whole system.\n        <ul>\n            <li>\n            <img src=\"../images/settings-general.png\"><br><b>Settings.</b> Displays the available settings\n            for Kactus2.\n            </li>\n            <br>\n            <li>\n            <img src=\"../images/system-help.png\"><br><b>Help.</b> Opens the Kactus2 manual.\n            </li>\n            <br>\n            <li>\n            <img src=\"../images/system-about.png\"><br><b>About.</b> Shows information about Kactus2.\n            </li>\n            <br>\n            <li>\n            <img src=\"../images/system-exit.png\"><br><b>Exit.</b> Exit Kactus2.\n            </li>\n        </ul>\n    </p>\n\n    <h2>Views</h2>\n    <p>\n        Views are used to present additional data regarding the currently open document.\n    </p>\n    <h3>Common</h3>\n    <p>\n        Views that can be displayed regardless of the currently open document:\n        <ul>\n            <li>\n                <b>Context Help</b> displays help of the currently open document or editor.\n            </li>\n            <li>\n                <b>IP-XACT Library</b> shows the used libraries of Kactus2. See\n                <a href=\"libraryNavigation.html\">library navigation</a>.\n            </li>\n            <li>\n                <b>Output</b> displays data of the actions performed by Kactus2.\n            </li>\n        </ul>\n    </p>\n    <h3>Vendor Extensions</h3>\n    <p>\n          Vendor Extensions are used to edit the user defined extensions. Depending on the currently\n          active editor, either the extensions of the current document or the active element are displayed.\n    </p>\n    <h3>Design</h3>\n    <p>\n        Views that are related to design documents, both HW and system.\n        <ul>\n            <li>\n                <b>Connection Editor</b> displays data of the currently active interconnection. See\n                <a href=\"../hwdesign/connection.html\">interconnection</a>,\n                <a href=\"../hwdesign/adhocconnection.html\">ad-hoc connection</a>,\n                <a href=\"../swsysdesign/apiconnection.html\">api connection</a> or\n                <a href=\"../swsysdesign/comconnection.html\">com connection</a>.\n            </li>\n            <li>\n                <b>Component Instance Details</b> displays details of the active component instance. See\n                <a href=\"../hwdesign/hwinstance.html\">component instance</a>,\n                <a href=\"../swsysdesign/hwmappinginstance.html\">HW mapping instance</a>,\n                <a href=\"../swsysdesign/swinstance.html\">SW component instance</a>.\n            </li>\n            <li>\n                <b>Design Configuration Details</b> allows the editing of the design details. The current\n                <i>design configuration</i> can be changed, and the view configuration allows the\n                editing of the active views for the contained component instances.\n            </li>\n            <li>\n                <b>Interface Editor</b> displays data related to the currently active interface:\n                <ul>\n                    <li>\n                        <b>Bus interface</b> contains data of the <i>bus type</i>, <i>abstraction type</i>, the\n                        <i>interface mode</i> and the contained <i>port maps</i>.\n                    </li>\n                    <li>\n                        <b>API interface</b> displays the <i>API type</i> of the interface and its\n                        <i>dependency direction</i>.\n                    </li>\n                    <li>\n                        <b>COM interface</b> details the <i>COM type</i>, <i>transfer type</i> and\n                        <i>direction</i> of the interface, as well as allowing editing of its property values.\n                    </li>\n                </ul>\n            </li>\n        </ul>\n    </p>\n    <h3>HW design</h3>\n    <p>\n        Views for displaying details only related to a HW design.\n        <ul>\n            <li>\n                <b>Ad hoc port editor</b> allows the editing of ad hoc ports. The port names and directions are displayed, and\n                port visibility can be enabled or disabled.\n            </li>\n            <li>\n                <b>Design parameters</b> displays the parameters of the parameters associated with the current\n                design. See <a href=\"../componenteditor/params.html\">parameters</a>.\n            </li>\n        </ul>\n    </p>\n    <h3>System design</h3>\n    <p>\n        Views for displaying details related only to a system design.\n        <ul>\n            <li>\n                <b>HW Mapping Details</b> allows the editing of the referenced HW component and selecting the\n                referenced active view. Additional functions for handling the SW are also provided.\n            </li>\n        </ul>\n    </p>\n  </body>\n</html>\n"
  },
  {
    "path": "Help/general/workSpace.html",
    "content": "<!DOCTYPE html> \n<html lang=\"en\">\n<head>\n    <meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">\n    <title>Workspaces</title>\n    <link href=\"style.css\" rel=\"stylesheet\" type=\"text/css\">\n</head>\n<body>\n\n<h2>Workspaces</h2>\n\n<p>Workspaces allow you to customize the sizes, locations, and visibilities of widgets for specific situations.</p>\n\n<ol>\n<li>Click workspace button on the top ribbon for workspace menu.</li>\n<li>You may select an existing workspace here.</li>\n<li>Creating new ones and deleting existing ones are supported.</li>\n<li>Insert the name for the new workspace on creation.</li>\n</ol>\n\n<p></p>\n\n<img alt=\"CreateWorkSpace\" src=\"../images/CreateWorkSpace.png\">\n\n<p>You may also customize what is seen in the component editor, while using a workspace:</p>\n\n<ol>\n<li>Open settings.</li>\n<li>Select <i>Component Editor Visibilities</i>.</li>\n<li>Choose the workspace which you wish to customize.</li>\n<li>Unchecking/checking items hides/shows the component editor section on the row in the hierarchy level of the given column. \nFor instance, you may decide that product level components do not need to show sections for external interfaces.</li>\n<li>By clicking a row or a column header, the whole row or column is checked/unchecked. As another example, you may \ndecide that since this workspace is reserved for software work, it does not need other clock drivers.</li>\n</ol>\n\n<p></p>\n\n<img alt=\"ComponentVisibilities\" src=\"../images/ComponentVisibilities.png\">\n\n<p>You may also customize design editors by dragging and closing the side widgets. For instance, in the image below, \nthe design configuration details widget has been detached to a floating window. You may reopen closed widgets with the visible \nwindows menu highlighted in the image.</p>\n\n<p></p>\n\n<img alt=\"desgConfOnly\" src=\"../images/WidgetsVisibility.png\">\n\n</body>\n</html>"
  },
  {
    "path": "Help/gettingStarted/accessingDocuments.html",
    "content": "<!DOCTYPE html> \n<html lang=\"en\">\n<head>\n    <meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">\n    <title>Accessing Documents</title>\n    <link href=\"style.css\" rel=\"stylesheet\" type=\"text/css\">\n</head>\n<body>\r\n\r\n<h2>Step 2: Accessing Documents</h2>\n\n<div id=\"vlnvtree\">\n<ol>\n<li>Select VLNV tree.</li>\n<li>Browse to the desired document, double click to open.</li>\n<li>Right click for context menu. The additional options include opening and creating designs.</li>\n<li>The external interfaces and ad-hoc ports are illustrated in preview.</li>\n<li>You need to open protection (ctrl + L) to modify the document. It is protected again with the same button or hotkey, or when protection of another document is opened.</li>\n</ol>\n\n<p>The next step is <a href=\"creatingDocuments.html\">creating documents.</a><p>\n<p>The previous step was <a href=\"configureLibrary.html\">configuring a library.</a><p>\n\n<img alt=\"VLNVtree\" src=\"../images/VLNVtree.png\">\n\n<p></p>\n\n<img alt=\"ProtectionLocation\" src=\"../images/protection-location.png\">\n</div>\n\r\n</body>\n</html>"
  },
  {
    "path": "Help/gettingStarted/configureLibrary.html",
    "content": "<!DOCTYPE html> \n<html lang=\"en\">\n<head>\n    <meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">\n    <title>Configuring Library</title>\n    <link href=\"style.css\" rel=\"stylesheet\" type=\"text/css\">\n</head>\n<body>\r\n\r\n<h2>Step 1: Configuring Library</h2>\n\n<p>Kactus2 library settings determine, which folders are scanned for components and other IP-XACT documents.</p>\n<ol>\r\n<li>Click the configure library button on the top ribbon.</li>\n<li>Click the plus button to add new location by browsing the file system.</li>\n<li>Select the root folder of the documents as the library path.</li>\n<li>Make sure it is both active and default.</li>\n<li>Click OK.</li>\n<li>If any readable IP-XACT documents were found, they will show up under <i>Library items.</i></li>\n</ol>\n\n<p>Any new documents will be placed under the default location.</p>\n\n<p>The existing documents are scanned from all active locations.</p>\n\n<p>The next step is <a href=\"accessingDocuments.html\">accessing documents.</a><p>\r\n\r\n<img alt=\"AddLibrary\" src=\"../images/AddLibrary.png\">\n\r\n</body>\n</html>"
  },
  {
    "path": "Help/gettingStarted/creatingDocuments.html",
    "content": "<!DOCTYPE html> \n<html lang=\"en\">\n<head>\n    <meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">\n    <title>Creating Documents</title>\n    <link href=\"style.css\" rel=\"stylesheet\" type=\"text/css\">\n</head>\n<body>\n\n<h2>Step 3: Creating Documents</h2>\n\n<p>A new document is required for new IP as well as for IP lacking IP-XACT packaging.</p>\n<ol>\n<li>Click the new button on the top ribbon.</li>\n<li>Select a document type. Detailed descriptions are in their corresponding sections in the manual.\n<ul>\n    <li>Bus Definition determines constraints for bus connections.</li>\n    <li>Catalog groups IP-XACT documents.</li>\n    <li>HW Component describes a hardware IP with behavioral functionality.</li>\n    <li>HW Design describes an IP that instantiates and connects other hardware IPs.</li>\n    <li>SW Component is used to group software source files and set their build rules.</li>\n    <li>SW Design describes an IP that instantiates and connects other software IPs.</li>\n    <li>System describes an IP that instantiates and connects software IPs and maps them to hardware IPs.</li>\n    <li>API definition describes external functions provided by software components.</li>\n    <li>COM Definition determines constraints for interprocess connections.</li>\n</ul>\n</li>\n<li>In case of HW component or HW design, you may select hierarchy level and firmness. See more details in the component section of the manual.</li>\n<li>Type VLNV tuple for the document:\n<ul>\n    <li>Vendor identifies the owner. To ensure uniqueness, it should be their internet domain name in left-to-right order (e.g., tut.fi not fi.tut).</li>\n    <li>Library is used to group documents, and thus should reflect the type of the IP-XACT document. This field is auto-filled with the selected hierarchy level, but you may replace it with something more accurate.</li>\n    <li>The name should be self-explanatory.</li>\n    <li>Technically, another version means another document.</li>\n</ul>\n</li>\n<li>Select a directory for the new document. Default location is constructed from the VLNV. It is based on the location of the default library, which was chosen in <a href=\"configureLibrary.html\">step 1.</a></li>\n<li>Click OK. If you are creating a component, this will open the component creation wizard. If you are not importing any existing IP, close it by clicking Finish.</li>\n</ol>\n\n<p>The previous step was <a href=\"accessingDocuments.html\">accessing documents.</a><p>\n\n<img alt=\"CreatingDocument\" src=\"../images/CreatingDocument.png\">\n\n</body>\n</html>"
  },
  {
    "path": "Help/hwdesign/adhocconnection.html",
    "content": "<html>\r\n<head>\r\n    <link href=\"../style.css\" rel=\"stylesheet\" type=\"text/css\">\r\n</head>\r\n<body>\r\n    <h2>Ad-hoc Connection</h2>\r\n    <p>\r\n\t\t<b>Ad-hoc connections</b> define the ad-hoc connections for the component instances\r\n\t\tin the design. They are only used to connect individual physical ports\r\n        whereas <i>interconnections</i> connect multiple ports grouped in the <i>bus interfaces</i>.\r\n    </p>\r\n\t\r\n    <h3>Connection Editor</h3>\r\n    <p>\r\n        The Connection Editor shows the properties of the selected connection.\r\n    <p>\r\n\t\tA connection has a mandatory <b>name</b> and an optional <b>description</b>.\r\n\t\tBy default, the connection is named by the connected instances and ports.\r\n\t\tThe name also forms the basis for signal naming in the generated HDL.\r\n    </p>\r\n    <p>\r\n        The connected ports are shown at the bottom. <b>Left Bound</b> and <b>Right Bound</b> can be used\r\n        to select the port bits in the connection. For example, a 2-bit port 'chip_select' could be connected\r\n        to two different instances where the first is connected to the lower bit of 'chip_select'\r\n        (chip_select[0:0]) and the second to the higher bit of 'chip_select' (chip_select[1:1]).\r\n    </p>\r\n</body>\r\n</html>\r\n"
  },
  {
    "path": "Help/hwdesign/adhocinterface.html",
    "content": "<html>\r<head>\r    <link href=\"../style.css\" rel=\"stylesheet\" type=\"text/css\">\r</head>\r<body>\r    <h2>Ad-hoc Interface</h2>\r    <p>\r        See <a href=\"adhocport.html\">Ad hoc Port</a>.\r    </p>\r</body>\r</html>\r"
  },
  {
    "path": "Help/hwdesign/adhocport.html",
    "content": "<html>\r\n<head>\r\n    <link href=\"../style.css\" rel=\"stylesheet\" type=\"text/css\">\r\n</head>\r\n<body>\r\n    <h2>Ad-hoc Port</h2>\r\n    <p>\r\n        <b>Ad hoc Port Details</b> shows the selected port <b>name</b>, <b>direction</b>\r\n        and bounds as defined in the containing component.\r\n    </p>\r\n    <p>\r\n        <b>Tied value</b> can be set\r\n        to connect a port to a constant value e.g. 0 for unsed input. The value can be given\r\n        as an expression, but it must resolve into a bit value compatible with the port\r\n        width. Tied value is valid only for in/inout ports of a component instance and out/inout\r\n        ports of the top-level component.\r\n\t</p>\r\n    <p>\r\n\t\tAd-hoc ports can be re-positioned by drag-dropping.\r\n\t</p>\r\n</body>\r\n</html>\r\n"
  },
  {
    "path": "Help/hwdesign/businterface.html",
    "content": "<html>\r<head>\r    <link href=\"../style.css\" rel=\"stylesheet\" type=\"text/css\">\r</head>\r<body>\r    <h2>Bus Interface</h2>\r    <p>\r        See <a href=\"busport.html\">Bus Interface</a>.\r    </p>\r</body>\r</html>\r"
  },
  {
    "path": "Help/hwdesign/busport.html",
    "content": "<html>\n<head>\n    <link href=\"../style.css\" rel=\"stylesheet\" type=\"text/css\">\n</head>\n<body>\n    <h2>Bus Interface</h2>\n    <p>\n        <b>Bus Interfaces</b> provide the connection points for the components. The access\n        details are defined within the containing component, but the connections are defined\n        in the design. Only compatible bus interfaces can be connected. The bus interface\n        mode is indicated using the following colors:\n    </p>\n    <p>\n        <img src=\"../images/interface_colors.png\">\n    </p>\n\t<p>\n\t\tBus interfaces can be re-positioned by drag-dropping.\n\t</p>\n    <h3>Interface Editor</h3>\n    <p>\n        The Interface Editor shows the selected bus interface <b>bus definition</b>, <b>abstraction\n        definition</b>, <b>name</b>, <b>interface mode</b> and <b>description</b> as\n        defined in the containing component. They are only editable if the bus interface\n        is a draft. Otherwise all changes must be made in the containing component.\n    </p>\n    <p>\n        <b>Port maps</b> shows the mapping of logical ports on the bus to the physical ports\n        in the containing component.</p>\n    <p>\n        <b>Exclude</b> can be set to exclude the logical port from the port maps of the\n        bus interface within this design.\n    </p>\n</body>\n</html>\n"
  },
  {
    "path": "Help/hwdesign/busport2022.html",
    "content": "<html>\n<head>\n    <link href=\"../style.css\" rel=\"stylesheet\" type=\"text/css\">\n</head>\n<body>\n    <h2>Bus Interface</h2>\n    <p>\n        <b>Bus Interfaces</b> provide the connection points for the components. The access\n        details are defined within the containing component, but the connections are defined\n        in the design. Only compatible bus interfaces can be connected. The bus interface\n        mode is indicated using the following colors:\n    </p>\n    <p>\n        <img src=\"../images/interface_colors2022.png\">\n    </p>\n\t<p>\n\t\tBus interfaces can be re-positioned by drag-dropping.\n\t</p>\n    <h3>Interface Editor</h3>\n    <p>\n        The Interface Editor shows the selected bus interface <b>bus definition</b>, <b>abstraction\n        definition</b>, <b>name</b>, <b>interface mode</b> and <b>description</b> as\n        defined in the containing component. They are only editable if the bus interface\n        is a draft. Otherwise all changes must be made in the containing component.\n    </p>\n    <p>\n        <b>Port maps</b> shows the mapping of logical ports on the bus to the physical ports\n        in the containing component.</p>\n    <p>\n        <b>Exclude</b> can be set to exclude the logical port from the port maps of the\n        bus interface within this design.\n    </p>\n</body>\n</html>\n"
  },
  {
    "path": "Help/hwdesign/connection.html",
    "content": "<html>\r\n<head>\r\n    <link href=\"../style.css\" rel=\"stylesheet\" type=\"text/css\">\r\n</head>\r\n<body>\r\n    <h2>Interconnection</h2>\r\n    <p>\r\t\t<b>Interconnections</b> define the connections for the component instances\r\t\tin the design.\r\n    </p>\r\t\r\n    <h3>Connection Editor</h3>\r\n    <p>\r\n        The Connection Editor shows the properties of the selected connection.\r    <p>\r\t\t<b>Bus type VLNV</b> and <b>Abstraction type VLNV</b> show the Bus Definition and\r\t\tthe Abstraction Definition that define the communication protocol on the bus.\r\t<p>\r\t\tA connection has a mandatory <b>name</b> and an optional <b>description</b>.\r\t\tBy default, the connection is named by the connected instances and interfaces.\r\t\tThe name also forms the basis for signal naming in the generated HDL.\r\n    </p>\r\n    <p>\r\n        <b>Connected physical ports</b> shows the physical ports as they are connected in\r\n        the port maps of the connected bus interfaces and to which port(s) they are connected\r\n        on the opposing end through the connection.\r\n    </p>\r\n</body>\r\n</html>\r\n"
  },
  {
    "path": "Help/hwdesign/hwdesign.html",
    "content": "<html>\r\n<head>\r\n    <link href=\"../style.css\" rel=\"stylesheet\" type=\"text/css\">\r\n</head>\r\n<body>\r\n    <h2>Hardware Design</h2>\r\n    <p>\r\n        A <i>design</i> describes the structure of a hardware component by instantiating other components from the \r\n        library and connecting them. \r\n    </p>\r\n    <p>\r\n        The design area in the center is divided into typed columns to create cleaner\r\n        layouts. There are four column types: 'Components', 'IO', 'Buses', and 'Custom'. Only items with matching\r\n        types can be placed on a column. New columns can be created using the <b>Add Column</b> button in the \r\n        toolbar. The column and its allowed types can edited by double-clicking the column header. \r\n        The column order can be changed by drag-dropping the columns by the header.\r\n    </p>\r\n    <p>\r\n        New <i>component instances</i> can be added by by drag-dropping <i>components</i> from\r\n        the library into the design area. If dropped on an existing instance, the component will\r\n\t\treplace the exisiting instance. Similarly, two existing instances can be swapped by holding the ALT-key\r\n\t\twhile drag-dropping one on the other.<br />\r\n        <img src=\"../images/hierarchy.png\"> A hierarchy icon is shown on the top right corner of the instance,\r\n        if it has a design of its own. Double-clicking the instance opens the design. If the component\r\n        does not have a design, the <b>Component Editor</b> is opened instead. Both options are also available\r\n        by right-clicking the instance. All the <i>bus interfaces</i> in the component will be\r\n        shown on the component instance and can be connected to other instances by creating an\r\n        <i>interconnection</i> with the <b>Interconnection Tool</b>. \r\n        Instances can be copy-pasted within the design or into other designs.\r\n        Selecting an item in the design shows more details in the windows on the right.\r\n    </p>\r\n\r\n    <h3>Design Parameters</h3>\r\n    <p>\r\n        The <i>Design</i> is configurable through a set of <i>parameters</i>. Parameters are name-value \r\n        pairs that can be referenced in e.g. <i>configurable element values</i> of the <i>component instances</i>\r\n        to propagate the same value to every instance.\r\n        For detailed information on parameters, see the parameters-section in the <b>Component Editor</b>.\r\n    </p>\r\n\r\n    <h3>Ad-hoc Visibility</h3>\r\n    <p>\r\n        The Ad-hoc Visibility window is always visible in the design. It lists all the physical ports on the \r\n        selected component instance. If no instance is selected, the ports of the top-level component are\r\n        listed instead. Setting the <b>ad-hoc</b> option for a port shows the individual port on the \r\n        component instance symbol or in the IO column, if it is a top-level port.\r\n    </p>\r\n\r\n    <h3>Design Configuration Details</h3>\r\n    <p>\r\n        The Design Configuration Details window is always visible in the design. A <i>design configuration</i> \r\n        contains additional information about an IP-XACT design. Each design can have multiple configurations. \r\n        Design configuration defines what are the <b>active views</b> of the component instances in the design.\r\n        While not explicitly mandatory, each component instance used in the design should have an active view defined. \r\n        Connecting hierarchical draft bus interfaces to component instance bus interfaces require that an active view is \r\n        defined for that component instance.\r\n    </p>\r\n \r\n\r\n    <h3>Toolbar</h3>\r\n   \r\n    <p>\r\n        <b>Generation</b> group has the tools for automatic generation of e.g. VHDL, Verilog, synthesis and \r\n        simulation scripts, and HTML documentation.\r\n    </p>\r\n    <p>\r\n        <b>Diagram tools</b> has all the design-specific actions including adding columns, connections and\r\n        IO pads. Individual connections can be changed to off-page for cleaner diagrams with \r\n        <b>Toggle Off-Page Tool</b>. Preliminary components can be designed with the <b>Drafting Tool</b>.\r\n    </p>\r\n    <p>\r\n        <b>View</b> has the tools for zooming in and out in the design. Zooming is also possible by holding\r\n        the Ctrl-key while scrolling with the mouse wheel. <b>Visible Windows</b> controls what information\r\n        is shown i.e. IP-XACT library, component preview, context help and design specific windows on the right.\r\n        <b>Visibility control</b> allows selection whether design details, such as 'sticky notes', are shown \r\n        or not.\r\n    </p>\r\n    <p>\r\n        <b>Workspaces</b> store the window layout and visibilty settings. It is handy for quickly changing the \r\n        layout depending on purpose, e.g. design editing vs. component packetization.\r\n    </p>\r\n   \r\n</body>\r\n</html>\r\n"
  },
  {
    "path": "Help/hwdesign/hwinstance.html",
    "content": "<html>\r\n<head>\r\n    <link href=\"../style.css\" rel=\"stylesheet\" type=\"text/css\">\r\n</head>\r\n<body>\r\n    <h2>Component Instance</h2>\r\n\r\n    <h3>Component Instance Details</h3>\r\n    <p>\r\n        Component Instance Details window shows the properties of the selected HW component.\r\n    </p>\r\n    <p>\r\n        <b>Component VLNV</b> shows the component identifier and cannot be changed.\r\n    </p>\r\n    <p>\r\n        <b>Name</b> is mandatory and used to identify the component instance. The name is\r\n        also be used in the generated HDL. \r\n    </p>\r\n    <p>\r\n        <b>Display name</b> is an optional means of providing a user-friendly name for the instance. \r\n        If defined, it is shown on the component instead of the name.\r\n    </p>\r\n    <p>\r\n        <b>Description</b> is an optional field for providing design specific details about the component instance.\r\n    </p>\r\n    <p>        \r\n        <b>Parameters</b> are instance-specific configuration options and shows all the component \r\n        <i>parameters</i>. The <b>value</b> can be set to override the <b>default value</b>\r\n        in the component. The value is editable only, if the parameter resolve-property\r\n        is set to 'user' or 'generated' within the component. By default parameters that cannot be \r\n        edited are filtered out, but will be shown when <b>Show immediate values</b> is selected.\r\n    </p>\r\n    <p>\r\n        <b>Module parameters</b> are language-specific configuration options (equivalent of VHDL\r\n        generics or Verilog parameters) similar to parameters. The element <b>value</b> can be set \r\n        to override the  <b>default value</b> in the component.\r\n    </p>\r\n\r\n    <h3>Ad-hoc Visibility</h3>\r\n    <p>\r\n        The Ad-hoc visibility window shows all the physical ports on the selected component.\r\n        Component symbols show all the <i>bus interfaces</i> by default, but individual\r\n        <i>ports</i> will be shown only, if they are marked as <b>ad-hoc</b>.\r\n    </p>\r\n\r\n    <h3>Design configuration</h3>\r\n    <p>\r\n        The <i>design configuration</i> is additional information about an IP-XACT design.\r\n        Each design can have multiple configurations. Design configuration defines what\r\n        is the <b>active view</b> of a component instance within the design.\r\n    </p>\r\n</body>\r\n</html>\r\n"
  },
  {
    "path": "Help/hwdesign/hwinstance2022.html",
    "content": "<html>\n<head>\n    <link href=\"../style.css\" rel=\"stylesheet\" type=\"text/css\">\n</head>\n<body>\n    <h2>Component Instance</h2>\n\n    <h3>Component Instance Details</h3>\n    <p>\n        Component Instance Details window shows the properties of the selected HW component.\n    </p>\n    <p>\n        <b>Component VLNV</b> shows the component identifier and cannot be changed.\n    </p>\n    <p>\n        <b>Name</b> is mandatory and used to identify the component instance. The name is\n        also be used in the generated HDL. \n    </p>\n    <p>\n        <b>Display name</b> is an optional means of providing a user-friendly name for the instance. \n        If defined, it is shown on the component instead of the name.\n    </p>\n    <p>\n        <b>Description</b> is an optional field for providing design specific details about the component instance.\n    </p>\n    <p>\n        <b>Power domains</b> editor is used to create and edit references to external power domains of the design component\n        and internal power domains of the component instance component.\n    </p>\n    <p>        \n        <b>Parameters</b> are instance-specific configuration options and shows all the component \n        <i>parameters</i>. The <b>value</b> can be set to override the <b>default value</b>\n        in the component. The value is editable only, if the parameter resolve-property\n        is set to 'user' or 'generated' within the component. By default parameters that cannot be \n        edited are filtered out, but will be shown when <b>Show immediate values</b> is selected.\n    </p>\n    <p>\n        <b>Module parameters</b> are language-specific configuration options (equivalent of VHDL\n        generics or Verilog parameters) similar to parameters. The element <b>value</b> can be set \n        to override the  <b>default value</b> in the component.\n    </p>\n\n    <h3>Ad-hoc Visibility</h3>\n    <p>\n        The Ad-hoc visibility window shows all the physical ports on the selected component.\n        Component symbols show all the <i>bus interfaces</i> by default, but individual\n        <i>ports</i> will be shown only, if they are marked as <b>ad-hoc</b>.\n    </p>\n\n    <h3>Design configuration</h3>\n    <p>\n        The <i>design configuration</i> is additional information about an IP-XACT design.\n        Each design can have multiple configurations. Design configuration defines what\n        is the <b>active view</b> of a component instance within the design.\n    </p>\n</body>\n</html>\n"
  },
  {
    "path": "Help/hwdesign/interconnectgenerator.html",
    "content": "<html>\n<head>\n    <link href=\"../style.css\" rel=\"stylesheet\" type=\"text/css\">\n</head>\n<body>\n    <h2>Interconnect generator</h2>\n    <p>\n        Kactus2 features a generator for generating interconnect components to connect IP blocks in a given design. To launch the generator, press the button \n        in the configuration tools section, while a design is open: \n        <br>\n        <img src=\"../images/icn-generator-button.png\" />\n        </br>\n    </p>\n\n    <h3>Overview</h3>\n    <p>\n        The interconnect generator can create IP-XACT models for interconnect components using either transparent bridges or channels for addressing. \n        RTL code generation (verilog) is supported for selected abstraction definitions and interconnect types. The RTL code relies on PULP open source libraries \n        for the functional RTL.\n    </p>\n\n    <h3>Generator dialog</h3>\n    <h4>Interconnect component VLNV editor</h4>\n    <br>\n    <img src=\"../images/icn-component-vlnv-editor.png\" />\n    <p>\n        VLNV editor is used to define the VLNV for the interconnect component. The generated IP-XACT document will be placed in the default library with a path derived from the VLNV.\n    </p>\n\n    <h4>Interconnect Component Configuration</h4>\n    <br>\n    <img src=\"../images/icn-component-configuration.png\" />\n    <p>\n        The interconnect component requires that an abstraction definition is selected for the bus interfaces that are generated. The abstraction definition should generally match the \n        wanted interconnect type, such as AXI4 or OBI. The listed abstraction definition options are abstraction definitions in use by the bus interfaces of the component instances in the design.\n    </p>\n\n    <h4>Generate RTL (experimental)</h4>\n    <br>\n    <img src=\"../images/icn-dialog-generate-rtl.png\" />\n    <p>\n        Apart from IP-XACT component description, a verilog RTL file can be automatically generated for supported configurations. RTL file generation is still experimental and requires that interconnect \n        uses a compatible abstraction definition. Currently supported abstraction definitions are TUNI authored AXI4(LITE) and OBI abstractions. RTL generation is recommended for channel-type \n        interconnect components, but bridges are also supported with limited address mapping capabilities. RTL generation also requires that the Verilog generator plugin is enabled. Generated RTL code  \n        needs bit width information for address and data widths. This information can be automatically extracted from selected abstraction definition, more information in the Interconnect component parameters section below.\n    </p>\n    <p>\n        The RTL file is generated to the interconnect component IP-XACT model location and the generated RTL can also be added to a file set by checking the \"Add to fileset\" checkbox and providing \n        a name for the fileset.\n    </p>\n\n    <h4>Interconnect component parameters</h4>\n    <br>\n    <img src=\"../images/icn-dialog-parameters.png\" />\n    <p>\n        It is possible to define parameters for the interconnect component. Some parameters are automatically created for RTL generation. These are the address and data bit widths. To automatically\n        extract widths, they must be parameterized in the selected abstraction definition. The disabled fields (grey background) in the screenshot above are automatically extracted width parameters. \n        If no width parameters are found, then they are automatically created with default names ADDR_WIDTH and DATA_WIDTH. Whether the parameters were extracted or created, they cannot be removed \n        during interconnect generation and only the value field can be edited.\n    </p>\n    <p>\n        Address ports in abstraction definition should use the address width \n        parameter as the port width, and have address qualifier set. The same applies to data ports and data widths. As an example, below is a screenshot from TUNI AXI4LITE abstraction \n        definition:\n    </p>\n    <br>\n    <img src=\"../images/icn-dialog-addr-data-widths.png\" />\n\n    <h4>Interconnect mode</h4>\n    <br>\n    <img src=\"../images/icn-dialog-modes.png\" />\n    <p>\n        Interconnect modes select which type of component is created: one using transparent bridges as the internal mapping, or one that uses a channel. Address mapping is currently only available for \n        channel-based interconnect components.\n    </p>\n\n    <h4>Instances to connect</h4>\n    <br>\n    <img src=\"../images/icn-dialog-instances.png\" />\n    <p>\n        The <b>Instances to connect</b> section consists of a list where component instances found in the design can be selected to be connected to the interconnect component. Instance interfaces to connect \n        can be selected with the round checkboxes. \n    </p>\n    <p>\n        For both bridge mode and channel mode, at least one initiator/master-adjacent and one target/slave-adjacent interface must be selected. Here, initiator-adjacent refers to an interface, which can be connected \n        to a mirrored initiator/master interface of the interconnect component if channel mode is selected, or a target/slave interface if bridge mode is selected. Target-adjacent refers to an interface that can be \n        connected to a mirrored target/slave interface if channel mode is selected, or an initiator/master interface if bridge mode is selected.\n    </p>\n    <p>\n        If channel mode is selected, it is possible to address-map the selected interfaces using the <b>Start</b> and <b>Range</b> editors. These editors accept IP-XACT expressions and parameters defined \n        in the parameter editor (see above).\n    </p>\n</body>\n</html>\n"
  },
  {
    "path": "Help/index.html",
    "content": "<html>\r\n<head>\r\n    <link href=\"style.css\" rel=\"stylesheet\" type=\"text/css\">\r\n</head>\r\n<body>\r\n    <h2>Kactus2 Manual</h2>\r\n    <p>\r\n        To access the manual topics, see the contents window (Right click on the menu bar).\r\n    </p>\r\n\r\n    <h3>Summary</h3>\r\n\r\n    <p>\r\n        Kactus2 is a toolset for designing embedded products, especially FPGA-based\r\n        MP-SoCs. The aim is easier IP reusabilility and integration for both hardware and\r\n        software. The tool is based on IEEE 1685-2014 \"IP-XACT\" standard.\r\n    </p>\r\n    \r\n    <h3>What you can do with Kactus2</h3>\r\n    \r\n    <p>See <a href=\"whatYouCanDo.html\">this page.</a></p>\r\n    \r\n    <h3>Examples</h3>\r\n    <p>\r\n        Example IPs are available in GitHub at \r\n\t\t<a href=\"https://github.com/kactus2/ipxactexamplelib\">https://github.com/kactus2/ipxactexamplelib</a>.\r\n    </p>\r\n    \r\n    <h3>Tutorials</h3>\r\n    <p>\r\n        Video tutorials are available in Youtube at \r\n\t\t<a href=\"https://www.youtube.com/channel/UCsilC6PiJ8tH5ltGxL5M8VA\">https://www.youtube.com/channel/UCsilC6PiJ8tH5ltGxL5M8VA</a>.\r\n    </p>\r\n</body>\r\n</html>\r\n"
  },
  {
    "path": "Help/kactus2help.qhcp",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n<QHelpCollectionProject version=\"1.0\">\r\n    <docFiles>\r\n        <generate>\r\n            <file>\r\n                <input>kactus2help.qhp</input>\r\n                <output>Kactus2Help.qch</output>\r\n            </file>\r\n        </generate>\r\n        <register>\r\n            <file>Kactus2Help.qch</file>\r\n        </register>\r\n    </docFiles>\r\n</QHelpCollectionProject>\r\n"
  },
  {
    "path": "Help/kactus2help.qhp",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<QtHelpProject version=\"1.0\">\n  <namespace>fi.tuni.kactus2</namespace>\n  <virtualFolder>doc</virtualFolder>\n  <customFilter name=\"Kactus2 2.0\">\n    <filterAttribute>kactus2</filterAttribute>\n    <filterAttribute>2.0</filterAttribute>\n  </customFilter>\n  <filterSection>\n    <filterAttribute>kactus2</filterAttribute>\n    <filterAttribute>2.0</filterAttribute>\n    <toc>\n      <section title=\"Kactus2 Manual\" ref=\"index.html\">\n        <section title=\"What you can do with Kactus2\" ref=\"whatYouCanDo.html\"/>\n        <section title=\"Getting Started\" ref=\"gettingStarted/configureLibrary.html\">\n          <section title=\"Step 1: Configuring Library\" ref=\"gettingStarted/configureLibrary.html\"/>\n          <section title=\"Step 2: Accessing Documents\" ref=\"gettingStarted/accessingDocuments.html\"/>\n          <section title=\"Step 3: Creating Documents\" ref=\"gettingStarted/creatingDocuments.html\"/>\n        </section>\n        <section title=\"General Help\" ref=\"general/ribbon.html\">\n          <section title=\"Toolbars and views\" ref=\"general/toolbarsAndViews.html\"/>\n          <section title=\"Library Navigation\" ref=\"general/libraryNavigation.html\"/>\n          <section title=\"Keyboard and Mouse Shortcuts\" ref=\"general/shortcuts.html\"/>\n          <section title=\"Expressions\" ref=\"general/expressions.html\"/>\n          <section title=\"Colors\" ref=\"general/colors.html\"/>\n          <section title=\"Workspace\" ref=\"general/workSpace.html\"/>\n          <section title=\"Default Applications\" ref=\"general/defaultApplication.html\"/>\n        </section>\n        <section title=\"IP-XACT 2022\">\n          <section title=\"Bus Definition\" ref=\"definitions/busdefinition2022.html\"/>\n          <section title=\"Abstraction Definition\" ref=\"definitions/abstractiondefinition2022.html\"/>\n          <section title=\"Catalog\" ref=\"definitions/catalog.html\"/>\n          <section title=\"Component\" ref=\"componenteditor/componenteditor.html\">\n            <section title=\"General\" ref=\"componenteditor/general2022.html\" />\n            <section title=\"File sets\" ref=\"componenteditor/filesets.html\">\n              <section title=\"File set\" ref=\"componenteditor/fileset2022.html\">\n                <section title=\"File\" ref=\"componenteditor/filegeneral.html\" />\n              </section>\n            </section>\n            <section title=\"Choices\" ref=\"componenteditor/choices.html\" />\n            <section title=\"Parameters\" ref=\"componenteditor/params.html\" />\n            <section title=\"Memory maps\" ref=\"componenteditor/memorymaps2022.html\">\n              <section title=\"Memory map\" ref=\"componenteditor/memorymap2022.html\">\n                <section title=\"Address block\" ref=\"componenteditor/addressblock2022.html\">\n                  <section title=\"Register\" ref=\"componenteditor/register2022.html\">\n                    <section title=\"Field\" ref=\"componenteditor/field2022.html\" />\n                  </section>\n                  <section title=\"Register file\" ref=\"componenteditor/registerFile2022.html\" />\n                </section>\n              <section title=\"Subspace map\" ref=\"componenteditor/subspacemap2022.html\" />\n              </section>\n            </section>\n            <section title=\"Address spaces\" ref=\"componenteditor/addressspaces2022.html\">\n              <section title=\"Address space\" ref=\"componenteditor/addressspace2022.html\">\n                <section title=\"Memory map\" ref=\"componenteditor/memorymap2022.html\">\n                  <section title=\"Address block\" ref=\"componenteditor/addressblock2022.html\">\n                    <section title=\"Register\" ref=\"componenteditor/register2022.html\">\n                      <section title=\"Field\" ref=\"componenteditor/field2022.html\" />\n                    </section>\n                  </section>\n                </section>\n              </section>\n            </section>\n            <section title=\"Instantiations\" ref=\"componenteditor/instantiations.html\">\n              <section title=\"Component instantiations\" ref=\"componenteditor/componentInstantiations.html\">\n                <section title=\"Component instantiation\" ref=\"componenteditor/componentInstantiation2022.html\" />\n              </section>\n              <section title=\"Design configuration instantiations\" ref=\"componenteditor/designConfigurationInstantiations.html\">\n                <section title=\"Design configuration instantiation\" ref=\"componenteditor/designConfigurationInstantiation2022.html\" />\n              </section>\n              <section title=\"Design instantiations\" ref=\"componenteditor/designInstantiations.html\">\n                <section title=\"Design instantiation\" ref=\"componenteditor/designInstantiation2022.html\" />\n              </section>\n            </section>\n            <section title=\"Views\" ref=\"componenteditor/views.html\">\n              <section title=\"View\" ref=\"componenteditor/view2022.html\" />\n            </section>\n            <section title=\"System views\" ref=\"componenteditor/systemviews.html\">\n              <section title=\"System view\" ref=\"componenteditor/systemview.html\" />\n            </section>\n            <section title=\"Ports\" ref=\"componenteditor/ports.html\">\n              <section title=\"Wire ports\" ref=\"componenteditor/wirePorts.html\" />\n              <section title=\"Transactional ports\" ref=\"componenteditor/transactionalPorts.html\" />\n            </section>\n            <section title=\"Bus interfaces\" ref=\"componenteditor/businterfaces2022.html\">\n              <section title=\"Bus interface\" ref=\"componenteditor/businterfacegeneral2022.html\"/>\n              <section title=\"Portmaps\" ref=\"componenteditor/portmaps2022.html\"/>\n            </section>\n            <section title=\"Indirect interfaces\" ref=\"componenteditor/indirectInterfaces.html\">\n              <section title=\"Single indirect interface\" ref=\"componenteditor/indirectInterface2022.html\" />\n            </section>\n            <section title=\"Channels\" ref=\"componenteditor/channels2022.html\" />\n            <section title=\"Modes\" ref=\"componenteditor/modes2022.html\">\n              <section title=\"Mode\" ref=\"componenteditor/mode2022.html\" />\n            </section>\n            <section title=\"CPUs\" ref=\"componenteditor/cpus2022.html\">\n              <section title=\"CPU\" ref=\"componenteditor/cpu2022.html\" />\n            </section>\n            <section title=\"Other clock drivers\" ref=\"componenteditor/otherclockdrivers.html\" />\n            <section title=\"Power domains\" ref=\"componenteditor/powerdomains2022.html\"/>\n            <section title=\"Reset types\" ref=\"componenteditor/resetTypes2022.html\"/>\n            <section title=\"COM interfaces\" ref=\"componenteditor/cominterfaces.html\">\n              <section title=\"COM interface\" ref=\"componenteditor/cominterface.html\" />\n            </section>\n            <section title=\"API interfaces\" ref=\"componenteditor/apiinterfaces.html\">\n              <section title=\"API interface\" ref=\"componenteditor/apiinterface.html\" />\n            </section>\n            <section title=\"Software properties\" ref=\"componenteditor/swproperties.html\" />\n          </section>\n          <section title=\"HW Design\" ref=\"hwdesign/hwdesign.html\">\n            <section title=\"Component Instance\" ref=\"hwdesign/hwinstance2022.html\" />\n            <section title=\"Bus Interface\" ref=\"hwdesign/busport2022.html\" />\n            <section title=\"Interconnection\" ref=\"hwdesign/connection.html\" />\n            <section title=\"Interconnect generator\" ref=\"hwdesign/interconnectgenerator.html\" />\n            <section title=\"Ad-hoc Port\" ref=\"hwdesign/adhocport.html\" />\n            <section title=\"Ad-hoc Connection\" ref=\"hwdesign/adhocconnection.html\" />\n          </section>\n        </section>\n        <section title=\"IP-XACT 2014\">\n          <section title=\"Bus Definition\" ref=\"definitions/busdefinition.html\"/>\n          <section title=\"Abstraction Definition\" ref=\"definitions/abstractiondefinition.html\"/>\n          <section title=\"Catalog\" ref=\"definitions/catalog.html\" />\n          <section title=\"Component\" ref=\"componenteditor/componenteditor.html\">\n            <section title=\"General\" ref=\"componenteditor/general.html\" />\n            <section title=\"File sets\" ref=\"componenteditor/filesets.html\">\n              <section title=\"File set\" ref=\"componenteditor/fileset.html\">\n                <section title=\"File\" ref=\"componenteditor/filegeneral.html\" />\n              </section>\n            </section>\n            <section title=\"Choices\" ref=\"componenteditor/choices.html\" />\n            <section title=\"Parameters\" ref=\"componenteditor/params.html\" />\n            <section title=\"Memory maps\" ref=\"componenteditor/memorymaps.html\">\n              <section title=\"Memory map\" ref=\"componenteditor/memorymap.html\">\n                <section title=\"Address block\" ref=\"componenteditor/addressblock.html\">\n                  <section title=\"Register\" ref=\"componenteditor/register.html\">\n                    <section title=\"Field\" ref=\"componenteditor/field.html\" />\n                  </section>\n                  <section title=\"Register file\" ref=\"componenteditor/registerFile.html\" />\n                </section>\n              <section title=\"Subspace map\" ref=\"componenteditor/subspacemap.html\" />\n              </section>\n            </section>\n            <section title=\"Address spaces\" ref=\"componenteditor/addressspaces.html\">\n              <section title=\"Address space\" ref=\"componenteditor/addressspace.html\">\n                <section title=\"Memory map\" ref=\"componenteditor/memorymap.html\">\n                  <section title=\"Address block\" ref=\"componenteditor/addressblock.html\">\n                    <section title=\"Register\" ref=\"componenteditor/register.html\">\n                      <section title=\"Field\" ref=\"componenteditor/field.html\" />\n                    </section>\n                  </section>\n                </section>\n              </section>\n            </section>\n            <section title=\"Instantiations\" ref=\"componenteditor/instantiations.html\">\n              <section title=\"Component instantiations\" ref=\"componenteditor/componentInstantiations.html\">\n                <section title=\"Component instantiation\" ref=\"componenteditor/componentInstantiation.html\" />\n              </section>\n              <section title=\"Design configuration instantiations\" ref=\"componenteditor/designConfigurationInstantiations.html\">\n                <section title=\"Design configuration instantiation\" ref=\"componenteditor/designConfigurationInstantiation.html\" />\n              </section>\n              <section title=\"Design instantiations\" ref=\"componenteditor/designInstantiations.html\">\n                <section title=\"Design instantiation\" ref=\"componenteditor/designInstantiation.html\" />\n              </section>\n            </section>\n            <section title=\"Views\" ref=\"componenteditor/views.html\">\n              <section title=\"View\" ref=\"componenteditor/view.html\" />\n            </section>\n            <section title=\"System views\" ref=\"componenteditor/systemviews.html\">\n              <section title=\"System view\" ref=\"componenteditor/systemview.html\" />\n            </section>\n            <section title=\"Ports\" ref=\"componenteditor/ports.html\">\n              <section title=\"Wire ports\" ref=\"componenteditor/wirePorts.html\" />\n              <section title=\"Transactional ports\" ref=\"componenteditor/transactionalPorts.html\" />\n            </section>\n            <section title=\"Bus interfaces\" ref=\"componenteditor/businterfaces.html\">\n              <section title=\"Bus interface\" ref=\"componenteditor/businterfacegeneral.html\" />\n              <section title=\"Portmaps\" ref=\"componenteditor/portmaps.html\" />\n            </section>\n            <section title=\"Indirect interfaces\" ref=\"componenteditor/indirectInterfaces.html\">\n              <section title=\"Single indirect interface\" ref=\"componenteditor/indirectInterface.html\" />\n            </section>\n            <section title=\"Channels\" ref=\"componenteditor/channels.html\" />\n            <section title=\"Remap states\" ref=\"componenteditor/remapStates.html\">\n              <section title=\"Single remap state\" ref=\"componenteditor/singleRemapState.html\" />\n            </section>\n            <section title=\"CPUs\" ref=\"componenteditor/cpus.html\">\n              <section title=\"CPU\" ref=\"componenteditor/cpu.html\" />\n            </section>\n            <section title=\"Other clock drivers\" ref=\"componenteditor/otherclockdrivers.html\" />\n            <section title=\"Reset types\" ref=\"componenteditor/resetTypes.html\"/>\n            <section title=\"COM interfaces\" ref=\"componenteditor/cominterfaces.html\">\n              <section title=\"COM interface\" ref=\"componenteditor/cominterface.html\" />\n            </section>\n            <section title=\"API interfaces\" ref=\"componenteditor/apiinterfaces.html\">\n              <section title=\"API interface\" ref=\"componenteditor/apiinterface.html\" />\n            </section>\n            <section title=\"Software properties\" ref=\"componenteditor/swproperties.html\" />\n          </section>\n          <section title=\"HW Design\" ref=\"hwdesign/hwdesign.html\">\n            <section title=\"Component Instance\" ref=\"hwdesign/hwinstance.html\" />\n            <section title=\"Bus Interface\" ref=\"hwdesign/busport.html\" />\n            <section title=\"Interconnection\" ref=\"hwdesign/connection.html\" />\n\t\t\t<section title=\"Interconnect generator\" ref=\"hwdesign/interconnectgenerator.html\" />\n\t\t\t<section title=\"Ad-hoc Port\" ref=\"hwdesign/adhocport.html\" />\n            <section title=\"Ad-hoc Connection\" ref=\"hwdesign/adhocconnection.html\" />\n          </section>\n        </section>\n        <section title=\"Memory Design\" ref=\"memoryDesign/memoryDesign.html\"/>\n        <section title=\"SW Design\" ref=\"swsysdesign/swdesign.html\">\n          <section title=\"SW Component Instance\" ref=\"swsysdesign/swinstance.html\" />\n        </section>\n        <!--section title=\"System Design\" ref=\"swsysdesign/systemdesign.html\"/-->\n        <section title=\"Community Guidelines\" ref=\"communityGuideLines.html\"/>\n      </section>\n    </toc>\n    <keywords>\n      <keyword name=\"HW Design\" id=\"Kactus2::hwdesign\" ref=\"hwdesign/hwdesign.html\" />\n    </keywords>\n    <files>\n      <file>style.css</file>\n      <file>*.html</file>\n      <file>general/*.html</file>\n      <file>componenteditor/*.html</file>\n      <file>definitions/*.html</file>\n      <file>hwdesign/*.html</file>\n      <file>swsysdesign/*.html</file>\n      <file>memoryDesign/*.html</file>\n      <file>gettingStarted/*.html</file>\n      <file>images/*.png</file>\n    </files>\n  </filterSection>\n</QtHelpProject>\n"
  },
  {
    "path": "Help/memoryDesign/memoryDesign.html",
    "content": "<html>\r<head>\r    <link href=\"../style.css\" rel=\"stylesheet\" type=\"text/css\" />\r    <title>Memory Design</title>\n</head>\r<body>\r    <h2>Memory Design</h2>\r    <p>\r        Memory design displays all the address spaces and memory maps from the associated HW design. These are\r        constructed from the component instances and their contained components. Connections made between the bus\r        interfaces in the HW design are displayed here as connections between the address space referenced by the\r        connected master bus interface and the memory map referenced by the connected slave interface.<br />\r        Initially the memory design is shown at the most simple level, all the items and connections are condensed\r        and both the sub memory items and bridge connections are hidden. These can all be expanded and shown\r        through the buttons on the <i>Filtering Tools</i> group in the tool bar.\r    </p>\r    <p>\r        Address spaces are displayed in green on the left side of the view. The address spaces are constructed\r        using the address spaces of the instanced components in the associated HW design. The address spaces can\r        contain address segments.\r    </p>\r    <p>\r        Memory maps are displayed in blue on the right side of the view. The memory maps are constructed using the\r        memory maps of the instanced components in the associated HW design. The memory maps can contain address\r        blocks, registers and register fields.\r    </p>\r    <p>\r        The memory items are displayed as rectangular items containing information regarding the memory item.\r        <ul>\r            <li><b>Name</b> displays the name of the memory item. If the item has a display name, it is shown\r                instead of the real name.</li>\r            <li><b>Instance name</b> displays the name of the component instance containing the memory item.\r                The instance name is displayed only for the address spaces and memory maps.</li>\r            <li><b>Base address</b> displays the modified base address of the memory item. Displayed at the\r                top corner of the item.</li>\r            <li><b>Last address</b> displays the modified last address of the memory item. Displayed at the\r                bottom corner of the item.</li>\r        </ul>\r        Additional information can be seen in the tool tip of a memory item.\r    </p>\r    <p>\r        Connections are featured as lines between the connected items, with the connection range displayed on\r        both sides of the connection. Connections and the connected memory items are arrayd so that the ranges of\r        the memory items and their sub memory items match.\r    </p>\r    <p>\r        Connections are divided into different classes:\r        <ul>\r            <li><b>Regular connections.</b> These are regular connections between an address space and a memory\r                map.</li>\r            <li><b>Bridge connections.</b> Bridges are displayed as a connection between a master bus interface\r                and another, bridged master bus interface. These connections are displayed in green, with a\r                modified connection line.</li>\r            <li><b>Local memory map connections.</b> Local memory maps are displayed as connections between an\r                address space and its local memory map. These are displayed in blue, with a modified connection\r                line.</li>\r        </ul>\r    </p>\r    <p>\r        Overlapping connections are displayed in red. with the overlapping range areas displayed next to the\r        connections.\r    </p>\r    <p>\r        All the sub memory items can be enabled or disabled through the use of buttons in the tool bar. This allows\r        the user to display only the required information. Additionally, field items can be extended to display\r        their full name. This can be achieved by pressing the button for extending the field items, or by pressing\r        ALT together with using the mouse wheel.<br />\r        The bridged connections are initially hidden, but they can be viewed through the use of Address Space\r        Filter button.<br />\r        As the memory items are initially displayed as compressed, it is possible to display them in full. This\r        can be achieved through the Compress Memory Items button.\r    </p>\r</body>\r</html>\r"
  },
  {
    "path": "Help/style.css",
    "content": ""
  },
  {
    "path": "Help/swsysdesign/apiconnection.html",
    "content": "<html>\r\n<head>\r\n    <link href=\"../style.css\" rel=\"stylesheet\" type=\"text/css\">\r\n</head>\r\n<body>\r\n    <h2>API Connection</h2>\r\n    <p>\r\n        This is Kactus2 extension <br><img src=\"../images/appicon.png\"><br><b>\r        API connections</b> define tight coupling of software component instances\r\t\tin the design. API interfaces are connected mainly between application and the platform (OS, drivers)\r\n        in contrast to <i>COM connections</i> that are used for communication between application modules.\r\n    </p>\r\n\r\n    <h3>Connection Editor</h3>\r\n    <p>\r\n        The Connection Editor shows the properties of the selected API connection.\r    <p>\r\t\t<b>API type VLNV</b> shows the API Definition that defines the communication protocol through\r        the API.\r\t<p>\r\t\tAn API connection has a mandatory <b>name</b> and an optional <b>description</b>.\r\t\tBy default, the connection is named by the connected instances and interfaces.\r\n    </p>\r\n</body>\r\n</html>\r\n"
  },
  {
    "path": "Help/swsysdesign/comconnection.html",
    "content": "<html>\r\n<head>\r\n    <link href=\"../style.css\" rel=\"stylesheet\" type=\"text/css\">\r\n</head>\r\n<body>\r\n    <h2>COM Connection</h2>\r\n    <p>\r\n        This is Kactus2 extension <br><img src=\"../images/appicon.png\"><br>\r\n        <b>COM connections</b> define the loose coupling of software component instances\r\t\tin the design. <i>COM connections</i> are mainly used for communication between application modules,\r\n        in contrast to <i>API interfaces</i> that are used between application and the platform (OS, drivers).\r\n    </p>\r\n\r\n    <h3>Connection Editor</h3>\r\n    <p>\r\n        The Connection Editor shows the properties of the selected COM connection.\r    <p>\r\t\t<b>COM type VLNV</b> shows the COM Definition that defines the communication protocol.\r\t<p>\r\t\tA COM connection has a mandatory <b>name</b> and an optional <b>description</b>.\r\t\tBy default, the connection is named by the connected instances and interfaces.\r\n    </p>\r\n</body>\r\n</html>\r\n"
  },
  {
    "path": "Help/swsysdesign/hwmappinginstance.html",
    "content": "<html>\r\n<head>\r\n    <link href=\"../style.css\" rel=\"stylesheet\" type=\"text/css\">\r\n</head>\r\n<body>\r\n    <h2>HW Mapping Instance</h2>\r\n    <p>\r\n      This is Kactus2 extension <br><img src=\"../images/appicon.png\"><br>\r\n      This instance represents a HW component instance that can be used as a platform\r\n      for running software i.e. it has at least one CPU element defined. HW mapping instances are\r\n      automatically searched within the selected HW design hierarchy and shown in system design.\r\n      Software components can be mapped on the platform by drag-dropping.\r\n    </p>\r\n\r\n    <h3>Component Instance Details</h3>\r\n    <p>\r\n        Component Instance Details window shows the properties of the selected HW mapping instance.\r\n    </p>\r\n    <p>\r\n        <b>Component VLNV</b> shows the component identifier and cannot be changed.\r\n    </p>\r\n    <p>\r\n        <b>Name</b> is mandatory and used to identify the instance.\r\n    </p>\r\n    <p>\r\n        <b>Display name</b> is an optional means of providing a user-friendly name for the instance. \r\n        If defined, it is shown on the component instead of the name.\r\n    </p>\r\n    <p>\r\n        <b>Description</b> is an optional field for providing design specific details about the instance.\r\n    </p>\r\n    <p>\r\n\t\t<b>Property values</b> allow specifying parameters as name-value pairs.\r\n    </p>\r\n</body>\r\n</html>\r\n"
  },
  {
    "path": "Help/swsysdesign/swdesign.html",
    "content": "<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01//EN\" \"http://www.w3.org/TR/html4/strict.dtd\">\r\n<html>\r\n<head>\r\n    <meta http-equiv=\"Content-Type\"content=\"text/html; charset=utf-8\">\r\n    <link href=\"../style.css\" rel=\"stylesheet\" type=\"text/css\">\r\n\t<title>SW Design</title>\r\n</head>\r\n<body>\r\n    <h2>SW Design</h2>\r\n    <p>\r\n      This is Kactus2 extension <br><img\r\n      src=\"../images/appicon.png\"><br> User can describe the structure of SW\r\n      similarly ot HW design. All SW instantiated in one <i>SW\r\n      design</i> will be executes on a single CPU. The mapping of SW\r\n      design onto CPU HW is done in a <i>system design</i>.\r\n    </p>\r\n    <p>\r\n      Select <i>SW components</i> from the library and connect\r\n      them. <br>Instead of <i>interfaces</i> and <i>ports</i>, SW\r\n      components have <i>API interfaces</i>. There are two modes, a SW\r\n      component can <i>request</i> an API (i.e. make calls to API\r\n      functions) or <i>provide</i> it (i.e. implement the API\r\n      functions). Connections are allowed only when interfaces match\r\n      or if either interface is 'UNSET' (no API VLNV associated with\r\n      it).\r\n    </p>\r\n</body>\r\n</html>\r\n"
  },
  {
    "path": "Help/swsysdesign/swinstance.html",
    "content": "<html>\r\n<head>\r\n    <link href=\"../style.css\" rel=\"stylesheet\" type=\"text/css\">\r\n</head>\r\n<body>\r\n    <h2>SW Component Instance</h2>\r\n\t<p>\r\n      This is Kactus2 extension <br><img src=\"../images/appicon.png\">\r\n      <br><br> Reusable piece of SW that is instantiated as a part of SW\r\n      design. Each instance has a mandatory <b>name</b>, and\r\n      optionally a <b>display name</b> and textual <b>description</b>.\r\n\t</p>\r\n\r\n    <p>\r\n\t\t<b>File set reference</b> refers to a file set of the <b>top component</b>\r\n        of the design that is to be used in conjunction with the instance.\r\n\t</p>\r\n\r\n\t<p>\r\n\t\t<b>Property values</b> allow specifying parameters as name-value pairs.\r\n\t</p>\r\n</body>\r\n</html>\r\n"
  },
  {
    "path": "Help/swsysdesign/systemdesign.html",
    "content": "<html>\r\n<head>\r\n    <link href=\"../style.css\" rel=\"stylesheet\" type=\"text/css\">\r\n</head>\r\n<body>\r\n    <h2>System Design</h2>\r\n    <p>\r\n      This is Kactus2 extension <br><img src=\"../images/appicon.png\"><br>\r\n      A <i>system design</i> describes the software mapping on hardware resources. \r\n      <i>Software components</i> can be mapped on hardware accelerators and\r\n      CPUs, and connected using <i>COM</i> and <i>API</i> connections.\r\n    </p>\r\n    <p>\r\n        The design area in the center is divided into typed columns to create cleaner\r\n        layouts. New columns can be created using the <b>Add Column</b> button in the \r\n        toolbar. The column name can edited by double-clicking the column header. \r\n        The column order can be changed by drag-dropping the columns by the header.\r\n    </p>\r\n    <p>\r\n        New <i>software component instances</i> can be added by by drag-dropping \r\n        <i>components</i> from the library into the design area. Hardware components\r\n        cannot be added directly, they must be defined in the underlying hardware design.<br />\r\n        Double-clicking the instance opens the design.\r\n        Selecting an item in the design shows more details in the windows on the right.\r\n    </p>\r\n\r\n    <h3>Design Configuration Details</h3>\r\n    <p>\r\n        The Design Configuration Details window is always visible in the design. A <i>design configuration</i> \r\n        contains additional information about an the design. Each design can have multiple configurations. \r\n        Design configuration defines what are the <b>active views</b> of the component instances in the design.\r\n    </p>\r\n\r\n    <h3>HW Mapping Details</h3>\r\n    <p>\r\n        The HW Mapping Details window is always visible in the system design. An <b>HW component reference</b> \r\n        defines the top level hardware component for which the system design applies. \r\n        <b>HW component view</b> defines the view containing the hardware design that is used as\r\n        a platform for the system. Changes to the component reference and view must be confirmed by selecting\r\n        <b>Apply</b>. <b>Revert</b> can be used to change back to the previous component configuration.\r\n    </p>\r\n</body>\r\n</html>\r\n"
  },
  {
    "path": "Help/swsysdesign/undefinedconnection.html",
    "content": "<html>\r\n<head>\r\n    <link href=\"../style.css\" rel=\"stylesheet\" type=\"text/css\">\r\n</head>\r\n<body>\r\n    <h2>Undefined Connection</h2>\r\n    <p>\r\n        This connection has no defined type yet. Setting the connection endpoint to\r\n        COM or API interface will automatically change the connection to the corresponding connection type.\r\n    </p>\r\n</body>\r\n</html>\r\n"
  },
  {
    "path": "Help/welcome.html",
    "content": "<html>\r\n<head>\r\n    <link href=\"style.css\" rel=\"stylesheet\" type=\"text/css\">\r\n</head>\r\n<body>\r\n    <h2>Welcome to Kactus2</h2>\r\n    <p>\r\n        This window will give context-sensitive guidance during your use of Kactus2.\r\n    </p>\r\n    <p>\r\n        <a href=\"gettingStarted/configureLibrary.html\">Getting started</a> section\r\n\t\twill guide you through the basic setup for configuring your IP-XACT library\r\n\t\tand accessing documents in the library.\r\n    </p>\t    \r\n\t<p>\r\n        <img src=\"images/system-help.png\"> The help content can be browsed at any time\r\n\t\tby clicking the <b>Help</b> button in the toolbar.\r\n    </p>\r\n</body>\r\n</html>\r\n"
  },
  {
    "path": "Help/whatYouCanDo.html",
    "content": "<html>\n<head>\n    <link href=\"style.css\" rel=\"stylesheet\" type=\"text/css\">\n</head>\n<body>\n    <h2>What you can do with Kactus2</h2>\n\n    <p>Package IPs for reuse and exchange</p>\n\n        <ul>\n        <li>Import your existing IPs as IP-XACT components</li>\n        <li>Create new IP-XACT components and generate their HDL module headers</li>\n        <li>Reuse IP-XACT files from any standard compatible vendor</li>\n        <li>Reuse the IPs in your designs and connect them with wires and busses</li>\n        </ul>\n\n    <p>Create HW designs with hierarchy</p>\n\n        <ul>\n        <li>Create multilevel hierarchies, where a design has multiple sub-designs</li>\n        <li>Configure component instances in designs, including the sub-designs</li>\n        <li>Use generator plugins to create HDL with wiring and parameterization</li>\n        </ul>\n\n    <p>Integrate HW and SW</p>\n\n        <ul>\n        <li>Use memory designer to preview memory maps and address spaces in your hierarchy</li>\n        <li>Package software to IP-XACT components and map them to hardware</li>\n        <li>Generate makefiles that build executables with rules defined in IP-XACT components</li>\n        </ul>\n        \n    <h3>What you cannot do with Kactus2</h3>\n    <ul>\n        <li>Behavioral logic: Neither Kactus2 nor IP-XACT handles module implementations</li>\n        <li>Synthesis or simulation: These require tools that are specificly created for the purpose</li>\n    </ul>\n    \n    <p></p>\n    \n\t<img alt=\"Kactus2 flow\" src=\"images/kactus2_flow.png\"></img>\n</body>\n</html>\n"
  },
  {
    "path": "IPXACTmodels/AbstractionDefinition/AbstractionDefinition.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: AbstractionDefinition.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Esko Pekkarinen\r\n// Date: 10.08.2015\r\n//\r\n// Description:\r\n// Implementation for ipxact:busDefinition element.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"AbstractionDefinition.h\"\r\n\r\n#include <IPXACTmodels/AbstractionDefinition/TransactionalAbstraction.h>\r\n#include <IPXACTmodels/AbstractionDefinition/WireAbstraction.h>\r\n#include <IPXACTmodels/AbstractionDefinition/PortAbstraction.h>\r\n\r\n#include <IPXACTmodels/common/Choice.h>\r\n\r\n#include <IPXACTmodels/utilities/Copy.h>\r\n\r\n#include <QDomDocument>\r\n#include <QString>\r\n#include <QDomNamedNodeMap>\r\n#include <QDomNode>\r\n#include <QDomNodeList>\r\n#include <QObject>\r\n#include <QSharedPointer>\r\n#include <QStringList>\r\n#include <QXmlStreamWriter>\r\n\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AbstractionDefinition::AbstractionDefinition()\r\n//-----------------------------------------------------------------------------\r\nAbstractionDefinition::AbstractionDefinition(VLNV const& vlnv, Document::Revision revision):\r\nDocument(vlnv, revision)\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AbstractionDefinition::AbstractionDefinition()\r\n//-----------------------------------------------------------------------------\r\nAbstractionDefinition::AbstractionDefinition(AbstractionDefinition const& other):\r\nDocument(other),\r\n    busType_(other.busType_),\r\n    extends_(other.extends_)\r\n{\r\n    Copy::copyList(other.logicalPorts_, logicalPorts_);\r\n    Copy::copyList(other.choices_, choices_);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AbstractionDefinition::operator=()\r\n//-----------------------------------------------------------------------------\r\nAbstractionDefinition & AbstractionDefinition::operator=(AbstractionDefinition const& other)\r\n{\r\n\tif (this != &other)\r\n    {\r\n\t\tDocument::operator=(other);\r\n        busType_ = other.busType_;\r\n\t\textends_ = other.extends_;\r\n\r\n        logicalPorts_->clear();\r\n        Copy::copyList(other.logicalPorts_, logicalPorts_);\r\n\r\n        choices_->clear();\r\n        Copy::copyList(other.choices_, choices_);\r\n\t}\r\n\treturn *this;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AbstractionDefinition::~AbstractionDefinition()\r\n//-----------------------------------------------------------------------------\r\nAbstractionDefinition::~AbstractionDefinition()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AbstractionDefinition::clone()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<Document> AbstractionDefinition::clone() const\r\n{\r\n\treturn QSharedPointer<Document>(new AbstractionDefinition(*this));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AbstractionDefinition::setVlnv()\r\n//-----------------------------------------------------------------------------\r\nvoid AbstractionDefinition::setVlnv(VLNV const& vlnv)\r\n{\r\n    VLNV abstractionDefinitionVLNV(vlnv);\r\n    abstractionDefinitionVLNV.setType(VLNV::ABSTRACTIONDEFINITION);\r\n    Document::setVlnv(abstractionDefinitionVLNV);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AbstractionDefinition::setBusType()\r\n//-----------------------------------------------------------------------------\r\nvoid AbstractionDefinition::setBusType(VLNV const& targetBus)\r\n{\r\n    busType_ = targetBus;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AbstractionDefinition::setBusType()\r\n//-----------------------------------------------------------------------------\r\nVLNV AbstractionDefinition::getBusType() const\r\n{\r\n    return busType_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AbstractionDefinition::getExtends()\r\n//-----------------------------------------------------------------------------\r\nVLNV AbstractionDefinition::getExtends() const\r\n{\r\n    return extends_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AbstractionDefinition::setExtends()\r\n//-----------------------------------------------------------------------------\r\nvoid AbstractionDefinition::setExtends(VLNV const& extends)\r\n{\r\n    extends_ = extends;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AbstractionDefinition::getDependentVLNVs()\r\n//-----------------------------------------------------------------------------\r\nQList<VLNV> AbstractionDefinition::getDependentVLNVs() const \r\n{\r\n    QList<VLNV> vlnvList;\r\n\r\n    if (busType_.isValid())\r\n    {\r\n        vlnvList.append(busType_);\r\n    }\r\n\r\n    if (extends_.isValid())\r\n    {\r\n        vlnvList.append(extends_);\r\n    }\r\n\r\n    return vlnvList;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AbstractionDefinition::getDependentFiles()\r\n//-----------------------------------------------------------------------------\r\nQStringList AbstractionDefinition::getDependentFiles() const\r\n{\r\n    return QStringList();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AbstractionDefinition::hasPort()\r\n//-----------------------------------------------------------------------------\r\nbool AbstractionDefinition::hasPort(QString const& portName, General::InterfaceMode mode) const\r\n{\r\n    if (logicalPorts_)\r\n    {\r\n\t\tif (mode == General::INTERFACE_MODE_COUNT)\r\n\t\t{\r\n\t\t\tfor (auto const& port: *logicalPorts_)\r\n\t\t\t{\r\n\t\t\t\tif (port->getLogicalName() == portName && port->hasWire())\r\n\t\t\t\t{\r\n\t\t\t\t\treturn true;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\r\n        for (auto const& port : *logicalPorts_)\r\n        {\r\n            if (port->getLogicalName() == portName)\r\n            {\r\n                QSharedPointer<WireAbstraction> portWire = port->getWire();\r\n                QSharedPointer<TransactionalAbstraction> portTransactional = port->getTransactional();\r\n                if ((mode == General::MASTER || mode == General::MIRRORED_MASTER || mode == General::INITIATOR || mode == General::MIRRORED_INITIATOR) &&\r\n                    ((portWire && portWire->hasMasterPort()) ||\r\n                    (portTransactional && portTransactional->hasMasterPort())))\r\n                {\r\n                    return true;\r\n                }\r\n                else if ((mode == General::SLAVE || mode == General::MIRRORED_SLAVE || mode == General::TARGET || mode == General::MIRRORED_TARGET) &&\r\n                    ((portWire && portWire->hasSlavePort()) ||\r\n                    (portTransactional && portTransactional->hasSlavePort())))\r\n                {\r\n                    return true;\r\n                }\r\n                else if ((mode == General::SYSTEM || mode == General::MIRRORED_SYSTEM) &&\r\n                    ((portWire && !portWire->getSystemPorts()->isEmpty()) ||\r\n                    (portTransactional && portTransactional->getSystemPorts()->isEmpty())))\r\n                {\r\n                    return true;\r\n                }\r\n            }\r\n        }\r\n    }\r\n\r\n    return false;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AbstractionDefinition::getPortNames()\r\n//-----------------------------------------------------------------------------\r\nQStringList AbstractionDefinition::getPortNames(General::InterfaceMode mode) const\r\n{\r\n    QStringList portNames;\r\n    if (logicalPorts_)\r\n    {\r\n        for (auto const& port : *logicalPorts_)\r\n        {\r\n            if (port->hasWire())\r\n            {\r\n                if ((mode == General::MASTER || mode == General::MIRRORED_MASTER) && port->getWire()->hasMasterPort())\r\n                {\r\n                    portNames.append(port->getLogicalName());\r\n                }\r\n                else if ((mode == General::SLAVE || mode == General::MIRRORED_SLAVE) && port->getWire()->hasSlavePort())\r\n                {\r\n                    portNames.append(port->getLogicalName());\r\n                }\r\n                else if ((mode == General::SYSTEM || mode == General::MIRRORED_SYSTEM) && \r\n                    !port->getWire()->getSystemPorts()->isEmpty())\r\n                {\r\n                    portNames.append(port->getLogicalName());\r\n                }\r\n            }        \r\n        }\r\n    }\r\n\r\n    return portNames;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AbstractionDefinition::getPortDirection()\r\n//-----------------------------------------------------------------------------\r\nDirectionTypes::Direction AbstractionDefinition::getPortDirection(QString const& portName,\r\n    General::InterfaceMode mode, QString const& newSystemGroup) const\r\n{\r\n    if (logicalPorts_)\r\n    {\r\n        for (auto const& port : *logicalPorts_)\r\n        {\r\n            if (port->getLogicalName() == portName && port->hasWire())\r\n            {\r\n                return port->getWire()->getDirection(mode, newSystemGroup);            \r\n            }        \r\n        }\r\n    }\r\n\r\n    return DirectionTypes::DIRECTION_INVALID;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AbstractionDefinition::getPortInitiative()\r\n//-----------------------------------------------------------------------------\r\nQString AbstractionDefinition::getPortInitiative(QString const& portName, General::InterfaceMode mode,\r\n    QString const& systemGroup) const\r\n{\r\n    if (logicalPorts_)\r\n    {\r\n        for (auto port : *logicalPorts_)\r\n        {\r\n            if (port->getLogicalName() == portName && port->hasTransactional())\r\n            {\r\n                return port->getTransactional()->getInitiative(mode, systemGroup);\r\n            }\r\n        }\r\n    }\r\n\r\n    return QString();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AbstractionDefinition::getPort()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<PortAbstraction> AbstractionDefinition::getPort(QString const& portName) const\r\n{\r\n    if (logicalPorts_)\r\n    {\r\n        for (auto const& port : *logicalPorts_)\r\n        {\r\n            if (port->getLogicalName() == portName)\r\n            {\r\n                return port;            \r\n            } \r\n        }\r\n    }\r\n\r\n    return QSharedPointer<PortAbstraction>();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AbstractionDefinition::getLogicalPorts()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<QList<QSharedPointer<PortAbstraction> > > AbstractionDefinition::getLogicalPorts() const\r\n{\r\n    return logicalPorts_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AbstractionDefinition::getPortsWithWire()\r\n//-----------------------------------------------------------------------------\r\nQList<QSharedPointer<PortAbstraction> > AbstractionDefinition::getPortsWithWire() const\r\n{\r\n    QList<QSharedPointer<PortAbstraction> > wirePorts;\r\n    std::for_each(logicalPorts_->cbegin(), logicalPorts_->cend(), [&wirePorts](QSharedPointer<PortAbstraction> portAbstraction)\r\n        {\r\n            if (portAbstraction->hasWire())\r\n            {\r\n                wirePorts.append(portAbstraction);\r\n            }\r\n        });\r\n    return wirePorts;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AbstractionDefinition::getPortsWithTransactional()\r\n//-----------------------------------------------------------------------------\r\nQList<QSharedPointer<PortAbstraction> > AbstractionDefinition::getPortsWithTransactional() const\r\n{\r\n    QList<QSharedPointer<PortAbstraction> > transPorts;\r\n    std::for_each(logicalPorts_->cbegin(), logicalPorts_->cend(), [&transPorts](QSharedPointer<PortAbstraction> portAbstraction)\r\n        {\r\n            if (portAbstraction->hasTransactional())\r\n            {\r\n                transPorts.append(portAbstraction);\r\n            }\r\n        });\r\n    return transPorts;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AbstractionDefinition::setChoices()\r\n//-----------------------------------------------------------------------------\r\nvoid AbstractionDefinition::setChoices(QSharedPointer<QList<QSharedPointer<Choice> > > choices)\r\n{\r\n    choices_ = choices;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AbstractionDefinition::getChoices()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<QList<QSharedPointer<Choice> > > AbstractionDefinition::getChoices() const\r\n{\r\n    return choices_;\r\n}\r\n"
  },
  {
    "path": "IPXACTmodels/AbstractionDefinition/AbstractionDefinition.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: AbstractionDefinition.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Esko Pekkarinen\r\n// Date: 10.08.2015\r\n//\r\n// Description:\r\n// Implementation for ipxact:abstractionDefinition element.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef ABSTRACTIONDEFINITION_H\r\n#define ABSTRACTIONDEFINITION_H\r\n\r\n#include <IPXACTmodels/common/Document.h>\r\n#include <IPXACTmodels/common/Parameter.h>\r\n\r\n#include <IPXACTmodels/common/DirectionTypes.h>\r\n#include <IPXACTmodels/common/VLNV.h>\r\n\r\n#include <IPXACTmodels/ipxactmodels_global.h>\r\n \r\n#include <QSharedPointer>\r\n\r\nclass PortAbstraction;\r\nclass Choice;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Implementation for ipxact:abstractionDefinition element.\r\n//-----------------------------------------------------------------------------\r\nclass IPXACTMODELS_EXPORT AbstractionDefinition: public Document\r\n{\r\npublic:\r\n\r\n    AbstractionDefinition(VLNV const& vlnv, Document::Revision revision);\r\n\r\n\t//! Copy constructor.\r\n\tAbstractionDefinition(AbstractionDefinition const& other);\r\n\r\n\t//! Assignment operator.\r\n\tAbstractionDefinition &operator=(AbstractionDefinition const& other);\r\n\r\n\t//! The destructor.\r\n\tvirtual ~AbstractionDefinition();\r\n\r\n\t/*!\r\n\t *  Creates a perfect copy of the Bus Definition.\r\n\t *\r\n\t *    @return Copy of the bus definition.\r\n\t */\r\n\tvirtual QSharedPointer<Document> clone() const;\r\n\r\n\t/*! Set the VLNV for the bus definition.\r\n\t*\r\n\t*    @param [in] vlnv     The vlnv to set\r\n\t*/\r\n\tvoid setVlnv(const VLNV& vlnv) final;\r\n\r\n\t/*! Get the vlnv tag of the bus definition that this abstraction definition details.\r\n\t * \r\n\t *    @return The VLNV this abstraction definition details.\r\n\t */\r\n\tVLNV getBusType() const;\r\n\r\n\t/*! Set the bus definition detailed in this abstraction definition.\r\n\t *\r\n\t *    @param [in] targetBus   The vlnv of the target bus definition.\r\n\t */\r\n\tvoid setBusType(VLNV const& targetBus);\r\n\r\n\t/*! Get the vlnv tag of the bus definition that this definition extends.\r\n\t * \r\n\t *    @return The VLNV this bus extends or empty VLNV if this bus does not extend another.\r\n\t */\r\n\tVLNV getExtends() const;\r\n\r\n\t/*! Set the bus to extend another.\r\n\t *\r\n\t *    @param [in] extends  The vlnv of the extended bus definition.\r\n\t */\r\n\tvoid setExtends(VLNV const& extends);\r\n    \r\n\t/*! Get the VLNVs that this busDefinition depends on.\r\n\t *\r\n\t *    @return The dependency VLNVs.\r\n\t */\r\n\tvirtual QList<VLNV> getDependentVLNVs() const;\r\n\r\n\t/*! Get the file dependencies of this busDefinition.\r\n     *\r\n\t *    @return The dependency files.\r\n     *\r\n     *      @remark This function never returns anything because busDefinition only has VLNV dependencies.\r\n\t */\r\n\tvirtual QStringList getDependentFiles() const;\r\n\r\n    /*!\r\n     *  Checks if the abstraction definition has a definition for a port in a given mode.\r\n     *\r\n     *    @param [in] portName    The name of the port to check.\r\n     *    @param [in] mode        The mode to check for. Is undefined by default, matching any port with a wire.\r\n     *\r\n     *    @return True, if the port definition is found, otherwise false.\r\n     */\r\n    bool hasPort(QString const& portName, General::InterfaceMode mode=General::INTERFACE_MODE_COUNT) const;\r\n\r\n    /*!\r\n     *  Gets the names of the ports defined in the abstraction definition.\r\n     *\r\n     *    @param [in] mode   The interface mode to find ports for.\r\n     *\r\n     *    @return The names of the ports in the given mode.\r\n     */\r\n    QStringList getPortNames(General::InterfaceMode mode) const;\r\n        \r\n    /*!\r\n     *  Gets the direction for a port in a given mode.\r\n     *\r\n     *    @param [in] portName            The name of the port to get the direction for.\r\n     *    @param [in] mode                The mode to get the direction for.\r\n     *    @param [in] newSystemGroup      Used system group of the new bus interface.\r\n     *\r\n     *    @return The direction for the port in the given mode.\r\n     */\r\n    DirectionTypes::Direction getPortDirection(QString const& portName, General::InterfaceMode mode,\r\n        QString const& newSystemGroup) const;\r\n\r\n    /*!\r\n     *  Gets the initiative for a port in the selected interface mode.\r\n     *\r\n     *    @param [in] portName        Name of the selected port.\r\n     *    @param [in] mode            Interface mode for the selected port.\r\n     *    @param [in] systemGroup     The used system group.\r\n     *\r\n     *    @return Initiative for the port in the given mode.\r\n     */\r\n    QString getPortInitiative(QString const& portName, General::InterfaceMode mode, QString const& systemGroup)\r\n        const;\r\n\r\n    /*!\r\n     *  Gets a logical port with the given name.\r\n     *\r\n     *    @param [in] portName   The name of the port to get.\r\n     *\r\n     *    @return The port with the given name.\r\n     */\r\n    QSharedPointer<PortAbstraction> getPort(QString const& portName) const;\r\n\r\n    /*!\r\n     *  Gets the logical ports in the abstraction description.\r\n     *\r\n     *    @return The logical ports.\r\n     */\r\n    QSharedPointer<QList<QSharedPointer<PortAbstraction> > > getLogicalPorts() const;\r\n\r\n    QList<QSharedPointer<PortAbstraction> > getPortsWithWire() const;\r\n\r\n    QList<QSharedPointer<PortAbstraction> > getPortsWithTransactional() const;\r\n\r\n    /*!\r\n     *\tSets the choices of the abstraction definition.\r\n     *  \r\n     *    @param [in] choices\tDescription\r\n     */\r\n    void setChoices(QSharedPointer<QList<QSharedPointer<Choice> > > choices);\r\n\r\n    /*!\r\n     *  Gets the choices of the abstraction description.\r\n     *\r\n     *    @return The choices.\r\n     */\r\n    QSharedPointer<QList<QSharedPointer<Choice> > > getChoices() const;\r\n\r\nprivate:\r\n\r\n    //! Specifies the bus definition this abstraction definition details.\r\n    VLNV busType_;\r\n\r\n\t//! Specifies if this definition is an extension from another abstraction definition.\r\n\tVLNV extends_;\r\n\r\n    //! The logical ports defined in the abstraction definition.\r\n    QSharedPointer<QList<QSharedPointer<PortAbstraction> > > logicalPorts_ =\r\n        QSharedPointer<QList<QSharedPointer<PortAbstraction > > >(new QList<QSharedPointer<PortAbstraction> >);\r\n\r\n    //! The choices of the abstraction definition.\r\n    QSharedPointer<QList<QSharedPointer<Choice> > > choices_ =\r\n        QSharedPointer<QList<QSharedPointer<Choice> > >(new QList<QSharedPointer<Choice> >);\r\n};\r\n\r\n#endif // ABSTRACTIONDEFINITION_H\r\n"
  },
  {
    "path": "IPXACTmodels/AbstractionDefinition/AbstractionDefinitionReader.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: AbstractionDefinitionReader.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Esko Pekkarinen\r\n// Date: 14.08.2015\r\n//\r\n// Description:\r\n// Reader for ipxact:abstractionDefinition.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"AbstractionDefinitionReader.h\"\r\n\r\n#include \"AbstractionDefinition.h\"\r\n\r\n#include \"PortAbstraction.h\"\r\n#include \"WireAbstraction.h\"\r\n#include \"WireAbstractionReader.h\"\r\n#include \"TransactionalAbstractionReader.h\"\r\n#include \"PacketReader.h\"\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AbstractionDefinitionReader::createAbstractionDefinitionFrom()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<AbstractionDefinition> AbstractionDefinitionReader::createAbstractionDefinitionFrom(\r\n    QDomNode const& document)\r\n{\r\n    QDomNode definitionNode = document.firstChildElement(QStringLiteral(\"ipxact:abstractionDefinition\"));\r\n    Document::Revision docRevision = DocumentReader::getXMLDocumentRevision(definitionNode);\r\n\r\n    VLNV vlnv = CommonItemsReader::createVLNVFrom(definitionNode, VLNV::ABSTRACTIONDEFINITION);\r\n\r\n    QSharedPointer<AbstractionDefinition> abstractionDefinition(new AbstractionDefinition(vlnv, docRevision));\r\n\r\n    DocumentReader::parseTopComments(document, abstractionDefinition);\r\n\r\n    DocumentReader::parseXMLProcessingInstructions(document, abstractionDefinition);\r\n\r\n    DocumentReader::parseNamespaceDeclarations(definitionNode, abstractionDefinition);\r\n\r\n    DocumentReader::parseDocumentNameGroup(definitionNode, abstractionDefinition);\r\n\r\n    Details::parseBusType(definitionNode, abstractionDefinition);\r\n\r\n    Details::parseExtends(definitionNode, abstractionDefinition);\r\n\r\n    Details::parsePorts(definitionNode, abstractionDefinition, docRevision);\r\n    \r\n    Details::parseChoices(definitionNode, abstractionDefinition);\r\n\r\n    DocumentReader::parseParameters(definitionNode, abstractionDefinition);\r\n\r\n    DocumentReader::parseAssertions(definitionNode, abstractionDefinition);\r\n\r\n    DocumentReader::parseKactusAndVendorExtensions(definitionNode, abstractionDefinition);\r\n\r\n    return abstractionDefinition;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AbstractionDefinitionReader::Details::parseBusType()\r\n//-----------------------------------------------------------------------------\r\nvoid AbstractionDefinitionReader::Details::parseBusType(QDomNode const& definitionNode, \r\n    QSharedPointer<AbstractionDefinition> abstractionDefinion)\r\n{\r\n    QDomNode extendsNode = definitionNode.firstChildElement(QStringLiteral(\"ipxact:busType\"));\r\n    abstractionDefinion->setBusType(DocumentReader::parseVLNVAttributes(extendsNode, VLNV::BUSDEFINITION));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AbstractionDefinitionReader::Details::parseExtends()\r\n//-----------------------------------------------------------------------------\r\nvoid AbstractionDefinitionReader::Details::parseExtends(QDomNode const& definitionNode, \r\n    QSharedPointer<AbstractionDefinition> abstractionDefinion)\r\n{\r\n    QDomNode extendsNode = definitionNode.firstChildElement(QStringLiteral(\"ipxact:extends\"));\r\n    if (!extendsNode.isNull())\r\n    {\r\n        abstractionDefinion->setExtends(DocumentReader::parseVLNVAttributes(extendsNode, VLNV::ABSTRACTIONDEFINITION));\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AbstractionDefinitionReader::Details::parsePorts()\r\n//-----------------------------------------------------------------------------\r\nvoid AbstractionDefinitionReader::Details::parsePorts(QDomNode definitionNode, \r\n    QSharedPointer<AbstractionDefinition> abstractionDefinion, Document::Revision revision)\r\n{\r\n    QSharedPointer<QList<QSharedPointer<PortAbstraction> > > logicalPorts = abstractionDefinion->getLogicalPorts();\r\n\r\n    QDomNodeList portNodes = definitionNode.firstChildElement(\r\n        QStringLiteral(\"ipxact:ports\")).elementsByTagName(QStringLiteral(\"ipxact:port\"));\r\n    int portCount = portNodes.count();\r\n    for (int i = 0; i < portCount; i++)\r\n    {\r\n        QSharedPointer<PortAbstraction> port = parsePort(portNodes.at(i), revision);\r\n        logicalPorts->append(port);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AbstractionDefinitionReader::Details::parsePort()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<PortAbstraction> AbstractionDefinitionReader::Details::parsePort(QDomNode const& portNode,\r\n    Document::Revision revision)\r\n{\r\n    QSharedPointer<PortAbstraction> port(new PortAbstraction());\r\n\r\n    port->setLogicalName(portNode.firstChildElement(QStringLiteral(\"ipxact:logicalName\")).firstChild().nodeValue());\r\n    port->setDisplayName(portNode.firstChildElement(QStringLiteral(\"ipxact:displayName\")).firstChild().nodeValue());\r\n    port->setDescription(portNode.firstChildElement(QStringLiteral(\"ipxact:description\")).firstChild().nodeValue());\r\n\r\n    if (revision == Document::Revision::Std22)\r\n    {\r\n        port->setShortDescription(portNode.firstChildElement(QStringLiteral(\"ipxact:shortDescription\")).firstChild().nodeValue());\r\n        port->setMatch(portNode.firstChildElement(QStringLiteral(\"ipxact:match\")).firstChild().nodeValue() == QStringLiteral(\"true\"));\r\n        parsePackets(portNode, port);\r\n    }\r\n    else\r\n    {\r\n        port->setIsPresent(portNode.firstChildElement(QStringLiteral(\"ipxact:isPresent\")).firstChild().nodeValue());\r\n    }\r\n\r\n    parseWire(portNode, port, revision);\r\n    parseTransactional(portNode, port, revision);\r\n\r\n    CommonItemsReader::parseVendorExtensions(portNode, port);\r\n\r\n    return port;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AbstractionDefinitionReader::Details::parsePackets()\r\n//-----------------------------------------------------------------------------\r\nvoid AbstractionDefinitionReader::Details::parsePackets(QDomNode const& portNode, QSharedPointer<PortAbstraction> port)\r\n   \r\n{\r\n    auto packetsNode = portNode.firstChildElement(QStringLiteral(\"ipxact:packets\"));\r\n\r\n    if (packetsNode.isNull())\r\n    {\r\n        return;\r\n    }\r\n\r\n    QSharedPointer<QList<QSharedPointer<Packet> > > portPackets(new QList<QSharedPointer<Packet> >());\r\n\r\n    auto packetNodes = packetsNode.elementsByTagName(QStringLiteral(\"ipxact:packet\"));\r\n\r\n    for (int i = 0; i < packetNodes.count(); ++i)\r\n    {\r\n        auto packetNode = packetNodes.at(i);\r\n        auto packet = PacketReader::createPacketFrom(packetNode);\r\n\r\n        portPackets->append(packet);\r\n    }\r\n\r\n    port->setPackets(portPackets);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AbstractionDefinitionReader::Details::parseWire()\r\n//-----------------------------------------------------------------------------\r\nvoid AbstractionDefinitionReader::Details::parseWire(QDomNode const& portNode, QSharedPointer<PortAbstraction> port,\r\n    Document::Revision revision)\r\n{\r\n    QDomNode wireNode = portNode.firstChildElement(QStringLiteral(\"ipxact:wire\"));\r\n\r\n    if (!wireNode.isNull())\r\n    {\r\n        QSharedPointer<WireAbstraction> wire = WireAbstractionReader::createWireAbstractionFrom(wireNode, revision);\r\n\r\n        port->setWire(wire);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AbstractionDefinitionReader::Details::parseTransactional()\r\n//-----------------------------------------------------------------------------\r\nvoid AbstractionDefinitionReader::Details::parseTransactional(QDomNode const& portNode, \r\n    QSharedPointer<PortAbstraction> port, Document::Revision revision)\r\n{\r\n    QDomNode transactionalNode = portNode.firstChildElement(QStringLiteral(\"ipxact:transactional\"));\r\n\r\n    if (!transactionalNode.isNull())\r\n    {\r\n        QSharedPointer<TransactionalAbstraction> transactional =\r\n            TransactionalAbstractionReader::createTransactionalAbstractionFrom(transactionalNode, revision);\r\n\r\n        port->setTransactional(transactional);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AbstractionDefinitionReader::Details::parseChoices()\r\n//-----------------------------------------------------------------------------\r\nvoid AbstractionDefinitionReader::Details::parseChoices(QDomNode const& definitionNode,\r\n    QSharedPointer<AbstractionDefinition> definition)\r\n{\r\n    if (definition->getRevision() != Document::Revision::Std22)\r\n    {\r\n        return;\r\n    }\r\n\r\n    auto parsedChoices = CommonItemsReader::parseChoices(definitionNode);\r\n\r\n    definition->setChoices(parsedChoices);\r\n}\r\n"
  },
  {
    "path": "IPXACTmodels/AbstractionDefinition/AbstractionDefinitionReader.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: AbstractionDefinitionReader.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Esko Pekkarinen\r\n// Date: 14.08.2015\r\n//\r\n// Description:\r\n// Reader for ipxact:abstractionDefinition.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef ABSTRACTIONDEFINITIONREADER_H\r\n#define ABSTRACTIONDEFINITIONREADER_H\r\n\r\n#include <IPXACTmodels/common/DocumentReader.h>\r\n\r\n#include <IPXACTmodels/ipxactmodels_global.h>\r\n\r\n#include <QDomNode>\r\n#include <QSharedPointer>\r\n\r\nclass AbstractionDefinition;\r\nclass PortAbstraction;\r\nclass WireAbstraction;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Reader for ipxact:abstractionDefinition.\r\n//-----------------------------------------------------------------------------\r\nnamespace AbstractionDefinitionReader\r\n{\r\n    /*!\r\n     *  Creates an abstraction definition from XML description.\r\n     *\r\n     *    @param [in] document   The XML document to create the abstraction definition from.\r\n     *\r\n     *    @return The created abstraction definition.\r\n     */\r\n    IPXACTMODELS_EXPORT QSharedPointer<AbstractionDefinition> createAbstractionDefinitionFrom(QDomNode const& document);\r\n    \r\n    namespace Details\r\n    {\r\n        /*!\r\n         *  Reads the bus type from XML to an abstraction definition.\r\n         *\r\n         *    @param [in]     definitionNode  The XML description of the abstraction definition.\r\n         *    @param [in/out] busDefinition   The abstraction definition to insert the extends property into.\r\n         */\r\n        void parseBusType(QDomNode const& definitionNode,\r\n            QSharedPointer<AbstractionDefinition> abstractionDefinion);\r\n                        \r\n        /*!\r\n         *  Reads the extends property from XML to an abstraction definition.\r\n         *\r\n         *    @param [in]     definitionNode          The XML description of the abstraction definition.\r\n         *    @param [in/out] abstractionDefinion     The abstraction definition to insert the extends property into.\r\n         */\r\n        void parseExtends(QDomNode const& definitionNode,\r\n            QSharedPointer<AbstractionDefinition> abstractionDefinion);\r\n                            \r\n        /*!\r\n         *  Reads the logical ports from XML to an abstraction definition.\r\n         *\r\n         *    @param [in]     definitionNode          The XML description of the abstraction definition.\r\n         *    @param [in/out] abstractionDefinion     The abstraction definition to insert the ports into.\r\n         */\r\n        void parsePorts(QDomNode definitionNode, QSharedPointer<AbstractionDefinition> abstractionDefinion,\r\n            Document::Revision revision);\r\n                                \r\n        /*!\r\n         *  Read a logical ports from XML to an abstraction definition.\r\n         *\r\n         *    @param [in]     portNode    The XML description of the logical port.\r\n         *\r\n         *    @return The read logical port.\r\n         */\r\n        QSharedPointer<PortAbstraction> parsePort(QDomNode const& portNode, Document::Revision revision);\r\n    \r\n        /*!\r\n         *\tReads port packets from XML.\r\n         *  \r\n         *    @param [in] portNode\tThe XML description of the logical port.\r\n         *    @param [in/out] port\tThe logical port definition to insert the packets into.\r\n         */\r\n        void parsePackets(QDomNode const& portNode, QSharedPointer<PortAbstraction> port);\r\n\r\n        /*!\r\n         *  Reads the wire description from XML to a logical port definition.\r\n         *\r\n         *    @param [in]     portNode    The XML description of the logical port.\r\n         *    @param [in/out] port        The logical port definition to insert the wire into.\r\n         */\r\n        void parseWire(QDomNode const& portNode, QSharedPointer<PortAbstraction> port, Document::Revision revision);\r\n    \r\n        /*!\r\n         *  Reads the transactional description from XML to a logical port definition.\r\n         *\r\n         *    @param [in]     portNode    The XML description of the logical port.\r\n         *    @param [in/out] port        The logical port definition to insert the transactional into.\r\n         */\r\n        void parseTransactional(QDomNode const& portNode, QSharedPointer<PortAbstraction> port, \r\n            Document::Revision revision);\r\n\r\n        void parseChoices(QDomNode const& definitionNode, QSharedPointer<AbstractionDefinition> definition);\r\n    }\r\n}\r\n\r\n#endif // ABSTRACTIONDEFINITIONREADER_H"
  },
  {
    "path": "IPXACTmodels/AbstractionDefinition/AbstractionDefinitionWriter.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: AbstractionDefinitionWriter.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Esko Pekkarinen\r\n// Date: 10.08.2015\r\n//\r\n// Description:\r\n// Writer for IP-XACT AbstractionDefinition element.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"AbstractionDefinitionWriter.h\"\r\n\r\n#include <IPXACTmodels/AbstractionDefinition/AbstractionDefinition.h>\r\n#include <IPXACTmodels/AbstractionDefinition/PortAbstraction.h>\r\n#include <IPXACTmodels/AbstractionDefinition/TransactionalAbstraction.h>\r\n#include <IPXACTmodels/AbstractionDefinition/TransactionalAbstractionWriter.h>\r\n#include <IPXACTmodels/AbstractionDefinition/WireAbstractionWriter.h>\r\n#include <IPXACTmodels/AbstractionDefinition/PacketWriter.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AbstractionDefinitionWriter::writeAbstractionDefinition()\r\n//-----------------------------------------------------------------------------\r\nvoid AbstractionDefinitionWriter::writeAbstractionDefinition(QXmlStreamWriter& writer, \r\n    QSharedPointer<AbstractionDefinition> abstractionDefinition)\r\n{\r\n    writer.writeStartDocument();\r\n    \r\n    DocumentWriter::writeTopComments(writer, abstractionDefinition);\r\n\r\n    DocumentWriter::writeXmlProcessingInstructions(writer, abstractionDefinition);\r\n\r\n    writer.writeStartElement(QStringLiteral(\"ipxact:abstractionDefinition\"));\r\n    DocumentWriter::writeNamespaceDeclarations(writer, abstractionDefinition);\r\n\r\n    DocumentWriter::writeDocumentNameGroup(writer, abstractionDefinition);\r\n\r\n    Details::writeBusType(writer, abstractionDefinition);\r\n\r\n    Details::writeExtends(writer, abstractionDefinition);\r\n\r\n    Details::writePorts(writer, abstractionDefinition);\r\n\r\n    Details::writeDescription(writer, abstractionDefinition);\r\n\r\n    Details::writeChoices(writer, abstractionDefinition);\r\n\r\n    DocumentWriter::writeParameters(writer, abstractionDefinition);\r\n\r\n    DocumentWriter::writeAssertions(writer, abstractionDefinition);\r\n\r\n    CommonItemsWriter::writeVendorExtensions(writer, abstractionDefinition);\r\n\r\n    writer.writeEndElement(); // \"ipxact:abstractionDefinition\"\r\n    writer.writeEndDocument();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AbstractionDefinitionWriter::Details::writeBusType()\r\n//-----------------------------------------------------------------------------\r\nvoid AbstractionDefinitionWriter::Details::writeBusType(QXmlStreamWriter& writer,\r\n    QSharedPointer<AbstractionDefinition> abstractionDefinition)\r\n{\r\n        writer.writeStartElement(QStringLiteral(\"ipxact:busType\"));\r\n        CommonItemsWriter::writeVLNVAttributes(writer, abstractionDefinition->getBusType());\r\n        writer.writeEndElement();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AbstractionDefinitionWriter::Details::writeExtends()\r\n//-----------------------------------------------------------------------------\r\nvoid AbstractionDefinitionWriter::Details::writeExtends(QXmlStreamWriter& writer,\r\n    QSharedPointer<AbstractionDefinition> abstractionDefinition)\r\n{\r\n    if (!abstractionDefinition->getExtends().isEmpty())\r\n    {\r\n        writer.writeStartElement(QStringLiteral(\"ipxact:extends\"));\r\n        CommonItemsWriter::writeVLNVAttributes(writer, abstractionDefinition->getExtends());\r\n        writer.writeEndElement();\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AbstractionDefinitionWriter::Details::writePorts()\r\n//-----------------------------------------------------------------------------\r\nvoid AbstractionDefinitionWriter::Details::writePorts(QXmlStreamWriter& writer, \r\n    QSharedPointer<AbstractionDefinition> abstractionDefinition)\r\n{\r\n    QList<QSharedPointer<PortAbstraction> > logicalPorts = *abstractionDefinition->getLogicalPorts(); \r\n    if (!logicalPorts.isEmpty())\r\n    {\r\n        writer.writeStartElement(QStringLiteral(\"ipxact:ports\"));\r\n        for (auto logicalPort : logicalPorts)\r\n        {\r\n            writePort(writer, logicalPort, abstractionDefinition->getRevision());\r\n        }\r\n        writer.writeEndElement();\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AbstractionDefinitionWriter::Details::writePort()\r\n//-----------------------------------------------------------------------------\r\nvoid AbstractionDefinitionWriter::Details::writePort(QXmlStreamWriter& writer,\r\n    QSharedPointer<PortAbstraction> logicalPort, Document::Revision revision)\r\n{\r\n    writer.writeStartElement(QStringLiteral(\"ipxact:port\"));\r\n\r\n    CommonItemsWriter::writeNonEmptyElement(writer, QStringLiteral(\"ipxact:isPresent\"), logicalPort->isPresent());\r\n\r\n    writer.writeTextElement(QStringLiteral(\"ipxact:logicalName\"), logicalPort->name());\r\n\r\n    CommonItemsWriter::writeNonEmptyElement(writer, QStringLiteral(\"ipxact:displayName\"), logicalPort->displayName());\r\n    CommonItemsWriter::writeNonEmptyElement(writer, QStringLiteral(\"ipxact:shortDescription\"), logicalPort->shortDescription());\r\n    CommonItemsWriter::writeNonEmptyElement(writer, QStringLiteral(\"ipxact:description\"), logicalPort->description());\r\n\r\n    if (logicalPort->getMatch())\r\n    {\r\n        writer.writeTextElement(QStringLiteral(\"ipxact:match\"), QStringLiteral(\"true\"));\r\n    }\r\n\r\n    writeWire(writer, logicalPort, revision);\r\n\r\n    writeTransactional(writer, logicalPort, revision);\r\n\r\n    writePackets(writer, logicalPort);\r\n\r\n    CommonItemsWriter::writeVendorExtensions(writer, logicalPort);\r\n\r\n    writer.writeEndElement();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AbstractionDefinitionWriter::Details::writeWire()\r\n//-----------------------------------------------------------------------------\r\nvoid AbstractionDefinitionWriter::Details::writeWire(QXmlStreamWriter& writer, \r\n    QSharedPointer<PortAbstraction> logicalPort, Document::Revision revision)\r\n{\r\n    if (logicalPort->hasWire())\r\n    {\r\n        WireAbstractionWriter::writeWire(writer, logicalPort->getWire(), revision);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AbstractionDefinitionWriter::Details::writeTransactional()\r\n//-----------------------------------------------------------------------------\r\nvoid AbstractionDefinitionWriter::Details::writeTransactional(QXmlStreamWriter& writer,\r\n    QSharedPointer<PortAbstraction> logicalPort, Document::Revision revision)\r\n{\r\n    if (logicalPort->hasTransactional())\r\n    {\r\n        TransactionalAbstractionWriter::writeTransactional(writer, logicalPort->getTransactional(), revision);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AbstractionDefinitionWriter::Details::writePackets()\r\n//-----------------------------------------------------------------------------\r\nvoid AbstractionDefinitionWriter::Details::writePackets(QXmlStreamWriter& writer,\r\n    QSharedPointer<PortAbstraction> logicalPort)\r\n{\r\n    auto packets = logicalPort->getPackets();\r\n\r\n    if (packets->isEmpty())\r\n    {\r\n        return;\r\n    }\r\n\r\n    writer.writeStartElement(QStringLiteral(\"ipxact:packets\"));\r\n\r\n    for (auto const& packet : *packets)\r\n    {\r\n        PacketWriter::writePacket(writer, packet);\r\n    }\r\n\r\n    writer.writeEndElement();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AbstractionDefinitionWriter::Details::writeDescription()\r\n//-----------------------------------------------------------------------------\r\nvoid AbstractionDefinitionWriter::Details::writeDescription(QXmlStreamWriter& writer, QSharedPointer<AbstractionDefinition> abstractionDefinition)\r\n{\r\n    if (abstractionDefinition->getRevision() == Document::Revision::Std22)\r\n    {\r\n        return;\r\n    }\r\n\r\n    CommonItemsWriter::writeDescription(writer, abstractionDefinition->getDescription());\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AbstractionDefinitionWriter::Details::writeChoices()\r\n//-----------------------------------------------------------------------------\r\nvoid AbstractionDefinitionWriter::Details::writeChoices(QXmlStreamWriter& writer, QSharedPointer<AbstractionDefinition> abstractionDefinition)\r\n{\r\n    if (abstractionDefinition->getRevision() != Document::Revision::Std22)\r\n    {\r\n        return;\r\n    }\r\n\r\n    CommonItemsWriter::writeChoices(writer, abstractionDefinition->getChoices());\r\n}\r\n"
  },
  {
    "path": "IPXACTmodels/AbstractionDefinition/AbstractionDefinitionWriter.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: AbstractionDefinitionWriter.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Esko Pekkarinen\r\n// Date: 10.08.2015\r\n//\r\n// Description:\r\n// Writer for IP-XACT AbstractionDefinition element.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef ABSTRACTIONDEFINITIONWRITER_H\r\n#define ABSTRACTIONDEFINITIONWRITER_H\r\n\r\n\r\n#include <IPXACTmodels/common/ParameterWriter.h>\r\n#include <IPXACTmodels/common/DocumentWriter.h>\r\n#include <IPXACTmodels/AbstractionDefinition/AbstractionDefinition.h>\r\n\r\n#include <IPXACTmodels/ipxactmodels_global.h>\r\n\r\n#include <QSharedPointer>\r\n#include <QXmlStreamWriter>\r\n\r\nclass AbstractionDefinition;\r\nclass PortAbstraction;\r\nclass VLNV;\r\nclass WirePort;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Writer for IP-XACT AbstractionDefinition element.\r\n//-----------------------------------------------------------------------------\r\nnamespace AbstractionDefinitionWriter\r\n{    \r\n    /*!\r\n     *  Writes the given abstraction definition into XML.\r\n     *\r\n     *    @param [in] writer                  The XML writer to use.\r\n     *    @param [in] abstractionDefinition   The abstraction definition to write.\r\n     */\r\n    IPXACTMODELS_EXPORT void writeAbstractionDefinition(QXmlStreamWriter& writer, \r\n        QSharedPointer<AbstractionDefinition> abstractionDefinition);\r\n\r\n    namespace Details\r\n    {\r\n        /*!\r\n         *  Writes the bus type (VLNV) detailed in the given abstraction definition into XML.\r\n         *\r\n         *    @param [in] writer                  The XML writer to use.\r\n         *    @param [in] abstractionDefinition   The abstraction definition whose bus type to write.\r\n         */\r\n        void writeBusType(QXmlStreamWriter& writer, QSharedPointer<AbstractionDefinition> abstractionDefinition);\r\n       \r\n        /*!\r\n         *  Writes the abstraction definition (VLNV) extended in the given abstraction definition into XML.\r\n         *\r\n         *    @param [in] writer                  The XML writer to use.\r\n         *    @param [in] abstractionDefinition   The abstraction definition whose extended VLVN to write.\r\n         */\r\n        void writeExtends(QXmlStreamWriter& writer, QSharedPointer<AbstractionDefinition> busDefinition);\r\n        \r\n        /*!\r\n         *  Writes the port definitions in the given abstraction definition into XML.\r\n         *\r\n         *    @param [in] writer                  The XML writer to use.\r\n         *    @param [in] abstractionDefinition   The abstraction definition whose ports to write.\r\n         */\r\n        void writePorts(QXmlStreamWriter& writer, QSharedPointer<AbstractionDefinition> abstractionDefinition);\r\n\r\n        /*!\r\n         *  Writes a port definitions into XML.\r\n         *\r\n         *    @param [in] writer          The XML writer to use.\r\n         *    @param [in] logicalPort     The port to write.\r\n         */\r\n        void writePort(QXmlStreamWriter& writer, QSharedPointer<PortAbstraction> logicalPort, \r\n            Document::Revision revision);\r\n    \r\n        /*!\r\n         *  Writes the wire definition in a port definitions into XML.\r\n         *\r\n         *    @param [in] writer          The XML writer to use.\r\n         *    @param [in] logicalPort     The port whose wire definition to write.\r\n         */\r\n        void writeWire(QXmlStreamWriter& writer, QSharedPointer<PortAbstraction> logicalPort,\r\n            Document::Revision revision);\r\n        \r\n        /*!\r\n         *  Writes the transactional definition in a port definitions into XML.\r\n         *\r\n         *    @param [in] writer          The XML writer to use.\r\n         *    @param [in] logicalPort     The port whose transactional definition to write.\r\n         */\r\n        void writeTransactional(QXmlStreamWriter& writer, QSharedPointer<PortAbstraction> logicalPort,\r\n            Document::Revision revision);\r\n\r\n        void writePackets(QXmlStreamWriter& writer, QSharedPointer<PortAbstraction> logicalPort);\r\n\r\n        void writeDescription(QXmlStreamWriter& writer,\r\n            QSharedPointer<AbstractionDefinition> abstractionDefinition);\r\n\r\n        void writeChoices(QXmlStreamWriter& writer, QSharedPointer<AbstractionDefinition> abstractionDefinition);\r\n    }\r\n};    \r\n\r\n#endif // ABSTRACTIONDEFINITIONWRITER_H"
  },
  {
    "path": "IPXACTmodels/AbstractionDefinition/Packet.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: Packet.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Anton Hagqvist\n// Date: 25.05.2023\n//\n// Description:\n// Implementation for ipxact:packet element within abstraction definition.\n//-----------------------------------------------------------------------------\n\n#include \"Packet.h\"\n\n#include <IPXACTmodels/utilities/Copy.h>\n\n//-----------------------------------------------------------------------------\n// Function: Packet::Packet()\n//-----------------------------------------------------------------------------\nPacket::Packet(QString const& name):\nNameGroup(name),\nExtendable()\n{\n}\n\n//-----------------------------------------------------------------------------\n// Function: Packet::Packet()\n//-----------------------------------------------------------------------------\nPacket::Packet(Packet const& other) :\n    NameGroup(other),\n    Extendable(other),\n    endianness_(other.endianness_)\n{\n    Copy::copyList(other.packetFields_, packetFields_);\n}\n\n//-----------------------------------------------------------------------------\n// Function: Packet::operator=()\n//-----------------------------------------------------------------------------\nPacket& Packet::operator=(Packet const& other)\n{\n    if (this != &other)\n    {\n        NameGroup::operator=(other);\n        Extendable::operator=(other);\n        endianness_ = other.endianness_;\n\n        packetFields_->clear();\n        Copy::copyList(other.packetFields_, packetFields_);\n    }\n\n    return *this;\n}\n\n//-----------------------------------------------------------------------------\n// Function: Packet::getEndianness()\n//-----------------------------------------------------------------------------\nQString Packet::getEndianness() const\n{\n    return endianness_;\n}\n\n//-----------------------------------------------------------------------------\n// Function: Packet::setEndianness()\n//-----------------------------------------------------------------------------\nvoid Packet::setEndianness(QString const& endianness)\n{\n    endianness_ = endianness;\n}\n\n//-----------------------------------------------------------------------------\n// Function: Packet::getPacketFields()\n//-----------------------------------------------------------------------------\nQSharedPointer<QList<QSharedPointer<PacketField> > > Packet::getPacketFields() const\n{\n    return packetFields_;\n}\n\n//-----------------------------------------------------------------------------\n// Function: Packet::setPacketFields()\n//-----------------------------------------------------------------------------\nvoid Packet::setPacketFields(QSharedPointer<QList<QSharedPointer<PacketField>>> packetFields)\n{\n    packetFields_ = packetFields;\n}\n"
  },
  {
    "path": "IPXACTmodels/AbstractionDefinition/Packet.h",
    "content": "//-----------------------------------------------------------------------------\n// File: Packet.h\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Anton Hagqvist\n// Date: 25.05.2023\n//\n// Description:\n// Implementation for ipxact:packet element within abstraction definition.\n//-----------------------------------------------------------------------------\n\n#ifndef PACKET_H\n#define PACKET_H\n\n#include \"PacketField.h\"\n\n#include <IPXACTmodels/common/Extendable.h>\n#include <IPXACTmodels/common/NameGroup.h>\n\n#include <QString>\n#include <QList>\n#include <QSharedPointer>\n\n//-----------------------------------------------------------------------------\n//! Implementation for ipxact:packet element within abstraction definition.\n//-----------------------------------------------------------------------------\nclass IPXACTMODELS_EXPORT Packet : public NameGroup, public Extendable\n{\npublic:\n\n\tPacket(QString const& name = QString());\n\n\tPacket(Packet const& other);\n\tPacket& operator=(Packet const& other);\n\n\t~Packet() = default;\n\n\t/*!\n\t *  Get the packet endianness.\n\t *\n\t *    @return The packet endianness.\n\t */\n\tQString getEndianness() const;\n\n\t/*!\n\t *  Set the packet endianness.\n\t *\n\t *    @param [in] endianness\tThe new packet endianness.\n\t */\n\tvoid setEndianness(QString const& endianness);\n\n\t/*!\n\t *  Get the packet fields.\n\t *\n\t *    @return The packet fields.\n\t */\n\tQSharedPointer<QList<QSharedPointer<PacketField> > > getPacketFields() const;\n\n\t/*!\n\t *  Set the packet fields.\n\t *\n\t *    @param [in] packetFields\tThe new packet fields.\n\t */\n\tvoid setPacketFields(QSharedPointer<QList<QSharedPointer<PacketField> > > packetFields);\n\nprivate:\n\n\t//! The packet endianness.\n\tQString endianness_;\n\n\t//! The packet fields.\n\tQSharedPointer<QList<QSharedPointer<PacketField> > > packetFields_ =\n\t\tQSharedPointer<QList<QSharedPointer<PacketField> > >(new QList<QSharedPointer<PacketField> >());\n};\n\n#endif // PACKET_H\n\n"
  },
  {
    "path": "IPXACTmodels/AbstractionDefinition/PacketField.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: PacketField.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Anton Hagqvist\n// Date: 25.05.2023\n//\n// Description:\n// Implementation for ipxact:packetField element within abstraction definition.\n//-----------------------------------------------------------------------------\n\n#include \"PacketField.h\"\n\n//-----------------------------------------------------------------------------\n// Function: PacketField::PacketField()\n//-----------------------------------------------------------------------------\nPacketField::PacketField(QString const& name):\nNameGroup(name),\nExtendable()\n{\n}\n\n//-----------------------------------------------------------------------------\n// Function: PacketField::PacketField()\n//-----------------------------------------------------------------------------\nPacketField::PacketField(PacketField const& other) :\n    NameGroup(other),\n    Extendable(other),\n    width_(other.width_),\n    value_(other.value_),\n    endianness_(other.endianness_),\n    qualifier_(new Qualifier(*other.qualifier_))\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: PacketField::operator==()\n//-----------------------------------------------------------------------------\nPacketField& PacketField::operator==(PacketField const& other)\n{\n    if (this != &other)\n    {\n        NameGroup::operator=(other);\n        Extendable::operator=(other);\n        width_ = other.width_;\n        value_ = other.value_;\n        endianness_ = other.endianness_;\n\n        if (other.qualifier_)\n        {\n            qualifier_ = QSharedPointer<Qualifier>(new Qualifier(*other.qualifier_));\n        }\n    }\n\n    return *this;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PacketField::getWidth()\n//-----------------------------------------------------------------------------\nQString PacketField::getWidth() const\n{\n    return width_;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PacketField::setWidth()\n//-----------------------------------------------------------------------------\nvoid PacketField::setWidth(QString const& width)\n{\n    width_ = width;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PacketField::getValue()\n//-----------------------------------------------------------------------------\nQString PacketField::getValue() const\n{\n    return value_;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PacketField::setValue()\n//-----------------------------------------------------------------------------\nvoid PacketField::setValue(QString const& value)\n{\n    value_ = value;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PacketField::getEndianness()\n//-----------------------------------------------------------------------------\nQString PacketField::getEndianness() const\n{\n    return endianness_;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PacketField::setEndianness()\n//-----------------------------------------------------------------------------\nvoid PacketField::setEndianness(QString const& endianness)\n{\n    endianness_ = endianness;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PacketField::getQualifier()\n//-----------------------------------------------------------------------------\nQSharedPointer<Qualifier> PacketField::getQualifier() const\n{\n    return qualifier_;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PacketField::setQualifier()\n//-----------------------------------------------------------------------------\nvoid PacketField::setQualifier(QSharedPointer<Qualifier> const& qualifier)\n{\n    qualifier_ = qualifier;\n}\n"
  },
  {
    "path": "IPXACTmodels/AbstractionDefinition/PacketField.h",
    "content": "//-----------------------------------------------------------------------------\n// File: PacketField.h\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Anton Hagqvist\n// Date: 25.05.2023\n//\n// Description:\n// Implementation for ipxact:packetField element within abstraction definition.\n//-----------------------------------------------------------------------------\n\n#ifndef PACKETFIELD_H\n#define PACKETFIELD_H\n\n#include <IPXACTmodels/common/Extendable.h>\n#include <IPXACTmodels/common/NameGroup.h>\n#include <IPXACTmodels/common/Qualifier.h>\n\n#include <QString>\n#include <QSharedPointer>\n\n//-----------------------------------------------------------------------------\n//! Implementation for ipxact:packetField element within abstraction definition.\n//-----------------------------------------------------------------------------\nclass IPXACTMODELS_EXPORT PacketField : public NameGroup, public Extendable\n{\npublic:\n\n    PacketField(QString const& name = QString());\n\n    PacketField(PacketField const& other);\n    PacketField& operator==(PacketField const& other);\n\n    ~PacketField() = default;\n    \n    /*!\n     *\tGets the packet field width.\n     *\t\t\n     * \t\t@return The packet field width in bits.\n     */\n    QString getWidth() const;\n\n    /*!\n     *\tSets the packet field width.\n     *  \n     *    @param [in] width\tThe packet field width in bits.\n     */\n    void setWidth(QString const& width);\n\n    /*!\n     *  Get the packet field value.\n     *\n     *    @return The packet field value.\n     */\n    QString getValue() const;\n\n    /*!\n     *  Set the packet field value.\n     *\n     *    @param [in] value   The new packet field value.\n     */\n    void setValue(QString const& value);\n\n    /*!\n     *  Get the packet field endianness.\n     *\n     *    @return The packet field endianness.\n     */\n    QString getEndianness() const;\n    \n    /*!\n     *  Set the packet field endianness.\n     *\n     *    @param [in] endianness  The new packet field endianness.\n     */\n    void setEndianness(QString const& endianness);\n    \n    /*!\n     *  Get the packet field qualifier.\n     *\n     *    @return The packet field qualifier.\n     */\n    QSharedPointer<Qualifier> getQualifier() const;\n    \n    /*!\n     *  Set the packet field qualifier.\n     *\n     *    @param [in] qualifier   The new packet field qualifier.\n     */\n    void setQualifier(QSharedPointer<Qualifier> const& qualifier);\n\nprivate:\n\n    //! The packet field width in bits.\n    QString width_;\n\n    //! The packet field value.\n    QString value_;\n\n    //! The packet field endianness.\n    QString endianness_;\n\n    //! The packet field qualifier.\n    QSharedPointer<Qualifier> qualifier_;\n\n};\n\n#endif // PACKETFIELD_H\n\n"
  },
  {
    "path": "IPXACTmodels/AbstractionDefinition/PacketReader.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: PacketReader.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Anton Hagqvist\n// Date: 30.05.2023\n//\n// Description:\n// Reader for ipxact:packet within a port of an abstraction definition.\n//-----------------------------------------------------------------------------\n\n#include \"PacketReader.h\"\n\n#include <IPXACTmodels/common/CommonItemsReader.h>\n#include <IPXACTmodels/common/QualifierReader.h>\n\n//-----------------------------------------------------------------------------\n// Function: PacketReader::createPacketFrom()\n//-----------------------------------------------------------------------------\nQSharedPointer<Packet> PacketReader::createPacketFrom(QDomNode const& packetNode)\n{\n    QSharedPointer<Packet> packet(new Packet);\n\n    Details::parseNameGroup(packetNode, packet);\n    \n    packet->setEndianness(packetNode.firstChildElement(QStringLiteral(\"ipxact:endianness\")).firstChild().nodeValue());\n\n    Details::parsePacketFields(packetNode, packet);\n\n    CommonItemsReader::parseVendorExtensions(packetNode, packet);\n\n    return packet;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PacketReader::Details::parseNameGroup()\n//-----------------------------------------------------------------------------\nvoid PacketReader::Details::parseNameGroup(QDomNode const& packetNode, QSharedPointer<Packet> packet)\n{\n    packet->setName(packetNode.firstChildElement(QStringLiteral(\"ipxact:name\")).firstChild().nodeValue());\n    packet->setDisplayName(packetNode.firstChildElement(QStringLiteral(\"ipxact:displayName\")).firstChild().nodeValue());\n    packet->setShortDescription(packetNode.firstChildElement(QStringLiteral(\"ipxact:shortDescription\")).firstChild().nodeValue());\n    packet->setDescription(packetNode.firstChildElement(QStringLiteral(\"ipxact:description\")).firstChild().nodeValue());\n}\n\n//-----------------------------------------------------------------------------\n// Function: PacketReader::Details::parsePacketFields()\n//-----------------------------------------------------------------------------\nvoid PacketReader::Details::parsePacketFields(QDomNode const& packetNode, QSharedPointer<Packet> packet)\n{\n    auto packetFields = packetNode.firstChildElement(QStringLiteral(\"ipxact:packetFields\"))\n        .elementsByTagName(QStringLiteral(\"ipxact:packetField\"));\n\n    QSharedPointer<QList<QSharedPointer<PacketField> > > packetPacketFields(\n        new QList<QSharedPointer<PacketField> >());\n\n    for (int i = 0; i < packetFields.count(); ++i)\n    {\n        auto fieldNode = packetFields.at(i);\n        \n        parseSinglePacketField(fieldNode, packetPacketFields);\n    }\n\n    packet->setPacketFields(packetPacketFields);\n}\n\n//-----------------------------------------------------------------------------\n// Function: PacketReader::Details::parseSinglePacketField()\n//-----------------------------------------------------------------------------\nvoid PacketReader::Details::parseSinglePacketField(QDomNode const& fieldNode, QSharedPointer<QList<QSharedPointer<PacketField> > > packetFields)\n{\n    QSharedPointer<PacketField> parsedPacketField(new PacketField());\n\n    parsedPacketField->setName(fieldNode.firstChildElement(QStringLiteral(\"ipxact:name\")).firstChild().nodeValue());\n    parsedPacketField->setDisplayName(\n        fieldNode.firstChildElement(QStringLiteral(\"ipxact:displayName\")).firstChild().nodeValue());\n    parsedPacketField->setShortDescription(\n        fieldNode.firstChildElement(QStringLiteral(\"ipxact:shortDescription\")).firstChild().nodeValue());\n    parsedPacketField->setDescription(\n        fieldNode.firstChildElement(QStringLiteral(\"ipxact:description\")).firstChild().nodeValue());\n    parsedPacketField->setWidth(\n        fieldNode.firstChildElement(QStringLiteral(\"ipxact:width\")).firstChild().nodeValue());\n    parsedPacketField->setValue(\n        fieldNode.firstChildElement(QStringLiteral(\"ipxact:value\")).firstChild().nodeValue());\n    parsedPacketField->setEndianness(\n        fieldNode.firstChildElement(QStringLiteral(\"ipxact:endianness\")).firstChild().nodeValue());\n\n    QSharedPointer<Qualifier> fieldQualifier(new Qualifier());\n    QualifierReader::parseQualifier(\n        fieldNode.firstChildElement(QStringLiteral(\"ipxact:qualifier\")), fieldQualifier, Document::Revision::Std22);\n\n    parsedPacketField->setQualifier(fieldQualifier);\n\n    CommonItemsReader::parseVendorExtensions(fieldNode, parsedPacketField);\n\n    packetFields->append(parsedPacketField);\n}\n"
  },
  {
    "path": "IPXACTmodels/AbstractionDefinition/PacketReader.h",
    "content": "//-----------------------------------------------------------------------------\n// File: PacketReader.h\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Anton Hagqvist\n// Date: 30.05.2023\n//\n// Description:\n// Reader for ipxact:packet within a port of an abstraction definition.\n//-----------------------------------------------------------------------------\n\n#ifndef PACKETREADER_H\n#define PACKETREADER_H\n\n#include \"PacketField.h\"\n#include \"Packet.h\"\n\n#include <QString>\n#include <QList>\n#include <QSharedPointer>\n#include <QDomNode>\n\n//-----------------------------------------------------------------------------\n//! Reader for ipxact:packet within ports of an abstraction definition.\n//-----------------------------------------------------------------------------\nnamespace PacketReader\n{\n    /*!\n     *  Creates a packet from XML description.\n     *\n     *    @param [in] packetNode      The XML document node to create the packet from.\n     *\n     *    @return The created packet.\n     */\n    QSharedPointer<Packet> createPacketFrom(QDomNode const& packetNode);\n\n    namespace Details\n    {\n        /*!\n         *  Parse the packet name group.\n         *\n         *    @param [in] packetNode      The XML document node of the packet.\n         *    @param [in/out] packet      The packet definition to write to.\n         */\n        void parseNameGroup(QDomNode const& packetNode, QSharedPointer<Packet> packet);\n\n        /*!\n         *  Parse the packet fields of the packet.\n         *\n         *    @param [in] packetNode      The XML document node of the packet.\n         *    @param [in/out] packet      The packet definition to inserts packet fields into.\n         */\n        void parsePacketFields(QDomNode const& packetNode, QSharedPointer<Packet> packet);\n\n        /*!\n         *\tParse a single packet field.\n         *  \n        *    @param [in] fieldNode\t        The XML description of the packet field.\n         *    @param [in/out] packetFields\tThe list of packet field definitions.\n         */\n        void parseSinglePacketField(QDomNode const& fieldNode,\n            QSharedPointer<QList<QSharedPointer<PacketField> > > packetFields);\n    }\n}\n\n#endif // PACKETREADER_H\n\n"
  },
  {
    "path": "IPXACTmodels/AbstractionDefinition/PacketWriter.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: PacketWriter.h\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Anton Hagqvist\n// Date: 01.06.2023\n//\n// Description:\n// Writer for ipxact:packet within a port of an abstraction definition.\n//-----------------------------------------------------------------------------\n\n#include \"PacketWriter.h\"\n\n#include <IPXACTmodels/common/NameGroupWriter.h>\n#include <IPXACTmodels/common/CommonItemsWriter.h>\n#include <IPXACTmodels/common/QualifierWriter.h>\n\n//-----------------------------------------------------------------------------\n// Function: PacketWriter::writePacket()\n//-----------------------------------------------------------------------------\nvoid PacketWriter::writePacket(QXmlStreamWriter& writer, QSharedPointer<Packet> packet)\n{\n    writer.writeStartElement(QStringLiteral(\"ipxact:packet\"));\n\n    NameGroupWriter::writeNameGroup(writer, packet, Document::Revision::Std22);\n\n    CommonItemsWriter::writeNonEmptyElement(writer, QStringLiteral(\"ipxact:endianness\"), packet->getEndianness());\n\n    Details::writePacketFields(writer, packet);\n\n    CommonItemsWriter::writeVendorExtensions(writer, packet);\n\n    writer.writeEndElement();\n}\n\n//-----------------------------------------------------------------------------\n// Function: PacketWriter::Details::writePacketFields()\n//-----------------------------------------------------------------------------\nvoid PacketWriter::Details::writePacketFields(QXmlStreamWriter& writer, QSharedPointer<Packet> packet)\n{\n    auto packetFields = packet->getPacketFields();\n\n    if (packetFields->isEmpty())\n    {\n        return;\n    }\n\n    writer.writeStartElement(QStringLiteral(\"ipxact:packetFields\"));\n\n    for (auto const& packetField : *packetFields)\n    {\n        Details::writeSinglePacketField(writer, packetField);\n    }\n\n    writer.writeEndElement();\n}\n\n//-----------------------------------------------------------------------------\n// Function: PacketWriter::Details::writeSinglePacketField()\n//-----------------------------------------------------------------------------\nvoid PacketWriter::Details::writeSinglePacketField(QXmlStreamWriter& writer, QSharedPointer<PacketField> packetField)\n{\n    writer.writeStartElement(QStringLiteral(\"ipxact:packetField\"));\n\n    NameGroupWriter::writeNameGroup(writer, packetField, Document::Revision::Std22);\n\n    CommonItemsWriter::writeNonEmptyElement(writer, QStringLiteral(\"ipxact:width\"), packetField->getWidth());\n    CommonItemsWriter::writeNonEmptyElement(writer, QStringLiteral(\"ipxact:value\"), packetField->getValue());\n    CommonItemsWriter::writeNonEmptyElement(writer, QStringLiteral(\"ipxact:endianness\"), packetField->getEndianness());\n\n    QualifierWriter::writeQualifier(writer, packetField->getQualifier());\n\n    CommonItemsWriter::writeVendorExtensions(writer, packetField);\n\n    writer.writeEndElement();\n}\n"
  },
  {
    "path": "IPXACTmodels/AbstractionDefinition/PacketWriter.h",
    "content": "//-----------------------------------------------------------------------------\n// File: PacketWriter.h\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Anton Hagqvist\n// Date: 01.06.2023\n//\n// Description:\n// Writer for ipxact:packet within a port of an abstraction definition.\n//-----------------------------------------------------------------------------\n\n#ifndef PACKETWRITER_H\n#define PACKETWRITER_H\n\n#include \"PacketField.h\"\n#include \"Packet.h\"\n\n#include <QString>\n#include <QList>\n#include <QSharedPointer>\n#include <QXmlStreamWriter>\n\n//-----------------------------------------------------------------------------\n//! Writer for ipxact:packet within ports of an abstraction definition.\n//-----------------------------------------------------------------------------\nnamespace PacketWriter\n{\n    IPXACTMODELS_EXPORT void writePacket(QXmlStreamWriter& writer, QSharedPointer<Packet> packet);\n\n    namespace Details\n    {\n        void writePacketFields(QXmlStreamWriter& writer, QSharedPointer<Packet> packet);\n\n        void writeSinglePacketField(QXmlStreamWriter& writer, QSharedPointer<PacketField> packetField);\n    }\n}\n\n#endif // PACKETWRITER_H\n\n"
  },
  {
    "path": "IPXACTmodels/AbstractionDefinition/PortAbstraction.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: PortAbstraction.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Esko Pekkarinen\r\n// Date: 12.08.2015\r\n//\r\n// Description:\r\n// Implementation for ipxact:port element within abstraction definition.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"PortAbstraction.h\"\r\n#include \"TransactionalAbstraction.h\"\r\n#include \"WireAbstraction.h\"\r\n#include \"WirePort.h\"\r\n#include \"TransactionalPort.h\"\r\n#include \"Packet.h\"\r\n\r\n#include <IPXACTmodels/common/Qualifier.h>\r\n#include <IPXACTmodels/utilities/Copy.h>\r\n\r\n#include <QString>\r\n#include <QSharedPointer>\r\n#include <QObject>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PortAbstraction::PortAbstraction()\r\n//-----------------------------------------------------------------------------\r\nPortAbstraction::PortAbstraction():\r\nNameGroup(),\r\n    Extendable()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PortAbstraction::PortAbstraction()\r\n//-----------------------------------------------------------------------------\r\nPortAbstraction::PortAbstraction(PortAbstraction const& other):\r\nNameGroup(other),\r\n    Extendable(other),\r\n    isPresent_(other.isPresent_),\r\n    match_(other.match_)\r\n{\r\n\r\n \tif (other.wire_)\r\n    {\r\n \t\twire_ = QSharedPointer<WireAbstraction>(new WireAbstraction(*other.wire_));\r\n \t}\r\n\r\n    if (other.transactional_)\r\n    {\r\n        transactional_ = QSharedPointer<TransactionalAbstraction>(\r\n            new TransactionalAbstraction(*other.transactional_));\r\n    }\r\n\r\n    Copy::copyList(other.packets_, packets_);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PortAbstraction::~PortAbstraction()\r\n//-----------------------------------------------------------------------------\r\nPortAbstraction::~PortAbstraction() \r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PortAbstraction::operator=()\r\n//-----------------------------------------------------------------------------\r\nPortAbstraction& PortAbstraction::operator=(PortAbstraction const& other)\r\n{\r\n\tif (this != &other) \r\n    {\r\n\t\tNameGroup::operator=(other);\r\n        Extendable::operator=(other);\r\n        isPresent_ = other.isPresent_;\r\n        match_ = other.match_;\r\n\r\n        wire_.clear();\r\n\t\tif (other.wire_)\r\n        {\r\n\t\t\twire_ = QSharedPointer<WireAbstraction>(new WireAbstraction(*other.wire_));\r\n\t\t}\r\n\r\n        transactional_.clear();\r\n\t\tif (other.transactional_)\r\n        {\r\n\t\t\ttransactional_ = QSharedPointer<TransactionalAbstraction>(\r\n                new TransactionalAbstraction(*other.transactional_));\r\n\t\t}\r\n\r\n        packets_->clear();\r\n        Copy::copyList(other.packets_, packets_);\r\n\t}\r\n\treturn *this;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PortAbstraction::setLogicalName()\r\n//-----------------------------------------------------------------------------\r\nvoid PortAbstraction::setLogicalName(QString const& logicalName)\r\n{\r\n    setName(logicalName);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PortAbstraction::getLogicalName()\r\n//-----------------------------------------------------------------------------\r\nQString PortAbstraction::getLogicalName() const\r\n{\r\n    return name();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PortAbstraction::setIsPresent()\r\n//-----------------------------------------------------------------------------\r\nvoid PortAbstraction::setIsPresent(QString const& presentExpression)\r\n{\r\n    isPresent_ = presentExpression;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PortAbstraction::isPresent()\r\n//-----------------------------------------------------------------------------\r\nQString PortAbstraction::isPresent() const\r\n{\r\n    return isPresent_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PortAbstraction::setMatch()\r\n//-----------------------------------------------------------------------------\r\nvoid PortAbstraction::setMatch(bool match)\r\n{\r\n    match_ = match;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PortAbstraction::getMatch()\r\n//-----------------------------------------------------------------------------\r\nbool PortAbstraction::getMatch() const\r\n{\r\n    return match_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PortAbstraction::hasWire()\r\n//-----------------------------------------------------------------------------\r\nbool PortAbstraction::hasWire() const\r\n{\r\n    return !wire_.isNull();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PortAbstraction::setWire()\r\n//-----------------------------------------------------------------------------\r\nvoid PortAbstraction::setWire(QSharedPointer<WireAbstraction> wire)\r\n{\r\n    wire_ = wire;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PortAbstraction::getWire()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<WireAbstraction> PortAbstraction::getWire() const\r\n{\r\n    return wire_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PortAbstraction::hasTransactional()\r\n//-----------------------------------------------------------------------------\r\nbool PortAbstraction::hasTransactional() const\r\n{\r\n    return !transactional_.isNull();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PortAbstraction::setTransactional()\r\n//-----------------------------------------------------------------------------\r\nvoid PortAbstraction::setTransactional(QSharedPointer<TransactionalAbstraction> transactional)\r\n{\r\n    transactional_ = transactional;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PortAbstraction::getTransactional()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<TransactionalAbstraction> PortAbstraction::getTransactional() const\r\n{\r\n    return transactional_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PortAbstraction::setPackets()\r\n//-----------------------------------------------------------------------------\r\nvoid PortAbstraction::setPackets(QSharedPointer<QList<QSharedPointer<Packet> > > packets)\r\n{\r\n    packets_ = packets;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PortAbstraction::getPackets()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<QList<QSharedPointer<Packet>>> PortAbstraction::getPackets() const\r\n{\r\n    return packets_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PortAbstraction::getDefaultValue()\r\n//-----------------------------------------------------------------------------\r\nQString PortAbstraction::getDefaultValue() const\r\n{\r\n\tif (hasWire() == false)\r\n    {\r\n\t\treturn QString();\r\n    }\r\n\r\n\treturn wire_->getDefaultValue();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PortAbstraction::setDefaultValue()\r\n//-----------------------------------------------------------------------------\r\nvoid PortAbstraction::setDefaultValue(QString const& defaultValue)\r\n{\r\n    if (hasWire() == false)\r\n    {\r\n        wire_ = QSharedPointer<WireAbstraction>(new WireAbstraction());\r\n    }\r\n\r\n    wire_->setDefaultValue(defaultValue);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PortAbstraction::getQualifier()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<Qualifier> PortAbstraction::getQualifier()\r\n{\r\n    if (hasWire())\r\n    {\r\n        return wire_->getQualifier();\r\n    }\r\n    else if (hasTransactional())\r\n    {\r\n         return transactional_->getQualifier();\r\n    }\r\n    else\r\n    {\r\n        return nullptr;\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PortAbstraction::setRequiresDriver()\r\n//-----------------------------------------------------------------------------\r\nvoid PortAbstraction::setRequiresDriver(bool requiresDriver)\r\n{\r\n    if (hasWire() == false)\r\n    {\r\n        wire_ = QSharedPointer<WireAbstraction>(new WireAbstraction());\r\n    }\r\n\r\n    wire_->setRequiresDriver(requiresDriver);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PortAbstraction::requiresDriver()\r\n//-----------------------------------------------------------------------------\r\nbool PortAbstraction::requiresDriver() const\r\n{\r\n    if (hasWire() == false)\r\n    {\r\n        return false;\r\n    }\r\n    else\r\n    {\r\n        return wire_->requiresDriver();\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PortAbstraction::getPresence()\r\n//-----------------------------------------------------------------------------\r\nPresenceTypes::Presence PortAbstraction::getPresence(General::InterfaceMode mode, QString const& systemGroup) const\r\n{\r\n    if (hasWire())\r\n    {\r\n        if ((mode == General::MASTER || mode == General::MIRRORED_MASTER || mode == General::INITIATOR || mode == General::MIRRORED_INITIATOR) && wire_->hasMasterPort())\r\n        {\r\n            return wire_->getMasterPort()->getPresence();\r\n        }\r\n        else if ((mode == General::SLAVE || mode == General::MIRRORED_SLAVE || mode == General::TARGET || mode == General::MIRRORED_TARGET) && wire_->hasSlavePort())\r\n        {\r\n            return wire_->getSlavePort()->getPresence();\r\n        }\r\n        else if ((mode == General::SYSTEM || mode == General::MIRRORED_SYSTEM) &&\r\n            !wire_->getSystemPorts()->isEmpty())\r\n        {\r\n            foreach (auto systemPort, *wire_->getSystemPorts())\r\n            {\r\n                if (systemPort->getSystemGroup() == systemGroup)\r\n                {\r\n                    return systemPort->getPresence();\r\n                }\r\n            }\r\n        }\r\n    }\r\n    else if (hasTransactional())\r\n    {\r\n        if ((mode == General::MASTER || mode == General::MIRRORED_MASTER || mode == General::INITIATOR || mode == General::MIRRORED_INITIATOR) && transactional_->hasMasterPort())\r\n        {\r\n            return transactional_->getMasterPort()->getPresence();\r\n        }\r\n        else if ((mode == General::SLAVE || mode == General::MIRRORED_SLAVE || mode == General::TARGET || mode == General::MIRRORED_TARGET) && transactional_->hasSlavePort())\r\n        {\r\n            return transactional_->getSlavePort()->getPresence();\r\n        }\r\n        else if ((mode == General::SYSTEM || mode == General::MIRRORED_SYSTEM) &&\r\n            !transactional_->getSystemPorts()->isEmpty())\r\n        {\r\n            foreach(auto systemPort, *transactional_->getSystemPorts())\r\n            {\r\n                if (systemPort->getSystemGroup() == systemGroup)\r\n                {\r\n                    return systemPort->getPresence();\r\n                }\r\n            }\r\n        }\r\n\r\n    }\r\n\r\n    return PresenceTypes::UNKNOWN;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PortAbstraction::hasMode()\r\n//-----------------------------------------------------------------------------\r\nbool PortAbstraction::hasMode(General::InterfaceMode mode, QString const& systemGroup) const\r\n{\r\n    if (hasWire())\r\n    {\r\n        return wire_->hasMode(mode, systemGroup);\r\n    }    \r\n    else if (hasTransactional())\r\n    {\r\n        return transactional_->hasMode(mode, systemGroup);\r\n    }\r\n\r\n    return false;\r\n}\r\n"
  },
  {
    "path": "IPXACTmodels/AbstractionDefinition/PortAbstraction.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: PortAbstraction.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Esko Pekkarinen\r\n// Date: 10.08.2015\r\n//\r\n// Description:\r\n// Implementation for ipxact:port element within abstraction definition.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef PORTABSTRACTION_H\r\n#define PORTABSTRACTION_H\r\n\r\n#include <IPXACTmodels/common/Extendable.h>\r\n#include <IPXACTmodels/common/NameGroup.h>\r\n#include <IPXACTmodels/common/Qualifier.h>\r\n\r\n#include <IPXACTmodels/ipxactmodels_global.h>\r\n#include <IPXACTmodels/common/PresenceTypes.h>\r\n#include <IPXACTmodels/generaldeclarations.h>\r\n\r\n#include <QSharedPointer>\r\n#include <QString>\r\n\r\nclass TransactionalAbstraction;\r\nclass VendorExtension;\r\nclass WireAbstraction;\r\nclass Packet;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Implementation for ipxact:port element within abstraction definition.\r\n//-----------------------------------------------------------------------------\r\nclass IPXACTMODELS_EXPORT PortAbstraction : public NameGroup, public Extendable\r\n{\r\n\r\npublic:\r\n\r\n\t//! The default constructor.\r\n\tPortAbstraction();\r\n\r\n\t//! The copy constructor.\r\n\tPortAbstraction(const PortAbstraction& other);\r\n  \r\n    //! The destructor.\r\n    ~PortAbstraction();\r\n\r\n\t//! Assignment operator.\r\n\tPortAbstraction& operator=(const PortAbstraction& other);\r\n\r\n    /*!\r\n     *  Sets the logical name of the port.\r\n     *\r\n     *    @param [in] logicalName   The name of the port to set.\r\n     */\r\n    void setLogicalName(QString const& logicalName);\r\n\r\n    /*!\r\n     *  Gets the logical name of the port.\r\n     *\r\n     *    @return The name of the port.\r\n     */\r\n    QString getLogicalName() const;\r\n\r\n    /*!\r\n     *  Sets the condition for the port existence.\r\n     *\r\n     *    @param [in] presentExpression   The condition when port is present.\r\n     */\r\n    void setIsPresent(QString const& presentExpression);\r\n\r\n    /*!\r\n     *  Gets the condition for the port existence.\r\n     *\r\n     *    @return The condition when the port is present in the document.\r\n     */\r\n    QString isPresent() const;\r\n\r\n    /*!\r\n     *  Sets the port match.\r\n     *\r\n     *    @param [in] match   The match flag.\r\n     */\r\n    void setMatch(bool match);\r\n\r\n    /*!\r\n     *  Gets the port match.\r\n     *\r\n     *    @return True, if port has to be present on both sides of a connection.\r\n     */\r\n    bool getMatch() const;\r\n\r\n    /*!\r\n     *  Checks if the port has wire definition.\r\n     *\r\n     *    @return True, if the port is a wire definition, otherwise false.\r\n     */\r\n    bool hasWire() const;\r\n    \r\n    /*!\r\n     *  Sets the wire definition for the port.\r\n     *\r\n     *    @param [in] wire   The wire to set.\r\n     */\r\n    void setWire(QSharedPointer<WireAbstraction> wire);\r\n\r\n\t/*!\r\n\t *  Gets the wire definition of the port.\r\n\t *\r\n\t *    @return The wire definition.\r\n\t */\r\n\tQSharedPointer<WireAbstraction> getWire() const;\r\n\r\n    /*!\r\n     *  Checks if the port has transactional definition.\r\n     *\r\n     *    @return True, if the port is a transactional definition, otherwise false.\r\n     */  \r\n    bool hasTransactional() const;\r\n    \r\n    /*!\r\n     *  Sets the transactional definition for the port.\r\n     *\r\n     *    @param [in] transactional   The transactional definition to set.\r\n     */\r\n    void setTransactional(QSharedPointer<TransactionalAbstraction> transactional);\r\n\r\n    /*!\r\n\t *  Gets the transactional definition of the port.\r\n\t *\r\n\t *    @return The transactional definition.\r\n\t */\r\n    QSharedPointer<TransactionalAbstraction> getTransactional() const;\r\n\r\n    /*!\r\n     *  Sets the packets of the port.\r\n     *\r\n     *    @param [in] packets     The packets to set.\r\n     */\r\n    void setPackets(QSharedPointer<QList<QSharedPointer<Packet> > > packets);\r\n\r\n    /*!\r\n     *  Gets the packets of the port.\r\n     *\r\n     *    @return The port packets.\r\n     */\r\n    QSharedPointer<QList<QSharedPointer<Packet> > > getPackets() const;\r\n\r\n\t/*!  Get the default value of the wire port.\r\n\t *\r\n\t *    @return The default value set for the wire port.\r\n\t*/\r\n\tQString getDefaultValue() const;\r\n\r\n\t/*! Set the default value for the wire port.\r\n\t *\r\n\t *    @param [in] defaultValue    The default value to set.\r\n\t*/\r\n\tvoid setDefaultValue(QString const& defaultValue);\r\n\r\n    /*!\r\n     *  Gets the wire qualifier.\r\n     *\r\n     *    @return The wire qualifier.\r\n     */\r\n    QSharedPointer<Qualifier> getQualifier();\r\n\r\n    /*!\r\n     *  Sets the wire driver requirement.\r\n     *\r\n     *    @param [in] requiresDriver   Whether or not the driver is required on the wire.\r\n     */\r\n    void setRequiresDriver(bool requiresDriver);\r\n\r\n    /*!\r\n     *  Checks if the wire requires a driver.\r\n     *\r\n     *    @return True, if a driver is required, otherwise false.\r\n     */\r\n    bool requiresDriver() const;\r\n\r\n    /*!\r\n     *  Gets the presence requirement for the port in given interface mode.\r\n     *\r\n     *    @param [in] mode            The mode to get the presence for.\r\n     *    @param [in] systemGroup     The system group, if applicable.\r\n     *\r\n     *    @return The required presence for the mode.\r\n     */\r\n    PresenceTypes::Presence getPresence(General::InterfaceMode mode, QString const& systemGroup) const;\r\n\r\n    /*!\r\n     *  Check if the port has the selected interface mode.\r\n     *\r\n     *    @param [in] mode            The selected interface mode.\r\n     *    @param [in] systemGroup     The system group, if applicable.\r\n     *\r\n     *    @return True, if the port has the selected mode, otherwise false.\r\n     */\r\n    bool hasMode(General::InterfaceMode mode, QString const& systemGroup) const;\r\n\r\nprivate:\r\n\r\n    //! Condition for port existence.\r\n    QString isPresent_;\r\n\r\n    //! Determines if ports in a connection must be present on both sides of a connection.\r\n    bool match_ = false;\r\n\r\n    //! Definitions for wire type port.\r\n\tQSharedPointer<WireAbstraction> wire_;\r\n\r\n    //! Definitions for transactional type port.\r\n    QSharedPointer<TransactionalAbstraction> transactional_;\r\n\r\n    //! The packets element within port.\r\n    QSharedPointer<QList<QSharedPointer<Packet> > > packets_ =\r\n        QSharedPointer<QList<QSharedPointer<Packet> > >(new QList<QSharedPointer<Packet> >());\r\n};\r\n\r\n#endif /* PORTABSTRACTION_H_ */\r\n"
  },
  {
    "path": "IPXACTmodels/AbstractionDefinition/TransactionalAbstraction.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: TransactionalAbstraction.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Esko Pekkarinen\r\n// Date: 21.08.2015\r\n//\r\n// Description:\r\n// Implementation for ipaxct:transactional within abstraction definition.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"TransactionalAbstraction.h\"\r\n\r\n#include \"TransactionalPort.h\"\r\n\r\n#include <IPXACTmodels/common/TransactionalTypes.h>\r\n\r\n#include <IPXACTmodels/utilities/Copy.h>\r\n\r\n#include <QList>\r\n#include <QObject>\r\n#include <QString>\r\n#include <QSharedPointer>\r\n\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: TransactionalAbstraction::TransactionalAbstraction()\r\n//-----------------------------------------------------------------------------\r\nTransactionalAbstraction::TransactionalAbstraction(TransactionalAbstraction const& other):\r\nqualifier_(new Qualifier(*other.qualifier_))\r\n{\r\n\tif (other.onInitiator_)\r\n    {\r\n\t\tonInitiator_ = QSharedPointer<TransactionalPort>(new TransactionalPort(*other.onInitiator_));\r\n\t}\r\n\r\n\tif (other.onTarget_)\r\n    {\r\n\t\tonTarget_ = QSharedPointer<TransactionalPort>(new TransactionalPort(*other.onTarget_));\r\n\t}\r\n\r\n    Copy::copyList(other.onSystem_, onSystem_);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: TransactionalAbstraction::()\r\n//-----------------------------------------------------------------------------\r\nTransactionalAbstraction& TransactionalAbstraction::operator=(TransactionalAbstraction const& other )\r\n{\r\n\tif (this != &other)\r\n    {\r\n\t    qualifier_ = other.qualifier_;\r\n\r\n        onInitiator_.clear();\r\n\t\tif (other.onInitiator_)\r\n        {\r\n\t\t\tonInitiator_ = QSharedPointer<TransactionalPort>(new TransactionalPort(*other.onInitiator_));\r\n\t\t}\r\n\r\n        onTarget_.clear();\r\n\t\tif (other.onTarget_)\r\n        {\r\n\t\t\tonTarget_ = QSharedPointer<TransactionalPort>(new TransactionalPort(*other.onTarget_));\r\n\t\t}\r\n\r\n        onSystem_->clear();\r\n        Copy::copyList(other.onSystem_, onSystem_);\r\n    }\r\n\treturn *this;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: TransactionalAbstraction::~TransactionalAbstraction()\r\n//-----------------------------------------------------------------------------\r\nTransactionalAbstraction::~TransactionalAbstraction()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: TransactionalAbstraction::getQualifier()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<Qualifier> TransactionalAbstraction::getQualifier()\r\n{\r\n\treturn qualifier_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: TransactionalAbstraction::setQualifier()\r\n//-----------------------------------------------------------------------------\r\nvoid TransactionalAbstraction::setQualifier(QSharedPointer<Qualifier> qualifier)\r\n{\r\n    qualifier_ = qualifier;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: TransactionalAbstraction::addQualifier()\r\n//-----------------------------------------------------------------------------\r\nvoid TransactionalAbstraction::addQualifier(Qualifier::Type qualifierType)\r\n{\r\n    qualifier_->setType(qualifierType);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: TransactionalAbstraction::addSystemPort()\r\n//-----------------------------------------------------------------------------\r\nvoid TransactionalAbstraction::addSystemPort(QSharedPointer<TransactionalPort> systemPort)\r\n{\r\n    onSystem_->append(systemPort);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: TransactionalAbstraction::getSystemPorts()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<QList<QSharedPointer<TransactionalPort> > > TransactionalAbstraction::getSystemPorts() const\r\n{\r\n    return onSystem_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: TransactionalAbstraction::hasInitiatorPort()\r\n//-----------------------------------------------------------------------------\r\nbool TransactionalAbstraction::hasInitiatorPort() const\r\n{\r\n    return !onInitiator_.isNull();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: TransactionalAbstraction::setInitiatorPort()\r\n//-----------------------------------------------------------------------------\r\nvoid TransactionalAbstraction::setInitiatorPort(QSharedPointer<TransactionalPort> initiatorPort)\r\n{\r\n    onInitiator_ = initiatorPort;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: TransactionalAbstraction::getInitiatorPort()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<TransactionalPort> TransactionalAbstraction::getInitiatorPort() const\r\n{\r\n    return onInitiator_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: TransactionalAbstraction::hasTargetPort()\r\n//-----------------------------------------------------------------------------\r\nbool TransactionalAbstraction::hasTargetPort() const\r\n{\r\n    return !onTarget_.isNull();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: TransactionalAbstraction::setTargetPort()\r\n//-----------------------------------------------------------------------------\r\nvoid TransactionalAbstraction::setTargetPort(QSharedPointer<TransactionalPort> targetPort)\r\n{\r\n    onTarget_ = targetPort;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: TransactionalAbstraction::getTargetPort()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<TransactionalPort> TransactionalAbstraction::getTargetPort() const\r\n{\r\n    return onTarget_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: TransactionalAbstraction::hasMasterPort()\r\n//-----------------------------------------------------------------------------\r\nbool TransactionalAbstraction::hasMasterPort() const\r\n{\r\n    return hasInitiatorPort();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: TransactionalAbstraction::setMasterPort()\r\n//-----------------------------------------------------------------------------\r\nvoid TransactionalAbstraction::setMasterPort(QSharedPointer<TransactionalPort> masterPort)\r\n{\r\n    setInitiatorPort(masterPort);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: TransactionalAbstraction::getMasterPort()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<TransactionalPort> TransactionalAbstraction::getMasterPort() const\r\n{\r\n    return getInitiatorPort();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: TransactionalAbstraction::hasSlavePort()\r\n//-----------------------------------------------------------------------------\r\nbool TransactionalAbstraction::hasSlavePort() const\r\n{\r\n    return hasTargetPort();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: TransactionalAbstraction::setSlavePort()\r\n//-----------------------------------------------------------------------------\r\nvoid TransactionalAbstraction::setSlavePort(QSharedPointer<TransactionalPort> slavePort)\r\n{\r\n    setTargetPort(slavePort);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: TransactionalAbstraction::getSlavePort()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<TransactionalPort> TransactionalAbstraction::getSlavePort() const\r\n{\r\n    return getTargetPort();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: TransactionalAbstraction::hasMode()\r\n//-----------------------------------------------------------------------------\r\nbool TransactionalAbstraction::hasMode(General::InterfaceMode mode, QString const& systemGroup) const\r\n{\r\n    if (mode == General::SYSTEM || mode == General::MIRRORED_SYSTEM)\r\n    {\r\n        QSharedPointer<TransactionalPort> systemPort = findSystemPort(systemGroup);\r\n        return !systemPort.isNull();\r\n    }\r\n\r\n    return (mode == General::MASTER && hasMasterPort()) ||\r\n        (mode == General::MIRRORED_MASTER && hasMasterPort()) ||\r\n        (mode == General::INITIATOR && hasMasterPort()) ||\r\n        (mode == General::MIRRORED_INITIATOR && hasMasterPort()) ||\r\n        (mode == General::SLAVE && hasSlavePort()) ||\r\n        (mode == General::MIRRORED_SLAVE && hasSlavePort()) ||\r\n        (mode == General::TARGET && hasSlavePort()) ||\r\n        (mode == General::MIRRORED_TARGET && hasSlavePort());\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: TransactionalAbstraction::findSystemPort()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<TransactionalPort> TransactionalAbstraction::findSystemPort(QString const& systemGroup) const\r\n{\r\n    for (QSharedPointer<TransactionalPort> systemPort : *onSystem_)\r\n    {\r\n        if (systemPort->getSystemGroup() == systemGroup)\r\n        {\r\n            return systemPort;\r\n        }\r\n    }\r\n\r\n    return QSharedPointer<TransactionalPort>();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: TransactionalAbstraction::getInitiative()\r\n//-----------------------------------------------------------------------------\r\nQString TransactionalAbstraction::getInitiative(General::InterfaceMode mode, QString const& systemGroup) const\r\n{\r\n    using namespace TransactionalTypes;\r\n\r\n    if ((mode == General::MASTER || mode == General::INITIATOR) && hasMasterPort())\r\n    {\r\n        return getMasterPort()->getInitiative();\r\n    }\r\n    else if ((mode == General::MIRRORED_MASTER || mode == General::MIRRORED_INITIATOR) && hasMasterPort())\r\n    {\r\n        return initiativeToString(convertToMirrored(getMasterPort()->getInitiative()));\r\n    }\r\n    else if ((mode == General::SLAVE || mode == General::TARGET) && hasSlavePort())\r\n    {\r\n        return getSlavePort()->getInitiative();\r\n    }\r\n    else if ((mode == General::MIRRORED_SLAVE || mode == General::MIRRORED_TARGET) && hasSlavePort())\r\n    {\r\n        return initiativeToString(convertToMirrored(getSlavePort()->getInitiative()));\r\n    }\r\n    else if (mode == General::SYSTEM)\r\n    {\r\n        if (QSharedPointer<TransactionalPort> systemPort = findSystemPort(systemGroup))\r\n        {\r\n            return systemPort->getInitiative();\r\n        }\r\n    }\r\n    else if (mode == General::MIRRORED_SYSTEM)\r\n    {\r\n        if (QSharedPointer<TransactionalPort> systemPort = findSystemPort(systemGroup))\r\n        {\r\n            return initiativeToString(convertToMirrored(systemPort->getInitiative()));\r\n        }\r\n    }\r\n\r\n    return QString();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: TransactionalAbstraction::getWidth()\r\n//-----------------------------------------------------------------------------\r\nQString TransactionalAbstraction::getWidth(General::InterfaceMode mode, QString const& systemGroup) const\r\n{\r\n    if ((mode == General::MASTER || mode == General::MIRRORED_MASTER ||\r\n        mode == General::INITIATOR || mode == General::MIRRORED_INITIATOR) && hasMasterPort())\r\n    {\r\n        return getMasterPort()->getBusWidth();\r\n    }\r\n    else if ((mode == General::SLAVE || mode == General::MIRRORED_SLAVE ||\r\n        mode == General::TARGET || mode == General::MIRRORED_TARGET) && hasSlavePort())\r\n    {\r\n        return getSlavePort()->getBusWidth();\r\n    }\r\n    else if (mode == General::SYSTEM || mode == General::MIRRORED_SYSTEM)\r\n    {\r\n        if (QSharedPointer<TransactionalPort> systemPort = findSystemPort(systemGroup))\r\n        {\r\n            return systemPort->getBusWidth();\r\n        }\r\n    }\r\n\r\n    return QString();\r\n}\r\n"
  },
  {
    "path": "IPXACTmodels/AbstractionDefinition/TransactionalAbstraction.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: TransactionalAbstraction.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Esko Pekkarinen\r\n// Date: 21.08.2015\r\n//\r\n// Description:\r\n// Implementation for ipaxct:transactional within abstraction definition.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef TRANSACTIONALABSTRACTION_H\r\n#define TRANSACTIONALABSTRACTION_H\r\n\r\n#include <IPXACTmodels/generaldeclarations.h>\r\n#include <IPXACTmodels/ipxactmodels_global.h>\r\n\r\n#include <IPXACTmodels/common/Qualifier.h>\r\n\r\n#include <QSharedPointer>\r\n#include <QList>\r\n#include <QDomNode>\r\n#include <QString>\r\n\r\nclass TransactionalPort;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Implementation for ipaxct:transactional within abstraction definition.\r\n//-----------------------------------------------------------------------------\r\nclass IPXACTMODELS_EXPORT TransactionalAbstraction\r\n{\r\npublic:\r\n\r\n\tTransactionalAbstraction() = default;\r\n\r\n\t//! \\brief Copy constructor\r\n\tTransactionalAbstraction(const TransactionalAbstraction& other);\r\n\r\n\t//! \\brief Assignment operator\r\n\tTransactionalAbstraction& operator=(const TransactionalAbstraction& other);\r\n\r\n\t/*! \\brief The destructor\r\n\t *\r\n\t */\r\n\t~TransactionalAbstraction();\r\n\r\n    /*!\r\n     *  Sets a qualifier for the information the transaction carries.\r\n     *\r\n     *    @param [in] qualifier   The qualifier to set.\r\n     */\r\n    void setQualifier(QSharedPointer<Qualifier> qualifier);\r\n\r\n    /*!\r\n     *  Add a qualifier type for the information the transaction carries.\r\n     *\r\n     *    @param [in] qualifierType   The qualifier type to add.\r\n     */\r\n    void addQualifier(Qualifier::Type qualifierType);\r\n\r\n    /*!\r\n     *  Gets the qualifier for the information the transaction carries.\r\n     *\r\n     *    @return The wire qualifier.\r\n     */\r\n    QSharedPointer<Qualifier> getQualifier();\r\n\r\n    /*!\r\n     *  Adds a system port definition for the transaction definition.\r\n     *\r\n     *    @param [in] systemPort   The system transaction port to add.\r\n     */\r\n    void addSystemPort(QSharedPointer<TransactionalPort> systemPort);\r\n\r\n    /*!\r\n     *  Gets the system port definitions for the transaction definition.\r\n     *\r\n     *    @return The system ports for the transaction definition.\r\n     */\r\n    QSharedPointer<QList<QSharedPointer<TransactionalPort> > > getSystemPorts() const;\r\n    \r\n    /*!\r\n     *  Find the selected system port.\r\n     *\r\n     *    @param [in] systemGroup     The selected interface system group.\r\n     *\r\n     *    @return The selected system port, if it exists.\r\n     */\r\n    QSharedPointer<TransactionalPort> findSystemPort(QString const& systemGroup) const;\r\n\r\n    /*!\r\n     *  Checks if the transactional has a port definition for initiator mode.\r\n     *\r\n     *    @return True, if initiator mode is defined, otherwise false.\r\n     */\r\n    bool hasInitiatorPort() const;\r\n\r\n    /*!\r\n     *  Sets the initiator mode port definitions for the transactional.\r\n     *\r\n     *    @param [in] initiatorPort The initiator port definition for the transactional.\r\n     */\r\n    void setInitiatorPort(QSharedPointer<TransactionalPort> initiatorPort);\r\n\r\n    /*!\r\n     *  Gets the initiator mode port definitions for the transactional.\r\n     *\r\n     *    @return The initiator port definition for the transactional.\r\n     */\r\n    QSharedPointer<TransactionalPort> getInitiatorPort() const;\r\n\r\n    /*!\r\n     *  Checks if the transactional has a port definition for target mode.\r\n     *\r\n     *    @return True, if target mode is defined, otherwise false.\r\n     */\r\n    bool hasTargetPort() const;\r\n\r\n    /*!\r\n     *  Sets the target mode port definitions for the transactional.\r\n     *\r\n     *    @param [in] slavePort The target port definition for the transactional.\r\n     */\r\n    void setTargetPort(QSharedPointer<TransactionalPort> targetPort);\r\n\r\n    /*!\r\n     *  Gets the target mode port definitions for the transactional.\r\n     *\r\n     *    @return The target port definition for the transactional.\r\n     */\r\n    QSharedPointer<TransactionalPort> getTargetPort() const;\r\n\r\n    /*!\r\n     *  Checks if the transaction definition has a port definition for master mode.\r\n     *\r\n     *    @return True, if master mode is defined, otherwise false.\r\n     */\r\n    bool hasMasterPort() const;\r\n       \r\n    /*!\r\n     *  Sets the master mode port definitions for the transaction definition.\r\n     *\r\n     *    @param [in] masterPort The master port definition for the transaction definition.\r\n     */ \t\r\n    void setMasterPort(QSharedPointer<TransactionalPort> masterPort);\r\n\r\n    /*!\r\n     *  Gets the master mode port definitions for the transaction definition.\r\n     *\r\n     *    @return The master port definition for the  transaction definition.\r\n     */\r\n\tQSharedPointer<TransactionalPort> getMasterPort() const;\r\n\r\n    /*!\r\n     *  Checks if the transaction definition has a port definition for slave mode.\r\n     *\r\n     *    @return True, if slave mode is defined, otherwise false.\r\n     */\r\n    bool hasSlavePort() const;\r\n      \r\n    /*!\r\n     *  Sets the slave mode port definitions for the transaction definition.\r\n     *\r\n     *    @param [in] slavePort The slave port definition for the transaction definition.\r\n     */\r\n\tvoid setSlavePort(QSharedPointer<TransactionalPort> slavePort);\r\n            \r\n    /*!\r\n     *  Gets the slave mode port definitions for the transaction definition.\r\n     *\r\n     *    @return The slave port definition for the transaction definition.\r\n     */\r\n    QSharedPointer<TransactionalPort> getSlavePort() const;\r\n\r\n    /*!\r\n     *  Check if the transactional has the selected interface mode.\r\n     *\r\n     *    @param [in] mode            The selected interface mode.\r\n     *    @param [in] systemGroup     The selected interface system group.\r\n     *\r\n     *    @return True, if the transactional has the selected mode, otherwise false.\r\n     */\r\n    bool hasMode(General::InterfaceMode mode, QString const& systemGroup) const;\r\n\r\n    /*!\r\n     *  Get the initiative of the selected interface mode.\r\n     *\r\n     *    @param [in] mode            The selected interface mode.\r\n     *    @param [in] systemGroup     The selected interface system group.\r\n     *\r\n     *    @return The initiative of the selected mode.\r\n     */\r\n    QString getInitiative(General::InterfaceMode mode, QString const& systemGroup) const;\r\n\r\n    /*!\r\n     *  Get the width of the selected interface mode.\r\n     *\r\n     *    @param [in] mode            The selected interface mode.\r\n     *    @param [in] systemGroup     The selected interface system group.\r\n     *\r\n     *    @return The width of the selected mode.\r\n     */\r\n    QString getWidth(General::InterfaceMode mode, QString const& systemGroup) const;\r\n\r\nprivate:\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! The qualifier describing the information the transaction carries.\r\n    QSharedPointer<Qualifier> qualifier_{ new Qualifier() };\r\n\r\n    //! The port definition for initiator mode.\r\n\tQSharedPointer<TransactionalPort> onInitiator_{ nullptr };\r\n\r\n    //! The port definition for target mode.\r\n    QSharedPointer<TransactionalPort> onTarget_{ nullptr };\r\n\r\n    //! The port definitions for system mode.\r\n    QSharedPointer<QList<QSharedPointer<TransactionalPort> > > onSystem_{ \r\n        new QList<QSharedPointer<TransactionalPort> >() };\r\n    \r\n};\r\n\r\n#endif /* TRANSACTIONALABSTRACTION_H */\r\n"
  },
  {
    "path": "IPXACTmodels/AbstractionDefinition/TransactionalAbstractionReader.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: TransactionalAbstractionReader.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Esko Pekkarinen\r\n// Date: 24.08.2015\r\n//\r\n// Description:\r\n// Reader for ipxact:transactional within abstraction definition.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"TransactionalAbstractionReader.h\"\r\n\r\n#include <IPXACTmodels/common/CommonItemsReader.h>\r\n#include <IPXACTmodels/common/GenericVendorExtension.h>\r\n#include <IPXACTmodels/common/Protocol.h>\r\n#include <IPXACTmodels/common/ProtocolReader.h>\r\n#include <IPXACTmodels/common/PresenceTypes.h>\r\n#include <IPXACTmodels/common/QualifierReader.h>\r\n\r\n#include \"TransactionalAbstraction.h\"\r\n#include \"TransactionalPort.h\"\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: TransactionalAbstractionReader::createTransactionalAbstractionFrom()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<TransactionalAbstraction> TransactionalAbstractionReader::createTransactionalAbstractionFrom(\r\n    QDomNode const& transactionalNode, Document::Revision revision)\r\n{\r\n    QSharedPointer<TransactionalAbstraction> transactional(new TransactionalAbstraction());\r\n\r\n    Details::parseQualifier(transactionalNode, transactional, revision);\r\n \r\n    Details::parseSystems(transactionalNode, transactional);\r\n \r\n    Details::parseInitiator(transactionalNode, transactional, revision);\r\n\r\n    Details::parseTarget(transactionalNode, transactional, revision);\r\n\r\n    return transactional;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: TransactionalAbstractionReader::Details::parseQualifier()\r\n//-----------------------------------------------------------------------------\r\nvoid TransactionalAbstractionReader::Details::parseQualifier(QDomNode const& transactionalNode, \r\n    QSharedPointer<TransactionalAbstraction> transactional, Document::Revision revision)\r\n{\r\n    QDomNode qualifierNode = transactionalNode.firstChildElement(QStringLiteral(\"ipxact:qualifier\"));\r\n\r\n    auto qualifier = transactional->getQualifier();\r\n\r\n    QualifierReader::parseQualifier(qualifierNode, qualifier, revision);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: TransactionalAbstractionReader::Details::parseSystems()\r\n//-----------------------------------------------------------------------------\r\nvoid TransactionalAbstractionReader::Details::parseSystems(QDomNode const& transactionalNode, \r\n    QSharedPointer<TransactionalAbstraction> transactional)\r\n{\r\n    QDomNodeList systemNodes = transactionalNode.toElement().elementsByTagName(QStringLiteral(\"ipxact:onSystem\"));\r\n\r\n    for (int i = 0; i < systemNodes.count(); i++)\r\n    {\r\n        QDomNode systemNode = systemNodes.at(i);\r\n\r\n        QSharedPointer<TransactionalPort> system = parseTransactionalPort(systemNode);\r\n        system->setSystemGroup(systemNode.firstChildElement(QStringLiteral(\"ipxact:group\")).firstChild().nodeValue());\r\n        transactional->addSystemPort(system);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: TransactionalAbstractionReader::Details::parseTransactionalPort()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<TransactionalPort> TransactionalAbstractionReader::Details::parseTransactionalPort(QDomNode const& portNode)\r\n{\r\n    QSharedPointer<TransactionalPort> transactionalPort(new TransactionalPort());\r\n\r\n    QDomNode presenceNode = portNode.firstChildElement(QStringLiteral(\"ipxact:presence\"));\r\n    transactionalPort->setPresence(PresenceTypes::str2Presence(presenceNode.firstChild().nodeValue(),\r\n        PresenceTypes::UNKNOWN));\r\n\r\n    transactionalPort->setInitiative(portNode.firstChildElement(QStringLiteral(\"ipxact:initiative\")).firstChild().nodeValue());\r\n\r\n    transactionalPort->setKind(portNode.firstChildElement(QStringLiteral(\"ipxact:kind\")).firstChild().nodeValue());\r\n\r\n    transactionalPort->setBusWidth(portNode.firstChildElement(QStringLiteral(\"ipxact:busWidth\")).firstChild().nodeValue());\r\n\r\n    parseProtocol(portNode, transactionalPort);\r\n\r\n    return transactionalPort;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: TransactionalAbstractionReader::Details::parseProtocol()\r\n//-----------------------------------------------------------------------------\r\nvoid TransactionalAbstractionReader::Details::parseProtocol(QDomNode const& portNode,\r\n    QSharedPointer<TransactionalPort> transactionalPort)\r\n{\r\n    QDomNode protocolNode = portNode.firstChildElement(QStringLiteral(\"ipxact:protocol\"));\r\n\r\n    if (!protocolNode.isNull())\r\n    {\r\n        ProtocolReader protocolReader;\r\n        transactionalPort->setProtocol(protocolReader.createProtocolFrom(protocolNode));\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: TransactionalAbstractionReader::Details::parseInitiator()\r\n//-----------------------------------------------------------------------------\r\nvoid TransactionalAbstractionReader::Details::parseInitiator(QDomNode const& transactionalNode, \r\n    QSharedPointer<TransactionalAbstraction> transactional, Document::Revision revision)\r\n{\r\n    QString elementName = revision == Document::Revision::Std22\r\n        ? QStringLiteral(\"ipxact:onInitiator\")\r\n        : QStringLiteral(\"ipxact:onMaster\");\r\n\r\n    QDomNode initiatorNode = transactionalNode.firstChildElement(elementName);\r\n\r\n    if (!initiatorNode.isNull())\r\n    {\r\n        QSharedPointer<TransactionalPort> initiator = parseTransactionalPort(initiatorNode);\r\n        transactional->setInitiatorPort(initiator);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: TransactionalAbstractionReader::Details::parseTarget()\r\n//-----------------------------------------------------------------------------\r\nvoid TransactionalAbstractionReader::Details::parseTarget(QDomNode const& transactionalNode, \r\n    QSharedPointer<TransactionalAbstraction> transactional, Document::Revision revision)\r\n{\r\n    QString elementName = revision == Document::Revision::Std22\r\n        ? QStringLiteral(\"ipxact:onTarget\")\r\n        : QStringLiteral(\"ipxact:onSlave\");\r\n\r\n    QDomNode targetNode = transactionalNode.firstChildElement(elementName);\r\n\r\n    if (!targetNode.isNull())\r\n    {\r\n        QSharedPointer<TransactionalPort> target = parseTransactionalPort(targetNode);\r\n        transactional->setTargetPort(target);\r\n    }\r\n}\r\n"
  },
  {
    "path": "IPXACTmodels/AbstractionDefinition/TransactionalAbstractionReader.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: TransactionalAbstractionReader.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Esko Pekkarinen\r\n// Date: 24.08.2015\r\n//\r\n// Description:\r\n// Reader class for ipxact:transactional within abstraction definition.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef TRANSACTIONALABSTRACTIONREADER_H\r\n#define TRANSACTIONALABSTRACTIONREADER_H\r\n\r\n#include <IPXACTmodels/common/Document.h>\r\n\r\n#include <QDomNode>\r\n#include <QObject>\r\n#include <QSharedPointer>\r\n\r\nclass Protocol;\r\nclass TransactionalAbstraction;\r\nclass TransactionalPort;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Reader for ipxact:transactional within abstraction definition.\r\n//-----------------------------------------------------------------------------\r\nnamespace TransactionalAbstractionReader\r\n{       \r\n    /*!\r\n     *  Creates a transactional for abstraction definition from XML description.\r\n     *\r\n     *    @param [in] transactionalNode   The XML document to create the transactional definition from.\r\n     *\r\n     *    @return The created transactional definition.\r\n     */\r\n    QSharedPointer<TransactionalAbstraction> createTransactionalAbstractionFrom(QDomNode const& transactionalNode,\r\n        Document::Revision revision);\r\n\r\n    namespace Details\r\n    {\r\n        /*!\r\n         *  Reads the qualifier from XML to a transactional.\r\n         *\r\n         *    @param [in]     transactionalNode    The XML description of the transactional.\r\n         *    @param [in/out] transactional        The transactional definition to insert the qualifier into.\r\n         *    @param [in]     revision             The standard revision of the XML document being read.\r\n         */\r\n        void parseQualifier(QDomNode const& transactionalNode, QSharedPointer<TransactionalAbstraction> transactional,\r\n            Document::Revision revision);\r\n\r\n        /*!\r\n         *  Reads the system ports from XML to a transactional.\r\n         *\r\n         *    @param [in]     transactionalNode    The XML description of the transactional.\r\n         *    @param [in/out] transactional        The transactional definition to insert the system ports into.\r\n         */\r\n        void parseSystems(QDomNode const& transactionalNode, QSharedPointer<TransactionalAbstraction> transactional);\r\n       \r\n        /*!\r\n         *  Creates a transactionalPort for a transactional from XML description.\r\n         *\r\n         *    @param [in]     transactionalPortNode    The XML description of the transactionalPort.\r\n         *\r\n         *    @return The created transactionalPort.\r\n         */\r\n        QSharedPointer<TransactionalPort> parseTransactionalPort(QDomNode const& portNode);    \r\n \r\n        /*!\r\n         *  Reads the protocol description for transactional port.\r\n         *\r\n         *    @param [in]     portNode            The XML description of the transactionalPort.\r\n         *    @param [in/out] transactionalPort   The transactional port to insert the protocol into.\r\n         */\r\n        void parseProtocol(QDomNode const& portNode, QSharedPointer<TransactionalPort> transactionalPort);\r\n\r\n        /*!\r\n         *  Reads the initiator port from XML to a transactional.\r\n         *\r\n         *    @param [in]     transactionalNode    The XML description of the transactional.\r\n         *    @param [in/out] transactional        The transactional definition to insert the initiator port into.\r\n         */                                    \r\n        void parseInitiator(QDomNode const& transactionalNode, QSharedPointer<TransactionalAbstraction> transactional,\r\n            Document::Revision revision);\r\n    \r\n        /*!\r\n         *  Reads the target port from XML to a transactional.\r\n         *\r\n         *    @param [in]     transactionalNode    The XML description of the transactional.\r\n         *    @param [in/out] transactional        The transactional definition to insert the target port into.\r\n         */ \r\n        void parseTarget(QDomNode const& transactionalNode, QSharedPointer<TransactionalAbstraction> transactional,\r\n            Document::Revision revision);\r\n    }\r\n}\r\n\r\n#endif // TRANSACTIONALABSTRACTIONREADER_H\r\n"
  },
  {
    "path": "IPXACTmodels/AbstractionDefinition/TransactionalAbstractionWriter.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: TransactionalAbstractionWriter.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Esko Pekkarinen\r\n// Date: 21.08.2015\r\n//\r\n// Description:\r\n// Writer class for IP-XACT Transactional element within abstraction definition.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"TransactionalAbstractionWriter.h\"\r\n\r\n#include \"TransactionalAbstraction.h\"\r\n#include \"TransactionalPort.h\"\r\n\r\n#include <IPXACTmodels/common/Protocol.h>\r\n#include <IPXACTmodels/common/ProtocolWriter.h>\r\n#include <IPXACTmodels/common/CommonItemsWriter.h>\r\n#include <IPXACTmodels/common/QualifierWriter.h>\r\n\r\n#include <IPXACTmodels/common/VendorExtension.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: TransactionalAbstractionWriter::writeTransactional()\r\n//-----------------------------------------------------------------------------\r\nvoid TransactionalAbstractionWriter::writeTransactional(QXmlStreamWriter& writer, \r\n    QSharedPointer<TransactionalAbstraction> transactional, Document::Revision revision)\r\n{\r\n    writer.writeStartElement(QStringLiteral(\"ipxact:transactional\"));\r\n\r\n    QualifierWriter::writeQualifier(writer, transactional->getQualifier());\r\n\r\n    Details::writeSystem(writer, transactional);\r\n\r\n    QString initiatorElementName = revision == Document::Revision::Std22\r\n        ? QStringLiteral(\"ipxact:onInitiator\")\r\n        : QStringLiteral(\"ipxact:onMaster\");\r\n\r\n    QString targetElementName = revision == Document::Revision::Std22\r\n        ? QStringLiteral(\"ipxact:onTarget\")\r\n        : QStringLiteral(\"ipxact:onSlave\");\r\n\r\n    Details::writeMaster(writer, transactional, initiatorElementName);\r\n\r\n    Details::writeSlave(writer, transactional, targetElementName);\r\n\r\n    writer.writeEndElement();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: TransactionalAbstractionWriter::Details::writeSystem()\r\n//-----------------------------------------------------------------------------\r\nvoid TransactionalAbstractionWriter::Details::writeSystem(QXmlStreamWriter& writer,\r\n    QSharedPointer<TransactionalAbstraction> transactional)\r\n{\r\n    for (auto const& systemPort : *transactional->getSystemPorts())\r\n    {\r\n        writer.writeStartElement(QStringLiteral(\"ipxact:onSystem\"));\r\n        writer.writeTextElement(QStringLiteral(\"ipxact:group\"), systemPort->getSystemGroup());\r\n        writeTransactionalPort(writer, systemPort);\r\n        writer.writeEndElement();\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: TransactionalAbstractionWriter::Details::writeTransactionalPort()\r\n//-----------------------------------------------------------------------------\r\nvoid TransactionalAbstractionWriter::Details::writeTransactionalPort(QXmlStreamWriter& writer, \r\n    QSharedPointer<TransactionalPort> port)\r\n{\r\n    writePresence(writer, port);\r\n\r\n    writeInitiative(writer, port);\r\n\r\n    writeKind(writer, port);\r\n\r\n    writeBusWidth(writer, port);\r\n\r\n    ProtocolWriter protocolWriter;\r\n    protocolWriter.writeProtocol(writer, port->getProtocol());\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: TransactionalAbstractionWriter::Details::writePresence()\r\n//-----------------------------------------------------------------------------\r\nvoid TransactionalAbstractionWriter::Details::writePresence(QXmlStreamWriter& writer,\r\n    QSharedPointer<TransactionalPort> port)\r\n{\r\n    if (port->getPresence() == PresenceTypes::REQUIRED)\r\n    {\r\n        writer.writeTextElement(QStringLiteral(\"ipxact:presence\"), QStringLiteral(\"required\"));\r\n    }\r\n    else if (port->getPresence() == PresenceTypes::OPTIONAL)\r\n    {\r\n        writer.writeTextElement(QStringLiteral(\"ipxact:presence\"), QStringLiteral(\"optional\"));\r\n    }\r\n    else if (port->getPresence() == PresenceTypes::ILLEGAL)\r\n    {\r\n        writer.writeTextElement(QStringLiteral(\"ipxact:presence\"), QStringLiteral(\"illegal\"));\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: TransactionalAbstractionWriter::Details::writeInitiative()\r\n//-----------------------------------------------------------------------------\r\nvoid TransactionalAbstractionWriter::Details::writeInitiative(QXmlStreamWriter& writer,\r\n    QSharedPointer<TransactionalPort> port)\r\n{\r\n    CommonItemsWriter::writeNonEmptyElement(writer, QStringLiteral(\"ipxact:initiative\"), port->getInitiative());\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: TransactionalAbstractionWriter::Details::writeKind()\r\n//-----------------------------------------------------------------------------\r\nvoid TransactionalAbstractionWriter::Details::writeKind(QXmlStreamWriter& writer, \r\n    QSharedPointer<TransactionalPort> port)\r\n{\r\n    if (!port->getKind().isEmpty())\r\n    {\r\n        QStringList standardKinds;\r\n        standardKinds << QStringLiteral(\"tlm_port\") << QStringLiteral(\"tlm_socket\") << \r\n            QStringLiteral(\"simple_socket\") << QStringLiteral(\"multi_socket\");\r\n\r\n        writer.writeStartElement(QStringLiteral(\"ipxact:kind\"));\r\n        if (standardKinds.contains(port->getKind()))\r\n        {\r\n            writer.writeCharacters(port->getKind());\r\n        }\r\n        else\r\n        {\r\n            writer.writeAttribute(QStringLiteral(\"custom\"), port->getKind());\r\n            writer.writeCharacters(QStringLiteral(\"custom\"));\r\n        }\r\n        writer.writeEndElement();\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: TransactionalAbstractionWriter::Details::writeBusWidth()\r\n//-----------------------------------------------------------------------------\r\nvoid TransactionalAbstractionWriter::Details::writeBusWidth(QXmlStreamWriter& writer, \r\n    QSharedPointer<TransactionalPort> port)\r\n{\r\n    if (!port->getBusWidth().isEmpty())\r\n    {\r\n        writer.writeTextElement(QStringLiteral(\"ipxact:busWidth\"), port->getBusWidth());\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: TransactionalAbstractionWriter::Details::writeVendorExtensions()\r\n//-----------------------------------------------------------------------------\r\nvoid TransactionalAbstractionWriter::Details::writeVendorExtensions(QXmlStreamWriter& writer, \r\n    QSharedPointer<Protocol> portProtocol)\r\n{\r\n    if (!portProtocol->getVendorExtensions()->isEmpty())\r\n    {\r\n        writer.writeStartElement(QStringLiteral(\"ipxact:vendorExtensions\"));\r\n        for (auto extension : *portProtocol->getVendorExtensions())\r\n        {\r\n            extension->write(writer);\r\n        }\r\n        writer.writeEndElement();\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: TransactionalAbstractionWriter::Details::writeMaster()\r\n//-----------------------------------------------------------------------------\r\nvoid TransactionalAbstractionWriter::Details::writeMaster(QXmlStreamWriter& writer,\r\n    QSharedPointer<TransactionalAbstraction> transactional, QString const& elementName)\r\n{\r\n   if (transactional->hasMasterPort())\r\n   {\r\n       writer.writeStartElement(elementName);\r\n       writeTransactionalPort(writer, transactional->getMasterPort());\r\n       writer.writeEndElement();\r\n   }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: TransactionalAbstractionWriter::Details::writeSlave()\r\n//-----------------------------------------------------------------------------\r\nvoid TransactionalAbstractionWriter::Details::writeSlave(QXmlStreamWriter& writer, \r\n    QSharedPointer<TransactionalAbstraction> transactional, QString const& elementName)\r\n{\r\n    if (transactional->hasSlavePort())\r\n    {\r\n        writer.writeStartElement(elementName);\r\n        writeTransactionalPort(writer, transactional->getSlavePort());\r\n        writer.writeEndElement();\r\n    }\r\n}\r\n"
  },
  {
    "path": "IPXACTmodels/AbstractionDefinition/TransactionalAbstractionWriter.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: TransactionalAbstractionWriter.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Esko Pekkarinen\r\n// Date: 21.08.2015\r\n//\r\n// Description:\r\n// Writer for IP-XACT Transactional element within abstraction definition.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef TRANSACTIONALABSTRACTIONWRITER_H\r\n#define TRANSACTIONALABSTRACTIONWRITER_H\r\n\r\n#include <IPXACTmodels/common/Document.h>\r\n\r\n#include <QObject>\r\n#include <QSharedPointer>\r\n#include <QXmlStreamWriter>\r\n\r\nclass TransactionalAbstraction;\r\nclass TransactionalPort;\r\nclass Protocol;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Writer for IP-XACT Transactional element within abstraction definition. \r\n//-----------------------------------------------------------------------------\r\nnamespace TransactionalAbstractionWriter\r\n{\r\n\r\n    /*!\r\n     *  Writes the given transactional description into XML.\r\n     *\r\n     *    @param [in] writer          The XML writer to use.\r\n     *    @param [in] transactional   The transactional to write.\r\n     *    @param [in] revision    The document standard revision to use.\r\n     */\r\n    IPXACTMODELS_EXPORT void writeTransactional(QXmlStreamWriter& writer, QSharedPointer<TransactionalAbstraction> transactional,\r\n        Document::Revision revision);\r\n\r\n    namespace Details\r\n    {\r\n        /*!\r\n         *  Writes the system port for the given transactional into XML.\r\n         *\r\n         *    @param [in] writer      The XML writer to use.\r\n         *    @param [in] wire        The transactional whose system port to write.\r\n         */\r\n        void writeSystem(QXmlStreamWriter& writer, QSharedPointer<TransactionalAbstraction> transactional);\r\n\r\n        /*!\r\n         *  Writes the transactional port on system/master/slave into XML.\r\n         *\r\n         *    @param [in] writer      The XML writer to use.\r\n         *    @param [in] port        The transactional port to write.\r\n         */\r\n        void writeTransactionalPort(QXmlStreamWriter& writer, QSharedPointer<TransactionalPort> port);\r\n\r\n        /*!\r\n         *  Writes the transactional port presence on system/master/slave into XML.\r\n         *\r\n         *    @param [in] writer      The XML writer to use.\r\n         *    @param [in] port        The transactional port whose presence to write.\r\n         */\r\n        void writePresence(QXmlStreamWriter& writer, QSharedPointer<TransactionalPort> port);\r\n\r\n        /*!\r\n         *  Writes the transactional port initiative on system/master/slave into XML.\r\n         *\r\n         *    @param [in] writer      The XML writer to use.\r\n         *    @param [in] port        The transactional port whose initiative to write.\r\n         */\r\n        void writeInitiative(QXmlStreamWriter& writer, QSharedPointer<TransactionalPort> port);\r\n\r\n        /*!\r\n         *  Writes the transactional port type on system/master/slave into XML.\r\n         *\r\n         *    @param [in] writer      The XML writer to use.\r\n         *    @param [in] port        The transactional port whose type to write.\r\n         */\r\n        void writeKind(QXmlStreamWriter& writer, QSharedPointer<TransactionalPort> port);\r\n\r\n        /*!\r\n         *  Writes the transactional port width in bits on system/master/slave into XML.\r\n         *\r\n         *    @param [in] writer      The XML writer to use.\r\n         *    @param [in] port        The transactional port whose width to write.\r\n         */\r\n        void writeBusWidth(QXmlStreamWriter& writer, QSharedPointer<TransactionalPort> port);\r\n\r\n        /*!\r\n         *  Writes the transactional port protocol vendor extensions on system/master/slave into XML.\r\n         *\r\n         *    @param [in] writer          The XML writer to use.\r\n         *    @param [in] portProtocol    The protocol whose vendor extensions to write.\r\n         */\r\n        void writeVendorExtensions(QXmlStreamWriter& writer, QSharedPointer<Protocol> portProtocol);\r\n\r\n        /*!\r\n         *  Writes the master port for the given transactional into XML.\r\n         *\r\n         *    @param [in] writer      The XML writer to use.\r\n         *    @param [in] wire        The transactional whose master port to write.\r\n         *    @param [in] elementName     The XML element name to use.\r\n         */\r\n        void writeMaster(QXmlStreamWriter& writer, QSharedPointer<TransactionalAbstraction> transactional,\r\n            QString const& elementName);\r\n\r\n        /*!\r\n         *  Writes the slave port for the given transactional into XML.\r\n         *\r\n         *    @param [in] writer          The XML writer to use.\r\n         *    @param [in] wire            The transactional whose slave port to write.\r\n         *    @param [in] elementName     The XML element name to use.\r\n         */\r\n        void writeSlave(QXmlStreamWriter& writer, QSharedPointer<TransactionalAbstraction> transactional,\r\n            QString const& elementName);\r\n    }\r\n};\r\n\r\n#endif // TRANSACTIONALABSTRACTIONWRITER_H"
  },
  {
    "path": "IPXACTmodels/AbstractionDefinition/TransactionalPort.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: TransactionalPort.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Esko Pekkarinen\r\n// Date: 21.08.2015\r\n//\r\n// Description:\r\n// Implementation for ipxact:transactionalPort.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"TransactionalPort.h\"\r\n\r\n#include <IPXACTmodels/common/Protocol.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: TransactionalPort::TransactionalPort()\r\n//-----------------------------------------------------------------------------\r\nTransactionalPort::TransactionalPort() : \r\nsystemGroup_(),\r\n    presence_(PresenceTypes::UNKNOWN), \r\n    initiative_(), \r\n    kind_(), \r\n    busWidth_(),\r\n    protocol_()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: TransactionalPort::TransactionalPort()\r\n//-----------------------------------------------------------------------------\r\nTransactionalPort::TransactionalPort(TransactionalPort const& other) :\r\nsystemGroup_(other.systemGroup_),\r\n    presence_(other.presence_),\r\n    initiative_(other.initiative_),\r\n    kind_(other.kind_),\r\n    busWidth_(other.busWidth_),\r\n    protocol_()\r\n{\r\n    if (other.protocol_)\r\n    {\r\n        protocol_ = QSharedPointer<Protocol>(new Protocol(*other.protocol_));\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: TransactionalPort::~TransactionalPort()\r\n//-----------------------------------------------------------------------------\r\nTransactionalPort::~TransactionalPort()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: TransactionalPort::setSystemGroup()\r\n//-----------------------------------------------------------------------------\r\nvoid TransactionalPort::setSystemGroup(QString const& group)\r\n{\r\n    systemGroup_ = group;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: TransactionalPort::getSystemGroup()\r\n//-----------------------------------------------------------------------------\r\nQString TransactionalPort::getSystemGroup() const\r\n{\r\n    return systemGroup_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: TransactionalPort::Presence()\r\n//-----------------------------------------------------------------------------\r\nvoid TransactionalPort::setPresence(PresenceTypes::Presence presence)\r\n{\r\n    presence_ = presence;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: TransactionalPort::Presence()\r\n//-----------------------------------------------------------------------------\r\nPresenceTypes::Presence TransactionalPort::getPresence() const\r\n{\r\n    return presence_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: TransactionalPort::setInitiative()\r\n//-----------------------------------------------------------------------------\r\nvoid TransactionalPort::setInitiative(QString const& initiative)\r\n{\r\n    initiative_ = initiative;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: TransactionalPort::getInitiative()\r\n//-----------------------------------------------------------------------------\r\nQString TransactionalPort::getInitiative() const\r\n{\r\n    return initiative_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: TransactionalPort::setKind()\r\n//-----------------------------------------------------------------------------\r\nvoid TransactionalPort::setKind(QString const& kind)\r\n{\r\n    kind_ = kind;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: TransactionalPort::getKind()\r\n//-----------------------------------------------------------------------------\r\nQString TransactionalPort::getKind() const\r\n{\r\n    return kind_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: TransactionalPort::setBusWidth()\r\n//-----------------------------------------------------------------------------\r\nvoid TransactionalPort::setBusWidth(QString const& widthExpression)\r\n{\r\n    busWidth_ = widthExpression;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: TransactionalPort::getBusWidth()\r\n//-----------------------------------------------------------------------------\r\nQString TransactionalPort::getBusWidth() const\r\n{\r\n    return busWidth_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: TransactionalPort::hasProtocol()\r\n//-----------------------------------------------------------------------------\r\nbool TransactionalPort::hasProtocol() const\r\n{\r\n    return !protocol_.isNull();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: TransactionalPort::setProtocol()\r\n//-----------------------------------------------------------------------------\r\nvoid TransactionalPort::setProtocol(QSharedPointer<Protocol> portProtocol)\r\n{\r\n    protocol_ = portProtocol;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: TransactionalPort::getProtocol()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<Protocol> TransactionalPort::getProtocol() const\r\n{\r\n    return protocol_;\r\n}\r\n"
  },
  {
    "path": "IPXACTmodels/AbstractionDefinition/TransactionalPort.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: TransactionalPort.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Esko Pekkarinen\r\n// Date: 21.08.2015\r\n//\r\n// Description:\r\n// Implementation for ipxact:transactionalPort.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef TRANSACTIONALPORT_H\r\n#define TRANSACTIONALPORT_H\r\n\r\n#include <IPXACTmodels/ipxactmodels_global.h>\r\n#include <IPXACTmodels/common/PresenceTypes.h>\r\n\r\n#include <IPXACTmodels/common/Qualifier.h>\r\n\r\n#include <QSharedPointer>\r\n\r\nclass Protocol;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Implementation for ipxact:transactionalPort. \r\n//-----------------------------------------------------------------------------\r\nclass IPXACTMODELS_EXPORT TransactionalPort\r\n{\r\npublic:\r\n    \r\n    //! The constructor.\r\n    TransactionalPort();\r\n\r\n    //! Copy constructor.\r\n    TransactionalPort(TransactionalPort const& other);\r\n\r\n    //! The destructor.\r\n    ~TransactionalPort();\r\n        \r\n    /*!\r\n     *  Sets the group name for system mode.\r\n     *\r\n     *    @param [in] groupName   The system group to set.\r\n     */\r\n    void setSystemGroup(QString const& group);\r\n        \r\n    /*!\r\n     *  Gets the group name for system mode.\r\n     *\r\n     *    @return The system group the transactional port belongs to.\r\n     */\r\n    QString getSystemGroup() const;\r\n\r\n    /*!\r\n     *  Sets the presence restriction for the port.\r\n     *\r\n     *    @param [in] presence   The restriction to set.\r\n     */\r\n    void setPresence(PresenceTypes::Presence presence);\r\n\r\n    /*!\r\n     *  Gets the presence restriction for the port.\r\n     *\r\n     *    @return The presence restriction for the port.\r\n     */\r\n    PresenceTypes::Presence getPresence() const;\r\n\r\n    /*!\r\n     *  Sets the access type for the transactional port.\r\n     *\r\n     *    @param [in] initiative   The access type to set.\r\n     */\r\n    void setInitiative(QString const& initiative);\r\n    \r\n    /*!\r\n     *  Gets the access type for the transactional port.\r\n     *\r\n     *    @return The access type for the port.\r\n     */\r\n    QString getInitiative() const;\r\n\r\n    /*!\r\n     *  Sets the port type.\r\n     *\r\n     *    @param [in] kind   The port type to set.\r\n     */\r\n    void setKind(QString const& kind);\r\n    \r\n    /*!\r\n     *  Gets the port type.\r\n     *\r\n     *    @return The port type.\r\n     */\r\n    QString getKind() const;\r\n\r\n    /*!\r\n     *  Sets the data width on the bus.\r\n     *\r\n     *    @param [in] widthExpression   The number of bits on the bus.\r\n     */\r\n    void setBusWidth(QString const& widthExpression);\r\n    \r\n    /*!\r\n     *  Gets the data width on the bus.\r\n     *\r\n     *    @return The number of bits on the bus.\r\n     */\r\n    QString getBusWidth() const;\r\n    \r\n    /*!\r\n     *  Checks if a protocol has been defined for the port.\r\n     *\r\n     *\r\n     *    @return True, if a protocol is defined, otherwise false.\r\n     */\r\n    bool hasProtocol() const;\r\n\r\n    /*!\r\n     *  Sets the protocol for the information transportation.\r\n     *\r\n     *    @param [in] portProtocol   The protocol to use on the port.\r\n     */\r\n    void setProtocol(QSharedPointer<Protocol> portProtocol);\r\n\r\n    /*!\r\n     *  Gets the protocol for the information transportation.\r\n     *\r\n     *    @return The protocol used on the port.\r\n     */\r\n    QSharedPointer<Protocol> getProtocol() const;\r\n\r\nprivate:\r\n\r\n    // Disable assignment.\r\n    TransactionalPort& operator=(TransactionalPort const& rhs);\r\n\r\n    //! The group this transactional port belongs to in system mode.\r\n    QString systemGroup_;\r\n    \r\n    //! Defines if the port is required or forbidden in a bus interface.\r\n    PresenceTypes::Presence presence_;\r\n\r\n    //! Defines the access type for the port.\r\n    QString initiative_;\r\n\r\n    //! Defines the port type.\r\n    QString kind_;\r\n\r\n    //! Defines the bus width.\r\n    QString busWidth_;\r\n\r\n    //! The protocol to use by the port.\r\n    QSharedPointer<Protocol> protocol_;\r\n\r\n};\r\n\r\n#endif // TRANSACTIONALPORT_H"
  },
  {
    "path": "IPXACTmodels/AbstractionDefinition/WireAbstraction.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: WireAbstraction.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Esko Pekkarinen\r\n// Date: 12.08.2015\r\n//\r\n// Description:\r\n// Implementation for ipxact:wire within abstraction definition.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"WireAbstraction.h\"\r\n\r\n#include \"WirePort.h\"\r\n\r\n#include <IPXACTmodels/utilities/Copy.h>\r\n\r\n#include <QSharedPointer>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: WireAbstraction::WireAbstraction()\r\n//-----------------------------------------------------------------------------\r\nWireAbstraction::WireAbstraction(WireAbstraction const& other):\r\nqualifier_(new Qualifier(*other.qualifier_)),\r\n    defaultValue_(other.defaultValue_),\r\n    requiresDriver_(other.requiresDriver_),\r\n    driverType_(other.driverType_)\r\n{\r\n    if (other.onInitiator_)\r\n    {\r\n        onInitiator_ = QSharedPointer<WirePort>(new WirePort(*other.onInitiator_));\r\n    }\r\n\r\n    if (other.onTarget_)\r\n    {\r\n        onTarget_ = QSharedPointer<WirePort>(new WirePort(*other.onTarget_));\r\n    } \r\n\r\n    Copy::copyList(other.onSystem_, onSystem_);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: WireAbstraction::operator=()\r\n//-----------------------------------------------------------------------------\r\nWireAbstraction& WireAbstraction::operator=(WireAbstraction const& other)\r\n{\r\n\tif (this != &other)\r\n    {\r\n        qualifier_ = other.qualifier_;\r\n\t\tdefaultValue_ = other.defaultValue_;\r\n\t\trequiresDriver_ = other.requiresDriver_;\r\n        driverType_ = other.driverType_;\r\n      \r\n        onInitiator_.clear();\r\n\t\tif (other.onInitiator_)\r\n        {\r\n\t\t\tonInitiator_ = QSharedPointer<WirePort>(new WirePort(*other.onInitiator_));\r\n\t\t}\r\n\r\n        onTarget_.clear();\r\n\t\tif (other.onTarget_)\r\n        {\r\n\t\t\tonTarget_ = QSharedPointer<WirePort>(new WirePort(*other.onTarget_));\r\n\t\t}\r\n  \r\n        onSystem_->clear();\r\n        Copy::copyList(other.onSystem_, onSystem_);\r\n\t}\r\n\treturn *this;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: WireAbstraction::~WireAbstraction()\r\n//-----------------------------------------------------------------------------\r\nWireAbstraction::~WireAbstraction()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: WireAbstraction::setDefaultValue()\r\n//-----------------------------------------------------------------------------\r\nvoid WireAbstraction::setDefaultValue(QString const& defaultValue)\r\n{\r\n    requiresDriver_ = false;\r\n    driverType_ = General::NO_DRIVER;\r\n\r\n    defaultValue_ = defaultValue;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: WireAbstraction::getDefaultValue()\r\n//-----------------------------------------------------------------------------\r\nQString WireAbstraction::getDefaultValue() const\r\n{\r\n    return defaultValue_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: WireAbstraction::setQualifier()\r\n//-----------------------------------------------------------------------------\r\nvoid WireAbstraction::setQualifier(QSharedPointer<Qualifier> qualifier)\r\n{\r\n    qualifier_ = qualifier;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: WireAbstraction::addQualifier()\r\n//-----------------------------------------------------------------------------\r\nvoid WireAbstraction::addQualifier(Qualifier::Type qualifierType)\r\n{\r\n    qualifier_->setType(qualifierType);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: WireAbstraction::getQualifier()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<Qualifier> WireAbstraction::getQualifier()\r\n{\r\n    return qualifier_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: WireAbstraction::addSystemPort()\r\n//-----------------------------------------------------------------------------\r\nvoid WireAbstraction::addSystemPort(QSharedPointer<WirePort> systemPort)\r\n{\r\n    if (!onSystem_->contains(systemPort))\r\n    {\r\n        onSystem_->append(systemPort);\r\n    }    \r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: WireAbstraction::getSystemPort()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<QList<QSharedPointer<WirePort> > > WireAbstraction::getSystemPorts() const\r\n{\r\n    return onSystem_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: WireAbstraction::findSystemPort()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<WirePort> WireAbstraction::findSystemPort(QString const& groupName) const\r\n{\r\n    auto it = std::find_if(onSystem_->cbegin(), onSystem_->cend(), [&groupName](auto const& systemPort)\r\n        {\r\n            return systemPort->getSystemGroup() == groupName;\r\n        });\r\n\r\n    if (it == onSystem_->cend())\r\n    {\r\n        return nullptr;\r\n    }\r\n\r\n    return *it;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: WireAbstraction::hasInitiatorPort()\r\n//-----------------------------------------------------------------------------\r\nbool WireAbstraction::hasInitiatorPort() const\r\n{\r\n    return !onInitiator_.isNull();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: WireAbstraction::setInitiatorPort()\r\n//-----------------------------------------------------------------------------\r\nvoid WireAbstraction::setInitiatorPort(QSharedPointer<WirePort> initiatorPort)\r\n{\r\n    onInitiator_ = initiatorPort;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: WireAbstraction::getInitiatorPort()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<WirePort> WireAbstraction::getInitiatorPort() const\r\n{\r\n    return onInitiator_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: WireAbstraction::hasTargetPort()\r\n//-----------------------------------------------------------------------------\r\nbool WireAbstraction::hasTargetPort() const\r\n{\r\n    return !onTarget_.isNull();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: WireAbstraction::setTargetPort()\r\n//-----------------------------------------------------------------------------\r\nvoid WireAbstraction::setTargetPort(QSharedPointer<WirePort> targetPort)\r\n{\r\n    onTarget_ = targetPort;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: WireAbstraction::getTargetPort()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<WirePort> WireAbstraction::getTargetPort() const\r\n{\r\n    return onTarget_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: WireAbstraction::hasMasterPort()\r\n//-----------------------------------------------------------------------------\r\nbool WireAbstraction::hasMasterPort() const\r\n{\r\n    return hasInitiatorPort();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: WireAbstraction::setMasterPort()\r\n//-----------------------------------------------------------------------------\r\nvoid WireAbstraction::setMasterPort(QSharedPointer<WirePort> masterPort)\r\n{\r\n    setInitiatorPort(masterPort);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: WireAbstraction::getMasterPort()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<WirePort> WireAbstraction::getMasterPort() const\r\n{\r\n    return getInitiatorPort();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: WireAbstraction::hasSlavePort()\r\n//-----------------------------------------------------------------------------\r\nbool WireAbstraction::hasSlavePort() const\r\n{\r\n    return hasTargetPort();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: WireAbstraction::setSlavePort()\r\n//-----------------------------------------------------------------------------\r\nvoid WireAbstraction::setSlavePort(QSharedPointer<WirePort> slavePort)\r\n{\r\n    setTargetPort(slavePort);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: WireAbstraction::getSlavePort()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<WirePort> WireAbstraction::getSlavePort() const\r\n{\r\n    return getTargetPort();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: WireAbstraction::setRequiresDriver()\r\n//-----------------------------------------------------------------------------\r\nvoid WireAbstraction::setRequiresDriver(bool requiresDriver)\r\n{\r\n    if (requiresDriver) \r\n    {\r\n        defaultValue_.clear();\r\n    }\r\n\r\n    requiresDriver_ = requiresDriver;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: WireAbstraction::requiresDriver()\r\n//-----------------------------------------------------------------------------\r\nbool WireAbstraction::requiresDriver() const\r\n{\r\n    return requiresDriver_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: WireAbstraction::setDriverType()\r\n//-----------------------------------------------------------------------------\r\nvoid WireAbstraction::setDriverType(General::DriverType driverType)\r\n{\r\n    setRequiresDriver(driverType != General::NO_DRIVER);\r\n\r\n    driverType_ = driverType;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: WireAbstraction::getDriverType()\r\n//-----------------------------------------------------------------------------\r\nGeneral::DriverType WireAbstraction::getDriverType() const\r\n{\r\n    return driverType_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: WireAbstraction::getDirection()\r\n//-----------------------------------------------------------------------------\r\nDirectionTypes::Direction WireAbstraction::getDirection(General::InterfaceMode mode,\r\n    QString const& systemGroup) const\r\n{\r\n    if ((mode == General::MASTER || mode == General::INITIATOR) && hasMasterPort())\r\n    {\r\n        return getMasterPort()->getDirection();\r\n    } \r\n    else if ((mode == General::MIRRORED_MASTER || mode == General::MIRRORED_INITIATOR) && hasMasterPort())\r\n    {\r\n        return DirectionTypes::convert2Mirrored(getMasterPort()->getDirection());\r\n    }\r\n    else if ((mode == General::SLAVE || mode == General::TARGET) && hasSlavePort())\r\n    {\r\n        return getSlavePort()->getDirection();\r\n    }                       \r\n    else if ((mode == General::MIRRORED_SLAVE || mode == General::MIRRORED_TARGET) && hasSlavePort())\r\n    {\r\n        return DirectionTypes::convert2Mirrored(getSlavePort()->getDirection());\r\n    }   \r\n    else if (mode == General::SYSTEM)\r\n    {\r\n        if (QSharedPointer<WirePort> systemPort = findSystemPort(systemGroup))\r\n        {\r\n            return systemPort->getDirection();\r\n        }\r\n    } \r\n    else if (mode == General::MIRRORED_SYSTEM)\r\n    {\r\n        if (QSharedPointer<WirePort> systemPort = findSystemPort(systemGroup))\r\n        {\r\n            return DirectionTypes::convert2Mirrored(systemPort->getDirection());\r\n        }\r\n    }\r\n\r\n    return DirectionTypes::DIRECTION_INVALID;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: WireAbstraction::getWidth()\r\n//-----------------------------------------------------------------------------\r\nQString WireAbstraction::getWidth(General::InterfaceMode mode, QString const& systemGroup) const\r\n{\r\n    if ((mode == General::MASTER || mode == General::MIRRORED_MASTER || \r\n        mode == General::INITIATOR || mode == General::MIRRORED_INITIATOR) && \r\n        hasMasterPort())\r\n    {\r\n        return getMasterPort()->getWidth();\r\n    } \r\n    else if ((mode == General::SLAVE || mode == General::MIRRORED_SLAVE ||\r\n        mode == General::TARGET || mode == General::MIRRORED_TARGET) &&\r\n        hasSlavePort())\r\n    {\r\n        return getSlavePort()->getWidth();\r\n    }                        \r\n    else if (mode == General::SYSTEM || mode == General::MIRRORED_SYSTEM)\r\n    {\r\n        if (QSharedPointer<WirePort> systemPort = findSystemPort(systemGroup))\r\n        {\r\n            return systemPort->getWidth();\r\n        }\r\n    } \r\n\r\n    return QString();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: WireAbstraction::hasMode()\r\n//-----------------------------------------------------------------------------\r\nbool WireAbstraction::hasMode(General::InterfaceMode mode, QString const& systemGroup) const\r\n{\r\n    if (mode == General::SYSTEM || mode == General::MIRRORED_SYSTEM)\r\n    {\r\n        QSharedPointer<WirePort> systemPort = findSystemPort(systemGroup);\r\n\r\n        return !systemPort.isNull();\r\n    }\r\n\r\n    return (mode == General::MASTER && hasMasterPort()) ||\r\n        (mode == General::MIRRORED_MASTER && hasMasterPort()) ||\r\n        (mode == General::INITIATOR && hasMasterPort()) ||\r\n        (mode == General::MIRRORED_INITIATOR && hasMasterPort()) ||\r\n        (mode == General::SLAVE && hasSlavePort()) ||\r\n        (mode == General::MIRRORED_SLAVE && hasSlavePort()) ||\r\n        (mode == General::TARGET && hasSlavePort()) ||\r\n        (mode == General::MIRRORED_TARGET && hasSlavePort());\r\n}\r\n"
  },
  {
    "path": "IPXACTmodels/AbstractionDefinition/WireAbstraction.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: WireAbstraction.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Esko Pekkarinen\r\n// Date: 12.08.2015\r\n//\r\n// Description:\r\n// Implementation for ipxact:wire within abstraction definition.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef WIREABSTRACTION_H\r\n#define WIREABSTRACTION_H\r\n\r\n#include <IPXACTmodels/ipxactmodels_global.h>\r\n#include <IPXACTmodels/generaldeclarations.h>\r\n\r\n#include <IPXACTmodels/common/DirectionTypes.h>\r\n#include <IPXACTmodels/common/Qualifier.h>\r\n\r\n#include <QSharedPointer>\r\n\r\nclass WirePort;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Implementation for ipxact:wire within abstraction definition.\r\n//-----------------------------------------------------------------------------\r\nclass IPXACTMODELS_EXPORT WireAbstraction\r\n{\r\npublic:\r\n    //! The default constructor.\r\n    WireAbstraction() = default;\r\n\r\n\t//! Copy constructor.\r\n\tWireAbstraction(const WireAbstraction& other);\r\n\r\n\t//! Assignment operator.\r\n\tWireAbstraction& operator=(const WireAbstraction& other);\r\n\r\n\t//! The destructor.\r\n\t~WireAbstraction();\r\n\r\n    /*! Sets the default value for this wire.\r\n\t *\r\n\t *    @param [in] defaultValue    The new default value.\r\n\t */\r\n\tvoid setDefaultValue(QString const& defaultValue);\r\n\r\n\t/*! Gets the default value of this wire.\r\n\t *\r\n\t *    @return The default value\r\n\t */\r\n\tQString getDefaultValue() const;\r\n\r\n    /*!\r\n     *  Sets a qualifier for the information the wire carries.\r\n     *\r\n     *    @param [in] qualifier   The qualifier to set.\r\n     */\r\n    void setQualifier(QSharedPointer<Qualifier> qualifier);\r\n    \r\n    /*!\r\n     *  Add a qualifier type for the information the wire carries.\r\n     *\r\n     *    @param [in] qualifierType   The qualifier type to add.\r\n     */\r\n    void addQualifier(Qualifier::Type qualifierType);\r\n    \r\n    /*!\r\n     *  Gets the qualifier for the information the wire carries.\r\n     *\r\n     *    @return The wire qualifier.\r\n     */\r\n\tQSharedPointer<Qualifier> getQualifier();\r\n\r\n    /*!\r\n     *  Adds a system port definition for the wire.\r\n     *\r\n     *    @param [in] systemPort   The system wire port to add.\r\n     */\r\n    void addSystemPort(QSharedPointer<WirePort> systemPort);\r\n\r\n    /*!\r\n     *  Gets the system port definitions for the wire.\r\n     *\r\n     *    @return The system ports for the wire.\r\n     */\r\n    QSharedPointer<QList<QSharedPointer<WirePort> > > getSystemPorts() const;\r\n    \r\n    /*!\r\n     *  Finds system port corresponding the name.\r\n     *\r\n     *    @return The wire port corresponding the name if it exists, else null.\r\n     */\r\n    QSharedPointer<WirePort> findSystemPort(QString const& groupName) const;\r\n\r\n    /*!\r\n     *  Checks if the wire has a port definition for initiator mode.\r\n     *\r\n     *    @return True, if initiator mode is defined, otherwise false.\r\n     */\r\n    bool hasInitiatorPort() const;\r\n\r\n    /*!\r\n     *  Sets the initiator mode port definitions for the wire.\r\n     *\r\n     *    @param [in] initiatorPort The initiator port definition for the wire.\r\n     */\r\n    void setInitiatorPort(QSharedPointer<WirePort> initiatorPort);\r\n\r\n    /*!\r\n     *  Gets the initiator mode port definitions for the wire.\r\n     *\r\n     *    @return The initiator port definition for the wire.\r\n     */\r\n    QSharedPointer<WirePort> getInitiatorPort() const;\r\n\r\n    /*!\r\n     *  Checks if the wire has a port definition for target mode.\r\n     *\r\n     *    @return True, if target mode is defined, otherwise false.\r\n     */\r\n    bool hasTargetPort() const;\r\n\r\n    /*!\r\n     *  Sets the target mode port definitions for the wire.\r\n     *\r\n     *    @param [in] slavePort The target port definition for the wire.\r\n     */\r\n    void setTargetPort(QSharedPointer<WirePort> targetPort);\r\n\r\n    /*!\r\n     *  Gets the target mode port definitions for the wire.\r\n     *\r\n     *    @return The target port definition for the wire.\r\n     */\r\n    QSharedPointer<WirePort> getTargetPort() const;\r\n\r\n    /*!\r\n     *  Checks if the wire has a port definition for master mode.\r\n     *\r\n     *    @return True, if master mode is defined, otherwise false.\r\n     */\r\n    bool hasMasterPort() const;\r\n    \r\n    /*!\r\n     *  Sets the master mode port definitions for the wire.\r\n     *\r\n     *    @param [in] masterPort The master port definition for the wire.\r\n     */\r\n    void setMasterPort(QSharedPointer<WirePort> masterPort);\r\n    \r\n    /*!\r\n     *  Gets the master mode port definitions for the wire.\r\n     *\r\n     *    @return The master port definition for the wire.\r\n     */\r\n    QSharedPointer<WirePort> getMasterPort() const;\r\n\r\n    /*!\r\n     *  Checks if the wire has a port definition for slave mode.\r\n     *\r\n     *    @return True, if slave mode is defined, otherwise false.\r\n     */\r\n    bool hasSlavePort() const;\r\n  \r\n    /*!\r\n     *  Sets the slave mode port definitions for the wire.\r\n     *\r\n     *    @param [in] slavePort The slave port definition for the wire.\r\n     */\r\n    void setSlavePort(QSharedPointer<WirePort> slavePort);\r\n        \r\n    /*!\r\n     *  Gets the slave mode port definitions for the wire.\r\n     *\r\n     *    @return The slave port definition for the wire.\r\n     */\r\n    QSharedPointer<WirePort> getSlavePort() const;\r\n    \r\n    /*!\r\n     *  Sets the wire to require a driver or not.\r\n     *\r\n     *    @param [in] requiresDriver   The r.\r\n     *\r\n     *    @return <Description>.\r\n     */\r\n    void setRequiresDriver(bool requiresDriver);\r\n\r\n    /*!\r\n     *  Checks if the wire requires a driver.\r\n     *\r\n     *    @return True, if the wire requires a driver, otherwise false.\r\n     */\r\n    bool requiresDriver() const;\r\n\r\n    /*! Sets the driver type for this wire.\r\n\t *\t \r\n\t *    @param [in] driverType The driver type to set.\r\n\t */\r\n\tvoid setDriverType(General::DriverType driverType);\r\n    \r\n    /*! Gets the driver type for this wire.\r\n\t *\t \r\n\t *    @return The driver type for this wire.\r\n\t */\r\n\tGeneral::DriverType getDriverType() const;\r\n\r\n    /*!\r\n     *  Gets the wire direction for a given interface mode.\r\n     *\r\n     *    @param [in] mode            The mode to get the direction for.\r\n     *    @param [in] systemGroup     The system group to get direction for.\r\n     *\r\n     *    @return The direction of the wire for the given interface mode.\r\n     */\r\n    DirectionTypes::Direction getDirection(General::InterfaceMode mode,\r\n        QString const& systemGroup) const;\r\n\r\n    /*!\r\n     *  Gets the wire width for a given interface mode.\r\n     *\r\n     *    @param [in] mode            The mode to get the width for.\r\n     *    @param [in] systemGroup     The system group to get width for.\r\n     *\r\n     *    @return The width of the wire for the given interface mode.\r\n     */\r\n    QString getWidth(General::InterfaceMode mode, QString const& systemGroup) const;\r\n\r\n    /*!\r\n     *  Check if the wire has the selected interface mode.\r\n     *\r\n     *    @param [in] mode            The selected interface mode.\r\n     *    @param [in] systemGroup     The selected interface system group.\r\n     *\r\n     *    @return True, if the wire has the selected mode, otherwise false.\r\n     */\r\n    bool hasMode(General::InterfaceMode mode, QString const& systemGroup) const;\r\n\r\nprivate:\r\n\r\n    //! The qualifier describing the information the wire carries.\r\n    QSharedPointer<Qualifier> qualifier_ = QSharedPointer<Qualifier>(new Qualifier());\r\n\r\n    //! The default value for the wire.\r\n    QString defaultValue_;\r\n    \r\n    //! Specifies whether the port requires a driver.\r\n    bool requiresDriver_{ false };\r\n\r\n    //! Specifies the required driver type.\r\n    General::DriverType driverType_{ General::NO_DRIVER };\r\n\r\n    //! The port definition for initiator mode.\r\n    QSharedPointer<WirePort> onInitiator_{ nullptr };\r\n\r\n    //! The port definition for target mode.\r\n    QSharedPointer<WirePort> onTarget_{ nullptr };\r\n\r\n    //! The port definitions for system mode.\r\n    QSharedPointer<QList<QSharedPointer<WirePort> > > onSystem_{ new QList<QSharedPointer<WirePort> >() };\r\n\r\n};\r\n\r\n#endif /* WIREABSTRACTION_H_ */\r\n"
  },
  {
    "path": "IPXACTmodels/AbstractionDefinition/WireAbstractionReader.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: WireAbstractionReader.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Esko Pekkarinen\r\n// Date: 18.08.2015\r\n//\r\n// Description:\r\n// Reader for ipxact:wire within abstraction definition.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"WireAbstractionReader.h\"\r\n\r\n#include <IPXACTmodels/common/CellSpecification.h>\r\n#include <IPXACTmodels/common/QualifierReader.h>\r\n#include <IPXACTmodels/generaldeclarations.h>\r\n\r\n#include <IPXACTmodels/common/CommonItemsReader.h>\r\n\r\n#include <IPXACTmodels/common/TimingConstraint.h>\r\n#include \"WireAbstraction.h\"\r\n#include \"WirePort.h\"\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: WireAbstractionReader::createWireAbstractionFrom()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<WireAbstraction> WireAbstractionReader::createWireAbstractionFrom(QDomNode const& wireNode,\r\n    Document::Revision revision)\r\n{\r\n    QSharedPointer<WireAbstraction> wire(new WireAbstraction());\r\n\r\n    Details::parseQualifier(wireNode, wire, revision);\r\n\r\n    Details::parseSystems(wireNode, wire, revision);\r\n\r\n    Details::parseInitiator(wireNode, wire, revision);\r\n\r\n    Details::parseTarget(wireNode, wire, revision);\r\n\r\n    wire->setDefaultValue(wireNode.firstChildElement(QStringLiteral(\"ipxact:defaultValue\")).firstChild().nodeValue());\r\n\r\n    QDomElement driverNode = wireNode.firstChildElement(QStringLiteral(\"ipxact:requiresDriver\"));\r\n    if (!driverNode.isNull())\r\n    {\r\n        bool requiresDriver = driverNode.firstChild().nodeValue() == QStringLiteral(\"true\");\r\n        if (requiresDriver)\r\n        {\r\n            wire->setDriverType(General::str2DriverType(driverNode.attribute(QStringLiteral(\"driverType\")),\r\n                General::ANY));\r\n            wire->setRequiresDriver(true);\r\n        }\r\n    }\r\n\r\n    return wire;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: WireAbstractionReader::parseQualifier()\r\n//-----------------------------------------------------------------------------\r\nvoid WireAbstractionReader::Details::parseQualifier(QDomNode const& wireNode,\r\n    QSharedPointer<WireAbstraction> wire, Document::Revision revision)\r\n{\r\n    QDomNode qualifierNode = wireNode.firstChildElement(QStringLiteral(\"ipxact:qualifier\"));\r\n\r\n    auto qualifier = wire->getQualifier();\r\n\r\n    QualifierReader::parseQualifier(qualifierNode, qualifier, revision);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: WireAbstractionReader::parseSystems()\r\n//-----------------------------------------------------------------------------\r\nvoid WireAbstractionReader::Details::parseSystems(QDomNode const& wireNode, \r\n    QSharedPointer<WireAbstraction> wire, Document::Revision revision)\r\n{\r\n    QDomNodeList systemNodes = wireNode.toElement().elementsByTagName(QStringLiteral(\"ipxact:onSystem\"));\r\n\r\n    for (int i = 0; i < systemNodes.count(); i++)\r\n    {\r\n        QDomNode systemNode = systemNodes.at(i);\r\n\r\n        QSharedPointer<WirePort> system = parseWirePort(systemNode, revision);\r\n        system->setSystemGroup(systemNode.firstChildElement(QStringLiteral(\"ipxact:group\")).firstChild().nodeValue());\r\n        wire->addSystemPort(system);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: WireAbstractionReader::parseWirePort()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<WirePort> WireAbstractionReader::Details::parseWirePort(QDomNode const& wirePortNode,\r\n    Document::Revision revision)\r\n{\r\n    QSharedPointer<WirePort> wirePort(new WirePort());\r\n\r\n    QDomNode presenceNode = wirePortNode.firstChildElement(QStringLiteral(\"ipxact:presence\"));\r\n    wirePort->setPresence(PresenceTypes::str2Presence(presenceNode.firstChild().nodeValue(),\r\n        PresenceTypes::UNKNOWN));\r\n\r\n    auto widthElement = wirePortNode.firstChildElement(QStringLiteral(\"ipxact:width\")).firstChild();\r\n\r\n    wirePort->setWidth(widthElement.nodeValue());\r\n\r\n    if (revision == Document::Revision::Std22)\r\n    {\r\n        wirePort->setAllBits(\r\n            widthElement.attributes().namedItem(QStringLiteral(\"allBits\")).nodeValue() == QStringLiteral(\"true\"));\r\n    }\r\n\r\n    QDomNode directionNode = wirePortNode.firstChildElement(QStringLiteral(\"ipxact:direction\"));\r\n    wirePort->setDirection(DirectionTypes::str2Direction(directionNode.firstChild().nodeValue(),\r\n        DirectionTypes::DIRECTION_INVALID));\r\n\r\n    parseConstraints(wirePortNode, wirePort);\r\n\r\n    parseMirroredConstraints(wirePortNode, wirePort);\r\n\r\n    return wirePort;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: WireAbstractionReader::parseConstraints()\r\n//-----------------------------------------------------------------------------\r\nvoid WireAbstractionReader::Details::parseConstraints(QDomNode const& wirePortNode, QSharedPointer<WirePort> wirePort)\r\n{\r\n    QDomNode constraintsNode = wirePortNode.firstChildElement(QStringLiteral(\"ipxact:modeConstraints\"));\r\n    if (!constraintsNode.isNull())\r\n    {\r\n        QDomElement timingNode = constraintsNode.firstChildElement(QStringLiteral(\"ipxact:timingConstraint\"));\r\n        if (!timingNode.isNull())\r\n        {\r\n            wirePort->setTimingConstraint(parseTimingConstraint(timingNode));\r\n        }\r\n\r\n        QDomNode loadNode = constraintsNode.firstChildElement(QStringLiteral(\"ipxact:loadConstraint\"));\r\n        if (!loadNode.isNull())\r\n        {\r\n            wirePort->setLoadConstraint(parseCellSpecification(loadNode.firstChildElement()));\r\n        }\r\n\r\n        QDomNode driveNode = constraintsNode.firstChildElement(QStringLiteral(\"ipxact:driveConstraint\"));\r\n        if (!driveNode.isNull())\r\n        {\r\n            wirePort->setDriveConstraint(parseCellSpecification(driveNode.firstChildElement()));\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: WireAbstractionReader::parseTimingConstraint()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<TimingConstraint> WireAbstractionReader::Details::parseTimingConstraint(QDomElement const& timingNode)\r\n{\r\n    QSharedPointer<TimingConstraint> timingConstraint(new TimingConstraint());\r\n\r\n    QString clockEdge = timingNode.attribute(QStringLiteral(\"clockEdge\"));\r\n    if (clockEdge == QLatin1String(\"fall\"))\r\n    {\r\n        timingConstraint->setClockEdge(TimingConstraint::FALL);\r\n    }\r\n    else if (clockEdge == QStringLiteral(\"rise\"))\r\n    {\r\n        timingConstraint->setClockEdge(TimingConstraint::RISE);\r\n    }\r\n\r\n    QString delay = timingNode.attribute(QStringLiteral(\"delayType\"));\r\n    if (delay == QLatin1String(\"min\"))\r\n    {\r\n        timingConstraint->setDelayType(TimingConstraint::MINIMUM_DELAY);\r\n    }\r\n    else if (delay == QLatin1String(\"max\"))\r\n    {\r\n        timingConstraint->setDelayType(TimingConstraint::MAXIMUM_DELAY);\r\n    }\r\n\r\n    timingConstraint->setClockName(timingNode.attribute(QStringLiteral(\"clockName\")));\r\n\r\n    timingConstraint->setValue(timingNode.firstChild().nodeValue().toDouble());\r\n\r\n    return timingConstraint;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: WireAbstractionReader::parseCellSpecification()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<CellSpecification> WireAbstractionReader::Details::parseCellSpecification(QDomElement const& cellNode)\r\n{\r\n    QSharedPointer<CellSpecification> cellSpecification(new CellSpecification());\r\n\r\n    QString cellStrength = cellNode.attribute(QStringLiteral(\"cellStrength\"));\r\n    if (cellStrength == QLatin1String(\"low\"))\r\n    {\r\n        cellSpecification->setCellStrength(CellSpecification::LOW);\r\n    }\r\n    else if (cellStrength == QLatin1String(\"median\"))\r\n    {\r\n        cellSpecification->setCellStrength(CellSpecification::MEDIAN);\r\n    }\r\n    else if (cellStrength == QLatin1String(\"high\"))\r\n    {\r\n        cellSpecification->setCellStrength(CellSpecification::HIGH);\r\n    }\r\n\r\n    QString cellFunction = cellNode.firstChildElement(QStringLiteral(\"ipxact:cellFunction\")).firstChild().nodeValue();\r\n    if (cellFunction == QLatin1String(\"other\"))\r\n    {\r\n        cellSpecification->setCellFunction(\r\n            cellNode.firstChildElement(QStringLiteral(\"ipxact:cellFunction\")).attribute(QStringLiteral(\"other\")));\r\n    }\r\n    else\r\n    {\r\n        cellSpecification->setCellFunction(cellFunction);\r\n    }\r\n\r\n    QString cellClass = cellNode.firstChildElement(QStringLiteral(\"ipxact:cellClass\")).firstChild().nodeValue();\r\n    if (cellClass == QLatin1String(\"sequential\"))\r\n    {\r\n        cellSpecification->setCellClass(CellSpecification::SEQUENTIAL);\r\n    }\r\n    else if (cellClass == QLatin1String(\"combinatorial\"))\r\n    {\r\n        cellSpecification->setCellClass(CellSpecification::COMBINATORIAL);\r\n    }\r\n\r\n    return cellSpecification;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: WireAbstractionReader::parseMirroredConstraints()\r\n//-----------------------------------------------------------------------------\r\nvoid WireAbstractionReader::Details::parseMirroredConstraints(QDomNode const& wirePortNode,\r\n    QSharedPointer<WirePort> wirePort)\r\n{\r\n    QDomNode constraintsNode = wirePortNode.firstChildElement(QStringLiteral(\"ipxact:mirroredModeConstraints\"));\r\n    if (!constraintsNode.isNull())\r\n    {\r\n        QDomElement timingNode = constraintsNode.firstChildElement(QStringLiteral(\"ipxact:timingConstraint\"));\r\n        if (!timingNode.isNull())\r\n        {\r\n            wirePort->setMirroredTimingConstraint(parseTimingConstraint(timingNode));\r\n        }\r\n\r\n        QDomNode loadNode = constraintsNode.firstChildElement(QStringLiteral(\"ipxact:loadConstraint\"));\r\n        if (!loadNode.isNull())\r\n        {\r\n            wirePort->setMirroredLoadConstraint(parseCellSpecification(loadNode.firstChildElement()));\r\n        }\r\n\r\n        QDomNode driveNode = constraintsNode.firstChildElement(QStringLiteral(\"ipxact:driveConstraint\"));\r\n        if (!driveNode.isNull())\r\n        {\r\n            wirePort->setMirroredDriveConstraint(parseCellSpecification(driveNode.firstChildElement()));\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: WireAbstractionReader::parseInitiator()\r\n//-----------------------------------------------------------------------------\r\nvoid WireAbstractionReader::Details::parseInitiator(QDomNode const& wireNode, \r\n    QSharedPointer<WireAbstraction> wire, Document::Revision revision)\r\n{\r\n    QString elementName = revision == Document::Revision::Std22\r\n        ? QStringLiteral(\"ipxact:onInitiator\")\r\n        : QStringLiteral(\"ipxact:onMaster\");\r\n\r\n    QDomNode initiatorNode = wireNode.firstChildElement(elementName);\r\n    if (!initiatorNode.isNull())\r\n    {\r\n        QSharedPointer<WirePort> initiator = parseWirePort(initiatorNode, revision);\r\n        wire->setInitiatorPort(initiator);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: WireAbstractionReader::parseTarget()\r\n//-----------------------------------------------------------------------------\r\nvoid WireAbstractionReader::Details::parseTarget(QDomNode const& wireNode, QSharedPointer<WireAbstraction> wire,\r\n    Document::Revision revision)\r\n{\r\n\r\n    QString elementName = revision == Document::Revision::Std22\r\n        ? QStringLiteral(\"ipxact:onTarget\")\r\n        : QStringLiteral(\"ipxact:onSlave\");\r\n\r\n    QDomNode targetNode = wireNode.firstChildElement(elementName);\r\n    if (!targetNode.isNull())\r\n    {\r\n        QSharedPointer<WirePort> target = parseWirePort(targetNode, revision);\r\n        wire->setTargetPort(target);\r\n    }\r\n}\r\n"
  },
  {
    "path": "IPXACTmodels/AbstractionDefinition/WireAbstractionReader.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: WireAbstractionReader.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Esko Pekkarinen\r\n// Date: 18.08.2015\r\n//\r\n// Description:\r\n// Reader for ipxact:wire within abstraction definition.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef WIREABSTRACTIONREADER_H\r\n#define WIREABSTRACTIONREADER_H\r\n\r\n#include <QDomNode>\r\n#include <QObject>\r\n#include <QSharedPointer>\r\n\r\n#include <IPXACTmodels/common/Document.h>\r\n\r\nclass WireAbstraction;\r\nclass WirePort;\r\nclass TimingConstraint;\r\nclass CellSpecification;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Reader for ipxact:wire within abstraction definition.\r\n//-----------------------------------------------------------------------------\r\nnamespace WireAbstractionReader\r\n{\r\n    /*!\r\n     *  Creates a wire for abstraction definition from XML description.\r\n     *\r\n     *    @param [in] wireNode   The XML document to create the wire definition from.\r\n     *    @param [in] revision   The standard revision of the XML document being read.\r\n     *\r\n     *    @return The created wire definition.\r\n     */\r\n    QSharedPointer<WireAbstraction> createWireAbstractionFrom(QDomNode const& wireNode, Document::Revision revision);\r\n\r\n    namespace Details\r\n    {\r\n        /*!\r\n         *  Reads the qualifier from XML to a wire.\r\n         *\r\n         *    @param [in]     wireNode    The XML description of the wire.\r\n         *    @param [in/out] wire        The wire definition to insert the qualifier into.\r\n         *    @param [in]     revision    The standard revision of the XML document being read.\r\n         */\r\n        void parseQualifier(QDomNode const& wireNode, QSharedPointer<WireAbstraction> wire,\r\n            Document::Revision revision);\r\n                                   \r\n        /*!\r\n         *  Reads the system ports from XML to a wire.\r\n         *\r\n         *    @param [in]     wireNode    The XML description of the wire.\r\n         *    @param [in/out] wire        The wire definition to insert the system ports into.\r\n         *    @param [in]     revision    The standard revision of the XML document being read.\r\n         */\r\n        void parseSystems(QDomNode const& wireNode, QSharedPointer<WireAbstraction> wire, Document::Revision revision);\r\n                                   \r\n        /*!\r\n         *  Creates a wirePort for a wire from XML description.\r\n         *\r\n         *    @param [in]     wirePortNode    The XML description of the wirePort.\r\n         *    @param [in]     revision    The standard revision of the XML document being read.\r\n         *\r\n         *    @return The created wirePort.\r\n         */\r\n        QSharedPointer<WirePort> parseWirePort(QDomNode const& wirePortNode, Document::Revision revision);\r\n\r\n        /*!\r\n         *  Reads the constraints for a wirePort from XML to a wire.\r\n         *\r\n         *    @param [in]     wirePortNode    The XML description of the wirePort.\r\n         *    @param [in/out] wirePort        The wirePort to insert the constraints into.\r\n         */\r\n        void parseConstraints(QDomNode const& wirePortNode, QSharedPointer<WirePort> wirePort);\r\n\r\n        /*!\r\n         *  Creates a timing constraint for a wirePort from a XML description.\r\n         *\r\n         *    @param [in]     timingNode    The XML description of the timing constraint.\r\n         *\r\n         *    @return The created timing constraint.\r\n         */\r\n        QSharedPointer<TimingConstraint> parseTimingConstraint(QDomElement const& timingNode);\r\n\r\n        /*!\r\n         *  Creates a cell specification for load or drive constraint in a wirePort from a XML description.\r\n         *\r\n         *    @param [in]     cellNode    The XML description of the cell specification.\r\n         *\r\n         *    @return The created cell specification.\r\n         */\r\n        QSharedPointer<CellSpecification> parseCellSpecification(QDomElement const& cellNode);\r\n       \r\n        /*!\r\n         *  Reads the constraints for mirrored mode for a wirePort from XML to a wire.\r\n         *\r\n         *    @param [in]     wirePortNode    The XML description of the wirePort.\r\n         *    @param [in/out] wirePort        The wirePort to insert the mirrored constraints into.\r\n         */\r\n        void parseMirroredConstraints(QDomNode const& wirePortNode, QSharedPointer<WirePort> wirePort);\r\n\r\n        /*!\r\n         *  Reads the initiator port from XML to a wire.\r\n         *\r\n         *    @param [in]     wireNode    The XML description of the wire.\r\n         *    @param [in/out] wire        The wire definition to insert the initiator port into.\r\n         *    @param [in]     revision    The standard revision of the XML document being read.\r\n         */\r\n        void parseInitiator(QDomNode const& wireNode, QSharedPointer<WireAbstraction> wire, Document::Revision revision);\r\n                                 \r\n        /*!\r\n         *  Reads the target port from XML to a wire.\r\n         *\r\n         *    @param [in]     wireNode    The XML description of the wire.\r\n         *    @param [in/out] wire        The wire definition to insert the target port into.\r\n         *    @param [in]     revision    The standard revision of the XML document being read.\r\n         */ \r\n        void parseTarget(QDomNode const& wireNode, QSharedPointer<WireAbstraction> wire, Document::Revision revision);\r\n    }\r\n}\r\n\r\n#endif // WIREABSTRACTIONREADER_H\r\n"
  },
  {
    "path": "IPXACTmodels/AbstractionDefinition/WireAbstractionWriter.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: WireAbstractionWriter.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Esko Pekkarinen\r\n// Date: 12.08.2015\r\n//\r\n// Description:\r\n// Writer for IP-XACT Wire element within abstraction definition.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"WireAbstractionWriter.h\"\r\n#include \"WireAbstraction.h\"\r\n#include \"WirePort.h\"\r\n\r\n#include <IPXACTmodels/common/TimingConstraint.h>\r\n#include <IPXACTmodels/common/CellSpecification.h>\r\n#include <IPXACTmodels/common/CommonItemsWriter.h>\r\n#include <IPXACTmodels/common/QualifierWriter.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: WireAbstractionWriter::writeWire()\r\n//-----------------------------------------------------------------------------\r\nvoid WireAbstractionWriter::writeWire(QXmlStreamWriter& writer, QSharedPointer<WireAbstraction> wire,\r\n    Document::Revision revision)\r\n{\r\n    writer.writeStartElement(QStringLiteral(\"ipxact:wire\"));\r\n\r\n    QualifierWriter::writeQualifier(writer, wire->getQualifier());\r\n\r\n    QString initiatorElementName = revision == Document::Revision::Std22\r\n        ? QStringLiteral(\"ipxact:onInitiator\")\r\n        : QStringLiteral(\"ipxact:onMaster\");\r\n\r\n    QString targetElementName = revision == Document::Revision::Std22\r\n        ? QStringLiteral(\"ipxact:onTarget\")\r\n        : QStringLiteral(\"ipxact:onSlave\");\r\n\r\n    Details::writeSystem(writer, wire);\r\n    Details::writeInitiator(writer, wire, initiatorElementName);\r\n    Details::writeTarget(writer, wire, targetElementName);\r\n    \r\n    if (!wire->getDefaultValue().isEmpty())\r\n    {\r\n        writer.writeTextElement(QStringLiteral(\"ipxact:defaultValue\"), wire->getDefaultValue());\r\n    }\r\n    else if (wire->requiresDriver())\r\n    {\r\n        writer.writeStartElement(QStringLiteral(\"ipxact:requiresDriver\"));\r\n        writer.writeAttribute(QStringLiteral(\"driverType\"), General::driverType2Str(wire->getDriverType()));       \r\n        writer.writeCharacters(QStringLiteral(\"true\"));\r\n        writer.writeEndElement();\r\n    }\r\n\r\n    writer.writeEndElement();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: WireAbstractionWriter::Details::writeSystem()\r\n//-----------------------------------------------------------------------------\r\nvoid WireAbstractionWriter::Details::writeSystem(QXmlStreamWriter& writer,\r\n    QSharedPointer<WireAbstraction> wire)\r\n{\r\n    for (auto systemPort : *wire->getSystemPorts())\r\n    {\r\n        writer.writeStartElement(QStringLiteral(\"ipxact:onSystem\"));\r\n        writer.writeTextElement(QStringLiteral(\"ipxact:group\"), systemPort->getSystemGroup());\r\n        writeWirePort(writer, systemPort);\r\n        writer.writeEndElement();\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: WireAbstractionWriter::Details::writeWirePort()\r\n//-----------------------------------------------------------------------------\r\nvoid WireAbstractionWriter::Details::writeWirePort(QXmlStreamWriter& writer, QSharedPointer<WirePort> wirePort)\r\n{\r\n    writePresence(writer, wirePort);\r\n\r\n    writeWidth(writer, wirePort);\r\n\r\n    writeDirection(writer, wirePort);\r\n\r\n    writeModeConstraints(writer, wirePort);\r\n\r\n    writeMirroredModeConstraints(writer, wirePort);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: WireAbstractionWriter::Details::writePresence()\r\n//-----------------------------------------------------------------------------\r\nvoid WireAbstractionWriter::Details::writePresence(QXmlStreamWriter& writer, QSharedPointer<WirePort> wirePort)\r\n{\r\n    if (wirePort->getPresence() == PresenceTypes::REQUIRED)\r\n    {\r\n        writer.writeTextElement(QStringLiteral(\"ipxact:presence\"), QStringLiteral(\"required\"));\r\n    }\r\n    else if (wirePort->getPresence() == PresenceTypes::OPTIONAL)\r\n    {\r\n        writer.writeTextElement(QStringLiteral(\"ipxact:presence\"), QStringLiteral(\"optional\"));\r\n    }\r\n    else if (wirePort->getPresence() == PresenceTypes::ILLEGAL)\r\n    {\r\n        writer.writeTextElement(QStringLiteral(\"ipxact:presence\"), QStringLiteral(\"illegal\"));\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: WireAbstractionWriter::Details::writeWidth()\r\n//-----------------------------------------------------------------------------\r\nvoid WireAbstractionWriter::Details::writeWidth(QXmlStreamWriter& writer, QSharedPointer<WirePort> wirePort)\r\n{\r\n    if (!wirePort->getWidth().isEmpty())\r\n    {\r\n\r\n        writer.writeStartElement(QStringLiteral(\"ipxact:width\"));\r\n\r\n        if (wirePort->getAllBits())\r\n        {\r\n            writer.writeAttribute(QStringLiteral(\"allBits\"), QStringLiteral(\"true\"));\r\n        }\r\n\r\n        writer.writeCharacters(wirePort->getWidth());\r\n\r\n        writer.writeEndElement();\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: WireAbstractionWriter::Details::writeDirection()\r\n//-----------------------------------------------------------------------------\r\nvoid WireAbstractionWriter::Details::writeDirection(QXmlStreamWriter& writer, QSharedPointer<WirePort> wirePort)\r\n{\r\n    if (wirePort->getDirection() != DirectionTypes::DIRECTION_INVALID)\r\n    {\r\n        writer.writeTextElement(QStringLiteral(\"ipxact:direction\"),\r\n            DirectionTypes::direction2Str(wirePort->getDirection()));\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: WireAbstractionWriter::Details::writeModeConstraints()\r\n//-----------------------------------------------------------------------------\r\nvoid WireAbstractionWriter::Details::writeModeConstraints(QXmlStreamWriter& writer, QSharedPointer<WirePort> wirePort)\r\n{\r\n    QSharedPointer<TimingConstraint> timing = wirePort->getTimingConstraint();\r\n    QSharedPointer<CellSpecification> driveConstraint = wirePort->getDriveConstraint();\r\n    QSharedPointer<CellSpecification> loadConstraint = wirePort->getLoadConstraint();\r\n\r\n    if (!timing.isNull() || !driveConstraint.isNull() || !loadConstraint.isNull())\r\n    {\r\n        writer.writeStartElement(QStringLiteral(\"ipxact:modeConstraints\"));\r\n\r\n        writeTimingConstraint(writer, timing);\r\n        writeDriveConstraint(writer, driveConstraint);\r\n        writeLoadConstraint(writer, loadConstraint);\r\n\r\n        writer.writeEndElement();\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: WireAbstractionWriter::Details::writeTimingConstraint()\r\n//-----------------------------------------------------------------------------\r\nvoid WireAbstractionWriter::Details::writeTimingConstraint(QXmlStreamWriter& writer, QSharedPointer<TimingConstraint> timing)\r\n{\r\n    if (!timing.isNull())\r\n    {\r\n        writer.writeStartElement(QStringLiteral(\"ipxact:timingConstraint\"));\r\n\r\n        if (timing->getClockEdge() == TimingConstraint::RISE)\r\n        {\r\n            writer.writeAttribute(QStringLiteral(\"clockEdge\"), QStringLiteral(\"rise\"));\r\n        }\r\n        else if (timing->getClockEdge() == TimingConstraint::FALL)\r\n        {\r\n            writer.writeAttribute(QStringLiteral(\"clockEdge\"), QStringLiteral(\"fall\"));\r\n        }\r\n\r\n        if (timing->getDelayType() == TimingConstraint::MINIMUM_DELAY)\r\n        {\r\n            writer.writeAttribute(QStringLiteral(\"delayType\"), QStringLiteral(\"min\"));\r\n        }\r\n        else if (timing->getDelayType() == TimingConstraint::MAXIMUM_DELAY)\r\n        {\r\n            writer.writeAttribute(QStringLiteral(\"delayType\"), QStringLiteral(\"max\"));\r\n        }\r\n\r\n        writer.writeAttribute(QStringLiteral(\"clockName\"), timing->getClockName());\r\n\r\n        writer.writeCharacters(QString::number(timing->getValue()));\r\n\r\n        writer.writeEndElement();\r\n    }\r\n}\r\n//-----------------------------------------------------------------------------\r\n// Function: WireAbstractionWriter::Details::writeLoadConstraint()\r\n//-----------------------------------------------------------------------------\r\nvoid WireAbstractionWriter::Details::writeLoadConstraint(QXmlStreamWriter& writer,\r\n    QSharedPointer<CellSpecification> loadConstraint)\r\n{\r\n    if (!loadConstraint.isNull())\r\n    {\r\n        writer.writeStartElement(QStringLiteral(\"ipxact:loadConstraint\"));\r\n        writeCellSpecification(writer, loadConstraint);\r\n        writer.writeEndElement();\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: WireAbstractionWriter::Details::writeCellSpecification()\r\n//-----------------------------------------------------------------------------\r\nvoid WireAbstractionWriter::Details::writeCellSpecification(QXmlStreamWriter& writer,\r\n    QSharedPointer<CellSpecification> specification)\r\n{\r\n    writer.writeStartElement(QStringLiteral(\"ipxact:cellSpecification\"));\r\n\r\n    if (specification->getCellStrength() == CellSpecification::LOW)\r\n    {\r\n        writer.writeAttribute(QStringLiteral(\"cellStrength\"), QStringLiteral(\"low\"));\r\n    }\r\n    else if (specification->getCellStrength() == CellSpecification::HIGH)\r\n    {\r\n        writer.writeAttribute(QStringLiteral(\"cellStrength\"), QStringLiteral(\"high\"));\r\n    }\r\n    else if (specification->getCellStrength() == CellSpecification::MEDIAN)\r\n    {\r\n        writer.writeAttribute(QStringLiteral(\"cellStrength\"), QStringLiteral(\"median\"));\r\n    }\r\n\r\n    if (specification->getCellClass() == CellSpecification::SEQUENTIAL)\r\n    {\r\n        writer.writeTextElement(QStringLiteral(\"ipxact:cellClass\"), QStringLiteral(\"sequential\"));\r\n    }\r\n    else if (specification->getCellClass() == CellSpecification::COMBINATORIAL)\r\n    {\r\n        writer.writeTextElement(QStringLiteral(\"ipxact:cellClass\"), QStringLiteral(\"combinatorial\"));\r\n    }\r\n\r\n    QString cellFunction = specification->getCellFunction();\r\n    if (!cellFunction.isEmpty())\r\n    {\r\n        writer.writeStartElement(QStringLiteral(\"ipxact:cellFunction\"));\r\n        \r\n        QStringList standardFunctions;\r\n        standardFunctions << QStringLiteral(\"nd2\") << QStringLiteral(\"buf\") << QStringLiteral(\"inv\") <<\r\n            QStringLiteral(\"mux21\") << QStringLiteral(\"dff\") << QStringLiteral(\"latch\") << QStringLiteral(\"xor2\");\r\n        if (standardFunctions.contains(cellFunction))\r\n        {\r\n            writer.writeCharacters(specification->getCellFunction());\r\n        }\r\n        else\r\n        {\r\n            writer.writeAttribute(QStringLiteral(\"other\"), cellFunction);\r\n            writer.writeCharacters(QStringLiteral(\"other\"));\r\n        }\r\n\r\n        writer.writeEndElement();\r\n    }\r\n\r\n    writer.writeEndElement();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: WireAbstractionWriter::Details::writeDriveConstraint()\r\n//-----------------------------------------------------------------------------\r\nvoid WireAbstractionWriter::Details::writeDriveConstraint(QXmlStreamWriter& writer, QSharedPointer<CellSpecification> driveConstraint)\r\n{\r\n    if (!driveConstraint.isNull())\r\n    {\r\n        writer.writeStartElement(QStringLiteral(\"ipxact:driveConstraint\"));\r\n        writeCellSpecification(writer, driveConstraint);\r\n        writer.writeEndElement();\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: WireAbstractionWriter::Details::writeMirroredModeConstraints()\r\n//-----------------------------------------------------------------------------\r\nvoid WireAbstractionWriter::Details::writeMirroredModeConstraints(QXmlStreamWriter& writer, \r\n    QSharedPointer<WirePort> wirePort)\r\n{\r\n    QSharedPointer<TimingConstraint> timing = wirePort->getMirroredTimingConstraint();\r\n    QSharedPointer<CellSpecification> driveConstraint = wirePort->getMirroredDriveConstraint();\r\n    QSharedPointer<CellSpecification> loadConstraint = wirePort->getMirroredLoadConstraint();\r\n\r\n    if (!timing.isNull() || !driveConstraint.isNull() || !loadConstraint.isNull())\r\n    {\r\n        writer.writeStartElement(QStringLiteral(\"ipxact:mirroredModeConstraints\"));\r\n\r\n        writeTimingConstraint(writer, timing);\r\n        writeDriveConstraint(writer, driveConstraint);\r\n        writeLoadConstraint(writer, loadConstraint);\r\n\r\n        writer.writeEndElement();\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: WireAbstractionWriter::Details::writeInitiator()\r\n//-----------------------------------------------------------------------------\r\nvoid WireAbstractionWriter::Details::writeInitiator(QXmlStreamWriter& writer,\r\n    QSharedPointer<WireAbstraction> wirePort, QString const& elementName)\r\n{\r\n    if (wirePort->hasMasterPort())\r\n    {\r\n        writer.writeStartElement(elementName);\r\n        writeWirePort(writer, wirePort->getMasterPort());\r\n        writer.writeEndElement();\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: WireAbstractionWriter::Details::writeTarget()\r\n//-----------------------------------------------------------------------------\r\nvoid WireAbstractionWriter::Details::writeTarget(QXmlStreamWriter& writer,\r\n    QSharedPointer<WireAbstraction> wirePort, QString const& elementName)\r\n{\r\n    if (wirePort->hasSlavePort())\r\n    {\r\n        writer.writeStartElement(elementName);\r\n        writeWirePort(writer, wirePort->getSlavePort());\r\n        writer.writeEndElement();\r\n    }\r\n}\r\n"
  },
  {
    "path": "IPXACTmodels/AbstractionDefinition/WireAbstractionWriter.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: WireAbstractionWriter.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Esko Pekkarinen\r\n// Date: 12.08.2015\r\n//\r\n// Description:\r\n// Writer for IP-XACT Wire element within abstraction definition.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef WIREABSTRACTIONWRITER_H\r\n#define WIREABSTRACTIONWRITER_H\r\n\r\n#include <IPXACTmodels/common/Document.h>\r\n\r\n#include <QSharedPointer>\r\n#include <QXmlStreamWriter>\r\n\r\nclass CellSpecification;\r\nclass TimingConstraint;\r\nclass WireAbstraction;\r\nclass WirePort;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Writer for IP-XACT Wire element within abstraction definition.\r\n//-----------------------------------------------------------------------------\r\nnamespace WireAbstractionWriter\r\n{\r\n\r\n    /*!\r\n     *  Writes the given wire into XML.\r\n     *\r\n     *    @param [in] writer      The XML writer to use.\r\n     *    @param [in] wire        The wire to write.\r\n     *    @param [in] revision    The document standard revision to use.\r\n     */\r\n    IPXACTMODELS_EXPORT void writeWire(QXmlStreamWriter& writer, QSharedPointer<WireAbstraction> wire,\r\n        Document::Revision revision);\r\n\r\n    namespace Details\r\n    {\r\n\r\n        /*!\r\n         *  Writes the system port for the given wire into XML.\r\n         *\r\n         *    @param [in] writer      The XML writer to use.\r\n         *    @param [in] wire        The wire whose system port to write.\r\n         */\r\n        void writeSystem(QXmlStreamWriter& writer, QSharedPointer<WireAbstraction> wire);\r\n\r\n        /*!\r\n         *  Writes the wire port on system/master/slave into XML.\r\n         *\r\n         *    @param [in] writer      The XML writer to use.\r\n         *    @param [in] wirePort    The wirePort to write.\r\n         */\r\n        void writeWirePort(QXmlStreamWriter& writer, QSharedPointer<WirePort> wirePort);\r\n\r\n        /*!\r\n         *  Writes the wire port presence on system/master/slave into XML.\r\n         *\r\n         *    @param [in] writer      The XML writer to use.\r\n         *    @param [in] wirePort    The wirePort whose presence to write.\r\n         */\r\n        void writePresence(QXmlStreamWriter& writer, QSharedPointer<WirePort> wirePort);\r\n\r\n        /*!\r\n         *  Writes the wire port width on system/master/slave into XML.\r\n         *\r\n         *    @param [in] writer      The XML writer to use.\r\n         *    @param [in] wirePort    The wirePort whose width to write.\r\n         */\r\n        void writeWidth(QXmlStreamWriter& writer, QSharedPointer<WirePort> wirePort);\r\n\r\n        /*!\r\n         *  Writes the wire port direction on system/master/slave into XML.\r\n         *\r\n         *    @param [in] writer      The XML writer to use.\r\n         *    @param [in] wirePort    The wirePort whose direction to write.\r\n         */\r\n        void writeDirection(QXmlStreamWriter& writer, QSharedPointer<WirePort> wirePort);\r\n\r\n        /*!\r\n         *  Writes the wire mode constraints into XML.\r\n         *\r\n         *    @param [in] writer      The XML writer to use.\r\n         *    @param [in] wirePort    The wirePort whose mode constraints to write.\r\n         */\r\n        void writeModeConstraints(QXmlStreamWriter& writer, QSharedPointer<WirePort> wirePort);\r\n\r\n        /*!\r\n         *  Writes a timing constraint into XML.\r\n         *\r\n         *    @param [in] writer      The XML writer to use.\r\n         *    @param [in] timing      The timing constraint to write.\r\n         */\r\n        void writeTimingConstraint(QXmlStreamWriter& writer, QSharedPointer<TimingConstraint> timing);\r\n\r\n        /*!\r\n         *  Writes a drive constraint into XML.\r\n         *\r\n         *    @param [in] writer              The XML writer to use.\r\n         *    @param [in] driveConstraint     The drive constraint to write.\r\n         */\r\n        void writeDriveConstraint(QXmlStreamWriter& writer, QSharedPointer<CellSpecification> driveConstraint);\r\n\r\n        /*!\r\n         *  Writes a load constraint into XML.\r\n         *\r\n         *    @param [in] writer              The XML writer to use.\r\n         *    @param [in] loadConstraint      The load constraint to write.\r\n         */\r\n        void writeLoadConstraint(QXmlStreamWriter& writer, QSharedPointer<CellSpecification> loadConstraint);\r\n\r\n        /*!\r\n         *  Writes a cell specification in load or drive constraint into XML.\r\n         *\r\n         *    @param [in] writer              The XML writer to use.\r\n         *    @param [in] specification       The  cell specification to write.\r\n         */\r\n        void writeCellSpecification(QXmlStreamWriter& writer, QSharedPointer<CellSpecification> specification);\r\n\r\n        /*!\r\n         *  Writes the wire mode constraints in mirrored mode into XML.\r\n         *\r\n         *    @param [in] writer      The XML writer to use.\r\n         *    @param [in] wirePort    The wirePort whose mirrored mode constraints to write.\r\n         */\r\n        void writeMirroredModeConstraints(QXmlStreamWriter& writer, QSharedPointer<WirePort> wirePort);\r\n\r\n        /*!\r\n         *  Writes the initiator port for the given wire qualifier into XML.\r\n         *\r\n         *    @param [in] writer      The XML writer to use.\r\n         *    @param [in] wire        The wire whose initiator port to write.\r\n         */\r\n        void writeInitiator(QXmlStreamWriter& writer, QSharedPointer<WireAbstraction> wirePort,\r\n            QString const& elementName);\r\n\r\n        /*!\r\n         *  Writes the target port for the given wire qualifier into XML.\r\n         *\r\n         *    @param [in] writer      The XML writer to use.\r\n         *    @param [in] wire        The wire whose target port to write.\r\n         */\r\n        void writeTarget(QXmlStreamWriter& writer, QSharedPointer<WireAbstraction> wirePort,\r\n            QString const& elementName);\r\n    }\r\n}\r\n\r\n#endif // WIREABSTRACTIONWRITER_H\r\n"
  },
  {
    "path": "IPXACTmodels/AbstractionDefinition/WirePort.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: WirePort.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Esko Pekkarinen\r\n// Date: 11.08.2015\r\n//\r\n// Description:\r\n// Implementation for ipxact:wirePort element within abstraction definition.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"WirePort.h\"\r\n\r\n#include <IPXACTmodels/common/TimingConstraint.h>\r\n\r\n#include <IPXACTmodels/common/CellSpecification.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: WirePort::WirePort()\r\n//-----------------------------------------------------------------------------\r\nWirePort::WirePort(): \r\nsystemGroupName_(),\r\n    presence_(PresenceTypes::UNKNOWN), \r\n    width_(),\r\n    direction_(DirectionTypes::DIRECTION_INVALID),\r\n    timingConstraint_(),\r\n    driveConstraint_(),\r\n    loadConstraint_(),\r\n    mirroredTimingConstraint_(),\r\n    mirroredDriveConstraint_(),\r\n    mirroredLoadConstraint_()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: WirePort::WirePort()\r\n//-----------------------------------------------------------------------------\r\nWirePort::WirePort(WirePort const& other): \r\nsystemGroupName_(other.systemGroupName_),\r\n    presence_(other.presence_),\r\n    width_(other.width_),\r\n    direction_(other.direction_),\r\n    timingConstraint_(),\r\n    driveConstraint_(),\r\n    loadConstraint_(),\r\n    mirroredTimingConstraint_(),\r\n    mirroredDriveConstraint_(),\r\n    mirroredLoadConstraint_()\r\n{\r\n    if (!other.timingConstraint_.isNull())\r\n    {\r\n        timingConstraint_ = QSharedPointer<TimingConstraint>(new TimingConstraint(*other.timingConstraint_));\r\n    }\r\n\r\n    if (!other.driveConstraint_.isNull())\r\n    {\r\n        driveConstraint_ = QSharedPointer<CellSpecification>(new CellSpecification(*other.driveConstraint_));\r\n    }\r\n\r\n    if (!other.driveConstraint_.isNull())\r\n    {\r\n        loadConstraint_ = QSharedPointer<CellSpecification>(new CellSpecification(*other.loadConstraint_));\r\n    }\r\n\r\n    if (!other.mirroredTimingConstraint_.isNull())\r\n    {\r\n        mirroredTimingConstraint_ = \r\n            QSharedPointer<TimingConstraint>(new TimingConstraint(*other.mirroredTimingConstraint_));\r\n    }\r\n\r\n    if (!other.mirroredDriveConstraint_.isNull())\r\n    {\r\n        mirroredDriveConstraint_ = \r\n            QSharedPointer<CellSpecification>(new CellSpecification(*other.mirroredDriveConstraint_));\r\n    }\r\n\r\n    if (!other.mirroredDriveConstraint_.isNull())\r\n    {\r\n        loadConstraint_ = QSharedPointer<CellSpecification>(new CellSpecification(*other.mirroredDriveConstraint_));\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: WirePort::~WirePort()\r\n//-----------------------------------------------------------------------------\r\nWirePort::~WirePort()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: WirePort::setSystemGroup()\r\n//-----------------------------------------------------------------------------\r\nvoid WirePort::setSystemGroup(QString const& groupName)\r\n{\r\n    systemGroupName_ = groupName;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: WirePort::getSystemGroup()\r\n//-----------------------------------------------------------------------------\r\nQString WirePort::getSystemGroup() const\r\n{\r\n    return systemGroupName_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: WirePort::setPresence()\r\n//-----------------------------------------------------------------------------\r\nvoid WirePort::setPresence(PresenceTypes::Presence presence)\r\n{\r\n    presence_ = presence;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: WirePort::getPresence()\r\n//-----------------------------------------------------------------------------\r\nPresenceTypes::Presence WirePort::getPresence() const\r\n{\r\n    return presence_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: WirePort::setWidth()\r\n//-----------------------------------------------------------------------------\r\nvoid WirePort::setWidth(QString const& widthExpression)\r\n{\r\n    width_ = widthExpression;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: WirePort::getWidth()\r\n//-----------------------------------------------------------------------------\r\nQString WirePort::getWidth() const\r\n{\r\n    return width_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: WirePort::setAllBits()\r\n//-----------------------------------------------------------------------------\r\nvoid WirePort::setAllBits(bool allBits)\r\n{\r\n    allBits_ = allBits;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: WirePort::getAllBits()\r\n//-----------------------------------------------------------------------------\r\nbool WirePort::getAllBits() const\r\n{\r\n    return allBits_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: WirePort::setDirection()\r\n//-----------------------------------------------------------------------------\r\nvoid WirePort::setDirection(DirectionTypes::Direction direction)\r\n{\r\n    direction_ = direction;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: WirePort::getDirection()\r\n//-----------------------------------------------------------------------------\r\nDirectionTypes::Direction WirePort::getDirection() const\r\n{\r\n    return direction_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: WirePort::setTimingConstraint()\r\n//-----------------------------------------------------------------------------\r\nvoid WirePort::setTimingConstraint(QSharedPointer<TimingConstraint> timeConstraint)\r\n{\r\n    timingConstraint_ = timeConstraint;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: WirePort::getTimingConstraint()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<TimingConstraint> WirePort::getTimingConstraint() const\r\n{\r\n    return timingConstraint_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: WirePort::setLoadConstraint()\r\n//-----------------------------------------------------------------------------\r\nvoid WirePort::setLoadConstraint(QSharedPointer<CellSpecification> loadConstraint)\r\n{\r\n    loadConstraint_ = loadConstraint;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: WirePort::getLoadConstraint()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<CellSpecification> WirePort::getLoadConstraint() const\r\n{\r\n    return loadConstraint_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: WirePort::setDriveConstraint()\r\n//-----------------------------------------------------------------------------\r\nvoid WirePort::setDriveConstraint(QSharedPointer<CellSpecification> driveConstraint)\r\n{\r\n    driveConstraint_ = driveConstraint;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: WirePort::getDriveConstraint()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<CellSpecification> WirePort::getDriveConstraint() const\r\n{\r\n    return driveConstraint_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: WirePort::setMirroredTimingConstraint()\r\n//-----------------------------------------------------------------------------\r\nvoid WirePort::setMirroredTimingConstraint(QSharedPointer<TimingConstraint> timeConstraint)\r\n{\r\n    mirroredTimingConstraint_ = timeConstraint;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: WirePort::getMirroredTimingConstraint()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<TimingConstraint> WirePort::getMirroredTimingConstraint() const\r\n{\r\n    return mirroredTimingConstraint_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: WirePort::setMirroredLoadConstraint()\r\n//-----------------------------------------------------------------------------\r\nvoid WirePort::setMirroredLoadConstraint(QSharedPointer<CellSpecification> loadConstraint)\r\n{\r\n    mirroredLoadConstraint_ = loadConstraint;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: WirePort::getMirroredLoadConstraint()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<CellSpecification> WirePort::getMirroredLoadConstraint() const\r\n{\r\n    return mirroredLoadConstraint_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: WirePort::setMirroredDriveConstraint()\r\n//-----------------------------------------------------------------------------\r\nvoid WirePort::setMirroredDriveConstraint(QSharedPointer<CellSpecification> driveConstraint)\r\n{\r\n    mirroredDriveConstraint_ = driveConstraint;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: WirePort::getMirroredDriveConstraint()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<CellSpecification> WirePort::getMirroredDriveConstraint() const\r\n{\r\n    return mirroredDriveConstraint_;\r\n}\r\n"
  },
  {
    "path": "IPXACTmodels/AbstractionDefinition/WirePort.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: WirePort.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Esko Pekkarinen\r\n// Date: 11.08.2015\r\n//\r\n// Description:\r\n// Implementation for ipxact:wirePort element within abstraction definition.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef WIREPORT_H\r\n#define WIREPORT_H\r\n\r\n#include <QString>\r\n#include <QSharedPointer>\r\n\r\n#include <IPXACTmodels/ipxactmodels_global.h>\r\n\r\n#include <IPXACTmodels/common/PresenceTypes.h>\r\n#include <IPXACTmodels/common/DirectionTypes.h>\r\n\r\nclass TimingConstraint;\r\nclass CellSpecification;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Implementation for ipxact:wirePort element within abstraction definition.\r\n//-----------------------------------------------------------------------------\r\nclass IPXACTMODELS_EXPORT WirePort \r\n{\r\npublic:\r\n\r\n\t//! The constructor.\r\n\tWirePort();\r\n\r\n    //! Copy constructor.\r\n    WirePort(WirePort const& other);\r\n\r\n\t//! The destructor.\r\n\t~WirePort();\r\n    \r\n    /*!\r\n     *  Sets the group name for system mode.\r\n     *\r\n     *    @param [in] groupName   The system group to set.\r\n     */\r\n    void setSystemGroup(QString const& groupName);\r\n    \r\n    /*!\r\n     *  Gets the group name for system mode.\r\n     *\r\n     *    @return The system group the wire belongs to.\r\n     */\r\n    QString getSystemGroup() const;\r\n\r\n    /*!\r\n     *  Sets the presence restriction for the port.\r\n     *\r\n     *    @param [in] presence   The restriction to set.\r\n     */\r\n    void setPresence(PresenceTypes::Presence presence);\r\n\r\n    /*!\r\n     *  Gets the presence restriction for the port.\r\n     *\r\n     *    @return The presence restriction for the port.\r\n     */\r\n    PresenceTypes::Presence getPresence() const;\r\n   \r\n    /*!\r\n     *  Sets the number of bits required for the port.\r\n     *\r\n     *    @param [in] widthExpression   The number of bits to set.\r\n     */\r\n    void setWidth(QString const& widthExpression);\r\n\r\n    /*!\r\n     *  Gets the number of bits required for the port.\r\n     *\r\n     *    @return The number of bits to required for the port.\r\n     */\r\n    QString getWidth() const;\r\n\r\n    /*!\r\n     *\tSets the allBits attribute for wire port width.\r\n     *  \r\n     *    @param [in] allBits\tFlag for setting allBits.\r\n     */\r\n    void setAllBits(bool allBits);\r\n\r\n    /*!\r\n     *\tGets the allBits attribute value of the wire port.\r\n     *\t\t\r\n     * \t\t@return True, if allBits is set, otherwise false.\r\n     */\r\n    bool getAllBits() const;\r\n\r\n    /*!\r\n     *  Sets a direction restriction for the port.\r\n     *\r\n     *    @param [in] direction   The required direction.\r\n     */\r\n    void setDirection(DirectionTypes::Direction direction);\r\n   \r\n    /*!\r\n     *  Gets a direction restriction for the port.\r\n     *\r\n     *    @return The required direction.\r\n     */\r\n    DirectionTypes::Direction getDirection() const;\r\n    \r\n    /*!\r\n     *  Sets a timing constraint for the port.\r\n     *\r\n     *    @param [in] timeConstraint      The constraint to set.\r\n     */\r\n    void setTimingConstraint(QSharedPointer<TimingConstraint> timeConstraint);\r\n\r\n    /*!\r\n     *  Gets the timing constraint for the port.\r\n     *\r\n     *    @return The timing constraint.\r\n     */\r\n    QSharedPointer<TimingConstraint> getTimingConstraint() const;\r\n        \r\n    /*!\r\n     *  Sets a load constraint for the port.\r\n     *\r\n     *    @param [in] loadConstraint      The constraint to set.\r\n     */\r\n    void setLoadConstraint(QSharedPointer<CellSpecification> loadConstraint);\r\n    \r\n    /*!\r\n     *  Gets the load constraint for the port.\r\n     *\r\n     *    @return The load constraint.\r\n     */\r\n    QSharedPointer<CellSpecification> getLoadConstraint() const;\r\n            \r\n    /*!\r\n     *  Sets a drive constraint for the port.\r\n     *\r\n     *    @param [in] driveConstraint     The constraint to set.\r\n     */\r\n    void setDriveConstraint(QSharedPointer<CellSpecification> driveConstraint);\r\n    \r\n    /*!\r\n     *  Gets the drive constraint for the port.\r\n     *\r\n     *    @return The drive constraint.\r\n     */\r\n    QSharedPointer<CellSpecification> getDriveConstraint() const;\r\n                \r\n    /*!\r\n     *  Sets a timing constraint for the port in the mirrored mode.\r\n     *\r\n     *    @param [in] timeConstraint     The constraint to set.\r\n     */\r\n    void setMirroredTimingConstraint(QSharedPointer<TimingConstraint> timeConstraint);\r\n    \r\n    /*!\r\n     *  Gets the timing constraint for the port in mirrored mode.\r\n     *\r\n     *    @return The timing constraint.\r\n     */\r\n    QSharedPointer<TimingConstraint> getMirroredTimingConstraint() const;\r\n                    \r\n    /*!\r\n     *  Sets a load constraint for the port in the mirrored mode.\r\n     *\r\n     *    @param [in] loadConstraint     The constraint to set.\r\n     */\r\n    void setMirroredLoadConstraint(QSharedPointer<CellSpecification> loadConstraint);\r\n        \r\n    /*!\r\n     *  Gets the load constraint for the port in mirrored mode.\r\n     *\r\n     *    @return The load constraint.\r\n     */\r\n    QSharedPointer<CellSpecification> getMirroredLoadConstraint() const;\r\n                        \r\n    /*!\r\n     *  Sets a drive constraint for the port in the mirrored mode.\r\n     *\r\n     *    @param [in] driveConstraint     The constraint to set.\r\n     */\r\n    void setMirroredDriveConstraint(QSharedPointer<CellSpecification> driveConstraint);\r\n        \r\n    /*!\r\n     *  Gets the drive constraint for the port in mirrored mode.\r\n     *\r\n     *    @return The drive constraint.\r\n     */\r\n    QSharedPointer<CellSpecification> getMirroredDriveConstraint() const;\r\n\r\nprivate:\r\n\r\n\t// Disable copying.\r\n    WirePort& operator=(WirePort const& rhs);\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! System group name for system interfaces.\r\n    QString systemGroupName_;\r\n\r\n    //! Defines if the port is required or forbidden in a bus interface.\r\n    PresenceTypes::Presence presence_;\r\n\r\n    //! Number of bits required for the port.\r\n    QString width_;\r\n\r\n    //! If false, any number of bits can be mapped. If true, all width bits shall be mapped.\r\n    bool allBits_ = false;\r\n\r\n    //! The direction restriction for the port.\r\n    DirectionTypes::Direction direction_;\r\n\r\n    //! The timing constraint for the port.\r\n    QSharedPointer<TimingConstraint> timingConstraint_;\r\n\r\n    //! The drive constraint for the port.\r\n    QSharedPointer<CellSpecification> driveConstraint_;\r\n\r\n    //! The load constraint for the port.\r\n    QSharedPointer<CellSpecification> loadConstraint_;\r\n\r\n    //! The timing constraint for the port in mirrored mode.\r\n    QSharedPointer<TimingConstraint> mirroredTimingConstraint_;\r\n\r\n    //! The drive constraint for the port in mirrored mode.\r\n    QSharedPointer<CellSpecification> mirroredDriveConstraint_;\r\n\r\n    //! The load constraint for the port in mirrored mode.\r\n    QSharedPointer<CellSpecification> mirroredLoadConstraint_;\r\n};\r\n\r\n#endif // WIREPORT_H\r\n\r\n"
  },
  {
    "path": "IPXACTmodels/AbstractionDefinition/validators/AbstractionDefinitionValidator.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// AbstractionDefinition: AbstractionDefinitionValidator.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Janne Virtanen\r\n// Date: 04.12.2015\r\n//\r\n// Description:\r\n// Validator for ipxact:AbstractionDefinition.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"AbstractionDefinitionValidator.h\"\r\n\r\n#include <KactusAPI/include/LibraryInterface.h>\r\n\r\n#include <KactusAPI/include/ExpressionParser.h>\r\n\r\n#include <IPXACTmodels/AbstractionDefinition/AbstractionDefinition.h>\r\n#include <IPXACTmodels/AbstractionDefinition/PortAbstraction.h>\r\n#include <IPXACTmodels/AbstractionDefinition/TransactionalAbstraction.h>\r\n#include <IPXACTmodels/AbstractionDefinition/WireAbstraction.h>\r\n#include <IPXACTmodels/AbstractionDefinition/Packet.h>\r\n\r\n#include <IPXACTmodels/common/Choice.h>\r\n#include <IPXACTmodels/common/validators/ChoiceValidator.h>\r\n\r\n#include <IPXACTmodels/BusDefinition/BusDefinition.h>\r\n\r\n#include <IPXACTmodels/common/Enumeration.h>\r\n#include <IPXACTmodels/common/DirectionTypes.h>\r\n#include <IPXACTmodels/common/TransactionalTypes.h>\r\n\r\n#include <IPXACTmodels/common/validators/CellSpecificationValidator.h>\r\n#include <IPXACTmodels/common/validators/TimingConstraintValidator.h>\r\n#include <IPXACTmodels/common/validators/QualifierValidator.h>\r\n#include <IPXACTmodels/AbstractionDefinition/validators/PacketValidator.h>\r\n\r\n#include <IPXACTmodels/utilities/BusDefinitionUtils.h>\r\n\r\n#include <QRegularExpression>\r\n#include <QStringList>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AbstractionDefinitionValidator::AbstractionDefinitionValidator()\r\n//-----------------------------------------------------------------------------\r\nAbstractionDefinitionValidator::AbstractionDefinitionValidator(LibraryInterface* library,\r\n    QSharedPointer<ExpressionParser> expressionParser) : \r\nlibrary_(library), \r\nexpressionParser_(expressionParser),\r\nportsValidator_(library_, expressionParser_)\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AbstractionDefinitionValidator::validateInstantiation()\r\n//-----------------------------------------------------------------------------\r\nbool AbstractionDefinitionValidator::validate(QSharedPointer<AbstractionDefinition> abstractionDefinition)\r\n{\r\n\t// Must have a valid VLNV.\r\n\tif (!abstractionDefinition->getVlnv().isValid())\r\n\t{\r\n\t\treturn false;\r\n\t}\r\n\r\n    if (!parameterValidator_)\r\n    {\r\n        parameterValidator_ = QSharedPointer<ParameterValidator>(\r\n            new ParameterValidator(expressionParser_, QSharedPointer<QList<QSharedPointer<Choice> > >(), \r\n                abstractionDefinition->getRevision()));\r\n    }\r\n\r\n\t// The defined bus must exist in the library as a component.\r\n    QSharedPointer<const BusDefinition> busDefinition = getBusDefinition(abstractionDefinition);\r\n    if (!busDefinition)\r\n    {\r\n        return false;\r\n    }\r\n\r\n\t// If this is an extension to another abstraction definition, it must exist.\r\n    if (!hasValidExtend(abstractionDefinition) || !hasValidExtendPorts(abstractionDefinition))\r\n\t{\r\n\t\treturn false;\r\n\t}\r\n\r\n\t// Any parameters must be valid.\r\n\tfor (auto const& parameter : *abstractionDefinition->getParameters())\r\n\t{\r\n\t\tif (!parameterValidator_->hasValidValue(parameter))\r\n\t\t{\r\n\t\t\treturn false;\r\n\t\t}\r\n\t}\r\n\r\n\t// Must have at least one logical port.\r\n\tif (abstractionDefinition->getLogicalPorts()->isEmpty())\r\n\t{\r\n\t\treturn false;\r\n\t}\r\n\r\n\t// Collection of names of logical ports.\r\n\tQVector<QString> logicalNames;\r\n\r\n\t// Validate each logical port.\r\n\tfor (auto const& portAbstraction : *abstractionDefinition->getLogicalPorts())\r\n\t{\r\n        // Logical name must unique within the abstraction definition.\r\n        if (logicalNames.contains(portAbstraction->getLogicalName()))\r\n        {\r\n            return false;\r\n        }\r\n\r\n\t\tif (!portsValidator_.validate(portAbstraction, abstractionDefinition, busDefinition))\r\n\t\t{\r\n\t\t\treturn false;\r\n\t\t}\r\n\r\n        // Logical name is valid: Mark it as used one!\r\n        logicalNames.append(portAbstraction->getLogicalName());\r\n\t}\r\n\r\n    if (!hasValidChoices(abstractionDefinition))\r\n    {\r\n        return false;\r\n    }\r\n\r\n\treturn true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AbstractionDefinitionValidator::findErrorsIn()\r\n//-----------------------------------------------------------------------------\r\nvoid AbstractionDefinitionValidator::findErrorsIn(QVector<QString>& errors,\r\n\tQSharedPointer<AbstractionDefinition> abstractionDefinition)\r\n{\r\n    if (!parameterValidator_)\r\n    {\r\n        parameterValidator_ = QSharedPointer<ParameterValidator>(\r\n            new ParameterValidator(expressionParser_, QSharedPointer<QList<QSharedPointer<Choice> > >(),\r\n                abstractionDefinition->getRevision()));\r\n    }\r\n\r\n\t// Must have a valid VLNV.\r\n\tif (!abstractionDefinition->getVlnv().isValid())\r\n\t{\r\n\t\terrors.append(QObject::tr(\"The VLNV %1 is invalid.\").arg(abstractionDefinition->getVlnv().toString()));\r\n\t}\r\n\r\n\t// The defined bus must exist in the library as a component.\r\n    QSharedPointer<const BusDefinition> busDefinition = getBusDefinition(abstractionDefinition);\r\n    if (!busDefinition)\r\n    {\r\n        errors.append(QObject::tr(\"The bus definition %1 referenced in %2 is not found in the library.\")\r\n            .arg(abstractionDefinition->getBusType().toString(), abstractionDefinition->getVlnv().toString()));\r\n    }\r\n\r\n    QString context = QObject::tr(\"abstraction definition %1\").arg(abstractionDefinition->getVlnv().toString());\r\n\r\n    // If this is an extension to another abstraction definition, it must exist.\r\n    findErrorsInExtend(errors, context, abstractionDefinition);\r\n    \r\n    // Any parameters must be valid.\r\n\tfor (auto const& currentPara : *abstractionDefinition->getParameters())\r\n\t{\r\n\t\tparameterValidator_->findErrorsIn(errors, currentPara, context);\r\n\t}\r\n\r\n\t// Must have at least one logical port.\r\n\tif (abstractionDefinition->getLogicalPorts()->isEmpty())\r\n\t{\r\n\t\terrors.append(QObject::tr(\"Abstraction definition must define at least one port.\"));\r\n\t}\r\n\r\n\t// Collection of names of logical ports.\r\n\tQVector<QString> logicalNames;\r\n\r\n\t// Validate each logical port.\r\n\tfor (auto const& port : *abstractionDefinition->getLogicalPorts())\r\n    {\t\r\n        // Logical name must unique within the abstraction definition.\r\n        if (logicalNames.contains(port->getLogicalName()))\r\n        {\r\n            errors.append(QObject::tr(\"Port name %1 is not unique within %2.\").arg(port->getLogicalName(),\r\n               context));\r\n        }\r\n\r\n        portsValidator_.findErrorsIn(errors, port, abstractionDefinition, busDefinition);\r\n\r\n        logicalNames.append(port->getLogicalName());\r\n\t}\r\n\r\n    if (auto choices = abstractionDefinition->getChoices(); !choices->isEmpty())\r\n    {\r\n        findErrorsInChoices(errors, context, choices);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AbstractionDefinitionValidator::hasValidName()\r\n//-----------------------------------------------------------------------------\r\nbool AbstractionDefinitionValidator::hasValidName(QString const& name) const\r\n{\r\n\tQRegularExpression whiteSpaceExpression(QStringLiteral(\"^\\\\s*$\"));\r\n\r\n\tif (name.isEmpty() || whiteSpaceExpression.match(name).hasMatch())\r\n\t{\r\n\t\treturn false;\r\n\t}\r\n\r\n\treturn true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AbstractionDefinitionValidator::getBusDefinition()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<const BusDefinition> AbstractionDefinitionValidator::getBusDefinition(\r\n    QSharedPointer<AbstractionDefinition> abstraction) const\r\n{\r\n    QSharedPointer<const Document> busDefinitionDocument = library_->getModelReadOnly(abstraction->getBusType());\r\n    if (busDefinitionDocument)\r\n    {\r\n        QSharedPointer<const BusDefinition> busDefinition =\r\n            busDefinitionDocument.dynamicCast<const BusDefinition>();\r\n\r\n        return busDefinition;\r\n    }\r\n\r\n    return QSharedPointer<const BusDefinition>();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AbstractionDefinitionValidator::hasValidExtendPorts()\r\n//-----------------------------------------------------------------------------\r\nbool AbstractionDefinitionValidator::hasValidExtendPorts(QSharedPointer<AbstractionDefinition> abstraction) const\r\n{\r\n    QSharedPointer<AbstractionDefinition> extendAbstraction = getExtendedAbstractionDefinition(abstraction);\r\n    if (extendAbstraction)\r\n    {\r\n        for (auto portAbstraction : *abstraction->getLogicalPorts())\r\n        {\r\n            QSharedPointer<PortAbstraction> extendPort = getMatchingExtendPort(portAbstraction, extendAbstraction);\r\n            if (extendPort &&\r\n                (*portAbstraction->getQualifier() != *extendPort->getQualifier() ||\r\n                portAbstraction->getMatch() != extendPort->getMatch() ||\r\n                ((portAbstraction->hasWire() && !extendWirePortIsValid(portAbstraction, extendPort)) ||\r\n                (portAbstraction->hasTransactional() &&\r\n                    !extendTransactionalPortAbstractionIsValid(portAbstraction, extendPort)))))\r\n            {\r\n                return false;\r\n            }\r\n        }\r\n    }\r\n\r\n    return true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AbstractionDefinitionValidator::extendWirePortIsValid()\r\n//-----------------------------------------------------------------------------\r\nbool AbstractionDefinitionValidator::extendWirePortIsValid(QSharedPointer<PortAbstraction> abstractionPort,\r\n    QSharedPointer<PortAbstraction> extendPort) const\r\n{\r\n    if (!extendPort->hasWire())\r\n    {\r\n        return false;\r\n    }\r\n\r\n    QSharedPointer<WireAbstraction> portWire = abstractionPort->getWire();\r\n    QSharedPointer<WireAbstraction> extendWire = extendPort->getWire();\r\n\r\n    if ((extendWire->getMasterPort() && (!portWire->getMasterPort() ||\r\n        portWire->getMasterPort()->getDirection() != extendWire->getMasterPort()->getDirection())) ||\r\n        (extendWire->getSlavePort() && (!portWire->getSlavePort() ||\r\n            portWire->getSlavePort()->getDirection() != extendWire->getSlavePort()->getDirection())))\r\n    {\r\n        return false;\r\n    }\r\n\r\n    for (auto extendSystem : *extendWire->getSystemPorts())\r\n    {\r\n        QSharedPointer<WirePort> matchingSystem;\r\n        for (auto portSystem : *portWire->getSystemPorts())\r\n        {\r\n            if (portSystem->getSystemGroup() == extendSystem->getSystemGroup())\r\n            {\r\n                matchingSystem = portSystem;\r\n                break;\r\n            }\r\n        }\r\n\r\n        if (!matchingSystem || extendSystem->getDirection() != matchingSystem->getDirection())\r\n        {\r\n            return false;\r\n        }\r\n    }\r\n\r\n    return true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AbstractionDefinitionValidator::extendTransactionalPortAbstractionIsValid()\r\n//-----------------------------------------------------------------------------\r\nbool AbstractionDefinitionValidator::extendTransactionalPortAbstractionIsValid(\r\n    QSharedPointer<PortAbstraction> abstractionPort, QSharedPointer<PortAbstraction> extendPort) const\r\n{\r\n    if (!extendPort->hasTransactional())\r\n    {\r\n        return false;\r\n    }\r\n\r\n    QSharedPointer<TransactionalAbstraction> portTransactional = abstractionPort->getTransactional();\r\n    QSharedPointer<TransactionalAbstraction> extendTransactional = extendPort->getTransactional();\r\n\r\n    if (extendTransactional->getMasterPort() &&\r\n        !extendTransactionalPortIsValid(portTransactional->getMasterPort(), extendTransactional->getMasterPort()))\r\n    {\r\n        return false;\r\n    }\r\n\r\n    if (extendTransactional->getSlavePort() &&\r\n        !extendTransactionalPortIsValid(portTransactional->getSlavePort(), extendTransactional->getSlavePort()))\r\n    {\r\n        return false;\r\n    }\r\n\r\n    for (auto extendSystem : *extendTransactional->getSystemPorts())\r\n    {\r\n        QSharedPointer<TransactionalPort> portSystem;\r\n        for (auto transactionalSystemPort : *portTransactional->getSystemPorts())\r\n        {\r\n            if (transactionalSystemPort->getSystemGroup() == extendSystem->getSystemGroup())\r\n            {\r\n                portSystem = transactionalSystemPort;\r\n                break;\r\n            }\r\n        }\r\n\r\n        if (!extendTransactionalPortIsValid(portSystem, extendSystem))\r\n        {\r\n            return false;\r\n        }\r\n    }\r\n\r\n    return true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AbstractionDefinitionValidator::extendTransactionalPortIsValid()\r\n//-----------------------------------------------------------------------------\r\nbool AbstractionDefinitionValidator::extendTransactionalPortIsValid(QSharedPointer<TransactionalPort> port,\r\n    QSharedPointer<TransactionalPort> extendPort) const\r\n{\r\n    if (!port)\r\n    {\r\n        return false;\r\n    }\r\n\r\n    QSharedPointer<Protocol> portProtocol = port->getProtocol();\r\n    QSharedPointer<Protocol> extendPortProtocol = extendPort->getProtocol();\r\n\r\n    return port->getInitiative() == extendPort->getInitiative() &&\r\n        port->getKind() == extendPort->getKind() && port->getBusWidth() == extendPort->getBusWidth() &&\r\n        ((!portProtocol && !extendPortProtocol) || (portProtocol && extendPortProtocol &&\r\n        portProtocol->getProtocolType() == extendPortProtocol->getProtocolType() &&\r\n            portProtocol->getPayloadName() == extendPortProtocol->getPayloadName() &&\r\n            portProtocol->getPayloadType() == extendPortProtocol->getPayloadType() &&\r\n            portProtocol->getPayloadExtension() == extendPortProtocol->getPayloadExtension()));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AbstractionDefinitionValidator::getMatchingExtendPort()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<PortAbstraction> AbstractionDefinitionValidator::getMatchingExtendPort(\r\n    QSharedPointer<PortAbstraction> logicalPort, QSharedPointer<AbstractionDefinition> extendAbstraction) const\r\n{\r\n    for (auto extendPort : *extendAbstraction->getLogicalPorts())\r\n    {\r\n        if (extendPort->name() == logicalPort->name())\r\n        {\r\n            return extendPort;\r\n        }\r\n    }\r\n\r\n    return QSharedPointer<PortAbstraction>();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AbstractionDefinitionValidator::hasValidExtend()\r\n//-----------------------------------------------------------------------------\r\nbool AbstractionDefinitionValidator::hasValidExtend(QSharedPointer<AbstractionDefinition> abstraction) const\r\n{\r\n    if (!abstraction->getExtends().isEmpty() && (!library_->contains(abstraction->getExtends()) ||\r\n        !busTypeDefinesExtendedAbstractionBusType(abstraction)))\r\n    {\r\n        return false;\r\n    }\r\n    else\r\n    {\r\n        return true;\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AbstractionDefinitionValidator::busTypeDefinesExtendedAbstractionBusType()\r\n//-----------------------------------------------------------------------------\r\nbool AbstractionDefinitionValidator::busTypeDefinesExtendedAbstractionBusType(\r\n    QSharedPointer<AbstractionDefinition> abstraction) const\r\n{\r\n    QSharedPointer<AbstractionDefinition> extendAbstraction = getExtendedAbstractionDefinition(abstraction);\r\n    if (!extendAbstraction)\r\n    {\r\n        return false;\r\n    }\r\n\r\n    return busTypeIsExtendedFromExtendBusType(getBusDefinition(abstraction), getBusDefinition(extendAbstraction));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AbstractionDefinitionValidator::getExtendedAbstractionDefinition()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<AbstractionDefinition> AbstractionDefinitionValidator::getExtendedAbstractionDefinition(\r\n    QSharedPointer<AbstractionDefinition> abstraction) const\r\n{\r\n    if (abstraction->getExtends().isValid())\r\n    {\r\n        QSharedPointer<Document> extendDocument = library_->getModel(abstraction->getExtends());\r\n        if (extendDocument)\r\n        {\r\n            QSharedPointer<AbstractionDefinition> extendAbstraction =\r\n                extendDocument.dynamicCast<AbstractionDefinition>();\r\n            if (extendAbstraction)\r\n            {\r\n                return extendAbstraction;\r\n            }\r\n        }\r\n    }\r\n\r\n    return QSharedPointer<AbstractionDefinition>();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AbstractionDefinitionValidator::busTypeIsExtendedFrom()\r\n//-----------------------------------------------------------------------------\r\nbool AbstractionDefinitionValidator::busTypeIsExtendedFromExtendBusType(\r\n    QSharedPointer<const BusDefinition> busType, QSharedPointer<const BusDefinition> extendBustype) const\r\n{\r\n    if (busType == extendBustype)\r\n    {\r\n        return true;\r\n    }\r\n\r\n    QSharedPointer<const BusDefinition> busTypeExtend = getBusTypeExtend(busType);\r\n    if (busTypeExtend && busTypeIsExtendedFromExtendBusType(busTypeExtend, extendBustype))\r\n    {\r\n        return true;\r\n    }\r\n\r\n    return false;\r\n}\r\n\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AbstractionDefinitionValidator::getBusTypeExtend()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<const BusDefinition> AbstractionDefinitionValidator::getBusTypeExtend(\r\n    QSharedPointer<const BusDefinition> busType) const\r\n{\r\n    if (!busType->getExtends().isEmpty() && busType->getExtends().isValid() &&\r\n        busType->getExtends().getType() == VLNV::BUSDEFINITION)\r\n    {\r\n        QSharedPointer<const Document> extendDocument = library_->getModelReadOnly(busType->getExtends());\r\n        if (extendDocument)\r\n        {\r\n            QSharedPointer<const BusDefinition> extendBusType = extendDocument.dynamicCast<const BusDefinition>();\r\n            if (extendBusType)\r\n            {\r\n                return extendBusType;\r\n            }\r\n        }\r\n    }\r\n\r\n    return QSharedPointer<const BusDefinition>();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AbstractionDefinitionValidator::findErrorsInExtend()\r\n//-----------------------------------------------------------------------------\r\nvoid AbstractionDefinitionValidator::findErrorsInExtend(QVector<QString>& errors, QString const& context,\r\n    QSharedPointer<AbstractionDefinition> abstraction) const\r\n{\r\n    VLNV extendVLNV = abstraction->getExtends();\r\n    if (!extendVLNV.isEmpty())\r\n    {\r\n        if (!library_->contains(extendVLNV))\r\n        {\r\n            errors.append(QObject::tr(\"The bus definition %1 extended in %2 is not found in the library\")\r\n                .arg(extendVLNV.toString(), context));\r\n        }\r\n        else\r\n        {\r\n            if (!busTypeDefinesExtendedAbstractionBusType(abstraction))\r\n            {\r\n                errors.append(\r\n                    QObject::tr(\"The bus definition %1 extended in %2 does not define extended abstraction definition\"\r\n                        \" bus type\").arg(abstraction->getBusType().toString(), context));\r\n            }\r\n\r\n            findErrorsInExtendPorts(errors, context, abstraction);\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AbstractionDefinitionValidator::findErrorsInExtendPorts()\r\n//-----------------------------------------------------------------------------\r\nvoid AbstractionDefinitionValidator::findErrorsInExtendPorts(QVector<QString>& errors, QString const& context,\r\n    QSharedPointer<AbstractionDefinition> abstraction) const\r\n{\r\n    QSharedPointer<AbstractionDefinition> extendAbstraction = getExtendedAbstractionDefinition(abstraction);\r\n    if (extendAbstraction)\r\n    {\r\n        for (auto portAbstraction : *abstraction->getLogicalPorts())\r\n        {\r\n            QSharedPointer<PortAbstraction> extendPort = getMatchingExtendPort(portAbstraction, extendAbstraction);\r\n            if (extendPort)\r\n            {\r\n                if (*portAbstraction->getQualifier() != *extendPort->getQualifier())\r\n                {\r\n                    errors.append(QObject::tr(\"The qualifier of extended port %1 in %2 cannot be edited\")\r\n                        .arg(extendPort->name(), context));\r\n                }\r\n\r\n                if (portAbstraction->getMatch() != extendPort->getMatch())\r\n                {\r\n                    errors.append(QObject::tr(\"Match of extended port %1 in %2 cannot be edited\")\r\n                        .arg(extendPort->name(), context));\r\n                }\r\n\r\n                if (portAbstraction->hasWire())\r\n                {\r\n                    findErrorsInExtendWireAbstraction(errors, context, portAbstraction, extendPort);\r\n                }\r\n                if (portAbstraction->hasTransactional())\r\n                {\r\n                    findErrorsInExtendTransactionalAbstraction(errors, context, portAbstraction, extendPort);\r\n                }\r\n            }\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AbstractionDefinitionValidator::findErrorsInExtendWirePort()\r\n//-----------------------------------------------------------------------------\r\nvoid AbstractionDefinitionValidator::findErrorsInExtendWireAbstraction(QVector<QString>& errors, QString const& context,\r\n    QSharedPointer<PortAbstraction> port, QSharedPointer<PortAbstraction> extendPort) const\r\n{\r\n    if (!extendPort->hasWire())\r\n    {\r\n        errors.append(QObject::tr(\"The extended port %1 in %2 is not wire\").arg(extendPort->name(), context));\r\n        return;\r\n    }\r\n\r\n    QSharedPointer<WireAbstraction> portWire = port->getWire();\r\n    QSharedPointer<WireAbstraction> extendWire = extendPort->getWire();\r\n\r\n    findErrorsInExtendWirePort(errors, context, portWire->getMasterPort(), extendWire->getMasterPort(),\r\n        extendPort->name(), General::interfaceMode2Str(General::MASTER));\r\n    findErrorsInExtendWirePort(errors, context, portWire->getSlavePort(), extendWire->getSlavePort(),\r\n        extendPort->name(), General::interfaceMode2Str(General::SLAVE));\r\n\r\n    for (auto extendSystem : *extendWire->getSystemPorts())\r\n    {\r\n        QSharedPointer<WirePort> matchingSystem;\r\n        for (auto portSystem : *portWire->getSystemPorts())\r\n        {\r\n            if (portSystem->getSystemGroup() == extendSystem->getSystemGroup())\r\n            {\r\n                matchingSystem = portSystem;\r\n                break;\r\n            }\r\n        }\r\n\r\n        if (!matchingSystem)\r\n        {\r\n            errors.append(QObject::tr(\"The extended system %1 port %2 in %3 was not found\")\r\n                .arg(extendSystem->getSystemGroup(), extendPort->name(), context));\r\n        }\r\n        else if (matchingSystem->getDirection() != extendSystem->getDirection())\r\n        {\r\n            errors.append(QObject::tr(\"The direction of extended system %1 port %2 in %3 cannot be edited\")\r\n                .arg(extendSystem->getSystemGroup(), extendPort->name(), context));\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AbstractionDefinitionValidator::findErrorsInExtendWirePort()\r\n//-----------------------------------------------------------------------------\r\nvoid AbstractionDefinitionValidator::findErrorsInExtendWirePort(QVector<QString>& errors, QString const& context,\r\n    QSharedPointer<WirePort> port, QSharedPointer<WirePort> extendPort, QString const& portName,\r\n    QString const& modeName) const\r\n{\r\n    if (extendPort)\r\n    {\r\n        if (!port)\r\n        {\r\n            errors.append(QObject::tr(\"The extended %1 port %2 in %3 was not found\")\r\n                .arg(modeName, portName, context));\r\n        }\r\n        else if (port->getDirection() != extendPort->getDirection())\r\n        {\r\n            errors.append(QObject::tr(\"The direction of extended %1 port %2 in %3 cannot be edited\")\r\n                .arg(modeName, portName, context));\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AbstractionDefinitionValidator::findErrorsInExtendTransactionalPort()\r\n//-----------------------------------------------------------------------------\r\nvoid AbstractionDefinitionValidator::findErrorsInExtendTransactionalAbstraction(QVector<QString>& errors,\r\n    QString const& context, QSharedPointer<PortAbstraction> port, QSharedPointer<PortAbstraction> extendPort) const\r\n{\r\n    if (!extendPort->hasTransactional())\r\n    {\r\n        errors.append(QObject::tr(\"The extended port %1 in %2 is not transactional\")\r\n            .arg(extendPort->name(), context));\r\n        return;\r\n    }\r\n\r\n    QSharedPointer<TransactionalAbstraction> portTransactional = port->getTransactional();\r\n    QSharedPointer<TransactionalAbstraction> extendTransactional = extendPort->getTransactional();\r\n\r\n    QString masterContext = QObject::tr(\"extended %1 port %2 in %3\")\r\n        .arg(General::interfaceMode2Str(General::MASTER), port->name(), context);\r\n    QString slaveContext = QObject::tr(\"extended %1 port %2 in %3\")\r\n        .arg(General::interfaceMode2Str(General::SLAVE), port->name(), context);\r\n\r\n    findErrorsInExtendTransactionalPort(errors, masterContext, portTransactional->getMasterPort(),\r\n        extendTransactional->getMasterPort());\r\n    findErrorsInExtendTransactionalPort(errors, slaveContext, portTransactional->getSlavePort(),\r\n        extendTransactional->getSlavePort());\r\n\r\n    for (auto extendSystem : *extendTransactional->getSystemPorts())\r\n    {\r\n        QSharedPointer<TransactionalPort> portSystem;\r\n        for (auto transactionalSystemPort : *portTransactional->getSystemPorts())\r\n        {\r\n            if (transactionalSystemPort->getSystemGroup() == extendSystem->getSystemGroup())\r\n            {\r\n                portSystem = transactionalSystemPort;\r\n                break;\r\n            }\r\n        }\r\n\r\n        QString systemContext = QObject::tr(\"extended %1 %2 port %3 in %4\").arg(\r\n            General::interfaceMode2Str(General::SYSTEM), portSystem->getSystemGroup(),  port->name(), context);\r\n        findErrorsInExtendTransactionalPort(errors, systemContext, portSystem, extendSystem);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AbstractionDefinitionValidator::findErrorsInExtendTransactionalPort()\r\n//-----------------------------------------------------------------------------\r\nvoid AbstractionDefinitionValidator::findErrorsInExtendTransactionalPort(QVector<QString>& errors,\r\n    QString const& context, QSharedPointer<TransactionalPort> port, QSharedPointer<TransactionalPort> extendPort)\r\n    const\r\n{\r\n    if (!extendPort)\r\n    {\r\n        return;\r\n    }\r\n\r\n    if (!port)\r\n    {\r\n        errors.append(QObject::tr(\"The %1 was not found\").arg(context));\r\n    }\r\n\r\n    if (port->getInitiative() != extendPort->getInitiative())\r\n    {\r\n        errors.append(QObject::tr(\"The initiative of %1 cannot be edited\").arg(context));\r\n    }\r\n    if (port->getKind() != extendPort->getKind())\r\n    {\r\n        errors.append(QObject::tr(\"The kind of %1 cannot be edited\").arg(context));\r\n    }\r\n    if (port->getBusWidth() != extendPort->getBusWidth())\r\n    {\r\n        errors.append(QObject::tr(\"The bus width of %1 cannot be edited\").arg(context));\r\n    }\r\n\r\n    QSharedPointer<Protocol> portProtocol = port->getProtocol();\r\n    QSharedPointer<Protocol> extendPortProtocol = extendPort->getProtocol();\r\n\r\n    if ((portProtocol && !extendPortProtocol) || (!portProtocol && extendPortProtocol))\r\n    {\r\n        errors.append(QObject::tr(\"The %1 does not contain protocol data\").arg(context));\r\n    }\r\n    else if (portProtocol && extendPortProtocol)\r\n    {\r\n        if (portProtocol->getProtocolType() != extendPortProtocol->getProtocolType() ||\r\n            (portProtocol->getProtocolType() == QLatin1String(\"custom\") &&\r\n            extendPortProtocol->getProtocolType() == QLatin1String(\"custom\") &&\r\n            portProtocol->getCustomProtocolType() != extendPortProtocol->getCustomProtocolType()))\r\n        {\r\n            errors.append(QObject::tr(\"The protocol type of %1 cannot be edited\").arg(context));\r\n        }\r\n        if (portProtocol->getPayloadName() != extendPortProtocol->getPayloadName())\r\n        {\r\n            errors.append(QObject::tr(\"The payload name of %1 cannot be edited\").arg(context));\r\n        }\r\n        if (portProtocol->getPayloadType() != extendPortProtocol->getPayloadType())\r\n        {\r\n            errors.append(QObject::tr(\"The payload type of %1 cannot be edited\").arg(context));\r\n        }\r\n        if (portProtocol->getPayloadExtension() != extendPortProtocol->getPayloadExtension())\r\n        {\r\n            errors.append(QObject::tr(\"The payload extension of %1 cannot be edited\").arg(context));\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AbstractionDefinitionValidator::hasValidChoices()\r\n//-----------------------------------------------------------------------------\r\nbool AbstractionDefinitionValidator::hasValidChoices(QSharedPointer<AbstractionDefinition> abstraction) const\r\n{\r\n    auto choices = abstraction->getChoices();\r\n\r\n    if (choices->isEmpty())\r\n    {\r\n        return true;\r\n    }\r\n\r\n    if (abstraction->getRevision() != Document::Revision::Std22)\r\n    {\r\n        return false;\r\n    }\r\n\r\n    ChoiceValidator choiceValidator(expressionParser_);\r\n\r\n    for (auto const& choice : *choices)\r\n    {\r\n        if (!choiceValidator.validate(choice))\r\n        {\r\n            return false;\r\n        }\r\n    }\r\n\r\n    return true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AbstractionDefinitionValidator::findErrorsInChoices()\r\n//-----------------------------------------------------------------------------\r\nvoid AbstractionDefinitionValidator::findErrorsInChoices(QVector<QString>& errors, QString const& context,\r\n    QSharedPointer<QList<QSharedPointer<Choice> > >choices) const\r\n{\r\n    ChoiceValidator choiceValidator(expressionParser_);\r\n\r\n    for (auto const& choice : *choices)\r\n    {\r\n        choiceValidator.findErrorsIn(errors, choice, context);\r\n    }\r\n}\r\n"
  },
  {
    "path": "IPXACTmodels/AbstractionDefinition/validators/AbstractionDefinitionValidator.h",
    "content": "//-----------------------------------------------------------------------------\r\n// AbstractionDefinition: AbstractionDefinitionValidator.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Janne Virtanen\r\n// Date: 04.12.2015\r\n//\r\n// Description:\r\n// Validator for ipxact:AbstractionDefinition.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef AbstractionDefinitionVALIDATOR_H\r\n#define AbstractionDefinitionVALIDATOR_H\r\n\r\n#include <IPXACTmodels/ipxactmodels_global.h>\r\n\r\n#include <IPXACTmodels/common/validators/ParameterValidator.h>\r\n#include <IPXACTmodels/common/validators/ProtocolValidator.h>\r\n\r\n#include <IPXACTmodels/AbstractionDefinition/TransactionalPort.h>\r\n#include <IPXACTmodels/AbstractionDefinition/WirePort.h>\r\n#include <IPXACTmodels/AbstractionDefinition/validators/PortAbstractionValidator.h>\r\n\r\n#include <QString>\r\n#include <QVector>\r\n#include <QSet>\r\n\r\nclass AbstractionDefinition;\r\nclass ExpressionParser;\r\nclass LibraryInterface;\r\nclass PortAbstraction;\r\nclass BusDefinition;\r\nclass Packet;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Validator for ipxact:AbstractionDefinition.\r\n//-----------------------------------------------------------------------------\r\nclass IPXACTMODELS_EXPORT AbstractionDefinitionValidator\r\n{\r\npublic:\r\n\r\n\t/*!\r\n\t *  The constructor.\r\n\t *\r\n\t */\r\n    AbstractionDefinitionValidator(LibraryInterface* library, QSharedPointer<ExpressionParser> expressionParser);\r\n\r\n    // Disable copying.\r\n    AbstractionDefinitionValidator(AbstractionDefinitionValidator const& rhs) = delete;\r\n    AbstractionDefinitionValidator& operator=(AbstractionDefinitionValidator const& rhs) = delete;\r\n\r\n\t//! The destructor.\r\n\t~AbstractionDefinitionValidator() = default;\r\n\r\n    /*!\r\n     *  Validates the given AbstractionDefinition.\r\n     *\r\n     *    @param [in] AbstractionDefinition           The AbstractionDefinition to validate.\r\n     *\r\n     *    @return True, if the AbstractionDefinition is valid IP-XACT, otherwise false.\r\n     */\r\n    bool validate(QSharedPointer<AbstractionDefinition> abstractionDefinition);\r\n\r\n    /*!\r\n     *  Finds possible errors in a AbstractionDefinition and creates a list of them.\r\n     *\r\n     *    @param [in] errors      List of found errors.\r\n     *    @param [in] AbstractionDefinition   The AbstractionDefinition whose errors to find.\r\n     */\r\n    void findErrorsIn(QVector<QString>& errors,\r\n\t\tQSharedPointer<AbstractionDefinition> abstractionDefinition);\r\n\r\nprivate:\r\n\r\n    /*!\r\n     *  Check if the name is valid.\r\n     *\r\n     *    @param [in] name    The name to be evaluated.\r\n     *\r\n     *    @return True, if the name is valid, otherwise false.\r\n     */\r\n\tbool hasValidName(QString const& name) const;\r\n\r\n    /*!\r\n     *  Get the bus definition used by the selected abstraction definition\r\n     *\r\n     *    @param [in] abstraction     The selected abstraction definition.\r\n     *\r\n     *    @return The bus definition used by the selected abstraction definition.\r\n     */\r\n    QSharedPointer<const BusDefinition> getBusDefinition(QSharedPointer<AbstractionDefinition> abstraction) const;\r\n\r\n    /*!\r\n     *  Check if the extended port elements of the selected abstraction definition are valid.\r\n     *\r\n     *    @param [in] abstraction     The selected abstraction definition.\r\n     *\r\n     *    @return True, if the extend ports are valid, false otherwise.\r\n     */\r\n    bool hasValidExtendPorts(QSharedPointer<AbstractionDefinition> abstraction) const;\r\n\r\n    /*!\r\n     *  Check if the wire of the selected extended abstraction port is valid.\r\n     *\r\n     *    @param [in] abstractionPort     The selected abstraction port.\r\n     *    @param [in] extendPort          The extend abstraction port.\r\n     *\r\n     *    @return True, if the extended wire is valid, false otherwise.\r\n     */\r\n    bool extendWirePortIsValid(QSharedPointer<PortAbstraction> abstractionPort,\r\n        QSharedPointer<PortAbstraction> extendPort) const;\r\n\r\n    /*!\r\n     *  Check if the transactional of the selected extended abstraction port is valid.\r\n     *\r\n     *    @param [in] abstractionPort     The selected abstraction port.\r\n     *    @param [in] extendPort          The extend abstraction port.\r\n     *\r\n     *    @return True, if the extended transactional is valid, false otherwise.\r\n     */\r\n    bool extendTransactionalPortAbstractionIsValid(QSharedPointer<PortAbstraction> abstractionPort,\r\n        QSharedPointer<PortAbstraction> extendPort) const;\r\n\r\n    /*!\r\n     *  Check if the extended transactional port is valid.\r\n     *\r\n     *    @param [in] port        The selected transactional port.\r\n     *    @param [in] extendPort  The extend transactional port.\r\n     *\r\n     *    @return True, if the extended transactional port is valid, false otherwise.\r\n     */\r\n    bool extendTransactionalPortIsValid(QSharedPointer<TransactionalPort> port,\r\n        QSharedPointer<TransactionalPort> extendPort) const;\r\n\r\n    /*!\r\n     *  Get the extended port abstraction matching the selected port abstraction.\r\n     *\r\n     *    @param [in] logicalPort         The selected abstraction port.\r\n     *    @param [in] extendAbstraction   The extend abstraction definition.\r\n     *\r\n     *    @return The extend port matching the selected port.\r\n     */\r\n    QSharedPointer<PortAbstraction> getMatchingExtendPort(QSharedPointer<PortAbstraction> logicalPort,\r\n        QSharedPointer<AbstractionDefinition> extendAbstraction) const;\r\n\r\n    /*!\r\n     *  Check if the extend is valid.\r\n     *\r\n     *    @param [in] abstraction     The selected abstraction definition.\r\n     *\r\n     *    @return True, if the extend is valid, false otherwise.\r\n     */\r\n    bool hasValidExtend(QSharedPointer<AbstractionDefinition> abstraction) const;\r\n\r\n    /*!\r\n     *  Check if the contained bus type defines the bus type of the extended abstraction definition.\r\n     *\r\n     *    @param [in] abstraction     The selected abstraction definition.\r\n     *\r\n     *    @return True, if the bus type defines the extend abstraction definition bus type, false otherwise.\r\n     */\r\n    bool busTypeDefinesExtendedAbstractionBusType(QSharedPointer<AbstractionDefinition> abstraction) const;\r\n\r\n    /*!\r\n     *  Check if the selected bus type is extended from the other bus type.\r\n     *\r\n     *    @param [in] busType         The selected bus type.\r\n     *    @param [in] extendBustype   The target bus type.\r\n     *\r\n     *    @return True, if the bus type is extended from the other bus type, false otherwise.\r\n     */\r\n    bool busTypeIsExtendedFromExtendBusType(QSharedPointer<const BusDefinition> busType,\r\n        QSharedPointer<const BusDefinition> extendBustype) const;\r\n\r\n    /*!\r\n     *  Get the extend abstraction definition.\r\n     *\r\n     *    @param [in] abstraction     The selected abstraction definition.\r\n     *\r\n     *    @return The extend abstraction definition.\r\n     */\r\n    QSharedPointer<AbstractionDefinition> getExtendedAbstractionDefinition(\r\n        QSharedPointer<AbstractionDefinition> abstraction) const;\r\n\r\n    /*!\r\n     *  Get the bus type extended bus definition.\r\n     *\r\n     *    @param [in] busType     The selected bus type.\r\n     *\r\n     *    @return The extend bus definition of the selected bus type.\r\n     */\r\n    QSharedPointer<const BusDefinition> getBusTypeExtend(QSharedPointer<const BusDefinition> busType) const;\r\n\r\n    /*!\r\n     *   Find possible errors in extend of the selected abstraction definition and create a list of them.\r\n     *\r\n     *    @param [in] errors          List of found errors.\r\n     *    @param [in] context         Context to help locate the errors.\r\n     *    @param [in] abstraction     The selected abstraction definition.\r\n     */\r\n    void findErrorsInExtend(QVector<QString>& errors, QString const& context,\r\n        QSharedPointer<AbstractionDefinition> abstraction) const;\r\n\r\n    /*!\r\n     *  Find errors in extended port abstractions of the selected abstraction definition.\r\n     *\r\n     *    @param [in] errors          List of found errors.\r\n     *    @param [in] context         Context to help locate the errors.\r\n     *    @param [in] abstraction     The selected abstraction definition.\r\n     */\r\n    void findErrorsInExtendPorts(QVector<QString>& errors, QString const& context,\r\n        QSharedPointer<AbstractionDefinition> abstraction) const;\r\n\r\n    /*!\r\n     *  Find errors in wire abstraction of the selected extend port abstraction.\r\n     *\r\n     *    @param [in] errors      List of found errors.\r\n     *    @param [in] context     Context to help locate the errors.\r\n     *    @param [in] port        The selected abstraction port.\r\n     *    @param [in] extendPort  The extend port.\r\n     */\r\n    void findErrorsInExtendWireAbstraction(QVector<QString>& errors, QString const& context,\r\n        QSharedPointer<PortAbstraction> port, QSharedPointer<PortAbstraction> extendPort) const;\r\n\r\n    /*!\r\n     *  Find errors in the selected extend wire port.\r\n     *\r\n     *    @param [in] errors      List of found errors.\r\n     *    @param [in] context     Context to help locate the errors.\r\n     *    @param [in] port        The selected wire port.\r\n     *    @param [in] extendPort  The extend port.\r\n     *    @param [in] portName    Name of the port.\r\n     *    @param [in] modeName    Name of the mode.\r\n     */\r\n    void findErrorsInExtendWirePort(QVector<QString>& errors, QString const& context,\r\n        QSharedPointer<WirePort> port, QSharedPointer<WirePort> extendPort, QString const& portName,\r\n        QString const& modeName) const;\r\n\r\n    /*!\r\n     *  Find errors in transactional abstraction of the selected extend port abstraction.\r\n     *\r\n     *    @param [in] errors      List of found errors.\r\n     *    @param [in] context     Context to help locate the errors.\r\n     *    @param [in] port        The selected abstraction port.\r\n     *    @param [in] extendPort  The extend port.\r\n     */\r\n    void findErrorsInExtendTransactionalAbstraction(QVector<QString>& errors, QString const& context,\r\n        QSharedPointer<PortAbstraction> port, QSharedPointer<PortAbstraction> extendPort) const;\r\n\r\n    /*!\r\n     *  Find errors in transactional abstraction of the selected extend port abstraction.\r\n     *\r\n     *    @param [in] errors      List of found errors.\r\n     *    @param [in] context     Context to help locate the errors.\r\n     *    @param [in] port        The selected transactional port.\r\n     *    @param [in] extendPort  The extend port.\r\n     */\r\n    void findErrorsInExtendTransactionalPort(QVector<QString>& errors, QString const& context,\r\n        QSharedPointer<TransactionalPort> port, QSharedPointer<TransactionalPort> extendPort) const;\r\n\r\n    /*!\r\n     *\tCheck if the choices of the abstraction definition are valid.\r\n     *  \r\n     *    @param [in] abstraction\t    The abstraction definition to check.\r\n     *\t\t\r\n     * \t\t@return True, if choices are valid, otherwise false.\r\n     */\r\n    bool hasValidChoices(QSharedPointer<AbstractionDefinition> abstraction) const;\r\n\r\n    /*!\r\n     *\tFind errors in the choices of an abstraction definition.\r\n     *  \r\n     *    @param [in] errors\t    List of found errors.\r\n     *    @param [in] context\t    Context to help locate the errors.\r\n     *    @param [in] choices\t    The choices to check.\r\n     */\r\n    void findErrorsInChoices(QVector<QString>& errors, QString const& context,\r\n        QSharedPointer<QList<QSharedPointer<Choice> > > choices) const;\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! The IP-XACT library available.\r\n    LibraryInterface* library_;\r\n\r\n    //! Parser for expressions in abstraction definition.\r\n    QSharedPointer<ExpressionParser> expressionParser_;\r\n\r\n    //! Validator for abstraction definition parameters.\r\n    QSharedPointer<ParameterValidator> parameterValidator_;\r\n\r\n    PortAbstractionValidator portsValidator_;\r\n\r\n    //! Validator for protocols within transactional ports.\r\n    ProtocolValidator protocolValidator_;\r\n};\r\n\r\n#endif // SYSTEMVERILOGVALIDATOR_H\r\n"
  },
  {
    "path": "IPXACTmodels/AbstractionDefinition/validators/PacketValidator.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: PacketValidator.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Anton Hagqvist\n// Date: 06.06.2023\n//\n// Description:\n// Validator for ipxact:packet.\n//-----------------------------------------------------------------------------\n\n#include \"PacketValidator.h\"\n\n#include <IPXACTmodels/common/validators/QualifierValidator.h>\n\n#include <QRegularExpression>\n\n//-----------------------------------------------------------------------------\n// Function: PacketValidator::PacketValidator()\n//-----------------------------------------------------------------------------\nPacketValidator::PacketValidator(QSharedPointer<ExpressionParser> expressionParser):\n    expressionParser_(expressionParser)\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: PacketValidator::validate()\n//-----------------------------------------------------------------------------\nbool PacketValidator::validate(QSharedPointer<Packet> packet) const\n{\n    if (!isValidName(packet->name()) || packet->getPacketFields()->isEmpty())\n    {\n        return false;\n    }\n\n    for (auto const& packetField : *packet->getPacketFields())\n    {\n        if (!isValidPacketField(packetField))\n        {\n            return false;\n        }\n    }\n\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PacketValidator::findErrorsIn()\n//-----------------------------------------------------------------------------\nvoid PacketValidator::findErrorsIn(QStringList& errors, QSharedPointer<Packet> packet, QString const& context) const\n{\n    if (packet->name().isEmpty())\n    {\n        errors.append(QObject::tr(\"Unnamed packet in %1\").arg(context));\n    }\n\n    if (packet->getPacketFields()->isEmpty())\n    {\n        errors.append(QObject::tr(\"No packet field defined for packet %1 in %2\").arg(packet->name(), context));\n    }\n    \n    auto fieldContext = QStringLiteral(\"packet \") + packet->name() + QStringLiteral(\" within \") + context;\n\n    for (auto const& packetField : *packet->getPacketFields())\n    {\n        findErrorsInPacketField(errors, fieldContext, packetField);\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: PacketValidator::isValidPacketField()\n//-----------------------------------------------------------------------------\nbool PacketValidator::isValidPacketField(QSharedPointer<PacketField> packetField) const\n{\n    if (!isValidName(packetField->name()))\n    {\n        return false;\n    }\n\n    // Check validity of field width.\n    bool widthIsValid = false;\n    auto resolvedWidth = parseFieldWidth(packetField->getWidth(), &widthIsValid);\n    if (!widthIsValid)\n    {\n        return false;\n    }\n\n    if (!hasValidFieldValue(packetField, resolvedWidth))\n    {\n        return false;\n    }\n\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PacketValidator::findErrorsInPacketField()\n//-----------------------------------------------------------------------------\nvoid PacketValidator::findErrorsInPacketField(QStringList& errors, QString const& context, \n    QSharedPointer<PacketField> packetField) const\n{\n    if (packetField->name().isEmpty())\n    {\n        errors.append(QObject::tr(\"No name defined for packet field in %1\").arg(context));\n    }\n\n    bool validWidth = false;\n    auto resolvedWidth = parseFieldWidth(packetField->getWidth(), &validWidth);\n    if (!validWidth)\n    {\n        errors.append(QObject::tr(\"Missing or invalid width defined for packet field %1 in %2\").arg(\n            packetField->name(), context));\n    }\n\n    findErrorsInPacketFieldValue(errors, context, packetField, resolvedWidth);\n}\n\n//-----------------------------------------------------------------------------\n// Function: PacketValidator::isValidName()\n//-----------------------------------------------------------------------------\nbool PacketValidator::isValidName(QString const& name) const\n{\n    QRegularExpression whiteSpaceExpression(QStringLiteral(\"^\\\\s*$\"));\n    QRegularExpressionMatch whiteSpaceMatch = whiteSpaceExpression.match(name);\n\n    if (name.isEmpty() || whiteSpaceMatch.hasMatch())\n    {\n        return false;\n    }\n\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PacketValidator::parseFieldWidth()\n//-----------------------------------------------------------------------------\nQString PacketValidator::parseFieldWidth(QString const& width, bool* widthIsValid) const\n{\n    bool validWidth = false;\n    auto resolvedWidth = expressionParser_->parseExpression(width, &validWidth);\n    if (width.isEmpty() || !validWidth)\n    {\n        *widthIsValid = false;\n        return QStringLiteral(\"\");\n    }\n\n    *widthIsValid = true;\n    return resolvedWidth;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PacketValidator::hasValidFieldValue()\n//-----------------------------------------------------------------------------\nbool PacketValidator::hasValidFieldValue(QSharedPointer<PacketField> packetField, \n    QString const& fieldWidth) const\n{\n    // Validate that field value bit width <= field width.\n\n    auto value = packetField->getValue();\n    if (value.isEmpty())\n    {\n        return true;\n    }\n\n    // Check if value is constant.\n    bool valueIsConstant = expressionParser_->isPlainValue(value);\n    QString resolvedValue;\n\n    if (!valueIsConstant)\n    {\n        // Value must be fixed, if opcode qualifier is set.\n        if (packetField->getQualifier()->hasType(Qualifier::Type::Opcode))\n        {\n            return false;\n        }\n\n        bool valueIsValid = false;\n        resolvedValue = expressionParser_->parseExpression(value, &valueIsValid);\n\n        if (!valueIsValid)\n        {\n            return false;\n        }\n        \n        // Convert to binary\n        resolvedValue = QString::number(resolvedValue.toInt(), 2);\n    }\n    else\n    {\n        resolvedValue = parseConstantFieldValue(value);\n    }\n\n    // Return false if parsing failed or if value width exceeds field width.\n    if (resolvedValue == QStringLiteral(\"x\") || resolvedValue.length() > fieldWidth.toInt())\n    {\n        return false;\n    }\n\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PacketValidator::findErrorsInPacketFieldValue()\n//-----------------------------------------------------------------------------\nvoid PacketValidator::findErrorsInPacketFieldValue(QStringList& errors, QString const& context, \n    QSharedPointer<PacketField> packetField, QString const& resolvedFieldWidth) const\n{\n    if (!hasValidFieldValue(packetField, resolvedFieldWidth))\n    {\n        errors.append(QObject::tr(\"Invalid packet field value within packet field %1 in %2.\").arg(\n            packetField->name(), context));\n    }\n    \n    auto value = packetField->getValue();\n\n    // Check if value is constant.\n    bool valueIsConstant = expressionParser_->isPlainValue(value);\n    QString resolvedValue;\n\n    if (!valueIsConstant)\n    {\n        // Value must be fixed, if opcode qualifier is set.\n        if (packetField->getQualifier()->hasType(Qualifier::Type::Opcode))\n        {\n            errors.append(QObject::tr(\"Value of packet field %1 in %2 must be constant when qualifier is opcode.\").arg(\n                packetField->name(), context));\n        }\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: PacketValidator::parseConstantFieldValue()\n//-----------------------------------------------------------------------------\nQString PacketValidator::parseConstantFieldValue(QString token) const\n{\n    if (token.contains(QLatin1Char('.')))\n    {\n        return token;\n    }\n\n    int base = baseOf(token);\n\n    // Remove formating of the number.\n    static QRegularExpression prefix(QStringLiteral(\"^([1-9][0-9_]*)?'[sS]?[dDbBoOhH]?\"));\n    token.remove(0, prefix.match(token).capturedLength());\n    token.remove(QLatin1Char('_'));\n\n    bool valid = false;\n    qlonglong value = token.toLongLong(&valid, base);\n    if (valid == false)\n    {\n        return QStringLiteral(\"x\");\n    }\n\n    // Convert to binary\n    return QString::number(value, 2);\n}\n\n//-----------------------------------------------------------------------------\n// Function: PacketValidator::baseOf()\n//-----------------------------------------------------------------------------\nint PacketValidator::baseOf(QString const& constantNumber) const\n{\n    const static QMap<QString, int> base_formats =\n    {\n        { QString(), 10 },\n        { QStringLiteral(\"d\"), 10 },\n        { QStringLiteral(\"D\"), 10 },\n        { QStringLiteral(\"h\"), 16 },\n        { QStringLiteral(\"H\"), 16 },\n        { QStringLiteral(\"o\"), 8 },\n        { QStringLiteral(\"O\"), 8 },\n        { QStringLiteral(\"b\"), 2 },\n        { QStringLiteral(\"B\"), 2 },\n    };\n\n    static QRegularExpression baseFormat(QStringLiteral(\"'[sS]?([dDbBoOhH]?)\"));\n\n    QString format = baseFormat.match(constantNumber).captured(1);\n\n    return base_formats.value(format, 0);\n}\n"
  },
  {
    "path": "IPXACTmodels/AbstractionDefinition/validators/PacketValidator.h",
    "content": "//-----------------------------------------------------------------------------\n// File: PacketValidator.h\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Anton Hagqvist\n// Date: 06.06.2023\n//\n// Description:\n// Validator for ipxact:packet.\n//-----------------------------------------------------------------------------\n\n#ifndef PACKETVALIDATOR_H\n#define PACKETVALIDATOR_H\n\n#include <IPXACTmodels/ipxactmodels_global.h>\n#include <IPXACTmodels/AbstractionDefinition/Packet.h>\n\n#include <KactusAPI/include/ExpressionParser.h>\n\n#include <QString>\n#include <QStringList>\n#include <QSharedPointer>\n\n//-----------------------------------------------------------------------------\n//! Validator for ipxact:packet.\n//-----------------------------------------------------------------------------\nclass IPXACTMODELS_EXPORT PacketValidator\n{\npublic:\n\n    PacketValidator(QSharedPointer<ExpressionParser> expressionParser);\n\n    ~PacketValidator() = default;\n\n    // Disable copying.\n    PacketValidator(PacketValidator const& other) = delete;\n    PacketValidator& operator=(PacketValidator const& other) = delete;\n\n    /*!\n     *  Validates the given Packet.\n     *\n     *    @param [in] packet  The packet to validate.\n     *\n     *    @return True, if the Packet is valid IP-XACT, otherwise false.\n     */\n    bool validate(QSharedPointer<Packet> packet) const;\n\n    /*!\n     *  Finds possible errors in a Packet and creates a list of them.\n     *\n     *    @param [in] errors      List of found errors.\n     *    @param [in] packet      The AbstractionDefinition whose errors to find.\n     *    @param [in] context     Context to help locate the error.\n     */\n    void findErrorsIn(QStringList& errors, QSharedPointer<Packet> packet, QString const& context) const;\n\nprivate:\n\n    /*!\n     *\tChecks if packet field is valid.\n     *  \n     *    @param [in] packetField     The packet field to check.\n     *\t\t\n     * \t\t@return True, if field is valid, otherwise false.\n     */\n    bool isValidPacketField(QSharedPointer<PacketField> packetField) const;\n\n    /*!\n     *\tFinds possible errors in a packet field and creates a list of them.\n     *  \n     *    @param [in] errors\t        List of found errors.\n     *    @param [in] context\t        Context to help locate the error.\n     *    @param [in] packetField\t    The packet field to check.\n     */\n    void findErrorsInPacketField(QStringList& errors, QString const& context, QSharedPointer<PacketField> packetField) const;\n\n    /*!\n     *\tChecks the validity of a packet or packet field name.\n     *  \n     *    @param [in] name\tThe name to check.\n     *\t\t\n     * \t\t@return True, if name is valid, otherwise false.\n     */\n    bool isValidName(QString const& name) const;\n\n    /*!\n     *\tParses the field width expression.\n     *  \n     *    @param [in] width\t        The width value to parse.\n     *    @param [in] widthIsValid\tIndicates if the parsed width is valid.\n     *\t\t\n     * \t\t@return Resolved width expression in bits.\n     */\n    QString parseFieldWidth(QString const& width, bool* widthIsValid) const;\n\n    /*!\n     *\tChecks if the packet field contains a valid value.\n     *  \n     *    @param [in] packetField\t    The packet field to check.\n     *    @param [in] fieldWidth\t    The width of the field in bits.\n     *\t\t\n     * \t\t@return True, if the value is valid, otherwise false.\n     */\n    bool hasValidFieldValue(QSharedPointer<PacketField> packetField, QString const& fieldWidth) const;\n\n    /*!\n     *\tFinds possible errors in a packet field value.\n     *  \n     *    @param [in] errors\t                List of found errors.\n     *    @param [in] context\t                Context to help locate the error.\n     *    @param [in] packetField\t            The packet field to check.\n     *    @param [in] resolvedFieldWidth      The width of the packet field in bits.\n     */\n    void findErrorsInPacketFieldValue(QStringList& errors, QString const& context,\n        QSharedPointer<PacketField> packetField, QString const& resolvedFieldWidth) const;\n\n    /*!\n     *\tParses a constant field value.\n     *  \n     *    @param [in] token\tDescription\n     *\t\t\n     * \t\t@return The resolved value expression in binary.\n     */\n    QString parseConstantFieldValue(QString token) const;\n\n    /*!\n     *  Get the base for a given number.\n     *\n     *    @param [in] constantNumber  The selected number.\n     *\n     *    @return The base for the selected number. Either 2, 8, 10 or 16.\n     */\n    int baseOf(QString const& constantNumber) const;\n\n    //! The Expression parser used to validate expressions in packet field elements.\n    QSharedPointer<ExpressionParser> expressionParser_;\n\n};\n\n#endif // PACKETVALIDATOR_H\n"
  },
  {
    "path": "IPXACTmodels/AbstractionDefinition/validators/PortAbstractionValidator.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: PortAbstractionValidator.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Anton Hagqvist\n// Date: 03.09.2024\n//\n// Description:\n// Validator for port abstractions.\n//-----------------------------------------------------------------------------\n\n#include \"PortAbstractionValidator.h\"\n\n#include <IPXACTmodels/AbstractionDefinition/AbstractionDefinition.h>\n#include <IPXACTmodels/AbstractionDefinition/WireAbstraction.h>\n#include <IPXACTmodels/AbstractionDefinition/TransactionalAbstraction.h>\n#include <IPXACTmodels/AbstractionDefinition/PortAbstraction.h>\n#include <IPXACTmodels/AbstractionDefinition/WirePort.h>\n#include <IPXACTmodels/AbstractionDefinition/TransactionalPort.h>\n\n#include <IPXACTmodels/common/TransactionalTypes.h>\n\n#include <IPXACTmodels/BusDefinition/BusDefinition.h>\n#include <IPXACTmodels/utilities/BusDefinitionUtils.h>\n\n#include <IPXACTmodels/common/validators/CommonItemsValidator.h>\n#include <IPXACTmodels/common/validators/QualifierValidator.h>\n#include <IPXACTmodels/common/validators/TimingConstraintValidator.h>\n#include <IPXACTmodels/common/validators/CellSpecificationValidator.h>\n\n#include <KactusAPI/include/ExpressionParser.h>\n\n//-----------------------------------------------------------------------------\n// Function: PortAbstractionValidator::PortAbstractionValidator()\n//-----------------------------------------------------------------------------\nPortAbstractionValidator::PortAbstractionValidator(LibraryInterface* library,\n    QSharedPointer<ExpressionParser> expressionParser) :\nexpressionParser_(expressionParser),\nlibrary_(library),\npacketValidator_(expressionParser_)\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortAbstractionValidator::validate()\n//-----------------------------------------------------------------------------\nbool PortAbstractionValidator::validate(QSharedPointer<PortAbstraction> port,\n    QSharedPointer<AbstractionDefinition > abstractionDefinition,\n    QSharedPointer<const BusDefinition> busDefinition) const\n{\n    if (!hasValidName(port))\n    {\n        return false;\n    }\n\n    if (abstractionDefinition->getRevision() != Document::Revision::Std22)\n    {\n        if (port->getMatch())\n        {\n            return false;\n        }\n\n        // Presence must be valid expression if defined.\n        bool isValidPresence = false;\n        expressionParser_->parseExpression(port->isPresent(), &isValidPresence);\n        if (!isValidPresence)\n        {\n            return false;\n        }\n    }\n    else\n    {\n        if (!port->isPresent().isEmpty())\n        {\n            return false;\n        }\n    }\n\n    QSharedPointer<WireAbstraction> wire = port->getWire();\n    QSharedPointer<TransactionalAbstraction> transactional = port->getTransactional();\n\n    // Must be wire XOR trans.\n    if ((!wire && !transactional) || (wire && transactional))\n    {\n        return false;\n    }\n\n    QStringList systemGroups = BusDefinitionUtils::getSystemGroups(busDefinition, library_);\n\n    auto ports = abstractionDefinition->getLogicalPorts();\n    if (wire)\n    {\n        if (!isValidPortQualifier(wire->getQualifier(), abstractionDefinition->getRevision()))\n        {\n            return false;\n        }\n\n        // Default value must be valid expression if defined.\n        bool isValidDefaultValue = false;\n        expressionParser_->parseExpression(wire->getDefaultValue(), &isValidDefaultValue);\n        if (isValidDefaultValue == false)\n        {\n            return false;\n        }\n\n        // Master and slave ports must be valid if exist.\n        if (wire->getMasterPort() && !isValidWirePort(wire->getMasterPort(), ports))\n        {\n            return false;\n        }\n\n        if (wire->getSlavePort() && !isValidWirePort(wire->getSlavePort(), ports))\n        {\n            return false;\n        }\n\n        // System ports must be valid if exist.\n        if (wire->getSystemPorts())\n        {\n            for (auto const& systemWirePort : *wire->getSystemPorts())\n            {\n                if (!isValidWirePort(systemWirePort, ports) ||\n                    !systemGroups.contains(systemWirePort->getSystemGroup()))\n                {\n                    return false;\n                }\n            }\n        }\n    }\n\n    if (transactional)\n    {\n        if (!isValidPortQualifier(transactional->getQualifier(), abstractionDefinition->getRevision()))\n        {\n            return false;\n        }\n\n        // Master and slave ports must be valid if exist.\n        if (transactional->getMasterPort() && !isValidTransactionalPort(transactional->getMasterPort()))\n        {\n            return false;\n        }\n\n        if (transactional->getSlavePort() && !isValidTransactionalPort(transactional->getSlavePort()))\n        {\n            return false;\n        }\n\n        // System ports must be valid if exist.\n        if (transactional->getSystemPorts())\n        {\n            for (auto const& transPort : *transactional->getSystemPorts())\n            {\n                if (!isValidTransactionalPort(transPort) || !systemGroups.contains(transPort->getSystemGroup()))\n                {\n                    return false;\n                }\n            }\n        }\n    }\n\n    if (!port->getPackets()->isEmpty() && (abstractionDefinition->getRevision() == Document::Revision::Std14 ||\n        !hasValidPortPackets(port)))\n    {\n        return false;\n    }\n\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortAbstractionValidator::findErrorsIn()\n//-----------------------------------------------------------------------------\nvoid PortAbstractionValidator::findErrorsIn(QStringList& errors, QSharedPointer<PortAbstraction> port,\n    QSharedPointer<AbstractionDefinition> abstractionDefinition, \n    QSharedPointer<const BusDefinition> busDefinition) const\n{\n    // The name must be non-empty.\n    if (!hasValidName(port))\n    {\n        errors.append(QObject::tr(\"Port name %1 is invalid.\").arg(port->getLogicalName()));\n    }\n\n    // Presence must be valid expression if defined.\n    if (!isValidExpression(port->isPresent()))\n    {\n        errors.append(QObject::tr(\"The presence '%1' of port %2 is invalid.\")\n            .arg(port->isPresent(), port->getLogicalName()));\n    }\n\n    if (abstractionDefinition->getRevision() != Document::Revision::Std22 && port->getMatch())\n    {\n        errors.append(QObject::tr(\"Port match is set for port %1 in abstraction definition not using IP-XACT\"\n            \" standard revision 2022.\").arg(port->getLogicalName()));\n    }\n\n    QSharedPointer<WireAbstraction> wire = port->getWire();\n    QSharedPointer<TransactionalAbstraction> transactional = port->getTransactional();\n\n    // Must be wire XOR trans.\n    if (!wire && !transactional)\n    {\n        errors.append(QObject::tr(\"Port %1 has neither wire nor transactional defined.\").arg(\n            port->getLogicalName()));\n    }\n\n    if (wire && transactional)\n    {\n        errors.append(QObject::tr(\"Port %1 has both wire and transactional.\").arg(port->getLogicalName()));\n    }\n\n    QString context = QObject::tr(\"port %1\").arg(port->getLogicalName());\n\n    QStringList systemGroupNames;\n    QString busDefinitionIdentifier = QStringLiteral(\":::\");\n    if (busDefinition)\n    {\n        systemGroupNames = BusDefinitionUtils::getSystemGroups(busDefinition, library_);\n        busDefinitionIdentifier = busDefinition->getVlnv().toString();\n    }\n\n    auto ports = abstractionDefinition->getLogicalPorts();\n    if (wire)\n    {\n        if (auto qualifier = wire->getQualifier(); qualifier->isSet())\n        {\n            findErrorsInPortQualifier(errors, qualifier, context, abstractionDefinition);\n        }\n\n        // Default value must be valid expression if defined.\n        bool isValidDefaultValue = false;\n        expressionParser_->parseExpression(wire->getDefaultValue(), &isValidDefaultValue);\n        if (isValidDefaultValue == false)\n        {\n            errors.append(QObject::tr(\"Default value for port %1 is invalid.\").arg(port->getLogicalName()));\n        }\n\n        // Master and slave ports must be valid if exist.\n        if (wire->getMasterPort())\n        {\n            findErrorsInWirePort(errors, wire->getMasterPort(), context, ports);\n        }\n\n        if (wire->getSlavePort())\n        {\n            findErrorsInWirePort(errors, wire->getSlavePort(), context, ports);\n        }\n\n        // System ports must be valid if exist.\n        if (wire->getSystemPorts())\n        {\n            for (auto const& wirePort : *wire->getSystemPorts())\n            {\n                findErrorsInWirePort(errors, wirePort, context, ports);\n                findErrorsInSystemGroup(\n                    errors, wirePort->getSystemGroup(), context, systemGroupNames, busDefinitionIdentifier);\n            }\n        }\n    }\n\n    if (transactional)\n    {\n        if (auto qualifier = transactional->getQualifier(); qualifier->isSet())\n        {\n            findErrorsInPortQualifier(errors, qualifier, context, abstractionDefinition);\n        }\n\n        // Master and slave ports must be valid if exist.\n        if (transactional->getMasterPort())\n        {\n            findErrorsInTransactionalPort(errors, context, transactional->getMasterPort());\n        }\n\n        if (transactional->getSlavePort())\n        {\n            findErrorsInTransactionalPort(errors, context, transactional->getSlavePort());\n        }\n\n        if (transactional->getSystemPorts())\n        {\n            // System ports must be valid if exist.\n            for (auto const& transPort : *transactional->getSystemPorts())\n            {\n                findErrorsInTransactionalPort(errors, context, transPort);\n                findErrorsInSystemGroup(\n                    errors, transPort->getSystemGroup(), context, systemGroupNames, busDefinitionIdentifier);\n            }\n        }\n    }\n\n    findErrorsInPortPackets(errors, context, port, abstractionDefinition->getRevision());\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortAbstractionValidator::hasValidName()\n//-----------------------------------------------------------------------------\nbool PortAbstractionValidator::hasValidName(QSharedPointer<PortAbstraction> portAbstraction) const\n{\n    return CommonItemsValidator::hasValidName(portAbstraction->getLogicalName());\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortAbstractionValidator::wireHasValidDefaultValue()\n//-----------------------------------------------------------------------------\nbool PortAbstractionValidator::wireHasValidDefaultValue(QSharedPointer<WireAbstraction> wireAbstraction) const\n{\n    return isValidExpression(wireAbstraction->getDefaultValue());\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortAbstractionValidator::isValidWirePort()\n//-----------------------------------------------------------------------------\nbool PortAbstractionValidator::isValidWirePort(QSharedPointer<WirePort> wirePort, QSharedPointer<QList<QSharedPointer<PortAbstraction> > > ports) const\n{\n    // Width must be valid expression if defined.\n    // Any existing constraints must be valid.\n    if (!wireHasValidWidth(wirePort) || !validateConstraints(wirePort, ports))\n    {\n        return false;\n    }\n\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortAbstractionValidator::wireHasValidWidth()\n//-----------------------------------------------------------------------------\nbool PortAbstractionValidator::wireHasValidWidth(QSharedPointer<WirePort> wirePort) const\n{\n    return isValidExpression(wirePort->getWidth());\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortAbstractionValidator::isValidTransactionalPort()\n//-----------------------------------------------------------------------------\nbool PortAbstractionValidator::isValidTransactionalPort(QSharedPointer<TransactionalPort> transPort) const\n{\n    // Initiative must be an existing one.\n    if (!transPort->getInitiative().isEmpty() &&\n        !TransactionalTypes::isIpXactInitiativeType(transPort->getInitiative()))\n    {\n        return false;\n    }\n\n    // Kind must be an existing one.\n    if (!transPort->getKind().isEmpty() && !TransactionalTypes::isIpXactKindType(transPort->getKind()))\n    {\n        return false;\n    }\n\n    // Bus width must be valid expression if defined.\n    if (!transactionalHasValidBusWidth(transPort))\n    {\n        return false;\n    }\n\n    QSharedPointer<Protocol> protocol = transPort->getProtocol();\n\n    // Protocol must be valid if it exists.\n    if (protocol && !protocolValidator_.validate(protocol))\n    {\n        return false;\n    }\n\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortAbstractionValidator::transactionalHasValidBusWidth()\n//-----------------------------------------------------------------------------\nbool PortAbstractionValidator::transactionalHasValidBusWidth(QSharedPointer<TransactionalPort> transPort) const\n{\n    return isValidExpression(transPort->getBusWidth());\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortAbstractionValidator::isValidPortQualifier()\n//-----------------------------------------------------------------------------\nbool PortAbstractionValidator::isValidPortQualifier(QSharedPointer<Qualifier> qualifier, Document::Revision documentRevision) const\n{\n    if (!QualifierValidator::validate(qualifier, documentRevision))\n    {\n        return false;\n    }\n\n    if (qualifier->hasType(Qualifier::Type::PowerEnable) &&\n        !qualifier->getAttribute(Qualifier::Attribute::PowerDomainReference).isEmpty())\n    {\n        return false;\n    }\n\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortAbstractionValidator::validateConstraints()\n//-----------------------------------------------------------------------------\nbool PortAbstractionValidator::validateConstraints(QSharedPointer<WirePort> wirePort, QSharedPointer<QList<QSharedPointer<PortAbstraction> > > ports) const\n{\n    // Validate timing constraints.\n    TimingConstraintValidator timeConstraintValidator;\n\n    if (auto timing = wirePort->getTimingConstraint();\n        timing && !timeConstraintValidator.validate(timing, ports))\n    {\n        return false;\n    }\n\n    if (auto timingMirrored = wirePort->getMirroredTimingConstraint();\n        timingMirrored && !timeConstraintValidator.validate(timingMirrored, ports))\n    {\n        return false;\n    }\n\n    // Validate driver constraints.\n    CellSpecificationValidator cellConstraintValidator;\n\n    if (auto drive = wirePort->getDriveConstraint();\n        drive && !cellConstraintValidator.validate(drive))\n    {\n        return false;\n    }\n\n    if (auto driveMirrored = wirePort->getMirroredDriveConstraint();\n        driveMirrored && !cellConstraintValidator.validate(driveMirrored))\n    {\n        return false;\n    }\n\n    // Validate load constraints.\n    if (auto load = wirePort->getLoadConstraint();\n        load && !cellConstraintValidator.validate(load))\n    {\n        return false;\n    }\n\n    if (auto loadMirrored = wirePort->getMirroredLoadConstraint();\n        loadMirrored && !cellConstraintValidator.validate(loadMirrored))\n    {\n        return false;\n    }\n\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortAbstractionValidator::hasValidPortPackets()\n//-----------------------------------------------------------------------------\nbool PortAbstractionValidator::hasValidPortPackets(QSharedPointer<PortAbstraction> port) const\n{\n    auto packets = port->getPackets();\n\n    if (packets->isEmpty())\n    {\n        return true;\n    }\n\n    PacketValidator packetValidator(expressionParser_);\n    for (auto const& packet : *packets)\n    {\n        if (!packetValidator.validate(packet))\n        {\n            return false;\n        }\n    }\n\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortAbstractionValidator::findErrorsInConstraints()\n//-----------------------------------------------------------------------------\nvoid PortAbstractionValidator::findErrorsInConstraints(QStringList& errors, QSharedPointer<WirePort> wirePort, QString const& context, QSharedPointer<QList<QSharedPointer<PortAbstraction> > > ports) const\n{\n    // Validate timing constraints.\n    TimingConstraintValidator timeConstraintValidator;\n\n    if (auto timing = wirePort->getTimingConstraint())\n    {\n        timeConstraintValidator.findErrorsIn(errors, timing, context, ports);\n    }\n\n    \n    if (auto timingMirrored = wirePort->getMirroredTimingConstraint())\n    {\n        timeConstraintValidator.findErrorsIn(errors, timingMirrored, context, ports);\n    }\n\n    // Validate driver constraints.\n    CellSpecificationValidator cellConstVal;\n\n    if (auto drive = wirePort->getDriveConstraint())\n    {\n        cellConstVal.findErrorsIn(errors, drive, context);\n    }\n\n    if (auto driveMirrored = wirePort->getMirroredDriveConstraint())\n    {\n        cellConstVal.findErrorsIn(errors, driveMirrored, context);\n    }\n\n    // Validate load constraints.\n    if (auto load = wirePort->getLoadConstraint())\n    {\n        cellConstVal.findErrorsIn(errors, load, context);\n    }\n\n    if (auto loadMirrored = wirePort->getMirroredLoadConstraint())\n    {\n        cellConstVal.findErrorsIn(errors, loadMirrored, context);\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortAbstractionValidator::findErrorsInWirePort()\n//-----------------------------------------------------------------------------\nvoid PortAbstractionValidator::findErrorsInWirePort(QStringList& errors, QSharedPointer<WirePort> wirePort, QString const& context, QSharedPointer<QList<QSharedPointer<PortAbstraction> > > ports) const\n{\n    // Width must be valid expression if defined.\n    if (!wireHasValidWidth(wirePort))\n    {\n        errors.append(QObject::tr(\"Wire port width is invalid in %1.\").arg(context));\n    }\n\n    // Any existing constraints must be valid.\n    findErrorsInConstraints(errors, wirePort, context, ports);\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortAbstractionValidator::findErrorsInTransactionalPort()\n//-----------------------------------------------------------------------------\nvoid PortAbstractionValidator::findErrorsInTransactionalPort(QStringList& errors, QString const& context, QSharedPointer<TransactionalPort> transPort) const\n{\n    // Initiative must be an existing one.\n    if (!transPort->getInitiative().isEmpty() &&\n        !TransactionalTypes::isIpXactInitiativeType(transPort->getInitiative()))\n    {\n        errors.append(QObject::tr(\"The transactional port initiative %1 is invalid in %2.\")\n            .arg(transPort->getInitiative(), context));\n    }\n\n    // Kind must be an existing one.\n    if (!transPort->getKind().isEmpty() && !TransactionalTypes::isIpXactKindType(transPort->getKind()))\n    {\n        errors.append(QObject::tr(\"The transactional port kind %1 is invalid in %2.\")\n            .arg(transPort->getInitiative(), context));\n    }\n\n    // Bus width must be valid expression if defined.\n    bool isValidBusWidth = false;\n    expressionParser_->parseExpression(transPort->getBusWidth(), &isValidBusWidth);\n    if (isValidBusWidth == false)\n    {\n        errors.append(QObject::tr(\"The transactional port bus width is invalid in %1.\").arg(context));\n    }\n\n    // Protocol must be valid if it exists.\n    if (QSharedPointer<Protocol> protocol = transPort->getProtocol())\n    {\n        protocolValidator_.findErrorsIn(errors, protocol, context);\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortAbstractionValidator::findErrorsInPortQualifier()\n//-----------------------------------------------------------------------------\nvoid PortAbstractionValidator::findErrorsInPortQualifier(QStringList& errors, QSharedPointer<Qualifier> qualifier, QString const& context, QSharedPointer<AbstractionDefinition> abstraction) const\n{\n    QualifierValidator::findErrorsIn(errors, qualifier, context, abstraction->getRevision());\n\n    if (qualifier->hasType(Qualifier::Type::PowerEnable) && \n        !qualifier->getAttribute(Qualifier::Attribute::PowerDomainReference).isEmpty())\n    {\n        errors.append(QObject::tr(\"Illegal attribute powerDomainRef set for power enable qualifier \"\n            \"of %1 within abstraction definition %2.\").arg(context, abstraction->getVlnv().toString()));\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortAbstractionValidator::findErrorsInSystemGroup()\n//-----------------------------------------------------------------------------\nvoid PortAbstractionValidator::findErrorsInSystemGroup(QVector<QString>& errors, QString const& systemGroup, QString const& context, QStringList const& availableSystemNames, QString const& busDefinitionIdentifier) const\n{\n    if (systemGroup.isEmpty())\n    {\n        errors.append(QObject::tr(\"System group must be assigned for %1.\").arg(context));\n    }\n    else if (!availableSystemNames.contains(systemGroup))\n    {\n        errors.append(QObject::tr(\n            \"The system group %1 in %2 is not defined in system groups of bus definition %3.\")\n            .arg(systemGroup, context, busDefinitionIdentifier));\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortAbstractionValidator::findErrorsInPortPackets()\n//-----------------------------------------------------------------------------\nvoid PortAbstractionValidator::findErrorsInPortPackets(QVector<QString>& errors, QString const& context, QSharedPointer<PortAbstraction> port, Document::Revision revision) const\n{\n    auto packets = port->getPackets();\n\n    if (packets->isEmpty())\n    {\n        return;\n    }\n\n    if (revision != Document::Revision::Std22)\n    {\n        errors.append(QObject::tr(\"Packets defined in %1 not supported by IP-XACT document revision.\").arg(context));\n    }\n    else\n    {\n        PacketValidator packetValidator(expressionParser_);\n        for (auto const& packet : *packets)\n        {\n            packetValidator.findErrorsIn(errors, packet, context);\n        }\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortAbstractionValidator::isValidExpressionOrZero()\n//-----------------------------------------------------------------------------\nbool PortAbstractionValidator::isValidExpression(QString const& expression) const\n{\n    bool expressionOk = false;\n    QString solvedValue = expressionParser_->parseExpression(expression, &expressionOk);\n\n    if (expressionOk == false)\n    {\n        return false;\n    }\n\n    return true;\n}\n"
  },
  {
    "path": "IPXACTmodels/AbstractionDefinition/validators/PortAbstractionValidator.h",
    "content": "//-----------------------------------------------------------------------------\n// File: PortAbstractionValidator.h\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Anton Hagqvist\n// Date: 03.09.2024\n//\n// Description:\n// Validator for port abstractions.\n//-----------------------------------------------------------------------------\n\n#ifndef PORTABSTRACTIONVALIDATOR_H\n#define PORTABSTRACTIONVALIDATOR_H\n\n#include <IPXACTmodels/ipxactmodels_global.h>\n\n#include <IPXACTmodels/common/Document.h>\n\n#include <IPXACTmodels/common/validators/ProtocolValidator.h>\n#include <IPXACTmodels/AbstractionDefinition/validators/PacketValidator.h>\n\nclass PortAbstraction;\nclass WirePort;\nclass WireAbstraction;\nclass TransactionalPort;\nclass AbstractionDefinition;\nclass BusDefinition;\nclass ExpressionParser;\nclass LibraryInterface;\n\nclass IPXACTMODELS_EXPORT PortAbstractionValidator\n{\n\npublic:\n\n    /*!\n     *\tThe constructor.\n     *  \n     *    @param [in] library              Library interface to use.\n     *    @param [in] expressionParser     Expression parser to use.\n     */\n    PortAbstractionValidator(LibraryInterface* library, QSharedPointer<ExpressionParser> expressionParser);\n    \n    virtual ~PortAbstractionValidator() = default;\n    \n    //! No copying or assignment.\n    PortAbstractionValidator(PortAbstractionValidator const& other) = delete;\n    PortAbstractionValidator& operator=(PortAbstractionValidator const& other) = delete;\n\n    /*!\n     *  Validates the given PortAbstraction.\n     *\n     *    @param [in] port\t\t\t        The PortAbstraction to validate.\n     *    @param [in] abstractionDefinition   The abstraction definition being validated.\n     *    @param [in] busDefinition           The bus definition used by the abstraction definition.\n     */\n    bool validate(QSharedPointer<PortAbstraction> port,\n        QSharedPointer<AbstractionDefinition > abstractionDefinition,\n        QSharedPointer<const BusDefinition> busDefinition) const;\n\n    /*!\n     *   Finds possible errors in a PortAbstraction and creates a list of them.\n     *\n     *    @param [in] errors\t\t\t        List of found errors.\n     *    @param [in] port\t\t\t        The PortAbstraction whose errors to find.\n     *    @param [in] abstractionDefinition   The abstraction definition.\n     *    @param [in] busDefinition           Bus definition used by the abstraction definition.\n     */\n    void findErrorsIn(QStringList& errors,\n        QSharedPointer<PortAbstraction> port,\n        QSharedPointer<AbstractionDefinition> abstractionDefinition,\n        QSharedPointer<const BusDefinition> busDefinition) const;\n\n    bool hasValidName(QSharedPointer<PortAbstraction> portAbstraction) const;\n\n    /*!\n     *\tChecks the validity of the default value of a wire port.\n     *\n     *    @param [in] wirePort    The wire port to check.\n     *\n     * \t    @return True, if the default value is valid, otherwise false.\n     */\n    bool wireHasValidDefaultValue(QSharedPointer<WireAbstraction> wireAbstraction) const;\n\n    /*!\n\t *  Validates the given WirePort.\n\t *\n\t *    @param [in] wirePort\t\t\tThe WirePort to validate.\n\t *    @param [in] ports\t\t\t\tCollection of ports within the abstraction definition.\n\t *\n\t *    @return True, if the WirePort is valid IP-XACT, otherwise false.\n\t */\n    bool isValidWirePort(QSharedPointer<WirePort> wirePort,\n        QSharedPointer<QList<QSharedPointer<PortAbstraction> > > ports) const;\n\n    /*!\n     *\tChecks the validity of the width of a wire port.\n     *\n     *    @param [in] wirePort    The wire port to check.\n     *\n     * \t    @return True, if the width is valid, otherwise false.\n     */\n    bool wireHasValidWidth(QSharedPointer<WirePort> wirePort) const;\n\n    /*!\n     *  Validates the given TransactionalPort.\n     *\n     *    @param [in] transPort\tThe TransactionalPort to validate.\n     */\n    bool isValidTransactionalPort(QSharedPointer<TransactionalPort> transPort) const;\n\n    /*!\n     *\tChecks the validity of the bus width of a transactional port.\n     *  \n     *    @param [in] transPort     The transactional port to check.\n     *\t    \n     * \t    @return True, if the bus width is valid, otherwise false.\n     */\n    bool transactionalHasValidBusWidth(QSharedPointer<TransactionalPort> transPort) const;\n\n    /*!\n     *\tValidates the given port qualifier.\n     *\n     *    @param [in] qualifier\t        The qualifier to check.\n     *    @param [in] documentRevision\tThe IP-XACT standard revision of the document being checked.\n     *\n     * \t\t@return True, if port qualifier is valid, otherwise false.\n     */\n    bool isValidPortQualifier(QSharedPointer<Qualifier> qualifier, Document::Revision documentRevision) const;\n\nprivate:\n\n    /*!\n     *  Validates the constraints of parameter wirePort.\n     *\n     *    @param [in] wirePort\t\tThe WirePort to validate.\n     *    @param [in] ports\t\t\tCollection of ports within the abstraction definition.\n     */\n    bool validateConstraints(QSharedPointer<WirePort> wirePort,\n        QSharedPointer<QList<QSharedPointer<PortAbstraction> > > ports) const;\n    \n    /*!\n     *\tCheck if port packets are valid.\n     *\n     *    @param [in] port\t        The port whose packets are checked.\n     *\n     * \t\t@return True if valid, otherwise false.\n     */\n    bool hasValidPortPackets(QSharedPointer<PortAbstraction> port)\n        const;\n\n    /*!\n     *   Finds possible errors in constraints of parameter wirePort and creates a list of them.\n     *\n     *    @param [in] errors      List of found errors.\n     *    @param [in] wirePort\tThe WirePort whose errors to find.\n     *    @param [in] context     Context to help locate the errors.\n     *    @param [in] ports\t\tCollection of ports within the abstraction definition.\n     */\n    void findErrorsInConstraints(QStringList& errors, QSharedPointer<WirePort> wirePort,\n        QString const& context, QSharedPointer<QList<QSharedPointer<PortAbstraction> > > ports) const;\n\n    /*!\n     *   Finds possible errors in a WirePort and creates a list of them.\n     *\n     *    @param [in] errors      List of found errors.\n     *    @param [in] wirePort\tThe WirePort whose errors to find.\n     *    @param [in] context     Context to help locate the errors.\n     *    @param [in] ports\t\tCollection of ports within the abstraction definition.\n     */\n    void findErrorsInWirePort(QStringList& errors, QSharedPointer<WirePort> wirePort, QString const& context,\n        QSharedPointer<QList<QSharedPointer<PortAbstraction> > > ports) const;\n\n\n    /*!\n     *   Finds possible errors in a TransactionalPort and creates a list of them.\n     *\n     *    @param [in] errors      List of found errors.\n     *    @param [in] transPort\tThe TransactionalPort whose errors to find.\n     *    @param [in] context     Context to help locate the errors.\n     */\n    void findErrorsInTransactionalPort(QStringList& errors, QString const& context,\n        QSharedPointer<TransactionalPort> transPort) const;\n\n    /*!\n     *\tFinds possible errors in a qualifier of a port and creates a list of them.\n     *\n     *    @param [in] errors\t            List of found errors.\n     *    @param [in] context\t            Context to help locate the errors.\n     *    @param [in] abstraction     \tThe abstraction definition being checked.\n     */\n    void findErrorsInPortQualifier(QStringList& errors, QSharedPointer<Qualifier> qualifier, QString const& context,\n        QSharedPointer<AbstractionDefinition> abstraction) const;\n\n\n    /*!\n     *  Find errors in the selected port system group.\n     *\n     *    @param [in] errors                      List of found errors.\n     *    @param [in] systemGroup                 The selected system group.\n     *    @param [in] context                     Context to help locate the errors.\n     *    @param [in] availableSystemNames        List of the available system names.\n     *    @param [in] busDefinitionIdentifier     Identifier for the bus definition containing the system names.\n     *\n     *    @return\n     */\n    void findErrorsInSystemGroup(QVector<QString>& errors, QString const& systemGroup, QString const& context,\n        QStringList const& availableSystemNames, QString const& busDefinitionIdentifier) const;\n\n    /*!\n     *\tFind errors in the packets of the selected port.\n     *\n     *    @param [in] errors\t    List of found errors.\n     *    @param [in] context\t    Context to help locate the errors.\n     *    @param [in] port\t    The port whose packets are checked.\n     *    @param [in] revision\tThe IP-XACT revision of the document.\n     */\n    void findErrorsInPortPackets(QVector<QString>& errors, QString const& context,\n        QSharedPointer<PortAbstraction> port, Document::Revision revision) const;\n\n    /*!\n     *\tChecks if the given expression is valid.\n     *  \n     *    @param [in] expression     The expression to check.\n     *\t    \n     * \t    @return True, if the expression is valid, otherwise false.\n     */\n    bool isValidExpression(QString const& expression) const;\n\n    QSharedPointer<ExpressionParser> expressionParser_;\n\n    LibraryInterface* library_;\n\n    ProtocolValidator protocolValidator_;\n\n    PacketValidator packetValidator_;\n};\n\n#endif // PORTABSTRACTIONVALIDATOR_H\n"
  },
  {
    "path": "IPXACTmodels/BusDefinition/BusDefinition.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: BusDefinition.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Esko Pekkarinen\r\n// Date: 05.08.2015\r\n//\r\n// Description:\r\n// Implementation for ipxact:busDefinition element.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"BusDefinition.h\"\r\n\r\n#include <IPXACTmodels/utilities/Copy.h>\r\n\r\n#include <QDomDocument>\r\n#include <QString>\r\n#include <QDomNamedNodeMap>\r\n#include <QDomNode>\r\n#include <QDomNodeList>\r\n#include <QObject>\r\n#include <QSharedPointer>\r\n#include <QStringList>\r\n#include <QXmlStreamWriter>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusDefinition::BusDefinition()\r\n//-----------------------------------------------------------------------------\r\nBusDefinition::BusDefinition(VLNV const& vlnv, Document::Revision revision):\r\nDocument(vlnv, revision)\r\n{\r\n\t\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusDefinition::BusDefinition()\r\n//-----------------------------------------------------------------------------\r\nBusDefinition::BusDefinition(BusDefinition const& other):\r\nDocument(other),\r\ndirectConnection_(other.directConnection_),\r\nbroadcast_(other.broadcast_),\r\nisAddressable_(other.isAddressable_),\r\nmaxMasters_(other.maxMasters_),\r\nmaxSlaves_(other.maxSlaves_),\r\nsystemGroupNames_(other.systemGroupNames_),\r\nextends_(other.extends_)\r\n{\r\n\tCopy::copyList(other.choices_, choices_);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusDefinition::operator=()\r\n//-----------------------------------------------------------------------------\r\nBusDefinition & BusDefinition::operator=(BusDefinition const& other)\r\n{\r\n\tif (this != &other)\r\n    {\r\n\t\tDocument::operator=(other);\r\n\t\tdirectConnection_ = other.directConnection_;\r\n        broadcast_ = other.broadcast_;\r\n\t\tisAddressable_ = other.isAddressable_;\r\n\t\tmaxMasters_ = other.maxMasters_;\r\n\t\tmaxSlaves_ = other.maxSlaves_;\r\n\t\tsystemGroupNames_ = other.systemGroupNames_;\r\n\t\textends_ = other.extends_;\r\n\r\n\t\tchoices_->clear();\r\n\t\tCopy::copyList(other.choices_, choices_);\r\n\t}\r\n\treturn *this;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusDefinition::~BusDefinition()\r\n//-----------------------------------------------------------------------------\r\nBusDefinition::~BusDefinition()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusDefinition::clone()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<Document> BusDefinition::clone() const\r\n{\r\n\treturn QSharedPointer<Document>(new BusDefinition(*this));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusDefinition::setVlnv()\r\n//-----------------------------------------------------------------------------\r\nvoid BusDefinition::setVlnv(VLNV const& vlnv)\r\n{\r\n    VLNV busDefinitionVLNV(vlnv);\r\n    busDefinitionVLNV.setType(VLNV::BUSDEFINITION);\r\n    Document::setVlnv(busDefinitionVLNV);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusDefinition::setDirectConnection()\r\n//-----------------------------------------------------------------------------\r\nvoid BusDefinition::setDirectConnection(bool directConnection)\r\n{\r\n    directConnection_ = directConnection;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusDefinition::getDirectConnection()\r\n//-----------------------------------------------------------------------------\r\nbool BusDefinition::getDirectConnection() const\r\n{\r\n    return directConnection_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusDefinition::setBroadcast()\r\n//-----------------------------------------------------------------------------\r\nvoid BusDefinition::setBroadcast(bool broadcast)\r\n{\r\n    broadcast_.setValue(broadcast);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusDefinition::getBroadcast()\r\n//-----------------------------------------------------------------------------\r\nBooleanValue BusDefinition::getBroadcast() const\r\n{\r\n    return broadcast_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusDefinition::setIsAddressable()\r\n//-----------------------------------------------------------------------------\r\nvoid BusDefinition::setIsAddressable(bool isAddressable)\r\n{\r\n    isAddressable_ = isAddressable;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusDefinition::getIsAddressable()\r\n//-----------------------------------------------------------------------------\r\nbool BusDefinition::getIsAddressable() const\r\n{\r\n    return isAddressable_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusDefinition::getExtends()\r\n//-----------------------------------------------------------------------------\r\nVLNV BusDefinition::getExtends() const\r\n{\r\n    return extends_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusDefinition::setExtends()\r\n//-----------------------------------------------------------------------------\r\nvoid BusDefinition::setExtends(VLNV const& extends)\r\n{\r\n    extends_ = extends;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusDefinition::setMaxMasters()\r\n//-----------------------------------------------------------------------------\r\nvoid BusDefinition::setMaxMasters(std::string const& maxMasters)\r\n{\r\n\tsetMaxInitiators(maxMasters);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusDefinition::getMaxMasters()\r\n//-----------------------------------------------------------------------------\r\nstd::string BusDefinition::getMaxMasters() const\r\n{\r\n\treturn getMaxInitiators();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusDefinition::setMaxSlaves()\r\n//-----------------------------------------------------------------------------\r\nvoid BusDefinition::setMaxSlaves(std::string const& maxSlaves)\r\n{\r\n\tsetMaxTargets(maxSlaves);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusDefinition::getMaxSlaves()\r\n//-----------------------------------------------------------------------------\r\nstd::string BusDefinition::getMaxSlaves() const\r\n{\r\n\treturn getMaxTargets();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusDefinition::setMaxInitiators()\r\n//-----------------------------------------------------------------------------\r\nvoid BusDefinition::setMaxInitiators(std::string const& maxInitiators)\r\n{\r\n\tmaxMasters_ = maxInitiators;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusDefinition::getMaxInitiators()\r\n//-----------------------------------------------------------------------------\r\nstd::string BusDefinition::getMaxInitiators() const\r\n{\r\n\treturn maxMasters_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusDefinition::setMaxTargets()\r\n//-----------------------------------------------------------------------------\r\nvoid BusDefinition::setMaxTargets(std::string const& maxTargets)\r\n{\r\n\tmaxSlaves_ = maxTargets;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusDefinition::getMaxTargets()\r\n//-----------------------------------------------------------------------------\r\nstd::string BusDefinition::getMaxTargets() const\r\n{\r\n\treturn maxSlaves_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusDefinition::setSystemGroupNames()\r\n//-----------------------------------------------------------------------------\r\nvoid BusDefinition::setSystemGroupNames(QStringList const& systemGroupNames)\r\n{\r\n\tsystemGroupNames_ = systemGroupNames;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusDefinition::getSystemGroupNames()\r\n//-----------------------------------------------------------------------------\r\nQStringList BusDefinition::getSystemGroupNames() const\r\n{\r\n\treturn systemGroupNames_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusDefinition::setChoices()\r\n//-----------------------------------------------------------------------------\r\nvoid BusDefinition::setChoices(QSharedPointer<QList<QSharedPointer<Choice> > > choices)\r\n{\r\n\tchoices_ = choices;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusDefinition::getChoices()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<QList<QSharedPointer<Choice> > > BusDefinition::getChoices() const\r\n{\r\n\treturn choices_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusDefinition::getDependentVLNVs()\r\n//-----------------------------------------------------------------------------\r\nQList<VLNV> BusDefinition::getDependentVLNVs() const \r\n{\r\n\tQList<VLNV> vlnvList;\r\n\tif (extends_.isValid())\r\n    {\r\n\t\tvlnvList.append(extends_);\r\n\t}\r\n\r\n\treturn vlnvList;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusDefinition::getDependentFiles()\r\n//-----------------------------------------------------------------------------\r\nQStringList BusDefinition::getDependentFiles() const\r\n{\r\n    return QStringList();\r\n}\r\n"
  },
  {
    "path": "IPXACTmodels/BusDefinition/BusDefinition.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: BusDefinition.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Esko Pekkarinen\r\n// Date: 05.08.2015\r\n//\r\n// Description:\r\n// Implementation for ipxact:busDefinition element.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef BUSDEFINITION_H\r\n#define BUSDEFINITION_H\r\n\r\n\r\n#include <IPXACTmodels/common/BooleanValue.h>\r\n#include <IPXACTmodels/common/Document.h>\r\n#include <IPXACTmodels/common/Parameter.h>\r\n#include <IPXACTmodels/common/VLNV.h>\r\n\r\n#include <IPXACTmodels/common/Choice.h>\r\n\r\n#include <IPXACTmodels/kactusExtensions/KactusAttribute.h>\r\n\r\n#include <IPXACTmodels/ipxactmodels_global.h>\r\n \r\n#include <QDomDocument>\r\n#include <QSharedPointer>\r\n#include <QStringList>\r\n#include <QList>\r\n#include <QFile>\r\n#include <QMap>\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Implementation for ipxact:busDefinition element.\r\n//-----------------------------------------------------------------------------\r\nclass IPXACTMODELS_EXPORT BusDefinition: public Document\r\n{\r\npublic:\r\n\r\n\tBusDefinition(VLNV const& vlnv, Document::Revision revision);\r\n\r\n\t//! Copy constructor.\r\n\tBusDefinition(BusDefinition const& other);\r\n\r\n\t//! Assignment operator.\r\n\tBusDefinition &operator=(BusDefinition const& other);\r\n\r\n\t//! The destructor.\r\n\t~BusDefinition() final;\r\n\r\n\t/*!\r\n\t *  Creates a perfect copy of the Bus Definition.\r\n\t *\r\n\t *    @return Copy of the bus definition.\r\n\t */\r\n\tvirtual QSharedPointer<Document> clone() const;\r\n\r\n\t/*! Set the VLNV for the bus definition.\r\n\t*\r\n\t*    @param [in] vlnv     The vlnv to set\r\n\t*/\r\n\tvoid setVlnv(const VLNV& vlnv) final;\r\n\r\n\t/*! Sets the bus to support/not support direct master-slave connections.\r\n\t *\r\n\t *    @param [in] directConnection The wanted setting.\r\n\t */\r\n\tvoid setDirectConnection(bool directConnection);\r\n\r\n\t/*! Check if the bus supports direct master-slave connections.\r\n\t *\r\n\t *    @return True, if the bus connects directly from master to slave, otherwise false.\r\n\t */\r\n\tbool getDirectConnection() const;\r\n   \r\n    /*! \r\n     *  Sets the bus to support/not support broadcast mode.\r\n\t *\r\n\t *    @param [in] broadcast The wanted setting.\r\n\t */\r\n    void setBroadcast(bool broadcast);\r\n        \r\n    /*!\r\n     *  Checks if the bus supports broadcast mode.\r\n     *\r\n     *    @return True, if broadcast is supported, otherwise false.\r\n     */\r\n    BooleanValue getBroadcast() const;\r\n\r\n\t/*! Set the whether this bus uses addressing.\r\n\t *\r\n\t *    @param [in] isAddressable The value to set.\r\n\t */\r\n\tvoid setIsAddressable(bool isAddressable);\r\n\r\n\t/*! Check if the bus uses addressing.\r\n\t *\r\n\t *    @return True, if the bus is addressable, otherwise false.\r\n\t */\r\n\tbool getIsAddressable() const;\r\n\r\n\t/*! Get the vlnv tag of the bus definition that this definition extends.\r\n\t * \r\n\t *    @return The VLNV this bus extends or empty VLNV if this bus does not extend another.\r\n\t */\r\n\tVLNV getExtends() const;\r\n\r\n\t/*! Set the bus to extend another.\r\n\t *\r\n\t *    @param [in] extends  The vlnv of the extended bus definition.\r\n\t */\r\n\tvoid setExtends(VLNV const& extends);\r\n        \r\n\t/*! Set the maximum number of masters on this bus\r\n\t *\r\n\t *    @param [in] maxMasters The maximum number of masters\r\n\t */\r\n    void setMaxMasters(std::string const& maxMasters);\r\n\r\n    /*! Get the maximum number of masters on this bus\r\n\t *\r\n\t *    @return unsigned int containing maximum number of masters\r\n\t */\r\n\tstd::string getMaxMasters() const;\r\n\r\n\t/*! Set the maximum number of slaves on this bus\r\n\t *\r\n\t *    @param [in] The maximum number of slaves\r\n\t */\r\n\tvoid setMaxSlaves(std::string const& maxSlaves);\r\n\r\n\t/*! Get the maximum number of slaves on this bus\r\n\t *\r\n\t *    @return The maximum number of slaves\r\n\t */\r\n\tstd::string getMaxSlaves() const;\r\n\r\n\t/*! Set the maximum number of initiators on this bus\r\n\t *\r\n\t *    @param [in] maxInitiators The maximum number of initiators\r\n\t */\r\n    void setMaxInitiators(std::string const& maxInitiators);\r\n\r\n    /*! Get the maximum number of initiators on this bus\r\n\t *\r\n\t *    @return unsigned int containing maximum number of initiators\r\n\t */\r\n\tstd::string getMaxInitiators() const;\r\n\r\n\t/*! Set the maximum number of targets on this bus\r\n\t *\r\n\t *    @param [in] The maximum number of targets\r\n\t */\r\n\tvoid setMaxTargets(std::string const& maxTargets);\r\n\r\n\t/*! Get the maximum number of targets on this bus\r\n\t *\r\n\t *    @return The maximum number of targets\r\n\t */\r\n\tstd::string getMaxTargets() const;\r\n\r\n\t/*! Set the systemGroupNames.\r\n\t *\r\n\t *    @param [in] systemGroupNames The names of the systemGroups available in onSystem mode.\r\n\t */\r\n\tvoid setSystemGroupNames(QStringList const& systemGroupNames);\r\n\r\n\t/*! Gets the systemGroupNames.\r\n\t *\r\n\t *    @return The names of available systemGroups\r\n\t */\r\n\tQStringList getSystemGroupNames() const;\r\n\r\n\t/*! Sets the choices.\r\n\t *\r\n\t *    @param [in] choices The choices to set.\r\n\t */\r\n\tvoid setChoices(QSharedPointer<QList<QSharedPointer<Choice> > > choices);\r\n\t\r\n\t/*! Gets the choices.\r\n\t *\r\n\t *    @return A list of the busDefinition choices\r\n\t */\r\n\tQSharedPointer<QList<QSharedPointer<Choice> > > getChoices() const;\r\n\r\n\t/*! Get the VLNVs that this busDefinition depends on.\r\n\t *\r\n\t *    @return The dependency VLNVs.\r\n\t */\r\n\tvirtual QList<VLNV> getDependentVLNVs() const;\r\n\r\n\t/*! Get the file dependencies of this busDefinition.\r\n     *\r\n\t *    @return The dependency files.\r\n     *\r\n     *      @remark This function never returns anything because busDefinition only has VLNV dependencies.\r\n\t */\r\n\tvirtual QStringList getDependentFiles() const;\r\n\r\nprivate:\r\n\r\n\t//! Direct connection specifies if direct master-slave connections are allowed.\r\n\tbool directConnection_ = true;\r\n\r\n    //! Specifies if the bus supports broadcast mode.\r\n    BooleanValue broadcast_;\r\n\r\n\t//! Specifies if the bus has addressing information.\r\n\tbool isAddressable_ = true;\r\n\r\n\t//! Maximum number of masters allowed on this bus.\r\n\tstd::string maxMasters_;\r\n\r\n\t//! Maximum number of slaves allowed on this bus.\r\n\tstd::string maxSlaves_;\r\n\r\n\t//! The choices of the bus definition\r\n\tQSharedPointer<QList<QSharedPointer<Choice> > > choices_ = \r\n\t\tQSharedPointer<QList<QSharedPointer<Choice> > >(new QList<QSharedPointer<Choice > >);\r\n\r\n\t//! List of systemGroupName elements.\r\n\tQStringList systemGroupNames_;\r\n\r\n\t//! specifies if this definition is an extension from another bus.\r\n\tVLNV extends_;\r\n\r\n};\r\n\r\n#endif /* BUSDEFINITION_H */\r\n"
  },
  {
    "path": "IPXACTmodels/BusDefinition/BusDefinitionReader.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: BusDefinitionReader.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Esko Pekkarinen\r\n// Date: 07.08.2015\r\n//\r\n// Description:\r\n// XML reader for IP-XACT Bus definition element.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"BusDefinitionReader.h\"\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusDefinitionReader::createBusDefinitionFrom()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<BusDefinition> BusDefinitionReader::createBusDefinitionFrom(QDomNode const& document)\r\n{\r\n    QDomNode busNode = document.firstChildElement();\r\n    Document::Revision docRevision = DocumentReader::getXMLDocumentRevision(busNode);\r\n    \r\n    VLNV vlnv = CommonItemsReader::createVLNVFrom(busNode, VLNV::BUSDEFINITION);\r\n\r\n    QSharedPointer<BusDefinition> busDefinition(new BusDefinition(vlnv, docRevision));\r\n\r\n    DocumentReader::parseTopComments(document, busDefinition);\r\n\r\n    DocumentReader::parseXMLProcessingInstructions(document, busDefinition);\r\n\r\n    DocumentReader::parseNamespaceDeclarations(busNode, busDefinition);\r\n\r\n    DocumentReader::parseDocumentNameGroup(busNode, busDefinition);\r\n\r\n    Details::parseDirectConnection(busNode, busDefinition);\r\n    \r\n    Details::parseBroadcast(busNode, busDefinition);\r\n    \r\n    Details::parseIsAddressable(busNode, busDefinition);\r\n    \r\n    Details::parseExtends(busNode, busDefinition);\r\n\r\n    Details::parseMaximumInitiators(busNode, busDefinition);\r\n    \r\n    Details::parseMaximumTargets(busNode, busDefinition);\r\n    \r\n    Details::parseSystemGroupNames(busNode, busDefinition);\r\n    \r\n    Details::parseChoices(busNode, busDefinition);\r\n    \r\n    DocumentReader::parseParameters(busNode, busDefinition);\r\n\r\n    DocumentReader::parseAssertions(busNode, busDefinition);\r\n\r\n    DocumentReader::parseKactusAndVendorExtensions(busNode, busDefinition);\r\n\r\n    return busDefinition;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusDefinitionReader::parseDirectConnection()\r\n//-----------------------------------------------------------------------------\r\nvoid BusDefinitionReader::Details::parseDirectConnection(QDomNode const& busNode,\r\n    QSharedPointer<BusDefinition> busDefinition)\r\n{\r\n    QString directConnection = busNode.firstChildElement(QStringLiteral(\"ipxact:directConnection\")).firstChild().nodeValue();\r\n    busDefinition->setDirectConnection(directConnection == QLatin1String(\"true\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: parseBroadcast()\r\n//-----------------------------------------------------------------------------\r\nvoid BusDefinitionReader::Details::parseBroadcast(QDomNode const& busNode,\r\n    QSharedPointer<BusDefinition> busDefinition)\r\n{\r\n    QDomNode broadcastNode = busNode.firstChildElement(QStringLiteral(\"ipxact:broadcast\"));\r\n    if (!broadcastNode.isNull())\r\n    {\r\n        busDefinition->setBroadcast(broadcastNode.firstChild().nodeValue() == QLatin1String(\"true\"));\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusDefinitionReader::parseIsAddressable()\r\n//-----------------------------------------------------------------------------\r\nvoid BusDefinitionReader::Details::parseIsAddressable(QDomNode const& busNode, QSharedPointer<BusDefinition> busDefinition)\r\n{\r\n    QString addressable = busNode.firstChildElement(QStringLiteral(\"ipxact:isAddressable\")).firstChild().nodeValue();\r\n    busDefinition->setIsAddressable(addressable == QLatin1String(\"true\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusDefinitionReader::parseExtends()\r\n//-----------------------------------------------------------------------------\r\nvoid BusDefinitionReader::Details::parseExtends(QDomNode const& busNode, QSharedPointer<BusDefinition> busDefinition)\r\n{\r\n    QDomNode extendsNode = busNode.firstChildElement(QStringLiteral(\"ipxact:extends\"));\r\n    if (!extendsNode.isNull())\r\n    {\r\n        QDomNamedNodeMap attributes = extendsNode.attributes();\r\n        VLNV extendedVLNV;\r\n        extendedVLNV.setType(VLNV::BUSDEFINITION);\r\n        extendedVLNV.setVendor(attributes.namedItem(QStringLiteral(\"vendor\")).nodeValue());\r\n        extendedVLNV.setLibrary(attributes.namedItem(QStringLiteral(\"library\")).nodeValue());\r\n        extendedVLNV.setName(attributes.namedItem(QStringLiteral(\"name\")).nodeValue());\r\n        extendedVLNV.setVersion(attributes.namedItem(QStringLiteral(\"version\")).nodeValue());\r\n\r\n        busDefinition->setExtends(extendedVLNV);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusDefinitionReader::parseMaximumInitiators()\r\n//-----------------------------------------------------------------------------\r\nvoid BusDefinitionReader::Details::parseMaximumInitiators(QDomNode const& busNode,\r\n    QSharedPointer<BusDefinition> busDefinition)\r\n{\r\n    QString elementName = busDefinition->getRevision() == Document::Revision::Std22\r\n        ? QStringLiteral(\"ipxact:maxInitiators\")\r\n        : QStringLiteral(\"ipxact:maxMasters\");\r\n\r\n    QDomNode maximumInitiatorsNode = busNode.firstChildElement(elementName);\r\n    if (!maximumInitiatorsNode.isNull())\r\n    {\r\n        busDefinition->setMaxMasters(maximumInitiatorsNode.firstChild().nodeValue().toStdString());\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusDefinitionReader::parseMaximumTargets()\r\n//-----------------------------------------------------------------------------\r\nvoid BusDefinitionReader::Details::parseMaximumTargets(QDomNode const& busNode,\r\n    QSharedPointer<BusDefinition> busDefinition)\r\n{\r\n    QString elementName = busDefinition->getRevision() == Document::Revision::Std22\r\n        ? QStringLiteral(\"ipxact:maxTargets\")\r\n        : QStringLiteral(\"ipxact:maxSlaves\");\r\n\r\n    QDomNode maximumTargetsNode = busNode.firstChildElement(elementName);\r\n    if (!maximumTargetsNode.isNull())\r\n    {\r\n        busDefinition->setMaxTargets(maximumTargetsNode.firstChild().nodeValue().toStdString());\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusDefinitionReader::parseSystemGroupNames()\r\n//-----------------------------------------------------------------------------\r\nvoid BusDefinitionReader::Details::parseSystemGroupNames(QDomNode const& busNode,\r\n    QSharedPointer<BusDefinition> busDefinition)\r\n{\r\n    QDomNodeList systemNodes = busNode.firstChildElement(QStringLiteral(\"ipxact:systemGroupNames\")).childNodes();\r\n    \r\n    QStringList systemGroupNames;\r\n    int systemNameCount = systemNodes.count();\r\n    for (int i = 0; i < systemNameCount; i++)\r\n    {\r\n        systemGroupNames.append(systemNodes.at(i).firstChild().nodeValue());\r\n    }\r\n\r\n    busDefinition->setSystemGroupNames(systemGroupNames);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusDefinitionReader::parseChoices()\r\n//-----------------------------------------------------------------------------\r\nvoid BusDefinitionReader::Details::parseChoices(QDomNode const& busNode, QSharedPointer<BusDefinition> busDefinition)\r\n{\r\n    if (busDefinition->getRevision() == Document::Revision::Std14 ||\r\n        busDefinition->getRevision() == Document::Revision::Unknown)\r\n    {\r\n        return;\r\n    }\r\n\r\n    auto parsedChoices = CommonItemsReader::parseChoices(busNode);\r\n    busDefinition->setChoices(parsedChoices);\r\n}\r\n"
  },
  {
    "path": "IPXACTmodels/BusDefinition/BusDefinitionReader.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: BusDefinitionReader.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Esko Pekkarinen\r\n// Date: 07.08.2015\r\n//\r\n// Description:\r\n// XML reader for IP-XACT Bus definition element.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef BUSDEFINITIONREADER_H\r\n#define BUSDEFINITIONREADER_H\r\n\r\n#include \"BusDefinition.h\"\r\n\r\n#include <QDomNode>\r\n#include <QSharedPointer>\r\n\r\n#include <IPXACTmodels/common/DocumentReader.h>\r\n#include <IPXACTmodels/ipxactmodels_global.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n//! XML reader for IP-XACT Bus definition element.\r\n//-----------------------------------------------------------------------------\r\nnamespace BusDefinitionReader\r\n{\r\n    /*!\r\n     *  Creates a bus definition from XML description.\r\n     *\r\n     *    @param [in] document   The XML document to create the bus definition from.\r\n     *\r\n     *    @return The created bus definition.\r\n     */\r\n    IPXACTMODELS_EXPORT QSharedPointer<BusDefinition> createBusDefinitionFrom(QDomNode const& document);\r\n \r\n    namespace Details\r\n    {\r\n        /*!\r\n         *  Reads the direct connection property from XML to a bus definition.\r\n         *\r\n         *    @param [in]     busNode         The XML description of the bus definition.\r\n         *    @param [in/out] busDefinition   The bus definition to insert the direct connection property into.\r\n         */\r\n        void parseDirectConnection(QDomNode const& busNode, QSharedPointer<BusDefinition> busDefinition);\r\n\r\n        /*!\r\n         *  Reads the broadcast property from XML to a bus definition.\r\n         *\r\n         *    @param [in]     busNode         The XML description of the bus definition.\r\n         *    @param [in/out] busDefinition   The bus definition to insert the broadcast property into.\r\n         */\r\n        void parseBroadcast(QDomNode const& busNode, QSharedPointer<BusDefinition> busDefinition);\r\n\r\n        /*!\r\n         *  Reads the isAddressable property from XML to a bus definition.\r\n         *\r\n         *    @param [in]     busNode         The XML description of the bus definition.\r\n         *    @param [in/out] busDefinition   The bus definition to insert the isAddressable property into.\r\n         */\r\n        void parseIsAddressable(QDomNode const& busNode, QSharedPointer<BusDefinition> busDefinition);\r\n\r\n        /*!\r\n         *  Reads the extends property from XML to a bus definition.\r\n         *\r\n         *    @param [in]     busNode         The XML description of the bus definition.\r\n         *    @param [in/out] busDefinition   The bus definition to insert the extends property into.\r\n         */\r\n        void parseExtends(QDomNode const& busNode, QSharedPointer<BusDefinition> busDefinition);\r\n\r\n        /*!\r\n         *  Reads the maximum number of initiators from XML to a bus definition.\r\n         *\r\n         *    @param [in]     busNode         The XML description of the bus definition.\r\n         *    @param [in/out] busDefinition   The bus definition to insert the maximum number of initiators into.\r\n         */\r\n        void parseMaximumInitiators(QDomNode const& busNode, QSharedPointer<BusDefinition> busDefinition);\r\n\r\n        /*!\r\n         *  Reads the maximum number of targets from XML to a bus definition.\r\n         *\r\n         *    @param [in]     busNode         The XML description of the bus definition.\r\n         *    @param [in/out] busDefinition   The bus definition to insert the maximum number of targets into.\r\n         */\r\n        void parseMaximumTargets(QDomNode const& busNode, QSharedPointer<BusDefinition> busDefinition);\r\n\r\n        /*!\r\n         *  Reads the system group names from XML to a bus definition.\r\n         *\r\n         *    @param [in]     busNode         The XML description of the bus definition.\r\n         *    @param [in/out] busDefinition   The bus definition to insert the system group names into.\r\n         */\r\n        void parseSystemGroupNames(QDomNode const& busNode, QSharedPointer<BusDefinition> busDefinition);\r\n\r\n        /*!\r\n         *  Reads the choices from XML to a bus definition.\r\n         *\r\n         *    @param [in]     busNode         The XML description of the bus definition.\r\n         *    @param [in/out] busDefinition   The bus definition to insert the choices into.\r\n         */\r\n        void parseChoices(QDomNode const& busNode, QSharedPointer<BusDefinition> busDefinition);\r\n    }\r\n}\r\n\r\n#endif // BUSDEFINITIONREADER_H"
  },
  {
    "path": "IPXACTmodels/BusDefinition/BusDefinitionWriter.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: BusDefinitionWriter.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Esko Pekkarinen\r\n// Date: 05.08.2015\r\n//\r\n// Description:\r\n// Writer for IP-XACT BusDefinition element.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"BusDefinitionWriter.h\"\r\n\r\n#include <IPXACTmodels/BusDefinition/BusDefinition.h>\r\n#include <IPXACTmodels/common/Choice.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusDefinitionWriter::writeBusDefinition()\r\n//-----------------------------------------------------------------------------\r\nvoid BusDefinitionWriter::writeBusDefinition(QXmlStreamWriter& writer, \r\n    QSharedPointer<BusDefinition> busDefinition)\r\n{\r\n    writer.writeStartDocument();\r\n    \r\n    DocumentWriter::writeTopComments(writer, busDefinition);\r\n\r\n    DocumentWriter::writeXmlProcessingInstructions(writer, busDefinition);\r\n\r\n    writer.writeStartElement(QStringLiteral(\"ipxact:busDefinition\"));\r\n    DocumentWriter::writeNamespaceDeclarations(writer, busDefinition);\r\n\r\n    DocumentWriter::writeDocumentNameGroup(writer, busDefinition);\r\n\r\n    writer.writeTextElement(QStringLiteral(\"ipxact:directConnection\"), Details::bool2Str(busDefinition->getDirectConnection()));\r\n\r\n    Details::writeBroadcast(writer, busDefinition);\r\n\r\n    writer.writeTextElement(QStringLiteral(\"ipxact:isAddressable\"), Details::bool2Str(busDefinition->getIsAddressable()));\r\n\r\n    Details::writeExtends(writer, busDefinition);\r\n\r\n    Details::writeMaximumInitiators(writer, busDefinition);\r\n    Details::writeMaximumTargets(writer, busDefinition);\r\n\r\n    Details::writeSystemGroupNames(writer, busDefinition);\r\n\r\n    Details::writeDescription(writer, busDefinition);\r\n\r\n    Details::writeChoices(writer, busDefinition);\r\n\r\n    DocumentWriter::writeParameters(writer, busDefinition);\r\n\r\n    DocumentWriter::writeAssertions(writer, busDefinition);\r\n\r\n    DocumentWriter::writeVendorExtensions(writer, busDefinition);\r\n\r\n    writer.writeEndElement(); // QStringLiteral(\"ipxact:busDefinition\"\r\n    writer.writeEndDocument();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusDefinitionWriter::writeBroadcast()\r\n//-----------------------------------------------------------------------------\r\nvoid BusDefinitionWriter::Details::writeBroadcast(QXmlStreamWriter& writer, \r\n    QSharedPointer<BusDefinition> busDefinition)\r\n{\r\n    BooleanValue broadcastValue = busDefinition->getBroadcast();\r\n    if (!broadcastValue.toString().isEmpty())\r\n    {\r\n        writer.writeTextElement(QStringLiteral(\"ipxact:broadcast\"), busDefinition->getBroadcast().toString());\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusDefinitionWriter::writeExtends()\r\n//-----------------------------------------------------------------------------\r\nvoid BusDefinitionWriter::Details::writeExtends(QXmlStreamWriter& writer, QSharedPointer<BusDefinition> busDefinition)\r\n{\r\n    if (!busDefinition->getExtends().isEmpty())\r\n    {\r\n        writer.writeStartElement(QStringLiteral(\"ipxact:extends\"));\r\n        CommonItemsWriter::writeVLNVAttributes(writer, busDefinition->getExtends());\r\n        writer.writeEndElement();\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusDefinitionWriter::writeMaximumInitiators()\r\n//-----------------------------------------------------------------------------\r\nvoid BusDefinitionWriter::Details::writeMaximumInitiators(QXmlStreamWriter& writer,\r\n    QSharedPointer<BusDefinition> busDefinition)\r\n{\r\n    auto const& maxInitiators = busDefinition->getMaxInitiators();\r\n\r\n    if (maxInitiators.empty())\r\n    {\r\n        return;\r\n    }\r\n\r\n    if (busDefinition->getRevision() == Document::Revision::Std14)\r\n    {\r\n        writer.writeTextElement(QStringLiteral(\"ipxact:maxMasters\"), QString::fromStdString(maxInitiators));\r\n    }\r\n    else if (busDefinition->getRevision() == Document::Revision::Std22)\r\n    {\r\n        writer.writeTextElement(QStringLiteral(\"ipxact:maxInitiators\"), QString::fromStdString(maxInitiators));\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusDefinitionWriter::writeMaximumTargets()\r\n//-----------------------------------------------------------------------------\r\nvoid BusDefinitionWriter::Details::writeMaximumTargets(QXmlStreamWriter& writer,\r\n    QSharedPointer<BusDefinition> busDefinition)\r\n{\r\n    auto const& maxTargets = busDefinition->getMaxTargets();\r\n\r\n    if (maxTargets.empty())\r\n    {\r\n        return;\r\n    }\r\n\r\n    if (busDefinition->getRevision() == Document::Revision::Std14)\r\n    {\r\n        writer.writeTextElement(QStringLiteral(\"ipxact:maxSlaves\"), QString::fromStdString(maxTargets));\r\n    }\r\n    else if (busDefinition->getRevision() == Document::Revision::Std22)\r\n    {\r\n        writer.writeTextElement(QStringLiteral(\"ipxact:maxTargets\"), QString::fromStdString(maxTargets));\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusDefinitionWriter::writeSystemGroupNames()\r\n//-----------------------------------------------------------------------------\r\nvoid BusDefinitionWriter::Details::writeSystemGroupNames(QXmlStreamWriter& writer,\r\n    QSharedPointer<BusDefinition> busDefinition)\r\n{\r\n    QStringList systemGroupNames = busDefinition->getSystemGroupNames();\r\n    if (!systemGroupNames.isEmpty())\r\n    {\r\n        writer.writeStartElement(QStringLiteral(\"ipxact:systemGroupNames\"));\r\n        for (auto const& name : systemGroupNames)\r\n        {\r\n            writer.writeTextElement(QStringLiteral(\"ipxact:systemGroupName\"), name);\r\n        }\r\n        writer.writeEndElement();\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusDefinitionWriter::writeChoices()\r\n//-----------------------------------------------------------------------------\r\nvoid BusDefinitionWriter::Details::writeChoices(QXmlStreamWriter& writer, \r\n    QSharedPointer<BusDefinition> busDefinition)\r\n{\r\n    if (busDefinition->getRevision() != Document::Revision::Std14)\r\n    {\r\n        CommonItemsWriter::writeChoices(writer, busDefinition->getChoices());\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusDefinitionWriter::writeDescription()\r\n//-----------------------------------------------------------------------------\r\nvoid BusDefinitionWriter::Details::writeDescription(QXmlStreamWriter& writer,\r\n    QSharedPointer<BusDefinition> busDefinition)\r\n{\r\n    if (busDefinition->getRevision() == Document::Revision::Std14)\r\n    {\r\n        CommonItemsWriter::writeDescription(writer, busDefinition->getDescription());\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusDefinitionWriter::bool2Str()\r\n//-----------------------------------------------------------------------------\r\nQString BusDefinitionWriter::Details::bool2Str(bool value)\r\n{\r\n    if (value)\r\n    {\r\n        return QStringLiteral(\"true\");\r\n    }\r\n    else\r\n    {\r\n        return QStringLiteral(\"false\");\r\n    }\r\n}\r\n\r\n\r\n"
  },
  {
    "path": "IPXACTmodels/BusDefinition/BusDefinitionWriter.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: BusDefinitionWriter.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Esko Pekkarinen\r\n// Date: 05.08.2015\r\n//\r\n// Description:\r\n// Writer for IP-XACT BusDefinition element.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef BUSDEFINITIONWRITER_H\r\n#define BUSDEFINITIONWRITER_H\r\n\r\n#include <QSharedPointer>\r\n#include <QXmlStreamWriter>\r\n\r\n#include <IPXACTmodels/common/ParameterWriter.h>\r\n#include <IPXACTmodels/common/DocumentWriter.h>\r\n\r\n#include <IPXACTmodels/ipxactmodels_global.h>\r\n\r\nclass BusDefinition;\r\nclass VLNV;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Writer for IP-XACT BusDefinition element.\r\n//-----------------------------------------------------------------------------\r\nnamespace BusDefinitionWriter\r\n{\r\n\r\n    /*!\r\n     *  Writes the given bus definition into xml.\r\n     *\r\n     *    @param [in] writer          The xml writer to use.\r\n     *    @param [in] busDefinition   The bus definition to write.\r\n     */\r\n    IPXACTMODELS_EXPORT void writeBusDefinition(QXmlStreamWriter& writer, QSharedPointer<BusDefinition> busDefinition);\r\n\r\n    namespace Details\r\n    {\r\n        /*!\r\n         *  Writes the broadcast property of a given bus definition into xml.\r\n         *\r\n         *    @param [in] writer          The xml writer to use.\r\n         *    @param [in] busDefinition   The bus definition whose broadcast to write.\r\n         */\r\n        void writeBroadcast(QXmlStreamWriter& writer, QSharedPointer<BusDefinition> busDefinition);\r\n\r\n        /*!\r\n         *  Writes the bus definition extended in a given bus definition into xml.\r\n         *\r\n         *    @param [in] writer          The xml writer to use.\r\n         *    @param [in] busDefinition   The bus definition whose extends property to write.\r\n         */\r\n        void writeExtends(QXmlStreamWriter& writer, QSharedPointer<BusDefinition> busDefinition);\r\n\r\n        /*!\r\n         *  Writes the maximum number of initiators allowed in a given bus definition into xml.\r\n         *\r\n         *    @param [in] writer          The xml writer to use.\r\n         *    @param [in] busDefinition   The bus definition whose initiator count to write.\r\n         */\r\n        void writeMaximumInitiators(QXmlStreamWriter& writer, QSharedPointer<BusDefinition> busDefinition);\r\n\r\n        /*!\r\n         *  Writes the maximum number of targets allowed in a given bus definition into xml.\r\n         *\r\n         *    @param [in] writer          The xml writer to use.\r\n         *    @param [in] busDefinition   The bus definition whose targets count to write.\r\n         */\r\n        void writeMaximumTargets(QXmlStreamWriter& writer, QSharedPointer<BusDefinition> busDefinition);\r\n\r\n        /*!\r\n         *  Writes the system group names defined in a given bus definition into xml.\r\n         *\r\n         *    @param [in] writer          The xml writer to use.\r\n         *    @param [in] busDefinition   The bus definition whose system group names to write.\r\n         */\r\n        void writeSystemGroupNames(QXmlStreamWriter& writer, QSharedPointer<BusDefinition> busDefinition);\r\n\r\n        /*!\r\n         *  Writes the choices of a bus definition into xml.\r\n         *\r\n         *    @param [in] writer          The xml writer to use.\r\n         *    @param [in] busDefinition   The bus definition whose choices to write.\r\n         */\r\n        void writeChoices(QXmlStreamWriter& writer, QSharedPointer<BusDefinition> busDefinition);\r\n\r\n        /*!\r\n         *  Writes the description of a bus definition into xml.\r\n         *\r\n         *    @param [in] writer          The xml writer to use.\r\n         *    @param [in] busDefinition   The bus definition whose choices to write.\r\n         */\r\n        void writeDescription(QXmlStreamWriter& writer, QSharedPointer<BusDefinition> busDefinition);\r\n\r\n        /*!\r\n         *  Converts boolean value to string.\r\n         *\r\n         *    @param [in] value   The boolean value to convert.\r\n         *\r\n         *    @return     The string representation of the boolean value.\r\n         */\r\n        QString bool2Str(bool value);\r\n    }\r\n};    \r\n\r\n#endif // BUSDEFINITIONWRITER_H"
  },
  {
    "path": "IPXACTmodels/BusDefinition/validators/BusDefinitionValidator.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: BusDefinitionValidator.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Janne Virtanen\r\n// Date: 17.11.2015\r\n//\r\n// Description:\r\n// Validator for ipxact:BusDefinition.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"BusDefinitionValidator.h\"\r\n\r\n#include <KactusAPI/include/ExpressionParser.h>\r\n\r\n#include <IPXACTmodels/common/validators/ParameterValidator.h>\r\n#include <IPXACTmodels/common/Choice.h>\r\n#include <IPXACTmodels/common/validators/ChoiceValidator.h>\r\n#include <IPXACTmodels/BusDefinition/BusDefinition.h>\r\n\r\n#include <KactusAPI/include/LibraryInterface.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusDefinitionValidator::BusDefinitionValidator()\r\n//-----------------------------------------------------------------------------\r\nBusDefinitionValidator::BusDefinitionValidator(LibraryInterface* library,\r\n    QSharedPointer<ExpressionParser> expressionParser):\r\nlibrary_(library),\r\nexpressionParser_(expressionParser),\r\nchoiceValidator_(new ChoiceValidator(expressionParser))\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusDefinitionValidator::~BusDefinitionValidator()\r\n//-----------------------------------------------------------------------------\r\nBusDefinitionValidator::~BusDefinitionValidator()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusDefinitionValidator::validate()\r\n//-----------------------------------------------------------------------------\r\nbool BusDefinitionValidator::validate(QSharedPointer<const BusDefinition> busDefinition) const\r\n{\r\n    if (busDefinition->getVlnv().isValid() == false)\r\n\t{\r\n\t\treturn false;\r\n\t}\r\n\r\n    if (!extendIsValid(busDefinition))\r\n    {\r\n        return false;\r\n    }\r\n    \r\n    bool validInitiators = false;\r\n    expressionParser_->parseExpression(QString::fromStdString(busDefinition->getMaxInitiators()), &validInitiators);\r\n    if (validInitiators == false)\r\n\t{\r\n\t\treturn false;\r\n\t}\r\n    \r\n    bool validTargets = false;\r\n    expressionParser_->parseExpression(QString::fromStdString(busDefinition->getMaxSlaves()), &validTargets);\r\n    if (validTargets == false)\r\n\t{\r\n\t\treturn false;\r\n\t}\r\n\r\n    ParameterValidator parameterValidator(expressionParser_, QSharedPointer<QList<QSharedPointer<Choice> > >(), busDefinition->getRevision());\r\n\r\n \tfor (auto const& currentParameter : *busDefinition->getParameters())\r\n\t{\r\n        if (parameterValidator.validate(currentParameter) == false)\r\n\t\t{\r\n\t\t\treturn false;\r\n\t\t}\r\n\t}\r\n\r\n    if (busDefinition->getRevision() != Document::Revision::Std22)\r\n    {\r\n        if (!busDefinition->getChoices()->isEmpty())\r\n        {\r\n            return false;\r\n        }\r\n\r\n        if (!busDefinition->getShortDescription().isEmpty())\r\n        {\r\n            return false;\r\n        }\r\n\r\n        if (!busDefinition->getDisplayName().isEmpty())\r\n        {\r\n            return false;\r\n        }\r\n    }\r\n    else\r\n    {\r\n        for (auto const& currentChoice : *busDefinition->getChoices())\r\n        {\r\n            if (!choiceValidator_->validate(currentChoice))\r\n            {\r\n                return false;\r\n            }\r\n        }\r\n    }\r\n\r\n\treturn true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusDefinitionValidator::extendIsValid()\r\n//-----------------------------------------------------------------------------\r\nbool BusDefinitionValidator::extendIsValid(QSharedPointer<const BusDefinition> busDefinition) const\r\n{\r\n    VLNV extendVLNV = busDefinition->getExtends();\r\n    return extendVLNV.isEmpty() ||\r\n        (library_->getModelReadOnly(extendVLNV) && extendVLNV.getType() == VLNV::BUSDEFINITION);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusDefinitionValidator::findErrorsIn()\r\n//-----------------------------------------------------------------------------\r\nvoid BusDefinitionValidator::findErrorsIn(QVector<QString>& errors,\r\n    QSharedPointer<const BusDefinition> busDefinition) const\r\n{\r\n    QString context = QObject::tr(\"containing bus definition\");\r\n\tif (busDefinition->getVlnv().isValid(errors, context))\r\n    {\r\n        context = QObject::tr(\"bus definition %1\").arg(busDefinition->getVlnv().toString());\r\n    }\r\n\r\n    if (!extendIsValid(busDefinition))\r\n    {\r\n        errors.append(QObject::tr(\"Extend VLNV '%1' is not valid within %2.\").arg(\r\n            busDefinition->getExtends().toString(), context));\r\n    }\r\n\r\n    bool initiatorsValid = false;\r\n    expressionParser_->parseExpression(QString::fromStdString(busDefinition->getMaxInitiators()),\r\n        &initiatorsValid);\r\n\r\n\tif (initiatorsValid == false)\r\n\t{\r\n\t\terrors.append(QObject::tr(\"MaxInitiators '%1' is not a valid expression within %2.\").arg(\r\n            QString::fromStdString(busDefinition->getMaxInitiators()), context));\r\n\t}\r\n    \r\n    bool targetsValid = false;\r\n    expressionParser_->parseExpression(QString::fromStdString(busDefinition->getMaxTargets()), &targetsValid);\r\n    if (targetsValid == false)\r\n\t{\r\n\t\terrors.append(QObject::tr(\"MaxTargets '%1' is not a valid expression within %2.\").arg(\r\n            QString::fromStdString(busDefinition->getMaxTargets()), context));\r\n\t}\r\n\r\n    ParameterValidator parameterValidator(expressionParser_, QSharedPointer<QList<QSharedPointer<Choice> > >(), busDefinition->getRevision());\r\n\r\n    for (auto const& currentParameter : *busDefinition->getParameters())\r\n    {\r\n        parameterValidator.findErrorsIn(errors, currentParameter, context);\r\n    }\r\n\r\n    if (!busDefinition->getChoices()->isEmpty()\r\n        && busDefinition->getRevision() != Document::Revision::Std22)\r\n    {\r\n        errors.append(QObject::tr(\"Choices within %1 not supported by standard revision.\").arg(context));\r\n    }\r\n\r\n    for (auto const& currentChoice : *busDefinition->getChoices())\r\n    {\r\n        choiceValidator_->findErrorsIn(errors, currentChoice, context);\r\n    }\r\n}\r\n"
  },
  {
    "path": "IPXACTmodels/BusDefinition/validators/BusDefinitionValidator.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: BusDefinitionValidator.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Janne Virtanen\r\n// Date: 17.11.2015\r\n//\r\n// Description:\r\n// Validator for ipxact:BusDefinition.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef BUSDEFINITIONVALIDATOR_H\r\n#define BUSDEFINITIONVALIDATOR_H\r\n\r\n#include <IPXACTmodels/ipxactmodels_global.h>\r\n\r\n#include <QString>\r\n#include <QSharedPointer>\r\n#include <QVector>\r\n\r\nclass BusDefinition;\r\nclass ExpressionParser;\r\nclass ParameterValidator;\r\nclass ChoiceValidator;\r\nclass LibraryInterface;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Validator for ipxact:BusDefinition.\r\n//-----------------------------------------------------------------------------\r\nclass IPXACTMODELS_EXPORT BusDefinitionValidator\r\n{\r\npublic:\r\n\r\n\t/*!\r\n\t *  The constructor.\r\n\t *\r\n     *    @param [in] library             The library interface.\r\n     *    @param [in] expressionParser    The expression parser to use.\r\n\t */\r\n    BusDefinitionValidator(LibraryInterface* library, QSharedPointer<ExpressionParser> expressionParser);\r\n\r\n\t//! The destructor.\r\n\tvirtual ~BusDefinitionValidator();\r\n    \r\n    /*!\r\n     *  Validates the given BusDefinition.\r\n     *\r\n     *    @param [in] BusDefinition           The BusDefinition to validate.\r\n     *\r\n     *    @return True, if the BusDefinition is valid IP-XACT, otherwise false.\r\n     */\r\n    virtual bool validate(QSharedPointer<const BusDefinition> busDefinition) const;\r\n\r\n    /*!\r\n     *  Finds possible errors in a BusDefinition and creates a list of them.\r\n     *\r\n     *    @param [out] errors         List of found errors.\r\n     *    @param [in] BusDefinition   The BusDefinition whose errors to find.\r\n     */\r\n    virtual void findErrorsIn(QVector<QString>& errors, QSharedPointer<const BusDefinition> busDefinition) const;\r\n\r\nprivate:\r\n\r\n\t// Disable copying.\r\n\tBusDefinitionValidator(BusDefinitionValidator const& rhs);\r\n\tBusDefinitionValidator& operator=(BusDefinitionValidator const& rhs);\r\n\r\n    /*!\r\n     *  Check if the extend value of the selected bus definition is valid.\r\n     *\r\n     *    @param [in] busDefinition   The selected bus definition.\r\n     *\r\n     *    @return True, if the extend value is valid, false otherwise.\r\n     */\r\n    bool extendIsValid(QSharedPointer<const BusDefinition> busDefinition) const;\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! The library interface.\r\n    LibraryInterface* library_;\r\n\r\n    //! The expression parser to use.\r\n    QSharedPointer<ExpressionParser> expressionParser_;\r\n\r\n    //! The validator for choices.\r\n    QSharedPointer<ChoiceValidator> choiceValidator_;\r\n};\r\n\r\n#endif // SYSTEMVERILOGVALIDATOR_H\r\n"
  },
  {
    "path": "IPXACTmodels/Catalog/Catalog.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: Catalog.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Esko Pekkarinen\n// Date: 30.01.2017\n//\n// Description:\n// Implementation for ipxact:catalog element.\n//-----------------------------------------------------------------------------\n\n#include \"Catalog.h\"\n\n#include \"IpxactFile.h\"\n\n#include <QString>\n#include <QObject>\n#include <QSharedPointer>\n#include <QStringList>\n\n//-----------------------------------------------------------------------------\n// Function: Catalog::Catalog()\n//-----------------------------------------------------------------------------\nCatalog::Catalog(VLNV const & vlnv, Document::Revision revision):\nDocument(vlnv, revision),\n    catalogs_(new QList<QSharedPointer<IpxactFile> >()),\n    busDefinitions_(new QList<QSharedPointer<IpxactFile> >()),\n    abstractionDefinitions_(new QList<QSharedPointer<IpxactFile> >()),\n    components_(new QList<QSharedPointer<IpxactFile> >()),\n    abstractors_(new QList<QSharedPointer<IpxactFile> >()),\n    designs_(new QList<QSharedPointer<IpxactFile> >()),\n    designConfigurations_(new QList<QSharedPointer<IpxactFile> >()),\n    generatorChains_(new QList<QSharedPointer<IpxactFile> >()),\n    typeDefinitions_(new QList<QSharedPointer<IpxactFile> >())\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: Catalog::Catalog()\n//-----------------------------------------------------------------------------\nCatalog::Catalog(Catalog const& other):\nDocument(other),\n    catalogs_(new QList<QSharedPointer<IpxactFile> >()),\n    busDefinitions_(new QList<QSharedPointer<IpxactFile> >()),\n    abstractionDefinitions_(new QList<QSharedPointer<IpxactFile> >()),\n    components_(new QList<QSharedPointer<IpxactFile> >()),\n    abstractors_(new QList<QSharedPointer<IpxactFile> >()),\n    designs_(new QList<QSharedPointer<IpxactFile> >()),\n    designConfigurations_(new QList<QSharedPointer<IpxactFile> >()),\n    generatorChains_(new QList<QSharedPointer<IpxactFile> >()),\n    typeDefinitions_(new QList<QSharedPointer<IpxactFile> >())\n{\n    copyIpxactFiles(other);\n}\n\n//-----------------------------------------------------------------------------\n// Function: Catalog::operator=()\n//-----------------------------------------------------------------------------\nCatalog & Catalog::operator=(Catalog const& other)\n{\n    if (this != &other)\n    {\n        Document::operator=(other);\n        \n        catalogs_->clear();\n        busDefinitions_->clear();\n        abstractionDefinitions_->clear();\n        components_->clear();\n        abstractors_->clear();\n        designs_->clear();\n        designConfigurations_->clear();\n        generatorChains_->clear();\n        typeDefinitions_->clear();\n\n        copyIpxactFiles(other);\n    }\n\n    return *this;\n}\n\n//-----------------------------------------------------------------------------\n// Function: Catalog::~Catalog()\n//-----------------------------------------------------------------------------\nCatalog::~Catalog()\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: Catalog::clone()\n//-----------------------------------------------------------------------------\nQSharedPointer<Document> Catalog::clone() const\n{\n    return QSharedPointer<Document>(new Catalog(*this));\n}\n\n//-----------------------------------------------------------------------------\n// Function: Catalog::setVlnv()\n//-----------------------------------------------------------------------------\nvoid Catalog::setVlnv(VLNV const& vlnv)\n{\n    VLNV CatalogVLNV(vlnv);\n    CatalogVLNV.setType(VLNV::CATALOG);\n\n    Document::setVlnv(CatalogVLNV);\n}\n\n//-----------------------------------------------------------------------------\n// Function: Catalog::getCatalogs()\n//-----------------------------------------------------------------------------\nQSharedPointer<QList<QSharedPointer<IpxactFile> > > Catalog::getCatalogs() const\n{\n    return catalogs_;\n}\n\n//-----------------------------------------------------------------------------\n// Function: Catalog::getBusDefinitions()\n//-----------------------------------------------------------------------------\nQSharedPointer<QList<QSharedPointer<IpxactFile> > > Catalog::getBusDefinitions() const\n{\n    return busDefinitions_;\n}\n\n//-----------------------------------------------------------------------------\n// Function: Catalog::getAbstractionDefinitions()\n//-----------------------------------------------------------------------------\nQSharedPointer<QList<QSharedPointer<IpxactFile> > > Catalog::getAbstractionDefinitions() const\n{\n    return abstractionDefinitions_;\n}\n\n//-----------------------------------------------------------------------------\n// Function: Catalog::getComponents()\n//-----------------------------------------------------------------------------\nQSharedPointer<QList<QSharedPointer<IpxactFile> > > Catalog::getComponents() const\n{\n    return components_;\n}\n\n//-----------------------------------------------------------------------------\n// Function: Catalog::getAbstractor()\n//-----------------------------------------------------------------------------\nQSharedPointer<QList<QSharedPointer<IpxactFile> > > Catalog::getAbstractors() const\n{\n    return abstractors_;\n}\n\n//-----------------------------------------------------------------------------\n// Function: Catalog::getDesigns()\n//-----------------------------------------------------------------------------\nQSharedPointer<QList<QSharedPointer<IpxactFile> > > Catalog::getDesigns() const\n{\n    return designs_;\n}\n\n//-----------------------------------------------------------------------------\n// Function: Catalog::getDesignConfigurations()\n//-----------------------------------------------------------------------------\nQSharedPointer<QList<QSharedPointer<IpxactFile> > > Catalog::getDesignConfigurations() const\n{\n    return designConfigurations_;\n}\n\n//-----------------------------------------------------------------------------\n// Function: Catalog::getGeneratorChains()\n//-----------------------------------------------------------------------------\nQSharedPointer<QList<QSharedPointer<IpxactFile> > > Catalog::getGeneratorChains() const\n{\n    return generatorChains_;\n}\n\n//-----------------------------------------------------------------------------\n// Function: Catalog::getTypeDefinitions()\n//-----------------------------------------------------------------------------\nQSharedPointer<QList<QSharedPointer<IpxactFile> > > Catalog::getTypeDefinitions() const\n{\n    return typeDefinitions_;\n}\n\n//-----------------------------------------------------------------------------\n// Function: Catalog::getDependentVLNVs()\n//-----------------------------------------------------------------------------\nQList<VLNV> Catalog::getDependentVLNVs() const \n{\n    QList<VLNV> vlnvs;\n\n    for (auto const& file : getAllFiles())\n    {\n        vlnvs.append(file->getVlnv());\n    }\n\n    return vlnvs;\n}\n\n//-----------------------------------------------------------------------------\n// Function: Catalog::getDependentFiles()\n//-----------------------------------------------------------------------------\nQStringList Catalog::getDependentFiles() const\n{\n    QStringList fileNames;\n\n    for (auto const& file : getAllFiles())\n    {\n        fileNames.append(file->getName());\n    }\n\n    return fileNames;\n}\n\n//-----------------------------------------------------------------------------\n// Function: Catalog::copyIpxactFiles()\n//-----------------------------------------------------------------------------\nvoid Catalog::copyIpxactFiles(Catalog const& other)\n{\n    for (auto const& catalog : *other.catalogs_)\n    {\n        catalogs_->append(QSharedPointer<IpxactFile>(new IpxactFile(*catalog)));\n    }\n\n    for (auto const& busDefinition : *other.busDefinitions_)\n    {\n        busDefinitions_->append(QSharedPointer<IpxactFile>(new IpxactFile(*busDefinition)));\n    }\n\n    for (auto const& abstractionDefinition : *other.abstractionDefinitions_)\n    {\n        abstractionDefinitions_->append(QSharedPointer<IpxactFile>(new IpxactFile(*abstractionDefinition)));\n    }\n\n    for (auto const& component : *other.components_)\n    {\n        components_->append(QSharedPointer<IpxactFile>(new IpxactFile(*component)));\n    }\n\n    for (auto const& abstractor : *other.abstractors_)\n    {\n        abstractors_->append(QSharedPointer<IpxactFile>(new IpxactFile(*abstractor)));\n    }\n    \n    for (auto const& design : *other.designs_)\n    {\n        designs_->append(QSharedPointer<IpxactFile>(new IpxactFile(*design)));\n    }\n\n    for (auto const& configuration : *other.designConfigurations_)\n    {\n        designConfigurations_->append(QSharedPointer<IpxactFile>(new IpxactFile(*configuration)));\n    }\n\n    for (auto const& chain : *other.generatorChains_)\n    {\n        generatorChains_->append(QSharedPointer<IpxactFile>(new IpxactFile(*chain)));\n    }\n    \n    for (auto const& typeDef : *other.typeDefinitions_)\n    {\n        typeDefinitions_->append(QSharedPointer<IpxactFile>(new IpxactFile(*typeDef)));\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: Catalog::getAllFiles()\n//-----------------------------------------------------------------------------\nQList<QSharedPointer<IpxactFile> > Catalog::getAllFiles() const\n{\n    QList<QSharedPointer<IpxactFile> > files;\n\n    files.append(*catalogs_);\n    files.append(*busDefinitions_);\n    files.append(*abstractionDefinitions_);\n    files.append(*components_);\n    files.append(*abstractors_);\n    files.append(*designs_);\n    files.append(*designConfigurations_);\n    files.append(*generatorChains_);\n    files.append(*typeDefinitions_);\n\n    return files;\n}\n"
  },
  {
    "path": "IPXACTmodels/Catalog/Catalog.h",
    "content": "//-----------------------------------------------------------------------------\n// File: Catalog.h\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Esko Pekkarinen\n// Date: 30.01.2017\n//\n// Description:\n// Implementation for ipxact:catalog element.\n//-----------------------------------------------------------------------------\n\n#ifndef CATALOG_H\n#define CATALOG_H\n\n\n#include <IPXACTmodels/common/Document.h>\n#include <IPXACTmodels/common/VLNV.h>\n\n#include <IPXACTmodels/ipxactmodels_global.h>\n \n#include <QSharedPointer>\n#include <QList>\n\nclass IpxactFile;\n\n//-----------------------------------------------------------------------------\n//! Implementation for ipxact:Catalog element.\n//-----------------------------------------------------------------------------\nclass IPXACTMODELS_EXPORT Catalog: public Document\n{\npublic:\n\n\t//! The default constructor.\n\tCatalog(VLNV const & vlnv, Document::Revision revision);\n\n\t//! Copy constructor.\n\tCatalog(Catalog const& other);\n\n\n\t//! Assignment operator.\n\tCatalog &operator=(Catalog const& other);\n\n\t//! The destructor.\n\tvirtual ~Catalog();\n\n\t/*!\n\t *  Creates a perfect copy of the catalog.\n\t *\n\t *    @return Copy of the catalog.\n\t */\n\tvirtual QSharedPointer<Document> clone() const;\n\n\t/*! Set the VLNV for the catalog.\n\t*\n\t*    @param [in] vlnv     The vlnv to set\n\t*/\n\tvirtual void setVlnv(const VLNV& vlnv);\n\n    /*!\n     *  Get the catalog descriptions in the catalog.\n     *\n     *    @return The catalogs referenced by this catalog.\n     */\n    QSharedPointer<QList<QSharedPointer<IpxactFile> > > getCatalogs() const;\n\n    /*!\n     *  Get the bus definitions descriptions in the catalog.\n     *\n     *    @return The bus definitions referenced by this catalog.\n     */\n    QSharedPointer<QList<QSharedPointer<IpxactFile> > > getBusDefinitions() const;\n\n    /*!\n     *  Get the abstractions definitions in the catalog.\n     *\n     *    @return The abstractions definitions referenced by this catalog.\n     */\n    QSharedPointer<QList<QSharedPointer<IpxactFile> > > getAbstractionDefinitions() const;\n\n    /*!\n     *  Get the component descriptions in the catalog.\n     *\n     *    @return The components referenced by this catalog.\n     */\n    QSharedPointer<QList<QSharedPointer<IpxactFile> > > getComponents() const;\n\n    /*!\n     *  Get the abstractor descriptions in the catalog.\n     *\n     *    @return The abstractors referenced by this catalog.\n     */\n    QSharedPointer<QList<QSharedPointer<IpxactFile> > > getAbstractors() const;\n  \n    /*!\n     *  Get the design descriptions in the catalog.\n     *\n     *    @return The designs referenced by this catalog.\n     */  \n    QSharedPointer<QList<QSharedPointer<IpxactFile> > > getDesigns() const;\n    \n    /*!\n     *  Get the design configuration descriptions in the catalog.\n     *\n     *    @return The design configurations referenced by this catalog.\n     */\n    QSharedPointer<QList<QSharedPointer<IpxactFile> > > getDesignConfigurations() const;\n\n    /*!\n     *  Get the generator chain descriptions in the catalog.\n     *\n     *    @return The generator chains referenced by this catalog.\n     */\n    QSharedPointer<QList<QSharedPointer<IpxactFile> > > getGeneratorChains() const;\n\n    /*!\n     *  Get the type definitions in the catalog.\n     *\n     *    @return The type definitions referenced by this catalog.\n     */\n    QSharedPointer<QList<QSharedPointer<IpxactFile> > > getTypeDefinitions() const;\n    \n\t/*! Get the VLNVs that this catalog depends on.\n\t *\n\t *    @return The dependency VLNVs.\n\t */\n\tvirtual QList<VLNV> getDependentVLNVs() const;\n\n\t/*! Get the file dependencies of this catalog.\n     *\n\t *    @return The dependency files.\n     *\n     *      @remark This function never returns anything because catalog only has VLNV dependencies.\n\t */\n\tvirtual QStringList getDependentFiles() const;\n\nprivate:\n\n    /*!\n     *  Copies file descriptions from another catalog.\n     *\n     *    @param [in] other   The catalog to copy from.\n     */\n    void copyIpxactFiles(Catalog const& other);\n\n    /*!\n     *  Gets all the ipxact files in the catalog regardless of the type.\n     *\n     *    @return All ipxact files in the catalog.\n     */\n    QList<QSharedPointer<IpxactFile> > getAllFiles() const;\n\n    //! The catalogs referenced by this catalog.\n    QSharedPointer<QList<QSharedPointer<IpxactFile> > > catalogs_;\n\n    //! The bus definitions referenced by this catalog.\n    QSharedPointer<QList<QSharedPointer<IpxactFile> > > busDefinitions_;\n\n    //! The abstration definitions referenced by this catalog.\n    QSharedPointer<QList<QSharedPointer<IpxactFile> > > abstractionDefinitions_;\n\n    //! The components referenced by this catalog.\n    QSharedPointer<QList<QSharedPointer<IpxactFile> > > components_;\n\n    //! The abstractors referenced by this catalog.\n    QSharedPointer<QList<QSharedPointer<IpxactFile> > > abstractors_;\n\n    //! The designs referenced by this catalog.\n    QSharedPointer<QList<QSharedPointer<IpxactFile> > > designs_;\n\n    //! The design configurations referenced by this catalog.\n    QSharedPointer<QList<QSharedPointer<IpxactFile> > > designConfigurations_;\n\n    //! The generator chains referenced by this catalog.\n    QSharedPointer<QList<QSharedPointer<IpxactFile> > > generatorChains_;\n    \n    //! The type definitions referenced by this catalog.\n    QSharedPointer<QList<QSharedPointer<IpxactFile> > > typeDefinitions_;\n};\n\n#endif // CATALOG_H\n"
  },
  {
    "path": "IPXACTmodels/Catalog/CatalogReader.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: CatalogReader.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Esko Pekkarinen\n// Date: 07.08.2015\n//\n// Description:\n// XML reader for IP-XACT Parameter element.\n//-----------------------------------------------------------------------------\n\n#include \"CatalogReader.h\"\n\n#include \"Catalog.h\"\n#include \"IpxactFile.h\"\n\n\n//-----------------------------------------------------------------------------\n// Function: CatalogReader::createCatalogFrom()\n//-----------------------------------------------------------------------------\nQSharedPointer<Catalog> CatalogReader::createCatalogFrom(QDomNode const& document)\n{\n    QDomNode catalogNode = document.firstChildElement();\n    \n    Document::Revision docRevision = DocumentReader::getXMLDocumentRevision(catalogNode);\n\n    VLNV vlnv = CommonItemsReader::createVLNVFrom(catalogNode, VLNV::CATALOG);\n\n    QSharedPointer<Catalog> catalog(new Catalog(vlnv, docRevision));\n\n    DocumentReader::parseTopComments(document, catalog);\n\n    DocumentReader::parseXMLProcessingInstructions(document, catalog);\n\n    DocumentReader::parseNamespaceDeclarations(catalogNode, catalog);\n\n    DocumentReader::parseDocumentNameGroup(catalogNode, catalog);\n\n    if (catalog->getRevision() != Document::Revision::Std22)\n    {\n        DocumentReader::parseDescription(catalogNode, catalog);\n    }\n\n    Details::parseCatalogs(catalogNode, catalog);\n\n    Details::parseBusDefinitions(catalogNode, catalog);\n\n    Details::parseAbstractionDefinitions(catalogNode, catalog);\n\n    Details::parseComponents(catalogNode, catalog);\n\n    Details::parseAbstractors(catalogNode, catalog);\n\n    Details::parseDesigns(catalogNode, catalog);\n    \n    Details::parseDesignCongfigurations(catalogNode, catalog);\n\n    Details::parseGeneratorChains(catalogNode, catalog);\n\n    Details::parseTypeDefinitions(catalogNode, catalog);\n\n    DocumentReader::parseKactusAndVendorExtensions(catalogNode, catalog);\n\n    return catalog;\n}\n\n//-----------------------------------------------------------------------------\n// Function: CatalogReader::Details::parseCatalogs()\n//-----------------------------------------------------------------------------\nvoid CatalogReader::Details::parseCatalogs(QDomNode const& catalogNode, QSharedPointer<Catalog> catalog)\n{   \n    QDomElement catalogsNode = catalogNode.firstChildElement(QStringLiteral(\"ipxact:catalogs\"));\n    \n    catalog->getCatalogs()->append(parseIpxactFileList(catalogsNode, VLNV::CATALOG));\n}\n\n//-----------------------------------------------------------------------------\n// Function: CatalogReader::Details::parseBusDefinitions()\n//-----------------------------------------------------------------------------\nvoid CatalogReader::Details::parseBusDefinitions(QDomNode const& catalogNode, QSharedPointer<Catalog> catalog)\n{   \n    QDomElement busDefinitionsNode = catalogNode.firstChildElement(QStringLiteral(\"ipxact:busDefinitions\"));\n\n    catalog->getBusDefinitions()->append(parseIpxactFileList(busDefinitionsNode, VLNV::BUSDEFINITION));\n}\n\n//-----------------------------------------------------------------------------\n// Function: CatalogReader::Details::parseAbstractionDefinitions()\n//-----------------------------------------------------------------------------\nvoid CatalogReader::Details::parseAbstractionDefinitions(QDomNode const& catalogNode, QSharedPointer<Catalog> catalog)\n{   \n    QDomElement abstractionsNode = catalogNode.firstChildElement(QStringLiteral(\"ipxact:abstractionDefinitions\"));\n\n    catalog->getAbstractionDefinitions()->append(parseIpxactFileList(abstractionsNode, VLNV::ABSTRACTIONDEFINITION));\n}\n\n//-----------------------------------------------------------------------------\n// Function: CatalogReader::Details::parseComponents()\n//-----------------------------------------------------------------------------\nvoid CatalogReader::Details::parseComponents(QDomNode const& catalogNode, QSharedPointer<Catalog> catalog)\n{   \n    QDomElement componentsNode = catalogNode.firstChildElement(QStringLiteral(\"ipxact:components\"));\n\n    catalog->getComponents()->append(parseIpxactFileList(componentsNode, VLNV::COMPONENT));\n}\n\n//-----------------------------------------------------------------------------\n// Function: CatalogReader::Details::parseAbstractors()\n//-----------------------------------------------------------------------------\nvoid CatalogReader::Details::parseAbstractors(QDomNode const& catalogNode, QSharedPointer<Catalog> catalog)\n{   \n    QDomElement abstractorsNode = catalogNode.firstChildElement(QStringLiteral(\"ipxact:abstractors\"));\n\n    catalog->getAbstractors()->append(parseIpxactFileList(abstractorsNode, VLNV::ABSTRACTOR));\n}\n\n//-----------------------------------------------------------------------------\n// Function: CatalogReader::Details::parseDesigns()\n//-----------------------------------------------------------------------------\nvoid CatalogReader::Details::parseDesigns(QDomNode const& catalogNode, QSharedPointer<Catalog> catalog)\n{   \n    QDomElement designsNode = catalogNode.firstChildElement(QStringLiteral(\"ipxact:designs\"));\n\n    catalog->getDesigns()->append(parseIpxactFileList(designsNode, VLNV::DESIGN));\n}\n\n//-----------------------------------------------------------------------------\n// Function: CatalogReader::Details::parseDesignCongfigurations()\n//-----------------------------------------------------------------------------\nvoid CatalogReader::Details::parseDesignCongfigurations(QDomNode const& catalogNode, QSharedPointer<Catalog> catalog)\n{   \n    QDomElement configurationsNode = catalogNode.firstChildElement(QStringLiteral(\"ipxact:designConfigurations\"));\n\n    catalog->getDesignConfigurations()->append(parseIpxactFileList(configurationsNode, VLNV::DESIGNCONFIGURATION));\n}\n\n//-----------------------------------------------------------------------------\n// Function: CatalogReader::Details::parseGeneratorChains()\n//-----------------------------------------------------------------------------\nvoid CatalogReader::Details::parseGeneratorChains(QDomNode const& catalogNode, QSharedPointer<Catalog> catalog)\n{   \n    QDomElement chainsNode = catalogNode.firstChildElement(QStringLiteral(\"ipxact:generatorChains\"));\n\n    catalog->getGeneratorChains()->append(parseIpxactFileList(chainsNode, VLNV::GENERATORCHAIN));\n}\n\n//-----------------------------------------------------------------------------\n// Function: CatalogReader::Details::parseTypeDefinitions()\n//-----------------------------------------------------------------------------\nvoid CatalogReader::Details::parseTypeDefinitions(QDomNode const& catalogNode, QSharedPointer<Catalog> catalog)\n{\n    if (catalog->getRevision() != Document::Revision::Std22)\n    {\n        return;\n    }\n    \n    QDomElement typeDefsNode = catalogNode.firstChildElement(QStringLiteral(\"ipxact:typeDefinitions\"));\n    \n    catalog->getTypeDefinitions()->append(parseIpxactFileList(typeDefsNode, VLNV::TYPEDEFINITION));\n}\n\n//-----------------------------------------------------------------------------\n// Function: CatalogReader::Details::parseIpxactFileList()\n//-----------------------------------------------------------------------------\nQList<QSharedPointer<IpxactFile> > CatalogReader::Details::parseIpxactFileList(QDomElement & filesNode, \n    VLNV::IPXactType documentType)\n{\n    QList<QSharedPointer<IpxactFile> > files;\n\n    if (!filesNode.isNull())\n    {\n        QDomNodeList fileNodeList = filesNode.elementsByTagName(QStringLiteral(\"ipxact:ipxactFile\"));\n        for (int fileIndex = 0; fileIndex < fileNodeList.count(); fileIndex++)\n        {\n            files.append(createIpxactFileFrom(fileNodeList.at(fileIndex), documentType));\n        }\n    }\n\n    return files;\n}\n\n//-----------------------------------------------------------------------------\n// Function: CatalogReader::Details::createIpxactFileFrom()\n//-----------------------------------------------------------------------------\nQSharedPointer<IpxactFile> CatalogReader::Details::createIpxactFileFrom(QDomNode const& fileNode, \n    VLNV::IPXactType documentType)\n{\n    QSharedPointer<IpxactFile> ipxactFile(new IpxactFile());\n\n    QDomNode vlnvNode = fileNode.firstChildElement(QStringLiteral(\"ipxact:vlnv\"));\n    ipxactFile->setVlnv(CommonItemsReader::parseVLNVAttributes(vlnvNode, documentType));\n\n    ipxactFile->setName(fileNode.firstChildElement(QStringLiteral(\"ipxact:name\")).firstChild().nodeValue());\n\n    QDomNode descriptionNode = fileNode.firstChildElement(QStringLiteral(\"ipxact:description\"));\n    ipxactFile->setDescription(descriptionNode.firstChild().nodeValue());\n\n    CommonItemsReader::parseVendorExtensions(fileNode, ipxactFile);\n\n    return ipxactFile;    \n}\n"
  },
  {
    "path": "IPXACTmodels/Catalog/CatalogReader.h",
    "content": "//-----------------------------------------------------------------------------\n// File: CatalogReader.h\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Esko Pekkarinen\n// Date: 01.02.2017\n//\n// Description:\n// XML reader for IP-XACT Catalog element.\n//-----------------------------------------------------------------------------\n\n#ifndef CATALOGREADER_H\n#define CATALOGREADER_H\n\n#include <QDomNode>\n#include <QSharedPointer>\n\n#include <IPXACTmodels/common/DocumentReader.h>\n#include <IPXACTmodels/ipxactmodels_global.h>\n\nclass Catalog;\nclass IpxactFile;\n\n//-----------------------------------------------------------------------------\n//! XML reader for IP-XACT Catalog element.\n//-----------------------------------------------------------------------------\nnamespace CatalogReader\n{\n\n    /*!\n     *  Creates a catalog from XML description.\n     *\n     *    @param [in] document   The XML document to create the catalog from.\n     *\n     *    @return The created catalog.\n     */\n    IPXACTMODELS_EXPORT QSharedPointer<Catalog> createCatalogFrom(QDomNode const& document);\n \n    namespace Details\n    {\n\n        /*!\n         *  Reads the catalog file descriptions to the catalog.\n         *\n         *    @param [in]     catalogNode     The XML description of the catalog.\n         *    @param [in/out] catalog         The catalog to insert the file descriptions into.\n         */\n        void parseCatalogs(QDomNode const& catalogNode, QSharedPointer<Catalog> catalog);\n\n        /*!\n         *  Reads the bus definition file descriptions to the catalog.\n         *\n         *    @param [in]     catalogNode     The XML description of the catalog.\n         *    @param [in/out] catalog         The catalog to insert the file descriptions into.\n         */\n        void parseBusDefinitions(QDomNode const& catalogNode, QSharedPointer<Catalog> catalog);\n\n        /*!\n         *  Reads the abstraction definition file descriptions to the catalog.\n         *\n         *    @param [in]     catalogNode     The XML description of the catalog.\n         *    @param [in/out] catalog         The catalog to insert the file descriptions into.\n         */\n        void parseAbstractionDefinitions(QDomNode const& catalogNode, QSharedPointer<Catalog> catalog);\n\n        /*!\n         *  Reads the component file descriptions to the catalog.\n         *\n         *    @param [in]     catalogNode     The XML description of the catalog.\n         *    @param [in/out] catalog         The catalog to insert the file descriptions into.\n         */\n        void parseComponents(QDomNode const& catalogNode, QSharedPointer<Catalog> catalog);\n\n        /*!\n         *  Reads the abstractor file descriptions to the catalog.\n         *\n         *    @param [in]     catalogNode     The XML description of the catalog.\n         *    @param [in/out] catalog         The catalog to insert the file descriptions into.\n         */\n        void parseAbstractors(QDomNode const& catalogNode, QSharedPointer<Catalog> catalog);\n\n        /*!\n         *  Reads the design file descriptions to the catalog.\n         *\n         *    @param [in]     catalogNode     The XML description of the catalog.\n         *    @param [in/out] catalog         The catalog to insert the file descriptions into.\n         */\n        void parseDesigns(QDomNode const& catalogNode, QSharedPointer<Catalog> catalog);\n\n        /*!\n         *  Reads the design configuration file descriptions to the catalog.\n         *\n         *    @param [in]     catalogNode     The XML description of the catalog.\n         *    @param [in/out] catalog         The catalog to insert the file descriptions into.\n         */\n        void parseDesignCongfigurations(QDomNode const& catalogNode, QSharedPointer<Catalog> catalog);\n\n        /*!\n         *  Reads the generator chain file descriptions to the catalog.\n         *\n         *    @param [in]     catalogNode     The XML description of the catalog.\n         *    @param [in/out] catalog         The catalog to insert the file descriptions into.\n         */\n        void parseGeneratorChains(QDomNode const& catalogNode, QSharedPointer<Catalog> catalog);\n\n        /*!\n         *\tReads the type definition file descriptions to the catalog.\n         *\n         *    @param [in] catalogNode     The XML description of the catalog.\n         *    @param [in/out] catalog\t        The catalog to insert the file description into.\n         */\n        void parseTypeDefinitions(QDomNode const& catalogNode, QSharedPointer<Catalog> catalog);\n\n        /*!\n         *  Reads XML node containing ipxactFile elements and creates a list of the parsed elements.\n         *\n         *    @param [in] filesNode  The XML description to read.\n         *    @param [in] documentType The type of IP-XACT document.\n         *\n         *    @return List of the parsed ipxactFiles.\n         */\n        QList<QSharedPointer<IpxactFile> > parseIpxactFileList(QDomElement& filesNode, VLNV::IPXactType documentType);\n\n        /*!\n         *  Parses an XML node to ipxactFile element.\n         *\n         *    @param [in] fileNode     The XML description to parse..\n         *    @param [in] documentType The type of IP-XACT document.\n         *\n         *    @return The parsed ipxactFile.\n         */\n        QSharedPointer<IpxactFile> createIpxactFileFrom(QDomNode const& fileNode, VLNV::IPXactType documentType);\n    }\n};\n\n#endif // CATALOGREADER_H"
  },
  {
    "path": "IPXACTmodels/Catalog/CatalogWriter.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: CatalogWriter.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Esko Pekkarinen\n// Date: 30.01.2017\n//\n// Description:\n// Writer for IP-XACT Catalog element.\n//-----------------------------------------------------------------------------\n\n#include \"CatalogWriter.h\"\n\n#include <IPXACTmodels/Catalog/Catalog.h>\n#include <IPXACTmodels/Catalog/IpxactFile.h>\n\n//-----------------------------------------------------------------------------\n// Function: CatalogWriter::writeCatalog()\n//-----------------------------------------------------------------------------\nvoid CatalogWriter::writeCatalog(QXmlStreamWriter& writer, QSharedPointer<Catalog> catalog)\n{\n    writer.writeStartDocument();\n    \n    DocumentWriter::writeTopComments(writer, catalog);\n\n    DocumentWriter::writeXmlProcessingInstructions(writer, catalog);\n\n    writer.writeStartElement(QStringLiteral(\"ipxact:catalog\"));\n    DocumentWriter::writeNamespaceDeclarations(writer, catalog);\n\n    DocumentWriter::writeDocumentNameGroup(writer, catalog);\n\n    if (catalog->getRevision() != Document::Revision::Std22)\n    {\n        DocumentWriter::writeDescription(writer, catalog->getDescription());\n    }\n\n    Details::writeCatalogs(writer, catalog);\n\n    Details::writeBusDefinitions(writer, catalog);\n\n    Details::writeAbstractionDefinitions(writer, catalog);\n\n    Details::writeComponents(writer, catalog);\n\n    Details::writeAbstractors(writer, catalog);\n\n    Details::writeDesigns(writer, catalog);\n\n    Details::writeDesignConfigurations(writer, catalog);\n\n    Details::writeGeneratorChains(writer, catalog);\n\n    Details::writeTypeDefinitions(writer, catalog);\n\n    CommonItemsWriter::writeVendorExtensions(writer, catalog);\n\n    writer.writeEndElement(); // \"ipxact:catalog\"\n    writer.writeEndDocument();\n}\n\n//-----------------------------------------------------------------------------\n// Function: CatalogWriter::Details::writeCatalogs()\n//-----------------------------------------------------------------------------\nvoid CatalogWriter::Details::writeCatalogs(QXmlStreamWriter& writer, QSharedPointer<Catalog> catalog)\n{\n    writeIpxactFileGroup(writer, catalog->getCatalogs(), QStringLiteral(\"ipxact:catalogs\"));\n}\n\n//-----------------------------------------------------------------------------\n// Function: CatalogWriter::Details::writeBusDefinitions()\n//-----------------------------------------------------------------------------\nvoid CatalogWriter::Details::writeBusDefinitions(QXmlStreamWriter& writer, QSharedPointer<Catalog> catalog)\n{\n    writeIpxactFileGroup(writer, catalog->getBusDefinitions(), QStringLiteral(\"ipxact:busDefinitions\"));\n}\n\n//-----------------------------------------------------------------------------\n// Function: CatalogWriter::Details::writeAbstractionDefinitions()\n//-----------------------------------------------------------------------------\nvoid CatalogWriter::Details::writeAbstractionDefinitions(QXmlStreamWriter& writer, QSharedPointer<Catalog> catalog)\n{\n    writeIpxactFileGroup(writer, catalog->getAbstractionDefinitions(), QStringLiteral(\"ipxact:abstractionDefinitions\"));\n}\n\n//-----------------------------------------------------------------------------\n// Function: CatalogWriter::Details::writeComponents()\n//-----------------------------------------------------------------------------\nvoid CatalogWriter::Details::writeComponents(QXmlStreamWriter& writer, QSharedPointer<Catalog> catalog)\n{\n    writeIpxactFileGroup(writer, catalog->getComponents(), QStringLiteral(\"ipxact:components\"));\n}\n\n//-----------------------------------------------------------------------------\n// Function: CatalogWriter::Details::writeAbstractors()\n//-----------------------------------------------------------------------------\nvoid CatalogWriter::Details::writeAbstractors(QXmlStreamWriter& writer, QSharedPointer<Catalog> catalog)\n{\n    writeIpxactFileGroup(writer, catalog->getAbstractors(), QStringLiteral(\"ipxact:abstractors\"));\n}\n\n//-----------------------------------------------------------------------------\n// Function: CatalogWriter::Details::writeDesigns()\n//-----------------------------------------------------------------------------\nvoid CatalogWriter::Details::writeDesigns(QXmlStreamWriter& writer, QSharedPointer<Catalog> catalog)\n{\n    writeIpxactFileGroup(writer, catalog->getDesigns(), QStringLiteral(\"ipxact:designs\"));\n}\n\n//-----------------------------------------------------------------------------\n// Function: CatalogWriter::Details::writeDesignConfigurations()\n//-----------------------------------------------------------------------------\nvoid CatalogWriter::Details::writeDesignConfigurations(QXmlStreamWriter& writer, QSharedPointer<Catalog> catalog)\n{\n    writeIpxactFileGroup(writer, catalog->getDesignConfigurations(), QStringLiteral(\"ipxact:designConfigurations\"));\n}\n\n//-----------------------------------------------------------------------------\n// Function: CatalogWriter::Details::writeGeneratorChains()\n//-----------------------------------------------------------------------------\nvoid CatalogWriter::Details::writeGeneratorChains(QXmlStreamWriter& writer, QSharedPointer<Catalog> catalog)\n{\n    writeIpxactFileGroup(writer, catalog->getGeneratorChains(), QStringLiteral(\"ipxact:generatorChains\"));\n}\n\n//-----------------------------------------------------------------------------\n// Function: CatalogWriter::Details::writeTypeDefinitions()\n//-----------------------------------------------------------------------------\nvoid CatalogWriter::Details::writeTypeDefinitions(QXmlStreamWriter& writer, QSharedPointer<Catalog> catalog)\n{\n    if (catalog->getRevision() == Document::Revision::Std22)\n    {\n        writeIpxactFileGroup(writer, catalog->getTypeDefinitions(), QStringLiteral(\"ipxact:typeDefinitions\"));    \n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: CatalogWriter::Details::writeIpxactFiles()\n//-----------------------------------------------------------------------------\nvoid CatalogWriter::Details::writeIpxactFileGroup(QXmlStreamWriter& writer, \n    QSharedPointer<QList<QSharedPointer<IpxactFile> > > files, QString const& elementName)\n{\n    if (files->isEmpty())\n    {\n        return;\n    }\n\n    writer.writeStartElement(elementName);\n\n    for (auto const& file : *files)\n    {\n        writeIpxactFile(writer, file);\n    }\n\n    writer.writeEndElement();\n}\n\n//-----------------------------------------------------------------------------\n// Function: CatalogWriter::Details::writeIpxactFile()\n//-----------------------------------------------------------------------------\nvoid CatalogWriter::Details::writeIpxactFile(QXmlStreamWriter& writer, QSharedPointer<IpxactFile> ipxactFile)\n{\n    writer.writeStartElement(QStringLiteral(\"ipxact:ipxactFile\"));\n\n    writer.writeEmptyElement(QStringLiteral(\"ipxact:vlnv\"));\n    CommonItemsWriter::writeVLNVAttributes(writer, ipxactFile->getVlnv());\n\n    writer.writeStartElement(QStringLiteral(\"ipxact:name\"));\n    writer.writeCharacters(ipxactFile->getName());\n    writer.writeEndElement(); // ipxact:name\n\n    if (!ipxactFile->getDescription().isEmpty())\n    {\n        writer.writeStartElement(QStringLiteral(\"ipxact:description\"));\n        writer.writeCharacters(ipxactFile->getDescription());\n        writer.writeEndElement(); // ipxact:description\n    }\n\n    CommonItemsWriter::writeVendorExtensions(writer, ipxactFile);\n\n    writer.writeEndElement(); // ipxact:ipxactFile\n}\n"
  },
  {
    "path": "IPXACTmodels/Catalog/CatalogWriter.h",
    "content": "//-----------------------------------------------------------------------------\n// File: CatalogWriter.h\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Esko Pekkarinen\n// Date: 30.01.2017\n//\n// Description:\n// Writer for IP-XACT Catalog element.\n//-----------------------------------------------------------------------------\n\n#ifndef CATALOGWRITER_H\n#define CATALOGWRITER_H\n\n#include <QSharedPointer>\n#include <QXmlStreamWriter>\n\n#include <IPXACTmodels/common/DocumentWriter.h>\n\n#include <IPXACTmodels/ipxactmodels_global.h>\n\nclass Catalog;\nclass PortAbstraction;\nclass VLNV;\nclass IpxactFile;\nclass WirePort;\n\n//-----------------------------------------------------------------------------\n//! Writer for IP-XACT Catalog element.\n//-----------------------------------------------------------------------------\nnamespace CatalogWriter\n{\n    \n    /*!\n     *  Writes the given catalog into XML.\n     *\n     *    @param [in] writer    The XML writer to use.\n     *    @param [in] catalog   The catalog to write.\n     */\n    IPXACTMODELS_EXPORT void writeCatalog(QXmlStreamWriter& writer, QSharedPointer<Catalog> catalog);\n\n    namespace Details\n    {\n        void writeCatalogs(QXmlStreamWriter& writer, QSharedPointer<Catalog> catalog);\n\n        void writeBusDefinitions(QXmlStreamWriter& writer, QSharedPointer<Catalog> catalog);\n\n        void writeAbstractionDefinitions(QXmlStreamWriter& writer, QSharedPointer<Catalog> catalog);\n\n        void writeComponents(QXmlStreamWriter& writer, QSharedPointer<Catalog> catalog);\n\n        void writeAbstractors(QXmlStreamWriter& writer, QSharedPointer<Catalog> catalog);\n\n        void writeDesigns(QXmlStreamWriter& writer, QSharedPointer<Catalog> catalog);\n\n        void writeDesignConfigurations(QXmlStreamWriter& writer, QSharedPointer<Catalog> catalog);\n\n        void writeGeneratorChains(QXmlStreamWriter& writer, QSharedPointer<Catalog> catalog);\n\n        void writeTypeDefinitions(QXmlStreamWriter& writer, QSharedPointer<Catalog> catalog);\n\n        void writeIpxactFileGroup(QXmlStreamWriter& writer, QSharedPointer<QList<QSharedPointer<IpxactFile> > > files,\n            QString const& elementName);\n\n        void writeIpxactFile(QXmlStreamWriter& writer, QSharedPointer<IpxactFile> ipxactFile);\n    }\n};    \n\n#endif // CATALOGWRITER_H"
  },
  {
    "path": "IPXACTmodels/Catalog/IpxactFile.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: IpxactFile.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Esko Pekkarinen\n// Date: 30.01.2017\n//\n// Description:\n// Implementation for ipxact:ipxactFile element.\n//-----------------------------------------------------------------------------\n\n#include \"IpxactFile.h\"\n\n#include <QString>\n#include <QDomNamedNodeMap>\n#include <QDomNode>\n#include <QDomNodeList>\n#include <QObject>\n#include <QSharedPointer>\n#include <QStringList>\n#include <QXmlStreamWriter>\n\n//-----------------------------------------------------------------------------\n// Function: IpxactFile::IpxactFile()\n//-----------------------------------------------------------------------------\nIpxactFile::IpxactFile(): \nExtendable(),\n    vlnv_(),\n    name_()\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: IpxactFile::IpxactFile()\n//-----------------------------------------------------------------------------\nIpxactFile::IpxactFile(IpxactFile const& other):\nExtendable(other),\n    vlnv_(other.vlnv_),\n    name_(other.name_)\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: IpxactFile::operator=()\n//-----------------------------------------------------------------------------\nIpxactFile & IpxactFile::operator=(IpxactFile const& other)\n{\n    if (this != &other)\n    {\n        Extendable::operator=(other);\n        vlnv_ = other.vlnv_;\n        name_ = other.name_;\n    }\n\n    return *this;\n}\n\n//-----------------------------------------------------------------------------\n// Function: IpxactFile::~IpxactFile()\n//-----------------------------------------------------------------------------\nIpxactFile::~IpxactFile()\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: IpxactFile::setVlnv()\n//-----------------------------------------------------------------------------\nvoid IpxactFile::setVlnv(VLNV const& vlnv)\n{\n    vlnv_ = vlnv;\n}\n\n//-----------------------------------------------------------------------------\n// Function: IpxactFile::getVlnv()\n//-----------------------------------------------------------------------------\nVLNV IpxactFile::getVlnv() const\n{\n    return vlnv_;\n}\n\n//-----------------------------------------------------------------------------\n// Function: IpxactFile::setName()\n//-----------------------------------------------------------------------------\nvoid IpxactFile::setName(QString const& name)\n{\n    name_ = name;\n}\n\n//-----------------------------------------------------------------------------\n// Function: IpxactFile::getName()\n//-----------------------------------------------------------------------------\nQString IpxactFile::getName() const\n{\n    return name_;\n}\n\n//-----------------------------------------------------------------------------\n// Function: IpxactFile::setDescription()\n//-----------------------------------------------------------------------------\nvoid IpxactFile::setDescription(QString const& description)\n{\n    description_ = description;\n}\n\n//-----------------------------------------------------------------------------\n// Function: IpxactFile::getDescription()\n//-----------------------------------------------------------------------------\nQString IpxactFile::getDescription() const\n{\n    return description_;\n}\n"
  },
  {
    "path": "IPXACTmodels/Catalog/IpxactFile.h",
    "content": "//-----------------------------------------------------------------------------\n// File: IpxactFile.h\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Esko Pekkarinen\n// Date: 30.01.2017\n//\n// Description:\n// Implementation for ipxact:ipxactFile element.\n//-----------------------------------------------------------------------------\n\n#ifndef IPXACTFILE_H\n#define IPXACTFILE_H\n\n\n#include <IPXACTmodels/common/Extendable.h>\n#include <IPXACTmodels/common/VLNV.h>\n\n#include <IPXACTmodels/ipxactmodels_global.h>\n \n#include <QSharedPointer>\n\n//-----------------------------------------------------------------------------\n//! Implementation for ipxact:ipxactFile element.\n//-----------------------------------------------------------------------------\nclass IPXACTMODELS_EXPORT IpxactFile: public Extendable\n{\npublic:\n\n\t//! The default constructor.\n\tIpxactFile();\n\n\t//! Copy constructor.\n\tIpxactFile(IpxactFile const& other);\n\n\t//! Assignment operator.\n\tIpxactFile &operator=(IpxactFile const& other);\n\n\t//! The destructor.\n\tvirtual ~IpxactFile();\n\n\t/*! Set the VLNV for the file.\n\t*\n\t*    @param [in] vlnv     The vlnv to set.\n\t*/\n\tvoid setVlnv(const VLNV& vlnv);\n    \t\n    /*! Get the VLNV for the file.\n\t *\n\t *    @return The vlnv referenced in the file.\n\t */\n    VLNV getVlnv() const;\n    \t\n    /*! Set the name (path) for the file.\n\t *\n\t *    @param [in] name   The name to set.\n\t */\n    void setName(QString const& name);\n    \t\n    /*! Get the name (path) for the file.\n\t *\n\t *    @return The path to the xml file.\n\t */\n    QString getName() const;\n    \t\n    /*! Set the description for the file.\n\t *\n\t *    @param [in] description   The description to set.\n\t */\n    void setDescription(QString const& description);\n    \t\n    /*! Get the description for the file.\n\t *\n\t *    @return   The description for the file.\n\t */\n    QString getDescription() const;\n\nprivate:\n\n    //! The VLNV referenced in the file.\n    VLNV vlnv_;\n\n    //! Path to the XML file.\n    QString name_;\n\n    //! Description of the XML file.\n    QString description_;\n};\n\n#endif // IPXACTFILE_H\n"
  },
  {
    "path": "IPXACTmodels/Catalog/validators/CatalogValidator.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: CatalogValidator.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Esko Pekkarinen\n// Date: 01.02.2017\n//\n// Description:\n// Validator for ipxact:catalog.\n//-----------------------------------------------------------------------------\n\n#include \"CatalogValidator.h\"\n\n#include <KactusAPI/include/LibraryInterface.h>\n\n#include <KactusAPI/include/ExpressionParser.h>\n\n#include <IPXACTmodels/Catalog/Catalog.h>\n#include <IPXACTmodels/Catalog/IpxactFile.h>\n\n#include <QRegularExpression>\n#include <QStringList>\n\n//-----------------------------------------------------------------------------\n// Function: CatalogValidator::CatalogValidator()\n//-----------------------------------------------------------------------------\nCatalogValidator::CatalogValidator()\n{\n\n}\n\n\n//-----------------------------------------------------------------------------\n// Function: CatalogValidator::~CatalogValidator()\n//-----------------------------------------------------------------------------\nCatalogValidator::~CatalogValidator()\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: CatalogValidator::validateInstantiation()\n//-----------------------------------------------------------------------------\nbool CatalogValidator::validate(QSharedPointer<Catalog> catalog) const\n{\n    return catalog->getVlnv().isValid() &&\n        validateFiles(catalog->getCatalogs()) &&\n        validateFiles(catalog->getBusDefinitions()) &&\n        validateFiles(catalog->getAbstractionDefinitions()) &&\n        validateFiles(catalog->getComponents()) &&\n        validateFiles(catalog->getAbstractors()) &&\n        validateFiles(catalog->getDesigns()) &&\n        validateFiles(catalog->getDesignConfigurations()) &&\n        validateFiles(catalog->getGeneratorChains()) &&\n        validateFiles(catalog->getTypeDefinitions());\n}\n\n//-----------------------------------------------------------------------------\n// Function: CatalogValidator::findErrorsIn()\n//-----------------------------------------------------------------------------\nvoid CatalogValidator::findErrorsIn(QVector<QString>& errors, QSharedPointer<Catalog> catalog) const\n{\n\t// Must have a valid VLNV.\n\tif (!catalog->getVlnv().isValid())\n\t{\n\t\terrors.append(QObject::tr(\"The VLNV %1 is invalid.\").arg(catalog->getVlnv().toString()));\n\t}\n\n    QString context = QObject::tr(\"catalog within catalog %1\").arg(catalog->getVlnv().toString());\n    findErrorsInFiles(errors, catalog->getCatalogs(), context);\n\n    context = QObject::tr(\"bus definition within catalog %1\").arg(catalog->getVlnv().toString());\n    findErrorsInFiles(errors, catalog->getBusDefinitions(), context);\n\n    context = QObject::tr(\"abstraction definition within catalog %1\").arg(catalog->getVlnv().toString());\n    findErrorsInFiles(errors, catalog->getAbstractionDefinitions(), context);\n\n    context = QObject::tr(\"component within catalog %1\").arg(catalog->getVlnv().toString());\n    findErrorsInFiles(errors, catalog->getComponents(), context);\n\n    context = QObject::tr(\"abstractor within catalog %1\").arg(catalog->getVlnv().toString());\n    findErrorsInFiles(errors, catalog->getAbstractors(), context);\n    \n    context = QObject::tr(\"design within catalog %1\").arg(catalog->getVlnv().toString());\n    findErrorsInFiles(errors, catalog->getDesigns(), context);\n\n    context = QObject::tr(\"design configuration within catalog %1\").arg(catalog->getVlnv().toString());\n    findErrorsInFiles(errors, catalog->getDesignConfigurations(), context);\n\n    context = QObject::tr(\"generator chain within catalog %1\").arg(catalog->getVlnv().toString());\n    findErrorsInFiles(errors, catalog->getGeneratorChains(), context);\n    \n    context = QObject::tr(\"type definition within catalog %1\").arg(catalog->getVlnv().toString());\n    findErrorsInFiles(errors, catalog->getTypeDefinitions(), context);\n}\n\n//-----------------------------------------------------------------------------\n// Function: CatalogValidator::validateFiles()\n//-----------------------------------------------------------------------------\nbool CatalogValidator::validateFiles(QSharedPointer<QList<QSharedPointer<IpxactFile> > > files) const\n{\n    for (auto const& file : *files)\n    {\n        if (!validateFile(file))\n        {\n            return false;\n        }\n    }\n\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: CatalogValidator::validateFile()\n//-----------------------------------------------------------------------------\nbool CatalogValidator::validateFile(QSharedPointer<IpxactFile> file) const\n{\n    return file->getVlnv().isValid() && !file->getName().isEmpty();\n}\n\n//-----------------------------------------------------------------------------\n// Function: CatalogValidator::findErrorsInFile()\n//-----------------------------------------------------------------------------\nvoid CatalogValidator::findErrorsInFiles(QVector<QString>& errors, \n    QSharedPointer<QList<QSharedPointer<IpxactFile> > > files, \n    QString const& context) const\n{\n    for (auto const& file : *files)\n    {\n        file->getVlnv().isValid(errors, context);\n\n        if (file->getName().isEmpty())\n        {\n            errors.append(QObject::tr(\"File name must not be empty for %1.\").arg(context));\n        }\n    }\n}\n"
  },
  {
    "path": "IPXACTmodels/Catalog/validators/CatalogValidator.h",
    "content": "//-----------------------------------------------------------------------------\n// File: CatalogValidator.h\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Esko Pekkarinen\n// Date: 01.02.2017\n//\n// Description:\n// Validator for ipxact:catalog.\n//-----------------------------------------------------------------------------\n\n#ifndef CATALOGVALIDATOR_H\n#define CATALOGVALIDATOR_H\n\n#include <IPXACTmodels/ipxactmodels_global.h>\n\n#include <QString>\n#include <QVector>\n#include <QList>\n#include <QSharedPointer>\n\nclass Catalog;\nclass IpxactFile;\n\n//-----------------------------------------------------------------------------\n//! Validator for ipxact:catalog.\n//-----------------------------------------------------------------------------\nclass IPXACTMODELS_EXPORT CatalogValidator\n{\npublic:\n\n\t/*!\n\t *  The constructor.\n\t *\n\t */\n    CatalogValidator();\n\n\t//! The destructor.\n\tvirtual ~CatalogValidator();\n\n    /*!\n     *  Validates the given Catalog.\n     *\n     *    @param [in] Catalog           The Catalog to validate.\n     *\n     *    @return True, if the catalog is valid IP-XACT, otherwise false.\n     */\n    virtual bool validate(QSharedPointer<Catalog> catalog) const;\n\n    /*!\n     *  Finds possible errors in a catalog and creates a list of them.\n     *\n     *    @param [in] errors      List of found errors.\n     *    @param [in] Catalog     The catalog whose errors to find.\n     */\n    virtual void findErrorsIn(QVector<QString>& errors, QSharedPointer<Catalog> catalog) const;\n\nprivate:\n\n    // Disable copying.\n    CatalogValidator(CatalogValidator const& rhs);\n    CatalogValidator& operator=(CatalogValidator const& rhs);\n\n    /*!\n     *  Validates the given set of ipxactFiles.\n     *\n     *    @param [in] files   The files to validate.\n     *\n     *    @return True, if all files are valid, otherwise false.\n     */\n    bool validateFiles(QSharedPointer<QList<QSharedPointer<IpxactFile> > > files) const;\n    \n    /*!\n     *  Validates the given ipxactFile.\n     *\n     *    @param [in] files   The file to validate.\n     *\n     *    @return True, if the file is valid, otherwise false.\n     */\n    bool validateFile(QSharedPointer<IpxactFile> file) const;\n\n    /*!\n     *  Finds possible errors in the given set of files and creates a list of them.\n     *\n     *    @param [in/out] errors  List of found errors.\n     *    @param [in] files       The files whose errors to find.\n     *    @param [in] context     Context for the files to  help locate errors.\n     */\n    void findErrorsInFiles(QVector<QString>& errors, \n        QSharedPointer<QList<QSharedPointer<IpxactFile> > > files,\n        QString const& context) const;\n\n};\n\n#endif // CATALOGVALIDATOR_H\n"
  },
  {
    "path": "IPXACTmodels/Component/AbstractionType.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: AbstractionType.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Esko Pekkarinen\r\n// Date: 20.10.2015\r\n//\r\n// Description:\r\n// Implementation of ipxact:abstractionType in bus interface.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"AbstractionType.h\"\r\n\r\n#include <IPXACTmodels/common/ConfigurableVLNVReference.h>\r\n\r\n#include <IPXACTmodels/Component/PortMap.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AbstractionType()\r\n//-----------------------------------------------------------------------------\r\nAbstractionType::AbstractionType():\r\nviewReferences_(new QStringList()),\r\nabstractionRef_(),\r\nportMaps_(new QList<QSharedPointer<PortMap> >())\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AbstractionType::~AbstractionType()\r\n//-----------------------------------------------------------------------------\r\nAbstractionType::~AbstractionType()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AbstractionType::AbstractionType()\r\n//-----------------------------------------------------------------------------\r\nAbstractionType::AbstractionType(AbstractionType const& other):\r\nviewReferences_(new QStringList()),\r\nabstractionRef_(),\r\nportMaps_(new QList<QSharedPointer<PortMap> >())\r\n{\r\n    if (other.abstractionRef_)\r\n    {\r\n        abstractionRef_ = QSharedPointer<ConfigurableVLNVReference>\r\n            (new ConfigurableVLNVReference(*other.abstractionRef_.data()));\r\n    }\r\n\r\n\tforeach (QSharedPointer<PortMap> portMap, *other.portMaps_)\r\n    {\r\n        if (portMap)\r\n        {\r\n            QSharedPointer<PortMap> copy = QSharedPointer<PortMap>(new PortMap(*portMap.data()));\r\n            portMaps_->append(copy);\r\n\t\t}\r\n\t}\r\n\r\n    copyViewReferences(other.viewReferences_);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AbstractionType::operator=()\r\n//-----------------------------------------------------------------------------\r\nAbstractionType& AbstractionType::operator=(AbstractionType const& other)\r\n{\r\n\tif (this != &other)\r\n\t{\r\n        abstractionRef_.clear();\r\n        if (other.abstractionRef_)\r\n        {\r\n            abstractionRef_ = QSharedPointer<ConfigurableVLNVReference>\r\n                (new ConfigurableVLNVReference(*other.abstractionRef_.data()));\r\n        }\r\n\r\n\t\tportMaps_->clear();\r\n\t\tforeach (QSharedPointer<PortMap> portMap, *other.portMaps_)\r\n\t\t{\r\n\t\t\tif (portMap)\r\n\t\t\t{\r\n\t\t\t\tQSharedPointer<PortMap> copy = QSharedPointer<PortMap>(new PortMap(*portMap.data()));\r\n\t\t\t\tportMaps_->append(copy);\r\n\t\t\t}\r\n\t\t}\r\n\r\n        viewReferences_->clear();\r\n        copyViewReferences(other.viewReferences_);\r\n\t}\r\n\r\n\treturn *this;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AbstractionType::copyViewReferences()\r\n//-----------------------------------------------------------------------------\r\nvoid AbstractionType::copyViewReferences(QSharedPointer<QStringList> newViewReferences)\r\n{\r\n    foreach (QString viewReference, *newViewReferences)\r\n    {\r\n        viewReferences_->append(viewReference);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AbstractionType::setViewReferences()\r\n//-----------------------------------------------------------------------------\r\nvoid AbstractionType::setViewReferences(QSharedPointer<QStringList> newViewReferences)\r\n{\r\n    viewReferences_ = newViewReferences;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AbstractionType::getViewReferences()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<QStringList> AbstractionType::getViewReferences() const\r\n{\r\n    return viewReferences_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AbstractionType::setAbstractionRef()\r\n//-----------------------------------------------------------------------------\r\nvoid AbstractionType::setAbstractionRef(QSharedPointer<ConfigurableVLNVReference> abstractionRef)\r\n{\r\n    abstractionRef_ = abstractionRef;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AbstractionType::getAbstractionRef()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<ConfigurableVLNVReference> AbstractionType::getAbstractionRef() const\r\n{\r\n    return abstractionRef_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AbstractionType::getPortMaps()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<QList<QSharedPointer<PortMap> > > AbstractionType::getPortMaps() const\r\n{\r\n    return portMaps_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AbstractionType::getPhysicalPortNames()\r\n//-----------------------------------------------------------------------------\r\nQStringList AbstractionType::getPhysicalPortNames() const\r\n{\r\n    QStringList portNames;\r\n\r\n    if (portMaps_)\r\n    {\r\n        foreach (QSharedPointer<PortMap> portMap, *portMaps_)\r\n        {\r\n            if (portMap->getPhysicalPort())\r\n            {\r\n                portNames.append(portMap->getPhysicalPort()->name_);\r\n            }\r\n        }\r\n    }\r\n\r\n    return portNames;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AbstractionType::getLogicalPortNames()\r\n//-----------------------------------------------------------------------------\r\nQStringList AbstractionType::getLogicalPortNames() const\r\n{\r\n    QStringList portNames;\r\n\r\n    if (portMaps_)\r\n    {\r\n        foreach (QSharedPointer<PortMap> portMap, *portMaps_)\r\n        {\r\n            if (portMap->getLogicalPort())\r\n            {\r\n                portNames.append(portMap->getLogicalPort()->name_);\r\n            }\r\n        }\r\n    }\r\n\r\n    return portNames;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AbstractionType::hasLogicalPort()\r\n//-----------------------------------------------------------------------------\r\nbool AbstractionType::hasLogicalPort(QString const& portName) const\r\n{\r\n    if (portMaps_)\r\n    {\r\n        foreach (QSharedPointer<PortMap> portMap, *portMaps_)\r\n        {\r\n            if (portMap->getLogicalPort() && portMap->getLogicalPort()->name_ == portName)\r\n            {\r\n                return true;\r\n            }\r\n        }\r\n    }\r\n\r\n    return false;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AbstractionType::hasPhysicalPort()\r\n//-----------------------------------------------------------------------------\r\nbool AbstractionType::hasPhysicalPort(QString const& portName) const\r\n{\r\n    if (portMaps_)\r\n    {\r\n        foreach (QSharedPointer<PortMap> portMap, *portMaps_)\r\n        {\r\n            if (portMap->getPhysicalPort() && portMap->getPhysicalPort()->name_ == portName)\r\n            {\r\n                return true;\r\n            }\r\n        }\r\n    }\r\n\r\n    return false;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AbstractionType::getMappedLogicalPortName()\r\n//-----------------------------------------------------------------------------\r\nQString AbstractionType::getMappedLogicalPortName(QString const& physicalPortName) const\r\n{\r\n    if (portMaps_)\r\n    {\r\n        foreach (QSharedPointer<PortMap> portMap, *portMaps_)\r\n        {\r\n            if (portMap->getPhysicalPort() && portMap->getLogicalPort() &&\r\n                portMap->getPhysicalPort()->name_.compare(physicalPortName) == 0)\r\n            {\r\n                return portMap->getLogicalPort()->name_;\r\n            }\r\n        }\r\n    }\r\n\r\n    return QString();\r\n}\r\n"
  },
  {
    "path": "IPXACTmodels/Component/AbstractionType.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: AbstractionType.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Esko Pekkarinen\r\n// Date: 20.10.2015\r\n//\r\n// Description:\r\n// Implementation of ipxact:abstractionType in bus interface.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef ABSTRACTION_TYPE_H\r\n#define ABSTRACTION_TYPE_H\r\n\r\n#include <IPXACTmodels/ipxactmodels_global.h>\r\n\r\n#include <QString>\r\n#include <QList>\r\n#include <QSharedPointer>\r\n\r\nclass ConfigurableVLNVReference;\r\nclass PortMap;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Implementation of ipxact:abstractionType in bus interface.\r\n//-----------------------------------------------------------------------------\r\nclass IPXACTMODELS_EXPORT AbstractionType\r\n{\r\npublic:\r\n    \r\n    /*!\r\n     *  Default constructor.\r\n     */\r\n    AbstractionType();\r\n\r\n    /*!\r\n     *  The destructor.\r\n     */\r\n    virtual ~AbstractionType();\r\n\r\n    /*!\r\n     *  Copy constructor.\r\n     */\r\n    AbstractionType(const AbstractionType &other);\r\n\r\n    /*!\r\n     *  Assignment operator.\r\n     */\r\n    AbstractionType &operator=(const AbstractionType &other);\r\n\r\n    /*!\r\n     *  Set the view references.\r\n     *\r\n     *    @param [in] newViewReferences   List containing the new view references.\r\n     */\r\n    void setViewReferences(QSharedPointer<QStringList> newViewReferences);\r\n\r\n    /*!\r\n     *  Get the view references.\r\n     *\r\n     *    @return List of the referenced views.\r\n     */\r\n    QSharedPointer<QStringList> getViewReferences() const;\r\n\r\n    /*!\r\n     *  Set the abstraction reference.\r\n     *\r\n     *    @param [in] abstractionRef  The referenced abstraction definition.\r\n     */\r\n    void setAbstractionRef(QSharedPointer<ConfigurableVLNVReference> abstractionRef);\r\n\r\n    /*!\r\n     *  Get the referenced abstraction definition.\r\n     *\r\n     *    @return The referenced abstraction definition.\r\n     */\r\n    QSharedPointer<ConfigurableVLNVReference> getAbstractionRef() const;\r\n\r\n    /*!\r\n     *  Get the port maps.\r\n     *\r\n     *    @return A list of port maps.\r\n     */\r\n    QSharedPointer<QList<QSharedPointer<PortMap> > > getPortMaps() const;\r\n\r\n    /*!\r\n     *  Get the names of the mapped physical ports.\r\n     *\r\n     *    @return A list containing the names of the mapped physical ports.\r\n     */\r\n    QStringList getPhysicalPortNames() const;\r\n\r\n    /*!\r\n     *  Get the names of the mapped logical ports.\r\n     *\r\n     *    @return A list containing the names of the mapped logical ports.\r\n     */\r\n    QStringList getLogicalPortNames() const;\r\n\r\n    /*!\r\n     *  Check if the selected logical port has been mapped.\r\n     *\r\n     *    @param [in] portName    Name of the selected logical port.\r\n     *\r\n     *    @return True, if the selected logical port has been mapped, false otherwise.\r\n     */\r\n    bool hasLogicalPort(QString const& portName) const;\r\n\r\n    /*!\r\n     *  Check if the selected physical port has been mapped.\r\n     *\r\n     *    @param [in] portName    Name of the selected physical port.\r\n     *\r\n     *    @return True, if the selected physical port has been mapped, false otherwise.\r\n     */\r\n    bool hasPhysicalPort(QString const& portName) const;\r\n\r\n    /*!\r\n     *  Get the name of the logical port that has been mapped to the selected physical port.\r\n     *\r\n     *    @param [in] physicalPortName    Name of the selected physical port.\r\n     *\r\n     *    @return The name of the logical port that has been mapped to the selected physical port.\r\n     */\r\n    QString getMappedLogicalPortName(QString const& physicalPortName) const;\r\n\r\nprivate:\r\n\r\n    /*!\r\n     *  Copy the selected view references.\r\n     *\r\n     *    @param [in] newViewReferences   The selected view references.\r\n     */\r\n    void copyViewReferences(QSharedPointer<QStringList> newViewReferences);\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! Specifies views where the abstraction type applies.\r\n    QSharedPointer<QStringList> viewReferences_;\r\n\r\n    //! Reference to an abstraction description for this abstractor instance.\r\n    QSharedPointer<ConfigurableVLNVReference> abstractionRef_;\r\n\r\n    //! Describes the mapping between the abstraction definition's logical ports and components physical ports.\r\n    QSharedPointer<QList<QSharedPointer<PortMap> > > portMaps_;\r\n};\r\n\r\n#endif // ABSTRACTION_TYPE_H\r\n"
  },
  {
    "path": "IPXACTmodels/Component/AccessPolicy.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: AccessPolicy.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Anton Hagqvist\n// Date: 8.8.2023\n//\n// Description:\n// Describes the ipxact:accessPolicy element.\n//-----------------------------------------------------------------------------\n\n#include \"AccessPolicy.h\"\n\n#include <IPXACTmodels/utilities/Copy.h>\n\n//-----------------------------------------------------------------------------\n// Function: AccessPolicy::AccessPolicy()\n//-----------------------------------------------------------------------------\nAccessPolicy::AccessPolicy():\n    Extendable()\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: AccessPolicy::AccessPolicy()\n//-----------------------------------------------------------------------------\nAccessPolicy::AccessPolicy(AccessPolicy const& other):\n    Extendable(other),\n    modeReferences_(new QList<QSharedPointer<ModeReference> >()),\n    access_(other.access_)\n{\n    Copy::copyList(other.modeReferences_, modeReferences_);\n}\n\n//-----------------------------------------------------------------------------\n// Function: AccessPolicy::operator=()\n//-----------------------------------------------------------------------------\nAccessPolicy& AccessPolicy::operator=(AccessPolicy const& other)\n{\n    if (this != &other)\n    {\n        Extendable::operator=(other);\n        access_ = other.access_;\n\n        modeReferences_->clear();\n        Copy::copyList(other.modeReferences_, modeReferences_);\n    }\n\n    return *this;\n}\n\n//-----------------------------------------------------------------------------\n// Function: AccessPolicy::getModeReferences()\n//-----------------------------------------------------------------------------\nQSharedPointer<QList<QSharedPointer<ModeReference> > > AccessPolicy::getModeReferences() const\n{\n    return modeReferences_;\n}\n\n//-----------------------------------------------------------------------------\n// Function: AccessPolicy::setModeReferences()\n//-----------------------------------------------------------------------------\nvoid AccessPolicy::setModeReferences(QSharedPointer<QList<QSharedPointer<ModeReference> > > modeRefs)\n{\n    modeReferences_ = modeRefs;\n}\n\n//-----------------------------------------------------------------------------\n// Function: AccessPolicy::getAccess()\n//-----------------------------------------------------------------------------\nAccessTypes::Access AccessPolicy::getAccess() const\n{\n    return access_;\n}\n\n//-----------------------------------------------------------------------------\n// Function: AccessPolicy::setAccess()\n//-----------------------------------------------------------------------------\nvoid AccessPolicy::setAccess(AccessTypes::Access newAccess)\n{\n    access_ = newAccess;\n}\n"
  },
  {
    "path": "IPXACTmodels/Component/AccessPolicy.h",
    "content": "//-----------------------------------------------------------------------------\n// File: AccessPolicy.h\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Anton Hagqvist\n// Date: 8.8.2023\n//\n// Description:\n// Describes the ipxact:accessPolicy element.\n//-----------------------------------------------------------------------------\n\n#ifndef ACCESSPOLICY_H\n#define ACCESSPOLICY_H\n\n#include \"ModeReference.h\"\n\n#include <IPXACTmodels/ipxactmodels_global.h>\n#include <IPXACTmodels/generaldeclarations.h>\n\n#include <IPXACTmodels/common/AccessTypes.h>\n#include <IPXACTmodels/common/Extendable.h>\n\nclass IPXACTMODELS_EXPORT AccessPolicy : public Extendable\n{\npublic:\n\n    AccessPolicy();\n\n    AccessPolicy(AccessPolicy const& other);\n\n    AccessPolicy& operator=(AccessPolicy const& other);\n    \n    virtual ~AccessPolicy() = default;\n\n    /*!\n     *\tGet the mode references of the field access policy.\n     *\t    \n     * \t    @return A pointer to the list of mode references.\n     */\n    QSharedPointer<QList<QSharedPointer<ModeReference> > > getModeReferences() const;\n    \n    /*!\n     *\tSet the mode references of the field access policy.\n     *  \n     *    @param [in] modeRefs     The mode references to set.\n     */\n    void setModeReferences(QSharedPointer<QList<QSharedPointer<ModeReference> > > modeRefs);\n\n    /*!\n     *\tGet the field access policy access value.\n     *  \n     * \t    @return The access value.\n     */\n    AccessTypes::Access getAccess() const;\n\n    /*!\n     *\tSet the access value.\n     *  \n     *    @param [in] newAccess     The new access value.\n     */\n    void setAccess(AccessTypes::Access newAccess);\n\nprivate:\n\n    //! The operating modes for which this field access policy is active.\n    QSharedPointer<QList<QSharedPointer<ModeReference> > > modeReferences_ =\n        QSharedPointer<QList<QSharedPointer<ModeReference> > >(new QList<QSharedPointer<ModeReference> >());\n\n    //! Contains the access type of the field.\n    AccessTypes::Access access_ = AccessTypes::ACCESS_COUNT;\n\n};\n\n#endif // ACCESSPOLICY_H\n"
  },
  {
    "path": "IPXACTmodels/Component/AccessPolicyReader.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: AccessPolicyReader.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Anton Hagqvist\n// Date: 8.8.2023\n//\n// Description:\n// Reader for ipxact:accessPolicy.\n//-----------------------------------------------------------------------------\n\n#include \"AccessPolicyReader.h\"\n\n#include <IPXACTmodels/common/CommonItemsReader.h>\n\n//-----------------------------------------------------------------------------\n// Function: AccessPolicyReader::createAccessPolicyFrom()\n//-----------------------------------------------------------------------------\nQSharedPointer<AccessPolicy> AccessPolicyReader::createAccessPolicyFrom(QDomNode const& accessPolicyNode)\n{\n    QSharedPointer<AccessPolicy> accessPolicy(new AccessPolicy());\n\n    Details::parseModeRefs(accessPolicyNode, accessPolicy->getModeReferences());\n\n    Details::parseAccess(accessPolicyNode, accessPolicy);\n\n    CommonItemsReader::parseVendorExtensions(accessPolicyNode, accessPolicy);\n\n    return accessPolicy;\n}\n\n//-----------------------------------------------------------------------------\n// Function: AccessPolicyReader::Details::parseModeRefs()\n//-----------------------------------------------------------------------------\nvoid AccessPolicyReader::Details::parseModeRefs(QDomNode const& rootNode, \n    QSharedPointer<QList<QSharedPointer<ModeReference> > > modeRefList)\n{\n    auto modeRefNodes = rootNode.childNodes();\n\n    for (int i = 0; i < modeRefNodes.size(); ++i)\n    {\n        if (auto const& modeRefNode = modeRefNodes.at(i);\n            modeRefNode.nodeName() == QStringLiteral(\"ipxact:modeRef\"))\n        {\n            QSharedPointer<ModeReference> newModeRef(new ModeReference());\n\n            newModeRef->setReference(modeRefNode.firstChild().nodeValue());\n            \n            auto const& priority = modeRefNode.attributes().namedItem(QStringLiteral(\"priority\")).nodeValue();\n            newModeRef->setPriority(priority.toUInt());\n\n            modeRefList->append(newModeRef);\n        }\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: AccessPolicyReader::Details::parseAccess()\n//-----------------------------------------------------------------------------\nvoid AccessPolicyReader::Details::parseAccess(QDomNode const& accessPolicyNode,\n    QSharedPointer<AccessPolicy> accessPolicy)\n{\n    auto accessElement = accessPolicyNode.firstChildElement(QStringLiteral(\"ipxact:access\"));\n    if (!accessElement.isNull())\n    {\n        auto accessString = accessElement.firstChild().nodeValue();\n        AccessTypes::Access access = AccessTypes::str2Access(accessString, AccessTypes::ACCESS_COUNT);\n        accessPolicy->setAccess(access);\n    }\n}\n"
  },
  {
    "path": "IPXACTmodels/Component/AccessPolicyReader.h",
    "content": "//-----------------------------------------------------------------------------\n// File: AccessPolicyReader.h\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Anton Hagqvist\n// Date: 8.8.2023\n//\n// Description:\n// Reader for ipxact:accessPolicy.\n//-----------------------------------------------------------------------------\n\n#ifndef ACCESSPOLICYREADER_H\n#define ACCESSPOLICYREADER_H\n\n#include \"AccessPolicy.h\"\n\n#include <IPXACTmodels/ipxactmodels_global.h>\n\n#include <QDomNode>\n\nnamespace AccessPolicyReader\n{\n\n    /*!\n     *\tCreate a field access policy from XML description.\n     *  \n     *    @param [in] accessPolicyNode     The XML description of the access policy.\n     *\t    \n     * \t    @return The created field access policy.\n     */\n    IPXACTMODELS_EXPORT QSharedPointer<AccessPolicy> createAccessPolicyFrom(QDomNode const& accessPolicyNode);\n\n    namespace Details\n    {\n        /*!\n         *\tRead mode references.\n         *  \n         *    @param [in] rootNode        The containing element.\n         *    @param [in/out] modeRefList     The mode reference list to read to.\n         */\n        void parseModeRefs(QDomNode const& rootNode, QSharedPointer<QList<QSharedPointer<ModeReference> > > modeRefList);\n\n        /*!\n         *\tParse field access policy access value.\n         *  \n         *    @param [in] accessPolicyNode     The XML description of the field access policy.\n         *    @param [in] accessPolicy         The created field access policy.\n         */\n        void parseAccess(QDomNode const& accessPolicyNode, QSharedPointer<AccessPolicy> accessPolicy);\n    }\n}\n\n#endif // FIELDACCESSPOLICYREADER_H"
  },
  {
    "path": "IPXACTmodels/Component/AccessPolicyWriter.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: AccessPolicyWriter.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Anton Hagqvist\n// Date: 8.8.2023\n//\n// Description:\n// Writer for ipxact:accessPolicy.\n//-----------------------------------------------------------------------------\n\n#include \"AccessPolicyWriter.h\"\n\n#include <IPXACTmodels/common/CommonItemsWriter.h>\n\n//-----------------------------------------------------------------------------\n// Function: AccessPolicyWriter::writeAccessPolicy()\n//-----------------------------------------------------------------------------\nvoid AccessPolicyWriter::writeAccessPolicy(QXmlStreamWriter& writer,\n    QSharedPointer<AccessPolicy> fieldAccessPolicy)\n{\n    writer.writeStartElement(QStringLiteral(\"ipxact:accessPolicy\"));\n\n    CommonItemsWriter::writeModeReferences(writer, fieldAccessPolicy->getModeReferences());\n\n    Details::writeAccess(writer, fieldAccessPolicy);\n\n    CommonItemsWriter::writeVendorExtensions(writer, fieldAccessPolicy);\n\n    writer.writeEndElement(); // ipxact:accessPolicy\n}\n\n//-----------------------------------------------------------------------------\n// Function: AccessPolicyWriter::Details::writeAccess()\n//-----------------------------------------------------------------------------\nvoid AccessPolicyWriter::Details::writeAccess(QXmlStreamWriter& writer, QSharedPointer<AccessPolicy> fieldAccessPolicy)\n{\n    if (fieldAccessPolicy->getAccess() != AccessTypes::ACCESS_COUNT)\n    {\n        QString access = AccessTypes::access2Str(fieldAccessPolicy->getAccess());\n        writer.writeTextElement(QStringLiteral(\"ipxact:access\"), access);\n    }\n}\n"
  },
  {
    "path": "IPXACTmodels/Component/AccessPolicyWriter.h",
    "content": "//-----------------------------------------------------------------------------\n// File: AccessPolicyWriter.h\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Anton Hagqvist\n// Date: 8.8.2023\n//\n// Description:\n// Writer for ipxact:accessPolicy.\n//-----------------------------------------------------------------------------\n\n#ifndef ACCESSPOLICYWRITER_H\n#define ACCESSPOLICYWRITER_H\n\n#include \"AccessPolicy.h\"\n\n#include <IPXACTmodels/ipxactmodels_global.h>\n\n#include <QXmlStreamWriter>\n\nnamespace AccessPolicyWriter\n{\n\n    /*!\n     *\tWrite a given access policy to XML.\n     *  \n     *    @param [in] writer           The XML writer to use.\n     *    @param [in] accessPolicy     The field access policy to write.\n     */\n    IPXACTMODELS_EXPORT void writeAccessPolicy(QXmlStreamWriter& writer, QSharedPointer<AccessPolicy> accessPolicy);\n\n    namespace Details\n    {\n        void writeAccess(QXmlStreamWriter& writer, QSharedPointer<AccessPolicy> accessPolicy);\n    }\n}\n\n#endif // ACCESSPOLICYWRITER_H\n"
  },
  {
    "path": "IPXACTmodels/Component/AddressBlock.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: AddressBlock.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 30.09.2015\r\n//\r\n// Description:\r\n// Describes the ipxact:addressBlock element.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"AddressBlock.h\"\r\n#include \"RegisterBase.h\"\r\n#include \"Register.h\"\r\n#include \"MemoryArray.h\"\r\n#include \"AccessPolicy.h\"\r\n\r\n#include <IPXACTmodels/utilities/Copy.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressBlock::AddressBlock()\r\n//-----------------------------------------------------------------------------\r\nAddressBlock::AddressBlock(QString const& name /* = QString() */, QString const& baseAddress /* = QString() */):\r\nMemoryBlockBase(name, baseAddress),\r\ntypeIdentifier_(),\r\nrange_(),\r\nrangeAttributes_(),\r\nwidth_(),\r\nwidthAttributes_(),\r\nusage_(General::USAGE_COUNT),\r\nvolatile_(),\r\naccess_(AccessTypes::ACCESS_COUNT)\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressBlock::AddressBlock()\r\n//-----------------------------------------------------------------------------\r\nAddressBlock::AddressBlock(const AddressBlock &other):\r\nMemoryBlockBase(other),\r\nmisalignmentAllowed_(other.misalignmentAllowed_),\r\naddressBlockDefinitionRef_(other.addressBlockDefinitionRef_),\r\ntypeDefinitionsRef_(other.typeDefinitionsRef_),\r\ntypeIdentifier_(other.typeIdentifier_),\r\nrange_(other.range_),\r\nrangeAttributes_(other.rangeAttributes_),\r\nwidth_(other.width_),\r\nwidthAttributes_(other.widthAttributes_),\r\nusage_(other.usage_),\r\nvolatile_(other.volatile_),\r\naccess_(other.access_)\r\n{\r\n    copyRegisterData(other);\r\n    Copy::copyList(other.accessPolicies_, accessPolicies_);\r\n\r\n    if (other.memoryArray_)\r\n    {\r\n        memoryArray_ = QSharedPointer<MemoryArray>(new MemoryArray(*other.memoryArray_));\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressBlock::operator=()\r\n//-----------------------------------------------------------------------------\r\nAddressBlock& AddressBlock::operator=( const AddressBlock& other )\r\n{\r\n    if (this != &other)\r\n    {\r\n        MemoryBlockBase::operator=(other);\r\n        misalignmentAllowed_ = other.misalignmentAllowed_;\r\n        addressBlockDefinitionRef_ = other.addressBlockDefinitionRef_;\r\n        typeDefinitionsRef_ = other.typeDefinitionsRef_;\r\n        typeIdentifier_ = other.typeIdentifier_;\r\n        range_ = other.range_;\r\n        rangeAttributes_ = other.rangeAttributes_;\r\n        width_ = other.width_;\r\n        widthAttributes_ = other.widthAttributes_;\r\n        usage_ = other.usage_;\r\n        volatile_ = other.volatile_;\r\n        access_ = other.access_;\r\n\r\n        registerData_->clear();\r\n        copyRegisterData(other);\r\n\r\n        accessPolicies_->clear();\r\n        Copy::copyList(other.accessPolicies_, accessPolicies_);\r\n\r\n        memoryArray_.clear();\r\n        if (other.memoryArray_)\r\n        {\r\n            memoryArray_ = QSharedPointer<MemoryArray>(new MemoryArray(*other.memoryArray_));\r\n        }\r\n    }\r\n\r\n    return *this;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressBlock::~AddressBlock()\r\n//-----------------------------------------------------------------------------\r\nAddressBlock::~AddressBlock()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressBlock::clone()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<MemoryBlockBase> AddressBlock::clone() const\r\n{\r\n    return QSharedPointer<MemoryBlockBase>(new AddressBlock(*this));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressBlock::getTypeIdentifier()\r\n//-----------------------------------------------------------------------------\r\nQString AddressBlock::getTypeIdentifier() const\r\n{\r\n    return typeIdentifier_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressBlock::setTypeIdentifier()\r\n//-----------------------------------------------------------------------------\r\nvoid AddressBlock::setTypeIdentifier(QString const& newTypeIdentifier)\r\n{\r\n    typeIdentifier_ = newTypeIdentifier;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressBlock::getRange()\r\n//-----------------------------------------------------------------------------\r\nQString AddressBlock::getRange() const\r\n{\r\n    return range_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressBlock::setRange()\r\n//-----------------------------------------------------------------------------\r\nvoid AddressBlock::setRange(QString const& newRange)\r\n{\r\n    range_ = newRange;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressBlock::getRangeAttributes()\r\n//-----------------------------------------------------------------------------\r\nQMap<QString, QString> AddressBlock::getRangeAttributes() const\r\n{\r\n    return rangeAttributes_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressBlock::setRangeAttributes()\r\n//-----------------------------------------------------------------------------\r\nvoid AddressBlock::setRangeAttributes(QMap<QString, QString> const& newRangeAttributes)\r\n{\r\n    rangeAttributes_ = newRangeAttributes;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressBlock::getWidth()\r\n//-----------------------------------------------------------------------------\r\nQString AddressBlock::getWidth() const\r\n{\r\n    return width_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressBlock::setWidth()\r\n//-----------------------------------------------------------------------------\r\nvoid AddressBlock::setWidth(QString const& newWidth)\r\n{\r\n    width_ = newWidth;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressBlock::getWidthAttributes()\r\n//-----------------------------------------------------------------------------\r\nQMap<QString, QString> AddressBlock::getWidthAttributes() const\r\n{\r\n    return widthAttributes_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressBlock::setWidthAttributes()\r\n//-----------------------------------------------------------------------------\r\nvoid AddressBlock::setWidthAttributes(QMap<QString, QString> const& newWidthAttributes)\r\n{\r\n    widthAttributes_ = newWidthAttributes;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressBlock::getUsage()\r\n//-----------------------------------------------------------------------------\r\nGeneral::Usage AddressBlock::getUsage() const\r\n{\r\n    return usage_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressBlock::setUsage()\r\n//-----------------------------------------------------------------------------\r\nvoid AddressBlock::setUsage(General::Usage newUsage)\r\n{\r\n    usage_ = newUsage;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressBlock::getVolatile()\r\n//-----------------------------------------------------------------------------\r\nQString AddressBlock::getVolatile() const\r\n{\r\n    return volatile_.toString();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressBlock::setVolatile()\r\n//-----------------------------------------------------------------------------\r\nvoid AddressBlock::setVolatile(bool newVolatileValue)\r\n{\r\n    volatile_.setValue(newVolatileValue);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressBlock::clearVolatile()\r\n//-----------------------------------------------------------------------------\r\nvoid AddressBlock::clearVolatile()\r\n{\r\n    volatile_.setUnspecified();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressBlock::getAccess()\r\n//-----------------------------------------------------------------------------\r\nAccessTypes::Access AddressBlock::getAccess() const\r\n{\r\n    return access_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressBlock::setAccess()\r\n//-----------------------------------------------------------------------------\r\nvoid AddressBlock::setAccess(AccessTypes::Access newAccess)\r\n{\r\n    access_ = newAccess;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressBlock::getRegisterData()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<QList<QSharedPointer<RegisterBase> > > AddressBlock::getRegisterData() const\r\n{\r\n    return registerData_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressBlock::setRegisterData()\r\n//-----------------------------------------------------------------------------\r\nvoid AddressBlock::setRegisterData(QSharedPointer<QList<QSharedPointer<RegisterBase> > > newRegisterData)\r\n{\r\n    registerData_ = newRegisterData;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: addressblock::getAllRegisterOffsets()\r\n//-----------------------------------------------------------------------------\r\nQStringList AddressBlock::getAllRegisterOffsets() const\r\n{\r\n    QStringList registerOffsets;\r\n\r\n    foreach (QSharedPointer<RegisterBase> registerBase, *registerData_)\r\n    {\r\n      registerOffsets.append(registerBase->getAddressOffset());\r\n    }\r\n\r\n    return registerOffsets;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressBlock::getMemoryArray()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<MemoryArray> AddressBlock::getMemoryArray() const\r\n{\r\n    return memoryArray_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressBlock::setMemoryArray()\r\n//-----------------------------------------------------------------------------\r\nvoid AddressBlock::setMemoryArray(QSharedPointer<MemoryArray> newMemoryArray)\r\n{\r\n    memoryArray_ = newMemoryArray;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressBlock::getMisalignmentAllowed()\r\n//-----------------------------------------------------------------------------\r\nQString AddressBlock::getMisalignmentAllowed() const\r\n{\r\n    return misalignmentAllowed_.toString();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressBlock::setMisalignmentAllowed()\r\n//-----------------------------------------------------------------------------\r\nvoid AddressBlock::setMisalignmentAllowed(bool newMisalignmentAllowed)\r\n{\r\n    misalignmentAllowed_.setValue(newMisalignmentAllowed);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressBlock::getAddressBlockDefinitionRef()\r\n//-----------------------------------------------------------------------------\r\nQString AddressBlock::getAddressBlockDefinitionRef() const\r\n{\r\n    return addressBlockDefinitionRef_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressBlock::setAddressBlockDefinitionRef()\r\n//-----------------------------------------------------------------------------\r\nvoid AddressBlock::setAddressBlockDefinitionRef(QString const& newAddressBlockDefinitionRef)\r\n{\r\n    addressBlockDefinitionRef_ = newAddressBlockDefinitionRef;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressBlock::getTypeDefinitionsRef()\r\n//-----------------------------------------------------------------------------\r\nQString AddressBlock::getTypeDefinitionsRef() const\r\n{\r\n    return typeDefinitionsRef_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressBlock::setTypeDefinitionsRef()\r\n//-----------------------------------------------------------------------------\r\nvoid AddressBlock::setTypeDefinitionsRef(QString const& newTypeDefinitionsRef)\r\n{\r\n    typeDefinitionsRef_ = newTypeDefinitionsRef;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressBlock::getAccessPolicies()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<QList<QSharedPointer<AccessPolicy> > > AddressBlock::getAccessPolicies() const\r\n{\r\n    return accessPolicies_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressBlock::setAccessPolicies()\r\n//-----------------------------------------------------------------------------\r\nvoid AddressBlock::setAccessPolicies(QSharedPointer<QList<QSharedPointer<AccessPolicy> > > newAccessPolicies)\r\n{\r\n    accessPolicies_ = newAccessPolicies;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressBlock::copyRegisterData()\r\n//-----------------------------------------------------------------------------\r\nvoid AddressBlock::copyRegisterData(const AddressBlock& other)\r\n{\r\n    for (auto registerBase : *other.registerData_)\r\n    {\r\n        if (registerBase)\r\n        {\r\n            QSharedPointer<RegisterBase> copy = registerBase->clone();\r\n            registerData_->append(copy);\r\n        }\r\n    }\r\n}\r\n"
  },
  {
    "path": "IPXACTmodels/Component/AddressBlock.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: AddressBlock.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 29.09.2015\r\n//\r\n// Description:\r\n// Describes the ipxact:addressBlock element.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef ADDRESSBLOCK_H\r\n#define ADDRESSBLOCK_H\r\n\r\n#include \"MemoryBlockBase.h\"\r\n\r\n#include <IPXACTmodels/common/BooleanValue.h>\r\n#include <IPXACTmodels/ipxactmodels_global.h>\r\n#include <IPXACTmodels/generaldeclarations.h>\r\n#include <IPXACTmodels/common/AccessTypes.h>\r\n\r\n#include <QString>\r\n#include <QMap>\r\n#include <QSharedPointer>\r\n\r\nclass RegisterBase;\r\nclass AccessPolicy;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Describes the ipxact:addressBlock element.\r\n//-----------------------------------------------------------------------------\r\nclass IPXACTMODELS_EXPORT AddressBlock: public MemoryBlockBase\r\n{\r\n\r\npublic:\r\n\r\n    /*!\r\n     *  The constructor.\r\n     *\r\n     *    @param [in] name            Name of the address block.\r\n     *    @param [in] baseAddress     The base address.\r\n     */\r\n    AddressBlock(QString const& name = QString(), QString const& baseAddress = QString());\r\n\t\r\n    //! The copy constructor.\r\n    AddressBlock(const AddressBlock &other);\r\n\r\n\t//! The assignment operator.\r\n\tAddressBlock &operator=(const AddressBlock &other);\r\n\r\n\t//! The destructor.\r\n\t~AddressBlock();\r\n\r\n    /*!\r\n     *  Clone this address block and return pointer to the copy.\r\n     *\r\n     *    @return Pointer to the cloned address block.\r\n     */\r\n    virtual QSharedPointer<MemoryBlockBase> clone() const;\r\n\r\n    /*!\r\n     *  Get the type identifier.\r\n     *\r\n     *    @return Address block type identifier.\r\n     */\r\n    QString getTypeIdentifier() const;\r\n\r\n    /*!\r\n     *  Set the type identifier.\r\n     *\r\n     *    @param [in] newTypeIdentifier   The new type identifier.\r\n     */\r\n    void setTypeIdentifier(QString const& newTypeIdentifier);\r\n\r\n\t/*!\r\n     *  Get the address range of the address block.\r\n\t *\r\n\t *    @return The address range.\r\n\t */\r\n\tQString getRange() const;\r\n\r\n\t/*!\r\n     *  Set the address range of the address block.\r\n\t *\r\n\t *    @param [in] newRange    The new range value.\r\n\t */\r\n\tvoid setRange(QString const& newRange);\r\n\r\n\t/*!\r\n     *  Get the attributes linked to range element.\r\n\t *\r\n\t *    @return The range attributes.\r\n\t */\r\n    QMap<QString, QString> getRangeAttributes() const;\r\n    \r\n\t/*!\r\n     *  Set the attributes linked to range element.\r\n\t *\r\n\t *    @param [in] newRangeAttributes      The new range attributes.\r\n\t */\r\n    void setRangeAttributes(QMap<QString, QString> const& newRangeAttributes);\r\n\r\n\t/*!\r\n     *  Get the bit width of a row in the address block.\r\n\t *\r\n\t *    @return The width of the address block.\r\n\t */\r\n    QString getWidth() const;\r\n\r\n\t/*!\r\n     *  Set the bit width of a row in the address block.\r\n\t *\r\n\t *    @param [in] newWidth    The new width.\r\n\t */\r\n    void setWidth(QString const& newWidth);\r\n\r\n\t/*!\r\n     *  Get the attributes linked to the width element.\r\n\t *\r\n\t *      return The attributes of the width element.\r\n\t */\r\n    QMap<QString, QString> getWidthAttributes() const;\r\n\r\n\t/*!\r\n     *  Set the attributes linked to the width element.\r\n\t *\r\n\t *    @param [in] newWidthAttributes  The new attributes for the width element.\r\n\t */\r\n    void setWidthAttributes(QMap<QString, QString> const& newWidthAttributes);\r\n\r\n\t/*!\r\n     *  Get the type of usage for the address block.\r\n\t *\r\n\t *    @return Usage.\r\n\t */\r\n\tGeneral::Usage getUsage() const;\r\n\r\n\t/*!\r\n     *  Set the type of usage for the address block.\r\n\t *\r\n\t *    @param [in] newUsage    The new usage type.\r\n\t */\r\n\tvoid setUsage(General::Usage newUsage);\r\n\r\n\t/*!\r\n     *  Get the volatile information.\r\n\t *\r\n\t *      return Volatile information. Empty string means unspecified volatile state.\r\n\t */\r\n    QString getVolatile() const;\r\n\r\n\t/*!\r\n     *  Set the volatile setting.\r\n\t *\r\n\t *    @param [in] newVolatileSetting  True for volatile address block, false otherwise.\r\n\t */\r\n    void setVolatile(bool newVolatileValue);\r\n\r\n    /*!\r\n     *  Set the volatile value to unspecified.\r\n     */\r\n    void clearVolatile();\r\n\r\n\t/*!\r\n     *  Get the access information.\r\n\t *\r\n\t *    @return Accessibility of the address block data.\r\n\t */\r\n    AccessTypes::Access getAccess() const;\r\n\r\n\t/*!\r\n     *  Set the accessibility of the address block.\r\n\t *\r\n\t *    @param [in] newAccess   The new access type of the address block.\r\n\t */\r\n    void setAccess(AccessTypes::Access newAccess);\r\n\r\n\t/*!\r\n     *  Get the list containing the register elements of address block.\r\n\t *\r\n\t *    @return Pointer to a list containing the register elements.\r\n \t */\r\n    QSharedPointer<QList<QSharedPointer<RegisterBase> > > getRegisterData() const;\r\n\r\n    /*!\r\n     *  Set the register elements.\r\n     *\r\n     *    @param [in] newRegisterData     The new register elements.\r\n     */\r\n    void setRegisterData(QSharedPointer<QList<QSharedPointer<RegisterBase> > > newRegisterData);\r\n    \r\n    /*!\r\n     *  Get offsets from each of the address block's registers.\r\n     *\r\n     *    @return     A list of offsets from all the registers.\r\n     */\r\n    QStringList getAllRegisterOffsets() const;\r\n\r\n    /*!\r\n     *\tGet the address block memory array.\r\n     *  \r\n     * \t    @return Pointer to the memory array of the address block.\r\n     */\r\n    QSharedPointer<MemoryArray> getMemoryArray() const;\r\n\r\n    /*!\r\n     *\tSet the memory array of the address block.\r\n     *  \r\n     *    @param [in] newMemoryArray     The memory array to set.\r\n     */\r\n    void setMemoryArray(QSharedPointer<MemoryArray> newMemoryArray);\r\n\r\n    /*!\r\n     *\tGet the misalignment allowed attribute.\r\n     *\t    \r\n     * \t    @return The misalignment attribute.\r\n     */\r\n    QString getMisalignmentAllowed() const;\r\n\r\n    /*!\r\n     *\tSet the misalignment allowed attribute.\r\n     *  \r\n     *    @param [in] newMisalignmentAllowed     New misalignment allowed value.\r\n     */\r\n    void setMisalignmentAllowed(bool newMisalignmentAllowed);\r\n\r\n    /*!\r\n     *\tGet the address block definition reference.\r\n     *  \r\n     * \t    @return The address block definition reference.\r\n     */\r\n    QString getAddressBlockDefinitionRef() const;\r\n\r\n    /*!\r\n     *\tSet the address block definition reference.\r\n     *  \r\n     *    @param [in] newAddressBlockDefinitionRef     The definition reference to set.\r\n     */\r\n    void setAddressBlockDefinitionRef(QString const& newAddressBlockDefinitionRef);\r\n\r\n    /*!\r\n     *\tGet the type definitions reference.\r\n     *  \r\n     * \t    @return The referenced type definitions.\r\n     */\r\n    QString getTypeDefinitionsRef() const;\r\n\r\n    /*!\r\n     *\tSet the type definitions reference.\r\n     *  \r\n     *    @param [in] newTypeDefinitionsRef     The type definitions reference to set.\r\n     */\r\n    void setTypeDefinitionsRef(QString const& newTypeDefinitionsRef);\r\n\r\n    /*!\r\n     *\tGet the access policies of the address block.\r\n     *\t    \r\n     * \t    @return Pointer to a list of access policies contained within the address block.\r\n     */\r\n    QSharedPointer<QList<QSharedPointer<AccessPolicy> > > getAccessPolicies() const;\r\n\r\n    /*!\r\n     *\tSet the access policies of the address block.\r\n     *  \r\n     *    @param [in] newAccessPolicies     The access policies to set.\r\n     */\r\n    void setAccessPolicies(QSharedPointer<QList<QSharedPointer<AccessPolicy> > > newAccessPolicies);\r\n\r\nprivate:\r\n\r\n    /*!\r\n     *  Copy the register elements.\r\n     *\r\n     *    @param [in] other   Address block being copied.\r\n     */\r\n    void copyRegisterData(const AddressBlock& other);\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! The attribute allowing or disallowing register address offset misalignment in the address block.\r\n    BooleanValue misalignmentAllowed_;\r\n\r\n    //! Contains the memory array of the address block.\r\n    QSharedPointer<MemoryArray> memoryArray_;\r\n\r\n    //! The address block definition reference.\r\n    QString addressBlockDefinitionRef_;\r\n\r\n    //! The type definitions reference.\r\n    QString typeDefinitionsRef_;\r\n\r\n    //! Indicates the type of the address block.\r\n    QString typeIdentifier_;\r\n\r\n\t//! Range of an address block.\r\n\tQString range_;\r\n\r\n\t//! The attributes linked to the range element in IP-Xact document.\r\n\tQMap<QString, QString> rangeAttributes_;\r\n\r\n\t//! The bit width of a row in the address block.\r\n    QString width_;\r\n\r\n\t//! The attributes linked to the range element in IP-Xact document.\r\n\tQMap<QString, QString> widthAttributes_;\r\n\r\n    //! Specified the type of usage.\r\n    General::Usage usage_;\r\n\r\n    //! Indicates the volatility of the address block.\r\n    BooleanValue volatile_;\r\n\r\n    //! Specifies the accessibility of the address block data.\r\n    AccessTypes::Access access_;\r\n\r\n    //! The access poclicies of the address block.\r\n    QSharedPointer<QList<QSharedPointer<AccessPolicy> > > accessPolicies_ = \r\n        QSharedPointer<QList<QSharedPointer<AccessPolicy> > >(new QList<QSharedPointer<AccessPolicy> >());\r\n\r\n\t//! Contains information about the grouping of bits into registers and fields.\r\n    QSharedPointer<QList<QSharedPointer<RegisterBase> > > registerData_ = \r\n        QSharedPointer<QList<QSharedPointer<RegisterBase> > >(new QList<QSharedPointer<RegisterBase> > ());\r\n};\r\n\r\nQ_DECLARE_METATYPE(QSharedPointer<AddressBlock>);\r\n\r\n#endif // ADDRESSBLOCK_H\r\n"
  },
  {
    "path": "IPXACTmodels/Component/AddressBlockReader.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: AddressBlockReader.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 30.09.2015\r\n//\r\n// Description:\r\n// Reader class for ipxact:addressBlock element.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"AddressBlockReader.h\"\r\n#include \"AddressBlock.h\"\r\n\r\n#include \"Register.h\"\r\n#include \"RegisterFile.h\"\r\n\r\n#include \"MemoryArrayReader.h\"\r\n#include \"AccessPolicyReader.h\"\r\n\r\n#include <IPXACTmodels/common/NameGroupReader.h>\r\n#include <IPXACTmodels/Component/RegisterReader.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressBlockReader::createAddressBlockFrom()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<AddressBlock> AddressBlockReader::createAddressBlockFrom(QDomNode const& addressBlockNode, Document::Revision docRevision)\r\n{\r\n    QSharedPointer<AddressBlock> newAddressBlock(new AddressBlock());\r\n\r\n    MemoryBlockBaseReader::parseNameGroup(addressBlockNode, newAddressBlock);\r\n    \r\n    if (docRevision == Document::Revision::Std14)\r\n    {\r\n        MemoryBlockBaseReader::parsePresence(addressBlockNode, newAddressBlock);\r\n        \r\n        Details::parseAccess(addressBlockNode, newAddressBlock);\r\n    }\r\n    else if (docRevision == Document::Revision::Std22)\r\n    {\r\n        Details::parseMisalignmentAllowed(addressBlockNode, newAddressBlock);\r\n\r\n        Details::parseMemoryArray(addressBlockNode, newAddressBlock);\r\n\r\n        Details::parseAddressBlockDefinitionRef(addressBlockNode, newAddressBlock);\r\n\r\n        Details::parseAccessPolicies(addressBlockNode, newAddressBlock);\r\n    }\r\n\r\n    MemoryBlockBaseReader::parseBaseAddress(addressBlockNode, newAddressBlock);\r\n\r\n    Details::parseTypeIdentifier(addressBlockNode, newAddressBlock);\r\n\r\n    Details::parseRange(addressBlockNode, newAddressBlock);\r\n\r\n    Details::parseWidth(addressBlockNode, newAddressBlock);\r\n\r\n    Details::parseUsage(addressBlockNode, newAddressBlock);\r\n\r\n    Details::parseVolatile(addressBlockNode, newAddressBlock);\r\n\r\n    MemoryBlockBaseReader::parseParameters(addressBlockNode, newAddressBlock, docRevision);\r\n\r\n    Details::parseRegisterData(addressBlockNode, newAddressBlock, docRevision);\r\n\r\n    CommonItemsReader::parseVendorExtensions(addressBlockNode, newAddressBlock);\r\n\r\n    return newAddressBlock;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressBlockReader::Details::parseTypeIdentifier()\r\n//-----------------------------------------------------------------------------\r\nvoid AddressBlockReader::Details::parseTypeIdentifier(QDomNode const& addressBlockNode,\r\n    QSharedPointer<AddressBlock> newAddressBlock)\r\n{\r\n    QDomElement typeIdentifierElement = addressBlockNode.firstChildElement(QStringLiteral(\"ipxact:typeIdentifier\"));\r\n    if (!typeIdentifierElement.isNull())\r\n    {\r\n        QString typeIdentifier = typeIdentifierElement.firstChild().nodeValue();\r\n        newAddressBlock->setTypeIdentifier(typeIdentifier);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressBlockReader::Details::parseRange()\r\n//-----------------------------------------------------------------------------\r\nvoid AddressBlockReader::Details::parseRange(QDomNode const& addressBlockNode, QSharedPointer<AddressBlock> newAddressBlock)\r\n   \r\n{\r\n    QString range = addressBlockNode.firstChildElement(QStringLiteral(\"ipxact:range\")).firstChild().nodeValue();\r\n    newAddressBlock->setRange(range);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressBlockReader::Details::parseWidth()\r\n//-----------------------------------------------------------------------------\r\nvoid AddressBlockReader::Details::parseWidth(QDomNode const& addressBlockNode, QSharedPointer<AddressBlock> newAddressBlock)\r\n   \r\n{\r\n    QString width = addressBlockNode.firstChildElement(QStringLiteral(\"ipxact:width\")).firstChild().nodeValue();\r\n    newAddressBlock->setWidth(width);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressBlockReader::Details::parseUsage()\r\n//-----------------------------------------------------------------------------\r\nvoid AddressBlockReader::Details::parseUsage(QDomNode const& addressBlockNode, QSharedPointer<AddressBlock> newAddressBlock)\r\n   \r\n{\r\n    QDomElement usageElement = addressBlockNode.firstChildElement(QStringLiteral(\"ipxact:usage\"));\r\n    if (!usageElement.isNull())\r\n    {\r\n        QString usageString = usageElement.firstChild().nodeValue();\r\n        General::Usage usage = General::str2Usage(usageString, General::USAGE_COUNT);\r\n        newAddressBlock->setUsage(usage);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressBlockReader::Details::parseVolatile()\r\n//-----------------------------------------------------------------------------\r\nvoid AddressBlockReader::Details::parseVolatile(QDomNode const& addressBlockNode,\r\n    QSharedPointer<AddressBlock> newAddressBlock)\r\n{\r\n    QDomElement volatileElement = addressBlockNode.firstChildElement(QStringLiteral(\"ipxact:volatile\"));\r\n    if (!volatileElement.isNull())\r\n    {\r\n        QString volatileString = volatileElement.firstChild().nodeValue();\r\n        if (volatileString == QLatin1String(\"true\"))\r\n        {\r\n            newAddressBlock->setVolatile(true);\r\n        }\r\n        else if (volatileString == QLatin1String(\"false\"))\r\n        {\r\n            newAddressBlock->setVolatile(false);\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressBlockReader::Details::parseAccess()\r\n//-----------------------------------------------------------------------------\r\nvoid AddressBlockReader::Details::parseAccess(QDomNode const& addressBlockNode,\r\n    QSharedPointer<AddressBlock> newAddressBlock)\r\n{\r\n    QDomElement accessElement = addressBlockNode.firstChildElement(QStringLiteral(\"ipxact:access\"));\r\n    if (!accessElement.isNull())\r\n    {\r\n        QString accessString = accessElement.firstChild().nodeValue();\r\n        AccessTypes::Access access = AccessTypes::str2Access(accessString, AccessTypes::ACCESS_COUNT);\r\n        newAddressBlock->setAccess(access);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressBlockReader::Details::parseRegisterData()\r\n//-----------------------------------------------------------------------------\r\nvoid AddressBlockReader::Details::parseRegisterData(QDomNode const& addressBlockNode,\r\n    QSharedPointer<AddressBlock> newAddressBlock,\r\n    Document::Revision docRevision)\r\n{\r\n    QDomNodeList childNodeList = addressBlockNode.childNodes();\r\n\r\n    for (int i = 0; i < childNodeList.count(); ++i)\r\n    {\r\n        QDomNode currentNode = childNodeList.at(i);\r\n        if (currentNode.nodeName() == QStringLiteral(\"ipxact:register\"))\r\n        {\r\n            QSharedPointer<Register> newRegister = RegisterReader::createRegisterfrom(currentNode, docRevision);\r\n            newAddressBlock->getRegisterData()->append(newRegister);\r\n        }\r\n        else if (childNodeList.at(i).nodeName() == QStringLiteral(\"ipxact:registerFile\"))\r\n        {\r\n            QSharedPointer<RegisterFile> newFile = RegisterReader::createRegisterFileFrom(currentNode, docRevision);\r\n            newAddressBlock->getRegisterData()->append(newFile);\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressBlockReader::Details::parseMemoryArray()\r\n//-----------------------------------------------------------------------------\r\nvoid AddressBlockReader::Details::parseMemoryArray(QDomNode const& addressBlockNode, QSharedPointer<AddressBlock> newAddressBlock)\r\n{\r\n    auto memArrayElement = addressBlockNode.firstChildElement(QStringLiteral(\"ipxact:array\"));\r\n\r\n    if (!memArrayElement.isNull())\r\n    {\r\n        auto newMemoryArray = MemoryArrayReader::createMemoryArrayFrom(memArrayElement, Document::Revision::Std22, false);\r\n\r\n        newAddressBlock->setMemoryArray(newMemoryArray);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressBlockReader::Details::parseMisalignmentAllowed()\r\n//-----------------------------------------------------------------------------\r\nvoid AddressBlockReader::Details::parseMisalignmentAllowed(QDomNode const& addressBlockNode, QSharedPointer<AddressBlock> newAddressBlock)\r\n{\r\n    auto attributes = CommonItemsReader::parseAttributes(addressBlockNode);\r\n\r\n    auto misalignmentAllowedStr = attributes.value(QStringLiteral(\"misalignmentAllowed\"), QString());\r\n\r\n    newAddressBlock->setMisalignmentAllowed(General::str2Bool(misalignmentAllowedStr, true));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressBlockReader::Details::parseAddressBlockDefinitionRef()\r\n//-----------------------------------------------------------------------------\r\nvoid AddressBlockReader::Details::parseAddressBlockDefinitionRef(QDomNode const& addressBlockNode, QSharedPointer<AddressBlock> newAddressBlock)\r\n{\r\n    auto definitionRefElement = addressBlockNode.firstChildElement(QStringLiteral(\"ipxact:addressBlockDefinitionRef\"));\r\n\r\n    if (!definitionRefElement.isNull())\r\n    {\r\n        QString definitionRef = definitionRefElement.firstChild().nodeValue();\r\n        QString typeDefinitionsRef = definitionRefElement.attribute(QStringLiteral(\"typeDefinitions\"), QString());\r\n\r\n        newAddressBlock->setAddressBlockDefinitionRef(definitionRef);\r\n        newAddressBlock->setTypeDefinitionsRef(typeDefinitionsRef);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressBlockReader::Details::parseAccessPolicies()\r\n//-----------------------------------------------------------------------------\r\nvoid AddressBlockReader::Details::parseAccessPolicies(QDomNode const& addressBlockNode, QSharedPointer<AddressBlock> newAddressBlock)\r\n{\r\n    auto accessPoliciesElement = addressBlockNode.firstChildElement(QStringLiteral(\"ipxact:accessPolicies\"));\r\n\r\n    if (accessPoliciesElement.isNull())\r\n    {\r\n        return;\r\n    }\r\n\r\n    auto accessPolicies = accessPoliciesElement.childNodes();\r\n\r\n    for (int i = 0; i < accessPolicies.size(); ++i)\r\n    {\r\n        if (accessPolicies.at(i).nodeName() == QStringLiteral(\"ipxact:accessPolicy\"))\r\n        {\r\n            auto newAccessPolicy = AccessPolicyReader::createAccessPolicyFrom(accessPolicies.at(i));\r\n\r\n            newAddressBlock->getAccessPolicies()->append(newAccessPolicy);\r\n        }\r\n    }\r\n}\r\n"
  },
  {
    "path": "IPXACTmodels/Component/AddressBlockReader.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: AddressBlockReader.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 30.09.2015\r\n//\r\n// Description:\r\n// Reader for ipxact:addressBlock element.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef ADDRESSBLOCKREADER_H\r\n#define ADDRESSBLOCKREADER_H\r\n\r\n#include <IPXACTmodels/ipxactmodels_global.h>\r\n\r\n#include <IPXACTmodels/Component/MemoryBlockBaseReader.h>\r\n\r\n#include <QSharedPointer>\r\n#include <QDomNode>\r\n\r\nclass AddressBlock;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Reader for ipxact:addressBlock element.\r\n//-----------------------------------------------------------------------------\r\nnamespace AddressBlockReader\r\n{\r\n\r\n    /*!\r\n     *  Creates a new address block from a given address block node.\r\n     *\r\n     *    @param [in] addressBlockNode    XML description of the address block.\r\n     *\r\n     *    @return The created address block.\r\n     */\r\n    IPXACTMODELS_EXPORT QSharedPointer<AddressBlock> createAddressBlockFrom(QDomNode const& addressBlockNode, Document::Revision docRevision);\r\n    \r\n    namespace Details\r\n    {\r\n\r\n        /*!\r\n         *  Reads the type identifier.\r\n         *\r\n         *    @param [in] addressBlockNode    XML description of the address block.\r\n         *    @param [in] newAddressBlock     The new address block.\r\n         */\r\n        void parseTypeIdentifier(QDomNode const& addressBlockNode, QSharedPointer<AddressBlock> newAddressBlock);\r\n\r\n        /*!\r\n         *  Reads the range.\r\n         *\r\n         *    @param [in] addressBlockNode    XML description of the address block.\r\n         *    @param [in] newAddressBlock     The new address block.\r\n         */\r\n        void parseRange(QDomNode const& addressBlockNode, QSharedPointer<AddressBlock> newAddressBlock);\r\n\r\n        /*!\r\n         *  Reads the width.\r\n         *\r\n         *    @param [in] addressBlockNode    XML description of the address block.\r\n         *    @param [in] newAddressBlock     The new address block.\r\n         */\r\n        void parseWidth(QDomNode const& addressBlockNode, QSharedPointer<AddressBlock> newAddressBlock);\r\n\r\n        /*!\r\n         *  Reads the usage.\r\n         *\r\n         *    @param [in] addressBlockNode    XML description of the address block.\r\n         *    @param [in] newAddressBlock     The new address block.\r\n         */\r\n        void parseUsage(QDomNode const& addressBlockNode, QSharedPointer<AddressBlock> newAddressBlock);\r\n\r\n        /*!\r\n         *  Reads the volatile value.\r\n         *\r\n         *    @param [in] addressBlockNode    XML description of the address block.\r\n         *    @param [in] newAddressBlock     The new address block.\r\n         */\r\n        void parseVolatile(QDomNode const& addressBlockNode, QSharedPointer<AddressBlock> newAddressBlock);\r\n\r\n        /*!\r\n         *  Reads the access value.\r\n         *\r\n         *    @param [in] addressBlockNode    XML description of the address block.\r\n         *    @param [in] newAddressBlock     The new address block.\r\n         */\r\n        void parseAccess(QDomNode const& addressBlockNode, QSharedPointer<AddressBlock> newAddressBlock);\r\n\r\n        /*!\r\n         *  Reads the register data.\r\n         *\r\n         *    @param [in] addressBlockNode    XML description of the address block.\r\n         *    @param [in] newAddressBlock     The new address block.\r\n         */\r\n        void parseRegisterData(QDomNode const& addressBlockNode, QSharedPointer<AddressBlock> newAddressBlock, Document::Revision docRevision);\r\n\r\n        /*!\r\n         *\tReads the memory array of the address block.\r\n         *  \r\n         *    @param [in] addressBlockNode    XML description of the address block.\r\n         *    @param [in] newAddressBlock     The new address block.\r\n         */\r\n        void parseMemoryArray(QDomNode const& addressBlockNode, QSharedPointer<AddressBlock> newAddressBlock);\r\n\r\n        /*!\r\n         *\tReads the misalignment allowed attribute of the address block.\r\n         *  \r\n         *    @param [in] addressBlockNode    XML description of the address block.\r\n         *    @param [in] newAddressBlock     The new address block.\r\n         */\r\n        void parseMisalignmentAllowed(QDomNode const& addressBlockNode, QSharedPointer<AddressBlock> newAddressBlock);\r\n\r\n        /*!\r\n         *\tReads the address block definition reference.\r\n         *  \r\n         *    @param [in] addressBlockNode    XML description of the address block.\r\n         *    @param [in] newAddressBlock     The new address block.\r\n         */\r\n        void parseAddressBlockDefinitionRef(QDomNode const& addressBlockNode, QSharedPointer<AddressBlock> newAddressBlock);\r\n\r\n        /*!\r\n         *\tReads the access policies of the address block.\r\n         *  \r\n         *    @param [in] addressBlockNode    XML description of the address block.\r\n         *    @param [in] newAddressBlock     The new address block.\r\n         */\r\n        void parseAccessPolicies(QDomNode const& addressBlockNode, QSharedPointer<AddressBlock> newAddressBlock);\r\n    }\r\n}\r\n\r\n#endif // ADDRESSBLOCKREADER_H"
  },
  {
    "path": "IPXACTmodels/Component/AddressBlockWriter.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: AddressBlockWriter.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 30.09.2015\r\n//\r\n// Description:\r\n// Writer for ipxact:addressBlock element.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"AddressBlockWriter.h\"\r\n#include \"AddressBlock.h\"\r\n\r\n#include \"MemoryArrayWriter.h\"\r\n#include \"AccessPolicyWriter.h\"\r\n\r\n#include <IPXACTmodels/common/NameGroupWriter.h>\r\n#include <IPXACTmodels/Component/RegisterWriter.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressBlockWriter::writeAddressBlock()\r\n//-----------------------------------------------------------------------------\r\nvoid AddressBlockWriter::writeAddressBlock(QXmlStreamWriter& writer, QSharedPointer<AddressBlock> addressBlock, Document::Revision docRevision)\r\n{\r\n    writer.writeStartElement(QStringLiteral(\"ipxact:addressBlock\"));\r\n \r\n    if (docRevision == Document::Revision::Std22)\r\n    {\r\n        CommonItemsWriter::writeNonEmptyAttribute(writer, QStringLiteral(\"misalignmentAllowed\"),\r\n            addressBlock->getMisalignmentAllowed());\r\n    }\r\n\r\n    MemoryBlockBaseWriter::writeNameGroup(writer, addressBlock, docRevision);\r\n\r\n    if (docRevision == Document::Revision::Std14)\r\n    {\r\n        CommonItemsWriter::writeIsPresent(writer, addressBlock->getIsPresent());\r\n    }\r\n    else if (docRevision == Document::Revision::Std22)\r\n    {\r\n        MemoryArrayWriter::writeMemoryArray(writer, addressBlock->getMemoryArray(), docRevision, false);\r\n    }\r\n\r\n    MemoryBlockBaseWriter::writeBaseAddress(writer, addressBlock);\r\n\r\n    if (docRevision == Document::Revision::Std22)\r\n    {\r\n        Details::writeDefinitionReference(writer, addressBlock);\r\n    }\r\n\r\n    Details::writeTypeIdentifier(writer, addressBlock);\r\n\r\n    CommonItemsWriter::writeNonEmptyElement(writer, QStringLiteral(\"ipxact:range\"), addressBlock->getRange());\r\n    CommonItemsWriter::writeNonEmptyElement(writer, QStringLiteral(\"ipxact:width\"), addressBlock->getWidth());\r\n\r\n    Details::writeUsage(writer, addressBlock);\r\n\r\n    Details::writeVolatile(writer, addressBlock);\r\n\r\n    if (docRevision == Document::Revision::Std14)\r\n    {\r\n        Details::writeAccess(writer, addressBlock);\r\n    }\r\n    else if (docRevision == Document::Revision::Std22)\r\n    {\r\n        Details::writeAccessPolicies(writer, addressBlock);\r\n    }\r\n\r\n    CommonItemsWriter::writeParameters(writer, addressBlock->getParameters(), docRevision);\r\n\r\n    Details::writeRegisterData(writer, addressBlock, docRevision);\r\n\r\n    CommonItemsWriter::writeVendorExtensions(writer, addressBlock);\r\n\r\n    writer.writeEndElement(); // ipxact:addressBlock\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressBlockWriter::Details::writeTypeIdentifier()\r\n//-----------------------------------------------------------------------------\r\nvoid AddressBlockWriter::Details::writeTypeIdentifier(QXmlStreamWriter& writer, QSharedPointer<AddressBlock> addressBlock)\r\n{\r\n    if (!addressBlock->getTypeIdentifier().isEmpty())\r\n    {\r\n        writer.writeTextElement(QStringLiteral(\"ipxact:typeIdentifier\"), addressBlock->getTypeIdentifier());\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressBlockWriter::Details::writeUsage()\r\n//-----------------------------------------------------------------------------\r\nvoid AddressBlockWriter::Details::writeUsage(QXmlStreamWriter& writer, QSharedPointer<AddressBlock> addressBlock)\r\n{\r\n    if (addressBlock->getUsage() != General::USAGE_COUNT)\r\n    {\r\n        QString usageString = General::usage2Str(addressBlock->getUsage());\r\n        writer.writeTextElement(QStringLiteral(\"ipxact:usage\"), usageString);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressBlockWriter::Details::writeVolatile()\r\n//-----------------------------------------------------------------------------\r\nvoid AddressBlockWriter::Details::writeVolatile(QXmlStreamWriter& writer, QSharedPointer<AddressBlock> addressBlock)\r\n{\r\n    if (!addressBlock->getVolatile().isEmpty())\r\n    {\r\n        writer.writeTextElement(QStringLiteral(\"ipxact:volatile\"), addressBlock->getVolatile());\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressBlockWriter::Details::writeAccess()\r\n//-----------------------------------------------------------------------------\r\nvoid AddressBlockWriter::Details::writeAccess(QXmlStreamWriter& writer, QSharedPointer<AddressBlock> addressBlock)\r\n{\r\n    if (addressBlock->getAccess() != AccessTypes::ACCESS_COUNT)\r\n    {\r\n        QString accessString = AccessTypes::access2Str(addressBlock->getAccess());\r\n        writer.writeTextElement(QStringLiteral(\"ipxact:access\"), accessString);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressBlockWriter::Details::writeRegisterData()\r\n//-----------------------------------------------------------------------------\r\nvoid AddressBlockWriter::Details::writeRegisterData(QXmlStreamWriter& writer, QSharedPointer<AddressBlock> addressBlock, Document::Revision docRevision)\r\n{\r\n    if (!addressBlock->getRegisterData()->isEmpty())\r\n    {\r\n        for (auto const& registerBase : *addressBlock->getRegisterData())\r\n        {\r\n            RegisterWriter::writeRegisterData(writer, registerBase, docRevision);\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressBlockWriter::Details::writeDefinitionReference()\r\n//-----------------------------------------------------------------------------\r\nvoid AddressBlockWriter::Details::writeDefinitionReference(QXmlStreamWriter& writer, QSharedPointer<AddressBlock> addressBlock)\r\n{\r\n    if (auto const& definitionReference = addressBlock->getAddressBlockDefinitionRef();\r\n        definitionReference.isEmpty() == false)\r\n    {\r\n        writer.writeStartElement(QStringLiteral(\"ipxact:addressBlockDefinitionRef\"));\r\n\r\n        if (auto const& typeDefinitionsRef = addressBlock->getTypeDefinitionsRef();\r\n            typeDefinitionsRef.isEmpty() == false)\r\n        {\r\n            writer.writeAttribute(QStringLiteral(\"typeDefinitions\"), typeDefinitionsRef);\r\n        }\r\n\r\n        writer.writeCharacters(definitionReference);\r\n        writer.writeEndElement();\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressBlockWriter::Details::writeAccessPolicies()\r\n//-----------------------------------------------------------------------------\r\nvoid AddressBlockWriter::Details::writeAccessPolicies(QXmlStreamWriter& writer, QSharedPointer<AddressBlock> addressBlock)\r\n{\r\n    if (auto accessPolicies = addressBlock->getAccessPolicies();\r\n        accessPolicies->isEmpty() == false)\r\n    {\r\n        writer.writeStartElement(QStringLiteral(\"ipxact:accessPolicies\"));\r\n\r\n        for (auto const& accessPolicy : *addressBlock->getAccessPolicies())\r\n        {\r\n            AccessPolicyWriter::writeAccessPolicy(writer, accessPolicy);\r\n        }\r\n\r\n        writer.writeEndElement(); // ipxact:accessPolicies\r\n    }\r\n}\r\n"
  },
  {
    "path": "IPXACTmodels/Component/AddressBlockWriter.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: AddressBlockWriter.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 30.09.2015\r\n//\r\n// Description:\r\n// Writer for ipxact:addressBlock element.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef ADDRESSBLOCKWRITER_H\r\n#define ADDRESSBLOCKWRITER_H\r\n\r\n#include <IPXACTmodels/ipxactmodels_global.h>\r\n\r\n#include <IPXACTmodels/Component/MemoryBlockBaseWriter.h>\r\n\r\n#include <QXmlStreamWriter>\r\n#include <QObject>\r\n#include <QSharedPointer>\r\n\r\nclass AddressBlock;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Writer for ipxact:addressBlock element.\r\n//-----------------------------------------------------------------------------\r\nnamespace AddressBlockWriter\r\n{\r\n\r\n    /*!\r\n     *  Write an address block to an XML file.\r\n     *\r\n     *    @param [in] writer          The used XML writer.\r\n     *    @param [in] addressBlock    The address block to be written.\r\n     */\r\n    IPXACTMODELS_EXPORT void writeAddressBlock(QXmlStreamWriter& writer, QSharedPointer<AddressBlock> addressBlock, Document::Revision docRevision);\r\n\r\n    namespace Details\r\n    {\r\n\r\n        /*!\r\n         *  Write the type identifier.\r\n         *\r\n         *    @param [in] writer          Used XML writer.\r\n         *    @param [in] addressBlock    Selected address block.\r\n         */\r\n        void writeTypeIdentifier(QXmlStreamWriter& writer, QSharedPointer<AddressBlock> addressBlock);\r\n\r\n        /*!\r\n         *  Write the usage.\r\n         *\r\n         *    @param [in] writer          Used XML writer.\r\n         *    @param [in] addressBlock    Selected address block.\r\n         */\r\n        void writeUsage(QXmlStreamWriter& writer, QSharedPointer<AddressBlock> addressBlock);\r\n\r\n        /*!\r\n         *  Write the volatile status.\r\n         *\r\n         *    @param [in] writer          Used XML writer.\r\n         *    @param [in] addressBlock    Selected address block.\r\n         */\r\n        void writeVolatile(QXmlStreamWriter& writer, QSharedPointer<AddressBlock> addressBlock);\r\n\r\n        /*!\r\n         *  Write the access value.\r\n         *\r\n         *    @param [in] writer          Used XML writer.\r\n         *    @param [in] addressBlock    Selected address block.\r\n         */\r\n        void writeAccess(QXmlStreamWriter& writer, QSharedPointer<AddressBlock> addressBlock);\r\n\r\n        /*!\r\n         *  Write register data.\r\n         *\r\n         *    @param [in] writer          Used XML writer.\r\n         *    @param [in] addressBlock    Selected address block.\r\n         */\r\n        void writeRegisterData(QXmlStreamWriter& writer, QSharedPointer<AddressBlock> addressBlock, Document::Revision docRevision);\r\n\r\n        /*!\r\n         *\tWrite the address block definition reference.\r\n         *  \r\n         *    @param [in] writer          Used XML writer.\r\n         *    @param [in] addressBlock    Selected address block.\r\n         */\r\n        void writeDefinitionReference(QXmlStreamWriter& writer, QSharedPointer<AddressBlock> addressBlock);\r\n\r\n        /*!\r\n         *\tWrite the access policies of the address block.\r\n         *  \r\n         *    @param [in] writer          Used XML writer.\r\n         *    @param [in] addressBlock    Selected address block.\r\n         */\r\n        void writeAccessPolicies(QXmlStreamWriter& writer, QSharedPointer<AddressBlock> addressBlock);\r\n    }\r\n}\r\n\r\n#endif // ADDRESSBLOCKWRITER_H"
  },
  {
    "path": "IPXACTmodels/Component/AddressSpace.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: AddressSpace.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: \r\n// Date:\r\n//\r\n// Description:\r\n// Describes the ipxact:addressSpace element.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"AddressSpace.h\"\r\n\r\n#include <IPXACTmodels/common/Parameter.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressSpace::()\r\n//-----------------------------------------------------------------------------\r\nAddressSpace::AddressSpace(QString const& name, QString const& range, QString const& width) :\r\nNameGroup(name),\r\nExtendable(),\r\nrange_(range),\r\nwidth_(width),\r\nsegments_(new QList<QSharedPointer<Segment> > ()),\r\naddressUnitBits_(),\r\nlocalMemoryMap_(nullptr),\r\nparameters_(new QList<QSharedPointer<Parameter> > ())\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressSpace::AddressSpace()\r\n//-----------------------------------------------------------------------------\r\nAddressSpace::AddressSpace( const AddressSpace &other ):\r\nNameGroup(other),\r\nExtendable(other),\r\nisPresent_(other.isPresent_),\r\nrange_(other.range_),\r\nwidth_(other.width_),\r\nsegments_(new QList<QSharedPointer<Segment> > ()),\r\naddressUnitBits_(other.addressUnitBits_),\r\nlocalMemoryMap_(),\r\nparameters_(new QList<QSharedPointer<Parameter> > ())\r\n{\r\n    copyLocalMemoryMap(other);\r\n    copySegments(other);\r\n    copyParameters(other);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressSpace::operator=()\r\n//-----------------------------------------------------------------------------\r\nAddressSpace & AddressSpace::operator=( const AddressSpace &other )\r\n{\r\n\tif (this != &other)\r\n    {\r\n\t\tNameGroup::operator=(other);\r\n        Extendable::operator=(other);\r\n\t\trange_ = other.range_;\r\n\t\twidth_ = other.width_;\r\n\t\taddressUnitBits_ = other.addressUnitBits_;\r\n\r\n        localMemoryMap_.clear();\r\n        copyLocalMemoryMap(other);\r\n\r\n        segments_->clear();\r\n        copySegments(other);\r\n\r\n        parameters_->clear();\r\n        copyParameters(other);\r\n\t}\r\n\treturn *this;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressSpace::~AddressSpace()\r\n//-----------------------------------------------------------------------------\r\nAddressSpace::~AddressSpace()\r\n{\r\n    localMemoryMap_.clear();\r\n\tsegments_.clear();\r\n    parameters_.clear();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressSpace::getIsPresent()\r\n//-----------------------------------------------------------------------------\r\nQString AddressSpace::getIsPresent() const\r\n{\r\n\treturn isPresent_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressSpace::setIsPresent()\r\n//-----------------------------------------------------------------------------\r\nvoid AddressSpace::setIsPresent(QString const& newIsPresent)\r\n{\r\n\tisPresent_ = newIsPresent;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressSpace::setAddressUnitBits()\r\n//-----------------------------------------------------------------------------\r\nvoid AddressSpace::setAddressUnitBits(QString const& newAddressUnitBits)\r\n{\r\n\taddressUnitBits_ = newAddressUnitBits;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressSpace::getAddressUnitBits()\r\n//-----------------------------------------------------------------------------\r\nQString AddressSpace::getAddressUnitBits(bool defaultIfEmpty /*= true*/) const\r\n{\r\n    if (addressUnitBits_.isEmpty() && defaultIfEmpty)\r\n    {\r\n        return QStringLiteral(\"8\");\r\n    }\r\n\r\n\treturn addressUnitBits_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressSpace::setRange()\r\n//-----------------------------------------------------------------------------\r\nvoid AddressSpace::setRange(QString const& newRange)\r\n{\r\n\trange_ = newRange;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressSpace::getRange()\r\n//-----------------------------------------------------------------------------\r\nQString AddressSpace::getRange() const\r\n{\r\n\treturn range_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressSpace::getWidth()\r\n//-----------------------------------------------------------------------------\r\nQString AddressSpace::getWidth() const\r\n{\r\n\treturn width_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressSpace::setWidth()\r\n//-----------------------------------------------------------------------------\r\nvoid AddressSpace::setWidth(QString const& newWidth)\r\n{\r\n\twidth_ = newWidth;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressSpace::getLocalMemoryMap()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<MemoryMapBase> AddressSpace::getLocalMemoryMap()\r\n{\r\n\treturn localMemoryMap_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressSpace::hasLocalMemoryMap()\r\n//-----------------------------------------------------------------------------\r\nbool AddressSpace::hasLocalMemoryMap() const\r\n{\r\n    return localMemoryMap_.isNull() == false;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressSpace::setLocalMemoryMap()\r\n//-----------------------------------------------------------------------------\r\nvoid AddressSpace::setLocalMemoryMap( QSharedPointer<MemoryMapBase> localMemoryMap )\r\n{\r\n\tif (localMemoryMap_)\r\n    {\r\n\t\tlocalMemoryMap_.clear();\r\n\t}\r\n\tlocalMemoryMap_ = localMemoryMap;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressSpace::()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<QList<QSharedPointer<Segment> > > AddressSpace::getSegments() const\r\n{\r\n\treturn segments_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressSpace::setSegments()\r\n//-----------------------------------------------------------------------------\r\nvoid AddressSpace::setSegments(QSharedPointer<QList<QSharedPointer<Segment> > > segments)\r\n{\r\n\tsegments_ = segments;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressSpace::getParameters()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<QList<QSharedPointer<Parameter> > > AddressSpace::getParameters() const\r\n{\r\n\treturn parameters_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressSpace::setParameters()\r\n//-----------------------------------------------------------------------------\r\nvoid AddressSpace::setParameters(QSharedPointer<QList<QSharedPointer<Parameter> > > newParameters)\r\n{\r\n    parameters_ = newParameters;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressSpace::copyLocalMemoryMap()\r\n//-----------------------------------------------------------------------------\r\nvoid AddressSpace::copyLocalMemoryMap(const AddressSpace& other)\r\n{\r\n    if (other.localMemoryMap_)\r\n    {\r\n        localMemoryMap_ = QSharedPointer<MemoryMapBase>(new MemoryMapBase(*other.localMemoryMap_.data()));\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressSpace::copySegments()\r\n//-----------------------------------------------------------------------------\r\nvoid AddressSpace::copySegments(const AddressSpace& other)\r\n{\r\n    for (auto const& segment :*other.segments_)\r\n    {\r\n        if (segment)\r\n        {\r\n            auto copy = QSharedPointer<Segment>(new Segment(*segment.data()));\r\n            segments_->append(copy);\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressSpace::copyParameters()\r\n//-----------------------------------------------------------------------------\r\nvoid AddressSpace::copyParameters(const AddressSpace& other)\r\n{\r\n    for (auto const& parameter : *other.parameters_)\r\n    {\r\n        if (parameter)\r\n        {\r\n            auto copy = QSharedPointer<Parameter>(new Parameter(*parameter.data()));\r\n            parameters_->append(copy);\r\n        }\r\n    }\r\n}"
  },
  {
    "path": "IPXACTmodels/Component/AddressSpace.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: AddressSpace.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: \r\n// Date:\r\n//\r\n// Description:\r\n// Describes the ipxact:addressSpace element.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef ADDRESSSPACE_H\r\n#define ADDRESSSPACE_H\r\n\r\n#include \"MemoryMapBase.h\"\r\n\r\n#include <IPXACTmodels/Component/Segment.h>\r\n\r\n#include <IPXACTmodels/ipxactmodels_global.h>\r\n#include <IPXACTmodels/common/Extendable.h>\r\n\r\n#include <QSharedPointer>\r\n#include <QString>\r\n#include <QList>\r\n\r\nclass Parameter;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Describes the ipxact:addressSpace element.\r\n//-----------------------------------------------------------------------------\r\nclass IPXACTMODELS_EXPORT AddressSpace : public NameGroup, public Extendable\r\n{\r\n\r\npublic:\r\n\r\n\t/*!\r\n\t *  The constructor.\r\n\t *\r\n\t *    @param [in] name    Name of the address space.\r\n\t *    @param [in] range   The range.\r\n\t *    @param [in] width   The width.\r\n\t */\r\n\tAddressSpace(QString const& name = QString(), QString const& range = QString(),\r\n        QString const& width = QString());\r\n\r\n\t//! The copy constructor.\r\n\tAddressSpace(const AddressSpace &other);\r\n\r\n\t//! The assignment operator.\r\n\tAddressSpace &operator=(const AddressSpace &other);\r\n\r\n\t//! The destructor.\r\n\t~AddressSpace();\r\n\r\n    /*!\r\n     *  Gets the presence.\r\n     *\r\n     *    @return The presence value.\r\n     */\r\n    QString getIsPresent() const;\r\n\r\n    /*!\r\n     *  Set the presence.\r\n     *\r\n     *    @param [in] newIsPresent    The new presence value.\r\n     */\r\n    void setIsPresent(QString const& newIsPresent);\r\n\r\n\t/*!\r\n     *  Get the address unit bits\r\n\t *\r\n     *    @param [in] defaultIfEmpty      Flag for returning the default AUB value (8 bits) if AUB is empty.\r\n\t *\r\n\t *    @return The address unit bits.\r\n\t */\r\n    QString getAddressUnitBits(bool defaultIfEmpty = true) const;\r\n\r\n\t/*!\r\n     *  Get the range of the address space.\r\n\t *\r\n\t *    @return The range of the address space\r\n\t */\r\n    QString getRange() const;\r\n\r\n\t/*!\r\n     *  Get the width of a row in an address space.\r\n\t *\r\n\t *    @return The width of the address space.\r\n\t */\r\n    QString getWidth() const;\r\n\r\n\t/*!\r\n     *  Set the address unit bits.\r\n\t *\r\n\t *    @param [in] newAddressUnitBits  The new address unit bits.\r\n\t */\r\n    void setAddressUnitBits(QString const& newAddressUnitBits);\r\n\r\n\t/*!\r\n     *  Set the range for the address space.\r\n\t *\r\n\t *    @param [in] newRange    The new range.\r\n\t */\r\n    void setRange(QString const& newRange);\r\n\r\n\t/*!\r\n     *  Set the width of the address space.\r\n\t *\r\n\t *    @param [in] newWidth    The new width.\r\n\t */\r\n    void setWidth(QString const& newWidth);\r\n\r\n\t/*!\r\n     *  Get the pointer to the local memory map.\r\n\t *\r\n\t *    @return A pointer to the local memory map.\r\n\t */\r\n\tQSharedPointer<MemoryMapBase> getLocalMemoryMap();\r\n\r\n\t/*!\r\n     *  Check if the address space contains a local memory map.\r\n\t *\r\n\t *    @return True if a local memory map is found.\r\n\t */\r\n\tbool hasLocalMemoryMap() const;\r\n\r\n\t/*!\r\n     *  Set the local memory map.\r\n\t *\r\n\t *    @param [in] localMemoryMap  A pointer to the new local memory map\r\n\t */\r\n\tvoid setLocalMemoryMap(QSharedPointer<MemoryMapBase> localMemoryMap);\r\n\r\n\t/*!\r\n     *  Get the parameters of the address space.\r\n\t *\r\n\t *    @return Pointer to a lis containing pointers to the parameters.\r\n\t */\r\n    QSharedPointer<QList<QSharedPointer<Parameter> > > getParameters() const;\r\n\r\n    /*!\r\n     *  Set the parameters.\r\n     *\r\n     *    @param [in] newParameters   Pointer to a list containing the new parameters.\r\n     */\r\n    void setParameters(QSharedPointer<QList<QSharedPointer<Parameter> > > newParameters);\r\n\r\n\t/*!\r\n     *  Get the segments contained in this address space.\r\n\t *\r\n\t *    @return Pointer to a list containing pointers to the segments.\r\n\t */\r\n    QSharedPointer<QList<QSharedPointer<Segment> > > getSegments() const;\r\n\r\n    /*!\r\n     *  Set the segments for this address space.\r\n \t *\r\n\t *    @param [in] segments    Pointer to a list containing the new segments for the address space.\r\n\t */\r\n    void setSegments(QSharedPointer<QList<QSharedPointer<Segment> > > segments);\r\n\r\nprivate:\r\n\r\n    /*!\r\n     *  Copy the local memory map.\r\n     *\r\n     *    @param [in] other   The address space being copied.\r\n     */\r\n    void copyLocalMemoryMap(const AddressSpace& other);\r\n\r\n    /*!\r\n     *  Copy the segments.\r\n     *\r\n     *    @param [in] other   The address space being copied.\r\n     */\r\n    void copySegments(const AddressSpace& other);\r\n\r\n    /*!\r\n     *  Copy the parameters.\r\n     *\r\n     *    @param [in] other   The address space being copied.\r\n     */\r\n    void copyParameters(const AddressSpace& other);\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! Presence of the address space.\r\n\tQString isPresent_;\r\n\r\n\t//! Address range of an address space.\r\n    QString range_;\r\n\r\n\t//! The bit width of a row in the address space.\r\n    QString width_;\r\n\r\n\t//! Contains the segments of the address space.\r\n    QSharedPointer<QList<QSharedPointer<Segment> > > segments_;\r\n\r\n\t//! The number of data bits in each address increment.\r\n    QString addressUnitBits_;\r\n\r\n\t//! Block of memory that can only be accessed by the master interfaces.\r\n\tQSharedPointer<MemoryMapBase> localMemoryMap_;\r\n\r\n\t//! Contains the parameters for the addressSpace.\r\n    QSharedPointer<QList<QSharedPointer<Parameter> > > parameters_;\r\n};\r\n\r\nQ_DECLARE_METATYPE(QSharedPointer<AddressSpace>);\r\n\r\n#endif // ADDRESSSPACE_H\r\n"
  },
  {
    "path": "IPXACTmodels/Component/AddressSpaceReader.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: AddressSpaceReader.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Janne Virtanen\r\n// Date: 30.09.2015\r\n//\r\n// Description:\r\n// Reader for IP-XACT AddressSpace element.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"AddressSpaceReader.h\"\r\n\r\n#include <IPXACTmodels/common/NameGroupReader.h>\r\n#include <IPXACTmodels/common/ParameterReader.h>\r\n#include <IPXACTmodels/Component/MemoryMapBaseReader.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressSpaceReader::createCPUFrom()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<AddressSpace> AddressSpaceReader::createAddressSpaceFrom(QDomNode const& addressSpaceNode,\r\n    Document::Revision docRevision)\r\n{\r\n\tQSharedPointer<AddressSpace> newAddressSpace (new AddressSpace());\r\n\r\n    Details::parseNameGroup(addressSpaceNode, newAddressSpace);\r\n\r\n    if (docRevision != Document::Revision::Std22)\r\n    {\r\n\t    newAddressSpace->setIsPresent(CommonItemsReader::parseIsPresent(addressSpaceNode.firstChildElement(QStringLiteral(\"ipxact:isPresent\"))));\r\n    }\r\n\r\n    Details::readBlockSize(addressSpaceNode, newAddressSpace);\r\n\r\n    Details::readSegments(addressSpaceNode, newAddressSpace);\r\n\r\n    Details::parseAddressUnitBits(addressSpaceNode, newAddressSpace);\r\n\r\n    Details::parseLocalMemoryMap(addressSpaceNode, newAddressSpace, docRevision);\r\n\r\n    Details::readParameters(addressSpaceNode, newAddressSpace, docRevision);\r\n\r\n    CommonItemsReader::parseVendorExtensions(addressSpaceNode, newAddressSpace);\r\n\r\n    return newAddressSpace;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressSpaceReader::Details::parseNameGroup()\r\n//-----------------------------------------------------------------------------\r\nvoid AddressSpaceReader::Details::parseNameGroup(QDomNode const& addressSpaceNode,\r\n    QSharedPointer<AddressSpace> newAddressSpace)\r\n{\r\n    NameGroupReader::parseNameGroup(addressSpaceNode, newAddressSpace);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressSpaceReader::Details::readBlockSize()\r\n//-----------------------------------------------------------------------------\r\nvoid AddressSpaceReader::Details::readBlockSize(QDomNode const& addressSpaceNode,\r\n    QSharedPointer<AddressSpace> newAddressSpace)\r\n{\r\n    QDomElement rangeElement = addressSpaceNode.firstChildElement(QStringLiteral(\"ipxact:range\"));\r\n    QString range = rangeElement.firstChild().nodeValue();\r\n    newAddressSpace->setRange(range);\r\n\r\n    QDomElement widthElement = addressSpaceNode.firstChildElement(QStringLiteral(\"ipxact:width\"));\r\n    QString width = widthElement.firstChild().nodeValue();\r\n    newAddressSpace->setWidth(width);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressSpaceReader::Details::readSegments()\r\n//-----------------------------------------------------------------------------\r\nvoid AddressSpaceReader::Details::readSegments(QDomNode const& addressSpaceNode,\r\n    QSharedPointer<AddressSpace> newAddressSpace)\r\n{\r\n    QDomElement segmentsElement = addressSpaceNode.firstChildElement(QStringLiteral(\"ipxact:segments\"));\r\n\r\n    QDomNodeList segmentNodeList = segmentsElement.elementsByTagName(QStringLiteral(\"ipxact:segment\"));\r\n\r\n    if (!segmentNodeList.isEmpty())\r\n    {\r\n        for (int i = 0; i < segmentNodeList.count(); ++i)\r\n        {\r\n            QDomNode segmentNode = segmentNodeList.at(i);\r\n            QSharedPointer<Segment> newSegment(new Segment());\r\n\r\n            NameGroupReader::parseNameGroup(segmentNode, newSegment);\r\n\r\n            newSegment->setIsPresent(CommonItemsReader::parseIsPresent(segmentNode.firstChildElement(QStringLiteral(\"ipxact:isPresent\"))));\r\n\r\n            parseAddressOffset(segmentNode, newSegment);\r\n\r\n            parseRange(segmentNode, newSegment);\r\n\r\n            CommonItemsReader::parseVendorExtensions(segmentNode, newSegment);\r\n\r\n            newAddressSpace->getSegments()->append(newSegment);\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressSpaceReader::Details::parseAddressOffset()\r\n//-----------------------------------------------------------------------------\r\nvoid AddressSpaceReader::Details::parseAddressOffset(QDomNode const& segmentNode, QSharedPointer<Segment> newSegment)\r\n{\r\n    QDomElement addressOffsetElement = segmentNode.firstChildElement(QStringLiteral(\"ipxact:addressOffset\"));\r\n    newSegment->setOffset(addressOffsetElement.firstChild().nodeValue());\r\n\r\n    QDomNamedNodeMap offsetAttributes = addressOffsetElement.attributes();\r\n    if (!offsetAttributes.isEmpty())\r\n    {\r\n        QMap<QString, QString> newOffsetAttributes;\r\n        for (int i = 0 ; i < offsetAttributes.count(); ++i)\r\n        {\r\n            QDomNode attributeNode = offsetAttributes.item(i);\r\n            QString key = attributeNode.nodeName();\r\n            QString value = attributeNode.firstChild().nodeValue();\r\n\r\n            newOffsetAttributes.insert(key, value);\r\n        }\r\n        newSegment->setOffsetAttributes(newOffsetAttributes);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressSpaceReader::Details::parseRange()\r\n//-----------------------------------------------------------------------------\r\nvoid AddressSpaceReader::Details::parseRange(QDomNode const& segmentNode, QSharedPointer<Segment> newSegment)\r\n{\r\n    QDomElement rangeElement = segmentNode.firstChildElement(QStringLiteral(\"ipxact:range\"));\r\n    newSegment->setRange(rangeElement.firstChild().nodeValue());\r\n\r\n    QDomNamedNodeMap rangeAttributes = rangeElement.attributes();\r\n    if (!rangeAttributes.isEmpty())\r\n    {\r\n        QMap<QString, QString> newRangeAttributes;\r\n        for (int i = 0 ; i < rangeAttributes.count(); ++i)\r\n        {\r\n            QDomNode attributeNode = rangeAttributes.item(i);\r\n            QString key = attributeNode.nodeName();\r\n            QString value = attributeNode.firstChild().nodeValue();\r\n\r\n            newRangeAttributes.insert(key, value);\r\n        }\r\n        newSegment->setRangeAttributes(newRangeAttributes);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressSpaceReader::Details::parseAddressUnitBits()\r\n//-----------------------------------------------------------------------------\r\nvoid AddressSpaceReader::Details::parseAddressUnitBits(QDomNode const& addressSpaceNode,\r\n    QSharedPointer<AddressSpace> newAddressSpace)\r\n{\r\n    QDomElement addressUnitElement = addressSpaceNode.firstChildElement(QStringLiteral(\"ipxact:addressUnitBits\"));\r\n    if (!addressUnitElement.isNull())\r\n    {\r\n        QString addressUnitBits = addressUnitElement.firstChild().nodeValue();\r\n        newAddressSpace->setAddressUnitBits(addressUnitBits);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressSpaceReader::Details::parseLocalMemoryMap()\r\n//-----------------------------------------------------------------------------\r\nvoid AddressSpaceReader::Details::parseLocalMemoryMap(QDomNode const& addressSpaceNode,\r\n    QSharedPointer<AddressSpace> newAddressSpace,\r\n    Document::Revision docRevision)\r\n{\r\n    QDomNode localMemoryMapNode = addressSpaceNode.firstChildElement(QStringLiteral(\"ipxact:localMemoryMap\"));\r\n    if (!localMemoryMapNode.isNull())\r\n    {\r\n        QSharedPointer<MemoryMapBase> newLocalMemoryMap(new MemoryMapBase());\r\n\r\n        MemoryMapBaseReader::readMemoryMapBase(localMemoryMapNode, newLocalMemoryMap, docRevision);\r\n        newAddressSpace->setLocalMemoryMap(newLocalMemoryMap);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressSpaceReader::Details::readParameters()\r\n//-----------------------------------------------------------------------------\r\nvoid AddressSpaceReader::Details::readParameters(QDomNode const& addressSpaceNode,\r\n    QSharedPointer<AddressSpace> newAddressSpace, Document::Revision docRevision)\r\n{\r\n    QSharedPointer<QList<QSharedPointer<Parameter> > > newParameters = \r\n        CommonItemsReader::parseAndCreateParameters(addressSpaceNode, docRevision);\r\n\r\n    if (!newParameters->isEmpty())\r\n    {\r\n        newAddressSpace->setParameters(newParameters);\r\n    }\r\n}\r\n"
  },
  {
    "path": "IPXACTmodels/Component/AddressSpaceReader.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: AddressSpaceReader.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Janne Virtanen\r\n// Date: 30.09.2015\r\n//\r\n// Description:\r\n// Reader for IP-XACT AddressSpace element.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef AddressSpaceReader_H\r\n#define AddressSpaceReader_H\r\n\r\n#include \"AddressSpace.h\"\r\n\r\n#include <IPXACTmodels/common/CommonItemsReader.h>\r\n#include <IPXACTmodels/common/Document.h>\r\n\r\n#include <QSharedPointer>\r\n#include <QDomNode>\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Reader for IP-XACT AddressSpace element.\r\n//-----------------------------------------------------------------------------\r\nnamespace AddressSpaceReader\r\n{\r\n    /*!\r\n     *  Creates a new AddressSpace from a given AddressSpace node.\r\n     *\r\n     *    @param [in] AddressSpaceNode    XML description of the address space.\r\n     *    @param [in] docRevision         The standard revision to use.\r\n     *\r\n\t *\t\t@return\t\tThe created address space.\r\n     */\r\n    IPXACTMODELS_EXPORT QSharedPointer<AddressSpace> createAddressSpaceFrom(QDomNode const& addressSpaceNode, Document::Revision docRevision);\r\n\r\n    namespace Details\r\n    {\r\n\r\n        /*!\r\n         *  Parse the name group.\r\n         *\r\n         *    @param [in] addressSpaceNode    XML description of the address space.\r\n         *    @param [in] newAddressSpace     The new address space.\r\n         */\r\n        void parseNameGroup(QDomNode const& addressSpaceNode, QSharedPointer<AddressSpace> newAddressSpace);\r\n\r\n        /*!\r\n         *  Parse the block size group.\r\n         *\r\n         *    @param [in] addressSpaceNode    XML description of the address space.\r\n         *    @param [in] newAddressSpace     The new address space.\r\n         */\r\n        void readBlockSize(QDomNode const& addressSpaceNode, QSharedPointer<AddressSpace> newAddressSpace);\r\n\r\n        /*!\r\n         *  Parse the segments.\r\n         *\r\n         *    @param [in] addressSpaceNode    XML description of the address space.\r\n         *    @param [in] newAddressSpace     The new address space.\r\n         */\r\n        void readSegments(QDomNode const& addressSpaceNode, QSharedPointer<AddressSpace> newAddressSpace);\r\n\r\n        /*!\r\n         *  Parse the address offset.\r\n         *\r\n         *    @param [in] segmentNode     XML description of a segment.\r\n         *    @param [in] newSegment      The new segment.\r\n         */\r\n        void parseAddressOffset(QDomNode const& segmentNode, QSharedPointer<Segment> newSegment);\r\n\r\n        /*!\r\n         *  Parse the range.\r\n         *\r\n         *    @param [in] segmentNode     XML description of a segment.\r\n         *    @param [in] newSegment      The new segment.\r\n         */\r\n        void parseRange(QDomNode const& segmentNode, QSharedPointer<Segment> newSegment);\r\n\r\n        /*!\r\n         *  Parse the address unit bits.\r\n         *\r\n         *    @param [in] addressSpaceNode    XML description of the address space.\r\n         *    @param [in] newAddressSpace     The new address space.\r\n         */\r\n        void parseAddressUnitBits(QDomNode const& addressSpaceNode, QSharedPointer<AddressSpace> newAddressSpace);\r\n\r\n        /*!\r\n         *  Parse the local memory map.\r\n         *\r\n         *    @param [in] addressSpaceNode    XML description of the address space.\r\n         *    @param [in] newAddressSpace     The new address space.\r\n         */\r\n        void parseLocalMemoryMap(QDomNode const& addressSpaceNode, QSharedPointer<AddressSpace> newAddressSpace, Document::Revision docRevision);\r\n\r\n        /*!\r\n         *  Parse the parameters.\r\n         *\r\n         *    @param [in] addressSpaceNode    XML description of the address space.\r\n         *    @param [in] newAddressSpace     The new address space.\r\n         *    @param [in] docRevision         The IP-XACT standard revision to comply to.\r\n         *\r\n         */\r\n        void readParameters(QDomNode const& addressSpaceNode, QSharedPointer<AddressSpace> newAddressSpace,\r\n            Document::Revision docRevision);\r\n    }\r\n};\r\n\r\n#endif // AddressSpaceReader_H"
  },
  {
    "path": "IPXACTmodels/Component/AddressSpaceWriter.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: AddressSpaceWriter.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Janne Virtanen\r\n// Date: 01.10.2015\r\n//\r\n// Description:\r\n// Writer for IP-XACT AddressSpace element.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"AddressSpaceWriter.h\"\r\n\r\n#include <IPXACTmodels/common/NameGroupWriter.h>\r\n#include <IPXACTmodels/common/ParameterWriter.h>\r\n\r\n#include <IPXACTmodels/Component/MemoryMapBaseWriter.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressSpaceWriter::writeAddressSpace()\r\n//-----------------------------------------------------------------------------\r\nvoid AddressSpaceWriter::writeAddressSpace(QXmlStreamWriter& writer, QSharedPointer<AddressSpace> addressSpace,\r\n    Document::Revision docRevision)\r\n{\r\n\twriter.writeStartElement(QStringLiteral(\"ipxact:addressSpace\"));\r\n\r\n    NameGroupWriter::writeNameGroup(writer, addressSpace, docRevision);\r\n\r\n    if (docRevision != Document::Revision::Std22)\r\n    {\r\n\t    CommonItemsWriter::writeIsPresent(writer, addressSpace->getIsPresent());\r\n    }\r\n\t\r\n    Details::writeBlockSize(writer, addressSpace);\r\n\r\n    Details::writeSegments(addressSpace, writer);\r\n\r\n    Details::writeAddressUnitBits(writer, addressSpace);\r\n\r\n    Details::writeLocalMemoryMap(writer, addressSpace, docRevision);\r\n\r\n    CommonItemsWriter::writeParameters(writer, addressSpace->getParameters(), docRevision);\r\n\r\n    CommonItemsWriter::writeVendorExtensions( writer, addressSpace );\r\n\r\n\twriter.writeEndElement();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressSpaceWriter::Details::writeBlockSize()\r\n//-----------------------------------------------------------------------------\r\nvoid AddressSpaceWriter::Details::writeBlockSize(QXmlStreamWriter &writer, QSharedPointer<AddressSpace> addressSpace)\r\n{\r\n    writer.writeTextElement(QStringLiteral(\"ipxact:range\"), addressSpace->getRange());\r\n    writer.writeTextElement(QStringLiteral(\"ipxact:width\"), addressSpace->getWidth());\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressSpaceWriter::Details::writeSegments()\r\n//-----------------------------------------------------------------------------\r\nvoid AddressSpaceWriter::Details::writeSegments(QSharedPointer<AddressSpace> addressSpace, QXmlStreamWriter &writer)\r\n{\r\n\tif (!addressSpace->getSegments()->isEmpty())\r\n\t{\r\n\t\twriter.writeStartElement(QStringLiteral(\"ipxact:segments\"));\r\n\r\n\t\tfor (auto const& segment : *addressSpace->getSegments())\r\n\t\t{\r\n            writeSingleSegment(writer, segment);\r\n\t\t}\r\n\r\n\t\twriter.writeEndElement(); // ipxact:segments\r\n\t}\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressSpaceWriter::Details::writeSingleSegment()\r\n//-----------------------------------------------------------------------------\r\nvoid AddressSpaceWriter::Details::writeSingleSegment(QXmlStreamWriter& writer, QSharedPointer<Segment> segment)\r\n{\r\n    writer.writeStartElement(QStringLiteral(\"ipxact:segment\"));\r\n\r\n    NameGroupWriter::writeNameGroup(writer, segment);\r\n\r\n    CommonItemsWriter::writeIsPresent(writer, segment->getIsPresent());\r\n\r\n    if (!segment->getAddressOffset().isEmpty())\r\n    {\r\n        writer.writeStartElement(QStringLiteral(\"ipxact:addressOffset\"));\r\n\r\n        writeAttributeMap(writer, segment->getOffsetAttributes());\r\n        writer.writeCharacters(segment->getAddressOffset());\r\n\r\n        writer.writeEndElement();\r\n    }\r\n\r\n    if ( !segment->getRange().isEmpty() )\r\n    {\r\n        writer.writeStartElement(QStringLiteral(\"ipxact:range\"));\r\n\r\n        writeAttributeMap(writer, segment->getRangeAttributes());\r\n        writer.writeCharacters(segment->getRange());\r\n\r\n        writer.writeEndElement();\r\n    }\r\n\r\n    CommonItemsWriter::writeVendorExtensions( writer, segment );\r\n\r\n    writer.writeEndElement(); // ipxact:segment\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressSpaceWriter::Details::writeAttributeMap()\r\n//-----------------------------------------------------------------------------\r\nvoid AddressSpaceWriter::Details::writeAttributeMap(QXmlStreamWriter& writer, QMap<QString, QString> attributes)\r\n{\r\n    for (QMap<QString, QString>::const_iterator i = attributes.begin(); i != attributes.end(); ++i)\r\n    {        \r\n        writer.writeAttribute(i.key(), i.value());\r\n    }\r\n    return;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressSpaceWriter::Details::writeAddressUnitBits()\r\n//-----------------------------------------------------------------------------\r\nvoid AddressSpaceWriter::Details::writeAddressUnitBits(QXmlStreamWriter& writer, QSharedPointer<AddressSpace> addressSpace)\r\n{\r\n    CommonItemsWriter::writeNonEmptyElement(writer, QStringLiteral(\"ipxact:addressUnitBits\"),\r\n        addressSpace->getAddressUnitBits(false));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressSpaceWriter::Details::writeLocalMemoryMap()\r\n//-----------------------------------------------------------------------------\r\nvoid AddressSpaceWriter::Details::writeLocalMemoryMap(QXmlStreamWriter& writer, \r\n    QSharedPointer<AddressSpace> addressSpace, Document::Revision docRevision)\r\n   \r\n{\r\n    if (addressSpace->getLocalMemoryMap())\r\n    {\r\n        writer.writeStartElement(QStringLiteral(\"ipxact:localMemoryMap\"));\r\n        \r\n        MemoryMapBaseWriter::writeMemoryMapBase(writer, addressSpace->getLocalMemoryMap(), docRevision);\r\n        \r\n        writer.writeEndElement(); // ipxact:localMemoryMap\r\n    }\r\n}\r\n"
  },
  {
    "path": "IPXACTmodels/Component/AddressSpaceWriter.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: AddressSpaceWriter.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Janne Virtanen\r\n// Date: 15.09.2015\r\n//\r\n// Description:\r\n// Writer for IP-XACT AddressSpace element.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef AddressSpaceWriter_H\r\n#define AddressSpaceWriter_H\r\n\r\n#include \"AddressSpace.h\"\r\n\r\n#include <IPXACTmodels/ipxactmodels_global.h>\r\n\r\n#include <IPXACTmodels/common/CommonItemsWriter.h>\r\n\r\n#include <QXmlStreamWriter>\r\n#include <QSharedPointer>\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Writer for IP-XACT AddressSpace element.\r\n//-----------------------------------------------------------------------------\r\nnamespace AddressSpaceWriter\r\n{\r\n\r\n    /*!\r\n     *  Write a AddressSpace to an XML file.\r\n     *\r\n     *    @param [in] writer\t\t\t\tThe used xml writer.\r\n     *    @param [in] AddressSpace\t\tThe AddressSpace to be written.\r\n     *    @param [in] docRevision\t\t\tThe standard revision to use.\r\n     */\r\n\tIPXACTMODELS_EXPORT void writeAddressSpace(QXmlStreamWriter& writer, QSharedPointer<AddressSpace> addressSpace,\r\n\t\tDocument::Revision docRevision);\r\n\t\r\n\tnamespace Details\r\n\t{\r\n\r\n\t\t/*!\r\n\t\t *  Writes block size of the item.\r\n\t\t *\r\n\t\t *    @param [in] writer\t\t\t\tThe used writer.\r\n\t\t *    @param [in] addressSpace\t\tThe address space being written.\r\n\t\t */\r\n\t\tvoid writeBlockSize(QXmlStreamWriter& writer, QSharedPointer<AddressSpace> addressSpace);\r\n\r\n\t\t/*!\r\n\t\t *  Writes segments, if any exists\r\n\t\t *\r\n\t\t *    @param [in] addressSpace\t\tThe address space which is to be written to XML.\r\n\t\t *    @param [in] writer\t\t\t\tThe writer use to write XLM.\r\n\t\t */\r\n\t\tvoid writeSegments(QSharedPointer<AddressSpace> addressSpace, QXmlStreamWriter& writer);\r\n\r\n\t\t/*!\r\n\t\t *  Writes a single segment.\r\n\t\t *\r\n\t\t *    @param [in] writer\t\tThe used writer.\r\n\t\t *    @param [in] segment     The segment being written.\r\n\t\t */\r\n\t\tvoid writeSingleSegment(QXmlStreamWriter& writer, QSharedPointer<Segment> segment);\r\n\r\n\t\t/*!\r\n\t\t *  Writes block size of the item.\r\n\t\t *\r\n\t\t *    @param [in] writer\t\t\t\tThe used writer.\r\n\t\t *    @param [in] addressSpace\t\tThe written attributes.\r\n\t\t */\r\n\t\tvoid writeAttributeMap(QXmlStreamWriter& writer, QMap<QString, QString> attributes);\r\n\r\n\t\t/*!\r\n\t\t *  Writes address unit bits.\r\n\t\t *\r\n\t\t *    @param [in] writer\t\t\t\tThe used writer.\r\n\t\t *    @param [in] addressSpace\t\tThe address space being written.\r\n\t\t */\r\n\t\tvoid writeAddressUnitBits(QXmlStreamWriter& writer, QSharedPointer<AddressSpace> addressSpace);\r\n\r\n\t\t/*!\r\n\t\t *  Writes the local memory map.\r\n\t\t *\r\n\t\t *    @param [in] writer\t\t\t\tThe used writer.\r\n\t\t *    @param [in] addressSpace\t\tThe address space being written.\r\n\t\t *    @param [in] docRevision         The standard revision in use.\r\n\t\t */\r\n\t\tvoid writeLocalMemoryMap(QXmlStreamWriter& writer, QSharedPointer<AddressSpace> addressSpace, \r\n\t\t\tDocument::Revision docRevision);\r\n\t}\r\n};\r\n\r\n#endif // AddressSpaceWriter_H"
  },
  {
    "path": "IPXACTmodels/Component/AlternateRegister.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: AlternateRegister.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 28.09.2015\r\n//\r\n// Description:\r\n// Describes the ipxact:alternateRegister element.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"AlternateRegister.h\"\r\n\r\n#include <IPXACTmodels/Component/ModeReference.h>\r\n\r\n#include <IPXACTmodels/utilities/Copy.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AlternateRegister::AlternateRegister()\r\n//-----------------------------------------------------------------------------\r\nAlternateRegister::AlternateRegister(QString const& name, QString const& alternateGroup):\r\nRegisterDefinition(name),\r\nalternateGroups_(new QStringList())\r\n{\r\n    if (!alternateGroup.isEmpty())\r\n    {\r\n        alternateGroups_->append(alternateGroup);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AlternateRegister::AlternateRegister()\r\n//-----------------------------------------------------------------------------\r\nAlternateRegister::AlternateRegister(const AlternateRegister& other):\r\nRegisterDefinition(other),\r\nalternateGroups_(new QStringList())\r\n{\r\n    copyAlternateGroups(other);\r\n    Copy::copyList(other.modeReferences_, modeReferences_);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AlternateRegister::operator=()\r\n//-----------------------------------------------------------------------------\r\nAlternateRegister& AlternateRegister::operator=(const AlternateRegister& other)\r\n{\r\n    if (this != &other)\r\n    {\r\n        RegisterDefinition::operator=(other);\r\n\r\n        alternateGroups_->clear();\r\n        copyAlternateGroups(other);\r\n\r\n        modeReferences_->clear();\r\n        Copy::copyList(other.modeReferences_, modeReferences_);\r\n    }\r\n\r\n    return *this;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AlternateRegister::~AlternateRegister()\r\n//-----------------------------------------------------------------------------\r\nAlternateRegister::~AlternateRegister()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AlternateRegister::clone()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<RegisterBase> AlternateRegister::clone()\r\n{\r\n    return QSharedPointer<RegisterBase>(new AlternateRegister(*this));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AlternateRegister::getAlternateGroups()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<QStringList> AlternateRegister::getAlternateGroups() const\r\n{\r\n    return alternateGroups_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AlternateRegister::setAlternateGroups()\r\n//-----------------------------------------------------------------------------\r\nvoid AlternateRegister::setAlternateGroups(QSharedPointer<QStringList> newAlternateGroups)\r\n{\r\n    alternateGroups_->clear();\r\n    alternateGroups_ = newAlternateGroups;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AlternateRegister::getModeReferences()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<QList<QSharedPointer<ModeReference> > > AlternateRegister::getModeReferences() const\r\n{\r\n    return modeReferences_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AlternateRegister::setModeReferences()\r\n//-----------------------------------------------------------------------------\r\nvoid AlternateRegister::setModeReferences(QSharedPointer<QList<QSharedPointer<ModeReference> > > newModeReferences)\r\n{\r\n    modeReferences_ = newModeReferences;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AlternateRegister::copyAlternateGroups()\r\n//-----------------------------------------------------------------------------\r\nvoid AlternateRegister::copyAlternateGroups(const AlternateRegister& other)\r\n{\r\n    for (auto const& group : *other.alternateGroups_)\r\n    {\r\n        alternateGroups_->append(group);\r\n    }\r\n}"
  },
  {
    "path": "IPXACTmodels/Component/AlternateRegister.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: AlternateRegister.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 28.09.2015\r\n//\r\n// Description:\r\n// Describes the ipxact:alternateRegister element.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef ALTERNATEREGISTER_H\r\n#define ALTERNATEREGISTER_H\r\n\r\n#include \"RegisterDefinition.h\"\r\n\r\n#include <IPXACTmodels/ipxactmodels_global.h>\r\n\r\n#include <QStringList>\r\n#include <QString>\r\n#include <QList>\r\n#include <QSharedPointer>\r\n\r\nclass ModeReference;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Describes the ipxact:alternateRegister element.\r\n//-----------------------------------------------------------------------------\r\nclass IPXACTMODELS_EXPORT AlternateRegister : public RegisterDefinition\r\n{\r\n\r\npublic:\r\n\r\n    /*!\r\n     *  The constructor.\r\n     *\r\n     *    @param [in] name            Name of the alternate register.\r\n     *    @param [in] alternateGroup  Name of the first alternate group.\r\n     */\r\n    AlternateRegister(QString const& name = QString(), QString const& alternateGroup = QString());\r\n\r\n\t//! Copy constructor.\r\n\tAlternateRegister(const AlternateRegister& other);\r\n\r\n\t//! Assignment operator.\r\n\tAlternateRegister& operator=(const AlternateRegister& other);\r\n\r\n\t//! The destructor.\r\n\tvirtual ~AlternateRegister();\r\n\r\n\t/*!\r\n     *  Clone the alternate register and return pointer to the copy.\r\n\t * \r\n\t *    @return Pointer to the cloned alternate register.\r\n\t */\r\n    virtual QSharedPointer<RegisterBase> clone();\r\n\t/*!\r\n     *  Get the list of the alternate groups.\r\n\t *\r\n\t *    @return A QList containing the names of the groups.\r\n\t */\r\n    QSharedPointer<QStringList> getAlternateGroups() const;\r\n\r\n\t/*!\r\n     *  Set the alternateGroups for this alternateRegister.\r\n\t *\r\n\t *    @param [in] newAlternateGroups  A QList containing names of the new groups.\r\n\t */\r\n    void setAlternateGroups(QSharedPointer<QStringList> newAlternateGroups);\r\n\r\n    /*!\r\n     *\tGet the mode references of the alternate register.\r\n     *  \r\n     * \t    @return Pointer to a list containing the mode references of the alternate register\r\n     */\r\n    QSharedPointer<QList<QSharedPointer<ModeReference> > > getModeReferences() const;\r\n\r\n    /*!\r\n     *\tSet the mode references of the alternate register.\r\n     *  \r\n     *    @param [in] newModeReferences     The mode references to set.\r\n     */\r\n    void setModeReferences(QSharedPointer<QList<QSharedPointer<ModeReference> > > newModeReferences);\r\n\r\nprivate:\r\n\r\n    /*!\r\n     *  Copy the alternate groups.\r\n     *\r\n     *    @param [in] other   The alternate register being copied.\r\n     */\r\n    void copyAlternateGroups(const AlternateRegister& other);\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n    \r\n    //! Contains the names of the alternateGroups.\r\n    QSharedPointer<QStringList> alternateGroups_;\r\n\r\n    //! The mode references of the alternate register.\r\n    QSharedPointer<QList<QSharedPointer<ModeReference> > > modeReferences_ =\r\n        QSharedPointer<QList<QSharedPointer<ModeReference> > >(new QList<QSharedPointer<ModeReference> >());\r\n};\r\n\r\n#endif // ALTERNATEREGISTER_H\r\n"
  },
  {
    "path": "IPXACTmodels/Component/BuildCommand.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: BuildCommand.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 15.09.2015\r\n//\r\n// Description:\r\n// Describes the ipxact:buildCommand element.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"BuildCommand.h\"\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BuildCommand::BuildCommand()\r\n//-----------------------------------------------------------------------------\r\nBuildCommand::BuildCommand() :\r\nBuildModel(),\r\ntargetName_(),\r\nflagsAppend_()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BuildCommand::BuildCommand()\r\n//-----------------------------------------------------------------------------\r\nBuildCommand::BuildCommand(const BuildCommand &other) :\r\nBuildModel(other),\r\ntargetName_(other.targetName_),\r\nflagsAppend_(other.flagsAppend_)\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BuildCommand::BuildCommand()\r\n//-----------------------------------------------------------------------------\r\nBuildCommand & BuildCommand::operator=(const BuildCommand &other)\r\n{\r\n    if (this != &other)\r\n    {\r\n        BuildModel::operator =(other);\r\n        targetName_ = other.targetName_;\r\n        flagsAppend_ = other.flagsAppend_;\r\n    }\r\n\r\n    return *this;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BuildCommand::~BuildCommand()\r\n//-----------------------------------------------------------------------------\r\nBuildCommand::~BuildCommand()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BuildCommand::getTargetName()\r\n//-----------------------------------------------------------------------------\r\nQString BuildCommand::getTargetName() const\r\n{\r\n    return targetName_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BuildCommand::setTargetName()\r\n//-----------------------------------------------------------------------------\r\nvoid BuildCommand::setTargetName(const QString &targetName)\r\n{\r\n    targetName_ = targetName;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BuildCommand::isFlagsAppend()\r\n//-----------------------------------------------------------------------------\r\nQString BuildCommand::getFlagsAppend() const\r\n{\r\n    return flagsAppend_.toString();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BuildCommand::setFlagsAppend()\r\n//-----------------------------------------------------------------------------\r\nvoid BuildCommand::setFlagsAppend(bool newAppend)\r\n{\r\n    flagsAppend_.setValue(newAppend);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BuildCommand::clearFlagsAppend()\r\n//-----------------------------------------------------------------------------\r\nvoid BuildCommand::clearFlagsAppend()\r\n{\r\n    flagsAppend_.setUnspecified();\r\n}\r\n"
  },
  {
    "path": "IPXACTmodels/Component/BuildCommand.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: BuildCommand.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 15.09.2015\r\n//\r\n// Description:\r\n// Describes the ipxact:buildCommand element.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef BUILDCOMMAND_H\r\n#define BUILDCOMMAND_H\r\n\r\n#include <IPXACTmodels/common/BuildModel.h>\r\n#include <IPXACTmodels/ipxactmodels_global.h>\r\n\r\n#include <IPXACTmodels/common/BooleanValue.h>\r\n\r\n#include <QString>\r\n#include <QMap>\r\n//-----------------------------------------------------------------------------\r\n//! Contains flags or commands for building the containing source file types.\r\n//-----------------------------------------------------------------------------\r\nclass IPXACTMODELS_EXPORT BuildCommand : public BuildModel\r\n{\r\n\r\npublic:\r\n\r\n    //! Default constructor.\r\n\tBuildCommand();\r\n\r\n\t//! The copy constructor.\r\n\tBuildCommand(const BuildCommand &other);\r\n\r\n\t//! The assignment operator.\r\n\tBuildCommand &operator=(const BuildCommand &other);\r\n\r\n    //! The destructor.\r\n\tvirtual ~BuildCommand();\r\n\r\n    /*!\r\n     *  Get the target name.\r\n     *\r\n     *    @return The target name.\r\n     */\r\n    QString getTargetName() const;\r\n\r\n\t/*!\r\n\t *  Set the target name.\r\n\t *\r\n\t *    @param [in] targetName  The new name of the target.\r\n\t */\r\n\tvoid setTargetName(const QString &targetName);\r\n\r\n    /*!\r\n     *  Get the flags append value.\r\n     *\r\n     *    @return QString containing true for boolean true, false for false and empty for an unspecified.\r\n     */\r\n    QString getFlagsAppend() const;\r\n\r\n    /*!\r\n     *  Set a new boolean value for the flags append.\r\n     *\r\n     *    @param [in] newAppend   The new flags append value.\r\n     */\r\n    void setFlagsAppend(bool newAppend);\r\n\r\n    /*!\r\n     *  Set the flags append to unspecified.\r\n     */\r\n    void clearFlagsAppend();\r\n\r\nprivate:\r\n\r\n    //! Defines the path to the file derived from the source file.\r\n\tQString targetName_;\r\n\r\n    //! Indicates whether the flags shall be appended to the current flags or replace them.\r\n    BooleanValue flagsAppend_;\r\n};\r\n\r\n#endif // BUILDCOMMAND_H\r\n"
  },
  {
    "path": "IPXACTmodels/Component/BusInterface.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: BusInterface.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: \r\n// Date:\r\n//\r\n// Description:\r\n// Describes the ipxact:busInterface element.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"BusInterface.h\"\r\n\r\n#include \"InitiatorInterface.h\"\r\n#include \"MirroredTargetInterface.h\"\r\n#include \"TargetInterface.h\"\r\n#include \"PortMap.h\"\r\n\r\n#include <IPXACTmodels/generaldeclarations.h>\r\n#include <IPXACTmodels/common/VendorExtension.h>\r\n\r\n#include <IPXACTmodels/kactusExtensions/Kactus2Position.h>\r\n\r\n#include <QString>\r\n#include <QList>\r\n#include <QSharedPointer>\r\n#include <QObject>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusInterface::MonitorInterface::MonitorInterface()\r\n//-----------------------------------------------------------------------------\r\nBusInterface::MonitorInterface::MonitorInterface()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusInterface::BusInterface()\r\n//-----------------------------------------------------------------------------\r\nBusInterface::BusInterface() :\r\n    NameGroup(),\r\n    Extendable()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusInterface::BusInterface()\r\n//-----------------------------------------------------------------------------\r\nBusInterface::BusInterface(const BusInterface& other) :\r\n    NameGroup(other),\r\n    Extendable(other),\r\n    isPresent_(other.isPresent_),\r\n    attributes_(other.attributes_),\r\n    busType_(other.busType_),\r\n    interfaceMode_(other.interfaceMode_),\r\n    connectionRequired_(other.connectionRequired_),\r\n    bitsInLau_(other.bitsInLau_),\r\n    bitSteering_(other.bitSteering_),\r\n    bitSteeringAttributes_(other.bitSteeringAttributes_),\r\n    endianness_(other.endianness_),\r\n    systemGroup_(other.systemGroup_)\r\n{\r\n    copyAbstractionTypes(other);\r\n    copyParameters(other);\r\n    copyInterfaceModes(other);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusInterface::operator=()\r\n//-----------------------------------------------------------------------------\r\nBusInterface& BusInterface::operator=(const BusInterface& other)\r\n{\r\n    if (this != &other)\r\n    {\r\n        NameGroup::operator=(other);\r\n        Extendable::operator=(other);\r\n        attributes_ = other.attributes_;\r\n        busType_ = other.busType_;\r\n        interfaceMode_ = other.interfaceMode_;\r\n        connectionRequired_ = other.connectionRequired_;\r\n        bitsInLau_ = other.bitsInLau_;\r\n        bitSteering_ = other.bitSteering_;\r\n        bitSteeringAttributes_ = other.bitSteeringAttributes_;\r\n        endianness_ = other.endianness_;\r\n        systemGroup_ = other.systemGroup_;\r\n\r\n        abstractionTypes_->clear();\r\n        copyAbstractionTypes(other);\r\n\r\n        parameters_->clear();\r\n        copyParameters(other);\r\n\r\n        copyInterfaceModes(other);\r\n    }\r\n    return *this;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusInterface::~BusInterface()\r\n//-----------------------------------------------------------------------------\r\nBusInterface::~BusInterface()\r\n{\r\n    abstractionTypes_.clear();\r\n    bitSteeringAttributes_.clear();\r\n    parameters_.clear();\r\n    initiator_.clear();\r\n    target_.clear();\r\n    monitor_.clear();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusInterface::getIsPresent()\r\n//-----------------------------------------------------------------------------\r\nQString BusInterface::getIsPresent() const\r\n{\r\n    return isPresent_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusInterface::setIsPresent()\r\n//-----------------------------------------------------------------------------\r\nvoid BusInterface::setIsPresent(QString const& newIsPresent)\r\n{\r\n    isPresent_ = newIsPresent;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusInterface::getBitSteering()\r\n//-----------------------------------------------------------------------------\r\nQString BusInterface::getBitSteering() const\r\n{\r\n    return bitSteering_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusInterface::getInterfaceMode()\r\n//-----------------------------------------------------------------------------\r\nGeneral::InterfaceMode BusInterface::getInterfaceMode() const\r\n{\r\n    return interfaceMode_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusInterface::setAbstractionTypes()\r\n//-----------------------------------------------------------------------------\r\nvoid BusInterface::setAbstractionTypes(QSharedPointer<QList<QSharedPointer<AbstractionType> > > abstractionTypes)\r\n{\r\n    abstractionTypes_->clear();\r\n    abstractionTypes_ = abstractionTypes;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusInterface::setConnectionRequired()\r\n//-----------------------------------------------------------------------------\r\nvoid BusInterface::setConnectionRequired(bool connectionRequired)\r\n{\r\n    connectionRequired_.setValue(connectionRequired);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusInterface::clearConnectionRequired()\r\n//-----------------------------------------------------------------------------\r\nvoid BusInterface::clearConnectionRequired()\r\n{\r\n    connectionRequired_.setUnspecified();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusInterface::setEndianness()\r\n//-----------------------------------------------------------------------------\r\nvoid BusInterface::setEndianness(BusInterface::Endianness endianness)\r\n{\r\n    endianness_ = endianness;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusInterface::getBitsInLau()\r\n//-----------------------------------------------------------------------------\r\nQString BusInterface::getBitsInLau() const\r\n{\r\n    return bitsInLau_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusInterface::getConnectionRequired()\r\n//-----------------------------------------------------------------------------\r\nQString BusInterface::getConnectionRequired() const\r\n{\r\n    return connectionRequired_.toString();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusInterface::setBitsInLau()\r\n//-----------------------------------------------------------------------------\r\nvoid BusInterface::setBitsInLau(QString const& newBitsInLau)\r\n{\r\n    bitsInLau_ = newBitsInLau;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusInterface::getParameters()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<QList<QSharedPointer<Parameter> > > BusInterface::getParameters() const\r\n{\r\n    return parameters_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusInterface::getAbstractionTypes()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<QList<QSharedPointer<AbstractionType> > > BusInterface::getAbstractionTypes() const\r\n{\r\n    return abstractionTypes_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusInterface::setBitSteeringAttributes()\r\n//-----------------------------------------------------------------------------\r\nvoid BusInterface::setBitSteeringAttributes(QMap<QString, QString> const& bitSteeringAttributes)\r\n{\r\n    bitSteeringAttributes_.clear();\r\n    bitSteeringAttributes_ = bitSteeringAttributes;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusInterface::getBusType()\r\n//-----------------------------------------------------------------------------\r\nConfigurableVLNVReference BusInterface::getBusType() const\r\n{\r\n    return busType_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusInterface::getBitSteeringAttributes()\r\n//-----------------------------------------------------------------------------\r\nQMap<QString, QString> BusInterface::getBitSteeringAttributes()\r\n{\r\n    return bitSteeringAttributes_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusInterface::getEndianness()\r\n//-----------------------------------------------------------------------------\r\nBusInterface::Endianness BusInterface::getEndianness() const\r\n{\r\n    return endianness_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusInterface::setInterfaceMode()\r\n//-----------------------------------------------------------------------------\r\nvoid BusInterface::setInterfaceMode(General::InterfaceMode interfaceMode)\r\n{\r\n    interfaceMode_ = interfaceMode;\r\n\r\n    if (interfaceMode == General::MASTER || interfaceMode == General::INITIATOR)\r\n    {\r\n        monitor_.clear();\r\n        target_.clear();\r\n        systemGroup_.clear();\r\n        mirroredTarget_.clear();\r\n        if (!initiator_)\r\n        {\r\n            initiator_ = QSharedPointer<InitiatorInterface>(new InitiatorInterface());\r\n        }\r\n    }\r\n    else if (interfaceMode == General::SLAVE || interfaceMode == General::TARGET)\r\n    {\r\n        monitor_.clear();\r\n        initiator_.clear();\r\n        systemGroup_.clear();\r\n        mirroredTarget_.clear();\r\n        if (!target_)\r\n        {\r\n            target_ = QSharedPointer<TargetInterface>(new TargetInterface());\r\n        }\r\n    }\r\n    else if (interfaceMode == General::SYSTEM)\r\n    {\r\n        monitor_.clear();\r\n        target_.clear();\r\n        initiator_.clear();\r\n        mirroredTarget_.clear();\r\n        systemGroup_ = QStringLiteral(\"default\");\r\n    }\r\n    else if (interfaceMode == General::MIRRORED_SLAVE || interfaceMode == General::MIRRORED_TARGET)\r\n    {\r\n        monitor_.clear();\r\n        target_.clear();\r\n        initiator_.clear();\r\n        systemGroup_.clear();\r\n        if (!mirroredTarget_)\r\n        {\r\n            mirroredTarget_ = QSharedPointer<MirroredTargetInterface>(new MirroredTargetInterface());\r\n        }\r\n    }\r\n    else if (interfaceMode == General::MIRRORED_MASTER || interfaceMode == General::MIRRORED_INITIATOR)\r\n    {\r\n        monitor_.clear();\r\n        target_.clear();\r\n        systemGroup_.clear();\r\n        mirroredTarget_.clear();\r\n        initiator_.clear();\r\n    }\r\n    else if (interfaceMode == General::MIRRORED_SYSTEM)\r\n    {\r\n        monitor_.clear();\r\n        target_.clear();\r\n        initiator_.clear();\r\n        mirroredTarget_.clear();\r\n        systemGroup_ = QStringLiteral(\"default\");\r\n    }\r\n    else if (interfaceMode == General::MONITOR)\r\n    {\r\n        target_.clear();\r\n        initiator_.clear();\r\n        systemGroup_.clear();\r\n        mirroredTarget_.clear();\r\n        if (!monitor_)\r\n        {\r\n            monitor_ = QSharedPointer<MonitorInterface>(new MonitorInterface());\r\n        }\r\n    }\r\n    else\r\n    {\r\n        monitor_.clear();\r\n        target_.clear();\r\n        initiator_.clear();\r\n        systemGroup_.clear();\r\n        mirroredTarget_.clear();\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusInterface::setBusType()\r\n//-----------------------------------------------------------------------------\r\nvoid BusInterface::setBusType(ConfigurableVLNVReference const& newBusType)\r\n{\r\n    busType_ = newBusType;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusInterface::setBitSteering()\r\n//-----------------------------------------------------------------------------\r\nvoid BusInterface::setBitSteering(QString const& bitSteering)\r\n{\r\n    bitSteering_ = bitSteering;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusInterface::getMaster()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<InitiatorInterface> BusInterface::getMaster() const\r\n{\r\n    return getInitiator();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusInterface::setMaster()\r\n//-----------------------------------------------------------------------------\r\nvoid BusInterface::setMaster(QSharedPointer<InitiatorInterface> master)\r\n{\r\n    setInitiator(master);\r\n    interfaceMode_ = General::MASTER;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusInterface::getInitiator()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<InitiatorInterface> BusInterface::getInitiator() const\r\n{\r\n    return initiator_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusInterface::setInitiator()\r\n//-----------------------------------------------------------------------------\r\nvoid BusInterface::setInitiator(QSharedPointer<InitiatorInterface> initiator)\r\n{\r\n    monitor_.clear();\r\n    target_.clear();\r\n    initiator_.clear();\r\n    systemGroup_.clear();\r\n    mirroredTarget_.clear();\r\n\r\n    interfaceMode_ = General::INITIATOR;\r\n    initiator_ = initiator;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusInterface::getSlave()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<TargetInterface> BusInterface::getSlave() const\r\n{\r\n    return target_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusInterface::setSlave()\r\n//-----------------------------------------------------------------------------\r\nvoid BusInterface::setSlave(QSharedPointer<TargetInterface> slave)\r\n{\r\n    setTarget(slave);\r\n    interfaceMode_ = General::SLAVE;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusInterface::getTarget()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<TargetInterface> BusInterface::getTarget() const\r\n{\r\n    return target_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusInterface::setSlave()\r\n//-----------------------------------------------------------------------------\r\nvoid BusInterface::setTarget(QSharedPointer<TargetInterface> target)\r\n{\r\n    monitor_.clear();\r\n    target_.clear();\r\n    initiator_.clear();\r\n    systemGroup_.clear();\r\n    mirroredTarget_.clear();\r\n\r\n    interfaceMode_ = General::TARGET;\r\n    target_ = target;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusInterface::getSystem()\r\n//-----------------------------------------------------------------------------\r\nQString BusInterface::getSystem() const\r\n{\r\n    return systemGroup_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusInterface::setSystem()\r\n//-----------------------------------------------------------------------------\r\nvoid BusInterface::setSystem(QString const& systemGroupName)\r\n{\r\n    monitor_.clear();\r\n    target_.clear();\r\n    initiator_.clear();\r\n    systemGroup_.clear();\r\n    mirroredTarget_.clear();\r\n\r\n    systemGroup_ = systemGroupName;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusInterface::getMonitor()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<BusInterface::MonitorInterface> BusInterface::getMonitor() const\r\n{\r\n    return monitor_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusInterface::setMonitor()\r\n//-----------------------------------------------------------------------------\r\nvoid BusInterface::setMonitor(QSharedPointer<BusInterface::MonitorInterface> monitor)\r\n{\r\n    monitor_.clear();\r\n    target_.clear();\r\n    initiator_.clear();\r\n    systemGroup_.clear();\r\n    mirroredTarget_.clear();\r\n\r\n    interfaceMode_ = General::MONITOR;\r\n    monitor_ = monitor;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusInterface::getMirroredSlave()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<MirroredTargetInterface> BusInterface::getMirroredSlave() const\r\n{\r\n    return getMirroredTarget();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusInterface::setMirroredSlave()\r\n//-----------------------------------------------------------------------------\r\nvoid BusInterface::setMirroredSlave(QSharedPointer<MirroredTargetInterface> mirroredSlave)\r\n{\r\n    setMirroredTarget(mirroredSlave);\r\n    interfaceMode_ = General::MIRRORED_SLAVE;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusInterface::getMirroredTarget()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<MirroredTargetInterface> BusInterface::getMirroredTarget() const\r\n{\r\n    return mirroredTarget_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusInterface::setMirroredTarget()\r\n//-----------------------------------------------------------------------------\r\nvoid BusInterface::setMirroredTarget(QSharedPointer<MirroredTargetInterface> mirroredTarget)\r\n{\r\n    monitor_.clear();\r\n    target_.clear();\r\n    initiator_.clear();\r\n    systemGroup_.clear();\r\n    mirroredTarget_.clear();\r\n\r\n    interfaceMode_ = General::MIRRORED_TARGET;\r\n    mirroredTarget_ = mirroredTarget;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusInterface::hasTransparentBridge()\r\n//-----------------------------------------------------------------------------\r\nbool BusInterface::hasTransparentBridge() const\r\n{\r\n    if (!target_)\r\n    {\r\n        return false;\r\n    }\r\n\r\n    return target_->hasTransparentBridge();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusInterface::getAttributes()\r\n//-----------------------------------------------------------------------------\r\nQMap<QString, QString> BusInterface::getAttributes() const\r\n{\r\n    return attributes_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusInterface::setAttributes()\r\n//-----------------------------------------------------------------------------\r\nvoid BusInterface::setAttributes(QMap<QString, QString> const& attributes)\r\n{\r\n    attributes_ = attributes;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusInterface::containsMappedPhysicalPort()\r\n//-----------------------------------------------------------------------------\r\nbool BusInterface::containsMappedPhysicalPort(QString const& portName) const\r\n{\r\n    if (abstractionTypes_)\r\n    {\r\n        for (QSharedPointer<AbstractionType> abstraction : *abstractionTypes_)\r\n        {\r\n            if (abstraction->hasPhysicalPort(portName))\r\n            {\r\n                return true;\r\n            }\r\n        }\r\n    }\r\n\r\n    return false;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusInterface::containsMappedlogicalPort()\r\n//-----------------------------------------------------------------------------\r\nbool BusInterface::containsMappedlogicalPort(QString const& portName) const\r\n{\r\n    if (abstractionTypes_)\r\n    {\r\n        for (QSharedPointer<AbstractionType> abstraction : *abstractionTypes_)\r\n        {\r\n            if (abstraction->hasLogicalPort(portName))\r\n            {\r\n                return true;\r\n            }\r\n        }\r\n    }\r\n\r\n    return false;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusInterface::getAllMappedPhysicalPorts()\r\n//-----------------------------------------------------------------------------\r\nQStringList BusInterface::getAllMappedPhysicalPorts() const\r\n{\r\n    QStringList portNames;\r\n\r\n    for (QSharedPointer<AbstractionType> abstraction : *abstractionTypes_)\r\n    {\r\n        for (QString const& port : abstraction->getPhysicalPortNames())\r\n        {\r\n            portNames.append(port);\r\n        }\r\n    }\r\n\r\n    return portNames;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusInterface::getAllPortMaps()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<QList<QSharedPointer<PortMap> > > BusInterface::getAllPortMaps() const\r\n{\r\n    QSharedPointer<QList<QSharedPointer<PortMap> > > containedPortMaps(new QList<QSharedPointer<PortMap> >());\r\n\r\n    for (QSharedPointer<AbstractionType> abstraction : *abstractionTypes_)\r\n    {\r\n        for (QSharedPointer<PortMap> portMap : *abstraction->getPortMaps())\r\n        {\r\n            containedPortMaps->append(portMap);\r\n        }\r\n    }\r\n\r\n    return containedPortMaps;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusInterface::getPortMapsForView()\r\n//-----------------------------------------------------------------------------\r\nQList<QSharedPointer<PortMap> > BusInterface::getPortMapsForView(QString const& view) const\r\n{\r\n    QList<QSharedPointer<PortMap> > portMaps;\r\n\r\n    for (QSharedPointer<AbstractionType> abstraction : *abstractionTypes_)\r\n    {\r\n        if (abstraction->getViewReferences()->isEmpty() || abstraction->getViewReferences()->contains(view))\r\n        {\r\n            for (QSharedPointer<PortMap> abstractionMap : *abstraction->getPortMaps())\r\n            {\r\n                portMaps.append(abstractionMap);\r\n            }\r\n        }\r\n    }\r\n\r\n    return portMaps;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusInterface::getAbstractionContainingView()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<AbstractionType> BusInterface::getAbstractionContainingView(QString const& view) const\r\n{\r\n    for (QSharedPointer<AbstractionType> abstraction : *abstractionTypes_)\r\n    {\r\n        if (abstraction->getViewReferences()->isEmpty() || abstraction->getViewReferences()->contains(view))\r\n        {\r\n            return abstraction;\r\n        }\r\n    }\r\n\r\n    return QSharedPointer<AbstractionType>();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusInterface::clearAllPortMaps()\r\n//-----------------------------------------------------------------------------\r\nvoid BusInterface::clearAllPortMaps()\r\n{\r\n    if (abstractionTypes_)\r\n    {\r\n        for (QSharedPointer<AbstractionType> abstraction : *abstractionTypes_)\r\n        {\r\n            abstraction->getPortMaps()->clear();\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: setMCAPIPortID()\r\n//-----------------------------------------------------------------------------\r\nvoid BusInterface::setMCAPIPortID(int portID)\r\n{\r\n    for (QSharedPointer<Parameter> param : *parameters_)\r\n    {\r\n        if (param->name() == QLatin1String(\"kts_port_id\"))\r\n        {\r\n            param->setValue(QString::number(portID));\r\n            return;\r\n        }\r\n    }\r\n\r\n    QSharedPointer<Parameter> param(new Parameter());\r\n    param->setName(QStringLiteral(\"kts_port_id\"));\r\n    param->setValue(QString::number(portID));\r\n    parameters_->append(param);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: getMCAPIPortID()\r\n//-----------------------------------------------------------------------------\r\nint BusInterface::getMCAPIPortID() const\r\n{\r\n    for (QSharedPointer<Parameter> param : *parameters_)\r\n    {\r\n        if (param->name() == QLatin1String(\"kts_port_id\"))\r\n        {\r\n            return param->getValue().toInt();\r\n        }\r\n    }\r\n\r\n    return -1;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusInterface::getMemoryMapRef()\r\n//-----------------------------------------------------------------------------\r\nQString BusInterface::getMemoryMapRef() const\r\n{\r\n    if ((interfaceMode_ != General::SLAVE && interfaceMode_ != General::TARGET) || !target_)\r\n    {\r\n        return QString();\r\n    }\r\n    else\r\n    {\r\n        return target_->getMemoryMapRef();\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusInterface::getAddressSpaceRef()\r\n//-----------------------------------------------------------------------------\r\nQString BusInterface::getAddressSpaceRef() const\r\n{\r\n    if (interfaceMode_ == General::MASTER || interfaceMode_ == General::MIRRORED_MASTER ||\r\n        interfaceMode_ == General::INITIATOR || interfaceMode_ == General::MIRRORED_INITIATOR)\r\n    {\r\n        if (!initiator_)\r\n        {\r\n            return QString();\r\n        }\r\n        else\r\n        {\r\n            return initiator_->getAddressSpaceRef();\r\n        }\r\n    }\r\n    else\r\n    {\r\n        return QString();\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusInterface::setDefaultPos()\r\n//-----------------------------------------------------------------------------\r\nvoid BusInterface::setDefaultPos(QPointF const& pos)\r\n{\r\n    for (QSharedPointer<VendorExtension> extension : *getVendorExtensions())\r\n    {\r\n        if (extension->type() == QLatin1String(\"kactus2:position\"))\r\n        {\r\n            getVendorExtensions()->removeAll(extension);\r\n        }\r\n    }\r\n\r\n    if (!pos.isNull())\r\n    {\r\n        QSharedPointer<Kactus2Position> newDefaultPosition(new Kactus2Position(pos));\r\n        getVendorExtensions()->append(newDefaultPosition);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusInterface::getDefaultPos()\r\n//-----------------------------------------------------------------------------\r\nQPointF BusInterface::getDefaultPos()\r\n{\r\n    for (QSharedPointer<VendorExtension> extension : *getVendorExtensions())\r\n    {\r\n        if (extension->type() == QLatin1String(\"kactus2:position\"))\r\n        {\r\n            QSharedPointer<Kactus2Position> defaultPosition = extension.dynamicCast<Kactus2Position>();\r\n            return defaultPosition->position();\r\n        }\r\n    }\r\n\r\n    return QPointF(0, 0);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusInterface::copyAbstractionTypes()\r\n//-----------------------------------------------------------------------------\r\nvoid BusInterface::copyAbstractionTypes(const BusInterface& other)\r\n{\r\n    for (QSharedPointer<AbstractionType> abstractionType : *other.abstractionTypes_)\r\n    {\r\n        QSharedPointer<AbstractionType> copy =\r\n            QSharedPointer<AbstractionType>(new AbstractionType(*abstractionType));\r\n        abstractionTypes_->append(copy);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusInterface::copyParameters()\r\n//-----------------------------------------------------------------------------\r\nvoid BusInterface::copyParameters(const BusInterface& other)\r\n{\r\n    for (QSharedPointer<Parameter> param : *other.parameters_)\r\n    {\r\n        QSharedPointer<Parameter> copy = QSharedPointer<Parameter>(new Parameter(*param));\r\n        parameters_->append(copy);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusInterface::copyInterfaceModes()\r\n//-----------------------------------------------------------------------------\r\nvoid BusInterface::copyInterfaceModes(const BusInterface& other)\r\n{\r\n    if (other.initiator_)\r\n    {\r\n        initiator_ = QSharedPointer<InitiatorInterface>(new InitiatorInterface(*other.initiator_));\r\n    }\r\n\r\n    if (other.target_)\r\n    {\r\n        target_ = QSharedPointer<TargetInterface>(new TargetInterface(*other.target_));\r\n    }\r\n\r\n    if (other.monitor_)\r\n    {\r\n        monitor_ = QSharedPointer<MonitorInterface>(new MonitorInterface(*other.monitor_));\r\n    }\r\n\r\n    if (other.mirroredTarget_)\r\n    {\r\n        mirroredTarget_ = QSharedPointer<MirroredTargetInterface>(new MirroredTargetInterface(*other.mirroredTarget_));\r\n    }\r\n}\r\n"
  },
  {
    "path": "IPXACTmodels/Component/BusInterface.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: businterface.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: \r\n// Date:\r\n//\r\n// Description:\r\n// Describes the ipxact:busInterface element.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef BUSINTERFACE_H\r\n#define BUSINTERFACE_H\r\n\r\n#include \"AbstractionType.h\"\r\n\r\n#include <IPXACTmodels/generaldeclarations.h>\r\n#include <IPXACTmodels/ipxactmodels_global.h>\r\n\r\n#include <IPXACTmodels/common/BooleanValue.h>\r\n#include <IPXACTmodels/common/ConfigurableVLNVReference.h>\r\n#include <IPXACTmodels/common/Extendable.h>\r\n#include <IPXACTmodels/common/NameGroup.h>\r\n#include <IPXACTmodels/common/Parameter.h>\r\n\r\n#include <IPXACTmodels/Component/InitiatorInterface.h>\r\n#include <IPXACTmodels/Component/TargetInterface.h>\r\n#include <IPXACTmodels/Component/MirroredTargetInterface.h>\r\n\r\n#include <QString>\r\n#include <QList>\r\n#include <QSharedPointer>\r\n#include <QMap>\r\n#include <QStringList>\r\n#include <QPointF>\r\n\r\nclass MonitorInterface;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Describes the ipxact:busInterface element.\r\n//-----------------------------------------------------------------------------\r\nclass IPXACTMODELS_EXPORT BusInterface : public NameGroup, public Extendable\r\n{\r\n\r\npublic:\r\n\r\n\t//! The endianness of a bus interface.\r\n\tenum Endianness\r\n\t{\r\n\t\tLITTLE,\r\n\t\tBIG,\r\n\t\tENDIANNESS_UNSPECIFIED\r\n\t};\r\n\r\n\t//! Implementation of the ipxact:monitor element.\r\n\tstruct MonitorInterface\r\n\t{\r\n\t\t//! Defines the interface mode for which this monitor interface can be connected to.\r\n\t\tGeneral::InterfaceMode interfaceMode_ = General::MONITOR;\r\n\r\n\t\t//! Defines the name of the system group for this monitor interface.\r\n\t\tQString group_;\r\n\r\n\t\t//! The default constructor.\r\n\t\tIPXACTMODELS_EXPORT MonitorInterface();\r\n\t};\r\n\r\n\t/*!\r\n\t *  Default constructor.\r\n\t */\r\n\tBusInterface();\r\n\r\n\t//! Copy constructor.\r\n\tBusInterface(const BusInterface& other);\r\n\r\n\t//! Assignment operator.\r\n\tBusInterface& operator=(const BusInterface& other);\r\n\r\n\t/*!\r\n\t *  The destructor.\r\n\t */\r\n\t~BusInterface();\r\n\r\n\t/*!\r\n\t *  Gets the presence.\r\n\t *\r\n\t *    @return The presence value.\r\n\t */\r\n\tQString getIsPresent() const;\r\n\r\n\t/*!\r\n\t *  Set the presence.\r\n\t *\r\n\t *    @param [in] newIsPresent    The new presence value.\r\n\t */\r\n\tvoid setIsPresent(QString const& newIsPresent);\r\n\r\n\t/*!\r\n\t *  Get the list of the bitSteering attributes.\r\n\t *\r\n\t *    @return A QMap containing the attributes for bitSteering element.\r\n\t */\r\n\tQMap<QString, QString> getBitSteeringAttributes();\r\n\r\n\t/*!\r\n\t *  Is the bitSteering on or off.\r\n\t *\r\n\t *    @return The bit of the bus interface.\r\n\t */\r\n\tQString getBitSteering() const;\r\n\r\n\t/*!\r\n\t *  Get bits in lau value.\r\n\t *\r\n\t *    @return The bits in lau value.\r\n\t */\r\n\tQString getBitsInLau() const;\r\n\r\n\t/*!\r\n\t *  Get the vlnv to the bus definition.\r\n\t *\r\n\t *    @return The vlnv tag of the bus definition that this bus interface references.\r\n\t */\r\n\tConfigurableVLNVReference getBusType() const;\r\n\r\n\t/*!\r\n\t *  Can this interface be left unconnected.\r\n\t *\r\n\t *    @return Qstring of true, false or empty. Empty means an unspecified requirement.\r\n\t */\r\n\tQString getConnectionRequired() const;\r\n\r\n\t/*!\r\n\t *  Get the endianness of the bus interface.\r\n\t *\r\n\t *    @return BIG, LITTLE or UNSPECIFIED.\r\n\t */\r\n\tEndianness getEndianness() const;\r\n\r\n\t/*!\r\n\t *  Get the mode of this interface.\r\n\t *\r\n\t *    @return The interface mode.\r\n\t */\r\n\tGeneral::InterfaceMode getInterfaceMode() const;\r\n\r\n\t/*!\r\n\t *  Get the parameters of the bus interface.\r\n\t *\r\n\t *    @return Pointer to a list holding the parameters for this interface.\r\n\t */\r\n\tQSharedPointer<QList<QSharedPointer<Parameter> > > getParameters() const;\r\n\r\n\t/*!\r\n\t *  Get the abstraction types for this interface.\r\n\t *\r\n\t *    @return Pointer to a list containing the abstraction types for this interface.\r\n\t */\r\n\tQSharedPointer<QList<QSharedPointer<AbstractionType> > > getAbstractionTypes() const;\r\n\r\n\t/*!\r\n\t *  Set the bit steering attributes for this interface.\r\n\t *\r\n\t *    @param [in] bitSteeringAttributes   A QMap holding the new attributes.\r\n\t */\r\n\tvoid setBitSteeringAttributes(QMap<QString, QString> const& bitSteeringAttributes);\r\n\r\n\t/*!\r\n\t *  Set the bit steering for this interface.\r\n\t *\r\n\t *    @param [in] bitSteering     The new bitSteering value.\r\n\t */\r\n\tvoid setBitSteering(QString const& bitSteering);\r\n\r\n\t/*!\r\n\t *  Set the bits in lau value.\r\n\t *\r\n\t *    @param [in] newBitsInLau    The new bits for the lau value.\r\n\t */\r\n\tvoid setBitsInLau(QString const& newBitsInLau);\r\n\r\n\t/*!\r\n\t *  Set the bus definition for this interface.\r\n\t *\r\n\t *    @param busType The vlnv of the bus definition.\r\n\t */\r\n\tvoid setBusType(ConfigurableVLNVReference const& newBusType);\r\n\r\n\t/*!\r\n\t *  Set the connectionRequired value.\r\n\t *\r\n\t *    @param [in] connectionRequired  True or false.\r\n\t */\r\n\tvoid setConnectionRequired(bool connectionRequired);\r\n\r\n\t/*!\r\n\t *  Set the connection requirement to unspecified.\r\n\t */\r\n\tvoid clearConnectionRequired();\r\n\r\n\t/*!\r\n\t *  Set the endianness for this interface.\r\n\t *\r\n\t *    @param [in] endianness  BIG, LITTLE or UNSPECIFIED.\r\n\t */\r\n\tvoid setEndianness(Endianness endianness);\r\n\r\n\t/*!\r\n\t *  Set the interface mode for this interface.\r\n\t *\r\n\t *    @param [in] interfaceMode   The new interface mode.\r\n\t */\r\n\tvoid setInterfaceMode(General::InterfaceMode interfaceMode);\r\n\r\n\t/*!\r\n\t *  Set the port maps for this interface.\r\n\t *\r\n\t *    @param [in] portMaps    Pointer to a list containing the port maps for this interface.\r\n\t */\r\n\tvoid setPortMaps(QSharedPointer<QList<QSharedPointer<PortMap> > > portMaps);\r\n\r\n\t/*!\r\n\t *  Set the port maps for this interface.\r\n\t *\r\n\t *    @param [in] abstractionTypes    Pointer to a list containing the abstraction types for this interface.\r\n\t */\r\n\tvoid setAbstractionTypes(QSharedPointer<QList<QSharedPointer<AbstractionType> > > abstractionTypes);\r\n\r\n\t/*!\r\n\t *  Get the pointer to the master-element.\r\n\t *\r\n\t *    @return A pointer to the master-instance of the interface.\r\n\t */\r\n\tQSharedPointer<InitiatorInterface> getMaster() const;\r\n\r\n\t/*!\r\n\t *  Set the master element for this interface.\r\n\t *\r\n\t *    @param [in] master  A pointer to the new master interface.\r\n\t */\r\n\tvoid setMaster(QSharedPointer<InitiatorInterface> master);\r\n\r\n\t/*!\r\n\t *  Get the pointer to the initiator-element.\r\n\t *\r\n\t *    @return A pointer to the initiator-instance of the interface.\r\n\t */\r\n\tQSharedPointer<InitiatorInterface> getInitiator() const;\r\n\r\n\tvoid setInitiator(QSharedPointer<InitiatorInterface> initiator);\r\n\r\n\t/*!\r\n\t *  Get the pointer to the monitor interface.\r\n\t *\r\n\t *    @return A pointer to the monitor interface.\r\n\t */\r\n\tQSharedPointer<MonitorInterface> getMonitor() const;\r\n\r\n\t/*!\r\n\t *  Set the monitor element for this interface.\r\n\t *\r\n\t *    @param [in] monitor     A pointer to the new monitor instance.\r\n\t */\r\n\tvoid setMonitor(QSharedPointer<MonitorInterface> monitor);\r\n\r\n\t/*!\r\n\t *  Get the pointer to the slave instance of the interface.\r\n\t *\r\n\t *    @return A pointer to the slave instance of the interface.\r\n\t */\r\n\tQSharedPointer<TargetInterface> getSlave() const;\r\n\r\n\t/*!\r\n\t *  Set the slave element for this interface.\r\n\t *\r\n\t *    @param [in] slave   A pointer to the new slave interface.\r\n\t */\r\n\tvoid setSlave(QSharedPointer<TargetInterface> slave);\r\n\r\n\tQSharedPointer<TargetInterface> getTarget() const;\r\n\tvoid setTarget(QSharedPointer<TargetInterface> target);\r\n\t/*!\r\n\t *  Get the system group name.\r\n\t *\r\n\t *    @return The system group name.\r\n\t */\r\n\tQString getSystem() const;\r\n\r\n\t/*!\r\n\t *  Set the system element for this interface.\r\n\t *\r\n\t *    @param [in] systemGroupName  The name of the system group to set.\r\n\t */\r\n\tvoid setSystem(QString const& systemGroupName);\r\n\r\n\t/*!\r\n\t *  Get the pointer to the mirroredSlace element\r\n\t *\r\n\t *    @return A pointer to the mirroredSlave element of this interface.\r\n\t */\r\n\tQSharedPointer<MirroredTargetInterface> getMirroredSlave() const;\r\n\r\n\t/*!\r\n\t *  Set the mirroredSlave element for this interface.\r\n\t *\r\n\t *    @param [in] mirroredSlave   A pointer to the new mirroredSlave instance.\r\n\t */\r\n\tvoid setMirroredSlave(QSharedPointer<MirroredTargetInterface> mirroredSlave);\r\n\r\n\t/*!\r\n\t *  Get the pointer to the mirroredTarget element\r\n\t *\r\n\t *    @return A pointer to the mirroredTarget element of this interface.\r\n\t */\r\n\tQSharedPointer<MirroredTargetInterface> getMirroredTarget() const;\r\n\r\n\t/*!\r\n\t *  Set the mirroredTarget element for this interface.\r\n\t *\r\n\t *    @param [in] mirroredTarget   A pointer to the new mirroredTarget instance.\r\n\t */\r\n\tvoid setMirroredTarget(QSharedPointer<MirroredTargetInterface> mirroredTarget);\r\n\r\n\t/*!\r\n\t *  Does this bus interface have a transparent bridge element defined.\r\n\t *\r\n\t *    @return True if a bridge is found, otherwise false.\r\n\t */\r\n\tbool hasTransparentBridge() const;\r\n\r\n\t/*!\r\n\t *  Get the attributes of the bus interface.\r\n\t *\r\n\t *    @return QMap containing the attributes.\r\n\t */\r\n\tQMap<QString, QString> getAttributes() const;\r\n\r\n\t/*!\r\n\t *  Set the attributes for the bus interface.\r\n\t *\r\n\t *    @param [in] attributes  QMap containing the attributes.\r\n\t */\r\n\tvoid setAttributes(QMap<QString, QString> const& attributes);\r\n\r\n\t/*!\r\n\t *  Check if the selected physical port has been mapped in the bus interface.\r\n\t *\r\n\t *    @param [in] portName    Name of the selected physical port.\r\n\t *\r\n\t *    @return True, if the physical port has been mapped, false otherwise.\r\n\t */\r\n\tbool containsMappedPhysicalPort(QString const& portName) const;\r\n\r\n\t/*!\r\n\t *  Check if the selected logical port has been mapped in the bus interface.\r\n\t *\r\n\t *    @param [in] portName    Name of the selected logical port.\r\n\t *\r\n\t *    @return True, if the selected logical port has been mapped in the bus interface.\r\n\t */\r\n\tbool containsMappedlogicalPort(QString const& portName) const;\r\n\r\n\t/*!\r\n\t *  Get the names of all the mapped physical ports.\r\n\t *\r\n\t *    @return A list of the names of all the mapped physical ports.\r\n\t */\r\n\tQStringList getAllMappedPhysicalPorts() const;\r\n\r\n\t/*!\r\n\t *  Get the port maps.\r\n\t *\r\n\t *    @return A list containing all the port maps.\r\n\t */\r\n\tQSharedPointer<QList<QSharedPointer<PortMap> > > getAllPortMaps() const;\r\n\r\n\t/*!\r\n\t *  Get all the port maps contained within the abstraction type with the selected view reference.\r\n\t *\r\n\t *    @param [in] view    Name of the view referenced by the selected abstraction type.\r\n\t *\r\n\t *    @return Port maps contained within the abstraction type referencing the selected view.\r\n\t */\r\n\tQList<QSharedPointer<PortMap> > getPortMapsForView(QString const& view) const;\r\n\r\n\t/*!\r\n\t *  Get the abstraction type referencing the selected view.\r\n\t *\r\n\t *    @param [in] view    Name of the selected view referenced by the abstraction type.\r\n\t *\r\n\t *    @return The abstraction type referencing the selected view.\r\n\t */\r\n\tQSharedPointer<AbstractionType> getAbstractionContainingView(QString const& view) const;\r\n\r\n\t/*!\r\n\t *  Remove all of the port maps contained within all of the abstraction types.\r\n\t */\r\n\tvoid clearAllPortMaps();\r\n\r\n\t/*!\r\n\t *  Sets the MCAPI port ID to the bus interface's parameters.\r\n\t */\r\n\tvoid setMCAPIPortID(int portID);\r\n\r\n\t/*!\r\n\t *  Returns the MCAPI port ID, or -1 if not set.\r\n\t */\r\n\tint getMCAPIPortID() const;\r\n\r\n\t/*!\r\n\t *  Sets the default position in the parent component's graphical representation.\r\n\t *\r\n\t *    @param [in] pos The position to set.\r\n\t */\r\n\tvoid setDefaultPos(QPointF const& pos);\r\n\r\n\t/*!\r\n\t *  Returns the default position in the parent component's graphical representation.\r\n\t *\r\n\t *    @return The default position.\r\n\t */\r\n\tQPointF getDefaultPos();\r\n\r\n\t/*!\r\n\t *  Get the memory map reference of a slave interface.\r\n\t *\r\n\t *    @return The name of the memory map referenced by slave interface.\r\n\t */\r\n\tQString getMemoryMapRef() const;\r\n\r\n\t/*!\r\n\t *  Get the address space reference of a master or mirrored master interface.\r\n\t *\r\n\t *    @return The name of the address space referenced by interface.\r\n\t */\r\n\tQString getAddressSpaceRef() const;\r\n\r\nprivate:\r\n\r\n\t/*!\r\n\t *  Copy the abstraction types.\r\n\t *\r\n\t *    @param [in] other   The bus interface being copied.\r\n\t */\r\n\tvoid copyAbstractionTypes(const BusInterface& other);\r\n\r\n\t/*!\r\n\t *  Copy the parameters.\r\n\t *\r\n\t *    @param [in] other   The bus interface being copied.\r\n\t */\r\n\tvoid copyParameters(const BusInterface& other);\r\n\r\n\t/*!\r\n\t *  Copy the interface modes.\r\n\t *\r\n\t *    @param [in] other   The bus interface being copied.\r\n\t */\r\n\tvoid copyInterfaceModes(const BusInterface& other);\r\n\r\n\t//-----------------------------------------------------------------------------\r\n\t// Data.\r\n\t//-----------------------------------------------------------------------------\r\n\r\n\t//! Presence of the businterface.\r\n\tQString isPresent_;\r\n\r\n\t//! Contains the attributes for the bus interface.\r\n\tQMap<QString, QString> attributes_;\r\n\r\n\t//! The vlnv of the bus definition this bus interface is referenced.\r\n\tConfigurableVLNVReference busType_;\r\n\r\n\t//! List of abstraction types existing within this object.\r\n\tQSharedPointer<QList<QSharedPointer<AbstractionType> > > abstractionTypes_ =\r\n\t\tQSharedPointer<QList<QSharedPointer<AbstractionType> > >(new QList<QSharedPointer<AbstractionType> >);\r\n\r\n\t//! Describes further information on the mode for this interface.\r\n\tGeneral::InterfaceMode interfaceMode_ = General::INTERFACE_MODE_COUNT;\r\n\r\n\t//! Specifies if the busInterface can be unconnected.\r\n\tBooleanValue connectionRequired_;\r\n\r\n\t//! Number of data bits addressable in the bus interface.\r\n\tQString bitsInLau_;\r\n\r\n\t//! Is bitSteering used.\r\n\tQString bitSteering_;\r\n\r\n\t//! The parameters set as attributes for the bit steering.\r\n\tQMap<QString, QString> bitSteeringAttributes_;\r\n\r\n\t//! Indicates the endianness of the bus interface.\r\n\tEndianness endianness_ = BusInterface::ENDIANNESS_UNSPECIFIED;\r\n\r\n\t//! Specifies any parameter data values for this bus interface.\r\n\tQSharedPointer<QList<QSharedPointer<Parameter> > > parameters_ =\r\n\t\tQSharedPointer<QList<QSharedPointer<Parameter> > >(new QList<QSharedPointer<Parameter> >);\r\n\r\n\t//! A pointer to the master / mirrored master instance\r\n\tQSharedPointer<InitiatorInterface> initiator_ = nullptr;\r\n\r\n\t//! A pointer to the slave instance.\r\n\tQSharedPointer<TargetInterface> target_ = nullptr;\r\n\r\n\t//! The system or mirrored system group name.\r\n\tQString systemGroup_;\r\n\r\n\t//! A pointer to the monitor instance.\r\n\tQSharedPointer<MonitorInterface> monitor_ = nullptr;\r\n\r\n\t//! A pointer to the mirroredTarget instance.\r\n\tQSharedPointer<MirroredTargetInterface> mirroredTarget_ = nullptr;\r\n\r\n\r\n};\r\n\r\nQ_DECLARE_METATYPE(QSharedPointer<BusInterface>);\r\n\r\n#endif // BUSINTERFACE_H\r\n"
  },
  {
    "path": "IPXACTmodels/Component/BusInterfaceReader.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: businterfaceReader.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Janne Virtanen\r\n// Date: 22.09.2015\r\n//\r\n// Description:\r\n// Reader class for IP-XACT businterface element.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"BusInterfaceReader.h\"\r\n\r\n#include \"InitiatorInterface.h\"\r\n#include \"MirroredTargetInterface.h\"\r\n#include \"TargetInterface.h\"\r\n\r\n#include <IPXACTmodels/common/NameGroupReader.h>\r\n#include <IPXACTmodels/common/ParameterReader.h>\r\n\r\n#include <IPXACTmodels/Component/TransparentBridge.h>\r\n\r\n#include <IPXACTmodels/utilities/XmlUtils.h>\r\n\r\n#include <QXmlStreamWriter>\r\n#include <QDomNamedNodeMap>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusinterfaceReader::createbusinterfaceFrom()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<BusInterface> BusinterfaceReader::createBusinterfaceFrom(QDomNode const& businterfaceNode,\r\n    Document::Revision docRevision)\r\n{\r\n\tQSharedPointer<BusInterface> newbusinterface (new BusInterface());\r\n\r\n\tnewbusinterface->setAttributes(CommonItemsReader::parseAttributes(businterfaceNode));\r\n\r\n    NameGroupReader::parseNameGroup(businterfaceNode, newbusinterface);\r\n\r\n    if (docRevision == Document::Revision::Std14)\r\n    {\r\n        auto presenceElement = businterfaceNode.firstChildElement(QStringLiteral(\"ipxact:isPresent\"));\r\n        newbusinterface->setIsPresent(CommonItemsReader::parseIsPresent(presenceElement));\r\n    }\r\n\r\n    QDomElement businterfaceElement = businterfaceNode.toElement();\r\n    \r\n    Details::parseBusType(businterfaceElement, newbusinterface);\r\n\r\n    Details::parseAbstractionTypes(businterfaceElement, newbusinterface, docRevision);\r\n\r\n    Details::parseInterfaceMode(businterfaceElement, newbusinterface, docRevision);\r\n\r\n    Details::parseConnectionRequired(businterfaceElement, newbusinterface);\r\n\r\n    Details::parseBitsInLau(businterfaceElement, newbusinterface);\r\n\r\n    Details::parseBitSteering(businterfaceElement, newbusinterface);\r\n\r\n    Details::parseEndianess(businterfaceElement, newbusinterface);\r\n\r\n    newbusinterface->getParameters()->append(*CommonItemsReader::parseAndCreateParameters(businterfaceNode));\r\n\r\n    Details::parseBusInterfaceExtensions(businterfaceNode, newbusinterface);\r\n\r\n    return newbusinterface;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusinterfaceReader::Details::parseBusType()\r\n//-----------------------------------------------------------------------------\r\nvoid BusinterfaceReader::Details::parseBusType(QDomElement& businterfaceElement,\r\n    QSharedPointer<BusInterface> newbusinterface)\r\n{\r\n    QDomElement busTypeElement = businterfaceElement.firstChildElement(QStringLiteral(\"ipxact:busType\"));\r\n    newbusinterface->setBusType(CommonItemsReader::parseVLNVAttributes(busTypeElement, VLNV::BUSDEFINITION));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusinterfaceReader::Details::parseConnectionRequired()\r\n//-----------------------------------------------------------------------------\r\nvoid BusinterfaceReader::Details::parseConnectionRequired(QDomElement& businterfaceElement,\r\n    QSharedPointer<BusInterface> newbusinterface)\r\n{\r\n    QDomElement requirementNode = businterfaceElement.firstChildElement(QStringLiteral(\"ipxact:connectionRequired\"));\r\n    if (!requirementNode.isNull())\r\n    {\r\n        QString connectionRequired = requirementNode.childNodes().at(0).nodeValue();\r\n        newbusinterface->setConnectionRequired(connectionRequired == QLatin1String(\"true\"));\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusinterfaceReader::Details::parseBitsInLau()\r\n//-----------------------------------------------------------------------------\r\nvoid BusinterfaceReader::Details::parseBitsInLau(QDomElement& businterfaceElement,\r\n    QSharedPointer<BusInterface> newbusinterface)\r\n{\r\n    QDomElement lauElement = businterfaceElement.firstChildElement(QStringLiteral(\"ipxact:bitsInLau\"));\r\n    if (!lauElement.isNull())\r\n    {\r\n        QString bitsInLau = lauElement.firstChild().nodeValue();\r\n        newbusinterface->setBitsInLau(bitsInLau);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusinterfaceReader::Details::parseBitSteering()\r\n//-----------------------------------------------------------------------------\r\nvoid BusinterfaceReader::Details::parseBitSteering(QDomElement& businterfaceElement,\r\n    QSharedPointer<BusInterface> newbusinterface)\r\n{\r\n    QDomElement bitSteeringElement = businterfaceElement.firstChildElement(QStringLiteral(\"ipxact:bitSteering\"));\r\n    if (!bitSteeringElement.isNull())\r\n    {\r\n        QString bitSteering = bitSteeringElement.childNodes().at(0).nodeValue();\r\n\r\n        newbusinterface->setBitSteering(bitSteering);\r\n\r\n        newbusinterface->setBitSteeringAttributes(CommonItemsReader::parseAttributes(bitSteeringElement));\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusinterfaceReader::Details::parseEndianess()\r\n//-----------------------------------------------------------------------------\r\nvoid BusinterfaceReader::Details::parseEndianess(QDomElement& businterfaceElement,\r\n    QSharedPointer<BusInterface> newbusinterface)\r\n{\r\n    QDomElement endiannessElement = businterfaceElement.firstChildElement(QStringLiteral(\"ipxact:endianness\"));\r\n    if (!endiannessElement.isNull())\r\n    {\r\n        QString endianness = endiannessElement.childNodes().at(0).nodeValue();\r\n        if (endianness == QLatin1String(\"little\"))\r\n        {\r\n            newbusinterface->setEndianness(BusInterface::LITTLE);\r\n        }\r\n        else if (endianness == QLatin1String(\"big\"))\r\n        {\r\n            newbusinterface->setEndianness(BusInterface::BIG);\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusinterfaceReader::readAbstractionTypes()\r\n//-----------------------------------------------------------------------------\r\nvoid BusinterfaceReader::Details::parseAbstractionTypes(QDomElement const& businterfaceElement,\r\n    QSharedPointer<BusInterface> busInterface, Document::Revision docRevision)\r\n{\r\n    auto abstractionTypesElement = businterfaceElement.firstChildElement(QStringLiteral(\"ipxact:abstractionTypes\"));\r\n\r\n    auto abstractionNodes = abstractionTypesElement.elementsByTagName(QStringLiteral(\"ipxact:abstractionType\"));\r\n\r\n    const int ABSTRACTIONTYPE_COUNT = abstractionNodes.count();\r\n\tfor (int i = 0; i < ABSTRACTIONTYPE_COUNT; ++i)\r\n    {\r\n        QSharedPointer<AbstractionType> newAbstractionType(new AbstractionType());\r\n\r\n        QDomNode abstractionNode = abstractionNodes.at(i);\r\n\r\n        parseViewReferences(abstractionNode, newAbstractionType);\r\n\r\n        QDomElement abstractionRefElement = abstractionNode.firstChildElement(QStringLiteral(\"ipxact:abstractionRef\"));\r\n        newAbstractionType->setAbstractionRef(CommonItemsReader::parseConfigurableVLNVReference(abstractionRefElement,\r\n            VLNV::ABSTRACTIONDEFINITION));\r\n\r\n        QDomElement portMapsElement = abstractionNode.firstChildElement(QStringLiteral(\"ipxact:portMaps\"));\r\n        parsePortMaps(portMapsElement, newAbstractionType, docRevision);\r\n\r\n        busInterface->getAbstractionTypes()->append(newAbstractionType);\r\n\t}\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusInterfaceReader::parseAbstractionTypes()\r\n//-----------------------------------------------------------------------------\r\nvoid BusinterfaceReader::Details::parseViewReferences(QDomNode const& abstractionNode,\r\n    QSharedPointer<AbstractionType> newAbstractionType)\r\n{\r\n    QDomElement abstractionElement = abstractionNode.toElement();\r\n    if (!abstractionElement.isNull())\r\n    {\r\n        QSharedPointer<QStringList> viewList(new QStringList());\r\n\r\n        QDomNodeList abstractionViewNodes =\r\n            abstractionNode.toElement().elementsByTagName(QStringLiteral(\"ipxact:viewRef\"));\r\n\r\n        const int VIEW_COUNT = abstractionViewNodes.count();\r\n        for (int i = 0; i < VIEW_COUNT; ++i)\r\n        {\r\n            QString viewReference = abstractionViewNodes.at(i).firstChild().nodeValue();\r\n            viewList->append(viewReference);\r\n        }\r\n\r\n        newAbstractionType->setViewReferences(viewList);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusinterfaceReader::parsePortMaps()\r\n//-----------------------------------------------------------------------------\r\nvoid BusinterfaceReader::Details::parsePortMaps(QDomElement const& portMapsElement,\r\n    QSharedPointer<AbstractionType> abstractionType, Document::Revision docRevision)\r\n{\r\n    QDomNodeList portMapNodes = portMapsElement.elementsByTagName(QStringLiteral(\"ipxact:portMap\"));\r\n\r\n    int portMapCount = portMapNodes.count();\r\n    for (int i = 0; i < portMapCount; i++)\r\n    {\r\n        QDomElement portMapElement = portMapNodes.at(i).toElement();\r\n\r\n        QSharedPointer<PortMap> portMap (new PortMap());\r\n\r\n        if (portMapElement.hasAttribute(QStringLiteral(\"invert\")))\r\n        {\r\n            portMap->setInvert(portMapElement.attribute(QStringLiteral(\"invert\")) == QLatin1String(\"true\"));\r\n        }\r\n\r\n        if (docRevision == Document::Revision::Std14)\r\n        {\r\n            QDomElement isPresentElement = portMapElement.firstChildElement(QStringLiteral(\"ipxact:isPresent\"));\r\n            portMap->setIsPresent(isPresentElement.firstChild().nodeValue());\r\n        }\r\n\r\n        parseLogicalPort(portMapElement.firstChildElement(QStringLiteral(\"ipxact:logicalPort\")), portMap);\r\n        parsePhysicalPort(portMapElement.firstChildElement(QStringLiteral(\"ipxact:physicalPort\")), portMap);\r\n\r\n        QDomElement logicalTieOffElement = portMapElement.firstChildElement(QStringLiteral(\"ipxact:logicalTieOff\"));\r\n\r\n        portMap->setLogicalTieOff(logicalTieOffElement.firstChild().nodeValue());\r\n\r\n        if (QDomElement isInformativeElement = portMapElement.firstChildElement(QStringLiteral(\"ipxact:isInformative\"));\r\n            isInformativeElement.firstChild().nodeValue().isEmpty())\r\n        {\r\n            portMap->clearIsInformative(); // Set unspecified value if value doesn't exist.\r\n        }\r\n        else\r\n        {\r\n            portMap->setIsInformative(isInformativeElement.firstChild().nodeValue() == QLatin1String(\"true\"));\r\n        }\r\n\r\n        if (docRevision == Document::Revision::Std22)\r\n        {\r\n            CommonItemsReader::parseVendorExtensions(portMapElement, portMap);\r\n        }\r\n\r\n        abstractionType->getPortMaps()->append(portMap);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusinterfaceReader::parseLogicalPort()\r\n//-----------------------------------------------------------------------------\r\nvoid BusinterfaceReader::Details::parseLogicalPort(QDomElement const& logicalPortElement,\r\n    QSharedPointer<PortMap> portMap)\r\n{\r\n    QDomElement nameElement = logicalPortElement.firstChildElement(QStringLiteral(\"ipxact:name\"));\r\n    QString portName = XmlUtils::removeWhiteSpace(nameElement.firstChild().nodeValue());\r\n\r\n    QSharedPointer<PortMap::LogicalPort> logicalPort(new PortMap::LogicalPort(portName));\r\n\r\n    if (QDomElement rangeElement = logicalPortElement.firstChildElement(QStringLiteral(\"ipxact:range\")); \r\n        !rangeElement.isNull())\r\n    {\r\n        logicalPort->range_ = QSharedPointer<Range>(new Range(CommonItemsReader::parseRange(rangeElement)));\r\n    }\r\n\r\n\tportMap->setLogicalPort(logicalPort);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusinterfaceReader::parsePhysicalPort()\r\n//-----------------------------------------------------------------------------\r\nvoid BusinterfaceReader::Details::parsePhysicalPort(QDomElement const& physicalPortElement,\r\n    QSharedPointer<PortMap> portMap)\r\n{\r\n    if (physicalPortElement.isNull())\r\n    {\r\n        return;\r\n    }\r\n\r\n    QDomElement nameElement = physicalPortElement.firstChildElement(QStringLiteral(\"ipxact:name\"));\r\n    QString portName = XmlUtils::removeWhiteSpace(nameElement.firstChild().nodeValue());\r\n\tQSharedPointer<PortMap::PhysicalPort> physicalPort(new PortMap::PhysicalPort(portName));\r\n\r\n    QDomElement partSelectElement = physicalPortElement.firstChildElement(QStringLiteral(\"ipxact:partSelect\"));\r\n    if (!partSelectElement.isNull())\r\n    {\r\n        QSharedPointer<PartSelect> newPartSelect = CommonItemsReader::parsePartSelect(partSelectElement);\r\n        physicalPort->partSelect_ = newPartSelect;\r\n    }\r\n\r\n\tportMap->setPhysicalPort(physicalPort);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusinterfaceReader::parseInterfaceMode()\r\n//-----------------------------------------------------------------------------\r\nvoid BusinterfaceReader::Details::parseInterfaceMode(QDomElement const& busInterfaceElement,\r\n    QSharedPointer<BusInterface> newbusinterface, Document::Revision docRevision)\r\n{\r\n    if (docRevision == Document::Revision::Std14)\r\n    {\r\n        QDomElement masterNode = busInterfaceElement.firstChildElement(QStringLiteral(\"ipxact:master\"));\r\n        if (!masterNode.isNull())\r\n        {\r\n            QSharedPointer<InitiatorInterface> newmode(new InitiatorInterface());\r\n            parseMasterInterface(masterNode, newmode);\r\n\r\n            newbusinterface->setMaster(newmode);\r\n            return;\r\n        }\r\n\r\n        QDomElement slaveNode = busInterfaceElement.firstChildElement(QStringLiteral(\"ipxact:slave\"));\r\n        if (!slaveNode.isNull())\r\n        {\r\n            QSharedPointer<TargetInterface> newmode(new TargetInterface());\r\n            parseSlaveInterface(slaveNode, newmode);\r\n\r\n            newbusinterface->setSlave(newmode);\r\n            return;\r\n        }\r\n\r\n        QDomElement mirroredMasterNode = busInterfaceElement.firstChildElement(QStringLiteral(\"ipxact:mirroredMaster\"));\r\n        if (!mirroredMasterNode.isNull())\r\n        {\r\n            newbusinterface->setInterfaceMode(General::MIRRORED_MASTER);\r\n            return;\r\n        }\r\n\r\n        QDomElement mirroredSlaveNode = busInterfaceElement.firstChildElement(QStringLiteral(\"ipxact:mirroredSlave\"));\r\n        if (!mirroredSlaveNode.isNull())\r\n        {\r\n            QSharedPointer<MirroredTargetInterface> newmode(new MirroredTargetInterface());\r\n            parseMirroredSlaveInterface(mirroredSlaveNode, newmode);\r\n\r\n            newbusinterface->setMirroredSlave(newmode);\r\n            return;\r\n        }\r\n    }\r\n    else if (docRevision == Document::Revision::Std22)\r\n    {\r\n        QDomElement initiatorNode = busInterfaceElement.firstChildElement(QStringLiteral(\"ipxact:initiator\"));\r\n        if (!initiatorNode.isNull())\r\n        {\r\n            QSharedPointer<InitiatorInterface> newmode(new InitiatorInterface());\r\n            parseInitiatorInterface(initiatorNode, newmode);\r\n\r\n            newbusinterface->setInitiator(newmode);\r\n            return;\r\n        }\r\n\r\n        QDomElement targetNode = busInterfaceElement.firstChildElement(QStringLiteral(\"ipxact:target\"));\r\n        if (!targetNode.isNull())\r\n        {\r\n            QSharedPointer<TargetInterface> newmode(new TargetInterface());\r\n            parseTargetInterface(targetNode, newmode, Document::Revision::Std22);\r\n\r\n            newbusinterface->setTarget(newmode);\r\n            return;\r\n        }\r\n\r\n        QDomElement mirroredTargetNode = busInterfaceElement.firstChildElement(QStringLiteral(\"ipxact:mirroredTarget\"));\r\n        if (!mirroredTargetNode.isNull())\r\n        {\r\n            QSharedPointer<MirroredTargetInterface> newmode(new MirroredTargetInterface());\r\n            parseMirroredTargetInterface(mirroredTargetNode, newmode);\r\n\r\n            newbusinterface->setMirroredTarget(newmode);\r\n            return;\r\n        }\r\n\r\n        QDomElement mirroredInitiatorNode = busInterfaceElement.firstChildElement(QStringLiteral(\"ipxact:mirroredInitiator\"));\r\n        if (!mirroredInitiatorNode.isNull())\r\n        {\r\n            newbusinterface->setInterfaceMode(General::MIRRORED_INITIATOR);\r\n            return;\r\n        }\r\n    }\r\n\r\n    QDomElement systemNode = busInterfaceElement.firstChildElement(QStringLiteral(\"ipxact:system\"));\r\n    if (!systemNode.isNull())\r\n    {\r\n        QString systemGroup = systemNode.firstChildElement(QStringLiteral(\"ipxact:group\")).firstChild().nodeValue();\r\n        \r\n        newbusinterface->setInterfaceMode(General::SYSTEM);\r\n        newbusinterface->setSystem(systemGroup);\r\n        return;\r\n    }\r\n\r\n\r\n    QDomElement mirroredSystemNode = busInterfaceElement.firstChildElement(QStringLiteral(\"ipxact:mirroredSystem\"));\r\n\tif (!mirroredSystemNode.isNull())\r\n\t{\r\n        QString systemGroup = mirroredSystemNode.firstChildElement(QStringLiteral(\"ipxact:group\")).firstChild().nodeValue();\r\n        \r\n        newbusinterface->setInterfaceMode(General::MIRRORED_SYSTEM);\r\n        newbusinterface->setSystem(systemGroup);\r\n        return;\r\n\t}\r\n\r\n    QDomElement monitorNode = busInterfaceElement.firstChildElement(QStringLiteral(\"ipxact:monitor\"));\r\n\tif (!monitorNode.isNull())\r\n    {\r\n        QSharedPointer<BusInterface::MonitorInterface> newmode(new BusInterface::MonitorInterface());\r\n        parseMonitorInterface(monitorNode, newmode);\r\n\r\n        newbusinterface->setMonitor(newmode);        \r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusinterfaceReader::parseMasterInterface()\r\n//-----------------------------------------------------------------------------\r\nvoid BusinterfaceReader::Details::parseMasterInterface(QDomElement const& masterInterfaceElement,\r\n    QSharedPointer<InitiatorInterface> masterInterface)\r\n{\r\n    QDomElement addressSpaceRefElement = masterInterfaceElement.firstChildElement(QStringLiteral(\"ipxact:addressSpaceRef\"));\r\n \r\n    QString addressSpaceRef = addressSpaceRefElement.attribute(QStringLiteral(\"addressSpaceRef\"));\r\n\r\n    masterInterface->setAddressSpaceRef(XmlUtils::removeWhiteSpace(addressSpaceRef));\r\n\r\n    QDomElement isPresentElement = addressSpaceRefElement.firstChildElement(QStringLiteral(\"ipxact:isPresent\"));\r\n    if (!isPresentElement.isNull())\r\n    {\r\n        masterInterface->setIsPresent(isPresentElement.firstChild().nodeValue());\r\n    }\r\n\r\n    QDomElement baseAddressElement = addressSpaceRefElement.firstChildElement(QStringLiteral(\"ipxact:baseAddress\"));\r\n\r\n    QString baseAddress = baseAddressElement.firstChild().nodeValue();\r\n    masterInterface->setBaseAddress(XmlUtils::removeWhiteSpace(baseAddress));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusinterfaceReader::parseSlaveInterface()\r\n//-----------------------------------------------------------------------------\r\nvoid BusinterfaceReader::Details::parseSlaveInterface(QDomElement const& slaveIntefaceElement,\r\n    QSharedPointer<TargetInterface> slaveInterface)\r\n{\r\n    parseTargetInterface(slaveIntefaceElement, slaveInterface, Document::Revision::Std14);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusinterfaceReader::parseMirroredSlaveInterface()\r\n//-----------------------------------------------------------------------------\r\nvoid BusinterfaceReader::Details::parseMirroredSlaveInterface(QDomElement const& mirroredInterfaceElement,\r\n    QSharedPointer<MirroredTargetInterface> mirroredSlaveInterface)\r\n{\r\n    QDomElement baseAddressElement = mirroredInterfaceElement.firstChildElement(QStringLiteral(\"ipxact:baseAddresses\"));\r\n\r\n    if (baseAddressElement.isNull())\r\n    {\r\n        return;\r\n    }\r\n\r\n    QDomNodeList remapAddressNodes = baseAddressElement.elementsByTagName(QStringLiteral(\"ipxact:remapAddress\"));\r\n    const int REMAP_ADDRESSES_COUNT = remapAddressNodes.count();\r\n    for (int i = 0; i < REMAP_ADDRESSES_COUNT; ++i)\r\n    {\r\n        QDomNode remapAddressNode = remapAddressNodes.at(i);\r\n        QString remapAddress = remapAddressNode.firstChild().nodeValue();\r\n\r\n        QSharedPointer<MirroredTargetInterface::RemapAddress> remap(\r\n            new MirroredTargetInterface::RemapAddress(remapAddress));\r\n\r\n        remap->remapAttributes_ = CommonItemsReader::parseAttributes(remapAddressNode);\r\n        remap->state_ = remap->remapAttributes_.take(QStringLiteral(\"state\"));\r\n\r\n        mirroredSlaveInterface->getRemapAddresses()->append(remap);\r\n    }\r\n\r\n    QDomNode rangeNode = baseAddressElement.firstChildElement(QStringLiteral(\"ipxact:range\"));\r\n    mirroredSlaveInterface->setRange(rangeNode.firstChild().nodeValue());\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusinterfaceReader::Details::parseInitiatorInterface()\r\n//-----------------------------------------------------------------------------\r\nvoid BusinterfaceReader::Details::parseInitiatorInterface(QDomElement const& initiatorNode, \r\n    QSharedPointer<InitiatorInterface> initiatorInterface)\r\n{\r\n    QDomElement addressSpaceRefElement = initiatorNode.firstChildElement(QStringLiteral(\"ipxact:addressSpaceRef\"));\r\n\r\n    QString addressSpaceRef = addressSpaceRefElement.attribute(QStringLiteral(\"addressSpaceRef\"));\r\n\r\n    initiatorInterface->setAddressSpaceRef(XmlUtils::removeWhiteSpace(addressSpaceRef));\r\n\r\n    CommonItemsReader::parseVendorExtensions(addressSpaceRefElement, initiatorInterface);\r\n\r\n    QDomElement baseAddressElement = addressSpaceRefElement.firstChildElement(QStringLiteral(\"ipxact:baseAddress\"));\r\n\r\n    QString baseAddress = baseAddressElement.firstChild().nodeValue();\r\n    initiatorInterface->setBaseAddress(XmlUtils::removeWhiteSpace(baseAddress));\r\n\r\n    initiatorInterface->setModeRefs(parseModeRefs(addressSpaceRefElement));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusinterfaceReader::Details::parseTargetInterface()\r\n//-----------------------------------------------------------------------------\r\nvoid BusinterfaceReader::Details::parseTargetInterface(QDomElement const& targetNode,\r\n    QSharedPointer<TargetInterface> targetInterface, Document::Revision docRevision)\r\n{\r\n    QDomElement memoryMapRefElement = targetNode.firstChildElement(QStringLiteral(\"ipxact:memoryMapRef\"));\r\n\r\n    QString memoryMapRef = memoryMapRefElement.attribute(QStringLiteral(\"memoryMapRef\"));\r\n    targetInterface->setMemoryMapRef(XmlUtils::removeWhiteSpace(memoryMapRef));\r\n\r\n    targetInterface->setModeRefs(parseModeRefs(memoryMapRefElement));\r\n\r\n    QDomNodeList bridgeNodes = targetNode.elementsByTagName(QStringLiteral(\"ipxact:transparentBridge\"));\r\n    int bridgeCount = bridgeNodes.count();\r\n    for (int i = 0; i < bridgeCount; i++)\r\n    {\r\n        QDomElement bridgeElement = bridgeNodes.at(i).toElement();\r\n\r\n        QSharedPointer<TransparentBridge> newBridge(new TransparentBridge());\r\n\r\n        auto attributeName = QStringLiteral(\"initiatorRef\");\r\n        if (docRevision == Document::Revision::Std14)\r\n        {\r\n            attributeName = QStringLiteral(\"masterRef\");\r\n        }\r\n\r\n        newBridge->setInitiatorRef(XmlUtils::removeWhiteSpace(bridgeElement.attribute(attributeName)));\r\n\r\n        if (docRevision == Document::Revision::Std14)\r\n        {\r\n            newBridge->setIsPresent(CommonItemsReader::parseIsPresent(bridgeElement.firstChildElement(\r\n                QStringLiteral(\"ipxact:isPresent\"))));\r\n        }\r\n\r\n        if (docRevision == Document::Revision::Std22)\r\n        {\r\n            CommonItemsReader::parseVendorExtensions(bridgeElement, newBridge);\r\n        }\r\n\r\n        // Another bridge is extracted.\r\n        targetInterface->getBridges()->append(newBridge);\r\n    }\r\n\r\n    QDomNodeList fileSetRefGroupNodes = targetNode.elementsByTagName(QStringLiteral(\"ipxact:fileSetRefGroup\"));\r\n    int filesetRefCount = fileSetRefGroupNodes.count();\r\n    // Go through all child elements.\r\n    for (int i = 0; i < filesetRefCount; i++)\r\n    {\r\n        QDomElement fileSetRefElement = fileSetRefGroupNodes.at(i).toElement();\r\n\r\n        QSharedPointer<TargetInterface::FileSetRefGroup> fileSetGroup(new TargetInterface::FileSetRefGroup());\r\n\r\n        QDomNode groupNode = fileSetRefElement.firstChildElement(QStringLiteral(\"ipxact:group\"));\r\n        fileSetGroup->group_ = XmlUtils::removeWhiteSpace(groupNode.firstChild().nodeValue());\r\n\r\n        if (auto fileSetRefs = CommonItemsReader::parseFileSetReferences(fileSetRefElement, docRevision);\r\n            fileSetRefs->isEmpty() == false)\r\n        {\r\n            fileSetGroup->fileSetRefs_ = fileSetRefs;\r\n        }\r\n\r\n        // Another file set ref group is extracted.\r\n        targetInterface->getFileSetRefGroup()->append(fileSetGroup);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusinterfaceReader::parseMirroredTargetInterface()\r\n//-----------------------------------------------------------------------------\r\nvoid BusinterfaceReader::Details::parseMirroredTargetInterface(QDomElement const& mirroredInterfaceElement,\r\n    QSharedPointer<MirroredTargetInterface> mirroredSlaveInterface)\r\n{\r\n    QDomElement baseAddressElement = mirroredInterfaceElement.firstChildElement(QStringLiteral(\"ipxact:baseAddresses\"));\r\n\r\n    if (baseAddressElement.isNull())\r\n    {\r\n        return;\r\n    }\r\n\r\n\r\n    QDomNodeList remapAddressesNodes = baseAddressElement.elementsByTagName(QStringLiteral(\"ipxact:remapAddresses\"));\r\n    const int REMAP_ADDRESS_COUNT = remapAddressesNodes.count();\r\n    for (int i = 0; i < REMAP_ADDRESS_COUNT; ++i)\r\n    {\r\n        QDomElement remapAddressesElement = remapAddressesNodes.at(i).toElement();\r\n\r\n        QDomNode remapAddressNode = remapAddressesElement.firstChildElement(QStringLiteral(\"ipxact:remapAddress\"));\r\n        QString remapAddress = remapAddressNode.firstChild().nodeValue();\r\n\r\n        QSharedPointer<MirroredTargetInterface::RemapAddress> remap(\r\n            new MirroredTargetInterface::RemapAddress(remapAddress));\r\n\r\n        remap->modeRefs_ = parseModeRefs(remapAddressesElement);\r\n\r\n        auto modeRefNodes = remapAddressesElement.elementsByTagName(QStringLiteral(\"ipxact:modeRef\"));\r\n        const int MODE_COUNT = modeRefNodes.count();\r\n        for (int j = 0; j < MODE_COUNT; ++j)\r\n        {\r\n            auto modeNode = modeRefNodes.at(j);\r\n            \r\n            auto priority = modeNode.attributes().namedItem(QStringLiteral(\"priority\")).nodeValue();\r\n            if (priority.isEmpty() == false)\r\n            {\r\n                auto modeRef = modeNode.firstChild().nodeValue();\r\n                remap->priorities_.insert(modeRef, priority.toUInt());\r\n            }\r\n        }\r\n\r\n\r\n        mirroredSlaveInterface->getRemapAddresses()->append(remap);\r\n    }\r\n\r\n    QDomNode rangeNode = baseAddressElement.firstChildElement(QStringLiteral(\"ipxact:range\"));\r\n    mirroredSlaveInterface->setRange(rangeNode.firstChild().nodeValue());\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusinterfaceReader::parseMonitorInterface()\r\n//-----------------------------------------------------------------------------\r\nvoid BusinterfaceReader::Details::parseMonitorInterface(QDomElement const& monitorElement,\r\n\tQSharedPointer<BusInterface::MonitorInterface> monitorInterface)\r\n{\r\n\tQString interfaceMode = monitorElement.attribute(QStringLiteral(\"interfaceMode\"));\r\n\tinterfaceMode = XmlUtils::removeWhiteSpace(interfaceMode);\r\n\r\n\tmonitorInterface->interfaceMode_ = General::str2Interfacemode(interfaceMode, General::MONITOR);\r\n    monitorInterface->group_ = monitorElement.firstChildElement(QStringLiteral(\"ipxact:group\")).firstChild().nodeValue();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusinterfaceReader::parseBusInterfaceExtensions()\r\n//-----------------------------------------------------------------------------\r\nvoid BusinterfaceReader::Details::parseBusInterfaceExtensions(QDomNode const& interfaceNode,\r\n    QSharedPointer<BusInterface> newInterface)\r\n{\r\n    QDomNode extensionsNode = interfaceNode.firstChildElement(QStringLiteral(\"ipxact:vendorExtensions\"));\r\n    QDomElement positionElement = extensionsNode.firstChildElement(QStringLiteral(\"kactus2:position\"));\r\n    if (!positionElement.isNull())\r\n    {\r\n        newInterface->setDefaultPos(CommonItemsReader::parsePoint(positionElement));\r\n    }\r\n\r\n    CommonItemsReader::parseVendorExtensions(interfaceNode, newInterface);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusinterfaceReader::Details::parseModeRefs()\r\n//-----------------------------------------------------------------------------\r\nQStringList BusinterfaceReader::Details::parseModeRefs(QDomElement const& containingElement)\r\n{\r\n    QStringList modeRefs;\r\n    auto modeRefNodes = containingElement.elementsByTagName(QStringLiteral(\"ipxact:modeRef\"));\r\n\r\n    const int MODE_COUNT = modeRefNodes.count();\r\n    for (int i = 0; i < MODE_COUNT; ++i)\r\n    {\r\n        auto modeNode = modeRefNodes.at(i);\r\n\r\n        modeRefs.append(modeNode.firstChild().nodeValue());\r\n    }\r\n\r\n    return modeRefs;\r\n}\r\n"
  },
  {
    "path": "IPXACTmodels/Component/BusInterfaceReader.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: businterfaceReader.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Janne Virtanen\r\n// Date: 22.09.2015\r\n//\r\n// Description:\r\n// Reader class for IP-XACT businterface element.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef businterfaceReader_H\r\n#define businterfaceReader_H\r\n\r\n#include \"BusInterface.h\"\r\n\r\n#include <IPXACTmodels/common/CommonItemsReader.h>\r\n#include <IPXACTmodels/Component/PortMap.h>\r\n\r\n#include <QSharedPointer>\r\n#include <QDomNode>\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Reader class for IP-XACT businterface element.\r\n//-----------------------------------------------------------------------------\r\nnamespace BusinterfaceReader \r\n{\r\n    /*!\r\n     *  Creates a new businterface from a given bus interface XML description.\r\n     *\r\n     *    @param [in] businterfaceNode    XML description of the businterface.\r\n     *    @param [in] docRevision         The applied IP-XACT standard revision.\r\n     *\r\n\t *    @return\t\t\t\t\t\t\tA new BusInterface.\r\n     */\r\n    IPXACTMODELS_EXPORT QSharedPointer<BusInterface> createBusinterfaceFrom(QDomNode const& businterfaceNode,\r\n        Document::Revision docRevision);\r\n\r\n    namespace Details\r\n    {\r\n        /*!\r\n         *  Parses the bus type for the bus interface.\r\n         *\r\n         *    @param [in] businterfaceElement XML description of the businterface.\r\n         *    @param [in] busInterface        The new businterface item.\r\n         */\r\n        void parseBusType(QDomElement& businterfaceElement, QSharedPointer<BusInterface> newbusinterface);\r\n\r\n        /*!\r\n         *  Parses the connectionRequired element for the bus interface.\r\n         *\r\n         *    @param [in] businterfaceElement XML description of the businterface.\r\n         *    @param [in] busInterface        The new businterface item.\r\n         */\r\n        void parseConnectionRequired(QDomElement& businterfaceElement, QSharedPointer<BusInterface> newbusinterface);\r\n\r\n        /*!\r\n         *  Parses the bits in lau element for the bus interface.\r\n         *\r\n         *    @param [in] businterfaceElement XML description of the businterface.\r\n         *    @param [in] busInterface        The new businterface item.\r\n         */\r\n        void parseBitsInLau(QDomElement& businterfaceElement, QSharedPointer<BusInterface> newbusinterface);\r\n\r\n        /*!\r\n         *  Parses the bit steering element for the bus interface.\r\n         *\r\n         *    @param [in] businterfaceElement XML description of the businterface.\r\n         *    @param [in] busInterface        The new businterface item.\r\n         */\r\n        void parseBitSteering(QDomElement& businterfaceElement, QSharedPointer<BusInterface> newbusinterface);\r\n\r\n        /*!\r\n         *  Parses the endianess element for the bus interface.\r\n         *\r\n         *    @param [in] businterfaceElement XML description of the businterface.\r\n         *    @param [in] busInterface        The new businterface item.\r\n         */\r\n        void parseEndianess(QDomElement& businterfaceElement, QSharedPointer<BusInterface> newbusinterface);\r\n\r\n        /*!\r\n         *  Parses the abstraction types for the bus interface.\r\n         *\r\n         *    @param [in] businterfaceElement The potential XML-node to yield abstraction types.\r\n         *    @param [in] busInterface        The new businterface item.\r\n         *    @param [in] docRevision         The applied IP-XACT standard revision.\r\n         */\r\n        void parseAbstractionTypes(QDomElement const& businterfaceElement,\r\n            QSharedPointer<BusInterface> busInterface, Document::Revision docRevision);\r\n\r\n        /*!\r\n         *  Reads the view references.\r\n         *\r\n         *    @param [in] abstractionNode     The examined abstraction type node.\r\n         *    @param [in] newAbstractionType  The abstraction type matching the selected node.\r\n         */\r\n        void parseViewReferences(QDomNode const& abstractionNode,\r\n            QSharedPointer<AbstractionType> newAbstractionType);\r\n\r\n        /*!\r\n         *  Tries to extract port maps from the parameter inspected and append them to parameter abstractionType.\r\n         *\r\n         *    @param [in] inspected\t\t\tThe potential XML-node to yield abstraction types.\r\n         *    @param [in] abstractionType\t    The object that will receive extracted port maps as a field.\r\n         *    @param [in] docRevision         The applied IP-XACT standard revision.\r\n         */\r\n        void parsePortMaps(QDomElement const& portMapsElement, QSharedPointer<AbstractionType> abstractionType,\r\n            Document::Revision docRevision);\r\n\r\n        /*!\r\n         *  Extracts a logical port from parameter logicalPortElement and sets it to parameter portMap.\r\n         *\r\n         *    @param [in] logicalPortElement\t\t\tThe XML-node to yield port.\r\n         *    @param [in] portMap\t\t\t\t        The port map, which port is being set.\r\n         */\r\n        void parseLogicalPort(QDomElement const& logicalPortElement, QSharedPointer<PortMap> portMap);\r\n\r\n        /*!\r\n         *  Extracts a physical port from parameter physicalPortElement and sets it to parameter portMap.\r\n         *\r\n         *    @param [in] physicalPortElement\t\tThe XML-node to yield port.\r\n         *    @param [in] portMap\t\t\t\t    The port map, which port is being set.\r\n         */\r\n        void parsePhysicalPort(QDomElement const& physicalPortElement, QSharedPointer<PortMap> portMap);\r\n\r\n        /*!\r\n         *  Tries to read interface mode from parameter busInterfaceElement and set it to newbusinterface.\r\n         *\r\n         *    @param [in] busInterfaceElement\t\tThe potential XML-node to yield interface mode.\r\n         *    @param [in] newbusinterface\t\t    This interface will have the extracted interface mode.\r\n         */\r\n        void parseInterfaceMode(QDomElement const& busInterfaceElement,\r\n            QSharedPointer<BusInterface> newbusinterface, Document::Revision docRevision);\r\n\r\n        /*!\r\n        *  Reads fields for a master interface struct from XML-input.\r\n        *\r\n        *    @param [in] masterInterfaceElement\tThe XML description to parse the information from.\r\n        *    @param [in] masterInterface\t\t\tThe interface object, which fields will be assigned.\r\n        */\r\n        void parseMasterInterface(QDomElement const& masterInterfaceElement,\r\n            QSharedPointer<InitiatorInterface> masterInterface);\r\n\r\n        /*!\r\n        *  Reads fields for a slave interface struct from XML-input.\r\n        *\r\n        *    @param [in] slaveIntefaceElement\t\t\tThe XML description to parse the information from.\r\n        *    @param [in] slaveInterface\t\t\t\tThe interface object, which fields will be assigned.\r\n        */\r\n        void parseSlaveInterface(QDomElement const& slaveIntefaceElement,\r\n            QSharedPointer<TargetInterface> slaveInterface);\r\n\r\n        /*!\r\n        *  Reads fields for a mirrored interface struct from XML-input.\r\n        *\r\n        *    @param [in] mirroredInterfaceElement\t\tThe XML description to parse the information from.\r\n        *    @param [in] mirroredSlaveInterface\t\tThe interface object, which fields will be assigned.\r\n        */\r\n        void parseMirroredSlaveInterface(QDomElement const& mirroredInterfaceElement,\r\n            QSharedPointer<MirroredTargetInterface> mirroredSlaveInterface);\r\n\r\n        /*!\r\n        *  Reads fields for a monitor interface struct from XML-input.\r\n        *\r\n        *    @param [in] monitorElement       The XML description to parse the information from.\r\n        *    @param [in] newmode\t\t\t\tThe interface object, which fields will be assigned.\r\n        */\r\n        void parseMonitorInterface(QDomElement const& monitorElement,\r\n            QSharedPointer<BusInterface::MonitorInterface> monitorInterface);\r\n\r\n        void parseInitiatorInterface(QDomElement const& initiatorNode, QSharedPointer<InitiatorInterface> initiatorInterface);\r\n\r\n        void parseTargetInterface(QDomElement const& targetNode, QSharedPointer<TargetInterface> targetInterface, \r\n            Document::Revision docRevision);\r\n\r\n        void parseMirroredTargetInterface(QDomElement const& mirroredInterfaceElement, \r\n            QSharedPointer<MirroredTargetInterface> mirroredSlaveInterface);\r\n\r\n        /*!\r\n         *  Read the extensions of the bus interface.\r\n         *\r\n         *    @param [in] interfaceNode   XML description of the bus interface.\r\n         *    @param [in] newInterface    The new bus interface item.\r\n         */\r\n        void parseBusInterfaceExtensions(QDomNode const& interfaceNode, QSharedPointer<BusInterface> newInterface);\r\n\r\n        QStringList parseModeRefs(QDomElement const& containingElement);\r\n    }\r\n};\r\n\r\n#endif // businterfaceReader_H\r\n\r\n"
  },
  {
    "path": "IPXACTmodels/Component/BusInterfaceWriter.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: businterfaceWriter.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Janne Virtanen\r\n// Date: 22.09.2015\r\n//\r\n// Description:\r\n// Writer class for IP-XACT businterface element.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"BusInterfaceWriter.h\"\r\n\r\n#include <IPXACTmodels/common/CommonItemsWriter.h>\r\n#include <IPXACTmodels/common/NameGroupWriter.h>\r\n#include <IPXACTmodels/common/ParameterWriter.h>\r\n\r\n#include <IPXACTmodels/Component/InitiatorInterface.h>\r\n#include <IPXACTmodels/Component/MirroredTargetInterface.h>\r\n#include <IPXACTmodels/Component/TargetInterface.h>\r\n#include <IPXACTmodels/Component/TransparentBridge.h>\r\n\r\n#include <QStringBuilder>\r\n#include <QXmlStreamWriter>\r\n#include <QDomNamedNodeMap>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusInterfaceWriter::writebusinterface()\r\n//-----------------------------------------------------------------------------\r\nvoid BusInterfaceWriter::writeBusInterface(QXmlStreamWriter& writer, QSharedPointer<BusInterface> businterface,\r\n    Document::Revision docRevision)\r\n{\r\n\twriter.writeStartElement(QStringLiteral(\"ipxact:busInterface\"));\r\n\r\n\t// Write attributes to the starting element.\t\r\n    CommonItemsWriter::writeAttributes(writer, businterface->getAttributes());\r\n\t    \r\n\t// Start the element, write name group, presence and, vendor extensions with pre-existing writers.\r\n    NameGroupWriter::writeNameGroup(writer, businterface, docRevision);\r\n\r\n    if (docRevision == Document::Revision::Std14)\r\n    {\r\n        CommonItemsWriter::writeNonEmptyElement(writer, QStringLiteral(\"ipxact:isPresent\"), businterface->getIsPresent());\r\n    }\r\n\r\n    // Write always bus type, connection requirement the bits in lau, and endianess.\r\n    writer.writeEmptyElement(QStringLiteral(\"ipxact:busType\"));\r\n    CommonItemsWriter::writeVLNVAttributes(writer, businterface->getBusType());\r\n\r\n    Details::writeAbstractionTypes(writer, businterface, docRevision);\r\n\r\n    Details::writeInterfaceMode(writer, businterface);\r\n\r\n    Details::writeConnectionRequired(writer, businterface);\r\n\r\n    Details::writeBitsInLau(writer, businterface);\r\n\r\n    Details::writeBitSteering(writer, businterface);\r\n\r\n    Details::writeEndianness(writer, businterface);\r\n\r\n\tCommonItemsWriter::writeParameters(writer, businterface->getParameters());\r\n\r\n    CommonItemsWriter::writeVendorExtensions(writer, businterface);\r\n\r\n\twriter.writeEndElement(); // ipxact:busInterface\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusInterfaceWriter::writeConnectionRequired()\r\n//-----------------------------------------------------------------------------\r\nvoid BusInterfaceWriter::Details::writeConnectionRequired(QXmlStreamWriter& writer,\r\n    QSharedPointer<BusInterface> busInterface) \r\n{\r\n    CommonItemsWriter::writeNonEmptyElement(writer,\r\n        QStringLiteral(\"ipxact:connectionRequired\"), busInterface->getConnectionRequired());\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusInterfaceWriter::writeBitsInLau()\r\n//-----------------------------------------------------------------------------\r\nvoid BusInterfaceWriter::Details::writeBitsInLau(QXmlStreamWriter& writer,\r\n    QSharedPointer<BusInterface> busInterface)\r\n{\r\n    CommonItemsWriter::writeNonEmptyElement(writer, QStringLiteral(\"ipxact:bitsInLau\"),\r\n        busInterface->getBitsInLau());\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusInterfaceWriter::writeEndianness()\r\n//-----------------------------------------------------------------------------\r\nvoid BusInterfaceWriter::Details::writeEndianness(QXmlStreamWriter& writer, QSharedPointer<BusInterface> busInterface)\r\n{\r\n    BusInterface::Endianness endianess = busInterface->getEndianness();\r\n    if (endianess == BusInterface::BIG)\r\n    {\r\n        writer.writeTextElement(QStringLiteral(\"ipxact:endianness\"), QStringLiteral(\"big\"));\r\n    }\r\n    else if (endianess == BusInterface::LITTLE)\r\n    {\r\n        writer.writeTextElement(QStringLiteral(\"ipxact:endianness\"), QStringLiteral(\"little\"));\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusInterfaceWriter::writeBitSteering()\r\n//-----------------------------------------------------------------------------\r\nvoid BusInterfaceWriter::Details::writeBitSteering(QXmlStreamWriter& writer,\r\n    QSharedPointer<BusInterface> businterface) \r\n{\r\n    auto bitSteering = businterface->getBitSteering();\r\n\r\n\t// If the bitSteering has been defined.\r\n    if (bitSteering.isEmpty() == false)\r\n    {\r\n        writer.writeStartElement(QStringLiteral(\"ipxact:bitSteering\"));\r\n\r\n        CommonItemsWriter::writeAttributes(writer, businterface->getBitSteeringAttributes());\r\n\r\n        writer.writeCharacters(bitSteering);\r\n\r\n        writer.writeEndElement(); // ipxact:bitSteering\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusInterfaceWriter::writeAbstractionTypes()\r\n//-----------------------------------------------------------------------------\r\nvoid BusInterfaceWriter::Details::writeAbstractionTypes(QXmlStreamWriter& writer,\r\n    QSharedPointer<BusInterface> businterface, Document::Revision docRevision)\r\n{\r\n    if (!businterface->getAbstractionTypes()->isEmpty())\r\n\t{\r\n\t\twriter.writeStartElement(QStringLiteral(\"ipxact:abstractionTypes\"));\r\n\r\n\t\tfor (QSharedPointer<AbstractionType> const& abstractionType : *businterface->getAbstractionTypes())\r\n\t\t{\r\n\t\t\twriter.writeStartElement(QStringLiteral(\"ipxact:abstractionType\"));\r\n\r\n            for (QString const& viewReference : *abstractionType->getViewReferences())\r\n            {\r\n                writer.writeTextElement(QStringLiteral(\"ipxact:viewRef\"), viewReference);\r\n            }\r\n\r\n            if (abstractionType->getAbstractionRef())\r\n            {\r\n                writer.writeEmptyElement(QStringLiteral(\"ipxact:abstractionRef\"));\r\n                CommonItemsWriter::writeVLNVAttributes(writer, *abstractionType->getAbstractionRef());\r\n            }\r\n\r\n            writePortMaps(writer, abstractionType, docRevision);\r\n\r\n\t\t\twriter.writeEndElement(); // ipxact:abstractionType\r\n\t\t}\r\n\r\n\t\twriter.writeEndElement(); // ipxact:abstractionTypes\r\n\t}\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusInterfaceWriter::writePortMaps()\r\n//-----------------------------------------------------------------------------\r\nvoid BusInterfaceWriter::Details::writePortMaps(QXmlStreamWriter& writer,\r\n    QSharedPointer<AbstractionType> abstractionType, Document::Revision docRevision)\r\n{\r\n    if (!abstractionType->getPortMaps()->isEmpty())\r\n    {\r\n        writer.writeStartElement(QStringLiteral(\"ipxact:portMaps\"));\r\n\r\n        for (QSharedPointer<PortMap> const& portMap : *abstractionType->getPortMaps())\r\n        {\r\n            writer.writeStartElement(QStringLiteral(\"ipxact:portMap\"));\r\n\r\n            CommonItemsWriter::writeNonEmptyAttribute(writer, QStringLiteral(\"invert\"), portMap->getInvert().toString());\r\n\r\n            if (docRevision == Document::Revision::Std14)\r\n            {\r\n                CommonItemsWriter::writeNonEmptyElement(writer, QStringLiteral(\"ipxact:isPresent\"), portMap->getIsPresent());\r\n            }\r\n\r\n            // Write ports for the port map.\r\n            if (portMap->getLogicalPort())\r\n            {\r\n                writeLogicalPort(writer, portMap->getLogicalPort());\r\n            }\r\n            if (portMap->getPhysicalPort())\r\n            {\r\n                writePhysicalPort(writer, portMap->getPhysicalPort());\r\n            }\r\n\r\n            CommonItemsWriter::writeNonEmptyElement(writer,\r\n                QStringLiteral(\"ipxact:logicalTieOff\"), portMap->getLogicalTieOff());\r\n            CommonItemsWriter::writeNonEmptyElement(writer,\r\n                QStringLiteral(\"ipxact:isInformative\"), portMap->getIsInformative().toString());\r\n\r\n            if (docRevision == Document::Revision::Std22)\r\n            {\r\n                CommonItemsWriter::writeVendorExtensions(writer, portMap);\r\n            }\r\n\r\n            writer.writeEndElement();\r\n        }\r\n\r\n        writer.writeEndElement();\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusInterfaceWriter::writeLogicalPort()\r\n//-----------------------------------------------------------------------------\r\nvoid BusInterfaceWriter::Details::writeLogicalPort(QXmlStreamWriter& writer,\r\n    QSharedPointer<PortMap::LogicalPort> logicalPort)\r\n{\r\n    writer.writeStartElement(QStringLiteral(\"ipxact:logicalPort\"));\r\n    writer.writeTextElement(QStringLiteral(\"ipxact:name\"), logicalPort->name_);\r\n\r\n    // Write range of the logical port.\r\n    QSharedPointer<Range> logicalRange = logicalPort->range_;\r\n    if (logicalRange && (logicalRange->getLeft().isEmpty() == false || logicalRange->getRight().isEmpty() == false))\r\n    {\r\n        writer.writeStartElement(QStringLiteral(\"ipxact:range\"));\r\n        writer.writeTextElement(QStringLiteral(\"ipxact:left\"), logicalPort->range_->getLeft());\r\n        writer.writeTextElement(QStringLiteral(\"ipxact:right\"), logicalPort->range_->getRight());\r\n        writer.writeEndElement();\r\n    }\r\n\r\n    writer.writeEndElement();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusInterfaceWriter::writePhysicalPort()\r\n//-----------------------------------------------------------------------------\r\nvoid BusInterfaceWriter::Details::writePhysicalPort(QXmlStreamWriter& writer,\r\n    QSharedPointer<PortMap::PhysicalPort> physicalPort)\r\n{\r\n    writer.writeStartElement(QStringLiteral(\"ipxact:physicalPort\"));\r\n    writer.writeTextElement(QStringLiteral(\"ipxact:name\"), physicalPort->name_);\r\n\r\n    QSharedPointer<PartSelect> partSelect = physicalPort->partSelect_;\r\n\r\n    CommonItemsWriter::writePartSelect(writer, partSelect);\r\n\r\n    writer.writeEndElement(); // ipxact:physicalPort\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusInterfaceWriter::writeInterfaceMode()\r\n//-----------------------------------------------------------------------------\r\nvoid BusInterfaceWriter::Details::writeInterfaceMode(QXmlStreamWriter& writer,\r\n    QSharedPointer<BusInterface> businterface)\r\n{\r\n    General::InterfaceMode interfaceMode = businterface->getInterfaceMode();\r\n    if (interfaceMode == General::INTERFACE_MODE_COUNT)\r\n    {\r\n        return;\r\n    }\r\n\r\n    writer.writeStartElement(QStringLiteral(\"ipxact:\") % General::interfaceMode2Str(interfaceMode));\r\n\r\n\t// Select the correct writer function for the interface mode.\r\n    if (interfaceMode == General::MASTER)\r\n    {\r\n        writeMasterInterface(writer, businterface->getMaster());\r\n    }       \r\n    // Mirrored master has only the element, no content.\r\n    else if (interfaceMode == General::SLAVE)\r\n    {\r\n        writeSlaveInterface(writer, businterface->getSlave());\r\n    }\r\n    else if (interfaceMode == General::MIRRORED_SLAVE)\r\n    {\r\n        writeMirroredSlaveInterface(writer, businterface->getMirroredSlave());\r\n    }\r\n    else if (interfaceMode == General::SYSTEM || interfaceMode == General::MIRRORED_SYSTEM)\r\n    {        \r\n        writer.writeTextElement(QStringLiteral(\"ipxact:group\"), businterface->getSystem());        \r\n    }\r\n    else if (interfaceMode == General::MONITOR)\r\n    {\r\n        writeMonitorInterface(writer, businterface);\r\n    }\r\n    else if (interfaceMode == General::INITIATOR)\r\n    {\r\n        writeInitiatorInterface(writer, businterface->getInitiator(), Document::Revision::Std22);\r\n    }\r\n    else if (interfaceMode == General::TARGET)\r\n    {\r\n        writeTargetInterface(writer, businterface->getTarget(), Document::Revision::Std22);\r\n    }\r\n    else if (interfaceMode == General::MIRRORED_TARGET)\r\n    {\r\n        writeMirroredTargetInterface(writer, businterface->getMirroredTarget(), Document::Revision::Std22);\r\n    }\r\n\r\n    writer.writeEndElement(); // ipxact:<mode>\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusInterfaceWriter::writeMasterInterface()\r\n//-----------------------------------------------------------------------------\r\nvoid BusInterfaceWriter::Details::writeMasterInterface(QXmlStreamWriter& writer,\r\n    QSharedPointer<InitiatorInterface> masterInterface)\r\n{\r\n    writeInitiatorInterface(writer, masterInterface, Document::Revision::Std14);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusInterfaceWriter::writeSlaveInterface()\r\n//-----------------------------------------------------------------------------\r\nvoid BusInterfaceWriter::Details::writeSlaveInterface(QXmlStreamWriter& writer, QSharedPointer<TargetInterface> slave)\r\n{\r\n    writeTargetInterface(writer, slave, Document::Revision::Std14);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusInterfaceWriter::writeMirroredSlaveInterface()\r\n//-----------------------------------------------------------------------------\r\nvoid BusInterfaceWriter::Details::writeMirroredSlaveInterface(QXmlStreamWriter& writer,\r\n    QSharedPointer<MirroredTargetInterface> mirroredSlave)\r\n{\r\n    writeMirroredTargetInterface(writer, mirroredSlave, Document::Revision::Std14);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusInterfaceWriter::writeMonitorInterface()\r\n//-----------------------------------------------------------------------------\r\nvoid BusInterfaceWriter::Details::writeMonitorInterface(QXmlStreamWriter& writer,\r\n    QSharedPointer<BusInterface> businterface)\r\n{\r\n    if (businterface->getMonitor() == nullptr)\r\n    {\r\n        return;\r\n    }\r\n\r\n    // Monitor has its interface mode as attribute.\r\n    writer.writeAttribute(QStringLiteral(\"interfaceMode\"),\r\n        General::interfaceMode2Str(businterface->getMonitor()->interfaceMode_));\r\n\r\n    CommonItemsWriter::writeNonEmptyElement(writer, QStringLiteral(\"ipxact:group\"),\r\n        businterface->getMonitor()->group_);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusInterfaceWriter::writeInitiatorInterface()\r\n//-----------------------------------------------------------------------------\r\nvoid BusInterfaceWriter::Details::writeInitiatorInterface(QXmlStreamWriter& writer,\r\n    QSharedPointer<InitiatorInterface> initiatorInterface, Document::Revision docRevsion)\r\n{\r\n    if (initiatorInterface == nullptr ||\r\n        (initiatorInterface->getAddressSpaceRef().isEmpty() && initiatorInterface->getBaseAddress().isEmpty()))\r\n    {\r\n        return;\r\n    }\r\n\r\n    writer.writeStartElement(QStringLiteral(\"ipxact:addressSpaceRef\"));\r\n\r\n    // Write address space reference if it exists.            \r\n    CommonItemsWriter::writeNonEmptyAttribute(writer,\r\n        QStringLiteral(\"addressSpaceRef\"), initiatorInterface->getAddressSpaceRef());\r\n\r\n    if (docRevsion == Document::Revision::Std14)\r\n    {\r\n        CommonItemsWriter::writeIsPresent(writer, initiatorInterface->getIsPresent());\r\n    }\r\n\r\n    // Write base address if it exists.\r\n    if (!initiatorInterface->getBaseAddress().isEmpty())\r\n    {\r\n        writer.writeStartElement(QStringLiteral(\"ipxact:baseAddress\"));\r\n\r\n        // Write the value of the baseAddress element and close the tag.\r\n        writer.writeCharacters(initiatorInterface->getBaseAddress());\r\n        writer.writeEndElement(); // ipxact:baseAddress\r\n    }\r\n\r\n    writer.writeEndElement(); // ipxact:addressSpaceRef\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusInterfaceWriter::writeTargetInterface()\r\n//-----------------------------------------------------------------------------\r\nvoid BusInterfaceWriter::Details::writeTargetInterface(QXmlStreamWriter& writer,\r\n    QSharedPointer<TargetInterface> target, Document::Revision docRevision)\r\n{\r\n    if (target == nullptr)\r\n    {\r\n        return;\r\n    }\r\n\r\n    // Write memory map reference, along its attributes.\r\n    if (!target->getMemoryMapRef().isEmpty())\r\n    {\r\n        writer.writeStartElement(QStringLiteral(\"ipxact:memoryMapRef\"));\r\n        writer.writeAttribute(QStringLiteral(\"memoryMapRef\"), target->getMemoryMapRef());\r\n\r\n        if (docRevision == Document::Revision::Std22)\r\n        {\r\n            for (auto const& mode : target->getModeRefs())\r\n            {\r\n                writer.writeTextElement(QStringLiteral(\"ipxact:modeRef\"), mode);\r\n            }\r\n        }\r\n\r\n        writer.writeEndElement(); // ipxact:memoryMapRef\r\n    }\r\n\r\n    // Write all bridges.\r\n    for (QSharedPointer<TransparentBridge> const& bridge : *target->getBridges())\r\n    {\r\n        // Bridge has a master reference.\r\n        writer.writeStartElement(QStringLiteral(\"ipxact:transparentBridge\"));\r\n\r\n        if (docRevision == Document::Revision::Std14)\r\n        {\r\n            writer.writeAttribute(QStringLiteral(\"masterRef\"), bridge->getMasterRef());\r\n        }\r\n        else if (docRevision == Document::Revision::Std22)\r\n        {\r\n            writer.writeAttribute(QStringLiteral(\"initiatorRef\"), bridge->getInitiatorRef());\r\n        }\r\n\r\n        if (docRevision == Document::Revision::Std14)\r\n        {\r\n            CommonItemsWriter::writeNonEmptyElement(writer, QStringLiteral(\"ipxact:isPresent\"),\r\n                bridge->getIsPresent());\r\n        }\r\n\r\n        if (docRevision == Document::Revision::Std22)\r\n        {\r\n            CommonItemsWriter::writeVendorExtensions(writer, bridge);\r\n        }\r\n        writer.writeEndElement();\r\n    }\r\n\r\n    // Write file set reference groups.\r\n    for (QSharedPointer<TargetInterface::FileSetRefGroup> const& group : *target->getFileSetRefGroup())\r\n    {\r\n        writer.writeStartElement(QStringLiteral(\"ipxact:fileSetRefGroup\"));\r\n\r\n        // Write the name of the group.\r\n        writer.writeTextElement(QStringLiteral(\"ipxact:group\"), group->group_);\r\n\r\n        // Write all the fileSetRefs for this group.\r\n        CommonItemsWriter::writeFileSetReferences(writer, group->fileSetRefs_, docRevision);\r\n\r\n        writer.writeEndElement(); // ipxact:fileSetRefGroup\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusInterfaceWriter::writeMirroredTargetInterface()\r\n//-----------------------------------------------------------------------------\r\nvoid BusInterfaceWriter::Details::writeMirroredTargetInterface(QXmlStreamWriter& writer,\r\n    QSharedPointer<MirroredTargetInterface> mirroredTarget, Document::Revision docRevision)\r\n{\r\n    if (mirroredTarget == nullptr || mirroredTarget->getRange().isEmpty())\r\n    {\r\n        return;\r\n    }\r\n\r\n    writer.writeStartElement(QStringLiteral(\"ipxact:baseAddresses\"));\r\n\r\n    // Write all remap addresses.\r\n    for (QSharedPointer<MirroredTargetInterface::RemapAddress> const& remapAddress :\r\n        *mirroredTarget->getRemapAddresses())\r\n    {\r\n        if (docRevision == Document::Revision::Std22)\r\n        {\r\n            writer.writeStartElement(QStringLiteral(\"ipxact:remapAddresses\"));\r\n        }\r\n\r\n        writer.writeStartElement(QStringLiteral(\"ipxact:remapAddress\"));\r\n\r\n        if (docRevision == Document::Revision::Std14)\r\n        {\r\n            // Write state if it exists.               \r\n            CommonItemsWriter::writeNonEmptyAttribute(writer, QStringLiteral(\"state\"), remapAddress->state_);\r\n\r\n            // Write the rest of the attributes.\r\n            CommonItemsWriter::writeAttributes(writer, remapAddress->remapAttributes_);\r\n        }\r\n\r\n        writer.writeCharacters(remapAddress->remapAddress_);\r\n\r\n        if (docRevision == Document::Revision::Std22)\r\n        {\r\n            for (auto const& modeRef : remapAddress->modeRefs_)\r\n            {\r\n                writer.writeTextElement(QStringLiteral(\"ipxact:modeRef\"), modeRef);\r\n                if (remapAddress->priorities_.contains(modeRef))\r\n                {\r\n                    writer.writeAttribute(QStringLiteral(\"priority\"),\r\n                        QString::number(remapAddress->priorities_.value(modeRef)));\r\n                }\r\n\r\n            }\r\n        }\r\n\r\n        writer.writeEndElement(); // ipxact:remapAddress\r\n\r\n        if (docRevision == Document::Revision::Std22)\r\n        {\r\n            writer.writeEndElement(); // ipxact:remapAddresses\r\n        }\r\n    }\r\n\r\n    CommonItemsWriter::writeNonEmptyElement(writer, QStringLiteral(\"ipxact:range\"), mirroredTarget->getRange());\r\n\r\n    writer.writeEndElement(); // ipxact:baseAddresses\r\n}\r\n"
  },
  {
    "path": "IPXACTmodels/Component/BusInterfaceWriter.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: businterfaceWriter.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Janne Virtanen\r\n// Date: 22.09.2015\r\n//\r\n// Description:\r\n// Writer class for IP-XACT businterface element.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef businterfaceWriter_H\r\n#define businterfaceWriter_H\r\n\r\n#include \"BusInterface.h\"\r\n\r\n#include <IPXACTmodels/common/Document.h>\r\n#include <IPXACTmodels/common/CommonItemsWriter.h>\r\n#include <IPXACTmodels/Component/PortMap.h>\r\n\r\n#include <QSharedPointer>\r\n#include <QDomNode>\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Writer class for IP-XACT businterface element.\r\n//-----------------------------------------------------------------------------\r\nnamespace BusInterfaceWriter \r\n{\r\n    /*!\r\n     *  Write a businterface to an XML file.\r\n     *\r\n     *    @param [in] writer\t\t\tThe used xml writer.\r\n     *    @param [in] businterface\tThe businterface to be written.\r\n     *    @param [in] docRevision     The applied IP-XACT standard revision.\r\n     */\r\n\tIPXACTMODELS_EXPORT void writeBusInterface(QXmlStreamWriter& writer,\r\n\t\tQSharedPointer<BusInterface> businterface, Document::Revision docRevision);\r\n\r\n\tnamespace Details\r\n\t{\r\n\r\n\t\t/*!\r\n\t\t *  Writes the connection requirement.\r\n\t\t *\r\n\t\t *    @param [in] writer          The used XML writer.\r\n\t\t *    @param [in] busInterface    The bus interface to be written.\r\n\t\t */\r\n\t\tvoid writeConnectionRequired(QXmlStreamWriter& writer, QSharedPointer<BusInterface> busInterface);\r\n\r\n\t\t/*!\r\n\t\t *  Writes the bits in lau.\r\n\t\t *\r\n\t\t *    @param [in] writer          The used XML writer.\r\n\t\t *    @param [in] busInterface    The bus interface to be written.\r\n\t\t */\r\n\t\tvoid writeBitsInLau(QXmlStreamWriter& writer, QSharedPointer<BusInterface> busInterface);\r\n\r\n\t\t/*!\r\n\t\t *  Writes the endianness.\r\n\t\t *\r\n\t\t *    @param [in] writer          The used XML writer.\r\n\t\t *    @param [in] busInterface    The bus interface to be written.\r\n\t\t */\r\n\t\tvoid writeEndianness(QXmlStreamWriter& writer, QSharedPointer<BusInterface> busInterface);\r\n\r\n\t\t/*!\r\n\t\t *  Write the bit steering of businterface.\r\n\t\t *\r\n\t\t *    @param [in] writer\t\t\t\tThe used xml writer.\r\n\t\t *    @param [in] businterface\t\tThe businterface to be written.\r\n\t\t */\r\n\t\tvoid writeBitSteering(QXmlStreamWriter& writer, QSharedPointer<BusInterface> businterface);\r\n\r\n\t\t/*!\r\n\t\t *  Write the abstraction types of businterface.\r\n\t\t *\r\n\t\t *    @param [in] writer\t\t\t\tThe used xml writer.\r\n         *    @param [in] businterface\t\tThe businterface to be written.\r\n         *    @param [in] docRevision\t\t\tThe applied IP-XACT standard revision.\r\n\t\t */\r\n\t\tvoid writeAbstractionTypes(QXmlStreamWriter& writer, QSharedPointer<BusInterface> businterface,\r\n\t\t\tDocument::Revision docRevision);\r\n\r\n\t\t/*!\r\n\t\t *  Write the port maps of an abstraction type.\r\n\t\t *\r\n\t\t *    @param [in] writer\t\t\t\tThe used xml writer.\r\n         *    @param [in] abstractionType\t\tThe abstraction type whose port maps to write.\r\n\t\t *    @param [in] docRevision\t\t\tThe applied IP-XACT standard revision.\r\n\t\t */\r\n\t\tvoid writePortMaps(QXmlStreamWriter& writer, QSharedPointer<AbstractionType> abstractionType,\r\n\t\t\tDocument::Revision docRevision);\r\n\r\n\t\t/*!\r\n\t\t *  Write the logical port of port map.\r\n\t\t *\r\n\t\t *    @param [in] writer\t\t\t\tThe used xml writer.\r\n\t\t *    @param [in] logicalPort\t\t    The logical port to be written.\r\n\t\t */\r\n\t\tvoid writeLogicalPort(QXmlStreamWriter& writer, QSharedPointer<PortMap::LogicalPort> physicalPort);\r\n\r\n\t\t/*!\r\n\t\t *  Write the physical port of port map.\r\n\t\t *\r\n\t\t *    @param [in] writer\t\t\t\tThe used xml writer.\r\n\t\t *    @param [in] physicalPort\t\tThe physical port to be written.\r\n\t\t */\r\n\t\tvoid writePhysicalPort(QXmlStreamWriter& writer, QSharedPointer<PortMap::PhysicalPort> physicalPort);\r\n\r\n\t\t/*!\r\n\t\t *  Write the interface mode of businterface.\r\n\t\t *\r\n\t\t *    @param [in] writer\t\t\t\tThe used xml writer.\r\n\t\t *    @param [in] businterface\t\tThe businterface to be written.\r\n\t\t */\r\n\t\tvoid writeInterfaceMode(QXmlStreamWriter& writer, QSharedPointer<BusInterface> businterface);\r\n\r\n\t\t/*!\r\n\t\t *  Write the master interface of businterface.\r\n\t\t *\r\n\t\t *    @param [in] writer\t\t\t\tThe used xml writer.\r\n\t\t *    @param [in] businterface\t\tThe businterface master to be written.\r\n\t\t */\r\n\t\tvoid writeMasterInterface(QXmlStreamWriter& writer, QSharedPointer<InitiatorInterface> masterInterface);\r\n\r\n\t\t/*!\r\n\t\t *  Write the slave interface of businterface.\r\n\t\t *\r\n\t\t *    @param [in] writer\t\t\t\tThe used xml writer.\r\n\t\t *    @param [in] businterface\t\tThe businterface slave to be written.\r\n\t\t */\r\n\t\tvoid writeSlaveInterface(QXmlStreamWriter& writer, QSharedPointer<TargetInterface> slave);\r\n\r\n\t\t/*!\r\n\t\t *  Write the mirrored slave interface of businterface.\r\n\t\t *\r\n\t\t *    @param [in] writer\t\t\t\tThe used xml writer.\r\n\t\t *    @param [in] businterface\t\tThe businterface to be written.\r\n\t\t */\r\n\t\tvoid writeMirroredSlaveInterface(QXmlStreamWriter& writer,\r\n\t\t\tQSharedPointer<MirroredTargetInterface> mirroredSlave);\r\n\r\n\t\t/*!\r\n\t\t *  Write the monitor interface of businterface.\r\n\t\t *\r\n\t\t *    @param [in] writer\t\t\t\tThe used xml writer.\r\n\t\t *    @param [in] businterface\t\tThe businterface to be written.\r\n\t\t */\r\n\t\tvoid writeMonitorInterface(QXmlStreamWriter& writer, QSharedPointer<BusInterface> businterface);\r\n\r\n\t\tvoid writeInitiatorInterface(QXmlStreamWriter& writer, \r\n\t\t\tQSharedPointer<InitiatorInterface> initiatorInterface, Document::Revision docRevsion);\r\n\r\n\t\tvoid writeTargetInterface(QXmlStreamWriter& writer, QSharedPointer<TargetInterface> target,\r\n\t\t\tDocument::Revision docRevision);\r\n\t\tvoid writeMirroredTargetInterface(QXmlStreamWriter& writer, \r\n\t\t\tQSharedPointer<MirroredTargetInterface> mirroredTarget, Document::Revision docRevision);\r\n\t}\r\n};\r\n\r\n#endif // businterfaceWriter_H"
  },
  {
    "path": "IPXACTmodels/Component/CPUReader.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: CPUReader.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Janne Virtanen\r\n// Date: 15.09.2015\r\n//\r\n// Description:\r\n// Reader class for IP-XACT CPU element.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"CPUReader.h\"\r\n\r\n#include <IPXACTmodels/common/NameGroupReader.h>\r\n#include <IPXACTmodels/common/ParameterReader.h>\r\n\r\n#include <IPXACTmodels/common/FileBuilderReader.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: CPUReader::createCPUFrom()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<Cpu> CPUReader::createCPUFrom(QDomNode const& cpuNode, Document::Revision docRevision)\r\n{\r\n\t// Create the new CPU.\r\n\tQSharedPointer<Cpu> newCpu (new Cpu());\r\n\r\n    NameGroupReader::parseNameGroup(cpuNode, newCpu);\r\n\r\n    if (docRevision == Document::Revision::Std14)\r\n    {\r\n        Details::parseIsPresent(cpuNode, newCpu);\r\n\r\n        Details::parseAddressSpaceRefs(cpuNode, newCpu);\r\n    }\r\n    else if (docRevision == Document::Revision::Std22)\r\n    {\r\n        Details::parseBlockSize(cpuNode, newCpu);\r\n\r\n        Details::parseRegions(cpuNode, newCpu);\r\n\r\n        Details::parseAddressUnitBits(cpuNode, newCpu);\r\n\r\n        Details::parseExecutableImages(cpuNode, newCpu);\r\n\r\n        Details::parseMemoryMapReference(cpuNode, newCpu);\r\n    }\r\n\r\n    Details::parseParameters(cpuNode, newCpu);\r\n\r\n    CommonItemsReader::parseVendorExtensions( cpuNode, newCpu );\r\n\r\n    return newCpu;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: CPUReader::parseIsPresent()\r\n//-----------------------------------------------------------------------------\r\nvoid CPUReader::Details::parseIsPresent(QDomNode const& cpuNode, QSharedPointer<Cpu> newCPU)\r\n{\r\n    newCPU->setIsPresent(CommonItemsReader::parseIsPresent(\r\n        cpuNode.firstChildElement(QStringLiteral(\"ipxact:isPresent\"))));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: CPUReader::parseAddressSpaceRefs()\r\n//-----------------------------------------------------------------------------\r\nvoid CPUReader::Details::parseAddressSpaceRefs(QDomNode const& cpuNode, QSharedPointer<Cpu> newCpu)\r\n{\r\n    QDomNodeList referenceNodes = cpuNode.toElement().elementsByTagName(QStringLiteral(\"ipxact:addressSpaceRef\"));\r\n\r\n    for (int spaceIndex = 0; spaceIndex < referenceNodes.count(); ++spaceIndex)\r\n    {\r\n        QDomElement addressSpaceElement = referenceNodes.at(spaceIndex).toElement();\r\n\r\n        QString reference = addressSpaceElement.attribute(QStringLiteral(\"addressSpaceRef\"));\r\n        QSharedPointer<Cpu::AddressSpaceRef> newAddressSpaceReference(new Cpu::AddressSpaceRef(reference));\r\n\r\n        QDomElement isPresentElement = addressSpaceElement.firstChildElement(QStringLiteral(\"ipxact:isPresent\"));\r\n        newAddressSpaceReference->setIsPresent(CommonItemsReader::parseIsPresent(isPresentElement));\r\n\r\n        newCpu->getAddressSpaceReferences()->append(newAddressSpaceReference);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: CPUReader::Details::parseBlockSize()\r\n//-----------------------------------------------------------------------------\r\nvoid CPUReader::Details::parseBlockSize(QDomNode const& cpuNode, QSharedPointer<Cpu> newCpu)\r\n{\r\n    QDomElement rangeElement = cpuNode.firstChildElement(QStringLiteral(\"ipxact:range\"));\r\n    newCpu->setRange(rangeElement.firstChild().nodeValue());\r\n\r\n    QDomElement widthElement = cpuNode.firstChildElement(QStringLiteral(\"ipxact:width\"));\r\n    newCpu->setWidth(widthElement.firstChild().nodeValue());\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: CPUReader::Details::parseRegions()\r\n//-----------------------------------------------------------------------------\r\nvoid CPUReader::Details::parseRegions(QDomNode const& cpuNode, QSharedPointer<Cpu> newCpu)\r\n{\r\n    QDomNode regionsNode = cpuNode.firstChildElement(QStringLiteral(\"ipxact:regions\"));\r\n\r\n    QDomNodeList regionNodes = regionsNode.childNodes();\r\n    const int REGION_COUNT = regionNodes.count();\r\n    for (int i = 0; i < REGION_COUNT; ++i)\r\n    {\r\n        QDomNode regionNode = regionNodes.at(i);\r\n        QSharedPointer<Region> newRegion(new Region());\r\n\r\n        NameGroupReader::parseNameGroup(regionNode, newRegion);\r\n\r\n        QDomElement offsetElement = regionNode.firstChildElement(QStringLiteral(\"ipxact:addressOffset\"));\r\n        newRegion->setOffset(offsetElement.firstChild().nodeValue());\r\n\r\n        QDomElement rangeElement = regionNode.firstChildElement(QStringLiteral(\"ipxact:range\"));\r\n        newRegion->setRange(rangeElement.firstChild().nodeValue());\r\n\r\n        CommonItemsReader::parseVendorExtensions(regionNode, newRegion);\r\n\r\n        newCpu->getRegions()->append(newRegion);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: CPUReader::Details::parseAddressUnitBits()\r\n//-----------------------------------------------------------------------------\r\nvoid CPUReader::Details::parseAddressUnitBits(QDomNode const& cpuNode, QSharedPointer<Cpu> newCpu)\r\n{\r\n    QDomElement aubElement = cpuNode.firstChildElement(QStringLiteral(\"ipxact:addressUnitBits\"));\r\n    newCpu->setAddressUnitBits(aubElement.firstChild().nodeValue());\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: CPUReader::Details::parseExecutableImages()\r\n//-----------------------------------------------------------------------------\r\nvoid CPUReader::Details::parseExecutableImages(QDomNode const& cpuNode, QSharedPointer<Cpu> newCpu)\r\n{\r\n    QDomNodeList imageNodes = cpuNode.toElement().elementsByTagName(QStringLiteral(\"ipxact:executableImage\"));\r\n\r\n    const int IMAGE_COUNT = imageNodes.count();\r\n    for (int i = 0; i < IMAGE_COUNT; ++i)\r\n    {\r\n        QDomElement imageElement = imageNodes.at(i).toElement();\r\n        QSharedPointer<ExecutableImage> image(new ExecutableImage);\r\n\r\n        NameGroupReader::parseNameGroup(imageElement, image);\r\n\r\n        QString id = imageElement.attribute(QStringLiteral(\"imageId\"));\r\n        image->setImageId(id);\r\n\r\n        QString type = imageElement.attribute(QStringLiteral(\"imageType\"));\r\n        image->setImageType(type);\r\n\r\n        image->setParameters(CommonItemsReader::parseAndCreateParameters(imageElement, Document::Revision::Std22));\r\n\r\n        auto languageToolsElement = imageElement.firstChildElement(QStringLiteral(\"ipxact:languageTools\"));\r\n        Details::parseLanguageTools(languageToolsElement, image);\r\n\r\n        newCpu->getExecutableImages()->append(image);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: CPUReader::Details::parseLanguageTools()\r\n//-----------------------------------------------------------------------------\r\nvoid CPUReader::Details::parseLanguageTools(QDomElement const& languageToolsElement,\r\n    QSharedPointer<ExecutableImage> image)\r\n{\r\n    QDomNodeList fileBuilderNodes = languageToolsElement.elementsByTagName(QStringLiteral(\"ipxact:fileBuilder\"));\r\n\r\n    QSharedPointer<LanguageTools> languageTools(new LanguageTools);\r\n    \r\n    const int BUILDER_COUNT = fileBuilderNodes.count();\r\n    for (int i = 0; i < BUILDER_COUNT; ++i)\r\n    {\r\n        QDomNode builderElement = fileBuilderNodes.at(i);\r\n\r\n        auto fileBuilder = FileBuilderReader::createFileBuilderFrom(builderElement, Document::Revision::Std22);\r\n        languageTools->getFileBuilders()->append(fileBuilder);\r\n    }\r\n\r\n    auto linkerElement = languageToolsElement.firstChildElement(QStringLiteral(\"ipxact:linker\"));\r\n    languageTools->setLinker(linkerElement.firstChild().nodeValue());\r\n\r\n    auto linkerFlagsElement = languageToolsElement.firstChildElement(QStringLiteral(\"ipxact:linkerFlags\"));\r\n    languageTools->setLinkerFlags(linkerFlagsElement.firstChild().nodeValue());\r\n\r\n    auto linkerCommandFileElement = languageToolsElement.firstChildElement(QStringLiteral(\"ipxact:linkerCommandFile\"));\r\n\r\n    parseLinkerCommandFile(linkerCommandFileElement, languageTools);\r\n\r\n    image->setLanguageTools(languageTools);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: CPUReader::Details::parseLinkerCommandFile()\r\n//-----------------------------------------------------------------------------\r\nvoid CPUReader::Details::parseLinkerCommandFile(QDomElement const& linkerCommandFileElement,\r\n    QSharedPointer<LanguageTools> languageTools)\r\n{\r\n    auto linkerCommandFile = languageTools->getLinkerCommandFile();\r\n\r\n    auto nameElement = linkerCommandFileElement.firstChildElement(QStringLiteral(\"ipxact:name\"));\r\n    linkerCommandFile->name_ = nameElement.firstChild().nodeValue();\r\n\r\n    auto switchElement = linkerCommandFileElement.firstChildElement(QStringLiteral(\"ipxact:commandLineSwitch\"));\r\n    linkerCommandFile->commandLineSwitch_ = switchElement.firstChild().nodeValue();\r\n\r\n    auto enableElement = linkerCommandFileElement.firstChildElement(QStringLiteral(\"ipxact:enable\"));\r\n    linkerCommandFile->enable_ = enableElement.firstChild().nodeValue();\r\n\r\n    auto generatorRefs = linkerCommandFileElement.elementsByTagName(QStringLiteral(\"ipxact:generatorRef\"));\r\n    const int GENERATOR_COUNT = generatorRefs.count();\r\n    for (int i = 0; i < GENERATOR_COUNT; ++i)\r\n    {\r\n        QDomNode generatorNode = generatorRefs.at(i);\r\n        linkerCommandFile->generatorRefs_.append(generatorNode.firstChild().nodeValue());\r\n    }\r\n\r\n    CommonItemsReader::parseVendorExtensions(linkerCommandFileElement, linkerCommandFile);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: CPUReader::Details::parseMemoryMapReference()\r\n//-----------------------------------------------------------------------------\r\nvoid CPUReader::Details::parseMemoryMapReference(QDomNode const& cpuNode, QSharedPointer<Cpu> newCpu)\r\n{\r\n    QDomElement memoryMapRefElement = cpuNode.firstChildElement(QStringLiteral(\"ipxact:memoryMapRef\"));\r\n    newCpu->setMemoryMapReference(memoryMapRefElement.firstChild().nodeValue());\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: CPUReader::parseParameters()\r\n//-----------------------------------------------------------------------------\r\nvoid CPUReader::Details::parseParameters(QDomNode const& cpuNode, QSharedPointer<Cpu> newCpu)\r\n{\r\n    QSharedPointer<QList<QSharedPointer<Parameter> > > parameters = CommonItemsReader::parseAndCreateParameters(cpuNode);\r\n\r\n    if (!parameters->isEmpty())\r\n    {\r\n        newCpu->getParameters()->append(*parameters);\r\n    }\r\n}\r\n"
  },
  {
    "path": "IPXACTmodels/Component/CPUReader.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: CPUReader.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Janne Virtanen\r\n// Date: 15.09.2015\r\n//\r\n// Description:\r\n// Reader class for IP-XACT CPU element.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef CPUReader_H\r\n#define CPUReader_H\r\n\r\n#include \"Cpu.h\"\r\n\r\n#include <IPXACTmodels/common/CommonItemsReader.h>\r\n#include <IPXACTmodels/common/Document.h>\r\n\r\n#include <QSharedPointer>\r\n#include <QDomNode>\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Reader class for IP-XACT CPU element.\r\n//-----------------------------------------------------------------------------\r\nnamespace CPUReader\r\n{\r\n    /*!\r\n     *  Creates a new CPU from a given CPU node.\r\n     *\r\n     *    @param [in] cpuNode    XML description of the CPU.\r\n     */\r\n    IPXACTMODELS_EXPORT QSharedPointer<Cpu> createCPUFrom(QDomNode const& cpuNode, Document::Revision docRevision);\r\n\r\n    namespace Details\r\n    {\r\n        /*!\r\n         *  Reads the presence.\r\n         *\r\n         *    @param [in] cpuNode    XML description of the cpu.\r\n         *    @param [in] newCPU     The new cpu item.\r\n         */\r\n        void parseIsPresent(QDomNode const& cpuNode, QSharedPointer<Cpu> newCPU);\r\n\r\n        /*!\r\n         *  Reads the address space references.\r\n         *\r\n         *    @param [in] cpuNode    XML description of the cpu.\r\n         *    @param [in] newCPU     The new cpu item.\r\n         */\r\n        void parseAddressSpaceRefs(QDomNode const& cpuNode, QSharedPointer<Cpu> newCpu);\r\n\r\n        void parseBlockSize(QDomNode const& cpuNode, QSharedPointer<Cpu> newCpu);\r\n\r\n        void parseRegions(QDomNode const& cpuNode, QSharedPointer<Cpu> newCpu);\r\n\r\n        void parseAddressUnitBits(QDomNode const& cpuNode, QSharedPointer<Cpu> newCpu);\r\n\r\n        void parseExecutableImages(QDomNode const& cpuNode, QSharedPointer<Cpu> newCpu);\r\n\r\n        void parseLanguageTools(QDomElement const& languageToolsElement, QSharedPointer<ExecutableImage> image);\r\n\r\n        void parseLinkerCommandFile(QDomElement const& linkerCommandFileElement,\r\n            QSharedPointer<LanguageTools> languageTools);\r\n\r\n        void parseMemoryMapReference(QDomNode const& cpuNode, QSharedPointer<Cpu> newCpu);\r\n\r\n        /*!\r\n         *  Reads the parameters.\r\n         *\r\n         *    @param [in] cpuNode    XML description of the cpu.\r\n         *    @param [in] newCPU     The new cpu item.\r\n         */\r\n        void parseParameters(QDomNode const& cpuNode, QSharedPointer<Cpu> newCpu);\r\n    }\r\n};\r\n\r\n#endif // CPUReader_H\r\n"
  },
  {
    "path": "IPXACTmodels/Component/CPUWriter.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: CPUWriter.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Janne Virtanen\r\n// Date: 15.09.2015\r\n//\r\n// Description:\r\n// Writer class for IP-XACT CPU element.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"CPUWriter.h\"\r\n\r\n#include <IPXACTmodels/common/NameGroupWriter.h>\r\n#include <IPXACTmodels/common/ParameterWriter.h>\r\n#include <IPXACTmodels/common/FileBuilderWriter.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: CPUWriter::writeCPU()\r\n//-----------------------------------------------------------------------------\r\nvoid CPUWriter::writeCPU(QXmlStreamWriter& writer, QSharedPointer<Cpu> cpu, Document::Revision docRevision)\r\n{\r\n\t// Start the element, write name group, presence and vendor extensions with pre-existing writers.\r\n\twriter.writeStartElement(QStringLiteral(\"ipxact:cpu\"));\r\n\r\n    NameGroupWriter::writeNameGroup(writer, cpu, docRevision);\r\n\r\n    if (docRevision == Document::Revision::Std14)\r\n    {\r\n        CommonItemsWriter::writeIsPresent(writer, cpu->getIsPresent());\r\n\r\n        Details::writeAddressSpaceRefs(writer, cpu);\r\n    }\r\n    else if (docRevision == Document::Revision::Std22)\r\n    {\r\n        Details::writeBlockSize(writer, cpu);\r\n\r\n        Details::writeRegions(writer, cpu);\r\n\r\n        Details::writeAddressUnitBits(writer, cpu);\r\n\r\n        Details::writeExecutableImages(writer, cpu);\r\n\r\n        Details::writeMemoryMapRef(writer, cpu);\r\n    }\r\n\r\n    CommonItemsWriter::writeParameters(writer, cpu->getParameters(), docRevision);\r\n\r\n    CommonItemsWriter::writeVendorExtensions( writer, cpu );\r\n\r\n\twriter.writeEndElement(); // ipxact:cpu\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: CPUWriter::writeAddressSpaceRefs()\r\n//-----------------------------------------------------------------------------\r\nvoid CPUWriter::Details::writeAddressSpaceRefs(QXmlStreamWriter& writer, QSharedPointer<Cpu> cpu)\r\n{\r\n    for (QSharedPointer<Cpu::AddressSpaceRef> reference : *cpu->getAddressSpaceReferences())\r\n    {\r\n        writer.writeStartElement(QStringLiteral(\"ipxact:addressSpaceRef\"));\r\n\r\n        writer.writeAttribute(QStringLiteral(\"addressSpaceRef\"), reference->getAddressSpaceRef());\r\n\r\n        CommonItemsWriter::writeIsPresent(writer, reference->getIsPresent());\r\n\r\n        writer.writeEndElement(); // ipxact:addressSpaceRef\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: CPUWriter::Details::writeBlockSize()\r\n//-----------------------------------------------------------------------------\r\nvoid CPUWriter::Details::writeBlockSize(QXmlStreamWriter& writer, QSharedPointer<Cpu> cpu)\r\n{\r\n    CommonItemsWriter::writeNonEmptyElement(writer, QStringLiteral(\"ipxact:range\"), cpu->getRange());\r\n    CommonItemsWriter::writeNonEmptyElement(writer, QStringLiteral(\"ipxact:width\"), cpu->getWidth());\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: CPUWriter::Details::writeRegions()\r\n//-----------------------------------------------------------------------------\r\nvoid CPUWriter::Details::writeRegions(QXmlStreamWriter& writer, QSharedPointer<Cpu> cpu)\r\n{\r\n    if (cpu->getRegions()->isEmpty())\r\n    {\r\n        return;\r\n    }\r\n\r\n    writer.writeStartElement(QStringLiteral(\"ipxact:regions\"));\r\n    for (auto const& region : *cpu->getRegions())\r\n    {\r\n        writer.writeStartElement(QStringLiteral(\"ipxact:region\"));\r\n\r\n        NameGroupWriter::writeNameGroup(writer, region, Document::Revision::Std22);\r\n\r\n        writer.writeTextElement(QStringLiteral(\"ipxact:addressOffset\"), region->getAddressOffset());\r\n\r\n        writer.writeTextElement(QStringLiteral(\"ipxact:range\"), region->getRange());\r\n\r\n        CommonItemsWriter::writeVendorExtensions(writer, region);\r\n\r\n        writer.writeEndElement(); // ipxact:region\r\n    }\r\n\r\n    writer.writeEndElement(); // ipxact:regions\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: CPUWriter::Details::writeExecutableImages()\r\n//-----------------------------------------------------------------------------\r\nvoid CPUWriter::Details::writeExecutableImages(QXmlStreamWriter& writer, QSharedPointer<Cpu> cpu)\r\n{\r\n    for (auto const& image : *cpu->getExecutableImages())\r\n    {\r\n        writer.writeStartElement(QStringLiteral(\"ipxact:executableImage\"));\r\n        writer.writeAttribute(QStringLiteral(\"imageId\"), image->getImageId());\r\n        CommonItemsWriter::writeNonEmptyAttribute(writer, QStringLiteral(\"imageType\"), image->getImageType());\r\n\r\n        NameGroupWriter::writeNameGroup(writer, image, Document::Revision::Std22);\r\n\r\n        CommonItemsWriter::writeParameters(writer, image->getParameters());\r\n\r\n        Details::writeLanguageTools(writer, image->getLanguageTools());\r\n\r\n        writer.writeEndElement(); // ipxact:executableImage\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: CPUWriter::Details::writeLanguageTools()\r\n//-----------------------------------------------------------------------------\r\nvoid CPUWriter::Details::writeLanguageTools(QXmlStreamWriter& writer, QSharedPointer<LanguageTools> languageTools)\r\n{\r\n    if (languageTools.isNull())\r\n    {\r\n        return;\r\n    }\r\n\r\n    writer.writeStartElement(QStringLiteral(\"ipxact:languageTools\"));\r\n\r\n    for (auto const& fileBuilder : *languageTools->getFileBuilders())\r\n    {\r\n        FileBuilderWriter::writeFileBuilder(writer, fileBuilder, Document::Revision::Std22);\r\n    }\r\n\r\n    writer.writeTextElement(QStringLiteral(\"ipxact:linker\"), languageTools->getLinker());\r\n\r\n    CommonItemsWriter::writeNonEmptyElement(writer, QStringLiteral(\"ipxact:linkerFlags\"),\r\n        languageTools->getLinkerFlags());\r\n\r\n    auto linkerCommandFile = languageTools->getLinkerCommandFile();\r\n    if (linkerCommandFile->name_.isEmpty() == false)\r\n    {\r\n        writer.writeStartElement(QStringLiteral(\"ipxact:linkerCommandFile\"));\r\n\r\n        writer.writeTextElement(QStringLiteral(\"ipxact:name\"), linkerCommandFile->name_);\r\n\r\n        writer.writeTextElement(QStringLiteral(\"ipxact:commandLineSwitch\"), linkerCommandFile->commandLineSwitch_);\r\n\r\n        writer.writeTextElement(QStringLiteral(\"ipxact:enable\"), linkerCommandFile->enable_);\r\n\r\n        for (auto const& generatorRef : linkerCommandFile->generatorRefs_)\r\n        {\r\n            writer.writeTextElement(QStringLiteral(\"ipxact:generatorRef\"), generatorRef);\r\n        }\r\n\r\n        CommonItemsWriter::writeVendorExtensions(writer, linkerCommandFile);\r\n\r\n        writer.writeEndElement(); // ipxact:linkerCommandFile\r\n    }\r\n\r\n    writer.writeEndElement(); // ipxact:languageTools\"\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: CPUWriter::Details::writeAddressUnitBits()\r\n//-----------------------------------------------------------------------------\r\nvoid CPUWriter::Details::writeAddressUnitBits(QXmlStreamWriter& writer, QSharedPointer<Cpu> cpu)\r\n{\r\n    CommonItemsWriter::writeNonEmptyElement(writer, QStringLiteral(\"ipxact:addressUnitBits\"), \r\n        cpu->getAddressUnitBits(false));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: CPUWriter::Details::writeMemoryMapRef()\r\n//-----------------------------------------------------------------------------\r\nvoid CPUWriter::Details::writeMemoryMapRef(QXmlStreamWriter& writer, QSharedPointer<Cpu> cpu)\r\n{\r\n    CommonItemsWriter::writeNonEmptyElement(writer, QStringLiteral(\"ipxact:memoryMapRef\"),\r\n        cpu->getMemoryMapReference());\r\n}\r\n"
  },
  {
    "path": "IPXACTmodels/Component/CPUWriter.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: CPUWriter.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Janne Virtanen\r\n// Date: 15.09.2015\r\n//\r\n// Description:\r\n// Writer class for IP-XACT CPU element.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef CPUWRITER_H\r\n#define CPUWRITER_H\r\n\r\n#include \"Cpu.h\"\r\n\r\n#include <IPXACTmodels/ipxactmodels_global.h>\r\n\r\n#include <IPXACTmodels/common/CommonItemsWriter.h>\r\n#include <IPXACTmodels/common/Document.h>\r\n\r\n#include <QXmlStreamWriter>\r\n#include <QSharedPointer>\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Writer class for IP-XACT CPU element.\r\n//-----------------------------------------------------------------------------\r\nnamespace CPUWriter\r\n{\r\n    /*!\r\n     *  Write a CPU to an XML file.\r\n     *\r\n     *    @param [in] writer  The used xml writer.\r\n     *    @param [in] cpu\t\tThe cpu to be written.\r\n     */\r\n    IPXACTMODELS_EXPORT void writeCPU(QXmlStreamWriter& writer, QSharedPointer<Cpu> cpu, Document::Revision docRevision);\r\n\r\n    namespace Details\r\n    {\r\n        /*!\r\n         *  Writes the address space references.\r\n         *\r\n         *    @param [in] writer  The used xml writer.\r\n         *    @param [in] cpu\t\tThe cpu to be written.\r\n         */\r\n        void writeAddressSpaceRefs(QXmlStreamWriter& writer, QSharedPointer<Cpu> cpu);\r\n\r\n        void writeBlockSize(QXmlStreamWriter& writer, QSharedPointer<Cpu> cpu);\r\n\r\n        void writeRegions(QXmlStreamWriter& writer, QSharedPointer<Cpu> cpu);\r\n\r\n        void writeExecutableImages(QXmlStreamWriter& writer, QSharedPointer<Cpu> cpu);\r\n\r\n        void writeLanguageTools(QXmlStreamWriter& writer, QSharedPointer<LanguageTools> languageTools);\r\n\r\n        void writeAddressUnitBits(QXmlStreamWriter& writer, QSharedPointer<Cpu> cpu);\r\n\r\n        void writeMemoryMapRef(QXmlStreamWriter& writer, QSharedPointer<Cpu> cpu);\r\n    }\r\n};\r\n\r\n#endif // CPUWRITER_H\r\n"
  },
  {
    "path": "IPXACTmodels/Component/Channel.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: Channel.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Janne Virtanen\r\n// Date: 20.09.2015\r\n//\r\n// Description:\r\n// Implementation for ipxact:channel element.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"Channel.h\"\r\n\r\n#include <QString>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Channel::Channel()\r\n//-----------------------------------------------------------------------------\r\nChannel::Channel(): NameGroup(), Extendable()\r\n{\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Channel::Channel()\r\n//-----------------------------------------------------------------------------\r\nChannel::Channel(Channel const& other):\r\nNameGroup(other),\r\nExtendable(other)\r\n{\r\n\tcopyBusInterfaceRefs(other);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Channel::operator=()\r\n//-----------------------------------------------------------------------------\r\nChannel& Channel::operator=(Channel const& other)\r\n{\r\n\tif (this != &other)\r\n    {\r\n        NameGroup::operator=(other);\r\n        Extendable::operator=(other);\r\n        copyBusInterfaceRefs(other);\r\n\t}\r\n\r\n\treturn *this;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Channel::~Channel()\r\n//-----------------------------------------------------------------------------\r\nChannel::~Channel()\r\n{\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Channel::getIsPresent()\r\n//-----------------------------------------------------------------------------\r\nQString Channel::getIsPresent() const\r\n{\r\n\treturn isPresent_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Channel::setIsPresent()\r\n//-----------------------------------------------------------------------------\r\nvoid Channel::setIsPresent(QString const& newIsPresent)\r\n{\r\n\tisPresent_ = newIsPresent;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Channel::getInterfaceNames()\r\n//-----------------------------------------------------------------------------\r\nQStringList Channel::getInterfaceNames() const\r\n{\r\n\tQStringList names;\r\n\r\n\tfor (auto const& interfaceRef : *busInterfaces_)\r\n\t{\r\n\t\tnames.append(interfaceRef->localName_);\r\n\t}\r\n\r\n\treturn names;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Channel::getInterfaces()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<QList<QSharedPointer<Channel::BusInterfaceRef> > > Channel::getInterfaces() const\r\n{\r\n\treturn busInterfaces_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Channel::setInterfaces()\r\n//-----------------------------------------------------------------------------\r\nvoid Channel::setInterfaces(QStringList const& interfaceNames)\r\n{\r\n    foreach (auto const& ref, *busInterfaces_)\r\n    {\r\n\t\tif (interfaceNames.contains(ref->localName_) == false)\r\n\t\t{\r\n\t\t\tbusInterfaces_->removeOne(ref);\r\n\t\t}\r\n    }\r\n\r\n\tfor (auto const& name : interfaceNames)\r\n\t{\r\n\t\tif (std::none_of(busInterfaces_->cbegin(), busInterfaces_->cend(),\r\n\t\t\t[&name](auto const& interfaceRef) { return interfaceRef->localName_ == name; }))\r\n\t\t{\r\n\t\t\tbusInterfaces_->append(QSharedPointer<BusInterfaceRef>(new BusInterfaceRef(name)));\r\n\t\t}\r\n\t}\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Channel::copyBusInterfaceRefs()\r\n//-----------------------------------------------------------------------------\r\nvoid Channel::copyBusInterfaceRefs(Channel const& other)\r\n{\r\n\tbusInterfaces_->clear();\r\n\tfor (auto const& ref : *other.busInterfaces_)\r\n\t{\r\n\t\tbusInterfaces_->append(QSharedPointer<BusInterfaceRef>(new BusInterfaceRef(*ref)));\r\n\t}\r\n}\r\n"
  },
  {
    "path": "IPXACTmodels/Component/Channel.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: Channel.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Janne Virtanen\r\n// Date: 20.09.2015\r\n//\r\n// Description:\r\n// Implementation for ipxact:channel element.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef CHANNEL_H\r\n#define CHANNEL_H\r\n\r\n#include <IPXACTmodels/common/NameGroup.h>\r\n#include <IPXACTmodels/common/Extendable.h>\r\n\r\n#include <QString>\r\n#include <QStringList>\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Implementation for ipxact:channel element.\r\n//-----------------------------------------------------------------------------\r\nclass IPXACTMODELS_EXPORT Channel : public NameGroup, public Extendable\r\n{\r\npublic:\r\n\r\n\t//! Struct for BusInterfaceRefs.\r\n\tstruct BusInterfaceRef: public Extendable\r\n\t{\r\n\t\tQString localName_;\r\n\r\n\t\texplicit BusInterfaceRef(QString const& localName) : localName_(localName) {};\r\n\r\n\t\t~BusInterfaceRef() = default;\r\n\r\n\t\tBusInterfaceRef& operator=(BusInterfaceRef const& other) = delete;\r\n\r\n\t\tBusInterfaceRef(BusInterfaceRef const& other):\r\n\t\t\tExtendable(other),\r\n\t\t\tlocalName_(other.localName_)\r\n\t\t{\r\n\t\t\tcopyVendorExtensions(other);\r\n\t\t}\r\n\t};\r\n\r\n\t/*! The default constructor\r\n\t *\r\n\t * Constructs an empty channel which is in invalid state.\r\n\t*/\r\n\tChannel();\r\n\r\n\t//! Copy constructor\r\n\tChannel(const Channel& other);\r\n\r\n\t//! Assignment operator\r\n\tChannel& operator=(const Channel& other);\r\n\r\n\t//! The destructor\r\n\t~Channel();\r\n\r\n    /*!\r\n     *  Gets the presence.\r\n     *\r\n     *    @return The presence value.\r\n     */\r\n    QString getIsPresent() const;\r\n\r\n    /*!\r\n     *  Set the presence.\r\n     *\r\n     *    @param [in] newIsPresent    The new presence value.\r\n     */\r\n    void setIsPresent(QString const& newIsPresent);\r\n\r\n\t/*! Get the references to bus interfaces that belong to this channel.\r\n\t *\r\n\t *    @return The interface name references.\r\n\t */\r\n\tQStringList getInterfaceNames() const;\r\n\r\n\tQSharedPointer<QList<QSharedPointer<BusInterfaceRef> > > getInterfaces() const;\r\n\r\n\t/*! Set the interfaces that belong to this channel.\r\n\t *\r\n\t *    @param [in] interfaceNames The name references to interfaces.\r\n\t*/\r\n\tvoid setInterfaces(QStringList const& interfaceNames);\r\n\r\nprivate:\r\n\r\n    void copyBusInterfaceRefs(Channel const& other);\r\n\r\n\t//! Presence of the channel.\r\n\tQString isPresent_;\r\n\r\n\t//! List of references to mirrored bus interfaces.\r\n\tQSharedPointer<QList<QSharedPointer<BusInterfaceRef> > > busInterfaces_ =\r\n\t\tQSharedPointer<QList<QSharedPointer<BusInterfaceRef> > >(new QList<QSharedPointer<BusInterfaceRef> >);\r\n\r\n};\r\n\r\n#endif // CHANNEL_H\r\n"
  },
  {
    "path": "IPXACTmodels/Component/ChannelReader.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ChannelReader.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Janne Virtanen\r\n// Date: 21.09.2015\r\n//\r\n// Description:\r\n// Reader class for IP-XACT Channel element.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"ChannelReader.h\"\r\n\r\n#include <IPXACTmodels/common/NameGroupReader.h>\r\n#include <IPXACTmodels/common/CommonItemsReader.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ChannelReader::createCPUFrom()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<Channel> ChannelReader::createChannelFrom(QDomNode const& channelNode,\r\n    Document::Revision docRevision)\r\n{\r\n\tQSharedPointer<Channel> newChannel (new Channel());\r\n\r\n\tNameGroupReader::parseNameGroup(channelNode, newChannel);\r\n\r\n    if (docRevision == Document::Revision::Std14)\r\n    {\r\n        newChannel->setIsPresent(CommonItemsReader::parseIsPresent(\r\n            channelNode.firstChildElement(QStringLiteral(\"ipxact:isPresent\"))));\r\n    }\r\n\r\n\tDetails::parseInterfaceReferences(channelNode, newChannel, docRevision);\r\n\r\n    if (docRevision == Document::Revision::Std22)\r\n    {\r\n        CommonItemsReader::parseVendorExtensions(channelNode, newChannel);\r\n    }\r\n\r\n    return newChannel;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ChannelReader::Details::parseInterfaceReferences()\r\n//-----------------------------------------------------------------------------\r\nvoid ChannelReader::Details::parseInterfaceReferences(QDomNode const& channelNode, \r\n    QSharedPointer<Channel> newChannel, Document::Revision docRevision)\r\n{\r\n    QDomNodeList interfaceReferenceNodes = \r\n        channelNode.toElement().elementsByTagName(QStringLiteral(\"ipxact:busInterfaceRef\"));\r\n\r\n    const int REFERENCE_COUNT = interfaceReferenceNodes.count();\r\n    for (int i = 0; i < REFERENCE_COUNT; i++)\r\n    {\r\n        QDomNode referenceNode = interfaceReferenceNodes.at(i);\r\n        QDomNode nameNode = referenceNode.toElement().firstChildElement(QStringLiteral(\"ipxact:localName\"));\r\n        auto localName = nameNode.firstChild().nodeValue();\r\n\r\n        QSharedPointer<Channel::BusInterfaceRef> interfaceRef(new Channel::BusInterfaceRef(localName));\r\n\r\n        if (docRevision == Document::Revision::Std22)\r\n        {\r\n            CommonItemsReader::parseVendorExtensions(referenceNode, interfaceRef);\r\n        }\r\n\r\n        newChannel->getInterfaces()->append(interfaceRef);\r\n    }\r\n}\r\n"
  },
  {
    "path": "IPXACTmodels/Component/ChannelReader.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ChannelReader.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Janne Virtanen\r\n// Date: 21.09.2015\r\n//\r\n// Description:\r\n// Reader class for IP-XACT Channel element.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef ChannelReader_H\r\n#define ChannelReader_H\r\n\r\n#include \"Channel.h\"\r\n\r\n#include <IPXACTmodels/common/CommonItemsReader.h>\r\n\r\n#include <QDomNode>\r\n\r\n#include <QSharedPointer>\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Reader class for IP-XACT Channel element.\r\n//-----------------------------------------------------------------------------\r\nnamespace  ChannelReader \r\n{\r\n    /*!\r\n     *  Creates a new channel from a given channel node.\r\n     *\r\n     *    @param [in] channelNode    XML description of the channel.\r\n     *    @param [in] docRevision    The applied IP-XACT standard revision.\r\n     */\r\n    IPXACTMODELS_EXPORT QSharedPointer<Channel> createChannelFrom(QDomNode const& channelNode,\r\n        Document::Revision docRevision);\r\n\r\n    namespace Details\r\n    {\r\n\r\n        /*!\r\n         *  Parses the local interface references for the channel. \r\n         *\r\n         *    @param [in] channelNode     XML description of the channel.\r\n         *    @param [in] newChannel      The channel to add the references to.\r\n         *    @param [in] docRevision     The applied IP-XACT standard revision.\r\n         */\r\n        void parseInterfaceReferences(QDomNode const& channelNode, QSharedPointer<Channel> newChannel,\r\n            Document::Revision docRevision);\r\n\r\n    }\r\n};\r\n\r\n#endif // ChannelReader_H\r\n"
  },
  {
    "path": "IPXACTmodels/Component/ChannelWriter.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ChannelWriter.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Janne Virtanen\r\n// Date: 21.09.2015\r\n//\r\n// Description:\r\n// Writer class for IP-XACT Channel element.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"ChannelWriter.h\"\r\n\r\n#include <IPXACTmodels/common/NameGroupWriter.h>\r\n\r\n#include <IPXACTmodels/common/CommonItemsWriter.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ChannelWriter::createChannelFrom()\r\n//-----------------------------------------------------------------------------\r\nvoid ChannelWriter::writeChannel(QXmlStreamWriter& writer, QSharedPointer<Channel> channel,\r\n\tDocument::Revision docRevision)\r\n{\r\n\t// Start the element, write name group and presence.\r\n    writer.writeStartElement(QStringLiteral(\"ipxact:channel\"));\r\n\r\n    NameGroupWriter::writeNameGroup(writer, channel);\r\n\r\n\tif (docRevision == Document::Revision::Std14)\r\n\t{\r\n        CommonItemsWriter::writeIsPresent(writer, channel->getIsPresent());\r\n\t}\r\n\r\n\tfor (auto const& busInterfaceReference : *channel->getInterfaces())\r\n\t{\r\n\t\twriter.writeStartElement(QStringLiteral(\"ipxact:busInterfaceRef\"));\r\n\t\twriter.writeTextElement(QStringLiteral(\"ipxact:localName\"), busInterfaceReference->localName_);\r\n\r\n\t\tif (docRevision == Document::Revision::Std22)\r\n\t\t{\r\n\t\t\tCommonItemsWriter::writeVendorExtensions(writer, busInterfaceReference);\r\n\t\t}\r\n\r\n\t\twriter.writeEndElement();\r\n\t}\r\n\r\n\tif (docRevision == Document::Revision::Std22)\r\n\t{\r\n        CommonItemsWriter::writeVendorExtensions(writer, channel);\r\n\t}\r\n\r\n\twriter.writeEndElement();\r\n\treturn;\r\n}\r\n"
  },
  {
    "path": "IPXACTmodels/Component/ChannelWriter.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ChannelWriter.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Janne Virtanen\r\n// Date: 21.09.2015\r\n//\r\n// Description:\r\n// Writer class for IP-XACT Channel element.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef ChannelWriter_H\r\n#define ChannelWriter_H\r\n\r\n#include \"Channel.h\"\r\n\r\n#include <IPXACTmodels/common/Document.h>\r\n\r\n#include <QXmlStreamWriter>\r\n#include <QSharedPointer>\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Writer class for IP-XACT Channel element.\r\n//-----------------------------------------------------------------------------\r\nnamespace ChannelWriter\r\n{\r\n\r\n    /*!\r\n     *  Write a channel to an XML file.\r\n     *\r\n     *    @param [in] writer      The used xml writer.\r\n     *    @param [in] channel\t\tThe channel to be written.\r\n     *    @param [in] docRevision The applied IP-XACT standard revision.\r\n     */\r\n    IPXACTMODELS_EXPORT void writeChannel(QXmlStreamWriter& writer, QSharedPointer<Channel> channel,\r\n        Document::Revision docRevision);\r\n\r\n};\r\n\r\n#endif // ChannelWriter_H\r\n"
  },
  {
    "path": "IPXACTmodels/Component/Component.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: Component.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 06.10.2015\r\n//\r\n// Description:\r\n// Describes the ipxact:component element.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"Component.h\"\r\n#include \"Model.h\"\r\n\r\n#include \"BusInterface.h\"\r\n#include \"Channel.h\"\r\n#include \"RemapState.h\"\r\n#include \"Mode.h\"\r\n#include \"AddressSpace.h\"\r\n#include \"MemoryMap.h\"\r\n#include \"View.h\"\r\n#include \"ComponentInstantiation.h\"\r\n#include \"DesignInstantiation.h\"\r\n#include \"DesignConfigurationInstantiation.h\"\r\n#include \"Port.h\"\r\n#include \"PowerDomain.h\"\r\n#include \"ComponentGenerator.h\"\r\n#include \"FileSet.h\"\r\n#include \"Cpu.h\"\r\n#include \"OtherClockDriver.h\"\r\n#include \"IndirectInterface.h\"\r\n#include \"ResetType.h\"\r\n\r\n#include \"File.h\"\r\n\r\n#include <IPXACTmodels/kactusExtensions/ComProperty.h>\r\n#include <IPXACTmodels/kactusExtensions/SystemView.h>\r\n#include <IPXACTmodels/kactusExtensions/ComInterface.h>\r\n#include <IPXACTmodels/kactusExtensions/ApiInterface.h>\r\n#include <IPXACTmodels/kactusExtensions/FileDependency.h>\r\n#include <IPXACTmodels/kactusExtensions/Kactus2Group.h>\r\n\r\n\r\n#include <IPXACTmodels/common/Choice.h>\r\n#include <IPXACTmodels/common/Parameter.h>\r\n#include <IPXACTmodels/common/VLNV.h>\r\n\r\n#include <IPXACTmodels/utilities/Search.h>\r\n#include <IPXACTmodels/utilities/Copy.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Component::Component()\r\n//-----------------------------------------------------------------------------\r\nComponent::Component(const VLNV &vlnv, Document::Revision revision):\r\nDocument(vlnv, revision)\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Component::Component()\r\n//-----------------------------------------------------------------------------\r\nComponent::Component(const Component &other):\r\nDocument(other),\r\npendingFileDependencies_(other.pendingFileDependencies_)\r\n{\r\n    Copy::copyList(other.powerDomains_, powerDomains_);\r\n    Copy::copyList(other.busInterfaces_, busInterfaces_);\r\n    Copy::copyList(other.indirectInterfaces_, indirectInterfaces_);\r\n    Copy::copyList(other.channels_, channels_);\r\n    Copy::copyList(other.remapStates_, remapStates_);\r\n    Copy::copyList(other.modes_, modes_);\r\n    Copy::copyList(other.addressSpaces_, addressSpaces_);\r\n    Copy::copyList(other.memoryMaps_, memoryMaps_);\r\n    model_ = QSharedPointer<Model>(new Model(*other.model_));\r\n    Copy::copyList(other.componentGenerators_, componentGenerators_);\r\n    Copy::copyList(other.choices_, choices_);\r\n    Copy::copyList(other.fileSets_, fileSets_);\r\n    Copy::copyList(other.cpus_, cpus_);\r\n    Copy::copyList(other.otherClockDrivers_, otherClockDrivers_);\r\n    Copy::copyList(other.resetTypes_, resetTypes_);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Component::operator=()\r\n//-----------------------------------------------------------------------------\r\nComponent& Component::operator=( const Component& other)\r\n{\r\n    if (this != &other)\r\n    {\r\n        Document::operator=(other);\r\n\r\n        pendingFileDependencies_ = other.pendingFileDependencies_;\r\n\r\n        powerDomains_->clear();\r\n        busInterfaces_->clear();\r\n        indirectInterfaces_->clear();\r\n        channels_->clear();\r\n        remapStates_->clear();\r\n        modes_->clear();\r\n        addressSpaces_->clear();\r\n        memoryMaps_->clear();\r\n        model_.clear();\r\n\r\n        componentGenerators_->clear();\r\n        choices_->clear();\r\n        fileSets_->clear();\r\n        cpus_->clear();\r\n        otherClockDrivers_->clear();\r\n        resetTypes_->clear();\r\n\r\n        Copy::copyList(other.powerDomains_, powerDomains_);\r\n        Copy::copyList(other.busInterfaces_, busInterfaces_);\r\n        Copy::copyList(other.indirectInterfaces_, indirectInterfaces_);\r\n        Copy::copyList(other.channels_, channels_);\r\n        Copy::copyList(other.remapStates_, remapStates_);\r\n        Copy::copyList(other.modes_, modes_);\r\n        Copy::copyList(other.addressSpaces_, addressSpaces_);\r\n        Copy::copyList(other.memoryMaps_, memoryMaps_);\r\n        model_ = QSharedPointer<Model>(new Model(*other.model_));\r\n        Copy::copyList(other.componentGenerators_, componentGenerators_);\r\n        Copy::copyList(other.choices_, choices_);\r\n        Copy::copyList(other.fileSets_, fileSets_);\r\n        Copy::copyList(other.cpus_, cpus_);\r\n        Copy::copyList(other.otherClockDrivers_, otherClockDrivers_);\r\n        Copy::copyList(other.resetTypes_, resetTypes_);\r\n    }\r\n\r\n    return *this;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Component::clone()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<Document> Component::clone() const \r\n{\r\n\treturn QSharedPointer<Document>(new Component(*this));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Component::isBus()\r\n//-----------------------------------------------------------------------------\r\nbool Component::isBus() const\r\n{\r\n    return isChannel() || isTransparentBridge() || isOpaqueBridge();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Component::isChannel()\r\n//-----------------------------------------------------------------------------\r\nbool Component::isChannel() const\r\n{\r\n    return !channels_->isEmpty();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Component::isBridge()\r\n//-----------------------------------------------------------------------------\r\nbool Component::isTransparentBridge() const\r\n{\r\n    return std::any_of(busInterfaces_->cbegin(), busInterfaces_->cend(),\r\n        [](auto busif) { return busif->hasTransparentBridge(); });\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Component::isOpaqueBridge()\r\n//-----------------------------------------------------------------------------\r\nbool Component::isOpaqueBridge() const\r\n{\r\n    auto memMapHasSubspaceMapWithInitRef = [](QSharedPointer<MemoryMap> memMap)\r\n        {\r\n            for (auto const& memoryBlock : *memMap->getMemoryBlocks())\r\n            {\r\n                if (auto subspaceMap = memoryBlock.dynamicCast<SubSpaceMap>();\r\n                    subspaceMap && !subspaceMap->getInitiatorReference().isEmpty())\r\n                {\r\n                    return true;\r\n                }\r\n            }\r\n            return false;\r\n        };\r\n\r\n    auto busInterfaceIsBridged = [this, memMapHasSubspaceMapWithInitRef](QSharedPointer<BusInterface> busIf)\r\n        {\r\n            if (busIf->getMemoryMapRef().isEmpty())\r\n            {\r\n                return false;\r\n            }\r\n\r\n            return std::any_of(memoryMaps_->cbegin(), memoryMaps_->cend(), memMapHasSubspaceMapWithInitRef);\r\n        };\r\n\r\n    return std::any_of(busInterfaces_->cbegin(), busInterfaces_->cend(), busInterfaceIsBridged);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Component::isCpu()\r\n//-----------------------------------------------------------------------------\r\nbool Component::isCpu() const\r\n{\r\n    return !cpus_->isEmpty();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Component::isHierarchical()\r\n//-----------------------------------------------------------------------------\r\nbool Component::isHierarchical() const\r\n{\r\n    return model_->hasHierView();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Component::getPowerDomains()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<QList<QSharedPointer<PowerDomain> > > Component::getPowerDomains() const\r\n{\r\n    return powerDomains_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Component::getBusInterfaces()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<QList<QSharedPointer<BusInterface> > > Component::getBusInterfaces() const\r\n{\r\n    return busInterfaces_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Component::setBusInterfaces()\r\n//-----------------------------------------------------------------------------\r\nvoid Component::setBusInterfaces(QSharedPointer<QList<QSharedPointer<BusInterface> > > newBusInterfaces)\r\n{\r\n    busInterfaces_ = newBusInterfaces;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Component::getInterfaceForPort()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<BusInterface> Component::getInterfaceForPort( const QString& portName ) const\r\n{\r\n    auto it = std::find_if(busInterfaces_->cbegin(), busInterfaces_->cend(),\r\n        [&portName](auto busif) { return busif->containsMappedPhysicalPort(portName); });\r\n\r\n    if (it == busInterfaces_->cend())\r\n    {\r\n        return nullptr;\r\n    }\r\n\r\n    return *it;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Component::getInterfacesUsedByPort()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<QList<QSharedPointer<BusInterface> > > Component::getInterfacesUsedByPort(QString const& portName)\r\n    const\r\n{\r\n    QSharedPointer<QList<QSharedPointer<BusInterface> > > interfaces (new QList<QSharedPointer<BusInterface> > ());\r\n\r\n    for (QSharedPointer<BusInterface> busInterface : *busInterfaces_)\r\n    {\r\n        if (busInterface->containsMappedPhysicalPort(portName))\r\n        {\r\n            interfaces->append(busInterface);\r\n        }\r\n    }\r\n\r\n    return interfaces;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Component::getIndirectInterfaces()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<QList<QSharedPointer<IndirectInterface> > > Component::getIndirectInterfaces() const\r\n{\r\n    return indirectInterfaces_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Component::getChannels()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<QList<QSharedPointer<Channel> > > Component::getChannels() const\r\n{\r\n    return channels_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Component::setChannels()\r\n//-----------------------------------------------------------------------------\r\nvoid Component::setChannels(QSharedPointer<QList<QSharedPointer<Channel> > > newChannels)\r\n{\r\n    channels_->clear();\r\n    channels_ = newChannels;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Component::getRemapStates()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<QList<QSharedPointer<RemapState> > > Component::getRemapStates() const\r\n{\r\n    return remapStates_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Component::getModes()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<QList<QSharedPointer<Mode> > > Component::getModes() const\r\n{\r\n    return modes_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Component::setRemapStates()\r\n//-----------------------------------------------------------------------------\r\nvoid Component::setRemapStates(QSharedPointer<QList<QSharedPointer<RemapState> > > newRemapStates)\r\n{\r\n    remapStates_ = newRemapStates;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Component::getAddressSpaces()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<QList<QSharedPointer<AddressSpace> > > Component::getAddressSpaces() const\r\n{\r\n    return addressSpaces_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Component::setAddressSpaces()\r\n//-----------------------------------------------------------------------------\r\nvoid Component::setAddressSpaces(QSharedPointer<QList<QSharedPointer<AddressSpace> > > newAddressSpaces)\r\n{\r\n    addressSpaces_->clear();\r\n    addressSpaces_ = newAddressSpaces;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Component::getMemoryMaps()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<QList<QSharedPointer<MemoryMap> > > Component::getMemoryMaps() const\r\n{\r\n    return memoryMaps_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Component::setMemoryMaps()\r\n//-----------------------------------------------------------------------------\r\nvoid Component::setMemoryMaps(QSharedPointer<QList<QSharedPointer<MemoryMap> > > newMemoryMaps)\r\n{\r\n    memoryMaps_->clear();\r\n    memoryMaps_ = newMemoryMaps;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Component::getModel()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<Model> Component::getModel() const\r\n{\r\n    return model_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Component::setModel()\r\n//-----------------------------------------------------------------------------\r\nvoid Component::setModel(QSharedPointer<Model> newModel)\r\n{\r\n    model_ = newModel;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Component::getViews()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<QList<QSharedPointer<View> > > Component::getViews() const\r\n{\r\n    return model_->getViews();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Component::setViews()\r\n//-----------------------------------------------------------------------------\r\nvoid Component::setViews(QSharedPointer<QList<QSharedPointer<View> > > newViews)\r\n{\r\n    model_->setViews(newViews);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Component::getComponentInstantiations()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<QList<QSharedPointer<ComponentInstantiation> > > Component::getComponentInstantiations() const\r\n{\r\n    return model_->getComponentInstantiations();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Component::setComponentInstantiations()\r\n//-----------------------------------------------------------------------------\r\nvoid Component::setComponentInstantiations(\r\n    QSharedPointer<QList<QSharedPointer<ComponentInstantiation> > > newInstantiation)\r\n{\r\n    model_->setComponentInstantiations(newInstantiation);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Component::getDesignInstantiations()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<QList<QSharedPointer<DesignInstantiation> > > Component::getDesignInstantiations() const\r\n{\r\n    return model_->getDesignInstantiations();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Component::setDesignInstantiations()\r\n//-----------------------------------------------------------------------------\r\nvoid Component::setDesignInstantiations(\r\n    QSharedPointer<QList<QSharedPointer<DesignInstantiation> > > newInstantiations)\r\n{\r\n    model_->setDesignInstantiations(newInstantiations);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Component::getDesignConfigurationInstantiations()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<QList<QSharedPointer<DesignConfigurationInstantiation> > > Component::\r\n    getDesignConfigurationInstantiations() const\r\n{\r\n    return model_->getDesignConfigurationInstantiations();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Component::setDesignConfigurationInstantiations()\r\n//-----------------------------------------------------------------------------\r\nvoid Component::setDesignConfigurationInstantiations(\r\n    QSharedPointer<QList<QSharedPointer<DesignConfigurationInstantiation> > > newInstantiations)\r\n{\r\n    model_->setDesignConfigurationInstantiations(newInstantiations);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Component::getPorts()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<QList<QSharedPointer<Port> > > Component::getPorts() const\r\n{\r\n    return model_->getPorts();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Component::setPorts()\r\n//-----------------------------------------------------------------------------\r\nvoid Component::setPorts(QSharedPointer<QList<QSharedPointer<Port> > > newPorts)\r\n{\r\n    model_->setPorts(newPorts);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Component::getCompGenerators()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<QList<QSharedPointer<ComponentGenerator> > > Component::getComponentGenerators() const\r\n{\r\n    return componentGenerators_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Component::setCompGenerators()\r\n//-----------------------------------------------------------------------------\r\nvoid Component::setComponentGenerators(QSharedPointer<QList<QSharedPointer<ComponentGenerator> > > newGenerators)\r\n{\r\n    componentGenerators_->clear();\r\n    componentGenerators_= newGenerators;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Component::getChoices()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<QList<QSharedPointer<Choice> > > Component::getChoices() const\r\n{\r\n    return choices_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Component::setChoices()\r\n//-----------------------------------------------------------------------------\r\nvoid Component::setChoices(QSharedPointer<QList<QSharedPointer<Choice> > > newChoices)\r\n{\r\n    choices_ = newChoices;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Component::getFileSets()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<QList<QSharedPointer<FileSet> > > Component::getFileSets() const\r\n{\r\n    return fileSets_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Component::setFileSets()\r\n//-----------------------------------------------------------------------------\r\nvoid Component::setFileSets(QSharedPointer<QList<QSharedPointer<FileSet> > > newFileSets)\r\n{\r\n    fileSets_->clear();\r\n    fileSets_ = newFileSets;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Component::getCpus()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<QList<QSharedPointer<Cpu> > >Component::getCpus() const\r\n{\r\n    return cpus_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Component::setCpus()\r\n//-----------------------------------------------------------------------------\r\nvoid Component::setCpus(QSharedPointer<QList<QSharedPointer<Cpu> > > newCpus)\r\n{\r\n    cpus_->clear();\r\n    cpus_ = newCpus;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Component::getOtherClockDrivers()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<QList<QSharedPointer<OtherClockDriver> > > Component::getOtherClockDrivers() const\r\n{\r\n    return otherClockDrivers_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Component::setOtherClockDrivers()\r\n//-----------------------------------------------------------------------------\r\nvoid Component::setOtherClockDrivers(\r\n    QSharedPointer<QList<QSharedPointer<OtherClockDriver> > > newOtherClockDrivers)\r\n{\r\n    otherClockDrivers_->clear();\r\n    otherClockDrivers_ = newOtherClockDrivers;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Component::getResetTypes()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<QList<QSharedPointer<ResetType> > > Component::getResetTypes() const\r\n{\r\n    return resetTypes_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Component::setResetTypes()\r\n//-----------------------------------------------------------------------------\r\nvoid Component::setResetTypes(QSharedPointer<QList<QSharedPointer<ResetType>>> newResetTypes)\r\n{\r\n    resetTypes_ = newResetTypes;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Component::getSWProperties()\r\n//-----------------------------------------------------------------------------\r\nQList<QSharedPointer<ComProperty> > Component::getSWProperties() const\r\n{\r\n    QList<QSharedPointer<VendorExtension> > swPropertiesExtensionList =\r\n        getGroupedExtensionsByType(QStringLiteral(\"kactus2:properties\"), QStringLiteral(\"kactus2:property\"));\r\n\r\n    QList<QSharedPointer<ComProperty> >  swProperties;\r\n    for (QSharedPointer<VendorExtension> extension : swPropertiesExtensionList)\r\n    {\r\n        swProperties.append(extension.dynamicCast<ComProperty>());\r\n    }\r\n\r\n    return swProperties;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Component::setSWProperties()\r\n//-----------------------------------------------------------------------------\r\nvoid Component::setSWProperties(QList<QSharedPointer<ComProperty> > newProperties)\r\n{\r\n    for (QSharedPointer<VendorExtension> extension : *getVendorExtensions())\r\n    {\r\n        if (extension->type() == QLatin1String(\"kactus2:properties\"))\r\n        {\r\n            getVendorExtensions()->removeAll(extension);\r\n            break;\r\n        }\r\n    }\r\n\r\n    if (!newProperties.isEmpty())\r\n    {\r\n        QSharedPointer<Kactus2Group> newPropertiesGroup (new Kactus2Group(QStringLiteral(\"kactus2:properties\")));\r\n        for (QSharedPointer<ComProperty> swProperty : newProperties)\r\n        {\r\n            newPropertiesGroup->addToGroup(swProperty);\r\n        }\r\n\r\n        getVendorExtensions()->append(newPropertiesGroup);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Component::getSystemViews()\r\n//-----------------------------------------------------------------------------\r\nQList<QSharedPointer<SystemView> > Component::getSystemViews() const\r\n{\r\n    QList<QSharedPointer<VendorExtension> > systemViewExtensions =\r\n        getGroupedExtensionsByType(QStringLiteral(\"kactus2:systemViews\"), QStringLiteral(\"kactus2:systemView\"));\r\n\r\n    QList<QSharedPointer<SystemView> > systemViews;\r\n    for (QSharedPointer<VendorExtension> extension : systemViewExtensions)\r\n    {\r\n        systemViews.append(extension.dynamicCast<SystemView>());\r\n    }\r\n\r\n    return systemViews;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Component::setSystemViews()\r\n//-----------------------------------------------------------------------------\r\nvoid Component::setSystemViews(QList<QSharedPointer<SystemView> > newSystemViews)\r\n{\r\n    for (QSharedPointer<VendorExtension> extension : *getVendorExtensions())\r\n    {\r\n        if (extension->type() == QLatin1String(\"kactus2:systemViews\"))\r\n        {\r\n            getVendorExtensions()->removeAll(extension);\r\n            break;\r\n        }\r\n    }\r\n\r\n    if (!newSystemViews.isEmpty())\r\n    {\r\n        QSharedPointer<Kactus2Group> newSystemViewGroup (new Kactus2Group(QStringLiteral(\"kactus2:systemViews\")));\r\n        for (QSharedPointer<SystemView> systemView : newSystemViews)\r\n        {\r\n            newSystemViewGroup->addToGroup(systemView);\r\n        }\r\n\r\n        getVendorExtensions()->append(newSystemViewGroup);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Component::getComInterfaces()\r\n//-----------------------------------------------------------------------------\r\nQList<QSharedPointer<ComInterface> > Component::getComInterfaces() const\r\n{\r\n    QList<QSharedPointer<VendorExtension> > comInterfaceExtensions =\r\n        getGroupedExtensionsByType(QStringLiteral(\"kactus2:comInterfaces\"), QStringLiteral(\"kactus2:comInterface\"));\r\n\r\n    QList<QSharedPointer<ComInterface> > comInterfaces;\r\n    for (QSharedPointer<VendorExtension> extension : comInterfaceExtensions)\r\n    {\r\n        comInterfaces.append(extension.dynamicCast<ComInterface>());\r\n    }\r\n\r\n    return comInterfaces;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Component::setComInterfaces()\r\n//-----------------------------------------------------------------------------\r\nvoid Component::setComInterfaces(QList<QSharedPointer<ComInterface> > newComInterfaces)\r\n{\r\n    for (QSharedPointer<VendorExtension> extension : *getVendorExtensions())\r\n    {\r\n        if (extension->type() == QLatin1String(\"kactus2:comInterfaces\"))\r\n        {\r\n            getVendorExtensions()->removeAll(extension);\r\n            break;\r\n        }\r\n    }\r\n\r\n    if (!newComInterfaces.isEmpty())\r\n    {\r\n        QSharedPointer<Kactus2Group> newComInterfaceGroup (new Kactus2Group(QStringLiteral(\"kactus2:comInterfaces\")));\r\n        for (QSharedPointer<ComInterface> comInterface : newComInterfaces)\r\n        {\r\n            newComInterfaceGroup->addToGroup(comInterface);\r\n        }\r\n\r\n        getVendorExtensions()->append(newComInterfaceGroup);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Component::getApiInterfaces()\r\n//-----------------------------------------------------------------------------\r\nQList<QSharedPointer<ApiInterface> > Component::getApiInterfaces() const\r\n{\r\n    QList<QSharedPointer<VendorExtension> > apiInterfaceExtensions =\r\n        getGroupedExtensionsByType(QStringLiteral(\"kactus2:apiInterfaces\"), QStringLiteral(\"kactus2:apiInterface\"));\r\n\r\n    QList<QSharedPointer<ApiInterface> > apiInterfaces;\r\n    for (QSharedPointer<VendorExtension> extension : apiInterfaceExtensions)\r\n    {\r\n        apiInterfaces.append(extension.dynamicCast<ApiInterface>());\r\n    }\r\n\r\n    return apiInterfaces;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Component::setApiInterfaces()\r\n//-----------------------------------------------------------------------------\r\nvoid Component::setApiInterfaces(QList<QSharedPointer<ApiInterface> > newApiInterfaces)\r\n{\r\n    for (QSharedPointer<VendorExtension> extension : *getVendorExtensions())\r\n    {\r\n        if (extension->type() == QLatin1String(\"kactus2:apiInterfaces\"))\r\n        {\r\n            getVendorExtensions()->removeAll(extension);\r\n            break;\r\n        }\r\n    }\r\n\r\n    if (!newApiInterfaces.isEmpty())\r\n    {\r\n        QSharedPointer<Kactus2Group> newApiInterfaceGroup (new Kactus2Group(QStringLiteral(\"kactus2:apiInterfaces\")));\r\n        for (QSharedPointer<ApiInterface> apiInterface : newApiInterfaces)\r\n        {\r\n            newApiInterfaceGroup->addToGroup(apiInterface);\r\n        }\r\n        getVendorExtensions()->append(newApiInterfaceGroup);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Component::getFileDependencies()\r\n//-----------------------------------------------------------------------------\r\nQList<QSharedPointer<FileDependency> > Component::getFileDependencies() const\r\n{\r\n    QList<QSharedPointer<VendorExtension> > fileDependencyExtensions =\r\n        getGroupedExtensionsByType(QStringLiteral(\"kactus2:fileDependencies\"), QStringLiteral(\"kactus2:fileDependency\"));\r\n\r\n    QList<QSharedPointer<FileDependency> > fileDependencies;\r\n    for (QSharedPointer<VendorExtension> extension : fileDependencyExtensions)\r\n    {\r\n        fileDependencies.append(extension.dynamicCast<FileDependency>());\r\n    }\r\n\r\n    return fileDependencies;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Component::setFileDependendencies()\r\n//-----------------------------------------------------------------------------\r\nvoid Component::setFileDependendencies(QList<QSharedPointer<FileDependency> > newFileDependencies)\r\n{\r\n    for (QSharedPointer<VendorExtension> extension : *getVendorExtensions())\r\n    {\r\n        if (extension->type() == QLatin1String(\"kactus2:fileDependencies\"))\r\n        {\r\n            getVendorExtensions()->removeAll(extension);\r\n            break;\r\n        }\r\n    }\r\n\r\n    if (!newFileDependencies.isEmpty())\r\n    {\r\n        QSharedPointer<Kactus2Group> newFileDependencyGroup (new Kactus2Group(QStringLiteral(\"kactus2:fileDependencies\")));\r\n        for (QSharedPointer<FileDependency> fileDependency : newFileDependencies)\r\n        {\r\n            newFileDependencyGroup->addToGroup(fileDependency);\r\n        }\r\n        getVendorExtensions()->append(newFileDependencyGroup);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Component::getPendingFileDependencies()\r\n//-----------------------------------------------------------------------------\r\nQList< QSharedPointer<FileDependency> > Component::getPendingFileDependencies() const\r\n{\r\n    return pendingFileDependencies_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Component::setPendingFileDependencies()\r\n//-----------------------------------------------------------------------------\r\nvoid Component::setPendingFileDependencies(QList<QSharedPointer<FileDependency> > newFileDependencies)\r\n{\r\n    pendingFileDependencies_ = newFileDependencies;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Component::getSourceDirectories()\r\n//-----------------------------------------------------------------------------\r\nQStringList Component::getSourceDirectories() const\r\n{\r\n    QList<QSharedPointer<VendorExtension> > sourceDirectoryExtensions =\r\n        getGroupedExtensionsByType(QStringLiteral(\"kactus2:sourceDirectories\"), QStringLiteral(\"kactus2:sourceDirectory\"));\r\n\r\n    QStringList sourceDirections;\r\n    for (QSharedPointer<VendorExtension> extension : sourceDirectoryExtensions)\r\n    {\r\n        QSharedPointer<Kactus2Value> sourceDirectory = extension.dynamicCast<Kactus2Value>();\r\n        sourceDirections.append(sourceDirectory->value());\r\n    }\r\n\r\n    return sourceDirections;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Component::setSourceDirectories()\r\n//-----------------------------------------------------------------------------\r\nvoid Component::setSourceDirectories(QStringList const& sourceDirs)\r\n{\r\n    for (QSharedPointer<VendorExtension> extension : *getVendorExtensions())\r\n    {\r\n        if (extension->type() == QLatin1String(\"kactus2:sourceDirectories\"))\r\n        {\r\n            getVendorExtensions()->removeAll(extension);\r\n            break;\r\n        }\r\n    }\r\n\r\n    if (!sourceDirs.isEmpty())\r\n    {\r\n        QSharedPointer<Kactus2Group> newSourceDirectoryGroup (new Kactus2Group(QStringLiteral(\"kactus2:sourceDirectories\")));\r\n        for (QString const& sourceDirectory : sourceDirs)\r\n        {\r\n            QSharedPointer<Kactus2Value> directoryExtension (\r\n                new Kactus2Value(QStringLiteral(\"kactus2:sourceDirectory\"), sourceDirectory));\r\n            newSourceDirectoryGroup->addToGroup(directoryExtension);\r\n        }\r\n        getVendorExtensions()->append(newSourceDirectoryGroup);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Component::getAuthor()\r\n//-----------------------------------------------------------------------------\r\nQString Component::getAuthor() const\r\n{\r\n    for (QSharedPointer<VendorExtension> extension : *getVendorExtensions())\r\n    {\r\n        if (extension->type() == QLatin1String(\"kactus2:author\"))\r\n        {\r\n            QSharedPointer<Kactus2Value> authorExtension = extension.dynamicCast<Kactus2Value>();\r\n            return authorExtension->value();\r\n        }\r\n    }\r\n\r\n    return QString();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Component::setAuthor()\r\n//-----------------------------------------------------------------------------\r\nvoid Component::setAuthor(QString const& author)\r\n{\r\n    for (QSharedPointer<VendorExtension> extension : *getVendorExtensions())\r\n    {\r\n        if (extension->type() == QLatin1String(\"kactus2:author\"))\r\n        {\r\n            getVendorExtensions()->removeAll(extension);\r\n        }\r\n    }\r\n\r\n    if (!author.isEmpty())\r\n    {\r\n        QSharedPointer<Kactus2Value> authorValue (new Kactus2Value(QStringLiteral(\"kactus2:author\"), author));\r\n        getVendorExtensions()->append(authorValue);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Component::getDependentFiles()\r\n//-----------------------------------------------------------------------------\r\nQStringList Component::getDependentFiles() const\r\n{\r\n    QStringList files;\r\n\r\n    std::for_each(fileSets_->cbegin(), fileSets_->cend(), \r\n        [&files](auto& item) { files.append(item->getFilePaths()); });\r\n\r\n    std::for_each(componentGenerators_->cbegin(), componentGenerators_->cend(), \r\n        [&files](auto& item) { files.append(item->getGeneratorExe()); });\r\n\r\n    return files;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Component::getDependentVLNVs()\r\n//-----------------------------------------------------------------------------\r\nQList<VLNV> Component::getDependentVLNVs() const\r\n{\r\n    QList<VLNV> vlnvList;\r\n\r\n    std::for_each(busInterfaces_->cbegin(), busInterfaces_->cend(),\r\n        [&vlnvList](auto const& busif)\r\n        {\r\n            vlnvList.append(busif->getBusType());\r\n\r\n            std::for_each(busif->getAbstractionTypes()->cbegin(), busif->getAbstractionTypes()->cend(),\r\n                [&vlnvList](auto const& abstractionType) {\r\n                    vlnvList.append(*abstractionType->getAbstractionRef());\r\n                });\r\n        });\r\n\r\n    vlnvList.append(model_->getViewReferences());\r\n\r\n    const auto systemViews = getSystemViews();\r\n    std::for_each(systemViews.cbegin(), systemViews.cend(), [&vlnvList](auto const& view)\r\n        {\r\n            vlnvList.append(view->getHierarchyRef());\r\n        });\r\n\r\n\r\n    const auto comInterfaces = getComInterfaces();\r\n    std::for_each(comInterfaces.cbegin(), comInterfaces.cend(),\r\n        [&vlnvList](auto const& comIf)\r\n        {\r\n            vlnvList.append(comIf->getComType());\r\n        });\r\n\r\n    const auto  apiInterfaces = getApiInterfaces();\r\n\r\n    std::for_each(apiInterfaces.cbegin(), apiInterfaces.cend(),\r\n        [&vlnvList](auto const& apiIf)\r\n        {\r\n            vlnvList.append(apiIf->getApiType());\r\n        });\r\n\r\n    auto it = std::remove_if(vlnvList.begin(), vlnvList.end(), [](auto& vlnv) { return vlnv.isValid() == false; });\r\n    vlnvList.erase(it, vlnvList.end());\r\n\r\n    return vlnvList;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: component::getPowerDomainNames()\r\n//-----------------------------------------------------------------------------\r\nQStringList Component::getPowerDomainNames() const\r\n{\r\n    return Search::getNames(powerDomains_);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: component::getRemapStateNames()\r\n//-----------------------------------------------------------------------------\r\nQStringList Component::getRemapStateNames() const\r\n{\r\n    return Search::getNames(remapStates_);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Component::getMemoryMapNames()\r\n//-----------------------------------------------------------------------------\r\nQStringList Component::getMemoryMapNames() const\r\n{\r\n    return Search::getNames(memoryMaps_);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Component::hasViews()\r\n//-----------------------------------------------------------------------------\r\nbool Component::hasViews() const\r\n{\r\n    return model_->hasViews();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Component::hasView()\r\n//-----------------------------------------------------------------------------\r\nbool Component::hasView( const QString& viewName ) const\r\n{\r\n    const auto views = getViews();\r\n    return std::any_of(views->cbegin(), views->cend(), [&viewName](auto& view)\r\n        { return view->name() == viewName; });\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Component::getViewNames()\r\n//-----------------------------------------------------------------------------\r\nQStringList Component::getViewNames() const\r\n{\r\n    return model_->getViewNames();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Component::getCpuNames()\r\n//-----------------------------------------------------------------------------\r\nQStringList Component::getCpuNames() const\r\n{\r\n    return Search::getNames(cpus_);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Component::getHierViews()\r\n//-----------------------------------------------------------------------------\r\nQStringList Component::getHierViews() const\r\n{\r\n    return model_->getHierViews();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Component::getFlatViews()\r\n//-----------------------------------------------------------------------------\r\nQStringList Component::getFlatViews() const\r\n{\r\n    return model_->getFlatViews();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Component::getHierRef()\r\n//-----------------------------------------------------------------------------\r\nVLNV Component::getHierRef(const QString viewName) const\r\n{\r\n    return model_->getHierRef(viewName);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Component::getHierRefs()\r\n//-----------------------------------------------------------------------------\r\nQList<VLNV> Component::getHierRefs() const\r\n{\r\n    return model_->getHierarchyRefs();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Component::hasSystemViews()\r\n//-----------------------------------------------------------------------------\r\nbool Component::hasSystemViews() const\r\n{\r\n    return !getSystemViews().isEmpty();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Component::hasSystemView()\r\n//-----------------------------------------------------------------------------\r\nbool Component::hasSystemView( const QString& viewName ) const\r\n{\r\n    return findSystemView(viewName) != nullptr;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Component::getSystemViewNames()\r\n//-----------------------------------------------------------------------------\r\nQStringList Component::getSystemViewNames() const\r\n{\r\n    return Search::getNames(getSystemViews());\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Component::findSystemView()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<SystemView> Component::findSystemView(QString const& name) const\r\n{\r\n    return Search::findByName(name, getSystemViews());\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Component::findSystemView()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<SystemView> Component::findSystemView( const VLNV& hierRef ) const\r\n{\r\n    const auto systemViews = getSystemViews();\r\n    auto it = std::find_if(systemViews.cbegin(), systemViews.cend(),\r\n        [&hierRef](auto const& view) { return view->getHierarchyRef() == hierRef; });\r\n\r\n    if (it == systemViews.cend())\r\n    {\r\n        return nullptr;\r\n    }\r\n\r\n    return *it;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Component::getHierSystemRef()\r\n//-----------------------------------------------------------------------------\r\nVLNV Component::getHierSystemRef(QString const& viewName) const\r\n{\r\n    const auto systemViews = getSystemViews();\r\n    auto it = std::find_if(systemViews.cbegin(), systemViews.cend(),\r\n        [&viewName](auto const& view)\r\n        { return view->name() == viewName || (viewName.isEmpty() && view->getHierarchyRef().isValid()); });\r\n\r\n    if (it == systemViews.cend())\r\n    {\r\n        return VLNV();\r\n    }\r\n\r\n    return (*it)->getHierarchyRef();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Component::getHierSystemRefs()\r\n//-----------------------------------------------------------------------------\r\nQList<VLNV> Component::getHierSystemRefs() const\r\n{\r\n    QList<VLNV> refs;\r\n\r\n    for (QSharedPointer<SystemView> view : getSystemViews())\r\n    {\r\n        if (view->getHierarchyRef().isValid())\r\n        {\r\n            refs.append(view->getHierarchyRef());\r\n        }\r\n    }\r\n    return refs;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Component::getFileSetNames()\r\n//-----------------------------------------------------------------------------\r\nQStringList Component::getFileSetNames() const\r\n{\r\n    return Search::getNames(fileSets_);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Component::getFileSet()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<FileSet> Component::getFileSet( const QString& name ) const\r\n{\r\n    return Search::findByName(name, *fileSets_);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Component::hasFileSet()\r\n//-----------------------------------------------------------------------------\r\nbool Component::hasFileSet( const QString& fileSetName ) const\r\n{\r\n    return std::any_of(fileSets_->cbegin(), fileSets_->cend(),\r\n        [&fileSetName](auto const& fileset) { return fileset->name() == fileSetName; });\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Component::hasFileSets()\r\n//-----------------------------------------------------------------------------\r\nbool Component::hasFileSets() const\r\n{\r\n    return !fileSets_->isEmpty();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Component::getFiles()\r\n//-----------------------------------------------------------------------------\r\nQList<QSharedPointer<File> > Component::getFiles(QString const& fileName) const\r\n{\r\n    QList<QSharedPointer<File> > fileList;\r\n\r\n    for (QSharedPointer<FileSet> fileSet : *fileSets_)\r\n    {\r\n        for (QSharedPointer<File> file : *fileSet->getFiles())\r\n        {\r\n            if (file->name() == fileName)\r\n            {\r\n                fileList.append(file);\r\n            }\r\n        }\r\n    }\r\n\r\n    return fileList;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Component::findFilesByFileType()\r\n//-----------------------------------------------------------------------------\r\nQStringList Component::findFilesByFileType( const QString& fileType ) const\r\n{\r\n    QStringList files;\r\n\r\n    std::for_each(fileSets_->cbegin(), fileSets_->cend(), \r\n        [&fileType, &files](auto const& fileSet){ files.append(fileSet->findFilesByFileType(fileType));  });\r\n\r\n    return files;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Component::findFileSetById()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<FileSet> Component::findFileSetById(QString const& id ) const\r\n{\r\n    auto it = std::find_if(fileSets_->cbegin(), fileSets_->cend(),\r\n        [&id](auto const& fileSet){ return fileSet->getFileSetId() == id; });\r\n\r\n    if (it == fileSets_->cend())\r\n    {\r\n        return nullptr;\r\n    }\r\n\r\n    return *it;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Component::getFilesFromFileSets()\r\n//-----------------------------------------------------------------------------\r\nQStringList Component::getFilesFromFileSets( const QStringList& fileSetNames, const QStringList& fileTypes ) const\r\n{\r\n    QStringList files;\r\n\r\n    for (QSharedPointer<FileSet> fileSet : *fileSets_)\r\n    {\r\n        if (fileSetNames.contains(fileSet->name()))\r\n        {\r\n            for (QSharedPointer<File> file : *fileSet->getFiles())\r\n            {\r\n                if (file->matchesFileType(fileTypes))\r\n                {\r\n                    files.append(file->name());\r\n                }\r\n            }\r\n        }\r\n    }\r\n\r\n    return files;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Component::hasFile()\r\n//-----------------------------------------------------------------------------\r\nbool Component::hasFile( const QString& fileName ) const\r\n{\r\n    return std::any_of(fileSets_->cbegin(), fileSets_->cend(),\r\n        [&fileName](auto const& fileSet) { return fileSet->contains(fileName); });\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Component::getBusInterfaceNames()\r\n//-----------------------------------------------------------------------------\r\nQStringList Component::getBusInterfaceNames() const\r\n{\r\n    return Search::getNames(busInterfaces_);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Component::getBusInterface()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<BusInterface> Component::getBusInterface(QString const& name ) const\r\n{\r\n    return Search::findByName(name, *busInterfaces_);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Component::getSlaveInterfaces()\r\n//-----------------------------------------------------------------------------\r\nQStringList Component::getTargetInterfaces( const QString& memoryMap ) const\r\n{\r\n    QStringList names;\r\n    \r\n    General::InterfaceMode interfaceModeName = getRevision() == Document::Revision::Std22 \r\n        ? General::TARGET : General::SLAVE;\r\n\r\n    for (auto const& busif : *busInterfaces_)\r\n    {\r\n        if ((busif->getInterfaceMode() == interfaceModeName) && busif->getMemoryMapRef() == memoryMap)\r\n        {\r\n            names.append(busif->name());\r\n        }\r\n    }\r\n\r\n    return names;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Component::getMasterInterfaces()\r\n//-----------------------------------------------------------------------------\r\nQStringList Component::getInitiatorInterfaces( const QString& addressSpace ) const\r\n{\r\n    QStringList names;\r\n\r\n    General::InterfaceMode initiatorModeName = getRevision() == Document::Revision::Std22\r\n        ? General::INITIATOR : General::MASTER;\r\n\r\n    General::InterfaceMode mirroredInitiatorModeName = getRevision() == Document::Revision::Std22\r\n        ? General::MIRRORED_INITIATOR : General::MIRRORED_MASTER;\r\n\r\n    for (auto const& busif : *busInterfaces_)\r\n    {\r\n        if ((busif->getInterfaceMode() == initiatorModeName || busif->getInterfaceMode() == mirroredInitiatorModeName)\r\n            && (busif->getAddressSpaceRef() == addressSpace))\r\n        {\r\n            names.append(busif->name());\r\n        }\r\n    }\r\n\r\n    return names;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Component::getMasterInterfaces()\r\n//-----------------------------------------------------------------------------\r\nQStringList Component::getInitiatorInterfaces() const\r\n{\r\n    QStringList names;\r\n\r\n    General::InterfaceMode initiatorModeName = getRevision() == Document::Revision::Std22\r\n        ? General::INITIATOR : General::MASTER;\r\n\r\n    General::InterfaceMode mirroredInitiatorModeName = getRevision() == Document::Revision::Std22\r\n        ? General::MIRRORED_INITIATOR : General::MIRRORED_MASTER;\r\n\r\n    for (QSharedPointer<const BusInterface> busif : *busInterfaces_)\r\n    {\r\n        if (busif->getInterfaceMode() == initiatorModeName || busif->getInterfaceMode() == mirroredInitiatorModeName)\r\n        {\r\n            names.append(busif->name());\r\n        }\r\n    }\r\n    return names;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Component::hasInterfaces()\r\n//-----------------------------------------------------------------------------\r\nbool Component::hasInterfaces() const\r\n{\r\n    return !busInterfaces_->isEmpty();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Component::hasInterface()\r\n//-----------------------------------------------------------------------------\r\nbool Component::hasInterface( const QString& interfaceName ) const\r\n{\r\n    return Search::findByName(interfaceName, *busInterfaces_).isNull() == false;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Component::getComInterface()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<ComInterface> Component::getComInterface( QString const& name )\r\n{\r\n    return Search::findByName(name, getComInterfaces());\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Component::getApiInterface()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<ApiInterface> Component::getApiInterface( QString const& name )\r\n{\r\n    return Search::findByName(name, getApiInterfaces());\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Component::getPort()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<Port> Component::getPort( const QString& name ) const\r\n{\r\n    return model_->getPort(name);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Component::getPorts()\r\n//-----------------------------------------------------------------------------\r\nQList<QSharedPointer<Port> > Component::getPortsMappedInInterface(const QString& interfaceName) const\r\n{\r\n    QList<QSharedPointer<Port> > ports;\r\n\r\n    auto busif = getBusInterface(interfaceName);\r\n\r\n    if ( busif.isNull())\r\n    {\r\n        return ports;\r\n    }\r\n\r\n    QStringList portNames = busif->getAllMappedPhysicalPorts();\r\n    \r\n    for (QSharedPointer<Port> port : *getPorts())\r\n    {\r\n        if (portNames.contains(port->name()))\r\n        {\r\n            ports.append(port);\r\n        }\r\n    }\r\n\r\n    return ports;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Component::hasPort()\r\n//-----------------------------------------------------------------------------\r\nbool Component::hasPort( const QString& name ) const\r\n{\r\n    return model_->hasPort(name);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Component::getPortNames()\r\n//-----------------------------------------------------------------------------\r\nQStringList Component::getPortNames() const\r\n{\r\n    return model_->getPortNames();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Component::hasPorts()\r\n//-----------------------------------------------------------------------------\r\nbool Component::hasPorts() const\r\n{\r\n    return model_->hasPorts();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Component::hasWires()\r\n//-----------------------------------------------------------------------------\r\nbool Component::hasWires() const\r\n{\r\n    return model_->hasWires();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Component::hasTransactionals()\r\n//-----------------------------------------------------------------------------\r\nbool Component::hasTransactionals() const\r\n{\r\n    return model_->hasTransactionals();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Component::getAddressSpaceNames()\r\n//-----------------------------------------------------------------------------\r\nQStringList Component::getAddressSpaceNames() const \r\n{\r\n    return Search::getNames(addressSpaces_);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Component::hasLocalMemoryMaps()\r\n//-----------------------------------------------------------------------------\r\nbool Component::hasLocalMemoryMaps() const\r\n{\r\n    return std::any_of(addressSpaces_->cbegin(), addressSpaces_->cend(),\r\n        [](auto const& addrSpace) { return addrSpace->hasLocalMemoryMap(); });\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Component::getDependentDirs()\r\n//-----------------------------------------------------------------------------\r\nQStringList Component::getDependentDirs() const\r\n{\r\n    QStringList dirs;\r\n\r\n    for (QSharedPointer<FileSet> fileSet : *fileSets_)\r\n    {\r\n        dirs.append(*fileSet->getDependencies());\r\n    }\r\n\r\n    return dirs;\r\n}\r\n"
  },
  {
    "path": "IPXACTmodels/Component/Component.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: Component.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 06.10.2015\r\n//\r\n// Description:\r\n// Describes the ipxact:component element.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef COMPONENT_H\r\n#define COMPONENT_H\r\n\r\n#include <IPXACTmodels/ipxactmodels_global.h>\r\n#include <IPXACTmodels/generaldeclarations.h>\r\n\r\n#include <IPXACTmodels/common/Document.h>\r\n\r\n#include <IPXACTmodels/Component/Model.h>\r\n#include <IPXACTmodels/kactusExtensions/KactusAttribute.h>\r\n\r\n#include <QList>\r\n#include <QString>\r\n#include <QSharedPointer>\r\n#include <QStringList>\r\n#include <QMultiMap>\r\n#include <QMap>\r\n\r\nclass AddressSpace;\r\nclass BusInterface;\r\nclass Channel;\r\nclass Choice;\r\nclass ComponentGenerator;\r\nclass ComponentInstantiation;\r\nclass Cpu;\r\nclass DesignInstantiation;\r\nclass DesignConfigurationInstantiation;\r\nclass FileSet;\r\nclass MemoryMap;\r\nclass Mode;\r\nclass IndirectInterface;\r\nclass OtherClockDriver;\r\nclass Port;\r\nclass PowerDomain;\r\nclass RemapState;\r\nclass View;\r\nclass ResetType;\r\n\r\n// Kactus2 extension classes.\r\n\r\nclass File;\r\nclass ComProperty;\r\nclass SystemView;\r\nclass ComInterface;\r\nclass ApiInterface;\r\nclass FileDependency;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Describes the ipxact:component element.\r\n//-----------------------------------------------------------------------------\r\nclass IPXACTMODELS_EXPORT Component: public Document\r\n{\r\n\r\npublic:\r\n\r\n\t/*!\r\n     *  The constructor.\r\n\t *\r\n\t *      param [in] vlnv     The vlnv that is set for the component.\r\n\t */\r\n\texplicit Component(const VLNV &vlnv, Document::Revision revision);\r\n\r\n\t//! Copy constructor.\r\n\tComponent(const Component &other);\r\n\r\n\t//! Assignment operator.\r\n\tComponent& operator=(const Component &other);\r\n\r\n\t/*!\r\n     *  The destructor\r\n\t */\r\n\t~Component() final = default;\r\n\r\n\t/*!\r\n     *  Clone this component and return pointer to the copy.\r\n\t * \r\n\t *    @return Pointer to the cloned component.\r\n\t */\r\n\tQSharedPointer<Document> clone() const final;\r\n\r\n\t/*!\r\n     *  Is this a bus component.\r\n\t *\r\n\t *    @return true if this is a bus component, false otherwise.\r\n\t */\r\n\tbool isBus() const;\r\n\r\n\t/*!\r\n     *  Does the component contain a channel-element.\r\n\t *\r\n\t *    @return True if a channel element is found.\r\n\t */\r\n\tbool isChannel() const;\r\n\r\n\t/*!\r\n     *  Does the component contain a transparent bridge element.\r\n\t *\r\n\t *    @return True if a transparent bridge element is found.\r\n\t */\r\n\tbool isTransparentBridge() const;\r\n\r\n\t/*!\r\n\t *  Does the component contain an opaque bridge.\r\n\t *\r\n\t *    @return True if an opaque bridge is found.\r\n\t */\r\n\tbool isOpaqueBridge() const;\r\n\r\n  \t/*!\r\n     *  Is this component a cpu.\r\n\t *\r\n\t *    @return True, if this is a cpu, otherwise false.\r\n\t */\r\n\tbool isCpu() const;\r\n\r\n\t/*!\r\n     *  Is this component a hierarchical component or not.\r\n\t *\r\n\t *    @return True if the component has design with subcomponents. False if the component is a flat component.\r\n\t */\r\n\tbool isHierarchical() const;\r\n\r\n    QSharedPointer<QList<QSharedPointer<PowerDomain> > > getPowerDomains() const;\r\n\r\n\t/*!\r\n     *  Get list of the bus interfaces of a component.\r\n\t *\r\n\t *    @return A list containing pointers to the bus interfaces.\r\n\t */\r\n    QSharedPointer<QList<QSharedPointer<BusInterface> > > getBusInterfaces() const;\r\n\r\n\t/*!\r\n     *  Set the bus interfaces for the component.\r\n\t *\r\n\t *    @param [in] newBusInterfaces    A list containing the pointers to the new bus interfaces.\r\n\t *\r\n\t */\r\n    void setBusInterfaces(QSharedPointer<QList<QSharedPointer<BusInterface> > > newBusInterfaces);\r\n\r\n\t/*! \\brief Check which interface contains the named port.\r\n\t *\r\n\t * \\param portName The name of the port that is searched in interfaces.\r\n\t *\r\n\t * \\return The interface that contains the port.\r\n\t*/\r\n\tQSharedPointer<BusInterface> getInterfaceForPort(const QString& portName) const;\r\n\r\n    /*!\r\n     *  Get the bus interfaces containing port maps referencing the selected port.\r\n     *\r\n     *    @param [in] portName    The name of the selected port.\r\n     *\r\n     *      return A list of interfaces containing references to the selected port.\r\n     */\r\n    QSharedPointer<QList<QSharedPointer<BusInterface> > > getInterfacesUsedByPort(QString const& portName) const;\r\n\r\n\t/*!\r\n     *  Get the indirect interfaces of a component.\r\n\t *\r\n\t *    @return The indirect interfaces of the component.\r\n\t */\r\n    QSharedPointer<QList<QSharedPointer<IndirectInterface> > > getIndirectInterfaces() const;\r\n\r\n\t/*!\r\n     * Get this component's channels.\r\n\t *\r\n\t *    @return A list containing component's channels.\r\n\t */\r\n    QSharedPointer<QList<QSharedPointer<Channel> > > getChannels() const;\r\n\r\n\t/*!\r\n     *  Set this component's channels.\r\n\t *\r\n\t *    @param [in] newChannels     A list containing the new channels to be set.\r\n\t */\r\n    void setChannels(QSharedPointer<QList<QSharedPointer<Channel> > > newChannels);\r\n\r\n\t/*!\r\n     *  Get this component's remap states.\r\n\t *\r\n\t *    @return A list containing component's remap states.\r\n\t */\r\n    QSharedPointer<QList<QSharedPointer<RemapState> > > getRemapStates() const;\r\n\r\n    /*!\r\n     *  Get this component's modes.\r\n     *\r\n     *    @return The component's modes.\r\n     */\r\n    QSharedPointer<QList<QSharedPointer<Mode> > > getModes() const;\r\n\r\n    /*!\r\n     *  Set the remap states.\r\n     *\r\n     *    @param [in] newRemapStates  A list containing the new remap states.\r\n     */\r\n    void setRemapStates(QSharedPointer<QList<QSharedPointer<RemapState> > > newRemapStates);\r\n\r\n\t/*!\r\n     *  Get this component's address spaces.\r\n\t *\r\n\t *    @return A list containing component's address spaces.\r\n\t */\r\n    QSharedPointer<QList<QSharedPointer<AddressSpace> > > getAddressSpaces() const;\r\n\r\n   \t/*!\r\n     *  Set this component's address spaces\r\n\t *\r\n\t *    @param [in] addressSpaces   A list containing the address spaces to be set.\r\n\t */\r\n    void setAddressSpaces(QSharedPointer<QList<QSharedPointer<AddressSpace> > > newAddressSpaces);\r\n\r\n\t/*!\r\n     *  Get this component's memory maps.\r\n\t *\r\n\t *    @return A list containing component's memory maps.\r\n\t */\r\n    QSharedPointer<QList<QSharedPointer<MemoryMap> > > getMemoryMaps() const;\r\n\r\n\t/*!\r\n     *  Set this components memory maps.\r\n\t *\r\n\t *    @param [in] newMemoryMaps   A list containing the memory maps to be set.\r\n\t */\r\n    void setMemoryMaps(QSharedPointer<QList<QSharedPointer<MemoryMap> > > newMemoryMaps);\r\n\r\n    /*!\r\n     *  Get this component's model information.\r\n\t *\r\n\t *    @return Pointer to this component's model information.\r\n\t */\r\n\tQSharedPointer<Model> getModel() const;\r\n\r\n\t/*!\r\n     *  Set this component's model information.\r\n\t *\r\n\t *    @param [in] model   Pointer to the model information to be set.\r\n\t */\r\n    void setModel(QSharedPointer<Model> newModel);\r\n\r\n\t/*!\r\n     *  Get the views of the component.\r\n\t *\r\n\t *    @return A list containing pointers to the views.\r\n\t */\r\n    QSharedPointer<QList<QSharedPointer<View> > > getViews() const;\r\n\r\n    /*!\r\n     *  Set the views.\r\n     *\r\n     *    @param [in] newViews    A list containing the new views..\r\n     */\r\n    void setViews(QSharedPointer<QList<QSharedPointer<View> > > newViews);\r\n\r\n    /*!\r\n     *  Get the component instantiations.\r\n     *\r\n     *    @return A list containing component instantiations.\r\n     */\r\n    QSharedPointer<QList<QSharedPointer<ComponentInstantiation> > > getComponentInstantiations() const;\r\n\r\n    /*!\r\n     *  Set the component instantiations.\r\n     *\r\n     *    @param [in] newInstantiation    A list containing the new component instantiations.\r\n     */\r\n    void setComponentInstantiations(\r\n        QSharedPointer<QList<QSharedPointer<ComponentInstantiation> > > newInstantiation);\r\n\r\n    /*!\r\n     *  Get the design instantiations.\r\n     *\r\n     *    @return A list containing the design instantiations.\r\n     */\r\n    QSharedPointer<QList<QSharedPointer<DesignInstantiation> > > getDesignInstantiations() const;\r\n\r\n    /*!\r\n     *  Set the design instantiations.\r\n     *\r\n     *    @param [in] newInstantiations   A list containing the new design instantiations.\r\n     */\r\n    void setDesignInstantiations(QSharedPointer<QList<QSharedPointer<DesignInstantiation> > > newInstantiations);\r\n\r\n    /*!\r\n     *  Get the design configuration instantiations.\r\n     *\r\n     *    @return A list containing the design configuration instantiations.\r\n     */\r\n    QSharedPointer<QList<QSharedPointer<DesignConfigurationInstantiation> > >\r\n        getDesignConfigurationInstantiations() const;\r\n\r\n    /*!\r\n     *  Set the design configuration instantiations.\r\n     *\r\n     *    @param [in] newInstantiations   A list containing the new design configuration instantiations.\r\n     */\r\n    void setDesignConfigurationInstantiations(\r\n        QSharedPointer<QList<QSharedPointer<DesignConfigurationInstantiation> > > newInstantiations);\r\n\r\n\t/*!\r\n     *  Get the ports contained in this component.\r\n\t *\r\n\t *    @return A list containing pointers to the ports.\r\n\t */\r\n    QSharedPointer<QList<QSharedPointer<Port> > > getPorts() const;\r\n\r\n    /*!\r\n     *  Set the ports.\r\n     *\r\n     *    @param [in] newPorts    A list containing the new ports.\r\n     */\r\n    void setPorts(QSharedPointer<QList<QSharedPointer<Port> > > newPorts);\r\n\r\n\t/*!\r\n     *  Get this components component generators.\r\n\t *\r\n\t *    @return A list containing component's component generators.\r\n\t */\r\n    QSharedPointer<QList<QSharedPointer<ComponentGenerator> > > getComponentGenerators() const;\r\n\r\n\t/*!\r\n     *  Set this component's component generators.\r\n\t *\r\n\t *    @param [in] newGenerators   A list containing the component generators to be set.\r\n\t */\r\n    void setComponentGenerators(QSharedPointer<QList<QSharedPointer<ComponentGenerator> > > newGenerators);\r\n\r\n   \t/*!\r\n     *  Get this component's choices.\r\n\t *\r\n\t *    @return A list containing component's choices.\r\n\t */\r\n\tQSharedPointer<QList<QSharedPointer<Choice> > > getChoices() const;\r\n\r\n    /*!\r\n     *  Set the choices.\r\n     *\r\n     *    @param [in] newChoices  A list containing the new choices.\r\n     */\r\n    void setChoices(QSharedPointer<QList<QSharedPointer<Choice> > > newChoices);\r\n\r\n\t/*!\r\n     *  Get the file sets of this component.\r\n\t *\r\n\t *    @return A list containing pointers to the file sets.\r\n\t */\r\n    QSharedPointer<QList<QSharedPointer<FileSet> > > getFileSets() const;\r\n\r\n\t/*!\r\n     *  Set this component's file sets.\r\n\t *\r\n\t *    @param [in] newFileSets     A list containing the file sets to be set.\r\n\t */\r\n    void setFileSets(QSharedPointer<QList<QSharedPointer<FileSet> > > newFileSets);\r\n    \r\n\t/*!\r\n     *  Get this component's cpus.\r\n\t *\r\n\t *    @return QList containing component's cpus.\r\n\t */\r\n    QSharedPointer<QList<QSharedPointer<Cpu> > >getCpus() const;\r\n\r\n\t/*!\r\n     *  Set this component's cpus.\r\n\t *\r\n\t *    @param [in] cpus    A list containing the cpus to be set.\r\n\t */\r\n    void setCpus(QSharedPointer<QList<QSharedPointer<Cpu> > > newCpus);\r\n\r\n\t/*!\r\n     *  Get this component's other clock drivers.\r\n\t *\r\n\t *    @return A list containing component's other clock drivers.\r\n\t */\r\n    QSharedPointer<QList<QSharedPointer<OtherClockDriver> > > getOtherClockDrivers() const;\r\n\r\n\t/*!\r\n     *  Set other clock drivers for this component.\r\n\t *\r\n\t *    @param [in] newOtherClockDrivers    A list containing the other clock drivers to be set.\r\n\t */\r\n    void setOtherClockDrivers(QSharedPointer<QList<QSharedPointer<OtherClockDriver> > > newOtherClockDrivers);\r\n\r\n    /*!\r\n     *  Get this component's reset types.\r\n     *\r\n     *    @return A list containing the reset types.\r\n     */\r\n    QSharedPointer<QList<QSharedPointer<ResetType> > > getResetTypes() const;\r\n\r\n    /*!\r\n     *  Set reset types for this component.\r\n     *\r\n     *    @param [in] newResetTypes   A list containing the new reset types.\r\n     */\r\n    void setResetTypes(QSharedPointer<QList<QSharedPointer<ResetType> > > newResetTypes);\r\n\r\n    /*!\r\n     *  Returns the list of SW properties.\r\n     *\r\n     *    @return A list of sw properties.\r\n     */\r\n    QList<QSharedPointer<ComProperty> > getSWProperties() const;\r\n\r\n    /*!\r\n     *  Sets the SW properties.\r\n     *\r\n     *    @param [in] properties  A list of properties to set.\r\n     */\r\n    void setSWProperties(QList<QSharedPointer<ComProperty> > newProperties);\r\n\r\n\t/*!\r\n     *  Get the system views of the component.\r\n\t *\r\n\t *    @return QList containing pointers to the system views.\r\n\t */\r\n    QList<QSharedPointer<SystemView> > getSystemViews() const;\r\n\r\n    /*!\r\n     *  Set the system views.\r\n     *\r\n     *    @param [in] newSystemViews  List containing the new system views.\r\n     */\r\n    void setSystemViews(QList<QSharedPointer<SystemView> > newSystemViews);\r\n\r\n    /*!\r\n     *  Returns the COM interfaces.\r\n     *\r\n     *    @return A list of com interfaces.\r\n     */\r\n    QList<QSharedPointer<ComInterface> > getComInterfaces() const;\r\n\r\n    /*!\r\n     *  Set the com interfaces.\r\n     *\r\n     *    @param [in] newComInterfaces    A list of the new com interfaces.\r\n     */\r\n    void setComInterfaces(QList<QSharedPointer<ComInterface> > newComInterfaces);\r\n\r\n    /*!\r\n     *  Returns the API interfaces.\r\n     *\r\n     *    @return A list of API interfaces.\r\n     */\r\n    QList<QSharedPointer<ApiInterface> > getApiInterfaces() const;\r\n\r\n    /*!\r\n     *  Set the api interfaces.\r\n     *\r\n     *    @param [in] newApiInterfaces    A list of new api interfaces.\r\n     */\r\n    void setApiInterfaces(QList<QSharedPointer<ApiInterface> > newApiInterfaces);\r\n    \r\n    /*!\r\n     *  Get this component's file dependencies.\r\n\t *\r\n\t *    @return QList containing component's file dependencies.\r\n\t */\r\n    QList<QSharedPointer<FileDependency> > getFileDependencies() const;\r\n\r\n    /*!\r\n     *  Set the file dependencies.\r\n     *\r\n     *    @param [in] newFileDependencies     A list of new file dependencies.\r\n     */\r\n    void setFileDependendencies(QList<QSharedPointer<FileDependency> > newFileDependencies);\r\n\r\n    /*!\r\n     *  Returns the pending dependency list for writing.\r\n     *\r\n     *    @return A list of pending dependencies.\r\n     */\r\n    QList<QSharedPointer<FileDependency> > getPendingFileDependencies() const;\r\n\r\n    /*!\r\n     *  Set the pending file dependencies.\r\n     *\r\n     *    @param [in] newFileDependencies     A list of new pending file dependencies.\r\n     */\r\n    void setPendingFileDependencies(QList<QSharedPointer<FileDependency> > newFileDependencies);\r\n\r\n    /*!\r\n     *  Returns the list of source directories.\r\n     *\r\n     *    @return A list of source directiories.\r\n     */\r\n    QStringList getSourceDirectories() const;\r\n    \r\n    /*!\r\n     *  Sets the source directories where to automatically scan files to file sets.\r\n     *\r\n     *    @param [in] sourceDirs The source directories to set.\r\n     */\r\n    void setSourceDirectories(QStringList const& sourceDirs);\r\n\r\n    /*!\r\n     *  Gets the author of the component.\r\n     *\r\n     *    @return The component author.\r\n     */\r\n    QString getAuthor() const;\r\n    \r\n    /*!\r\n     *  Sets the author of the component.\r\n     *\r\n     *    @param [in] author   The name of the component author.\r\n     */\r\n    void setAuthor(QString const& author);\r\n\r\n\t/*!\r\n     *  Get list of the files needed by this component.\r\n\t *\r\n\t *    @return A list containing the paths to the files.\r\n\t */\r\n\tQStringList getDependentFiles() const final;\r\n\r\n\t/*!\r\n     *  Get list of the VLNVs needed by this component.\r\n\t *\r\n\t *    @return QList containing pointers to the VLNVs.\r\n\t */\r\n\tQList<VLNV> getDependentVLNVs() const final;\r\n    \r\n    QStringList getPowerDomainNames() const;\r\n\r\n    /*!\r\n     *  Get the names of the remap states.\r\n     *\r\n     *    @return A list containing the names of the remap states.\r\n     */\r\n    QStringList getRemapStateNames() const;\r\n    \r\n\r\n    /*!\r\n     *  Get the names of the memory maps contained within this component.\r\n\t *\r\n\t *    @return QStringList containing the memory map names.\r\n\t */\r\n\tQStringList getMemoryMapNames() const;\r\n\r\n\t/*!\r\n     *  Checks if the component contains views.\r\n\t *\r\n\t *    @return True if views exist.\r\n\t */\r\n\tbool hasViews() const;\r\n\r\n\t/*!\r\n     *  Check if the component has a view with given name.\r\n\t *\r\n\t *    @param [in] viewName    The name of the view to search for.\r\n\t *\r\n\t *    @return True if the view is found.\r\n\t */\r\n\tbool hasView(const QString& viewName) const;\r\n\r\n\t/*!\r\n     *  Get the names of the views of the component.\r\n\t *\r\n\t *    @return QStringList containing the view names.\r\n\t */\r\n\tQStringList getViewNames() const;\r\n            \r\n\t/*!\r\n     *  Get the names of the CPU elements within component.\r\n\t *\r\n\t *    @return QStringList containing the CPU names.\r\n\t */\r\n\tQStringList getCpuNames() const;\r\n\r\n\t/*!\r\n     *  Get the hierarchical views of a component.\r\n\t *\r\n\t *      return QStringList containing the names of the hierarchical HW views.\r\n\t */\r\n\tQStringList getHierViews() const;\r\n\r\n\t/*!\r\n     *  Get the non-hierarchical views of a component.\r\n\t *\r\n\t *    @return QStringList containing the names of the non-hierarchical HW views.\r\n\t */\r\n\tQStringList getFlatViews() const;\r\n\r\n\t/*!\r\n     *  Get the design of a hierarchical component.\r\n\t *\r\n     *    @return A vlnv of a design or configuration that is used within this component.\r\n\t */\r\n\tVLNV getHierRef(const QString viewName = QString()) const;\r\n\r\n\t/*!\r\n     *  Get the hierarchical references this component contains.\r\n\t *\r\n\t *    @return QList<VLNV> contains the VLNVs of the hierarchical references.\r\n\t */\r\n\tQList<VLNV> getHierRefs() const;\r\n\r\n    /*!\r\n     *  Checks if the component contains system views.\r\n\t *\r\n\t *    @return True if system views exist.\r\n\t */\r\n\tbool hasSystemViews() const;\r\n\r\n\t/*!\r\n     *  Check if the component has a system view with given name.\r\n\t *\r\n\t *    @param [in] viewName    The name of the system view to search for.\r\n\t *\r\n\t *    @return True if the view is found.\r\n\t */\r\n\tbool hasSystemView(const QString& viewName) const;\r\n\r\n\t/*!\r\n     *  Get the names of the system views of the component.\r\n\t *\r\n\t *    @return QStringList containing the system view names.\r\n\t */\r\n\tQStringList getSystemViewNames() const;\r\n\r\n\t/*!\r\n     *  Find a named system view within a component.\r\n\t *\r\n\t *    @param [in] name    The name of the system view to search for.\r\n\t *\r\n\t *    @return Pointer to the specified system view. Null pointer if the system view was not found.\r\n\t */\r\n    QSharedPointer<SystemView> findSystemView(QString const& name) const;\r\n\r\n\t/*!\r\n     *  Find a system view which refers to the given VLNV.\r\n\t *\r\n\t *    @param [in] hierRef     The VLNV to the design/configuration that is searched among the views.\r\n\t *\r\n\t *    @return Pointer to the system view. Null pointer if no system view is found.\r\n\t */\r\n\tQSharedPointer<SystemView> findSystemView(const VLNV& hierRef) const;\r\n\r\n\t/*!\r\n     *  Get the system design of a hierarchical component.\r\n\t *\r\n     *    @return A vlnv of a design or configuration that is used within this component.\r\n     */\r\n\tVLNV getHierSystemRef(QString const& viewName = QString()) const;\r\n\r\n\t/*!\r\n     *  Get the hierarchical system references this component contains.\r\n\t *\r\n\t *    @return QList<VLNV> contains the VLNVs of the hierarchical system references.\r\n\t */\r\n\tQList<VLNV> getHierSystemRefs() const;\r\n\r\n\t/*!\r\n     *  Get names of the file sets stored in the component.\r\n\t *\r\n\t *    @return QStringList containing the names of the file sets of the component.\r\n\t */\r\n\tQStringList getFileSetNames() const;\r\n\r\n\t/*!\r\n     *  Get the specified file set if one exists.\r\n\t *\r\n\t *    @param [in] name    Name of the file set that is wanted.\r\n\t *\r\n\t *    @return Pointer to the file set. If file set was not found, creates and returns pointer to it.\r\n\t */\r\n\tQSharedPointer<FileSet> getFileSet(const QString& name) const;\r\n\r\n\t/*!\r\n     *  Check if the component has the named file set or not.\r\n\t *\r\n\t *    @param [in] fileSetName     The name of the file set to search\r\n\t *\r\n\t *    @return True if the file set is found.\r\n\t */\r\n\tbool hasFileSet(const QString& fileSetName) const;\r\n\r\n\t/*!\r\n     *  Checks if the component contains file sets.\r\n\t *\r\n\t *    @return True if file sets exist.\r\n\t */\r\n\tbool hasFileSets() const;\r\n\r\n\t/*!\r\n\t *  Returns all file pointers in all file sets that reference the given file name.\r\n\t *\r\n\t *    @param [in]  filename   The filename to search for.\r\n\t *    @param [out] files      All found files that reference the given file name.\r\n\t */\r\n    QList<QSharedPointer<File> > getFiles(QString const& fileName) const;\r\n\r\n\t/*!\r\n     *  Find the files that match the specified file type.\r\n\t *\r\n\t *    @param [in] fileType    The file type to search within the files.\r\n\t *\r\n\t *    @return QStringList containing the file paths of files matching the file type.\r\n\t */\r\n\tQStringList findFilesByFileType(const QString& fileType) const;\r\n\r\n\t/*!\r\n     *  Find the file set by the file set id.\r\n\t *\r\n\t *    @param [in] id  Identifies the file set.\r\n\t *\r\n\t *    @return Pointer to the file set found, null pointer if none found.\r\n\t */\r\n\tQSharedPointer<FileSet> findFileSetById(QString const& id) const;\r\n\r\n\t/*!\r\n     *  Get file paths of all specified file sets that match the specified file types.\r\n\t *\r\n\t *    @param [in] fileSetNames    Contains the file sets to search from.\r\n\t *    @param [in] fileTypes       Contains the file types that are searched among the file sets.\r\n\t *\r\n\t *    @return QStringList containing the relative file paths to the files.\r\n\t */\r\n\tQStringList getFilesFromFileSets(const QStringList& fileSetNames, const QStringList& fileTypes) const;\r\n\r\n\t\r\n\t/*!\r\n     *  Check if the component has the given file in it's file sets.\r\n\t *\r\n\t *    @param [in] fileName    The name of the file to search.\r\n\t *\r\n\t *    @return True if file is found in one of the file sets.\r\n\t */\r\n\tbool hasFile(const QString& fileName) const;\r\n\r\n\t/*!\r\n     *  Get list of names of all the bus interfaces in this component.\r\n\t *\r\n\t *    @return QStringList containing the names of the bus interfaces.\r\n\t */\r\n\tQStringList getBusInterfaceNames() const;\r\n\r\n\t/*!\r\n     *  Get a A bus interface.\r\n\t *\r\n\t *    @param [in] name    Contains the name of the wanted bus interface.\r\n\t *\r\n\t *    @return A pointer to the busInterface instance or null pointer.\r\n\t */\r\n\tQSharedPointer<BusInterface> getBusInterface(const QString& name) const;\r\n\r\n\t/*!\r\n     *  Get list of the slave interfaces that refer to given memory map.\r\n\t *\r\n\t *    @param [in] memoryMap   The name of the memory map to search for.\r\n\t *\r\n\t *    @return QStringList containing names of the slave interfaces.\r\n\t */\r\n\tQStringList getTargetInterfaces(const QString& memoryMap) const;\r\n\r\n\t/*!\r\n     *  Get list of the master and mirrored master interfaces that refer to given address space.\r\n\t *\r\n\t *    @param [in] addressSpace    The name of the address space to search for.\r\n\t *\r\n\t *    @return QStringList containing names of the master and mirrored master interfaces.\r\n\t */\r\n\tQStringList getInitiatorInterfaces(const QString& addressSpace) const;\r\n\r\n\t/*!\r\n     *  Get list of the master and mirrored master interface names.\r\n\t *\r\n\t *    @return QStringList containing the interface names.\r\n\t */\r\n\tQStringList getInitiatorInterfaces() const;\r\n\r\n\t/*!\r\n     *  Checks if the component contains bus interfaces.\r\n\t *\r\n\t *    @return bool True if bus interfaces exist.\r\n\t */\r\n\tbool hasInterfaces() const;\r\n\r\n\t/*!\r\n     *  Check if the component contains the named interface.\r\n\t *\r\n\t *    @param [in] interfaceName   The name of the interface to search for.\r\n\t *\r\n\t *    @return True if the interface was found.\r\n\t */\r\n\tbool hasInterface(const QString& interfaceName) const;\r\n\r\n    /*!\r\n     *  Finds the COM interface with the given name.\r\n     *\r\n     *    @param [in] name The name of the COM interface.\r\n     *\r\n     *    @return The COM interface, or 0 if there is no COM interface with the given name.\r\n     */\r\n\tQSharedPointer<ComInterface> getComInterface(QString const& name);\r\n\r\n    /*!\r\n     *  Finds the API interface with the given name.\r\n     *\r\n     *    @param [in] name The name of the API interface.\r\n     *\r\n     *    @return The API interface, or 0 if there is no API interface with the given name.\r\n     */\r\n\tQSharedPointer<ApiInterface> getApiInterface(QString const& name);\r\n\r\n\t/*!\r\n     *  Get the named port of a component\r\n\t *\r\n\t *    @param [in] name    QString containing the name of the port\r\n\t *\r\n\t *    @return Pointer to the port instance\r\n\t */\r\n\tQSharedPointer<Port> getPort(const QString& name) const;\r\n\r\n\t/*!\r\n     *  Get the ports that are found in specified interface.\r\n\t *\r\n\t *    @param [in] interfaceName   The name of interface that's ports are requested.\r\n\t *\r\n\t *    @return List containing pointers to the ports.\r\n\t */\r\n    QList<QSharedPointer<Port> > getPortsMappedInInterface(const QString& interfaceName) const;\r\n\r\n\t/*!\r\n     *  Check if the component has the specified port or not.\r\n\t *\r\n\t *    @param [in] name    The name of the port to be searched\r\n\t *\r\n\t *    @return True if the port is found\r\n\t */\r\n\tbool hasPort(const QString& name) const;\r\n\r\n\t/*!\r\n     *  Get list of port names for this component.\r\n\t *\r\n\t *    @return QStringList containing the port names.\r\n\t */\r\n\tQStringList getPortNames() const;\r\n\r\n\t/*!\r\n     *  Checks if the component contains ports.\r\n\t *\r\n\t *    @return bool True if ports exist.\r\n\t */\r\n\tbool hasPorts() const;\r\n\t\r\n\t/*!\r\n\t *\tChecks if the component has wire ports.\r\n\t *  \r\n\t * \t    @return True if wire ports exist.\r\n\t */\r\n\tbool hasWires() const;\r\n\r\n\t/*!\r\n\t *\tChecks if the component has transactional ports.\r\n\t *  \r\n\t * \t    @return True if transactional ports exist.\r\n\t */\r\n\tbool hasTransactionals() const;\r\n\r\n\t/*!\r\n     *  Get the names of the address spaces stored in this component.\r\n\t *\r\n\t *    @return QStringList containing the names of the address spaces.\r\n\t */\r\n\tQStringList getAddressSpaceNames() const;\r\n\r\n\t/*!\r\n     *  Check if the component contains at least one local memory map.\r\n\t *\r\n\t *    @return True if at least one local memory map is found.\r\n\t */\r\n\tbool hasLocalMemoryMaps() const;\r\n\r\n\t/*!\r\n     *  Get the directories which this component needs.\r\n\t *\r\n\t *    @return QStringList containing the relative directory paths.\r\n\t */\r\n\tQStringList getDependentDirs() const final;\r\n\r\nprivate:\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! Specifies all the power domains for this component.\r\n    QSharedPointer<QList<QSharedPointer<PowerDomain> > > powerDomains_ =\r\n        QSharedPointer<QList<QSharedPointer<PowerDomain> > >(new QList<QSharedPointer<PowerDomain> >());\r\n\r\n    //! Specifies all the bus interfaces for this component.\r\n\tQSharedPointer<QList<QSharedPointer<BusInterface> > > busInterfaces_ =\r\n        QSharedPointer<QList<QSharedPointer<BusInterface> > >(new QList<QSharedPointer<BusInterface> >());\r\n\r\n    //! Specifies all the indirect interfaces for this component.\r\n    QSharedPointer<QList<QSharedPointer<IndirectInterface> > > indirectInterfaces_ = \r\n        QSharedPointer<QList<QSharedPointer<IndirectInterface> > >(new QList<QSharedPointer<IndirectInterface> >());\r\n\r\n    //! Specifies the interconnection between interfaces within component.\r\n\tQSharedPointer<QList<QSharedPointer<Channel> > > channels_ =\r\n        QSharedPointer<QList<QSharedPointer<Channel> > >(new QList<QSharedPointer<Channel> >());\r\n\t\r\n\t//! Contains the remapStates.\r\n\tQSharedPointer<QList<QSharedPointer<RemapState> > > remapStates_ =\r\n        QSharedPointer<QList<QSharedPointer<RemapState> > >(new QList<QSharedPointer<RemapState> >());\r\n\r\n    //! Contains the modes.\r\n    QSharedPointer<QList<QSharedPointer<Mode> > > modes_ =\r\n        QSharedPointer<QList<QSharedPointer<Mode> > >(new QList<QSharedPointer<Mode> >());\r\n\r\n\t//! Contains the addressSpaces.\r\n\tQSharedPointer<QList<QSharedPointer<AddressSpace> > > addressSpaces_ =\r\n        QSharedPointer<QList<QSharedPointer<AddressSpace> > >(new QList<QSharedPointer<AddressSpace> >());\r\n\r\n\t//! Contains the memoryMaps\r\n\tQSharedPointer<QList<QSharedPointer<MemoryMap> > > memoryMaps_ =\r\n        QSharedPointer<QList<QSharedPointer<MemoryMap> > >(new QList<QSharedPointer<MemoryMap> >());\r\n\r\n\t//! Contains the model.\r\n    QSharedPointer<Model> model_ = QSharedPointer<Model> (new Model());\r\n\r\n    //! Contains the componentGenerators.\r\n    QSharedPointer<QList<QSharedPointer<ComponentGenerator> > > componentGenerators_ =\r\n        QSharedPointer < QList<QSharedPointer<ComponentGenerator> > >(new QList<QSharedPointer<ComponentGenerator> >());\r\n\r\n\t//! Contains the choices.\r\n\tQSharedPointer<QList<QSharedPointer<Choice> > > choices_ =\r\n        QSharedPointer<QList<QSharedPointer<Choice> > >(new QList<QSharedPointer<Choice> >());\r\n\r\n\t//! Contains the fileSets.\r\n\tQSharedPointer<QList<QSharedPointer<FileSet> > > fileSets_ =\r\n        QSharedPointer<QList<QSharedPointer<FileSet> > >(new QList<QSharedPointer<FileSet> >());\r\n    \r\n\t//! Contains the cpus.\r\n\tQSharedPointer<QList<QSharedPointer<Cpu> > > cpus_ =\r\n        QSharedPointer<QList<QSharedPointer<Cpu> > >(new QList<QSharedPointer<Cpu> >());\r\n    \r\n\t//! Contains the otherClockDrivers.\r\n\tQSharedPointer<QList<QSharedPointer<OtherClockDriver> > > otherClockDrivers_ =\r\n        QSharedPointer<QList<QSharedPointer<OtherClockDriver> > >(new QList<QSharedPointer<OtherClockDriver> >());\r\n\r\n    //! Contains the reset types.\r\n    QSharedPointer<QList<QSharedPointer<ResetType> > > resetTypes_ =\r\n        QSharedPointer<QList<QSharedPointer<ResetType> > >(new QList<QSharedPointer<ResetType> >());\r\n\r\n    //! Contains the pending file dependencies.\r\n    QList<QSharedPointer<FileDependency> > pendingFileDependencies_;\r\n\r\n};\r\n\r\n\r\n#endif // COMPONENT_H\r\n"
  },
  {
    "path": "IPXACTmodels/Component/ComponentGenerator.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ComponentGenerator.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Janne Virtanen\r\n// Date: 05.10.2015\r\n//\r\n// Description:\r\n// Implementation for ipxact:componentGenerator element.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"ComponentGenerator.h\"\r\n\r\n#include <IPXACTmodels/utilities/Copy.h>\r\n\r\n#include <IPXACTmodels/common/Parameter.h>\r\n\r\n#include <QList>\r\n#include <QSharedPointer>\r\n#include <QString>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentGenerator::ComponentGenerator()\r\n//-----------------------------------------------------------------------------\r\nComponentGenerator::ComponentGenerator(ComponentGenerator const& other):\r\nNameGroup(other),\r\nExtendable(other),\r\nhidden_(other.hidden_),\r\nscope_(other.scope_),\r\nphase_(other.phase_),\r\napiType_(other.apiType_),\r\napiService_(other.apiService_),\r\ntransportMethods_(other.transportMethods_),\r\ngeneratorExe_(other.generatorExe_),\r\ngroups_(other.groups_)\r\n{\r\n    Copy::copyList(other.parameters_, parameters_);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentGenerator::operator=()\r\n//-----------------------------------------------------------------------------    \r\nComponentGenerator& ComponentGenerator::operator=(ComponentGenerator const& other)\r\n{\r\n\tif (this != &other)\r\n    {\r\n\t\tNameGroup::operator=(other);\r\n        Extendable::operator=(other);\r\n        hidden_ = other.hidden_;\r\n        scope_ = other.scope_;\r\n\t\tphase_ = other.phase_;\r\n\t\tapiType_ = other.apiType_;\r\n\t\tapiService_ = other.apiService_;\r\n        generatorExe_ = other.generatorExe_;\r\n        groups_ = other.groups_;\r\n\r\n        parameters_->clear();\r\n        Copy::copyList(other.parameters_, parameters_);\r\n    }\r\n\r\n    return *this;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentGenerator::setHidden()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentGenerator::setHidden(bool hidden)\r\n{\r\n    hidden_.setValue(hidden);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentGenerator::getHidden()\r\n//-----------------------------------------------------------------------------\r\nBooleanValue ComponentGenerator::getHidden() const\r\n{\r\n    return hidden_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentGenerator::setScope()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentGenerator::setScope(Scope scope)\r\n{\r\n    scope_ = scope;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentGenerator::getScope()\r\n//-----------------------------------------------------------------------------\r\nComponentGenerator::Scope ComponentGenerator::getScope() const\r\n{\r\n\treturn scope_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentGenerator::setPhase()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentGenerator::setPhase(QString const& phaseExpression)\r\n{\r\n    phase_ = phaseExpression;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentGenerator::getPhase()\r\n//-----------------------------------------------------------------------------\r\nQString ComponentGenerator::getPhase() const\r\n{\r\n    return phase_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentGenerator::getParameters()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<QList<QSharedPointer<Parameter> > > ComponentGenerator::getParameters()\r\n{\r\n    return parameters_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentGenerator::setApiType()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentGenerator::setApiType(ApiType apiType)\r\n{\r\n    apiType_ = apiType;\r\n}\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentGenerator::getApiType()\r\n//-----------------------------------------------------------------------------\r\nComponentGenerator::ApiType ComponentGenerator::getApiType() const\r\n{\r\n    return apiType_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentGenerator::setTransportMethods()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentGenerator::setTransportMethods(QStringList const& transportMethods)\r\n{\r\n    transportMethods_ = transportMethods;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentGenerator::getTransportMethods()\r\n//-----------------------------------------------------------------------------\r\nQStringList ComponentGenerator::getTransportMethods() const\r\n{\r\n    return transportMethods_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentGenerator::setGeneratorExe()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentGenerator::setGeneratorExe(QString const& generatorExe)\r\n{\r\n    generatorExe_ = generatorExe;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentGenerator::getGeneratorExe()\r\n//-----------------------------------------------------------------------------\r\nQString ComponentGenerator::getGeneratorExe() const\r\n{\r\n    return generatorExe_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentGenerator::setGroups()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentGenerator::setGroups(QStringList const& groups)\r\n{\r\n    groups_ = groups;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentGenerator::getGroups()\r\n//-----------------------------------------------------------------------------\r\nQStringList ComponentGenerator::getGroups() const\r\n{\r\n    return groups_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentGenerator::getApiService()\r\n//-----------------------------------------------------------------------------\r\nQString ComponentGenerator::getApiService() const\r\n{\r\n    return apiService_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentGenerator::setApiService()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentGenerator::setApiService(QString const& newApiService)\r\n{\r\n    apiService_ = newApiService;\r\n}\r\n"
  },
  {
    "path": "IPXACTmodels/Component/ComponentGenerator.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ComponentGenerator.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Janne Virtanen\r\n// Date: 05.10.2015\r\n//\r\n// Description:\r\n// Implementation for ipxact:componentGenerator element.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef COMPONENTGENERATOR_H\r\n#define COMPONENTGENERATOR_H\r\n\r\n#include <IPXACTmodels/ipxactmodels_global.h>\r\n\r\n#include <IPXACTmodels/common/BooleanValue.h>\r\n#include <IPXACTmodels/common/Extendable.h>\r\n#include <IPXACTmodels/common/NameGroup.h>\r\n#include <IPXACTmodels/generaldeclarations.h>\r\n\r\n#include <QList>\r\n#include <QString>\r\n\r\nclass Choice;\r\nclass Parameter;\r\n//-----------------------------------------------------------------------------\r\n//! Implementation for ipxact:componentGenerator element.\r\n//-----------------------------------------------------------------------------\r\nclass IPXACTMODELS_EXPORT ComponentGenerator : public NameGroup, public Extendable\r\n{\r\n\r\npublic:\r\n\r\n\t//! Indicates the type of API used by the generator.\r\n\tenum class ApiType\r\n\t{\r\n\t\tTGI_2022_BASE,\r\n\t\tTBGI_2022_EXTENDED,\r\n\t\tTGI_2014_BASE,\r\n\t\tTGI_2014_EXTENDED,\r\n\t\tTGI_2009,\r\n\t\tNONE,\r\n        EMPTY_API_TYPE\r\n\t};\r\n\r\n\t//! Specifies if the generator shall be run once for all instances or once for each instance of this component.\r\n\tenum class Scope\r\n    {\r\n\t\tINSTANCE,\r\n\t\tENTITY,\r\n        NO_SCOPE\r\n\t};\r\n\r\n\t//! The constructor.\r\n\tComponentGenerator() = default;\r\n\r\n\t//! Copy constructor.\r\n\tComponentGenerator(const ComponentGenerator &other);\r\n\r\n\t//! Assignment operator.\r\n\tComponentGenerator &operator=(const ComponentGenerator &other);\r\n\r\n\t//! The destructor.\r\n\t~ComponentGenerator() override = default;\r\n\r\n    /*! Set the hidden setting for this component generator.\r\n\t *\r\n\t *    @param [in] hidden  The hidden value to set.\r\n\t */\r\n\tvoid setHidden(bool hidden);\r\n\r\n\t/*! Get the hidden setting of this component generator.\r\n\t *\r\n\t *    @return The hidden setting.\r\n\t */\r\n\tBooleanValue getHidden() const;\r\n\r\n\t/*! Set the scope of this component generator.\r\n\t *\r\n\t *    @param [in] scope The scope to be set.\r\n\t */\r\n\tvoid setScope(Scope scope);\r\n\r\n\t/*! Get the scope of this component generator.\r\n\t *\r\n\t *    @return  The scope of the generator.\r\n\t */\r\n\tScope getScope() const;\r\n\r\n\t/*! Set the phase for the component generator.\r\n\t *\r\n\t *    @param [in] phase   The phase value to set.\r\n\t */\r\n\tvoid setPhase(QString const& phaseExpression);\r\n\r\n    /*! Get the phase of the component generator.\r\n\t *\r\n\t *    @return The generator phase.\r\n\t */\r\n\tQString getPhase() const;\r\n\r\n\t/*! Get the parameters for this component generator.\r\n\t *\r\n\t *    @return QList containing pointers to the parameters.\r\n\t */\r\n\tQSharedPointer<QList<QSharedPointer<Parameter> > > getParameters();\r\n    \r\n\t/*! Set the ApiType for this Component Generator\r\n\t *\r\n\t *    @param [in] apiType enum ApiType containing the API type.\r\n\t */\r\n\tvoid setApiType(ApiType apiType);\r\n\r\n    /*! Get the API type of the generator.\r\n\t *\r\n\t *    @return The generator API type.\r\n\t */\r\n\tApiType getApiType() const;\r\n\r\n    /*! Set the supported transport methods.\r\n\t *\r\n\t *    @param [in] transportMethods The transport methods to set.\r\n\t */\r\n\tvoid setTransportMethods(QStringList const& transportMethods);\r\n\r\n\t/*! Get the supported transport methods.\r\n\t *\r\n\t *    @return The supported transport methods.\r\n\t */\r\n\tQStringList getTransportMethods() const;\r\n    \r\n\t/*! Set the path to the generator executable for this generator.\r\n\t *\r\n\t *    @param [in] generatorExe The path to the generator executable.\r\n\t */\r\n\tvoid setGeneratorExe(QString const& generatorExe);\r\n\r\n\t/*! Get the path of the generator executable.\r\n\t *\r\n\t *    @return The generator executable path.\r\n\t */\r\n\tQString getGeneratorExe() const;\r\n\r\n\t/*! Set the groups for this component generator.\r\n\t *\r\n\t *    @param [in] groups The names of the groups for this generator.\r\n\t */\r\n\tvoid setGroups(QStringList const& groups);\r\n\r\n\t/*! Get list of the groups for this Component Generator\r\n\t *\r\n\t *    @return The names of the groups this generator belongs to.\r\n\t */\r\n\tQStringList getGroups() const;\r\n\t\r\n\t/*!\r\n\t *\tGet the component generator transport service.\r\n\t *  \r\n\t * \t    @return The transport service used by the component generator.\r\n\t */\r\n\tQString getApiService() const;\r\n\r\n\t/*!\r\n\t *\tSet the component generator transport service.\r\n\t *\r\n\t * \t    @param [in] newApiService\tThe transport service to set.\r\n\t */\r\n\tvoid setApiService(QString const& newApiService);\r\n\r\nprivate:\r\n\r\n\t//! Specifies if this generator can be run as standalone or if it must be run as part of a generator chain.\r\n\tBooleanValue hidden_;\r\n    \r\n\t//! Indicates if the generator shall be run once for all instances or once for each instance of this component.\r\n\tScope scope_ = ComponentGenerator::Scope::NO_SCOPE;\r\n\r\n\t//! Determines the generator phase in a sequence of generator runs. \r\n\tQString phase_;\r\n\r\n\t// Specifies any component generator specific parameters.\r\n\tQSharedPointer<QList<QSharedPointer<Parameter> > > parameters_ = \r\n\t\tQSharedPointer<QList<QSharedPointer<Parameter> > >(new QList<QSharedPointer<Parameter> >());\r\n\r\n\t//! Indicates the type of API used by the generator.\r\n\tApiType apiType_ = ComponentGenerator::ApiType::EMPTY_API_TYPE;\r\n\r\n\t//! Indicates which transport service is used.\r\n\tQString apiService_;\r\n    \r\n    //! The alternate SOAP transport protocols supported by the component generator.\r\n\tQStringList transportMethods_;\r\n\r\n\t//! The path to the generator executable.\r\n\tQString generatorExe_;\r\n\r\n    //! Names for assigning this generator to a group with other generators.\r\n\tQList<QString> groups_;\r\n\r\n};\r\n\r\n#endif /* COMPONENTGENERATOR_H */\r\n"
  },
  {
    "path": "IPXACTmodels/Component/ComponentGeneratorReader.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ComponentGeneratorReader.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Janne Virtanen\r\n// Date: 05.10.2015\r\n//\r\n// Description:\r\n// Reader for IP-XACT ComponentGenerator element.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"ComponentGeneratorReader.h\"\r\n\r\n#include <IPXACTmodels/common/NameGroupReader.h>\r\n#include <IPXACTmodels/common/ParameterReader.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentGeneratorReader::createComponentGeneratorFrom()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<ComponentGenerator> ComponentGeneratorReader::createComponentGeneratorFrom(\r\n    QDomNode const& componentGeneratorNode, Document::Revision docRevision)\r\n{\r\n\tQSharedPointer<ComponentGenerator> newComponentGenerator (new ComponentGenerator());\r\n\r\n\tNameGroupReader::parseNameGroup(componentGeneratorNode, newComponentGenerator);\r\n\r\n\tDetails::readAttributes(componentGeneratorNode, newComponentGenerator);\r\n\r\n    if (auto const& phaseElement = componentGeneratorNode.firstChildElement(QStringLiteral(\"ipxact:phase\")); \r\n        !phaseElement.isNull())\r\n    {\r\n        newComponentGenerator->setPhase(phaseElement.firstChild().nodeValue());\r\n    }\r\n\r\n    Details::readParameters(componentGeneratorNode.firstChildElement(QStringLiteral(\"ipxact:parameters\")), newComponentGenerator, docRevision);\r\n        \r\n    Details::readApiType(componentGeneratorNode.firstChildElement(QStringLiteral(\"ipxact:apiType\")), newComponentGenerator);\r\n   \r\n    if (docRevision == Document::Revision::Std22)\r\n    {\r\n        Details::readApiService(componentGeneratorNode.firstChildElement(QStringLiteral(\"ipxact:apiService\")), newComponentGenerator);\r\n    }\r\n\r\n    Details::readTransportMethods(componentGeneratorNode.firstChildElement(QStringLiteral(\"ipxact:transportMethods\")), newComponentGenerator);\r\n\r\n    if (auto const& exeElement = componentGeneratorNode.firstChildElement(QStringLiteral(\"ipxact:generatorExe\")); \r\n        !exeElement.isNull())\r\n    {\r\n        newComponentGenerator->setGeneratorExe(exeElement.firstChild().nodeValue());\r\n    }\r\n\r\n    CommonItemsReader::parseVendorExtensions(componentGeneratorNode, newComponentGenerator);\r\n\r\n    Details::parseGroups(componentGeneratorNode, newComponentGenerator);\r\n\r\n    return newComponentGenerator;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentGeneratorReader::Details::readAttributes()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentGeneratorReader::Details::readAttributes(QDomNode const& componentGeneratorNode,\r\n\tQSharedPointer<ComponentGenerator> newComponentGenerator)\r\n{\r\n\tQDomNamedNodeMap attributeMap = componentGeneratorNode.attributes();\r\n\r\n\tQString scope = attributeMap.namedItem(QStringLiteral(\"scope\")).nodeValue();\r\n\tif (scope == QLatin1String(\"entity\"))\r\n\t{\r\n\t\tnewComponentGenerator->setScope(ComponentGenerator::Scope::ENTITY);\r\n\t}\r\n\telse if (scope == QLatin1String(\"instance\"))\r\n\t{\r\n\t\tnewComponentGenerator->setScope(ComponentGenerator::Scope::INSTANCE);\r\n\t}\r\n\r\n    QString hidden = attributeMap.namedItem(QStringLiteral(\"hidden\")).firstChild().nodeValue();\r\n    if (hidden == QLatin1String(\"true\"))\r\n    {\r\n        newComponentGenerator->setHidden(true);\r\n    }\r\n    else if (hidden == QLatin1String(\"false\"))\r\n    {\r\n        newComponentGenerator->setHidden(false);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentGeneratorReader::Details::readParameters()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentGeneratorReader::Details::readParameters(QDomNode const& parametersNode, \r\n    QSharedPointer<ComponentGenerator> componentGenerator, \r\n    Document::Revision docRevision)\r\n{\r\n    int parameterCount = parametersNode.childNodes().count();\r\n\tfor (int i = 0; i < parameterCount; i++)\r\n\t{\r\n\t\tQDomNode parameterNode = parametersNode.childNodes().at(i);\r\n\t\tcomponentGenerator->getParameters()->append(ParameterReader::createParameterFrom(parameterNode, docRevision));\r\n\t}\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentGeneratorReader::Details::readApiType()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentGeneratorReader::Details::readApiType(QDomNode const& apiTypeNode,\r\n\tQSharedPointer<ComponentGenerator> newComponentGenerator)\r\n{\r\n\tQString apiType = apiTypeNode.firstChild().nodeValue();\r\n\tif (apiType == QLatin1String(\"TGI_2014_BASE\"))\r\n\t{\r\n\t\tnewComponentGenerator->setApiType(ComponentGenerator::ApiType::TGI_2014_BASE);\r\n\t}\r\n\telse if (apiType == QLatin1String(\"TGI_2014_EXTENDED\"))\r\n\t{\r\n\t\tnewComponentGenerator->setApiType(ComponentGenerator::ApiType::TGI_2014_EXTENDED);\r\n\t}\r\n\telse if (apiType == QLatin1String(\"TGI_2009\"))\r\n\t{\r\n\t\tnewComponentGenerator->setApiType(ComponentGenerator::ApiType::TGI_2009);\r\n\t}\r\n    else if (apiType == QLatin1String(\"none\"))\r\n    {\r\n        newComponentGenerator->setApiType(ComponentGenerator::ApiType::NONE);\r\n    }\r\n    else if (apiType == QLatin1String(\"TGI_2022_BASE\"))\r\n    {\r\n        newComponentGenerator->setApiType(ComponentGenerator::ApiType::TGI_2022_BASE);\r\n    }\r\n    else if (apiType == QLatin1String(\"TBGI_2022_EXTENDED\"))\r\n    {\r\n        newComponentGenerator->setApiType(ComponentGenerator::ApiType::TBGI_2022_EXTENDED);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentGeneratorReader::Details::readApiService()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentGeneratorReader::Details::readApiService(QDomNode const& apiServiceNode, \r\n    QSharedPointer<ComponentGenerator> newComponentGenerator)\r\n{\r\n    if (!apiServiceNode.isNull())\r\n    {\r\n        newComponentGenerator->setApiService(apiServiceNode.firstChild().nodeValue());\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentGeneratorReader::Details::readTransportMethods()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentGeneratorReader::Details::readTransportMethods(QDomElement const& methodsNode, \r\n    QSharedPointer<ComponentGenerator> newComponentGenerator)\r\n{\r\n    if (methodsNode.isNull())\r\n    {\r\n        return;\r\n    }\r\n\r\n    QStringList transportMethods;\r\n    int methodsCount = methodsNode.childNodes().count();\r\n    for (int i = 0; i < methodsCount; i++)\r\n    {\r\n        QDomNode methodNode = methodsNode.childNodes().at(i);\r\n        transportMethods.append(methodNode.firstChild().nodeValue());\r\n    }\r\n\r\n    newComponentGenerator->setTransportMethods(transportMethods);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentGeneratorReader::Details::parseGroups()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentGeneratorReader::Details::parseGroups(QDomNode const& componentGeneratorNode, \r\n    QSharedPointer<ComponentGenerator> newComponentGenerator)\r\n{\r\n    QDomNodeList groupNodes = componentGeneratorNode.toElement().elementsByTagName(QStringLiteral(\"ipxact:group\"));\r\n\r\n    QStringList groupNames;\r\n    int groupCount = groupNodes.count();\r\n    for (int i = 0; i < groupCount; i++)\r\n    {\r\n        groupNames.append(groupNodes.at(i).firstChild().nodeValue());\r\n    }\r\n\r\n    newComponentGenerator->setGroups(groupNames);\r\n}\r\n"
  },
  {
    "path": "IPXACTmodels/Component/ComponentGeneratorReader.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ComponentGeneratorReader.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Janne Virtanen\r\n// Date: 05.10.2015\r\n//\r\n// Description:\r\n// Reader for IP-XACT ComponentGenerator element.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef ComponentGeneratorReader_H\r\n#define ComponentGeneratorReader_H\r\n\r\n#include \"ComponentGenerator.h\"\r\n\r\n#include <IPXACTmodels/common/CommonItemsReader.h>\r\n#include <IPXACTmodels/common/Document.h>\r\n\r\n#include <QSharedPointer>\r\n#include <QDomNode>\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Reader for IP-XACT ComponentGenerator element.\r\n//-----------------------------------------------------------------------------\r\nnamespace ComponentGeneratorReader\r\n{\r\n\r\n    /*!\r\n     *  Creates a new ComponentGenerator from a given ComponentGenerator node.\r\n     *\r\n     *    @param [in] ComponentGeneratorNode    XML description of the ComponentGenerator.\r\n     *    @param [in] docRevision\t\t\t\t  The IP-XACT standard revision in use.\r\n\r\n     *    @return The component generator described in the XML.\r\n     */\r\n\tIPXACTMODELS_EXPORT QSharedPointer<ComponentGenerator> createComponentGeneratorFrom(\r\n\t\tQDomNode const& componentGeneratorNode, Document::Revision docRevision);\r\n\r\n\tnamespace Details\r\n\t{\r\n\r\n\t\t/*!\r\n\t\t *  Extracts attributes from componentGeneratorNode.\r\n\t\t *\r\n\t\t *    @param [in] componentGeneratorNode\t\t    The XML description of the component generator.\r\n\t\t *    @param [in/out] newComponentGenerator\t\tThe created component generator.\r\n\t\t */\r\n\t\tvoid readAttributes(QDomNode const& componentGeneratorNode,\r\n\t\t\tQSharedPointer<ComponentGenerator> newComponentGenerator);\r\n\r\n\t\t/*!\r\n\t\t *  Extracts parameters from parameters XML description.\r\n\t\t *\r\n\t\t *    @param [in] parametersNode\t\t\t\t    The XML description of the parameters.\r\n         *    @param [in/out] componentGenerator  \t\tThe created component generator.\r\n\t\t *    @param [in] docRevision\t\t\t\t\t\tThe IP-XACT standard revision in use.\r\n\t\t */\r\n\t\tvoid readParameters(QDomNode const& parametersNode,\r\n\t\t\tQSharedPointer<ComponentGenerator> componentGenerator,\r\n\t\t\tDocument::Revision docRevision);\r\n\r\n\t\t/*!\r\n\t\t *  Extracts API type from XML description.\r\n\t\t *\r\n\t\t *    @param [in] apiTypeNode\t\t\t\t\t    The XML description of the API type.\r\n\t\t *    @param [in/out] newComponentGenerator\t\tThe created component generator.\r\n\t\t */\r\n\t\tvoid readApiType(QDomNode const& apiTypeNode, QSharedPointer<ComponentGenerator> newComponentGenerator);\r\n\r\n\t\t/*!\r\n\t\t *\tExtracts API service from XML description.\r\n\t\t *  \r\n         *    @param [in] apiServiceNode\t\t\t\t\tThe XML description of the API service.\r\n         *    @param [in/out] newComponentGenerator\t\tThe created component generator.\r\n\t\t */\r\n\t\tvoid readApiService(QDomNode const& apiServiceNode, QSharedPointer<ComponentGenerator> newComponentGenerator);\r\n\r\n\t\t/*!\r\n\t\t *  Extracts the transport type methods from XML description.\r\n\t\t *\r\n\t\t *    @param [in] tempNode\t\t\t\t\t    The XML description of transport methods.\r\n\t\t *    @param [in/out] newComponentGenerator\t\tThe created component generator.\r\n\t\t */\r\n\t\tvoid readTransportMethods(QDomElement const& methodsNode,\r\n\t\t\tQSharedPointer<ComponentGenerator> newComponentGenerator);\r\n\r\n\t\t/*!\r\n\t\t *  Extracts the generator group names from XML description.\r\n\t\t *\r\n\t\t *    @param [in]     componentGeneratorNode\t\tThe XML description of component generator.\r\n\t\t *    @param [in/out] newComponentGenerator\t\tThe created component generator.\r\n\t\t */\r\n\t\tvoid parseGroups(QDomNode const& componentGeneratorNode,\r\n\t\t\tQSharedPointer<ComponentGenerator> newComponentGenerator);\r\n\t}\r\n};\r\n\r\n#endif // ComponentGeneratorReader_H"
  },
  {
    "path": "IPXACTmodels/Component/ComponentGeneratorWriter.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ComponentGeneratorWriter.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Janne Virtanen\r\n// Date: 05.10.2015\r\n//\r\n// Description:\r\n// Writer for IP-XACT ComponentGenerator element.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"ComponentGeneratorWriter.h\"\r\n\r\n#include <IPXACTmodels/common/NameGroupWriter.h>\r\n#include <IPXACTmodels/common/ParameterWriter.h>\r\n#include <IPXACTmodels/common/CommonItemsWriter.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentGeneratorWriter::writeComponentGenerator()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentGeneratorWriter::writeComponentGenerator(QXmlStreamWriter& writer,\r\n\tQSharedPointer<ComponentGenerator> componentGenerator, Document::Revision docRevision)\r\n{\r\n\twriter.writeStartElement(QStringLiteral(\"ipxact:componentGenerator\"));\r\n\r\n\tDetails::writeAttributes(writer, componentGenerator);\r\n\r\n\t// Write name group.\r\n    NameGroupWriter::writeNameGroup(writer, componentGenerator, docRevision);\r\n\r\n    CommonItemsWriter::writeNonEmptyElement(writer, QStringLiteral(\"ipxact:phase\"), componentGenerator->getPhase());\r\n\r\n    CommonItemsWriter::writeParameters(writer, componentGenerator->getParameters(), docRevision);\r\n\r\n    Details::writeApiType(writer, componentGenerator, docRevision);\r\n\r\n    Details::writeApiService(writer, componentGenerator, docRevision);\r\n\r\n    Details::writeTransportMethods(writer, componentGenerator);\r\n\r\n    CommonItemsWriter::writeNonEmptyElement(writer, QStringLiteral(\"ipxact:generatorExe\"), \r\n        componentGenerator->getGeneratorExe());\r\n\r\n    CommonItemsWriter::writeVendorExtensions(writer, componentGenerator);\r\n\r\n\tfor (auto const& group : componentGenerator->getGroups())\r\n\t{\r\n\t\twriter.writeTextElement(QStringLiteral(\"ipxact:group\"), group);\r\n\t}\r\n\r\n\twriter.writeEndElement();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentGeneratorWriter::Details::writeAttributes()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentGeneratorWriter::Details::writeAttributes(QXmlStreamWriter& writer,\r\n\tQSharedPointer<ComponentGenerator> componentGenerator)\r\n{\r\n    if (auto hiddenValue = componentGenerator->getHidden().toString(); \r\n        !hiddenValue.isEmpty())\r\n    {\r\n        writer.writeAttribute(QStringLiteral(\"hidden\"), hiddenValue);\r\n    }\r\n\r\n\tif (componentGenerator->getScope() == ComponentGenerator::Scope::ENTITY)\r\n\t{\r\n\t\twriter.writeAttribute(QStringLiteral(\"scope\"), QStringLiteral(\"entity\"));\r\n\t}\r\n\telse if (componentGenerator->getScope() == ComponentGenerator::Scope::INSTANCE)\r\n\t{\r\n\t\twriter.writeAttribute(QStringLiteral(\"scope\"), QStringLiteral(\"instance\"));\r\n\t}\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentGeneratorWriter::Details::writeApiType()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentGeneratorWriter::Details::writeApiType(QXmlStreamWriter& writer,\r\n\tQSharedPointer<ComponentGenerator> componentGenerator, Document::Revision docRevision)\r\n{\r\n    if (componentGenerator->getApiType() == ComponentGenerator::ApiType::NONE)\r\n    {\r\n        writer.writeTextElement(QStringLiteral(\"ipxact:apiType\"), QStringLiteral(\"none\"));\r\n    }\r\n    else if (componentGenerator->getApiType() == ComponentGenerator::ApiType::TGI_2014_EXTENDED)\r\n    {\r\n        writer.writeTextElement(QStringLiteral(\"ipxact:apiType\"), QStringLiteral(\"TGI_2014_EXTENDED\"));\r\n    }\r\n    else if (componentGenerator->getApiType() == ComponentGenerator::ApiType::TGI_2009)\r\n    {\r\n        writer.writeTextElement(QStringLiteral(\"ipxact:apiType\"), QStringLiteral(\"TGI_2009\"));\r\n    }\r\n    \r\n    if (docRevision == Document::Revision::Std22)\r\n    {\r\n        if (componentGenerator->getApiType() == ComponentGenerator::ApiType::TBGI_2022_EXTENDED)\r\n        {\r\n            writer.writeTextElement(QStringLiteral(\"ipxact:apiType\"), QStringLiteral(\"TBGI_2022_EXTENDED\"));\r\n        }\r\n        else if (componentGenerator->getApiType() == ComponentGenerator::ApiType::TGI_2022_BASE)\r\n        {\r\n            writer.writeTextElement(QStringLiteral(\"ipxact:apiType\"), QStringLiteral(\"TGI_2022_BASE\"));\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentGeneratorWriter::Details::writeApiService()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentGeneratorWriter::Details::writeApiService(QXmlStreamWriter& writer, \r\n    QSharedPointer<ComponentGenerator> componentGenerator, Document::Revision docRevision)\r\n{\r\n    if (docRevision == Document::Revision::Std22)\r\n    {\r\n        CommonItemsWriter::writeNonEmptyElement(writer, QStringLiteral(\"ipxact:apiService\"),\r\n            componentGenerator->getApiService());\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentGeneratorWriter::Details::writeTransportMethods()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentGeneratorWriter::Details::writeTransportMethods(QXmlStreamWriter& writer,\r\n    QSharedPointer<ComponentGenerator> componentGenerator)\r\n{\r\n    QStringList transportMethods = componentGenerator->getTransportMethods();\r\n    \r\n    if (!transportMethods.isEmpty())\r\n    {\r\n       writer.writeStartElement(QStringLiteral(\"ipxact:transportMethods\"));\r\n       for (auto const& method : transportMethods)\r\n       {\r\n           writer.writeTextElement(QStringLiteral(\"ipxact:transportMethod\"), method);\r\n       }\r\n       writer.writeEndElement();\r\n    }\r\n}\r\n"
  },
  {
    "path": "IPXACTmodels/Component/ComponentGeneratorWriter.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ComponentGeneratorWriter.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Janne Virtanen\r\n// Date: 05.10.2015\r\n//\r\n// Description:\r\n// Writer for IP-XACT ComponentGenerator element.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef ComponentGeneratorWriter_H\r\n#define ComponentGeneratorWriter_H\r\n\r\n#include \"ComponentGenerator.h\"\r\n\r\n#include <IPXACTmodels/ipxactmodels_global.h>\r\n\r\n#include <IPXACTmodels/common/Document.h>\r\n\r\n#include <QXmlStreamWriter>\r\n#include <QSharedPointer>\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Writer for IP-XACT ComponentGenerator element.\r\n//-----------------------------------------------------------------------------\r\nnamespace ComponentGeneratorWriter\r\n{\r\n\r\n    /*!\r\n     *  Write a ComponentGenerator to an XML file.\r\n     *\r\n     *    @param [in] writer                  The used xml writer.\r\n     *    @param [in] ComponentGenerator\t\tThe ComponentGenerator to be written.\r\n     *    @param [in] docRevision\t\t\t\tThe IP-XACT standard revision in use.\r\n     */\r\n\tIPXACTMODELS_EXPORT void writeComponentGenerator(QXmlStreamWriter& writer, \r\n\t\tQSharedPointer<ComponentGenerator> componentGenerator, Document::Revision docRevision);\r\n\r\n\tnamespace Details\r\n\t{\r\n\r\n\t\t/*!\r\n\t\t *  Writes the component generator attributes to XML.\r\n\t\t *\r\n\t\t *    @param [in] writer\t\t\t\t\tThe used xml writer.\r\n\t\t *    @param [in] componentGenerator\t\tThe component generator whose attributes to write.\r\n\t\t */\r\n\t\tvoid writeAttributes(QXmlStreamWriter& writer, QSharedPointer<ComponentGenerator> componentGenerator);\r\n\r\n\t\t/*!\r\n\t\t *  Writes the component generator API type to XML.\r\n\t\t *\r\n\t\t *    @param [in] writer\t\t\t\t\tThe used xml writer.\r\n\t\t *    @param [in] componentGenerator\t\tThe component generator whose API type to write.\r\n\t\t */\r\n\t\tvoid writeApiType(QXmlStreamWriter& writer, QSharedPointer<ComponentGenerator> componentGenerator, Document::Revision docRevision);\r\n\t\t\r\n\t\t/*!\r\n\t\t *\tWrites the component generator API service to XML.\r\n\t\t *  \r\n         *    @param [in] writer\t\t\t\t\tThe used xml writer.\r\n         *    @param [in] componentGenerator\t\tThe component generator whose attributes to write.\r\n\t\t *    @param [in] docRevision\t\t\t\tThe IP-XACT standard revision in use.\r\n\t\t */\r\n\t\tvoid writeApiService(QXmlStreamWriter& writer, QSharedPointer<ComponentGenerator> componentGenerator, Document::Revision docRevision);\r\n\r\n\t\t/*!\r\n\t\t *  Writes the component generator transport methods to XML.\r\n\t\t *\r\n\t\t *    @param [in] writer\t\t\t\t\tThe used xml writer.\r\n\t\t *    @param [in] componentGenerator\t\tThe component generator whose transport mehtods to write.\r\n\t\t */\r\n\t\tvoid writeTransportMethods(QXmlStreamWriter& writer,\r\n\t\t\tQSharedPointer<ComponentGenerator> componentGenerator);\r\n\t}\r\n};\r\n\r\n#endif // ComponentGeneratorWriter_H"
  },
  {
    "path": "IPXACTmodels/Component/ComponentInstantiation.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ComponentInstantiation.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Mikko Teuho\r\n// Date: 08.09.2015\r\n//\r\n// Description:\r\n// Describes the ipxact:componentInstantiation element.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"ComponentInstantiation.h\"\r\n\r\n#include <IPXACTmodels/utilities/Copy.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentInstantiation::ComponentInstantiation()\r\n//-----------------------------------------------------------------------------\r\nComponentInstantiation::ComponentInstantiation(QString const& name /* = QString() */,\r\n    QString const& displayName /* = QString() */, QString const& description /* = QString() */) :\r\nNameGroup(name, displayName, description),\r\nExtendable(),\r\nvirtuality_(false),\r\nlanguage_(),\r\nlanguageStrictness_(false),\r\nlibraryName_(),\r\npackageName_(),\r\nmoduleName_(),\r\narchitectureName_(),\r\nconfigurationName_()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentInstantiation::ComponentInstantiation()\r\n//-----------------------------------------------------------------------------\r\nComponentInstantiation::ComponentInstantiation(const ComponentInstantiation& other) :\r\nNameGroup(other),\r\nExtendable(other),\r\nvirtuality_(other.virtuality_),\r\nlanguage_(other.language_),\r\nlanguageStrictness_(other.languageStrictness_),\r\nlibraryName_(other.libraryName_),\r\npackageName_(other.packageName_),\r\nmoduleName_(other.moduleName_),\r\narchitectureName_(other.architectureName_),\r\nconfigurationName_(other.configurationName_)\r\n{\r\n    Copy::copyList(other.moduleParameters_, moduleParameters_);\r\n    Copy::copyList(other.defaultFileBuilders_, defaultFileBuilders_);\r\n    Copy::copyList(other.fileSetReferences_, fileSetReferences_);\r\n    Copy::copyList(other.parameters_, parameters_);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentInstantiation::operator=()\r\n//-----------------------------------------------------------------------------\r\nComponentInstantiation& ComponentInstantiation::operator=(const ComponentInstantiation& other)\r\n{\r\n    if (this != &other)\r\n    {\r\n        NameGroup::operator=(other);\r\n        Extendable::operator=(other);\r\n        \r\n        virtuality_ = other.virtuality_;\r\n        language_ = other.language_;\r\n        languageStrictness_ = other.languageStrictness_;\r\n        libraryName_ = other.libraryName_;\r\n        packageName_ = other.packageName_;\r\n        moduleName_ = other.moduleName_;\r\n        architectureName_ = other.architectureName_;\r\n        configurationName_ = other.configurationName_;\r\n\r\n        moduleParameters_->clear();\r\n        Copy::copyList(other.moduleParameters_, moduleParameters_);\r\n\r\n        defaultFileBuilders_->clear();\r\n        Copy::copyList(other.defaultFileBuilders_, defaultFileBuilders_);\r\n\r\n        fileSetReferences_->clear();\r\n        Copy::copyList(other.fileSetReferences_, fileSetReferences_);\r\n\r\n        parameters_->clear();\r\n        Copy::copyList(other.parameters_, parameters_);\r\n    }\r\n\r\n    return *this;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentInstantiation::~ComponentInstantiation()\r\n//-----------------------------------------------------------------------------\r\nComponentInstantiation::~ComponentInstantiation()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentInstantiation::isVirtual()\r\n//-----------------------------------------------------------------------------\r\nbool ComponentInstantiation::isVirtual() const\r\n{\r\n    return virtuality_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentInstantiation::setVirtual()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentInstantiation::setVirtual(bool virtualStatus)\r\n{\r\n    virtuality_ = virtualStatus;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentInstantiation::getLanguage()\r\n//-----------------------------------------------------------------------------\r\nQString ComponentInstantiation::getLanguage() const\r\n{\r\n    return language_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentInstantiation::setLanguage()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentInstantiation::setLanguage(QString const& newLanguage)\r\n{\r\n    language_ = newLanguage;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentInstantiation::isLanguageStrict()\r\n//-----------------------------------------------------------------------------\r\nbool ComponentInstantiation::isLanguageStrict() const\r\n{\r\n    return languageStrictness_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentInstantiation::setLanguageStrictness()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentInstantiation::setLanguageStrictness(bool strictness)\r\n{\r\n    languageStrictness_ = strictness;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentInstantiation::getLibraryName()\r\n//-----------------------------------------------------------------------------\r\nQString ComponentInstantiation::getLibraryName() const\r\n{\r\n    return libraryName_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentInstantiation::setLibraryName()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentInstantiation::setLibraryName(QString const& newLibraryName)\r\n{\r\n    libraryName_ = newLibraryName;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentInstantiation::getPackageName()\r\n//-----------------------------------------------------------------------------\r\nQString ComponentInstantiation::getPackageName() const\r\n{\r\n    return packageName_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentInstantiation::setPackageName()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentInstantiation::setPackageName(QString const& newPackageName)\r\n{\r\n    packageName_ = newPackageName;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentInstantiation::getModuleName()\r\n//-----------------------------------------------------------------------------\r\nQString ComponentInstantiation::getModuleName() const\r\n{\r\n    return moduleName_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentInstantiation::setModuleName()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentInstantiation::setModuleName(QString const& newModuleName)\r\n{\r\n    moduleName_ = newModuleName;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentInstantiation::getArchitectureName()\r\n//-----------------------------------------------------------------------------\r\nQString ComponentInstantiation::getArchitectureName() const\r\n{\r\n    return architectureName_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentInstantiation::setArchitectureName()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentInstantiation::setArchitectureName(QString const& newArchitectureName)\r\n{\r\n    architectureName_ = newArchitectureName;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentInstantiation::getConfigurationName()\r\n//-----------------------------------------------------------------------------\r\nQString ComponentInstantiation::getConfigurationName() const\r\n{\r\n    return configurationName_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentInstantiation::setConfigurationName()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentInstantiation::setConfigurationName(QString const& newConfigurationName)\r\n{\r\n    configurationName_ = newConfigurationName;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentInstantiation::getModuleParameters()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<QList<QSharedPointer<ModuleParameter> > > ComponentInstantiation::getModuleParameters() const\r\n{\r\n    return moduleParameters_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentInstantiation::setModuleParameters()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentInstantiation::setModuleParameters(\r\n    QSharedPointer<QList<QSharedPointer<ModuleParameter> > > newModuleParameters)\r\n{\r\n    moduleParameters_->clear();\r\n    moduleParameters_ = newModuleParameters;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentInstantiation::getDefaultFileBuilders()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<QList<QSharedPointer<FileBuilder> > > ComponentInstantiation::getDefaultFileBuilders() const\r\n{\r\n    return defaultFileBuilders_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentInstantiation::setDefaultFileBuilders()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentInstantiation::setDefaultFileBuilders(\r\n    QSharedPointer<QList<QSharedPointer<FileBuilder> > > newDefaultFileBuilders)\r\n{\r\n    defaultFileBuilders_->clear();\r\n    defaultFileBuilders_ = newDefaultFileBuilders;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentInstantiation::getFileSetReferences()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<QList<QSharedPointer<FileSetRef> > > ComponentInstantiation::getFileSetReferences() const\r\n{\r\n    return fileSetReferences_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentInstantiation::getFileSetReferenceStrings()\r\n//-----------------------------------------------------------------------------\r\nQStringList ComponentInstantiation::getFileSetReferenceStrings() const\r\n{\r\n    QStringList referenceStrings;\r\n    std::transform(fileSetReferences_->cbegin(), fileSetReferences_->cend(), std::back_inserter(referenceStrings),\r\n        [](QSharedPointer<FileSetRef> fileSetRef)\r\n        {\r\n            return fileSetRef->getReference();\r\n        });\r\n\r\n    return referenceStrings;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentInstantiation::setFileSetReferences()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentInstantiation::setFileSetReferences(QSharedPointer<QList<QSharedPointer<FileSetRef> > > newFileSetReferences)\r\n{\r\n    fileSetReferences_ = newFileSetReferences;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentInstantiation::getParameters()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<QList<QSharedPointer<Parameter> > > ComponentInstantiation::getParameters() const\r\n{\r\n    return parameters_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentInstantiation::setParameters()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentInstantiation::setParameters(QSharedPointer<QList<QSharedPointer<Parameter> > > newParameters)\r\n{\r\n    parameters_->clear();\r\n    parameters_ = newParameters;\r\n}\r\n"
  },
  {
    "path": "IPXACTmodels/Component/ComponentInstantiation.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ComponentInstantiation.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Mikko Teuho\r\n// Date: 08.09.2015\r\n//\r\n// Description:\r\n// Describes the ipxact:componentInstantiation element.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef COMPONENTINSTANTIATION_H\r\n#define COMPONENTINSTANTIATION_H\r\n\r\n#include \"FileSetRef.h\"\r\n\r\n#include <IPXACTmodels/common/NameGroup.h>\r\n#include <IPXACTmodels/common/Extendable.h>\r\n#include <IPXACTmodels/common/Parameter.h>\r\n#include <IPXACTmodels/common/ModuleParameter.h>\r\n#include <IPXACTmodels/common/FileBuilder.h>\r\n\r\n#include <IPXACTmodels/ipxactmodels_global.h>\r\n\r\n#include <QSharedPointer>\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Describes the ipxact:componentInstantiation element.\r\n//-----------------------------------------------------------------------------\r\nclass IPXACTMODELS_EXPORT ComponentInstantiation : public NameGroup, public Extendable\r\n{\r\n\r\npublic:\r\n\r\n    using List = QSharedPointer<QList<QSharedPointer<ComponentInstantiation> > >;\r\n\r\n    /*!\r\n     *  The constructor.\r\n     *\r\n     *    @param [in] name            Name of the instantiation.\r\n     *    @param [in] displayName     Display name of the instantiation.\r\n     *    @param [in] description     Description of the instantiation.\r\n     */\r\n    ComponentInstantiation(QString const& name = QString(), QString const& displayName = QString(),\r\n        QString const& description = QString());\r\n\r\n    /*!\r\n     *  The copy constructor.\r\n     */\r\n    ComponentInstantiation(const ComponentInstantiation& other);\r\n\r\n    /*!\r\n     *  The assignment operator.\r\n     */\r\n    ComponentInstantiation& operator=(const ComponentInstantiation& other);\r\n\r\n    /*!\r\n     *  The destructor.\r\n     */\r\n    ~ComponentInstantiation();\r\n\r\n    /*!\r\n     *  Check if the instantiation is virtual.\r\n     *\r\n     *    @return True, if the instantiation is virtual, false otherwise.\r\n     */\r\n    bool isVirtual() const;\r\n\r\n    /*!\r\n     *  Set the virtuality status of the instantiation.\r\n     *\r\n     *    @param [in] virtualStatus   The virtuality status of the instantiation.\r\n     */\r\n    void setVirtual(bool virtualStatus);\r\n\r\n    /*!\r\n     *  Get the used HDL.\r\n     *\r\n     *    @return The used HDL.\r\n     */\r\n    QString getLanguage() const;\r\n\r\n    /*!\r\n     *  Set the used HDL.\r\n     *\r\n     *    @param [in] newLanguage     The used HDL.\r\n     */\r\n    void setLanguage(QString const& newLanguage);\r\n   \r\n    /*!\r\n     *  Check if the language is strict.\r\n     *\r\n     *    @return True, if the language is strict, false otherwise.\r\n     */\r\n    bool isLanguageStrict() const;\r\n\r\n    /*!\r\n     *  Set the language strictness.\r\n     *\r\n     *    @param [in] virtualStatus   The language strictness.\r\n     */\r\n    void setLanguageStrictness(bool strictness);\r\n\r\n    /*!\r\n     *  Get the name of the library in which the model should be compiled.\r\n     *\r\n     *    @return The name of the library.\r\n     */\r\n    QString getLibraryName() const;\r\n\r\n    /*!\r\n     *  Set the name of the library in which the model should be compiled.\r\n     *\r\n     *    @param [in] newLanguage     The new name of the library.\r\n     */\r\n    void setLibraryName(QString const& newLibraryName);\r\n\r\n    /*!\r\n     *  Get the name of the VHDL package containing the interface of the model.\r\n     *\r\n     *    @return The name of the VHDL package.\r\n     */\r\n    QString getPackageName() const;\r\n\r\n    /*!\r\n     *  Set the name of the VHDL package containing the interface of the model.\r\n     *\r\n     *    @param [in] newPackageName  The name of the VHDL package.\r\n     */\r\n    void setPackageName(QString const& newPackageName);\r\n\r\n    /*!\r\n     *  Get the module name or the VHDL entity name.\r\n     *\r\n     *    @return The module or VHDL entity name.\r\n     */\r\n    QString getModuleName() const;\r\n\r\n    /*!\r\n     *  Set the module name or the VHDL entity name.\r\n     *\r\n     *    @param [in] newModuleName   The module or VHDL entity name.\r\n     */\r\n    void setModuleName(QString const& newModuleName);\r\n\r\n    /*!\r\n     *  Get the name of the VHDL architecture.\r\n     *\r\n     *    @return The name of the VHDL architecture.\r\n     */\r\n    QString getArchitectureName() const;\r\n\r\n    /*!\r\n     *  Set the name of the VHDL architecture.\r\n     *\r\n     *    @param [in] newArchitectureName     The name of the VHDL architecture.\r\n     */\r\n    void setArchitectureName(QString const& newArchitectureName);\r\n\r\n    /*!\r\n     *  Get the name of configuration.\r\n     *\r\n     *    @return The name of the configuration.\r\n     */\r\n    QString getConfigurationName() const;\r\n\r\n    /*!\r\n     *  Set the name of configuration.\r\n     *\r\n     *    @param [in] newConfigurationName    The name of the configuration.\r\n     */\r\n    void setConfigurationName(QString const& newConfigurationName);\r\n\r\n    /*!\r\n     *  Get the module parameters.\r\n     *\r\n     *    @return Pointer to a list containing module parameters.\r\n     */\r\n    QSharedPointer<QList<QSharedPointer<ModuleParameter> > > getModuleParameters() const;\r\n\r\n    /*!\r\n     *  Set the module parameters.\r\n     *\r\n     *    @param [in] newModuleParameters     The new module parameters.\r\n     */\r\n    void setModuleParameters(QSharedPointer<QList<QSharedPointer<ModuleParameter> > > newModuleParameters);\r\n\r\n    /*!\r\n     *  Get the default file builders.\r\n     *\r\n     *    @return A pointer to a list containing the default file builders.\r\n     */\r\n    QSharedPointer<QList<QSharedPointer<FileBuilder> > > getDefaultFileBuilders() const;\r\n\r\n    /*!\r\n     *  Set the default file builders.\r\n     *\r\n     *    @param [in] newDefaultFileBuilders  The new file builders.\r\n     */\r\n    void setDefaultFileBuilders(QSharedPointer<QList<QSharedPointer<FileBuilder> > > newDefaultFileBuilders);\r\n\r\n    /*!\r\n     *  Get the file set references.\r\n     *\r\n     *    @return Pointer to a list containing referenced file sets.\r\n     */\r\n    QSharedPointer<QList<QSharedPointer<FileSetRef> > > getFileSetReferences() const;\r\n\r\n    /*!\r\n     *\tGet the file set references as a list of strings.\r\n     *  \r\n     * \t    @return The file set references as strings.\r\n     */\r\n    QStringList getFileSetReferenceStrings() const;\r\n\r\n    /*!\r\n     *  Set the file set references.\r\n     *\r\n     *    @param [in] newFileSetReferences    The new file set references.\r\n     */\r\n    void setFileSetReferences(QSharedPointer<QList<QSharedPointer<FileSetRef> > > newFileSetReferences);\r\n\r\n    /*!\r\n     *  Get the parameters.\r\n     *\r\n     *    @return A pointer to a list containing parameters.\r\n     */\r\n    QSharedPointer<QList<QSharedPointer<Parameter> > > getParameters() const;\r\n\r\n    /*!\r\n     *  Set the parameters.\r\n     *\r\n     *    @param [in] newParameters   The new parameters.\r\n     */\r\n    void setParameters(QSharedPointer<QList<QSharedPointer<Parameter> > > newParameters);\r\n\r\nprivate:\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! The virtual status of the instantiation.\r\n    bool virtuality_;\r\n\r\n    //! The used HDL.\r\n    QString language_;\r\n\r\n    //! Determines whether the language shall be strictly enforced or not.\r\n    bool languageStrictness_;\r\n\r\n    //! The name of the library.\r\n    QString libraryName_;\r\n\r\n    //! The name of the VHDL package containing the interface of the model.\r\n    QString packageName_;\r\n\r\n    //! The name of the module or VHDL entity.\r\n    QString moduleName_;\r\n\r\n    //! The name of the VHDL architecture.\r\n    QString architectureName_;\r\n\r\n    //! The configuration.\r\n    QString configurationName_;\r\n\r\n    //! A list of module parameters.\r\n    QSharedPointer<QList<QSharedPointer<ModuleParameter> > > moduleParameters_ =\r\n        QSharedPointer<QList<QSharedPointer<ModuleParameter> > >(new QList<QSharedPointer<ModuleParameter> > ());\r\n\r\n    //! A list of default file builders.\r\n    QSharedPointer<QList<QSharedPointer<FileBuilder> > > defaultFileBuilders_ = \r\n        QSharedPointer<QList<QSharedPointer<FileBuilder> > >(new QList<QSharedPointer<FileBuilder> > ());\r\n\r\n    //! A list of file set references.\r\n    QSharedPointer<QList<QSharedPointer<FileSetRef> > > fileSetReferences_ = \r\n        QSharedPointer<QList<QSharedPointer<FileSetRef> > >(new QList<QSharedPointer<FileSetRef> >());\r\n\r\n    //! A list of instantiation parameters.\r\n    QSharedPointer<QList<QSharedPointer<Parameter> > > parameters_ = \r\n        QSharedPointer<QList<QSharedPointer<Parameter> > >(new QList<QSharedPointer<Parameter> > ());\r\n};\r\n\r\n#endif // DESIGNINSTANTIATION_H"
  },
  {
    "path": "IPXACTmodels/Component/ComponentReader.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ComponentReader.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 14.10.2015\r\n//\r\n// Description:\r\n// Reader class for ipxact:component element.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"ComponentReader.h\"\r\n#include \"Component.h\"\r\n\r\n#include <IPXACTmodels/common/ChoiceReader.h>\r\n#include <IPXACTmodels/common/NameGroupReader.h>\r\n#include <IPXACTmodels/Component/BusInterfaceReader.h>\r\n#include <IPXACTmodels/Component/ChannelReader.h>\r\n#include <IPXACTmodels/Component/RemapStateReader.h>\r\n#include <IPXACTmodels/Component/ModeReader.h>\r\n#include <IPXACTmodels/Component/AddressSpaceReader.h>\r\n#include <IPXACTmodels/Component/MemoryMapReader.h>\r\n#include <IPXACTmodels/Component/ViewReader.h>\r\n#include <IPXACTmodels/Component/InstantiationsReader.h>\r\n#include <IPXACTmodels/Component/PortReader.h>\r\n#include <IPXACTmodels/Component/PowerDomainReader.h>\r\n#include <IPXACTmodels/Component/ComponentGeneratorReader.h>\r\n#include <IPXACTmodels/Component/FileSetReader.h>\r\n#include <IPXACTmodels/Component/CPUReader.h>\r\n#include <IPXACTmodels/Component/OtherClockDriverReader.h>\r\n#include <IPXACTmodels/Component/IndirectInterface.h>\r\n#include <IPXACTmodels/Component/IndirectInterfaceReader.h>\r\n#include <IPXACTmodels/Component/ResetType.h>\r\n\r\n#include <IPXACTmodels/kactusExtensions/ComProperty.h>\r\n#include <IPXACTmodels/kactusExtensions/SystemView.h>\r\n#include <IPXACTmodels/kactusExtensions/ComInterface.h>\r\n#include <IPXACTmodels/kactusExtensions/ApiInterface.h>\r\n#include <IPXACTmodels/kactusExtensions/FileDependency.h>\r\n\r\n#include <IPXACTmodels/Component/Model.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentReader::ComponentReader()\r\n//-----------------------------------------------------------------------------\r\nComponentReader::ComponentReader(): DocumentReader()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentReader::createComponentFrom()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<Component> ComponentReader::createComponentFrom(QDomDocument const& componentDocument) const\r\n{\r\n    QDomNode componentNode = componentDocument.firstChildElement();\r\n\r\n    Document::Revision revision = DocumentReader::getXMLDocumentRevision(componentNode);\r\n\r\n    VLNV vlnv = CommonItemsReader::createVLNVFrom(componentNode, VLNV::COMPONENT);\r\n\r\n    QSharedPointer<Component> newComponent (new Component(vlnv, revision));\r\n\r\n    parseTopComments(componentDocument, newComponent);\r\n\r\n    parseXMLProcessingInstructions(componentDocument, newComponent);\r\n\r\n    parseNamespaceDeclarations(componentNode, newComponent);\r\n    \r\n    if (revision == Document::Revision::Std22)\r\n    {\r\n        parsePowerDomains(componentNode, newComponent);\r\n    }\r\n\r\n    parseBusInterfaces(componentNode, newComponent);\r\n\r\n    parseIndirectInterfaces(componentNode, newComponent);\r\n\r\n    parseChannels(componentNode, newComponent);\r\n\r\n    if (revision == Document::Revision::Std14)\r\n    {\r\n        parseRemapStates(componentNode, newComponent);\r\n    }\r\n    \r\n    if (revision == Document::Revision::Std22)\r\n    {\r\n        parseModes(componentNode, newComponent);\r\n    }\r\n\r\n    parseAddressSpaces(componentNode, newComponent);\r\n\r\n    parseMemoryMaps(componentNode, newComponent);\r\n\r\n    parseModel(componentNode, newComponent);\r\n\r\n    parseComponentGenerators(componentNode, newComponent);\r\n\r\n    parseChoices(componentNode, newComponent);\r\n\r\n    parseFileSets(componentNode, newComponent);\r\n\r\n    parseCPUs(componentNode, newComponent);\r\n\r\n    parseOtherClockDrivers(componentNode, newComponent);\r\n\r\n    parseResetTypes(componentNode, newComponent);\r\n\r\n    parseDescription(componentNode, newComponent);\r\n\r\n    parseParameters(componentNode, newComponent);\r\n\r\n    parseAssertions(componentNode, newComponent);\r\n\r\n    parseComponentExtensions(componentNode, newComponent);\r\n\r\n    return newComponent;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentReader::parsePowerDomains()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentReader::parsePowerDomains(QDomNode const& componentNode, QSharedPointer<Component> newComponent) const\r\n{\r\n    QDomElement powerDomainsElement = componentNode.firstChildElement(QStringLiteral(\"ipxact:powerDomains\"));\r\n\r\n    if (!powerDomainsElement.isNull())\r\n    {\r\n        QDomNodeList domainList = powerDomainsElement.elementsByTagName(QStringLiteral(\"ipxact:powerDomain\"));\r\n        for (int i = 0; i < domainList.count(); ++i)\r\n        {\r\n            QSharedPointer<PowerDomain> newDomain = PowerDomainReader::createFrom(domainList.at(i));\r\n            newComponent->getPowerDomains()->append(newDomain);\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentReader::parseBusInterfaces()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentReader::parseBusInterfaces(QDomNode const& componentNode, QSharedPointer<Component> newComponent)\r\n    const\r\n{\r\n    QDomElement busInterfaceElement = componentNode.firstChildElement(QStringLiteral(\"ipxact:busInterfaces\"));\r\n\r\n    if (!busInterfaceElement.isNull())\r\n    {\r\n        QDomNodeList busInterfaceNodeList = busInterfaceElement.elementsByTagName(QStringLiteral(\"ipxact:busInterface\"));\r\n        for (int interfaceIndex = 0; interfaceIndex < busInterfaceNodeList.count(); ++interfaceIndex)\r\n        {\r\n            QDomNode busNode = busInterfaceNodeList.at(interfaceIndex);\r\n            QSharedPointer<BusInterface> newBus = BusinterfaceReader::createBusinterfaceFrom(busNode,\r\n                newComponent->getRevision());\r\n\r\n            newComponent->getBusInterfaces()->append(newBus);\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentReader::parseIndirectInterfaces()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentReader::parseIndirectInterfaces(QDomNode const& componentNode, QSharedPointer<Component> newComponent) const\r\n{\r\n    QDomElement interfaceElement = componentNode.firstChildElement(QStringLiteral(\"ipxact:indirectInterfaces\"));\r\n\r\n    if (!interfaceElement.isNull())\r\n    {\r\n        QDomNodeList interfaceList = interfaceElement.elementsByTagName(QStringLiteral(\"ipxact:indirectInterface\"));\r\n        for (int i = 0; i < interfaceList.count(); ++i)\r\n        {\r\n            QDomNode interfaceNode = interfaceList.at(i);\r\n            QSharedPointer<IndirectInterface> newInterface = \r\n                IndirectInterfaceReader::createIndirectInterfaceFrom(interfaceNode, newComponent->getRevision());\r\n\r\n            newComponent->getIndirectInterfaces()->append(newInterface);\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentReader::parseChannels()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentReader::parseChannels(QDomNode const& componentNode, QSharedPointer<Component> newComponent) const\r\n{\r\n    QDomElement channelsElement = componentNode.firstChildElement(QStringLiteral(\"ipxact:channels\"));\r\n\r\n    if (!channelsElement.isNull())\r\n    {\r\n        QDomNodeList channelNodeList = channelsElement.elementsByTagName(QStringLiteral(\"ipxact:channel\"));\r\n        for (int channelIndex = 0; channelIndex < channelNodeList.count(); ++channelIndex)\r\n        {\r\n            QDomNode channelNode = channelNodeList.at(channelIndex);\r\n            auto newChannel = ChannelReader::createChannelFrom(channelNode, newComponent->getRevision());\r\n\r\n            newComponent->getChannels()->append(newChannel);\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentReader::parseRemapStates()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentReader::parseRemapStates(QDomNode const& componentNode, QSharedPointer<Component> newComponent) const\r\n{\r\n    QDomElement remapStateElement = componentNode.firstChildElement(QStringLiteral(\"ipxact:remapStates\"));\r\n\r\n    if (!remapStateElement.isNull())\r\n    {\r\n        QDomNodeList remapNodeList = remapStateElement.elementsByTagName(QStringLiteral(\"ipxact:remapState\"));\r\n        for (int remapStateIndex = 0; remapStateIndex < remapNodeList.count(); ++remapStateIndex)\r\n        {\r\n            QDomNode remapStateNode = remapNodeList.at(remapStateIndex);\r\n            QSharedPointer<RemapState> newRemapState = RemapStateReader::createRemapStateFrom(remapStateNode);\r\n\r\n            newComponent->getRemapStates()->append(newRemapState);\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentReader::parseModes()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentReader::parseModes(QDomNode const& componentNode, QSharedPointer<Component> newComponent) const\r\n{\r\n    QDomElement modesElement = componentNode.firstChildElement(QStringLiteral(\"ipxact:modes\"));\r\n\r\n    if (!modesElement.isNull())\r\n    {\r\n        QDomNodeList modeNodeList = modesElement.elementsByTagName(QStringLiteral(\"ipxact:mode\"));\r\n\r\n        const int MODE_COUNT = modeNodeList.count();\r\n        for (int i = 0; i < MODE_COUNT; ++i)\r\n        {\r\n            QDomNode modeNode = modeNodeList.at(i);\r\n            QSharedPointer<Mode> newMode = ModeReader::createModeFrom(modeNode);\r\n\r\n            newComponent->getModes()->append(newMode);\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentReader::parseAddressSpaces()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentReader::parseAddressSpaces(QDomNode const& componentNode, QSharedPointer<Component> newComponent)\r\n    const\r\n{\r\n    QDomElement addressSpacesElement = componentNode.firstChildElement(QStringLiteral(\"ipxact:addressSpaces\"));\r\n\r\n    if (!addressSpacesElement.isNull())\r\n    {\r\n        QDomNodeList addressNodeList = addressSpacesElement.elementsByTagName(QStringLiteral(\"ipxact:addressSpace\"));\r\n        for (int spaceIndex = 0; spaceIndex < addressNodeList.count(); ++spaceIndex)\r\n        {\r\n            QDomNode addressSpaceNode = addressNodeList.at(spaceIndex);\r\n            QSharedPointer<AddressSpace> newAddressSpace = AddressSpaceReader::createAddressSpaceFrom(addressSpaceNode, \r\n                newComponent->getRevision());\r\n\r\n            newComponent->getAddressSpaces()->append(newAddressSpace);\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentReader::parseMemoryMaps()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentReader::parseMemoryMaps(QDomNode const& componentNode, QSharedPointer<Component> newComponent) const\r\n{\r\n    QDomElement memoryMapsElement = componentNode.firstChildElement(QStringLiteral(\"ipxact:memoryMaps\"));\r\n\r\n    if (!memoryMapsElement.isNull())\r\n    {\r\n        QDomNodeList memoryMapNodeList = memoryMapsElement.elementsByTagName(QStringLiteral(\"ipxact:memoryMap\"));\r\n        for (int memoryIndex = 0; memoryIndex < memoryMapNodeList.count(); ++memoryIndex)\r\n        {\r\n            QDomNode memoryMapNode = memoryMapNodeList.at(memoryIndex);\r\n            QSharedPointer<MemoryMap> newMemoryMap = MemoryMapReader::createMemoryMapFrom(memoryMapNode, newComponent->getRevision());\r\n\r\n            newComponent->getMemoryMaps()->append(newMemoryMap);\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentReader::parseModel()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentReader::parseModel(QDomNode const& componentNode, QSharedPointer<Component> newComponent) const\r\n{\r\n    QDomElement modelElement = componentNode.firstChildElement(QStringLiteral(\"ipxact:model\"));\r\n    if (!modelElement.isNull())\r\n    {\r\n        QSharedPointer<Model> newmodel (new Model());\r\n\r\n        parseViews(modelElement, newmodel, newComponent->getRevision());\r\n\r\n        parseInstantiations(modelElement, newmodel, newComponent->getRevision());\r\n\r\n        parsePorts(modelElement, newmodel, newComponent->getRevision());\r\n\r\n        newComponent->setModel(newmodel);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentReader::parseViews()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentReader::parseViews(QDomElement const& modelElement, QSharedPointer<Model> newModel,\r\n    Document::Revision docRevision) const\r\n{\r\n    QDomElement viewsElement = modelElement.firstChildElement(QStringLiteral(\"ipxact:views\"));\r\n\r\n    if (!viewsElement.isNull())\r\n    {\r\n        QDomNodeList viewNodeList = viewsElement.elementsByTagName(QStringLiteral(\"ipxact:view\"));\r\n        for (int viewIndex = 0; viewIndex < viewNodeList.count(); ++viewIndex)\r\n        {\r\n            QDomNode viewNode = viewNodeList.at(viewIndex);\r\n            QSharedPointer<View> newView = ViewReader::createViewFrom(viewNode, docRevision);\r\n\r\n            newModel->getViews()->append(newView);\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentReader::parseInstantiations()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentReader::parseInstantiations(QDomElement const& modelElement, QSharedPointer<Model> newModel,\r\n    Document::Revision docRevision) const\r\n{\r\n    QDomElement instantiationsElement = modelElement.firstChildElement(QStringLiteral(\"ipxact:instantiations\"));\r\n    if (!instantiationsElement.isNull())\r\n    {\r\n        parseComponentInstantiations(instantiationsElement, newModel, docRevision);\r\n\r\n        parseDesignInstantiations(instantiationsElement, newModel);\r\n\r\n        parseDesignConfigurationInstantiations(instantiationsElement, newModel, docRevision);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentReader::parseComponentInstantiations()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentReader::parseComponentInstantiations(QDomElement const& instantiationsElement,\r\n    QSharedPointer<Model> newModel, Document::Revision docRevision) const\r\n{\r\n    QDomNodeList componentInstantiationNodeList =\r\n        instantiationsElement.elementsByTagName(QStringLiteral(\"ipxact:componentInstantiation\"));\r\n    if (!componentInstantiationNodeList.isEmpty())\r\n    {\r\n        for (int i = 0 ; i < componentInstantiationNodeList.count(); ++i)\r\n        {\r\n            QDomNode componentInstantiationNode = componentInstantiationNodeList.at(i);\r\n            QSharedPointer<ComponentInstantiation> newInstantiation =\r\n                InstantiationsReader::createComponentInstantiationFrom(componentInstantiationNode, docRevision);\r\n\r\n            newModel->getComponentInstantiations()->append(newInstantiation);\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentReader::parseDesignInstantiations()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentReader::parseDesignInstantiations(QDomElement const& instantiationsElement,\r\n    QSharedPointer<Model> newModel) const\r\n{\r\n    QDomNodeList designInstantiationNodeList =\r\n        instantiationsElement.elementsByTagName(QStringLiteral(\"ipxact:designInstantiation\"));\r\n    if (!designInstantiationNodeList.isEmpty())\r\n    {\r\n        for (int i = 0 ; i < designInstantiationNodeList.count(); ++i)\r\n        {\r\n            QDomNode designInstantiationNode = designInstantiationNodeList.at(i);\r\n            QSharedPointer<DesignInstantiation> newInstantiation =\r\n                InstantiationsReader::createDesignInstantiationFrom(designInstantiationNode);\r\n\r\n            newModel->getDesignInstantiations()->append(newInstantiation);\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentReader::parseDesignConfigurationInstantiations()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentReader::parseDesignConfigurationInstantiations(QDomElement const& instantiationsElement,\r\n    QSharedPointer<Model> newModel, Document::Revision docRevision) const\r\n{\r\n    QDomNodeList designConfigurationInstantiationNodeList =\r\n        instantiationsElement.elementsByTagName(QStringLiteral(\"ipxact:designConfigurationInstantiation\"));\r\n    if (!designConfigurationInstantiationNodeList.isEmpty())\r\n    {\r\n        for (int i = 0 ; i < designConfigurationInstantiationNodeList.count(); ++i)\r\n        {\r\n            QDomNode designConfigurationInstantiationNode = designConfigurationInstantiationNodeList.at(i);\r\n            QSharedPointer<DesignConfigurationInstantiation> newInstantiation =\r\n                InstantiationsReader::createDesignConfigurationInstantiationFrom(\r\n                    designConfigurationInstantiationNode, docRevision);\r\n\r\n            newModel->getDesignConfigurationInstantiations()->append(newInstantiation);\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentReader::parsePorts()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentReader::parsePorts(QDomElement const& modelElement, QSharedPointer<Model> newModel,\r\n    Document::Revision docRevision) const\r\n{\r\n    QDomElement portsElement = modelElement.firstChildElement(QStringLiteral(\"ipxact:ports\"));\r\n\r\n    if (!portsElement.isNull())\r\n    {\r\n        QDomNodeList portNodeList = portsElement.elementsByTagName(QStringLiteral(\"ipxact:port\"));\r\n        for (int portIndex = 0; portIndex < portNodeList.count(); ++portIndex)\r\n        {\r\n            QDomNode portNode = portNodeList.at(portIndex);\r\n            QSharedPointer<Port> newPort = PortReader::createPortFrom(portNode, docRevision);\r\n\r\n            newModel->getPorts()->append(newPort);\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentReader::parseComponentGenerators()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentReader::parseComponentGenerators(QDomNode const& componentNode,\r\n    QSharedPointer<Component> newComponent) const\r\n{\r\n    QDomElement componentGeneratorsElement = componentNode.firstChildElement(QStringLiteral(\"ipxact:componentGenerators\"));\r\n\r\n    if (!componentGeneratorsElement.isNull())\r\n    {\r\n        QDomNodeList generatorNodeList = componentGeneratorsElement.elementsByTagName(QStringLiteral(\"ipxact:componentGenerator\"));\r\n        for (int generatorIndex = 0; generatorIndex < generatorNodeList.count(); ++generatorIndex)\r\n        {\r\n            QDomNode generatorNode = generatorNodeList.at(generatorIndex);\r\n            QSharedPointer<ComponentGenerator> newComponentGenerator =\r\n                ComponentGeneratorReader::createComponentGeneratorFrom(generatorNode, newComponent->getRevision());\r\n\r\n            newComponent->getComponentGenerators()->append(newComponentGenerator);\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentReader::parseChoices()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentReader::parseChoices(QDomNode const& componentNode, QSharedPointer<Component> newComponent) const\r\n{\r\n    newComponent->setChoices(CommonItemsReader::parseChoices(componentNode));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentReader::parseFileSets()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentReader::parseFileSets(QDomNode const& componentNode, QSharedPointer<Component> newComponent) const\r\n{\r\n    QDomElement fileSetsElement = componentNode.firstChildElement(QStringLiteral(\"ipxact:fileSets\"));\r\n\r\n    if (!fileSetsElement.isNull())\r\n    {\r\n        QDomNodeList fileSetNodeList = fileSetsElement.elementsByTagName(QStringLiteral(\"ipxact:fileSet\"));\r\n        for (int fileSetIndex = 0; fileSetIndex < fileSetNodeList.count(); ++fileSetIndex)\r\n        {\r\n            QDomNode fileSetNode = fileSetNodeList.at(fileSetIndex);\r\n            QSharedPointer<FileSet> newFileSet = FileSetReader::createFileSetFrom(fileSetNode, newComponent->getRevision());\r\n\r\n            newComponent->getFileSets()->append(newFileSet);\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentReader::parseCPUs()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentReader::parseCPUs(QDomNode const& componentNode, QSharedPointer<Component> newComponent) const\r\n{\r\n    QDomElement cpusElement = componentNode.firstChildElement(QStringLiteral(\"ipxact:cpus\"));\r\n\r\n    if (!cpusElement.isNull())\r\n    {\r\n        QDomNodeList cpuNodeList = cpusElement.elementsByTagName(QStringLiteral(\"ipxact:cpu\"));\r\n        for (int cpuIndex = 0; cpuIndex < cpuNodeList.count(); ++cpuIndex)\r\n        {\r\n            QDomNode cpuNode = cpuNodeList.at(cpuIndex);\r\n            QSharedPointer<Cpu> newCPU = CPUReader::createCPUFrom(cpuNode, newComponent->getRevision());\r\n\r\n            newComponent->getCpus()->append(newCPU);\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentReader::parseOtherClockDrivers()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentReader::parseOtherClockDrivers(QDomNode const& componentNode,\r\n    QSharedPointer<Component> newComponent) const\r\n{\r\n    QDomElement otherClocksElement = componentNode.firstChildElement(QStringLiteral(\"ipxact:otherClockDrivers\"));\r\n\r\n    if (!otherClocksElement.isNull())\r\n    {\r\n        OtherClockDriverReader otherClockReader;\r\n\r\n        QDomNodeList clockNodeList = otherClocksElement.elementsByTagName(QStringLiteral(\"ipxact:otherClockDriver\"));\r\n        for (int clockIndex = 0; clockIndex < clockNodeList.count(); ++clockIndex)\r\n        {\r\n            QDomNode clockNode = clockNodeList.at(clockIndex);\r\n            QSharedPointer<OtherClockDriver> newClockDriver =\r\n                otherClockReader.createOtherClockDriverFrom(clockNode);\r\n\r\n            newComponent->getOtherClockDrivers()->append(newClockDriver);\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentReader::parseResetTypes()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentReader::parseResetTypes(QDomNode const& componentNode, QSharedPointer<Component> newComponent) const\r\n{\r\n    QDomElement resetTypesElement = componentNode.firstChildElement(QLatin1String(\"ipxact:resetTypes\"));\r\n\r\n    if (!resetTypesElement.isNull())\r\n    {\r\n        QDomNodeList resetTypeList = resetTypesElement.childNodes();\r\n\r\n        for (int i = 0; i < resetTypeList.size(); ++i)\r\n        {\r\n            QDomNode resetTypeNode = resetTypeList.at(i);\r\n\r\n            QSharedPointer<ResetType> newResetType(new ResetType());\r\n\r\n            NameGroupReader::parseNameGroup(resetTypeNode, newResetType);\r\n\r\n            parseVendorExtensions(resetTypeNode, newResetType);\r\n\r\n            newComponent->getResetTypes()->append(newResetType);\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentReader::parseComponentExtensions()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentReader::parseComponentExtensions(QDomNode const& componentNode,\r\n    QSharedPointer<Component> newComponent) const\r\n{\r\n    QDomNodeList extensionNodeList = componentNode.firstChildElement(QStringLiteral(\"ipxact:vendorExtensions\")).childNodes();\r\n\r\n    for (int extensionIndex = 0; extensionIndex < extensionNodeList.count(); ++extensionIndex)\r\n    {\r\n        QDomNode singleExtensionNode = extensionNodeList.at(extensionIndex);\r\n        if (singleExtensionNode.nodeName() == QLatin1String(\"kactus2:properties\"))\r\n        {\r\n            parseSwProperties(singleExtensionNode, newComponent);\r\n        }\r\n        else if (singleExtensionNode.nodeName() == QLatin1String(\"kactus2:systemViews\"))\r\n        {\r\n            parseSystemViews(singleExtensionNode, newComponent);\r\n        }\r\n        else if (singleExtensionNode.nodeName() == QLatin1String(\"kactus2:comInterfaces\"))\r\n        {\r\n            parseComInterfaces(singleExtensionNode, newComponent);\r\n        }\r\n        else if (singleExtensionNode.nodeName() == QLatin1String(\"kactus2:apiInterfaces\"))\r\n        {\r\n            parseApiInterfaces(singleExtensionNode, newComponent);\r\n        }\r\n        else if (singleExtensionNode.nodeName() == QLatin1String(\"kactus2:sourceDirectories\"))\r\n        {\r\n            parseFilesetSourceDirectories(singleExtensionNode, newComponent);\r\n        }\r\n        else if (singleExtensionNode.nodeName() == QLatin1String(\"kactus2:fileDependencies\"))\r\n        {\r\n            parseFileDependencies(singleExtensionNode, newComponent);\r\n        }\r\n        else if (singleExtensionNode.nodeName() == QLatin1String(\"kactus2:author\"))\r\n        {\r\n            parseAuthor(singleExtensionNode, newComponent);\r\n        }\r\n    }\r\n\r\n    parseKactusAndVendorExtensions(componentNode, newComponent);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentReader::parseSwProperties()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentReader::parseSwProperties(QDomNode const& propertiesNode, QSharedPointer<Component> newComponent)\r\n    const\r\n{\r\n    QList<QSharedPointer<ComProperty> > swProperties;\r\n\r\n    QDomNodeList propertyNodeList = propertiesNode.childNodes();\r\n    for (int propertyIndex = 0; propertyIndex < propertyNodeList.count(); ++propertyIndex)\r\n    {\r\n        QDomElement propertyElement = propertyNodeList.at(propertyIndex).toElement();\r\n\r\n        QString name = propertyElement.attribute(QStringLiteral(\"name\"));\r\n        QString type = propertyElement.attribute(QStringLiteral(\"propertyType\"));\r\n        QString defaultValue = propertyElement.attribute(QStringLiteral(\"defaultValue\"));\r\n        QString description =propertyElement.attribute(QStringLiteral(\"description\"));\r\n        QString requiredString = propertyElement.attribute(QStringLiteral(\"required\"));\r\n        bool required = false;\r\n        if (requiredString == QLatin1String(\"true\"))\r\n        {\r\n            required = true;\r\n        }\r\n\r\n        QSharedPointer<ComProperty> newSWProperty (new ComProperty());\r\n        newSWProperty->setName(name);\r\n        newSWProperty->setType(type);\r\n        newSWProperty->setDefaultValue(defaultValue);\r\n        newSWProperty->setDescription(description);\r\n        newSWProperty->setRequired(required);\r\n\r\n        swProperties.append(newSWProperty);\r\n    }\r\n\r\n    newComponent->setSWProperties(swProperties);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentReader::parseSystemViews()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentReader::parseSystemViews(QDomNode const& viewsNode, QSharedPointer<Component> newComponent) const\r\n{\r\n    QList<QSharedPointer<SystemView> > viewList;\r\n\r\n    QDomNodeList viewNodeList = viewsNode.childNodes();\r\n    for (int viewIndex = 0; viewIndex < viewNodeList.count(); ++viewIndex)\r\n    {\r\n        QDomElement singleSystemElement = viewNodeList.at(viewIndex).toElement();\r\n\r\n        QSharedPointer<SystemView> newSystemView (new SystemView());\r\n\r\n        NameGroupReader::parseNameGroup(singleSystemElement, newSystemView);\r\n\r\n        QDomElement hierarchyElement = singleSystemElement.firstChildElement(QStringLiteral(\"kactus2:hierarchyRef\"));\r\n        if (!hierarchyElement.isNull())\r\n        {\r\n            VLNV hierarhcyReference = parseVLNVAttributes(hierarchyElement, VLNV::DESIGNCONFIGURATION);\r\n            newSystemView->setHierarchyRef(hierarhcyReference);\r\n        }\r\n\r\n        QDomElement hwViewReferenceElement = singleSystemElement.firstChildElement(QStringLiteral(\"kactus2:hwViewRef\"));\r\n        if (!hwViewReferenceElement.isNull())\r\n        {\r\n            QString viewRefernce = hwViewReferenceElement.firstChild().nodeValue();\r\n            newSystemView->setHWViewRef(viewRefernce);\r\n        }\r\n\r\n        QDomNodeList fileSetRefNodeList = singleSystemElement.elementsByTagName(QStringLiteral(\"kactus2:fileSetRef\"));\r\n        QStringList fileSetReferences;\r\n        for (int setIndex = 0; setIndex < fileSetRefNodeList.count(); ++setIndex)\r\n        {\r\n            QString setReference = fileSetRefNodeList.at(setIndex).firstChild().nodeValue();\r\n            fileSetReferences.append(setReference);\r\n        }\r\n        newSystemView->setFileSetRefs(fileSetReferences);\r\n\r\n        viewList.append(newSystemView);\r\n    }\r\n\r\n    newComponent->setSystemViews(viewList);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentReader::parseComInterfaces()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentReader::parseComInterfaces(QDomNode const& interfaceNode, QSharedPointer<Component> newComponent)\r\n    const\r\n{\r\n    QList<QSharedPointer<ComInterface> > interfaceList;\r\n\r\n    QDomNodeList interfaceNodeList = interfaceNode.childNodes();\r\n    for (int interfaceIndex = 0; interfaceIndex < interfaceNodeList.count(); ++interfaceIndex)\r\n    {\r\n        QDomElement interfaceElement = interfaceNodeList.at(interfaceIndex).toElement();\r\n\r\n        QSharedPointer<ComInterface> newComInterface (new ComInterface());\r\n\r\n        NameGroupReader::parseNameGroup(interfaceElement, newComInterface);\r\n\r\n        QDomElement comTypeElement = interfaceElement.firstChildElement(QStringLiteral(\"kactus2:comType\"));\r\n        if (!comTypeElement.isNull())\r\n        {\r\n            VLNV comType = parseVLNVAttributes(comTypeElement, VLNV::DESIGN);\r\n            newComInterface->setComType(comType);\r\n        }\r\n\r\n        QDomElement transferElement = interfaceElement.firstChildElement(QStringLiteral(\"kactus2:transferType\"));\r\n        if (!transferElement.isNull())\r\n        {\r\n            QString transfer = transferElement.firstChild().nodeValue();\r\n            newComInterface->setTransferType(transfer);\r\n        }\r\n\r\n        QDomElement directionElement = interfaceElement.firstChildElement(QStringLiteral(\"kactus2:comDirection\"));\r\n        if (!directionElement.isNull())\r\n        {\r\n            QString directionString = directionElement.firstChild().nodeValue();\r\n            DirectionTypes::Direction direction =\r\n                DirectionTypes::str2Direction(directionString, DirectionTypes::DIRECTION_INVALID);\r\n            newComInterface->setDirection(direction);\r\n        }\r\n\r\n        QDomElement propertiesElement = interfaceElement.firstChildElement(QStringLiteral(\"kactus2:propertyValues\"));\r\n        if (!propertiesElement.isNull())\r\n        {\r\n            QMap<QString, QString> newProperties;\r\n\r\n            QDomNodeList propertiesNodeList = propertiesElement.childNodes();\r\n            for (int i = 0; i < propertiesNodeList.count(); ++i)\r\n            {\r\n                QString name = propertiesNodeList.at(i).toElement().attribute(QStringLiteral(\"name\"));\r\n                QString value = propertiesNodeList.at(i).toElement().attribute(QStringLiteral(\"value\"));\r\n                newProperties.insert(name, value);\r\n            }\r\n\r\n            newComInterface->setPropertyValues(newProperties);\r\n        }\r\n\r\n        QDomElement comImplementationElement = interfaceElement.firstChildElement(QStringLiteral(\"kactus2:comImplementationRef\"));\r\n        if (!comImplementationElement.isNull())\r\n        {\r\n            VLNV comImplementation = parseVLNVAttributes(comImplementationElement, VLNV::DESIGN);\r\n            newComInterface->setComImplementation(comImplementation);\r\n        }\r\n\r\n        QDomElement positionElement = interfaceElement.firstChildElement(QStringLiteral(\"kactus2:position\"));\r\n        if (!positionElement.isNull())\r\n        {\r\n            int positionX = positionElement.attribute(QStringLiteral(\"x\")).toInt();\r\n            int positionY = positionElement.attribute(QStringLiteral(\"y\")).toInt();\r\n            newComInterface->setDefaultPos(QPointF(positionX, positionY));\r\n        }\r\n\r\n        interfaceList.append(newComInterface);\r\n    }\r\n\r\n    newComponent->setComInterfaces(interfaceList);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentReader::parseApiInterfaces()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentReader::parseApiInterfaces(QDomNode const& interfaceNode, QSharedPointer<Component> newComponent)\r\n    const\r\n{\r\n    QList<QSharedPointer<ApiInterface> > interfaceList;\r\n\r\n    QDomNodeList interfaceNodeList = interfaceNode.childNodes();\r\n    for (int interfaceIndex = 0; interfaceIndex < interfaceNodeList.count(); ++interfaceIndex)\r\n    {\r\n        QDomElement interfaceElement = interfaceNodeList.at(interfaceIndex).toElement();\r\n\r\n        QSharedPointer<ApiInterface> newApiInterface (new ApiInterface());\r\n\r\n        NameGroupReader::parseNameGroup(interfaceElement, newApiInterface);\r\n\r\n        QDomElement apiTypeElement = interfaceElement.firstChildElement(QStringLiteral(\"kactus2:apiType\"));\r\n        if (!apiTypeElement.isNull())\r\n        {\r\n            VLNV apiType = parseVLNVAttributes(apiTypeElement, VLNV::DESIGN);\r\n            newApiInterface->setApiType(apiType);\r\n        }\r\n\r\n        QDomElement directionElement = interfaceElement.firstChildElement(QStringLiteral(\"kactus2:dependencyDirection\"));\r\n        if (!directionElement.isNull())\r\n        {\r\n            QString directionString = directionElement.firstChild().nodeValue();\r\n            newApiInterface->setDependencyDirection\r\n                (str2DependencyDirection(directionString, DEPENDENCY_PROVIDER));\r\n        }\r\n\r\n        QDomElement positionElement = interfaceElement.firstChildElement(QStringLiteral(\"kactus2:position\"));\r\n        if (!positionElement.isNull())\r\n        {\r\n            int positionX = positionElement.attribute(QStringLiteral(\"x\")).toInt();\r\n            int positionY = positionElement.attribute(QStringLiteral(\"y\")).toInt();\r\n            newApiInterface->setDefaultPos(QPointF(positionX, positionY));\r\n        }\r\n\r\n        interfaceList.append(newApiInterface);\r\n    }\r\n\r\n    newComponent->setApiInterfaces(interfaceList);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentReader::parseFilesetSourceDirectories()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentReader::parseFilesetSourceDirectories(QDomNode const& singleExtensionNode, \r\n    QSharedPointer<Component> newComponent) const\r\n{\r\n    QStringList sourceDirectories;\r\n\r\n    QDomNodeList dirctoryNodeList = singleExtensionNode.childNodes();\r\n    for (int i = 0; i < dirctoryNodeList.count(); i++)\r\n    {\r\n        sourceDirectories.append(dirctoryNodeList.at(i).firstChild().nodeValue());\r\n    }\r\n\r\n    newComponent->setSourceDirectories(sourceDirectories);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentReader::parseFileDependencies()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentReader::parseFileDependencies(QDomNode const& fileNode, QSharedPointer<Component> newComponent) const\r\n{\r\n    QList<QSharedPointer<FileDependency> > fileDependencies;\r\n\r\n    QDomNodeList dependencyNodeList = fileNode.childNodes();\r\n    for (int dependencyIndex = 0; dependencyIndex < dependencyNodeList.count(); ++dependencyIndex)\r\n    {\r\n        QDomElement dependencyElement = dependencyNodeList.at(dependencyIndex).toElement();\r\n        bool manual = dependencyElement.attribute(QStringLiteral(\"manual\")) == QLatin1String(\"true\");\r\n\r\n        // Parse only manually added dependencies\r\n        if (!manual)\r\n        {\r\n            continue;\r\n        }\r\n\r\n        QString file1 = dependencyElement.firstChildElement(QStringLiteral(\"kactus2:fileRef1\")).firstChild().nodeValue();\r\n        QString file2 = dependencyElement.firstChildElement(QStringLiteral(\"kactus2:fileRef2\")).firstChild().nodeValue();\r\n        QString description = dependencyElement.firstChildElement(QStringLiteral(\"ipxact:description\")).firstChild().nodeValue();\r\n\r\n        bool locked = dependencyElement.attribute(QStringLiteral(\"locked\")) == QLatin1String(\"true\");\r\n        bool biDirectional = dependencyElement.attribute(QStringLiteral(\"bidirectional\")) == QLatin1String(\"true\");\r\n\r\n        QSharedPointer<FileDependency> newDependency (new FileDependency());\r\n        newDependency->setFile1(file1);\r\n        newDependency->setFile2(file2);\r\n        newDependency->setDescription(description);\r\n        newDependency->setLocked(locked);\r\n        newDependency->setBidirectional(biDirectional);\r\n        newDependency->setManual(manual);\r\n\r\n        fileDependencies.append(newDependency);\r\n    }\r\n\r\n    newComponent->setFileDependendencies(fileDependencies);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentReader::parseAuthor()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentReader::parseAuthor(QDomNode const& authorNode, QSharedPointer<Component> newComponent) const\r\n{\r\n    newComponent->setAuthor(authorNode.firstChild().nodeValue());\r\n}\r\n"
  },
  {
    "path": "IPXACTmodels/Component/ComponentReader.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ComponentReader.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 14.10.2015\r\n//\r\n// Description:\r\n// Reader class for ipxact:component element.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef COMPONENTREADER_H\r\n#define COMPONENTREADER_H\r\n\r\n#include <IPXACTmodels/ipxactmodels_global.h>\r\n\r\n#include <IPXACTmodels/common/DocumentReader.h>\r\n\r\n#include <QSharedPointer>\r\n#include <QDomNode>\r\n\r\nclass Component;\r\nclass Model;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Reader class for ipxact:component element.\r\n//-----------------------------------------------------------------------------\r\nclass IPXACTMODELS_EXPORT ComponentReader : public DocumentReader\r\n{\r\npublic:\r\n\r\n    //! The constructor.\r\n    ComponentReader();\r\n\r\n    /*!\r\n     *  The destructor.\r\n     */\r\n    ~ComponentReader() = default;\r\n\r\n    /*!\r\n     *  Creates a new component from a given component document.\r\n     *\r\n     *    @param [in] addressBlockNode    XML description of the component.\r\n     *\r\n     *    @return The created component.\r\n     */\r\n    QSharedPointer<Component> createComponentFrom(QDomDocument const& componentDocument) const;\r\n\r\nprivate:\r\n\r\n    //! No copying allowed.\r\n    ComponentReader(ComponentReader const& rhs);\r\n    ComponentReader& operator=(ComponentReader const& rhs);\r\n\r\n    void parsePowerDomains(QDomNode const& componentNode, QSharedPointer<Component> newComponent) const;\r\n\r\n    /*!\r\n     *  Reads the bus interfaces.\r\n     *\r\n     *    @param [in] componentNode   XML description of the component.\r\n     *    @param [in] newComponent    The new component.\r\n     */\r\n    void parseBusInterfaces(QDomNode const& componentNode, QSharedPointer<Component> newComponent) const;\r\n  \r\n    /*!\r\n     *  Reads the indirect interfaces.\r\n     *\r\n     *    @param [in] componentNode   XML description of the component.\r\n     *    @param [in] newComponent    The new component.\r\n     */\r\n    void parseIndirectInterfaces(QDomNode const& componentNode, QSharedPointer<Component> newComponent) const;\r\n\r\n    /*!\r\n     *  Reads the channels.\r\n     *\r\n     *    @param [in] componentNode   XML description of the component.\r\n     *    @param [in] newComponent    The new component.\r\n     */\r\n    void parseChannels(QDomNode const& componentNode, QSharedPointer<Component> newComponent) const;\r\n\r\n    /*!\r\n     *  Reads the remap states.\r\n     *\r\n     *    @param [in] componentNode   XML description of the component.\r\n     *    @param [in] newComponent    The new component.\r\n     */\r\n    void parseRemapStates(QDomNode const& componentNode, QSharedPointer<Component> newComponent) const;\r\n\r\n    void parseModes(QDomNode const& componentNode, QSharedPointer<Component> newComponent) const;\r\n\r\n    /*!\r\n     *  Reads the address spaces.\r\n     *\r\n     *    @param [in] componentNode   XML description of the component.\r\n     *    @param [in] newComponent    The new component.\r\n     */\r\n    void parseAddressSpaces(QDomNode const& componentNode, QSharedPointer<Component> newComponent) const;\r\n\r\n    /*!\r\n     *  Reads the memory maps.\r\n     *\r\n     *    @param [in] componentNode   XML description of the component.\r\n     *    @param [in] newComponent    The new component.\r\n     */\r\n    void parseMemoryMaps(QDomNode const& componentNode, QSharedPointer<Component> newComponent) const;\r\n\r\n    /*!\r\n     *  Reads the model.\r\n     *\r\n     *    @param [in] componentNode   XML description of the component.\r\n     *    @param [in] newComponent    The new component.\r\n     */\r\n    void parseModel(QDomNode const& componentNode, QSharedPointer<Component> newComponent) const;\r\n\r\n    /*!\r\n     *  Reads the views.\r\n     *\r\n     *    @param [in] modelElement    XML description of the model.\r\n     *    @param [in] newModel        The new model item.\r\n     *    @param [in] docRevision     The IP-XACT standard revision to comply to.\r\n     */\r\n    void parseViews(QDomElement const& modelElement, QSharedPointer<Model> newModel,\r\n        Document::Revision docRevision) const;\r\n\r\n    /*!\r\n     *  Reads the instantiations.\r\n     *\r\n     *    @param [in] modelElement    XML description of the model.\r\n     *    @param [in] newModel        The new model item.\r\n     */\r\n    void parseInstantiations(QDomElement const& modelElement, QSharedPointer<Model> newModel,\r\n        Document::Revision docRevision) const;\r\n\r\n    /*!\r\n     *  Reads the component instantiations.\r\n     *\r\n     *    @param [in] instantiationsElement   XML description of the instantiations element.\r\n     *    @param [in] newModel                The new model item.\r\n     *    @param [in] docRevision             The IP-XACT standard revision to comply to.\r\n     */\r\n    void parseComponentInstantiations(QDomElement const& instantiationsElement, QSharedPointer<Model> newModel,\r\n        Document::Revision docRevision) const;\r\n\r\n    /*!\r\n     *  Reads the design instantiations.\r\n     *\r\n     *    @param [in] instantiationsElement   XML description of the instantiations element.\r\n     *    @param [in] newModel                The new model item.\r\n     */\r\n    void parseDesignInstantiations(QDomElement const& instantiationsElement, QSharedPointer<Model> newModel) const;\r\n\r\n    /*!\r\n     *  Reads the design configuration instantiations.\r\n     *\r\n     *    @param [in] instantiationsElement   XML description of the instantiations element.\r\n     *    @param [in] newModel                The new model item.\r\n     *    @param [in] docRevision             The IP-XACT standard revision to comply to.\r\n     */\r\n    void parseDesignConfigurationInstantiations(QDomElement const& instantiationsElement,\r\n        QSharedPointer<Model> newModel, Document::Revision docRevision) const;\r\n\r\n    /*!\r\n     *  Reads the ports.\r\n     *\r\n     *    @param [in] modelElement    XML description of the model.\r\n     *    @param [in] newModel        The new model item.\r\n     */\r\n    void parsePorts(QDomElement const& modelElement, QSharedPointer<Model> newModel, Document::Revision docRevisio) const;\r\n\r\n    /*!\r\n     *  Reads the component generators.\r\n     *\r\n     *    @param [in] componentNode   XML description of the component.\r\n     *    @param [in] newComponent    The new component.\r\n     */\r\n    void parseComponentGenerators(QDomNode const& componentNode, QSharedPointer<Component> newComponent) const;\r\n\r\n    /*!\r\n     *  Reads the choices.\r\n     *\r\n     *    @param [in] componentNode   XML description of the component.\r\n     *    @param [in] newComponent    The new component.\r\n     */\r\n    void parseChoices(QDomNode const& componentNode, QSharedPointer<Component> newComponent) const;\r\n\r\n    /*!\r\n     *  Reads the file sets.\r\n     *\r\n     *    @param [in] componentNode   XML description of the component.\r\n     *    @param [in] newComponent    The new component.\r\n     */\r\n    void parseFileSets(QDomNode const& componentNode, QSharedPointer<Component> newComponent) const;\r\n\r\n    /*!\r\n     *  Reads the cpus.\r\n     *\r\n     *    @param [in] componentNode   XML description of the component.\r\n     *    @param [in] newComponent    The new component.\r\n     */\r\n    void parseCPUs(QDomNode const& componentNode, QSharedPointer<Component> newComponent) const;\r\n\r\n    /*!\r\n     *  Reads the other clock drivers.\r\n     *\r\n     *    @param [in] componentNode   XML description of the component.\r\n     *    @param [in] newComponent    The new component.\r\n     */\r\n    void parseOtherClockDrivers(QDomNode const& componentNode, QSharedPointer<Component> newComponent) const;\r\n\r\n    /*!\r\n     *  Reads the reset types.\r\n     *\r\n     *    @param [in] componentNode   XML description of the component.\r\n     *    @param [in] newComponent    The new component.\r\n     */\r\n    void parseResetTypes(QDomNode const& componentNode, QSharedPointer<Component> newComponent) const;\r\n\r\n    /*!\r\n     *  Reads the component extensions.\r\n     *\r\n     *    @param [in] componentNode   XML description of the component.\r\n     *    @param [in] newComponent    The new component.\r\n     */\r\n    void parseComponentExtensions(QDomNode const& componentNode, QSharedPointer<Component> newComponent) const;\r\n\r\n    /*!\r\n     *  Reads the swView extensions.\r\n     *\r\n     *    @param [in] swViewsNode     XML description of the sw views.\r\n     *    @param [in] newComponent    The new component.\r\n     */\r\n    void parseSwViews(QDomNode const& swViewsNode, QSharedPointer<Component> newComponent) const;\r\n\r\n    /*!\r\n     *  Reads the sw property extensions.\r\n     *\r\n     *    @param [in] propertiesNode  XML description of the sw properties.\r\n     *    @param [in] newComponent    The new component.\r\n     */\r\n    void parseSwProperties(QDomNode const& propertiesNode, QSharedPointer<Component> newComponent) const;\r\n\r\n    /*!\r\n     *  Reads the system view extensions.\r\n     *\r\n     *    @param [in] viewsNode       XML description of the system views.\r\n     *    @param [in] newComponent    The new component.\r\n     */\r\n    void parseSystemViews(QDomNode const& viewsNode, QSharedPointer<Component> newComponent) const;\r\n\r\n    /*!\r\n     *  Reads the com interface extensions.\r\n     *\r\n     *    @param [in] interfaceNode   XML description of the com interfaces.\r\n     *    @param [in] newComponent    The new component.\r\n     */\r\n    void parseComInterfaces(QDomNode const& interfaceNode, QSharedPointer<Component> newComponent) const;\r\n\r\n    /*!\r\n     *  Reads the api interface extensions.\r\n     *\r\n     *    @param [in] interfaceNode   XML description of the api interfaces.\r\n     *    @param [in] newComponent    The new component.\r\n     */\r\n    void parseApiInterfaces(QDomNode const& interfaceNode, QSharedPointer<Component> newComponent) const;\r\n\r\n    /*!\r\n     *  Reades the source directories for file sets.\r\n     *\r\n     *    @param [in] singleExtensionNode     XML description of the file source directories.\r\n     *    @param [in] newComponent            The new component.\r\n     */\r\n    void parseFilesetSourceDirectories(QDomNode const& singleExtensionNode, \r\n        QSharedPointer<Component> newComponent) const;\r\n\r\n    /*!\r\n     *  Reads the file dependency extensions.\r\n     *\r\n     *    @param [in] fileNode        XML description of the file dependencies.\r\n     *    @param [in] newComponent    The new component.\r\n     */\r\n    void parseFileDependencies(QDomNode const& fileNode, QSharedPointer<Component> newComponent) const;\r\n\r\n    /*!\r\n     *  Reads the author vendor extension.\r\n     *\r\n     *    @param [in] authorNode      XML description of the author.\r\n     *    @param [in] newComponent    The new component.\r\n     */\r\n    void parseAuthor(QDomNode const& authorNode, QSharedPointer<Component> newComponent) const;\r\n};\r\n\r\n#endif // COMPONENTREADER_H"
  },
  {
    "path": "IPXACTmodels/Component/ComponentWriter.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ComponentWriter.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 12.10.2015\r\n//\r\n// Description:\r\n// Writer class for ipxact:component element.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"ComponentWriter.h\"\r\n#include \"Component.h\"\r\n#include \"Model.h\"\r\n\r\n#include \"BusInterfaceWriter.h\"\r\n#include \"IndirectInterfaceWriter.h\"\r\n#include \"ChannelWriter.h\"\r\n#include \"RemapStateWriter.h\"\r\n#include \"ModeWriter.h\"\r\n#include \"AddressSpaceWriter.h\"\r\n#include \"MemoryMapWriter.h\"\r\n#include \"ViewWriter.h\"\r\n#include \"InstantiationsWriter.h\"\r\n#include \"PortWriter.h\"\r\n#include \"PowerDomainWriter.h\"\r\n#include \"ComponentGeneratorWriter.h\"\r\n#include \"FileSetWriter.h\"\r\n#include \"CPUWriter.h\"\r\n#include \"OtherClockDriverWriter.h\"\r\n#include \"ResetType.h\"\r\n\r\n#include <IPXACTmodels/common/NameGroupWriter.h>\r\n#include <IPXACTmodels/common/ChoiceWriter.h>\r\n#include <IPXACTmodels/kactusExtensions/FileDependency.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentWriter::ComponentWriter()\r\n//-----------------------------------------------------------------------------\r\nComponentWriter::ComponentWriter() : DocumentWriter()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentWriter::writeComponent()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentWriter::writeComponent(QXmlStreamWriter& writer, QSharedPointer<Component> component) const\r\n{\r\n    writer.writeStartDocument();\r\n\r\n    writeTopComments(writer, component);\r\n\r\n    writeXmlProcessingInstructions(writer, component);\r\n\r\n    writer.writeStartElement(QStringLiteral(\"ipxact:component\"));\r\n\r\n    writeNamespaceDeclarations(writer, component);\r\n\r\n    writeVLNVElements(writer, component->getVlnv());\r\n\r\n    writePowerDomains(writer, component);\r\n\r\n    writeBusInterfaces(writer, component);\r\n\r\n    writeIndirectInterfaces(writer, component);\r\n\r\n    writeChannels(writer, component);\r\n\r\n    writeRemapStates(writer, component);\r\n\r\n    writeModes(writer, component);\r\n\r\n    writeAddressSpaces(writer, component);\r\n\r\n    writeMemoryMaps(writer, component);\r\n\r\n    writeModel(writer, component);\r\n    \r\n    writeComponentGenerators(writer, component);\r\n\r\n    writeChoices(writer, component);\r\n\r\n    writeFileSets(writer, component);\r\n\r\n    writeCPUs(writer, component);\r\n\r\n    writeOtherClockDrivers(writer, component);\r\n\r\n    writeResetTypes(writer, component);\r\n\r\n    writeDescription(writer, component->getDescription());\r\n\r\n    writeParameters(writer, component);\r\n\r\n    writeAssertions(writer, component);\r\n\r\n    writeComponentExtensions(writer, component);\r\n\r\n    writer.writeEndElement(); // ipxact:component\r\n\r\n    writer.writeEndDocument();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentWriter::writePowerDomains()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentWriter::writePowerDomains(QXmlStreamWriter& writer, QSharedPointer<Component> component) const\r\n{\r\n    if (component->getRevision() != Document::Revision::Std22 || component->getPowerDomains()->isEmpty())\r\n    {\r\n        return;\r\n    }\r\n\r\n    writer.writeStartElement(QStringLiteral(\"ipxact:powerDomains\"));\r\n\r\n    for (QSharedPointer<PowerDomain> domain : *component->getPowerDomains())\r\n    {\r\n        PowerDomainWriter::write(writer, domain);\r\n    }\r\n\r\n    writer.writeEndElement(); // ipxact:powerDomains\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentWriter::writeBusInterfaces()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentWriter::writeBusInterfaces(QXmlStreamWriter& writer, QSharedPointer<Component> component) const\r\n{\r\n    if (!component->getBusInterfaces()->isEmpty())\r\n    {\r\n        writer.writeStartElement(QStringLiteral(\"ipxact:busInterfaces\"));\r\n\r\n        for (QSharedPointer<BusInterface> busInterface : *component->getBusInterfaces())\r\n        {\r\n            BusInterfaceWriter::writeBusInterface(writer, busInterface, component->getRevision());\r\n        }\r\n\r\n        writer.writeEndElement(); // ipxact:busInterfaces\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentWriter::writeIndirectInterfaces()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentWriter::writeIndirectInterfaces(QXmlStreamWriter& writer, QSharedPointer<Component> component) const\r\n{\r\n    if (!component->getIndirectInterfaces()->isEmpty())\r\n    {\r\n        writer.writeStartElement(QStringLiteral(\"ipxact:indirectInterfaces\"));\r\n\r\n        for (QSharedPointer<IndirectInterface> indirectInterface : *component->getIndirectInterfaces())\r\n        {\r\n            IndirectInterfaceWriter::writeIndirectInterface(writer, indirectInterface, component->getRevision());\r\n        }\r\n\r\n        writer.writeEndElement(); // ipxact:indirectInterfaces\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentWriter::writeChannels()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentWriter::writeChannels(QXmlStreamWriter& writer, QSharedPointer<Component> component) const\r\n{\r\n    if (!component->getChannels()->isEmpty())\r\n    {\r\n        writer.writeStartElement(QStringLiteral(\"ipxact:channels\"));\r\n\r\n        for (QSharedPointer<Channel> channel: *component->getChannels())\r\n        {\r\n            ChannelWriter::writeChannel(writer, channel, component->getRevision());\r\n        }\r\n\r\n        writer.writeEndElement(); // ipxact:channels\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentWriter::writeRemapStates()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentWriter::writeRemapStates(QXmlStreamWriter& writer, QSharedPointer<Component> component) const\r\n{\r\n    if (component->getRevision() == Document::Revision::Std14 && !component->getRemapStates()->isEmpty())\r\n    {\r\n        writer.writeStartElement(QStringLiteral(\"ipxact:remapStates\"));\r\n\r\n        for (QSharedPointer<RemapState> remapState : *component->getRemapStates())\r\n        {\r\n            RemapStateWriter::writeRemapState(writer, remapState);\r\n        }\r\n\r\n        writer.writeEndElement(); // ipxact:remapStates\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentWriter::writeModes()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentWriter::writeModes(QXmlStreamWriter& writer, QSharedPointer<Component> component) const\r\n{\r\n    if (component->getRevision() == Document::Revision::Std22 && component->getModes()->isEmpty() == false)\r\n    {\r\n        writer.writeStartElement(QStringLiteral(\"ipxact:modes\"));\r\n\r\n        for (auto const& mode : *component->getModes())\r\n        {\r\n            ModeWriter::writeMode(writer, mode);\r\n        }\r\n\r\n        writer.writeEndElement(); // ipxact:modes\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentWriter::writeAddressSpaces()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentWriter::writeAddressSpaces(QXmlStreamWriter& writer, QSharedPointer<Component> component) const\r\n{\r\n    if (!component->getAddressSpaces()->isEmpty())\r\n    {\r\n        writer.writeStartElement(QStringLiteral(\"ipxact:addressSpaces\"));\r\n\r\n        for (QSharedPointer<AddressSpace> addressSpace : *component->getAddressSpaces())\r\n        {\r\n            AddressSpaceWriter::writeAddressSpace(writer, addressSpace, component->getRevision());\r\n        }\r\n\r\n        writer.writeEndElement(); // ipxact:addressSpaces\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentWriter::writeMemoryMaps()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentWriter::writeMemoryMaps(QXmlStreamWriter& writer, QSharedPointer<Component> component) const\r\n{\r\n    if (!component->getMemoryMaps()->isEmpty())\r\n    {\r\n        writer.writeStartElement(QStringLiteral(\"ipxact:memoryMaps\"));\r\n\r\n        for (auto const& memoryMap : *component->getMemoryMaps())\r\n        {\r\n            MemoryMapWriter::writeMemoryMap(writer, memoryMap, component->getRevision());\r\n        }\r\n\r\n        writer.writeEndElement(); // ipxact:memoryMaps\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentWriter::writeModel()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentWriter::writeModel(QXmlStreamWriter& writer, QSharedPointer<Component> component) const\r\n{\r\n    if (component->getModel()->hasContents())\r\n    {\r\n        writer.writeStartElement(QStringLiteral(\"ipxact:model\"));\r\n\r\n        writeViews(writer, component);\r\n\r\n        writeInstantiations(writer, component);\r\n\r\n        writePorts(writer, component);\r\n\r\n        writer.writeEndElement(); // ipxact:model\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentWriter::writeViews()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentWriter::writeViews(QXmlStreamWriter& writer, QSharedPointer<Component> component) const\r\n{\r\n    if (!component->getViews()->isEmpty())\r\n    {\r\n        writer.writeStartElement(QStringLiteral(\"ipxact:views\"));\r\n\r\n        for (auto const& view : *component->getViews())\r\n        {\r\n            ViewWriter::writeView(writer, view, component->getRevision());\r\n        }\r\n\r\n        writer.writeEndElement(); // ipxact:views\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentWriter::writeInstantiations()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentWriter::writeInstantiations(QXmlStreamWriter& writer, QSharedPointer<Component> component) const\r\n{\r\n    if (!component->getComponentInstantiations()->isEmpty() || !component->getDesignInstantiations()->isEmpty() ||\r\n        !component->getDesignConfigurationInstantiations()->isEmpty())\r\n    {\r\n        writer.writeStartElement(QStringLiteral(\"ipxact:instantiations\"));\r\n\r\n        for (QSharedPointer<ComponentInstantiation> instantiation : *component->getComponentInstantiations())\r\n        {\r\n            InstantiationsWriter::writeComponentInstantiation(writer, instantiation, component->getRevision());\r\n        }\r\n        for (QSharedPointer<DesignInstantiation> instantiation : *component->getDesignInstantiations())\r\n        {\r\n            InstantiationsWriter::writeDesignInstantiation(writer, instantiation, component->getRevision());\r\n        }\r\n        for (QSharedPointer<DesignConfigurationInstantiation> instantiation :\r\n            *component->getDesignConfigurationInstantiations())\r\n        {\r\n            InstantiationsWriter::writeDesignConfigurationInstantiation(writer, instantiation,\r\n                component->getRevision());\r\n        }\r\n\r\n        writer.writeEndElement(); // ipxact:instantiations\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentWriter::writePorts()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentWriter::writePorts(QXmlStreamWriter& writer, QSharedPointer<Component> component) const\r\n{\r\n    if (!component->getPorts()->isEmpty())\r\n    {\r\n        PortWriter portWriter;\r\n\r\n        writer.writeStartElement(QStringLiteral(\"ipxact:ports\"));\r\n\r\n        const auto revision = component->getRevision();\r\n        for (QSharedPointer<Port> port : *component->getPorts())\r\n        {\r\n            portWriter.writePort(writer, port, revision);\r\n        }\r\n\r\n        writer.writeEndElement(); // ipxact:ports\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentWriter::writeComponentGenerators()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentWriter::writeComponentGenerators(QXmlStreamWriter& writer, QSharedPointer<Component> component) const\r\n{\r\n    if (!component->getComponentGenerators()->isEmpty())\r\n    {\r\n        writer.writeStartElement(QStringLiteral(\"ipxact:componentGenerators\"));\r\n\r\n        for (auto const& generator : *component->getComponentGenerators())\r\n        {\r\n            ComponentGeneratorWriter::writeComponentGenerator(writer, generator, component->getRevision());\r\n        }\r\n\r\n        writer.writeEndElement(); // ipxact:componentGenerators\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentWriter::writeChoices()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentWriter::writeChoices(QXmlStreamWriter& writer, QSharedPointer<Component> component) const\r\n{\r\n    if (!component->getChoices()->isEmpty())\r\n    {\r\n        writer.writeStartElement(QStringLiteral(\"ipxact:choices\"));\r\n\r\n        for (QSharedPointer<Choice> choice : *component->getChoices())\r\n        {\r\n            ChoiceWriter::writeChoice(writer, choice);\r\n        }\r\n\r\n        writer.writeEndElement(); // ipxact:choices\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentWriter::writeFileSets()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentWriter::writeFileSets(QXmlStreamWriter& writer, QSharedPointer<Component> component) const\r\n{\r\n    if (!component->getFileSets()->isEmpty())\r\n    {\r\n        writer.writeStartElement(QStringLiteral(\"ipxact:fileSets\"));\r\n\r\n        for (QSharedPointer<FileSet> fileSet : *component->getFileSets())\r\n        {\r\n            FileSetWriter::writeFileSet(writer, fileSet, component->getRevision());\r\n        }\r\n\r\n        writer.writeEndElement(); // ipxact:fileSets\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentWriter::writeCPUs()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentWriter::writeCPUs(QXmlStreamWriter& writer, QSharedPointer<Component> component) const\r\n{\r\n    if (!component->getCpus()->isEmpty())\r\n    {\r\n        writer.writeStartElement(QStringLiteral(\"ipxact:cpus\"));\r\n\r\n        for (QSharedPointer<Cpu> cpu : *component->getCpus())\r\n        {\r\n            CPUWriter::writeCPU(writer, cpu, component->getRevision());\r\n        }\r\n\r\n        writer.writeEndElement(); // ipxact:cpus\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentWriter::writeOtherClockDrivers()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentWriter::writeOtherClockDrivers(QXmlStreamWriter& writer, QSharedPointer<Component> component) const\r\n{\r\n    if (!component->getOtherClockDrivers()->isEmpty())\r\n    {\r\n        OtherClockDriverWriter clockWriter;\r\n\r\n        writer.writeStartElement(QStringLiteral(\"ipxact:otherClockDrivers\"));\r\n\r\n        for (QSharedPointer<OtherClockDriver> driver : *component->getOtherClockDrivers())\r\n        {\r\n            clockWriter.writeOtherClockDriver(writer, driver);\r\n        }\r\n\r\n        writer.writeEndElement(); // ipxact:otherClockDrivers\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentWriter::writeResetTypes()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentWriter::writeResetTypes(QXmlStreamWriter& writer, QSharedPointer<Component> component) const\r\n{\r\n    if (component->getResetTypes() && !component->getResetTypes()->isEmpty())\r\n    {\r\n        writer.writeStartElement(QStringLiteral(\"ipxact:resetTypes\"));\r\n\r\n        for (QSharedPointer<ResetType> resetType : *component->getResetTypes())\r\n        {\r\n            writer.writeStartElement(QStringLiteral(\"ipxact:resetType\"));\r\n\r\n            NameGroupWriter::writeNameGroup(writer, resetType, component->getRevision());\r\n            writeVendorExtensions(writer, resetType);\r\n\r\n            writer.writeEndElement(); // ipxact:resetType\r\n        }\r\n\r\n        writer.writeEndElement(); // ipxact:resetTypes\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentWriter::writeComponentExtensions()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentWriter::writeComponentExtensions(QXmlStreamWriter& writer, QSharedPointer<Component> component) const\r\n{\r\n    if (!component->getPendingFileDependencies().isEmpty())\r\n    {\r\n        component->setFileDependendencies(component->getPendingFileDependencies());\r\n    }\r\n\r\n    // Write only manual dependencies\r\n    QList<QSharedPointer<FileDependency> > dependenciesToAdd;\r\n    for (auto const& dependency : component->getFileDependencies())\r\n    {\r\n        if (dependency->isManual())\r\n        {\r\n            dependenciesToAdd.append(dependency);\r\n        }\r\n    }\r\n\r\n    component->setFileDependendencies(dependenciesToAdd);\r\n    writeVendorExtensions(writer, component);\r\n}\r\n\r\n"
  },
  {
    "path": "IPXACTmodels/Component/ComponentWriter.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ComponentWriter.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 12.10.2015\r\n//\r\n// Description:\r\n// Writer class for ipxact:component element.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef COMPONENTWRITER_H\r\n#define COMPONENTWRITER_H\r\n\r\n#include <IPXACTmodels/ipxactmodels_global.h>\r\n#include <IPXACTmodels/common/DocumentWriter.h>\r\n\r\n#include <QXmlStreamWriter>\r\n#include <QSharedPointer>\r\n\r\nclass Component;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Writer class for ipxact:component element.\r\n//-----------------------------------------------------------------------------\r\nclass IPXACTMODELS_EXPORT ComponentWriter : public DocumentWriter\r\n{\r\npublic:\r\n\r\n    /*!\r\n     *  The constructor.\r\n     */\r\n    ComponentWriter();\r\n\r\n    /*!\r\n     *  The destructor.\r\n     */\r\n    ~ComponentWriter() = default;\r\n\r\n    /*!\r\n     *  Write a component to an XML file.\r\n     *\r\n     *    @param [in] writer      The used XML writer.\r\n     *    @param [in] component   The component to be written.\r\n     */\r\n    void writeComponent(QXmlStreamWriter& writer, QSharedPointer<Component> component) const;\r\n\r\nprivate:\r\n\r\n    //! No copying allowed.\r\n    ComponentWriter(ComponentWriter const& rhs);\r\n    ComponentWriter& operator=(ComponentWriter const& rhs);\r\n\r\n    /*!\r\n     *  Write the bus interfaces.\r\n     *\r\n     *    @param [in] writer      The used XML writer.\r\n     *    @param [in] component   The component being written.\r\n     */\r\n    void writeBusInterfaces(QXmlStreamWriter& writer, QSharedPointer<Component> component) const;\r\n\r\n    /*!\r\n     *  Write the indirect interfaces.\r\n     *\r\n     *    @param [in] writer      The used XML writer.\r\n     *    @param [in] component   The component being written.\r\n     */\r\n    void writeIndirectInterfaces(QXmlStreamWriter& writer, QSharedPointer<Component> component) const;\r\n\r\n    /*!\r\n     *  Write the channels.\r\n     *\r\n     *    @param [in] writer      The used XML writer.\r\n     *    @param [in] component   The component being written.\r\n     */\r\n    void writeChannels(QXmlStreamWriter& writer, QSharedPointer<Component> component) const;\r\n\r\n    /*!\r\n     *  Write the remap states.\r\n     *\r\n     *    @param [in] writer      The used XML writer.\r\n     *    @param [in] component   The component being written.\r\n     */\r\n    void writeRemapStates(QXmlStreamWriter& writer, QSharedPointer<Component> component) const;\r\n\r\n    void writeModes(QXmlStreamWriter& writer, QSharedPointer<Component> component) const;\r\n\r\n    /*!\r\n     *  Write the address spaces.\r\n     *\r\n     *    @param [in] writer      The used XML writer.\r\n     *    @param [in] component   The component being written.\r\n     */\r\n    void writeAddressSpaces(QXmlStreamWriter& writer, QSharedPointer<Component> component) const;\r\n\r\n    /*!\r\n     *  Write the memory maps.\r\n     *\r\n     *    @param [in] writer      The used XML writer.\r\n     *    @param [in] component   The component being written.\r\n     */\r\n    void writeMemoryMaps(QXmlStreamWriter& writer, QSharedPointer<Component> component) const;\r\n\r\n    /*!\r\n     *  Write the model.\r\n     *\r\n     *    @param [in] writer      The used XML writer.\r\n     *    @param [in] component   The component being written.\r\n     */\r\n    void writeModel(QXmlStreamWriter& writer, QSharedPointer<Component> component) const;\r\n\r\n    /*!\r\n     *  Write the views.\r\n     *\r\n     *    @param [in] writer      The used XML writer.\r\n     *    @param [in] component   The component being written.\r\n     */\r\n    void writeViews(QXmlStreamWriter& writer, QSharedPointer<Component> component) const;\r\n\r\n    /*!\r\n     *  Write the instantiations.\r\n     *\r\n     *    @param [in] writer      The used XML writer.\r\n     *    @param [in] component   The component being written.\r\n     */\r\n    void writeInstantiations(QXmlStreamWriter& writer, QSharedPointer<Component> component) const;\r\n\r\n    /*!\r\n     *  Write the ports.\r\n     *\r\n     *    @param [in] writer      The used XML writer.\r\n     *    @param [in] component   The component being written.\r\n     */\r\n    void writePorts(QXmlStreamWriter& writer, QSharedPointer<Component> component) const;\r\n\r\n    /*!\r\n     *  Write the component generators.\r\n     *\r\n     *    @param [in] writer      The used XML writer.\r\n     *    @param [in] component   The component being written.\r\n     */\r\n    void writeComponentGenerators(QXmlStreamWriter& writer, QSharedPointer<Component> component) const;\r\n\r\n    /*!\r\n     *  Write the choices.\r\n     *\r\n     *    @param [in] writer      The used XML writer.\r\n     *    @param [in] component   The component being written.\r\n     */\r\n    void writeChoices(QXmlStreamWriter& writer, QSharedPointer<Component> component) const;\r\n\r\n    /*!\r\n     *  Write the file sets.\r\n     *\r\n     *    @param [in] writer      The used XML writer.\r\n     *    @param [in] component   The component being written.\r\n     */\r\n    void writeFileSets(QXmlStreamWriter& writer, QSharedPointer<Component> component) const;\r\n\r\n    /*!\r\n     *  Write the cpus.\r\n     *\r\n     *    @param [in] writer      The used XML writer.\r\n     *    @param [in] component   The component being written.\r\n     */\r\n    void writeCPUs(QXmlStreamWriter& writer, QSharedPointer<Component> component) const;\r\n\r\n    /*!\r\n     *  Write the other clock drivers.\r\n     *\r\n     *    @param [in] writer      The used XML writer.\r\n     *    @param [in] component   The component being written.\r\n     */\r\n    void writeOtherClockDrivers(QXmlStreamWriter& writer, QSharedPointer<Component> component) const;\r\n\r\n    /*!\r\n     *  Write the reset types.\r\n     *\r\n     *    @param [in] writer      The used XML writer.\r\n     *    @param [in] component   The component being written.\r\n     */\r\n    void writeResetTypes(QXmlStreamWriter& writer, QSharedPointer<Component> component) const;\r\n\r\n    /*!\r\n     *  Write the other component extensions.\r\n     *\r\n     *    @param [in] writer      The used XML writer.\r\n     *    @param [in] component   The component being written.\r\n     */\r\n    void writeComponentExtensions(QXmlStreamWriter& writer, QSharedPointer<Component> component) const;\r\n    void writePowerDomains(QXmlStreamWriter& writer, QSharedPointer<Component> component) const;\r\n};\r\n\r\n#endif // COMPONENTWRITER_H"
  },
  {
    "path": "IPXACTmodels/Component/Cpu.cpp",
    "content": "/* \r\n *\r\n *  Created on: 6.8.2010\r\n *      Author: Antti Kamppi\r\n */\r\n\r\n#include \"Cpu.h\"\r\n\r\n#include <IPXACTmodels/common/Parameter.h>\r\n\r\n#include <QString>\r\n#include <QList>\r\n#include <QSharedPointer>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Cpu::AddressSpaceRef::AddressSpaceRef()\r\n//-----------------------------------------------------------------------------\r\nCpu::AddressSpaceRef::AddressSpaceRef(QString const& addressSpaceReference) :\r\naddressSpaceRef_(addressSpaceReference)\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Cpu::getAddressSpaceRef()\r\n//-----------------------------------------------------------------------------\r\nQString Cpu::AddressSpaceRef::getAddressSpaceRef() const\r\n{\r\n    return addressSpaceRef_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Cpu::AddressSpaceRef::setAddressSpaceRef()\r\n//-----------------------------------------------------------------------------\r\nvoid Cpu::AddressSpaceRef::setAddressSpaceRef(QString const& newAddressSpaceRef)\r\n{\r\n    addressSpaceRef_ = newAddressSpaceRef;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Cpu::AddressSpaceRef::getIsPresent()\r\n//-----------------------------------------------------------------------------\r\nQString Cpu::AddressSpaceRef::getIsPresent() const\r\n{\r\n    return isPresent_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Cpu::AddressSpaceRef::setIsPresent()\r\n//-----------------------------------------------------------------------------\r\nvoid Cpu::AddressSpaceRef::setIsPresent(QString const& newIsPresent)\r\n{\r\n    isPresent_ = newIsPresent;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Cpu::Cpu()\r\n//-----------------------------------------------------------------------------\r\nCpu::Cpu(QString const& name) :\r\nNameGroup(name),\r\nExtendable()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Cpu::Cpu()\r\n//-----------------------------------------------------------------------------\r\nCpu::Cpu(Cpu const& other):\r\nNameGroup(other),\r\nExtendable(other),\r\nisPresent_(other.isPresent_),\r\nrange_(other.range_),\r\nwidth_(other.width_),\r\naddressUnitBits_(other.addressUnitBits_),\r\nmemoryMapReference_(other.memoryMapReference_)\r\n{\r\n    copyParameters(other);\r\n    copyAddressSpaceRefs(other);\r\n    copyRegions(other);\r\n    copyExecutableImages(other);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Cpu::operator=()\r\n//-----------------------------------------------------------------------------\r\nCpu & Cpu::operator=(Cpu const& other)\r\n{\r\n\tif (this != &other)\r\n    {\r\n\t\tNameGroup::operator=(other);\r\n        Extendable::operator=(other);\r\n\r\n        range_ = other.range_;\r\n        width_ = other.width_;\r\n        addressUnitBits_ = other.addressUnitBits_;\r\n        memoryMapReference_ = other.memoryMapReference_;\r\n\r\n        addressSpaceRefs_->clear();\r\n        copyAddressSpaceRefs(other);\r\n\r\n        regions_->clear();\r\n        copyRegions(other);\r\n\r\n        executableImages_->clear();\r\n        copyExecutableImages(other);\r\n\r\n        parameters_->clear();\r\n        copyParameters(other);\r\n\t}\r\n\treturn *this;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Cpu::~Cpu()\r\n//-----------------------------------------------------------------------------\r\nCpu::~Cpu()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Cpu::getIsPresent()\r\n//-----------------------------------------------------------------------------\r\nQString Cpu::getIsPresent() const\r\n{\r\n\treturn isPresent_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Cpu::setIsPresent()\r\n//-----------------------------------------------------------------------------\r\nvoid Cpu::setIsPresent(QString const& newIsPresent)\r\n{\r\n\tisPresent_ = newIsPresent;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: cpu::getParameters()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<QList<QSharedPointer<Parameter> > > Cpu::getParameters()\r\n{\r\n\treturn parameters_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: cpu::getAddressSpaceRefs()\r\n//-----------------------------------------------------------------------------\r\nQStringList Cpu::getAddressSpaceRefs() const\r\n{\r\n    QStringList references;\r\n\r\n    for (QSharedPointer<Cpu::AddressSpaceRef> addressSpaceRef : *addressSpaceRefs_)\r\n    {\r\n        references.append(addressSpaceRef->getAddressSpaceRef());\r\n    }\r\n\r\n    return references;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: cpu::getAddressSpaceReferences()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<QList<QSharedPointer<Cpu::AddressSpaceRef> > > Cpu::getAddressSpaceReferences() const\r\n{\r\n    return addressSpaceRefs_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Cpu::setAddressSpaceRefs()\r\n//-----------------------------------------------------------------------------\r\nvoid Cpu::setAddressSpaceRefs(QStringList addrSpaceNames)\r\n{\r\n\taddressSpaceRefs_->clear();\r\n    for (QString const& addressSpaceName : addrSpaceNames)\r\n    {\r\n        QSharedPointer<AddressSpaceRef> addressSpaceRef(new AddressSpaceRef(addressSpaceName));\r\n        addressSpaceRefs_->append(addressSpaceRef);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: cpu::setAddressSpaceRefs()\r\n//-----------------------------------------------------------------------------\r\nvoid Cpu::setAddressSpaceReferences(QSharedPointer<QList<QSharedPointer<AddressSpaceRef> > > newAddressSpaceRefs)\r\n{\r\n\taddressSpaceRefs_->clear();\r\n\taddressSpaceRefs_ = newAddressSpaceRefs;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Cpu::getRange()\r\n//-----------------------------------------------------------------------------\r\nQString Cpu::getRange() const\r\n{\r\n    return range_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Cpu::setRange()\r\n//-----------------------------------------------------------------------------\r\nvoid Cpu::setRange(QString const& range)\r\n{\r\n    range_ = range;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Cpu::getWidth()\r\n//-----------------------------------------------------------------------------\r\nQString Cpu::getWidth() const\r\n{\r\n    return width_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Cpu::setWidth()\r\n//-----------------------------------------------------------------------------\r\nvoid Cpu::setWidth(QString const& width)\r\n{\r\n    width_ = width;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Cpu::getMemoryMapReference()\r\n//-----------------------------------------------------------------------------\r\nQString Cpu::getMemoryMapReference() const\r\n{\r\n    return memoryMapReference_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Cpu::setMemoryMapReference()\r\n//-----------------------------------------------------------------------------\r\nvoid Cpu::setMemoryMapReference(QString const& memoryMapRef)\r\n{\r\n    memoryMapReference_ = memoryMapRef;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Cpu::getRegions()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<QList<QSharedPointer<Region> > > Cpu::getRegions() const\r\n{\r\n    return regions_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Cpu::getAddressUnitBits()\r\n//-----------------------------------------------------------------------------\r\nQString Cpu::getAddressUnitBits(bool defaultIfEmpty /*= true*/) const\r\n{\r\n    if (addressUnitBits_.isEmpty() && defaultIfEmpty)\r\n    {\r\n        return QStringLiteral(\"8\");\r\n    }\r\n\r\n    return addressUnitBits_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Cpu::getExecutableImages()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<QList<QSharedPointer<ExecutableImage> > > Cpu::getExecutableImages()\r\n{\r\n    return executableImages_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Cpu::setAddressUnitBits()\r\n//-----------------------------------------------------------------------------\r\nvoid Cpu::setAddressUnitBits(QString const& addressUnitBits)\r\n{\r\n    addressUnitBits_ = addressUnitBits;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: cpu::copyParameters()\r\n//-----------------------------------------------------------------------------\r\nvoid Cpu::copyParameters(Cpu const& other)\r\n{\r\n    for (QSharedPointer<Parameter> param : *other.parameters_)\r\n    {\r\n        QSharedPointer<Parameter> copy(new Parameter(*param));\r\n        parameters_->append(copy);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: cpu::copyAddressSpaceRefs()\r\n//-----------------------------------------------------------------------------\r\nvoid Cpu::copyAddressSpaceRefs(Cpu const& other)\r\n{\r\n    for (QSharedPointer<Cpu::AddressSpaceRef> reference : *other.addressSpaceRefs_)\r\n    {\r\n        QSharedPointer<Cpu::AddressSpaceRef> copy(new AddressSpaceRef(*reference));\r\n        addressSpaceRefs_->append(copy);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Cpu::copyRegions()\r\n//-----------------------------------------------------------------------------\r\nvoid Cpu::copyRegions(Cpu const& other)\r\n{\r\n    for (QSharedPointer<Region> region: *other.regions_)\r\n    {\r\n        QSharedPointer<Region> copy(new Region(*region));\r\n        regions_->append(copy);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Cpu::copyExecutableImages()\r\n//-----------------------------------------------------------------------------\r\nvoid Cpu::copyExecutableImages(Cpu const& other)\r\n{\r\n    for (QSharedPointer<ExecutableImage> image : *other.executableImages_)\r\n    {\r\n        QSharedPointer<ExecutableImage> copy(new ExecutableImage(*image));\r\n        executableImages_->append(copy);\r\n    }\r\n}\r\n"
  },
  {
    "path": "IPXACTmodels/Component/Cpu.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: cpu.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Antti Kamppi\r\n// Date: 06.08.2010\r\n//\r\n// Description:\r\n// Implementation of ipxact:cpu element.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef CPU_H\r\n#define CPU_H\r\n\r\n#include <IPXACTmodels/common/NameGroup.h>\r\n#include <IPXACTmodels/common/Extendable.h>\r\n\r\n#include <IPXACTmodels/Component/Region.h>\r\n#include <IPXACTmodels/Component/ExecutableImage.h>\r\n\r\n#include <QString>\r\n#include <QStringList>\r\n#include <QSharedPointer>\r\n\r\nclass Choice;\r\nclass Parameter;\r\nclass VendorExtension;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Implementation of ipxact:cpu element.\r\n//-----------------------------------------------------------------------------\r\nclass IPXACTMODELS_EXPORT Cpu : public NameGroup, public Extendable\r\n{\r\n\r\npublic:\r\n\r\n    //! Cpu address space reference.\r\n    struct IPXACTMODELS_EXPORT AddressSpaceRef\r\n    {\r\n        //! The address space reference.\r\n        QString addressSpaceRef_;\r\n\r\n        //! The presence.\r\n        QString isPresent_;\r\n\r\n        /*!\r\n         *  The constructor.\r\n         *\r\n         *    @param [in] addressSpaceReference   The address space reference.\r\n         */\r\n        AddressSpaceRef(QString const& addressSpaceReference = QString());\r\n\r\n        /*!\r\n         *  Get the address space reference.\r\n         *\r\n         *    @return Address space reference.\r\n         */\r\n        QString getAddressSpaceRef() const;\r\n\r\n        /*!\r\n         *  Set the address space reference.\r\n         *\r\n         *    @param [in] newAddressSpaceRef  The new address space reference.\r\n         */\r\n        void setAddressSpaceRef(QString const& newAddressSpaceRef);\r\n\r\n        /*!\r\n         *  Get the is present.\r\n         *\r\n         *    @return Is present value.\r\n         */\r\n        QString getIsPresent() const;\r\n\r\n        /*!\r\n         *  Set the is present value.\r\n         *\r\n         *    @param [in] newIsPresent    The new is present value.\r\n         */\r\n        void setIsPresent(QString const& newIsPresent);\r\n    };\r\n\r\n    /*!\r\n     *  Default constructor.\r\n     *\r\n     *    @param [in] name    Name of the cpu.\r\n     */\r\n    Cpu(QString const& name = QString());\r\n\r\n\t//! Copy constructor.\r\n\tCpu(const Cpu &other);\r\n\r\n\t//! Assignment operator.\r\n\tCpu &operator=(const Cpu &other);\r\n\r\n\t//! The destructor.\r\n\t~Cpu();\r\n\r\n    /*!\r\n     *  Gets the presence.\r\n     *\r\n     *    @return The presence value.\r\n     */\r\n    QString getIsPresent() const;\r\n\r\n    /*!\r\n     *  Set the presence.\r\n     *\r\n     *    @param [in] newIsPresent    The new presence value.\r\n     */\r\n    void setIsPresent(QString const& newIsPresent);\r\n\r\n\t/*!\r\n     *  Get list of the address space references for this cpu.\r\n\t *\r\n\t *    @return A list containing the addressSpaceRefs.\r\n\t */\r\n    QStringList getAddressSpaceRefs() const;\r\n\r\n    /*!\r\n     *  Get the address space references.\r\n     *\r\n     *    @return List of address space references.\r\n     */\r\n    QSharedPointer<QList<QSharedPointer<Cpu::AddressSpaceRef> > > getAddressSpaceReferences() const;\r\n          \r\n    /*!\r\n     *  Set the address space references.\r\n     *\r\n     *    @param [in] addrSpaceNames    The address space references to set.\r\n     */  \r\n    void setAddressSpaceRefs(QStringList addrSpaceNames);\r\n\r\n    /*!\r\n     *  Set the address space references.\r\n     *\r\n     *    @param [in] newAddressSpaceRefs     List containing the new address space references.\r\n     */\r\n    void setAddressSpaceReferences(QSharedPointer<QList<QSharedPointer<AddressSpaceRef> > > newAddressSpaceRefs);\r\n\r\n    QString getRange() const;\r\n\r\n    void setRange(QString const& range);\r\n\r\n    QString getWidth() const;\r\n\r\n    void setWidth(QString const& width);\r\n\r\n    QString getMemoryMapReference() const;\r\n\r\n    void setMemoryMapReference(QString const& memoryMapRef);\r\n\r\n    QSharedPointer<QList<QSharedPointer<Region> > > getRegions() const;\r\n\r\n    /*!\r\n     *  Get the address unit bits\r\n     *\r\n     *    @param [in] defaultIfEmpty      Flag for returning the default AUB value (8 bits) if AUB is empty.\r\n     * \r\n     *    @return The address unit bits.\r\n     */\r\n    QString getAddressUnitBits(bool defaultIfEmpty = true) const;\r\n\r\n\r\n    QSharedPointer<QList<QSharedPointer<ExecutableImage> > > getExecutableImages();\r\n\r\n    void setAddressUnitBits(QString const& addressUnitBits);\r\n\r\n\t/*!\r\n     *  Get the parameters of the cpu.\r\n\t *\r\n\t *    @return List containing pointers to the parameters for the cpu.\r\n\t */\r\n\tQSharedPointer<QList<QSharedPointer<Parameter> > >  getParameters();\r\n\r\nprivate:\r\n\r\n    /*!\r\n     *  Copy the parameters.\r\n     *\r\n     *    @param [in] other   The cpu being copied.\r\n     */\r\n    void copyParameters(const Cpu& other);\r\n\r\n    /*!\r\n     *  Copy the address space references.\r\n     *\r\n     *    @param [in] other   The cpu being copied.\r\n     */\r\n    void copyAddressSpaceRefs(const Cpu& other);\r\n\r\n    void copyRegions(Cpu const& other);\r\n\r\n    void copyExecutableImages(Cpu const& other);\r\n\r\n\r\n    //! Presence of the CPU.\r\n\tQString isPresent_;\r\n\r\n    //! References a name of an address space within component.\r\n    QSharedPointer<QList<QSharedPointer<AddressSpaceRef> > > addressSpaceRefs_ =\r\n        QSharedPointer<QList<QSharedPointer<AddressSpaceRef> > >(new QList<QSharedPointer<AddressSpaceRef> >);\r\n\r\n    QString range_;\r\n\r\n    QString width_;\r\n\r\n\r\n    QSharedPointer<QList<QSharedPointer<Region> > > regions_ =\r\n        QSharedPointer<QList<QSharedPointer<Region> > >(new QList<QSharedPointer<Region> >);\r\n\r\n    QString addressUnitBits_;\r\n\r\n    QSharedPointer<QList<QSharedPointer<ExecutableImage> > > executableImages_ =\r\n        QSharedPointer<QList<QSharedPointer<ExecutableImage> > >(new QList<QSharedPointer<ExecutableImage> >);\r\n\r\n    QString memoryMapReference_;\r\n\r\n\t//! Specifies any cpu-type parameters.\r\n    QSharedPointer<QList<QSharedPointer<Parameter> > > parameters_ =\r\n        QSharedPointer<QList<QSharedPointer<Parameter> > >(new QList<QSharedPointer<Parameter> >);\r\n\r\n};\r\n\r\n#endif // CPU_H\r\n"
  },
  {
    "path": "IPXACTmodels/Component/DesignConfigurationInstantiation.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: DesignConfigurationInstantiation.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 07.09.2015\r\n//\r\n// Description:\r\n// Describes the ipxact:designConfigurationInstantiation element.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"DesignConfigurationInstantiation.h\"\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignConfigurationInstantiation::DesignConfigurationInstantiation()\r\n//-----------------------------------------------------------------------------\r\nDesignConfigurationInstantiation::DesignConfigurationInstantiation(QString const& name /* = QString() */,\r\n    QString const& displayName /* = QString() */, QString const& description /* = QString() */) :\r\nNameGroup(name, displayName, description),\r\nExtendable(),\r\nlanguage_(),\r\nlanguageStrictness_(),\r\ndesignConfigurationRef_(new ConfigurableVLNVReference()),\r\nparameters_(new QList<QSharedPointer<Parameter> > ())\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignConfigurationInstantiation::DesignConfigurationInstantiation()\r\n//-----------------------------------------------------------------------------\r\nDesignConfigurationInstantiation::DesignConfigurationInstantiation(const DesignConfigurationInstantiation& other) :\r\nNameGroup(other),\r\nExtendable(other),\r\nlanguage_(other.language_),\r\nlanguageStrictness_(other.languageStrictness_),\r\ndesignConfigurationRef_(new ConfigurableVLNVReference(*other.designConfigurationRef_.data())),\r\nparameters_(new QList<QSharedPointer<Parameter> > ())\r\n{\r\n    copyParameters(other);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignConfigurationInstantiation::operator=()\r\n//-----------------------------------------------------------------------------\r\nDesignConfigurationInstantiation& DesignConfigurationInstantiation::operator=(\r\n    const DesignConfigurationInstantiation& other)\r\n{\r\n    if (this != &other)\r\n    {\r\n        NameGroup::operator=(other);\r\n        Extendable::operator=(other);\r\n\r\n        language_ = other.language_;\r\n        languageStrictness_ = other.languageStrictness_;\r\n\r\n        designConfigurationRef_.clear();\r\n        designConfigurationRef_ = QSharedPointer<ConfigurableVLNVReference> \r\n            (new ConfigurableVLNVReference(*other.designConfigurationRef_.data()));\r\n\r\n        parameters_->clear();\r\n        copyParameters(other);\r\n    }\r\n    return *this;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignConfigurationInstantiation::~DesignConfigurationInstantiation()\r\n//-----------------------------------------------------------------------------\r\nDesignConfigurationInstantiation::~DesignConfigurationInstantiation()\r\n{\r\n    designConfigurationRef_.clear();\r\n    parameters_.clear();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignConfigurationInstantiation::getLanguage()\r\n//-----------------------------------------------------------------------------\r\nQString DesignConfigurationInstantiation::getLanguage() const\r\n{\r\n    return language_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignConfigurationInstantiation::setLanguage()\r\n//-----------------------------------------------------------------------------\r\nvoid DesignConfigurationInstantiation::setLanguage(QString const& newLanguage)\r\n{\r\n    language_ = newLanguage;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignConfigurationInstantiation::isLangugageStrict()\r\n//-----------------------------------------------------------------------------\r\nbool DesignConfigurationInstantiation::isLangugageStrict() const\r\n{\r\n    return languageStrictness_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignConfigurationInstantiation::setLanguageStrict()\r\n//-----------------------------------------------------------------------------\r\nvoid DesignConfigurationInstantiation::setLanguageStrict(bool strictness)\r\n{\r\n    languageStrictness_ = strictness;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignConfigurationInstantiation::getDesignConfigurationReference()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<ConfigurableVLNVReference> DesignConfigurationInstantiation::getDesignConfigurationReference() const\r\n{\r\n    return designConfigurationRef_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignConfigurationInstantiation::setDesignConfigurationReference()\r\n//-----------------------------------------------------------------------------\r\nvoid DesignConfigurationInstantiation::setDesignConfigurationReference(\r\n    QSharedPointer<ConfigurableVLNVReference> newDesignConfigurationReference)\r\n{\r\n    designConfigurationRef_ = newDesignConfigurationReference;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignConfigurationInstantiation::getParameters()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<QList<QSharedPointer<Parameter> > > DesignConfigurationInstantiation::getParameters() const\r\n{\r\n    return parameters_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignConfigurationInstantiation::setParameters()\r\n//-----------------------------------------------------------------------------\r\nvoid DesignConfigurationInstantiation::setParameters(\r\n    QSharedPointer<QList<QSharedPointer<Parameter> > > newParameters)\r\n{\r\n    parameters_ = newParameters;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignConfigurationInstantiation::copyParameters()\r\n//-----------------------------------------------------------------------------\r\nvoid DesignConfigurationInstantiation::copyParameters(DesignConfigurationInstantiation const& other) const\r\n{\r\n    foreach (QSharedPointer<Parameter> parameter, *other.parameters_)\r\n    {\r\n        if (parameter)\r\n        {\r\n            QSharedPointer<Parameter> copy = QSharedPointer<Parameter>(new Parameter(*parameter.data()));\r\n            parameters_->append(copy);\r\n        }\r\n    }\r\n}"
  },
  {
    "path": "IPXACTmodels/Component/DesignConfigurationInstantiation.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: DesignConfigurationInstantiation.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 07.09.2015\r\n//\r\n// Description:\r\n// Describes the ipxact:designConfigurationInstantiation element.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef DESIGNCONFIGURATIONINSTANTIATION_H\r\n#define DESIGNCONFIGURATIONINSTANTIATION_H\r\n\r\n#include <IPXACTmodels/common/NameGroup.h>\r\n#include <IPXACTmodels/common/Extendable.h>\r\n#include <IPXACTmodels/common/ConfigurableVLNVReference.h>\r\n#include <IPXACTmodels/common/Parameter.h>\r\n\r\n#include <IPXACTmodels/ipxactmodels_global.h>\r\n\r\n#include <QSharedPointer>\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Describes the ipxact:designConfigurationInstantiation element.\r\n//-----------------------------------------------------------------------------\r\nclass IPXACTMODELS_EXPORT DesignConfigurationInstantiation : public NameGroup, public Extendable\r\n{\r\n\r\npublic:\r\n\r\n    using List = QSharedPointer<QList<QSharedPointer<DesignConfigurationInstantiation> > >;\r\n\r\n    /*!\r\n     *  The constructor.\r\n     *\r\n     *    @param [in] name            Name of the instantiation.\r\n     *    @param [in] displayName     Display name of the instantiation.\r\n     *    @param [in] description     Description of the instantiation.\r\n     */\r\n    DesignConfigurationInstantiation(QString const& name = QString(), QString const& displayName = QString(),\r\n        QString const& description = QString());\r\n\r\n    /*!\r\n     *  The copy constructor.\r\n     */\r\n    DesignConfigurationInstantiation(const DesignConfigurationInstantiation& other);\r\n\r\n    /*!\r\n     *  The assignment operator.\r\n     */\r\n    DesignConfigurationInstantiation& operator=(const DesignConfigurationInstantiation& other);\r\n\r\n    /*!\r\n     *  The destructor.\r\n     */\r\n    ~DesignConfigurationInstantiation();\r\n\r\n    /*!\r\n     *  Get the HDL used for instantiation.\r\n     *\r\n     *    @return The used HDL.\r\n     */\r\n    QString getLanguage() const;\r\n\r\n    /*!\r\n     *  Set the HDL for this instantiation.\r\n     *\r\n     *    @param [in] newLanguage     The new HDL.\r\n     */\r\n    void setLanguage(QString const& newLanguage);\r\n\r\n    /*!\r\n     *  Check if the used language shall be strictly enforced.\r\n     *\r\n     *    @return True, if the language shall be strictly enforced, false otherwise.\r\n     */\r\n    bool isLangugageStrict() const;\r\n\r\n    /*!\r\n     *  Set the strictness of the language.\r\n     *\r\n     *    @param [in] strictness  If true, the language shall be strictly enforced.\r\n     */\r\n    void setLanguageStrict(bool strictness);\r\n\r\n    /*!\r\n     *  Get the design configuration reference.\r\n     *\r\n     *    @return Pointer to the design configuration referenced by the instantiation.\r\n     */\r\n    QSharedPointer<ConfigurableVLNVReference> getDesignConfigurationReference() const;\r\n\r\n    /*!\r\n     *  Set the design configuration reference.\r\n     *\r\n     *    @param [in] newDesignReference  The referenced design configuration.\r\n     */\r\n    void setDesignConfigurationReference(QSharedPointer<ConfigurableVLNVReference> newDesignConfigurationReference);\r\n\r\n    /*!\r\n     *  Get a list of parameters used in this instantiation.\r\n     *\r\n     *    @return A list of parameters.\r\n     */\r\n    QSharedPointer<QList<QSharedPointer<Parameter> > > getParameters() const;\r\n\r\n    /*!\r\n     *  Set a list of parameters.\r\n     *\r\n     *    @param [in] newParameters   The new list of parameters.\r\n     */\r\n    void setParameters(QSharedPointer<QList<QSharedPointer<Parameter> > > newParameters);\r\n\r\nprivate:\r\n\r\n    /*!\r\n     *  Copy parameters from another design configuration instantiation.\r\n     *\r\n     *    @param [in] other   The location of the copied parameters.\r\n     */\r\n    void copyParameters(DesignConfigurationInstantiation const& other) const;\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! The used HDL.\r\n    QString language_;\r\n\r\n    //! Determines whether the language shall be strictly enforced or not.\r\n    bool languageStrictness_;\r\n\r\n    //! Design configuration reference.\r\n    QSharedPointer<ConfigurableVLNVReference> designConfigurationRef_;\r\n\r\n    //! A list of instantiation parameters.\r\n    QSharedPointer<QList<QSharedPointer<Parameter> > > parameters_;\r\n};\r\n\r\n#endif // DESIGNINSTANTIATION_H"
  },
  {
    "path": "IPXACTmodels/Component/DesignInstantiation.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: DesignInstantiation.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 03.09.2015\r\n//\r\n// Description:\r\n// Describes the ipxact:view element of a component.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"DesignInstantiation.h\"\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignInstantiation::DesignInstantiation()\r\n//-----------------------------------------------------------------------------\r\nDesignInstantiation::DesignInstantiation(QString const& name /* = QString() */,\r\n    QString const& displayName /* = QString() */, QString const& description /* = QString() */) :\r\nNameGroup(name, displayName, description),\r\nExtendable(),\r\ndesignRef_(new ConfigurableVLNVReference())\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignInstantiation::DesignInstantiation()\r\n//-----------------------------------------------------------------------------\r\nDesignInstantiation::DesignInstantiation(const DesignInstantiation& other):\r\nNameGroup(other),\r\nExtendable(other),\r\ndesignRef_(new ConfigurableVLNVReference(*other.designRef_.data()))\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignInstantiation::operator=()\r\n//-----------------------------------------------------------------------------\r\nDesignInstantiation& DesignInstantiation::operator=(DesignInstantiation const& other)\r\n{\r\n    if (this != &other)\r\n    {\r\n        NameGroup::operator=(other);\r\n        Extendable::operator=(other);\r\n\r\n        designRef_.clear();\r\n        designRef_ =\r\n            QSharedPointer<ConfigurableVLNVReference> (new ConfigurableVLNVReference(*other.designRef_.data()));\r\n    }\r\n\r\n    return *this;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignInstantiation::~DesignInstantiation()\r\n//-----------------------------------------------------------------------------\r\nDesignInstantiation::~DesignInstantiation()\r\n{\r\n    designRef_.clear();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignInstantiation::getDesignReference()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<ConfigurableVLNVReference> DesignInstantiation::getDesignReference() const\r\n{\r\n    return designRef_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignInstantiation::setDesignReference()\r\n//-----------------------------------------------------------------------------\r\nvoid DesignInstantiation::setDesignReference(QSharedPointer<ConfigurableVLNVReference> newDesignReference)\r\n{\r\n    designRef_ = newDesignReference;\r\n}"
  },
  {
    "path": "IPXACTmodels/Component/DesignInstantiation.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: DesignInstantiation.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 03.09.2015\r\n//\r\n// Description:\r\n// Describes the ipxact:designInstantiation element.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef DESIGNINSTANTIATION_H\r\n#define DESIGNINSTANTIATION_H\r\n\r\n#include <IPXACTmodels/common/NameGroup.h>\r\n#include <IPXACTmodels/common/Extendable.h>\r\n#include <IPXACTmodels/common/ConfigurableVLNVReference.h>\r\n\r\n#include <IPXACTmodels/ipxactmodels_global.h>\r\n\r\n#include <QSharedPointer>\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Describes the ipxact:designInstantiation element.\r\n//-----------------------------------------------------------------------------\r\nclass IPXACTMODELS_EXPORT DesignInstantiation : public NameGroup, public Extendable\r\n{\r\n\r\npublic:\r\n\r\n    using List = QSharedPointer<QList<QSharedPointer<DesignInstantiation> > >;\r\n\r\n    /*!\r\n     *  The constructor.\r\n     *\r\n     *    @param [in] name            Name of the instantiation.\r\n     *    @param [in] displayName     Display name of the instantiation.\r\n     *    @param [in] description     Description of the instantiation.\r\n     */\r\n    DesignInstantiation(QString const& name = QString(), QString const& displayName = QString(),\r\n        QString const& description = QString());\r\n\r\n    /*!\r\n     *  The copy constructor.\r\n     */\r\n    DesignInstantiation(const DesignInstantiation& other);\r\n\r\n    /*!\r\n     *  The assignment operator.\r\n     */\r\n    DesignInstantiation& operator=(const DesignInstantiation& other);\r\n\r\n    /*!\r\n     *  The destructor.\r\n     */\r\n    ~DesignInstantiation();\r\n\r\n    /*!\r\n     *  Get the design reference.\r\n     *\r\n     *    @return Pointer to the design referenced by the instantiation.\r\n     */\r\n    QSharedPointer<ConfigurableVLNVReference> getDesignReference() const;\r\n\r\n    /*!\r\n     *  Set the design reference.\r\n     *\r\n     *    @param [in] newDesignReference  The referenced design.\r\n     */\r\n    void setDesignReference(QSharedPointer<ConfigurableVLNVReference> newDesignReference);\r\n\r\nprivate:\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! The design referenced by this instantitation.\r\n    QSharedPointer<ConfigurableVLNVReference> designRef_;\r\n};\r\n\r\n#endif // DESIGNINSTANTIATION_H"
  },
  {
    "path": "IPXACTmodels/Component/Driver.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: Driver.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Esko Pekkarinen\n// Date: 7.11.2023\n//\n// Description:\n// Implementation of ipxact:driver for wire ports.\n//-----------------------------------------------------------------------------\n\n#include \"Driver.h\"\n\n#include <QList>\n#include <QString>\n\n//-----------------------------------------------------------------------------\n// Function: Driver::clone()\n//-----------------------------------------------------------------------------\nDriver* Driver::clone() const\n{\n    return new Driver(*this);\n}\n\n//-----------------------------------------------------------------------------\n// Function: Driver::getRange()\n//-----------------------------------------------------------------------------\nRange Driver::getRange() const\n{\n    return range_;\n}\n\n//-----------------------------------------------------------------------------\n// Function: Driver::setRange()\n//-----------------------------------------------------------------------------\nvoid Driver::setRange(Range const& range)\n{\n    range_ = range;\n}\n\n//-----------------------------------------------------------------------------\n// Function: Driver::getDefaultValue()\n//-----------------------------------------------------------------------------\nQString Driver::getDefaultValue() const\n{\n    return defaultValue_;\n}\n\n//-----------------------------------------------------------------------------\n// Function: Driver::setDefaultValue()\n//-----------------------------------------------------------------------------\nvoid Driver::setDefaultValue(QString const& value)\n{\n    defaultValue_ = value;\n}\n"
  },
  {
    "path": "IPXACTmodels/Component/Driver.h",
    "content": "//-----------------------------------------------------------------------------\n// File: Driver.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Esko Pekkarinen\n// Date: 7.11.2023\n//\n// Description:\n// Implementation of ipxact:driver for wire ports.\n//-----------------------------------------------------------------------------\n\n#ifndef DRIVER_H\n#define DRIVER_H\n\n#include <IPXACTmodels/common/Range.h>\n\n#include <IPXACTmodels/ipxactmodels_global.h>\n#include <QString>\n\n//-----------------------------------------------------------------------------\n//! Implementation of ipxact:driver for wire ports.\n//-----------------------------------------------------------------------------\nclass IPXACTMODELS_EXPORT Driver\n{\npublic:\n\n    /*!\n     *  Create a copy of the Driver.\n     *\n     *    @return A Driver identical to this.\n     */\n\tDriver* clone() const;\n\n    /*!\n     *  Get the applied range for the driver.\n     *\n     *    @return The range the driver applies to.\n     */\n    Range getRange() const;\n\n    /*!\n     *  Set the range the driver applies to\n     *\n     *    @param [in] range The range to set.\n     */\n    void setRange(Range const& range);\n\n\t/*!\n\t *  Get the default value of the driver.\n\t *\n\t *    @return The default value.\n\t */\n\tQString getDefaultValue() const;\n\n\t/*!\n\t *  Set the default value in the driver.\n\t *\n\t *    @param [in] value The default value to set.\n\t */\n\tvoid setDefaultValue(QString const& value);\n\nprivate:\n\n    //! The range the driver applies to.\n\tRange range_{ QString(), QString() };\n\n    //! The default value of the wire.\n    QString defaultValue_;\n\n\t//! ClockDriver not supported.\n\t\n\t//! SingleShotDriver not supported.\n};\n\n\n\n#endif // DRIVER_H\n"
  },
  {
    "path": "IPXACTmodels/Component/EnumeratedValue.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: EnumeratedValue.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 23.09.2015\r\n//\r\n// Description:\r\n// Describes the ipxact:enumeratedValue element of a field.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"EnumeratedValue.h\"\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: EnumeratedValue::EnumeratedValue()\r\n//-----------------------------------------------------------------------------\r\nEnumeratedValue::EnumeratedValue(QString const& enumerationName, QString const& value) :\r\nNameGroup(enumerationName),\r\nExtendable(),\r\nusage_(EnumeratedValue::UNKNOWNUSAGE),\r\nvalue_(value)\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: EnumeratedValue::EnumeratedValue()\r\n//-----------------------------------------------------------------------------\r\nEnumeratedValue::EnumeratedValue(const EnumeratedValue& other) :\r\nNameGroup(other),\r\nExtendable(other),\r\nusage_(other.usage_),\r\nvalue_(other.value_)\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: EnumeratedValue::operator=()\r\n//-----------------------------------------------------------------------------\r\nEnumeratedValue& EnumeratedValue::operator=(const EnumeratedValue& other)\r\n{\r\n    if (this != &other)\r\n    {\r\n        NameGroup::operator=(other);\r\n        Extendable::operator=(other);\r\n        usage_ = other.usage_;\r\n        value_ = other.value_;\r\n    }\r\n\r\n    return *this;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: EnumeratedValue::~EnumeratedValue()\r\n//-----------------------------------------------------------------------------\r\nEnumeratedValue::~EnumeratedValue()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: EnumeratedValue::getUsage()\r\n//-----------------------------------------------------------------------------\r\nEnumeratedValue::EnumeratedUsage EnumeratedValue::getUsage() const\r\n{\r\n    return usage_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: EnumeratedValue::setUsage()\r\n//-----------------------------------------------------------------------------\r\nvoid EnumeratedValue::setUsage(EnumeratedValue::EnumeratedUsage usage)\r\n{\r\n    usage_ = usage;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: EnumeratedValue::getValue()\r\n//-----------------------------------------------------------------------------\r\nQString EnumeratedValue::getValue() const\r\n{\r\n    return value_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: EnumeratedValue::setValue()\r\n//-----------------------------------------------------------------------------\r\nvoid EnumeratedValue::setValue( QString const& value )\r\n{\r\n    value_ = value;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: EnumeratedValue::usage2Str()\r\n//-----------------------------------------------------------------------------\r\nQString EnumeratedValue::usage2Str(EnumeratedValue::EnumeratedUsage usage)\r\n{\r\n    if (usage == EnumeratedValue::READ)\r\n    {\r\n        return QStringLiteral(\"read\");\r\n    }\r\n    else if (usage == EnumeratedValue::WRITE)\r\n    {\r\n        return QStringLiteral(\"write\");\r\n    }\r\n    else if (usage == EnumeratedValue::READWRITE)\r\n    {\r\n        return QStringLiteral(\"read-write\");\r\n    }\r\n    else\r\n    {\r\n        return QString();\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: EnumeratedValue::str2Usage()\r\n//-----------------------------------------------------------------------------\r\nEnumeratedValue::EnumeratedUsage EnumeratedValue::str2Usage(const QString& usage, EnumeratedUsage defaultValue)\r\n{\r\n    if (usage == QLatin1String(\"read\"))\r\n    {\r\n        return EnumeratedValue::READ;\r\n    }\r\n    else if (usage == QLatin1String(\"write\"))\r\n    {\r\n        return EnumeratedValue::WRITE;\r\n    }\r\n    else if (usage == QLatin1String(\"read-write\"))\r\n    {\r\n        return EnumeratedValue::READWRITE;\r\n    }\r\n    else\r\n    {\r\n        return defaultValue;\r\n    }\r\n}\r\n"
  },
  {
    "path": "IPXACTmodels/Component/EnumeratedValue.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: EnumeratedValue.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 23.09.2015\r\n//\r\n// Description:\r\n// Describes the ipxact:enumeratedValue element of a field.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef ENUMERATEDVALUE_H\r\n#define ENUMERATEDVALUE_H\r\n\r\n#include <IPXACTmodels/common/Extendable.h>\r\n#include <IPXACTmodels/common/NameGroup.h>\r\n\r\n#include <IPXACTmodels/ipxactmodels_global.h>\r\n\r\n#include <QString>\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Describes the ipxact:enumeratedValue element of a field.\r\n//-----------------------------------------------------------------------------\r\nclass IPXACTMODELS_EXPORT EnumeratedValue : public NameGroup, public Extendable\r\n{\r\n\r\npublic:\r\n\r\n\t/*! \r\n     *  Matches the values of ipxact:usage.\r\n\t */\r\n\tenum EnumeratedUsage\r\n    {\r\n\t\tREAD = 0,\r\n\t\tWRITE,\r\n\t\tREADWRITE,\t// default value\r\n        UNKNOWNUSAGE\r\n\t};\r\n\r\n\t/*!\r\n\t *  The constructor.\r\n\t *\r\n\t *    @param [in] enumerationName     Name of the enumerated value.\r\n\t *    @param [in] value               The enumerated value.\r\n\t */\r\n\tEnumeratedValue(QString const& enumerationName = QString(), QString const& value = QString());\r\n\r\n\t//! Copy constructor\r\n\tEnumeratedValue(const EnumeratedValue& other);\r\n\r\n\t//! Assignment operator\r\n\tEnumeratedValue& operator=(const EnumeratedValue& other);\r\n\r\n    //! The destructor\r\n    virtual ~EnumeratedValue();\r\n\r\n    /*!\r\n     *  Get the usage.\r\n     *\r\n     *    @return     The usage.\r\n     */\r\n    EnumeratedUsage getUsage() const;\r\n\r\n    /*!\r\n     *  Set the usage.\r\n     *\r\n     *    @param [in] usage   The new usage value.\r\n     */\r\n    void setUsage(EnumeratedUsage usage);\r\n\r\n    /*!\r\n     *  Get the value of the enumeratedValue.\r\n     *\r\n     *    @return The value.\r\n     */\r\n\tQString getValue() const;\r\n\r\n    /*!\r\n     *  Set the value of the enumeratedValue.\r\n     *\r\n     *    @param [in] value   The new value.\r\n     */\r\n\tvoid setValue(QString const& value);\r\n\r\n    /*!\r\n     *  Static function that translates enumeratedUsage to QString.\r\n     *\r\n     *    @param [in] usage   The usage to be translated to QString\r\n     *\r\n     *    @return String form of the usage.\r\n     */\r\n    static QString usage2Str(EnumeratedValue::EnumeratedUsage usage);\r\n\r\n    /*!\r\n     *  Static function that translates QString to enumeratedUsage.\r\n     *\r\n     *    @param [in] usage           QString that is translated into enumeratedUsage.\r\n     *    @param [in] defaultValue    The value that is returned if the string doesn't match any usage.\r\n     *\r\n     *    @return EnumeratedValue that matches the string of defaultValue.\r\n     */\r\n    static EnumeratedValue::EnumeratedUsage str2Usage(const QString& usage, EnumeratedUsage defaultValue);\r\n\r\nprivate:\r\n\r\n    //! Defines the software access condition.\r\n    EnumeratedUsage usage_;\r\n\r\n    //! The value of the enumeratedValue\r\n    QString value_;\r\n};\r\n\r\nQ_DECLARE_METATYPE(QSharedPointer<EnumeratedValue>);\r\n\r\n#endif // ENUMERATEDVALUE_H\r\n"
  },
  {
    "path": "IPXACTmodels/Component/EnumeratedValueReader.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: EnumeratedValueReader.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 23.09.2015\r\n//\r\n// Description:\r\n// Reader class for IP-XACT enumerated value element.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"EnumeratedValueReader.h\"\r\n#include \"EnumeratedValue.h\"\r\n\r\n#include <IPXACTmodels/common/NameGroupReader.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: EnumeratedValueReader::EnumeratedValueReader()\r\n//-----------------------------------------------------------------------------\r\nEnumeratedValueReader::EnumeratedValueReader() : CommonItemsReader()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: EnumeratedValueReader::~EnumeratedValueReader()\r\n//-----------------------------------------------------------------------------\r\nEnumeratedValueReader::~EnumeratedValueReader()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: EnumeratedValueReader::createEnumeratedValueFrom()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<EnumeratedValue> EnumeratedValueReader::createEnumeratedValueFrom\r\n    (QDomNode const& enumeratedValueNode) const\r\n{\r\n    QSharedPointer<EnumeratedValue> newEnumeratedValue (new EnumeratedValue());\r\n\r\n    parseUsage(enumeratedValueNode, newEnumeratedValue);\r\n\r\n    parseNameGroup(enumeratedValueNode, newEnumeratedValue);\r\n\r\n    parseValue(enumeratedValueNode, newEnumeratedValue);\r\n\r\n    parseVendorExtensions(enumeratedValueNode, newEnumeratedValue);\r\n\r\n    return newEnumeratedValue;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: EnumeratedValueReader::parseNameGroup()\r\n//-----------------------------------------------------------------------------\r\nvoid EnumeratedValueReader::parseNameGroup(QDomNode const& enumerationNode,\r\n    QSharedPointer<EnumeratedValue> newEnumeration) const\r\n{\r\n    NameGroupReader::parseNameGroup(enumerationNode, newEnumeration);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: EnumeratedValueReader::parseUsage()\r\n//-----------------------------------------------------------------------------\r\nvoid EnumeratedValueReader::parseUsage(QDomNode const& enumerationNode,\r\n    QSharedPointer<EnumeratedValue> newEnumeration) const\r\n{\r\n    QDomElement enumerationElement = enumerationNode.toElement();\r\n    if (enumerationElement.hasAttribute(QStringLiteral(\"usage\")))\r\n    {\r\n        QString usageString = enumerationElement.attribute(QStringLiteral(\"usage\"));\r\n        EnumeratedValue::EnumeratedUsage usage =\r\n            EnumeratedValue::str2Usage(usageString, EnumeratedValue::UNKNOWNUSAGE);\r\n\r\n        newEnumeration->setUsage(usage);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: EnumeratedValueReader::parseValue()\r\n//-----------------------------------------------------------------------------\r\nvoid EnumeratedValueReader::parseValue(QDomNode const& enumerationNode,\r\n    QSharedPointer<EnumeratedValue> newEnumeration) const\r\n{\r\n    QString value = enumerationNode.firstChildElement(QStringLiteral(\"ipxact:value\")).firstChild().nodeValue();\r\n    newEnumeration->setValue(value);\r\n}"
  },
  {
    "path": "IPXACTmodels/Component/EnumeratedValueReader.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: EnumeratedValueReader.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 23.09.2015\r\n//\r\n// Description:\r\n// Reader class for IP-XACT enumerated value element.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef ENUMERATEDVALUEREADER_H\r\n#define ENUMERATEDVALUEREADER_H\r\n\r\n#include <IPXACTmodels/ipxactmodels_global.h>\r\n\r\n#include <IPXACTmodels/common/CommonItemsReader.h>\r\n\r\n#include <QSharedPointer>\r\n#include <QDomNode>\r\n\r\nclass EnumeratedValue;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Reader class for IP-XACT enumerated value element.\r\n//-----------------------------------------------------------------------------\r\nclass IPXACTMODELS_EXPORT EnumeratedValueReader : public CommonItemsReader\r\n{\r\npublic:\r\n\r\n    //! The constructor.\r\n    EnumeratedValueReader();\r\n\r\n    /*!\r\n     *  The destructor.\r\n     */\r\n    ~EnumeratedValueReader();\r\n\r\n    /*!\r\n     *  Creates a new enumerated value from a given enumerated value node.\r\n     *\r\n     *    @param [in] enumeratedValueNode     XML description of the enumerated value.\r\n     *\r\n     *    @return The created enumerated value.\r\n     */\r\n    QSharedPointer<EnumeratedValue> createEnumeratedValueFrom(QDomNode const& enumeratedValueNode) const;\r\n\r\nprivate:\r\n\r\n    //! No copying allowed.\r\n    EnumeratedValueReader(EnumeratedValueReader const& rhs);\r\n    EnumeratedValueReader& operator=(EnumeratedValueReader const& rhs);\r\n\r\n    /*!\r\n     *  Reads the usage.\r\n     *\r\n     *    @param [in] enumerationNode     XML description of the enumerated value.\r\n     *    @param [in] newEnumeration      The new enumerated item.\r\n     */\r\n    void parseUsage(QDomNode const& enumerationNode, QSharedPointer<EnumeratedValue> newEnumeration) const;\r\n\r\n    /*!\r\n     *  Reads the name group.\r\n     *\r\n     *    @param [in] enumerationNode     XML description of the enumerated value.\r\n     *    @param [in] newEnumeration      The new enumerated item.\r\n     */\r\n    void parseNameGroup(QDomNode const& enumerationNode, QSharedPointer<EnumeratedValue> newEnumeration) const;\r\n\r\n    /*!\r\n     *  Reads the value.\r\n     *\r\n     *    @param [in] enumerationNode     XML description of the enumerated value.\r\n     *    @param [in] newEnumeration      The new enumerated item.\r\n     */\r\n    void parseValue(QDomNode const& enumerationNode, QSharedPointer<EnumeratedValue> newEnumeration) const;\r\n};\r\n\r\n#endif // ENUMERATEDVALUEREADER_H"
  },
  {
    "path": "IPXACTmodels/Component/EnumeratedValueWriter.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: EnumeratedValueWriter.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 23.09.2015\r\n//\r\n// Description:\r\n// Writer class for IP-XACT enumerated value element.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"EnumeratedValueWriter.h\"\r\n#include \"EnumeratedValue.h\"\r\n\r\n#include <IPXACTmodels/common/NameGroupWriter.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: EnumeratedValueWriter::EnumeratedValueWriter()\r\n//-----------------------------------------------------------------------------\r\nEnumeratedValueWriter::EnumeratedValueWriter() : CommonItemsWriter()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: EnumeratedValueWriter::~EnumeratedValueWriter()\r\n//-----------------------------------------------------------------------------\r\nEnumeratedValueWriter::~EnumeratedValueWriter()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: EnumeratedValueWriter::writeEnumeratedValue()\r\n//-----------------------------------------------------------------------------\r\nvoid EnumeratedValueWriter::writeEnumeratedValue(QXmlStreamWriter& writer,\r\n    QSharedPointer<EnumeratedValue> enumeratedValue) const\r\n{\r\n    writer.writeStartElement(QStringLiteral(\"ipxact:enumeratedValue\"));\r\n\r\n    writeUsage(writer, enumeratedValue);\r\n\r\n    writeNameGroup(writer, enumeratedValue);\r\n\r\n    writeValue(writer, enumeratedValue);\r\n\r\n    writeVendorExtensions(writer, enumeratedValue);\r\n\r\n    writer.writeEndElement(); // ipxact:enumeratedValue\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: EnumeratedValueWriter::writeUsage()\r\n//-----------------------------------------------------------------------------\r\nvoid EnumeratedValueWriter::writeUsage(QXmlStreamWriter& writer, QSharedPointer<EnumeratedValue> enumeratedValue)\r\n    const\r\n{\r\n    EnumeratedValue::EnumeratedUsage usage = enumeratedValue->getUsage();\r\n    if (usage != EnumeratedValue::UNKNOWNUSAGE)\r\n    {\r\n        writer.writeAttribute(QStringLiteral(\"usage\"), EnumeratedValue::usage2Str(usage));\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: EnumeratedValueWriter::writeNameGroup()\r\n//-----------------------------------------------------------------------------\r\nvoid EnumeratedValueWriter::writeNameGroup(QXmlStreamWriter& writer,\r\n    QSharedPointer<EnumeratedValue> enumeratedValue) const\r\n{\r\n    NameGroupWriter::writeNameGroup(writer, enumeratedValue);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: EnumeratedValueWriter::writeValue()\r\n//-----------------------------------------------------------------------------\r\nvoid EnumeratedValueWriter::writeValue(QXmlStreamWriter& writer, QSharedPointer<EnumeratedValue> enumeratedValue)\r\n    const\r\n{\r\n    writer.writeTextElement(QStringLiteral(\"ipxact:value\"), enumeratedValue->getValue());\r\n}\r\n"
  },
  {
    "path": "IPXACTmodels/Component/EnumeratedValueWriter.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: EnumeratedValueWriter.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 23.09.2015\r\n//\r\n// Description:\r\n// Writer class for IP-XACT enumerated value element.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef ENUMERATEDVALUEWRITER_H\r\n#define ENUMERATEDVALUEWRITER_H\r\n\r\n#include <IPXACTmodels/ipxactmodels_global.h>\r\n#include <IPXACTmodels/common/CommonItemsWriter.h>\r\n\r\n#include <QXmlStreamWriter>\r\n#include <QSharedPointer>\r\n\r\nclass EnumeratedValue;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Writer class for IP-XACT enumerated value element.\r\n//-----------------------------------------------------------------------------\r\nclass IPXACTMODELS_EXPORT EnumeratedValueWriter : public CommonItemsWriter\r\n{\r\npublic:\r\n\r\n    /*!\r\n     *  The constructor.\r\n     */\r\n    EnumeratedValueWriter();\r\n\r\n    /*!\r\n     *  The destructor.\r\n     */\r\n    ~EnumeratedValueWriter();\r\n\r\n    /*!\r\n     *  Write an enumerated value to an XML file.\r\n     *\r\n     *    @param [in] writer              The used xml writer.\r\n     *    @param [in] enumeratedValue     The enumerated value to be written.\r\n     */\r\n    void writeEnumeratedValue(QXmlStreamWriter& writer, QSharedPointer<EnumeratedValue> enumeratedValue) const;\r\n\r\nprivate:\r\n\r\n    //! No copying allowed.\r\n    EnumeratedValueWriter(EnumeratedValueWriter const& rhs);\r\n    EnumeratedValueWriter& operator=(EnumeratedValueWriter const& rhs);\r\n\r\n    /*!\r\n     *  Write the enumeration usage.\r\n     *\r\n     *    @param [in] writer              Used XML writer.\r\n     *    @param [in] enumeratedValue     The selected enumerated value item.\r\n     */\r\n    void writeUsage(QXmlStreamWriter& writer, QSharedPointer<EnumeratedValue> enumeratedValue) const;\r\n\r\n    /*!\r\n     *  Write the name group.\r\n     *\r\n     *    @param [in] writer              Used XML writer.\r\n     *    @param [in] enumeratedValue     The selected enumerated value item.\r\n     */\r\n    void writeNameGroup(QXmlStreamWriter& writer, QSharedPointer<EnumeratedValue> enumeratedValue) const;\r\n\r\n    /*!\r\n     *  Write the value.\r\n     *\r\n     *    @param [in] writer              Used XML writer.\r\n     *    @param [in] enumeratedValue     The selected enumerated value item.\r\n     */\r\n    void writeValue(QXmlStreamWriter& writer, QSharedPointer<EnumeratedValue> enumeratedValue) const;\r\n};\r\n\r\n#endif // ENUMERATEDVALUEWRITER_H"
  },
  {
    "path": "IPXACTmodels/Component/ExecutableImage.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: ExecutableImage.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Esko Pekkarinen\n// Date: 15.6.2023\n//\n// Description:\n// Implementation for ipxact:executableImage element.\n//-----------------------------------------------------------------------------\n\n#include \"ExecutableImage.h\"\n\n//-----------------------------------------------------------------------------\n// Function: ExecutableImage::ExecutableImage()\n//-----------------------------------------------------------------------------\nExecutableImage::ExecutableImage(QString const& name) :\n    NameGroup(name),\n    Extendable()\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: ExecutableImage::ExecutableImage()\n//-----------------------------------------------------------------------------\nExecutableImage::ExecutableImage( const ExecutableImage& other ):\n\tNameGroup(other),\n    Extendable(other)\n{\n    copyParameters(other);\n    copyLanguageTools(other);\n}\n\n\n//-----------------------------------------------------------------------------\n// Function: ExecutableImage::~ExecutableImage()\n//-----------------------------------------------------------------------------\nExecutableImage::~ExecutableImage()\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: ExecutableImage::operator=()\n//-----------------------------------------------------------------------------\nExecutableImage& ExecutableImage::operator=( const ExecutableImage& other )\n{\n\tif (this != &other)\n    {\n\t\tNameGroup::operator=(other);\n        Extendable::operator=(other);\n\n        parameters_->clear();\n        copyParameters(other);\n\n        copyLanguageTools(other);\n\n\t}\n\treturn *this;\n}\n\n//-----------------------------------------------------------------------------\n// Function: ExecutableImage::getImageId()\n//-----------------------------------------------------------------------------\nQString ExecutableImage::getImageId() const\n{\n    return imageId_;\n}\n\n//-----------------------------------------------------------------------------\n// Function: ExecutableImage::setImageId()\n//-----------------------------------------------------------------------------\nvoid ExecutableImage::setImageId(QString const& id)\n{\n    imageId_ = id;\n}\n\n//-----------------------------------------------------------------------------\n// Function: ExecutableImage::getImageType()\n//-----------------------------------------------------------------------------\nQString ExecutableImage::getImageType() const\n{\n    return imageType_;\n}\n\n//-----------------------------------------------------------------------------\n// Function: ExecutableImage::setImageType()\n//-----------------------------------------------------------------------------\nvoid ExecutableImage::setImageType(QString const& type)\n{\n    imageType_ = type;\n}\n\n//-----------------------------------------------------------------------------\n// Function: ExecutableImage::getParameters()\n//-----------------------------------------------------------------------------\nQSharedPointer<QList<QSharedPointer<Parameter> > > ExecutableImage::getParameters() const\n{\n    return parameters_;\n}\n\n//-----------------------------------------------------------------------------\n// Function: ExecutableImage::setParameters()\n//-----------------------------------------------------------------------------\nvoid ExecutableImage::setParameters(QSharedPointer<QList<QSharedPointer<Parameter> > > parameters)\n{\n    parameters_ = parameters;\n}\n\n//-----------------------------------------------------------------------------\n// Function: ExecutableImage::getLanguageTools()\n//-----------------------------------------------------------------------------\nQSharedPointer<LanguageTools> ExecutableImage::getLanguageTools() const\n{\n    return languageTools_;\n}\n\n//-----------------------------------------------------------------------------\n// Function: ExecutableImage::setLanguageTools()\n//-----------------------------------------------------------------------------\nvoid ExecutableImage::setLanguageTools(QSharedPointer<LanguageTools> languageTools)\n{\n    languageTools_ = languageTools;\n}\n\n//-----------------------------------------------------------------------------\n// Function: ExecutableImage::copyParameters()\n//-----------------------------------------------------------------------------\nvoid ExecutableImage::copyParameters(ExecutableImage const& other)\n{\n    for (auto const& parameter : *other.parameters_)\n    {\n        parameters_->append(QSharedPointer<Parameter>(new Parameter(*parameter)));\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: ExecutableImage::copyLanguageTools()\n//-----------------------------------------------------------------------------\nvoid ExecutableImage::copyLanguageTools(ExecutableImage const& other)\n{\n    if (other.languageTools_ == nullptr)\n    {\n        languageTools_.clear();\n    }\n    else\n    {\n        languageTools_ = other.languageTools_->clone();\n    }\n}\n"
  },
  {
    "path": "IPXACTmodels/Component/ExecutableImage.h",
    "content": "//-----------------------------------------------------------------------------\n// File: ExecutableImage.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Esko Pekkarinen\n// Date: 15.6.2023\n//\n// Description:\n// Implementation for ipxact:executableImage element.\n//-----------------------------------------------------------------------------\n\n#ifndef EXECUTABLE_IMAGE_H\n#define EXECUTABLE_IMAGE_H\n\n#include <IPXACTmodels/common/NameGroup.h>\n#include <IPXACTmodels/common/Extendable.h>\n#include <IPXACTmodels/common/Parameter.h>\n\n#include <IPXACTmodels/Component/Region.h>\n#include <IPXACTmodels/Component/LanguageTools.h>\n\n#include <IPXACTmodels/ipxactmodels_global.h>\n\n#include <QString>\n#include <QMap>\n\n//-----------------------------------------------------------------------------\n//! Implementation for ipxact:executableImage element.\n//-----------------------------------------------------------------------------\nclass IPXACTMODELS_EXPORT ExecutableImage : public NameGroup, public Extendable\n{\npublic:\n\n\t/*!\n\t *  The default constructor.\n\t *\n\t *    @param [in] name            Name of the executable image.\n\t */\n\tExecutableImage(QString const& name = QString());\n\t\n\t//! The destructor.\n\tvirtual ~ExecutableImage();\n\n\t//! The copy constructor.\n\tExecutableImage(const ExecutableImage& other);\n\n\t//! The assignment operator.\n\tExecutableImage& operator=(const ExecutableImage& other);\n\n\t/*!\n\t *  Get the imageId attribute.\n\t *\n\t *    @return The imageId attribute.\n\t */\n\tQString getImageId() const;\n\n\t/*!\n\t *  Set the imageId attribute.\n\t *\n\t *    @param [in] id The id to set.\n\t */\n\tvoid setImageId(QString const& id);\n\t\t\n\t/*!\n\t *  Get the imageType attribute.\n\t *\n\t *    @return The imageType attribute.\n\t */\n\tQString getImageType() const;\n\n\t/*!\n\t *  Set the imageType attribute.\n\t *\n\t *    @param [in] type The imageType to set.\n\t */\n\tvoid setImageType(QString const& type);\n\n    /*!\n\t *  Get the parameters of the executable image.\n\t *\n\t *    @return Pointer to a list holding the parameters for this executable image.\n\t */\n    QSharedPointer<QList<QSharedPointer<Parameter> > > getParameters() const;\n\n\t/*!\n\t *  Set the parameter for the executable image.\n\t *\n\t *    @param [in] parameters The parameters to set.\n\t */\n\tvoid setParameters(QSharedPointer<QList<QSharedPointer<Parameter> > > parameters);\n\n\t/*!\n\t *  Get the language tools defined for the executable image.\n\t *\n\t *    @return The language tools of the executable image.\n\t */\n\tQSharedPointer<LanguageTools> getLanguageTools() const;\n\n    /*!\n     *  Set the language tools for the executable image.\n     *\n     *    @param [in] languageTools The language tools to set.\n     */\n    void setLanguageTools(QSharedPointer<LanguageTools> languageTools);\n\nprivate:\n\n\t//! Copy parameters from other executable image.\n    void copyParameters(ExecutableImage const& other);\n\n    //! Copy language tools from other executable image.\n    void copyLanguageTools(ExecutableImage const& other);\n\n\t//! The imageId attribute.\n    QString imageId_;\n    \n\t//! The imageType attribute.\n\tQString imageType_;\n\n\t//! The parameters of the executable image.\n\tQSharedPointer<QList<QSharedPointer<Parameter> > > parameters_ =\n\t\tQSharedPointer<QList<QSharedPointer<Parameter> > >(new QList<QSharedPointer<Parameter> >);\n\n\t//! The language tools of the exeuctable image.\n\tQSharedPointer<LanguageTools> languageTools_ = nullptr;\n};\n\n\n#endif // EXECUTABLE_IMAGE_H"
  },
  {
    "path": "IPXACTmodels/Component/Field.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: Field.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 24.09.2015\r\n//\r\n// Description:\r\n// Describes the ipxact:field element.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"Field.h\"\r\n\r\n#include <IPXACTmodels/common/Parameter.h>\r\n#include <IPXACTmodels/Component/EnumeratedValue.h>\r\n#include <IPXACTmodels/Component/WriteValueConstraint.h>\r\n#include <IPXACTmodels/Component/MemoryArray.h>\r\n#include <IPXACTmodels/Component/FieldReference.h>\r\n\r\n#include <IPXACTmodels/utilities/Copy.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Field::Field()\r\n//-----------------------------------------------------------------------------\r\nField::Field(QString const& name) :\r\nNameGroup(name),\r\nExtendable(),\r\nid_(),\r\nisPresent_(),\r\nbitOffset_(),\r\nresets_(new QList<QSharedPointer<FieldReset> >()),\r\ntypeIdentifier_(),\r\nbitWidth_(),\r\nvolatile_(),\r\naccess_(AccessTypes::ACCESS_COUNT),\r\nenumeratedValues_(new QList<QSharedPointer<EnumeratedValue> > ()),\r\nmodifiedWrite_(General::MODIFIED_WRITE_COUNT),\r\nmodifiedWriteModify_(),\r\nwriteValueConstraint_(),\r\nreadAction_(General::READ_ACTION_COUNT),\r\nreadActionModify_(),\r\ntestable_(),\r\ntestConstraint_(General::TESTCONSTRAINT_COUNT),\r\nreserved_(),\r\nparameters_(new QList<QSharedPointer<Parameter> > ())\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Field::Field()\r\n//-----------------------------------------------------------------------------\r\nField::Field(const Field& other) :\r\nNameGroup(other),\r\nExtendable(other),\r\nid_(other.id_),\r\nisPresent_(other.isPresent_),\r\nbitOffset_(other.bitOffset_),\r\nfieldDefinitionRef_(other.fieldDefinitionRef_),\r\ntypeDefinitionsRef_(other.typeDefinitionsRef_),\r\nresets_(new QList<QSharedPointer<FieldReset> >()),\r\ntypeIdentifier_(other.typeIdentifier_),\r\nbitWidth_(other.bitWidth_),\r\nvolatile_(other.volatile_),\r\naccess_(other.access_),\r\nenumeratedValues_(new QList<QSharedPointer<EnumeratedValue> > ()),\r\nmodifiedWrite_(other.modifiedWrite_),\r\nmodifiedWriteModify_(other.modifiedWriteModify_),\r\nreadAction_(other.readAction_),\r\nreadActionModify_(other.readActionModify_),\r\ntestable_(other.testable_),\r\ntestConstraint_(other.testConstraint_),\r\nreserved_(other.reserved_),\r\nparameters_(new QList<QSharedPointer<Parameter> > ())\r\n{\r\n    Copy::copyList(other.enumeratedValues_, enumeratedValues_);\r\n    Copy::copyList(other.parameters_, parameters_);\r\n    Copy::copyList(other.resets_, resets_);\r\n    Copy::copyList(other.fieldAccessPolicies_, fieldAccessPolicies_);\r\n    copyWriteValueConstraint(other);\r\n    copyMemoryArray(other);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Field::operator=()\r\n//-----------------------------------------------------------------------------\r\nField& Field::operator=( const Field& other )\r\n{\r\n    if (this != &other)\r\n    {\r\n        NameGroup::operator=(other);\r\n        Extendable::operator=(other);\r\n        id_ = other.id_;\r\n        isPresent_ = other.isPresent_;\r\n        bitOffset_ = other.bitOffset_;\r\n        typeIdentifier_ = other.typeIdentifier_;\r\n        fieldDefinitionRef_ = other.fieldDefinitionRef_;\r\n        typeDefinitionsRef_ = other.typeDefinitionsRef_;\r\n        bitWidth_ = other.bitWidth_;\r\n        volatile_ = other.volatile_;\r\n        access_ = other.access_;\r\n        modifiedWrite_ = other.modifiedWrite_;\r\n        modifiedWriteModify_ = other.modifiedWriteModify_;\r\n        readAction_ = other.readAction_;\r\n        readActionModify_ = other.readActionModify_;\r\n        testable_ = other.testable_;\r\n        testConstraint_ = other.testConstraint_;\r\n        reserved_ = other.reserved_;\r\n\r\n        enumeratedValues_->clear();\r\n        Copy::copyList(other.enumeratedValues_, enumeratedValues_);\r\n\r\n        parameters_->clear();\r\n        Copy::copyList(other.parameters_, parameters_);\r\n\r\n        resets_->clear();\r\n        Copy::copyList(other.resets_, resets_);\r\n\r\n        fieldAccessPolicies_->clear();\r\n        Copy::copyList(other.fieldAccessPolicies_, fieldAccessPolicies_);\r\n        copyWriteValueConstraint(other);\r\n        copyMemoryArray(other);\r\n    }\r\n\r\n    return *this;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Field::~Field()\r\n//-----------------------------------------------------------------------------\r\nField::~Field()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Field::getId()\r\n//-----------------------------------------------------------------------------\r\nQString Field::getId() const\r\n{\r\n    return id_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Field::setId()\r\n//-----------------------------------------------------------------------------\r\nvoid Field::setId(QString const& id)\r\n{\r\n    id_ = id;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Field::getIsPresent()\r\n//-----------------------------------------------------------------------------\r\nQString Field::getIsPresent() const\r\n{\r\n    return isPresent_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Field::setIsPresent()\r\n//-----------------------------------------------------------------------------\r\nvoid Field::setIsPresent(QString const& newIsPresent)\r\n{\r\n    isPresent_ = newIsPresent;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Field::getMemoryArray()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<MemoryArray> Field::getMemoryArray() const\r\n{\r\n    return memoryArray_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Field::setMemoryArray()\r\n//-----------------------------------------------------------------------------\r\nvoid Field::setMemoryArray(QSharedPointer<MemoryArray> memArray)\r\n{\r\n    memoryArray_ = memArray;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Field::getBitOffset()\r\n//-----------------------------------------------------------------------------\r\nQString Field::getBitOffset() const\r\n{\r\n    return bitOffset_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Field::setBitOffset()\r\n//-----------------------------------------------------------------------------\r\nvoid Field::setBitOffset(QString const& newBitOffset)\r\n{\r\n    bitOffset_ = newBitOffset;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Field::getFieldDefinitionRef()\r\n//-----------------------------------------------------------------------------\r\nQString Field::getFieldDefinitionRef() const\r\n{\r\n    return fieldDefinitionRef_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Field::setFieldDefinitionRef()\r\n//-----------------------------------------------------------------------------\r\nvoid Field::setFieldDefinitionRef(QString const& newFieldDefRef)\r\n{\r\n    fieldDefinitionRef_ = newFieldDefRef;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Field::getTypeDefinitionsRef()\r\n//-----------------------------------------------------------------------------\r\nQString Field::getTypeDefinitionsRef() const\r\n{\r\n    return typeDefinitionsRef_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Field::setTypeDefinitionsRef()\r\n//-----------------------------------------------------------------------------\r\nvoid Field::setTypeDefinitionsRef(QString const& newTypeDefRef)\r\n{\r\n    typeDefinitionsRef_ = newTypeDefRef;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Field::getResets()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<QList<QSharedPointer<FieldReset> > > Field::getResets() const\r\n{\r\n    return resets_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Field::setResets()\r\n//-----------------------------------------------------------------------------\r\nvoid Field::setResets(QSharedPointer<QList<QSharedPointer<FieldReset> > > newResets)\r\n{\r\n    resets_->clear();\r\n    resets_ = newResets;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Field::getTypeIdentifier()\r\n//-----------------------------------------------------------------------------\r\nQString Field::getTypeIdentifier() const\r\n{\r\n    return typeIdentifier_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Field::setTypeIdentifier()\r\n//-----------------------------------------------------------------------------\r\nvoid Field::setTypeIdentifier(const QString& typeIdentifier)\r\n{\r\n    typeIdentifier_ = typeIdentifier;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Field::getBitWidth()\r\n//-----------------------------------------------------------------------------\r\nQString Field::getBitWidth() const\r\n{\r\n    return bitWidth_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Field::setBitWidth()\r\n//-----------------------------------------------------------------------------\r\nvoid Field::setBitWidth(QString const& newBitWidth)\r\n{\r\n    bitWidth_ = newBitWidth;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Field::getVolatile()\r\n//-----------------------------------------------------------------------------\r\nBooleanValue Field::getVolatile() const\r\n{\r\n    return volatile_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Field::setVolatile()\r\n//-----------------------------------------------------------------------------\r\nvoid Field::setVolatile( bool volatileValue )\r\n{\r\n    volatile_.setValue(volatileValue);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Field::getFieldReference()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<FieldReference> Field::getFieldReference() const\r\n{\r\n    return fieldReference_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Field::setFieldReference()\r\n//-----------------------------------------------------------------------------\r\nvoid Field::setFieldReference(QSharedPointer<FieldReference> fieldRef)\r\n{\r\n    fieldReference_ = fieldRef;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Field::clearVolatile()\r\n//-----------------------------------------------------------------------------\r\nvoid Field::clearVolatile()\r\n{\r\n    volatile_.setUnspecified();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Field::getAccess()\r\n//-----------------------------------------------------------------------------\r\nAccessTypes::Access Field::getAccess() const\r\n{\r\n    return access_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Field::setAccess()\r\n//-----------------------------------------------------------------------------\r\nvoid Field::setAccess( AccessTypes::Access access )\r\n{\r\n    access_ = access;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Field::getEnumeratedValues()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<QList<QSharedPointer<EnumeratedValue> > > Field::getEnumeratedValues() const\r\n{\r\n    return enumeratedValues_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Field::setEnumeratedValues()\r\n//-----------------------------------------------------------------------------\r\nvoid Field::setEnumeratedValues(QSharedPointer<QList<QSharedPointer<EnumeratedValue> > > newEnumeratedValues)\r\n{\r\n        enumeratedValues_ = newEnumeratedValues;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Field::getModifiedWrite()\r\n//-----------------------------------------------------------------------------\r\nGeneral::ModifiedWrite Field::getModifiedWrite() const\r\n{\r\n    return modifiedWrite_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Field::setModifiedWrite()\r\n//-----------------------------------------------------------------------------\r\nvoid Field::setModifiedWrite(General::ModifiedWrite const& newModifiedWriteValue)\r\n{\r\n    modifiedWrite_ = newModifiedWriteValue;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Field::getModifiedWriteModify()\r\n//-----------------------------------------------------------------------------\r\nQString Field::getModifiedWriteModify() const\r\n{\r\n    return modifiedWriteModify_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Field::setModifiedWriteModify()\r\n//-----------------------------------------------------------------------------\r\nvoid Field::setModifiedWriteModify(QString const& newModify)\r\n{\r\n    modifiedWriteModify_ = newModify;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Field::getWriteConstraint()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<WriteValueConstraint> Field::getWriteConstraint() const\r\n{\r\n    return writeValueConstraint_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Field::setWriteConstraint()\r\n//-----------------------------------------------------------------------------\r\nvoid Field::setWriteConstraint(QSharedPointer<WriteValueConstraint> newWriteValueConstraint)\r\n{\r\n    writeValueConstraint_ = newWriteValueConstraint;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Field::getReadAction()\r\n//-----------------------------------------------------------------------------\r\nGeneral::ReadAction Field::getReadAction() const\r\n{\r\n    return readAction_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Field::setReadAction()\r\n//-----------------------------------------------------------------------------\r\nvoid Field::setReadAction(General::ReadAction const& readAction)\r\n{\r\n    readAction_ = readAction;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Field::getReadActionModify()\r\n//-----------------------------------------------------------------------------\r\nQString Field::getReadActionModify() const\r\n{\r\n    return readActionModify_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Field::setReadActionModify()\r\n//-----------------------------------------------------------------------------\r\nvoid Field::setReadActionModify(QString const& newModify)\r\n{\r\n    readActionModify_ = newModify;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Field::getTestable()\r\n//-----------------------------------------------------------------------------\r\nBooleanValue Field::getTestable() const\r\n{\r\n    return testable_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Field::setTestable()\r\n//-----------------------------------------------------------------------------\r\nvoid Field::setTestable(bool newTestable)\r\n{\r\n    testable_.setValue(newTestable);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Field::clearTestable()\r\n//-----------------------------------------------------------------------------\r\nvoid Field::clearTestable()\r\n{\r\n    testable_.setUnspecified();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Field::getTestConstraint()\r\n//-----------------------------------------------------------------------------\r\nGeneral::TestConstraint Field::getTestConstraint() const\r\n{\r\n    return testConstraint_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Field::setTestConstraint()\r\n//-----------------------------------------------------------------------------\r\nvoid Field::setTestConstraint(General::TestConstraint const& newTestContraint)\r\n{\r\n    testConstraint_ = newTestContraint;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Field::getReserved()\r\n//-----------------------------------------------------------------------------\r\nQString Field::getReserved() const\r\n{\r\n    return reserved_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Field::setReserved()\r\n//-----------------------------------------------------------------------------\r\nvoid Field::setReserved(QString const& newReserved)\r\n{\r\n    reserved_ = newReserved;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Field::getParameters()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<QList<QSharedPointer<Parameter> > > Field::getParameters() const\r\n{\r\n    return parameters_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Field::setParameters()\r\n//-----------------------------------------------------------------------------\r\nvoid Field::setParameters(QSharedPointer<QList<QSharedPointer<Parameter> > > newParameters)\r\n{\r\n    parameters_->clear();\r\n    parameters_ = newParameters;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Field::getFieldAccessPolicies()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<QList<QSharedPointer<FieldAccessPolicy> > > Field::getFieldAccessPolicies() const\r\n{\r\n    return fieldAccessPolicies_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Field::setFieldAccessPolicies()\r\n//-----------------------------------------------------------------------------\r\nvoid Field::setFieldAccessPolicies(QSharedPointer<QList<QSharedPointer<FieldAccessPolicy> > > newFieldAccessPolicies)\r\n{\r\n    fieldAccessPolicies_ = newFieldAccessPolicies;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Field::copyWriteValueConstraint()\r\n//-----------------------------------------------------------------------------\r\nvoid Field::copyWriteValueConstraint(const Field& other)\r\n{\r\n    writeValueConstraint_.clear();\r\n    if (other.writeValueConstraint_)\r\n    {\r\n        writeValueConstraint_ =\r\n            QSharedPointer<WriteValueConstraint>(new WriteValueConstraint(*other.writeValueConstraint_));\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Field::copyMemoryArray()\r\n//-----------------------------------------------------------------------------\r\nvoid Field::copyMemoryArray(Field const& other)\r\n{\r\n    memoryArray_.clear();\r\n    if (other.memoryArray_)\r\n    {\r\n        memoryArray_ = QSharedPointer<MemoryArray>(new MemoryArray(*other.memoryArray_));\r\n    }\r\n}\r\n"
  },
  {
    "path": "IPXACTmodels/Component/Field.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: Field.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 24.09.2015\r\n//\r\n// Description:\r\n// Describes the ipxact:field element.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef FIELD_H\r\n#define FIELD_H\r\n\r\n#include <IPXACTmodels/generaldeclarations.h>\r\n#include <IPXACTmodels/common/AccessTypes.h>\r\n#include <IPXACTmodels/ipxactmodels_global.h>\r\n\r\n#include <IPXACTmodels/common/NameGroup.h>\r\n#include <IPXACTmodels/common/Extendable.h>\r\n#include <IPXACTmodels/common/BooleanValue.h>\r\n\r\n#include <IPXACTmodels/Component/FieldReset.h>\r\n#include <IPXACTmodels/Component/FieldReference.h>\r\n#include <IPXACTmodels/Component/FieldAccessPolicy.h>\r\n\r\n#include <QString>\r\n#include <QMap>\r\n#include <QList>\r\n#include <QSharedPointer>\r\n\r\nclass Parameter;\r\nclass EnumeratedValue;\r\nclass WriteValueConstraint;\r\nclass MemoryArray;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Describes the ipxact:field element.\r\n//-----------------------------------------------------------------------------\r\nclass IPXACTMODELS_EXPORT Field : public NameGroup, public Extendable\r\n{\r\n\r\npublic:\r\n\r\n\r\n\t/*!\r\n\t *  The constructor.\r\n\t *\r\n\t *    @param [in] name    Name of the bit field.\r\n\t */\r\n\tField(QString const& name = QString());\r\n\r\n\t/*!\r\n     *  Copy constructor.\r\n     */\r\n\tField(const Field& other);\r\n\r\n\t/*!\r\n     *  Assignment operator.\r\n     */\r\n\tField& operator=(const Field& other);\r\n\r\n\t/*!\r\n     *  The destructor.\r\n     */\r\n\tvirtual ~Field();\r\n\r\n\t/*!\r\n\t *  Get the id of the field.\r\n\t *\r\n\t *    @return The field's id.\r\n\t */\r\n\tQString getId() const;\r\n\r\n\t/*!\r\n\t *  Set the id for the field.\r\n\t *\r\n\t *    @param [in] newId   The id to set for the field.\r\n\t *\r\n\t */\r\n\tvoid setId(QString const& newId);\r\n\r\n\t/*!\r\n\t *  Get the isPresent value of the field.\r\n\t *\r\n\t *    @return The is present value.\r\n\t */\r\n\tQString getIsPresent() const;\r\n\r\n\t/*!\r\n\t *  Set the is present value for the field.\r\n\t *\r\n\t *    @param [in] newIsPresent    The new is present value.\r\n\t */\r\n\tvoid setIsPresent(QString const& newIsPresent);\r\n\r\n\t/*!\r\n\t *\tGet the memory array of the field.\r\n\t *\t    \r\n\t * \t    @return The field's memory array.\r\n\t */\r\n\tQSharedPointer<MemoryArray> getMemoryArray() const;\r\n\r\n\t/*!\r\n\t *\tSet the field's memory array.\r\n\t *  \r\n\t *    @param [in] memArray     Description\r\n\t */\r\n\tvoid setMemoryArray(QSharedPointer<MemoryArray> memArray);\r\n\r\n\t/*!\r\n\t *  Get the bit offset.\r\n\t *\r\n\t *    @return Bit offset.\r\n\t */\r\n\tQString getBitOffset() const;\r\n\r\n\t/*!\r\n\t *  Set the bit offset.\r\n\t *\r\n\t *    @param [in] newBitOffset    The new bit offset.\r\n\t */\r\n\tvoid setBitOffset(QString const& newBitOffset);\r\n\r\n    /*!\r\n     *  Get the field definition reference.\r\n     *        \r\n     *    @return The field definition reference.\r\n     */\r\n    QString getFieldDefinitionRef() const;\r\n\r\n    /*!\r\n     *  Set the field definition reference.\r\n     *  \r\n     *    @param [in] newFieldDefRef     Description\r\n     */\r\n    void setFieldDefinitionRef(QString const& newFieldDefRef);\r\n\r\n    /*!\r\n     *  Get the type definitions reference.\r\n     *\r\n     *    @return The type definitions reference.\r\n     */\r\n    QString getTypeDefinitionsRef() const;\r\n\r\n    /*!\r\n     *  Set the type definitions reference.\r\n     *  \r\n     *    @param [in] newTypeDefRef     Description\r\n     */\r\n    void setTypeDefinitionsRef(QString const& newTypeDefRef);\r\n    \r\n\t/*!\r\n\t *  Get a list of the reset for the field.\r\n\t *\r\n\t *    @return Pointer to a list containing the resets.\r\n\t */\r\n    QSharedPointer<QList<QSharedPointer<FieldReset> > > getResets() const;\r\n\r\n\t/*!\r\n\t *  Set the reset for the field.\r\n\t *\r\n\t *    @param [in] newResets   Pointer to a list containing the new resets.\r\n\t */\r\n\tvoid setResets(QSharedPointer<QList<QSharedPointer<FieldReset> > > newResets);\r\n\r\n\t/*!\r\n\t *  Get the typeIdentifier.\r\n\t *\r\n\t *    @return The typeIdentifier.\r\n\t */\r\n\tQString getTypeIdentifier() const;\r\n\r\n\t/*!\r\n\t *  Set the typeIdentifier for the field.\r\n\t *\r\n\t *    @param [in] newTypeIdentifier   The new typeIdentifier.\r\n\t */\r\n\tvoid setTypeIdentifier(QString const& newTypeIdentifier);\r\n\r\n\t/*!\r\n\t *  Get the bit width.\r\n\t *\r\n\t *    @return Bit width.\r\n\t */\r\n\tQString getBitWidth() const;\r\n\r\n\t/*!\r\n\t *  Set the bit width for the field.\r\n\t *\r\n\t *    @param [in] newBitwidth     The new bit width.\r\n\t */\r\n\tvoid setBitWidth(QString const& newBitWidth);\r\n\r\n\t/*!\r\n\t *  Get the volatile state of the field.\r\n\t *\r\n\t *    @return The volatile state.\r\n\t */\r\n\tBooleanValue getVolatile() const;\r\n\r\n\t/*!\r\n\t *  Set the volatile value to unspecified.\r\n\t */\r\n\tvoid clearVolatile();\r\n\r\n\t/*!\r\n\t *  Set the volatile state for the field.\r\n\t *\r\n\t *    @param [in] volatileValue   The new volatile state to set.\r\n\t */\r\n\tvoid setVolatile(bool volatileValue);\r\n\r\n\t/*!\r\n\t *\tGet the field reference.\r\n\t *\t    \r\n\t * \t    @return\t\tThe field reference.\r\n\t */\r\n\tQSharedPointer<FieldReference> getFieldReference() const;\r\n\r\n\t/*!\r\n\t *\tSet the field reference.\r\n\t *  \r\n\t *    @param [in] fieldRef     The new field reference.\r\n\t */\r\n\tvoid setFieldReference(QSharedPointer<FieldReference> fieldRef);\r\n\r\n\t/*!\r\n\t *  Get the access type of the field.\r\n\t *\r\n\t *    @return The access type of the field.\r\n\t */\r\n\tAccessTypes::Access getAccess() const;\r\n\r\n\t/*!\r\n\t *  Set the access type for the field.\r\n\t *\r\n\t *    @param [in] access  The access type to set.\r\n\t */\r\n\tvoid setAccess(AccessTypes::Access access);\r\n\r\n\t/*!\r\n\t *  Get the list of the enumeratedValues.\r\n\t *\r\n\t *    @return Pointer to a list containing the enumerated values.\r\n\t */\r\n\tQSharedPointer<QList<QSharedPointer<EnumeratedValue> > > getEnumeratedValues() const;\r\n\r\n\t/*!\r\n\t *  Set the enumerated values for the field.\r\n\t *\r\n\t *    @param [in] newEnumeratedValues     Pointer to a list containing the enumerated values.\r\n\t */\r\n\tvoid setEnumeratedValues(QSharedPointer<QList<QSharedPointer<EnumeratedValue> > > newEnumeratedValues);\r\n\r\n\t/*!\r\n\t *  Get the modified write value setting of the field.\r\n\t *\r\n\t *    @return The modified write value setting.\r\n\t */\r\n\tGeneral::ModifiedWrite getModifiedWrite() const;\r\n\r\n\t/*!\r\n\t *  Set the modified write value setting for the field.\r\n\t *\r\n\t *    @param [in] newModWriteValue    The value to set.\r\n\t *\r\n\t */\r\n\tvoid setModifiedWrite(General::ModifiedWrite const& newModifiedWriteValue);\r\n\r\n\t/*!\r\n\t *  Get the modify attribute of the modified write value.\r\n\t *\r\n\t *    @return The modify attribute of the modified write value.\r\n\t */\r\n\tQString getModifiedWriteModify() const;\r\n\r\n\t/*!\r\n\t *  Set the modify attribute of the modified write value.\r\n\t *\r\n\t *    @param [in] newModify   The new modified attribute.\r\n\t */\r\n\tvoid setModifiedWriteModify(QString const& newModify);\r\n\r\n\t/*!\r\n\t *  Get the write constraint of the field.\r\n\t *\r\n\t *    @return Pointer to the write constraint.\r\n\t */\r\n\tQSharedPointer<WriteValueConstraint> getWriteConstraint() const;\r\n\r\n\t/*!\r\n\t *  Set the write value constraint.\r\n\t *\r\n\t *    @param [in] newWriteValueConstraint     Pointer to the new write value constraint.\r\n\t */\r\n\tvoid setWriteConstraint(QSharedPointer<WriteValueConstraint> newWriteValueConstraint);\r\n\r\n\t/*!\r\n\t *  Get the read action setting of the field.\r\n\t *\r\n\t *    @return The read action setting.\r\n\t */\r\n\tGeneral::ReadAction getReadAction() const;\r\n\r\n\t/*!\r\n\t *  Set the read action setting for the field.\r\n\t *\r\n\t *    @param [in] readAction  The new read action -value.\r\n\t */\r\n\tvoid setReadAction(General::ReadAction const& readAction);\r\n\r\n\t/*!\r\n\t *  Get the read action modify attribute.\r\n\t *\r\n\t *    @return The read action modify attribute.\r\n\t */\r\n\tQString getReadActionModify() const;\r\n\r\n\t/*!\r\n\t *  Set the read action modify attribute.\r\n\t *\r\n\t *    @param [in] newModify   The new modify attribute.\r\n\t */\r\n\tvoid setReadActionModify(QString const& newModify);\r\n\r\n\t/*!\r\n\t *  Get the testable setting of the field.\r\n\t *\r\n\t *    @return The testable setting.\r\n\t */\r\n\tBooleanValue getTestable() const;\r\n\r\n\t/*!\r\n\t *  Set the testable setting for the field.\r\n\t *\r\n\t *    @param [in] newTestable     The new testable value.\r\n\t */\r\n\tvoid setTestable(bool newTestable);\r\n\r\n\t/*!\r\n\t *  Clear the testable value of the field.\r\n\t */\r\n\tvoid clearTestable();\r\n\r\n\t/*!\r\n\t *  Get the test constraint setting of the field.\r\n\t *\r\n\t *    @return The test constraint of the field.\r\n\t */\r\n\tGeneral::TestConstraint getTestConstraint() const;\r\n\r\n\t/*!\r\n\t *  Set the test constraint for the field.\r\n\t *\r\n\t *    @param [in] testContraint   The new test constraint.\r\n\t */\r\n\tvoid setTestConstraint(General::TestConstraint const& newTestContraint);\r\n\r\n\t/*!\r\n\t *  Get the reserved value.\r\n\t *\r\n\t *    @return The reserved value.\r\n\t */\r\n\tQString getReserved() const;\r\n\r\n\t/*!\r\n\t *  Set the reserved value.\r\n\t *\r\n\t *    @param [in] newReserved     The new reserved value.\r\n\t */\r\n\tvoid setReserved(QString const& newReserved);\r\n\r\n\t/*!\r\n\t *  Get a list of the parameters for the field.\r\n\t *\r\n\t *    @return Pointer to a list containing the parameters.\r\n\t */\r\n\tQSharedPointer<QList<QSharedPointer<Parameter> > > getParameters() const;\r\n\r\n\t/*!\r\n\t *  Set the parameters for the field.\r\n\t *\r\n\t *    @param [in] newParameters   Pointer to a list containing the new parameters.\r\n\t */\r\n\tvoid setParameters(QSharedPointer<QList<QSharedPointer<Parameter> > > newParameters);\r\n\r\n\t/*!\r\n\t *\tGet the field access policies of the field.\r\n\t *\t    \r\n\t * \t    @return Pointer to a list containing the field access policies.\r\n\t */\r\n\tQSharedPointer<QList<QSharedPointer<FieldAccessPolicy> > > getFieldAccessPolicies() const;\r\n\r\n\t/*!\r\n\t *\tSet the field access policies for the field.\r\n\t *  \r\n\t *    @param [in] newFieldAccessPolicies     The new field access policies.\r\n\t */\r\n\tvoid setFieldAccessPolicies(QSharedPointer<QList<QSharedPointer<FieldAccessPolicy> > > newFieldAccessPolicies);\r\n\r\nprivate:\r\n\r\n\t/*!\r\n\t *  Copy the write value constraint.\r\n\t *\r\n\t *    @param [in] other   The copied field.\r\n\t */\r\n\tvoid copyWriteValueConstraint(const Field& other);\r\n\r\n\tvoid copyMemoryArray(Field const& other);\r\n\r\n\t//-----------------------------------------------------------------------------\r\n\t// Data.\r\n\t//-----------------------------------------------------------------------------\r\n\r\n\t//! A unique id.\r\n\tQString id_;\r\n\r\n\t//! The presence of the field.\r\n\tQString isPresent_;\r\n\r\n    //! The field's memory array.\r\n    QSharedPointer<MemoryArray> memoryArray_;\r\n\r\n\t//! Describes the offset where this bit field starts.\r\n\tQString bitOffset_;\r\n\r\n    //! A reference to a fieldDefinition inside typeDefinitions.\r\n    QString fieldDefinitionRef_;\r\n\r\n    //! A refrence to a typeDefinitions containing the fieldDefinition.\r\n    QString typeDefinitionsRef_;\r\n\r\n    //! List of resets.\r\n\tQSharedPointer<QList<QSharedPointer<FieldReset> > > resets_;\r\n\r\n\t// Field elements with the same identifier contain the same information for the field definition group.\r\n\tQString typeIdentifier_;\r\n\r\n\t//! Width of the field.\r\n\tQString bitWidth_;\r\n\r\n\t//! Contains the volatile value for the field.\r\n\tBooleanValue volatile_;\r\n\r\n\t//! Contains the access type of the field.\r\n\tAccessTypes::Access access_;\r\n\r\n\t//! Pointer to a list containing the enumerated values.\r\n\tQSharedPointer<QList<QSharedPointer<EnumeratedValue> > > enumeratedValues_;\r\n\r\n\t//! Contains the modified write setting for the field.\r\n\tGeneral::ModifiedWrite modifiedWrite_;\r\n\r\n\t//! User defined value for a modify modified write.\r\n\tQString modifiedWriteModify_;\r\n\r\n\t//! Pointer to the write value constraint.\r\n\tQSharedPointer<WriteValueConstraint> writeValueConstraint_{ nullptr };\r\n\r\n\t//! Contains the read action setting for the field.\r\n\tGeneral::ReadAction readAction_;\r\n\r\n\t//! User defined additional information for a modify read action.\r\n\tQString readActionModify_;\r\n\r\n\t//! Contains the testable setting for the field.\r\n\tBooleanValue testable_;\r\n\r\n\t//! Contains the test constraint setting for the field.\r\n\tGeneral::TestConstraint testConstraint_;\r\n\r\n\t//! Indicates whether this field is reserved or not.\r\n\tQString reserved_;\r\n\r\n\t//! Contains the parameters.\r\n\tQSharedPointer<QList<QSharedPointer<Parameter> > > parameters_;\r\n\r\n\t//! Reference to another field (ipxact:aliasOf).\r\n\tQSharedPointer<FieldReference> fieldReference_;\r\n\t\r\n\t//! The field access policies of the field, for standard revision 2022.\r\n\tQSharedPointer<QList<QSharedPointer<FieldAccessPolicy> > > fieldAccessPolicies_ = \r\n\t\tQSharedPointer<QList<QSharedPointer<FieldAccessPolicy> > >(new QList<QSharedPointer<FieldAccessPolicy> > ());\r\n};\r\n\r\nQ_DECLARE_METATYPE(QSharedPointer<Field>);\r\n\r\n#endif // FIELD_H\r\n"
  },
  {
    "path": "IPXACTmodels/Component/FieldAccessPolicy.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: FieldAccessPolicy.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Anton Hagqvist\n// Date: 31.7.2023\n//\n// Description:\n// Describes the ipxact:fieldAccessPolicy element.\n//-----------------------------------------------------------------------------\n\n#include \"FieldAccessPolicy.h\"\n\n#include <IPXACTmodels/utilities/Copy.h>\n\n//-----------------------------------------------------------------------------\n// Function: FieldAccessPolicy::AccessRestriction::AccessRestriction()\n//-----------------------------------------------------------------------------\nFieldAccessPolicy::AccessRestriction::AccessRestriction(AccessRestriction const& other) :\n    modeRefs_(new QList<QSharedPointer<ModeReference> >()),\n    readAccessMask_(other.readAccessMask_),\n    writeAccessMask_(other.writeAccessMask_)\n{\n    Copy::copyList(other.modeRefs_, modeRefs_);\n}\n\n//-----------------------------------------------------------------------------\n// Function: FieldAccessPolicy::AccessRestriction::operator=()\n//-----------------------------------------------------------------------------\nFieldAccessPolicy::AccessRestriction& FieldAccessPolicy::AccessRestriction::operator=(FieldAccessPolicy::AccessRestriction const& other)\n{\n    if (this != &other)\n    {\n        readAccessMask_ = other.readAccessMask_;\n        writeAccessMask_ = other.writeAccessMask_;\n\n        modeRefs_->clear();\n        Copy::copyList(other.modeRefs_, modeRefs_);\n    }\n\n    return *this;\n}\n\n//-----------------------------------------------------------------------------\n// Function: FieldAccessPolicy::FieldAccessPolicy()\n//-----------------------------------------------------------------------------\nFieldAccessPolicy::FieldAccessPolicy():\n    AccessPolicy()\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: FieldAccessPolicy::FieldAccessPolicy()\n//-----------------------------------------------------------------------------\nFieldAccessPolicy::FieldAccessPolicy(FieldAccessPolicy const& other) :\n    AccessPolicy(other),\n    fieldAccessPolicyDefinitionRef_(other.fieldAccessPolicyDefinitionRef_),\n    fieldAccessPolicyTypeDefinitionRef_(other.fieldAccessPolicyTypeDefinitionRef_),\n    modifiedWrite_(other.modifiedWrite_),\n    modifiedWriteModify_(other.modifiedWriteModify_),\n    writeValueConstraint_(),\n    readAction_(other.readAction_),\n    readActionModify_(other.readActionModify_),\n    readResponse_(other.readResponse_),\n    broadcasts_(new QList<QSharedPointer<FieldReference> >()),\n    accessRestrictions_(new QList<QSharedPointer<AccessRestriction> >()),\n    testable_(other.testable_),\n    testConstraint_(other.testConstraint_),\n    reserved_(other.reserved_)\n{\n    Copy::copyList(other.broadcasts_, broadcasts_);\n    Copy::copyList(other.accessRestrictions_, accessRestrictions_);\n    copyWriteValueConstraint(other);\n}\n\n//-----------------------------------------------------------------------------\n// Function: FieldAccessPolicy::operator=()\n//-----------------------------------------------------------------------------\nFieldAccessPolicy& FieldAccessPolicy::operator=(FieldAccessPolicy const& other)\n{\n    if (this != &other)\n    {\n        AccessPolicy::operator=(other);\n        fieldAccessPolicyDefinitionRef_ = other.fieldAccessPolicyDefinitionRef_;\n        fieldAccessPolicyTypeDefinitionRef_ = other.fieldAccessPolicyTypeDefinitionRef_;\n        modifiedWrite_ = other.modifiedWrite_;\n        modifiedWriteModify_ = other.modifiedWriteModify_;\n        readAction_ = other.readAction_;\n        readActionModify_ = other.readActionModify_;\n        readResponse_ = other.readResponse_;\n        testable_ = other.testable_;\n        testConstraint_ = other.testConstraint_;\n        reserved_ = other.reserved_;\n\n        broadcasts_->clear();\n        Copy::copyList(other.broadcasts_, broadcasts_);\n\n        accessRestrictions_->clear();\n        Copy::copyList(other.accessRestrictions_, accessRestrictions_);\n        copyWriteValueConstraint(other);\n    }\n\n    return *this;\n}\n\n//-----------------------------------------------------------------------------\n// Function: FieldAccessPolicy::getModifiedWrite()\n//-----------------------------------------------------------------------------\nGeneral::ModifiedWrite FieldAccessPolicy::getModifiedWrite() const\n{\n    return modifiedWrite_;\n}\n\n//-----------------------------------------------------------------------------\n// Function: FieldAccessPolicy::setModifiedWrite()\n//-----------------------------------------------------------------------------\nvoid FieldAccessPolicy::setModifiedWrite(General::ModifiedWrite modifiedWrite)\n{\n    modifiedWrite_ = modifiedWrite;\n}\n\n//-----------------------------------------------------------------------------\n// Function: FieldAccessPolicy::getModifiedWriteModify()\n//-----------------------------------------------------------------------------\nQString FieldAccessPolicy::getModifiedWriteModify() const\n{\n    return modifiedWriteModify_;\n}\n\n//-----------------------------------------------------------------------------\n// Function: FieldAccessPolicy::setModifiedWriteModify()\n//-----------------------------------------------------------------------------\nvoid FieldAccessPolicy::setModifiedWriteModify(QString const& modify)\n{\n    modifiedWriteModify_ = modify;\n}\n\n//-----------------------------------------------------------------------------\n// Function: FieldAccessPolicy::getWriteValueConstraint()\n//-----------------------------------------------------------------------------\nQSharedPointer<WriteValueConstraint> FieldAccessPolicy::getWriteValueConstraint() const\n{\n    return writeValueConstraint_;\n}\n\n//-----------------------------------------------------------------------------\n// Function: FieldAccessPolicy::setWriteValueConstraint()\n//-----------------------------------------------------------------------------\nvoid FieldAccessPolicy::setWriteValueConstraint(QSharedPointer<WriteValueConstraint> constraint)\n{\n    writeValueConstraint_ = constraint;\n}\n\n//-----------------------------------------------------------------------------\n// Function: FieldAccessPolicy::getReadAction()\n//-----------------------------------------------------------------------------\nGeneral::ReadAction FieldAccessPolicy::getReadAction() const\n{\n    return readAction_;\n}\n\n//-----------------------------------------------------------------------------\n// Function: FieldAccessPolicy::setReadAction()\n//-----------------------------------------------------------------------------\nvoid FieldAccessPolicy::setReadAction(General::ReadAction readAction)\n{\n    readAction_ = readAction;\n}\n\n//-----------------------------------------------------------------------------\n// Function: FieldAccessPolicy::getReadActionModify()\n//-----------------------------------------------------------------------------\nQString FieldAccessPolicy::getReadActionModify() const\n{\n    return readActionModify_;\n}\n\n//-----------------------------------------------------------------------------\n// Function: FieldAccessPolicy::setReadActionModify()\n//-----------------------------------------------------------------------------\nvoid FieldAccessPolicy::setReadActionModify(QString const& readActionModify)\n{\n    readActionModify_ = readActionModify;\n}\n\n//-----------------------------------------------------------------------------\n// Function: FieldAccessPolicy::getTestable()\n//-----------------------------------------------------------------------------\nBooleanValue FieldAccessPolicy::getTestable() const\n{\n    return testable_;\n}\n\n//-----------------------------------------------------------------------------\n// Function: FieldAccessPolicy::setTestable()\n//-----------------------------------------------------------------------------\nvoid FieldAccessPolicy::setTestable(bool newTestable)\n{\n    testable_.setValue(newTestable);\n}\n\n//-----------------------------------------------------------------------------\n// Function: FieldAccessPolicy::clearTestable()\n//-----------------------------------------------------------------------------\nvoid FieldAccessPolicy::clearTestable()\n{\n    testable_.setUnspecified();\n}\n\n//-----------------------------------------------------------------------------\n// Function: FieldAccessPolicy::getReadResponse()\n//-----------------------------------------------------------------------------\nQString FieldAccessPolicy::getReadResponse() const\n{\n    return readResponse_;\n}\n\n//-----------------------------------------------------------------------------\n// Function: FieldAccessPolicy::setReadResponse()\n//-----------------------------------------------------------------------------\nvoid FieldAccessPolicy::setReadResponse(QString const& response)\n{\n    readResponse_ = response;\n}\n\n//-----------------------------------------------------------------------------\n// Function: FieldAccessPolicy::getTestConstraint()\n//-----------------------------------------------------------------------------\nGeneral::TestConstraint FieldAccessPolicy::getTestConstraint() const\n{\n    return testConstraint_;\n}\n\n//-----------------------------------------------------------------------------\n// Function: FieldAccessPolicy::setTestConstraint()\n//-----------------------------------------------------------------------------\nvoid FieldAccessPolicy::setTestConstraint(General::TestConstraint constraint)\n{\n    testConstraint_ = constraint;\n}\n\n// Function: FieldAccessPolicy::getReserved()\n//-----------------------------------------------------------------------------\nQString FieldAccessPolicy::getReserved() const\n{\n    return reserved_;\n}\n\n//-----------------------------------------------------------------------------\n// Function: FieldAccessPolicy::setReserved()\n//-----------------------------------------------------------------------------\nvoid FieldAccessPolicy::setReserved(QString const& reserved)\n{\n    reserved_ = reserved;\n}\n\n//-----------------------------------------------------------------------------\n// Function: FieldAccessPolicy::getFieldAccessPolicyDefinitionRef()\n//-----------------------------------------------------------------------------\nQString FieldAccessPolicy::getFieldAccessPolicyDefinitionRef() const\n{\n    return fieldAccessPolicyDefinitionRef_;\n}\n\n//-----------------------------------------------------------------------------\n// Function: FieldAccessPolicy::setFieldAccessPolicyDefinitionRef()\n//-----------------------------------------------------------------------------\nvoid FieldAccessPolicy::setFieldAccessPolicyDefinitionRef(QString const& definitionRef)\n{\n    fieldAccessPolicyDefinitionRef_ = definitionRef;\n}\n\n//-----------------------------------------------------------------------------\n// Function: FieldAccessPolicy::getFieldAccessPolicyTypeDefinitionRef()\n//-----------------------------------------------------------------------------\nQString FieldAccessPolicy::getFieldAccessPolicyTypeDefinitionRef() const\n{\n    return fieldAccessPolicyTypeDefinitionRef_;\n}\n\n//-----------------------------------------------------------------------------\n// Function: FieldAccessPolicy::setFieldAccessPolicyTypeDefinitionRef()\n//-----------------------------------------------------------------------------\nvoid FieldAccessPolicy::setFieldAccessPolicyTypeDefinitionRef(QString const& typeDefRef)\n{\n    fieldAccessPolicyTypeDefinitionRef_ = typeDefRef;\n}\n\n//-----------------------------------------------------------------------------\n// Function: FieldAccessPolicy::getAccessRestrictions()\n//-----------------------------------------------------------------------------\nQSharedPointer<QList<QSharedPointer<FieldAccessPolicy::FieldAccessPolicy::AccessRestriction> > > FieldAccessPolicy::getAccessRestrictions() const\n{\n    return accessRestrictions_;\n}\n\n//-----------------------------------------------------------------------------\n// Function: FieldAccessPolicy::setAccessRestrictions()\n//-----------------------------------------------------------------------------\nvoid FieldAccessPolicy::setAccessRestrictions(QSharedPointer<QList<QSharedPointer<AccessRestriction> > > newAccessRestrictions)\n{\n    accessRestrictions_ = newAccessRestrictions;\n}\n\n//-----------------------------------------------------------------------------\n// Function: FieldAccessPolicy::copyWriteValueConstraint()\n//-----------------------------------------------------------------------------\nvoid FieldAccessPolicy::copyWriteValueConstraint(FieldAccessPolicy const& other)\n{\n    writeValueConstraint_.clear();\n    if (other.writeValueConstraint_)\n    {\n        writeValueConstraint_ = QSharedPointer<WriteValueConstraint>(new WriteValueConstraint(*other.writeValueConstraint_));\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: FieldAccessPolicy::getBroadcasts()\n//-----------------------------------------------------------------------------\nQSharedPointer<QList<QSharedPointer<FieldReference> > > FieldAccessPolicy::getBroadcasts() const\n{\n    return broadcasts_;\n}\n\n//-----------------------------------------------------------------------------\n// Function: FieldAccessPolicy::setBroadcasts()\n//-----------------------------------------------------------------------------\nvoid FieldAccessPolicy::setBroadcasts(QSharedPointer<QList<QSharedPointer<FieldReference> > > broadcasts)\n{\n    broadcasts_ = broadcasts;\n}\n\n"
  },
  {
    "path": "IPXACTmodels/Component/FieldAccessPolicy.h",
    "content": "//-----------------------------------------------------------------------------\n// File: FieldAccessPolicy.h\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Anton Hagqvist\n// Date: 28.7.2023\n//\n// Description:\n// Describes the ipxact:fieldAccessPolicy element.\n//-----------------------------------------------------------------------------\n\n#ifndef FIELDACCESSPOLICY_H\n#define FIELDACCESSPOLICY_H\n\n#include \"AccessPolicy.h\"\n#include \"FieldReference.h\"\n#include \"ModeReference.h\"\n#include \"WriteValueConstraint.h\"\n\n#include <IPXACTmodels/ipxactmodels_global.h>\n#include <IPXACTmodels/generaldeclarations.h>\n\n#include <IPXACTmodels/common/BooleanValue.h>\n\nclass IPXACTMODELS_EXPORT FieldAccessPolicy : public AccessPolicy\n{\npublic:\n\n    //! Describes ipxact:accessRestriction\n    struct IPXACTMODELS_EXPORT AccessRestriction\n    {\n        //! The operating modes for which the access restriction is active.\n        QSharedPointer<QList<QSharedPointer<ModeReference> > > modeRefs_ = \n            QSharedPointer<QList<QSharedPointer<ModeReference> > >(new QList<QSharedPointer<ModeReference> >());\n\n        //! Which bits of the field are readable.\n        QString readAccessMask_;\n\n        //! Which bits of the field are writable.\n        QString writeAccessMask_;\n\n        AccessRestriction() = default;\n\n        AccessRestriction(AccessRestriction const& other);\n\n        AccessRestriction& operator=(AccessRestriction const& other);\n    };\n\n    FieldAccessPolicy();\n\n    FieldAccessPolicy(FieldAccessPolicy const& other);\n    FieldAccessPolicy& operator=(FieldAccessPolicy const& other);\n    \n    virtual ~FieldAccessPolicy() = default;\n\n    /*!\n     *  Get the modified write value setting of the field.\n     *\n     *    @return The modified write value setting.\n     */\n    General::ModifiedWrite getModifiedWrite() const;\n\n    /*!\n     *  Set the modified write value setting for the field.\n     *\n     *    @param [in] modifiedWrite    The value to set.\n     *\n     */\n    void setModifiedWrite(General::ModifiedWrite modifiedWrite);\n\n    /*!\n     *  Get the modify attribute of the modified write value.\n     *\n     *    @return The modify attribute of the modified write value.\n     */\n    QString getModifiedWriteModify() const;\n\n    /*!\n     *  Set the modify attribute of the modified write value.\n     *\n     *    @param [in] modify   The new modified attribute.\n     */\n    void setModifiedWriteModify(QString const& modify);\n\n    /*!\n     *  Get the write constraint of the field.\n     *\n     *    @return Pointer to the write constraint.\n     */\n    QSharedPointer<WriteValueConstraint> getWriteValueConstraint() const;\n\n    /*!\n     *  Set the write value constraint.\n     *\n     *    @param [in] constraint     Pointer to the new write value constraint.\n     */\n    void setWriteValueConstraint(QSharedPointer<WriteValueConstraint> constraint);\n\n    /*!\n     *  Get the read action setting of the field.\n     *\n     *    @return The read action setting.\n     */\n    General::ReadAction getReadAction() const;\n\n    /*!\n     *  Set the read action setting for the field.\n     *\n     *    @param [in] readAction  The new read action -value.\n     */\n    void setReadAction(General::ReadAction readAction);\n\n    /*!\n     *  Get the read action modify attribute.\n     *\n     *    @return The read action modify attribute.\n     */\n    QString getReadActionModify() const;\n\n    /*!\n     *  Set the read action modify attribute.\n     *\n     *    @param [in] readActionModify   The new modify attribute.\n     */\n    void setReadActionModify(QString const& readActionModify);\n\n    /*!\n     *  Get the testable setting of the field.\n     *\n     *    @return The testable setting.\n     */\n    BooleanValue getTestable() const;\n\n    /*!\n     *  Set the testable setting for the field.\n     *\n     *    @param [in] newTestable     The new testable value.\n     */\n    void setTestable(bool newTestable);\n\n    /*!\n     *  Clear the testable value of the field.\n     */\n    void clearTestable();\n\n    /*!\n     *\tGet the read response of the field.\n     *\t    \n     * \t    @return  The read response of the field.\n     */\n    QString getReadResponse() const;\n\n    /*!\n     *\tSet the read response of the field.\n     *  \n     *    @param [in] response     Description\n     */\n    void setReadResponse(QString const& response);\n\n    /*!\n     *\tGet the broadcasts of the field.\n     *  \n     * \t    @return The broadcasts of the field.\n     */\n    QSharedPointer<QList<QSharedPointer<FieldReference> > > getBroadcasts() const;\n\n    /*!\n     *\tSet the broadcasts of the field.\n     *  \n     *    @param [in] broadcasts     Description\n     */\n    void setBroadcasts(QSharedPointer<QList<QSharedPointer<FieldReference> > > broadcasts);\n\n    /*!\n     *  Get the test constraint setting of the field.\n     *\n     *    @return The test constraint of the field.\n     */\n    General::TestConstraint getTestConstraint() const;\n\n    /*!\n     *  Set the test constraint for the field.\n     *\n     *    @param [in] testContraint   The new test constraint.\n     */\n    void setTestConstraint(General::TestConstraint constraint);\n\n    /*!\n     *  Get the reserved value.\n     *\n     *    @return The reserved value.\n     */\n    QString getReserved() const;\n\n    /*!\n     *  Set the reserved value.\n     *\n     *    @param [in] newReserved     The new reserved value.\n     */\n    void setReserved(QString const& reserved);\n\n    /*!\n     *\tGet the field access policy definition reference.\n     *  \n     * \t    @return The defintion reference.\n     */\n    QString getFieldAccessPolicyDefinitionRef() const;\n\n    /*!\n     *\tSet the field access policy definition reference.\n     *  \n     *    @param [in] definitionRef     The definition reference to set.\n     */\n    void setFieldAccessPolicyDefinitionRef(QString const& definitionRef);\n\n    /*!\n     *\tGet the field access policy type definitions reference.\n     *\t    \n     * \t    @return The type definitions reference.\n     */\n    QString getFieldAccessPolicyTypeDefinitionRef() const;\n\n    /*!\n     *\tSet the field access policy type definitions reference.\n     *  \n     *    @param [in] typeDefRef     The type definitions reference to set.\n     */\n    void setFieldAccessPolicyTypeDefinitionRef(QString const& typeDefRef);\n\n    /*!\n     *\tGet the access restrictions of the field access policy.\n     *  \n     * \t    @return The list of access restrictions.\n     */\n    QSharedPointer<QList<QSharedPointer<AccessRestriction> > > getAccessRestrictions() const;\n\n    /*!\n     *\tSet the access restrictions of the field access policy.\n     *  \n     *    @param [in] newAccessRestrictions     The access restrictions to set.\n     */\n    void setAccessRestrictions(QSharedPointer<QList<QSharedPointer<AccessRestriction> > > newAccessRestrictions);\n\nprivate:\n    \n    /*!\n     *\tCopy the write value constraint of the field access policy.\n     */\n    void copyWriteValueConstraint(FieldAccessPolicy const& other);\n\n    //-----------------------------------------------------------------------------\n    // Data.\n    //-----------------------------------------------------------------------------\n\n    //! Reference to a field access policy definition.\n    QString fieldAccessPolicyDefinitionRef_;\n\n    //! Reference to a typeDefinitions element through an external type definition.\n    QString fieldAccessPolicyTypeDefinitionRef_;\n\n    //! Contains the modified write setting for the field.\n    General::ModifiedWrite modifiedWrite_ = General::MODIFIED_WRITE_COUNT;\n\n    //! User defined value for a modify modified write.\n    QString modifiedWriteModify_;\n\n    //! Pointer to the write value constraint.\n    QSharedPointer<WriteValueConstraint> writeValueConstraint_;\n\n    //! Contains the read action setting for the field.\n    General::ReadAction readAction_ = General::READ_ACTION_COUNT;\n\n    //! User defined additional information for a modify read action.\n    QString readActionModify_;\n\n    //! The read response value.\n    QString readResponse_;\n\n    //! The fields that write operations to this field are broadcast to.\n    QSharedPointer<QList<QSharedPointer<FieldReference> > > broadcasts_ = \n        QSharedPointer<QList<QSharedPointer<FieldReference> > >(new QList<QSharedPointer<FieldReference> >());\n\n    //! Describes which bits can be read from and written to for different modes.\n    QSharedPointer<QList<QSharedPointer<AccessRestriction> > > accessRestrictions_ = \n        QSharedPointer<QList<QSharedPointer<AccessRestriction> > >(new QList<QSharedPointer<AccessRestriction> >());\n\n    //! Contains the testable setting for the field.\n    BooleanValue testable_;\n\n    //! Contains the test constraint setting for the field.\n    General::TestConstraint testConstraint_ = General::TESTCONSTRAINT_COUNT; \n\n    //! Indicates whether this field is reserved or not.\n    QString reserved_;\n\n};\n\n#endif // FIELDACCESSPOLICY_H\n"
  },
  {
    "path": "IPXACTmodels/Component/FieldAccessPolicyReader.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: FieldAccessPolicyReader.h\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Anton Hagqvist\n// Date: 31.7.2023\n//\n// Description:\n// Reader for ipxact:fieldAccessPolicy.\n//-----------------------------------------------------------------------------\n\n#include \"FieldAccessPolicyReader.h\"\n#include \"FieldReferenceReader.h\"\n\n#include <IPXACTmodels/common/CommonItemsReader.h>\n\n//-----------------------------------------------------------------------------\n// Function: FieldAccessPolicyReader::createFieldAccessPolicyFrom()\n//-----------------------------------------------------------------------------\nQSharedPointer<FieldAccessPolicy> FieldAccessPolicyReader::createFieldAccessPolicyFrom(\n    QDomNode const& fieldAccessPolicyNode)\n{\n    QSharedPointer<FieldAccessPolicy> fieldAccessPolicy(new FieldAccessPolicy());\n\n    Details::parseModeRefs(fieldAccessPolicyNode, fieldAccessPolicy);\n\n    Details::parseDefinitionRef(fieldAccessPolicyNode, fieldAccessPolicy);\n\n    Details::parseAccess(fieldAccessPolicyNode, fieldAccessPolicy);\n\n    Details::parseModifiedWriteValue(fieldAccessPolicyNode, fieldAccessPolicy);\n\n    Details::parseWriteValueConstraint(fieldAccessPolicyNode, fieldAccessPolicy);\n\n    Details::parseReadAction(fieldAccessPolicyNode, fieldAccessPolicy);\n\n    Details::parseReadResponse(fieldAccessPolicyNode, fieldAccessPolicy);\n\n    Details::parseBroadcasts(fieldAccessPolicyNode, fieldAccessPolicy);\n\n    Details::parseAccessRestrictions(fieldAccessPolicyNode, fieldAccessPolicy);\n\n    Details::parseTestable(fieldAccessPolicyNode, fieldAccessPolicy);\n\n    Details::parseReserved(fieldAccessPolicyNode, fieldAccessPolicy);\n\n    CommonItemsReader::parseVendorExtensions(fieldAccessPolicyNode, fieldAccessPolicy);\n\n    return fieldAccessPolicy;\n}\n\n//-----------------------------------------------------------------------------\n// Function: FieldAccessPolicyReader::Details::parseModeRefs()\n//-----------------------------------------------------------------------------\nvoid FieldAccessPolicyReader::Details::parseModeRefs(QDomNode const& rootNode, \n    QSharedPointer<FieldAccessPolicy> accessPolicy)\n{\n    accessPolicy->setModeReferences(CommonItemsReader::parseModeReferences(rootNode));\n}\n\n//-----------------------------------------------------------------------------\n// Function: FieldAccessPolicyReader::Details::parseDefinitionRef()\n//-----------------------------------------------------------------------------\nvoid FieldAccessPolicyReader::Details::parseDefinitionRef(QDomNode const& accessPolicyNode,\n    QSharedPointer<FieldAccessPolicy> accessPolicy)\n{\n    auto definitionNode = accessPolicyNode.firstChildElement(\n        QStringLiteral(\"ipxact:fieldAccessPolicyDefinitionRef\"));\n\n    accessPolicy->setFieldAccessPolicyDefinitionRef(definitionNode.firstChild().nodeValue());\n\n    if (definitionNode.hasAttribute(QStringLiteral(\"typeDefinitions\")))\n    {\n        accessPolicy->setFieldAccessPolicyTypeDefinitionRef(\n            definitionNode.attribute(QStringLiteral(\"typeDefinitions\")));\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: FieldAccessPolicyReader::Details::parseAccess()\n//-----------------------------------------------------------------------------\nvoid FieldAccessPolicyReader::Details::parseAccess(QDomNode const& accessPolicyNode,\n    QSharedPointer<FieldAccessPolicy> accessPolicy)\n{\n    auto accessElement = accessPolicyNode.firstChildElement(QStringLiteral(\"ipxact:access\"));\n    if (!accessElement.isNull())\n    {\n        auto accessString = accessElement.firstChild().nodeValue();\n        AccessTypes::Access access = AccessTypes::str2Access(accessString, AccessTypes::ACCESS_COUNT);\n        accessPolicy->setAccess(access);\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: FieldAccessPolicyReader::Details::parseModifiedWriteValue()\n//-----------------------------------------------------------------------------\nvoid FieldAccessPolicyReader::Details::parseModifiedWriteValue(QDomNode const& accessPolicyNode,\n    QSharedPointer<FieldAccessPolicy> accessPolicy)\n{\n    auto modifiedWriteElement = accessPolicyNode.firstChildElement(QStringLiteral(\"ipxact:modifiedWriteValue\"));\n    if (!modifiedWriteElement.isNull())\n    {\n        QString modifiedWriteValueString = modifiedWriteElement.firstChild().nodeValue();\n        General::ModifiedWrite modifiedWriteValue = General::str2ModifiedWrite(modifiedWriteValueString);\n        accessPolicy->setModifiedWrite(modifiedWriteValue);\n\n        if (modifiedWriteElement.hasAttribute(QStringLiteral(\"modify\")))\n        {\n            accessPolicy->setModifiedWriteModify(modifiedWriteElement.attribute(QStringLiteral(\"modify\")));\n        }\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: FieldAccessPolicyReader::Details::parseWriteValueConstraint()\n//-----------------------------------------------------------------------------\nvoid FieldAccessPolicyReader::Details::parseWriteValueConstraint(QDomNode const& accessPolicyNode, \n    QSharedPointer<FieldAccessPolicy> accessPolicy)\n{\n    QDomElement writeConstraintElement = accessPolicyNode.firstChildElement(\n        QStringLiteral(\"ipxact:writeValueConstraint\"));\n    \n    if (!writeConstraintElement.isNull())\n    {\n        QSharedPointer<WriteValueConstraint> writeConstraint(new WriteValueConstraint());\n\n        if (auto writeAsReadElement = writeConstraintElement.firstChildElement(\n            QStringLiteral(\"ipxact:writeAsRead\")); !writeAsReadElement.isNull())\n        {\n            writeConstraint->setType(WriteValueConstraint::WRITE_AS_READ);\n        }\n        if (auto useEnumerationElement = writeConstraintElement.firstChildElement(\n            QStringLiteral(\"ipxact:useEnumeratedValues\")); !useEnumerationElement.isNull())\n        {\n            writeConstraint->setType(WriteValueConstraint::USE_ENUM);\n        }\n        if (auto minimumElement = writeConstraintElement.firstChildElement(QStringLiteral(\"ipxact:minimum\"));\n            !minimumElement.isNull())\n        {\n            writeConstraint->setMinimum(minimumElement.firstChild().nodeValue());\n        }\n        if (auto maximumElement = writeConstraintElement.firstChildElement(QStringLiteral(\"ipxact:maximum\"));\n            !maximumElement.isNull())\n        {\n            writeConstraint->setMaximum(maximumElement.firstChild().nodeValue());\n        }\n\n        accessPolicy->setWriteValueConstraint(writeConstraint);\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: FieldAccessPolicyReader::Details::parseReadAction()\n//-----------------------------------------------------------------------------\nvoid FieldAccessPolicyReader::Details::parseReadAction(QDomNode const& accessPolicyNode,\n    QSharedPointer<FieldAccessPolicy> accessPolicy)\n{\n    auto readActionElement = accessPolicyNode.firstChildElement(QStringLiteral(\"ipxact:readAction\"));\n    if (!readActionElement.isNull())\n    {\n        QString readActionString = readActionElement.firstChild().nodeValue();\n        General::ReadAction readAction = General::str2ReadAction(readActionString);\n\n        accessPolicy->setReadAction(readAction);\n\n        if (readActionElement.hasAttribute(QStringLiteral(\"modify\")))\n        {\n            accessPolicy->setReadActionModify(readActionElement.attribute(QStringLiteral(\"modify\")));\n        }\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: FieldAccessPolicyReader::Details::parseReadResponse()\n//-----------------------------------------------------------------------------\nvoid FieldAccessPolicyReader::Details::parseReadResponse(QDomNode const& accessPolicyNode, \n    QSharedPointer<FieldAccessPolicy> accessPolicy)\n{\n    auto readResponseElement = accessPolicyNode.firstChildElement(QStringLiteral(\"ipxact:readResponse\"));\n\n    if (!readResponseElement.isNull())\n    {\n        accessPolicy->setReadResponse(readResponseElement.firstChild().nodeValue());\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: FieldAccessPolicyReader::Details::parseBroadcasts()\n//-----------------------------------------------------------------------------\nvoid FieldAccessPolicyReader::Details::parseBroadcasts(QDomNode const& accessPolicyNode,\n    QSharedPointer<FieldAccessPolicy> accessPolicy)\n{\n    auto broadcastsElement = accessPolicyNode.firstChildElement(QStringLiteral(\"ipxact:broadcasts\"));\n\n    if (broadcastsElement.isNull())\n    {\n        return;\n    }\n    \n    auto broadcastElements = broadcastsElement.childNodes();\n\n    for (int i = 0; i < broadcastElements.size(); ++i)\n    {\n        auto singleBroadcast = broadcastElements.at(i);\n\n        if (singleBroadcast.nodeName() == QStringLiteral(\"ipxact:broadcastTo\"))\n        {\n            auto fieldRef = FieldReferenceReader::createFieldReferenceFrom(singleBroadcast);\n\n            accessPolicy->getBroadcasts()->append(fieldRef);\n        }\n    }\n    \n}\n\n//-----------------------------------------------------------------------------\n// Function: FieldAccessPolicyReader::Details::parseAccessRestrictions()\n//-----------------------------------------------------------------------------\nvoid FieldAccessPolicyReader::Details::parseAccessRestrictions(QDomNode const& accessPolicyNode,\n    QSharedPointer<FieldAccessPolicy> accessPolicy)\n{\n    auto accessRestrictionsElement = accessPolicyNode.firstChildElement(\n        QStringLiteral(\"ipxact:accessRestrictions\"));\n\n    if (accessRestrictionsElement.isNull())\n    {\n        return;\n    }\n\n    auto accessRestrictions = accessRestrictionsElement.childNodes();\n\n    for (int i = 0; i < accessRestrictions.size(); ++i)\n    {\n        QSharedPointer<FieldAccessPolicy::AccessRestriction> accessRestriction(\n            new FieldAccessPolicy::AccessRestriction());\n\n        auto accessRestrictionNode = accessRestrictions.at(i);\n\n        if (accessRestrictionNode.nodeName() == QStringLiteral(\"ipxact:accessRestriction\"))\n        {\n            accessRestriction->modeRefs_ = CommonItemsReader::parseModeReferences(accessRestrictionNode);\n        }\n\n        accessRestriction->readAccessMask_ = accessRestrictionNode.firstChildElement(\n            QStringLiteral(\"ipxact:readAccessMask\")).firstChild().nodeValue();\n\n        accessRestriction->writeAccessMask_ = accessRestrictionNode.firstChildElement(\n            QStringLiteral(\"ipxact:writeAccessMask\")).firstChild().nodeValue();\n\n        accessPolicy->getAccessRestrictions()->append(accessRestriction);\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: FieldAccessPolicyReader::Details::parseTestable()\n//-----------------------------------------------------------------------------\nvoid FieldAccessPolicyReader::Details::parseTestable(QDomNode const& accessPolicyNode,\n    QSharedPointer<FieldAccessPolicy> accessPolicy)\n{\n    auto testableElement = accessPolicyNode.firstChildElement(QStringLiteral(\"ipxact:testable\"));\n    if (!testableElement.isNull())\n    {\n        accessPolicy->setTestable(General::str2Bool(testableElement.firstChild().nodeValue(), false));\n\n        if (testableElement.hasAttribute(QStringLiteral(\"testConstraint\")))\n        {\n            QString testConstraintString = testableElement.attribute(QStringLiteral(\"testConstraint\"));\n            General::TestConstraint testConstraint = General::str2TestConstraint(testConstraintString);\n            accessPolicy->setTestConstraint(testConstraint);\n        }\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: FieldAccessPolicyReader::Details::parseReserved()\n//-----------------------------------------------------------------------------\nvoid FieldAccessPolicyReader::Details::parseReserved(QDomNode const& accessPolicyNode, QSharedPointer<FieldAccessPolicy> accessPolicy)\n{\n    auto reservedElement = accessPolicyNode.firstChildElement(QStringLiteral(\"ipxact:reserved\"));\n    if (!reservedElement.isNull())\n    {\n        accessPolicy->setReserved(reservedElement.firstChild().nodeValue());\n    }\n}\n"
  },
  {
    "path": "IPXACTmodels/Component/FieldAccessPolicyReader.h",
    "content": "//-----------------------------------------------------------------------------\n// File: FieldAccessPolicyReader.h\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Anton Hagqvist\n// Date: 31.7.2023\n//\n// Description:\n// Reader for ipxact:fieldAccessPolicy\n//-----------------------------------------------------------------------------\n\n#ifndef FIELDACCESSPOLICYREADER_H\n#define FIELDACCESSPOLICYREADER_H\n\n#include \"FieldAccessPolicy.h\"\n\n#include <IPXACTmodels/ipxactmodels_global.h>\n\n#include <QDomNode>\n\nnamespace FieldAccessPolicyReader\n{\n\n    /*!\n     *\tCreate a field access policy from XML description.\n     *  \n     *    @param [in] fieldAccessPolicyNode     The XML description of the field access policy.\n     *\t    \n     * \t    @return The created field access policy.\n     */\n    IPXACTMODELS_EXPORT QSharedPointer<FieldAccessPolicy> createFieldAccessPolicyFrom(QDomNode const& fieldAccessPolicyNode);\n\n    namespace Details\n    {\n        /*!\n         *\tRead mode references.\n         *  \n         *    @param [in] rootNode        The containing element.\n         *    @param [in] accessPolicy    The created field access policy.\n         */\n        void parseModeRefs(QDomNode const& rootNode, QSharedPointer<FieldAccessPolicy> accessPolicy);\n\n        /*!\n         *\tRead the access policy definition reference.\n         *  \n         *    @param [in] accessPolicyNode     The XML description of the field access policy.\n         *    @param [in] accessPolicy         The created field access policy.\n         */\n        void parseDefinitionRef(QDomNode const& accessPolicyNode, QSharedPointer<FieldAccessPolicy> accessPolicy);\n\n        /*!\n         *\tParse field access policy access value.\n         *  \n         *    @param [in] accessPolicyNode     The XML description of the field access policy.\n         *    @param [in] accessPolicy         The created field access policy.\n         */\n        void parseAccess(QDomNode const& accessPolicyNode, QSharedPointer<FieldAccessPolicy> accessPolicy);\n\n        /*!\n         *\tRead the modified write value of the field access policy.\n         *  \n         *    @param [in] accessPolicyNode     The XML description of the field access policy.\n         *    @param [in] accessPolicy         The created field access policy.\n         */\n        void parseModifiedWriteValue(QDomNode const& accessPolicyNode, QSharedPointer<FieldAccessPolicy> accessPolicy);\n\n        /*!\n         *\tRead the write value constraint.\n         *  \n         *    @param [in] accessPolicyNode     The XML description of the field access policy.\n         *    @param [in] accessPolicy         The created field access policy.\n         */\n        void parseWriteValueConstraint(QDomNode const& accessPolicyNode, QSharedPointer<FieldAccessPolicy> accessPolicy);\n\n        /*!\n         *\tRead the read action.\n         *  \n         *    @param [in] accessPolicyNode     The XML description of the field access policy.\n         *    @param [in] accessPolicy         The created field access policy.\n         */\n        void parseReadAction(QDomNode const& accessPolicyNode, QSharedPointer<FieldAccessPolicy> accessPolicy);\n\n        /*!\n         *\tRead the read response of the field access policy.\n         *  \n         *    @param [in] accessPolicyNode     The XML description of the field access policy.\n         *    @param [in] accessPolicy         The created field access policy.\n         */\n        void parseReadResponse(QDomNode const& accessPolicyNode, QSharedPointer<FieldAccessPolicy> accessPolicy);\n\n        /*!\n         *\tRead the broadcasts of the field access policy.\n         *  \n         *    @param [in] accessPolicyNode     The XML description of the field access policy.\n         *    @param [in] accessPolicy         The created field access policy.\n         */\n        void parseBroadcasts(QDomNode const& accessPolicyNode, QSharedPointer<FieldAccessPolicy> accessPolicy);\n\n        /*!\n         *\tRead the access restrictions of the field access policy.\n         *  \n         *    @param [in] accessPolicyNode     The XML description of the field access policy.\n         *    @param [in] accessPolicy         The created field access policy.\n         */\n        void parseAccessRestrictions(QDomNode const& accessPolicyNode, QSharedPointer<FieldAccessPolicy> accessPolicy);\n\n        /*!\n         *\tRead the testable value of the field access policy.\n         *  \n         *    @param [in] accessPolicyNode     The XML description of the field access policy.\n         *    @param [in] accessPolicy         The created field access policy.\n         */\n        void parseTestable(QDomNode const& accessPolicyNode, QSharedPointer<FieldAccessPolicy> accessPolicy);\n        \n        /*!\n         *\tRead the reserved value of the field access policy.\n         *  \n         *    @param [in] accessPolicyNode     The XML description of the field access policy.\n         *    @param [in] accessPolicy         The created field access policy.\n         */\n        void parseReserved(QDomNode const& accessPolicyNode, QSharedPointer<FieldAccessPolicy> accessPolicy);\n    }\n}\n\n#endif // FIELDACCESSPOLICYREADER_H"
  },
  {
    "path": "IPXACTmodels/Component/FieldAccessPolicyWriter.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: FieldAccessPolicyWriter.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Anton Hagqvist\n// Date: 2.8.2023\n//\n// Description:\n// Writer for ipxact:fieldAccessPolicy.\n//-----------------------------------------------------------------------------\n\n#include \"FieldAccessPolicyWriter.h\"\n#include \"FieldReferenceWriter.h\"\n\n#include <IPXACTmodels/common/CommonItemsWriter.h>\n\n//-----------------------------------------------------------------------------\n// Function: FieldAccessPolicyWriter::writeFieldAccessPolicy()\n//-----------------------------------------------------------------------------\nvoid FieldAccessPolicyWriter::writeFieldAccessPolicy(QXmlStreamWriter& writer,\n    QSharedPointer<FieldAccessPolicy> fieldAccessPolicy)\n{\n    writer.writeStartElement(QStringLiteral(\"ipxact:fieldAccessPolicy\"));\n\n    CommonItemsWriter::writeModeReferences(writer, fieldAccessPolicy->getModeReferences());\n\n    Details::writeFieldAccessPolicyDefinitionRef(writer, fieldAccessPolicy);\n\n    Details::writeAccess(writer, fieldAccessPolicy);\n\n    Details::writeValueConstraint(writer, fieldAccessPolicy);\n\n    Details::writeModifiedWriteValue(writer, fieldAccessPolicy);\n\n    Details::writeReadAction(writer, fieldAccessPolicy);\n\n    Details::writeReadResponse(writer, fieldAccessPolicy);\n\n    Details::writeBroadCasts(writer, fieldAccessPolicy);\n\n    Details::writeAccessRestrictions(writer, fieldAccessPolicy);\n\n    Details::writeTestable(writer, fieldAccessPolicy);\n\n    Details::writeReserved(writer, fieldAccessPolicy);\n\n    CommonItemsWriter::writeVendorExtensions(writer, fieldAccessPolicy);\n\n    writer.writeEndElement(); // ipxact:fieldAccessPolicy\n}\n\n//-----------------------------------------------------------------------------\n// Function: FieldAccessPolicyWriter::Details::writeFieldAccessPolicyDefinitionRef()\n//-----------------------------------------------------------------------------\nvoid FieldAccessPolicyWriter::Details::writeFieldAccessPolicyDefinitionRef(QXmlStreamWriter& writer,\n    QSharedPointer<FieldAccessPolicy> fieldAccessPolicy)\n{\n    if (auto const& definitionRef = fieldAccessPolicy->getFieldAccessPolicyDefinitionRef();\n        !definitionRef.isEmpty())\n    {\n        writer.writeStartElement(QStringLiteral(\"ipxact:fieldAccessPolicyDefinitionRef\"));\n\n        if (auto const& typeDefs = fieldAccessPolicy->getFieldAccessPolicyTypeDefinitionRef();\n            !typeDefs.isEmpty())\n        {\n            writer.writeAttribute(QStringLiteral(\"typeDefinitions\"), typeDefs);\n        }\n\n        writer.writeCharacters(definitionRef);\n        writer.writeEndElement(); // ipxact:fieldAccessPolicyDefinitionRef\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: FieldAccessPolicyWriter::Details::writeAccess()\n//-----------------------------------------------------------------------------\nvoid FieldAccessPolicyWriter::Details::writeAccess(QXmlStreamWriter& writer, QSharedPointer<FieldAccessPolicy> fieldAccessPolicy)\n{\n    if (fieldAccessPolicy->getAccess() != AccessTypes::ACCESS_COUNT)\n    {\n        QString access = AccessTypes::access2Str(fieldAccessPolicy->getAccess());\n        writer.writeTextElement(QStringLiteral(\"ipxact:access\"), access);\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: FieldAccessPolicyWriter::Details::writeModifiedWriteValue()\n//-----------------------------------------------------------------------------\nvoid FieldAccessPolicyWriter::Details::writeModifiedWriteValue(QXmlStreamWriter& writer, QSharedPointer<FieldAccessPolicy> fieldAccessPolicy)\n{\n    if (fieldAccessPolicy->getModifiedWrite() != General::MODIFIED_WRITE_COUNT)\n    {\n        writer.writeStartElement(QStringLiteral(\"ipxact:modifiedWriteValue\"));\n\n        if (!fieldAccessPolicy->getModifiedWriteModify().isEmpty())\n        {\n            writer.writeAttribute(QStringLiteral(\"modify\"), fieldAccessPolicy->getModifiedWriteModify());\n        }\n\n        QString modifiedWriteValue = General::modifiedWrite2Str(fieldAccessPolicy->getModifiedWrite());\n        writer.writeCharacters(modifiedWriteValue);\n\n        writer.writeEndElement(); // ipxact:modifiedWriteValue\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: FieldAccessPolicyWriter::Details::writeValueConstraint()\n//-----------------------------------------------------------------------------\nvoid FieldAccessPolicyWriter::Details::writeValueConstraint(QXmlStreamWriter& writer, QSharedPointer<FieldAccessPolicy> fieldAccessPolicy)\n{\n    auto writeConstraint = fieldAccessPolicy->getWriteValueConstraint();\n\n    if (!writeConstraint.isNull())\n    {\n        auto constraintType = writeConstraint->getType();\n\n        if (constraintType == WriteValueConstraint::TYPE_COUNT)\n        {\n            return;\n        }\n\n        writer.writeStartElement(QStringLiteral(\"ipxact:writeValueConstraint\"));\n\n        if (constraintType == WriteValueConstraint::WRITE_AS_READ)\n        {\n            writer.writeTextElement(QStringLiteral(\"ipxact:writeAsRead\"), QStringLiteral(\"true\"));\n        }\n        else if (constraintType == WriteValueConstraint::USE_ENUM)\n        {\n            writer.writeTextElement(QStringLiteral(\"ipxact:useEnumeratedValues\"), QStringLiteral(\"true\"));\n        }\n        else if (constraintType == WriteValueConstraint::MIN_MAX)\n        {\n            writer.writeTextElement(QStringLiteral(\"ipxact:minimum\"), writeConstraint->getMinimum());\n            writer.writeTextElement(QStringLiteral(\"ipxact:maximum\"), writeConstraint->getMaximum());\n        }\n\n        writer.writeEndElement(); // ipxact:writeValueConstraint\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: FieldAccessPolicyWriter::Details::writeReadAction()\n//-----------------------------------------------------------------------------\nvoid FieldAccessPolicyWriter::Details::writeReadAction(QXmlStreamWriter& writer, QSharedPointer<FieldAccessPolicy> fieldAccessPolicy)\n{\n    if (fieldAccessPolicy->getReadAction() != General::READ_ACTION_COUNT)\n    {\n        QString readAction = General::readAction2Str(fieldAccessPolicy->getReadAction());\n\n        writer.writeStartElement(QStringLiteral(\"ipxact:readAction\"));\n\n        if (!fieldAccessPolicy->getReadActionModify().isEmpty())\n        {\n            writer.writeAttribute(QStringLiteral(\"modify\"), fieldAccessPolicy->getReadActionModify());\n        }\n        writer.writeCharacters(readAction);\n\n        writer.writeEndElement(); // ipxact:readAction\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: FieldAccessPolicyWriter::Details::writeReadResponse()\n//-----------------------------------------------------------------------------\nvoid FieldAccessPolicyWriter::Details::writeReadResponse(QXmlStreamWriter& writer, QSharedPointer<FieldAccessPolicy> fieldAccessPolicy)\n{\n    if (auto const& readResponse = fieldAccessPolicy->getReadResponse();\n        readResponse.isEmpty() == false)\n    {\n        writer.writeTextElement(QStringLiteral(\"ipxact:readResponse\"), readResponse);\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: FieldAccessPolicyWriter::Details::writeBroadCasts()\n//-----------------------------------------------------------------------------\nvoid FieldAccessPolicyWriter::Details::writeBroadCasts(QXmlStreamWriter& writer, QSharedPointer<FieldAccessPolicy> fieldAccessPolicy)\n{\n    if (auto const& broadcasts = fieldAccessPolicy->getBroadcasts();\n        broadcasts->isEmpty() == false)\n    {\n        writer.writeStartElement(QStringLiteral(\"ipxact:broadcasts\"));\n\n        for (auto const& fieldReference : *broadcasts)\n        {\n            writer.writeStartElement(QStringLiteral(\"ipxact:broadcastTo\"));\n\n            FieldReferenceWriter::writeFieldReference(writer, fieldReference);\n\n            writer.writeEndElement(); // ipxact:broadcastTo\n        }\n\n        writer.writeEndElement(); // ipxact:broadcasts\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: FieldAccessPolicyWriter::Details::writeAccessRestrictions()\n//-----------------------------------------------------------------------------\nvoid FieldAccessPolicyWriter::Details::writeAccessRestrictions(QXmlStreamWriter& writer, QSharedPointer<FieldAccessPolicy> fieldAccessPolicy)\n{\n    auto accessRestrictions = fieldAccessPolicy->getAccessRestrictions();\n\n    if (accessRestrictions->isEmpty())\n    {\n        return;\n    }\n\n    writer.writeStartElement(QStringLiteral(\"ipxact:accessRestrictions\"));\n\n    for (auto const& accessRestriction : *accessRestrictions)\n    {\n        writer.writeStartElement(QStringLiteral(\"ipxact:accessRestriction\"));\n\n        CommonItemsWriter::writeModeReferences(writer, accessRestriction->modeRefs_);\n\n        if (!accessRestriction->readAccessMask_.isEmpty())\n        {\n            writer.writeTextElement(QStringLiteral(\"ipxact:readAccessMask\"), accessRestriction->readAccessMask_);\n        }\n\n        if (!accessRestriction->writeAccessMask_.isEmpty())\n        {\n            writer.writeTextElement(QStringLiteral(\"ipxact:writeAccessMask\"), accessRestriction->writeAccessMask_);\n        }\n\n        writer.writeEndElement(); // ipxact:accessRestriction\n    }\n\n    writer.writeEndElement(); // ipxact:accessRestrictions\n}\n\n//-----------------------------------------------------------------------------\n// Function: FieldAccessPolicyWriter::Details::writeTestable()\n//-----------------------------------------------------------------------------\nvoid FieldAccessPolicyWriter::Details::writeTestable(QXmlStreamWriter& writer, QSharedPointer<FieldAccessPolicy> fieldAccessPolicy)\n{\n    if (!fieldAccessPolicy->getTestable().toString().isEmpty())\n    {\n        writer.writeStartElement(QStringLiteral(\"ipxact:testable\"));\n\n        if (fieldAccessPolicy->getTestConstraint() != General::TESTCONSTRAINT_COUNT)\n        {\n            QString testConstraint = General::testConstraint2Str(fieldAccessPolicy->getTestConstraint());\n            writer.writeAttribute(QStringLiteral(\"testConstraint\"), testConstraint);\n        }\n\n        writer.writeCharacters(fieldAccessPolicy->getTestable().toString());\n\n        writer.writeEndElement(); // ipxact:testable\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: FieldAccessPolicyWriter::Details::writeReserved()\n//-----------------------------------------------------------------------------\nvoid FieldAccessPolicyWriter::Details::writeReserved(QXmlStreamWriter& writer, QSharedPointer<FieldAccessPolicy> fieldAccessPolicy)\n{\n    if (!fieldAccessPolicy->getReserved().isEmpty())\n    {\n        writer.writeTextElement(QStringLiteral(\"ipxact:reserved\"), fieldAccessPolicy->getReserved());\n    }\n}\n"
  },
  {
    "path": "IPXACTmodels/Component/FieldAccessPolicyWriter.h",
    "content": "//-----------------------------------------------------------------------------\n// File: FieldAccessPolicyWriter.h\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Anton Hagqvist\n// Date: 2.8.2023\n//\n// Description:\n// Writer for ipxact:fieldAccessPolicy.\n//-----------------------------------------------------------------------------\n\n#ifndef FIELDACCESSPOLICYWRITER_H\n#define FIELDACCESSPOLICYWRITER_H\n\n#include \"FieldAccessPolicy.h\"\n\n#include <IPXACTmodels/ipxactmodels_global.h>\n\n#include <QXmlStreamWriter>\n\nnamespace FieldAccessPolicyWriter\n{\n\n    /*!\n     *\tWrite a given field access policy to XML.\n     *  \n     *    @param [in] writer                The XML writer to use.\n     *    @param [in] fieldAccessPolicy     The field access policy to write.\n     */\n    IPXACTMODELS_EXPORT void writeFieldAccessPolicy(QXmlStreamWriter& writer, QSharedPointer<FieldAccessPolicy> fieldAccessPolicy);\n\n    namespace Details\n    {\n        void writeFieldAccessPolicyDefinitionRef(QXmlStreamWriter& writer, QSharedPointer<FieldAccessPolicy> fieldAccessPolicy);\n\n        void writeAccess(QXmlStreamWriter& writer, QSharedPointer<FieldAccessPolicy> fieldAccessPolicy);\n\n        void writeModifiedWriteValue(QXmlStreamWriter& writer, QSharedPointer<FieldAccessPolicy> fieldAccessPolicy);\n\n        void writeValueConstraint(QXmlStreamWriter& writer, QSharedPointer<FieldAccessPolicy> fieldAccessPolicy);\n\n        void writeReadAction(QXmlStreamWriter& writer, QSharedPointer<FieldAccessPolicy> fieldAccessPolicy);\n\n        void writeReadResponse(QXmlStreamWriter& writer, QSharedPointer<FieldAccessPolicy> fieldAccessPolicy);\n\n        void writeBroadCasts(QXmlStreamWriter& writer, QSharedPointer<FieldAccessPolicy> fieldAccessPolicy);\n\n        void writeAccessRestrictions(QXmlStreamWriter& writer, QSharedPointer<FieldAccessPolicy> fieldAccessPolicy);\n\n        void writeTestable(QXmlStreamWriter& writer, QSharedPointer<FieldAccessPolicy> fieldAccessPolicy);\n\n        void writeReserved(QXmlStreamWriter& writer, QSharedPointer<FieldAccessPolicy> fieldAccessPolicy);\n    }\n}\n\n#endif // FIELDACCESSPOLICYWRITER_H\n"
  },
  {
    "path": "IPXACTmodels/Component/FieldReader.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: FieldReader.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 25.09.2015\r\n//\r\n// Description:\r\n// Reader class for IP-XACT field element.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"FieldReader.h\"\r\n#include \"Field.h\"\r\n#include \"EnumeratedValueReader.h\"\r\n#include \"EnumeratedValue.h\"\r\n#include \"WriteValueConstraint.h\"\r\n#include \"MemoryArrayReader.h\"\r\n#include \"FieldReferenceReader.h\"\r\n#include \"FieldAccessPolicyReader.h\"\r\n\r\n#include <IPXACTmodels/common/NameGroupReader.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FieldReader::createFieldFrom()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<Field> FieldReader::createFieldFrom(QDomNode const& fieldNode, Document::Revision docRevision)\r\n{\r\n    QDomElement fieldElement = fieldNode.toElement();\r\n\r\n    QSharedPointer<Field> newField (new Field());\r\n\r\n    NameGroupReader::parseNameGroup(fieldNode, newField);\r\n    \r\n    if (docRevision == Document::Revision::Std14)\r\n    {\r\n        Details::parseID(fieldElement, newField);\r\n        Details::parsePresence(fieldElement, newField);\r\n\r\n        Details::parseAccess(fieldElement, newField);\r\n        Details::parseModifiedWriteValue(fieldElement, newField);\r\n        Details::parseWriteValueConstraint(fieldElement, newField);\r\n        Details::parseReadAction(fieldElement, newField);\r\n        Details::parseTestable(fieldElement, newField);\r\n        Details::parseReserved(fieldElement, newField);\r\n\r\n    }\r\n    else if (docRevision == Document::Revision::Std22)\r\n    {\r\n        Details::parseMemoryArray(fieldElement, newField);\r\n        Details::parseFieldDefinitionRef(fieldElement, newField);\r\n        Details::parseFieldReference(fieldElement, newField);\r\n        Details::parseFieldAccessPolicies(fieldElement, newField);\r\n    }\r\n\r\n    Details::parseBitOffset(fieldElement, newField);\r\n\r\n    Details::parseResets(fieldElement, newField);\r\n\r\n    Details::parseTypeIdentifier(fieldElement, newField);\r\n\r\n    Details::parseBitWidth(fieldElement, newField);\r\n\r\n    Details::parseVolatile(fieldElement, newField);\r\n\r\n    Details::parseEnumeratedValues(fieldElement, newField);\r\n\r\n    Details::parseParameters(fieldElement, newField);\r\n\r\n    CommonItemsReader::parseVendorExtensions(fieldNode, newField);\r\n\r\n    return newField;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FieldReader::Details::parseID()\r\n//-----------------------------------------------------------------------------\r\nvoid FieldReader::Details::parseID(QDomElement const& fieldElement, QSharedPointer<Field> newField)\r\n{\r\n    if (fieldElement.hasAttribute(QStringLiteral(\"fieldID\")))\r\n    {\r\n        QString fieldID = fieldElement.attribute(QStringLiteral(\"fieldID\"));\r\n        newField->setId(fieldID);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FieldReader::Details::parsePresence()\r\n//-----------------------------------------------------------------------------\r\nvoid FieldReader::Details::parsePresence(QDomElement const& fieldElement, QSharedPointer<Field> newField)\r\n{\r\n    QString newIsPresent = CommonItemsReader::parseIsPresent(fieldElement.firstChildElement(QStringLiteral(\"ipxact:isPresent\")));\r\n    if (!newIsPresent.isEmpty())\r\n    {\r\n        newField->setIsPresent(newIsPresent);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FieldReader::Details::parseMemoryArray()\r\n//-----------------------------------------------------------------------------\r\nvoid FieldReader::Details::parseMemoryArray(QDomElement const& fieldElement, QSharedPointer<Field> newField)\r\n{   \r\n    if (auto memArrayElement = fieldElement.firstChildElement(QStringLiteral(\"ipxact:array\"));\r\n        !memArrayElement.isNull())\r\n    {\r\n        auto newArray = MemoryArrayReader::createMemoryArrayFrom(memArrayElement, Document::Revision::Std22, true);\r\n        newField->setMemoryArray(newArray);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FieldReader::Details::parseBitOffset()\r\n//-----------------------------------------------------------------------------\r\nvoid FieldReader::Details::parseBitOffset(QDomElement const& fieldElement, QSharedPointer<Field> newField)\r\n{\r\n    QDomElement bitOffsetElement = fieldElement.firstChildElement(QStringLiteral(\"ipxact:bitOffset\"));\r\n    QString bitOffset = bitOffsetElement.firstChild().nodeValue();\r\n    newField->setBitOffset(bitOffset);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FieldReader::Details::parseFieldDefinitionRef()\r\n//-----------------------------------------------------------------------------\r\nvoid FieldReader::Details::parseFieldDefinitionRef(QDomElement const& fieldElement, QSharedPointer<Field> newField)\r\n{\r\n    QDomElement fieldDefElement = fieldElement.firstChildElement(QStringLiteral(\"ipxact:fieldDefinitionRef\"));\r\n    if (!fieldDefElement.isNull())\r\n    {\r\n        newField->setFieldDefinitionRef(fieldDefElement.firstChild().nodeValue());\r\n        newField->setTypeDefinitionsRef(fieldDefElement.attribute(QStringLiteral(\"typeDefinitions\"), QString()));\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FieldReader::Details::parseResets()\r\n//-----------------------------------------------------------------------------\r\nvoid FieldReader::Details::parseResets(QDomElement const& fieldElement, QSharedPointer<Field> newField)\r\n{\r\n    QDomElement resetsElement = fieldElement.firstChildElement(QStringLiteral(\"ipxact:resets\"));\r\n    if (!resetsElement.isNull())\r\n    {\r\n        QDomNodeList resetNodeList = resetsElement.elementsByTagName(QStringLiteral(\"ipxact:reset\"));\r\n        for (int resetIndex = 0; resetIndex < resetNodeList.count(); ++resetIndex)\r\n        {\r\n            QDomElement resetElement = resetNodeList.at(resetIndex).toElement();\r\n\r\n            QSharedPointer<FieldReset> fldReset = QSharedPointer<FieldReset>(new FieldReset());\r\n\r\n            parseResetTypeRef(resetElement, fldReset);\r\n            parseResetValue(resetElement, fldReset);\r\n            parseResetMask(resetElement, fldReset);\r\n\r\n            newField->getResets()->append(fldReset);\r\n\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FieldReader::Details::parseResetTypeRef()\r\n//-----------------------------------------------------------------------------\r\nvoid FieldReader::Details::parseResetTypeRef(QDomElement const& resetElement, QSharedPointer<FieldReset> fieldReset)\r\n{\r\n  if (resetElement.hasAttribute(QStringLiteral(\"resetTypeRef\")))\r\n  {\r\n      fieldReset->setResetTypeReference(resetElement.attribute(QStringLiteral(\"resetTypeRef\")));\r\n  }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FieldReader::Details::parseResetValue()\r\n//-----------------------------------------------------------------------------\r\nvoid FieldReader::Details::parseResetValue(QDomElement const& resetElement, QSharedPointer<FieldReset> fieldReset)\r\n{\r\n  QString resetValue = resetElement.firstChildElement(QStringLiteral(\"ipxact:value\")).firstChild().nodeValue();\r\n  fieldReset->setResetValue(resetValue);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FieldReader::Details::parseResetMask()\r\n//-----------------------------------------------------------------------------\r\nvoid FieldReader::Details::parseResetMask(QDomElement const& resetElement, QSharedPointer<FieldReset> fieldReset)\r\n{\r\n  QDomElement resetMaskElement = resetElement.firstChildElement(QStringLiteral(\"ipxact:mask\"));\r\n  if (!resetMaskElement.isNull())\r\n  {\r\n      QString resetMask = resetMaskElement.firstChild().nodeValue();\r\n      fieldReset->setResetMask(resetMask);\r\n  }\r\n}\r\n\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FieldReader::Details::parseTypeIdentifier()\r\n//-----------------------------------------------------------------------------\r\nvoid FieldReader::Details::parseTypeIdentifier(QDomElement const& fieldElement, QSharedPointer<Field> newField)\r\n{\r\n    QDomElement typeIdentifierElement = fieldElement.firstChildElement(QStringLiteral(\"ipxact:typeIdentifier\"));\r\n    if (!typeIdentifierElement.isNull())\r\n    {\r\n        QString typeIdentifier = typeIdentifierElement.firstChild().nodeValue();\r\n        newField->setTypeIdentifier(typeIdentifier);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FieldReader::Details::parseBitWidth()\r\n//-----------------------------------------------------------------------------\r\nvoid FieldReader::Details::parseBitWidth(QDomElement const& fieldElement, QSharedPointer<Field> newField)\r\n{\r\n    QDomElement bitWidthElement = fieldElement.firstChildElement(QStringLiteral(\"ipxact:bitWidth\"));\r\n    QString bitWidth = bitWidthElement.firstChild().nodeValue();\r\n    newField->setBitWidth(bitWidth);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FieldReader::Details::parseVolatile()\r\n//-----------------------------------------------------------------------------\r\nvoid FieldReader::Details::parseVolatile(QDomElement const& fieldElement, QSharedPointer<Field> newField)\r\n{\r\n    QDomElement volatileElement = fieldElement.firstChildElement(QStringLiteral(\"ipxact:volatile\"));\r\n    if (!volatileElement.isNull())\r\n    {\r\n        if (volatileElement.firstChild().nodeValue() == QLatin1String(\"true\"))\r\n        {\r\n            newField->setVolatile(true);\r\n        }\r\n        else\r\n        {\r\n            newField->setVolatile(false);\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FieldReader::Details::parseFieldReference()\r\n//-----------------------------------------------------------------------------\r\nvoid FieldReader::Details::parseFieldReference(QDomElement const& fieldElement, QSharedPointer<Field> newField)\r\n{\r\n    QDomElement rootReferenceElement = fieldElement.firstChildElement(QStringLiteral(\"ipxact:aliasOf\"));\r\n    \r\n    if (!rootReferenceElement.isNull())\r\n    {\r\n        auto newFieldReference = FieldReferenceReader::createFieldReferenceFrom(rootReferenceElement);\r\n\r\n        newField->setFieldReference(newFieldReference);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FieldReader::Details::parseAccess()\r\n//-----------------------------------------------------------------------------\r\nvoid FieldReader::Details::parseAccess(QDomElement const& fieldElement, QSharedPointer<Field> newField)\r\n{\r\n    QDomElement accessElement = fieldElement.firstChildElement(QStringLiteral(\"ipxact:access\"));\r\n    if (!accessElement.isNull())\r\n    {\r\n        QString accessString = accessElement.firstChild().nodeValue();\r\n        AccessTypes::Access access = AccessTypes::str2Access(accessString, AccessTypes::ACCESS_COUNT);\r\n        newField->setAccess(access);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FieldReader::Details::parseEnumeratedValues()\r\n//-----------------------------------------------------------------------------\r\nvoid FieldReader::Details::parseEnumeratedValues(QDomElement const& fieldElement, QSharedPointer<Field> newField)\r\n{\r\n    QDomElement enumeratedValuesElement = fieldElement.firstChildElement(QStringLiteral(\"ipxact:enumeratedValues\"));\r\n    if (!enumeratedValuesElement.isNull())\r\n    {\r\n        EnumeratedValueReader enumerationReader;\r\n\r\n        QDomNodeList enumeratedValueNodes = enumeratedValuesElement.elementsByTagName(QStringLiteral(\"ipxact:enumeratedValue\"));\r\n        for (int enumerationIndex = 0; enumerationIndex < enumeratedValueNodes.count(); ++enumerationIndex)\r\n        {\r\n            QDomNode enumerationNode = enumeratedValueNodes.at(enumerationIndex);\r\n\r\n            QSharedPointer<EnumeratedValue> enumeration =\r\n                enumerationReader.createEnumeratedValueFrom(enumerationNode);\r\n\r\n            newField->getEnumeratedValues()->append(enumeration);\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FieldReader::Details::parseModifiedWriteValue()\r\n//-----------------------------------------------------------------------------\r\nvoid FieldReader::Details::parseModifiedWriteValue(QDomElement const& fieldElement, QSharedPointer<Field> newField)\r\n{\r\n    QDomElement modifiedWriteElement = fieldElement.firstChildElement(QStringLiteral(\"ipxact:modifiedWriteValue\"));\r\n    if (!modifiedWriteElement.isNull())\r\n    {\r\n        QString modifiedWriteValueString = modifiedWriteElement.firstChild().nodeValue();\r\n        General::ModifiedWrite modifiedWriteValue = General::str2ModifiedWrite(modifiedWriteValueString);\r\n        newField->setModifiedWrite(modifiedWriteValue);\r\n\r\n        if (modifiedWriteElement.hasAttribute(QStringLiteral(\"modify\")))\r\n        {\r\n            newField->setModifiedWriteModify(modifiedWriteElement.attribute(QStringLiteral(\"modify\")));\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FieldReader::Details::parseWriteValueConstraint()\r\n//-----------------------------------------------------------------------------\r\nvoid FieldReader::Details::parseWriteValueConstraint(QDomElement const& fieldElement, QSharedPointer<Field> newField)\r\n{\r\n    QDomElement writeConstraintElement = fieldElement.firstChildElement(QStringLiteral(\"ipxact:writeValueConstraint\"));\r\n    if (!writeConstraintElement.isNull())\r\n    {\r\n        QSharedPointer<WriteValueConstraint> writeConstraint (new WriteValueConstraint());\r\n\r\n        QDomElement writeAsReadElement = writeConstraintElement.firstChildElement(QStringLiteral(\"ipxact:writeAsRead\"));\r\n        QDomElement useEnumerationElement = writeConstraintElement.firstChildElement(QStringLiteral(\"ipxact:useEnumeratedValues\"));\r\n        if (!writeAsReadElement.isNull())\r\n        {\r\n            writeConstraint->setType(WriteValueConstraint::WRITE_AS_READ);\r\n        }\r\n        else if (!useEnumerationElement.isNull())\r\n        {\r\n            writeConstraint->setType(WriteValueConstraint::USE_ENUM);\r\n        }\r\n        else\r\n        {\r\n            QString minimum = writeConstraintElement.firstChildElement(QStringLiteral(\"ipxact:minimum\")).firstChild().nodeValue();\r\n            writeConstraint->setMinimum(minimum);\r\n\r\n            QString maximum = writeConstraintElement.firstChildElement(QStringLiteral(\"ipxact:maximum\")).firstChild().nodeValue();\r\n            writeConstraint->setMaximum(maximum);\r\n        }\r\n\r\n        newField->setWriteConstraint(writeConstraint);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FieldReader::Details::parseReadAction()\r\n//-----------------------------------------------------------------------------\r\nvoid FieldReader::Details::parseReadAction(QDomElement const& fieldElement, QSharedPointer<Field> newField)\r\n{\r\n    QDomElement readActionElement = fieldElement.firstChildElement(QStringLiteral(\"ipxact:readAction\"));\r\n    if (!readActionElement.isNull())\r\n    {\r\n        QString readActionString = readActionElement.firstChild().nodeValue();\r\n        General::ReadAction readAction = General::str2ReadAction(readActionString);\r\n\r\n        newField->setReadAction(readAction);\r\n\r\n        if (readActionElement.hasAttribute(QStringLiteral(\"modify\")))\r\n        {\r\n            newField->setReadActionModify(readActionElement.attribute(QStringLiteral(\"modify\")));\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FieldReader::Details::parseTestable()\r\n//-----------------------------------------------------------------------------\r\nvoid FieldReader::Details::parseTestable(QDomElement const& fieldElement, QSharedPointer<Field> newField)\r\n{\r\n    QDomElement testableElement = fieldElement.firstChildElement(QStringLiteral(\"ipxact:testable\"));\r\n    if (!testableElement.isNull())\r\n    {\r\n        QString testableString = testableElement.firstChild().nodeValue();\r\n        if (testableString == QLatin1String(\"true\"))\r\n        {\r\n            newField->setTestable(true);\r\n        }\r\n        else\r\n        {\r\n            newField->setTestable(false);\r\n        }\r\n\r\n        if (testableElement.hasAttribute(QStringLiteral(\"testConstraint\")))\r\n        {\r\n            QString testConstraintString = testableElement.attribute(QStringLiteral(\"testConstraint\"));\r\n            General::TestConstraint testConstraint = General::str2TestConstraint(testConstraintString);\r\n            newField->setTestConstraint(testConstraint);\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FieldReader::Details::parseReserved()\r\n//-----------------------------------------------------------------------------\r\nvoid FieldReader::Details::parseReserved(QDomElement const& fieldElement, QSharedPointer<Field> newField)\r\n{\r\n    QDomElement reservedElement = fieldElement.firstChildElement(QStringLiteral(\"ipxact:reserved\"));\r\n    if (!reservedElement.isNull())\r\n    {\r\n        QString reserved = reservedElement.firstChild().nodeValue();\r\n        newField->setReserved(reserved);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FieldReader::Details::parseParameters()\r\n//-----------------------------------------------------------------------------\r\nvoid FieldReader::Details::parseParameters(QDomElement const& fieldElement, QSharedPointer<Field> newField)\r\n{\r\n    QDomElement parametersElement = fieldElement.firstChildElement(QStringLiteral(\"ipxact:parameters\"));\r\n    if (!parametersElement.isNull())\r\n    {\r\n        QSharedPointer<QList<QSharedPointer<Parameter> > > newParameters = CommonItemsReader::parseAndCreateParameters(fieldElement);\r\n        for (auto parameter : *newParameters)\r\n        {\r\n            newField->getParameters()->append(parameter);\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FieldReader::Details::parseFieldAccessPolicies()\r\n//-----------------------------------------------------------------------------\r\nvoid FieldReader::Details::parseFieldAccessPolicies(QDomElement const& fieldElement, QSharedPointer<Field> newField)\r\n{\r\n    auto fieldAccessPoliciesElement = fieldElement.firstChildElement(QStringLiteral(\"ipxact:fieldAccessPolicies\"));\r\n\r\n    if (fieldAccessPoliciesElement.isNull() || fieldAccessPoliciesElement.hasChildNodes() == false)\r\n    {\r\n        return;\r\n    }\r\n\r\n    auto fieldAccessPolicies = fieldAccessPoliciesElement.childNodes();\r\n\r\n    for (int i = 0; i < fieldAccessPolicies.size(); ++i)\r\n    {\r\n        auto fieldAccessPolicyNode = fieldAccessPolicies.at(i);\r\n\r\n        if (fieldAccessPolicyNode.nodeName() == QStringLiteral(\"ipxact:fieldAccessPolicy\"))\r\n        {\r\n            auto newFieldAccessPolicy = FieldAccessPolicyReader::createFieldAccessPolicyFrom(fieldAccessPolicyNode);\r\n\r\n            newField->getFieldAccessPolicies()->append(newFieldAccessPolicy);\r\n        }\r\n    }\r\n}\r\n"
  },
  {
    "path": "IPXACTmodels/Component/FieldReader.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: FieldReader.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 25.09.2015\r\n//\r\n// Description:\r\n// Reader for IP-XACT field element.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef FIELDREADER_H\r\n#define FIELDREADER_H\r\n\r\n#include \"FieldReference.h\"\r\n\r\n#include <IPXACTmodels/ipxactmodels_global.h>\r\n\r\n#include <IPXACTmodels/common/CommonItemsReader.h>\r\n\r\n\r\n#include <QSharedPointer>\r\n#include <QDomNode>\r\n\r\nclass Field;\r\nclass FieldReset;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Reader for IP-XACT field element.\r\n//-----------------------------------------------------------------------------\r\nnamespace FieldReader\r\n{\r\n\r\n    /*!\r\n     *  Creates a new field from a given field node.\r\n     *\r\n     *    @param [in] fieldNode   XML description of the field.\r\n     *\r\n     *    @return The created field.\r\n     */\r\n    IPXACTMODELS_EXPORT QSharedPointer<Field> createFieldFrom(QDomNode const& fieldNode, Document::Revision docRevision);\r\n\r\n    namespace Details\r\n    {\r\n\r\n        /*!\r\n         *  Reads the field ID.\r\n         *\r\n         *    @param [in] fieldElement    XML description of the field.\r\n         *    @param [in] newField        The new field item.\r\n         */\r\n        void parseID(QDomElement const& fieldElement, QSharedPointer<Field> newField);\r\n\r\n        /*!\r\n         *  Reads the is present value.\r\n         *\r\n         *    @param [in] fieldElement    XML description of the field.\r\n         *    @param [in] newField        The new field item.\r\n         */\r\n        void parsePresence(QDomElement const& fieldElement, QSharedPointer<Field> newField);\r\n\r\n        /*!\r\n         *\tReads the field memory array.\r\n         *  \r\n         *    @param [in] fieldElement    XML description of the field.\r\n         *    @param [in] newField        The new field item.\r\n         */\r\n        void parseMemoryArray(QDomElement const& fieldElement, QSharedPointer<Field> newField);\r\n\r\n        /*!\r\n         *  Reads the bit offset.\r\n         *\r\n         *    @param [in] fieldElement    XML description of the field.\r\n         *    @param [in] newField        The new field item.\r\n         */\r\n        void parseBitOffset(QDomElement const& fieldElement, QSharedPointer<Field> newField);\r\n\r\n        /*!\r\n         *\tReads the std2022 field definition reference.\r\n         *  \r\n         *    @param [in] fieldElement     XML description of the field.\r\n         *    @param [in] newField         The new field item.\r\n         */\r\n        void parseFieldDefinitionRef(QDomElement const& fieldElement, QSharedPointer<Field> newField);\r\n\r\n        /*!\r\n         *  Reads the reset.\r\n         *\r\n         *    @param [in] fieldElement    XML description of the field.\r\n         *    @param [in] newField        The new field item.\r\n         */\r\n        void parseResets(QDomElement const& fieldElement, QSharedPointer<Field> newField);\r\n\r\n        /*!\r\n         *  Reads the reset type reference.\r\n         *\r\n         *    @param [in] resetElement    XML description of the reset.\r\n         *    @param [in] fldReset        The Reset Structure to parse into.\r\n         */\r\n        void parseResetTypeRef(QDomElement const& resetElement, QSharedPointer<FieldReset> fieldReset);\r\n\r\n        /*!\r\n         *  Reads the reset value.\r\n         *\r\n         *    @param [in] resetElement    XML description of the reset.\r\n         *    @param [in] fldReset        The Reset Structure to parse into.\r\n         */\r\n        void parseResetValue(QDomElement const& resetElement, QSharedPointer<FieldReset> fieldReset);\r\n\r\n        /*!\r\n         *  Reads the reset mask.\r\n         *\r\n         *    @param [in] resetElement    XML description of the reset.\r\n         *    @param [in] fldReset        The Reset Structure to parse into.\r\n         */\r\n        void parseResetMask(QDomElement const& resetElement, QSharedPointer<FieldReset> fieldReset);\r\n\r\n        /*!\r\n         *  Reads the type identifier.\r\n         *\r\n         *    @param [in] fieldElement    XML description of the field.\r\n         *    @param [in] newField        The new field item.\r\n         */\r\n        void parseTypeIdentifier(QDomElement const& fieldElement, QSharedPointer<Field> newField);\r\n\r\n        /*!\r\n         *  Reads the bit width.\r\n         *\r\n         *    @param [in] fieldElement    XML description of the field.\r\n         *    @param [in] newField        The new field item.\r\n         */\r\n        void parseBitWidth(QDomElement const& fieldElement, QSharedPointer<Field> newField);\r\n\r\n        /*!\r\n         *  Reads the volatile value.\r\n         *\r\n         *    @param [in] fieldElement    XML description of the field.\r\n         *    @param [in] newField        The new field item.\r\n         */\r\n        void parseVolatile(QDomElement const& fieldElement, QSharedPointer<Field> newField);\r\n        \r\n        /*!\r\n        *  Reads the field reference (ipxact:aliasOf).\r\n        *\r\n        *    @param [in] fieldElement    XML description of the field.\r\n        *    @param [in] newField        The new field item.\r\n        */\r\n        void parseFieldReference(QDomElement const& fieldElement, QSharedPointer<Field> newField);\r\n\r\n        /*!\r\n         *  Reads the access value.\r\n         *\r\n         *    @param [in] fieldElement    XML description of the field.\r\n         *    @param [in] newField        The new field item.\r\n         */\r\n        void parseAccess(QDomElement const& fieldElement, QSharedPointer<Field> newField);\r\n\r\n        /*!\r\n         *  Reads the enumerated values.\r\n         *\r\n         *    @param [in] fieldElement    XML description of the field.\r\n         *    @param [in] newField        The new field item.\r\n         */\r\n        void parseEnumeratedValues(QDomElement const& fieldElement, QSharedPointer<Field> newField);\r\n\r\n        /*!\r\n         *  Reads the modified write value.\r\n         *\r\n         *    @param [in] fieldElement    XML description of the field.\r\n         *    @param [in] newField        The new field item.\r\n         */\r\n        void parseModifiedWriteValue(QDomElement const& fieldElement, QSharedPointer<Field> newField);\r\n\r\n        /*!\r\n         *  Reads the write value constraint.\r\n         *\r\n         *    @param [in] fieldElement    XML description of the field.\r\n         *    @param [in] newField        The new field item.\r\n         */\r\n        void parseWriteValueConstraint(QDomElement const& fieldElement, QSharedPointer<Field> newField);\r\n\r\n        /*!\r\n         *  Reads the read action value.\r\n         *\r\n         *    @param [in] fieldElement    XML description of the field.\r\n         *    @param [in] newField        The new field item.\r\n         */\r\n        void parseReadAction(QDomElement const& fieldElement, QSharedPointer<Field> newField);\r\n\r\n        /*!\r\n         *  Reads the testable value.\r\n         *\r\n         *    @param [in] fieldElement    XML description of the field.\r\n         *    @param [in] newField        The new field item.\r\n         */\r\n        void parseTestable(QDomElement const& fieldElement, QSharedPointer<Field> newField);\r\n\r\n        /*!\r\n         *  Reads the reserved value.\r\n         *\r\n         *    @param [in] fieldElement    XML description of the field.\r\n         *    @param [in] newField        The new field item.\r\n         */\r\n        void parseReserved(QDomElement const& fieldElement, QSharedPointer<Field> newField);\r\n\r\n        /*!\r\n         *  Reads the parameters.\r\n         *\r\n         *    @param [in] fieldElement    XML description of the field.\r\n         *    @param [in] newField        The new field item.\r\n         */\r\n        void parseParameters(QDomElement const& fieldElement, QSharedPointer<Field> newField);\r\n\r\n        /*!\r\n         *\tParse 2022 std field access policies.\r\n         *  \r\n         *    @param [in] fieldElement    XML description of the field.\r\n         *    @param [in] newField        The new field item.\r\n         */\r\n        void parseFieldAccessPolicies(QDomElement const& fieldElement, QSharedPointer<Field> newField);\r\n    }\r\n};\r\n\r\n#endif // FIELDREADER_H\r\n"
  },
  {
    "path": "IPXACTmodels/Component/FieldReference.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: FieldReference.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Anton Hagqvist\n// Date: 26.7.2023\n//\n// Description:\n// Reference to a field in the encapsulating component. Describes the elements \n// in the fieldReferenceGroup and fieldSliceReferenceGroup.\n//-----------------------------------------------------------------------------\n\n#include \"FieldReference.h\"\n\n#include <IPXACTmodels/utilities/Copy.h>\n\nconst QString FieldReference::TYPES_AS_STRINGS[] = {\n    QLatin1String(\"addressSpaceRef\"),\n    QLatin1String(\"memoryMapRef\"),\n    QLatin1String(\"memoryRemapRef\"),\n    QLatin1String(\"bankRef\"),\n    QLatin1String(\"addressBlockRef\"),\n    QLatin1String(\"registerFileRef\"),\n    QLatin1String(\"registerRef\"),\n    QLatin1String(\"alternateRegisterRef\"),\n    QLatin1String(\"fieldRef\"),\n    QLatin1String(\"\")\n};\n\n//-----------------------------------------------------------------------------\n// Function: FieldReference::IndexedReference::IndexedReference()\n//-----------------------------------------------------------------------------\nFieldReference::IndexedReference::IndexedReference(IndexedReference const& other) :\n    reference_(other.reference_),\n    indices_(other.indices_)\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: FieldReference::IndexedReference::IndexedReference()\n//-----------------------------------------------------------------------------\nFieldReference::IndexedReference::IndexedReference(QString const& reference, QList<QString> const& indices):\n    reference_(reference),\n    indices_(indices)\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: FieldReference::IndexedReference::operator=()\n//-----------------------------------------------------------------------------\nFieldReference::IndexedReference& FieldReference::IndexedReference::operator=(FieldReference::IndexedReference const& other)\n{\n    if (this != &other)\n    {\n        reference_ = other.reference_;\n        indices_ = other.indices_;\n    }\n\n    return *this;\n}\n\n//-----------------------------------------------------------------------------\n// Function: FieldReference::FieldReference()\n//-----------------------------------------------------------------------------\nFieldReference::FieldReference()\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: FieldReference::FieldReference()\n//-----------------------------------------------------------------------------\nFieldReference::FieldReference(FieldReference const& other) :\n    addressSpaceRef_(other.addressSpaceRef_),\n    memoryMapRef_(other.memoryMapRef_),\n    memoryRemapRef_(other.memoryRemapRef_),\n    addressBlockRef_(other.addressBlockRef_),\n    registerRef_(other.registerRef_),\n    alternateRegisterRef_(other.alternateRegisterRef_),\n    fieldRef_(other.fieldRef_)\n{\n    Copy::copyList(other.bankRefs_, bankRefs_);\n    Copy::copyList(other.registerFileRefs_, registerFileRefs_);\n}\n\n//-----------------------------------------------------------------------------\n// Function: FieldReference::operator=()\n//-----------------------------------------------------------------------------\nFieldReference& FieldReference::operator=(FieldReference const& other)\n{\n    if (this != &other)\n    {\n        addressSpaceRef_ = other.addressSpaceRef_;\n        memoryMapRef_ = other.memoryMapRef_;\n        memoryRemapRef_ = other.memoryRemapRef_;\n        addressBlockRef_ = other.addressBlockRef_;\n        registerRef_ = other.registerRef_;\n        alternateRegisterRef_ = other.alternateRegisterRef_;\n        fieldRef_ = other.fieldRef_;\n\n        bankRefs_->clear();\n        Copy::copyList(other.bankRefs_, bankRefs_);\n\n        registerFileRefs_->clear();\n        Copy::copyList(other.registerFileRefs_, registerFileRefs_);\n    }\n\n    return *this;\n}\n\n//-----------------------------------------------------------------------------\n// Function: FieldReference::setReference()\n//-----------------------------------------------------------------------------\nvoid FieldReference::setReference(QSharedPointer<IndexedReference> reference, FieldReference::Type refType)\n{\n    switch (refType)\n    {\n    case FieldReference::Type::ADDRESS_SPACE:\n        addressSpaceRef_ = reference;\n        break;\n    case FieldReference::Type::MEMORY_MAP:\n        memoryMapRef_ = reference;\n        break;\n    case FieldReference::Type::MEMORY_REMAP:\n        memoryRemapRef_ = reference;\n        break;\n    case FieldReference::Type::BANK:\n        if (!bankRefs_)\n        {\n            bankRefs_ = QSharedPointer<QList<QSharedPointer<IndexedReference> > >(\n                new QList<QSharedPointer<IndexedReference> >());\n        }\n        bankRefs_->append(reference);\n        break;\n    case FieldReference::Type::ADDRESS_BLOCK:\n        addressBlockRef_ = reference;\n        break;\n    case FieldReference::Type::REGISTER_FILE:\n        if (!registerFileRefs_)\n        {\n            registerFileRefs_ = QSharedPointer<QList<QSharedPointer<IndexedReference> > >(\n                new QList<QSharedPointer<IndexedReference> >());\n        }\n        registerFileRefs_->append(reference);\n        break;\n    case FieldReference::Type::REGISTER:\n        registerRef_ = reference;\n        break;\n    case FieldReference::Type::ALTERNATE_REGISTER:\n        alternateRegisterRef_ = reference;\n        break;\n    case FieldReference::Type::FIELD:\n        fieldRef_ = reference;\n        break;\n    default:\n        break;\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: FieldReference::getReference()\n//-----------------------------------------------------------------------------\nQSharedPointer<FieldReference::IndexedReference> FieldReference::getReference(Type refType) const\n{\n    switch (refType)\n    {\n    case FieldReference::Type::ADDRESS_SPACE:\n        return addressSpaceRef_;\n    case FieldReference::Type::MEMORY_MAP:\n        return memoryMapRef_;\n    case FieldReference::Type::MEMORY_REMAP:\n        return memoryRemapRef_;\n    case FieldReference::Type::ADDRESS_BLOCK:\n        return addressBlockRef_;\n    case FieldReference::Type::REGISTER:\n        return registerRef_;\n    case FieldReference::Type::ALTERNATE_REGISTER:\n        return alternateRegisterRef_;\n    case FieldReference::Type::FIELD:\n        return fieldRef_;\n    default:\n        return nullptr;\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: FieldReference::clearReference()\n//-----------------------------------------------------------------------------\nvoid FieldReference::clearReference(Type refType)\n{\n    switch (refType)\n    {\n    case FieldReference::Type::ADDRESS_SPACE:\n        addressSpaceRef_.clear();\n        break;\n    case FieldReference::Type::MEMORY_MAP:\n        memoryMapRef_.clear();\n        break;\n    case FieldReference::Type::MEMORY_REMAP:\n        memoryRemapRef_.clear();\n        break;\n    case FieldReference::Type::BANK:\n        bankRefs_->clear();\n        break;\n    case FieldReference::Type::ADDRESS_BLOCK:\n        addressBlockRef_.clear();\n        break;\n    case FieldReference::Type::REGISTER_FILE:\n        registerFileRefs_->clear();\n        break;\n    case FieldReference::Type::REGISTER:\n        registerRef_.clear();\n        break;\n    case FieldReference::Type::ALTERNATE_REGISTER:\n        alternateRegisterRef_.clear();\n        break;\n    case FieldReference::Type::FIELD:\n        fieldRef_.clear();\n        break;\n    default:\n        break;\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: FieldReference::getMultipleReference()\n//-----------------------------------------------------------------------------\nQSharedPointer<QList<QSharedPointer<FieldReference::IndexedReference> > > FieldReference::getMultipleReference(Type refType) const\n{\n    QSharedPointer<QList<QSharedPointer<FieldReference::IndexedReference> > > referenceList(\n        new QList<QSharedPointer<FieldReference::IndexedReference> >());\n\n    switch (refType)\n    {\n    case FieldReference::Type::ADDRESS_SPACE:\n        referenceList->append(addressSpaceRef_);\n        break;\n    case FieldReference::Type::MEMORY_MAP:\n        referenceList->append(memoryMapRef_);\n        break;\n    case FieldReference::Type::MEMORY_REMAP:\n        referenceList->append(memoryRemapRef_);\n        break;\n    case FieldReference::Type::BANK:\n        return bankRefs_;\n    case FieldReference::Type::ADDRESS_BLOCK:\n        referenceList->append(addressBlockRef_);\n        break;\n    case FieldReference::Type::REGISTER_FILE:\n        return registerFileRefs_;\n    case FieldReference::Type::REGISTER:\n        referenceList->append(registerRef_);\n        break;\n    case FieldReference::Type::ALTERNATE_REGISTER:\n        referenceList->append(alternateRegisterRef_);\n        break;\n    case FieldReference::Type::FIELD:\n        referenceList->append(fieldRef_);\n        break;\n    default:\n        break;\n    }\n\n    return referenceList;\n}\n\n//-----------------------------------------------------------------------------\n// Function: FieldReference::str2Type()\n//-----------------------------------------------------------------------------\nFieldReference::Type FieldReference::str2Type(QString const& refTypeStr)\n{\n    for (unsigned int i = 0; i < FieldReference::Type::REFERENCE_TYPE_COUNT; ++i)\n    {\n        if (refTypeStr.compare(TYPES_AS_STRINGS[i]) == 0)\n        {\n            return static_cast<FieldReference::Type>(i);\n        }\n    }\n\n    return FieldReference::Type::REFERENCE_TYPE_COUNT;\n}\n\n//-----------------------------------------------------------------------------\n// Function: FieldReference::type2Str()\n//-----------------------------------------------------------------------------\nQString FieldReference::type2Str(FieldReference::Type refType)\n{\n    return TYPES_AS_STRINGS[refType];\n}\n\n"
  },
  {
    "path": "IPXACTmodels/Component/FieldReference.h",
    "content": "//-----------------------------------------------------------------------------\n// File: FieldReference.h\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Anton Hagqvist\n// Date: 26.7.2023\n//\n// Description:\n// Reference to a field in the encapsulating component. Describes the elements \n// in the fieldReferenceGroup and fieldSliceReferenceGroup.\n//-----------------------------------------------------------------------------\n\n#ifndef FIELDREFERENCE_H\n#define FIELDREFERENCE_H\n\n#include <IPXACTmodels/ipxactmodels_global.h>\n\n#include <array>\n\n#include <QString>\n#include <QList>\n\nclass IPXACTMODELS_EXPORT FieldReference\n{\npublic:\n    //! Type of reference in the field reference group.\n    enum Type\n    {\n        ADDRESS_SPACE = 0,\n        MEMORY_MAP,\n        MEMORY_REMAP,\n        BANK,\n        ADDRESS_BLOCK,\n        REGISTER_FILE,\n        REGISTER,\n        ALTERNATE_REGISTER,\n        FIELD,\n        REFERENCE_TYPE_COUNT\n    };\n\n    //! Reference with indices.x\n    struct IPXACTMODELS_EXPORT IndexedReference\n    {\n        //! The reference.\n        QString reference_;\n\n        //! The indices of the reference. Is empty for references without indices.\n        QList<QString> indices_;\n\n        IndexedReference() = default;\n\n        IndexedReference(QString const& reference, QList<QString> const& indices = QList<QString>());\n        \n        IndexedReference(IndexedReference const& other);\n        IndexedReference& operator=(IndexedReference const& other);\n    };\n\n    /*!\n     *\tThe constructor.\n     */\n    FieldReference();\n\n    /*!\n     *\tCopy constructor.\n     */\n    FieldReference(FieldReference const& other);\n\n    FieldReference& operator=(FieldReference const& other);\n\n    virtual ~FieldReference() = default;\n\n    //! The above types as strings matching the IP-XACT element names.\n    static const QString TYPES_AS_STRINGS[];\n\n    /*!\n     *\tSets a reference by type. If the reference is of type bank or register file,\n     *  it will be added to the respective reference list.\n     *  \n     *    @param [in] reference     The reference to set.\n     *    @param [in] refType       The reference type.\n     */\n    void setReference(QSharedPointer<IndexedReference> reference, FieldReference::Type refType);\n\n    /*!\n     *\tGet the reference of a specific type.\n     *  \n     *    @param [in] refType     The reference type.\n     *\t    \n     * \t    @return The reference, or nullptr if invalid refType or the reference is a multiple reference.\n     */\n    QSharedPointer<IndexedReference> getReference(FieldReference::Type refType) const;\n    \n    void clearReference(FieldReference::Type refType);\n\n    /*!\n     *\tGet a list of references of a specific type. Can be called for all types, but can have multiple references\n     *  only for types bank and register file.\n     *  \n     *    @param [in] refType     The type of reference to get.\n     *\t    \n     * \t    @return A list of references of a specific type.\n     */\n    QSharedPointer<QList<QSharedPointer<IndexedReference> > > getMultipleReference(FieldReference::Type refType) const;\n    \n    //! Converts a reference type string to type.\n    static FieldReference::Type str2Type(QString const& refTypeStr);\n\n    //! Converts a reference type to string.\n    static QString type2Str(FieldReference::Type refType);\n\nprivate:\n\n    //! The address space reference.\n    QSharedPointer<IndexedReference> addressSpaceRef_;\n\n    //! The memory map reference.\n    QSharedPointer<IndexedReference> memoryMapRef_;\n\n    //! The memory remap reference.\n    QSharedPointer<IndexedReference> memoryRemapRef_;\n    \n    //! The bank references.\n    QSharedPointer<QList<QSharedPointer<IndexedReference> > > bankRefs_ = \n        QSharedPointer<QList<QSharedPointer<IndexedReference> > >(new QList<QSharedPointer<IndexedReference> >());\n\n    //! The address block reference.\n    QSharedPointer<IndexedReference> addressBlockRef_;\n\n    //! The register file references.\n    QSharedPointer<QList<QSharedPointer<IndexedReference> > > registerFileRefs_ =\n        QSharedPointer<QList<QSharedPointer<IndexedReference> > >(new QList<QSharedPointer<IndexedReference> >());\n\n    //! The register reference.\n    QSharedPointer<IndexedReference> registerRef_;\n\n    //! The alternate register reference.\n    QSharedPointer<IndexedReference> alternateRegisterRef_;\n\n    //! The field reference.\n    QSharedPointer<IndexedReference> fieldRef_;\n};\n\n#endif // FIELDREFERENCE_H\n"
  },
  {
    "path": "IPXACTmodels/Component/FieldReferenceReader.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: FieldReferenceReader.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Anton Hagqvist\n// Date: 1.8.2023\n//\n// Description:\n// Reads a field reference group from IP-XACT XML.\n//-----------------------------------------------------------------------------\n\n#include \"FieldReferenceReader.h\"\n\n//-----------------------------------------------------------------------------\n// Function: FieldReferenceReader::createFieldReferenceFrom()\n//-----------------------------------------------------------------------------\nQSharedPointer<FieldReference> FieldReferenceReader::createFieldReferenceFrom(QDomNode const& groupNode)\n{\n    QSharedPointer<FieldReference> newFieldReference(new FieldReference());\n\n    auto referenceElementNodes = groupNode.childNodes();\n\n    for (int i = 0; i < referenceElementNodes.size(); ++i)\n    {\n        auto currentNode = referenceElementNodes.at(i);\n\n        Details::readSingleReferenceElement(referenceElementNodes.at(i), newFieldReference);\n    }\n\n    return newFieldReference;\n}\n\n//-----------------------------------------------------------------------------\n// Function: FieldReferenceReader::Details::readSingleReferenceElement()\n//-----------------------------------------------------------------------------\nvoid FieldReferenceReader::Details::readSingleReferenceElement(QDomNode const& currentNode,\n    QSharedPointer<FieldReference> newFieldReference)\n{\n    auto nodeName = currentNode.nodeName().split(QStringLiteral(\":\")).back();\n    auto refType = FieldReference::str2Type(nodeName);\n    auto refValue = currentNode.attributes().namedItem(nodeName).nodeValue();\n\n    if (refValue.isEmpty() || refType == FieldReference::REFERENCE_TYPE_COUNT)\n    {\n        return;\n    }\n\n    QSharedPointer<FieldReference::IndexedReference> newFieldRefElement(new FieldReference::IndexedReference());\n    newFieldRefElement->reference_ = refValue;\n\n    // Read possible indices.\n    if (currentNode.hasChildNodes())\n    {\n        Details::readReferenceIndices(currentNode, newFieldRefElement);\n    }\n\n    newFieldReference->setReference(newFieldRefElement, refType);\n}\n\n//-----------------------------------------------------------------------------\n// Function: FieldReferenceReader::Details::readReferenceIndices()\n//-----------------------------------------------------------------------------\nvoid FieldReferenceReader::Details::readReferenceIndices(QDomNode const& referenceNode, \n    QSharedPointer<FieldReference::IndexedReference> newFieldRefElement)\n{\n    auto indicesNode = referenceNode.firstChildElement(QStringLiteral(\"ipxact:indices\"));\n    auto const& indexNodes = indicesNode.childNodes();\n\n    for (auto i = 0; i < indexNodes.size(); ++i)\n    {\n        auto currentIndexNode = indexNodes.at(i);\n\n        if (currentIndexNode.nodeName() == QStringLiteral(\"ipxact:index\"))\n        {\n            newFieldRefElement->indices_.append(currentIndexNode.firstChild().nodeValue());\n        }\n    }\n}\n"
  },
  {
    "path": "IPXACTmodels/Component/FieldReferenceReader.h",
    "content": "//-----------------------------------------------------------------------------\n// File: FieldReferenceReader.h\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Anton Hagqvist\n// Date: 1.8.2023\n//\n// Description:\n// Reads a field reference group from IP-XACT XML.\n//-----------------------------------------------------------------------------\n\n#ifndef FIELDREFERENCEREADER_H\n#define FIELDREFERENCEREADER_H\n\n#include <IPXACTmodels/ipxactmodels_global.h>\n\n#include <IPXACTmodels/Component/FieldReference.h>\n\n#include <QDomNode>\n\nnamespace FieldReferenceReader\n{\n\n    /*!\n     *\tCreate a field reference from a given parent document node.\n     *  \n     *    @param [in] groupNode     The containing element of the field reference group.\n     *\t    \n     * \t    @return The created field reference.\n     */\n    IPXACTMODELS_EXPORT QSharedPointer<FieldReference> createFieldReferenceFrom(QDomNode const& groupNode);\n\n    namespace Details\n    {\n        /*!\n         *\tReads a single refrence element of the field reference.\n         *  \n         *    @param [in] currentNode            The current XML document node.\n         *    @param [in] newFieldReference      The created field reference.\n         */\n        void readSingleReferenceElement(QDomNode const& currentNode, \n            QSharedPointer<FieldReference> newFieldReference);\n\n        /*!\n         *\tRead the indices of a field reference element.\n         *  \n         *    @param [in] referenceNode           The XML document node of the field reference element.\n         *    @param [in] newFieldRefElement      The created field reference.\n         */\n        void readReferenceIndices(QDomNode const& referenceNode, \n            QSharedPointer<FieldReference::IndexedReference> newFieldRefElement);\n    }\n}\n\n\n#endif // FIELDREFERENCEREADER_H\n"
  },
  {
    "path": "IPXACTmodels/Component/FieldReferenceWriter.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: FieldReferenceWriter.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Anton Hagqvist\n// Date: 1.8.2023\n//\n// Description:\n// Writer for the fieldReferenceGroup group.\n//-----------------------------------------------------------------------------\n\n#include \"FieldReferenceWriter.h\"\n\n//-----------------------------------------------------------------------------\n// Function: FieldReferenceWriter::writeFieldReference()\n//-----------------------------------------------------------------------------\nvoid FieldReferenceWriter::writeFieldReference(QXmlStreamWriter& writer, \n    QSharedPointer<FieldReference> fieldReference)\n{\n    if (!fieldReference)\n    {\n        return;\n    }\n\n    for (auto i = 0; i < FieldReference::Type::REFERENCE_TYPE_COUNT; ++i)\n    {\n        if (i == FieldReference::BANK || i == FieldReference::REGISTER_FILE)\n        {\n            Details::writeMultipleFieldReference(writer, fieldReference, static_cast<FieldReference::Type>(i));\n        }\n        else\n        {\n            if (auto reference = fieldReference->getReference(static_cast<FieldReference::Type>(i));\n                reference != nullptr)\n            {\n                Details::writeSingleFieldReference(writer, reference, static_cast<FieldReference::Type>(i));\n            }\n        }\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: FieldReferenceWriter::Details::writeSingleFieldReference()\n//-----------------------------------------------------------------------------\nvoid FieldReferenceWriter::Details::writeSingleFieldReference(QXmlStreamWriter& writer, \n    QSharedPointer<FieldReference::IndexedReference> referenceElement, FieldReference::Type refType)\n{\n    if (referenceElement)\n    {\n        auto typeAsString = FieldReference::type2Str(refType);\n        auto elementName = QStringLiteral(\"ipxact:\") + typeAsString;\n\n        writer.writeStartElement(elementName); // ipxact:____Ref\n        writer.writeAttribute(typeAsString, referenceElement->reference_);\n\n        if (!referenceElement->indices_.isEmpty())\n        {\n            Details::writeFieldReferenceIndices(writer, referenceElement);\n        }\n\n        writer.writeEndElement(); // ipxact:____Ref\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: FieldReferenceWriter::Details::writeMultipleFieldReference()\n//-----------------------------------------------------------------------------\nvoid FieldReferenceWriter::Details::writeMultipleFieldReference(QXmlStreamWriter& writer, \n    QSharedPointer<FieldReference> fieldReference, FieldReference::Type refType)\n{\n    auto references = fieldReference->getMultipleReference(refType);\n\n    if (!references->isEmpty())\n    {\n        for (auto const& reference : *references)\n        {\n            writeSingleFieldReference(writer, reference, refType);\n        }\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: FieldReferenceWriter::Details::writeFieldReferenceIndices()\n//-----------------------------------------------------------------------------\nvoid FieldReferenceWriter::Details::writeFieldReferenceIndices(QXmlStreamWriter& writer, \n    QSharedPointer<FieldReference::IndexedReference> referenceElement)\n{\n    writer.writeStartElement(QStringLiteral(\"ipxact:indices\"));\n\n    for (auto const& index : referenceElement->indices_)\n    {\n        writer.writeTextElement(QStringLiteral(\"ipxact:index\"), index);\n    }\n\n    writer.writeEndElement(); // ipxact:indices\n}\n"
  },
  {
    "path": "IPXACTmodels/Component/FieldReferenceWriter.h",
    "content": "//-----------------------------------------------------------------------------\n// File: FieldReferenceWriter.h\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Anton Hagqvist\n// Date: 1.8.2023\n//\n// Description:\n// Writer for the fieldReferenceGroup group.\n//-----------------------------------------------------------------------------\n\n#ifndef FIELDREFERENCEWRITER_H\n#define FIELDREFERENCEWRITER_H\n\n#include <IPXACTmodels/ipxactmodels_global.h>\n\n#include <IPXACTmodels/Component/FieldReference.h>\n\n#include <QXmlStreamWriter>\n\nnamespace FieldReferenceWriter\n{\n    \n    /*!\n     *\tWrites a given field reference to XML.\n     *  \n     *    @param [in] writer              The XML writer to use.\n     *    @param [in] fieldReference      The field reference to write.\n     */\n    IPXACTMODELS_EXPORT void writeFieldReference(QXmlStreamWriter& writer, QSharedPointer<FieldReference> fieldReference);\n\n    namespace Details\n    {\n        /*!\n         *\tWrite a given reference element of specified type.\n         *  \n         *    @param [in] writer               The XML writer to use.\n         *    @param [in] referenceElement     The field reference element to write.\n         *    @param [in] refType              The reference type to write.\n         */\n        void writeSingleFieldReference(QXmlStreamWriter& writer,\n            QSharedPointer<FieldReference::IndexedReference> referenceElement, FieldReference::Type refType);\n\n        /*!\n         *\tWrite a list of similar field reference elements, e.g. bank refrences or register file references.\n         *  \n         *    @param [in] writer             The XML writer to use.\n         *    @param [in] fieldReference     The field reference to write.\n         *    @param [in] refType            The reference type to write.\n         */\n        void writeMultipleFieldReference(QXmlStreamWriter& writer, QSharedPointer<FieldReference> fieldReference,\n            FieldReference::Type refType);\n\n        /*!\n         *\tWrite the indices of a reference element.\n         *  \n         *    @param [in] writer               The XML writer to use.\n         *    @param [in] referenceElement     The field reference element to write.\n         */\n        void writeFieldReferenceIndices(QXmlStreamWriter& writer, \n            QSharedPointer<FieldReference::IndexedReference> referenceElement);\n    }\n}\n\n#endif // FIELDREFERENCEWRITER_H\n\n"
  },
  {
    "path": "IPXACTmodels/Component/FieldReset.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: FieldReset.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Mikko Teuho\n// Date: 09.01.2019\n//\n// Description:\n// Describes the ipxact:reset element.\n//-----------------------------------------------------------------------------\n\n#include \"FieldReset.h\"\n\n//-----------------------------------------------------------------------------\n// Function: FieldReset::FieldReset()\n//-----------------------------------------------------------------------------\nFieldReset::FieldReset():\nresetTypeReference_(),\nresetValue_(),\nresetMask_()\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: FieldReset::FieldReset()\n//-----------------------------------------------------------------------------\nFieldReset::FieldReset(const FieldReset& other):\nresetTypeReference_(other.resetTypeReference_),\nresetValue_(other.resetValue_),\nresetMask_(other.resetMask_)\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: FieldReset::operator=()\n//-----------------------------------------------------------------------------\nFieldReset& FieldReset::operator=(const FieldReset& other)\n{\n    if (this != &other)\n    {\n        resetTypeReference_ = other.resetTypeReference_;\n        resetValue_ = other.resetValue_;\n        resetMask_ = other.resetMask_;\n    }\n\n    return *this;\n}\n\n//-----------------------------------------------------------------------------\n// Function: FieldReset::~FieldReset()\n//-----------------------------------------------------------------------------\nFieldReset::~FieldReset()\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: FieldReset::getResetTypeReference()\n//-----------------------------------------------------------------------------\nQString FieldReset::getResetTypeReference() const\n{\n    return resetTypeReference_;\n}\n\n//-----------------------------------------------------------------------------\n// Function: FieldReset::setResetTypeReference()\n//-----------------------------------------------------------------------------\nvoid FieldReset::setResetTypeReference(QString const& newResetTypeReference)\n{\n    resetTypeReference_ = newResetTypeReference;\n}\n\n//-----------------------------------------------------------------------------\n// Function: FieldReset::getResetValue()\n//-----------------------------------------------------------------------------\nQString FieldReset::getResetValue() const\n{\n    return resetValue_;\n}\n\n//-----------------------------------------------------------------------------\n// Function: FieldReset::setResetValue()\n//-----------------------------------------------------------------------------\nvoid FieldReset::setResetValue(QString const& newResetValue)\n{\n    resetValue_ = newResetValue;\n}\n\n//-----------------------------------------------------------------------------\n// Function: FieldReset::getResetMask()\n//-----------------------------------------------------------------------------\nQString FieldReset::getResetMask() const\n{\n    return resetMask_;\n}\n\n//-----------------------------------------------------------------------------\n// Function: FieldReset::setResetMask()\n//-----------------------------------------------------------------------------\nvoid FieldReset::setResetMask(QString const& newResetMask)\n{\n    resetMask_ = newResetMask;\n}\n"
  },
  {
    "path": "IPXACTmodels/Component/FieldReset.h",
    "content": "//-----------------------------------------------------------------------------\n// File: FieldReset.h\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Mikko Teuho\n// Date: 09.01.2019\n//\n// Description:\n// Describes the ipxact:reset element.\n//-----------------------------------------------------------------------------\n\n#ifndef FIELDRESET_H\n#define FIELDRESET_H\n\n\n#include <IPXACTmodels/ipxactmodels_global.h>\n\n#include <QString>\n\n//-----------------------------------------------------------------------------\n//! Describes the ipxact:reset element.\n//-----------------------------------------------------------------------------\nclass IPXACTMODELS_EXPORT FieldReset\n{\n\npublic:\n\n\t/*!\n     *  The constructor.\n     */\n\tFieldReset();\n\n\t/*!\n     *  Copy constructor.\n     */\n    FieldReset(const FieldReset& other);\n\n\t/*!\n     *  Assignment operator.\n     */\n    FieldReset& operator=(const FieldReset& other);\n\n\t/*!\n     *  The destructor.\n     */\n    virtual ~FieldReset();\n\n    /*!\n     *  Get the reset type reference.\n     *\n     *    @return The reset type reference.\n     */\n    QString getResetTypeReference() const;\n\n    /*!\n     *  Set the reset type reference.\n     *\n     *    @param [in] newResetTypeReference   The new reset type reference.\n     */\n    void setResetTypeReference(QString const& newResetTypeReference);\n\n    /*!\n     *  Get the reset value.\n     *\n     *    @return The reset value.\n     */\n    QString getResetValue() const;\n\n    /*!\n     *  Set the reset value.\n     *\n     *    @param [in] newResetValue   The new reset value.\n     */\n    void setResetValue(QString const& newResetValue);\n\n    /*!\n     *  Get the reset mask.\n     *\n     *    @return The reset mask.\n     */\n    QString getResetMask() const;\n\n    /*!\n     *  Set the reset mask.\n     *\n     *    @param [in] newResetMask    The new reset mask.\n     */\n    void setResetMask(QString const& newResetMask);\n\nprivate:\n\n\t//-----------------------------------------------------------------------------\n\t// Data.\n\t//-----------------------------------------------------------------------------\n\n    //! The type of the defined reset.\n    QString resetTypeReference_;\n\n    //! The reset value.\n    QString resetValue_;\n\n    //! Defines the bits that have a known reset value.\n    QString resetMask_;\n};\n\n#endif // FIELDRESET_H\n"
  },
  {
    "path": "IPXACTmodels/Component/FieldSlice.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: FieldSlice.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Esko Pekkarinen\n// Date: 18.8.2023\n//\n// Description:\n// Describes the ipxact:fieldSlice element.\n//-----------------------------------------------------------------------------\n\n#include \"FieldSlice.h\"\n\n#include <IPXACTmodels/common/Enumeration.h>\n\n#include <QList>\n#include <QString>\n\n//-----------------------------------------------------------------------------\n// Function: FieldSlice::FieldSlice()\n//-----------------------------------------------------------------------------\nFieldSlice::FieldSlice(QString const& name):\n    NameGroup(name),\n    FieldReference(),\n    Range(QString(), QString())\n{\n    \n}\n\n//-----------------------------------------------------------------------------\n// Function: FieldSlice::FieldSlice()\n//-----------------------------------------------------------------------------\nFieldSlice::FieldSlice( const FieldSlice& other ):\n    NameGroup(other),\n    FieldReference(other),\n    Range(other)\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: FieldSlice::operator=()\n//-----------------------------------------------------------------------------\nFieldSlice& FieldSlice::operator=( const FieldSlice& other )\n{\n\tif (this != &other)\n    {\n        NameGroup::operator=(other);\n        FieldReference::operator=(other);\n        Range::operator=(other);\n\t}\n\treturn *this;\n}\n\n//-----------------------------------------------------------------------------\n// Function: FieldSlice::~FieldSlice()\n//-----------------------------------------------------------------------------\nFieldSlice::~FieldSlice()\n{\n\n}\n"
  },
  {
    "path": "IPXACTmodels/Component/FieldSlice.h",
    "content": "//-----------------------------------------------------------------------------\n// File: FieldSlice.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Esko Pekkarinen\n// Date: 18.8.2023\n//\n// Description:\n// Describes the ipxact:fieldSlice element.\n//-----------------------------------------------------------------------------\n\n#ifndef FIELDSLICE_H\n#define FIELDSLICE_H\n\n#include <IPXACTmodels/ipxactmodels_global.h>\n#include <IPXACTmodels/common/NameGroup.h>\n\n#include <IPXACTmodels/common/Range.h>\n\n#include <IPXACTmodels/Component/FieldReference.h>\n\n#include <QSharedPointer>\n#include <QString>\n#include <QStringList>\n#include <QList>\n\n//-----------------------------------------------------------------------------\n//! Equals the ipxact:FieldSlice element in IP-Xact specification.\n//-----------------------------------------------------------------------------\nclass IPXACTMODELS_EXPORT FieldSlice : public NameGroup, public FieldReference, public Range\n{\n\npublic:\n\n\tusing List = QSharedPointer<QList<QSharedPointer<FieldSlice> > >;\n\n\t//! The default constructor.\n\texplicit FieldSlice(QString const& name = QString());\n\n\t//! Copy constructor\n\tFieldSlice(const FieldSlice& other);\n\n\t//! Assignment operator\n\tFieldSlice& operator=(const FieldSlice& other);\n\n\t//! The destructor\n\tvirtual ~FieldSlice();\n\n\n};\n\n#endif /* FIELDSLICE_H */\n"
  },
  {
    "path": "IPXACTmodels/Component/FieldWriter.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: FieldWriter.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 24.09.2015\r\n//\r\n// Description:\r\n// Writer for IP-XACT field element.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"FieldWriter.h\"\r\n#include \"FieldReferenceWriter.h\"\r\n#include \"FieldAccessPolicyWriter.h\"\r\n#include \"Field.h\"\r\n#include \"WriteValueConstraint.h\"\r\n#include \"MemoryArrayWriter.h\"\r\n#include \"EnumeratedValueWriter.h\"\r\n#include \"FieldReset.h\"\r\n\r\n#include <IPXACTmodels/common/NameGroupWriter.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FieldWriter::writeField()\r\n//-----------------------------------------------------------------------------\r\nvoid FieldWriter::writeField(QXmlStreamWriter& writer, QSharedPointer<Field> field, Document::Revision docRevision)\r\n{\r\n    writer.writeStartElement(QStringLiteral(\"ipxact:field\"));\r\n\r\n    Details::writeID(writer, field->getId(), docRevision);\r\n\r\n    NameGroupWriter::writeNameGroup(writer, field, docRevision);\r\n\r\n    if (docRevision == Document::Revision::Std14)\r\n    {\r\n        CommonItemsWriter::writeIsPresent(writer, field->getIsPresent());\r\n    }\r\n    \r\n    Details::writeMemoryArray(writer, field, docRevision);\r\n    \r\n    writer.writeTextElement(QStringLiteral(\"ipxact:bitOffset\"), field->getBitOffset());\r\n\r\n    if (docRevision == Document::Revision::Std14)\r\n    {\r\n        Details::writeFieldData2014(writer, field);\r\n    }\r\n    else if (docRevision == Document::Revision::Std22)\r\n    {\r\n        Details::writeFieldData2022(writer, field);\r\n    }\r\n\r\n    CommonItemsWriter::writeParameters(writer, field->getParameters(), docRevision);\r\n\r\n    CommonItemsWriter::writeVendorExtensions(writer, field);\r\n\r\n    writer.writeEndElement(); // ipxact:field\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FieldWriter::Details::writeID()\r\n//-----------------------------------------------------------------------------\r\nvoid FieldWriter::Details::writeID(QXmlStreamWriter& writer, QString const& fieldID,\r\n    Document::Revision docRevision)\r\n{\r\n    if (!fieldID.isEmpty() && docRevision == Document::Revision::Std14)\r\n    {\r\n        writer.writeAttribute(QStringLiteral(\"fieldID\"), fieldID);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FieldWriter::Details::writeMemoryArray()\r\n//-----------------------------------------------------------------------------\r\nvoid FieldWriter::Details::writeMemoryArray(QXmlStreamWriter& writer, QSharedPointer<Field> field,\r\n    Document::Revision docRevision)\r\n{\r\n    if (auto memArray = field->getMemoryArray();\r\n        memArray && docRevision == Document::Revision::Std22)\r\n    {\r\n        MemoryArrayWriter::writeMemoryArray(writer, memArray, docRevision, true);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FieldWriter::Details::writeFieldDefinitionRef()\r\n//-----------------------------------------------------------------------------\r\nvoid FieldWriter::Details::writeFieldDefinitionRef(QXmlStreamWriter& writer, QSharedPointer<Field> field)\r\n{\r\n    if (auto const& fieldDefRef = field->getFieldDefinitionRef(); !fieldDefRef.isEmpty())\r\n    {\r\n        writer.writeStartElement(QStringLiteral(\"ipxact:fieldDefinitionRef\"));\r\n\r\n        writer.writeAttribute(QStringLiteral(\"typeDefinitions\"), field->getTypeDefinitionsRef());\r\n\r\n        writer.writeCharacters(field->getFieldDefinitionRef());\r\n\r\n        writer.writeEndElement(); // ixpact:fieldDefinitionRef\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FieldWriter::Details::writeResets()\r\n//-----------------------------------------------------------------------------\r\nvoid FieldWriter::Details::writeResets(QXmlStreamWriter& writer, QSharedPointer<Field> field)\r\n{\r\n    if(field->getResets() && !field->getResets()->isEmpty())\r\n    {\r\n        writer.writeStartElement(QStringLiteral(\"ipxact:resets\"));\r\n        \r\n        foreach (QSharedPointer<FieldReset> reset, *(field->getResets()))\r\n        {\r\n            if (reset && (!reset->getResetTypeReference().isEmpty() || !reset->getResetValue().isEmpty() ||\r\n                !reset->getResetMask().isEmpty()))\r\n            {\r\n                writer.writeStartElement(QStringLiteral(\"ipxact:reset\"));\r\n                \r\n                if (!reset->getResetTypeReference().isEmpty())\r\n                {\r\n                    writer.writeAttribute(QStringLiteral(\"resetTypeRef\"), reset->getResetTypeReference());\r\n                }\r\n              \r\n                writer.writeTextElement(QStringLiteral(\"ipxact:value\"), reset->getResetValue());\r\n              \r\n                if (!reset->getResetMask().isEmpty())\r\n                {\r\n                    writer.writeTextElement(QStringLiteral(\"ipxact:mask\"), reset->getResetMask());\r\n                }\r\n              \r\n                writer.writeEndElement(); // ipxact:reset\r\n            }\r\n        }\r\n\r\n        writer.writeEndElement(); // ipxact:resets\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FieldWriter::Details::writeTypeIdentifier()\r\n//-----------------------------------------------------------------------------\r\nvoid FieldWriter::Details::writeTypeIdentifier(QXmlStreamWriter& writer, QSharedPointer<Field> field)\r\n{\r\n    if (!field->getTypeIdentifier().isEmpty())\r\n    {\r\n        writer.writeTextElement(QStringLiteral(\"ipxact:typeIdentifier\"), field->getTypeIdentifier());\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FieldWriter::Details::writeVolatile()\r\n//-----------------------------------------------------------------------------\r\nvoid FieldWriter::Details::writeVolatile(QXmlStreamWriter& writer, QSharedPointer<Field> field)\r\n{\r\n    if (!field->getVolatile().toString().isEmpty())\r\n    {\r\n        writer.writeTextElement(QStringLiteral(\"ipxact:volatile\"), field->getVolatile().toString());\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FieldWriter::Details::writeAccess()\r\n//-----------------------------------------------------------------------------\r\nvoid FieldWriter::Details::writeAccess(QXmlStreamWriter& writer, QSharedPointer<Field> field)\r\n{\r\n    if (field->getAccess() != AccessTypes::ACCESS_COUNT)\r\n    {\r\n        QString access = AccessTypes::access2Str(field->getAccess());\r\n        writer.writeTextElement(QStringLiteral(\"ipxact:access\"), access);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FieldWriter::Details::writeEnumerations()\r\n//-----------------------------------------------------------------------------\r\nvoid FieldWriter::Details::writeEnumerations(QXmlStreamWriter& writer, QSharedPointer<Field> field)\r\n{\r\n    if (!field->getEnumeratedValues()->isEmpty())\r\n    {\r\n        EnumeratedValueWriter enumerationWriter;\r\n        writer.writeStartElement(QStringLiteral(\"ipxact:enumeratedValues\"));\r\n\r\n        foreach (QSharedPointer<EnumeratedValue> enumeration, *field->getEnumeratedValues())\r\n        {\r\n            enumerationWriter.writeEnumeratedValue(writer, enumeration);\r\n        }\r\n\r\n        writer.writeEndElement(); // ipxact:enumeratedValues\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FieldWriter::Details::writeModifiedWriteValue()\r\n//-----------------------------------------------------------------------------\r\nvoid FieldWriter::Details::writeModifiedWriteValue(QXmlStreamWriter& writer, QSharedPointer<Field> field)\r\n{\r\n    if (field->getModifiedWrite() != General::MODIFIED_WRITE_COUNT)\r\n    {\r\n        writer.writeStartElement(QStringLiteral(\"ipxact:modifiedWriteValue\"));\r\n\r\n        if (!field->getModifiedWriteModify().isEmpty())\r\n        {\r\n            writer.writeAttribute(QStringLiteral(\"modify\"), field->getModifiedWriteModify());\r\n        }\r\n\r\n        QString modifiedWriteValue = General::modifiedWrite2Str(field->getModifiedWrite());\r\n        writer.writeCharacters(modifiedWriteValue);\r\n\r\n        writer.writeEndElement(); // ipxact:modifiedWriteValue\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FieldWriter::Details::writeWriteValueConstraint()\r\n//-----------------------------------------------------------------------------\r\nvoid FieldWriter::Details::writeWriteValueConstraint(QXmlStreamWriter& writer,\r\n    QSharedPointer<WriteValueConstraint> writeConstraint)\r\n{\r\n    if (!writeConstraint.isNull())\r\n    {\r\n        writer.writeStartElement(QStringLiteral(\"ipxact:writeValueConstraint\"));\r\n\r\n        if (writeConstraint->getType() == WriteValueConstraint::WRITE_AS_READ)\r\n        {\r\n            writer.writeTextElement(QStringLiteral(\"ipxact:writeAsRead\"), QStringLiteral(\"true\"));\r\n        }\r\n        else if (writeConstraint->getType() == WriteValueConstraint::USE_ENUM)\r\n        {\r\n            writer.writeTextElement(QStringLiteral(\"ipxact:useEnumeratedValues\"), QStringLiteral(\"true\"));\r\n        }\r\n        else if (writeConstraint->getType() == WriteValueConstraint::MIN_MAX)\r\n        {\r\n            writer.writeTextElement(QStringLiteral(\"ipxact:minimum\"), writeConstraint->getMinimum());\r\n            writer.writeTextElement(QStringLiteral(\"ipxact:maximum\"), writeConstraint->getMaximum());\r\n        }\r\n\r\n        writer.writeEndElement(); // ipxact:writeValueConstraint\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FieldWriter::Details::writeReadAction()\r\n//-----------------------------------------------------------------------------\r\nvoid FieldWriter::Details::writeReadAction(QXmlStreamWriter& writer, QSharedPointer<Field> field)\r\n{\r\n    if (field->getReadAction() != General::READ_ACTION_COUNT)\r\n    {\r\n        QString readAction = General::readAction2Str(field->getReadAction());\r\n\r\n        writer.writeStartElement(QStringLiteral(\"ipxact:readAction\"));\r\n\r\n        if (!field->getReadActionModify().isEmpty())\r\n        {\r\n            writer.writeAttribute(QStringLiteral(\"modify\"), field->getReadActionModify());\r\n        }\r\n        writer.writeCharacters(readAction);\r\n\r\n        writer.writeEndElement(); // ipxact:readAction\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FieldWriter::Details::writeTestable()\r\n//-----------------------------------------------------------------------------\r\nvoid FieldWriter::Details::writeTestable(QXmlStreamWriter& writer, QSharedPointer<Field> field)\r\n{\r\n    if (!field->getTestable().toString().isEmpty())\r\n    {\r\n        writer.writeStartElement(QStringLiteral(\"ipxact:testable\"));\r\n\r\n        if (field->getTestConstraint() != General::TESTCONSTRAINT_COUNT)\r\n        {\r\n            QString testConstraint = General::testConstraint2Str(field->getTestConstraint());\r\n            writer.writeAttribute(QStringLiteral(\"testConstraint\"), testConstraint);\r\n        }\r\n\r\n        writer.writeCharacters(field->getTestable().toString());\r\n\r\n        writer.writeEndElement(); // ipxact:testable\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FieldWriter::Details::writeReserved()\r\n//-----------------------------------------------------------------------------\r\nvoid FieldWriter::Details::writeReserved(QXmlStreamWriter& writer, QSharedPointer<Field> field)\r\n{\r\n    if (!field->getReserved().isEmpty())\r\n    {\r\n        writer.writeTextElement(QStringLiteral(\"ipxact:reserved\"), field->getReserved());\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FieldWriter::Details::writeFieldData2014()\r\n//-----------------------------------------------------------------------------\r\nvoid FieldWriter::Details::writeFieldData2014(QXmlStreamWriter& writer, QSharedPointer<Field> field)\r\n{\r\n    Details::writeResets(writer, field);\r\n\r\n    Details::writeTypeIdentifier(writer, field);\r\n\r\n    writer.writeTextElement(QStringLiteral(\"ipxact:bitWidth\"), field->getBitWidth());\r\n\r\n    Details::writeVolatile(writer, field);\r\n\r\n    Details::writeAccess(writer, field);\r\n\r\n    Details::writeEnumerations(writer, field);\r\n\r\n    Details::writeModifiedWriteValue(writer, field);\r\n\r\n    Details::writeWriteValueConstraint(writer, field->getWriteConstraint());\r\n\r\n    Details::writeReadAction(writer, field);\r\n\r\n    Details::writeTestable(writer, field);\r\n\r\n    Details::writeReserved(writer, field);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FieldWriter::Details::writeFieldData2022()\r\n//-----------------------------------------------------------------------------\r\nvoid FieldWriter::Details::writeFieldData2022(QXmlStreamWriter& writer, QSharedPointer<Field> field)\r\n{\r\n    Details::writeFieldDefinitionRef(writer, field);\r\n\r\n    Details::writeTypeIdentifier(writer, field);\r\n\r\n    if (auto const& bitWidth = field->getBitWidth(); !bitWidth.isEmpty())\r\n    {\r\n        writer.writeTextElement(QStringLiteral(\"ipxact:bitWidth\"), bitWidth);\r\n    }\r\n\r\n    Details::writeVolatile(writer, field);\r\n\r\n    Details::writeResets(writer, field);\r\n\r\n    Details::writeFieldReference(writer, field); // ipxact:aliasOf\r\n\r\n    if (auto const& fieldAccessPolicies = field->getFieldAccessPolicies();\r\n        fieldAccessPolicies->isEmpty() == false)\r\n    {\r\n        writer.writeStartElement(QStringLiteral(\"ipxact:fieldAccessPolicies\"));\r\n        \r\n        for (auto const& fieldAccessPolicy : *fieldAccessPolicies)\r\n        {\r\n            FieldAccessPolicyWriter::writeFieldAccessPolicy(writer, fieldAccessPolicy);\r\n        }\r\n\r\n        writer.writeEndElement(); // ipxact:fieldAccessPolicies\r\n    }\r\n\r\n    Details::writeEnumerations(writer, field);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FieldWriter::Details::writeFieldReference()\r\n//-----------------------------------------------------------------------------\r\nvoid FieldWriter::Details::writeFieldReference(QXmlStreamWriter& writer, QSharedPointer<Field> field)\r\n{\r\n    auto fieldReference = field->getFieldReference();\r\n\r\n    if (!fieldReference)\r\n    {\r\n        return;\r\n    }\r\n\r\n    writer.writeStartElement(QStringLiteral(\"ipxact:aliasOf\"));\r\n\r\n    FieldReferenceWriter::writeFieldReference(writer, fieldReference);\r\n\r\n    writer.writeEndElement(); // ipxact:aliasOf\r\n}"
  },
  {
    "path": "IPXACTmodels/Component/FieldWriter.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: FieldWriter.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 24.09.2015\r\n//\r\n// Description:\r\n// Writer for IP-XACT field element.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef FIELDWRITER_H\r\n#define FIELDWRITER_H\r\n\r\n#include <IPXACTmodels/ipxactmodels_global.h>\r\n#include <IPXACTmodels/common/CommonItemsWriter.h>\r\n#include <IPXACTmodels/common/Document.h>\r\n#include \"FieldReference.h\"\r\n\r\n#include <QXmlStreamWriter>\r\n#include <QSharedPointer>\r\n\r\nclass Field;\r\nclass WriteValueConstraint;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Writer for IP-XACT field element.\r\n//-----------------------------------------------------------------------------\r\nnamespace FieldWriter\r\n{\r\n\r\n    /*!\r\n     *  Write a field to an XML file.\r\n     *\r\n     *    @param [in] writer  The used xml writer.\r\n     *    @param [in] field   The field to be written.\r\n     */\r\n    IPXACTMODELS_EXPORT void writeField(QXmlStreamWriter& writer, QSharedPointer<Field> field, Document::Revision docRevision = Document::Revision::Std14);\r\n\r\n    namespace Details\r\n    {\r\n\r\n        /*!\r\n         *  Write the field id attribute.\r\n         *\r\n         *    @param [in] writer      Used XML writer.\r\n         *    @param [in] fieldID     The field id.\r\n         */\r\n        void writeID(QXmlStreamWriter& writer, QString const& fieldID, Document::Revision docRevision);\r\n\r\n        /*!\r\n         *\tWrite the field memory array.\r\n         *  \r\n         *    @param [in] writer  The used xml writer.\r\n         *    @param [in] field   The field to be written.\r\n         */\r\n        void writeMemoryArray(QXmlStreamWriter& writer, QSharedPointer<Field> field, Document::Revision docRevision);\r\n\r\n        /*!\r\n         *\tWrite the field definition reference.\r\n         *  \r\n         *    @param [in] writer     The used XML writer.\r\n         *    @param [in] field      The field to be written.\r\n         */\r\n        void writeFieldDefinitionRef(QXmlStreamWriter& writer, QSharedPointer<Field> field);\r\n\r\n        /*!\r\n         *  Write the reset.\r\n         *\r\n         *    @param [in] writer  Used XML writer.\r\n         *    @param [in] field   The selected field item.\r\n         */\r\n        void writeResets(QXmlStreamWriter& writer, QSharedPointer<Field> field);\r\n\r\n        /*!\r\n         *  Write the type identifier.\r\n         *\r\n         *    @param [in] writer  Used XML writer.\r\n         *    @param [in] field   The selected field item.\r\n         */\r\n        void writeTypeIdentifier(QXmlStreamWriter& writer, QSharedPointer<Field> field);\r\n\r\n        /*!\r\n         *  Write the volatile value.\r\n         *\r\n         *    @param [in] writer  Used XML writer.\r\n         *    @param [in] field   The selected field item.\r\n         */\r\n        void writeVolatile(QXmlStreamWriter& writer, QSharedPointer<Field> field);\r\n\r\n        /*!\r\n         *  Write the access value.\r\n         *\r\n         *    @param [in] writer  Used XML writer.\r\n         *    @param [in] field   The selected field item.\r\n         */\r\n        void writeAccess(QXmlStreamWriter& writer, QSharedPointer<Field> field);\r\n\r\n        /*!\r\n         *  Write the enumerated values.\r\n         *\r\n         *    @param [in] writer  Used XML writer.\r\n         *    @param [in] field   The selected field item.\r\n         */\r\n        void writeEnumerations(QXmlStreamWriter& writer, QSharedPointer<Field> field);\r\n\r\n        /*!\r\n         *  Write the modified write value.\r\n         *\r\n         *    @param [in] writer  Used XML writer.\r\n         *    @param [in] field   The selected field item.\r\n         */\r\n        void writeModifiedWriteValue(QXmlStreamWriter& writer, QSharedPointer<Field> field);\r\n\r\n        /*!\r\n         *  Write the write value constraint.\r\n         *\r\n         *    @param [in] writer          Used XML writer.\r\n         *    @param [in] writeConstaint  The field write value constraint.\r\n         */\r\n        void writeWriteValueConstraint(QXmlStreamWriter& writer, QSharedPointer<WriteValueConstraint> writeConstraint)\r\n           ;\r\n\r\n        /*!\r\n         *  Write the read action.\r\n         *\r\n         *    @param [in] writer  Used XML writer.\r\n         *    @param [in] field   The selected field item.\r\n         */\r\n        void writeReadAction(QXmlStreamWriter& writer, QSharedPointer<Field> field);\r\n\r\n        /*!\r\n         *  Write the testable element.\r\n         *\r\n         *    @param [in] writer  Used XML writer.\r\n         *    @param [in] field   The selected field item.\r\n         */\r\n        void writeTestable(QXmlStreamWriter& writer, QSharedPointer<Field> field);\r\n\r\n        /*!\r\n         *  Write the reserved value.\r\n         *\r\n         *    @param [in] writer  Used XML writer.\r\n         *    @param [in] field   The selected field item.\r\n         */\r\n        void writeReserved(QXmlStreamWriter& writer, QSharedPointer<Field> field);\r\n\r\n        /*!\r\n         *\tWrite field data using 2014 standard revision.\r\n         *  \r\n         *    @param [in] writer  Used XML writer.\r\n         *    @param [in] field   The selected field item.\r\n         */\r\n        void writeFieldData2014(QXmlStreamWriter& writer, QSharedPointer<Field> field);\r\n\r\n        /*!\r\n         *\tWrite field data using 2022 standard revision.\r\n         *  \r\n         *    @param [in] writer  Used XML writer.\r\n         *    @param [in] field   The selected field item.\r\n         */\r\n        void writeFieldData2022(QXmlStreamWriter& writer, QSharedPointer<Field> field);\r\n\r\n        /*!\r\n         *\tWrite the field reference, i.e. ipxact:aliasOf.\r\n         *  \r\n         *    @param [in] writer  Used XML writer.\r\n         *    @param [in] field   The selected field item.\r\n         */\r\n        void writeFieldReference(QXmlStreamWriter& writer, QSharedPointer<Field> field);\r\n    }\r\n};\r\n\r\n#endif // FIELDWRITER_H\r\n"
  },
  {
    "path": "IPXACTmodels/Component/File.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: File.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 16.09.2015\r\n//\r\n// Description:\r\n// Describes the ipxact:file element.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"File.h\"\r\n\r\n#include <IPXACTmodels/common/FileType.h>\r\n\r\n#include <IPXACTmodels/kactusExtensions/Kactus2Value.h>\r\n\r\n#include <QFileInfo>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: File::File()\r\n//-----------------------------------------------------------------------------\r\nFile::File(QString const& filePath, QString const& fileType) :\r\nExtendable(),\r\nname_(filePath)\r\n{\r\n\tparseFileName();\r\n\r\n    if (!fileType.isEmpty())\r\n    {\r\n        fileTypes_->append(FileType(fileType));\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: File::File()\r\n//-----------------------------------------------------------------------------\r\nFile::File(const File& other) :\r\nExtendable(other),\r\nfileId_(other.fileId_),\r\nattributes_(other.attributes_),\r\nname_(other.name_),\r\nfileName_(other.fileName_),\r\nisPresent_(other.isPresent_),\r\nstructural_(other.structural_),\r\nincludeFile_(other.includeFile_),\r\nexternalDeclarations_(other.externalDeclarations_),\r\nlogicalName_(other.logicalName_),\r\nlogicalNameDefault_(other.logicalNameDefault_),\r\ndescription_(other.description_)\r\n{\r\n    copyBuildCommand(other);\r\n    copyDefines(other);\r\n    copyStringLists(other);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: File::operator=()\r\n//-----------------------------------------------------------------------------\r\nFile& File::operator=(const File &other)\r\n{\r\n    if (this != & other)\r\n    {\r\n        Extendable::operator=(other);\r\n        fileId_ = other.fileId_;\r\n        attributes_ = other.attributes_;\r\n        name_ = other.name_;\r\n        isPresent_ = other.isPresent_;\r\n        structural_ = other.structural_;\r\n        includeFile_ = other.includeFile_;\r\n        externalDeclarations_ = other.externalDeclarations_;\r\n        logicalName_ = other.logicalName_;\r\n        logicalNameDefault_ = other.logicalNameDefault_;\r\n        description_ = other.description_;\r\n        \r\n        buildCommand_.clear();\r\n        copyBuildCommand(other);\r\n        defines_->clear();\r\n        copyDefines(other);\r\n        fileTypes_->clear();\r\n        exportedNames_->clear();\r\n        dependencies_->clear();\r\n        imageTypes_->clear();\r\n        copyStringLists(other);\r\n    }\r\n    return *this;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: File::~File()\r\n//-----------------------------------------------------------------------------\r\nFile::~File()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: File::operator==()\r\n//-----------------------------------------------------------------------------\r\nbool File::operator==( const File& other ) const\r\n{\r\n    return name_ == other.name_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: File::operator!=()\r\n//-----------------------------------------------------------------------------\r\nbool File::operator!=( const File& other ) const\r\n{\r\n    return !operator==(other);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: File::getFileId()\r\n//-----------------------------------------------------------------------------\r\nQString File::getFileId() const\r\n{\r\n    return fileId_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: File::setFileId()\r\n//-----------------------------------------------------------------------------\r\nvoid File::setFileId(QString const& fileId)\r\n{\r\n    fileId_ = fileId;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: File::getAttributes()\r\n//-----------------------------------------------------------------------------\r\nQMap<QString, QString> File::getAttributes() const\r\n{\r\n    return attributes_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: File::setAttributes()\r\n//-----------------------------------------------------------------------------\r\nvoid File::setAttributes(QMap<QString, QString> const& newAttributes)\r\n{\r\n\tattributes_.clear();\r\n\tattributes_ = newAttributes;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: File::name()\r\n//-----------------------------------------------------------------------------\r\nQString File::name() const\r\n{\r\n    return name_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: File::setName()\r\n//-----------------------------------------------------------------------------\r\nvoid File::setName(QString const& newName)\r\n{\r\n    name_ = newName;\r\n\tparseFileName();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: File::getIsPresent()\r\n//-----------------------------------------------------------------------------\r\nQString File::getIsPresent() const\r\n{\r\n    return isPresent_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: File::setIsPresent()\r\n//-----------------------------------------------------------------------------\r\nvoid File::setIsPresent(QString const& newIsPresent)\r\n{\r\n    isPresent_ = newIsPresent;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: File::getFileTypes()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<QList<FileType> > File::getFileTypes() const\r\n{\r\n    return fileTypes_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: File::getFileTypeNames()\r\n//-----------------------------------------------------------------------------\r\nQStringList File::getFileTypeNames() const\r\n{\r\n    QStringList types;\r\n    std::for_each(fileTypes_->cbegin(), fileTypes_->cend(), [&types](auto const& fileType) {\r\n        types.append(fileType.type_);\r\n        });\r\n\r\n    return types;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: File::setFileTypes()\r\n//-----------------------------------------------------------------------------\r\nvoid File::setFileTypes( QSharedPointer<QList<FileType> > fileTypes )\r\n{\r\n    fileTypes_ = fileTypes;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: File::isStructural()\r\n//-----------------------------------------------------------------------------\r\nbool File::isStructural() const\r\n{\r\n    return structural_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: File::setStructural()\r\n//-----------------------------------------------------------------------------\r\nvoid File::setStructural(bool structuralStatus)\r\n{\r\n    structural_ = structuralStatus;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: File::getIncludeFile()\r\n//-----------------------------------------------------------------------------\r\nbool File::isIncludeFile() const\r\n{\r\n    return includeFile_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: File::setIncludeFile()\r\n//-----------------------------------------------------------------------------\r\nvoid File::setIncludeFile(bool includeFile)\r\n{\r\n    includeFile_ = includeFile;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: File::getExternalDeclarations()\r\n//-----------------------------------------------------------------------------\r\nbool File::hasExternalDeclarations() const\r\n{\r\n    return externalDeclarations_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: File::setExternalDeclarations()\r\n//-----------------------------------------------------------------------------\r\nvoid File::setExternalDeclarations(bool externalDeclarations)\r\n{\r\n    externalDeclarations_ = externalDeclarations;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: File::getLogicalName()\r\n//-----------------------------------------------------------------------------\r\nQString File::getLogicalName() const\r\n{\r\n    return logicalName_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: File::setLogicalName()\r\n//-----------------------------------------------------------------------------\r\nvoid File::setLogicalName(QString const& logicalName)\r\n{\r\n    logicalName_ = logicalName;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: File::getLogicalNameDefault()\r\n//-----------------------------------------------------------------------------\r\nbool File::isLogicalNameDefault() const\r\n{\r\n    return logicalNameDefault_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: File::setLogicalNameDefault()\r\n//-----------------------------------------------------------------------------\r\nvoid File::setLogicalNameDefault(bool logicalNameDefault)\r\n{\r\n    logicalNameDefault_ = logicalNameDefault;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: File::getExportedNames()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<QStringList> File::getExportedNames() const\r\n{\r\n    return exportedNames_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: File::setExportedNames()\r\n//-----------------------------------------------------------------------------\r\nvoid File::setExportedNames(QSharedPointer<QStringList> exportedNames)\r\n{\r\n\texportedNames_->clear();\r\n\texportedNames_ = exportedNames;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: File::getBuildcommand()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<BuildCommand> File::getBuildCommand() const\r\n{\r\n    if (buildCommand_)\r\n    {\r\n        return buildCommand_;\r\n    }\r\n    else\r\n    {\r\n        return nullptr;\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: File::setBuildcommand()\r\n//-----------------------------------------------------------------------------\r\nvoid File::setBuildcommand( QSharedPointer<BuildCommand> newBuildCommand)\r\n{\r\n    buildCommand_ = newBuildCommand;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: File::getDependencies()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<QStringList> File::getDependencies()\r\n{\r\n    return dependencies_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: File::setDependencies()\r\n//-----------------------------------------------------------------------------\r\nvoid File::setDependencies(QSharedPointer<QStringList> newDependecies)\r\n{\r\n    dependencies_->clear();\r\n    dependencies_ = newDependecies;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: File::getDefines()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<QList<QSharedPointer<NameValuePair> > > File::getDefines()\r\n{\r\n    return defines_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: File::setDefines()\r\n//-----------------------------------------------------------------------------\r\nvoid File::setDefines(QSharedPointer<QList<QSharedPointer<NameValuePair> > > newDefines)\r\n{\r\n    defines_ = newDefines;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: File::getImageTypes()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<QStringList> File::getImageTypes()\r\n{\r\n    return imageTypes_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: File::setImageTypes()\r\n//-----------------------------------------------------------------------------\r\nvoid File::setImageTypes(QSharedPointer<QStringList> newImageTypes)\r\n{\r\n\timageTypes_->clear();\r\n\timageTypes_ = newImageTypes;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: File::getDescription()\r\n//-----------------------------------------------------------------------------\r\nQString File::getDescription() const\r\n{\r\n    return description_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: File::setDescription()\r\n//-----------------------------------------------------------------------------\r\nvoid File::setDescription(QString const& description)\r\n{\r\n    description_ = description;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: File::matchesFileType()\r\n//-----------------------------------------------------------------------------\r\nbool File::matchesFileType(const QStringList& fileTypes) const\r\n{\r\n    return std::any_of(fileTypes_->cbegin(), fileTypes_->cend(),\r\n        [&fileTypes](auto const& fileType) { return fileTypes.contains(fileType.type_); });\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: File::matchesFileType()\r\n//-----------------------------------------------------------------------------\r\nbool File::matchesFileType( const QString& fileType ) const\r\n{\r\n    return std::any_of(fileTypes_->cbegin(), fileTypes_->cend(),\r\n        [&fileType](auto const& type) { return type.type_.compare(fileType) == 0; });\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: File::setFileTypes()\r\n//-----------------------------------------------------------------------------\r\nvoid File::setFileTypes( QSettings& settings )\r\n{\r\n    QFileInfo info(name_);\r\n    QStringList types = FileTypes::getFileTypes(settings, info.suffix());\r\n\r\n    fileTypes_->clear();\r\n    for (auto const& fileType : types)\r\n    {\r\n        fileTypes_->append(FileType(fileType));\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: File::addFileType()\r\n//-----------------------------------------------------------------------------\r\nvoid File::addFileType( QString const& fileType, QString const& libext)\r\n{\r\n    if (matchesFileType(fileType) == false)\r\n    {\r\n        fileTypes_->append(FileType(fileType, libext));\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: File::clearFileTypes()\r\n//-----------------------------------------------------------------------------\r\nvoid File::clearFileTypes()\r\n{\r\n    fileTypes_->clear();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: File::clearDefines()\r\n//-----------------------------------------------------------------------------\r\nvoid File::clearDefines()\r\n{\r\n    defines_->clear();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: File::getCommand()\r\n//-----------------------------------------------------------------------------\r\nQString File::getCommand() const\r\n{\r\n    if (buildCommand_)\r\n    {\r\n        return buildCommand_->getCommand();\r\n    }\r\n    else\r\n    {\r\n        return QString();\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: File::getFlags()\r\n//-----------------------------------------------------------------------------\r\nQString File::getFlags() const\r\n{\r\n    QString flags;\r\n\r\n    if (buildCommand_)\r\n    {\r\n        if (!buildCommand_->getReplaceDefaultFlags().isEmpty())\r\n        {\r\n            return buildCommand_->getFlags();\r\n        }\r\n        else\r\n        {\r\n            flags += buildCommand_->getFlags();\r\n        }\r\n        flags.append(QLatin1Char(' '));\r\n    }\r\n\r\n    return flags;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: File::isRTLFile()\r\n//-----------------------------------------------------------------------------\r\nbool File::isRTLFile() const\r\n{\r\n    return isVhdlFile() || isVerilogFile();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: File::isVhdlFile()\r\n//-----------------------------------------------------------------------------\r\nbool File::isVhdlFile() const\r\n{\r\n    for (auto const& fileType : *fileTypes_)\r\n    {\r\n        if (fileType.type_.compare(QLatin1String(\"vhdlSource\"), Qt::CaseInsensitive) == 0 ||\r\n            fileType.type_.compare(QLatin1String(\"vhdlSource-87\"), Qt::CaseInsensitive) == 0 ||\r\n            fileType.type_.compare(QLatin1String(\"vhdlSource-93\"), Qt::CaseInsensitive) == 0)\r\n        {\r\n            return true;\r\n        }\r\n    }\r\n    return false;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: File::isVerilogFile()\r\n//-----------------------------------------------------------------------------\r\nbool File::isVerilogFile() const\r\n{\r\n    for (auto const& fileType : *fileTypes_)\r\n    {\r\n        if (fileType.type_.compare(QLatin1String(\"verilogSource\"), Qt::CaseInsensitive) == 0 ||\r\n            fileType.type_.compare(QLatin1String(\"verilogSource-95\"), Qt::CaseInsensitive) == 0 ||\r\n            fileType.type_.compare(QLatin1String(\"verilogSource-2001\"), Qt::CaseInsensitive) == 0 )\r\n        {\r\n            return true;\r\n        }\r\n    }\r\n\r\n    return false;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: File::setCommand()\r\n//-----------------------------------------------------------------------------\r\nvoid File::setCommand( const QString& buildCommand )\r\n{\r\n    if (!buildCommand_)\r\n    {\r\n        buildCommand_ = QSharedPointer<BuildCommand>(new BuildCommand());\r\n    }\r\n\r\n    buildCommand_->setCommand(buildCommand);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: File::setBuildFlags()\r\n//-----------------------------------------------------------------------------\r\nvoid File::setBuildFlags(QString const& buildFlags, QString const& replaceDefaultFlags)\r\n{\r\n    if (!buildCommand_)\r\n    {\r\n        buildCommand_ = QSharedPointer<BuildCommand>(new BuildCommand());\r\n    }\r\n    buildCommand_->setFlags(buildFlags);\r\n    buildCommand_->setReplaceDefaultFlags(replaceDefaultFlags);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: File::getFileName()\r\n//-----------------------------------------------------------------------------\r\nQString File::getFileName() const\r\n{\r\n\treturn fileName_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: File::parseFileName()\r\n//-----------------------------------------------------------------------------\r\nvoid File::parseFileName()\r\n{\r\n\tQFileInfo fileInfo(name_);\r\n\tfileName_ = fileInfo.fileName();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: File::copyBuildCommand()\r\n//-----------------------------------------------------------------------------\r\nvoid File::copyBuildCommand(const File& other)\r\n{\r\n    if (other.buildCommand_)\r\n    {\r\n        buildCommand_ = QSharedPointer<BuildCommand> (new BuildCommand(*other.buildCommand_));\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: File::copyDefines()\r\n//-----------------------------------------------------------------------------\r\nvoid File::copyDefines(const File& other)\r\n{\r\n    for (QSharedPointer<NameValuePair> definition : *other.defines_)\r\n    {\r\n        if (definition)\r\n        {\r\n            QSharedPointer<NameValuePair> copy =\r\n                QSharedPointer<NameValuePair>(new NameValuePair(*definition));\r\n            defines_->append(copy);\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: File::copyStringLists()\r\n//-----------------------------------------------------------------------------\r\nvoid File::copyStringLists(const File& other)\r\n{\r\n    for (auto const& fileType : *other.fileTypes_)\r\n    {\r\n        fileTypes_->append(fileType);\r\n    }\r\n\r\n    exportedNames_->append(*other.exportedNames_);\r\n\r\n    dependencies_->append(*other.dependencies_);\r\n\r\n    imageTypes_->append(*other.imageTypes_);\r\n\r\n}"
  },
  {
    "path": "IPXACTmodels/Component/File.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: File.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 16.09.2015\r\n//\r\n// Description:\r\n// Describes the ipxact:file element.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef FILE_H\r\n#define FILE_H\r\n\r\n#include <IPXACTmodels/common/BuildModel.h>\r\n#include <IPXACTmodels/Component/BuildCommand.h>\r\n#include <IPXACTmodels/common/FileType.h>\r\n\r\n#include <IPXACTmodels/common/NameValuePair.h>\r\n#include <IPXACTmodels/common/Extendable.h>\r\n\r\n#include <IPXACTmodels/ipxactmodels_global.h>\r\n\r\n#include <QString>\r\n#include <QSharedPointer>\r\n#include <QStringList>\r\n#include <QSettings>\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Describes the ipxact:file element.\r\n//-----------------------------------------------------------------------------\r\nclass IPXACTMODELS_EXPORT File : public Extendable\r\n{\r\n\r\npublic:\r\n\r\n    /*!\r\n     *  The constructor.\r\n     *\r\n     *    @param [in] filePath    Path to or name of the file.\r\n     *    @param [in] fileType    The file type.\r\n     */\r\n    File (QString const& filePath = QString(), QString const& fileType = QString());\r\n\r\n\t//! Copy constructor.\r\n    File(const File& other);\r\n\r\n\t//! Assignment operator.\r\n\tFile& operator=(const File &other);\r\n\r\n\t//! The destructor.\r\n\t~File();\r\n\r\n    //! Comparison operator\r\n\tbool operator==(const File& other) const;\r\n\r\n    //! Opposed comparison operator.\r\n\tbool operator!=(const File& other) const;\r\n\r\n\t/*!\r\n\t *  Get the id of the file.\r\n\t *\r\n     *    @return The ID of the file.\r\n\t */\r\n\tQString getFileId() const;\r\n    \r\n\t/*!\r\n     *  Set the id.\r\n\t *\r\n\t *    @param [in]     newFileId The new id.\r\n\t */\r\n\tvoid setFileId(QString const& newFileId);\r\n\r\n\t/*! \r\n     *  Get the attributes for the file-element\r\n\t *\r\n\t *    @return QMap containing the attributes.\r\n\t */\r\n\tQMap<QString, QString> getAttributes() const;\r\n\r\n    /*! \r\n     *  Set the attributes for the file\r\n\t *\r\n\t *    @param [in]     newAttributes Qmap containing the new attributes.\r\n\t */\r\n\tvoid setAttributes(QMap<QString, QString> const& newAttributes);\r\n\r\n\t/*! \r\n     *  Get the name of the file\r\n\t *\r\n\t *    @return QString containing the name.\r\n\t */\r\n\tQString name() const;\r\n\r\n\t/*! \r\n     *  Set the name for this file.\r\n\t *\r\n\t *    @param [in] name    QString containing the name.\r\n\t */\r\n\tvoid setName(QString const& newName);\r\n\r\n    /*!\r\n     *  Get the presence of this file.\r\n     *\r\n     *    @return The presence of this file.\r\n     */\r\n    QString getIsPresent() const;\r\n\r\n    /*!\r\n     *  Set the presence for this file.\r\n     *\r\n     *    @param [in] newIsPresent    The new presence.\r\n     */\r\n    void setIsPresent(QString const& newIsPresent);\r\n\r\n\t/*! \r\n    *   Get the file types\r\n\t*\r\n\t*    @return Pointer to a QList containing the file types.\r\n\t*/\r\n    QSharedPointer<QList<FileType> > getFileTypes() const;\r\n\r\n\t/*!\r\n\t*   Get the file types as a list\r\n\t*\r\n\t*    @return The file types.\r\n\t*/\r\n\tQStringList getFileTypeNames() const;\r\n\r\n\t/*! \r\n    *   Set the file types for this file\r\n\t*\r\n\t*    @param [in] fileTypes   QList containing the new file types.\r\n\t*/\r\n\tvoid setFileTypes(QSharedPointer<QList<FileType> > newFileTypes);\r\n\r\n    /*!\r\n     *  Check if the file contains structural RTL.\r\n     *\r\n     *    @return True if the file contains structural RTL, false otherwise.\r\n     */\r\n    bool isStructural() const;\r\n\r\n    /*!\r\n     *  Set the file to contain structural RTL.\r\n     *\r\n     *    @param [in] structuralStatus    The new structural status.\r\n     */\r\n    void setStructural(bool structuralStatus);\r\n\r\n\t/*!\r\n     *  Get the isIncludeFile setting.\r\n\t *\r\n\t *    @return True if the file is an include file, otherwise false.\r\n\t */\r\n\tbool isIncludeFile() const;\r\n\r\n\t/*! \r\n     *  Set the isIncludeFile setting for this file.\r\n\t *\r\n\t *    @param [in] includeFile     boolean value to be set.\r\n\t */\r\n\tvoid setIncludeFile(bool includeFile);\r\n\r\n\t/*! \r\n     *  Get attribute value of external declarations.\r\n\t *\r\n\t *    @return True of the file has external declarations, otherwise false.\r\n\t */\r\n\tbool hasExternalDeclarations() const;\r\n\r\n\t/*! \r\n     *  Set the externalDeclarations setting\r\n\t *\r\n\t *    @param [in] externalDeclarations    Boolean value to be set.\r\n\t */\r\n\tvoid setExternalDeclarations(bool externalDeclarations);\r\n\r\n\t/*! \r\n     *  Get the logicalName of the file\r\n\t *\r\n\t *    @return QString containing the name.\r\n\t */\r\n\tQString getLogicalName() const;\r\n\r\n\t/*! \r\n     *  Set the logical name for this file.\r\n\t *\r\n\t *    @param [in] logicalName     QString containing the new logical name.\r\n\t */\r\n\tvoid setLogicalName(QString const& logicalName);\r\n\r\n\t/*! \r\n     *  Get the default-attribute value of the logicalName element.\r\n\t *\r\n\t *    @return True of the logical name is default, otherwise false.\r\n\t */\r\n\tbool isLogicalNameDefault() const;\r\n\r\n\t/*! \r\n     *  Set the logical name attribute default.\r\n\t *\r\n\t *    @param [in] logicalNameDefault  Boolean value of the attribute.\r\n\t */\r\n\tvoid setLogicalNameDefault(bool logicalNameDefault);\r\n\r\n\t/*! \r\n     *  Get the exportedName for this file\r\n\t *\r\n\t *    @return QList containing the names that can be referenced externally.\r\n\t */\r\n    QSharedPointer<QStringList> getExportedNames() const;\r\n\r\n\t/*! \r\n     *  Set the exported names for this file\r\n\t *\r\n\t *    @param [in] exportedNames   QList containing the exported names.\r\n\t */\r\n\tvoid setExportedNames(QSharedPointer<QStringList> exportedNames);\r\n\r\n\t/*! \r\n     *  Get the build command for this file\r\n\t *\r\n\t *    @return A pointer to the BuildCommand containing the flags and commands.\r\n\t */\r\n    QSharedPointer<BuildCommand> getBuildCommand() const;\r\n\r\n\t/*! \r\n     *  Set the buildCommand for this file\r\n\t *\r\n\t *    @param [in] buildcommand    A pointer to the new build command.\r\n\t */\r\n    void setBuildcommand(QSharedPointer<BuildCommand> newBuildCommand);\r\n\r\n\t/*! \r\n     *  Get the dependencies for this file\r\n\t *\r\n\t *    @return QList containing the paths to the directories containing files on which this file depends on.\r\n\t */\r\n    QSharedPointer<QStringList> getDependencies();\r\n\r\n\t/*! \r\n     *  Set the dependencies for this file.\r\n\t *\r\n\t *    @param [in] dependencies    The paths to directories containing files on which this file depends on.\r\n\t */\r\n    void setDependencies(QSharedPointer<QStringList> newDependencies);\r\n\r\n\t/*! \r\n     *  Get the defines of the file\r\n\t *\r\n\t *    @return Name value pairs of the file defines.\r\n\t */\r\n    QSharedPointer<QList<QSharedPointer<NameValuePair> > > getDefines();\r\n\r\n\t/*! \r\n     *  Set the defines for this file.\r\n\t *\r\n\t *    @param [in] defines     The new name-value pairs.\r\n\t */\r\n    void setDefines(QSharedPointer<QList<QSharedPointer<NameValuePair> > > newDefines);\r\n\r\n\t/*! \r\n     *  Get the imageTypes of this file\r\n\t *\r\n\t *    @return QList containing the imageTypes.\r\n\t */\r\n    QSharedPointer<QStringList> getImageTypes();\r\n\r\n\t/*! \r\n     *  Set the image types for this file\r\n\t *\r\n\t *    @param [in] imageTypes  QList containing the new image types.\r\n\t */\r\n    void setImageTypes(QSharedPointer<QStringList> newImageTypes);\r\n\r\n\t/*! \r\n     *  Get the description of this file.\r\n\t *\r\n\t *    @return QString containing the description.\r\n\t */\r\n\tQString getDescription() const;\r\n\r\n\t/*! \r\n     *  Set the description for this file.\r\n\t *\r\n\t *    @param [in] description     QString containing the description.\r\n\t */\r\n\tvoid setDescription(QString const& description);\r\n\r\n\t/*! \r\n     *  Check if the file matches at least one of the specified file types.\r\n\t *\r\n\t *    @param [in] fileTypes   The file types to check.\r\n\t *\r\n\t *    @return True if at least on of the file types matches the file types of this file.\r\n     */\r\n\tbool matchesFileType(const QStringList& fileTypes) const;\r\n\r\n\t/*! \r\n     *  Check if the file matches the specified file type.\r\n\t *\r\n\t *    @param [in] fileType    The file type to check.\r\n\t *\r\n\t *    @return True if the file type is found either in file types or user file types.\r\n\t */\r\n\tbool matchesFileType(const QString& fileType) const;\r\n\r\n\t/*! Set the file types for the file to match the defined settings.\r\n\t *\r\n\t *    @param [in] settings    Contains the file type settings.\r\n\t *\r\n\t */\r\n\tvoid setFileTypes(QSettings& settings);\r\n\r\n\t/*! \r\n     *  Add a new file type definition.\r\n\t *\r\n\t *    @param [in] fileType    The name of the file type.\r\n\t */\r\n\tvoid addFileType(QString const& fileType, QString const& libext = QString());\r\n\r\n\t/*!\r\n     *  Clear all the fileTypes and userFileTypes\r\n\t *\r\n\t */\r\n\tvoid clearFileTypes();\r\n\r\n\t/*! \r\n     *  Clear all the defines from the file\r\n\t */\r\n\tvoid clearDefines();\r\n\r\n\t/*! \r\n     *  Get the build command's command-part\r\n\t *\r\n\t *    @return QString containing the command.\r\n\t */\r\n\tQString getCommand() const;\r\n\r\n\t/*! \r\n     *  Get the build flags for this file.\r\n\t *\r\n\t *    @return QString containing the flags for this file.\r\n\t */\r\n\tQString getFlags() const;\r\n\r\n\t/*! \r\n     *  Check if the file is a RTL file or not.\r\n\t *\r\n\t *    @return bool True if file is vhdl or verilog file.\r\n\t */\r\n\tbool isRTLFile() const;\r\n    \r\n\t/*! \r\n     *  Check if this file is a vhdl file.\r\n\t *\r\n\t *    @return bool True if the file is vhdl-file.\r\n\t */\r\n\tbool isVhdlFile() const;\r\n\r\n    /*!\r\n     *  Check if the file is a verilog file.\r\n     *\r\n     *    @return True if the file is a verilog file.\r\n     */\r\n    bool isVerilogFile() const;\r\n\r\n\t/*!\r\n     *  Set a build command for the file\r\n\t *\r\n\t *    @param [in] buildCommand    QString containing the command.\r\n\t */\r\n\tvoid setCommand(const QString& buildCommand);\r\n\r\n\t/*! \r\n     *  Set the flags for the build command\r\n\t *\r\n\t *    @param [in] buildFlags      QString containing the flags\r\n\t *    @param [in] replaceDefault  Should the default flags be replaced or appended.\r\n\t *\r\n\t */\r\n    void setBuildFlags(QString const& buildFlags, QString const& replaceDefaultFlags);\r\n\t\r\n\t/*! \r\n     *  Get the file name, including the extension, if it exists. Excludes the path.\r\n\t */\r\n\tQString getFileName() const;\r\n\r\nprivate:\r\n\t\r\n    /*!\r\n     *  Parses the current fileName_ from path in name_.\r\n     */\r\n\tvoid parseFileName();\r\n\r\n    /*!\r\n     *  Copy the build command from another file.\r\n     */\r\n    void copyBuildCommand(const File& other);\r\n\r\n    /*!\r\n     *  Copy the defines from another file.\r\n     */\r\n    void copyDefines(const File& other);\r\n\r\n    /*!\r\n     *  Copy the file types, exported names, dependencies and image types from another file.\r\n     */\r\n    void copyStringLists(const File& other);\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n\t//! Contains the id.\r\n\tQString fileId_;\r\n\r\n\t//! Contains any additional attributes for the File-element.\r\n\tQMap<QString, QString> attributes_;\r\n    \r\n\t//! Contains a path to a filename of a directory.\r\n\tQString name_;\r\n\r\n\t//! Contains the name of the file, including the extension, if it exists.\r\n\tQString fileName_;\r\n\r\n    //! Contains the presence of the file.\r\n    QString isPresent_;\r\n\r\n\t//! Contains the file types of the file.\r\n\tQSharedPointer<QList<FileType> > fileTypes_ = \r\n\t\tQSharedPointer<QList<FileType> >(new QList<FileType>);\r\n\r\n    //! Holds whether the file contains a structural RTL or not.\r\n    bool structural_ = false;\r\n\r\n\t//! Declares if the file is an include file or not.\r\n\tbool includeFile_ = false;\r\n\r\n\t//! Indicates if the include file is needed by users.\r\n\tbool externalDeclarations_ = false;\r\n\r\n\t//! The logical name for the file or directory.\r\n\tQString logicalName_;\r\n\r\n\t//! Can another process override this name or not.\r\n\tbool logicalNameDefault_ = false;\r\n\r\n\t//! Defines any names that can be referenced externally.\r\n    QSharedPointer<QStringList> exportedNames_ = QSharedPointer<QStringList>(new QStringList());\r\n\r\n\t//! Contains the buildCommand element.\r\n\tQSharedPointer<BuildCommand> buildCommand_ = nullptr;\r\n\r\n\t//! Contains paths to the directories containing dependency files.\r\n    QSharedPointer<QStringList> dependencies_ = QSharedPointer<QStringList>(new QStringList);\r\n\r\n\t//! Specifies the define symbols to use in the source file.\r\n    QSharedPointer<QList<QSharedPointer<NameValuePair> > > defines_ =\r\n\t\tQSharedPointer<QList<QSharedPointer<NameValuePair> > >(new QList<QSharedPointer<NameValuePair> >());\r\n\r\n\t//! Relates the file to a executable image type in the design.\r\n    QSharedPointer<QStringList> imageTypes_ = QSharedPointer<QStringList>(new QStringList());\r\n\r\n\t//! Details the file for the user.\r\n\tQString description_;\r\n\r\n};\r\n\r\n#endif // FILE_H\r\n"
  },
  {
    "path": "IPXACTmodels/Component/FileReader.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: FileReader.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 18.09.2015\r\n//\r\n// Description:\r\n// Reader class for IP-XACT file element.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"FileReader.h\"\r\n\r\n#include <IPXACTmodels/common/CommonItemsReader.h>\r\n#include <IPXACTmodels/common/NameGroupReader.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileReader::createFileFrom()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<File> FileReader::createFileFrom(QDomNode const& fileNode, Document::Revision docRevision)\r\n{\r\n    QDomElement fileElement = fileNode.toElement();\r\n    QString fileName = fileNode.firstChildElement(QStringLiteral(\"ipxact:name\")).firstChild().nodeValue();\r\n\r\n    QSharedPointer<File> newFile (new File(fileName));\r\n\r\n    Details::parseFileAttributes(fileElement, newFile);\r\n\r\n    if (docRevision == Document::Revision::Std14)\r\n    {\r\n        auto isPresent = CommonItemsReader::parseIsPresent(fileNode.firstChildElement(QStringLiteral(\"ipxact:isPresent\")));\r\n        newFile->setIsPresent(isPresent);\r\n    }\r\n\r\n    Details::parseFileTypes(fileElement, newFile, docRevision);\r\n\r\n    Details::parseIsStructural(fileElement, newFile);\r\n\r\n    Details::parseIsIncludeFile(fileElement, newFile);\r\n\r\n    Details::parseLogicalName(fileElement, newFile);\r\n\r\n    Details::parseExportedNames(fileElement, newFile);\r\n\r\n    Details::parseBuildCommand(fileElement, newFile);\r\n\r\n    Details::parseDependencies(fileElement, newFile);\r\n\r\n    Details::parseDefines(fileElement, newFile);\r\n\r\n    Details::parseImageTypes(fileElement, newFile);\r\n\r\n    Details::parseDescription(fileElement, newFile);\r\n\r\n    Details::parseFileExtensions(fileElement, newFile);\r\n\r\n    return newFile;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileReader::parseFileType()\r\n//-----------------------------------------------------------------------------\r\nFileType FileReader::parseFileType(QDomNode const& fileTypeNode, Document::Revision docRevision)\r\n{\r\n    QString fileType = fileTypeNode.firstChild().nodeValue();\r\n\r\n    QDomNamedNodeMap fileTypeAttributes = fileTypeNode.attributes();\r\n    if (fileType == QLatin1String(\"user\"))\r\n    {\r\n        fileType = fileTypeAttributes.namedItem(QStringLiteral(\"user\")).nodeValue();\r\n    }\r\n\r\n    FileType type(fileType);\r\n\r\n    if (docRevision == Document::Revision::Std22)\r\n    {\r\n        type.libext_ = fileTypeAttributes.namedItem(QStringLiteral(\"libext\")).nodeValue();\r\n    }\r\n\r\n    return type;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileReader::parseFileAttributes()\r\n//-----------------------------------------------------------------------------\r\nvoid FileReader::Details::parseFileAttributes(QDomElement const& fileElement, QSharedPointer<File> newFile)\r\n{\r\n    QDomNamedNodeMap fileAttributes = fileElement.attributes();\r\n\r\n    if (!fileAttributes.isEmpty())\r\n    {\r\n        QMap<QString, QString> otherAttributes;\r\n\r\n        for (int attributeIndex = 0; attributeIndex < fileAttributes.count(); ++attributeIndex)\r\n        {\r\n            QDomNode attributeNode = fileAttributes.item(attributeIndex);\r\n            QString attributeKey = attributeNode.nodeName();\r\n            QString attributeValue = attributeNode.firstChild().nodeValue();\r\n\r\n            if (attributeKey == QLatin1String(\"fileId\"))\r\n            {\r\n                QString fileId = attributeNode.firstChild().nodeValue();\r\n                newFile->setFileId(fileId);\r\n            }\r\n            else\r\n            {\r\n                otherAttributes.insert(attributeKey, attributeValue);\r\n            }\r\n        }\r\n\r\n        if (!otherAttributes.isEmpty())\r\n        {\r\n            newFile->setAttributes(otherAttributes);\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileReader::parseFileTypes()\r\n//-----------------------------------------------------------------------------\r\nvoid FileReader::Details::parseFileTypes(QDomElement const& fileElement, QSharedPointer<File> newFile, Document::Revision docRevision)\r\n{\r\n    QDomNodeList fileTypeNodeList = fileElement.elementsByTagName(QStringLiteral(\"ipxact:fileType\"));\r\n    \r\n    for (int fileTypeIndex = 0; fileTypeIndex < fileTypeNodeList.count(); ++fileTypeIndex)\r\n    {\r\n        QDomNode fileTypeNode = fileTypeNodeList.at(fileTypeIndex);\r\n\r\n        newFile->getFileTypes()->append(parseFileType(fileTypeNode, docRevision));\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileReader::parseIsStructural()\r\n//-----------------------------------------------------------------------------\r\nvoid FileReader::Details::parseIsStructural(QDomElement const& fileElement, QSharedPointer<File> newFile)\r\n{\r\n    QDomElement structuralElement = fileElement.firstChildElement(QStringLiteral(\"ipxact:isStructural\"));\r\n\r\n    if (!structuralElement.isNull())\r\n    {\r\n        newFile->setStructural(true);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileReader::parseIsIncludeFile()\r\n//-----------------------------------------------------------------------------\r\nvoid FileReader::Details::parseIsIncludeFile(QDomElement const& fileElement, QSharedPointer<File> newFile)\r\n{\r\n    QDomElement includeElement = fileElement.firstChildElement(QStringLiteral(\"ipxact:isIncludeFile\"));\r\n\r\n    if (!includeElement.isNull())\r\n    {\r\n        newFile->setIncludeFile(true);\r\n\r\n        if (!includeElement.attribute(QStringLiteral(\"externalDeclarations\")).isNull())\r\n        {\r\n            newFile->setExternalDeclarations(true);\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileReader::parseLogicalName()\r\n//-----------------------------------------------------------------------------\r\nvoid FileReader::Details::parseLogicalName(QDomElement const& fileElement, QSharedPointer<File> newFile)\r\n{\r\n    QDomElement logicalNameElement = fileElement.firstChildElement(QStringLiteral(\"ipxact:logicalName\"));\r\n\r\n    if (!logicalNameElement.isNull())\r\n    {\r\n        QString logicalName = logicalNameElement.firstChild().nodeValue();\r\n        newFile->setLogicalName(logicalName);\r\n\r\n        if (!logicalNameElement.attribute(QStringLiteral(\"default\")).isNull())\r\n        {\r\n            newFile->setLogicalNameDefault(true);\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileReader::parseExportedNames()\r\n//-----------------------------------------------------------------------------\r\nvoid FileReader::Details::parseExportedNames(QDomElement const& fileElement, QSharedPointer<File> newFile)\r\n{\r\n    QDomNodeList exportedNameNodeList = fileElement.elementsByTagName(QStringLiteral(\"ipxact:exportedName\"));\r\n\r\n    for (int exportedIndex = 0; exportedIndex < exportedNameNodeList.count(); ++exportedIndex)\r\n    {\r\n        QString exportedName = exportedNameNodeList.at(exportedIndex).firstChild().nodeValue();\r\n        newFile->getExportedNames()->append(exportedName);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileReader::parseBuildCommand()\r\n//-----------------------------------------------------------------------------\r\nvoid FileReader::Details::parseBuildCommand(QDomElement const& fileElement, QSharedPointer<File> newFile)\r\n{\r\n    QDomElement buildCommandElement = fileElement.firstChildElement(QStringLiteral(\"ipxact:buildCommand\"));\r\n\r\n    if (!buildCommandElement.isNull())\r\n    {\r\n        QSharedPointer<BuildCommand> newBuildCommand (new BuildCommand());\r\n\r\n        parseBuildCommandCommand(buildCommandElement, newBuildCommand);\r\n        \r\n        parseBuildCommandFlags(buildCommandElement, newBuildCommand);\r\n\r\n        parseBuildCommandReplaceFlags(buildCommandElement, newBuildCommand);\r\n\r\n        parseBuildCommandReplaceFlags(buildCommandElement, newBuildCommand);\r\n\r\n        parseBuildCommandTarget(buildCommandElement, newBuildCommand);\r\n\r\n        newFile->setBuildcommand(newBuildCommand);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileReader::parseBuildCommandCommand()\r\n//-----------------------------------------------------------------------------\r\nvoid FileReader::Details::parseBuildCommandCommand(QDomElement const& buildCommandElement,\r\n    QSharedPointer<BuildCommand> newBuildCommand)\r\n{\r\n    QDomElement commandElement = buildCommandElement.firstChildElement(QStringLiteral(\"ipxact:command\"));\r\n    if (!commandElement.isNull())\r\n    {\r\n        newBuildCommand->setCommand(commandElement.firstChild().nodeValue());\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileReader::parseBuildCommandFlags()\r\n//-----------------------------------------------------------------------------\r\nvoid FileReader::Details::parseBuildCommandFlags(QDomElement const& buildCommandElement,\r\n    QSharedPointer<BuildCommand> newBuildCommand)\r\n{\r\n    QDomElement flagsElement = buildCommandElement.firstChildElement(QStringLiteral(\"ipxact:flags\"));\r\n    if (!flagsElement.isNull())\r\n    {\r\n        newBuildCommand->setFlags(flagsElement.firstChild().nodeValue());\r\n        if (!flagsElement.attribute(QStringLiteral(\"append\")).isNull())\r\n        {\r\n            if (flagsElement.attribute(QStringLiteral(\"append\")) == QLatin1String(\"true\"))\r\n            {\r\n                newBuildCommand->setFlagsAppend(true);\r\n            }\r\n            else\r\n            {\r\n                newBuildCommand->setFlagsAppend(false);\r\n            }\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileReader::parseBuildCommandReplaceFlags()\r\n//-----------------------------------------------------------------------------\r\nvoid FileReader::Details::parseBuildCommandReplaceFlags(QDomElement const& buildCommandElement,\r\n    QSharedPointer<BuildCommand> newBuildCommand)\r\n{\r\n    QDomElement replaceFlagsElement = buildCommandElement.firstChildElement(QStringLiteral(\"ipxact:replaceDefaultFlags\"));\r\n    if (!replaceFlagsElement.isNull())\r\n    {\r\n        newBuildCommand->setReplaceDefaultFlags(replaceFlagsElement.firstChild().nodeValue());\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileReader::parseBuildCommandTargets()\r\n//-----------------------------------------------------------------------------\r\nvoid FileReader::Details::parseBuildCommandTarget(QDomElement const& buildCommandElement,\r\n    QSharedPointer<BuildCommand> newBuildCommand)\r\n{\r\n    QDomElement targetElement = buildCommandElement.firstChildElement(QStringLiteral(\"ipxact:targetName\"));\r\n    if (!targetElement.isNull())\r\n    {\r\n        newBuildCommand->setTargetName(targetElement.firstChild().nodeValue());\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileReader::parseDependencies()\r\n//-----------------------------------------------------------------------------\r\nvoid FileReader::Details::parseDependencies(QDomElement const& fileElement, QSharedPointer<File> newFile)\r\n{\r\n    QDomNodeList dependencyNodeList = fileElement.elementsByTagName(QStringLiteral(\"ipxact:dependency\"));\r\n\r\n    for (int dependencyIndex = 0; dependencyIndex < dependencyNodeList.count(); ++dependencyIndex)\r\n    {\r\n        QString dependency = dependencyNodeList.at(dependencyIndex).firstChild().nodeValue();\r\n        newFile->getDependencies()->append(dependency);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileReader::parseDefines()\r\n//-----------------------------------------------------------------------------\r\nvoid FileReader::Details::parseDefines(QDomElement const& fileElement, QSharedPointer<File> newFile)\r\n{\r\n    QDomNodeList defineNodeList = fileElement.elementsByTagName(QStringLiteral(\"ipxact:define\"));\r\n\r\n    if (!defineNodeList.isEmpty())\r\n    {\r\n        for (int defineIndex = 0; defineIndex < defineNodeList.count(); ++defineIndex)\r\n        {\r\n            QDomNode defineNode = defineNodeList.at(defineIndex);\r\n\r\n            QSharedPointer<NameValuePair> newDefine (new NameValuePair());\r\n\r\n            NameGroupReader::parseNameGroup(defineNode, newDefine);\r\n\r\n            QString value = defineNode.firstChildElement(QStringLiteral(\"ipxact:value\")).firstChild().nodeValue();\r\n            newDefine->setValue(value);\r\n\r\n            CommonItemsReader::parseVendorExtensions(defineNode, newDefine);\r\n\r\n            newFile->getDefines()->append(newDefine);\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileReader::parseImageTypes()\r\n//-----------------------------------------------------------------------------\r\nvoid FileReader::Details::parseImageTypes(QDomElement const& fileElement, QSharedPointer<File> newFile)\r\n{\r\n    QDomNodeList imagetTypeNodeList = fileElement.elementsByTagName(QStringLiteral(\"ipxact:imageType\"));\r\n\r\n    for (int imageTypeIndex = 0; imageTypeIndex < imagetTypeNodeList.count(); ++imageTypeIndex)\r\n    {\r\n        QString imageType = imagetTypeNodeList.at(imageTypeIndex).firstChild().nodeValue();\r\n        newFile->getImageTypes()->append(imageType);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileReader::parseDescription()\r\n//-----------------------------------------------------------------------------\r\nvoid FileReader::Details::parseDescription(QDomElement const& fileElement, QSharedPointer<File> newFile)\r\n{\r\n    QDomElement descriptionNameElement = fileElement.firstChildElement(QStringLiteral(\"ipxact:description\"));\r\n\r\n    if (!descriptionNameElement.isNull())\r\n    {\r\n        QString description = descriptionNameElement.firstChild().nodeValue();\r\n        newFile->setDescription(description);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileReader::parseFileExtensions()\r\n//-----------------------------------------------------------------------------\r\nvoid FileReader::Details::parseFileExtensions(QDomNode const& fileNode, QSharedPointer<File> newFile)\r\n{\r\n    CommonItemsReader::parseVendorExtensions(fileNode, newFile);\r\n}"
  },
  {
    "path": "IPXACTmodels/Component/FileReader.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: FileReader.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 18.09.2015\r\n//\r\n// Description:\r\n// Reader class for IP-XACT file element.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef FILEREADER_H\r\n#define FILEREADER_H\r\n\r\n#include \"File.h\"\r\n\r\n#include <IPXACTmodels/common/Document.h>\r\n\r\n#include <QSharedPointer>\r\n#include <QDomNode>\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Reader class for IP-XACT file element.\r\n//-----------------------------------------------------------------------------\r\nnamespace FileReader\r\n{\r\n    /*!\r\n     *  Creates a new file from a given file node.\r\n     *\r\n     *    @param [in] fileNode        XML description of the file.\r\n     *    @param [in] docRevision     The applied IP-XACT standard revision.\r\n     */\r\n    IPXACTMODELS_EXPORT QSharedPointer<File> createFileFrom(QDomNode const& fileNode, Document::Revision docRevision);\r\n\r\n    /*!\r\n     *  Creates a new file type from a given node.\r\n     *\r\n     *    @param [in] fileTypeNode    XML description of the file type.\r\n     *    @param [in] docRevision     The applied IP-XACT standard revision.\r\n     */\r\n    FileType parseFileType(QDomNode const& fileTypeNode, Document::Revision docRevision);\r\n\r\n\r\n    namespace Details\r\n    {\r\n        /*!\r\n         *  Parses the file attributes.\r\n         *\r\n         *    @param [in] fileElement     XML description of the file.\r\n         *    @param [in] newFile         The new file item.\r\n         */\r\n        void parseFileAttributes(QDomElement const& fileElement, QSharedPointer<File> newFile);\r\n\r\n        /*!\r\n         *  Parses the file types.\r\n         *\r\n         *    @param [in] fileElement     XML description of the file.\r\n         *    @param [in] newFile         The new file item.\r\n         *    @param [in] docRevision     The applied IP-XACT standard revision.\r\n         */\r\n        void parseFileTypes(QDomElement const& fileElement, QSharedPointer<File> newFile, Document::Revision docRevision);\r\n\r\n        /*!\r\n         *  Parses the structural status.\r\n         *\r\n         *    @param [in] fileElement     XML description of the file.\r\n         *    @param [in] newFile         The new file item.\r\n         */\r\n        void parseIsStructural(QDomElement const& fileElement, QSharedPointer<File> newFile);\r\n\r\n        /*!\r\n         *  Parses the include file status.\r\n         *\r\n         *    @param [in] fileElement     XML description of the file.\r\n         *    @param [in] newFile         The new file item.\r\n         */\r\n        void parseIsIncludeFile(QDomElement const& fileElement, QSharedPointer<File> newFile);\r\n\r\n        /*!\r\n         *  Parses the logical name.\r\n         *\r\n         *    @param [in] fileElement     XML description of the file.\r\n         *    @param [in] newFile         The new file item.\r\n         */\r\n        void parseLogicalName(QDomElement const& fileElement, QSharedPointer<File> newFile);\r\n\r\n        /*!\r\n         *  Parses the exported names.\r\n         *\r\n         *    @param [in] fileElement     XML description of the file.\r\n         *    @param [in] newFile         The new file item.\r\n         */\r\n        void parseExportedNames(QDomElement const& fileElement, QSharedPointer<File> newFile);\r\n\r\n        /*!\r\n         *  Parses the file build command.\r\n         *\r\n         *    @param [in] fileElement     XML description of the file.\r\n         *    @param [in] newFile         The new file item.\r\n         */\r\n        void parseBuildCommand(QDomElement const& fileElement, QSharedPointer<File> newFile);\r\n\r\n        /*!\r\n         *  Parses the command used in the build command.\r\n         *\r\n         *    @param [in] buildCommandElement     XML description of the build command.\r\n         *    @param [in] newBuildCommand         The new build command item.\r\n         */\r\n        void parseBuildCommandCommand(QDomElement const& buildCommandElement,\r\n            QSharedPointer<BuildCommand> newBuildCommand);\r\n\r\n        /*!\r\n         *  Parses the build command flags.\r\n         *\r\n         *    @param [in] buildCommandElement     XML description of the build command.\r\n         *    @param [in] newBuildCommand         The new build command item.\r\n         */\r\n        void parseBuildCommandFlags(QDomElement const& buildCommandElement,\r\n            QSharedPointer<BuildCommand> newBuildCommand);\r\n\r\n        /*!\r\n         *  Parses the expression for build command flag replacement.\r\n         *\r\n         *    @param [in] buildCommandElement     XML description of the build command.\r\n         *    @param [in] newBuildCommand         The new build command item.\r\n         */\r\n        void parseBuildCommandReplaceFlags(QDomElement const& buildCommandElement,\r\n            QSharedPointer<BuildCommand> newBuildCommand);\r\n\r\n        /*!\r\n         *  Parses the build command target.\r\n         *\r\n         *    @param [in] buildCommandElement     XML description of the build command.\r\n         *    @param [in] newBuildCommand         The new build command item.\r\n         */\r\n        void parseBuildCommandTarget(QDomElement const& buildCommandElement,\r\n            QSharedPointer<BuildCommand> newBuildCommand);\r\n\r\n        /*!\r\n         *  Parses the dependencies.\r\n         *\r\n         *    @param [in] fileElement     XML description of the file.\r\n         *    @param [in] newFile         The new file item.\r\n         */\r\n        void parseDependencies(QDomElement const& fileElement, QSharedPointer<File> newFile);\r\n\r\n        /*!\r\n         *  Parses the defines.\r\n         *\r\n         *    @param [in] fileElement     XML description of the file.\r\n         *    @param [in] newFile         The new file item.\r\n         */\r\n        void parseDefines(QDomElement const& fileElement, QSharedPointer<File> newFile);\r\n\r\n        /*!\r\n         *  Parses the image types.\r\n         *\r\n         *    @param [in] fileElement     XML description of the file.\r\n         *    @param [in] newFile         The new file item.\r\n         */\r\n        void parseImageTypes(QDomElement const& fileElement, QSharedPointer<File> newFile);\r\n\r\n        /*!\r\n         *  Parses the description.\r\n         *\r\n         *    @param [in] fileElement     XML description of the file.\r\n         *    @param [in] newFile         The new file item.\r\n         */\r\n        void parseDescription(QDomElement const& fileElement, QSharedPointer<File> newFile);\r\n\r\n        /*!\r\n         *  Parses the file vendor extensions.\r\n         *\r\n         *    @param [in] fileElement     XML description of the file.\r\n         *    @param [in] newFile         The new file item.\r\n         */\r\n        void parseFileExtensions(QDomNode const& fileNode, QSharedPointer<File> newFile);\r\n    }\r\n};\r\n\r\n#endif // FILEREADER_H"
  },
  {
    "path": "IPXACTmodels/Component/FileSet.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: FileSet.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 18.09.2015\r\n//\r\n// Description:\r\n// Describes the ipxact:fileSet element.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"FileSet.h\"\r\n\r\n#include <IPXACTmodels/common/VendorExtension.h>\r\n#include <IPXACTmodels/common/FileType.h>\r\n#include <IPXACTmodels/kactusExtensions/Kactus2Value.h>\r\n\r\n#include <IPXACTmodels/utilities/Search.h>\r\n\r\n#include <QFileInfo>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileSet::FileSet()\r\n//-----------------------------------------------------------------------------\r\nFileSet::FileSet(QString const& name, QString const& group) :\r\nNameGroup(name),\r\nExtendable()\r\n{\r\n    if (!group.isEmpty())\r\n    {\r\n        groups_->append(group);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileSet::FileSet()\r\n//-----------------------------------------------------------------------------\r\nFileSet::FileSet(const FileSet &other) :\r\nNameGroup(other),\r\nExtendable(other)\r\n{\r\n    copyFiles(other);\r\n    copyDefaultFileBuilders(other);\r\n    copyFunctions(other);\r\n    copyStringLists(other);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileSet::operator=()\r\n//-----------------------------------------------------------------------------\r\nFileSet& FileSet::operator=(const FileSet& other)\r\n{\r\n    if (this != &other)\r\n    {\r\n        NameGroup::operator=(other);\r\n        Extendable::operator=(other);\r\n\r\n        files_->clear();\r\n        copyFiles(other);\r\n        defaultFileBuilders_->clear();\r\n        copyDefaultFileBuilders(other);\r\n        functions_->clear();\r\n        copyFunctions(other);\r\n        groups_->clear();\r\n        dependencies_->clear();\r\n        copyStringLists(other);\r\n    }\r\n\r\n    return *this;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileSet::~FileSet()\r\n//-----------------------------------------------------------------------------\r\nFileSet::~FileSet()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileSet::getGroups()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<QStringList> FileSet::getGroups() const\r\n{\r\n    return groups_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileSet::setGroups()\r\n//-----------------------------------------------------------------------------\r\nvoid FileSet::setGroups(QSharedPointer<QStringList> newGroups)\r\n{\r\n    groups_->clear();\r\n    groups_ = newGroups;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileSet::setGroups()\r\n//-----------------------------------------------------------------------------\r\nvoid FileSet::setGroups(QString const& groupName )\r\n{\r\n    groups_->clear();\r\n    groups_->append(groupName);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileSet::getFiles()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<QList<QSharedPointer<File> > > FileSet::getFiles() const\r\n{\r\n    return files_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileSet::getFiles()\r\n//-----------------------------------------------------------------------------\r\nQStringList FileSet::getFileNames(QStringList const& fileTypes ) const\r\n{\r\n    QStringList files;\r\n\r\n    for (QSharedPointer<File> file : *files_)\r\n    {\r\n        if (file->matchesFileType(fileTypes))\r\n        {\r\n            files.append(file->name());\r\n        }\r\n    }\r\n\r\n    return files;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileSet::setFiles()\r\n//-----------------------------------------------------------------------------\r\nvoid FileSet::setFiles(QSharedPointer<QList<QSharedPointer<File> > > newFiles)\r\n{\r\n    files_->clear();\r\n    files_ = newFiles;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileSet::getDefaultFileBuilders()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<QList<QSharedPointer<FileBuilder> > > FileSet::getDefaultFileBuilders() const\r\n{\r\n    return defaultFileBuilders_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileSet::setDefaultFileBuilders()\r\n//-----------------------------------------------------------------------------\r\nvoid FileSet::setDefaultFileBuilders(QSharedPointer<QList<QSharedPointer<FileBuilder> > > newDefaultFileBuilders)\r\n{\r\n    defaultFileBuilders_->clear();\r\n    defaultFileBuilders_ = newDefaultFileBuilders;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileSet::getDependencies()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<QStringList> FileSet::getDependencies() const\r\n{\r\n    return dependencies_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileSet::setDependencies()\r\n//-----------------------------------------------------------------------------\r\nvoid FileSet::setDependencies(QSharedPointer<QStringList> newDependencies)\r\n{\r\n    dependencies_->clear();\r\n    dependencies_ = newDependencies;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileSet::addDependency()\r\n//-----------------------------------------------------------------------------\r\nvoid FileSet::addDependency( QString const& path )\r\n{\r\n    dependencies_->append(path);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileSet::getFunctions()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<QList<QSharedPointer<Function> > > FileSet::getFunctions() const\r\n{\r\n\treturn functions_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileSet::setFunctions()\r\n//-----------------------------------------------------------------------------\r\nvoid FileSet::setFunctions(QSharedPointer<QList<QSharedPointer<Function> > > newFunctions)\r\n{\r\n\tfunctions_->clear();\r\n\tfunctions_ = newFunctions;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileSet::getVhdlLibraryNames()\r\n//-----------------------------------------------------------------------------\r\nQStringList FileSet::getVhdlLibraryNames() const\r\n{\r\n    QStringList libraries;\r\n    for (QSharedPointer<File> file : *files_)\r\n    {\r\n        if (file->isVhdlFile() && !file->getLogicalName().isEmpty() && !libraries.contains(file->getLogicalName()))\r\n        {\r\n            libraries.append(file->getLogicalName());\r\n        }\r\n    }\r\n    return libraries;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileSet::getFilePaths()\r\n//-----------------------------------------------------------------------------\r\nQStringList FileSet::getFilePaths() const\r\n{\r\n    QStringList filePaths;\r\n\r\n    std::for_each(files_->cbegin(), files_->cend(), \r\n        [&filePaths](auto const& file) { filePaths.append(file->name()); });\r\n\r\n    return filePaths;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileSet::addFile()\r\n//-----------------------------------------------------------------------------\r\nvoid FileSet::addFile(QSharedPointer<File> file)\r\n{\r\n    auto fileName = file->name();\r\n    auto it = std::find_if(files_->cbegin(), files_->cend(),\r\n        [&fileName](auto const& existingFile) { return existingFile->name() == fileName; });\r\n\r\n    if (it == files_->cend())\r\n    {\r\n        files_->append(file);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileSet::addFile()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<File> FileSet::addFile(QString const& filePath, QSettings& settings)\r\n{\r\n    QSharedPointer<File> file = Search::findByName(filePath, *files_);\r\n    \r\n    if (!file)\r\n    {\r\n        file = QSharedPointer<File> (new File(filePath));\r\n        files_->append(file);\r\n    }\r\n\r\n    QFileInfo fileInfo(filePath);\r\n    QStringList types = FileTypes::getFileTypes(settings, fileInfo);\r\n\r\n    for (QString const& fileType : types)\r\n    {\r\n        if (!file->matchesFileType(fileType))\r\n        {\r\n            file->addFileType(fileType);\r\n        }\r\n\t}\r\n\r\n    return file;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileSet::getFile()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<File> FileSet::getFile(QString const& logicalName) const\r\n{\r\n    auto it = std::find_if(files_->cbegin(), files_->cend(),\r\n        [&logicalName](auto const& file) { return file->getLogicalName() == logicalName; });\r\n\r\n    if (it != files_->cend())\r\n    {\r\n        return *it;\r\n    }\r\n\r\n    return nullptr;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileSet::getFileNames()\r\n//-----------------------------------------------------------------------------\r\nQStringList FileSet::getFileNames() const\r\n{\r\n    return getFilePaths();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileSet::findFilesByFileType()\r\n//-----------------------------------------------------------------------------\r\nQStringList FileSet::findFilesByFileType(QString const& fileType ) const\r\n{\r\n    QStringList files;\r\n    for (QSharedPointer<const File> file : *files_)\r\n    {\r\n        if (file->matchesFileType(fileType))\r\n        {\r\n            files.append(file->name());\r\n        }\r\n    }\r\n\r\n    return files;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileSet::removeFile()\r\n//-----------------------------------------------------------------------------\r\nvoid FileSet::removeFile(QString const& fileName )\r\n{\r\n    QSharedPointer<File> file = Search::findByName(fileName, *files_);\r\n\r\n    files_->removeOne(file);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileSet::removeFile()\r\n//-----------------------------------------------------------------------------\r\nvoid FileSet::removeFile(QSharedPointer<File> file)\r\n{\r\n    files_->removeOne(file);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileSet::createFile()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<File> FileSet::createFile()\r\n{\r\n    QSharedPointer<File> file(new File());\r\n    files_->append(file);\r\n    return file;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileSet::getDefaultCommand()\r\n//-----------------------------------------------------------------------------\r\nQString FileSet::getDefaultCommand(QSharedPointer<File> file) const\r\n{\r\n    if (!file)\r\n    {\r\n        return QString();\r\n    }\r\n\r\n    for (auto const& fileType : *file->getFileTypes())\r\n    {\r\n        for (QSharedPointer<FileBuilder> fileBuilder : *defaultFileBuilders_)\r\n        {\r\n            if (fileBuilder->hasFileType(fileType.type_))\r\n            {\r\n                return fileBuilder->getCommand();\r\n            }\r\n        }\r\n    }\r\n\r\n    return QString();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileSet::getDefaultFlags()\r\n//-----------------------------------------------------------------------------\r\nQString FileSet::getDefaultFlags(QSharedPointer<File> file) const\r\n{\r\n    if (!file)\r\n    {\r\n        return QString();\r\n    }\r\n    \r\n    for (auto const& fileType : *file->getFileTypes())\r\n    {\r\n        for (QSharedPointer<FileBuilder> fileBuilder : *defaultFileBuilders_)\r\n        {\r\n            if (fileBuilder->hasFileType(fileType.type_))\r\n            {\r\n                return fileBuilder->getFlags();\r\n            }\r\n        }\r\n    }\r\n    return QString();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileSet::getRTLFiles()\r\n//-----------------------------------------------------------------------------\r\nQList<QSharedPointer<File> > FileSet::getRTLFiles() const\r\n{\r\n    QList<QSharedPointer<File> > list;\r\n    for (QSharedPointer<File> file : *files_)\r\n    {\r\n        if (file->isRTLFile())\r\n        {\r\n            list.append(file);\r\n        }\r\n    }\r\n    return list;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileSet::contains()\r\n//-----------------------------------------------------------------------------\r\nbool FileSet::contains(QString const& fileName ) const\r\n{\r\n    return Search::findByName(fileName, *files_).isNull() == false;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileSet::changeFileName()\r\n//-----------------------------------------------------------------------------\r\nvoid FileSet::changeFileName(QString const& from, QString const& to )\r\n{\r\n    QSharedPointer<File> file = Search::findByName(from, *files_);\r\n    if (file.isNull() == false)\r\n    {\r\n        file->setName(to);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileSet::clearFiles()\r\n//-----------------------------------------------------------------------------\r\nvoid FileSet::clearFiles()\r\n{\r\n    files_->clear();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileSet::getFileSetId()\r\n//-----------------------------------------------------------------------------\r\nQString FileSet::getFileSetId() const\r\n{\r\n    auto extension = findVendorExtension(QStringLiteral(\"kactus2:fileSetId\"));\r\n    if (extension != nullptr)\r\n    {\r\n        QSharedPointer<Kactus2Value> idExtension = extension.dynamicCast<Kactus2Value>();\r\n        return idExtension->value();\r\n    }\r\n\r\n    return QString();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileSet::setFileSetId()\r\n//-----------------------------------------------------------------------------\r\nvoid FileSet::setFileSetId(QString const& id )\r\n{\r\n    auto extension = findVendorExtension(QStringLiteral(\"kactus2:fileSetId\")).dynamicCast<Kactus2Value>();\r\n    if (!id.isEmpty())\r\n    {\r\n        if (extension == nullptr)\r\n        {\r\n            extension = QSharedPointer<Kactus2Value>(new Kactus2Value(QStringLiteral(\"kactus2:fileSetId\"), QString()));\r\n            getVendorExtensions()->append(extension);\r\n        }\r\n\r\n        extension->setValue(id);\r\n    }\r\n    else\r\n    {\r\n        getVendorExtensions()->removeAll(extension);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileSet::copyFiles()\r\n//-----------------------------------------------------------------------------\r\nvoid FileSet::copyFiles(const FileSet& other)\r\n{\r\n    for (QSharedPointer<File> file : *other.files_)\r\n    {\r\n        QSharedPointer<File> copy = QSharedPointer<File>(new File(*file));\r\n        files_->append(copy);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileSet::copyDefaultFileBuilders()\r\n//-----------------------------------------------------------------------------\r\nvoid FileSet::copyDefaultFileBuilders(const FileSet& other)\r\n{\r\n    for (QSharedPointer<FileBuilder> fileBuilder : *other.defaultFileBuilders_)\r\n    {\r\n        QSharedPointer<FileBuilder> copy = QSharedPointer<FileBuilder>(new FileBuilder(*fileBuilder));\r\n        defaultFileBuilders_->append(copy);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileSet::copyFunctions()\r\n//-----------------------------------------------------------------------------\r\nvoid FileSet::copyFunctions(const FileSet& other)\r\n{\r\n    for (QSharedPointer<Function> funcion : *other.functions_)\r\n    {\r\n        QSharedPointer<Function> copy = QSharedPointer<Function>(new Function(*funcion));\r\n        functions_->append(copy);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileSet::copyFunctions()\r\n//-----------------------------------------------------------------------------\r\nvoid FileSet::copyStringLists(const FileSet& other)\r\n{\r\n    groups_->append(*other.groups_);\r\n\r\n    dependencies_->append(*other.dependencies_);\r\n}\r\n"
  },
  {
    "path": "IPXACTmodels/Component/FileSet.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: FileSet.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 18.09.2015\r\n//\r\n// Description:\r\n// Describes the ipxact:fileSet element.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef FILESET_H\r\n#define FILESET_H\r\n\r\n#include \"Function.h\"\r\n#include \"File.h\"\r\n#include <IPXACTmodels/common/FileBuilder.h>\r\n\r\n#include <IPXACTmodels/generaldeclarations.h>\r\n\r\n#include <IPXACTmodels/common/NameGroup.h>\r\n#include <IPXACTmodels/common/Extendable.h>\r\n\r\n#include <IPXACTmodels/ipxactmodels_global.h>\r\n\r\n#include <QString>\r\n#include <QList>\r\n#include <QStringList>\r\n#include <QSharedPointer>\r\n#include <QSettings>\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Describes the ipxact:fileSet element.\r\n//-----------------------------------------------------------------------------\r\nclass IPXACTMODELS_EXPORT FileSet : public NameGroup, public Extendable\r\n{\r\n\r\npublic:\r\n\r\n    /*!\r\n     *  The constructor.\r\n     *\r\n     *    @param [in] name    Name of the file set.\r\n     *    @param [in] group   Group where this file set belongs to.\r\n     */\r\n    FileSet(const QString& name = QString(), const QString& group = QString());\r\n\r\n\t//! Copy constructor\r\n\tFileSet(const FileSet& other);\r\n\r\n\t//! Assignment operator\r\n\tFileSet &operator=(const FileSet& other);\r\n\r\n\t/*!\r\n     *  The destructor\r\n\t */\r\n\t~FileSet();\r\n\r\n\t/*! \r\n     *  Get the groups of this file set\r\n\t *\r\n\t *      @reutnr The groups.\r\n\t */\r\n    QSharedPointer<QStringList> getGroups() const;\r\n    \r\n\t/*!\r\n     *  Set the groups for this file  set\r\n\t *\r\n\t *    @param [in] groups  The new group names.\r\n\t */\r\n    void setGroups (QSharedPointer<QStringList> newGroups);\r\n\r\n\t/*! Clear the previous groups and add a new group identifier.\r\n\t *\r\n\t *    @param [in] groupName   The group identifier which is set after clearing.\r\n\t */\r\n\tvoid setGroups(const QString& groupName);\r\n    \r\n\t/*! \r\n     *  Get the files associated with this file set\r\n\t *\r\n\t *    @return Pointer to a list containing the files associated with this file set.\r\n\t */\r\n    QSharedPointer<QList<QSharedPointer<File> > > getFiles() const;\r\n    \r\n\t/*! \r\n     *  Get the files that match the specified file types.\r\n\t *\r\n\t *    @param [in] fileTypes   Contains the file types that are being searched.\r\n\t *\r\n\t *    @return The relative file paths to the matched files.\r\n\t */\r\n\tQStringList getFileNames(const QStringList& fileTypes) const;\r\n\r\n\t/*! \r\n     *  Set the files for this file set\r\n\t *\r\n\t *    @param [in] files   Pointer to a list containing the new files.\r\n\t */\r\n    void setFiles(QSharedPointer<QList<QSharedPointer<File> > > newFiles);\r\n\r\n\r\n\t/*! \r\n     *  Get the default file builders for this file set\r\n\t *\r\n\t *    @return Pointer to a list containing the file builders.\r\n\t */\r\n    QSharedPointer<QList<QSharedPointer<FileBuilder> > > getDefaultFileBuilders()  const;\r\n    \r\n\t/*! \r\n     *  Set the default file builders for this file set.\r\n\t *\r\n\t *    @param [in] defaultFileBuilders     Pointer to a list containing the new default file builders.\r\n\t */\r\n    void setDefaultFileBuilders(QSharedPointer<QList<QSharedPointer<FileBuilder> > > newDefaultFileBuilders);\r\n    \r\n\t/*! \r\n     *  Get the dependencies for this file set\r\n\t *\r\n\t *    @return Paths for the directories containing files on which this file set depends.\r\n\t */\r\n    QSharedPointer<QStringList> getDependencies() const;\r\n\r\n\t/*! \r\n     *  Set the dependencies for this file set\r\n\t *\r\n\t *    @param [in] dependencies    The new dependencies.\r\n\t */\r\n    void setDependencies(QSharedPointer<QStringList> newDependencies);\r\n\r\n\t/*! Add a new dependent directory to the file set.\r\n\t *\r\n\t *    @param [in] path    Relative path to the dependent directory to add.\r\n\t *\r\n\t */\r\n\tvoid addDependency(const QString& path);\r\n\r\n\t/*! Get list of the functions for this file set\r\n\t *\r\n\t *    @return Pointer to a list containing the functions.\r\n\t */\r\n    QSharedPointer<QList<QSharedPointer<Function> > > getFunctions() const;\r\n    \r\n\t/*! \r\n     *  Set the functions for this file set\r\n\t *\r\n\t *    @param [in] functions Pointer to a list containing the new functions.\r\n\t */\r\n    void setFunctions(QSharedPointer<QList<QSharedPointer<Function> > > newFunctions);\r\n\r\n\t/*! \r\n     *  Get the names of the vhdl libraries on this file set.\r\n\t *\r\n\t *    @return The library names.\r\n\t */\r\n\tQStringList getVhdlLibraryNames() const;\r\n    \r\n\t/*! \r\n     *  Get the file paths of the files stored in the file set.\r\n\t *\r\n\t *    @return The file paths.\r\n\t */\r\n    QStringList getFilePaths() const;\r\n        \r\n\t/*! \r\n     *  Add a new file to the file set.\r\n\t *\r\n\t *    @param [in] file Pointer to the new file to be added.\r\n\t */\r\n\tvoid addFile(QSharedPointer<File> file);\r\n\r\n\t/*! \r\n     *  Add a new file to the file set.\r\n\t *\r\n\t *    @param [in] filePath    Path to the file to add (this should be relative path).\r\n\t *    @param [in] settings    Contains the file type settings for Kactus2.\r\n\t *\r\n     *    @return Pointer to the new file.\r\n\t */\r\n\tQSharedPointer<File> addFile(const QString& filePath, QSettings& settings);\r\n\r\n\t/*! \r\n     *  Get pointer to the file with given logical name.\r\n\t *\r\n\t *    @param [in] logicalName     The logical name of the wanted file. The first one found is returned.\r\n\t *\r\n\t *    @return Pointer to the File instance, null pointer if none is found.\r\n\t */\r\n\tQSharedPointer<File> getFile(QString const& logicalName) const;\r\n\r\n\t/*! \r\n     *  Get the name elements of the files stored within this file set.\r\n\t *\r\n\t *    @return The file names.\r\n\t */\r\n\tQStringList getFileNames() const;\r\n\r\n\t/*! \r\n     *  Find the files that match the specified file type.\r\n\t *\r\n\t *    @param [in] fileType    The file type to search within files.\r\n\t *\r\n\t *    @return The file paths to files that match the file type.\r\n     */\r\n\tQStringList findFilesByFileType(const QString& fileType) const;\r\n\r\n\t/*!\r\n     *  Remove the specified file from the file set.\r\n\t *\r\n\t *    @param [in] fileName    The name of the file to be removed\r\n\t */\r\n\tvoid removeFile(const QString& fileName);\r\n\r\n\t/*! \r\n     * Remove the specified file from the file set.\r\n\t *\r\n\t *    @param [in] file    Pointer to the file that is to be removed\r\n\t */\r\n    void removeFile(QSharedPointer<File> file);\r\n\r\n\t/*!\r\n     *  Create a new file to the file set.\r\n\t * \r\n\t *    @return Pointer to the file that was created.\r\n\t */\r\n\tQSharedPointer<File> createFile();\r\n\r\n\t/*!\r\n     *  Get the default build command's command part for given file.\r\n\t *\r\n\t *    @param [in] file    Pointer to the file that's command is wanted.\r\n\t *\r\n\t *    @return Command of the selected file.\r\n\t */\r\n    QString getDefaultCommand(QSharedPointer<File> file) const;\r\n\r\n\t/*! \r\n     *  Get the default build command's flags for given file.\r\n\t *\r\n\t *    @param [in] file    Pointer to the file that's default flags are wanted.\r\n\t *\r\n\t *    @return The default flags of selected file.\r\n\t */\r\n    QString getDefaultFlags(QSharedPointer<File> file) const;\r\n\r\n\t/*!\r\n     *  Get list of the RTL files contained in this file set.\r\n\t *\r\n\t *    @return Pointers to the files.\r\n\t */\r\n\tQList<QSharedPointer<File> > getRTLFiles() const;\r\n\r\n\t/*! \r\n     *  Does the file set contain file with given name.\r\n\t *\r\n\t *    @param [in] fileName    The name of the file searched for.\r\n\t *\r\n\t *    @return True if file is found, false otherwise.\r\n\t */\r\n\tbool contains(const QString& fileName) const;\r\n\r\n\t/*! \r\n     *  Change the name of a file within this file set.\r\n\t * \r\n\t *    @param [in] from    The current file name.\r\n\t *    @param [in] to      The file name to set.\r\n\t */\r\n\tvoid changeFileName(const QString& from, const QString& to);\r\n\r\n\t/*!\r\n     *  Remove the files listed in the file set.\r\n\t */\r\n\tvoid clearFiles();\r\n\r\n\t/*! \r\n     *  Get id of the file set.\r\n\t *\r\n\t *    @return The file set id.\r\n\t */\r\n\tQString getFileSetId() const;\r\n\r\n\t/*!\r\n     *  Set the file set id.\r\n\t *\r\n\t *    @param [in] id  The id to be set.\r\n\t */\r\n\tvoid setFileSetId(const QString& newId);\r\n\r\nprivate:\r\n\r\n    /*!\r\n     *  Copies the files.\r\n     *\r\n     *    @param [in] other   The file set from which to copy the files.\r\n     */\r\n    void copyFiles(const FileSet& other);\r\n\r\n    /*!\r\n     *  Copies the default file builders.\r\n     *\r\n     *    @param [in] other   The file set from which to copy the default file builders.\r\n     */\r\n    void copyDefaultFileBuilders(const FileSet& other);\r\n\r\n    /*!\r\n     *  Copies the functions.\r\n     *\r\n     *    @param [in] other   The file set from which to copy the functions.\r\n     */\r\n    void copyFunctions(const FileSet& other);\r\n\r\n    /*!\r\n     *  Copies the groups and dependencies.\r\n     *\r\n     *    @param [in] other   The file set from which to copy the groups and dependencies.\r\n     */\r\n    void copyStringLists(const FileSet& other);\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n\t//! Describes the function or purpose of the file set.\r\n\tQSharedPointer<QStringList> groups_ = QSharedPointer<QStringList>(new QStringList);\r\n\r\n\t//! The contained files.\r\n\tQSharedPointer<QList<QSharedPointer<File> > > files_ =\r\n\t\tQSharedPointer<QList<QSharedPointer<File> > >(new QList<QSharedPointer<File> >);\r\n\r\n\t//! The contained default file builders.\r\n\tQSharedPointer<QList<QSharedPointer<FileBuilder> > > defaultFileBuilders_ =\r\n\t\tQSharedPointer<QList<QSharedPointer<FileBuilder> > >(new QList<QSharedPointer<FileBuilder> >);\r\n\r\n\t//! Contains paths to directories containing dependency files\r\n\tQSharedPointer<QStringList> dependencies_ = QSharedPointer<QStringList>(new QStringList);\r\n\r\n\t//! The contained functions.\r\n\tQSharedPointer<QList<QSharedPointer<Function> > > functions_ =\r\n\t\tQSharedPointer<QList<QSharedPointer<Function> > >(new QList<QSharedPointer<Function> >);\r\n};\r\n\r\n#endif // FILESET_H\r\n"
  },
  {
    "path": "IPXACTmodels/Component/FileSetReader.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: FileSetReader.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 22.09.2015\r\n//\r\n// Description:\r\n// Reader class for IP-XACT fileSet element.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"FileSetReader.h\"\r\n#include \"FileReader.h\"\r\n\r\n#include <IPXACTmodels/common/FileBuilderReader.h>\r\n#include <IPXACTmodels/common/NameGroupReader.h>\r\n\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileSetReader::createFileSetFrom()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<FileSet> FileSetReader::createFileSetFrom(QDomNode const& fileSetNode, Document::Revision docRevision)\r\n{\r\n    QDomElement fileSetElement = fileSetNode.toElement();\r\n    QSharedPointer<FileSet> newFileSet (new FileSet());\r\n\r\n    NameGroupReader::parseNameGroup(fileSetNode, newFileSet);\r\n\r\n    Details::parseGroups(fileSetElement, newFileSet);\r\n\r\n    Details::parseFiles(fileSetElement, newFileSet, docRevision);\r\n\r\n    Details::parseDefaultFileBuilders(fileSetElement, newFileSet, docRevision);\r\n\r\n    Details::parseDependencies(fileSetElement, newFileSet);\r\n\r\n    Details::parseFunctions(fileSetElement, newFileSet);\r\n\r\n    Details::parseFileSetExtensions(fileSetElement, newFileSet);\r\n\r\n    return newFileSet;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileSetReader::parseGroups()\r\n//-----------------------------------------------------------------------------\r\nvoid FileSetReader::Details::parseGroups(QDomElement const& fileSetElement, QSharedPointer<FileSet> newFileSet)\r\n{\r\n    QDomNodeList groupNodeList = fileSetElement.elementsByTagName(QStringLiteral(\"ipxact:group\"));\r\n\r\n    for (int groupIndex = 0; groupIndex < groupNodeList.count(); ++groupIndex)\r\n    {\r\n        QString newGroup = groupNodeList.at(groupIndex).firstChild().nodeValue();\r\n        newFileSet->getGroups()->append(newGroup);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileSetReader::parseFiles()\r\n//-----------------------------------------------------------------------------\r\nvoid FileSetReader::Details::parseFiles(QDomElement const& fileSetElement, QSharedPointer<FileSet> newFileSet,\r\n    Document::Revision docRevision)\r\n{\r\n\t// Find all file-elements.\r\n    QDomNodeList fileNodeList = fileSetElement.elementsByTagName(QStringLiteral(\"ipxact:file\"));\r\n\r\n    if (!fileNodeList.isEmpty())\r\n    {\r\n        for (int fileIndex = 0; fileIndex < fileNodeList.count(); ++fileIndex)\r\n\t\t{\r\n\t\t\t// Read each file with the file reader.\r\n            QSharedPointer<File> newFile = FileReader::createFileFrom(fileNodeList.at(fileIndex), docRevision);\r\n\t\t\t// Then append the file to the list.\r\n            newFileSet->getFiles()->append(newFile);\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileSetReader::parseDefaultFileBuilders()\r\n//-----------------------------------------------------------------------------\r\nvoid FileSetReader::Details::parseDefaultFileBuilders(QDomElement const& fileSetElement, QSharedPointer<FileSet> newFileSet,\r\n    Document::Revision docRevision)\r\n{\r\n    QDomNodeList fileBuilderNodeList = fileSetElement.elementsByTagName(QStringLiteral(\"ipxact:defaultFileBuilder\"));\r\n\r\n    if (!fileBuilderNodeList.isEmpty())\r\n    {\r\n        for (int fileBuilderIndex = 0; fileBuilderIndex < fileBuilderNodeList.count(); ++fileBuilderIndex)\r\n        {\r\n            QSharedPointer<FileBuilder> newFileBuilder =\r\n                FileBuilderReader::createFileBuilderFrom(fileBuilderNodeList.at(fileBuilderIndex), docRevision);\r\n            newFileSet->getDefaultFileBuilders()->append(newFileBuilder);\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileSetReader::parseDependencies()\r\n//-----------------------------------------------------------------------------\r\nvoid FileSetReader::Details::parseDependencies(QDomElement const& fileSetElement, QSharedPointer<FileSet> newFileSet)\r\n{\r\n    for (int childnodeIndex = 0; childnodeIndex < fileSetElement.childNodes().count(); ++childnodeIndex)\r\n    {\r\n        QDomNode childNode = fileSetElement.childNodes().at(childnodeIndex);\r\n\r\n        if (childNode.nodeName() == QStringLiteral(\"ipxact:dependency\"))\r\n        {\r\n            QString dependency = childNode.firstChild().nodeValue();\r\n            newFileSet->getDependencies()->append(dependency);\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileSetReader::parseFunctions()\r\n//-----------------------------------------------------------------------------\r\nvoid FileSetReader::Details::parseFunctions(QDomElement const& fileSetElement, QSharedPointer<FileSet> newFileSet)\r\n{\r\n    QDomNodeList functionNodeList = fileSetElement.elementsByTagName(QStringLiteral(\"ipxact:function\"));\r\n\r\n    for (int functionIndex = 0; functionIndex < functionNodeList.count(); ++functionIndex)\r\n    {\r\n        QDomElement functionElement = functionNodeList.at(functionIndex).toElement();\r\n\r\n        QString fileReference = functionElement.firstChildElement(QStringLiteral(\"ipxact:fileRef\")).firstChild().nodeValue();\r\n        QSharedPointer<Function> newFunction (new Function(fileReference));\r\n\r\n        if (functionElement.hasAttribute(QStringLiteral(\"replicate\")))\r\n        {\r\n            newFunction->setReplicate(true);\r\n        }\r\n\r\n        parseFunctionEntryPoint(functionElement, newFunction);\r\n\r\n        parseFunctionReturnType(functionElement, newFunction);\r\n\r\n        parseFunctionArguments(functionElement, newFunction);\r\n\r\n        parseFunctionDisabled(functionElement, newFunction);\r\n\r\n        parseFunctionSourceFiles(functionElement, newFunction);\r\n\r\n        newFileSet->getFunctions()->append(newFunction);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileSetReader::parseFunctionEntryPoint()\r\n//-----------------------------------------------------------------------------\r\nvoid FileSetReader::Details::parseFunctionEntryPoint(QDomElement const& functionElement,\r\n    QSharedPointer<Function> newFunction)\r\n{\r\n    QDomElement entryPointElement = functionElement.firstChildElement(QStringLiteral(\"ipxact:entryPoint\"));\r\n    if (!entryPointElement.isNull())\r\n    {\r\n        QString entryPoint = entryPointElement.firstChild().nodeValue();\r\n        newFunction->setEntryPoint(entryPoint);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileSetReader::parseFunctionReturnType()\r\n//-----------------------------------------------------------------------------\r\nvoid FileSetReader::Details::parseFunctionReturnType(QDomElement const& functionElement,\r\n    QSharedPointer<Function> newFunction)\r\n{\r\n    QDomElement returnTypeElement = functionElement.firstChildElement(QStringLiteral(\"ipxact:returnType\"));\r\n    if (!returnTypeElement.isNull())\r\n    {\r\n        QString returnType = returnTypeElement.firstChild().nodeValue();\r\n        newFunction->setReturnType(returnType);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileSetReader::parseFunctionArguments()\r\n//-----------------------------------------------------------------------------\r\nvoid FileSetReader::Details::parseFunctionArguments(QDomElement const& functionElement,\r\n    QSharedPointer<Function> newFunction)\r\n{\r\n    QDomNodeList argumentNodeList = functionElement.elementsByTagName(QStringLiteral(\"ipxact:argument\"));\r\n\r\n    if (!argumentNodeList.isEmpty())\r\n    {\r\n        for (int argumentIndex = 0; argumentIndex < argumentNodeList.count(); ++argumentIndex)\r\n        {\r\n            QDomNode argumentNode = argumentNodeList.at(argumentIndex);\r\n\r\n            QSharedPointer<NameValuePair> newArgument (new NameValuePair());\r\n\r\n            NameGroupReader::parseNameGroup(argumentNode, newArgument);\r\n\r\n            QString value = argumentNode.firstChildElement(QStringLiteral(\"ipxact:value\")).firstChild().nodeValue();\r\n            newArgument->setValue(value);\r\n\r\n            CommonItemsReader::parseVendorExtensions(argumentNode, newArgument);\r\n\r\n            newFunction->getArguments()->append(newArgument);\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileSetReader::parseFunctionDisabled()\r\n//-----------------------------------------------------------------------------\r\nvoid FileSetReader::Details::parseFunctionDisabled(QDomElement const& functionElement, QSharedPointer<Function> newFunction)\r\n{\r\n    QDomElement disabledElement = functionElement.firstChildElement(QStringLiteral(\"ipxact:disabled\"));\r\n    if (!disabledElement.isNull())\r\n    {\r\n        QString disabledValue = disabledElement.firstChild().nodeValue();\r\n        newFunction->setDisabled(disabledValue);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileSetReader::parseFunctionSourceFiles()\r\n//-----------------------------------------------------------------------------\r\nvoid FileSetReader::Details::parseFunctionSourceFiles(QDomElement const& functionElement,\r\n    QSharedPointer<Function> newFunction)\r\n{\r\n    QDomNodeList sourceFileNodeList = functionElement.elementsByTagName(QStringLiteral(\"ipxact:sourceFile\"));\r\n\r\n    for (int i = 0; i < sourceFileNodeList.count(); ++i)\r\n    {\r\n        QDomNode sourceNode = sourceFileNodeList.at(i);\r\n\r\n        QString sourceName = sourceNode.firstChildElement(QStringLiteral(\"ipxact:sourceName\")).firstChild().nodeValue();\r\n        QString sourceType = sourceNode.firstChildElement(QStringLiteral(\"ipxact:fileType\")).firstChild().nodeValue();\r\n\r\n        QSharedPointer<Function::SourceFile> newSourceFile (new Function::SourceFile(sourceName, sourceType));\r\n\r\n        newFunction->getSourceFiles()->append(newSourceFile);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileSetReader::parseFileSetExtensions()\r\n//-----------------------------------------------------------------------------\r\nvoid FileSetReader::Details::parseFileSetExtensions(QDomElement const& fileSetElement,\r\n    QSharedPointer<FileSet> newFileSet)\r\n{\r\n    QDomElement extensionsElement = fileSetElement.firstChildElement(QStringLiteral(\"ipxact:vendorExtensions\"));\r\n    QDomElement idExtension = extensionsElement.firstChildElement(QStringLiteral(\"kactus2:fileSetId\"));\r\n    if (!idExtension.isNull())\r\n    {\r\n        QString fileSetID = idExtension.firstChild().nodeValue();\r\n        newFileSet->setFileSetId(fileSetID);\r\n    }\r\n\r\n    CommonItemsReader::parseVendorExtensions(fileSetElement, newFileSet);\r\n}\r\n"
  },
  {
    "path": "IPXACTmodels/Component/FileSetReader.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: FileSetReader.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 22.09.2015\r\n//\r\n// Description:\r\n// Reader class for IP-XACT fileSet element.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef FILESETREADER_H\r\n#define FILESETREADER_H\r\n\r\n#include \"FileSet.h\"\r\n\r\n#include <IPXACTmodels/common/CommonItemsReader.h>\r\n\r\n#include <QSharedPointer>\r\n#include <QDomNode>\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Reader class for IP-XACT fileSet element.\r\n//-----------------------------------------------------------------------------\r\nnamespace FileSetReader \r\n{\r\n    /*!\r\n     *  Creates a new file set from a given file set node.\r\n     *\r\n     *    @param [in] fileSetNode     XML description of the file set.\r\n     *    @param [in] docRevision     The applied IP-XACT standard revision.\r\n     */\r\n    IPXACTMODELS_EXPORT QSharedPointer<FileSet> createFileSetFrom(QDomNode const& fileSetNode, Document::Revision docRevision);\r\n\r\n    namespace Details\r\n    {\r\n        /*!\r\n         *  Reads the groups.\r\n         *\r\n         *    @param [in] fileSetElement  XML description of the file set.\r\n         *    @param [in] newFileSet      The new file set item.\r\n         */\r\n        void parseGroups(QDomElement const& fileSetElement, QSharedPointer<FileSet> newFileSet);\r\n\r\n        /*!\r\n         *  Reads the files.\r\n         *\r\n         *    @param [in] fileSetElement  XML description of the file set.\r\n         *    @param [in] newFileSet      The new file set item.\r\n         *    @param [in] docRevision     The applied IP-XACT standard revision.\r\n         */\r\n        void parseFiles(QDomElement const& fileSetElement, QSharedPointer<FileSet> newFileSet, Document::Revision docRevision);\r\n\r\n        /*!\r\n         *  Reads the default file builders.\r\n         *\r\n         *    @param [in] fileSetElement  XML description of the file set.\r\n         *    @param [in] newFileSet      The new file set item.\r\n         *    @param [in] docRevision     The applied IP-XACT standard revision.\r\n         */\r\n        void parseDefaultFileBuilders(QDomElement const& fileSetElement, QSharedPointer<FileSet> newFileSet,\r\n            Document::Revision docRevision);\r\n\r\n        /*!\r\n         *  Reads the dependencies.\r\n         *\r\n         *    @param [in] fileSetElement  XML description of the file set.\r\n         *    @param [in] newFileSet      The new file set item.\r\n         */\r\n        void parseDependencies(QDomElement const& fileSetElement, QSharedPointer<FileSet> newFileSet);\r\n\r\n        /*!\r\n         *  Reads the functions.\r\n         *\r\n         *    @param [in] fileSetElement  XML description of the file set.\r\n         *    @param [in] newFileSet      The new file set item.\r\n         */\r\n        void parseFunctions(QDomElement const& fileSetElement, QSharedPointer<FileSet> newFileSet);\r\n\r\n        /*!\r\n         *  Reads the function entry point.\r\n         *\r\n         *    @param [in] functionElement     XML description of the function.\r\n         *    @param [in] newFunction         The new function item.\r\n         */\r\n        void parseFunctionEntryPoint(QDomElement const& functionElement, QSharedPointer<Function> newFunction);\r\n\r\n        /*!\r\n         *  Reads the function return type.\r\n         *\r\n         *    @param [in] functionElement     XML description of the function.\r\n         *    @param [in] newFunction         The new function item.\r\n         */\r\n        void parseFunctionReturnType(QDomElement const& functionElement, QSharedPointer<Function> newFunction);\r\n\r\n        /*!\r\n         *  Reads the function arguments.\r\n         *\r\n         *    @param [in] functionElement     XML description of the function.\r\n         *    @param [in] newFunction         The new function item.\r\n         */\r\n        void parseFunctionArguments(QDomElement const& functionElement, QSharedPointer<Function> newFunction);\r\n\r\n        /*!\r\n         *  Reads the function disabled value.\r\n         *\r\n         *    @param [in] functionElement     XML description of the function.\r\n         *    @param [in] newFunction         The new function item.\r\n         */\r\n        void parseFunctionDisabled(QDomElement const& functionElement, QSharedPointer<Function> newFunction);\r\n\r\n        /*!\r\n         *  Reads the function source files.\r\n         *\r\n         *    @param [in] functionElement     XML description of the function.\r\n         *    @param [in] newFunction         The new function item.\r\n         */\r\n        void parseFunctionSourceFiles(QDomElement const& functionElement, QSharedPointer<Function> newFunction);\r\n\r\n        /*!\r\n         *  Reads the file set extensions.\r\n         *\r\n         *    @param [in] fileSetElement  XML description of the file set.\r\n         *    @param [in] newFileSet      The new file set item.\r\n         */\r\n        void parseFileSetExtensions(QDomElement const& fileSetElement, QSharedPointer<FileSet> newFileSet);\r\n    }\r\n};\r\n\r\n#endif // FILESETREADER_H"
  },
  {
    "path": "IPXACTmodels/Component/FileSetRef.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: FileSetRef.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Anton Hagqvist\n// Date: 4.9.2023\n//\n// Description:\n// Describes the ipxact:fileSetRef element.\n//-----------------------------------------------------------------------------\n\n#include \"FileSetRef.h\"\n\n//-----------------------------------------------------------------------------\n// Function: FileSetRef::FileSetRef()\n//-----------------------------------------------------------------------------\nFileSetRef::FileSetRef(FileSetRef const& other) :\n    Extendable(other),\n    localName_(other.localName_),\n    isPresent_(other.isPresent_)\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: FileSetRef::FileSetRef()\n//-----------------------------------------------------------------------------\nFileSetRef::FileSetRef(QString const& localName) :\n    Extendable(),\n    localName_(localName)\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: FileSetRef::getLocalName()\n//-----------------------------------------------------------------------------\nQString FileSetRef::getReference() const\n{\n    return localName_;\n}\n\n//-----------------------------------------------------------------------------\n// Function: FileSetRef::setLocalName()\n//-----------------------------------------------------------------------------\nvoid FileSetRef::setReference(QString const& newName)\n{\n    localName_ = newName;\n}\n\n//-----------------------------------------------------------------------------\n// Function: FileSetRef::getIsPresent()\n//-----------------------------------------------------------------------------\nQString FileSetRef::getIsPresent() const\n{\n    return isPresent_;\n}\n\n//-----------------------------------------------------------------------------\n// Function: FileSetRef::setIsPresent()\n//-----------------------------------------------------------------------------\nvoid FileSetRef::setIsPresent(QString const& newIsPresent)\n{\n    isPresent_ = newIsPresent;\n}\n\n//-----------------------------------------------------------------------------\n// Function: FileSetRef::operator=()\n//-----------------------------------------------------------------------------\nFileSetRef& FileSetRef::operator=(FileSetRef const& other)\n{\n    if (this != &other)\n    {\n        Extendable::operator=(other);\n        localName_ = other.localName_;\n        isPresent_ = other.isPresent_;\n    }\n\n    return *this;\n}\n"
  },
  {
    "path": "IPXACTmodels/Component/FileSetRef.h",
    "content": "//-----------------------------------------------------------------------------\n// File: FileSetRef.h\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Anton Hagqvist\n// Date: 4.9.2023\n//\n// Description:\n// Describes the ipxact:fileSetRef element.\n//-----------------------------------------------------------------------------\n\n#ifndef FILESETREF_H\n#define FILESETREF_H\n\n#include <IPXACTmodels/ipxactmodels_global.h>\n\n#include <QString>\n\n#include <IPXACTmodels/common/Extendable.h>\n\nclass IPXACTMODELS_EXPORT FileSetRef : public Extendable\n{\npublic:\n\n    //! The constructor.\n    explicit FileSetRef(QString const& localName = QString());\n\n    ~FileSetRef() override = default;\n\n    //! Copy constructor.\n    FileSetRef(FileSetRef const& other);\n\n    //! Copy assignment.\n    FileSetRef& operator=(FileSetRef const& other);\n\n    //! Get the file set reference.\n    QString getReference() const;\n\n    //! Set the file set reference.\n    void setReference(QString const& newName);\n\n    //! Get the isPresent value.\n    QString getIsPresent() const;\n\n    //! Set the isPresent value.\n    void setIsPresent(QString const& newIsPresent);\n\nprivate:\n    //! The name of the referenced file set.\n    QString localName_;\n\n    //! The is present value.\n    QString isPresent_;\n};\n\n#endif // FILESETREF_H\n"
  },
  {
    "path": "IPXACTmodels/Component/FileSetWriter.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: FileSetWriter.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 21.09.2015\r\n//\r\n// Description:\r\n// Writer class for IP-XACT fileSet element.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"FileSetWriter.h\"\r\n#include \"FileWriter.h\"\r\n\r\n#include <IPXACTmodels/common/FileBuilderWriter.h>\r\n#include <IPXACTmodels/common/NameGroupWriter.h>\r\n#include <IPXACTmodels/common/FileType.h>\r\n\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileSetWriter::writeFileSet()\r\n//-----------------------------------------------------------------------------\r\nvoid FileSetWriter::writeFileSet(QXmlStreamWriter& writer, QSharedPointer<FileSet> fileSet,\r\n    Document::Revision docRevision)\r\n{\r\n    writer.writeStartElement(QStringLiteral(\"ipxact:fileSet\"));\r\n\r\n    NameGroupWriter::writeNameGroup(writer, fileSet, docRevision);\r\n\r\n    Details::writeGroups(writer, fileSet->getGroups());\r\n\r\n    Details::writeFiles(writer, fileSet->getFiles(), docRevision);\r\n\r\n    Details::writeDefaultFileBuilders(writer, fileSet->getDefaultFileBuilders(), docRevision);\r\n\r\n    Details::writeDependencies(writer, fileSet->getDependencies());\r\n\r\n    Details::writeFunctions(writer, fileSet->getFunctions(), docRevision);\r\n\r\n    CommonItemsWriter::writeVendorExtensions(writer, fileSet);\r\n\r\n    writer.writeEndElement(); // ipxact:file\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileSetWriter::writeGroups()\r\n//-----------------------------------------------------------------------------\r\nvoid FileSetWriter::Details::writeGroups(QXmlStreamWriter& writer, QSharedPointer<QStringList> groups)\r\n{\r\n    for (QString const& singleGroup : *groups)\r\n    {\r\n        writer.writeTextElement(QStringLiteral(\"ipxact:group\"), singleGroup);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileSetWriter::writeFiles()\r\n//-----------------------------------------------------------------------------\r\nvoid FileSetWriter::Details::writeFiles(QXmlStreamWriter& writer,\r\n    QSharedPointer<QList<QSharedPointer<File> > > fileSetFiles, Document::Revision docRevision)\r\n{\r\n    for (QSharedPointer<File> file : *fileSetFiles)\r\n    {\r\n        FileWriter::writeFile(writer, file, docRevision);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileSetWriter::writeDefaultFileBuilders()\r\n//-----------------------------------------------------------------------------\r\nvoid FileSetWriter::Details::writeDefaultFileBuilders(QXmlStreamWriter& writer,\r\n    QSharedPointer<QList<QSharedPointer<FileBuilder> > > defaultFileBuilders,\r\n    Document::Revision docRevision)\r\n{\r\n    for (QSharedPointer<FileBuilder> fileBuilder : *defaultFileBuilders)\r\n    {\r\n        FileBuilderWriter::writeDefaultFileBuilder(writer, fileBuilder, docRevision);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileSetWriter::writeDependencies()\r\n//-----------------------------------------------------------------------------\r\nvoid FileSetWriter::Details::writeDependencies(QXmlStreamWriter& writer, QSharedPointer<QStringList> dependencies)\r\n{\r\n    for (QString const& singleDependency : *dependencies)\r\n    {\r\n        writer.writeTextElement(QStringLiteral(\"ipxact:dependency\"), singleDependency);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileSetWriter::writeFunctions()\r\n//-----------------------------------------------------------------------------\r\nvoid FileSetWriter::Details::writeFunctions(QXmlStreamWriter& writer,\r\n    QSharedPointer<QList<QSharedPointer<Function> > > functions, \r\n    Document::Revision docRevision)\r\n{\r\n    for (QSharedPointer<Function> singleFunction : *functions)\r\n    {\r\n        writer.writeStartElement(QStringLiteral(\"ipxact:function\"));\r\n\r\n        if (singleFunction->getReplicate())\r\n        {\r\n            writer.writeAttribute(QStringLiteral(\"replicate\"), QStringLiteral(\"true\"));\r\n        }\r\n\r\n        writeFunctionEntryPoint(writer, singleFunction);\r\n\r\n        writer.writeTextElement(QStringLiteral(\"ipxact:fileRef\"), singleFunction->getFileRef());\r\n\r\n        writeFunctionReturnType(writer, singleFunction);\r\n\r\n        writeFunctionArguments(writer, singleFunction->getArguments());\r\n\r\n        writeFunctionDisabledValue(writer, singleFunction);\r\n\r\n        writeFunctionSourceFiles(writer, singleFunction->getSourceFiles(), docRevision);\r\n\r\n        writer.writeEndElement(); // ipxact:function\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileSetWriter::writeFunctionEntryPoint()\r\n//-----------------------------------------------------------------------------\r\nvoid FileSetWriter::Details::writeFunctionEntryPoint(QXmlStreamWriter& writer, QSharedPointer<Function> function)\r\n{\r\n    CommonItemsWriter::writeNonEmptyElement(writer, QStringLiteral(\"ipxact:entryPoint\"), function->getEntryPoint());\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileSetWriter::writeReturnType()\r\n//-----------------------------------------------------------------------------\r\nvoid FileSetWriter::Details::writeFunctionReturnType(QXmlStreamWriter& writer, QSharedPointer<Function> function)\r\n{\r\n    CommonItemsWriter::writeNonEmptyElement(writer, QStringLiteral(\"ipxact:returnType\"), function->getReturnType());\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileSetWriter::writeFunctionArguments()\r\n//-----------------------------------------------------------------------------\r\nvoid FileSetWriter::Details::writeFunctionArguments(QXmlStreamWriter& writer,\r\n    QSharedPointer<QList<QSharedPointer<NameValuePair> > > arguments)\r\n{\r\n    for (QSharedPointer<NameValuePair> singleArgument : *arguments)\r\n    {\r\n        writer.writeStartElement(QStringLiteral(\"ipxact:argument\"));\r\n\r\n        NameGroupWriter::writeNameGroup(writer, singleArgument);\r\n\r\n        writer.writeTextElement(QStringLiteral(\"ipxact:value\"), singleArgument->getValue());\r\n\r\n        CommonItemsWriter::writeVendorExtensions(writer, singleArgument);\r\n\r\n        writer.writeEndElement(); // ipxact:argument\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileSetWriter::writeFunctionDisabledValue()\r\n//-----------------------------------------------------------------------------\r\nvoid FileSetWriter::Details::writeFunctionDisabledValue(QXmlStreamWriter& writer, QSharedPointer<Function> function)\r\n{\r\n    CommonItemsWriter::writeNonEmptyElement(writer, QStringLiteral(\"ipxact:disabled\"), function->getDisabled());\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileSetWriter::writeFunctionSourceFiles()\r\n//-----------------------------------------------------------------------------\r\nvoid FileSetWriter::Details::writeFunctionSourceFiles(QXmlStreamWriter& writer,\r\n    QSharedPointer<QList<QSharedPointer<Function::SourceFile> > > sourceFiles,\r\n    Document::Revision docRevision)\r\n{\r\n    for (QSharedPointer<Function::SourceFile> source : *sourceFiles)\r\n    {\r\n        writer.writeStartElement(QStringLiteral(\"ipxact:sourceFile\"));\r\n\r\n        writer.writeTextElement(QStringLiteral(\"ipxact:sourceName\"), source->getSourceName());\r\n\r\n        FileWriter::writeFileType(writer, source->getFileType(), docRevision);\r\n\r\n        writer.writeEndElement(); // ipxact:sourceFile\r\n    }\r\n}\r\n"
  },
  {
    "path": "IPXACTmodels/Component/FileSetWriter.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: FileSetWriter.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 21.09.2015\r\n//\r\n// Description:\r\n// Writer class for IP-XACT fileSet element.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef FILESETWRITER_H\r\n#define FILESETWRITER_H\r\n\r\n#include \"FileSet.h\"\r\n\r\n#include <IPXACTmodels/common/CommonItemsWriter.h>\r\n#include <IPXACTmodels/common/Document.h>\r\n#include <IPXACTmodels/ipxactmodels_global.h>\r\n\r\n#include <QXmlStreamWriter>\r\n#include <QSharedPointer>\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Writer class for IP-XACT fileSet element.\r\n//-----------------------------------------------------------------------------\r\nnamespace FileSetWriter \r\n{\r\n\r\n    /*!\r\n     *  Write a file set to an XML file.\r\n     *\r\n     *    @param [in] writer          The used xml writer.\r\n     *    @param [in] file            The file set to be written.\r\n     *    @param [in] docRevision     The applied IP-XACT standard revision.\r\n     */\r\n    IPXACTMODELS_EXPORT void writeFileSet(QXmlStreamWriter& writer, QSharedPointer<FileSet> fileSet,\r\n        Document::Revision docRevision);\r\n\r\n    namespace Details\r\n    {\r\n\r\n        /*!\r\n         *  Write the file set groups.\r\n         *\r\n         *    @param [in] writer  Used XML writer.\r\n         *    @param [in] groups  The file set groups.\r\n         */\r\n        void writeGroups(QXmlStreamWriter& writer, QSharedPointer<QStringList> groups);\r\n\r\n        /*!\r\n         *  Write the files.\r\n         *\r\n         *    @param [in] writer          Used XML writer.\r\n         *    @param [in] fileSetFiles    The files.\r\n         *    @param [in] docRevision     The applied IP-XACT standard revision.\r\n         */\r\n        void writeFiles(QXmlStreamWriter& writer, QSharedPointer<QList<QSharedPointer<File> > > fileSetFiles,\r\n            Document::Revision docRevision);\r\n\r\n        /*!\r\n         *  Write the default file builders.\r\n         *\r\n         *    @param [in] writer                  Used XML writer.\r\n         *    @param [in] defaultFileBuilders     The default file builders.\r\n         *    @param [in] docRevision             The applied IP-XACT standard revision.\r\n         */\r\n        void writeDefaultFileBuilders(QXmlStreamWriter& writer,\r\n            QSharedPointer<QList<QSharedPointer<FileBuilder> > > defaultFileBuilders,\r\n            Document::Revision docRevision);\r\n\r\n        /*!\r\n         *  Write the dependencies.\r\n         *\r\n         *    @param [in] writer          Used XML writer.\r\n         *    @param [in] dependencies    The dependencies of the file set.\r\n         */\r\n        void writeDependencies(QXmlStreamWriter& writer, QSharedPointer<QStringList> dependencies);\r\n\r\n        /*!\r\n         *  Write the functions.\r\n         *\r\n         *    @param [in] writer          Used XML writer.\r\n         *    @param [in] functions       The functions.\r\n         *    @param [in] docRevision     The applied IP-XACT standard revision.\r\n         */\r\n        void writeFunctions(QXmlStreamWriter& writer, QSharedPointer<QList<QSharedPointer<Function> > > functions,\r\n            Document::Revision docRevision);\r\n\r\n        /*!\r\n         *  Write the function entry point.\r\n         *\r\n         *    @param [in] writer      Used XML writer.\r\n         *    @param [in] function    The selected function.\r\n         */\r\n        void writeFunctionEntryPoint(QXmlStreamWriter& writer, QSharedPointer<Function> function);\r\n\r\n        /*!\r\n         *  Write the function return type.\r\n         *\r\n         *    @param [in] writer      Used XML writer.\r\n         *    @param [in] function    The selected function.\r\n         */\r\n        void writeFunctionReturnType(QXmlStreamWriter& writer, QSharedPointer<Function> function);\r\n\r\n        /*!\r\n         *  Write the function arguments.\r\n         *\r\n         *    @param [in] writer      Used XML writer.\r\n         *    @param [in] arguments   The function arguments.\r\n         */\r\n        void writeFunctionArguments(QXmlStreamWriter& writer,\r\n            QSharedPointer<QList<QSharedPointer<NameValuePair> > > arguments);\r\n\r\n        /*!\r\n         *  Write the function disabled value.\r\n         *\r\n         *    @param [in] writer      Used XML writer.\r\n         *    @param [in] function    The selected function.\r\n         */\r\n        void writeFunctionDisabledValue(QXmlStreamWriter& writer, QSharedPointer<Function> function);\r\n\r\n        /*!\r\n         *  Write the function source files.\r\n         *\r\n         *    @param [in] writer          Used XML writer.\r\n         *    @param [in] function        The selected function.\r\n         *    @param [in] docRevision     The applied IP-XACT standard revision.\r\n         */\r\n        void writeFunctionSourceFiles(QXmlStreamWriter& writer,\r\n            QSharedPointer<QList<QSharedPointer<Function::SourceFile> > > sourceFiles,\r\n            Document::Revision docRevision);\r\n    }\r\n};\r\n\r\n#endif // FILESETWRITER_H"
  },
  {
    "path": "IPXACTmodels/Component/FileWriter.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: FileWriter.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 16.09.2015\r\n//\r\n// Description:\r\n// Writer class for IP-XACT file element.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"FileWriter.h\"\r\n\r\n#include <IPXACTmodels/common/NameGroupWriter.h>\r\n#include <IPXACTmodels/common/CommonItemsWriter.h>\r\n#include <IPXACTmodels/common/FileType.h>\r\n\r\n#include <QMap>\r\n\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileWriter::writeFile()\r\n//-----------------------------------------------------------------------------\r\nvoid FileWriter::writeFile(QXmlStreamWriter& writer, QSharedPointer<File> file, Document::Revision docRevision)\r\n{\r\n    writer.writeStartElement(QStringLiteral(\"ipxact:file\"));\r\n\r\n    Details::writeAttributes(writer, file);\r\n\r\n    writer.writeTextElement(QStringLiteral(\"ipxact:name\"), file->name());\r\n\r\n    if (docRevision == Document::Revision::Std14)\r\n    {\r\n        CommonItemsWriter::writeIsPresent(writer, file->getIsPresent());\r\n    }\r\n\r\n    Details::writeFileTypes(writer, file, docRevision);\r\n\r\n    Details::writeIsStructural(writer, file);\r\n\r\n    Details::writeIsIncludeFile(writer, file);\r\n\r\n    Details::writeLogicalName(writer, file);\r\n\r\n    Details::writeExportedNames(writer, file);\r\n\r\n    Details::writeBuildCommand(writer, file);\r\n\r\n    Details::writeDependencies(writer, file);\r\n\r\n    Details::writeDefines(writer, file);\r\n\r\n    Details::writeImageTypes(writer, file);\r\n\r\n    CommonItemsWriter::writeDescription(writer, file->getDescription());\r\n\r\n    Details::writeFileExtensions(writer, file);\r\n\r\n    writer.writeEndElement(); // ipxact:file\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileWriter::writeFileType()\r\n//-----------------------------------------------------------------------------\r\nvoid FileWriter::writeFileType(QXmlStreamWriter& writer, FileType const& fileType,\r\n    Document::Revision docRevision)\r\n{\r\n    writer.writeStartElement(QStringLiteral(\"ipxact:fileType\"));\r\n\r\n    if (FileTypes::isIpXactFileType(fileType.type_, docRevision))\r\n    {\r\n        if (docRevision == Document::Revision::Std22 && fileType.libext_.isEmpty() == false)\r\n        {\r\n            writer.writeAttribute(QStringLiteral(\"libext\"), fileType.libext_);\r\n        }\r\n\r\n        writer.writeCharacters(fileType.type_);\r\n    }\r\n    else\r\n    {\r\n        writer.writeAttribute(QStringLiteral(\"user\"), fileType.type_);\r\n\r\n        if (docRevision == Document::Revision::Std22 && fileType.libext_.isEmpty() == false)\r\n        {\r\n            writer.writeAttribute(QStringLiteral(\"libext\"), fileType.libext_);\r\n        }\r\n\r\n        writer.writeCharacters(QStringLiteral(\"user\"));\r\n    }\r\n\r\n    writer.writeEndElement(); // ipxact:fileType\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileWriter::writeAttributes()\r\n//-----------------------------------------------------------------------------\r\nvoid FileWriter::Details::writeAttributes(QXmlStreamWriter& writer, QSharedPointer<File> file)\r\n{\r\n    if (!file->getFileId().isEmpty())\r\n    {\r\n        writer.writeAttribute(QStringLiteral(\"fileId\"), file->getFileId());\r\n    }\r\n\r\n    QMapIterator<QString, QString> attributeIterator(file->getAttributes());\r\n\r\n    while (attributeIterator.hasNext())\r\n    {\r\n        attributeIterator.next();\r\n        writer.writeAttribute(attributeIterator.key(), attributeIterator.value());\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileWriter::writeFileType()\r\n//-----------------------------------------------------------------------------\r\nvoid FileWriter::Details::writeFileTypes(QXmlStreamWriter& writer, QSharedPointer<File> file,\r\n    Document::Revision docRevision)\r\n{\r\n    for (auto const& fileType : *file->getFileTypes())\r\n    {\r\n        writeFileType(writer, fileType, docRevision);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileWriter::writeIsStructural()\r\n//-----------------------------------------------------------------------------\r\nvoid FileWriter::Details::writeIsStructural(QXmlStreamWriter& writer, QSharedPointer<File> file)\r\n{\r\n    if (file->isStructural())\r\n    {\r\n        writer.writeTextElement(QStringLiteral(\"ipxact:isStructural\"), QStringLiteral(\"true\"));\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileWriter::writeIsIncludeFile()\r\n//-----------------------------------------------------------------------------\r\nvoid FileWriter::Details::writeIsIncludeFile(QXmlStreamWriter& writer, QSharedPointer<File> file)\r\n{\r\n    if (file->isIncludeFile())\r\n    {\r\n        writer.writeStartElement(QStringLiteral(\"ipxact:isIncludeFile\"));\r\n\r\n        if (file->hasExternalDeclarations())\r\n        {\r\n            writer.writeAttribute(QStringLiteral(\"externalDeclarations\"), QStringLiteral(\"true\"));\r\n        }\r\n\r\n        writer.writeCharacters(QStringLiteral(\"true\"));\r\n\r\n        writer.writeEndElement(); // ipxact:isIncludeFile\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileWriter::writeLogicalName()\r\n//-----------------------------------------------------------------------------\r\nvoid FileWriter::Details::writeLogicalName(QXmlStreamWriter& writer, QSharedPointer<File> file)\r\n{\r\n    if (!file->getLogicalName().isEmpty())\r\n    {\r\n        writer.writeStartElement(QStringLiteral(\"ipxact:logicalName\"));\r\n\r\n        if (file->isLogicalNameDefault())\r\n        {\r\n            writer.writeAttribute(QStringLiteral(\"default\"), QStringLiteral(\"true\"));\r\n        }\r\n\r\n        writer.writeCharacters(file->getLogicalName());\r\n\r\n        writer.writeEndElement(); // ipxact:logicalName\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileWriter::writeExportedNames()\r\n//-----------------------------------------------------------------------------\r\nvoid FileWriter::Details::writeExportedNames(QXmlStreamWriter& writer, QSharedPointer<File> file)\r\n{\r\n    for (QString const& exportedName : *file->getExportedNames())\r\n    {\r\n        writer.writeTextElement(QStringLiteral(\"ipxact:exportedName\"), exportedName);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileWriter::writeBuildCommand()\r\n//-----------------------------------------------------------------------------\r\nvoid FileWriter::Details::writeBuildCommand(QXmlStreamWriter& writer, QSharedPointer<File> file)\r\n{\r\n    if (file->getBuildCommand())\r\n    {\r\n        writer.writeStartElement(QStringLiteral(\"ipxact:buildCommand\"));\r\n\r\n        QSharedPointer<BuildCommand> buildCommand = file->getBuildCommand();\r\n\r\n        CommonItemsWriter::writeNonEmptyElement(writer, QStringLiteral(\"ipxact:command\"), buildCommand->getCommand());\r\n\r\n        if (!buildCommand->getFlags().isEmpty())\r\n        {\r\n            writer.writeStartElement(QStringLiteral(\"ipxact:flags\"));\r\n\r\n            if (!buildCommand->getFlagsAppend().isEmpty())\r\n            {\r\n                writer.writeAttribute(QStringLiteral(\"append\"), buildCommand->getFlagsAppend());\r\n            }\r\n\r\n            writer.writeCharacters(buildCommand->getFlags());\r\n            writer.writeEndElement(); // ipxact:flags\r\n        }\r\n\r\n        CommonItemsWriter::writeNonEmptyElement(writer,\r\n            QStringLiteral(\"ipxact:replaceDefaultFlags\"), buildCommand->getReplaceDefaultFlags());\r\n\r\n        CommonItemsWriter::writeNonEmptyElement(writer,\r\n            QStringLiteral(\"ipxact:targetName\"), buildCommand->getTargetName());\r\n\r\n        writer.writeEndElement(); // ipxact:buildCommand\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileWriter::writeDefines()\r\n//-----------------------------------------------------------------------------\r\nvoid FileWriter::Details::writeDependencies(QXmlStreamWriter& writer, QSharedPointer<File> file)\r\n{\r\n    for (QString const& dependency : *file->getDependencies())\r\n    {\r\n        writer.writeTextElement(QStringLiteral(\"ipxact:dependency\"), dependency);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileWriter::writeDefines()\r\n//-----------------------------------------------------------------------------\r\nvoid FileWriter::Details::writeDefines(QXmlStreamWriter& writer, QSharedPointer<File> file)\r\n{\r\n    if (!file->getDefines()->isEmpty())\r\n    {\r\n        for (QSharedPointer<NameValuePair> define : *file->getDefines())\r\n        {\r\n            writer.writeStartElement(QStringLiteral(\"ipxact:define\"));\r\n\r\n            NameGroupWriter::writeNameGroup(writer, define);\r\n\r\n            writer.writeTextElement(QStringLiteral(\"ipxact:value\"), define->getValue());\r\n\r\n            CommonItemsWriter::writeVendorExtensions(writer, define);\r\n\r\n            writer.writeEndElement(); // ipxact:define\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileWriter::writeImageTypes()\r\n//-----------------------------------------------------------------------------\r\nvoid FileWriter::Details::writeImageTypes(QXmlStreamWriter& writer, QSharedPointer<File> file)\r\n{\r\n    for (QString const& imageType : *file->getImageTypes())\r\n    {\r\n        writer.writeTextElement(QStringLiteral(\"ipxact:imageType\"), imageType);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileWriter::writeFileExtensions()\r\n//-----------------------------------------------------------------------------\r\nvoid FileWriter::Details::writeFileExtensions(QXmlStreamWriter& writer, QSharedPointer<File> file)\r\n{\r\n    CommonItemsWriter::writeVendorExtensions(writer, file);\r\n}"
  },
  {
    "path": "IPXACTmodels/Component/FileWriter.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: FileWriter.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 16.09.2015\r\n//\r\n// Description:\r\n// Writer class for IP-XACT file element.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef FILEWRITER_H\r\n#define FILEWRITER_H\r\n\r\n#include \"File.h\"\r\n\r\n#include <IPXACTmodels/common/CommonItemsWriter.h>\r\n#include <IPXACTmodels/common/Document.h>\r\n#include <IPXACTmodels/ipxactmodels_global.h>\r\n\r\n#include <QXmlStreamWriter>\r\n#include <QObject>\r\n#include <QSharedPointer>\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Writer class for IP-XACT file element.\r\n//-----------------------------------------------------------------------------\r\nnamespace  FileWriter\r\n{\r\n    /*!\r\n     *  Write a file to an XML file.\r\n     *\r\n     *    @param [in] writer          The used xml writer.\r\n     *    @param [in] file            The file to be written.\r\n     *    @param [in] docRevision     The applied IP-XACT standard revision.\r\n     */\r\n    IPXACTMODELS_EXPORT void writeFile(QXmlStreamWriter& writer, QSharedPointer<File> file, Document::Revision docRevision);\r\n \r\n    /*!\r\n     *  Write a file type to an XML file.\r\n     *\r\n     *    @param [in] writer          The used xml writer.\r\n     *    @param [in] fileType        The file type to be written.\r\n     *    @param [in] docRevision     The applied IP-XACT standard revision.\r\n     */\r\n    void writeFileType(QXmlStreamWriter& writer, FileType const& fileType,\r\n        Document::Revision docRevision);\r\n\r\n    namespace Details\r\n    {\r\n        /*!\r\n         *  Write the file types.\r\n         *\r\n         *    @param [in] writer          The used xml writer.\r\n         *    @param [in] file            The file to be written.\r\n         *    @param [in] docRevision     The applied IP-XACT standard revision.\r\n         */\r\n        void writeFileTypes(QXmlStreamWriter& writer, QSharedPointer<File> file, Document::Revision docRevision);\r\n\r\n        /*!\r\n         *  Write the file attributes.\r\n         *\r\n         *    @param [in] writer  The used xml writer.\r\n         *    @param [in] file    The file to be written.\r\n         */\r\n        void writeAttributes(QXmlStreamWriter& writer, QSharedPointer<File> file);\r\n\r\n        /*!\r\n         *  Write the structural status of the file.\r\n         *\r\n         *    @param [in] writer  The used xml writer.\r\n         *    @param [in] file    The file to be written.\r\n         */\r\n        void writeIsStructural(QXmlStreamWriter& writer, QSharedPointer<File> file);\r\n\r\n        /*!\r\n         *  Write the include file status of the value.\r\n         *\r\n         *    @param [in] writer  The used xml writer.\r\n         *    @param [in] file    The file to be written.\r\n         */\r\n        void writeIsIncludeFile(QXmlStreamWriter& writer, QSharedPointer<File> file);\r\n\r\n        /*!\r\n         *  Write the logical name of the file.\r\n         *\r\n         *    @param [in] writer  The used xml writer.\r\n         *    @param [in] file    The file to be written.\r\n         */\r\n        void writeLogicalName(QXmlStreamWriter& writer, QSharedPointer<File> file);\r\n\r\n        /*!\r\n         *  Write the exported names of the file.\r\n         *\r\n         *    @param [in] writer  The used xml writer.\r\n         *    @param [in] file    The file to be written.\r\n         */\r\n        void writeExportedNames(QXmlStreamWriter& writer, QSharedPointer<File> file);\r\n\r\n        /*!\r\n         *  Write the build command of the file.\r\n         *\r\n         *    @param [in] writer  The used xml writer.\r\n         *    @param [in] file    The file to be written.\r\n         */\r\n        void writeBuildCommand(QXmlStreamWriter& writer, QSharedPointer<File> file);\r\n\r\n        /*!\r\n         *  Write the dependencies of the file.\r\n         *\r\n         *    @param [in] writer  The used xml writer.\r\n         *    @param [in] file    The file to be written.\r\n         */\r\n        void writeDependencies(QXmlStreamWriter& writer, QSharedPointer<File> file);\r\n\r\n        /*!\r\n         *  Write the defines of the file.\r\n         *\r\n         *    @param [in] writer  The used xml writer.\r\n         *    @param [in] file    The file to be written.\r\n         */\r\n        void writeDefines(QXmlStreamWriter& writer, QSharedPointer<File> file);\r\n\r\n        /*!\r\n         *  Write the image types of the file.\r\n         *\r\n         *    @param [in] writer  The used xml writer.\r\n         *    @param [in] file    The file to be written.\r\n         */\r\n        void writeImageTypes(QXmlStreamWriter& writer, QSharedPointer<File> file);\r\n\r\n        /*!\r\n         *  Write the file extensions.\r\n         *\r\n         *    @param [in] writer  The used xml writer.\r\n         *    @param [in] file    The file to be written.\r\n         */\r\n        void writeFileExtensions(QXmlStreamWriter& writer, QSharedPointer<File> file);\r\n    }\r\n};\r\n\r\n#endif // FILEWRITER_H"
  },
  {
    "path": "IPXACTmodels/Component/Function.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: Function.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 18.09.2015\r\n//\r\n// Description:\r\n// Describes the ipxact:function element.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"Function.h\"\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Function::SourceFile()\r\n//-----------------------------------------------------------------------------\r\nFunction::SourceFile::SourceFile(QString const& sourceName, QString const& fileType) :\r\nsourceName_(sourceName),\r\nfileType_(fileType)\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Function::SourceFile()\r\n//-----------------------------------------------------------------------------\r\nFunction::SourceFile::SourceFile(const SourceFile& other) :\r\nsourceName_(other.sourceName_),\r\nfileType_(other.fileType_)\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Function::getSourceName()\r\n//-----------------------------------------------------------------------------\r\nQString Function::SourceFile::getSourceName() const\r\n{\r\n    return sourceName_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Function::setSourceName()\r\n//-----------------------------------------------------------------------------\r\nvoid Function::SourceFile::setSourceName(QString const& newSourceName)\r\n{\r\n    sourceName_ = newSourceName;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Function::getFileType()\r\n//-----------------------------------------------------------------------------\r\nFileType Function::SourceFile::getFileType() const\r\n{\r\n    return fileType_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Function::setFileType()\r\n//-----------------------------------------------------------------------------\r\nvoid Function::SourceFile::setFileType(FileType const& newFileType)\r\n{\r\n    fileType_ = newFileType;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Function::Function()\r\n//-----------------------------------------------------------------------------\r\nFunction::Function(QString const& fileReference) :\r\n    fileRef_(fileReference)\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Function::Function()\r\n//-----------------------------------------------------------------------------\r\nFunction::Function(const Function &other):\r\nreplicate_(other.replicate_),\r\nentryPoint_(other.entryPoint_),\r\nfileRef_(other.fileRef_),\r\nreturnType_(other.returnType_),\r\ndisabled_(other.disabled_),\r\ndisabledAttributes_(other.disabledAttributes_)\r\n{\r\n    copyArguments(other);\r\n    copySourceFiles(other);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Function::operator=()\r\n//-----------------------------------------------------------------------------\r\nFunction& Function::operator=(const Function& other)\r\n{\r\n    if (this != &other)\r\n    {\r\n        replicate_ = other.replicate_;\r\n        entryPoint_ = other.entryPoint_;\r\n        fileRef_ = other.fileRef_;\r\n        returnType_ = other.returnType_;\r\n        disabled_ = other.disabled_;\r\n        disabledAttributes_ = other.disabledAttributes_;\r\n\r\n        arguments_->clear();\r\n        copyArguments(other);\r\n\r\n        sourceFiles_->clear();\r\n        copySourceFiles(other);\r\n    }\r\n\r\n    return *this;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Function::~Function()\r\n//-----------------------------------------------------------------------------\r\nFunction::~Function()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Function::getReplicate()\r\n//-----------------------------------------------------------------------------\r\nbool Function::getReplicate() const\r\n{\r\n    return replicate_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Function::setReplicate()\r\n//-----------------------------------------------------------------------------\r\nvoid Function::setReplicate(bool replicate)\r\n{\r\n    replicate_ = replicate;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Function::getEntryPoint()\r\n//-----------------------------------------------------------------------------\r\nQString Function::getEntryPoint() const\r\n{\r\n    return entryPoint_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Function::setEntryPoint()\r\n//-----------------------------------------------------------------------------\r\nvoid Function::setEntryPoint(QString const& entryPoint)\r\n{\r\n    entryPoint_ = entryPoint;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Function::getFileRef()\r\n//-----------------------------------------------------------------------------\r\nQString Function::getFileRef() const\r\n{\r\n    return fileRef_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Function::setFileRef()\r\n//-----------------------------------------------------------------------------\r\nvoid Function::setFileRef(QString const& fileRef)\r\n{\r\n    fileRef_ = fileRef;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Function::getReturnType()\r\n//-----------------------------------------------------------------------------\r\nQString Function::getReturnType() const\r\n{\r\n    return returnType_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Function::setReturnType()\r\n//-----------------------------------------------------------------------------\r\nvoid Function::setReturnType(QString const& returnType)\r\n{\r\n    if (returnType.isEmpty() || returnType == QLatin1String(\"int\") || returnType == QLatin1String(\"void\"))\r\n    {\r\n        returnType_ = returnType;\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Function::getArguments()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<QList<QSharedPointer<NameValuePair> > > Function::getArguments() const\r\n{\r\n    return arguments_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Function::setArguments()\r\n//-----------------------------------------------------------------------------\r\nvoid Function::setArguments(QSharedPointer<QList<QSharedPointer<NameValuePair> > > arguments)\r\n{\r\n    arguments_.clear();\r\n    arguments_ = arguments;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Function::isDisabled()\r\n//-----------------------------------------------------------------------------\r\nQString Function::getDisabled() const\r\n{\r\n    return disabled_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Function::setDisabled()\r\n//-----------------------------------------------------------------------------\r\nvoid Function::setDisabled(QString const& newDisabled)\r\n{\r\n    disabled_ = newDisabled;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Function::getDisabledAttributes()\r\n//-----------------------------------------------------------------------------\r\nQMap<QString, QString> Function::getDisabledAttributes() const\r\n{\r\n    return disabledAttributes_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Function::setDisabledAttributes()\r\n//-----------------------------------------------------------------------------\r\nvoid Function::setDisabledAttributes(QMap<QString, QString> &disabledAttributes)\r\n{\r\n    disabledAttributes_.clear();\r\n    disabledAttributes_ = disabledAttributes;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Function::getSourceFiles()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<QList<QSharedPointer<Function::SourceFile> > > Function::getSourceFiles() const\r\n{\r\n    return sourceFiles_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Function::setSourceFiles()\r\n//-----------------------------------------------------------------------------\r\nvoid Function::setSourceFiles(QSharedPointer<QList<QSharedPointer<Function::SourceFile> > > sourceFiles)\r\n{\r\n    sourceFiles_.clear();\r\n    sourceFiles_ = sourceFiles;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Function::copyArguments()\r\n//-----------------------------------------------------------------------------\r\nvoid Function::copyArguments(const Function& other)\r\n{\r\n    for (QSharedPointer<NameValuePair> argument : *other.arguments_)\r\n    {\r\n        QSharedPointer<NameValuePair> copy = QSharedPointer<NameValuePair>(new NameValuePair(*argument));\r\n        arguments_->append(copy);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Function::copySourceFiles()\r\n//-----------------------------------------------------------------------------\r\nvoid Function::copySourceFiles(const Function& other)\r\n{\r\n    for (QSharedPointer<SourceFile> sourceFile : *other.sourceFiles_)\r\n    {\r\n        QSharedPointer<SourceFile> copy = QSharedPointer<SourceFile>(new SourceFile(*sourceFile));\r\n        sourceFiles_->append(copy);\r\n    }\r\n}\r\n"
  },
  {
    "path": "IPXACTmodels/Component/Function.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: Function.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 18.09.2015\r\n//\r\n// Description:\r\n// Describes the ipxact:function element.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef FUNCTION_H\r\n#define FUNCTION_H\r\n\r\n#include <IPXACTmodels/common/NameValuePair.h>\r\n#include <IPXACTmodels/common/FileType.h>\r\n\r\n#include <IPXACTmodels/ipxactmodels_global.h>\r\n\r\n#include <QString>\r\n#include <QList>\r\n#include <QMap>\r\n#include <QSharedPointer>\r\n#include <QStringList>\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Describes the ipxact:function element.\r\n//-----------------------------------------------------------------------------\r\nclass IPXACTMODELS_EXPORT Function\r\n{\r\n\r\npublic:\r\n\r\n\t/*! \r\n     *  Equals the ipxact:sourceFile element in IP-Xact specification.\r\n\t */\r\n\tstruct SourceFile\r\n    {\r\n\t\t//! Contains absolute or relative path to a file name or directory\r\n\t\tQString sourceName_;\r\n\r\n\t\t//! Specifies the file type known by IP-Xact.\r\n\t\tFileType fileType_;\r\n\t\t\r\n\t\t/*!\r\n\t\t *  The constructor.\r\n\t\t *\r\n\t\t *    @param [in] sourceName  The name of the source file.\r\n\t\t *    @param [in] fileType    The file type.\r\n\t\t */\r\n\t\tIPXACTMODELS_EXPORT SourceFile(QString const& sourceName = QString(), QString const& fileType = QString());\r\n\r\n        //! Copy constructor.\r\n        SourceFile(const SourceFile& other);\r\n\r\n        /*!\r\n         *  Gets the source name.\r\n         *\r\n         *    @return The name of the source.\r\n         */\r\n\t\tIPXACTMODELS_EXPORT QString getSourceName() const;\r\n\r\n        /*!\r\n         *  Set the source name.\r\n         *\r\n         *    @param [in] newSourceName   The new name for the source.\r\n         */\r\n\t\tIPXACTMODELS_EXPORT void setSourceName(QString const& newSourceName);\r\n\r\n        /*!\r\n         *  Get the file type of the source.\r\n         *\r\n         *    @return The source file type.\r\n         */\r\n\t\tIPXACTMODELS_EXPORT FileType getFileType() const;\r\n\r\n        /*!\r\n         *  Set the file type for the source.\r\n         *\r\n         *    @param [in] newFileType     The new source file type.\r\n         */\r\n\t\tIPXACTMODELS_EXPORT void setFileType(FileType const& newFileType);\r\n\t};\r\n\r\n    /*!\r\n     *  The constructor.\r\n     *\r\n     *    @param [in] fileReference   The referenced file.\r\n     */\r\n    Function(QString const& fileReference = QString());\r\n\r\n\t// Copy constructor\r\n\t Function(const Function &other);\r\n\r\n\t// Assignment operator\r\n\t Function& operator=(const Function& other);\r\n\r\n\t/*!\r\n     *  The destructor.\r\n\t */\r\n\t~Function();\r\n\r\n\t/*! \r\n     *  Get the value of the replicate-attribute.\r\n\t *\r\n\t *    @return True for a replicated function, false otherwise.\r\n\t */\r\n\tbool getReplicate() const;\r\n    \r\n\t/*! \r\n     *  Set the replicate value.\r\n\t *\r\n\t *    @param [in] replicate   The new replicate value.\r\n\t */\r\n\tvoid setReplicate(bool replicate);\r\n    \r\n\t/*! \r\n     *  Get entry point of the function.\r\n\t *\r\n\t *    @return     The entry point.\r\n\t */\r\n\tQString getEntryPoint() const;\r\n    \r\n\t/*!\r\n     *  Set the entry point for the function.\r\n\t *\r\n\t *    @param [in] entryPoint  The new entry point.\r\n\t */\r\n\tvoid setEntryPoint(QString const& entryPoint);\r\n    \r\n\t/*!\r\n     *  Get the file reference.\r\n\t *\r\n\t *    @return The file reference.\r\n\t */\r\n\tQString getFileRef() const;\r\n    \r\n\t/*! \r\n     *  Set the file reference.\r\n\t *\r\n\t *    @param [in] fileRef     The reference to the new file.\r\n\t */\r\n\tvoid setFileRef(QString const& fileRef);\r\n    \r\n\t/*!\r\n     *  Get the return type of the function.\r\n\t *\r\n\t *    @return The return type.\r\n\t */\r\n\tQString getReturnType() const;\r\n    \r\n\t/*!\r\n     *  Set the return type of the function.\r\n\t *\r\n\t *    @param [in] returnType  The new return type. Only void and int are appected.\r\n\t */\r\n\tvoid setReturnType(QString const& returnType);\r\n\r\n\t/*! \r\n     *  Get the list of function arguments.\r\n\t *\r\n\t *    @return Pointer to a list containing the arguments.\r\n\t */\r\n    QSharedPointer<QList<QSharedPointer<NameValuePair> > > getArguments() const;\r\n    \r\n\t/*!\r\n     *  Set arguments for the function.\r\n\t *\r\n\t *    @param [in] arguments   Pointer to a list containing the new arguments.\r\n\t */\r\n\tvoid setArguments(QSharedPointer<QList<QSharedPointer<NameValuePair> > > arguments);\r\n\r\n\t/*!\r\n     *  Get the disabled value\r\n\t *\r\n\t *    @return The expression for the disabled value.\r\n\t */\r\n\tQString getDisabled() const;\r\n\r\n\t/*! \r\n     *  Set the disabled value\r\n\t *\r\n\t *    @param [in] disabled    The new disabled value.\r\n\t */\r\n\tvoid setDisabled(QString const& newDisabled);\r\n    \r\n\t/*!\r\n     *  Get the attributes of the disabled-element.\r\n\t *\r\n\t *    @return QMap containing the attributes for disabled value.\r\n\t */\r\n\tQMap<QString, QString> getDisabledAttributes() const;\r\n\r\n\t/*! \r\n     *  Set the attributes for the disabled-element.\r\n\t *\r\n\t *    @param [in] disabledAttributes  The new attributes for the disabled value.\r\n\t */\r\n\tvoid setDisabledAttributes(QMap<QString, QString>& disabledAttributes);\r\n\r\n\t/*!\r\n     *  Get list of the source files for the function.\r\n\t *\r\n\t *    @return Pointer to a list containing the source files.\r\n\t */\r\n    QSharedPointer<QList<QSharedPointer<SourceFile> > > getSourceFiles() const;\r\n\r\n\t/*! \r\n     *  Set the source files for the function.\r\n\t *\r\n\t *    @param [in] sourceFiles     Pointer to a list containing the new source files.\r\n\t */\r\n    void setSourceFiles(QSharedPointer<QList<QSharedPointer<SourceFile> > > newSourceFiles);\r\n\r\nprivate:\r\n\r\n    /*!\r\n     *  Copy the arguments of a function.\r\n     *\r\n     *    @param [in] other   The function being copied.\r\n     */\r\n    void copyArguments(const Function& other);\r\n\r\n    /*!\r\n     *  Copy the source files of a function.\r\n     *\r\n     *    @param [in] other   The function being copied.\r\n     */\r\n    void copySourceFiles(const Function& other);\r\n\r\n\t //! When true, the generator compiles a separate object module for each instance of the component.\r\n\t bool replicate_ = false;\r\n\r\n\t //! The entry point name for the function or subroutine.\r\n\t QString entryPoint_;\r\n\r\n\t //! Reference to the file that contains the entry point for the function.\r\n\t QString fileRef_;\r\n\r\n\t //! Indicates the return type of the function.\r\n\t QString returnType_;\r\n\r\n\t //! Contains arguments passed when this function is called.\r\n     QSharedPointer<QList<QSharedPointer<NameValuePair> > > arguments_ =\r\n\t\t QSharedPointer<QList<QSharedPointer<NameValuePair> > >(new QList<QSharedPointer<NameValuePair> >);\r\n\r\n\t //! Holds whether the software function is disabled or not.\r\n     QString disabled_;\r\n\r\n\t //! Contains attributes for the disabled element.\r\n\t QMap<QString, QString> disabledAttributes_;\r\n\r\n\t //!  References any source files. The order of the source files must be maintained.\r\n\t QSharedPointer<QList<QSharedPointer<SourceFile> > > sourceFiles_ =\r\n\t\t QSharedPointer<QList<QSharedPointer<SourceFile> > >(new QList<QSharedPointer<SourceFile> >);\r\n};\r\n\r\n#endif // FUNCTION_H\r\n"
  },
  {
    "path": "IPXACTmodels/Component/IndirectInterface.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: IndirectInterface.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Esko Pekkarinen\n// Date: 02.08.2017\n//\n// Description:\n// Implementation of the ipxact:indirectInterface element.\n//-----------------------------------------------------------------------------\n\n#include \"IndirectInterface.h\"\n\n#include <IPXACTmodels/Component/TransparentBridge.h>\n\n//-----------------------------------------------------------------------------\n// Function: IndirectInterface::IndirectInterface()\n//-----------------------------------------------------------------------------\nIndirectInterface::IndirectInterface(QString const& name) : NameGroup(name), \n    Extendable(),\n    indirectAddressRef_(), \n    indirectDataRef_(),\n    memoryMapRef_(),\n    transparentBridges_(new QList<QSharedPointer<TransparentBridge> >()),\n    bitsInLau_(),\n    endianness_(),\n    parameters_(new QList<QSharedPointer<Parameter> >())\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: IndirectInterface::IndirectInterface()\n//-----------------------------------------------------------------------------\nIndirectInterface::IndirectInterface(IndirectInterface const& other):\nNameGroup(other),\n    Extendable(other),\n    indirectAddressRef_(other.indirectAddressRef_), \n    indirectDataRef_(other.indirectDataRef_),\n    memoryMapRef_(other.memoryMapRef_),\n    transparentBridges_(new QList<QSharedPointer<TransparentBridge> >()),\n    bitsInLau_(other.bitsInLau_),\n    endianness_(other.endianness_),\n    parameters_(new QList<QSharedPointer<Parameter> >())\n{\n    foreach (QSharedPointer<TransparentBridge> bridge, *other.getTransparentBridges())\n    {\n        transparentBridges_->append(QSharedPointer<TransparentBridge>(new TransparentBridge(*bridge.data())));\n    }\n\n    foreach (QSharedPointer<Parameter> parameter, *other.getParameters())\n    {\n        parameters_->append(QSharedPointer<Parameter>(new Parameter(*parameter.data())));\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: IndirectInterface::getAttributes()\n//-----------------------------------------------------------------------------\nQMap<QString, QString> IndirectInterface::getAttributes() const\n{\n    return attributes_;\n}\n\n//-----------------------------------------------------------------------------\n// Function: IndirectInterface::setAttributes()\n//-----------------------------------------------------------------------------\nvoid IndirectInterface::setAttributes(QMap<QString, QString> const& attributes)\n{\n    attributes_ = attributes;\n}\n\n//-----------------------------------------------------------------------------\n// Function: IndirectInterface::setIndirectAddressRef()\n//-----------------------------------------------------------------------------\nvoid IndirectInterface::setIndirectAddressRef(QString const& addressFieldId)\n{\n    indirectAddressRef_ = addressFieldId;\n}\n\n//-----------------------------------------------------------------------------\n// Function: IndirectInterface::getIndirectAddressRef()\n//-----------------------------------------------------------------------------\nQString IndirectInterface::getIndirectAddressRef() const\n{\n    return indirectAddressRef_;\n}\n\n//-----------------------------------------------------------------------------\n// Function: IndirectInterface::setIndirectDataRef()\n//-----------------------------------------------------------------------------\nvoid IndirectInterface::setIndirectDataRef(QString const& dataFieldId)\n{\n    indirectDataRef_ = dataFieldId;\n}\n\n//-----------------------------------------------------------------------------\n// Function: IndirectInterface::getIndirectDataRef()\n//-----------------------------------------------------------------------------\nQString IndirectInterface::getIndirectDataRef() const\n{\n    return indirectDataRef_;\n}\n\n//-----------------------------------------------------------------------------\n// Function: IndirectInterface::setMemoryMapRef()\n//-----------------------------------------------------------------------------\nvoid IndirectInterface::setMemoryMapRef(QString const& memoryMapName)\n{\n    memoryMapRef_ = memoryMapName;\n}\n\n//-----------------------------------------------------------------------------\n// Function: IndirectInterface::getMemoryMapRef()\n//-----------------------------------------------------------------------------\nQString IndirectInterface::getMemoryMapRef() const\n{\n    return memoryMapRef_;\n}\n\n//-----------------------------------------------------------------------------\n// Function: IndirectInterface::getTransparentBridges()\n//-----------------------------------------------------------------------------\nQSharedPointer<QList<QSharedPointer<TransparentBridge> > > IndirectInterface::getTransparentBridges() const\n{\n    return transparentBridges_;\n}\n\n//-----------------------------------------------------------------------------\n// Function: IndirectInterface::getBitsInLau()\n//-----------------------------------------------------------------------------\nvoid IndirectInterface::setBitsInLau(QString const& bitsInLau) \n{\n    bitsInLau_ = bitsInLau;\n}\n\n//-----------------------------------------------------------------------------\n// Function: IndirectInterface::getBitsInLau()\n//-----------------------------------------------------------------------------\nQString IndirectInterface::getBitsInLau() const\n{\n    return bitsInLau_;\n}\n\n//-----------------------------------------------------------------------------\n// Function: IndirectInterface::setEndianess()\n//-----------------------------------------------------------------------------\nvoid IndirectInterface::setEndianness(QString const& endianness)\n{\n    endianness_ = endianness;\n}\n\n//-----------------------------------------------------------------------------\n// Function: IndirectInterface::getEndianess()\n//-----------------------------------------------------------------------------\nQString IndirectInterface::getEndianness() const\n{\n    return endianness_;\n}\n\n//-----------------------------------------------------------------------------\n// Function: IndirectInterface::getParameters()\n//-----------------------------------------------------------------------------\nQSharedPointer<QList<QSharedPointer<Parameter> > > IndirectInterface::getParameters() const\n{\n    return parameters_;\n}"
  },
  {
    "path": "IPXACTmodels/Component/IndirectInterface.h",
    "content": "//-----------------------------------------------------------------------------\n// File: IndirectInterface.h\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Esko Pekkarinen\n// Date: 02.08.2017\n//\n// Description:\n// Implementation of the ipxact:indirectInterface element.\n//-----------------------------------------------------------------------------\n\n#ifndef INDIRECTINTERFACE_H\n#define INDIRECTINTERFACE_H\n\n#include <IPXACTmodels/common/Extendable.h>\n#include <IPXACTmodels/common/NameGroup.h>\n#include <IPXACTmodels/common/Parameter.h>\n\n#include <QSharedPointer>\n#include <QVector>\n\nclass TransparentBridge;\n\n//-----------------------------------------------------------------------------\n//! Implementation of the ipxact:indirectInterface element.\n//-----------------------------------------------------------------------------\nclass IPXACTMODELS_EXPORT IndirectInterface : public NameGroup, public Extendable\n{\npublic:\n\n\t//! The constructor.\n\tIndirectInterface(QString const& name = QString());\n\n    //! Copy constructor.\n    IndirectInterface(IndirectInterface const& other);\n\n    // Disable assignment.\n    IndirectInterface& operator=(IndirectInterface const& rhs) = delete;\n\n\t//! The destructor.\n\tvirtual ~IndirectInterface() = default;\n\n\t/*!\n     *  Get the attributes of the indirect interface.\n\t *\n\t *    @return The attributes.\n \t */\n\tQMap<QString, QString> getAttributes() const;\n\n\t/*!\n     *  Set the attributes for the indirect interface.\n\t * \n\t *    @param [in] attributes  The attributes to set.\n\t */\n\tvoid setAttributes(QMap<QString, QString> const& attributes);\n\n    /*!\n     *  Sets the reference for the indirect access address field.\n     *\n     *    @param [in] addressFieldId      The id for the address field.     \n     */\n    void setIndirectAddressRef(QString const& addressFieldId);\n\n    /*!\n     *  Gets the reference for the indirect access address field.\n     *\n     *    @return The indirect address field id.\n     */\n    QString getIndirectAddressRef() const;\n\n    /*!\n     *  Sets the reference for the indirect access data field.\n     *\n     *    @param [in] dataFieldId         The id for the data field.     \n     */    \n    void setIndirectDataRef(QString const& dataFieldId);\n    \n    /*!\n     *  Gets the reference for the indirect access data field.\n     *\n     *    @return The indirect data field id.\n     */  \n    QString getIndirectDataRef() const;\n    \n    /*!\n     *  Sets the indirectly accessible memory map.\n     *\n     *    @param [in] memoryMapName   The name of the accessible memory map.\n     */\n    void setMemoryMapRef(QString const& memoryMapName);\n    \n    /*!\n     *  Gets the indirectly accessible memory map.\n     *\n     *    @return The name of the indirectly accessible memory map.\n     */\n    QString getMemoryMapRef() const;\n\n   /*!\n     *  Gets the transparent bridges in the indirect interface.\n     *\n     *    @return The transparent bridges.\n     */\n    QSharedPointer<QList<QSharedPointer<TransparentBridge> > > getTransparentBridges() const;\n\n    /*!\n     *  Sets the number of bits in the least addressable unit.\n     *\n     *    @param [in] bitsInLau   The number of bits to set.\n     */\n    void setBitsInLau(QString const& bitsInLau);\n\n    /*!\n     *  Gets the number of bits in the least addressable unit.\n     *\n     *    @return   The number of bits in the least addressable unit.\n     */\n    QString getBitsInLau() const;\n\n    /*!\n     *  Sets the endianness (little/big) for the indirect interface.\n     *\n     *    @param [in] endianness   The endianness to set.\n     */\n    void setEndianness(QString const& endianness);\n\n    /*!\n     *  Gets the endianness (little/big) for the indirect interface.\n     *\n     *    @return The endianness of the indirect interface.\n     */\n    QString getEndianness() const;\n\n    /*!\n     *  Gets the parameters in the indirect interface.\n     *\n     *    @return The parameters of the indirect interface.\n     */\n    QSharedPointer<QList<QSharedPointer<Parameter> > > getParameters() const;\n\nprivate:\n\n    //-----------------------------------------------------------------------------\n    // Data.\n    //-----------------------------------------------------------------------------\n\n    //! Contains the attributes for the indirect interface.\n    QMap<QString, QString> attributes_;\n\n    //! Reference to the indirect address field.\n    QString indirectAddressRef_;\n\n    //! Reference to the indirect data field.\n    QString indirectDataRef_;\n\n    //! Reference to the indirectly accessible memory map.\n    QString memoryMapRef_;\n\n    //! The indirect transparent bridges.\n    QSharedPointer<QList<QSharedPointer<TransparentBridge> > > transparentBridges_;\n\n    //! The number of bits in least addressable unit.\n    QString bitsInLau_;\n\n    //! The endianness of the indirect interface.\n    QString endianness_;\n\n    //! Parameters of the indirect interface.\n    QSharedPointer<QList<QSharedPointer<Parameter> > > parameters_;\n};\n\n#endif // INDIRECTINTERFACE_H\n"
  },
  {
    "path": "IPXACTmodels/Component/IndirectInterfaceReader.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: IndirectInterfaceReader.h\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Esko Pekkarinen\n// Date: 02.08.2017\n//\n// Description:\n// XML reader class for IP-XACT Indirect Interface element.\n//-----------------------------------------------------------------------------\n\n#include \"IndirectInterfaceReader.h\"\n#include \"IndirectInterface.h\"\n\n#include <IPXACTmodels/common/NameGroupReader.h>\n#include <IPXACTmodels/Component/TransparentBridge.h>\n\n//-----------------------------------------------------------------------------\n// Function: IndirectInterfaceReader::createIndirectInterfaceFrom()\n//-----------------------------------------------------------------------------\nQSharedPointer<IndirectInterface> IndirectInterfaceReader::createIndirectInterfaceFrom(QDomNode const& interfaceNode,\n    Document::Revision docRevision)\n{\n    QSharedPointer<IndirectInterface> newIndirectInterface(new IndirectInterface());\n\n    Details::parseAttributes(interfaceNode, newIndirectInterface);\n\n    NameGroupReader::parseNameGroup(interfaceNode, newIndirectInterface);\n\n    Details::parseIndirectAddressAndData(interfaceNode, newIndirectInterface);\n\n    Details::parseMemoryMapRef(interfaceNode, newIndirectInterface);\n\n    Details::parseTransparentBridges(interfaceNode, newIndirectInterface, docRevision);\n\n    Details::parseBitsInLau(interfaceNode, newIndirectInterface);\n\n    Details::parseEndianness(interfaceNode, newIndirectInterface);\n\n    Details::parseParameters(interfaceNode, newIndirectInterface, docRevision);\n\n    CommonItemsReader::parseVendorExtensions(interfaceNode, newIndirectInterface);\n\n    return newIndirectInterface;\n}\n\n//-----------------------------------------------------------------------------\n// Function: IndirectInterfaceReader::parseAttributes()\n//-----------------------------------------------------------------------------\nvoid IndirectInterfaceReader::Details::parseAttributes(QDomNode const& interfaceNode,\n    QSharedPointer<IndirectInterface> indirectInterface)\n{\n    QMap<QString, QString> attributes;\n\n    QDomNamedNodeMap attributeMap = interfaceNode.attributes();\n    for (int i = 0; i < attributeMap.size(); ++i)\n    {\n        QString name = attributeMap.item(i).nodeName();\n        QString value = attributeMap.item(i).nodeValue();\n        attributes.insert(name, value);\n    }\n\n    indirectInterface->setAttributes(attributes);\n}\n\n//-----------------------------------------------------------------------------\n// Function: IndirectInterfaceReader::parseIndirectAddressAndData()\n//-----------------------------------------------------------------------------\nvoid IndirectInterfaceReader::Details::parseIndirectAddressAndData(QDomNode const& interfaceNode,\n    QSharedPointer<IndirectInterface> indirectInterface)\n{\n    QString indirectAddress = \n        interfaceNode.firstChildElement(QStringLiteral(\"ipxact:indirectAddressRef\")).firstChild().nodeValue();\n\n    QString indirectData = \n        interfaceNode.firstChildElement(QStringLiteral(\"ipxact:indirectDataRef\")).firstChild().nodeValue();\n\n    indirectInterface->setIndirectAddressRef(indirectAddress);\n    indirectInterface->setIndirectDataRef(indirectData);\n}\n\n//-----------------------------------------------------------------------------\n// Function: IndirectInterfaceReader::parseMemoryMapRef()\n//-----------------------------------------------------------------------------\nvoid IndirectInterfaceReader::Details::parseMemoryMapRef(QDomNode const& interfaceNode,\n    QSharedPointer<IndirectInterface> indirectInterface)\n{\n    QString memoryMapRef = \n        interfaceNode.firstChildElement(QStringLiteral(\"ipxact:memoryMapRef\")).firstChild().nodeValue();\n\n    indirectInterface->setMemoryMapRef(memoryMapRef);\n}\n\n//-----------------------------------------------------------------------------\n// Function: IndirectInterfaceReader::parseTransparentBridges()\n//-----------------------------------------------------------------------------\nvoid IndirectInterfaceReader::Details::parseTransparentBridges(QDomNode const& interfaceNode,\n    QSharedPointer<IndirectInterface> indirectInterface, Document::Revision docRevision)\n{\n    QDomNodeList bridgeNodes = \n        interfaceNode.toElement().elementsByTagName(QStringLiteral(\"ipxact:transparentBridge\"));\n\n    int bridgeCount = bridgeNodes.count();\n    for (int i = 0; i < bridgeCount; i++)\n    {\n        QDomElement bridgeNode = bridgeNodes.at(i).toElement();\n\n        QString initiatorReference;\n        if (docRevision == Document::Revision::Std14)\n        {\n            initiatorReference = bridgeNode.attributes().namedItem(QStringLiteral(\"masterRef\")).firstChild().nodeValue();\n        }\n        else if (docRevision == Document::Revision::Std22)\n        {\n            initiatorReference = bridgeNode.attributes().namedItem(QStringLiteral(\"initiatorRef\")).firstChild().nodeValue();\n        }\n\n        QSharedPointer<TransparentBridge> newBridge(new TransparentBridge(initiatorReference));\n\n        if (docRevision == Document::Revision::Std14)\n        {\n            QString isPresent = bridgeNode.firstChildElement(QStringLiteral(\"ipxact:isPresent\")).firstChild().nodeValue();\n            newBridge->setIsPresent(isPresent);\n        }\n        \n        if (docRevision == Document::Revision::Std22)\n        {\n            CommonItemsReader::parseVendorExtensions(bridgeNode, newBridge);\n        }\n\n        indirectInterface->getTransparentBridges()->append(newBridge);\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: IndirectInterfaceReader::parseEndianness()\n//-----------------------------------------------------------------------------\nvoid IndirectInterfaceReader::Details::parseEndianness(QDomNode const& interfaceNode,\n    QSharedPointer<IndirectInterface> indirectInterface)\n{\n    QString endianness = \n        interfaceNode.firstChildElement(QStringLiteral(\"ipxact:endianness\")).firstChild().nodeValue();\n\n    indirectInterface->setEndianness(endianness);\n}\n\n//-----------------------------------------------------------------------------\n// Function: IndirectInterfaceReader::parseBitsInLau()\n//-----------------------------------------------------------------------------\nvoid IndirectInterfaceReader::Details::parseBitsInLau(QDomNode const& interfaceNode,\n    QSharedPointer<IndirectInterface> indirectInterface)\n{\n    QDomElement lauElement = interfaceNode.firstChildElement(QStringLiteral(\"ipxact:bitsInLau\"));\n\n    QString bitsInLau = lauElement.firstChild().nodeValue();\n    indirectInterface->setBitsInLau(bitsInLau);\n}\n\n//-----------------------------------------------------------------------------\n// Function: IndirectInterfaceReader::parseParameters()\n//-----------------------------------------------------------------------------\nvoid IndirectInterfaceReader::Details::parseParameters(QDomNode const& interfaceNode,\n    QSharedPointer<IndirectInterface> indirectInterface, Document::Revision docRevision) \n{\n    indirectInterface->getParameters()->append(\n        *CommonItemsReader::parseAndCreateParameters(interfaceNode, docRevision));\n}\n"
  },
  {
    "path": "IPXACTmodels/Component/IndirectInterfaceReader.h",
    "content": "//-----------------------------------------------------------------------------\n// File: IndirectInterfaceReader.h\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Esko Pekkarinen\n// Date: 02.08.2017\n//\n// Description:\n// XML reader class for IP-XACT Indirect Interface element.\n//-----------------------------------------------------------------------------\n\n#ifndef INDIRECTINTERFACEREADER_H\n#define INDIRECTINTERFACEREADER_H\n\n#include <QSharedPointer>\n#include <QDomNode>\n\n#include <IPXACTmodels/common/CommonItemsReader.h>\n\n#include <IPXACTmodels/ipxactmodels_global.h>\n\nclass IndirectInterface;\n\nnamespace  IndirectInterfaceReader\n{\n    /*!\n     *  Creates an indirect interface definition from an XML description.\n     *\n     *    @param [in] interfaceNode   The XML node describing the interface.\n     *\n     *    @return The created indirect interface.\n     */\n    IPXACTMODELS_EXPORT QSharedPointer<IndirectInterface> createIndirectInterfaceFrom(QDomNode const& interfaceNode,\n        Document::Revision docRevision);\n    \n    namespace Details\n    {\n        /*!\n          *  Reads the attributes from XML to an indirect interface.\n          *\n          *    @param [in] interfaceNode           The XML description of the indirect interface.\n          *    @param [in/out] indirectInterface   The indirect interface to insert the attributes into.\n          */\n        void parseAttributes(QDomNode const& interfaceNode, QSharedPointer<IndirectInterface> indirectInterface);\n\n        /*!\n          *  Reads the indirect address and data from XML to an indirect interface.\n          *\n          *    @param [in] interfaceNode           The XML description of the indirect interface.\n          *    @param [in/out] indirectInterface   The indirect interface to insert the address and data into.\n          */\n        void parseIndirectAddressAndData(QDomNode const& interfaceNode,\n            QSharedPointer<IndirectInterface> indirectInterface);\n\n        /*!\n          *  Reads the memory map reference from XML to an indirect interface.\n          *\n          *    @param [in] interfaceNode           The XML description of the indirect interface.\n          *    @param [in/out] indirectInterface   The indirect interface to insert the memory map reference into.\n          */\n        void parseMemoryMapRef(QDomNode const& interfaceNode, QSharedPointer<IndirectInterface> indirectInterface);\n\n        /*!\n          *  Reads the transparent bridges from XML to an indirect interface.\n          *\n          *    @param [in] interfaceNode           The XML description of the indirect interface.\n          *    @param [in/out] indirectInterface   The indirect interface to insert the transparent bridges into.\n          */\n        void parseTransparentBridges(QDomNode const& interfaceNode,\n            QSharedPointer<IndirectInterface> indirectInterface, Document::Revision docRevision);\n\n        /*!\n          *  Reads the endianness from XML to an indirect interface.\n          *\n          *    @param [in] interfaceNode           The XML description of the indirect interface.\n          *    @param [in/out] indirectInterface   The indirect interface to insert the endianness into.\n          */\n        void parseEndianness(QDomNode const& interfaceNode, QSharedPointer<IndirectInterface> indirectInterface);\n\n        /*!\n          *  Reads the bits in lau element from XML to an indirect interface.\n          *\n          *    @param [in] interfaceNode           The XML description of the indirect interface.\n          *    @param [in/out] indirectInterface   The indirect interface to insert the bits in lau info into.\n          */\n        void parseBitsInLau(QDomNode const& interfaceNode, QSharedPointer<IndirectInterface> indirectInterface);\n\n        /*!\n          *  Reads the parameters from XML to an indirect interface.\n          *\n          *    @param [in] interfaceNode           The XML description of the indirect interface.\n          *    @param [in/out] indirectInterface   The indirect interface to insert the parameters into.\n          */\n        void parseParameters(QDomNode const& interfaceNode, QSharedPointer<IndirectInterface> indirectInterface,\n            Document::Revision docRevision);\n    }\n};\n\n#endif // INDIRECTINTERFACEREADER_H\n"
  },
  {
    "path": "IPXACTmodels/Component/IndirectInterfaceWriter.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: IndirectInterfaceWriter.h\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Esko Pekkarinen\n// Date: 07.08.2017\n//\n// Description:\n// XML writer class for IP-XACT Indirect Interface element.\n//-----------------------------------------------------------------------------\n\n#include \"IndirectInterfaceWriter.h\"\n#include \"IndirectInterface.h\"\n\n#include <IPXACTmodels/common/NameGroupWriter.h>\n#include <IPXACTmodels/Component/TransparentBridge.h>\n\n//-----------------------------------------------------------------------------\n// Function: IndirectInterfaceWriter::writeIndirectInterface()\n//-----------------------------------------------------------------------------\nvoid IndirectInterfaceWriter::writeIndirectInterface(QXmlStreamWriter& writer,\n    QSharedPointer<IndirectInterface> indirectInterface, Document::Revision docRevision)\n{\n    writer.writeStartElement(QStringLiteral(\"ipxact:indirectInterface\"));\n\n    NameGroupWriter::writeNameGroup(writer, indirectInterface);\n\n    Details::writeIndirectFields(writer, indirectInterface);\n\n    CommonItemsWriter::writeNonEmptyElement(writer, QStringLiteral(\"ipxact:memoryMapRef\"), indirectInterface->getMemoryMapRef());\n\n    Details::writeTransparentBridges(writer, indirectInterface, docRevision);\n\n    CommonItemsWriter::writeNonEmptyElement(writer, QStringLiteral(\"ipxact:bitsInLau\"), indirectInterface->getBitsInLau());\n\n    CommonItemsWriter::writeNonEmptyElement(writer, QStringLiteral(\"ipxact:endianness\"), indirectInterface->getEndianness());\n\n    CommonItemsWriter::writeParameters(writer, indirectInterface->getParameters());\n\n    CommonItemsWriter::writeVendorExtensions(writer, indirectInterface);\n\n    writer.writeEndElement();\n}\n\n//-----------------------------------------------------------------------------\n// Function: IndirectInterfaceWriter::writeIndirectFields()\n//-----------------------------------------------------------------------------\nvoid IndirectInterfaceWriter::Details::writeIndirectFields(QXmlStreamWriter& writer,\n    QSharedPointer<IndirectInterface> indirectInterface)\n{\n    writer.writeStartElement(QStringLiteral(\"ipxact:indirectAddressRef\"));\n    writer.writeCharacters(indirectInterface->getIndirectAddressRef());\n    writer.writeEndElement();\n\n    writer.writeStartElement(QStringLiteral(\"ipxact:indirectDataRef\"));\n    writer.writeCharacters(indirectInterface->getIndirectDataRef());\n    writer.writeEndElement();\n}\n\n//-----------------------------------------------------------------------------\n// Function: IndirectInterfaceWriter::writeTransparentBridges()\n//-----------------------------------------------------------------------------\nvoid IndirectInterfaceWriter::Details::writeTransparentBridges(QXmlStreamWriter& writer,\n    QSharedPointer<IndirectInterface> indirectInterface, Document::Revision docRevision)\n{    \n    for (QSharedPointer<TransparentBridge> bridge : *indirectInterface->getTransparentBridges())\n    {\n        writer.writeStartElement(QStringLiteral(\"ipxact:transparentBridge\"));\n\n        QString referenceName;\n        if (docRevision == Document::Revision::Std14)\n        {\n            referenceName = QStringLiteral(\"masterRef\");\n        }\n        else if (docRevision == Document::Revision::Std22)\n        {\n            referenceName = QStringLiteral(\"initiatorRef\");\n        }\n\n        writer.writeAttribute(referenceName, bridge->getInitiatorRef());\n\n        if (docRevision == Document::Revision::Std14)\n        {\n            CommonItemsWriter::writeIsPresent(writer, bridge->getIsPresent());\n        }\n\n        if (docRevision == Document::Revision::Std22)\n        {\n            CommonItemsWriter::writeVendorExtensions(writer, bridge);\n        }\n\n        writer.writeEndElement();\n    }\n}\n"
  },
  {
    "path": "IPXACTmodels/Component/IndirectInterfaceWriter.h",
    "content": "//-----------------------------------------------------------------------------\n// File: IndirectInterfaceWriter.h\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Esko Pekkarinen\n// Date: 07.08.2017\n//\n// Description:\n// XML writer class for IP-XACT Indirect Interface element.\n//-----------------------------------------------------------------------------\n\n#ifndef INDIRECTINTERFACEWriter_H\n#define INDIRECTINTERFACEWriter_H\n\n#include <QSharedPointer>\n#include <QDomNode>\n\n#include <IPXACTmodels/common/CommonItemsWriter.h>\n#include <IPXACTmodels/common/Document.h>\n\n#include <IPXACTmodels/ipxactmodels_global.h>\n\nclass IndirectInterface;\n\n//-----------------------------------------------------------------------------\n//! XML writer class for IP-XACT Indirect Interface element.\n//-----------------------------------------------------------------------------\nnamespace  IndirectInterfaceWriter\n{\n    /*!\n     *  Write the name group of the indirect interface.\n     *\n     *    @param [in] writer              The used XML writer.\n     *    @param [in] indirectInterface   The indirect interface being written.\n     *    @param [in] docRevision         The applied IP-XACT standard revision.\n     */\n    IPXACTMODELS_EXPORT void writeIndirectInterface(QXmlStreamWriter& writer, QSharedPointer<IndirectInterface> indirectInterface,\n        Document::Revision docRevision) ;\n\n    namespace Details\n    {\n        /*!\n         *  Write the indirect address and data fields of the indirect interface.\n         *\n         *    @param [in] writer              The used XML writer.\n         *    @param [in] indirectInterface   The indirect interface being written.\n         */\n        void writeIndirectFields(QXmlStreamWriter& writer, QSharedPointer<IndirectInterface> indirectInterface);\n\n        /*!\n         *  Write the transparent bridges of the indirect interface.\n         *\n         *    @param [in] writer              The used XML writer.\n         *    @param [in] indirectInterface   The indirect interface being written.\n         *    @param [in] docRevision         The applied IP-XACT standard revision.\n         */\n        void writeTransparentBridges(QXmlStreamWriter& writer,\n            QSharedPointer<IndirectInterface> indirectInterface, Document::Revision docRevision);\n    }\n};\n\n#endif // INDIRECTINTERFACEWriter_H\n"
  },
  {
    "path": "IPXACTmodels/Component/InitiatorInterface.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: InitiatorInterface.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Esko Pekkarinen\n// Date: 28.6.2023\n//\n// Description:\n// \n//-----------------------------------------------------------------------------\n#include \"InitiatorInterface.h\"\n\n#include <QString>\n#include <QMap>\n#include <QObject>\n\n//-----------------------------------------------------------------------------\n// Function: InitiatorInterface::InitiatorInterface()\n//-----------------------------------------------------------------------------\nInitiatorInterface::InitiatorInterface() :\n    Extendable()\n{\n}\n\n//-----------------------------------------------------------------------------\n// Function: InitiatorInterface::InitiatorInterface()\n//-----------------------------------------------------------------------------\nInitiatorInterface::InitiatorInterface(InitiatorInterface const& other):\n    Extendable(other),\n    addressSpaceRef_(other.addressSpaceRef_),\n    isPresent_(other.isPresent_),\n    baseAddress_(other.baseAddress_),\n    modeRefs_(other.modeRefs_)\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: InitiatorInterface::operator=()\n//-----------------------------------------------------------------------------\nInitiatorInterface& InitiatorInterface::operator=(InitiatorInterface const& other)\n{\n    if (this != &other)\n    {\n        Extendable::operator=(other);\n\n        addressSpaceRef_ = other.addressSpaceRef_;\n        isPresent_ = other.isPresent_;\n        baseAddress_ = other.baseAddress_;\n        modeRefs_ = other.modeRefs_;\n    }\n\n    return *this;\n}\n\n//-----------------------------------------------------------------------------\n// Function: InitiatorInterface::~InitiatorInterface()\n//-----------------------------------------------------------------------------\nInitiatorInterface::~InitiatorInterface()\n{\n}\n\n//-----------------------------------------------------------------------------\n// Function: InitiatorInterface::setAddressSpaceRef()\n//-----------------------------------------------------------------------------\nvoid InitiatorInterface::setAddressSpaceRef(QString const& addressSpaceRef)\n{\n    addressSpaceRef_ = addressSpaceRef;\n}\n\n//-----------------------------------------------------------------------------\n// Function: InitiatorInterface::getAddressSpaceRef()\n//-----------------------------------------------------------------------------\nQString InitiatorInterface::getAddressSpaceRef() const\n{\n    return addressSpaceRef_;\n}\n\n//-----------------------------------------------------------------------------\n// Function: InitiatorInterface::setIsPresent()\n//-----------------------------------------------------------------------------\nvoid InitiatorInterface::setIsPresent(QString const& newIsPresent)\n{\n    isPresent_ = newIsPresent;\n}\n\n//-----------------------------------------------------------------------------\n// Function: InitiatorInterface::getIsPresent()\n//-----------------------------------------------------------------------------\nQString InitiatorInterface::getIsPresent() const\n{\n    return isPresent_;\n}\n\n//-----------------------------------------------------------------------------\n// Function: InitiatorInterface::setBaseAddress()\n//-----------------------------------------------------------------------------\nvoid InitiatorInterface::setBaseAddress(QString const& baseAddress)\n{\n    baseAddress_ = baseAddress;\n}\n\n//-----------------------------------------------------------------------------\n// Function: InitiatorInterface::getBaseAddress()\n//-----------------------------------------------------------------------------\nQString InitiatorInterface::getBaseAddress() const\n{\n    return baseAddress_;\n}\n\n//-----------------------------------------------------------------------------\n// Function: InitiatorInterface::setModeRefs()\n//-----------------------------------------------------------------------------\nvoid InitiatorInterface::setModeRefs(QStringList const& modeRefs)\n{\n    modeRefs_ = modeRefs;\n}\n\n//-----------------------------------------------------------------------------\n// Function: InitiatorInterface::getModeRefs()\n//-----------------------------------------------------------------------------\nQStringList InitiatorInterface::getModeRefs() const\n{\n    return modeRefs_;\n}\n"
  },
  {
    "path": "IPXACTmodels/Component/InitiatorInterface.h",
    "content": "//-----------------------------------------------------------------------------\n// File: InitiatorInterface.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Esko Pekkarinen\n// Date: 28.6.2023\n//\n// Description:\n// Implementation of ipxact:initiator in bus interface.\n//-----------------------------------------------------------------------------\n\n#ifndef INITIATORINTERFACE_H\n#define INITIATORINTERFACE_H\n\n#include <IPXACTmodels/ipxactmodels_global.h>\n\n#include <IPXACTmodels/common/Extendable.h>\n\n#include <QString>\n#include <QMap>\n#include <QDomNode>\n\n//-----------------------------------------------------------------------------\n//! Implementation of ipxact:initiator in bus interface.\n//-----------------------------------------------------------------------------\nclass IPXACTMODELS_EXPORT InitiatorInterface: public Extendable\n{\npublic:\n\n\t//! Default constructor.\n\tInitiatorInterface();\n\n\t//! Copy constructor.\n\tInitiatorInterface(const InitiatorInterface& other);\n\n\t//! Assignment operator.\n\tInitiatorInterface& operator=(const InitiatorInterface& other);\n\n\t//! The destructor.\n\tvirtual ~InitiatorInterface();\n    \n\t/*! Set the address space reference.\n\t *\n\t *    @param [in] addressSpaceRef     The name of the address space to reference.\n\t */\n\tvoid setAddressSpaceRef(QString const& addressSpaceRef);\n\n\t/*! Get the address space reference.\n\t *\n\t *    @return QString containing the address space name\n\t */\n\tQString getAddressSpaceRef() const;\n    \n    /*!\n     *  Set the presence value.\n     *\n     *    @param [in] newIsPresent    The new isPresent value.\n     */\n    void setIsPresent(QString const& newIsPresent);\n\n    /*!\n     *  Get the presence.\n     *\n     *    @return The isPresent value.\n     */\n    QString getIsPresent() const;\n\n\t/*! Set the base address.\n\t *\n\t *    @param [in]  baseAddress    The base address to set.\n\t */\n\tvoid setBaseAddress(QString const& baseAddress);\n\n\t/*! Get the base address.\n\t *\n\t *    @return The base address for the initiator interface.\n\t */\n\tQString getBaseAddress() const;\n\n\n\tvoid setModeRefs(QStringList const& modeRefs);\n\n\tQStringList getModeRefs() const;\n\nprivate:\n\n    //! The name of an address space that defines the range and width for transaction for the initiator interface.\n    QString addressSpaceRef_;\n\n    //! The presence of the master interface.\n    QString isPresent_;\n\n\t// The starting address of the address space.\n\tQString baseAddress_;\n\n\n\t//! Mode references.\n\tQStringList modeRefs_;\n};\n\n#endif // INITIATORINTERFACE_H\n"
  },
  {
    "path": "IPXACTmodels/Component/InstantiationsReader.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: InstantiationsReader.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 07.09.2015\r\n//\r\n// Description:\r\n// Reader for IP-XACT instantiations.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"InstantiationsReader.h\"\r\n\r\n#include <IPXACTmodels/common/NameGroupReader.h>\r\n#include <IPXACTmodels/common/FileBuilderReader.h>\r\n\r\n#include <IPXACTmodels/common/ModuleParameterReader.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: InstantiationsReader::createDesignInstantiationFrom()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<DesignInstantiation> InstantiationsReader::createDesignInstantiationFrom(\r\n    QDomNode const& instantiationNode)\r\n{\r\n    QSharedPointer<DesignInstantiation> newInstantiation (new DesignInstantiation());\r\n\r\n    NameGroupReader::parseNameGroup(instantiationNode, newInstantiation);\r\n\r\n    QDomNode designReferenceNode = instantiationNode.firstChildElement(QStringLiteral(\"ipxact:designRef\"));\r\n    newInstantiation->setDesignReference(CommonItemsReader::parseConfigurableVLNVReference(designReferenceNode, VLNV::DESIGN));\r\n\r\n    CommonItemsReader::parseVendorExtensions(instantiationNode, newInstantiation);\r\n\r\n    return newInstantiation;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: InstantiationsReader::createDesignConfigurationInstantiationFrom()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<DesignConfigurationInstantiation> InstantiationsReader::createDesignConfigurationInstantiationFrom(\r\n    QDomNode const& instantiationNode, Document::Revision docRevision)\r\n{\r\n    QSharedPointer<DesignConfigurationInstantiation> newInstantiation(new DesignConfigurationInstantiation());\r\n\r\n    NameGroupReader::parseNameGroup(instantiationNode, newInstantiation);\r\n\r\n    QDomNode configurationReferenceNode = instantiationNode.firstChildElement(\r\n        QStringLiteral(\"ipxact:designConfigurationRef\"));\r\n    QSharedPointer<ConfigurableVLNVReference> configurationReference =\r\n        CommonItemsReader::parseConfigurableVLNVReference(configurationReferenceNode, VLNV::DESIGNCONFIGURATION);\r\n    newInstantiation->setDesignConfigurationReference(configurationReference);\r\n\r\n    newInstantiation->setLanguage(Details::parseLanguageFrom(instantiationNode));\r\n    newInstantiation->setLanguageStrict(Details::parseLanguageStrictnessFrom(instantiationNode));\r\n\r\n    newInstantiation->setParameters(CommonItemsReader::parseAndCreateParameters(instantiationNode, docRevision));\r\n\r\n    CommonItemsReader::parseVendorExtensions(instantiationNode, newInstantiation);\r\n\r\n    return newInstantiation;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: InstantiationsReader::Details::getLanguageFrom()\r\n//-----------------------------------------------------------------------------\r\nQString InstantiationsReader::Details::parseLanguageFrom(QDomNode const& instantiationNode)\r\n{\r\n    QDomElement languageNode = instantiationNode.firstChildElement(QStringLiteral(\"ipxact:language\"));\r\n    return languageNode.firstChild().nodeValue();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: InstantiationsReader::Details::getLanguageStrictnessFrom()\r\n//-----------------------------------------------------------------------------\r\nbool InstantiationsReader::Details::parseLanguageStrictnessFrom(QDomNode const& instantiationNode)\r\n{\r\n    QDomElement languageNode = instantiationNode.firstChildElement(QStringLiteral(\"ipxact:language\"));\r\n    if (!languageNode.attribute(QStringLiteral(\"strict\")).isNull())\r\n    {\r\n        return true;\r\n    }\r\n    else\r\n    {\r\n        return false;\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: InstantiationsReader::createComponentInstantiationFrom()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<ComponentInstantiation> InstantiationsReader::createComponentInstantiationFrom(\r\n    QDomNode const& instantiationNode, Document::Revision docRevision)\r\n{\r\n    QSharedPointer<ComponentInstantiation> newInstantiation (new ComponentInstantiation());\r\n\r\n    NameGroupReader::parseNameGroup(instantiationNode, newInstantiation);\r\n\r\n    if (!instantiationNode.firstChildElement(QStringLiteral(\"ipxact:isVirtual\")).isNull())\r\n    {\r\n        newInstantiation->setVirtual(true);\r\n    }\r\n\r\n    newInstantiation->setLanguage(Details::parseLanguageFrom(instantiationNode));\r\n    newInstantiation->setLanguageStrictness(Details::parseLanguageStrictnessFrom(instantiationNode));\r\n\r\n    Details::parseNameReferences(instantiationNode, newInstantiation);\r\n\r\n    Details::parseModuleParameters(instantiationNode, newInstantiation, docRevision);\r\n\r\n    Details::parseDefaultFileBuilders(instantiationNode, newInstantiation, docRevision);\r\n\r\n    Details::parseFileSetReferences(instantiationNode, newInstantiation, docRevision);\r\n\r\n    newInstantiation->setParameters(CommonItemsReader::parseAndCreateParameters(instantiationNode, docRevision));\r\n\r\n    CommonItemsReader::parseVendorExtensions(instantiationNode, newInstantiation);\r\n\r\n    return newInstantiation;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: InstantiationsReader::Details::parseNameReferences()\r\n//-----------------------------------------------------------------------------\r\nvoid InstantiationsReader::Details::parseNameReferences(QDomNode const& instantiationNode,\r\n    QSharedPointer<ComponentInstantiation> instantiation)\r\n{\r\n    QDomElement libraryElement = instantiationNode.firstChildElement(QStringLiteral(\"ipxact:libraryName\"));\r\n    if (!libraryElement.isNull())\r\n    {\r\n        instantiation->setLibraryName(libraryElement.firstChild().nodeValue());\r\n    }\r\n\r\n    QDomElement packageElement = instantiationNode.firstChildElement(QStringLiteral(\"ipxact:packageName\"));\r\n    if (!libraryElement.isNull())\r\n    {\r\n        instantiation->setPackageName(packageElement.firstChild().nodeValue());\r\n    }\r\n\r\n    QDomElement moduleElement = instantiationNode.firstChildElement(QStringLiteral(\"ipxact:moduleName\"));\r\n    if (!moduleElement.isNull())\r\n    {\r\n        instantiation->setModuleName(moduleElement.firstChild().nodeValue());\r\n    }\r\n\r\n    QDomElement architectureElement = instantiationNode.firstChildElement(QStringLiteral(\"ipxact:architectureName\"));\r\n    if (!architectureElement.isNull())\r\n    {\r\n        instantiation->setArchitectureName(architectureElement.firstChild().nodeValue());\r\n    }\r\n\r\n    QDomElement configurationElement = instantiationNode.firstChildElement(QStringLiteral(\"ipxact:configurationName\"));\r\n    if (!configurationElement.isNull())\r\n    {\r\n        instantiation->setConfigurationName(configurationElement.firstChild().nodeValue());\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: InstantiationsReader::Details::parseModuleParameters()\r\n//-----------------------------------------------------------------------------\r\nvoid InstantiationsReader::Details::parseModuleParameters(QDomNode const& instantiationNode,\r\n    QSharedPointer<ComponentInstantiation> instantiation, Document::Revision docRevision)\r\n{\r\n    QDomElement moduleParametersElement = instantiationNode.firstChildElement(QStringLiteral(\"ipxact:moduleParameters\"));\r\n    if (!moduleParametersElement.isNull())\r\n    {\r\n        QDomNodeList moduleParameterNodes = moduleParametersElement.elementsByTagName(QStringLiteral(\"ipxact:moduleParameter\"));\r\n\r\n        for (int parameterIndex = 0; parameterIndex < moduleParameterNodes.count(); ++parameterIndex)\r\n        {\r\n            QSharedPointer<ModuleParameter> newModuleParameter =\r\n                ModuleParameterReader::createModuleParameterFrom(moduleParameterNodes.at(parameterIndex), docRevision);\r\n\r\n            instantiation->getModuleParameters()->append(newModuleParameter);\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: InstantiationsReader::Details::parseDefaultFileBuilders()\r\n//-----------------------------------------------------------------------------\r\nvoid InstantiationsReader::Details::parseDefaultFileBuilders(QDomNode const& instantiationNode,\r\n    QSharedPointer<ComponentInstantiation> instantiation,\r\n    Document::Revision docRevision)\r\n{\r\n    QDomElement instantiationElement = instantiationNode.toElement();\r\n\r\n    QDomNodeList defaultFileBuilderNodeList = instantiationElement.elementsByTagName(QStringLiteral(\"ipxact:defaultFileBuilder\"));\r\n\r\n    if (!defaultFileBuilderNodeList.isEmpty())\r\n    {\r\n        for (int i = 0; i < defaultFileBuilderNodeList.count(); ++i)\r\n        {\r\n            QSharedPointer<FileBuilder> defaultFileBuilder =\r\n                FileBuilderReader::createFileBuilderFrom(defaultFileBuilderNodeList.at(i), docRevision);\r\n            instantiation->getDefaultFileBuilders()->append(defaultFileBuilder);\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: InstantiationsReader::Details::parseFileSetReferences()\r\n//-----------------------------------------------------------------------------\r\nvoid InstantiationsReader::Details::parseFileSetReferences(QDomNode const& instantiationNode,\r\n    QSharedPointer<ComponentInstantiation> instantiation,\r\n    Document::Revision docRevision)\r\n{\r\n    QDomElement instantiationElement = instantiationNode.toElement();\r\n    \r\n    if (!instantiationElement.isNull())\r\n    {\r\n        if (auto fileSetRefs = CommonItemsReader::parseFileSetReferences(instantiationNode.toElement(), docRevision);\r\n            fileSetRefs->isEmpty() == false)\r\n        {\r\n            instantiation->setFileSetReferences(fileSetRefs);\r\n        }\r\n    }\r\n}"
  },
  {
    "path": "IPXACTmodels/Component/InstantiationsReader.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: InstantiationsReader.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 07.09.2015\r\n//\r\n// Description:\r\n// Reader for IP-XACT instantiations.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef INSTANTIATIONSREADER_H\r\n#define INSTANTIATIONSREADER_H\r\n\r\n#include \"ComponentInstantiation.h\"\r\n#include \"DesignInstantiation.h\"\r\n#include \"DesignConfigurationInstantiation.h\"\r\n\r\n#include <IPXACTmodels/common/Document.h>\r\n\r\n#include <IPXACTmodels/common/CommonItemsReader.h>\r\n\r\n#include <QSharedPointer>\r\n#include <QDomNode>\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Reader for IP-XACT instantiations.\r\n//-----------------------------------------------------------------------------\r\nnamespace InstantiationsReader\r\n{\r\n    /*!\r\n     *  Creates a new design instantiation.\r\n     *\r\n     *    @param [in] instantiationNode   XML description of the instantiation.\r\n     *\r\n     *    @return Pointer to the created design instantiation.\r\n     */\r\n    IPXACTMODELS_EXPORT QSharedPointer<DesignInstantiation> createDesignInstantiationFrom(QDomNode const& instantiationNode);\r\n\r\n    /*!\r\n     *  Creates a new design configuration instantiation.\r\n     *\r\n     *    @param [in] instantiationNode   XML description of the instantiation.\r\n     *    @param [in] docRevision         The IP-XACT standard revision to comply to.\r\n     *\r\n     *    @return The created design configuration instantiation.\r\n     */\r\n    IPXACTMODELS_EXPORT QSharedPointer<DesignConfigurationInstantiation> createDesignConfigurationInstantiationFrom\r\n        (QDomNode const& instantiationNode, Document::Revision docRevision);\r\n\r\n    /*!\r\n     *  Creates a new component instantiation.\r\n     *\r\n     *    @param [in] instantiationNode   XML description of the instantiation.\r\n     *    @param [in] docRevision         The IP-XACT standard to comply to.\r\n     * \r\n     *    @return The created component instantiation.\r\n     */\r\n    IPXACTMODELS_EXPORT QSharedPointer<ComponentInstantiation> createComponentInstantiationFrom(QDomNode const& instantiationNode,\r\n        Document::Revision docRevision);\r\n    \r\n    namespace Details\r\n    {\r\n        /*!\r\n         *  Get the used HDL from XML.\r\n         *\r\n         *    @param [in] instantiationNode   XML description of the instantiation.\r\n         *\r\n         *    @return The used HDL.\r\n         */\r\n        QString parseLanguageFrom(QDomNode const& instantiationNode);\r\n\r\n        /*!\r\n         *  Get the strictness of the used HDL from XML.\r\n         *\r\n         *    @param [in] instantiationNode   XML description of the instantiation.\r\n         *\r\n         *    @return True, if the language shall be strictly enforced, false otherwise.\r\n         */\r\n        bool parseLanguageStrictnessFrom(QDomNode const& instantiationNode);\r\n\r\n        /*!\r\n         *  Reads the name references from XML.\r\n         *\r\n         *    @param [in] instantiationNode   XML description of the instantiation.\r\n         *    @param [in] instantiation       The selected instantiation.\r\n         */\r\n        void parseNameReferences(QDomNode const& instantiationNode,\r\n            QSharedPointer<ComponentInstantiation> instantiation);\r\n\r\n        /*!\r\n         *  Reads the module parameter from XML.\r\n         *\r\n         *    @param [in] instantiationNode   XML description of the instantiation.\r\n         *    @param [in] instantiation       The selected instantiation.\r\n         *    @param [in] docRevision         The IP-XACT standard revision to comply to.\r\n         */\r\n        void parseModuleParameters(QDomNode const& instantiationNode,\r\n            QSharedPointer<ComponentInstantiation> instantiation, Document::Revision docRevision);\r\n\r\n        /*!\r\n         *  Reads the default file builders from XML.\r\n         *\r\n         *    @param [in] instantiationNode   XML description of the instantiation.\r\n         *    @param [in] instantiation       The selected instantiation.\r\n         *    @param [in] docRevision         The IP-XACT standard revision to comply to.\r\n         */\r\n        void parseDefaultFileBuilders(QDomNode const& instantiationNode,\r\n            QSharedPointer<ComponentInstantiation> instantiation,\r\n            Document::Revision docRevision);\r\n\r\n        /*!\r\n         *  Reads the file set references from XLM.\r\n         *\r\n         *    @param [in] instantiationNode   XML description of the instantiation.\r\n         *    @param [in] instantiation       The selected instantiation.\r\n         *    @param [in] docRevision         The IP-XACT standard revision to comply to.\r\n         */\r\n        void parseFileSetReferences(QDomNode const& instantiationNode,\r\n            QSharedPointer<ComponentInstantiation> instantiation,\r\n            Document::Revision docRevision);\r\n    }\r\n};\r\n\r\n#endif // VIEWREADER_H"
  },
  {
    "path": "IPXACTmodels/Component/InstantiationsWriter.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: InstantiationsWriter.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 04.09.2015\r\n//\r\n// Description:\r\n// Writer for IP-XACT instantiations element.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"InstantiationsWriter.h\"\r\n\r\n#include <IPXACTmodels/common/FileBuilderWriter.h>\r\n#include <IPXACTmodels/common/ModuleParameterWriter.h>\r\n#include <IPXACTmodels/common/NameGroupWriter.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: InstantiationsWriter::writeDesignInstantiation()\r\n//-----------------------------------------------------------------------------\r\nvoid InstantiationsWriter::writeDesignInstantiation(QXmlStreamWriter& writer,\r\n    QSharedPointer<DesignInstantiation> instantiation, Document::Revision docRevision)\r\n{\r\n    writer.writeStartElement(QStringLiteral(\"ipxact:designInstantiation\"));\r\n\r\n    NameGroupWriter::writeNameGroup(writer, instantiation, docRevision);\r\n\r\n    Details::writeReference(writer, instantiation->getDesignReference(), QStringLiteral(\"ipxact:designRef\"));\r\n\r\n    CommonItemsWriter::writeVendorExtensions(writer, instantiation);\r\n\r\n    writer.writeEndElement(); // ipxact:designInstantiation\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: InstantiationsWriter::Details::writeReference()\r\n//-----------------------------------------------------------------------------\r\nvoid InstantiationsWriter::Details::writeReference(QXmlStreamWriter& writer,\r\n    QSharedPointer<ConfigurableVLNVReference> reference, QString const& elementName)\r\n{\r\n    if (reference)\r\n    {\r\n        writer.writeStartElement(elementName);\r\n\r\n        CommonItemsWriter::writeVLNVAttributes(writer, *reference);\r\n        CommonItemsWriter::writeConfigurableElementValues(writer, reference->getConfigurableElementValues());\r\n\r\n        writer.writeEndElement(); // elementName\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: InstantiationsWriter::writeDesignConfigurationInstantiation()\r\n//-----------------------------------------------------------------------------\r\nvoid InstantiationsWriter::writeDesignConfigurationInstantiation(QXmlStreamWriter& writer,\r\n    QSharedPointer<DesignConfigurationInstantiation> instantiation, Document::Revision docRevision)\r\n{\r\n    writer.writeStartElement(QStringLiteral(\"ipxact:designConfigurationInstantiation\"));\r\n\r\n    NameGroupWriter::writeNameGroup(writer, instantiation, docRevision);\r\n\r\n    Details::writeLanguage(writer, instantiation->getLanguage(), instantiation->isLangugageStrict());\r\n\r\n    Details::writeReference(writer, instantiation->getDesignConfigurationReference(), QStringLiteral(\"ipxact:designConfigurationRef\"));\r\n\r\n    CommonItemsWriter::writeParameters(writer, instantiation->getParameters(), docRevision);\r\n\r\n    CommonItemsWriter::writeVendorExtensions(writer, instantiation);\r\n\r\n    writer.writeEndElement(); // ipxact:designConfigurationInstantiation\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: InstantiationsWriter::Details::writeLanguage()\r\n//-----------------------------------------------------------------------------\r\nvoid InstantiationsWriter::Details::writeLanguage(QXmlStreamWriter& writer, QString const& language,\r\n    bool languageStrictness)\r\n{\r\n    if (!language.isEmpty())\r\n    {\r\n        writer.writeStartElement(QStringLiteral(\"ipxact:language\"));\r\n\r\n        if (languageStrictness)\r\n        {\r\n            writer.writeAttribute(QStringLiteral(\"strict\"), QStringLiteral(\"true\"));\r\n        }\r\n        writer.writeCharacters(language);\r\n\r\n        writer.writeEndElement(); // ipxact:language\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: InstantiationsWriter::writeComponentInstantiation()\r\n//-----------------------------------------------------------------------------\r\nvoid InstantiationsWriter::writeComponentInstantiation(QXmlStreamWriter& writer,\r\n    QSharedPointer<ComponentInstantiation> instantiation, Document::Revision docRevision)\r\n{\r\n    writer.writeStartElement(QStringLiteral(\"ipxact:componentInstantiation\"));\r\n\r\n    NameGroupWriter::writeNameGroup(writer, instantiation, docRevision);\r\n\r\n    Details::writeLanguage(writer, instantiation->getLanguage(), instantiation->isLanguageStrict());\r\n\r\n    if (instantiation->isVirtual())\r\n    {\r\n        writer.writeTextElement(QStringLiteral(\"ipxact:isVirtual\"), QStringLiteral(\"true\"));\r\n    }\r\n\r\n    Details::writeNameReferences(writer, instantiation);\r\n\r\n    Details::writeModuleParameters(writer, instantiation->getModuleParameters(), docRevision);\r\n\r\n    Details::writeDefaultFileBuilders(writer, instantiation->getDefaultFileBuilders(), docRevision);\r\n\r\n    Details::writeFileSetReferences(writer, instantiation, docRevision);\r\n\r\n    CommonItemsWriter::writeParameters(writer, instantiation->getParameters(), docRevision);\r\n\r\n    CommonItemsWriter::writeVendorExtensions(writer, instantiation);\r\n\r\n    writer.writeEndElement(); // ipxact:componentInstantiation\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: InstantiationsWriter::Details::writeNameReferences()\r\n//-----------------------------------------------------------------------------\r\nvoid InstantiationsWriter::Details::writeNameReferences(QXmlStreamWriter& writer,\r\n    QSharedPointer<ComponentInstantiation> instantiation)\r\n{\r\n    if (!instantiation->getLibraryName().isEmpty())\r\n    {\r\n        writer.writeTextElement(QStringLiteral(\"ipxact:libraryName\"), instantiation->getLibraryName());\r\n    }\r\n    if (!instantiation->getPackageName().isEmpty())\r\n    {\r\n        writer.writeTextElement(QStringLiteral(\"ipxact:packageName\"), instantiation->getPackageName());\r\n    }\r\n    if (!instantiation->getModuleName().isEmpty())\r\n    {\r\n        writer.writeTextElement(QStringLiteral(\"ipxact:moduleName\"), instantiation->getModuleName());\r\n    }\r\n    if (!instantiation->getArchitectureName().isEmpty())\r\n    {\r\n        writer.writeTextElement(QStringLiteral(\"ipxact:architectureName\"), instantiation->getArchitectureName());\r\n    }\r\n    if (!instantiation->getConfigurationName().isEmpty())\r\n    {\r\n        writer.writeTextElement(QStringLiteral(\"ipxact:configurationName\"), instantiation->getConfigurationName());\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: InstantiationsWriter::Details::writeModuleParameters()\r\n//-----------------------------------------------------------------------------\r\nvoid InstantiationsWriter::Details::writeModuleParameters(QXmlStreamWriter& writer,\r\n    QSharedPointer<QList<QSharedPointer<ModuleParameter> > > moduleParameters,\r\n    Document::Revision docRevision)\r\n{\r\n    if (!moduleParameters->isEmpty())\r\n    {\r\n        writer.writeStartElement(QStringLiteral(\"ipxact:moduleParameters\"));\r\n\r\n        for (auto const& singleModuleParameter : *moduleParameters)\r\n        {\r\n            ModuleParameterWriter::writeModuleParameter(writer, singleModuleParameter, docRevision);\r\n        }\r\n\r\n        writer.writeEndElement(); // ipxact:moduleParameters\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: InstantiationsWriter::Details::writeDefaultFileBuilders()\r\n//-----------------------------------------------------------------------------\r\nvoid InstantiationsWriter::Details::writeDefaultFileBuilders(QXmlStreamWriter& writer,\r\n    QSharedPointer<QList<QSharedPointer<FileBuilder> > > defautlFileBuilders,\r\n    Document::Revision docRevision)\r\n{\r\n    for (QSharedPointer<FileBuilder> fileBuilder : *defautlFileBuilders)\r\n    {\r\n        FileBuilderWriter::writeDefaultFileBuilder(writer, fileBuilder, docRevision);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: InstantiationsWriter::Details::writeFileSetReferences()\r\n//-----------------------------------------------------------------------------\r\nvoid InstantiationsWriter::Details::writeFileSetReferences(QXmlStreamWriter& writer, \r\n    QSharedPointer<ComponentInstantiation> instantiation, \r\n    Document::Revision docRevision)\r\n{\r\n    if (auto fileSetRefs = instantiation->getFileSetReferences();\r\n        fileSetRefs->isEmpty() == false)\r\n    {\r\n        CommonItemsWriter::writeFileSetReferences(writer, fileSetRefs, docRevision);\r\n    }\r\n}\r\n"
  },
  {
    "path": "IPXACTmodels/Component/InstantiationsWriter.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: InstantiationsWriter.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 04.09.2015\r\n//\r\n// Description:\r\n// Writer for IP-XACT instantiations element.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef INSTANTIATIONSWRITER_H\r\n#define INSTANTIATIONSWRITER_H\r\n\r\n#include \"ComponentInstantiation.h\"\r\n#include \"DesignInstantiation.h\"\r\n#include \"DesignConfigurationInstantiation.h\"\r\n\r\n#include <IPXACTmodels/common/CommonItemsWriter.h>\r\n#include <IPXACTmodels/ipxactmodels_global.h>\r\n\r\n#include <QXmlStreamWriter>\r\n#include <QSharedPointer>\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Writer for IP-XACT view element.\r\n//-----------------------------------------------------------------------------\r\nnamespace InstantiationsWriter\r\n{\r\n    /*!\r\n     *  Write a design instantiation to an XML file.\r\n     *\r\n     *    @param [in] writer          The used XML writer.\r\n     *    @param [in] instantiation   The instantiation to be written.\r\n     *    @param [in] docRevision     The IP-XACT standard revision in use.\r\n     */\r\n    IPXACTMODELS_EXPORT void writeDesignInstantiation(QXmlStreamWriter& writer, \r\n        QSharedPointer<DesignInstantiation> instantiation, Document::Revision docRevision);\r\n\r\n    /*!\r\n     *  Write a design configuration instantiation to an XML file.\r\n     *\r\n     *    @param [in] writer          The used XML writer.\r\n     *    @param [in] instantiation   The instantiation to be written.\r\n     *    @param [in] docRevision     The IP-XACT standard revision in use.\r\n     */\r\n    IPXACTMODELS_EXPORT void writeDesignConfigurationInstantiation(QXmlStreamWriter& writer,\r\n        QSharedPointer<DesignConfigurationInstantiation> instantiation, Document::Revision docRevision);\r\n\r\n    /*!\r\n     *  Writes a component instantiation to an XML file.\r\n     *\r\n     *    @param [in] writer          The used XML writer.\r\n     *    @param [in] instantiation   The instantiation to be written.\r\n     *    @param [in] docRevision     The IP-XACT standard revision in use.\r\n     */\r\n    IPXACTMODELS_EXPORT void writeComponentInstantiation(QXmlStreamWriter& writer,\r\n        QSharedPointer<ComponentInstantiation> instantiation, Document::Revision docRevision);\r\n\r\n    namespace Details\r\n    {\r\n\r\n        /*!\r\n         *  Write a reference to an IP-XACT item.\r\n         *\r\n         *    @param [in] writer          The used XML writer.\r\n         *    @param [in] reference       The referenced item.\r\n         *    @param [in] elementName     The name of the reference containing element.\r\n         */\r\n        void writeReference(QXmlStreamWriter& writer, QSharedPointer<ConfigurableVLNVReference> reference,\r\n            QString const& elementName);\r\n\r\n        /*!\r\n         *  Write the language.\r\n         *\r\n         *    @param [in] writer              The used XML writer.\r\n         *    @param [in] language            The language to be written.\r\n         *    @param [in] languageStrictness  Strictness of the language.\r\n         */\r\n        void writeLanguage(QXmlStreamWriter& writer, QString const& language, bool languageStrictness);\r\n\r\n        /*!\r\n         *  Writes the name references of an instantiation.\r\n         *\r\n         *    @param [in] writer              The used XML writer.\r\n         *    @param [in] instantiation       The containing instantiation.\r\n         */\r\n        void writeNameReferences(QXmlStreamWriter& writer, QSharedPointer<ComponentInstantiation> instantiation);\r\n\r\n        /*!\r\n         *  Writes the module parameters of an instantiation.\r\n         *\r\n         *    @param [in] writer              The used XML writer.\r\n         *    @param [in] moduleParameters    The module parameters to be written.\r\n         *    @param [in] docRevision         The IP-XACT standard revision in use.\r\n         */\r\n        void writeModuleParameters(QXmlStreamWriter& writer,\r\n            QSharedPointer<QList<QSharedPointer<ModuleParameter> > > moduleParameters,\r\n            Document::Revision docRevision);\r\n\r\n        /*!\r\n         *  Writes the default file builders.\r\n         *\r\n         *    @param [in] writer                  The used XML writer.\r\n         *    @param [in] defautlFileBuilders     The file builders to be written.\r\n         */\r\n        void writeDefaultFileBuilders(QXmlStreamWriter& writer,\r\n            QSharedPointer<QList<QSharedPointer<FileBuilder> > > defautlFileBuilders,\r\n            Document::Revision docRevision);\r\n\r\n        /*!\r\n         *  Writes the file set references.\r\n         *\r\n         *    @param [in] writer          The used XML writer.\r\n         *    @param [in] instantiation   The instantiation whose file set refs are written.\r\n         *    @param [in] docRevision     The IP-XACT standard revision in use.\r\n         */\r\n        void writeFileSetReferences(QXmlStreamWriter& writer, QSharedPointer<ComponentInstantiation> instantiation, Document::Revision docRevision);\r\n    }\r\n};\r\n\r\n#endif // INSTANTIATIONSWRITER_H"
  },
  {
    "path": "IPXACTmodels/Component/LanguageTools.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: LanguageTools.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Esko Pekkarinen\n// Date: 15.6.2023\n//\n// Description:\n// Implementation of the ipxact:languageTools element.\n//-----------------------------------------------------------------------------\n\n#include \"LanguageTools.h\"\n\n//-----------------------------------------------------------------------------\n// Function: LanguageTools::LanguageTools()\n//-----------------------------------------------------------------------------\nLanguageTools::LanguageTools()\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: LanguageTools::LanguageTools()\n//-----------------------------------------------------------------------------\nLanguageTools::LanguageTools(const LanguageTools& other) :\n    NameGroup(other),\n    Extendable(other)\n{\n    copyFileBuilders(other);\n}\n\n//-----------------------------------------------------------------------------\n// Function: LanguageTools::operator=()\n//-----------------------------------------------------------------------------\nLanguageTools& LanguageTools::operator=(const LanguageTools& other)\n{\n    if (this != &other)\n    {\n        NameGroup::operator=(other);\n        Extendable::operator=(other);\n\n        fileBuilders_->clear();\n        copyFileBuilders(other);\n    }\n\n    return *this;\n}\n\n//-----------------------------------------------------------------------------\n// Function: LanguageTools::~LanguageTools()\n//-----------------------------------------------------------------------------\nLanguageTools::~LanguageTools()\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: LanguageTools::clone()\n//-----------------------------------------------------------------------------\nQSharedPointer<LanguageTools> LanguageTools::clone() const\n{\n    QSharedPointer<LanguageTools> copy(new LanguageTools(*this));\n    return copy;\n}\n\n//-----------------------------------------------------------------------------\n// Function: LanguageTools::getFileBuilders()\n//-----------------------------------------------------------------------------\nQSharedPointer<QList<QSharedPointer<FileBuilder> > > LanguageTools::getFileBuilders() const\n{\n    return fileBuilders_;\n}\n\n//-----------------------------------------------------------------------------\n// Function: LanguageTools::setDefaultFileBuilders()\n//-----------------------------------------------------------------------------\nvoid LanguageTools::setFileBuilders(\n    QSharedPointer<QList<QSharedPointer<FileBuilder> > > newFileBuilders)\n{\n    fileBuilders_ = newFileBuilders;\n}\n\n//-----------------------------------------------------------------------------\n// Function: LanguageTools::getLinker()\n//-----------------------------------------------------------------------------\nQString LanguageTools::getLinker() const\n{\n    return linker_;\n}\n\n//-----------------------------------------------------------------------------\n// Function: LanguageTools::setLinker()\n//-----------------------------------------------------------------------------\nvoid LanguageTools::setLinker(QString const& linker)\n{\n    linker_ = linker;\n}\n\n//-----------------------------------------------------------------------------\n// Function: LanguageTools::getLinkerFlags()\n//-----------------------------------------------------------------------------\nQString LanguageTools::getLinkerFlags() const\n{\n    return linkerFlags_;\n}\n\n//-----------------------------------------------------------------------------\n// Function: LanguageTools::setLinkerFlags()\n//-----------------------------------------------------------------------------\nvoid LanguageTools::setLinkerFlags(QString const& flags)\n{\n    linkerFlags_ = flags;\n}\n\n//-----------------------------------------------------------------------------\n// Function: LanguageTools::getLinkerCommandFile()\n//-----------------------------------------------------------------------------\nQSharedPointer<LanguageTools::LanguageTools::LinkerCommandFile> LanguageTools::getLinkerCommandFile() const\n{\n    return linkerCommandFile_;\n}\n\n//-----------------------------------------------------------------------------\n// Function: LanguageTools::copyFileBuilders()\n//-----------------------------------------------------------------------------\nvoid LanguageTools::copyFileBuilders(const LanguageTools& other) const\n{\n    for (QSharedPointer<FileBuilder> fileBuilder : *other.fileBuilders_)\n    {\n        QSharedPointer<FileBuilder> copy = QSharedPointer<FileBuilder>(new FileBuilder(*fileBuilder));\n        fileBuilders_->append(copy);\n    }\n}\n"
  },
  {
    "path": "IPXACTmodels/Component/LanguageTools.h",
    "content": "//-----------------------------------------------------------------------------\n// File: LanguageTools.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Esko Pekkarinen\n// Date: 15.6.2023\n//\n// Description:\n// Implementation of the ipxact:languageTools element.\n//-----------------------------------------------------------------------------\n\n#ifndef LANGUAGE_TOOLS_H\n#define LANGUAGE_TOOLS_H\n\n#include <IPXACTmodels/common/FileBuilder.h>\n\n#include <IPXACTmodels/ipxactmodels_global.h>\n\n#include <QSharedPointer>\n\n//-----------------------------------------------------------------------------\n//! Implementation of the ipxact:languageTools element.\n//-----------------------------------------------------------------------------\nclass IPXACTMODELS_EXPORT LanguageTools : public NameGroup, public Extendable\n{\npublic:\n\n    //! Implementation of the ipxact:linkerCommandFile element.\n    struct LinkerCommandFile : public Extendable\n    {\n        QString name_;\n\n        QString commandLineSwitch_;\n\n        QString enable_;\n\n        QStringList generatorRefs_;\n    };\n\n    /*!\n     *  The constructor.\n     */\n    LanguageTools();\n\n    /*!\n     *  The copy constructor.\n     */\n    LanguageTools(const LanguageTools& other);\n\n    /*!\n     *  The assignment operator.\n     */\n    LanguageTools& operator=(const LanguageTools& other);\n\n    /*!\n     *  The destructor.\n     */\n    virtual ~LanguageTools();\n\n    /*!\n     *  Create a copy of the language tools.\n     *\n     *    @return A copy of the language tools object.\n     */\n    QSharedPointer<LanguageTools> clone() const;\n\n    /*!\n     *  Get the file builders.\n     *\n     *    @return A pointer to a list containing the file builders.\n     */\n    QSharedPointer<QList<QSharedPointer<FileBuilder> > > getFileBuilders() const;\n\n    /*!\n     *  Set the file builders.\n     *\n     *    @param [in] newFileBuilders  The new file builders.\n     */\n    void setFileBuilders(QSharedPointer<QList<QSharedPointer<FileBuilder> > > newDefaultFileBuilders);\n\n    /*!\n     *  Get the linker defined in the language tools.\n     *\n     *    @return The linker in the language tools.\n     */\n    QString getLinker() const;\n\n    /*!\n     *  Set the linker in the language tools.\n     *\n     *    @param [in] linker The linker to set.\n     */\n    void setLinker(QString const& linker);\n\n    /*!\n     *  Get the linker flags defined in the language tools.\n     *\n     *    @return The linker glags in the language tools.\n     */\n    QString getLinkerFlags() const;\n\n    /*!\n     *  Set the linker flags in the language tools.\n     *\n     *    @param [in] linker The linker flags to set.\n     */\n    void setLinkerFlags(QString const& flags);\n\n    /*!\n     *  Get the linker command file defined in the language tools.\n     *\n     *    @return The linker command file.\n     */\n    QSharedPointer<LanguageTools::LinkerCommandFile> getLinkerCommandFile() const;\n\n\nprivate:\n\n    /*!\n     *  Copy file builders.\n     */\n    void copyFileBuilders(const LanguageTools& other) const;\n\n    //-----------------------------------------------------------------------------\n    // Data.\n    //-----------------------------------------------------------------------------\n\n\n    //! A list of default file builders.\n    QSharedPointer<QList<QSharedPointer<FileBuilder> > > fileBuilders_ =\n        QSharedPointer<QList<QSharedPointer<FileBuilder> > >(new QList<QSharedPointer<FileBuilder> >);\n\n    //! The used linker.\n    QString linker_;\n\n    //! The used linker flags.\n    QString linkerFlags_;\n\n    //! The linker command file.\n    QSharedPointer<LinkerCommandFile> linkerCommandFile_ = QSharedPointer<LinkerCommandFile>(new LinkerCommandFile);\n\n};\n\n#endif // LANGUAGE_TOOLS_H"
  },
  {
    "path": "IPXACTmodels/Component/MemoryArray.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: MemoryArray.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Anton Hagqvist\n// Date: 21.7.2023\n//\n// Description:\n// Describes the ipxact:array element found in array block, register, and field.\n//-----------------------------------------------------------------------------\n\n#include \"MemoryArray.h\"\n\n#include <IPXACTmodels/utilities/Copy.h>\n\n//-----------------------------------------------------------------------------\n// Function: MemoryArray::MemoryArray()\n//-----------------------------------------------------------------------------\nMemoryArray::MemoryArray()\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: MemoryArray::MemoryArray()\n//-----------------------------------------------------------------------------\nMemoryArray::MemoryArray(MemoryArray const& other):\n    stride_(other.stride_)\n{\n    Copy::copyList(other.dimensions_, dimensions_);\n}\n\n//-----------------------------------------------------------------------------\n// Function: MemoryArray::operator=()\n//-----------------------------------------------------------------------------\nMemoryArray& MemoryArray::operator=(MemoryArray const& other)\n{\n    if (this != &other)\n    {\n        stride_ = other.stride_;\n\n        dimensions_->clear();\n        Copy::copyList(other.dimensions_, dimensions_);\n    }\n\n    return *this;\n}\n\n//-----------------------------------------------------------------------------\n// Function: MemoryArray::getDimensions()\n//-----------------------------------------------------------------------------\nQSharedPointer<QList<QSharedPointer<MemoryArray::Dimension> > > MemoryArray::getDimensions() const\n{\n    return dimensions_;\n}\n\n//-----------------------------------------------------------------------------\n// Function: MemoryArray::setDimensions()\n//-----------------------------------------------------------------------------\nvoid MemoryArray::setDimensions(QSharedPointer<QList<QSharedPointer<Dimension> > > dimensions)\n{\n    dimensions_ = dimensions;\n}\n\n//-----------------------------------------------------------------------------\n// Function: MemoryArray::getStride()\n//-----------------------------------------------------------------------------\nQString MemoryArray::getStride() const\n{\n    return stride_;\n}\n\n//-----------------------------------------------------------------------------\n// Function: MemoryArray::setStride()\n//-----------------------------------------------------------------------------\nvoid MemoryArray::setStride(QString const& stride)\n{\n    stride_ = stride;\n}\n"
  },
  {
    "path": "IPXACTmodels/Component/MemoryArray.h",
    "content": "//-----------------------------------------------------------------------------\n// File: MemoryArray.h\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Anton Hagqvist\n// Date: 21.7.2023\n//\n// Description:\n// Describes the ipxact:array element found in array block, register, and field.\n//-----------------------------------------------------------------------------\n\n#ifndef MEMORYARRAY_H\n#define MEMORYARRAY_H\n\n#include <IPXACTmodels/ipxactmodels_global.h>\n\n#include <QString>\n\n//-----------------------------------------------------------------------------\n//! Describes the ipxact:array element.\n//-----------------------------------------------------------------------------\nclass IPXACTMODELS_EXPORT MemoryArray\n{\n\npublic:\n    // ipxact:dim\n    struct Dimension\n    {\n        QString value_;\n        QString indexVar_;\n    };\n\n    /*!\n     *\tThe constructor.     \n     */\n    MemoryArray();\n\n    MemoryArray(MemoryArray const& other);\n\n    MemoryArray& operator=(MemoryArray const& other);\n\n    /*!\n     *\tThe destructor.\n     */\n    virtual ~MemoryArray() = default;\n\n    /*!\n     *\tGet the array dimensions.\n     *\t    \n     * \t    @return The dimensions of the array.\n     */\n    QSharedPointer<QList<QSharedPointer<Dimension> > > getDimensions() const;\n\n    /*!\n     *\tSet the dimensions of the array.\n     *  \n     *    @param [in] dimensions     The dimensions to set.\n     *\t    \n     */\n    void setDimensions(QSharedPointer<QList<QSharedPointer<Dimension> > > dimensions);\n\n    /*!\n     *\tGet the array stride.\n     *  \n     * \t    @return The array stride, or bitStride if the array is within a field element.\n     */\n    QString getStride() const;\n\n    /*!\n     *\tSet the array stride or bitStride, if in a field element.\n     *  \n     *    @param [in] stride     Description\n     */\n    void setStride(QString const& stride);\n\nprivate:\n\n    //! List of dimensions in the array.\n    QSharedPointer<QList<QSharedPointer<Dimension> > > dimensions_ = \n        QSharedPointer<QList<QSharedPointer<Dimension> > >(new QList<QSharedPointer<Dimension> >);\n\n    //! ipxact:stride or ipxact:bitStride.\n    QString stride_;\n};\n\n#endif // MEMORYARRAY_H\n"
  },
  {
    "path": "IPXACTmodels/Component/MemoryArrayReader.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: MemoryArrayReader.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Anton Hagqvist\n// Date: 21.7.2023\n//\n// Description:\n// Reader for ixpact:array memory array elements and 2014 standard dim elements.\n//-----------------------------------------------------------------------------\n\n#include \"MemoryArrayReader.h\"\n#include \"MemoryArray.h\"\n\n//-----------------------------------------------------------------------------\n// Function: MemoryArrayReader::createMemoryArrayFrom()\n//-----------------------------------------------------------------------------\nQSharedPointer<MemoryArray> MemoryArrayReader::createMemoryArrayFrom(QDomNode const& arrayNode,\n    Document::Revision docRevision, bool isField)\n{\n    QSharedPointer<MemoryArray> newArray(new MemoryArray());\n\n    Details::parseDimensions(arrayNode, newArray, docRevision);\n\n    if (docRevision == Document::Revision::Std22)\n    {\n        Details::parseStride(arrayNode, newArray, isField);\n    }\n\n    return newArray;\n}\n\n//-----------------------------------------------------------------------------\n// Function: MemoryArrayReader::Details::parseDimensions()\n//-----------------------------------------------------------------------------\nvoid MemoryArrayReader::Details::parseDimensions(QDomNode const& arrayNode, QSharedPointer<MemoryArray> newArray, Document::Revision docRevision)\n{\n    auto dimensionNodes = arrayNode.childNodes();\n\n    for (int i = 0; i < dimensionNodes.size(); ++i)\n    {\n        QSharedPointer<MemoryArray::Dimension> newDimension(new MemoryArray::Dimension);\n\n        auto dimensionNode = dimensionNodes.at(i);\n        if (dimensionNode.nodeName() == QStringLiteral(\"ipxact:dim\"))\n        {\n            newDimension->value_ = dimensionNode.firstChild().nodeValue();\n\n            if (docRevision == Document::Revision::Std22)\n            {\n                newDimension->indexVar_ = dimensionNode.attributes().namedItem(QStringLiteral(\"indexVar\")).nodeValue();\n            }\n\n            newArray->getDimensions()->append(newDimension);\n        }\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: MemoryArrayReader::Details::parseStride()\n//-----------------------------------------------------------------------------\nvoid MemoryArrayReader::Details::parseStride(QDomNode const& arrayNode, QSharedPointer<MemoryArray> newArray, bool isField)\n{\n    QString nodeName = isField ? QStringLiteral(\"ipxact:bitStride\") : QStringLiteral(\"ipxact:stride\");\n    \n    auto strideNode = arrayNode.firstChildElement(nodeName);\n    newArray->setStride(strideNode.firstChild().nodeValue());\n}\n"
  },
  {
    "path": "IPXACTmodels/Component/MemoryArrayReader.h",
    "content": "//-----------------------------------------------------------------------------\n// File: MemoryArrayReader.h\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Anton Hagqvist\n// Date: 21.7.2023\n//\n// Description:\n// Reader for ixpact:array memory array elements and 2014 standard dim elements.\n//-----------------------------------------------------------------------------\n\n#ifndef MEMORYARRAYREADER_H\n#define MEMORYARRAYREADER_H\n\n#include <IPXACTmodels/ipxactmodels_global.h>\n\n#include <IPXACTmodels/common/Document.h>\n\n#include <QDomNode>\n\nclass MemoryArray;\n\n//-----------------------------------------------------------------------------\n//! Reader for ixpact:array memory array elements.\n//-----------------------------------------------------------------------------\nnamespace MemoryArrayReader\n{\n    \n    /*!\n     *\tCreates a new memory array from a given memory array node.\n     *  \n     *    @param [in] arrayNode     XML description of the memory array.\n     *    @param [in] docRevision   The IP-XACT standard revision to comply to.\n     *    @param [in] isField       Flag indicating if array is within a field element.\n     *\t    \n     * \t    @return The created memory array.\n     */\n    IPXACTMODELS_EXPORT QSharedPointer<MemoryArray> createMemoryArrayFrom(QDomNode const& arrayNode,\n        Document::Revision docRevision, bool isField);\n\n    namespace Details\n    {\n        /*!\n         *\tParse the array dimensions.\n         *  \n         *    @param [in] arrayNode     XML description of the memory array.\n         *    @param [in] newArray      The new memory array.\n         *    @param [in] docRevision   The IP-XACT standard revision to comply to.\n         */\n        void parseDimensions(QDomNode const& arrayNode, QSharedPointer<MemoryArray> newArray, Document::Revision docRevision);\n\n        /*!\n         *\tParse the array stride.\n         *  \n         *    @param [in] arrayNode     XML description of the memory array.\n         *    @param [in] newArray      The new memory array.\n         *    @param [in] isField       Flag indicating if array is within a field element.\n         */\n        void parseStride(QDomNode const& arrayNode, QSharedPointer<MemoryArray> newArray, bool isField);\n    }\n};\n\n#endif // MEMORYARRAYREADER_H\n"
  },
  {
    "path": "IPXACTmodels/Component/MemoryArrayWriter.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: MemoryArrayWriter.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Anton Hagqvist\n// Date: 21.7.2023\n//\n// Description:\n// Writer for ipxact:array memory array elements.\n//-----------------------------------------------------------------------------\n\n#include \"MemoryArrayWriter.h\"\n#include \"MemoryArray.h\"\n\n//-----------------------------------------------------------------------------\n// Function: MemoryArrayWriter::writeMemoryArray()\n//-----------------------------------------------------------------------------\nvoid MemoryArrayWriter::writeMemoryArray(QXmlStreamWriter& writer, QSharedPointer<MemoryArray> memoryArray, Document::Revision docRevision, bool isField)\n{\n    if (!memoryArray)\n    {\n        return;\n    }\n\n    if (docRevision == Document::Revision::Std14)\n    {\n        Details::writeDimensions(writer, memoryArray, docRevision);\n    }\n    else if (docRevision == Document::Revision::Std22)\n    {\n        writer.writeStartElement(QStringLiteral(\"ipxact:array\"));\n\n        Details::writeDimensions(writer, memoryArray, docRevision);\n\n        Details::writeStride(writer, memoryArray, isField);\n\n        writer.writeEndElement(); // ipxact:array\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: MemoryArrayWriter::Details::writeDimensions()\n//-----------------------------------------------------------------------------\nvoid MemoryArrayWriter::Details::writeDimensions(QXmlStreamWriter& writer, QSharedPointer<MemoryArray> memoryArray, \n    Document::Revision docRevision)\n{\n    for (auto const& dimension : *memoryArray->getDimensions())\n    {\n        writer.writeStartElement(QStringLiteral(\"ipxact:dim\"));\n\n        if (dimension->indexVar_.isEmpty() == false && docRevision == Document::Revision::Std22)\n        {\n            writer.writeAttribute(QStringLiteral(\"indexVar\"), dimension->indexVar_);\n        }\n\n        writer.writeCharacters(dimension->value_);\n        writer.writeEndElement(); // ipxact:dim\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: MemoryArrayWriter::Details::writeStride()\n//-----------------------------------------------------------------------------\nvoid MemoryArrayWriter::Details::writeStride(QXmlStreamWriter& writer, QSharedPointer<MemoryArray> memoryArray, bool isField)\n{\n    QString elementName = isField ? QStringLiteral(\"ipxact:bitStride\") : QStringLiteral(\"ipxact:stride\");\n\n    if (auto const& stride = memoryArray->getStride(); stride.isEmpty() == false)\n    {\n        writer.writeTextElement(elementName, stride);\n    }\n}\n"
  },
  {
    "path": "IPXACTmodels/Component/MemoryArrayWriter.h",
    "content": "//-----------------------------------------------------------------------------\n// File: MemoryArrayWriter.h\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Anton Hagqvist\n// Date: 21.7.2023\n//\n// Description:\n// Writer for ipxact:array memory array elements.\n//-----------------------------------------------------------------------------\n\n#ifndef MEMORYARRAYWRITER_H\n#define MEMORYARRAYWRITER_H\n\n#include <IPXACTmodels/ipxactmodels_global.h>\n\n#include <IPXACTmodels/common/Document.h>\n\n#include <QXmlStreamWriter>\n\nclass MemoryArray;\n\n//-----------------------------------------------------------------------------\n//! Writer for ipxact:array memory array elements.\n//-----------------------------------------------------------------------------\nnamespace MemoryArrayWriter\n{\n    \n    /*!\n     *\tWrite a memory array to XML.\n     *  \n     *    @param [in] writer          The XML writer to use.\n     *    @param [in] memoryArray     The memory array to write.\n     *    @param [in] docRevision     The IP-XACT standard revision to comply to.\n     *    @param [in] isField         Flag indicating if the array is within a field.\n     */\n    IPXACTMODELS_EXPORT void writeMemoryArray(QXmlStreamWriter& writer, QSharedPointer<MemoryArray> memoryArray, \n        Document::Revision docRevision, bool isField);\n\n    namespace Details\n    {\n        /*!\n         *\tWrite the array dimensions.\n         *  \n         *    @param [in] writer          The XML writer to use.\n         *    @param [in] memoryArray     The memory array whose dimensions are written.\n         *    @param [in] docRevision     The IP-XACT standard revision to comply to.\n         */\n        void writeDimensions(QXmlStreamWriter& writer, QSharedPointer<MemoryArray> memoryArray, Document::Revision docRevision);\n\n        /*!\n         *\tWrite the stride or bitStride of the memory array.\n         *  \n         *    @param [in] writer          The XML writer to use.\n         *    @param [in] memoryArray     The memory array to write.\n         *    @param [in] isField         Indicates whether the memory array is within a field or not. \n         *                                  Write bitStride to XML if true, otherwise write stride.\n         */\n        void writeStride(QXmlStreamWriter& writer, QSharedPointer<MemoryArray> memoryArray, bool isField);\n    }\n};\n\n#endif // MEMORYARRAYWRITER_H\n"
  },
  {
    "path": "IPXACTmodels/Component/MemoryBlockBase.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: MemoryBlockBase.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 29.09.2015\r\n//\r\n// Description:\r\n// Describes the base class for ipxact:addressBlock, ipxact:bank and ipxact:subspaceMap elements.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"MemoryBlockBase.h\"\r\n\r\n#include <IPXACTmodels/common/Parameter.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryBlockBase::MemoryBlockBase()\r\n//-----------------------------------------------------------------------------\r\nMemoryBlockBase::MemoryBlockBase(QString const& name, QString const& baseAddress):\r\nNameGroup(name),\r\nExtendable(),\r\nisPresent_(),\r\nbaseAddress_(baseAddress),\r\nparameters_(new QList<QSharedPointer<Parameter> > ())\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryBlockBase::MemoryBlockBase()\r\n//-----------------------------------------------------------------------------\r\nMemoryBlockBase::MemoryBlockBase(const MemoryBlockBase& other):\r\nNameGroup(other),\r\nExtendable(other),\r\nisPresent_(other.isPresent_),\r\nbaseAddress_(other.baseAddress_),\r\nparameters_(new QList<QSharedPointer<Parameter> > ())\r\n{\r\n    copyParameters(other);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryBlockBase::operator=()\r\n//-----------------------------------------------------------------------------\r\nMemoryBlockBase& MemoryBlockBase::operator=(const MemoryBlockBase& other)\r\n{\r\n    if (this != &other)\r\n    {\r\n        NameGroup::operator=(other);\r\n        Extendable::operator=(other);\r\n        isPresent_ = other.isPresent_;\r\n        baseAddress_ = other.baseAddress_;\r\n        \r\n        parameters_->clear();\r\n        copyParameters(other);\r\n    }\r\n\r\n    return *this;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryBlockBase::~MemoryBlockBase()\r\n//-----------------------------------------------------------------------------\r\nMemoryBlockBase::~MemoryBlockBase()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryBlockBase::getIsPresent()\r\n//-----------------------------------------------------------------------------\r\nQString MemoryBlockBase::getIsPresent() const\r\n{\r\n    return isPresent_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryBlockBase::setIsPresent()\r\n//-----------------------------------------------------------------------------\r\nvoid MemoryBlockBase::setIsPresent(QString const& newIsPresent)\r\n{\r\n    isPresent_ = newIsPresent;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryBlockBase::getBaseAddress()\r\n//-----------------------------------------------------------------------------\r\nQString MemoryBlockBase::getBaseAddress() const\r\n{\r\n    return baseAddress_;\r\n}\r\n\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryBlockBase::setBaseAddress()\r\n//-----------------------------------------------------------------------------\r\nvoid MemoryBlockBase::setBaseAddress(QString const& baseAddress)\r\n{\r\n    baseAddress_ = baseAddress;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryBlockBase::getParametesrs()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<QList<QSharedPointer<Parameter> > > MemoryBlockBase::getParameters() const\r\n{\r\n    return parameters_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryBlockBase::setParameters()\r\n//-----------------------------------------------------------------------------\r\nvoid MemoryBlockBase::setParameters(QSharedPointer<QList<QSharedPointer<Parameter> > > newParameters)\r\n{\r\n    parameters_ = newParameters;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryBlockBase::copyParameters()\r\n//-----------------------------------------------------------------------------\r\nvoid MemoryBlockBase::copyParameters(const MemoryBlockBase& other)\r\n{\r\n    foreach (QSharedPointer<Parameter> parameter, *other.parameters_)\r\n    {\r\n        if (parameter)\r\n        {\r\n            QSharedPointer<Parameter> copy = QSharedPointer<Parameter>(new Parameter(*parameter.data()));\r\n            parameters_->append(copy);\r\n        }\r\n    }\r\n}"
  },
  {
    "path": "IPXACTmodels/Component/MemoryBlockBase.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: MemoryBlockBase.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 29.09.2015\r\n//\r\n// Description:\r\n// Describes the base class for ipxact:addressBlock, ipxact:bank and ipxact:subspaceMap elements.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef MEMORYBLOCKBASE_H\r\n#define MEMORYBLOCKBASE_H\r\n\r\n#include <IPXACTmodels/ipxactmodels_global.h>\r\n\r\n#include <IPXACTmodels/common/Extendable.h>\r\n#include <IPXACTmodels/common/NameGroup.h>\r\n\r\n#include <QMap>\r\n#include <QString>\r\n#include <QSharedPointer>\r\n#include <QList>\r\n\r\nclass Parameter;\r\nclass MemoryArray;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Describes the base class for ipxact:addressBlock, ipxact:bank and ipxact:subspaceMap elements.\r\n//-----------------------------------------------------------------------------\r\nclass IPXACTMODELS_EXPORT MemoryBlockBase : public NameGroup, public Extendable\r\n{\r\n\r\npublic:\r\n\r\n\t/*!\r\n\t *  The constructor.\r\n\t *\r\n\t *    @param [in] name            Name of the memory block.\r\n\t *    @param [in] baseAddress     Base address of the memory block.\r\n\t */\r\n\tMemoryBlockBase(QString const& name = QString(), QString const& baseAddress = QString());\r\n\r\n\t//! Copy constructor.\r\n\tMemoryBlockBase(const MemoryBlockBase& other);\r\n\r\n\t//! The assignment operator.\r\n\tMemoryBlockBase& operator=(const MemoryBlockBase& other);\r\n\r\n\t//! The destructor.\r\n\tvirtual ~MemoryBlockBase();\r\n\r\n\t/*!\r\n     *  Clone this memory map item and return pointer to the copy.\r\n\t * \r\n\t *    @return Pointer to the cloned memory map item.\r\n\t */\r\n\tvirtual QSharedPointer<MemoryBlockBase> clone() const = 0;\r\n\r\n    /*!\r\n     *  Get the presence of the memory block.\r\n     *\r\n     *    @return The isPresent value.\r\n     */\r\n    QString getIsPresent() const;\r\n\r\n    /*!\r\n     *  Set the presence of the memory block.\r\n     *\r\n     *    @param [in] newIsPresent    The new isPresent value.\r\n     */\r\n    void setIsPresent(QString const& newIsPresent);\r\n\r\n\t/*!\r\n     *  Get the base address of the block.\r\n\t *\r\n\t *    @return The base address\r\n\t */\r\n    QString getBaseAddress() const;\r\n\r\n\t/*!\r\n     *  Set base address for the block.\r\n\t *\r\n\t *    @param [in} baseAddress     The new base address\r\n\t */\r\n\tvirtual void setBaseAddress(QString const& baseAddress);\r\n\r\n    /*!\r\n     *  Get the contained parameters.\r\n     *\r\n     *    @return Pointer to a list containing the parameters.\r\n     */\r\n    QSharedPointer<QList<QSharedPointer<Parameter> > > getParameters() const;\r\n\r\n    /*!\r\n     *  Set the parameters.\r\n     *\r\n     *    @param [in] newParameters   Pointer to a list containing the new parameters.\r\n     */\r\n    void setParameters(QSharedPointer<QList<QSharedPointer<Parameter> > > newParameters);\r\n\r\nprivate:\r\n\r\n    /*!\r\n     *  Copy the parameters.\r\n     *\r\n     *    @param [in] other   The memory block being copied.\r\n     */\r\n    void copyParameters(const MemoryBlockBase& other);\r\n\r\n    //! Contains the presence of the block.\r\n    QString isPresent_;\r\n\r\n\t//! Contains the base address of the block.\r\n\tQString baseAddress_;\r\n\r\n    //! Contains the parameters of the block.\r\n    QSharedPointer<QList<QSharedPointer<Parameter> > > parameters_;\r\n};\r\n\r\nQ_DECLARE_METATYPE(QSharedPointer<MemoryBlockBase>);\r\n\r\n#endif // MEMORYBLOCKBASE_H\r\n"
  },
  {
    "path": "IPXACTmodels/Component/MemoryBlockBaseReader.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: MemoryBlockBaseReader.h\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Mikko Teuho\n// Date: 27.01.2022\n//\n// Description:\n// Base reader for memory map sub elements.\n//-----------------------------------------------------------------------------\n\n#include \"MemoryBlockBaseReader.h\"\n\n#include <IPXACTmodels/common/NameGroupReader.h>\n\n#include <IPXACTmodels/Component/MemoryBlockBase.h>\n#include <IPXACTmodels/Component/RegisterReader.h>\n\n//-----------------------------------------------------------------------------\n// Function: MemoryBlockBaseReader::parseNameGroup()\n//-----------------------------------------------------------------------------\nvoid MemoryBlockBaseReader::parseNameGroup(QDomNode const& memoryBlockNode,\n    QSharedPointer<MemoryBlockBase> newMemoryBlock)\n{\n    NameGroupReader::parseNameGroup(memoryBlockNode, newMemoryBlock);\n}\n\n//-----------------------------------------------------------------------------\n// Function: MemoryBlockBaseReader::parsePresence()\n//-----------------------------------------------------------------------------\nvoid MemoryBlockBaseReader::parsePresence(QDomNode const& memoryBlockNode,\n    QSharedPointer<MemoryBlockBase> newMemoryBlock)\n{\n    QDomElement isPresentElement = memoryBlockNode.firstChildElement(QStringLiteral(\"ipxact:isPresent\"));\n    if (!isPresentElement.isNull())\n    {\n        QString isPresent = isPresentElement.firstChild().nodeValue();\n        newMemoryBlock->setIsPresent(isPresent);\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: MemoryBlockBaseReader::parseBaseAddress()\n//-----------------------------------------------------------------------------\nvoid MemoryBlockBaseReader::parseBaseAddress(QDomNode const& memoryBlockNode,\n    QSharedPointer<MemoryBlockBase> newMemoryBlock)\n{\n    QDomElement baseAddressElement = memoryBlockNode.firstChildElement(QStringLiteral(\"ipxact:baseAddress\"));\n    if (!baseAddressElement.isNull())\n    {\n        QString baseAddress = baseAddressElement.firstChild().nodeValue();\n        newMemoryBlock->setBaseAddress(baseAddress);\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: AddressBlockReader::parseParameters()\n//-----------------------------------------------------------------------------\nIPXACTMODELS_EXPORT void MemoryBlockBaseReader::parseParameters(QDomNode const& addressBlockNode,\n    QSharedPointer<MemoryBlockBase> newMemoryBlock,\n    Document::Revision docRevision)\n{\n    QSharedPointer<QList<QSharedPointer<Parameter> > > newParameters = \n        CommonItemsReader::parseAndCreateParameters(addressBlockNode, docRevision);\n\n    if (!newParameters->isEmpty())\n    {\n        newMemoryBlock->setParameters(newParameters);\n    }\n}\n"
  },
  {
    "path": "IPXACTmodels/Component/MemoryBlockBaseReader.h",
    "content": "//-----------------------------------------------------------------------------\n// File: MemoryBlockBaseReader.h\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Mikko Teuho\n// Date: 27.01.2022\n//\n// Description:\n// Base reader for memory map sub elements.\n//-----------------------------------------------------------------------------\n\n#ifndef MEMORYBLOCKBASEREADER_H\n#define MEMORYBLOCKBASEREADER_H\n\n#include <IPXACTmodels/ipxactmodels_global.h>\n\n#include <IPXACTmodels/common/CommonItemsReader.h>\n\n#include <QSharedPointer>\n#include <QDomNode>\n\nclass MemoryBlockBase;\n\n//-----------------------------------------------------------------------------\n//! Base reader for memory map sub elements.\n//-----------------------------------------------------------------------------\nnamespace MemoryBlockBaseReader\n{\n    /*!\n     *  Reads the name group.\n     *\n     *    @param [in] memoryBlockNode     XML description of the memory block.\n     *    @param [in] newMemoryBlock      The new memory block.\n     */\n    IPXACTMODELS_EXPORT void parseNameGroup(QDomNode const& memoryBlockNode, QSharedPointer<MemoryBlockBase> newMemoryBlock);\n\n    /*!\n     *  Reads the presence.\n     *\n     *    @param [in] memoryBlockNode     XML description of the memory block.\n     *    @param [in] newMemoryBlock      The new memory block.\n     */\n    IPXACTMODELS_EXPORT void parsePresence(QDomNode const& memoryBlockNode, QSharedPointer<MemoryBlockBase> newMemoryBlock);\n\n    /*!\n     *  Reads the base address.\n     *\n     *    @param [in] memoryBlockNode     XML description of the memory block.\n     *    @param [in] newMemoryBlock      The new memory block.\n     */\n    IPXACTMODELS_EXPORT void parseBaseAddress(QDomNode const& memoryBlockNode, QSharedPointer<MemoryBlockBase> newMemoryBlock);\n\n    /*!\n     *  Reads the parameters.\n     *\n     *    @param [in] memoryBlockNode     XML description of the memory block.\n     *    @param [in] newMemoryBlock      The new memory block.\n     */\n    IPXACTMODELS_EXPORT void parseParameters(QDomNode const& addressBlockNode, QSharedPointer<MemoryBlockBase> newMemoryBlock, Document::Revision docRevision);\n}\n\n#endif // MEMORYBLOCKBASEREADER_H"
  },
  {
    "path": "IPXACTmodels/Component/MemoryBlockBaseWriter.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: MemoryBlockBaseWriter.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Mikko Teuho\n// Date: 28.01.2022\n//\n// Description:\n// Writer for base memory block element.\n//-----------------------------------------------------------------------------\n\n#include \"MemoryBlockBaseWriter.h\"\n\n#include <IPXACTmodels/common/NameGroupWriter.h>\n\n#include <IPXACTmodels/Component/MemoryBlockBase.h>\n\n//-----------------------------------------------------------------------------\n// Function: MemoryBlockBaseWriter::writeNameGroup()\n//-----------------------------------------------------------------------------\nvoid MemoryBlockBaseWriter::writeNameGroup(QXmlStreamWriter& writer, \n    QSharedPointer<MemoryBlockBase> memoryBlock, Document::Revision docRevision)\n{\n    NameGroupWriter::writeNameGroup(writer, memoryBlock, docRevision);\n}\n\n//-----------------------------------------------------------------------------\n// Function: MemoryBlockBaseWriter::writeBaseAddress()\n//-----------------------------------------------------------------------------\nvoid MemoryBlockBaseWriter::writeBaseAddress(QXmlStreamWriter& writer, QSharedPointer<MemoryBlockBase> memoryBlock)\n{\n    writer.writeTextElement(QStringLiteral(\"ipxact:baseAddress\"), memoryBlock->getBaseAddress());\n}\n"
  },
  {
    "path": "IPXACTmodels/Component/MemoryBlockBaseWriter.h",
    "content": "//-----------------------------------------------------------------------------\n// File: MemoryBlockBaseWriter.h\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Mikko Teuho\n// Date: 28.01.2022\n//\n// Description:\n// Writer for base memory block element.\n//-----------------------------------------------------------------------------\n\n#ifndef MEMORYBLOCKBASEWRITER_H\n#define MEMORYBLOCKBASEWRITER_H\n\n#include <IPXACTmodels/ipxactmodels_global.h>\n#include <IPXACTmodels/common/CommonItemsWriter.h>\n\n#include <QXmlStreamWriter>\n#include <QSharedPointer>\n#include <QObject>\n\nclass MemoryBlockBase;\n\n//-----------------------------------------------------------------------------\n//! Writer for base memory block element.\n//-----------------------------------------------------------------------------\nnamespace  MemoryBlockBaseWriter\n{\n    /*!\n     *  Write the name group.\n     *\n     *    @param [in] writer          Used XML writer.\n     *    @param [in] memoryBlock     Selected memory block.\n     */\n    IPXACTMODELS_EXPORT void writeNameGroup(QXmlStreamWriter& writer, QSharedPointer<MemoryBlockBase> memoryBlock, \n        Document::Revision docRevision);\n\n    /*!\n     *  Write the base address.\n     *\n     *    @param [in] writer          Used XML writer.\n     *    @param [in] memoryBlock     Selected memory block.\n     */\n    IPXACTMODELS_EXPORT void writeBaseAddress(QXmlStreamWriter& writer, QSharedPointer<MemoryBlockBase> memoryBlock);\n};\n\n#endif // ADDRESSBLOCKWRITER_H"
  },
  {
    "path": "IPXACTmodels/Component/MemoryMap.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: MemoryMap.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 01.10.2015\r\n//\r\n// Description:\r\n// Describes the ipxact:memoryMap element.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"MemoryMap.h\"\r\n\r\n#include \"MemoryRemap.h\"\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryMap::MemoryMap()\r\n//-----------------------------------------------------------------------------\r\nMemoryMap::MemoryMap(QString const& name):\r\nMemoryMapBase(name),\r\n    memoryRemaps_(new QList<QSharedPointer<MemoryRemap> > ()),\r\n    addressUnitBits_(),\r\n    shared_()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryMap::MemoryMap()\r\n//-----------------------------------------------------------------------------\r\nMemoryMap::MemoryMap(const MemoryMap& other):\r\nMemoryMapBase(other),\r\nmemoryRemaps_(new QList<QSharedPointer<MemoryRemap> > ()),\r\naddressUnitBits_(other.addressUnitBits_),\r\nshared_(other.shared_),\r\nmemoryMapDefinitionReference_(other.memoryMapDefinitionReference_),\r\ntypeDefinitionsReference_(other.typeDefinitionsReference_)\r\n\r\n{\r\n    copyMemoryRemaps(other);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryMap::operator=()\r\n//-----------------------------------------------------------------------------\r\nMemoryMap& MemoryMap::operator=(const MemoryMap& other)\r\n{\r\n    if (this != &other)\r\n    {\r\n        MemoryMapBase::operator=(other);\r\n\r\n        memoryRemaps_->clear();\r\n        copyMemoryRemaps(other);\r\n        \r\n        addressUnitBits_ = other.addressUnitBits_;\r\n        shared_ = other.shared_;\r\n        memoryMapDefinitionReference_ = other.memoryMapDefinitionReference_;\r\n        typeDefinitionsReference_ = other.typeDefinitionsReference_;\r\n\r\n    }\r\n\r\n    return *this;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: memorymap::~MemoryMap()\r\n//-----------------------------------------------------------------------------\r\nMemoryMap::~MemoryMap()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: memorymap::getMemoryRemaps()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<QList<QSharedPointer<MemoryRemap> > > MemoryMap::getMemoryRemaps() const\r\n{\r\n    return memoryRemaps_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryMap::setMemoryRemaps()\r\n//-----------------------------------------------------------------------------\r\nvoid MemoryMap::setMemoryRemaps(QSharedPointer<QList<QSharedPointer<MemoryRemap> > > newMemoryRemaps)\r\n{\r\n    memoryRemaps_ = newMemoryRemaps;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: memorymap::getAddressUnitBits()\r\n//-----------------------------------------------------------------------------\r\nQString MemoryMap::getAddressUnitBits(bool defaultIfEmpty /*= true*/) const\r\n{\r\n    if (addressUnitBits_.isEmpty() && defaultIfEmpty)\r\n    {\r\n        return QStringLiteral(\"8\");\r\n    }\r\n\r\n    return addressUnitBits_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: memorymap::setAddressUnitBits()\r\n//-----------------------------------------------------------------------------\r\nvoid MemoryMap::setAddressUnitBits(QString const& newAddressUnitBits)\r\n{\r\n\taddressUnitBits_ = newAddressUnitBits;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryMap::getShared()\r\n//-----------------------------------------------------------------------------\r\nQString MemoryMap::getShared() const\r\n{\r\n    return shared_.toString();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryMap::setShared()\r\n//-----------------------------------------------------------------------------\r\nvoid MemoryMap::setShared(bool newSharedStatus)\r\n{\r\n    shared_.setValue(newSharedStatus);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryMap::clearShared()\r\n//-----------------------------------------------------------------------------\r\nvoid MemoryMap::clearShared()\r\n{\r\n    shared_.setUnspecified();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryMap::getMemoryMapDefinitionReference()\r\n//-----------------------------------------------------------------------------\r\nQString MemoryMap::getMemoryMapDefinitionReference() const\r\n{\r\n    return memoryMapDefinitionReference_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryMap::setMemoryMapDefinitionReference()\r\n//-----------------------------------------------------------------------------\r\nvoid MemoryMap::setMemoryMapDefinitionReference(QString const& newDefinitionRef)\r\n{\r\n    memoryMapDefinitionReference_ = newDefinitionRef;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryMap::getTypeDefinitionsReference()\r\n//-----------------------------------------------------------------------------\r\nQString MemoryMap::getTypeDefinitionsReference() const\r\n{\r\n    return typeDefinitionsReference_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryMap::setTypeDefinitionsReference()\r\n//-----------------------------------------------------------------------------\r\nvoid MemoryMap::setTypeDefinitionsReference(QString const& newTypeDefinitionsRef)\r\n{\r\n    typeDefinitionsReference_ = newTypeDefinitionsRef;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryMap::copyMemoryRemaps()\r\n//-----------------------------------------------------------------------------\r\nvoid MemoryMap::copyMemoryRemaps(const MemoryMap& other)\r\n{\r\n    for (auto memoryRemap : *other.memoryRemaps_)\r\n    {\r\n        if (memoryRemap)\r\n        {\r\n            auto copy = QSharedPointer<MemoryRemap>(new MemoryRemap(*memoryRemap));\r\n            memoryRemaps_->append(copy);\r\n        }\r\n    }\r\n}"
  },
  {
    "path": "IPXACTmodels/Component/MemoryMap.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: MemoryMap.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 01.10.2015\r\n//\r\n// Description:\r\n// Describes the ipxact:memoryMap element.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef MEMORYMAP_H\r\n#define MEMORYMAP_H\r\n\r\n#include \"MemoryMapBase.h\"\r\n\r\n#include <IPXACTmodels/ipxactmodels_global.h>\r\n\r\n#include <IPXACTmodels/common/BooleanValue.h>\r\n\r\n#include <QDomNode>\r\n#include <QXmlStreamWriter>\r\n#include <QTextStream>\r\n\r\nclass MemoryRemap;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Describes the ipxact:memoryMap element.\r\n//-----------------------------------------------------------------------------\r\nclass IPXACTMODELS_EXPORT MemoryMap : public MemoryMapBase\r\n{\r\n\r\npublic:\r\n\r\n\t/*!\r\n\t *  The default constructor.\r\n\t */\r\n\tMemoryMap(QString const& name = QString());\r\n\r\n\t/*!\r\n\t *  Copy constructor.\r\n\t *\r\n\t *    @param [in] other   The memory map to be copied.\r\n\t */\r\n\tMemoryMap(const MemoryMap& other);\r\n\r\n\t/*!\r\n\t *  Assignment operator.\r\n\t *\r\n\t *    @param [in] other   The memory map being assigned.\r\n\t */\r\n\tMemoryMap& operator=(const MemoryMap& other);\r\n\r\n\t/*!\r\n\t *  The destructor.\r\n\t */\r\n\t~MemoryMap();\r\n\r\n    /*!\r\n     *  Get a pointer to the list containing the memory remaps of this memory map.\r\n     *\r\n     *    @return Pointer to the list containing the memory remaps of this memory map.\r\n     */\r\n    QSharedPointer<QList<QSharedPointer<MemoryRemap> > > getMemoryRemaps() const;\r\n\r\n    /*!\r\n     *  Set the memory remaps.\r\n     *\r\n     *    @param [in] newMemoryRemaps     Pointer to a list containing the new memory remaps.\r\n     */\r\n    void setMemoryRemaps(QSharedPointer<QList<QSharedPointer<MemoryRemap> > > newMemoryRemaps);\r\n\r\n    /*!\r\n\t *  Get the address unit bits value.\r\n\t *      \r\n     *    @param [in] defaultIfEmpty      Flag for returning the default AUB value (8 bits) if AUB is empty.\r\n     * \r\n     *    @return The address unit bit value.\r\n\t */\r\n    QString getAddressUnitBits(bool defaultIfEmpty = true) const;\r\n\r\n\t/*!\r\n\t *  Set the address unit bits for this memory map.\r\n\t *\r\n\t *    @param [in] newAddressUnitBits  Value to be set.\r\n\t */\r\n    void setAddressUnitBits(QString const& newAddressUnitBits);\r\n\r\n    /*!\r\n     *  Get the shared value.\r\n     *\r\n     *    @return The shared value.\r\n     */\r\n    QString getShared() const;\r\n\r\n    /*!\r\n     *  Set the shared value.\r\n     *\r\n     *    @param [in] newSharedStatus     The new shared value.\r\n     */\r\n    void setShared(bool newSharedStatus);\r\n\r\n    /*!\r\n     *  Set the shared value to unspecified.\r\n     */\r\n    void clearShared();\r\n\r\n    /*!\r\n     *\tGet the memory map definition reference.\r\n     *\r\n     * \t    @return The memory map definition reference.\r\n     */\r\n    QString getMemoryMapDefinitionReference() const;\r\n    \r\n    /*!\r\n     *\tSet the memory map definition reference.\r\n     *\r\n     *    @param [in] newDefinitionRef     The new definition reference.\r\n     */\r\n    void setMemoryMapDefinitionReference(QString const& newDefinitionRef);\r\n\r\n    /*!\r\n     *\tGet the type definitions reference of this memory remap.\r\n     *\r\n     *\r\n     * \t    @return The type definitions reference.\r\n     */\r\n    QString getTypeDefinitionsReference() const;\r\n\r\n    /*!\r\n     *\tSet the type definitions reference for this memory remap\r\n     *\r\n     *    @param [in] newTypeDefinitionsRef     The type definitions reference to set.\r\n     */\r\n    void setTypeDefinitionsReference(QString const& newTypeDefinitionsRef);\r\n\r\nprivate:\r\n\r\n    /*!\r\n     *  Copy the memory remaps.\r\n     *\r\n     *    @param [in] other   The memory map being copied.\r\n     */\r\n    void copyMemoryRemaps(const MemoryMap& other);\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! Memory remaps of the memory map.\r\n    QSharedPointer<QList<QSharedPointer<MemoryRemap> > > memoryRemaps_;\r\n\r\n\t//! Defines the number of data bits in each address increment of the memory map.\r\n    QString addressUnitBits_;\r\n\r\n    //! Defines the shared status.\r\n    BooleanValue shared_;\r\n\r\n    //! The referenced memory map definition.\r\n    QString memoryMapDefinitionReference_;\r\n\r\n    //! The referenced type definitions.\r\n    QString typeDefinitionsReference_;\r\n};\r\n\r\n#endif // MEMORYMAP_H\r\n"
  },
  {
    "path": "IPXACTmodels/Component/MemoryMapBase.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: MemoryMapBase.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 30.09.2015\r\n//\r\n// Description:\r\n// Contains common memory-map elements.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"MemoryMapBase.h\"\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryMapBase::MemoryMapBase()\r\n//-----------------------------------------------------------------------------\r\nMemoryMapBase::MemoryMapBase(QString const& name /* = QString() */):\r\nNameGroup(name),\r\nExtendable(),\r\nisPresent_(),\r\nmemoryBlocks_(new QList<QSharedPointer<MemoryBlockBase> > ())\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryMapBase::MemoryMapBase()\r\n//-----------------------------------------------------------------------------\r\nMemoryMapBase::MemoryMapBase(const MemoryMapBase& other):\r\nNameGroup(other),\r\nExtendable(other),\r\nisPresent_(other.isPresent_),\r\nmemoryBlocks_(new QList<QSharedPointer<MemoryBlockBase> > ())\r\n{\r\n    copyMemoryBlocks(other);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryMapBase::operator=()\r\n//-----------------------------------------------------------------------------\r\nMemoryMapBase& MemoryMapBase::operator=( const MemoryMapBase& other)\r\n{\r\n    if (this != &other)\r\n    {\r\n        NameGroup::operator=(other);\r\n        Extendable::operator=(other);\r\n        isPresent_ = other.isPresent_;\r\n\r\n        memoryBlocks_->clear();\r\n        copyMemoryBlocks(other);\r\n    }\r\n\r\n    return *this;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryMapBase::~MemoryMapBase()\r\n//-----------------------------------------------------------------------------\r\nMemoryMapBase::~MemoryMapBase()\r\n{\r\n    memoryBlocks_.clear();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryMapBase::elementName()\r\n//-----------------------------------------------------------------------------\r\nQString MemoryMapBase::elementName() const\r\n{\r\n    return QLatin1String(\"memory map\");\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryMapBase::getIsPresent()\r\n//-----------------------------------------------------------------------------\r\nQString MemoryMapBase::getIsPresent() const\r\n{\r\n    return isPresent_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryMapBase::setIsPresent()\r\n//-----------------------------------------------------------------------------\r\nvoid MemoryMapBase::setIsPresent(QString const& newIsPresent)\r\n{\r\n    isPresent_ = newIsPresent;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryMapBase::getMemoryBlocks()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<QList<QSharedPointer<MemoryBlockBase> > > MemoryMapBase::getMemoryBlocks() const\r\n{\r\n    return memoryBlocks_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryMapBase::setMemoryBlocks()\r\n//-----------------------------------------------------------------------------\r\nvoid MemoryMapBase::setMemoryBlocks(QSharedPointer<QList<QSharedPointer<MemoryBlockBase> > > newMemoryBlocks)\r\n{\r\n    memoryBlocks_->clear();\r\n    memoryBlocks_ = newMemoryBlocks;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryMapBase::hasMemoryBlocks()\r\n//-----------------------------------------------------------------------------\r\nbool MemoryMapBase::hasMemoryBlocks() const\r\n{\r\n    return !memoryBlocks_->isEmpty();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryMapBase::copyMemoryBlocks()\r\n//-----------------------------------------------------------------------------\r\nvoid MemoryMapBase::copyMemoryBlocks(const MemoryMapBase& other)\r\n{\r\n    foreach (QSharedPointer<MemoryBlockBase> memoryBlockBase, *other.memoryBlocks_)\r\n    {\r\n        if (memoryBlockBase)\r\n        {\r\n            QSharedPointer<MemoryBlockBase> copy = memoryBlockBase->clone();\r\n            memoryBlocks_->append(copy);\r\n        }\r\n    }\r\n}\r\n"
  },
  {
    "path": "IPXACTmodels/Component/MemoryMapBase.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: MemoryMapBase.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 30.09.2015\r\n//\r\n// Description:\r\n// Contains common memory-map elements.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef MEMORYMAPBASE_H\r\n#define MEMORYMAPBASE_H\r\n\r\n#include \"MemoryBlockBase.h\"\r\n\r\n#include <IPXACTmodels/common/NameGroup.h>\r\n#include <IPXACTmodels/ipxactmodels_global.h>\r\n#include <IPXACTmodels/Component/SubSpaceMap.h>\r\n\r\n#include <QList>\r\n#include <QString>\r\n#include <QSharedPointer>\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Contains common memory-map elements.\r\n//-----------------------------------------------------------------------------\r\nclass IPXACTMODELS_EXPORT MemoryMapBase : public NameGroup, public Extendable\r\n{\r\n\r\npublic:\r\n\r\n    /*!\r\n     *  [Description].\r\n     *\r\n     *    @param [in] name    Name of the memory map base.\r\n     */\r\n    MemoryMapBase(QString const& name = QString());\r\n\r\n    /*!\r\n     *  Copy constructor.\r\n     *\r\n     *    @param [in] other   The abstract memory map to be copied.\r\n     */\r\n    MemoryMapBase(const MemoryMapBase& other);\r\n\r\n    /*!\r\n     *  Assignment operator.\r\n     *\r\n     *    @param [in] other   The abstract memory map to be assigned.\r\n     */\r\n    MemoryMapBase &operator=(const MemoryMapBase& other);\r\n\r\n    /*!\r\n     *  The destructor.\r\n     */\r\n    virtual ~MemoryMapBase();\r\n    \r\n    /*!\r\n     *  Get the element name of the memory map.\r\n     *\r\n     *    @return Memory map for default memory maps.\r\n     */\r\n    virtual QString elementName() const;\r\n\r\n    /*!\r\n     *  Get the isPresent value.\r\n     *\r\n     *    @return The isPresent value.\r\n     */\r\n    QString getIsPresent() const;\r\n\r\n    /*!\r\n     *  Set the value for the isPresent.\r\n     *\r\n     *    @param [in] newIsPresent    The new IsPresent value.\r\n     */\r\n    void setIsPresent(QString const& newIsPresent);\r\n\r\n    /*!\r\n     *  Get a list of the contained memory map blocks.\r\n     *\r\n     *    @return Pointer to a list containing the memory blocks stored in this instance.\r\n     */\r\n    QSharedPointer<QList<QSharedPointer<MemoryBlockBase> > > getMemoryBlocks() const;\r\n\r\n    /*!\r\n     *  Set the memory map blocks for this memory map.\r\n     *\r\n     *    @param [in] newItems    A Pointer to a list containing the blocks to be stored in this memory map.\r\n     */\r\n    void setMemoryBlocks(QSharedPointer<QList<QSharedPointer<MemoryBlockBase> > > newMemoryBlocks);\r\n\r\n    /*!\r\n     *  Check if the memory map contains any sub items.\r\n     *\r\n     *    @return True, if the memory map contains sub items, false otherwise.\r\n     */\r\n    bool hasMemoryBlocks() const;\r\n\r\n    /*!\r\n     *  Check if the memory map contains any subspace maps.\r\n     *\r\n     *    @return True, if the memory map contains subspace items, false otherwise.\r\n     */\r\n    bool hasSubSpaceMaps() const;\r\n\r\nprivate:\r\n\r\n    /*!\r\n     *  Copy the contained memory blocks.\r\n     *\r\n     *    @param [in] other   The memory map base being copied.\r\n     */\r\n    void copyMemoryBlocks(const MemoryMapBase& other);\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! Defines the presence.\r\n    QString isPresent_;\r\n\r\n    //! Contains pointers to the contained memory blocks.\r\n    QSharedPointer<QList<QSharedPointer<MemoryBlockBase> > > memoryBlocks_;\r\n};\r\n\r\nQ_DECLARE_METATYPE(QSharedPointer<MemoryMapBase>);\r\n\r\n#endif // MEMORYMAPBASE_H\r\n"
  },
  {
    "path": "IPXACTmodels/Component/MemoryMapBaseReader.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: MemoryMapBaseReader.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Janne Virtanen\r\n// Date: 01.10.2015\r\n//\r\n// Description:\r\n// Reader class for ipxact:MemoryMapBase element.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"MemoryMapBaseReader.h\"\r\n#include \"MemoryMapBase.h\"\r\n\r\n#include \"AddressBlock.h\"\r\n#include \"MemoryBlockBase.h\"\r\n\r\n#include <IPXACTmodels/common/NameGroupReader.h>\r\n#include <IPXACTmodels/common/CommonItemsReader.h>\r\n#include <IPXACTmodels/Component/AddressBlockReader.h>\r\n#include <IPXACTmodels/Component/SubspaceMapReader.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryMapBaseReader::createMemoryMapBaseFrom()\r\n//-----------------------------------------------------------------------------\r\nvoid MemoryMapBaseReader::readMemoryMapBase(QDomNode const& MemoryMapBaseNode,\r\n\tQSharedPointer<MemoryMapBase> newMemoryMapBase,\r\n\tDocument::Revision docRevision)\r\n{\r\n    NameGroupReader::parseNameGroup(MemoryMapBaseNode, newMemoryMapBase);\r\n\r\n    if (docRevision == Document::Revision::Std14)\r\n    {\r\n        Details::parsePresence(MemoryMapBaseNode, newMemoryMapBase);\r\n    }\r\n\r\n    Details::parseMemoryBlocks(MemoryMapBaseNode, newMemoryMapBase, docRevision);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryMapBaseReader::Details::parseNameGroup()\r\n//-----------------------------------------------------------------------------\r\nvoid MemoryMapBaseReader::Details::parseNameGroup(QDomNode const& MemoryMapBaseBaseNode,\r\n    QSharedPointer<MemoryMapBase> newMemoryMapBaseBase)\r\n{\r\n    NameGroupReader::parseNameGroup(MemoryMapBaseBaseNode, newMemoryMapBaseBase);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryMapBaseReader::Details::parsePresence()\r\n//-----------------------------------------------------------------------------\r\nvoid MemoryMapBaseReader::Details::parsePresence(QDomNode const& MemoryMapBaseBaseNode,\r\n    QSharedPointer<MemoryMapBase> newMemoryMapBaseBase)\r\n{\r\n    QDomNode isPresentNode = MemoryMapBaseBaseNode.firstChildElement(QStringLiteral(\"ipxact:isPresent\"));\r\n    if (!isPresentNode.isNull())\r\n    {\r\n        QString isPresent = isPresentNode.firstChild().nodeValue();\r\n        newMemoryMapBaseBase->setIsPresent(isPresent);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryMapBaseReader::Details::parseMemoryBlocks()\r\n//-----------------------------------------------------------------------------\r\nvoid MemoryMapBaseReader::Details::parseMemoryBlocks(QDomNode const& memoryMapBaseNode,\r\n    QSharedPointer<MemoryMapBase> newMemoryMapBase,\r\n    Document::Revision docRevision)\r\n{\r\n    QDomNodeList childNodes = memoryMapBaseNode.childNodes();\r\n\r\n    for (int childIndex = 0; childIndex < childNodes.count(); ++childIndex)\r\n    {\r\n        QDomNode blockBaseNode = childNodes.at(childIndex);\r\n        if (blockBaseNode.nodeName() == QLatin1String(\"ipxact:addressBlock\"))\r\n        {\r\n            QSharedPointer<AddressBlock> newAddressBlock =\r\n                AddressBlockReader::createAddressBlockFrom(blockBaseNode, docRevision);\r\n\r\n            newMemoryMapBase->getMemoryBlocks()->append(newAddressBlock);\r\n        }\r\n        else if (blockBaseNode.nodeName() == QLatin1String(\"ipxact:subspaceMap\"))\r\n        {\r\n            QSharedPointer<SubSpaceMap> newSubSpaceMap = SubspaceMapReader::createSubspaceMapFrom(blockBaseNode, docRevision);\r\n\r\n            newMemoryMapBase->getMemoryBlocks()->append(newSubSpaceMap);\r\n        }\r\n    }\r\n}\r\n"
  },
  {
    "path": "IPXACTmodels/Component/MemoryMapBaseReader.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: MemoryMapBaseReader.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Janne Virtanen\r\n// Date: 01.10.2015\r\n//\r\n// Description:\r\n// Reader for ipxact:MemoryMapBase element.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef MemoryMapBaseREADER_H\r\n#define MemoryMapBaseREADER_H\r\n\r\n#include <IPXACTmodels/ipxactmodels_global.h>\r\n\r\n#include <IPXACTmodels/common/Document.h>\r\n\r\n#include <QSharedPointer>\r\n#include <QDomNode>\r\n\r\nclass MemoryMapBase;\r\nclass MemoryRemap;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Reader for ipxact:MemoryMapBase element.\r\n//-----------------------------------------------------------------------------\r\nnamespace MemoryMapBaseReader\r\n{\r\n\r\n    /*!\r\n     *  Creates a new memory map from a given memory map node.\r\n     *\r\n     *    @param [in] MemoryMapBaseNode   XML description of the memory map.\r\n     *\r\n     *    @return The created memory map.\r\n     */\r\n    IPXACTMODELS_EXPORT void readMemoryMapBase(QDomNode const& MemoryMapBaseNode, QSharedPointer<MemoryMapBase> newMemoryMapBase, Document::Revision docRevision);\r\n\r\n    namespace Details\r\n    {\r\n\r\n        /*!\r\n         *  Reads the name group.\r\n         *\r\n         *    @param [in] MemoryMapBaseBaseNode   XML description of the memory map base.\r\n         *    @param [in] newMemoryMapBaseBase    The new memory map base item.\r\n         */\r\n        void parseNameGroup(QDomNode const& MemoryMapBaseBaseNode, QSharedPointer<MemoryMapBase> newMemoryMapBase);\r\n\r\n        /*!\r\n         *  Reads the isPresent value.\r\n         *\r\n         *    @param [in] MemoryMapBaseBaseNode   XML description of the memory map base.\r\n         *    @param [in] newMemoryMapBaseBase    The new memory map base item.\r\n         */\r\n        void parsePresence(QDomNode const& MemoryMapBaseBaseNode, QSharedPointer<MemoryMapBase> newMemoryMapBase);\r\n\r\n        /*!\r\n         *  Reads the contained memory blocks.\r\n         *\r\n         *    @param [in] memoryMapBaseBaseNode   XML description of the memory map base.\r\n         *    @param [in] newMemoryMapBaseBase    The new memory map base item.\r\n         */\r\n        void parseMemoryBlocks(QDomNode const& memoryMapBaseNode, QSharedPointer<MemoryMapBase> newMemoryMapBase, Document::Revision docRevision);\r\n    }\r\n};\r\n\r\n#endif // MemoryMapBaseREADER_H"
  },
  {
    "path": "IPXACTmodels/Component/MemoryMapBaseWriter.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: MemoryMapBaseWriter.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Janne Virtanen\r\n// Date: 01.10.2015\r\n//\r\n// Description:\r\n// Writer for ipxact:MemoryMapBase element.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"MemoryMapBaseWriter.h\"\r\n#include \"MemoryMapBase.h\"\r\n#include \"AddressBlock.h\"\r\n\r\n#include <IPXACTmodels/common/CommonItemsWriter.h>\r\n#include <IPXACTmodels/common/NameGroupWriter.h>\r\n#include <IPXACTmodels/Component/SubSpaceMap.h>\r\n#include <IPXACTmodels/Component/AddressBlockWriter.h>\r\n#include <IPXACTmodels/Component/SubSpaceMapWriter.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryMapBaseWriter::writeMemoryMapBase()\r\n//-----------------------------------------------------------------------------\r\nvoid MemoryMapBaseWriter::writeMemoryMapBase(QXmlStreamWriter& writer, QSharedPointer<MemoryMapBase> MemoryMapBase,\r\n    Document::Revision docRevision)\r\n{\r\n    NameGroupWriter::writeNameGroup(writer, MemoryMapBase, docRevision);\r\n\r\n    CommonItemsWriter::writeIsPresent(writer, MemoryMapBase->getIsPresent());\r\n\r\n    Details::writeMemoryBlocks(writer, MemoryMapBase, docRevision);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryMapBaseWriter::writeNameGroup()\r\n//-----------------------------------------------------------------------------\r\nvoid MemoryMapBaseWriter::Details::writeNameGroup(QXmlStreamWriter& writer, QSharedPointer<MemoryMapBase> MemoryMapBase,\r\n    Document::Revision docRevision)\r\n{\r\n    NameGroupWriter::writeNameGroup(writer, MemoryMapBase, docRevision);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryMapBaseWriter::writeMemoryBlocks()\r\n//-----------------------------------------------------------------------------\r\nvoid MemoryMapBaseWriter::Details::writeMemoryBlocks(QXmlStreamWriter& writer, QSharedPointer<MemoryMapBase> MemoryMapBase, Document::Revision docRevision)\r\n{\r\n    if (!MemoryMapBase->getMemoryBlocks()->isEmpty())\r\n    {\r\n        for (auto const& memoryBlock : *MemoryMapBase->getMemoryBlocks())\r\n        {\r\n            QSharedPointer<AddressBlock> addressBlock = memoryBlock.dynamicCast<AddressBlock>();\r\n            if (addressBlock)\r\n            {\r\n                AddressBlockWriter::writeAddressBlock(writer, addressBlock, docRevision);\r\n            }\r\n\r\n            else if (QSharedPointer<SubSpaceMap> subspaceMap = memoryBlock.dynamicCast<SubSpaceMap>())\r\n            {\r\n                SubSpaceMapWriter::writeSubSpaceMap(writer, subspaceMap, docRevision);\r\n            }\r\n        }\r\n    }\r\n}\r\n"
  },
  {
    "path": "IPXACTmodels/Component/MemoryMapBaseWriter.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: MemoryMapBaseWriter.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Janne Virtanen\r\n// Date: 01.10.2015\r\n//\r\n// Description:\r\n// Writer for ipxact:MemoryMapBase element.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef MemoryMapBaseWRITER_H\r\n#define MemoryMapBaseWRITER_H\r\n\r\n#include <IPXACTmodels/ipxactmodels_global.h>\r\n\r\n#include <IPXACTmodels/common/Document.h>\r\n\r\n#include <QXmlStreamWriter>\r\n#include <QSharedPointer>\r\n\r\nclass MemoryMapBase;\r\nclass MemoryMapBaseBase;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Writer for ipxact:MemoryMapBase element.\r\n//-----------------------------------------------------------------------------\r\nnamespace MemoryMapBaseWriter\r\n{\r\n    /*!\r\n     *  Write a memory map to an XML file.\r\n     *\r\n     *    @param [in] writer          The used XML writer.\r\n     *    @param [in] MemoryMapBase   The memory map to be written.\r\n     *    @param [in] docRevision     The standard revision in use.\r\n     */\r\n    IPXACTMODELS_EXPORT void writeMemoryMapBase(QXmlStreamWriter& writer, QSharedPointer<MemoryMapBase> MemoryMapBase,\r\n        Document::Revision docRevision);\r\n\r\n    namespace Details\r\n    {\r\n\r\n        /*!\r\n         *  Write the name group.\r\n         *\r\n         *    @param [in] writer              Used XML writer.\r\n         *    @param [in] MemoryMapBaseBase   The selected memory map base.\r\n         *    @param [in] docRevision         The standard revision in use.\r\n         */\r\n        void writeNameGroup(QXmlStreamWriter& writer, QSharedPointer<MemoryMapBase> MemoryMapBase,\r\n            Document::Revision docRevision);\r\n\r\n        /*!\r\n         *  Write the memory blocks.\r\n         *\r\n         *    @param [in] writer              Used XML writer.\r\n         *    @param [in] MemoryMapBaseBase   The selected memory map base.\r\n         */\r\n        void writeMemoryBlocks(QXmlStreamWriter& writer, QSharedPointer<MemoryMapBase> MemoryMapBase, Document::Revision docRevision);\r\n    }\r\n}\r\n\r\n#endif // MemoryMapBaseWRITER_H"
  },
  {
    "path": "IPXACTmodels/Component/MemoryMapReader.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: MemoryMapReader.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 01.10.2015\r\n//\r\n// Description:\r\n// Reader for ipxact:memoryMap element.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"MemoryMapReader.h\"\r\n#include \"MemoryMapBaseReader.h\"\r\n#include \"MemoryMap.h\"\r\n#include \"MemoryRemap.h\"\r\n\r\n#include \"AddressBlock.h\"\r\n#include \"MemoryBlockBase.h\"\r\n\r\n#include <IPXACTmodels/common/NameGroupReader.h>\r\n#include <IPXACTmodels/Component/AddressBlockReader.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryMapReader::createMemoryMapFrom()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<MemoryMap> MemoryMapReader::createMemoryMapFrom(QDomNode const& memoryMapNode, Document::Revision docRevision)\r\n{\r\n    QSharedPointer<MemoryMap> newMemoryMap(new MemoryMap());\r\n\r\n\tMemoryMapBaseReader::readMemoryMapBase(memoryMapNode, newMemoryMap, docRevision);\r\n\r\n    Details::parseDefinitionReference(memoryMapNode, newMemoryMap, docRevision);\r\n\r\n    Details::parseMemoryRemaps(memoryMapNode, newMemoryMap, docRevision);\r\n\r\n    Details::parseAddressUnitBits(memoryMapNode, newMemoryMap);\r\n\r\n    Details::parseShared(memoryMapNode, newMemoryMap);\r\n\r\n    CommonItemsReader::parseVendorExtensions(memoryMapNode, newMemoryMap);\r\n\r\n    return newMemoryMap;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryMapReader::Details::parseMemoryRemaps()\r\n//-----------------------------------------------------------------------------\r\nvoid MemoryMapReader::Details::parseMemoryRemaps(QDomNode const& memoryMapNode, QSharedPointer<MemoryMap> newMemoryMap, Document::Revision docRevision)\r\n{\r\n    QDomNodeList memoryRemapNodeList = memoryMapNode.toElement().elementsByTagName(QStringLiteral(\"ipxact:memoryRemap\"));\r\n\r\n    for (int memoryRemapIndex = 0; memoryRemapIndex < memoryRemapNodeList.count(); ++memoryRemapIndex)\r\n    {\r\n        QDomElement remapElement = memoryRemapNodeList.at(memoryRemapIndex).toElement();\r\n\r\n        QSharedPointer<MemoryRemap> newMemoryRemap = createSingleMemoryRemap(remapElement, docRevision);\r\n\r\n        newMemoryMap->getMemoryRemaps()->append(newMemoryRemap);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryMapReader::Details::parseSingleMemoryRemap()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<MemoryRemap> MemoryMapReader::Details::createSingleMemoryRemap(QDomElement const& memoryRemapElement, Document::Revision docRevision)\r\n{\r\n    QSharedPointer<MemoryRemap> newMemoryRemap (new MemoryRemap());\r\n\r\n    if (docRevision == Document::Revision::Std14)\r\n    {\r\n        QString remapState = memoryRemapElement.attribute(QStringLiteral(\"state\"));\r\n        newMemoryRemap->setRemapState(remapState);\r\n        MemoryMapBaseReader::Details::parsePresence(memoryRemapElement, newMemoryRemap);\r\n    }\r\n    else if (docRevision == Document::Revision::Std22)\r\n    {\r\n        newMemoryRemap->setModeReferences(CommonItemsReader::parseModeReferences(memoryRemapElement));\r\n\r\n        auto definitionRefElement = memoryRemapElement.firstChildElement(\r\n            QStringLiteral(\"ipxact:remapDefinitionRef\"));\r\n\r\n        newMemoryRemap->setMemoryRemapDefinitionReference(definitionRefElement.firstChild().nodeValue());\r\n\r\n        newMemoryRemap->setTypeDefinitionsReference(definitionRefElement.attribute(\r\n            QStringLiteral(\"typeDefinitions\")));\r\n    }\r\n\r\n    NameGroupReader::parseNameGroup(memoryRemapElement, newMemoryRemap);\r\n\r\n    MemoryMapBaseReader::Details::parseMemoryBlocks(memoryRemapElement, newMemoryRemap, docRevision);\r\n\r\n    return newMemoryRemap;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryMapReader::Details::parseAddressUnitBits()\r\n//-----------------------------------------------------------------------------\r\nvoid MemoryMapReader::Details::parseAddressUnitBits(QDomNode const& memoryMapNode, QSharedPointer<MemoryMap> newMemoryMap)\r\n   \r\n{\r\n    QDomNode addressUnitBitsNode = memoryMapNode.firstChildElement(QStringLiteral(\"ipxact:addressUnitBits\"));\r\n    if (!addressUnitBitsNode.isNull())\r\n    {\r\n        QString addressUnitBits = addressUnitBitsNode.firstChild().nodeValue();\r\n        newMemoryMap->setAddressUnitBits(addressUnitBits);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryMapReader::Details::parseShared()\r\n//-----------------------------------------------------------------------------\r\nvoid MemoryMapReader::Details::parseShared(QDomNode const& memoryMapNode, QSharedPointer<MemoryMap> newMemoryMap)\r\n{\r\n    QDomNode sharedNode = memoryMapNode.firstChildElement(QStringLiteral(\"ipxact:shared\"));\r\n    if (!sharedNode.isNull())\r\n    {\r\n        QString sharedValue = sharedNode.firstChild().nodeValue();\r\n        if (sharedValue == QLatin1String(\"yes\"))\r\n        {\r\n            newMemoryMap->setShared(true);\r\n        }\r\n        else if (sharedValue == QLatin1String(\"no\"))\r\n        {\r\n            newMemoryMap->setShared(false);\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryMapReader::Details::parseDefinitionReference()\r\n//-----------------------------------------------------------------------------\r\nvoid MemoryMapReader::Details::parseDefinitionReference(QDomNode const& memoryMapNode, QSharedPointer<MemoryMap> newMemoryMap, Document::Revision docRevision)\r\n{\r\n    if (docRevision == Document::Revision::Std22)\r\n    {\r\n        auto definitionRefElement = memoryMapNode.firstChildElement(QStringLiteral(\"ipxact:memoryMapDefinitionRef\"));\r\n\r\n        newMemoryMap->setMemoryMapDefinitionReference(definitionRefElement.firstChild().nodeValue());\r\n        newMemoryMap->setTypeDefinitionsReference(definitionRefElement.attribute(QStringLiteral(\"typeDefinitions\")));\r\n    }\r\n}\r\n"
  },
  {
    "path": "IPXACTmodels/Component/MemoryMapReader.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: MemoryMapReader.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 01.10.2015\r\n//\r\n// Description:\r\n// Reader for ipxact:memoryMap element.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef MEMORYMAPREADER_H\r\n#define MEMORYMAPREADER_H\r\n\r\n#include <IPXACTmodels/ipxactmodels_global.h>\r\n\r\n#include <IPXACTmodels/common/CommonItemsReader.h>\r\n\r\n#include <QSharedPointer>\r\n#include <QDomNode>\r\n\r\nclass MemoryMap;\r\nclass MemoryMapBase;\r\nclass MemoryRemap;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Reader for ipxact:memoryMap element.\r\n//-----------------------------------------------------------------------------\r\nnamespace MemoryMapReader\r\n{\r\n    /*!\r\n     *  Creates a new memory map from a given memory map node.\r\n     *\r\n     *    @param [in] memoryMapNode   XML description of the memory map.\r\n     *\r\n     *    @return The created memory map.\r\n     */\r\n    IPXACTMODELS_EXPORT QSharedPointer<MemoryMap> createMemoryMapFrom(QDomNode const& memoryMapNode, Document::Revision docRevision);\r\n\r\n    namespace Details\r\n    {\r\n\r\n        /*!\r\n         *  Reads the memory remaps.\r\n         *\r\n         *    @param [in] memoryMapNode   XML description of the memory map.\r\n         *    @param [in] newMemoryMap    The new memory map item.\r\n         */\r\n        void parseMemoryRemaps(QDomNode const& memoryMapNode, QSharedPointer<MemoryMap> newMemoryMap, Document::Revision docRevision);\r\n\r\n        /*!\r\n         *  Creates a new memory remap from a given memory remap element.\r\n         *\r\n         *    @param [in] memoryRemapElement  XML description of the memory remap.\r\n         *\r\n         *    @return Pointer to the created memory remap.\r\n         */\r\n        QSharedPointer<MemoryRemap> createSingleMemoryRemap(QDomElement const& memoryRemapElement, Document::Revision docRevision);\r\n\r\n        /*!\r\n         *  Reads the address unit bits.\r\n         *\r\n         *    @param [in] memoryMapNode   XML description of the memory map.\r\n         *    @param [in] newMemoryMap    The new memory map item.\r\n         */\r\n        void parseAddressUnitBits(QDomNode const& memoryMapNode, QSharedPointer<MemoryMap> newMemoryMap);\r\n\r\n        /*!\r\n         *  Reads the shared value.\r\n         *\r\n         *    @param [in] memoryMapNode   XML description of the memory map.\r\n         *    @param [in] newMemoryMap    The new memory map item.\r\n         */\r\n        void parseShared(QDomNode const& memoryMapNode, QSharedPointer<MemoryMap> newMemoryMap);\r\n\r\n        void parseDefinitionReference(QDomNode const& memoryMapNode, QSharedPointer<MemoryMap> newMemoryMap, Document::Revision docRevision);\r\n    }\r\n}\r\n\r\n#endif // MEMORYMAPREADER_H"
  },
  {
    "path": "IPXACTmodels/Component/MemoryMapWriter.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: MemoryMapWriter.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 01.10.2015\r\n//\r\n// Description:\r\n// Writer for ipxact:memoryMap element.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"MemoryMapWriter.h\"\r\n#include \"MemoryMap.h\"\r\n#include \"MemoryRemap.h\"\r\n#include \"MemoryMapBase.h\"\r\n\r\n#include \"AddressBlock.h\"\r\n#include \"MemoryMapBaseWriter.h\"\r\n\r\n#include <IPXACTmodels/common/CommonItemsWriter.h>\r\n#include <IPXACTmodels/common/NameGroupWriter.h>\r\n#include <IPXACTmodels/Component/AddressBlockWriter.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryMapWriter::writeMemoryMap()\r\n//-----------------------------------------------------------------------------\r\nvoid MemoryMapWriter::writeMemoryMap(QXmlStreamWriter& writer, QSharedPointer<MemoryMap> memoryMap, \r\n    Document::Revision docRevision)\r\n{\r\n    writer.writeStartElement(QStringLiteral(\"ipxact:memoryMap\"));\r\n\r\n    if (docRevision == Document::Revision::Std14)\r\n    {\r\n\t    MemoryMapBaseWriter::writeMemoryMapBase(writer, memoryMap, docRevision);\r\n\r\n        Details::writeMemoryRemaps(writer, memoryMap, docRevision);\r\n\r\n        Details::writeAddressUnitBits(writer, memoryMap);\r\n\r\n        Details::writeShared(writer, memoryMap);\r\n\r\n        CommonItemsWriter::writeVendorExtensions(writer, memoryMap);\r\n    }\r\n    else if (docRevision == Document::Revision::Std22)\r\n    {\r\n        NameGroupWriter::writeNameGroup(writer, memoryMap, docRevision);\r\n\r\n        Details::writeMemoryMapDefinitionReference(writer, memoryMap);\r\n\r\n        MemoryMapBaseWriter::Details::writeMemoryBlocks(writer, memoryMap, docRevision);\r\n\r\n        Details::writeMemoryRemaps(writer, memoryMap, docRevision);\r\n\r\n        Details::writeAddressUnitBits(writer, memoryMap);\r\n\r\n        Details::writeShared(writer, memoryMap);\r\n\r\n        CommonItemsWriter::writeVendorExtensions(writer, memoryMap);\r\n    }\r\n\r\n    writer.writeEndElement(); // ipxact:memoryMap\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryMapWriter::Details::writeMemoryRemaps()\r\n//-----------------------------------------------------------------------------\r\nvoid MemoryMapWriter::Details::writeMemoryRemaps(QXmlStreamWriter& writer, QSharedPointer<MemoryMap> memoryMap, \r\n    Document::Revision docRevision)\r\n{\r\n    for (auto const& memoryRemap : *memoryMap->getMemoryRemaps())\r\n    {\r\n        writer.writeStartElement(QStringLiteral(\"ipxact:memoryRemap\"));\r\n\r\n        if (docRevision == Document::Revision::Std14)\r\n        {\r\n            writer.writeAttribute(QStringLiteral(\"state\"), memoryRemap->getRemapState());\r\n\r\n            NameGroupWriter::writeNameGroup(writer, memoryRemap, docRevision);\r\n\r\n            CommonItemsWriter::writeIsPresent(writer, memoryRemap->getIsPresent());\r\n\r\n            MemoryMapBaseWriter::Details::writeMemoryBlocks(writer, memoryRemap, docRevision);\r\n        }\r\n        else if (docRevision == Document::Revision::Std22)\r\n        {\r\n            NameGroupWriter::writeNameGroup(writer, memoryRemap, docRevision);\r\n\r\n            CommonItemsWriter::writeModeReferences(writer, memoryRemap->getModeReferences());\r\n\r\n            writeRemapDefinitionReference(writer, memoryRemap);\r\n\r\n            MemoryMapBaseWriter::Details::writeMemoryBlocks(writer, memoryRemap, docRevision);\r\n\r\n            CommonItemsWriter::writeVendorExtensions(writer, memoryRemap);\r\n        }\r\n\r\n        writer.writeEndElement(); // ipxact:memoryRemap\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryMapWriter::Details::writeAddressUnitBits()\r\n//-----------------------------------------------------------------------------\r\nvoid MemoryMapWriter::Details::writeAddressUnitBits(QXmlStreamWriter& writer, QSharedPointer<MemoryMap> memoryMap)\r\n{\r\n    CommonItemsWriter::writeNonEmptyElement(writer, QStringLiteral(\"ipxact:addressUnitBits\"),\r\n        memoryMap->getAddressUnitBits(false));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryMapWriter::Details::writeShared()\r\n//-----------------------------------------------------------------------------\r\nvoid MemoryMapWriter::Details::writeShared(QXmlStreamWriter& writer, QSharedPointer<MemoryMap> memoryMap)\r\n{\r\n    if (!memoryMap->getShared().isEmpty())\r\n    {\r\n        writer.writeStartElement(QStringLiteral(\"ipxact:shared\"));\r\n\r\n        if (memoryMap->getShared() == QLatin1String(\"true\"))\r\n        {\r\n            writer.writeCharacters(QStringLiteral(\"yes\"));\r\n        }\r\n        else\r\n        {\r\n            writer.writeCharacters(QStringLiteral(\"no\"));\r\n        }\r\n\r\n        writer.writeEndElement(); // ipxact:shared\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryMapWriter::Details::writeMemoryMapDefinitionReference()\r\n//-----------------------------------------------------------------------------\r\nvoid MemoryMapWriter::Details::writeMemoryMapDefinitionReference(QXmlStreamWriter& writer, \r\n    QSharedPointer<MemoryMap> memoryMap)\r\n{\r\n    if (!memoryMap->getMemoryMapDefinitionReference().isEmpty())\r\n    {\r\n        writer.writeStartElement(QStringLiteral(\"ipxact:memoryMapDefinitionRef\"));\r\n\r\n        CommonItemsWriter::writeNonEmptyAttribute(writer, QStringLiteral(\"typeDefinitions\"),\r\n            memoryMap->getTypeDefinitionsReference());\r\n\r\n        writer.writeCharacters(memoryMap->getMemoryMapDefinitionReference());\r\n\r\n        writer.writeEndElement(); // ipxact:remapDefinitionRef\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryMapWriter::Details::writeRemapDefinitionReference()\r\n//-----------------------------------------------------------------------------\r\nvoid MemoryMapWriter::Details::writeRemapDefinitionReference(QXmlStreamWriter& writer, \r\n    QSharedPointer<MemoryRemap> memoryRemap)\r\n{\r\n    if (!memoryRemap->getMemoryRemapDefinitionReference().isEmpty())\r\n    {\r\n        writer.writeStartElement(QStringLiteral(\"ipxact:remapDefinitionRef\"));\r\n\r\n        CommonItemsWriter::writeNonEmptyAttribute(writer, QStringLiteral(\"typeDefinitions\"),\r\n            memoryRemap->getTypeDefinitionsReference());\r\n\r\n        writer.writeCharacters(memoryRemap->getMemoryRemapDefinitionReference());\r\n\r\n        writer.writeEndElement(); // ipxact:remapDefinitionRef\r\n    }\r\n}\r\n"
  },
  {
    "path": "IPXACTmodels/Component/MemoryMapWriter.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: MemoryMapWriter.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 01.10.2015\r\n//\r\n// Description:\r\n// Writer for ipxact:memoryMap element.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef MEMORYMAPWRITER_H\r\n#define MEMORYMAPWRITER_H\r\n\r\n#include <IPXACTmodels/ipxactmodels_global.h>\r\n\r\n#include <IPXACTmodels/common/Document.h>\r\n\r\n#include <QXmlStreamWriter>\r\n#include <QSharedPointer>\r\n\r\nclass MemoryMap;\r\nclass MemoryRemap;\r\nclass MemoryMapBase;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Writer for ipxact:memoryMap element.\r\n//-----------------------------------------------------------------------------\r\nnamespace MemoryMapWriter\r\n{\r\n\r\n    /*!\r\n     *  Write a memory map to an XML file.\r\n     *\r\n     *    @param [in] writer        The used XML writer.\r\n     *    @param [in] memoryMap     The memory map to be written.\r\n     *    @param [in] docRevision   The standard revision in use.\r\n     */\r\n    IPXACTMODELS_EXPORT void writeMemoryMap(QXmlStreamWriter& writer, QSharedPointer<MemoryMap> memoryMap, Document::Revision docRevision);\r\n\r\n    namespace Details\r\n    {\r\n\r\n        /*!\r\n         *  Write the memory remaps.\r\n         *\r\n         *    @param [in] writer      Used XML writer.\r\n         *    @param [in] memoryMap   The selected memory map.\r\n         *    @param [in] docRevision     The standard revision in use.\r\n         */\r\n        void writeMemoryRemaps(QXmlStreamWriter& writer, QSharedPointer<MemoryMap> memoryMap, Document::Revision docRevision);\r\n\r\n        /*!\r\n         *  Write the address unit bits.\r\n         *\r\n         *    @param [in] writer      Used XML writer.\r\n         *    @param [in] memoryMap   The selected memory map.\r\n\r\n\r\n         */\r\n        void writeAddressUnitBits(QXmlStreamWriter& writer, QSharedPointer<MemoryMap> memoryMap);\r\n\r\n        /*!\r\n         *  Write the shared value.\r\n         *\r\n         *    @param [in] writer      Used XML writer.\r\n         *    @param [in] memoryMap   The selected memory map.\r\n         */\r\n        void writeShared(QXmlStreamWriter& writer, QSharedPointer<MemoryMap> memoryMap);\r\n\r\n        /*!\r\n         *\tWrite the definition reference of the memory map.\r\n         *  \r\n         *    @param [in] writer      Used XML writer.\r\n         *    @param [in] memoryMap   The selected memory map.\r\n         */\r\n        void writeMemoryMapDefinitionReference(QXmlStreamWriter& writer, QSharedPointer<MemoryMap> memoryMap);\r\n\r\n        /*!\r\n         *\tWrite the definition reference of the memory remap.\r\n         *\r\n         *    @param [in] writer        Used XML writer.\r\n         *    @param [in] memoryRemap   The selected memory remap.\r\n         */\r\n        void writeRemapDefinitionReference(QXmlStreamWriter& writer, QSharedPointer<MemoryRemap> memoryRemap);\r\n    }\r\n}\r\n\r\n#endif // MEMORYMAPWRITER_H"
  },
  {
    "path": "IPXACTmodels/Component/MemoryRemap.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: MemoryRemap.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 01.10.2015\r\n//\r\n// Description:\r\n// Describes the ipxact:memoryRemap element.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"MemoryRemap.h\"\r\n\r\n#include <IPXACTmodels/Component/ModeReference.h>\r\n\r\n#include <IPXACTmodels/utilities/Copy.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryRemap::MemoryRemap()\r\n//-----------------------------------------------------------------------------\r\nMemoryRemap::MemoryRemap(QString const& name /* = QString() */, QString const& remapState /* = QString() */):\r\nMemoryMapBase(name),\r\nremapState_(remapState)\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryRemap::MemoryRemap()\r\n//-----------------------------------------------------------------------------\r\nMemoryRemap::MemoryRemap(const MemoryRemap& other):\r\nMemoryMapBase(other),\r\nremapState_(other.remapState_),\r\nmemoryRemapDefinitionReference_(other.memoryRemapDefinitionReference_),\r\ntypeDefinitionsReference_(other.typeDefinitionsReference_)\r\n{\r\n    Copy::copyList(other.modeReferences_, modeReferences_);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryRemap::operator=()\r\n//-----------------------------------------------------------------------------\r\nMemoryRemap& MemoryRemap::operator=(const MemoryRemap& other)\r\n{\r\n    if (this != &other)\r\n    {\r\n        MemoryMapBase::operator=(other);\r\n        remapState_ = other.remapState_;\r\n        memoryRemapDefinitionReference_ = other.memoryRemapDefinitionReference_;\r\n        typeDefinitionsReference_ = other.typeDefinitionsReference_;\r\n\r\n        modeReferences_->clear();\r\n        Copy::copyList(other.modeReferences_, modeReferences_);\r\n    }\r\n\r\n    return *this;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryRemap::~MemoryRemap()\r\n//-----------------------------------------------------------------------------\r\nMemoryRemap::~MemoryRemap()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryRemap::elementName()\r\n//-----------------------------------------------------------------------------\r\nQString MemoryRemap::elementName() const\r\n{\r\n    return QLatin1String(\"memory remap\");\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryRemap::getRemapState()\r\n//-----------------------------------------------------------------------------\r\nQString MemoryRemap::getRemapState() const\r\n{\r\n    return remapState_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryRemap::setRemapState()\r\n//-----------------------------------------------------------------------------\r\nvoid MemoryRemap::setRemapState(QString newRemapState)\r\n{\r\n    remapState_ = newRemapState;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryRemap::getMemoryRemapDefinitionReference()\r\n//-----------------------------------------------------------------------------\r\nQString MemoryRemap::getMemoryRemapDefinitionReference() const\r\n{\r\n    return memoryRemapDefinitionReference_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryRemap::setMemoryRemapDefinitionReference()\r\n//-----------------------------------------------------------------------------\r\nvoid MemoryRemap::setMemoryRemapDefinitionReference(QString const& newDefinitionRef)\r\n{\r\n    memoryRemapDefinitionReference_ = newDefinitionRef;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryRemap::getTypeDefinitionsReference()\r\n//-----------------------------------------------------------------------------\r\nQString MemoryRemap::getTypeDefinitionsReference() const\r\n{\r\n    return typeDefinitionsReference_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryRemap::setTypeDefinitionsReference()\r\n//-----------------------------------------------------------------------------\r\nvoid MemoryRemap::setTypeDefinitionsReference(QString const& newTypeDefinitionsRef)\r\n{\r\n    typeDefinitionsReference_ = newTypeDefinitionsRef;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryRemap::getModeReferences()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<QList<QSharedPointer<ModeReference> > > MemoryRemap::getModeReferences() const\r\n{\r\n    return modeReferences_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryRemap::setModeReferences()\r\n//-----------------------------------------------------------------------------\r\nvoid MemoryRemap::setModeReferences(QSharedPointer<QList<QSharedPointer<ModeReference> > > newModeRefs)\r\n{\r\n    modeReferences_ = newModeRefs;\r\n}\r\n"
  },
  {
    "path": "IPXACTmodels/Component/MemoryRemap.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: MemoryRemap.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 01.10.2015\r\n//\r\n// Description:\r\n// Describes the ipxact:memoryRemap element.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef MEMORYREMAP_H\r\n#define MEMORYREMAP_H\r\n\r\n#include <IPXACTmodels/ipxactmodels_global.h>\r\n\r\n#include <IPXACTmodels/Component/MemoryMapBase.h>\r\n\r\n#include <QSharedPointer>\r\n#include <QDomNode>\r\n#include <QXmlStreamWriter>\r\n#include <QTextStream>\r\n\r\nclass ModeReference;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Describes the ipxact:memoryRemap element.\r\n//-----------------------------------------------------------------------------\r\nclass IPXACTMODELS_EXPORT MemoryRemap : public MemoryMapBase\r\n{\r\n\r\npublic:\r\n\r\n    /*!\r\n     *  The constructor.\r\n     *\r\n     *    @param [in] name        Name of the memory remap.\r\n     *    @param [in] remapState  The remap state refered by the memory remap.\r\n     */\r\n    MemoryRemap(QString const& name = QString(), QString const& remapState = QString());\r\n\r\n    /*!\r\n     *  Copy constructor.\r\n     *\r\n     *    @param [in] other   The memory remap being copied.\r\n     */\r\n    MemoryRemap(const MemoryRemap& other);\r\n\r\n    /*!\r\n     *  Assignment operator.\r\n     *\r\n     *    @param [in] other   The memory remap being assigned.\r\n     */\r\n    MemoryRemap& operator=(const MemoryRemap& other);\r\n\r\n    /*!\r\n     *  The destructor.\r\n     */\r\n    ~MemoryRemap();\r\n\r\n    /*!\r\n     *  Get the element name of the memory remap.\r\n     *\r\n     *    @return QString containing \"Memory remap\".\r\n     */\r\n    virtual QString elementName() const;\r\n\r\n    /*!\r\n     *  Get the remap state of the memory remap.\r\n     *\r\n     *    @return The name of the remap state of the memory remap.\r\n     */\r\n    QString getRemapState() const;\r\n\r\n    /*!\r\n     *  Set the remap state of the memory remap.\r\n     *\r\n     *    @param [in] newRemapState   The name of the new remap state of the memory remap.\r\n     */\r\n    void setRemapState(QString newRemapState);\r\n\r\n    /*!\r\n     *\tGet the memory remap definition reference.\r\n     *  \r\n     * \t    @return The memory remap definition reference.\r\n     */\r\n    QString getMemoryRemapDefinitionReference() const;\r\n\r\n    /*!\r\n     *\tSet the memory remap definition reference.\r\n     *  \r\n     *    @param [in] newDefinitionRef     The new definition reference.\r\n     */\r\n    void setMemoryRemapDefinitionReference(QString const& newDefinitionRef);\r\n\r\n    /*!\r\n     *\tGet the type definitions reference of this memory remap.\r\n     *  \r\n     *\t    \r\n     * \t    @return The type definitions reference.\r\n     */\r\n    QString getTypeDefinitionsReference() const;\r\n\r\n    /*!\r\n     *\tSet the type definitions reference for this memory remap\r\n     *  \r\n     *    @param [in] newTypeDefinitionsRef     The type definitions reference to set.\r\n     */\r\n    void setTypeDefinitionsReference(QString const& newTypeDefinitionsRef);\r\n\r\n    /*!\r\n     *\tGet the remap mode references.\r\n     *  \r\n     * \t    @return The mode references of the memory remap.\r\n     */\r\n    QSharedPointer<QList<QSharedPointer<ModeReference> > > getModeReferences() const;\r\n\r\n    /*!\r\n     *\tSet the mode references of the remap.\r\n     *  \r\n     *    @param [in] newModeRefs     The mode references to set.\r\n     */\r\n    void setModeReferences(QSharedPointer<QList<QSharedPointer<ModeReference> > > newModeRefs);\r\n\r\nprivate:\r\n\r\n    //! The remap state of this memory remap.\r\n    QString remapState_;\r\n\r\n    //! The referenced memory remap type definition.\r\n    QString memoryRemapDefinitionReference_;\r\n\r\n    //! The referenced type definitions.\r\n    QString typeDefinitionsReference_;\r\n\r\n    //! The mode references of the memory remap.\r\n    QSharedPointer<QList<QSharedPointer<ModeReference> > > modeReferences_ =\r\n        QSharedPointer<QList<QSharedPointer<ModeReference> > >(new QList<QSharedPointer<ModeReference> >());\r\n\r\n};\r\n\r\n#endif // MEMORYREMAP_H_\r\n"
  },
  {
    "path": "IPXACTmodels/Component/MirroredTargetInterface.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: MirroredTargetInterface.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Esko Pekkarinen\r\n// Date: 29.06.2023\r\n//\r\n// Description:\r\n// Implementation of ipxact:mirroredTarget in bus interface.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"MirroredTargetInterface.h\"\r\n\r\n#include <QMap>\r\n#include <QString>\r\n#include <QObject>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MirroredSlaveInterface::RemapAddress::RemapAddress()\r\n//-----------------------------------------------------------------------------\r\nMirroredTargetInterface::RemapAddress::RemapAddress(QString const& remapAddress):\r\nremapAddress_(remapAddress)\r\n{\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MirroredSlaveInterface::MirroredSlaveInterface()\r\n//-----------------------------------------------------------------------------\r\nMirroredTargetInterface::MirroredTargetInterface()\r\n{\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MirroredSlaveInterface::MirroredSlaveInterface()\r\n//-----------------------------------------------------------------------------\r\nMirroredTargetInterface::MirroredTargetInterface(MirroredTargetInterface const& other):\r\nrange_(other.range_)\r\n{\r\n    for (QSharedPointer<RemapAddress> remapAddr : *other.remapAddresses_)\r\n    {\r\n        QSharedPointer<RemapAddress> copy(new RemapAddress(*remapAddr));\r\n        remapAddresses_->append(copy);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MirroredSlaveInterface::operator=()\r\n//-----------------------------------------------------------------------------\r\nMirroredTargetInterface& MirroredTargetInterface::operator=(MirroredTargetInterface const& other)\r\n{\r\n\tif (this != &other)\r\n    {\r\n\t\trange_ = other.range_;\r\n\r\n        remapAddresses_->clear();\r\n        for (QSharedPointer<RemapAddress> remapAddr : *other.remapAddresses_)\r\n        {\r\n            QSharedPointer<RemapAddress> copy(new RemapAddress(*remapAddr));\r\n            remapAddresses_->append(copy);\r\n        }\r\n\r\n    }\r\n    return *this;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MirroredSlaveInterface::~MirroredSlaveInterface()\r\n//-----------------------------------------------------------------------------\r\nMirroredTargetInterface::~MirroredTargetInterface()\r\n{\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MirroredSlaveInterface::getRange()\r\n//-----------------------------------------------------------------------------\r\nQString MirroredTargetInterface::getRange() const\r\n{\r\n\treturn range_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MirroredSlaveInterface::setRange()\r\n//-----------------------------------------------------------------------------\r\nvoid MirroredTargetInterface::setRange(const QString& range)\r\n{\r\n\trange_ = range;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: mirroredslaveinterface::getRemapAddress()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<QList<QSharedPointer<MirroredTargetInterface::RemapAddress> > > \r\n    MirroredTargetInterface::getRemapAddresses() const\r\n{\r\n\treturn remapAddresses_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MirroredSlaveInterface::setRemapAddress()\r\n//-----------------------------------------------------------------------------\r\nvoid MirroredTargetInterface::setRemapAddress(QString const& newRemapAddress)\r\n{\r\n    if (!newRemapAddress.isEmpty())\r\n    {\r\n        if (getRemapAddresses()->isEmpty())\r\n        {\r\n            QSharedPointer<RemapAddress> remapAddress (new RemapAddress(newRemapAddress));\r\n            getRemapAddresses()->append(remapAddress);\r\n        }\r\n        else\r\n        {\r\n            QSharedPointer<RemapAddress> firstRemapAddress = remapAddresses_->first();\r\n            firstRemapAddress->remapAddress_ = newRemapAddress;\r\n        }\r\n    }\r\n    else\r\n    {\r\n        if (!getRemapAddresses()->isEmpty())\r\n        {\r\n            getRemapAddresses()->removeFirst();\r\n        }\r\n    }\r\n}\r\n"
  },
  {
    "path": "IPXACTmodels/Component/MirroredTargetInterface.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: MirroredTargetInterface.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Esko Pekkarinen\r\n// Date: 29.06.2023\r\n//\r\n// Description:\r\n// Implementation of ipxact:mirroredTarget in bus interface.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef MIRRORED_TARGET_INTERFACE_H_\r\n#define MIRRORED_TARGET_INTERFACE_H_\r\n\r\n#include <IPXACTmodels/ipxactmodels_global.h>\r\n\r\n#include <QString>\r\n#include <QMap>\r\n#include <QList>\r\n#include <QSharedPointer>\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Implementation of ipxact:mirroredTarget in bus interface.\r\n//-----------------------------------------------------------------------------\r\nclass IPXACTMODELS_EXPORT MirroredTargetInterface\r\n{\r\npublic:\r\n\r\n\t//! Implementation of ipxact:remapAddress element in mirrored target.\r\n\tstruct RemapAddress\r\n    {\r\n\t\t//! The address offset to apply to the connected target interface.\r\n\t\tQString remapAddress_;\r\n\r\n\t\t//! The remap state for which the remapAddress and range apply.\t\t \r\n\t\tQString state_;\r\n\r\n\t\t//! Any other attributes specified for the remapAddress.\t\t \r\n\t\tQMap<QString, QString> remapAttributes_;\r\n\r\n\t\t//! The mode references.\r\n\t\tQStringList modeRefs_;\r\n\r\n\t\t//! The mode priorities.\r\n\t\tQMap<QString, unsigned int> priorities_;\r\n\r\n\t\t/*! The constructor.\r\n\t\t *\r\n\t\t *    @param [in] remapAddress The remap address to set.\r\n\t\t*/\r\n\t\tIPXACTMODELS_EXPORT explicit RemapAddress(QString const& remapAddress);\r\n\t};\r\n\r\n\t//! The default constructor.\r\n\tMirroredTargetInterface();\r\n\r\n\t//! Copy constructor\r\n\tMirroredTargetInterface(const MirroredTargetInterface& other);\r\n\r\n\t//! Assignment operator\r\n\tMirroredTargetInterface& operator=(const MirroredTargetInterface& other);\r\n\r\n\t/*! The destructor\r\n\t *\r\n\t */\r\n\t~MirroredTargetInterface();\r\n\r\n\t/*! Get the range of the mirrored target interface.\r\n\t *\r\n\t *    @return The range.\r\n\t */\r\n\tQString getRange() const;\r\n\r\n\t/*! Set the range for this mirrored target interface.\r\n\t *\r\n\t *    @param [in] range The range of the mirrored target interface.\r\n\t */\r\n\tvoid setRange(QString const& range);\r\n\r\n\t/*!\r\n\t *  Get the remap addresses for the mirrored target interface.\r\n\t *\r\n\t *    @return The remap addresses.\r\n\t */\r\n\tQSharedPointer<QList<QSharedPointer<RemapAddress> > > getRemapAddresses() const;\r\n\r\n    /*!\r\n     *  Set the remap address.\r\n     *\r\n     *    @param [in] newRemapAddress     The new remap address.\r\n     */\r\n    void setRemapAddress(QString const& newRemapAddress);\r\n\r\nprivate:\r\n\r\n\t//!  Specifies the address range to apply to the connected target interface.\r\n\tQString range_;\r\n\r\n\t//! The remap addresses for the target interface.\r\n\tQSharedPointer<QList<QSharedPointer<RemapAddress> > > remapAddresses_ =\r\n\t\tQSharedPointer<QList<QSharedPointer<RemapAddress> > >(new QList<QSharedPointer<RemapAddress> >);\r\n};\r\n\r\n#endif /* MIRRORED_TARGET_INTERFACE_H_ */\r\n"
  },
  {
    "path": "IPXACTmodels/Component/Mode.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: Mode.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Esko Pekkarinen\n// Date: 03.08.2023\n//\n// Description:\n// Describes the ipxact:mode element.\n//-----------------------------------------------------------------------------\n\n#include \"Mode.h\"\n\n//-----------------------------------------------------------------------------\n// Function: Mode::Mode()\n//-----------------------------------------------------------------------------\nMode::Mode(QString const& name):\nNameGroup(name),\nExtendable()\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: Mode::Mode()\n//-----------------------------------------------------------------------------\nMode::Mode( const Mode& other ):\nNameGroup(other),\n    Extendable(other),\n    condition_(other.condition_)\n{\n    for (auto portSlice : *other.portSlices_)\n    {\n        portSlices_->append(QSharedPointer<PortSlice>(new PortSlice(*portSlice)));\n    }\n\n    for (auto fieldSlice : *other.fieldSlices_)\n    {\n        fieldSlices_->append(QSharedPointer<FieldSlice>(new FieldSlice(*fieldSlice)));\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: Mode::~Mode()\n//-----------------------------------------------------------------------------\nMode::~Mode()\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: Mode::operator=()\n//-----------------------------------------------------------------------------\nMode& Mode::operator=( const Mode& other )\n{\n\tif (this != &other)\n    {\n\t\tNameGroup::operator=(other);\n        Extendable::operator=(other);\n        \n        condition_ = other.condition_;\n\n\t\tportSlices_->clear();\n\t\tfor (auto portSlice : *other.portSlices_)\n\t\t{\n\t\t\tportSlices_->append(QSharedPointer<PortSlice>(new PortSlice(*portSlice)));\n\t\t}\n\n        fieldSlices_->clear();\n        for (auto fieldSlice : *other.fieldSlices_)\n        {\n            fieldSlices_->append(QSharedPointer<FieldSlice>(new FieldSlice(*fieldSlice)));\n        }\n\t}\n\treturn *this;\n}\n\n//-----------------------------------------------------------------------------\n// Function: Mode::getCondition()\n//-----------------------------------------------------------------------------\nQString Mode::getCondition() const\n{\n    return condition_;\n}\n\n//-----------------------------------------------------------------------------\n// Function: Mode::setCondition()\n//-----------------------------------------------------------------------------\nvoid Mode::setCondition(QString const& conditionExpression)\n{\n    condition_ = conditionExpression;\n}\n\n//-----------------------------------------------------------------------------\n// Function: Mode::getPortSlices()\n//-----------------------------------------------------------------------------\nPortSlice::List Mode::getPortSlices() const\n{\n\treturn portSlices_;\n}\n\n//-----------------------------------------------------------------------------\n// Function: Mode::getFieldSlices()\n//-----------------------------------------------------------------------------\nQSharedPointer<QList<QSharedPointer<FieldSlice> > > Mode::getFieldSlices() const\n{\n    return fieldSlices_;\n}\n"
  },
  {
    "path": "IPXACTmodels/Component/Mode.h",
    "content": "//-----------------------------------------------------------------------------\n// File: Mode.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Esko Pekkarinen\n// Date: 03.08.2023\n//\n// Description:\n// Describes the ipxact:mode element.\n//-----------------------------------------------------------------------------\n\n#ifndef MODE_H\n#define MODE_H\n\n#include <IPXACTmodels/common/NameGroup.h>\n#include <IPXACTmodels/common/Extendable.h>\n\n#include <IPXACTmodels/Component/FieldSlice.h>\n\n#include <IPXACTmodels/ipxactmodels_global.h>\n\n#include \"PortSlice.h\"\n\n#include <QString>\n#include <QMap>\n\n\n//-----------------------------------------------------------------------------\n//! Mode describes the location and size of an area in memory.\n//-----------------------------------------------------------------------------\nclass IPXACTMODELS_EXPORT Mode : public NameGroup, public Extendable\n{\n\npublic:\n\n\tusing List = QSharedPointer<QList<QSharedPointer<Mode> > >;\n\n\t/*!\n\t *  The default constructor.\n\t *\n\t *    @param [in] name\tName of the mode.\n\t */\n\tMode(QString const& name = QString());\n\t\n\t//! The destructor.\n\tvirtual ~Mode();\n\n\t//! The copy constructor.\n\tMode(const Mode& other);\n\n\t//! The assignment operator.\n\tMode& operator=(const Mode& other);\n\n\t/*!\n\t * Get the condition expression.\n\t *\n\t *    @return The condition expression.\n\t */\n\tQString getCondition() const;\n\n\t/*!\n\t *  Sets the condition expression.\n\t *\n\t *    @param [in] conditionExpression The expression to set.\n\t */\n\tvoid setCondition(QString const& conditionExpression);\n\n\t/*!\n\t *  Get the port slices.\n\t *\n\t *    @return The port slices.\n\t */\n\tPortSlice::List getPortSlices() const;\n\n\n\tQSharedPointer<QList<QSharedPointer<FieldSlice> > > getFieldSlices() const;\n\nprivate:\n\n\t//! The condition to activate the mode.\n\tQString condition_;\n\n\t//! The port slices available in the condition.\n\tPortSlice::List portSlices_ = PortSlice::List(new QList<QSharedPointer<PortSlice> >());\n\n    //! The field slices available in the condition.\n\tFieldSlice::List fieldSlices_ = FieldSlice::List(new QList<QSharedPointer<FieldSlice> >());\n\n};\n\n#endif // MODE_H"
  },
  {
    "path": "IPXACTmodels/Component/ModeReader.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: ModeReader.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Esko Pekkarinen\n// Date: 03.08.2023\n//\n// Description:\n// Reader class for IP-XACT mode element.\n//-----------------------------------------------------------------------------\n\n#include \"ModeReader.h\"\n#include \"Mode.h\"\n#include \"RemapPort.h\"\n\n#include <IPXACTmodels/common/CommonItemsReader.h>\n#include <IPXACTmodels/common/NameGroupReader.h>\n#include <IPXACTmodels/common/PartSelect.h>\n#include <IPXACTmodels/Component/FieldReferenceReader.h>\n\n//-----------------------------------------------------------------------------\n// Function: ModeReader::createModeFrom()\n//-----------------------------------------------------------------------------\nQSharedPointer<Mode> ModeReader::createModeFrom(QDomNode const& modeNode)\n{\n    QSharedPointer<Mode> newMode (new Mode());\n\n    NameGroupReader::parseNameGroup(modeNode, newMode);\n\n    Details::parseCondition(modeNode, newMode);\n\n    Details::parsePortSlices(modeNode, newMode);\n\n    Details::parseFieldSlices(modeNode, newMode);\n\n    return newMode;\n}\n\n//-----------------------------------------------------------------------------\n// Function: ModeReader::Details::parseCondition()\n//-----------------------------------------------------------------------------\nvoid ModeReader::Details::parseCondition(QDomNode const& modeNode, QSharedPointer<Mode> newMode)\n{\n    auto conditionElement = modeNode.firstChildElement(QStringLiteral(\"ipxact:condition\"));\n    newMode->setCondition(conditionElement.firstChild().nodeValue());\n}\n\n//-----------------------------------------------------------------------------\n// Function: ModeReader::parsePortSlices()\n//-----------------------------------------------------------------------------\nvoid ModeReader::Details::parsePortSlices(QDomNode const& modeNode, QSharedPointer<Mode> newMode)\n{\n    auto sliceNodeList = modeNode.toElement().elementsByTagName(QStringLiteral(\"ipxact:portSlice\"));\n\n    const int SLICE_COUNT = sliceNodeList.count();\n    for (int i = 0; i < SLICE_COUNT; ++i)\n    {\n        auto portSliceElement = sliceNodeList.at(i).toElement();\n\n        QSharedPointer<PortSlice> newSlice(new PortSlice());\n\n        NameGroupReader::parseNameGroup(portSliceElement, newSlice);\n\n        auto portRefElement = portSliceElement.firstChildElement(QStringLiteral(\"ipxact:portRef\"));\n        auto portRef = portRefElement.attribute(QStringLiteral(\"portRef\"));\n        newSlice->setPortRef(portRef);\n\n        \n        if (QDomNode partSelectNode = portSliceElement.firstChildElement(QStringLiteral(\"ipxact:partSelect\")); \n            !partSelectNode.isNull())\n        {\n            QSharedPointer<PartSelect> newPartSelect = CommonItemsReader::parsePartSelect(partSelectNode);\n            newSlice->setPartSelect(newPartSelect);\n        }\n\n        newMode->getPortSlices()->append(newSlice);\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: ModeReader::parseFieldSlices()\n//-----------------------------------------------------------------------------\nvoid ModeReader::Details::parseFieldSlices(QDomNode const& modeNode, QSharedPointer<Mode> newMode)\n{\n    auto sliceNodeList = modeNode.toElement().elementsByTagName(QStringLiteral(\"ipxact:fieldSlice\"));\n\n    const int SLICE_COUNT = sliceNodeList.count();\n    for (int i = 0; i < SLICE_COUNT; ++i)\n    {\n        auto fieldSliceElement = sliceNodeList.at(i).toElement();\n\n        QSharedPointer<FieldSlice> newSlice(new FieldSlice());\n\n        NameGroupReader::parseNameGroup(fieldSliceElement, newSlice);\n\n        auto ref = FieldReferenceReader::createFieldReferenceFrom(fieldSliceElement);\n        newSlice->FieldReference::operator=(*ref);\n\n        Details::parseRange(fieldSliceElement, newSlice);\n\n        newMode->getFieldSlices()->append(newSlice);\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: ModeReader::Details::parseRange()\n//-----------------------------------------------------------------------------\nvoid ModeReader::Details::parseRange(QDomElement const& element, QSharedPointer<Range> range)\n{\n    auto rangeElement = element.firstChildElement(QStringLiteral(\"ipxact:range\"));\n    if (!rangeElement.isNull())\n    {\n        auto leftRange = rangeElement.firstChildElement(QStringLiteral(\"ipxact:left\")).firstChild().nodeValue();\n        auto rightRange = rangeElement.firstChildElement(QStringLiteral(\"ipxact:right\")).firstChild().nodeValue();\n\n        range->setLeft(leftRange);\n        range->setRight(rightRange);\n    }\n}\n"
  },
  {
    "path": "IPXACTmodels/Component/ModeReader.h",
    "content": "//-----------------------------------------------------------------------------\n// File: ModeReader.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Esko Pekkarinen\n// Date: 03.08.2023\n//\n// Description:\n// Reader class for IP-XACT mode element.\n//-----------------------------------------------------------------------------\n\n#ifndef ModeREADER_H\n#define ModeREADER_H\n\n#include <IPXACTmodels/ipxactmodels_global.h>\n\n#include <IPXACTmodels/common/Range.h>\n\n#include <QObject>\n#include <QSharedPointer>\n#include <QDomNode>\n\nclass Mode;\nclass RemapPort;\n\n//-----------------------------------------------------------------------------\n//! Reader class for IP-XACT mode element.\n//-----------------------------------------------------------------------------\nnamespace ModeReader\n{\n\n    /*!\n     *  Creates a new mode from a given view node.\n     *\n     *    @param [in] modeNode  XML description of the mode.\n     *\n     *    @return The created mode.\n     */\n    IPXACTMODELS_EXPORT QSharedPointer<Mode> createModeFrom(QDomNode const& modeNode);\n\n    namespace Details\n    {\n\n        /*!\n         *   Parses the mode condition.\n         *\n         *    @param [in] modeNode   XML description of the nodet.\n         *    @param [in] newMode    The selected mode item.\n         *\n         */\n        void parseCondition(QDomNode const& modeNode, QSharedPointer<Mode> newMode);\n\n        /*!\n         *  Read the remap ports.\n         *\n         *    @param [in] ModeNode  XML description of the mode.\n         *    @param [in] newMode   The selected mode item.\n         */\n        void parsePortSlices(QDomNode const& modeNode, QSharedPointer<Mode> newMode);\n       \n        /*!\n         *  Read the field slices.\n         *\n         *    @param [in] modeNode  XML description of the mode.\n         *    @param [in] newMode   The selected mode item.\n         */\n        void parseFieldSlices(QDomNode const& modeNode, QSharedPointer<Mode> newMode);\n\n\n        /*!\n         *   Parses range.\n         *\n         *    @param [in] element    XML description of the IP-XACT element.\n         *    @param [in] range      The range to read to.\n         *\n         */\n        void parseRange(QDomElement const& element, QSharedPointer<Range> range);\n    }\n};\n\n#endif // VIEWREADER_H\n"
  },
  {
    "path": "IPXACTmodels/Component/ModeReference.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: ModeReference.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Anton Hagqvist\n// Date: 28.7.2023\n//\n// Description:\n// Describes the ipxact:modeRef element.\n//-----------------------------------------------------------------------------\n\n#include \"ModeReference.h\"\n\n//-----------------------------------------------------------------------------\n// Function: ModeReference::ModeReference()\n//-----------------------------------------------------------------------------\nModeReference::ModeReference()\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: ModeReference::ModeReference()\n//-----------------------------------------------------------------------------\nModeReference::ModeReference(ModeReference const& other):\n    reference_(other.reference_),\n    priority_(other.priority_)\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: ModeReference::Reference()\n//-----------------------------------------------------------------------------\nQString ModeReference::getReference() const\n{\n    return reference_;\n}\n\n//-----------------------------------------------------------------------------\n// Function: ModeReference::Reference()\n//-----------------------------------------------------------------------------\nvoid ModeReference::setReference(QString const& val)\n{\n    reference_ = val;\n}\n\n//-----------------------------------------------------------------------------\n// Function: ModeReference::getPriority()\n//-----------------------------------------------------------------------------\nunsigned int ModeReference::getPriority() const\n{\n    return priority_;\n}\n\n//-----------------------------------------------------------------------------\n// Function: ModeReference::setPriority()\n//-----------------------------------------------------------------------------\nvoid ModeReference::setPriority(unsigned int val)\n{\n    priority_ = val;\n}\n"
  },
  {
    "path": "IPXACTmodels/Component/ModeReference.h",
    "content": "//-----------------------------------------------------------------------------\n// File: ModeReference.h\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Anton Hagqvist\n// Date: 28.7.2023\n//\n// Description:\n// Describes an ipxact:modeRef element.\n//-----------------------------------------------------------------------------\n\n#ifndef MODEREFERENCE_H\n#define MODEREFERENCE_H\n\n#include <QString>\n\n#include <IPXACTmodels/ipxactmodels_global.h>\n\n\nclass IPXACTMODELS_EXPORT ModeReference\n{\npublic:\n\n\tModeReference();\n\n\tModeReference(ModeReference const& other);\n\n\tvirtual ~ModeReference() = default;\n\n\tQString getReference() const;\n\n\tvoid setReference(QString const& val);\n\n\tunsigned int getPriority() const;\n\n\tvoid setPriority(unsigned int val);\n\t\nprivate:\n\tQString reference_;\n\n\tunsigned int priority_ = 0;\n};\n\n#endif // MODEREFERENCE_\n"
  },
  {
    "path": "IPXACTmodels/Component/ModeWriter.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: ModeWriter.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Esko Pekkarinen\n// Date: 07.08.2023\n//\n// Description:\n// Writer class for IP-XACT mode element.\n//-----------------------------------------------------------------------------\n\n#include \"ModeWriter.h\"\n#include \"Mode.h\"\n#include \"RemapPort.h\"\n\n#include <IPXACTmodels/common/CommonItemsWriter.h>\n#include <IPXACTmodels/common/NameGroupWriter.h>\n#include <IPXACTmodels/Component/FieldReferenceWriter.h>\n\n//-----------------------------------------------------------------------------\n// Function: ModeWriter::writeMode()\n//-----------------------------------------------------------------------------\nvoid ModeWriter::writeMode(QXmlStreamWriter& writer, QSharedPointer<Mode> mode)\n{\n    writer.writeStartElement(QStringLiteral(\"ipxact:mode\"));\n\n    NameGroupWriter::writeNameGroup(writer, mode, Document::Revision::Std22);\n\n    Details::writeCondition(writer, mode);\n\n    Details::writePortSlices(writer, mode);\n\n    Details::writeFieldSlices(writer, mode);\n\n    writer.writeEndElement(); // ipxact:mode\n}\n\n//-----------------------------------------------------------------------------\n// Function: ModeWriter::Details::writeCondition()\n//-----------------------------------------------------------------------------\nvoid ModeWriter::Details::writeCondition(QXmlStreamWriter& writer, QSharedPointer<Mode> mode)\n{\n    CommonItemsWriter::writeNonEmptyElement(writer, QStringLiteral(\"ipxact:condition\"), mode->getCondition());\n}\n\n//-----------------------------------------------------------------------------\n// Function: ModeWriter::Details::writePortSlices()\n//-----------------------------------------------------------------------------\nvoid ModeWriter::Details::writePortSlices(QXmlStreamWriter& writer, QSharedPointer<Mode> mode)\n{\n    for (auto slice : *mode->getPortSlices())\n    {\n        writer.writeStartElement(QStringLiteral(\"ipxact:portSlice\"));\n\n        NameGroupWriter::writeNameGroup(writer, slice, Document::Revision::Std22);\n\n        writer.writeStartElement(QStringLiteral(\"ipxact:portRef\"));\n        writer.writeAttribute(QStringLiteral(\"portRef\"), slice->getPortRef());\n        writer.writeEndElement(); // ipxact:portRef\n\n        CommonItemsWriter::writePartSelect(writer, slice->getPartSelect());\n\n        writer.writeEndElement(); // ipxact:portSlice\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: ModeWriter::Details::writeFieldSlices()\n//-----------------------------------------------------------------------------\nvoid ModeWriter::Details::writeFieldSlices(QXmlStreamWriter& writer, QSharedPointer<Mode> mode)\n{\n    for (auto slice : *mode->getFieldSlices())\n    {\n        writer.writeStartElement(QStringLiteral(\"ipxact:fieldSlice\"));\n\n        NameGroupWriter::writeNameGroup(writer, slice, Document::Revision::Std22);\n\n        FieldReferenceWriter::writeFieldReference(writer, slice);\n\n        // Write range of the field slice.\n        if (slice->getLeft().isEmpty() == false || slice->getRight().isEmpty() == false)\n        {\n            writer.writeStartElement(QStringLiteral(\"ipxact:range\"));\n            writer.writeTextElement(QStringLiteral(\"ipxact:left\"), slice->getLeft());\n            writer.writeTextElement(QStringLiteral(\"ipxact:right\"), slice->getRight());\n            writer.writeEndElement(); //! ipxact:range\n        }\n\n        writer.writeEndElement(); // ipxact:fieldSlice\n    }\n}\n"
  },
  {
    "path": "IPXACTmodels/Component/ModeWriter.h",
    "content": "//-----------------------------------------------------------------------------\n// File: ModeWriter.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Esko Pekkarinen\n// Date: 07.08.2023\n//\n// Description:\n// Writer class for IP-XACT mode element.\n//-----------------------------------------------------------------------------\n\n#ifndef ModeWRITER_H\n#define ModeWRITER_H\n\n#include <IPXACTmodels/ipxactmodels_global.h>\n\n#include <QXmlStreamWriter>\n#include <QSharedPointer>\n\nclass Mode;\n\n//-----------------------------------------------------------------------------\n//! Writer class for IP-XACT mode element.\n//-----------------------------------------------------------------------------\nnamespace ModeWriter\n{\n\n    /*!\n     *  Write a mode to an XML file.\n     *\n     *    @param [in] writer  The used xml writer.\n     *    @param [in] view    The mode to be written.\n     */\n    IPXACTMODELS_EXPORT void writeMode(QXmlStreamWriter& writer, QSharedPointer<Mode> mode);\n\n    namespace Details\n    {\n        /*!\n         *  Write the mode condition to an XML file.\n         *\n         *    @param [in] writer  The used xml writer.\n         *    @param [in] view    The mode whose condition to write.\n         */\n        void writeCondition(QXmlStreamWriter& writer, QSharedPointer<Mode> mode);\n\n        /*!\n         *  Write the mode port slices to an XML file.\n         *\n         *    @param [in] writer  The used xml writer.\n         *    @param [in] view    The mode whose port slices to write.\n         */\n        void writePortSlices(QXmlStreamWriter& writer, QSharedPointer<Mode> mode);\n       \n        /*!\n         *  Write the mode field slices to an XML file.\n         *\n         *    @param [in] writer  The used xml writer.\n         *    @param [in] view    The mode whose field slices to write.\n         */\n        void writeFieldSlices(QXmlStreamWriter& writer, QSharedPointer<Mode> mode);\n    }\n};\n\n#endif // ModeWRITER_H"
  },
  {
    "path": "IPXACTmodels/Component/Model.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: Model.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 12.10.2015\r\n//\r\n// Description:\r\n// Describes the ipxact:model element in an IP-XACT document\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"Model.h\"\r\n#include \"View.h\"\r\n#include \"ComponentInstantiation.h\"\r\n#include \"DesignInstantiation.h\"\r\n#include \"DesignConfigurationInstantiation.h\"\r\n#include \"Port.h\"\r\n\r\n#include <IPXACTmodels/utilities/Search.h>\r\n#include <IPXACTmodels/utilities/Copy.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Model::Model()\r\n//-----------------------------------------------------------------------------\r\nModel::Model(Model const& other)\r\n{\r\n    Copy::copyList(other.views_, views_); \r\n    Copy::copyList(other.componentInstantiations_, componentInstantiations_);\r\n    Copy::copyList(other.designInstantiations_, designInstantiations_);\r\n    Copy::copyList(other.designConfigurationInstantiations_, designConfigurationInstantiations_);\r\n    Copy::copyList(other.ports_, ports_);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Model::operator=()\r\n//-----------------------------------------------------------------------------\r\nModel& Model::operator=(Model const& other )\r\n{\r\n    if (this != &other)\r\n    {\r\n        views_->clear();\r\n        Copy::copyList(other.views_, views_);\r\n        componentInstantiations_->clear();\r\n        Copy::copyList(other.componentInstantiations_, componentInstantiations_);\r\n        designInstantiations_->clear();\r\n        Copy::copyList(other.designInstantiations_, designInstantiations_);\r\n        designConfigurationInstantiations_->clear();\r\n        Copy::copyList(other.designConfigurationInstantiations_, designConfigurationInstantiations_);\r\n        ports_->clear();\r\n        Copy::copyList(other.ports_, ports_);\r\n    }\r\n\treturn *this;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Model::getViews()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<QList<QSharedPointer<View> > > Model::getViews() const\r\n{\r\n    return views_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Model::setViews()\r\n//-----------------------------------------------------------------------------\r\nvoid Model::setViews(QSharedPointer<QList<QSharedPointer<View> > > newViews)\r\n{\r\n\tviews_ = newViews;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Model::findComponentInstantiation()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<ComponentInstantiation> Model::findComponentInstantiation(QString const& name) const\r\n{\r\n\treturn Search::findByName(name, componentInstantiations_);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Model::getComponentInstantiations()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<QList<QSharedPointer<ComponentInstantiation> > > Model::getComponentInstantiations() const\r\n{\r\n    return componentInstantiations_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Model::setComponentInstantiations()\r\n//-----------------------------------------------------------------------------\r\nvoid Model::setComponentInstantiations(\r\n    QSharedPointer<QList<QSharedPointer<ComponentInstantiation> > > instantiations)\r\n{\r\n    componentInstantiations_ = instantiations;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Model::findDesignInstantiation()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<DesignInstantiation> Model::findDesignInstantiation(QString const& name) const\r\n{\r\n    return Search::findByName(name, designInstantiations_);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Model::getDesignInstantiations()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<QList<QSharedPointer<DesignInstantiation> > > Model::getDesignInstantiations() const\r\n{\r\n    return designInstantiations_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Model::setDesignInstantiations()\r\n//-----------------------------------------------------------------------------\r\nvoid Model::setDesignInstantiations(QSharedPointer<QList<QSharedPointer<DesignInstantiation> > > newInstantiations)\r\n{\r\n    designInstantiations_ = newInstantiations;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Model::findDesignInstantiation()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<DesignConfigurationInstantiation> Model::findDesignConfigurationInstantiation(QString const& name) \r\n    const\r\n{\r\n    return Search::findByName(name, designConfigurationInstantiations_);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Model::getDesignConfigurationInstantiations()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<QList<QSharedPointer<DesignConfigurationInstantiation> > > \r\n    Model::getDesignConfigurationInstantiations() const\r\n{\r\n    return designConfigurationInstantiations_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Model::setDesignConfigurationInstantiations()\r\n//-----------------------------------------------------------------------------\r\nvoid Model::setDesignConfigurationInstantiations\r\n    (QSharedPointer<QList<QSharedPointer<DesignConfigurationInstantiation> > > newInstantiations)\r\n{\r\n    designConfigurationInstantiations_ = newInstantiations;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Model::getPorts()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<QList<QSharedPointer<Port> > > Model::getPorts() const\r\n{\r\n    return ports_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Model::setPorts()\r\n//-----------------------------------------------------------------------------\r\nvoid Model::setPorts(QSharedPointer<QList<QSharedPointer<Port> > > newPorts)\r\n{\r\n    ports_ = newPorts;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Model::hasViews()\r\n//-----------------------------------------------------------------------------\r\nbool Model::hasViews() const\r\n{\r\n    return !views_->isEmpty();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Model::getViewNames()\r\n//-----------------------------------------------------------------------------\r\nQStringList Model::getViewNames() const\r\n{\r\n    return Search::getNames(views_);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Model::getHierViews()\r\n//-----------------------------------------------------------------------------\r\nQStringList Model::getHierViews() const\r\n{\r\n    QStringList viewList;\r\n    for (QSharedPointer<View> view : *views_)\r\n    {\r\n        if (view->isHierarchical())\r\n        {\r\n            viewList.append(view->name());\r\n        }\r\n    }\r\n    return viewList;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Model::getFlatViews()\r\n//-----------------------------------------------------------------------------\r\nQStringList Model::getFlatViews() const\r\n{\r\n    QStringList viewList;\r\n    for (QSharedPointer<View> view : *views_)\r\n    {\r\n        if (!view->isHierarchical())\r\n        {\r\n            viewList.append(view->name());\r\n        }\r\n    }\r\n    return viewList;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Model::findView()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<View> Model::findView(const QString name) const\r\n{\r\n\treturn Search::findByName(name, views_);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Model::getHierRef()\r\n//-----------------------------------------------------------------------------\r\nVLNV Model::getHierRef(QString const& viewName) const\r\n{\r\n    QSharedPointer<View> view = findView(viewName);\r\n    if (view)\r\n    {\r\n        if (!view->getDesignConfigurationInstantiationRef().isEmpty())\r\n        {\r\n            QSharedPointer<DesignConfigurationInstantiation> viewDesignConfiguration =\r\n                findDesignConfigurationInstantiation(view->getDesignConfigurationInstantiationRef());\r\n            if (viewDesignConfiguration)\r\n            {\r\n                return *viewDesignConfiguration->getDesignConfigurationReference();\r\n            }\r\n        }\r\n\r\n        if (!view->getDesignInstantiationRef().isEmpty())\r\n        {\r\n            QSharedPointer<DesignInstantiation> viewDesign = \r\n                findDesignInstantiation(view->getDesignInstantiationRef());\r\n            if (viewDesign)\r\n            {\r\n                return *viewDesign->getDesignReference();\r\n            }\r\n        }\r\n    }\r\n\r\n    return VLNV();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Model::getHierarchyRefs()\r\n//-----------------------------------------------------------------------------\r\nQList<VLNV> Model::getHierarchyRefs() const\r\n{\r\n    QList<VLNV> list;\r\n\r\n    for (QSharedPointer<View> view : *views_)\r\n    {\r\n        if (view->isHierarchical())\r\n        {\r\n            QSharedPointer<DesignInstantiation> viewDesign = findDesignInstantiation(view->getDesignInstantiationRef());\r\n            if (viewDesign)\r\n            {\r\n                list.append(*viewDesign->getDesignReference());\r\n            }\r\n\r\n            QSharedPointer<DesignConfigurationInstantiation> viewDesignConfiguration =\r\n                findDesignConfigurationInstantiation(view->getDesignConfigurationInstantiationRef());\r\n            if (viewDesignConfiguration)\r\n            {\r\n                list.append(*viewDesignConfiguration->getDesignConfigurationReference());\r\n            }\r\n        }\r\n    }\r\n\r\n    return list;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Model::getPort()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<Port> Model::getPort(QString const& name) const\r\n{\r\n    return Search::findByName(name, ports_);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Model::hasPort()\r\n//-----------------------------------------------------------------------------\r\nbool Model::hasPort(QString const& name) const\r\n{\r\n    return getPort(name).isNull() == false;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Model::hasWires()\r\n//-----------------------------------------------------------------------------\r\nbool Model::hasWires() const\r\n{\r\n    return std::any_of(ports_->cbegin(), ports_->cend(), [](QSharedPointer<Port> port)\r\n        {\r\n            return port->getWire();\r\n        });\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Model::hasTransactionals()\r\n//-----------------------------------------------------------------------------\r\nbool Model::hasTransactionals() const\r\n{\r\n    return std::any_of(ports_->cbegin(), ports_->cend(), [](QSharedPointer<Port> port)\r\n        {\r\n            return port->getTransactional();\r\n        });\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Model::getPortNames()\r\n//-----------------------------------------------------------------------------\r\nQStringList Model::getPortNames() const\r\n{\r\n    return Search::getNames(ports_);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Model::hasPorts()\r\n//-----------------------------------------------------------------------------\r\nbool Model::hasPorts() const\r\n{\r\n    return !ports_->isEmpty();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Model::hasHierView()\r\n//-----------------------------------------------------------------------------\r\nbool Model::hasHierView() const\r\n{\r\n    return std::any_of(views_->cbegin(), views_->cend(), [](const auto& view) { return view->isHierarchical(); });\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Model::getViewReferences()\r\n//-----------------------------------------------------------------------------\r\nQList<VLNV> Model::getViewReferences() const\r\n{\r\n    QList<VLNV> vlnvList;\r\n\r\n    for (QSharedPointer<View> view : *views_)\r\n    {\r\n        if (!view->getDesignInstantiationRef().isEmpty())\r\n        {\r\n            QSharedPointer<DesignInstantiation> viewDesign =\r\n                findDesignInstantiation(view->getDesignInstantiationRef());\r\n            if (viewDesign)\r\n            {\r\n                vlnvList.append(*viewDesign->getDesignReference());\r\n            }\r\n        }\r\n\r\n        if (!view->getDesignConfigurationInstantiationRef().isEmpty())\r\n        {\r\n            QSharedPointer<DesignConfigurationInstantiation> viewDesignConfiguration =\r\n                findDesignConfigurationInstantiation(view->getDesignConfigurationInstantiationRef());\r\n            if (viewDesignConfiguration)\r\n            {\r\n                vlnvList.append(*viewDesignConfiguration->getDesignConfigurationReference());\r\n            }\r\n\r\n        }\r\n    }\r\n    return vlnvList;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Model::hasContents()\r\n//-----------------------------------------------------------------------------\r\nbool Model::hasContents() const\r\n{\r\n    return (!views_->isEmpty() || !componentInstantiations_->isEmpty() || !designInstantiations_->isEmpty() ||\r\n        !designConfigurationInstantiations_->isEmpty() || !ports_->isEmpty());\r\n}\r\n"
  },
  {
    "path": "IPXACTmodels/Component/Model.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: Model.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 12.10.2015\r\n//\r\n// Description:\r\n// Describes the ipxact:model element in an IP-XACT document\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef MODEL_H\r\n#define MODEL_H\r\n\r\n#include <IPXACTmodels/Component/Port.h>\r\n#include <IPXACTmodels/Component/View.h>\r\n#include <IPXACTmodels/Component/ComponentInstantiation.h>\r\n#include <IPXACTmodels/Component/DesignInstantiation.h>\r\n#include <IPXACTmodels/Component/DesignConfigurationInstantiation.h>\r\n\r\n#include <IPXACTmodels/common/DirectionTypes.h>\r\n\r\n#include <IPXACTmodels/ipxactmodels_global.h>\r\n\r\n#include <QList>\r\n#include <QSharedPointer>\r\n#include <QStringList>\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Describes the ipxact:model element in an IP-XACT document\r\n//-----------------------------------------------------------------------------\r\nclass IPXACTMODELS_EXPORT Model\r\n{\r\n\r\npublic:\r\n\r\n\t/*!\r\n     *  The default constructor.\r\n\t */\r\n\tModel() = default;\r\n\r\n\t//! Copy constructor.\r\n\tModel(const Model &other);\r\n\r\n\t//! Assignment operator.\r\n\tModel& operator=(const Model& other);\r\n\r\n\t/*!\r\n     *  The destructor.\r\n\t */\r\n\t~Model() = default;\r\n\r\n\t/*!\r\n     *  Get the views of this model.\r\n\t *\r\n\t *    @return Pointer to a lis containing pointers to the views of this model.\r\n\t */\r\n    QSharedPointer<QList<QSharedPointer<View> > > getViews() const;\r\n\r\n\t/*!\r\n     *  Set the views for this model.\r\n\t *\r\n\t *    @param [in] newViews    Pointer to a list containing pointers to the views.\r\n\t */\r\n\tvoid setViews(QSharedPointer<QList<QSharedPointer<View> > > newViews);\r\n\t\r\n\t/*\r\n     *  Get a component instantiation by name.\r\n\t *\r\n\t *    @return The component instantiation if found, else null.\r\n\t */\r\n\tQSharedPointer<ComponentInstantiation> findComponentInstantiation(QString const& name) const;\r\n\r\n    /*!\r\n     *  Get the component instantiations.\r\n     *\r\n     *    @return Pointer to a list containing the component instantiations.\r\n     */\r\n    QSharedPointer<QList<QSharedPointer<ComponentInstantiation> > > getComponentInstantiations() const;\r\n\r\n    /*!\r\n     *  Set the component instantiations.\r\n     *\r\n     *    @param [in] instantiations  Pointer to a list containing the new component instantiations.\r\n     */\r\n    void setComponentInstantiations(QSharedPointer<QList<QSharedPointer<ComponentInstantiation> > > instantiations);\r\n\t\r\n\t/*\r\n     *  Get a design instantiation by name.\r\n\t *\r\n\t *    @return The design instantiation if found, else null.\r\n\t */\r\n\tQSharedPointer<DesignInstantiation> findDesignInstantiation(QString const& name) const;\r\n\r\n    /*!\r\n     *  Get the design instantiations.\r\n     *\r\n     *    @return Pointer to a list containing the design instantiations.\r\n     */\r\n    QSharedPointer<QList<QSharedPointer<DesignInstantiation> > > getDesignInstantiations() const;\r\n\r\n    /*!\r\n     *  Set the design instantiations.\r\n     *\r\n     *    @param [in] instantiations  Pointer to a list containing the new design instantiations.\r\n     */\r\n    void setDesignInstantiations(QSharedPointer<QList<QSharedPointer<DesignInstantiation> >  > newInstantiations);\r\n\t\r\n\t/*\r\n     *  Get a design configuration instantiation by name.\r\n\t *\r\n\t *    @return The design configuration instantiation if found, else null.\r\n\t */\r\n\tQSharedPointer<DesignConfigurationInstantiation> findDesignConfigurationInstantiation(QString const& name) const;\r\n\r\n    /*!\r\n     *  Get the design configuration instantiations.\r\n     *\r\n     *    @return Pointer to a list containing the design configuration instantiations.\r\n     */\r\n    QSharedPointer<QList<QSharedPointer<DesignConfigurationInstantiation> > >\r\n        getDesignConfigurationInstantiations() const;\r\n\r\n    /*!\r\n     *  Set the design conifguration instantiations.\r\n     *\r\n     *    @param [in] instantiations  Pointer to a list containing the new design configuration instantiations.\r\n     */\r\n    void setDesignConfigurationInstantiations(\r\n        QSharedPointer<QList<QSharedPointer<DesignConfigurationInstantiation> > > newInstantiations);\r\n    \r\n\t/*!\r\n     *  Get the ports of this model.\r\n\t *\r\n\t *    @return Pointer to a list containing the ports.\r\n\t */\r\n    QSharedPointer<QList<QSharedPointer<Port> > > getPorts() const;\r\n\r\n    /*!\r\n     *  Set the ports.\r\n     *\r\n     *    @param [in] newPorts    Pointer to a list containing the new ports.\r\n     */\r\n    void setPorts(QSharedPointer<QList<QSharedPointer<Port> > > newPorts);\r\n\r\n\t/*!\r\n     *  Checks if the model has views.\r\n\t *\r\n\t *    @return bool True if views exist.\r\n\t */\r\n\tbool hasViews() const;\r\n    \r\n\t/*!\r\n     *  Get list of the view names in this model.\r\n\t *\r\n\t *    @return QStringList containing the view names.\r\n\t */\r\n\tQStringList getViewNames() const;\r\n\r\n\t/*!\r\n     *  Get the hierarchical views of the model.\r\n\t *\r\n\t *    @return QStringList containing the names of the hierarchical views.\r\n\t */\r\n\tQStringList getHierViews() const;\r\n\r\n\t/*\r\n     *  Get the non-hierarchical views of the model.\r\n\t *\r\n\t *    @return QStringList containing the names of the non-hierarchical views.\r\n\t */\r\n\tQStringList getFlatViews() const;\r\n\r\n\t/*\r\n     *  Get a view by name.\r\n\t *\r\n\t *    @return The view if found, else null.\r\n\t */\r\n\tQSharedPointer<View> findView(const QString name) const;\r\n    \r\n\t/*!\r\n     *  Get the VLNV of a design in model's view.\r\n\t *\r\n\t *    @return A vlnv of a design that is used within this component. Null pointer if design is not found.\r\n\t */\r\n\tVLNV getHierRef(QString const& viewName = QString()) const;\r\n\r\n\t/*!\r\n     *  Get list of the design VLNVs that are referenced within model.\r\n\t *\r\n\t *    @return QList containing pointers to the VLNVs\r\n\t */\r\n\tQList<VLNV> getHierarchyRefs() const;\r\n    \r\n\t/*!\r\n     *  Get the specific port of the model.\r\n     *\r\n\t *    @param [in] name    Name of the port.\r\n\t *\r\n\t *    @return Pointer to the specified port.\r\n\t */\r\n\tQSharedPointer<Port> getPort(const QString& name) const;\r\n\r\n    /*!\r\n     *  Check if the model has a specified port.\r\n     *\r\n     *    @param [in] name    Name of the port being searched for.\r\n     *\r\n     *    @return True, if the port is found, false otherwise.\r\n     */\r\n    bool hasPort(QString const& name) const;\r\n\r\n    /*!\r\n     *  Check if the model has wire ports.\r\n     *\r\n     *    @return True, if wire ports are found, false otherwise.\r\n     */\r\n    bool hasWires() const;\r\n    \r\n    /*!\r\n     *  Check if the model has transactional ports.\r\n     *\r\n     *    @return True, if transactional ports are found, false otherwise.\r\n     */\r\n    bool hasTransactionals() const;\r\n\r\n\t/*!\r\n     *  Get names of the ports in this model.\r\n\t *\r\n\t *    @return QStringList containing the port names.\r\n\t */\r\n\tQStringList getPortNames() const;\r\n\r\n\t/*!\r\n     *  Checks if the model has ports.\r\n\t *\r\n\t *    @return bool True if ports exist.\r\n\t */\r\n\tbool hasPorts() const;\r\n\r\n\t/*!\r\n     *  Does this model contains a hierarchical view.\r\n     *\r\n\t *    @return True if a hierarchyRef is found in one of the views, otherwise false.\r\n\t */\r\n\tbool hasHierView() const;\r\n    \r\n    /*!\r\n     *  Get the references of the views.\r\n     *\r\n     *    @return A list of VLNVs referenced by the views.\r\n     */\r\n    QList<VLNV> getViewReferences() const;\r\n    \r\n    /*!\r\n     *  Check if the model has any contents.\r\n     *\r\n     *    @return True, if contents are found, false otherwise.\r\n     */\r\n    bool hasContents() const;\r\n\r\nprivate:\r\n\r\n\t//! Contains the views for this model.\r\n    View::List views_ = View::List(new QList<QSharedPointer<View> >());\r\n\r\n    //! Contains the component instantiations.\r\n    ComponentInstantiation::List componentInstantiations_ =\r\n        ComponentInstantiation::List(new QList<QSharedPointer<ComponentInstantiation> >());\r\n\r\n    //! Contains the design instantiations.\r\n    DesignInstantiation::List designInstantiations_ = \r\n        DesignInstantiation::List(new QList<QSharedPointer<DesignInstantiation> >());\r\n\r\n    //! Contains the design configuration instantiations.\r\n    DesignConfigurationInstantiation::List designConfigurationInstantiations_ = \r\n        DesignConfigurationInstantiation::List(new QList<QSharedPointer<DesignConfigurationInstantiation> >());\r\n\r\n\t//! Contains the ports for this model.\r\n    Port::List ports_ = Port::List(new QList<QSharedPointer<Port> >());\r\n};\r\n\r\n#endif // MODEL_H\r\n"
  },
  {
    "path": "IPXACTmodels/Component/OtherClockDriver.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: OtherClockDriver.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: \r\n// Date: \r\n//\r\n// Description:\r\n// Writer class for ipxact:otherClockDriver element.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"OtherClockDriver.h\"\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: OtherClockDriver::OtherClockDriver()\r\n//-----------------------------------------------------------------------------\r\nOtherClockDriver::OtherClockDriver(QString const& clockName) :\r\nclockName_(clockName),\r\nclockSource_(),\r\nclockPeriod_(new ClockUnit()),\r\nclockPulseOffset_(new ClockUnit()),\r\nclockPulseValue_(),\r\nclockPulseDuration_(new ClockUnit())\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: OtherClockDriver::OtherClockDriver()\r\n//-----------------------------------------------------------------------------\r\nOtherClockDriver::OtherClockDriver( const OtherClockDriver &other ):\r\nclockName_(other.clockName_),\r\nclockSource_(other.clockSource_),\r\nclockPeriod_(new ClockUnit()),\r\nclockPulseOffset_(new ClockUnit()),\r\nclockPulseValue_(other.clockPulseValue_),\r\nclockPulseDuration_(new ClockUnit())\r\n{\r\n    copyClockData(other);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: OtherClockDriver::operator=()\r\n//-----------------------------------------------------------------------------\r\nOtherClockDriver & OtherClockDriver::operator=( const OtherClockDriver &other )\r\n{\r\n\tif (this != &other)\r\n    {\r\n\t\tclockName_ = other.clockName_;\r\n\t\tclockSource_ = other.clockSource_;\r\n        clockPulseValue_ = other.clockPulseValue_;\r\n\r\n        copyClockData(other);\r\n\t}\r\n\treturn *this;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: OtherClockDriver::()\r\n//-----------------------------------------------------------------------------\r\nOtherClockDriver::~OtherClockDriver()\r\n{\r\n    clockPeriod_.clear();\r\n    clockPulseOffset_.clear();\r\n    clockPulseDuration_.clear();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: OtherClockDriver::getClockName()\r\n//-----------------------------------------------------------------------------\r\nQString OtherClockDriver::getClockName() const\r\n{\r\n\treturn clockName_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: OtherClockDriver::setClockName()\r\n//-----------------------------------------------------------------------------\r\nvoid OtherClockDriver::setClockName(QString const& clockName)\r\n{\r\n\tclockName_ = clockName;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: OtherClockDriver::getClockSource()\r\n//-----------------------------------------------------------------------------\r\nQString OtherClockDriver::getClockSource() const\r\n{\r\n    return clockSource_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: OtherClockDriver::setClockSource()\r\n//-----------------------------------------------------------------------------\r\nvoid OtherClockDriver::setClockSource(QString const& clockSource)\r\n{\r\n    clockSource_ = clockSource;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: OtherClockDriver::getClockPeriod()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<ClockUnit> OtherClockDriver::getClockPeriod() const\r\n{\r\n    return clockPeriod_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: OtherClockDriver::setClockPeriod()\r\n//-----------------------------------------------------------------------------\r\nvoid OtherClockDriver::setClockPeriod(QSharedPointer<ClockUnit> newClockPeriod)\r\n{\r\n    clockPeriod_ = newClockPeriod;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: OtherClockDriver::getClockPulseOffset()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<ClockUnit> OtherClockDriver::getClockPulseOffset() const\r\n{\r\n    return clockPulseOffset_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: OtherClockDriver::setClockPulseOffset()\r\n//-----------------------------------------------------------------------------\r\nvoid OtherClockDriver::setClockPulseOffset(QSharedPointer<ClockUnit> newClockPulseOffset)\r\n{\r\n    clockPulseOffset_ = newClockPulseOffset;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: OtherClockDriver::getClockPulseValue()\r\n//-----------------------------------------------------------------------------\r\nQString OtherClockDriver::getClockPulseValue() const\r\n{\r\n    return clockPulseValue_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: OtherClockDriver::setClockPulseValue()\r\n//-----------------------------------------------------------------------------\r\nvoid OtherClockDriver::setClockPulseValue(QString const& newClockPulseValue)\r\n{\r\n    clockPulseValue_ = newClockPulseValue;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: OtherClockDriver::getClockPulseDuration()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<ClockUnit> OtherClockDriver::getClockPulseDuration() const\r\n{\r\n    return clockPulseDuration_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: OtherClockDriver::setClockPulseDuration()\r\n//-----------------------------------------------------------------------------\r\nvoid OtherClockDriver::setClockPulseDuration(QSharedPointer<ClockUnit> newClockPulseDuration)\r\n{\r\n    clockPulseDuration_ = newClockPulseDuration;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: OtherClockDriver::copyClockData()\r\n//-----------------------------------------------------------------------------\r\nvoid OtherClockDriver::copyClockData(const OtherClockDriver &other)\r\n{\r\n    if (other.clockPeriod_)\r\n    {\r\n        clockPeriod_ = QSharedPointer<ClockUnit>(new ClockUnit(*other.clockPeriod_.data()));\r\n    }\r\n\r\n    if (other.clockPulseOffset_)\r\n    {\r\n        clockPulseOffset_ = QSharedPointer<ClockUnit>(new ClockUnit(*other.clockPulseOffset_.data()));\r\n    }\r\n\r\n    if (other.clockPulseDuration_)\r\n    {\r\n        clockPulseDuration_ = QSharedPointer<ClockUnit>(new ClockUnit(*other.clockPulseDuration_.data()));\r\n    }\r\n}"
  },
  {
    "path": "IPXACTmodels/Component/OtherClockDriver.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: OtherClockDriver.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: \r\n// Date: \r\n//\r\n// Description:\r\n// Class for ipxact:otherClockDriver element.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef OTHERCLOCKDRIVER_H\r\n#define OTHERCLOCKDRIVER_H\r\n\r\n#include <IPXACTmodels/ipxactmodels_global.h>\r\n\r\n#include <IPXACTmodels/common/ClockUnit.h>\r\n\r\n#include <QList>\r\n#include <QString>\r\n#include <QSharedPointer>\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Class for ipxact:otherClockDriver element.\r\n//-----------------------------------------------------------------------------\r\nclass IPXACTMODELS_EXPORT OtherClockDriver\r\n{\r\n\r\npublic:\r\n\r\n\t/*!\r\n\t *  The constructor.\r\n\t *\r\n\t *    @param [in] clockName   The name of the clock driver.\r\n\t */\r\n\tOtherClockDriver(QString const& clockName = QString());\r\n\r\n\t//! Copy constructor.\r\n\tOtherClockDriver(const OtherClockDriver &other);\r\n\r\n\t//! Assignment operator.\r\n\tOtherClockDriver &operator=(const OtherClockDriver &other);\r\n\r\n\t/*!\r\n     *  The destructor.\r\n\t */\r\n\t~OtherClockDriver();\r\n\r\n    /*!\r\n     *  Get the name of the clock.\r\n\t *\r\n\t *    @return QString containing the name\r\n\t */\r\n\tQString getClockName() const;\r\n    \r\n\t/*!\r\n     *  Set the clock name.\r\n\t *\r\n\t *    @param [in] clockName   The new name of the clock.\r\n\t */\r\n\tvoid setClockName(QString const& clockName);\r\n    \r\n\t/*!\r\n     *  Get the clock source.\r\n\t *\r\n\t *    @return QString containing the path and name of the clock generation cell.\r\n\t */\r\n\tQString getClockSource() const;\r\n    \r\n\t/*!\r\n     *  Set the clock source.\r\n\t *\r\n\t *    @param [in] clockSource     QString containing the name and path of the clock generation cell.\r\n\t */\r\n\tvoid setClockSource(QString const& clockSource);\r\n\r\n\t/*!\r\n     *  Get the clock period.\r\n\t *\r\n\t *    @return A pointer to the clock period.\r\n\t */\r\n    QSharedPointer<ClockUnit> getClockPeriod() const;\r\n\r\n\t/*!\r\n     *  Set the clock period.\r\n\t *\r\n\t *    @param [in] clockPeriod     A pointer to the new clock period.\r\n\t */\r\n    void setClockPeriod(QSharedPointer<ClockUnit> newClockPeriod);\r\n\r\n\t/*!\r\n     *  Get the clock pulse offset.\r\n\t *\r\n\t *    @return Pointer to the clock pulse offset.\r\n\t */\r\n    QSharedPointer<ClockUnit> getClockPulseOffset() const;\r\n    \r\n\t/*!\r\n     *  Set the clock pulse offset.\r\n\t *\r\n\t *    @param [in] clockPulseOffset    Pointer to the new clock pulse offset.\r\n\t */\r\n    void setClockPulseOffset(QSharedPointer<ClockUnit> newClockPulseOffset);\r\n\r\n\t/*!\r\n     *  Get the clock pulse value.\r\n\t *\r\n\t *    @return The clock pulse value.\r\n\t */\r\n    QString getClockPulseValue() const;\r\n    \r\n\t/*!\r\n     *  Set the clock pulse value.\r\n\t *\r\n\t *    @param [in]     The new clock pulse value.\r\n\t */\r\n    void setClockPulseValue(QString const& newClockPulseValue);\r\n\r\n\t/*!\r\n     *  Get the clock pulse duration.\r\n\t *\r\n\t *    @return A pointer to the new clock pulse duration.\r\n\t */\r\n    QSharedPointer<ClockUnit> getClockPulseDuration() const;\r\n\r\n\t/*!\r\n     *  Set the clock pulse duration.\r\n\t *\r\n\t *    @param [in] clockPulseDuration  A pointer to the new clock pulse duration.\r\n\t */\r\n    void setClockPulseDuration(QSharedPointer<ClockUnit> newClockPulseDuration);\r\n\r\nprivate:\r\n\r\n    /*!\r\n     *  Copy the clock data.\r\n     *\r\n     *    @param [in] other   The other clock driver being copied.\r\n     */\r\n    void copyClockData(const OtherClockDriver &other);\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n\t//! The name of the clock for reference by a constraint.\r\n\tQString clockName_;\r\n\r\n\t//! Defines the physical path and name of the clock generation cell.\r\n\tQString clockSource_;\r\n\r\n\t//! Specifies the overall length of one cycle of the waveform.\r\n    QSharedPointer<ClockUnit> clockPeriod_;\r\n\r\n\t//! Specifies the time delay from the start of the waveform to the first transition.\r\n    QSharedPointer<ClockUnit> clockPulseOffset_;\r\n\r\n\t//! Specifies the logic value to which the port transitions.\r\n    QString clockPulseValue_;\r\n\r\n\t//! Specifies how long the waveform remains at the value specified by clockPulseValue.\r\n    QSharedPointer<ClockUnit> clockPulseDuration_;\r\n};\r\n\r\n#endif // OTHERCLOCKDRIVER_H\r\n"
  },
  {
    "path": "IPXACTmodels/Component/OtherClockDriverReader.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: OtherClockDriverReader.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Janne Virtanen\r\n// Date: 02.10.2015\r\n//\r\n// Description:\r\n// Reader class for IP-XACT OtherClockDriver element.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"OtherClockDriverReader.h\"\r\n\r\n#include <IPXACTmodels/common/ClockUnit.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: OtherClockDriverReader::createCPUFrom()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<OtherClockDriver> OtherClockDriverReader::createOtherClockDriverFrom\r\n\t(QDomNode const& otherClockDriverNode) const\r\n{\r\n\tQSharedPointer<OtherClockDriver> newOtherClockDriver (new OtherClockDriver());\r\n\r\n    parseClockDriverAttributes(otherClockDriverNode, newOtherClockDriver);\r\n\r\n    newOtherClockDriver->setClockPeriod(parseClockUnit(otherClockDriverNode, QStringLiteral(\"ipxact:clockPeriod\")));\r\n\r\n    newOtherClockDriver->setClockPulseOffset(parseClockUnit(otherClockDriverNode, QStringLiteral(\"ipxact:clockPulseOffset\")));\r\n\r\n    parseClockPulseValue(otherClockDriverNode, newOtherClockDriver);\r\n\r\n    newOtherClockDriver->setClockPulseDuration(parseClockUnit(otherClockDriverNode, QStringLiteral(\"ipxact:clockPulseDuration\")));\r\n\r\n    return newOtherClockDriver;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: OtherClockDriverReader::parseClockDriverAttributes()\r\n//-----------------------------------------------------------------------------\r\nvoid OtherClockDriverReader::parseClockDriverAttributes(QDomNode const& otherClockDriverNode,\r\n    QSharedPointer<OtherClockDriver> newOtherClockDriver) const\r\n{\r\n    QString name = otherClockDriverNode.toElement().attribute(QStringLiteral(\"clockName\"));\r\n    newOtherClockDriver->setClockName(name);\r\n\r\n    if (otherClockDriverNode.toElement().hasAttribute(QStringLiteral(\"clockSource\")))\r\n    {\r\n        QString clockSource = otherClockDriverNode.toElement().attribute(QStringLiteral(\"clockSource\"));\r\n        newOtherClockDriver->setClockSource(clockSource);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: OtherClockDriverReader::parseClockUnit()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<ClockUnit> OtherClockDriverReader::parseClockUnit(QDomNode const& otherClockDriverNode,\r\n    QString const& elementName) const\r\n{\r\n    QDomElement childElement = otherClockDriverNode.firstChildElement(elementName);\r\n\r\n    QString value = childElement.firstChild().nodeValue();\r\n    QSharedPointer<ClockUnit> newClockUnit (new ClockUnit(value));\r\n\r\n    if (childElement.hasAttribute(QStringLiteral(\"units\")))\r\n    {\r\n        QString timeUnit = childElement.attribute(QStringLiteral(\"units\"));\r\n        newClockUnit->setTimeUnit(timeUnit);\r\n    }\r\n\r\n    return newClockUnit;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: OtherClockDriverReader::parseClockDriverAttributes()\r\n//-----------------------------------------------------------------------------\r\nvoid OtherClockDriverReader::parseClockPulseValue(QDomNode const& otherClockDriverNode,\r\n    QSharedPointer<OtherClockDriver> newOtherClockDriver) const\r\n{\r\n    QString pulseValue = otherClockDriverNode.firstChildElement(QStringLiteral(\"ipxact:clockPulseValue\")).firstChild().nodeValue();\r\n    newOtherClockDriver->setClockPulseValue(pulseValue);\r\n}\r\n"
  },
  {
    "path": "IPXACTmodels/Component/OtherClockDriverReader.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: OtherClockDriverReader.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Janne Virtanen\r\n// Date: 02.10.2015\r\n//\r\n// Description:\r\n// Reader class for IP-XACT OtherClockDriver element.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef OtherClockDriverReader_H\r\n#define OtherClockDriverReader_H\r\n\r\n#include \"OtherClockDriver.h\"\r\n\r\n#include <IPXACTmodels/common/ClockUnit.h>\r\n\r\n#include <QSharedPointer>\r\n#include <QDomNode>\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Reader class for IP-XACT OtherClockDriver element.\r\n//-----------------------------------------------------------------------------\r\nclass IPXACTMODELS_EXPORT OtherClockDriverReader\r\n{\r\npublic:\r\n\r\n    /*!\r\n     *  Creates a new OtherClockDriver from a given OtherClockDriver node.\r\n     *\r\n     *    @param [in] OtherClockDriverNode    XML description of the OtherClockDriver.\r\n     */\r\n    QSharedPointer<OtherClockDriver> createOtherClockDriverFrom(QDomNode const& otherClockDriverNode) const;\r\n\r\nprivate:\r\n\r\n    /*!\r\n     *  Parse the clock driver attributes.\r\n     *\r\n     *    @param [in] otherClockDriverNode    XML description of the other clock driver.\r\n     *    @param [in] newOtherClockDriver     The new other clock driver.\r\n     */\r\n    void parseClockDriverAttributes(QDomNode const& otherClockDriverNode,\r\n        QSharedPointer<OtherClockDriver> newOtherClockDriver) const;\r\n\r\n    /*!\r\n     *  Parse a clock unit.\r\n     *\r\n     *    @param [in] otherClockDriverNode    XML description of the other clock driver.\r\n     *    @param [in] elementName             The name of the clock unit element.\r\n     */\r\n    QSharedPointer<ClockUnit> parseClockUnit(QDomNode const& otherClockDriverNode, QString const& elementName) const;\r\n\r\n    /*!\r\n     *  Parse the clock pulse value.\r\n     *\r\n     *    @param [in] otherClockDriverNode    XML description of the other clock driver.\r\n     *    @param [in] newOtherClockDriver     The new other clock driver.\r\n     */\r\n    void parseClockPulseValue(QDomNode const& otherClockDriverNode,\r\n        QSharedPointer<OtherClockDriver> newOtherClockDriver) const;\r\n};\r\n\r\n#endif // OtherClockDriverReader_H"
  },
  {
    "path": "IPXACTmodels/Component/OtherClockDriverWriter.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: OtherClockDriverWriter.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Janne Virtanen\r\n// Date: 02.10.2015\r\n//\r\n// Description:\r\n// Writer class for IP-XACT OtherClockDriver element.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"OtherClockDriverWriter.h\"\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: OtherClockDriverWriter::writeOtherClockDriver()\r\n//-----------------------------------------------------------------------------\r\nvoid OtherClockDriverWriter::writeOtherClockDriver(QXmlStreamWriter& writer, QSharedPointer<OtherClockDriver> otherClockDriver) const\r\n{\r\n\twriter.writeStartElement(QStringLiteral(\"ipxact:otherClockDriver\"));\r\n\r\n    writeClockDriverAttributes(writer, otherClockDriver);\r\n\r\n    writeClockUnit(writer, otherClockDriver->getClockPeriod(), QStringLiteral(\"ipxact:clockPeriod\"));\r\n\r\n    writeClockUnit(writer, otherClockDriver->getClockPulseOffset(), QStringLiteral(\"ipxact:clockPulseOffset\"));\r\n\r\n    writer.writeTextElement(QStringLiteral(\"ipxact:clockPulseValue\"), otherClockDriver->getClockPulseValue());\r\n\r\n    writeClockUnit(writer, otherClockDriver->getClockPulseDuration(), QStringLiteral(\"ipxact:clockPulseDuration\"));\r\n\r\n\twriter.writeEndElement();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: OtherClockDriverWriter::writeClockDriverAttributes()\r\n//-----------------------------------------------------------------------------\r\nvoid OtherClockDriverWriter::writeClockDriverAttributes(QXmlStreamWriter& writer,\r\n    QSharedPointer<OtherClockDriver> otherClockDriver) const\r\n{\r\n    writer.writeAttribute(QStringLiteral(\"clockName\"), otherClockDriver->getClockName());\r\n\r\n    if (!otherClockDriver->getClockSource().isEmpty())\r\n    {\r\n        writer.writeAttribute(QStringLiteral(\"clockSource\"), otherClockDriver->getClockSource());\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: OtherClockDriverWriter::writeClockUnit()\r\n//-----------------------------------------------------------------------------\r\nvoid OtherClockDriverWriter::writeClockUnit(QXmlStreamWriter& writer, QSharedPointer<ClockUnit> clockUnit,\r\n    QString const& elementName) const\r\n{\r\n    writer.writeStartElement(elementName);\r\n\r\n    if (clockUnit->getTimeUnit() != ClockUnit::TIMEUNIT_UNSPECIFIED)\r\n    {\r\n        writer.writeAttribute(QStringLiteral(\"units\"), clockUnit->timeUnitToString());\r\n    }\r\n\r\n    writer.writeCharacters(clockUnit->getValue());\r\n\r\n    writer.writeEndElement(); // elementName\r\n}\r\n"
  },
  {
    "path": "IPXACTmodels/Component/OtherClockDriverWriter.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: OtherClockDriverWriter.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Janne Virtanen\r\n// Date: 02.10.2015\r\n//\r\n// Description:\r\n// Writer class for IP-XACT OtherClockDriver element.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef OtherClockDriverWriter_H\r\n#define OtherClockDriverWriter_H\r\n\r\n#include \"OtherClockDriver.h\"\r\n\r\n#include <IPXACTmodels/ipxactmodels_global.h>\r\n\r\n#include <QXmlStreamWriter>\r\n#include <QSharedPointer>\r\n\r\nclass ClockUnit;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Writer class for IP-XACT OtherClockDriver element.\r\n//-----------------------------------------------------------------------------\r\nclass IPXACTMODELS_EXPORT OtherClockDriverWriter \r\n{\r\npublic:\r\n\r\n    /*!\r\n     *  Write a OtherClockDriver to an XML file.\r\n     *\r\n     *    @param [in] writer  The used xml writer.\r\n     *    @param [in] OtherClockDriver\t\tThe OtherClockDriver to be written.\r\n     */\r\n    void writeOtherClockDriver(QXmlStreamWriter& writer, QSharedPointer<OtherClockDriver> otherClockDriver) const;\r\n\r\nprivate:\r\n\r\n    /*!\r\n     *  Write the other clock driver attributes.\r\n     *\r\n     *    @param [in] writer              The used XML writer.\r\n     *    @param [in] otherClockDriver    The new other clock driver.\r\n     */\r\n    void writeClockDriverAttributes(QXmlStreamWriter& writer, QSharedPointer<OtherClockDriver> otherClockDriver) const;\r\n\r\n    /*!\r\n     *  Write a clock unit.\r\n     *\r\n     *    @param [in] writer          The used XML writer.\r\n     *    @param [in] clockUnit       The new other clock driver.\r\n     *    @param [in] elementName     The name of the element being written.\r\n     */\r\n    void writeClockUnit(QXmlStreamWriter& writer, QSharedPointer<ClockUnit> clockUnit, QString const& elementName)\r\n        const;\r\n};\r\n\r\n#endif // OtherClockDriverWriter_H"
  },
  {
    "path": "IPXACTmodels/Component/Port.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: Port.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 11.09.2015\r\n//\r\n// Description:\r\n// Describes the ipxact:port element.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"Port.h\"\r\n#include \"Transactional.h\"\r\n#include \"Wire.h\"\r\n\r\n#include <IPXACTmodels/kactusExtensions/Kactus2Placeholder.h>\r\n#include <IPXACTmodels/kactusExtensions/Kactus2Position.h>\r\n#include <IPXACTmodels/kactusExtensions/Kactus2Value.h>\r\n\r\n#include <IPXACTmodels/utilities/Copy.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Port::Port()\r\n//-----------------------------------------------------------------------------\r\nPort::Port(QString const& portName) :\r\nNameGroup(portName),\r\nExtendable()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Port::Port()\r\n//-----------------------------------------------------------------------------\r\nPort::Port(const Port &other): \r\nNameGroup(other),\r\nExtendable(other),\r\nisPresent_(other.isPresent_)\r\n{\r\n    if (other.wire_)\r\n    {\r\n        wire_ = QSharedPointer<Wire>(other.wire_->clone());\r\n\t}\r\n\r\n\tif (other.transactional_)\r\n    {\r\n        transactional_ = QSharedPointer<Transactional>(other.transactional_->clone());\r\n\t}\r\n\r\n    if (other.structured_)\r\n    {\r\n        structured_ = QSharedPointer<Structured>(other.structured_->clone());\r\n    }\r\n\r\n    Copy::copyList(other.configurableArrays_, configurableArrays_);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Port::operator=()\r\n//-----------------------------------------------------------------------------\r\nPort & Port::operator=( const Port &other )\r\n{\r\n    if (this != &other)\r\n    {\r\n\t\tNameGroup::operator=(other);\r\n        Extendable::operator=(other);\r\n        isPresent_ = other.isPresent_;\r\n\r\n        wire_.clear();\r\n\t\tif (other.wire_)\r\n        {\r\n            wire_ = QSharedPointer<Wire>(other.wire_->clone());\r\n        }\r\n\r\n        transactional_.clear();\r\n\t\tif (other.transactional_) \r\n        {\r\n\t\t\ttransactional_ = QSharedPointer<Transactional>(other.transactional_->clone());\r\n\t\t}\r\n\r\n        structured_.clear();\r\n\t\tif (other.structured_)\r\n\t\t{\r\n\t\t\tstructured_ = QSharedPointer<Structured>(other.structured_->clone());\r\n\t\t}\r\n\r\n        configurableArrays_->clear();\r\n        Copy::copyList(other.configurableArrays_, configurableArrays_);\r\n\t}\r\n\treturn *this;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Port::getWire()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<Wire> Port::getWire() const\r\n{\r\n    return wire_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Port::setWire()\r\n//-----------------------------------------------------------------------------\r\nvoid Port::setWire(QSharedPointer<Wire> newWire)\r\n{\r\n    transactional_.clear();\r\n    structured_.clear();\r\n\r\n    wire_ = newWire;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Port::getTransactional()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<Transactional> Port::getTransactional() const\r\n{\r\n    return transactional_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Port::setTransactional()\r\n//-----------------------------------------------------------------------------\r\nvoid Port::setTransactional(QSharedPointer<Transactional> newTransactional)\r\n{\r\n    wire_.clear();\r\n    structured_.clear();\r\n\r\n\ttransactional_ = newTransactional;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Port::getStructured()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<Structured> Port::getStructured() const\r\n{\r\n    return structured_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Port::setStructural()\r\n//-----------------------------------------------------------------------------\r\nvoid Port::setStructured(QSharedPointer<Structured> newStructured)\r\n{\r\n    wire_.clear();\r\n    transactional_.clear();\r\n\r\n    structured_ = newStructured;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Port::getLeftBound()\r\n//-----------------------------------------------------------------------------\r\nQString Port::getLeftBound() const\r\n{\r\n    if (wire_)\r\n    {\r\n        return wire_->getVectorLeftBound();\r\n    }\r\n\r\n    return QStringLiteral(\"0\");\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Port::setLeftBound()\r\n//-----------------------------------------------------------------------------\r\nvoid Port::setLeftBound(QString const& newLeftBound)\r\n{\r\n    if (wire_.isNull())\r\n    {\r\n        wire_ = QSharedPointer<Wire>(new Wire());\r\n    }\r\n\r\n    wire_->setVectorLeftBound(newLeftBound);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Port::getRightBound()\r\n//-----------------------------------------------------------------------------\r\nQString Port::getRightBound() const\r\n{\r\n    if (wire_)\r\n    {\r\n        return wire_->getVectorRightBound();\r\n    }\r\n\r\n    return QStringLiteral(\"0\");\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Port::setRightBound()\r\n//-----------------------------------------------------------------------------\r\nvoid Port::setRightBound(QString const& newRightBound)\r\n{\r\n    if (wire_.isNull())\r\n    {\r\n        wire_ = QSharedPointer<Wire>(new Wire());\r\n    }\r\n\r\n    wire_->setVectorRightBound(newRightBound);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Port::setPortSize()\r\n//-----------------------------------------------------------------------------\r\nvoid Port::setPortSize( int size )\r\n{\r\n    setLeftBound(QString::number(qMax(0, size-1)));\r\n    setRightBound(QStringLiteral(\"0\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Port::getDefaultValue()\r\n//-----------------------------------------------------------------------------\r\nQString Port::getDefaultValue() const\r\n{\r\n    if (!wire_)\r\n    {\r\n        return QString();\r\n    }\r\n    return wire_->getDefaultDriverValue();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Port::setDefaultValue()\r\n//-----------------------------------------------------------------------------\r\nvoid Port::setDefaultValue( const QString& defaultValue )\r\n{\r\n    if (wire_)\r\n    {\r\n        wire_->setDefaultDriverValue(defaultValue);\r\n    }\r\n    else if (!transactional_)\r\n    {\r\n        wire_ = QSharedPointer<Wire>(new Wire());\r\n        wire_->setDefaultDriverValue(defaultValue);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Port::getDirection()\r\n//-----------------------------------------------------------------------------\r\nDirectionTypes::Direction Port::getDirection() const\r\n{\r\n    if (wire_)\r\n    {\r\n        return wire_->getDirection();\r\n    }\r\n    return DirectionTypes::DIRECTION_INVALID;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Port::setDirection()\r\n//-----------------------------------------------------------------------------\r\nvoid Port::setDirection(DirectionTypes::Direction direction)\r\n{\r\n    if (wire_)\r\n    {\r\n        wire_->setDirection(direction);\r\n    }\r\n    else if (!transactional_)\r\n    {\r\n        wire_ = QSharedPointer<Wire>(new Wire());\r\n        wire_->setDirection(direction);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Port::allLogicalDirectionsAllowed()\r\n//-----------------------------------------------------------------------------\r\nbool Port::allLogicalDirectionsAllowed() const\r\n{\r\n    if (wire_)\r\n    {\r\n        return wire_->getAllLogicalDirectionsAllowed();\r\n    }\r\n    else if (transactional_)\r\n    {\r\n        return transactional_->getAllLogicalInitiativesAllowed();\r\n    }\r\n\r\n    return false;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Port::setAllLogicalDirectionsAllowed()\r\n//-----------------------------------------------------------------------------\r\nvoid Port::setAllLogicalDirectionsAllowed( bool allowed )\r\n{\r\n    if (wire_)\r\n    {\r\n        wire_->setAllLogicalDirectionsAllowed(allowed);\r\n    }\r\n    else if (transactional_)\r\n    {\r\n        transactional_->setAllLogicalInitiativesAllowed(allowed);\r\n    }\r\n    else \r\n    {\r\n        wire_ = QSharedPointer<Wire>(new Wire());\r\n        wire_->setAllLogicalDirectionsAllowed(allowed);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Port::getTypeName()\r\n//-----------------------------------------------------------------------------\r\nQString Port::getTypeName( const QString& viewName ) const\r\n{\r\n    if (wire_)\r\n    {\r\n        return wire_->getTypeName(viewName);\r\n    }\r\n    else if (transactional_)\r\n    {\r\n        return transactional_->getTypeName(viewName);\r\n    }\r\n    else \r\n    {\r\n        return QString();\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Port::setTypeName()\r\n//-----------------------------------------------------------------------------\r\nvoid Port::setTypeName( const QString& typeName, const QString& viewName )\r\n{\r\n    if (wire_)\r\n    {\r\n        wire_->setTypeName(typeName, viewName);\r\n    }\r\n    else if (transactional_)\r\n    {\r\n        transactional_->setTypeName(typeName, viewName);\r\n    }\r\n    else\r\n    {\r\n        wire_ = QSharedPointer<Wire>(new Wire());\r\n        wire_->setTypeName(typeName, viewName);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Port::hasType()\r\n//-----------------------------------------------------------------------------\r\nbool Port::hasType( const QString& viewName ) const\r\n{\r\n    if (wire_)\r\n    {\r\n        return wire_->hasType(viewName);\r\n    }\r\n    else if (transactional_)\r\n    {\r\n        return transactional_->hasType(viewName);\r\n    }\r\n\r\n    return false;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Port::getTypeDefinition()\r\n//-----------------------------------------------------------------------------\r\nQString Port::getTypeDefinition( const QString& typeName ) const\r\n{\r\n    if (wire_)\r\n    {\r\n        return wire_->getTypeDefinition(typeName);\r\n    }\r\n    else if (transactional_)\r\n    {\r\n        return transactional_->getTypeDefinition(typeName);\r\n    }\r\n    else\r\n    {\r\n        return QString();\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Port::getTypeDefinitions()\r\n//-----------------------------------------------------------------------------\r\nQStringList Port::getTypeDefinitions() const\r\n{\r\n    if (wire_)\r\n    {\r\n        return wire_->getTypeDefinitions();\r\n    }\r\n    else if (transactional_)\r\n    {\r\n        return transactional_->getTypeDefinitions();\r\n    }\r\n    else\r\n    {\r\n        return QStringList();\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Port::setTypeDefinition()\r\n//-----------------------------------------------------------------------------\r\nvoid Port::setTypeDefinition( const QString& typeName, const QString& typeDefinition )\r\n{\r\n    if (wire_)\r\n    {\r\n        wire_->setTypeDefinition(typeName, typeDefinition);\r\n    }\r\n    else if (transactional_)\r\n    {\r\n        transactional_->setTypeDefinition(typeName, typeDefinition);\r\n    }\r\n    else\r\n    {\r\n        wire_ = QSharedPointer<Wire>(new Wire());\r\n        wire_->setTypeDefinition(typeName, typeDefinition);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Port::hasTypeDefinitions()\r\n//-----------------------------------------------------------------------------\r\nbool Port::hasTypeDefinitions() const\r\n{\r\n    if (wire_)\r\n    {\r\n        return wire_->hasTypeDefinition();\r\n    }\r\n    else if (transactional_)\r\n    {\r\n        return transactional_->hasTypeDefinitions();\r\n    }\r\n    else\r\n    {\r\n        return false;\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Port::isAdHocVisible()\r\n//-----------------------------------------------------------------------------\r\nbool Port::isAdHocVisible() const\r\n{\r\n    return std::any_of(getVendorExtensions()->cbegin(), getVendorExtensions()->cend(),\r\n        [](auto const& extension) { return extension->type() == QStringLiteral(\"kactus2:adHocVisible\"); });\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Port::setAdHocVisible()\r\n//-----------------------------------------------------------------------------\r\nvoid Port::setAdHocVisible(bool visible)\r\n{\r\n    auto adHocExtension = findVendorExtension(QStringLiteral(\"kactus2:adHocVisible\"));\r\n   \r\n    if (visible && adHocExtension.isNull())\r\n    {\r\n        QSharedPointer<Kactus2Placeholder> adHocVisibility(new Kactus2Placeholder(\r\n            QStringLiteral(\"kactus2:adHocVisible\")));\r\n        getVendorExtensions()->append(adHocVisibility);\r\n    }\r\n    else if (visible == false)\r\n    {\r\n        getVendorExtensions()->removeAll(adHocExtension);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Port::getDefaultPos()\r\n//-----------------------------------------------------------------------------\r\nQPointF Port::getDefaultPos() const\r\n{\r\n    if (auto positionExtension = findVendorExtension(QStringLiteral(\"kactus2:position\")); \r\n        positionExtension.isNull() == false)\r\n    {\r\n        return positionExtension.dynamicCast<Kactus2Position>()->position();\r\n    }\r\n\r\n    return QPointF();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Port::setDefaultPos()\r\n//-----------------------------------------------------------------------------\r\nvoid Port::setDefaultPos(QPointF const& pos)\r\n{\r\n    auto positionExtension = findVendorExtension(QStringLiteral(\"kactus2:position\")).dynamicCast<Kactus2Position>();\r\n    if (positionExtension.isNull())\r\n    {\r\n        positionExtension = QSharedPointer<Kactus2Position>(new Kactus2Position(pos));\r\n        getVendorExtensions()->append(positionExtension);\r\n    }\r\n\r\n    positionExtension->setPosition(pos);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: port::getArrayLeft()\r\n//-----------------------------------------------------------------------------\r\nQString Port::getArrayLeft() const\r\n{\r\n    if (configurableArrays_->isEmpty())\r\n    {\r\n        return QString();\r\n    }\r\n\r\n    return configurableArrays_->first().getLeft();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: port::setArrayLeft()\r\n//-----------------------------------------------------------------------------\r\nvoid Port::setArrayLeft(QString const& newArrayLeft)\r\n{\r\n    if (configurableArrays_->isEmpty())\r\n    {\r\n        configurableArrays_->append(Array(newArrayLeft, QStringLiteral(\"0\")));\r\n    }\r\n    else\r\n    {\r\n        auto& portArray = configurableArrays_->first();\r\n        if (newArrayLeft.isEmpty() && portArray.getRight().isEmpty())\r\n        {\r\n            configurableArrays_->removeFirst();\r\n        }\r\n        else\r\n        {\r\n            portArray.setLeft(newArrayLeft);\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: port::getArrayRight()\r\n//-----------------------------------------------------------------------------\r\nQString Port::getArrayRight() const\r\n{\r\n    if (configurableArrays_->isEmpty())\r\n    {\r\n        return QString();\r\n    }\r\n    \r\n    return configurableArrays_->first().getRight();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: port::setArrayRight()\r\n//-----------------------------------------------------------------------------\r\nvoid Port::setArrayRight(QString const& newArrayRight)\r\n{\r\n    if (configurableArrays_->isEmpty())\r\n    {\r\n        configurableArrays_->append(Array(QStringLiteral(\"0\"), newArrayRight));\r\n    }\r\n    else\r\n    {\r\n        auto& portArray = configurableArrays_->first();\r\n        if (portArray.getLeft().isEmpty() && newArrayRight.isEmpty())\r\n        {\r\n            configurableArrays_->removeFirst();\r\n        }\r\n        else\r\n        {\r\n            portArray.setRight(newArrayRight);\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: port::getPortTags()\r\n//-----------------------------------------------------------------------------\r\nQString Port::getPortTags() const\r\n{\r\n    auto tagExtension = findVendorExtension(QStringLiteral(\"kactus2:portTags\")).dynamicCast<Kactus2Value>();\r\n    if (tagExtension.isNull())\r\n    {\r\n        return QString();\r\n    }\r\n\r\n    return tagExtension->value();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: port::setPortTags()\r\n//-----------------------------------------------------------------------------\r\nvoid Port::setPortTags(const QString& newPortTags)\r\n{\r\n    auto tagExtension = findVendorExtension(QStringLiteral(\"kactus2:portTags\")).dynamicCast<Kactus2Value>();\r\n\r\n    if (newPortTags.isEmpty())\r\n    {\r\n        getVendorExtensions()->removeAll(tagExtension);\r\n    }\r\n    else if (tagExtension.isNull())\r\n    {\r\n        tagExtension = QSharedPointer<Kactus2Value>(new Kactus2Value(QStringLiteral(\"kactus2:portTags\"), newPortTags));\r\n        getVendorExtensions()->append(tagExtension);\r\n    }\r\n    else\r\n    {\r\n        tagExtension->setValue(newPortTags);\r\n    }    \r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Port::getIsPresent()\r\n//-----------------------------------------------------------------------------\r\nQString Port::getIsPresent() const\r\n{\r\n    return isPresent_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Port::setIsPresent()\r\n//-----------------------------------------------------------------------------\r\nvoid Port::setIsPresent(QString const& newIsPresent)\r\n{\r\n    isPresent_ = newIsPresent;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Port::getArrays()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<QList<Array> > Port::getArrays() const\r\n{\r\n    return configurableArrays_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Port::getTypes()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<QList<QSharedPointer<WireTypeDef> > > Port::getWireTypes() const\r\n{\r\n    if (wire_)\r\n    {\r\n        return wire_->getWireTypeDefs();\r\n    }\r\n\r\n    return nullptr;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Port::getTransactionalTypes()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<QList<QSharedPointer<WireTypeDef> > > Port::getTransactionalTypes() const\r\n{\r\n    if (transactional_)\r\n    {\r\n        return transactional_->getTransTypeDef();\r\n    }\r\n\r\n    return nullptr;\r\n}\r\n"
  },
  {
    "path": "IPXACTmodels/Component/Port.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: Port.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 10.09.2015\r\n//\r\n// Description:\r\n// Describes the ipxact:port element.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef PORT_H\r\n#define PORT_H\r\n\r\n#include <IPXACTmodels/ipxactmodels_global.h>\r\n\r\n#include <IPXACTmodels/common/DirectionTypes.h>\r\n#include <IPXACTmodels/common/NameGroup.h>\r\n#include <IPXACTmodels/common/Extendable.h>\r\n#include <IPXACTmodels/common/Array.h>\r\n\r\n#include <IPXACTmodels/Component/Structured.h>\r\n#include <IPXACTmodels/Component/Transactional.h>\r\n#include <IPXACTmodels/Component/Wire.h>\r\n\r\n#include <QString>\r\n#include <QList>\r\n#include <QSharedPointer>\r\n#include <QStringList>\r\n#include <QPointF>\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Describes the ipxact:port element.\r\n//-----------------------------------------------------------------------------\r\nclass IPXACTMODELS_EXPORT Port : public NameGroup, public Extendable\r\n{\r\n\r\npublic:\r\n\r\n    using List = QSharedPointer<QList<QSharedPointer<Port> > >;\r\n\r\n\t/*!\r\n\t *  The constructor.\r\n\t *\r\n\t *    @param [in] portName    Name of the port.\r\n\t */\r\n    explicit Port(QString const& portName = QString());\r\n\r\n    /*!\r\n     *  Copy constructor.\r\n\t */\r\n\tPort(const Port &other);\r\n\r\n\t/*!\r\n\t *  Assignment operator.\r\n\t */\r\n\tPort &operator=(const Port &other);\r\n\r\n\t/*!\r\n\t *  The destructor.\r\n\t */\r\n\t~Port() = default;\r\n    \r\n    /*!\r\n     *  Get a pointer to the wire element.\r\n     *\r\n     *    @return A pointer to the wire instance.\r\n     */\r\n    QSharedPointer<Wire> getWire() const;\r\n\r\n    /*!\r\n     *  Set the wire element for the port.\r\n     *\r\n     *    @param [in] newWire     The new wire element.\r\n     */\r\n    void setWire(QSharedPointer<Wire> newWire);\r\n\r\n    /*!\r\n     *  Get a pointer to the transactional element.\r\n     *\r\n     *    @return Pointer to the transactional element.\r\n     */\r\n    QSharedPointer<Transactional> getTransactional() const;\r\n\r\n    /*!\r\n     *  Set the transactional element for the port.\r\n     *\r\n     *    @param [in] newTransactional    The new transactional element.\r\n     */\r\n    void setTransactional(QSharedPointer<Transactional> newTransactional);\r\n\r\n    /*!\r\n     *  Get the structured element.\r\n     *\r\n     *    @return The structured element.\r\n     */\r\n    QSharedPointer<Structured> getStructured() const;\r\n\r\n    /*!\r\n     *  Set the structured element for the port.\r\n     *\r\n     *    @param [in] newStructural    The new structural element.\r\n     */\r\n    void setStructured(QSharedPointer<Structured> newStructured);\r\n\r\n    /*!\r\n     *  Get the left bound of a vectored port.\r\n     *\r\n     *    @return the left bound of the port.\r\n     */\r\n    QString getLeftBound() const;\r\n        \r\n    /*!\r\n     *  Set the left bound of the port.\r\n     *\r\n     *    @param [in] newLeftBound    The new left bound of the port.\r\n     */\r\n    void setLeftBound(QString const& newLeftBound);\r\n    \r\n    /*!\r\n     *  Get the right bound of a vectored port.\r\n     *\r\n     *    @return The right bound of the port.\r\n     */\r\n    QString getRightBound() const;\r\n\r\n    /*!\r\n     *  Set the right bound of the port.\r\n     *\r\n     *    @param [in] newRightBound   The new right bound of the port.\r\n     */\r\n    void setRightBound(QString const& newRightBound);\r\n\r\n\t/*!\r\n\t *  Set the size of the port.\r\n\t *\r\n\t *    @param [in] size    The new size. Port bounds are set to size-1 and 0;\r\n\t */\r\n\tvoid setPortSize(int size);\r\n    \r\n    /*!\r\n     *  Get the default value of the port.\r\n     *\r\n     *    @return The contained default value.\r\n     */\r\n    QString getDefaultValue() const;\r\n    \r\n\t/*!\r\n\t *  Set the default value for the port.\r\n\t *\r\n\t *    @param [in] defaultValue    The new default value.\r\n\t */\r\n\tvoid setDefaultValue(const QString& defaultValue);\r\n    \r\n    /*!\r\n     *  Get the direction of the port.\r\n     *\r\n     *    @return Enum direction.\r\n     */\r\n    DirectionTypes::Direction getDirection() const;\r\n\r\n\t/*!\r\n\t *  Set the direction.\r\n\t *\r\n\t *    @param [in] direction   The new direction.\r\n\t */\r\n\tvoid setDirection(DirectionTypes::Direction direction);\r\n    \r\n\t/*!\r\n\t *  Get the value of the logical directions allowed for wires or logical initiatives allowed for transactionals.\r\n\t *\r\n     *    @return True, if the given value is allowed, false otherwise.\r\n\t */\r\n\tbool allLogicalDirectionsAllowed() const;\r\n    \r\n\t/*!\r\n\t *  Set the port to allow/disallow logical directions / initiatives.\r\n\t *\r\n\t *    @param [in] allowed     The setting.\r\n\t */\r\n\tvoid setAllLogicalDirectionsAllowed(bool allowed);\r\n\r\n\t/*!\r\n\t *  Get the type name of the port for a given view.\r\n\t *\r\n\t *    @param [in] viewName    The name of the view.\r\n     *\r\n     *    @return The matching type name.\r\n\t */\r\n\tQString getTypeName(const QString& viewName = QString()) const;\r\n    \r\n\t/*!\r\n\t *  Set the type name for the port in given view.\r\n\t *\r\n\t *    @param [in] typeName    The name of the type.\r\n\t *    @param [in] viewName    The name of the view used for this type.\r\n\t */\r\n\tvoid setTypeName(const QString& typeName, const QString& viewName = QString());\r\n\r\n\t/*!\r\n\t *  Check if the port has a type name in given view.\r\n\t *\r\n\t *    @param [in] viewName    The name of the view that's type name is searched for.\r\n     *\r\n     *    @return True if a type is found, false otherwise.\r\n\t */\r\n\tbool hasType(const QString& viewName = QString()) const;\r\n    \r\n\t/*!\r\n\t *  Get the type definition of the given type name.\r\n\t *\r\n\t *    @param [in] typeName    The name of the type that's type definition is wanted.\r\n     *    @return The found type definition.\r\n\t */\r\n\tQString getTypeDefinition(const QString& typeName) const;\r\n\r\n\t/*!\r\n\t *  Get the type definitions of the wired port.\r\n\t *\r\n     *    @return A list containing the type definitions.\r\n\t */\r\n\tQStringList getTypeDefinitions() const;\r\n\r\n\t/*!\r\n\t *  Set the type definition of the given type name.\r\n\t *\r\n\t *    @param [in] typeName        Identifies the type definition.\r\n\t *    @param [in] typeDefinition  The type definition to be set.\r\n\t */\r\n\tvoid setTypeDefinition(const QString& typeName, const QString& typeDefinition);\r\n\r\n\t/*!\r\n\t *  Check if the port has a type definition.\r\n\t *\r\n     *    @return True if the type definition is defined.\r\n\t */\r\n\tbool hasTypeDefinitions() const;\r\n        \r\n    /*!\r\n     *  Returns true if the ad-hoc visibility is turned on.\r\n     */\r\n    bool isAdHocVisible() const;\r\n\r\n    /*!\r\n     *  Sets default the ad-hoc visibility of the port.\r\n     *\r\n     *    @param [in] visible If true, the port is set visible for ad-hoc connections.\r\n     */\r\n    void setAdHocVisible(bool visible);\r\n\r\n    /*!\r\n     *  Returns the default position in the parent component's graphical representation.\r\n     */\r\n    QPointF getDefaultPos() const;\r\n\r\n    /*!\r\n     *  Sets the default position in the parent component's graphical representation.\r\n     *\r\n     *    @param [in] pos The position to set.\r\n     */\r\n    void setDefaultPos(QPointF const& pos);\r\n\r\n    /*!\r\n     *  Gets the left value of the array.\r\n     *\r\n     *    @return The left value of the array.\r\n     */\r\n    QString getArrayLeft() const;\r\n\r\n    /*!\r\n     *  Sets the left value for the array.\r\n     *\r\n     *    @param [in] newArrayLeft    The value to be set as left.\r\n     */\r\n    void setArrayLeft(QString const& newArrayLeft);\r\n\r\n    /*!\r\n     *  Gets the right value of the array.\r\n     *\r\n     *    @return The right value of the array.\r\n     */\r\n    QString getArrayRight() const;\r\n\r\n    /*!\r\n     *  Sets the right value for the array.\r\n     *\r\n     *    @param [in] newArrayRight   The value to be set as right.\r\n     */\r\n    void setArrayRight(QString const& newArrayRight);\r\n\r\n    /*!\r\n     *  Gets the tags associated with the port.\r\n     *\r\n     *    @return Tags associated with the port.\r\n     */\r\n    QString getPortTags() const;\r\n\r\n    /*!\r\n     *  Set the port tags.\r\n     *\r\n     *    @param [in] portTags    The tags separated by a comma.\r\n     */\r\n    void setPortTags(const QString& portTags);\r\n\r\n    /*!\r\n     *  Get the presence of the port.\r\n     *\r\n     *    @return The presence.\r\n     */\r\n    QString getIsPresent() const;\r\n\r\n    /*!\r\n     *  Set the presence for the port.\r\n     *\r\n     *    @param [in] newIsPresent    The new presence expression.\r\n     */\r\n    void setIsPresent(QString const& newIsPresent);\r\n    \r\n    /*!\r\n     *  Get the arrays associated with the port.\r\n     *\r\n     *    @return Pointer to a list containing the arrays.\r\n     */\r\n    QSharedPointer<QList<Array> > getArrays() const;\r\n\r\n    /*!\r\n     *  Get the wire type definitions.\r\n     *\r\n     *    @return The type definitions contained within the wire port.\r\n     */\r\n    QSharedPointer<QList<QSharedPointer<WireTypeDef> > > getWireTypes() const;\r\n\r\n    /*!\r\n     *  Get the transactional type definitions.\r\n     *\r\n     *    @return The type definitions contained within the transactional port.\r\n     */\r\n    QSharedPointer<QList<QSharedPointer<WireTypeDef> > > getTransactionalTypes() const;\r\n\r\nprivate:\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! The presence of the port.\r\n    QString isPresent_;\r\n\r\n    //! The wire port type.\r\n    QSharedPointer<Wire> wire_{ nullptr };\r\n\r\n    //! Transactional port type.\r\n\tQSharedPointer<Transactional> transactional_{ nullptr };\r\n\r\n    //! Structural port type.\r\n    QSharedPointer<Structured> structured_{ nullptr };\r\n\r\n    //! The list of arrays.\r\n    QSharedPointer<QList<Array > > configurableArrays_{ new QList<Array>() };\r\n};\r\n\r\nQ_DECLARE_METATYPE(QSharedPointer<Port>)\r\n\r\n#endif // PORT_H\r\n"
  },
  {
    "path": "IPXACTmodels/Component/PortMap.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: PortMap.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Esko Pekkarinen\r\n// Date: 28.08.2014\r\n//\r\n// Description:\r\n// Implementation for ipxact:portMap.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"PortMap.h\"\r\n\r\n#include <IPXACTmodels/common/Vector.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PortMap::PortMap()\r\n//-----------------------------------------------------------------------------\r\nPortMap::PortMap(): \r\n    Extendable()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PortMap::PortMap()\r\n//-----------------------------------------------------------------------------\r\nPortMap::PortMap(PortMap const& other): \r\n    Extendable(other),\r\ninvert_(other.invert_),\r\nisPresent_(other.isPresent_),\r\nlogicalTieOff_(other.logicalTieOff_),\r\nisInformative_(other.isInformative_)\r\n{\r\n    if (other.logicalPort_)\r\n    {\r\n        logicalPort_ = QSharedPointer<PortMap::LogicalPort>(new PortMap::LogicalPort());\r\n        logicalPort_->name_ = other.logicalPort_->name_;\r\n\r\n        if (other.logicalPort_->range_)\r\n        {\r\n            logicalPort_->range_ = QSharedPointer<Range>(new Range(other.logicalPort_->range_->getLeft(), \r\n                other.logicalPort_->range_->getRight()));\r\n        }\r\n    }\r\n\r\n    if (other.physicalPort_)\r\n    {\r\n        physicalPort_ = QSharedPointer<PortMap::PhysicalPort>(new PortMap::PhysicalPort());\r\n        physicalPort_->name_ = other.physicalPort_->name_;\r\n\r\n        if (other.physicalPort_->partSelect_)\r\n        {\r\n            physicalPort_->partSelect_ =\r\n                QSharedPointer<PartSelect>(new PartSelect(*other.physicalPort_->partSelect_));\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PortMap::operator=()\r\n//-----------------------------------------------------------------------------\r\nPortMap& PortMap::operator=(PortMap const& other)\r\n{\r\n    if (this != &other)\r\n    {\r\n        Extendable::operator=(other);\r\n\r\n        invert_ = other.invert_;\r\n        isPresent_ = other.isPresent_;\r\n\r\n        logicalPort_.clear();\r\n        logicalPort_ = QSharedPointer<PortMap::LogicalPort>(new PortMap::LogicalPort(*other.logicalPort_));\r\n        \r\n        physicalPort_.clear();\r\n        if (!other.getPhysicalPort().isNull())\r\n        {  \r\n            physicalPort_ = QSharedPointer<PortMap::PhysicalPort>(new PortMap::PhysicalPort(*other.physicalPort_));\r\n        }\r\n      \r\n        logicalTieOff_ = other.logicalTieOff_;\r\n\r\n        isInformative_ = other.isInformative_;\r\n    }\r\n\r\n\treturn *this;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PortMap::getInvert()\r\n//-----------------------------------------------------------------------------\r\nBooleanValue PortMap::getInvert() const\r\n{\r\n    return invert_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PortMap::setInvert()\r\n//-----------------------------------------------------------------------------\r\nvoid PortMap::setInvert(bool newInvert)\r\n{\r\n    invert_.setValue(newInvert);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PortMap::clearInvert()\r\n//-----------------------------------------------------------------------------\r\nvoid PortMap::clearInvert()\r\n{\r\n    invert_.setUnspecified();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PortMap::getIsPresent()\r\n//-----------------------------------------------------------------------------\r\nQString PortMap::getIsPresent() const\r\n{\r\n    return isPresent_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PortMap::setIsPresent()\r\n//-----------------------------------------------------------------------------\r\nvoid PortMap::setIsPresent(QString const& newIsPresent)\r\n{\r\n    isPresent_ = newIsPresent;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PortMap::getIsInformative()\r\n//-----------------------------------------------------------------------------\r\nBooleanValue PortMap::getIsInformative() const\r\n{\r\n    return isInformative_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PortMap::setIsInformative()\r\n//-----------------------------------------------------------------------------\r\nvoid PortMap::setIsInformative(bool newInformative)\r\n{\r\n    isInformative_.setValue(newInformative);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PortMap::clearIsInformative()\r\n//-----------------------------------------------------------------------------\r\nvoid PortMap::clearIsInformative()\r\n{\r\n    isInformative_.setUnspecified();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PortMap::getLogicalPort()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<PortMap::LogicalPort> PortMap::getLogicalPort() const\r\n{\r\n\treturn logicalPort_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PortMap::setLogicalPort()\r\n//-----------------------------------------------------------------------------\r\nvoid PortMap::setLogicalPort(QSharedPointer<LogicalPort> logicalPort)\r\n{\r\n    logicalPort_ = logicalPort;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PortMap::getPhysicalPort()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<PortMap::PhysicalPort> PortMap::getPhysicalPort() const\r\n{\r\n    return physicalPort_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PortMap::setPhysicalPort()\r\n//-----------------------------------------------------------------------------\r\nvoid PortMap::setPhysicalPort(QSharedPointer<PhysicalPort> physicalPort)\r\n{\r\n    physicalPort_ = physicalPort;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PortMap::getLogicalTiedOff()\r\n//-----------------------------------------------------------------------------\r\nQString PortMap::getLogicalTieOff() const\r\n{\r\n\treturn logicalTieOff_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PortMap::setLogicalTiedOff()\r\n//-----------------------------------------------------------------------------\r\nvoid PortMap::setLogicalTieOff(QString const& logicalTieOff)\r\n{\r\n\tlogicalTieOff_ = logicalTieOff;\r\n}\r\n"
  },
  {
    "path": "IPXACTmodels/Component/PortMap.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: PortMap.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Esko Pekkarinen\r\n// Date: 28.08.2014\r\n//\r\n// Description:\r\n// Implementation for ipxact:portMap.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef PORTMAP_H\r\n#define PORTMAP_H\r\n\r\n#include <IPXACTmodels/ipxactmodels_global.h>\r\n\r\n#include <IPXACTmodels/common/Range.h>\r\n#include <IPXACTmodels/common/PartSelect.h>\r\n\r\n#include <IPXACTmodels/common/BooleanValue.h>\r\n#include <IPXACTmodels/common/Extendable.h>\r\n\r\n#include <QSharedPointer>\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Implementation for ipxact:portMap.\r\n//-----------------------------------------------------------------------------\r\nclass IPXACTMODELS_EXPORT PortMap : public Extendable \r\n{\r\npublic:\r\n\r\n\t//! The logical port of the port map.\r\n\tstruct LogicalPort\r\n\t{\r\n\t\t//! The name of the logical port.\r\n\t\tQString name_;\r\n\r\n\t\t//! The range of the logical port.\r\n\t\tQSharedPointer<Range> range_;\r\n\r\n\t\t//! The constructor.\r\n\t\tLogicalPort(QString const& name = QString()): name_(name), range_(0) {}\r\n\t};\r\n\r\n\t//! The physical port of the port map.\r\n\tstruct PhysicalPort\r\n\t{\r\n\t\t//! The name of the physical port.\r\n\t\tQString name_;\r\n\r\n\t\t//! The selected physical port mapping.\r\n\t\tQSharedPointer<PartSelect> partSelect_;\r\n\r\n\t\t//! The constructor.\r\n\t\tPhysicalPort(QString const& name = QString()): name_(name), partSelect_(0) {}\r\n\t};\r\n\r\n    //! Default constructor\r\n\tPortMap();\r\n\r\n\t//! The copy constructor\r\n\tPortMap(PortMap const& other);\r\n\r\n    //! The destructor.\r\n    ~PortMap() = default;\r\n\r\n\t/*! The assignment operator\r\n\t *\r\n\t *    @param [in] other   The PortMap to assign.\r\n\t *\r\n\t *    @return Reference to this PortMap.\r\n\t*/\r\n\tPortMap& operator=(PortMap const& other);\r\n    \r\n    /*!\r\n     *  Get the invert value.\r\n     *\r\n     *    @return The invert value as either true, false or empty.\r\n     */\r\n    BooleanValue getInvert() const;\r\n\r\n    /*!\r\n     *  Set the invert value.\r\n     *\r\n     *    @param [in] newInvert   The new invert value.\r\n     */\r\n    void setInvert(bool newInvert);\r\n\r\n    /*!\r\n     *  Remove the invert value.\r\n     */\r\n    void clearInvert();\r\n\r\n    /*!\r\n     *  Get the presence.\r\n     *\r\n     *    @return The value defining the presence.\r\n     */\r\n    QString getIsPresent() const;\r\n\r\n    /*!\r\n     *  Set the presence value.\r\n     *\r\n     *    @param [in] newIsPresent    The new value for presence.\r\n     */\r\n    void setIsPresent(QString const& newIsPresent);\r\n\r\n    /*!\r\n     *  Get the is informative value.\r\n     *\r\n     *    @return The isInformative value.\r\n     */\r\n    BooleanValue getIsInformative() const;\r\n\r\n    /*!\r\n     *  Set the is informative value.\r\n     *\r\n     *    @param [in] newInformative  The new is informative value.\r\n     */\r\n    void setIsInformative(bool newInformative);\r\n\r\n    /*!\r\n     *  Remove the is informative value..\r\n     */\r\n    void clearIsInformative();\r\n\r\n    /*!\r\n     *  Gets the logical port in the port map.\r\n     *\r\n     *    @return The name of the logical port.\r\n     */\r\n    QSharedPointer<LogicalPort> getLogicalPort() const;\r\n\r\n    /*!\r\n     *  Sets the logical port in the port map.\r\n     *\r\n     *    @param [in] logicalPort   The logical port to set.\r\n     */\r\n    void setLogicalPort(QSharedPointer<LogicalPort> logicalPort);\r\n\r\n    /*!\r\n     *  Gets the physical port in the port map.\r\n     *\r\n     *    @return The name of the physical port.\r\n     */\r\n    QSharedPointer<PhysicalPort> getPhysicalPort() const;\r\n\r\n    /*!\r\n     *  Sets the physical port in the port map.\r\n     *\r\n     *    @param [in] physical   The physical port to set.\r\n     */\r\n    void setPhysicalPort(QSharedPointer<PhysicalPort> physicalPort);\r\n\t\r\n    /*!\r\n     *  Gets the logical tie off.\r\n     *\r\n     *    @return    The logical tie off value.\r\n     */\r\n\tQString getLogicalTieOff() const;\r\n\t\r\n    /*!\r\n     *  Sets the logical tie off.\r\n     *\r\n     *    @param [in] logicalTieOff   The new logical tie off.\r\n     */\r\n\tvoid setLogicalTieOff(QString const& logicalTieOff);\r\n\r\nprivate:\r\n\r\n    //! Specifies connections to the indicated physical port shall be logically inverted.\r\n    BooleanValue invert_;\r\n\r\n    //! The presence of this port map.\r\n    QString isPresent_;\r\n\r\n\t//! The logical port in the port map.\r\n\tQSharedPointer<LogicalPort> logicalPort_ = nullptr;\r\n\r\n    //! The physical port in the port map.\r\n    QSharedPointer<PhysicalPort> physicalPort_ = nullptr;\r\n         \r\n\t//! The logical tie off.\r\n\tQString logicalTieOff_;\r\n\r\n    //! When true, specifies the port map to be used only for informative purposes.\r\n    BooleanValue isInformative_;\r\n};\r\n\r\n#endif // PORTMAP_H"
  },
  {
    "path": "IPXACTmodels/Component/PortReader.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: PortReader.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 14.09.2015\r\n//\r\n// Description:\r\n// Reader class for IP-XACT port element.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"PortReader.h\"\r\n\r\n#include <IPXACTmodels/common/NameGroupReader.h>\r\n#include <IPXACTmodels/common/ProtocolReader.h>\r\n#include <IPXACTmodels/common/QualifierReader.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PortReader::createPortFrom()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<Port> PortReader::createPortFrom(QDomNode const& portNode, Document::Revision docRevision)\r\n{\r\n    QSharedPointer<Port> newPort (new Port());\r\n\r\n    NameGroupReader::parseNameGroup(portNode, newPort);\r\n\r\n    newPort->setIsPresent(portNode.firstChildElement(QStringLiteral(\"ipxact:isPresent\")).firstChild().nodeValue());\r\n\r\n    if (QDomElement wireElement = portNode.firstChildElement(QStringLiteral(\"ipxact:wire\")); \r\n        !wireElement.isNull())\r\n    {\r\n        newPort->setWire(Details::createWireFrom(wireElement, docRevision));\r\n    }\r\n    \r\n    if (QDomElement transactionalElement = portNode.firstChildElement(QStringLiteral(\"ipxact:transactional\")); \r\n        !transactionalElement.isNull())\r\n    {\r\n        Details::parseTransactional(transactionalElement, newPort);\r\n    }\r\n\r\n    if (docRevision == Document::Revision::Std22)\r\n    {\r\n        if (QDomElement structuredElement = portNode.firstChildElement(QStringLiteral(\"ipxact:structured\")); \r\n            !structuredElement.isNull())\r\n        {\r\n            newPort->setStructured(Details::createStructuredFrom(structuredElement));\r\n        }\r\n    }\r\n\r\n    newPort->getArrays()->append(Details::createArrays(portNode));\r\n\r\n    Details::parsePortExtensions(portNode, newPort);\r\n\r\n    return newPort;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PortReader::Details::parseWire()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<Wire> PortReader::Details::createWireFrom(QDomElement const& wireElement, \r\n    Document::Revision docRevision)\r\n{\r\n    QDomElement directionElement = wireElement.firstChildElement(QStringLiteral(\"ipxact:direction\"));\r\n    QString directionString = directionElement.firstChild().nodeValue();\r\n\r\n    QSharedPointer<Wire> newWire (new Wire());\r\n    newWire->setDirection(DirectionTypes::str2Direction(directionString, DirectionTypes::DIRECTION_INVALID));\r\n\r\n    if (docRevision == Document::Revision::Std22)\r\n    {\r\n        auto qualifierElement = wireElement.firstChildElement(QStringLiteral(\"ipxact:qualifier\"));\r\n        QualifierReader::parseQualifier(qualifierElement, newWire->getQualifier(), docRevision);\r\n    }\r\n\r\n    QString allLogicalDirectionsAllowed = wireElement.attribute(QStringLiteral(\"allLogicalDirectionsAllowed\"));\r\n    if (!allLogicalDirectionsAllowed.isEmpty())\r\n    {\r\n        newWire->setAllLogicalDirectionsAllowed(true);\r\n    }\r\n\r\n    parseWireVectors(wireElement, newWire, docRevision);\r\n\r\n    QDomElement wireTypeDefsElement = wireElement.firstChildElement(QStringLiteral(\"ipxact:wireTypeDefs\"));\r\n    if (!wireTypeDefsElement.isNull())\r\n    {\r\n        newWire->setWireTypeDefs(parseWireTypeDefinitions(wireTypeDefsElement, QStringLiteral(\"ipxact:wireTypeDef\"),\r\n            QStringLiteral(\"constrained\")));\r\n    }\r\n\r\n    parseWireDefaultValue(wireElement, newWire);\r\n\r\n    return newWire;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PortReader::Details::parseWireVectors()\r\n//-----------------------------------------------------------------------------\r\nvoid PortReader::Details::parseWireVectors(QDomElement const& wireElement, QSharedPointer<Wire> newWire,\r\n    Document::Revision docRevision)\r\n{\r\n    newWire->getVectors()->append(parseVectors(wireElement, docRevision));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PortReader::Details::parseVectors()\r\n//-----------------------------------------------------------------------------\r\nQList<Vector> PortReader::Details::parseVectors(QDomElement const& parentElement, Document::Revision docRevision)\r\n{\r\n    auto const vectorsElement = parentElement.firstChildElement(QStringLiteral(\"ipxact:vectors\"));\r\n\r\n    auto const vectorNodeList = vectorsElement.elementsByTagName(QStringLiteral(\"ipxact:vector\"));\r\n\r\n    QList<Vector> vectors;\r\n    const auto VECTOR_COUNT = vectorNodeList.size();\r\n    for (int i = 0; i < VECTOR_COUNT; ++i)\r\n    {\r\n        vectors.append(parseVector(vectorNodeList.at(i), docRevision));\r\n    }\r\n\r\n    return vectors;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PortReader::Details::parseVector()\r\n//-----------------------------------------------------------------------------\r\nVector PortReader::Details::parseVector(QDomNode const& vectorNode, Document::Revision docRevision)\r\n{\r\n    auto readVector = Vector();\r\n\r\n    readVector.setLeft(vectorNode.firstChildElement(QStringLiteral(\"ipxact:left\")).firstChild().nodeValue());\r\n    readVector.setRight(vectorNode.firstChildElement(QStringLiteral(\"ipxact:right\")).firstChild().nodeValue());\r\n\r\n    if (docRevision == Document::Revision::Std22)\r\n    {\r\n        readVector.setId(vectorNode.toElement().attribute(QStringLiteral(\"vectorId\")));\r\n    }\r\n\r\n    return readVector;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PortReader::Details::parseWireTypeDefinitions()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<QList<QSharedPointer<WireTypeDef> > > PortReader::Details::parseWireTypeDefinitions(\r\n    QDomElement const& typeDefinitionsElement, QString const& elementName, QString const& attributeName)\r\n{\r\n    QSharedPointer<QList<QSharedPointer<WireTypeDef> > > typeDefinitions (new QList<QSharedPointer<WireTypeDef> >);\r\n\r\n    QDomNodeList wireYypeDefinitionNodeList = typeDefinitionsElement.elementsByTagName(elementName);\r\n    for (int wireTypeIndex = 0; wireTypeIndex < wireYypeDefinitionNodeList.count(); ++wireTypeIndex)\r\n    {\r\n        QDomElement wireTypeDefinitionElement = wireYypeDefinitionNodeList.at(wireTypeIndex).toElement();\r\n\r\n        QDomElement nameElement = wireTypeDefinitionElement.firstChildElement(QStringLiteral(\"ipxact:typeName\"));\r\n        QString typeName = nameElement.firstChild().nodeValue();\r\n        QSharedPointer<WireTypeDef> newWireTypeDefinition (new WireTypeDef(typeName));\r\n        if (!nameElement.attribute(attributeName).isEmpty())\r\n        {\r\n            newWireTypeDefinition->setConstrained(true);\r\n        }\r\n\r\n        parseTypeDefinitions(wireTypeDefinitionElement, newWireTypeDefinition);\r\n\r\n        parseViewReferences(wireTypeDefinitionElement, newWireTypeDefinition);\r\n\r\n        typeDefinitions->append(newWireTypeDefinition);\r\n    }\r\n\r\n    return typeDefinitions;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PortReader::Details::parseTypeDefinitions()\r\n//-----------------------------------------------------------------------------\r\nvoid PortReader::Details::parseTypeDefinitions(QDomElement const& wireTypeDefinitionElement,\r\n    QSharedPointer<WireTypeDef> newWireTypeDefinition)\r\n{\r\n    QDomNodeList typeDefinitionList = wireTypeDefinitionElement.elementsByTagName(QStringLiteral(\"ipxact:typeDefinition\"));\r\n    QSharedPointer<QStringList> definitionList(new QStringList());\r\n    for (int typeDefinitionIndex = 0; typeDefinitionIndex < typeDefinitionList.count(); ++typeDefinitionIndex)\r\n    {\r\n        QString definition = typeDefinitionList.at(typeDefinitionIndex).firstChild().nodeValue();\r\n        definitionList->append(definition);\r\n    }\r\n    if (!definitionList->isEmpty())\r\n    {\r\n        newWireTypeDefinition->setTypeDefinitions(definitionList);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PortReader::Details::parseViewReferences()\r\n//-----------------------------------------------------------------------------\r\nvoid PortReader::Details::parseViewReferences(QDomElement const& wireTypeDefinitionElement,\r\n    QSharedPointer<WireTypeDef> newWireTypeDefinition)\r\n{\r\n    QDomNodeList viewRefNodeList = wireTypeDefinitionElement.elementsByTagName(QStringLiteral(\"ipxact:viewRef\"));\r\n    QSharedPointer<QStringList> viewRefs(new QStringList());\r\n\r\n    for (int viewIndex = 0; viewIndex < viewRefNodeList.count(); ++viewIndex)\r\n    {\r\n        QString viewName = viewRefNodeList.at(viewIndex).firstChild().nodeValue();\r\n        viewRefs->append(viewName);\r\n    }\r\n\r\n    if (!viewRefs->isEmpty())\r\n    {\r\n        newWireTypeDefinition->setViewRefs(viewRefs);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PortReader::Details::parseWireDefaultValue()\r\n//-----------------------------------------------------------------------------\r\nvoid PortReader::Details::parseWireDefaultValue(QDomElement const& wireElement, QSharedPointer<Wire> newWire)\r\n{\r\n    QDomElement driversElement = wireElement.firstChildElement(QStringLiteral(\"ipxact:drivers\"));\r\n\r\n    if (!driversElement.isNull())\r\n    {\r\n        QDomNodeList driverNodeList = driversElement.elementsByTagName(QStringLiteral(\"ipxact:driver\"));\r\n        for (int driverIndex = 0; driverIndex < driverNodeList.count(); ++driverIndex)\r\n        {\r\n            auto driver = QSharedPointer<Driver>(new Driver());\r\n            if (QDomElement rangeElement = driverNodeList.at(driverIndex).firstChildElement(QStringLiteral(\"ipxact:range\"));\r\n                !rangeElement.isNull())\r\n            {\r\n                driver->setRange(CommonItemsReader::parseRange(rangeElement));\r\n            }\r\n\r\n            QDomNode driverDefaultNode = driverNodeList.at(driverIndex).firstChildElement(QStringLiteral(\"ipxact:defaultValue\"));\r\n            QString defaultValue = driverDefaultNode.firstChild().nodeValue();\r\n            driver->setDefaultValue(defaultValue);\r\n\r\n            newWire->setDriver(driver);\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PortReader::Details::parseTransactional()\r\n//-----------------------------------------------------------------------------\r\nvoid PortReader::Details::parseTransactional(QDomElement const& transactionalElement, QSharedPointer<Port> newPort)\r\n{\r\n    QSharedPointer<Transactional> newTransactional(new Transactional());\r\n\r\n    QString allLogicalInitiativesAllowed = transactionalElement.attribute(\r\n        QStringLiteral(\"allLogicalInitiativesAllowed\"));\r\n    if (!allLogicalInitiativesAllowed.isEmpty())\r\n    {\r\n        newTransactional->setAllLogicalInitiativesAllowed(true);\r\n    }\r\n\r\n    QDomElement initiativeElement = transactionalElement.firstChildElement(QStringLiteral(\"ipxact:initiative\"));\r\n    QString initiative = initiativeElement.firstChild().nodeValue();\r\n    newTransactional->setInitiative(initiative);\r\n\r\n    parseTransactionalKind(transactionalElement.firstChildElement(QStringLiteral(\"ipxact:kind\")), newTransactional);\r\n\r\n    QDomElement busWidthElement = transactionalElement.firstChildElement(QStringLiteral(\"ipxact:busWidth\"));\r\n    if (!busWidthElement.isNull())\r\n    {\r\n        QString busWidth = busWidthElement.firstChild().nodeValue();\r\n        newTransactional->setBusWidth(busWidth);\r\n    }\r\n\r\n    parseTransactionalProtocol(transactionalElement, newTransactional);\r\n\r\n    QDomElement typeDefinitions = transactionalElement.firstChildElement(QStringLiteral(\"ipxact:transTypeDefs\"));\r\n    if (!typeDefinitions.isNull())\r\n    {\r\n        newTransactional->setTransTypeDefs(parseWireTypeDefinitions(typeDefinitions, \r\n            QStringLiteral(\"ipxact:transTypeDef\"), QStringLiteral(\"exact\")));\r\n    }\r\n\r\n    parseTransactionalConnectionsMinMax(transactionalElement, newTransactional);\r\n\r\n    newPort->setTransactional(newTransactional);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PortReader::Details::parseTransactionalKind()\r\n//-----------------------------------------------------------------------------\r\nvoid PortReader::Details::parseTransactionalKind(QDomElement const& kindElement,\r\n    QSharedPointer<Transactional> transactional)\r\n{\r\n    if (!kindElement.isNull())\r\n    {\r\n        QString transactionalKind = kindElement.firstChild().nodeValue();\r\n        if (transactionalKind == QLatin1String(\"custom\") && kindElement.hasAttribute(QStringLiteral(\"custom\")))\r\n        {\r\n            transactionalKind = kindElement.attribute(QStringLiteral(\"custom\"));\r\n        }\r\n        transactional->setKind(transactionalKind);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PortReader::Details::parseTransactionalProtocol()\r\n//-----------------------------------------------------------------------------\r\nvoid PortReader::Details::parseTransactionalProtocol(QDomNode const& transactionalNode,\r\n    QSharedPointer<Transactional> transactional)\r\n{\r\n    QDomNode protocolNode = transactionalNode.firstChildElement(QStringLiteral(\"ipxact:protocol\"));\r\n    if (!protocolNode.isNull())\r\n    {\r\n        ProtocolReader protocolReader;\r\n        QSharedPointer<Protocol> transactionalProtocol = protocolReader.createProtocolFrom(protocolNode);\r\n        transactional->setProtocol(transactionalProtocol);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PortReader::Details::parseTransactionalConnectionsMinMax()\r\n//-----------------------------------------------------------------------------\r\nvoid PortReader::Details::parseTransactionalConnectionsMinMax(QDomElement const& transactionalElement,\r\n    QSharedPointer<Transactional> transactional)\r\n{\r\n    auto const connectionsElement = transactionalElement.firstChildElement(QStringLiteral(\"ipxact:connection\"));\r\n    if (!connectionsElement.isNull())\r\n    {\r\n        auto const maxElement = connectionsElement.firstChildElement(QStringLiteral(\"ipxact:maxConnections\"));\r\n        transactional->setMaxConnections(maxElement.firstChild().nodeValue());\r\n\r\n        auto const minElement = connectionsElement.firstChildElement(QStringLiteral(\"ipxact:minConnections\"));\r\n        transactional->setMinConnections(minElement.firstChild().nodeValue());\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PortReader::Details::parseStructured()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<Structured> PortReader::Details::createStructuredFrom(QDomElement const& structuredElement)\r\n{\r\n    QSharedPointer<Structured> newStructured(new Structured());\r\n\r\n    newStructured->setPacked(structuredElement.attribute(QStringLiteral(\"packed\")) == QStringLiteral(\"true\"));\r\n\r\n    parseStructuredType(structuredElement, newStructured);\r\n\r\n    parseStructuredVectors(structuredElement, newStructured);\r\n\r\n    parseSubPorts(structuredElement, newStructured);\r\n\r\n    return newStructured;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PortReader::Details::parseStructuralType()\r\n//-----------------------------------------------------------------------------\r\nvoid PortReader::Details::parseStructuredType(QDomElement const& structuredElement,\r\n    QSharedPointer<Structured> newStructured)\r\n{\r\n    using namespace DirectionTypes;\r\n    if (auto const structElement = structuredElement.firstChildElement(QStringLiteral(\"ipxact:struct\"));\r\n        structElement.isNull() == false)\r\n    {\r\n        newStructured->setType(Structured::Type::Struct);\r\n        newStructured->setDirection(str2Direction(structElement.attribute(QStringLiteral(\"direction\"))));\r\n    }\r\n    else if (auto const unionElement = structuredElement.firstChildElement(QStringLiteral(\"ipxact:union\"));\r\n        unionElement.isNull() == false)\r\n    {\r\n        newStructured->setType(Structured::Type::Union);\r\n        newStructured->setDirection(str2Direction(unionElement.attribute(QStringLiteral(\"direction\"))));\r\n    }\r\n    else if (auto const interfaceElement = structuredElement.firstChildElement(QStringLiteral(\"ipxact:interface\"));\r\n        interfaceElement.isNull() == false)\r\n    {\r\n        newStructured->setType(Structured::Type::Interface);\r\n        if (interfaceElement.attribute(QStringLiteral(\"phantom\")) == QStringLiteral(\"true\"))\r\n        {\r\n            newStructured->setDirection(DIRECTION_PHANTOM);\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PortReader::Details::parseStructuralVectors()\r\n//-----------------------------------------------------------------------------\r\nvoid PortReader::Details::parseStructuredVectors(QDomElement const& structuredElement,\r\n    QSharedPointer<Structured> newStructured)\r\n{\r\n    newStructured->getVectors()->append(parseVectors(structuredElement, Document::Revision::Std22));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PortReader::Details::parseSubPorts()\r\n//-----------------------------------------------------------------------------\r\nvoid PortReader::Details::parseSubPorts(QDomElement const& structuredElement, QSharedPointer<Structured> newStructured)\r\n{\r\n    const auto subPortsElement = structuredElement.firstChildElement(QStringLiteral(\"ipxact:subPorts\"));\r\n    const auto subPortList = subPortsElement.childNodes();\r\n\r\n    const auto SUBPORT_COUNT = subPortList.count();\r\n    for (int i = 0; i < SUBPORT_COUNT; ++i)\r\n    {\r\n        const auto subPortElement = subPortList.at(i).toElement();\r\n\r\n        QSharedPointer<SubPort> parsedSubPort(new SubPort());\r\n        parsedSubPort->setIsIO(subPortElement.attribute(QStringLiteral(\"isIO\")) == QStringLiteral(\"true\"));\r\n        NameGroupReader::parseNameGroup(subPortElement, parsedSubPort);\r\n\r\n        if (QDomElement wireElement = subPortElement.firstChildElement(QStringLiteral(\"ipxact:wire\"));\r\n            !wireElement.isNull())\r\n        {\r\n            parsedSubPort->setWire(Details::createWireFrom(wireElement, Document::Revision::Std22));\r\n        }\r\n        else if (QDomElement nestedStructured = subPortElement.firstChildElement(QStringLiteral(\"ipxact:structured\"));\r\n            !nestedStructured.isNull())\r\n        {\r\n            parsedSubPort->setStructured(Details::createStructuredFrom(nestedStructured));\r\n        }\r\n\r\n        parsedSubPort->getArrays()->append(createArrays(subPortElement));\r\n\r\n        newStructured->getSubPorts()->append(parsedSubPort);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PortReader::Details::createArrays()\r\n//-----------------------------------------------------------------------------\r\nQList<Array> PortReader::Details::createArrays(QDomNode const& parentNode)\r\n{\r\n    const auto arraysElement = parentNode.firstChildElement(QStringLiteral(\"ipxact:arrays\"));\r\n\r\n    const auto arrayNodeList = arraysElement.elementsByTagName(QStringLiteral(\"ipxact:array\"));\r\n\r\n    QList<Array> parsedArrays;\r\n    for (int arrayIndex = 0; arrayIndex < arrayNodeList.count(); ++arrayIndex)\r\n    {\r\n        auto const& arrayNode = arrayNodeList.at(arrayIndex);\r\n\r\n        auto arrayLeft = arrayNode.firstChildElement(QStringLiteral(\"ipxact:left\")).firstChild().nodeValue();\r\n        auto arrayRight = arrayNode.firstChildElement(QStringLiteral(\"ipxact:right\")).firstChild().nodeValue();\r\n\r\n        parsedArrays.append(Array(arrayLeft, arrayRight));\r\n    }\r\n\r\n    return parsedArrays;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PortReader::Details::parsePortExtensions()\r\n//-----------------------------------------------------------------------------\r\nvoid PortReader::Details::parsePortExtensions(QDomNode const& portNode, QSharedPointer<Port> newPort)\r\n{\r\n    QDomElement extensionsNode = portNode.firstChildElement(QStringLiteral(\"ipxact:vendorExtensions\"));\r\n\r\n    if (QDomElement adHocElement = extensionsNode.firstChildElement(QStringLiteral(\"kactus2:adHocVisible\")); \r\n        !adHocElement.isNull())\r\n    {\r\n        newPort->setAdHocVisible(true);\r\n    }\r\n\r\n    if (QDomElement positionElement = extensionsNode.firstChildElement(QStringLiteral(\"kactus2:position\")); \r\n        !positionElement.isNull())\r\n    {\r\n        parsePosition(positionElement, newPort);\r\n    }\r\n\r\n    if (QDomElement tagsElement = extensionsNode.firstChildElement(QStringLiteral(\"kactus2:portTags\")); \r\n        !tagsElement.isNull())\r\n    {\r\n        newPort->setPortTags(tagsElement.firstChild().nodeValue());\r\n    }\r\n\r\n    CommonItemsReader::parseVendorExtensions(portNode, newPort);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PortReader::Details::parsePosition()\r\n//-----------------------------------------------------------------------------\r\nvoid PortReader::Details::parsePosition(QDomElement const& positionElement, QSharedPointer<Port> newPort)\r\n{\r\n    int positionX = positionElement.attribute(QStringLiteral(\"x\")).toInt();\r\n    int positionY = positionElement.attribute(QStringLiteral(\"y\")).toInt();\r\n    newPort->setDefaultPos(QPointF(positionX, positionY));\r\n}"
  },
  {
    "path": "IPXACTmodels/Component/PortReader.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: PortReader.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 14.09.2015\r\n//\r\n// Description:\r\n// Reader class for IP-XACT port element.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef PORTREADER_H\r\n#define PORTREADER_H\r\n\r\n#include \"Port.h\"\r\n\r\n#include <IPXACTmodels/common/CommonItemsReader.h>\r\n#include <IPXACTmodels/common/Document.h>\r\n\r\n#include <QSharedPointer>\r\n#include <QDomNode>\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Reader class for IP-XACT port element.\r\n//-----------------------------------------------------------------------------\r\nnamespace  PortReader \r\n{\r\n\r\n\r\n    /*!\r\n     *  Creates a new port from XML description.\r\n     *\r\n     *    @param [in] portNode    XML description of the port.\r\n     *\r\n     *    @return A new port created from the XML description.\r\n     */\r\n    IPXACTMODELS_EXPORT QSharedPointer<Port> createPortFrom(QDomNode const& portNode,\r\n        Document::Revision docRevision);\r\n\r\n    namespace Details\r\n    {\r\n\r\n        /*!\r\n         *  Parses a wire port.\r\n         *\r\n         *    @param [in] wireElement     XML description of the wire.\r\n         *    @param [in] docRevision     The applied IP-XACT revision.\r\n         */\r\n        QSharedPointer<Wire> createWireFrom(QDomElement const& wireElement, \r\n            Document::Revision docRevision);\r\n\r\n        /*!\r\n         *  Parse vectors.\r\n         *\r\n         *    @param [in] wireElement     XML description of the wire.\r\n         *    @param [in] newWire         The containing wire item.\r\n         */\r\n        void parseWireVectors(QDomElement const& wireElement, QSharedPointer<Wire> newWire,\r\n            Document::Revision docRevision);\r\n\r\n        /*!\r\n         *  Parse the vectors in the given element.\r\n         *\r\n         *    @param [in] parentElement   The element containing vectors.\r\n         *    @param [in] docRevision     The applied IP-XACT revision.\r\n         *\r\n         *    @return The parsed vectors.\r\n         */\r\n        QList<Vector> parseVectors(QDomElement const& parentElement, Document::Revision docRevision);\r\n\r\n        /*!\r\n         *  Parse a single vector.\r\n         *\r\n         *    @param [in] vectorNode  The xml presentation of the vector.\r\n         *    @param [in] docRevision The applied IP-XACT revision.\r\n         *\r\n         *    @return The parsed vector.\r\n         */\r\n        Vector parseVector(QDomNode const& vectorNode, Document::Revision docRevision);\r\n\r\n        /*!\r\n         *  Parse the wire type definitions.\r\n         *\r\n         *    @param [in] typeDefinitionsElement  XML description of the type definitions.\r\n         *    @param [in] elementName             Name of the type definition element.\r\n         *    @param [in] attributeName           Name of the attribute containing the constraint.\r\n         *\r\n         *    @return Pointer to a list containing the created type definitions.\r\n         */\r\n        QSharedPointer<QList<QSharedPointer<WireTypeDef> > >parseWireTypeDefinitions(\r\n            QDomElement const& typeDefinitionsElement, QString const& elementName, QString const& attributeName);\r\n\r\n        /*!\r\n         *  Parse the type definitions.\r\n         *\r\n         *    @param [in] wireTypeDefinitionElement   XML description of the wire type definition.\r\n         *    @param [in] newWireTypeDefinition       The containing wire type definition.\r\n         */\r\n        void parseTypeDefinitions(QDomElement const& wireTypeDefinitionElement,\r\n            QSharedPointer<WireTypeDef> newWireTypeDefinition);\r\n\r\n        /*!\r\n         *  Parse the view references.\r\n         *\r\n         *    @param [in] wireTypeDefinitionElement   XML description of the wire type definition.\r\n         *    @param [in] newWireTypeDefinition       The containing wire type definition.\r\n         */\r\n        void parseViewReferences(QDomElement const& wireTypeDefinitionElement,\r\n            QSharedPointer<WireTypeDef> newWireTypeDefinition);\r\n\r\n        /*!\r\n         *  Parse the wire driver default value.\r\n         *\r\n         *    @param [in] wireElement     XML description of the wire.\r\n         *    @param [in] newWire         The containing wire item.\r\n         */\r\n        void parseWireDefaultValue(QDomElement const& wireElement, QSharedPointer<Wire> newWire);\r\n\r\n        /*!\r\n         *  Parse a transactional port.\r\n         *\r\n         *    @param [in] transactionalElement    XML description of the transactional.\r\n         *    @param [in] newPort                 The containing port.\r\n         */\r\n        void parseTransactional(QDomElement const& transactionalElement, QSharedPointer<Port> newPort);\r\n\r\n        /*!\r\n         *  Parse the kind of the transactional port.\r\n         *\r\n         *    @param [in] kindElement     XML description of the kind.\r\n         *    @param [in] transactional   The containing transactional port.\r\n         */\r\n        void parseTransactionalKind(QDomElement const& kindElement, QSharedPointer<Transactional> transactional);\r\n\r\n        /*!\r\n         *  Parse the transactional protocol.\r\n         *\r\n         *    @param [in] transactionalNode   XML description of the transactional.\r\n         *    @param [in] transactional       The containing transactional port.\r\n         */\r\n        void parseTransactionalProtocol(QDomNode const& transactionalNode, \r\n            QSharedPointer<Transactional> transactional);\r\n\r\n        /*!\r\n         *  Parse the maximum and minimum connections allowed to a transactional port.\r\n         *\r\n         *    @param [in] transactionalElement    XML description of the transactional.\r\n         *    @param [in] transactional           The containing transactional port.\r\n         */\r\n        void parseTransactionalConnectionsMinMax(QDomElement const& transactionalElement,\r\n            QSharedPointer<Transactional> transactional);\r\n\r\n        /*!\r\n         *  Parse a structured port.\r\n         *\r\n         *    @param [in] structuredElement   The XML description of the structured port.\r\n         *    @param [in] newPort             The containing port item.\r\n         *\r\n         *    @return \r\n         */\r\n        QSharedPointer<Structured> createStructuredFrom(QDomElement const& structuredElement);\r\n\r\n        /*!\r\n         *  Parse the structured port type.\r\n         *\r\n         *    @param [in] structuredElementt   The XML description of the structured port.\r\n         *    @param [in] newStructured        The containing structured port.\r\n         */\r\n        void parseStructuredType(QDomElement const& structuredElement, QSharedPointer<Structured> newStructured);\r\n\r\n        /*!\r\n         *  Parse the vectors in the structured port.\r\n         *\r\n         *    @param [in] structuredElementt   The XML description of the structured port.\r\n         *    @param [in] newStructured        The containing structured port.\r\n         */\r\n        void parseStructuredVectors(QDomElement const& structuredElement, QSharedPointer<Structured> newStructured);\r\n\r\n        /*!\r\n         *  Parse the sub-ports in the structured port.\r\n         *\r\n         *    @param [in] structuredElementt   The XML description of the structured port.\r\n         *    @param [in] newStructured        The containing structured port.\r\n         */\r\n        void parseSubPorts(QDomElement const& structuredElement, QSharedPointer<Structured> newStructured);\r\n\r\n        /*!\r\n         *  Parse the port arrays.\r\n         *\r\n         *    @param [in] parentNode  XML node .\r\n         *    @param [in] newPort     The containing port item.\r\n         */\r\n        QList<Array> createArrays(QDomNode const& parentNode);\r\n\r\n        /*!\r\n         *  Parse the port vendor extensions.\r\n         *\r\n         *    @param [in] portNode    XML description of the port.\r\n         *    @param [in] newPort     The containing port item.\r\n         */\r\n        void parsePortExtensions(QDomNode const& portNode, QSharedPointer<Port> newPort);\r\n\r\n        /*!\r\n         *  Parse the port position.\r\n         *\r\n         *    @param [in] positionElement     XML description of the port position.\r\n         *    @param [in] newPort             The contianing port item.\r\n         */\r\n        void parsePosition(QDomElement const& positionElement, QSharedPointer<Port> newPort) ;\r\n    }\r\n};\r\n\r\n#endif // PORTREADER_H\r\n"
  },
  {
    "path": "IPXACTmodels/Component/PortSlice.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: PortSlice.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Esko Pekkarinen\n// Date: 09.08.2023\n//\n// Description:\n// Describes the ipxact:portSlice element.\n//-----------------------------------------------------------------------------\n\n#include \"PortSlice.h\"\n\n//-----------------------------------------------------------------------------\n// Function: PortSlice::PortSlice()\n//-----------------------------------------------------------------------------\nPortSlice::PortSlice(QString const& name) :\nNameGroup(name)\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortSlice::PortSlice()\n//-----------------------------------------------------------------------------\nPortSlice::PortSlice(const PortSlice &other) :\n    NameGroup(other),\n    portRef_(other.portRef_)\n{\n    if (other.partSelect_ != nullptr)\n    {\n        partSelect_ = QSharedPointer<PartSelect>(new PartSelect(*other.partSelect_));\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortSlice::operator=()\n//-----------------------------------------------------------------------------\nPortSlice& PortSlice::operator=(const PortSlice& other)\n{\n    if (this != &other)\n    {\n        NameGroup::operator=(other);\n        portRef_ = other.portRef_;\n        \n        if (other.partSelect_ != nullptr)\n        {\n            partSelect_ = QSharedPointer<PartSelect>(new PartSelect(*other.partSelect_));\n        }\n    }\n\n    return *this;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortSlice::~PortSlice()\n//-----------------------------------------------------------------------------\nPortSlice::~PortSlice()\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortSlice::getPortRef()\n//-----------------------------------------------------------------------------\nQString PortSlice::getPortRef() const\n{\n    return portRef_;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortSlice::setPortNameRef()\n//-----------------------------------------------------------------------------\nvoid PortSlice::setPortRef(QString const& newPortRef)\n{\n    portRef_ = newPortRef;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortSlice::getPartSelect()\n//-----------------------------------------------------------------------------\nQSharedPointer<PartSelect> PortSlice::getPartSelect() const\n{\n    return partSelect_;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortSlice::setPartSelect()\n//-----------------------------------------------------------------------------\nvoid PortSlice::setPartSelect(QSharedPointer<PartSelect> partSelect)\n{\n    partSelect_ = partSelect;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortSlice::getLeftRange()\n//-----------------------------------------------------------------------------\nQString PortSlice::getLeftRange() const\n{\n    if (partSelect_)\n    {\n        return partSelect_->getLeftRange();\n    }\n\n    return QString();\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortSlice::getRightRange()\n//-----------------------------------------------------------------------------\nQString PortSlice::getRightRange() const\n{\n    if (partSelect_)\n    {\n        return partSelect_->getRightRange();\n    }\n\n    return QString();\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortSlice::setLeftRange()\n//-----------------------------------------------------------------------------\nvoid PortSlice::setLeftRange(QString const& newLeftRange)\n{\n    if (partSelect_.isNull())\n    {\n        partSelect_ = QSharedPointer<PartSelect>(new PartSelect());\n    }\n\n    return partSelect_->setLeftRange(newLeftRange);\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortSlice::setRightRange()\n//-----------------------------------------------------------------------------\nvoid PortSlice::setRightRange(QString const& newRightRange)\n{\n    if (partSelect_.isNull())\n    {\n        partSelect_ = QSharedPointer<PartSelect>(new PartSelect());\n    }\n\n    return partSelect_->setRightRange(newRightRange);\n}\n"
  },
  {
    "path": "IPXACTmodels/Component/PortSlice.h",
    "content": "//-----------------------------------------------------------------------------\n// File: PortSlice.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Esko Pekkarinen\n// Date: 09.08.2023\n//\n// Description:\n// Describes the ipxact:portSlice element.\n//-----------------------------------------------------------------------------\n\n#ifndef PORTSLICE_H\n#define PORTSLICE_H\n\n#include <IPXACTmodels/ipxactmodels_global.h>\n\n#include <IPXACTmodels/common/NameGroup.h>\n#include <IPXACTmodels/common/PartSelect.h>\n\n#include <QString>\n#include <QList>\n\n//-----------------------------------------------------------------------------\n//! Describes the ipxact:PortSlice element.\n//-----------------------------------------------------------------------------\nclass IPXACTMODELS_EXPORT PortSlice : public NameGroup\n{\n\npublic:\n\n    using List = QSharedPointer<QList<QSharedPointer<PortSlice> > >;\n\n    /*!\n     *  The default constructor.\n     */\n    PortSlice(QString const& name = QString());\n\n\t//! Copy constructor.\n\tPortSlice(const PortSlice &other);\n\n    //! Assignment operator.\n\tPortSlice &operator=(const PortSlice &other);\n\n\t/*! \n     *  The destructor\n\t */\n\t~PortSlice();\n\n\t/*!\n     *  Get the value of the port reference.\n\t *\n\t *    @return The port reference.\n\t */\n\tQString getPortRef() const;\n\n\t/*!\n     *  Set the portNameRef for this PortSlice.\n\t *\n\t *    @param [in] newPortNameRef  The new port reference.\n\t */\n\tvoid setPortRef(QString const& newPortNameRef);\n    \n\n\tQSharedPointer<PartSelect> getPartSelect() const;\n\n\tvoid setPartSelect(QSharedPointer<PartSelect> partSelect);\n\n    /*!\n     *  Get the left value of the range.\n     *\n     *    @return The left value of the range.\n     */\n    QString getLeftRange() const;\n\n    /*!\n     *  Get the right value of the range.\n     *\n     *    @return The right value of the range.\n     */\n    QString getRightRange() const;\n\n    /*!\n     *  Set the left value for the range.\n     *\n     *    @param [in] newLeftRange    The new value for the left value of the range.\n     */\n    void setLeftRange(QString const& newLeftRange);\n\n    /*!\n     *  Set the right value for the range.\n     *\n     *    @param [in] newRightRange   The new value for the right value of the range.\n     */\n    void setRightRange(QString const& newRightRange);\n\nprivate:\n\n    //! Name of the referenced port.\n\tQString portRef_;\n\n\t//! The part select for the port.\n\tQSharedPointer<PartSelect> partSelect_ = nullptr;\n};\n\n#endif // PORTSLICE_H\n"
  },
  {
    "path": "IPXACTmodels/Component/PortWriter.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: PortWriter.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 11.09.2015\r\n//\r\n// Description:\r\n// Writer class for IP-XACT port element.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"PortWriter.h\"\r\n\r\n#include <IPXACTmodels/common/ProtocolWriter.h>\r\n#include <IPXACTmodels/common/Vector.h>\r\n#include <IPXACTmodels/common/NameGroupWriter.h>\r\n#include <IPXACTmodels/common/TransactionalTypes.h>\r\n#include <IPXACTmodels/common/QualifierWriter.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PortWriter::writePort()\r\n//-----------------------------------------------------------------------------\r\nvoid PortWriter::writePort(QXmlStreamWriter& writer, QSharedPointer<Port> port, Document::Revision docRevision) const\r\n{\r\n    writer.writeStartElement(QStringLiteral(\"ipxact:port\"));\r\n\r\n    NameGroupWriter::writeNameGroup(writer, port, docRevision);\r\n\r\n    if (docRevision == Document::Revision::Std14)\r\n    {\r\n        CommonItemsWriter::writeIsPresent(writer, port->getIsPresent());\r\n    }\r\n\r\n    if (port->getWire())\r\n    {\r\n        writeWire(writer, port->getWire(), docRevision);\r\n    }\r\n    else if (port->getTransactional())\r\n    {\r\n        writeTransactional(writer, port->getTransactional(), docRevision);\r\n    }\r\n    else if (port->getStructured() && docRevision == Document::Revision::Std22)\r\n    {\r\n        writeStructured(writer, port->getStructured());\r\n    }\r\n\r\n    writeArrays(writer, port->getArrays());\r\n\r\n    CommonItemsWriter::writeVendorExtensions(writer, port);\r\n\r\n    writer.writeEndElement(); // ipxact:port\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PortWriter::writeWire()\r\n//-----------------------------------------------------------------------------\r\nvoid PortWriter::writeWire(QXmlStreamWriter& writer, QSharedPointer<Wire> wire, Document::Revision docRevision) const\r\n{\r\n    writer.writeStartElement(QStringLiteral(\"ipxact:wire\"));\r\n\r\n    if (wire->getAllLogicalDirectionsAllowed())\r\n    {\r\n        writer.writeAttribute(QStringLiteral(\"allLogicalDirectionsAllowed\"), QStringLiteral(\"true\"));\r\n    }\r\n\r\n    writer.writeTextElement(QStringLiteral(\"ipxact:direction\"), DirectionTypes::direction2Str(wire->getDirection()));\r\n\r\n    if (docRevision == Document::Revision::Std22)\r\n    {\r\n        QualifierWriter::writeQualifier(writer, wire->getQualifier());\r\n    }\r\n\r\n    writeVectors(writer, wire->getVectors(), docRevision);\r\n    \r\n    writeWireTypeDefinitions(writer, wire->getWireTypeDefs());\r\n\r\n    writeWireDriver(writer, wire->getDriver());\r\n\r\n    writer.writeEndElement(); // ipxact:wire\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PortWriter::writeVector()\r\n//-----------------------------------------------------------------------------\r\nvoid PortWriter::writeVectors(QXmlStreamWriter& writer, QSharedPointer<QList<Vector> > vectors,\r\n    Document::Revision docRevision) const\r\n{\r\n    if (vectors->isEmpty())\r\n    {\r\n        return;\r\n    }\r\n\r\n    writer.writeStartElement(QStringLiteral(\"ipxact:vectors\"));\r\n\r\n    for (auto const& vector : *vectors)\r\n    {\r\n        writer.writeStartElement(QStringLiteral(\"ipxact:vector\"));\r\n\r\n        if (docRevision == Document::Revision::Std22 && vector.getId().isEmpty() == false)\r\n        {\r\n            writer.writeAttribute(QStringLiteral(\"vectorId\"), vector.getId());\r\n        }\r\n\r\n        writer.writeTextElement(QStringLiteral(\"ipxact:left\"), vector.getLeft());\r\n        writer.writeTextElement(QStringLiteral(\"ipxact:right\"), vector.getRight());\r\n\r\n        writer.writeEndElement(); // ipxact:vector\r\n    }\r\n\r\n    writer.writeEndElement(); // ipxact:vectors\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PortWriter::writeTypeDefinitions()\r\n//-----------------------------------------------------------------------------\r\nvoid PortWriter::writeWireTypeDefinitions(QXmlStreamWriter& writer,\r\n    QSharedPointer<QList<QSharedPointer<WireTypeDef> > > typeDefinitions) const\r\n{\r\n    if (typeDefinitions && hasNonEmptyTypeDefinitions(typeDefinitions))\r\n    {\r\n        writer.writeStartElement(QStringLiteral(\"ipxact:wireTypeDefs\"));\r\n\r\n        for (QSharedPointer<WireTypeDef> singleTypeDefinition : *typeDefinitions)\r\n        {\r\n            if (singleTypeDefinition->isEmpty() == false)\r\n            {\r\n                writer.writeStartElement(QStringLiteral(\"ipxact:wireTypeDef\"));\r\n\r\n                writeSingleTypeDefinition(writer, singleTypeDefinition, QStringLiteral(\"constrained\"));\r\n\r\n                writer.writeEndElement(); // ipxact:wireTypeDef\r\n            }\r\n        }\r\n\r\n        writer.writeEndElement(); // ipxact:wireTypeDefs\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PortWriter::hasNonEmptyTypeDefinitions()\r\n//-----------------------------------------------------------------------------\r\nbool PortWriter::hasNonEmptyTypeDefinitions(QSharedPointer<QList<QSharedPointer<WireTypeDef> > > typeDefinitions)\r\n    const\r\n{\r\n    return std::any_of(typeDefinitions->cbegin(), typeDefinitions->cend(), [](auto const& singleTypeDefinition)\r\n        {\r\n            return singleTypeDefinition->isEmpty() == false;\r\n        });\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PortWriter::writeSingleTypeDefinition()\r\n//-----------------------------------------------------------------------------\r\nvoid PortWriter::writeSingleTypeDefinition(QXmlStreamWriter& writer, QSharedPointer<WireTypeDef> typeDefinition,\r\n    QString const& attributeName) const\r\n{\r\n    if (!typeDefinition->getTypeName().isEmpty())\r\n    {\r\n        writer.writeStartElement(QStringLiteral(\"ipxact:typeName\"));\r\n\r\n        if (typeDefinition->isConstrained())\r\n        {\r\n            writer.writeAttribute(attributeName, QStringLiteral(\"true\"));\r\n        }\r\n\r\n        writer.writeCharacters(typeDefinition->getTypeName());\r\n        writer.writeEndElement(); // ipxact:typeName\r\n    }\r\n\r\n    for (QString const& definition : *typeDefinition->getTypeDefinitions())\r\n    {\r\n        if (!definition.isEmpty())\r\n        {\r\n            writer.writeTextElement(QStringLiteral(\"ipxact:typeDefinition\"), definition);\r\n        }\r\n    }\r\n\r\n    for (QString const& viewReference : *typeDefinition->getViewRefs())\r\n    {\r\n        if (!viewReference.isEmpty())\r\n        {\r\n            writer.writeTextElement(QStringLiteral(\"ipxact:viewRef\"), viewReference);\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PortWriter::writeWireDriver()\r\n//-----------------------------------------------------------------------------\r\nvoid PortWriter::writeWireDriver(QXmlStreamWriter& writer, QSharedPointer<Driver> driver) const\r\n{\r\n    if (driver)\r\n    {\r\n        writer.writeStartElement(QStringLiteral(\"ipxact:drivers\"));\r\n        writer.writeStartElement(QStringLiteral(\"ipxact:driver\"));\r\n\r\n        CommonItemsWriter::writeRange(writer, driver->getRange());\r\n\r\n        writer.writeTextElement(QStringLiteral(\"ipxact:defaultValue\"), driver->getDefaultValue());\r\n\r\n        writer.writeEndElement(); // ipxact:driver\r\n        writer.writeEndElement(); // ipxact:drivers\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PortWriter::writeTransactional()\r\n//-----------------------------------------------------------------------------\r\nvoid PortWriter::writeTransactional(QXmlStreamWriter& writer, QSharedPointer<Transactional> transactional,\r\n    Document::Revision docRevision) const\r\n{\r\n    writer.writeStartElement(QStringLiteral(\"ipxact:transactional\"));\r\n\r\n    if (transactional->getAllLogicalInitiativesAllowed())\r\n    {\r\n        writer.writeAttribute(QStringLiteral(\"allLogicalInitiativesAllowed\"), QStringLiteral(\"true\"));\r\n    }\r\n\r\n    writer.writeTextElement(QStringLiteral(\"ipxact:initiative\"), transactional->getInitiative());\r\n\r\n    writeTransactionalKind(writer, transactional->getKind());\r\n\r\n    writeTransactionalBusWidth(writer, transactional->getBusWidth());\r\n\r\n    if (docRevision == Document::Revision::Std22)\r\n    {\r\n        QualifierWriter::writeQualifier(writer, transactional->getQualifier());\r\n    }\r\n\r\n    ProtocolWriter protocolWriter;\r\n    protocolWriter.writeProtocol(writer, transactional->getProtocol());\r\n\r\n    writeTransactionalTypeDefinitions(writer, transactional);\r\n\r\n    writeTransactionalMinMaxConnections(writer, transactional);\r\n\r\n    writer.writeEndElement(); // ipxact:transactional\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PortWriter::writeTransactionalKind()\r\n//-----------------------------------------------------------------------------\r\nvoid PortWriter::writeTransactionalKind(QXmlStreamWriter& writer, QString const& kind) const\r\n{\r\n    if (!kind.isEmpty())\r\n    {\r\n        writer.writeStartElement(QStringLiteral(\"ipxact:kind\"));\r\n        if (TransactionalTypes::isIpXactKindType(kind))\r\n        {\r\n            writer.writeCharacters(kind);\r\n        }\r\n        else\r\n        {\r\n            writer.writeAttribute(QStringLiteral(\"custom\"), kind);\r\n            writer.writeCharacters(QStringLiteral(\"custom\"));\r\n        }\r\n\r\n        writer.writeEndElement(); // ipxact:kind\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PortWriter::writeTransactionalBusWidth()\r\n//-----------------------------------------------------------------------------\r\nvoid PortWriter::writeTransactionalBusWidth(QXmlStreamWriter& writer, QString const& busWidth) const\r\n{\r\n    if (!busWidth.isEmpty())\r\n    {\r\n        writer.writeTextElement(QStringLiteral(\"ipxact:busWidth\"), busWidth);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PortWriter::writeTransactionalTypeDefinitions()\r\n//-----------------------------------------------------------------------------\r\nvoid PortWriter::writeTransactionalTypeDefinitions(QXmlStreamWriter& writer,\r\n    QSharedPointer<Transactional> transactional) const\r\n{\r\n    if (!transactional->getTransTypeDef()->isEmpty())\r\n    {\r\n        writer.writeStartElement(QStringLiteral(\"ipxact:transTypeDefs\"));\r\n\r\n        for (QSharedPointer<WireTypeDef> transactionalTypeDefinition : *transactional->getTransTypeDef())\r\n        {\r\n            writer.writeStartElement(QStringLiteral(\"ipxact:transTypeDef\"));\r\n\r\n            writeSingleTypeDefinition(writer, transactionalTypeDefinition, QStringLiteral(\"exact\"));\r\n\r\n            writer.writeEndElement(); // ipxact:transTypeDef\r\n        }\r\n\r\n        writer.writeEndElement(); // ipxact:transTypeDefs\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PortWriter::writeTransactionalMinMaxConnections()\r\n//-----------------------------------------------------------------------------\r\nvoid PortWriter::writeTransactionalMinMaxConnections(QXmlStreamWriter& writer,\r\n    QSharedPointer<Transactional> transactional) const\r\n{\r\n    if (!transactional->getMinConnections().isEmpty() || !transactional->getMaxConnections().isEmpty())\r\n    {\r\n        writer.writeStartElement(QStringLiteral(\"ipxact:connection\"));\r\n\r\n        if (!transactional->getMaxConnections().isEmpty())\r\n        {\r\n            writer.writeTextElement(QStringLiteral(\"ipxact:maxConnections\"), transactional->getMaxConnections());\r\n        }\r\n        if (!transactional->getMinConnections().isEmpty())\r\n        {\r\n            writer.writeTextElement(QStringLiteral(\"ipxact:minConnections\"), transactional->getMinConnections());\r\n        }\r\n        writer.writeEndElement(); // ipxact:connection\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PortWriter::writeStructured()\r\n//-----------------------------------------------------------------------------\r\nvoid PortWriter::writeStructured(QXmlStreamWriter& writer, QSharedPointer<Structured> structured) const\r\n{\r\n    writer.writeStartElement(QStringLiteral(\"ipxact:structured\"));\r\n\r\n    if (structured->isPacked())\r\n    {\r\n        writer.writeAttribute(QStringLiteral(\"packed\"), QStringLiteral(\"true\"));\r\n    }\r\n    \r\n    writeStructuredType(writer, structured);\r\n\r\n    writeVectors(writer, structured->getVectors(), Document::Revision::Std22);\r\n\r\n    writeSubPorts(writer, structured);\r\n\r\n    writer.writeEndElement(); // ipxact:structured\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PortWriter::writeStructuredType()\r\n//-----------------------------------------------------------------------------\r\nvoid PortWriter::writeStructuredType(QXmlStreamWriter& writer, QSharedPointer<Structured> structured) const\r\n{\r\n    if (structured->getType() != Structured::Type::Undefined)\r\n    {\r\n\t\twriter.writeStartElement(QStringLiteral(\"ipxact:\") + Structured::toString(structured->getType()));\r\n\t\tif (structured->getType() == Structured::Type::Struct || structured->getType() == Structured::Type::Union)\r\n\t\t{\r\n\t\t\twriter.writeAttribute(QStringLiteral(\"direction\"), DirectionTypes::direction2Str(structured->getDirection()));\r\n\t\t}\r\n\t\telse if (structured->getType() == Structured::Type::Interface &&\r\n\t\t\tstructured->getDirection() == DirectionTypes::DIRECTION_PHANTOM)\r\n\t\t{\r\n\t\t\twriter.writeAttribute(QStringLiteral(\"phantom\"), QStringLiteral(\"true\"));\r\n\t\t}\r\n\t\twriter.writeEndElement(); // ipxact:struct/union/interface\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PortWriter::writeSubPorts()\r\n//-----------------------------------------------------------------------------\r\nvoid PortWriter::writeSubPorts(QXmlStreamWriter& writer, QSharedPointer<Structured> structured) const\r\n{\r\n    if (structured->getSubPorts()->isEmpty())\r\n    {\r\n        return;\r\n    }\r\n\r\n    writer.writeStartElement(QStringLiteral(\"ipxact:subPorts\"));\r\n\r\n    for (auto const& subPort : *structured->getSubPorts())\r\n    {\r\n        writer.writeStartElement(QStringLiteral(\"ipxact:subPort\"));\r\n\r\n        if (subPort->isIO())\r\n        {\r\n            writer.writeAttribute(QStringLiteral(\"isIO\"), QStringLiteral(\"true\"));\r\n        }\r\n\r\n        NameGroupWriter::writeNameGroup(writer, subPort, Document::Revision::Std22);\r\n\r\n        if (subPort->isWire())\r\n        {\r\n            writeWire(writer, subPort->getWire(), Document::Revision::Std22);\r\n        }\r\n        else if (subPort->isStructured())\r\n        {\r\n            writeStructured(writer, subPort->getStructured());\r\n        }\r\n\r\n        writer.writeEndElement(); // ipxact:subPort\r\n    }\r\n\r\n    writer.writeEndElement(); // ipxact:subPorts\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PortWriter::writeArrays()\r\n//-----------------------------------------------------------------------------\r\nvoid PortWriter::writeArrays(QXmlStreamWriter& writer, QSharedPointer<QList<Array> > arrays) const\r\n{\r\n    if (arrays->isEmpty())\r\n    {\r\n        return;\r\n    }\r\n\r\n    writer.writeStartElement(QStringLiteral(\"ipxact:arrays\"));\r\n\r\n    for (auto const& singleArray : *arrays)\r\n    {\r\n        writer.writeStartElement(QStringLiteral(\"ipxact:array\"));\r\n\r\n        writer.writeTextElement(QStringLiteral(\"ipxact:left\"), singleArray.getLeft());\r\n        writer.writeTextElement(QStringLiteral(\"ipxact:right\"), singleArray.getRight());\r\n\r\n        writer.writeEndElement(); // ipxact:array\r\n    }\r\n\r\n    writer.writeEndElement(); // ipxact:arrays\r\n}\r\n"
  },
  {
    "path": "IPXACTmodels/Component/PortWriter.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: PortWriter.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 11.09.2015\r\n//\r\n// Description:\r\n// Writer class for IP-XACT port element.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef PORTWRITER_H\r\n#define PORTWRITER_H\r\n\r\n#include \"Port.h\"\r\n\r\n#include <IPXACTmodels/common/CommonItemsWriter.h>\r\n#include <IPXACTmodels/ipxactmodels_global.h>\r\n\r\n#include <QXmlStreamWriter>\r\n#include <QSharedPointer>\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Writer class for IP-XACT port element.\r\n//-----------------------------------------------------------------------------\r\nclass IPXACTMODELS_EXPORT PortWriter\r\n{\r\npublic:\r\n\r\n    /*!\r\n     *  Write a component port to an XML file.\r\n     *\r\n     *    @param [in] writer          The used XML writer.\r\n     *    @param [in] port            The port to be written.\r\n     *    @param [in] docRevision     The applied IP-XACT standard revision.\r\n     */\r\n    void writePort(QXmlStreamWriter& writer, QSharedPointer<Port> port, Document::Revision docRevision) const;\r\n\r\nprivate:\r\n\r\n    /*!\r\n     *  Write a wire port.\r\n     *\r\n     *    @param [in] writer          Used XML writer.\r\n     *    @param [in] wire            The wire to be written.\r\n     *    @param [in] docRevision     The applied IP-XACT standard revision.\r\n     */\r\n    void writeWire(QXmlStreamWriter& writer, QSharedPointer<Wire> wire, Document::Revision docRevision) const;\r\n\r\n    /*!\r\n     *  Write a transactional port.\r\n     *\r\n     *    @param [in] writer          Used XML writer.\r\n     *    @param [in] transactional   The transactional to be written.\r\n     *    @param [in] docRevision     The applied IP-XACT standard revision.\r\n     */\r\n    void writeTransactional(QXmlStreamWriter& writer, QSharedPointer<Transactional> transactional,\r\n        Document::Revision docRevision) const;\r\n\r\n    /*!\r\n     *  Write a vector.\r\n     *\r\n     *    @param [in] writer          Used XML writer.\r\n     *    @param [in] vector          The vector to be written.\r\n     *    @param [in] docRevision     The applied IP-XACT standard revision.\r\n     */\r\n    void writeVectors(QXmlStreamWriter& writer, QSharedPointer<QList<Vector> > vectors,\r\n        Document::Revision docRevision) const;\r\n\r\n    /*!\r\n     *  Write the wire type definitions.\r\n     *\r\n     *    @param [in] writer              Used XML writer.\r\n     *    @param [in] typeDefinitions     A list of the wire type definitions to be written.\r\n     */\r\n    void writeWireTypeDefinitions(QXmlStreamWriter& writer,\r\n        QSharedPointer<QList<QSharedPointer<WireTypeDef> > > typeDefinitions) const;\r\n\r\n    /*!\r\n     *  Check if the wire type definitions are not empty.\r\n     *\r\n     *    @param [in] typeDefinitions     A list of the wire type definitions to be check.\r\n     *\r\n     *    @return True, if at least one type definition is not empty, false otherwise.\r\n     */\r\n    bool hasNonEmptyTypeDefinitions(QSharedPointer<QList<QSharedPointer<WireTypeDef> > > typeDefinitions) const;\r\n\r\n    /*!\r\n     *  Write a single type definition.\r\n     *\r\n     *    @param [in] writer          Used XML writer.\r\n     *    @param [in] typeDefinition  The type definition to be written.\r\n     *    @param [in] attributeName   The type definition constraining attribute name.\r\n     */\r\n    void writeSingleTypeDefinition(QXmlStreamWriter& writer, QSharedPointer<WireTypeDef> typeDefinition,\r\n        QString const& attributeName) const;\r\n\r\n    /*!\r\n     *  Write the wire driver.\r\n     *\r\n     *    @param [in] writer          Used XML writer.\r\n     *    @param [in] driver          The driver to be written.\r\n     */\r\n    void writeWireDriver(QXmlStreamWriter& writer, QSharedPointer<Driver> driver) const;\r\n\r\n    /*!\r\n     *  Write the transactional kind.\r\n     *\r\n     *    @param [in] writer  Used XML writer.\r\n     *    @param [in] kind    The kind to be written.\r\n     */\r\n    void writeTransactionalKind(QXmlStreamWriter& writer, QString const& kind) const;\r\n\r\n    /*!\r\n     *  Write the transactional bus width.\r\n     *\r\n     *    @param [in] writer      Used XML writer.\r\n     *    @param [in] busWidth    The bus width to be written.\r\n     */\r\n    void writeTransactionalBusWidth(QXmlStreamWriter& writer, QString const& busWidth) const;\r\n\r\n    /*!\r\n     *  Write the transactional type definitions.\r\n     *\r\n     *    @param [in] writer          Used XML writer.\r\n     *    @param [in] transactional   The transactional containing the type definitions.\r\n     */\r\n    void writeTransactionalTypeDefinitions(QXmlStreamWriter& writer, QSharedPointer<Transactional> transactional)\r\n        const;\r\n\r\n    /*!\r\n     *  Write the transactional minimum and maximum connections.\r\n     *\r\n     *    @param [in] writer          Used XML writer.\r\n     *    @param [in] transactional   The transactional containing the minimum and maximum connections.\r\n     */\r\n    void writeTransactionalMinMaxConnections(QXmlStreamWriter& writer, QSharedPointer<Transactional> transactional)\r\n        const;\r\n\r\n    /*!\r\n     *  Write the structural port.\r\n     *\r\n     *    @param [in] writer          The used XML writer.\r\n     *    @param [in] structured      The structured port description to write.   \r\n     */\r\n    void writeStructured(QXmlStreamWriter& writer, QSharedPointer<Structured> structured) const;\r\n\r\n    /*!\r\n     *  Write the type of the structural port.\r\n     *\r\n     *    @param [in] writer          The used XML writer.\r\n     *    @param [in] structured      The structured port whose type to write.\r\n     */\r\n    void writeStructuredType(QXmlStreamWriter& writer, QSharedPointer<Structured> structured) const;\r\n\r\n    /*!\r\n     *  Write the sub-ports in a structural port.\r\n     *\r\n     *    @param [in] writer          The used XML writer.\r\n     *    @param [in] structured      The structured port whose sub-ports to write.\r\n     */\r\n    void writeSubPorts(QXmlStreamWriter& writer, QSharedPointer<Structured> structured) const;\r\n\r\n    /*!\r\n     *  Write the port arrays.\r\n     *\r\n     *    @param [in] writer  Used XML writer.\r\n     *    @param [in] arrays  The arrays to be written.\r\n     */\r\n    void writeArrays(QXmlStreamWriter& writer, QSharedPointer<QList<Array> > arrays) const;\r\n\r\n};\r\n\r\n#endif // INSTANTIATIONSWRITER_H"
  },
  {
    "path": "IPXACTmodels/Component/PowerDomain.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: PowerDomain.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Esko Pekkarinen\n// Date: 4.10.2023\n//\n// Description:\n// Implementation for ipxact:powerDomain element.\n//-----------------------------------------------------------------------------\n\n#include \"PowerDomain.h\"\n\n#include <QString>\n\n//-----------------------------------------------------------------------------\n// Function: PowerDomain::PowerDomain()\n//-----------------------------------------------------------------------------\nPowerDomain::PowerDomain(): NameGroup(), Extendable()\n{\n}\n\n//-----------------------------------------------------------------------------\n// Function: PowerDomain::PowerDomain()\n//-----------------------------------------------------------------------------\nPowerDomain::PowerDomain(PowerDomain const& other):\nNameGroup(other),\nExtendable(other),\nalwaysOn_(other.alwaysOn_),\nsubDomainOf_(other.subDomainOf_)\n{\n    copyParameters(other);\n}\n\n//-----------------------------------------------------------------------------\n// Function: PowerDomain::operator=()\n//-----------------------------------------------------------------------------\nPowerDomain& PowerDomain::operator=(PowerDomain const& other)\n{\n\tif (this != &other)\n    {\n        NameGroup::operator=(other);\n        Extendable::operator=(other);\n\n        alwaysOn_ = other.alwaysOn_;\n        subDomainOf_ = other.subDomainOf_;\n\n        copyParameters(other);\n\t}\n\n\treturn *this;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PowerDomain::~PowerDomain()\n//-----------------------------------------------------------------------------\nPowerDomain::~PowerDomain()\n{\n}\n\n//-----------------------------------------------------------------------------\n// Function: PowerDomain::setAlwaysOn()\n//-----------------------------------------------------------------------------\nvoid PowerDomain::setAlwaysOn(QString const& expression)\n{\n    alwaysOn_ = expression;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PowerDomain::getAlwaysOn()\n//-----------------------------------------------------------------------------\nQString PowerDomain::getAlwaysOn() const\n{\n    return alwaysOn_;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PowerDomain::setSubDomainOf()\n//-----------------------------------------------------------------------------\nvoid PowerDomain::setSubDomainOf(QString const& domainName)\n{\n    subDomainOf_ = domainName;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PowerDomain::getSubDomainOf()\n//-----------------------------------------------------------------------------\nQString PowerDomain::getSubDomainOf() const\n{\n    return subDomainOf_;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PowerDomain::setParameters()\n//-----------------------------------------------------------------------------\nvoid PowerDomain::setParameters(QSharedPointer<QList<QSharedPointer<Parameter> > > parameters)\n{\n    parameters_ = parameters;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PowerDomain::getParameters()\n//-----------------------------------------------------------------------------\nQSharedPointer<QList<QSharedPointer<Parameter> > > PowerDomain::getParameters()\n{\n    return parameters_;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PowerDomain::copyParameters()\n//-----------------------------------------------------------------------------\nvoid PowerDomain::copyParameters(PowerDomain const& other)\n{\n    for (auto parameter : *other.parameters_)\n    {\n        parameters_->append(QSharedPointer<Parameter>(new Parameter(*parameter)));\n    }\n}\n"
  },
  {
    "path": "IPXACTmodels/Component/PowerDomain.h",
    "content": "//-----------------------------------------------------------------------------\n// File: PowerDomain.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Esko Pekkarinen\n// Date: 4.10.2023\n//\n// Description:\n// Implementation for ipxact:powerDomain element.\n//-----------------------------------------------------------------------------\n\n#ifndef POWERDOMAIN_H\n#define POWERDOMAIN_H\n\n#include <IPXACTmodels/common/NameGroup.h>\n#include <IPXACTmodels/common/Extendable.h>\n#include <IPXACTmodels/common/Parameter.h>\n\n#include <QString>\n#include <QStringList>\n\n//-----------------------------------------------------------------------------\n//! Implementation for ipxact:powerDomain element.\n//-----------------------------------------------------------------------------\nclass IPXACTMODELS_EXPORT PowerDomain : public NameGroup, public Extendable\n{\npublic:\n\n\n\t/*! The default constructor\n\t *\n\t * Constructs an empty PowerDomain which is in invalid state.\n\t*/\n\tPowerDomain();\n\n\t//! Copy constructor\n\tPowerDomain(const PowerDomain& other);\n\n\t//! Assignment operator\n\tPowerDomain& operator=(const PowerDomain& other);\n\n\t//! The destructor\n\tvirtual ~PowerDomain();\n\n \n\tvoid setAlwaysOn(QString const& expression);\n\n\tQString getAlwaysOn() const;\n\n\tvoid setSubDomainOf(QString const& domainName);\n\n\tQString getSubDomainOf() const;\n\n\tvoid setParameters(QSharedPointer<QList<QSharedPointer<Parameter> > > parameters);\n\n\tQSharedPointer<QList<QSharedPointer<Parameter> > > getParameters();\n\nprivate:\n\n\tvoid copyParameters(PowerDomain const& other);\n\n\t//! Expression for power domain being always on.\n\tQString alwaysOn_;\n\n\tQString subDomainOf_;\n\n    QSharedPointer<QList<QSharedPointer<Parameter> > > parameters_ =\n        QSharedPointer<QList<QSharedPointer<Parameter> > >(new QList<QSharedPointer<Parameter> >);\n};\n\n#endif // POWERDOMAIN_H\n"
  },
  {
    "path": "IPXACTmodels/Component/PowerDomainReader.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: PowerDomainReader.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Esko Pekkarinen\n// Date: 4.10.2023\n//\n// Description:\n// Reader class for IP-XACT PowerDomain element.\n//-----------------------------------------------------------------------------\n\n#include \"PowerDomainReader.h\"\n\n#include <IPXACTmodels/common/NameGroupReader.h>\n#include <IPXACTmodels/common/CommonItemsReader.h>\n\n//-----------------------------------------------------------------------------\n// Function: PowerDomainReader::createFrom()\n//-----------------------------------------------------------------------------\nQSharedPointer<PowerDomain> PowerDomainReader::createFrom(QDomNode const& powerDomainNode)\n{\n    QSharedPointer<PowerDomain> newPowerDomain(new PowerDomain());\n\n    NameGroupReader::parseNameGroup(powerDomainNode, newPowerDomain);\n\n    Details::parseAlwaysOn(powerDomainNode, newPowerDomain);\n\n    Details::parseSubDomain(powerDomainNode, newPowerDomain);\n\n    newPowerDomain->setParameters(CommonItemsReader::parseAndCreateParameters(powerDomainNode, \n        Document::Revision::Std22));\n\n    CommonItemsReader::parseVendorExtensions(powerDomainNode, newPowerDomain);\n\n    return newPowerDomain;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PowerDomainReader::Details::parseAlwaysOn()\n//-----------------------------------------------------------------------------\nvoid PowerDomainReader::Details::parseAlwaysOn(QDomNode const& powerDomainNode, QSharedPointer<PowerDomain> powerDomain)\n{\n    QDomElement onElement = powerDomainNode.firstChildElement(QStringLiteral(\"ipxact:alwaysOn\"));\n\n    if (onElement.isNull() == false)\n    {\n        QString alwaysOn = onElement.firstChild().nodeValue();\n        powerDomain->setAlwaysOn(alwaysOn);\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: PowerDomainReader::Details::parseSubDomain()\n//-----------------------------------------------------------------------------\nvoid PowerDomainReader::Details::parseSubDomain(QDomNode const& powerDomainNode, QSharedPointer<PowerDomain> powerDomain)\n{\n    QDomElement domainElement = powerDomainNode.firstChildElement(QStringLiteral(\"ipxact:subDomainOf\"));\n\n    if (domainElement.isNull() == false)\n    {\n        QString domainName = domainElement.firstChild().nodeValue();\n        powerDomain->setSubDomainOf(domainName);\n    }\n}\n"
  },
  {
    "path": "IPXACTmodels/Component/PowerDomainReader.h",
    "content": "//-----------------------------------------------------------------------------\n// File: PowerDomainReader.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Esko Pekkarinen\n// Date: 4.10.2023\n//\n// Description:\n// Reader class for IP-XACT PowerDomain element.\n//-----------------------------------------------------------------------------\n\n#ifndef PowerDomainReader_H\n#define PowerDomainReader_H\n\n#include \"PowerDomain.h\"\n\n#include <IPXACTmodels/common/CommonItemsReader.h>\n\n#include <QDomNode>\n\n#include <QSharedPointer>\n\n//-----------------------------------------------------------------------------\n//! Reader class for IP-XACT PowerDomain element.\n//-----------------------------------------------------------------------------\nnamespace  PowerDomainReader \n{\n    /*!\n     *  Creates a new PowerDomain from a given PowerDomain node.\n     *\n     *    @param [in] PowerDomainNode    XML description of the PowerDomain.\n     *    @param [in] docRevision    The applied IP-XACT standard revision.\n     */\n    IPXACTMODELS_EXPORT QSharedPointer<PowerDomain> createFrom(QDomNode const& PowerDomainNode);\n\n    namespace Details\n    {\n\n\n\n        void parseAlwaysOn(QDomNode const& powerDomainNode, QSharedPointer<PowerDomain> powerDomain);\n        void parseSubDomain(QDomNode const& powerDomainNode, QSharedPointer<PowerDomain> powerDomain);\n    }\n};\n\n#endif // PowerDomainReader_H\n"
  },
  {
    "path": "IPXACTmodels/Component/PowerDomainWriter.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: PowerDomainWriter.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Esko Pekkarinen\n// Date: 4.10.2023\n//\n// Description:\n// Writer namespace for ipxact:powerDomain.\n//-----------------------------------------------------------------------------\n\n#include \"PowerDomainWriter.h\"\n\n#include <IPXACTmodels/common/NameGroupWriter.h>\n\n#include <IPXACTmodels/common/CommonItemsWriter.h>\n\n//-----------------------------------------------------------------------------\n// Function: PowerDomainWriter::createPowerDomainFrom()\n//-----------------------------------------------------------------------------\nvoid PowerDomainWriter::write(QXmlStreamWriter& writer, QSharedPointer<PowerDomain> domain)\n{\n    writer.writeStartElement(QStringLiteral(\"ipxact:powerDomain\"));\n\n    NameGroupWriter::writeNameGroup(writer, domain, Document::Revision::Std22);\n\n    CommonItemsWriter::writeNonEmptyElement(writer, QStringLiteral(\"ipxact:alwaysOn\"), domain->getAlwaysOn());\n\n    CommonItemsWriter::writeNonEmptyElement(writer, QStringLiteral(\"ipxact:subDomainOf\"), domain->getSubDomainOf());\n\n    CommonItemsWriter::writeParameters(writer, domain->getParameters(), Document::Revision::Std22);\n\n    CommonItemsWriter::writeVendorExtensions(writer, domain);\n\n\twriter.writeEndElement(); // ipxact:powerDomain\n}\n"
  },
  {
    "path": "IPXACTmodels/Component/PowerDomainWriter.h",
    "content": "//-----------------------------------------------------------------------------\n// File: PowerDomainWriter.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Esko Pekkarinen\n// Date: 4.10.2023\n//\n// Description:\n// Writer namespace for ipxact:powerDomain.\n//-----------------------------------------------------------------------------\n\n#ifndef POWERDOMAINWRITER_H\n#define POWERDOMAINWRITER_H\n\n#include \"PowerDomain.h\"\n\n\n#include <QXmlStreamWriter>\n#include <QSharedPointer>\n\n//-----------------------------------------------------------------------------\n//! Writer namespace for ipxact:powerDomain.\n//-----------------------------------------------------------------------------\nnamespace PowerDomainWriter\n{\n\n    /*!\n     *  Write a channel to an XML file.\n     *\n     *    @param [in] writer      The used xml writer.\n     *    @param [in] domain\t\tThe power domain to be written.\n     */\n    IPXACTMODELS_EXPORT void write(QXmlStreamWriter& writer, QSharedPointer<PowerDomain> domain);\n\n};\n\n#endif // POWERDOMAINWRITER_H\n"
  },
  {
    "path": "IPXACTmodels/Component/Region.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: Region.h\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Esko Pekkarinen\n// Date: 15.06.2023\n//\n// Description:\n// Region describes the location and size of an area in memory.\n//-----------------------------------------------------------------------------\n\n#include \"Region.h\"\n\n//-----------------------------------------------------------------------------\n// Function: Region::Region()\n//-----------------------------------------------------------------------------\nRegion::Region(QString const& name, QString const& addressOffset, QString const& range):\nNameGroup(name),\nExtendable(),\naddressOffset_(addressOffset),\nrange_(range)\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: Region::Region()\n//-----------------------------------------------------------------------------\nRegion::Region( const Region& other ):\nNameGroup(other),\n    Extendable(other),\n    addressOffset_(other.addressOffset_),\n    range_(other.range_)\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: Region::~Region()\n//-----------------------------------------------------------------------------\nRegion::~Region()\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: Region::operator=()\n//-----------------------------------------------------------------------------\nRegion& Region::operator=( const Region& other )\n{\n\tif (this != &other)\n    {\n\t\tNameGroup::operator=(other);\n        Extendable::operator=(other);\n\n\t\taddressOffset_ = other.addressOffset_;\n\t\trange_ = other.range_;\n\t}\n\treturn *this;\n}\n\n//-----------------------------------------------------------------------------\n// Function: Region::getAddressOffset()\n//-----------------------------------------------------------------------------\nQString Region::getAddressOffset() const\n{\n\treturn addressOffset_;\n}\n\n//-----------------------------------------------------------------------------\n// Function: Region::setOffset()\n//-----------------------------------------------------------------------------\nvoid Region::setOffset( QString const& addressOffset )\n{\n    addressOffset_ = addressOffset;\n}\n\n//-----------------------------------------------------------------------------\n// Function: Region::getRange()\n//-----------------------------------------------------------------------------\nQString Region::getRange() const\n{\n\treturn range_;\n}\n\n//-----------------------------------------------------------------------------\n// Function: Region::setRange()\n//-----------------------------------------------------------------------------\nvoid Region::setRange( QString const& range )\n{\n    range_ = range;\n}\n"
  },
  {
    "path": "IPXACTmodels/Component/Region.h",
    "content": "//-----------------------------------------------------------------------------\n// File: Region.h\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Esko Pekkarinen\n// Date: 15.06.2023\n//\n// Description:\n// Region describes the location and size of an area in memory.\n//-----------------------------------------------------------------------------\n\n#ifndef REGION_H\n#define REGION_H\n\n#include <IPXACTmodels/common/NameGroup.h>\n#include <IPXACTmodels/common/Extendable.h>\n\n#include <IPXACTmodels/ipxactmodels_global.h>\n\n#include <QString>\n#include <QMap>\n\n//-----------------------------------------------------------------------------\n//! Region describes the location and size of an area in memory.\n//-----------------------------------------------------------------------------\nclass IPXACTMODELS_EXPORT Region : public NameGroup, public Extendable\n{\n\npublic:\n\n\t/*!\n\t *  The default constructor.\n\t *\n\t *    @param [in] name            Name of the region.\n\t */\n\tRegion(QString const& name = QString(), QString const& addressOffset = QString(), QString const& range = QString());\n\t\n\t//! The destructor.\n\tvirtual ~Region();\n\n\t//! The copy constructor.\n\tRegion(const Region& other);\n\n\t//! The assignment operator.\n\tRegion& operator=(const Region& other);\n\n\t/*!\n     *  Get the address offset of the region.\n\t *\n\t *    @return The address offset.\n\t */\n\tQString getAddressOffset() const;\n\n    /*!\n     *  Set the address offset for the region.\n\t *\n\t *    @param [in] addressOffset   The offset within the containing memory.\n\t */\n\tvoid setOffset(QString const& addressOffset);\n\n\t/*!\n     *  Get the range of the region.\n\t *\n\t *    @return  The number of addressable units the region has.\n\t */\n\tQString getRange() const;\n    \n\t/*!\n     *  Set the range for the region.\n\t *\n\t *    @param [in] range   The number of addressable units the region contains.\n\t */\n\tvoid setRange(QString const& range);\n\nprivate:\n\n\t//! The offset of the region from the beginning of the containing memory.\n\tQString addressOffset_;\n\n\t//! The range of the region in addressable units.\n\tQString range_;\n\n};\n\n#endif // REGION_H"
  },
  {
    "path": "IPXACTmodels/Component/Register.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: Register.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 28.09.2015\r\n//\r\n// Description:\r\n// Describes the ipxact:register element.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"Register.h\"\r\n#include \"AlternateRegister.h\"\r\n\r\n#include <IPXACTmodels/Component/MemoryArray.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Register::Register()\r\n//-----------------------------------------------------------------------------\r\nRegister::Register(QString const& name, QString const& addressOffset, QString const& size):\r\nRegisterDefinition(name, addressOffset),\r\nsize_(size),\r\nalternateRegisters_(new QList<QSharedPointer<AlternateRegister> > ())\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Register::Register()\r\n//-----------------------------------------------------------------------------\r\nRegister::Register(const Register& other):\r\n    RegisterDefinition(other),\r\n    size_(other.size_),\r\n    alternateRegisters_(new QList<QSharedPointer<AlternateRegister> > ()),\r\n    registerDefinitionReference_(other.registerDefinitionReference_),\r\n    typeDefinitionsReference_(other.typeDefinitionsReference_)\r\n{\r\n    copyAlternateRegisters(other);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Register::operator=()\r\n//-----------------------------------------------------------------------------\r\nRegister& Register::operator=(const Register& other)\r\n{\r\n    if (this != &other)\r\n    {\r\n        RegisterDefinition::operator=(other);\r\n        size_ = other.size_;\r\n        registerDefinitionReference_ = other.registerDefinitionReference_;\r\n        typeDefinitionsReference_ = other.typeDefinitionsReference_;\r\n\r\n        alternateRegisters_->clear();\r\n        copyAlternateRegisters(other);\r\n    }\r\n\r\n    return *this;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Register::~Register()\r\n//-----------------------------------------------------------------------------\r\nRegister::~Register()\r\n{\r\n    alternateRegisters_.clear();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Register::clone()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<RegisterBase> Register::clone()\r\n{\r\n    return QSharedPointer<RegisterBase>(new Register(*this));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Register::getAlternateRegisters()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<QList<QSharedPointer<AlternateRegister> > > Register::getAlternateRegisters() const\r\n{\r\n    return alternateRegisters_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Register::setAlternateRegisters()\r\n//-----------------------------------------------------------------------------\r\nvoid Register::setAlternateRegisters\r\n    (QSharedPointer<QList<QSharedPointer<AlternateRegister> > > newAlternateRegisters)\r\n{\r\n    alternateRegisters_->clear();\r\n    alternateRegisters_ = newAlternateRegisters;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Register::getSize()\r\n//-----------------------------------------------------------------------------\r\nQString Register::getSize() const\r\n{\r\n    return size_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Register::setSize()\r\n//-----------------------------------------------------------------------------\r\nvoid Register::setSize(QString const& newSize)\r\n{\r\n    size_ = newSize;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Register::getRegisterDefinitionReference()\r\n//-----------------------------------------------------------------------------\r\nQString Register::getRegisterDefinitionReference() const\r\n{\r\n    return registerDefinitionReference_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Register::setRegisterDefinitionReference()\r\n//-----------------------------------------------------------------------------\r\nvoid Register::setRegisterDefinitionReference(QString const& registerDefinitionRef)\r\n{\r\n    registerDefinitionReference_ = registerDefinitionRef;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Register::getTypeDefinitionsReference()\r\n//-----------------------------------------------------------------------------\r\nQString Register::getTypeDefinitionsReference() const\r\n{\r\n    return typeDefinitionsReference_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Register::setTypeDefinitionsReference()\r\n//-----------------------------------------------------------------------------\r\nvoid Register::setTypeDefinitionsReference(QString const& typeDefinitionsRef)\r\n{\r\n    typeDefinitionsReference_ = typeDefinitionsRef;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Register::copyAlternateRegisters()\r\n//-----------------------------------------------------------------------------\r\nvoid Register::copyAlternateRegisters(const Register& other)\r\n{\r\n    for (auto const& alternateRegister : *other.alternateRegisters_)\r\n    {\r\n        if (alternateRegister)\r\n        {\r\n            auto copy = QSharedPointer<AlternateRegister>(new AlternateRegister(*alternateRegister));\r\n            alternateRegisters_->append(copy);\r\n        }\r\n    }\r\n}\r\n"
  },
  {
    "path": "IPXACTmodels/Component/Register.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: Register.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 28.09.2015\r\n//\r\n// Description:\r\n// Describes the ipxact:register element.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef REGISTER_H\r\n#define REGISTER_H\r\n\r\n#include \"RegisterDefinition.h\"\r\n\r\n#include <IPXACTmodels/ipxactmodels_global.h>\r\n\r\n#include <QString>\r\n#include <QList>\r\n#include <QSharedPointer>\r\n\r\nclass AlternateRegister;\r\nclass MemoryArray;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Describes the ipxact:register element.\r\n//-----------------------------------------------------------------------------\r\nclass IPXACTMODELS_EXPORT Register: public RegisterDefinition\r\n{\r\n\r\npublic:\r\n\r\n\t/*!\r\n\t *  The constructor.\r\n\t *\r\n\t *    @param [in] name            Name of the register.\r\n\t *    @param [in] addressOffset   Offset of the register.\r\n\t *    @param [in] size            Size of the register.\r\n\t */\r\n\tRegister(QString const& name = QString(), QString const& addressOffset = QString(),\r\n        QString const& size = QString());\r\n\r\n\t//! Copy constructor.\r\n\tRegister(const Register& other);\r\n\r\n\t//! Assignment operator.\r\n\tRegister& operator=(const Register& other);\r\n\r\n\t//! The destructor.\r\n\tvirtual ~Register();\r\n\r\n\t/*!\r\n     *  Clone the register and return pointer to the copy.\r\n\t * \r\n\t *    @return Pointer to the cloned register.\r\n\t */\r\n    virtual QSharedPointer<RegisterBase> clone();\r\n    \r\n\r\n    /*!\r\n     *  Get the alternate registers of this register.\r\n     *\r\n     *    @return Pointer to a list containing the alternate registers.\r\n     */\r\n    QSharedPointer<QList<QSharedPointer<AlternateRegister> > > getAlternateRegisters() const;\r\n\r\n    /*!\r\n     *  Set the alternate registers for this register.\r\n     *\r\n     *    @param [in] alternateRegisters  Pointer to a list containing the new alternateRegisters.\r\n     */\r\n    void setAlternateRegisters(QSharedPointer<QList<QSharedPointer<AlternateRegister> > > newAlternateRegisters);\r\n\r\n\t/*!\r\n     *  Get the width of the register.\r\n\t *\r\n\t *    @return The width of the register in bits.\r\n\t */\r\n    QString getSize() const;\r\n\r\n\t/*!\r\n     *  Set the width of the register.\r\n\t *\r\n\t *    @param [in] size    The width of the register in bits.\r\n\t */\r\n    void setSize(QString const& newSize);\r\n\r\n    /*!\r\n     *\tGet the register definition reference.\r\n     *\t    \r\n     * \t    @return The reference to a register definition.\r\n     */\r\n    QString getRegisterDefinitionReference() const;\r\n\r\n    /*!\r\n     *\tSet the register definition reference.\r\n     *  \r\n     *    @param [in] registerDefinitionRef     The new register definition reference.\r\n     */\r\n    void setRegisterDefinitionReference(QString const& registerDefinitionRef);\r\n\r\n    /*!\r\n     *\tGet the reference to the type definitions containing the register definition reference.\r\n     *\t    \r\n     * \t    @return The reference to the type definitions containing the register definition.\r\n     */\r\n    QString getTypeDefinitionsReference() const;\r\n\r\n    /*!\r\n     *\tSet the type definitions reference.\r\n     *  \r\n     *    @param [in] typeDefinitionsRef     The new type definitions reference to set.\r\n     */\r\n    void setTypeDefinitionsReference(QString const& typeDefinitionsRef);\r\n\r\nprivate:\r\n\r\n    /*!\r\n     *  Copy the alternate registers.\r\n     *\r\n     *    @param [in] other   The register being copied.\r\n     */\r\n    void copyAlternateRegisters(const Register& other);\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! The width of the registers, in bits.\r\n    QString size_;\r\n\r\n\t//! Contains the alternateRegisters for this register.\r\n    QSharedPointer<QList<QSharedPointer<AlternateRegister> > > alternateRegisters_;\r\n\r\n    //! The name of the referenced register definition.\r\n    QString registerDefinitionReference_;\r\n\r\n    //! The type definitions containing the referenced register definition.\r\n    QString typeDefinitionsReference_;\r\n};\r\n\r\nQ_DECLARE_METATYPE(QSharedPointer<Register>);\r\n\r\n#endif // REGISTER_H\r\n"
  },
  {
    "path": "IPXACTmodels/Component/RegisterBase.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: RegisterBase.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 28.09.2015\r\n//\r\n// Description:\r\n// Describes the base class for ipxact:register, RegisterBase and alternateRegister.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"RegisterBase.h\"\r\n\r\n#include <IPXACTmodels/common/Parameter.h>\r\n#include <IPXACTmodels/Component/AccessPolicy.h>\r\n#include <IPXACTmodels/Component/MemoryArray.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: RegisterBase::RegisterBase()\r\n//-----------------------------------------------------------------------------\r\nRegisterBase::RegisterBase(QString const& name /* = QString() */) :\r\nNameGroup(name),\r\nExtendable()\r\n{\r\n\r\n}\r\nRegisterBase::RegisterBase(QString const& name,QString const& addressOffset) :\r\nNameGroup(name),\r\nExtendable(),\r\naddressOffset_(addressOffset)\r\n{\r\n\r\n}\r\n//-----------------------------------------------------------------------------\r\n// Function: RegisterBase::RegisterBase()\r\n//-----------------------------------------------------------------------------\r\nRegisterBase::RegisterBase (const RegisterBase& other):\r\nNameGroup(other),\r\nExtendable(other),\r\naddressOffset_(other.addressOffset_),\r\nisPresent_(other.isPresent_),\r\ntypeIdentifier_(other.typeIdentifier_)\r\n{\r\n    copyParameters(other);\r\n    copyAccessPolicies(other);\r\n\r\n    if (other.memoryArray_)\r\n    {\r\n        memoryArray_ = QSharedPointer<MemoryArray>(new MemoryArray(*other.memoryArray_));\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: RegisterBase::operator=()\r\n//-----------------------------------------------------------------------------\r\nRegisterBase& RegisterBase::operator=(const RegisterBase& other)\r\n{\r\n    if (this != &other)\r\n    {\r\n        NameGroup::operator=(other);\r\n        Extendable::operator=(other);\r\n        addressOffset_ = other.addressOffset_;\r\n        isPresent_ = other.isPresent_;\r\n        typeIdentifier_ = other.typeIdentifier_;\r\n\r\n        parameters_->clear();\r\n        copyParameters(other);\r\n        accessPolicies_->clear();\r\n        copyAccessPolicies(other);\r\n\r\n        if (other.memoryArray_)\r\n        {\r\n            memoryArray_ = QSharedPointer<MemoryArray>(new MemoryArray(*other.memoryArray_));\r\n        }\r\n    }\r\n\r\n    return *this;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: RegisterBase::~RegisterBase()\r\n//-----------------------------------------------------------------------------\r\nRegisterBase::~RegisterBase()\r\n{\r\n    parameters_.clear();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: RegisterBase::getIsPresent()\r\n//-----------------------------------------------------------------------------\r\nQString RegisterBase::getIsPresent() const\r\n{\r\n    return isPresent_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: RegisterBase::setIsPresent()\r\n//-----------------------------------------------------------------------------\r\nvoid RegisterBase::setIsPresent(QString const& newIsPresent)\r\n{\r\n    isPresent_ = newIsPresent;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: RegisterBase::getTypeIdentifier()\r\n//-----------------------------------------------------------------------------\r\nQString RegisterBase::getTypeIdentifier() const\r\n{\r\n    return typeIdentifier_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: RegisterBase::setTypeIdentifier()\r\n//-----------------------------------------------------------------------------\r\nvoid RegisterBase::setTypeIdentifier(QString const& newTypeIdentifier)\r\n{\r\n    typeIdentifier_ = newTypeIdentifier;\r\n}\r\n//-----------------------------------------------------------------------------\r\n// Function: RegisterBase::()\r\n//-----------------------------------------------------------------------------\r\nQString RegisterBase::getDimension() const\r\n{   \r\n    if (memoryArray_)\r\n    {\r\n        return memoryArray_->getDimensions()->first()->value_;\r\n    }\r\n\r\n    return QString();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: RegisterBase::setDimension()\r\n//-----------------------------------------------------------------------------\r\nvoid RegisterBase::setDimension(QString const& newDimension)\r\n{\r\n    if (!memoryArray_)\r\n    {\r\n        memoryArray_ = QSharedPointer<MemoryArray>(new MemoryArray());\r\n    }\r\n    \r\n    if (newDimension.isEmpty())\r\n    {\r\n        memoryArray_.clear();\r\n        return;\r\n    }\r\n\r\n    // Create dimension if missing, otherwise set the new value to the first dim.\r\n    if (memoryArray_->getDimensions()->isEmpty())\r\n    {\r\n        QSharedPointer<MemoryArray::Dimension> newDim(new MemoryArray::Dimension());\r\n        newDim->value_ = newDimension;\r\n        memoryArray_->getDimensions()->append(newDim);\r\n    }\r\n    else\r\n    {\r\n        memoryArray_->getDimensions()->first()->value_ = newDimension;\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: RegisterBase::getMemoryArray()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<MemoryArray> RegisterBase::getMemoryArray() const\r\n{\r\n    return memoryArray_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: RegisterBase::setMemoryArray()\r\n//-----------------------------------------------------------------------------\r\nvoid RegisterBase::setMemoryArray(QSharedPointer<MemoryArray> newMemArray)\r\n{\r\n    memoryArray_ = newMemArray;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: RegisterBase::getAddressOffset()\r\n//-----------------------------------------------------------------------------\r\nQString RegisterBase::getAddressOffset() const\r\n{\r\n    return addressOffset_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: RegisterBase::setAddressOffset()\r\n//-----------------------------------------------------------------------------\r\nvoid RegisterBase::setAddressOffset(QString const& newAddressOffset)\r\n{\r\n    addressOffset_ = newAddressOffset;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: RegisterBase::getParameters()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<QList<QSharedPointer<Parameter> > > RegisterBase::getParameters() const\r\n{\r\n    return parameters_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: RegisterBase::setParameters()\r\n//-----------------------------------------------------------------------------\r\nvoid RegisterBase::setParameters(QSharedPointer<QList<QSharedPointer<Parameter> > > newParameters)\r\n{\r\n    parameters_->clear();\r\n    parameters_ = newParameters;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: RegisterBase::getAccessPolicies()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<QList<QSharedPointer<AccessPolicy> > > RegisterBase::getAccessPolicies() const\r\n{\r\n    return accessPolicies_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: RegisterBase::setAccessPolicies()\r\n//-----------------------------------------------------------------------------\r\nvoid RegisterBase::setAccessPolicies(QSharedPointer<QList<QSharedPointer<AccessPolicy> > > newAccessPolicies)\r\n{\r\n    accessPolicies_ = newAccessPolicies;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: RegisterBase::copyParameters()\r\n//-----------------------------------------------------------------------------\r\nvoid RegisterBase::copyParameters(const RegisterBase& other)\r\n{\r\n    for (auto const& parameter : *other.parameters_)\r\n    {\r\n        if (parameter)\r\n        {\r\n            QSharedPointer<Parameter> copy = QSharedPointer<Parameter>(new Parameter(*parameter.data()));\r\n            parameters_->append(copy);\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: RegisterBase::copyAccessPolicies()\r\n//-----------------------------------------------------------------------------\r\nvoid RegisterBase::copyAccessPolicies(const RegisterBase& other)\r\n{\r\n    for (auto const& accessPolicy : *other.accessPolicies_)\r\n    {\r\n        if (accessPolicy)\r\n        {\r\n            auto copy = QSharedPointer<AccessPolicy>(new AccessPolicy(*accessPolicy));\r\n            accessPolicies_->append(copy);\r\n        }\r\n    }\r\n}\r\n"
  },
  {
    "path": "IPXACTmodels/Component/RegisterBase.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: RegisterBase.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 28.09.2015\r\n//\r\n// Description:\r\n// Describes the base class for ipxact:register, ipxact:registerFile and ipxact:alternateRegister.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef REGISTERBASE_H\r\n#define REGISTERBASE_H\r\n\r\n#include <IPXACTmodels/ipxactmodels_global.h>\r\n#include <IPXACTmodels/common/NameGroup.h>\r\n#include <IPXACTmodels/common/Extendable.h>\r\n\r\n#include <QList>\r\n#include <QString>\r\n#include <QSharedPointer>\r\n\r\nclass Parameter;\r\nclass AccessPolicy;\r\nclass MemoryArray;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Describes the base class for ipxact:register, ipxact:registerFile and ipxact:alternateRegister.\r\n//-----------------------------------------------------------------------------\r\nclass IPXACTMODELS_EXPORT RegisterBase : public NameGroup, public Extendable\r\n{\r\n\r\npublic:\r\n\r\n    /*!\r\n     *  The constructor.\r\n     *\r\n     *    @param [in] name    The register name.\r\n     */\r\n    RegisterBase(QString const& name = QString());\r\n    RegisterBase(QString const& name, QString const& addressOffset);\r\n\r\n    //! The copy constructor.\r\n    RegisterBase(const RegisterBase& other);\r\n\r\n\t//! The assignment operator.\r\n    RegisterBase& operator=(const RegisterBase& other);\r\n\r\n\t//! The destructor.\r\n    virtual ~RegisterBase();\r\n\r\n\t/*!\r\n     *  Clone the register model and return pointer to the copy.\r\n\t * \r\n\t *    @return Pointer to the cloned register model.\r\n\t */\r\n    virtual QSharedPointer<RegisterBase> clone() = 0;\r\n\r\n    /*!\r\n     *  Get the presence value.\r\n     *\r\n     *    @return The isPresent value.\r\n     */\r\n    QString getIsPresent() const;\r\n\r\n    /*!\r\n     *  Set the is present value.\r\n     *\r\n     *    @param [in] newIsPresent    The new value for is present.\r\n     */\r\n    void setIsPresent(QString const& newIsPresent);\r\n    /*!\r\n     *  Get the dimension of the register.\r\n     *\r\n     *    @return The first dimension defined for the register.\r\n     */\r\n    QString getDimension() const;\r\n\r\n    /*!\r\n     *  Set the first dimension of the register base.\r\n     *\r\n     *    @param [in] newDimension    The new value for the first dim-element.\r\n     */\r\n    void setDimension(QString const& newDimension);\r\n\r\n    /*!\r\n     *\tGet the register's memory array.\r\n     *\r\n     * \t    @return Pointer to the memory array of the register.\r\n     */\r\n    QSharedPointer<MemoryArray> getMemoryArray() const;\r\n\r\n    /*!\r\n     *\tSet the memory array of the register.\r\n     *\r\n     *    @param [in] newMemArray     Pointer to the memory array to set.\r\n     */\r\n    void setMemoryArray(QSharedPointer<MemoryArray> newMemArray);\r\n\r\n    /*!\r\n     *  Get the address offset of the registerFile.\r\n     *\r\n     *    @return The offset.\r\n     */\r\n    QString getAddressOffset() const;\r\n\r\n    /*!\r\n     *  Set the address offset.\r\n     *\r\n     *    @param [in] newAddressOffset    The new offset.\r\n     */\r\n    void setAddressOffset(QString const& newAddressOffset);\r\n\r\n    /*!\r\n     *  Get the register type identifier.\r\n     *\r\n     *    @return The type identifier of the register.\r\n     */\r\n    QString getTypeIdentifier() const;\r\n\r\n    /*!\r\n     *  Set the register type identifier.\r\n     *\r\n     *    @param [in] newTypeIdentifier   The new register type identifier.\r\n     */\r\n    void setTypeIdentifier(QString const& newTypeIdentifier);\r\n\r\n    /*!\r\n     *  Get the parameters of the register.\r\n     *\r\n     *    @return Pointer to a list containing the parameters.\r\n     */\r\n    QSharedPointer<QList<QSharedPointer<Parameter> > > getParameters() const;\r\n\r\n    /*!\r\n     *  Set the parameters for the register.\r\n     *\r\n     *    @param [in] newParameters   Pointer to a list containing the new parameters\r\n     */\r\n    void setParameters(QSharedPointer<QList<QSharedPointer<Parameter> > > newParameters);\r\n\r\n    /*!\r\n     *\tGet the access policies of the register.\r\n     *  \r\n     * \t    @return Pointer to a list containing the access policies.\r\n     */\r\n    QSharedPointer<QList<QSharedPointer<AccessPolicy> > > getAccessPolicies() const;\r\n\r\n    /*!\r\n     *\tSet the access policies of the register.\r\n     *  \r\n     *    @param [in] newAccessPolicies     The new access policies to set.\r\n     */\r\n    void setAccessPolicies(QSharedPointer<QList<QSharedPointer<AccessPolicy> > > newAccessPolicies);\r\n\r\nprotected:\r\n\r\n    //! Offset from the base address.\r\n    QString addressOffset_;\r\n\r\nprivate:\r\n\r\n    /*!\r\n     *  Copy the parameters.\r\n     *\r\n     *    @param [in] other   The register base class being copied.\r\n     */\r\n    void copyParameters(const RegisterBase& other);\r\n\r\n    /*!\r\n     *  Copy the access policies.\r\n     *\r\n     *    @param [in] other   The register base class being copied.\r\n     */\r\n    void copyAccessPolicies(const RegisterBase& other);\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! The presence value.\r\n    QString isPresent_;\r\n\r\n    //! The type identifier.\r\n    QString typeIdentifier_;\r\n\r\n    //! The memory array.\r\n    QSharedPointer<MemoryArray> memoryArray_;\r\n\r\n\t//! Contains the parameters.\r\n    QSharedPointer<QList<QSharedPointer<Parameter> > > parameters_ = \r\n        QSharedPointer<QList<QSharedPointer<Parameter> > >(new QList<QSharedPointer<Parameter> > ());\r\n\r\n    //! The access policies.\r\n    QSharedPointer<QList<QSharedPointer<AccessPolicy> > > accessPolicies_ =\r\n        QSharedPointer<QList<QSharedPointer<AccessPolicy> > >(new QList<QSharedPointer<AccessPolicy> >());;\r\n};\r\n\r\nQ_DECLARE_METATYPE(QSharedPointer<RegisterBase>);\r\n\r\n#endif // REGISTERBASE_H\r\n"
  },
  {
    "path": "IPXACTmodels/Component/RegisterDefinition.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: RegisterDefinition.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 28.09.2015\r\n//\r\n// Description:\r\n// Describes the base definition for ipxact:register and ipxact:alternateRegister.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"RegisterDefinition.h\"\r\n#include \"Field.h\"\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: RegisterDefinition::RegisterDefinition()\r\n//-----------------------------------------------------------------------------\r\n\r\nRegisterDefinition::RegisterDefinition(QString const& name, QString const& addressOffset) :\r\n  RegisterBase(name, addressOffset),\r\n  volatile_(),\r\n  access_(AccessTypes::ACCESS_COUNT),\r\n  fields_(new QList<QSharedPointer<Field> > ())\r\n{\r\n\r\n}\r\nRegisterDefinition::RegisterDefinition(QString const& name /* = QString() */) :\r\n  RegisterBase(name),\r\n  volatile_(),\r\n  access_(AccessTypes::ACCESS_COUNT),\r\n  fields_(new QList<QSharedPointer<Field> > ())\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: RegisterDefinition::RegisterDefinition()\r\n//-----------------------------------------------------------------------------\r\nRegisterDefinition::RegisterDefinition(const RegisterDefinition& other):\r\nRegisterBase(other),\r\nvolatile_(other.volatile_),\r\naccess_(other.access_),\r\nfields_(new QList<QSharedPointer<Field> > ())\r\n{\r\n    copyFields(other);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: RegisterDefinition::operator=()\r\n//-----------------------------------------------------------------------------\r\nRegisterDefinition& RegisterDefinition::operator=( const RegisterDefinition& other)\r\n{\r\n    if (this != &other)\r\n    {\r\n        RegisterBase::operator=(other);\r\n\r\n        volatile_ = other.volatile_;\r\n        access_ = other.access_;\r\n\r\n        fields_->clear();\r\n        copyFields(other);\r\n    }\r\n\r\n    return *this;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: RegisterDefinition::~RegisterDefinition()\r\n//-----------------------------------------------------------------------------\r\nRegisterDefinition::~RegisterDefinition()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: RegisterDefinition::getVolatile()\r\n//-----------------------------------------------------------------------------\r\nQString RegisterDefinition::getVolatile() const\r\n{\r\n    return volatile_.toString();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: RegisterDefinition::setVolatile()\r\n//-----------------------------------------------------------------------------\r\nvoid RegisterDefinition::setVolatile(bool newVolatile)\r\n{\r\n    volatile_.setValue(newVolatile);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: RegisterDefinition::clearVolatile()\r\n//-----------------------------------------------------------------------------\r\nvoid RegisterDefinition::clearVolatile()\r\n{\r\n    volatile_.setUnspecified();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: RegisterDefinition::getAccess()\r\n//-----------------------------------------------------------------------------\r\nAccessTypes::Access RegisterDefinition::getAccess() const\r\n{\r\n    return access_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: RegisterDefinition::setAccess()\r\n//-----------------------------------------------------------------------------\r\nvoid RegisterDefinition::setAccess(AccessTypes::Access newAccessValue)\r\n{\r\n    access_ = newAccessValue;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: RegisterDefinition::getFields()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<QList<QSharedPointer<Field> > > RegisterDefinition::getFields() const\r\n{\r\n    return fields_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: RegisterDefinition::setFields()\r\n//-----------------------------------------------------------------------------\r\nvoid RegisterDefinition::setFields(QSharedPointer<QList<QSharedPointer<Field> > > newFields)\r\n{\r\n    fields_->clear();\r\n    fields_ = newFields;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: RegisterDefinition::copyFields()\r\n//-----------------------------------------------------------------------------\r\nvoid RegisterDefinition::copyFields(const RegisterDefinition& other)\r\n{\r\n    foreach (QSharedPointer<Field> field, *other.fields_)\r\n    {\r\n        if (field)\r\n        {\r\n            QSharedPointer<Field> copy = QSharedPointer<Field>(new Field(*field.data()));\r\n            fields_->append(copy);\r\n        }\r\n    }\r\n}\r\n"
  },
  {
    "path": "IPXACTmodels/Component/RegisterDefinition.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: RegisterDefinition.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 28.09.2015\r\n//\r\n// Description:\r\n// Describes the base definition for ipxact:register and ipxact:alternateRegister.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef REGISTERDEFINITION_H\r\n#define REGISTERDEFINITION_H\r\n\r\n#include \"RegisterBase.h\"\r\n\r\n#include <IPXACTmodels/common/BooleanValue.h>\r\n\r\n#include <IPXACTmodels/common/AccessTypes.h>\r\n#include <IPXACTmodels/ipxactmodels_global.h>\r\n\r\n#include <QString>\r\n#include <QList>\r\n#include <QSharedPointer>\r\n\r\nclass Field;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Describes the base definition for ipxact:register and ipxact:alternateRegister.\r\n//-----------------------------------------------------------------------------\r\nclass IPXACTMODELS_EXPORT RegisterDefinition : public RegisterBase\r\n{\r\n\r\npublic:\r\n\r\n\t/*!\r\n\t *  The constructor.\r\n\t *\r\n\t *    @param [in] name    Name of the register definition.\r\n\t */\r\n    RegisterDefinition(QString const& name, QString const& addressOffset );\r\n\r\n\tRegisterDefinition(QString const& name = QString());\r\n\r\n\t//! Copy constructor.\r\n\tRegisterDefinition(const RegisterDefinition& other);\r\n\r\n\t//! Assignment operator.\r\n\tRegisterDefinition& operator=(const RegisterDefinition& other);\r\n\r\n\t//! The destructor.\r\n\tvirtual ~RegisterDefinition();\r\n\r\n    /*!\r\n     *  Get the volatile value.\r\n     *\r\n     *    @return The volatile value in string format. Empty string means an unspecified volatility.\r\n     */\r\n    QString getVolatile() const;\r\n\r\n    /*!\r\n     *  Set the volatileValue.\r\n     *\r\n     *    @param [in] newVolatile     The new volatile value.\r\n     */\r\n    void setVolatile(bool newVolatile);\r\n\r\n    /*!\r\n     *  Sets the volatile value to unspecified.\r\n     */\r\n    void clearVolatile();\r\n\r\n\t/*!\r\n     *  Get the access.\r\n\t *\r\n\t *    @return Access value.\r\n\t */\r\n    AccessTypes::Access getAccess() const;\r\n\r\n    /*!\r\n     *  Set the access.\r\n     *\r\n     *    @param [in] access  The new access value.\r\n     */\r\n    void setAccess(AccessTypes::Access newAccessValue);\r\n\r\n\t/*!\r\n     *  Get the list of contained fields.\r\n     *\r\n     *    @return Pointer to a list containing the fields.\r\n     */\r\n    QSharedPointer<QList<QSharedPointer<Field> > > getFields() const;\r\n\r\n    /*!\r\n     *  Set the new fields for the register.\r\n     *\r\n     *    @param [in] fields  Pointer to a list containing the fields.\r\n     */\r\n    void setFields(QSharedPointer<QList<QSharedPointer<Field> > > newFields);\r\n\r\nprivate:\r\n\r\n    /*!\r\n     *  Copy the fields.\r\n     *\r\n     *    @param [in] other   The register definition being copied.\r\n     */\r\n    void copyFields(const RegisterDefinition& other);\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n\t//! Indicates whether the contained data is volatile.\r\n    BooleanValue volatile_;\r\n\r\n\t//! Indicates the accessibility of the data.\r\n    AccessTypes::Access access_;\r\n\r\n\t//! Contains the field-elements.\r\n    QSharedPointer<QList<QSharedPointer<Field> > > fields_;\r\n};\r\n\r\n#endif // REGISTERDEFINITION_H\r\n"
  },
  {
    "path": "IPXACTmodels/Component/RegisterFile.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: RegisterFile.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 28.09.2015\r\n//\r\n// Description:\r\n// Describes the ipxact:registerFile element.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"Register.h\"\r\n#include \"RegisterFile.h\"\r\n\r\n#include <IPXACTmodels/Component/MemoryArray.h>\r\n\r\n#include <QString>\r\n#include <QMap>\r\n#include <QSharedPointer>\r\n#include <QStringList>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: RegisterFile::RegisterFile()\r\n//-----------------------------------------------------------------------------\r\nRegisterFile::RegisterFile(QString const& name, QString const& addressOffset, QString const& range):\r\nRegisterBase(name, addressOffset),\r\nrange_(range),\r\nregisterData_(new QList<QSharedPointer<RegisterBase> > ())\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: RegisterFile::RegisterFile()\r\n//-----------------------------------------------------------------------------\r\nRegisterFile::RegisterFile(const RegisterFile& other):\r\nRegisterBase(other),\r\nrange_(other.range_),\r\nregisterData_(new QList<QSharedPointer<RegisterBase> > ()),\r\nregisterFileDefinitionReference_(other.registerFileDefinitionReference_),\r\ntypeDefinitionsReference_(other.typeDefinitionsReference_)\r\n{\r\n    copyRegisterData(other);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: RegisterFile::operator=()\r\n//-----------------------------------------------------------------------------\r\nRegisterFile& RegisterFile::operator=(const RegisterFile& other)\r\n{\r\n    if (this != &other)\r\n    {\r\n        RegisterBase::operator=(other);\r\n        range_ = other.range_;\r\n        registerData_->clear();\r\n        copyRegisterData(other);\r\n\r\n        registerFileDefinitionReference_ = other.registerFileDefinitionReference_;\r\n        typeDefinitionsReference_ = other.typeDefinitionsReference_;\r\n    }\r\n\r\n    return *this;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: RegisterFile::~RegisterFile()\r\n//-----------------------------------------------------------------------------\r\nRegisterFile::~RegisterFile()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: RegisterFile::clone()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<RegisterBase> RegisterFile::clone()\r\n{\r\n    return QSharedPointer<RegisterBase>(new RegisterFile(*this));\r\n}\r\n\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: RegisterFile::getRange()\r\n//-----------------------------------------------------------------------------\r\nQString RegisterFile::getRange() const\r\n{\r\n    return range_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: RegisterFile::setRange()\r\n//-----------------------------------------------------------------------------\r\nvoid RegisterFile::setRange(QString const& newRange)\r\n{\r\n    range_ = newRange;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: RegisterFile::getRegisterData()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<QList<QSharedPointer<RegisterBase> > > RegisterFile::getRegisterData() const\r\n{\r\n    return registerData_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: RegisterFile::setRegisterData()\r\n//-----------------------------------------------------------------------------\r\nvoid RegisterFile::setRegisterData(QSharedPointer<QList<QSharedPointer<RegisterBase> > > newRegisterData)\r\n{\r\n    registerData_ = newRegisterData;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: RegisterFile::getRegisterFileDefinitionReference()\r\n//-----------------------------------------------------------------------------\r\nQString RegisterFile::getRegisterFileDefinitionReference() const\r\n{\r\n    return registerFileDefinitionReference_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: RegisterFile::setRegisterFileDefinitionReference()\r\n//-----------------------------------------------------------------------------\r\nvoid RegisterFile::setRegisterFileDefinitionReference(QString const& newRegisterFileDefinitionRef)\r\n{\r\n    registerFileDefinitionReference_ = newRegisterFileDefinitionRef;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: RegisterFile::getTypeDefinitionsReference()\r\n//-----------------------------------------------------------------------------\r\nQString RegisterFile::getTypeDefinitionsReference() const\r\n{\r\n    return typeDefinitionsReference_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: RegisterFile::setTypeDefinitionsReference()\r\n//-----------------------------------------------------------------------------\r\nvoid RegisterFile::setTypeDefinitionsReference(QString const& newTypeDefinitionsRef)\r\n{\r\n    typeDefinitionsReference_ = newTypeDefinitionsRef;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: RegisterFile::getAllRegisterOffsets()\r\n//-----------------------------------------------------------------------------\r\nQStringList RegisterFile::getAllRegisterOffsets() const\r\n{\r\n    QStringList registerOffsets;\r\n\r\n    foreach (QSharedPointer<RegisterBase> registerBase, *registerData_)\r\n    {\r\n      registerOffsets.append(registerBase->getAddressOffset());\r\n    }\r\n\r\n    return registerOffsets;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: RegisterFile::copyRegisterData()\r\n//-----------------------------------------------------------------------------\r\nvoid RegisterFile::copyRegisterData(const RegisterFile& other)\r\n{\r\n    foreach (QSharedPointer<RegisterBase> registerBase, *other.registerData_)\r\n    {\r\n        if (registerBase)\r\n        {\r\n            QSharedPointer<RegisterBase> copy = registerBase->clone();\r\n\r\n            registerData_->append(copy);\r\n        }\r\n    }\r\n}\r\n"
  },
  {
    "path": "IPXACTmodels/Component/RegisterFile.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: RegisterFile.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 28.09.2015\r\n//\r\n// Description:\r\n// Describes the ipxact:registerFile element.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef REGISTERFILE_H\r\n#define REGISTERFILE_H\r\n\r\n#include \"RegisterBase.h\"\r\n\r\n#include <IPXACTmodels/ipxactmodels_global.h>\r\n\r\n#include <QString>\r\n#include <QMap>\r\n#include <QSharedPointer>\r\n\r\nclass MemoryArray;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Describes the ipxact:registerFile element.\r\n//-----------------------------------------------------------------------------\r\nclass IPXACTMODELS_EXPORT RegisterFile: public RegisterBase\r\n{\r\n\r\npublic:\r\n\r\n    /*!\r\n     *  The constructor.\r\n     *\r\n     *    @param [in] name            The register file name.\r\n     *    @param [in] addressOffset   The address offset.\r\n     *    @param [in] range           The range of the register file.\r\n     */\r\n    RegisterFile(QString const& name = QString(), QString const& addressOffset = QString(),\r\n        QString const& range = QString());\r\n\r\n\t//! Copy constructor.\r\n\tRegisterFile(const RegisterFile& other);\r\n\r\n\t//! Assignment operator.\r\n\tRegisterFile& operator=(const RegisterFile& other);\r\n\r\n\t//! The destructor.\r\n\tvirtual ~RegisterFile();\r\n\r\n\t/*!\r\n     *  Clone the register file and return pointer to the copy.\r\n\t *\r\n\t *    @return Pointer to the cloned register file.\r\n\t */\r\n    virtual QSharedPointer<RegisterBase> clone();\r\n\r\n\t/*!\r\n     *  Get the range of the registerFile.\r\n\t *\r\n\t *    @return The range of the registerFile.\r\n\t */\r\n    QString getRange() const;\r\n\r\n\t/*!\r\n     *  Set the range of the registerFile.\r\n\t *\r\n\t *    @param [in] newRange    The new range.\r\n\t */\r\n    void setRange(QString const& newRange);\r\n\r\n  QStringList getAllRegisterOffsets() const;\r\n\t/*!\r\n     *  Get the registerData elements of the reigsterFile.\r\n\t *\r\n\t *    @return Pointer to a list containing the register data.\r\n\t */\r\n    QSharedPointer<QList<QSharedPointer<RegisterBase> > > getRegisterData() const;\r\n\r\n\t/*!\r\n     *  Set the registerData for the registerFile.\r\n\t *\r\n\t *    @param [in] newRegisterData     Pointer to a list containing the register data.\r\n\t */\r\n    void setRegisterData(QSharedPointer<QList<QSharedPointer<RegisterBase> > > newRegisterData);\r\n\r\n    /*!\r\n     *\tGet the register file definition reference.\r\n     *\r\n     * \t    @return The reference to a register file definition.\r\n     */\r\n    QString getRegisterFileDefinitionReference() const;\r\n\r\n    /*!\r\n     *\tSet the register file definition reference.\r\n     *\r\n     *    @param [in] registerFileDefinitionRef     The new register file definition reference.\r\n     */\r\n    void setRegisterFileDefinitionReference(QString const& newRegisterFileDefinitionRef);\r\n\r\n    /*!\r\n     *\tGet the reference to the type definitions containing the register file definition reference.\r\n     *\r\n     * \t    @return The reference to the type definitions containing the register file definition.\r\n     */\r\n    QString getTypeDefinitionsReference() const;\r\n\r\n    /*!\r\n     *\tSet the type definitions reference.\r\n     *\r\n     *    @param [in] typeDefinitionsRef     The new type definitions reference to set.\r\n     */\r\n    void setTypeDefinitionsReference(QString const& newTypeDefinitionsRef);\r\n\r\nprivate:\r\n\r\n    /*!\r\n     *  Copy the register data.\r\n     *\r\n     *    @param [in] other   The register file being copied.\r\n     */\r\n    void copyRegisterData(const RegisterFile& other);\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n\t//! The range of a registerFile.\r\n    QString range_;\r\n\r\n\t//! Contains pointers to the register data.\r\n    QSharedPointer<QList<QSharedPointer<RegisterBase> > > registerData_;\r\n\r\n    //! The name of the referenced register file definition.\r\n    QString registerFileDefinitionReference_;\r\n\r\n    //! The type definitions containing the referenced register file definition.\r\n    QString typeDefinitionsReference_;\r\n\r\n};\r\n\r\nQ_DECLARE_METATYPE(QSharedPointer<RegisterFile>);\r\n\r\n#endif // REGISTERFILE_H\r\n"
  },
  {
    "path": "IPXACTmodels/Component/RegisterReader.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: RegisterReader.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 29.09.2015\r\n//\r\n// Description:\r\n// Reader for ipxact:register element.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"RegisterReader.h\"\r\n#include \"RegisterBase.h\"\r\n#include \"Register.h\"\r\n#include \"RegisterDefinition.h\"\r\n#include \"AlternateRegister.h\"\r\n#include \"RegisterFile.h\"\r\n#include \"FieldReader.h\"\r\n#include \"MemoryArrayReader.h\"\r\n#include \"MemoryArray.h\"\r\n#include \"AccessPolicyReader.h\"\r\n\r\n#include <IPXACTmodels/common/NameGroupReader.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: RegisterReader::createRegisterfrom()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<Register> RegisterReader::createRegisterfrom(QDomNode const& registerNode, Document::Revision docRevision)\r\n{\r\n    QDomElement registerElement = registerNode.toElement();\r\n\r\n    QSharedPointer<Register> newRegister(new Register());\r\n\r\n    NameGroupReader::parseNameGroup(registerNode, newRegister);\r\n\r\n    if (docRevision == Document::Revision::Std14)\r\n    {\r\n        Details::parsePresence(registerNode, newRegister);\r\n        \r\n        Details::parseRegisterDimension(registerNode, newRegister);\r\n\r\n        Details::parseAccess(registerNode, newRegister);\r\n    }\r\n    else if (docRevision == Document::Revision::Std22)\r\n    {\r\n        Details::parseRegisterDefinitionReference(registerNode, newRegister);\r\n\r\n        Details::parseRegisterMemoryArray(registerNode, newRegister);\r\n    \r\n        Details::parseAccessPolicies(registerNode, newRegister);\r\n    }\r\n\r\n    newRegister->setAddressOffset(Details::createAddressOffsetFrom(registerNode));\r\n\r\n    Details::parseTypeIdentifier(registerNode, newRegister);\r\n\r\n    Details::parseRegisterSize(registerNode, newRegister);\r\n\r\n    Details::parseVolatile(registerNode, newRegister);\r\n\r\n    Details::parseFields(registerElement, newRegister, docRevision);\r\n\r\n    Details::parseAlternateRegisters(registerElement, newRegister, docRevision);\r\n\r\n    Details::parseParameters(registerNode, newRegister);\r\n\r\n    CommonItemsReader::parseVendorExtensions(registerNode, newRegister);\r\n\r\n    return newRegister;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: RegisterReader::createRegisterFileFrom()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<RegisterFile> RegisterReader::createRegisterFileFrom(QDomNode const& registerFileNode, Document::Revision docRevision)\r\n{\r\n    QSharedPointer<RegisterFile> newRegisterFile (new RegisterFile());\r\n\r\n    NameGroupReader::parseNameGroup(registerFileNode, newRegisterFile);\r\n\r\n    if (docRevision == Document::Revision::Std14)\r\n    {\r\n        Details::parsePresence(registerFileNode, newRegisterFile);\r\n\r\n        Details::parseRegisterFileDimension(registerFileNode, newRegisterFile);\r\n    }\r\n    else if (docRevision == Document::Revision::Std22)\r\n    {\r\n        Details::parseRegisterFileMemoryArray(registerFileNode, newRegisterFile);\r\n\r\n        Details::parseRegisterFileDefinitionReference(registerFileNode, newRegisterFile);\r\n\r\n        Details::parseAccessPolicies(registerFileNode, newRegisterFile);\r\n    }\r\n\r\n    newRegisterFile->setAddressOffset(Details::createAddressOffsetFrom(registerFileNode));\r\n\r\n    Details::parseTypeIdentifier(registerFileNode, newRegisterFile);\r\n\r\n    Details::parseRegisterFileRange(registerFileNode, newRegisterFile);\r\n\r\n    Details::parseRegisterFileRegisterData(registerFileNode, newRegisterFile, docRevision);\r\n\r\n    Details::parseParameters(registerFileNode, newRegisterFile);\r\n\r\n    CommonItemsReader::parseVendorExtensions(registerFileNode, newRegisterFile);\r\n\r\n    return newRegisterFile;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: RegisterReader::Details::parseIsPresent()\r\n//-----------------------------------------------------------------------------\r\nvoid RegisterReader::Details::parsePresence(QDomNode const& registerBaseNode, QSharedPointer<RegisterBase> registerBase)\r\n   \r\n{\r\n    QDomElement isPresentElement = registerBaseNode.firstChildElement(QStringLiteral(\"ipxact:isPresent\"));\r\n    QString isPresent = CommonItemsReader::parseIsPresent(isPresentElement);\r\n\r\n    if (!isPresent.isEmpty())\r\n    {\r\n        registerBase->setIsPresent(isPresent);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: RegisterReader::Details::createAddressOffset()\r\n//-----------------------------------------------------------------------------\r\nQString RegisterReader::Details::createAddressOffsetFrom(QDomNode const& registerBaseNode)\r\n{\r\n    QDomElement addressOffsetElement = registerBaseNode.firstChildElement(QStringLiteral(\"ipxact:addressOffset\"));\r\n    return addressOffsetElement.firstChild().nodeValue();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: RegisterReader::Details::parseRegisterSize()\r\n//-----------------------------------------------------------------------------\r\nvoid RegisterReader::Details::parseRegisterSize(QDomNode const& registerNode, QSharedPointer<Register> selectedRegister)\r\n   \r\n{\r\n    QString registerSize = registerNode.firstChildElement(QStringLiteral(\"ipxact:size\")).firstChild().nodeValue();\r\n    selectedRegister->setSize(registerSize);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: RegisterReader::Details::createRegisterDimension()\r\n//-----------------------------------------------------------------------------\r\nvoid RegisterReader::Details::parseRegisterDimension(QDomNode const& registerNode,\r\n    QSharedPointer<Register> selectedRegister)\r\n{\r\n    auto newMemoryArray = MemoryArrayReader::createMemoryArrayFrom(registerNode, Document::Revision::Std14, false);\r\n\r\n    if (!newMemoryArray->getDimensions()->isEmpty())\r\n    {\r\n        selectedRegister->setMemoryArray(newMemoryArray);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: RegisterReader::Details::parseTypeIdentifier()\r\n//-----------------------------------------------------------------------------\r\nvoid RegisterReader::Details::parseTypeIdentifier(QDomNode const& registerBaseNode,\r\n    QSharedPointer<RegisterBase> registerBase)\r\n{\r\n    QDomElement typeIdentifierElement = registerBaseNode.firstChildElement(QStringLiteral(\"ipxact:typeIdentifier\"));\r\n    if (!typeIdentifierElement.isNull())\r\n    {\r\n        QString typeIdentifier = typeIdentifierElement.firstChild().nodeValue();\r\n        registerBase->setTypeIdentifier(typeIdentifier);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: RegisterReader::Details::parseDefinitionVolatile()\r\n//-----------------------------------------------------------------------------\r\nvoid RegisterReader::Details::parseVolatile(QDomNode const& registerDefinitionNode,\r\n    QSharedPointer<RegisterDefinition> registerDefinition)\r\n{\r\n    QDomElement volatileElement = registerDefinitionNode.firstChildElement(QStringLiteral(\"ipxact:volatile\"));\r\n    if (!volatileElement.isNull())\r\n    {\r\n        QString volatileString = volatileElement.firstChild().nodeValue();\r\n\r\n        if (volatileString == QLatin1String(\"true\"))\r\n        {\r\n            registerDefinition->setVolatile(true);\r\n        }\r\n        else\r\n        {\r\n            registerDefinition->setVolatile(false);\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: RegisterReader::Details::parseAccess()\r\n//-----------------------------------------------------------------------------\r\nvoid RegisterReader::Details::parseAccess(QDomNode const& definitionNode,\r\n    QSharedPointer<RegisterDefinition> registerDefinition)\r\n{\r\n    QDomElement accessElement = definitionNode.firstChildElement(QStringLiteral(\"ipxact:access\"));\r\n    if (!accessElement.isNull())\r\n    {\r\n        QString accessString = accessElement.firstChild().nodeValue();\r\n        AccessTypes::Access access = AccessTypes::str2Access(accessString, AccessTypes::ACCESS_COUNT);\r\n        registerDefinition->setAccess(access);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: RegisterReader::Details::parseFields()\r\n//-----------------------------------------------------------------------------\r\nvoid RegisterReader::Details::parseFields(QDomElement const& registerDefinitionElement,\r\n    QSharedPointer<RegisterDefinition> registerDefinition,\r\n    Document::Revision docRevision)\r\n{\r\n    QDomNodeList fieldNodeList = registerDefinitionElement.childNodes();\r\n\r\n    if (!fieldNodeList.isEmpty())\r\n    {\r\n        for (int fieldIndex = 0; fieldIndex < fieldNodeList.count(); ++fieldIndex)\r\n        {\r\n            if (fieldNodeList.at(fieldIndex).nodeName() == QLatin1String(\"ipxact:field\"))\r\n            {\r\n                QSharedPointer<Field> newField = FieldReader::createFieldFrom(fieldNodeList.at(fieldIndex), docRevision);\r\n                registerDefinition->getFields()->append(newField);\r\n            }\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: RegisterReader::Details::parseAlternateRegisters()\r\n//-----------------------------------------------------------------------------\r\nvoid RegisterReader::Details::parseAlternateRegisters(QDomElement const& registerElement,\r\n    QSharedPointer<Register> targetRegister,\r\n    Document::Revision docRevision)\r\n{\r\n    QDomElement multipleAlternaterRegisterNode = registerElement.firstChildElement(QStringLiteral(\"ipxact:alternateRegisters\"));\r\n    if (!multipleAlternaterRegisterNode.isNull())\r\n    {\r\n        QDomNodeList alternateNodeList =\r\n            multipleAlternaterRegisterNode.elementsByTagName(QStringLiteral(\"ipxact:alternateRegister\"));\r\n\r\n        for (int alternateIndex = 0; alternateIndex < alternateNodeList.count(); ++alternateIndex)\r\n        {\r\n            QSharedPointer<AlternateRegister> newAlternateRegister (new AlternateRegister());\r\n\r\n            parseSingleAlternateRegister(alternateNodeList.at(alternateIndex).toElement(), newAlternateRegister, docRevision);\r\n\r\n            targetRegister->getAlternateRegisters()->append(newAlternateRegister);\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: RegisterReader::Details::parseSingleAlternateRegister()\r\n//-----------------------------------------------------------------------------\r\nvoid RegisterReader::Details::parseSingleAlternateRegister(QDomElement const& alternateRegisterElement,\r\n    QSharedPointer<AlternateRegister> newAlternateRegister,\r\n    Document::Revision docRevision)\r\n{\r\n    NameGroupReader::parseNameGroup(alternateRegisterElement, newAlternateRegister);\r\n\r\n    if (docRevision == Document::Revision::Std14)\r\n    {\r\n        parsePresence(alternateRegisterElement, newAlternateRegister);\r\n\r\n        parseAlternateGroups(alternateRegisterElement, newAlternateRegister);\r\n    \r\n        parseAccess(alternateRegisterElement, newAlternateRegister);\r\n    }\r\n    else if (docRevision == Document::Revision::Std22)\r\n    {\r\n        parseAlternateRegisterModeRefs(alternateRegisterElement, newAlternateRegister);\r\n\r\n        parseAccessPolicies(alternateRegisterElement, newAlternateRegister);\r\n    }\r\n\r\n    parseTypeIdentifier(alternateRegisterElement, newAlternateRegister);\r\n\r\n    parseVolatile(alternateRegisterElement, newAlternateRegister);\r\n\r\n    parseFields(alternateRegisterElement, newAlternateRegister, docRevision);\r\n\r\n    parseParameters(alternateRegisterElement, newAlternateRegister);\r\n\r\n    CommonItemsReader::parseVendorExtensions(alternateRegisterElement, newAlternateRegister);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: RegisterReader::Details::parseAlternateGroups()\r\n//-----------------------------------------------------------------------------\r\nvoid RegisterReader::Details::parseAlternateGroups(QDomElement const& alternateRegisterElement,\r\n    QSharedPointer<AlternateRegister> newAlternateRegister)\r\n{\r\n    QDomElement groupsElement = alternateRegisterElement.firstChildElement(QStringLiteral(\"ipxact:alternateGroups\"));\r\n    if (!groupsElement.isNull())\r\n    {\r\n        QDomNodeList groupNodeList = groupsElement.elementsByTagName(QStringLiteral(\"ipxact:alternateGroup\"));\r\n\r\n        for (int groupIndex = 0; groupIndex < groupNodeList.count(); ++groupIndex)\r\n        {\r\n            QString groupName = groupNodeList.at(groupIndex).firstChild().nodeValue();\r\n\r\n            newAlternateRegister->getAlternateGroups()->append(groupName);\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: RegisterReader::Details::parseParameters()\r\n//-----------------------------------------------------------------------------\r\nvoid RegisterReader::Details::parseParameters(QDomNode const& registerBaseNode,\r\n    QSharedPointer<RegisterBase> newRegisterBase)\r\n{\r\n    QSharedPointer<QList<QSharedPointer<Parameter> > > newParameters = \r\n        CommonItemsReader::parseAndCreateParameters(registerBaseNode);\r\n\r\n    if (!newParameters->isEmpty())\r\n    {\r\n        newRegisterBase->setParameters(newParameters);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: RegisterReader::Details::parseRegisterFileRange()\r\n//-----------------------------------------------------------------------------\r\nvoid RegisterReader::Details::parseRegisterFileRange(QDomNode const& registerFileNode,\r\n    QSharedPointer<RegisterFile> newRegisterFile)\r\n{\r\n    QDomElement rangeElement = registerFileNode.firstChildElement(QStringLiteral(\"ipxact:range\"));\r\n    if (!rangeElement.isNull())\r\n    {\r\n        QString range = rangeElement.firstChild().nodeValue();\r\n        newRegisterFile->setRange(range);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: RegisterReader::Details::parseRegisterFileDimension()\r\n//-----------------------------------------------------------------------------\r\nvoid RegisterReader::Details::parseRegisterFileDimension(QDomNode const& registerFileNode,\r\n    QSharedPointer<RegisterFile> newRegisterFile)\r\n{\r\n    QDomElement dimensionElement = registerFileNode.firstChildElement(QStringLiteral(\"ipxact:dim\"));\r\n    if (!dimensionElement.isNull())\r\n    {\r\n        QString dimension = dimensionElement.firstChild().nodeValue();\r\n        newRegisterFile->setDimension(dimension);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: RegisterReader::Details::parseRegisterFileRegisterData()\r\n//-----------------------------------------------------------------------------\r\nvoid RegisterReader::Details::parseRegisterFileRegisterData(QDomNode const& registerFileNode,\r\n    QSharedPointer<RegisterFile> newRegisterFile,\r\n    Document::Revision docRevision)\r\n{\r\n    QDomNodeList childNodeList = registerFileNode.childNodes();\r\n\r\n    for (int i = 0; i < childNodeList.count(); ++i)\r\n    {\r\n        if (childNodeList.at(i).nodeName() == QStringLiteral(\"ipxact:register\"))\r\n        {\r\n            QSharedPointer<Register> newRegister = createRegisterfrom(childNodeList.at(i), docRevision);\r\n            newRegisterFile->getRegisterData()->append(newRegister);\r\n        }\r\n\r\n        else if (childNodeList.at(i).nodeName() == QStringLiteral(\"ipxact:registerFile\"))\r\n        {\r\n            QSharedPointer<RegisterFile> containedRegisterFile = createRegisterFileFrom(childNodeList.at(i), docRevision);\r\n            newRegisterFile->getRegisterData()->append(containedRegisterFile);\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: RegisterReader::Details::parseRegisterDefinitionReference()\r\n//-----------------------------------------------------------------------------\r\nvoid RegisterReader::Details::parseRegisterDefinitionReference(QDomNode const& registerNode,\r\n    QSharedPointer<Register> newRegister)\r\n{\r\n    auto registerDefinitionReferenceElement = registerNode.firstChildElement(QStringLiteral(\"ipxact:registerDefinitionRef\"));\r\n\r\n    if (!registerDefinitionReferenceElement.isNull())\r\n    {\r\n        newRegister->setRegisterDefinitionReference(registerDefinitionReferenceElement.firstChild().nodeValue());\r\n\r\n        newRegister->setTypeDefinitionsReference(\r\n            registerDefinitionReferenceElement.attribute(QStringLiteral(\"typeDefinitions\")));\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: RegisterReader::Details::parseRegisterMemoryArray()\r\n//-----------------------------------------------------------------------------\r\nvoid RegisterReader::Details::parseRegisterMemoryArray(QDomNode const& registerNode, QSharedPointer<Register> newRegister)\r\n{\r\n    auto memArrayElement = registerNode.firstChildElement(QStringLiteral(\"ipxact:array\"));\r\n\r\n    if (!memArrayElement.isNull())\r\n    {\r\n        auto newMemoryArray = MemoryArrayReader::createMemoryArrayFrom(memArrayElement, Document::Revision::Std22, false);\r\n\r\n        newRegister->setMemoryArray(newMemoryArray);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: RegisterReader::Details::parseRegisterFileMemoryArray()\r\n//-----------------------------------------------------------------------------\r\nvoid RegisterReader::Details::parseRegisterFileMemoryArray(QDomNode const& registerFileNode, QSharedPointer<RegisterFile> newRegisterFile)\r\n{\r\n    auto memArrayElement = registerFileNode.firstChildElement(QStringLiteral(\"ipxact:array\"));\r\n\r\n    if (!memArrayElement.isNull())\r\n    {\r\n        auto newMemoryArray = MemoryArrayReader::createMemoryArrayFrom(memArrayElement, Document::Revision::Std22, false);\r\n\r\n        newRegisterFile->setMemoryArray(newMemoryArray);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: RegisterReader::Details::parseRegisterFileDefinitionReference()\r\n//-----------------------------------------------------------------------------\r\nvoid RegisterReader::Details::parseRegisterFileDefinitionReference(QDomNode const& registerFileNode, QSharedPointer<RegisterFile> newRegisterFile)\r\n{\r\n    auto registerDefinitionReferenceElement = registerFileNode.firstChildElement(QStringLiteral(\"ipxact:registerFileDefinitionRef\"));\r\n\r\n    if (!registerDefinitionReferenceElement.isNull())\r\n    {\r\n        newRegisterFile->setRegisterFileDefinitionReference(registerDefinitionReferenceElement.firstChild().nodeValue());\r\n\r\n        newRegisterFile->setTypeDefinitionsReference(\r\n            registerDefinitionReferenceElement.attribute(QStringLiteral(\"typeDefinitions\")));\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: RegisterReader::Details::parseAccessPolicies()\r\n//-----------------------------------------------------------------------------\r\nvoid RegisterReader::Details::parseAccessPolicies(QDomNode const& registerBaseNode, QSharedPointer<RegisterBase> newRegisterBase)\r\n{\r\n    auto accessPoliciesElement = registerBaseNode.firstChildElement(QStringLiteral(\"ipxact:accessPolicies\"));\r\n\r\n    if (accessPoliciesElement.isNull())\r\n    {\r\n        return;\r\n    }\r\n\r\n    auto accessPolicies = accessPoliciesElement.childNodes();\r\n\r\n    for (int i = 0; i < accessPolicies.size(); ++i)\r\n    {\r\n        if (accessPolicies.at(i).nodeName() == QStringLiteral(\"ipxact:accessPolicy\"))\r\n        {\r\n            auto newAccessPolicy = AccessPolicyReader::createAccessPolicyFrom(accessPolicies.at(i));\r\n\r\n            newRegisterBase->getAccessPolicies()->append(newAccessPolicy);\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: RegisterReader::Details::parseAlternateRegisterModeRefs()\r\n//-----------------------------------------------------------------------------\r\nvoid RegisterReader::Details::parseAlternateRegisterModeRefs(QDomNode const& alternateRegisterNode, QSharedPointer<AlternateRegister> newAlternateRegister)\r\n{\r\n    newAlternateRegister->setModeReferences(CommonItemsReader::parseModeReferences(alternateRegisterNode));\r\n}\r\n"
  },
  {
    "path": "IPXACTmodels/Component/RegisterReader.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: RegisterReader.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 29.09.2015\r\n//\r\n// Description:\r\n// Reader for ipxact:register element.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef REGISTERREADER_H\r\n#define REGISTERREADER_H\r\n\r\n#include <IPXACTmodels/ipxactmodels_global.h>\r\n\r\n#include <IPXACTmodels/common/CommonItemsReader.h>\r\n\r\n#include <QSharedPointer>\r\n#include <QDomNode>\r\n\r\nclass RegisterBase;\r\nclass Register;\r\nclass RegisterDefinition;\r\nclass AlternateRegister;\r\nclass RegisterFile;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Reader for ipxact:register element.\r\n//-----------------------------------------------------------------------------\r\nnamespace RegisterReader\r\n{\r\n    /*!\r\n     *  Creates a new register from a given register node.\r\n     *\r\n     *    @param [in] registerNode    XML description of the register.\r\n     *\r\n     *    @return The created register.\r\n     */\r\n    IPXACTMODELS_EXPORT QSharedPointer<Register> createRegisterfrom(QDomNode const& registerNode, Document::Revision docRevision);\r\n\r\n    /*!\r\n     *  Creates a new register file from a given register file node.\r\n     *\r\n     *    @param [in] registerFileNode    XML description fo the register file.\r\n     *\r\n     *    @return The created register file.\r\n     */\r\n    IPXACTMODELS_EXPORT QSharedPointer<RegisterFile> createRegisterFileFrom(QDomNode const& registerFileNode, Document::Revision docRevision);\r\n\r\n    namespace Details\r\n    {\r\n\r\n        /*!\r\n         *  Create address offset from a given register base node.\r\n         *\r\n         *    @param [in] registerBaseNode    XML description of the register base.\r\n         *\r\n         *    @return The parsed address offset.\r\n         */\r\n        QString createAddressOffsetFrom(QDomNode const& registerBaseNode);\r\n\r\n        /*!\r\n         *  Reads the register size.\r\n         *\r\n         *    @param [in] registerNode        XML description of the register.\r\n         *    @param [in] selectedRegister    The selected register.\r\n         */\r\n        void parseRegisterSize(QDomNode const& registerNode, QSharedPointer<Register> selectedRegister);\r\n\r\n        /*!\r\n         *  Reads the is present value.\r\n         *\r\n         *    @param [in] registerBaseNode    XML description of the register base.\r\n         *    @param [in] registerBase        Selected register base.\r\n         */\r\n        void parsePresence(QDomNode const& registerBaseNode, QSharedPointer<RegisterBase> registerBase);\r\n\r\n        /*!\r\n         *  Reads the register dimension.\r\n         *\r\n         *    @param [in] registerNode        XML description of the register.\r\n         *    @param [in] selectedRegister    Selected register.\r\n         */\r\n        void parseRegisterDimension(QDomNode const& registerNode, QSharedPointer<Register> selectedRegister);\r\n\r\n        /*!\r\n         *  Reads the type identifier.\r\n         *\r\n         *    @param [in] registerBaseNode    XML description of the register base.\r\n         *    @param [in] registerBase        Selected register base.\r\n         */\r\n        void parseTypeIdentifier(QDomNode const& registerBaseNode, QSharedPointer<RegisterBase> registerBase);\r\n\r\n        /*!\r\n         *  Reads the volatile value.\r\n         *\r\n         *    @param [in] registerDefinitionNode  XML description of the register definition.\r\n         *    @param [in] registerDefinition      Selected register definition.\r\n         */\r\n        void parseVolatile(QDomNode const& registerDefinitionNode,\r\n            QSharedPointer<RegisterDefinition> registerDefinition);\r\n\r\n        /*!\r\n         *  Reads the access value.\r\n         *\r\n         *    @param [in] registerDefinitionNode  XML description of the register definition.\r\n         *    @param [in] registerDefinition      Selected register definition.\r\n         */\r\n        void parseAccess(QDomNode const& definitionNode, QSharedPointer<RegisterDefinition> registerDefinition);\r\n\r\n        /*!\r\n         *  Reads the fields.\r\n         *\r\n         *    @param [in] registerDefinitionElement   XML description of the register definition.\r\n         *    @param [in] registerDefinition          Selected register definition.\r\n         */\r\n        void parseFields(QDomElement const& registerDefinitionElement,\r\n            QSharedPointer<RegisterDefinition> registerDefinition,\r\n            Document::Revision docRevision);\r\n\r\n        /*!\r\n         *  Reads the alternate registers.\r\n         *\r\n         *    @param [in] registerElement     XML description of the register.\r\n         *    @param [in] targetRegister      Selected register.\r\n         */\r\n        void parseAlternateRegisters(QDomElement const& registerElement, QSharedPointer<Register> targetRegister, Document::Revision docRevision);\r\n\r\n        /*!\r\n         *  Reads a single alternate register.\r\n         *\r\n         *    @param [in] alternateRegisterElement    XML description of the alternate register.\r\n         *    @param [in] newAlternateRegister        Selected alternate register.\r\n         */\r\n        void parseSingleAlternateRegister(QDomElement const& alternateRegisterElement,\r\n            QSharedPointer<AlternateRegister> newAlternateRegister,\r\n            Document::Revision docRevision);\r\n\r\n        /*!\r\n         *  Reads alternate register alternate groups.\r\n         *\r\n         *    @param [in] alternateRegisterElement    XML description of the alternate register.\r\n         *    @param [in] newAlternateRegister        Selected alternate register.\r\n         */\r\n        void parseAlternateGroups(QDomElement const& alternateRegisterElement,\r\n            QSharedPointer<AlternateRegister> newAlternateRegister);\r\n\r\n        /*!\r\n         *  Reads the parameters.\r\n         *\r\n         *    @param [in] registerBaseNode    XML description of the register base.\r\n         *    @param [in] newRegisterBase     Selected register base.\r\n         */\r\n        void parseParameters(QDomNode const& registerBaseNode, QSharedPointer<RegisterBase> newRegisterBase);\r\n\r\n        /*!\r\n         *  Reads the register file range.\r\n         *\r\n         *    @param [in] registerFileNode    XML description of the register file.\r\n         *    @param [in] newRegisterFile     Selected register file.\r\n         */\r\n        void parseRegisterFileRange(QDomNode const& registerFileNode, QSharedPointer<RegisterFile> newRegisterFile)\r\n           ;\r\n\r\n        /*!\r\n         *  Reads the register file dimension.\r\n         *\r\n         *    @param [in] registerFileNode    XML description of the register file.\r\n         *    @param [in] newRegisterFile     Selected register file.\r\n         */\r\n        void parseRegisterFileDimension(QDomNode const& registerFileNode,\r\n            QSharedPointer<RegisterFile> newRegisterFile);\r\n\r\n        /*!\r\n         *  Reads the contained register data of a register file.\r\n         *\r\n         *    @param [in] registerFileNode    XML description of the register file.\r\n         *    @param [in] newRegisterFile     Selected register file.\r\n         */\r\n        void parseRegisterFileRegisterData(QDomNode const& registerFileNode,\r\n            QSharedPointer<RegisterFile> newRegisterFile,\r\n            Document::Revision docRevision);\r\n\r\n        /*!\r\n         *\tReads the register definition refernece of a register.\r\n         *  \r\n         *    @param [in] registerNode     XML description of the register.\r\n         *    @param [in] newRegister      The selected register.\r\n         */\r\n        void parseRegisterDefinitionReference(QDomNode const& registerNode,\r\n            QSharedPointer<Register> newRegister);\r\n\r\n        /*!\r\n         *\tReads the memory array of a register.\r\n         *  \r\n         *    @param [in] registerNode     XML description of the register.\r\n         *    @param [in] newRegister      The selected register.\r\n         */\r\n        void parseRegisterMemoryArray(QDomNode const& registereNode, QSharedPointer<Register> newRegister);\r\n\r\n        /*!\r\n         *\tReads the memory array of a register file.\r\n         *  \r\n         *    @param [in] registerFileNode     XML description of the register file.\r\n         *    @param [in] newRegisterFile      The selected register file.\r\n         */\r\n        void parseRegisterFileMemoryArray(QDomNode const& registerFileNode, QSharedPointer<RegisterFile> newRegisterFile);\r\n        \r\n        /*!\r\n         *\tReads the definition reference of a register file.\r\n         *  \r\n         *    @param [in] registerFileNode     XML description of the register file.\r\n         *    @param [in] newRegisterFile      The selected register file.\r\n         */\r\n        void parseRegisterFileDefinitionReference(QDomNode const& registerFileNode,\r\n            QSharedPointer<RegisterFile> newRegisterFile);\r\n\r\n        /*!\r\n         *\tReads the access policies for a register, register file or alternate register.\r\n         *  \r\n         *    @param [in] registerBaseNode    XML description of the register base.\r\n         *    @param [in] newRegisterBase     Selected register base.\r\n         */\r\n        void parseAccessPolicies(QDomNode const& registerBaseNode, QSharedPointer<RegisterBase> newRegisterBase);\r\n\r\n        /*!\r\n         *\tReads the mode references of an alternate register.\r\n         *  \r\n         *    @param [in] alternateRegisterNode       XML description of the alternate register.\r\n         *    @param [in] newAlternateRegister        Selected alternate register.\r\n         */\r\n        void parseAlternateRegisterModeRefs(QDomNode const& alternateRegisterNode, QSharedPointer<AlternateRegister> newAlternateRegister);\r\n    }\r\n}\r\n\r\n#endif // REGISTERREADER_H"
  },
  {
    "path": "IPXACTmodels/Component/RegisterWriter.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: RegisterWriter.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 28.09.2015\r\n//\r\n// Description:\r\n// Writer for IP-XACT register element.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"RegisterWriter.h\"\r\n#include \"Register.h\"\r\n#include \"RegisterFile.h\"\r\n#include \"RegisterBase.h\"\r\n#include \"AlternateRegister.h\"\r\n#include \"FieldWriter.h\"\r\n#include \"AccessPolicyWriter.h\"\r\n#include \"MemoryArrayWriter.h\"\r\n#include \"MemoryArray.h\"\r\n\r\n#include <IPXACTmodels/common/NameGroupWriter.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: RegisterWriter::writeRegisterData()\r\n//-----------------------------------------------------------------------------\r\nvoid RegisterWriter::writeRegisterData(QXmlStreamWriter& writer, QSharedPointer<RegisterBase> registerData, Document::Revision docRevision)\r\n{\r\n    QSharedPointer<Register> targetRegister = registerData.dynamicCast<Register>();\r\n    QSharedPointer<RegisterFile> registerFile = registerData.dynamicCast<RegisterFile>();\r\n\r\n    if (targetRegister)\r\n    {\r\n        Details::writeRegister(writer, targetRegister, docRevision);\r\n    }\r\n    else if (registerFile)\r\n    {\r\n        Details::writeRegisterFile(writer, registerFile, docRevision);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: RegisterWriter::Details::writeRegister()\r\n//-----------------------------------------------------------------------------\r\nvoid RegisterWriter::Details::writeRegister(QXmlStreamWriter& writer, QSharedPointer<Register> targetRegister, Document::Revision docRevision)\r\n{\r\n    writer.writeStartElement(QStringLiteral(\"ipxact:register\"));\r\n\r\n    NameGroupWriter::writeNameGroup(writer, targetRegister, docRevision);\r\n    \r\n    if (docRevision == Document::Revision::Std14)\r\n    {\r\n        CommonItemsWriter::writeIsPresent(writer, targetRegister->getIsPresent());\r\n\r\n        // Write dimensions\r\n        MemoryArrayWriter::writeMemoryArray(writer, targetRegister->getMemoryArray(), docRevision, false);\r\n\r\n        writeAddressOffset(writer, targetRegister->getAddressOffset());\r\n\r\n        writeTypeIdentifier(writer, targetRegister);\r\n\r\n        writer.writeTextElement(QStringLiteral(\"ipxact:size\"), targetRegister->getSize());\r\n        \r\n        writeVolatile(writer, targetRegister);\r\n\r\n        writeAccess(writer, targetRegister);\r\n    }\r\n    else if (docRevision == Document::Revision::Std22)\r\n    {\r\n        MemoryArrayWriter::writeMemoryArray(writer, targetRegister->getMemoryArray(), docRevision, false);\r\n\r\n        writeAddressOffset(writer, targetRegister->getAddressOffset());\r\n\r\n        writeRegisterDefinitionReference(writer, targetRegister);\r\n\r\n        writeTypeIdentifier(writer, targetRegister);\r\n\r\n\r\n        if (auto const& regSize = targetRegister->getSize(); regSize.isEmpty() == false)\r\n        {\r\n            writer.writeTextElement(QStringLiteral(\"ipxact:size\"), targetRegister->getSize());\r\n        }\r\n\r\n        writeVolatile(writer, targetRegister);\r\n\r\n        writeAccessPolicies(writer, targetRegister);\r\n    }\r\n\r\n    writeFields(writer, targetRegister, docRevision);\r\n\r\n    writeAlternateRegisters(writer, targetRegister, docRevision);\r\n\r\n    CommonItemsWriter::writeParameters(writer, targetRegister->getParameters());\r\n\r\n    CommonItemsWriter::writeVendorExtensions(writer, targetRegister);\r\n\r\n    writer.writeEndElement(); // ipxact:register\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: RegisterWriter::Details::writeAddressOffset()\r\n//-----------------------------------------------------------------------------\r\nvoid RegisterWriter::Details::writeAddressOffset(QXmlStreamWriter& writer, QString const& addressOffset)\r\n{\r\n    writer.writeTextElement(QStringLiteral(\"ipxact:addressOffset\"), addressOffset);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: RegisterWriter::Details::writeTypeIdentifier()\r\n//-----------------------------------------------------------------------------\r\nvoid RegisterWriter::Details::writeTypeIdentifier(QXmlStreamWriter& writer, QSharedPointer<RegisterBase> registerData)\r\n{\r\n    if (!registerData->getTypeIdentifier().isEmpty())\r\n    {\r\n        writer.writeTextElement(QStringLiteral(\"ipxact:typeIdentifier\"), registerData->getTypeIdentifier());\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: RegisterWriter::Details::writeVolatile()\r\n//-----------------------------------------------------------------------------\r\nvoid RegisterWriter::Details::writeVolatile(QXmlStreamWriter& writer, QSharedPointer<RegisterDefinition> registerDefinition)\r\n   \r\n{\r\n    if (!registerDefinition->getVolatile().isEmpty())\r\n    {\r\n        writer.writeTextElement(QStringLiteral(\"ipxact:volatile\"), registerDefinition->getVolatile());\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: RegisterWriter::Details::writeAccess()\r\n//-----------------------------------------------------------------------------\r\nvoid RegisterWriter::Details::writeAccess(QXmlStreamWriter& writer, QSharedPointer<RegisterDefinition> registerDefinition)\r\n   \r\n{\r\n    if (registerDefinition->getAccess() != AccessTypes::ACCESS_COUNT)\r\n    {\r\n        QString accessString = AccessTypes::access2Str(registerDefinition->getAccess());\r\n        writer.writeTextElement(QStringLiteral(\"ipxact:access\"), accessString);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: RegisterWriter::Details::writeFields()\r\n//-----------------------------------------------------------------------------\r\nvoid RegisterWriter::Details::writeFields(QXmlStreamWriter& writer, QSharedPointer<RegisterDefinition> registerDefinition, Document::Revision docRevision)\r\n{\r\n    for (auto const& field : *registerDefinition->getFields())\r\n    {\r\n        FieldWriter::writeField(writer, field, docRevision);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: RegisterWriter::Details::writeAlternateRegisters()\r\n//-----------------------------------------------------------------------------\r\nvoid RegisterWriter::Details::writeAlternateRegisters(QXmlStreamWriter& writer, QSharedPointer<Register> targetRegister, Document::Revision docRevision)\r\n{\r\n    if (!targetRegister->getAlternateRegisters()->isEmpty())\r\n    {\r\n        writer.writeStartElement(QStringLiteral(\"ipxact:alternateRegisters\"));\r\n\r\n        for (auto const& alternateRegister : *targetRegister->getAlternateRegisters())\r\n        {\r\n            writeSingleAlternateRegister(writer, alternateRegister, docRevision);\r\n        }\r\n\r\n        writer.writeEndElement(); // ipxact:alternateRegisters\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: RegisterWriter::Details::writeSingleAlternateRegister()\r\n//-----------------------------------------------------------------------------\r\nvoid RegisterWriter::Details::writeSingleAlternateRegister(QXmlStreamWriter& writer,\r\n    QSharedPointer<AlternateRegister> alternateRegister,\r\n    Document::Revision docRevision)\r\n{\r\n    writer.writeStartElement(QStringLiteral(\"ipxact:alternateRegister\"));\r\n\r\n    NameGroupWriter::writeNameGroup(writer, alternateRegister, docRevision);\r\n\r\n    if (docRevision == Document::Revision::Std14)\r\n    {\r\n        CommonItemsWriter::writeIsPresent(writer, alternateRegister->getIsPresent());\r\n\r\n        writeAlternateGroups(writer, alternateRegister);\r\n    }\r\n    else if (docRevision == Document::Revision::Std22)\r\n    {\r\n        CommonItemsWriter::writeModeReferences(writer, alternateRegister->getModeReferences());\r\n    }\r\n\r\n    writeTypeIdentifier(writer, alternateRegister);\r\n\r\n    writeVolatile(writer, alternateRegister);\r\n\r\n    if (docRevision == Document::Revision::Std14)\r\n    {\r\n        writeAccess(writer, alternateRegister);\r\n    }\r\n    else if (docRevision == Document::Revision::Std22)\r\n    {\r\n        writeAccessPolicies(writer, alternateRegister);\r\n    }\r\n\r\n    writeFields(writer, alternateRegister, docRevision);\r\n\r\n    CommonItemsWriter::writeParameters(writer, alternateRegister->getParameters());\r\n\r\n    CommonItemsWriter::writeVendorExtensions(writer, alternateRegister);\r\n\r\n    writer.writeEndElement(); // ipxact:alternateRegister\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: RegisterWriter::Details::writeAlternateGroups()\r\n//-----------------------------------------------------------------------------\r\nvoid RegisterWriter::Details::writeAlternateGroups(QXmlStreamWriter& writer,\r\n    QSharedPointer<AlternateRegister> alternateRegister)\r\n{\r\n    writer.writeStartElement(QStringLiteral(\"ipxact:alternateGroups\"));\r\n\r\n    for (auto const& groupName : *alternateRegister->getAlternateGroups())\r\n    {\r\n        writer.writeTextElement(QStringLiteral(\"ipxact:alternateGroup\"), groupName);\r\n    }\r\n\r\n    writer.writeEndElement(); // ipxact:alternateGroups\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: RegisterWriter::Details::writeRegisterFile()\r\n//-----------------------------------------------------------------------------\r\nvoid RegisterWriter::Details::writeRegisterFile(QXmlStreamWriter& writer, QSharedPointer<RegisterFile> registerFile, Document::Revision docRevision)\r\n{\r\n    writer.writeStartElement(QStringLiteral(\"ipxact:registerFile\"));\r\n\r\n    NameGroupWriter::writeNameGroup(writer, registerFile, docRevision);\r\n    if (docRevision == Document::Revision::Std14)\r\n    {\r\n        CommonItemsWriter::writeIsPresent(writer, registerFile->getIsPresent());\r\n\r\n        MemoryArrayWriter::writeMemoryArray(writer, registerFile->getMemoryArray(), docRevision, false);\r\n\r\n        writeAddressOffset(writer, registerFile->getAddressOffset());\r\n\r\n        writeTypeIdentifier(writer, registerFile);\r\n\r\n        writer.writeTextElement(QStringLiteral(\"ipxact:range\"), registerFile->getRange());\r\n    }\r\n    else if (docRevision == Document::Revision::Std22)\r\n    {\r\n        MemoryArrayWriter::writeMemoryArray(writer, registerFile->getMemoryArray(), docRevision, false);\r\n\r\n        writeAddressOffset(writer, registerFile->getAddressOffset());\r\n\r\n        writeRegisterFileDefinitionReference(writer, registerFile);\r\n\r\n        writeTypeIdentifier(writer, registerFile);\r\n\r\n        if (auto const& range = registerFile->getRange(); range.isEmpty() == false)\r\n        {\r\n            writer.writeTextElement(QStringLiteral(\"ipxact:range\"), registerFile->getRange());\r\n        }\r\n\r\n        writeAccessPolicies(writer, registerFile);\r\n    }\r\n\r\n    writeRegisterFileRegisterData(writer, registerFile, docRevision);\r\n\r\n    CommonItemsWriter::writeParameters(writer, registerFile->getParameters());\r\n\r\n    CommonItemsWriter::writeVendorExtensions(writer, registerFile);\r\n\r\n    writer.writeEndElement(); // ipxact:registerFile\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: RegisterWriter::Details::writeRegisterFileRegisterData()\r\n//-----------------------------------------------------------------------------\r\nvoid RegisterWriter::Details::writeRegisterFileRegisterData(QXmlStreamWriter& writer,\r\n    QSharedPointer<RegisterFile> registerFile,\r\n    Document::Revision docRevision)\r\n{\r\n    for (auto const& registerData : *registerFile->getRegisterData())\r\n    {\r\n        writeRegisterData(writer, registerData, docRevision);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: RegisterWriter::Details::writeAccessPolicies()\r\n//-----------------------------------------------------------------------------\r\nvoid RegisterWriter::Details::writeAccessPolicies(QXmlStreamWriter& writer, \r\n    QSharedPointer<RegisterBase> targetRegisterBase)\r\n{\r\n    if (auto accessPolicies = targetRegisterBase->getAccessPolicies();\r\n        accessPolicies->isEmpty() == false)\r\n    {\r\n        writer.writeStartElement(QStringLiteral(\"ipxact:accessPolicies\"));\r\n\r\n        for (auto const& accessPolicy : *targetRegisterBase->getAccessPolicies())\r\n        {\r\n            AccessPolicyWriter::writeAccessPolicy(writer, accessPolicy);\r\n        }\r\n\r\n        writer.writeEndElement(); // ipxact:accessPolicies\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: RegisterWriter::Details::writeRegisterDefinitionReference()\r\n//-----------------------------------------------------------------------------\r\nvoid RegisterWriter::Details::writeRegisterDefinitionReference(QXmlStreamWriter& writer, QSharedPointer<Register> targetRegister)\r\n{\r\n    if (auto const& definitionReference = targetRegister->getRegisterDefinitionReference();\r\n        definitionReference.isEmpty() == false)\r\n    {\r\n        writer.writeStartElement(QStringLiteral(\"ipxact:registerDefinitionRef\"));\r\n\r\n        if (auto const& typeDefinitionsRef = targetRegister->getTypeDefinitionsReference();\r\n            typeDefinitionsRef.isEmpty() == false)\r\n        {\r\n            writer.writeAttribute(QStringLiteral(\"typeDefinitions\"), typeDefinitionsRef);\r\n        }\r\n\r\n        writer.writeCharacters(definitionReference);\r\n        writer.writeEndElement();\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: RegisterWriter::Details::writeRegisterFileDefinitionReference()\r\n//-----------------------------------------------------------------------------\r\nvoid RegisterWriter::Details::writeRegisterFileDefinitionReference(QXmlStreamWriter& writer, QSharedPointer<RegisterFile> registerFile)\r\n{\r\n    if (auto const& definitionReference = registerFile->getRegisterFileDefinitionReference();\r\n        definitionReference.isEmpty() == false)\r\n    {\r\n        writer.writeStartElement(QStringLiteral(\"ipxact:registerFileDefinitionRef\"));\r\n\r\n        if (auto const& typeDefinitionsRef = registerFile->getTypeDefinitionsReference();\r\n            typeDefinitionsRef.isEmpty() == false)\r\n        {\r\n            writer.writeAttribute(QStringLiteral(\"typeDefinitions\"), typeDefinitionsRef);\r\n        }\r\n\r\n        writer.writeCharacters(definitionReference);\r\n        writer.writeEndElement();\r\n    }\r\n}\r\n"
  },
  {
    "path": "IPXACTmodels/Component/RegisterWriter.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: RegisterWriter.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 28.09.2015\r\n//\r\n// Description:\r\n// Writer for IP-XACT register element.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef REGISTERWRITER_H\r\n#define REGISTERWRITER_H\r\n\r\n#include <IPXACTmodels/ipxactmodels_global.h>\r\n#include <IPXACTmodels/common/CommonItemsWriter.h>\r\n\r\n#include <QXmlStreamWriter>\r\n#include <QSharedPointer>\r\n\r\nclass Register;\r\nclass RegisterFile;\r\nclass RegisterBase;\r\nclass RegisterDefinition;\r\nclass AlternateRegister;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Writer for IP-XACT register element.\r\n//-----------------------------------------------------------------------------\r\nnamespace RegisterWriter\r\n{\r\n\r\n    /*!\r\n     *  Write a register or a register file to an XML file.\r\n     *\r\n     *    @param [in] writer          The used XML writer.\r\n     *    @param [in] registerData    The register data to be written.\r\n     */\r\n    IPXACTMODELS_EXPORT void writeRegisterData(QXmlStreamWriter& writer, QSharedPointer<RegisterBase> registerData, Document::Revision docRevision);\r\n\r\n    namespace Details\r\n    {\r\n        /*!\r\n         *  Write a register.\r\n         *\r\n         *    @param [in] writer          The used XML writer.\r\n         *    @param [in] targetRegister  The selected register.\r\n         */\r\n        void writeRegister(QXmlStreamWriter& writer, QSharedPointer<Register> targetRegister, Document::Revision docRevision);\r\n\r\n        /*!\r\n         *  Write the address offset.\r\n         *\r\n         *    @param [in] writer          Used XML writer.\r\n         *    @param [in] addressOffset   Address offset to be written.\r\n         */\r\n        void writeAddressOffset(QXmlStreamWriter& writer, QString const& addressOffset);\r\n\r\n        /*!\r\n         *  Write the type identifier.\r\n         *\r\n         *    @param [in] writer          Used XML writer.\r\n         *    @param [in] registerData    Register data containing the type identifier.\r\n         */\r\n        void writeTypeIdentifier(QXmlStreamWriter& writer, QSharedPointer<RegisterBase> registerData);\r\n\r\n        /*!\r\n         *  Write the volatile value.\r\n         *\r\n         *    @param [in] writer              Used XML writer.\r\n         *    @param [in] registerDefinition  The selected register definition.\r\n         */\r\n        void writeVolatile(QXmlStreamWriter& writer, QSharedPointer<RegisterDefinition> registerDefinition);\r\n\r\n        /*!\r\n         *  Write the access value.\r\n         *\r\n         *    @param [in] writer              Used XML writer.\r\n         *    @param [in] registerDefinition  The selected register definition.\r\n         */\r\n        void writeAccess(QXmlStreamWriter& writer, QSharedPointer<RegisterDefinition> registerDefinition);\r\n\r\n        /*!\r\n         *  Write the fields.\r\n         *\r\n         *    @param [in] writer              Used XML writer.\r\n         *    @param [in] registerDefinition  The selected register definition.\r\n         */\r\n        void writeFields(QXmlStreamWriter& writer, QSharedPointer<RegisterDefinition> registerDefinition, Document::Revision docRevision);\r\n\r\n        /*!\r\n         *  Write the register alternate registers.\r\n         *\r\n         *    @param [in] writer          Used XML writer.\r\n         *    @param [in] targetRegister  The selected register.\r\n         */\r\n        void writeAlternateRegisters(QXmlStreamWriter& writer, QSharedPointer<Register> targetRegister, Document::Revision docRevision);\r\n\r\n        /*!\r\n         *  Write a single alternate register.\r\n         *\r\n         *    @param [in] writer              Used XML writer.\r\n         *    @param [in] alternateRegister   The selected alternate register.\r\n         */\r\n        void writeSingleAlternateRegister(QXmlStreamWriter& writer,\r\n            QSharedPointer<AlternateRegister> alternateRegister,\r\n            Document::Revision docRevision);\r\n\r\n        /*!\r\n         *  Write the alternate register alternate groups.\r\n         *\r\n         *    @param [in] writer              Used XML writer.\r\n         *    @param [in] alternateRegister   The selected alternate register.\r\n         */\r\n        void writeAlternateGroups(QXmlStreamWriter& writer, QSharedPointer<AlternateRegister> alternateRegister);\r\n\r\n        /*!\r\n         *  Write a register file.\r\n         *\r\n         *    @param [in] writer          Used XML writer.\r\n         *    @param [in] registerFile    The register file to be written.\r\n         */\r\n        void writeRegisterFile(QXmlStreamWriter& writer, QSharedPointer<RegisterFile> registerFile, Document::Revision docRevision);\r\n\r\n        /*!\r\n         *  Write register data contained within a register file.\r\n         *\r\n         *    @param [in] writer          Used XML writer.\r\n         *    @param [in] registerFile    The register file to be written.\r\n         */\r\n        void writeRegisterFileRegisterData(QXmlStreamWriter& writer, QSharedPointer<RegisterFile> registerFile, Document::Revision docRevision);\r\n\r\n        /*!\r\n         *\tWrite the access policies of the selected register base.\r\n         *  \r\n         *    @param [in] writer          XML writer to use.\r\n         *    @param [in] targetRegister  The selected register base.\r\n         */\r\n        void writeAccessPolicies(QXmlStreamWriter& writer, QSharedPointer<RegisterBase> targetRegisterBase);\r\n\r\n        /*!\r\n         *\tWrite the register definition reference.\r\n         *  \r\n         *    @param [in] writer          XML writer to use.\r\n         *    @param [in] targetRegister  The selected register.\r\n         */\r\n        void writeRegisterDefinitionReference(QXmlStreamWriter& writer, QSharedPointer<Register> targetRegister);\r\n    \r\n        /*!\r\n         *\tWrite the register file definition reference.\r\n         *  \r\n         *    @param [in] writer          XML writer to use.\r\n         *    @param [in] registerFile    The register file to be written.\r\n         */\r\n        void writeRegisterFileDefinitionReference(QXmlStreamWriter& writer, QSharedPointer<RegisterFile> registerFile);\r\n    }\r\n}\r\n\r\n#endif // REGISTERWRITER_H"
  },
  {
    "path": "IPXACTmodels/Component/RemapPort.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: RemapPort.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 23.09.2015\r\n//\r\n// Description:\r\n// Describes the ipxact:remapPort element.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"RemapPort.h\"\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: RemapPort::RemapPort()\r\n//-----------------------------------------------------------------------------\r\nRemapPort::RemapPort(QString const& portReference) :\r\nvalue_(),\r\n    portRef_(portReference),\r\n    portIndex_()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: RemapPort::RemapPort()\r\n//-----------------------------------------------------------------------------\r\nRemapPort::RemapPort(const RemapPort &other) :\r\nvalue_(other.value_),\r\n    portRef_(other.portRef_),\r\n    portIndex_(other.portIndex_)\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: RemapPort::operator=()\r\n//-----------------------------------------------------------------------------\r\nRemapPort& RemapPort::operator=(const RemapPort& other)\r\n{\r\n    if (this != &other)\r\n    {\r\n        value_ = other.value_;\r\n        portRef_ = other.portRef_;\r\n        portIndex_ = other.portIndex_;\r\n    }\r\n\r\n    return *this;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: RemapPort::~RemapPort()\r\n//-----------------------------------------------------------------------------\r\nRemapPort::~RemapPort()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: RemapPort::getPortNameRef()\r\n//-----------------------------------------------------------------------------\r\nQString RemapPort::getPortNameRef() const\r\n{\r\n    return portRef_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: RemapPort::setPortNameRef()\r\n//-----------------------------------------------------------------------------\r\nvoid RemapPort::setPortNameRef(QString const& newPortNameRef)\r\n{\r\n    portRef_ = newPortNameRef;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: RemapPort::getPortIndex()\r\n//-----------------------------------------------------------------------------\r\nQString RemapPort::getPortIndex() const\r\n{\r\n    return portIndex_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: RemapPort::setPortIndex()\r\n//-----------------------------------------------------------------------------\r\nvoid RemapPort::setPortIndex(QString const& newPortIndex)\r\n{\r\n    portIndex_ = newPortIndex;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: RemapPort::getValue()\r\n//-----------------------------------------------------------------------------\r\nQString RemapPort::getValue() const\r\n{\r\n    return value_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: RemapPort::setValue()\r\n//-----------------------------------------------------------------------------\r\nvoid RemapPort::setValue(QString const& newValue)\r\n{\r\n    value_ = newValue;\r\n}\r\n"
  },
  {
    "path": "IPXACTmodels/Component/RemapPort.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: RemapPort.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 23.09.2015\r\n//\r\n// Description:\r\n// Describes the ipxact:remapPort element.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef REMAPPORT_H\r\n#define REMAPPORT_H\r\n\r\n#include <IPXACTmodels/ipxactmodels_global.h>\r\n\r\n#include <QString>\r\n#include <QList>\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Describes the ipxact:remapPort element.\r\n//-----------------------------------------------------------------------------\r\nclass IPXACTMODELS_EXPORT RemapPort\r\n{\r\n\r\npublic:\r\n\r\n    /*!\r\n     *  The default constructor.\r\n     */\r\n    RemapPort(QString const& portReference = QString());\r\n\r\n\t//! Copy constructor.\r\n\tRemapPort(const RemapPort &other);\r\n\r\n    //! Assignment operator.\r\n\tRemapPort &operator=(const RemapPort &other);\r\n\r\n\t/*! \r\n     *  The destructor\r\n\t */\r\n\t~RemapPort();\r\n\r\n\t/*!\r\n     *  Get the value of the port reference.\r\n\t *\r\n\t *    @return The port reference.\r\n\t */\r\n\tQString getPortNameRef() const;\r\n\r\n\t/*!\r\n     *  Set the portNameRef for this remapPort.\r\n\t *\r\n\t *    @param [in] newPortNameRef  The new port reference.\r\n\t */\r\n\tvoid setPortNameRef(QString const& newPortNameRef);\r\n    \r\n\t/*!\r\n     *  Get index of a port.\r\n\t *\r\n\t *    @return The port index.\r\n\t */\r\n    QString getPortIndex() const;\r\n\r\n\t/*!\r\n     *  Set the port index.\r\n\t *\r\n\t *    @param [in] newPortIndex    The new port index.\r\n\t */\r\n    void setPortIndex(QString const& newPortIndex);\r\n\r\n\t/*!\r\n     *  Get the value of the remapPort element.\r\n\t *\r\n\t *    @return The value of the remap port.\r\n\t */\r\n\tQString getValue() const;\r\n\r\n\t/*! \r\n     *  Set the value for the remapPort element.\r\n\t *\r\n\t *    @param [in] value   The new value.\r\n\t */\r\n\tvoid setValue(QString const& newValue);\r\n\r\nprivate:\r\n\r\n    //! The value that activates the remap state.\r\n\tQString value_;\r\n\r\n    //! Name of the referenced port.\r\n\tQString portRef_;\r\n\r\n    //! The index of the referenced port.\r\n    QString portIndex_;\r\n};\r\n\r\n#endif // REMAPPORT_H\r\n"
  },
  {
    "path": "IPXACTmodels/Component/RemapState.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: RemapState.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 23.09.2015\r\n//\r\n// Description:\r\n// Describes the ipxact:remapState element.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"RemapState.h\"\r\n#include \"RemapPort.h\"\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: RemapState::RemapState()\r\n//-----------------------------------------------------------------------------\r\nRemapState::RemapState(QString const& name /* = QString() */) :\r\nNameGroup(name)\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: RemapState::RemapState()\r\n//-----------------------------------------------------------------------------\r\nRemapState::RemapState(const RemapState &other) :\r\nNameGroup(other)\r\n{\r\n    copyRemapPorts(other);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: RemapState::operator=()\r\n//-----------------------------------------------------------------------------\r\nRemapState& RemapState::operator=(const RemapState& other)\r\n{\r\n    if (this != &other)\r\n    {\r\n        NameGroup::operator=(other);\r\n\r\n        remapPorts_->clear();\r\n        copyRemapPorts(other);\r\n    }\r\n\r\n    return *this;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: RemapState::~RemapState()\r\n//-----------------------------------------------------------------------------\r\nRemapState::~RemapState()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: RemapState::getRemapPorts()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<QList<QSharedPointer<RemapPort> > > RemapState::getRemapPorts() const\r\n{\r\n    return remapPorts_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: RemapState::setRemapPorts()\r\n//-----------------------------------------------------------------------------\r\nvoid RemapState::setRemapPorts(QSharedPointer<QList<QSharedPointer<RemapPort> > > newRemapPorts)\r\n{\r\n    remapPorts_ = newRemapPorts;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: RemapState::copyRemapPorts()\r\n//-----------------------------------------------------------------------------\r\nvoid RemapState::copyRemapPorts(const RemapState& other)\r\n{\r\n    for (QSharedPointer<RemapPort> remapPort : *other.remapPorts_)\r\n    {\r\n        auto copy = QSharedPointer<RemapPort>(new RemapPort(*remapPort));\r\n        remapPorts_->append(copy);\r\n    }\r\n}"
  },
  {
    "path": "IPXACTmodels/Component/RemapState.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: RemapState.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 23.09.2015\r\n//\r\n// Description:\r\n// Describes the ipxact:remapState element.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef REMAPSTATE_H\r\n#define REMAPSTATE_H\r\n\r\n#include <IPXACTmodels/ipxactmodels_global.h>\r\n\r\n#include <IPXACTmodels/common/NameGroup.h>\r\n\r\n#include <QString>\r\n#include <QList>\r\n#include <QSharedPointer>\r\n\r\nclass RemapPort;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Describes the ipxact:remapState element.\r\n//-----------------------------------------------------------------------------\r\nclass IPXACTMODELS_EXPORT RemapState : public NameGroup\r\n{\r\n\r\npublic:\r\n\r\n    /*!\r\n     *  The constructor.\r\n     *\r\n     *    @param [in] name    The name of the remap state.\r\n     */\r\n    RemapState(QString const& name = QString());\r\n\r\n\t/*!\r\n\t *  Copy constructor.\r\n\t *\r\n\t *    @param [in] other   The remap state to be copied.\r\n\t */\r\n\tRemapState(const RemapState &other);\r\n\r\n    /*!\r\n\t *  Assignment operator.\r\n\t *\r\n\t *    @param [in] other   The remap state being assigned.\r\n\t */\r\n\tRemapState &operator=(const RemapState &other);\r\n\r\n\t/*!\r\n\t *  The destructor.\r\n\t */\r\n\t~RemapState();\r\n\r\n    /*!\r\n\t *  Get the list of the remap ports for this remap state.\r\n\t *\r\n     *    @return List containing pointer to the remap port instances.\r\n\t */\r\n    QSharedPointer<QList<QSharedPointer<RemapPort> > > getRemapPorts() const;\r\n\r\n    /*!\r\n     *  Set the remap ports.\r\n     *\r\n     *    @param [in] newRemapPorts   Pointer to a list containing the new remap ports.\r\n     */\r\n    void setRemapPorts(QSharedPointer<QList<QSharedPointer<RemapPort> > > newRemapPorts);\r\n\r\nprivate:\r\n\r\n    /*!\r\n     *  Copy the remap ports.\r\n     *\r\n     *    @param [in] other   The copied remap state.\r\n     */\r\n    void copyRemapPorts(const RemapState& other);\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! List of remap ports defining the remap state.\r\n    QSharedPointer<QList<QSharedPointer<RemapPort> > > remapPorts_ =\r\n        QSharedPointer<QList<QSharedPointer<RemapPort> > >(new QList<QSharedPointer<RemapPort> >());\r\n};\r\n\r\n#endif // REMAPSTATE_H\r\n"
  },
  {
    "path": "IPXACTmodels/Component/RemapStateReader.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: RemapStateReader.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 23.09.2015\r\n//\r\n// Description:\r\n// Reader class for IP-XACT remap state element.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"RemapStateReader.h\"\r\n#include \"RemapState.h\"\r\n#include \"RemapPort.h\"\r\n\r\n#include <IPXACTmodels/common/NameGroupReader.h>\r\n\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: RemapStateReader::createRemapStateFrom()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<RemapState> RemapStateReader::createRemapStateFrom(QDomNode const& remapStateNode)\r\n{\r\n    QSharedPointer<RemapState> newRemapState (new RemapState());\r\n\r\n    Details::parseNameGroup(remapStateNode, newRemapState);\r\n\r\n    Details::parseRemapPorts(remapStateNode, newRemapState);\r\n\r\n    return newRemapState;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: RemapStateReader::Details::parseNameGroup()\r\n//-----------------------------------------------------------------------------\r\nvoid RemapStateReader::Details::parseNameGroup(QDomNode const& remapStateNode, \r\n    QSharedPointer<RemapState> newRemapState)\r\n{\r\n    NameGroupReader::parseNameGroup(remapStateNode, newRemapState);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: RemapStateReader::Details::parseRemapPorts()\r\n//-----------------------------------------------------------------------------\r\nvoid RemapStateReader::Details::parseRemapPorts(QDomNode const& remapStateNode,\r\n    QSharedPointer<RemapState> newRemapState)\r\n{\r\n    QDomElement remapPortsElement = remapStateNode.firstChildElement(QStringLiteral(\"ipxact:remapPorts\"));\r\n    if (!remapPortsElement.isNull())\r\n    {\r\n        QDomNodeList remapPortNodeList = remapPortsElement.elementsByTagName(QStringLiteral(\"ipxact:remapPort\"));\r\n\r\n        for (int remapPortIndex = 0; remapPortIndex < remapPortNodeList.count(); ++remapPortIndex)\r\n        {\r\n            QDomElement remapPortElement = remapPortNodeList.at(remapPortIndex).toElement();\r\n\r\n            QString portRef = remapPortElement.attribute(QStringLiteral(\"portRef\"));\r\n            QSharedPointer<RemapPort> newRemapPort (new RemapPort(portRef));\r\n\r\n            parseRemapPortIndex(remapPortElement, newRemapPort);\r\n\r\n            parseRemapPortValue(remapPortElement, newRemapPort);\r\n\r\n            newRemapState->getRemapPorts()->append(newRemapPort);\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: RemapStateReader::Details::parseRemapPortIndex()\r\n//-----------------------------------------------------------------------------\r\nvoid RemapStateReader::Details::parseRemapPortIndex(QDomElement const& remapPortElement,\r\n    QSharedPointer<RemapPort> newRemapPort)\r\n{\r\n    QDomElement portIndexElement = remapPortElement.firstChildElement(QStringLiteral(\"ipxact:portIndex\"));\r\n    if (!portIndexElement.isNull())\r\n    {\r\n        QString portIndex = portIndexElement.firstChild().nodeValue();\r\n        newRemapPort->setPortIndex(portIndex);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: RemapStateReader::Details::parseRemapPortValue()\r\n//-----------------------------------------------------------------------------\r\nvoid RemapStateReader::Details::parseRemapPortValue(QDomElement const& remapPortElement,\r\n    QSharedPointer<RemapPort> newRemapPort)\r\n{\r\n    QString value = remapPortElement.firstChildElement(QStringLiteral(\"ipxact:value\")).firstChild().nodeValue();\r\n    newRemapPort->setValue(value);\r\n}"
  },
  {
    "path": "IPXACTmodels/Component/RemapStateReader.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: RemapStateReader.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 23.09.2015\r\n//\r\n// Description:\r\n// Reader class for IP-XACT remap state element.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef REMAPSTATEREADER_H\r\n#define REMAPSTATEREADER_H\r\n\r\n#include <IPXACTmodels/ipxactmodels_global.h>\r\n\r\n#include <QSharedPointer>\r\n#include <QDomNode>\r\n\r\nclass RemapState;\r\nclass RemapPort;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Reader class for IP-XACT remap state element.\r\n//-----------------------------------------------------------------------------\r\nnamespace RemapStateReader\r\n{\r\n    /*!\r\n     *  Creates a new remap state from a given view node.\r\n     *\r\n     *    @param [in] remapStateNode  XML description of the remap state.\r\n     *\r\n     *    @return The created remap state.\r\n     */\r\n    IPXACTMODELS_EXPORT QSharedPointer<RemapState> createRemapStateFrom(QDomNode const& remapStateNode);\r\n\r\n    namespace Details\r\n    {\r\n        /*!\r\n         *  Read the remap state name group.\r\n         *\r\n         *    @param [in] remapStateNode  XML description of the remap state.\r\n         *    @param [in] newRemapState   The selected remap state item.\r\n         */\r\n        void parseNameGroup(QDomNode const& remapStateNode, QSharedPointer<RemapState> newRemapState);\r\n\r\n        /*!\r\n         *  Read the remap ports.\r\n         *\r\n         *    @param [in] remapStateNode  XML description of the remap state.\r\n         *    @param [in] newRemapState   The selected remap state item.\r\n         */\r\n        void parseRemapPorts(QDomNode const& remapStateNode, QSharedPointer<RemapState> newRemapState);\r\n\r\n        /*!\r\n         *  Read the remap port index.\r\n         *\r\n         *    @param [in] remapPortElement    XML description of the remap port.\r\n         *    @param [in] newRemapPort        The selected remap port item.\r\n         */\r\n        void parseRemapPortIndex(QDomElement const& remapPortElement, QSharedPointer<RemapPort> newRemapPort);\r\n\r\n        /*!\r\n         *  Read the remap port value.\r\n         *\r\n         *    @param [in] remapPortElement    XML description of the remap port.\r\n         *    @param [in] newRemapPort        The selected remap port item.\r\n         */\r\n        void parseRemapPortValue(QDomElement const& remapPortElement, QSharedPointer<RemapPort> newRemapPort);\r\n    };\r\n};\r\n\r\n#endif // VIEWREADER_H"
  },
  {
    "path": "IPXACTmodels/Component/RemapStateWriter.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: RemapStateWriter.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 23.09.2015\r\n//\r\n// Description:\r\n// Writer class for IP-XACT remapState element.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"RemapStateWriter.h\"\r\n#include \"RemapState.h\"\r\n#include \"RemapPort.h\"\r\n\r\n#include <IPXACTmodels/common/NameGroupWriter.h>\r\n\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: RemapStateWriter::writeRemapState()\r\n//-----------------------------------------------------------------------------\r\nvoid RemapStateWriter::writeRemapState(QXmlStreamWriter& writer, QSharedPointer<RemapState> remapState)\r\n{\r\n    writer.writeStartElement(QStringLiteral(\"ipxact:remapState\"));\r\n\r\n    Details::writeNameGroup(writer, remapState);\r\n\r\n    Details::writeRemapPorts(writer, remapState);\r\n\r\n    writer.writeEndElement(); // ipxact:remapState\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: RemapStateWriter::Details::writeNameGroup()\r\n//-----------------------------------------------------------------------------\r\nvoid RemapStateWriter::Details::writeNameGroup(QXmlStreamWriter& writer, QSharedPointer<RemapState> remapState)\r\n{\r\n    NameGroupWriter::writeNameGroup(writer, remapState);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: RemapStateWriter::writeRemapPorts()\r\n//-----------------------------------------------------------------------------\r\nvoid RemapStateWriter::Details::writeRemapPorts(QXmlStreamWriter& writer, QSharedPointer<RemapState> remapState)\r\n{\r\n    if (!remapState->getRemapPorts()->isEmpty())\r\n    {\r\n        writer.writeStartElement(QStringLiteral(\"ipxact:remapPorts\"));\r\n\r\n        for (auto const& remapPort : *remapState->getRemapPorts())\r\n        {\r\n            writeSingleRemapPort(writer, remapPort);\r\n        }\r\n\r\n        writer.writeEndElement(); // ipxact:remapPorts\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: RemapStateWriter::Details::writeSingleRemapPort()\r\n//-----------------------------------------------------------------------------\r\nvoid RemapStateWriter::Details::writeSingleRemapPort(QXmlStreamWriter& writer, QSharedPointer<RemapPort> remapPort)\r\n{\r\n    writer.writeStartElement(QStringLiteral(\"ipxact:remapPort\"));\r\n\r\n    writer.writeAttribute(QStringLiteral(\"portRef\"), remapPort->getPortNameRef());\r\n\r\n    if (!remapPort->getPortIndex().isEmpty())\r\n    {\r\n        writer.writeTextElement(QStringLiteral(\"ipxact:portIndex\"), remapPort->getPortIndex());\r\n    }\r\n\r\n    writer.writeTextElement(QStringLiteral(\"ipxact:value\"), remapPort->getValue());\r\n\r\n    writer.writeEndElement(); // ipxact:remapPort\r\n}"
  },
  {
    "path": "IPXACTmodels/Component/RemapStateWriter.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: RemapStateWriter.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 23.09.2015\r\n//\r\n// Description:\r\n// Writer class for IP-XACT remapState element.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef REMAPSTATEWRITER_H\r\n#define REMAPSTATEWRITER_H\r\n\r\n#include <IPXACTmodels/ipxactmodels_global.h>\r\n\r\n#include <QXmlStreamWriter>\r\n#include <QObject>\r\n#include <QSharedPointer>\r\n\r\nclass RemapState;\r\nclass RemapPort;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Writer class for IP-XACT remapState element.\r\n//-----------------------------------------------------------------------------\r\nnamespace  RemapStateWriter \r\n{\r\n\r\n    /*!\r\n     *  Write a remap state to an XML file.\r\n     *\r\n     *    @param [in] writer  The used xml writer.\r\n     *    @param [in] view    The remap state to be written.\r\n     */\r\n    IPXACTMODELS_EXPORT void writeRemapState(QXmlStreamWriter& writer, QSharedPointer<RemapState> remapState);\r\n\r\n    namespace Details\r\n    {\r\n        /*!\r\n         *  Write the name group.\r\n         *\r\n         *    @param [in] writer      Used XML writer.\r\n         *    @param [in] remapState  The selected remap state.\r\n         */\r\n        void writeNameGroup(QXmlStreamWriter& writer, QSharedPointer<RemapState> remapState);\r\n\r\n        /*!\r\n         *  Write the remap ports.\r\n         *\r\n         *    @param [in] writer      Used XML writer.\r\n         *    @param [in] remapState  The selected remap state.\r\n         */\r\n        void writeRemapPorts(QXmlStreamWriter& writer, QSharedPointer<RemapState> remapState);\r\n\r\n        /*!\r\n         *  Write a single remap port.\r\n         *\r\n         *    @param [in] writer      Used XML writer.\r\n         *    @param [in] remapPort   The selected remap port.\r\n         */\r\n        void writeSingleRemapPort(QXmlStreamWriter& writer, QSharedPointer<RemapPort> remapPort);\r\n    };\r\n};\r\n\r\n#endif // REMAPSTATEWRITER_H"
  },
  {
    "path": "IPXACTmodels/Component/ResetType.h",
    "content": "//-----------------------------------------------------------------------------\n// File: ResetType.h\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Mikko Teuho\n// Date: 02.01.2019\n//\n// Description:\n// Describes the ipxact:resetType element.\n//-----------------------------------------------------------------------------\n\n#ifndef RESETTYPE_H\n#define RESETTYPE_H\n\n#include <IPXACTmodels/common/NameGroup.h>\n#include <IPXACTmodels/common/Extendable.h>\n\n//-----------------------------------------------------------------------------\n//! Describes the ipxact:resetType element.\n//-----------------------------------------------------------------------------\nclass IPXACTMODELS_EXPORT ResetType: public NameGroup, public Extendable\n{\n\npublic:\n\n\t/*!\n\t *  The constructor.\n\t */\n    ResetType() = default;\n\n    /*!\n     *  The destructor.\n     */\n    virtual ~ResetType() = default;\n\n\t/*!\n     *  Copy constructor.\n     */\n    ResetType(const ResetType& other) = default;\n\n\t/*!\n     *  Assignment operator.\n     */\n    ResetType& operator=(const ResetType& other) = default;\n};\n\n#endif // RESETTYPE_H\n"
  },
  {
    "path": "IPXACTmodels/Component/Segment.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: Segment.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 22.10.2015\r\n//\r\n// Description:\r\n// Segment describes the location and size of an area in containing address space.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"Segment.h\"\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Segment::Segment()\r\n//-----------------------------------------------------------------------------\r\nSegment::Segment(QString const& name, QString const& addressOffset, QString const& range):\r\nRegion(name, addressOffset, range)\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Segment::Segment()\r\n//-----------------------------------------------------------------------------\r\nSegment::Segment( const Segment& other ):\r\n\tRegion(other),\r\n\tisPresent_(other.isPresent_),\r\n    offsetAttributes_(other.offsetAttributes_),\r\n    rangeAttributes_(other.rangeAttributes_)\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Segment::~Segment()\r\n//-----------------------------------------------------------------------------\r\nSegment::~Segment()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Segment::operator=()\r\n//-----------------------------------------------------------------------------\r\nSegment& Segment::operator=( const Segment& other )\r\n{\r\n\tif (this != &other)\r\n    {\r\n\t\tRegion::operator=(other);\r\n\r\n\t\toffsetAttributes_ = other.offsetAttributes_;\r\n\t\trangeAttributes_ = other.rangeAttributes_;\r\n\t}\r\n\treturn *this;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Segment::getIsPresent()\r\n//-----------------------------------------------------------------------------\r\nQString Segment::getIsPresent() const\r\n{\r\n\treturn isPresent_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Segment::setIsPresent()\r\n//-----------------------------------------------------------------------------\r\nvoid Segment::setIsPresent(QString const& newIsPresent)\r\n{\r\n\tisPresent_ = newIsPresent;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Segment::getOffsetAttributes()\r\n//-----------------------------------------------------------------------------\r\nQMap<QString, QString> Segment::getOffsetAttributes() const\r\n{\r\n    return offsetAttributes_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Segment::setOffsetAttributes()\r\n//-----------------------------------------------------------------------------\r\nvoid Segment::setOffsetAttributes( QMap<QString, QString> offsetAttributes )\r\n{\r\n    offsetAttributes_ = offsetAttributes;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Segment::getRangeAttributes()\r\n//-----------------------------------------------------------------------------\r\nQMap<QString, QString> Segment::getRangeAttributes() const\r\n{\r\n\treturn rangeAttributes_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Segment::setRangeAttributes()\r\n//-----------------------------------------------------------------------------\r\nvoid Segment::setRangeAttributes( QMap<QString, QString> rangeAttributes )\r\n{\r\n\trangeAttributes_ = rangeAttributes;\r\n}\r\n"
  },
  {
    "path": "IPXACTmodels/Component/Segment.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: Segment.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 22.10.2015\r\n//\r\n// Description:\r\n// Segment describes the location and size of an area in containing address space.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef SEGMENT_H\r\n#define SEGMENT_H\r\n\r\n#include <IPXACTmodels/common/NameGroup.h>\r\n#include <IPXACTmodels/common/Extendable.h>\r\n\r\n#include <IPXACTmodels/Component/Region.h>\r\n\r\n#include <IPXACTmodels/ipxactmodels_global.h>\r\n\r\n#include <QString>\r\n#include <QMap>\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Segment describes the location and size of an area in containing address space.\r\n//-----------------------------------------------------------------------------\r\nclass IPXACTMODELS_EXPORT Segment : public Region\r\n{\r\n\r\npublic:\r\n\r\n\t/*!\r\n\t *  The default constructor.\r\n\t *\r\n\t *    @param [in] name            Name of the segment.\r\n\t *    @param [in] addressOffset   Address offset of the segment.\r\n\t *    @param [in] range           Range of the segment.\r\n\t */\r\n\tSegment(QString const& name = QString(), QString const& addressOffset = QString(),\r\n        QString const& range = QString());\r\n\t\r\n\t//! The destructor.\r\n\tvirtual ~Segment();\r\n\r\n\t//! The copy constructor.\r\n\tSegment(const Segment& other);\r\n\r\n\t//! The assignment operator.\r\n\tSegment& operator=(const Segment& other);\r\n\r\n    /*!\r\n     *  Gets the presence.\r\n     *\r\n     *    @return The presence value.\r\n     */\r\n    QString getIsPresent() const;\r\n\r\n    /*!\r\n     *  Set the presence.\r\n     *\r\n     *    @param [in] newIsPresent    The new presence value.\r\n     */\r\n    void setIsPresent(QString const& newIsPresent);\r\n    \r\n\t/*!\r\n     *  Get the attributes of the address offset.\r\n\t *\r\n\t *    @return Reference to the QMap containing the attributes as name-value pairs.\r\n\t */\r\n\tQMap<QString, QString> getOffsetAttributes() const;\r\n    \r\n\t/*!\r\n     *  Set the attributes of the address offset.\r\n\t *\r\n\t *    @param [in] offsetAttributes    QMap containing the attributes as name-value pairs.\r\n\t */\r\n\tvoid setOffsetAttributes( QMap<QString, QString> offsetAttributes );\r\n\r\n\t/*!\r\n     *  Get the attributes of the range.\r\n\t *\r\n\t *    @return Reference to the QMap containing the attributes as name-value pairs.\r\n\t */\r\n\tQMap<QString, QString> getRangeAttributes() const;\r\n\r\n\t/*!\r\n     *  Set the attributes of the range.\r\n\t *\r\n\t *    @param [in] rangeAttributes     QMap containing the attributes as name-value pairs.\r\n\t */\r\n\tvoid setRangeAttributes( QMap<QString, QString> rangeAttributes );\r\n\r\nprivate:\r\n\r\n\t//! Presence of the segment.\r\n\tQString isPresent_;\r\n\r\n\t//! The attributes for the offset\r\n\tQMap<QString, QString> offsetAttributes_;\r\n\r\n\t//! The attributes for the range.\r\n\tQMap<QString, QString> rangeAttributes_;\r\n};\r\n\r\nQ_DECLARE_METATYPE(QSharedPointer<Segment>);\r\n\r\n#endif // SEGMENT_H"
  },
  {
    "path": "IPXACTmodels/Component/Structured.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: Structured.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Esko Pekkarinen\n// Date: 20.11.2023\n//\n// Description:\n// Implementation of ipxact:structured in component port.\n//-----------------------------------------------------------------------------\n\n#include \"Structured.h\"\n\n//-----------------------------------------------------------------------------\n// Function: Structured::clone()\n//-----------------------------------------------------------------------------\nStructured* Structured::clone() const\n{\n\treturn new Structured(*this);\n}\n\n//-----------------------------------------------------------------------------\n// Function: Structural::toString()\n//-----------------------------------------------------------------------------\nQString Structured::toString(Type type)\n{\n    if (type == Type::Struct)\n    {\n        return QStringLiteral(\"struct\");\n    }\n    else if (type == Type::Union)\n    {\n        return QStringLiteral(\"union\");\n    }\n    else if (type == Type::Interface)\n    {\n        return QStringLiteral(\"interface\");\n    }\n\n    return QString();\n}\n"
  },
  {
    "path": "IPXACTmodels/Component/Structured.h",
    "content": "//-----------------------------------------------------------------------------\n// File: Structured.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Esko Pekkarinen\n// Date: 20.11.2023\n//\n// Description:\n// Implementation of ipxact:structured in component port.\n//-----------------------------------------------------------------------------\n\n#ifndef STRUCTURED_H\n#define STRUCTURED_H\n\n#include <IPXACTmodels/common/DirectionTypes.h>\n#include <IPXACTmodels/common/Vector.h>\n\n#include \"SubPort.h\"\n\n#include <IPXACTmodels/ipxactmodels_global.h>\n\n//-----------------------------------------------------------------------------\n//! Implementation of ipxact:structured in component port.\n//-----------------------------------------------------------------------------\nclass IPXACTMODELS_EXPORT Structured\n{\npublic:\n\n    enum class Type\n    {\n        Struct,\n        Union,\n        Interface,\n        Undefined\n    };\n\n    /*!\n     *  Create a copy of the Structured.\n     *\n     *    @return A Structured identical to this.\n     */\n    Structured* clone() const;\n\n    /*!\n     *  Set the structured port as packed.\n     *\n     *    @param [in] packed Packed or not.\n     */\n    constexpr void setPacked(bool packed) noexcept { packed_ = packed; }\n\n    /*!\n     *  Check if the structured port can be packed.\n     *\n     *    @return True, if the port can be packed, otherwise false.\n     */\n    [[nodiscard]] bool isPacked() const noexcept { return packed_; }\n\n    /*!\n     *  Set the port type.\n     *\n     *    @param [in] type The type to set.\n     */\n    constexpr void setType(Type type) noexcept { portType_ = type; }\n\n    /*!\n     *  Get the port type.\n     *\n     *    @return The port type.\n     */\n    [[nodiscard]] constexpr Type getType() const noexcept { return portType_; }\n\n    /*!\n     *  Set the direction of this port.\n     *\n     *    @param [in] direction   The new direction.\n     */\n    constexpr void setDirection(DirectionTypes::Direction direction) noexcept { direction_ = direction; }\n\n    /*!\n     *  Get the direction of the port.\n     *\n     *    @return Enum direction specifying the port direction.\n     */\n    [[nodiscard]] constexpr DirectionTypes::Direction getDirection() const noexcept { return direction_; }\n\n    /*!\n     *  Get the vectors in the structured port.\n     *\n     *    @return The vectors in the port.\n     */\n    [[nodiscard]] QSharedPointer<QList<Vector> > getVectors() const { return vectors_; }\n\n    /*!\n     *  Get the sub-ports in the structured port.\n     *\n     *    @return The sub-ports in the port.\n     */\n    [[nodiscard]] SubPort::List getSubPorts() const { return subPorts_; }\n\n    /*!\n     *  Convert the structured type to string.\n     *\n     *    @return The string representation of the type.\n     */\n    [[nodiscard]] static QString toString(Type type);\n\nprivate:\n\n    //! Port is mappable to packed bit sequence.\n    bool packed_{ true };\n\n    //! The type of this port.\n    Type portType_{ Type::Undefined };\n\n    //! The direction of the port.\n    DirectionTypes::Direction direction_{ DirectionTypes::DIRECTION_INVALID };\n\n    //! The vectors of the port.\n    QSharedPointer<QList<Vector> > vectors_{ new QList<Vector>() };\n\n    //! The sub-ports of the structural port.\n    SubPort::List subPorts_{ new QList<QSharedPointer<SubPort> >() };\n};\n\n#endif // STRUCTURED_H"
  },
  {
    "path": "IPXACTmodels/Component/SubPort.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: SubPort.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Esko Pekkarinen\n// Date: 21.11.2023\n//\n// Description:\n// Implementation of ipxact:SubPort in component port.\n//-----------------------------------------------------------------------------\n\n#include \"SubPort.h\"\n\n//-----------------------------------------------------------------------------\n// Function: SubPort::setWire()\n//-----------------------------------------------------------------------------\nvoid SubPort::setWire(QSharedPointer<Wire> wire)\n{\n    structured_.clear();\n    wire_ = wire;\n}\n\n//-----------------------------------------------------------------------------\n// Function: SubPort::setStructured()\n//-----------------------------------------------------------------------------\nvoid SubPort::setStructured(QSharedPointer<Structured> structured)\n{\n    wire_.clear();\n    structured_ = structured;\n}\n"
  },
  {
    "path": "IPXACTmodels/Component/SubPort.h",
    "content": "//-----------------------------------------------------------------------------\n// File: SubPort.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Esko Pekkarinen\n// Date: 21.11.2023\n//\n// Description:\n// Implementation of ipxact:subPort in component port.\n//-----------------------------------------------------------------------------\n\n#ifndef SUBPORT_H\n#define SUBPORT_H\n\n#include <IPXACTmodels/common/Array.h>\n#include <IPXACTmodels/common/NameGroup.h>\n\n#include <IPXACTmodels/ipxactmodels_global.h>\n\nclass Structured;\nclass Wire;\n\n//-----------------------------------------------------------------------------\n//! Implementation of ipxact:SubPort in component port.\n//-----------------------------------------------------------------------------\nclass IPXACTMODELS_EXPORT SubPort : public NameGroup\n{\npublic:\n\n    using List = QSharedPointer<QList<QSharedPointer<SubPort> > >;\n\n    /*!\n     *  Set for input, inout or output ports in an interface.\n     *\n     *    @param [in] isIO Wheter the port is an input, inout or output.\n     */\n    void setIsIO(bool isIO) noexcept { isIO_ = isIO; }\n\n    /*!\n     *  Check if the port is an input, output or inout.\n     *\n     *    @return True, if the port is input, output or inout, otherwise false.\n     */\n    [[nodiscard]] bool isIO() const noexcept { return isIO_; }\n\n    /*!\n     *  Check if the sub-port has a wire definition.\n     *\n     *    @return True, if the sub-port has a wire, otherwise false.\n     */\n    [[nodiscard]] bool isWire() const noexcept { return wire_.isNull() == false; }\n\n    /*!\n     *  Set the wire port in the sub-port.\n     *\n     *    @param [in] wire The wire to set.\n     */\n    void setWire(QSharedPointer<Wire> wire);\n\n    /*!\n     *  Get the wire port in the sub-port.\n     *\n     *    @return The wire port, if available, otherwise nullptr.\n     */\n    [[nodiscard]] QSharedPointer<Wire> getWire() const  { return wire_; }\n\n    /*!\n     *  Check if the sub-port has a structured definition.\n     *\n     *    @return True, if the sub-port has a structured, otherwise false.\n     */\n    [[nodiscard]] bool isStructured() const noexcept { return structured_.isNull() == false; }\n\n    /*!\n     *  Set the structured port in the sub-port.\n     *\n     *    @param [in] structured  The structured port to set.\n     */\n    void setStructured(QSharedPointer<Structured> structured);\n\n    /*!\n     *  Get the structured port in the sub-port.\n     *\n     *    @return The structured port, if available, otherwise nullptr.\n     */\n    [[nodiscard]] QSharedPointer<Structured> getStructured() const { return structured_; }\n\n    [[nodiscard]] QSharedPointer<QList<Array> > getArrays() const { return arrays_; }\n\nprivate:\n\n    //! The sub-port wire port.\n    QSharedPointer<Wire> wire_{ nullptr };\n\n    //! The nested structured port.\n    QSharedPointer<Structured> structured_{ nullptr };\n\n    //! The sub-port arrays.\n    QSharedPointer<QList<Array> > arrays_{ new QList<Array>() };\n\n    //! Is the sub-port input, output or inout in an interface.\n    bool isIO_;\n};\n\n#endif // SUBPORT_H"
  },
  {
    "path": "IPXACTmodels/Component/SubSpaceMap.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: SubSpaceMap.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Mikko Teuho\n// Date: 17.01.2022\n//\n// Description:\n// Contains elements for sub space maps.\n//-----------------------------------------------------------------------------\n\n#include \"SubSpaceMap.h\"\n\n//-----------------------------------------------------------------------------\n// Function: SubSpaceMap::SubSpaceMap()\n//-----------------------------------------------------------------------------\nSubSpaceMap::SubSpaceMap(QString const& name, QString const& baseAddress):\nMemoryBlockBase(name, baseAddress),\ninitiatorReference_(),\nsegmentRef_()\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: SubSpaceMap::SubSpaceMap()\n//-----------------------------------------------------------------------------\nSubSpaceMap::SubSpaceMap(const SubSpaceMap& other):\nMemoryBlockBase(other),\ninitiatorReference_(other.initiatorReference_),\nsegmentRef_(other.segmentRef_)\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: SubSpaceMap::operator=()\n//-----------------------------------------------------------------------------\nSubSpaceMap& SubSpaceMap::operator=( const SubSpaceMap& other)\n{\n    if (this != &other)\n    {\n        MemoryBlockBase::operator=(other);\n        initiatorReference_ = other.initiatorReference_;\n        segmentRef_ = other.segmentRef_;\n    }\n\n    return *this;\n}\n\n//-----------------------------------------------------------------------------\n// Function: SubSpaceMap::clone()\n//-----------------------------------------------------------------------------\nQSharedPointer<MemoryBlockBase> SubSpaceMap::clone() const\n{\n    return QSharedPointer<SubSpaceMap>(new SubSpaceMap(*this));\n}\n\n//-----------------------------------------------------------------------------\n// Function: SubSpaceMap::getMasterReference()\n//-----------------------------------------------------------------------------\nQString SubSpaceMap::getInitiatorReference() const\n{\n    return initiatorReference_;\n}\n\n//-----------------------------------------------------------------------------\n// Function: SubSpaceMap::setMasterReference()\n//-----------------------------------------------------------------------------\nvoid SubSpaceMap::setInitiatorReference(QString const& newInitiatorReference)\n{\n    initiatorReference_ = newInitiatorReference;\n}\n\n//-----------------------------------------------------------------------------\n// Function: SubSpaceMap::getSegmentReference()\n//-----------------------------------------------------------------------------\nQString SubSpaceMap::getSegmentReference() const\n{\n    return segmentRef_;\n}\n\n//-----------------------------------------------------------------------------\n// Function: SubSpaceMap::setSegmentReference()\n//-----------------------------------------------------------------------------\nvoid SubSpaceMap::setSegmentReference(QString const& newSegmentReference)\n{\n    segmentRef_ = newSegmentReference;\n}\n"
  },
  {
    "path": "IPXACTmodels/Component/SubSpaceMap.h",
    "content": "//-----------------------------------------------------------------------------\n// File: SubSpaceMap.h\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Mikko Teuho\n// Date: 17.01.2022\n//\n// Description:\n// Contains elements for sub space maps.\n//-----------------------------------------------------------------------------\n\n#ifndef SUBSPACEMAP_H\n#define SUBSPACEMAP_H\n\n#include <IPXACTmodels/ipxactmodels_global.h>\n\n#include <IPXACTmodels/Component/MemoryBlockBase.h>\n\n//-----------------------------------------------------------------------------\n//! Contains elements for sub space maps.\n//-----------------------------------------------------------------------------\nclass IPXACTMODELS_EXPORT SubSpaceMap : public MemoryBlockBase\n{\n\npublic:\n\n    /*!\n     *  Constructor for sub space maps.\n     *\n     *    @param [in] name    Name of the memory map base.\n     */\n    SubSpaceMap(QString const& name = QString(), QString const& baseAddress = QString());\n\n    /*!\n     *  Copy constructor.\n     *\n     *    @param [in] other   The subspace map to be copied.\n     */\n    SubSpaceMap(const SubSpaceMap& other);\n\n    /*!\n     *  Assignment operator.\n     *\n     *    @param [in] other   The subspace map to be assigned.\n     */\n    SubSpaceMap &operator=(const SubSpaceMap& other);\n\n    /*!\n     *  The destructor.\n     */\n    virtual ~SubSpaceMap() = default;\n\n    /*!\n     *  Clone this subspace map item and return pointer to the copy.\n\t * \n\t *    @return Pointer to the cloned subspace map item.\n\t */\n\tvirtual QSharedPointer<MemoryBlockBase> clone() const;\n\n    /*!\n     *  Get the master interface reference.\n     *\n     *    @return The master reference.\n     */\n    QString getInitiatorReference() const;\n\n    /*!\n     *  Set the reference to the initiator interface.\n     *\n     *    @param [in] newInitiatorReference  The new initiator interface reference.\n     */\n    void setInitiatorReference(QString const& newInitiatorReference);\n\n    /*!\n     *  Get the segment reference.\n     *\n     *    @return The segment reference.\n     */\n    QString getSegmentReference() const;\n\n    /*!\n     *  Set the segment reference.\n     *\n     *    @param [in] newSegmentReference     The new segment reference.\n     */\n    void setSegmentReference(QString const& newSegmentReference);\n\nprivate:\n\n    //-----------------------------------------------------------------------------\n    // Data.\n    //-----------------------------------------------------------------------------\n\n    // The reference to the initiator interface whose address space is being mapped.\n    QString initiatorReference_;\n\n    //! Reference to a segment in the address space of the referenced initiator reference.\n    QString segmentRef_;\n};\n\n#endif // SUBSPACEMAP_H\n"
  },
  {
    "path": "IPXACTmodels/Component/SubSpaceMapWriter.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: SubSpaceMapWriter.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Mikko Teuho\n// Date: 18.01.2022\n//\n// Description:\n// Writer class for ipxact:subSpaceMap element.\n//-----------------------------------------------------------------------------\n\n#include \"SubSpaceMapWriter.h\"\n\n#include <IPXACTmodels/common/NameGroupWriter.h>\n#include <IPXACTmodels/Component/SubSpaceMap.h>\n\n//-----------------------------------------------------------------------------\n// Function: SubSpaceMapWriter::writeSubSpaceMap()\n//-----------------------------------------------------------------------------\nvoid SubSpaceMapWriter::writeSubSpaceMap(QXmlStreamWriter& writer, QSharedPointer<SubSpaceMap> subMap, \n    Document::Revision docRevision)\n{\n    writer.writeStartElement(QStringLiteral(\"ipxact:subspaceMap\"));\n\n    Details::writeAttributes(writer, subMap, docRevision);\n\n    MemoryBlockBaseWriter::writeNameGroup(writer, subMap, docRevision);\n\n    if (docRevision == Document::Revision::Std14)\n    {\n        CommonItemsWriter::writeIsPresent(writer, subMap->getIsPresent());\n    }\n\n    MemoryBlockBaseWriter::writeBaseAddress(writer, subMap);\n\n    CommonItemsWriter::writeParameters(writer, subMap->getParameters(), docRevision);\n\n    CommonItemsWriter::writeVendorExtensions(writer, subMap);\n\n    writer.writeEndElement(); // ipxact:subspaceMap\n}\n\n//-----------------------------------------------------------------------------\n// Function: SubSpaceMapWriter::Details::writeAttributes()\n//-----------------------------------------------------------------------------\nvoid SubSpaceMapWriter::Details::writeAttributes(QXmlStreamWriter& writer, QSharedPointer<SubSpaceMap> subMap, \n    Document::Revision docRevision)\n{\n    QString initiatorAttrName = docRevision == Document::Revision::Std22\n        ? QStringLiteral(\"initiatorRef\") : QStringLiteral(\"masterRef\");\n\n    writer.writeAttribute(initiatorAttrName, subMap->getInitiatorReference());\n\n    if (!subMap->getSegmentReference().isEmpty())\n    {\n        writer.writeAttribute(QStringLiteral(\"segmentRef\"), subMap->getSegmentReference());\n    }\n}\n"
  },
  {
    "path": "IPXACTmodels/Component/SubSpaceMapWriter.h",
    "content": "//-----------------------------------------------------------------------------\n// File: SubSpaceMapWriter.h\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Mikko Teuho\n// Date: 18.01.2022\n//\n// Description:\n// Writer for ipxact:subSpaceMap element.\n//-----------------------------------------------------------------------------\n\n#ifndef SUBSPACEMAPWRITER_H\n#define SUBSPACEMAPWRITER_H\n\n#include <IPXACTmodels/ipxactmodels_global.h>\n\n#include <IPXACTmodels/Component/MemoryBlockBaseWriter.h>\n\n#include <QXmlStreamWriter>\n#include <QSharedPointer>\n\nclass SubSpaceMap;\n\n//-----------------------------------------------------------------------------\n//! Writer for ipxact:subSpaceMap element.\n//-----------------------------------------------------------------------------\nnamespace SubSpaceMapWriter\n{\n    /*!\n     *  Write a subspace map to an XML file.\n     *\n     *    @param [in] writer          The used XML writer.\n     *    @param [in] subMap          The subspace map to be written.\n     *    @param [in] docRevision     The IP-XACT standard revision to comply to.\n     */\n    IPXACTMODELS_EXPORT void writeSubSpaceMap(QXmlStreamWriter& writer, QSharedPointer<SubSpaceMap> subMap, \n        Document::Revision docRevision);\n\n    namespace Details\n    {\n        /*!\n         *  Writes the attributes of a given subspace map into xml.\n         *\n         *    @param [in] writer          The xml writer to use.\n         *    @param [in] subMap          The subspace map whose attributes to write.\n         *    @param [in] docRevision     The IP-XACT standard revision to comply to.\n         */\n        void writeAttributes(QXmlStreamWriter& writer, QSharedPointer<SubSpaceMap> subMap, Document::Revision docRevision);\n    }\n};\n\n#endif // SUBSPACEMAPWRITER_H"
  },
  {
    "path": "IPXACTmodels/Component/SubspaceMapReader.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: SubspaceMapReader.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Mikko Teuho\n// Date: 21.01.2022\n//\n// Description:\n// Reader for ipxact:subspaceMap element.\n//-----------------------------------------------------------------------------\n\n#include \"SubspaceMapReader.h\"\n\n#include <IPXACTmodels/common/NameGroupReader.h>\n#include <IPXACTmodels/Component/SubSpaceMap.h>\n\n//-----------------------------------------------------------------------------\n// Function: SubspaceMapReader::createMemoryBlockFrom()\n//-----------------------------------------------------------------------------\nIPXACTMODELS_EXPORT QSharedPointer<SubSpaceMap> SubspaceMapReader::createSubspaceMapFrom(QDomNode const& subspaceMapNode, Document::Revision docRevision)\n{\n    QSharedPointer<SubSpaceMap> newSubspaceMap(new SubSpaceMap());\n\n    Details::parseAttributes(subspaceMapNode, newSubspaceMap, docRevision);\n\n    MemoryBlockBaseReader::parseNameGroup(subspaceMapNode, newSubspaceMap);\n\n    if (docRevision == Document::Revision::Std14)\n    {\n        MemoryBlockBaseReader::parsePresence(subspaceMapNode, newSubspaceMap);\n    }\n\n    MemoryBlockBaseReader::parseBaseAddress(subspaceMapNode, newSubspaceMap);\n\n    MemoryBlockBaseReader::parseParameters(subspaceMapNode, newSubspaceMap, docRevision);\n\n    CommonItemsReader::parseVendorExtensions(subspaceMapNode, newSubspaceMap);\n\n    return newSubspaceMap;\n}\n\n//-----------------------------------------------------------------------------\n// Function: SubspaceMapReader::Details::parseAttributes()\n//-----------------------------------------------------------------------------\nvoid SubspaceMapReader::Details::parseAttributes(QDomNode const& subspaceMapNode,\n    QSharedPointer<SubSpaceMap> newSubspaceMap,\n    Document::Revision docRevision)\n{\n    QString initiatorAttrName = docRevision == Document::Revision::Std22\n        ? QStringLiteral(\"initiatorRef\")\n        : QStringLiteral(\"masterRef\");\n\n    QDomNamedNodeMap attributes = subspaceMapNode.attributes();\n    for (int j = 0; j < attributes.size(); ++j)\n    {\n        QString attributeName = attributes.item(j).nodeName();\n        QString attributeValue = attributes.item(j).nodeValue();\n\n        if (attributeName == initiatorAttrName)\n        {\n            newSubspaceMap->setInitiatorReference(attributeValue);\n        }\n        else if (attributeName == QStringLiteral(\"segmentRef\"))\n        {\n            newSubspaceMap->setSegmentReference(attributeValue);\n        }\n    }\n\n}\n"
  },
  {
    "path": "IPXACTmodels/Component/SubspaceMapReader.h",
    "content": "//-----------------------------------------------------------------------------\n// File: SubspaceMapReader.h\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Mikko Teuho\n// Date: 21.01.2022\n//\n// Description:\n// Reader for ipxact:subspaceMap element.\n//-----------------------------------------------------------------------------\n\n#ifndef SUBSPACEMAPREADER_H\n#define SUBSPACEMAPREADER_H\n\n#include <IPXACTmodels/ipxactmodels_global.h>\n\n#include <IPXACTmodels/Component/MemoryBlockBaseReader.h>\n\n#include <QSharedPointer>\n#include <QDomNode>\n\nclass SubSpaceMap;\n\n//-----------------------------------------------------------------------------\n//! Reader for ipxact:subspaceMap element.\n//-----------------------------------------------------------------------------\nnamespace SubspaceMapReader\n{\n    /*!\n     *  Creates a new subspace map from a given subspace map node.\n     *\n     *    @param [in] subspaceMapNode     XML description of the subspace map.\n     *    @param [in] docRevision         The IP-XACT standard revision to comply to.\n     *\n     *    @return The created subspace map.\n     */\n    IPXACTMODELS_EXPORT QSharedPointer<SubSpaceMap> createSubspaceMapFrom(QDomNode const& subspaceMapNode,\n        Document::Revision docRevision);\n\n    namespace Details\n    {\n        /*!\n         *  Reads the attributes from XML to a subspace map.\n         *\n         *    @param [in] subspaceMapNode     The XML description of the subspace map.\n         *    @param [in/out] newSubspaceMap  The subspace map to insert the attributes into.\n         *    @param [in] docRevision         The IP-XACT standard revision to comply to.\n         */\n        void parseAttributes(QDomNode const& subspaceMapNode, QSharedPointer<SubSpaceMap> newSubspaceMap, \n            Document::Revision docRevision);\n    }\n}\n\n#endif // SUBSPACEMAPREADER_H"
  },
  {
    "path": "IPXACTmodels/Component/TargetInterface.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: TargetInterface.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Esko Pekkarinen\r\n// Date: 28.06.2023\r\n//\r\n// Description:\r\n// Implementation of ipxact:target in bus interface.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"TargetInterface.h\"\r\n\r\n#include <QString>\r\n#include <QList>\r\n#include <QSharedPointer>\r\n#include <QObject>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: TargetInterface::TargetInterface()\r\n//-----------------------------------------------------------------------------\r\nTargetInterface::TargetInterface()\r\n{\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: TargetInterface::TargetInterface()\r\n//-----------------------------------------------------------------------------\r\nTargetInterface::TargetInterface(TargetInterface const& other) :\r\n    memoryMapRef_(other.memoryMapRef_),\r\n    modeRefs_(other.modeRefs_)\r\n{\r\n    for (QSharedPointer<TransparentBridge> bridge : *other.bridges_)\r\n    {\r\n        QSharedPointer<TransparentBridge> copy(new TransparentBridge(*bridge));\r\n        bridges_->append(copy);\r\n    }\r\n\r\n    for (QSharedPointer<FileSetRefGroup> refGroup : *other.fileSetRefGroup_)\r\n    {\r\n        QSharedPointer<FileSetRefGroup> copy(new FileSetRefGroup(*refGroup));\r\n        fileSetRefGroup_->append(copy);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: TargetInterface::operator=()\r\n//-----------------------------------------------------------------------------\r\nTargetInterface& TargetInterface::operator=(TargetInterface const& other)\r\n{\r\n\tif (this != &other)\r\n    {\r\n        memoryMapRef_ = other.memoryMapRef_;\r\n\r\n        modeRefs_ = other.modeRefs_;\r\n\r\n        bridges_->clear();\r\n        for (QSharedPointer<TransparentBridge> bridge : *other.bridges_) \r\n        {\r\n            QSharedPointer<TransparentBridge> copy(new TransparentBridge(*bridge));\r\n            bridges_->append(copy);\r\n        }\r\n\r\n        fileSetRefGroup_.clear();\r\n        for (QSharedPointer<FileSetRefGroup> refGroup: *other.fileSetRefGroup_)\r\n        {\r\n            QSharedPointer<FileSetRefGroup> copy(new FileSetRefGroup(*refGroup));\r\n            fileSetRefGroup_->append(copy);\r\n        }\r\n    }\r\n    return *this;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: TargetInterface::~TargetInterface()\r\n//-----------------------------------------------------------------------------\r\nTargetInterface::~TargetInterface()\r\n{\r\n\tbridges_->clear();\r\n\tfileSetRefGroup_->clear();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: TargetInterface::getMemoryMapRef()\r\n//-----------------------------------------------------------------------------\r\nQString TargetInterface::getMemoryMapRef() const\r\n{\r\n    return memoryMapRef_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: TargetInterface::setMemoryMapRef()\r\n//-----------------------------------------------------------------------------\r\nvoid TargetInterface::setMemoryMapRef(QString const& memoryMapRef)\r\n{\r\n    memoryMapRef_ = memoryMapRef;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: TargetInterface::getModeRefs()\r\n//-----------------------------------------------------------------------------\r\nQStringList TargetInterface::getModeRefs() const\r\n{\r\n    return modeRefs_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: TargetInterface::setModeRefs()\r\n//-----------------------------------------------------------------------------\r\nvoid TargetInterface::setModeRefs(QStringList const& modeRefs)\r\n{\r\n    modeRefs_ = modeRefs;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: TargetInterface::getBridges()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<QList<QSharedPointer<TransparentBridge> > > TargetInterface::getBridges() const\r\n{\r\n\treturn bridges_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: TargetInterface::hasTransparentBridge()\r\n//-----------------------------------------------------------------------------\r\nbool TargetInterface::hasTransparentBridge() const\r\n{\r\n    return !bridges_->isEmpty();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: TargetInterface::getMasterReferences()\r\n//-----------------------------------------------------------------------------\r\nQStringList TargetInterface::getMasterReferences() const \r\n{\r\n    QStringList masterNames;\r\n    for (QSharedPointer<TransparentBridge> bridge: *bridges_)\r\n    {\r\n        masterNames.append(bridge->getMasterRef());\r\n    }\r\n\r\n    return masterNames;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: TargetInterface::getFileSetRefGroup()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<QList<QSharedPointer<TargetInterface::FileSetRefGroup> > > TargetInterface::getFileSetRefGroup() const\r\n{\r\n    return fileSetRefGroup_;\r\n}\r\n"
  },
  {
    "path": "IPXACTmodels/Component/TargetInterface.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: SlaveInterface.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Esko Pekkarinen\r\n// Date: 28.062023\r\n//\r\n// Description:\r\n// Implementation of ipxact:target in bus interface.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef TARGETINTERFACE_H\r\n#define TARGETINTERFACE_H\r\n\r\n#include \"TransparentBridge.h\"\r\n#include \"FileSetRef.h\"\r\n\r\n#include <IPXACTmodels/ipxactmodels_global.h>\r\n\r\n#include <IPXACTmodels/utilities/Copy.h>\r\n\r\n#include <QString>\r\n#include <QList>\r\n#include <QStringList>\r\n#include <QSharedPointer>\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Implementation of ipxact:target in bus interface.\r\n//-----------------------------------------------------------------------------\r\nclass IPXACTMODELS_EXPORT TargetInterface\r\n{\r\npublic:\r\n\r\n    //! Implementation of ipxact:fileSetRefGroup element.\r\n\tstruct FileSetRefGroup\r\n\t{\r\n\t\t//! The group name.\r\n\t\tQString group_;\r\n\r\n        //! The referenced filesets.\r\n\t\tQSharedPointer<QList<QSharedPointer<FileSetRef> > > fileSetRefs_ =\r\n\t\t\tQSharedPointer<QList<QSharedPointer<FileSetRef> > >(new QList<QSharedPointer<FileSetRef> > ());\r\n\r\n\t\t//! The constructor.\t\r\n\t\tFileSetRefGroup(): group_() {}\r\n\r\n\t\tFileSetRefGroup(FileSetRefGroup const& other) : group_(other.group_)\r\n\t\t{\r\n\t\t\tCopy::copyList(other.fileSetRefs_, fileSetRefs_);\r\n\t\t}\r\n\r\n\t\tFileSetRefGroup& operator=(FileSetRefGroup const& other)\r\n\t\t{\r\n\t\t\tif (this != &other)\r\n\t\t\t{\r\n\t\t\t\tgroup_ = other.group_;\r\n\r\n\t\t\t\tfileSetRefs_->clear();\r\n\t\t\t\tCopy::copyList(other.fileSetRefs_, fileSetRefs_);\r\n\t\t\t}\r\n\r\n\t\t\treturn *this;\r\n\t\t}\r\n\t};\r\n\r\n\t//! The default constructor.\r\n\tTargetInterface();\r\n\r\n\t//! Copy constructor\r\n\tTargetInterface(const TargetInterface& other);\r\n\r\n\t//! Assignment operator\r\n\tTargetInterface& operator=(const TargetInterface& other);\r\n\t\r\n\t//! The destructor\r\n\t~TargetInterface();\r\n    \r\n    /*!  Get the name of the referenced memory map if any.\r\n\t *\r\n\t *    @return The name of the memory map referenced in the slave interface.\r\n\t */\r\n\tQString getMemoryMapRef() const;\r\n    \r\n\t/*! Set the memory map for this interface.\r\n\t *\r\n\t *    @param [in] memoryMapRef    The name of the memory map to reference.\r\n\t */\r\n\tvoid setMemoryMapRef(QString const& memoryMapRef);\r\n\r\n\r\n    QStringList getModeRefs() const;\r\n    void setModeRefs(QStringList const& modeRefs);\r\n\r\n\t/*! Get the bridges for this slave interface.\r\n\t *\r\n\t *    @return The bridges for this slave interface.\r\n\t */\r\n\tQSharedPointer<QList<QSharedPointer<TransparentBridge> > > getBridges() const;\r\n    \r\n\t/*! Check if the slave is connected to a master interface through transparent bridge.\r\n\t *\r\n\t *    @return True if at least one bridge is found, otherwise false.\r\n\t */\r\n\tbool hasTransparentBridge() const;\r\n\r\n\t/*! Get list of the master interfaces referred to through the contained bridge-elements.\r\n\t *\r\n\t *    @return The names of the referred master interfaces.\r\n\t */\r\n\tQStringList getMasterReferences() const;\r\n\r\n\t/*! Get the fileSetRefGroups for this slave interface.\r\n\t *\r\n\t *    @return The fileSetRefGroups for this slave interface.\r\n\t */\r\n\tQSharedPointer<QList<QSharedPointer<FileSetRefGroup> > > getFileSetRefGroup() const;\r\n\r\nprivate:\r\n\r\n\t//! The referenced memory map name.\r\n\tQString memoryMapRef_;\r\n\r\n    //! Mode references.\r\n    QStringList modeRefs_;\r\n\r\n\t//! The bridges to master interfaces.\r\n\tQSharedPointer<QList<QSharedPointer<TransparentBridge> > > bridges_ =\r\n\t\tQSharedPointer<QList<QSharedPointer<TransparentBridge> > >(new QList<QSharedPointer<TransparentBridge> >);\r\n\r\n    //! The file set references for the slave interface.\r\n\tQSharedPointer<QList<QSharedPointer<FileSetRefGroup> > > fileSetRefGroup_ =\r\n\t\tQSharedPointer<QList<QSharedPointer<FileSetRefGroup> > >(\r\n\t\t\tnew QList<QSharedPointer<TargetInterface::FileSetRefGroup> >);\r\n};\r\n\r\n\r\n#endif // TARGETINTERFACE_H\r\n"
  },
  {
    "path": "IPXACTmodels/Component/Transactional.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: Transactional.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 10.09.2015\r\n//\r\n// Description:\r\n// Describes the ipxact:transactional element within component ports.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"Transactional.h\"\r\n\r\n#include <IPXACTmodels/common/TransactionalTypes.h>\r\n\r\n#include <IPXACTmodels/utilities/Copy.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Transactional::Transactional()\r\n//-----------------------------------------------------------------------------\r\nTransactional::Transactional(const Transactional& other) :\r\n    allLogicalInitiativesAllowed_(other.allLogicalInitiativesAllowed_),\r\n    initiative_(other.initiative_),\r\n    kind_(other.kind_),\r\n    busWidth_(other.busWidth_),\r\n    qualifier_(other.qualifier_->clone()),\r\n    maxConnections_(other.maxConnections_),\r\n    minConnections_(other.minConnections_)\r\n{\r\n    if (other.protocol_)\r\n    {\r\n        protocol_ = QSharedPointer<Protocol>(other.protocol_->clone());\r\n    }\r\n\r\n    Copy::copyList(other.transTypeDefs_, transTypeDefs_);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Transactional::clone()\r\n//-----------------------------------------------------------------------------\r\nTransactional* Transactional::clone() const\r\n{\r\n    return new Transactional(*this);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Transactional::operator=()\r\n//-----------------------------------------------------------------------------\r\nTransactional& Transactional::operator=( const Transactional& other)\r\n{\r\n    if (this != & other)\r\n    {\r\n        allLogicalInitiativesAllowed_ = other.allLogicalInitiativesAllowed_;\r\n        initiative_ = other.initiative_;\r\n        kind_ = other.kind_;\r\n        busWidth_ = other.busWidth_;\r\n        qualifier_ = QSharedPointer<Qualifier>(other.qualifier_->clone());\r\n        maxConnections_ = other.maxConnections_;\r\n        minConnections_ = other.minConnections_;\r\n\r\n        protocol_.clear();\r\n        if (other.protocol_)\r\n        {\r\n            protocol_ = QSharedPointer<Protocol>(other.protocol_->clone());\r\n        }\r\n\r\n        transTypeDefs_->clear();\r\n        Copy::copyList(other.transTypeDefs_, transTypeDefs_);\r\n    }\r\n\r\n    return *this;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Transactional::getAllLogicalInitiativesAllowed()\r\n//-----------------------------------------------------------------------------\r\nbool Transactional::getAllLogicalInitiativesAllowed() const\r\n{\r\n    return allLogicalInitiativesAllowed_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Transactional::setAllLogicalInitiativesAllowed()\r\n//-----------------------------------------------------------------------------\r\nvoid Transactional::setAllLogicalInitiativesAllowed(bool allow)\r\n{\r\n    allLogicalInitiativesAllowed_ = allow;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Transactional::getInitiative()\r\n//-----------------------------------------------------------------------------\r\nQString Transactional::getInitiative() const\r\n{\r\n    return initiative_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Transactional::setInitiative()\r\n//-----------------------------------------------------------------------------\r\nvoid Transactional::setInitiative(QString const& newInitiative)\r\n{\r\n    if (TransactionalTypes::isIpXactInitiativeType(newInitiative))\r\n    {\r\n        initiative_ = newInitiative;\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Transactional::getKind()\r\n//-----------------------------------------------------------------------------\r\nQString Transactional::getKind() const\r\n{\r\n    return kind_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Transactional::setKind()\r\n//-----------------------------------------------------------------------------\r\nvoid Transactional::setKind(QString const& newKind)\r\n{\r\n    kind_ = newKind;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Transactional::getBusWidth()\r\n//-----------------------------------------------------------------------------\r\nQString Transactional::getBusWidth() const\r\n{\r\n    return busWidth_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Transactional::setBusWidth()\r\n//-----------------------------------------------------------------------------\r\nvoid Transactional::setBusWidth(QString const& newBusWidth)\r\n{\r\n    busWidth_ = newBusWidth;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Transactional::getQualifier()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<Qualifier> Transactional::getQualifier() const\r\n{\r\n    return qualifier_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Transactional::getProtocol()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<Protocol> Transactional::getProtocol() const\r\n{\r\n    return protocol_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Transactional::setProtocol()\r\n//-----------------------------------------------------------------------------\r\nvoid Transactional::setProtocol(QSharedPointer<Protocol> newProtocol)\r\n{\r\n    protocol_ = newProtocol;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Transactional::getTransTypeDef()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<QList<QSharedPointer<WireTypeDef> > > Transactional::getTransTypeDef() const\r\n{\r\n    return transTypeDefs_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Transactional::setTransTypeDefs()\r\n//-----------------------------------------------------------------------------\r\nvoid Transactional::setTransTypeDefs(QSharedPointer<QList<QSharedPointer<WireTypeDef> > > newTransTypeDefs)\r\n{\r\n    transTypeDefs_->clear();\r\n    transTypeDefs_ = newTransTypeDefs;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Transactional::getMaxConnections()\r\n//-----------------------------------------------------------------------------\r\nQString Transactional::getMaxConnections() const\r\n{\r\n    return maxConnections_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Transactional::setMaxConnections()\r\n//-----------------------------------------------------------------------------\r\nvoid Transactional::setMaxConnections(QString const& newMaxConnectionsExpression)\r\n{\r\n\tmaxConnections_ = newMaxConnectionsExpression;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Transactional::getMinConnections()\r\n//-----------------------------------------------------------------------------\r\nQString Transactional::getMinConnections() const\r\n{\r\n    return minConnections_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Transactional::setMinConnections()\r\n//-----------------------------------------------------------------------------\r\nvoid Transactional::setMinConnections(QString const& newMinConnectionsExpression)\r\n{\r\n    minConnections_ = newMinConnectionsExpression;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Transactional::getTypeName()\r\n//-----------------------------------------------------------------------------\r\nQString Transactional::getTypeName(QString const& viewName) const\r\n{\r\n    for (QSharedPointer<WireTypeDef> transactionalTypeDefinition : *transTypeDefs_)\r\n    {\r\n        if (transactionalTypeDefinition->hasView(viewName))\r\n        {\r\n            return transactionalTypeDefinition->getTypeName();\r\n        }\r\n    }\r\n\r\n    return QString();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Transactional::setTypeName()\r\n//-----------------------------------------------------------------------------\r\nvoid Transactional::setTypeName(QString const& typeName, QString const& viewName)\r\n{\r\n    for (QSharedPointer<WireTypeDef> transactionalTypeDefinition : *transTypeDefs_)\r\n    {\r\n        if (viewName.isEmpty() || transactionalTypeDefinition->hasView(viewName))\r\n        {\r\n            transactionalTypeDefinition->setTypeName(typeName);\r\n            return;\r\n        }\r\n    }\r\n\r\n    transTypeDefs_->clear();\r\n\r\n    if (!typeName.isEmpty())\r\n    {\r\n        QSharedPointer<WireTypeDef> newTransactionalTypeDefinition(new WireTypeDef(typeName));\r\n        newTransactionalTypeDefinition->getViewRefs()->append(viewName);\r\n        transTypeDefs_->append(newTransactionalTypeDefinition);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Transactional::hasType()\r\n//-----------------------------------------------------------------------------\r\nbool Transactional::hasType(QString const& viewName) const\r\n{\r\n    return std::any_of(transTypeDefs_->cbegin(), transTypeDefs_->cend(),\r\n        [&viewName](auto const& transactionalTypeDefinition)\r\n        {\r\n            return ((viewName.isEmpty() && !transactionalTypeDefinition->getTypeName().isEmpty()) ||\r\n                (transactionalTypeDefinition->hasView(viewName) &&\r\n                    !transactionalTypeDefinition->getTypeName().isEmpty()));\r\n        });\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Transactional::getTypeDefinition()\r\n//-----------------------------------------------------------------------------\r\nQString Transactional::getTypeDefinition(QString const& typeName) const\r\n{\r\n    for (QSharedPointer<WireTypeDef> transactionalTypeDefinition : *transTypeDefs_)\r\n    {\r\n        if (transactionalTypeDefinition->getTypeName() == typeName)\r\n        {\r\n            return transactionalTypeDefinition->getTypeDefinitions()->value(0, QString());\r\n        }\r\n    }\r\n\r\n    return QString();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Transactional::getTypeDefinitions()\r\n//-----------------------------------------------------------------------------\r\nQStringList Transactional::getTypeDefinitions() const\r\n{\r\n    QStringList typeDefs;\r\n    for (QSharedPointer<WireTypeDef> transactionalTypeDefinition : *transTypeDefs_)\r\n    {\r\n        typeDefs.append(*transactionalTypeDefinition->getTypeDefinitions());\r\n    }\r\n    return typeDefs;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Transactional::setTypeDefinition()\r\n//-----------------------------------------------------------------------------\r\nvoid Transactional::setTypeDefinition(const QString& typeName, const QString& typeDefinition)\r\n{\r\n    for (QSharedPointer<WireTypeDef> transactionalTypeDefinition : *transTypeDefs_)\r\n    {\r\n        if (transactionalTypeDefinition->getTypeName() == typeName)\r\n        {\r\n            QSharedPointer<QStringList> typeDefinitions(new QStringList());\r\n            typeDefinitions->append(typeDefinition);\r\n            transactionalTypeDefinition->setTypeDefinitions(typeDefinitions);\r\n            return;\r\n        }\r\n    }\r\n\r\n    transTypeDefs_->clear();\r\n\r\n    QSharedPointer<WireTypeDef> transactionalTypeDefinition(new WireTypeDef(typeName));\r\n    QSharedPointer<QStringList> typeDefinitions(new QStringList());\r\n    typeDefinitions->append(typeDefinition);\r\n    transactionalTypeDefinition->setTypeDefinitions(typeDefinitions);\r\n    transTypeDefs_->append(transactionalTypeDefinition);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Transactional::hasTypeDefinitions()\r\n//-----------------------------------------------------------------------------\r\nbool Transactional::hasTypeDefinitions() const\r\n{\r\n    return std::any_of(transTypeDefs_->cbegin(), transTypeDefs_->cend(),\r\n        [](auto const& transactionalTypeDefinition)\r\n        {\r\n            return (!transactionalTypeDefinition->getTypeName().isEmpty() ||\r\n                !transactionalTypeDefinition->getTypeDefinitions()->isEmpty());\r\n        });\r\n}\r\n"
  },
  {
    "path": "IPXACTmodels/Component/Transactional.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: Transactional.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 10.09.2015\r\n//\r\n// Description:\r\n// Describes the ipxact:transactional element within component ports.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef TRANSACTIONAL_H\r\n#define TRANSACTIONAL_H\r\n\r\n#include \"WireTypeDef.h\"\r\n\r\n#include <IPXACTmodels/common/Protocol.h>\r\n#include <IPXACTmodels/common/Qualifier.h>\r\n\r\n#include <IPXACTmodels/ipxactmodels_global.h>\r\n\r\n#include <QList>\r\n#include <QString>\r\n#include <QSharedPointer>\r\n\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Describes the ipxact:transactional element within component ports.\r\n//-----------------------------------------------------------------------------\r\nclass IPXACTMODELS_EXPORT Transactional\r\n{\r\n\r\npublic:\r\n\r\n    //! The default constructor.\r\n    Transactional() = default;\r\n\r\n    /*!\r\n     *  Create a copy of the Transactional.\r\n     *\r\n     *    @return A Transactional identical to this.\r\n     */\r\n    Transactional* clone() const;\r\n\r\n\t/*!\r\n\t *  Copy constructor.\r\n\t */\r\n\tTransactional(const Transactional &other);\r\n\r\n\t/*!\r\n\t *  Assignment operator.\r\n\t */\r\n\tTransactional &operator=(const Transactional &other);\r\n\r\n    /*!\r\n     *  The destructor.\r\n     */\r\n    ~Transactional() = default;\r\n\r\n\t/*!\r\n\t *  Get the all logical initiatives allowed settings.\r\n\t *\r\n     *    @return True if the logical initiatives are allowed, false otherwise.\r\n\t */\r\n\tbool getAllLogicalInitiativesAllowed() const;\r\n\r\n\t/*!\r\n\t *  Set the all logical initiatives to allowed or disallowed.\r\n\t *\r\n\t *    @param [in] allow    The new value to be set.\r\n\t */\r\n\tvoid setAllLogicalInitiativesAllowed(bool allow);\r\n\r\n    /*!\r\n     *  Get the initiative.\r\n     *\r\n     *    @return The initiative.\r\n     */\r\n    QString getInitiative() const;\r\n\r\n    /*!\r\n     *  Set the initiative.\r\n     *\r\n     *    @param [in] newInitiative   The new initiative.\r\n     */\r\n    void setInitiative(QString const& newInitiative);\r\n\r\n    /*!\r\n     *  Get the kind.\r\n     *\r\n     *    @return The kind.\r\n     */\r\n    QString getKind() const;\r\n\r\n    /*!\r\n     *  Set the kind.\r\n     *\r\n     *    @param [in] newKind     The kind.\r\n     */\r\n    void setKind(QString const& newKind);\r\n\r\n    /*!\r\n     *  Get the bus width.\r\n     *\r\n     *    @return The bus width.\r\n     */\r\n    QString getBusWidth() const;\r\n\r\n    /*!\r\n     *  Set the bus width.\r\n     *\r\n     *    @param [in] newBusWidth     The new bus width.\r\n     */\r\n    void setBusWidth(QString const& newBusWidth);\r\n\r\n    /*!\r\n     *  Get the transactional qualifier.\r\n     *\r\n     *    @return The qualifier.\r\n     */\r\n    QSharedPointer<Qualifier> getQualifier() const;\r\n\r\n    /*!\r\n     *  Get the protocol.\r\n     *\r\n     *    @return Pointer to a protocol used in this port.\r\n     */\r\n    QSharedPointer<Protocol> getProtocol() const;\r\n\r\n    /*!\r\n     *  Set a protocol for this port.\r\n     *\r\n     *    @param [in] newProtocol     The new protocol.\r\n     */\r\n    void setProtocol(QSharedPointer<Protocol> newProtocol);\r\n\r\n    /*!\r\n     *  Get the transactional type definitions.\r\n     *\r\n     *    @return Pointer to a list containing transactional type definitions.\r\n     */\r\n    QSharedPointer<QList<QSharedPointer<WireTypeDef> > > getTransTypeDef() const;\r\n\r\n    /*!\r\n     *  Set the transactional type definitions.\r\n     *\r\n     *    @param [in] newTransTypeDefs    The new transactional type definitions.\r\n     */\r\n    void setTransTypeDefs(QSharedPointer<QList<QSharedPointer<WireTypeDef> > > newTransTypeDefs);\r\n\r\n    /*!\r\n     *  Get the maximum number of possible connections.\r\n     *\r\n     *    @return Expression containing the maximum number of connections.\r\n     */\r\n    QString getMaxConnections() const;\r\n\r\n    /*!\r\n     *  Set the maximum number of connections.\r\n     *\r\n     *    @param [in] newMaxConnectionsExpression     Expression containing the maximum number of connections.\r\n     */\r\n    void setMaxConnections(QString const& newMaxConnectionsExpression);\r\n\r\n    /*!\r\n     *  Get the minimum number of connections.\r\n     *\r\n     *    @return The minimum number of connections.\r\n     */\r\n    QString getMinConnections() const;\r\n\r\n    /*!\r\n     *  Set the minimum number of connections.\r\n     *\r\n     *    @param [in] newMinConnectionsExpression     The new expression for minimum connections.\r\n     */\r\n    void setMinConnections(QString const& newMinConnectionsExpression);\r\n\r\n    /*!\r\n     *  Get a type name associated with a view name.\r\n     *\r\n     *    @param [in] viewName    The associated view name.\r\n     *\r\n     *    @return The type name.\r\n     */\r\n    QString getTypeName(QString const& viewName) const;\r\n\r\n    /*!\r\n     *  Set a type name.\r\n     *\r\n     *    @param [in] typeName    The new type name.\r\n     *    @param [in] viewName    The view name associated with the new type name.\r\n     */\r\n    void setTypeName(QString const& typeName, QString const& viewName);\r\n\r\n    /*!\r\n     *  Check if a type is contained.\r\n     *\r\n     *    @param [in] viewName    View name associated with the type.\r\n     *\r\n     *    @return True, if a type is contained, false otherwise.\r\n     */\r\n    bool hasType(QString const& viewName) const;\r\n\r\n    /*!\r\n     *  Get a type definition.\r\n     *\r\n     *    @param [in] typeName    The name of the type.\r\n     *\r\n     *    @return Type definition associated with the given type name.\r\n     */\r\n    QString getTypeDefinition(QString const& typeName) const;\r\n\r\n    /*!\r\n     *  Get the type definitions.\r\n     *\r\n     *    @return A list of type definitions.\r\n     */\r\n    QStringList getTypeDefinitions() const;\r\n    \r\n    /*!\r\n     *  Set a type definition.\r\n     *\r\n     *    @param [in] typeName        The type name associated with the definition.\r\n     *    @param [in] typeDefinition  The new type definition.\r\n     */\r\n    void setTypeDefinition(const QString& typeName, const QString& typeDefinition);\r\n\r\n    /*!\r\n     *  Check if a type definition exists.\r\n     *\r\n     *    @return True, if a type definition exists, false otherwise.\r\n     */\r\n    bool hasTypeDefinitions() const;\r\n\r\nprivate:\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! Defines the allowed logical initiatives.\r\n    bool allLogicalInitiativesAllowed_{ false };\r\n\r\n\t//! Defines the type of access.\r\n    QString initiative_;\r\n\r\n    //! Defines the kind.\r\n    QString kind_;\r\n\r\n    //! Defines the bus width.\r\n    QString busWidth_;\r\n\r\n    //! The transactional qualifier.\r\n    QSharedPointer<Qualifier> qualifier_{ new Qualifier };\r\n\r\n    //! Defines the used protocol\r\n    QSharedPointer<Protocol> protocol_{ nullptr };\r\n\r\n\t//! Defines the port type expressed in the default language for this port.\r\n    WireTypeDef::List transTypeDefs_{ new QList<QSharedPointer<WireTypeDef> >() };\r\n\r\n    //! Defines the maximum number of connections.\r\n    QString maxConnections_;\r\n\r\n    //! Defines the minimum number of connections.\r\n    QString minConnections_;\r\n};\r\n\r\n#endif // TRANSACTIONAL_H\r\n"
  },
  {
    "path": "IPXACTmodels/Component/TransparentBridge.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: TransparentBridge.h\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Esko Pekkarinen\n// Date: 07.08.2017\n//\n// Description:\n// Implementation of ipxact:transparentBridge element.\n//-----------------------------------------------------------------------------\n\n#include \"TransparentBridge.h\"\n\n//-----------------------------------------------------------------------------\n// Function: TransparentBridge::TransparentBridge()\n//-----------------------------------------------------------------------------\nTransparentBridge::TransparentBridge(QString const& masterInterfaceRef):\n    Extendable(),\n    initiatorRef_(masterInterfaceRef)\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: TransparentBridge::setMasterRef()\n//-----------------------------------------------------------------------------\nvoid TransparentBridge::setMasterRef(QString const& interfaceName)\n{\n    setInitiatorRef(interfaceName);\n}\n\n//-----------------------------------------------------------------------------\n// Function: TransparentBridge::getMasterRef()\n//-----------------------------------------------------------------------------\nQString TransparentBridge::getMasterRef() const\n{\n    return getInitiatorRef();\n}\n\n//-----------------------------------------------------------------------------\n// Function: TransparentBridge::getMasterRef()\n//-----------------------------------------------------------------------------\nvoid TransparentBridge::setInitiatorRef(QString const& interfaceName)\n{\n    initiatorRef_ = interfaceName;\n}\n\n//-----------------------------------------------------------------------------\n// Function: TransparentBridge::getMasterRef()\n//-----------------------------------------------------------------------------\nQString TransparentBridge::getInitiatorRef() const\n{\n    return initiatorRef_;\n}\n\n//-----------------------------------------------------------------------------\n// Function: TransparentBridge::setIsPresent()\n//-----------------------------------------------------------------------------\nvoid TransparentBridge::setIsPresent(QString const& presence)\n{\n    isPresent_ = presence;\n}\n\n//-----------------------------------------------------------------------------\n// Function: TransparentBridge::getIsPresent()\n//-----------------------------------------------------------------------------\nQString TransparentBridge::getIsPresent() const\n{\n    return isPresent_;\n}\n"
  },
  {
    "path": "IPXACTmodels/Component/TransparentBridge.h",
    "content": "//-----------------------------------------------------------------------------\n// File: TransparentBridge.h\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Esko Pekkarinen\n// Date: 07.08.2017\n//\n// Description:\n// Implementation of ipxact:transparentBridge element.\n//-----------------------------------------------------------------------------\n\n#ifndef TRANSPARENTBRIDGE_H\n#define TRANSPARENTBRIDGE_H\n\n#include <IPXACTmodels/ipxactmodels_global.h>\n\n#include <IPXACTmodels/common/Extendable.h>\n\n#include <QString>\n\n//-----------------------------------------------------------------------------\n//! Implementation of ipxact:transparentBridge element.\n//-----------------------------------------------------------------------------\nclass IPXACTMODELS_EXPORT TransparentBridge : public Extendable\n{\npublic:\n\n\t/*!\n\t *  The constructor.\n\t *\n\t *    @param [in] masterInterfaceRef   Name reference to the bridged master interface.\n\t */\n\texplicit TransparentBridge(QString const& masterInterfaceRef = QString());\n    \t\n\t//! The destructor.\n\t~TransparentBridge() = default;\n\n    /*!\n     *  Set the master interface reference.\n     *\n     *    @param [in] interfaceName   The master interface name to reference.\n     */\n    void setMasterRef(QString const& interfaceName);\n\n    /*!\n     *  Get the referenced master interface name.\n     *\n     *    @return The name of the referenced master interface.\n     */\n    QString getMasterRef() const;\n\n    /*!\n     *  Set the initiator interface reference.\n     *\n     *    @param [in] interfaceName   The initiator interface name to reference.\n     */\n    void setInitiatorRef(QString const& interfaceName);\n\n    /*!\n     *  Get the referenced initiator interface name.\n     *\n     *    @return The name of the referenced initiator interface.\n     */\n    QString getInitiatorRef() const;\n\n    /*!\n     *  Sets the presence for the transparent bridge.\n     *\n     *    @param [in] presence   The presence to set.\n     */\n    void setIsPresent(QString const& presence);\n\n    /*!\n     *  Get the presence of the transparent bridge.\n     *\n     *    @return The presence of the transparent bridge.\n     */\n    QString getIsPresent() const;\n  \nprivate:\n   \n    //! Reference to an initiator interface.\n    QString initiatorRef_;\n\n    //! Presence of the transparent bridge.\n    QString isPresent_;\n\n};\n\n#endif // TRANSPARENTBRIDGE_H\n"
  },
  {
    "path": "IPXACTmodels/Component/View.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: View.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 03.09.2015\r\n//\r\n// Description:\r\n// Describes the ipxact:view element of a component.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"View.h\"\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: View::View()\r\n//-----------------------------------------------------------------------------\r\nView::View(QString const& name /* = QString() */, QString const& displayName /* = QString() */,\r\n    QString const& description /* = QString() */) :\r\nNameGroup(name, displayName, description),\r\nExtendable(),\r\nisPresent_(),\r\nenvIdentifiers_(new QList<QSharedPointer<EnvironmentIdentifier> >),\r\ncomponentInstantiationRef_(),\r\ndesignInstantiationRef_(),\r\ndesignConfigurationInstantiationRef_()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: View::View()\r\n//-----------------------------------------------------------------------------\r\nView::View(const View &other):\r\nNameGroup(other),\r\nExtendable(other),\r\nisPresent_(other.isPresent_),\r\nenvIdentifiers_(other.envIdentifiers_),\r\ncomponentInstantiationRef_(other.componentInstantiationRef_),\r\ndesignInstantiationRef_(other.designInstantiationRef_),\r\ndesignConfigurationInstantiationRef_(other.designConfigurationInstantiationRef_)\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: View::operator=()\r\n//-----------------------------------------------------------------------------\r\nView& View::operator=(const View &other)\r\n{\r\n    if (this != &other)\r\n    {\r\n        NameGroup::operator=(other);\r\n        Extendable::operator=(other);\r\n        isPresent_ = other.isPresent_;\r\n        envIdentifiers_ = other.envIdentifiers_;\r\n        componentInstantiationRef_ = other.componentInstantiationRef_;\r\n        designInstantiationRef_ = other.designInstantiationRef_;\r\n        designConfigurationInstantiationRef_ = other.designConfigurationInstantiationRef_;\r\n    }\r\n\r\n    return *this;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: View::~View()\r\n//-----------------------------------------------------------------------------\r\nView::~View()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: View::getEnvIdentifiers()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<QList<QSharedPointer<View::EnvironmentIdentifier> > > View::getEnvIdentifiers() const\r\n{\r\n\treturn envIdentifiers_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: View::addEnvIdentifier()\r\n//-----------------------------------------------------------------------------\r\nvoid View::addEnvIdentifier(QSharedPointer<View::EnvironmentIdentifier> envIdentifier)\r\n{\r\n\tenvIdentifiers_->append(envIdentifier);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: View::hasEnvIdentifier()\r\n//-----------------------------------------------------------------------------\r\nbool View::hasEnvIdentifier(QSharedPointer<View::EnvironmentIdentifier> envIdentifier) const\r\n{\r\n\tforeach(QSharedPointer<View::EnvironmentIdentifier> identifier, *envIdentifiers_)\r\n\t{\r\n\t\tif (identifier->language == envIdentifier->language &&\r\n\t\t\tidentifier->tool == envIdentifier->tool &&\r\n\t\t\tidentifier->vendorSpecific == envIdentifier->vendorSpecific)\r\n\t\t{\r\n\t\t\treturn true;\r\n\t\t}\r\n\t}\r\n\r\n\treturn false;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: View::getIsPresent()\r\n//-----------------------------------------------------------------------------\r\nQString View::getIsPresent() const\r\n{\r\n    return isPresent_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: View::setIsPresent()\r\n//-----------------------------------------------------------------------------\r\nvoid View::setIsPresent(QString const& newIsPresent)\r\n{\r\n    isPresent_ = newIsPresent;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: View::getComponentInstantiationRef()\r\n//-----------------------------------------------------------------------------\r\nQString View::getComponentInstantiationRef() const\r\n{\r\n    return componentInstantiationRef_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: View::setComponentInstantiationRef()\r\n//-----------------------------------------------------------------------------\r\nvoid View::setComponentInstantiationRef(QString const& newInstantiationRef)\r\n{\r\n    componentInstantiationRef_ = newInstantiationRef;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: View::getDesignInstantiationRef()\r\n//-----------------------------------------------------------------------------\r\nQString View::getDesignInstantiationRef() const\r\n{\r\n    return designInstantiationRef_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: View::setDesignInstantiationRef()\r\n//-----------------------------------------------------------------------------\r\nvoid View::setDesignInstantiationRef(QString const& newInstantiationRef)\r\n{\r\n    designInstantiationRef_ = newInstantiationRef;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: View::getDesignConfigurationInstantiationRef()\r\n//-----------------------------------------------------------------------------\r\nQString View::getDesignConfigurationInstantiationRef() const\r\n{\r\n    return designConfigurationInstantiationRef_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: View::setDesignConfiguraitonInstantiationRef()\r\n//-----------------------------------------------------------------------------\r\nvoid View::setDesignConfigurationInstantiationRef(QString const& newInstantiationRef)\r\n{\r\n    designConfigurationInstantiationRef_ = newInstantiationRef;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: View::isHierarchical()\r\n//-----------------------------------------------------------------------------\r\nbool View::isHierarchical() const\r\n{\r\n    return !designInstantiationRef_.isEmpty() || !designConfigurationInstantiationRef_.isEmpty();\r\n}"
  },
  {
    "path": "IPXACTmodels/Component/View.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: View.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 03.09.2015\r\n//\r\n// Description:\r\n// Describes the ipxact:view element of a component.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef VIEW_H\r\n#define VIEW_H\r\n\r\n#include <IPXACTmodels/common/NameGroup.h>\r\n#include <IPXACTmodels/common/Extendable.h>\r\n\r\n#include <IPXACTmodels/ipxactmodels_global.h>\r\n\r\n#include <QString>\r\n#include <QSharedPointer>\r\n#include <QStringList>\r\n#include <QList>\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Represents the ipxact:view element.\r\n//-----------------------------------------------------------------------------\r\nclass IPXACTMODELS_EXPORT View : public NameGroup, public Extendable\r\n{\r\npublic:\r\n\r\n    using List = QSharedPointer<QList<QSharedPointer<View> > >;\r\n\r\n\t// Represents the ipxact:envIdentifier element, broken down to separate fields.\r\n\tstruct EnvironmentIdentifier\r\n\t{\r\n\t\t// The fields of ipxact:environment element.\r\n\t\tQString language;\r\n\t\tQString tool;\r\n\t\tQString vendorSpecific;\r\n\t\t\r\n        EnvironmentIdentifier(): language(), tool(), vendorSpecific() {}\r\n\r\n        EnvironmentIdentifier(QString const& IdentifierLanguage, QString const& identifierTool = QString(),\r\n            QString const& identifierVendorSpecific = QString()):\r\n        language(IdentifierLanguage), tool(identifierTool), vendorSpecific(identifierVendorSpecific)\r\n        {\r\n\r\n        }\r\n\r\n\t\t/*!\r\n\t\t *  Returns the environment identifier in its ipxact format: language:tool:vendorSpecific.\r\n\t\t */\r\n\t\tQString toString()\r\n\t\t{\r\n\t\t\treturn language + QLatin1Char(':') + tool + QLatin1Char(':') + vendorSpecific;\r\n\t\t}\r\n\t};\r\n\r\n\t/*!\r\n\t *  The constructor.\r\n\t *\r\n\t *    @param [in] name            Name of the view.\r\n\t *    @param [in] displayName     Display name of the view.\r\n\t *    @param [in] description     Description of the view.\r\n\t */\r\n\tView(QString const& name = QString(), QString const& displayName = QString(),\r\n        QString const& description = QString());\r\n\r\n\t/*!\r\n\t *  Copy constructor.\r\n\t */\r\n\tView(const View &other);\r\n\r\n\t/*!\r\n\t *  Assignment operator.\r\n\t */\r\n\tView& operator=(const View &other);\r\n\r\n\t/*!\r\n\t *  The destructor.\r\n\t */\r\n\t~View();\r\n\r\n\t/*!\r\n\t *  Get a list of envIdentifiers.\r\n\t *\r\n     *    @return A list containing the envIdentifiers.\r\n\t */\r\n\tQSharedPointer<QList<QSharedPointer<EnvironmentIdentifier> > > getEnvIdentifiers() const;\r\n\r\n\t/*!\r\n\t *  Add a new envIdentifier for this view.\r\n\t *\r\n\t *    @param [in] envIdentifier   The envIdentifier to add.\r\n\t */\r\n\tvoid addEnvIdentifier(QSharedPointer<EnvironmentIdentifier> envIdentifier);\r\n\t\r\n    /*!\r\n     *  Returns true, if an identifier with the exactly same fields exists within the view.\r\n     */\r\n    bool hasEnvIdentifier(QSharedPointer<EnvironmentIdentifier> envIdentifier) const;\r\n\r\n    /*!\r\n     *  Gets the presence.\r\n     *\r\n     *    @return The presence value.\r\n     */\r\n    QString getIsPresent() const;\r\n\r\n    /*!\r\n     *  Set the presence.\r\n     *\r\n     *    @param [in] newIsPresent    The new presence value.\r\n     */\r\n    void setIsPresent(QString const& newIsPresent);\r\n\r\n    /*!\r\n     *  Get the name of the referenced component instantiation.\r\n     *\r\n     *    @return The name of the referenced component instantiation.\r\n     */\r\n    QString getComponentInstantiationRef() const;\r\n\r\n    /*!\r\n     *  Set a component instantiation reference.\r\n     *\r\n     *    @param [in] newInstantiationRef     Name of the referenced component instantiation.\r\n     */\r\n    void setComponentInstantiationRef(QString const& newInstantiationRef);\r\n\r\n    /*!\r\n     *  Get the name of the referenced design instantiation.\r\n     *\r\n     *    @return The name of the referenced design instantiation.\r\n     */\r\n    QString getDesignInstantiationRef() const;\r\n\r\n    /*!\r\n     *  Set a design instantiation reference.\r\n     *\r\n     *    @param [in] newInstantiationRef     Name of the referenced design instantiation.\r\n     */\r\n    void setDesignInstantiationRef(QString const& newInstantiationRef);\r\n\r\n    /*!\r\n     *  Get the name of the referenced design configuration instantiation.\r\n     *\r\n     *    @return The name of the referenced design configuration instantiation.\r\n     */\r\n    QString getDesignConfigurationInstantiationRef() const;\r\n\r\n    /*!\r\n     *  Set a design configuration instantiation reference.\r\n     *\r\n     *    @param [in] newInstantiationRef     Name of the referenced design configuration instantiation.\r\n     */\r\n    void setDesignConfigurationInstantiationRef(QString const& newInstantiationRef);\r\n\r\n    /*!\r\n     *  Check if the view is hierarchical.\r\n     *\r\n     *    @return True, if the view is hierarchical, false otherwise.\r\n     */\r\n    bool isHierarchical() const;\r\n\r\nprivate:\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! Presence of the view.\r\n    QString isPresent_;\r\n\r\n    //! Designates and qualifies information of deployment in a particular tool environment.\r\n\tQSharedPointer<QList<QSharedPointer<EnvironmentIdentifier> > > envIdentifiers_;\r\n\r\n    //! Name of the referenced component instantiation.\r\n    QString componentInstantiationRef_;\r\n\r\n    //! Name of the referenced design instantiation.\r\n    QString designInstantiationRef_;\r\n\r\n    //! Name of the referenced design configuration instantiation.\r\n    QString designConfigurationInstantiationRef_;\r\n};\r\n\r\n#endif // VIEW_H\r\n"
  },
  {
    "path": "IPXACTmodels/Component/ViewReader.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ViewReader.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 04.09.2015\r\n//\r\n// Description:\r\n// Reader for IP-XACT view element.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"ViewReader.h\"\r\n\r\n#include <IPXACTmodels/common/NameGroupReader.h>\r\n#include <IPXACTmodels/common/CommonItemsReader.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ViewReader::createViewFrom()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<View> ViewReader::createViewFrom(QDomNode const& viewNode, Document::Revision docRevision)\r\n{\r\n    QSharedPointer<View> newView (new View());\r\n\r\n    NameGroupReader::parseNameGroup(viewNode, newView);\r\n\r\n    if (docRevision == Document::Revision::Std14)\r\n    {\r\n        Details::parseIsPresent(viewNode, newView);\r\n    }\r\n    else if (docRevision == Document::Revision::Std22)\r\n    {\r\n        CommonItemsReader::parseVendorExtensions(viewNode, newView);\r\n    }\r\n\r\n    Details::parseEnvIdentifiers(viewNode, newView);\r\n\r\n    Details::parseInstantiationRefs(viewNode, newView);\r\n\r\n    return newView;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ViewReader::Details::parseIsPresent()\r\n//-----------------------------------------------------------------------------\r\nvoid ViewReader::Details::parseIsPresent(QDomNode const& viewNode, QSharedPointer<View> newView)\r\n{\r\n    QString newIsPresent = viewNode.firstChildElement(QStringLiteral(\"ipxact:isPresent\")).firstChild().nodeValue();\r\n    if (!newIsPresent.isEmpty())\r\n    {\r\n        newView->setIsPresent(newIsPresent);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ViewReader::Details::parseEnvIdentifiers()\r\n//-----------------------------------------------------------------------------\r\nvoid ViewReader::Details::parseEnvIdentifiers(QDomNode const& viewNode, QSharedPointer<View> newView)\r\n{\r\n    QDomElement viewElement = viewNode.toElement();\r\n\r\n    if (!viewElement.isNull())\r\n    {\r\n        QDomNodeList envIdentifierNodes = viewElement.elementsByTagName(QStringLiteral(\"ipxact:envIdentifier\"));\r\n\r\n        for (int i = 0; i < envIdentifierNodes.count(); ++i)\r\n        {\r\n\t\t\t// Read an environment identifier, identify its parts by the separator.\r\n\t\t\tQString idString = envIdentifierNodes.at(i).firstChild().nodeValue();\r\n\t\t\tQStringList idTuple = idString.split(QLatin1Char(':'));\r\n\r\n\t\t\t// Assign the parts to a struct.\r\n\t\t\tQSharedPointer<View::EnvironmentIdentifier> identifier( new View::EnvironmentIdentifier );\r\n\r\n\t\t\tif ( idTuple.size() > 0 )\r\n\t\t\t{\r\n\t\t\t\tidentifier->language = idTuple.at(0);\r\n\t\t\t}\r\n\r\n\t\t\tif ( idTuple.size() > 1 )\r\n\t\t\t{\r\n\t\t\t\tidentifier->tool = idTuple.at(1);\r\n\t\t\t}\r\n\r\n\t\t\tif ( idTuple.size() > 2 )\r\n\t\t\t{\r\n\t\t\t\tidentifier->vendorSpecific = idTuple.at(2);\r\n\t\t\t}\r\n\r\n\t\t\t// Append to the view.\r\n            newView->addEnvIdentifier(identifier);\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ViewReader::Details::parseInstantiationRefs()\r\n//-----------------------------------------------------------------------------\r\nvoid ViewReader::Details::parseInstantiationRefs(QDomNode const& viewNode, QSharedPointer<View> newView)\r\n{\r\n    QDomElement componentRefNode = viewNode.firstChildElement(QStringLiteral(\"ipxact:componentInstantiationRef\"));\r\n    if (!componentRefNode.isNull())\r\n    {\r\n        newView->setComponentInstantiationRef(componentRefNode.firstChild().nodeValue());\r\n    }\r\n\r\n    QDomElement designRefNode = viewNode.firstChildElement(QStringLiteral(\"ipxact:designInstantiationRef\"));\r\n    if (!designRefNode.isNull())\r\n    {\r\n        newView->setDesignInstantiationRef(designRefNode.firstChild().nodeValue());\r\n    }\r\n\r\n    QDomElement designConfigurationRefNode =\r\n        viewNode.firstChildElement(QStringLiteral(\"ipxact:designConfigurationInstantiationRef\"));\r\n    if (!designConfigurationRefNode.isNull())\r\n    {\r\n        newView->setDesignConfigurationInstantiationRef(designConfigurationRefNode.firstChild().nodeValue());\r\n    }\r\n}\r\n"
  },
  {
    "path": "IPXACTmodels/Component/ViewReader.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ViewReader.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 04.09.2015\r\n//\r\n// Description:\r\n// Reader for IP-XACT view element.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef VIEWREADER_H\r\n#define VIEWREADER_H\r\n\r\n#include \"View.h\"\r\n\r\n#include <IPXACTmodels/ipxactmodels_global.h>\r\n#include <IPXACTmodels/common/Document.h>\r\n\r\n#include <QObject>\r\n#include <QSharedPointer>\r\n#include <QDomNode>\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Reader for IP-XACT view element.\r\n//-----------------------------------------------------------------------------\r\nnamespace ViewReader\r\n{\r\n\r\n    /*!\r\n     *  Creates a new view from a given view node.\r\n     *\r\n     *    @param [in] viewNode    XML description of the view.\r\n     *    @param [in] docRevision The IP-XACT standard revision to comply to.\r\n     *\r\n     *    @return The created view.\r\n     */\r\n    IPXACTMODELS_EXPORT QSharedPointer<View> createViewFrom(QDomNode const& viewNode, Document::Revision docRevision);\r\n\r\n    namespace Details\r\n    {\r\n\r\n        /*!\r\n         *  Reads the presence.\r\n         *\r\n         *    @param [in] viewNode    XML description of the view.\r\n         *    @param [in] newView     The new view item.\r\n         */\r\n        void parseIsPresent(QDomNode const& viewNode, QSharedPointer<View> newView);\r\n\r\n        /*!\r\n         *  Reads the envIdentifiers.\r\n         *\r\n         *    @param [in] viewNode    XML description of the view.\r\n         *    @param [in] newView     The new view item.\r\n         */\r\n        void parseEnvIdentifiers(QDomNode const& viewNode, QSharedPointer<View> newView);\r\n\r\n        /*!\r\n         *  Reads the instantiation references.\r\n         *\r\n         *    @param [in] viewNode    XML description of the view.\r\n         *    @param [in] newView     The new view item.\r\n         */\r\n        void parseInstantiationRefs(QDomNode const& viewNode, QSharedPointer<View> newView);\r\n    }\r\n};\r\n\r\n#endif // VIEWREADER_H"
  },
  {
    "path": "IPXACTmodels/Component/ViewWriter.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ViewWriter.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 04.09.2015\r\n//\r\n// Description:\r\n// Writer for IP-XACT view element.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"ViewWriter.h\"\r\n\r\n#include <IPXACTmodels/common/NameGroupWriter.h>\r\n#include <IPXACTmodels/common/CommonItemsWriter.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ViewWriter::writeView()\r\n//-----------------------------------------------------------------------------\r\nvoid ViewWriter::writeView(QXmlStreamWriter& writer, QSharedPointer<View> view, Document::Revision docRevision)\r\n{\r\n    writer.writeStartElement(QStringLiteral(\"ipxact:view\"));\r\n\r\n    NameGroupWriter::writeNameGroup(writer, view, docRevision);\r\n\r\n    if (docRevision == Document::Revision::Std14)\r\n    {\r\n        Details::writeIsPresent(writer, view);\r\n    }\r\n\r\n    Details::writeEnvIdentifiers(writer, view);\r\n\r\n    Details::writeInstantiationReferences(writer, view);\r\n\r\n    if (docRevision == Document::Revision::Std22)\r\n    {\r\n        CommonItemsWriter::writeVendorExtensions(writer, view);\r\n    }\r\n\r\n    writer.writeEndElement(); // ipxact:view\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ViewWriter::Details::writeIsPresent()\r\n//-----------------------------------------------------------------------------\r\nvoid ViewWriter::Details::writeIsPresent(QXmlStreamWriter& writer, QSharedPointer<View> view)\r\n{\r\n    if (!view->getIsPresent().isEmpty())\r\n    {\r\n        writer.writeTextElement(QStringLiteral(\"ipxact:isPresent\"), view->getIsPresent());\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ViewWriter::Details::writeEnvIdentifiers()\r\n//-----------------------------------------------------------------------------\r\nvoid ViewWriter::Details::writeEnvIdentifiers(QXmlStreamWriter& writer, QSharedPointer<View> view)\r\n{\r\n    for (auto const& identifier : *view->getEnvIdentifiers())\r\n    {\r\n        writer.writeTextElement(QStringLiteral(\"ipxact:envIdentifier\"), identifier->toString());\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ViewWriter::Details::writeInstantiationReferences()\r\n//-----------------------------------------------------------------------------\r\nvoid ViewWriter::Details::writeInstantiationReferences(QXmlStreamWriter& writer, QSharedPointer<View> view)\r\n{\r\n    if (!view->getComponentInstantiationRef().isEmpty())\r\n    {\r\n        writer.writeTextElement(QStringLiteral(\"ipxact:componentInstantiationRef\"), view->getComponentInstantiationRef());\r\n    }\r\n\r\n    if (!view->getDesignInstantiationRef().isEmpty())\r\n    {\r\n        writer.writeTextElement(QStringLiteral(\"ipxact:designInstantiationRef\"), view->getDesignInstantiationRef());\r\n    }\r\n\r\n    if (!view->getDesignConfigurationInstantiationRef().isEmpty())\r\n    {\r\n        writer.writeTextElement(\r\n            QStringLiteral(\"ipxact:designConfigurationInstantiationRef\"), view->getDesignConfigurationInstantiationRef());\r\n    }\r\n}"
  },
  {
    "path": "IPXACTmodels/Component/ViewWriter.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ViewWriter.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 04.09.2015\r\n//\r\n// Description:\r\n// Writer for IP-XACT view element.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef VIEWWRITER_H\r\n#define VIEWWRITER_H\r\n\r\n#include \"View.h\"\r\n\r\n#include <IPXACTmodels/ipxactmodels_global.h>\r\n#include <IPXACTmodels/common/Document.h>\r\n\r\n#include <QXmlStreamWriter>\r\n#include <QObject>\r\n#include <QSharedPointer>\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Writer for IP-XACT view element.\r\n//-----------------------------------------------------------------------------\r\nnamespace ViewWriter\r\n{\r\n\r\n    /*!\r\n     *  Write a view to an XML file.\r\n     *\r\n     *    @param [in] writer       The used xml writer.\r\n     *    @param [in] view         The view to be written.\r\n     *    @param [in] docRevision  The IP-XACT standard revision to comply to.\r\n     */\r\n    IPXACTMODELS_EXPORT void writeView(QXmlStreamWriter& writer, QSharedPointer<View> view, \r\n        Document::Revision docRevision);\r\n\r\n    namespace Details\r\n    {\r\n\r\n        /*!\r\n         *  Writes the presence to an XML file.\r\n         *\r\n         *    @param [in] writer  The used xml writer.\r\n         *    @param [in] view    The view to be written.\r\n         */\r\n        void writeIsPresent(QXmlStreamWriter& writer, QSharedPointer<View> view);\r\n\r\n        /*!\r\n         *  Writes the envIdentifiers to an XML file.\r\n         *\r\n         *    @param [in] writer  The used xml writer.\r\n         *    @param [in] view    The view to be written.\r\n         */\r\n        void writeEnvIdentifiers(QXmlStreamWriter& writer, QSharedPointer<View> view);\r\n\r\n        /*!\r\n         *  Writes the instantiation references to an XML file.\r\n         *\r\n         *    @param [in] writer  The used xml writer.\r\n         *    @param [in] view    The view to be written.\r\n         */\r\n        void writeInstantiationReferences(QXmlStreamWriter& writer, QSharedPointer<View> view);\r\n    }\r\n};\r\n\r\n#endif // VIEWWRITER_H"
  },
  {
    "path": "IPXACTmodels/Component/Wire.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: Wire.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 10.09.2015\r\n//\r\n// Description:\r\n// Describes the ipxact:wire element.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"Wire.h\"\r\n\r\n#include <IPXACTmodels/common/Vector.h>\r\n\r\n#include <IPXACTmodels/utilities/Copy.h>\r\n\r\n#include <QString>\r\n#include <QList>\r\n#include <QObject>\r\n#include <QSharedPointer>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Wire()\r\n//-----------------------------------------------------------------------------\r\nWire::Wire(Wire const& other) : \r\ndirection_(other.direction_),\r\nallLogicalDirectionsAllowed_(other.allLogicalDirectionsAllowed_),\r\nqualifier_(other.qualifier_->clone())\r\n{\r\n    Copy::copyList(other.vectors_, vectors_);\r\n\r\n    Copy::copyList(other.wireTypeDefs_, wireTypeDefs_);\r\n\r\n    if (other.driver_)\r\n    {\r\n        driver_ = QSharedPointer<Driver>(other.driver_->clone());\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Wire::operator=()\r\n//-----------------------------------------------------------------------------\r\nWire& Wire::operator=( const Wire &other )\r\n{\r\n\tif (this != &other)\r\n    {\r\n\t\tdirection_ = other.direction_;\r\n\t\tallLogicalDirectionsAllowed_ = other.allLogicalDirectionsAllowed_;\r\n        qualifier_ = QSharedPointer<Qualifier>(other.qualifier_->clone());\r\n\r\n        vectors_->clear();\r\n        Copy:: copyList(other.vectors_, vectors_);\r\n\r\n        wireTypeDefs_->clear();\r\n        Copy::copyList(other.wireTypeDefs_, wireTypeDefs_);\r\n\r\n        driver_.clear();\r\n        if (other.driver_)\r\n        {\r\n            driver_ = QSharedPointer<Driver>(other.driver_->clone());\r\n        }\r\n\t}\r\n\treturn *this;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Wire::clone()\r\n//-----------------------------------------------------------------------------\r\nWire* Wire::clone() const\r\n{\r\n    return new Wire(*this);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Wire::getDirection()\r\n//-----------------------------------------------------------------------------\r\nDirectionTypes::Direction Wire::getDirection() const\r\n{\r\n    return direction_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Wire::getQualifier()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<Qualifier> Wire::getQualifier() const\r\n{\r\n    return qualifier_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Wire::getVectors()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<QList<Vector> > Wire::getVectors() const\r\n{\r\n    return vectors_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Wire::getWireTypeDefs()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<QList<QSharedPointer<WireTypeDef> > > Wire::getWireTypeDefs() const\r\n{\r\n    return wireTypeDefs_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Wire::setDirection()\r\n//-----------------------------------------------------------------------------\r\nvoid Wire::setDirection(DirectionTypes::Direction direction)\r\n{\r\n\tdirection_ = direction;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Wire::getAllLogicalDirectionsAllowed()\r\n//-----------------------------------------------------------------------------\r\nbool Wire::getAllLogicalDirectionsAllowed() const\r\n{\r\n    return allLogicalDirectionsAllowed_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Wire::setWireTypeDefs()\r\n//-----------------------------------------------------------------------------\r\nvoid Wire::setWireTypeDefs(QSharedPointer<QList<QSharedPointer<WireTypeDef> > > newWireTypeDefs)\r\n{\r\n\twireTypeDefs_ = newWireTypeDefs;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Wire::setAllLogicalDirectionsAllowed()\r\n//-----------------------------------------------------------------------------\r\nvoid Wire::setAllLogicalDirectionsAllowed(bool allow)\r\n{\r\n    allLogicalDirectionsAllowed_ = allow;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Wire::setDefaultDriverValue()\r\n//-----------------------------------------------------------------------------\r\nvoid Wire::setDefaultDriverValue(const QString& defaultDriverValue)\r\n{\r\n    if (driver_.isNull())\r\n    {\r\n        driver_ = QSharedPointer<Driver>(new Driver{});\r\n    }\r\n\r\n    driver_->setDefaultValue(defaultDriverValue);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Wire::getDefaultDriverValue()\r\n//-----------------------------------------------------------------------------\r\nQString Wire::getDefaultDriverValue() const\r\n{\r\n    if (driver_.isNull())\r\n    {\r\n        return QString();\r\n    }\r\n\r\n    return driver_->getDefaultValue();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: wire::setLeftBoundExpression()\r\n//-----------------------------------------------------------------------------\r\nvoid Wire::setVectorLeftBound(QString const& expression)\r\n{\r\n    if (vectors_->isEmpty())\r\n    {\r\n        vectors_->append(Vector(QStringLiteral(\"0\"), QStringLiteral(\"0\")));\r\n    }\r\n\r\n    vectors_->first().setLeft(expression);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: wire::setRightBoundExpression()\r\n//-----------------------------------------------------------------------------\r\nvoid Wire::setVectorRightBound(QString const& expression)\r\n{\r\n    if (vectors_->isEmpty())\r\n    {\r\n        vectors_->append(Vector(QStringLiteral(\"0\"), QStringLiteral(\"0\")));\r\n    }\r\n\r\n    vectors_->first().setRight(expression);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: wire::getLeftBoundExpression()\r\n//-----------------------------------------------------------------------------\r\nQString Wire::getVectorLeftBound() const\r\n{\r\n    if (vectors_->isEmpty())\r\n    {\r\n        return QString();\r\n    }\r\n\r\n    return vectors_->first().getLeft();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: wire::getRightBoundExpression()\r\n//-----------------------------------------------------------------------------\r\nQString Wire::getVectorRightBound() const\r\n{\r\n    if (vectors_->isEmpty())\r\n    {\r\n        return QString();\r\n    }\r\n\r\n    return vectors_->first().getRight();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Wire::setDriver()\r\n//-----------------------------------------------------------------------------\r\nvoid Wire::setDriver(QSharedPointer<Driver> driver)\r\n{\r\n    driver_ = driver;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Wire::getDriver()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<Driver> Wire::getDriver() const\r\n{\r\n    return driver_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Wire::getTypeName()\r\n//-----------------------------------------------------------------------------\r\nQString Wire::getTypeName(QString const& viewName) const\r\n{\r\n    if (wireTypeDefs_)\r\n    {\r\n        for (QSharedPointer<WireTypeDef> wireTypeDefinition : *wireTypeDefs_)\r\n        {\r\n            if (wireTypeDefinition->hasView(viewName))\r\n            {\r\n                return wireTypeDefinition->getTypeName();\r\n            }\r\n        }\r\n    }\r\n\r\n    return QString();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Wire::setTypeName()\r\n//-----------------------------------------------------------------------------\r\nvoid Wire::setTypeName(QString const& typeName, QString const& viewName)\r\n{\r\n    if (wireTypeDefs_)\r\n    {\r\n        for (QSharedPointer<WireTypeDef> wireTypeDefinition : *wireTypeDefs_)\r\n        {\r\n            if (wireTypeDefinition->getViewRefs()->contains(viewName) || viewName.isEmpty())\r\n            {\r\n                wireTypeDefinition->setTypeName(typeName);\r\n                return;\r\n            }\r\n        }\r\n    }\r\n    else\r\n    {\r\n        wireTypeDefs_ = QSharedPointer<QList<QSharedPointer<WireTypeDef> > >(\r\n            new QList<QSharedPointer<WireTypeDef> >());\r\n    }\r\n\r\n    wireTypeDefs_->clear();\r\n\r\n    if (!typeName.isEmpty())\r\n    {\r\n        QSharedPointer<WireTypeDef> newWireTypeDefinition(new WireTypeDef(typeName));\r\n        \r\n        if (!viewName.isEmpty())\r\n        {\r\n            newWireTypeDefinition->getViewRefs()->append(viewName);\r\n        }\r\n        \r\n        wireTypeDefs_->append(newWireTypeDefinition);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Wire::getTypeDefinition()\r\n//-----------------------------------------------------------------------------\r\nQString Wire::getTypeDefinition(QString const& typeName) const\r\n{\r\n    if (wireTypeDefs_)\r\n    {  \r\n        for (QSharedPointer<WireTypeDef> wireTypeDefinition : *wireTypeDefs_)\r\n        {\r\n            if (wireTypeDefinition->getTypeName() == typeName)\r\n            {\r\n                return wireTypeDefinition->getTypeDefinitions()->value(0, QString());\r\n            }\r\n        }\r\n    }\r\n\r\n    return QString();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Wire::getTypeDefinitions()\r\n//-----------------------------------------------------------------------------\r\nQStringList Wire::getTypeDefinitions() const\r\n{\r\n    QStringList typeDefs;\r\n    if (wireTypeDefs_)\r\n    {\r\n        for (QSharedPointer<WireTypeDef> wireTypeDefinition : *wireTypeDefs_)\r\n        {\r\n            for (QString singleDefinition : *wireTypeDefinition->getTypeDefinitions())\r\n            {\r\n                typeDefs.append(singleDefinition);\r\n            }\r\n        }\r\n    }\r\n\treturn typeDefs;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Wire::setTypeDefinition()\r\n//-----------------------------------------------------------------------------\r\nvoid Wire::setTypeDefinition(QString const& typeName, QString const& typeDefinition )\r\n{\r\n    if (wireTypeDefs_)\r\n    {\r\n        for (QSharedPointer<WireTypeDef> wireTypeDefinition : *wireTypeDefs_)\r\n        {\r\n            if (wireTypeDefinition->getTypeName() == typeName)\r\n            {\r\n                QSharedPointer<QStringList> typeDefinitions(new QStringList());\r\n                typeDefinitions->append(typeDefinition);\r\n                wireTypeDefinition->setTypeDefinitions(typeDefinitions);\r\n                return;\r\n            }\r\n        }\r\n    }\r\n    else\r\n    {\r\n        wireTypeDefs_ = QSharedPointer<QList<QSharedPointer<WireTypeDef> > >(\r\n            new QList<QSharedPointer<WireTypeDef> >());\r\n    }\r\n\r\n    wireTypeDefs_->clear();\r\n\r\n    QSharedPointer<WireTypeDef> newWireTypeDefinition(new WireTypeDef(typeName));\r\n    QSharedPointer<QStringList> typeDefinitions(new QStringList());\r\n    typeDefinitions->append(typeDefinition);\r\n    newWireTypeDefinition->setTypeDefinitions(typeDefinitions);\r\n    wireTypeDefs_->append(newWireTypeDefinition);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Wire::hasType()\r\n//-----------------------------------------------------------------------------\r\nbool Wire::hasType(QString const& viewName) const\r\n{\r\n    if (!wireTypeDefs_)\r\n    {\r\n        return false;\r\n    }\r\n\r\n    for (QSharedPointer<WireTypeDef> wireTypeDefinition : *wireTypeDefs_)\r\n    {\r\n\t\tif (!wireTypeDefinition->getTypeName().isEmpty() && \r\n            (viewName.isEmpty() ||  wireTypeDefinition->hasView(viewName) ))\r\n        {\r\n            return true;\r\n\t\t}\r\n\t}\r\n\r\n    return false;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Wire::hasTypeDefinition()\r\n//-----------------------------------------------------------------------------\r\nbool Wire::hasTypeDefinition() const\r\n{\r\n    if (!wireTypeDefs_)\r\n    {\r\n        return false;\r\n    }\r\n\r\n    return std::any_of(wireTypeDefs_->cbegin(), wireTypeDefs_->cend(), [](auto const& typeDefinition)\r\n        {\r\n            return !typeDefinition->getTypeName().isEmpty() || !typeDefinition->getTypeDefinitions()->isEmpty();\r\n        });\r\n}\r\n"
  },
  {
    "path": "IPXACTmodels/Component/Wire.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: Wire.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 09.09.2015\r\n//\r\n// Description:\r\n// Describes the ipxact:wire element.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef WIRE_H\r\n#define WIRE_H\r\n\r\n#include \"Driver.h\"\r\n#include \"WireTypeDef.h\"\r\n\r\n#include <IPXACTmodels/common/DirectionTypes.h>\r\n#include <IPXACTmodels/common/Qualifier.h>\r\n\r\n#include <IPXACTmodels/ipxactmodels_global.h>\r\n\r\n#include <QString>\r\n#include <QList>\r\n#include <QSharedPointer>\r\n#include <QStringList>\r\n#include <QMap>\r\n\r\nclass Vector;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Describes the ipxact:wire element.\r\n//-----------------------------------------------------------------------------\r\nclass IPXACTMODELS_EXPORT Wire\r\n{\r\n\r\npublic:\r\n\r\n    //! The default constructor.\r\n    Wire() noexcept = default;\r\n\r\n    /*!\r\n\t * Copy constructor.\r\n\t */\r\n\tWire(Wire const& other);\r\n\r\n\t/*!\r\n\t *  Assignment operator.\r\n\t */\r\n\tWire &operator=(const Wire &other);\r\n\r\n\t/*!\r\n\t *  Create a copy of the Wire.\r\n\t *\r\n\t *    @return A Wire identical to this.\r\n\t */\r\n\tWire* clone() const;\r\n\r\n    /* The destructor.\r\n     */\r\n    ~Wire() = default;\r\n\r\n\t/*!\r\n\t *  Get the value of all logical directions allowed element.\r\n\t *\r\n     *    @return True if all the logical directions are allowed, false otherwise.\r\n\t */\r\n\tbool getAllLogicalDirectionsAllowed() const;\r\n\r\n\t/*!\r\n\t *  Get the direction of the port.\r\n\t *\r\n     *    @return Enum direction specifying the port direction.\r\n\t */\r\n\tDirectionTypes::Direction getDirection() const;\r\n\r\n\t/*!\r\n\t *  Get the qualifier of the port.\r\n\t *\r\n\t *    @return The wire port qualifier.\r\n\t */\r\n\tQSharedPointer<Qualifier> getQualifier() const;\r\n\r\n\t/*!\r\n     *  Get the vectors element of this port.\r\n     *\r\n     *    @return The vectors of the wire.\r\n     */\r\n\tQSharedPointer<QList<Vector> > getVectors() const;\r\n\r\n    /*!\r\n     *  Get the list of this port's wire type definitions.\r\n     *\r\n     *    @return Pointer to a list containing wire type definitions.\r\n     */\r\n    QSharedPointer<QList<QSharedPointer<WireTypeDef> > > getWireTypeDefs() const;\r\n\r\n\t/*!\r\n\t *  Allow / disallow all logical directions allowed value for this port.\r\n\t *\r\n\t *    @param [in] allow     The allowed status.\r\n\t */\r\n\tvoid setAllLogicalDirectionsAllowed(bool allow);\r\n\r\n\t/*!\r\n\t *  Set the direction of this port.\r\n\t *\r\n\t *    @param [in] direction   The new direction.\r\n\t */\r\n\tvoid setDirection(DirectionTypes::Direction direction);\r\n\r\n    /*!\r\n     *  Set the wire type definitions.\r\n     *\r\n     *    @param [in] newWireTypeDefs     The new wire type definitions.\r\n     */\r\n    void setWireTypeDefs(QSharedPointer<QList<QSharedPointer<WireTypeDef> > > newWireTypeDefs);\r\n\r\n\t/*!\r\n\t *  Get the default driver value for the wire.\r\n\t *\r\n     *    @return The default value.\r\n\t */\r\n\tQString getDefaultDriverValue() const;\r\n\r\n\t/*!\r\n\t *  Set the default driver value.\r\n\t *\r\n\t *    @param [in] defaultDriverValue  The new default value.\r\n\t */\r\n\tvoid setDefaultDriverValue(const QString& defaultDriverValue);\r\n\r\n    /*!\r\n     *  Set the left bound expression.\r\n     *\r\n     *    @param [in] expression   The expression.\r\n     */\r\n    void setVectorLeftBound(QString const& expression);\r\n\r\n    /*!\r\n     *  Set the right bound expression.\r\n     *\r\n     *    @param [in] expression   The expression.\r\n     */\r\n    void setVectorRightBound(QString const& expression);\r\n\r\n    /*!\r\n     *  Get the left bound expression.\r\n     *\r\n     *    @return     The expression.\r\n     */\r\n    QString getVectorLeftBound() const;\r\n\r\n    /*!\r\n     *  Get the right bound expression.\r\n     *\r\n     *    @return     The expression.\r\n     */\r\n    QString getVectorRightBound() const;\r\n\r\n\tvoid setDriver(QSharedPointer<Driver> driver);\r\n\r\n\tQSharedPointer<Driver> getDriver() const;\r\n\r\n\t/*!\r\n\t *  Get the type name of the port for a given view.\r\n\t *\r\n\t *    @param [in] viewName    The name of the used view.\r\n     *\r\n     *    @return The required type name.\r\n\t */\r\n\tQString getTypeName(const QString& viewName = QString()) const;\r\n\r\n\t/*!\r\n\t *  Check if the wire has a type name in given view.\r\n\t *\r\n\t *    @param [in] viewName    The name of the view that's type is searched for.\r\n     *\r\n     *    @return True, if a type is found, false otherwise.\r\n\t */\r\n\tbool hasType(const QString& viewName = QString()) const;\r\n\r\n\t/*!\r\n\t *  Check if the port has a type or type definition.\r\n     *\r\n\t *    @return True, if either the port type name or type definition are defined.\r\n\t */\r\n\tbool hasTypeDefinition() const;\r\n\r\n\t/*!\r\n\t *  Set the type name for the port in a given view.\r\n\t *\r\n\t *    @param [in] typeName    The name of the type.\r\n\t *    @param [in] viewName    The name of the view used for this type.\r\n\t */\r\n\tvoid setTypeName(const QString& typeName, const QString& viewName = QString());\r\n\r\n\t/*!\r\n\t *  Get the type definition of the given type name.\r\n\t *\r\n\t *    @param [in] typeName    The name of the type that's type definition is searched for.\r\n     *\r\n     *    @return The required type definition.\r\n\t */\r\n\tQString getTypeDefinition(const QString& typeName) const;\r\n\r\n\t/*!\r\n\t *  Get the type definition.\r\n\t *\r\n     *    @return A list containing the type definition.\r\n\t */\r\n\tQStringList getTypeDefinitions() const;\r\n\r\n\t/*!\r\n\t *  Set the type definition of the given type name.\r\n\t *\r\n\t *    @param [in] typeName        Identifies the type definition.\r\n\t *    @param [in] typeDefinition  The new type definition.\r\n\t */\r\n\tvoid setTypeDefinition(const QString& typeName, const QString& typeDefinition);\r\n\r\nprivate:\r\n\r\n    //! The direction of the port.\r\n\tDirectionTypes::Direction direction_{ DirectionTypes::DIRECTION_INVALID };\r\n    \r\n\t//! Defines whether the port may be mapped to a port in an abstraction definition with a different direction.\r\n    bool allLogicalDirectionsAllowed_{ false };\r\n\r\n\t//! The wire qualifier.\r\n\tQSharedPointer<Qualifier> qualifier_{ new Qualifier };\r\n\r\n    //! Determines the vector qualities of the port.\r\n\tQSharedPointer<QList<Vector> > vectors_{ new QList<Vector>() };\r\n\r\n    //! Specifies a driver for this port.\r\n\t//! Multiple drivers not supported.\r\n\tQSharedPointer<Driver> driver_{ nullptr };\r\n\r\n    //! Describes the ports type as defined bu the implementation.\r\n    WireTypeDef::List wireTypeDefs_{ new QList<QSharedPointer<WireTypeDef> > };\r\n\r\n    //! DomainTypeDefs not supported.\r\n\r\n    //! SignalTypeDefs not supported.\r\n\t \r\n    //! ConstraintSets not supported.\r\n\r\n    //! PowerConstraints not supported.\r\n};\r\n\r\n#endif // WIRE_H\r\n"
  },
  {
    "path": "IPXACTmodels/Component/WireTypeDef.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: WireTypeDef.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 10.09.2015\r\n//\r\n// Description:\r\n// Describes the ipxact:wireTypeDef element.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"WireTypeDef.h\"\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: WireTypeDef::WireTypeDef()\r\n//-----------------------------------------------------------------------------\r\nWireTypeDef::WireTypeDef(const QString& typeName) :\r\ntypeName_(typeName)\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: WireTypeDef::WireTypeDef()\r\n//-----------------------------------------------------------------------------\r\nWireTypeDef::WireTypeDef(const WireTypeDef& other) :\r\ntypeName_(other.typeName_),\r\nconstrained_(other.constrained_)\r\n{\r\n    copyTypeDefinitions(*other.typeDefinitions_);\r\n    copyViewNameReferences(*other.viewNameRefs_);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: WireTypeDef::operator=()\r\n//-----------------------------------------------------------------------------\r\nWireTypeDef& WireTypeDef::operator=(const WireTypeDef& other)\r\n{\r\n    if (this != &other)\r\n    {\r\n        typeName_ = other.typeName_;\r\n        constrained_ = other.constrained_;\r\n\r\n        typeDefinitions_->clear();\r\n        copyTypeDefinitions(*other.typeDefinitions_);\r\n\r\n        viewNameRefs_->clear();\r\n        copyViewNameReferences(*other.viewNameRefs_);\r\n    }\r\n\r\n    return *this;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: WireTypeDef::hasView()\r\n//-----------------------------------------------------------------------------\r\nbool WireTypeDef::hasView(QString const& viewName) const\r\n{\r\n    return (viewName.isEmpty() && viewNameRefs_->isEmpty()) || viewNameRefs_->contains(viewName);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: WireTypeDef::getTypeName()\r\n//-----------------------------------------------------------------------------\r\nQString WireTypeDef::getTypeName() const\r\n{\r\n    return typeName_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: WireTypeDef::setTypeName()\r\n//-----------------------------------------------------------------------------\r\nvoid WireTypeDef::setTypeName(QString const& newTypeName)\r\n{\r\n    typeName_ = newTypeName;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: WireTypeDef::isConstrained()\r\n//-----------------------------------------------------------------------------\r\nbool WireTypeDef::isConstrained() const\r\n{\r\n    return constrained_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: WireTypeDef::setConstrained()\r\n//-----------------------------------------------------------------------------\r\nvoid WireTypeDef::setConstrained(bool constrainedStatus)\r\n{\r\n    constrained_ = constrainedStatus;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: WireTypeDef::getTypeDefinitions()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<QStringList> WireTypeDef::getTypeDefinitions() const\r\n{\r\n    return typeDefinitions_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: WireTypeDef::setTypeDefinitions()\r\n//-----------------------------------------------------------------------------\r\nvoid WireTypeDef::setTypeDefinitions(QSharedPointer<QStringList> newTypeDefinitions)\r\n{\r\n    typeDefinitions_ = newTypeDefinitions;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: WireTypeDef::getViewRefs()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<QStringList> WireTypeDef::getViewRefs() const\r\n{\r\n    return viewNameRefs_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: WireTypeDef::setViewRefs()\r\n//-----------------------------------------------------------------------------\r\nvoid WireTypeDef::setViewRefs(QSharedPointer<QStringList> newViewRefs)\r\n{\r\n    viewNameRefs_ = newViewRefs;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: WireTypeDef::isEmpty()\r\n//-----------------------------------------------------------------------------\r\nbool WireTypeDef::isEmpty() const\r\n{\r\n    return typeName_.isEmpty() && typeDefinitions_->isEmpty() && viewNameRefs_->isEmpty();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: WireTypeDef::copyTypeDefinitions()\r\n//-----------------------------------------------------------------------------\r\nvoid WireTypeDef::copyTypeDefinitions(QStringList const& newTypeDefinitions)\r\n{\r\n    for (auto const& definition : newTypeDefinitions)\r\n    {\r\n        typeDefinitions_->append(definition);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: WireTypeDef::copyViewNameReferences()\r\n//-----------------------------------------------------------------------------\r\nvoid WireTypeDef::copyViewNameReferences(QStringList const& newViewReferences)\r\n{\r\n    for (auto const& viewReference : newViewReferences)\r\n    {\r\n        viewNameRefs_->append(viewReference);\r\n    }\r\n}\r\n"
  },
  {
    "path": "IPXACTmodels/Component/WireTypeDef.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: WireTypeDef.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 10.09.2015\r\n//\r\n// Description:\r\n// Describes the ipxact:wireTypeDef element.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef WIRETYPEDEF_H\r\n#define WIRETYPEDEF_H\r\n\r\n#include <IPXACTmodels/ipxactmodels_global.h>\r\n\r\n#include <QString>\r\n#include <QStringList>\r\n#include <QSharedPointer>\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Describes the ipxact:wireTypeDef element.\r\n//-----------------------------------------------------------------------------\r\nclass IPXACTMODELS_EXPORT WireTypeDef\r\n{\r\n\r\npublic:\r\n\r\n    using List = QSharedPointer<QList<QSharedPointer<WireTypeDef> > >;\r\n\r\n    /*!\r\n     *  The constructor.\r\n     *\r\n     *    @param [in] typeName        The type name for the wire type definition.\r\n     */\r\n    explicit WireTypeDef(const QString& typeName = QString());\r\n\r\n    /*!\r\n     *  The copy constructor.\r\n     */\r\n    WireTypeDef(const WireTypeDef& other);\r\n       \r\n    /*!\r\n     *  The move constructor.\r\n     */\r\n    WireTypeDef(WireTypeDef&& other) = default;\r\n\r\n    /*!\r\n     *  Assignment operator.\r\n     */\r\n    WireTypeDef& operator=(const WireTypeDef& other);\r\n\r\n    /*!\r\n     *  Move assignment operator.\r\n     */\r\n    WireTypeDef& operator=(WireTypeDef&& other) = default;\r\n\r\n    /*!\r\n     *  The destructor.\r\n     */\r\n    ~WireTypeDef() = default;\r\n\r\n    /*!\r\n     *  Check if a wire type definition has been determined for a given view.\r\n     *\r\n     *    @param [in] viewName    The name of the view to search.\r\n     *\r\n     *    @return True, if the view is found within a view name reference.\r\n     */\r\n    bool hasView(QString const& viewName) const;\r\n\r\n    /*!\r\n     *  Get the type name.\r\n     *\r\n     *    @return The type name.\r\n     */\r\n    QString getTypeName() const;\r\n\r\n    /*!\r\n     *  Set the type name.\r\n     *\r\n     *    @param [in] newTypeName     The new type name.\r\n     */\r\n    void setTypeName(QString const& newTypeName);\r\n\r\n    /*!\r\n     *  Check if the number of bits in the type declaration is fixed.\r\n     *\r\n     *    @return True, if the number of bits is fixed, false otherwise.\r\n     */\r\n    bool isConstrained() const;\r\n\r\n    /*!\r\n     *  Set the number of bits in the type declaration to be fixed / not fixed.\r\n     *\r\n     *    @param [in] constrainedStatus   The new status.\r\n     */\r\n    void setConstrained(bool constrainedStatus);\r\n\r\n    /*!\r\n     *  Get the type definitions.\r\n     *\r\n     *    @return A list of type definitions.\r\n     */\r\n    QSharedPointer<QStringList> getTypeDefinitions() const;\r\n\r\n    /*!\r\n     *  Set the type definitions.\r\n     *\r\n     *    @param [in] newTypeDefinitions  A list of new type definitions.\r\n     */\r\n    void setTypeDefinitions(QSharedPointer<QStringList> newTypeDefinitions);\r\n\r\n    /*!\r\n     *  Get the view references.\r\n     *\r\n     *    @return A list of view references.\r\n     */\r\n    QSharedPointer<QStringList> getViewRefs() const;\r\n\r\n    /*!\r\n     *  Set the view references.\r\n     *\r\n     *    @param [in] newViewRefs     A new list of view references.\r\n     */\r\n    void setViewRefs(QSharedPointer<QStringList> newViewRefs);\r\n\r\n    /*!\r\n     *  Checks if all the fields are empty.\r\n     *\r\n     *    @return True, if all the type definition fields are empty, otherwise false. \r\n     */\r\n    bool isEmpty() const;\r\n\r\nprivate:\r\n\r\n    /*!\r\n     *  Copy the type definitions.\r\n     *\r\n     *    @param [in] newTypeDefinitions  List of new type definitions.\r\n     */\r\n    void copyTypeDefinitions(QStringList const& newTypeDefinitions);\r\n\r\n    /*!\r\n     *  Copy the view references.\r\n     *\r\n     *    @param [in] newViewReferences   List of new view references.\r\n     */\r\n    void copyViewNameReferences(QStringList const& newViewReferences);\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! Defines the name of the type for the port\r\n    QString typeName_;\r\n\r\n    //! Indicates whether or not the number of bits in the type declaration is fixed or not.\r\n    bool constrained_{ false };\r\n\r\n    //! Contains language specific reference to where given type is actually defined.\r\n    QSharedPointer<QStringList> typeDefinitions_{ new QStringList() };\r\n\r\n    //! Indicates the view or views in which this type definition applies.\r\n    QSharedPointer<QStringList> viewNameRefs_{ new QStringList() };\r\n};\r\n\r\n#endif // WIRETYPEDEF_H\r\n"
  },
  {
    "path": "IPXACTmodels/Component/WriteValueConstraint.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: WriteValueConstraint.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 24.09.2015\r\n//\r\n// Description:\r\n// Describes the ipxact:writeValueConstraint element.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"WriteValueConstraint.h\"\r\n\r\nnamespace\r\n{\r\n    QString const WRITE_AS_READ_TEXT = QLatin1String(\"Write as read\");\r\n    QString const ENUM_VALUES_TEXT = QLatin1String(\"Use enumerated values\");\r\n    QString const MIN_MAX_LIMITS_TEXT = QLatin1String(\"Set minimum and maximum limits\");\r\n    QString const NO_CONSTRAINTS_TEXT = QLatin1String(\"No constraints\");\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: WriteValueConstraint::WriteValueConstraint()\r\n//-----------------------------------------------------------------------------\r\nWriteValueConstraint::WriteValueConstraint():\r\ntype_(WriteValueConstraint::TYPE_COUNT),\r\nwriteAsRead_(false),\r\nuseEnumValues_(false),\r\nminimum_(),\r\nmaximum_()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: WriteValueConstraint::WriteValueConstraint()\r\n//-----------------------------------------------------------------------------\r\nWriteValueConstraint::WriteValueConstraint(WriteValueConstraint const& other):\r\ntype_(other.type_),\r\nwriteAsRead_(other.writeAsRead_),\r\nuseEnumValues_(other.useEnumValues_),\r\nminimum_(other.minimum_),\r\nmaximum_(other.maximum_)\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: WriteValueConstraint::~WriteValueConstraint()\r\n//-----------------------------------------------------------------------------\r\nWriteValueConstraint::~WriteValueConstraint()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: WriteValueConstraint::operator=()\r\n//-----------------------------------------------------------------------------\r\nWriteValueConstraint& WriteValueConstraint::operator=(WriteValueConstraint const& other)\r\n{\r\n    if (&other != this)\r\n    {\r\n        type_ = other.type_;\r\n\t\twriteAsRead_ = other.writeAsRead_;\r\n\t\tuseEnumValues_ = other.useEnumValues_;\r\n\t\tminimum_ = other.minimum_;\r\n\t\tmaximum_ = other.maximum_;\r\n\t}\r\n\treturn *this;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: WriteValueConstraint::getType()\r\n//-----------------------------------------------------------------------------\r\nWriteValueConstraint::Type WriteValueConstraint::getType() const\r\n{\r\n    return type_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: WriteValueConstraint::setType()\r\n//-----------------------------------------------------------------------------\r\nvoid WriteValueConstraint::setType(WriteValueConstraint::Type newType )\r\n{\r\n    type_ = newType;\r\n\r\n    writeAsRead_ = false;\r\n    useEnumValues_ = true;\r\n    minimum_ = QString();\r\n    maximum_ = QString();\r\n\r\n    if (type_ == WriteValueConstraint::WRITE_AS_READ)\r\n    {\r\n        writeAsRead_ = true;\r\n    }\r\n    else if(type_ == WriteValueConstraint::USE_ENUM)\r\n    {\r\n        useEnumValues_ = true;\r\n    }\r\n    else if (type_ == WriteValueConstraint::MIN_MAX)\r\n    {\r\n        minimum_ = QString();\r\n        maximum_ = QString();\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: WriteValueConstraint::getMinimum()\r\n//-----------------------------------------------------------------------------\r\nQString WriteValueConstraint::getMinimum() const\r\n{\r\n    if (type_ == WriteValueConstraint::MIN_MAX)\r\n    {\r\n        return minimum_;\r\n    }\r\n    else\r\n    {\r\n        return QString();\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: WriteValueConstraint::setMinimum()\r\n//-----------------------------------------------------------------------------\r\nvoid WriteValueConstraint::setMinimum(QString const& newMinimum)\r\n{\r\n    useEnumValues_ = false;\r\n    writeAsRead_ = false;\r\n\r\n    type_ = WriteValueConstraint::MIN_MAX;\r\n    minimum_ = newMinimum;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: WriteValueConstraint::getMaximum()\r\n//-----------------------------------------------------------------------------\r\nQString WriteValueConstraint::getMaximum() const\r\n{\r\n    if (type_ == WriteValueConstraint::MIN_MAX)\r\n    {\r\n        return maximum_;\r\n    }\r\n    else\r\n    {\r\n        return QString();\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: WriteValueConstraint::setMaximum()\r\n//-----------------------------------------------------------------------------\r\nvoid WriteValueConstraint::setMaximum(QString const& newMaximum)\r\n{\r\n    useEnumValues_ = false;\r\n    writeAsRead_ = false;\r\n\r\n    type_ = WriteValueConstraint::MIN_MAX;\r\n    maximum_ = newMaximum;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: WriteValueConstraint::stringToType()\r\n//-----------------------------------------------------------------------------\r\nWriteValueConstraint::Type WriteValueConversions::stringToType(QString const& typeText)\r\n{\r\n    if (typeText.compare(WRITE_AS_READ_TEXT) == 0)\r\n    {\r\n        return WriteValueConstraint::WRITE_AS_READ;\r\n    }\r\n    else if (typeText.compare(ENUM_VALUES_TEXT) == 0)\r\n    {\r\n        return WriteValueConstraint::USE_ENUM;\r\n    }\r\n    else if (typeText.compare(MIN_MAX_LIMITS_TEXT) == 0)\r\n    {\r\n        return WriteValueConstraint::MIN_MAX;\r\n    }\r\n    else\r\n    {\r\n        return WriteValueConstraint::TYPE_COUNT;\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: WriteValueConstraint::typeToString()\r\n//-----------------------------------------------------------------------------\r\nQString WriteValueConversions::typeToString(WriteValueConstraint::Type const& constraintType)\r\n{\r\n    if (constraintType == WriteValueConstraint::WRITE_AS_READ)\r\n    {\r\n        return WRITE_AS_READ_TEXT;\r\n    }\r\n    else if (constraintType == WriteValueConstraint::USE_ENUM)\r\n    {\r\n        return ENUM_VALUES_TEXT;\r\n    }\r\n    else if (constraintType == WriteValueConstraint::MIN_MAX)\r\n    {\r\n        return MIN_MAX_LIMITS_TEXT;\r\n    }\r\n    else\r\n    {\r\n        return NO_CONSTRAINTS_TEXT;\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: WriteValueConversions::getConstraintTypes()\r\n//-----------------------------------------------------------------------------\r\nQStringList WriteValueConversions::getConstraintTypes()\r\n{\r\n    QStringList types;\r\n    types.append(WRITE_AS_READ_TEXT);\r\n    types.append(ENUM_VALUES_TEXT);\r\n    types.append(MIN_MAX_LIMITS_TEXT);\r\n    types.append(NO_CONSTRAINTS_TEXT);\r\n\r\n    return types;\r\n}\r\n"
  },
  {
    "path": "IPXACTmodels/Component/WriteValueConstraint.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: WriteValueConstraint.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 24.09.2015\r\n//\r\n// Description:\r\n// Describes the ipxact:writeValueConstraint element.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef WRITEVALUECONSTRAINT_H\r\n#define WRITEVALUECONSTRAINT_H\r\n\r\n#include <IPXACTmodels/ipxactmodels_global.h>\r\n\r\n#include <QString>\r\n#include <QXmlStreamWriter>\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Describes the ipxact:writeValueConstraint element.\r\n//-----------------------------------------------------------------------------\r\nclass IPXACTMODELS_EXPORT WriteValueConstraint\r\n{\r\n\r\npublic:\r\n\r\n\t//! Specifies the different write value constraint types.\r\n\tenum Type\r\n    {\r\n\t\tWRITE_AS_READ = 0,\r\n\t\tUSE_ENUM,\r\n\t\tMIN_MAX,\r\n\t\tTYPE_COUNT\r\n\t};\r\n\r\n\t//! The default constructor.\r\n\tWriteValueConstraint();\r\n\r\n\t//! Copy constructor.\r\n\tWriteValueConstraint(WriteValueConstraint const& other);\r\n\r\n\t//! Assignment operator.\r\n\tWriteValueConstraint& operator=(WriteValueConstraint const& other);\r\n\r\n\t//! The destructor.\r\n\tvirtual ~WriteValueConstraint();\r\n\r\n\t/*! \r\n     *  Get the type of the constraint.\r\n\t *\r\n\t *    @return The constraint type.\r\n\t */\r\n\tType getType() const;\r\n\r\n\t/*! \r\n     *  Set the type for the constraint.\r\n\t *\r\n\t *    @param [in] newType     The new type.\r\n\t */\r\n\tvoid setType(Type newType);\r\n\r\n\t/*!\r\n     *  Get the minimum value of the constraint.\r\n\t * \r\n\t *    @return The minimum value.\r\n\t */\r\n    QString getMinimum() const;\r\n\r\n\t/*!\r\n     *  Set the minimum value for the constraint.\r\n\t * \r\n\t *    @param [in] newMinimum  The minimum value to set.\r\n\t */\r\n    void setMinimum(QString const& newMinimum);\r\n\r\n\t/*!\r\n     *  Get the maximum value of the constraint.\r\n\t * \r\n\t *    @return The maximum value.\r\n\t */\r\n    QString getMaximum() const;\r\n\r\n\t/*!\r\n     *  Set the maximum value for the constraint.\r\n\t * \r\n\t *    @param [in] newMaximum  The maximum value to set.\r\n\t */\r\n    void setMaximum(QString const& newMaximum);\r\n\r\nprivate:\r\n\r\n\t//! Specifies the type of the constraint.\r\n\tType type_;\r\n\r\n\t//! Contains whether legal values for this field must be read from this field or not.\r\n\tbool writeAsRead_;\r\n\r\n\t//! Implies whether the only legal values are specified in the use enumerated values element or not.\r\n\tbool useEnumValues_;\r\n\r\n\t//! The minimum value for this field.\r\n    QString minimum_;\r\n\r\n\t//! The maximum value for this field.\r\n    QString maximum_;\r\n};\r\n\r\n//! Namespace for converting write value constraint types\r\nnamespace WriteValueConversions\r\n{\r\n    /*!\r\n     *  Convert a string to write value constraint type.\r\n     *\r\n     *    @param [in] typeText    The selected string.\r\n     *\r\n     *    @return Write value constraint type matching the selected string.\r\n     */\r\n    IPXACTMODELS_EXPORT WriteValueConstraint::Type stringToType(QString const& typeText);\r\n\r\n    /*!\r\n     *  Convert a write value constraint type to string.\r\n     *\r\n     *    @param [in] constraintType      The selected write value constraint type.\r\n     *\r\n     *    @return String matching the selected write value constraint type.\r\n     */\r\n    IPXACTMODELS_EXPORT QString typeToString(WriteValueConstraint::Type const& constraintType);\r\n\r\n    /*!\r\n     *  Get a list of all the write value constraint types in string format.\r\n     *\r\n     *    @return String list of all the write value constraint types.\r\n     */\r\n    IPXACTMODELS_EXPORT QStringList getConstraintTypes();\r\n};\r\n\r\n#endif // WRITEVALUECONSTRAINT_H\r\n"
  },
  {
    "path": "IPXACTmodels/Component/validators/AbstractionTypeValidator.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: AbstractionTypeValidator.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Mikko Teuho\n// Date: 19.01.2018\n//\n// Description:\n// Validator for the ipxact:abstractionType.\n//-----------------------------------------------------------------------------\n\n#include \"AbstractionTypeValidator.h\"\n\n#include <KactusAPI/include/ExpressionParser.h>\n\n#include <IPXACTmodels/common/ConfigurableVLNVReference.h>\n\n#include <IPXACTmodels/Component/AbstractionType.h>\n#include <IPXACTmodels/Component/Component.h>\n#include <IPXACTmodels/Component/View.h>\n#include <IPXACTmodels/Component/BusInterface.h>\n#include <IPXACTmodels/Component/PortMap.h>\n#include <IPXACTmodels/Component/validators/PortMapValidator.h>\n#include <IPXACTmodels/Component/validators/MemoryReserve.h>\n\n#include <IPXACTmodels/AbstractionDefinition/AbstractionDefinition.h>\n#include <IPXACTmodels/AbstractionDefinition/PortAbstraction.h>\n\n#include <KactusAPI/include/LibraryInterface.h>\n\n//-----------------------------------------------------------------------------\n// Function: AbstractionTypeValidator::AbstractionTypeValidator()\n//-----------------------------------------------------------------------------\nAbstractionTypeValidator::AbstractionTypeValidator(QSharedPointer<ExpressionParser> expressionParser,\n    QSharedPointer<QList<QSharedPointer<View> > > views, QSharedPointer<PortMapValidator> portMapValidator,\n    LibraryInterface* library):\nlibrary_(library),\navailableViews_(views),\nportMapValidator_(portMapValidator),\nexpressionParser_(expressionParser)\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: AbstractionTypeValidator::~AbstractionTypeValidator()\n//-----------------------------------------------------------------------------\nAbstractionTypeValidator::~AbstractionTypeValidator()\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: AbstractionTypeValidator::changeComponent()\n//-----------------------------------------------------------------------------\nvoid AbstractionTypeValidator::changeComponent(QSharedPointer<QList<QSharedPointer<View> > > newViews,\n    QSharedPointer<QList<QSharedPointer<Port> > > newPorts)\n{\n    availableViews_ = newViews;\n\n    portMapValidator_->componentChanged(newPorts);\n}\n\n//-----------------------------------------------------------------------------\n// Function: AbstractionTypeValidator::getPortMapValidator()\n//-----------------------------------------------------------------------------\nQSharedPointer<PortMapValidator> AbstractionTypeValidator::getPortMapValidator() const\n{\n    return portMapValidator_;\n}\n\n//-----------------------------------------------------------------------------\n// Function: AbstractionTypeValidator::validate()\n//-----------------------------------------------------------------------------\nbool AbstractionTypeValidator::validate(QSharedPointer<AbstractionType> abstraction,\n    QSharedPointer<QList<QSharedPointer<AbstractionType> > > abstractionList,\n    QSharedPointer<BusInterface> containingBus) const\n{\n    return hasValidAbstractionReference(abstraction) &&\n        hasValidViewReferences(abstraction, abstractionList) &&\n        hasValidPortMaps(abstraction, containingBus);\n}\n\n//-----------------------------------------------------------------------------\n// Function: AbstractionTypeValidator::hasValidAbstractionReference()\n//-----------------------------------------------------------------------------\nbool AbstractionTypeValidator::hasValidAbstractionReference(QSharedPointer<AbstractionType> abstraction) const\n{\n    return abstraction->getAbstractionRef() &&\n        library_->getDocumentType(*abstraction->getAbstractionRef()) == VLNV::ABSTRACTIONDEFINITION;\n}\n\n//-----------------------------------------------------------------------------\n// Function: AbstractionTypeValidator::hasValidViewReferences()\n//-----------------------------------------------------------------------------\nbool AbstractionTypeValidator::hasValidViewReferences(QSharedPointer<AbstractionType> abstraction,\n    QSharedPointer<QList<QSharedPointer<AbstractionType> > > abstractionList) const\n{\n    if (abstraction->getViewReferences()->isEmpty() && abstractionList->size() > 1)\n    {\n        return false;\n    }\n    else if (abstraction->getViewReferences()->count() == 1)\n    {\n        QString view = abstraction->getViewReferences()->first();\n        return view.isEmpty() ||referencedViewIsValid(view, abstractionList);\n    }\n    if (abstraction && abstraction->getViewReferences()->size()== 1)\n    {\n        QString view = abstraction->getViewReferences()->first();\n        return view.isEmpty() || referencedViewIsValid(view, abstractionList);\n    }\n    else\n    {\n        for (int i = 0; i < abstraction->getViewReferences()->size(); ++i)\n        {\n            QString view = abstraction->getViewReferences()->at(i);\n            if (referencedViewIsValid(view, abstractionList) == false)\n            {\n                return false;\n            }\n        }\n    }\n\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: AbstractionTypeValidator::referencedViewIsValid()\n//-----------------------------------------------------------------------------\nbool AbstractionTypeValidator::referencedViewIsValid(QString const& viewReference,\n    QSharedPointer<QList<QSharedPointer<AbstractionType> > > abstractionList) const\n{\n    return !viewReference.isEmpty() && referencedViewExists(viewReference) &&\n        viewIsReferencedOnce(viewReference, abstractionList);\n}\n\n//-----------------------------------------------------------------------------\n// Function: AbstractionTypeValidator::referencedViewExists()\n//-----------------------------------------------------------------------------\nbool AbstractionTypeValidator::referencedViewExists(QString const& viewReference) const\n{\n    for (QSharedPointer<View> const& view : *availableViews_)\n    {\n        if (view->name().compare(viewReference) == 0)\n        {\n            return true;\n        }\n    }\n\n    return false;\n}\n\n//-----------------------------------------------------------------------------\n// Function: AbstractionTypeValidator::viewIsReferencedOnce()\n//-----------------------------------------------------------------------------\nbool AbstractionTypeValidator::viewIsReferencedOnce(QString const& viewReference,\n    QSharedPointer<QList<QSharedPointer<AbstractionType> > > abstractionList) const\n{\n    for (QSharedPointer<AbstractionType> const& abstraction : *abstractionList)\n    {\n        for (QString const& abstractionView  : *abstraction->getViewReferences())\n        {\n            if (abstractionView != viewReference && abstractionView.compare(viewReference) == 0)\n            {\n                return false;\n            }\n        }\n    }\n\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: AbstractionTypeValidator::hasValidPortMaps()\n//-----------------------------------------------------------------------------\nbool AbstractionTypeValidator::hasValidPortMaps(QSharedPointer<AbstractionType> abstraction,\n    QSharedPointer<BusInterface> containingBus) const\n{\n    if (abstraction->getAbstractionRef())\n    {\n        QSharedPointer<AbstractionDefinition const> abstractionDefinition =\n            getAbstractionDefinition(abstraction->getAbstractionRef());\n\n        if (!requiredPortAbstractionsAreMapped(containingBus, abstractionDefinition, abstraction->getPortMaps()))\n        {\n            return false;\n        }\n        else if (!abstraction->getPortMaps()->isEmpty())\n        {\n            portMapValidator_->busInterfaceChanged(\n                abstraction->getAbstractionRef(), containingBus->getInterfaceMode(), containingBus->getSystem());\n\n            MemoryReserve reservedArea;\n            for (QSharedPointer<PortMap> const& portMap : *abstraction->getPortMaps())\n            {\n                QSharedPointer<PortMap::LogicalPort> logicalPort = portMap->getLogicalPort();\n                if (abstractionDefinition && logicalPort &&\n                    !logicalPortHasValidPresence(abstractionDefinition, logicalPort->name_,\n                    containingBus->getInterfaceMode(), containingBus->getSystem()))\n                {\n                    return false;\n                }\n\n                if (!portMapValidator_->validate(portMap))\n                {\n                    return false;\n                }\n\n                qint64 logicalAreaBegin = 0;\n                qint64 LogicalAreaEnd = 0;\n\n                if (logicalPort->range_)\n                {\n                    logicalAreaBegin = expressionParser_->parseExpression(\n                        logicalPort->range_->getLeft()).toLongLong();\n                    LogicalAreaEnd = expressionParser_->parseExpression(\n                        logicalPort->range_->getRight()).toLongLong();\n                }\n\n                if (LogicalAreaEnd < logicalAreaBegin)\n                {\n                    int temporary = logicalAreaBegin;\n                    logicalAreaBegin = LogicalAreaEnd;\n                    LogicalAreaEnd = temporary;\n                }\n\n                reservedArea.addArea(logicalPort->name_, logicalAreaBegin, LogicalAreaEnd);\n            }\n\n            return !reservedArea.hasIdDependantOverlap();\n        }\n    }\n\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: AbstractionTypeValidator::getAbstractionDefinition()\n//-----------------------------------------------------------------------------\nQSharedPointer<AbstractionDefinition const> AbstractionTypeValidator::getAbstractionDefinition(\n    QSharedPointer<ConfigurableVLNVReference> abstractionReference) const\n{\n    QSharedPointer<AbstractionDefinition const> abstractionDefinition;\n\n    if (abstractionReference)\n    {\n        abstractionDefinition = library_->getModelReadOnly<AbstractionDefinition>(*abstractionReference);\n    }\n\n    return abstractionDefinition;\n}\n\n//-----------------------------------------------------------------------------\n// Function: AbstractionTypeValidator::requiredPortAbstractionsAreMapped()\n//-----------------------------------------------------------------------------\nbool AbstractionTypeValidator::requiredPortAbstractionsAreMapped(QSharedPointer<BusInterface> containingBus,\n    QSharedPointer<AbstractionDefinition const> abstractionDefinition,\n    QSharedPointer<QList<QSharedPointer<PortMap> > > portMaps) const\n{\n    if (abstractionDefinition && abstractionDefinition->getLogicalPorts())\n    {\n        for (QSharedPointer<PortAbstraction> logicalPort : *abstractionDefinition->getLogicalPorts())\n        {\n            if (logicalPort->hasMode(containingBus->getInterfaceMode(), containingBus->getSystem()) &&\n                logicalPort->getPresence(\n                containingBus->getInterfaceMode(), containingBus->getSystem()) == PresenceTypes::REQUIRED &&\n                !logicalPortHasReferencingPortMaps(logicalPort->name(), portMaps))\n            {\n                return false;\n            }\n        }\n    }\n\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: AbstractionTypesValidator::logicalPortHasReferencingPortMaps()\n//-----------------------------------------------------------------------------\nbool AbstractionTypeValidator::logicalPortHasReferencingPortMaps(QString const& portName,\n    QSharedPointer<QList<QSharedPointer<PortMap> > > portMaps) const\n{\n    for (QSharedPointer<PortMap> currentMap : *portMaps)\n    {\n        if (currentMap->getLogicalPort() && currentMap->getLogicalPort()->name_ == portName)\n        {\n            return true;\n        }\n    }\n\n    return false;\n}\n\n//-----------------------------------------------------------------------------\n// Function: AbstractionTypesValidator::logicalPortHasValidPresence()\n//-----------------------------------------------------------------------------\nbool AbstractionTypeValidator::logicalPortHasValidPresence(\n    QSharedPointer<AbstractionDefinition const> abstractionDefinition, QString const& logicalPortName,\n    General::InterfaceMode mode, QString const& systemGroup) const\n{\n    QSharedPointer<PortAbstraction> logicalPort = getLogicalPort(logicalPortName, abstractionDefinition);\n\n    if (logicalPort && logicalPort->getPresence(mode, systemGroup) == PresenceTypes::ILLEGAL)\n    {\n        return false;\n    }\n\n    return true;\n}\n\n\n//-----------------------------------------------------------------------------\n// Function: AbstractionTypesValidator::getLogicalPort()\n//-----------------------------------------------------------------------------\nQSharedPointer<PortAbstraction> AbstractionTypeValidator::getLogicalPort(QString const& portName,\n    QSharedPointer<AbstractionDefinition const> abstractionDefinition) const\n{\n    if (abstractionDefinition)\n    {\n        for (QSharedPointer<PortAbstraction> const& definitionPort : *abstractionDefinition->getLogicalPorts())\n        {\n            if (portName == definitionPort->getLogicalName())\n            {\n                return definitionPort;\n            }\n        }\n    }\n\n    return QSharedPointer<PortAbstraction>();\n}\n\n//-----------------------------------------------------------------------------\n// Function: AbstractionTypeValidator::findErrorsIn()\n//-----------------------------------------------------------------------------\nvoid AbstractionTypeValidator::findErrorsIn(QVector<QString>& errors, QSharedPointer<AbstractionType> abstraction,\n    QSharedPointer<QList<QSharedPointer<AbstractionType> > > abstractionList,\n    QSharedPointer<BusInterface> containingBus, QString const& context) const\n{\n    findErrorsInReferencedViews(errors, abstraction, abstractionList, context);\n    findErrorsInAbstractionReference(errors, abstraction, context);\n\n    QString portMapContext = QObject::tr(\"%1 %2\")\n        .arg(General::interfaceMode2Str(containingBus->getInterfaceMode())).arg(context);\n\n    findErrorsInPortMaps(errors, abstraction, containingBus, portMapContext);\n}\n\n//-----------------------------------------------------------------------------\n// Function: AbstractionTypeValidator::findErrorsInReferencedViews()\n//-----------------------------------------------------------------------------\nvoid AbstractionTypeValidator::findErrorsInReferencedViews(QVector<QString>& errors,\n    QSharedPointer<AbstractionType> abstraction,\n    QSharedPointer<QList<QSharedPointer<AbstractionType> > > abstractionList, QString const& context) const\n{\n    if (abstraction->getViewReferences()->isEmpty() && abstractionList->size() > 1)\n    {\n        QString newError = QObject::tr(\n            \"Abstraction with no view references should be the only abstraction definition in %1\").arg(context);\n        if (!errors.contains(newError))\n        {\n            errors.append(newError);\n        }\n    }\n    else\n    {\n        for (QString const& abstractionView : *abstraction->getViewReferences())\n        {\n            if (!referencedViewExists(abstractionView))\n            {\n                QString newError = QObject::tr(\"Invalid view reference %1 set for abstraction type in %2\")\n                    .arg(abstractionView).arg(context);\n                if (!errors.contains(newError))\n                {\n                    errors.append(newError);\n                }\n            }\n            if (!viewIsReferencedOnce(abstractionView, abstractionList))\n            {\n                QString newError =\n                    QObject::tr(\"View %1 has been referenced multiple times in abstraction types in %2\")\n                    .arg(abstractionView).arg(context);\n                if (!errors.contains(newError))\n                {\n                    errors.append(newError);\n                }\n            }\n        }\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: AbstractionTypeValidator::findErrorsInAbstractionReference()\n//-----------------------------------------------------------------------------\nvoid AbstractionTypeValidator::findErrorsInAbstractionReference(QVector<QString>& errors,\n    QSharedPointer<AbstractionType> abstraction, QString const& context) const\n{\n    if (!abstraction->getAbstractionRef())\n    {\n        errors.append(QObject::tr(\"Abstraction reference must be set for each abstraction type in %1\")\n            .arg(context));\n    }\n    else\n    {\n        if (!library_->contains(*abstraction->getAbstractionRef().data()))\n        {\n            errors.append(QObject::tr(\"Abstraction reference %1 set for %2 could not be found in the library\")\n                .arg(abstraction->getAbstractionRef()->toString()).arg(context));\n        }\n        if (library_->getDocumentType(*abstraction->getAbstractionRef()) != VLNV::ABSTRACTIONDEFINITION)\n        {\n            errors.append(QObject::tr(\"Invalid abstraction reference set within %1\").arg(context));\n        }\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: AbstractionTypeValidator::findErrorsInPortMaps()\n//-----------------------------------------------------------------------------\nvoid AbstractionTypeValidator::findErrorsInPortMaps(QVector<QString>& errors,\n    QSharedPointer<AbstractionType> abstraction, QSharedPointer<BusInterface> containingBus,\n    QString const& context) const\n{\n    if (abstraction && abstraction->getAbstractionRef())\n    {\n        QSharedPointer<AbstractionDefinition const> abstractionDefinition =\n            getAbstractionDefinition(abstraction->getAbstractionRef());\n\n        if (!requiredPortAbstractionsAreMapped(containingBus, abstractionDefinition, abstraction->getPortMaps()))\n        {\n            findErrorsInRequiredPortAbstractions(\n                errors, context, containingBus, abstractionDefinition, abstraction->getPortMaps());\n        }\n\n        if (!abstraction->getPortMaps()->isEmpty())\n        {\n            portMapValidator_->busInterfaceChanged(\n                abstraction->getAbstractionRef(), containingBus->getInterfaceMode(), containingBus->getSystem());\n\n            QStringList portNames;\n\n            MemoryReserve logicalReservedArea;\n\n            for (QSharedPointer<PortMap> const& portMap : *abstraction->getPortMaps())\n            {\n                QSharedPointer<PortMap::LogicalPort> logicalPort = portMap->getLogicalPort();\n                if (abstractionDefinition && logicalPort &&\n                    !logicalPortHasValidPresence(abstractionDefinition, logicalPort->name_,\n                    containingBus->getInterfaceMode(), containingBus->getSystem()) &&\n                    !portNames.contains(logicalPort->name_))\n                {\n                    errors.append(QObject::tr(\"Logical port %1 with presence 'ILLEGAL' mapped within %2.\")\n                        .arg(logicalPort->name_)\n                        .arg(context));\n\n                    portNames.append(logicalPort->name_);\n                }\n\n                portMapValidator_->findErrorsIn(errors, portMap, context);\n\n                if (logicalPort)\n                {\n                    qint64 logicalAreaBegin = 0;\n                    qint64 LogicalAreaEnd = 0;\n\n                    if (logicalPort->range_)\n                    {\n                        logicalAreaBegin = expressionParser_->parseExpression(\n                            logicalPort->range_->getLeft()).toLongLong();\n                        LogicalAreaEnd = expressionParser_->parseExpression(\n                            logicalPort->range_->getRight()).toLongLong();\n                    }\n                    if (LogicalAreaEnd < logicalAreaBegin)\n                    {\n                        int temporary = logicalAreaBegin;\n                        logicalAreaBegin = LogicalAreaEnd;\n                        LogicalAreaEnd = temporary;\n                    }\n\n                    logicalReservedArea.addArea(logicalPort->name_, logicalAreaBegin, LogicalAreaEnd);\n                }\n            }\n            logicalReservedArea.findErrorsInIdDependantOverlap(errors, QLatin1String(\"logical port\"), context);\n        }\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: AbstractionTypeValidator::findErrorsInRequiredPortAbstractions()\n//-----------------------------------------------------------------------------\nvoid AbstractionTypeValidator::findErrorsInRequiredPortAbstractions(QVector<QString>& errors,\n    QString const& context, QSharedPointer<BusInterface> busInterface,\n    QSharedPointer<AbstractionDefinition const> abstractionDefinition,\n    QSharedPointer<QList<QSharedPointer<PortMap> > > portMaps) const\n{\n    if (!requiredPortAbstractionsAreMapped(busInterface, abstractionDefinition, portMaps))\n    {\n        for (QSharedPointer<PortAbstraction> const& logicalPort : *abstractionDefinition->getLogicalPorts())\n        {\n            if (logicalPort->hasMode(busInterface->getInterfaceMode(), busInterface->getSystem()) &&\n                logicalPort->getPresence(busInterface->getInterfaceMode(), busInterface->getSystem())\n                == PresenceTypes::REQUIRED && !logicalPortHasReferencingPortMaps(logicalPort->name(), portMaps))\n            {\n                errors.append(QObject::tr(\"Logical port %1 with presence 'REQUIRED' is not mapped within %2.\")\n                    .arg(logicalPort->name())\n                    .arg(context));\n            }\n        }\n    }\n}"
  },
  {
    "path": "IPXACTmodels/Component/validators/AbstractionTypeValidator.h",
    "content": "//-----------------------------------------------------------------------------\n// File: AbstractionTypeValidator.h\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Mikko Teuho\n// Date: 19.01.2018\n//\n// Description:\n// Validator for the ipxact:abstractionType.\n//-----------------------------------------------------------------------------\n\n#ifndef ABSTRACTIONTYPEVALIDATOR_H\n#define ABSTRACTIONTYPEVALIDATOR_H\n\n#include <IPXACTmodels/generaldeclarations.h>\n\nclass LibraryInterface;\n\nclass View;\nclass Port;\nclass PortMap;\nclass PortAbstraction;\n\nclass AbstractionType;\nclass BusInterface;\nclass AbstractionDefinition;\nclass ConfigurableVLNVReference;\n\nclass PortMapValidator;\n\nclass ExpressionParser;\n\n#include <QList>\n\n//-----------------------------------------------------------------------------\n//! Validator for the ipxact:abstractionType.\n//-----------------------------------------------------------------------------\nclass IPXACTMODELS_EXPORT AbstractionTypeValidator\n{\npublic:\n\n    /*!\n     *  The constructor.\n     *\n     *    @param [in] expressionParser    Expression parser.\n     *    @param [in] views               Views contained within the component.\n     *    @param [in] portMapValidator    Validator for port maps.\n     *    @param [in] library             Interface for the VLNV library.\n     */\n    AbstractionTypeValidator(QSharedPointer<ExpressionParser> expressionParser,\n        QSharedPointer<QList<QSharedPointer<View> > > views, QSharedPointer<PortMapValidator> portMapValidator,\n        LibraryInterface* library);\n\n    /*!\n     *  The destructor.\n     */\n    virtual ~AbstractionTypeValidator();\n\n    /*!\n     *  Change the currently selected component.\n     *\n     *    @param [in] newViews    Views contained within the new component.\n     *    @param [in] newPorts    Ports contained within the new component.\n     */\n    void changeComponent(QSharedPointer<QList<QSharedPointer<View> > > newViews,\n        QSharedPointer<QList<QSharedPointer<Port> > > newPorts);\n\n    /*!\n     *  Get the validator for port maps.\n     *\n     *    @return The port map validator.\n     */\n    QSharedPointer<PortMapValidator> getPortMapValidator() const;\n\n    /*!\n     *  Validates the given abstraction type.\n     *\n     *    @param [in] abstraction         The selected abstraction type.\n     *    @param [in] abstractionList     List of the abstraction types contained within the bus interface.\n     *    @param [in] containingBus       Bus interface containing the selected abstraction type.\n     *\n     *    @return True, if the selected abstraction type is valid, false otherwise.\n     */\n    virtual bool validate(QSharedPointer<AbstractionType> abstraction,\n        QSharedPointer<QList<QSharedPointer<AbstractionType> > > abstractionList,\n        QSharedPointer<BusInterface> containingBus) const;\n\n    /*!\n     *  Check if the reference to the abstraction definition of the selected abstraction type is valid.\n     *\n     *    @param [in] abstraction     The selected abstraction type.\n     *\n     *    @return True, if the abstraction reference is valid, false otherwise.\n     */\n    bool hasValidAbstractionReference(QSharedPointer<AbstractionType> abstraction) const;\n\n    /*!\n     *  Check if the view references contained within the selected abstraction type are valid.\n     *\n     *    @param [in] abstraction         The selected abstraction type.\n     *    @param [in] abstractionList     List of the abstraction types contained within the bus interface.\n     *\n     *    @return True, if the view references are valid, false otherwise.\n     */\n    bool hasValidViewReferences(QSharedPointer<AbstractionType> abstraction,\n        QSharedPointer<QList<QSharedPointer<AbstractionType> > > abstractionList) const;\n\n    /*!\n     *  Check if the selected view reference is valid.\n     *\n     *    @param [in] viewReference       The selected view reference.\n     *    @param [in] abstractionList     List of the abstraction types contained within the bus interface.\n     *\n     *    @return True, if the selected view reference is valid, false otherwise.\n     */\n    bool referencedViewIsValid(QString const& viewReference,\n        QSharedPointer<QList<QSharedPointer<AbstractionType> > > abstractionList) const;\n\n    /*!\n     *  Check if the port maps contained within the selected abstraction type are valid.\n     *\n     *    @param [in] abstraction     The selected abstraction type.\n     *    @param [in] containingBus   Bus interface containing the selected abstraction type.\n     *\n     *    @return True, if the port maps are valid, false otherwise.\n     */\n    bool hasValidPortMaps(QSharedPointer<AbstractionType> abstraction, QSharedPointer<BusInterface> containingBus)\n        const;\n\n    /*!\n     *  Find errors within the selected abstraction type.\n     *\n     *    @param [in/out] errors          List of the found errors.\n     *    @param [in] abstraction         The selected abstraction type.\n     *    @param [in] abstractionList     List of the abstraction types contained within the bus interface.\n     *    @param [in] containingBus       Bus interface containing the selected abstraction type.\n     *    @param [in] context             Context of the errors.\n     */\n    virtual void findErrorsIn(QVector<QString>& errors, QSharedPointer<AbstractionType> abstraction,\n        QSharedPointer<QList<QSharedPointer<AbstractionType> > > abstractionList,\n        QSharedPointer<BusInterface> containingBus, QString const& context) const;\n\nprivate:\n\n    // Disable copying.\n    AbstractionTypeValidator(AbstractionTypeValidator const& rhs);\n    AbstractionTypeValidator& operator=(AbstractionTypeValidator const& rhs);\n\n    /*!\n     *  Check if the selected view reference exists.\n     *\n     *    @param [in] viewReference   The selected view reference.\n     *\n     *    @return True, if the view reference exists, false otherwise.\n     */\n    bool referencedViewExists(QString const& viewReference) const;\n\n    /*!\n     *  Check if the selected view reference is used only once in the containing bus interface.\n     *\n     *    @param [in] viewReference       The selected view reference.\n     *    @param [in] abstractionList     List of the abstraction types contained within the bus interface.\n     *\n     *    @return True, if the selected view is referenced once, false otherwise.\n     */\n    bool viewIsReferencedOnce(QString const& viewReference,\n        QSharedPointer<QList<QSharedPointer<AbstractionType> > > abstractionList) const;\n\n    /*!\n     *  Get the abstraction definition referenced by the abstraction type.\n     *\n     *    @param [in] abstractionReference    The VLNV reference of the selected abstraction type.\n     *\n     *    @return Abstraction definition matching the selected VLNV reference.\n     */\n    QSharedPointer<AbstractionDefinition const> getAbstractionDefinition(\n        QSharedPointer<ConfigurableVLNVReference> abstractionReference) const;\n\n    /*!\n     *  Check if the required logical ports have been mapped.\n     *\n     *    @param [in] containingBus           Bus interface containing the abstraction type.\n     *    @param [in] abstractionDefinition   Abstraction definition referenced by the abstraction type.\n     *    @param [in] portMaps                List of the port maps contained within the abstraction type.\n     *\n     *    @return True, if the required port abstractions have been mapped, false otherwise.\n     */\n    bool requiredPortAbstractionsAreMapped(QSharedPointer<BusInterface> containingBus,\n        QSharedPointer<AbstractionDefinition const> abstractionDefinition,\n        QSharedPointer<QList<QSharedPointer<PortMap> > > portMaps) const;\n\n    /*!\n     *  Check if the selected logical port has been referenced in any port maps.\n     *\n     *    @param [in] portName    Name of the selected logical port.\n     *    @param [in] portMaps    List of the contained port maps.\n     *\n     *    @return True, if the logical port has been mapped, false otherwise.\n     */\n    bool logicalPortHasReferencingPortMaps(QString const& portName,\n        QSharedPointer<QList<QSharedPointer<PortMap> > > portMaps) const;\n\n    /*!\n     *  Check if the logical port has valid presence.\n     *\n     *    @param [in] abstractionDefinition   Abstraction definition of the abstraction type.\n     *    @param [in] logicalPortName         Name of the selected logical port.\n     *    @param [in] mode                    Interface mode of the containing bus interface.\n     *    @param [in] systemGroup             System group used in the containing bus interface.\n     *\n     *    @return True, if the logical port has valid presence, false otherwise.\n     */\n    bool logicalPortHasValidPresence(QSharedPointer<AbstractionDefinition const> abstractionDefinition,\n        QString const& logicalPortName, General::InterfaceMode mode, QString const& systemGroup) const;\n\n    /*!\n     *  Get the selected logical port from the selected abstraction definition.\n     *\n     *    @param [in] portName                Name of the selected logical port.\n     *    @param [in] abstractionDefinition   The selected abstraction definition.\n     *\n     *    @return The logical port with the selected name.\n     */\n    QSharedPointer<PortAbstraction> getLogicalPort(QString const& portName,\n        QSharedPointer<AbstractionDefinition const> abstractionDefinition) const;\n\n    /*!\n     *  Find errors within the view references of the selected abstraction type.\n     *\n     *    @param [in/out] errors          List of found errors.\n     *    @param [in] abstraction         The selected Abstraction type.\n     *    @param [in] abstractionList     List of the abstraction types contained within the bus interface.\n     *    @param [in] context             Context of the errors.\n     */\n    void findErrorsInReferencedViews(QVector<QString>& errors, QSharedPointer<AbstractionType> abstraction,\n        QSharedPointer<QList<QSharedPointer<AbstractionType> > > abstractionList, QString const& context) const;\n\n    /*!\n     *  Find errors within the abstraction definition reference of the selected abstraction type.\n     *\n     *    @param [in/out] errors      List of found errors.\n     *    @param [in] abstraction     The selected abstraction type.\n     *    @param [in] context         Context of the errors.\n     */\n    void findErrorsInAbstractionReference(QVector<QString>& errors, QSharedPointer<AbstractionType> abstraction,\n        QString const& context) const;\n\n    /*!\n     *  Find errors within the port maps of the selected abstraction type.\n     *\n     *    @param [in/out] errors      List of found errors.\n     *    @param [in] abstraction     The selected abstraction type.\n     *    @param [in] containingBus   Bus interface containing the selected abstraction type.\n     *    @param [in] context         Context of the errors.\n     */\n    void findErrorsInPortMaps(QVector<QString>& errors, QSharedPointer<AbstractionType> abstraction,\n        QSharedPointer<BusInterface> containingBus, QString const& context) const;\n\n    /*!\n     *  Find errors within the required port map logical ports.\n     *\n     *    @param [in/out] errors              List of found errors.\n     *    @param [in] context                 Context of the errors.\n     *    @param [in] busInterface            Bus interface containing the abstraction definition reference.\n     *    @param [in] abstractionDefinition   The selected abstraction definition.\n     *    @param [in] portMaps                List of the port maps.\n     */\n    void findErrorsInRequiredPortAbstractions(QVector<QString>& errors, QString const& context,\n        QSharedPointer<BusInterface> busInterface,\n        QSharedPointer<AbstractionDefinition const> abstractionDefinition,\n        QSharedPointer<QList<QSharedPointer<PortMap> > > portMaps) const;\n\n    //-----------------------------------------------------------------------------\n    // Data.\n    //-----------------------------------------------------------------------------\n\n    //! Interface for the VLNV library.\n    LibraryInterface* library_;\n\n    //! List of the view contained within the containing component.\n    QSharedPointer<QList<QSharedPointer<View> > > availableViews_;\n\n    //! Validator for port maps.\n    QSharedPointer<PortMapValidator> portMapValidator_;\n\n    //! The expression validator.\n    QSharedPointer<ExpressionParser> expressionParser_;\n};\n\n#endif // ABSTRACTIONTYPEVALIDATOR_H\n"
  },
  {
    "path": "IPXACTmodels/Component/validators/AddressBlockValidator.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: AddressBlockValidator.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 23.11.2015\r\n//\r\n// Description:\r\n// Validator for ipxact:addressBlock.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"AddressBlockValidator.h\"\r\n\r\n#include <KactusAPI/include/ExpressionParser.h>\r\n\r\n#include <IPXACTmodels/Component/validators/MemoryReserve.h>\r\n#include <IPXACTmodels/Component/validators/RegisterValidator.h>\r\n#include <IPXACTmodels/Component/validators/RegisterFileValidator.h>\r\n#include <IPXACTmodels/Component/validators/MemoryArrayValidator.h>\r\n#include <IPXACTmodels/common/validators/ParameterValidator.h>\r\n#include <IPXACTmodels/common/validators/CommonItemsValidator.h>\r\n#include <IPXACTmodels/Component/validators/CollectionValidators.h>\r\n\r\n#include <IPXACTmodels/Component/Component.h>\r\n#include <IPXACTmodels/Component/AddressBlock.h>\r\n#include <IPXACTmodels/Component/RegisterBase.h>\r\n#include <IPXACTmodels/Component/Register.h>\r\n#include <IPXACTmodels/Component/RegisterFile.h>\r\n#include <IPXACTmodels/Component/Field.h>\r\n#include <IPXACTmodels/Component/MemoryArray.h>\r\n#include <IPXACTmodels/common/Parameter.h>\r\n\r\n#include <QRegularExpression>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressBlockValidator::AddressBlockValidator()\r\n//-----------------------------------------------------------------------------\r\nAddressBlockValidator::AddressBlockValidator(QSharedPointer<ExpressionParser> expressionParser,\r\n    QSharedPointer<RegisterValidator> registerValidator,\r\n    QSharedPointer<RegisterFileValidator> registerFileValidator,\r\n    QSharedPointer<ParameterValidator> parameterValidator,\r\n    Document::Revision docRevision) :\r\nMemoryBlockValidator(expressionParser, parameterValidator, docRevision),\r\nregisterValidator_(registerValidator),\r\nregisterFileValidator_(registerFileValidator)\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressBlockValidator::getBlockType()\r\n//-----------------------------------------------------------------------------\r\nQString AddressBlockValidator::getBlockType() const\r\n{\r\n    return QStringLiteral(\"address block\");\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressBlockValidator::componentChange()\r\n//-----------------------------------------------------------------------------\r\nvoid AddressBlockValidator::componentChange(QSharedPointer<Component> newComponent)\r\n{\r\n    registerValidator_->componentChange(newComponent);\r\n    registerFileValidator_->componentChange(newComponent);\r\n\r\n    if (newComponent)\r\n    {\r\n        docRevision_ = newComponent->getRevision();\r\n        componentModes_ = newComponent->getModes();\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressBlockValidator::getRegisterValidator()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<RegisterValidator> AddressBlockValidator::getRegisterValidator() const\r\n{\r\n    return registerValidator_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressBlockValidator::getRegisterFileValidator()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<RegisterFileValidator> AddressBlockValidator::getRegisterFileValidator() const\r\n{\r\n    return registerFileValidator_;\r\n}\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressBlockValidator::validate()\r\n//-----------------------------------------------------------------------------\r\nbool AddressBlockValidator::validate(QSharedPointer<AddressBlock> addressBlock, QString const& addressUnitBits)\r\n{\r\n    bool validAmongSiblings = validComparedToSiblings(addressBlock);\r\n\r\n    if (docRevision_ == Document::Revision::Std14)\r\n    {\r\n        return MemoryBlockValidator::validate(addressBlock) &&\r\n            hasValidRange(addressBlock) &&\r\n            hasValidWidth(addressBlock) &&\r\n            hasValidRegisterData(addressBlock, addressUnitBits) &&\r\n            hasValidUsage(addressBlock) && validAmongSiblings;\r\n    }\r\n    else if (docRevision_ == Document::Revision::Std22)\r\n    {\r\n        // Check mandatory elements, if there is no definition reference.\r\n        if (addressBlock->getAddressBlockDefinitionRef().isEmpty() &&\r\n            (!hasValidRange(addressBlock) || !hasValidWidth(addressBlock)))\r\n        {\r\n            return false;\r\n        }\r\n\r\n        return validAmongSiblings && MemoryBlockValidator::validate(addressBlock) &&\r\n            hasValidRegisterAlignment(addressBlock) && hasValidMemoryArray(addressBlock) &&\r\n            hasValidUsage(addressBlock) && hasValidAccessPolicies(addressBlock) &&\r\n            hasValidRegisterData(addressBlock, addressUnitBits) &&\r\n            hasValidStructure(addressBlock) && validAmongSiblings;\r\n    }\r\n\r\n    return false;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressBlockValidator::hasValidRange()\r\n//-----------------------------------------------------------------------------\r\nbool AddressBlockValidator::hasValidRange(QSharedPointer<AddressBlock> addressBlock) const\r\n{\r\n    bool toIntOk = true;\r\n    quint64 range = getExpressionParser()->parseExpression(addressBlock->getRange()).toULongLong(&toIntOk);\r\n\r\n    return toIntOk && range > 0;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressBlockValidator::hasValidWidth()\r\n//-----------------------------------------------------------------------------\r\nbool AddressBlockValidator::hasValidWidth(QSharedPointer<AddressBlock> addressBlock) const\r\n{\r\n    bool toIntOk = true;\r\n    getExpressionParser()->parseExpression(addressBlock->getWidth()).toULongLong(&toIntOk);\r\n\r\n    return toIntOk;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressBlockValidator::hasValidRegisterData()\r\n//-----------------------------------------------------------------------------\r\nbool AddressBlockValidator::hasValidRegisterData(QSharedPointer<AddressBlock> addressBlock,\r\n    QString const& addressUnitBits)\r\n{\r\n    if (addressBlock->getRegisterData()->isEmpty())\r\n    {\r\n        return true;\r\n    }\r\n\r\n    QMultiHash<QString, QSharedPointer<RegisterBase> > foundNames;\r\n\r\n    QStringList typeIdentifiers;\r\n\r\n    bool aubChangeOk = true;\r\n    qint64 aubInt = getExpressionParser()->parseExpression(addressUnitBits).toLongLong(&aubChangeOk);\r\n    qint64 addressBlockRange = getExpressionParser()->parseExpression(addressBlock->getRange()).toLongLong();\r\n\r\n    auto registerDataCopy = QSharedPointer<QList<QSharedPointer<RegisterBase> > >(new QList(*addressBlock->getRegisterData()));\r\n\r\n    bool errorFound = false;\r\n\r\n    // Sort registers and register files by address offset\r\n    auto sortByAddressOffset = [&](QSharedPointer<RegisterBase> registerBaseA, QSharedPointer<RegisterBase> registerBaseB)\r\n        {\r\n            return getExpressionParser()->parseExpression(registerBaseA->getAddressOffset()).toLongLong() <\r\n                getExpressionParser()->parseExpression(registerBaseB->getAddressOffset()).toLongLong();\r\n        };\r\n\r\n    std::sort(registerDataCopy->begin(), registerDataCopy->end(), sortByAddressOffset);\r\n    qint64 lastEndAddress = -1;\r\n\r\n    bool lastWasRegister = true;\r\n\r\n    // Register and register file validity together must be checked before separately\r\n    for (auto regIter = registerDataCopy->begin(); regIter != registerDataCopy->end(); ++regIter)\r\n    {\r\n        QSharedPointer<Register> targetRegister = (*regIter).dynamicCast<Register>();\r\n        if (targetRegister)\r\n        {\r\n            // Mark name as valid, if not found in map.\r\n            if (!foundNames.contains(targetRegister->name()))\r\n            {\r\n                registerValidator_->setChildItemValidity(targetRegister, true);\r\n            }\r\n\r\n            foundNames.insert(targetRegister->name(), targetRegister);\r\n\r\n            if (registerSizeIsNotWithinBlockWidth(targetRegister, addressBlock) ||\r\n                !hasValidVolatileForRegister(addressBlock, targetRegister) ||\r\n                !hasValidAccessWithRegister(addressBlock, targetRegister))\r\n            {\r\n                registerValidator_->setChildItemValidity(targetRegister, false);\r\n                errorFound = true;\r\n            }\r\n\r\n            if (!targetRegister->getTypeIdentifier().isEmpty() &&\r\n                typeIdentifiers.contains(targetRegister->getTypeIdentifier()))\r\n            {\r\n                int typeIdentifierIndex = typeIdentifiers.indexOf(targetRegister->getTypeIdentifier());\r\n                if (!registersHaveSimilarDefinitionGroups(targetRegister, addressBlock,\r\n                    typeIdentifierIndex))\r\n                {\r\n                    errorFound = true;\r\n                }\r\n            }\r\n\r\n            if (aubChangeOk && aubInt != 0 &&\r\n                markRegisterOverlap(regIter, lastEndAddress, addressBlockRange, aubInt, true, lastWasRegister))\r\n            {\r\n                errorFound = true;\r\n            }\r\n\r\n            lastWasRegister = true;\r\n            typeIdentifiers.append(targetRegister->getTypeIdentifier());\r\n        }\r\n        else if (QSharedPointer<RegisterFile> targetRegisterFile = (*regIter).dynamicCast<RegisterFile>())\r\n        {\r\n            if (!foundNames.contains(targetRegisterFile->name()))\r\n            {\r\n                registerFileValidator_->setChildItemValidity(targetRegisterFile, true);\r\n            }\r\n\r\n            foundNames.insert(targetRegisterFile->name(), targetRegisterFile);\r\n\r\n            if (aubChangeOk && aubInt != 0 &&\r\n                markRegisterOverlap(regIter, lastEndAddress, addressBlockRange, aubInt, false, lastWasRegister))\r\n            {\r\n                errorFound = true;\r\n            }\r\n\r\n            lastWasRegister = false;\r\n        }\r\n    }\r\n\r\n    // Mark registers with duplicate names as invalid. Return if any errors were found from any previous check.\r\n    if (markDuplicateNames(foundNames) || errorFound)\r\n    {\r\n        return false;\r\n    }\r\n\r\n    // Validate registers and register files separately\r\n    for (auto const& registerBase : *registerDataCopy)\r\n    {\r\n        if (QSharedPointer<Register> asRegister = registerBase.dynamicCast<Register>();\r\n            asRegister && !registerValidator_->validate(asRegister))\r\n        {\r\n            return false;\r\n        }\r\n        else if (QSharedPointer<RegisterFile> asRegisterFile = registerBase.dynamicCast<RegisterFile>();\r\n            asRegisterFile && !registerFileValidator_->validate(asRegisterFile, addressUnitBits, addressBlock->getWidth()))\r\n        {\r\n            return false;\r\n        }\r\n    }\r\n\r\n    return true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressBlockValidator::registerIsNotContainedWithinBlock()\r\n//-----------------------------------------------------------------------------\r\nbool AddressBlockValidator::registerSizeIsNotWithinBlockWidth(QSharedPointer<Register> targetRegister,\r\n    QSharedPointer<AddressBlock> addressBlock) const\r\n{\r\n    int registerSize = getExpressionParser()->parseExpression(targetRegister->getSize()).toInt();\r\n    int addressBlockWidth = getExpressionParser()->parseExpression(addressBlock->getWidth()).toInt();\r\n\r\n    return registerSize > addressBlockWidth;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressBlockValidator::hasInvalidVolatileForRegister()\r\n//-----------------------------------------------------------------------------\r\nbool AddressBlockValidator::hasValidVolatileForRegister(QSharedPointer<AddressBlock> addressBlock,\r\n    QSharedPointer<Register> targetRegister) const\r\n{\r\n    if (targetRegister->getVolatile() == QLatin1String(\"true\") &&\r\n        addressBlock->getVolatile() == QLatin1String(\"false\"))\r\n    {\r\n        return false;\r\n    }\r\n\r\n    for (QSharedPointer<Field> const& field : *targetRegister->getFields())\r\n    {\r\n        if (field->getVolatile().toBool() == true && addressBlock->getVolatile() == QLatin1String(\"false\"))\r\n        {\r\n            return false;\r\n        }\r\n    }\r\n\r\n    return true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressBlockValidator::hasValidAccessWithRegister()\r\n//-----------------------------------------------------------------------------\r\nbool AddressBlockValidator::hasValidAccessWithRegister(QSharedPointer<AddressBlock> addressBlock,\r\n    QSharedPointer<Register> targetRegister) const\r\n{\r\n    AccessTypes::Access blockAccess = addressBlock->getAccess();\r\n\r\n\tif (AccessTypes::Access registerAccess = targetRegister->getAccess();\r\n        registerAccess != AccessTypes::ACCESS_COUNT &&\r\n\t\t((blockAccess == AccessTypes::READ_ONLY && registerAccess != AccessTypes::READ_ONLY) ||\r\n        (blockAccess == AccessTypes::WRITE_ONLY && (registerAccess != AccessTypes::WRITE_ONLY &&\r\n            registerAccess != AccessTypes::WRITEONCE)) ||\r\n        (blockAccess == AccessTypes::READ_WRITEONCE && (registerAccess != AccessTypes::READ_ONLY &&\r\n            registerAccess != AccessTypes::READ_WRITEONCE && registerAccess != AccessTypes::WRITEONCE)) ||\r\n        (blockAccess == AccessTypes::WRITEONCE && registerAccess != AccessTypes::WRITEONCE)))\r\n    {\r\n        return false;\r\n    }\r\n\r\n    return true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressBlockValidator::hasAddressBlockDefinitionGroupDefined()\r\n//-----------------------------------------------------------------------------\r\nbool AddressBlockValidator::hasAddressBlockDefinitionGroupDefined(QSharedPointer<AddressBlock> addressBlock) const\r\n{\r\n    return !addressBlock->getTypeIdentifier().isEmpty() || !addressBlock->getRange().isEmpty() ||\r\n        !addressBlock->getWidth().isEmpty() || hasMemoryBlockDataGroupDefined(addressBlock) ||\r\n        !addressBlock->getRegisterData()->isEmpty();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressBlockValidator::hasMemoryBlockDataGroupDefined()\r\n//-----------------------------------------------------------------------------\r\nbool AddressBlockValidator::hasMemoryBlockDataGroupDefined(QSharedPointer<AddressBlock> addressBlock) const\r\n{\r\n    return addressBlock->getUsage() != General::USAGE_COUNT || !addressBlock->getVolatile().isEmpty() ||\r\n        !addressBlock->getAccessPolicies()->isEmpty() || !addressBlock->getParameters()->isEmpty();\r\n}\r\n\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressBlockValidator::markRegisterOverlap()\r\n//-----------------------------------------------------------------------------\r\nbool AddressBlockValidator::markRegisterOverlap(QList<QSharedPointer<RegisterBase> >::iterator regIter, qint64& lastEndAddress,\r\n    qint64 addressBlockRange, qint64 addressUnitBits, bool targetIsRegister, bool lastWasRegister)\r\n{\r\n    auto targetRegisterBase = *regIter;\r\n\r\n    qint64 registerBaseBegin = getExpressionParser()->parseExpression(\r\n        targetRegisterBase->getAddressOffset()).toLongLong();\r\n    qint64 registerBaseRangeInt = -1;\r\n\r\n    bool errorFound = false;\r\n\r\n    if (targetIsRegister)\r\n    {\r\n        registerBaseRangeInt = getRegisterSizeInLAU(targetRegisterBase.staticCast<Register>(), addressUnitBits);\r\n    }\r\n    else\r\n    {\r\n        registerBaseRangeInt = getTrueRegisterFileRange(targetRegisterBase.staticCast<RegisterFile>());\r\n    }\r\n\r\n    qint64 registerBaseEnd = registerBaseBegin + registerBaseRangeInt - 1;\r\n\r\n    if (targetRegisterBase->getIsPresent().isEmpty() ||\r\n        getExpressionParser()->parseExpression(targetRegisterBase->getIsPresent()).toInt())\r\n    {\r\n        if (registerBaseBegin <= lastEndAddress && lastEndAddress != -1)\r\n        {\r\n            auto prevRegisterBase = *std::prev(regIter);\r\n\r\n            if (lastWasRegister)\r\n            {\r\n                registerValidator_->setChildItemValidity(prevRegisterBase, false);\r\n            }\r\n            else\r\n            {\r\n                registerFileValidator_->setChildItemValidity(prevRegisterBase, false);\r\n            }\r\n\r\n\r\n            if (targetIsRegister)\r\n            {\r\n                registerValidator_->setChildItemValidity(targetRegisterBase, false);\r\n            }\r\n            else\r\n            {\r\n                registerFileValidator_->setChildItemValidity(targetRegisterBase, false);\r\n            }\r\n\r\n            errorFound = true;\r\n        }\r\n\r\n        if (registerBaseEnd > lastEndAddress)\r\n        {\r\n            lastEndAddress = registerBaseEnd;\r\n        }\r\n    }\r\n\r\n    if (registerBaseBegin < 0 || registerBaseBegin + registerBaseRangeInt > addressBlockRange)\r\n    {\r\n        targetIsRegister\r\n            ? registerValidator_->setChildItemValidity(targetRegisterBase, false)\r\n            : registerFileValidator_->setChildItemValidity(targetRegisterBase, false);\r\n        errorFound = true;\r\n    }\r\n\r\n    return errorFound;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressBlockValidator::markDuplicateNames()\r\n//-----------------------------------------------------------------------------\r\nbool AddressBlockValidator::markDuplicateNames(QMultiHash<QString, QSharedPointer<RegisterBase>> const& foundNames)\r\n{\r\n    bool errorFound = false;\r\n\r\n    for (auto const& name : foundNames.keys())\r\n    {\r\n        if (auto const& duplicateNames = foundNames.values(name);\r\n            duplicateNames.count() > 1)\r\n        {\r\n            std::for_each(duplicateNames.begin(), duplicateNames.end(),\r\n                [this](QSharedPointer<RegisterBase> registerBase)\r\n                {\r\n                    if (auto asRegister = registerBase.dynamicCast<Register>())\r\n                    {\r\n                        registerValidator_->setChildItemValidity(asRegister, false);\r\n                    }\r\n                    else if (auto asRegisterFile = registerBase.dynamicCast<RegisterFile>())\r\n                    {\r\n                        registerFileValidator_->setChildItemValidity(asRegisterFile, false);\r\n                    }\r\n                });\r\n\r\n            errorFound = true;\r\n        }\r\n    }\r\n\r\n    return errorFound;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressBlockValidator::registersHaveSimilarDefinitionGroups()\r\n//-----------------------------------------------------------------------------\r\nbool AddressBlockValidator::registersHaveSimilarDefinitionGroups(QSharedPointer<Register> targetRegister,\r\n    QSharedPointer<AddressBlock> addressBlock, int indexOfSimilarDefinition) const\r\n{\r\n    if (indexOfSimilarDefinition <= addressBlock->getRegisterData()->size())\r\n    {\r\n        QSharedPointer<RegisterBase> registerData = addressBlock->getRegisterData()->at(indexOfSimilarDefinition);\r\n        QSharedPointer<Register> comparisonRegister = registerData.dynamicCast<Register>();\r\n        if (comparisonRegister)\r\n        {\r\n            if (targetRegister->getSize() != comparisonRegister->getSize() ||\r\n                targetRegister->getVolatile() != comparisonRegister->getVolatile() ||\r\n                targetRegister->getAccess() != comparisonRegister->getAccess())\r\n            {\r\n                registerValidator_->setChildItemValidity(targetRegister, false);\r\n                registerValidator_->setChildItemValidity(comparisonRegister, false);\r\n                return false;\r\n            }\r\n        }\r\n    }\r\n\r\n    return true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressBlockValidator::hasValidUsage()\r\n//-----------------------------------------------------------------------------\r\nbool AddressBlockValidator::hasValidUsage(QSharedPointer<AddressBlock> addressBlock) const\r\n{\r\n    if (!addressBlock->getRegisterData()->isEmpty())\r\n    {\r\n        if (addressBlock->getUsage() == General::RESERVED)\r\n        {\r\n            return false;\r\n        }\r\n/*\r\n        else if (addressBlock->getUsage() == General::MEMORY)\r\n        {\r\n            for (QSharedPointer<RegisterBase> const& registerData : *addressBlock->getRegisterData())\r\n            {\r\n                QSharedPointer<Register> targetRegister = registerData.dynamicCast<Register>();\r\n                if (targetRegister)\r\n                {\r\n                    if (!targetRegister->getVolatile().isEmpty() ||\r\n                        targetRegister->getAccess() != AccessTypes::ACCESS_COUNT)\r\n                    {\r\n                        return false;\r\n                    }\r\n                }\r\n            }\r\n        }\r\n*/\r\n    }\r\n\r\n    return true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressBlockValidator::hasValidRegisterAlignment()\r\n//-----------------------------------------------------------------------------\r\nbool AddressBlockValidator::hasValidRegisterAlignment(QSharedPointer<AddressBlock> addressBlock) const\r\n{\r\n    // Check scr 7.27 (for each register in address block, if misalignment == false \r\n    // then the following should be true: (register bit offset % addressBlock width) + register size <= address block width)\r\n\r\n    if (docRevision_ != Document::Revision::Std22 || General::str2Bool(addressBlock->getMisalignmentAllowed(), true))\r\n    {\r\n        return true;\r\n    }\r\n\r\n    bool addressBlockExpressionOk;\r\n    qint64 addressBlockWidth = getExpressionParser()->parseExpression(addressBlock->getWidth(), &addressBlockExpressionOk).toLongLong();\r\n\r\n    for (auto const& singleRegisterData : *addressBlock->getRegisterData())\r\n    {\r\n        if (auto singleRegister = singleRegisterData.dynamicCast<Register>())\r\n        {\r\n            bool registerSizeOk;\r\n            qint64 registerSize = getExpressionParser()->parseExpression(singleRegister->getSize(), &registerSizeOk).toLongLong();\r\n\r\n            bool registerOffsetOk;\r\n            qint64 registerOffset = getExpressionParser()->parseExpression(singleRegister->getAddressOffset(), &registerOffsetOk).toLongLong();\r\n\r\n            // SCR 7.27\r\n            qint64 valueToCheck = (registerOffset % addressBlockWidth) + registerSize;\r\n\r\n            if (addressBlockExpressionOk && registerOffsetOk && registerSizeOk &&\r\n                valueToCheck > addressBlockWidth)\r\n            {\r\n                return false;\r\n            }\r\n        }\r\n    }\r\n\r\n    return true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressBlockValidator::hasValidMemoryArray()\r\n//-----------------------------------------------------------------------------\r\nbool AddressBlockValidator::hasValidMemoryArray(QSharedPointer<AddressBlock> addressBlock) const\r\n{\r\n    if (auto memArray = addressBlock->getMemoryArray())\r\n    {\r\n        MemoryArrayValidator validator(getExpressionParser());\r\n\r\n        return validator.validate(memArray);\r\n    }\r\n\r\n    return true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressBlockValidator::hasValidAccessPolicies()\r\n//-----------------------------------------------------------------------------\r\nbool AddressBlockValidator::hasValidAccessPolicies(QSharedPointer<AddressBlock> addressBlock) const\r\n{\r\n    return CommonItemsValidator::hasValidAccessPolicies(addressBlock->getAccessPolicies(), componentModes_);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressBlockValidator::hasValidStructure()\r\n//-----------------------------------------------------------------------------\r\nbool AddressBlockValidator::hasValidStructure(QSharedPointer<AddressBlock> addressBlock) const\r\n{\r\n    if (docRevision_ == Document::Revision::Std22)\r\n    {\r\n        if (!addressBlock->getTypeDefinitionsRef().isEmpty() && hasAddressBlockDefinitionGroupDefined(addressBlock))\r\n        {\r\n            return false;\r\n        }\r\n    }\r\n\r\n    return true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressBlockValidator::findErrorsIn()\r\n//-----------------------------------------------------------------------------\r\nvoid AddressBlockValidator::findErrorsIn(QVector<QString>& errors, QSharedPointer<AddressBlock> addressBlock,\r\n    QString const& addressUnitBits, QString const& context) const\r\n{    \r\n    QString addressBlockContext = getBlockType() + QStringLiteral(\" \") + addressBlock->name();\r\n    findErrorsInName(errors, addressBlock, context);\r\n    findErrorsInBaseAddress(errors, addressBlock, context);\r\n    findErrorsInUsage(errors, addressBlock, context);\r\n    findErrorsInParameters(errors, addressBlock, addressBlockContext);\r\n    findErrorsInRegisterData(errors, addressBlock, addressUnitBits, addressBlockContext);\r\n\r\n    if (docRevision_ == Document::Revision::Std14)\r\n    {\r\n        findErrorsInIsPresent(errors, addressBlock, context);\r\n        findErrorsInRange(errors, addressBlock, context);\r\n        findErrorsInWidth(errors, addressBlock, context);\r\n    }\r\n\r\n    else if (docRevision_ == Document::Revision::Std22)\r\n    {\r\n        if (addressBlock->getAddressBlockDefinitionRef().isEmpty())\r\n        {\r\n            findErrorsInRange(errors, addressBlock, context);\r\n            findErrorsInWidth(errors, addressBlock, context);\r\n        }\r\n\r\n        QString preciseContext = QStringLiteral(\"address block \") + addressBlock->name() + QStringLiteral(\" within \") + context;\r\n        findErrorsInMemoryArray(errors, addressBlock, preciseContext);\r\n        findErrorsInAccessPolicies(errors, addressBlock, preciseContext);\r\n        findErrorsInRegisterAlignment(errors, addressBlock, preciseContext);\r\n        findErrorsInStructure(errors, addressBlock, context);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressBlockValidator::findErrorsInRange()\r\n//-----------------------------------------------------------------------------\r\nvoid AddressBlockValidator::findErrorsInRange(QVector<QString>& errors, QSharedPointer<AddressBlock> addressBlock,\r\n    QString const& context) const\r\n{\r\n    if (!hasValidRange(addressBlock))\r\n    {\r\n        errors.append(QObject::tr(\"Invalid range set for address block %1 within %2\").\r\n            arg(addressBlock->name()).arg(context));\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressBlockValidator::findErrorsInWidth()\r\n//-----------------------------------------------------------------------------\r\nvoid AddressBlockValidator::findErrorsInWidth(QVector<QString>& errors, QSharedPointer<AddressBlock> addressBlock,\r\n    QString const& context) const\r\n{\r\n    if (!hasValidWidth(addressBlock))\r\n    {\r\n        errors.append(QObject::tr(\"Invalid width set for address block %1 within %2\").arg(addressBlock->name())\r\n            .arg(context));\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressBlockValidator::findErrorsInUsage()\r\n//-----------------------------------------------------------------------------\r\nvoid AddressBlockValidator::findErrorsInUsage(QVector<QString>& errors, QSharedPointer<AddressBlock> addressBlock,\r\n    QString const& context) const\r\n{\r\n    if (addressBlock->getUsage() == General::RESERVED && !addressBlock->getRegisterData()->isEmpty())\r\n    {\r\n        errors.append(QObject::tr(\"Registers cannot be contained in address block %1 with usage %2 within %3\")\r\n            .arg(addressBlock->name()).arg(General::usage2Str(addressBlock->getUsage())).arg(context));\r\n    }\r\n/*\r\n    else if (addressBlock->getUsage() == General::MEMORY)\r\n    {\r\n        for (QSharedPointer<RegisterBase> const& registerData : *addressBlock->getRegisterData())\r\n        {\r\n            QSharedPointer<Register> targetRegister = registerData.dynamicCast<Register>();\r\n            if (targetRegister)\r\n            {\r\n                if (!targetRegister->getVolatile().isEmpty() ||\r\n                    targetRegister->getAccess() != AccessTypes::ACCESS_COUNT)\r\n                {\r\n                    errors.append(QObject::tr(\"Access and volatile values must be empty for register %1 in \"\r\n                        \"address block %2 with usage %3 within %4\").arg(targetRegister->name())\r\n                        .arg(addressBlock->name()).arg(General::usage2Str(addressBlock->getUsage())).arg(context));\r\n                }\r\n            }\r\n        }\r\n    }\r\n*/\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressBlockValidator::findErrorsInRegisterData()\r\n//-----------------------------------------------------------------------------\r\nvoid AddressBlockValidator::findErrorsInRegisterData(QVector<QString>& errors,\r\n    QSharedPointer<AddressBlock> addressBlock, QString const& addressUnitBits, QString const& context) const\r\n{\r\n    if (addressBlock->getRegisterData()->isEmpty())\r\n    {\r\n        return;\r\n    }\r\n\r\n    QStringList registerNames;\r\n    QStringList registerFileNames;\r\n    QStringList duplicateRegisterNames;\r\n    QStringList duplicateRegisterFileNames;\r\n    QStringList typeIdentifiers;\r\n\r\n    MemoryReserve reservedArea;\r\n    bool aubChangeOk = true;\r\n    qint64 aubInt = getExpressionParser()->parseExpression(addressUnitBits).toLongLong(&aubChangeOk);\r\n    qint64 addressBlockRange = getExpressionParser()->parseExpression(addressBlock->getRange()).toLongLong();\r\n\r\n    for (QSharedPointer<RegisterBase> const& registerData : *addressBlock->getRegisterData())\r\n    {\r\n        QSharedPointer<Register> targetRegister = registerData.dynamicCast<Register>();\r\n        if (targetRegister)\r\n        {\r\n            if (registerNames.contains(targetRegister->name()) &&\r\n                !duplicateRegisterNames.contains(targetRegister->name()))\r\n            {\r\n                errors.append(QObject::tr(\"Name %1 of registers in addressBlock %2 is not unique.\")\r\n                    .arg(targetRegister->name()).arg(addressBlock->name()));\r\n                duplicateRegisterNames.append(targetRegister->name());\r\n            }\r\n            else\r\n            {\r\n                registerNames.append(targetRegister->name());\r\n            }\r\n\r\n            registerValidator_->findErrorsIn(errors, targetRegister, context);\r\n\r\n            if (registerSizeIsNotWithinBlockWidth(targetRegister, addressBlock))\r\n            {\r\n                errors.append(QObject::tr(\"Register %1 size must not be greater than the containing \"\r\n                    \"addressBlock %2 width.\").arg(targetRegister->name()).arg(addressBlock->name()));\r\n            }\r\n                \r\n            if (!hasValidVolatileForRegister(addressBlock, targetRegister))\r\n            {\r\n                errors.append(QObject::tr(\"Volatile value cannot be set to false for addressBlock %1 \"\r\n                    \"containing a register or register field with volatile true\").arg(addressBlock->name()));\r\n            }\r\n\r\n            if (!targetRegister->getTypeIdentifier().isEmpty() &&\r\n                typeIdentifiers.contains(targetRegister->getTypeIdentifier()))\r\n            {\r\n                int typeIdentifierIndex = typeIdentifiers.indexOf(targetRegister->getTypeIdentifier());\r\n\r\n                if (!registersHaveSimilarDefinitionGroups(targetRegister, addressBlock, typeIdentifierIndex))\r\n                {\r\n                    errors.append(QObject::tr(\"Registers containing the same type identifiers must contain \"\r\n                        \"similar register definitions within %1\").arg(context));\r\n                }\r\n            }\r\n            typeIdentifiers.append(targetRegister->getTypeIdentifier());\r\n\r\n            if (docRevision_ == Document::Revision::Std14 && !hasValidAccessWithRegister(addressBlock, targetRegister))\r\n            {\r\n                errors.append(QObject::tr(\r\n                    \"Access cannot be set to %1 in register %2, where containing address block %3 has access %4\")\r\n                    .arg(AccessTypes::access2Str(targetRegister->getAccess()))\r\n                    .arg(targetRegister->name())\r\n                    .arg(addressBlock->name())\r\n                    .arg(AccessTypes::access2Str(addressBlock->getAccess())));\r\n            }\r\n\r\n            if (aubChangeOk && aubInt != 0)\r\n            {\r\n                qint64 registerSize = getRegisterSizeInLAU(targetRegister, aubInt);\r\n\r\n                qint64 registerBegin =\r\n                    getExpressionParser()->parseExpression(targetRegister->getAddressOffset()).toLongLong();\r\n\r\n                qint64 registerEnd = registerBegin + registerSize - 1;\r\n\r\n                if(targetRegister->getIsPresent().isEmpty() ||\r\n                    getExpressionParser()->parseExpression(targetRegister->getIsPresent()).toInt())\r\n                {\r\n                    reservedArea.addArea(targetRegister->name(), registerBegin, registerEnd);\r\n                }\r\n\r\n                if ( registerBegin < 0 || registerBegin + registerSize > addressBlockRange)\r\n                {\r\n                    errors.append(QObject::tr(\"Register %1 is not contained within %2\")\r\n                        .arg(targetRegister->name()).arg(context));\r\n                }\r\n            }\r\n        }\r\n        else if (QSharedPointer<RegisterFile> targetRegisterFile = registerData.dynamicCast<RegisterFile>())\r\n        {\r\n            if (registerFileNames.contains(targetRegisterFile->name()) &&\r\n                !duplicateRegisterFileNames.contains(targetRegisterFile->name()))\r\n            {\r\n                errors.append(QObject::tr(\"Name %1 of register files in addressBlock %2 is not unique.\")\r\n                    .arg(targetRegisterFile->name()).arg(addressBlock->name()));\r\n                duplicateRegisterFileNames.append(targetRegisterFile->name());\r\n            }\r\n            else\r\n            {\r\n                registerFileNames.append(targetRegisterFile->name());\r\n            }\r\n\r\n            registerFileValidator_->findErrorsIn(errors, targetRegisterFile, context, addressUnitBits, addressBlock->getWidth());\r\n\r\n            qint64 registerFileBegin = getExpressionParser()->parseExpression(\r\n                targetRegisterFile->getAddressOffset()).toLongLong();\r\n\r\n            qint64 registerFileRangeInt = getTrueRegisterFileRange(targetRegisterFile);\r\n\r\n            qint64 registerFileEnd = registerFileBegin + registerFileRangeInt - 1;\r\n\r\n            if (targetRegisterFile->getIsPresent().isEmpty() ||\r\n                getExpressionParser()->parseExpression(targetRegisterFile->getIsPresent()).toInt())\r\n            {\r\n                reservedArea.addArea(targetRegisterFile->name(), registerFileBegin, registerFileEnd);\r\n            }\r\n\r\n            if (registerFileBegin < 0 || registerFileBegin + registerFileRangeInt > addressBlockRange)\r\n            {\r\n                errors.append(QObject::tr(\"Register file %1 is not contained within %2\")\r\n                    .arg(targetRegisterFile->name()).arg(context));\r\n            }\r\n        }\r\n    }\r\n\r\n    reservedArea.findErrorsInOverlap(errors, QLatin1String(\"Register data\"), context);\r\n    \r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressBlockValidator::findErrorsInMemoryArray()\r\n//-----------------------------------------------------------------------------\r\nvoid AddressBlockValidator::findErrorsInMemoryArray(QStringList& errors, QSharedPointer<AddressBlock> addressBlock, QString const& context) const\r\n{\r\n    if (auto memArray = addressBlock->getMemoryArray())\r\n    {\r\n        MemoryArrayValidator validator(getExpressionParser());\r\n\r\n        validator.findErrorsIn(errors, memArray, context);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressBlockValidator::findErrorsInAccessPolicies()\r\n//-----------------------------------------------------------------------------\r\nvoid AddressBlockValidator::findErrorsInAccessPolicies(QStringList& errors, QSharedPointer<AddressBlock> addressBlock, QString const& context) const\r\n{\r\n    CommonItemsValidator::findErrorsInAccessPolicies(errors, addressBlock->getAccessPolicies(), componentModes_, context);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressBlockValidator::findErrorsInRegisterAlignment()\r\n//-----------------------------------------------------------------------------\r\nvoid AddressBlockValidator::findErrorsInRegisterAlignment(QStringList& errors, QSharedPointer<AddressBlock> addressBlock, QString const& context) const\r\n{\r\n    if (!hasValidRegisterAlignment(addressBlock))\r\n    {\r\n        errors.append(QObject::tr(\"Register misalignment set to false for %1, \"\r\n            \"where one or more registers are fully or partly offset outside of the address block width.\")\r\n            .arg(context));\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressBlockValidator::findErrorsInStructure()\r\n//-----------------------------------------------------------------------------\r\nvoid AddressBlockValidator::findErrorsInStructure(QStringList& errors, QSharedPointer<AddressBlock> addressBlock,\r\n    QString const& context) const\r\n{\r\n    if (!hasValidStructure(addressBlock))\r\n    {\r\n        errors.append(QObject::tr(\"Address block %1 in %2 must not be explicitly defined while also containing\" \r\n            \" a definition reference.\").arg(addressBlock->name()).arg(context));\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressBlockValidator::getRegisterSizeInLAU()\r\n//-----------------------------------------------------------------------------\r\nqint64 AddressBlockValidator::getRegisterSizeInLAU(QSharedPointer<Register> targetRegister, qint64 addressUnitBits) const\r\n{\r\n    qint64 size = getExpressionParser()->parseExpression(targetRegister->getSize()).toLongLong();\r\n    qint64 dimensionsProduct = 1;\r\n\r\n    if (auto memArray = targetRegister->getMemoryArray())\r\n    {\r\n        for (auto const& dimension : *memArray->getDimensions())\r\n        {\r\n            dimensionsProduct *= getExpressionParser()->parseExpression(dimension->value_).toLongLong();\r\n        }\r\n    }\r\n\r\n    // Round register size up to closest multiple of AUB to get size in least addressable units/AUB.\r\n    qint64 dimensionlessSize = static_cast<qint64>(std::ceil(size / static_cast<double>(addressUnitBits)));\r\n\r\n    qint64 trueSize = dimensionlessSize * dimensionsProduct;\r\n\r\n    return trueSize;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressBlockValidator::getRealRegisterFileRange()\r\n//-----------------------------------------------------------------------------\r\nqint64 AddressBlockValidator::getTrueRegisterFileRange(QSharedPointer<RegisterFile> targetRegisterFile) const\r\n{\r\n    qint64 dimensionsProduct = 1;\r\n\r\n    if (auto memArray = targetRegisterFile->getMemoryArray())\r\n    {\r\n        for (auto const& dimension : *memArray->getDimensions())\r\n        {\r\n            dimensionsProduct *= getExpressionParser()->parseExpression(dimension->value_).toLongLong();\r\n        }\r\n    }\r\n\r\n    qint64 dimensionlessRange = getExpressionParser()->parseExpression(targetRegisterFile->getRange()).toLongLong();\r\n    qint64 trueRange = dimensionlessRange * dimensionsProduct;\r\n\r\n    return trueRange;\r\n}\r\n"
  },
  {
    "path": "IPXACTmodels/Component/validators/AddressBlockValidator.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: AddressBlockValidator.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 23.11.2015\r\n//\r\n// Description:\r\n// Validator for ipxact:addressBlock.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef ADDRESSBLOCKVALIDATOR_H\r\n#define ADDRESSBLOCKVALIDATOR_H\r\n\r\n#include <IPXACTmodels/ipxactmodels_global.h>\r\n\r\n#include <IPXACTmodels/Component/validators/MemoryBlockValidator.h>\r\n#include <IPXACTmodels/common/Document.h>\r\n\r\n#include <QSharedPointer>\r\n#include <QString>\r\n\r\nclass ExpressionParser;\r\nclass AddressBlock;\r\nclass Register;\r\nclass RegisterBase;\r\nclass RegisterFile;\r\nclass ResetType;\r\nclass Component;\r\nclass RegisterValidator;\r\nclass RegisterFileValidator;\r\nclass ParameterValidator;\r\nclass Mode;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Validator for ipxact:addressBlock.\r\n//-----------------------------------------------------------------------------\r\nclass IPXACTMODELS_EXPORT AddressBlockValidator : public MemoryBlockValidator\r\n{\r\npublic:\r\n\r\n\t/*!\r\n\t *  The constructor.\r\n\t *\r\n\t *    @param [in] expressionParser    The parser to use for solving expressions.\r\n     *    @param [in] registerValidator   Validator used for registers.\r\n     *    @param [in] parameterValidator  Validator used for parameters.\r\n     *    @param [in] docRevision         The IP-XACT standard revision to comply to.\r\n\t */\r\n    AddressBlockValidator(QSharedPointer<ExpressionParser> expressionParser, \r\n        QSharedPointer<RegisterValidator> registerValidator,\r\n        QSharedPointer<RegisterFileValidator> registerFileValidator, \r\n        QSharedPointer<ParameterValidator> parameterValidator, Document::Revision docRevision);\r\n\r\n\t//! The destructor.\r\n\tvirtual ~AddressBlockValidator() = default;\r\n\r\n    // Disable copying.\r\n    AddressBlockValidator(AddressBlockValidator const& rhs) = delete;\r\n    AddressBlockValidator& operator=(AddressBlockValidator const& rhs) = delete;\r\n    \r\n    /*!\r\n     *  Change the containing component.\r\n     *\r\n     *    @param [in] newComponent    The selected component.\r\n     */\r\n    void componentChange(QSharedPointer<Component> newComponent);\r\n\r\n    /*!\r\n     *  Get the used register validator.\r\n     *\r\n     *    @return The used register validator.\r\n     */\r\n    QSharedPointer<RegisterValidator> getRegisterValidator() const;\r\n\r\n    /*!\r\n     *  Get the used register file validator.\r\n     *\r\n     *    @return The used register validator.\r\n     */\r\n    QSharedPointer<RegisterFileValidator> getRegisterFileValidator() const;\r\n\r\n    /*!\r\n     *  Validates the given address block.\r\n     *\r\n     *    @param [in] addressBlock        The address block to validate.\r\n     *    @param [in] addressUnitBits     The address unit bits of a memory map.\r\n     *\r\n     *    @return True, if the address block is valid IP-XACT, otherwise false.\r\n     */\r\n    bool validate(QSharedPointer<AddressBlock> addressBlock, QString const& addressUnitBits);\r\n\r\n    /*!\r\n     *  Check if the address block contains a valid range.\r\n     *\r\n     *    @param [in] addressBlock    The selected address block.\r\n     *\r\n     *    @return True, if the range is valid, otherwise false.\r\n     */\r\n    bool hasValidRange(QSharedPointer<AddressBlock> addressBlock) const;\r\n\r\n    /*!\r\n     *  Check if the address block contains a valid width.\r\n     *\r\n     *    @param [in] addressBlock    The selected address block.\r\n     *\r\n     *    @return True, if the width is valid, otherwise false.\r\n     */\r\n    bool hasValidWidth(QSharedPointer<AddressBlock> addressBlock) const;\r\n\r\n    /*!\r\n     *  Check if the address block contains valid register data.\r\n     *\r\n     *    @param [in] addressBlock        The selected address block.\r\n     *    @param [in] addressUnitBits     The address unit bits of a memory map.\r\n     *\r\n     *    @return True, if the register data is valid, otherwise false.\r\n     */\r\n    bool hasValidRegisterData(QSharedPointer<AddressBlock> addressBlock, QString const& addressUnitBits);\r\n\r\n    /*!\r\n     *  Check if the register size is not within address block width.\r\n     *\r\n     *    @param [in] targetRegister  The selected register.\r\n     *    @param [in] addressBlock    The selected address block.\r\n     *\r\n     *    @return True, if the register size within address block width, otherwise false.\r\n     */\r\n    bool registerSizeIsNotWithinBlockWidth(QSharedPointer<Register> targetRegister,\r\n        QSharedPointer<AddressBlock> addressBlock) const;\r\n\r\n    /*!\r\n     *  Check if the address block contains a valid volatile value compared to registers.\r\n     *\r\n     *    @param [in] addressBlock    The selected address block.\r\n     *    @param [in] targetRegister  The selected register.\r\n     *\r\n     *    @return True, if the volatile is valid, otherwise false.\r\n     */\r\n    bool hasValidVolatileForRegister(QSharedPointer<AddressBlock> addressBlock,\r\n        QSharedPointer<Register> targetRegister) const;\r\n\r\n    /*!\r\n     *  Check if the address block contains a valid usage.\r\n     *\r\n     *    @param [in] addressBlock    The selected address block.\r\n     *\r\n     *    @return True, if the usage is valid, otherwise false.\r\n     */\r\n    bool hasValidUsage(QSharedPointer<AddressBlock> addressBlock) const;\r\n\r\n    /*!\r\n     *\tCheck if the registers contained within the address block are aligned correctly according to the misalignment allowed attribute.\r\n     *  \r\n     *    @param [in] addressBlock     The selected address block.\r\n     *\t    \r\n     * \t    @return Bool, if the registers are aligned correctly, otherwise false.\r\n     */\r\n    bool hasValidRegisterAlignment(QSharedPointer<AddressBlock> addressBlock) const;\r\n\r\n    /*!\r\n     *\tCheck if the memory array of the address block is valid.\r\n     *  \r\n     *    @param [in] addressBlock     The selected address block.\r\n     *\t    \r\n     * \t    @return True, if the memory array is valid, otherwise false.\r\n     */\r\n    bool hasValidMemoryArray(QSharedPointer<AddressBlock> addressBlock) const;\r\n\r\n    /*!\r\n     *\tCheck if the address block has valid access policies.\r\n     *  \r\n     *    @param [in] addressBlock     The selected address block.\r\n     *\t    \r\n     * \t    @return True, if the access policies are valid, otherwise false.\r\n     */\r\n    bool hasValidAccessPolicies(QSharedPointer<AddressBlock> addressBlock) const;\r\n\r\n    /*!\r\n     *\tCheck if the combination of defined sub-elements of the address block is valid.\r\n     *  \r\n     *    @param [in] addressBlock     The selected address block.\r\n     *\t    \r\n     * \t    @return True, if the combination of sub-elements is valid, otherwise false.\r\n     */\r\n    bool hasValidStructure(QSharedPointer<AddressBlock> addressBlock) const;\r\n\r\n    /*!\r\n     *  Locate errors within an address block.\r\n     *\r\n     *    @param [in] errors              List of found errors.\r\n     *    @param [in] addressBlock        The selected address block.\r\n     *    @param [in] addressUnitBits     The address unit bits of a memory map.\r\n     *    @param [in] context             Context to help locate the error.\r\n     */\r\n    void findErrorsIn(QVector<QString>& errors, QSharedPointer<AddressBlock> addressBlock,\r\n        QString const& addressUnitBits, QString const& context) const;\r\n\r\nprivate:\r\n\r\n    /*!\r\n     *\tMark overlapping registers as invalid.\r\n     *\r\n     *    @param [in] regIter             Iterator pointing to current register(file).\r\n     *    @param [in] lastEndAddress      Currently biggest register end address found.\r\n     *    @param [in] addressBlockRange   The address block range.\r\n     *    @param [in] addressUnitBits     The memory map address unit bits.\r\n     *    @param [in] targetIsRegister    Flag indicating if regIter points to register or register file.\r\n     *    @param [in] lastWasRegister     Flag indicating if the previous item was a register or register file.\r\n     *\r\n     * \t    @return True, if overlapping registers and/or register files were found, otherwise false.\r\n     */\r\n    bool markRegisterOverlap(QList<QSharedPointer<RegisterBase> >::iterator regIter, qint64& lastEndAddress, qint64 addressBlockRange, qint64 addressUnitBits, bool targetIsRegister, bool lastWasRegister);\r\n\r\n    /*!\r\n     *\tMark registers with duplicate names as invalid.\r\n     *\r\n     *    @param [in] foundNames     The registers and register files to check.\r\n     *\r\n     * \t    @return True, if duplicate names were found, otherwise false.\r\n     */\r\n    bool markDuplicateNames(QMultiHash<QString, QSharedPointer<RegisterBase>> const& foundNames);\r\n\r\n    /*!\r\n     *  Get the type of the memory block.\r\n     *\r\n     *    @return Identification type of the memory block.\r\n     */\r\n    virtual QString getBlockType() const override final;\r\n\r\n    /*!\r\n     *  Check if the contained registers have similar register definitions.\r\n     *\r\n     *    @param [in] targetRegister              The selected register.\r\n     *    @param [in] addressBlock                The selected address block.\r\n     *    @param [in] indexOfSimilarDefinition    The index of the register with similar register definition.\r\n     *\r\n     *    @return True, if the register definitions are similar, otherwise false.\r\n     */\r\n    bool registersHaveSimilarDefinitionGroups(QSharedPointer<Register> targetRegister,\r\n        QSharedPointer<AddressBlock> addressBlock, int indexOfSimilarDefinition) const;\r\n\r\n    /*!\r\n     *  Check if a register contain a valid access.\r\n     *\r\n     *    @param [in] addressBlock    The selected address block.\r\n     *    @param [in] targetRegister  The selected register.\r\n     *\r\n     *    @return True, if the register has a valid access, otherwise false.\r\n     */\r\n    bool hasValidAccessWithRegister(QSharedPointer<AddressBlock> addressBlock,\r\n        QSharedPointer<Register> targetRegister) const;\r\n\r\n    /*!\r\n     *\tChecks if the address block has any address block definition group elements defined.\r\n     *  \r\n     *    @param [in] addressBlock    The selected address block.\r\n     *\r\n     * \t    @return True, if any elements in the address block definition group are defined, otherwise false.\r\n     */\r\n    bool hasAddressBlockDefinitionGroupDefined(QSharedPointer<AddressBlock> addressBlock) const;\r\n\r\n    /*!\r\n     *\tChecks if the address block has any memory block data group elements defined.\r\n     *\r\n     *    @param [in] addressBlock    The selected address block.\r\n     *\r\n     * \t    @return True, if any elements in the memory block data group are defined, otherwise false.\r\n     */\r\n    bool hasMemoryBlockDataGroupDefined(QSharedPointer<AddressBlock> addressBlock) const;\r\n\r\n    /*!\r\n     *  Gets the register size in LAU (least addressable unit).\r\n     *\r\n     *    @param [in] targetRegister      The selected register.\r\n     *    @param [in] addressUnitBits     The address unit bits of a memory map.\r\n     *\r\n     *    @return The register size in LAU.\r\n     */\r\n    qint64 getRegisterSizeInLAU(QSharedPointer<Register> targetRegister, qint64 addressUnitBits) const;\r\n\r\n    /*!\r\n     *\tGet register file range (size in AUB) taking dimensions into account.\r\n     *  \r\n     *    @param [in] targetRegisterFile     The register file to get range of.\r\n     *\t    \r\n     * \t    @return The true register file range.\r\n     */\r\n    qint64 getTrueRegisterFileRange(QSharedPointer<RegisterFile> targetRegisterFile) const;\r\n\r\n    /*!\r\n     *  Find errors within the address block range.\r\n     *\r\n     *    @param [in] errors          List of found errors.\r\n     *    @param [in] addressBlock    The selected addressBlock.\r\n     *    @param [in] context         Context to help locate the error.\r\n     */\r\n    void findErrorsInRange(QVector<QString>& errors, QSharedPointer<AddressBlock> addressBlock,\r\n        QString const& context) const;\r\n\r\n    /*!\r\n     *  Find errors within address block width.\r\n     *\r\n     *    @param [in] errors          List of found errors.\r\n     *    @param [in] addressBlock    The selected addressBlock.\r\n     *    @param [in] context         Context to help locate the error.\r\n     */\r\n    void findErrorsInWidth(QVector<QString>& errors, QSharedPointer<AddressBlock> addressBlock,\r\n        QString const& context) const;\r\n\r\n    /*!\r\n     *  Find errors within address block usage.\r\n     *\r\n     *    @param [in] errors          List of found errors.\r\n     *    @param [in] addressBlock    The selected addressBlock.\r\n     *    @param [in] context         Context to help locate the error.\r\n     */\r\n    void findErrorsInUsage(QVector<QString>& errors, QSharedPointer<AddressBlock> addressBlock,\r\n        QString const& context) const;\r\n\r\n    /*!\r\n     *  Find errors within register data.\r\n     *\r\n     *    @param [in] errors              List of found errors.\r\n     *    @param [in] addressBlock        The selected addressBlock.\r\n     *    @param [in] addressUnitBits     The address unit bits of a memory map.\r\n     *    @param [in] context             Context to help locate the error.\r\n     */\r\n    void findErrorsInRegisterData(QVector<QString>& errors, QSharedPointer<AddressBlock> addressBlock,\r\n        QString const& addressUnitBits, QString const& context) const;\r\n\r\n    /*!\r\n     *\tFind errors within the address block memory array.\r\n     *  \r\n     *    @param [in] errors              List of found errors.\r\n     *    @param [in] addressBlock        The selected addressBlock.\r\n     *    @param [in] context             Context to help locate the error.\r\n     */\r\n    void findErrorsInMemoryArray(QStringList& errors, QSharedPointer<AddressBlock> addressBlock,\r\n        QString const& context) const;\r\n\r\n    /*!\r\n     *\tFind errors within the address block access policies.\r\n     *\r\n     *    @param [in] errors              List of found errors.\r\n     *    @param [in] addressBlock        The selected addressBlock.\r\n     *    @param [in] context             Context to help locate the error.\r\n     */\r\n    void findErrorsInAccessPolicies(QStringList& errors, QSharedPointer<AddressBlock> addressBlock,\r\n        QString const& context) const;\r\n\r\n    /*!\r\n     *\tFind errors regarding the register alignment of the address block registers.\r\n     *\r\n     *    @param [in] errors              List of found errors.\r\n     *    @param [in] addressBlock        The selected addressBlock.\r\n     *    @param [in] context             Context to help locate the error.\r\n     */\r\n    void findErrorsInRegisterAlignment(QStringList& errors, QSharedPointer<AddressBlock> addressBlock,\r\n        QString const& context) const;\r\n\r\n    /*!\r\n     *\tFind errors in the address block structure, the combination of sub-elements.\r\n     *  \r\n     *    @param [in] errors              List of found errors.\r\n     *    @param [in] addressBlock        The selected addressBlock.\r\n     *    @param [in] context             Context to help locate the error.\r\n     */\r\n    void findErrorsInStructure(QStringList& errors, QSharedPointer<AddressBlock> addressBlock,\r\n        QString const& context) const;\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! The validator used for registers.\r\n    QSharedPointer<RegisterValidator> registerValidator_;\r\n\r\n    //! The validator used for register files.\r\n    QSharedPointer<RegisterFileValidator> registerFileValidator_;\r\n\r\n    //! Available component modes.\r\n    QSharedPointer<QList<QSharedPointer<Mode> > > componentModes_;\r\n\r\n};\r\n\r\n#endif // ADDRESSBLOCKVALIDATOR_H\r\n"
  },
  {
    "path": "IPXACTmodels/Component/validators/AddressSpaceValidator.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: AddressSpaceValidator.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 30.11.2015\r\n//\r\n// Description:\r\n// Validator for the ipxact:addressSpace.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"AddressSpaceValidator.h\"\r\n\r\n#include <KactusAPI/include/ExpressionParser.h>\r\n\r\n#include <IPXACTmodels/Component/validators/MemoryReserve.h>\r\n#include <IPXACTmodels/Component/validators/MemoryMapBaseValidator.h>\r\n#include <IPXACTmodels/Component/AddressSpace.h>\r\n#include <IPXACTmodels/Component/Segment.h>\r\n#include <IPXACTmodels/Component/Component.h>\r\n#include <IPXACTmodels/Component/AddressBlock.h>\r\n\r\n#include <IPXACTmodels/common/validators/ParameterValidator.h>\r\n#include <IPXACTmodels/common/Parameter.h>\r\n\r\n#include <QRegularExpression>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressSpaceValidator::AddressSpaceValidator()\r\n//-----------------------------------------------------------------------------\r\nAddressSpaceValidator::AddressSpaceValidator(QSharedPointer<ExpressionParser> expressionParser,\r\n    QSharedPointer<MemoryMapBaseValidator> memoryMapBaseValidator,\r\n    QSharedPointer<ParameterValidator> parameterValidator) :\r\nHierarchicalValidator(),\r\nexpressionParser_(expressionParser),\r\nlocalMemoryMapValidator_(memoryMapBaseValidator),\r\nparameterValidator_(parameterValidator)\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressSpaceValidator::getLocalMemoryMapValidator()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<MemoryMapBaseValidator> AddressSpaceValidator::getLocalMemoryMapValidator()\r\n{\r\n    return localMemoryMapValidator_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressSpaceValidator::validate()\r\n//-----------------------------------------------------------------------------\r\nbool AddressSpaceValidator::validate(QSharedPointer<AddressSpace> addressSpace) const\r\n{\r\n    return hasValidName(addressSpace->name()) && \r\n        hasValidIsPresent(addressSpace->getIsPresent()) &&\r\n        hasValidRange(addressSpace) && hasValidWidth(addressSpace) && hasValidSegments(addressSpace) &&\r\n        hasValidAddressUnitBits(addressSpace) && hasValidLocalMemoryMap(addressSpace) &&\r\n        hasValidParameters(addressSpace) && validComparedToSiblings(addressSpace);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressSpaceValidator::changeComponent()\r\n//-----------------------------------------------------------------------------\r\nvoid AddressSpaceValidator::componentChange(QSharedPointer<Component> newComponent)\r\n{\r\n    localMemoryMapValidator_->componentChange(newComponent);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressSpaceValidator::hasValidName()\r\n//-----------------------------------------------------------------------------\r\nbool AddressSpaceValidator::hasValidName(QString const& name) const\r\n{\r\n    QRegularExpression whiteSpaceExpression;\r\n    whiteSpaceExpression.setPattern(QStringLiteral(\"^\\\\s*$\"));\r\n    QRegularExpressionMatch whiteSpaceMatch = whiteSpaceExpression.match(name);\r\n\r\n    if (name.isEmpty() || whiteSpaceMatch.hasMatch())\r\n    {\r\n        return false;\r\n    }\r\n\r\n    return true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressSpaceValidator::hasValidIsPresent()\r\n//-----------------------------------------------------------------------------\r\nbool AddressSpaceValidator::hasValidIsPresent(QString const& isPresent) const\r\n{\r\n    if (!isPresent.isEmpty())\r\n    {\r\n        QString solvedValue = expressionParser_->parseExpression(isPresent);\r\n\r\n        bool toIntOk = true;\r\n        int intValue = solvedValue.toInt(&toIntOk);\r\n\r\n        if (!toIntOk || intValue < 0 || intValue > 1)\r\n        {\r\n            return false;\r\n        }\r\n    }\r\n\r\n    return true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressSpaceValidator::hasValidRange()\r\n//-----------------------------------------------------------------------------\r\nbool AddressSpaceValidator::hasValidRange(QSharedPointer<AddressSpace> addressSpace) const\r\n{\r\n    if (!addressSpace->getRange().isEmpty())\r\n    {\r\n        bool rangeOk = true;\r\n        bool expressionValid = false;\r\n        quint64 range =\r\n            expressionParser_->parseExpression(addressSpace->getRange(), &expressionValid).toULongLong(&rangeOk);\r\n\r\n        return rangeOk && expressionValid && range != 0;\r\n    }\r\n\r\n    return false;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressSpaceValidator::hasValidWidth()\r\n//-----------------------------------------------------------------------------\r\nbool AddressSpaceValidator::hasValidWidth(QSharedPointer<AddressSpace> addressSpace) const\r\n{\r\n    if (!addressSpace->getWidth().isEmpty())\r\n    {\r\n        bool widthOk = true;\r\n        bool expressionValid = false;\r\n        auto width =\r\n            expressionParser_->parseExpression(addressSpace->getWidth(), &expressionValid).toLongLong(&widthOk);\r\n\r\n        return widthOk && width >= 0;\r\n    }\r\n\r\n    return false;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressSpaceValidator::hasValidSegments()\r\n//-----------------------------------------------------------------------------\r\nbool AddressSpaceValidator::hasValidSegments(QSharedPointer<AddressSpace> addressSpace) const\r\n{\r\n    if (!addressSpace->getSegments()->isEmpty())\r\n    {\r\n        MemoryReserve reservedArea;\r\n\r\n        QStringList segmentNames;\r\n\r\n        qint64 addressSpaceRange = expressionParser_->parseExpression(addressSpace->getRange()).toLongLong();\r\n\r\n        for (QSharedPointer<Segment> segment : *addressSpace->getSegments())\r\n        {\r\n            qint64 segmentBegin = expressionParser_->parseExpression(segment->getAddressOffset()).toLongLong();\r\n            qint64 segmentRange = expressionParser_->parseExpression(segment->getRange()).toLongLong();\r\n            qint64 segmentEnd = segmentBegin + segmentRange - 1;\r\n\r\n            if (segmentNames.contains(segment->name()) ||\r\n                !hasValidName(segment->name()) ||\r\n                !hasValidIsPresent(segment->getIsPresent()) ||\r\n                !segmentHasValidAddressOffset(segment) ||\r\n                !segmentHasValidRange(segment) ||\r\n                segmentEnd > addressSpaceRange)\r\n            {\r\n                return false;\r\n            }\r\n            else\r\n            {\r\n                segmentNames.append(segment->name());\r\n\r\n                reservedArea.addArea(segment->name(), segmentBegin, segmentEnd);\r\n            }\r\n        }\r\n\r\n        return !reservedArea.hasOverlap();\r\n    }\r\n\r\n    return true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressSpaceValidator::segmentHasValidAddressOffset()\r\n//-----------------------------------------------------------------------------\r\nbool AddressSpaceValidator::segmentHasValidAddressOffset(QSharedPointer<Segment> segment) const\r\n{\r\n    if (!segment->getAddressOffset().isEmpty())\r\n    {\r\n        bool offsetOk = true;\r\n        expressionParser_->parseExpression(segment->getAddressOffset()).toULongLong(&offsetOk);\r\n\r\n        return offsetOk;\r\n    }\r\n\r\n    return false;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressSpaceValidator::segmentHasValidRange()\r\n//-----------------------------------------------------------------------------\r\nbool AddressSpaceValidator::segmentHasValidRange(QSharedPointer<Segment> segment) const\r\n{\r\n    if (!segment->getRange().isEmpty())\r\n    {\r\n        bool rangeOk = true;\r\n        quint64 range = expressionParser_->parseExpression(segment->getRange()).toULongLong(&rangeOk);\r\n\r\n        return rangeOk && range > 0;\r\n    }\r\n\r\n    return false;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressSpaceValidator::localMemMapaddressBlocksOverlap()\r\n//-----------------------------------------------------------------------------\r\nbool AddressSpaceValidator::addressBlocksAreContainedWithinAddressSpace(QSharedPointer<AddressSpace> addressSpace) const\r\n{\r\n    auto localMemMap = addressSpace->getLocalMemoryMap();\r\n\r\n    if (!localMemMap)\r\n    {\r\n        return true;\r\n    }\r\n\r\n    for (auto const& memoryBlock : *localMemMap->getMemoryBlocks())\r\n    {\r\n        auto addressBlock = memoryBlock.dynamicCast<AddressBlock>();\r\n\r\n        if (addressBlock && !addressBlockIsContainedWithinAddressSpace(addressSpace, addressBlock))\r\n        {\r\n            return false;\r\n        }\r\n    }\r\n\r\n    return true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressSpaceValidator::addressBlockIsContainedWithinLocalMemMap()\r\n//-----------------------------------------------------------------------------\r\nbool AddressSpaceValidator::addressBlockIsContainedWithinAddressSpace(QSharedPointer<AddressSpace> addressSpace, QSharedPointer<AddressBlock> addressBlock) const\r\n{\r\n    if (!addressBlock)\r\n    {\r\n        return false;\r\n    }\r\n    \r\n    bool rangeOk = false;\r\n    bool baseAddrOk = false;\r\n\r\n    quint64 addressBlockRange = expressionParser_->parseExpression(addressBlock->getRange()).toULongLong(&rangeOk);\r\n    quint64 startPos = expressionParser_->parseExpression(addressBlock->getBaseAddress()).toULongLong(&baseAddrOk);\r\n\r\n    if (!rangeOk || !baseAddrOk)\r\n    {\r\n        return false;\r\n    }\r\n\r\n    quint64 endPos = startPos + addressBlockRange;\r\n\r\n    return endPos <= expressionParser_->parseExpression(addressSpace->getRange()).toULongLong();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressSpaceValidator::findErrorsInAddressBlockRanges()\r\n//-----------------------------------------------------------------------------\r\nvoid AddressSpaceValidator::findErrorsInAddressBlockRanges(QStringList& errors, QSharedPointer<AddressSpace> addressSpace, QString const& context) const\r\n{\r\n    auto localMemMap = addressSpace->getLocalMemoryMap();\r\n\r\n    if (!localMemMap)\r\n    {\r\n        return;\r\n    }\r\n\r\n    for (auto const& memoryBlock : *localMemMap->getMemoryBlocks())\r\n    {\r\n        auto addressBlock = memoryBlock.dynamicCast<AddressBlock>();\r\n\r\n        if (addressBlock && !addressBlockIsContainedWithinAddressSpace(addressSpace, addressBlock))\r\n        {\r\n            errors.append(QObject::tr(\"Address block %1 is not contained within local memory map of %2.\")\r\n                .arg(addressBlock->name()).arg(context));\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressSpaceValidator::hasValidAddressUnitBits()\r\n//-----------------------------------------------------------------------------\r\nbool AddressSpaceValidator::hasValidAddressUnitBits(QSharedPointer<AddressSpace> addressSpace) const\r\n{\r\n    if (!addressSpace->getAddressUnitBits().isEmpty())\r\n    {\r\n        bool bitsOk = true;\r\n\r\n        quint64 unitBits =\r\n            expressionParser_->parseExpression(addressSpace->getAddressUnitBits()).toULongLong(&bitsOk);\r\n\r\n        return bitsOk && unitBits > 0;\r\n    }\r\n\r\n    return true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressSpaceValidator::hasValidLocalMemoryMap()\r\n//-----------------------------------------------------------------------------\r\nbool AddressSpaceValidator::hasValidLocalMemoryMap(QSharedPointer<AddressSpace> addressSpace) const\r\n{\r\n    if (auto localMemoryMap = addressSpace->getLocalMemoryMap())\r\n    {\r\n        QString addressUnitBits = addressSpace->getAddressUnitBits();\r\n        if (addressUnitBits.isEmpty())\r\n        {\r\n            addressUnitBits = QLatin1String(\"8\");\r\n        }\r\n\r\n        if (!localMemoryMapValidator_->validate(localMemoryMap, addressUnitBits) ||\r\n            !addressBlocksAreContainedWithinAddressSpace(addressSpace))\r\n        {\r\n            return false;\r\n        }\r\n    }\r\n\r\n    return true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressSpaceValidator::hasValidParameters()\r\n//-----------------------------------------------------------------------------\r\nbool AddressSpaceValidator::hasValidParameters(QSharedPointer<AddressSpace> addressSpace) const\r\n{\r\n    if (!addressSpace->getParameters()->isEmpty())\r\n    {\r\n        QStringList parameterNames;\r\n        for (QSharedPointer<Parameter> const& parameter : *addressSpace->getParameters())\r\n        {\r\n            if (parameterNames.contains(parameter->name()) || !parameterValidator_->validate(parameter))\r\n            {\r\n                return false;\r\n            }\r\n            else\r\n            {\r\n                parameterNames.append(parameter->name());\r\n            }\r\n        }\r\n    }\r\n\r\n    return true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressSpaceValidator::findErrorsIn()\r\n//-----------------------------------------------------------------------------\r\nvoid AddressSpaceValidator::findErrorsIn(QVector<QString>& errors, QSharedPointer<AddressSpace> addressSpace,\r\n    QString const& context) const\r\n{\r\n    QString addressSpaceContext = QStringLiteral(\"address space \") + addressSpace->name();\r\n\r\n    findErrorsInName(errors, addressSpace, context);\r\n    findErrorsInIsPresent(errors, addressSpace, context);\r\n    findErrorsInRange(errors, addressSpace, context);\r\n    findErrorsInWidth(errors, addressSpace, context);\r\n    findErrorsInSegments(errors, addressSpace, addressSpaceContext);\r\n    findErrorsInAddressUnitBits(errors, addressSpace, context);\r\n    findErrorsInLocalMemoryMap(errors, addressSpace, addressSpaceContext);\r\n    findErrorsInParameters(errors, addressSpace, addressSpaceContext);\r\n    findErrorsInAddressBlockRanges(errors, addressSpace, addressSpaceContext);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressSpaceValidator::findErrorsInName()\r\n//-----------------------------------------------------------------------------\r\nvoid AddressSpaceValidator::findErrorsInName(QVector<QString>& errors, QSharedPointer<AddressSpace> addressSpace,\r\n    QString const& context) const\r\n{\r\n    if (!hasValidName(addressSpace->name()))\r\n    {\r\n        errors.append(QObject::tr(\"Invalid name specified for address space %1 within %2\")\r\n            .arg(addressSpace->name()).arg(context));\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressSpaceValidator::findErrorsInIsPresent()\r\n//-----------------------------------------------------------------------------\r\nvoid AddressSpaceValidator::findErrorsInIsPresent(QVector<QString>& errors,\r\n    QSharedPointer<AddressSpace> addressSpace, QString const& context) const\r\n{\r\n    if (!hasValidIsPresent(addressSpace->getIsPresent()))\r\n    {\r\n        errors.append(QObject::tr(\"Invalid isPresent set for address space %1 within %2\")\r\n            .arg(addressSpace->name()).arg(context));\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressSpaceValidator::findErrorsInRange()\r\n//-----------------------------------------------------------------------------\r\nvoid AddressSpaceValidator::findErrorsInRange(QVector<QString>& errors, QSharedPointer<AddressSpace> addressSpace,\r\n    QString const& context) const\r\n{\r\n    if (!hasValidRange(addressSpace))\r\n    {\r\n        errors.append(QObject::tr(\"Invalid range set for address space %1 within %2\")\r\n            .arg(addressSpace->name()).arg(context));\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressSpaceValidator::findErrorsInWidth()\r\n//-----------------------------------------------------------------------------\r\nvoid AddressSpaceValidator::findErrorsInWidth(QVector<QString>& errors, QSharedPointer<AddressSpace> addressSpace,\r\n    QString const& context) const\r\n{\r\n    if (!hasValidWidth(addressSpace))\r\n    {\r\n        errors.append(QObject::tr(\"Invalid width set for address space %1 within %2\")\r\n            .arg(addressSpace->name()).arg(context));\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressSpaceValidator::findErrorsInSegments()\r\n//-----------------------------------------------------------------------------\r\nvoid AddressSpaceValidator::findErrorsInSegments(QVector<QString>& errors,\r\n    QSharedPointer<AddressSpace> addressSpace, QString const& context) const\r\n{\r\n    if (!addressSpace->getSegments()->isEmpty())\r\n    {\r\n        qint64 addressSpaceRange = expressionParser_->parseExpression(addressSpace->getRange()).toLongLong();\r\n\r\n        MemoryReserve reservedArea;\r\n        QStringList segmentNames;\r\n        QStringList foundNames;\r\n        for (QSharedPointer<Segment> const& segment : *addressSpace->getSegments())\r\n        {\r\n            if (segmentNames.contains(segment->name()) && !foundNames.contains(segment->name()))\r\n            {\r\n                errors.append(QObject::tr(\"Name %1 of segments in %2 is not unique\")\r\n                    .arg(segment->name()).arg(context));\r\n                foundNames.append(segment->name());\r\n            }\r\n            else\r\n            {\r\n                segmentNames.append(segment->name());\r\n            }\r\n            if (!hasValidName(segment->name()))\r\n            {\r\n                errors.append(QObject::tr(\"Invalid name specified for segment %1 within %2\")\r\n                    .arg(segment->name()).arg(context));\r\n            }\r\n            if (!hasValidIsPresent(segment->getIsPresent()))\r\n            {\r\n                errors.append(QObject::tr(\"Invalid isPresent set for segment %1 within %2\")\r\n                    .arg(segment->name()).arg(context));\r\n            }\r\n            if (!segmentHasValidAddressOffset(segment))\r\n            {\r\n                errors.append(QObject::tr(\"Invalid address offset set for segment %1 within %2\")\r\n                    .arg(segment->name()).arg(context));\r\n            }\r\n            if (!segmentHasValidRange(segment))\r\n            {\r\n                errors.append(QObject::tr(\"Invalid range set for segment %1 within %2\")\r\n                    .arg(segment->name()).arg(context));\r\n            }\r\n\r\n            qint64 segmentBegin = expressionParser_->parseExpression(segment->getAddressOffset()).toLongLong();\r\n            qint64 segmentRange = expressionParser_->parseExpression(segment->getRange()).toLongLong();\r\n            qint64 segmentEnd = segmentBegin + segmentRange - 1;\r\n\r\n            reservedArea.addArea(segment->name(), segmentBegin, segmentEnd);\r\n\r\n            if (segmentEnd > addressSpaceRange)\r\n            {\r\n                errors.append(QObject::tr(\"Segment %1 is not contained within %2\")\r\n                    .arg(segment->name()).arg(context));\r\n            }\r\n        }\r\n\r\n        reservedArea.findErrorsInOverlap(errors, QLatin1String(\"Segments\"), context);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressSpaceValidator::findErrorsInAddressUnitBits()\r\n//-----------------------------------------------------------------------------\r\nvoid AddressSpaceValidator::findErrorsInAddressUnitBits(QVector<QString>& errors,\r\n    QSharedPointer<AddressSpace> addressSpace, QString const& context) const\r\n{\r\n    if (!hasValidAddressUnitBits(addressSpace))\r\n    {\r\n        errors.append(QObject::tr(\"Invalid address unit bits set for address space %1 within %2\")\r\n            .arg(addressSpace->name()).arg(context));\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressSpaceValidator::findErrorsInLocalMemoryMap()\r\n//-----------------------------------------------------------------------------\r\nvoid AddressSpaceValidator::findErrorsInLocalMemoryMap(QVector<QString>& errors,\r\n    QSharedPointer<AddressSpace> addressSpace, QString const& context) const\r\n{\r\n    if (addressSpace->getLocalMemoryMap())\r\n    {\r\n        QString addressUnitBits= addressSpace->getAddressUnitBits();\r\n        if (addressUnitBits.isEmpty())\r\n        {\r\n            addressUnitBits = QLatin1String(\"8\");\r\n        }\r\n\r\n        localMemoryMapValidator_->findErrorsIn(\r\n            errors, addressSpace->getLocalMemoryMap(), addressUnitBits, context);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressSpaceValidator::findErrorsInParameters()\r\n//-----------------------------------------------------------------------------\r\nvoid AddressSpaceValidator::findErrorsInParameters(QVector<QString>& errors,\r\n    QSharedPointer<AddressSpace> addressSpace, QString const& context) const\r\n{\r\n    if (!addressSpace->getParameters()->isEmpty())\r\n    {\r\n        QStringList parameterNames;\r\n        for (QSharedPointer<Parameter> const& parameter : *addressSpace->getParameters())\r\n        {\r\n            if (parameterNames.contains(parameter->name()))\r\n            {\r\n                errors.append(QObject::tr(\"Name %1 of parameters in %2 is not unique.\").arg(parameter->name()).\r\n                    arg(context));\r\n            }\r\n            else\r\n            {\r\n                parameterNames.append(parameter->name());\r\n            }\r\n\r\n            parameterValidator_->findErrorsIn(errors, parameter, context);\r\n        }\r\n    }\r\n}\r\n"
  },
  {
    "path": "IPXACTmodels/Component/validators/AddressSpaceValidator.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: AddressSpaceValidator.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 30.11.2015\r\n//\r\n// Description:\r\n// Validator for the ipxact:addressSpace.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef ADDRESSSPACEVALIDATOR_H\r\n#define ADDRESSSPACEVALIDATOR_H\r\n\r\n#include <IPXACTmodels/ipxactmodels_global.h>\r\n\r\n#include <IPXACTmodels/common/validators/HierarchicalValidator.h>\r\n\r\n#include <QSharedPointer>\r\n#include <QString>\r\n\r\nclass ExpressionParser;\r\nclass AddressSpace;\r\nclass Segment;\r\nclass MemoryReserve;\r\nclass Component;\r\nclass AddressBlock;\r\n\r\nclass MemoryMapBaseValidator;\r\nclass ParameterValidator;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Validator for the ipxact:addressSpace.\r\n//-----------------------------------------------------------------------------\r\nclass IPXACTMODELS_EXPORT AddressSpaceValidator : public HierarchicalValidator\r\n{\r\npublic:\r\n\r\n\t/*!\r\n\t *  The constructor.\r\n\t *\r\n\t *    @param [in] expressionParser        The parser to use for solving expressions.\r\n     *    @param [in] memoryMapBaseValidator  Validator used for local memory map.\r\n     *    @param [in] parameterValidator      Validator used for parameters.\r\n\t */\r\n    AddressSpaceValidator(QSharedPointer<ExpressionParser> expressionParser,\r\n        QSharedPointer<MemoryMapBaseValidator> memoryMapBaseValidator,\r\n        QSharedPointer<ParameterValidator> parameterValidator);\r\n\r\n\t//! The destructor.\r\n\t~AddressSpaceValidator() = default;\r\n    \r\n    /*!\r\n     *  Get the validator used for local memory map.\r\n     *\r\n     *    @return The validator used for local memory map.\r\n     */\r\n    QSharedPointer<MemoryMapBaseValidator> getLocalMemoryMapValidator();\r\n\r\n    /*!\r\n     *  Validates the given address space.\r\n     *\r\n     *    @param [in] addressSpace        The selected address space.\r\n     *\r\n     *    @return True, if the address space is valid IP-XACT, otherwise false.\r\n     */\r\n    bool validate(QSharedPointer<AddressSpace> addressSpace) const;\r\n\r\n    /*!\r\n     *\tChange the containing component.\r\n     *  \r\n     *    @param [in] newComponent     The new component.\r\n     */\r\n    void componentChange(QSharedPointer<Component> newComponent);\r\n\r\n    /*!\r\n     *  Check if the name is valid.\r\n     *\r\n     *    @param [in] name    The selected name.\r\n     *\r\n     *    @return True, if the name is valid, otherwise false.\r\n     */\r\n    bool hasValidName(QString const& name) const;\r\n\r\n    /*!\r\n     *  Check if the is present value is valid.\r\n     *\r\n     *    @param [in] isPresent   The selected is present value.\r\n     *\r\n     *    @return True, if the is present is valid, otherwise false.\r\n     */\r\n    bool hasValidIsPresent(QString const& isPresent) const;\r\n\r\n    /*!\r\n     *  Check if the address space contains a valid range.\r\n     *\r\n     *    @param [in] addressSpace    The selected address space.\r\n     *\r\n     *    @return True, if the range is valid, otherwise false.\r\n     */\r\n    bool hasValidRange(QSharedPointer<AddressSpace> addressSpace) const;\r\n\r\n    /*!\r\n     *  Check if the address space contains a valid width.\r\n     *\r\n     *    @param [in] addressSpace    The selected address space.\r\n     *\r\n     *    @return True, if the width is valid, otherwise false.\r\n     */\r\n    bool hasValidWidth(QSharedPointer<AddressSpace> addressSpace) const;\r\n\r\n    /*!\r\n     *  Check if the address space contains valid segments.\r\n     *\r\n     *    @param [in] addressSpace    The selected address space.\r\n     *\r\n     *    @return True, if the segments are valid, otherwise false.\r\n     */\r\n    bool hasValidSegments(QSharedPointer<AddressSpace> addressSpace) const;\r\n\r\n    /*!\r\n     *  Check if the address space contains a valid address unit bits value.\r\n     *\r\n     *    @param [in] addressSpace    The selected address space.\r\n     *\r\n     *    @return True, if the address unit bits value is valid, otherwise false.\r\n     */\r\n    bool hasValidAddressUnitBits(QSharedPointer<AddressSpace> addressSpace) const;\r\n\r\n    /*!\r\n     *  Check if the address space contains a valid local memory map.\r\n     *\r\n     *    @param [in] addressSpace    The selected address space.\r\n     *\r\n     *    @return True, if the local memory map is valid, otherwise false.\r\n     */\r\n    bool hasValidLocalMemoryMap(QSharedPointer<AddressSpace> addressSpace) const;\r\n\r\n    /*!\r\n     *  Check if the address space contains valid parameters.\r\n     *\r\n     *    @param [in] addressSpace    The selected address space.\r\n     *\r\n     *    @return True, if the parameters are valid, otherwise false.\r\n     */\r\n    bool hasValidParameters(QSharedPointer<AddressSpace> addressSpace) const;\r\n\r\n    /*!\r\n     *  Locate errors within an address space.\r\n     *\r\n     *    @param [in] errors          List of found errors.\r\n     *    @param [in] addressSpace    The selected address space.\r\n     *    @param [in] context         Context to help locate the error.\r\n     */\r\n    void findErrorsIn(QVector<QString>& errors, QSharedPointer<AddressSpace> addressSpace,\r\n        QString const& context) const;\r\n\r\nprivate:\r\n\r\n\t// Disable copying.\r\n\tAddressSpaceValidator(AddressSpaceValidator const& rhs);\r\n\tAddressSpaceValidator& operator=(AddressSpaceValidator const& rhs);\r\n\r\n    /*!\r\n     *  Check if the segment contains a valid address offset.\r\n     *\r\n     *    @param [in] segment     The selected segment.\r\n     *\r\n     *    @return True, if the address offset is valid, otherwise false.\r\n     */\r\n    bool segmentHasValidAddressOffset(QSharedPointer<Segment> segment) const;\r\n\r\n    /*!\r\n     *  Check if the segment contains a valid range.\r\n     *\r\n     *    @param [in] segment     The selected segment.\r\n     *\r\n     *    @return True, if the range is valid, otherwise false.\r\n     */\r\n    bool segmentHasValidRange(QSharedPointer<Segment> segment) const;\r\n\r\n    /*!\r\n     *\tCheck if the address blocks of the local memory map are contained within the address space.\r\n     *  \r\n     *    @param [in] addressSpace     The address space whose local memory map address blocks are checked.\r\n     *\t    \r\n     * \t    @return True, if address blocks are in the range of the address space, otherwise false.\r\n     */\r\n    bool addressBlocksAreContainedWithinAddressSpace(QSharedPointer<AddressSpace> addressSpace) const;\r\n\r\n    /*!\r\n     *\tCheck if a single address block in the local memory map of the address space is contained within the address space.\r\n     *  \r\n     *    @param [in] addressSpace     Address space where the address block is contained.\r\n     *    @param [in] addressBlock     The address block to check.\r\n     *\t    \r\n     * \t    @return True, if the address block is within the address space range.\r\n     */\r\n    bool addressBlockIsContainedWithinAddressSpace(QSharedPointer<AddressSpace> addressSpace, QSharedPointer<AddressBlock> addressBlock) const;\r\n\r\n    /*!\r\n     *\tFind errors in local memory map address block ranges. Issues an error if one or more address blocks\r\n     *  are out of the address space range.\r\n     *  \r\n     *    @param [in] errors          List of found errors.\r\n     *    @param [in] addressSpace    The selected address space.\r\n     *    @param [in] context         Context to help locate the error.\r\n     */\r\n    void findErrorsInAddressBlockRanges(QStringList& errors, QSharedPointer<AddressSpace> addressSpace,\r\n        QString const& context) const;\r\n\r\n    /*!\r\n     *  Find errors within address space name.\r\n     *\r\n     *    @param [in] errors          List of found errors.\r\n     *    @param [in] addressSpace    The selected address space.\r\n     *    @param [in] context         Context to help locate the error.\r\n     */\r\n    void findErrorsInName(QVector<QString>& errors, QSharedPointer<AddressSpace> addressSpace,\r\n        QString const& context) const;\r\n\r\n    /*!\r\n     *  Find errors within address space isPresent.\r\n     *\r\n     *    @param [in] errors          List of found errors.\r\n     *    @param [in] addressSpace    The selected address space.\r\n     *    @param [in] context         Context to help locate the error.\r\n     */\r\n    void findErrorsInIsPresent(QVector<QString>& errors, QSharedPointer<AddressSpace> addressSpace,\r\n        QString const& context) const;\r\n\r\n    /*!\r\n     *  Find errors within address space range.\r\n     *\r\n     *    @param [in] errors          List of found errors.\r\n     *    @param [in] addressSpace    The selected address space.\r\n     *    @param [in] context         Context to help locate the error.\r\n     */\r\n    void findErrorsInRange(QVector<QString>& errors, QSharedPointer<AddressSpace> addressSpace,\r\n        QString const& context) const;\r\n\r\n    /*!\r\n     *  Find errors within address space width.\r\n     *\r\n     *    @param [in] errors          List of found errors.\r\n     *    @param [in] addressSpace    The selected address space.\r\n     *    @param [in] context         Context to help locate the error.\r\n     */\r\n    void findErrorsInWidth(QVector<QString>& errors, QSharedPointer<AddressSpace> addressSpace,\r\n        QString const& context) const;\r\n\r\n    /*!\r\n     *  Find errors within address space segments.\r\n     *\r\n     *    @param [in] errors          List of found errors.\r\n     *    @param [in] addressSpace    The selected address space.\r\n     *    @param [in] context         Context to help locate the error.\r\n     */\r\n    void findErrorsInSegments(QVector<QString>& errors, QSharedPointer<AddressSpace> addressSpace,\r\n        QString const& context) const;\r\n\r\n    /*!\r\n     *  Find errors within address space address unit bits.\r\n     *\r\n     *    @param [in] errors          List of found errors.\r\n     *    @param [in] addressSpace    The selected address space.\r\n     *    @param [in] context         Context to help locate the error.\r\n     */\r\n    void findErrorsInAddressUnitBits(QVector<QString>& errors, QSharedPointer<AddressSpace> addressSpace,\r\n        QString const& context) const;\r\n\r\n    /*!\r\n     *  Find errors within address space local memory map.\r\n     *\r\n     *    @param [in] errors          List of found errors.\r\n     *    @param [in] addressSpace    The selected address space.\r\n     *    @param [in] context         Context to help locate the error.\r\n     */\r\n    void findErrorsInLocalMemoryMap(QVector<QString>& errors, QSharedPointer<AddressSpace> addressSpace,\r\n        QString const& context) const;\r\n\r\n    /*!\r\n     *  Find errors within address space parameters.\r\n     *\r\n     *    @param [in] errors          List of found errors.\r\n     *    @param [in] addressSpace    The selected address space.\r\n     *    @param [in] context         Context to help locate the error.\r\n     */\r\n    void findErrorsInParameters(QVector<QString>& errors, QSharedPointer<AddressSpace> addressSpace,\r\n        QString const& context) const;\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! The expression parser to use.\r\n    QSharedPointer<ExpressionParser> expressionParser_;\r\n\r\n    //! The validator used for local memory map.\r\n    QSharedPointer<MemoryMapBaseValidator> localMemoryMapValidator_;\r\n\r\n    //! The validator used for parameters.\r\n    QSharedPointer<ParameterValidator> parameterValidator_;\r\n};\r\n\r\n#endif // ADDRESSSPACEVALIDATOR_H\r\n"
  },
  {
    "path": "IPXACTmodels/Component/validators/BusInterfaceValidator.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: BusInterfaceValidator.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 01.12.2015\r\n//\r\n// Description:\r\n// Validator for the ipxact:busInterface.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"BusInterfaceValidator.h\"\r\n\r\n#include <KactusAPI/include/ExpressionParser.h>\r\n\r\n#include <KactusAPI/include/LibraryInterface.h>\r\n\r\n#include <IPXACTmodels/BusDefinition/BusDefinition.h>\r\n#include <IPXACTmodels/AbstractionDefinition/AbstractionDefinition.h>\r\n#include <IPXACTmodels/AbstractionDefinition/PortAbstraction.h>\r\n\r\n#include <IPXACTmodels/Component/View.h>\r\n#include <IPXACTmodels/Component/Port.h>\r\n#include <IPXACTmodels/Component/AddressSpace.h>\r\n#include <IPXACTmodels/Component/MemoryMap.h>\r\n#include <IPXACTmodels/Component/FileSet.h>\r\n#include <IPXACTmodels/Component/RemapState.h>\r\n\r\n#include <IPXACTmodels/Component/AbstractionType.h>\r\n#include <IPXACTmodels/Component/InitiatorInterface.h>\r\n\r\n#include <IPXACTmodels/Component/validators/MemoryReserve.h>\r\n#include <IPXACTmodels/Component/validators/PortMapValidator.h>\r\n#include <IPXACTmodels/Component/validators/AbstractionTypeValidator.h>\r\n\r\n#include <IPXACTmodels/common/validators/CommonItemsValidator.h>\r\n#include <IPXACTmodels/common/validators/ParameterValidator.h>\r\n#include <IPXACTmodels/common/Parameter.h>\r\n\r\n#include <IPXACTmodels/generaldeclarations.h>\r\n#include <IPXACTmodels/utilities/Search.h>\r\n\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusInterfaceValidator::BusInterfaceValidator()\r\n//-----------------------------------------------------------------------------\r\nBusInterfaceValidator::BusInterfaceValidator(QSharedPointer<ExpressionParser> expressionParser,\r\n    QSharedPointer<QList<QSharedPointer<Choice> > > choices,\r\n    QSharedPointer<QList<QSharedPointer<View> > > views,\r\n    QSharedPointer<QList<QSharedPointer<Port> > > ports,\r\n    QSharedPointer<QList<QSharedPointer<AddressSpace> > > addressSpaces,\r\n    QSharedPointer<QList<QSharedPointer<MemoryMap> > > memoryMaps,\r\n    QSharedPointer<QList<QSharedPointer<BusInterface> > > busInterfaces,\r\n    QSharedPointer<QList<QSharedPointer<FileSet> > > fileSets,\r\n    QSharedPointer<QList<QSharedPointer<RemapState> > > remapStates,\r\n    QSharedPointer<QList<QSharedPointer<Mode> > > modes,\r\n    QSharedPointer<PortMapValidator> portMapValidator,\r\n    QSharedPointer<ParameterValidator> parameterValidator,\r\n    LibraryInterface* libraryHandler):\r\nHierarchicalValidator(),\r\nexpressionParser_(expressionParser),\r\navailableChoices_(choices),\r\navailableViews_(views),\r\navailablePorts_(ports),\r\navailableAddressSpaces_(addressSpaces),\r\navailableMemoryMaps_(memoryMaps),\r\navailableBusInterfaces_(busInterfaces),\r\navailableFileSets_(fileSets),\r\navailableRemapStates_(remapStates),\r\navailableModes_(modes),\r\nlibraryHandler_(libraryHandler),\r\nparameterValidator_(parameterValidator),\r\nabstractionValidator_(new AbstractionTypeValidator(expressionParser, views, portMapValidator, libraryHandler))\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusInterfaceValidator::~BusInterfaceValidator()\r\n//-----------------------------------------------------------------------------\r\nBusInterfaceValidator::~BusInterfaceValidator()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusInterfaceValidator::componentChange()\r\n//-----------------------------------------------------------------------------\r\nvoid BusInterfaceValidator::componentChange(QSharedPointer<QList<QSharedPointer<Choice> > > newChoices,\r\n    QSharedPointer<QList<QSharedPointer<View> > > newViews, QSharedPointer<QList<QSharedPointer<Port> > > newPorts,\r\n    QSharedPointer<QList<QSharedPointer<AddressSpace> > > newAddressSpaces,\r\n    QSharedPointer<QList<QSharedPointer<MemoryMap> > > newMemoryMaps,\r\n    QSharedPointer<QList<QSharedPointer<BusInterface> > > newBusInterfaces,\r\n    QSharedPointer<QList<QSharedPointer<FileSet> > > newFileSets,\r\n    QSharedPointer<QList<QSharedPointer<RemapState> > > newRemapStates,\r\n    QSharedPointer<QList<QSharedPointer<Mode> > > newModes)\r\n{\r\n    availableChoices_ = newChoices;\r\n    availableViews_ = newViews;\r\n    availablePorts_ = newPorts;\r\n    availableAddressSpaces_ = newAddressSpaces;\r\n    availableMemoryMaps_ = newMemoryMaps;\r\n    availableBusInterfaces_ = newBusInterfaces;\r\n    availableFileSets_ = newFileSets;\r\n    availableRemapStates_ = newRemapStates;\r\n    availableModes_ = newModes;\r\n\r\n    abstractionValidator_->changeComponent(newViews, newPorts);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusInterfaceValidator::getAbstractionValidator()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<AbstractionTypeValidator> BusInterfaceValidator::getAbstractionValidator() const\r\n{\r\n    return abstractionValidator_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusInterfaceValidator::validate()\r\n//-----------------------------------------------------------------------------\r\nbool BusInterfaceValidator::validate(QSharedPointer<BusInterface> busInterface,\r\n    Document::Revision docRevision) const\r\n{\r\n    return hasValidName(busInterface) && hasValidIsPresent(busInterface->getIsPresent()) &&\r\n        hasValidBusType(busInterface) && hasValidAbstractionTypes(busInterface) &&\r\n        hasValidInterfaceMode(busInterface) && hasValidBitsInLAU(busInterface) &&\r\n        hasValidBitSteering(busInterface, docRevision) && hasValidParameters(busInterface) &&\r\n        validComparedToSiblings(busInterface);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusInterfaceValidator::hasValidName()\r\n//-----------------------------------------------------------------------------\r\nbool BusInterfaceValidator::hasValidName(QSharedPointer<BusInterface> busInterface) const\r\n{\r\n    return CommonItemsValidator::hasValidName(busInterface->name());\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusInterfaceValidator::hasValidIsPresent()\r\n//-----------------------------------------------------------------------------\r\nbool BusInterfaceValidator::hasValidIsPresent(QString const& isPresent) const\r\n{\r\n    return CommonItemsValidator::hasValidIsPresent(isPresent, expressionParser_);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusInterfaceValidator::hasValidBusType()\r\n//-----------------------------------------------------------------------------\r\nbool BusInterfaceValidator::hasValidBusType(QSharedPointer<BusInterface> busInterface) const\r\n{\r\n    return busInterface->getBusType().isValid() && libraryHandler_->contains(busInterface->getBusType()) &&\r\n        libraryHandler_->getDocumentType(busInterface->getBusType()) == VLNV::BUSDEFINITION;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusInterfaceValidator::hasValidAbstractionType()\r\n//-----------------------------------------------------------------------------\r\nbool BusInterfaceValidator::hasValidAbstractionTypes(QSharedPointer<BusInterface> busInterface) const\r\n{\r\n    QSharedPointer<QList<QSharedPointer<AbstractionType> > > busAbstractions = busInterface->getAbstractionTypes();\r\n    for (QSharedPointer<AbstractionType> const& abstraction : *busAbstractions)\r\n    {\r\n        if (!abstractionValidator_->validate(abstraction, busAbstractions, busInterface))\r\n        {\r\n            return false;\r\n        }\r\n    }\r\n\r\n    return true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusInterfaceValidator::hasValidInterfaceMode()\r\n//-----------------------------------------------------------------------------\r\nbool BusInterfaceValidator::hasValidInterfaceMode(QSharedPointer<BusInterface> busInterface) const\r\n{\r\n    General::InterfaceMode interfaceMode = busInterface->getInterfaceMode();\r\n\r\n    if (interfaceMode == General::MASTER)\r\n    {\r\n        return hasValidMasterInterface(busInterface->getMaster());\r\n    }\r\n    else if (interfaceMode == General::MIRRORED_MASTER)\r\n    {\r\n        return true;\r\n    }\r\n    else if (interfaceMode == General::SLAVE)\r\n    {\r\n        return hasValidSlaveInterface(busInterface, busInterface->getSlave());\r\n    }\r\n    else if (interfaceMode == General::SYSTEM || interfaceMode == General::MIRRORED_SYSTEM)\r\n    {\r\n        return hasValidSystemInterface(busInterface, busInterface->getSystem());\r\n    }\r\n    else if (interfaceMode == General::MIRRORED_SLAVE)\r\n    {\r\n        return hasValidMirroredSlaveInterface(busInterface->getMirroredSlave());\r\n    }\r\n    else if (interfaceMode == General::MONITOR)\r\n    {\r\n        return hasValidMonitorInterface(busInterface, busInterface->getMonitor());\r\n    }\r\n    else if (interfaceMode == General::INITIATOR)\r\n    {\r\n        return hasValidInitiatorInterface(busInterface->getInitiator());\r\n    }\r\n    else if (interfaceMode == General::MIRRORED_INITIATOR)\r\n    {\r\n        return true;\r\n    }\r\n    else if (interfaceMode == General::TARGET)\r\n    {\r\n        return hasValidTargetInterface(busInterface, busInterface->getTarget());\r\n    }\r\n    else if (interfaceMode == General::MIRRORED_TARGET)\r\n    {\r\n        return hasValidMirroredTargetInterface(busInterface->getMirroredTarget());\r\n    }\r\n\r\n    return false;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusInterfaceValidator::hasValidMasterInterface()\r\n//-----------------------------------------------------------------------------\r\nbool BusInterfaceValidator::hasValidMasterInterface(QSharedPointer<InitiatorInterface> master) const\r\n{\r\n    if (master->getAddressSpaceRef().isEmpty() == false)\r\n    {\r\n        auto space = Search::findByName(master->getAddressSpaceRef(), *availableAddressSpaces_);\r\n        if (space.isNull() || !interfaceReferenceHasValidPresence(master->getIsPresent(), space->getIsPresent()))\r\n        {\r\n            return false;\r\n        }\r\n    }\r\n    else if (master->getBaseAddress().isEmpty() == false || master->getIsPresent().isEmpty() == false)\r\n    {\r\n        return false;\r\n    }\r\n\r\n    if (master->getBaseAddress().isEmpty() == false)\r\n    {\r\n        bool changeOk = true;\r\n        bool expressionValid = false;\r\n        expressionParser_->parseExpression(master->getBaseAddress(), &expressionValid).toLongLong(&changeOk);\r\n\r\n        if (!changeOk || !expressionValid)\r\n        {\r\n            return false;\r\n        }\r\n    }\r\n\r\n    return hasValidIsPresent(master->getIsPresent());\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusInterfaceValidator::hasValidInitiatorInterface()\r\n//-----------------------------------------------------------------------------\r\nbool BusInterfaceValidator::hasValidInitiatorInterface(QSharedPointer<InitiatorInterface> initiator) const\r\n{\r\n    if (initiator->getAddressSpaceRef().isEmpty() == false)\r\n    {\r\n        auto space = Search::findByName(initiator->getAddressSpaceRef(), *availableAddressSpaces_);\r\n        if (space.isNull())\r\n        {\r\n            return false;\r\n        }\r\n    }\r\n    else if (initiator->getBaseAddress().isEmpty() == false || initiator->getModeRefs().isEmpty() == false)\r\n    {\r\n        return false;\r\n    }\r\n\r\n    if (initiator->getBaseAddress().isEmpty() == false)\r\n    {\r\n        bool changeOk = true;\r\n        bool expressionValid = false;\r\n        expressionParser_->parseExpression(initiator->getBaseAddress(), &expressionValid).toLongLong(&changeOk);\r\n\r\n        if (!changeOk || !expressionValid)\r\n        {\r\n            return false;\r\n        }\r\n    }\r\n\r\n    return hasValidModeRefs(initiator->getModeRefs());\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusInterfaceValidator::hasValidModeRefs()\r\n//-----------------------------------------------------------------------------\r\nbool BusInterfaceValidator::hasValidModeRefs(QStringList const& modeRefs) const\r\n{\r\n    return std::all_of(modeRefs.cbegin(), modeRefs.cend(),\r\n        [this](auto mode) {return Search::findByName(mode, *availableModes_).isNull() == false;  });\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusInterfaceValidator::masterInterfaceHasValidPresenceForReference()\r\n//-----------------------------------------------------------------------------\r\nbool BusInterfaceValidator::interfaceReferenceHasValidPresence(QString const& interfacePresence,\r\n    QString const& targetPresence) const\r\n{\r\n    if (!interfacePresence.isEmpty())\r\n    {\r\n        int masterPresence = 1;\r\n        if (!interfacePresence.isEmpty())\r\n        {\r\n            masterPresence = expressionParser_->parseExpression(interfacePresence).toInt();\r\n        }\r\n\r\n        if (masterPresence == 1)\r\n        {\r\n            int spacePresence = 1;\r\n            if (!targetPresence.isEmpty())\r\n            {\r\n                spacePresence = expressionParser_->parseExpression(targetPresence).toInt();\r\n            }\r\n\r\n            return spacePresence == 1;\r\n        }\r\n    }\r\n\r\n    return true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusInterfaceValidator::hasValidSlaveInterface()\r\n//-----------------------------------------------------------------------------\r\nbool BusInterfaceValidator::hasValidSlaveInterface(QSharedPointer<BusInterface> busInterface,\r\n    QSharedPointer<TargetInterface> slave) const\r\n{\r\n    bool validMemoryMapRef = slaveInterfaceHasValidMemoryMapRef(busInterface, slave);\r\n    bool validBridges = hasValidBridges(slave->getBridges());\r\n    bool validFileSetRefs = slaveInterfaceFileSetRefGroupsAreValid(slave);\r\n\r\n    return validFileSetRefs && validMemoryMapRef && validBridges &&\r\n        (slave->getBridges()->isEmpty() || slave->getMemoryMapRef().isEmpty());\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusInterfaceValidator::hasValidTargetInterface()\r\n//-----------------------------------------------------------------------------\r\nbool BusInterfaceValidator::hasValidTargetInterface(QSharedPointer<BusInterface> busInterface,\r\n    QSharedPointer<TargetInterface> target) const\r\n{\r\n    return hasValidSlaveInterface(busInterface, target) &&\r\n        hasValidModeRefs(target->getModeRefs());\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusInterfaceValidator::slaveInterfaceHasValidMemoryMapRef()\r\n//-----------------------------------------------------------------------------\r\nbool BusInterfaceValidator::slaveInterfaceHasValidMemoryMapRef(QSharedPointer<BusInterface> busInterface,\r\n    QSharedPointer<TargetInterface> slave) const\r\n{\r\n    if (slave->getMemoryMapRef().isEmpty())\r\n    {\r\n        return true;\r\n    }\r\n    \r\n    auto memoryMap = Search::findByName(slave->getMemoryMapRef(), *availableMemoryMaps_);\r\n    return memoryMap.isNull() == false &&\r\n        interfaceReferenceHasValidPresence(busInterface->getIsPresent(), memoryMap->getIsPresent());\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusInterfaceValidator::hasValidBridges()\r\n//-----------------------------------------------------------------------------\r\nbool BusInterfaceValidator::hasValidBridges(QSharedPointer<QList<QSharedPointer<TransparentBridge> > > bridges) const\r\n{\r\n    if (bridges.isNull())\r\n    {\r\n        return true;\r\n    }\r\n\r\n    return std::all_of(bridges->cbegin(), bridges->cend(), [this](auto bridge)\r\n        {\r\n            return slaveBridgeReferencesValidMaster(bridge) && hasValidIsPresent(bridge->getIsPresent());\r\n        });\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusInterfaceValidator::slaveBridgeReferencesValidMaster()\r\n//-----------------------------------------------------------------------------\r\nbool BusInterfaceValidator::slaveBridgeReferencesValidMaster(QSharedPointer<TransparentBridge> bridge) const\r\n{\r\n    auto bridgeTarget = Search::findByName(bridge->getMasterRef(), *availableBusInterfaces_);\r\n\r\n    return bridgeTarget.isNull() == false &&\r\n        (bridgeTarget->getInterfaceMode() == General::MASTER || bridgeTarget->getInterfaceMode() == General::INITIATOR);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusInterfaceValidator::slaveInterfaceFileSetRefGroupsAreValid()\r\n//-----------------------------------------------------------------------------\r\nbool BusInterfaceValidator::slaveInterfaceFileSetRefGroupsAreValid(QSharedPointer<TargetInterface> slave) const\r\n{\r\n    return std::all_of(slave->getFileSetRefGroup()->cbegin(), slave->getFileSetRefGroup()->cend(), [this](auto group)\r\n        {\r\n            return std::all_of(group->fileSetRefs_->cbegin(), group->fileSetRefs_->cend(),\r\n            [this](auto fileSetReference) { return slaveFileSetReferenceIsValid(fileSetReference); });\r\n        });\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusInterfaceValidator::slaveFileSetReferenceIsValid()\r\n//-----------------------------------------------------------------------------\r\nbool BusInterfaceValidator::slaveFileSetReferenceIsValid(QSharedPointer<FileSetRef> fileSetReference) const\r\n{\r\n    auto fileSet = Search::findByName(fileSetReference->getReference(), *availableFileSets_);\r\n    return fileSet.isNull() == false;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusInterfaceValidator::hasValidSystemInterface()\r\n//-----------------------------------------------------------------------------\r\nbool BusInterfaceValidator::hasValidSystemInterface(QSharedPointer<BusInterface> busInterface,\r\n    QString const& systemGroup) const\r\n{\r\n    if (systemGroup.isEmpty())\r\n    {\r\n        return false;\r\n    }\r\n\r\n    auto busDefinition = libraryHandler_->getModelReadOnly<BusDefinition>(busInterface->getBusType());\r\n\r\n    return (busDefinition && busDefinition->getSystemGroupNames().contains(systemGroup));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusInterfaceValidator::hasValidMirroredSlaveInterface()\r\n//-----------------------------------------------------------------------------\r\nbool BusInterfaceValidator::hasValidMirroredSlaveInterface(QSharedPointer<MirroredTargetInterface> mirroredSlave)\r\n    const\r\n{\r\n    if (mirroredSlave->getRemapAddresses()->isEmpty() && mirroredSlave->getRange().isEmpty())\r\n    {\r\n        return true;\r\n    }\r\n\r\n    if (mirroredSlaveRangeIsValid(mirroredSlave) && !mirroredSlave->getRemapAddresses()->isEmpty())\r\n    {\r\n        return std::all_of(mirroredSlave->getRemapAddresses()->cbegin(), mirroredSlave->getRemapAddresses()->cend(), \r\n            [this](auto remapAddress)\r\n            {\r\n                return mirroredSlaveRemapAddressIsValid(remapAddress) && mirroredSlaveStateIsValid(remapAddress);\r\n            });\r\n    }\r\n\r\n    return false;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusInterfaceValidator::hasValidMirroredTargetInterface()\r\n//-----------------------------------------------------------------------------\r\nbool BusInterfaceValidator::hasValidMirroredTargetInterface(QSharedPointer<MirroredTargetInterface> mirroredTarget)\r\nconst\r\n{\r\n    if (mirroredTarget->getRemapAddresses()->isEmpty() && mirroredTarget->getRange().isEmpty())\r\n    {\r\n        return true;\r\n    }\r\n\r\n    if (mirroredSlaveRangeIsValid(mirroredTarget) && !mirroredTarget->getRemapAddresses()->isEmpty())\r\n    {\r\n        return std::all_of(mirroredTarget->getRemapAddresses()->cbegin(), mirroredTarget->getRemapAddresses()->cend(),\r\n            [this](auto remapAddress)\r\n            {\r\n                return mirroredSlaveRemapAddressIsValid(remapAddress) && hasValidModeRefs(remapAddress->modeRefs_);\r\n            });\r\n    }\r\n\r\n    return false;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusInterfaceValidator::mirroredSlaveRangeIsValid()\r\n//-----------------------------------------------------------------------------\r\nbool BusInterfaceValidator::mirroredSlaveRangeIsValid(QSharedPointer<MirroredTargetInterface> mirroredSlave) const\r\n{\r\n    bool changeOk = true;\r\n    quint64 range = expressionParser_->parseExpression(mirroredSlave->getRange()).toULongLong(&changeOk);\r\n\r\n    return changeOk && range > 0;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusInterfaceValidator::mirroredSlaveRemapAddressIsValid()\r\n//-----------------------------------------------------------------------------\r\nbool BusInterfaceValidator::mirroredSlaveRemapAddressIsValid(\r\n    QSharedPointer<MirroredTargetInterface::RemapAddress> remapAddress) const\r\n{\r\n    if (!remapAddress->remapAddress_.isEmpty())\r\n    {\r\n        bool changeOk = true;\r\n        expressionParser_->parseExpression(remapAddress->remapAddress_).toULongLong(&changeOk);\r\n\r\n        return changeOk;\r\n    }\r\n\r\n    return false;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusInterfaceValidator::mirroredSlaveStateIsValid()\r\n//-----------------------------------------------------------------------------\r\nbool BusInterfaceValidator::mirroredSlaveStateIsValid(\r\n    QSharedPointer<MirroredTargetInterface::RemapAddress> remapAddress) const\r\n{\r\n    if (remapAddress->state_.isEmpty())\r\n    {\r\n        return true;\r\n    }\r\n\r\n    auto remapState = Search::findByName(remapAddress->state_, *availableRemapStates_);\r\n\r\n    return remapState.isNull() == false;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusInterfaceValidator::hasValidMonitorInterface()\r\n//-----------------------------------------------------------------------------\r\nbool BusInterfaceValidator::hasValidMonitorInterface(QSharedPointer<BusInterface> busInterface,\r\n    QSharedPointer<BusInterface::MonitorInterface> monitorInterface) const\r\n{\r\n    General::InterfaceMode interfaceMode = monitorInterface->interfaceMode_;\r\n\r\n    if (interfaceMode != General::INTERFACE_MODE_COUNT && interfaceMode != General::MONITOR)\r\n    {\r\n        if (interfaceMode == General::SYSTEM || interfaceMode == General::MIRRORED_SYSTEM)\r\n        {\r\n            return hasValidSystemInterface(busInterface, monitorInterface->group_);\r\n        }\r\n\r\n        return monitorInterface->group_.isEmpty();\r\n    }\r\n\r\n    return false;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusInterfaceValidator::hasValidBitsInLAU()\r\n//-----------------------------------------------------------------------------\r\nbool BusInterfaceValidator::hasValidBitsInLAU(QSharedPointer<BusInterface> busInterface) const\r\n{\r\n    if (!busInterface->getBitsInLau().isEmpty())\r\n    {\r\n        bool changeOk = true;\r\n        quint64 bitsInLAU =\r\n            expressionParser_->parseExpression(busInterface->getBitsInLau()).toULongLong(&changeOk);\r\n\r\n        if (!changeOk || bitsInLAU <= 0)\r\n        {\r\n            return false;\r\n        }\r\n    }\r\n\r\n    return true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusInterfaceValidator::hasValidBitSteering()\r\n//-----------------------------------------------------------------------------\r\nbool BusInterfaceValidator::hasValidBitSteering(QSharedPointer<BusInterface> busInterface,\r\n    Document::Revision docRevision) const\r\n{\r\n    auto const& bitStreering = busInterface->getBitSteering();\r\n    if (bitStreering.isEmpty())\r\n    {\r\n        return true;\r\n    }\r\n\r\n    if (bitSteeringIsAllowed(busInterface) == false)\r\n    {\r\n        return false;\r\n    }\r\n\r\n    if (docRevision == Document::Revision::Std14)\r\n    {\r\n        return bitStreering == QLatin1String(\"on\") || bitStreering == QLatin1String(\"off\");\r\n    }\r\n    else if (docRevision == Document::Revision::Std22)\r\n    {\r\n        bool validExpression = false;\r\n        auto bitSteeringValue = expressionParser_->parseExpression(bitStreering, &validExpression);\r\n\r\n        return validExpression && \r\n            (bitSteeringValue == QLatin1String(\"1\") || bitSteeringValue == QLatin1String(\"0\"));\r\n    }\r\n\r\n    return false;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusInterfaceValidator::bitSteeringIsAllowed()\r\n//-----------------------------------------------------------------------------\r\nbool BusInterfaceValidator::bitSteeringIsAllowed(QSharedPointer<BusInterface> busInterface) const\r\n{\r\n    General::InterfaceMode interfaceMode = busInterface->getInterfaceMode();\r\n    if (interfaceMode == General::MIRRORED_MASTER || interfaceMode == General::MIRRORED_INITIATOR ||\r\n        interfaceMode == General::SYSTEM || interfaceMode == General::MIRRORED_SYSTEM)\r\n    {\r\n        return false;\r\n    }\r\n\r\n    return true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusInterfaceValidator::hasValidParameters()\r\n//-----------------------------------------------------------------------------\r\nbool BusInterfaceValidator::hasValidParameters(QSharedPointer<BusInterface> busInterface) const\r\n{\r\n    if (!busInterface->getParameters()->isEmpty())\r\n    {\r\n        QStringList parameterNames;\r\n        for (QSharedPointer<Parameter> parameter : *busInterface->getParameters())\r\n        {\r\n            if (parameterNames.contains(parameter->name()) || !parameterValidator_->validate(parameter))\r\n            {\r\n                return false;\r\n            }\r\n            else\r\n            {\r\n                parameterNames.append(parameter->name());\r\n            }\r\n        }\r\n    }\r\n\r\n    return true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusInterfaceValidator::findErrorsIn()\r\n//-----------------------------------------------------------------------------\r\nvoid BusInterfaceValidator::findErrorsIn(QVector<QString>& errors, QSharedPointer<BusInterface> busInterface,\r\n    QString const& context, Document::Revision docRevision) const\r\n{\r\n    QString busInterfaceContext = QStringLiteral(\"bus interface \") + busInterface->name();\r\n\r\n    findErrorsInName(errors, busInterface, context);\r\n    findErrorsInIsPresent(errors, busInterface, context);\r\n    findErrorsInBusType(errors, busInterface, context);\r\n    findErrorsInAbstractionTypes(errors, busInterface, busInterfaceContext);\r\n    findErrorsInInterfaceMode(errors, busInterface, busInterfaceContext, context);\r\n    findErrorsInBitsInLAU(errors, busInterface, context);\r\n    findErrorsInBitSteering(errors, busInterface, context, docRevision);\r\n    findErrorsInParameters(errors, busInterface, busInterfaceContext);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusInterfaceValidator::findErrorsInName()\r\n//-----------------------------------------------------------------------------\r\nvoid BusInterfaceValidator::findErrorsInName(QVector<QString>& errors, QSharedPointer<BusInterface> busInterface,\r\n    QString const& context) const\r\n{\r\n    if (!hasValidName(busInterface))\r\n    {\r\n        errors.append(QObject::tr(\"Invalid name specified for bus interface %1 within %2\")\r\n            .arg(busInterface->name(), context));\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusInterfaceValidator::findErrorsInIsPresent()\r\n//-----------------------------------------------------------------------------\r\nvoid BusInterfaceValidator::findErrorsInIsPresent(QVector<QString>& errors,\r\n    QSharedPointer<BusInterface> busInterface, QString const& context) const\r\n{\r\n    if (!hasValidIsPresent(busInterface->getIsPresent()))\r\n    {\r\n        errors.append(QObject::tr(\"Invalid isPresent set for bus interface %1 within %2\")\r\n            .arg(busInterface->name(), context));\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusInterfaceValidator::findErrorsInBusType()\r\n//-----------------------------------------------------------------------------\r\nvoid BusInterfaceValidator::findErrorsInBusType(QVector<QString>& errors,\r\n    QSharedPointer<BusInterface> busInterface, QString const& context) const\r\n{\r\n    if (!busInterface->getBusType().isValid())\r\n    {\r\n        errors.append(QObject::tr(\"Bus definition must be given for bus interface %1 within %2\")\r\n            .arg(busInterface->name(), context));\r\n    }\r\n    else\r\n    {\r\n        if (!libraryHandler_->contains(busInterface->getBusType()))\r\n        {\r\n            errors.append(QObject::tr(\"Bus definition %1 set for bus interface %2 within %3 could not be found in \"\r\n                \"the library\").arg(busInterface->getBusType().toString(), busInterface->name(), context));\r\n        }\r\n        if (libraryHandler_->getDocumentType(busInterface->getBusType()) != VLNV::BUSDEFINITION)\r\n        {\r\n            errors.append(QObject::tr(\"Invalid bus definition set for %1 within %2\")\r\n                .arg(busInterface->name(), context));\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusInterfaceValidator::findErrorsInAbstractionTypes()\r\n//-----------------------------------------------------------------------------\r\nvoid BusInterfaceValidator::findErrorsInAbstractionTypes(QVector<QString>& errors,\r\n    QSharedPointer<BusInterface> busInterface, QString const& context) const\r\n{\r\n    QSharedPointer<QList<QSharedPointer<AbstractionType> > > busAbstractions = busInterface->getAbstractionTypes();\r\n    for (QSharedPointer<AbstractionType> abstraction : *busAbstractions)\r\n    {\r\n        abstractionValidator_->findErrorsIn(errors, abstraction, busAbstractions, busInterface, context);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusInterfaceValidator::findErrorsInParameters()\r\n//-----------------------------------------------------------------------------\r\nvoid BusInterfaceValidator::findErrorsInParameters(QVector<QString>& errors,\r\n    QSharedPointer<BusInterface> busInterface, QString const& context) const\r\n{\r\n    if (!busInterface->getParameters()->isEmpty())\r\n    {\r\n        QVector<QString> parameterNames(busInterface->getParameters()->count());\r\n        for (QSharedPointer<Parameter> parameter : *busInterface->getParameters())\r\n        {\r\n            if (parameterNames.contains(parameter->name()))\r\n            {\r\n                errors.append(QObject::tr(\"Parameter name %1 is not unique within %2.\").arg(parameter->name(), \r\n                    context));\r\n            }\r\n            else\r\n            {\r\n                parameterNames.append(parameter->name());\r\n            }\r\n\r\n            parameterValidator_->findErrorsIn(errors, parameter, context);\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusInterfaceValidator::findErrorsInInterfaceMode()\r\n//-----------------------------------------------------------------------------\r\nvoid BusInterfaceValidator::findErrorsInInterfaceMode(QVector<QString>& errors,\r\n    QSharedPointer<BusInterface> busInterface, QString const& busInterfaceContext,\r\n    QString const& containingContext) const\r\n{\r\n    General::InterfaceMode interfaceMode = busInterface->getInterfaceMode();\r\n\r\n    QString newContext = General::interfaceMode2Str(busInterface->getInterfaceMode());\r\n    newContext.append(QLatin1Char(' '));\r\n    newContext.append(busInterfaceContext);\r\n\r\n    if (interfaceMode == General::MASTER)\r\n    {\r\n        findErrorsInMasterInterface(errors, busInterface->getMaster(), newContext);\r\n    }\r\n    else if (interfaceMode == General::SLAVE)\r\n    {\r\n        findErrorsInSlaveInterface(errors, busInterface, busInterface->getSlave(), newContext);\r\n    }\r\n    else if (interfaceMode == General::SYSTEM || interfaceMode == General::MIRRORED_SYSTEM)\r\n    {\r\n        findErrorsInSystemInterface(errors, busInterface->getSystem(), busInterface, newContext);\r\n    }\r\n    else if (interfaceMode == General::MIRRORED_MASTER)\r\n    {\r\n        // Intentionally empty.\r\n    }\r\n    else if (interfaceMode == General::MIRRORED_SLAVE)\r\n    {\r\n        findErrorsInMirroredSlaveInterface(errors, busInterface->getMirroredSlave(), newContext);\r\n    }\r\n    else if (interfaceMode == General::MONITOR)\r\n    {\r\n        findErrorsInMonitorInterface(errors, busInterface, busInterface->getMonitor(), newContext);\r\n    }\r\n\r\n    else if (interfaceMode == General::INITIATOR)\r\n    {\r\n        findErrorsInInitiatorInterface(errors, busInterface->getInitiator(), newContext);\r\n    }\r\n    else if (interfaceMode == General::TARGET)\r\n    {\r\n        findErrorsInTargetInterface(errors, busInterface, busInterface->getTarget(), newContext);\r\n    }\r\n    else if (interfaceMode == General::MIRRORED_INITIATOR)\r\n    {\r\n        // Intentionally empty.\r\n    }\r\n    else if (interfaceMode == General::MIRRORED_TARGET)\r\n    {\r\n        findErrorsInMirroredTargetInterface(errors, busInterface->getMirroredTarget(), newContext);\r\n    }\r\n    else\r\n    {\r\n        errors.append(QObject::tr(\"Unknown interface mode set for bus interface %1 within %2\")\r\n            .arg(busInterface->name(), containingContext));\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusInterfaceValidator::findErrorsInMasterInterface()\r\n//-----------------------------------------------------------------------------\r\nvoid BusInterfaceValidator::findErrorsInMasterInterface(QVector<QString>& errors,\r\n    QSharedPointer<InitiatorInterface> master, QString const& context) const\r\n{\r\n    if (master.isNull())\r\n    {\r\n        return;\r\n    }\r\n\r\n    if (!master->getAddressSpaceRef().isEmpty())\r\n    {\r\n        auto space = Search::findByName(master->getAddressSpaceRef(), *availableAddressSpaces_);\r\n\r\n        if (space.isNull() == false)\r\n        {\r\n            if (!interfaceReferenceHasValidPresence(master->getIsPresent(), space->getIsPresent()))\r\n            {\r\n                errors.append(QObject::tr(\"Cannot refer to non-present address space %1 in %2\")\r\n                    .arg(space->name()).arg(context));\r\n            }\r\n        }\r\n        else\r\n        {\r\n            errors.append(QObject::tr(\"Could not find address space %1 referenced by the %2\")\r\n                .arg(master->getAddressSpaceRef()).arg(context));\r\n        }\r\n        if (!master->getBaseAddress().isEmpty())\r\n        {\r\n            bool changeOk = true;\r\n            bool expressionValid = false;\r\n\r\n            expressionParser_->parseExpression(master->getBaseAddress(), &expressionValid).toLongLong(&changeOk);\r\n\r\n            if (!changeOk || !expressionValid)\r\n            {\r\n                errors.append(QObject::tr(\"Invalid base address set for %1\").arg(context));\r\n            }\r\n        }\r\n        if (!hasValidIsPresent(master->getIsPresent()))\r\n        {\r\n            errors.append(QObject::tr(\"Invalid is present set for address space reference in %1\").arg(context));\r\n        }\r\n    }\r\n    else if (!master->getIsPresent().isEmpty() || !master->getBaseAddress().isEmpty())\r\n    {\r\n        errors.append(QObject::tr(\"Invalid address space reference set for %1\").arg(context));\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusInterfaceValidator::findErrorsInInitiatorInterface()\r\n//-----------------------------------------------------------------------------\r\nvoid BusInterfaceValidator::findErrorsInInitiatorInterface(QVector<QString>& errors,\r\n    QSharedPointer<InitiatorInterface> initiator, QString const& context) const\r\n{\r\n    if (initiator.isNull())\r\n    {\r\n        return;\r\n    }\r\n\r\n    if (!initiator->getAddressSpaceRef().isEmpty())\r\n    {\r\n        auto space = Search::findByName(initiator->getAddressSpaceRef(), *availableAddressSpaces_);\r\n        if (space.isNull())\r\n        {\r\n            errors.append(QObject::tr(\"Could not find address space %1 referenced by the %2\").arg(\r\n                initiator->getAddressSpaceRef(), context));\r\n        }\r\n    }\r\n    else if (initiator->getBaseAddress().isEmpty() == false || initiator->getModeRefs().isEmpty() == false)\r\n    {\r\n        errors.append(QObject::tr(\"Invalid address space reference set for %1\").arg(context));\r\n    }\r\n\r\n    if (!initiator->getBaseAddress().isEmpty())\r\n    {\r\n        bool changeOk = true;\r\n        bool expressionValid = false;\r\n\r\n        expressionParser_->parseExpression(initiator->getBaseAddress(), &expressionValid).toLongLong(&changeOk);\r\n\r\n        if (!changeOk || !expressionValid)\r\n        {\r\n            errors.append(QObject::tr(\"Invalid base address set for %1\").arg(context));\r\n        }\r\n    }\r\n\r\n    findErrorsInModeReferences(initiator->getModeRefs(), errors, context);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusInterfaceValidator::findErrorsInModeReferences()\r\n//-----------------------------------------------------------------------------\r\nvoid BusInterfaceValidator::findErrorsInModeReferences(QStringList const& modeRefs, QVector<QString>& errors, QString const& context) const\r\n{\r\n    for (auto modeRef : modeRefs)\r\n    {\r\n        if (auto mode = Search::findByName(modeRef, *availableModes_); mode.isNull())\r\n        {\r\n            errors.append(QObject::tr(\"Could not find mode %1 referenced by the %2\").arg(modeRef, context));\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusInterfaceValidator::findErrorsInSlaveInterface()\r\n//-----------------------------------------------------------------------------\r\nvoid BusInterfaceValidator::findErrorsInSlaveInterface(QVector<QString>& errors,\r\n    QSharedPointer<BusInterface> busInterface, QSharedPointer<TargetInterface> slave, QString const& context) const\r\n{\r\n    if (!slave->getMemoryMapRef().isEmpty() && !slave->getBridges()->isEmpty())\r\n    {\r\n        errors.append(QObject::tr(\"Both a memory map reference and transparent bridges are contained within %1\")\r\n            .arg(context));\r\n    }\r\n    if (!slave->getMemoryMapRef().isEmpty() &&!slaveInterfaceHasValidMemoryMapRef(busInterface, slave))\r\n    {\r\n        errors.append(QObject::tr(\"Memory map %1 referenced by the %2 was not found\")\r\n            .arg(slave->getMemoryMapRef()).arg(context));\r\n    }\r\n\r\n    for (QSharedPointer<TransparentBridge> bridge : *slave->getBridges())\r\n    {\r\n        if (!slaveBridgeReferencesValidMaster(bridge))\r\n        {\r\n            errors.append(QObject::tr(\"Master bus interface %1 referenced by the %2 was not found\")\r\n                .arg(bridge->getMasterRef()).arg(context));\r\n        }\r\n        if (!hasValidIsPresent(bridge->getIsPresent()))\r\n        {\r\n            errors.append(QObject::tr(\"Transparent bridge within the %1 has invalid isPresent\")\r\n                .arg(context));\r\n        }\r\n    }\r\n\r\n    for (QSharedPointer<TargetInterface::FileSetRefGroup> group : *slave->getFileSetRefGroup())\r\n    {\r\n        for (auto const& fileSetReference : *group->fileSetRefs_)\r\n        {\r\n            if (!slaveFileSetReferenceIsValid(fileSetReference))\r\n            {\r\n                errors.append(QObject::tr(\"Invalid file set %1 referenced within group %2 of %3\").arg(\r\n                    fileSetReference->getReference(), group->group_, context));\r\n            }\r\n        }\r\n    }\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusInterfaceValidator::findErrorsInTargetInterface()\r\n//-----------------------------------------------------------------------------\r\nvoid BusInterfaceValidator::findErrorsInTargetInterface(QVector<QString>& errors,\r\n    QSharedPointer<BusInterface> busInterface, QSharedPointer<TargetInterface> target, \r\n    QString const& context) const\r\n{\r\n    if (!target->getMemoryMapRef().isEmpty() && !target->getBridges()->isEmpty())\r\n    {\r\n        errors.append(QObject::tr(\"Both a memory map reference and transparent bridges are contained within %1\")\r\n            .arg(context));\r\n    }\r\n    if (!target->getMemoryMapRef().isEmpty() && !slaveInterfaceHasValidMemoryMapRef(busInterface, target))\r\n    {\r\n        errors.append(QObject::tr(\"Memory map %1 referenced by the %2 was not found\")\r\n            .arg(target->getMemoryMapRef(), context));\r\n    }\r\n\r\n    for (QSharedPointer<TransparentBridge> bridge : *target->getBridges())\r\n    {\r\n        if (!slaveBridgeReferencesValidMaster(bridge))\r\n        {\r\n            errors.append(QObject::tr(\"Initiator bus interface %1 referenced by the %2 was not found\")\r\n                .arg(bridge->getInitiatorRef(), context));\r\n        }\r\n    }\r\n\r\n    for (QSharedPointer<TargetInterface::FileSetRefGroup> group : *target->getFileSetRefGroup())\r\n    {\r\n        for (auto const& fileSetReference : *group->fileSetRefs_)\r\n        {\r\n            if (!slaveFileSetReferenceIsValid(fileSetReference))\r\n            {\r\n                errors.append(QObject::tr(\"Invalid file set %1 referenced within group %2 of %3\").arg(\r\n                    fileSetReference->getReference(), group->group_, context));\r\n            }\r\n        }\r\n    }\r\n\r\n    findErrorsInModeReferences(target->getModeRefs(), errors, context);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusInterfaceValidator::findErrorsInSystemInterface()\r\n//-----------------------------------------------------------------------------\r\nvoid BusInterfaceValidator::findErrorsInSystemInterface(QVector<QString>& errors, QString const& systemGroup,\r\n    QSharedPointer<BusInterface> busInterface, QString const& context) const\r\n{\r\n    if (systemGroup.isEmpty())\r\n    {\r\n        errors.append(QObject::tr(\"No system group given for %1\").arg(context));\r\n    }\r\n\r\n    else\r\n    {\r\n        if (busInterface->getBusType().isValid())\r\n        {\r\n\t\t\tQSharedPointer<Document const> definitionDocument = libraryHandler_->getModelReadOnly(busInterface->getBusType());\r\n\t\t\tQSharedPointer<BusDefinition const> busDefinition = definitionDocument.dynamicCast<BusDefinition const>();\r\n\r\n            if (busDefinition && !busDefinition->getSystemGroupNames().contains(systemGroup))\r\n            {\r\n                errors.append(QObject::tr(\"Could not find system group %1 set for %2 with bus definition %3.\")\r\n                    .arg(systemGroup, context, busInterface->getBusType().toString()));\r\n            }\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusInterfaceValidator::findErrorsInMirroredSlaveInterface()\r\n//-----------------------------------------------------------------------------\r\nvoid BusInterfaceValidator::findErrorsInMirroredSlaveInterface(QVector<QString>& errors,\r\n    QSharedPointer<MirroredTargetInterface> mirroredSlave, QString const& context) const\r\n{\r\n    if (!mirroredSlave->getRange().isEmpty() || !mirroredSlave->getRemapAddresses()->isEmpty())\r\n    {\r\n        if (mirroredSlave->getRemapAddresses()->isEmpty())\r\n        {\r\n            errors.append(QObject::tr(\"Invalid remap address set for %1\").arg(context));\r\n        }\r\n\r\n        for (QSharedPointer<MirroredTargetInterface::RemapAddress> remapAddress :\r\n            *mirroredSlave->getRemapAddresses())\r\n        {\r\n            if (!mirroredSlaveRemapAddressIsValid(remapAddress))\r\n            {\r\n                errors.append(QObject::tr(\"Invalid remap address set for %1\").arg(context));\r\n            }\r\n            if (!mirroredSlaveStateIsValid(remapAddress))\r\n            {\r\n                errors.append(QObject::tr(\"Invalid remap state set for %1\").arg(context));\r\n            }\r\n        }\r\n\r\n        if (!mirroredSlaveRangeIsValid(mirroredSlave))\r\n        {\r\n            errors.append(QObject::tr(\"Invalid range set for %1\").arg(context));\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusInterfaceValidator::findErrorsInMirroredTargetInterface()\r\n//-----------------------------------------------------------------------------\r\nvoid BusInterfaceValidator::findErrorsInMirroredTargetInterface(QVector<QString>& errors,\r\n    QSharedPointer<MirroredTargetInterface> mirroredTarget, QString const& context) const\r\n{\r\n    if (!mirroredTarget->getRange().isEmpty() || !mirroredTarget->getRemapAddresses()->isEmpty())\r\n    {\r\n        if (mirroredTarget->getRemapAddresses()->isEmpty())\r\n        {\r\n            errors.append(QObject::tr(\"Invalid remap address set for %1\").arg(context));\r\n        }\r\n\r\n        for (QSharedPointer<MirroredTargetInterface::RemapAddress> remapAddress :\r\n            *mirroredTarget->getRemapAddresses())\r\n        {\r\n            if (!mirroredSlaveRemapAddressIsValid(remapAddress))\r\n            {\r\n                errors.append(QObject::tr(\"Invalid remap address set for %1\").arg(context));\r\n            }\r\n\r\n            findErrorsInModeReferences(remapAddress->modeRefs_, errors, context);\r\n        }\r\n\r\n        if (!mirroredSlaveRangeIsValid(mirroredTarget))\r\n        {\r\n            errors.append(QObject::tr(\"Invalid range set for %1\").arg(context));\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusInterfaceValidator::findErrorsInMonitorInterface()\r\n//-----------------------------------------------------------------------------\r\nvoid BusInterfaceValidator::findErrorsInMonitorInterface(QVector<QString>& errors,\r\n    QSharedPointer<BusInterface> busInterface, QSharedPointer<BusInterface::MonitorInterface> monitor,\r\n    QString const& context) const\r\n{\r\n    General::InterfaceMode interfaceMode = monitor->interfaceMode_;\r\n\r\n    if (interfaceMode == General::INTERFACE_MODE_COUNT || interfaceMode == General::MONITOR)\r\n    {\r\n        errors.append(QObject::tr(\"Invalid interface mode set for %1\").arg(context));\r\n    }\r\n\r\n    else\r\n    {\r\n        if (interfaceMode == General::SYSTEM || interfaceMode == General::MIRRORED_SYSTEM)\r\n        {\r\n            findErrorsInSystemInterface(errors, monitor->group_, busInterface, context);\r\n        }\r\n\r\n        else if (!monitor->group_.isEmpty())\r\n        {\r\n            errors.append(QObject::tr(\"Group cannot be set for %1 with interface mode master, slave, \"\r\n                \"mirrored master or mirrored slave\").arg(context));\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusInterfaceValidator::findErrorsInBitsInLAU()\r\n//-----------------------------------------------------------------------------\r\nvoid BusInterfaceValidator::findErrorsInBitsInLAU(QVector<QString>& errors,\r\n    QSharedPointer<BusInterface> busInterface, QString const& context) const\r\n{\r\n    if (!hasValidBitsInLAU(busInterface))\r\n    {\r\n        errors.append(QObject::tr(\"Invalid bits in LAU set for bus interface %1 within %2\")\r\n            .arg(busInterface->name()).arg(context));\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusInterfaceValidator::findErrorsInBitSteering()\r\n//-----------------------------------------------------------------------------\r\nvoid BusInterfaceValidator::findErrorsInBitSteering(QVector<QString>& errors,\r\n    QSharedPointer<BusInterface> busInterface, QString const& context,\r\n    Document::Revision docRevision) const\r\n{\r\n    if (!hasValidBitSteering(busInterface, docRevision))\r\n    {\r\n        QString usedInterface = General::interfaceMode2Str(busInterface->getInterfaceMode());\r\n\r\n        if (bitSteeringIsAllowed(busInterface) == false)\r\n        {\r\n            errors.append(QObject::tr(\"Bit steering value is not allowed in %1 bus interface %2 within %3\").arg(\r\n                usedInterface, busInterface->name(), context));\r\n        }\r\n        else\r\n        {\r\n            errors.append(QObject::tr(\"Bit steering value '%1' is not valid in bus interface %2 within %3\").arg(\r\n                busInterface->getBitSteering(), busInterface->name(), context));\r\n        }\r\n    }\r\n}\r\n"
  },
  {
    "path": "IPXACTmodels/Component/validators/BusInterfaceValidator.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: BusInterfaceValidator.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 01.12.2015\r\n//\r\n// Description:\r\n// Validator for the ipxact:busInterface.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef BUSINTERFACEVALIDATOR_H\r\n#define BUSINTERFACEVALIDATOR_H\r\n\r\n#include <IPXACTmodels/ipxactmodels_global.h>\r\n\r\n#include <IPXACTmodels/common/Document.h>\r\n#include <IPXACTmodels/Component/BusInterface.h>\r\n#include <IPXACTmodels/Component/PortMap.h>\r\n#include <IPXACTmodels/Component/TargetInterface.h>\r\n#include <IPXACTmodels/Component/MirroredTargetInterface.h>\r\n#include <IPXACTmodels/Component/Mode.h>\r\n\r\n#include <IPXACTmodels/common/validators/ParameterValidator.h>\r\n#include <IPXACTmodels/common/validators/HierarchicalValidator.h>\r\n\r\n#include <QSharedPointer>\r\n#include <QString>\r\n\r\nclass AbstractionType;\r\nclass AddressSpace;\r\nclass Choice;\r\nclass ExpressionParser;\r\nclass FileSet;\r\nclass FileSetRef;\r\nclass LibraryInterface;\r\nclass InitiatorInterface;\r\nclass MemoryMap;\r\nclass Port;\r\nclass RemapState;\r\nclass View;\r\nclass AbstractionDefinition;\r\nclass PortAbstraction;\r\nclass AbstractionTypeValidator;\r\nclass PortMapValidator;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Validator for the ipxact:busInterface.\r\n//-----------------------------------------------------------------------------\r\nclass IPXACTMODELS_EXPORT BusInterfaceValidator : public HierarchicalValidator\r\n{\r\npublic:\r\n\r\n    /*!\r\n     *  The constructor.\r\n     *\r\n     *    @param [in] expressionParser    The parse to use for solving expressions.\r\n     *    @param [in] choices             List of available choices.\r\n     *    @param [in] views               List of available views.\r\n     *    @param [in] ports               List of available ports.\r\n     *    @param [in] addressSpaces       List of available address spaces.\r\n     *    @param [in] memoryMaps          List of available memory maps.\r\n     *    @param [in] busInterfaces       List of available bus interfaces.\r\n     *    @param [in] fileSets            List of available file sets.\r\n     *    @param [in] remapStates         List of available remap states.\r\n     *    @param [in] modes               List of available modes.\r\n     *    @param [in] portMapValidator    Validator used for port maps.\r\n     *    @param [in] parameterValidator  Validator used for parameters.\r\n     *    @param [in] libraryHandler      The library interface.\r\n     */\r\n    BusInterfaceValidator(QSharedPointer<ExpressionParser> expressionParser,\r\n        QSharedPointer<QList<QSharedPointer<Choice> > > choices,\r\n        QSharedPointer<QList<QSharedPointer<View> > > views,\r\n        QSharedPointer<QList<QSharedPointer<Port> > > ports,\r\n        QSharedPointer<QList<QSharedPointer<AddressSpace> > > addressSpaces,\r\n        QSharedPointer<QList<QSharedPointer<MemoryMap> > > memoryMaps,\r\n        QSharedPointer<QList<QSharedPointer<BusInterface> > > busInterfaces,\r\n        QSharedPointer<QList<QSharedPointer<FileSet> > > fileSets,\r\n        QSharedPointer<QList<QSharedPointer<RemapState> > > remapStates,\r\n        QSharedPointer<QList<QSharedPointer<Mode> > > modes,\r\n        QSharedPointer<PortMapValidator> portMapValidator,\r\n        QSharedPointer<ParameterValidator> parameterValidator,\r\n        LibraryInterface* libraryHandler);\r\n\r\n\t//! The destructor.\r\n\tvirtual ~BusInterfaceValidator();\r\n\r\n\r\n    // Disable copying.\r\n    BusInterfaceValidator(BusInterfaceValidator const& rhs) = delete;\r\n    BusInterfaceValidator& operator=(BusInterfaceValidator const& rhs) = delete;\r\n\r\n    /*!\r\n     *  Change the available component elements.\r\n     *\r\n     *    @param [in] newChoices          The new choices.\r\n     *    @param [in] newViews            The new views.\r\n     *    @param [in] newPorts            The new ports.\r\n     *    @param [in] newAddressSpaces    The new address spaces.\r\n     *    @param [in] newMemoryMaps       The new memory maps.\r\n     *    @param [in] newBusInterfaces    The new bus interfaces.\r\n     *    @param [in] newFileSets         The new file sets.\r\n     *    @param [in] newRemapStates      The new remap states.\r\n     *    @param [in] newRemapStates      The new modes.\r\n     */\r\n    void componentChange(QSharedPointer<QList<QSharedPointer<Choice> > > newChoices,\r\n        QSharedPointer<QList<QSharedPointer<View> > > newViews,\r\n        QSharedPointer<QList<QSharedPointer<Port> > > newPorts,\r\n        QSharedPointer<QList<QSharedPointer<AddressSpace> > > newAddressSpaces,\r\n        QSharedPointer<QList<QSharedPointer<MemoryMap> > > newMemoryMaps,\r\n        QSharedPointer<QList<QSharedPointer<BusInterface> > > newBusInterfaces,\r\n        QSharedPointer<QList<QSharedPointer<FileSet> > > newFileSets,\r\n        QSharedPointer<QList<QSharedPointer<RemapState> > > newRemapStates,\r\n        QSharedPointer<QList<QSharedPointer<Mode> > > newModes);\r\n\r\n    /*!\r\n     *  Get the used abstraction type validator.\r\n     *\r\n     *    @return The used abstraction type validator.\r\n     */\r\n    QSharedPointer<AbstractionTypeValidator> getAbstractionValidator() const;\r\n\r\n    /*!\r\n     *  Validates the given bus interface.\r\n     *\r\n     *    @param [in] busInterface    The selected bus interface.\r\n     *\r\n     *    @return True, if the bus interface is valid IP-XACT, otherwise false.\r\n     */\r\n    bool validate(QSharedPointer<BusInterface> busInterface,\r\n        Document::Revision docRevision) const;\r\n\r\n    /*!\r\n     *  Check if the name is valid.\r\n     *\r\n     *    @param [in] busInterface    The selected bus interface.\r\n     *\r\n     *    @return True, if the name is valid, otherwise false.\r\n     */\r\n    bool hasValidName(QSharedPointer<BusInterface> busInterface) const;\r\n\r\n    /*!\r\n     *  Check if the is present value is valid.\r\n     *\r\n     *    @param [in] isPresent   The selected is present value.\r\n     *\r\n     *    @return True, if the is present is valid, otherwise false.\r\n     */\r\n    bool hasValidIsPresent(QString const& isPresent) const;\r\n\r\n    /*!\r\n     *  Check if the bus type is valid.\r\n     *\r\n     *    @param [in] busInterface    The selected bus interface.\r\n     *\r\n     *    @return True, if the bus type is valid, otherwise false.\r\n     */\r\n    bool hasValidBusType(QSharedPointer<BusInterface> busInterface) const;\r\n\r\n    /*!\r\n     *  Check if the abstraction types are valid.\r\n     *\r\n     *    @param [in] busInterface    The selected bus interface.\r\n     *\r\n     *    @return True, if the abstraction types are valid, otherwise false.\r\n     */\r\n    bool hasValidAbstractionTypes(QSharedPointer<BusInterface> busInterface) const;\r\n\r\n    /*!\r\n     *  Check if the bus interface mode is valid.\r\n     *\r\n     *    @param [in] busInterface    The selected bus interface.\r\n     *\r\n     *    @return True, if the bus interface mode is valid, otherwise false.\r\n     */\r\n    bool hasValidInterfaceMode(QSharedPointer<BusInterface> busInterface) const;\r\n\r\n    /*!\r\n     *  Check if the bits in LAU value is valid.\r\n     *\r\n     *    @param [in] busInterface    The selected bus interface.\r\n     *\r\n     *    @return True, if the bits in LAU value is valid, otherwise false.\r\n     */\r\n    bool hasValidBitsInLAU(QSharedPointer<BusInterface> busInterface) const;\r\n\r\n    /*!\r\n     *  Check if the bit steering is valid.\r\n     *\r\n     *    @param [in] busInterface    The selected bus interface.\r\n     *\r\n     *    @return True, if the bit steering is valid, otherwise false.\r\n     */\r\n    bool hasValidBitSteering(QSharedPointer<BusInterface> busInterface,\r\n        Document::Revision docRevision) const;\r\n\r\n    bool bitSteeringIsAllowed(QSharedPointer<BusInterface> busInterface) const;\r\n\r\n    /*!\r\n     *  Check if the bus interface contains valid parameters.\r\n     *\r\n     *    @param [in] busInterface    The selected bus interface.\r\n     *\r\n     *    @return True, if the parameters are valid, otherwise false.\r\n     */\r\n    bool hasValidParameters(QSharedPointer<BusInterface> busInterface) const;\r\n\r\n    /*!\r\n     *  Locate errors within a bus interface.\r\n     *\r\n     *    @param [in] errors          List of found errors.\r\n     *    @param [in] busInterface    The selected busInterface.\r\n     *    @param [in] context         Context to help locate the error.\r\n     */\r\n    virtual void findErrorsIn(QVector<QString>& errors, QSharedPointer<BusInterface> busInterface,\r\n        QString const& context, Document::Revision docRevision) const;\r\n\r\n    /*!\r\n     *  Check if the selected transparent bridges are valid.\r\n     *\r\n     *    @param [in] bridges     The selected transparent bridges.\r\n     *\r\n     *    @return True, if the bridges are valid, otherwise false.\r\n     */\r\n    bool hasValidBridges(QSharedPointer<QList<QSharedPointer<TransparentBridge> > > bridges) const;\r\n\r\nprivate:\r\n\r\n    /*!\r\n     *  Check if the master interface is valid.\r\n     *\r\n     *    @param [in] master  The selected master interface.\r\n     *\r\n     *    @return True, if the master interface is valid, otherwise false.\r\n     */\r\n    bool hasValidMasterInterface(QSharedPointer<InitiatorInterface> master) const;\r\n\r\n    /*!\r\n     *  Check if the initiator interface is valid.\r\n     *\r\n     *    @param [in] initiator  The selected initiator interface.\r\n     *\r\n     *    @return True, if the initiator interface is valid, otherwise false.\r\n     */\r\n    bool hasValidInitiatorInterface(QSharedPointer<InitiatorInterface> initiator) const;\r\n\r\n    /*!\r\n     *  Check if the given mode references are valid.\r\n     *\r\n     *    @param [in] modeRefs    The mode references to check.\r\n     *\r\n     *    @return True, if all the references are valid, otherwise false.\r\n     */\r\n    bool hasValidModeRefs(QStringList const& modeRefs) const;\r\n\r\n    /*!\r\n     *  Check if the slave interface is valid.\r\n     *\r\n     *    @param [in] busInterface    The containing bus interface.\r\n     *    @param [in] slave           The selected slave interface.\r\n     *\r\n     *    @return True, if the slave interface is valid, otherwise false.\r\n     */\r\n    bool hasValidSlaveInterface(QSharedPointer<BusInterface> busInterface, \r\n        QSharedPointer<TargetInterface> slave) const;\r\n\r\n    /*!\r\n     *  Check if the target interface is valid.\r\n     *\r\n     *    @param [in] busInterface    The containing bus interface.\r\n     *    @param [in] target          The selected target interface.\r\n     *\r\n     *    @return True, if the target interface is valid, otherwise false.\r\n     */\r\n    bool hasValidTargetInterface(QSharedPointer<BusInterface> busInterface,\r\n        QSharedPointer<TargetInterface> target) const;\r\n\r\n    /*!\r\n     *  Check if the slave interface has a valid memory map reference.\r\n     *\r\n     *    @param [in] busInterface    The containing bus interface\r\n     *    @param [in] slave           The selected slave interface.\r\n     *\r\n     *    @return True, if the memory map reference is valid, otherwise false.\r\n     */\r\n    bool slaveInterfaceHasValidMemoryMapRef(QSharedPointer<BusInterface> busInterface,\r\n        QSharedPointer<TargetInterface> slave) const;\r\n\r\n    /*!\r\n     *  Check if a slave interface bridge have a valid master interface reference.\r\n     *\r\n     *    @param [in] bridge  The selected bridge.\r\n     *\r\n     *    @return True, if the master interface reference is valid, otherwise false.\r\n     */\r\n    bool slaveBridgeReferencesValidMaster(QSharedPointer<TransparentBridge> bridge) const;\r\n\r\n    /*!\r\n     *  Check if the slave interface file set reference group is valid.\r\n     *\r\n     *    @param [in] slave   The selected slave interface.\r\n     *\r\n     *    @return True, if the slave interface file set reference group is valid, otherwise false.\r\n     */\r\n    bool slaveInterfaceFileSetRefGroupsAreValid(QSharedPointer<TargetInterface> slave) const;\r\n\r\n    /*!\r\n     *  Check if a file set reference is valid.\r\n     *\r\n     *    @param [in] fileSet reference   The selected file set reference.\r\n     *\r\n     *    @return True, if the file set reference is valid, otherwise false.\r\n     */\r\n    bool slaveFileSetReferenceIsValid(QSharedPointer<FileSetRef> fileSetReference) const;\r\n\r\n    /*!\r\n     *  Check if the system interface is valid.\r\n     *\r\n     *    @param [in] busInterface    The containing bus interface.\r\n     *    @param [in] systemGroup     The selected system group\r\n     *\r\n     *    @return True, if the system interface is valid, otherwise false.\r\n     */\r\n    bool hasValidSystemInterface(QSharedPointer<BusInterface> busInterface, QString const& systemGroup) const;\r\n\r\n    /*!\r\n     *  Check if the mirrored slave interface is valid.\r\n     *\r\n     *    @param [in] mirroredSlave   The selected mirrored slave interface.\r\n     *\r\n     *    @return True, if the mirrored slave interface is valid, otherwise false.\r\n     */\r\n    bool hasValidMirroredSlaveInterface(QSharedPointer<MirroredTargetInterface> mirroredSlave) const;\r\n\r\n    /*!\r\n     *  Check if the mirrored target interface is valid.\r\n     *\r\n     *    @param [in] mirroredTarget   The selected mirrored target interface.\r\n     *\r\n     *    @return True, if the mirrored target interface is valid, otherwise false.\r\n     */\r\n    bool hasValidMirroredTargetInterface(QSharedPointer<MirroredTargetInterface> mirroredTarget) const;\r\n\r\n    /*!\r\n     *  Check if the mirrored slave interface range is valid.\r\n     *\r\n     *    @param [in] mirroredSlave   The selected mirrored slave interface.\r\n     *\r\n     *    @return True, if the range is valid, otherwise false.\r\n     */\r\n    bool mirroredSlaveRangeIsValid(QSharedPointer<MirroredTargetInterface> mirroredSlave) const;\r\n\r\n    /*!\r\n     *  Check if the mirrored slave interface remap address is valid.\r\n     *\r\n     *    @param [in] remapAddress    The selected remap address.\r\n     *\r\n     *    @return True, if the remap address is valid, otherwise false.\r\n     */\r\n    bool mirroredSlaveRemapAddressIsValid(QSharedPointer<MirroredTargetInterface::RemapAddress> remapAddress) const;\r\n\r\n    /*!\r\n     *  Check if the mirrored slave interface remap address remap state is valid.\r\n     *\r\n     *    @param [in] remapAddress    The selected mirrored slave interface remap address.\r\n     *\r\n     *    @return True, if the mirrored slave interface remap address is valid, otherwise false.\r\n     */\r\n    bool mirroredSlaveStateIsValid(QSharedPointer<MirroredTargetInterface::RemapAddress> remapAddress) const;\r\n\r\n    /*!\r\n     *  Check if the monitor interface is valid.\r\n     *\r\n     *    @param [in] busInterface        The containing bus interface.\r\n     *    @param [in] monitorInterface    The selected monitor interface.\r\n     *\r\n     *    @return True, if the monitor interface is valid, otherwise false.\r\n     */\r\n    bool hasValidMonitorInterface(QSharedPointer<BusInterface> busInterface,\r\n        QSharedPointer<BusInterface::MonitorInterface> monitorInterface) const;\r\n\r\n    /*!\r\n     *  Check if the interface reference has a valid presence.\r\n     *\r\n     *    @param [in] interfacePresence   The presence of the original interface.\r\n     *    @param [in] targetPresence      The presence of the target interface.\r\n     *\r\n     *    @return True, if the interface reference has a valid presence, otherwise false.\r\n     */\r\n    bool interfaceReferenceHasValidPresence(QString const& interfacePresence, QString const& targetPresence) const;\r\n\r\n    /*!\r\n     *  Find errors within name.\r\n     *\r\n     *    @param [in] errors          List of found errors.\r\n     *    @param [in] busInterface    The selected bus interface.\r\n     *    @param [in] context         Context to help locate the error.\r\n     */\r\n    void findErrorsInName(QVector<QString>& errors, QSharedPointer<BusInterface> busInterface,\r\n        QString const& context) const;\r\n\r\n    /*!\r\n     *  Find errors within isPresent.\r\n     *\r\n     *    @param [in] errors          List of found errors.\r\n     *    @param [in] busInterface    The selected bus interface.\r\n     *    @param [in] context         Context to help locate the error.\r\n     */\r\n    void findErrorsInIsPresent(QVector<QString>& errors, QSharedPointer<BusInterface> busInterface,\r\n        QString const& context) const;\r\n\r\n    /*!\r\n     *  Find errors within bus type.\r\n     *\r\n     *    @param [in] errors          List of found errors.\r\n     *    @param [in] busInterface    The selected bus interface.\r\n     *    @param [in] context         Context to help locate the error.\r\n     */\r\n    void findErrorsInBusType(QVector<QString>& errors, QSharedPointer<BusInterface> busInterface,\r\n        QString const& context) const;\r\n\r\n    /*!\r\n     *  Find errors within parameters.\r\n     *\r\n     *    @param [in] errors          List of found errors.\r\n     *    @param [in] busInterface    The selected bus interface.\r\n     *    @param [in] context         Context to help locate the error.\r\n     */\r\n    void findErrorsInParameters(QVector<QString>& errors, QSharedPointer<BusInterface> busInterface,\r\n        QString const& context) const;\r\n\r\n    /*!\r\n     *  Find errors within abstraction types.\r\n     *\r\n     *    @param [in] errors          List of found errors.\r\n     *    @param [in] busInterface    The selected bus interface.\r\n     *    @param [in] context         Context to help locate the error.\r\n     */\r\n    void findErrorsInAbstractionTypes(QVector<QString>& errors, QSharedPointer<BusInterface> busInterface,\r\n        QString const& context) const;\r\n\r\n    /*!\r\n     *  Find errors within interface mode.\r\n     *\r\n     *    @param [in] errors                  List of found errors.\r\n     *    @param [in] busInterface            The selected bus interface.\r\n     *    @param [in] busInterfaceContext     Context information of the bus interface\r\n     *    @param [in] containingContext       Context to help locate the error.\r\n     */\r\n    void findErrorsInInterfaceMode(QVector<QString>& errors, QSharedPointer<BusInterface> busInterface,\r\n        QString const& busInterfaceContext, QString const& containingContext) const;\r\n\r\n    /*!\r\n     *  Find errors within master interface.\r\n     *\r\n     *    @param [in] errors      List of found errors.\r\n     *    @param [in] master      The selected master interface.\r\n     *    @param [in] context     Context to help locate the error.\r\n     */\r\n    void findErrorsInMasterInterface(QVector<QString>& errors, QSharedPointer<InitiatorInterface> master,\r\n        QString const& context) const;\r\n\r\n    /*!\r\n     *  Find errors within initiator interface.\r\n     *\r\n     *    @param [in] errors      List of found errors.\r\n     *    @param [in] master      The selected initiator interface.\r\n     *    @param [in] context     Context to help locate the error.\r\n     */\r\n    void findErrorsInInitiatorInterface(QVector<QString>& errors, QSharedPointer<InitiatorInterface> initiator, \r\n        QString const& context) const;\r\n\r\n    /*!\r\n     *  Find errors within mode references.\r\n     *\r\n     *    @param [in] modeRefs    The references to check.\r\n     *    @param [in] errors      List of found errors.\r\n     *    @param [in] context     Context to help locate the error.\r\n     */\r\n    void findErrorsInModeReferences(QStringList const& modeRefs, QVector<QString>& errors, \r\n        QString const& context) const;\r\n\r\n    /*!\r\n     *  Find errors within slave interface.\r\n     *\r\n     *    @param [in] errors          List of found errors.\r\n     *    @param [in] busInterface    The containing bus interface.\r\n     *    @param [in] slave           The selected slave interface.\r\n     *    @param [in] context         Context to help locate the error.\r\n     */\r\n    void findErrorsInSlaveInterface(QVector<QString>& errors, QSharedPointer<BusInterface> busInterface,\r\n        QSharedPointer<TargetInterface> slave, QString const& context) const;\r\n    /*!\r\n     *  Find errors within target interface.\r\n     *\r\n     *    @param [in] errors          List of found errors.\r\n     *    @param [in] busInterface    The containing bus interface.\r\n     *    @param [in] target          The selected target interface.\r\n     *    @param [in] context         Context to help locate the error.\r\n     */\r\n    void findErrorsInTargetInterface(QVector<QString>& errors, QSharedPointer<BusInterface> busInterface, \r\n        QSharedPointer<TargetInterface> target, QString const& context) const;\r\n\r\n    /*!\r\n     *  Find errors within system mode.\r\n     *\r\n     *    @param [in] errors          List of found errors.\r\n     *    @param [in] systemGroup     The selected system group.\r\n     *    @param [in] busInterface    The containing bus interface.\r\n     *    @param [in] context         Context to help locate the error.\r\n     */\r\n    void findErrorsInSystemInterface(QVector<QString>& errors, QString const& systemGroup,\r\n        QSharedPointer<BusInterface> busInterface, QString const& context) const;\r\n\r\n    /*!\r\n     *  Find errors within mirrored slave interface.\r\n     *\r\n     *    @param [in] errors          List of found errors.\r\n     *    @param [in] mirroredSlave   The selected mirrored slave interface.\r\n     *    @param [in] context         Context to help locate the error.\r\n     */\r\n    void findErrorsInMirroredSlaveInterface(QVector<QString>& errors,\r\n        QSharedPointer<MirroredTargetInterface> mirroredSlave, QString const& context) const;\r\n\r\n    /*!\r\n     *  Find errors within mirrored target interface.\r\n     *\r\n     *    @param [in] errors          List of found errors.\r\n     *    @param [in] mirroredTarget  The selected mirrored target interface.\r\n     *    @param [in] context         Context to help locate the error.\r\n     */\r\n    void findErrorsInMirroredTargetInterface(QVector<QString>& errors, \r\n        QSharedPointer<MirroredTargetInterface> mirroredTarget, QString const& context) const;\r\n\r\n    /*!\r\n     *  Find errors within monitor interface.\r\n     *\r\n     *    @param [in] errors      List of found errors.\r\n     *    @param [in] monitor     The selected monitor interface.\r\n     *    @param [in] context     Context to help locate the error.\r\n     */\r\n    void findErrorsInMonitorInterface(QVector<QString>& errors, QSharedPointer<BusInterface> busInterface,\r\n        QSharedPointer<BusInterface::MonitorInterface> monitor, QString const& context) const;\r\n\r\n    /*!\r\n     *  Find errors within bis in LAU.\r\n     *\r\n     *    @param [in] errors          List of found errors.\r\n     *    @param [in] busInterface    The selected bus interface.\r\n     *    @param [in] context         Context to help locate the error.\r\n     */\r\n    void findErrorsInBitsInLAU(QVector<QString>& errors, QSharedPointer<BusInterface> busInterface,\r\n        QString const& context) const;\r\n\r\n    /*!\r\n     *  Find errors within bit steering.\r\n     *\r\n     *    @param [in] errors          List of found errors.\r\n     *    @param [in] busInterface    The selected bus interface.\r\n     *    @param [in] context         Context to help locate the error.\r\n     */\r\n    void findErrorsInBitSteering(QVector<QString>& errors, QSharedPointer<BusInterface> busInterface,\r\n        QString const& context, Document::Revision docRevision) const;\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! The expression parser to use.\r\n    QSharedPointer<ExpressionParser> expressionParser_;\r\n\r\n    //! The currently available choices.\r\n    QSharedPointer<QList<QSharedPointer<Choice> > > availableChoices_;\r\n\r\n    //! The currently available views.\r\n    QSharedPointer<QList<QSharedPointer<View> > > availableViews_;\r\n\r\n    //! The currently available ports.\r\n    QSharedPointer<QList<QSharedPointer<Port> > > availablePorts_;\r\n\r\n    //! The currently available address spaces.\r\n    QSharedPointer<QList<QSharedPointer<AddressSpace> > > availableAddressSpaces_;\r\n\r\n    //! The currently available memory maps.\r\n    QSharedPointer<QList<QSharedPointer<MemoryMap> > > availableMemoryMaps_;\r\n\r\n    //! The currently available bus interfaces.\r\n    QSharedPointer<QList<QSharedPointer<BusInterface> > > availableBusInterfaces_;\r\n    \r\n    //! The currently available file sets.\r\n    QSharedPointer<QList<QSharedPointer<FileSet> > > availableFileSets_;\r\n\r\n    //! The currently available remap states.\r\n    QSharedPointer<QList<QSharedPointer<RemapState> > > availableRemapStates_;\r\n\r\n    //! The currently available modes.\r\n    QSharedPointer<QList<QSharedPointer<Mode> > > availableModes_;\r\n\r\n    //! The library interface.\r\n    LibraryInterface* libraryHandler_;\r\n\r\n    //! Validator for parameters.\r\n    QSharedPointer<ParameterValidator> parameterValidator_;\r\n\r\n    //! Validator for abstraction types.\r\n    QSharedPointer<AbstractionTypeValidator> abstractionValidator_;\r\n};\r\n\r\n#endif // ADDRESSSPACEVALIDATOR_H\r\n"
  },
  {
    "path": "IPXACTmodels/Component/validators/CPUValidator.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: CPUValidator.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Janne Virtanen\r\n// Date: 18.11.2015\r\n//\r\n// Description:\r\n// Validator for ipxact:CPU.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"CPUValidator.h\"\r\n\r\n#include <IPXACTmodels/common/validators/CommonItemsValidator.h>\r\n#include <IPXACTmodels/common/validators/ParameterValidator.h>\r\n\r\n#include <IPXACTmodels/Component/AddressSpace.h>\r\n#include <IPXACTmodels/Component/MemoryMap.h>\r\n#include <IPXACTmodels/Component/Cpu.h>\r\n#include <IPXACTmodels/Component/validators/MemoryReserve.h>\r\n\r\n#include <KactusAPI/include/ExpressionParser.h>\r\n\r\n#include <QRegularExpression>\r\n#include <QStringList>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: CPUValidator::CPUValidator()\r\n//-----------------------------------------------------------------------------\r\nCPUValidator::CPUValidator(QSharedPointer<ParameterValidator> parameterValidator,\r\n    QSharedPointer<ExpressionParser> expressionParser,\r\n    QSharedPointer<QList<QSharedPointer<AddressSpace> > > addressSpaces, \r\n    QSharedPointer<QList<QSharedPointer<MemoryMap> > > memoryMaps,\r\n    Document::Revision revision) :\r\nHierarchicalValidator(),\r\nparameterValidator_(parameterValidator),\r\nregionValidator_(new RegionValidator(expressionParser)),\r\nexpressionParser_(expressionParser),\r\naddressSpaces_(addressSpaces),\r\nmemoryMaps_(memoryMaps),\r\nrevision_(revision)\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: CPUValidator::componentChange()\r\n//-----------------------------------------------------------------------------\r\nvoid CPUValidator::componentChange(QSharedPointer<QList<QSharedPointer<AddressSpace> > > newAddressSpaces,\r\n    QSharedPointer<QList<QSharedPointer<MemoryMap> > > memoryMaps,\r\n    Document::Revision revision)\r\n{\r\n    addressSpaces_ = newAddressSpaces;\r\n    memoryMaps_ = memoryMaps;\r\n    revision_ = revision;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: CPUValidator::validate()\r\n//-----------------------------------------------------------------------------\r\nbool CPUValidator::validate(QSharedPointer<Cpu> cpu) const\r\n{\r\n\tif (hasValidName( cpu->name()) == false)\r\n\t{\r\n\t\treturn false;\r\n\t}\r\n\r\n    if (revision_ == Document::Revision::Std14)\r\n    {\r\n        bool isValidPresence = false;\r\n        expressionParser_->parseExpression(cpu->getIsPresent(), &isValidPresence);\r\n        if (isValidPresence == false)\r\n        {\r\n            return false;\r\n        }\r\n\r\n        if (hasValidAddressSpaceReferences(cpu) == false)\r\n        {\r\n            return false;\r\n        }\r\n    }\r\n\r\n    if (revision_ == Document::Revision::Std22 &&\r\n        (hasValidMemoryMapReference(cpu) == false || hasValidRange(cpu) == false || \r\n         hasValidWidth(cpu) == false || hasValidAddressUnitBits(cpu) == false ||\r\n         hasValidRegions(cpu) == false))\r\n    {\r\n        return false;\r\n    }\r\n\r\n\tfor (QSharedPointer<Parameter> const& currentPara : *cpu->getParameters())\r\n\t{\r\n\t\tif (parameterValidator_->hasValidValue(currentPara) == false)\r\n\t\t{\r\n\t\t\treturn false;\r\n\t\t}\r\n\t}\r\n\r\n\treturn validComparedToSiblings(cpu);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: CPUValidator::hasValidAddressSpaceReferences()\r\n//-----------------------------------------------------------------------------\r\nbool CPUValidator::hasValidAddressSpaceReferences(QSharedPointer<Cpu> cpu) const\r\n{\r\n    if (cpu->getAddressSpaceReferences()->count() < 1)\r\n    {\r\n        return false;\r\n    }\r\n\r\n    for (QSharedPointer<Cpu::AddressSpaceRef> currentRef : *cpu->getAddressSpaceReferences())\r\n    {\r\n        if (isValidAddressSpaceReference(currentRef->getAddressSpaceRef()) == false)\r\n        {\r\n            return false;\r\n        }\r\n        \r\n\t    bool isValidPresence = false;\r\n        expressionParser_->parseExpression(currentRef->getIsPresent(), &isValidPresence);\r\n        if (isValidPresence == false)\r\n        {\r\n            return false;\r\n        }\r\n    }\r\n\r\n    return true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: CPUValidator::hasValidMemoryMapReference()\r\n//-----------------------------------------------------------------------------\r\nbool CPUValidator::hasValidMemoryMapReference(QSharedPointer<Cpu> cpu) const\r\n{\r\n    QString ref = cpu->getMemoryMapReference();\r\n    if (ref.isEmpty())\r\n    {\r\n        return false;\r\n    }\r\n\r\n    if (memoryMaps_)\r\n    {\r\n        return std::any_of(memoryMaps_->cbegin(), memoryMaps_->cend(),\r\n            [&ref](auto const& memoryMap) {return memoryMap->name() == ref; });\r\n    }\r\n\r\n    return false;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: CPUValidator::hasValidRegions()\r\n//-----------------------------------------------------------------------------\r\nbool CPUValidator::hasValidRegions(QSharedPointer<Cpu> cpu) const\r\n{\r\n    if (cpu->getRegions()->isEmpty())\r\n    {\r\n        return true;\r\n    }\r\n\r\n    MemoryReserve reservedArea;\r\n\r\n    QStringList regionNames;\r\n\r\n    qint64 availableRange = expressionParser_->parseExpression(cpu->getRange()).toLongLong();\r\n\r\n    for (QSharedPointer<Region> region : *cpu->getRegions())\r\n    {\r\n        qint64 regionBegin = expressionParser_->parseExpression(region->getAddressOffset()).toLongLong();\r\n        qint64 regionRange = expressionParser_->parseExpression(region->getRange()).toLongLong();\r\n        qint64 regionEnd = regionBegin + regionRange - 1;\r\n\r\n        if (regionNames.contains(region->name()) ||\r\n            regionValidator_->validate(region) == false ||\r\n            regionEnd > availableRange)\r\n        {\r\n            return false;\r\n        }\r\n        else\r\n        {\r\n            regionNames.append(region->name());\r\n            reservedArea.addArea(region->name(), regionBegin, regionEnd);\r\n        }\r\n    }\r\n\r\n    return reservedArea.hasOverlap() == false;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: CPUValidator::findErrorsIn()\r\n//-----------------------------------------------------------------------------\r\nvoid CPUValidator::findErrorsIn(QVector<QString>& errors, QSharedPointer<Cpu> cpu,\r\n    QString const& context) const\r\n{\r\n\tif (hasValidName(cpu->name()) == false)\r\n\t{\r\n        errors.append(QObject::tr(\"Invalid name '%1' set for CPU within %2.\").arg(cpu->name(), context));\r\n\t}\r\n\r\n    if (revision_ == Document::Revision::Std14)\r\n    {\r\n        bool isValidPresence = false;\r\n        expressionParser_->parseExpression(cpu->getIsPresent(), &isValidPresence);\r\n        if (isValidPresence == false)\r\n        {\r\n            errors.append(QObject::tr(\"Is present expression '%1' in CPU %2 is invalid.\").arg(\r\n                cpu->getIsPresent(), cpu->name()));\r\n        }\r\n\r\n        if (cpu->getAddressSpaceReferences()->count() < 1)\r\n        {\r\n            errors.append(QObject::tr(\"No address space reference set for CPU %1 within %2.\")\r\n                .arg(cpu->name()).arg(context));\r\n        }\r\n\r\n        for (QSharedPointer<Cpu::AddressSpaceRef> const& currentRef : *cpu->getAddressSpaceReferences())\r\n        {\r\n            if (!isValidAddressSpaceReference(currentRef->getAddressSpaceRef()))\r\n            {\r\n                errors.append(QObject::tr(\"Address space '%1' referenced within CPU %2 is not found.\").arg(\r\n                    currentRef->getAddressSpaceRef(), cpu->name()));\r\n            }\r\n\r\n            bool isValidRefPresence = false;\r\n            expressionParser_->parseExpression(currentRef->getIsPresent(), &isValidRefPresence);\r\n            if (isValidRefPresence == false)\r\n            {\r\n                errors.append(QObject::tr(\r\n                    \"Is present expression '%1' for address space reference %2 in CPU %3 is invalid.\"\r\n                ).arg(currentRef->getIsPresent(), currentRef->getAddressSpaceRef(), cpu->name()));\r\n            }\r\n        }\r\n    }\r\n\t\r\n    if (revision_ == Document::Revision::Std22)\r\n    {\r\n        if (cpu->getMemoryMapReference().isEmpty())\r\n        {\r\n            errors.append(QObject::tr(\"No memory map reference set for CPU %1 within %2.\").arg(\r\n                cpu->name(), context));\r\n        }\r\n        else if (isValidMemoryMapReference(cpu->getMemoryMapReference()) == false)\r\n        {\r\n            errors.append(QObject::tr(\"Memory map '%1' referenced within CPU %2 is not found.\").arg(\r\n                cpu->getMemoryMapReference(), cpu->name()));\r\n        }\r\n\r\n        if (hasValidRange(cpu) == false)\r\n        {\r\n            errors.append(QObject::tr(\"Invalid range set for CPU %1.\").arg(cpu->name()));\r\n        }\r\n\r\n        if (hasValidWidth(cpu) == false)\r\n        {\r\n            errors.append(QObject::tr(\"Invalid width set for CPU %1.\").arg(cpu->name()));\r\n        }\r\n\r\n        if (hasValidAddressUnitBits(cpu) == false)\r\n        {\r\n            errors.append(QObject::tr(\"Invalid address unit bits set for CPU %1.\").arg(cpu->name()));\r\n        }\r\n\r\n        findErrorsInRegions(errors, cpu, context);\r\n    }\r\n\r\n    QString cpuContext = QObject::tr(\"cpu %1\").arg(cpu->name());\r\n\tfor (QSharedPointer<Parameter> const& currentPara : *cpu->getParameters())\r\n\t{\r\n\t\tparameterValidator_->findErrorsIn(errors, currentPara, cpuContext);\r\n\t}\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: CPUValidator::findErrorsInRegions()\r\n//-----------------------------------------------------------------------------\r\nvoid CPUValidator::findErrorsInRegions(QVector<QString>& errors,\r\n    QSharedPointer<Cpu> cpu, QString const& context) const\r\n{\r\n    if (cpu->getRegions()->isEmpty() == false)\r\n    {\r\n        qint64 availableRange = expressionParser_->parseExpression(cpu->getRange()).toLongLong();\r\n\r\n        MemoryReserve reservedArea;\r\n        QStringList regionNames;\r\n        QStringList foundNames;\r\n\r\n        for (QSharedPointer<Region> const& region : *cpu->getRegions())\r\n        {\r\n            regionValidator_->findErrorsIn(errors, region, context);\r\n\r\n            if (regionNames.contains(region->name()) && !foundNames.contains(region->name()))\r\n            {\r\n                errors.append(QObject::tr(\"Name %1 of regions in %2 is not unique.\").arg(region->name(), context));\r\n                foundNames.append(region->name());\r\n            }\r\n            else\r\n            {\r\n                regionNames.append(region->name());\r\n            }\r\n\r\n            qint64 regionBegin = expressionParser_->parseExpression(region->getAddressOffset()).toLongLong();\r\n            qint64 regionRange = expressionParser_->parseExpression(region->getRange()).toLongLong();\r\n            qint64 regionEnd = regionBegin + regionRange - 1;\r\n\r\n            reservedArea.addArea(region->name(), regionBegin, regionEnd);\r\n\r\n            if (regionEnd > availableRange)\r\n            {\r\n                errors.append(QObject::tr(\"Region %1 is not contained within address space of CPU %2.\").arg(\r\n                    region->name(), cpu->name()));\r\n            }\r\n        }\r\n\r\n        reservedArea.findErrorsInOverlap(errors, QLatin1String(\"Regions\"),\r\n            QObject::tr(\"address space of CPU %1\").arg(cpu->name()));\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: CPUValidator::getRegionValidator()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<RegionValidator> CPUValidator::getRegionValidator() const\r\n{\r\n    return regionValidator_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: EnumeratedValueValidator::hasValidName()\r\n//-----------------------------------------------------------------------------\r\nbool CPUValidator::hasValidName(QString const& name) const\r\n{\r\n    return CommonItemsValidator::hasValidName(name);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: CPUValidator::isValidAddressSpaceReference()\r\n//-----------------------------------------------------------------------------\r\nbool CPUValidator::isValidAddressSpaceReference(QString const& reference) const\r\n{\r\n    if (!reference.isEmpty() && addressSpaces_)\r\n    {\r\n        return std::any_of(addressSpaces_->cbegin(), addressSpaces_->cend(),\r\n            [&reference](auto const& addressSpace) {return addressSpace->name() == reference; });\r\n    }\r\n\r\n    return false;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: CPUValidator::isValidMemoryMapReference()\r\n//-----------------------------------------------------------------------------\r\nbool CPUValidator::isValidMemoryMapReference(QString const& reference) const\r\n{\r\n    if (memoryMaps_)\r\n    {\r\n        return std::any_of(memoryMaps_->cbegin(), memoryMaps_->cend(),\r\n            [&reference](auto const& memoryMap) {return memoryMap->name() == reference; });\r\n    }\r\n\r\n    return false;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: CPUValidator::hasValidRange()\r\n//-----------------------------------------------------------------------------\r\nbool CPUValidator::hasValidRange(QSharedPointer<Cpu> cpu) const\r\n{\r\n    auto range = cpu->getRange();\r\n    return range.isEmpty() == false && CommonItemsValidator::isValidExpression(range, expressionParser_);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: CPUValidator::hasValidWidth()\r\n//-----------------------------------------------------------------------------\r\nbool CPUValidator::hasValidWidth(QSharedPointer<Cpu> cpu) const\r\n{\r\n    auto width = cpu->getWidth();\r\n    return width.isEmpty() == false && CommonItemsValidator::isValidExpression(width, expressionParser_);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: CPUValidator::hasValidAddressUnitBits()\r\n//-----------------------------------------------------------------------------\r\nbool CPUValidator::hasValidAddressUnitBits(QSharedPointer<Cpu> cpu) const\r\n{\r\n    auto aub = cpu->getAddressUnitBits();\r\n    return aub.isEmpty() || CommonItemsValidator::isValidExpression(aub, expressionParser_);\r\n}\r\n"
  },
  {
    "path": "IPXACTmodels/Component/validators/CPUValidator.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: CPUValidator.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Janne Virtanen\r\n// Date: 18.11.2015\r\n//\r\n// Description:\r\n// Validator for ipxact:CPU.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef CPUVALIDATOR_H\r\n#define CPUVALIDATOR_H\r\n\r\n#include <IPXACTmodels/ipxactmodels_global.h>\r\n\r\n#include <IPXACTmodels/common/Document.h>\r\n\r\n#include <IPXACTmodels/common/validators/HierarchicalValidator.h>\r\n\r\n#include \"RegionValidator.h\"\r\n\r\n#include <QList>\r\n#include <QSharedPointer>\r\n#include <QString>\r\n#include <QVector>\r\n\r\nclass AddressSpace;\r\nclass Cpu;\r\nclass ExpressionParser;\r\nclass MemoryMap;\r\nclass ParameterValidator;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Validator for ipxact:CPU.\r\n//-----------------------------------------------------------------------------\r\nclass IPXACTMODELS_EXPORT CPUValidator : public HierarchicalValidator\r\n{\r\npublic:\r\n\r\n\t/*!\r\n\t *  The constructor.\r\n\t *\r\n     *    @param [in] parameterValidator  Validator for cpu parameters.\r\n     *    @param [in] expressionParser    Parser for expressions in cpu.\r\n     *    @param [in] addressSpaces       The available address spaces that may be referenced.\r\n     *    @param [in] addressSpaces       The available memory maps that may be referenced.\r\n     *    @param [in] revision            The applied IP-XACT standard revision.\r\n\t */\r\n    CPUValidator(QSharedPointer<ParameterValidator> parameterValidator,\r\n        QSharedPointer<ExpressionParser> expressionParser,\r\n        QSharedPointer<QList<QSharedPointer<AddressSpace> > > addressSpaces,\r\n        QSharedPointer<QList<QSharedPointer<MemoryMap> > > memoryMaps,\r\n        Document::Revision revision);\r\n\r\n\t//! The destructor.\r\n\t~CPUValidator() = default;\r\n\r\n    // Disable copying.\r\n    CPUValidator(CPUValidator const& rhs) = delete;\r\n    CPUValidator& operator=(CPUValidator const& rhs) = delete;\r\n\r\n    /*!\r\n     *  Change the available address spaces.\r\n     *\r\n     *    @param [in] newAddressSpaces    The new address spaces.\r\n     *    @param [in] addressSpaces       The available memory maps that may be referenced.\r\n     *    @param [in] revision            The applied IP-XACT standard revision.\r\n     */\r\n    void componentChange(QSharedPointer<QList<QSharedPointer<AddressSpace> > > newAddressSpaces,\r\n        QSharedPointer<QList<QSharedPointer<MemoryMap> > > memoryMaps,\r\n        Document::Revision revision);\r\n\r\n    /*!\r\n     *  Validates the given CPU.\r\n     *\r\n     *    @param [in] cpu           The CPU to validate.\r\n     *\r\n     *    @return True, if the CPU is valid IP-XACT, otherwise false.\r\n     */\r\n    bool validate(QSharedPointer<Cpu> cpu) const;\r\n\r\n    /*!\r\n     *  Checks if the address space references of a CPU are valid.\r\n     *\r\n     *    @param [in] cpu   The CPU whose address space references to check.\r\n     *\r\n     *    @return True, if the references are valid, otherwise false.\r\n     */\r\n    bool hasValidAddressSpaceReferences(QSharedPointer<Cpu> cpu) const;\r\n\r\n    /*!\r\n     *  Checks if the memory map reference of a CPU is valid (1865-2022).\r\n     *\r\n     *    @param [in] cpu   The CPU whose memory map references to check.\r\n     *\r\n     *    @return True, if the reference is valid, otherwise false.\r\n     */\r\n    bool hasValidMemoryMapReference(QSharedPointer<Cpu> cpu) const;\r\n\r\n    /*!\r\n     *  Checks if the range of a CPU are valid (1865-2022).\r\n     *\r\n     *    @param [in] cpu   The CPU whose range to check.\r\n     *\r\n     *    @return True, if the range is valid, otherwise false.\r\n     */\r\n    bool hasValidRange(QSharedPointer<Cpu> cpu) const;\r\n\r\n    /*!\r\n     *  Checks if the width of a CPU are valid (1865-2022).\r\n     *\r\n     *    @param [in] cpu   The CPU whose width to check.\r\n     *\r\n     *    @return True, if the width is valid, otherwise false.\r\n     */\r\n    bool hasValidWidth(QSharedPointer<Cpu> cpu) const;\r\n\r\n    /*!\r\n     *  Checks if the address unit bits of a CPU are valid (1865-2022).\r\n     *\r\n     *    @param [in] cpu   The CPU whose address unit bits to check.\r\n     *\r\n     *    @return True, if the address unit bits are valid, otherwise false.\r\n     */\r\n    bool hasValidAddressUnitBits(QSharedPointer<Cpu> cpu) const;\r\n\r\n    /*!\r\n     *  Checks if the regions of a CPU are valid (1865-2022).\r\n     *\r\n     *    @param [in] cpu   The CPU whose regions to check.\r\n     *\r\n     *    @return True, if the regions are valid, otherwise false.\r\n     */\r\n    bool hasValidRegions(QSharedPointer<Cpu> testCpu) const;\r\n\r\n    /*!\r\n     *  Finds possible errors in a CPU and creates a list of them.\r\n     *\r\n     *    @param [in] errors      List of found errors.\r\n     *    @param [in] cpu         The CPU whose errors to find.\r\n     *    @param [in] context     Context to help locate the errors.\r\n     */\r\n    void findErrorsIn(QVector<QString>& errors, QSharedPointer<Cpu> cpu, QString const& context) const;\r\n\r\n    /*!\r\n     *  Finds possible errors in the CPU regions and creates a list of them.\r\n     *\r\n     *    @param [in] errors      List of found errors.\r\n     *    @param [in] cpu         The CPU whose region errors to find.\r\n     *    @param [in] context     Context to help locate the errors.\r\n     */   \r\n    void findErrorsInRegions(QVector<QString>& errors, QSharedPointer<Cpu> cpu, QString const& context) const;\r\n\r\n    /*!\r\n     *  Get the validator used for checking regions.\r\n     *\r\n     *    @return The validator for regions.\r\n     */\r\n    QSharedPointer<RegionValidator> getRegionValidator() const;\r\n\r\nprivate:\r\n\r\n    /*!\r\n     *  Check if the name is valid.\r\n     *\r\n     *    @param [in] name    The name to be evaluated.\r\n     *\r\n     *    @return True, if the name is valid, otherwise false.\r\n     */\r\n    bool hasValidName(QString const& name) const;\r\n\r\n    /*!\r\n     *  Checks if the given reference to address space is valid.\r\n     *\r\n     *    @param [in] reference   The name reference for the address space.\r\n     *\r\n     *    @return True, if the reference is valid, otherwise false.\r\n     */\r\n    bool isValidAddressSpaceReference(QString const& reference) const;\r\n\r\n    /*!\r\n     *  Checks if the given reference to a memory map is valid.\r\n     *\r\n     *    @param [in] reference   The name reference for the memory map.\r\n     *\r\n     *    @return True, if the reference is valid, otherwise false.\r\n     */\r\n    bool isValidMemoryMapReference(QString const& reference) const;\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! Validator for cpu parameters.\r\n    QSharedPointer<ParameterValidator> parameterValidator_;\r\n\r\n    //! Validator for cpu regions.\r\n    QSharedPointer<RegionValidator> regionValidator_;\r\n\r\n    //! Parser for expressions in cpu.\r\n    QSharedPointer<ExpressionParser> expressionParser_;\r\n\r\n    //! The available address spaces for referencing.\r\n    QSharedPointer<QList<QSharedPointer<AddressSpace> > > addressSpaces_;\r\n\r\n    //! The available memory maps for referencing.\r\n    QSharedPointer<QList<QSharedPointer<MemoryMap> > > memoryMaps_;\r\n\r\n    //! The IP-XACT standard revision to validate against.\r\n    Document::Revision revision_;\r\n};\r\n\r\n#endif // SYSTEMVERILOGVALIDATOR_H\r\n"
  },
  {
    "path": "IPXACTmodels/Component/validators/ChannelValidator.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ChannelValidator.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Janne Virtanen\r\n// Date: 19.11.2015\r\n//\r\n// Description:\r\n// Validator for ipxact:Channel.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"ChannelValidator.h\"\r\n\r\n#include <IPXACTmodels/Component/BusInterface.h>\r\n#include <IPXACTmodels/common/validators/CommonItemsValidator.h>\r\n#include <IPXACTmodels/utilities/Search.h>\r\n\r\n#include <KactusAPI/include/ExpressionParser.h>\r\n\r\n#include <QStringList>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ChannelValidator::ChannelValidator()\r\n//-----------------------------------------------------------------------------\r\nChannelValidator::ChannelValidator(QSharedPointer<ExpressionParser> expressionParser,\r\n    QSharedPointer<QList<QSharedPointer<BusInterface> > > componentBusInterfaces):\r\nbusInterfaces_(componentBusInterfaces),\r\nexpressionParser_(expressionParser)\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ChannelValidator::componentChange()\r\n//-----------------------------------------------------------------------------\r\nvoid ChannelValidator::componentChange(QSharedPointer<QList<QSharedPointer<BusInterface> > > newBusInterfaces)\r\n{\r\n    busInterfaces_ = newBusInterfaces;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ChannelValidator::validate()\r\n//-----------------------------------------------------------------------------\r\nbool ChannelValidator::validate(QSharedPointer<Channel> channel) const\r\n{\r\n\tif (!hasValidName(channel->name()))\r\n\t{\r\n\t\treturn false;\r\n\t}\r\n\t\r\n    if (CommonItemsValidator::hasValidIsPresent(channel->getIsPresent(), expressionParser_) == false)\r\n\t{\r\n\t\treturn false;\r\n\t}\r\n\t\r\n    if (!hasValidBusInterfaceReferences(channel))\r\n\t{\r\n\t\treturn false;\r\n\t}\r\n\r\n\treturn true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ChannelValidator::hasValidBusInterfaceReferences()\r\n//-----------------------------------------------------------------------------\r\nbool ChannelValidator::hasValidBusInterfaceReferences(QSharedPointer<Channel> channel) const\r\n{\r\n    if (channel->getInterfaces()->count() < 2)\r\n    {\r\n        return false;\r\n    }\r\n\r\n    return std::all_of(channel->getInterfaces()->cbegin(), channel->getInterfaces()->cend(),\r\n        [this](auto const& currentRef) { return isReferenceToMirroredInterface(currentRef->localName_); });\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ChannelValidator::findErrorsIn()\r\n//-----------------------------------------------------------------------------\r\nvoid ChannelValidator::findErrorsIn(QVector<QString>& errors, QSharedPointer<Channel> channel,\r\n    QString const& context) const\r\n{\r\n\tif (!hasValidName(channel->name()))\r\n\t{\r\n\t\terrors.append(QObject::tr(\"Invalid name %1 specified for channel within %2.\")\r\n            .arg(channel->name()).arg(context));\r\n\t}\r\n\r\n\tif (CommonItemsValidator::hasValidIsPresent(channel->getIsPresent(), expressionParser_) == false)\r\n\t{\r\n        errors.append(QObject::tr(\"Is present expression '%1' in channel %2 is invalid.\").arg(\r\n            channel->getIsPresent(), channel->name()));\r\n\t}\r\n\t\r\n\tif (channel->getInterfaces()->count() < 2)\r\n\t{\r\n\t\terrors.append(QObject::tr(\"At least two interfaces must be defined for channel %1.\").arg(channel->name()));\r\n\t}\r\n\r\n\tfor (auto const& currentRef : *channel->getInterfaces())\r\n\t{\r\n\t\tif (!isValidBusIntefaceReference(currentRef->localName_))\r\n\t\t{\r\n\t\t\terrors.append(QObject::tr(\"Bus interface '%1' referenced within channel %2 not found.\").arg(\r\n                currentRef->localName_, channel->name()));\r\n\t\t}\r\n        else if (!isReferenceToMirroredInterface(currentRef->localName_))\r\n        {\r\n            errors.append(QObject::tr(\"Bus interface '%1' referenced within channel %2 is not a mirrored interface.\"\r\n                ).arg(currentRef->localName_, channel->name()));\r\n        }\r\n\t}\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: EnumeratedValueValidator::hasValidName()\r\n//-----------------------------------------------------------------------------\r\nbool ChannelValidator::hasValidName(QString const& name) const\r\n{\r\n\treturn CommonItemsValidator::hasValidName(name);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ChannelValidator::isValidBusIntefaceReference()\r\n//-----------------------------------------------------------------------------\r\nbool ChannelValidator::isValidBusIntefaceReference(QString const& interfaceName) const\r\n{\r\n    if (busInterfaces_ == nullptr)\r\n    {\r\n        return false;\r\n    }\r\n\r\n    auto const& busInterface = Search::findByName(interfaceName, *busInterfaces_);\r\n    return busInterface.isNull() == false;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ChannelValidator::isReferenceToMirroredInterface()\r\n//-----------------------------------------------------------------------------\r\nbool ChannelValidator::isReferenceToMirroredInterface(QString const& interfaceName) const\r\n{\r\n    if (busInterfaces_ == nullptr)\r\n    {\r\n        return false;\r\n    }\r\n\r\n    auto const& busInterface = Search::findByName(interfaceName, *busInterfaces_);\r\n    if (busInterface == nullptr)\r\n    {\r\n        return false;\r\n    }\r\n\r\n    auto const& mode = busInterface->getInterfaceMode();\r\n    return mode == General::MIRRORED_MASTER ||\r\n        mode == General::MIRRORED_SLAVE ||\r\n        mode == General::MIRRORED_INITIATOR ||\r\n        mode == General::MIRRORED_TARGET ||\r\n        mode == General::MIRRORED_SYSTEM;\r\n}\r\n    "
  },
  {
    "path": "IPXACTmodels/Component/validators/ChannelValidator.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ChannelValidator.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Janne Virtanen\r\n// Date: 19.11.2015\r\n//\r\n// Description:\r\n// Validator for ipxact:Channel.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef CHANNELVALIDATOR_H\r\n#define CHANNELVALIDATOR_H\r\n\r\n#include <IPXACTmodels/ipxactmodels_global.h>\r\n\r\n#include <IPXACTmodels/Component/Channel.h>\r\n\r\n#include <QList>\r\n#include <QSharedPointer>\r\n#include <QString>\r\n#include <QVector>\r\n\r\nclass BusInterface;\r\nclass ExpressionParser;\r\n//-----------------------------------------------------------------------------\r\n//! Validator for ipxact:Channel.\r\n//-----------------------------------------------------------------------------\r\nclass IPXACTMODELS_EXPORT ChannelValidator\r\n{\r\npublic:\r\n\r\n\t/*!\r\n\t *  The constructor.\r\n\t *\r\n\t */\r\n    ChannelValidator(QSharedPointer<ExpressionParser> expressionParser,\r\n        QSharedPointer<QList<QSharedPointer<BusInterface> > > componentBusInterfaces);\r\n\r\n\t//! The destructor.\r\n\t~ChannelValidator() = default;\r\n\r\n    // Disable copying.\r\n    ChannelValidator(ChannelValidator const& rhs) = delete;\r\n    ChannelValidator& operator=(ChannelValidator const& rhs) = delete;\r\n\r\n    /*!\r\n     *  Change the available bus interfaces.\r\n     *\r\n     *    @param [in] newBusInterfaces    The new bus interfaces.\r\n     */\r\n    void componentChange(QSharedPointer<QList<QSharedPointer<BusInterface> > > newBusInterfaces);\r\n\r\n    /*!\r\n     *  Validates the given Channel.\r\n     *\r\n     *    @param [in] Channel           The Channel to validate.\r\n     *\r\n     *    @return True, if the Channel is valid IP-XACT, otherwise false.\r\n     */\r\n    bool validate(QSharedPointer<Channel> channel) const;\r\n\r\n    bool hasValidBusInterfaceReferences(QSharedPointer<Channel> channel) const;\r\n\r\n    /*!\r\n     *  Finds possible errors in a Channel and creates a list of them.\r\n     *\r\n     *    @param [in] errors      List of found errors.\r\n     *    @param [in] Channel   The Channel whose errors to find.\r\n     *    @param [in] context     Context to help locate the errors.\r\n     */\r\n    void findErrorsIn(QVector<QString>& errors, QSharedPointer<Channel> channel,\r\n\t\tQString const& context) const;\r\n\r\nprivate:\r\n\r\n    /*!\r\n     *  Check if the name is valid.\r\n     *\r\n     *    @param [in] name    The name to be evaluated.\r\n     *\r\n     *    @return True, if the name is valid, otherwise false.\r\n     */\r\n    bool hasValidName(QString const& name) const;\r\n    \r\n    /*!\r\n     *  Checks if the given name for referencing a bus interface is valid.\r\n     *\r\n     *    @param [in] interfaceName   The name of the bus interface to check.\r\n     *\r\n     *    @return True, if the reference is valid, otherwise false.\r\n     */\r\n    bool isValidBusIntefaceReference(QString const& interfaceName) const;\r\n        \r\n    /*!\r\n     *  Checks if the given name for referencing a bus interface is for a mirrored interface.\r\n     *\r\n     *    @param [in] interfaceName   The name of the bus interface to check.\r\n     *\r\n     *    @return True, if the reference is for a mirrored interface, otherwise false.\r\n     */ \r\n    bool isReferenceToMirroredInterface(QString const& interfaceName) const;\r\n\r\n    //! The bus interfaces of the containing component.\r\n    QSharedPointer<QList<QSharedPointer<BusInterface> > > busInterfaces_;\r\n\r\n    //! The expression parser to use.\r\n    QSharedPointer<ExpressionParser> expressionParser_;\r\n};\r\n\r\n#endif // CHANNELVALIDATOR_H\r\n"
  },
  {
    "path": "IPXACTmodels/Component/validators/CollectionValidators.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: CollectionValidators.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Anton Hagqvist\n// Date: 02.08.2024\n//\n// Description:\n// Validators for validating top-level items inside a component.\n//-----------------------------------------------------------------------------\n\n#include \"CollectionValidators.h\"\n\n#include <IPXACTmodels/Component/MemoryMap.h>\n#include <IPXACTmodels/Component/validators/MemoryMapValidator.h>\n\n#include <IPXACTmodels/Component/FileSet.h>\n#include <IPXACTmodels/Component/validators/FileSetValidator.h>\n\n#include <IPXACTmodels/Component/AddressSpace.h>\n#include <IPXACTmodels/Component/validators/AddressSpaceValidator.h>\n\n#include <IPXACTmodels/Component/View.h>\n#include <IPXACTmodels/Component/validators/ViewValidator.h>\n\n#include <IPXACTmodels/Component/Port.h>\n#include <IPXACTmodels/Component/validators/PortValidator.h>\n\n#include <IPXACTmodels/Component/BusInterface.h>\n#include <IPXACTmodels/Component/validators/BusInterfaceValidator.h>\n\n#include <IPXACTmodels/Component/IndirectInterface.h>\n#include <IPXACTmodels/Component/validators/IndirectInterfaceValidator.h>\n\n#include <IPXACTmodels/Component/Cpu.h>\n#include <IPXACTmodels/Component/validators/CPUValidator.h>\n\n#include <IPXACTmodels/Component/PowerDomain.h>\n#include <IPXACTmodels/Component/validators/PowerDomainValidator.h>\n\n#include <IPXACTmodels/Component/Component.h>\n#include <IPXACTmodels/Component/validators/InstantiationsValidator.h>\n\n//-----------------------------------------------------------------------------\n// Function: MemoryMapsValidator::MemoryMapsValidator()\n//-----------------------------------------------------------------------------\nMemoryMapsValidator::MemoryMapsValidator(QSharedPointer<MemoryMapValidator> mapValidator) : \n    HierarchicalValidator(),\n    memMapValidator_(mapValidator)\n{\n    setChildValidator(mapValidator);\n}\n\n//-----------------------------------------------------------------------------\n// Function: MemoryMapsValidator::validate()\n//-----------------------------------------------------------------------------\nbool MemoryMapsValidator::validate(MapList memoryMaps)\n{\n    if (auto memoryMapsAsNameGroup = CollectionValidators::itemListToNameGroupList(memoryMaps); \n        !childrenHaveUniqueNames(memoryMapsAsNameGroup))\n    {\n        return false;\n    }\n\n    for (auto const& child : *memoryMaps)\n    {\n        if (!memMapValidator_->validate(child))\n        {\n            return false;\n        }\n    }\n\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: FileSetsValidator::FileSetsValidator()\n//-----------------------------------------------------------------------------\nFileSetsValidator::FileSetsValidator(QSharedPointer<FileSetValidator> fileSetValidator):\n    HierarchicalValidator(),\n    fileSetValidator_(fileSetValidator)\n{\n    setChildValidator(fileSetValidator);\n}\n\n//-----------------------------------------------------------------------------\n// Function: FileSetsValidator::validate()\n//-----------------------------------------------------------------------------\nbool FileSetsValidator::validate(FileSetList fileSets)\n{\n    if (auto fileSetsAsNameGroup = CollectionValidators::itemListToNameGroupList(fileSets);\n        !childrenHaveUniqueNames(fileSetsAsNameGroup))\n    {\n        return false;\n    }\n\n    for (auto const& child : *fileSets)\n    {\n        if (!fileSetValidator_->validate(child))\n        {\n            return false;\n        }\n    }\n\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: AddressSpacesValidator::AddressSpacesValidator()\n//-----------------------------------------------------------------------------\nAddressSpacesValidator::AddressSpacesValidator(QSharedPointer<AddressSpaceValidator> addressSpaceValidator):\n    HierarchicalValidator(),\n    addressSpaceValidator_(addressSpaceValidator)\n{\n    setChildValidator(addressSpaceValidator);\n}\n\n//-----------------------------------------------------------------------------\n// Function: AddressSpacesValidator::validate()\n//-----------------------------------------------------------------------------\nbool AddressSpacesValidator::validate(AddressSpaceList addressSpaces)\n{\n    if (auto addressSpacesAsNameGroup = CollectionValidators::itemListToNameGroupList(addressSpaces);\n        !childrenHaveUniqueNames(addressSpacesAsNameGroup))\n    {\n        return false;\n    }\n\n    for (auto const& child : *addressSpaces)\n    {\n        if (!addressSpaceValidator_->validate(child))\n        {\n            return false;\n        }\n    }\n\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: AllInstantiationsValidator::AllInstantiationsValidator()\n//-----------------------------------------------------------------------------\nAllInstantiationsValidator::AllInstantiationsValidator(QSharedPointer<InstantiationsValidator> singleInstantiationValidator):\n    HierarchicalValidator(),\n    singleInstantiationValidator_(singleInstantiationValidator)\n{\n    setChildValidator(singleInstantiationValidator);\n}\n\n//-----------------------------------------------------------------------------\n// Function: AllInstantiationsValidator::validate()\n//-----------------------------------------------------------------------------\nbool AllInstantiationsValidator::validate(QSharedPointer<Component> component)\n{\n    auto instantiationsAsNameGroups = CollectionValidators::itemListToNameGroupList(component->getComponentInstantiations());\n    instantiationsAsNameGroups->append(*CollectionValidators::itemListToNameGroupList(component->getDesignInstantiations()));\n    instantiationsAsNameGroups->append(*CollectionValidators::itemListToNameGroupList(component->getDesignConfigurationInstantiations()));\n    if (!childrenHaveUniqueNames(instantiationsAsNameGroups))\n    {\n        return false;\n    }\n    \n    if (!hasValidComponentInstantiations(component) || !hasValidDesignConfigurationInstantiations(component) ||\n        !hasValidDesignInstantiations(component))\n    {\n        return false;\n    }\n\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: AllInstantiationsValidator::hasValidComponentInstantiations()\n//-----------------------------------------------------------------------------\nbool AllInstantiationsValidator::hasValidComponentInstantiations(QSharedPointer<Component> component) const\n{\n    for (auto const& componentInstantiation : *component->getComponentInstantiations())\n    {\n        if (!singleInstantiationValidator_->validateComponentInstantiation(componentInstantiation))\n        {\n            return false;\n        }\n    }\n\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: AllInstantiationsValidator::hasValidDesignConfigurationInstantiations()\n//-----------------------------------------------------------------------------\nbool AllInstantiationsValidator::hasValidDesignConfigurationInstantiations(QSharedPointer<Component> component) const\n{\n    for (auto const& designConfigInstantiation : *component->getDesignConfigurationInstantiations())\n    {\n        if (!singleInstantiationValidator_->validateDesignConfigurationInstantiation(designConfigInstantiation))\n        {\n            return false;\n        }\n    }\n\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: AllInstantiationsValidator::hasValidDesignInstantiations()\n//-----------------------------------------------------------------------------\nbool AllInstantiationsValidator::hasValidDesignInstantiations(QSharedPointer<Component> component) const\n{\n    for (auto const& designInstantiation : *component->getDesignInstantiations())\n    {\n        if (!singleInstantiationValidator_->validateDesignInstantiation(designInstantiation))\n        {\n            return false;\n        }\n    }\n\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: ViewsValidator::ViewsValidator()\n//-----------------------------------------------------------------------------\nViewsValidator::ViewsValidator(QSharedPointer<ViewValidator> viewValidator) : \n    HierarchicalValidator(),\n    viewValidator_(viewValidator)\n{\n    setChildValidator(viewValidator);\n}\n\n//-----------------------------------------------------------------------------\n// Function: ViewsValidator::validate()\n//-----------------------------------------------------------------------------\nbool ViewsValidator::validate(QSharedPointer<QList<QSharedPointer<View> > > views)\n{\n    if (auto viewsAsNameGroup = CollectionValidators::itemListToNameGroupList(views);\n        !childrenHaveUniqueNames(viewsAsNameGroup))\n    {\n        return false;\n    }\n\n    for (auto const& child : *views)\n    {\n        if (!viewValidator_->validate(child))\n        {\n            return false;\n        }\n    }\n\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortsValidator::PortsValidator()\n//-----------------------------------------------------------------------------\nPortsValidator::PortsValidator(QSharedPointer<PortValidator> portValidator):\n    HierarchicalValidator(),\n    portValidator_(portValidator)\n{\n    setChildValidator(portValidator);\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortsValidator::validate()\n//-----------------------------------------------------------------------------\nbool PortsValidator::validate(QSharedPointer<QList<QSharedPointer<Port> > > ports)\n{\n    if (auto portsAsNameGroup = CollectionValidators::itemListToNameGroupList(ports);\n        !childrenHaveUniqueNames(portsAsNameGroup))\n    {\n        return false;\n    }\n\n    for (auto const& child : *ports)\n    {\n        if (!portValidator_->validate(child))\n        {\n            return false;\n        }\n    }\n\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: BusInterfacesValidator::BusInterfacesValidator()\n//-----------------------------------------------------------------------------\nBusInterfacesValidator::BusInterfacesValidator(QSharedPointer<BusInterfaceValidator> busInterfaceValidator) :\n    HierarchicalValidator(),\n    busInterfaceValidator_(busInterfaceValidator)\n{\n    setChildValidator(busInterfaceValidator);\n}\n\n//-----------------------------------------------------------------------------\n// Function: BusInterfacesValidator::validate()\n//-----------------------------------------------------------------------------\nbool BusInterfacesValidator::validate(QSharedPointer<QList<QSharedPointer<BusInterface> > > interfaces,\n    Document::Revision docRevision)\n{\n    if (auto busInterfacesAsNameGroup = CollectionValidators::itemListToNameGroupList(interfaces);\n        !childrenHaveUniqueNames(busInterfacesAsNameGroup))\n    {\n        return false;\n    }\n\n    for (auto const& child : *interfaces)\n    {\n        if (!busInterfaceValidator_->validate(child, docRevision))\n        {\n            return false;\n        }\n    }\n\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: IndirectInterfacesValidator::IndirectInterfacesValidator()\n//-----------------------------------------------------------------------------\nIndirectInterfacesValidator::IndirectInterfacesValidator(QSharedPointer<IndirectInterfaceValidator> indirectInterfaceValidator) :\n    HierarchicalValidator(),\n    indirectInterfaceValidator_(indirectInterfaceValidator)\n{\n    setChildValidator(indirectInterfaceValidator);\n}\n\n//-----------------------------------------------------------------------------\n// Function: IndirectInterfacesValidator::validate()\n//-----------------------------------------------------------------------------\nbool IndirectInterfacesValidator::validate(QSharedPointer<QList<QSharedPointer<IndirectInterface> > > indirectInterfaces)\n{\n    if (auto indirectInterfacesAsNameGroup = CollectionValidators::itemListToNameGroupList(indirectInterfaces);\n        !childrenHaveUniqueNames(indirectInterfacesAsNameGroup))\n    {\n        return false;\n    }\n\n    for (auto const& child : *indirectInterfaces)\n    {\n        if (!indirectInterfaceValidator_->validate(child))\n        {\n            return false;\n        }\n    }\n\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: CPUsValidator::CPUsValidator()\n//-----------------------------------------------------------------------------\nCPUsValidator::CPUsValidator(QSharedPointer<CPUValidator> cpuValidator):\n    cpuValidator_(cpuValidator)\n{\n    setChildValidator(cpuValidator);\n}\n\n//-----------------------------------------------------------------------------\n// Function: CPUsValidator::validate()\n//-----------------------------------------------------------------------------\nbool CPUsValidator::validate(QSharedPointer<QList<QSharedPointer<Cpu> > > cpus)\n{\n    if (auto cpusAsNameGroup = CollectionValidators::itemListToNameGroupList(cpus);\n        !childrenHaveUniqueNames(cpusAsNameGroup))\n    {\n        return false;\n    }\n\n    for (auto const& child : *cpus)\n    {\n        if (!cpuValidator_->validate(child))\n        {\n            return false;\n        }\n    }\n\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PowerDomainsValidator::PowerDomainsValidator()\n//-----------------------------------------------------------------------------\nPowerDomainsValidator::PowerDomainsValidator(QSharedPointer<PowerDomainValidator> powerDomainValidator):\n    HierarchicalValidator(),\n    powerDomainValidator_(powerDomainValidator)\n{\n    setChildValidator(powerDomainValidator);\n}\n\n//-----------------------------------------------------------------------------\n// Function: PowerDomainsValidator::validate()\n//-----------------------------------------------------------------------------\nbool PowerDomainsValidator::validate(QSharedPointer<QList<QSharedPointer<PowerDomain> > > powerDomains)\n{\n    if (auto powerDomainsAsNameGroup = CollectionValidators::itemListToNameGroupList(powerDomains);\n        !childrenHaveUniqueNames(powerDomainsAsNameGroup))\n    {\n        return false;\n    }\n\n    for (auto const& child : *powerDomains)\n    {\n        if (!powerDomainValidator_->validate(child))\n        {\n            return false;\n        }\n    }\n\n    return true;\n}\n"
  },
  {
    "path": "IPXACTmodels/Component/validators/CollectionValidators.h",
    "content": "//-----------------------------------------------------------------------------\n// File: CollectionValidators.h\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Anton Hagqvist\n// Date: 01.08.2024\n//\n// Description:\n// Validators for validating top-level items inside a component.\n//-----------------------------------------------------------------------------\n\n#ifndef COLLECTIONVALIDATORS_H\n#define COLLECTIONVALIDATORS_H\n\n#include <QList>\n#include <QSharedPointer>\n\n#include <IPXACTmodels/ipxactmodels_global.h>\n\n#include <IPXACTmodels/common/Document.h>\n\n#include <IPXACTmodels/common/validators/HierarchicalValidator.h>\n\nnamespace CollectionValidators\n{\n    //-----------------------------------------------------------------------------\n    // Function: itemListToNameGroupList()\n    //-----------------------------------------------------------------------------\n    template <typename T> QSharedPointer<QList<QSharedPointer<NameGroup> > >\n    itemListToNameGroupList(QSharedPointer<QList<QSharedPointer<T> > > items)\n    {\n        QSharedPointer<QList<QSharedPointer<NameGroup> > >listWithNameGroups(new QList<QSharedPointer<NameGroup> >);\n        std::transform(items->begin(), items->end(), std::back_inserter(*listWithNameGroups), [](QSharedPointer<T> item)\n            {\n                return qSharedPointerCast<NameGroup>(item);\n            });\n        return listWithNameGroups;\n    }\n}\n\nclass MemoryMap;\nclass MemoryMapValidator;\n\n/*\n *  Validator for memory maps.\n */\nclass IPXACTMODELS_EXPORT MemoryMapsValidator : public HierarchicalValidator\n{\npublic:\n\n    using MapList = QSharedPointer<QList<QSharedPointer<MemoryMap> > >;\n\n    MemoryMapsValidator(QSharedPointer<MemoryMapValidator> mapValidator);\n    virtual ~MemoryMapsValidator() = default;\n\n    MemoryMapsValidator(MemoryMapsValidator& other) = delete;\n    MemoryMapsValidator& operator=(MemoryMapsValidator& other) = delete;\n\n    bool validate(MapList memoryMaps);\n\nprivate:\n\n    QSharedPointer<MemoryMapValidator> memMapValidator_;\n};\n\n\nclass FileSet;\nclass FileSetValidator;\n\n/*\n *  Validator for file sets.\n */\nclass IPXACTMODELS_EXPORT FileSetsValidator : public HierarchicalValidator\n{\npublic:\n\n    using FileSetList = QSharedPointer<QList<QSharedPointer<FileSet> > >;\n\n    explicit FileSetsValidator(QSharedPointer<FileSetValidator> fileSetValidator);\n    virtual ~FileSetsValidator() = default;\n\n    FileSetsValidator(FileSetsValidator& other) = delete;\n    FileSetsValidator& operator=(FileSetsValidator& other) = delete;\n\n    bool validate(FileSetList fileSets);\n\nprivate:\n\n    QSharedPointer<FileSetValidator> fileSetValidator_;\n};\n\n\nclass AddressSpace;\nclass AddressSpaceValidator;\n\n/*\n *  Validator for address spaces.\n */\nclass IPXACTMODELS_EXPORT AddressSpacesValidator : public HierarchicalValidator\n{\npublic:\n\n    using AddressSpaceList = QSharedPointer<QList<QSharedPointer<AddressSpace> > >;\n\n    explicit AddressSpacesValidator(QSharedPointer<AddressSpaceValidator> addressSpaceValidator );\n    virtual ~AddressSpacesValidator() = default;\n\n    AddressSpacesValidator(AddressSpacesValidator& other) = delete;\n    AddressSpacesValidator& operator=(AddressSpacesValidator& other) = delete;\n\n    bool validate(AddressSpaceList addressSpaces);\n\nprivate:\n\n    QSharedPointer<AddressSpaceValidator> addressSpaceValidator_;\n};\n\n\nclass InstantiationsValidator;\nclass Component;\n/*\n *  Validator for all instantiations.\n */\nclass IPXACTMODELS_EXPORT AllInstantiationsValidator: public HierarchicalValidator\n{\npublic:\n\n    explicit AllInstantiationsValidator(QSharedPointer<InstantiationsValidator> singleInstantiationValidator);\n    virtual ~AllInstantiationsValidator() = default;\n\n    AllInstantiationsValidator(AllInstantiationsValidator& other) = delete;\n    AllInstantiationsValidator& operator=(AllInstantiationsValidator& other) = delete;\n\n    bool validate(QSharedPointer<Component> component);\n\n    bool hasValidComponentInstantiations(QSharedPointer<Component> component) const;\n\n    bool hasValidDesignConfigurationInstantiations(QSharedPointer<Component> component) const;\n\n    bool hasValidDesignInstantiations(QSharedPointer<Component> component) const;\n\nprivate:\n\n    QSharedPointer<InstantiationsValidator> singleInstantiationValidator_;\n};\n\nclass View;\nclass ViewValidator;\n/*\n *  Validator for views.\n */\nclass IPXACTMODELS_EXPORT ViewsValidator : public HierarchicalValidator\n{\npublic:\n\n    explicit ViewsValidator(QSharedPointer<ViewValidator> viewValidator);\n    virtual ~ViewsValidator() = default;\n\n    ViewsValidator(ViewsValidator& other) = delete;\n    ViewsValidator& operator=(ViewsValidator& other) = delete;\n\n    bool validate(QSharedPointer<QList<QSharedPointer<View> > > views);\n\nprivate:\n\n    QSharedPointer<ViewValidator> viewValidator_;\n};\n\nclass Port;\nclass PortValidator;\n/*\n *  Validator for ports.\n */\nclass IPXACTMODELS_EXPORT PortsValidator: public HierarchicalValidator\n{\npublic:\n\n    explicit PortsValidator(QSharedPointer<PortValidator> portValidator);\n    virtual ~PortsValidator() = default;\n\n    PortsValidator(PortsValidator& other) = delete;\n    PortsValidator& operator=(PortsValidator& other) = delete;\n\n    bool validate(QSharedPointer<QList<QSharedPointer<Port> > > ports);\n\nprivate:\n\n    QSharedPointer<PortValidator> portValidator_;\n};\n\nclass BusInterface;\nclass BusInterfaceValidator;\n/*\n *  Validator for bus interfaces.\n */\nclass IPXACTMODELS_EXPORT BusInterfacesValidator : public HierarchicalValidator\n{\npublic:\n\n    explicit BusInterfacesValidator(QSharedPointer<BusInterfaceValidator> busInterfaceValidator);\n    virtual ~BusInterfacesValidator() = default;\n\n    BusInterfacesValidator(BusInterfacesValidator& other) = delete;\n    BusInterfacesValidator& operator=(BusInterfacesValidator& other) = delete;\n\n    bool validate(QSharedPointer<QList<QSharedPointer<BusInterface> > > interfaces, Document::Revision docRevision);\n\nprivate:\n\n    QSharedPointer<BusInterfaceValidator> busInterfaceValidator_;\n};\n\nclass IndirectInterface;\nclass IndirectInterfaceValidator;\n/*\n *  Validator for indirect interfaces.\n */\nclass IPXACTMODELS_EXPORT IndirectInterfacesValidator : public HierarchicalValidator\n{\npublic:\n\n    explicit IndirectInterfacesValidator(QSharedPointer<IndirectInterfaceValidator> indirectInterfaceValidator);\n    virtual ~IndirectInterfacesValidator() = default;\n\n    IndirectInterfacesValidator(IndirectInterfacesValidator& other) = delete;\n    IndirectInterfacesValidator& operator=(IndirectInterfacesValidator& other) = delete;\n\n    bool validate(QSharedPointer<QList<QSharedPointer<IndirectInterface> > > indirectInterfaces);\n\nprivate:\n\n    QSharedPointer<IndirectInterfaceValidator> indirectInterfaceValidator_;\n};\n\n\nclass Cpu;\nclass CPUValidator;\n/*\n *  Validator for modes.\n */\nclass IPXACTMODELS_EXPORT CPUsValidator: public HierarchicalValidator\n{\npublic:\n\n    explicit CPUsValidator(QSharedPointer<CPUValidator> cpuValidator);\n    virtual ~CPUsValidator() = default;\n\n    CPUsValidator(CPUsValidator& other) = delete;\n    CPUsValidator& operator=(CPUsValidator& other) = delete;\n\n    bool validate(QSharedPointer<QList<QSharedPointer<Cpu> > > cpus);\n\nprivate:\n\n    QSharedPointer<CPUValidator> cpuValidator_;\n};\n\n\nclass PowerDomain;\nclass PowerDomainValidator;\n/*\n *  Validator for modes.\n */\nclass IPXACTMODELS_EXPORT PowerDomainsValidator : public HierarchicalValidator\n{\npublic:\n\n    explicit PowerDomainsValidator(QSharedPointer<PowerDomainValidator> powerDomainValidator);\n    virtual ~PowerDomainsValidator() = default;\n\n    PowerDomainsValidator(PowerDomainsValidator& other) = delete;\n    PowerDomainsValidator& operator=(PowerDomainsValidator& other) = delete;\n\n    bool validate(QSharedPointer<QList<QSharedPointer<PowerDomain> > > powerDomains);\n\nprivate:\n\n    QSharedPointer<PowerDomainValidator> powerDomainValidator_;\n};\n\n#endif // COLLECTIONVALIDATORS_H\n"
  },
  {
    "path": "IPXACTmodels/Component/validators/ComponentGeneratorValidator.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ComponentGeneratorValidator.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 07.01.2016\r\n//\r\n// Description:\r\n// Validator for the component generator.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"ComponentGeneratorValidator.h\"\r\n\r\n#include <KactusAPI/include/ExpressionParser.h>\r\n\r\n#include <IPXACTmodels/Component/ComponentGenerator.h>\r\n\r\n#include <IPXACTmodels/common/validators/ParameterValidator.h>\r\n#include <IPXACTmodels/common/validators/CommonItemsValidator.h>\r\n\r\n#include <QRegularExpression>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentGeneratorValidator::ComponentGeneratorValidator()\r\n//-----------------------------------------------------------------------------\r\nComponentGeneratorValidator::ComponentGeneratorValidator(QSharedPointer<ExpressionParser> expressionParser,\r\n    QSharedPointer<ParameterValidator> parameterValidator):\r\nexpressionParser_(expressionParser),\r\nparameterValidator_(parameterValidator)\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentGeneratorValidator::validate()\r\n//-----------------------------------------------------------------------------\r\nbool ComponentGeneratorValidator::validate(QSharedPointer<ComponentGenerator> generator) const\r\n{\r\n    return hasValidName(generator) && hasValidPhase(generator) && hasValidGeneratorExe(generator);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentGeneratorValidator::hasValidName()\r\n//-----------------------------------------------------------------------------\r\nbool ComponentGeneratorValidator::hasValidName(QSharedPointer<ComponentGenerator> generator) const\r\n{\r\n    return CommonItemsValidator::hasValidName(generator->name());\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentGeneratorValidator::hasValidPhase()\r\n//-----------------------------------------------------------------------------\r\nbool ComponentGeneratorValidator::hasValidPhase(QSharedPointer<ComponentGenerator> generator) const\r\n{\r\n    if (!generator->getPhase().isEmpty())\r\n    {\r\n        bool valueToRealOk = true;\r\n        expressionParser_->parseExpression(generator->getPhase()).toDouble(&valueToRealOk);\r\n        \r\n        return valueToRealOk;\r\n    }\r\n\r\n    return true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentGeneratorValidator::hasValidGeneratorExe()\r\n//-----------------------------------------------------------------------------\r\nbool ComponentGeneratorValidator::hasValidGeneratorExe(QSharedPointer<ComponentGenerator> generator) const\r\n{\r\n    return !generator->getGeneratorExe().isEmpty();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentGeneratorValidator::findErrorsIn()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentGeneratorValidator::findErrorsIn(QStringList& errors,\r\n    QSharedPointer<ComponentGenerator> generator, QString const& context) const\r\n{\r\n    findErrorsInName(errors, generator, context);\r\n    findErrorsInPhase(errors, generator, context);\r\n    findErrorsInGeneratorExe(errors, generator, context);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentGeneratorValidator::findErrorsInName()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentGeneratorValidator::findErrorsInName(QStringList& errors,\r\n    QSharedPointer<ComponentGenerator> generator, QString const& context) const\r\n{\r\n    if (!hasValidName(generator))\r\n    {\r\n        errors.append(QObject::tr(\"Invalid name specified for component generator %1 within %2\").\r\n            arg(generator->name()).arg(context));\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentGeneratorValidator::findErrorsInPhase()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentGeneratorValidator::findErrorsInPhase(QStringList& errors,\r\n    QSharedPointer<ComponentGenerator> generator, QString const& context) const\r\n{\r\n    if (!hasValidPhase(generator))\r\n    {\r\n        errors.append(QObject::tr(\"Invalid phase value set for component generator '%1' within %2\")\r\n            .arg(generator->name()).arg(context));\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentGeneratorValidator::findErrorsInGeneratorExe()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentGeneratorValidator::findErrorsInGeneratorExe(QStringList& errors,\r\n    QSharedPointer<ComponentGenerator> generator, QString const& context) const\r\n{\r\n    if (!hasValidGeneratorExe(generator))\r\n    {\r\n        errors.append(QObject::tr(\"Invalid generator exe set for component generator '%1' within %2\")\r\n            .arg(generator->name()).arg(context));\r\n    }\r\n}"
  },
  {
    "path": "IPXACTmodels/Component/validators/ComponentGeneratorValidator.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ComponentGeneratorValidator.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 07.01.2016\r\n//\r\n// Description:\r\n// Validator for the component generator.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef COMPONENTGENERATORVALIDATOR_H\r\n#define COMPONENTGENERATORVALIDATOR_H\r\n\r\n#include <IPXACTmodels/ipxactmodels_global.h>\r\n\r\n#include <QSharedPointer>\r\n#include <QString>\r\n\r\nclass ExpressionParser;\r\nclass ComponentGenerator;\r\n\r\nclass ParameterValidator;\r\n//-----------------------------------------------------------------------------\r\n//! Validator for the base ipxact:componentGenerator.\r\n//-----------------------------------------------------------------------------\r\nclass IPXACTMODELS_EXPORT ComponentGeneratorValidator\r\n{\r\npublic:\r\n\r\n    /*!\r\n     *  The constructor.\r\n     *\r\n     *    @param [in] expressionParser    The parser used for solving expressions.\r\n     *    @param [in] parameterValidator  Validator used for parameters.\r\n     */\r\n    ComponentGeneratorValidator(QSharedPointer<ExpressionParser> expressionParser,\r\n        QSharedPointer<ParameterValidator> parameterValidator);\r\n\r\n    // Disable copying.\r\n    ComponentGeneratorValidator(ComponentGeneratorValidator const& rhs) = delete;\r\n    ComponentGeneratorValidator& operator=(ComponentGeneratorValidator const& rhs) = delete;\r\n\r\n\t//! The destructor.\r\n\t~ComponentGeneratorValidator() = default;\r\n    \r\n    /*!\r\n     *  Validates the given component generator.\r\n     *\r\n     *    @param [in] generator   The component generator to validate.\r\n     *\r\n     *    @return True, if the component generator is valid IP-XACT, otherwise false.\r\n     */\r\n    bool validate(QSharedPointer<ComponentGenerator> generator) const;\r\n\r\n    /*!\r\n     *  Check if the component generator contains a valid name.\r\n     *\r\n     *    @param [in] generator   The selected component generator.\r\n     *\r\n     *    @return True, if the name is valid, otherwise false.\r\n     */\r\n    bool hasValidName(QSharedPointer<ComponentGenerator> generator) const;\r\n\r\n    /*!\r\n     *  Check if the component generator contains a phase.\r\n     *\r\n     *    @param [in] generator   The selected component generator.\r\n     *\r\n     *    @return True, if the phase is valid, otherwise false.\r\n     */\r\n    bool hasValidPhase(QSharedPointer<ComponentGenerator> generator) const;\r\n\r\n    /*!\r\n     *  Check if the component generator contains a valid generator exe.\r\n     *\r\n     *    @param [in] generator   The selected component generator.\r\n     *\r\n     *    @return True, if the generator exe is valid, otherwise false.\r\n     */\r\n    bool hasValidGeneratorExe(QSharedPointer<ComponentGenerator> generator) const;\r\n\r\n    /*!\r\n     *  Locate errors within a component generator.\r\n     *\r\n     *    @param [in] errors      List of found errors.\r\n     *    @param [in] generator   The selected component generator.\r\n     *    @param [in] context     Context to help locate the error.\r\n     */\r\n    void findErrorsIn(QStringList& errors, QSharedPointer<ComponentGenerator> generator,\r\n        QString const& context) const;\r\n\r\nprivate:\r\n\r\n    /*!\r\n     *  Find errors in name.\r\n     *\r\n     *    @param [in] errors      List of found errors.\r\n     *    @param [in] generator   The selected component generator.\r\n     *    @param [in] context     Context to help locate the error.\r\n     */\r\n    void findErrorsInName(QStringList& errors, QSharedPointer<ComponentGenerator> generator,\r\n        QString const& context) const;\r\n\r\n    /*!\r\n     *  Find errors in phase.\r\n     *\r\n     *    @param [in] errors      List of found errors.\r\n     *    @param [in] generator   The selected component generator.\r\n     *    @param [in] context     Context to help locate the error.\r\n     */\r\n    void findErrorsInPhase(QStringList& errors, QSharedPointer<ComponentGenerator> generator,\r\n        QString const& context) const;\r\n\r\n    /*!\r\n     *  Find errors in generator exe.\r\n     *\r\n     *    @param [in] errors      List of found errors.\r\n     *    @param [in] generator   The selected component generator.\r\n     *    @param [in] context     Context to help locate the error.\r\n     */\r\n    void findErrorsInGeneratorExe(QStringList& errors, QSharedPointer<ComponentGenerator> generator,\r\n        QString const& context) const;\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! The used expression parser.\r\n    QSharedPointer<ExpressionParser> expressionParser_;\r\n\r\n    //! The used parameter validator.\r\n    QSharedPointer<ParameterValidator> parameterValidator_;\r\n};\r\n\r\n#endif // COMPONENTGENERATORVALIDATOR_H\r\n"
  },
  {
    "path": "IPXACTmodels/Component/validators/ComponentValidator.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ComponentValidator.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 14.12.2015\r\n//\r\n// Description:\r\n// Validator for the ipxact:component.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"ComponentValidator.h\"\r\n\r\n#include <KactusAPI/include/ExpressionParser.h>\r\n#include <KactusAPI/include/ModeConditionParserInterface.h>\r\n\r\n#include <IPXACTmodels/Component/Component.h>\r\n#include <IPXACTmodels/Component/BusInterface.h>\r\n#include <IPXACTmodels/Component/IndirectInterface.h>\r\n#include <IPXACTmodels/Component/RemapState.h>\r\n#include <IPXACTmodels/Component/AddressSpace.h>\r\n#include <IPXACTmodels/Component/MemoryMap.h>\r\n#include <IPXACTmodels/Component/View.h>\r\n#include <IPXACTmodels/Component/ComponentInstantiation.h>\r\n#include <IPXACTmodels/Component/DesignInstantiation.h>\r\n#include <IPXACTmodels/Component/DesignConfigurationInstantiation.h>\r\n#include <IPXACTmodels/Component/Port.h>\r\n#include <IPXACTmodels/Component/PowerDomain.h>\r\n#include <IPXACTmodels/Component/ComponentGenerator.h>\r\n#include <IPXACTmodels/common/Choice.h>\r\n#include <IPXACTmodels/Component/FileSet.h>\r\n#include <IPXACTmodels/Component/Cpu.h>\r\n#include <IPXACTmodels/Component/OtherClockDriver.h>\r\n#include <IPXACTmodels/Component/ResetType.h>\r\n\r\n#include <IPXACTmodels/common/validators/AssertionValidator.h>\r\n#include <IPXACTmodels/common/validators/ChoiceValidator.h>\r\n#include <IPXACTmodels/common/validators/ParameterValidator.h>\r\n\r\n#include <IPXACTmodels/Component/validators/BusInterfaceValidator.h>\r\n#include <IPXACTmodels/Component/validators/IndirectInterfaceValidator.h>\r\n#include <IPXACTmodels/Component/validators/PortMapValidator.h>\r\n#include <IPXACTmodels/Component/validators/ChannelValidator.h>\r\n#include <IPXACTmodels/Component/validators/RemapStateValidator.h>\r\n#include <IPXACTmodels/Component/validators/ModeValidator.h>\r\n#include <IPXACTmodels/Component/validators/AddressSpaceValidator.h>\r\n#include <IPXACTmodels/Component/validators/MemoryMapValidator.h>\r\n#include <IPXACTmodels/Component/validators/AddressBlockValidator.h>\r\n#include <IPXACTmodels/Component/validators/SubspaceMapValidator.h>\r\n#include <IPXACTmodels/Component/validators/RegisterValidator.h>\r\n#include <IPXACTmodels/Component/validators/RegisterFileValidator.h>\r\n#include <IPXACTmodels/Component/validators/FieldValidator.h>\r\n#include <IPXACTmodels/Component/validators/EnumeratedValueValidator.h>\r\n#include <IPXACTmodels/Component/validators/ViewValidator.h>\r\n#include <IPXACTmodels/Component/validators/InstantiationsValidator.h>\r\n#include <IPXACTmodels/Component/validators/PortValidator.h>\r\n#include <IPXACTmodels/Component/validators/PowerDomainValidator.h>\r\n#include <IPXACTmodels/Component/validators/ComponentGeneratorValidator.h>\r\n#include <IPXACTmodels/Component/validators/FileSetValidator.h>\r\n#include <IPXACTmodels/Component/validators/FileValidator.h>\r\n#include <IPXACTmodels/Component/validators/CPUValidator.h>\r\n#include <IPXACTmodels/Component/validators/OtherClockDriverValidator.h>\r\n#include <IPXACTmodels/common/Parameter.h>\r\n#include <IPXACTmodels/common/Assertion.h>\r\n\r\n#include <QRegularExpression>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentValidator::ComponentValidator()\r\n//-----------------------------------------------------------------------------\r\nComponentValidator::ComponentValidator(QSharedPointer<ExpressionParser> parser,\r\n    QSharedPointer<ModeConditionParserBaseInterface> modeConditionParserInterface,\r\n    LibraryInterface* library, Document::Revision docRevision) :\r\ncomponent_(),\r\nbusInterfaceValidator_(),\r\nindirectInterfaceValidator_(),\r\nchannelValidator_(),\r\nremapStateValidator_(),\r\nmodeValidator_(),\r\naddressSpaceValidator_(),\r\nmemoryMapValidator_(),\r\nviewValidator_(),\r\ninstantiationsValidator_(),\r\nportValidator_(),\r\ngeneratorValidator_(),\r\nchoiceValidator_(),\r\nfileSetValidator_(),\r\ncpuValidator_(),\r\notherClockDriverValidator_(),\r\nparameterValidator_(),\r\nassertionValidator_(),\r\nmodeConditionParserInterface_(modeConditionParserInterface)\r\n{\r\n    parameterValidator_ = QSharedPointer<ParameterValidator>(new ParameterValidator(parser,\r\n        QSharedPointer<QList<QSharedPointer<Choice> > > (), docRevision));\r\n\r\n    QSharedPointer<PortMapValidator> portMapvalidator(\r\n        new PortMapValidator(parser, QSharedPointer<QList<QSharedPointer<Port> > > (), library));\r\n\r\n    busInterfaceValidator_ = QSharedPointer<BusInterfaceValidator>(new BusInterfaceValidator(parser,\r\n        QSharedPointer<QList<QSharedPointer<Choice> > > (), QSharedPointer<QList<QSharedPointer<View> > > (),\r\n        QSharedPointer<QList<QSharedPointer<Port> > > (), QSharedPointer<QList<QSharedPointer<AddressSpace> > > (),\r\n        QSharedPointer<QList<QSharedPointer<MemoryMap> > > (),\r\n        QSharedPointer<QList<QSharedPointer<BusInterface> > > (),\r\n        QSharedPointer<QList<QSharedPointer<FileSet> > > (),\r\n        QSharedPointer<QList<QSharedPointer<RemapState> > > (), \r\n        nullptr,\r\n        portMapvalidator, parameterValidator_, library));\r\n\r\n    indirectInterfaceValidator_ = QSharedPointer<IndirectInterfaceValidator>(\r\n        new IndirectInterfaceValidator(component_, parser, parameterValidator_));\r\n\r\n    channelValidator_ = QSharedPointer<ChannelValidator>(\r\n        new ChannelValidator(parser, QSharedPointer<QList<QSharedPointer<BusInterface> > > ()));\r\n\r\n    remapStateValidator_ = QSharedPointer<RemapStateValidator>(\r\n        new RemapStateValidator(parser, QSharedPointer<QList<QSharedPointer<Port> > > ()));\r\n  \r\n    modeConditionParser_ = modeConditionParserInterface_->createParser();\r\n    modeValidator_ = QSharedPointer<ModeValidator>(new ModeValidator(component_, modeConditionParser_));\r\n\r\n    QSharedPointer<EnumeratedValueValidator> enumValidator (new EnumeratedValueValidator(parser));\r\n    QSharedPointer<FieldValidator> fieldValidator (new FieldValidator(parser, enumValidator, parameterValidator_, docRevision));\r\n    QSharedPointer<RegisterValidator> registerValidator (new RegisterValidator(parser, fieldValidator, parameterValidator_, docRevision));\r\n    QSharedPointer<RegisterFileValidator> registerFileValidator (new RegisterFileValidator(parser, registerValidator, parameterValidator_, docRevision));\r\n\r\n    QSharedPointer<AddressBlockValidator> addressBlockValidator(new AddressBlockValidator(\r\n        parser, registerValidator, registerFileValidator, parameterValidator_, docRevision));\r\n\r\n    QSharedPointer<SubspaceMapValidator> subspaceValidator(new SubspaceMapValidator(parser, parameterValidator_, docRevision));\r\n\r\n    QSharedPointer<MemoryMapBaseValidator> localMapValidator(new MemoryMapBaseValidator(\r\n        parser, addressBlockValidator, subspaceValidator));\r\n\r\n    addressSpaceValidator_ = QSharedPointer<AddressSpaceValidator>\r\n        (new AddressSpaceValidator(parser, localMapValidator, parameterValidator_));\r\n\r\n    memoryMapValidator_ = QSharedPointer<MemoryMapValidator>(new MemoryMapValidator(\r\n        parser, addressBlockValidator, subspaceValidator, QSharedPointer<Component>()));\r\n\r\n    viewValidator_ = QSharedPointer<ViewValidator>(new ViewValidator(parser, QSharedPointer<Model> ()));\r\n\r\n    instantiationsValidator_ = QSharedPointer<InstantiationsValidator>(new InstantiationsValidator(\r\n        parser, QSharedPointer<QList<QSharedPointer<FileSet> > > (), parameterValidator_, library));\r\n\r\n    portValidator_ =\r\n        QSharedPointer<PortValidator>(new PortValidator(parser, QSharedPointer<QList<QSharedPointer<View> > > ()));\r\n\r\n    generatorValidator_ =\r\n        QSharedPointer<ComponentGeneratorValidator>(new ComponentGeneratorValidator(parser, parameterValidator_));\r\n\r\n    choiceValidator_ = QSharedPointer<ChoiceValidator>(new ChoiceValidator(parser));\r\n\r\n    QSharedPointer<FileValidator> fileValidator (new FileValidator(parser));\r\n    fileSetValidator_ = QSharedPointer<FileSetValidator>(new FileSetValidator(fileValidator, parser));\r\n\r\n    cpuValidator_ = QSharedPointer<CPUValidator>(\r\n        new CPUValidator(parameterValidator_, parser, nullptr, nullptr, Document::Revision::Unknown));\r\n\r\n    otherClockDriverValidator_ = QSharedPointer<OtherClockDriverValidator>(new OtherClockDriverValidator(parser));\r\n\r\n    powerDomainValidator_ = QSharedPointer<PowerDomainValidator>(new PowerDomainValidator(nullptr,\r\n        parser, parameterValidator_));\r\n\r\n    assertionValidator_ = QSharedPointer<AssertionValidator>(new AssertionValidator(parser));\r\n\r\n    memoryMapsValidator_ = QSharedPointer<MemoryMapsValidator>(new MemoryMapsValidator(memoryMapValidator_));\r\n\r\n    fileSetsValidator_ = QSharedPointer<FileSetsValidator>(new FileSetsValidator(fileSetValidator_));\r\n\r\n    addressSpacesValidator_ = QSharedPointer<AddressSpacesValidator>(new AddressSpacesValidator(addressSpaceValidator_));\r\n\r\n    allInstantiationsValidator_ = QSharedPointer<AllInstantiationsValidator>(new AllInstantiationsValidator(instantiationsValidator_));\r\n\r\n    viewsValidator_ = QSharedPointer<ViewsValidator>(new ViewsValidator(viewValidator_));\r\n\r\n    portsValidator_ = QSharedPointer<PortsValidator>(new PortsValidator(portValidator_));\r\n\r\n    busIfsValidator_ = QSharedPointer<BusInterfacesValidator>(new BusInterfacesValidator(busInterfaceValidator_));\r\n\r\n    indirectInterfacesValidator_ = QSharedPointer<IndirectInterfacesValidator>(new IndirectInterfacesValidator(indirectInterfaceValidator_));\r\n\r\n    cpusValidator_ = QSharedPointer<CPUsValidator>(new CPUsValidator(cpuValidator_));\r\n\r\n    powerDomainsValidator_ = QSharedPointer<PowerDomainsValidator>(new PowerDomainsValidator(powerDomainValidator_));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: OtherClockDriverValidator::validate()\r\n//-----------------------------------------------------------------------------\r\nbool ComponentValidator::validate(QSharedPointer<Component> component)\r\n{\r\n    changeComponent(component);\r\n\r\n    return hasValidVLNV(component) && hasValidBusInterfaces(component) && \r\n        hasValidIndirectInterfaces(component) && hasValidChannels(component) &&\r\n        hasValidRemapStates(component) && hasValidModes(component) &&\r\n        hasValidAddressSpaces(component) && hasValidMemoryMaps(component) &&\r\n        hasValidViews(component) && hasValidInstantiations(component) &&\r\n        hasValidPorts(component) && hasValidComponentGenerators(component) && hasValidChoices(component) &&\r\n        hasValidFileSets(component) && hasValidCPUs(component) && hasValidOtherClockDrivers(component) &&\r\n        hasValidPowerDomains(component) &&\r\n        hasValidResetTypes(component) && hasValidParameters(component) && hasValidAssertions(component);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentValidator::hasValidVLNV()\r\n//-----------------------------------------------------------------------------\r\nbool ComponentValidator::hasValidVLNV(QSharedPointer<Component> component) const\r\n{\r\n    return component->getVlnv().getType() == VLNV::COMPONENT && component->getVlnv().isValid();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentValidator::hasValidBusInterfaces()\r\n//-----------------------------------------------------------------------------\r\nbool ComponentValidator::hasValidBusInterfaces(QSharedPointer<Component> component)\r\n{\r\n    changeComponent(component);\r\n    return busIfsValidator_->validate(component->getBusInterfaces(), component->getRevision());\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentValidator::hasValidIndirectInterfaces()\r\n//-----------------------------------------------------------------------------\r\nbool ComponentValidator::hasValidIndirectInterfaces(QSharedPointer<Component> component)\r\n{\r\n    changeComponent(component);\r\n    return indirectInterfacesValidator_->validate(component->getIndirectInterfaces());\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentValidator::hasValidChannels()\r\n//-----------------------------------------------------------------------------\r\nbool ComponentValidator::hasValidChannels(QSharedPointer<Component> component)\r\n{\r\n    changeComponent(component);\r\n\r\n    if (!component->getChannels()->isEmpty())\r\n    {\r\n        QVector<QString> channelNames;\r\n        QVector<QString> interfaceNames;\r\n        for (QSharedPointer<Channel> channel : *component->getChannels())\r\n        {\r\n            if (channelNames.contains(channel->name()) || !channelValidator_->validate(channel))\r\n            {\r\n                return false;\r\n            }\r\n            else\r\n            {\r\n                channelNames.append(channel->name());\r\n                for (auto const& busInterface : *channel->getInterfaces())\r\n                {\r\n                    if (interfaceNames.contains(busInterface->localName_))\r\n                    {\r\n                        return false;\r\n                    }\r\n                                    \r\n                    interfaceNames.append(busInterface->localName_);\r\n                }\r\n            }\r\n        }\r\n    }\r\n\r\n    return true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentValidator::hasValidRemapStates()\r\n//-----------------------------------------------------------------------------\r\nbool ComponentValidator::hasValidRemapStates(QSharedPointer<Component> component)\r\n{\r\n    changeComponent(component);\r\n\r\n    if (!component->getRemapStates()->isEmpty())\r\n    {\r\n        QVector<QString> stateNames;\r\n        for (QSharedPointer<RemapState> remapState : *component->getRemapStates())\r\n        {\r\n            if (stateNames.contains(remapState->name()) || !remapStateValidator_->validate(remapState))\r\n            {\r\n                return false;\r\n            }\r\n            else\r\n            {\r\n                stateNames.append(remapState->name());\r\n            }\r\n        }\r\n    }\r\n\r\n    return true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentValidator::hasValidModes()\r\n//-----------------------------------------------------------------------------\r\nbool ComponentValidator::hasValidModes(QSharedPointer<Component> component)\r\n{\r\n    changeComponent(component);\r\n\r\n    modeConditionParserInterface_->setModes(modeConditionParser_, component->getModes());\r\n\r\n    QSet<QString> modeNames;\r\n    for (QSharedPointer<Mode> mode : *component->getModes())\r\n    {\r\n        modeConditionParserInterface_->setFieldSlices(modeConditionParser_, mode->getFieldSlices());\r\n        modeConditionParserInterface_->setPortSlices(modeConditionParser_, mode->getPortSlices());\r\n\r\n        if (modeNames.contains(mode->name()) || !modeValidator_->validate(mode))\r\n        {\r\n            return false;\r\n        }\r\n\r\n        modeNames.insert(mode->name());\r\n    }\r\n\r\n    return true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentValidator::hasValidAddressSpaces()\r\n//-----------------------------------------------------------------------------\r\nbool ComponentValidator::hasValidAddressSpaces(QSharedPointer<Component> component)\r\n{\r\n    changeComponent(component);\r\n    return addressSpacesValidator_->validate(component->getAddressSpaces());\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentValidator::hasValidMemoryMaps()\r\n//-----------------------------------------------------------------------------\r\nbool ComponentValidator::hasValidMemoryMaps(QSharedPointer<Component> component)\r\n{\r\n    changeComponent(component);\r\n    return memoryMapsValidator_->validate(component->getMemoryMaps());\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentValidator::hasValidViews()\r\n//-----------------------------------------------------------------------------\r\nbool ComponentValidator::hasValidViews(QSharedPointer<Component> component)\r\n{\r\n    changeComponent(component);\r\n    return viewsValidator_->validate(component->getViews());\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentValidator::hasValidInstantiations()\r\n//-----------------------------------------------------------------------------\r\nbool ComponentValidator::hasValidInstantiations(QSharedPointer<Component> component)\r\n{\r\n    changeComponent(component);\r\n    return allInstantiationsValidator_->validate(component);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentValidator::hasValidPorts()\r\n//-----------------------------------------------------------------------------\r\nbool ComponentValidator::hasValidPorts(QSharedPointer<Component> component)\r\n{\r\n    changeComponent(component);\r\n    return portsValidator_->validate(component->getPorts());\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentValidator::hasValidComponentGenerators()\r\n//-----------------------------------------------------------------------------\r\nbool ComponentValidator::hasValidComponentGenerators(QSharedPointer<Component> component)\r\n{\r\n    changeComponent(component);\r\n\r\n    if (!component->getComponentGenerators()->isEmpty())\r\n    {\r\n        QVector<QString> generatorNames;\r\n        for (QSharedPointer<ComponentGenerator> generator : *component->getComponentGenerators())\r\n        {\r\n            if (generatorNames.contains(generator->name()) || !generatorValidator_->validate(generator))\r\n            {\r\n                return false;\r\n            }\r\n            else\r\n            {\r\n                generatorNames.append(generator->name());\r\n            }\r\n        }\r\n    }\r\n\r\n    return true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentValidator::hasValidChoices()\r\n//-----------------------------------------------------------------------------\r\nbool ComponentValidator::hasValidChoices(QSharedPointer<Component> component)\r\n{\r\n    changeComponent(component);\r\n\r\n    if (!component->getChoices()->isEmpty())\r\n    {\r\n        QVector<QString> choiceNames;\r\n        for (QSharedPointer<Choice> choice : *component->getChoices())\r\n        {\r\n            if (choiceNames.contains(choice->name()) || !choiceValidator_->validate(choice))\r\n            {\r\n                return false;\r\n            }\r\n            else\r\n            {\r\n                choiceNames.append(choice->name());\r\n            }\r\n        }\r\n    }\r\n    return true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentValidator::hasValidFileSets()\r\n//-----------------------------------------------------------------------------\r\nbool ComponentValidator::hasValidFileSets(QSharedPointer<Component> component)\r\n{\r\n    changeComponent(component);\r\n    return fileSetsValidator_->validate(component->getFileSets());\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentValidator::hasValidCPUs()\r\n//-----------------------------------------------------------------------------\r\nbool ComponentValidator::hasValidCPUs(QSharedPointer<Component> component)\r\n{\r\n    changeComponent(component);\r\n    return cpusValidator_->validate(component->getCpus());\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentValidator::hasValidOtherClockDrivers()\r\n//-----------------------------------------------------------------------------\r\nbool ComponentValidator::hasValidOtherClockDrivers(QSharedPointer<Component> component)\r\n{\r\n    changeComponent(component);\r\n\r\n    if (!component->getOtherClockDrivers()->isEmpty())\r\n    {\r\n        QVector<QString> driverNames;\r\n        for (QSharedPointer<OtherClockDriver> otherClockDriver : *component->getOtherClockDrivers())\r\n        {\r\n            if (driverNames.contains(otherClockDriver->getClockName()) ||\r\n                !otherClockDriverValidator_->validate(otherClockDriver))\r\n            {\r\n                return false;\r\n            }\r\n            else\r\n            {\r\n                driverNames.append(otherClockDriver->getClockName());\r\n            }\r\n        }\r\n    }\r\n    return true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentValidator::hasValidPowerDomains()\r\n//-----------------------------------------------------------------------------\r\nbool ComponentValidator::hasValidPowerDomains(QSharedPointer<Component> component)\r\n{\r\n    changeComponent(component);\r\n    return powerDomainsValidator_->validate(component->getPowerDomains());\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentValidator::hasValidResetTypes()\r\n//-----------------------------------------------------------------------------\r\nbool ComponentValidator::hasValidResetTypes(QSharedPointer<Component> component)\r\n{\r\n    if (!component->getResetTypes()->isEmpty())\r\n    {\r\n        for(QSharedPointer<ResetType> resetType : *component->getResetTypes())\r\n        {\r\n            if (!singleResetTypeIsValid(resetType, component->getResetTypes()))\r\n            {\r\n                return false;\r\n            }\r\n        }\r\n    }\r\n\r\n    return true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentValidator::singleResetTypeIsValid()\r\n//-----------------------------------------------------------------------------\r\nbool ComponentValidator::singleResetTypeIsValid(QSharedPointer<ResetType> resetType,\r\n    QSharedPointer<QList<QSharedPointer<ResetType> > > resetTypes) const\r\n{\r\n    QString currentName = resetType->name();\r\n    if (currentName.isEmpty() || currentName.toUpper().compare(QLatin1String(\"HARD\")) == 0)\r\n    {\r\n        return false;\r\n    }\r\n\r\n    for(QSharedPointer<ResetType> comparisonReset : *resetTypes)\r\n    {\r\n        if (resetType != comparisonReset && currentName == comparisonReset->name())\r\n        {\r\n            return false;\r\n        }\r\n    }\r\n\r\n    return true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentValidator::hasValidParameters()\r\n//-----------------------------------------------------------------------------\r\nbool ComponentValidator::hasValidParameters(QSharedPointer<Component> component)\r\n{\r\n    changeComponent(component);\r\n\r\n    if (!component->getParameters()->isEmpty())\r\n    {\r\n        QVector<QString> parameterNames;\r\n        for (QSharedPointer<Parameter> parameter : *component->getParameters())\r\n        {\r\n            if (parameterNames.contains(parameter->name()) || !parameterValidator_->validate(parameter))\r\n            {\r\n                return false;\r\n            }\r\n            else\r\n            {\r\n                parameterNames.append(parameter->name());\r\n            }\r\n        }\r\n    }\r\n    return true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentValidator::hasValidAssertions()\r\n//-----------------------------------------------------------------------------\r\nbool ComponentValidator::hasValidAssertions(QSharedPointer<Component> component)\r\n{\r\n    changeComponent(component);\r\n\r\n    if (!component->getAssertions()->isEmpty())\r\n    {\r\n        QVector<QString> assertionNames;\r\n        for (QSharedPointer<Assertion> assertion : *component->getAssertions())\r\n        {\r\n            if (assertionNames.contains(assertion->name()) || !assertionValidator_->validate(assertion))\r\n            {\r\n                return false;\r\n            }\r\n            else\r\n            {\r\n                assertionNames.append(assertion->name());\r\n            }\r\n        }\r\n    }\r\n\r\n    return true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentValidator::findErrorsIn()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentValidator::findErrorsIn(QVector<QString>& errors, QSharedPointer<Component> component)\r\n{\r\n    changeComponent(component);\r\n\r\n    QString context = QObject::tr(\"component %1\").arg(component->getVlnv().toString());\r\n\r\n    findErrorsInVLNV(errors, component);\r\n    findErrorsInBusInterface(errors, component, context);\r\n    findErrorsInIndirectInterfaces(errors, component, context);\r\n    findErrorsInChannels(errors, component, context);\r\n    findErrorsInRemapStates(errors, component, context);\r\n    findErrorsInModes(errors, component, context);\r\n    findErrorsInAddressSpaces(errors, component, context);\r\n    findErrorsInMemoryMaps(errors, component, context);\r\n    findErrorsInViews(errors, component, context);\r\n    findErrorsInComponentInstantiations(errors, component, context);\r\n    findErrorsInDesignInstantiations(errors, component, context);\r\n    findErrorsInDesignConfigurationInstantiations(errors, component, context);\r\n    findErrorsInPorts(errors, component, context);\r\n    findErrorsInComponentGenerators(errors, component, context);\r\n    findErrorsInChoices(errors, component, context);\r\n    findErrorsInFileSets(errors, component, context);\r\n    findErrorsInCPUs(errors, component, context);\r\n    findErrorsInOtherClockDrivers(errors, component, context);\r\n    findErrorsInPowerDomains(errors, component, context);\r\n    findErrorsInResetTypes(errors, component, context);\r\n    findErrorsInParameters(errors, component, context);\r\n    findErrorsInAssertions(errors, component, context);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentValidator::findErrorsInVLNV()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentValidator::findErrorsInVLNV(QVector<QString>& errors, QSharedPointer<Component> component) const\r\n{\r\n    component->getVlnv().isValid(errors, QLatin1String(\"component\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentValidator::findErrorsInBusInterface()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentValidator::findErrorsInBusInterface(QVector<QString>& errors, QSharedPointer<Component> component,\r\n    QString const& context) const\r\n{\r\n    if (!component->getBusInterfaces()->isEmpty())\r\n    {\r\n        QVector<QString> busInterfaceNames;\r\n        QVector<QString> duplicateNames;\r\n        for (QSharedPointer<BusInterface> bus : *component->getBusInterfaces())\r\n        {\r\n            if (busInterfaceNames.contains(bus->name()) && !duplicateNames.contains(bus->name()))\r\n            {\r\n                errors.append(QObject::tr(\"Bus interface name %1 within %2 is not unique.\")\r\n                    .arg(bus->name()).arg(context));\r\n                duplicateNames.append(bus->name());\r\n            }\r\n\r\n            busInterfaceNames.append(bus->name());\r\n            busInterfaceValidator_->findErrorsIn(errors, bus, context, component->getRevision());\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentValidator::findErrorsInIndirectInterfaces()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentValidator::findErrorsInIndirectInterfaces(QVector<QString>& errors, QSharedPointer<Component> component, QString const& context)\r\n{\r\n    QVector<QString> interfaceNames;\r\n    QVector<QString> duplicateNames;\r\n    for (QSharedPointer<IndirectInterface> indirectInterface : *component->getIndirectInterfaces())\r\n    {\r\n        if (interfaceNames.contains(indirectInterface->name()) && !duplicateNames.contains(indirectInterface->name()))\r\n        {\r\n            errors.append(QObject::tr(\"Indirect interface name '%1' within %2 is not unique.\").arg(\r\n                indirectInterface->name()).arg(context));\r\n            duplicateNames.append(indirectInterface->name());\r\n        }\r\n\r\n        interfaceNames.append(indirectInterface->name());\r\n        indirectInterfaceValidator_->findErrorsIn(errors, indirectInterface, context);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentValidator::findErrorsInChannels()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentValidator::findErrorsInChannels(QVector<QString>& errors, QSharedPointer<Component> component,\r\n    QString const& context) const\r\n{\r\n    if (!component->getChannels()->isEmpty())\r\n    {\r\n        QVector<QString> channelNames;\r\n        QVector<QString> duplicateChannelNames;\r\n\r\n        QVector<QString> interfaceNames;\r\n        QVector<QString> duplicateInterfaceNames;\r\n        for(QSharedPointer<Channel> channel : *component->getChannels())\r\n        {\r\n            if (channelNames.contains(channel->name()) && !duplicateChannelNames.contains(channel->name()))\r\n            {\r\n                errors.append(QObject::tr(\"Channel name '%1' within %2 is not unique.\")\r\n                    .arg(channel->name()).arg(context));\r\n                duplicateChannelNames.append(channel->name());\r\n            }\r\n\r\n            channelNames.append(channel->name());\r\n            channelValidator_->findErrorsIn(errors, channel, context);\r\n\r\n            for (auto const& busInterface : *channel->getInterfaces())\r\n            {\r\n                if (interfaceNames.contains(busInterface->localName_) && !duplicateInterfaceNames.contains(busInterface->localName_))\r\n                {\r\n                    errors.append(QObject::tr(\"Bus interface '%1' is not unique in channels within %2.\")\r\n                        .arg(busInterface->localName_).arg(context));\r\n                    duplicateInterfaceNames.append(busInterface->localName_);\r\n                }\r\n\r\n                interfaceNames.append(busInterface->localName_);\r\n            }\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentValidator::findErrorsInRemapStates()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentValidator::findErrorsInRemapStates(QVector<QString>& errors, QSharedPointer<Component> component,\r\n    QString const& context) const\r\n{\r\n    if (!component->getRemapStates()->isEmpty())\r\n    {\r\n        QVector<QString> stateNames;\r\n        QVector<QString> duplicateNames;\r\n        for (QSharedPointer<RemapState> remapState : *component->getRemapStates())\r\n        {\r\n            if (stateNames.contains(remapState->name()) && !duplicateNames.contains(remapState->name()))\r\n            {\r\n                errors.append(QObject::tr(\"Remap state name %1 within %2 is not unique.\")\r\n                    .arg(remapState->name()).arg(context));\r\n                duplicateNames.append(remapState->name());\r\n            }\r\n\r\n            stateNames.append(remapState->name());\r\n            remapStateValidator_->findErrorsIn(errors, remapState, context);\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentValidator::findErrorsInModes()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentValidator::findErrorsInModes(QVector<QString>& errors, QSharedPointer<Component> component,\r\n    QString const& context) const\r\n{\r\n    QStringList modeNames;\r\n    QStringList duplicateNames;\r\n    modeConditionParserInterface_->setModes(modeConditionParser_, component->getModes());\r\n\r\n    for (auto const& mode : *component->getModes())\r\n    {\r\n        modeConditionParserInterface_->setFieldSlices(modeConditionParser_, mode->getFieldSlices());\r\n        modeConditionParserInterface_->setPortSlices(modeConditionParser_, mode->getPortSlices());\r\n\r\n        if (modeNames.contains(mode->name()) && !duplicateNames.contains(mode->name()))\r\n        {\r\n            errors.append(QObject::tr(\"Mode name %1 within %2 is not unique.\")\r\n                .arg(mode->name()).arg(context));\r\n            duplicateNames.append(mode->name());\r\n        }\r\n\r\n        modeNames.append(mode->name());\r\n        modeValidator_->findErrorsIn(errors, mode, context);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentValidator::findErrorsInAddressSpaces()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentValidator::findErrorsInAddressSpaces(QVector<QString>& errors, QSharedPointer<Component> component,\r\n    QString const& context) const\r\n{\r\n    if (!component->getAddressSpaces()->isEmpty())\r\n    {\r\n        QVector<QString> spaceNames;\r\n        QVector<QString> duplicateNames;\r\n        for (QSharedPointer<AddressSpace> addressSpace : *component->getAddressSpaces())\r\n        {\r\n            if (spaceNames.contains(addressSpace->name()) && !duplicateNames.contains(addressSpace->name()))\r\n            {\r\n                errors.append(QObject::tr(\"Address space name %1 within %2 is not unique.\")\r\n                    .arg(addressSpace->name()).arg(context));\r\n                duplicateNames.append(addressSpace->name());\r\n            }\r\n\r\n            spaceNames.append(addressSpace->name());\r\n            addressSpaceValidator_->findErrorsIn(errors, addressSpace, context);\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentValidator::findErrorsInMemoryMaps()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentValidator::findErrorsInMemoryMaps(QVector<QString>& errors, QSharedPointer<Component> component,\r\n    QString const& context) const\r\n{\r\n    if (!component->getMemoryMaps()->isEmpty())\r\n    {\r\n        QVector<QString> mapNames;\r\n        QVector<QString> duplicateNames;\r\n        for (QSharedPointer<MemoryMap> memoryMap : *component->getMemoryMaps())\r\n        {\r\n            if (mapNames.contains(memoryMap->name()) && !duplicateNames.contains(memoryMap->name()))\r\n            {\r\n                errors.append(QObject::tr(\"Memory map name %1 within %2 is not unique.\")\r\n                    .arg(memoryMap->name()).arg(context));\r\n                duplicateNames.append(memoryMap->name());\r\n            }\r\n\r\n            mapNames.append(memoryMap->name());\r\n            memoryMapValidator_->findErrorsIn(errors, memoryMap, context);\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentValidator::findErrorsInViews()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentValidator::findErrorsInViews(QVector<QString>& errors, QSharedPointer<Component> component,\r\n    QString const& context) const\r\n{\r\n    if (!component->getViews()->isEmpty())\r\n    {\r\n        QVector<QString> viewNames;\r\n        QVector<QString> duplicateNames;\r\n        for (QSharedPointer<View> view : *component->getViews())\r\n        {\r\n            if (viewNames.contains(view->name()) && !duplicateNames.contains(view->name()))\r\n            {\r\n                errors.append(QObject::tr(\"View name %1 within %2 is not unique.\").arg(view->name()).arg(context));\r\n                duplicateNames.append(view->name());\r\n            }\r\n            \r\n            viewNames.append(view->name());\r\n            viewValidator_->findErrorsIn(errors, view, context);\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentValidator::findErrorsInComponentInstantiations()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentValidator::findErrorsInComponentInstantiations(QVector<QString>& errors,\r\n    QSharedPointer<Component> component, QString const& context) const\r\n{\r\n    if (!component->getComponentInstantiations()->isEmpty())\r\n    {\r\n        QVector<QString> instantiationNames;\r\n        QVector<QString> duplicateNames;\r\n        for (QSharedPointer<ComponentInstantiation> instantiation : *component->getComponentInstantiations())\r\n        {\r\n            if (instantiationNames.contains(instantiation->name()) &&\r\n                !duplicateNames.contains(instantiation->name()))\r\n            {\r\n                errors.append(QObject::tr(\"Component instantiation name %1 within %2 is not unique.\")\r\n                    .arg(instantiation->name()).arg(context));\r\n                duplicateNames.append(instantiation->name());\r\n            }\r\n\r\n            instantiationNames.append(instantiation->name());\r\n            instantiationsValidator_->findErrorsInComponentInstantiation(errors, instantiation, context,\r\n                component->getRevision());\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentValidator::findErrorsInDesignInstantiations()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentValidator::findErrorsInDesignInstantiations(QVector<QString>& errors,\r\n    QSharedPointer<Component> component, QString const& context) const\r\n{\r\n    if (!component->getDesignInstantiations()->isEmpty())\r\n    {\r\n        QVector<QString> instantiationNames;\r\n        QVector<QString> duplicateNames;\r\n        for (QSharedPointer<DesignInstantiation> instantiation : *component->getDesignInstantiations())\r\n        {\r\n            if (instantiationNames.contains(instantiation->name()) &&\r\n                !duplicateNames.contains(instantiation->name()))\r\n            {\r\n                errors.append(QObject::tr(\"Design instantiation name %1 within %2 is not unique.\")\r\n                    .arg(instantiation->name()).arg(context));\r\n                duplicateNames.append(instantiation->name());\r\n            }\r\n\r\n            instantiationNames.append(instantiation->name());\r\n            instantiationsValidator_->findErrorsInDesignInstantiation(errors, instantiation, context);\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentValidator::findErrorsInDesignConfigurationInstantiations()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentValidator::findErrorsInDesignConfigurationInstantiations(QVector<QString>& errors,\r\n    QSharedPointer<Component> component, QString const& context) const\r\n{\r\n    if (!component->getDesignConfigurationInstantiations()->isEmpty())\r\n    {\r\n        QVector<QString> instantiationNames;\r\n        QVector<QString> duplicateNames;\r\n        for (QSharedPointer<DesignConfigurationInstantiation> instantiation :\r\n            *component->getDesignConfigurationInstantiations())\r\n        {\r\n            if (instantiationNames.contains(instantiation->name()) &&\r\n                !duplicateNames.contains(instantiation->name()))\r\n            {\r\n                errors.append(QObject::tr(\"Design configuration instantiation name %1 within %2 is not unique.\")\r\n                    .arg(instantiation->name()).arg(context));\r\n                duplicateNames.append(instantiation->name());\r\n            }\r\n\r\n            instantiationNames.append(instantiation->name());\r\n            instantiationsValidator_->findErrorsInDesignConfigurationInstantiation(errors, instantiation, context);\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentValidator::findErrorsInPorts()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentValidator::findErrorsInPorts(QVector<QString>& errors, QSharedPointer<Component> component,\r\n    QString const& context) const\r\n{\r\n    if (!component->getPorts()->isEmpty())\r\n    {\r\n        QVector<QString> portNames;\r\n        QVector<QString> duplicateNames;\r\n        for (QSharedPointer<Port> port : *component->getPorts())\r\n        {\r\n            if (portNames.contains(port->name()) && !duplicateNames.contains(port->name()))\r\n            {\r\n                errors.append(QObject::tr(\"Port name %1 within %2 is not unique.\").arg(port->name()).arg(context));\r\n                duplicateNames.append(port->name());\r\n            }\r\n\r\n            portNames.append(port->name());\r\n            portValidator_->findErrorsIn(errors, port, context);\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentValidator::findErrorsInComponentGenerators()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentValidator::findErrorsInComponentGenerators(QVector<QString>& errors,\r\n    QSharedPointer<Component> component, QString const& context) const\r\n{\r\n    if (!component->getComponentGenerators()->isEmpty())\r\n    {\r\n        QVector<QString> generatorNames;\r\n        QVector<QString> duplicateNames;\r\n        for (QSharedPointer<ComponentGenerator> generator : *component->getComponentGenerators())\r\n        {\r\n            if (generatorNames.contains(generator->name()) && !duplicateNames.contains(generator->name()))\r\n            {\r\n                errors.append(QObject::tr(\"Component generator name '%1' within %2 is not unique.\")\r\n                    .arg(generator->name()).arg(context));\r\n                duplicateNames.append(generator->name());\r\n            }\r\n\r\n            generatorNames.append(generator->name());\r\n            generatorValidator_->findErrorsIn(errors, generator, context);\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentValidator::findErrorsInChoices()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentValidator::findErrorsInChoices(QVector<QString>& errors, QSharedPointer<Component> component,\r\n    QString const& context) const\r\n{\r\n    if (!component->getChoices()->isEmpty())\r\n    {\r\n        QVector<QString> choiceNames;\r\n        QVector<QString> duplicateNames;\r\n        for (QSharedPointer<Choice> choice : *component->getChoices())\r\n        {\r\n            if (choiceNames.contains(choice->name()) && !duplicateNames.contains(choice->name()))\r\n            {\r\n                errors.append(QObject::tr(\"Choice name %1 within %2 is not unique.\")\r\n                    .arg(choice->name()).arg(context));\r\n                duplicateNames.append(choice->name());\r\n            }\r\n\r\n            choiceNames.append(choice->name());\r\n            choiceValidator_->findErrorsIn(errors, choice, context);\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentValidator::findErrorsInFileSets()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentValidator::findErrorsInFileSets(QVector<QString>& errors, QSharedPointer<Component> component,\r\n    QString const& context) const\r\n{\r\n    if (!component->getFileSets()->isEmpty())\r\n    {\r\n        QVector<QString> fileSetNames;\r\n        QVector<QString> duplicateNames;\r\n        for (QSharedPointer<FileSet> fileSet : *component->getFileSets())\r\n        {\r\n            if (fileSetNames.contains(fileSet->name()) && !duplicateNames.contains(fileSet->name()))\r\n            {\r\n                errors.append(QObject::tr(\"File set name %1 within %2 is not unique.\")\r\n                    .arg(fileSet->name()).arg(context));\r\n                duplicateNames.append(fileSet->name());\r\n            }\r\n\r\n            fileSetNames.append(fileSet->name());\r\n            fileSetValidator_->findErrorsIn(errors, fileSet, context);\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentValidator::findErrorsInCPUs()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentValidator::findErrorsInCPUs(QVector<QString>& errors, QSharedPointer<Component> component,\r\n    QString const& context) const\r\n{\r\n    if (!component->getCpus()->isEmpty())\r\n    {\r\n        QVector<QString> cpuNames;\r\n        QVector<QString> duplicateNames;\r\n        for (QSharedPointer<Cpu> cpu : *component->getCpus())\r\n        {\r\n            if (cpuNames.contains(cpu->name()) && !duplicateNames.contains(cpu->name()))\r\n            {\r\n                errors.append(QObject::tr(\"CPU name %1 within %2 is not unique.\").arg(cpu->name()).arg(context));\r\n                duplicateNames.append(cpu->name());\r\n            }\r\n\r\n            cpuNames.append(cpu->name());\r\n            cpuValidator_->findErrorsIn(errors, cpu, context);\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentValidator::findErrorsInOtherClockDrivers()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentValidator::findErrorsInOtherClockDrivers(QVector<QString>& errors,\r\n    QSharedPointer<Component> component, QString const& context) const\r\n{\r\n    if (!component->getOtherClockDrivers()->isEmpty())\r\n    {\r\n        QVector<QString> clockDriverNames;\r\n        QVector<QString> duplicateNames;\r\n        for (QSharedPointer<OtherClockDriver> clockDriver : *component->getOtherClockDrivers())\r\n        {\r\n            if (clockDriverNames.contains(clockDriver->getClockName()) &&\r\n                !duplicateNames.contains(clockDriver->getClockName()))\r\n            {\r\n                errors.append(QObject::tr(\"Other clock driver name %1 within %2 is not unique.\")\r\n                    .arg(clockDriver->getClockName()).arg(context));\r\n                duplicateNames.append(clockDriver->getClockName());\r\n            }\r\n\r\n            clockDriverNames.append(clockDriver->getClockName());\r\n            otherClockDriverValidator_->findErrorsIn(errors, clockDriver, context);\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentValidator::findErrorsInPowerDomains()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentValidator::findErrorsInPowerDomains(QVector<QString>& errors,\r\n    QSharedPointer<Component> component, QString const& context) const\r\n{\r\n    QVector<QString> domainNames;\r\n    QVector<QString> duplicateNames;\r\n    for (QSharedPointer<PowerDomain> domain : *component->getPowerDomains())\r\n    {\r\n        if (domainNames.contains(domain->name()) && !duplicateNames.contains(domain->name()))\r\n        {\r\n            errors.append(QObject::tr(\"Power domain name %1 within %2 is not unique.\").arg(domain->name(), context));\r\n            duplicateNames.append(domain->name());\r\n        }\r\n\r\n        domainNames.append(domain->name());\r\n        powerDomainValidator_->findErrorsIn(errors, domain, context);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentValidator::findErrorsInResetTypes()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentValidator::findErrorsInResetTypes(QVector<QString>&errors, QSharedPointer<Component> component,\r\n    QString const& context) const\r\n{\r\n    if (!component->getResetTypes()->isEmpty())\r\n    {\r\n        QVector<QString> resetTypeNames;\r\n        QVector<QString> duplicateNames;\r\n        for(QSharedPointer<ResetType> resetType : *component->getResetTypes())\r\n        {\r\n            if (resetType->name().isEmpty())\r\n            {\r\n                errors.append(QObject::tr(\"Invalid name '%1' set for reset type within %2\")\r\n                    .arg(resetType->name()).arg(context));\r\n            }\r\n\r\n            if (resetType->name().compare(QLatin1String(\"HARD\"), Qt::CaseInsensitive) == 0)\r\n            {\r\n                errors.append(QObject::tr\r\n                (\"Invalid name '%1' set for reset type within %2, HARD is reserved for the default reset type.\")\r\n                    .arg(resetType->name()).arg(context));\r\n            }\r\n\r\n            if (resetTypeNames.contains(resetType->name()) && !duplicateNames.contains(resetType->name()))\r\n            {\r\n                errors.append(QObject::tr(\"Reset type name '%1' within %2 is not unique.\")\r\n                    .arg(resetType->name()).arg(context));\r\n                duplicateNames.append(resetType->name());\r\n            }\r\n\r\n            resetTypeNames.append(resetType->name());\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentValidator::findErrorsInParameters()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentValidator::findErrorsInParameters(QVector<QString>& errors, QSharedPointer<Component> component,\r\n    QString const& context) const\r\n{\r\n    if (!component->getParameters()->isEmpty())\r\n    {\r\n        QVector<QString> parameterNames;\r\n        QVector<QString> duplicateNames;\r\n        for (QSharedPointer<Parameter> parameter : *component->getParameters())\r\n        {\r\n            if (parameterNames.contains(parameter->name()) && !duplicateNames.contains(parameter->name()))\r\n            {\r\n                errors.append(QObject::tr(\"Parameter name %1 within %2 is not unique.\")\r\n                    .arg(parameter->name()).arg(context));\r\n                duplicateNames.append(parameter->name());\r\n            }\r\n\r\n            parameterNames.append(parameter->name());\r\n            parameterValidator_->findErrorsIn(errors, parameter, context);\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentValidator::findErrorsInAssertions()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentValidator::findErrorsInAssertions(QVector<QString>& errors, QSharedPointer<Component> component,\r\n    QString const& context) const\r\n{\r\n    if (!component->getAssertions()->isEmpty())\r\n    {\r\n        QVector<QString> assertionNames;\r\n        QVector<QString> duplicateNames;\r\n        for (QSharedPointer<Assertion> assertion : *component->getAssertions())\r\n        {\r\n            if (assertionNames.contains(assertion->name()) && !duplicateNames.contains(assertion->name()))\r\n            {\r\n                errors.append(QObject::tr(\"Assertion name %1 within %2 is not unique.\")\r\n                    .arg(assertion->name()).arg(context));\r\n                duplicateNames.append(assertion->name());\r\n            }\r\n\r\n            assertionNames.append(assertion->name());\r\n            assertionValidator_->findErrorsIn(errors, assertion, context);\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentValidator::updateComponent()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentValidator::changeComponent(QSharedPointer<Component> newComponent)\r\n{\r\n    if (newComponent && (!component_ || component_ != newComponent))\r\n    {\r\n        busInterfaceValidator_->componentChange(newComponent->getChoices(), newComponent->getViews(),\r\n            newComponent->getPorts(), newComponent->getAddressSpaces(), newComponent->getMemoryMaps(),\r\n            newComponent->getBusInterfaces(), newComponent->getFileSets(), newComponent->getRemapStates(),\r\n            newComponent->getModes());\r\n        indirectInterfaceValidator_->componentChange(newComponent);\r\n        parameterValidator_->componentChange(newComponent->getChoices(), newComponent->getRevision());\r\n        channelValidator_->componentChange(newComponent->getBusInterfaces());\r\n        remapStateValidator_->componentChange(newComponent->getPorts());\r\n        modeValidator_->componentChange(newComponent);\r\n        memoryMapValidator_->componentChange(newComponent);\r\n        viewValidator_->componentChange(newComponent->getModel());\r\n        instantiationsValidator_->componentChange(newComponent->getFileSets());\r\n        portValidator_->componentChange(newComponent->getViews());\r\n        cpuValidator_->componentChange(newComponent->getAddressSpaces(), newComponent->getMemoryMaps(),\r\n            newComponent->getRevision());\r\n        powerDomainValidator_->componentChange(newComponent->getPowerDomains());\r\n        addressSpaceValidator_->componentChange(newComponent);\r\n\r\n        component_ = newComponent;\r\n    }\r\n}\r\n"
  },
  {
    "path": "IPXACTmodels/Component/validators/ComponentValidator.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ComponentValidator.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 14.12.2015\r\n//\r\n// Description:\r\n// Validator for the ipxact:component.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef COMPONENTVALIDATOR_H\r\n#define COMPONENTVALIDATOR_H\r\n\r\n#include <IPXACTmodels/ipxactmodels_global.h>\r\n\r\n#include <IPXACTmodels/common/Document.h>\r\n\r\n#include <IPXACTmodels/Component/validators/CollectionValidators.h>\r\n\r\n#include <QSharedPointer>\r\n#include <QString>\r\n#include <QVector>\r\n\r\nclass Component;\r\nclass ResetType;\r\n\r\nclass BusInterfaceValidator;\r\nclass IndirectInterfaceValidator;\r\nclass ChannelValidator;\r\nclass RemapStateValidator;\r\nclass ModeValidator;\r\nclass AddressSpaceValidator;\r\nclass MemoryMapValidator;\r\nclass ViewValidator;\r\nclass InstantiationsValidator;\r\nclass PortValidator;\r\nclass PowerDomainValidator;\r\nclass ComponentGeneratorValidator;\r\nclass ChoiceValidator;\r\nclass FileSetValidator;\r\nclass CPUValidator;\r\nclass OtherClockDriverValidator;\r\nclass ParameterValidator;\r\nclass AssertionValidator;\r\n\r\nclass ExpressionParser;\r\nclass LibraryInterface;\r\nclass ModeConditionParserBaseInterface;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Validator for the ipxact:component.\r\n//-----------------------------------------------------------------------------\r\nclass IPXACTMODELS_EXPORT ComponentValidator\r\n{\r\npublic:\r\n\r\n    /*!\r\n     *  The constructor.\r\n     *\r\n     *    @param [in] parser                       The used expression parser.\r\n     *    @param [in] modeConditionParserInterface The interface used to create and manage the mode condition parser.\r\n     *    @param [in] library                      The used library interface.\r\n     */\r\n    ComponentValidator(QSharedPointer<ExpressionParser> parser, \r\n        QSharedPointer<ModeConditionParserBaseInterface> modeConditionParserInterface,\r\n        LibraryInterface* library, Document::Revision docRevision);\r\n\r\n\t//! The destructor.\r\n\t~ComponentValidator() = default;\r\n\r\n    // Disable copying.\r\n    ComponentValidator(ComponentValidator const& rhs) = delete;\r\n    ComponentValidator& operator=(ComponentValidator const& rhs) = delete;\r\n\r\n    /*!\r\n     *  Validates the given component.\r\n     *\r\n     *    @param [in] component   The selected component.\r\n     *\r\n     *    @return True, if the component is valid IP-XACT, otherwise false.\r\n     */\r\n    bool validate(QSharedPointer<Component> component);\r\n\r\n    /*!\r\n     *  Check if the component vlnv is valid.\r\n     *\r\n     *    @param [in] component   The selected component.\r\n     *\r\n     *    @return True, if the vlnv is valid, otherwise false.\r\n     */\r\n    bool hasValidVLNV(QSharedPointer<Component> component) const;\r\n\r\n    /*!\r\n     *  Check if the contained bus interfaces are valid.\r\n     *\r\n     *    @param [in] component   The selected component.\r\n     *\r\n     *    @return True, if the bus interfaces are valid, otherwise false.\r\n     */\r\n    bool hasValidBusInterfaces(QSharedPointer<Component> component);\r\n   \r\n    /*!\r\n     *  Check if the contained indirect interfaces are valid.\r\n     *\r\n     *    @param [in] component   The selected component.\r\n     *\r\n     *    @return True, if the indirect interfaces are valid, otherwise false.\r\n     */     \r\n    bool hasValidIndirectInterfaces(QSharedPointer<Component> component);\r\n\r\n    /*!\r\n     *  Check if the contained channels are valid.\r\n     *\r\n     *    @param [in] component   The selected component.\r\n     *\r\n     *    @return True, if the channels are valid, otherwise false.\r\n     */\r\n    bool hasValidChannels(QSharedPointer<Component> component);\r\n\r\n    /*!\r\n     *  Check if the contained remap states are valid.\r\n     *\r\n     *    @param [in] component   The selected component.\r\n     *\r\n     *    @return True, if the remap states are valid, otherwise false.\r\n     */\r\n    bool hasValidRemapStates(QSharedPointer<Component> component);\r\n\r\n    /*!\r\n     *  Check if the contained modes are valid.\r\n     *\r\n     *    @param [in] component   The selected component.\r\n     *\r\n     *    @return True, if the modes are valid, otherwise false.\r\n     */\r\n    bool hasValidModes(QSharedPointer<Component> component);\r\n\r\n    /*!\r\n     *  Check if the contained address spaces are valid.\r\n     *\r\n     *    @param [in] component   The selected component.\r\n     *\r\n     *    @return True, if the address spaces are valid, otherwise false.\r\n     */\r\n    bool hasValidAddressSpaces(QSharedPointer<Component> component);\r\n\r\n    /*!\r\n     *  Check if the contained memory maps are valid.\r\n     *\r\n     *    @param [in] component   The selected component.\r\n     *\r\n     *    @return True, if the memory maps are valid, otherwise false.\r\n     */\r\n    bool hasValidMemoryMaps(QSharedPointer<Component> component);\r\n\r\n    /*!\r\n     *  Check if the contained views are valid.\r\n     *\r\n     *    @param [in] component   The selected component.\r\n     *\r\n     *    @return True, if the views are valid, otherwise false.\r\n     */\r\n    bool hasValidViews(QSharedPointer<Component> component);\r\n\r\n    /*!\r\n     *  Check if the contained instantiations are valid.\r\n     *\r\n     *    @param [in] component   The selected component.\r\n     *\r\n     *    @return True, if the instantiations of the selected component are valid, otherwise false.\r\n     */\r\n    bool hasValidInstantiations(QSharedPointer<Component> component);\r\n\r\n    /*!\r\n     *  Check if the contained ports are valid.\r\n     *\r\n     *    @param [in] component   The selected component.\r\n     *\r\n     *    @return True, if the ports are valid, otherwise false.\r\n     */\r\n    bool hasValidPorts(QSharedPointer<Component> component);\r\n\r\n    /*!\r\n     *  Check if the contained component generators are valid.\r\n     *\r\n     *    @param [in] component   The selected component.\r\n     *\r\n     *    @return True, if the component generators are valid, otherwise false.\r\n     */\r\n    bool hasValidComponentGenerators(QSharedPointer<Component> component);\r\n\r\n    /*!\r\n     *  Check if the contained choices are valid.\r\n     *\r\n     *    @param [in] component   The selected component.\r\n     *\r\n     *    @return True, if the choices are valid, otherwise false.\r\n     */\r\n    bool hasValidChoices(QSharedPointer<Component> component);\r\n\r\n    /*!\r\n     *  Check if the contained file sets are valid.\r\n     *\r\n     *    @param [in] component   The selected component.\r\n     *\r\n     *    @return True, if the file sets are valid, otherwise false.\r\n     */\r\n    bool hasValidFileSets(QSharedPointer<Component> component);\r\n\r\n    /*!\r\n     *  Check if the contained CPUs are valid.\r\n     *\r\n     *    @param [in] component   The selected component.\r\n     *\r\n     *    @return True, if the CPUs are valid, otherwise false.\r\n     */\r\n    bool hasValidCPUs(QSharedPointer<Component> component);\r\n\r\n    /*!\r\n     *  Check if the contained other clock drivers are valid.\r\n     *\r\n     *    @param [in] component   The selected component.\r\n     *\r\n     *    @return True, if the other clock drivers are valid, otherwise false.\r\n     */\r\n    bool hasValidOtherClockDrivers(QSharedPointer<Component> component);\r\n\r\n    /*!\r\n     *  Check if the contained power domains are valid.\r\n     *\r\n     *    @param [in] component   The selected component.\r\n     *\r\n     *    @return True, if the power domains are valid, otherwise false.\r\n     */\r\n    bool hasValidPowerDomains(QSharedPointer<Component> component);\r\n\r\n    /*!\r\n     *  Check if the reset types of the selected component are valid.\r\n     *\r\n     *    @param [in] component   The selected component.\r\n     *\r\n     *    @return True, if the reset types are valid, otherwise false.\r\n     */\r\n    bool hasValidResetTypes(QSharedPointer<Component> component);\r\n\r\n    /*!\r\n     *  Check if a single reset type is valid.\r\n     *\r\n     *    @param [in] resetType   The selected reset type.\r\n     *    @param [in] resetTypes  The reset types of the containing component.\r\n     *\r\n     *    @return True, if the reset type is valid, otherwise false.\r\n     */\r\n    bool singleResetTypeIsValid(QSharedPointer<ResetType> resetType,\r\n        QSharedPointer<QList<QSharedPointer<ResetType> > > resetTypes) const;\r\n\r\n    /*!\r\n     *  Check if the contained parameters are valid.\r\n     *\r\n     *    @param [in] component   The selected component.\r\n     *\r\n     *    @return True, if the parameters are valid, otherwise false.\r\n     */\r\n    bool hasValidParameters(QSharedPointer<Component> component);\r\n\r\n    /*!\r\n     *  Check if the contained assertions are valid.\r\n     *\r\n     *    @param [in] component   The selected component.\r\n     *\r\n     *    @return True, if the assertions are valid, otherwise false.\r\n     */\r\n    bool hasValidAssertions(QSharedPointer<Component> component);\r\n\r\n    /*!\r\n     *  Locate errors within a component.\r\n     *\r\n     *    @param [in] errors      List of found errors.\r\n     *    @param [in] component   The selected component.\r\n     */\r\n    void findErrorsIn(QVector<QString>& errors, QSharedPointer<Component> component);\r\n\r\nprivate:\r\n\r\n    /*!\r\n     *  Find errors in component VLNV.\r\n     *\r\n     *    @param [in] errors      List of found errors.\r\n     *    @param [in] component   The selected component.\r\n     */\r\n    void findErrorsInVLNV(QVector<QString>& errors, QSharedPointer<Component> component) const;\r\n\r\n    /*!\r\n     *  Find errors in bus interfaces.\r\n     *\r\n     *    @param [in] errors      List of found errors.\r\n     *    @param [in] component   The selected component.\r\n     *    @param [in] context     Context to help locate the error.\r\n     */\r\n    void findErrorsInBusInterface(QVector<QString>& errors, QSharedPointer<Component> component,\r\n        QString const& context) const;\r\n\r\n    /*!\r\n     *  Find errors in indirect interfaces.\r\n     *\r\n     *    @param [in] errors      List of found errors.\r\n     *    @param [in] component   The selected component.\r\n     *    @param [in] context     Context to help locate the error.\r\n     */\r\n    void findErrorsInIndirectInterfaces(QVector<QString>& errors, QSharedPointer<Component> component, QString const& context);\r\n\r\n    /*!\r\n     *  Find errors in channels.\r\n     *\r\n     *    @param [in] errors      List of found errors.\r\n     *    @param [in] component   The selected component.\r\n     *    @param [in] context     Context to help locate the error.\r\n     */\r\n    void findErrorsInChannels(QVector<QString>& errors, QSharedPointer<Component> component,\r\n        QString const& context) const;\r\n\r\n    /*!\r\n     *  Find errors in remap states.\r\n     *\r\n     *    @param [in] errors      List of found errors.\r\n     *    @param [in] component   The selected component.\r\n     *    @param [in] context     Context to help locate the error.\r\n     */\r\n    void findErrorsInRemapStates(QVector<QString>& errors, QSharedPointer<Component> component,\r\n        QString const& context) const;\r\n\r\n    /*!\r\n     *  Find errors in modes.\r\n     *\r\n     *    @param [in] errors      List of found errors.\r\n     *    @param [in] component   The selected component.\r\n     *    @param [in] context     Context to help locate the error.\r\n     */\r\n    void findErrorsInModes(QVector<QString>& errors, QSharedPointer<Component> component,\r\n        QString const& context) const;\r\n\r\n    /*!\r\n     *  Find errors in address spaces.\r\n     *\r\n     *    @param [in] errors      List of found errors.\r\n     *    @param [in] component   The selected component.\r\n     *    @param [in] context     Context to help locate the error.\r\n     */\r\n    void findErrorsInAddressSpaces(QVector<QString>& errors, QSharedPointer<Component> component,\r\n        QString const& context) const;\r\n\r\n    /*!\r\n     *  Find errors in memory maps.\r\n     *\r\n     *    @param [in] errors      List of found errors.\r\n     *    @param [in] component   The selected component.\r\n     *    @param [in] context     Context to help locate the error.\r\n     */\r\n    void findErrorsInMemoryMaps(QVector<QString>& errors, QSharedPointer<Component> component,\r\n        QString const& context) const;\r\n\r\n    /*!\r\n     *  Find errors in views.\r\n     *\r\n     *    @param [in] errors      List of found errors.\r\n     *    @param [in] component   The selected component.\r\n     *    @param [in] context     Context to help locate the error.\r\n     */\r\n    void findErrorsInViews(QVector<QString>& errors, QSharedPointer<Component> component, QString const& context)\r\n        const;\r\n\r\n    /*!\r\n     *  Find errors in component instantiations.\r\n     *\r\n     *    @param [in] errors      List of found errors.\r\n     *    @param [in] component   The selected component.\r\n     *    @param [in] context     Context to help locate the error.\r\n     */\r\n    void findErrorsInComponentInstantiations(QVector<QString>& errors, QSharedPointer<Component> component,\r\n        QString const& context) const;\r\n\r\n    /*!\r\n     *  Find errors in design instantiations.\r\n     *\r\n     *    @param [in] errors      List of found errors.\r\n     *    @param [in] component   The selected component.\r\n     *    @param [in] context     Context to help locate the error.\r\n     */\r\n    void findErrorsInDesignInstantiations(QVector<QString>& errors, QSharedPointer<Component> component,\r\n        QString const& context) const;\r\n\r\n    /*!\r\n     *  Find errors in design configuration instantiations.\r\n     *\r\n     *    @param [in] errors      List of found errors.\r\n     *    @param [in] component   The selected component.\r\n     *    @param [in] context     Context to help locate the error.\r\n     */\r\n    void findErrorsInDesignConfigurationInstantiations(QVector<QString>& errors,\r\n        QSharedPointer<Component> component, QString const& context) const;\r\n\r\n    /*!\r\n     *  Find errors in ports.\r\n     *\r\n     *    @param [in] errors      List of found errors.\r\n     *    @param [in] component   The selected component.\r\n     *    @param [in] context     Context to help locate the error.\r\n     */\r\n    void findErrorsInPorts(QVector<QString>& errors, QSharedPointer<Component> component, QString const& context)\r\n        const;\r\n\r\n    /*!\r\n     *  Find errors in component generators.\r\n     *\r\n     *    @param [in] errors      List of found errors.\r\n     *    @param [in] component   The selected component.\r\n     *    @param [in] context     Context to help locate the error.\r\n     */\r\n    void findErrorsInComponentGenerators(QVector<QString>& errors, QSharedPointer<Component> component,\r\n        QString const& context) const;\r\n\r\n    /*!\r\n     *  Find errors in choices.\r\n     *\r\n     *    @param [in] errors      List of found errors.\r\n     *    @param [in] component   The selected component.\r\n     *    @param [in] context     Context to help locate the error.\r\n     */\r\n    void findErrorsInChoices(QVector<QString>& errors, QSharedPointer<Component> component, QString const& context)\r\n        const;\r\n\r\n    /*!\r\n     *  Find errors in file sets.\r\n     *\r\n     *    @param [in] errors      List of found errors.\r\n     *    @param [in] component   The selected component.\r\n     *    @param [in] context     Context to help locate the error.\r\n     */\r\n    void findErrorsInFileSets(QVector<QString>& errors, QSharedPointer<Component> component,\r\n        QString const& context) const;\r\n\r\n    /*!\r\n     *  Find errors in CPUs.\r\n     *\r\n     *    @param [in] errors      List of found errors.\r\n     *    @param [in] component   The selected component.\r\n     *    @param [in] context     Context to help locate the error.\r\n     */\r\n    void findErrorsInCPUs(QVector<QString>& errors, QSharedPointer<Component> component, QString const& context)\r\n        const;\r\n\r\n    /*!\r\n     *  Find errors in other clock drivers.\r\n     *\r\n     *    @param [in] errors      List of found errors.\r\n     *    @param [in] component   The selected component.\r\n     *    @param [in] context     Context to help locate the error.\r\n     */\r\n    void findErrorsInOtherClockDrivers(QVector<QString>& errors, QSharedPointer<Component> component,\r\n        QString const& context) const;\r\n\r\n    /*!\r\n     *  Find errors in power domains.\r\n     *\r\n     *    @param [in] errors      List of found errors.\r\n     *    @param [in] component   The selected component.\r\n     *    @param [in] context     Context to help locate the error.\r\n     */\r\n    void findErrorsInPowerDomains(QVector<QString>& errors, QSharedPointer<Component> component,\r\n        QString const& context) const;\r\n    /*!\r\n     *  Find errors in reset types.\r\n     *\r\n     *    @param [in] errors      List of found errors.\r\n     *    @param [in] component   The selected component.\r\n     *    @param [in] context     Context to help locate the error.\r\n     */\r\n    void findErrorsInResetTypes(QVector<QString>& errors, QSharedPointer<Component> component,\r\n        QString const& context) const;\r\n\r\n    /*!\r\n     *  Find errors in parameters.\r\n     *\r\n     *    @param [in] errors      List of found errors.\r\n     *    @param [in] component   The selected component.\r\n     *    @param [in] context     Context to help locate the error.\r\n     */\r\n    void findErrorsInParameters(QVector<QString>& errors, QSharedPointer<Component> component,\r\n        QString const& context) const;\r\n\r\n    /*!\r\n     *  Find errors in assertions.\r\n     *\r\n     *    @param [in] errors      List of found errors.\r\n     *    @param [in] component   The selected component.\r\n     *    @param [in] context     Context to help locate the error.\r\n     */\r\n    void findErrorsInAssertions(QVector<QString>& errors, QSharedPointer<Component> component,\r\n        QString const& context) const;\r\n\r\n    /*!\r\n     *  Change the used component.\r\n     *\r\n     *    @param [in] newComponent    The new component.\r\n     */\r\n    void changeComponent(QSharedPointer<Component> newComponent);\r\n    \r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! The last validated component.\r\n    QSharedPointer<Component> component_;\r\n\r\n    //! The used bus interface validator.\r\n    QSharedPointer<BusInterfaceValidator> busInterfaceValidator_;\r\n\r\n    //! The used indirect interface validator.\r\n    QSharedPointer<IndirectInterfaceValidator> indirectInterfaceValidator_;\r\n\r\n    //! The used channel validator.\r\n    QSharedPointer<ChannelValidator> channelValidator_;\r\n\r\n    //! The used remap state validator.\r\n    QSharedPointer<RemapStateValidator> remapStateValidator_;\r\n\r\n    //! The used mode validator.\r\n    QSharedPointer<ModeValidator> modeValidator_;\r\n\r\n    //! The used address space validator.\r\n    QSharedPointer<AddressSpaceValidator> addressSpaceValidator_;\r\n    \r\n    //! The used memory map validator.\r\n    QSharedPointer<MemoryMapValidator> memoryMapValidator_;\r\n\r\n    //! The used view validator.\r\n    QSharedPointer<ViewValidator> viewValidator_;\r\n\r\n    //! The used instantiations validator.\r\n    QSharedPointer<InstantiationsValidator> instantiationsValidator_;\r\n\r\n    //! The used port validator.\r\n    QSharedPointer<PortValidator> portValidator_;\r\n\r\n    //! The used component generator validator.\r\n    QSharedPointer<ComponentGeneratorValidator> generatorValidator_;\r\n\r\n    //! The used choice validator.\r\n    QSharedPointer<ChoiceValidator> choiceValidator_;\r\n\r\n    //! The used file set validator.\r\n    QSharedPointer<FileSetValidator> fileSetValidator_;\r\n\r\n    //! The used CPU validator.\r\n    QSharedPointer<CPUValidator> cpuValidator_;\r\n\r\n    //! The used other clock driver validator.\r\n    QSharedPointer<OtherClockDriverValidator> otherClockDriverValidator_;\r\n\r\n    //! The used power domain validator.\r\n    QSharedPointer<PowerDomainValidator> powerDomainValidator_;\r\n\r\n    //! The used parameter validator.\r\n    QSharedPointer<ParameterValidator> parameterValidator_;\r\n\r\n    //! The used assertion validator.\r\n    QSharedPointer<AssertionValidator> assertionValidator_;\r\n\r\n    //! Top-level validators\r\n    \r\n    //! The memory maps validator.\r\n    QSharedPointer<MemoryMapsValidator> memoryMapsValidator_;\r\n\r\n    //! The file sets validator.\r\n    QSharedPointer<FileSetsValidator> fileSetsValidator_;\r\n\r\n    //! THe address spaces validator.\r\n    QSharedPointer<AddressSpacesValidator> addressSpacesValidator_;\r\n\r\n    //! Validator for validating all instantiations together.\r\n    QSharedPointer<AllInstantiationsValidator> allInstantiationsValidator_;\r\n\r\n    //! Validator for validating all component views together.\r\n    QSharedPointer<ViewsValidator> viewsValidator_;\r\n\r\n    //! Validator for validating all ports together.\r\n    QSharedPointer<PortsValidator> portsValidator_;\r\n\r\n    //! Validator for validating all bus interfaces together.\r\n    QSharedPointer<BusInterfacesValidator> busIfsValidator_;\r\n\r\n    //! Validator for validating all indirect interfaces together.\r\n    QSharedPointer<IndirectInterfacesValidator> indirectInterfacesValidator_;\r\n\r\n    //! Interface for creating and managing mode condition parser.\r\n    QSharedPointer<ModeConditionParserBaseInterface> modeConditionParserInterface_;\r\n\r\n    //! The mode condition parser to use.\r\n    QSharedPointer<ExpressionParser> modeConditionParser_;\r\n\r\n    //! Validator for validating all cpus together.\r\n    QSharedPointer<CPUsValidator> cpusValidator_;\r\n\r\n    //! Validator for validating all power domains together.\r\n    QSharedPointer<PowerDomainsValidator> powerDomainsValidator_;\r\n};\r\n\r\n#endif // COMPONENTVALIDATOR_H\r\n"
  },
  {
    "path": "IPXACTmodels/Component/validators/EnumeratedValueValidator.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: EnumeratedValueValidator.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 17.11.2015\r\n//\r\n// Description:\r\n// Validator for ipxact:EnumeratedValue.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"EnumeratedValueValidator.h\"\r\n\r\n#include <KactusAPI/include/ExpressionParser.h>\r\n\r\n#include <IPXACTmodels/Component/EnumeratedValue.h>\r\n\r\n#include <QRegularExpression>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: EnumeratedValueValidator::EnumeratedValueValidator()\r\n//-----------------------------------------------------------------------------\r\nEnumeratedValueValidator::EnumeratedValueValidator(QSharedPointer<ExpressionParser> expressionParser):\r\nexpressionParser_(expressionParser)\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: EnumeratedValueValidator::validate()\r\n//-----------------------------------------------------------------------------\r\nbool EnumeratedValueValidator::validate(QSharedPointer<EnumeratedValue> enumeratedValue) const\r\n{\r\n    return hasValidName(enumeratedValue) && hasValidValue(enumeratedValue);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: EnumeratedValueValidator::hasValidName()\r\n//-----------------------------------------------------------------------------\r\nbool EnumeratedValueValidator::hasValidName(QSharedPointer<EnumeratedValue> enumeratedValue) const\r\n{\r\n    QRegularExpression whiteSpaceExpression;\r\n    whiteSpaceExpression.setPattern(QStringLiteral(\"^\\\\s*$\"));\r\n    QRegularExpressionMatch whiteSpaceMatch = whiteSpaceExpression.match(enumeratedValue->name());\r\n\r\n    if (enumeratedValue->name().isEmpty() || whiteSpaceMatch.hasMatch())\r\n    {\r\n        return false;\r\n    }\r\n\r\n    return true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: EnumeratedValueValidator::hasValidValue()\r\n//-----------------------------------------------------------------------------\r\nbool EnumeratedValueValidator::hasValidValue(QSharedPointer<EnumeratedValue> enumeratedValue) const\r\n{\r\n    QString value = enumeratedValue->getValue();\r\n    QString solvedValue = expressionParser_->parseExpression(value);\r\n\r\n    QRegularExpression bitExpression(QStringLiteral(\"^([0-9]+|[1-9]+[0-9]*'([bB][01_]+|[hH][0-9a-fA-F_]+))$\"));\r\n    return !value.isEmpty() || bitExpression.match(value).hasMatch() || bitExpression.match(solvedValue).hasMatch();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: EnumeratedValueValidator::findErrorsIn()\r\n//-----------------------------------------------------------------------------\r\nvoid EnumeratedValueValidator::findErrorsIn(QVector<QString>& errors,\r\n    QSharedPointer<EnumeratedValue> enumeratedValue, QString const& context) const\r\n{\r\n    findErrorsInName(errors, enumeratedValue, context);\r\n    findErrorsInValue(errors, enumeratedValue, context);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: EnumeratedValueValidator::findErrorsInName()\r\n//-----------------------------------------------------------------------------\r\nvoid EnumeratedValueValidator::findErrorsInName(QVector<QString>& errors,\r\n    QSharedPointer<EnumeratedValue> enumeratedValue, QString const& context) const\r\n{\r\n    if (!hasValidName(enumeratedValue))\r\n    {\r\n        errors.append(QObject::tr(\"Invalid name specified for %1 within %2\").arg(enumeratedValue->name(), context));\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: EnumeratedValueValidator::findErrorsInValue()\r\n//-----------------------------------------------------------------------------\r\nvoid EnumeratedValueValidator::findErrorsInValue(QVector<QString>& errors,\r\n    QSharedPointer<EnumeratedValue> enumeratedValue, QString const& context) const\r\n{\r\n    if (!hasValidValue(enumeratedValue))\r\n    {\r\n        errors.append(QObject::tr(\"Invalid value %1 set for enumerated value %2 within %3\").\r\n            arg(enumeratedValue->getValue()).arg(enumeratedValue->name()).arg(context));\r\n    }\r\n}"
  },
  {
    "path": "IPXACTmodels/Component/validators/EnumeratedValueValidator.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: EnumeratedValueValidator.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 17.11.2015\r\n//\r\n// Description:\r\n// Validator for ipxact:EnumeratedValue.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef ENUMERATEDVALUEVALIDATOR_H\r\n#define ENUMERATEDVALUEVALIDATOR_H\r\n\r\n#include <IPXACTmodels/ipxactmodels_global.h>\r\n\r\n#include <QSharedPointer>\r\n#include <QString>\r\n\r\nclass ExpressionParser;\r\nclass EnumeratedValue;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Validator for ipxact:EnumeratedValue.\r\n//-----------------------------------------------------------------------------\r\nclass IPXACTMODELS_EXPORT EnumeratedValueValidator\r\n{\r\npublic:\r\n\r\n\t/*!\r\n\t *  The constructor.\r\n\t *\r\n\t *    @param [in] expressionParser    The parser to use for solving expressions.\r\n\t */\r\n    EnumeratedValueValidator(QSharedPointer<ExpressionParser> expressionParser);\r\n\r\n\t//! The destructor.\r\n\t~EnumeratedValueValidator() = default;\r\n    \r\n    /*!\r\n     *  Validates the given enumerated value.\r\n     *\r\n     *    @param [in] enumeratedValue     The enumerated value to validate.\r\n     *\r\n     *    @return True, if the enumerated value is valid IP-XACT, otherwise false.\r\n     */\r\n    bool validate(QSharedPointer<EnumeratedValue> enumeratedValue) const;\r\n\r\n    /*!\r\n     *  Check if the enumerated value contains a valid name.\r\n     *\r\n     *    @param [in] enumeratedValue     The selected enumerated value.\r\n     *\r\n     *    @return True, if the name is valid, otherwise false.\r\n     */\r\n    bool hasValidName(QSharedPointer<EnumeratedValue> enumeratedValue) const;\r\n\r\n    /*!\r\n     *  Check if the enumerated value contains a valid value.\r\n     *\r\n     *    @param [in] enumeratedValue     The selected enumerated value.\r\n     *\r\n     *    @return True, if the value is valid, otherwise false.\r\n     */\r\n    bool hasValidValue(QSharedPointer<EnumeratedValue> enumeratedValue) const;\r\n\r\n    /*!\r\n     *  Locate errors within an enumerated value.\r\n     *\r\n     *    @param [in] errors              List of found errors.\r\n     *    @param [in] enumeratedValue     The selected enumerated value.\r\n     *    @param [in] context             Context to help locate the error.\r\n     */\r\n    void findErrorsIn(QVector<QString>& errors, QSharedPointer<EnumeratedValue> enumeratedValue,\r\n        QString const& context) const;\r\n\r\nprivate:\r\n\r\n\t// Disable copying.\r\n\tEnumeratedValueValidator(EnumeratedValueValidator const& rhs);\r\n\tEnumeratedValueValidator& operator=(EnumeratedValueValidator const& rhs);\r\n\r\n    /*!\r\n     *  Find errors within a name.\r\n     *\r\n     *    @param [in] errors              List of found errors.\r\n     *    @param [in] enumeratedValue     The selected enumerated value.\r\n     *    @param [in] context             Context to help locate the error.\r\n     */\r\n    void findErrorsInName(QVector<QString>& errors, QSharedPointer<EnumeratedValue> enumeratedValue,\r\n        QString const& context) const;\r\n\r\n    /*!\r\n     *  Find errors within a value.\r\n     *\r\n     *    @param [in] errors              List of found errors.\r\n     *    @param [in] enumeratedValue     The selected enumerated value.\r\n     *    @param [in] context             Context to help locate the error.\r\n     */\r\n    void findErrorsInValue(QVector<QString>& errors, QSharedPointer<EnumeratedValue> enumeratedValue,\r\n        QString const& context) const;\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! The expression parser to use.\r\n    QSharedPointer<ExpressionParser> expressionParser_;\r\n};\r\n\r\n#endif // ENUMERATEDVALUEVALIDATOR_H\r\n"
  },
  {
    "path": "IPXACTmodels/Component/validators/FieldAccessPolicyValidator.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: FieldAccessPolicyValidator.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Anton Hagqvist\n// Date: 3.8.2023\n//\n// Description:\n// Validator for ipxact:fieldAccessPolicy.\n//-----------------------------------------------------------------------------\n\n#include \"FieldAccessPolicyValidator.h\"\n#include \"FieldReferenceValidator.h\"\n\n#include <IPXACTmodels/common/validators/CommonItemsValidator.h>\n\n#include <KactusAPI/include/ExpressionParser.h>\n\n#include <QRegularExpression>\n\n//-----------------------------------------------------------------------------\n// Function: FieldAccessPolicyValidator::FieldAccessPolicyValidator()\n//-----------------------------------------------------------------------------\nFieldAccessPolicyValidator::FieldAccessPolicyValidator(QSharedPointer<ExpressionParser> expressionParser):\n    expressionParser_(expressionParser)\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: FieldAccessPolicyValidator::validate()\n//-----------------------------------------------------------------------------\nbool FieldAccessPolicyValidator::validate(QSharedPointer<FieldAccessPolicy> fieldAccessPolicy, QSharedPointer<QList<QSharedPointer<Mode> > > availableModes) const\n{\n    return hasValidAccess(fieldAccessPolicy) &&\n        hasValidDefinitionRef(fieldAccessPolicy) && hasValidWriteValueConstraint(fieldAccessPolicy) &&\n        hasValidReadResponse(fieldAccessPolicy) && hasValidBroadcasts(fieldAccessPolicy) &&\n        hasValidAccessRestrictions(fieldAccessPolicy, availableModes) && hasValidReserved(fieldAccessPolicy);\n}\n\n//-----------------------------------------------------------------------------\n// Function: FieldAccessPolicyValidator::findErrorsIn()\n//-----------------------------------------------------------------------------\nvoid FieldAccessPolicyValidator::findErrorsIn(QStringList& errors, \n    QSharedPointer<FieldAccessPolicy> fieldAccessPolicy, QString const& context, \n    QSharedPointer<QList<QSharedPointer<Mode> > > availableModes) const\n{\n    finderrorsInDefinitionRef(errors, fieldAccessPolicy, context);\n    findErrorsInAccess(errors, fieldAccessPolicy, context);\n    findErrorsInWriteValueConstraint(errors, fieldAccessPolicy, context);\n    findErrorsInReadResponse(errors, fieldAccessPolicy, context);\n    findErrorsInBroadcasts(errors, fieldAccessPolicy, context);\n    findErrorsInAccessRestrictions(errors, fieldAccessPolicy, context, availableModes);\n    findErrorsInReserved(errors, fieldAccessPolicy, context);\n}\n\n//-----------------------------------------------------------------------------\n// Function: FieldAccessPolicyValidator::hasValidDefinitionRef()\n//-----------------------------------------------------------------------------\nbool FieldAccessPolicyValidator::hasValidDefinitionRef(QSharedPointer<FieldAccessPolicy> fieldAccessPolicy) const\n{\n    if (!fieldAccessPolicy->getFieldAccessPolicyDefinitionRef().isEmpty() &&\n        fieldAccessPolicy->getFieldAccessPolicyTypeDefinitionRef().isEmpty())\n    {\n        return false;\n    }\n\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: FieldAccessPolicyValidator::hasValidAcces()\n//-----------------------------------------------------------------------------\nbool FieldAccessPolicyValidator::hasValidAccess(QSharedPointer<FieldAccessPolicy> fieldAccessPolicy) const\n{\n    if (fieldAccessPolicy->getAccess() == AccessTypes::READ_ONLY)\n    {\n        return fieldAccessPolicy->getModifiedWrite() == General::MODIFIED_WRITE_COUNT;\n    }\n    else if (fieldAccessPolicy->getAccess() == AccessTypes::WRITE_ONLY ||\n        fieldAccessPolicy->getAccess() == AccessTypes::WRITEONCE)\n    {\n        return fieldAccessPolicy->getReadAction() == General::READ_ACTION_COUNT;\n    }\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: FieldAccessPolicyValidator::hasValidWriteValueConstraint()\n//-----------------------------------------------------------------------------\nbool FieldAccessPolicyValidator::hasValidWriteValueConstraint(QSharedPointer<FieldAccessPolicy> fieldAccessPolicy) const\n{\n    if (fieldAccessPolicy->getWriteValueConstraint())\n    {\n        QSharedPointer<WriteValueConstraint> writeConstraint = fieldAccessPolicy->getWriteValueConstraint();\n\n        if (writeConstraint->getType() == WriteValueConstraint::TYPE_COUNT)\n        {\n            return false;\n        }\n        else if (writeConstraint->getType() == WriteValueConstraint::MIN_MAX)\n        {\n            int minimumInt = expressionParser_->parseExpression(writeConstraint->getMinimum()).toInt();\n            int maximumInt = expressionParser_->parseExpression(writeConstraint->getMaximum()).toInt();\n\n            return !writeConstraint->getMinimum().isEmpty() && !writeConstraint->getMaximum().isEmpty() &&\n                isBitExpressionValid(writeConstraint->getMinimum()) &&\n                isBitExpressionValid(writeConstraint->getMaximum()) &&\n                minimumInt <= maximumInt;\n        }\n    }\n\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: FieldAccessPolicyValidator::hasValidReadResponse()\n//-----------------------------------------------------------------------------\nbool FieldAccessPolicyValidator::hasValidReadResponse(QSharedPointer<FieldAccessPolicy> fieldAccessPolicy) const\n{\n    if (auto const& readResponse = fieldAccessPolicy->getReadResponse(); readResponse.isEmpty() == false)\n    {\n        if (isBitExpressionValid(readResponse) == false)\n        {\n            return false;\n        }\n    }\n\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: FieldAccessPolicyValidator::hasValidBroadcasts()\n//-----------------------------------------------------------------------------\nbool FieldAccessPolicyValidator::hasValidBroadcasts(QSharedPointer<FieldAccessPolicy> fieldAccessPolicy) const\n{\n    for (auto const& fieldRef : *fieldAccessPolicy->getBroadcasts())\n    {\n        if (FieldReferenceValidator::validate(fieldRef) == false)\n        {\n            return false;\n        }\n    }\n    \n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: FieldAccessPolicyValidator::hasValidAccessRestrictions()\n//-----------------------------------------------------------------------------\nbool FieldAccessPolicyValidator::hasValidAccessRestrictions(QSharedPointer<FieldAccessPolicy> fieldAccessPolicy, QSharedPointer<QList<QSharedPointer<Mode> > > availableModes) const\n{\n    if (fieldAccessPolicy->getAccessRestrictions()->isEmpty())\n    {\n        return true;\n    }\n\n    // Check mode refs. Refrence and priority must both be unique in all modes inside accessRestrictions.\n    QSharedPointer<QList<QSharedPointer<ModeReference> > > allModeRefs(new QList<QSharedPointer<ModeReference> >());\n\n    for (auto const& accessRestriction : *fieldAccessPolicy->getAccessRestrictions())\n    {\n        allModeRefs->append(*accessRestriction->modeRefs_);\n\n        if (!isBitExpressionValid(accessRestriction->readAccessMask_) ||\n            !isBitExpressionValid(accessRestriction->writeAccessMask_))\n        {\n            return false;\n        }\n    }\n\n    return CommonItemsValidator::hasValidModeRefs(allModeRefs, availableModes);\n}\n\n//-----------------------------------------------------------------------------\n// Function: FieldAccessPolicyValidator::hasValidReserved()\n//-----------------------------------------------------------------------------\nbool FieldAccessPolicyValidator::hasValidReserved(QSharedPointer<FieldAccessPolicy> fieldAccessPolicy) const\n{\n    if (!fieldAccessPolicy->getReserved().isEmpty())\n    {\n        bool isValidReserved = false;\n        QString solvedValue = expressionParser_->parseExpression(fieldAccessPolicy->getReserved(), &isValidReserved);\n        bool canConvert = false;\n        int intValue = solvedValue.toInt(&canConvert);\n\n        if (isValidReserved == false || canConvert == false || intValue < 0 || intValue > 1)\n        {\n            return false;\n        }\n    }\n\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: FieldAccessPolicyValidator::finderrorsInDefinitionRef()\n//-----------------------------------------------------------------------------\nvoid FieldAccessPolicyValidator::finderrorsInDefinitionRef(QStringList& errors, QSharedPointer<FieldAccessPolicy> fieldAccessPolicy, QString const& context) const\n{\n    if (!hasValidDefinitionRef(fieldAccessPolicy))\n    {\n        errors.append(QObject::tr(\"Field access policy in %1 has invalid or missing reference to definition reference type definitions.\").arg(context));\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: FieldAccessPolicyValidator::findErrorsInAccess()\n//-----------------------------------------------------------------------------\nvoid FieldAccessPolicyValidator::findErrorsInAccess(QStringList& errors, QSharedPointer<FieldAccessPolicy> fieldAccessPolicy, QString const& context) const\n{\n    if (fieldAccessPolicy->getAccess() == AccessTypes::READ_ONLY)\n    {\n        if (fieldAccessPolicy->getModifiedWrite() != General::MODIFIED_WRITE_COUNT)\n        {\n            errors.append(QObject::tr(\"In field access policy within %1, access type readOnly does not \"\n                \"allow the field access policy to include a modified write value.\").arg(context));\n        }\n    }\n    else if (fieldAccessPolicy->getAccess() == AccessTypes::WRITE_ONLY || fieldAccessPolicy->getAccess() == AccessTypes::WRITEONCE)\n    {\n        if (fieldAccessPolicy->getReadAction() != General::READ_ACTION_COUNT)\n        {\n            errors.append(QObject::tr(\"In field access policy within %1, access type write only and write once \"\n                \"do not allow the field access policy to include a read action value.\").arg(context));\n        }\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: FieldAccessPolicyValidator::findErrorsInWriteValueConstraint()\n//-----------------------------------------------------------------------------\nvoid FieldAccessPolicyValidator::findErrorsInWriteValueConstraint(QStringList& errors, QSharedPointer<FieldAccessPolicy> fieldAccessPolicy, QString const& context) const\n{\n    if (hasValidWriteValueConstraint(fieldAccessPolicy))\n    {\n        return;\n    }\n    \n    QSharedPointer<WriteValueConstraint> writeConstaint = fieldAccessPolicy->getWriteValueConstraint();\n    if (writeConstaint->getType() == WriteValueConstraint::TYPE_COUNT)\n    {\n        errors.append(QObject::tr(\"Invalid write value constraint set for field access policy within %1\")\n            .arg(context));\n    }\n    else\n    {\n        bool minimumIsValid = isBitExpressionValid(writeConstaint->getMinimum());\n        bool maximumIsValid = isBitExpressionValid(writeConstaint->getMaximum());\n\n        if (!minimumIsValid)\n        {\n            errors.append(QObject::tr(\n                \"Invalid minimum value set for write value constraint in field access policy within %1\")\n                .arg(context));\n        }\n        if (!maximumIsValid)\n        {\n            errors.append(QObject::tr(\n                \"Invalid maximum value set for write value constraint in field access policy within %1\")\n                .arg(context));\n        }\n\n        if (minimumIsValid && maximumIsValid)\n        {\n            int minimumInt = expressionParser_->parseExpression(writeConstaint->getMinimum()).toInt();\n            int maximumInt = expressionParser_->parseExpression(writeConstaint->getMaximum()).toInt();\n\n            if (minimumInt > maximumInt)\n            {\n                errors.append(QObject::tr(\n                    \"Maximum value must be greater than or equal to the minimum value in \"\n                    \"write value constraint set for field access policy within %1\").arg(context));\n            }\n        }\n    }\n    \n}\n\n//-----------------------------------------------------------------------------\n// Function: FieldAccessPolicyValidator::findErrorsInReadResponse()\n//-----------------------------------------------------------------------------\nvoid FieldAccessPolicyValidator::findErrorsInReadResponse(QStringList& errors, QSharedPointer<FieldAccessPolicy> fieldAccessPolicy, QString const& context) const\n{\n    if (!hasValidReadResponse(fieldAccessPolicy))\n    {\n        errors.append(QObject::tr(\"Invalid read response value for field access policy within %1\").arg(context));\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: FieldAccessPolicyValidator::findErrorsInBroadcasts()\n//-----------------------------------------------------------------------------\nvoid FieldAccessPolicyValidator::findErrorsInBroadcasts(QStringList& errors, QSharedPointer<FieldAccessPolicy> fieldAccessPolicy, QString const& context) const\n{\n    for (auto const& fieldRef : *fieldAccessPolicy->getBroadcasts())\n    {\n        FieldReferenceValidator::findErrorsIn(errors, fieldRef, context);\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: FieldAccessPolicyValidator::findErrorsInAccessRestrictions()\n//-----------------------------------------------------------------------------\n\nvoid FieldAccessPolicyValidator::findErrorsInAccessRestrictions(QStringList& errors, QSharedPointer<FieldAccessPolicy> fieldAccessPolicy, QString const& context, QSharedPointer<QList<QSharedPointer<Mode> > > availableModes) const\n{\n    if (fieldAccessPolicy->getAccessRestrictions()->isEmpty())\n    {\n        return;\n    }\n\n    // Check mode refs. Refrence and priority must both be unique in all modes inside accessRestrictions.\n    QSharedPointer<QList<QSharedPointer<ModeReference> > > allModeRefs(new QList<QSharedPointer<ModeReference> >());\n\n    for (auto const& accessRestriction : *fieldAccessPolicy->getAccessRestrictions())\n    {\n        allModeRefs->append(*accessRestriction->modeRefs_);\n\n        if (!isBitExpressionValid(accessRestriction->readAccessMask_) && !accessRestriction->readAccessMask_.isEmpty())\n        {\n            errors.append(QObject::tr(\"A field access policy access restriction in %1 has an invalid \"\n                \"read access mask value.\").arg(context));\n        }\n\n        if (!isBitExpressionValid(accessRestriction->writeAccessMask_) && !accessRestriction->writeAccessMask_.isEmpty())\n        {\n            errors.append(QObject::tr(\"A field access policy access restriction in %1 has an invalid \"\n                \"write access mask value.\").arg(context));\n        }\n    }\n\n    if (!CommonItemsValidator::hasValidModeRefs(allModeRefs, availableModes))\n    {\n        errors.append(QObject::tr(\"Field access policy access restrictions in %1\"\n            \" cannot have empty or duplicate mode references or priorities.\").arg(context));\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: FieldAccessPolicyValidator::findErrorsInReserved()\n//-----------------------------------------------------------------------------\nvoid FieldAccessPolicyValidator::findErrorsInReserved(QStringList& errors, QSharedPointer<FieldAccessPolicy> fieldAccessPolicy, QString const& context) const\n{\n    if (!hasValidReserved(fieldAccessPolicy))\n    {\n        errors.append(QObject::tr(\"Invalid reserved set for field access policy within %1\").arg(context));\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: FieldAccessPolicyValidator::isBitExpressionValid()\n//-----------------------------------------------------------------------------\nbool FieldAccessPolicyValidator::isBitExpressionValid(QString const& expression) const\n{\n    QString solvedValue = expressionParser_->parseExpression(expression);\n\n    QRegularExpression bitExpression(QStringLiteral(\"^([0-9]+|[1-9]+[0-9]*'([bB][01_]+|[hH][0-9a-fA-F_]+))$\"));\n    return bitExpression.match(expression).hasMatch() || bitExpression.match(solvedValue).hasMatch();\n}\n"
  },
  {
    "path": "IPXACTmodels/Component/validators/FieldAccessPolicyValidator.h",
    "content": "//-----------------------------------------------------------------------------\n// File: FieldAccessPolicyValidator.h\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Anton Hagqvist\n// Date: 3.8.2023\n//\n// Description:\n// Validator for ipxact:fieldAccessPolicy.\n//-----------------------------------------------------------------------------\n\n#ifndef FIELDACCESSPOLICYVALIDATOR_H\n#define FIELDACCESSPOLICYVALIDATOR_H\n\n#include <IPXACTmodels/Component/FieldAccessPolicy.h>\n\n#include <IPXACTmodels/ipxactmodels_global.h>\n\nclass ExpressionParser;\nclass Mode;\n\nclass IPXACTMODELS_EXPORT FieldAccessPolicyValidator\n{\npublic:\n\n    explicit FieldAccessPolicyValidator(QSharedPointer<ExpressionParser> expressionParser);\n\n    ~FieldAccessPolicyValidator() = default;\n\n    FieldAccessPolicyValidator(FieldAccessPolicyValidator& other) = delete;\n    FieldAccessPolicyValidator& operator=(FieldAccessPolicyValidator& other) = delete;\n    \n    /*!\n     *\tValidates the given field access policy.\n     *  \n     *    @param [in] fieldAccessPolicy     The field access policy to validate\n     *\t    \n     * \t    @return True, if the field access policy is valid, otherwise false.\n     */\n    bool validate(QSharedPointer<FieldAccessPolicy> fieldAccessPolicy, \n        QSharedPointer<QList<QSharedPointer<Mode> > > availableModes) const;\n\n    /*!\n     *\tLocate errors within a field access policy.\n     *  \n     *    @param [in] errors                List of found errors.\n     *    @param [in] fieldAccessPolicy     The selected field access policy.\n     *    @param [in] context               Context to help locate the error.\n     */\n    void findErrorsIn(QStringList& errors, QSharedPointer<FieldAccessPolicy> fieldAccessPolicy, \n        QString const& context, QSharedPointer<QList<QSharedPointer<Mode> > > availableModes) const;\n    \n    /*!\n     *  Check if the field access policy has a valid access value.\n     *\n     *    @param [in] fieldAccessPolicy   The selected field access policy.\n     *\n     *    @return True, if the access is valid, otherwise false.\n     */\n    bool hasValidAccess(QSharedPointer<FieldAccessPolicy> fieldAccessPolicy) const;\n\n    /*!\n     *  Check if the field access policy has a valid write value constraint.\n     *\n     *    @param [in] fieldAccessPolicy   The selected field access policy.\n     *\n     *    @return True, if the write value constraint is valid, otherwise false.\n     */\n    bool hasValidWriteValueConstraint(QSharedPointer<FieldAccessPolicy> fieldAccessPolicy) const;\n\n    /*!\n     *  Check if the field access policy has a valid read response.\n     *\n     *    @param [in] fieldAccessPolicy   The selected field access policy.\n     *\n     *    @return True, if the write read response is valid, otherwise false.\n     */\n    bool hasValidReadResponse(QSharedPointer<FieldAccessPolicy> fieldAccessPolicy) const;\n\n    /*!\n     *  Check if the field access policy has valid broadcasts.\n     *\n     *    @param [in] fieldAccessPolicy   The selected field access policy.\n     *\n     *    @return True, if the broadcasts are valid, otherwise false.\n     */\n    bool hasValidBroadcasts(QSharedPointer<FieldAccessPolicy> fieldAccessPolicy) const;\n\n    /*!\n     *  Check if the field access policy has a valid reserved value.\n     *\n     *    @param [in] fieldAccessPolicy   The selected field access policy.\n     *\n     *    @return True, if the broadcasts are valid, otherwise false.\n     */\n    bool hasValidReserved(QSharedPointer<FieldAccessPolicy> fieldAccessPolicy) const;\n\nprivate:\n\n    /*!\n     *  Check if the field access policy has a valid field access policy definition reference.\n     *\n     *    @param [in] fieldAccessPolicy   The selected field access policy.\n     *\n     *    @return True, if the field access policy definition reference is valid, otherwise false.\n     */\n    bool hasValidDefinitionRef(QSharedPointer<FieldAccessPolicy> fieldAccessPolicy) const;\n\n    /*!\n     *  Check if the access restrictions of the field access policy are valid.\n     *\n     *    @param [in] fieldAccessPolicy   The selected field access policy.\n     *\n     *    @return True, if the access restrictions are valid, otherwise false.\n     */\n    bool hasValidAccessRestrictions(QSharedPointer<FieldAccessPolicy> fieldAccessPolicy, \n        QSharedPointer<QList<QSharedPointer<Mode> > > availableModes) const;\n\n    /*!\n     *  Find errors within the field access policy definition reference.\n     *\n     *    @param [in] errors                  List of found errors.\n     *    @param [in] fieldAccessPolicy       The selected field access policy.\n     *    @param [in] context                 Context to help locate the error.\n     */\n    void finderrorsInDefinitionRef(QStringList& errors, QSharedPointer<FieldAccessPolicy> fieldAccessPolicy, \n        QString const& context) const;\n\n    /*!\n     *  Find errors within the access value.\n     *\n     *    @param [in] errors                  List of found errors.\n     *    @param [in] fieldAccessPolicy       The selected field access policy.\n     *    @param [in] context                 Context to help locate the error.\n     */\n    void findErrorsInAccess(QStringList& errors, QSharedPointer<FieldAccessPolicy> fieldAccessPolicy, \n        QString const& context) const;\n\n    /*!\n     *  Find errors within the write value constraint.\n     *\n     *    @param [in] errors                  List of found errors.\n     *    @param [in] fieldAccessPolicy       The selected field access policy.\n     *    @param [in] context                 Context to help locate the error.\n     */\n    void findErrorsInWriteValueConstraint(QStringList& errors, QSharedPointer<FieldAccessPolicy> fieldAccessPolicy, \n        QString const& context) const;\n\n    /*!\n     *  Find errors in the read response value.\n     *\n     *    @param [in] errors                  List of found errors.\n     *    @param [in] fieldAccessPolicy       The selected field access policy.\n     *    @param [in] context                 Context to help locate the error.\n     */\n    void findErrorsInReadResponse(QStringList& errors, QSharedPointer<FieldAccessPolicy> fieldAccessPolicy, \n        QString const& context) const;\n\n    /*!\n     *  Find errors in the broadcasts of the field access policy.\n     *\n     *    @param [in] errors                  List of found errors.\n     *    @param [in] fieldAccessPolicy       The selected field access policy.\n     *    @param [in] context                 Context to help locate the error.\n     */\n    void findErrorsInBroadcasts(QStringList& errors, QSharedPointer<FieldAccessPolicy> fieldAccessPolicy, \n        QString const& context) const;\n\n    /*!\n     *  Find errors in the access restrictions of the field access policy.\n     *\n     *    @param [in] errors                  List of found errors.\n     *    @param [in] fieldAccessPolicy       The selected field access policy.\n     *    @param [in] context                 Context to help locate the error.\n     */\n    void findErrorsInAccessRestrictions(QStringList& errors, QSharedPointer<FieldAccessPolicy> fieldAccessPolicy,\n        QString const& context, QSharedPointer<QList<QSharedPointer<Mode> > > availableModes) const;\n\n    /*!\n     *  Find errors in the reserved value.\n     *\n     *    @param [in] errors                  List of found errors.\n     *    @param [in] fieldAccessPolicy       The selected field access policy.\n     *    @param [in] context                 Context to help locate the error.\n     */\n    void findErrorsInReserved(QStringList& errors, QSharedPointer<FieldAccessPolicy> fieldAccessPolicy, \n        QString const& context) const;\n\n    /*!\n     *\tCheck if a given bit expression is valid.\n     *  \n     *    @param [in] expression     The given bit expression.\n     *\t    \n     * \t    @return True, if the expression is valid, otherwise false.\n     */\n    bool isBitExpressionValid(QString const& expression) const;\n\n    //! The expression parser to use.\n    QSharedPointer<ExpressionParser> expressionParser_;\n};\n\n#endif // FIELDACCESSPOLICYVALIDATOR_H\n\n"
  },
  {
    "path": "IPXACTmodels/Component/validators/FieldReferenceValidator.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: FieldReferenceValidator.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Anton Hagqvist\n// Date: 3.8.2023\n//\n// Description:\n// Validator for field reference group.\n//-----------------------------------------------------------------------------\n\n#include \"FieldReferenceValidator.h\"\n\n//-----------------------------------------------------------------------------\n// Function: FieldReferenceValidator::validate()\n//-----------------------------------------------------------------------------\nbool FieldReferenceValidator::validate(QSharedPointer<FieldReference> fieldReference)\n{\n    if (fieldReference->getReference(FieldReference::ADDRESS_SPACE) &&\n        (fieldReference->getReference(FieldReference::MEMORY_MAP) ||\n            fieldReference->getReference(FieldReference::MEMORY_REMAP)))\n    {\n        return false;\n    }\n\n    if (!fieldReference->getReference(FieldReference::FIELD))\n    {\n        return false;\n    }\n\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: FieldReferenceValidator::findErrorsIn()\n//-----------------------------------------------------------------------------\nvoid FieldReferenceValidator::findErrorsIn(QStringList& errorList, QSharedPointer<FieldReference> fieldReference, QString const& context)\n{\n    if (fieldReference->getReference(FieldReference::ADDRESS_SPACE) &&\n        (fieldReference->getReference(FieldReference::MEMORY_MAP) ||\n            fieldReference->getReference(FieldReference::MEMORY_REMAP)))\n    {\n        errorList.append(QObject::tr(\"Field reference in %1 cannot contain both an address space reference\"\n            \" and a memory map or memory remap reference.\").arg(context));\n    }\n\n    if (!fieldReference->getReference(FieldReference::FIELD))\n    {\n        errorList.append(QObject::tr(\"Field reference in %1 must contain a reference to a field.\").arg(context));\n    }\n}\n"
  },
  {
    "path": "IPXACTmodels/Component/validators/FieldReferenceValidator.h",
    "content": "//-----------------------------------------------------------------------------\n// File: FieldReferenceValidator.h\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Anton Hagqvist\n// Date: 3.8.2023\n//\n// Description:\n// Validator for field reference group.\n//-----------------------------------------------------------------------------\n\n#ifndef FIELDREFERENCEVALIDATOR_H\n#define FIELDREFERENCEVALIDATOR_H\n\n#include <IPXACTmodels/ipxactmodels_global.h>\n\n#include <IPXACTmodels/Component/FieldReference.h>\n\n#include <QObject>\n\nnamespace FieldReferenceValidator\n{\n    /*!\n     *  Validates the given field reference.\n     *\n     *    @param [in] fieldReference   The field reference to validate.\n     *\n     *    @return True, if the field is valid IP-XACT, otherwise false.\n     */\n    IPXACTMODELS_EXPORT bool validate(QSharedPointer<FieldReference> fieldReference);\n\n    /*!\n     *  Locate errors within a field reference.\n     *\n     *    @param [in] errors              List of found errors.\n     *    @param [in] fieldReference      The selected field reference.\n     *    @param [in] context             Context to help locate the error.\n     */\n    IPXACTMODELS_EXPORT void findErrorsIn(QStringList& errorList, QSharedPointer<FieldReference> fieldReference, QString const& context);\n\n}\n\n#endif // FIELDREFERENCEVALIDATOR_H\n"
  },
  {
    "path": "IPXACTmodels/Component/validators/FieldSliceValidator.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: FieldSliceValidator.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Esko Pekkarinen\n// Date: 07.09.2023\n//\n// Description:\n// Validator for ipxact:fieldSlice.\n//-----------------------------------------------------------------------------\n\n#include \"FieldSliceValidator.h\"\n\n#include <KactusAPI/include/ExpressionParser.h>\n\n#include <IPXACTmodels/Component/FieldSlice.h>\n#include <IPXACTmodels/Component/Component.h>\n#include <IPXACTmodels/Component/AddressSpace.h>\n#include <IPXACTmodels/Component/MemoryMap.h>\n#include <IPXACTmodels/Component/AddressBlock.h>\n#include <IPXACTmodels/Component/Register.h>\n#include <IPXACTmodels/Component/Field.h>\n\n#include <IPXACTmodels/common/validators/CommonItemsValidator.h>\n\n\n#include <QStringList>\n\n//-----------------------------------------------------------------------------\n// Function: FieldSliceValidator::FieldSliceValidator()\n//-----------------------------------------------------------------------------\nFieldSliceValidator::FieldSliceValidator(QSharedPointer<Component> component, \n\tQSharedPointer<ExpressionParser> expressionParser):\n\tcomponent_(component),\nexpressionParser_(expressionParser)\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: FieldSliceValidator::~FieldSliceValidator()\n//-----------------------------------------------------------------------------\nFieldSliceValidator::~FieldSliceValidator()\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: FieldSliceValidator::validate()\n//-----------------------------------------------------------------------------\nbool FieldSliceValidator::validate(QSharedPointer<FieldSlice> fieldSlice) const\n{\n    return hasValidName(fieldSlice->name()) &&\n        hasValidFieldReference(fieldSlice)  &&\n        hasValidLeftRange(fieldSlice) &&\n        hasValidRightRange(fieldSlice);\n}\n\n//-----------------------------------------------------------------------------\n// Function: FieldSliceValidator::hasValidLeftRange()\n//-----------------------------------------------------------------------------\nbool FieldSliceValidator::hasValidLeftRange(QSharedPointer<FieldSlice> fieldSlice) const\n{\n    if (fieldSlice->getLeft().isEmpty() == false && fieldSlice->getRight().isEmpty())\n    {\n        return false;\n    }\n\n    if (fieldSlice->getLeft().isEmpty())\n    {\n        return true;\n    }\n\n    auto field = findField(fieldSlice);\n    if (field.isNull())\n    {\n        return false;\n    }\n\n\n    int lsb = expressionParser_->parseExpression(field->getBitOffset()).toInt();\n    int msb = lsb + expressionParser_->parseExpression(field->getBitWidth()).toInt() - 1;\n\n    return isInValidRange(fieldSlice->getLeft(), msb, lsb);\n}\n\n//-----------------------------------------------------------------------------\n// Function: FieldSliceValidator::hasValidRightRange()\n//-----------------------------------------------------------------------------\nbool FieldSliceValidator::hasValidRightRange(QSharedPointer<FieldSlice> fieldSlice) const\n{\n    if (fieldSlice->getRight().isEmpty() == false && fieldSlice->getLeft().isEmpty())\n    {\n        return false;\n    }\n\n    if (fieldSlice->getRight().isEmpty())\n    {\n        return true;\n    }\n\n    auto field = findField(fieldSlice);\n    if (field.isNull())\n    {\n        return false;\n    }\n\n    int lsb = expressionParser_->parseExpression(field->getBitOffset()).toInt();\n    int msb = lsb + expressionParser_->parseExpression(field->getBitWidth()).toInt() - 1;\n\n    return isInValidRange(fieldSlice->getRight(), msb, lsb);\n}\n\n//-----------------------------------------------------------------------------\n// Function: FieldSliceValidator::hasValidFieldReference()\n//-----------------------------------------------------------------------------\nbool FieldSliceValidator::hasValidFieldReference(QSharedPointer<FieldSlice> fieldSlice) const\n{\n    auto field = findField(fieldSlice);\n\n    return field.isNull() == false;\n}\n\n//-----------------------------------------------------------------------------\n// Function: FieldSliceValidator::hasValidName()\n//-----------------------------------------------------------------------------\nbool FieldSliceValidator::hasValidName(QString const& name) const\n{\n\treturn CommonItemsValidator::hasValidName(name);\n}\n\n//-----------------------------------------------------------------------------\n// Function: FieldSliceValidator::findErrorsIn()\n//-----------------------------------------------------------------------------\nvoid FieldSliceValidator::findErrorsIn(QVector<QString>& errors, QSharedPointer<FieldSlice> fieldSlice,\n    QString const& context) const\n{\n    if (hasValidName(fieldSlice->name()) == false)\n    {\n        errors.append(QObject::tr(\"Invalid name '%1' set for field condition within %2.\").arg(\n            fieldSlice->name(), context));\n    }\n\n    if (hasValidFieldReference(fieldSlice) == false)\n    {\n        errors.append(QObject::tr(\"Field reference in condition '%1' is not valid in %2.\").arg(\n            fieldSlice->name(), context));\n    }\n\n    if (hasValidLeftRange(fieldSlice) == false)\n    {\n        errors.append(QObject::tr(\"Left range in field condition '%1' is not valid in %2.\").arg(\n            fieldSlice->name(), context));\n    }\n\n    if (hasValidRightRange(fieldSlice) == false)\n    {\n        errors.append(QObject::tr(\"Right range in field condition '%1' is not valid in %2.\").arg(\n            fieldSlice->name(), context));\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: FieldSliceValidator::componentChange()\n//-----------------------------------------------------------------------------\nvoid FieldSliceValidator::componentChange(QSharedPointer<Component> newComponent)\n{\n\tcomponent_ = newComponent;\n}\n\n//-----------------------------------------------------------------------------\n// Function: FieldSliceValidator::setExpressionParser()\n//-----------------------------------------------------------------------------\nvoid FieldSliceValidator::setExpressionParser(QSharedPointer<ExpressionParser> expressionParser)\n{\n    expressionParser_ = expressionParser;\n}\n\n//-----------------------------------------------------------------------------\n// Function: FieldSliceValidator::isInValidRange()\n//-----------------------------------------------------------------------------\nbool FieldSliceValidator::isInValidRange(QString const& value, int leftBound, int rightBound) const\n{\n    bool validExpression = false;\n    auto leftRange = expressionParser_->parseExpression(value, &validExpression).toInt();\n\n    return validExpression && (rightBound <= leftRange && leftRange <= leftBound);\n}\n\n//-----------------------------------------------------------------------------\n// Function: FieldSliceValidator::findField()\n//-----------------------------------------------------------------------------\nQSharedPointer<Field> FieldSliceValidator::findField(QSharedPointer<FieldSlice> fieldSlice) const\n{\n    auto addressSpace = findItem(fieldSlice->getReference(FieldReference::ADDRESS_SPACE),\n        component_->getAddressSpaces());\n\n    QSharedPointer<MemoryMapBase> memoryMap = nullptr;\n    if (addressSpace)\n    {\n        memoryMap = addressSpace->getLocalMemoryMap();\n    }\n    else\n    {\n        memoryMap = findItem(fieldSlice->getReference(FieldReference::MEMORY_MAP), component_->getMemoryMaps());\n    }\n\n    if (memoryMap.isNull())\n    {\n        return nullptr;\n    }\n\n    auto addressBlock = findItem(fieldSlice->getReference(FieldReference::ADDRESS_BLOCK),\n        memoryMap->getMemoryBlocks());\n    if (addressBlock.isNull())\n    {\n        return nullptr;\n    }\n\n    auto reg = findItem(fieldSlice->getReference(FieldReference::REGISTER),\n        addressBlock.dynamicCast<AddressBlock>()->getRegisterData());\n    if (reg.isNull())\n    {\n        return nullptr;\n    }\n\n    auto field = findItem(fieldSlice->getReference(FieldReference::FIELD),\n        reg.dynamicCast<Register>()->getFields());\n\n    return field;\n}\n"
  },
  {
    "path": "IPXACTmodels/Component/validators/FieldSliceValidator.h",
    "content": "//-----------------------------------------------------------------------------\n// File: FieldSliceValidator.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Esko Pekkarinen\n// Date: 07.09.2023\n//\n// Description:\n// Validator for ipxact:fieldSlice.\n//-----------------------------------------------------------------------------\n\n#ifndef FIELDSLICEVALIDATOR_H\n#define FIELDSLICEVALIDATOR_H\n\n#include <IPXACTmodels/ipxactmodels_global.h>\n\n#include <IPXACTmodels/Component/FieldSlice.h>\n#include <IPXACTmodels/Component/Field.h>\n#include <IPXACTmodels/Component/Component.h>\n\n#include <IPXACTmodels/utilities/Search.h>\n\n#include <QSharedPointer>\n#include <QString>\n#include <QVector>\n\nclass ExpressionParser;\n\n//-----------------------------------------------------------------------------\n//! Validator for ipxact:portSlice.\n//-----------------------------------------------------------------------------\nclass IPXACTMODELS_EXPORT FieldSliceValidator\n{\npublic:\n\n\t/*!\n     *  The constructor.\n     * \n     *    @param [in] component      The component containing the FieldSlices.\n     *    @param [in] FieldSlice           The expression parser for solving expressions in FieldSlices.\n\t *\n\t */\n    FieldSliceValidator(QSharedPointer<Component> component, QSharedPointer<ExpressionParser> expressionParser);\n\n\t//! The destructor.\n\tvirtual ~FieldSliceValidator();\n    \n\t// Disable copying.\n\tFieldSliceValidator(FieldSliceValidator const& rhs) = delete;\n\tFieldSliceValidator& operator=(FieldSliceValidator const& rhs) = delete;\n\n    /*!\n     *  Validates the given port slice.\n     *\n     *    @param [in] FieldSlice           The port slice to validate.\n     *\n     *    @return True, if the FieldSlice is valid IP-XACT, otherwise false.\n     */\n    bool validate(QSharedPointer<FieldSlice> portSlice) const;\n\n    /*!\n     *  Validates the port reference in the given port slice.\n     *\n     *    @param [in] portSlice           The port slice to validate.\n     *\n     *    @return True, if the portSlice is has a valid port reference, otherwise false.\n     */\n    bool hasValidFieldReference(QSharedPointer<FieldSlice> portSlice) const;\n\n    /*!\n     *  Validates the left range in the given port slice.\n     *\n     *    @param [in] portSlice           The port slice to validate.\n     *\n     *    @return True, if the portSlice is has a valid left range, otherwise false.\n     */\n    bool hasValidLeftRange(QSharedPointer<FieldSlice> portSlice) const;\n\n    /*!\n     *  Validates the right range in the given port slice.\n     *\n     *    @param [in] portSlice           The port slice to validate.\n     *\n     *    @return True, if the portSlice is has a valid right range, otherwise false.\n     */\n    bool hasValidRightRange(QSharedPointer<FieldSlice> portSlice) const;\n\n    /*!\n     *  Check if the portSlice name is valid.\n     *\n     *    @param [in] name    The name to be evaluated.\n     *\n     *    @return True, if the name is valid, otherwise false.\n     */\n    bool hasValidName(QString const& name) const;\n\n    /*!\n     *  Finds possible errors in a FieldSlice and creates a list of them.\n     *\n     *    @param [in] errors      List of found errors.\n     *    @param [in] FieldSlice        The FieldSlice whose errors to find.\n     *    @param [in] context     Context to help locate the errors.\n     */\n    void findErrorsIn(QVector<QString>& errors, QSharedPointer<FieldSlice> portSlice, QString const& context) const;\n\n    /*!\n     *  Change the active component.\n     *\n     *    @param [in] newComponent    List of found errors.\n     */\n    void componentChange(QSharedPointer<Component> newComponent);\n\n    /*!\n     *\tSet the expression parser to be used.\n     *\n     *    @param [in] expressionParser     The expression parser to set.\n     */\n    void setExpressionParser(QSharedPointer<ExpressionParser> expressionParser);\n\nprivate:\n\n    /* Check if the given value is in the given range.\n     *\n     *    @param [in] value        The value to be evaluated.\n     *    @param [in] leftBound    The left bound of the range.\n     *    @param [in] rightBound   The right bound of the range.\n     *\n     *    @return True, if the value is in the range, otherwise false.\n     */\n    bool isInValidRange(QString const& value, int leftBound, int rightBound) const;\n\n    /*!\n     *  Find the field referenced in the field slice.\n     *\n     *    @param [in] fieldSlice  The field slice whose referenced field to find.\n     *\n     *    @return The referenced field.\n     */\n    QSharedPointer<Field> findField(QSharedPointer<FieldSlice> fieldSlice) const;\n\n\n    /*!\n     *  Find a referenced item.\n     *\n     *    @param [in] reference   The reference to the item.\n     *    @param [in] container   The container to search in.\n     *\n     *    @return The referenced item, if found.\n     */\n    template <typename T>\n    QSharedPointer<T> findItem(QSharedPointer<FieldReference::IndexedReference> reference,\n        QSharedPointer<QList<QSharedPointer<T> > > container) const\n    {\n        if (reference.isNull() || reference->reference_.isEmpty())\n        {\n            return nullptr;\n        }\n\n        return Search::findByName(reference->reference_, *container);\n    }\n\n    //! The component containing the FieldSlices.\n    QSharedPointer<Component> component_ = nullptr;\n\n    //! The expression parser to use.\n    QSharedPointer<ExpressionParser> expressionParser_;\n\n};\n\n#endif // FIELDSLICEVALIDATOR_H\n"
  },
  {
    "path": "IPXACTmodels/Component/validators/FieldValidator.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: FieldValidator.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 17.11.2015\r\n//\r\n// Description:\r\n// Validator for ipxact:Field.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"FieldValidator.h\"\r\n#include \"FieldAccessPolicyValidator.h\"\r\n\r\n#include <KactusAPI/include/ExpressionParser.h>\r\n\r\n#include <IPXACTmodels/Component/Component.h>\r\n#include <IPXACTmodels/common/Parameter.h>\r\n#include <IPXACTmodels/common/validators/ParameterValidator.h>\r\n#include <IPXACTmodels/common/validators/CommonItemsValidator.h>\r\n#include <IPXACTmodels/Component/Field.h>\r\n#include <IPXACTmodels/Component/validators/MemoryArrayValidator.h>\r\n#include <IPXACTmodels/Component/EnumeratedValue.h>\r\n#include <IPXACTmodels/Component/WriteValueConstraint.h>\r\n#include <IPXACTmodels/Component/FieldReset.h>\r\n#include <IPXACTmodels/Component/ResetType.h>\r\n#include <IPXACTmodels/Component/Mode.h>\r\n#include <IPXACTmodels/Component/validators/EnumeratedValueValidator.h>\r\n\r\n#include <QRegularExpression>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FieldValidator::FieldValidator()\r\n//-----------------------------------------------------------------------------\r\nFieldValidator::FieldValidator(QSharedPointer<ExpressionParser> expressionParser,\r\n    QSharedPointer<EnumeratedValueValidator> enumeratedValueValidator,\r\n    QSharedPointer<ParameterValidator> parameterValidator,\r\n    Document::Revision docRevision):\r\nHierarchicalValidator(),\r\nexpressionParser_(expressionParser),\r\nenumeratedValueValidator_(enumeratedValueValidator),\r\nparameterValidator_(parameterValidator),\r\ndocRevision_(docRevision)\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FieldValidator::componentChange()\r\n//-----------------------------------------------------------------------------\r\nvoid FieldValidator::componentChange(QSharedPointer<Component> newComponent)\r\n{\r\n    availableResetTypes_.clear();\r\n    if (newComponent)\r\n    {\r\n        availableResetTypes_ = newComponent->getResetTypes();\r\n        docRevision_ = newComponent->getRevision();\r\n        componentModes_ = newComponent->getModes();\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FieldValidator::getEnumeratedValueValidator()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<EnumeratedValueValidator> FieldValidator::getEnumeratedValueValidator() const\r\n{\r\n    return enumeratedValueValidator_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FieldValidator::validate()\r\n//-----------------------------------------------------------------------------\r\nbool FieldValidator::validate(QSharedPointer<Field> field) const\r\n{\r\n    if (docRevision_ == Document::Revision::Std14)\r\n    {\r\n        return validComparedToSiblings(field) && hasValidName(field) && hasValidIsPresent(field) && \r\n            hasValidBitOffset(field) && hasValidResets(field) &&\r\n            hasValidWriteValueConstraint(field) && hasValidReserved(field) && hasValidBitWidth(field) &&\r\n            hasValidEnumeratedValues(field) && hasValidParameters(field) && hasValidAccess(field);\r\n    }\r\n    else if (docRevision_ == Document::Revision::Std22)\r\n    {\r\n        FieldAccessPolicyValidator fieldAccessPolicyValidator(expressionParser_);\r\n\r\n        for (auto const& fieldAccessPolicy : *field->getFieldAccessPolicies())\r\n        {\r\n            if (!fieldAccessPolicyValidator.validate(fieldAccessPolicy, componentModes_))\r\n            {\r\n                return false;\r\n            }\r\n        }\r\n\r\n        // Check mode refs of all field access policies. Priority and reference must both be unique between\r\n        // all field access policies.\r\n        if (!hasValidFieldAccessPolicyModeRefs(field))\r\n        {\r\n            return false;\r\n        }\r\n\r\n        return validComparedToSiblings(field) && hasValidName(field) && hasValidMemoryArray(field) && \r\n            hasValidBitOffset(field) && hasValidResets(field) &&\r\n            hasValidWriteValueConstraint(field) && hasValidReserved(field) && hasValidBitWidth(field) &&\r\n            hasValidEnumeratedValues(field) && hasValidParameters(field) && hasValidAccess(field) &&\r\n            hasValidStructure(field);\r\n    }\r\n\r\n    return true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FieldValidator::hasValidName()\r\n//-----------------------------------------------------------------------------\r\nbool FieldValidator::hasValidName(QSharedPointer<Field> field) const\r\n{\r\n    QRegularExpression whiteSpaceExpression;\r\n    whiteSpaceExpression.setPattern(QStringLiteral(\"^\\\\s*$\"));\r\n    QRegularExpressionMatch whiteSpaceMatch = whiteSpaceExpression.match(field->name());\r\n\r\n    if (field->name().isEmpty() || whiteSpaceMatch.hasMatch())\r\n    {\r\n        return false;\r\n    }\r\n\r\n    return true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FieldValidator::hasValidIsPresent()\r\n//-----------------------------------------------------------------------------\r\nbool FieldValidator::hasValidIsPresent(QSharedPointer<Field> field) const\r\n{\r\n    if (!field->getIsPresent().isEmpty())\r\n    {\r\n        QString solvedValue = expressionParser_->parseExpression(field->getIsPresent());\r\n\r\n        bool toIntOk = true;\r\n        int intValue = solvedValue.toInt(&toIntOk);\r\n\r\n        if (!toIntOk || intValue < 0 || intValue > 1)\r\n        {\r\n            return false;\r\n        }\r\n    }\r\n\r\n    return true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FieldValidator::hasValidMemoryArray()\r\n//-----------------------------------------------------------------------------\r\nbool FieldValidator::hasValidMemoryArray(QSharedPointer<Field> field) const\r\n{\r\n    if (auto memArray = field->getMemoryArray(); memArray)\r\n    {\r\n        MemoryArrayValidator validator(expressionParser_);\r\n        return validator.validate(field->getMemoryArray());\r\n    }\r\n    \r\n    return true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FieldValidator::hasValidBitOffset()\r\n//-----------------------------------------------------------------------------\r\nbool FieldValidator::hasValidBitOffset(QSharedPointer<Field> field) const\r\n{\r\n    QString solvedValue = expressionParser_->parseExpression(field->getBitOffset());\r\n\r\n    bool changeOk = true;\r\n    solvedValue.toULongLong(&changeOk);\r\n\r\n    return changeOk;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FieldValidator::hasValidResetTypeReference()\r\n//-----------------------------------------------------------------------------\r\nbool FieldValidator::hasValidResetTypeReference(QSharedPointer<FieldReset> fieldReset) const\r\n{\r\n    if (fieldReset->getResetTypeReference().isEmpty())\r\n    {\r\n        return true;\r\n    }\r\n\r\n    else if (availableResetTypes_)\r\n    {\r\n        for (auto resetType : *availableResetTypes_)\r\n        {\r\n            if (resetType->name() == fieldReset->getResetTypeReference())\r\n            {\r\n                return true;\r\n            }\r\n        }\r\n    }\r\n\r\n    return false;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FieldValidator::hasValidResetValue()\r\n//-----------------------------------------------------------------------------\r\nbool FieldValidator::hasValidResetValue(QSharedPointer<FieldReset> fieldReset) const\r\n{\r\n    if (fieldReset->getResetValue().isEmpty() == false)\r\n    {\r\n        return isBitExpressionValid(fieldReset->getResetValue());\r\n    }\r\n    else if (fieldReset->getResetValue().isEmpty() &&\r\n        (!fieldReset->getResetTypeReference().isEmpty() || !fieldReset->getResetMask().isEmpty()))\r\n    {\r\n        return false;\r\n    }\r\n\r\n    return true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FieldValidator::hasValidResetMask()\r\n//-----------------------------------------------------------------------------\r\nbool FieldValidator::hasValidResetMask(QSharedPointer<FieldReset> fieldReset) const\r\n{\r\n    if (fieldReset->getResetMask().isEmpty())\r\n    {\r\n        return true;\r\n    }\r\n    else\r\n    {\r\n        return isBitExpressionValid(fieldReset->getResetMask());\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FieldValidator::hasValidWriteValueConstraint()\r\n//-----------------------------------------------------------------------------\r\nbool FieldValidator::hasValidWriteValueConstraint(QSharedPointer<Field> field) const\r\n{\r\n    if (field->getWriteConstraint())\r\n    {\r\n        QSharedPointer<WriteValueConstraint> writeConstraint = field->getWriteConstraint();\r\n\r\n        if (writeConstraint->getType() == WriteValueConstraint::TYPE_COUNT)\r\n        {\r\n            return false;\r\n        }\r\n        else if (writeConstraint->getType() == WriteValueConstraint::MIN_MAX)\r\n        {\r\n            int minimumInt = expressionParser_->parseExpression(writeConstraint->getMinimum()).toInt();\r\n            int maximumInt = expressionParser_->parseExpression(writeConstraint->getMaximum()).toInt();\r\n\r\n            return !writeConstraint->getMinimum().isEmpty() && !writeConstraint->getMaximum().isEmpty() &&\r\n                isBitExpressionValid(writeConstraint->getMinimum()) &&\r\n                isBitExpressionValid(writeConstraint->getMaximum()) &&\r\n                minimumInt <= maximumInt;\r\n        }\r\n    }\r\n\r\n    return true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FieldValidator::hasValidReserved()\r\n//-----------------------------------------------------------------------------\r\nbool FieldValidator::hasValidReserved(QSharedPointer<Field> field) const\r\n{\r\n    if (!field->getReserved().isEmpty())\r\n    {\r\n        bool isValidReserved = false;\r\n        QString solvedValue = expressionParser_->parseExpression(field->getReserved(), &isValidReserved);\r\n        bool canConvert = false;\r\n        int intValue = solvedValue.toInt(&canConvert);\r\n\r\n        if (isValidReserved == false || canConvert ==false || intValue < 0 || intValue > 1)\r\n        {\r\n            return false;\r\n        }\r\n    }\r\n\r\n    return true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FieldValidator::hasValidBitWidth()\r\n//-----------------------------------------------------------------------------\r\nbool FieldValidator::hasValidBitWidth(QSharedPointer<Field> field) const\r\n{\r\n    if (field->getFieldDefinitionRef().isEmpty())\r\n    {\r\n        QString solvedValue = expressionParser_->parseExpression(field->getBitWidth());\r\n\r\n        bool changeOk = true;\r\n        quint64 intValue = solvedValue.toULongLong(&changeOk);\r\n\r\n        if (changeOk && intValue > 0)\r\n        {\r\n            return true;\r\n        }\r\n\r\n        return false;\r\n    }\r\n\r\n    return true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FieldValidator::hasValidEnumeratedValues()\r\n//-----------------------------------------------------------------------------\r\nbool FieldValidator::hasValidEnumeratedValues(QSharedPointer<Field> field) const\r\n{\r\n    if (!field->getEnumeratedValues()->isEmpty())\r\n    {\r\n        QStringList enumeratedValueNames;\r\n\r\n        bool constraintUsesEnums = false;\r\n        if (field->getWriteConstraint())\r\n        {\r\n            if (field->getWriteConstraint()->getType() == WriteValueConstraint::USE_ENUM)\r\n            {\r\n                constraintUsesEnums = true;\r\n            }\r\n        }\r\n\r\n        bool enumerationWriteUsage = false;\r\n        for (QSharedPointer<EnumeratedValue> const& enumeratedValue : *field->getEnumeratedValues())\r\n        {\r\n            if (!enumerationWriteUsage && constraintUsesEnums &&\r\n                (enumeratedValue->getUsage() == EnumeratedValue::WRITE ||\r\n                enumeratedValue->getUsage() == EnumeratedValue::READWRITE))\r\n            {\r\n                enumerationWriteUsage = true;\r\n            }\r\n\r\n            if (!enumeratedValueValidator_->validate(enumeratedValue) ||\r\n                enumeratedValueNames.contains(enumeratedValue->name()))\r\n            {\r\n                return false;\r\n            }\r\n            else\r\n            {\r\n                enumeratedValueNames.append(enumeratedValue->name());\r\n            }\r\n        }\r\n\r\n        if (constraintUsesEnums && !enumerationWriteUsage)\r\n        {\r\n            return false;\r\n        }\r\n    }\r\n\r\n    return true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FieldValidator::hasValidParameters()\r\n//-----------------------------------------------------------------------------\r\nbool FieldValidator::hasValidParameters(QSharedPointer<Field> field) const\r\n{\r\n    if (!field->getParameters()->isEmpty())\r\n    {\r\n        QStringList parameterNames;\r\n\r\n        for (QSharedPointer<Parameter> const& parameter : *field->getParameters())\r\n        {\r\n            if (parameterNames.contains(parameter->name()) || !parameterValidator_->validate(parameter))\r\n            {\r\n                return false;\r\n            }\r\n            else\r\n            {\r\n                parameterNames.append(parameter->name());\r\n            }\r\n        }\r\n    }\r\n\r\n    return true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FieldValidator::hasValidAccess()\r\n//-----------------------------------------------------------------------------\r\nbool FieldValidator::hasValidAccess(QSharedPointer<Field> field) const\r\n{\r\n    if (field->getAccess() == AccessTypes::READ_ONLY)\r\n    {\r\n        return field->getModifiedWrite() == General::MODIFIED_WRITE_COUNT;\r\n    }\r\n    else if (field->getAccess() == AccessTypes::WRITE_ONLY || field->getAccess() == AccessTypes::WRITEONCE)\r\n    {\r\n        return field->getReadAction() == General::READ_ACTION_COUNT;\r\n    }\r\n    return true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FieldValidator::hasValidFieldDefinitionRef()\r\n//-----------------------------------------------------------------------------\r\nbool FieldValidator::hasValidFieldDefinitionRef(QSharedPointer<Field> field) const\r\n{\r\n    if (!field->getFieldDefinitionRef().isEmpty() && field->getTypeDefinitionsRef().isEmpty())\r\n    {\r\n        return false;\r\n    }\r\n\r\n    return true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FieldValidator::hasValidStructure()\r\n//-----------------------------------------------------------------------------\r\nbool FieldValidator::hasValidStructure(QSharedPointer<Field> field) const\r\n{\r\n    if (field->getFieldDefinitionRef().isEmpty())\r\n    {\r\n        return hasValidReferenceResetChoice(field);\r\n    }\r\n    else\r\n    {\r\n        if (field->getTypeIdentifier().isEmpty() == false ||\r\n            field->getFieldAccessPolicies()->isEmpty() == false ||\r\n            field->getEnumeratedValues()->isEmpty() == false ||\r\n            field->getBitWidth().isEmpty() == false ||\r\n            field->getVolatile().toString() == QStringLiteral(\"true\") ||\r\n            field->getResets()->isEmpty() == false ||\r\n            field->getFieldReference())\r\n        {\r\n            return false;\r\n        }\r\n    }\r\n\r\n    return true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FieldValidator::findErrorsIn()\r\n//-----------------------------------------------------------------------------\r\nvoid FieldValidator::findErrorsIn(QVector<QString>& errors, QSharedPointer<Field> field, QString const& context)\r\n    const\r\n{\r\n    findErrorsInName(errors, field, context);\r\n    findErrorsInIsPresent(errors, field, context);\r\n    findErrorsInBitOffset(errors, field, context);\r\n    findErrorsInResets(errors, field, context);\r\n    findErrorsInEnumeratedValues(errors, field);\r\n    findErrorsInParameters(errors, field);\r\n\r\n    if (docRevision_ == Document::Revision::Std14)\r\n    {\r\n        findErrorsInWriteValueConstraint(errors, field, context);\r\n        findErrorsInReserved(errors, field, context);\r\n        findErrorsInAccess(errors, field, context);\r\n        findErrorsInBitWidth(errors, field, context);\r\n    }\r\n    else if (docRevision_ == Document::Revision::Std22)\r\n    {\r\n        auto newContext = QStringLiteral(\"field \") + field->name() + QStringLiteral(\" within \") + context;\r\n\r\n        findErrorsInMemoryArray(errors, field, newContext);\r\n        findErrorsInFieldDefinitionRef(errors, field, context);\r\n\r\n        FieldAccessPolicyValidator fieldAccessPolicyValidator(expressionParser_);\r\n        \r\n        for (auto const& fieldAccessPolicy : *field->getFieldAccessPolicies())\r\n        {\r\n            fieldAccessPolicyValidator.findErrorsIn(errors, fieldAccessPolicy, newContext, componentModes_);\r\n        }\r\n\r\n        findErrorsInModeRefs(errors, field, newContext);\r\n\r\n        findErrorsInStructure(errors, field, context);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FieldValidator::findErrorsInName()\r\n//-----------------------------------------------------------------------------\r\nvoid FieldValidator::findErrorsInName(QVector<QString>& errors, QSharedPointer<Field> field,\r\n    QString const& context) const\r\n{\r\n    if (!hasValidName(field))\r\n    {\r\n        errors.append(QObject::tr(\"Invalid name specified for %1 within %2\").arg(field->name(), context));\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FieldValidator::findErrorsInIsPresent()\r\n//-----------------------------------------------------------------------------\r\nvoid FieldValidator::findErrorsInIsPresent(QVector<QString>& errors, QSharedPointer<Field> field,\r\n    QString const& context) const\r\n{\r\n    if (!hasValidIsPresent(field))\r\n    {\r\n        errors.append(QObject::tr(\"Invalid isPresent value specified for %1 within %2. Value should evaluate to \"\r\n            \"0 or 1.\").\r\n            arg(field->name()).arg(context));\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FieldValidator::findErrorsInMemoryArray()\r\n//-----------------------------------------------------------------------------\r\nvoid FieldValidator::findErrorsInMemoryArray(QVector<QString>& errors, QSharedPointer<Field> field,\r\n    QString const& context) const\r\n{\r\n    MemoryArrayValidator validator(expressionParser_);\r\n    if (auto memArray = field->getMemoryArray(); memArray)\r\n    {\r\n        validator.findErrorsIn(errors, field->getMemoryArray(), context);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FieldValidator::findErrorsInBitOffset()\r\n//-----------------------------------------------------------------------------\r\nvoid FieldValidator::findErrorsInBitOffset(QVector<QString>& errors, QSharedPointer<Field> field,\r\n    QString const& context) const\r\n{\r\n    if (!hasValidBitOffset(field))\r\n    {\r\n        errors.append(QObject::tr(\"Invalid bit offset set for field %1 within %2\").arg(field->name()).arg(context));\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FieldValidator::findErrorsInResets()\r\n//-----------------------------------------------------------------------------\r\nvoid FieldValidator::findErrorsInResets(QVector<QString>& errors, QSharedPointer<Field> field,\r\n    QString const& context) const\r\n{\r\n    QString resetContext = QStringLiteral(\"field %1 in %2\").arg(field->name(), context);\r\n\r\n    if (!hasValidResetsTypeReferences(field))\r\n    {\r\n        errors.append(QObject::tr(\"Multiple references to default reset type in %1.\").arg(resetContext));\r\n    }\r\n\r\n    for (auto fieldReset : *field->getResets())\r\n    {\r\n        findErrorsInResetTypeReference(errors, fieldReset, resetContext);\r\n        findErrorsInResetValue(errors, fieldReset, resetContext);\r\n        findErrorsInResetMask(errors, fieldReset, resetContext);\r\n    }\r\n}\r\n\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FieldValidator::findErrorsInResetTypeReference()\r\n//-----------------------------------------------------------------------------\r\nvoid FieldValidator::findErrorsInResetTypeReference(QVector<QString>& errors,\r\n    QSharedPointer<FieldReset> fieldReset, QString const& context) const\r\n{\r\n    if (!hasValidResetTypeReference(fieldReset))\r\n    {\r\n        errors.append(QObject::tr(\"Reset type '%1' referenced in %2 does not exist.\")\r\n            .arg(fieldReset->getResetTypeReference()).arg(context));\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FieldValidator::findErrorsInResetValue()\r\n//-----------------------------------------------------------------------------\r\nvoid FieldValidator::findErrorsInResetValue(QVector<QString>& errors, QSharedPointer<FieldReset> fieldReset,\r\n    QString const& context) const\r\n{\r\n    if (!hasValidResetValue(fieldReset))\r\n    {\r\n        errors.append(QObject::tr(\"Invalid reset value set within %1\").arg(context));\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FieldValidator::findErrorsInResetMask()\r\n//-----------------------------------------------------------------------------\r\nvoid FieldValidator::findErrorsInResetMask(QVector<QString>& errors, QSharedPointer<FieldReset> fieldReset,\r\n    QString const& context) const\r\n{\r\n    if (!hasValidResetMask(fieldReset))\r\n    {\r\n        errors.append(QObject::tr(\"Invalid reset mask set within %1\").arg(context));\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FieldValidator::findErrorsInWriteValueConstraint()\r\n//-----------------------------------------------------------------------------\r\nvoid FieldValidator::findErrorsInWriteValueConstraint(QVector<QString>& errors, QSharedPointer<Field> field,\r\n    QString const& context) const\r\n{\r\n    if (!hasValidWriteValueConstraint(field))\r\n    {\r\n        QSharedPointer<WriteValueConstraint> writeConstaint = field->getWriteConstraint();\r\n        if (writeConstaint->getType() == WriteValueConstraint::TYPE_COUNT)\r\n        {\r\n            errors.append(QObject::tr(\"Invalid write value constraint set for field %1 within %2\").\r\n                arg(field->name()).arg(context));\r\n        }\r\n        else\r\n        {\r\n            bool minimumIsValid = isBitExpressionValid(writeConstaint->getMinimum());\r\n            bool maximumIsValid = isBitExpressionValid(writeConstaint->getMaximum());\r\n\r\n            if (!minimumIsValid)\r\n            {\r\n                errors.append(QObject::tr(\r\n                    \"Invalid minimum value set for write value constraint in field %1 within %2\").\r\n                    arg(field->name()).arg(context));\r\n            }\r\n            if (!maximumIsValid)\r\n            {\r\n                errors.append(QObject::tr(\r\n                    \"Invalid maximum value set for write value constraint in field %1 within %2\").\r\n                    arg(field->name()).arg(context));\r\n            }\r\n\r\n            if (minimumIsValid && maximumIsValid)\r\n            {\r\n                int minimumInt = expressionParser_->parseExpression(writeConstaint->getMinimum()).toInt();\r\n                int maximumInt = expressionParser_->parseExpression(writeConstaint->getMaximum()).toInt();\r\n\r\n                if (minimumInt > maximumInt)\r\n                {\r\n                    errors.append(QObject::tr(\r\n                        \"Maximum value must be greater than or equal to the minimum value in write value \"\r\n                        \"constraint set for field %1 within %2\").arg(field->name()).arg(context));\r\n                }\r\n            }\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FieldValidator::findErrorsInReserved()\r\n//-----------------------------------------------------------------------------\r\nvoid FieldValidator::findErrorsInReserved(QVector<QString>& errors, QSharedPointer<Field> field,\r\n    QString const& context) const\r\n{\r\n    if (!hasValidReserved(field))\r\n    {\r\n        errors.append(QObject::tr(\"Invalid reserved set for field %1 within %2\").arg(field->name()).arg(context));\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FieldValidator::findErrorsInBitWidth()\r\n//-----------------------------------------------------------------------------\r\nvoid FieldValidator::findErrorsInBitWidth(QVector<QString>& errors, QSharedPointer<Field> field,\r\n    QString const& context) const\r\n{\r\n    if (!hasValidBitWidth(field))\r\n    {\r\n        errors.append(QObject::tr(\"Invalid bit width set for field %1 within %2\").arg(field->name()).arg(context));\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FieldValidator::findErrorsInEnumeratedValues()\r\n//-----------------------------------------------------------------------------\r\nvoid FieldValidator::findErrorsInEnumeratedValues(QVector<QString>& errors, QSharedPointer<Field> field) const\r\n{\r\n    if (!field->getEnumeratedValues()->isEmpty())\r\n    {\r\n        QString context = QStringLiteral(\"field \") + field->name();\r\n\r\n        bool useEnumerations = false;\r\n        if (field->getWriteConstraint())\r\n        {\r\n            if (field->getWriteConstraint()->getType() == WriteValueConstraint::USE_ENUM)\r\n            {\r\n                useEnumerations = true;\r\n            }\r\n        }\r\n\r\n        bool writeEnumerationWasFound = false;\r\n        QStringList enumeratedValueNames;\r\n        for (QSharedPointer<EnumeratedValue> const& enumeratedValue : *field->getEnumeratedValues())\r\n        {\r\n            enumeratedValueValidator_->findErrorsIn(errors, enumeratedValue, context);\r\n\r\n            if (enumeratedValueNames.contains(enumeratedValue->name()))\r\n            {\r\n                errors.append(QObject::tr(\"Name %1 of enumerated values in %2 is not unique.\").\r\n                    arg(enumeratedValue->name()).arg(context));\r\n            }\r\n            else\r\n            {\r\n                enumeratedValueNames.append(enumeratedValue->name());\r\n            }\r\n\r\n            if (useEnumerations && !writeEnumerationWasFound &&\r\n                (enumeratedValue->getUsage() == EnumeratedValue::WRITE ||\r\n                enumeratedValue->getUsage() == EnumeratedValue::READWRITE))\r\n            {\r\n                writeEnumerationWasFound = true;\r\n            }\r\n        }\r\n\r\n        if (useEnumerations && !writeEnumerationWasFound)\r\n        {\r\n            errors.append(QObject::tr(\"Write value constraint of Use enumerated values needs an enumerated value \"\r\n                \"with usage of write or read-write. Such an enumerated value was not found in field %1\")\r\n                .arg(field->name()));\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FieldValidator::findErrorsInParameters()\r\n//-----------------------------------------------------------------------------\r\nvoid FieldValidator::findErrorsInParameters(QVector<QString>& errors, QSharedPointer<Field> field) const\r\n{\r\n    if (!hasValidParameters(field))\r\n    {\r\n        QString context = QStringLiteral(\"field \") + field->name();\r\n\r\n        QStringList parameterNames;\r\n        for (QSharedPointer<Parameter> const& parameter : *field->getParameters())\r\n        {\r\n            parameterValidator_->findErrorsIn(errors, parameter, context);\r\n\r\n            if (parameterNames.contains(parameter->name()))\r\n            {\r\n                errors.append(QObject::tr(\"Name %1 of parameters in %2 is not unique.\").arg(parameter->name()).\r\n                    arg(context));\r\n            }\r\n            else\r\n            {\r\n                parameterNames.append(parameter->name());\r\n            }\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FieldValidator::findErrorsInAccess()\r\n//-----------------------------------------------------------------------------\r\nvoid FieldValidator::findErrorsInAccess(QVector<QString>& errors, QSharedPointer<Field> field,\r\n    QString const& context) const\r\n{\r\n    if (field->getAccess() == AccessTypes::READ_ONLY)\r\n    {\r\n        if (field->getModifiedWrite() != General::MODIFIED_WRITE_COUNT)\r\n        {\r\n            errors.append(QObject::tr(\"In field %1 within %2, access type readOnly does not allow a field \"\r\n                \"to include a modified write value.\").arg(field->name()).arg(context));\r\n        }\r\n    }\r\n    else if (field->getAccess() == AccessTypes::WRITE_ONLY || field->getAccess() == AccessTypes::WRITEONCE)\r\n    {\r\n        if (field->getReadAction() != General::READ_ACTION_COUNT)\r\n        {\r\n            errors.append(QObject::tr(\"In field %1 within %2, access type write only and write once do not \"\r\n                \"allow a field to include a read action value.\").arg(field->name()).arg(context));\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FieldValidator::findErrorsInFieldDefinitionRef()\r\n//-----------------------------------------------------------------------------\r\nvoid FieldValidator::findErrorsInFieldDefinitionRef(QStringList& errors, QSharedPointer<Field> field, QString const& context) const\r\n{\r\n    if (!hasValidFieldDefinitionRef(field))\r\n    {\r\n        errors.append(QObject::tr(\"Field %1 within %2 has no typeDefinitions reference \"\r\n            \"defined for field definition reference.\").arg(field->name()).arg(context));\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FieldValidator::hasValidReferenceResetChoice()\r\n//-----------------------------------------------------------------------------\r\nbool FieldValidator::hasValidReferenceResetChoice(QSharedPointer<Field> field) const\r\n{\r\n    // Field can include bit width, volatility and resets OR field reference (aliasOf).\r\n    if ((field->getBitWidth().isEmpty() == false ||\r\n        field->getVolatile().toString() == QStringLiteral(\"true\") ||\r\n        field->getResets()->isEmpty() == false) &&\r\n        field->getFieldReference()) \r\n    {\r\n        return false;\r\n    }\r\n\r\n    // Field must have either bit width OR a field reference defined.\r\n    if (field->getBitWidth().isEmpty() && !field->getFieldReference())\r\n    {\r\n        return false;\r\n    }\r\n    \r\n    // Check bit width validity, if present.\r\n    if (field->getBitWidth().isEmpty() == false && hasValidBitWidth(field) == false)\r\n    {\r\n        return false;\r\n    }\r\n    \r\n    return true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FieldValidator::findErrorsInStructure()\r\n//-----------------------------------------------------------------------------\r\nvoid FieldValidator::findErrorsInStructure(QStringList& errors, QSharedPointer<Field> field, QString const& context) const\r\n{\r\n    if (field->getFieldDefinitionRef().isEmpty())\r\n    {\r\n        if (field->getFieldReference())\r\n        {\r\n            if (field->getBitWidth().isEmpty() == false || field->getVolatile().toBool() ||\r\n                field->getResets()->isEmpty() == false)\r\n            {\r\n                errors.append(QObject::tr(\"In field %1 within %2: Bit width, volatility, and resets must not be defined\"\r\n                    \" for a field containing a reference to another field.\").arg(field->name()).arg(context));\r\n            }\r\n        }\r\n        else\r\n        {\r\n            if (field->getBitWidth().isEmpty())\r\n            {\r\n                errors.append(QObject::tr(\"In field %1 within %2: Bit width must be defined when no field definition reference\"\r\n                    \" or field reference is defined.\").arg(field->name()).arg(context));\r\n            }\r\n        }\r\n    }\r\n    else\r\n    {\r\n        if (field->getTypeIdentifier().isEmpty() == false)\r\n        {\r\n            errors.append(QObject::tr(\"In field %1 within %2: Type identifier must not be defined for a field \"\r\n                \"with a field definition reference.\").arg(field->name()).arg(context));\r\n        }\r\n\r\n        if (field->getFieldAccessPolicies()->isEmpty() == false)\r\n        {\r\n            errors.append(QObject::tr(\"In field %1 within %2: No field access policies can be defined for a field \"\r\n                \"with a field definition reference.\").arg(field->name()).arg(context));\r\n        }\r\n\r\n        if (field->getEnumeratedValues()->isEmpty() == false)\r\n        {\r\n            errors.append(QObject::tr(\"In field %1 within %2: No enumerated values can be defined for a field \"\r\n                \"with a field definition reference.\").arg(field->name()).arg(context));\r\n        }\r\n\r\n        if (field->getBitWidth().isEmpty() == false)\r\n        {\r\n            errors.append(QObject::tr(\"In field %1 within %2: Bit width must not be defined for a field \"\r\n                \"with a field definition reference.\").arg(field->name()).arg(context));\r\n        }\r\n\r\n        if (field->getVolatile().toBool())\r\n        {\r\n            errors.append(QObject::tr(\"In field %1 within %2: Volatility must not be defined for a field \"\r\n                \"with a field definition reference.\").arg(field->name()).arg(context));\r\n        }\r\n\r\n        if (field->getResets()->isEmpty() == false)\r\n        {\r\n            errors.append(QObject::tr(\"In field %1 within %2: Field resets must not be defined for a field \"\r\n                \"with a field definition reference.\").arg(field->name()).arg(context));\r\n        }\r\n\r\n        if (field->getFieldReference())\r\n        {\r\n            errors.append(QObject::tr(\"In field %1 within %2: Field reference must not be defined for a field \"\r\n                \"with a field definition reference.\").arg(field->name()).arg(context));\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FieldValidator::findErrorsInModeRefs()\r\n//-----------------------------------------------------------------------------\r\nvoid FieldValidator::findErrorsInModeRefs(QStringList& errors, QSharedPointer<Field> field, QString const& context) const\r\n{\r\n    QString fieldAccessPolicyContext = QObject::tr(\"field %1 in %2\")\r\n        .arg(field->name()).arg(context);\r\n\r\n    // Slice field access policies, we only need their mode references.\r\n    QSharedPointer<QList<QSharedPointer<AccessPolicy> > > fieldAccessPoliciesSliced(new QList<QSharedPointer<AccessPolicy> >());\r\n    for (auto const& fieldAP : *field->getFieldAccessPolicies())\r\n    {\r\n        fieldAccessPoliciesSliced->append(fieldAP);\r\n    }\r\n\r\n    CommonItemsValidator::findErrorsInAccessPolicies(errors, fieldAccessPoliciesSliced, componentModes_, fieldAccessPolicyContext);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FieldValidator::hasValidResets()\r\n//-----------------------------------------------------------------------------\r\nbool FieldValidator::hasValidResets(QSharedPointer<Field> field) const\r\n{\r\n    if (!hasValidResetsTypeReferences(field))\r\n    {\r\n        return false;\r\n    }\r\n\r\n    for (auto fieldReset : *field->getResets())\r\n    {\r\n        if (!hasValidResetValue(fieldReset) || !hasValidResetMask(fieldReset) ||\r\n            !hasValidResetTypeReference(fieldReset))\r\n        {\r\n            return false;\r\n        }\r\n    }\r\n\r\n    return true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FieldValidator::hasValidResetsTypeReferences()\r\n//-----------------------------------------------------------------------------\r\nbool FieldValidator::hasValidResetsTypeReferences(QSharedPointer<Field> field) const\r\n{\r\n    for (int i = 0; i < field->getResets()->size(); ++i)\r\n    {\r\n        QSharedPointer<FieldReset> fieldReset = field->getResets()->at(i);\r\n        if (fieldReset->getResetTypeReference().isEmpty())\r\n        {\r\n            for (int j = i + 1; j < field->getResets()->size(); ++j)\r\n            {\r\n                if (field->getResets()->at(j)->getResetTypeReference().isEmpty())\r\n                {\r\n                    return false;\r\n                }\r\n            }\r\n        }\r\n    }\r\n\r\n    return true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FieldValidator::validateBitExpression()\r\n//-----------------------------------------------------------------------------\r\nbool FieldValidator::isBitExpressionValid(QString const& expression) const\r\n{\r\n    QString solvedValue = expressionParser_->parseExpression(expression);\r\n\r\n    QRegularExpression bitExpression(QStringLiteral(\"^([0-9]+|[1-9]+[0-9]*'([bB][01_]+|[hH][0-9a-fA-F_]+))$\"));\r\n    return bitExpression.match(expression).hasMatch() || bitExpression.match(solvedValue).hasMatch();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FieldValidator::hasValidAccessPolicyModeRefs()\r\n//-----------------------------------------------------------------------------\r\nbool FieldValidator::hasValidFieldAccessPolicyModeRefs(QSharedPointer<Field> field) const\r\n{\r\n    // Slice field access policies, we only need their mode references.\r\n    QSharedPointer<QList<QSharedPointer<AccessPolicy> > > fieldAccessPoliciesSliced(new QList<QSharedPointer<AccessPolicy> >());\r\n    for (auto const& fieldAP : *field->getFieldAccessPolicies())\r\n    {\r\n        fieldAccessPoliciesSliced->append(fieldAP);\r\n    }\r\n\r\n    return CommonItemsValidator::hasValidAccessPolicies(fieldAccessPoliciesSliced, componentModes_);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FieldValidator::singleFieldAccessPolicyHasValidModeRefs()\r\n//-----------------------------------------------------------------------------\r\nbool FieldValidator::singleFieldAccessPolicyHasValidModeRefs(QSharedPointer<Field> field, \r\n    int fieldAccessPolicyIndex) const\r\n{\r\n    auto fieldAccessPolicies = field->getFieldAccessPolicies();\r\n\r\n    if (fieldAccessPolicyIndex < 0 || fieldAccessPolicyIndex >= fieldAccessPolicies->size())\r\n    {\r\n        return false;\r\n    }\r\n\r\n    QSharedPointer<QList<QSharedPointer<ModeReference> > > otherModeRefs(new QList<QSharedPointer<ModeReference> >());\r\n\r\n    for (int i = 0; i < fieldAccessPolicies->size(); ++i)\r\n    {\r\n        auto currentAccessPolicy = fieldAccessPolicies->at(i);\r\n        if (i != fieldAccessPolicyIndex)\r\n        {\r\n            otherModeRefs->append(currentAccessPolicy->getModeReferences()->begin(),\r\n                currentAccessPolicy->getModeReferences()->end());\r\n        }\r\n    }\r\n\r\n    return CommonItemsValidator::hasValidModeRefs(fieldAccessPolicies->at(fieldAccessPolicyIndex)->getModeReferences(),\r\n        otherModeRefs, componentModes_);\r\n}\r\n"
  },
  {
    "path": "IPXACTmodels/Component/validators/FieldValidator.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: FieldValidator.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 17.11.2015\r\n//\r\n// Description:\r\n// Validator for ipxact:Field.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef FIELDVALIDATOR_H\r\n#define FIELDVALIDATOR_H\r\n\r\n#include <IPXACTmodels/ipxactmodels_global.h>\r\n\r\n#include <IPXACTmodels/Component/Field.h>\r\n\r\n#include <IPXACTmodels/common/Document.h>\r\n\r\n#include <IPXACTmodels/common/validators/HierarchicalValidator.h>\r\n\r\n#include <QSharedPointer>\r\n#include <QString>\r\n\r\nclass ExpressionParser;\r\nclass Field;\r\nclass FieldReset;\r\nclass ResetType;\r\nclass ParameterValidator;\r\nclass EnumeratedValueValidator;\r\nclass Component;\r\nclass Mode;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Validator for ipxact:Field.\r\n//-----------------------------------------------------------------------------\r\nclass IPXACTMODELS_EXPORT FieldValidator : public HierarchicalValidator\r\n{\r\npublic:\r\n\r\n    /*!\r\n     *  The constructor.\r\n     *\r\n     *    @param [in] expressionParser            The parser used to solve expressions.\r\n     *    @param [in] enumeratedValueValidator    Validator used for enumerated values.\r\n     *    @param [in] parameterValidator          Validator used for parameters.\r\n     */\r\n    FieldValidator(QSharedPointer<ExpressionParser> expressionParser,\r\n        QSharedPointer<EnumeratedValueValidator> enumeratedValueValidator,\r\n        QSharedPointer<ParameterValidator> parameterValidator,\r\n        Document::Revision docRevision = Document::Revision::Std14);\r\n\r\n\t/*!\r\n     *  The destructor.\r\n     */\r\n\t~FieldValidator() = default;\r\n\r\n    // Disable copying.\r\n    FieldValidator(FieldValidator const& rhs) = delete;\r\n    FieldValidator& operator=(FieldValidator const& rhs) = delete;\r\n\r\n    /*!\r\n     *  Change the containing component.\r\n     *\r\n     *    @param [in] newComponent    The selected component.\r\n     */\r\n    void componentChange(QSharedPointer<Component> newComponent);\r\n\r\n    /*!\r\n     *  Get the validator used for enumerated values.\r\n     *\r\n     *    @return The validator used for enumerated values.\r\n     */\r\n    QSharedPointer<EnumeratedValueValidator> getEnumeratedValueValidator() const;\r\n\r\n    /*!\r\n     *  Validates the given field.\r\n     *\r\n     *    @param [in] field   The field to validate.\r\n     *\r\n     *    @return True, if the field is valid IP-XACT, otherwise false.\r\n     */\r\n    bool validate(QSharedPointer<Field> field) const;\r\n\r\n    /*!\r\n     *  Check if the field contains a valid name.\r\n     *\r\n     *    @param [in] field   The selected field.\r\n     *\r\n     *    @return True, if the name is valid, otherwise false.\r\n     */\r\n    bool hasValidName(QSharedPointer<Field> field) const;\r\n\r\n    /*!\r\n     *  Check if the field has a valid presence value.\r\n     *\r\n     *    @param [in] field   The selected field.\r\n     *\r\n     *    @return True, if the isPresent is valid, otherwise false.\r\n     */\r\n    bool hasValidIsPresent(QSharedPointer<Field> field) const;\r\n\r\n    /*!\r\n     *\tCheck if the field has a valid memory array.\r\n     *  \r\n     *    @param [in] field     The selected field.\r\n     *\t    \r\n     * \t    @return True, if the memory array is valid, otherwise false.\r\n     */\r\n    bool hasValidMemoryArray(QSharedPointer<Field> field) const;\r\n\r\n    /*!\r\n     *  Check if the field has a valid bit offset.\r\n     *\r\n     *    @param [in] field   The selected field.\r\n     *\r\n     *    @return True, if the bit offset is valid, otherwise false.\r\n     */\r\n    bool hasValidBitOffset(QSharedPointer<Field> field) const;\r\n\r\n    /*!\r\n     *  Check if the resets within the field are valid.\r\n     *\r\n     *    @param [in] field  The field whose resets to check\r\n     *\r\n     *    @return True, if all resets are valid, otherwise false.\r\n     */\r\n    bool hasValidResets(QSharedPointer<Field> field) const;\r\n\r\n    /*!\r\n    *  Check if the reset type references within a field are valid.\r\n    *\r\n    *    @param [in] field     The selected field.\r\n    *\r\n    *    @return True, if all reset type references are valid, otherwise false.\r\n    */\r\n    bool hasValidResetsTypeReferences(QSharedPointer<Field> field) const;\r\n\r\n    /*!\r\n     *  Check if the selected reset type reference is valid.\r\n     *\r\n     *    @param [in] fieldReset   Reset containing the selected reset type reference.\r\n     *\r\n     *    @return True, if the reset type reference is valid.\r\n     */\r\n    bool hasValidResetTypeReference(QSharedPointer<FieldReset> fieldReset) const;\r\n\r\n    /*!\r\n     *  Check if the field has a valid reset value.\r\n     *\r\n     *    @param [in] fieldReset   The selected field reset.\r\n     *\r\n     *    @return True, if the reset value is valid, otherwise false.\r\n     */\r\n    bool hasValidResetValue(QSharedPointer<FieldReset> fieldReset) const;\r\n\r\n    /*!\r\n     *  Check if the field has a valid reset mask.\r\n     *\r\n     *    @param [in] field   The selected field reset.\r\n     *\r\n     *    @return True, if the reset mask is valid, otherwise false.\r\n     */\r\n    bool hasValidResetMask(QSharedPointer<FieldReset> fieldReset) const;\r\n\r\n    /*!\r\n     *  Check if the field has a valid write value constraint.\r\n     *\r\n     *    @param [in] field   The selected field.\r\n     *\r\n     *    @return True, if the write value constraint is valid, otherwise false.\r\n     */\r\n    bool hasValidWriteValueConstraint(QSharedPointer<Field> field) const;\r\n\r\n    /*!\r\n     *  Check if the field has a valid reserved value.\r\n     *\r\n     *    @param [in] field   The selected field.\r\n     *\r\n     *    @return True, if the reserved is valid, otherwise false.\r\n     */\r\n    bool hasValidReserved(QSharedPointer<Field> field) const;\r\n\r\n    /*!\r\n     *  Check if the field has a valid bit width.\r\n     *\r\n     *    @param [in] field   The selected field.\r\n     *\r\n     *    @return True, if the bit width is valid, otherwise false.\r\n     */\r\n    bool hasValidBitWidth(QSharedPointer<Field> field) const;\r\n\r\n    /*!\r\n     *  Check if the field has valid enumerated values.\r\n     *\r\n     *    @param [in] field   The selected field.\r\n     *\r\n     *    @return True, if the enumerated values are valid, otherwise false.\r\n     */\r\n    bool hasValidEnumeratedValues(QSharedPointer<Field> field) const;\r\n\r\n    /*!\r\n     *  Check if the field has valid parameters.\r\n     *\r\n     *    @param [in] field   The selected field.\r\n     *\r\n     *    @return True, if the parameters are valid, otherwise false.\r\n     */\r\n    bool hasValidParameters(QSharedPointer<Field> field) const;\r\n\r\n    /*!\r\n     *  Check if the field has a valid access value.\r\n     *\r\n     *    @param [in] field   The selected field.\r\n     *\r\n     *    @return True, if the access is valid, otherwise false.\r\n     */\r\n    bool hasValidAccess(QSharedPointer<Field> field) const;\r\n\r\n    /*!\r\n     *\tCheck if the field has a valid field definition reference.\r\n     *  \r\n     *    @param [in] field     The field to check.\r\n     *\t    \r\n     * \t    @return True, if the field definition reference is valid, otherwise false.\r\n     */\r\n    bool hasValidFieldDefinitionRef(QSharedPointer<Field> field) const;\r\n\r\n    /*!\r\n     *\tChecks that the field has a valid combination of data for 2022 standard.\r\n     *  \r\n     *    @param [in] field     The field to check.\r\n     *\t    \r\n     * \t    @return True, if the field structure is valid, otherwise false.\r\n     */\r\n    bool hasValidStructure(QSharedPointer<Field> field) const;\r\n\r\n    /*!\r\n     *\tChecks that the field has valid mode references in its field access policies.\r\n     *\r\n     *    @param [in] field     The field to check.\r\n     *\r\n     * \t    @return True, if the field mode references valid, otherwise false.\r\n     */\r\n    bool hasValidFieldAccessPolicyModeRefs(QSharedPointer<Field> field) const;\r\n\r\n    /*!\r\n     *\tValidate the mode references of a single field access policy against mode references of other field access\r\n     *  policies. For validation in UI.\r\n     *  \r\n     *    @param [in] field                   The field containing the field access policy.\r\n     *    @param [in] fieldAccessPolicy       The field access policy whose mode referneces are checked.\r\n     *\t    \r\n     * \t    @return True, if the mode references are valid, otherwise false.\r\n     */\r\n    bool singleFieldAccessPolicyHasValidModeRefs(QSharedPointer<Field> field, int fieldAccessPolicyIndex) const;\r\n\r\n    /*!\r\n     *  Locate errors within a field.\r\n     *\r\n     *    @param [in] errors      List of found errors.\r\n     *    @param [in] field       The selected field.\r\n     *    @param [in] context     Context to help locate the error.\r\n     */\r\n    void findErrorsIn(QVector<QString>& errors, QSharedPointer<Field> field, QString const& context) const;\r\n\r\nprivate:\r\n\r\n    /*!\r\n     *  Find errors within field name.\r\n     *\r\n     *    @param [in] errors      List of found errors.\r\n     *    @param [in] field       The selected field.\r\n     *    @param [in] context     Context to help locate the error.\r\n     */\r\n    void findErrorsInName(QVector<QString>& errors, QSharedPointer<Field> field, QString const& context) const;\r\n\r\n    /*!\r\n     *  Find errors within field is present.\r\n     *\r\n     *    @param [in] errors      List of found errors.\r\n     *    @param [in] field       The selected field.\r\n     *    @param [in] context     Context to help locate the error.\r\n     */\r\n    void findErrorsInIsPresent(QVector<QString>& errors, QSharedPointer<Field> field, QString const& context) const;\r\n\r\n    /*!\r\n     *\tFind errors within the memory array of the field.\r\n     *  \r\n     *    @param [in] errors      List of found errors.\r\n     *    @param [in] field       The selected field.\r\n     *    @param [in] context     Context to help locate the error.\r\n     */\r\n    void findErrorsInMemoryArray(QVector<QString>& errors, QSharedPointer<Field> field, QString const& context) const;\r\n\r\n    /*!\r\n     *  Find errors within field bit offset.\r\n     *\r\n     *    @param [in] errors      List of found errors.\r\n     *    @param [in] field       The selected field.\r\n     *    @param [in] context     Context to help locate the error.\r\n     */\r\n    void findErrorsInBitOffset(QVector<QString>& errors, QSharedPointer<Field> field, QString const& context) const;\r\n\r\n    /*!\r\n     *  Find errors within resets.\r\n     *\r\n     *    @param [in] errors      List of found errors.\r\n     *    @param [in] field       The selected field.\r\n     *    @param [in] context     Context to help locate the errors.\r\n     */\r\n    void findErrorsInResets(QVector<QString>& errors, QSharedPointer<Field> field, QString const& context) const;\r\n\r\n    /*!\r\n     *  Find errors within reset type reference.\r\n     *\r\n     *    @param [in] errors      List of found errors.\r\n     *    @param [in] fieldReset  The selected reset.\r\n     *    @param [in] context     Context to help locate the errors.\r\n     */\r\n    void findErrorsInResetTypeReference(QVector<QString>& errors, QSharedPointer<FieldReset> fieldReset,\r\n        QString const& context) const;\r\n\r\n    /*!\r\n     *  Find errors within field reset value.\r\n     *\r\n     *    @param [in] errors      List of found errors.\r\n     *    @param [in] fieldReset  The selected field reset.\r\n     *    @param [in] context     Context to help locate the error.\r\n     */\r\n    void findErrorsInResetValue(QVector<QString>& errors, QSharedPointer<FieldReset> fieldReset,\r\n        QString const& context) const;\r\n\r\n    /*!\r\n     *  Find errors within field reset mask.\r\n     *\r\n     *    @param [in] errors      List of found errors.\r\n     *    @param [in] fieldReset  The selected field reset.\r\n     *    @param [in] context     Context to help locate the error.\r\n     */\r\n    void findErrorsInResetMask(QVector<QString>& errors, QSharedPointer<FieldReset> fieldReset,\r\n        QString const& context) const;\r\n\r\n    /*!\r\n     *  Find errors within field write value constraint.\r\n     *\r\n     *    @param [in] errors      List of found errors.\r\n     *    @param [in] field       The selected field.\r\n     *    @param [in] context     Context to help locate the error.\r\n     */\r\n    void findErrorsInWriteValueConstraint(QVector<QString>& errors, QSharedPointer<Field> field,\r\n        QString const& context) const;\r\n\r\n    /*!\r\n     *  Find errors within field reserved value.\r\n     *\r\n     *    @param [in] errors      List of found errors.\r\n     *    @param [in] field       The selected field.\r\n     *    @param [in] context     Context to help locate the error.\r\n     */\r\n    void findErrorsInReserved(QVector<QString>& errors, QSharedPointer<Field> field, QString const& context) const;\r\n\r\n    /*!\r\n     *  Find errors within field bit width.\r\n     *\r\n     *    @param [in] errors      List of found errors.\r\n     *    @param [in] field       The selected field.\r\n     *    @param [in] context     Context to help locate the error.\r\n     */\r\n    void findErrorsInBitWidth(QVector<QString>& errors, QSharedPointer<Field> field, QString const& context) const;\r\n\r\n    /*!\r\n     *  Find errors within field enumerated values.\r\n     *\r\n     *    @param [in] errors      List of found errors.\r\n     *    @param [in] field       The selected field.\r\n     */\r\n    void findErrorsInEnumeratedValues(QVector<QString>& errors, QSharedPointer<Field> field) const;\r\n\r\n    /*!\r\n     *  Find errors within field parameters.\r\n     *\r\n     *    @param [in] errors      List of found errors.\r\n     *    @param [in] field       The selected field.\r\n     */\r\n    void findErrorsInParameters(QVector<QString>& errors, QSharedPointer<Field> field) const;\r\n\r\n    /*!\r\n     *  Find errors within field access.\r\n     *\r\n     *    @param [in] errors      List of found errors.\r\n     *    @param [in] field       The selected field.\r\n     *    @param [in] context     Context to help locate the error.\r\n     */\r\n    void findErrorsInAccess(QVector<QString>& errors, QSharedPointer<Field> field, QString const& context) const;\r\n\r\n    /*!\r\n     *\tFind errors within field definition reference.\r\n     *  \r\n     *    @param [in] errors     List of found errors.\r\n     *    @param [in] field      The selected field.\r\n     *    @param [in] context    Context to help locate the error.\r\n     */\r\n    void findErrorsInFieldDefinitionRef(QStringList& errors, QSharedPointer<Field> field, QString const& context) const;\r\n\r\n    /*!\r\n     *\tCheck if the field has a valid combination of bit width, volatility, resets and field reference.\r\n     *\r\n     *    @param [in] errors     List of found errors.\r\n     *    @param [in] field      The selected field.\r\n     *    @param [in] context    Context to help locate the error.\r\n     */\r\n    bool hasValidReferenceResetChoice(QSharedPointer<Field> field) const;\r\n\r\n    /*!\r\n     *\tFind errors in the combination of data set to the field (for standard revision 2022).\r\n     *  \r\n     *    @param [in] errors     List of found errors.\r\n     *    @param [in] field      The selected field.\r\n     *    @param [in] context    Context to help locate the error.\r\n     */\r\n    void findErrorsInStructure(QStringList& errors, QSharedPointer<Field> field, QString const& context) const;\r\n\r\n    /*!\r\n     *\tFind errors in the mode references of the field's field access policies.\r\n     *  \r\n     *    @param [in] errors     List of found errors.\r\n     *    @param [in] field      The selected field.\r\n     *    @param [in] context    Context to help locate the error.\r\n     */\r\n    void findErrorsInModeRefs(QStringList& errors, QSharedPointer<Field> field, QString const& context) const;\r\n\r\n    /*!\r\n     *  Check if the contained bit expression is valid.\r\n     *\r\n     *    @param [in] expression  The expression to check.\r\n     *\r\n     *    @return True, if the expression is a valid bit expression, otherwise false.\r\n     */\r\n    bool isBitExpressionValid(QString const& expression) const;\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! The expression parser to use.\r\n    QSharedPointer<ExpressionParser> expressionParser_;\r\n\r\n    //! The used enumerated value validator.\r\n    QSharedPointer<EnumeratedValueValidator> enumeratedValueValidator_;\r\n\r\n    //! The used parameter validator.\r\n    QSharedPointer<ParameterValidator> parameterValidator_;\r\n\r\n    //! The reset types of the containing component.\r\n    QSharedPointer<QList<QSharedPointer<ResetType> > > availableResetTypes_;\r\n\r\n    //! The IP-XACT standard revision in use.\r\n    Document::Revision docRevision_;\r\n\r\n    //! The available component modes.\r\n    QSharedPointer<QList<QSharedPointer<Mode> > > componentModes_;\r\n};\r\n\r\n#endif // FIELDVALIDATOR_H\r\n"
  },
  {
    "path": "IPXACTmodels/Component/validators/FileSetValidator.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// FileSet: FileSetValidator.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Janne Virtanen\r\n// Date: 20.11.2015\r\n//\r\n// Description:\r\n// Validator for ipxact:FileSet.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"FileSetValidator.h\"\r\n#include \"FileValidator.h\"\r\n\r\n#include <KactusAPI/include/ExpressionParser.h>\r\n\r\n#include <IPXACTmodels/common/Choice.h>\r\n#include <IPXACTmodels/common/Enumeration.h>\r\n#include <IPXACTmodels/common/FileBuilder.h>\r\n\r\n#include <QStringList>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SystemVerilogValidator::SystemVerilogValidator()\r\n//-----------------------------------------------------------------------------\r\nFileSetValidator::FileSetValidator(QSharedPointer<FileValidator> fileValidator,\r\n\tQSharedPointer<ExpressionParser> expressionParser) :\r\nHierarchicalValidator(),\r\nfileValidator_(fileValidator),\r\nexpressionParser_(expressionParser)\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileSetValidator::validate()\r\n//-----------------------------------------------------------------------------\r\nbool FileSetValidator::validate(QSharedPointer<FileSet> fileSet) const\r\n{\r\n\tif (!hasValidName( fileSet->name()))\r\n\t{\r\n\t\treturn false;\r\n\t}\r\n\r\n\tfor (QSharedPointer<FileBuilder> const& currentFileBuilder : *fileSet->getDefaultFileBuilders())\r\n\t{\r\n\t\tif (!hasValidName(currentFileBuilder->getFileType().type_) ||\r\n            !fileBuilderHasValidReplaceDefaultFlags(currentFileBuilder))\r\n\t\t{\r\n\t\t\treturn false;\r\n\t\t}\r\n\t}\r\n\r\n\tfor (QSharedPointer<File> const& file : *fileSet->getFiles())\r\n\t{\r\n\t\tif (!fileValidator_->validate(file))\r\n\t\t{\r\n\t\t\treturn false;\r\n\t\t}\r\n\t}\r\n\r\n\treturn validComparedToSiblings(fileSet);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileSetValidator::fileBuilderHasValidReplaceDefaultFlags()\r\n//-----------------------------------------------------------------------------\r\nbool FileSetValidator::fileBuilderHasValidReplaceDefaultFlags(QSharedPointer<FileBuilder> builder) const\r\n{\r\n    if (!builder->getReplaceDefaultFlags().isEmpty())\r\n    {\r\n        bool canConvert = true;\r\n        int replaceFlags =\r\n            expressionParser_->parseExpression(builder->getReplaceDefaultFlags()).toInt(&canConvert);\r\n\r\n        if (!canConvert || replaceFlags < 0 || replaceFlags > 1)\r\n        {\r\n            return false;\r\n        }\r\n    }\r\n\r\n    return true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileSetValidator::findErrorsIn()\r\n//-----------------------------------------------------------------------------\r\nvoid FileSetValidator::findErrorsIn(QVector<QString>& errors, QSharedPointer<FileSet> fileSet,\r\n    QString const& context) const\r\n{\r\n\tif (!hasValidName(fileSet->name()))\r\n\t{\r\n        errors.append(QObject::tr(\"Invalid name '%1' set for file set within %2\")\r\n            .arg(fileSet->name()).arg(context));\r\n\t}\r\n\r\n\tfor (QSharedPointer<FileBuilder> const& currentFileBuilder : *fileSet->getDefaultFileBuilders())\r\n\t{\r\n\t\tif (!hasValidName(currentFileBuilder->getFileType().type_))\r\n\t\t{\r\n\t\t\terrors.append(QObject::tr(\"The type of default file builder is empty within file set %1.\").arg(\r\n                fileSet->name()));\r\n\t\t}\r\n\r\n        if (!fileBuilderHasValidReplaceDefaultFlags(currentFileBuilder))\r\n\t\t{\r\n            errors.append(QObject::tr(\"Invalid \\\"replace default flags\\\" value set for file set %1. Value must \"\r\n                \"evaluate to 0 or 1.\").\r\n                arg(fileSet->name()));\r\n\t\t}\r\n\t}\r\n\r\n    QString filesetContext = QObject::tr(\"file set %1\").arg(fileSet->name());\r\n\tfor (QSharedPointer<File> const& file : *fileSet->getFiles())\r\n\t{\r\n\t\tfileValidator_->findErrorsIn(errors, file, filesetContext);\r\n\t}\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: EnumeratedValueValidator::hasValidName()\r\n//-----------------------------------------------------------------------------\r\nbool FileSetValidator::hasValidName(QString const& name) const\r\n{\r\n\treturn !(name.isEmpty() || name.trimmed().isEmpty());\r\n}\r\n"
  },
  {
    "path": "IPXACTmodels/Component/validators/FileSetValidator.h",
    "content": "//-----------------------------------------------------------------------------\r\n// FileSet: FileSetValidator.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Janne Virtanen\r\n// Date: 20.11.2015\r\n//\r\n// Description:\r\n// Validator for ipxact:FileSet.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef FileSetVALIDATOR_H\r\n#define FileSetVALIDATOR_H\r\n\r\n#include <IPXACTmodels/ipxactmodels_global.h>\r\n\r\n#include <IPXACTmodels/Component/FileSet.h>\r\n#include <IPXACTmodels/common/validators/HierarchicalValidator.h>\r\n\r\n#include <QString>\r\n#include <QVector>\r\n\r\nclass ExpressionParser;\r\nclass FileValidator;\r\nclass FileBuilder;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Validator for ipxact:FileSet.\r\n//-----------------------------------------------------------------------------\r\nclass IPXACTMODELS_EXPORT FileSetValidator : public HierarchicalValidator\r\n{\r\npublic:\r\n\r\n\t/*!\r\n\t *  The constructor.\r\n\t *\r\n\t */\r\n    FileSetValidator(QSharedPointer<FileValidator> fileValidator,\r\n        QSharedPointer<ExpressionParser> expressionParser);\r\n\r\n\t//! The destructor.\r\n\t~FileSetValidator() = default;\r\n\r\n    // Disable copying.\r\n    FileSetValidator(FileSetValidator const& rhs) = delete;\r\n    FileSetValidator& operator=(FileSetValidator const& rhs) = delete;\r\n\r\n    /*!\r\n     *  Validates the given FileSet.\r\n     *\r\n     *    @param [in] FileSet           The FileSet to validate.\r\n     *\r\n     *    @return True, if the FileSet is valid IP-XACT, otherwise false.\r\n     */\r\n    bool validate(QSharedPointer<FileSet> FileSet) const;\r\n    \r\n    /*!\r\n     *  Check if the name is valid.\r\n     *\r\n     *    @param [in] name    The name to be evaluated.\r\n     *\r\n     *    @return True, if the name is valid, otherwise false.\r\n     */\r\n    bool hasValidName(QString const& name) const;\r\n\r\n    /*!\r\n     *  Check if a file builder has a valid replace default flags value.\r\n     *\r\n     *    @param [in] builder     The selected file builder.\r\n     *\r\n     *    @return True, if the replace default flags valie is valid, false otherwise.\r\n     */\r\n    bool fileBuilderHasValidReplaceDefaultFlags(QSharedPointer<FileBuilder> builder) const;\r\n\r\n    /*!\r\n     *  Finds possible errors in a FileSet and creates a list of them.\r\n     *\r\n     *    @param [in] errors      List of found errors.\r\n     *    @param [in] FileSet   The FileSet whose errors to find.\r\n     *    @param [in] context     Context to help locate the errors.\r\n     */\r\n    void findErrorsIn(QVector<QString>& errors, QSharedPointer<FileSet> FileSet,\r\n\t\tQString const& context) const;\r\n\r\nprivate:\r\n\r\n    //! The used file validator.\r\n    QSharedPointer<FileValidator> fileValidator_;\r\n\r\n    //! The used expression parser.\r\n    QSharedPointer<ExpressionParser> expressionParser_;\r\n};\r\n\r\n#endif // SYSTEMVERILOGVALIDATOR_H\r\n"
  },
  {
    "path": "IPXACTmodels/Component/validators/FileValidator.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: FileValidator.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Janne Virtanen\r\n// Date: 20.11.2015\r\n//\r\n// Description:\r\n// Validator for ipxact:File.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"FileValidator.h\"\r\n\r\n#include <KactusAPI/include/ExpressionParser.h>\r\n\r\n#include <IPXACTmodels/Component/File.h>\r\n\r\n#include <IPXACTmodels/Component/BuildCommand.h>\r\n\r\n#include <QRegularExpression>\r\n#include <QStringList>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileValidator::FileValidator()\r\n//-----------------------------------------------------------------------------\r\nFileValidator::FileValidator(QSharedPointer<ExpressionParser> expressionParser):\r\nexpressionParser_(expressionParser)\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileValidator::~FileValidator()\r\n//-----------------------------------------------------------------------------\r\nFileValidator::~FileValidator()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileValidator::validate()\r\n//-----------------------------------------------------------------------------\r\nbool FileValidator::validate(QSharedPointer<File> file) const\r\n{\r\n\tif (!hasValidName(file->name()))\r\n\t{\r\n\t\treturn false;\r\n\t}\r\n\r\n    bool isValidPresence = false;\r\n    expressionParser_->parseExpression(file->getIsPresent(), &isValidPresence);\r\n\tif (isValidPresence == false)\r\n\t{\r\n\t\treturn false;\r\n\t}\r\n\t\r\n\tif (file->getFileTypes()->count() < 1)\r\n\t{\r\n\t\treturn false;\r\n\t}\r\n\r\n\tfor (QSharedPointer<NameValuePair> currentPair : *file->getDefines())\r\n\t{\r\n\t\tif (!hasValidName(currentPair->name()))\r\n\t\t{\r\n\t\t\treturn false;\r\n\t\t}\r\n\t}\r\n\r\n    if (file->getBuildCommand() && !buildCommandHasValidReplaceDefaultFlags(file->getBuildCommand()))\r\n    {\r\n        return false;\r\n    }\r\n\r\n\treturn true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileValidator::buildCommandHasValidReplaceDefaultFlags()\r\n//-----------------------------------------------------------------------------\r\nbool FileValidator::buildCommandHasValidReplaceDefaultFlags(QSharedPointer<BuildCommand> buildCommand) const\r\n{\r\n    if (!buildCommand->getReplaceDefaultFlags().isEmpty())\r\n    {\r\n        bool canConvert = true;\r\n        int replaceFlags =\r\n            expressionParser_->parseExpression(buildCommand->getReplaceDefaultFlags()).toInt(&canConvert);\r\n\r\n        if (!canConvert || replaceFlags < 0 || replaceFlags > 1)\r\n        {\r\n            return false;\r\n        }\r\n    }\r\n\r\n    return true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileValidator::findErrorsIn()\r\n//-----------------------------------------------------------------------------\r\nvoid FileValidator::findErrorsIn(QVector<QString>& errors, QSharedPointer<File> file,\r\n    QString const& context) const\r\n{\r\n\tif (!hasValidName(file->name()))\r\n\t{\r\n\t\terrors.append(QObject::tr(\"The file name '%1' is invalid within %2.\").arg(file->name(), context));\r\n\t}\r\n\r\n    bool isValidPresence = false;\r\n    expressionParser_->parseExpression(file->getIsPresent(), &isValidPresence);\r\n\tif (isValidPresence == false)\r\n\t{\r\n\t\terrors.append(QObject::tr(\"The presence '%1' is invalid in file %2.\").arg(file->getIsPresent(), \r\n            file->name()));\r\n\t}\r\n\r\n\tif (file->getFileTypes()->count() < 1)\r\n\t{\r\n\t\terrors.append(QObject::tr(\"File %1 must have at least one file type defined.\").arg(file->name()));\r\n\t}\r\n\r\n\tfor (QSharedPointer<NameValuePair> currentPair : *file->getDefines())\r\n\t{\r\n\t\tif (!hasValidName(currentPair->name()))\r\n\t\t{\r\n\t\t\terrors.append(QObject::tr(\"The name '%1' of a define is invalid within file %2.\").arg(\r\n                currentPair->name(), file->name()));\r\n\t\t}\r\n\t}\r\n\r\n    if (file->getBuildCommand() && !buildCommandHasValidReplaceDefaultFlags(file->getBuildCommand()))\r\n\t{\r\n        errors.append(QObject::tr(\"Invalid \\\"replace default flags\\\" value set for build command in file %1.\"\r\n            \" Value must evaluate to 0 or 1.\").\r\n            arg(file->name()));\r\n\t}\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileValidator::hasValidName()\r\n//-----------------------------------------------------------------------------\r\nbool FileValidator::hasValidName(QString const& name) const\r\n{\r\n\treturn !(name.isEmpty() || name.trimmed().isEmpty());\r\n}\r\n"
  },
  {
    "path": "IPXACTmodels/Component/validators/FileValidator.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: FileValidator.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Janne Virtanen\r\n// Date: 20.11.2015\r\n//\r\n// Description:\r\n// Validator for ipxact:File.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef FileVALIDATOR_H\r\n#define FileVALIDATOR_H\r\n\r\n#include <IPXACTmodels/ipxactmodels_global.h>\r\n\r\n#include <QSharedPointer>\r\n#include <QString>\r\n#include <QVector>\r\n\r\nclass ExpressionParser;\r\nclass File;\r\nclass BuildCommand;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Validator for ipxact:File.\r\n//-----------------------------------------------------------------------------\r\nclass IPXACTMODELS_EXPORT FileValidator\r\n{\r\npublic:\r\n\r\n\t/*!\r\n\t *  The constructor.\r\n\t *\r\n\t */\r\n    FileValidator(QSharedPointer<ExpressionParser> expressionParser);\r\n\r\n\t//! The destructor.\r\n\tvirtual ~FileValidator();\r\n    \r\n    /*!\r\n     *  Validates the given File.\r\n     *\r\n     *    @param [in] File           The File to validate.\r\n     *\r\n     *    @return True, if the File is valid IP-XACT, otherwise false.\r\n     */\r\n    virtual bool validate(QSharedPointer<File> file) const;\r\n\r\n    /*!\r\n     *  Check if the name is valid.\r\n     *\r\n     *    @param [in] name    The name to be evaluated.\r\n     *\r\n     *    @return True, if the name is valid, otherwise false.\r\n     */\r\n    bool hasValidName(QString const& name) const;\r\n\r\n    /*!\r\n     *  Check if a build command has a valid replace default flags value.\r\n     *\r\n     *    @param [in] buildCommand    The selected build command.\r\n     *\r\n     *    @return True, if the build command replace default flags is valid, false otherwise.\r\n     */\r\n    bool buildCommandHasValidReplaceDefaultFlags(QSharedPointer<BuildCommand> buildCommand) const;\r\n\r\n    /*!\r\n     *  Finds possible errors in a File and creates a list of them.\r\n     *\r\n     *    @param [in] errors      List of found errors.\r\n     *    @param [in] File   The File whose errors to find.\r\n     *    @param [in] context     Context to help locate the errors.\r\n     */\r\n    virtual void findErrorsIn(QVector<QString>& errors, QSharedPointer<File> file,\r\n\t\tQString const& context) const;\r\n\r\nprivate:\r\n    \r\n\t// Disable copying.\r\n\tFileValidator(FileValidator const& rhs);\r\n\tFileValidator& operator=(FileValidator const& rhs);\r\n\r\n    //! The expression parser to use.\r\n    QSharedPointer<ExpressionParser> expressionParser_;\r\n};\r\n\r\n#endif // SYSTEMVERILOGVALIDATOR_H\r\n"
  },
  {
    "path": "IPXACTmodels/Component/validators/IndirectInterfaceValidator.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: IndirectInterfaceValidator.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Esko Pekkarinen\n// Date: 10.08.2017\n//\n// Description:\n// Validator for ipxact:indirectInterface.\n//-----------------------------------------------------------------------------\n\n#include \"IndirectInterfaceValidator.h\"\n\n\n#include <IPXACTmodels/Component/AddressBlock.h>\n#include <IPXACTmodels/Component/BusInterface.h>\n#include <IPXACTmodels/Component/Component.h>\n#include <IPXACTmodels/Component/Field.h>\n#include <IPXACTmodels/Component/IndirectInterface.h>\n#include <IPXACTmodels/Component/MemoryBlockBase.h>\n#include <IPXACTmodels/Component/MemoryMap.h>\n#include <IPXACTmodels/Component/Register.h>\n#include <IPXACTmodels/Component/TransparentBridge.h>\n\n#include <IPXACTmodels/common/validators/ParameterValidator.h>\n\n#include <KactusAPI/include/ExpressionParser.h>\n\n#include <QRegularExpression>\n#include <QStringList>\n\n//-----------------------------------------------------------------------------\n// Function: IndirectInterfaceValidator::IndirectInterfaceValidator()\n//-----------------------------------------------------------------------------\nIndirectInterfaceValidator::IndirectInterfaceValidator(QSharedPointer<Component> component,\n    QSharedPointer<ExpressionParser> parser, QSharedPointer<ParameterValidator> parameterValidator): \nHierarchicalValidator(),\ncomponent_(component), expressionParser_(parser),\nparameterValidator_(parameterValidator)\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: IndirectInterfaceValidator::componentChange()\n//-----------------------------------------------------------------------------\nvoid IndirectInterfaceValidator::componentChange(QSharedPointer<Component> component)\n{\n    component_ = component;\n}\n\n//-----------------------------------------------------------------------------\n// Function: IndirectInterfaceValidator::validate()\n//-----------------------------------------------------------------------------\nbool IndirectInterfaceValidator::validate(QSharedPointer<IndirectInterface> indirectInterface) const\n{\n\treturn hasValidName(indirectInterface) && \n        hasValidAddressReference(indirectInterface) &&\n        hasValidDataReference(indirectInterface) &&\n        hasEitherMemoryMapReferenceOrTransparentBridge(indirectInterface) &&\n        hasValidMemoryMapReference(indirectInterface) &&\n        hasValidTransparentBridges(indirectInterface->getTransparentBridges()) &&\n        hasValidBitsInLau(indirectInterface) &&\n        hasValidEndianness(indirectInterface) &&\n        hasValidParameters(indirectInterface) &&\n        validComparedToSiblings(indirectInterface);\n}\n\n//-----------------------------------------------------------------------------\n// Function: IndirectInterfaceValidator::hasValidName()\n//-----------------------------------------------------------------------------\nbool IndirectInterfaceValidator::hasValidName(QSharedPointer<IndirectInterface> indirectInterface) const\n{\n    QRegularExpression whiteSpaceExpression(QStringLiteral(\"^\\\\s*$\"));\n    QRegularExpressionMatch whiteSpaceMatch = whiteSpaceExpression.match(indirectInterface->name());\n\n    return !indirectInterface->name().isEmpty() && !whiteSpaceMatch.hasMatch();\n}\n\n//-----------------------------------------------------------------------------\n// Function: IndirectInterfaceValidator::hasValidAddressReference()\n//-----------------------------------------------------------------------------\nbool IndirectInterfaceValidator::hasValidAddressReference(QSharedPointer<IndirectInterface> indirectInterface) const\n{\n    QSharedPointer<Field> addressField = findField(indirectInterface->getIndirectAddressRef());\n\n    return isValidFieldReference(indirectInterface->getIndirectAddressRef(), indirectInterface->getMemoryMapRef()) &&\n        addressField->getAccess() != AccessTypes::READ_ONLY &&\n        addressField->getAccess() != AccessTypes::READ_WRITEONCE &&\n        addressField->getAccess() != AccessTypes::WRITEONCE;\n}\n\n//-----------------------------------------------------------------------------\n// Function: IndirectInterfaceValidator::hasValidDataReference()\n//-----------------------------------------------------------------------------\nbool IndirectInterfaceValidator::hasValidDataReference(QSharedPointer<IndirectInterface> indirectInterface) const\n{\n    return isValidFieldReference(indirectInterface->getIndirectDataRef(), indirectInterface->getMemoryMapRef());\n}\n\n//-----------------------------------------------------------------------------\n// Function: IndirectInterfaceValidator::hasValidMemoryMapReference()\n//-----------------------------------------------------------------------------\nbool IndirectInterfaceValidator::hasValidMemoryMapReference(QSharedPointer<IndirectInterface> indirectInterface) const\n{\n    if (indirectInterface->getMemoryMapRef().isEmpty())\n    {\n        return true;\n    }\n\n    return std::any_of(component_->getMemoryMaps()->cbegin(), component_->getMemoryMaps()->cend(),\n        [&indirectInterface](auto const& map)\n        { return map->name().compare(indirectInterface->getMemoryMapRef()) == 0; });\n}\n\n//-----------------------------------------------------------------------------\n// Function: IndirectInterfaceValidator::hasValidTransparentBridges()\n//-----------------------------------------------------------------------------\nbool IndirectInterfaceValidator::hasValidTransparentBridges(\n    QSharedPointer<QList<QSharedPointer<TransparentBridge>>> bridges) const\n{\n    if (!bridges)\n    {\n        return true;\n    }\n\n    int foundInterfaces = 0;\n    for (QSharedPointer<TransparentBridge> const& bridge : *bridges)\n    {\n        for (QSharedPointer<BusInterface> const& busInterface : *component_->getBusInterfaces())\n        {\n            if (busInterface->name().compare(bridge->getMasterRef()) == 0 &&\n                busInterface->getInterfaceMode() == General::MASTER)\n            {\n                foundInterfaces++;\n                break;\n            }\n        }\n    }\n\n    return bridges->count() == foundInterfaces;\n}\n\n//-----------------------------------------------------------------------------\n// Function: IndirectInterfaceValidator::hasValidBitsInLau()\n//-----------------------------------------------------------------------------\nbool IndirectInterfaceValidator::hasValidBitsInLau(QSharedPointer<IndirectInterface> indirectInterface) const\n{\n    if (indirectInterface->getBitsInLau().isEmpty())\n    {\n        return true;\n    }\n\n    bool isValidBits = false;\n    expressionParser_->parseExpression(indirectInterface->getBitsInLau(), &isValidBits);\n    if (isValidBits == false)\n    {\n        return false;\n    }\n\n    bool canConvert = false;\n    int value = expressionParser_->parseExpression(indirectInterface->getBitsInLau()).toInt(&canConvert);\n\n    return canConvert && value >= 0;\n}\n\n//-----------------------------------------------------------------------------\n// Function: IndirectInterfaceValidator::hasValidEndianness()\n//-----------------------------------------------------------------------------\nbool IndirectInterfaceValidator::hasValidEndianness(QSharedPointer<IndirectInterface> indirectInterface) const\n{\n    QString endianness = indirectInterface->getEndianness();\n    return endianness.isEmpty() || endianness.compare(QStringLiteral(\"big\")) == 0 ||\n        endianness.compare(QStringLiteral(\"little\")) == 0;\n}\n\n//-----------------------------------------------------------------------------\n// Function: IndirectInterfaceValidator::hasValidParameters()\n//-----------------------------------------------------------------------------\nbool IndirectInterfaceValidator::hasValidParameters(QSharedPointer<IndirectInterface> indirectInterface) const\n{\n    QStringList parameterNames;\n    for (QSharedPointer<Parameter> const& parameter : *indirectInterface->getParameters())\n    {\n        if (parameterNames.contains(parameter->name()) || !parameterValidator_->validate(parameter))\n        {\n            return false;\n        }\n\n        parameterNames.append(parameter->name());\n    }\n\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: IndirectInterfaceValidator::findErrorsIn()\n//-----------------------------------------------------------------------------\nvoid IndirectInterfaceValidator::findErrorsIn(QVector<QString>& errors, \n    QSharedPointer<IndirectInterface> indirectInterface, QString const& context) const\n{\n    findErrorsInName(errors, indirectInterface, context);\n    findErrorsInAddressReference(errors, indirectInterface, context);\n    findErrorsInDataReference(errors, indirectInterface, context);\n    findErrorsInMemoryReference(errors, indirectInterface, context);\n    findErrorsInMemoryMap(errors, indirectInterface, context);\n    findErrorsInTransparentBridges(errors, indirectInterface, context);\n    findErrorsInBitsInLau(errors, indirectInterface, context);\n    findErrorsInEndianness(errors, indirectInterface, context);\n    findErrorsInParameters(errors, indirectInterface, context);\n}\n\n//-----------------------------------------------------------------------------\n// Function: IndirectInterfaceValidator::findField()\n//-----------------------------------------------------------------------------\nQSharedPointer<Field> IndirectInterfaceValidator::findField(QString const& fieldReference) const\n{\n    for (QSharedPointer<MemoryMap> const& map : *component_->getMemoryMaps())\n    {\n        for (QSharedPointer<MemoryBlockBase> const& block : *map->getMemoryBlocks())\n        {\n            QSharedPointer<AddressBlock> addressBlock = block.dynamicCast<AddressBlock>();\n            if (addressBlock)\n            {\n                for (QSharedPointer<RegisterBase> const& registerBase : *addressBlock->getRegisterData())\n                {\n                    QSharedPointer<Register> reg = registerBase.dynamicCast<Register>();\n                    if (reg)\n                    {\n                        for (QSharedPointer<Field> const& field : *reg->getFields())\n                        {\n                            if (field->getId().compare(fieldReference) == 0)\n                            {\n                                return field;                                    \n                            }\n                        }\n                    }\n                }\n            }\n        }\n    }\n\n    return QSharedPointer<Field>(0);\n}\n\n//-----------------------------------------------------------------------------\n// Function: IndirectInterfaceValidator::isValidFieldReference()\n//-----------------------------------------------------------------------------\nbool IndirectInterfaceValidator::isValidFieldReference(QString const& fieldReference,\n    QString const& targetMemoryMap) const\n{\n    if (fieldReference.isEmpty())\n    {\n        return false;\n    }\n\n    QSharedPointer<Field> targetField = findField(fieldReference);\n\n    return targetField && !memoryMapContainsField(targetMemoryMap, fieldReference);\n}\n\n//-----------------------------------------------------------------------------\n// Function: IndirectInterfaceValidator::findMemoryMapFor()\n//-----------------------------------------------------------------------------\nbool IndirectInterfaceValidator::memoryMapContainsField(QString const& memoryMapName,\n    QString const& fieldReference) const\n{\n    for (QSharedPointer<MemoryMap> const& map : *component_->getMemoryMaps())\n    {\n        if (map->name().compare(memoryMapName) == 0)\n        {\n            for (QSharedPointer<MemoryBlockBase> const& block : *map->getMemoryBlocks())\n            {\n                QSharedPointer<AddressBlock> addressBlock = block.dynamicCast<AddressBlock>();\n                if (addressBlock)\n                {\n                    for (QSharedPointer<RegisterBase> const& registerBase : *addressBlock->getRegisterData())\n                    {\n                        QSharedPointer<Register> reg = registerBase.dynamicCast<Register>();\n                        if (reg)\n                        {\n                            for (QSharedPointer<Field> const& field : *reg->getFields())\n                            {\n                                if (field->getId().compare(fieldReference) == 0)\n                                {\n                                    return true;                                  \n                                }\n                            }\n                        }\n                    }\n                }\n            }\n        }\n    }\n\n    return false;\n}\n\n//-----------------------------------------------------------------------------\n// Function: IndirectInterfaceValidator::hasEitherMemoryMapReferenceOrTransparentBridge()\n//-----------------------------------------------------------------------------\nbool IndirectInterfaceValidator::hasEitherMemoryMapReferenceOrTransparentBridge(\n    QSharedPointer<IndirectInterface> indirectInterface) const\n{\n    bool hasMemoryMap = !indirectInterface->getMemoryMapRef().isEmpty();\n    bool hasBridges = !indirectInterface->getTransparentBridges()->isEmpty();\n\n    return (hasMemoryMap && !hasBridges) || (!hasMemoryMap && hasBridges);\n}\n\n//-----------------------------------------------------------------------------\n// Function: IndirectInterfaceValidator::findErrorsInName()\n//-----------------------------------------------------------------------------\nvoid IndirectInterfaceValidator::findErrorsInName(QVector<QString>& errors,\n    QSharedPointer<IndirectInterface> indirectInterface, QString const& context) const\n{\n    if (!hasValidName(indirectInterface))\n    {\n        errors.append(QStringLiteral(\"Invalid name specified for indirect interface '%1' within %2\").arg(\n            indirectInterface->name(), context));\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: IndirectInterfaceValidator::findErrorsInAddressReference()\n//-----------------------------------------------------------------------------\nvoid IndirectInterfaceValidator::findErrorsInAddressReference(QVector<QString>& errors,\n    QSharedPointer<IndirectInterface> indirectInterface, QString const& context) const\n{\n    if (indirectInterface->getIndirectAddressRef().isEmpty())\n    {\n        errors.append(QStringLiteral(\"No field specified for address in indirect interface '%1' within %2\")\n            .arg(indirectInterface->name(), context));\n        return;\n    }\n    \n    QSharedPointer<Field> targetField = findField(indirectInterface->getIndirectAddressRef());\n    if (targetField.isNull())\n    {\n        errors.append(QStringLiteral(\n            \"Field '%1' not found for address in indirect interface '%2' within %3\").arg(\n            indirectInterface->getIndirectAddressRef(), indirectInterface->name(), context));\n    }\n    else if (memoryMapContainsField(indirectInterface->getMemoryMapRef(), indirectInterface->getIndirectAddressRef()))\n    {\n        errors.append(QStringLiteral(\n            \"Field '%1' is defined within indirect memory map '%2' in indirect interface %3 within %4\").arg(\n            indirectInterface->getIndirectAddressRef(), indirectInterface->getMemoryMapRef(), \n            indirectInterface->name(), context));\n    }\n\n    if (targetField && (targetField->getAccess() == AccessTypes::READ_ONLY ||\n        targetField->getAccess() == AccessTypes::READ_WRITEONCE ||\n        targetField->getAccess() == AccessTypes::WRITEONCE))\n    {\n        errors.append(QStringLiteral(\n            \"Field '%1' has invalid access '%2' for address in indirect interface %3 within %4\").arg(\n            indirectInterface->getIndirectAddressRef(), AccessTypes::access2Str(targetField->getAccess()),\n            indirectInterface->name(), indirectInterface->name(), context));\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: IndirectInterfaceValidator::findErrorsInDataReference()\n//-----------------------------------------------------------------------------\nvoid IndirectInterfaceValidator::findErrorsInDataReference(QVector<QString>& errors,\n    QSharedPointer<IndirectInterface> indirectInterface, QString const& context) const\n{\n    if (indirectInterface->getIndirectDataRef().isEmpty())\n    {\n        errors.append(QStringLiteral(\"No field specified for data in indirect interface '%1' within %2\")\n            .arg(indirectInterface->name(), context));\n    }\n    else if (!findField(indirectInterface->getIndirectDataRef()))\n    {\n        errors.append(QStringLiteral(\n            \"Field '%1' not found for data in indirect interface '%2' within %3\").arg(\n            indirectInterface->getIndirectDataRef(), indirectInterface->name(), context));        \n    }\n    else if (memoryMapContainsField(indirectInterface->getMemoryMapRef(), indirectInterface->getIndirectDataRef()))\n    {\n        errors.append(QStringLiteral(\n            \"Field '%1' is defined within indirect memory map '%2' in indirect interface %3 within %4\").arg(\n            indirectInterface->getIndirectDataRef(), indirectInterface->getMemoryMapRef(), \n            indirectInterface->name(), context));\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: IndirectInterfaceValidator::findErrorsInMemoryReference()\n//-----------------------------------------------------------------------------\nvoid IndirectInterfaceValidator::findErrorsInMemoryReference(QVector<QString>& errors,\n    QSharedPointer<IndirectInterface> indirectInterface, QString const& context) const\n{\n    bool hasMemoryMap = !indirectInterface->getMemoryMapRef().isEmpty();\n    bool hasBridges = !indirectInterface->getTransparentBridges()->isEmpty();\n\n    if (hasMemoryMap && hasBridges)\n    {\n        errors.append(QStringLiteral(\n            \"Both memory map and transparent bridges defined for indirect interface '%1' within %2.\").arg(\n            indirectInterface->name(), context));\n    }\n    else if (!hasMemoryMap && !hasBridges)\n    {\n        errors.append(QStringLiteral(\n            \"No memory map or transparent bridges defined for indirect interface '%1' within %2.\").arg(\n            indirectInterface->name(), context));\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: IndirectInterfaceValidator::findErrorsInMemoryMap()\n//-----------------------------------------------------------------------------\nvoid IndirectInterfaceValidator::findErrorsInMemoryMap(QVector<QString>& errors,\n    QSharedPointer<IndirectInterface> indirectInterface, QString const& context) const\n{\n    if (!hasValidMemoryMapReference(indirectInterface))\n    {\n        errors.append(QStringLiteral(\n            \"Invalid memory map '%1' referenced in indirect interface '%2' within %3.\").arg(\n            indirectInterface->getMemoryMapRef(), indirectInterface->name(), context));\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: IndirectInterfaceValidator::findErrorsInTransparentBridges()\n//-----------------------------------------------------------------------------\nvoid IndirectInterfaceValidator::findErrorsInTransparentBridges(QVector<QString>& errors,\n    QSharedPointer<IndirectInterface> indirectInterface, QString const& context) const\n{\n    for (QSharedPointer<TransparentBridge> const& bridge : *indirectInterface->getTransparentBridges())\n    {\n        bool foundInterface = false;\n        for (QSharedPointer<BusInterface> const& busInterface : *component_->getBusInterfaces())\n        {\n            if (busInterface->name().compare(bridge->getMasterRef()) == 0)\n            {\n                foundInterface = true;\n                if (busInterface->getInterfaceMode() != General::MASTER)\n                {\n                    errors.append(QStringLiteral(\n                        \"Transparent bridge references a non-master bus interface '%1' in indirect interface '%2' within %3.\").arg(\n                        bridge->getMasterRef(), indirectInterface->name(), context));\n                }\n            }\n        }\n\n        if (!foundInterface)\n        {\n            errors.append(QStringLiteral(\n                \"Transparent bridge references an invalid bus interface '%1' in indirect interface '%2' within %3.\").arg(\n                bridge->getMasterRef(), indirectInterface->name(), context));\n        }\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: IndirectInterfaceValidator::findErrorsInBitsInLau()\n//-----------------------------------------------------------------------------\nvoid IndirectInterfaceValidator::findErrorsInBitsInLau(QVector<QString>& errors,\n    QSharedPointer<IndirectInterface> indirectInterface, QString const& context) const\n{\n    if (!hasValidBitsInLau(indirectInterface))\n    {\n        errors.append(QStringLiteral(\n            \"Invalid bits in lau '%1' defined in indirect interface '%2' within %3.\").arg(\n            indirectInterface->getBitsInLau(), indirectInterface->name(), context));\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: IndirectInterfaceValidator::findErrorsInEndianness()\n//-----------------------------------------------------------------------------\nvoid IndirectInterfaceValidator::findErrorsInEndianness(QVector<QString>& errors,\n    QSharedPointer<IndirectInterface> indirectInterface, QString const& context) const\n{\n    if (!hasValidEndianness(indirectInterface))\n    {\n        errors.append(QStringLiteral(\n            \"Invalid endianness '%1' defined in indirect interface '%2' within %3.\").arg(\n            indirectInterface->getEndianness(), indirectInterface->name(), context));\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: IndirectInterfaceValidator::findErrorsInParameters()\n//-----------------------------------------------------------------------------\nvoid IndirectInterfaceValidator::findErrorsInParameters(QVector<QString>& errors,\n    QSharedPointer<IndirectInterface> indirectInterface, QString const& context) const\n{\n    QVector<QString> parameterNames;\n    for (QSharedPointer<Parameter> const& parameter : *indirectInterface->getParameters())\n    {\n        if (parameterNames.contains(parameter->name()))\n        {\n            errors.append(QObject::tr(\"Parameter name %1 is not unique in indirect interface %2 within %3.\").arg(\n                parameter->name(), indirectInterface->name(), context));\n        }\n        else\n        {\n            parameterNames.append(parameter->name());\n        }\n\n        parameterValidator_->findErrorsIn(errors, parameter, context);\n    }\n}\n"
  },
  {
    "path": "IPXACTmodels/Component/validators/IndirectInterfaceValidator.h",
    "content": "//-----------------------------------------------------------------------------\n// File: IndirectInterfaceValidator.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Esko Pekkarinen\n// Date: 10.08.2017\n//\n// Description:\n// Validator for ipxact:indirectInterface.\n//-----------------------------------------------------------------------------\n\n#ifndef INDIRECTINTERFACEVALIDATOR_H\n#define INDIRECTINTERFACEVALIDATOR_H\n\n#include <IPXACTmodels/ipxactmodels_global.h>\n\n#include <IPXACTmodels/common/validators/HierarchicalValidator.h>\n\n#include <QList>\n#include <QSharedPointer>\n#include <QString>\n#include <QVector>\n\nclass Component;\nclass Field;\nclass IndirectInterface;\nclass ExpressionParser;\nclass ParameterValidator;\nclass TransparentBridge;\n\n//-----------------------------------------------------------------------------\n//! Validator for ipxact:indirectInterface.\n//-----------------------------------------------------------------------------\nclass IPXACTMODELS_EXPORT IndirectInterfaceValidator : public HierarchicalValidator\n{\npublic:\n\n\n    /*!\n     *  The constructor.\n     *\n     *    @param [in] component           The component containing the indirect interface to validate.\n     *    @param [in] parser              The expression parser to use in validation.\n     *    @param [in] parameterValidator  The validator to use for parameters.\n     */\n    IndirectInterfaceValidator(QSharedPointer<Component> component,\n        QSharedPointer<ExpressionParser> parser,\n        QSharedPointer<ParameterValidator> parameterValidator);\n\n\t//! The destructor.\n\t~IndirectInterfaceValidator()= default;\n\n    // Disable copying.\n    IndirectInterfaceValidator(IndirectInterfaceValidator const& rhs) = delete;\n    IndirectInterfaceValidator& operator=(IndirectInterfaceValidator const& rhs) = delete;\n\n    void componentChange(QSharedPointer<Component> component);\n\n    /*!\n     *  Validates the given IndirectInterface.\n     *\n     *    @param [in] indirectInterface           The indirectInterface to validate.\n     *\n     *    @return True, if the IndirectInterface is valid IP-XACT, otherwise false.\n     */\n    bool validate(QSharedPointer<IndirectInterface> indirectInterface) const;\n    \n    /*!\n     *  Check if the name is valid.\n     *\n     *    @param [in] indirectInterface   The indirect interface to check.\n     *\n     *    @return True, if the name is valid, otherwise false.\n     */\n    bool hasValidName(QSharedPointer<IndirectInterface> indirectInterface) const;\n   \n    /*!\n     *  Check if the address field reference is valid.\n     *\n     *    @param [in] indirectInterface   The indirect interface to check.\n     *\n     *    @return True, if the reference is valid, otherwise false.\n     */\n    bool hasValidAddressReference(QSharedPointer<IndirectInterface> indirectInterface) const;\n   \n    /*!\n     *  Check if the data field reference is valid.\n     *\n     *    @param [in] indirectInterface   The indirect interface to check.\n     *\n     *    @return True, if the reference is valid, otherwise false.\n     */\n    bool hasValidDataReference(QSharedPointer<IndirectInterface> indirectInterface) const;\n   \n    /*!\n     *  Check if the memory map reference is valid.\n     *\n     *    @param [in] indirectInterface   The indirect interface to check.\n     *\n     *    @return True, if the reference is valid, otherwise false.\n     */\n    bool hasValidMemoryMapReference(QSharedPointer<IndirectInterface> testInterface) const;\n   \n    /*!\n     *  Check if the selected transparent bridge references are valid.\n     *\n     *    @param [in] bridges     The selected transparent bridges.\n     *\n     *    @return True, if the references are valid, otherwise false.\n     */\n    bool hasValidTransparentBridges(QSharedPointer<QList<QSharedPointer<TransparentBridge> > > bridges) const;\n\n    /*!\n     *  Check if the bits in lau definition is valid.\n     *\n     *    @param [in] indirectInterface   The indirect interface to check.\n     *\n     *    @return True, if the bits in lau definition is valid, otherwise false.\n     */\n    bool hasValidBitsInLau(QSharedPointer<IndirectInterface> indirectInterface) const;\n       \n    /*!\n     *  Check if the endianness is valid.\n     *\n     *    @param [in] indirectInterface   The indirect interface to check.\n     *\n     *    @return True, if the endianness is valid, otherwise false.\n     */\n    bool hasValidEndianness(QSharedPointer<IndirectInterface> indirectInterface) const;\n       \n    /*!\n     *  Check if the parameters are valid.\n     *\n     *    @param [in] indirectInterface   The indirect interface to check.\n     *\n     *    @return True, if the parameters are valid, otherwise false.\n     */\n    bool hasValidParameters(QSharedPointer<IndirectInterface> indirectInterface) const;\n\n    /*!\n    *  Finds possible errors in an indirectInterface and creates a list of them.\n    *\n    *    @param [in] errors              List of found errors.\n    *    @param [in] indirectInterface   The indirectInterface whose errors to find.\n    *    @param [in] context             Context to help locate the errors.\n    */\n    void findErrorsIn(QVector<QString>& errors, QSharedPointer<IndirectInterface> indirectInterface,\n        QString const& context) const;\n\nprivate:\n\n    /*!\n     * Finds the field with the given Id reference.\n     *\n     *    @param [in] fieldReference   The Id of the field to find.\n     *\n     *    @return The found field.\n     */\n    QSharedPointer<Field> findField(QString const& fieldReference) const;\n\n    /*!\n     *  Checks if the given field reference is valid.\n     *\n     *    @param [in] fieldReference      The Id reference to check.\n     *    @param [in] targetMemoryMap     The name of the indirect memory map in the interface.\n     *\n     *    @returnTrue, if the reference is valid, otherwise false.\n     */\n    bool isValidFieldReference(QString const& fieldReference, QString const& targetMemoryMap) const;\n\n    /*!\n     *  Checks if the given field is defined within the given memory map.\n     *\n     *    @param [in] memoryMapName   The name of the memory map to check.\n     *    @param [in] fieldReference  The Id reference of the field to check.\n     *\n     *    @return True, if the field is defined within the memory map, otherwise false.\n     */\n    bool memoryMapContainsField(QString const& memoryMapName, QString const& fieldReference) const;\n    \n    /*!\n     *  Checks if the given indirect map has either a memory map or transparent bridges but not both.\n     *\n     *    @param [in] indirectInterface   The indirect interface to check.\n     *\n     *    @return True, if either memory map or bridges are defined, otherwise false.\n     */\n    bool hasEitherMemoryMapReferenceOrTransparentBridge(QSharedPointer<IndirectInterface> indirectInterface) const;\n       \n    /*!\n    *  Finds possible errors in indirectInterface name.\n    *\n    *    @param [in] errors              List of found errors.\n    *    @param [in] indirectInterface   The indirectInterface whose errors to find.\n    *    @param [in] context             Context to help locate the errors.\n    */    \n    void findErrorsInName(QVector<QString>& errors, QSharedPointer<IndirectInterface> indirectInterface, \n        QString const& context) const;\n       \n    /*!\n    *  Finds possible errors in indirectInterface address reference.\n    *\n    *    @param [in] errors              List of found errors.\n    *    @param [in] indirectInterface   The indirectInterface whose errors to find.\n    *    @param [in] context             Context to help locate the errors.\n    */    \n    void findErrorsInAddressReference(QVector<QString>& errors, \n        QSharedPointer<IndirectInterface> indirectInterface, QString const& context) const;\n       \n    /*!\n    *  Finds possible errors in indirectInterface data reference.\n    *\n    *    @param [in] errors              List of found errors.\n    *    @param [in] indirectInterface   The indirectInterface whose errors to find.\n    *    @param [in] context             Context to help locate the errors.\n    */    \n    void findErrorsInDataReference(QVector<QString>& errors, QSharedPointer<IndirectInterface> indirectInterface,\n        QString const& context) const;\n       \n    /*!\n    *  Finds possible errors in an indirectInterface defining either a memory map or transparent bridges.\n    *\n    *    @param [in] errors              List of found errors.\n    *    @param [in] indirectInterface   The indirectInterface whose errors to find.\n    *    @param [in] context             Context to help locate the errors.\n    */    \n    void findErrorsInMemoryReference(QVector<QString>& errors, QSharedPointer<IndirectInterface> indirectInterface,\n        QString const& context) const;\n           \n    /*!\n    *  Finds possible errors in indirectInterface memory map reference.\n    *\n    *    @param [in] errors              List of found errors.\n    *    @param [in] indirectInterface   The indirectInterface whose errors to find.\n    *    @param [in] context             Context to help locate the errors.\n    */    \n    void findErrorsInMemoryMap(QVector<QString>& errors, QSharedPointer<IndirectInterface> indirectInterface,\n        QString const& context) const;\n           \n    /*!\n    *  Finds possible errors in indirectInterface transparent bridges.\n    *\n    *    @param [in] errors              List of found errors.\n    *    @param [in] indirectInterface   The indirectInterface whose errors to find.\n    *    @param [in] context             Context to help locate the errors.\n    */   \n    void findErrorsInTransparentBridges(QVector<QString>& errors,\n        QSharedPointer<IndirectInterface> indirectInterface, QString const& context) const;\n               \n    /*!\n    *  Finds possible errors in indirectInterface bits in lau definition.\n    *\n    *    @param [in] errors              List of found errors.\n    *    @param [in] indirectInterface   The indirectInterface whose errors to find.\n    *    @param [in] context             Context to help locate the errors.\n    */   \n    void findErrorsInBitsInLau(QVector<QString>& errors, QSharedPointer<IndirectInterface> indirectInterface,\n        QString const& context) const;\n               \n    /*!\n    *  Finds possible errors in indirectInterface endianness.\n    *\n    *    @param [in] errors              List of found errors.\n    *    @param [in] indirectInterface   The indirectInterface whose errors to find.\n    *    @param [in] context             Context to help locate the errors.\n    */   \n    void findErrorsInEndianness(QVector<QString>& errors, QSharedPointer<IndirectInterface> indirectInterface,\n        QString const& context) const;\n               \n    /*!\n    *  Finds possible errors in indirectInterface parameters.\n    *\n    *    @param [in] errors              List of found errors.\n    *    @param [in] indirectInterface   The indirectInterface whose errors to find.\n    *    @param [in] context             Context to help locate the errors.\n    */   \n    void findErrorsInParameters(QVector<QString>& errors, QSharedPointer<IndirectInterface> indirectInterface,\n        QString const& context) const;\n    \n    //-----------------------------------------------------------------------------\n    // Data.\n    //-----------------------------------------------------------------------------\n\n    //! The component containing the indirect interface to check.\n    QSharedPointer<Component> component_;\n\n    //! Parser for expressions.\n    QSharedPointer<ExpressionParser> expressionParser_;\n\n    //! Validator for parameters within the indirect interfaces.\n    QSharedPointer<ParameterValidator> parameterValidator_;\n};\n\n#endif // INDIRECTINTERFACEVALIDATOR_H\n"
  },
  {
    "path": "IPXACTmodels/Component/validators/InstantiationsValidator.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// Instantiations: InstantiationsValidator.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Janne Virtanen\r\n// Date: 23.11.2015\r\n//\r\n// Description:\r\n// Validator for ipxact:Instantiations.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"InstantiationsValidator.h\"\r\n\r\n#include <KactusAPI/include/ExpressionParser.h>\r\n\r\n#include <KactusAPI/include/LibraryInterface.h>\r\n\r\n#include <IPXACTmodels/common/Choice.h>\r\n#include <IPXACTmodels/Component/DesignConfigurationInstantiation.h>\r\n#include <IPXACTmodels/Component/DesignInstantiation.h>\r\n#include <IPXACTmodels/Component/ComponentInstantiation.h>\r\n#include <IPXACTmodels/Component/FileSet.h>\r\n#include <IPXACTmodels/Component/FileSetRef.h>\r\n\r\n#include <IPXACTmodels/common/Enumeration.h>\r\n#include <IPXACTmodels/common/validators/CommonItemsValidator.h>\r\n#include <IPXACTmodels/common/validators/ParameterValidator.h>\r\n\r\n#include <QStringList>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: InstantiationsValidator::InstantiationsValidator()\r\n//-----------------------------------------------------------------------------\r\nInstantiationsValidator::InstantiationsValidator(QSharedPointer<ExpressionParser> expressionParser,\r\n                                                 QSharedPointer<QList<QSharedPointer<FileSet> > > fileSets,\r\n                                                 QSharedPointer<ParameterValidator> parameterValidator,\r\n                                                 LibraryInterface* libraryHandler):\r\nHierarchicalValidator(),\r\nexpressionParser_(expressionParser),\r\navailableFileSets_(fileSets),\r\nparameterValidator_(parameterValidator),\r\nlibraryHandler_(libraryHandler)\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: InstantiationsValidator::~InstantiationsValidator()\r\n//-----------------------------------------------------------------------------\r\nInstantiationsValidator::~InstantiationsValidator()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: InstantiationsValidator::componentChange()\r\n//-----------------------------------------------------------------------------\r\nvoid InstantiationsValidator::componentChange(QSharedPointer<QList<QSharedPointer<FileSet> > > newFileSets)\r\n{\r\n    availableFileSets_ = newFileSets;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: InstantiationsValidator::validateDesignInstantiation()\r\n//-----------------------------------------------------------------------------\r\nbool InstantiationsValidator::validateDesignInstantiation(QSharedPointer<DesignInstantiation> designInstantiation)\r\n    const\r\n{\r\n    return validComparedToSiblings(designInstantiation) && hasValidName(designInstantiation->name()) && \r\n        hasValidDesignReference(designInstantiation);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: EnumeratedValueValidator::hasValidName()\r\n//-----------------------------------------------------------------------------\r\nbool InstantiationsValidator::hasValidName(QString const& name) const\r\n{\r\n    return CommonItemsValidator::hasValidName(name);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: InstantiationsValidator::hasValidDesignReference()\r\n//-----------------------------------------------------------------------------\r\nbool InstantiationsValidator::hasValidDesignReference(QSharedPointer<DesignInstantiation> designInstantiation) const\r\n{\r\n    if (designInstantiation->getDesignReference() && designInstantiation->getDesignReference()->isValid())\r\n    {\r\n        return libraryHandler_->getDocumentType(*designInstantiation->getDesignReference().data()) == VLNV::DESIGN;\r\n    }\r\n\r\n    return false;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: InstantiationsValidator::findErrorsInDesignInstantiation()\r\n//-----------------------------------------------------------------------------\r\nvoid InstantiationsValidator::findErrorsInDesignInstantiation(QVector<QString>& errors,\r\n    QSharedPointer<DesignInstantiation> designInstantiation, QString const& context) const\r\n{\r\n\tif ( !hasValidName( designInstantiation->name() ) )\r\n\t{\r\n        errors.append(QObject::tr(\"Invalid name set for design instantiation %1 within %2\")\r\n            .arg(designInstantiation->name()).arg(context));\r\n\t}\r\n\r\n\tif ( !designInstantiation->getDesignReference() )\r\n\t{\r\n\t\terrors.append(QObject::tr(\"The design reference does not exist for design instantiation %2.\")\r\n            .arg(designInstantiation->name()));\r\n\t}\r\n    else if (!designInstantiation->getDesignReference()->isValid())\r\n\t{\r\n\t\terrors.append(QObject::tr(\"Invalid design reference %1 set for design instantiation %2\")\r\n            .arg(designInstantiation->getDesignReference()->toString()).arg(designInstantiation->name()));\r\n\t}\r\n    else if (!libraryHandler_->contains(*designInstantiation->getDesignReference()))\r\n    {\r\n        errors.append(QObject::tr(\"Design %1 referenced by design instantiation in %2 was not found in the \"\r\n            \"library.\")\r\n            .arg(designInstantiation->getDesignReference()->toString()).arg(context));\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: InstantiationsValidator::validateDesignConfigurationInstantiation()\r\n//-----------------------------------------------------------------------------\r\nbool InstantiationsValidator::validateDesignConfigurationInstantiation(\r\n\tQSharedPointer<DesignConfigurationInstantiation> instantiation) const\r\n{\r\n    return validComparedToSiblings(instantiation) && hasValidName(instantiation->name()) && \r\n        hasValidDesignConfigurationReference(instantiation) && hasValidParameters(instantiation->getParameters());\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: InstantiationsValidator::hasValidDesignConfigurationReference()\r\n//-----------------------------------------------------------------------------\r\nbool InstantiationsValidator::hasValidDesignConfigurationReference(\r\n    QSharedPointer<DesignConfigurationInstantiation> instantiation) const\r\n{\r\n    if (instantiation->getDesignConfigurationReference() &&\r\n        instantiation->getDesignConfigurationReference()->isValid())\r\n    {\r\n        return libraryHandler_->getDocumentType(*instantiation->getDesignConfigurationReference()) == \r\n            VLNV::DESIGNCONFIGURATION;\r\n    }\r\n\r\n    return false;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: InstantiationsValidator::hasValidParameters()\r\n//-----------------------------------------------------------------------------\r\nbool InstantiationsValidator::hasValidParameters(\r\n    QSharedPointer<QList<QSharedPointer<Parameter> > > availableParameters) const\r\n{\r\n    if (!availableParameters->isEmpty())\r\n    {\r\n        QStringList parameterNames;\r\n        for( QSharedPointer<Parameter> parameter : *availableParameters )\r\n        {\r\n            if ( parameterNames.contains(parameter->name()) || !parameterValidator_->validate(parameter) )\r\n            {\r\n                return false;\r\n            }\r\n            else\r\n            {\r\n                parameterNames.append(parameter->name());\r\n            }\r\n        }\r\n    }\r\n\r\n    return true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: InstantiationsValidator::findErrorsInDesignConfigurationInstantiation()\r\n//-----------------------------------------------------------------------------\r\nvoid InstantiationsValidator::findErrorsInDesignConfigurationInstantiation(QVector<QString>& errors,\r\n\tQSharedPointer<DesignConfigurationInstantiation> instantiation, QString const& contex) const\r\n{\r\n\tif ( !hasValidName( instantiation->name() ) )\r\n\t{\r\n        errors.append(QObject::tr(\"Invalid name set for design configuration instantiation %1 within %2\")\r\n            .arg(instantiation->name()).arg(contex));\r\n\t}\r\n\r\n\tif ( !instantiation->getDesignConfigurationReference() )\r\n\t{\r\n\t\terrors.append(QObject::tr(\"The design configuration reference does not exist for design configuration \"\r\n            \"instantiation %1.\").arg(instantiation->name()));\r\n\t}\r\n\telse if ( !instantiation->getDesignConfigurationReference()->isValid() )\r\n\t{\r\n        errors.append(QObject::tr(\"Invalid design configuration reference %1 set for design configuration \"\r\n            \"instantiation %2\")\r\n            .arg(instantiation->getDesignConfigurationReference()->toString()).arg(instantiation->name()));\r\n\t}\r\n    else if (!libraryHandler_->contains(*instantiation->getDesignConfigurationReference()))\r\n    {\r\n        errors.append(QObject::tr(\"Design configuration %1 referenced by design configuration instantiation in \"\r\n            \"%2 was not found in the library.\")\r\n            .arg(instantiation->getDesignConfigurationReference()->toString()).arg(contex));\r\n    }\r\n\r\n    QStringList parameterNames;\r\n    QStringList foundNames;\r\n\tfor ( QSharedPointer<Parameter> parameter : *instantiation->getParameters() )\r\n\t{\r\n        if (parameterNames.contains(parameter->name()) && !foundNames.contains(parameter->name()))\r\n        {\r\n            errors.append(QObject::tr(\"Parameter name %1 is not unique within design configuration \"\r\n                \"instantiation %2\").arg(parameter->name()).arg(instantiation->name()));\r\n            foundNames.append(parameter->name());\r\n        }\r\n        else\r\n        {\r\n            parameterNames.append(parameter->name());\r\n        }\r\n\t\tparameterValidator_->findErrorsIn(errors,parameter,contex);\r\n\t}\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: InstantiationsValidator::validateComponentInstantiation()\r\n//-----------------------------------------------------------------------------\r\nbool InstantiationsValidator::validateComponentInstantiation (QSharedPointer<ComponentInstantiation> instantiation,\r\n    Document::Revision docRevision) const\r\n{\r\n    return validComparedToSiblings(instantiation) && hasValidName(instantiation->name()) &&\r\n        componentInstantiationFileBuildersAreValid(instantiation) &&\r\n        componentInstantiationFileSetReferencesAreValid(instantiation) &&\r\n        hasValidModuleParameters(instantiation, docRevision) &&\r\n        hasValidParameters(instantiation->getParameters());\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: InstantiationsValidator::componentInstantiationFileBuildersAreValid()\r\n//-----------------------------------------------------------------------------\r\nbool InstantiationsValidator::componentInstantiationFileBuildersAreValid(\r\n    QSharedPointer<ComponentInstantiation> instantiation) const\r\n{\r\n    for ( QSharedPointer<FileBuilder> currentFileBuilder : *instantiation->getDefaultFileBuilders() )\r\n    {\r\n        if ( !hasValidName( currentFileBuilder->getFileType().type_ ) ||\r\n            !fileBuilderReplaceDefaultFlagsIsValid(currentFileBuilder) )\r\n        {\r\n            return false;\r\n        }\r\n    }\r\n\r\n    return true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: InstantiationsValidator::fileBuilderReplaceDefaultFlagsIsValid()\r\n//-----------------------------------------------------------------------------\r\nbool InstantiationsValidator::fileBuilderReplaceDefaultFlagsIsValid(QSharedPointer<FileBuilder> fileBuilder) const\r\n{\r\n    QString replaceDefaultFlags = fileBuilder->getReplaceDefaultFlags();\r\n    if (!replaceDefaultFlags.isEmpty())\r\n    {\r\n        bool replaceFlagsOk = false;\r\n        int replaceFlagsInt = expressionParser_->parseExpression(replaceDefaultFlags, &replaceFlagsOk).toInt();\r\n\r\n        return replaceFlagsOk && (replaceFlagsInt == 0 || replaceFlagsInt == 1);\r\n    }\r\n\r\n    return true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: InstantiationsValidator::componentInstantiationFileSetReferencesAreValid()\r\n//-----------------------------------------------------------------------------\r\nbool InstantiationsValidator::componentInstantiationFileSetReferencesAreValid(\r\n    QSharedPointer<ComponentInstantiation> instantiation) const\r\n{\r\n    for ( auto const& fileSetRef : *instantiation->getFileSetReferences() )\r\n    {\r\n        if ( !fileSetReferenceIsValid(fileSetRef) )\r\n        {\r\n            return false;\r\n        }\r\n    }\r\n\r\n    return true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: InstantiationsValidator::existingReference()\r\n//-----------------------------------------------------------------------------\r\nbool InstantiationsValidator::fileSetReferenceIsValid(QSharedPointer<FileSetRef> fileSetRef) const\r\n{\r\n    for ( auto const& fileSet : *availableFileSets_ )\r\n    {\r\n        if ( fileSetRef->getReference() == fileSet->name() )\r\n        {\r\n            return true;\r\n        }\r\n    }\r\n\r\n    return false;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: InstantiationsValidator::hasValidModuleParameters()\r\n//-----------------------------------------------------------------------------\r\nbool InstantiationsValidator::hasValidModuleParameters(QSharedPointer<ComponentInstantiation> instantiation,\r\n    Document::Revision docRevision) const\r\n{\r\n    if (!instantiation->getModuleParameters()->isEmpty())\r\n    {\r\n        QStringList moduleParameterNames;\r\n        for ( QSharedPointer<ModuleParameter> parameter : *instantiation->getModuleParameters() )\r\n        {\r\n            if ( moduleParameterNames.contains(parameter->name()) || !parameterValidator_->validate(parameter) ||\r\n                !moduleParameterHasValidPresence(parameter) || !moduleParameterHasValidUsageType(parameter, docRevision))\r\n            {\r\n                return false;\r\n            }\r\n\r\n            moduleParameterNames.append(parameter->name());\r\n        }\r\n    }\r\n\r\n    return true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: InstantiationsValidator::findErrorsInComponentInstantiation()\r\n//-----------------------------------------------------------------------------\r\nvoid InstantiationsValidator::findErrorsInComponentInstantiation(QVector<QString>& errors,\r\n    QSharedPointer<ComponentInstantiation> instantiation, QString const& context,\r\n    Document::Revision docRevision) const\r\n{\r\n    if (!hasValidName(instantiation->name()))\r\n    {\r\n        errors.append(QObject::tr(\"Invalid name set for component instantiation %1 within %2\")\r\n            .arg(instantiation->name()).arg(context));\r\n    }\r\n\r\n    for ( auto const& fileSetRef : *instantiation->getFileSetReferences() )\r\n    {\r\n        if ( !fileSetReferenceIsValid(fileSetRef) )\r\n        {\r\n            errors.append(QObject::tr(\"Referenced file set %1 does not exist.\").arg(fileSetRef->getReference()));\r\n        }\r\n    }\r\n\r\n\tfor ( QSharedPointer<FileBuilder> currentFileBuilder : *instantiation->getDefaultFileBuilders() )\r\n\t{\r\n\t\tif ( !hasValidName( currentFileBuilder->getFileType().type_ ) )\r\n\t\t{\r\n\t\t\terrors.append(QObject::tr(\"The type of default file builder is empty.\"));\r\n\t\t}\r\n        if (!fileBuilderReplaceDefaultFlagsIsValid(currentFileBuilder))\r\n\t\t{\r\n            errors.append(QObject::tr(\"Invalid \\\"replace default flags\\\" value set for component instantiation %1.\"\r\n                \" Value must evaluate to 0 or 1.\").\r\n                arg(instantiation->name()));\r\n\t\t}\r\n\t}\r\n\r\n    QStringList parameterNames;\r\n    QStringList duplicateParameterNames;\r\n\tfor ( QSharedPointer<ModuleParameter> parameter : *instantiation->getModuleParameters() )\r\n\t{\r\n\t\tparameterValidator_->findErrorsIn(errors,parameter,context);\r\n\r\n\t\tif ( !moduleParameterHasValidPresence(parameter) )\r\n\t\t{\r\n\t\t\terrors.append(QObject::tr(\"The presence of module parameter %1 is invalid: %2\")\r\n\t\t\t\t.arg(parameter->name()).arg(parameter->getIsPresent()));\r\n\t\t}\r\n\r\n\t\tif (!moduleParameterHasValidUsageType(parameter, docRevision))\r\n\t\t{\r\n\t\t\terrors.append(QObject::tr(\"The usage of module parameter %1 is invalid: %2\")\r\n\t\t\t\t.arg(parameter->name()).arg(parameter->getUsageType()));\r\n\t\t}\r\n\r\n        if (parameterNames.contains(parameter->name()) && !duplicateParameterNames.contains(parameter->name()))\r\n        {\r\n            errors.append(QObject::tr(\"Module parameter name %1 within %2 is not unique.\")\r\n                .arg(parameter->name()).arg(context));\r\n            duplicateParameterNames.append(parameter->name());\r\n        }\r\n        else\r\n        {\r\n            parameterNames.append(parameter->name());\r\n        }\r\n\t}\r\n\r\n    parameterNames.clear();\r\n    duplicateParameterNames.clear();\r\n\tfor ( QSharedPointer<Parameter> parameter : *instantiation->getParameters() )\r\n\t{\r\n        parameterValidator_->findErrorsIn(errors,parameter,context);\r\n        \r\n        if (parameterNames.contains(parameter->name()) && !duplicateParameterNames.contains(parameter->name()))\r\n        {\r\n            errors.append(QObject::tr(\"Parameter name %1 within %2 is not unique.\")\r\n                .arg(parameter->name()).arg(context));\r\n            duplicateParameterNames.append(parameter->name());\r\n        }\r\n        else\r\n        {\r\n            parameterNames.append(parameter->name());\r\n        }\r\n\t}\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: InstantiationsValidator::isValidUsageType()\r\n//-----------------------------------------------------------------------------\r\nbool InstantiationsValidator::moduleParameterHasValidUsageType(QSharedPointer<ModuleParameter> parameter,\r\n    Document::Revision docRevision) const\r\n{\r\n    if (parameter->getUsageType().isEmpty())\r\n    {\r\n        return true;\r\n    }\r\n\r\n    QStringList validUsageTypes = { QStringLiteral(\"nontyped\"), QStringLiteral(\"typed\") };\r\n    if (docRevision == Document::Revision::Std22)\r\n    {\r\n        validUsageTypes << QStringLiteral(\"runtime\");\r\n    }\r\n\r\n    if (!validUsageTypes.contains(parameter->getUsageType()))\r\n    {\r\n        return false;\r\n    }\r\n\r\n    return true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: InstantiationsValidator::isValidPresence()\r\n//-----------------------------------------------------------------------------\r\nbool InstantiationsValidator::moduleParameterHasValidPresence(QSharedPointer<ModuleParameter> parameter) const\r\n{\r\n    bool isValidPresence = false;\r\n    expressionParser_->parseExpression(parameter->getIsPresent(), &isValidPresence);\r\n    \r\n\tif (isValidPresence == false)\r\n\t{\r\n\t\treturn false;\r\n\t}\r\n\r\n    return true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: InstantiationsValidator::getParameterValidator()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<ParameterValidator> InstantiationsValidator::getParameterValidator() const\r\n{\r\n    return parameterValidator_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: InstantiationsValidator::setParameterValidator()\r\n//-----------------------------------------------------------------------------\r\nvoid InstantiationsValidator::setParameterValidator(QSharedPointer<ParameterValidator> newParameterValidator)\r\n{\r\n    parameterValidator_ = newParameterValidator;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: InstantiationsValidator::setExpressionParser()\r\n//-----------------------------------------------------------------------------\r\nvoid InstantiationsValidator::setExpressionParser(QSharedPointer<ExpressionParser> newExpressionParser)\r\n{\r\n    expressionParser_ = newExpressionParser;\r\n}\r\n"
  },
  {
    "path": "IPXACTmodels/Component/validators/InstantiationsValidator.h",
    "content": "//-----------------------------------------------------------------------------\r\n// Instantiations: InstantiationsValidator.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Janne Virtanen\r\n// Date: 23.11.2015\r\n//\r\n// Description:\r\n// Validator for ipxact:Instantiations.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef InstantiationsVALIDATOR_H\r\n#define InstantiationsVALIDATOR_H\r\n\r\n#include <IPXACTmodels/ipxactmodels_global.h>\r\n#include <IPXACTmodels/common/Document.h>\r\n\r\n#include <IPXACTmodels/common/validators/HierarchicalValidator.h>\r\n\r\n#include <QSharedPointer>\r\n#include <QString>\r\n#include <QVector>\r\n\r\nclass LibraryInterface;\r\nclass ExpressionParser;\r\n\r\nclass ComponentInstantiation;\r\nclass DesignInstantiation;\r\nclass DesignConfigurationInstantiation;\r\n\r\nclass FileBuilder;\r\nclass FileSet;\r\nclass FileSetRef;\r\nclass Parameter;\r\nclass ModuleParameter;\r\nclass ParameterValidator;\r\n//-----------------------------------------------------------------------------\r\n//! Validator for ipxact:Instantiations.\r\n//-----------------------------------------------------------------------------\r\nclass IPXACTMODELS_EXPORT InstantiationsValidator : public HierarchicalValidator\r\n{\r\npublic:\r\n\r\n    /*!\r\n     *  The constructor.\r\n     *\r\n     *    @param [in] expressionParser    The used expression parser.\r\n     *    @param [in] fileSets            The available file sets.\r\n     *    @param [in] parameterValidator  The used parameter validator.\r\n     *    @param [in] libraryHandler      The used library interface.\r\n     */\r\n    InstantiationsValidator(QSharedPointer<ExpressionParser> expressionParser,\r\n        QSharedPointer<QList<QSharedPointer<FileSet> > > fileSets,\r\n        QSharedPointer<ParameterValidator> parameterValidator, LibraryInterface* libraryHandler);\r\n\r\n\t//! The destructor.\r\n\tvirtual ~InstantiationsValidator();\r\n\t\r\n    /*!\r\n     *  Change the available file sets.\r\n     *\r\n     *    @param [in] newFileSets     The new file sets.\r\n     */\r\n    void componentChange(QSharedPointer<QList<QSharedPointer<FileSet> > > newFileSets);\r\n\r\n    /*!\r\n     *  Validates the given design instantiation.\r\n     *\r\n\t *    @param [in] designInstantiation     The instantiation to validate.\r\n     *\r\n     *    @return True, if the design instantiation is valid IP-XACT, otherwise false.\r\n     */\r\n\tbool validateDesignInstantiation(QSharedPointer<DesignInstantiation> designInstantiation) const;\r\n\t\r\n    /*!\r\n     *  Check if the name is valid.\r\n     *\r\n     *    @param [in] name    The name to be evaluated.\r\n     *\r\n     *    @return True, if the name is valid, otherwise false.\r\n     */\r\n    bool hasValidName(QString const& name) const;\r\n\r\n    /*!\r\n     *  Check if the design reference is valid.\r\n     *\r\n     *    @param [in] designInstantiation     The selected design instantiation.\r\n     *\r\n     *    @return True, if the reference is valid, otherwise false.\r\n     */\r\n    bool hasValidDesignReference(QSharedPointer<DesignInstantiation> designInstantiation) const;\r\n\r\n    /*!\r\n     *  Finds possible errors in design instantiation and creates a list of them.\r\n     *\r\n     *    @param [in] errors                  List of found errors.\r\n     *    @param [in] designInstantiation     The design instantiation whose errors to find.\r\n\t *    @param [in] context                 Context to help locate the errors.\r\n     */\r\n\tvoid findErrorsInDesignInstantiation(QVector<QString>& errors,\r\n\t\tQSharedPointer<DesignInstantiation> designInstantiation, QString const& context) const;\r\n\t\r\n    /*!\r\n     *  Validates the given design configuration instantiation.\r\n     *\r\n\t *    @param [in] instantiation   The design configuration instantiation to validate.\r\n     *\r\n     *    @return True, if the design configuration instantiation is valid IP-XACT, otherwise false.\r\n     */\r\n\tbool validateDesignConfigurationInstantiation(QSharedPointer<DesignConfigurationInstantiation> instantiation) const;\r\n\t\r\n    /*!\r\n     *  Check if the design configuration reference is valid.\r\n     *\r\n     *    @param [in] instantiation   The selected design configuration instantiation.\r\n     *\r\n     *    @return True, if the design configuration reference is valid, otherwise false.\r\n     */\r\n    bool hasValidDesignConfigurationReference(QSharedPointer<DesignConfigurationInstantiation> instantiation)\r\n        const;\r\n\r\n    /*!\r\n     *  Finds possible errors in a design configuration instantiation and creates a list of them.\r\n     *\r\n     *    @param [in] errors          List of found errors.\r\n     *    @param [in] instantiation   The design configuration instantiation whose errors to find.\r\n\t *    @param [in] context         Context to help locate the errors.\r\n     */\r\n\tvoid findErrorsInDesignConfigurationInstantiation(QVector<QString>& errors,\r\n\t\tQSharedPointer<DesignConfigurationInstantiation> instantiation, QString const& contex) const;\r\n\r\n    /*!\r\n     *  Validates the given component instantiation.\r\n     *\r\n\t *    @param [in] instantiation   The component instantiation to validate.\r\n     *\r\n     *    @return True, if the component instantiation is valid IP-XACT, otherwise false.\r\n     */\r\n    bool validateComponentInstantiation(QSharedPointer<ComponentInstantiation> instantiation,\r\n        Document::Revision docRevision = Document::Revision::Std14) const;\r\n\r\n    /*!\r\n     *  Check if the file builders are valid.\r\n     *\r\n     *    @param [in] instantiation   The selected component instantiation.\r\n     *\r\n     *    @return True, if the file builders are valid, otherwise false.\r\n     */\r\n    bool componentInstantiationFileBuildersAreValid(QSharedPointer<ComponentInstantiation> instantiation) const;\r\n\r\n    /*!\r\n     *  Check if the file builder replace default flags value is valid.\r\n     *\r\n     *    @param [in] fileBuilder     The selected file builder.\r\n     *\r\n     *    @return True, if the replace default flags value is valid, otherwise false.\r\n     */\r\n    bool fileBuilderReplaceDefaultFlagsIsValid(QSharedPointer<FileBuilder> fileBuilder) const;\r\n\r\n    /*!\r\n     *  Check if the file set references are valid.\r\n     *\r\n     *    @param [in] instantiation   The selected component instantiation.\r\n     *\r\n     *    @return True, if the file set references are valid, otherwise false.\r\n     */\r\n    bool componentInstantiationFileSetReferencesAreValid(QSharedPointer<ComponentInstantiation> instantiation)\r\n        const;\r\n\r\n    /*!\r\n     *  Checks if file set referenced by parameter fileSetRef exist in file sets.\r\n     *\r\n\t *    @param [in] fileSetRef  The selected file set reference.\r\n     *\r\n     *    @return True, if the file set reference is valid, otherwise false.\r\n     */\r\n\tbool fileSetReferenceIsValid(QSharedPointer<FileSetRef> fileSetRef) const;\r\n\r\n    /*!\r\n     *  Finds possible errors in a instantiation and creates a list of them.\r\n     *\r\n     *    @param [in] errors          List of found errors.\r\n     *    @param [in] instantiation   The instantiation whose errors to find.\r\n\t *    @param [in] context         Context to help locate the errors.\r\n     */\r\n    virtual void findErrorsInComponentInstantiation(QVector<QString>& errors,\r\n        QSharedPointer<ComponentInstantiation> instantiation, QString const& context,\r\n        Document::Revision docRevision) const;\r\n\r\n    /*!\r\n     *  Get the assigned parameter validator.\r\n     *\r\n     *    @return The assigned parameter validator.\r\n     */\r\n    QSharedPointer<ParameterValidator> getParameterValidator() const;\r\n\r\n    void setParameterValidator(QSharedPointer<ParameterValidator> newParameterValidator);\r\n\r\n    void setExpressionParser(QSharedPointer<ExpressionParser> newExpressionParser);\r\n\r\nprivate:\r\n\r\n    /*!\r\n     *  Check if the contained parameters are valid.\r\n     *\r\n     *    @param [in] availableParameters     The contained parameters.\r\n     *\r\n     *    @return True, if the parameters are valid, otherwise false.\r\n     */\r\n    bool hasValidParameters(QSharedPointer<QList<QSharedPointer<Parameter> > > availableParameters) const;\r\n\r\n    /*!\r\n     *  Check if the contained module parameters are valid.\r\n     *\r\n     *    @param [in] instantiation   The selected component instantiation.\r\n     *\r\n     *    @return True, if the module parameters are valid, otherwise false.\r\n     */\r\n    bool hasValidModuleParameters(QSharedPointer<ComponentInstantiation> instantiation,\r\n        Document::Revision docRevision) const;\r\n\r\n    /*!\r\n     *  Check if the usage type of a model parameter is valid.\r\n     *\r\n     *    @param [in] parameter    The model parameter to be evaluated.\r\n     *\r\n     *    @return True, if the usage type is valid, otherwise false.\r\n     */\r\n\tbool moduleParameterHasValidUsageType(QSharedPointer<ModuleParameter> parameter, \r\n        Document::Revision docRevision) const;\r\n\r\n\t/*!\r\n\t *  Checks if isPresent element is valid.\r\n\t *\r\n\t *    @param [in] parameter\t\tThe selected module parameter.\r\n\t *\r\n\t *    @return True, if the presence is a valid expression, otherwise false.\r\n\t */\r\n\tbool moduleParameterHasValidPresence(QSharedPointer<ModuleParameter> parameter) const;\r\n\r\n\t// Disable copying.\r\n\tInstantiationsValidator(InstantiationsValidator const& rhs);\r\n\tInstantiationsValidator& operator=(InstantiationsValidator const& rhs);\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! The used expression parser.\r\n    QSharedPointer<ExpressionParser> expressionParser_;\r\n\r\n    //! The available file sets.\r\n    QSharedPointer<QList<QSharedPointer<FileSet> > > availableFileSets_;\r\n\r\n    //! The validator used for parameters.\r\n    QSharedPointer<ParameterValidator> parameterValidator_;\r\n\r\n    //! The used library interface.\r\n    LibraryInterface* libraryHandler_;\r\n};\r\n\r\n#endif // SYSTEMVERILOGVALIDATOR_H\r\n"
  },
  {
    "path": "IPXACTmodels/Component/validators/MemoryArrayValidator.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: MemoryArrayValidator.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Anton Hagqvist\n// Date: 21.7.2023\n//\n// Description:\n// Validator for ipxact:array memory array elements.\n//-----------------------------------------------------------------------------\n\n#include \"MemoryArrayValidator.h\"\n#include <IPXACTmodels/Component/MemoryArray.h>\n\n//-----------------------------------------------------------------------------\n// Function: MemoryArrayValidator::MemoryArrayValidator()\n//-----------------------------------------------------------------------------\nMemoryArrayValidator::MemoryArrayValidator(QSharedPointer<ExpressionParser> expressionParser):\n    expressionParser_(expressionParser)\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: MemoryArrayValidator::validate()\n//-----------------------------------------------------------------------------\nbool MemoryArrayValidator::validate(QSharedPointer<MemoryArray> memoryArray) const\n{\n    return hasValidDimensions(memoryArray) && hasValidStride(memoryArray);\n}\n\n//-----------------------------------------------------------------------------\n// Function: MemoryArrayValidator::findErrorsIn()\n//-----------------------------------------------------------------------------\nvoid MemoryArrayValidator::findErrorsIn(QStringList& errorList, QSharedPointer<MemoryArray> memoryArray,\n    QString const& context) const\n{\n    if (memoryArray->getDimensions()->isEmpty())\n    {\n        errorList.append(QObject::tr(\"No dimensions defined for memory array in %1\").arg(context));\n    }\n    \n    bool invalidDim = false;\n    for (auto const& dim : *memoryArray->getDimensions())\n    {\n        if (!hasValidElementValue(dim->value_, false))\n        {\n            invalidDim = true;\n            break;\n        }\n    }\n\n    if (invalidDim && !memoryArray->getDimensions()->isEmpty())\n    {\n        errorList.append(QObject::tr(\"One or more dimensions of the memory array in %1 have an invalid value.\")\n            .arg(context));\n    }\n\n    if (!hasValidStride(memoryArray))\n    {\n        errorList.append(QObject::tr(\"Memory array in %1 has an invalid stride value.\").arg(context));\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: MemoryArrayValidator::hasDimensions()\n//-----------------------------------------------------------------------------\nbool MemoryArrayValidator::hasValidDimensions(QSharedPointer<MemoryArray> memoryArray) const\n{\n    if (!memoryArray)\n    {\n        return true;\n    }\n\n    if (memoryArray->getDimensions()->isEmpty())\n    {\n        return false;\n    }\n\n    for (auto const& dim : *memoryArray->getDimensions())\n    {\n        if (!hasValidElementValue(dim->value_, false))\n        {\n            return false;\n        }\n    }\n        \n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: MemoryArrayValidator::hasValidStride()\n//-----------------------------------------------------------------------------\nbool MemoryArrayValidator::hasValidStride(QSharedPointer<MemoryArray> memoryArray) const\n{\n    return hasValidElementValue(memoryArray->getStride(), true);\n}\n\n//-----------------------------------------------------------------------------\n// Function: MemoryArrayValidator::hasValidElementValue()\n//-----------------------------------------------------------------------------\nbool MemoryArrayValidator::hasValidElementValue(QString const& value, bool canBeEmpty) const\n{\n    if (!value.isEmpty())\n    {\n        bool validValue = false;\n        auto solvedValue = expressionParser_->parseExpression(value, &validValue);\n\n        if (!validValue)\n        {\n            return false;\n        }\n\n        auto castedValue = solvedValue.toULongLong(&validValue);\n        if (!validValue || castedValue == 0)\n        {\n            return false;\n        }\n\n        return true;\n    }\n\n    return canBeEmpty;\n}\n"
  },
  {
    "path": "IPXACTmodels/Component/validators/MemoryArrayValidator.h",
    "content": "//-----------------------------------------------------------------------------\n// File: MemoryArrayValidator.h\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Anton Hagqvist\n// Date: 21.7.2023\n//\n// Description:\n// Validator for ipxact:array memory array elements.\n//-----------------------------------------------------------------------------\n\n#ifndef MEMORYARRAYVALIDATOR_H\n#define MEMORYARRAYVALIDATOR_H\n\n#include <IPXACTmodels/ipxactmodels_global.h>\n\n#include <KactusAPI/include/SystemVerilogExpressionParser.h>\n\n#include <QObject>\n\nclass MemoryArray;\n\nclass IPXACTMODELS_EXPORT MemoryArrayValidator\n{\npublic:\n\n    /*!\n     *\tThe constructor.\n     *  \n     *    @param [in] expressionParser     The expression parser to use.\n     */\n    MemoryArrayValidator(QSharedPointer<ExpressionParser> expressionParser);\n\n    virtual ~MemoryArrayValidator() = default;\n\n    MemoryArrayValidator(MemoryArrayValidator const& other) = delete;\n    MemoryArrayValidator& operator=(MemoryArrayValidator const& other) = delete;\n    \n    /*!\n     *\tValidates the given memory array.\n     *\n     *    @param [in] memoryArray     The memory array to validate.\n     *\n     * \t    @return True, if memory array is valid, otherwise false.\n     */\n    bool validate(QSharedPointer<MemoryArray> memoryArray) const;\n    \n    /*!\n     *\tChecks if a given memory array has dimensions defined.\n     *\n     *    @param [in] memoryArray     The memory array to check.\n     *\n     * \t    @return True, if at least one dimension is defined for the array.\n     */\n    bool hasValidDimensions(QSharedPointer<MemoryArray> memoryArray) const;\n    \n    /*!\n     *\tFinds errors within a memory array.\n     *\n     *    @param [in] errorList       A list of found errors.\n     *    @param [in] memoryArray     The memory array to check.\n     *    @param [in] context         Context to help locate the error.\n     */\n    void findErrorsIn(QStringList& errorList, QSharedPointer<MemoryArray> memoryArray,\n        QString const& context) const;\n\nprivate:\n\n\n    /*!\n     *\tValidate the (bit)stride of the array.\n     *  \n     *    @param [in] memoryArray     The memory array to check.\n     *\t    \n     * \t    @return True, if the stride can be evaluated or is empty, false otherwise.\n     */\n    bool hasValidStride(QSharedPointer<MemoryArray> memoryArray) const;\n\n    /*!\n     *\tValidates a given value as an unsigned, nonzero long int.\n     *  \n     *    @param [in] value       The value to check.\n     *    @param [in] canBeEmpty  Flag that indicates if the value given can be empty or not.\n     *\t    \n     * \t    @return True, if the given value is valid, false otherwise.\n     */\n    bool hasValidElementValue(QString const& value, bool canBeEmpty) const;\n\n    //! The expression parser to use.\n    QSharedPointer<ExpressionParser> expressionParser_;\n};\n\n#endif // MEMORYARRAYVALIDATOR_H\n"
  },
  {
    "path": "IPXACTmodels/Component/validators/MemoryBlockValidator.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: MemoryBlockValidator.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Mikko Teuho\n// Date: 16.02.2022\n//\n// Description:\n// Validator for memory block.\n//-----------------------------------------------------------------------------\n\n#include \"MemoryBlockValidator.h\"\n\n#include <KactusAPI/include/ExpressionParser.h>\n\n#include <IPXACTmodels/common/validators/ParameterValidator.h>\n#include <IPXACTmodels/common/validators/CommonItemsValidator.h>\n#include <IPXACTmodels/common/Parameter.h>\n#include <IPXACTmodels/Component/MemoryBlockBase.h>\n\n#include <QRegularExpression>\n\n//-----------------------------------------------------------------------------\n// Function: MemoryBlockValidator::MemoryBlockValidator()\n//-----------------------------------------------------------------------------\nMemoryBlockValidator::MemoryBlockValidator(QSharedPointer<ExpressionParser> expressionParser,\n    QSharedPointer<ParameterValidator> parameterValidator,\n    Document::Revision docRevision) :\nHierarchicalValidator(),\ndocRevision_(docRevision),\nexpressionParser_(expressionParser),\nparameterValidator_(parameterValidator)\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: MemoryBlockValidator::getExpressionParser()\n//-----------------------------------------------------------------------------\nQSharedPointer<ExpressionParser> MemoryBlockValidator::getExpressionParser() const\n{\n    return expressionParser_;\n}\n\n//-----------------------------------------------------------------------------\n// Function: MemoryBlockValidator::validate()\n//-----------------------------------------------------------------------------\nbool MemoryBlockValidator::validate(QSharedPointer<MemoryBlockBase> memoryBlock) const\n{\n    return validComparedToSiblings(memoryBlock) && \n        hasValidName(memoryBlock) &&\n        hasValidIsPresent(memoryBlock) &&\n        hasValidBaseAddress(memoryBlock) &&\n        hasValidParameters(memoryBlock);\n}\n\n//-----------------------------------------------------------------------------\n// Function: MemoryBlockValidator::hasValidName()\n//-----------------------------------------------------------------------------\nbool MemoryBlockValidator::hasValidName(QSharedPointer<MemoryBlockBase> memoryBlock) const\n{\n    return CommonItemsValidator::hasValidName(memoryBlock->name());\n}\n\n//-----------------------------------------------------------------------------\n// Function: MemoryBlockValidator::hasValidIsPresent()\n//-----------------------------------------------------------------------------\nbool MemoryBlockValidator::hasValidIsPresent(QSharedPointer<MemoryBlockBase> memoryBlock) const\n{\n    if (docRevision_ != Document::Revision::Std22 && !memoryBlock->getIsPresent().isEmpty())\n    {\n        QString solvedValue = expressionParser_->parseExpression(memoryBlock->getIsPresent());\n\n        bool toIntOk = true;\n        int intValue = solvedValue.toInt(&toIntOk);\n\n        if (!toIntOk || intValue < 0 || intValue > 1)\n        {\n            return false;\n        }\n    }\n\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: MemoryBlockValidator::hasValidBaseAddress()\n//-----------------------------------------------------------------------------\nbool MemoryBlockValidator::hasValidBaseAddress(QSharedPointer<MemoryBlockBase> memoryBlock) const\n{\n    bool toIntOk = true;\n\n    QString parsedBaseAddress = memoryBlock->getBaseAddress();\n\n    expressionParser_->parseExpression(memoryBlock->getBaseAddress()).toULongLong(&toIntOk);\n\n    return toIntOk;\n}\n\n//-----------------------------------------------------------------------------\n// Function: MemoryBlockValidator::hasValidParameters()\n//-----------------------------------------------------------------------------\nbool MemoryBlockValidator::hasValidParameters(QSharedPointer<MemoryBlockBase> memoryBlock) const\n{\n    if (!memoryBlock->getParameters()->isEmpty())\n    {\n        QStringList parameterNames;\n        for (QSharedPointer<Parameter> const& parameter : *memoryBlock->getParameters())\n        {\n            if (parameterNames.contains(parameter->name()) || !parameterValidator_->validate(parameter))\n            {\n                return false;\n            }\n            else\n            {\n                parameterNames.append(parameter->name());\n            }\n        }\n    }\n\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: MemoryBlockValidator::findErrorsInName()\n//-----------------------------------------------------------------------------\nvoid MemoryBlockValidator::findErrorsInName(QVector<QString>& errors, QSharedPointer<MemoryBlockBase> memoryBlock,\n    QString const& context) const\n{\n    if (!hasValidName(memoryBlock))\n    {\n        errors.append(\n            QObject::tr(\"Invalid name specified for %1 %2 within %3\").\n            arg(getBlockType(), memoryBlock->name(), context));\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: MemoryBlockValidator::findErrorsInIsPresent()\n//-----------------------------------------------------------------------------\nvoid MemoryBlockValidator::findErrorsInIsPresent(QVector<QString>& errors,\n    QSharedPointer<MemoryBlockBase> memoryBlock, QString const& context) const\n{\n    if (!hasValidIsPresent(memoryBlock))\n    {\n        errors.append(QObject::tr(\"Invalid isPresent set for %1 %2 within %3\").\n            arg(getBlockType(), memoryBlock->name(), context));\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: MemoryBlockValidator::findErrorsInBaseAddress()\n//-----------------------------------------------------------------------------\nvoid MemoryBlockValidator::findErrorsInBaseAddress(QVector<QString>& errors,\n    QSharedPointer<MemoryBlockBase> memoryBlock, QString const& context) const\n{\n    if (!hasValidBaseAddress(memoryBlock))\n    {\n        errors.append(QObject::tr(\"Invalid baseAddress set for %1 %2 within %3\").\n            arg(getBlockType(), memoryBlock->name(), context));\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: MemoryBlockValidator::findErrorsInParameters()\n//-----------------------------------------------------------------------------\nvoid MemoryBlockValidator::findErrorsInParameters(QVector<QString>& errors,\n    QSharedPointer<MemoryBlockBase> memoryBlock, QString const& context) const\n{\n    if (!memoryBlock->getParameters()->isEmpty())\n    {\n        QStringList parameterNames;\n        for (QSharedPointer<Parameter> const& parameter : *memoryBlock->getParameters())\n        {\n            if (parameterNames.contains(parameter->name()))\n            {\n                errors.append(QObject::tr(\"Name %1 of parameters in %2 is not unique.\").arg(parameter->name()).\n                    arg(context));\n            }\n            else\n            {\n                parameterNames.append(parameter->name());\n            }\n\n            parameterValidator_->findErrorsIn(errors, parameter, context);\n        }\n    }\n}\n"
  },
  {
    "path": "IPXACTmodels/Component/validators/MemoryBlockValidator.h",
    "content": "//-----------------------------------------------------------------------------\n// File: MemoryBlockValidator.h\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Mikko Teuho\n// Date: 16.02.2022\n//\n// Description:\n// Validator for memory block.\n//-----------------------------------------------------------------------------\n\n#ifndef MEMORYBLOCKVALIDATOR_H\n#define MEMORYBLOCKVALIDATOR_H\n\n#include <IPXACTmodels/ipxactmodels_global.h>\n\n#include <IPXACTmodels/common/Document.h>\n#include <IPXACTmodels/common/validators/HierarchicalValidator.h>\n\n#include <QSharedPointer>\n#include <QString>\n\nclass ExpressionParser;\nclass MemoryBlockBase;\nclass ParameterValidator;\n\n//-----------------------------------------------------------------------------\n//! Validator for memory block.\n//-----------------------------------------------------------------------------\nclass IPXACTMODELS_EXPORT MemoryBlockValidator : public HierarchicalValidator\n{\npublic:\n\n\t/*!\n\t *  The constructor.\n\t *\n\t *    @param [in] expressionParser    The parser to use for solving expressions.\n     *    @param [in] parameterValidator  Validator used for parameters.\n\t */\n    MemoryBlockValidator(QSharedPointer<ExpressionParser> expressionParser, \n        QSharedPointer<ParameterValidator> parameterValidator,\n        Document::Revision docRevision);\n\n\t/*!\n     *  The destructor.\n     */\n    ~MemoryBlockValidator() = default;\n\n    /*!\n     *  Validates the given memory block.\n     *\n     *    @param [in] memoryBlock     The memory block to validate.\n     *\n     *    @return True, if the memory block is valid IP-XACT, otherwise false.\n     */\n    bool validate(QSharedPointer<MemoryBlockBase> memoryBlock) const;\n\n    /*!\n     *  Check if the memory block contains a valid name.\n     *\n     *    @param [in] memoryBlock     The selected memory block.\n     *\n     *    @return True, if the name is valid, otherwise false.\n     */\n    bool hasValidName(QSharedPointer<MemoryBlockBase> memoryBlock) const;\n\n    /*!\n     *  Check if the memory block contains a valid isPresent value.\n     *\n     *    @param [in] memoryBlock     The selected memory block.\n     *\n     *    @return True, if the isPresent is valid, otherwise false.\n     */\n    bool hasValidIsPresent(QSharedPointer<MemoryBlockBase> memoryBlock) const;\n\n    /*!\n     *  Check if the memory block contains a valid base address.\n     *\n     *    @param [in] memoryBlock     The selected memory block.\n     *\n     *    @return True, if the base address is valid, otherwise false.\n     */\n    bool hasValidBaseAddress(QSharedPointer<MemoryBlockBase> memoryBlock) const;\n\n    /*!\n     *  Check if the memory block contains valid parameters.\n     *\n     *    @param [in] memoryBlock     The selected memory block.\n     *\n     *    @return True, if the parameters are valid, otherwise false.\n     */\n    bool hasValidParameters(QSharedPointer<MemoryBlockBase> memoryBlock) const;\n\nprotected:\n\n    /*!\n     *  Get the expression parser.\n     *\n     *    @return The parser for expressions.\n     */\n    QSharedPointer<ExpressionParser> getExpressionParser() const;\n    \n    /*!\n     *  Find errors within a name.\n     *\n     *    @param [in] errors          List of found errors.\n     *    @param [in] memoryBlock     The selected memory block.\n     *    @param [in] context         Context to help locate the error.\n     */\n    void findErrorsInName(QVector<QString>& errors, QSharedPointer<MemoryBlockBase> memoryBlock,\n        QString const& context) const;\n\n    /*!\n     *  Find errors within isPresent.\n     *\n     *    @param [in] errors          List of found errors.\n     *    @param [in] memoryBlock     The selected memory block.\n     *    @param [in] context         Context to help locate the error.\n     */\n    void findErrorsInIsPresent(QVector<QString>& errors, QSharedPointer<MemoryBlockBase> memoryBlock,\n        QString const& context) const;\n\n    /*!\n     *  Find errors within base address.\n     *\n     *    @param [in] errors          List of found errors.\n     *    @param [in] memoryBlock     The selected memory block.\n     *    @param [in] context         Context to help locate the error.\n     */\n    void findErrorsInBaseAddress(QVector<QString>& errors, QSharedPointer<MemoryBlockBase> memoryBlock,\n        QString const& context) const;\n\n    /*!\n     *  Find errors within memory block parameters.\n     *\n     *    @param [in] errors          List of found errors.\n     *    @param [in] memoryBlock     The selected memory block.\n     *    @param [in] context         Context to help locate the error.\n     */\n    void findErrorsInParameters(QVector<QString>& errors, QSharedPointer<MemoryBlockBase> memoryBlock,\n        QString const& context) const;\n\n    //! The IP-XACT standard revision to comply to.\n    Document::Revision docRevision_;\n\nprivate:\n\n\t// Disable copying.\n\tMemoryBlockValidator(MemoryBlockValidator const& rhs);\n    MemoryBlockValidator& operator=(MemoryBlockValidator const& rhs);\n\n    /*!\n     *  Get the type of the memory block.\n     *\n     *    @return Identification type of the memory block.\n     */\n    virtual QString getBlockType() const = 0;\n\n    //-----------------------------------------------------------------------------\n    // Data.\n    //-----------------------------------------------------------------------------\n\n    //! The expression parser to use.\n    QSharedPointer<ExpressionParser> expressionParser_;\n\n    //! The validator used for parameters.\n    QSharedPointer<ParameterValidator> parameterValidator_;\n};\n\n#endif // MEMORYBLOCKVALIDATOR_H\n"
  },
  {
    "path": "IPXACTmodels/Component/validators/MemoryMapBaseValidator.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: MemoryMapBaseValidator.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 25.11.2015\r\n//\r\n// Description:\r\n// Validator for the memoryMap base class.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"MemoryMapBaseValidator.h\"\r\n\r\n#include <KactusAPI/include/ExpressionParser.h>\r\n\r\n#include <IPXACTmodels/Component/Component.h>\r\n#include <IPXACTmodels/Component/AddressSpace.h>\r\n#include <IPXACTmodels/Component/BusInterface.h>\r\n#include <IPXACTmodels/Component/MemoryMapBase.h>\r\n#include <IPXACTmodels/Component/MemoryBlockBase.h>\r\n#include <IPXACTmodels/Component/AddressBlock.h>\r\n#include <IPXACTmodels/Component/SubSpaceMap.h>\r\n\r\n#include <IPXACTmodels/Component/validators/AddressBlockValidator.h>\r\n#include <IPXACTmodels/Component/validators/SubspaceMapValidator.h>\r\n#include <IPXACTmodels/Component/validators/CollectionValidators.h>\r\n\r\n#include <QRegularExpression>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryMapBaseValidator::MemoryMapBaseValidator()\r\n//-----------------------------------------------------------------------------\r\nMemoryMapBaseValidator::MemoryMapBaseValidator(QSharedPointer<ExpressionParser> expressionParser,\r\n    QSharedPointer<AddressBlockValidator> addressBlockValidator,\r\n    QSharedPointer<SubspaceMapValidator> subspaceValidator,\r\n    Document::Revision docRevision):\r\nHierarchicalValidator(),\r\ndocRevision_(docRevision),\r\nexpressionParser_(expressionParser),\r\naddressBlockValidator_(addressBlockValidator),\r\nsubspaceValidator_(subspaceValidator),\r\navailableBusInterfaces_(),\r\navailableSpaces_()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryMapBaseValidator::componentChange()\r\n//-----------------------------------------------------------------------------\r\nvoid MemoryMapBaseValidator::componentChange(QSharedPointer<Component> newComponent)\r\n{\r\n    addressBlockValidator_->componentChange(newComponent);\r\n    subspaceValidator_->componentChange(newComponent);\r\n\r\n    availableBusInterfaces_.clear();\r\n    availableSpaces_.clear();\r\n\r\n    if (newComponent)\r\n    {\r\n        availableBusInterfaces_ = newComponent->getBusInterfaces();\r\n        availableSpaces_ = newComponent->getAddressSpaces();\r\n        docRevision_ = newComponent->getRevision();\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryMapBaseValidator::getAddressBlockValidator()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<AddressBlockValidator> MemoryMapBaseValidator::getAddressBlockValidator() const\r\n{\r\n    return addressBlockValidator_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryMapBaseValidator::getSubspaceValidator()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<SubspaceMapValidator> MemoryMapBaseValidator::getSubspaceValidator() const\r\n{\r\n    return subspaceValidator_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryMapBaseValidator::validate()\r\n//-----------------------------------------------------------------------------\r\nbool MemoryMapBaseValidator::validate(QSharedPointer<MemoryMapBase> memoryMapBase, QString const& addressUnitBits)\r\n{\r\n    return hasValidName(memoryMapBase) && hasValidIsPresent(memoryMapBase) && \r\n        hasValidMemoryBlocks(memoryMapBase, addressUnitBits) && validComparedToSiblings(memoryMapBase);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryMapBaseValidator::markBlocksWithDuplicateNames()\r\n//-----------------------------------------------------------------------------\r\nbool MemoryMapBaseValidator::markBlocksWithDuplicateNames(QMultiHash<QString, QSharedPointer<NameGroup>> const& foundNames)\r\n{\r\n    bool errorFound = false;\r\n    for (auto const& name : foundNames.keys())\r\n    {\r\n        if (auto const& duplicateNames = foundNames.values(name);\r\n            duplicateNames.count() > 1)\r\n        {\r\n            std::for_each(duplicateNames.begin(), duplicateNames.end(),\r\n                [this](QSharedPointer<NameGroup> memoryBlock)\r\n                {\r\n                    if (auto asAddressBlock = memoryBlock.dynamicCast<AddressBlock>())\r\n                    {\r\n                        addressBlockValidator_->setChildItemValidity(asAddressBlock, false);\r\n                    }\r\n                    else if (auto asSubspace = memoryBlock.dynamicCast<SubSpaceMap>())\r\n                    {\r\n                        subspaceValidator_->setChildItemValidity(asSubspace, false);\r\n                    }\r\n                });\r\n\r\n            errorFound = true;\r\n        }\r\n    }\r\n\r\n    return errorFound;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryMapBaseValidator::hasValidName()\r\n//-----------------------------------------------------------------------------\r\nbool MemoryMapBaseValidator::hasValidName(QSharedPointer<MemoryMapBase> memoryMapBase) const\r\n{\r\n    QRegularExpression whiteSpaceExpression;\r\n    whiteSpaceExpression.setPattern(QStringLiteral(\"^\\\\s*$\"));\r\n    QRegularExpressionMatch whiteSpaceMatch = whiteSpaceExpression.match(memoryMapBase->name());\r\n\r\n    if (memoryMapBase->name().isEmpty() || whiteSpaceMatch.hasMatch())\r\n    {\r\n        return false;\r\n    }\r\n\r\n    return true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryMapBaseValidator::hasValidIsPresent()\r\n//-----------------------------------------------------------------------------\r\nbool MemoryMapBaseValidator::hasValidIsPresent(QSharedPointer<MemoryMapBase> memoryMapBase) const\r\n{\r\n    if (!memoryMapBase->getIsPresent().isEmpty())\r\n    {\r\n        QString solvedValue = expressionParser_->parseExpression(memoryMapBase->getIsPresent());\r\n\r\n        bool toIntOk = true;\r\n        int intValue = solvedValue.toInt(&toIntOk);\r\n\r\n        if (!toIntOk || intValue < 0 || intValue > 1)\r\n        {\r\n            return false;\r\n        }\r\n    }\r\n\r\n    return true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryMapBaseValidator::hasValidMemoryBlocks()\r\n//-----------------------------------------------------------------------------\r\nbool MemoryMapBaseValidator::hasValidMemoryBlocks(QSharedPointer<MemoryMapBase> memoryMapBase,\r\n    QString const& addressUnitBits)\r\n{\r\n    if (memoryMapBase->getMemoryBlocks()->isEmpty())\r\n    {\r\n        return true;\r\n    }\r\n    \r\n    bool errorFound = false;\r\n    \r\n    // Address block and subspace map names should be unique, subspace can't have the same name as an address block.\r\n    QMultiHash<QString, QSharedPointer<NameGroup> > foundMemoryBlockNames;\r\n\r\n    auto childBlocksCopy = QSharedPointer<QList<QSharedPointer<MemoryBlockBase> > >(new QList(*memoryMapBase->getMemoryBlocks()));\r\n\r\n    // Sort blocks by base address to make checking for overlaps easier.\r\n    auto sortByBaseAddr = [this](QSharedPointer<MemoryBlockBase> memoryBlockA, QSharedPointer<MemoryBlockBase> memoryBlockB)\r\n        {\r\n            return expressionParser_->parseExpression(memoryBlockA->getBaseAddress()).toLongLong() <\r\n                expressionParser_->parseExpression(memoryBlockB->getBaseAddress()).toLongLong();\r\n        };\r\n\r\n    std::sort(childBlocksCopy->begin(), childBlocksCopy->end(), sortByBaseAddr);\r\n\r\n    quint64 lastEnd = 0;\r\n    bool lastBlockWasAddressBlock = false;\r\n\r\n    // Validate blocks together\r\n    for (int blockIndex = 0; blockIndex < childBlocksCopy->size(); ++blockIndex)\r\n    {\r\n        auto child = childBlocksCopy->at(blockIndex).staticCast<MemoryBlockBase>();\r\n        bool currentIsAddressBlock = false;\r\n\r\n        // First check names, but don't set invalidity yet.\r\n        if (auto addressBlock = child.dynamicCast<AddressBlock>())\r\n        {\r\n            if (!foundMemoryBlockNames.contains(addressBlock->name()))\r\n            {\r\n                addressBlockValidator_->setChildItemValidity(addressBlock, true);\r\n            }\r\n\r\n            foundMemoryBlockNames.insert(addressBlock->name(), addressBlock);\r\n            currentIsAddressBlock = true;\r\n        }\r\n        else if (auto subspaceMap = child.dynamicCast<SubSpaceMap>())\r\n        {\r\n            if (!foundMemoryBlockNames.contains(subspaceMap->name()))\r\n            {\r\n                subspaceValidator_->setChildItemValidity(subspaceMap, true);\r\n            }\r\n\r\n            foundMemoryBlockNames.insert(subspaceMap->name(), subspaceMap);\r\n        }\r\n\r\n        // Check overlaps of the sorted blocks comparing the start of the current block to the end of \r\n        // the current rightmost point, last block or not.\r\n        bool childPresent = child->getIsPresent().isEmpty() ||\r\n            expressionParser_->parseExpression(child->getIsPresent()).toInt();\r\n\r\n        if (blockIndex == 0 && childPresent)\r\n        {\r\n            quint64 blockBegin = expressionParser_->parseExpression(child->getBaseAddress()).toULongLong();\r\n            lastEnd = blockBegin + getBlockRange(child) - 1;\r\n        }\r\n        else if (childPresent)\r\n        {\r\n            quint64 blockBegin = expressionParser_->parseExpression(child->getBaseAddress()).toULongLong();\r\n            quint64 blockEnd = blockBegin + getBlockRange(child) - 1;\r\n\r\n            // Mark this and the last block as invalid, if overlap.\r\n            if (blockBegin <= lastEnd)\r\n            {\r\n                lastBlockWasAddressBlock\r\n                    ? addressBlockValidator_->setChildItemValidity(childBlocksCopy->at(blockIndex - 1), false)\r\n                    : subspaceValidator_->setChildItemValidity(childBlocksCopy->at(blockIndex - 1), false);\r\n\r\n                currentIsAddressBlock\r\n                    ? addressBlockValidator_->setChildItemValidity(child, false)\r\n                    : subspaceValidator_->setChildItemValidity(child, false);\r\n                errorFound = true;\r\n            }\r\n\r\n            if (blockEnd > lastEnd)\r\n            {\r\n                lastEnd = blockEnd;\r\n            }\r\n        }\r\n\r\n        lastBlockWasAddressBlock = currentIsAddressBlock;\r\n    }\r\n\r\n    // Mark all blocks with duplicate names invalid.\r\n    if (markBlocksWithDuplicateNames(foundMemoryBlockNames))\r\n    {\r\n        errorFound = true;\r\n    }\r\n\r\n    // No need to check child blocks if they are erroneous together.\r\n    if (errorFound)\r\n    {\r\n        return false;\r\n    }\r\n\r\n    // Validate blocks separately\r\n    for (auto const& child : *childBlocksCopy)\r\n    {\r\n        if (QSharedPointer<AddressBlock> addressBlock = child.dynamicCast<AddressBlock>();\r\n            addressBlock && (!addressBlockValidator_->validate(addressBlock, addressUnitBits)\r\n            || !addressBlockWidthIsMultipleOfAUB(addressUnitBits, addressBlock)))\r\n        {\r\n            return false;\r\n        }\r\n        else if (QSharedPointer<SubSpaceMap> subspace = child.dynamicCast<SubSpaceMap>();\r\n            subspace && !subspaceValidator_->validate(subspace))\r\n        {\r\n            return false;\r\n        }\r\n    }\r\n\r\n    return true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryMapBaseValidator::addressBlockWidthIsMultipleOfAUB()\r\n//-----------------------------------------------------------------------------\r\nbool MemoryMapBaseValidator::addressBlockWidthIsMultipleOfAUB(QString const& addressUnitBits,\r\n    QSharedPointer<AddressBlock> addressBlock) const\r\n{\r\n    bool aubToIntOk = true;\r\n    bool widthToIntOk = true;\r\n\r\n    int addressUnitBitsInt = expressionParser_->parseExpression(addressUnitBits).toInt(&aubToIntOk);\r\n    int addressBlockWidth = expressionParser_->parseExpression(addressBlock->getWidth()).toInt(&widthToIntOk);\r\n\r\n    bool isValid = aubToIntOk && widthToIntOk && addressUnitBitsInt != 0 && addressBlockWidth % addressUnitBitsInt == 0;\r\n    if (!isValid)\r\n    {\r\n        addressBlockValidator_->setChildItemValidity(addressBlock, false);\r\n    }\r\n\r\n    return isValid;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryMapBaseValidator::twoAddressBlocksOverlap()\r\n//-----------------------------------------------------------------------------\r\nbool MemoryMapBaseValidator::twoMemoryBlocksOverlap(QSharedPointer<MemoryBlockBase> memoryBlock,\r\n    QSharedPointer<MemoryBlockBase> comparedBlock) const\r\n{\r\n    bool blockPresent = memoryBlock->getIsPresent().isEmpty() ||\r\n        expressionParser_->parseExpression(memoryBlock->getIsPresent()).toInt();\r\n    bool comparedPresent = comparedBlock->getIsPresent().isEmpty() ||\r\n        expressionParser_->parseExpression(comparedBlock->getIsPresent()).toInt();\r\n\r\n    if (blockPresent && comparedPresent)\r\n    {\r\n        quint64 blockBegin = expressionParser_->parseExpression(memoryBlock->getBaseAddress()).toULongLong();\r\n        quint64 blockEnd = blockBegin + getBlockRange(memoryBlock) - 1;\r\n\r\n        quint64 compareBegin = expressionParser_->parseExpression(comparedBlock->getBaseAddress()).toULongLong();\r\n        quint64 compareEnd = compareBegin + getBlockRange(comparedBlock) - 1;\r\n\r\n        if (((blockBegin >= compareBegin && blockBegin <= compareEnd) ||\r\n            (blockEnd >= compareBegin && blockEnd <= compareEnd)) ||\r\n            ((compareBegin >= blockBegin && compareBegin <= blockEnd) ||\r\n            (compareEnd >= blockBegin && compareEnd <= blockEnd)))\r\n        {\r\n            return true;\r\n        }\r\n    }\r\n\r\n    return false;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryMapBaseValidator::getBlockEnd()\r\n//-----------------------------------------------------------------------------\r\nquint64 MemoryMapBaseValidator::getBlockRange(QSharedPointer<MemoryBlockBase> block) const\r\n{\r\n    quint64 memoryRange = 0;\r\n    QSharedPointer<AddressBlock> addressBlock = block.dynamicCast<AddressBlock>();\r\n    if (addressBlock)\r\n    {\r\n        memoryRange = expressionParser_->parseExpression(addressBlock->getRange()).toULongLong();\r\n    }\r\n\r\n    QSharedPointer<SubSpaceMap> subspace = block.dynamicCast<SubSpaceMap>();\r\n    if (subspace)\r\n    {\r\n        memoryRange = 1;\r\n\r\n        QSharedPointer<AddressSpace> referencedSpace = getReferencedAddressSpace(subspace);\r\n        if (referencedSpace)\r\n        {\r\n            QSharedPointer<Segment> referencedSegment = getReferencedSegment(subspace, referencedSpace);\r\n\r\n            if (referencedSegment)\r\n            {\r\n                memoryRange = expressionParser_->parseExpression(referencedSegment->getRange()).toULongLong();\r\n            }\r\n            else\r\n            {\r\n                memoryRange = expressionParser_->parseExpression(referencedSpace->getRange()).toULongLong();\r\n            }\r\n        }\r\n    }\r\n\r\n    return memoryRange;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryMapBaseValidator::getReferencedAddressSpace()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<AddressSpace> MemoryMapBaseValidator::getReferencedAddressSpace(\r\n    QSharedPointer<SubSpaceMap> subspace) const\r\n{\r\n    for (auto bus : *availableBusInterfaces_)\r\n    {\r\n        if (subspace->getInitiatorReference() == bus->name())\r\n        {\r\n            for (auto space : *availableSpaces_)\r\n            {\r\n                if (bus->getAddressSpaceRef() == space->name())\r\n                {\r\n                    return space;\r\n                }\r\n            }\r\n        }\r\n    }\r\n\r\n    return QSharedPointer<AddressSpace>();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryMapBaseValidator::getReferencedSegment()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<Segment> MemoryMapBaseValidator::getReferencedSegment(QSharedPointer<SubSpaceMap> subspace,\r\n    QSharedPointer<AddressSpace> containingSpace) const\r\n{\r\n    for (auto segment : *containingSpace->getSegments())\r\n    {\r\n        if (segment->name() == subspace->getSegmentReference())\r\n        {\r\n            return segment;\r\n        }\r\n    }\r\n\r\n    return QSharedPointer<Segment>();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryMapBaseValidator::findErrorsIn()\r\n//-----------------------------------------------------------------------------\r\nvoid MemoryMapBaseValidator::findErrorsIn(QVector<QString>& errors, QSharedPointer<MemoryMapBase> memoryMapBase,\r\n    QString const& addressUnitBits, QString const& context)\r\n{\r\n    QString memoryMapContext = memoryMapBase->elementName();\r\n    memoryMapContext.append(QLatin1Char(' '));\r\n    memoryMapContext.append(memoryMapBase->name());\r\n\r\n    findErrorsInName(errors, memoryMapBase, context);\r\n    findErrorsInIsPresent(errors, memoryMapBase, context);\r\n    findErrorsInAddressBlocks(errors, memoryMapBase, addressUnitBits, memoryMapContext);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryMapBaseValidator::findErrorsInName()\r\n//-----------------------------------------------------------------------------\r\nvoid MemoryMapBaseValidator::findErrorsInName(QVector<QString>& errors,\r\n    QSharedPointer<MemoryMapBase> memoryMapBase, QString const& context) const\r\n{\r\n    if (!hasValidName(memoryMapBase))\r\n    {\r\n        errors.append(QObject::tr(\"Invalid name specified for %1 %2 within %3\").arg(memoryMapBase->elementName())\r\n            .arg(memoryMapBase->name()).arg(context));\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryMapBaseValidator::findErrorsInIsPresent()\r\n//-----------------------------------------------------------------------------\r\nvoid MemoryMapBaseValidator::findErrorsInIsPresent(QVector<QString>& errors,\r\n    QSharedPointer<MemoryMapBase> memoryMapBase, QString const& context) const\r\n{\r\n    if (docRevision_ == Document::Revision::Std14 && !hasValidIsPresent(memoryMapBase))\r\n    {\r\n        errors.append(QObject::tr(\"Invalid isPresent set for %1 %2 within %3\").arg(memoryMapBase->elementName())\r\n            .arg(memoryMapBase->name()).arg(context));\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryMapBaseValidator::findErrorsInAddressBlocks()\r\n//-----------------------------------------------------------------------------\r\nvoid MemoryMapBaseValidator::findErrorsInAddressBlocks(QVector<QString>& errors,\r\n    QSharedPointer<MemoryMapBase> memoryMapBase, QString const& addressUnitBits, QString const& context)\r\n{\r\n    if (memoryMapBase->getMemoryBlocks()->isEmpty())\r\n    {\r\n        return;\r\n    }\r\n    \r\n    // Keep track of found names, and if an error has been issued for duplicate names.\r\n    QHash<QString, bool> memoryBlockNames; \r\n\r\n    for (int blockIndex = 0; blockIndex < memoryMapBase->getMemoryBlocks()->size(); ++blockIndex)\r\n    {\r\n        QSharedPointer<MemoryBlockBase> memoryBlock = memoryMapBase->getMemoryBlocks()->at(blockIndex);\r\n        if (memoryBlockNames.contains(memoryBlock->name()) && memoryBlockNames[memoryBlock->name()] == false)\r\n        {\r\n            errors.append(QObject::tr(\"Name %1 of memory blocks in %2 is not unique\")\r\n                .arg(memoryBlock->name()).arg(context));\r\n            memoryBlockNames[memoryBlock->name()] = true;\r\n        }\r\n        else\r\n        {\r\n            memoryBlockNames.insert(memoryBlock->name(), false);\r\n        }\r\n\r\n        if (QSharedPointer<AddressBlock> addressBlock = memoryBlock.dynamicCast<AddressBlock>())\r\n        {\r\n            addressBlockValidator_->findErrorsIn(errors, addressBlock, addressUnitBits, context);\r\n            if (!addressBlockWidthIsMultipleOfAUB(addressUnitBits, addressBlock))\r\n            {\r\n                errors.append(QObject::tr(\r\n                    \"Width of address block %1 is not a multiple of the address unit bits of %2 %3\")\r\n                    .arg(addressBlock->name())\r\n                    .arg(memoryMapBase->elementName())\r\n                    .arg(memoryMapBase->name()));\r\n            }\r\n        }\r\n        else if (QSharedPointer<SubSpaceMap> subspace = memoryBlock.dynamicCast<SubSpaceMap>())\r\n        {\r\n            subspaceValidator_->findErrorsIn(errors, subspace, context);\r\n        }\r\n\r\n        findErrorsInOverlappingBlocks(errors, memoryMapBase, memoryBlock, blockIndex, context);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryMapBaseValidator::findErrorsInOverlappingBlocks()\r\n//-----------------------------------------------------------------------------\r\nvoid MemoryMapBaseValidator::findErrorsInOverlappingBlocks(QVector<QString>& errors,\r\n    QSharedPointer<MemoryMapBase> memoryMapBase, QSharedPointer<MemoryBlockBase> memoryBlock, int blockIndex,\r\n    QString const& context) const\r\n{\r\n    for (int comparisonIndex = blockIndex + 1; comparisonIndex < memoryMapBase->getMemoryBlocks()->size();\r\n        ++comparisonIndex)\r\n    {\r\n        QSharedPointer<MemoryBlockBase> comparisonBlock = memoryMapBase->getMemoryBlocks()->at(comparisonIndex);\r\n        if (comparisonBlock)\r\n        {\r\n            if (twoMemoryBlocksOverlap(memoryBlock, comparisonBlock))\r\n            {\r\n                errors.append(QObject::tr(\"Memory blocks %1 and %2 overlap in %3\")\r\n                    .arg(memoryBlock->name()).arg(comparisonBlock->name()).arg(context));\r\n            }\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryMapBaseValidator::getExpressionParser()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<ExpressionParser> MemoryMapBaseValidator::getExpressionParser() const\r\n{\r\n    return expressionParser_;\r\n}\r\n"
  },
  {
    "path": "IPXACTmodels/Component/validators/MemoryMapBaseValidator.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: MemoryMapBaseValidator.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 25.11.2015\r\n//\r\n// Description:\r\n// Validator for the memoryMap base class.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef MEMORYMAPBASEVALIDATOR_H\r\n#define MEMORYMAPBASEVALIDATOR_H\r\n\r\n#include <IPXACTmodels/ipxactmodels_global.h>\r\n\r\n#include <IPXACTmodels/common/Document.h>\r\n#include <IPXACTmodels/common/validators/HierarchicalValidator.h>\r\n\r\n#include <QSharedPointer>\r\n#include <QString>\r\n\r\nclass ExpressionParser;\r\nclass MemoryMapBase;\r\nclass MemoryBlockBase;\r\nclass AddressBlockValidator;\r\nclass ResetType;\r\nclass SubspaceMapValidator;\r\nclass Component;\r\nclass AddressBlock;\r\nclass SubSpaceMap;\r\nclass BusInterface;\r\nclass AddressSpace;\r\nclass Segment;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Validator for the base ipxact:memoryMap.\r\n//-----------------------------------------------------------------------------\r\nclass IPXACTMODELS_EXPORT MemoryMapBaseValidator : public HierarchicalValidator\r\n{\r\npublic:\r\n\r\n\r\n\t/*!\r\n\t *  The constructor.\r\n\t *\r\n\t *    @param [in] expressionParser        The parser to use for solving expressions.\r\n     *    @param [in] addressBlockValidator   Validator used for address blocks.\r\n\t */\r\n    MemoryMapBaseValidator(QSharedPointer<ExpressionParser> expressionParser,\r\n        QSharedPointer<AddressBlockValidator> addressBlockValidator,\r\n        QSharedPointer<SubspaceMapValidator> subspaceValidator,\r\n        Document::Revision docRevision = Document::Revision::Unknown);\r\n\r\n\t/*!\r\n     *  The destructor.\r\n     */\r\n\tvirtual ~MemoryMapBaseValidator() = default;\r\n\r\n    // Disable copying.\r\n    MemoryMapBaseValidator(MemoryMapBaseValidator const& rhs) = delete;\r\n    MemoryMapBaseValidator& operator=(MemoryMapBaseValidator const& rhs) = delete;\r\n    \r\n    /*!\r\n     *  Change the containing component.\r\n     *\r\n     *    @param [in] newComponent    The selected component.\r\n     */\r\n    void componentChange(QSharedPointer<Component> newComponent);\r\n\r\n    /*!\r\n     *  Get the validator used for address blocks.\r\n     *\r\n     *    @return The validator used for address blocks.\r\n     */\r\n    QSharedPointer<AddressBlockValidator> getAddressBlockValidator() const;\r\n\r\n    /*!\r\n     *  Get the validator used for subspace maps.\r\n     *\r\n     *    @return The validator used for subspace maps.\r\n     */\r\n    QSharedPointer<SubspaceMapValidator> getSubspaceValidator() const;\r\n\r\n    /*!\r\n     *  Validates the given memory map base.\r\n     *\r\n     *    @param [in] memoryMapBase       The memory map base to validate.\r\n     *    @param [in] addressUnitBits     The address unit bits used by the memory map.\r\n     *\r\n     *    @return True, if the memory map base is valid IP-XACT, otherwise false.\r\n     */\r\n    virtual bool validate(QSharedPointer<MemoryMapBase> memoryMapBase, QString const& addressUnitBits);\r\n\r\n    /*!\r\n     *  Check if the memory map base contains a valid name.\r\n     *\r\n     *    @param [in] memoryMapBase   The selected memory map base.\r\n     *\r\n     *    @return True, if the name is valid, otherwise false.\r\n     */\r\n    bool hasValidName(QSharedPointer<MemoryMapBase> memoryMapBase) const;\r\n\r\n    /*!\r\n     *  Check if the memory map base contains a valid isPresent value.\r\n     *\r\n     *    @param [in] memoryMapBase   The selected memory map base.\r\n     *\r\n     *    @return True, if the isPresent is valid, otherwise false.\r\n     */\r\n    bool hasValidIsPresent(QSharedPointer<MemoryMapBase> memoryMapBase) const;\r\n\r\n    /*!\r\n     *  Check if the memory map base contains valid memory blocks.\r\n     *\r\n     *    @param [in] memoryMapBase       The selected memory map base.\r\n     *    @param [in] addressUnitBits     The address unit bits used by the memory map.\r\n     *\r\n     *    @return True, if the memory blocks are valid, otherwise false.\r\n     */\r\n    bool hasValidMemoryBlocks(QSharedPointer<MemoryMapBase> memoryMapBase, QString const& addressUnitBits);\r\n\r\n    /*!\r\n     *  Locate errors within a memory map base.\r\n     *\r\n     *    @param [in] errors              List of found errors.\r\n     *    @param [in] memoryMapBase       The selected memory map base.\r\n     *    @param [in] addressUnitBits     The address unit bits used by the memory map.\r\n     *    @param [in] context             Context to help locate the error.\r\n     */\r\n    virtual void findErrorsIn(QVector<QString>& errors, QSharedPointer<MemoryMapBase> memoryMapBase,\r\n        QString const& addressUnitBits, QString const& context);\r\n\r\nprotected:\r\n\r\n    /*!\r\n     *  Get the expression parser.\r\n     *\r\n     *    @return The used expression parser.\r\n     */\r\n    QSharedPointer<ExpressionParser> getExpressionParser() const;\r\n\r\n    //! The IP-XACT standard revision to comply to.\r\n    Document::Revision docRevision_;\r\n\r\nprivate:\r\n\r\n\r\n    /*!\r\n     *\tMark address blocks and subspace maps as invalid if they have duplicate names.\r\n     *\r\n     *    @param [in] foundNames     The found names and associated memory blocks.\r\n     *\r\n     * \t    @return True, if duplicate names were found, otherwise false.\r\n     */\r\n    bool markBlocksWithDuplicateNames(QMultiHash<QString, QSharedPointer<NameGroup>> const& foundNames);\r\n\r\n    /*!\r\n     *  Check if two memory blocks overlap.\r\n     *\r\n     *    @param [in] memoryBlock     The selected memory block.\r\n     *    @param [in] comparedBlock   The compared memory block.\r\n     */\r\n    bool twoMemoryBlocksOverlap(QSharedPointer<MemoryBlockBase> memoryBlock,\r\n        QSharedPointer<MemoryBlockBase> comparedBlock) const;\r\n\r\n    /*!\r\n     *  Get the range of the selected memory block\r\n     *\r\n     *    @param [in] block   The selected memory block.\r\n     *\r\n     *    @return Range of the selected memory block.\r\n     */\r\n    quint64 getBlockRange(QSharedPointer<MemoryBlockBase> block) const;\r\n\r\n    /*!\r\n     *  Get the address space referenced by the selected subspace map.\r\n     *\r\n     *    @param [in] subspace    The selected subspace map.\r\n     *\r\n     *    @return The referenced address space.\r\n     */\r\n    QSharedPointer<AddressSpace> getReferencedAddressSpace(QSharedPointer<SubSpaceMap> subspace) const;\r\n\r\n    /*!\r\n     *  Get the segment referenced by the selected subspace map.\r\n     *\r\n     *    @param [in] subspace            The selected subspace map.\r\n     *    @param [in] containingSpace     Address space referenced by the subspace map.\r\n     *\r\n     *    @return Segment referened by the selected subspace map.\r\n     */\r\n    QSharedPointer<Segment> getReferencedSegment(QSharedPointer<SubSpaceMap> subspace,\r\n        QSharedPointer<AddressSpace> containingSpace) const;\r\n\r\n    /*!\r\n     *  Check if the address block width is a multiple of address unit bits.\r\n     *\r\n     *    @param [in] addressUnitBits     The address unit bits.\r\n     *    @param [in] addressBlock        The selected address block.\r\n     *\r\n     *    @return True, if the address block width is a multiple of address unit bits, otherwise false.\r\n     */\r\n    bool addressBlockWidthIsMultipleOfAUB(QString const& addressUnitBits,\r\n        QSharedPointer<AddressBlock> addressBlock) const;\r\n    \r\n    /*!\r\n     *  Find errors within a name.\r\n     *\r\n     *    @param [in] errors          List of found errors.\r\n     *    @param [in] memoryMapBase   The selected memory map base.\r\n     *    @param [in] context         Context to help locate the error.\r\n     */\r\n    void findErrorsInName(QVector<QString>& errors, QSharedPointer<MemoryMapBase> memoryMapBase,\r\n        QString const& context) const;\r\n\r\n    /*!\r\n     *  Find errors within a isPresent.\r\n     *\r\n     *    @param [in] errors          List of found errors.\r\n     *    @param [in] memoryMapBase   The selected memory map base.\r\n     *    @param [in] context         Context to help locate the error.\r\n     */\r\n    void findErrorsInIsPresent(QVector<QString>& errors, QSharedPointer<MemoryMapBase> memoryMapBase,\r\n        QString const& context) const;\r\n\r\n    /*!\r\n     *  Find errors within address blocks.\r\n     *\r\n     *    @param [in] errors              List of found errors.\r\n     *    @param [in] memoryMapBase       The selected memory map base.\r\n     *    @param [in] addressUnitBits     The address unit bits used by the memory map.\r\n     *    @param [in] context             Context to help locate the error.\r\n     */\r\n    void findErrorsInAddressBlocks(QVector<QString>& errors, QSharedPointer<MemoryMapBase> memoryMapBase,\r\n        QString const& addressUnitBits, QString const& context);\r\n\r\n    /*!\r\n     *  Find errors within overlapping memory blocks.\r\n     *\r\n     *    @param [in] errors          List of found errors.\r\n     *    @param [in] memoryMapBase   The selected memory map base.\r\n     *    @param [in] memoryBlock     The selected memory block.\r\n     *    @param [in] blockIndex      The index of the address block.\r\n     *    @param [in] context         Context to help locate the error.\r\n     */\r\n    void findErrorsInOverlappingBlocks(QVector<QString>& errors, QSharedPointer<MemoryMapBase> memoryMapBase,\r\n        QSharedPointer<MemoryBlockBase> memoryBlock, int blockIndex, QString const& context) const;\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! The expression parser to use.\r\n    QSharedPointer<ExpressionParser> expressionParser_;\r\n\r\n    //! The used address block validator.\r\n    QSharedPointer<AddressBlockValidator> addressBlockValidator_;\r\n\r\n    //! Validator for subspace maps.\r\n    QSharedPointer<SubspaceMapValidator> subspaceValidator_;\r\n\r\n    //! Interface for accessomg bus interfaces.\r\n    QSharedPointer<QList<QSharedPointer<BusInterface> > > availableBusInterfaces_;\r\n\r\n    //! List of available address spaces.\r\n    QSharedPointer<QList<QSharedPointer<AddressSpace> > > availableSpaces_;\r\n};\r\n\r\n#endif // MEMORYMAPBASEVALIDATOR_H\r\n"
  },
  {
    "path": "IPXACTmodels/Component/validators/MemoryMapValidator.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: MemoryMapValidator.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 25.11.2015\r\n//\r\n// Description:\r\n// Validator for the ipxact:memoryMap.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"MemoryMapValidator.h\"\r\n\r\n#include <KactusAPI/include/ExpressionParser.h>\r\n\r\n#include <IPXACTmodels/Component/MemoryMap.h>\r\n#include <IPXACTmodels/Component/MemoryRemap.h>\r\n#include <IPXACTmodels/Component/RemapState.h>\r\n#include <IPXACTmodels/Component/Component.h>\r\n#include <IPXACTmodels/Component/Mode.h>\r\n#include <IPXACTmodels/Component/ModeReference.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryMapValidator::MemoryMapValidator()\r\n//-----------------------------------------------------------------------------\r\nMemoryMapValidator::MemoryMapValidator(QSharedPointer<ExpressionParser> expressionParser,\r\n    QSharedPointer<AddressBlockValidator> addressBlockValidator,\r\n    QSharedPointer<SubspaceMapValidator> subspaceValidator, QSharedPointer<Component> component):\r\nMemoryMapBaseValidator(expressionParser, addressBlockValidator, subspaceValidator)\r\n{\r\n    componentChange(component);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryMapValidator::componentChange()\r\n//-----------------------------------------------------------------------------\r\nvoid MemoryMapValidator::componentChange(QSharedPointer<Component> newComponent)\r\n{\r\n    if (availableRemapStates_)\r\n    {\r\n        availableRemapStates_.clear();\r\n    }\r\n\r\n    if (newComponent)\r\n    {\r\n        availableRemapStates_ = newComponent->getRemapStates();\r\n        componentModes_ = newComponent->getModes();\r\n    }\r\n\r\n    MemoryMapBaseValidator::componentChange(newComponent);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryMapValidator::validate()\r\n//-----------------------------------------------------------------------------\r\nbool MemoryMapValidator::validate(QSharedPointer<MemoryMap> memoryMap)\r\n{\r\n    if (docRevision_ == Document::Revision::Std14)\r\n    {\r\n        return MemoryMapBaseValidator::validate(memoryMap, memoryMap->getAddressUnitBits()) &&\r\n            hasValidAddressUnitBits(memoryMap) && hasValidMemoryRemaps(memoryMap);\r\n    }\r\n    else if (docRevision_ == Document::Revision::Std22)\r\n    {\r\n        return MemoryMapBaseValidator::validate(memoryMap, memoryMap->getAddressUnitBits()) &&\r\n            hasValidAddressUnitBits(memoryMap) && hasValidMemoryRemaps(memoryMap) && hasValidStructure(memoryMap);\r\n    }\r\n\r\n    return false;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryMapValidator::hasValidAddressUnitBits()\r\n//-----------------------------------------------------------------------------\r\nbool MemoryMapValidator::hasValidAddressUnitBits(QSharedPointer<MemoryMap> memoryMap) const\r\n{\r\n    QString solvedValue = getExpressionParser()->parseExpression(memoryMap->getAddressUnitBits());\r\n    bool changeOk = true;\r\n    quint64 addressUnitBits = solvedValue.toULongLong(&changeOk);\r\n\r\n    return changeOk && addressUnitBits > 0;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryMapValidator::hasValidMemoryRemaps()\r\n//-----------------------------------------------------------------------------\r\nbool MemoryMapValidator::hasValidMemoryRemaps(QSharedPointer<MemoryMap> memoryMap)\r\n{\r\n    if (!memoryMap->getMemoryRemaps()->isEmpty())\r\n    {\r\n        QStringList remapNames;\r\n        QStringList remapStates;\r\n\r\n        if (docRevision_ == Document::Revision::Std22 && !remapsHaveValidModeRefs(memoryMap))\r\n        {\r\n            return false;\r\n        }\r\n\r\n        for (QSharedPointer<MemoryRemap> memoryRemap : *memoryMap->getMemoryRemaps())\r\n        {\r\n            if (docRevision_ == Document::Revision::Std14)\r\n            {\r\n                if (remapNames.contains(memoryRemap->name()) ||\r\n                    remapStates.contains(memoryRemap->getRemapState()) ||\r\n                    remapStateIsNotValid(memoryRemap) ||\r\n                    !MemoryMapBaseValidator::validate(memoryRemap, memoryMap->getAddressUnitBits()))\r\n                {\r\n                    return false;\r\n                }\r\n            }\r\n            else if (docRevision_ == Document::Revision::Std22)\r\n            {\r\n                if (remapNames.contains(memoryRemap->name()) ||\r\n                    !remapHasValidStructure(memoryRemap) ||\r\n                    !MemoryMapBaseValidator::validate(memoryRemap, memoryMap->getAddressUnitBits()))\r\n                {\r\n                    return false;\r\n                }\r\n            }\r\n\r\n            remapNames.append(memoryRemap->name());\r\n            remapStates.append(memoryRemap->getRemapState());\r\n        }\r\n    }\r\n\r\n    return true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryMapValidator::remapStateIsNotValid()\r\n//-----------------------------------------------------------------------------\r\nbool MemoryMapValidator::remapStateIsNotValid(QSharedPointer<MemoryRemap> memoryRemap) const\r\n{\r\n    if (!memoryRemap->getRemapState().isEmpty())\r\n    {\r\n        for (QSharedPointer<RemapState> state : *availableRemapStates_)\r\n        {\r\n            if (state->name() == memoryRemap->getRemapState())\r\n            {\r\n                return false;\r\n            }\r\n        }\r\n    }\r\n\r\n    return true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryMapValidator::hasValidRemapStateOrModeReferences()\r\n//-----------------------------------------------------------------------------\r\nbool MemoryMapValidator::hasValidRemapStateOrModeReferences(QSharedPointer<MemoryMap> parentMap, QSharedPointer<MemoryRemap> memoryRemap) const\r\n{\r\n    if (docRevision_ == Document::Revision::Std22)\r\n    {\r\n        return remapsHaveValidModeRefs(parentMap);\r\n    }\r\n\r\n    return !remapStateIsNotValid(memoryRemap);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryMapValidator::remapHasValidStructure()\r\n//-----------------------------------------------------------------------------\r\nbool MemoryMapValidator::remapHasValidStructure(QSharedPointer<MemoryRemap> memoryRemap) const\r\n{\r\n    if (!memoryRemap->getMemoryRemapDefinitionReference().isEmpty() && !memoryRemap->getMemoryBlocks()->isEmpty())\r\n    {\r\n        return false;\r\n    }\r\n\r\n    return true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryMapValidator::hasValidStructure()\r\n//-----------------------------------------------------------------------------\r\nbool MemoryMapValidator::hasValidStructure(QSharedPointer<MemoryMap> memoryMap) const\r\n{\r\n    if (!memoryMap->getMemoryMapDefinitionReference().isEmpty() && (\r\n        !memoryMap->getMemoryBlocks()->isEmpty() ||\r\n        !memoryMap->getMemoryRemaps()->isEmpty() ||\r\n        !memoryMap->getAddressUnitBits(false).isEmpty() ||\r\n        !memoryMap->getShared().isEmpty()))\r\n    {\r\n        return false;\r\n    }\r\n\r\n    return true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryMapValidator::findErrorsIn()\r\n//-----------------------------------------------------------------------------\r\nvoid MemoryMapValidator::findErrorsIn(QVector<QString>& errors, QSharedPointer<MemoryMap> memoryMap,\r\n    QString const& context)\r\n{\r\n    QString memoryMapContext = memoryMap->elementName();\r\n    memoryMapContext.append(QLatin1Char(' '));\r\n    memoryMapContext.append(memoryMap->name());\r\n\r\n    MemoryMapBaseValidator::findErrorsIn(errors, memoryMap, memoryMap->getAddressUnitBits(), context);\r\n    findErrorsInAddressUnitBits(errors, memoryMap, context);\r\n    findErrorsInMemoryRemaps(errors, memoryMap, memoryMapContext);\r\n    if (docRevision_ == Document::Revision::Std22)\r\n    {\r\n        findErrorsInStrucutre(errors, memoryMap, memoryMapContext);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryMapValidator::remapsHaveValidModeRefs()\r\n//-----------------------------------------------------------------------------\r\nbool MemoryMapValidator::remapsHaveValidModeRefs(QSharedPointer<MemoryMap> memoryMap) const\r\n{\r\n    if (docRevision_ != Document::Revision::Std22)\r\n    {\r\n        return true;\r\n    }\r\n\r\n    QStringList references; // References must be unique within the containing memoryMap\r\n\r\n    for (auto const& remap : *memoryMap->getMemoryRemaps())\r\n    {        \r\n        auto modeRefs = remap->getModeReferences();\r\n\r\n        for (auto const& ref : *modeRefs)\r\n        {\r\n            if (references.contains(ref->getReference()) ||\r\n                ref->getReference().isEmpty())\r\n            {\r\n                return false;\r\n            }\r\n\r\n            references.append(ref->getReference());\r\n        }\r\n\r\n        // Remap must contain at least one mode reference.\r\n        if (modeRefs->isEmpty())\r\n        {\r\n            return false;\r\n        }\r\n    }\r\n\r\n    return true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryMapValidator::findErrorsInRemapModeRefs()\r\n//-----------------------------------------------------------------------------\r\nvoid MemoryMapValidator::findErrorsInRemapModeRefs(QStringList& errors, QSharedPointer<MemoryMap> memoryMap, \r\n    QString const& context) const\r\n{\r\n    if (docRevision_ != Document::Revision::Std22)\r\n    {\r\n        return;\r\n    }\r\n\r\n    QStringList references; // References must be unique within the containing memoryMap\r\n\r\n    for (auto const& remap : *memoryMap->getMemoryRemaps())\r\n    {\r\n        auto modeRefs = remap->getModeReferences();\r\n\r\n        for (auto const& ref : *modeRefs)\r\n        {\r\n            QString const& referenceValue = ref->getReference();\r\n\r\n            if (referenceValue.isEmpty())\r\n            {\r\n                errors.append(QObject::tr(\"Empty mode reference value set for memory remap %1 in %2\").arg(remap->name()).arg(context));\r\n            }\r\n\r\n            if (references.contains(referenceValue))\r\n            {\r\n                errors.append(QObject::tr(\"Duplicate mode reference value %1 set for memory remap %2 in %3\")\r\n                    .arg(referenceValue).arg(remap->name()).arg(context));\r\n            }\r\n            else\r\n            {\r\n                references.append(referenceValue);\r\n            }\r\n        }\r\n\r\n        if (modeRefs->isEmpty())\r\n        {\r\n            errors.append(QObject::tr(\"Memory remap %1 in %2 must contain at least one mode reference.\")\r\n                .arg(remap->name()).arg(context));\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryMapValidator::findErrorsInStrucutre()\r\n//-----------------------------------------------------------------------------\r\nvoid MemoryMapValidator::findErrorsInStrucutre(QStringList& errors, QSharedPointer<MemoryMap> memoryMap, QString const& context) const\r\n{\r\n    if (!hasValidStructure(memoryMap))\r\n    {\r\n        errors.append(QObject::tr(\"Memory map %1 in %2 cannot contain both a definition reference\"\r\n            \" and memory blocks, remaps or definitions for address unit bits or shared values.\").arg(memoryMap->name()).arg(context));\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryMapValidator::findErrorsInAddressUnitBits()\r\n//-----------------------------------------------------------------------------\r\nvoid MemoryMapValidator::findErrorsInAddressUnitBits(QVector<QString>& errors, QSharedPointer<MemoryMap> memoryMap,\r\n    QString const& context) const\r\n{\r\n    if (!hasValidAddressUnitBits(memoryMap))\r\n    {\r\n        errors.append(QObject::tr(\"Invalid address unit bits specified for %1 %2 within %3\")\r\n            .arg(memoryMap->elementName()).arg(memoryMap->name()).arg(context));\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryMapValidator::findErrorsInMemoryRemaps()\r\n//-----------------------------------------------------------------------------\r\nvoid MemoryMapValidator::findErrorsInMemoryRemaps(QVector<QString>& errors, QSharedPointer<MemoryMap> memoryMap,\r\n    QString const& context)\r\n{\r\n    if (!memoryMap->getMemoryRemaps()->isEmpty())\r\n    {\r\n        QStringList memoryRemapNames;\r\n        QStringList nonUniqueNames;\r\n        QStringList remapStates;\r\n        bool remapStatesAreUnique = true;\r\n        for (QSharedPointer<MemoryRemap> memoryRemap : *memoryMap->getMemoryRemaps())\r\n        {\r\n            MemoryMapBaseValidator::findErrorsIn(errors, memoryRemap, memoryMap->getAddressUnitBits(), context);\r\n\r\n            if (memoryRemapNames.contains(memoryRemap->name()) && !nonUniqueNames.contains(memoryRemap->name()))\r\n            {\r\n                nonUniqueNames.append(memoryRemap->name());\r\n                errors.append(QObject::tr(\"Name %1 of memory remaps in memory map %2 is not unique.\")\r\n                    .arg(memoryRemap->name()).arg(memoryMap->name()));\r\n            }\r\n            else\r\n            {\r\n                memoryRemapNames.append(memoryRemap->name());\r\n            }\r\n\r\n            if (docRevision_ == Document::Revision::Std14)\r\n            {\r\n                if (remapStateIsNotValid(memoryRemap))\r\n                {\r\n                    errors.append(QObject::tr(\"Invalid remap state %1 set for %2 %3 within %4\")\r\n                        .arg(memoryRemap->getRemapState()).arg(memoryRemap->elementName()).arg(memoryRemap->name())\r\n                        .arg(context));\r\n                }\r\n                if (remapStatesAreUnique && remapStates.contains(memoryRemap->getRemapState()))\r\n                {\r\n                    remapStatesAreUnique = false;\r\n                    errors.append(QObject::tr(\"Remap states are not unique for each memory remap within memory map %1\")\r\n                        .arg(memoryMap->name()));\r\n                }\r\n                else if (remapStatesAreUnique)\r\n                {\r\n                    remapStates.append(memoryRemap->getRemapState());\r\n                }\r\n            }\r\n            else if (docRevision_ == Document::Revision::Std22)\r\n            {\r\n                findErrorsInRemapStructure(errors, memoryRemap, context);\r\n            }\r\n        }\r\n\r\n        findErrorsInRemapModeRefs(errors, memoryMap, context);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryMapValidator::findErrorsInRemapStructure()\r\n//-----------------------------------------------------------------------------\r\nvoid MemoryMapValidator::findErrorsInRemapStructure(QStringList& errors, QSharedPointer<MemoryRemap> memoryRemap, QString const& context) const\r\n{\r\n    if (!remapHasValidStructure(memoryRemap))\r\n    {\r\n        errors.append(QObject::tr(\"Memory remap %1 in %2 cannot contain both a definition reference\" \r\n            \" and address blocks / subspace maps.\").arg(memoryRemap->name()).arg(context));\r\n    }\r\n}\r\n"
  },
  {
    "path": "IPXACTmodels/Component/validators/MemoryMapValidator.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: MemoryMapValidator.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 25.11.2015\r\n//\r\n// Description:\r\n// Validator for the ipxact:memoryMap.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef MEMORYMAPVALIDATOR_H\r\n#define MEMORYMAPVALIDATOR_H\r\n\r\n#include <IPXACTmodels/ipxactmodels_global.h>\r\n\r\n#include <IPXACTmodels/Component/validators/MemoryMapBaseValidator.h>\r\n\r\n#include <QSharedPointer>\r\n#include <QString>\r\n\r\nclass ExpressionParser;\r\nclass MemoryMap;\r\nclass MemoryRemap;\r\nclass RemapState;\r\nclass AddressBlockValidator;\r\nclass SubspaceMapValidator;\r\nclass Mode;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Validator for the ipxact:memoryMap.\r\n//-----------------------------------------------------------------------------\r\nclass IPXACTMODELS_EXPORT MemoryMapValidator: public MemoryMapBaseValidator\r\n{\r\npublic:\r\n\r\n\t/*!\r\n\t *  The constructor.\r\n\t *\r\n\t *    @param [in] expressionParser        The parser to use for solving expressions.\r\n     *    @param [in] addressBlockValidator   Validator used for address blocks.\r\n     *    @param [in] subspaceValidator       Validator used for subspace maps.\r\n     *    @param [in] component               The containing component.\r\n\t */\r\n    MemoryMapValidator(QSharedPointer<ExpressionParser> expressionParser,\r\n        QSharedPointer<AddressBlockValidator> addressBlockValidator,\r\n        QSharedPointer<SubspaceMapValidator> subspaceValidator,\r\n        QSharedPointer<Component> component);\r\n\r\n\t//! The destructor.\r\n\tvirtual ~MemoryMapValidator() override final = default;\r\n\r\n    // Disable copying.\r\n    MemoryMapValidator(MemoryMapValidator const& rhs) = delete;\r\n    MemoryMapValidator& operator=(MemoryMapValidator const& rhs) = delete;\r\n    \r\n    /*!\r\n     *  Change the containing component.\r\n     *\r\n     *    @param [in] newComponent    The selected component.\r\n     */\r\n    void componentChange(QSharedPointer<Component> newComponent);\r\n\r\n    /*!\r\n     *  Validates the given memory map.\r\n     *\r\n     *    @param [in] memoryMap   The memory map to validate.\r\n     *\r\n     *    @return True, if the memory map is valid IP-XACT, otherwise false.\r\n     */\r\n    virtual bool validate(QSharedPointer<MemoryMap> memoryMap);\r\n\r\n    /*!\r\n     *  Check if the memory map contains valid address unit bits.\r\n     *\r\n     *    @param [in] memoryMap   The selected memory map.\r\n     *\r\n     *    @return True, if the address unit bits is valid, otherwise false.\r\n     */\r\n    bool hasValidAddressUnitBits(QSharedPointer<MemoryMap> memoryMap) const;\r\n\r\n    /*!\r\n     *  Check if the memory map contains valid memory remaps.\r\n     *\r\n     *    @param [in] memoryMap   The selected memory map.\r\n     *\r\n     *    @return True, if the memory remaps are valid, otherwise false.\r\n     */\r\n    bool hasValidMemoryRemaps(QSharedPointer<MemoryMap> memoryMap);\r\n\r\n    /*!\r\n     *  Check if the memory remap remap state is valid.\r\n     *\r\n     *    @param [in] memoryRemap     The selected memory remap.\r\n     *\r\n     *    @return True, if the remap state is valid, otherwise false.\r\n     */\r\n    bool remapStateIsNotValid(QSharedPointer<MemoryRemap> memoryRemap) const;\r\n\r\n    bool hasValidRemapStateOrModeReferences(QSharedPointer<MemoryMap> parentMap, QSharedPointer<MemoryRemap> memoryRemap) const;\r\n\r\n    /*!\r\n     *\tCheck if the memory remap has a valid structure. It cannot simultanously have a \r\n     *  definition reference and defined memory blocks (std 2022).\r\n     *  \r\n     *    @param [in] memoryRemap     The selected memory remap.\r\n     *\t    \r\n     * \t    @return True, if the structure is valid, otherwise false.\r\n     */\r\n    bool remapHasValidStructure(QSharedPointer<MemoryRemap> memoryRemap) const;\r\n\r\n    /*!\r\n     *\tCheck if the memory map has a valid structure. It cannot simultanously have a\r\n     *  definition reference and elements defined in the memoryMapGroup (std 2022).\r\n     *\r\n     *    @param [in] memoryMap       The selected memory map.\r\n     *\r\n     * \t    @return True, if the structure is valid, otherwise false.\r\n     */\r\n    bool hasValidStructure(QSharedPointer<MemoryMap> memoryMap) const;\r\n\r\n    /*!\r\n     *  Locate errors within a memory map.\r\n     *\r\n     *    @param [in] errors      List of found errors.\r\n     *    @param [in] memoryMap   The selected memory map.\r\n     *    @param [in] context     Context to help locate the error.\r\n     */\r\n    virtual void findErrorsIn(QVector<QString>& errors, QSharedPointer<MemoryMap> memoryMap,\r\n        QString const& context);\r\n\r\nprivate:\r\n    \r\n    /*!\r\n     *\tCheck if memory remaps contain valid mode references.\r\n     *  \r\n     *    @param [in] memoryMap     The memory map whose remaps are checked.\r\n     *\t    \r\n     * \t    @return True, if the mode references of remaps are valid, otherwise false.\r\n     */\r\n    bool remapsHaveValidModeRefs(QSharedPointer<MemoryMap> memoryMap) const;\r\n\r\n    /*!\r\n     *\tFind errors within the mode references of memory remaps.\r\n     *  \r\n     *    @param [in] errors      List of found errors.\r\n     *    @param [in] memoryMap   The selected memory map.\r\n     *    @param [in] context     Context to help locate the error.\r\n     */\r\n    void findErrorsInRemapModeRefs(QStringList& errors, QSharedPointer<MemoryMap> memoryMap, \r\n        QString const& context) const;\r\n\r\n    /*!\r\n     *\tFind errors in the structure of the memory map.\r\n     *  \r\n     *    @param [in] errors      List of found errors.\r\n     *    @param [in] memoryMap   The selected memory map.\r\n     *    @param [in] context     Context to help locate the error.\r\n     */\r\n    void findErrorsInStrucutre(QStringList& errors, QSharedPointer<MemoryMap> memoryMap,\r\n        QString const& context) const;\r\n\r\n    /*!\r\n     *  Locate errors within memory map address unit bits.\r\n     *\r\n     *    @param [in] errors      List of found errors.\r\n     *    @param [in] memoryMap   The selected memory map.\r\n     *    @param [in] context     Context to help locate the error.\r\n     */\r\n    void findErrorsInAddressUnitBits(QVector<QString>& errors, QSharedPointer<MemoryMap> memoryMap,\r\n        QString const& context) const;\r\n\r\n    /*!\r\n     *  Locate errors within memory map memory remaps.\r\n     *\r\n     *    @param [in] errors      List of found errors.\r\n     *    @param [in] memoryMap   The selected memory map.\r\n     *    @param [in] context     Context to help locate the error.\r\n     */\r\n    void findErrorsInMemoryRemaps(QVector<QString>& errors, QSharedPointer<MemoryMap> memoryMap,\r\n        QString const& context);\r\n\r\n    /*!\r\n     *\tFind errors in the structure of a memory remap.\r\n     *  \r\n     *    @param [in] errors      List of found errors.\r\n     *    @param [in] memoryMap   The selected memory remap.\r\n     *    @param [in] context     Context to help locate the error.\r\n     */\r\n    void findErrorsInRemapStructure(QStringList& errors, QSharedPointer<MemoryRemap> memoryRemap,\r\n        QString const& context) const;\r\n\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! The available remap states.\r\n    QSharedPointer<QList<QSharedPointer<RemapState> > > availableRemapStates_;\r\n\r\n    //! The available component modes.\r\n    QSharedPointer<QList<QSharedPointer<Mode> > > componentModes_;\r\n};\r\n\r\n#endif // MEMORYMAPVALIDATOR_H\r\n"
  },
  {
    "path": "IPXACTmodels/Component/validators/MemoryReserve.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: MemoryReserve.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 26.11.2015\r\n//\r\n// Description:\r\n// Class for determining overlapping within an area.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"MemoryReserve.h\"\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryReserve::MemoryReserve()\r\n//-----------------------------------------------------------------------------\r\nMemoryReserve::MemoryReserve()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryReserve::MemoryArea::operator<()\r\n//-----------------------------------------------------------------------------\r\nbool MemoryReserve::MemoryArea::operator<(const MemoryReserve::MemoryArea& other) const\r\n{\r\n    return begin_ < other.begin_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryReserve::addArea()\r\n//-----------------------------------------------------------------------------\r\nvoid MemoryReserve::addArea(QString const& newId, qint64 newBegin, qint64 newEnd)\r\n{\r\n    MemoryArea newArea;\r\n    newArea.id_ = newId;\r\n    newArea.begin_ = newBegin;\r\n    newArea.end_ = newEnd;\r\n\r\n    reservedArea_.append(newArea);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryReserve::hasOverlap()\r\n//-----------------------------------------------------------------------------\r\nbool MemoryReserve::hasOverlap()\r\n{\r\n    if (reservedArea_.count() < 2)\r\n    {\r\n        return false;\r\n    }\r\n\r\n    std::sort(reservedArea_.begin(), reservedArea_.end());\r\n\r\n    for (int areaIndex = 0; areaIndex < reservedArea_.size() - 1; ++areaIndex)\r\n    {\r\n        if (reservedArea_.at(areaIndex + 1).begin_ <= reservedArea_.at(areaIndex).end_)\r\n        {\r\n            return true;\r\n        }\r\n    }\r\n\r\n    return false;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryReserve::hasIdDependantOverlap()\r\n//-----------------------------------------------------------------------------\r\nbool MemoryReserve::hasIdDependantOverlap()\r\n{\r\n    if (reservedArea_.count() < 2)\r\n    {\r\n        return false;\r\n    }\r\n\r\n    std::sort(reservedArea_.begin(), reservedArea_.end());\r\n\r\n    for (int areaIndex = 0; areaIndex < reservedArea_.size() - 1; ++areaIndex)\r\n    {\r\n        MemoryArea const& area = reservedArea_.at(areaIndex);\r\n\r\n        for (int nextIndex = areaIndex + 1; nextIndex < reservedArea_.size(); ++nextIndex)\r\n        {\r\n            MemoryArea const& nextArea = reservedArea_.at(nextIndex);\r\n\r\n            if (area.id_ == nextArea.id_)\r\n            {\r\n                if (nextArea.begin_ > area.end_)\r\n                {\r\n                    break;\r\n                }\r\n                else\r\n                {\r\n                    return true;\r\n                }\r\n            }\r\n        }\r\n    }\r\n\r\n    return false;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryReserve::findErrorsInOverlap()\r\n//-----------------------------------------------------------------------------\r\nvoid MemoryReserve::findErrorsInOverlap(QVector<QString>& errors, QString const& itemIdentifier,\r\n    QString const& context)\r\n{\r\n    if (reservedArea_.isEmpty())\r\n    {\r\n        return;\r\n\t}\r\n\r\n\tstd::sort(reservedArea_.begin(), reservedArea_.end());\r\n\r\n\tfor (int i = 0; i < reservedArea_.size(); ++i)\r\n\t{\r\n\t\tMemoryArea area = reservedArea_.at(i);\r\n\r\n\t\tfor (int j = i + 1; j < reservedArea_.size(); ++j)\r\n\t\t{\r\n\t\t\tMemoryArea nextArea = reservedArea_.at(j);\r\n\r\n\t\t\tif (nextArea.begin_ > area.end_)\r\n\t\t\t{\r\n\t\t\t\tbreak;\r\n\t\t\t}\r\n\t\t\telse\r\n\t\t\t{\r\n\t\t\t\terrors.append(QObject::tr(\"%1 %2 and %3 overlap within %4\")\r\n\t\t\t\t\t.arg(itemIdentifier).arg(area.id_).arg(nextArea.id_).arg(context));\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryReserve::findErrorsInIdDependantOverlap()\r\n//-----------------------------------------------------------------------------\r\nvoid MemoryReserve::findErrorsInIdDependantOverlap(QVector<QString>& errors, QString const& itemIdentifier,\r\n    QString const& context)\r\n{\r\n    if (reservedArea_.isEmpty())\r\n\t{\r\n\t\treturn;\r\n\t}\r\n\r\n\tstd::sort(reservedArea_.begin(), reservedArea_.end());\r\n\r\n\tfor (int i = 0; i < reservedArea_.size(); ++i)\r\n\t{\r\n\t\tMemoryArea const& area = reservedArea_.at(i);\r\n\r\n\t\tfor (int j = i + 1; j < reservedArea_.size(); ++j)\r\n\t\t{\r\n\t\t\tMemoryArea const& nextArea = reservedArea_.at(j);\r\n\r\n\t\t\tif (area.id_ == nextArea.id_ && nextArea.begin_ <= area.end_)\r\n\t\t\t{\r\n\t\t\t\terrors.append(QObject::tr(\"Multiple definitions of %1 %2 overlap within %3\")\r\n\t\t\t\t\t.arg(itemIdentifier).arg(area.id_).arg(context));\r\n\t\t\t\tbreak;\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n}\r\n"
  },
  {
    "path": "IPXACTmodels/Component/validators/MemoryReserve.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: MemoryReserve.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 26.11.2015\r\n//\r\n// Description:\r\n// Class for determining overlapping within an area.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef MEMORYRESERVE_H\r\n#define MEMORYRESERVE_H\r\n\r\n#include <IPXACTmodels/ipxactmodels_global.h>\r\n\r\n#include <QSharedPointer>\r\n#include <QString>\r\n#include <QVector>\r\n#include <QObject>\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Class for determining overlapping within an area.\r\n//-----------------------------------------------------------------------------\r\nclass IPXACTMODELS_EXPORT MemoryReserve\r\n{\r\npublic:\r\n\r\n\t/*!\r\n\t *  The constructor.\r\n\t */\r\n    MemoryReserve();\r\n\r\n    //! The destructor.\r\n    ~MemoryReserve() = default;\r\n\r\n    // Disable copying.\r\n    MemoryReserve(MemoryReserve const& rhs) = delete;\r\n    MemoryReserve& operator=(MemoryReserve const& rhs) = delete;\r\n\r\n    /*!\r\n     *  Reserve an area.\r\n     *\r\n     *    @param [in] newId       Id of the reserved area.\r\n     *    @param [in] newBegin    Start point of the area.\r\n     *    @param [in] newEnd      End point of the area.\r\n     */\r\n    void addArea(QString const& newId, qint64 newBegin, qint64 newEnd);\r\n\r\n    /*!\r\n     *  Check if reserved areas overlap.\r\n     *\r\n     *    @return True, if overlap exists, otherwise false.\r\n     */\r\n    bool hasOverlap();\r\n\r\n    /*!\r\n     *  Check if the reserved ares with the same identifier overlap.\r\n     *\r\n     *    @return True, if overlap exists, otherwise false.\r\n     */\r\n    bool hasIdDependantOverlap();\r\n\r\n    /*!\r\n     *  Find errors related to overlapping.\r\n     *\r\n     *    @param [in] errors          The error list.\r\n     *    @param [in] itemIdentifier  Identifier for the overlapping items.\r\n     *    @param [in] context         Context used to help find the error.\r\n     */\r\n    void findErrorsInOverlap(QVector<QString>& errors, QString const& itemIdentifier, QString const& context);\r\n\r\n    /*!\r\n     *  Find errors related to overlapping with same identifiers.\r\n     *\r\n     *    @param [in] errors          The error list.\r\n     *    @param [in] itemIdentifier  Identifier for the overlapping items.\r\n     *    @param [in] context         Context used to help find the errors.\r\n     */\r\n    void findErrorsInIdDependantOverlap(QVector<QString>& errors, QString const& itemIdentifier,\r\n        QString const& context);\r\n\r\nprivate:\r\n\r\n\t\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    // A memory area.\r\n    struct MemoryArea\r\n    {\r\n        //! Identifier for the area.\r\n        QString id_;\r\n\r\n        //! Start point of the area.\r\n        qint64 begin_ = 0;\r\n\r\n        //! End point of the area.\r\n        qint64 end_ = 0;\r\n\r\n        /*!\r\n         *  Assignment operator for MemoryArea.\r\n         *\r\n         *    @param [in] other   Memory area to be assigned.\r\n         *\r\n         *    @return The newly assigned memory area.\r\n         */\r\n        MemoryArea& operator=(const MemoryArea& other) = default;\r\n        \r\n        /*!\r\n         *  Check if a memory area has lower start point than another memory area.\r\n         *\r\n         *    @param [in] other   Memory area being compared to.\r\n         */\r\n        bool operator<(const MemoryArea& other) const;\r\n    };\r\n\r\n    //! The currently reserved memory areas.\r\n    QVector<MemoryArea> reservedArea_;\r\n};\r\n\r\n#endif // MEMORYRESERVE_H\r\n"
  },
  {
    "path": "IPXACTmodels/Component/validators/ModeValidator.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: ModeValidator.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Esko Pekkarinen\n// Date: 14.08.2023\n//\n// Description:\n// Validator for ipxact:mode.\n//-----------------------------------------------------------------------------\n\n#include \"ModeValidator.h\"\n\n#include <KactusAPI/include/ExpressionParser.h>\n\n#include <IPXACTmodels/Component/Mode.h>\n\n#include <IPXACTmodels/common/validators/CommonItemsValidator.h>\n\n#include <QStringList>\n\n//-----------------------------------------------------------------------------\n// Function: ModeValidator::ModeValidator()\n//-----------------------------------------------------------------------------\nModeValidator::ModeValidator(\n\tQSharedPointer<Component> component, \n\tQSharedPointer<ExpressionParser> expressionParser):\nHierarchicalValidator(),\nportValidator_(new PortSliceValidator(component, expressionParser)),\nfieldValidator_(new FieldSliceValidator(component, expressionParser)),\ncomponent_(component),\nexpressionParser_(expressionParser)\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: ModeValidator::~ModeValidator()\n//-----------------------------------------------------------------------------\nModeValidator::~ModeValidator()\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: ModeValidator::validate()\n//-----------------------------------------------------------------------------\nbool ModeValidator::validate(QSharedPointer<Mode> mode) const\n{\n\tif (hasValidName(mode->name()) == false)\n\t{\n\t\treturn false;\n\t}\n\t\n    if (hasValidCondition(mode) == false)\n    {\n        return false;\n    }\n\n\tif (hasValidPortSlices(mode) == false)\n\t{\n\t\treturn false;\n\t}\n\n\tif (hasValidFieldSlices(mode) == false)\n\t{\n\t\treturn false;\n\t}\n\n\tif (validComparedToSiblings(mode) == false)\n\t{\n\t\treturn false;\n\t}\n\n\treturn true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: ModeValidator::hasValidName()\n//-----------------------------------------------------------------------------\nbool ModeValidator::hasValidName(QString const& name) const\n{\n\treturn CommonItemsValidator::hasValidName(name);\n}\n\n//-----------------------------------------------------------------------------\n// Function: ModeValidator::hasValidCondition()\n//-----------------------------------------------------------------------------\nbool ModeValidator::hasValidCondition(QSharedPointer<Mode> mode) const\n{\n    bool valid = false;\n    expressionParser_->parseExpression(mode->getCondition(), &valid);\n\n    return valid;\n}\n\n//-----------------------------------------------------------------------------\n// Function: ModeValidator::hasValidPortSlices()\n//-----------------------------------------------------------------------------\nbool ModeValidator::hasValidPortSlices(QSharedPointer<Mode> mode) const\n{\n\tQStringList sliceNames;\n\n\tfor (auto const& portSlice : *mode->getPortSlices())\n    {\n        if (sliceNames.contains(portSlice->name()))\n        {\n            return false;\n        }\n\n\t\tif (portValidator_->validate(portSlice) == false)\n\t\t{\n\t\t\treturn false;\n\t\t}\n\n\t\tsliceNames.append(portSlice->name());\n\t}\n\n\treturn true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: ModeValidator::hasValidFieldSlices()\n//-----------------------------------------------------------------------------\nbool ModeValidator::hasValidFieldSlices(QSharedPointer<Mode> mode) const\n{\n    QStringList sliceNames;\n\n    for (auto const& fieldSlice : *mode->getFieldSlices())\n    {\n        if (sliceNames.contains(fieldSlice->name()))\n        {\n            return false;\n        }\n\n        if (fieldValidator_->validate(fieldSlice) == false)\n        {\n            return false;\n        }\n\n        sliceNames.append(fieldSlice->name());\n    }\n\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: ModeValidator::findErrorsIn()\n//-----------------------------------------------------------------------------\nvoid ModeValidator::findErrorsIn(QVector<QString>& errors, QSharedPointer<Mode> mode,\n    QString const& context) const\n{\n    if (!hasValidName(mode->name()))\n    {\n        errors.append(QObject::tr(\"Invalid name '%1' set for mode within %2.\").arg(mode->name(), context));\n    }\n\n\tQString modeContext(QStringLiteral(\"mode '%1'\").arg(mode->name()));\n\tQStringList portNames;\n\tQStringList reportedPorts;\n\n    if (hasValidCondition(mode) == false)\n    {\n        errors.append(QObject::tr(\"Condition is not a valid expression within %1.\").arg(\n             modeContext));\n    }\n\n    for (auto const& portSlice : *mode->getPortSlices())\n    {\n\t\tif (portNames.contains(portSlice->name()) && reportedPorts.contains(portSlice->name()) == false)\n        {\n            errors.append(QObject::tr(\"Port condition name '%1' is not unique within %2.\").arg(\n                portSlice->name(), modeContext));\n\n            reportedPorts.append(portSlice->name());\n\t\t}\n        portNames.append(portSlice->name());\n\n\t\tportValidator_->findErrorsIn(errors, portSlice, modeContext);\n    }\n\n    QStringList fieldNames;\n    QStringList reportedFields;\n\n    for (auto const& fieldSlice : *mode->getFieldSlices())\n    {\n        if (fieldNames.contains(fieldSlice->name()) && reportedFields.contains(fieldSlice->name()) == false)\n        {\n            errors.append(QObject::tr(\"Field condition name '%1' is not unique within %2.\").arg(\n                fieldSlice->name(), modeContext));\n\n            reportedFields.append(fieldSlice->name());\n        }\n        fieldNames.append(fieldSlice->name());\n\n        fieldValidator_->findErrorsIn(errors, fieldSlice, modeContext);\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: ModeValidator::componentChange()\n//-----------------------------------------------------------------------------\nvoid ModeValidator::componentChange(QSharedPointer<Component> newComponent)\n{\n\tcomponent_ = newComponent;\n\tportValidator_->componentChange(newComponent);\n    fieldValidator_->componentChange(newComponent);\n}\n\n//-----------------------------------------------------------------------------\n// Function: ModeValidator::getPortSliceValidator()\n//-----------------------------------------------------------------------------\nQSharedPointer<PortSliceValidator> ModeValidator::getPortSliceValidator() const\n{\n\treturn portValidator_;\n}\n\n//-----------------------------------------------------------------------------\n// Function: ModeValidator::getFieldSliceValidator()\n//-----------------------------------------------------------------------------\nQSharedPointer<FieldSliceValidator> ModeValidator::getFieldSliceValidator() const\n{\n    return fieldValidator_;\n}\n\n//-----------------------------------------------------------------------------\n// Function: ModeValidator::setConditionParser()\n//-----------------------------------------------------------------------------\nvoid ModeValidator::setConditionParser(QSharedPointer<ExpressionParser> expressionParser)\n{\n    expressionParser_ = expressionParser;\n    portValidator_->setExpressionParser(expressionParser);\n    fieldValidator_->setExpressionParser(expressionParser);\n}\n\n//-----------------------------------------------------------------------------\n// Function: ModeValidator::getConditionParser()\n//-----------------------------------------------------------------------------\nQSharedPointer<ExpressionParser> ModeValidator::getConditionParser() const\n{\n    return expressionParser_;\n}\n"
  },
  {
    "path": "IPXACTmodels/Component/validators/ModeValidator.h",
    "content": "//-----------------------------------------------------------------------------\n// File: ModeValidator.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Esko Pekkarinen\n// Date: 14.08.2023\n//\n// Description:\n// Validator for ipxact:mode.\n//-----------------------------------------------------------------------------\n\n#ifndef MODEVALIDATOR_H\n#define MODEVALIDATOR_H\n\n#include <IPXACTmodels/ipxactmodels_global.h>\n\n#include <IPXACTmodels/Component/Mode.h>\n#include <IPXACTmodels/Component/Component.h>\n\n#include <IPXACTmodels/Component/validators/PortSliceValidator.h>\n#include <IPXACTmodels/Component/validators/FieldSliceValidator.h>\n#include <IPXACTmodels/Component/validators/CollectionValidators.h>\n\n#include <QSharedPointer>\n#include <QString>\n#include <QVector>\n\nclass ExpressionParser;\nclass BuildCommand;\n\n//-----------------------------------------------------------------------------\n//! Validator for ipxact:File.\n//-----------------------------------------------------------------------------\nclass IPXACTMODELS_EXPORT ModeValidator : public HierarchicalValidator\n{\npublic:\n\n\t/*!\n     *  The constructor.\n     * \n     *    @param [in] sliceValidator The validator for port slices.\n     *    @param [in] component      The component containing the modes.\n     *    @param [in] mode           The expression parser for solving expressions in modes.\n\t *\n\t */\n    ModeValidator(\n        QSharedPointer<Component> component,\n        QSharedPointer<ExpressionParser> expressionParser);\n\n\t//! The destructor.\n\tvirtual ~ModeValidator();\n    \n\t// Disable copying.\n\tModeValidator(ModeValidator const& rhs) = delete;\n\tModeValidator& operator=(ModeValidator const& rhs) = delete;\n\n    /*!\n     *  Validates the given mode.\n     *\n     *    @param [in] mode           The mode to validate.\n     *\n     *    @return True, if the mode is valid IP-XACT, otherwise false.\n     */\n    bool validate(QSharedPointer<Mode> mode) const;\n\n    /*!\n     *  Check if the mode name is valid.\n     *\n     *    @param [in] name    The name to be evaluated.\n     *\n     *    @return True, if the name is valid, otherwise false.\n     */\n    bool hasValidName(QString const& name) const;\n\n    bool hasValidCondition(QSharedPointer<Mode> mode) const;\n\n    /*!\n     *  Check if the port slices are valid.\n     *\n     *    @param [in] mode    The mode whose port slices to check.\n     *\n     *    @return True, if the slices are valid, otherwise false.\n     */\n    bool hasValidPortSlices(QSharedPointer<Mode> mode) const;\n\n    bool hasValidFieldSlices(QSharedPointer<Mode> mode) const;\n\n    /*!\n     *  Finds possible errors in a mode and creates a list of them.\n     *\n     *    @param [in] errors      List of found errors.\n     *    @param [in] mode        The mode whose errors to find.\n     *    @param [in] context     Context to help locate the errors.\n     */\n    void findErrorsIn(QVector<QString>& errors, QSharedPointer<Mode> mode,\n\t\tQString const& context) const;\n\n    // Change the active component.\n    void componentChange(QSharedPointer<Component> newComponent);\n\n    //! Get the port slice validator.\n    QSharedPointer<PortSliceValidator> getPortSliceValidator() const;\n\n    //! Get the field slice validator.\n    QSharedPointer<FieldSliceValidator> getFieldSliceValidator() const;\n\n    /*!\n     *\tSet the mode condition expression parser.\n     *  \n     *    @param [in] expressionParser     The parser to set.\n     */\n    void setConditionParser(QSharedPointer<ExpressionParser> expressionParser);\n\n    QSharedPointer<ExpressionParser> getConditionParser() const;\n\nprivate:\n    \n    //! The port slice validator to use.\n    QSharedPointer<PortSliceValidator> portValidator_;\n\n    QSharedPointer<FieldSliceValidator> fieldValidator_;\n\n    //! The component containing the modes.\n    QSharedPointer<Component> component_ = nullptr;\n\n    //! The expression parser to use.\n    QSharedPointer<ExpressionParser> expressionParser_;\n};\n\n#endif // MODEVALIDATOR_H\n"
  },
  {
    "path": "IPXACTmodels/Component/validators/OtherClockDriverValidator.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: OtherClockDriverValidator.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 14.12.2015\r\n//\r\n// Description:\r\n// Validator for the ipxact:otherClockDriver.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"OtherClockDriverValidator.h\"\r\n\r\n#include <KactusAPI/include/ExpressionParser.h>\r\n\r\n#include <IPXACTmodels/Component/OtherClockDriver.h>\r\n#include <IPXACTmodels/common/ClockUnit.h>\r\n\r\n#include <QRegularExpression>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: OtherClockDriverValidator::OtherClockDriverValidator()\r\n//-----------------------------------------------------------------------------\r\nOtherClockDriverValidator::OtherClockDriverValidator(QSharedPointer<ExpressionParser> expressionParser):\r\nexpressionParser_(expressionParser)\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: OtherClockDriverValidator::validate()\r\n//-----------------------------------------------------------------------------\r\nbool OtherClockDriverValidator::validate(QSharedPointer<OtherClockDriver> otherClockDriver) const\r\n{\r\n    return hasValidName(otherClockDriver->getClockName()) &&\r\n        hasValidClockValue(otherClockDriver->getClockPeriod()) &&\r\n        hasValidClockValue(otherClockDriver->getClockPulseOffset()) &&\r\n        hasValidClockValue(otherClockDriver->getClockPulseDuration()) &&\r\n        hasValidClockPulseValue(otherClockDriver);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: OtherClockDriverValidator::hasValidName()\r\n//-----------------------------------------------------------------------------\r\nbool OtherClockDriverValidator::hasValidName(QString const& name) const\r\n{\r\n    QRegularExpression whiteSpaceExpression;\r\n    whiteSpaceExpression.setPattern(QStringLiteral(\"^\\\\s*$\"));\r\n    QRegularExpressionMatch whiteSpaceMatch = whiteSpaceExpression.match(name);\r\n\r\n    if (name.isEmpty() || whiteSpaceMatch.hasMatch())\r\n    {\r\n        return false;\r\n    }\r\n\r\n    return true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: OtherClockDriverValidator::hasValidClockValue()\r\n//-----------------------------------------------------------------------------\r\nbool OtherClockDriverValidator::hasValidClockValue(QSharedPointer<ClockUnit> clockUnit) const\r\n{\r\n    if (clockUnit)\r\n    {\r\n        if (!clockUnit->getValue().isEmpty())\r\n        {\r\n            bool valueToRealOk = true;\r\n            expressionParser_->parseExpression(clockUnit->getValue()).toDouble(&valueToRealOk);\r\n\r\n            return valueToRealOk;\r\n        }\r\n    }\r\n\r\n    return false;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: OtherClockDriverValidator::hasValidClockPulseValue()\r\n//-----------------------------------------------------------------------------\r\nbool OtherClockDriverValidator::hasValidClockPulseValue(QSharedPointer<OtherClockDriver> otherClockDriver) const\r\n{\r\n    if (!otherClockDriver->getClockPulseValue().isEmpty())\r\n    {\r\n        bool bitVectorOk = true;\r\n\r\n        QString clockPulse = otherClockDriver->getClockPulseValue();\r\n        int pulseValueBit = expressionParser_->parseExpression(clockPulse).toInt(&bitVectorOk);\r\n\r\n        return bitVectorOk && pulseValueBit >= 0;\r\n    }\r\n\r\n    return false;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: OtherClockDriverValidator::findErrorsIn()\r\n//-----------------------------------------------------------------------------\r\nvoid OtherClockDriverValidator::findErrorsIn(QVector<QString>& errors,\r\n    QSharedPointer<OtherClockDriver> otherClockDriver, QString const& context) const\r\n{\r\n    findErrorsInName(errors, otherClockDriver, context);\r\n    findErrorsInClockUnits(errors, otherClockDriver, context);\r\n    findErrorsInClockPulseValue(errors, otherClockDriver, context);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: OtherClockDriverValidator::findErrorsInName()\r\n//-----------------------------------------------------------------------------\r\nvoid OtherClockDriverValidator::findErrorsInName(QVector<QString>& errors,\r\n    QSharedPointer<OtherClockDriver> otherClockDriver, QString const& context) const\r\n{\r\n    if (!hasValidName(otherClockDriver->getClockName()))\r\n    {\r\n        errors.append(QObject::tr(\"Invalid name '%1' set for other clock driver within %2\")\r\n            .arg(otherClockDriver->getClockName()).arg(context));\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: OtherClockDriverValidator::findErrorsInClockUnit()\r\n//-----------------------------------------------------------------------------\r\nvoid OtherClockDriverValidator::findErrorsInClockUnits(QVector<QString>& errors,\r\n    QSharedPointer<OtherClockDriver> otherClockDriver, QString const& context) const\r\n{\r\n    if (!hasValidClockValue(otherClockDriver->getClockPeriod()))\r\n    {\r\n        errors.append(QObject::tr(\"Invalid clock period %1 set for other clock driver %2 within %3\")\r\n            .arg(otherClockDriver->getClockPeriod()->getValue()).arg(otherClockDriver->getClockName())\r\n            .arg(context));\r\n    }\r\n    \r\n    if (!hasValidClockValue(otherClockDriver->getClockPulseOffset()))\r\n    {\r\n        errors.append(QObject::tr(\"Invalid clock pulse offset %1 set for other clock driver %2 within %3\")\r\n            .arg(otherClockDriver->getClockPulseOffset()->getValue()).arg(otherClockDriver->getClockName())\r\n            .arg(context));\r\n    }\r\n\r\n    if (!hasValidClockValue(otherClockDriver->getClockPulseDuration()))\r\n    {\r\n        errors.append(QObject::tr(\"Invalid clock pulse duration %1 set for other clock driver %2 within %3\")\r\n            .arg(otherClockDriver->getClockPulseDuration()->getValue()).arg(otherClockDriver->getClockName())\r\n            .arg(context));\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: OtherClockDriverValidator::findErrorsInClockPulseValue()\r\n//-----------------------------------------------------------------------------\r\nvoid OtherClockDriverValidator::findErrorsInClockPulseValue(QVector<QString>& errors,\r\n    QSharedPointer<OtherClockDriver> otherClockDriver, QString const& context) const\r\n{\r\n    if (!hasValidClockPulseValue(otherClockDriver))\r\n    {\r\n        errors.append(QObject::tr(\"Invalid clock pulse value %1 set for other clock driver %2 within %3\")\r\n            .arg(otherClockDriver->getClockPulseValue()).arg(otherClockDriver->getClockName()).arg(context));\r\n    }\r\n}"
  },
  {
    "path": "IPXACTmodels/Component/validators/OtherClockDriverValidator.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: OtherClockDriverValidator.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 14.12.2015\r\n//\r\n// Description:\r\n// Validator for the ipxact:otherClockDriver.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef OTHERCLOCKDRIVERVALIDATOR_H\r\n#define OTHERCLOCKDRIVERVALIDATOR_H\r\n\r\n#include <IPXACTmodels/ipxactmodels_global.h>\r\n\r\n#include <QSharedPointer>\r\n#include <QString>\r\n#include <QVector>\r\n\r\nclass ExpressionParser;\r\nclass OtherClockDriver;\r\nclass ClockUnit;\r\n//-----------------------------------------------------------------------------\r\n//! Validator for the ipxact:otherClockDriver.\r\n//-----------------------------------------------------------------------------\r\nclass IPXACTMODELS_EXPORT OtherClockDriverValidator\r\n{\r\npublic:\r\n\r\n\t/*!\r\n\t *  The constructor.\r\n\t *\r\n\t *    @param [in] expressionParser        The parser to use for solving expressions.\r\n\t */\r\n    OtherClockDriverValidator(QSharedPointer<ExpressionParser> expressionParser);\r\n\r\n\t//! The destructor.\r\n\t~OtherClockDriverValidator() = default;\r\n    \r\n    /*!\r\n     *  Validates the given other clock driver.\r\n     *\r\n     *    @param [in] otherClockDriver    The selected other clock driver.\r\n     *\r\n     *    @return True, if the other clock driver is valid IP-XACT, otherwise false.\r\n     */\r\n    bool validate(QSharedPointer<OtherClockDriver> otherClockDriver) const;\r\n\r\n    /*!\r\n     *  Check if the name is valid.\r\n     *\r\n     *    @param [in] name    The selected name.\r\n     *\r\n     *    @return True, if the name is valid, otherwise false.\r\n     */\r\n    bool hasValidName(QString const& name) const;\r\n\r\n    /*!\r\n     *  Check if a clock value is valid.\r\n     *\r\n     *    @param [in] clockUnit   The selected clock unit.\r\n     *\r\n     *    @return True, if the clock value is valid, otherwise false.\r\n     */\r\n    bool hasValidClockValue(QSharedPointer<ClockUnit> clockUnit) const;\r\n\r\n    /*!\r\n     *  Check if the clock pulse value is valid.\r\n     *\r\n     *    @param [in] otherClockDriver    The selected other clock driver.\r\n     *\r\n     *    @return True, if the pulse value is valid, otherwise false.\r\n     */\r\n    bool hasValidClockPulseValue(QSharedPointer<OtherClockDriver> otherClockDriver) const;\r\n\r\n    /*!\r\n     *  Locate errors within an other clock driver.\r\n     *\r\n     *    @param [in] errors              List of found errors.\r\n     *    @param [in] otherClockDriver    The selected other clock driver.\r\n     *    @param [in] context             Context to help locate the error.\r\n     */\r\n    void findErrorsIn(QVector<QString>& errors, QSharedPointer<OtherClockDriver> otherClockDriver,\r\n        QString const& context) const;\r\n\r\nprivate:\r\n\r\n\t// Disable copying.\r\n\tOtherClockDriverValidator(OtherClockDriverValidator const& rhs);\r\n\tOtherClockDriverValidator& operator=(OtherClockDriverValidator const& rhs);\r\n\r\n    /*!\r\n     *  Find errors within name.\r\n     *\r\n     *    @param [in] errors              List of found errors.\r\n     *    @param [in] otherClockDriver    The selected other clock driver.\r\n     *    @param [in] context             Context to help locate the error.\r\n     */\r\n    void findErrorsInName(QVector<QString>& errors, QSharedPointer<OtherClockDriver> otherClockDriver,\r\n        QString const& context) const;\r\n\r\n    /*!\r\n     *  Find errors within clock units.\r\n     *\r\n     *    @param [in] errors              List of found errors.\r\n     *    @param [in] otherClockDriver    The selected other clock driver.\r\n     *    @param [in] context             Context to help locate the error.\r\n     */\r\n    void findErrorsInClockUnits(QVector<QString>& errors, QSharedPointer<OtherClockDriver> otherClockDriver,\r\n        QString const& context) const;\r\n\r\n    /*!\r\n     *  Find errors within clock pulse value.\r\n     *\r\n     *    @param [in] errors              List of found errors.\r\n     *    @param [in] otherClockDriver    The selected other clock driver.\r\n     *    @param [in] context             Context to help locate the error.\r\n     */\r\n    void findErrorsInClockPulseValue(QVector<QString>& errors, QSharedPointer<OtherClockDriver> otherClockDriver,\r\n        QString const& context) const;\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! The expression parser to use.\r\n    QSharedPointer<ExpressionParser> expressionParser_;\r\n};\r\n\r\n#endif // OTHERCLOCKDRIVERVALIDATOR_H\r\n"
  },
  {
    "path": "IPXACTmodels/Component/validators/PortMapValidator.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: PortMapValidator.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 04.12.2015\r\n//\r\n// Description:\r\n// Validator for the ipxact:portMap.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"PortMapValidator.h\"\r\n\r\n#include <KactusAPI/include/ExpressionParser.h>\r\n\r\n#include <KactusAPI/include/LibraryInterface.h>\r\n\r\n#include <IPXACTmodels/common/ConfigurableVLNVReference.h>\r\n#include <IPXACTmodels/common/DirectionTypes.h>\r\n#include <IPXACTmodels/common/TransactionalTypes.h>\r\n\r\n#include <IPXACTmodels/common/validators/CommonItemsValidator.h>\r\n\r\n#include <IPXACTmodels/AbstractionDefinition/AbstractionDefinition.h>\r\n#include <IPXACTmodels/AbstractionDefinition/PortAbstraction.h>\r\n#include <IPXACTmodels/AbstractionDefinition/WireAbstraction.h>\r\n#include <IPXACTmodels/AbstractionDefinition/TransactionalAbstraction.h>\r\n\r\n#include <IPXACTmodels/Component/Port.h>\r\n\r\n#include <IPXACTmodels/utilities/Search.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PortMapValidator::PortMapValidator()\r\n//-----------------------------------------------------------------------------\r\nPortMapValidator::PortMapValidator(QSharedPointer<ExpressionParser> parser,\r\n    QSharedPointer<QList<QSharedPointer<Port> > > ports, LibraryInterface* libraryHandler) :\r\nexpressionParser_(parser),\r\navailablePorts_(ports),\r\nlibraryHandler_(libraryHandler)\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PortMapValidator::busInterfaceChanged()\r\n//-----------------------------------------------------------------------------\r\nvoid PortMapValidator::busInterfaceChanged(QSharedPointer<ConfigurableVLNVReference> newAbstractionReference,\r\n    General::InterfaceMode newInterfaceMode, QString const& newSystemGroup)\r\n{\r\n    if (newAbstractionReference)\r\n    {\r\n        abstractionDefinition_ = libraryHandler_->getModelReadOnly<AbstractionDefinition>(*newAbstractionReference);\r\n    }\r\n    else\r\n    {\r\n        abstractionDefinition_.clear();\r\n    }\r\n\r\n    interfaceMode_ = newInterfaceMode;\r\n    systemGroup_ = newSystemGroup;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PortMapValidator::busInterfaceChanged()\r\n//-----------------------------------------------------------------------------\r\nvoid PortMapValidator::abstractionDefinitionChanged(QSharedPointer<AbstractionDefinition const> newDefinition,\r\n    General::InterfaceMode newInterfaceMode)\r\n{\r\n    if (newDefinition)\r\n    {\r\n        abstractionDefinition_ = newDefinition;\r\n    }\r\n\r\n    interfaceMode_ = newInterfaceMode;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PortMapValidator::componentChanged()\r\n//-----------------------------------------------------------------------------\r\nvoid PortMapValidator::componentChanged(QSharedPointer<QList<QSharedPointer<Port> > > newPorts)\r\n{\r\n    availablePorts_ = newPorts;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PortMapValidator::validate()\r\n//-----------------------------------------------------------------------------\r\nbool PortMapValidator::validate(QSharedPointer<PortMap> const& portMap) const\r\n{\r\n    QSharedPointer<PortMap::LogicalPort> const& logical = portMap->getLogicalPort();\r\n    QSharedPointer<PortMap::PhysicalPort> const& physical = portMap->getPhysicalPort();\r\n    \r\n    if (hasValidLogicalPort(logical) && hasValidPhysicalMapping(portMap) &&\r\n        hasValidIsPresent(portMap))\r\n    {\r\n        if (hasValidPhysicalPort(physical))\r\n        {\r\n            QSharedPointer<PortAbstraction> logicalPort = findLogicalPort(logical->name_);\r\n            QSharedPointer<Port> physicalPort = findPhysicalPort(physical->name_);\r\n\r\n            return connectedPortsHaveValidPortTypes(logicalPort, physicalPort) &&\r\n                connectedPortsHaveValidDirections(logicalPort, physicalPort) &&\r\n                connectedPortsHaveValidInitiatives(logicalPort, physicalPort) &&\r\n                connectedPortsHaveSameRange(logical->range_, physical->partSelect_);\r\n        }\r\n\r\n        return hasValidTieOff(portMap->getLogicalTieOff());\r\n    }\r\n\r\n    return false;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PortMapValidator::hasValidIsPresent()\r\n//-----------------------------------------------------------------------------\r\nbool PortMapValidator::hasValidIsPresent(QSharedPointer<PortMap> const& portMap) const\r\n{\r\n    return CommonItemsValidator::hasValidIsPresent(portMap->getIsPresent(), expressionParser_);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PortMapValidator::hasValidLogicalPort()\r\n//-----------------------------------------------------------------------------\r\nbool PortMapValidator::hasValidLogicalPort(QSharedPointer<PortMap::LogicalPort> const& logical) const\r\n{\r\n    if (logical.isNull())\r\n    {\r\n        return false;\r\n    }\r\n\r\n    QSharedPointer<PortAbstraction> referencedPort = findLogicalPort(logical->name_);\r\n    if (referencedPort.isNull() || logical->name_.isEmpty())\r\n    {\r\n        return false;\r\n    }\r\n\r\n    return logicalPortHasValidRange(logical->range_, referencedPort);\r\n}\r\n\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PortMapValidator::logicalPortHasValidRange()\r\n//-----------------------------------------------------------------------------\r\nbool PortMapValidator::logicalPortHasValidRange(QSharedPointer<Range> const & logicalRange,\r\n    QSharedPointer<PortAbstraction> const & referencedPort) const\r\n{\r\n    if (logicalRange && (!logicalRange->getLeft().isEmpty() || !logicalRange->getRight().isEmpty()))\r\n    {\r\n        if (!bothRangeValuesExist(logicalRange->getLeft(), logicalRange->getRight()))\r\n        {\r\n            return false;\r\n        }\r\n        \r\n        auto [leftToIntOk, leftValue] = checkAndParseExpression(logicalRange->getLeft());\r\n        if (!leftToIntOk)\r\n        {\r\n            return false;\r\n        }\r\n\r\n        auto [rightToIntOk, rightValue] = checkAndParseExpression(logicalRange->getRight());\r\n        if (!rightToIntOk)\r\n        {\r\n            return false;\r\n        }\r\n\r\n        auto logicalWidth = getLogicalPortWidth(referencedPort);\r\n        if (logicalWidth == 0)\r\n        {\r\n            return true;\r\n        }\r\n\r\n        return rangeIsWithinWidth(leftValue, rightValue, logicalWidth);\r\n    }\r\n\r\n    return true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PortMapValidator::bothRangeValuesExist()\r\n//-----------------------------------------------------------------------------\r\nbool PortMapValidator::bothRangeValuesExist(QString const& leftRange, QString const& rightRange) const\r\n{\r\n    return leftRange.isEmpty() == rightRange.isEmpty();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PortMapValidator::getLogicalPortWidth()\r\n//-----------------------------------------------------------------------------\r\nquint64 PortMapValidator::getLogicalPortWidth(QSharedPointer<PortAbstraction> const& logicalPort) const\r\n{\r\n    if (logicalPort->hasWire())\r\n    {\r\n        return logicalPort->getWire()->getWidth(interfaceMode_, systemGroup_).toULongLong();\r\n    }\r\n    else if (logicalPort->hasTransactional())\r\n    {\r\n        return logicalPort->getTransactional()->getWidth(interfaceMode_, systemGroup_).toULongLong();\r\n    }\r\n\r\n    return 0;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PortMapValidator::rangeIsWithinWidth()\r\n//-----------------------------------------------------------------------------\r\nbool PortMapValidator::rangeIsWithinWidth(qint64 const& rangeLeft, qint64 const& rangeRight,\r\n    quint64 const& width) const\r\n{\r\n    return (0 <= rangeLeft && rangeLeft < static_cast<qint64>(width)) &&\r\n        (0 <= rangeRight && rangeRight < static_cast<qint64>(width));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PortMapValidator::hasValidPhysicalMapping()\r\n//-----------------------------------------------------------------------------\r\nbool PortMapValidator::hasValidPhysicalMapping(QSharedPointer<PortMap> const& portMap) const\r\n{\r\n    QSharedPointer<PortMap::PhysicalPort> physical = portMap->getPhysicalPort();\r\n    QString const& tieOff = portMap->getLogicalTieOff();\r\n\r\n    return !physical.isNull() || !tieOff.isEmpty();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PortMapValidator::hasValidPhysicalPort()\r\n//-----------------------------------------------------------------------------\r\nbool PortMapValidator::hasValidPhysicalPort(QSharedPointer<PortMap::PhysicalPort> const& physical) const\r\n{\r\n    if (physical.isNull())\r\n    {\r\n        return false;\r\n    }\r\n\r\n    QSharedPointer<Port> portReference = findPhysicalPort(physical->name_);\r\n    if (portReference.isNull())\r\n    {\r\n        return false;\r\n    }\r\n\r\n    return physicalPortHasValidPartSelect(physical->partSelect_, portReference);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PortMapValidator::hasValidTieOff()\r\n//-----------------------------------------------------------------------------\r\nbool PortMapValidator::hasValidTieOff(QString const& tieOff) const\r\n{\r\n    if (tieOff.isEmpty())\r\n    {\r\n        return false;\r\n    }\r\n\r\n    bool changeOk = true;\r\n    quint64 tieOffValue = 0;\r\n\r\n    std::tie(changeOk, tieOffValue) = checkAndParseExpression(tieOff);\r\n    return changeOk;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PortMapValidator::connectedPortsHaveValidPortTypes()\r\n//-----------------------------------------------------------------------------\r\nbool PortMapValidator::connectedPortsHaveValidPortTypes(QSharedPointer<PortAbstraction> const& logicalPort,\r\n    QSharedPointer<Port> const& physicalPort) const\r\n{\r\n    return (logicalPort->getWire() && physicalPort->getWire()) ||\r\n        (logicalPort->getTransactional() && physicalPort->getTransactional());\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PortMapValidator::connectedPortsHaveValidDirections()\r\n//-----------------------------------------------------------------------------\r\nbool PortMapValidator::connectedPortsHaveValidDirections(QSharedPointer<PortAbstraction> const& logicalPort,\r\n    QSharedPointer<Port> const& physicalPort) const\r\n{\r\n    if (logicalPort->getWire() && physicalPort->getWire())\r\n    {\r\n        if (physicalPort->getWire()->getAllLogicalDirectionsAllowed())\r\n        {\r\n            return true;\r\n        }\r\n        \r\n        DirectionTypes::Direction logicalDirection =\r\n            logicalPort->getWire()->getDirection(interfaceMode_, systemGroup_);\r\n        DirectionTypes::Direction physicalDirection = physicalPort->getWire()->getDirection();\r\n\r\n        if ((logicalDirection == DirectionTypes::IN && physicalDirection == DirectionTypes::OUT) ||\r\n            (logicalDirection == DirectionTypes::OUT && physicalDirection == DirectionTypes::IN) ||\r\n            (logicalDirection == DirectionTypes::INOUT &&\r\n            (physicalDirection == DirectionTypes::IN || physicalDirection == DirectionTypes::OUT)))\r\n        {\r\n            return false;\r\n        }\r\n    }\r\n\r\n    return true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PortMapValidator::connectedPortsHaveValidInitiatives()\r\n//-----------------------------------------------------------------------------\r\nbool PortMapValidator::connectedPortsHaveValidInitiatives(QSharedPointer<PortAbstraction> const& logicalPort,\r\n    QSharedPointer<Port> const& physicalPort) const\r\n{\r\n    if (logicalPort->getTransactional() && physicalPort->getTransactional())\r\n    {\r\n        if (physicalPort->getTransactional()->getAllLogicalInitiativesAllowed())\r\n        {\r\n            return true;\r\n        }\r\n\r\n        TransactionalTypes::Initiative logicalInitiative = TransactionalTypes::strToInitiative(\r\n            logicalPort->getTransactional()->getInitiative(interfaceMode_, systemGroup_));\r\n        TransactionalTypes::Initiative physicalInitiative =\r\n            TransactionalTypes::strToInitiative(physicalPort->getTransactional()->getInitiative());\r\n\r\n        if (physicalInitiative == TransactionalTypes::Initiative::INITIATIVE_INVALID ||\r\n            ((logicalInitiative == TransactionalTypes::Initiative::REQUIRES &&\r\n                physicalInitiative == TransactionalTypes::Initiative::PROVIDES) ||\r\n                (logicalInitiative == TransactionalTypes::Initiative::PROVIDES &&\r\n                    physicalInitiative == TransactionalTypes::Initiative::REQUIRES) ||\r\n                (logicalInitiative == TransactionalTypes::Initiative::BOTH &&\r\n                    (physicalInitiative == TransactionalTypes::Initiative::REQUIRES ||\r\n                    physicalInitiative == TransactionalTypes::Initiative::PROVIDES))))\r\n        {\r\n            return false;\r\n        }\r\n    }\r\n\r\n    return true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PortMapValidator::physicalPortHasValidPartSelect()\r\n//-----------------------------------------------------------------------------\r\nbool PortMapValidator::physicalPortHasValidPartSelect(QSharedPointer<PartSelect> const& physicalPart,\r\n    QSharedPointer<Port> const& referencedPort) const\r\n{\r\n    if (physicalPart.isNull())\r\n    {\r\n        return true;\r\n    }\r\n\r\n    if (physicalPart->getLeftRange().isEmpty() && physicalPart->getRightRange().isEmpty())\r\n    {\r\n        return true;\r\n    }\r\n\r\n    if (!bothRangeValuesExist(physicalPart->getLeftRange(), physicalPart->getRightRange()))\r\n    {\r\n        return false;\r\n    }\r\n\r\n    bool leftOK = true;\r\n    qint64 leftValue = 0;\r\n    std::tie(leftOK, leftValue) = checkAndParseExpression(physicalPart->getLeftRange());\r\n    if (!leftOK)\r\n    {\r\n        return false;\r\n    }\r\n\r\n    bool rightOK = true;\r\n    qint64 rightValue = 0;\r\n    std::tie(rightOK, rightValue) = checkAndParseExpression(physicalPart->getRightRange());\r\n    if (!rightOK)\r\n    {\r\n        return false;\r\n    }\r\n\r\n    if (referencedPort->getWire())\r\n    {\r\n        return rangeIsValidInWire(leftValue, rightValue,\r\n            expressionParser_->parseExpression(referencedPort->getLeftBound()).toULongLong(),\r\n            expressionParser_->parseExpression(referencedPort->getRightBound()).toULongLong());\r\n    }\r\n    else if (referencedPort->getTransactional())\r\n    {\r\n        return rangeIsWithinWidth(leftValue, rightValue, expressionParser_->parseExpression(\r\n            referencedPort->getTransactional()->getBusWidth()).toULongLong());\r\n    }\r\n  \r\n     return false;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PortMapValidator::rangeIsValidInWire()\r\n//-----------------------------------------------------------------------------\r\nbool PortMapValidator::rangeIsValidInWire(quint64 const& rangeLeft, quint64 const& rangeRight,\r\n    quint64 const& wireLeft, quint64 const& wireRight) const\r\n{\r\n    if (wireLeft > wireRight)\r\n    {\r\n        return rangeLeft >= wireRight && rangeLeft <= wireLeft &&\r\n            rangeRight >= wireRight && rangeRight <= wireLeft;\r\n    }\r\n    else\r\n    {\r\n        return rangeLeft >= wireLeft && rangeLeft <= wireRight &&\r\n            rangeRight >= wireLeft && rangeRight <= wireRight;\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PortMapValidator::connectedPortsHaveSameRange()\r\n//-----------------------------------------------------------------------------\r\nbool PortMapValidator::connectedPortsHaveSameRange(QSharedPointer<Range> const& logicalRange,\r\n    QSharedPointer<PartSelect> const& physicalPart) const\r\n{\r\n    quint64 physicalLeft = 0;\r\n    quint64 physicalRight = 0;\r\n\r\n    if (physicalPart && (!physicalPart->getLeftRange().isEmpty() || !physicalPart->getRightRange().isEmpty()))\r\n    {\r\n        bool leftValid = false;\r\n        std::tie(leftValid, physicalLeft) = checkAndParseExpression(physicalPart->getLeftRange());\r\n        if (leftValid == false)\r\n        {\r\n            return false;\r\n        }\r\n\r\n        bool rightValid = false;\r\n        std::tie(rightValid, physicalRight) = checkAndParseExpression(physicalPart->getRightRange());\r\n        if (rightValid == false)\r\n        {\r\n            return false;\r\n        }\r\n    }\r\n\r\n    quint64 logicalLeft = 0;\r\n    quint64 logicalRight = 0;\r\n    if (logicalRange && (!logicalRange->getLeft().isEmpty() || !logicalRange->getRight().isEmpty()))\r\n    {\r\n        bool leftValid = false;\r\n        std::tie(leftValid, logicalLeft) = checkAndParseExpression(logicalRange->getLeft());\r\n        if (leftValid == false)\r\n        {\r\n            return false;\r\n        }\r\n\r\n        bool rightValid = false;\r\n        std::tie(rightValid, logicalRight) = checkAndParseExpression(logicalRange->getRight());\r\n        if (rightValid == false)\r\n        {\r\n            return false;\r\n        }\r\n    }\r\n\r\n    quint64 physicalMax = qMax(physicalLeft, physicalRight);\r\n    quint64 physicalMin = qMin(physicalLeft, physicalRight);\r\n    quint64 logicalMax = qMax(logicalLeft, logicalRight);\r\n    quint64 logicalMin = qMin(logicalLeft, logicalRight);\r\n\r\n    quint64 logicalSize = logicalMax - logicalMin + 1;\r\n    quint64 physicalSize = physicalMax - physicalMin + 1;\r\n\r\n    return logicalSize == physicalSize;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PortMapValidator::findErrorsIn()\r\n//-----------------------------------------------------------------------------\r\nvoid PortMapValidator::findErrorsIn(QVector<QString>& errors, QSharedPointer<PortMap> portMap,\r\n    QString const& context) const\r\n{\r\n    QSharedPointer<PortMap::LogicalPort> logicalPort = portMap->getLogicalPort();\r\n    QSharedPointer<PortMap::PhysicalPort> physicalPort = portMap->getPhysicalPort();\r\n\r\n    QSharedPointer<PortAbstraction> referencedLogicalPort;\r\n    if (logicalPort)\r\n    {\r\n        referencedLogicalPort = findLogicalPort(logicalPort->name_);\r\n    }\r\n    QSharedPointer<Port> referencedPhysicalPort;\r\n    if (physicalPort)\r\n    {\r\n        referencedPhysicalPort = findPhysicalPort(physicalPort->name_);\r\n    }\r\n\r\n    findErrorsInIsPresent(errors, portMap, context);\r\n    findErrorsInLogicalPort(errors, logicalPort, referencedLogicalPort, context);\r\n\r\n    if (physicalPort && !portMap->getLogicalTieOff().isEmpty())\r\n    {\r\n        errors.append(QObject::tr(\"Invalid port map: contains both a physical port and a tie off value within %1\")\r\n            .arg(context));\r\n    }\r\n    else if (!portMap->getLogicalTieOff().isEmpty())\r\n    {\r\n        findErrorsInTieOff(errors, portMap->getLogicalTieOff(), context);\r\n    }\r\n    else if (physicalPort.isNull() == false && !physicalPort->name_.isEmpty())\r\n    {\r\n        findErrorsInPhysicalPort(errors, physicalPort, referencedPhysicalPort, context);\r\n\r\n        if (hasValidLogicalPort(logicalPort) && hasValidPhysicalPort(physicalPort))\r\n        {\r\n            findErrorsInPortConnection(\r\n                errors, logicalPort, physicalPort, referencedLogicalPort, referencedPhysicalPort, context);\r\n        }\r\n    }\r\n    else\r\n    {\r\n        errors.append(QObject::tr(\"Port map does not contain a physical port or a logical tie off within %1\")\r\n            .arg(context));\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PortMapValidator::findErrorsInIsPresent()\r\n//-----------------------------------------------------------------------------\r\nvoid PortMapValidator::findErrorsInIsPresent(QVector<QString>& errors, QSharedPointer<PortMap> portMap,\r\n    QString const& context) const\r\n{\r\n    if (!hasValidIsPresent(portMap))\r\n    {\r\n        errors.append(QObject::tr(\"Invalid isPresent set for port map within %1\").arg(context));\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PortMapValidator::findErrorsInLogicalPort()\r\n//-----------------------------------------------------------------------------\r\nvoid PortMapValidator::findErrorsInLogicalPort(QVector<QString>& errors,\r\n    QSharedPointer<PortMap::LogicalPort> logicalPort, QSharedPointer<PortAbstraction> referencedPort,\r\n    QString const& context) const\r\n{\r\n    if (logicalPort == nullptr || logicalPort->name_.isEmpty())\r\n    {\r\n        errors.append(QObject::tr(\"Port map does not contain a logical port within %1\").arg(context));\r\n        return;\r\n    }\r\n\r\n    if (referencedPort == nullptr)\r\n    {\r\n        errors.append(QObject::tr(\"Could not locate logical port %1 mapped within %2\")\r\n            .arg(logicalPort->name_).arg(context));\r\n        return;\r\n    }\r\n\r\n    if (logicalPort->range_)\r\n    {\r\n        QSharedPointer<Range> logicalRange = logicalPort->range_;\r\n        if (!bothRangeValuesExist(logicalRange->getLeft(), logicalRange->getRight()))\r\n        {\r\n            if (logicalRange->getLeft().isEmpty())\r\n            {\r\n                errors.append(QObject::tr(\"Empty left value in logical port %1 mapped within %2\")\r\n                    .arg(logicalPort->name_).arg(context));\r\n            }\r\n            if (logicalRange->getRight().isEmpty())\r\n            {\r\n                errors.append(QObject::tr(\"Empty right value in logical port %1 mapped within %2\")\r\n                    .arg(logicalPort->name_).arg(context));\r\n            }\r\n        }\r\n        else\r\n        {\r\n            bool leftValid = false;\r\n            bool rightValid = false;\r\n            qint64 rangeLeft = 0;\r\n            qint64 rangeRight = 0;\r\n\r\n            std::tie(leftValid, rangeLeft) = checkAndParseExpression(logicalRange->getLeft());\r\n            std::tie(rightValid, rangeRight) = checkAndParseExpression(logicalRange->getRight());\r\n\r\n            if (!logicalRange->getLeft().isEmpty() && !leftValid)\r\n            {\r\n                errors.append(QObject::tr(\r\n                    \"Invalid value given for logical left in logical port %1 mapped within %2\")\r\n                    .arg(logicalPort->name_).arg(context));\r\n            }\r\n            if (!logicalRange->getRight().isEmpty() && !rightValid)\r\n            {\r\n                errors.append(QObject::tr(\r\n                    \"Invalid value given for logical right in logical port %1 mapped within %2\")\r\n                    .arg(logicalPort->name_).arg(context));\r\n            }\r\n\r\n            if (leftValid && rightValid &&\r\n                !rangeIsWithinWidth(rangeLeft, rangeRight, getLogicalPortWidth(referencedPort)))\r\n            {\r\n                errors.append(QObject::tr(\r\n                    \"Range is not within the referenced port width in mapped logical port %1 in %2\")\r\n                    .arg(logicalPort->name_).arg(context));\r\n            }\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PortMapValidator::findErrorsInTieOff()\r\n//-----------------------------------------------------------------------------\r\nvoid PortMapValidator::findErrorsInTieOff(QVector<QString>& errors, QString const& tieOff, QString const& context)\r\n    const\r\n{\r\n    if (!hasValidTieOff(tieOff))\r\n    {\r\n        errors.append(QObject::tr(\"Invalid port map logical tie off set within %1\").arg(context));\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PortMapValidator::findErrorsInPhysicalPort()\r\n//-----------------------------------------------------------------------------\r\nvoid PortMapValidator::findErrorsInPhysicalPort(QVector<QString>& errors,\r\n    QSharedPointer<PortMap::PhysicalPort> physicalPort, QSharedPointer<Port> referencedPort,\r\n    QString const& context) const\r\n{\r\n    if (physicalPort == nullptr)\r\n    {\r\n        return;\r\n    }\r\n\r\n    if (physicalPort->name_.isEmpty())\r\n    {\r\n        errors.append(QObject::tr(\"Port map does not contain a physical port within %1\").arg(context));\r\n        return;\r\n    }\r\n    \r\n    if (!referencedPort)\r\n    {\r\n        errors.append(QObject::tr(\"Could not locate physical port %1 mapped within %2\")\r\n            .arg(physicalPort->name_).arg(context));\r\n        return;\r\n    }\r\n\r\n    QSharedPointer<PartSelect> physicalPart = physicalPort->partSelect_;\r\n    if (!physicalPart.isNull())\r\n    {\r\n        if (!bothRangeValuesExist(physicalPart->getLeftRange(), physicalPart->getRightRange()))\r\n        {\r\n            if (physicalPart->getLeftRange().isEmpty())\r\n            {\r\n                errors.append(QObject::tr(\"Empty left value in physical port %1 mapped within %2\")\r\n                    .arg(physicalPort->name_).arg(context));\r\n            }\r\n            if (physicalPart->getRightRange().isEmpty())\r\n            {\r\n                errors.append(QObject::tr(\"Empty right value in physical port %1 mapped within %2\")\r\n                    .arg(physicalPort->name_).arg(context));\r\n            }\r\n        }\r\n        else\r\n        {\r\n            bool leftValid = false;\r\n            bool rightValid = false;\r\n            qint64 rangeLeft = 0;\r\n            qint64 rangeRight = 0;\r\n\r\n            std::tie(leftValid, rangeLeft) = checkAndParseExpression(physicalPart->getLeftRange());\r\n            std::tie(rightValid, rangeRight) = checkAndParseExpression(physicalPart->getRightRange());\r\n\r\n            if (!leftValid)\r\n            {\r\n                errors.append(QObject::tr(\r\n                    \"Invalid value given for physical left in physical port %1 mapped within %2\")\r\n                    .arg(physicalPort->name_).arg(context));\r\n            }\r\n            if (!rightValid)\r\n            {\r\n                errors.append(QObject::tr(\r\n                    \"Invalid value given for physical right in physical port %1 mapped within %2\")\r\n                    .arg(physicalPort->name_).arg(context));\r\n            }\r\n            if (leftValid && rightValid)\r\n            {\r\n                if ((referencedPort->getWire() && !rangeIsValidInWire(rangeLeft, rangeRight,\r\n                    expressionParser_->parseExpression(referencedPort->getLeftBound()).toULongLong(),\r\n                    expressionParser_->parseExpression(referencedPort->getRightBound()).toULongLong())) ||\r\n                    ((referencedPort->getTransactional() && !rangeIsWithinWidth(rangeLeft, rangeRight,\r\n                        expressionParser_->parseExpression(\r\n                            referencedPort->getTransactional()->getBusWidth()).toULongLong()))))\r\n                {\r\n                    errors.append(QObject::tr(\r\n                        \"Range is not within the referenced port width in mapped physical port %1 in %2\")\r\n                        .arg(physicalPort->name_).arg(context));\r\n                }\r\n            }\r\n        }\r\n    }\r\n\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PortMapValidator::findErrorsInPortConnection()\r\n//-----------------------------------------------------------------------------\r\nvoid PortMapValidator::findErrorsInPortConnection(QVector<QString>& errors,\r\n    QSharedPointer<PortMap::LogicalPort> logical, QSharedPointer<PortMap::PhysicalPort> physical,\r\n    QSharedPointer<PortAbstraction> logicalPort, QSharedPointer<Port> physicalPort, QString const& context) const\r\n{\r\n    if (!connectedPortsHaveValidPortTypes(logicalPort, physicalPort))\r\n    {\r\n        errors.append(QObject::tr(\"Connected logical port %1 and physical port %3 do not have the same port \"\r\n            \"type within %5\").arg(logicalPort->name(), physicalPort->name(), context));\r\n    }\r\n    else\r\n    {\r\n        if (!connectedPortsHaveValidDirections(logicalPort, physicalPort))\r\n        {\r\n            QString logicalDirection =\r\n                DirectionTypes::direction2Str(logicalPort->getWire()->getDirection(interfaceMode_, systemGroup_));\r\n            QString physicalDirection = DirectionTypes::direction2Str(physicalPort->getWire()->getDirection());\r\n\r\n            errors.append(QObject::tr(\"Invalid connection made between logical port '%1' with direction '%2' and \"\r\n                \"physical port '%3' with direction '%4' within %5\")\r\n                .arg(logicalPort->name()).arg(logicalDirection).arg(physicalPort->name()).arg(physicalDirection)\r\n                .arg(context));\r\n        }\r\n\r\n        if (!connectedPortsHaveValidInitiatives(logicalPort, physicalPort))\r\n        {\r\n            QString logicalInitiative =\r\n                logicalPort->getTransactional()->getInitiative(interfaceMode_, systemGroup_);\r\n            QString physicalInitiative = physicalPort->getTransactional()->getInitiative();\r\n\r\n            errors.append(QObject::tr(\"Invalid connection made between logical port '%1' with initiative '%2' and \"\r\n                \"physical port '%3' with initiative '%4' within %5\")\r\n                .arg(logicalPort->name()).arg(logicalInitiative).arg(physicalPort->name()).arg(physicalInitiative)\r\n                .arg(context));\r\n        }\r\n\r\n        if (!connectedPortsHaveSameRange(logical->range_, physical->partSelect_))\r\n        {\r\n            errors.append(QObject::tr(\"Connected logical port %1 and physical port %2 do not have the same range \"\r\n                \"size within %3\").arg(logicalPort->name(), physicalPort->name(), context));\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PortMapValidator::checkAndParseExpression()\r\n//-----------------------------------------------------------------------------\r\nstd::pair<bool, quint64> PortMapValidator::checkAndParseExpression(QString const& expression) const\r\n{\r\n    bool expressionValid = false;\r\n    bool conversionValid = false;\r\n    quint64 value = expressionParser_->parseExpression(expression, &expressionValid).toULongLong(&conversionValid);\r\n\r\n    return std::make_pair(expressionValid && conversionValid, value);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PortMapValidator::findLogicalPort()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<PortAbstraction> PortMapValidator::findLogicalPort(QString const& portName) const\r\n{\r\n    if (abstractionDefinition_)\r\n    {\r\n        return Search::findByName(portName, *abstractionDefinition_->getLogicalPorts());\r\n    }\r\n\r\n    return QSharedPointer<PortAbstraction>();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PortMapValidator::findPhysicalPort()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<Port> PortMapValidator::findPhysicalPort(QString const& portName) const\r\n{\r\n    return Search::findByName(portName, *availablePorts_);\r\n}\r\n"
  },
  {
    "path": "IPXACTmodels/Component/validators/PortMapValidator.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: PortMapValidator.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 04.12.2015\r\n//\r\n// Description:\r\n// Validator for the ipxact:portMap.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef PORTMAPVALIDATOR_H\r\n#define PORTMAPVALIDATOR_H\r\n\r\n#include <IPXACTmodels/ipxactmodels_global.h>\r\n\r\n#include <IPXACTmodels/Component/PortMap.h>\r\n#include <IPXACTmodels/generaldeclarations.h>\r\n\r\n#include <QSharedPointer>\r\n#include <QString>\r\n\r\nclass AbstractionDefinition;\r\nclass LibraryInterface;\r\nclass ExpressionParser;\r\nclass ConfigurableVLNVReference;\r\nclass Port;\r\nclass PortAbstraction;\r\n//-----------------------------------------------------------------------------\r\n//! Validator for the ipxact:portMap.\r\n//-----------------------------------------------------------------------------\r\nclass IPXACTMODELS_EXPORT PortMapValidator\r\n{\r\npublic:\r\n\r\n    /*!\r\n     *  The constructor.\r\n     *\r\n     *    @param [in] parser                  The parse to use for solving expressions.\r\n     *    @param [in] ports                   The available ports.\r\n     *    @param [in] libraryHandler          The library interface.\r\n     */\r\n    PortMapValidator(QSharedPointer<ExpressionParser> parser,\r\n        QSharedPointer<QList<QSharedPointer<Port> > > ports,\r\n        LibraryInterface* libraryHandler);\r\n\r\n\t/*!\r\n     *  The destructor.\r\n     */\r\n\t~PortMapValidator() = default;\r\n    \r\n    // Disable copying.\r\n    PortMapValidator(PortMapValidator const& rhs) = delete;\r\n    PortMapValidator& operator=(PortMapValidator const& rhs) = delete;\r\n\r\n    /*!\r\n     *  Handle the change in bus interface.\r\n     *\r\n     *    @param [in] newAbstractionReference     Abstraction definition of the new bus interface.\r\n     *    @param [in] newInterfaceMode            Interface mode of the new bus interface.\r\n     *    @param [in] newSystemGroup              Used system group of the new bus interface.\r\n     */\r\n    void busInterfaceChanged(QSharedPointer<ConfigurableVLNVReference> newAbstractionReference,\r\n        General::InterfaceMode newInterfaceMode,\r\n        QString const& newSystemGroup);\r\n\r\n    /*!\r\n     *  Handle the change of abstraction definition.\r\n     *\r\n     *    @param [in] newDefinition       The new abstraction definition.\r\n     *    @param [in] newInterfaceMode    The new interface mode.\r\n     */\r\n    void abstractionDefinitionChanged(QSharedPointer<AbstractionDefinition const> newDefinition,\r\n        General::InterfaceMode newInterfaceMode);\r\n\r\n    /*!\r\n     *  Handle the change in component.\r\n     *\r\n     *    @param [in] newPorts    List of new ports.\r\n     */\r\n    void componentChanged(QSharedPointer<QList<QSharedPointer<Port> > > newPorts);\r\n\r\n    /*!\r\n     *  Validates the given port map.\r\n     *\r\n     *    @param [in] portMap     The selected port map.\r\n     *\r\n     *    @return True, if the port map is valid IP-XACT, otherwise false.\r\n     */\r\n    bool validate(QSharedPointer<PortMap> const& portMap) const;\r\n\r\n    /*!\r\n     *  Check if the is present value is valid.\r\n     *\r\n     *    @param [in] portMap     The selected port map.\r\n     *\r\n     *    @return True, if the is present is valid, otherwise false.\r\n     */\r\n    bool hasValidIsPresent(QSharedPointer<PortMap> const& portMap) const;\r\n\r\n    /*!\r\n     *  Check if the selected logical port is valid.\r\n     *\r\n     *    @param [in] logical     The selected logical port of a port map.\r\n     *\r\n     *    @return True, if the logical port is valid, otherwise false.\r\n     */\r\n    bool hasValidLogicalPort(QSharedPointer<PortMap::LogicalPort> const& logical) const;\r\n\r\n    /*!\r\n     *  Check if the port map has a valid physical port or a valid tie off.\r\n     *\r\n     *    @param [in] portMap     The selected port map.\r\n     *\r\n     *    @return True, if the physical mapping is valid, otherwise false.\r\n     */\r\n    bool hasValidPhysicalMapping(QSharedPointer<PortMap> const& portMap) const;\r\n\r\n    /*!\r\n     *  Check if the selected physical port is valid.\r\n     *\r\n\t *    @param [in] physical    The selected physical port of a port map.\r\n     *\r\n     *    @return True, if the physical port is valid, otherwise false.\r\n     */\r\n    bool hasValidPhysicalPort(QSharedPointer<PortMap::PhysicalPort> const& physical) const;\r\n\r\n    /*!\r\n     *  Check if the tie off value is valid.\r\n     *\r\n     *    @param [in] tieOff  The selected tie off value.\r\n     *\r\n     *    @return True, if the tie off value is valid, otherwise false.\r\n     */\r\n    bool hasValidTieOff(QString const& tieOff) const;\r\n\r\n    /*!\r\n     *  Check if the connected ports have valid port types.\r\n     *\r\n     *    @param [in] logicalPort     The logical port to check.\r\n     *    @param [in] physicalPort    The physical port to check.\r\n     *\r\n     *    @return True, if the port types are valid, otherwise false.\r\n     */\r\n    bool connectedPortsHaveValidPortTypes(QSharedPointer<PortAbstraction> const& logicalPort,\r\n        QSharedPointer<Port> const& physicalPort) const;\r\n\r\n    /*!\r\n     *  Check if the connected ports have valid directions.\r\n     *\r\n\t *    @param [in] logicalPort     The logical port to check.\r\n\t *    @param [in] physicalPort    The physical port to check.\r\n     *\r\n     *    @return True, if the directions are valid, otherwise false.\r\n     */\r\n\tbool connectedPortsHaveValidDirections(QSharedPointer<PortAbstraction> const& logicalPort,\r\n\t\tQSharedPointer<Port> const& physicalPort) const;\r\n\r\n    /*!\r\n     *  Check if the connected ports have valid initiatives.\r\n     *\r\n     *    @param [in] logicalPort     The logical port to check.\r\n     *    @param [in] physicalPort    The physical port to check.\r\n     *\r\n     *    @return True, if the initiatives are valid, otherwise false.\r\n     */\r\n    bool connectedPortsHaveValidInitiatives(QSharedPointer<PortAbstraction> const& logicalPort,\r\n        QSharedPointer<Port> const& physicalPort) const;\r\n\r\n    /*!\r\n     * Checks if the logical port has a valid range.\r\n     *\r\n     *    @param [in] logicalRange     The logical port range to check.\r\n     *    @param [in] referencedPort   The logical signal in the referenced abstraction.\r\n     *\r\n     *    @return True, if the range is valid, otherwise false.\r\n     */\r\n    bool logicalPortHasValidRange(QSharedPointer<Range> const & logicalRange,\r\n        QSharedPointer<PortAbstraction> const & referencedPort) const;\r\n\r\n    /*!\r\n     *  Check if the physical port has a valid part select.\r\n     *\r\n     *    @param [in] physicalPart    The selected part select.\r\n     *    @param [in] referencedPort  Port referenced by the physical port.\r\n     *\r\n     *    @return True, if the part select is valid, otherwise false.\r\n     */\r\n    bool physicalPortHasValidPartSelect(QSharedPointer<PartSelect> const& physicalPart,\r\n        QSharedPointer<Port> const& referencedPort) const;\r\n\r\n    /*!\r\n     *  Check if the connected ports have the same range.\r\n     *\r\n     *    @param [in] logicalRange    The logical range of the port map.\r\n     *    @param [in] physicalPart    The physical part selected of the port map.\r\n     *\r\n     *    @return True, if the connected ports have the same range, otherwise false.\r\n     */\r\n    bool connectedPortsHaveSameRange(QSharedPointer<Range> const& logicalRange,\r\n        QSharedPointer<PartSelect> const& physicalPart) const;\r\n\r\n    /*!\r\n     *  Locate errors within a port map.\r\n     *\r\n     *    @param [in] errors      List of found errors.\r\n     *    @param [in] portMap     The selected port map.\r\n     *    @param [in] context     Context to help locate the error.\r\n     */\r\n    void findErrorsIn(QVector<QString>& errors, QSharedPointer<PortMap> portMap, QString const& context)\r\n        const;\r\n\r\nprivate:\r\n\r\n    /*!\r\n     *  Checks if both of the given range values exist.\r\n     *\r\n     *    @param [in] leftRange   The selected left range.\r\n     *    @param [in] rightRange  The selected right range.\r\n     *\r\n     *    @return True, if both of the range values exist.\r\n     */\r\n    bool bothRangeValuesExist(QString const& leftRange, QString const& rightRange) const;\r\n\r\n    /*!\r\n     *  Get the bus width of a logical signal.\r\n     *\r\n     *    @param [in] logicalPort     The selected logical signal.\r\n     *\r\n     *    @return The bus width of the selected logical signal.\r\n     */\r\n    quint64 getLogicalPortWidth(QSharedPointer<PortAbstraction> const& logicalPort) const;\r\n\r\n    /*!\r\n     *  Check if the range is within the selected width.\r\n     *\r\n     *    @param [in] rangeLeft   Left range value.\r\n     *    @param [in] rangeRight  Right range value.\r\n     *    @param [in] width       The selected width.\r\n     *\r\n     *    @return True, if the range is within the selected width, false otherwise.\r\n     */\r\n    bool rangeIsWithinWidth(qint64 const& rangeLeft, qint64 const& rangeRight, quint64 const& width) const;\r\n\r\n    /*!\r\n     *  Check if the range is valid in a wire port.\r\n     *\r\n     *    @param [in] rangeLeft   Left range value.\r\n     *    @param [in] rangeRight  Right range value.\r\n     *    @param [in] wireLeft    Left limit of the wire.\r\n     *    @param [in] wireRight   Right limit of the wire.\r\n     *\r\n     *    @return True, if the range is valid in the wire limits, false otherwise.\r\n     */\r\n    bool rangeIsValidInWire(quint64 const& rangeLeft, quint64 const& rangeRight, quint64 const& wireLeft,\r\n        quint64 const& wireRight) const;\r\n\r\n    /*!\r\n     *  Find errors within port map isPresent.\r\n     *\r\n     *    @param [in] errors      List of found errors.\r\n     *    @param [in] portMap     The selected port map.\r\n     *    @param [in] context     Context to help locate the error.\r\n     */\r\n    void findErrorsInIsPresent(QVector<QString>& errors, QSharedPointer<PortMap> portMap, QString const& context)\r\n        const;\r\n\r\n    /*!\r\n     *  Find errors within the logical port.\r\n     *\r\n     *    @param [in] errors          List of found errors.\r\n     *    @param [in] logicalPort     The selected logical port.\r\n\t *    @param [in] referencedPort  The abstraction for the logical port.\r\n     *    @param [in] context         Context to help locate the error.\r\n     */\r\n    void findErrorsInLogicalPort(QVector<QString>& errors, QSharedPointer<PortMap::LogicalPort> logicalPort,\r\n        QSharedPointer<PortAbstraction> referencedPort, QString const& context) const;\r\n\r\n    /*!\r\n     *  Find errors within the logical tie off.\r\n     *\r\n     *    @param [in] errors      List of found errors.\r\n     *    @param [in] tieOff      The selected tie off value.\r\n     *    @param [in] context     Context to help locate the error.\r\n     */\r\n    void findErrorsInTieOff(QVector<QString>& errors, QString const& tieOff, QString const& context) const;\r\n\r\n    /*!\r\n     *  Find errors within the physical port.\r\n     *\r\n     *    @param [in] errors          List of found errors.\r\n\t *    @param [in] physicalPort    The physical port to check.\r\n     *    @param [in] referencedPort  The component port referenced by the physical port.\r\n     *    @param [in] context         Context to help locate the error.\r\n     */\r\n    void findErrorsInPhysicalPort(QVector<QString>& errors, QSharedPointer<PortMap::PhysicalPort> physicalPort,\r\n        QSharedPointer<Port> referencedPort, QString const& context) const;\r\n\r\n    /*!\r\n     *  Find errors within the mapping.\r\n     *\r\n     *    @param [in] errors          List of found errors.\r\n     *    @param [in] logical         The mapped logical port.\r\n     *    @param [in] physical        The mapped physical port.\r\n\t *    @param [in] logicalPort     The logical port abstraction.\r\n\t *    @param [in] physicalPort    The physical port to check.\r\n     *    @param [in] context         Context to help locate the error.\r\n     */\r\n    void findErrorsInPortConnection(QVector<QString>& errors, QSharedPointer<PortMap::LogicalPort> logical,\r\n        QSharedPointer<PortMap::PhysicalPort> physical, QSharedPointer<PortAbstraction> logicalPort,\r\n        QSharedPointer<Port> physicalPort, QString const& context) const;\r\n\r\n    /*!\r\n     * Parse expression and check if it is valid.\r\n     *\r\n     *    @param [in] expression  The expression to parse\r\n     *\r\n     *    @return Indication if the expression is valid and the parsed value.\r\n     */\r\n     std::pair<bool, quint64> checkAndParseExpression(QString const & expression) const;\r\n\r\n    /*!\r\n     *  Get the referenced logical port.\r\n     *\r\n     *    @param [in] portName    The name of the referenced logical port.\r\n     *\r\n     *    @return The referenced logical port.\r\n     */\r\n    QSharedPointer<PortAbstraction> findLogicalPort(QString const& portName) const;\r\n\r\n    /*!\r\n     *  Find the referenced physical port.\r\n     *\r\n     *    @param [in] portName    The name of the referenced physical port.\r\n     *\r\n     *    @return The referenced physical port.\r\n     */\r\n    QSharedPointer<Port> findPhysicalPort(QString const& portName) const;\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! The expression parser to use.\r\n    QSharedPointer<ExpressionParser> expressionParser_;\r\n\r\n    //! The currently available ports.\r\n    QSharedPointer<QList<QSharedPointer<Port> > > availablePorts_;\r\n\r\n\t//! The used abstraction definition.\r\n    QSharedPointer<AbstractionDefinition const> abstractionDefinition_;\r\n\r\n    //! Interface mode of the containing bus interface.\r\n    General::InterfaceMode interfaceMode_ = General::INTERFACE_MODE_COUNT;\r\n\r\n    //! The system group name in case of system mode.\r\n    QString systemGroup_;\r\n\r\n    //! The library interface.\r\n    LibraryInterface* libraryHandler_;\r\n};\r\n\r\n#endif // PORTMAPVALIDATOR_H\r\n"
  },
  {
    "path": "IPXACTmodels/Component/validators/PortSliceValidator.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: PortSliceValidator.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Esko Pekkarinen\n// Date: 17.08.2023\n//\n// Description:\n// Validator for ipxact:portSlice.\n//-----------------------------------------------------------------------------\n\n#include \"PortSliceValidator.h\"\n\n#include <KactusAPI/include/ExpressionParser.h>\n\n#include <IPXACTmodels/Component/PortSlice.h>\n\n#include <IPXACTmodels/common/validators/CommonItemsValidator.h>\n\n#include <QStringList>\n\n//-----------------------------------------------------------------------------\n// Function: PortSliceValidator::PortSliceValidator()\n//-----------------------------------------------------------------------------\nPortSliceValidator::PortSliceValidator(QSharedPointer<Component> component, \n\tQSharedPointer<ExpressionParser> expressionParser):\n\tcomponent_(component),\nexpressionParser_(expressionParser)\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortSliceValidator::~PortSliceValidator()\n//-----------------------------------------------------------------------------\nPortSliceValidator::~PortSliceValidator()\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortSliceValidator::validate()\n//-----------------------------------------------------------------------------\nbool PortSliceValidator::validate(QSharedPointer<PortSlice> portSlice) const\n{\n    if (hasValidName(portSlice->name()) == false)\n    {\n        return false;\n    }\n\n    if (hasValidPortReference(portSlice) == false)\n    {\n        return false;\n    }\n\n    auto physicalPort = component_->getPort(portSlice->getPortRef());\n    auto leftBound = expressionParser_->parseExpression(physicalPort->getLeftBound()).toInt();\n    auto rightBound = expressionParser_->parseExpression(physicalPort->getRightBound()).toInt();\n\n    if (isInValidRange(portSlice->getLeftRange(), leftBound, rightBound) == false)\n    {\n        return false;\n    }\n\n    if (isInValidRange(portSlice->getRightRange(), leftBound, rightBound) == false)\n    {\n        return false;\n    }\n\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortSliceValidator::hasValidLeftRange()\n//-----------------------------------------------------------------------------\nbool PortSliceValidator::hasValidLeftRange(QSharedPointer<PortSlice> portSlice) const\n{\n    auto physicalPort = component_->getPort(portSlice->getPortRef());\n    if (physicalPort.isNull())\n    {\n        return false;\n    }\n\n    auto leftBound = expressionParser_->parseExpression(physicalPort->getLeftBound()).toInt();\n    auto rightBound = expressionParser_->parseExpression(physicalPort->getRightBound()).toInt();\n\n    return isInValidRange(portSlice->getLeftRange(), leftBound, rightBound);\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortSliceValidator::hasValidRightRange()\n//-----------------------------------------------------------------------------\nbool PortSliceValidator::hasValidRightRange(QSharedPointer<PortSlice> portSlice) const\n{\n    auto physicalPort = component_->getPort(portSlice->getPortRef());\n    if (physicalPort.isNull())\n    {\n        return false;\n    }\n\n    auto leftBound = expressionParser_->parseExpression(physicalPort->getLeftBound()).toInt();\n    auto rightBound = expressionParser_->parseExpression(physicalPort->getRightBound()).toInt();\n\n    return isInValidRange(portSlice->getRightRange(), leftBound, rightBound);\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortSliceValidator::hasValidPortReference()\n//-----------------------------------------------------------------------------\nbool PortSliceValidator::hasValidPortReference(QSharedPointer<PortSlice> portSlice) const\n{\n    auto physicalPort = component_->getPort(portSlice->getPortRef());\n    return physicalPort.isNull() == false;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortSliceValidator::hasValidName()\n//-----------------------------------------------------------------------------\nbool PortSliceValidator::hasValidName(QString const& name) const\n{\n\treturn CommonItemsValidator::hasValidName(name);\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortSliceValidator::findErrorsIn()\n//-----------------------------------------------------------------------------\nvoid PortSliceValidator::findErrorsIn(QVector<QString>& errors, QSharedPointer<PortSlice> portSlice, QString const& context) const\n{\n    if (hasValidName(portSlice->name()) == false)\n    {\n        errors.append(QObject::tr(\"Invalid name '%1' set for port condition within %2.\").arg(\n            portSlice->name(), context));\n    }\n\n    if (portSlice->getPortRef().isEmpty())\n    {\n        errors.append(QObject::tr(\"No port reference set for '%1' within %2.\").arg(\n            portSlice->name(), context));\n    }\n    else if (component_ && component_->hasPort(portSlice->getPortRef()) == false)\n    {\n        errors.append(QObject::tr(\n            \"Port '%1' in port condition '%2' in %3 could not be found in the component.\").arg(\n                portSlice->getPortRef(), portSlice->name(), context));\n    }\n\n    auto physicalPort = component_->getPort(portSlice->getPortRef());\n\n    if (physicalPort)\n    {\n        auto leftBound = expressionParser_->parseExpression(physicalPort->getLeftBound()).toInt();\n        auto rightBound = expressionParser_->parseExpression(physicalPort->getRightBound()).toInt();\n\n        bool leftOk = false;\n        bool rightOk = false;\n        auto leftRange = expressionParser_->parseExpression(portSlice->getLeftRange(), &leftOk).toInt();\n        auto rightRange = expressionParser_->parseExpression(portSlice->getRightRange(), &rightOk).toInt();\n\n        if (leftOk == false)\n        {\n            errors.append(QObject::tr(\"Left range in port condition '%1' is not a valid expression in %2.\").arg(\n                portSlice->name(), context));\n        }\n        else if (!(leftBound <= leftRange && leftRange <= rightBound))\n        {\n            errors.append(QObject::tr(\"Range in port condition '%1' is outside the bounds of port '%2' in %3.\").arg(\n                portSlice->name(), portSlice->getPortRef(), context));\n        }\n\n        if (rightOk == false)\n        {\n            errors.append(QObject::tr(\"Right range in port condition '%1' is not a valid expression in %3.\").arg(\n                portSlice->name(),  context));\n        }\n        else if (!(leftBound <= rightRange && rightRange <= rightBound))\n        {\n            errors.append(QObject::tr(\"Range in port condition '%1' is outside the bounds of port '%2' in %3.\").arg(\n                portSlice->name(), portSlice->getPortRef(), context));\n        }\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortSliceValidator::componentChange()\n//-----------------------------------------------------------------------------\nvoid PortSliceValidator::componentChange(QSharedPointer<Component> newComponent)\n{\n\tcomponent_ = newComponent;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortSliceValidator::setExpressionParser()\n//-----------------------------------------------------------------------------\nvoid PortSliceValidator::setExpressionParser(QSharedPointer<ExpressionParser> expressionParser)\n{\n    expressionParser_ = expressionParser;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortSliceValidator::isInValidRange()\n//-----------------------------------------------------------------------------\nbool PortSliceValidator::isInValidRange(QString const& value, int leftBound, int rightBound) const\n{\n    bool validExpression = false;\n    auto rangeValue = expressionParser_->parseExpression(value, &validExpression).toInt();\n\n    return validExpression && (rightBound <= rangeValue && rangeValue <= leftBound);\n}\n"
  },
  {
    "path": "IPXACTmodels/Component/validators/PortSliceValidator.h",
    "content": "//-----------------------------------------------------------------------------\n// File: PortSliceValidator.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Esko Pekkarinen\n// Date: 17.08.2023\n//\n// Description:\n// Validator for ipxact:portSlice.\n//-----------------------------------------------------------------------------\n\n#ifndef PORTSLICEVALIDATOR_H\n#define PORTSLICEVALIDATOR_H\n\n#include <IPXACTmodels/ipxactmodels_global.h>\n\n#include <IPXACTmodels/Component/PortSlice.h>\n#include <IPXACTmodels/Component/Component.h>\n\n\n#include <QSharedPointer>\n#include <QString>\n#include <QVector>\n\nclass ExpressionParser;\n\n//-----------------------------------------------------------------------------\n//! Validator for ipxact:portSlice.\n//-----------------------------------------------------------------------------\nclass IPXACTMODELS_EXPORT PortSliceValidator\n{\npublic:\n\n\t/*!\n     *  The constructor.\n     * \n     *    @param [in] component      The component containing the PortSlices.\n     *    @param [in] PortSlice           The expression parser for solving expressions in PortSlices.\n\t *\n\t */\n    PortSliceValidator(QSharedPointer<Component> component, QSharedPointer<ExpressionParser> expressionParser);\n\n\t//! The destructor.\n\tvirtual ~PortSliceValidator();\n    \n\t// Disable copying.\n\tPortSliceValidator(PortSliceValidator const& rhs) = delete;\n\tPortSliceValidator& operator=(PortSliceValidator const& rhs) = delete;\n\n    /*!\n     *  Validates the given port slice.\n     *\n     *    @param [in] PortSlice           The port slice to validate.\n     *\n     *    @return True, if the PortSlice is valid IP-XACT, otherwise false.\n     */\n    bool validate(QSharedPointer<PortSlice> portSlice) const;\n\n    /*!\n     *  Validates the port reference in the given port slice.\n     *\n     *    @param [in] portSlice           The port slice to validate.\n     *\n     *    @return True, if the portSlice is has a valid port reference, otherwise false.\n     */\n    bool hasValidPortReference(QSharedPointer<PortSlice> portSlice) const;\n\n    /*!\n     *  Validates the left range in the given port slice.\n     *\n     *    @param [in] portSlice           The port slice to validate.\n     *\n     *    @return True, if the portSlice is has a valid left range, otherwise false.\n     */\n    bool hasValidLeftRange(QSharedPointer<PortSlice> portSlice) const;\n\n    /*!\n     *  Validates the right range in the given port slice.\n     *\n     *    @param [in] portSlice           The port slice to validate.\n     *\n     *    @return True, if the portSlice is has a valid right range, otherwise false.\n     */\n    bool hasValidRightRange(QSharedPointer<PortSlice> portSlice) const;\n\n    /*!\n     *  Check if the portSlice name is valid.\n     *\n     *    @param [in] name    The name to be evaluated.\n     *\n     *    @return True, if the name is valid, otherwise false.\n     */\n    bool hasValidName(QString const& name) const;\n\n    /*!\n     *  Finds possible errors in a PortSlice and creates a list of them.\n     *\n     *    @param [in] errors      List of found errors.\n     *    @param [in] PortSlice        The PortSlice whose errors to find.\n     *    @param [in] context     Context to help locate the errors.\n     */\n    void findErrorsIn(QVector<QString>& errors, QSharedPointer<PortSlice> portSlice, QString const& context) const;\n\n    /*!\n     *  Change the active component.\n     *\n     *    @param [in] newComponent    List of found errors.\n     */\n    void componentChange(QSharedPointer<Component> newComponent);\n\n    /*!\n     *\tSet the expression parser to be used.\n     *  \n     *    @param [in] expressionParser     The expression parser to set.\n     */\n    void setExpressionParser(QSharedPointer<ExpressionParser> expressionParser);\n\nprivate:\n\n    /* Check if the given value is in the given range.\n     *\n     *    @param [in] value        The value to be evaluated.\n     *    @param [in] leftBound    The left bound of the range.\n     *    @param [in] rightBound   The right bound of the range.\n     *\n     *    @return True, if the value is in the range, otherwise false.\n     */\n    bool isInValidRange(QString const& value, int leftBound, int rightBound) const;\n\n    //! The component containing the PortSlices.\n    QSharedPointer<Component> component_ = nullptr;\n\n    //! The expression parser to use.\n    QSharedPointer<ExpressionParser> expressionParser_;\n};\n\n#endif // PORTSLICEVALIDATOR_H\n"
  },
  {
    "path": "IPXACTmodels/Component/validators/PortTypeValidator.cpp",
    "content": "//-----------------------------------------------------------------------------\n// Port: PortTypeValidator.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Mikko Teuho\n// Date: 05.01.2018\n//\n// Description:\n// Validator for port types and their associated elements.\n//-----------------------------------------------------------------------------\n\n#include \"PortTypeValidator.h\"\n\n#include <IPXACTmodels/Component/View.h>\n\n//-----------------------------------------------------------------------------\n// Function: PortTypeValidator::PortTypeValidator()\n//-----------------------------------------------------------------------------\nPortTypeValidator::PortTypeValidator(QSharedPointer<QList<QSharedPointer<View> > > views):\navailableViews_(views)\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortTypeValidator::componentChange()\n//-----------------------------------------------------------------------------\nvoid PortTypeValidator::componentChange(QSharedPointer<QList<QSharedPointer<View> > > newViews)\n{\n    availableViews_ = newViews;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortTypeValidator::validate()\n//-----------------------------------------------------------------------------\nbool PortTypeValidator::validate(QSharedPointer<WireTypeDef> typeDefinition,\n    QSharedPointer<QList<QSharedPointer<WireTypeDef> > > definitionList) const\n{\n    return hasValidtype(typeDefinition) && hasValidViewReferences(typeDefinition, definitionList);\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortTypeValidator::hasValidtype()\n//-----------------------------------------------------------------------------\nbool PortTypeValidator::hasValidtype(QSharedPointer<WireTypeDef> /*typeDefinition*/) const\n{\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortTypeValidator::hasValidViewReferences()\n//-----------------------------------------------------------------------------\nbool PortTypeValidator::hasValidViewReferences(QSharedPointer<WireTypeDef> typeDefinition,\n    QSharedPointer<QList<QSharedPointer<WireTypeDef> > > definitionList) const\n{\n    if (typeDefinition->getViewRefs()->isEmpty() && definitionList->size() != 1)\n    {\n        return false;\n    }\n    else\n    {\n        for (QString const& view : *typeDefinition->getViewRefs())\n        {            \n            if (!hasValidView(view, definitionList))\n            {\n                return false;\n            }\n        }\n    }\n\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortTypeValidator::hasValidView()\n//-----------------------------------------------------------------------------\nbool PortTypeValidator::hasValidView(QString const& view,\n    QSharedPointer<QList<QSharedPointer<WireTypeDef> > > typeDefinitionList) const\n{\n    return !view.isEmpty() && referencedViewExists(view) && viewIsReferencedOnce(view, typeDefinitionList);\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortTypeValidator::referencedViewExists()\n//-----------------------------------------------------------------------------\nbool PortTypeValidator::referencedViewExists(QString const& viewRef) const\n{\n    for (QSharedPointer<View> view : *availableViews_)\n    {\n        if (view->name() == viewRef)\n        {\n            return true;\n        }\n    }\n\n    return false;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortTypeValidator::viewIsReferencedOnce()\n//-----------------------------------------------------------------------------\nbool PortTypeValidator::viewIsReferencedOnce(QString const& referencedView,\n    QSharedPointer<QList<QSharedPointer<WireTypeDef> > > typeDefinitionList) const\n{\n    if (!typeDefinitionList)\n    {\n        return false;\n    }\n\n    int count = 0;\n    for (QSharedPointer<WireTypeDef> typeDefinition : *typeDefinitionList)\n    {\n        for (QString const& typeView : *typeDefinition->getViewRefs())\n        {           \n            if (QString::compare(typeView, referencedView) == 0)\n            {\n                ++count;\n                if (count > 1)\n                {\n                    return false;\n                }\n            }\n        }\n    }\n\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortTypeValidator::findErrorsIn()\n//-----------------------------------------------------------------------------\nvoid PortTypeValidator::findErrorsIn(QVector<QString>& errors, QString const& context,\n    QSharedPointer<WireTypeDef> typeDefinition,\n    QSharedPointer<QList<QSharedPointer<WireTypeDef> > > definitionList) const\n{\n    if (!hasValidtype(typeDefinition))\n    {\n        errors.append(QObject::tr(\"Empty port type name set for wire type definition within %1\").arg(context));\n    }\n\n    findErrorsInViewReferences(errors, context, typeDefinition, definitionList);\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortTypeValidator::findErrorsInViewReferences()\n//-----------------------------------------------------------------------------\nvoid PortTypeValidator::findErrorsInViewReferences(QVector<QString>& errors, QString const& context,\n    QSharedPointer<WireTypeDef> typeDefinition,\n    QSharedPointer<QList<QSharedPointer<WireTypeDef> > > definitionList) const\n{\n    QString typeName = typeDefinition->getTypeName();\n\n    if (typeDefinition->getViewRefs()->isEmpty() && definitionList->size() > 1)\n    {\n        errors.append(QObject::tr(\n            \"Port type %1 within %2 should be the only defined type for the containing port\").\n            arg(typeName).arg(context));\n    }\n    else\n    {\n        for (QString const& view : *typeDefinition->getViewRefs())\n        {\n            if (view.isEmpty())\n            {\n                errors.append(QObject::tr(\"Empty view reference assigned to port type %1 within %2\").\n                    arg(typeName).arg(context));\n            }\n            else\n            {\n                if (!referencedViewExists(view))\n                {\n                    errors.append(QObject::tr(\"View %1 referenced by port type %2 does not exist within %3\").\n                        arg(view).arg(typeName).arg(context));\n                }\n\n                if (!viewIsReferencedOnce(view, definitionList))\n                {\n                    errors.append(QObject::tr(\n                        \"View %1 referenced by port type %2 has been used in multiple types within %3\").\n                        arg(view).arg(typeName).arg(context));\n                }\n            }\n        }\n    }\n}\n"
  },
  {
    "path": "IPXACTmodels/Component/validators/PortTypeValidator.h",
    "content": "//-----------------------------------------------------------------------------\n// Port: PortTypeValidator.h\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Mikko Teuho\n// Date: 05.01.2018\n//\n// Description:\n// Validator for port types and their associated elements.\n//-----------------------------------------------------------------------------\n\n#ifndef PORTTYPEVALIDATOR_H\n#define PORTTYPEVALIDATOR_H\n\n#include <IPXACTmodels/Component/View.h>\n#include <IPXACTmodels/Component/WireTypeDef.h>\n\n#include <QSharedPointer>\n\n//-----------------------------------------------------------------------------\n//! Validator for port types and their associated elements.\n//-----------------------------------------------------------------------------\nclass IPXACTMODELS_EXPORT PortTypeValidator\n{\npublic:\n\n\t/*!\n\t *  The constructor.\n\t *\n     *    @param [in] views   The available views.\n\t */\n    PortTypeValidator(QSharedPointer<QList<QSharedPointer<View> > > views);\n\n\t/*!\n     *  The destructor.\n     */\n    ~PortTypeValidator() = default;\n\n    // No copying. No assignment.\n    PortTypeValidator(PortTypeValidator const& rhs) = delete;\n    PortTypeValidator& operator=(PortTypeValidator const& rhs) = delete;\n\n    /*!\n     *  Change the available views.\n     *\n     *    @param [in] newViews    The new views.\n     */\n    void componentChange(QSharedPointer<QList<QSharedPointer<View> > > newViews);\n\n    /*!\n     *  Validates the given port type definition.\n     *\n     *    @param [in] typeDefinition  The selected type definition.\n     *    @param [in] definitionList  List containing all the port type definitions.\n     *\n     *    @return True, if the type definition is valid IP-XACT, otherwise false.\n     */\n    bool validate(QSharedPointer<WireTypeDef> typeDefinition,\n        QSharedPointer<QList<QSharedPointer<WireTypeDef> > > definitionList) const;\n\n    /*!\n     *  Checks if the selected type definition has a valid type name.\n     *\n     *    @param [in] typeDefinition  The selected type definition.\n     *\n     *    @return True, if the type name is valid IP-XACT, otherwise false.\n     */\n    bool hasValidtype(QSharedPointer<WireTypeDef> typeDefinition) const;\n\n    /*!\n     *  Checks if the selected type definition has valid view references.\n     *\n     *    @param [in] typeDefinition  The selected type definition.\n     *    @param [in] definitionList  List containing all the type definitions of the containing port.\n     *\n     *    @return True, if the view references are valid IP-XACT, otherwise false.\n     */\n    bool hasValidViewReferences(QSharedPointer<WireTypeDef> typeDefinition,\n        QSharedPointer<QList<QSharedPointer<WireTypeDef> > > definitionList) const;\n\n    /*!\n     *  Checks if the selected view reference is valid.\n     *\n     *    @param [in] view                The selected view reference.\n     *    @param [in] typeDefinitionList  List containing all the type definitions of the containing port.\n     *\n     *    @return True, if the view reference is valid IP-XACT, otherwise false.\n     */\n    bool hasValidView(QString const& view, QSharedPointer<QList<QSharedPointer<WireTypeDef> > > typeDefinitionList)\n        const;\n\n    /*!\n     *  Check if the referenced view exists within the containing component.\n     *\n\t *    @param [in] viewRef     The selected view reference.\n     *\n     *    @return True, if the view reference exists, otherwise false.\n     */\n    bool referencedViewExists(QString const& viewRef) const;\n\n    /*!\n     *  Checks if the selected view is referenced only once in all of the type definitions.\n     *\n     *    @param [in] referencedView      The selected view reference.\n     *    @param [in] typeDefinitionList  List containing all the type definitions of the containing port.\n     *\n     *    @return True, if the view reference is used only once in all of the type definitions, otherwise false.\n     */\n    bool viewIsReferencedOnce(QString const& referencedView,\n        QSharedPointer<QList<QSharedPointer<WireTypeDef> > > typeDefinitionList) const;\n\n    /*!\n     *  Find possible errors in a type definition and create a list of them.\n     *\n     *    @param [in/out] errors      List of found errors.\n     *    @param [in] context         Context to help locate the errors.\n     *    @param [in] typeDefinition  The selected type definition.\n     *    @param [in] definitionList  List of type definitions contained within the containing port.\n     */\n    void findErrorsIn(QVector<QString>& errors, QString const& context,\n        QSharedPointer<WireTypeDef> typeDefinition,\n        QSharedPointer<QList<QSharedPointer<WireTypeDef> > > definitionList) const;\n\nprivate:\n\n    /*!\n     *  Find errors in the view references of the selected type definition.\n     *\n     *    @param [in/out] errors          List containing the found errors.\n     *    @param [in] context             Context to help locate the errors.\n     *    @param [in] typeDefinition      The selected type definition.\n     *    @param [in] definitionList      List of type definitions contained within the containing port.\n     */\n    void findErrorsInViewReferences(QVector<QString>& errors, QString const& context,\n        QSharedPointer<WireTypeDef> typeDefinition,\n        QSharedPointer<QList<QSharedPointer<WireTypeDef> > > definitionList) const;\n\n    //-----------------------------------------------------------------------------\n    // Data.\n    //-----------------------------------------------------------------------------\n\n    //! The currently available views.\n    QSharedPointer<QList<QSharedPointer<View> > > availableViews_;\n};\n\n#endif // PORTTYPEVALIDATOR_H\n"
  },
  {
    "path": "IPXACTmodels/Component/validators/PortValidator.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// Port: PortValidator.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Janne Virtanen\r\n// Date: 25.11.2015\r\n//\r\n// Description:\r\n// Validator for ipxact:Port.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"PortValidator.h\"\r\n\r\n#include <KactusAPI/include/ExpressionParser.h>\r\n\r\n#include <IPXACTmodels/common/TransactionalTypes.h>\r\n#include <IPXACTmodels/common/Enumeration.h>\r\n#include <IPXACTmodels/common/validators/ProtocolValidator.h>\r\n\r\n#include <IPXACTmodels/common/Choice.h>\r\n#include <IPXACTmodels/Component/Port.h>\r\n#include <IPXACTmodels/Component/View.h>\r\n\r\n#include <IPXACTmodels/Component/validators/PortTypeValidator.h>\r\n\r\n#include <QRegularExpression>\r\n#include <QStringList>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PortValidator::PortValidator()\r\n//-----------------------------------------------------------------------------\r\nPortValidator::PortValidator(QSharedPointer<ExpressionParser> expressionParser,\r\n    QSharedPointer<QList<QSharedPointer<View> > > views):\r\nHierarchicalValidator(),\r\nexpressionParser_(expressionParser),\r\ntypeValidator_(new PortTypeValidator(views))\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PortValidator::~PortValidator()\r\n//-----------------------------------------------------------------------------\r\nPortValidator::~PortValidator()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PortValidator::getTypeValidator()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<PortTypeValidator> PortValidator::getTypeValidator() const\r\n{\r\n    return typeValidator_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PortValidator::componentChange()\r\n//-----------------------------------------------------------------------------\r\nvoid PortValidator::componentChange(QSharedPointer<QList<QSharedPointer<View> > > newViews)\r\n{\r\n    typeValidator_->componentChange(newViews);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PortValidator::validate()\r\n//-----------------------------------------------------------------------------\r\nbool PortValidator::validate(QSharedPointer<Port> port) const\r\n{\r\n    return hasValidName(port->name()) && hasValidIsPresent(port) && hasValidArrays(port) &&\r\n        (port->getTransactional() || port->getWire() || port->getStructured()) && hasValidWire(port) &&\r\n        hasValidTransactionalPort(port) && validComparedToSiblings(port);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PortValidator::hasValidName()\r\n//-----------------------------------------------------------------------------\r\nbool PortValidator::hasValidName(QString const& name) const\r\n{\r\n    QRegularExpression nameExpression;\r\n    nameExpression.setPattern(QStringLiteral(\"^[a-zA-Z:_]+[a-zA-Z0-9:_.-]*$\"));\r\n\r\n    return nameExpression.match(name).hasMatch();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PortValidator::hasValidIsPresent()\r\n//-----------------------------------------------------------------------------\r\nbool PortValidator::hasValidIsPresent(QSharedPointer<Port> port) const\r\n{\r\n    if (!port->getIsPresent().isEmpty())\r\n    {\r\n        QString solvedValue = expressionParser_->parseExpression(port->getIsPresent());\r\n\r\n        bool toIntOk = true;\r\n        int intValue = solvedValue.toInt(&toIntOk);\r\n\r\n        if (!toIntOk || intValue < 0 || intValue > 1)\r\n        {\r\n            return false;\r\n        }\r\n    }\r\n\r\n    return true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PortValidator::hasValidArrays()\r\n//-----------------------------------------------------------------------------\r\nbool PortValidator::hasValidArrays(QSharedPointer<Port> port) const\r\n{\r\n    // Any arrays must have valid left and right.\r\n    for ( auto const& array : *port->getArrays() )\r\n    {\r\n        if (!arrayValueIsValid(array.getLeft()) || !arrayValueIsValid(array.getRight()))\r\n        {\r\n            return false;\r\n        }\r\n    }\r\n\r\n    return true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PortValidator::arrayValueIsValid()\r\n//-----------------------------------------------------------------------------\r\nbool PortValidator::arrayValueIsValid(QString const& arrayValue) const\r\n{\r\n    if (!arrayValue.isEmpty())\r\n    {\r\n        bool valueIsOk = false;\r\n        int valueInt = expressionParser_->parseExpression(arrayValue, &valueIsOk).toInt();\r\n         \r\n        if (valueIsOk)\r\n        {\r\n            return valueInt >= 0;\r\n        }\r\n    }\r\n\r\n    return false;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PortValidator::hasValidWire()\r\n//-----------------------------------------------------------------------------\r\nbool PortValidator::hasValidWire(QSharedPointer<Port> port) const\r\n{\r\n    QSharedPointer<Wire> wire = port->getWire();\r\n\r\n    if (wire)\r\n    {\r\n\t\t// Bounds not defined, means they are ok.\r\n        if (!wireHasValidDirection(wire))\r\n        {\r\n            return false;\r\n        }\r\n\r\n\t\tif (!wire->getVectorLeftBound().isEmpty() || !wire->getVectorRightBound().isEmpty())\r\n\t\t{\r\n\t\t\t// Bounds must be valid if defined.\r\n\t\t\tif (!portBoundIsValid(wire->getVectorLeftBound()) || !portBoundIsValid(wire->getVectorRightBound()))\r\n\t\t\t{\r\n\t\t\t\treturn false;\r\n\t\t\t}\r\n\t\t}\r\n\r\n        if (!hasValidDefaultValue(port))\r\n        {\r\n            return false;\r\n        }\r\n\r\n        if (!hasValidTypeDefinitions(wire->getWireTypeDefs()))\r\n        {\r\n            return false;\r\n        }\r\n    }\r\n\r\n    return true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PortValidator::hasValidDefaultValue()\r\n//-----------------------------------------------------------------------------\r\nbool PortValidator::hasValidDefaultValue(QSharedPointer<Port> port) const\r\n{\r\n    QSharedPointer<Wire> wire = port->getWire();\r\n\r\n    if (!wire)\r\n    {\r\n        return true;\r\n    }\r\n\r\n    bool inDirection = wire->getDirection() == DirectionTypes::IN || wire->getDirection() == DirectionTypes::INOUT;\r\n    return inDirection || wire->getDefaultDriverValue().isEmpty();        \r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PortValidator::wireHasValidDirection()\r\n//-----------------------------------------------------------------------------\r\nbool PortValidator::wireHasValidDirection(QSharedPointer<Wire> wire) const\r\n{\r\n    return wire->getDirection() != DirectionTypes::DIRECTION_INVALID;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PortValidator::portBoundIsValid()\r\n//-----------------------------------------------------------------------------\r\nbool PortValidator::portBoundIsValid(QString const& portBound) const\r\n{\r\n    if (!portBound.isEmpty())\r\n    {\r\n        bool isValidBound = false;\r\n        bool canConvertToInt = false;\r\n        int valueInt = expressionParser_->parseExpression(portBound, &isValidBound).toInt(&canConvertToInt);\r\n        \r\n        return isValidBound && canConvertToInt && valueInt >= 0;\r\n    }\r\n\r\n    return false;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PortValidator::hasValidTransactionalPort()\r\n//-----------------------------------------------------------------------------\r\nbool PortValidator::hasValidTransactionalPort(QSharedPointer<Port> port) const\r\n{\r\n    QSharedPointer<Transactional> trans = port->getTransactional();\r\n    if (trans)\r\n    {\r\n        return hasValidTransactionalInitiative(trans) && hasValidTransactionalKind(trans) &&\r\n            hasValidTransactionalWidth(trans) && hasValidTransactionalMaxConnections(trans) &&\r\n            hasValidTransactionalMinConnections(trans) && hasValidTypeDefinitions(trans->getTransTypeDef()) &&\r\n            hasValidTransactionalProtocol(trans);\r\n    }\r\n\r\n    return true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PortValidator::hasValidTransactionalInitiative()\r\n//-----------------------------------------------------------------------------\r\nbool PortValidator::hasValidTransactionalInitiative(QSharedPointer<Transactional> transactional) const\r\n{\r\n    return TransactionalTypes::isIpXactInitiativeType(transactional->getInitiative());\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PortValidator::hasValidTransactionalKind()\r\n//-----------------------------------------------------------------------------\r\nbool PortValidator::hasValidTransactionalKind(QSharedPointer<Transactional> transactional) const\r\n{\r\n    return true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PortValidator::hasValidTransactionalWidth()\r\n//-----------------------------------------------------------------------------\r\nbool PortValidator::hasValidTransactionalWidth(QSharedPointer<Transactional> transactional) const\r\n{\r\n    bool isValidBusWidth = false;\r\n    expressionParser_->parseExpression(transactional->getBusWidth(), &isValidBusWidth);\r\n\r\n    return isValidBusWidth;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PortValidator::hasValidTransactionalMaxConnections()\r\n//-----------------------------------------------------------------------------\r\nbool PortValidator::hasValidTransactionalMaxConnections(QSharedPointer<Transactional> transactional) const\r\n{\r\n    bool isValidMaxConnections = false;\r\n    expressionParser_->parseExpression(transactional->getMaxConnections(), &isValidMaxConnections);\r\n\r\n    return isValidMaxConnections;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PortValidator::hasValidTransactionalMinConnections()\r\n//-----------------------------------------------------------------------------\r\nbool PortValidator::hasValidTransactionalMinConnections(QSharedPointer<Transactional> transactional) const\r\n{\r\n    bool isValidMinConnections = false;\r\n    expressionParser_->parseExpression(transactional->getMinConnections(), &isValidMinConnections);\r\n\r\n    return isValidMinConnections;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PortValidator::hasValidTransactionalProtocol()\r\n//-----------------------------------------------------------------------------\r\nbool PortValidator::hasValidTransactionalProtocol(QSharedPointer<Transactional> transactional) const\r\n{\r\n    QSharedPointer<Protocol> protocol = transactional->getProtocol();\r\n    if (protocol)\r\n    {\r\n        ProtocolValidator protocolValidator;\r\n        if (!protocolValidator.validate(protocol))\r\n        {\r\n            return false;\r\n        }\r\n    }\r\n\r\n    return true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PortValidator::hasValidTypeDefinitions()\r\n//-----------------------------------------------------------------------------\r\nbool PortValidator::hasValidTypeDefinitions(QSharedPointer<QList<QSharedPointer<WireTypeDef> > > typeDefinitions)\r\n    const\r\n{\r\n    for (QSharedPointer<WireTypeDef> singleTypeDefinition : *typeDefinitions)\r\n    {\r\n        if (!typeValidator_->validate(singleTypeDefinition, typeDefinitions))\r\n        {\r\n            return false;\r\n        }\r\n    }\r\n\r\n    return true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PortValidator::findErrorsIn()\r\n//-----------------------------------------------------------------------------\r\nvoid PortValidator::findErrorsIn(QVector<QString>& errors, QSharedPointer<Port> port, QString const& context) const\r\n{\r\n\t// Name must be valid.\r\n\tif (!hasValidName(port->name()))\r\n\t{\r\n        errors.append(QObject::tr(\"Invalid name set for port %1 within %2\").arg(port->name()).arg(context));\r\n\t}\r\n\r\n\t// Presence must be valid if defined.\r\n    if (!hasValidIsPresent(port))\r\n\t{\r\n\t\terrors.append(QObject::tr(\"The presence is invalid: %1 in port %2\")\r\n            .arg(port->getIsPresent()).arg(port->name()));\r\n\t}\r\n\r\n\t// Any arrays must have valid left and right.\r\n\tfor ( auto const& array : *port->getArrays() )\r\n\t{\r\n        if (!arrayValueIsValid(array.getLeft()))\r\n\t\t{\r\n\t\t\terrors.append(QObject::tr(\"The left of array is invalid: %1 in port %2\").arg(array.getLeft(), \r\n                port->name()));\r\n\t\t}\r\n        if (!arrayValueIsValid(array.getRight()))\r\n\t\t{\r\n\t\t\terrors.append(QObject::tr(\"The right of array is invalid: %1 in port %2\").arg(\r\n                array.getRight(), port->name()));\r\n\t\t}\r\n\t}\r\n\r\n\tif (port->getWire())\r\n\t{\r\n        findErrorsInWire(errors, port, context);\r\n\t}\r\n\r\n\tif (port->getTransactional())\r\n\t{\r\n        findErrorsInTransactional(errors, port, context);\r\n\t}\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PortValidator::findErrorsInWire()\r\n//-----------------------------------------------------------------------------\r\nvoid PortValidator::findErrorsInWire(QVector<QString>& errors, QSharedPointer<Port> port, QString const& context)\r\n    const\r\n{\r\n    QSharedPointer<Wire> wire = port->getWire();\r\n\r\n    if (wire)\r\n    {\r\n        if (!wire->getVectorLeftBound().isEmpty() || !wire->getVectorRightBound().isEmpty())\r\n        {\r\n            // Bounds must be valid.\r\n            if (!portBoundIsValid(wire->getVectorLeftBound()))\r\n            {\r\n                errors.append(QObject::tr(\"The left of vector is invalid: %1 in port %2\").arg(\r\n                    wire->getVectorLeftBound(), port->name()));\r\n            }\r\n\r\n            if (!portBoundIsValid(wire->getVectorRightBound()))\r\n            {\r\n                errors.append(QObject::tr(\"The right of vector is invalid: %1 in port %2\").arg(\r\n                    wire->getVectorRightBound(), port->name()));\r\n            }\r\n        }\r\n\r\n        if (!wireHasValidDirection(wire))\r\n        {\r\n            errors.append(QObject::tr(\"Invalid direction set for port %1 within %2\").arg(port->name()).arg(context));\r\n        }\r\n\r\n        if (!hasValidDefaultValue(port))\r\n        {\r\n            errors.append(QObject::tr(\"Default value cannot be set for direction %1 for port %2 within %3.\").arg(\r\n                DirectionTypes::direction2Str(port->getDirection()), port->name(), context));\r\n        }\r\n\r\n        findErrorsInTypeDefinitions(errors, wire->getWireTypeDefs(), context);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PortValidator::findErrorsInTransactional()\r\n//-----------------------------------------------------------------------------\r\nvoid PortValidator::findErrorsInTransactional(QVector<QString> &errors, QSharedPointer<Port> port, \r\n    QString const& context) const\r\n{\r\n    QSharedPointer<Transactional> trans = port->getTransactional();\r\n    if (trans)\r\n    {\r\n        if (!hasValidTransactionalInitiative(trans))\r\n        {\r\n            errors.append(QObject::tr(\"The transactional initiative is invalid: %1 in port %2\")\r\n                .arg(trans->getInitiative()).arg(port->name()));\r\n        }\r\n        if (!hasValidTransactionalKind(trans))\r\n        {\r\n            errors.append(QObject::tr(\"The transactional kind is invalid: %1 in port %2\")\r\n                .arg(trans->getInitiative()).arg(port->name()));\r\n        }\r\n        if (!hasValidTransactionalWidth(trans))\r\n        {\r\n            errors.append(QObject::tr(\"The transactional bus width is invalid: %1 in port %2\")\r\n                .arg(trans->getBusWidth()).arg(port->name()));\r\n        }\r\n        if (!hasValidTransactionalMaxConnections(trans))\r\n        {\r\n            errors.append(QObject::tr(\"The transactional max connections is invalid: %1 in port %2\")\r\n                .arg(trans->getMaxConnections()).arg(port->name()));\r\n        }\r\n        if (!hasValidTransactionalMinConnections(trans))\r\n        {\r\n            errors.append(QObject::tr(\"The transactional min connections is invalid: %1 in port %2\")\r\n                .arg(trans->getMinConnections()).arg(port->name()));\r\n        }\r\n\r\n        findErrorsInTypeDefinitions(errors, trans->getTransTypeDef(), context);\r\n\r\n        QSharedPointer<Protocol> protocol = trans->getProtocol();\r\n\r\n        // Protocol must be valid if it exists.\r\n        if (protocol)\r\n        {\r\n            ProtocolValidator protocolValidator;\r\n            protocolValidator.findErrorsIn(errors, protocol, context);\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PortValidator::findErrorsInTypeDefinitions()\r\n//-----------------------------------------------------------------------------\r\nvoid PortValidator::findErrorsInTypeDefinitions(QVector<QString>& errors,\r\n    QSharedPointer<QList<QSharedPointer<WireTypeDef> > > typeDefinitions, QString const& context) const\r\n{\r\n    for (QSharedPointer<WireTypeDef> singleTypeDefinition : *typeDefinitions)\r\n    {\r\n        typeValidator_->findErrorsIn(errors, context, singleTypeDefinition, typeDefinitions);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PortValidator::hasValidTypes()\r\n//-----------------------------------------------------------------------------\r\nbool PortValidator::hasValidTypes(QSharedPointer<Port> port) const\r\n{\r\n    QSharedPointer<QList<QSharedPointer<WireTypeDef> > > typeDefinitions;\r\n\r\n    if (port->getWire())\r\n    {\r\n        typeDefinitions = port->getWire()->getWireTypeDefs();\r\n    }\r\n    else if (port->getTransactional())\r\n    {\r\n        typeDefinitions = port->getTransactional()->getTransTypeDef();\r\n    }\r\n\r\n    if (typeDefinitions)\r\n    {\r\n        for (QSharedPointer<WireTypeDef> singleType : *typeDefinitions)\r\n        {\r\n            if (!typeValidator_->validate(singleType, typeDefinitions))\r\n            {\r\n                return false;\r\n            }\r\n        }\r\n        \r\n        return true;\r\n    }\r\n\r\n    return false;\r\n}\r\n"
  },
  {
    "path": "IPXACTmodels/Component/validators/PortValidator.h",
    "content": "//-----------------------------------------------------------------------------\r\n// Port: PortValidator.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Janne Virtanen\r\n// Date: 25.11.2015\r\n//\r\n// Description:\r\n// Validator for ipxact:Port.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef PortVALIDATOR_H\r\n#define PortVALIDATOR_H\r\n\r\n#include <IPXACTmodels/ipxactmodels_global.h>\r\n\r\n#include <IPXACTmodels/common/validators/HierarchicalValidator.h>\r\n\r\n#include <QString>\r\n#include <QVector>\r\n#include <QSharedPointer>\r\n\r\nclass ExpressionParser;\r\nclass Port;\r\nclass View;\r\nclass Wire;\r\nclass WireTypeDef;\r\nclass Transactional;\r\nclass PortTypeValidator;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Validator for ipxact:Port.\r\n//-----------------------------------------------------------------------------\r\nclass IPXACTMODELS_EXPORT PortValidator : public HierarchicalValidator\r\n{\r\npublic:\r\n\r\n\t/*!\r\n\t *  The constructor.\r\n\t *\r\n     *    @param [in] expressionParser    The used expression parser.\r\n     *    @param [in] views               The available views.\r\n\t */\r\n    PortValidator(QSharedPointer<ExpressionParser> expressionParser,\r\n        QSharedPointer<QList<QSharedPointer<View> > > views);\r\n\r\n\t//! The destructor.\r\n\tvirtual ~PortValidator();\r\n\r\n    /*!\r\n     *  Change the available views.\r\n     *\r\n     *    @param [in] newViews    The new views.\r\n     */\r\n    void componentChange(QSharedPointer<QList<QSharedPointer<View> > > newViews);\r\n\r\n    /*!\r\n     *  Validates the given Port.\r\n     *\r\n     *    @param [in] Port           The Port to validate.\r\n     *\r\n     *    @return True, if the Port is valid IP-XACT, otherwise false.\r\n     */\r\n    virtual bool validate(QSharedPointer<Port> port) const;\r\n\r\n    \r\n    /*!\r\n     *  Check if the name is valid.\r\n     *\r\n     *    @param [in] name    The name to be evaluated.\r\n     *\r\n     *    @return True, if the name is valid, otherwise false.\r\n     */\r\n\tbool hasValidName(QString const& name) const;\r\n\t\r\n    /*!\r\n     *  Check if the is present is valid.\r\n     *\r\n     *    @param [in] port    The selected port.\r\n     *\r\n     *    @return True, if the is present is valid, otherwise false.\r\n     */\r\n    bool hasValidIsPresent(QSharedPointer<Port> port) const;\r\n\r\n    /*!\r\n     *  Check if the arrays are valid.\r\n     *\r\n     *    @param [in] port    The selected port.\r\n     *\r\n     *    @return True, if the arrays are valid, otherwise false.\r\n     */\r\n    bool hasValidArrays(QSharedPointer<Port> port) const;\r\n\r\n    /*!\r\n     *  Check if an array value is valid.\r\n     *\r\n     *    @param [in] arrayValue  The selected array value.\r\n     *\r\n     *    @return True, if the array value is valid, otherwise false.\r\n     */\r\n    bool arrayValueIsValid(QString const& arrayValue) const;\r\n\r\n    /*!\r\n     *  Check if the port wire is valid.\r\n     *\r\n     *    @param [in] port    The selected port.\r\n     *\r\n     *    @return True, if the port wire is valid, otherwise false.\r\n     */\r\n    bool hasValidWire(QSharedPointer<Port> port) const;\r\n    bool hasValidDefaultValue(QSharedPointer<Port> port) const;\r\n\r\n    /*!\r\n     *  Check if the wire is valid.\r\n     *\r\n     *    @param [in] wire    The selected wire.\r\n     *\r\n     *    @return True, if the wire is valid, otherwise false.\r\n     */\r\n    bool wireHasValidDirection(QSharedPointer<Wire> wire) const;\r\n\r\n    /*!\r\n     *  Check if the wire port bound is valid.\r\n     *\r\n     *    @param [in] portBound   The selected port bound.\r\n     *\r\n     *    @return True, if the port bound is valid, otherwise false.\r\n     */\r\n    bool portBoundIsValid(QString const& portBound) const;\r\n\r\n    /*!\r\n     *  Check if the transactional port is valid.\r\n     *\r\n     *    @param [in] port    The selected port.\r\n     *\r\n     *    @return True, if the transactional port is valid, otherwise false.\r\n     */\r\n    bool hasValidTransactionalPort(QSharedPointer<Port> port) const;\r\n\r\n    /*!\r\n     *  Check if a transactional has a valid initiative.\r\n     *\r\n     *    @param [in] transactional   The selected transactional\r\n     *\r\n     *    @return True, if the initiative is valid, false otherwise.\r\n     */\r\n    bool hasValidTransactionalInitiative(QSharedPointer<Transactional> transactional) const;\r\n\r\n    /*!\r\n     *  Check if a transactional has a valid kind.\r\n     *\r\n     *    @param [in] transactional   The selected transactional\r\n     *\r\n     *    @return True, if the kind is valid, false otherwise.\r\n     */\r\n    bool hasValidTransactionalKind(QSharedPointer<Transactional> transactional) const;\r\n\r\n    /*!\r\n     *  Check if a transactional has a valid bus width.\r\n     *\r\n     *    @param [in] transactional   The selected transactional\r\n     *\r\n     *    @return True, if the bus width is valid, false otherwise.\r\n     */\r\n    bool hasValidTransactionalWidth(QSharedPointer<Transactional> transactional) const;\r\n\r\n    /*!\r\n     *  Check if a transactional has a valid value for maximum connections.\r\n     *\r\n     *    @param [in] transactional   The selected transactional\r\n     *\r\n     *    @return True, if the maximum connections value is valid, false otherwise.\r\n     */\r\n    bool hasValidTransactionalMaxConnections(QSharedPointer<Transactional> transactional) const;\r\n\r\n    /*!\r\n     *  Check if a transactional has a valid value for minimum connections.\r\n     *\r\n     *    @param [in] transactional   The selected transactional\r\n     *\r\n     *    @return True, if the minimum connections value is valid, false otherwise.\r\n     */\r\n    bool hasValidTransactionalMinConnections(QSharedPointer<Transactional> transactional) const;\r\n\r\n    /*!\r\n     *  Check if a transactional has a protocol.\r\n     *\r\n     *    @param [in] transactional   The selected transactional\r\n     *\r\n     *    @return True, if the protocol is valid, false otherwise.\r\n     */\r\n    bool hasValidTransactionalProtocol(QSharedPointer<Transactional> transactional) const;\r\n\r\n    /*!\r\n     *  Check if the port has valid type definitions.\r\n     *\r\n     *    @param [in] port    The selected port.\r\n     *\r\n     *    @return True, if the type definitions are valid, false otherwise.\r\n     */\r\n    bool hasValidTypes(QSharedPointer<Port> port) const;\r\n\r\n    /*!\r\n     *  Check if the selected type definitions are valid.\r\n     *\r\n     *    @param [in] typeDefinitions     The selected type definitions.\r\n     *\r\n     *    @return True, if the type definitions are valid, false otherwise.\r\n     */\r\n    bool hasValidTypeDefinitions(QSharedPointer<QList<QSharedPointer<WireTypeDef> > > typeDefinitions) const;\r\n\r\n    /*!\r\n     *  Finds possible errors in a Port and creates a list of them.\r\n     *\r\n     *    @param [in] errors      List of found errors.\r\n     *    @param [in] Port   The Port whose errors to find.\r\n     *    @param [in] context     Context to help locate the errors.\r\n     */\r\n    virtual void findErrorsIn(QVector<QString>& errors, QSharedPointer<Port> port, QString const& context) const;\r\n\r\n    /*!\r\n     *  Get the type definition validator.\r\n     *\r\n     *    @return The validator used for type definitions.\r\n     */\r\n    QSharedPointer<PortTypeValidator> getTypeValidator() const;\r\n\r\nprivate:\r\n\r\n\t// Disable copying.\r\n\tPortValidator(PortValidator const& rhs);\r\n\tPortValidator& operator=(PortValidator const& rhs);\r\n\r\n    /*!\r\n     *  Finds possible errors in a wire and creates a list of them.\r\n     *\r\n     *    @param [in] errors      List of found errors.\r\n     *    @param [in] port        The Port whose errors to find.\r\n     *    @param [in] context     Context to help locate the errors.\r\n     */\r\n    void findErrorsInWire(QVector<QString>& errors, QSharedPointer<Port> port, QString const& context) const;\r\n    \r\n    /*!\r\n     *  Finds possible errors in a transactional and creates a list of them.\r\n     *\r\n     *    @param [in] errors      List of found errors.\r\n     *    @param [in] port        The port whose errors to find.\r\n     *    @param [in] context     Context to help locate the errors.\r\n     */\r\n    void findErrorsInTransactional(QVector<QString> &errors, QSharedPointer<Port> port,\r\n        QString const& context) const;\r\n\r\n    /*!\r\n     *  Find possible errors in the selected type definitions.\r\n     *\r\n     *    @param [in] errors              List of found errors.\r\n     *    @param [in] typeDefinitions     The selected type definitions.\r\n     *    @param [in] context             Context to help locate the errors.\r\n     */\r\n    void findErrorsInTypeDefinitions(QVector<QString>& errors,\r\n        QSharedPointer<QList<QSharedPointer<WireTypeDef> > > typeDefinitions, QString const& context) const;\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! The used expression parser.\r\n    QSharedPointer<ExpressionParser> expressionParser_;\r\n\r\n    //! Validator for port type definitions.\r\n    QSharedPointer<PortTypeValidator> typeValidator_;\r\n};\r\n\r\n#endif // SYSTEMVERILOGVALIDATOR_H\r\n"
  },
  {
    "path": "IPXACTmodels/Component/validators/PowerDomainValidator.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: PowerDomainValidator.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Esko Pekkarinen\n// Date: 6.10.2023\n//\n// Description:\n// Validator for the ipxact:powerDomain.\n//-----------------------------------------------------------------------------\n\n#include \"PowerDomainValidator.h\"\n\n#include <KactusAPI/include/ExpressionParser.h>\n\n#include <IPXACTmodels/Component/PowerDomain.h>\n#include <IPXACTmodels/common/validators/ParameterValidator.h>\n#include <IPXACTmodels/common/validators/CommonItemsValidator.h>\n#include <IPXACTmodels/common/Parameter.h>\n\n#include <IPXACTmodels/utilities/Search.h>\n\n//-----------------------------------------------------------------------------\n// Function: PowerDomainValidator::PowerDomainValidator()\n//-----------------------------------------------------------------------------\nPowerDomainValidator::PowerDomainValidator(QSharedPointer<QList<QSharedPointer<PowerDomain> > > availableDomains,\n    QSharedPointer<ExpressionParser> expressionParser,\n    QSharedPointer<ParameterValidator> parameterValidator):\nHierarchicalValidator(),\navailableDomains_(availableDomains),\nexpressionParser_(expressionParser),\nparameterValidator_(parameterValidator)\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: PowerDomainValidator::~PowerDomainValidator()\n//-----------------------------------------------------------------------------\nPowerDomainValidator::~PowerDomainValidator()\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: PowerDomainValidator::validate()\n//-----------------------------------------------------------------------------\nbool PowerDomainValidator::validate(QSharedPointer<PowerDomain> powerDomain) const\n{\n    return hasValidName(powerDomain->name()) &&\n        hasValidAlwaysOn(powerDomain) &&\n        hasValidSubDomainOf(powerDomain) &&\n        hasValidParameters(powerDomain) &&\n        validComparedToSiblings(powerDomain);\n}\n\n//-----------------------------------------------------------------------------\n// Function: PowerDomainValidator::hasValidName()\n//-----------------------------------------------------------------------------\nbool PowerDomainValidator::hasValidName(QString const& name) const\n{\n    return CommonItemsValidator::hasValidName(name);\n}\n\n//-----------------------------------------------------------------------------\n// Function: PowerDomainValidator::hasValidAlwaysOn()\n//-----------------------------------------------------------------------------\nbool PowerDomainValidator::hasValidAlwaysOn(QSharedPointer<PowerDomain> powerDomain) const\n{\n    return CommonItemsValidator::hasValidIsPresent(powerDomain->getAlwaysOn(), expressionParser_);\n}\n\n//-----------------------------------------------------------------------------\n// Function: PowerDomainValidator::hasValidSubDomainOf()\n//-----------------------------------------------------------------------------\nbool PowerDomainValidator::hasValidSubDomainOf(QSharedPointer<PowerDomain> powerDomain) const\n{\n    if (powerDomain->getSubDomainOf().isEmpty())\n    {\n        return true;\n    }\n\n    auto referencedDomain = Search::findByName(powerDomain->getSubDomainOf(), *availableDomains_);\n\n    return referencedDomain.isNull() == false;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PowerDomainValidator::hasValidParameters()\n//-----------------------------------------------------------------------------\nbool PowerDomainValidator::hasValidParameters(QSharedPointer<PowerDomain> powerDomain) const\n{\n    if (!powerDomain->getParameters()->isEmpty())\n    {\n        QStringList parameterNames;\n        for (QSharedPointer<Parameter> const& parameter : *powerDomain->getParameters())\n        {\n            if (parameterNames.contains(parameter->name()) || !parameterValidator_->validate(parameter))\n            {\n                return false;\n            }\n            else\n            {\n                parameterNames.append(parameter->name());\n            }\n        }\n    }\n\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PowerDomainValidator::findErrorsIn()\n//-----------------------------------------------------------------------------\nvoid PowerDomainValidator::findErrorsIn(QVector<QString>& errors, QSharedPointer<PowerDomain> powerDomain,\n    QString const& context) const\n{\n    QString powerDomainContext = QStringLiteral(\"power domain \") + powerDomain->name();\n\n    findErrorsInName(errors, powerDomain, context);\n    findErrorsInAlwaysOn(errors, powerDomain, context);\n    findErrorsInSubDomainOf(errors, powerDomain, context);\n    findErrorsInParameters(errors, powerDomain, powerDomainContext);\n}\n\n//-----------------------------------------------------------------------------\n// Function: PowerDomainValidator::componentChange()\n//-----------------------------------------------------------------------------\nvoid PowerDomainValidator::componentChange(QSharedPointer<QList<QSharedPointer<PowerDomain>>> powerDomains)\n{\n    availableDomains_ = powerDomains;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PowerDomainValidator::findErrorsInName()\n//-----------------------------------------------------------------------------\nvoid PowerDomainValidator::findErrorsInName(QVector<QString>& errors, QSharedPointer<PowerDomain> powerDomain,\n    QString const& context) const\n{\n    if (!hasValidName(powerDomain->name()))\n    {\n        errors.append(QObject::tr(\"Invalid name specified for power domain %1 within %2\").arg(\n            powerDomain->name(), context));\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: PowerDomainValidator::findErrorsInAlwaysOn()\n//-----------------------------------------------------------------------------\nvoid PowerDomainValidator::findErrorsInAlwaysOn(QVector<QString>& errors, QSharedPointer<PowerDomain> powerDomain,\n    QString const& context) const\n{\n    if (!hasValidAlwaysOn(powerDomain))\n    {\n        errors.append(QObject::tr(\"Invalid expression set for always on in power domain %1 within %2\").arg(\n            powerDomain->name(), context));\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: PowerDomainValidator::findErrorsInSubDomainOf()\n//-----------------------------------------------------------------------------\nvoid PowerDomainValidator::findErrorsInSubDomainOf(QVector<QString>& errors, \n    QSharedPointer<PowerDomain> powerDomain, QString const& context) const\n{\n    if (!hasValidSubDomainOf(powerDomain))\n    {\n        errors.append(QObject::tr(\"Invalid power domain '%1' referenced in power domain %2 within %3\").arg(\n            powerDomain->getSubDomainOf(), powerDomain->name(), context));\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: PowerDomainValidator::findErrorsInParameters()\n//-----------------------------------------------------------------------------\nvoid PowerDomainValidator::findErrorsInParameters(QVector<QString>& errors,\n    QSharedPointer<PowerDomain> powerDomain, QString const& context) const\n{\n    if (!powerDomain->getParameters()->isEmpty())\n    {\n        QStringList parameterNames;\n        for (QSharedPointer<Parameter> const& parameter : *powerDomain->getParameters())\n        {\n            if (parameterNames.contains(parameter->name()))\n            {\n                errors.append(QObject::tr(\"Name %1 of parameters in %2 is not unique.\").arg(parameter->name(),\n                    context));\n            }\n            else\n            {\n                parameterNames.append(parameter->name());\n            }\n\n            parameterValidator_->findErrorsIn(errors, parameter, context);\n        }\n    }\n}\n"
  },
  {
    "path": "IPXACTmodels/Component/validators/PowerDomainValidator.h",
    "content": "//-----------------------------------------------------------------------------\n// File: PowerDomainValidator.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Esko Pekkarinen\n// Date: 6.10.2023\n//\n// Description:\n// Validator for the ipxact:powerDomain.\n//-----------------------------------------------------------------------------\n\n#ifndef POWERDOMAINVALIDTAOR_H\n#define POWERDOMAINVALIDTAOR_H\n\n#include <IPXACTmodels/ipxactmodels_global.h>\n\n#include <IPXACTmodels/common/validators/HierarchicalValidator.h>\n\n#include <QSharedPointer>\n#include <QString>\n\nclass ExpressionParser;\nclass PowerDomain;\nclass Segment;\nclass MemoryReserve;\n\nclass MemoryMapBaseValidator;\nclass ParameterValidator;\n\n//-----------------------------------------------------------------------------\n//! Validator for the ipxact:PowerDomain.\n//-----------------------------------------------------------------------------\nclass IPXACTMODELS_EXPORT PowerDomainValidator : public HierarchicalValidator\n{\npublic:\n\n\t/*!\n\t *  The constructor.\n\t *\n\t *    @param [in] expressionParser        The parser to use for solving expressions.\n     *    @param [in] parameterValidator      Validator used for parameters.\n\t */\n    PowerDomainValidator(QSharedPointer<QList<QSharedPointer<PowerDomain> > > availableDomains,\n        QSharedPointer<ExpressionParser> expressionParser,\n        QSharedPointer<ParameterValidator> parameterValidator);\n\n\t//! The destructor.\n\t~PowerDomainValidator();\n\n\t// Disable copying.\n\tPowerDomainValidator(PowerDomainValidator const& rhs) = delete;\n\tPowerDomainValidator& operator=(PowerDomainValidator const& rhs) = delete;\n\n    /*!\n     *  Validates the given power domain.\n     *\n     *    @param [in] powerDomain        The selected power domain to validate.\n     *\n     *    @return True, if the power domain is valid IP-XACT, otherwise false.\n     */\n    bool validate(QSharedPointer<PowerDomain> powerDomain) const;\n\n    /*!\n     *  Check if the name is valid.\n     *\n     *    @param [in] name    The selected name.\n     *\n     *    @return True, if the name is valid, otherwise false.\n     */\n    bool hasValidName(QString const& name) const;\n\n    /*!\n     *  Check if the always on expression is valid.\n     *\n     *    @param [in] name    The power domain to check.\n     *\n     *    @return True, if the expression is valid, otherwise false.\n     */\n    bool hasValidAlwaysOn(QSharedPointer<PowerDomain> powerDomain) const;\n\n    /*!\n     *  Check if the subdomain reference is valid.\n     *\n     *    @param [in] name    The power domain to check.\n     *\n     *    @return True, if the expression is valid, otherwise false.\n     */\n    bool hasValidSubDomainOf(QSharedPointer<PowerDomain> powerDomain) const;\n\n    /*!\n     *  Check if the power domain contains valid parameters.\n     *\n     *    @param [in] PowerDomain    The selected power domain.\n     *\n     *    @return True, if the parameters are valid, otherwise false.\n     */\n    bool hasValidParameters(QSharedPointer<PowerDomain> PowerDomain) const;\n\n    /*!\n     *  Locate errors within an power domain.\n     *\n     *    @param [in] errors          List of found errors.\n     *    @param [in] PowerDomain    The selected power domain.\n     *    @param [in] context         Context to help locate the error.\n     */\n    void findErrorsIn(QVector<QString>& errors, QSharedPointer<PowerDomain> PowerDomain,\n        QString const& context) const;\n\n    /*!\n     *  Change the available power domains.\n     *\n     *    @param [in] powerDomains    The new available power domains.\n     */\n    void componentChange(QSharedPointer<QList<QSharedPointer<PowerDomain> > > powerDomains);\n\nprivate:\n\n    /*!\n     *  Find errors within power domain name.\n     *\n     *    @param [in] errors          List of found errors.\n     *    @param [in] powerDomain     The selected power domain.\n     *    @param [in] context         Context to help locate the error.\n     */\n    void findErrorsInName(QVector<QString>& errors, QSharedPointer<PowerDomain> PowerDomain,\n        QString const& context) const;\n        \n    /*!\n     *  Find errors within always on expression.\n     *\n     *    @param [in] errors          List of found errors.\n     *    @param [in] powerDomain     The selected power domain.\n     *    @param [in] context         Context to help locate the error.\n     */\n    void findErrorsInAlwaysOn(QVector<QString>& errors, QSharedPointer<PowerDomain> powerDomain, \n        QString const& context) const;\n\n    /*!\n     *  Find errors within sub domain reference.\n     *\n     *    @param [in] errors          List of found errors.\n     *    @param [in] powerDomain     The selected power domain.\n     *    @param [in] context         Context to help locate the error.\n     */\n    void findErrorsInSubDomainOf(QVector<QString>& errors, QSharedPointer<PowerDomain> powerDomain,\n        QString const& context) const;\n\n    /*!\n     *  Find errors within power domain parameters.\n     *\n     *    @param [in] errors          List of found errors.\n     *    @param [in] PowerDomain    The selected power domain.\n     *    @param [in] context         Context to help locate the error.\n     */\n    void findErrorsInParameters(QVector<QString>& errors, QSharedPointer<PowerDomain> PowerDomain,\n        QString const& context) const;\n\n    //-----------------------------------------------------------------------------\n    // Data.\n    //-----------------------------------------------------------------------------\n\n    //! The available power domains.\n    QSharedPointer<QList<QSharedPointer<PowerDomain> > > availableDomains_;\n\n    //! The expression parser to use.\n    QSharedPointer<ExpressionParser> expressionParser_;\n\n    //! The validator used for parameters.\n    QSharedPointer<ParameterValidator> parameterValidator_;\n\n};\n\n#endif // POWERDOMAINVALIDTAOR_H\n"
  },
  {
    "path": "IPXACTmodels/Component/validators/RegionValidator.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: RegionValidator.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Esko Pekkarinen\n// Date: 21.6.2023\n//\n// Description:\n// Validator for the ipxact:region.\n//-----------------------------------------------------------------------------\n\n#include \"RegionValidator.h\"\n\n#include <KactusAPI/include/ExpressionParser.h>\n\n#include <IPXACTmodels/Component/validators/MemoryReserve.h>\n#include <IPXACTmodels/Component/validators/MemoryMapBaseValidator.h>\n#include <IPXACTmodels/Component/Region.h>\n#include <IPXACTmodels/Component/Segment.h>\n\n#include <IPXACTmodels/common/validators/CommonItemsValidator.h>\n#include <IPXACTmodels/common/validators/ParameterValidator.h>\n#include <IPXACTmodels/common/Parameter.h>\n\n#include <QRegularExpression>\n\n//-----------------------------------------------------------------------------\n// Function: RegionValidator::RegionValidator()\n//-----------------------------------------------------------------------------\nRegionValidator::RegionValidator(QSharedPointer<ExpressionParser> expressionParser):\nexpressionParser_(expressionParser)\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: RegionValidator::validate()\n//-----------------------------------------------------------------------------\nbool RegionValidator::validate(QSharedPointer<Region> region) const\n{\n    return hasValidName(region->name()) &&  hasValidRange(region) && hasValidAddressOffset(region);\n}\n\n//-----------------------------------------------------------------------------\n// Function: RegionValidator::hasValidName()\n//-----------------------------------------------------------------------------\nbool RegionValidator::hasValidName(QString const& name) const\n{\n    return CommonItemsValidator::hasValidName(name);\n}\n\n//-----------------------------------------------------------------------------\n// Function: RegionValidator::hasValidRange()\n//-----------------------------------------------------------------------------\nbool RegionValidator::hasValidRange(QSharedPointer<Region> region) const\n{\n    if (!region->getRange().isEmpty())\n    {\n        bool rangeOk = true;\n        bool expressionValid = false;\n        quint64 range =\n            expressionParser_->parseExpression(region->getRange(), &expressionValid).toULongLong(&rangeOk);\n\n        return rangeOk && expressionValid && range != 0;\n    }\n\n    return false;\n}\n\n//-----------------------------------------------------------------------------\n// Function: RegionValidator::hasValidAddressOffset()\n//-----------------------------------------------------------------------------\nbool RegionValidator::hasValidAddressOffset(QSharedPointer<Region> region) const\n{\n    if (!region->getAddressOffset().isEmpty())\n    {\n        bool offsetOk = true;\n        expressionParser_->parseExpression(region->getAddressOffset()).toULongLong(&offsetOk);\n\n        return offsetOk;\n    }\n\n    return false;\n}\n\n//-----------------------------------------------------------------------------\n// Function: RegionValidator::findErrorsIn()\n//-----------------------------------------------------------------------------\nvoid RegionValidator::findErrorsIn(QVector<QString>& errors, QSharedPointer<Region> region,\n    QString const& context) const\n{\n    findErrorsInName(errors, region, context);\n    findErrorsInRange(errors, region, context);\n    findErrorsInOffset(errors, region, context);\n}\n\n//-----------------------------------------------------------------------------\n// Function: RegionValidator::findErrorsInName()\n//-----------------------------------------------------------------------------\nvoid RegionValidator::findErrorsInName(QVector<QString>& errors, QSharedPointer<Region> region,\n    QString const& context) const\n{\n    if (!hasValidName(region->name()))\n    {\n        errors.append(QObject::tr(\"Invalid name specified for region %1 in %2.\").arg(region->name(), context));\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: RegionValidator::findErrorsInRange()\n//-----------------------------------------------------------------------------\nvoid RegionValidator::findErrorsInRange(QVector<QString>& errors, QSharedPointer<Region> region,\n    QString const& context) const\n{\n    if (!hasValidRange(region))\n    {\n        errors.append(QObject::tr(\"Invalid range set for region %1 in %2.\").arg(region->name(), context));\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: RegionValidator::findErrorsInOffset()\n//-----------------------------------------------------------------------------\nvoid RegionValidator::findErrorsInOffset(QVector<QString>& errors, QSharedPointer<Region> region,\n    QString const& context) const\n{\n    if (!hasValidAddressOffset(region))\n    {\n        errors.append(QObject::tr(\"Invalid address offset set for region %1 in %2.\").arg(region->name(), context));\n    }\n}\n"
  },
  {
    "path": "IPXACTmodels/Component/validators/RegionValidator.h",
    "content": "//-----------------------------------------------------------------------------\n// File: RegionValidator.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Esko Pekkarinen\n// Date: 21.6.2023\n//\n// Description:\n// Validator for the ipxact:region.\n//-----------------------------------------------------------------------------\n\n#ifndef RegionVALIDATOR_H\n#define RegionVALIDATOR_H\n\n#include <IPXACTmodels/ipxactmodels_global.h>\n\n#include <QSharedPointer>\n#include <QString>\n\nclass ExpressionParser;\nclass Region;\nclass Segment;\nclass MemoryReserve;\n\nclass MemoryMapBaseValidator;\nclass ParameterValidator;\n//-----------------------------------------------------------------------------\n//! Validator for the ipxact:region.\n//-----------------------------------------------------------------------------\nclass IPXACTMODELS_EXPORT RegionValidator\n{\npublic:\n\n\t/*!\n\t *  The constructor.\n\t *\n\t *    @param [in] expressionParser        The parser to use for solving expressions.\n\t */\n    RegionValidator(QSharedPointer<ExpressionParser> expressionParser);\n\n\t//! The destructor.\n\t~RegionValidator() = default;\n\n    // Disable copying.\n    RegionValidator(RegionValidator const& rhs) = delete;\n    RegionValidator& operator=(RegionValidator const& rhs) = delete;\n\n    /*!\n     *  Validates the given address region.\n     *\n     *    @param [in] Region        The selected address region.\n     *\n     *    @return True, if the address region is valid IP-XACT, otherwise false.\n     */\n    bool validate(QSharedPointer<Region> region) const;\n\n    /*!\n     *  Check if the name is valid.\n     *\n     *    @param [in] name    The selected name.\n     *\n     *    @return True, if the name is valid, otherwise false.\n     */\n    bool hasValidName(QString const& name) const;\n\n    /*!\n     *  Check if the address region contains a valid range.\n     *\n     *    @param [in] Region    The selected address region.\n     *\n     *    @return True, if the range is valid, otherwise false.\n     */\n    bool hasValidRange(QSharedPointer<Region> region) const;\n\n    /*!\n     *  Check if the address region contains a valid address offset.\n     *\n     *    @param [in] Region    The selected address region.\n     *\n     *    @return True, if the address offset is valid, otherwise false.\n     */\n    bool hasValidAddressOffset(QSharedPointer<Region> region) const;\n\n    /*!\n     *  Locate errors within an address region.\n     *\n     *    @param [in] errors          List of found errors.\n     *    @param [in] region          The selected region.\n     *    @param [in] context         Context to help locate the error.\n     */\n    void findErrorsIn(QVector<QString>& errors, QSharedPointer<Region> region,\n        QString const& context) const;\n\nprivate:\n\n    /*!\n     *  Find errors within address region name.\n     *\n     *    @param [in] errors          List of found errors.\n     *    @param [in] region          The selected address region.\n     *    @param [in] context         Context to help locate the error.\n     */\n    void findErrorsInName(QVector<QString>& errors, QSharedPointer<Region> region,\n        QString const& context) const;\n\n    /*!\n     *  Find errors within address space range.\n     *\n     *    @param [in] errors          List of found errors.\n     *    @param [in] region          The selected address region.\n     *    @param [in] context         Context to help locate the error.\n     */\n    void findErrorsInRange(QVector<QString>& errors, QSharedPointer<Region> region,\n        QString const& context) const;\n\n    /*!\n     *  Find errors within address space offset.\n     *\n     *    @param [in] errors          List of found errors.\n     *    @param [in] region          The selected address region.\n     *    @param [in] context         Context to help locate the error.\n     */\n    void findErrorsInOffset(QVector<QString>& errors, QSharedPointer<Region> region,\n        QString const& context) const;\n\n    //-----------------------------------------------------------------------------\n    // Data.\n    //-----------------------------------------------------------------------------\n\n    //! The expression parser to use.\n    QSharedPointer<ExpressionParser> expressionParser_;\n};\n\n#endif // RegionVALIDATOR_H\n"
  },
  {
    "path": "IPXACTmodels/Component/validators/RegisterBaseValidator.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: RegisterBaseValidator.h\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Mikko Teuho\n// Date: 19.11.2015\n//\n// Description:\n// Validator for ipxact:Register.\n//-----------------------------------------------------------------------------\n\n#include \"RegisterBaseValidator.h\"\n\n#include <KactusAPI/include/ExpressionParser.h>\n\n#include <IPXACTmodels/common/validators/ParameterValidator.h>\n#include <IPXACTmodels/common/validators/CommonItemsValidator.h>\n#include <IPXACTmodels/common/Parameter.h>\n\n#include <IPXACTmodels/Component/RegisterBase.h>\n#include <IPXACTmodels/Component/AccessPolicy.h>\n#include <IPXACTmodels/Component/Mode.h>\n\n#include <QRegularExpression>\n\n//-----------------------------------------------------------------------------\n// Function: RegisterBaseValidator::RegisterBaseValidator()\n//-----------------------------------------------------------------------------\nRegisterBaseValidator::RegisterBaseValidator(QSharedPointer<ExpressionParser> expressionParser,\n    QSharedPointer<ParameterValidator> parameterValidator,\n    Document::Revision docRevision) :\nHierarchicalValidator(),\nexpressionParser_(expressionParser),\nparameterValidator_(parameterValidator),\ndocRevision_(docRevision),\nmemArrayValidator_(expressionParser)\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: RegisterBaseValidator::validate()\n//-----------------------------------------------------------------------------\nbool RegisterBaseValidator::validate(QSharedPointer<RegisterBase> selectedRegisterBase) const\n{\n    if (docRevision_ == Document::Revision::Std14)\n    {\n        return hasValidName(selectedRegisterBase) &&\n            hasValidIsPresent(selectedRegisterBase) &&\n            hasValidDimensions(selectedRegisterBase) &&\n            hasValidAddressOffset(selectedRegisterBase) &&\n            hasValidParameters(selectedRegisterBase) &&\n            validComparedToSiblings(selectedRegisterBase);\n    }\n    else if (docRevision_ == Document::Revision::Std22)\n    {\n        return hasValidName(selectedRegisterBase) &&\n            hasValidAddressOffset(selectedRegisterBase) &&\n            hasValidMemoryArray(selectedRegisterBase) &&\n            hasValidAccessPolicies(selectedRegisterBase) &&\n            hasValidParameters(selectedRegisterBase) &&\n            validComparedToSiblings(selectedRegisterBase);\n    }\n\n    return false;\n}\n\n//-----------------------------------------------------------------------------\n// Function: RegisterBaseValidator::hasValidName()\n//-----------------------------------------------------------------------------\nbool RegisterBaseValidator::hasValidName(QSharedPointer<RegisterBase> selectedRegisterBase) const\n{\n    return CommonItemsValidator::hasValidName(selectedRegisterBase->name());\n}\n\n//-----------------------------------------------------------------------------\n// Function: RegisterBaseValidator::hasValidIsPresent()\n//-----------------------------------------------------------------------------\nbool RegisterBaseValidator::hasValidIsPresent(QSharedPointer<RegisterBase> selectedRegisterBase) const\n{\n    if (!selectedRegisterBase->getIsPresent().isEmpty())\n    {\n        QString solvedValue = expressionParser_->parseExpression(selectedRegisterBase->getIsPresent());\n\n        bool toIntOk = true;\n        int intValue = solvedValue.toInt(&toIntOk);\n\n        if (!toIntOk || intValue < 0 || intValue > 1)\n        {\n            return false;\n        }\n    }\n\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: RegisterBaseValidator::hasValidDimension()\n//-----------------------------------------------------------------------------\nbool RegisterBaseValidator::hasValidDimensions(QSharedPointer<RegisterBase> selectedRegisterBase) const\n{\n    return memArrayValidator_.hasValidDimensions(selectedRegisterBase->getMemoryArray());\n}\n\n//-----------------------------------------------------------------------------\n// Function: RegisterBaseValidator::hasValidAddressOffset()\n//-----------------------------------------------------------------------------\nbool RegisterBaseValidator::hasValidAddressOffset(QSharedPointer<RegisterBase> selectedRegisterBase) const\n{\n    bool changeOk = true;\n    bool expressionValid = false;\n\n    QString solvedValue =\n        expressionParser_->parseExpression(selectedRegisterBase->getAddressOffset(), &expressionValid);\n    [[maybe_unused]] quint64 offsetInt = solvedValue.toULongLong(&changeOk);\n\n    return changeOk && expressionValid;\n}\n\n//-----------------------------------------------------------------------------\n// Function: RegisterBaseValidator::hasValidParameters()\n//-----------------------------------------------------------------------------\nbool RegisterBaseValidator::hasValidParameters(QSharedPointer<RegisterBase> selectedRegisterBase) const\n{\n    if (!selectedRegisterBase->getParameters()->isEmpty())\n    {\n        QStringList parameterNames;\n        for (QSharedPointer<Parameter> parameter : *selectedRegisterBase->getParameters())\n        {\n            if (parameterNames.contains(parameter->name()) || !parameterValidator_->validate(parameter))\n            {\n                return false;\n            }\n            else\n            {\n                parameterNames.append(parameter->name());\n            }\n        }\n    }\n\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: RegisterBaseValidator::hasValidAccessPolicies()\n//-----------------------------------------------------------------------------\nbool RegisterBaseValidator::hasValidAccessPolicies(QSharedPointer<RegisterBase> registerBase) const\n{\n    return CommonItemsValidator::hasValidAccessPolicies(registerBase->getAccessPolicies(), componentModes_);\n}\n\n//-----------------------------------------------------------------------------\n// Function: RegisterBaseValidator::hasValidMemoryArray()\n//-----------------------------------------------------------------------------\nbool RegisterBaseValidator::hasValidMemoryArray(QSharedPointer<RegisterBase> registerBase) const\n{\n    if (!registerBase->getMemoryArray())\n    {\n        return true;\n    }\n\n    return memArrayValidator_.validate(registerBase->getMemoryArray());\n}\n\n//-----------------------------------------------------------------------------\n// Function: RegisterBaseValidator::findErrorsInName()\n//-----------------------------------------------------------------------------\nvoid RegisterBaseValidator::findErrorsInName(QVector<QString>& errors,\n                                             QSharedPointer<RegisterBase> selectedRegisterBase,\n                                             QString const& context) const\n{\n    if (!hasValidName(selectedRegisterBase))\n    {\n        errors.append(\n            QObject::tr(\"Invalid name specified for %1\").arg(context));\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: RegisterBaseValidator::findErrorsInIsPresent()\n//-----------------------------------------------------------------------------\nvoid RegisterBaseValidator::findErrorsInIsPresent(QVector<QString>& errors,\n                                                  QSharedPointer<RegisterBase> selectedRegisterBase,\n                                                  QString const& context) const\n{\n    if (!hasValidIsPresent(selectedRegisterBase))\n    {\n        errors.append(QObject::tr(\"Invalid isPresent set for %1\").arg(context));\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: RegisterBaseValidator::findErrorsInDimension()\n//-----------------------------------------------------------------------------\nvoid RegisterBaseValidator::findErrorsInDimension(QVector<QString>& errors,\n                                                  QSharedPointer<RegisterBase> selectedRegisterBase,\n                                                  QString const& context) const\n{\n    if (!hasValidDimensions(selectedRegisterBase))\n    {\n        errors.append(QObject::tr(\"Invalid dimensions set for %1\").arg(context));\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: RegisterBaseValidator::findErrorsInAddressOffset()\n//-----------------------------------------------------------------------------\nvoid RegisterBaseValidator::findErrorsInAddressOffset(QVector<QString>& errors,\n                                                      QSharedPointer<RegisterBase> selectedRegisterBase,\n                                                      QString const& context) const\n{\n    if (!hasValidAddressOffset(selectedRegisterBase))\n    {\n        errors.append(QObject::tr(\"Invalid address offset set for %1\").arg(context));\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: RegisterBaseValidator::findErrorsInParameters()\n//-----------------------------------------------------------------------------\nvoid RegisterBaseValidator::findErrorsInParameters(QVector<QString>&errors,\n                                                   QSharedPointer<RegisterBase> selectedRegisterBase,\n                                                   QString const& context) const\n{\n    if (!selectedRegisterBase->getParameters()->isEmpty())\n    {\n        QStringList parameterNames;\n        for (QSharedPointer<Parameter> parameter : *selectedRegisterBase->getParameters())\n        {\n            if (parameterNames.contains(parameter->name()))\n            {\n                errors.append(QObject::tr(\"Name %1 of parameters in %2 is not unique.\").arg(parameter->name(),\n                    context));\n            }\n            else\n            {\n                parameterNames.append(parameter->name());\n            }\n\n            parameterValidator_->findErrorsIn(errors, parameter, context);\n        }\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: RegisterBaseValidator::findErrorsInAccessPolicies()\n//-----------------------------------------------------------------------------\nvoid RegisterBaseValidator::findErrorsInAccessPolicies(QStringList& errors, QSharedPointer<RegisterBase> registerBase, QString const& context) const\n{\n    CommonItemsValidator::findErrorsInAccessPolicies(errors, registerBase->getAccessPolicies(), componentModes_, context);\n}\n\n//-----------------------------------------------------------------------------\n// Function: RegisterBaseValidator::findErrorsInMemoryArray()\n//-----------------------------------------------------------------------------\nvoid RegisterBaseValidator::findErrorsInMemoryArray(QStringList& errors, QSharedPointer<RegisterBase> registerBase,\n    QString const& context) const\n{\n    if (auto const& memArray = registerBase->getMemoryArray())\n    {\n        memArrayValidator_.findErrorsIn(errors, memArray, context);\n    }\n}\n"
  },
  {
    "path": "IPXACTmodels/Component/validators/RegisterBaseValidator.h",
    "content": "//-----------------------------------------------------------------------------\n// File: RegisterBaseValidator.h\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Mikko Teuho\n// Date: 19.11.2015\n//\n// Description:\n// Validator for ipxact:Register.\n//-----------------------------------------------------------------------------\n\n#ifndef RegisterBaseValidator_H\n#define RegisterBaseValidator_H\n\n#include <IPXACTmodels/ipxactmodels_global.h>\n\n#include <IPXACTmodels/common/Document.h>\n\n#include <IPXACTmodels/Component/validators/MemoryArrayValidator.h>\n#include <IPXACTmodels/common/validators/HierarchicalValidator.h>\n\n#include <QSharedPointer>\n#include <QString>\n\nclass ExpressionParser;\nclass RegisterBase;\nclass RegisterDefinition;\nclass Register;\nclass AlternateRegister;\nclass Choice;\nclass Field;\nclass FieldValidator;\nclass ParameterValidator;\nclass ModeReference;\nclass Mode;\n\n//-----------------------------------------------------------------------------\n//! Validator for ipxact:Register.\n//-----------------------------------------------------------------------------\nclass IPXACTMODELS_EXPORT RegisterBaseValidator : public HierarchicalValidator\n{\npublic:\n\n    /*!\n     *  The constructor.\n     *\n     *    @param [in] expressionParser    The parser to use for solving expressions.\n     *    @param [in] parameterValidator  Validator used for parameters.\n     */\n    RegisterBaseValidator(QSharedPointer<ExpressionParser> expressionParser,\n        QSharedPointer<ParameterValidator> parameterValidator,\n        Document::Revision docRevision);\n\n    //! The destructor.\n    virtual ~RegisterBaseValidator() = default;\n\n    // Disable copying.\n    RegisterBaseValidator(RegisterBaseValidator const& rhs) = delete;\n    RegisterBaseValidator& operator=(RegisterBaseValidator const& rhs) = delete;\n\n    /*!\n     *  Validates the given register.\n     *\n     *    @param [in] selectedRegisterBase    The register to validate.\n     *\n     *    @return True, if the register is valid IP-XACT, otherwise false.\n     */\n    virtual bool validate(QSharedPointer<RegisterBase> selectedRegisterBase) const;\n\n    /*!\n     *  Check if the register contains a valid name.\n     *\n     *    @param [in] selectedRegisterBase    The selected register base.\n     *\n     *    @return True, if the name is valid, otherwise false.\n     */\n    bool hasValidName(QSharedPointer<RegisterBase> selectedRegisterBase) const;\n\n    /*!\n     *  Check if the register contains a valid isPresent value.\n     *\n     *    @param [in] selectedRegisterBase    The selected register base.\n     *\n     *    @return True, if the isPresent is valid, otherwise false.\n     */\n    bool hasValidIsPresent(QSharedPointer<RegisterBase> selectedRegisterBase) const;\n\n    /*!\n     *  Check if the register contains a valid dimension value.\n     *\n     *    @param [in] selectedRegisterBase    The selected register.\n     *\n     *    @return True, if the dimension is valid, otherwise false.\n     */\n    bool hasValidDimensions(QSharedPointer<RegisterBase> selectedRegisterBase) const;\n\n    /*!\n     *  Check if the register contains a valid address offset.\n     *\n     *    @param [in] selectedRegisterBase    The selected register.\n     *\n     *    @return True, if the address offset is valid, otherwise false.\n     */\n    bool hasValidAddressOffset(QSharedPointer<RegisterBase> selectedRegisterBase) const;\n\n    /*!\n     *  Check if the register contains valid parameters.\n     *\n     *    @param [in] selectedRegisterBase    The selected register base.\n     *\n     *    @return True, if the parameters are valid, otherwise false.\n     */\n    bool hasValidParameters(QSharedPointer<RegisterBase> selectedRegisterBase) const;\n\n    /*!\n     *\tCheck if the register has valid access policies (or rather the mode references of the access policies).\n     *  \n     *    @param [in] registerBase     The register base to check\n     *\t    \n     * \t    @return True, if the access policies are valid, otherwise false.\n     */\n    bool hasValidAccessPolicies(QSharedPointer<RegisterBase> registerBase) const;\n\n    /*!\n     *\tValidate the memory array of a selected register.\n     *\n     *    @param [in] registerBase     The register base to check.\n     *\n     * \t    @return True, if valid, otherwise false.\n     */\n    bool hasValidMemoryArray(QSharedPointer<RegisterBase> registerBase) const;\n\nprotected:\n    /*!\n     *  Find errors within a name.\n     *\n     *    @param [in] errors              List of found errors.\n     *    @param [in] selectedRegisterBase    The selected register.\n     *    @param [in] context             Context to help locate the error.\n     */\n    void findErrorsInName(QVector<QString>& errors, QSharedPointer<RegisterBase> selectedRegisterBase,\n        QString const& context) const;\n\n    /*!\n     *  Find errors within is present value.\n     *\n     *    @param [in] errors              List of found errors.\n     *    @param [in] selectedRegisterBase    The selected register.\n     *    @param [in] context             Context to help locate the error.\n     */\n    void findErrorsInIsPresent(QVector<QString>& errors, QSharedPointer<RegisterBase> selectedRegisterBase,\n        QString const& context) const;\n\n    /*!\n     *  Find errors within dimension.\n     *\n     *    @param [in] errors              List of found errors.\n     *    @param [in] selectedRegisterBase    The selected register.\n     *    @param [in] context             Context to help locate the error.\n     */\n    void findErrorsInDimension(QVector<QString>& errors, QSharedPointer<RegisterBase> selectedRegisterBase,\n        QString const& context) const;\n\n    /*!\n     *  Find errors within address offset.\n     *\n     *    @param [in] errors              List of found errors.\n     *    @param [in] selectedRegisterBase    The selected register.\n     *    @param [in] context             Context to help locate the error.\n     */\n    void findErrorsInAddressOffset(QVector<QString>& errors, QSharedPointer<RegisterBase> selectedRegisterBase,\n        QString const& context) const;\n    /*!\n     *  Find errors within Parameters.\n     *\n     *    @param [in] errors              List of found errors.\n     *    @param [in] selectedRegisterBase    The selected register.\n     *    @param [in] context             Context to help locate the error.\n     */\n    void findErrorsInParameters(QVector<QString>&errors,\n        QSharedPointer<RegisterBase> selectedRegisterBase, QString const& context) const;\n\n    /*!\n     *\tFind errors in the access policies of the selected register.\n     *  \n     *    @param [in] errors                  List of found errors.\n     *    @param [in] selectedRegisterBase    The selected register.\n     *    @param [in] context                 Context to help locate the error.\n     */\n    void findErrorsInAccessPolicies(QStringList& errors, QSharedPointer<RegisterBase> registerBase,\n        QString const& context) const;\n\n    /*!\n     *  Find errors within memory array.\n     *\n     *    @param [in] errors              List of found errors.\n     *    @param [in] registerBase        The selected register base.\n     *    @param [in] context             Context to help locate the error.\n     */\n    void findErrorsInMemoryArray(QStringList& errors, QSharedPointer<RegisterBase> registerBase,\n        QString const& context) const;\n\n    //-----------------------------------------------------------------------------\n    // Data.\n    //-----------------------------------------------------------------------------\n\n    //! The expression parser to use.\n    QSharedPointer<ExpressionParser> expressionParser_;\n\n    //! The validator used for parameters.\n    QSharedPointer<ParameterValidator> parameterValidator_;\n\n    //! The IP-XACT standard revision in use.\n    Document::Revision docRevision_;\n\n    //! The memory array validator.\n    MemoryArrayValidator memArrayValidator_;\n\n    //! Available component modes.\n    QSharedPointer<QList<QSharedPointer<Mode> > > componentModes_;\n};\n\n#endif // RegisterBaseValidator_H\n"
  },
  {
    "path": "IPXACTmodels/Component/validators/RegisterFileValidator.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: RegisterFileValidator.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Dan Chianucci\n// Date: 04.06.2018\n//\n// Description:\n// Validator for ipxact:RegisterFile.\n//-----------------------------------------------------------------------------\n\n#include \"RegisterFileValidator.h\"\n#include <KactusAPI/include/ExpressionParser.h>\n#include <IPXACTmodels/Component/validators/RegisterValidator.h>\n#include <IPXACTmodels/Component/validators/MemoryArrayValidator.h>\n#include <IPXACTmodels/Component/validators/EnumeratedValueValidator.h>\n#include <IPXACTmodels/Component/validators/FieldValidator.h>\n#include <IPXACTmodels/common/validators/ParameterValidator.h>\n\n#include <IPXACTmodels/Component/RegisterBase.h>\n#include <IPXACTmodels/Component/RegisterFile.h>\n#include <IPXACTmodels/Component/Register.h>\n#include <IPXACTmodels/Component/MemoryArray.h>\n#include <IPXACTmodels/Component/Component.h>\n#include <QRegularExpression>\n\n//-----------------------------------------------------------------------------\n// Function: RegisterFileValidator::RegisterFileValidator()\n//-----------------------------------------------------------------------------\nRegisterFileValidator::RegisterFileValidator(QSharedPointer<ExpressionParser> expressionParser,\n    QSharedPointer<RegisterValidator> registerValidator,\n    QSharedPointer<ParameterValidator> parameterValidator,\n    Document::Revision docRevision) :\n    RegisterBaseValidator(expressionParser, parameterValidator, docRevision),\n    registerValidator_(registerValidator)\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: RegisterFileValidator::getRegisterValidator()\n//-----------------------------------------------------------------------------\nQSharedPointer<RegisterValidator> RegisterFileValidator::getRegisterValidator() const\n{\n    return registerValidator_;\n}\n\n//-----------------------------------------------------------------------------\n// Function: RegisterFileValidator::componentChange()\n//-----------------------------------------------------------------------------\nvoid RegisterFileValidator::componentChange(QSharedPointer<Component> newComponent)\n{\n    if (newComponent)\n    {\n        docRevision_ = newComponent->getRevision();\n        componentModes_ = newComponent->getModes();\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: RegisterFileValidator::validate()\n//-----------------------------------------------------------------------------\nbool RegisterFileValidator::validate(QSharedPointer<RegisterFile> selectedRegisterFile, QString const& addressUnitBits, QString const& addressBlockWidth)\n{\n    if (docRevision_ == Document::Revision::Std14)\n    {\n        return hasValidRange(selectedRegisterFile) &&\n            hasValidRegisterData(selectedRegisterFile, addressUnitBits, addressBlockWidth) &&\n            RegisterBaseValidator::validate(selectedRegisterFile);\n    }\n    else if (docRevision_ == Document::Revision::Std22)\n    {\n        return hasValidRange(selectedRegisterFile) &&\n            hasValidRegisterData(selectedRegisterFile, addressUnitBits, addressBlockWidth) &&\n            hasValidAccessPolicies(selectedRegisterFile) &&\n            RegisterBaseValidator::validate(selectedRegisterFile) &&\n            hasValidStructure(selectedRegisterFile);\n    }\n\n    return false;\n}\n\n//-----------------------------------------------------------------------------\n// Function: RegisterFileValidator::hasValidSize()\n//-----------------------------------------------------------------------------\nbool RegisterFileValidator::hasValidRange(QSharedPointer<RegisterFile> selectedRegisterFile) const\n{\n    bool toIntOk = true;\n    quint64 range = expressionParser_->parseExpression(selectedRegisterFile->getRange()).toULongLong(&toIntOk);\n\n    return toIntOk && range > 0;\n}\n\n//-----------------------------------------------------------------------------\n// Function: RegisterFileValidator::hasValidRegisterData()\n//-----------------------------------------------------------------------------\nbool RegisterFileValidator::hasValidRegisterData(QSharedPointer<RegisterFile> selectedRegisterFile, QString const& addressUnitBits, QString const& addressBlockWidth)\n{\n    if (selectedRegisterFile->getRegisterData()->isEmpty())\n    {\n        return true;\n    }\n\n    QMultiHash<QString, QSharedPointer<RegisterBase> > foundNames;\n\n    bool aubChangeOk = true;\n    qint64 aubInt = expressionParser_->parseExpression(addressUnitBits).toLongLong(&aubChangeOk);\n    qint64 registerFileRangeInt = getTrueRegisterFileRange(selectedRegisterFile);\n\n    auto registerDataCopy = QSharedPointer<QList<QSharedPointer<RegisterBase> > >(new QList(*selectedRegisterFile->getRegisterData()));\n\n    bool registerDataIsValid = true;\n\n    // Sort registers and register files by address offset\n    auto sortByAddressOffset = [&](QSharedPointer<RegisterBase> registerBaseA, QSharedPointer<RegisterBase> registerBaseB)\n        {\n            return expressionParser_->parseExpression(registerBaseA->getAddressOffset()).toLongLong() <\n                expressionParser_->parseExpression(registerBaseB->getAddressOffset()).toLongLong();\n        };\n\n    std::sort(registerDataCopy->begin(), registerDataCopy->end(), sortByAddressOffset);\n\n    qint64 lastRangeEnd = -1;\n\n    bool previousWasRegister = false;\n\n    for (auto regIter = registerDataCopy->begin(); regIter != registerDataCopy->end(); ++regIter)\n    {\n        if (auto asRegister = regIter->dynamicCast<Register>())\n        {\n            if (!foundNames.contains(asRegister->name()))\n            {\n                registerValidator_->setChildItemValidity(asRegister, true);\n            }\n\n            foundNames.insert(asRegister->name(), asRegister);\n\n            qint64 registerSize = getRegisterSizeInLAU(asRegister, aubInt);\n            qint64 blockWidth = expressionParser_->parseExpression(addressBlockWidth).toLongLong();\n\n            if (registerSize > blockWidth)\n            {\n                registerValidator_->setChildItemValidity(asRegister, false);\n                registerDataIsValid = false;\n            }\n\n            if (aubChangeOk && aubInt != 0 &&\n                markRegisterOverlap(regIter, lastRangeEnd, registerFileRangeInt, aubInt, true, previousWasRegister))\n            {\n                registerDataIsValid = false;\n            }\n\n            previousWasRegister = true;\n        }\n        else if (auto asRegisterFile = regIter->dynamicCast<RegisterFile>())\n        {\n            if (!foundNames.contains(asRegisterFile->name()))\n            {\n                setChildItemValidity(asRegisterFile, true);\n            }\n\n            foundNames.insert(asRegisterFile->name(), asRegisterFile);\n\n            if (aubChangeOk && aubInt != 0 &&\n                markRegisterOverlap(regIter, lastRangeEnd, registerFileRangeInt, aubInt, false, previousWasRegister))\n            {\n                registerDataIsValid = false;\n            }\n\n            previousWasRegister = false;\n        }\n    }\n\n    // Mark registers and register files with duplicate names as invalid.\n    for (auto const& name : foundNames.keys())\n    {\n        if (auto const& duplicateNames = foundNames.values(name);\n            duplicateNames.count() > 1)\n        {\n            std::for_each(duplicateNames.begin(), duplicateNames.end(),\n                [this](QSharedPointer<RegisterBase> registerBase)\n                {\n                    if (registerBase.dynamicCast<Register>())\n                    {\n                        registerValidator_->setChildItemValidity(registerBase, false);\n                    }\n                    else if (registerBase.dynamicCast<RegisterFile>())\n                    {\n                        setChildItemValidity(registerBase, false);\n                    }\n                });\n\n            registerDataIsValid = false;\n        }\n    }\n\n    if (!registerDataIsValid)\n    {\n        return false;\n    }\n\n    // Validate registers and register files separately\n    for (auto const& registerBase : *registerDataCopy)\n    {\n        if (QSharedPointer<Register> asRegister = registerBase.dynamicCast<Register>();\n            asRegister && !registerValidator_->validate(asRegister))\n        {\n            return false;\n        }\n        else if (QSharedPointer<RegisterFile> asRegisterFile = registerBase.dynamicCast<RegisterFile>();\n            asRegisterFile && !validate(asRegisterFile, addressUnitBits, addressBlockWidth))\n        {\n            return false;\n        }\n    }\n\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: RegisterFileValidator::hasValidStructure()\n//-----------------------------------------------------------------------------\nbool RegisterFileValidator::hasValidStructure(QSharedPointer<RegisterFile> selectedRegisterFile) const\n{\n    if (!selectedRegisterFile->getRegisterFileDefinitionReference().isEmpty() &&\n        (!selectedRegisterFile->getTypeIdentifier().isEmpty() ||\n            !selectedRegisterFile->getRange().isEmpty() ||\n            !selectedRegisterFile->getAccessPolicies()->isEmpty() ||\n            !selectedRegisterFile->getRegisterData()->isEmpty()))\n    {\n        return false;\n    }\n\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: RegisterFileValidator::findErrorsIn()\n//-----------------------------------------------------------------------------\nvoid RegisterFileValidator::findErrorsIn(QVector<QString>& errors, QSharedPointer<RegisterFile> selectedRegisterFile,\n    QString const& context, QString const& addressUnitBits, QString const& addressBlockWidth) const\n{\n    QString registerContext = QStringLiteral(\"register file \") + selectedRegisterFile->name();\n\n    QString completeContext = QObject::tr(\"register file '%1' within %2\").arg(selectedRegisterFile->name()).arg(context);\n\n    findErrorsInName(errors, selectedRegisterFile, completeContext);\n\n    if (docRevision_ == Document::Revision::Std14)\n    {\n        findErrorsInIsPresent(errors, selectedRegisterFile, completeContext);\n        findErrorsInDimension(errors, selectedRegisterFile, completeContext);\n    }\n    else if (docRevision_ == Document::Revision::Std22)\n    {\n        findErrorsInMemoryArray(errors, selectedRegisterFile, completeContext);\n        findErrorsInAccessPolicies(errors, selectedRegisterFile, context);\n\n        if (!hasValidStructure(selectedRegisterFile))\n        {\n            errors.append(QObject::tr(\"Register file '%1' in %2 contains both a register file definition reference and register file definition values.\").arg(selectedRegisterFile->name()).arg(context));\n        }\n    }\n\n    findErrorsInAddressOffset(errors, selectedRegisterFile, completeContext);\n    findErrorsInParameters(errors, selectedRegisterFile, registerContext);\n    findErrorsInRange(errors, selectedRegisterFile, context);\n    findErrorsInRegisterData(errors, selectedRegisterFile, completeContext, addressUnitBits, addressBlockWidth);\n}\n\n//-----------------------------------------------------------------------------\n// Function: RegisterFileValidator::findErrorsInSize()\n//-----------------------------------------------------------------------------\nvoid RegisterFileValidator::findErrorsInRange(QVector<QString>& errors,\n    QSharedPointer<RegisterFile> selectedRegisterFile,\n    QString const& context) const\n{\n    if (!hasValidRange(selectedRegisterFile))\n    {\n        errors.append(QObject::tr(\"Invalid range specified for register file %1 within %2\").\n            arg(selectedRegisterFile->name()).arg(context));\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: RegisterFileValidator::findErrorsInRegisterData()\n//-----------------------------------------------------------------------------\nvoid RegisterFileValidator::findErrorsInRegisterData(QVector<QString>& errors,\n    QSharedPointer<RegisterFile> selectedRegisterFile, QString const& context, QString const& addressUnitBits,\n    QString const& addressBlockWidth) const\n{\n    if (selectedRegisterFile->getRegisterData()->isEmpty())\n    {\n        return;\n    }\n\n    MemoryReserve reservedArea;\n\n    QStringList registerNames;\n    QStringList registerFileNames;\n    QStringList duplicateRegisterNames;\n    QStringList duplicateRegisterFileNames;\n\n    QMultiHash<QString, QSharedPointer<RegisterBase> > foundNames;\n\n    bool aubChangeOk = true;\n    qint64 aubInt = expressionParser_->parseExpression(addressUnitBits).toLongLong(&aubChangeOk);\n    qint64 registerFileRangeInt = getTrueRegisterFileRange(selectedRegisterFile);\n    qint64 addressBlockWidthInt = expressionParser_->parseExpression(addressBlockWidth).toLongLong();\n\n    auto registerData = selectedRegisterFile->getRegisterData();\n\n    if (aubChangeOk && aubInt != 0)\n    {\n        for (auto const& reg : *registerData)\n        {\n            if (auto asRegister = reg.dynamicCast<Register>())\n            {\n                findErrorsInChildRegister(errors, asRegister, context, aubInt, \n                    registerFileRangeInt, addressBlockWidthInt, reservedArea, registerNames, duplicateRegisterNames);\n            }\n            else if (auto asRegisterFile = reg.dynamicCast<RegisterFile>())\n            {\n                findErrorsInChildRegisterFile(errors, asRegisterFile, context, addressUnitBits, \n                    registerFileRangeInt, addressBlockWidth, reservedArea, registerFileNames, duplicateRegisterFileNames);\n            }\n        }\n    }\n    reservedArea.findErrorsInOverlap(errors, QStringLiteral(\"Register data\"), context);\n}\n\n//-----------------------------------------------------------------------------\n// Function: RegisterFileValidator::findErrorsInAccessPolicies()\n//-----------------------------------------------------------------------------\nvoid RegisterFileValidator::findErrorsInAccessPolicies(QStringList& errors, \n    QSharedPointer<RegisterFile> selectedRegisterFile, QString const& context) const\n{\n    QString registerFileContext = QStringLiteral(\"register file \") + selectedRegisterFile->name() + QStringLiteral(\" within \") + context;\n\n    RegisterBaseValidator::findErrorsInAccessPolicies(errors, selectedRegisterFile, registerFileContext);\n}\n\n//-----------------------------------------------------------------------------\n// Function: RegisterFileValidator::getRegisterSizeInLAU()\n//-----------------------------------------------------------------------------\nqint64 RegisterFileValidator::getRegisterSizeInLAU(QSharedPointer<Register> targetRegister, qint64 addressUnitBits) const\n{\n    qint64 size = expressionParser_->parseExpression(targetRegister->getSize()).toLongLong();\n    qint64 dimensionsProduct = 1;\n\n    if (auto memArray = targetRegister->getMemoryArray())\n    {\n        for (auto const& dimension : *memArray->getDimensions())\n        {\n            dimensionsProduct *= expressionParser_->parseExpression(dimension->value_).toLongLong();\n        }\n    }\n\n    qint64 topPart = size + addressUnitBits - 1;\n    qint64 dimensionlessSize = topPart / addressUnitBits;\n\n    qint64 trueSize = dimensionlessSize * dimensionsProduct;\n\n    return trueSize;\n}\n\n//-----------------------------------------------------------------------------\n// Function: RegisterFileValidator::findErrorsInChildRegister()\n//-----------------------------------------------------------------------------\nvoid RegisterFileValidator::findErrorsInChildRegister(QStringList& errors, QSharedPointer<Register> childRegister,\n    QString const& context, qint64 addressUnitBits, qint64 parentRegisterFileRange, \n    qint64 addressBlockWidth, MemoryReserve& reservedArea, QStringList& registerNames, \n    QStringList& duplicateRegisterNames) const\n{\n    QString const& childRegName = childRegister->name();\n\n    if (registerNames.contains(childRegName) && !duplicateRegisterNames.contains(childRegName))\n    {\n        errors.append(QObject::tr(\"Name %1 of registers in %2 is not unique.\").arg(childRegName).arg(context));\n        duplicateRegisterNames.append(childRegName);\n    }\n    else\n    {\n        registerNames.append(childRegName);\n    }\n\n    registerValidator_->findErrorsIn(errors, childRegister, context);\n\n    qint64 registerSize = expressionParser_->parseExpression(childRegister->getSize()).toInt();\n\n    if (registerSize > addressBlockWidth)\n    {\n        errors.append(QObject::tr(\"Register %1 size must not be greater than the containing \"\n            \"addressBlock width.\").arg(childRegName));\n    }\n\n    qint64 realRegisterSize = getRegisterSizeInLAU(childRegister, addressUnitBits);\n\n    qint64 registerBegin = expressionParser_->parseExpression(\n        childRegister->getAddressOffset()).toLongLong();\n\n    qint64 registerEnd = registerBegin + realRegisterSize - 1;\n\n    if (registerBegin < 0 || registerBegin + realRegisterSize > parentRegisterFileRange)\n    {\n        errors.append(QObject::tr(\"Register %1 is not contained within parent register file.\")\n            .arg(childRegName));\n    }\n\n    if (childRegister->getIsPresent().isEmpty() ||\n        expressionParser_->parseExpression(childRegister->getIsPresent()).toInt())\n    {\n        reservedArea.addArea(childRegName, registerBegin, registerEnd);\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: RegisterFileValidator::findErrorsInChildRegisterFile()\n//-----------------------------------------------------------------------------\nvoid RegisterFileValidator::findErrorsInChildRegisterFile(QStringList& errors, \n    QSharedPointer<RegisterFile> childRegisterFile, QString const& context, QString const& addressUnitBits, \n    qint64 parentRegisterFileRange, QString const& addressBlockWidth, MemoryReserve& reservedArea, \n    QStringList& registerFileNames, QStringList& duplicateRegisterFileNames) const\n{\n    QString const& childRegFileName = childRegisterFile->name();\n\n    if (registerFileNames.contains(childRegFileName) && !duplicateRegisterFileNames.contains(childRegFileName))\n    {\n        errors.append(QObject::tr(\"Name %1 of register files in %2 is not unique.\").arg(childRegFileName).arg(context));\n        duplicateRegisterFileNames.append(childRegFileName);\n    }\n    else\n    {\n        registerFileNames.append(childRegFileName);\n    }\n\n    findErrorsIn(errors, childRegisterFile, context, addressUnitBits, addressBlockWidth);\n\n    qint64 registerFileBegin = expressionParser_->parseExpression(\n        childRegisterFile->getAddressOffset()).toLongLong();\n\n    qint64 registerFileRangeInt = expressionParser_->parseExpression(childRegisterFile->getRange()).toLongLong();\n    qint64 registerFileEnd = registerFileBegin + registerFileRangeInt - 1;\n\n    if (registerFileBegin < 0 || registerFileBegin + registerFileEnd > parentRegisterFileRange)\n    {\n        errors.append(QObject::tr(\"Register file %1 not contained within %2.\").arg(childRegisterFile->name()).arg(context));\n    }\n\n    if (childRegisterFile->getIsPresent().isEmpty() ||\n        expressionParser_->parseExpression(childRegisterFile->getIsPresent()).toInt())\n    {\n        reservedArea.addArea(childRegisterFile->name(), registerFileBegin, registerFileEnd);\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: RegisterFileValidator::markRegisterOverlap()\n//-----------------------------------------------------------------------------\nbool RegisterFileValidator::markRegisterOverlap(QList<QSharedPointer<RegisterBase> >::iterator regIter, \n    qint64& lastEndAddress, qint64 registerFileRange, qint64 addressUnitBits, bool targetIsRegister, \n    bool lastWasRegister)\n{\n    auto targetRegisterBase = *regIter;\n\n    qint64 targetRegisterBaseBegin = expressionParser_->parseExpression(\n        targetRegisterBase->getAddressOffset()).toLongLong();\n    qint64 targetRegisterBaseRangeInt = -1;\n\n    bool errorFound = false;\n\n    if (targetIsRegister)\n    {\n        targetRegisterBaseRangeInt = getRegisterSizeInLAU(targetRegisterBase.staticCast<Register>(), addressUnitBits);\n    }\n    else\n    {\n        targetRegisterBaseRangeInt = getTrueRegisterFileRange(targetRegisterBase.staticCast<RegisterFile>());\n    }\n\n    qint64 registerBaseEnd = targetRegisterBaseBegin + targetRegisterBaseRangeInt - 1;\n\n    if (targetRegisterBase->getIsPresent().isEmpty() ||\n        expressionParser_->parseExpression(targetRegisterBase->getIsPresent()).toInt())\n    {\n        if (targetRegisterBaseBegin <= lastEndAddress && lastEndAddress != -1)\n        {\n            auto prevRegisterBase = *std::prev(regIter);\n\n            if (lastWasRegister)\n            {\n                registerValidator_->setChildItemValidity(prevRegisterBase, false);\n            }\n            else\n            {\n                setChildItemValidity(prevRegisterBase, false);\n            }\n\n            if (targetIsRegister)\n            {\n                registerValidator_->setChildItemValidity(targetRegisterBase, false);\n            }\n            else\n            {\n                setChildItemValidity(targetRegisterBase, false);\n            }\n\n            errorFound = true;\n        }\n\n        if (registerBaseEnd > lastEndAddress)\n        {\n            lastEndAddress = registerBaseEnd;\n        }\n    }\n\n    if (targetRegisterBaseBegin < 0 || targetRegisterBaseBegin + targetRegisterBaseRangeInt > registerFileRange)\n    {\n        targetIsRegister\n            ? registerValidator_->setChildItemValidity(targetRegisterBase, false)\n            : setChildItemValidity(targetRegisterBase, false);\n        errorFound = true;\n    }\n\n    return errorFound;\n}\n\n//-----------------------------------------------------------------------------\n// Function: RegisterFileValidator::getTrueRegisterFileRange()\n//-----------------------------------------------------------------------------\nqint64 RegisterFileValidator::getTrueRegisterFileRange(QSharedPointer<RegisterFile> targetRegisterFile) const\n{\n    qint64 dimensionsProduct = 1;\n\n    if (auto memArray = targetRegisterFile->getMemoryArray())\n    {\n        for (auto const& dimension : *memArray->getDimensions())\n        {\n            dimensionsProduct *= expressionParser_->parseExpression(dimension->value_).toLongLong();\n        }\n    }\n\n    qint64 dimensionlessRange = expressionParser_->parseExpression(targetRegisterFile->getRange()).toLongLong();\n    qint64 trueRange = dimensionlessRange * dimensionsProduct;\n\n    return trueRange;\n}\n"
  },
  {
    "path": "IPXACTmodels/Component/validators/RegisterFileValidator.h",
    "content": "//-----------------------------------------------------------------------------\n// File: RegisterFileValidator.h\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Dan Chianucci\n// Date: 04.06.2018\n//\n// Description:\n// Validator for ipxact:RegisterFile.\n//-----------------------------------------------------------------------------\n\n#ifndef REGISTERFILEVALIDATOR_H\n#define REGISTERFILEVALIDATOR_H\n\n#include <IPXACTmodels/ipxactmodels_global.h>\n#include <IPXACTmodels/Component/validators/RegisterBaseValidator.h>\n#include <IPXACTmodels/Component/validators/MemoryReserve.h>\n\n#include <QSharedPointer>\n#include <QString>\n\nclass ExpressionParser;\nclass RegisterBase;\nclass RegisterFile;\nclass RegisterValidator;\nclass ParameterValidator;\nclass Component;\n\n//-----------------------------------------------------------------------------\n//! Validator for ipxact:RegisterFile.\n//-----------------------------------------------------------------------------\nclass IPXACTMODELS_EXPORT RegisterFileValidator : public RegisterBaseValidator\n{\npublic:\n\n    /*!\n     * The constructor.\n     *\n     *    @param [in] expressionParser     Parser for expressions.\n     *    @param [in] registerValidator    Validator for registers.\n     *    @param [in] parameterValidator   Validator for parameters.\n     */\n    RegisterFileValidator(QSharedPointer<ExpressionParser> expressionParser,\n        QSharedPointer<RegisterValidator> registerValidator,\n        QSharedPointer<ParameterValidator> parameterValidator,\n        Document::Revision docRevision);\n\n    //! The destructor.\n    virtual ~RegisterFileValidator() = default;\n\n    // Disable copying.\n    RegisterFileValidator(RegisterFileValidator const& rhs) = delete;\n    RegisterFileValidator& operator=(RegisterFileValidator const& rhs) = delete;\n\n\n    QSharedPointer<RegisterValidator> getRegisterValidator() const;\n\n    void componentChange(QSharedPointer<Component> newComponent);\n\n    /*!\n    *  Validates the given register file.\n    *\n    *    @param [in] selectedRegisterFile    The register file to validate.\n    *\n    *    @return True, if the register file is valid IP-XACT, otherwise false.\n    */\n    bool validate(QSharedPointer<RegisterFile> selectedRegisterFile, QString const& addressUnitBits, QString const& addressBlockWidth);\n\n    /*!\n    *  Check if the register file has a valid range.\n    *\n    *    @param [in] selectedRegisterFile    The selected register file whose range to check.\n    *\n    *    @return True, if the range is valid, otherwise false.\n    */\n    bool hasValidRange(QSharedPointer<RegisterFile> selectedRegisterFile) const;\n\n    /*!\n    *  Check if the register file has a valid register data.\n    *\n    *    @param [in] selectedRegisterFile    The selected register file whose register data to check\n    *    @param [in] addressUnitBits         The number of bits per address unit.\n    *    @param [in] addressBlockWidth       The width of the enclosing address block.\n    *\n    *    @return True, if the register data is valid, otherwise false.\n    */\n    bool hasValidRegisterData(QSharedPointer<RegisterFile> selectedRegisterFile, QString const& addressUnitBits, \n        QString const& addressBlockWidth);\n\n    /*!\n     *\tCheck if the register file has a valid structure (choice of elements).\n     *  \n     *    @param [in] selectedRegisterFile     The selected register file to check.\n     *\t    \n     * \t    @return True, if the structure is valid, otherwise false.\n     */\n    bool hasValidStructure(QSharedPointer<RegisterFile> selectedRegisterFile) const;\n\n    /*!\n    *  Locate errors within a register file.\n    *\n    *    @param [in/out] errors               List of found errors.\n    *    @param [in] selectedRegisterFile     The selected register file.\n    *    @param [in] context                  Context to help locate the error.\n    *    @param [in] addressUnitBits          The number of bits per address unit.\n    *    @param [in] addressBlockWidth        The width of the enclosing address block.\n    */\n    void findErrorsIn(QVector<QString>& errors,\n        QSharedPointer<RegisterFile> selectedRegisterFile,\n        QString const& context,\n        QString const& addressUnitBits,\n        QString const& addressBlockWidth) const;\n\nprivate:\n\n    /*!\n    *  Find errors within the range value.\n    *\n    *    @param [in/out] errors               List of found errors.\n    *    @param [in] selectedRegisterFile     The selected register file.\n    *    @param [in] context                  Context to help locate the error.\n    */\n    void findErrorsInRange(QVector<QString>& errors,\n        QSharedPointer<RegisterFile> selectedRegisterFile,\n        QString const& context) const;\n\n    /*!\n    *  Find errors within the register data.\n    *\n    *    @param [in/out] errors               List of found errors.\n    *    @param [in] selectedRegisterFile     The selected register file.\n    *    @param [in] context                  Context to help locate the error.\n    */\n    void findErrorsInRegisterData(QVector<QString>& errors,\n        QSharedPointer<RegisterFile> selectedRegisterFile,\n        QString const& context,\n        QString const& addressUnitBits,\n        QString const& addressBlockWidth) const;\n\n    /*!\n     *\tFind errors within the access policies of the register file.\n     *  \n     *    @param [in/out] errors               List of found errors.\n     *    @param [in] selectedRegisterFile     The selected register file.\n     *    @param [in] context                  Context to help locate the error.\n     */\n    void findErrorsInAccessPolicies(QStringList& errors, QSharedPointer<RegisterFile> selectedRegisterFile,\n        QString const& context) const;\n\n    /*!\n     *\tGet size of the given register in address units.\n     *  \n     *    @param [in] targetRegister      The register whose size to get.\n     *    @param [in] addressUnitBits     The number of bits per address unit in use.\n     *\t    \n     * \t    @return The register size in address units.\n     */\n    qint64 getRegisterSizeInLAU(QSharedPointer<Register> targetRegister, qint64 addressUnitBits) const;\n\n    /*!\n     *\tFind errors in a given child register of the register file being checked.\n     * \n     *    @param [in/out] errors                      List of found errors.\n     *    @param [in] childRegister                   The child register to check.\n     *    @param [in] context                         Context to help locate the error.\n     *    @param [in] addressUnitBits                 The number of bits in an address unit.\n     *    @param [in] parentRegisterFileRange         The range of the parent register file.\n     *    @param [in] addressBlockWidth               The width of the enclosing address block.\n     *    @param [in/out] reservedArea                The currently reserved memory areas.\n     *    @param [in/out] registerFileNames           List of checked register names.\n     *    @param [in/out] duplicateRegisterFileNames  List to keep track of duplicate registers to prevent\n     *                                                  duplicate errors.\n     */\n    void findErrorsInChildRegister(QStringList& errors, QSharedPointer<Register> childRegister,\n        QString const& context, qint64 addressUnitBits, qint64 parentRegisterFileRange, \n        qint64 addressBlockWidth, MemoryReserve& reservedArea, QStringList& registerNames, \n        QStringList& duplicateRegisterNames) const;\n\n    /*!\n     *\tFind errors in a given child register file of the register file being checked.\n     *\n     *    @param [in/out] errors                      List of found errors.\n     *    @param [in] childRegisterFile               The child register to check.\n     *    @param [in] context                         Context to help locate the error.\n     *    @param [in] addressUnitBits                 The number of bits in an address unit.\n     *    @param [in] parentRegisterFileRange         The range of the parent register file.\n     *    @param [in] addressBlockWidth               The width of the enclosing address block.\n     *    @param [in/out] reservedArea                The currently reserved memory areas.\n     *    @param [in/out] registerFileNames           List of checked register file names.\n     *    @param [in/out] duplicateRegisterFileNames  List to keep track of duplicate register files to prevent\n     *                                                  duplicate errors.\n     */\n    void findErrorsInChildRegisterFile(QStringList& errors, QSharedPointer<RegisterFile> childRegisterFile, \n        QString const& context, QString const& addressUnitBits, qint64 parentRegisterFileRange, \n        QString const& addressBlockWidth, MemoryReserve& reservedArea, QStringList& registerFileNames,\n        QStringList& duplicateRegisterFileNames) const;\n\n    /*!\n     *\tMark overlapping registers and register files as invalid.\n     *\n     *    @param [in] regIter             Iterator pointing to current register(file).\n     *    @param [in] lastEndAddress      Currently biggest register end address found.\n     *    @param [in] registerFileRange   The address block range.\n     *    @param [in] addressUnitBits     The memory map address unit bits.\n     *    @param [in] targetIsRegister    Flag indicating if regIter points to register or register file.\n     *    @param [in] lastWasRegister     Flag indicating if the previous item was a register or register file.\n     *\n     * \t    @return True, if overlapping registers and/or register files were found, otherwise false.\n     */\n    bool markRegisterOverlap(QList<QSharedPointer<RegisterBase> >::iterator regIter, qint64& lastEndAddress,\n        qint64 registerFileRange, qint64 addressUnitBits, bool targetIsRegister, bool lastWasRegister);\n\n    /*!\n     *\tGet register file range (size in AUB) taking dimensions into account.\n     *\n     *    @param [in] targetRegisterFile     The register file to get range of.\n     *\n     * \t    @return The true register file range.\n     */\n    qint64 getTrueRegisterFileRange(QSharedPointer<RegisterFile> targetRegisterFile) const;\n\n    //-----------------------------------------------------------------------------\n    // Data.\n    //-----------------------------------------------------------------------------\n    //! The validator used for fields.\n    QSharedPointer<RegisterValidator> registerValidator_;\n};\n\n#endif // REGISTERFILEVALIDATOR_H\n"
  },
  {
    "path": "IPXACTmodels/Component/validators/RegisterValidator.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: RegisterValidator.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 19.11.2015\r\n//\r\n// Description:\r\n// Validator for ipxact:Register.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"RegisterValidator.h\"\r\n\r\n#include <KactusAPI/include/ExpressionParser.h>\r\n#include <IPXACTmodels/Component/validators/FieldValidator.h>\r\n#include <IPXACTmodels/common/validators/CommonItemsValidator.h>\r\n#include <IPXACTmodels/common/validators/ParameterValidator.h>\r\n\r\n#include <IPXACTmodels/Component/validators/MemoryReserve.h>\r\n#include <IPXACTmodels/Component/Component.h>\r\n#include <IPXACTmodels/Component/validators/MemoryArrayValidator.h>\r\n#include <IPXACTmodels/Component/RegisterBase.h>\r\n#include <IPXACTmodels/Component/RegisterDefinition.h>\r\n#include <IPXACTmodels/Component/Register.h>\r\n#include <IPXACTmodels/Component/AlternateRegister.h>\r\n#include <IPXACTmodels/Component/Field.h>\r\n#include <IPXACTmodels/Component/MemoryArray.h>\r\n#include <IPXACTmodels/Component/EnumeratedValue.h>\r\n#include <IPXACTmodels/Component/WriteValueConstraint.h>\r\n\r\n#include <QRegularExpression>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: RegisterValidator::RegisterValidator()\r\n//-----------------------------------------------------------------------------\r\nRegisterValidator::RegisterValidator(QSharedPointer<ExpressionParser> expressionParser,\r\n    QSharedPointer<FieldValidator> fieldValidator, QSharedPointer<ParameterValidator> parameterValidator,\r\n    Document::Revision docRevision) :\r\n    RegisterBaseValidator(expressionParser, parameterValidator, docRevision),\r\n    fieldValidator_(fieldValidator)\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: RegisterValidator::componentChange()\r\n//-----------------------------------------------------------------------------\r\nvoid RegisterValidator::componentChange(QSharedPointer<Component> newComponent)\r\n{\r\n    fieldValidator_->componentChange(newComponent);\r\n\r\n    if (newComponent)\r\n    {\r\n        docRevision_ = newComponent->getRevision();\r\n        componentModes_ = newComponent->getModes();\r\n    }\r\n}   \r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: RegisterValidator::getFieldValidator()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<FieldValidator> RegisterValidator::getFieldValidator() const\r\n{\r\n    return fieldValidator_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: RegisterValidator::validate()\r\n//-----------------------------------------------------------------------------\r\nbool RegisterValidator::validate(QSharedPointer<Register> selectedRegister) const\r\n{\r\n    return hasValidSize(selectedRegister) &&\r\n           hasValidFields(selectedRegister, selectedRegister->getSize()) &&\r\n           hasValidAlternateRegisters(selectedRegister) &&\r\n            RegisterBaseValidator::validate(selectedRegister) &&\r\n           hasValidStructure(selectedRegister);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n//-----------------------------------------------------------------------------// Function: RegisterValidator::hasValidSize()\r\n//-----------------------------------------------------------------------------\r\nbool RegisterValidator::hasValidSize(QSharedPointer<Register> selectedRegister) const\r\n{\r\n    bool changeOk = true;\r\n    bool expressionValid = false;\r\n\r\n    QString solvedValue = expressionParser_->parseExpression(selectedRegister->getSize(), &expressionValid);\r\n    quint64 sizeInt = solvedValue.toULongLong(&changeOk);\r\n\r\n    return changeOk && expressionValid && sizeInt != 0;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: RegisterValidator::hasValidFields()\r\n//-----------------------------------------------------------------------------\r\nbool RegisterValidator::hasValidFields(QSharedPointer<RegisterDefinition> selectedRegister,\r\n    QString const& registerSize) const\r\n{\r\n    if (selectedRegister->getFields()->isEmpty())\r\n    {\r\n        return false;\r\n    }\r\n\r\n    qint64 registerSizeInt = expressionParser_->parseExpression(registerSize).toLongLong();\r\n\r\n    QVector<QString> fieldNames;\r\n    QVector<QString> fieldTypeIdentifiers;\r\n\r\n    QMultiHash<QString, QSharedPointer<Field> > foundFieldNames;\r\n\r\n    bool fieldsAreValid = true;\r\n    \r\n    auto fieldsCopy = QSharedPointer<QList<QSharedPointer<Field> > >(new QList(*selectedRegister->getFields()));\r\n\r\n    // Sort fields by offset for checking overlap.\r\n    auto sortFieldsByOffset = [&](QSharedPointer<Field> fieldA, QSharedPointer<Field> fieldB)\r\n        {\r\n            return expressionParser_->parseExpression(fieldA->getBitOffset()).toLongLong() < \r\n                expressionParser_->parseExpression(fieldB->getBitOffset()).toLongLong();\r\n        };\r\n\r\n    std::sort(fieldsCopy->begin(), fieldsCopy->end(), sortFieldsByOffset);\r\n\r\n    qint64 lastFieldEnd = 0;\r\n\r\n    for (int fieldIndex = 0; fieldIndex < fieldsCopy->size(); ++fieldIndex)\r\n    {\r\n        QSharedPointer<Field> field = fieldsCopy->at(fieldIndex);\r\n\r\n        quint64 bitWidth = getTrueFieldBitWidth(field);\r\n        qint64 rangeBegin = expressionParser_->parseExpression(field->getBitOffset()).toLongLong();\r\n        qint64 rangeEnd = rangeBegin + bitWidth - 1;\r\n        qint64 fieldEndPosition = registerSizeInt - bitWidth;\r\n\r\n        if (!fieldNames.contains(field->name()))\r\n        {\r\n            fieldValidator_->setChildItemValidity(field, true);\r\n        }\r\n\r\n        foundFieldNames.insert(field->name(), field);\r\n        \r\n        if (rangeBegin < 0 || rangeBegin > fieldEndPosition)\r\n        {\r\n            fieldValidator_->setChildItemValidity(field, false);\r\n            fieldsAreValid = false;\r\n        }\r\n\r\n        if (!field->getTypeIdentifier().isEmpty() && fieldTypeIdentifiers.contains(field->getTypeIdentifier()))\r\n        {\r\n            int typeIdIndex = fieldTypeIdentifiers.indexOf(field->getTypeIdentifier());\r\n\r\n            QSharedPointer<Field> comparedField = fieldsCopy->at(typeIdIndex);\r\n            if (!fieldsHaveSimilarDefinitionGroups(field, comparedField))\r\n            {\r\n                fieldValidator_->setChildItemValidity(field, false);\r\n                fieldValidator_->setChildItemValidity(comparedField, false);\r\n                fieldsAreValid = false;\r\n            }\r\n        }\r\n\r\n        fieldTypeIdentifiers.append(field->getTypeIdentifier());\r\n\r\n        if (field->getVolatile().toBool() == true && selectedRegister->getVolatile() == QLatin1String(\"false\"))\r\n        {\r\n            fieldValidator_->setChildItemValidity(field, false);\r\n            fieldsAreValid = false;\r\n        }\r\n\r\n        if (docRevision_ == Document::Revision::Std14 && !fieldHasValidAccess(selectedRegister, field))\r\n        {\r\n            fieldValidator_->setChildItemValidity(field, false);\r\n            fieldsAreValid = false;\r\n        }\r\n\r\n        if (field->getIsPresent().isEmpty() || expressionParser_->parseExpression(field->getIsPresent()).toInt())\r\n        {\r\n            if (fieldIndex != 0 && rangeBegin <= lastFieldEnd)\r\n            {\r\n                fieldValidator_->setChildItemValidity(field, false);\r\n                fieldValidator_->setChildItemValidity(fieldsCopy->at(fieldIndex - 1), false);\r\n                fieldsAreValid = false;\r\n            }\r\n\r\n            if (rangeEnd > lastFieldEnd)\r\n            {\r\n                lastFieldEnd = rangeEnd;\r\n            }\r\n        }\r\n    }\r\n    \r\n    // Mark fields with duplicate names as invalid.\r\n    for (auto const& name : foundFieldNames.keys())\r\n    {\r\n        if (auto const& duplicateNames = foundFieldNames.values(name);\r\n            duplicateNames.count() > 1)\r\n        {\r\n            std::for_each(duplicateNames.begin(), duplicateNames.end(),\r\n                [this](QSharedPointer<Field> field)\r\n                {\r\n                    fieldValidator_->setChildItemValidity(field, false);\r\n                });\r\n\r\n            fieldsAreValid = false;\r\n        }\r\n    }\r\n\r\n    if (!fieldsAreValid)\r\n    {\r\n        return false;\r\n    }\r\n\r\n    // Validate fields separately.\r\n    for (auto const& field : *fieldsCopy)\r\n    {\r\n        if (!fieldValidator_->validate(field))\r\n        {\r\n            return false;\r\n        }\r\n    }\r\n\r\n    return true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: RegisterValidator::hasValidAlternateRegisters()\r\n//-----------------------------------------------------------------------------\r\nbool RegisterValidator::hasValidAlternateRegisters(QSharedPointer<Register> selectedRegister) const\r\n{\r\n    QStringList alternateRegisterNames;\r\n\r\n    QStringList checkedModeReferences;\r\n    QStringList checkedModePriorities;\r\n\r\n    auto allModeRefs = QSharedPointer<QList<QSharedPointer<ModeReference> > >(\r\n        new QList<QSharedPointer<ModeReference> >());\r\n\r\n    for (QSharedPointer<AlternateRegister> alternateRegister : *selectedRegister->getAlternateRegisters())\r\n    {\r\n        if (alternateRegisterNames.contains(alternateRegister->name()))\r\n        {\r\n            return false;\r\n        }\r\n        else\r\n        {\r\n            alternateRegisterNames.append(alternateRegister->name());\r\n        }\r\n\r\n        auto modeRefs = alternateRegister->getModeReferences();\r\n        std::for_each(modeRefs->cbegin(), modeRefs->cend(), [&allModeRefs](auto modeRef)\r\n            {\r\n                allModeRefs->append(modeRef);\r\n            });\r\n\r\n        if (!alternateRegisterIsValid(alternateRegister, selectedRegister))\r\n        {\r\n            return false;\r\n        }\r\n    }\r\n    \r\n    if (!CommonItemsValidator::hasValidModeRefs(allModeRefs, componentModes_))\r\n    {\r\n        return false;\r\n    }\r\n\r\n    return true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: RegisterValidator::hasValidAlternateGroups()\r\n//-----------------------------------------------------------------------------\r\nbool RegisterValidator::hasValidAlternateGroups(QSharedPointer<AlternateRegister> selectedRegister) const\r\n{\r\n    if (selectedRegister->getAlternateGroups()->isEmpty() && docRevision_ == Document::Revision::Std22)\r\n    {\r\n        return false;\r\n    }\r\n\r\n    QRegularExpression whiteSpaceExpression;\r\n    whiteSpaceExpression.setPattern(QStringLiteral(\"^\\\\s*$\"));\r\n\r\n    QStringList alternateGroups;\r\n    bool alternateGroupsOk = false;\r\n    for (QString const& group : *selectedRegister->getAlternateGroups())\r\n    {\r\n        if (group.isEmpty() || whiteSpaceExpression.match(group).hasMatch() || alternateGroups.contains(group))\r\n        {\r\n            return false;\r\n        }\r\n        else\r\n        {\r\n            alternateGroups.append(group);\r\n            alternateGroupsOk = true;\r\n        }\r\n    }\r\n\r\n    return alternateGroupsOk;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: RegisterValidator::hasValidStructure()\r\n//-----------------------------------------------------------------------------\r\nbool RegisterValidator::hasValidStructure(QSharedPointer<Register> selectedRegister) const\r\n{\r\n    if (docRevision_ == Document::Revision::Std22)\r\n    {\r\n        // Either definition reference or register definition group can be defined.\r\n        if (selectedRegister->getRegisterDefinitionReference().isEmpty() == false &&\r\n            (!selectedRegister->getTypeIdentifier().isEmpty() || !selectedRegister->getSize().isEmpty() ||\r\n                !selectedRegister->getVolatile().isEmpty() || !selectedRegister->getAccessPolicies()->isEmpty() ||\r\n                !selectedRegister->getFields()->isEmpty()))\r\n        {\r\n            return false;\r\n        }\r\n    }\r\n\r\n    return true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: RegisterValidator::fieldHasValidAccess()\r\n//-----------------------------------------------------------------------------\r\nbool RegisterValidator::fieldHasValidAccess(QSharedPointer<RegisterDefinition> selectedRegsiter,\r\n    QSharedPointer<Field> field) const\r\n{\r\n    AccessTypes::Access registerAccess = selectedRegsiter->getAccess();\r\n\r\n\tif (AccessTypes::Access fieldAccess = field->getAccess();\r\n\t\t(registerAccess == AccessTypes::READ_ONLY && fieldAccess == AccessTypes::READ_ONLY) ||\r\n        (registerAccess == AccessTypes::WRITE_ONLY && (fieldAccess == AccessTypes::WRITE_ONLY ||\r\n            fieldAccess == AccessTypes::WRITEONCE)) ||\r\n        (registerAccess == AccessTypes::READ_WRITEONCE && (fieldAccess == AccessTypes::READ_ONLY ||\r\n            fieldAccess == AccessTypes::READ_WRITEONCE || fieldAccess == AccessTypes::WRITEONCE)) ||\r\n        (registerAccess == AccessTypes::WRITEONCE && fieldAccess == AccessTypes::WRITEONCE) ||\r\n        registerAccess == AccessTypes::ACCESS_COUNT || fieldAccess == AccessTypes::ACCESS_COUNT ||\r\n        registerAccess == AccessTypes::READ_WRITE)\r\n     {\r\n         return true;\r\n     }\r\n\r\n     return false;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: RegisterValidator::fieldsHaveSimilarDefinitionGroup()\r\n//-----------------------------------------------------------------------------\r\nbool RegisterValidator::fieldsHaveSimilarDefinitionGroups(QSharedPointer<Field> field,\r\n    QSharedPointer<Field> comparedField) const\r\n{\r\n    int foundComparisons = 0;\r\n    for (QSharedPointer<EnumeratedValue> enumeratedValue : *field->getEnumeratedValues())\r\n    {\r\n        for (QSharedPointer<EnumeratedValue> comparedEnumeratedValue : *comparedField->getEnumeratedValues())\r\n        {\r\n            if (enumeratedValue->name() == comparedEnumeratedValue->name() &&\r\n                enumeratedValue->displayName() == comparedEnumeratedValue->displayName() &&\r\n                enumeratedValue->shortDescription() == comparedEnumeratedValue->shortDescription() &&\r\n                enumeratedValue->description() == comparedEnumeratedValue->description() &&\r\n                enumeratedValue->getValue() == comparedEnumeratedValue->getValue() &&\r\n                enumeratedValue->getVendorExtensions()->size() ==\r\n                comparedEnumeratedValue->getVendorExtensions()->size())\r\n            {\r\n                ++foundComparisons;\r\n            }\r\n        }\r\n    }\r\n    if (foundComparisons != field->getEnumeratedValues()->size() ||\r\n        foundComparisons != comparedField->getEnumeratedValues()->size())\r\n    {\r\n        return false;\r\n    }\r\n\r\n    if (field->getWriteConstraint() && comparedField->getWriteConstraint())\r\n    {\r\n        if (field->getWriteConstraint()->getType() != comparedField->getWriteConstraint()->getType() ||\r\n            field->getWriteConstraint()->getMinimum() != comparedField->getWriteConstraint()->getMinimum() ||\r\n            field->getWriteConstraint()->getMaximum() != comparedField->getWriteConstraint()->getMaximum())\r\n        {\r\n            return false;\r\n        }\r\n    }\r\n    else if (field->getWriteConstraint() || comparedField->getWriteConstraint())\r\n    {\r\n        return false;\r\n    }\r\n\r\n    return field->getBitWidth() == comparedField->getBitWidth() &&\r\n        field->getVolatile().toString() == comparedField->getVolatile().toString() &&\r\n        field->getAccess() == comparedField->getAccess() &&\r\n        field->getModifiedWrite() == comparedField->getModifiedWrite() &&\r\n        field->getModifiedWriteModify() == comparedField->getModifiedWriteModify() &&\r\n        field->getReadAction() == comparedField->getReadAction() &&\r\n        field->getReadActionModify() == comparedField->getReadActionModify() &&\r\n        field->getTestable().toString() == comparedField->getTestable().toString() &&\r\n        field->getTestConstraint() == comparedField->getTestConstraint() &&\r\n        field->getReserved() == comparedField->getReserved();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: RegisterValidator::findErrorsIn()\r\n//-----------------------------------------------------------------------------\r\nvoid RegisterValidator::findErrorsIn(QVector<QString>& errors, QSharedPointer<Register> selectedRegister,\r\n    QString const& context) const\r\n{\r\n    QString registerContext = QStringLiteral(\"register \") + selectedRegister->name();\r\n    QString completeRegisterContext = QStringLiteral(\"register '\") + selectedRegister->name() + QStringLiteral(\"' within \") + context;\r\n\r\n    if (docRevision_ == Document::Revision::Std14)\r\n    {\r\n        findErrorsInName(errors, selectedRegister, completeRegisterContext);\r\n        findErrorsInIsPresent(errors, selectedRegister, completeRegisterContext);\r\n        findErrorsInDimension(errors, selectedRegister, completeRegisterContext);\r\n        findErrorsInAddressOffset(errors, selectedRegister, completeRegisterContext);\r\n        findErrorsInSize(errors, selectedRegister, completeRegisterContext);\r\n        findErrorsInFields(errors, selectedRegister, selectedRegister->getSize(), registerContext);\r\n        findErrorsInAlternateRegisters(errors, selectedRegister);\r\n        findErrorsInParameters(errors, selectedRegister, registerContext);\r\n    }\r\n    else if (docRevision_ == Document::Revision::Std22)\r\n    {\r\n        findErrorsInName(errors, selectedRegister, completeRegisterContext);\r\n        findErrorsInMemoryArray(errors, selectedRegister, completeRegisterContext);\r\n        findErrorsInAddressOffset(errors, selectedRegister, completeRegisterContext);\r\n        findErrorsInSize(errors, selectedRegister, completeRegisterContext);\r\n        findErrorsInAccessPolicies(errors, selectedRegister, completeRegisterContext);\r\n        findErrorsInFields(errors, selectedRegister, selectedRegister->getSize(), registerContext);\r\n        findErrorsInAlternateRegisters(errors, selectedRegister);\r\n        if (!hasValidStructure(selectedRegister))\r\n        {\r\n            errors.append(QObject::tr(\"Register %1 in %2 contains both a register definition reference and register definition values.\").arg(selectedRegister->name()).arg(context));\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: RegisterValidator::findErrorsInSize()\r\n//-----------------------------------------------------------------------------\r\nvoid RegisterValidator::findErrorsInSize(QVector<QString>& errors, QSharedPointer<Register> selectedRegister,\r\n    QString const& context) const\r\n{\r\n    if (!hasValidSize(selectedRegister))\r\n    {\r\n        errors.append(QObject::tr(\"Invalid size specified for %1\").arg(context));\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: RegisterValidator::findErrorsInFields()\r\n//-----------------------------------------------------------------------------\r\nvoid RegisterValidator::findErrorsInFields(QVector<QString>& errors,\r\n    QSharedPointer<RegisterDefinition> selectedRegister, QString const& registerSize, QString const& context) const\r\n{\r\n    if (!selectedRegister->getFields()->isEmpty())\r\n    {\r\n        QStringList fieldNames;\r\n        QStringList fieldTypeIdentifiers;\r\n\r\n        qint64 registerSizeInt = expressionParser_->parseExpression(registerSize).toLongLong();\r\n        MemoryReserve reservedArea;\r\n\r\n        for (auto const& field : *selectedRegister->getFields())\r\n        {\r\n            fieldValidator_->findErrorsIn(errors, field, context);\r\n\r\n            if (fieldNames.contains(field->name()))\r\n            {\r\n                errors.append(\r\n                    QObject::tr(\"Name %1 of fields in %2 is not unique.\").arg(field->name()).arg(context));\r\n            }\r\n\r\n            qint64 bitWidth = getTrueFieldBitWidth(field);\r\n\r\n            qint64 rangeBegin = expressionParser_->parseExpression(field->getBitOffset()).toLongLong();\r\n            qint64 rangeEnd = rangeBegin + bitWidth - 1;\r\n\r\n            qint64 fieldEndPosition = registerSizeInt - bitWidth;\r\n\r\n            if (rangeBegin < 0 || rangeBegin > fieldEndPosition)\r\n            {\r\n                errors.append(QObject::tr(\"Field %1 is not contained within %2\").arg(field->name()).\r\n                    arg(selectedRegister->name()));\r\n            }\r\n\r\n            if(field->getIsPresent().isEmpty() || expressionParser_->parseExpression(field->getIsPresent()).toInt())\r\n            {\r\n              reservedArea.addArea(field->name(), rangeBegin, rangeEnd);\r\n            }\r\n\r\n            if (!field->getTypeIdentifier().isEmpty() && fieldTypeIdentifiers.contains(field->getTypeIdentifier()))\r\n            {\r\n                int typeIdIndex = fieldTypeIdentifiers.indexOf(field->getTypeIdentifier());\r\n                QSharedPointer<Field> comparedField = selectedRegister->getFields()->at(typeIdIndex);\r\n                if (!fieldsHaveSimilarDefinitionGroups(field, comparedField))\r\n                {\r\n                    errors.append(QObject::tr(\"Fields %1 and %2 have type identifier %3, but different \"\r\n                        \"field definitions within %4\").arg(comparedField->name()).arg(field->name())\r\n                        .arg(field->getTypeIdentifier()).arg(context));\r\n                }\r\n            }\r\n\r\n            fieldNames.append(field->name());\r\n            fieldTypeIdentifiers.append(field->getTypeIdentifier());\r\n\r\n            if (field->getVolatile().toBool() == true && selectedRegister->getVolatile() == QLatin1String(\"false\"))\r\n            {\r\n                errors.append(QObject::tr(\"Volatile cannot be set to false in %1, where contained field %2 \"\r\n                    \"has volatile true\").arg(context).arg(field->name()));\r\n            }\r\n\r\n            if (docRevision_ == Document::Revision::Std14)\r\n            {\r\n                if (!fieldHasValidAccess(selectedRegister, field))\r\n                {\r\n                    errors.append(QObject::tr(\"Access cannot be set to %1 in field %2, where containing register %3 \"\r\n                        \"has access %4\").arg(AccessTypes::access2Str(field->getAccess())).arg(field->name())\r\n                        .arg(selectedRegister->name()).arg(AccessTypes::access2Str(selectedRegister->getAccess())));\r\n                }\r\n            }\r\n        }\r\n\r\n        reservedArea.findErrorsInOverlap(errors, QLatin1String(\"Fields\"), context);\r\n    }\r\n    else\r\n    {\r\n        errors.append(QObject::tr(\"Register %1 must contain at least one field\").arg(selectedRegister->name()));\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: RegisterValidator::findErrorsInAlternateRegisters()\r\n//-----------------------------------------------------------------------------\r\nvoid RegisterValidator::findErrorsInAlternateRegisters(QVector<QString>& errors,\r\n    QSharedPointer<Register> selectedRegister) const\r\n{\r\n    QString context = QStringLiteral(\"register \") + selectedRegister->name();\r\n    QStringList alternateGroupNames;\r\n    \r\n    // Keep track of checked mode references.\r\n    bool duplicateRefErrorIssued = false;\r\n    bool duplicatePriorityErrorIssued = false;\r\n\r\n    QStringList checkedModeReferences;\r\n    QList<unsigned int> checkedModePriorities;\r\n\r\n    for (QSharedPointer<AlternateRegister> alternateRegister : *selectedRegister->getAlternateRegisters())\r\n    {\r\n        if (alternateGroupNames.contains(alternateRegister->name()))\r\n        {\r\n            errors.append(QObject::tr(\"Name %1 of alternate registers in %2 is not unique.\").arg(\r\n                alternateRegister->name(), context));\r\n        }\r\n        else\r\n        {\r\n            alternateGroupNames.append(alternateRegister->name());\r\n        }\r\n\r\n        QString registerContext = QStringLiteral(\"alternate register \") + alternateRegister->name() + QStringLiteral(\" within \") + context;\r\n\r\n        findErrorsInName(errors, alternateRegister, registerContext);\r\n        \r\n        if (docRevision_ == Document::Revision::Std14)\r\n        {\r\n            findErrorsInIsPresent(errors, alternateRegister, registerContext);\r\n            findErrorsInAlternateGroups(errors, alternateRegister, registerContext);\r\n        }\r\n        else if (docRevision_ == Document::Revision::Std22)\r\n        {\r\n            findErrorsInAlternateRegisterModeRefs(errors, alternateRegister, context, checkedModeReferences, \r\n                checkedModePriorities, &duplicateRefErrorIssued, &duplicatePriorityErrorIssued);\r\n            findErrorsInAccessPolicies(errors, alternateRegister, registerContext);\r\n        }\r\n\r\n        findErrorsInFields(errors, alternateRegister, selectedRegister->getSize(), registerContext);\r\n        findErrorsInParameters(errors, alternateRegister, registerContext);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: RegisterValidator::findErrorsInAlternateGroups()\r\n//-----------------------------------------------------------------------------\r\nvoid RegisterValidator::findErrorsInAlternateGroups(QVector<QString>& errors,\r\n    QSharedPointer<AlternateRegister> selectedRegister, QString const& context) const\r\n{\r\n    if (!hasValidAlternateGroups(selectedRegister))\r\n    {\r\n        errors.append(QObject::tr(\"Alternate groups are not unique or not empty in %1\").arg(context));\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: RegisterValidator::findErrorsInAlternateRegisterModeRefs()\r\n//-----------------------------------------------------------------------------\r\nvoid RegisterValidator::findErrorsInAlternateRegisterModeRefs(QStringList& errors, QSharedPointer<AlternateRegister> selectedRegister, QString const& context, QStringList& checkedModeRefs, QList<unsigned int>& checkedPriorities, bool* duplicateRefErrorIssued, bool* duplicatePriorityErrorIssued) const\r\n{\r\n    if (selectedRegister->getModeReferences()->isEmpty())\r\n    {\r\n        errors.append(QObject::tr(\"Alternate register %1 within %2 must have at least one mode reference defined.\")\r\n            .arg(selectedRegister->name()).arg(context));\r\n    }\r\n\r\n    QString altRegisterContext = QStringLiteral(\"alternate register \") + selectedRegister->name()\r\n        + QStringLiteral(\" within \") + context;\r\n\r\n    CommonItemsValidator::findErrorsInModeRefs(errors, selectedRegister->getModeReferences(), altRegisterContext, \r\n        checkedModeRefs, checkedPriorities, duplicateRefErrorIssued, duplicatePriorityErrorIssued, componentModes_);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: RegisterValidator::alternateRegisterIsValid()\r\n//-----------------------------------------------------------------------------\r\nbool RegisterValidator::alternateRegisterIsValid(QSharedPointer<AlternateRegister> alternateRegister, \r\n    QSharedPointer<Register> selectedRegister) const\r\n{   \r\n    if (!hasValidName(alternateRegister) ||\r\n        !hasValidFields(alternateRegister, selectedRegister->getSize()) ||\r\n        !hasValidParameters(alternateRegister))\r\n    {\r\n        return false;\r\n    }\r\n\r\n    if (docRevision_ == Document::Revision::Std14)\r\n    {\r\n        if (!hasValidIsPresent(alternateRegister) ||\r\n            !hasValidAlternateGroups(alternateRegister))\r\n        {\r\n            return false;\r\n        }\r\n    }\r\n    else if (docRevision_ == Document::Revision::Std22)\r\n    {\r\n        if (alternateRegister->getModeReferences()->isEmpty() ||\r\n            !RegisterBaseValidator::hasValidAccessPolicies(alternateRegister))\r\n        {\r\n            return false;\r\n        }\r\n    }\r\n\r\n    return true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: RegisterValidator::getTrueFieldBitWidth()\r\n//-----------------------------------------------------------------------------\r\nquint64 RegisterValidator::getTrueFieldBitWidth(QSharedPointer<Field> field) const\r\n{\r\n    quint64 bitWidth = expressionParser_->parseExpression(field->getBitWidth()).toULongLong();\r\n\r\n    // Calculate true bit width taking memory array dimensions into account.\r\n    if (auto memArray = field->getMemoryArray();\r\n        memArray && docRevision_ == Document::Revision::Std22)\r\n    {\r\n        auto fieldDimensions = field->getMemoryArray()->getDimensions();\r\n\r\n        std::for_each(fieldDimensions->cbegin(), fieldDimensions->cend(), [&bitWidth, this](auto dim)\r\n            {\r\n                bitWidth *= expressionParser_->parseExpression(dim->value_).toULongLong();\r\n            });\r\n    }\r\n\r\n    return bitWidth;\r\n}\r\n"
  },
  {
    "path": "IPXACTmodels/Component/validators/RegisterValidator.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: RegisterValidator.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 19.11.2015\r\n//\r\n// Description:\r\n// Validator for ipxact:Register.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef REGISTERVALIDATOR_H\r\n#define REGISTERVALIDATOR_H\r\n\r\n#include <IPXACTmodels/ipxactmodels_global.h>\r\n#include <IPXACTmodels/Component/validators/RegisterBaseValidator.h>\r\n\r\n#include <QSharedPointer>\r\n#include <QString>\r\n\r\nclass ExpressionParser;\r\nclass RegisterBase;\r\nclass RegisterDefinition;\r\nclass Register;\r\nclass AlternateRegister;\r\nclass Choice;\r\nclass Field;\r\nclass FieldValidator;\r\nclass ParameterValidator;\r\nclass RegisterBaseValidator;\r\nclass ResetType;\r\nclass Component;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Validator for ipxact:Register.\r\n//-----------------------------------------------------------------------------\r\nclass IPXACTMODELS_EXPORT RegisterValidator : public RegisterBaseValidator\r\n{\r\npublic:\r\n\r\n\t/*!\r\n\t *  The constructor.\r\n\t *\r\n\t *    @param [in] expressionParser    The parser to use for solving expressions.\r\n     *    @param [in] fieldValidator      Validator used for fields.\r\n     *    @param [in] parameterValidator  Validator used for parameters.\r\n     *    @param [in] docRevision         The IP-XACT standard revision to comply to.\r\n\t */\r\n    RegisterValidator(QSharedPointer<ExpressionParser> expressionParser,\r\n        QSharedPointer<FieldValidator> fieldValidator,\r\n        QSharedPointer<ParameterValidator> parameterValidator,\r\n        Document::Revision docRevision = Document::Revision::Std14);\r\n\r\n\t//! The destructor.\r\n    virtual ~RegisterValidator() = default;\r\n\r\n    // Disable copying.\r\n    RegisterValidator(RegisterValidator const& rhs) = delete;\r\n    RegisterValidator& operator=(RegisterValidator const& rhs) = delete;\r\n\r\n    /*!\r\n     *  Change the containing component.\r\n     *\r\n     *    @param [in] newComponent    The selected component.\r\n     */\r\n    void componentChange(QSharedPointer<Component> newComponent);\r\n\r\n    /*!\r\n     *  Get the field validator.\r\n     *\r\n     *    @return The field validator.\r\n     */\r\n    QSharedPointer<FieldValidator> getFieldValidator() const;\r\n\r\n    /*!\r\n     *  Validates the given register.\r\n     *\r\n     *    @param [in] selectedRegister    The register to validate.\r\n     *\r\n     *    @return True, if the register is valid IP-XACT, otherwise false.\r\n     */\r\n    bool validate(QSharedPointer<Register> selectedRegister) const;\r\n\r\n    /*!\r\n     *  Check if the register contains a valid size.\r\n     *\r\n     *    @param [in] selectedRegister    The selected register.\r\n     *\r\n     *    @return True, if the size is valid, otherwise false.\r\n     */\r\n    bool hasValidSize(QSharedPointer<Register> selectedRegister) const;\r\n\r\n    /*!\r\n     *  Check if the register contains valid fields.\r\n     *\r\n     *    @param [in] selectedRegister    The selected register definition.\r\n     *    @param [in] registerSize        Size of the containing register.\r\n     *\r\n     *    @return True, if the fields are valid, otherwise false.\r\n     */\r\n    bool hasValidFields(QSharedPointer<RegisterDefinition> selectedRegister, QString const& registerSize) const;\r\n\r\n    /*!\r\n     *  Check if the register contains valid alternate registers.\r\n     *\r\n     *    @param [in] selectedRegister    The selected register.\r\n     *\r\n     *    @return True, if the alternate registers are valid, otherwise false.\r\n     */\r\n    bool hasValidAlternateRegisters(QSharedPointer<Register> selectedRegister) const;\r\n\r\n    /*!\r\n     *  Check if the alternate register contains valid alternate groups.\r\n     *\r\n     *    @param [in] selectedRegister    The selected alternate register.\r\n     *\r\n     *    @return True, if the alternate groups are valid, otherwise false.\r\n     */\r\n    bool hasValidAlternateGroups(QSharedPointer<AlternateRegister> selectedRegister) const;\r\n\r\n    /*!\r\n     *\tCheck if a 2022 std register has a valid structure, valid combination of subelements.\r\n     *  \r\n     *    @param [in] selectedRegister     The register to check.\r\n     *\t    \r\n     * \t    @return True, if the structure is valid, otherwise false.\r\n     */\r\n    bool hasValidStructure(QSharedPointer<Register> selectedRegister) const;\r\n\r\n    /*!\r\n     *  Locate errors within a register.\r\n     *\r\n     *    @param [in] errors              List of found errors.\r\n     *    @param [in] selectedRegister    The selected register.\r\n     *    @param [in] context             Context to help locate the error.\r\n     */\r\n    void findErrorsIn(QVector<QString>& errors, QSharedPointer<Register> selectedRegister, QString const& context)\r\n        const;\r\n\r\nprivate:\r\n\r\n    /*!\r\n     *  Check if the field contains a valid access value.\r\n     *\r\n     *    @param [in] selectedRegister    The selected register definition.\r\n     *    @param [in] field               The selected field\r\n     *\r\n     *    @return True, if the access value is valid, otherwise false.\r\n     */\r\n    bool fieldHasValidAccess(QSharedPointer<RegisterDefinition> selectedRegsiter, QSharedPointer<Field> field)\r\n        const;\r\n\r\n    /*!\r\n     *  Check if the fields contain similar definition groups.\r\n     *\r\n     *    @param [in] field           The selected field.\r\n     *    @param [in] comparedField   The field being compared to\r\n     *\r\n     *    @return True, if the fields are similar, otherwise false.\r\n     */\r\n    bool fieldsHaveSimilarDefinitionGroups(QSharedPointer<Field> field, QSharedPointer<Field> comparedField) const;\r\n\r\n    /*!\r\n     *  Find errors within size.\r\n     *\r\n     *    @param [in] errors              List of found errors.\r\n     *    @param [in] selectedRegister    The selected register.\r\n     *    @param [in] context             Context to help locate the error.\r\n     */\r\n    void findErrorsInSize(QVector<QString>& errors, QSharedPointer<Register> selectedRegister,\r\n        QString const& context) const;\r\n\r\n    /*!\r\n     *  Find errors within fields.\r\n     *\r\n     *    @param [in] errors              List of found errors.\r\n     *    @param [in] selectedRegister    The selected register.\r\n     *    @param [in] context             Context to help locate the error.\r\n     */\r\n    void findErrorsInFields(QVector<QString>& errors, QSharedPointer<RegisterDefinition> selectedRegister,\r\n        QString const& registerSize, QString const& context) const;\r\n\r\n    /*!\r\n     *  Find errors within alternate registers.\r\n     *\r\n     *    @param [in] errors              List of found errors.\r\n     *    @param [in] selectedRegister    The selected register.\r\n     */\r\n    void findErrorsInAlternateRegisters(QVector<QString>& errors, QSharedPointer<Register> selectedRegister) const;\r\n\r\n    /*!\r\n     *  Find errors within alternate groups.\r\n     *\r\n     *    @param [in] errors              List of found errors.\r\n     *    @param [in] selectedRegister    The selected alternate register.\r\n     *    @param [in] context             Context to help locate the error.\r\n     */\r\n    void findErrorsInAlternateGroups(QVector<QString>& errors, QSharedPointer<AlternateRegister> selectedRegister,\r\n        QString const& context) const;\r\n\r\n    /*!\r\n     *  Find errors within the mode references of an alternate register.\r\n     *\r\n     *    @param [in] errors              List of found errors.\r\n     *    @param [in] selectedRegister    The selected register.\r\n     *    @param [in] context             Context to help locate the error.\r\n     *    @param [in] \r\n     */\r\n    void findErrorsInAlternateRegisterModeRefs(QStringList& errors,\r\n        QSharedPointer<AlternateRegister> selectedRegister, QString const& context, \r\n        QStringList& checkedModeRefs, QList<unsigned int>& checkedPriorities, \r\n        bool* duplicateRefErrorIssued, bool* duplicatePriorityErrorIssued) const;\r\n\r\n    /*!\r\n     *\tValidate single alternate register.\r\n     *  \r\n     *    @param [in] alternateRegister     The alternate register to check.\r\n     *    @param [in] selectedRegister      The parent register.\r\n     *\t    \r\n     * \t    @return  True, if the alternate register is valid, otherwise false.\r\n     */\r\n    bool alternateRegisterIsValid(QSharedPointer<AlternateRegister> alternateRegister, QSharedPointer<Register> selectedRegister) const;\r\n\r\n    /*!\r\n     *\tGet the bit width of the field taking into account the dimensions of it if std22 is in use.\r\n     *  \r\n     *    @param [in] field     The field whose width to get.\r\n     *\t    \r\n     * \t    @return The true bit width of the field.\r\n     */\r\n    quint64 getTrueFieldBitWidth(QSharedPointer<Field> field) const;\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! The validator used for fields.\r\n    QSharedPointer<FieldValidator> fieldValidator_;\r\n\r\n};\r\n\r\n#endif // REGISTERVALIDATOR_H\r\n"
  },
  {
    "path": "IPXACTmodels/Component/validators/RemapStateValidator.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: RemapStateValidator.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 27.11.2015\r\n//\r\n// Description:\r\n// Validator for the ipxact:remapState.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"RemapStateValidator.h\"\r\n\r\n#include <KactusAPI/include/ExpressionParser.h>\r\n\r\n#include <IPXACTmodels/Component/RemapState.h>\r\n#include <IPXACTmodels/Component/RemapPort.h>\r\n#include <IPXACTmodels/Component/Port.h>\r\n\r\n#include <IPXACTmodels/common/validators/CommonItemsValidator.h>\r\n\r\n#include <IPXACTmodels/utilities/Search.h>\r\n\r\n#include <QRegularExpression>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: RemapStateValidator::RemapStateValidator()\r\n//-----------------------------------------------------------------------------\r\nRemapStateValidator::RemapStateValidator(QSharedPointer<ExpressionParser> expressionParser,\r\n    QSharedPointer<QList<QSharedPointer<Port> > > ports):\r\nexpressionParser_(expressionParser),\r\navailablePorts_(ports)\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: RemapStateValidator::componentChange()\r\n//-----------------------------------------------------------------------------\r\nvoid RemapStateValidator::componentChange(QSharedPointer<QList<QSharedPointer<Port> > > newPorts)\r\n{\r\n    availablePorts_ = newPorts;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: RemapStateValidator::validate()\r\n//-----------------------------------------------------------------------------\r\nbool RemapStateValidator::validate(QSharedPointer<RemapState> remapState) const\r\n{\r\n    return hasValidName(remapState) && hasValidRemapPorts(remapState);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: RemapStateValidator::hasValidName()\r\n//-----------------------------------------------------------------------------\r\nbool RemapStateValidator::hasValidName(QSharedPointer<RemapState> remapState) const\r\n{\r\n    return CommonItemsValidator::hasValidName(remapState->name());\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: RemapStateValidator::hasValidRemapPorts()\r\n//-----------------------------------------------------------------------------\r\nbool RemapStateValidator::hasValidRemapPorts(QSharedPointer<RemapState> remapState) const\r\n{\r\n    return std::all_of(remapState->getRemapPorts()->cbegin(), remapState->getRemapPorts()->cend(),\r\n        [this](auto remapPort) \r\n        { \r\n            return remapPortHasValidPortReference(remapPort) && remapPortHasValidValue(remapPort);  \r\n        });\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: RemapStateValidator::hasValidPortReference()\r\n//-----------------------------------------------------------------------------\r\nbool RemapStateValidator::remapPortHasValidPortReference(QSharedPointer<RemapPort> remapPort) const\r\n{\r\n    auto port = Search::findByName(remapPort->getPortNameRef(), *availablePorts_);\r\n    return port.isNull() == false && remapPortHasValidIndex(remapPort, port);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: RemapStateValidator::remapPortHasValidIndex()\r\n//-----------------------------------------------------------------------------\r\nbool RemapStateValidator::remapPortHasValidIndex(QSharedPointer<RemapPort> remapPort,\r\n    QSharedPointer<Port> referencedPort) const\r\n{\r\n    if (!remapPort->getPortIndex().isEmpty())\r\n    {\r\n        bool leftOk = true;\r\n        int leftBound = expressionParser_->parseExpression(referencedPort->getLeftBound()).toInt(&leftOk);\r\n\r\n        bool rightOk = true;\r\n        int rightBound = expressionParser_->parseExpression(referencedPort->getRightBound()).toInt(&rightOk);\r\n\r\n        int maxBound = qMax(leftBound, rightBound);\r\n\r\n        bool indexOk = true;\r\n        int remapIndex = expressionParser_->parseExpression(remapPort->getPortIndex()).toInt(&indexOk);\r\n\r\n        return leftOk && rightOk && indexOk && remapIndex >= 0 && remapIndex <= maxBound;\r\n    }\r\n\r\n    return true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: RemapStateValidator::remapPortHasValidValue()\r\n//-----------------------------------------------------------------------------\r\nbool RemapStateValidator::remapPortHasValidValue(QSharedPointer<RemapPort> remapPort) const\r\n{\r\n    bool valueValid = false;\r\n    bool valueIsOk = true;\r\n    expressionParser_->parseExpression(remapPort->getValue(), &valueValid).toULongLong(&valueIsOk);\r\n\r\n    return valueValid && valueIsOk;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: RemapStateValidator::findErrorsIn()\r\n//-----------------------------------------------------------------------------\r\nvoid RemapStateValidator::findErrorsIn(QVector<QString>& errors, QSharedPointer<RemapState> remapState,\r\n    QString const& context) const\r\n{\r\n    QString const& remapStateContext = QStringLiteral(\"remap state \") + remapState->name();\r\n\r\n    findErrorsInName(errors, remapState, context);\r\n    findErrorsInRemapPorts(errors, remapState, remapStateContext);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: RemapStateValidator::findErrorsInName()\r\n//-----------------------------------------------------------------------------\r\nvoid RemapStateValidator::findErrorsInName(QVector<QString>& errors, QSharedPointer<RemapState> remapState,\r\n    QString const& context) const\r\n{\r\n    if (!hasValidName(remapState))\r\n    {\r\n        errors.append(QObject::tr(\"Invalid name specified for remap state %1 within %2\") .arg(remapState->name(),\r\n            context));\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: RemapStateValidator::findErrorsInRemapPorts()\r\n//-----------------------------------------------------------------------------\r\nvoid RemapStateValidator::findErrorsInRemapPorts(QVector<QString>& errors, QSharedPointer<RemapState> remapState,\r\n    QString const& context) const\r\n{\r\n    for (QSharedPointer<RemapPort> remapPort : *remapState->getRemapPorts())\r\n    {\r\n        findErrorsInRemapPortPortReference(errors, remapPort, context);\r\n\r\n        if (!remapPortHasValidValue(remapPort))\r\n        {\r\n            errors.append(QObject::tr(\"Invalid value set for remap port %1 within %2\").arg(\r\n                remapPort->getPortNameRef(), context));\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: RemapStateValidator::findErrorsInPortReference()\r\n//-----------------------------------------------------------------------------\r\nvoid RemapStateValidator::findErrorsInRemapPortPortReference(QVector<QString>& errors,\r\n    QSharedPointer<RemapPort> remapPort, QString const& context) const\r\n{\r\n    auto port = Search::findByName(remapPort->getPortNameRef(), *availablePorts_);\r\n    if (port.isNull())\r\n    {\r\n        errors.append(QObject::tr(\"Invalid port %1 set for %2\").arg(remapPort->getPortNameRef(), context));\r\n    }\r\n    else if (!remapPortHasValidIndex(remapPort, port))\r\n    {\r\n        errors.append(QObject::tr(\"Invalid port index set for remap port %1 within %2\").arg(\r\n            remapPort->getPortNameRef(), context));\r\n    }\r\n}\r\n"
  },
  {
    "path": "IPXACTmodels/Component/validators/RemapStateValidator.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: RemapStateValidator.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 27.11.2015\r\n//\r\n// Description:\r\n// Validator for the ipxact:remapState.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef REMAPSTATEVALIDATOR_H\r\n#define REMAPSTATEVALIDATOR_H\r\n\r\n#include <IPXACTmodels/ipxactmodels_global.h>\r\n\r\n#include <QSharedPointer>\r\n#include <QString>\r\n\r\nclass ExpressionParser;\r\nclass RemapState;\r\nclass RemapPort;\r\nclass Port;\r\n//-----------------------------------------------------------------------------\r\n//! Validator for the ipxact:remapState.\r\n//-----------------------------------------------------------------------------\r\nclass IPXACTMODELS_EXPORT RemapStateValidator\r\n{\r\npublic:\r\n\r\n\t/*!\r\n\t *  The constructor.\r\n\t *\r\n\t *    @param [in] expressionParser    The parser to use for solving expressions.\r\n     *    @param [in] ports               The available component ports.\r\n\t */\r\n    RemapStateValidator(QSharedPointer<ExpressionParser> expressionParser,\r\n        QSharedPointer<QList<QSharedPointer<Port> > > ports);\r\n\r\n\t//! The destructor.\r\n\t~RemapStateValidator() = default;\r\n    \r\n    /*!\r\n     *  Change the available ports.\r\n     *\r\n     *    @param [in] newPorts    The new ports.\r\n     */\r\n    void componentChange(QSharedPointer<QList<QSharedPointer<Port> > > newPorts);\r\n\r\n    /*!\r\n     *  Validates the given remap state.\r\n     *\r\n     *    @param [in] remapState  The remap state to validate.\r\n     *\r\n     *    @return True, if the remap state is valid IP-XACT, otherwise false.\r\n     */\r\n    bool validate(QSharedPointer<RemapState> remapState) const;\r\n\r\n    /*!\r\n     *  Check if the remap state has a valid name.\r\n     *\r\n     *    @param [in] remapState  The selected remap state.\r\n     *\r\n     *    @return True, if the name is valid IP-XACT, otherwise false.\r\n     */\r\n    bool hasValidName(QSharedPointer<RemapState> remapState) const;\r\n\r\n    /*!\r\n     *  Check if the remap state has valid remap ports.\r\n     *\r\n     *    @param [in] remapState  The selected remap state.\r\n     *\r\n     *    @return True, if the remap ports are valid IP-XACT, otherwise false.\r\n     */\r\n    bool hasValidRemapPorts(QSharedPointer<RemapState> remapState) const;\r\n\r\n    /*!\r\n     *  Locate errors within a remap state.\r\n     *\r\n     *    @param [in] errors      List of found errors.\r\n     *    @param [in] remapState  The selected remap state.\r\n     *    @param [in] context     Context to help locate the error.\r\n     */\r\n    void findErrorsIn(QVector<QString>& errors, QSharedPointer<RemapState> remapState, QString const& context)\r\n        const;\r\n\r\nprivate:\r\n\r\n\t// Disable copying.\r\n\tRemapStateValidator(RemapStateValidator const& rhs);\r\n\tRemapStateValidator& operator=(RemapStateValidator const& rhs);\r\n    \r\n    /*!\r\n     *  Check if the remap port has a valid port reference.\r\n     *\r\n     *    @param [in] remapPort   The selected remap port.\r\n     *\r\n     *    @return True, if the port reference is valid IP-XACT, otherwise false.\r\n     */\r\n    bool remapPortHasValidPortReference(QSharedPointer<RemapPort> remapPort) const;\r\n\r\n    /*!\r\n     *  Check if the remap port has a valid port index.\r\n     *\r\n     *    @param [in] remapPort       The selected remap port.\r\n     *    @param [in] referencedPort  The port referenced by the remap port.\r\n     *\r\n     *    @return True, if the port index is valid IP-XACT, otherwise false.\r\n     */\r\n    bool remapPortHasValidIndex(QSharedPointer<RemapPort> remapPort, QSharedPointer<Port> referencedPort) const;\r\n\r\n    /*!\r\n     *  Check if the remap port has a valid value.\r\n     *\r\n     *    @param [in] remapPort   The selected remap port.\r\n     *\r\n     *    @return True, if the value is valid IP-XACT, otherwise false.\r\n     */\r\n    bool remapPortHasValidValue(QSharedPointer<RemapPort> remapPort) const;\r\n\r\n    /*!\r\n     *  Find errors within a name.\r\n     *\r\n     *    @param [in] errors      List of found errors.\r\n     *    @param [in] remapState  The selected remap state.\r\n     *    @param [in] context     Context to help locate the error.\r\n     */\r\n    void findErrorsInName(QVector<QString>& errors, QSharedPointer<RemapState> remapState, QString const& context)\r\n        const;\r\n\r\n    /*!\r\n     *  Find errors within remap ports.\r\n     *\r\n     *    @param [in] errors      List of found errors.\r\n     *    @param [in] remapState  The selected remap state.\r\n     *    @param [in] context     Context to help locate the error.\r\n     */\r\n    void findErrorsInRemapPorts(QVector<QString>& errors, QSharedPointer<RemapState> remapState,\r\n        QString const& context) const;\r\n\r\n    /*!\r\n     *  Find errors within remap port port reference.\r\n     *\r\n     *    @param [in] errors      List of found errors.\r\n     *    @param [in] remapPort   The selected remap port.\r\n     *    @param [in] context     Context to help locate the error.\r\n     */\r\n    void findErrorsInRemapPortPortReference(QVector<QString>& errors, QSharedPointer<RemapPort> remapPort,\r\n        QString const& context) const;\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! The used expression parser.\r\n    QSharedPointer<ExpressionParser> expressionParser_;\r\n\r\n    //! A list of available remap ports.\r\n    QSharedPointer<QList<QSharedPointer<Port> > > availablePorts_;\r\n};\r\n\r\n#endif // REMAPSTATEVALIDATOR_H\r\n"
  },
  {
    "path": "IPXACTmodels/Component/validators/SubspaceMapValidator.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: SubspaceMapValidator.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Mikko Teuho\n// Date: 16.02.2022\n//\n// Description:\n// Validator for ipxact:subspaceMap.\n//-----------------------------------------------------------------------------\n\n#include \"SubspaceMapValidator.h\"\n\n#include <IPXACTmodels/Component/Component.h>\n#include <IPXACTmodels/Component/SubSpaceMap.h>\n#include <IPXACTmodels/Component/AddressSpace.h>\n#include <IPXACTmodels/Component/BusInterface.h>\n#include <IPXACTmodels/Component/Segment.h>\n\n//-----------------------------------------------------------------------------\n// Function: SubspaceMapValidator::SubspaceMapValidator()\n//-----------------------------------------------------------------------------\nSubspaceMapValidator::SubspaceMapValidator(QSharedPointer<ExpressionParser> expressionParser,\n    QSharedPointer<ParameterValidator> parameterValidator,\n    Document::Revision docRevision) :\nMemoryBlockValidator(expressionParser, parameterValidator, docRevision),\navailableBuses_(),\navailableSpaces_()\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: SubspaceMapValidator::getBlockType()\n//-----------------------------------------------------------------------------\nQString SubspaceMapValidator::getBlockType() const\n{\n    return QStringLiteral(\"subspace map\");\n}\n\n//-----------------------------------------------------------------------------\n// Function: SubspaceMapValidator::componentChange()\n//-----------------------------------------------------------------------------\nvoid SubspaceMapValidator::componentChange(QSharedPointer<Component> component)\n{\n    availableBuses_.clear();\n    availableSpaces_.clear();\n\n    if (component)\n    {\n        availableBuses_ = component->getBusInterfaces();\n        availableSpaces_ = component->getAddressSpaces();\n        docRevision_ = component->getRevision();\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: SubspaceMapValidator::validate()\n//-----------------------------------------------------------------------------\nbool SubspaceMapValidator::validate(QSharedPointer<SubSpaceMap> subspace) const\n{\n    return MemoryBlockValidator::validate(subspace) &&\n        hasValidMasterReference(subspace) &&\n        hasValidSegmentReference(subspace);\n}\n\n//-----------------------------------------------------------------------------\n// Function: SubspaceMapValidator::hasValidMasterReference()\n//-----------------------------------------------------------------------------\nbool SubspaceMapValidator::hasValidMasterReference(QSharedPointer<SubSpaceMap> subspace) const\n{\n    QString masterReference = subspace->getInitiatorReference();\n    if (masterReference.isEmpty() || !masterReferenceExists(masterReference) ||\n        !referencedBusIsMaster(masterReference))\n    {\n        return false;\n    }\n\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: SubspaceMapValidator::masterReferenceExists()\n//-----------------------------------------------------------------------------\nbool SubspaceMapValidator::masterReferenceExists(QString const& masterReference) const\n{\n    QSharedPointer<BusInterface> bus = getReferencedBusInterface(masterReference);\n    if (bus)\n    {\n        return true;\n    }\n\n    return false;\n}\n\n//-----------------------------------------------------------------------------\n// Function: SubspaceMapValidator::getReferencedBusInterface()\n//-----------------------------------------------------------------------------\nQSharedPointer<BusInterface> SubspaceMapValidator::getReferencedBusInterface(QString const& masterReference) const\n{\n    for (auto busInterface : *availableBuses_)\n    {\n        if (busInterface->name() == masterReference)\n        {\n            return busInterface;\n        }\n    }\n\n    return QSharedPointer<BusInterface>();\n}\n\n//-----------------------------------------------------------------------------\n// Function: SubspaceMapValidator::referencedBusIsMaster()\n//-----------------------------------------------------------------------------\nbool SubspaceMapValidator::referencedBusIsMaster(QString const& masterReference) const\n{\n    QSharedPointer<BusInterface> bus = getReferencedBusInterface(masterReference);\n    if (bus && bus->getInterfaceMode() == General::MASTER && docRevision_ == Document::Revision::Std14)\n    {\n        return true;\n    }\n    else if (bus && bus->getInterfaceMode() == General::INITIATOR && docRevision_ == Document::Revision::Std22)\n    {\n        return true;\n    }\n\n    return false;\n}\n\n//-----------------------------------------------------------------------------\n// Function: SubspaceMapValidator::hasValidSegmentReference()\n//-----------------------------------------------------------------------------\nbool SubspaceMapValidator::hasValidSegmentReference(QSharedPointer<SubSpaceMap> subspace) const\n{\n    QString segmentReference = subspace->getSegmentReference();\n    if (segmentReference.isEmpty() ||\n        spaceContainsSegmentReference(subspace->getInitiatorReference(), segmentReference))\n    {\n        return true;\n    }\n\n    return false;\n}\n\n//-----------------------------------------------------------------------------\n// Function: SubspaceMapValidator::spaceContainsSegmentReference()\n//-----------------------------------------------------------------------------\nbool SubspaceMapValidator::spaceContainsSegmentReference(QString const& masterReference,\n    QString const& segmentReference) const\n{\n    QSharedPointer<AddressSpace> space = getReferencedSpace(masterReference);\n    if (space)\n    {\n        for (auto segment : *space->getSegments())\n        {\n            if (segment->name() == segmentReference)\n            {\n                return true;\n            }\n        }\n    }\n\n    return false;\n}\n\n//-----------------------------------------------------------------------------\n// Function: SubspaceMapValidator::getReferencedSpace()\n//-----------------------------------------------------------------------------\nQSharedPointer<AddressSpace> SubspaceMapValidator::getReferencedSpace(QString const& masterReference) const\n{\n    QSharedPointer<BusInterface> bus = getReferencedBusInterface(masterReference);\n    if (bus)\n    {\n        for (auto space : *availableSpaces_)\n        {\n            if (space->name() == bus->getAddressSpaceRef())\n            {\n                return space;\n            }\n        }\n    }\n\n    return QSharedPointer<AddressSpace>();\n}\n\n//-----------------------------------------------------------------------------\n// Function: SubspaceMapValidator::findErrorsIn()\n//-----------------------------------------------------------------------------\nvoid SubspaceMapValidator::findErrorsIn(QVector<QString>& errors, QSharedPointer<SubSpaceMap> subspace,\n    QString const& context) const\n{\n    QString subspaceContext = getBlockType() + QStringLiteral(\" \") + subspace->name();\n\n    findErrorsInName(errors, subspace, context);\n    findErrorsInIsPresent(errors, subspace, context);\n    findErrorsInBaseAddress(errors, subspace, context);\n    findErrorsInMasterReference(errors, subspace, context);\n    findErrorsInSegmentReference(errors, subspace, context);\n\n    findErrorsInParameters(errors, subspace, subspaceContext);\n}\n\n//-----------------------------------------------------------------------------\n// Function: SubspaceMapValidator::findErrorsInMasterReference()\n//-----------------------------------------------------------------------------\nvoid SubspaceMapValidator::findErrorsInMasterReference(QVector<QString>& errors,\n    QSharedPointer<SubSpaceMap> subspace, QString const& context) const\n{\n    \n\n    QString masterReference = subspace->getInitiatorReference();\n    if (masterReference.isEmpty())\n    {\n        if (docRevision_ == Document::Revision::Std14)\n        {\n            errors.append(\n                QObject::tr(\"A master bus interface reference is not specified in subspace map %1 within %2\").\n                arg(subspace->name(), context));\n        }\n        else if (docRevision_ == Document::Revision::Std22)\n        {\n            errors.append(\n                QObject::tr(\"An initiator bus interface reference is not specified in subspace map %1 within %2\").\n                arg(subspace->name(), context));\n        }\n    }\n    else if (!masterReferenceExists(masterReference))\n    {\n        errors.append(QObject::tr(\"Bus interface %1 referenced in %2 within %3 does not exist\").\n            arg(masterReference, subspace->name(), context));\n    }\n    else if (!referencedBusIsMaster(masterReference))\n    {\n        if (docRevision_ == Document::Revision::Std14)\n        {\n            errors.append(QObject::tr(\"Bus interface %1 referenced in %2 within %3 is not a master\").\n                arg(masterReference, subspace->name(), context));\n        }\n        else if (docRevision_ == Document::Revision::Std22)\n        {\n            errors.append(QObject::tr(\"Bus interface %1 referenced in %2 within %3 is not an initiator\").\n                arg(masterReference, subspace->name(), context));\n        }\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: SubspaceMapValidator::findErrorsInSegmentReference()\n//-----------------------------------------------------------------------------\nvoid SubspaceMapValidator::findErrorsInSegmentReference(QVector<QString>& errors,\n    QSharedPointer<SubSpaceMap> subspace, QString const& context) const\n{\n    QString segmentReference = subspace->getSegmentReference();\n    if (!segmentReference.isEmpty() &&\n        !spaceContainsSegmentReference(subspace->getInitiatorReference(), segmentReference))\n    {\n        errors.append(QObject::tr(\n            \"Segment %1 does not exist in address space of bus interface %2 referenced in %3 within %4\").\n            arg(segmentReference, subspace->getInitiatorReference(), subspace->name(), context));\n    }\n}\n"
  },
  {
    "path": "IPXACTmodels/Component/validators/SubspaceMapValidator.h",
    "content": "//-----------------------------------------------------------------------------\n// File: SubspaceMapValidator.h\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Mikko Teuho\n// Date: 16.02.2022\n//\n// Description:\n// Validator for ipxact:subspaceMap.\n//-----------------------------------------------------------------------------\n\n#ifndef SUBSPACEMAPVALIDATOR_H\n#define SUBSPACEMAPVALIDATOR_H\n\n#include <IPXACTmodels/ipxactmodels_global.h>\n\n#include <IPXACTmodels/Component/validators/MemoryBlockValidator.h>\n\n#include <QSharedPointer>\n#include <QString>\n\nclass SubSpaceMap;\nclass Component;\nclass BusInterface;\nclass AddressSpace;\n\n//-----------------------------------------------------------------------------\n//! Validator for ipxact:subspaceMap.\n//-----------------------------------------------------------------------------\nclass IPXACTMODELS_EXPORT SubspaceMapValidator : public MemoryBlockValidator\n{\npublic:\n\n\t/*!\n\t *  The constructor.\n\t *\n\t *    @param [in] expressionParser    The parser to use for solving expressions.\n     *    @param [in] parameterValidator  Validator used for parameters.\n\t */\n    SubspaceMapValidator(QSharedPointer<ExpressionParser> expressionParser, \n        QSharedPointer<ParameterValidator> parameterValidator, Document::Revision docRevision);\n\n\t/*!\n     *  The destructor.\n     */\n    virtual ~SubspaceMapValidator() = default;\n    \n    /*!\n     *  Change the containing component.\n     *\n     *    @param [in] component   The new component.\n     */\n    void componentChange(QSharedPointer<Component> component);\n\n    /*!\n     *  Validates the given subspace map.\n     *\n     *    @param [in] subspace    The subspace map to validate.\n     *\n     *    @return True, if the subspace map is valid IP-XACT, otherwise false.\n     */\n    bool validate(QSharedPointer<SubSpaceMap> subspace) const;\n\n    /*!\n     *  Check if the selected subspace map has a valid master bus interface reference.\n     *\n     *    @param [in] subspace    The selected subspace map.\n     *\n     *    @return True, if the master bus interface reference is valid, false otherwise.\n     */\n    bool hasValidMasterReference(QSharedPointer<SubSpaceMap> subspace) const;\n\n    /*!\n     *  Check if the selected subspace map has a valid segment reference.\n     *\n     *    @param [in] subspace    The selected subspace map.\n     *\n     *    @return True, if the segment reference is valid, false otherwise.\n     */\n    bool hasValidSegmentReference(QSharedPointer<SubSpaceMap> subspace) const;\n\n    /*!\n     *  Locate errors within a subspace map.\n     *\n     *    @param [in] errors      List of found errors.\n     *    @param [in] subspace    The selected subspace map.\n     *    @param [in] context     Context to help locate the error.\n     */\n    void findErrorsIn(QVector<QString>& errors, QSharedPointer<SubSpaceMap> subspace, QString const& context)\n        const;\n\nprivate:\n\n\t// Disable copying.\n\tSubspaceMapValidator(SubspaceMapValidator const& rhs);\n    SubspaceMapValidator& operator=(SubspaceMapValidator const& rhs);\n\n    /*!\n     *  Get the type of the memory block.\n     *\n     *    @return Identification type of the memory block.\n     */\n    virtual QString getBlockType() const override final;\n\n    /*!\n     *  Check if the referenced master bus interface exists.\n     *\n     *    @param [in] masterReference     Reference to the selected master bus interface.\n     *\n     *    @return True, if the master bus interface reference exists, false otherwise.\n     */\n    bool masterReferenceExists(QString const& masterReference) const;\n\n    /*!\n     *  Check if the referenced bus interface is master.\n     *\n     *    @param [in] masterReference     Reference to the selected bus interface.\n     *\n     *    @return True, if the bus interface is master, false otherwise.\n     */\n    bool referencedBusIsMaster(QString const& masterReference) const;\n\n    /*!\n     *  Check if the address space within the selected master bus interface contains the selected segment.\n     *\n     *    @param [in] masterReference     Reference to the selected master bus interface.\n     *    @param [in] segmentReference    Reference to the selected segment.\n     *\n     *    @return True, if the address space contains the selected segment, false otherwise.\n     */\n    bool spaceContainsSegmentReference(QString const& masterReference, QString const& segmentReference) const;\n\n    /*!\n     *  Get the selected bus interface.\n     *\n     *    @param [in] masterReference     Reference to the selected bus interface.\n     *\n     *    @return The selected bus interface.\n     */\n    QSharedPointer<BusInterface> getReferencedBusInterface(QString const& masterReference) const;\n\n    /*!\n     *  Get the address space within the selected master bus interface.\n     *\n     *    @param [in] masterReference     Reference to the selected bus interface.\n     *\n     *    @return Address space within the selected master bus interface.\n     */\n    QSharedPointer<AddressSpace> getReferencedSpace(QString const& masterReference) const;\n\n    /*!\n     *  Find errors within master bus interface reference.\n     *\n     *    @param [in] errors      List of found errors.\n     *    @param [in] subspace    The selected subspace map.\n     *    @param [in] context     Context to help locate the error.\n     */\n    void findErrorsInMasterReference(QVector<QString>& errors, QSharedPointer<SubSpaceMap> subspace,\n        QString const& context) const;\n\n    /*!\n     *  Find errors within segment reference.\n     *\n     *    @param [in] errors      List of found errors.\n     *    @param [in] subspace    The selected subspace map.\n     *    @param [in] context     Context to help locate the error.\n     */\n    void findErrorsInSegmentReference(QVector<QString>& errors, QSharedPointer<SubSpaceMap> subspace,\n        QString const& context) const;\n\n    //-----------------------------------------------------------------------------\n    // Data.\n    //-----------------------------------------------------------------------------\n\n    //! List of available bus interfaces.\n    QSharedPointer<QList<QSharedPointer<BusInterface> > > availableBuses_;\n\n    //! List of available address spaces.\n    QSharedPointer<QList<QSharedPointer<AddressSpace> > > availableSpaces_;\n};\n\n#endif // SUBSPACEMAPVALIDATOR_H\n"
  },
  {
    "path": "IPXACTmodels/Component/validators/ViewValidator.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// View: ViewValidator.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Janne Virtanen\r\n// Date: 24.11.2015\r\n//\r\n// Description:\r\n// Validator for ipxact:View.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"ViewValidator.h\"\r\n\r\n#include <IPXACTmodels/Component/Model.h>\r\n\r\n#include <KactusAPI/include/ExpressionParser.h>\r\n\r\n#include <QRegularExpression>\r\n#include <QStringList>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ViewValidator::ViewValidator()\r\n//-----------------------------------------------------------------------------\r\nViewValidator::ViewValidator(QSharedPointer<ExpressionParser> expressionParser, QSharedPointer<Model> model):\r\nexpressionParser_(expressionParser),\r\nmodel_(model)\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ViewValidator::componentChange()\r\n//-----------------------------------------------------------------------------\r\nvoid ViewValidator::componentChange(QSharedPointer<Model> newModel)\r\n{\r\n    model_ = newModel;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ViewValidator::validateInstantiation()\r\n//-----------------------------------------------------------------------------\r\nbool ViewValidator::validate(QSharedPointer<View> view) const\r\n{\r\n    return hasValidName(view->name()) && hasValidIsPresent(view) && hasValidEnvironmentIdentifiers(view) &&\r\n        hasValidComponentInstantiationReference(view) && hasValidDesignInstantiationReference(view) &&\r\n        hasValidDesignConfigurationInstantiationReference(view) && validComparedToSiblings(view);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ViewValidator::hasValidName()\r\n//-----------------------------------------------------------------------------\r\nbool ViewValidator::hasValidName(QString const& name) const\r\n{\r\n    QRegularExpression whiteSpaceExpression;\r\n    whiteSpaceExpression.setPattern(QStringLiteral(\"^\\\\s*$\"));\r\n    QRegularExpressionMatch whiteSpaceMatch = whiteSpaceExpression.match(name);\r\n\r\n    if (name.isEmpty() || whiteSpaceMatch.hasMatch())\r\n    {\r\n        return false;\r\n    }\r\n\r\n    return true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ViewValidator::hasValidIsPresent()\r\n//-----------------------------------------------------------------------------\r\nbool ViewValidator::hasValidIsPresent(QSharedPointer<View> view) const\r\n{\r\n    if (!view->getIsPresent().isEmpty())\r\n    {\r\n        bool isPresentOk = false;\r\n        QString solvedValue = expressionParser_->parseExpression(view->getIsPresent(), &isPresentOk);\r\n\r\n        int intValue = solvedValue.toInt();\r\n\r\n        return isPresentOk && (intValue == 0 || intValue == 1);\r\n    }\r\n\r\n    return true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ViewValidator::hasValidEnvironmentIdentifiers()\r\n//-----------------------------------------------------------------------------\r\nbool ViewValidator::hasValidEnvironmentIdentifiers(QSharedPointer<View> view) const\r\n{\r\n    for ( QSharedPointer<View::EnvironmentIdentifier> const& envId : *view->getEnvIdentifiers() )\r\n    {\r\n        if ( !isValidEnvId( envId ) )\r\n        {\r\n            return false;\r\n        }\r\n    }\r\n    return true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ViewValidator::isValidEnvId()\r\n//-----------------------------------------------------------------------------\r\nbool ViewValidator::isValidEnvId(QSharedPointer<View::EnvironmentIdentifier> const& envId) const\r\n{\r\n    QRegularExpression envIdExpression;\r\n\tenvIdExpression.setPattern(QStringLiteral(\"[A-Za-z0-9_+\\\\*\\\\.]*\"));\r\n\r\n\tQRegularExpressionMatch envIdMatchLanguage = envIdExpression.match(envId->language);\r\n    if (!envId->language.isEmpty() && !envIdMatchLanguage.hasMatch())\r\n    {\r\n        return false;\r\n    }\r\n    \r\n    QRegularExpressionMatch envIdMatchTool = envIdExpression.match(envId->tool);\r\n    if (!envId->tool.isEmpty() && !envIdMatchTool.hasMatch())\r\n    {\r\n        return false;\r\n    }\r\n\r\n    QRegularExpressionMatch envIdMatchVendor = envIdExpression.match(envId->vendorSpecific);\r\n\tif ( !envId->vendorSpecific.isEmpty() && !envIdMatchVendor.hasMatch() )\r\n\t{\r\n\t\treturn false;\r\n\t}\r\n\r\n    return true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ViewValidator::hasValidComponentInstantiationReference()\r\n//-----------------------------------------------------------------------------\r\nbool ViewValidator::hasValidComponentInstantiationReference(QSharedPointer<View> view) const\r\n{\r\n    if ( !view->getComponentInstantiationRef().isEmpty() &&\r\n        !model_->findComponentInstantiation( view->getComponentInstantiationRef() ) )\r\n    {\r\n        return false;\r\n    }\r\n\r\n    return true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ViewValidator::hasValidDesignInstantiationReference()\r\n//-----------------------------------------------------------------------------\r\nbool ViewValidator::hasValidDesignInstantiationReference(QSharedPointer<View> view) const\r\n{\r\n    if ( !view->getDesignInstantiationRef().isEmpty() &&\r\n        !model_->findDesignInstantiation( view->getDesignInstantiationRef() ) )\r\n    {\r\n        return false;\r\n    }\r\n\r\n    return true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ViewValidator::hasValidDesignConfigurationInstantiationReference()\r\n//-----------------------------------------------------------------------------\r\nbool ViewValidator::hasValidDesignConfigurationInstantiationReference(QSharedPointer<View> view) const\r\n{\r\n    if ( !view->getDesignConfigurationInstantiationRef().isEmpty() &&\r\n        !model_->findDesignConfigurationInstantiation( view->getDesignConfigurationInstantiationRef() ) )\r\n    {\r\n        return false;\r\n    }\r\n\r\n    return true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ViewValidator::findErrorsIn()\r\n//-----------------------------------------------------------------------------\r\nvoid ViewValidator::findErrorsIn(QVector<QString>& errors, QSharedPointer<View> view, QString const& contex) const\r\n{\r\n\tif ( !hasValidName( view->name() ) )\r\n\t{\r\n\t\terrors.append(QObject::tr(\"Invalid name specified for view %1 within %2\").arg(view->name()).arg(contex));\r\n\t}\r\n\r\n    if (!hasValidIsPresent(view))\r\n\t{\r\n\t\terrors.append(QObject::tr(\"The presence %1 is invalid in view %2\")\r\n            .arg(view->getIsPresent()).arg(view->name()));\r\n\t}\r\n\r\n\tfor ( QSharedPointer<View::EnvironmentIdentifier> const& envId : *view->getEnvIdentifiers() )\r\n\t{\r\n\t\tif ( !isValidEnvId( envId ) )\r\n\t\t{\r\n\t\t\terrors.append(QObject::tr(\"The env identifier %1 is invalid in view %2\").arg(envId->toString()).arg(view->name()));\r\n\t\t}\r\n\t}\r\n\r\n    if (!hasValidComponentInstantiationReference(view))\r\n\t{\r\n\t\terrors.append(QObject::tr(\"Referring non-existing component instantiation %1 in view %2\")\r\n\t\t\t.arg(view->getComponentInstantiationRef()).arg(view->name()));\r\n\t}\r\n\r\n    if (!hasValidDesignInstantiationReference(view))\r\n\t{\r\n\t\terrors.append(QObject::tr(\"Referring non-existing design instantiation %1 in view %2\")\r\n\t\t\t.arg(view->getDesignInstantiationRef()).arg(view->name()));\r\n\t}\r\n\r\n    if (!hasValidDesignConfigurationInstantiationReference(view))\r\n\t{\r\n\t\terrors.append(QObject::tr(\"Referring non-existing design configuration instantiation %1 in view %2\")\r\n\t\t\t.arg(view->getDesignConfigurationInstantiationRef()).arg(view->name()));\r\n\t}\r\n}\r\n"
  },
  {
    "path": "IPXACTmodels/Component/validators/ViewValidator.h",
    "content": "//-----------------------------------------------------------------------------\r\n// View: ViewValidator.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Janne Virtanen\r\n// Date: 24.11.2015\r\n//\r\n// Description:\r\n// Validator for ipxact:View.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef ViewVALIDATOR_H\r\n#define ViewVALIDATOR_H\r\n\r\n#include <IPXACTmodels/ipxactmodels_global.h>\r\n#include <IPXACTmodels/Component/View.h>\r\n\r\n#include <IPXACTmodels/Component/validators/CollectionValidators.h>\r\n\r\n#include <QString>\r\n#include <QVector>\r\n#include <QSharedPointer>\r\n\r\nclass ExpressionParser;\r\nclass Model;\r\nclass ComponentInstantiation;\r\nclass DesignInstantiation;\r\nclass DesignConfigurationInstantiation;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Validator for ipxact:View.\r\n//-----------------------------------------------------------------------------\r\nclass IPXACTMODELS_EXPORT ViewValidator : public HierarchicalValidator\r\n{\r\npublic:\r\n\r\n\t/*!\r\n\t *  The constructor.\r\n     *\r\n     *    @param [in] expressionParser    The used expression parser.\r\n\t *    @param [in] model               The containing component model.\r\n\t */\r\n    ViewValidator(QSharedPointer<ExpressionParser> expressionParser, QSharedPointer<Model> model);\r\n\r\n\t//! The destructor.\r\n\t~ViewValidator() = default;\r\n\r\n    /*!\r\n     *  Change the available model.\r\n     *\r\n     *    @param [in] newModel    The new model.\r\n     */\r\n    void componentChange(QSharedPointer<Model> newModel);\r\n\r\n    /*!\r\n     *  Validates the given View.\r\n     *\r\n     *    @param [in] View    The View to validate.\r\n     *\r\n     *    @return True, if the View is valid IP-XACT, otherwise false.\r\n     */\r\n    bool validate(QSharedPointer<View> view) const;\r\n\r\n    /*!\r\n     *  Check if the name is valid.\r\n     *\r\n     *    @param [in] name    The name to be evaluated.\r\n     *\r\n     *    @return True, if the name is valid, otherwise false.\r\n     */\r\n\tbool hasValidName(QString const& name) const;\r\n\t\r\n    /*!\r\n     *  Check if the is present value is valid.\r\n     *\r\n     *    @param [in] view    The selected view.\r\n     *\r\n     *    @return True, if the is present value is valid, otherwise false.\r\n     */\r\n    bool hasValidIsPresent(QSharedPointer<View> view) const;\r\n\r\n    /*!\r\n     *  Check if the environment identifiers are valid.\r\n     *\r\n     *    @param [in] view    The selected view.\r\n     *\r\n     *    @return True, if the environment identifiers are valid, otherwise false.\r\n     */\r\n    bool hasValidEnvironmentIdentifiers(QSharedPointer<View> view) const;\r\n\r\n    /*!\r\n     *  Check if the component instantiation reference is valid.\r\n     *\r\n     *    @param [in] view    The selected view.\r\n     *\r\n     *    @return True, if the component instantiation reference is valid, otherwise false.\r\n     */\r\n    bool hasValidComponentInstantiationReference(QSharedPointer<View> view) const;\r\n\r\n    /*!\r\n     *  Check if the is design instantiation reference is valid.\r\n     *\r\n     *    @param [in] view    The selected view.\r\n     *\r\n     *    @return True, if the design instantiation reference is valid, otherwise false.\r\n     */\r\n    bool hasValidDesignInstantiationReference(QSharedPointer<View> view) const;\r\n\r\n    /*!\r\n     *  Check if the design configuration reference is valid.\r\n     *\r\n     *    @param [in] view    The selected view.\r\n     *\r\n     *    @return True, if the is design configuration reference is valid, otherwise false.\r\n     */\r\n    bool hasValidDesignConfigurationInstantiationReference(QSharedPointer<View> view) const;\r\n\r\n    /*!\r\n     *  Check if an environment identifier is valid.\r\n     *\r\n     *    @param [in] name    The environment identifier to be evaluated.\r\n     *\r\n     *    @return True, if the environment identifier is valid, otherwise false.\r\n     */\r\n\tbool isValidEnvId(QSharedPointer<View::EnvironmentIdentifier> const& envId) const;\r\n\r\n    /*!\r\n     *  Finds possible errors in a View and creates a list of them.\r\n     *\r\n     *    @param [in] errors      List of found errors.\r\n     *    @param [in] View        The View whose errors to find.\r\n     *    @param [in] context     Context to help locate the errors.\r\n     */\r\n    void findErrorsIn(QVector<QString>& errors, QSharedPointer<View> view, QString const& contex) const;\r\n\r\nprivate:\r\n\r\n\t// Disable copying.\r\n\tViewValidator(ViewValidator const& rhs);\r\n\tViewValidator& operator=(ViewValidator const& rhs);\r\n\r\n    //! The used expression parser.\r\n    QSharedPointer<ExpressionParser> expressionParser_;\r\n\r\n    //! The containing component model.\r\n    QSharedPointer<Model> model_;\r\n};\r\n\r\n#endif // SYSTEMVERILOGVALIDATOR_H\r\n"
  },
  {
    "path": "IPXACTmodels/Design/ActiveInterface.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ActiveInterface.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 21.08.2015\r\n//\r\n// Description:\r\n// Describes the ipxact:activeInterface element in an IP-XACT document.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"ActiveInterface.h\"\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ActiveInterface::ActiveInterface()\r\n//-----------------------------------------------------------------------------\r\nActiveInterface::ActiveInterface(QString const& componentRef, QString const& busRef):\r\nHierInterface(busRef),\r\ncomponentRef_(componentRef)\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ActiveInterface::ActiveInterface()\r\n//-----------------------------------------------------------------------------\r\nActiveInterface::ActiveInterface(const ActiveInterface& other) :\r\nHierInterface(other),\r\ncomponentRef_(other.componentRef_)\r\n{\r\n    for (QString const& portName : *other.excludePorts_)\r\n    {\r\n        excludePorts_->append(portName);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ActiveInterface::operator=()\r\n//-----------------------------------------------------------------------------\r\nActiveInterface& ActiveInterface::operator=(const ActiveInterface& other)\r\n{\r\n    if (this != &other)\r\n    {\r\n        HierInterface::operator=(other);\r\n        componentRef_ = other.componentRef_;\r\n\r\n        excludePorts_->clear();\r\n        for (QString const& portName : *other.excludePorts_)\r\n        {\r\n            excludePorts_->append(portName);\r\n        }\r\n    }\r\n\r\n    return *this;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ActiveInterface::operator==()\r\n//-----------------------------------------------------------------------------\r\nbool ActiveInterface::operator==(const ActiveInterface& other) const\r\n{\r\n    return (HierInterface::operator==(other)) &&\r\n        (componentRef_.compare(other.componentRef_, Qt::CaseInsensitive) == 0);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ActiveInterface::operator!=()\r\n//-----------------------------------------------------------------------------\r\nbool ActiveInterface::operator!=(const ActiveInterface& other) const\r\n{\r\n    return !operator==(other);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ActiveInterface::operator<()\r\n//-----------------------------------------------------------------------------\r\nbool ActiveInterface::operator<(const ActiveInterface& other) const\r\n{\r\n    int busRefeferencecomparison = HierInterface::operator<(other);\r\n    if (busRefeferencecomparison == 0)\r\n    {\r\n        return componentRef_.compare(other.componentRef_, Qt::CaseInsensitive) < 0;\r\n    }\r\n    else\r\n    {\r\n        return busRefeferencecomparison < 0;\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ActiveInterface::references()\r\n//-----------------------------------------------------------------------------\r\nbool ActiveInterface::references(QString const& instanceName, QString const& busInterfaceName) const\r\n{\r\n    return instanceName == componentRef_ && busInterfaceName == getBusReference();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ActiveInterface::getComponentReference()\r\n//-----------------------------------------------------------------------------\r\nQString ActiveInterface::getComponentReference() const\r\n{\r\n    return componentRef_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ActiveInterface::setComponentReference()\r\n//-----------------------------------------------------------------------------\r\nvoid ActiveInterface::setComponentReference(QString const& newComponentReference)\r\n{\r\n    componentRef_ = newComponentReference;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ActiveInterface::getExcludePorts()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<QStringList> ActiveInterface::getExcludePorts() const\r\n{\r\n    return excludePorts_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ActiveInterface::setExcludePorts()\r\n//-----------------------------------------------------------------------------\r\nvoid ActiveInterface::setExcludePorts(QSharedPointer<QStringList> newExcludePorts)\r\n{\r\n    excludePorts_ = newExcludePorts;\r\n}\r\n"
  },
  {
    "path": "IPXACTmodels/Design/ActiveInterface.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ActiveInterface.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 20.08.2015\r\n//\r\n// Description:\r\n// Describes the ipxact:activeInterface element in an IP-XACT document.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef ACTIVEINTERFACE_H\r\n#define ACTIVEINTERFACE_H\r\n\r\n#include \"HierInterface.h\"\r\n\r\n#include <IPXACTmodels/ipxactmodels_global.h>\r\n\r\n#include <QStringList>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Ipxact:activeInterface element.\r\n//-----------------------------------------------------------------------------\r\nclass IPXACTMODELS_EXPORT ActiveInterface : public HierInterface\r\n{\r\n\r\npublic:\r\n\r\n    /*!\r\n     *  The constructor.\r\n     *\r\n     *    @param [in] componentRef    The name of the referenced component instance.\r\n     *    @param [in] busRef          The name of the referenced bus interface.\r\n     */\r\n    ActiveInterface(QString const& componentRef = QString(), QString const& busRef = QString());\r\n\r\n    /*!\r\n     *  Copy constructor.\r\n     */\r\n    ActiveInterface(const ActiveInterface& other);\r\n    \r\n    /*!\r\n     *  The destructor.\r\n     */\r\n    ~ActiveInterface() final = default;\r\n\r\n    /*!\r\n     *  Assignment operator.\r\n     */\r\n    ActiveInterface& operator=(const ActiveInterface& other);\r\n\r\n    /*!\r\n     *  Comparison operator.\r\n     *\r\n     *    @return True, if the interfaces refer the same component and bus interface, otherwise false.\r\n     */\r\n    bool operator==(const ActiveInterface& other) const;\r\n\r\n    /*!\r\n     *  The != operator.\r\n     */\r\n    bool operator!=(const ActiveInterface& other) const;\r\n\r\n    /*!\r\n     *  The operator <.\r\n     *\r\n     *    @return The operator uses QString to compare instance names and bus interface names.\r\n     */\r\n    bool operator<(const ActiveInterface& other) const;\r\n\r\n    /*!\r\n     *  Checks if the interface referenced a given instance and a bus interface.\r\n     *\r\n     *    @param [in] instanceName        The name of the component instance to compare to.\r\n     *    @param [in] busInterfaceName    The name of the bus interface to compare to.\r\n     *\r\n     *    @return True, if the given instance and bus interface are reference by the interface.\r\n     */\r\n    bool references(QString const& instanceName, QString const& busInterfaceName) const;\r\n\r\n    /*!\r\n     *  Get the referenced component.\r\n     *\r\n     *    @return The name of the referenced component.\r\n     */\r\n    QString getComponentReference() const;\r\n\r\n    /*!\r\n     *  Set a new component referenced.\r\n     *\r\n     *    @param [in] newComponentReference   The new component reference.\r\n     */\r\n    void setComponentReference(QString const& newComponentReference);\r\n\r\n    /*!\r\n     *  Get a list of excluded ports.\r\n     *\r\n     *    @return Pointer to a list containing the excluded ports.\r\n     */\r\n    QSharedPointer<QStringList> getExcludePorts() const;\r\n\r\n    /*!\r\n     *  Set a new list of excluded ports.\r\n     *\r\n     *    @param [in] newExcludePorts     A new list of excluded ports.\r\n     */\r\n    void setExcludePorts(QSharedPointer<QStringList> newExcludePorts);\r\n\r\nprivate:\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! The name of the referenced component.\r\n    QString componentRef_;\r\n\r\n    //! A list of excluded ports\r\n    QSharedPointer<QStringList> excludePorts_ = QSharedPointer<QStringList>(new QStringList());\r\n\r\n};\r\n#endif // ACTIVEINTERFACE_H\r\n"
  },
  {
    "path": "IPXACTmodels/Design/AdHocConnection.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: AdHocConnection.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 24.08.2015\r\n//\r\n// Description:\r\n// Describes the ipxact:adHocConnection element in an IP-XACT document\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"AdHocConnection.h\"\r\n\r\n#include <IPXACTmodels/kactusExtensions/Kactus2Placeholder.h>\r\n#include <IPXACTmodels/kactusExtensions/Kactus2Group.h>\r\n#include <IPXACTmodels/kactusExtensions/Kactus2Position.h>\r\n\r\n#include <IPXACTmodels/utilities/Copy.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AdHocConnection::AdHocConnection()\r\n//-----------------------------------------------------------------------------\r\nAdHocConnection::AdHocConnection(QString name, \r\n    QString tiedValue, QList<QPointF> const& route,  bool offPage) :\r\nNameGroup(name),\r\n    Extendable(),\r\n    tiedValue_(tiedValue)\r\n{\r\n    setOffPage(offPage);\r\n    setRoute(route);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AdHocConnection::AdHocConnection()\r\n//-----------------------------------------------------------------------------\r\nAdHocConnection::AdHocConnection( const AdHocConnection& other ):\r\nNameGroup(other),\r\n    Extendable(other),\r\n    isPresent_(other.isPresent_),\r\n    tiedValue_(other.tiedValue_)\r\n{\r\n    Copy::copyList(other.internalPortReferences_, internalPortReferences_);\r\n\r\n    Copy::copyList(other.externalPortReferences_, externalPortReferences_);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AdHocConnection::operator=()\r\n//-----------------------------------------------------------------------------\r\nAdHocConnection& AdHocConnection::operator=( const AdHocConnection& other )\r\n{\r\n    if (this != &other)\r\n    {\r\n        NameGroup::operator=(other);\r\n        Extendable::operator=(other);\r\n        isPresent_ = other.isPresent_;\r\n        tiedValue_ = other.tiedValue_;\r\n\r\n        internalPortReferences_->clear();\r\n        Copy::copyList(other.internalPortReferences_, internalPortReferences_);\r\n\r\n        externalPortReferences_->clear();\r\n        Copy::copyList(other.externalPortReferences_, externalPortReferences_);\r\n    }\r\n\r\n    return *this;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AdHocConnection::getInternalPortReferences()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<QList<QSharedPointer<PortReference> > > AdHocConnection::getInternalPortReferences() const\r\n{\r\n    return internalPortReferences_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AdHocConnection::setInternalPortReferences()\r\n//-----------------------------------------------------------------------------\r\nvoid AdHocConnection::setInternalPortReferences(QSharedPointer<QList<QSharedPointer<PortReference> > > newInternals)\r\n{\r\n    internalPortReferences_ = newInternals;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AdHocConnection::getExternalPortReferences()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<QList<QSharedPointer<PortReference> > > AdHocConnection::getExternalPortReferences() const\r\n{\r\n    return externalPortReferences_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AdHocConnection::setExternalPortReferences()\r\n//-----------------------------------------------------------------------------\r\nvoid AdHocConnection::setExternalPortReferences(QSharedPointer<QList<QSharedPointer<PortReference> > > newExternals)\r\n{\r\n    externalPortReferences_ = newExternals;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AdHocConnection::setRoute()\r\n//-----------------------------------------------------------------------------\r\nvoid AdHocConnection::setRoute(QList<QPointF> const& route) const\r\n{\r\n    auto extension = findVendorExtension(QStringLiteral(\"kactus2:route\"));\r\n    getVendorExtensions()->removeAll(extension);\r\n\r\n    if (!route.isEmpty())\r\n    {\r\n        QSharedPointer<Kactus2Group> routeGroup (new Kactus2Group(QStringLiteral(\"kactus2:route\")));\r\n        for (auto const& location : route)\r\n        {\r\n            QSharedPointer<Kactus2Position> routePoint (new Kactus2Position(location));\r\n            routeGroup->addToGroup(routePoint);\r\n        }\r\n\r\n        getVendorExtensions()->append(routeGroup);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AdHocConnection::getRoute()\r\n//-----------------------------------------------------------------------------\r\nQList<QPointF> AdHocConnection::getRoute() const\r\n{\r\n    QList<QSharedPointer<VendorExtension> > routeExtensions =\r\n        getGroupedExtensionsByType(QStringLiteral(\"kactus2:route\"), QStringLiteral(\"kactus2:position\"));\r\n\r\n    QList<QPointF> route;\r\n    for (auto const& extension : routeExtensions)\r\n    {\r\n        QSharedPointer<Kactus2Position> position = extension.dynamicCast<Kactus2Position>();\r\n        route.append(position->position());\r\n    }\r\n\r\n    return route;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AdHocConnection::isOffPage()\r\n//-----------------------------------------------------------------------------\r\nbool AdHocConnection::isOffPage() const\r\n{\r\n    return findVendorExtension(QStringLiteral(\"kactus2:offPage\")) != nullptr;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AdHocConnection::setOffPage()\r\n//-----------------------------------------------------------------------------\r\nvoid AdHocConnection::setOffPage(bool offPage)\r\n{\r\n    setPlaceholderExtension(offPage, QStringLiteral(\"kactus2:offPage\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AdHocConnection::getIsPresent()\r\n//-----------------------------------------------------------------------------\r\nQString AdHocConnection::getIsPresent() const\r\n{\r\n    return isPresent_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AdHocConnection::setIsPresent()\r\n//-----------------------------------------------------------------------------\r\nvoid AdHocConnection::setIsPresent(QString const& newIsPresent)\r\n{\r\n    isPresent_ = newIsPresent;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AdHocConnection::getTiedValue()\r\n//-----------------------------------------------------------------------------\r\nQString AdHocConnection::getTiedValue() const\r\n{\r\n    return tiedValue_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AdHocConnection::setTiedValue()\r\n//-----------------------------------------------------------------------------\r\nvoid AdHocConnection::setTiedValue(QString const& newTiedValue)\r\n{\r\n    tiedValue_ = newTiedValue;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AdHocConnection::changeInterfaceComponentReferences()\r\n//-----------------------------------------------------------------------------\r\nvoid AdHocConnection::changeInterfaceComponentReferences(QString const& oldName, QString const& newName) const\r\n{\r\n    for (QSharedPointer<PortReference> portReference : *internalPortReferences_)\r\n    {\r\n        if (portReference->getComponentRef().compare(oldName) == 0)\r\n        {\r\n            portReference->setComponentRef(newName);\r\n        }\r\n    }\r\n}\r\n"
  },
  {
    "path": "IPXACTmodels/Design/AdHocConnection.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: AdHocConnection.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 24.08.2015\r\n//\r\n// Description:\r\n// Describes the ipxact:adHocConnection element in an IP-XACT document\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef ADHOCCONNECTION_H\r\n#define ADHOCCONNECTION_H\r\n\r\n#include \"PortReference.h\"\r\n\r\n#include <IPXACTmodels/common/NameGroup.h>\r\n#include <IPXACTmodels/common/Extendable.h>\r\n#include <IPXACTmodels/ipxactmodels_global.h>\r\n\r\n#include <QPointF>\r\n#include <QList>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Describes the ipxact:adHocConnection element in an IP-XACT document\r\n//-----------------------------------------------------------------------------\r\nclass IPXACTMODELS_EXPORT AdHocConnection : public NameGroup, public Extendable\r\n{\r\npublic:\r\n\r\n    /*!\r\n     *  The constructor.\r\n     *\r\n     *    @param [in] name            The name of the adHocConnection.\r\n     *    @param [in] tiedValue       Fixed logic value for the connection.\r\n     *    @param [in] route           The route of the connection.\r\n     *    @param [in] offPage         Specifies whether the connection is off page or not.\r\n     */\r\n    AdHocConnection(QString name,\r\n        QString tiedValue = QString(),\r\n        QList<QPointF> const& route = QList<QPointF>(),\r\n        bool offPage = false);\r\n\r\n    /*!\r\n     *  The destructor.\r\n     */\r\n    ~AdHocConnection() override = default;\r\n\r\n    /*!\r\n     *  Copy constructor.\r\n     */\r\n    AdHocConnection(const AdHocConnection& other);\r\n\r\n    /*!\r\n     *  Assignment operator.\r\n     */\r\n    AdHocConnection& operator=(const AdHocConnection& other);\r\n\r\n    /*!\r\n     *  Gets the internal port references of the connection.\r\n     *\r\n     *    @return A pointer to a list of internal port references.\r\n     */\r\n    QSharedPointer<QList<QSharedPointer<PortReference> > > getInternalPortReferences() const;\r\n\r\n    /*!\r\n     *  Gets the external port references of the connection.     \r\n     *\r\n     *    @return A pointer to a list of external port references.\r\n     */\r\n    QSharedPointer<QList<QSharedPointer<PortReference> > > getExternalPortReferences() const;\r\n\r\n    /*!\r\n     *  Sets the route of the connection.\r\n     *\r\n     *    @param [in] route   The route to set.\r\n     */\r\n    void setRoute(QList<QPointF> const& route) const;\r\n\r\n    /*!\r\n     *  Gets the route of the connection.     \r\n     *\r\n     *    @return The route of the connection.\r\n     */\r\n    QList<QPointF> getRoute() const;\r\n\r\n    /*!\r\n     *  Checks if the connection is treated as an off-page connection.\r\n     *\r\n     *    @return True if off-page connection, otherwise false.\r\n     */\r\n    bool isOffPage() const;\r\n\r\n    /*!\r\n     *  Set/unset the connection to off-page connection.\r\n     *\r\n     *    @param [in] offPage   True if set to off-page, otherwise false.\r\n     */\r\n    void setOffPage(bool offPage);\r\n\r\n    /*!\r\n     *  Set a new list of internal port references.\r\n     *\r\n     *    @param [in] newInternals    The new list of internal port references.\r\n     */\r\n    void setInternalPortReferences(QSharedPointer<QList<QSharedPointer<PortReference> > > newInternals);\r\n\r\n    /*!\r\n     *  Set a new list of external port references.\r\n     *\r\n     *    @param [in] newExternals    The new list of external port references.\r\n     */\r\n    void setExternalPortReferences(QSharedPointer<QList<QSharedPointer<PortReference> > > newExternals);\r\n\r\n    /*!\r\n     *  Get the presence of the connection.\r\n     *\r\n     *    @return The presence value of the connection.\r\n     */\r\n    QString getIsPresent() const;\r\n\r\n    /*!\r\n     *  Set the presence.\r\n     *\r\n     *    @param [in] newIsPresent    The new value for presence.\r\n     */\r\n    void setIsPresent(QString const& newIsPresent);\r\n\r\n    /*!\r\n     *  Get the tied value of the connection.\r\n     *\r\n     *    @return The tied value.\r\n     */\r\n    QString getTiedValue() const;\r\n\r\n    /*!\r\n     *  Set the tied value.\r\n     *\r\n     *    @param [in] newTiedValue    The new tied value.\r\n     */\r\n    void setTiedValue(QString const& newTiedValue);\r\n\r\n    /*!\r\n     *  Change the component reference of contained interfaces.\r\n     *\r\n     *    @param [in] oldName     The old component reference.\r\n     *    @param [in] newName     The new component reference.\r\n     */\r\n    void changeInterfaceComponentReferences(QString const& oldName, QString const& newName) const;\r\n\r\nprivate:\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! Defines the presence of the connection\r\n    QString isPresent_;\r\n\r\n    //! Specifies a fixed logic value for this connection.\r\n    QString tiedValue_;\r\n\r\n    //! A list of port references of the component instance.\r\n    QSharedPointer<QList<QSharedPointer<PortReference> > > internalPortReferences_ =\r\n        QSharedPointer<QList<QSharedPointer<PortReference> > >(new QList<QSharedPointer<PortReference> >());\r\n        \r\n    //! A list of port references of the encompassing component.\r\n    QSharedPointer<QList<QSharedPointer<PortReference> > > externalPortReferences_ =\r\n        QSharedPointer<QList<QSharedPointer<PortReference> > >(new QList<QSharedPointer<PortReference> >());\r\n};\r\n#endif // ADHOCCONNECTION_H\r\n"
  },
  {
    "path": "IPXACTmodels/Design/ComponentInstance.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ComponentInstance.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 17.08.2015\r\n//\r\n// Description:\r\n// Describes the ipxact:componentInstance element.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"ComponentInstance.h\"\r\n\r\n#include <IPXACTmodels/kactusExtensions/Kactus2Group.h>\r\n#include <IPXACTmodels/kactusExtensions/Kactus2Placeholder.h>\r\n#include <IPXACTmodels/kactusExtensions/Kactus2Position.h>\r\n#include <IPXACTmodels/kactusExtensions/Kactus2Value.h>\r\n\r\n#include <QUuid>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentInstance::ComponentInstance()\r\n//-----------------------------------------------------------------------------\r\nComponentInstance::ComponentInstance() :\r\n    Extendable(),\r\n    NameGroup(),\r\n    componentRef_(new ConfigurableVLNVReference())\r\n{\r\n    setupUuid();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentInstance::ComponentInstance()\r\n//-----------------------------------------------------------------------------\r\nComponentInstance::ComponentInstance(QString const& instanceName, QSharedPointer<ConfigurableVLNVReference> componentRef):\r\n    Extendable(),\r\n    NameGroup(instanceName),\r\n    componentRef_(componentRef)\r\n{\r\n    setupUuid();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentInstance::ComponentInstance()\r\n//-----------------------------------------------------------------------------\r\nComponentInstance::ComponentInstance(ComponentInstance const& other) :\r\n    Extendable(other),\r\n    NameGroup(other),\r\n    isPresent_(other.isPresent_),\r\n    componentRef_(new ConfigurableVLNVReference(*other.componentRef_))\r\n{\r\n    setupUuid();\r\n\r\n    for (auto const& link : *other.powerDomainLinks_)\r\n    {\r\n        powerDomainLinks_->append(QSharedPointer<PowerDomainLink>(link->clone()));\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentInstance::operator=()\r\n//-----------------------------------------------------------------------------\r\nComponentInstance& ComponentInstance::operator=(ComponentInstance const& other)\r\n{\r\n    if (this != &other)\r\n    {\r\n        Extendable::operator=(other);\r\n        NameGroup::operator=(other);\r\n\r\n        isPresent_ = other.isPresent_;\r\n        componentRef_ = other.componentRef_;\r\n\r\n        setupUuid();\r\n\r\n        powerDomainLinks_->clear();\r\n        for (auto const& link : *other.powerDomainLinks_)\r\n        {\r\n            powerDomainLinks_->append(QSharedPointer<PowerDomainLink>(link->clone()));\r\n        }\r\n    }\r\n\r\n    return *this;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentInstance::setInstanceName()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentInstance::setInstanceName(QString const& name)\r\n{\r\n    setName(name);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentInstance::getInstanceName()\r\n//-----------------------------------------------------------------------------\r\nQString ComponentInstance::getInstanceName() const\r\n{\r\n    return name();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentInstance::setComponentRef()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentInstance::setComponentRef(QSharedPointer<ConfigurableVLNVReference> newComponentRef)\r\n{\r\n    componentRef_ = newComponentRef;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentInstance::getComponentRef()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<ConfigurableVLNVReference> ComponentInstance::getComponentRef() const\r\n{\r\n    return componentRef_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentInstance::getIsPresent()\r\n//-----------------------------------------------------------------------------\r\nQString ComponentInstance::getIsPresent() const\r\n{\r\n    return isPresent_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentInstance::setIsPresent()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentInstance::setIsPresent(QString const& newIsPresent)\r\n{\r\n    isPresent_ = newIsPresent;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentInstance::setConfigurableElementValues()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentInstance::setConfigurableElementValues(\r\n    QSharedPointer<QList<QSharedPointer<ConfigurableElementValue> > > newValues)\r\n{\r\n    componentRef_->setConfigurableElementValues(newValues);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentInstance::getConfigurableElementValues()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<QList<QSharedPointer<ConfigurableElementValue> > > ComponentInstance::getConfigurableElementValues()\r\nconst\r\n{\r\n    return componentRef_->getConfigurableElementValues();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentInstance::setPosition()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<QList<QSharedPointer<ComponentInstance::PowerDomainLink> > > ComponentInstance::getPowerDomainLinks() const\r\n{\r\n    return powerDomainLinks_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentInstance::setPosition()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentInstance::setPosition(QPointF const& pos)\r\n{\r\n    auto extension = findVendorExtension(QStringLiteral(\"kactus2:position\")).dynamicCast<Kactus2Position>();\r\n\r\n    if (pos.isNull())\r\n    {\r\n        getVendorExtensions()->removeAll(extension);\r\n    }\r\n    else\r\n    {\r\n        if (extension == nullptr)\r\n        {\r\n            extension = QSharedPointer<Kactus2Position>(new Kactus2Position(QPoint()));\r\n            getVendorExtensions()->append(extension);\r\n        }\r\n\r\n        extension->setPosition(pos);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentInstance::setImportRef()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentInstance::setImportRef(QString const& nameRef)\r\n{\r\n    auto importExtension = findVendorExtension(QStringLiteral(\"kactus2:imported\")).dynamicCast<Kactus2Placeholder>();\r\n\r\n    if (!nameRef.isEmpty())\r\n    {\r\n        if (importExtension == nullptr)\r\n        {\r\n            importExtension = QSharedPointer<Kactus2Placeholder>(new Kactus2Placeholder(QStringLiteral(\"kactus2:imported\")));\r\n            getVendorExtensions()->append(importExtension);\r\n        }\r\n\r\n        importExtension->setAttribute(QStringLiteral(\"importRef\"), nameRef);\r\n    }\r\n    else\r\n    {\r\n        setImported(true);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentInstance::setPropertyValues()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentInstance::setPropertyValues(QMap<QString, QString> const& values)\r\n{\r\n    auto extension = findVendorExtension(QStringLiteral(\"kactus2:propertyValues\"));\r\n    getVendorExtensions()->removeAll(extension);\r\n\r\n    if (!values.isEmpty())\r\n    {\r\n        QSharedPointer<Kactus2Group> propertyValueGroup(new Kactus2Group(QStringLiteral(\"kactus2:propertyValues\")));\r\n\r\n        for (auto it = values.cbegin(); it != values.cend(); ++it)\r\n        {\r\n            QSharedPointer<Kactus2Placeholder> propertyValue(\r\n                new Kactus2Placeholder(QStringLiteral(\"kactus2:propertyValue\")));\r\n            propertyValue->setAttribute(QStringLiteral(\"name\"), it.key());\r\n            propertyValue->setAttribute(QStringLiteral(\"value\"), it.value());\r\n\r\n            propertyValueGroup->addToGroup(propertyValue);\r\n        }\r\n\r\n        getVendorExtensions()->append(propertyValueGroup);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentInstance::updateBusInterfacePosition()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentInstance::updateBusInterfacePosition(QString const& name, QPointF const& pos)\r\n{\r\n    updatePositionsMap(name, pos, QStringLiteral(\"kactus2:portPositions\"), QStringLiteral(\"kactus2:portPosition\"),\r\n        QStringLiteral(\"busRef\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentInstance::removeBusInterfacePosition()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentInstance::removeBusInterfacePosition(QString const& interfaceName)\r\n{\r\n    removePosition(interfaceName, QStringLiteral(\"kactus2:portPositions\"), QStringLiteral(\"kactus2:portPosition\"),\r\n        QStringLiteral(\"busRef\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentInstance::updateAdHocPortPosition()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentInstance::updateAdHocPortPosition(QString const& name, QPointF const& pos)\r\n{\r\n    updatePositionsMap(name, pos, QStringLiteral(\"kactus2:adHocVisibilities\"), \r\n        QStringLiteral(\"kactus2:adHocVisible\"), QStringLiteral(\"portName\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentInstance::updateApiInterfacePosition()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentInstance::updateApiInterfacePosition(QString const& name, QPointF const& pos)\r\n{\r\n    updatePositionsMap(name, pos, QStringLiteral(\"kactus2:apiInterfacePositions\"), \r\n        QStringLiteral(\"kactus2:apiInterfacePosition\"), QStringLiteral(\"apiRef\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentInstance::removeApiInterfacePosition()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentInstance::removeApiInterfacePosition(QString const& name)\r\n{\r\n    removePosition(name, QStringLiteral(\"kactus2:apiInterfacePositions\"),\r\n        QStringLiteral(\"kactus2:apiInterfacePosition\"),\r\n        QStringLiteral(\"apiRef\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentInstance::updateComInterfacePosition()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentInstance::updateComInterfacePosition(QString const& name, QPointF const& pos)\r\n{\r\n    updatePositionsMap(name, pos, QStringLiteral(\"kactus2:comInterfacePositions\"), \r\n        QStringLiteral(\"kactus2:comInterfacePosition\"), QStringLiteral(\"comRef\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentInstance::removeComInterfacePosition()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentInstance::removeComInterfacePosition(QString const& name)\r\n{\r\n    removePosition(name, QStringLiteral(\"kactus2:comInterfacePositions\"),\r\n        QStringLiteral(\"kactus2:comInterfacePosition\"),\r\n        QStringLiteral(\"comRef\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentInstance::getPosition()\r\n//-----------------------------------------------------------------------------\r\nQPointF ComponentInstance::getPosition() const\r\n{\r\n    if (auto position = findVendorExtension(QStringLiteral(\"kactus2:position\")).dynamicCast<Kactus2Position>(); \r\n        position != nullptr)\r\n    {\r\n        return position->position();\r\n    }\r\n\r\n    return QPointF();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentInstance::setImported()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentInstance::setImported(bool isImported)\r\n{\r\n    setPlaceholderExtension(isImported, QStringLiteral(\"kactus2:imported\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentInstance::isImported()\r\n//-----------------------------------------------------------------------------\r\nbool ComponentInstance::isImported() const\r\n{\r\n    return findVendorExtension(QStringLiteral(\"kactus2:imported\")) != nullptr;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentInstance::getImportRef()\r\n//-----------------------------------------------------------------------------\r\nQString ComponentInstance::getImportRef() const\r\n{\r\n    if (auto importExtension = findVendorExtension(QStringLiteral(\"kactus2:imported\")).dynamicCast<Kactus2Placeholder>(); \r\n        importExtension != nullptr)\r\n    {\r\n        return importExtension->getAttributeValue(QStringLiteral(\"importRef\"));\r\n    }\r\n\r\n    return QString();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentInstance::getPropertyValues()\r\n//-----------------------------------------------------------------------------\r\nQMap<QString, QString> ComponentInstance::getPropertyValues() const\r\n{\r\n    QMap<QString, QString> propertyValues;\r\n\r\n    if (auto propertyGroup = findVendorExtension(QStringLiteral(\"kactus2:propertyValues\")).dynamicCast<Kactus2Group>(); \r\n        propertyGroup != nullptr)\r\n    {\r\n        QList<QSharedPointer<VendorExtension> > valueExtensionList =\r\n            propertyGroup->getByType(QStringLiteral(\"kactus2:propertyValue\"));\r\n\r\n        for (auto const& valueExtension : valueExtensionList)\r\n        {\r\n            QSharedPointer<Kactus2Placeholder> propertyValue = valueExtension.dynamicCast<Kactus2Placeholder>();\r\n            QString name = propertyValue->getAttributeValue(QStringLiteral(\"name\"));\r\n            QString value = propertyValue->getAttributeValue(QStringLiteral(\"value\"));\r\n\r\n            propertyValues.insert(name, value);\r\n        }\r\n    }\r\n\r\n    return propertyValues;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentInstance::getBusInterfacePositions()\r\n//-----------------------------------------------------------------------------\r\nQMap<QString, QPointF> ComponentInstance::getBusInterfacePositions() const\r\n{\r\n    return getPositionMap(QStringLiteral(\"kactus2:portPositions\"), QStringLiteral(\"kactus2:portPosition\"), \r\n        QStringLiteral(\"busRef\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentInstance::getAdHocPortPositions()\r\n//-----------------------------------------------------------------------------\r\nQMap<QString, QPointF> ComponentInstance::getAdHocPortPositions() const\r\n{\r\n    return getPositionMap(QStringLiteral(\"kactus2:adHocVisibilities\"), QStringLiteral(\"kactus2:adHocVisible\"),\r\n        QStringLiteral(\"portName\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentInstance::getApiInterfacePositions()\r\n//-----------------------------------------------------------------------------\r\nQMap<QString, QPointF> ComponentInstance::getApiInterfacePositions() const\r\n{\r\n    return getPositionMap(QStringLiteral(\"kactus2:apiInterfacePositions\"), \r\n        QStringLiteral(\"kactus2:apiInterfacePosition\"), QStringLiteral(\"apiRef\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentInstance::getComInterfacePositions()\r\n//-----------------------------------------------------------------------------\r\nQMap<QString, QPointF> ComponentInstance::getComInterfacePositions() const\r\n{\r\n    return getPositionMap(QStringLiteral(\"kactus2:comInterfacePositions\"), \r\n        QStringLiteral(\"kactus2:comInterfacePosition\"), QStringLiteral(\"comRef\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentInstance::getPortAdHocVisibilities()\r\n//-----------------------------------------------------------------------------\r\nQMap<QString, bool> ComponentInstance::getPortAdHocVisibilities() const\r\n{\r\n    QMap<QString, bool> portAdHocVisibilities;\r\n\r\n    QList<QSharedPointer<VendorExtension> > adHocPortExtensionList =\r\n        getGroupedExtensionsByType(QStringLiteral(\"kactus2:adHocVisibilities\"),\r\n        QStringLiteral(\"kactus2:adHocVisible\"));\r\n\r\n    for (auto const& extension : adHocPortExtensionList)\r\n    {\r\n        QSharedPointer<Kactus2Placeholder> portExtension = extension.dynamicCast<Kactus2Placeholder>();\r\n        portAdHocVisibilities.insert(portExtension->getAttributeValue(QStringLiteral(\"portName\")), true);\r\n    }\r\n\r\n    return portAdHocVisibilities;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentInstance::setFileSetRef()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentInstance::setFileSetRef(QString const& fileSetName)\r\n{\r\n    setValueExtension(fileSetName, QStringLiteral(\"kactus2:fileSetRef\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentInstance::setMapping()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentInstance::setMapping(QString const& hwRef)\r\n{\r\n    auto extension = findVendorExtension(QStringLiteral(\"kactus2:mapping\")).dynamicCast<Kactus2Placeholder>();\r\n\r\n    if (!hwRef.isEmpty())\r\n    {\r\n        if (extension == nullptr)\r\n        {\r\n            extension = QSharedPointer<Kactus2Placeholder>(new Kactus2Placeholder(QStringLiteral(\"kactus2:mapping\")));\r\n            getVendorExtensions()->append(extension);\r\n        }\r\n        \r\n        extension->setAttribute(QStringLiteral(\"hwRef\"), hwRef);\r\n\r\n    }\r\n    else\r\n    {\r\n        getVendorExtensions()->removeAll(extension);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentInstance::getFileSetRef()\r\n//-----------------------------------------------------------------------------\r\nQString ComponentInstance::getFileSetRef() const\r\n{\r\n    if (auto extension = findVendorExtension(QStringLiteral(\"kactus2:fileSetRef\")).dynamicCast<Kactus2Value>(); \r\n        extension != nullptr)\r\n    {\r\n        return extension->value();\r\n    }\r\n\r\n    return QString();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentInstance::getMapping()\r\n//-----------------------------------------------------------------------------\r\nQString ComponentInstance::getMapping() const\r\n{\r\n    if (auto extension = findVendorExtension(QStringLiteral(\"kactus2:mapping\")).dynamicCast<Kactus2Placeholder>(); \r\n        extension != nullptr)\r\n    {\r\n        return extension->getAttributeValue(QStringLiteral(\"hwRef\"));\r\n    }\r\n\r\n    return QString();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentInstance::getUuid()\r\n//-----------------------------------------------------------------------------\r\nQString ComponentInstance::getUuid() const\r\n{\r\n    if (auto extension = findVendorExtension(QStringLiteral(\"kactus2:uuid\")).dynamicCast<Kactus2Value>(); \r\n        extension != nullptr)\r\n    {\r\n        return extension->value();\r\n    }\r\n\r\n    return QString();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentInstance::isDraft()\r\n//-----------------------------------------------------------------------------\r\nbool ComponentInstance::isDraft() const\r\n{\r\n    return findVendorExtension(QStringLiteral(\"kactus2:draft\")) != nullptr;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentInstance::setDraft()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentInstance::setDraft(bool instanceIsDraft)\r\n{\r\n    setPlaceholderExtension(instanceIsDraft, QStringLiteral(\"kactus2:draft\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentInstance::setUuid()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentInstance::setUuid(QString const& newUuid)\r\n{\r\n    setValueExtension(newUuid, QStringLiteral(\"kactus2:uuid\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentInstance::hideAdHocPort()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentInstance::hideAdHocPort(QString const& portName)\r\n{\r\n    removePosition(portName, QStringLiteral(\"kactus2:adHocVisibilities\"),\r\n        QStringLiteral(\"kactus2:adHocVisible\"),\r\n        QStringLiteral(\"portName\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentInstance::setupUuid()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentInstance::setupUuid()\r\n{\r\n    if (getUuid().isEmpty())\r\n    {\r\n        setUuid(QUuid::createUuid().toString());\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentInstance::updatePositionsMap()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentInstance::updatePositionsMap(QString const& newReferenceName, QPointF const& newPosition,\r\n    QString const& groupIdentifier, QString const& itemIdentifier, QString const& referenceIdentifier) const\r\n{\r\n    if (newReferenceName.isEmpty() || newPosition.isNull())\r\n    {\r\n        return;\r\n    }\r\n\r\n    auto portGroup = findVendorExtension(groupIdentifier).dynamicCast<Kactus2Group>();\r\n    if (portGroup == nullptr)\r\n    {\r\n        portGroup = QSharedPointer<Kactus2Group>(new Kactus2Group(groupIdentifier));\r\n        getVendorExtensions()->append(portGroup);\r\n    }\r\n\r\n    QList<QSharedPointer<VendorExtension> > interfacePositions = portGroup->getByType(itemIdentifier);\r\n\r\n    auto it = std::find_if(interfacePositions.begin(), interfacePositions.end(),\r\n        [&referenceIdentifier, &newReferenceName](QSharedPointer<VendorExtension> positionExtension)\r\n    {   return positionExtension.dynamicCast<Kactus2Placeholder>()->getAttributeValue(referenceIdentifier) == newReferenceName; });\r\n\r\n    QSharedPointer<Kactus2Placeholder> positionExtension;\r\n    if (it != interfacePositions.cend())\r\n    {\r\n        positionExtension = (*it).dynamicCast<Kactus2Placeholder>();\r\n    }\r\n    else\r\n    {\r\n        positionExtension = QSharedPointer<Kactus2Placeholder>(new Kactus2Placeholder(itemIdentifier));\r\n        positionExtension->setAttribute(referenceIdentifier, newReferenceName);\r\n\r\n        portGroup->addToGroup(positionExtension);\r\n    }\r\n\r\n    positionExtension->setAttribute(QStringLiteral(\"x\"), QString::number(newPosition.x()));\r\n    positionExtension->setAttribute(QStringLiteral(\"y\"), QString::number(newPosition.y()));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentInstance::removePosition()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentInstance::removePosition(QString const& interfaceName, QString const& groupIdentifier, \r\n    QString const& itemIdentifier, QString const& referenceIdentifier)\r\n{\r\n    if (interfaceName.isEmpty())\r\n    {\r\n        return;\r\n    }\r\n\r\n    QSharedPointer<Kactus2Group> portGroup = findVendorExtension(groupIdentifier).\r\n        dynamicCast<Kactus2Group>();\r\n\r\n    if (portGroup == nullptr)\r\n    {\r\n        return;\r\n    }\r\n\r\n    QList<QSharedPointer<VendorExtension> > interfacePositions = portGroup->getByType(itemIdentifier);\r\n\r\n    auto it = std::find_if(interfacePositions.begin(), interfacePositions.end(),\r\n        [&referenceIdentifier, &interfaceName](QSharedPointer<VendorExtension> positionExtension)\r\n    { return positionExtension.dynamicCast<Kactus2Placeholder>()->getAttributeValue(referenceIdentifier) == interfaceName; });\r\n\r\n    QSharedPointer<Kactus2Placeholder> positionExtension;\r\n    if (it != interfacePositions.cend())\r\n    {\r\n        positionExtension = (*it).dynamicCast<Kactus2Placeholder>();\r\n        portGroup->removeFromGroup(positionExtension);\r\n    }\r\n\r\n    if (portGroup->getByType(itemIdentifier).isEmpty())\r\n    {\r\n        getVendorExtensions()->removeAll(portGroup);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentInstance::getPositionMap()\r\n//-----------------------------------------------------------------------------\r\nQMap<QString, QPointF> ComponentInstance::getPositionMap(QString const& groupIdentifier,\r\n    QString const& itemIdentifier, QString const& referenceIdentifier) const\r\n{\r\n    QList<QSharedPointer<VendorExtension> > positionList =\r\n        getGroupedExtensionsByType(groupIdentifier, itemIdentifier);\r\n\r\n    QMap<QString, QPointF> portPositions;\r\n\r\n    for (auto const& extension : positionList)\r\n    {\r\n        auto positionExtension = extension.dynamicCast<Kactus2Placeholder>();\r\n        QString referenceName = positionExtension->getAttributeValue(referenceIdentifier);\r\n        int positionX = positionExtension->getAttributeValue(QStringLiteral(\"x\")).toInt();\r\n        int positionY = positionExtension->getAttributeValue(QStringLiteral(\"y\")).toInt();\r\n\r\n        portPositions.insert(referenceName , QPointF(positionX, positionY));\r\n    }\r\n\r\n    return portPositions;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentInstance::setValueExtension()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentInstance::setValueExtension(QString const& value, QString const& extensionType)\r\n{\r\n    auto extension = findVendorExtension(extensionType).dynamicCast<Kactus2Value>();\r\n\r\n    if (value.isEmpty() == false)\r\n    {\r\n        if (extension == nullptr)\r\n        {\r\n            extension = QSharedPointer<Kactus2Value>(new Kactus2Value(extensionType, QString()));\r\n            getVendorExtensions()->append(extension);\r\n        }\r\n\r\n        extension->setValue(value);\r\n    }\r\n    else\r\n    {\r\n        getVendorExtensions()->removeAll(extension);\r\n    }\r\n}\r\n\r\n"
  },
  {
    "path": "IPXACTmodels/Design/ComponentInstance.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ComponentInstance.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 17.08.2015\r\n//\r\n// Description:\r\n// Describes the ipxact:componentInstance element.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef COMPONENTINSTANCE_H\r\n#define COMPONENTINSTANCE_H\r\n\r\n#include <IPXACTmodels/common/VLNV.h>\r\n\r\n#include <IPXACTmodels/common/ConfigurableVLNVReference.h>\r\n#include <IPXACTmodels/common/Extendable.h>\r\n#include <IPXACTmodels/common/NameGroup.h>\r\n\r\n#include <IPXACTmodels/kactusExtensions/Kactus2Placeholder.h>\r\n#include <IPXACTmodels/kactusExtensions/Kactus2Value.h>\r\n\r\n#include <IPXACTmodels/ipxactmodels_global.h>\r\n\r\n#include <QSharedPointer>\r\n#include <QString>\r\n#include <QPointF>\r\n#include <QMap>\r\n\r\n//-----------------------------------------------------------------------------\r\n//! IP-XACT component instance class.\r\n//-----------------------------------------------------------------------------\r\nclass IPXACTMODELS_EXPORT ComponentInstance : public Extendable, public NameGroup\r\n{\r\npublic:\r\n\r\n    using List = QSharedPointer<QList<QSharedPointer<ComponentInstance> > >;\r\n\r\n    struct PowerDomainLink\r\n    {\r\n        using List = QSharedPointer<QList<QSharedPointer<PowerDomainLink> > >;\r\n\r\n        QString externalReference_;\r\n        QStringList internalReferences_;\r\n\r\n        PowerDomainLink* clone() const { return new PowerDomainLink({ externalReference_, internalReferences_ }); };\r\n    };\r\n\r\n\r\n    /*!\r\n     *  The default constructor.\r\n     */\r\n    ComponentInstance();\r\n\r\n    /*!\r\n     *  The constructor.\r\n     *\r\n     *    @param [in] instanceName    The name of the component instance.\r\n     *    @param [in] componentRef    The referenced component.\r\n     */\r\n    ComponentInstance(QString const& instanceName, QSharedPointer<ConfigurableVLNVReference> componentRef);\r\n\r\n    /*!\r\n     *  Copy constructor.\r\n     */\r\n    ComponentInstance(ComponentInstance const& other);\r\n\r\n    /*!\r\n     *  The destructor.\r\n     */\r\n    ~ComponentInstance() final = default;\r\n\r\n    /*!\r\n     *  Assignment operator.\r\n     */\r\n    ComponentInstance& operator=(ComponentInstance const& other);\r\n\r\n    /*!\r\n     *  Sets the name of the instance.\r\n     *\r\n     *    @param [in] name The name to set.\r\n     */\r\n    void setInstanceName(QString const& name);\r\n   \r\n    /*!\r\n     *  Returns the name of the instance.\r\n     */\r\n    QString getInstanceName() const;\r\n\r\n    /*!\r\n     *  Sets the component reference.\r\n     *\r\n     *    @param [in] vlnv The referenced component VLNV.\r\n     */\r\n    void setComponentRef(QSharedPointer<ConfigurableVLNVReference> newComponentRef);\r\n\r\n    /*!\r\n     *  Returns the component reference.\r\n     */\r\n    QSharedPointer<ConfigurableVLNVReference> getComponentRef() const;\r\n\r\n    /*!\r\n     *  Get the presence of the instance.\r\n     *\r\n     *    @return A QString containing the presence.\r\n     */\r\n    QString getIsPresent() const;\r\n\r\n    /*!\r\n     *  Set the presence of the instance.\r\n     *\r\n     *    @param [in] newIsPresent    The new value for the presence.\r\n     */\r\n    void setIsPresent(QString const& newIsPresent);\r\n\r\n    /*!\r\n     *  Sets the configurable element values.\r\n     *\r\n     *    @param [in] values The configurable element values to set.\r\n     */\r\n    void setConfigurableElementValues(QSharedPointer<QList<QSharedPointer<ConfigurableElementValue> > > newValues);\r\n\r\n    /*!\r\n     *  Returns the configurable element values.\r\n     */\r\n    QSharedPointer<QList<QSharedPointer<ConfigurableElementValue> > > getConfigurableElementValues() const;\r\n\r\n    QSharedPointer<QList<QSharedPointer<PowerDomainLink> > > getPowerDomainLinks() const;\r\n\r\n    /*!\r\n     *  Sets the global position of the instance.\r\n     *\r\n     *    @param [in] pos The global position in the design, in pixels.\r\n     */\r\n    void setPosition(QPointF const& pos);\r\n\r\n    /*!\r\n     *  Sets the name of the import source instance.\r\n     *\r\n     *    @param [in] nameRef The name of the import source instance.\r\n     */\r\n    void setImportRef(QString const& nameRef);\r\n\r\n    /*!\r\n     *  Sets the property values.\r\n     *\r\n     *    @param [in] values The property values.\r\n     */\r\n    void setPropertyValues(QMap<QString, QString> const& values);\r\n\r\n    /*!\r\n     *  Updates the position of the bus interface with the given name.\r\n     *\r\n     *    @param [in] name The name of the bus interface.\r\n     *    @param [in] pos  The local position of the bus interface.\r\n     */\r\n    void updateBusInterfacePosition(QString const& name, QPointF const& pos);\r\n\r\n    /*!\r\n     *  Remove bus interface position.\r\n     *\r\n     *    @param [in] interfaceName    Name of the removed bus interface.\r\n     */\r\n    void removeBusInterfacePosition(QString const& interfaceName);\r\n\r\n    /*!\r\n     *  Updates the position of the ad-hoc port with the given name.\r\n     *\r\n     *    @param [in] name The name of the ad-hoc port.\r\n     *    @param [in] pos  The local position of the ad-hoc port.\r\n     */\r\n    void updateAdHocPortPosition(QString const& name, QPointF const& pos);\r\n\r\n    /*!\r\n     *  Updates the position of the API interface with the given name.\r\n     *\r\n     *    @param [in] name The name of the API interface.\r\n     *    @param [in] pos  The local position of the API interface.\r\n     */\r\n    void updateApiInterfacePosition(QString const& name, QPointF const& pos);\r\n\r\n    /*!\r\n     *  Remove API interface position.\r\n     *\r\n     *    @param [in] name    Name of the selected API interface.\r\n     */\r\n    void removeApiInterfacePosition(QString const& name);\r\n\r\n    /*!\r\n     *  Updates the position of the API interface with the given name.\r\n     *\r\n     *    @param [in] name The name of the API interface.\r\n     *    @param [in] pos  The local position of the API interface.\r\n     */\r\n    void updateComInterfacePosition(QString const& name, QPointF const& pos);\r\n\r\n    /*!\r\n     *  Remove COM interface position.\r\n     *\r\n     *    @param [in] name    Name of the selected COM interface.\r\n     */\r\n    void removeComInterfacePosition(QString const& name);\r\n\r\n    /*!\r\n     *  Returns the global position of the instance in the design.\r\n     */\r\n    QPointF getPosition() const;\r\n\r\n    /*!\r\n     *  Set the imported value for the component instance.\r\n     *\r\n     *    @param [in] isImported  True if the component is imported, false otherwise.\r\n     */\r\n    void setImported(bool isImported);\r\n\r\n    /*!\r\n     *  Returns true if the instance is an imported one.\r\n     *\r\n     *    @return True if the component is imported, false otherwise.\r\n     */\r\n    bool isImported() const;\r\n\r\n    /*!\r\n     *  Returns the name of the import source instance.\r\n     */\r\n    QString getImportRef() const;\r\n\r\n    /*!\r\n     *  Returns the property values.\r\n     */\r\n    QMap<QString, QString> getPropertyValues() const;\r\n\r\n    /*!\r\n     *  Returns the local bus interface positions of the instance in the design.\r\n     */\r\n    QMap<QString, QPointF> getBusInterfacePositions() const;\r\n\r\n    /*!\r\n     *  Returns the local ad-hoc port positions of the instance in the design.\r\n     */\r\n    QMap<QString, QPointF> getAdHocPortPositions() const;\r\n\r\n    /*!\r\n     *  Returns the local API interface positions of the instance in the design.\r\n     */\r\n    QMap<QString, QPointF> getApiInterfacePositions() const;\r\n\r\n    /*!\r\n     *  Returns the local COM interface positions of the instance in the design.\r\n     */\r\n    QMap<QString, QPointF> getComInterfacePositions() const;\r\n\r\n    /*!\r\n     *  Returns the port ad-hoc visibilities.\r\n     */\r\n    QMap<QString, bool> getPortAdHocVisibilities() const;\r\n    \r\n    /*!\r\n     *  Get the Uuid of the instance.\r\n\t *\r\n     *    @return QString containing the uuid.\r\n\t */\r\n    QString getUuid() const;\r\n        \r\n    /*!\r\n     *  Set the universally unique identifier (Kactus2 extension).\r\n     *\r\n     *    @param [in] newUuid     The new unique identifier.\r\n     */\r\n    void setUuid(QString const& newUuid);\r\n\r\n    /*!\r\n     *  Checks if the component instance is a draft.\r\n     *\r\n     *    @return True, if the instance is a draft, otherwise false.\r\n     */\r\n    bool isDraft() const;\r\n     \r\n    /*!\r\n     *  Set the draft status of a component instance (Kactus2 extension).\r\n     *\r\n     *    @param [in] instanceIsDraft     True for draft component instance, false for normal.\r\n     */\r\n    void setDraft(bool instanceIsDraft);\r\n\r\n    /*!\r\n     *  Hides an ad hoc port in the instance.\r\n     *\r\n     *    @param [in] portName   The name of the port to hide.\r\n     */\r\n    void hideAdHocPort(QString const& portName);\r\n\r\n    /*!\r\n     *  Sets the file set reference.\r\n     *\r\n     *    @param [in] fileSetName The name of the referenced file set in the top-level component.\r\n     */\r\n    void setFileSetRef(QString const& fileSetName);\r\n\r\n    /*!\r\n     *  Sets the HW mapping information for the SW instance.\r\n     *\r\n     *    @param [in] hwRef The name of the HW component instance to which the SW instance is mapped.\r\n     */\r\n    void setMapping(QString const& hwRef);\r\n\r\n    /*!\r\n     *  Returns the file set reference (i.e. the name of the referenced file set).\r\n     */\r\n    QString getFileSetRef() const;\r\n\r\n    /*!\r\n     *  Returns the name of the referenced HW component instance onto which the SW instance is mapped.\r\n     */\r\n    QString getMapping() const;\r\n\r\nprivate:\r\n\r\n    void setupUuid();\r\n\r\n    /*!\r\n     *  Update a positions map extension (Kactus2 extension).\r\n     *\r\n     *    @param [in] newReferenceName        The name of the new reference.\r\n     *    @param [in] newPosition             The position of the new reference.\r\n     *    @param [in] groupIdentifier         The identifier for the group.\r\n     *    @param [in] itemIdentifier          The identifier for the item.\r\n     *    @param [in] referenceIdentifier     The identifier for the reference.\r\n     */\r\n    void updatePositionsMap(QString const& newReferenceName, QPointF const& newPosition,\r\n        QString const& groupIdentifier, QString const& itemIdentifier, QString const& referenceIdentifier) const;\r\n \r\n    void removePosition(QString const& interfaceName, QString const& groupIdentifier, QString const& itemIdentifier,\r\n        QString const& referenceIdentifier);\r\n\r\n    /*!\r\n     *  Get a map of positions (Kactus2 extension).\r\n     *\r\n     *    @param [in] groupIdentifier         The identifier of the position group.\r\n     *    @param [in] itemIdentifier          The identifier of the position item.\r\n     *    @param [in] referenceIdentifier     The identifier of the position reference.\r\n     */\r\n    QMap<QString, QPointF> getPositionMap(QString const& groupIdentifier, QString const& itemIdentifier,\r\n        QString const& referenceIdentifier) const;\r\n    \r\n\r\n    /*!\r\n     * Sets the Kactus2 vendor extension value. If the extension does not exist, it is created.\r\n     *\r\n     *    @param [in] value            The value to set.\r\n     *    @param [in] extensionType    The type of the vendor extension.\r\n     */\r\n    void setValueExtension(QString const& value, QString const& extensionType);\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! The presence.\r\n    QString isPresent_;\r\n\r\n    //! The referenced component.\r\n    QSharedPointer<ConfigurableVLNVReference> componentRef_;\r\n\r\n    //! The power domain links of the component instance.\r\n    PowerDomainLink::List powerDomainLinks_ = PowerDomainLink::List(new QList<QSharedPointer<PowerDomainLink> >());\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n\r\n#endif // COMPONENTINSTANCE_H\r\n"
  },
  {
    "path": "IPXACTmodels/Design/ComponentInstanceReader.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ComponentInstanceReader.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 02.09.2015\r\n//\r\n// Description:\r\n// XML reader class for IP-XACT component instance.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"ComponentInstanceReader.h\"\r\n\r\n#include <IPXACTmodels/Design/ComponentInstance.h>\r\n\r\n#include <IPXACTmodels/common/NameGroupReader.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentInstanceReader::createComponentInstanceFrom()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<ComponentInstance> ComponentInstanceReader::createComponentInstanceFrom(\r\n    QDomNode const& instanceNode, Document::Revision docRevision)\r\n{\r\n    QSharedPointer<ComponentInstance> newComponentInstance(new ComponentInstance());\r\n    NameGroupReader::parseNameGroup(instanceNode, newComponentInstance);\r\n\r\n    QString instanceName = instanceNode.firstChildElement(QStringLiteral(\"ipxact:instanceName\")).firstChild().nodeValue();\r\n    newComponentInstance->setInstanceName(instanceName);\r\n\r\n    QDomNode componentRefNode = instanceNode.firstChildElement(QStringLiteral(\"ipxact:componentRef\"));\r\n\r\n    QSharedPointer<ConfigurableVLNVReference> componentRef =\r\n        CommonItemsReader::parseConfigurableVLNVReference(componentRefNode, VLNV::COMPONENT);\r\n    newComponentInstance->setComponentRef(componentRef);\r\n\r\n    if (docRevision == Document::Revision::Std14)\r\n    {\r\n        QString isPresent = instanceNode.firstChildElement(QStringLiteral(\"ipxact:isPresent\")).firstChild().nodeValue();\r\n        newComponentInstance->setIsPresent(isPresent);\r\n    }\r\n\r\n    if (docRevision == Document::Revision::Std22)\r\n    {\r\n        Details::parsePowerDomainLinks(instanceNode, newComponentInstance);\r\n    }\r\n\r\n    Details::parseExtensions(instanceNode, newComponentInstance);\r\n\r\n    return newComponentInstance;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentInstanceReader::parsePowerDomainLinks()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentInstanceReader::Details::parsePowerDomainLinks(QDomNode const& instanceNode,\r\n    QSharedPointer<ComponentInstance> instance)\r\n{\r\n    QDomElement domainsNode = instanceNode.firstChildElement(QStringLiteral(\"ipxact:powerDomainLinks\"));\r\n    QDomNodeList domainNodeList = domainsNode.childNodes();\r\n\r\n    const int DOMAIN_COUNT = domainNodeList.count();\r\n    for (int index = 0; index < DOMAIN_COUNT; ++index)\r\n    {\r\n        auto const& domainNode = domainNodeList.at(index);\r\n        auto externalLink = domainNode.firstChildElement(QStringLiteral(\"ipxact:externalPowerDomainReference\")).firstChild().nodeValue();\r\n\r\n        QStringList internalLinks;\r\n        auto linkNodes = domainNode.toElement().elementsByTagName(QStringLiteral(\"ipxact:internalPowerDomainReference\"));\r\n        const auto LINK_COUNT = linkNodes.count();\r\n        for (int i = 0; i < LINK_COUNT; ++i)\r\n        {\r\n            auto linkNode = linkNodes.at(i);\r\n            internalLinks.append(linkNode.firstChild().nodeValue());\r\n        }\r\n\r\n        auto link = QSharedPointer<ComponentInstance::PowerDomainLink>(\r\n            new ComponentInstance::PowerDomainLink({ externalLink, internalLinks }));\r\n        instance->getPowerDomainLinks()->append(link);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentInstanceReader::parseExtensions()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentInstanceReader::Details::parseExtensions(const QDomNode& componentInstanceNode,\r\n    QSharedPointer<ComponentInstance> instance)\r\n{\r\n    QDomElement extensionsNode = componentInstanceNode.firstChildElement(QStringLiteral(\"ipxact:vendorExtensions\"));\r\n    QDomNodeList extensionNodeList = extensionsNode.childNodes();\r\n\r\n    if (QDomElement uuidElement = extensionsNode.firstChildElement(QStringLiteral(\"kactus2:uuid\")); \r\n        !uuidElement.isNull())\r\n    {\r\n        instance->setUuid(uuidElement.firstChild().nodeValue());\r\n    }\r\n\r\n    QDomElement draftNode = extensionsNode.firstChildElement(QStringLiteral(\"kactus2:draft\"));\r\n    parseDraft(draftNode, instance);\r\n\r\n    QDomElement positionNode = extensionsNode.firstChildElement(QStringLiteral(\"kactus2:position\"));\r\n    parsePosition(positionNode, instance);\r\n    \r\n    QDomElement importNode = extensionsNode.firstChildElement(QStringLiteral(\"kactus2:imported\"));\r\n    parseImport(importNode, instance);\r\n    \r\n    QDomElement portPositionNode = extensionsNode.firstChildElement(QStringLiteral(\"kactus2:portPositions\"));\r\n    parsePortPositions(portPositionNode, instance);\r\n\r\n    QDomElement adHocVisibilityNode = extensionsNode.firstChildElement(QStringLiteral(\"kactus2:adHocVisibilities\"));\r\n    parseAdHocVisibilities(adHocVisibilityNode, instance);\r\n\r\n    QDomElement apiPositionsNode = extensionsNode.firstChildElement(QStringLiteral(\"kactus2:apiInterfacePositions\"));\r\n    parseApiInterfacePositions(apiPositionsNode, instance);\r\n \r\n    QDomElement comPositionsNode = extensionsNode.firstChildElement(QStringLiteral(\"kactus2:comInterfacePositions\"));\r\n    parseComInterfacePositions(comPositionsNode, instance);\r\n\r\n    QDomElement propertyNode = extensionsNode.firstChildElement(QStringLiteral(\"kactus2:propertyValues\"));\r\n    parsePropertyValues(propertyNode, instance);\r\n\r\n    QDomElement fileSetRefNode = extensionsNode.firstChildElement(QStringLiteral(\"kactus2:fileSetRef\"));\r\n    parseFileSetRef(fileSetRefNode, instance);\r\n\r\n    QDomElement mappingNode = extensionsNode.firstChildElement(QStringLiteral(\"kactus2:mapping\"));\r\n    parseMapping(mappingNode, instance);\r\n\r\n    CommonItemsReader::parseVendorExtensions(componentInstanceNode, instance);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentInstanceReader::parseDraft()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentInstanceReader::Details::parseDraft(QDomElement const& draftNode,\r\n    QSharedPointer<ComponentInstance> instance)\r\n{\r\n    instance->setDraft(!draftNode.isNull());\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentInstanceReader::parsePosition()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentInstanceReader::Details::parsePosition(QDomElement const& positionElement,\r\n    QSharedPointer<ComponentInstance> instance)\r\n{\r\n    if (!positionElement.isNull())\r\n    {\r\n        int positionX = positionElement.attribute(QStringLiteral(\"x\")).toInt();\r\n        int positionY = positionElement.attribute(QStringLiteral(\"y\")).toInt();\r\n        instance->setPosition(QPointF(positionX, positionY));\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentInstanceReader::parseImport()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentInstanceReader::Details::parseImport(QDomElement const& importElement,\r\n    QSharedPointer<ComponentInstance> instance)\r\n{\r\n    if (!importElement.isNull())\r\n    {\r\n        QString importReference = importElement.attribute(QStringLiteral(\"importRef\"));\r\n\r\n        if (!importReference.isEmpty())\r\n        {\r\n            instance->setImportRef(importReference);\r\n        }\r\n        else\r\n        {\r\n            instance->setImported(true);\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentInstanceReader::parsePortPositions()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentInstanceReader::Details::parsePortPositions(QDomElement const& portPositionsElement,\r\n    QSharedPointer<ComponentInstance> instance)\r\n{\r\n    QMap<QString, QPointF> portPositions = createMappedPositions(portPositionsElement, \r\n        QStringLiteral(\"kactus2:portPosition\"), QStringLiteral(\"busRef\"));\r\n\r\n    for (auto portIterator = portPositions.cbegin(); portIterator != portPositions.cend(); ++portIterator)\r\n    {\r\n        instance->updateBusInterfacePosition(portIterator.key(), portIterator.value());\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentInstanceReader::parseAdHocVisibilities()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentInstanceReader::Details::parseAdHocVisibilities(QDomElement const& adHocElement,\r\n    QSharedPointer<ComponentInstance> instance)\r\n{\r\n    QMap<QString, QPointF> adHocPositions = createMappedPositions(adHocElement,\r\n        QStringLiteral(\"kactus2:adHocVisible\"), QStringLiteral(\"portName\"));\r\n\r\n    for (auto adHocIterator = adHocPositions.cbegin(); adHocIterator != adHocPositions.cend(); ++adHocIterator)\r\n    {\r\n        instance->updateAdHocPortPosition(adHocIterator.key(), adHocIterator.value());\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentInstanceReader::parseApiInterfacePositions()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentInstanceReader::Details::parseApiInterfacePositions(QDomElement const& apiElement,\r\n    QSharedPointer<ComponentInstance> instance)\r\n{\r\n    QMap<QString, QPointF> apiInterfacePositions = createMappedPositions(apiElement,\r\n        QStringLiteral(\"kactus2:apiInterfacePosition\"), QStringLiteral(\"apiRef\"));\r\n\r\n    for (auto apiInterfaceIterator = apiInterfacePositions.cbegin(); \r\n        apiInterfaceIterator != apiInterfacePositions.cend(); ++apiInterfaceIterator)\r\n    {\r\n        instance->updateApiInterfacePosition(apiInterfaceIterator.key(), apiInterfaceIterator.value());\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentInstanceReader::parseComInterfacePositions()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentInstanceReader::Details::parseComInterfacePositions(QDomElement const& comElement,\r\n    QSharedPointer<ComponentInstance> instance)\r\n{\r\n    QMap<QString, QPointF> comInterfacePositions = createMappedPositions(comElement,\r\n        QStringLiteral(\"kactus2:comInterfacePosition\"), QStringLiteral(\"comRef\"));\r\n\r\n    for (auto comInterfaceIterator = comInterfacePositions.cbegin(); \r\n        comInterfaceIterator != comInterfacePositions.cend(); ++comInterfaceIterator)\r\n    {\r\n        instance->updateComInterfacePosition(comInterfaceIterator.key(), comInterfaceIterator.value());\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentInstanceReader::parsePropertyValues()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentInstanceReader::Details::parsePropertyValues(QDomElement const& propertyElement,\r\n    QSharedPointer<ComponentInstance> instance)\r\n{\r\n    QDomNodeList propertyValueNodes = propertyElement.elementsByTagName(QStringLiteral(\"kactus2:propertyValue\"));\r\n    QMap<QString, QString> newPropertyValues;\r\n\r\n    for (int propertyIndex = 0; propertyIndex < propertyValueNodes.count(); ++propertyIndex)\r\n    {\r\n        QDomNode propertyNode = propertyValueNodes.at(propertyIndex);\r\n        QDomNamedNodeMap propertyAttributes = propertyNode.attributes();\r\n\r\n        QString propertyName = propertyAttributes.namedItem(QStringLiteral(\"name\")).firstChild().nodeValue();\r\n        QString propertyValue = propertyAttributes.namedItem(QStringLiteral(\"value\")).firstChild().nodeValue();\r\n        newPropertyValues.insert(propertyName, propertyValue);\r\n    }\r\n\r\n    instance->setPropertyValues(newPropertyValues);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentInstanceReader::createMappedPositions()\r\n//-----------------------------------------------------------------------------\r\nQMap<QString, QPointF> ComponentInstanceReader::Details::createMappedPositions(QDomElement const& positionElement,\r\n    QString const& itemIdentifier, QString const& referenceIdentifier)\r\n{\r\n    QMap<QString, QPointF> positionMap;\r\n\r\n    QDomNodeList positionNodeList = positionElement.elementsByTagName(itemIdentifier);\r\n    const int NODE_COUNT = positionNodeList.count();\r\n    for (int positionIndex = 0; positionIndex < NODE_COUNT; ++positionIndex)\r\n    {\r\n        QDomElement currentPosition = positionNodeList.at(positionIndex).toElement();\r\n\r\n        QString interfaceReference = currentPosition.attribute(referenceIdentifier);\r\n\r\n        if (!currentPosition.hasAttribute(QStringLiteral(\"x\")))\r\n        {\r\n            currentPosition = currentPosition.firstChildElement(QStringLiteral(\"kactus2:position\"));\r\n        }\r\n\r\n        int positionX = currentPosition.attribute(QStringLiteral(\"x\")).toInt();\r\n        int positionY = currentPosition.attribute(QStringLiteral(\"y\")).toInt();\r\n\r\n        positionMap.insert(interfaceReference, QPointF(positionX, positionY));\r\n    }\r\n\r\n    return positionMap;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentInstanceReader::parseFileSetRef()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentInstanceReader::Details::parseFileSetRef(QDomElement const& fileSetRefElement,\r\n    QSharedPointer<ComponentInstance> instance)\r\n{\r\n    if (!fileSetRefElement.isNull())\r\n    {\r\n        QString fileSetReference = fileSetRefElement.firstChild().nodeValue();\r\n\r\n        if (!fileSetReference.isEmpty())\r\n        {\r\n            instance->setFileSetRef(fileSetReference);\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentInstanceReader::parseMapping()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentInstanceReader::Details::parseMapping(QDomElement const& mappingElement,\r\n    QSharedPointer<ComponentInstance> instance)\r\n{\r\n    if (!mappingElement.isNull())\r\n    {\r\n        QString mapping = mappingElement.attribute(QStringLiteral(\"hwRef\"));\r\n\r\n        if (!mapping.isEmpty())\r\n        {\r\n            instance->setMapping(mapping);\r\n        }\r\n    }\r\n}\r\n"
  },
  {
    "path": "IPXACTmodels/Design/ComponentInstanceReader.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ComponentInstanceReader.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 02.09.2015\r\n//\r\n// Description:\r\n// XML reader for IP-XACT component instance.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef COMPONENTINSTANCEREADER_H\r\n#define COMPONENTINSTANCEREADER_H\r\n\r\n#include <IPXACTmodels/common/DocumentReader.h>\r\n#include <IPXACTmodels/common/CommonItemsReader.h>\r\n\r\n#include <QDomNode>\r\n\r\nclass ComponentInstance;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! XML reader for IP-XACT component instance.\r\n//-----------------------------------------------------------------------------\r\nnamespace ComponentInstanceReader \r\n{\r\n\r\n    /*!\r\n     *  Creates a component instance from XML definition.\r\n     *\r\n     *    @param [in] instanceNode    The XML description of the component instance.\r\n     *    @param [in] docRevision     The IP-XACT revision to comply.\r\n     *\r\n     *    @return The created component instance.\r\n     */\r\n    IPXACTMODELS_EXPORT QSharedPointer<ComponentInstance> createComponentInstanceFrom(QDomNode const& instanceNode,\r\n        Document::Revision docRevision);\r\n\r\n    namespace Details\r\n    {\r\n        /*!\r\n         * Parse the power domain links of the instance.\r\n         *\r\n         *    @param [in] instanceNode  XML description of the instance.\r\n         *    @param [in] instance      The component instance whose power domain links are read.\r\n         *\r\n         *    @return \r\n         */\r\n         void parsePowerDomainLinks(QDomNode const& instanceNode, QSharedPointer<ComponentInstance> instance) ;\r\n\r\n        /*!\r\n         *  Parse extensions of the instance.\r\n         *\r\n         *    @param [in] componentInstanceNode   XML description of the extensions.\r\n         *    @param [in] instance                The component instance whose extensions are read.\r\n         */\r\n        void parseExtensions(const QDomNode& componentInstanceNode, QSharedPointer<ComponentInstance> instance) ;\r\n\r\n        /*!\r\n         *  Parse the draft flag of the instance.\r\n         *\r\n         *    @param [in] draftNode           XML description of the draft flag.\r\n         *    @param [in] instance            The possessing component instance.\r\n         */\r\n        void parseDraft(QDomElement const& draftNode, QSharedPointer<ComponentInstance> instance) ;\r\n\r\n        /*!\r\n         *  Parse the position of the instance.\r\n         *\r\n         *    @param [in] positionElement     XML description of the instance position.\r\n         *    @param [in] instance            The possessing component instance.\r\n         */\r\n        void parsePosition(QDomElement const& positionElement, QSharedPointer<ComponentInstance> instance) ;\r\n\r\n        /*!\r\n         *  Parse import information.\r\n         *\r\n         *    @param [in] importElement   XML description of the instance import.\r\n         *    @param [in] instance        The possessing component instance.\r\n         */\r\n        void parseImport(QDomElement const& importElement, QSharedPointer<ComponentInstance> instance) ;\r\n\r\n        /*!\r\n         *  Parse port positions.\r\n         *\r\n         *    @param [in] portPositionsElement    XML description of the component instance port positions.\r\n         *    @param [in] instance                The possessing component instance.\r\n         */\r\n        void parsePortPositions(QDomElement const& portPositionsElement,\r\n            QSharedPointer<ComponentInstance> instance) ;\r\n\r\n        /*!\r\n         *  Parse ad-hoc visibilities.\r\n         *\r\n         *    @param [in] adHocElement    XML description of the ad-hoc visibilities.\r\n         *    @param [in] instance        The possessing component instance.\r\n         */\r\n        void parseAdHocVisibilities(QDomElement const& adHocElement, QSharedPointer<ComponentInstance> instance) ;\r\n\r\n        /*!\r\n         *  Parse api interface positions.\r\n         *\r\n         *    @param [in] apiElement  XML description of the api interfaces.\r\n         *    @param [in] instance    The possessing component instance.\r\n         */\r\n        void parseApiInterfacePositions(QDomElement const& apiElement,\r\n            QSharedPointer<ComponentInstance> instance) ;\r\n\r\n        /*!\r\n         *  Parse com interface positions.\r\n         *\r\n         *    @param [in] comElement  XML description of the com interfaces.\r\n         *    @param [in] instance    The possessing component instance.\r\n         */\r\n        void parseComInterfacePositions(QDomElement const& comElement,\r\n            QSharedPointer<ComponentInstance> instance) ;\r\n\r\n        /*!\r\n         *  Parse property values.\r\n         *\r\n         *    @param [in] propertyElement     XML description of the property values.\r\n         *    @param [in] instance            The possessing component instance.\r\n         */\r\n        void parsePropertyValues(QDomElement const& propertyElement, QSharedPointer<ComponentInstance> instance) ;\r\n\r\n        /*!\r\n         *  Create mapped positions.\r\n         *\r\n         *    @param [in] positionElement         XML description of the positions.\r\n         *    @param [in] itemIdentifier          Identifier for the containing XML element.\r\n         *    @param [in] referenceIdentifier     Identifier for the reference.\r\n         */\r\n        QMap<QString, QPointF> createMappedPositions(QDomElement const& positionElement, QString const& itemIdentifier,\r\n            QString const& referenceIdentifier) ;\r\n\r\n        /*!\r\n         *  Parse file set reference.\r\n         *\r\n         *    @param [in] fileSetRefElement       XML description of the file set reference.\r\n         *    @param [in] instance                The possessing component instance.\r\n         */\r\n        void parseFileSetRef(QDomElement const& fileSetRefElement, QSharedPointer<ComponentInstance> instance) ;\r\n\r\n        /*!\r\n         *  Parse hardware mapping.\r\n         *\r\n         *    @param [in] mappingElement          XML description of the mapping.\r\n         *    @param [in] instance                The possessing component instance.\r\n         */\r\n        void parseMapping(QDomElement const& mappingElement, QSharedPointer<ComponentInstance> instance) ;\r\n    }\r\n};\r\n\r\n#endif // COMPONENTINSTANCEREADER_H\r\n"
  },
  {
    "path": "IPXACTmodels/Design/ComponentInstanceWriter.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ComponentInstanceWriter.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 02.09.2015\r\n//\r\n// Description:\r\n// Writer for IP-XACT component instance element.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"ComponentInstanceWriter.h\"\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentInstanceWriter::writeComponentInstance()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentInstanceWriter::writeComponentInstance(QXmlStreamWriter& writer,\r\n    QSharedPointer<ComponentInstance> instance, Document::Revision docRevision)\r\n{\r\n    writer.writeStartElement(QStringLiteral(\"ipxact:componentInstance\"));\r\n    writer.writeTextElement(QStringLiteral(\"ipxact:instanceName\"), instance->name());\r\n\r\n    CommonItemsWriter::writeDisplayName(writer, instance->displayName());\r\n\r\n    if (docRevision == Document::Revision::Std22)\r\n    {\r\n        CommonItemsWriter::writeShortDescription(writer, instance->shortDescription());\r\n    }\r\n\r\n    CommonItemsWriter::writeDescription(writer, instance->description());\r\n\r\n    if (docRevision == Document::Revision::Std14)\r\n    {\r\n        CommonItemsWriter::writeIsPresent(writer, instance->getIsPresent());\r\n    }\r\n\r\n    Details::writeConfigurableVLNVReference(writer, instance->getComponentRef(), QStringLiteral(\"ipxact:componentRef\"));\r\n\r\n    if (docRevision == Document::Revision::Std22)\r\n    {\r\n        Details::writePowerDomainLinks(writer, instance);\r\n    }\r\n\r\n    CommonItemsWriter::writeVendorExtensions(writer, instance);\r\n\r\n    writer.writeEndElement(); // ipxact:componentInstance\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentInstanceWriter::writeConfigurableVLNVReference()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentInstanceWriter::Details::writeConfigurableVLNVReference(QXmlStreamWriter& writer,\r\n    QSharedPointer<ConfigurableVLNVReference> VLNVreference, QString const& xmlElementName)\r\n{\r\n    writer.writeStartElement(xmlElementName);\r\n\r\n    CommonItemsWriter::writeVLNVAttributes(writer, *VLNVreference);\r\n\r\n    if (!VLNVreference->getConfigurableElementValues()->isEmpty())\r\n    {\r\n        writer.writeStartElement(QStringLiteral(\"ipxact:configurableElementValues\"));\r\n\r\n        for (auto const& configurableElement : *VLNVreference->getConfigurableElementValues())\r\n        {\r\n            writer.writeStartElement(QStringLiteral(\"ipxact:configurableElementValue\"));\r\n            writer.writeAttribute(QStringLiteral(\"referenceId\"), configurableElement->getReferenceId());\r\n            writer.writeCharacters(configurableElement->getConfigurableValue());\r\n            writer.writeEndElement(); // ipxact:configurableElementValue\r\n        }\r\n        writer.writeEndElement(); // ipxact:configurableElementValues\r\n    }\r\n\r\n    writer.writeEndElement(); // xmlElementName\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentInstanceWriter::writePowerDomainLinks()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentInstanceWriter::Details::writePowerDomainLinks(QXmlStreamWriter& writer,\r\n    QSharedPointer<ComponentInstance> instance)\r\n{\r\n    if (instance->getPowerDomainLinks()->isEmpty())\r\n    {\r\n        return;\r\n    }\r\n\r\n    writer.writeStartElement(QStringLiteral(\"ipxact:powerDomainLinks\"));\r\n    for (auto const& link : *instance->getPowerDomainLinks())\r\n    {\r\n        writer.writeStartElement(QStringLiteral(\"ipxact:powerDomainLink\"));\r\n\r\n        writer.writeTextElement(QStringLiteral(\"ipxact:externalPowerDomainReference\"), \r\n            link->externalReference_);\r\n\r\n        for (const auto& internalReference : link->internalReferences_)\r\n        {\r\n            writer.writeTextElement(QStringLiteral(\"ipxact:internalPowerDomainReference\"), internalReference);\r\n        }\r\n\r\n        writer.writeEndElement(); // ipxact:powerDomainLink\r\n    }\r\n\r\n    writer.writeEndElement(); // ipxact:powerDomainLinks\r\n}\r\n"
  },
  {
    "path": "IPXACTmodels/Design/ComponentInstanceWriter.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ComponentInstanceWriter.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 02.09.2015\r\n//\r\n// Description:\r\n// Writer for IP-XACT component instance element.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef COMPONENTINSTANCEWRITER_H\r\n#define COMPONENTINSTANCEWRITER_H\r\n\r\n#include \"ComponentInstance.h\"\r\n\r\n#include <IPXACTmodels/common/Document.h>\r\n#include <IPXACTmodels/common/CommonItemsWriter.h>\r\n\r\n#include <QXmlStreamWriter>\r\n#include <QSharedPointer>\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Writer for IP-XACT component instance element.\r\n//-----------------------------------------------------------------------------\r\nnamespace  ComponentInstanceWriter\r\n{\r\n    /*!\r\n     *  Write the component instance.\r\n     *\r\n     *    @param [in] writer      The used XML writer.\r\n     *    @param [in] design      The selected component instance.\r\n     *    @param [in] docRevision The IP-XACT standard revision to apply.\r\n     */\r\n    IPXACTMODELS_EXPORT void writeComponentInstance(QXmlStreamWriter& writer, \r\n        QSharedPointer<ComponentInstance> instance, Document::Revision docRevision);\r\n\r\n    namespace Details\r\n    {\r\n        /*!\r\n         *  Write a configurable VLNV.\r\n         *\r\n         *    @param [in] writer          The used XML writer.\r\n         *    @param [in] VLNVreference   The configurable VLNV.\r\n         *    @param [in] xmlElementName  The name of the XML element.\r\n         */\r\n        void writeConfigurableVLNVReference(QXmlStreamWriter& writer,\r\n            QSharedPointer<ConfigurableVLNVReference> VLNVreference, QString const& xmlElementName);\r\n\r\n        /*!\r\n         * Write the power domain links of the component instance\r\n         *\r\n         *    @param [in] writer       The used XML writer.\r\n         *    @param [in] instance     The instance whose power domain links to write.\r\n         */\r\n         void writePowerDomainLinks(QXmlStreamWriter& writer, QSharedPointer<ComponentInstance> instance);\r\n    }\r\n};\r\n\r\n#endif // COMPONENTINSTANCEWRITER_H\r\n"
  },
  {
    "path": "IPXACTmodels/Design/Design.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: Design.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 17.08.2015\r\n//\r\n// Description:\r\n// Describes the ipxact:design element in an IP-XACT document\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"Design.h\"\r\n\r\n#include <IPXACTmodels/kactusExtensions/Kactus2Placeholder.h>\r\n#include <IPXACTmodels/kactusExtensions/ConnectionRoute.h>\r\n#include <IPXACTmodels/kactusExtensions/InterfaceGraphicsData.h>\r\n\r\n#include <IPXACTmodels/utilities/Search.h>\r\n#include <IPXACTmodels/utilities/Copy.h>\r\n\r\n#include <KactusAPI/include/LibraryInterface.h>\r\n\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Design::Design()\r\n//-----------------------------------------------------------------------------\r\nDesign::Design(VLNV const& vlnv, Document::Revision revision) :\r\nDocument(vlnv, revision)\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Design::Design()\r\n//-----------------------------------------------------------------------------\r\nDesign::Design(Design const& other) :\r\nDocument(other)\r\n{\r\n    copySharedLists(other);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Design::operator=()\r\n//-----------------------------------------------------------------------------\r\nDesign& Design::operator=( const Design& other )\r\n{\r\n\tif (this != &other)\r\n    {\r\n\t\tDocument::operator=(other);\r\n\r\n        componentInstances_->clear();\r\n        interconnections_->clear();\r\n        monitorInterconnections_->clear();\r\n        adHocConnections_->clear();\r\n\r\n        copySharedLists(other);\r\n\t}\r\n\treturn *this;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Design::close()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<Document> Design::clone() const\r\n{\r\n\treturn QSharedPointer<Document>(new Design(*this));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Design::setVlnv()\r\n//-----------------------------------------------------------------------------\r\nvoid Design::setVlnv(VLNV const& vlnv)\r\n{\r\n    VLNV designVLNV(vlnv);\r\n    designVLNV.setType(VLNV::DESIGN);\r\n    Document::setVlnv(vlnv);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Design::findComponentInstance()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<ComponentInstance> Design::findComponentInstance(QString const& instanceName) const\r\n{\r\n    return Search::findByName(instanceName, componentInstances_);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Design::getComponentInstances()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<QList<QSharedPointer<ComponentInstance> > > Design::getComponentInstances() const\r\n{\r\n\treturn componentInstances_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Design::getInterconnections()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<QList<QSharedPointer<Interconnection> > > Design::getInterconnections() const\r\n{\r\n    return interconnections_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Design::getAdHocConnections()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<QList<QSharedPointer<AdHocConnection> > > Design::getAdHocConnections() const\r\n{\r\n    return adHocConnections_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Design::setComponentInstances()\r\n//-----------------------------------------------------------------------------\r\nvoid Design::setComponentInstances(QSharedPointer<QList<QSharedPointer<ComponentInstance> > > newComponentInstances)\r\n{\r\n    componentInstances_ = newComponentInstances;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Design::setInterconnections()\r\n//-----------------------------------------------------------------------------\r\nvoid Design::setInterconnections(QSharedPointer<QList<QSharedPointer<Interconnection> > > newInterconnections)\r\n{\r\n    interconnections_ = newInterconnections;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Design::setAdHocConnections()\r\n//-----------------------------------------------------------------------------\r\nvoid Design::setAdHocConnections(QSharedPointer<QList<QSharedPointer<AdHocConnection> > > newAdHocConnections)\r\n{\r\n    adHocConnections_ = newAdHocConnections;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Design::getDependentFiles()\r\n//-----------------------------------------------------------------------------\r\nQStringList Design::getDependentFiles() const\r\n{\r\n\t// TODO implement this\r\n\treturn QStringList();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Design::getDependentVLNVs()\r\n//-----------------------------------------------------------------------------\r\nQList<VLNV> Design::getDependentVLNVs() const\r\n{\r\n\tQList<VLNV> instanceList;\r\n\r\n\t// go through all component instances within the design\r\n    for (auto const& instance : *componentInstances_)\r\n    {\r\n\t\t// if the pointer is valid and it is not already added to the list of\r\n\t\t// component instances (two instances of same component are not added twice)\r\n        QSharedPointer<ConfigurableVLNVReference> componentReference = instance->getComponentRef();\r\n\r\n        if (componentReference->isValid() && !instanceList.contains(*componentReference))\r\n        {\r\n            instanceList.append(*componentReference);\r\n        }\r\n\t}\r\n\r\n\treturn instanceList;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Design::getPortAdHocVisibilities()\r\n//-----------------------------------------------------------------------------\r\nQMap<QString, bool> Design::getPortAdHocVisibilities() const\r\n{\r\n    QList<QSharedPointer<VendorExtension> > portAdHocExtensions =\r\n        getGroupedExtensionsByType(QStringLiteral(\"kactus2:adHocVisibilities\"),\r\n        QStringLiteral(\"kactus2:adHocVisible\"));\r\n\r\n    QMap<QString, bool> portAdHocVisibilities;\r\n\r\n    for (auto const& extension : portAdHocExtensions)\r\n    {\r\n        QSharedPointer<Kactus2Placeholder> portAdHocVisibility = extension.dynamicCast<Kactus2Placeholder>();\r\n        \r\n        QString portName = portAdHocVisibility->getAttributeValue(QStringLiteral(\"portName\"));\r\n\r\n        portAdHocVisibilities.insert(portName, true);\r\n    }\r\n\r\n    return portAdHocVisibilities;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Design::getAdHocPortPositions()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<VendorExtension> Design::getAdHocPortPositions() const\r\n{\r\n    return findVendorExtension(QStringLiteral(\"kactus2:adHocVisibilities\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Design::getColumns()\r\n//-----------------------------------------------------------------------------\r\nQList<QSharedPointer<ColumnDesc> > Design::getColumns() const\r\n{\r\n    QList<QSharedPointer<ColumnDesc> > columnList;\r\n\r\n    if (QSharedPointer<Kactus2Group> columnExtensions = getLayoutExtension(); \r\n        columnExtensions != nullptr)\r\n    {  \r\n        auto columnIdentifier = QStringLiteral(\"kactus2:column\");\r\n        for (auto const& extension : columnExtensions->getByType(columnIdentifier))\r\n        {\r\n            columnList.append(extension.dynamicCast<ColumnDesc>());\r\n        }\r\n    }\r\n\r\n    return columnList;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Design::getRoutes()\r\n//-----------------------------------------------------------------------------\r\nQList<QSharedPointer<ConnectionRoute> > Design::getRoutes() const\r\n{\r\n    QList<QSharedPointer<ConnectionRoute> > routes;\r\n \r\n    if (QSharedPointer<Kactus2Group> routeExtensions = getRoutesExtension(); \r\n        routeExtensions != nullptr)\r\n    {  \r\n        auto routeIdentifier = QStringLiteral(\"kactus2:route\");\r\n        for (auto const& extension : routeExtensions->getByType(routeIdentifier))\r\n        {\r\n            routes.append(extension.dynamicCast<ConnectionRoute>());\r\n        }\r\n    }\r\n\r\n    return routes;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Design::setAdHocPortPositions()\r\n//-----------------------------------------------------------------------------\r\nvoid Design::setAdHocPortPositions(QMap<QString, QPointF> const& val) const\r\n{\r\n    auto extension = findVendorExtension(QStringLiteral(\"kactus2:adHocVisibilities\"));\r\n    getVendorExtensions()->removeAll(extension);\r\n\r\n    if (!val.isEmpty())\r\n    {\r\n        QSharedPointer<Kactus2Group> portAdHocs(new Kactus2Group(QStringLiteral(\"kactus2:adHocVisibilities\")));\r\n\r\n        for (auto it = val.cbegin(); it != val.cend(); ++it)\r\n        {\r\n            QSharedPointer<Kactus2Placeholder> newAdHocPort(new Kactus2Placeholder(QStringLiteral(\"kactus2:adHocVisible\")));\r\n\r\n            newAdHocPort->setAttribute(QStringLiteral(\"portName\"), it.key());\r\n            newAdHocPort->setAttribute(QStringLiteral(\"x\"), QString::number(it.value().x()));\r\n            newAdHocPort->setAttribute(QStringLiteral(\"y\"), QString::number(it.value().y()));\r\n\r\n            portAdHocs->addToGroup(newAdHocPort);\r\n        }\r\n\r\n        getVendorExtensions()->append(portAdHocs);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Design::setApiConnections()\r\n//-----------------------------------------------------------------------------\r\nvoid Design::setApiConnections(QList<QSharedPointer<ApiInterconnection> > newApiConnections) const\r\n{\r\n    auto extension = findVendorExtension(QStringLiteral(\"kactus2:apiConnections\"));\r\n    getVendorExtensions()->removeAll(extension);\r\n\r\n    if (!newApiConnections.isEmpty())\r\n    {\r\n        QSharedPointer<Kactus2Group> newApiConnectionGroup(\r\n            new Kactus2Group(QStringLiteral(\"kactus2:apiConnections\")));\r\n\r\n        for (auto const& connection : newApiConnections)\r\n        {\r\n            newApiConnectionGroup->addToGroup(connection);\r\n        }\r\n\r\n        getVendorExtensions()->append(newApiConnectionGroup);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Design::setComConnections()\r\n//-----------------------------------------------------------------------------\r\nvoid Design::setComConnections(QList<QSharedPointer<ComInterconnection> > newComConnections) const\r\n{\r\n    auto extension = findVendorExtension(QStringLiteral(\"kactus2:comConnections\"));\r\n    getVendorExtensions()->removeAll(extension);\r\n\r\n    if (!newComConnections.isEmpty())\r\n    {\r\n        QSharedPointer<Kactus2Group> newComConnectionGroup(\r\n            new Kactus2Group(QStringLiteral(\"kactus2:comConnections\")));\r\n\r\n        for (auto const& connection : newComConnections)\r\n        {\r\n            newComConnectionGroup->addToGroup(connection);\r\n        }\r\n\r\n        getVendorExtensions()->append(newComConnectionGroup);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Design::getApiDependencies()\r\n//-----------------------------------------------------------------------------\r\nQList<QSharedPointer<ApiInterconnection> > Design::getApiConnections() const\r\n{\r\n    QList<QSharedPointer<VendorExtension> > apiConnectionExtensions =\r\n        getGroupedExtensionsByType(QStringLiteral(\"kactus2:apiConnections\"), QStringLiteral(\"kactus2:apiConnection\"));\r\n\r\n    QList<QSharedPointer<ApiInterconnection> > connectionList;\r\n\r\n    for (auto const& extension : apiConnectionExtensions)\r\n    {\r\n        connectionList.append(extension.dynamicCast<ApiInterconnection>());\r\n    }\r\n\r\n    return connectionList;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Design::getComConnections()\r\n//-----------------------------------------------------------------------------\r\nQList<QSharedPointer<ComInterconnection> > Design::getComConnections() const\r\n{\r\n    QList<QSharedPointer<VendorExtension> > comConnectionExtensions =\r\n        getGroupedExtensionsByType(QStringLiteral(\"kactus2:comConnections\"), QStringLiteral(\"kactus2:comConnection\"));\r\n\r\n    QList<QSharedPointer<ComInterconnection> > comConnectionList;\r\n\r\n    for (auto const& extension : comConnectionExtensions)\r\n    {\r\n        comConnectionList.append(extension.dynamicCast<ComInterconnection>());\r\n    }\r\n\r\n    return comConnectionList;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: design::hasInterconnection()\r\n//-----------------------------------------------------------------------------\r\nbool Design::hasInterconnection(QString const& instanceName, QString const& interfaceName) const \r\n{\r\n    return std::any_of(interconnections_->cbegin(), interconnections_->cend(), \r\n        [&instanceName, &interfaceName](auto const& interconnection)\r\n        { return interconnection->hasInterfaceReferencingComponent(instanceName, interfaceName); });\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: design::getHWComponentVLNV()\r\n//-----------------------------------------------------------------------------\r\nVLNV Design::getHWComponentVLNV(QString const& instanceName) const \r\n{\r\n    if (auto const instance = findComponentInstance(instanceName); instance != nullptr)\r\n    {\r\n        return *instance->getComponentRef();\r\n    }\r\n\r\n\t// no instance was found\r\n\treturn VLNV();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: design::containsHWInstance()\r\n//-----------------------------------------------------------------------------\r\nbool Design::containsHWInstance(QString const& instanceName) const\r\n{\r\n    return findComponentInstance(instanceName) != nullptr;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: design::hasConfElementValue()\r\n//-----------------------------------------------------------------------------\r\nbool Design::hasConfElementValue(QString const& instanceName, QString const& confElementName) const\r\n{\r\n    if (auto const instance = findComponentInstance(instanceName); instance != nullptr)\r\n    {\r\n        return instance->getComponentRef()->hasConfigurableElementValue(confElementName);\r\n    }\r\n\r\n\t// specified instance was not found\r\n\treturn false;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: design::getConfElementValue()\r\n//-----------------------------------------------------------------------------\r\nQString Design::getConfElementValue(QString const& instanceName, QString const& confElementName) const\r\n{\r\n    if (auto const instance = findComponentInstance(instanceName); instance != nullptr)\r\n    {\r\n        return instance->getComponentRef()->getSingleConfigurableElementValue(confElementName);\r\n    }\r\n\r\n\t// specified instance was not found\r\n\treturn QString();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: design::setDesignImplementation()\r\n//-----------------------------------------------------------------------------\r\nvoid Design::setDesignImplementation(KactusAttribute::Implementation implementation)\r\n{\r\n    setImplementation(implementation);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: design::getDesignImplementation()\r\n//-----------------------------------------------------------------------------\r\nKactusAttribute::Implementation Design::getDesignImplementation() const\r\n{\r\n    return getImplementation();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: design::getHWInstanceDescription()\r\n//-----------------------------------------------------------------------------\r\nQString Design::getHWInstanceDescription(QString const& instanceName) const\r\n{\r\n    if (auto const instance = findComponentInstance(instanceName); instance != nullptr)\r\n    {\r\n        return instance->description();\r\n    }\r\n\r\n\treturn QString();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Design::getMonitorInterconnecions()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<QList<QSharedPointer<MonitorInterconnection> > > Design::getMonitorInterconnecions() const\r\n{\r\n    return monitorInterconnections_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Design::setMonitorInterconnections()\r\n//-----------------------------------------------------------------------------\r\nvoid Design::setMonitorInterconnections(\r\n    QSharedPointer<QList<QSharedPointer<MonitorInterconnection> > > newMonitorInterconnections)\r\n{\r\n    monitorInterconnections_ = newMonitorInterconnections;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Design::addColumn()\r\n//-----------------------------------------------------------------------------\r\nvoid Design::addColumn(QSharedPointer<ColumnDesc> column)\r\n{\r\n    QSharedPointer<Kactus2Group> layoutGroup = getLayoutExtension();\r\n\r\n    if (layoutGroup.isNull())\r\n    {\r\n        layoutGroup = QSharedPointer<Kactus2Group>(new Kactus2Group(QStringLiteral(\"kactus2:columnLayout\")));\r\n        getVendorExtensions()->append(layoutGroup);\r\n    }\r\n    \r\n    layoutGroup->addToGroup(column);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Design::removeColumn()\r\n//-----------------------------------------------------------------------------\r\nvoid Design::removeColumn(QSharedPointer<ColumnDesc> column) const\r\n{\r\n    QSharedPointer<Kactus2Group> layoutGroup = getLayoutExtension();\r\n    if (!layoutGroup.isNull())\r\n    {\r\n        layoutGroup->removeFromGroup(column);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Design::addRoute()\r\n//-----------------------------------------------------------------------------\r\nvoid Design::addRoute(QSharedPointer<ConnectionRoute> route) const\r\n{\r\n    QSharedPointer<Kactus2Group> routesGroup = getRoutesExtension();\r\n\r\n    if (routesGroup.isNull())\r\n    {\r\n        routesGroup = QSharedPointer<Kactus2Group>(new Kactus2Group(QStringLiteral(\"kactus2:routes\")));\r\n        getVendorExtensions()->append(routesGroup);\r\n    }\r\n\r\n    routesGroup->addToGroup(route);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Design::removeRoute()\r\n//-----------------------------------------------------------------------------\r\nvoid Design::removeRoute(QSharedPointer<ConnectionRoute> route) const\r\n{\r\n    QSharedPointer<Kactus2Group> routesGroup = getRoutesExtension();\r\n\r\n    if (!routesGroup.isNull())\r\n    {\r\n        routesGroup->removeFromGroup(route);\r\n\r\n        if (routesGroup->getByType(QStringLiteral(\"kactus2:route\")).isEmpty())\r\n        {\r\n            getVendorExtensions()->removeAll(routesGroup);\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Design::copySharedLists()\r\n//-----------------------------------------------------------------------------\r\nvoid Design::copySharedLists(Design const& other)\r\n{\r\n    Copy::copyList(other.componentInstances_, componentInstances_);\r\n\r\n    Copy::copyList(other.interconnections_, interconnections_);\r\n\r\n    Copy::copyList(other.monitorInterconnections_, monitorInterconnections_);\r\n\r\n    Copy::copyList(other.adHocConnections_, adHocConnections_);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Design::getLayoutExtension()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<Kactus2Group> Design::getLayoutExtension() const\r\n{\r\n    return findVendorExtension(QStringLiteral(\"kactus2:columnLayout\")).dynamicCast<Kactus2Group>();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Design::getRoutesExtension()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<Kactus2Group> Design::getRoutesExtension() const\r\n{\r\n    return findVendorExtension(QStringLiteral(\"kactus2:routes\")).dynamicCast<Kactus2Group>();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Design::getInterfacePositions()\r\n//-----------------------------------------------------------------------------\r\nQList<QSharedPointer<InterfaceGraphicsData> > Design::getInterfaceGraphicsData() const\r\n{\r\n    QList<QSharedPointer<InterfaceGraphicsData> > interfaceGrahics;\r\n\r\n    for (auto const& extension : *getVendorExtensions())\r\n    {\r\n        if (extension->type() == QLatin1String(\"kactus2:interfaceGraphics\"))\r\n        {\r\n            QSharedPointer<InterfaceGraphicsData> graphicsData = extension.dynamicCast<InterfaceGraphicsData>();\r\n            if (graphicsData)\r\n            {\r\n                interfaceGrahics.append(extension.dynamicCast<InterfaceGraphicsData>());\r\n            }\r\n        }\r\n    }\r\n\r\n    return interfaceGrahics;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Design::removeInterfacePosition()\r\n//-----------------------------------------------------------------------------\r\nvoid Design::removeInterfaceGraphicsData(QString const& name) const\r\n{\r\n    for (auto const& containedInterface : getInterfaceGraphicsData())\r\n    {\r\n        if (name == containedInterface->getName())\r\n        {\r\n            getVendorExtensions()->removeAll(containedInterface);\r\n            return;\r\n        }\r\n    }\r\n}\r\n"
  },
  {
    "path": "IPXACTmodels/Design/Design.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: Design.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 17.08.2015\r\n//\r\n// Description:\r\n// Describes the ipxact:design element in an IP-XACT document\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef DESIGN_H\r\n#define DESIGN_H\r\n\r\n#include \"ComponentInstance.h\"\r\n#include \"Interconnection.h\"\r\n#include \"MonitorInterconnection.h\"\r\n#include \"AdHocConnection.h\"\r\n\r\n#include <IPXACTmodels/common/VendorExtension.h>\r\n#include <IPXACTmodels/common/VLNV.h>\r\n#include <IPXACTmodels/ipxactmodels_global.h>\r\n\r\n#include <IPXACTmodels/common/Document.h>\r\n\r\n#include <IPXACTmodels/kactusExtensions/KactusAttribute.h>\r\n#include <IPXACTmodels/kactusExtensions/ColumnDesc.h>\r\n#include <IPXACTmodels/kactusExtensions/Kactus2Group.h>\r\n#include <IPXACTmodels/kactusExtensions/ApiInterconnection.h>\r\n#include <IPXACTmodels/kactusExtensions/ComInterconnection.h>\r\n\r\n#include <QSharedPointer>\r\n#include <QList>\r\n#include <QString>\r\n#include <QMap>\r\n#include <QDomDocument>\r\n#include <QDomNode>\r\n#include <QStringList>\r\n#include <QFile>\r\n#include <QPointF>\r\n\r\nclass ConnectionRoute;\r\nclass InterfaceGraphicsData;\r\nclass LibraryInterface;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Implementation for the ipxact:design element.\r\n//-----------------------------------------------------------------------------\r\nclass IPXACTMODELS_EXPORT Design : public Document\r\n{\r\n\r\npublic:\r\n\t/*!\r\n\t *  The constructor.\r\n\t *\r\n\t *    @param [in] vlnv    The VLNV for the design.\r\n\t */\r\n\tDesign(VLNV const& vlnv, Document::Revision revision);\r\n\r\n\t/*!\r\n\t *  Copy constructor.\r\n\t */\r\n\tDesign(Design const& other);\r\n\r\n\t/*!\r\n\t *  Assignment operator.\r\n\t */\r\n\tDesign& operator=(Design const& other);\r\n\r\n\t/*!\r\n\t *  The destructor.\r\n\t */\r\n\t~Design() final = default;\r\n\r\n\t/*!\r\n\t *  Clone this design.\r\n\t *\r\n     *    @return A pointer to the cloned copy.\r\n\t */\r\n\tQSharedPointer<Document> clone()  const final;\r\n\r\n\t/*!\r\n\t *  Set the VLNV.\r\n\t *\r\n\t *    @param [in] vlnv    The new VLNV.\r\n\t */\r\n\tvoid setVlnv(VLNV const& vlnv) final;\r\n\r\n\t/*\r\n\t*  Get the component instance by name.\r\n\t*/\r\n\tQSharedPointer<ComponentInstance> findComponentInstance(QString const& instanceName) const;\r\n\r\n    /*!\r\n     *  Get the component instances.\r\n     *\r\n     *    @return A pointer to a list containing the component instances\r\n     */\r\n    QSharedPointer<QList<QSharedPointer<ComponentInstance> > > getComponentInstances() const;\r\n\r\n    /*!\r\n\t *  Get the description of the specified HW instance.\r\n\t *\r\n\t *    @param [in] instanceName    The name of the instance to be searched for.\r\n     *\r\n     *    @return The description of the found HW instance.\r\n\t */\r\n\tQString getHWInstanceDescription(QString const& instanceName) const;\r\n\r\n    /*!\r\n     *  Get a list of the interconnections.\r\n     *\r\n     *    @return Pointer to a list of interconnections.\r\n     */\r\n    QSharedPointer<QList<QSharedPointer<Interconnection> > > getInterconnections() const;\r\n\r\n\t/*!\r\n\t *  Check if the specified interface is connected to some other interface within the design.\r\n\t *\r\n\t *    @param [in] instanceName    The name of the instance.\r\n\t *    @param [in] interfaceName   The name of the interface.\r\n     *\r\n     *    @return True if at least one interconnection is found, false otherwise.\r\n\t */\r\n\tbool hasInterconnection(QString const& instanceName, QString const& interfaceName) const;\r\n\r\n    /*!\r\n     *  Get a list of ad-hoc connections.\r\n     *\r\n     *    @return Pointer to a list of ad-hoc connections.\r\n     */\r\n    QSharedPointer<QList<QSharedPointer<AdHocConnection> > > getAdHocConnections() const;\r\n\r\n    /*!\r\n     *  Returns the list of API dependencies.\r\n     */\r\n    QList<QSharedPointer<ApiInterconnection> > getApiConnections() const;\r\n\r\n    /*!\r\n     *  Returns the list of COM connections.\r\n     */\r\n    QList<QSharedPointer<ComInterconnection> > getComConnections() const;\r\n\r\n    /*!\r\n     *  Returns the port ad-hoc visibilities for the top-level component in this design.\r\n     */\r\n    QMap<QString, bool> getPortAdHocVisibilities() const;\r\n\r\n    /*!\r\n     *  Returns the ad-hoc port positions.\r\n     */\r\n    QSharedPointer<VendorExtension> getAdHocPortPositions() const;\r\n\r\n    /*! \r\n     *  Returns the list of columns.\r\n     */\r\n    QList<QSharedPointer<ColumnDesc> > getColumns() const;\r\n\r\n    /*! \r\n     *  Returns the list of routes.\r\n     */\r\n    QList<QSharedPointer<ConnectionRoute> > getRoutes() const;\r\n\r\n    /*!\r\n     *  Set the component instances.\r\n     *\r\n     *    @param [in] newComponentInstances   A list of new component instances.\r\n     */\r\n    void setComponentInstances(QSharedPointer<QList<QSharedPointer<ComponentInstance> > > newComponentInstances);\r\n\r\n    /*!\r\n     *  Set the interconnections.\r\n     *\r\n     *    @param [in] newInterconnections     A list of new interconnections.\r\n     */\r\n    void setInterconnections(QSharedPointer<QList<QSharedPointer<Interconnection> > > newInterconnections);\r\n\r\n    /*!\r\n     *  Set the ad-hoc connections.\r\n     *\r\n     *    @param [in] newAdHocConnections     A list of new ad-hoc connections.\r\n     */\r\n    void setAdHocConnections(QSharedPointer<QList<QSharedPointer<AdHocConnection> > > newAdHocConnections);\r\n\r\n    /*!\r\n     *  Sets the API dependencies for the design.\r\n     *\r\n     *    @param [in] apiDependencies A list of API dependencies.\r\n     */\r\n    void setApiConnections(QList<QSharedPointer<ApiInterconnection> > newApiConnections) const;\r\n\r\n    /*!\r\n     *  Sets the COM connections for the design.\r\n     *\r\n     *    @param [in] comConnections A list of COM connections.\r\n     */\r\n    void setComConnections(QList<QSharedPointer<ComInterconnection> > newComConnections) const;\r\n\r\n    /*!\r\n     *  Sets the ad-hoc port positions.\r\n     */\r\n    void setAdHocPortPositions(QMap<QString, QPointF> const& val) const;\r\n\r\n\t/*!\r\n\t *  Get the dependent files.\r\n     *\r\n     *    @return A list of the dependent file names.\r\n\t */\r\n\tQStringList getDependentFiles() const final;\r\n\r\n\t/*!\r\n\t *  Get dependend VLNVs.\r\n\t *\r\n     *    @return A list of the dependend VLNVs.\r\n\t */\r\n\tQList<VLNV> getDependentVLNVs() const final;\r\n\r\n\t/*!\r\n\t *  Get the VLNV of the HW component instantiated with the given name.\r\n\t *\r\n\t *    @param [in] instanceName    The name identifying the component instance.\r\n     *\r\n     *    @return VLNV of the instantiated component.\r\n\t */\r\n\tVLNV getHWComponentVLNV(QString const& instanceName) const;\r\n\r\n\t/*!\r\n\t *  Check if the design contains a given HW instance.\r\n\t *\r\n\t *    @param [in] instanceName    The name of the HW instance being searched.\r\n     *\r\n     *    @return True if the instance is found, false otherwise.\r\n\t */\r\n\tbool containsHWInstance(QString const& instanceName) const;\r\n\r\n\t/*!\r\n\t *  Check if there is a configurable element value set for the given HW instance.\r\n\t *\r\n\t *    @param [in] instanceName        The name of the HW instance.\r\n\t *    @param [in] confElementName     The identifier of the configurable element value.\r\n     *\r\n     *    @return Ture if the value has been set, otherwise false.\r\n\t */\r\n\tbool hasConfElementValue(QString const& instanceName, QString const& confElementName) const;\r\n\r\n\t/*!\r\n\t *  Get the configurable element value set for the given HW instance.\r\n\t *\r\n\t *    @param [in] instanceName        Identifies the HW instance.\r\n\t *    @param [in] confElementName     Identifies the configurable element value.\r\n     *\r\n     *    @return QString containing the configurable element value.\r\n\t */\r\n\tQString getConfElementValue(QString const& instanceName, QString const& confElementName) const;\r\n\r\n\t/*!\r\n\t *  Set the implementation type of the design.\r\n\t *\r\n\t *    @param [in] implementation  The new implementation type.\r\n\t */\r\n\tvoid setDesignImplementation(KactusAttribute::Implementation implementation);\r\n\r\n\t/*!\r\n\t *  Get the implementation type.\r\n\t *\r\n     *    @return The implementation type.\r\n\t */\r\n\tKactusAttribute::Implementation getDesignImplementation() const;\r\n\r\n    /*!\r\n     *  Get the monitor interconnections.\r\n     *\r\n     *    @return A pointer to the monitor interconnections.\r\n     */\r\n    QSharedPointer<QList<QSharedPointer<MonitorInterconnection> > > getMonitorInterconnecions() const;\r\n\r\n    /*!\r\n     *  Set the monitor interconnections.\r\n     *\r\n     *    @param [in] newMonitorInterconnections  The new monitor interconnections.\r\n     */\r\n    void setMonitorInterconnections(\r\n        QSharedPointer<QList<QSharedPointer<MonitorInterconnection> > > newMonitorInterconnections);\r\n\r\n    /*!\r\n     *  Adds a column to the design vendor extensions.\r\n     *\r\n     *    @param [in] column   The column to add.\r\n     */\r\n    void addColumn(QSharedPointer<ColumnDesc> column);\r\n\r\n    /*!\r\n     *  Removes a column from design vendor extensions.\r\n     *\r\n     *    @param [in] column   The column to remove\r\n     */\r\n    void removeColumn(QSharedPointer<ColumnDesc> column) const;    \r\n\r\n    void addRoute(QSharedPointer<ConnectionRoute> route) const;\r\n    \r\n    void removeRoute(QSharedPointer<ConnectionRoute> route) const;\r\n\r\n    /*!\r\n     *  Get the interface graphics data.\r\n     *\r\n     *    @return A list containing all the interface graphics data.\r\n     */\r\n    QList<QSharedPointer<InterfaceGraphicsData> > getInterfaceGraphicsData() const;\r\n\r\n    /*!\r\n     *  Remove the selected interface graphics data.\r\n     *\r\n     *    @param [in] name    Name of the selected graphics data.\r\n     */\r\n    void removeInterfaceGraphicsData(QString const& name) const;\r\n\r\nprivate:\r\n    /*!\r\n     *  Copy the shared lists of another design.\r\n     *\r\n     *    @param [in] other   The design being copied.\r\n     */\r\n    void copySharedLists(Design const& other);\r\n\r\n    /*!\r\n     *  Gets the vendor extension containing the column layout.\r\n     *\r\n     *    @return The extensions for the column layout.\r\n     */\r\n    QSharedPointer<Kactus2Group> getLayoutExtension() const;\r\n  \r\n    /*!\r\n     *  Gets the vendor extension containing the interconnection routes.\r\n     *\r\n     *    @return The extensions for the interconnection routes.\r\n     */\r\n    QSharedPointer<Kactus2Group> getRoutesExtension() const;\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! The HW component instances.\r\n    ComponentInstance::List componentInstances_ =\r\n        ComponentInstance::List(new QList<QSharedPointer<ComponentInstance> >());\r\n\r\n    //! The interconnections.\r\n    QSharedPointer<QList<QSharedPointer<Interconnection> > > interconnections_ =\r\n        QSharedPointer<QList<QSharedPointer<Interconnection> > >(new QList<QSharedPointer<Interconnection> >());\r\n    \r\n    //! The monitor interconnections.\r\n    QSharedPointer<QList<QSharedPointer<MonitorInterconnection> > > monitorInterconnections_ =\r\n        QSharedPointer<QList<QSharedPointer<MonitorInterconnection> > >(new QList<QSharedPointer<MonitorInterconnection> >());\r\n\r\n    //! Ad-hoc connections\r\n    QSharedPointer<QList<QSharedPointer<AdHocConnection> > > adHocConnections_ =\r\n         QSharedPointer<QList<QSharedPointer<AdHocConnection> > >(new QList<QSharedPointer<AdHocConnection> >());\r\n\r\n};\r\n\r\n#endif // DESIGN_H\r\n"
  },
  {
    "path": "IPXACTmodels/Design/DesignReader.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: DesignReader.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 25.08.2015\r\n//\r\n// Description:\r\n// XML reader class for IP-XACT design element.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"DesignReader.h\"\r\n#include \"ComponentInstanceReader.h\"\r\n\r\n#include <IPXACTmodels/common/NameGroupReader.h>\r\n\r\n#include <IPXACTmodels/kactusExtensions/ConnectionRoute.h>\r\n\r\n#include <IPXACTmodels/common/GenericVendorExtension.h>\r\n#include <IPXACTmodels/kactusExtensions/Kactus2Position.h>\r\n#include <IPXACTmodels/kactusExtensions/Kactus2Placeholder.h>\r\n#include <IPXACTmodels/kactusExtensions/InterfaceGraphicsData.h>\r\n\r\n#include <IPXACTmodels/utilities/XmlUtils.h>\r\n\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignReader::createDesignFrom()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<Design> DesignReader::createDesignFrom(QDomDocument const& document)\r\n{\r\n    QDomNode designNode = document.firstChildElement();\r\n\r\n    VLNV vlnv = CommonItemsReader::createVLNVFrom(designNode, VLNV::DESIGN);\r\n    Document::Revision docRevision = DocumentReader::getXMLDocumentRevision(designNode);\r\n\r\n    QSharedPointer<Design> newDesign (new Design(vlnv, docRevision));\r\n\r\n    DocumentReader::parseTopComments(document, newDesign);\r\n\r\n    DocumentReader::parseXMLProcessingInstructions(document, newDesign);\r\n\r\n    DocumentReader::parseNamespaceDeclarations(designNode, newDesign);\r\n\r\n    DocumentReader::parseDocumentNameGroup(designNode, newDesign);\r\n\r\n    Details::parseComponentInstances(designNode, newDesign);\r\n\r\n    Details::parseInterconnections(designNode, newDesign);\r\n\r\n    Details::parseAdHocConnections(designNode, newDesign);\r\n\r\n    DocumentReader::parseParameters(designNode, newDesign);\r\n\r\n    DocumentReader::parseAssertions(designNode, newDesign);\r\n\r\n    Details::parseDesignExtensions(designNode, newDesign);\r\n\r\n    return newDesign;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignReader::parseComponentInstances()\r\n//-----------------------------------------------------------------------------\r\nvoid DesignReader::Details::parseComponentInstances(QDomNode const& designNode, QSharedPointer<Design> newDesign)\r\n{\r\n    QDomNode componentInstancesNode = designNode.firstChildElement(QStringLiteral(\"ipxact:componentInstances\"));\r\n\r\n    QDomNodeList instanceNodes = componentInstancesNode.childNodes();\r\n\r\n    for (int i = 0; i < instanceNodes.size(); ++i)\r\n    {\r\n        QDomNode singleInstanceNode = instanceNodes.at(i);\r\n\r\n        QSharedPointer<ComponentInstance> newComponentInstance =\r\n            ComponentInstanceReader::createComponentInstanceFrom(singleInstanceNode, newDesign->getRevision());\r\n\r\n        newDesign->getComponentInstances()->append(newComponentInstance);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignReader::parseInterconnections()\r\n//-----------------------------------------------------------------------------\r\nvoid DesignReader::Details::parseInterconnections(QDomNode const& designNode, QSharedPointer<Design> newDesign)\r\n{\r\n    QDomNode multipleInterconnectionsNode = designNode.firstChildElement(QStringLiteral(\"ipxact:interconnections\"));\r\n\r\n    QDomNodeList interconnectionNodes = multipleInterconnectionsNode.childNodes();\r\n\r\n    for (int interconnectionIndex = 0; interconnectionIndex < interconnectionNodes.size(); ++interconnectionIndex)\r\n    {\r\n        QDomNode singleInterconnectionNode = interconnectionNodes.at(interconnectionIndex);\r\n        parseSingleInterconnection(singleInterconnectionNode, newDesign);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignReader::parseSingleInterconnection()\r\n//-----------------------------------------------------------------------------\r\nvoid DesignReader::Details::parseSingleInterconnection(QDomNode const& interconnectionNode,\r\n    QSharedPointer<Design> newDesign)\r\n{\r\n    if (interconnectionNode.nodeName() == QStringLiteral(\"ipxact:interconnection\"))\r\n    {\r\n        parseComponentInterconnection(interconnectionNode, newDesign);\r\n    }\r\n    else if (interconnectionNode.nodeName() == QStringLiteral(\"ipxact:monitorInterconnection\"))\r\n    {\r\n        parseMonitorInterconnection(interconnectionNode, newDesign);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignReader::parseComponentInterconnection()\r\n//-----------------------------------------------------------------------------\r\nvoid DesignReader::Details::parseComponentInterconnection(QDomNode const& interconnectionNode,\r\n    QSharedPointer<Design> newDesign)\r\n{\r\n    QSharedPointer<Interconnection> newInterconnection(new Interconnection());\r\n    NameGroupReader::parseNameGroup(interconnectionNode, newInterconnection);\r\n\r\n    QSharedPointer<ActiveInterface> startInterface (new ActiveInterface);\r\n    QDomNode startInterfaceNode = interconnectionNode.firstChildElement(QStringLiteral(\"ipxact:activeInterface\"));\r\n    parseActiveInterface(startInterfaceNode, startInterface, newDesign->getRevision());\r\n    newInterconnection->setStartInterface(startInterface);\r\n\r\n    if (newDesign->getRevision() == Document::Revision::Std14)\r\n    {\r\n        QString isPresent = interconnectionNode.firstChildElement(QStringLiteral(\"ipxact:isPresent\")).firstChild().nodeValue();\r\n        newInterconnection->setIsPresent(isPresent);\r\n    }\r\n\r\n    QDomNodeList interfaceNodes = interconnectionNode.childNodes();\r\n\r\n    for (int interfaceIndex = 0; interfaceIndex < interfaceNodes.size(); ++interfaceIndex)\r\n    {\r\n        QDomNode singleInterfaceNode = interfaceNodes.at(interfaceIndex);\r\n        if (singleInterfaceNode.nodeName() == QLatin1String(\"ipxact:activeInterface\") &&\r\n            singleInterfaceNode != startInterfaceNode)\r\n        {\r\n            QSharedPointer<ActiveInterface> activeInterface (new ActiveInterface());\r\n            parseActiveInterface(singleInterfaceNode, activeInterface, newDesign->getRevision());\r\n\r\n            newInterconnection->getActiveInterfaces()->append(activeInterface);\r\n        }\r\n        else if (singleInterfaceNode.nodeName() == QLatin1String(\"ipxact:hierInterface\"))\r\n        {\r\n            QSharedPointer<HierInterface> hierInterface (new HierInterface());\r\n            parseHierInterface(singleInterfaceNode, hierInterface);\r\n\r\n            newInterconnection->getHierInterfaces()->append(hierInterface);\r\n        }\r\n    }\r\n\r\n    parseInterconnectionExtensions(interconnectionNode, newInterconnection);\r\n\r\n    newDesign->getInterconnections()->append(newInterconnection);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignReader::parseComponentInterconnectionExtensions()\r\n//-----------------------------------------------------------------------------\r\nvoid DesignReader::Details::parseInterconnectionExtensions(const QDomNode& interconnectionNode,\r\n    QSharedPointer<Interconnection> interconnection)\r\n{\r\n    QDomNode extensionNode = interconnectionNode.firstChildElement(QStringLiteral(\"ipxact:vendorExtensions\")); \r\n    QDomElement offPageElement = extensionNode.firstChildElement(QStringLiteral(\"kactus2:offPage\"));\r\n\r\n    if (!offPageElement.isNull())\r\n    {\r\n        interconnection->setOffPage(true);\r\n    }\r\n\r\n    CommonItemsReader::parseVendorExtensions(interconnectionNode, interconnection);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignReader::parseActiveInterface()\r\n//-----------------------------------------------------------------------------\r\nvoid DesignReader::Details::parseActiveInterface(QDomNode const& interfaceNode,\r\n    QSharedPointer<ActiveInterface> newInterface, Document::Revision docRevision)\r\n{\r\n    parseHierInterface(interfaceNode, newInterface);\r\n\r\n    newInterface->setComponentReference(parseComponentReference(interfaceNode, docRevision));\r\n\r\n    QDomNode baseExcludePortsNode = interfaceNode.firstChildElement(QStringLiteral(\"ipxact:excludePorts\"));\r\n    QDomNodeList excludePortNodes = baseExcludePortsNode.childNodes();\r\n\r\n    for (int i = 0; i < excludePortNodes.size(); ++i)\r\n    {\r\n        QString portName = excludePortNodes.at(i).firstChild().nodeValue();\r\n        newInterface->getExcludePorts()->append(portName);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignReader::parseHierInterface()\r\n//-----------------------------------------------------------------------------\r\nQString DesignReader::Details::parseComponentReference(QDomNode const& interfaceNode, Document::Revision docRevision)\r\n{\r\n    QDomNamedNodeMap attributeMap = interfaceNode.attributes();\r\n\r\n    auto attributeName = QString();\r\n    if (docRevision == Document::Revision::Std14)\r\n    {\r\n        attributeName = QStringLiteral(\"componentRef\");\r\n    }\r\n    else if (docRevision == Document::Revision::Std22)\r\n    {\r\n        attributeName = QStringLiteral(\"componentInstanceRef\");\r\n    }\r\n\r\n    return attributeMap.namedItem(attributeName).nodeValue();;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignReader::parseHierInterface()\r\n//-----------------------------------------------------------------------------\r\nvoid DesignReader::Details::parseHierInterface(QDomNode const& interfaceNode, QSharedPointer<HierInterface> newInterface)\r\n{\r\n    QDomNamedNodeMap attributeMap = interfaceNode.attributes();\r\n    \r\n    newInterface->setBusReference(attributeMap.namedItem(QStringLiteral(\"busRef\")).nodeValue());\r\n    newInterface->setIsPresent(interfaceNode.firstChildElement(QStringLiteral(\"ipxact:isPresent\")).firstChild().nodeValue());\r\n    newInterface->setDescription(interfaceNode.firstChildElement(QStringLiteral(\"ipxact:description\")).firstChild().nodeValue());\r\n\r\n    parseHierInterfaceExtensions(interfaceNode, newInterface);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignReader::parseHierInterfaceExtensions()\r\n//-----------------------------------------------------------------------------\r\nvoid DesignReader::Details::parseHierInterfaceExtensions(const QDomNode& interfaceNode,\r\n    QSharedPointer<HierInterface> newInterface)\r\n{\r\n    QDomNode extensionsNode = interfaceNode.firstChildElement(QStringLiteral(\"ipxact:vendorExtensions\"));\r\n\r\n    QDomElement routeElement = extensionsNode.firstChildElement(QStringLiteral(\"kactus2:route\"));\r\n    if (!routeElement.isNull())\r\n    {\r\n        QList<QPointF> newRoute;\r\n\r\n        QDomNodeList positionNodesList = routeElement.elementsByTagName(QStringLiteral(\"kactus2:position\"));\r\n\r\n        for (int positionIndex = 0; positionIndex < positionNodesList.count(); ++positionIndex)\r\n        {\r\n            QDomNode positionNode = positionNodesList.at(positionIndex);\r\n            QDomNamedNodeMap positionAttributes = positionNode.attributes();\r\n            int positionX = positionAttributes.namedItem(QStringLiteral(\"x\")).nodeValue().toInt();\r\n            int positionY = positionAttributes.namedItem(QStringLiteral(\"y\")).nodeValue().toInt();\r\n\r\n            newRoute.append(QPointF(positionX, positionY));\r\n        }\r\n\r\n        newInterface->setRoute(newRoute);\r\n    }\r\n\r\n    CommonItemsReader::parseVendorExtensions(interfaceNode, newInterface);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignReader::parseMonitorInterconnection()\r\n//-----------------------------------------------------------------------------\r\nvoid DesignReader::Details::parseMonitorInterconnection(QDomNode const& monitorNode, QSharedPointer<Design> newDesign)\r\n{\r\n    QSharedPointer<MonitorInterconnection> newMonitorConnection(new MonitorInterconnection());\r\n    NameGroupReader::parseNameGroup(monitorNode, newMonitorConnection);\r\n    \r\n    QDomNode activeInterfaceNode = monitorNode.firstChildElement(QStringLiteral(\"ipxact:monitoredActiveInterface\"));\r\n    QSharedPointer<MonitorInterface> monitoredActiveInterface(new MonitorInterface());\r\n    newMonitorConnection->setMonitoredctiveInterface(monitoredActiveInterface);\r\n\r\n    parseMonitorInterface(activeInterfaceNode, monitoredActiveInterface, newDesign->getRevision());\r\n    if (newDesign->getRevision() == Document::Revision::Std14)\r\n    {\r\n        QString isPresent = monitorNode.firstChildElement(QStringLiteral(\"ipxact:isPresent\")).firstChild().nodeValue();\r\n        newMonitorConnection->setIsPresent(isPresent);\r\n    }\r\n\r\n    QDomNodeList monitorChildNodes = monitorNode.childNodes();\r\n\r\n    for (int monitorInterfaceIndex = 0; monitorInterfaceIndex < monitorChildNodes.size(); ++monitorInterfaceIndex)\r\n    {\r\n        QDomNode monitorInterfaceNode = monitorChildNodes.at(monitorInterfaceIndex);\r\n        if (monitorInterfaceNode.nodeName() == QStringLiteral(\"ipxact:monitorInterface\"))\r\n        {\r\n            QSharedPointer<MonitorInterface> newMonitorInterface (new MonitorInterface());\r\n            parseMonitorInterface(monitorInterfaceNode, newMonitorInterface, newDesign->getRevision());\r\n\r\n            newMonitorConnection->getMonitorInterfaces()->append(newMonitorInterface);\r\n        }\r\n    }\r\n\r\n    newDesign->getMonitorInterconnecions()->append(newMonitorConnection);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignReader::parseMonitorInterface()\r\n//-----------------------------------------------------------------------------\r\nvoid DesignReader::Details::parseMonitorInterface(QDomNode const& interfaceNode,\r\n    QSharedPointer<MonitorInterface> newInterface, Document::Revision docRevision)\r\n{\r\n    parseHierInterface(interfaceNode, newInterface);\r\n\r\n    newInterface->setComponentReference(parseComponentReference(interfaceNode, docRevision));\r\n\r\n    QDomNamedNodeMap attributeMap = interfaceNode.attributes();\r\n    newInterface->setPath(attributeMap.namedItem(QStringLiteral(\"path\")).nodeValue());\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignReader::parseAdHocConnections()\r\n//-----------------------------------------------------------------------------\r\nvoid DesignReader::Details::parseAdHocConnections(QDomNode const& designNode, QSharedPointer<Design> newDesign)\r\n{\r\n    QDomNode adHocConnectionsNode = designNode.firstChildElement(QStringLiteral(\"ipxact:adHocConnections\"));\r\n\r\n    QDomNodeList adHocNodeList = adHocConnectionsNode.childNodes();\r\n\r\n    for (int adHocIndex = 0; adHocIndex < adHocNodeList.size(); ++adHocIndex)\r\n    {\r\n        parseSingleAdHocConnection(adHocNodeList.at(adHocIndex), newDesign);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignReader::parseSingleAdHocConnection()\r\n//-----------------------------------------------------------------------------\r\nvoid DesignReader::Details::parseSingleAdHocConnection(const QDomNode& adHocNode, QSharedPointer<Design> newDesign)\r\n{\r\n    QSharedPointer<AdHocConnection> newAdHocConnection(new AdHocConnection(QString()));\r\n    NameGroupReader::parseNameGroup(adHocNode, newAdHocConnection);\r\n\r\n    QString isPresent = adHocNode.firstChildElement(QStringLiteral(\"ipxact:isPresent\")).firstChild().nodeValue();\r\n    newAdHocConnection->setIsPresent(isPresent);\r\n\r\n    QString tiedValue = adHocNode.firstChildElement(QStringLiteral(\"ipxact:tiedValue\")).firstChild().nodeValue();\r\n    newAdHocConnection->setTiedValue(tiedValue);\r\n\r\n    QDomElement portReferencesNode = adHocNode.firstChildElement(QStringLiteral(\"ipxact:portReferences\"));\r\n    QDomNodeList internalReferenceNodes = portReferencesNode.elementsByTagName(QStringLiteral(\"ipxact:internalPortReference\"));\r\n    QDomNodeList externalReferenceNodes = portReferencesNode.elementsByTagName(QStringLiteral(\"ipxact:externalPortReference\"));\r\n\r\n    parseInternalPortReferences(internalReferenceNodes, newAdHocConnection, newDesign->getRevision());\r\n\r\n    parseExternalPortReferences(externalReferenceNodes, newAdHocConnection, newDesign->getRevision());\r\n\r\n    parseAdHocConnectionExtensions(adHocNode, newAdHocConnection);\r\n\r\n    newDesign->getAdHocConnections()->append(newAdHocConnection);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignReader::parseInternalPortReferences()\r\n//-----------------------------------------------------------------------------\r\nvoid DesignReader::Details::parseInternalPortReferences(const QDomNodeList& internalNodes,\r\n    QSharedPointer<AdHocConnection> newAdHocConnection, Document::Revision docRevision)\r\n{\r\n    for (int i = 0; i < internalNodes.size(); ++i)\r\n    {\r\n        QDomNode internalNode = internalNodes.at(i);\r\n        QSharedPointer<PortReference> internalReference = createPortReference(internalNode, docRevision);\r\n\r\n        QDomNamedNodeMap attributeMap = internalNode.attributes();\r\n        internalReference->setComponentRef(parseComponentReference(internalNode, docRevision));\r\n\r\n        newAdHocConnection->getInternalPortReferences()->append(internalReference);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignReader::parseExternalPortReferences()\r\n//-----------------------------------------------------------------------------\r\nvoid DesignReader::Details::parseExternalPortReferences(const QDomNodeList& externalNodes,\r\n    QSharedPointer<AdHocConnection> newAdHocConnection,\r\n    Document::Revision docRevision)\r\n{\r\n    for (int i = 0;i < externalNodes.size(); ++i)\r\n    {\r\n        QDomNode externalNode = externalNodes.at(i);\r\n        QSharedPointer<PortReference> externalReference = createPortReference(externalNode, docRevision);\r\n\r\n        newAdHocConnection->getExternalPortReferences()->append(externalReference);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignReader::createPortReference()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<PortReference> DesignReader::Details::createPortReference(QDomNode const& portReferenceNode,\r\n    Document::Revision docRevision)\r\n{\r\n    QDomNamedNodeMap attributeMap = portReferenceNode.attributes();\r\n\r\n    QString portReference = attributeMap.namedItem(QStringLiteral(\"portRef\")).nodeValue();\r\n\r\n    QSharedPointer<PortReference> newPortReference (new PortReference(portReference));\r\n\r\n    if (docRevision == Document::Revision::Std14)\r\n    {\r\n        QString isPresent = portReferenceNode.firstChildElement(QStringLiteral(\"ipxact:isPresent\")).firstChild().nodeValue();\r\n        newPortReference->setIsPresent(isPresent);\r\n    }\r\n\r\n    if (docRevision == Document::Revision::Std22)\r\n    {\r\n        auto subReferencesNodes = portReferenceNode.toElement().elementsByTagName(QStringLiteral(\"ipxact:subPortReference\"));\r\n\r\n        const int nodeCount = subReferencesNodes.count();\r\n        for (int i = 0; i < nodeCount; ++i)\r\n        {\r\n            auto subPortNode = subReferencesNodes.at(i);\r\n            auto subPortReference = subPortNode.attributes().namedItem(QStringLiteral(\"subPortRef\")).nodeValue();\r\n\r\n            QSharedPointer<PortReference> subPortItem(new PortReference(subPortReference));\r\n            \r\n            auto partSelectNode = subPortNode.firstChildElement(QStringLiteral(\"ipxact:partSelect\"));\r\n            subPortItem->setPartSelect(CommonItemsReader::parsePartSelect(partSelectNode));\r\n\r\n            newPortReference->getSubPortReferences()->append(subPortItem);\r\n        }\r\n    }\r\n\r\n    QDomNode partSelectNode = portReferenceNode.firstChildElement(QStringLiteral(\"ipxact:partSelect\"));\r\n    if (!partSelectNode.isNull())\r\n    {\r\n        newPortReference->setPartSelect(CommonItemsReader::parsePartSelect(partSelectNode));\r\n    }\r\n\r\n    return newPortReference;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignReader::parseAdHocConnectionExtensions()\r\n//-----------------------------------------------------------------------------\r\nvoid DesignReader::Details::parseAdHocConnectionExtensions(const QDomNode& adHocNode,\r\n    QSharedPointer<AdHocConnection> newAdHocConnection)\r\n{\r\n    QDomNode extensionsNode = adHocNode.firstChildElement(QStringLiteral(\"ipxact:vendorExtensions\"));\r\n\r\n    QDomElement offPageElement = extensionsNode.firstChildElement(QStringLiteral(\"kactus2:offPage\"));\r\n    if (!offPageElement.isNull())\r\n    {\r\n        newAdHocConnection->setOffPage(true);\r\n    }\r\n\r\n    QDomElement routeElement = extensionsNode.firstChildElement(QStringLiteral(\"kactus2:route\"));\r\n    if (!routeElement.isNull())\r\n    {\r\n        QList<QPointF> route;\r\n\r\n        QDomNodeList positionNodes = routeElement.elementsByTagName(QStringLiteral(\"kactus2:position\"));\r\n        for (int i = 0; i < positionNodes.count(); ++i)\r\n        {\r\n            QDomNamedNodeMap positionAttributes = positionNodes.at(i).attributes();\r\n            int positionX = positionAttributes.namedItem(QStringLiteral(\"x\")).nodeValue().toInt();\r\n            int positionY = positionAttributes.namedItem(QStringLiteral(\"y\")).nodeValue().toInt();\r\n\r\n            route.append(QPointF(positionX, positionY));\r\n        }\r\n\r\n        newAdHocConnection->setRoute(route);\r\n    }\r\n\r\n    CommonItemsReader::parseVendorExtensions(adHocNode, newAdHocConnection);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignReader::parseDesignExtensions()\r\n//-----------------------------------------------------------------------------\r\nvoid DesignReader::Details::parseDesignExtensions(QDomNode const& documentNode, QSharedPointer<Design> design)\r\n{\r\n    DocumentReader::parseKactusAndVendorExtensions(documentNode, design);\r\n\r\n    QDomElement extensionNode = documentNode.firstChildElement(QStringLiteral(\"ipxact:vendorExtensions\"));\r\n   \r\n    parseColumnLayout(extensionNode.firstChildElement(QStringLiteral(\"kactus2:columnLayout\")), design);\r\n\r\n    parseRoutes(extensionNode.firstChildElement(QStringLiteral(\"kactus2:routes\")), design);\r\n\r\n    parseSwInstances(extensionNode.firstChildElement(QStringLiteral(\"kactus2:swInstances\")), design);\r\n\r\n    parseAdHocPortPositions(extensionNode.firstChildElement(QStringLiteral(\"kactus2:adHocVisibilities\")), design);\r\n\r\n    parseApiConnections(extensionNode.firstChildElement(QStringLiteral(\"kactus2:apiConnections\")), design);\r\n\r\n    parseComConnections(extensionNode.firstChildElement(QStringLiteral(\"kactus2:comConnections\")), design);\r\n\r\n    parseInterfaceGraphics(extensionNode, design);\r\n\r\n    parseNotes(extensionNode, design);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignReader::parseColumnLayout()\r\n//-----------------------------------------------------------------------------\r\nvoid DesignReader::Details::parseColumnLayout(QDomNode const& columnLayoutNode, QSharedPointer<Design> design)\r\n{\r\n    QDomNodeList columnNodeList = columnLayoutNode.childNodes();\r\n    int columnCount = columnNodeList.count();\r\n    for (int columnIndex = 0; columnIndex < columnCount; ++columnIndex)\r\n    {\r\n        QDomNode columnNode = columnNodeList.at(columnIndex);\r\n        if (columnNode.nodeName() == QLatin1String(\"kactus2:column\"))\r\n        {\r\n            QDomNamedNodeMap attributes =  columnNode.attributes();\r\n\r\n            auto contentType = static_cast<ColumnTypes::ColumnContentType>(\r\n                attributes.namedItem(QStringLiteral(\"contentType\")).nodeValue().toInt());\r\n\r\n            QSharedPointer<ColumnDesc> newColumn (new ColumnDesc());\r\n            newColumn->setName(attributes.namedItem(QStringLiteral(\"name\")).nodeValue());\r\n            newColumn->setContentType(contentType);\r\n            newColumn->setAllowedItems(attributes.namedItem(QStringLiteral(\"allowedItems\")).nodeValue().toUInt());\r\n           \r\n            if (attributes.contains(QStringLiteral(\"minWidth\")))\r\n            {\r\n                newColumn->setMinimumWidth(attributes.namedItem(QStringLiteral(\"minWidth\")).nodeValue().toUInt());\r\n            }\r\n            else if (contentType == ColumnTypes::IO)\r\n            {\r\n                newColumn->setMinimumWidth(119);\r\n            }\r\n\r\n            if (attributes.contains(QStringLiteral(\"width\")))\r\n            {\r\n                newColumn->setWidth(attributes.namedItem(QStringLiteral(\"width\")).nodeValue().toUInt());\r\n            }\r\n            else if (contentType == ColumnTypes::IO)\r\n            {\r\n                newColumn->setWidth(119);\r\n            }\r\n\r\n            newColumn->setPosition(attributes.namedItem(QStringLiteral(\"x\")).nodeValue().toUInt());\r\n\r\n            design->addColumn(newColumn);\r\n\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignReader::parseRoutes()\r\n//-----------------------------------------------------------------------------\r\nvoid DesignReader::Details::parseRoutes(QDomElement const& routesElement, QSharedPointer<Design> design)\r\n{\r\n    QDomNodeList routeList = routesElement.childNodes();\r\n\r\n    QSharedPointer<Kactus2Group> routesGroup(new Kactus2Group(QStringLiteral(\"kactus2:routes\")));\r\n\r\n    int routeCount = routeList.count();\r\n    for (int i = 0; i < routeCount; ++i)\r\n    {\r\n        QDomElement routeNode = routeList.at(i).toElement();\r\n\r\n        QString connectionName = routeNode.attribute(QStringLiteral(\"kactus2:connRef\"));\r\n        QSharedPointer<ConnectionRoute> route(new ConnectionRoute(connectionName));\r\n\r\n        bool offpage = routeNode.attribute(QStringLiteral(\"kactus2:offPage\")) == QLatin1String(\"true\");\r\n        route->setOffpage(offpage);\r\n\r\n        QDomNodeList routePoints = routeNode.elementsByTagName(QStringLiteral(\"kactus2:position\"));\r\n        int pointCount = routePoints.count();\r\n        for (int j = 0; j < pointCount; j++)\r\n        {\r\n            QDomElement pointNode = routePoints.at(j).toElement();\r\n            QString x = pointNode.attribute(QStringLiteral(\"x\"));\r\n            QString y = pointNode.attribute(QStringLiteral(\"y\"));\r\n\r\n            QPointF point(x.toInt(), y.toInt());\r\n            route->addPoint(point);\r\n        }\r\n\r\n        routesGroup->addToGroup(route);        \r\n    }\r\n\r\n    if (routeCount > 0)\r\n    {\r\n        design->getVendorExtensions()->append(routesGroup);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignReader::parseSwInstances()\r\n//-----------------------------------------------------------------------------\r\nvoid DesignReader::Details::parseSwInstances(QDomNode const& swInstancesNode, QSharedPointer<Design> design)\r\n{\r\n    QDomNodeList swNodeList = swInstancesNode.childNodes();\r\n    \r\n    int swInstanceCount = swNodeList.count();\r\n    for (int swIndex = 0; swIndex < swInstanceCount; ++swIndex)\r\n    {\r\n        QDomNode swNode = swNodeList.at(swIndex);\r\n        if (swNode.nodeName() == QLatin1String(\"kactus2:swInstance\"))\r\n        {\r\n            QSharedPointer<ComponentInstance> newSWInstance = parseSwInstance(swNode);\r\n            design->getComponentInstances()->append(newSWInstance);\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignReader::parseSwInstance()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<ComponentInstance> DesignReader::Details::parseSwInstance(QDomNode const& node)\r\n{\r\n    auto newSWInstance = QSharedPointer<ComponentInstance>(new ComponentInstance);\r\n\r\n    for (int i = 0; i < node.childNodes().count(); ++i)\r\n    {\r\n        QDomNode childNode = node.childNodes().at(i);\r\n\r\n        if (childNode.isComment())\r\n        {\r\n            continue;\r\n        }\r\n\r\n        if (childNode.nodeName() == QLatin1String(\"kactus2:instanceName\"))\r\n        {\r\n            newSWInstance->setInstanceName(childNode.firstChild().nodeValue());\r\n        }\r\n        else if (childNode.nodeName() == QLatin1String(\"kactus2:displayName\"))\r\n        {\r\n            newSWInstance->setDisplayName(childNode.firstChild().nodeValue());\r\n        }\r\n        else if (childNode.nodeName() == QLatin1String(\"kactus2:description\"))\r\n        {\r\n            newSWInstance->setDescription(childNode.firstChild().nodeValue());\r\n        }\r\n        else if (childNode.nodeName() == QLatin1String(\"kactus2:componentRef\"))\r\n        {\r\n            QDomNamedNodeMap attributeMap = childNode.attributes();\r\n\r\n            QString vendor = attributeMap.namedItem(QStringLiteral(\"vendor\")).nodeValue();\r\n            QString library = attributeMap.namedItem(QStringLiteral(\"library\")).nodeValue();\r\n            QString name = attributeMap.namedItem(QStringLiteral(\"name\")).nodeValue();\r\n            QString version = attributeMap.namedItem(QStringLiteral(\"version\")).nodeValue();\r\n\r\n            QSharedPointer<ConfigurableVLNVReference> vlnvReference(\r\n                new ConfigurableVLNVReference(VLNV::COMPONENT, vendor, library, name, version));\r\n\r\n            newSWInstance->setComponentRef(vlnvReference);\r\n        }\r\n        else if (childNode.nodeName() == QLatin1String(\"kactus2:fileSetRef\"))\r\n        {\r\n            newSWInstance->setFileSetRef(childNode.firstChild().nodeValue());\r\n        }\r\n        else if (childNode.nodeName() == QLatin1String(\"kactus2:mapping\"))\r\n        {\r\n            newSWInstance->setMapping(childNode.attributes().namedItem(QStringLiteral(\"hwRef\")).nodeValue());\r\n        }\r\n        else if (childNode.nodeName() == QLatin1String(\"kactus2:position\"))\r\n        {\r\n            int positionX = childNode.attributes().namedItem(QStringLiteral(\"x\")).nodeValue().toInt();\r\n            int positionY = childNode.attributes().namedItem(QStringLiteral(\"y\")).nodeValue().toInt();\r\n            newSWInstance->setPosition(QPointF(positionX, positionY));\r\n        }\r\n        else if (childNode.nodeName() == QLatin1String(\"kactus2:imported\"))\r\n        {\r\n            newSWInstance->setImportRef(childNode.attributes().namedItem(QStringLiteral(\"importRef\")).nodeValue());\r\n        }\r\n        else if (childNode.nodeName() == QLatin1String(\"kactus2:propertyValues\"))\r\n        {\r\n            QMap<QString, QString> newPropertyValues;\r\n\r\n            for (int j = 0; j < childNode.childNodes().count(); ++j)\r\n            {\r\n                QDomNode propNode = childNode.childNodes().at(j);\r\n\r\n                if (propNode.nodeName() == QLatin1String(\"kactus2:propertyValue\"))\r\n                {\r\n                    QString name = propNode.attributes().namedItem(QStringLiteral(\"name\")).nodeValue();\r\n                    QString value = propNode.attributes().namedItem(QStringLiteral(\"value\")).nodeValue();\r\n\r\n                    newPropertyValues.insert(name, value);\r\n                }\r\n            }\r\n\r\n            newSWInstance->setPropertyValues(newPropertyValues);\r\n        }\r\n        else if (childNode.nodeName() == QLatin1String(\"kactus2:draft\"))\r\n        {\r\n            newSWInstance->setDraft(true);\r\n        }\r\n    }\r\n\r\n    return newSWInstance;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignReader::parseAdHocPositions()\r\n//-----------------------------------------------------------------------------\r\nvoid DesignReader::Details::parseAdHocPortPositions(QDomNode const& adHocsNode, QSharedPointer<Design> design)\r\n{\r\n    QMap<QString, QPointF> adHocPortPositions;\r\n\r\n    QDomNodeList adHocPortPositionNodeList = adHocsNode.childNodes();\r\n    int adHocPortPositionCount = adHocPortPositionNodeList.count();\r\n    for (int portPositionIndex = 0; portPositionIndex < adHocPortPositionCount; ++portPositionIndex)\r\n    {\r\n        QDomNode adHocPortPositionNode = adHocPortPositionNodeList.at(portPositionIndex);\r\n        if (adHocPortPositionNode.nodeName() == QLatin1String(\"kactus2:adHocVisible\"))\r\n        {\r\n            QDomNamedNodeMap adHocAttributes = adHocPortPositionNode.attributes();\r\n            QString portName = adHocAttributes.namedItem(QStringLiteral(\"portName\")).nodeValue();\r\n            int positionX = adHocAttributes.namedItem(QStringLiteral(\"x\")).nodeValue().toInt();\r\n            int positionY = adHocAttributes.namedItem(QStringLiteral(\"y\")).nodeValue().toInt();\r\n\r\n            QPointF adHocPosition (positionX, positionY);\r\n            adHocPortPositions.insert(portName, adHocPosition);\r\n        }\r\n    }\r\n\r\n    design->setAdHocPortPositions(adHocPortPositions);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignReader::parseApiConnections()\r\n//-----------------------------------------------------------------------------\r\nvoid DesignReader::Details::parseApiConnections(QDomNode const& apiConnectionsNode, QSharedPointer<Design> design)\r\n{\r\n    QList<QSharedPointer<ApiInterconnection> > apiConnections;\r\n\r\n    QDomNodeList apiConnectionNodeList = apiConnectionsNode.childNodes();\r\n\r\n    int apiConnectionsCount = apiConnectionNodeList.count();\r\n    for (int apiConnectionIndex = 0; apiConnectionIndex < apiConnectionsCount; ++apiConnectionIndex)\r\n    {\r\n        QDomNode singleApiConnectionNode = apiConnectionNodeList.at(apiConnectionIndex);\r\n\r\n        QSharedPointer<ApiInterconnection> newApiConnection (new ApiInterconnection(singleApiConnectionNode));\r\n        apiConnections.append(newApiConnection);\r\n    }\r\n\r\n    design->setApiConnections(apiConnections);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignReader::parseComConnections()\r\n//-----------------------------------------------------------------------------\r\nvoid DesignReader::Details::parseComConnections(QDomNode const& comConnectionsNode, QSharedPointer<Design> design)\r\n{\r\n    QList<QSharedPointer<ComInterconnection> > comConnections;\r\n\r\n    QDomNodeList comConnectionNodeList = comConnectionsNode.childNodes();\r\n    int comConnectionsCount = comConnectionNodeList.count();\r\n    for (int connectionIndex = 0; connectionIndex < comConnectionsCount; ++connectionIndex)\r\n    {\r\n        QDomNode singleComConnectionNode = comConnectionNodeList.at(connectionIndex);\r\n\r\n        QSharedPointer<ComInterconnection> newConnection (new ComInterconnection(singleComConnectionNode));\r\n\r\n        comConnections.append(newConnection);\r\n    }\r\n\r\n    design->setComConnections(comConnections);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignReader::parseInterfaceGraphics()\r\n//-----------------------------------------------------------------------------\r\nvoid DesignReader::Details::parseInterfaceGraphics(QDomElement const& extensionsNode, QSharedPointer<Design> design)\r\n{\r\n    QDomNodeList graphicsExtensions = extensionsNode.elementsByTagName(QStringLiteral(\"kactus2:interfaceGraphics\"));\r\n\r\n    int extensionCount = graphicsExtensions.count();\r\n    for (int i = 0; i < extensionCount; i++)\r\n    {\r\n        QDomElement extension = graphicsExtensions.at(i).toElement();\r\n        \r\n        QString name = extension.firstChildElement(QStringLiteral(\"kactus2:name\")).firstChild().nodeValue();\r\n\r\n        QDomElement positionElement = extension.firstChildElement(QStringLiteral(\"kactus2:position\"));\r\n        int xCoordinate = positionElement.attribute(QStringLiteral(\"x\")).toInt();\r\n        int yCoordinate = positionElement.attribute(QStringLiteral(\"y\")).toInt();\r\n        QPointF graphicsPosition (xCoordinate, yCoordinate);\r\n\r\n        QDomElement directionElement = extension.firstChildElement(QStringLiteral(\"kactus2:direction\"));\r\n        int xDirection = directionElement.attribute(QStringLiteral(\"x\")).toInt();\r\n        int yDirection = directionElement.attribute(QStringLiteral(\"y\")).toInt();\r\n        QVector2D graphicsVector (xDirection, yDirection);\r\n\r\n        QSharedPointer<InterfaceGraphicsData> graphicsData(new InterfaceGraphicsData(name, graphicsPosition, \r\n            graphicsVector));\r\n\r\n        design->getVendorExtensions()->append(graphicsData);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignReader::parseNotes()\r\n//-----------------------------------------------------------------------------\r\nvoid DesignReader::Details::parseNotes(QDomElement const& extensionNode, QSharedPointer<Design> design)\r\n{\r\n    QDomNodeList notesExtensions = extensionNode.elementsByTagName(QStringLiteral(\"kactus2:note\"));\r\n\r\n    int notesCount = notesExtensions.count();\r\n    for (int noteIndex = 0; noteIndex < notesCount; ++noteIndex)\r\n    {\r\n        QSharedPointer<Kactus2Group> note(new Kactus2Group(QStringLiteral(\"kactus2:note\")));\r\n        \r\n        const int childCount = notesExtensions.at(noteIndex).childNodes().count();\r\n        for (int childIndex = 0; childIndex < childCount; ++childIndex)\r\n        {\r\n            QDomNode childNode = notesExtensions.at(noteIndex).childNodes().at(childIndex);\r\n\r\n            if (childNode.nodeName().compare(QLatin1String(\"kactus2:position\")) == 0)\r\n            {                \r\n                QPointF point = CommonItemsReader::parsePoint(childNode);\r\n                QSharedPointer<Kactus2Position> positionExtension(new Kactus2Position(point));\r\n                note->addToGroup(positionExtension);\r\n            }\r\n            else if (childNode.nodeName().compare(QLatin1String(\"kactus2:associations\")) == 0)\r\n            {\r\n                QSharedPointer<Kactus2Group> associations(new Kactus2Group(QStringLiteral(\"kactus2:associations\")));\r\n\r\n                const int associationCount = childNode.childNodes().count();\r\n                for (int associationIndex = 0; associationIndex < associationCount; ++associationIndex)\r\n                {\r\n                    QPointF position = CommonItemsReader::parsePoint(childNode.childNodes().at(associationIndex));\r\n                    QSharedPointer<Kactus2Position> positionExtension(new Kactus2Position(position));\r\n                    associations->addToGroup(positionExtension);\r\n                }\r\n\r\n                note->addToGroup(associations);\r\n            }\r\n            else\r\n            {\r\n                QSharedPointer<Kactus2Value> valueExtension(new Kactus2Value(childNode.nodeName(), \r\n                    childNode.firstChild().nodeValue()));\r\n                note->addToGroup(valueExtension);\r\n            }        \r\n        }\r\n\r\n        design->getVendorExtensions()->append(note);\r\n    }\r\n}\r\n"
  },
  {
    "path": "IPXACTmodels/Design/DesignReader.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: DesignReader.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 25.08.2015\r\n//\r\n// Description:\r\n// XML reader for IP-XACT design element.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef DESIGNREADER_H\r\n#define DESIGNREADER_H\r\n\r\n#include \"Design.h\"\r\n#include \"ActiveInterface.h\"\r\n#include \"HierInterface.h\"\r\n#include \"MonitorInterface.h\"\r\n#include \"PortReference.h\"\r\n\r\n#include <IPXACTmodels/common/DocumentReader.h>\r\n\r\n#include <QDomNode>\r\n#include <QDomNodeList>\r\n\r\n//-----------------------------------------------------------------------------\r\n//! XML reader for IP-XACT design element.\r\n//-----------------------------------------------------------------------------\r\nnamespace DesignReader\r\n{\r\n\r\n    /*!\r\n     *  Creates a design from XML definition.\r\n     *\r\n     *    @param [in] document    The XML document to create the design from.\r\n     *\r\n     *    @return The created design.\r\n     */\r\n    IPXACTMODELS_EXPORT QSharedPointer<Design> createDesignFrom(QDomDocument const& document);\r\n\r\n    namespace Details\r\n    {\r\n        /*!\r\n         *  Reads the component instances from XML to design.\r\n         *\r\n         *    @param [in] designNode  The XML description of the design.\r\n         *    @param [in] newDesign   The new design item.\r\n         */\r\n        void parseComponentInstances(QDomNode const& designNode, QSharedPointer<Design> newDesign);\r\n\r\n        /*!\r\n         *  Reads the interconnections from XML to design.\r\n         *\r\n         *    @param [in] designNode  The XML description of the design.\r\n         *    @param [in] newDesign   The new design item.\r\n         */\r\n        void parseInterconnections(QDomNode const& designNode, QSharedPointer<Design> newDesign);\r\n\r\n        /*!\r\n         *  Reads a single interconnection from XML.\r\n         *\r\n         *    @param [in] interconnectionNode     The XML description of the interconnection.\r\n         *    @param [in] newDesign               The new design item.\r\n         */\r\n        void parseSingleInterconnection(QDomNode const& interconnectionNode, QSharedPointer<Design> newDesign);\r\n\r\n        /*!\r\n         *  Reads an interconnection between components.\r\n         *\r\n         *    @param [in] interconnectionNode     The XML description of the interconnection.\r\n         *    @param [in] newDesign               The new design item.\r\n         */\r\n        void parseComponentInterconnection(QDomNode const& interconnectionNode, QSharedPointer<Design> newDesign);\r\n\r\n        /*!\r\n         *  Reads interconnection extensions.\r\n         *\r\n         *    @param [in] interconnectionNode     XML description of the interconnection.\r\n         *    @param [in] interconnection         The new interconnection item.\r\n         */\r\n        void parseInterconnectionExtensions(const QDomNode& interconnectionNode,\r\n            QSharedPointer<Interconnection> interconnection);\r\n\r\n        /*!\r\n         *  Reads an active interface.\r\n         *\r\n         *    @param [in] interfaceNode   The XML description of the active interface.\r\n         *    @param [in] newInterface    The new interface item.\r\n         *    @param [in] docRevision     The applied IP-XACT standard revision.\r\n         */\r\n        void parseActiveInterface(QDomNode const& interfaceNode, QSharedPointer<ActiveInterface> newInterface,\r\n            Document::Revision docRevision);\r\n\r\n        /*!\r\n         * Reads a component reference for active interface, monitor interface and ad-hoc connection.\r\n         *\r\n         *    @param [in] interfaceNode  <Description>\r\n         *    @param [in] docRevision  <Description>\r\n         *\r\n         *    @return The read component reference.\r\n         */\r\n         QString parseComponentReference(QDomNode const& interfaceNode, Document::Revision docRevision);\r\n\r\n        /*!\r\n         *  Reads a hierarchical interface.\r\n         *\r\n         *    @param [in] interfaceNode   The XML description of the hierarchical interface.\r\n         *    @param [in] newInterface    The new interface item.\r\n         */\r\n        void parseHierInterface(QDomNode const& interfaceNode, QSharedPointer<HierInterface> newInterface);\r\n\r\n        /*!\r\n         *  Reads interface extensions.\r\n         *\r\n         *    @param [in] interfaceNode   XML description of the hierarchical interface.\r\n         *    @param [in] newInterface    The new interface item.\r\n         */\r\n        void parseHierInterfaceExtensions(const QDomNode& interfaceNode, \r\n            QSharedPointer<HierInterface> newInterface);\r\n\r\n        /*!\r\n         *  Reads a monitor interconnection.\r\n         *\r\n         *    @param [in] monitorNode     The XML description of the monitor interconnection.\r\n         *    @param [in] newDesign       The new design item.\r\n         */\r\n        void parseMonitorInterconnection(QDomNode const& monitorNode, QSharedPointer<Design> newDesign);\r\n\r\n        /*!\r\n         *  Reads a monitor interface.\r\n         *\r\n         *    @param [in] interfaceNode   The XML description of the monitor interface.\r\n         *    @param [in] newInterface    The new interface item.\r\n         *    @param [in] docRevision     The applied IP-XACT standard revision.\r\n         */\r\n        void parseMonitorInterface(QDomNode const& interfaceNode, QSharedPointer<MonitorInterface> newInterface,\r\n            Document::Revision docRevision);\r\n\r\n        /*!\r\n         *  Reads the ad-hoc connections.\r\n         *\r\n         *    @param [in] designNode  The XML description of the design.\r\n         *    @param [in] newDesign   The new design item.\r\n         */\r\n        void parseAdHocConnections(QDomNode const& designNode, QSharedPointer<Design> newDesign);\r\n\r\n        /*!\r\n         *  Reads a single ad-hoc connection.\r\n         *\r\n         *    @param [in] adHocNode   XML description of an ad-hoc connection.\r\n         *    @param [in] newDesign   The new design item.\r\n         */\r\n        void parseSingleAdHocConnection(const QDomNode& adHocNode, QSharedPointer<Design> newDesign);\r\n\r\n        /*!\r\n         *  Reads the internal port references.\r\n         *\r\n         *    @param [in] internalNodes       XML description of the internal port references.\r\n         *    @param [in] newAdHocConnection  The new ad-hoc connection item.\r\n         *    @param [in] docRevision         The applied IP-XACT standard revision.\r\n         */\r\n        void parseInternalPortReferences(const QDomNodeList& internalNodes,\r\n            QSharedPointer<AdHocConnection> newAdHocConnection, Document::Revision docRevision);\r\n\r\n        /*!\r\n         *  Reads the external port references.\r\n         *\r\n         *    @param [in] externalNodes       XML description of the external port references.\r\n         *    @param [in] newAdHocConnection  The new ad-hoc connection item.\r\n         *    @param [in] docRevision         The applied IP-XACT standard revision.\r\n         */\r\n        void parseExternalPortReferences(const QDomNodeList& externalNodes,\r\n            QSharedPointer<AdHocConnection> newAdHocConnection,\r\n            Document::Revision docRevision);\r\n\r\n        /*!\r\n         *  Creates a port reference.\r\n         *\r\n         *    @param [in] portReferenceNode   The XML description of the port.\r\n         *    @param [in] docRevision         The applied IP-XACT standard revision.\r\n         */\r\n        QSharedPointer<PortReference> createPortReference(QDomNode const& portReferenceNode,\r\n            Document::Revision docRevision);\r\n\r\n        /*!\r\n         *  Reads ad-hoc connection extensions.\r\n         *\r\n         *    @param [in] adHocNode           XML description of the ad-hoc connection.\r\n         *    @param [in] newAdHocConnection  The new ad-hoc connection item.\r\n         */\r\n        void parseAdHocConnectionExtensions(const QDomNode& adHocNode,\r\n            QSharedPointer<AdHocConnection> newAdHocConnection);\r\n\r\n        /*!\r\n         *  Reads the design vendor extensions.\r\n         *\r\n         *    @param [in] documentNode    The XML description of the document.\r\n         *    @param [in] design          The new design item.\r\n         */\r\n        void parseDesignExtensions(QDomNode const& documentNode, QSharedPointer<Design> design);\r\n\r\n        /*!\r\n         *  Reads the design column layout (Kactus2 extension).\r\n         *\r\n         *    @param [in] columnLayoutNode    The XML description of the column layout.\r\n         *    @param [in] design              The new design item.\r\n         */\r\n        void parseColumnLayout(QDomNode const& columnLayoutNode, QSharedPointer<Design> design);\r\n\r\n        /*!\r\n         * Reads the route for a connection (Kactus2 extension).\r\n         *\r\n         *    @param [in] routesElement    The XML description of the route.\r\n         *    @param [in] design           The new design item.\r\n         *\r\n         *    @return \r\n         */\r\n         void parseRoutes(QDomElement const& routesElement, QSharedPointer<Design> design);\r\n\r\n        /*!\r\n         *  Reads the software instances (Kactus2 extension).\r\n         *\r\n         *    @param [in] swInstancesNode     The XML description of the software instances.\r\n         *    @param [in] design              The new design item.\r\n         */\r\n        void parseSwInstances(QDomNode const& swInstancesNode, QSharedPointer<Design> design);\r\n\r\n        /*!\r\n         *  Reads the a single software instance (Kactus2 extension).\r\n         *\r\n         *    @param [in] QDomNode const& node     The XML description of the software instance.\r\n         *\r\n         *    @return The parsed software instance.\r\n         */\r\n        QSharedPointer<ComponentInstance> parseSwInstance(QDomNode const& node);\r\n\r\n        /*!\r\n         *  Reads the ad-hoc port (Kactus2:extension).\r\n         *\r\n         *    @param [in] adHocsNode  The XML description of the ad-hoc ports.\r\n         *    @param [in] design      The new design item.\r\n         */\r\n        void parseAdHocPortPositions(QDomNode const& adHocsNode, QSharedPointer<Design> design);\r\n\r\n        /*!\r\n         *  Reads the api connections (Kactus2 extension).\r\n         *\r\n         *    @param [in] apiConnectionsNode  The XML description of the api connections.\r\n         *    @param [in] design              The new design item.\r\n         */\r\n        void parseApiConnections(QDomNode const& apiConnectionsNode, QSharedPointer<Design>design);\r\n\r\n        /*!\r\n         *  Reads the com connections (Kactus2 extension).\r\n         *\r\n         *    @param [in] comConnectionsNode  The XML description of the com connections.\r\n         *    @param [in] design              The new design item.\r\n         */\r\n        void parseComConnections(QDomNode const& comConnectionsNode, QSharedPointer<Design> design);\r\n\r\n        /*!\r\n         *  Reads the interface graphics extensions for the design.\r\n         *\r\n         *    @param [in] extensionsNode      The XML description of the design vendor extensions.\r\n         *    @param [in] design              The new design item.\r\n         */\r\n        void parseInterfaceGraphics(QDomElement const& extensionsNode, QSharedPointer<Design> design);\r\n\r\n        /*!\r\n         *  Reads the sticky notes for the design.\r\n         *\r\n         *    @param [in] extensionNode   The XML description of the design vendor extensions.\r\n         *    @param [in] design          The new design item.\r\n         */\r\n        void parseNotes(QDomElement const& extensionNode, QSharedPointer<Design> design);\r\n    }\r\n};\r\n\r\n#endif // DESIGNREADER_H\r\n"
  },
  {
    "path": "IPXACTmodels/Design/DesignWriter.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: DesignWriter.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 17.08.2015\r\n//\r\n// Description:\r\n// Writer class for IP-XACT Design element.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"DesignWriter.h\"\r\n\r\n#include <IPXACTmodels/common/NameGroupWriter.h>\r\n#include <IPXACTmodels/Design/ComponentInstanceWriter.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignWriter::writeDesign()\r\n//-----------------------------------------------------------------------------\r\nvoid DesignWriter::writeDesign(QXmlStreamWriter& writer, QSharedPointer<Design> design)\r\n{\r\n    writer.writeStartDocument();\r\n\r\n    Details::writeDesignStart(writer, design);\r\n\r\n    DocumentWriter::writeNamespaceDeclarations(writer, design);\r\n\r\n    DocumentWriter::writeDocumentNameGroup(writer, design);\r\n\r\n    Details::writeComponentInstances(writer, design);\r\n\r\n    Details::writeInterconnections(writer, design);\r\n\r\n    Details::writeAdHocConnections(writer, design);\r\n    \r\n    if (design->getRevision() == Document::Revision::Std14)\r\n    {\r\n        CommonItemsWriter::writeDescription(writer, design->getDescription());\r\n    }\r\n\r\n    DocumentWriter::writeParameters(writer, design);\r\n\r\n    DocumentWriter::writeAssertions(writer, design);\r\n\r\n    CommonItemsWriter::writeVendorExtensions(writer, design);\r\n\r\n    writer.writeEndElement(); // ipxact:design\r\n    writer.writeEndDocument();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignWriter::writeDesignStart()\r\n//-----------------------------------------------------------------------------\r\nvoid DesignWriter::Details::writeDesignStart(QXmlStreamWriter& writer, QSharedPointer<Design> design)\r\n{\r\n    DocumentWriter::writeTopComments(writer, design);\r\n    DocumentWriter::writeXmlProcessingInstructions(writer, design);\r\n    writer.writeStartElement(QStringLiteral(\"ipxact:design\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignWriter::writeComponentInstances()\r\n//-----------------------------------------------------------------------------\r\nvoid DesignWriter::Details::writeComponentInstances(QXmlStreamWriter& writer, QSharedPointer<Design> design)\r\n{\r\n    if (design->getComponentInstances()->isEmpty())\r\n    {\r\n        return;\r\n    }\r\n\r\n    writer.writeStartElement(QStringLiteral(\"ipxact:componentInstances\"));\r\n\r\n    for (auto const& instance : *design->getComponentInstances())\r\n    {\r\n        ComponentInstanceWriter::writeComponentInstance(writer, instance, design->getRevision());\r\n    }\r\n\r\n    writer.writeEndElement(); // ipxact:componentInstances\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignWriter::writeInterconnections()\r\n//-----------------------------------------------------------------------------\r\nvoid DesignWriter::Details::writeInterconnections(QXmlStreamWriter& writer, QSharedPointer<Design> design)\r\n{\r\n    if (design->getInterconnections()->isEmpty() && design->getMonitorInterconnecions()->isEmpty())\r\n    {\r\n        return;\r\n    }\r\n\r\n    writer.writeStartElement(QStringLiteral(\"ipxact:interconnections\"));\r\n\r\n    for (auto const& currentInterconnection : *design->getInterconnections())\r\n    {\r\n        writeSingleInterconncetion(writer, currentInterconnection, design->getRevision());\r\n    }\r\n\r\n    for (auto const& connection : *design->getMonitorInterconnecions())\r\n    {\r\n        writeMonitorInterconnection(writer, connection, design->getRevision());\r\n    }\r\n\r\n    writer.writeEndElement(); // ipxact:interconnections\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignWriter::writeSingleInterconncetion()\r\n//-----------------------------------------------------------------------------\r\nvoid DesignWriter::Details::writeSingleInterconncetion(QXmlStreamWriter& writer,\r\n    QSharedPointer<Interconnection> currentInterconnection, Document::Revision docRevision)\r\n{\r\n    writer.writeStartElement(QStringLiteral(\"ipxact:interconnection\"));\r\n\r\n    NameGroupWriter::writeNameGroup(writer, currentInterconnection, docRevision);\r\n\r\n    if (docRevision == Document::Revision::Std14)\r\n    {\r\n        CommonItemsWriter::writeIsPresent(writer, currentInterconnection->getIsPresent());\r\n    }\r\n\r\n    writeActiveInterface(writer, currentInterconnection->getStartInterface(), docRevision);\r\n\r\n    for (auto const& currentInterface: *currentInterconnection->getActiveInterfaces())\r\n    {\r\n        writeActiveInterface(writer, currentInterface, docRevision);\r\n    }\r\n\r\n    for (auto const& currentInterface : *currentInterconnection->getHierInterfaces())\r\n    {\r\n        writeHierInterface(writer, currentInterface);\r\n    }\r\n\r\n    CommonItemsWriter::writeVendorExtensions(writer, currentInterconnection);\r\n\r\n    writer.writeEndElement(); // ipxact:interconnection\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignWriter::writeActiveInterface()\r\n//-----------------------------------------------------------------------------\r\nvoid DesignWriter::Details::writeActiveInterface(QXmlStreamWriter& writer,\r\n    QSharedPointer<ActiveInterface> activeInterface, Document::Revision docRevision)\r\n{\r\n    writer.writeStartElement(QStringLiteral(\"ipxact:activeInterface\"));\r\n\r\n    writer.writeAttribute(componentReferenceAttribute(docRevision), activeInterface->getComponentReference());\r\n    writer.writeAttribute(QStringLiteral(\"busRef\"), activeInterface->getBusReference());\r\n    \r\n    if (docRevision == Document::Revision::Std14)\r\n    {\r\n        CommonItemsWriter::writeIsPresent(writer, activeInterface->getIsPresent());\r\n    }\r\n\r\n    CommonItemsWriter::writeDescription(writer, activeInterface->getDescription());\r\n\r\n    if (!activeInterface->getExcludePorts()->isEmpty())\r\n    {\r\n        writer.writeStartElement(QStringLiteral(\"ipxact:excludePorts\"));\r\n\r\n        for (auto const& portName : *activeInterface->getExcludePorts())\r\n        {\r\n            writer.writeTextElement(QStringLiteral(\"ipxact:excludePort\"), portName);\r\n        }\r\n\r\n        writer.writeEndElement(); // ipxact:excludePorts\r\n    }\r\n\r\n    CommonItemsWriter::writeVendorExtensions(writer, activeInterface);\r\n\r\n    writer.writeEndElement(); //ipxact:activeInterface\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignWriter::componentReferenceAttribute()\r\n//-----------------------------------------------------------------------------\r\nQString DesignWriter::Details::componentReferenceAttribute(Document::Revision docRevision)\r\n{\r\n    auto referenceAttribute = QString();\r\n    if (docRevision == Document::Revision::Std14)\r\n    {\r\n        referenceAttribute = QStringLiteral(\"componentRef\");\r\n    }\r\n    else if (docRevision == Document::Revision::Std22)\r\n    {\r\n        referenceAttribute = QStringLiteral(\"componentInstanceRef\");\r\n    }\r\n\r\n    return referenceAttribute;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignWriter::writeHierInterface()\r\n//-----------------------------------------------------------------------------\r\nvoid DesignWriter::Details::writeHierInterface(QXmlStreamWriter& writer, \r\n    QSharedPointer<HierInterface> hierInterface)\r\n{\r\n    writer.writeStartElement(QStringLiteral(\"ipxact:hierInterface\"));\r\n\r\n    writer.writeAttribute(QStringLiteral(\"busRef\"), hierInterface->getBusReference());\r\n\r\n    CommonItemsWriter::writeIsPresent(writer, hierInterface->getIsPresent());\r\n\r\n    CommonItemsWriter::writeDescription(writer, hierInterface->getDescription());\r\n\r\n    CommonItemsWriter::writeVendorExtensions(writer, hierInterface);\r\n\r\n    writer.writeEndElement(); //ipxact:hierInterface\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignWriter::writeMonitorInterconnection()\r\n//-----------------------------------------------------------------------------\r\nvoid DesignWriter::Details::writeMonitorInterconnection(QXmlStreamWriter& writer,\r\n    QSharedPointer<MonitorInterconnection> monitorConnection, Document::Revision docRevision)\r\n{\r\n    writer.writeStartElement(QStringLiteral(\"ipxact:monitorInterconnection\"));\r\n\r\n    NameGroupWriter::writeNameGroup(writer, monitorConnection, docRevision);\r\n\r\n    CommonItemsWriter::writeIsPresent(writer, monitorConnection->getIsPresent());\r\n\r\n    writer.writeStartElement(QStringLiteral(\"ipxact:monitoredActiveInterface\"));\r\n\r\n    writeMonitorInterface(writer, monitorConnection->getMonitoredActiveInterface(), docRevision);\r\n\r\n    writer.writeEndElement(); // ipxact:monitoredActiveInterface\r\n\r\n    for (auto const& monitorInterface : *monitorConnection->getMonitorInterfaces())\r\n    {\r\n        writer.writeStartElement(QStringLiteral(\"ipxact:monitorInterface\"));\r\n\r\n        writeMonitorInterface(writer, monitorInterface, docRevision);\r\n\r\n        if (docRevision == Document::Revision::Std14)\r\n        {\r\n            CommonItemsWriter::writeIsPresent(writer, monitorInterface->getIsPresent());\r\n        }\r\n\r\n        writer.writeEndElement(); // ipxact:monitorInterface\r\n    }\r\n\r\n    writer.writeEndElement(); // ipxact:monitorInterconnection\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignWriter::writeMonitorInterface()\r\n//-----------------------------------------------------------------------------\r\nvoid DesignWriter::Details::writeMonitorInterface(QXmlStreamWriter& writer,\r\n    QSharedPointer<MonitorInterface> monitorInterface, Document::Revision docRevision)\r\n{\r\n    writer.writeAttribute(componentReferenceAttribute(docRevision), monitorInterface->getComponentReference());\r\n\r\n    writer.writeAttribute(QStringLiteral(\"busRef\"), monitorInterface->getBusReference());\r\n\r\n    if (!monitorInterface->getPath().isEmpty())\r\n    {\r\n        writer.writeAttribute(QStringLiteral(\"path\"), monitorInterface->getPath());\r\n    }\r\n\r\n    CommonItemsWriter::writeDescription(writer, monitorInterface->getDescription());\r\n\r\n    CommonItemsWriter::writeVendorExtensions(writer, monitorInterface);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignWriter::writeAdHocConnections()\r\n//-----------------------------------------------------------------------------\r\nvoid DesignWriter::Details::writeAdHocConnections(QXmlStreamWriter& writer, QSharedPointer<Design> design)\r\n{\r\n    if (design->getAdHocConnections()->isEmpty())\r\n    {\r\n        return;\r\n    }\r\n\r\n    writer.writeStartElement(QStringLiteral(\"ipxact:adHocConnections\"));\r\n\r\n    for (auto const& connection : *design->getAdHocConnections())\r\n    {\r\n        writeSingleAdHocConnection(writer, connection, design->getRevision());\r\n    }\r\n\r\n    writer.writeEndElement(); // ipxact:adHocConnections\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignWriter::writeSingleAdHocConnection()\r\n//-----------------------------------------------------------------------------\r\nvoid DesignWriter::Details::writeSingleAdHocConnection(QXmlStreamWriter& writer,\r\n    QSharedPointer<AdHocConnection> adHocConnection, Document::Revision docRevision)\r\n{\r\n    writer.writeStartElement(QStringLiteral(\"ipxact:adHocConnection\"));\r\n\r\n    NameGroupWriter::writeNameGroup(writer, adHocConnection, docRevision);\r\n\r\n    CommonItemsWriter::writeIsPresent(writer, adHocConnection->getIsPresent());\r\n\r\n    CommonItemsWriter::writeNonEmptyElement(writer, QStringLiteral(\"ipxact:tiedValue\"), adHocConnection->getTiedValue());\r\n\r\n    writeAdHocPortReferences(writer, adHocConnection, docRevision);\r\n\r\n    CommonItemsWriter::writeVendorExtensions(writer, adHocConnection);\r\n\r\n    writer.writeEndElement(); // ipxact:adHocConnection\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignWriter::writeAdHocPortReferences()\r\n//-----------------------------------------------------------------------------\r\nvoid DesignWriter::Details::writeAdHocPortReferences(QXmlStreamWriter& writer,\r\n    QSharedPointer<AdHocConnection> adHocConnection, Document::Revision docRevision)\r\n{\r\n    if (adHocConnection->getInternalPortReferences()->isEmpty() &&\r\n        adHocConnection->getExternalPortReferences()->isEmpty())\r\n    {\r\n        return;\r\n    }\r\n\r\n    writer.writeStartElement(QStringLiteral(\"ipxact:portReferences\"));\r\n\r\n    for (auto const& internalRef : *adHocConnection->getInternalPortReferences())\r\n    {\r\n        writer.writeStartElement(QStringLiteral(\"ipxact:internalPortReference\"));\r\n\r\n        writer.writeAttribute(componentReferenceAttribute(docRevision), internalRef->getComponentRef());\r\n\r\n        writePortReference(writer, internalRef, docRevision);\r\n\r\n        writer.writeEndElement(); // ipxact:internalPortReference\r\n    }\r\n\r\n    for (auto const& externalRef : *adHocConnection->getExternalPortReferences())\r\n    {\r\n        writer.writeStartElement(QStringLiteral(\"ipxact:externalPortReference\"));\r\n\r\n        writePortReference(writer, externalRef, docRevision);\r\n\r\n        writer.writeEndElement(); // ipxact:externalPortReference\r\n    }\r\n\r\n    writer.writeEndElement(); // ipxact:portReferences\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignWriter::writePortReference()\r\n//-----------------------------------------------------------------------------\r\nvoid DesignWriter::Details::writePortReference(QXmlStreamWriter& writer, QSharedPointer<PortReference> portReference,\r\n    Document::Revision docRevision)\r\n{\r\n    writer.writeAttribute(QStringLiteral(\"portRef\"), portReference->getPortRef());\r\n\r\n    if (docRevision == Document::Revision::Std14)\r\n    {\r\n        CommonItemsWriter::writeIsPresent(writer, portReference->getIsPresent());\r\n    }\r\n\r\n    if (docRevision == Document::Revision::Std22)\r\n    {\r\n        for (auto const& subPortReference : *portReference->getSubPortReferences())\r\n        {\r\n            writer.writeStartElement(QStringLiteral(\"ipxact:subPortReference\"));\r\n            writer.writeAttribute(QStringLiteral(\"subPortRef\"), subPortReference->getPortRef());\r\n\r\n            CommonItemsWriter::writePartSelect(writer, subPortReference->getPartSelect());\r\n\r\n            writer.writeEndElement(); //ipxact:subPortReference\r\n        }\r\n    }\r\n\r\n    CommonItemsWriter::writePartSelect(writer, portReference->getPartSelect());\r\n}\r\n"
  },
  {
    "path": "IPXACTmodels/Design/DesignWriter.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: DesignWriter.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 17.08.2015\r\n//\r\n// Description:\r\n// Writer for IP-XACT Design element.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef DESIGNWRITER_H\r\n#define DESIGNWRITER_H\r\n\r\n#include \"Design.h\"\r\n\r\n#include <IPXACTmodels/common/DocumentWriter.h>\r\n\r\n#include <QXmlStreamWriter>\r\n#include <QSharedPointer>\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Writer for IP-XACT Design element.\r\n//-----------------------------------------------------------------------------\r\nnamespace DesignWriter \r\n{\r\n    /*!\r\n     *  Write the design.\r\n     *\r\n     *    @param [in] writer  The used XML writer.\r\n     *    @param [in] design  The selected design.\r\n     */\r\n    IPXACTMODELS_EXPORT void writeDesign(QXmlStreamWriter& writer, QSharedPointer<Design> design);\r\n\r\n    namespace Details\r\n    {\r\n        /*!\r\n         *  Write the start of the XML file.\r\n         *\r\n         *    @param [in] writer  The used XML writer.\r\n         *    @param [in] design  The selected design.\r\n         */\r\n        void writeDesignStart(QXmlStreamWriter& writer, QSharedPointer<Design> design);\r\n\r\n        /*!\r\n         *  Write the component instances of the design.\r\n         *\r\n         *    @param [in] writer  The used XML writer.\r\n         *    @param [in] design  The selected design.\r\n         */\r\n        void writeComponentInstances(QXmlStreamWriter& writer, QSharedPointer<Design> design);\r\n\r\n        /*!\r\n         *  Write the design interconnections.\r\n         *\r\n         *    @param [in] writer  The used XML writer.\r\n         *    @param [in] design  The selected design.\r\n         */\r\n        void writeInterconnections(QXmlStreamWriter& writer, QSharedPointer<Design> design);\r\n\r\n        /*!\r\n         *  Write a single interconnection.\r\n         *\r\n         *    @param [in] writer                  The used XML writer.\r\n         *    @param [in] currentInterconnection  The selected interconnection.\r\n         *    @param [in] docRevision             The applied IP-XACT standard revision.\r\n         */\r\n        void writeSingleInterconncetion(QXmlStreamWriter& writer,\r\n            QSharedPointer<Interconnection> currentInterconnection, Document::Revision docRevision);\r\n\r\n        /*!\r\n         *  Write an active interface.\r\n         *\r\n         *    @param [in] writer              The used XML writer.\r\n         *    @param [in] activeInterface     The selected active interface.\r\n         *    @param [in] docRevision             The applied IP-XACT standard revision.\r\n         */\r\n        void writeActiveInterface(QXmlStreamWriter& writer, QSharedPointer<ActiveInterface> activeInterface,\r\n            Document::Revision docRevision);\r\n\r\n        QString componentReferenceAttribute(Document::Revision docRevision);\r\n\r\n        /*!\r\n         *  Write a hier interface.\r\n         *\r\n         *    @param [in] writer          The used XML writer.\r\n         *    @param [in] hierInterface   The selected hier interface.\r\n         */\r\n        void writeHierInterface(QXmlStreamWriter& writer, QSharedPointer<HierInterface> hierInterface);\r\n\r\n        /*!\r\n         *  Write a monitor interconnection.\r\n         *\r\n         *    @param [in] writer              The used XML writer.\r\n         *    @param [in] monitorConnection   The selected monitor interconnection.\r\n         *    @param [in] docRevision             The applied IP-XACT standard revision.\r\n         */\r\n        void writeMonitorInterconnection(QXmlStreamWriter& writer,\r\n            QSharedPointer<MonitorInterconnection> monitorConnection, Document::Revision docRevision);\r\n\r\n        /*!\r\n         *  Write a monitor interface.\r\n         *\r\n         *    @param [in] writer              The used XML writer.\r\n         *    @param [in] monitorInterface    The selected monitor interface.\r\n         *    @param [in] docRevision             The applied IP-XACT standard revision.\r\n         */\r\n        void writeMonitorInterface(QXmlStreamWriter& writer, QSharedPointer<MonitorInterface> monitorInterface,\r\n            Document::Revision docRevision);\r\n\r\n        /*!\r\n         *  Write ad-hoc connections.\r\n         *\r\n         *    @param [in] writer  The used XML writer.\r\n         *    @param [in] design  The selected design.\r\n         */\r\n        void writeAdHocConnections(QXmlStreamWriter& writer, QSharedPointer<Design> design);\r\n\r\n        /*!\r\n         *  Write a single ad-hoc connection.\r\n         *\r\n         *    @param [in] writer              The used XML writer.\r\n         *    @param [in] adHocConnection     The selected ad-hoc connection.\r\n         *    @param [in] docRevision         The applied IP-XACT standard revision.\r\n         */\r\n        void writeSingleAdHocConnection(QXmlStreamWriter& writer, QSharedPointer<AdHocConnection> adHocConnection,\r\n            Document::Revision docRevision);\r\n\r\n        /*!\r\n         *  Write ad-hoc port references.\r\n         *\r\n         *    @param [in] writer              The used XML writer.\r\n         *    @param [in] adHocConnection     The selected ad-hoc connection.\r\n         *    @param [in] docRevision         The applied IP-XACT standard revision.\r\n         */\r\n        void writeAdHocPortReferences(QXmlStreamWriter& writer, QSharedPointer<AdHocConnection> adHocConnection,\r\n            Document::Revision docRevision);\r\n\r\n        /*!\r\n         *  Write a port reference.\r\n         *\r\n         *    @param [in] writer          The used XML writer.\r\n         *    @param [in] portRefernce    The selected port reference.\r\n         *    @param [in] docRevision     The applied IP-XACT standard revision.\r\n         */\r\n        void writePortReference(QXmlStreamWriter& writer, QSharedPointer<PortReference> portRefernce,\r\n            Document::Revision docRevision);\r\n\r\n    }\r\n};\r\n\r\n#endif // DESIGNWRITER_H\r\n"
  },
  {
    "path": "IPXACTmodels/Design/HierInterface.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: HierInterface.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 19.08.2015\r\n//\r\n// Description:\r\n// Describes the ipxact:hierInterface element in an IP-XACT document.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"HierInterface.h\"\r\n\r\n#include <IPXACTmodels/kactusExtensions/Kactus2Position.h>\r\n#include <IPXACTmodels/kactusExtensions/Kactus2Group.h>\r\n\r\n#include <QPointF>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HierInterface::HierInterface()\r\n//-----------------------------------------------------------------------------\r\nHierInterface::HierInterface(QString const& busRef) :\r\nExtendable(),\r\nbusRef_(busRef)\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HierInterface::~HierInterface()\r\n//-----------------------------------------------------------------------------\r\nHierInterface::~HierInterface()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HierInterface::operator=()\r\n//-----------------------------------------------------------------------------\r\nHierInterface& HierInterface::operator=(const HierInterface& other)\r\n{\r\n    if (this != &other)\r\n    {\r\n        Extendable::operator =(other);\r\n        busRef_ = other.busRef_;\r\n        isPresent_ = other.isPresent_;\r\n        description_ = other.description_;\r\n    }\r\n\r\n    return *this;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HierInterface::operator==()\r\n//-----------------------------------------------------------------------------\r\nbool HierInterface::operator==(const HierInterface& other) const\r\n{\r\n    return (busRef_.compare(other.busRef_, Qt::CaseInsensitive) == 0);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HierInterface::operator!=()\r\n//-----------------------------------------------------------------------------\r\nbool HierInterface::operator!=(const HierInterface& other) const\r\n{\r\n    return !operator==(other);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HierInterface::operator<()\r\n//-----------------------------------------------------------------------------\r\nbool HierInterface::operator<(const HierInterface& other) const\r\n{\r\n    int busResult = busRef_.compare(other.busRef_, Qt::CaseInsensitive);\r\n\r\n    return busResult < 0;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HierInterface::getBusReference()\r\n//-----------------------------------------------------------------------------\r\nQString HierInterface::getBusReference() const\r\n{\r\n    return busRef_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HierInterface::setBusReference()\r\n//-----------------------------------------------------------------------------\r\nvoid HierInterface::setBusReference(QString const& newBusReference)\r\n{\r\n    busRef_ = newBusReference;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HierInterface::getIsPresent()\r\n//-----------------------------------------------------------------------------\r\nQString HierInterface::getIsPresent() const\r\n{\r\n    return isPresent_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HierInterface::setIsPresent()\r\n//-----------------------------------------------------------------------------\r\nvoid HierInterface::setIsPresent(QString const& newIsPresent)\r\n{\r\n    isPresent_ = newIsPresent;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HierInterface::getDescription()\r\n//-----------------------------------------------------------------------------\r\nQString HierInterface::getDescription() const\r\n{\r\n    return description_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HierInterface::setDescription()\r\n//-----------------------------------------------------------------------------\r\nvoid HierInterface::setDescription(QString const& newDescription)\r\n{\r\n    description_ = newDescription;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HierInterface::setRoute()\r\n//-----------------------------------------------------------------------------\r\nvoid HierInterface::setRoute(QList<QPointF> newRoute) const\r\n{\r\n    auto extension = findVendorExtension(QStringLiteral(\"kactus2:route\"));\r\n    getVendorExtensions()->removeAll(extension);\r\n\r\n    if (!newRoute.isEmpty())\r\n    {\r\n        QSharedPointer<Kactus2Group> routeGroup (new Kactus2Group(QStringLiteral(\"kactus2:route\")));\r\n\r\n        for (QPointF const& position : newRoute)\r\n        {\r\n            QSharedPointer<Kactus2Position> newPosition(new Kactus2Position(position));\r\n            routeGroup->addToGroup(newPosition);\r\n        }\r\n\r\n        getVendorExtensions()->append(routeGroup);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HierInterface::getRoute()\r\n//-----------------------------------------------------------------------------\r\nQList<QPointF> HierInterface::getRoute() const\r\n{\r\n    QList<QSharedPointer<VendorExtension> > routeExtension = \r\n        getGroupedExtensionsByType(QStringLiteral(\"kactus2:route\"), QStringLiteral(\"kactus2:position\"));\r\n\r\n    QList<QPointF> route;\r\n\r\n    if (!routeExtension.isEmpty())\r\n    {\r\n        for (QSharedPointer<VendorExtension> extension : routeExtension)\r\n        {\r\n            QSharedPointer<Kactus2Position> position = extension.dynamicCast<Kactus2Position>();\r\n            route.append(position->position());\r\n        }\r\n    }\r\n\r\n    return route;\r\n}\r\n"
  },
  {
    "path": "IPXACTmodels/Design/HierInterface.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: HierInterface.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 19.08.2015\r\n//\r\n// Description:\r\n// Describes the ipxact:hierInterface element in an IP-XACT document.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef HIERINTERFACE_H\r\n#define HIERINTERFACE_H\r\n\r\n#include <IPXACTmodels/common/Extendable.h>\r\n#include <IPXACTmodels/ipxactmodels_global.h>\r\n\r\n#include <QString>\r\n\r\n//-----------------------------------------------------------------------------\r\n// ipxact:hierInterface element. Works as a base class for other design interfaces.\r\n//-----------------------------------------------------------------------------\r\nclass IPXACTMODELS_EXPORT HierInterface : public Extendable\r\n{\r\n\r\npublic:\r\n\r\n    /*!\r\n     *  The constructor.\r\n     *\r\n     *    @param [in] busRef  The name of the referenced bus interface.\r\n     */\r\n    explicit HierInterface(QString const& busRef = QString());\r\n\r\n    /*!\r\n     *  Copy constructor.\r\n     */\r\n    HierInterface(const HierInterface& other) = default;\r\n\r\n    /*!\r\n     *  The destructor.\r\n     */\r\n    ~HierInterface() override;\r\n\r\n    /*!\r\n     *  Assignment operator.\r\n     */\r\n    HierInterface& operator=(const HierInterface& other);\r\n\r\n    /*!\r\n     *  Comparison operator.\r\n     *\r\n     *    @return True, if the bus interfaces reference the same interface.\r\n     */\r\n    bool operator==(const HierInterface& other) const;\r\n\r\n    /*!\r\n     *  The != operator.\r\n     */\r\n    bool operator!=(const HierInterface& other) const;\r\n\r\n    /*!\r\n     *  The < operator.\r\n     */\r\n    bool operator<(const HierInterface& other) const;\r\n\r\n    /*!\r\n     *  Get the name of the referenced bus interface.\r\n     *\r\n     *    @return The name of the referenced bus interface.\r\n     */\r\n    QString getBusReference() const;\r\n\r\n    /*!\r\n     *  Set the bus interface reference.\r\n     *\r\n     *    @param [in] newBusReference     The name of the new bus interface reference.\r\n     */\r\n    void setBusReference(QString const& newBusReference);\r\n\r\n    /*!\r\n     *  Get the presence.\r\n     *\r\n     *    @return The presence.\r\n     */\r\n    QString getIsPresent() const;\r\n\r\n    /*!\r\n     *  Set the presence.\r\n     *\r\n     *    @param [in] newIsPresent    The new presence.\r\n     */\r\n    void setIsPresent(QString const& newIsPresent);\r\n\r\n    /*!\r\n     *  Get the description.\r\n     *\r\n     *    @return The description.\r\n     */\r\n    QString getDescription() const;\r\n\r\n    /*!\r\n     *  Set the description.\r\n     *\r\n     *    @param [in] newDescription  The new description.\r\n     */\r\n    void setDescription(QString const& newDescription);\r\n\r\n    /*!\r\n     *  Set the route to this interface.\r\n     *\r\n     *    @param [in] newRoute    The new route.\r\n     */\r\n    void setRoute(QList<QPointF> newRoute) const;\r\n\r\n    /*!\r\n     *  Get the route to this interface.\r\n     *\r\n     *    @return The route to this interface.\r\n     */\r\n    QList<QPointF> getRoute() const;\r\n\r\nprivate:\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! The name of the referenced bus interface.\r\n    QString busRef_;\r\n\r\n    //! The presence.\r\n    QString isPresent_;\r\n\r\n    //! The description.\r\n    QString description_;\r\n};\r\n#endif // HIERINTERFACE_H\r\n"
  },
  {
    "path": "IPXACTmodels/Design/Interconnection.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: Interconnection.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 19.08.2015\r\n//\r\n// Description:\r\n// Describes the ipxact:interconnection element in an IP-XACT document.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"Interconnection.h\"\r\n\r\n#include <IPXACTmodels/kactusExtensions/Kactus2Placeholder.h>\r\n\r\n#include <IPXACTmodels/utilities/Copy.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Interconnection::Interconnection()\r\n//-----------------------------------------------------------------------------\r\nInterconnection::Interconnection(QString const name, QSharedPointer<ActiveInterface> startInterface,\r\n    QString const& displayName, QString const& description) :\r\nNameGroup(name, displayName, description),\r\nExtendable(),\r\nstartInterface_(startInterface)\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Interconnection::Interconnection()\r\n//-----------------------------------------------------------------------------\r\nInterconnection::Interconnection():\r\nNameGroup(),\r\nExtendable()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Interconnection::Interconnection()\r\n//-----------------------------------------------------------------------------\r\nInterconnection::Interconnection(const Interconnection& other) :\r\nNameGroup(other),\r\nExtendable(other),\r\nstartInterface_(new ActiveInterface(*other.startInterface_)),\r\nisPresent_(other.isPresent_)\r\n{\r\n    Copy::copyList(other.activeInterfaces_, activeInterfaces_);\r\n\r\n    Copy::copyList(other.hierInterfaces_, hierInterfaces_);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Interconnection::operator=()\r\n//-----------------------------------------------------------------------------\r\nInterconnection& Interconnection::operator=( const Interconnection& other)\r\n{\r\n    if (this != &other)\r\n    {\r\n        NameGroup::operator=(other);\r\n        Extendable::operator=(other);\r\n\r\n        isPresent_ = other.isPresent_;\r\n\r\n        startInterface_.clear();\r\n        startInterface_ = QSharedPointer<ActiveInterface>(new ActiveInterface(*other.startInterface_));\r\n\r\n        activeInterfaces_->clear();\r\n        Copy::copyList(other.activeInterfaces_, activeInterfaces_);\r\n\r\n        hierInterfaces_->clear();\r\n\r\n        Copy::copyList(other.hierInterfaces_, hierInterfaces_);\r\n    }\r\n\r\n    return *this;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Interconnection::isOffPage()\r\n//-----------------------------------------------------------------------------\r\nbool Interconnection::isOffPage() const\r\n{\r\n    return findVendorExtension(QStringLiteral(\"kactus2:offPage\")) != nullptr;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Interconnection::setOffPage()\r\n//-----------------------------------------------------------------------------\r\nvoid Interconnection::setOffPage(bool offpage)\r\n{\r\n    setPlaceholderExtension(offpage, QStringLiteral(\"kactus2:offPage\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Interconnection::getStartInterface()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<ActiveInterface> Interconnection::getStartInterface() const\r\n{\r\n    return startInterface_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Interconnection::setStartInterface()\r\n//-----------------------------------------------------------------------------\r\nvoid Interconnection::setStartInterface(QSharedPointer<ActiveInterface> newStartInterface)\r\n{\r\n    startInterface_ = newStartInterface;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Interconnection::getActiveInterfaces()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<QList<QSharedPointer<ActiveInterface> > > Interconnection::getActiveInterfaces() const\r\n{\r\n    return activeInterfaces_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Interconnection::getHierInterfaces()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<QList<QSharedPointer<HierInterface> > > Interconnection::getHierInterfaces() const\r\n{\r\n    return hierInterfaces_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Interconnection::getIsPresent()\r\n//-----------------------------------------------------------------------------\r\nQString Interconnection::getIsPresent() const\r\n{\r\n    return isPresent_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Interconnection::setIsPresent()\r\n//-----------------------------------------------------------------------------\r\nvoid Interconnection::setIsPresent(QString const& newIsPresent)\r\n{\r\n    isPresent_ = newIsPresent;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Interconnection::hasInterfaceReferencing()\r\n//-----------------------------------------------------------------------------\r\nbool Interconnection::hasInterfaceReferencingComponent(QString const& instanceName, \r\n    QString const& busInterfaceName) const\r\n{\r\n    if (startInterface_->getComponentReference() == instanceName &&\r\n        startInterface_->getBusReference() == busInterfaceName)\r\n    {\r\n        return true;\r\n    }\r\n\r\n    return std::any_of(activeInterfaces_->cbegin(), activeInterfaces_->cend(),\r\n        [&instanceName, &busInterfaceName](auto const& singleInterface)\r\n        { return singleInterface->getComponentReference() == instanceName &&\r\n          singleInterface->getBusReference() == busInterfaceName; });\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Interconnection::changeInterfaceComponentReferences()\r\n//-----------------------------------------------------------------------------\r\nvoid Interconnection::changeInterfaceComponentReferences(QString const& oldComponent, QString const& newComponent)\r\n{\r\n    if (startInterface_ && startInterface_->getComponentReference() == oldComponent)\r\n    {\r\n        startInterface_->setComponentReference(newComponent);\r\n    }\r\n\r\n    for (auto currentInterface : *activeInterfaces_)\r\n    {\r\n        if (currentInterface->getComponentReference().compare(oldComponent) == 0)\r\n        {\r\n            currentInterface->setComponentReference(newComponent);\r\n        }\r\n    }\r\n}\r\n"
  },
  {
    "path": "IPXACTmodels/Design/Interconnection.h",
    "content": "//-----------------------------------------------------------------------------\n// File: Interconnection.h\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Mikko Teuho\n// Date: 19.08.2015\n//\n// Description:\n// Describes the ipxact:interconnection element in an IP-XACT document.\n//-----------------------------------------------------------------------------\n\n#ifndef INTERCONNECTION_H\n#define INTERCONNECTION_H\n\n#include \"ActiveInterface.h\"\n#include \"HierInterface.h\"\n\n#include <IPXACTmodels/common/NameGroup.h>\n#include <IPXACTmodels/common/Extendable.h>\n\n#include <IPXACTmodels/ipxactmodels_global.h>\n\n#include <QString>\n\n//-----------------------------------------------------------------------------\n// Describes the ipxact:interconnection element. Specifies a connection between the bus interfaces of components.\n//-----------------------------------------------------------------------------\nclass IPXACTMODELS_EXPORT Interconnection : public NameGroup, public Extendable\n{\npublic:\n\n    /*!\n     *  The constructor.\n     *\n     *    @param [in] name            The name of the interconnection.\n     *    @param [in] startInterface  The start interface.\n     *    @param [in] displayName     The display name.\n     *    @param [in] description     The description.\n     */\n    Interconnection(QString const name, QSharedPointer<ActiveInterface> startInterface,\n        QString const& displayName = QString(), QString const& description = QString ());\n\n    /*!\n     *  The constructor.\n     */\n    Interconnection();\n\n    /*!\n     *  Copy constructor.\n     */\n    Interconnection(const Interconnection& other);\n\n    /*!\n     *  The destructor.\n     */\n    ~Interconnection() override = default;\n\n    /*!\n     *  Assignment operator.\n     */\n    Interconnection& operator=(const Interconnection& other);\n\n    /*!\n     *  Checks if the interconnection is treated as an off-page connection.\n     *\n     *    @return True if off-page connection, otherwise false.\n     */\n    bool isOffPage() const;\n\n    /*!\n     *  Set/unset the connection to off-page connection.\n     *\n     *    @param [in] offPage   True if set to off-page, otherwise false.\n     */\n    void setOffPage(bool offpage);\n\n    /*!\n     *  Get the start interface.\n     *\n     *    @return Pointer to the start interface.\n     */\n    QSharedPointer<ActiveInterface> getStartInterface() const;\n\n    /*!\n     *  Set the start interface.\n     *\n     *    @param [in] newStartInterface   The new start interface.\n     */\n    void setStartInterface(QSharedPointer<ActiveInterface> newStartInterface);\n\n    /*!\n     *  Get the active interfaces.\n     *\n     *    @return A pointer to a list containing the active interfaces.\n     */\n    QSharedPointer<QList<QSharedPointer<ActiveInterface> > > getActiveInterfaces() const;\n\n    /*!\n     *  Get the hier interfaces.\n     *\n     *    @return A pointer to a list containing the hier interfaces.\n     */\n    QSharedPointer<QList<QSharedPointer<HierInterface> > > getHierInterfaces() const;\n\n    /*!\n     *  Get the presence.\n     *\n     *    @return The presence.\n     */\n    QString getIsPresent() const;\n\n    /*!\n     *  Set the presence.\n     *\n     *    @param [in] newIsPresent    The new presence.\n     */\n    void setIsPresent(QString const& newIsPresent);\n\n    /*!\n     *  Check if an interface references a given component and a bus interface.\n     *\n     *    @param [in] instanceName        Name of the component.\n     *    @param [in] busInterfaceName    Name of the bus interface.\n     *\n     *    @return True, if an interface references the given component and bus interface, otherwise false.\n     */\n    bool hasInterfaceReferencingComponent(QString const& instanceName, QString const& busInterfaceName) const;\n\n    /*!\n     *  Change the component reference of contained interfaces.\n     *\n     *    @param [in] oldName     The old component reference.\n     *    @param [in] newName     The new component reference.\n     */\n    void changeInterfaceComponentReferences(QString const& oldComponent, QString const& newComponent);\n\nprivate:\n\n    //-----------------------------------------------------------------------------\n    // Data.\n    //-----------------------------------------------------------------------------\n\n    //! The first interface.\n    QSharedPointer<ActiveInterface> startInterface_;\n\n    //! A list of active interfaces.\n    QSharedPointer<QList<QSharedPointer<ActiveInterface> > > activeInterfaces_ =\n        QSharedPointer<QList<QSharedPointer<ActiveInterface> > >(new QList<QSharedPointer<ActiveInterface> >());\n\n    //! A list of hier interfaces.\n    QSharedPointer<QList<QSharedPointer<HierInterface> > > hierInterfaces_ =\n        QSharedPointer<QList<QSharedPointer<HierInterface> > >(new QList<QSharedPointer<HierInterface> >());\n\n    //! The presence.\n    QString isPresent_;\n\n};\n#endif // INTERCONNECTION_H\n"
  },
  {
    "path": "IPXACTmodels/Design/MonitorInterconnection.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: MonitorInterconnection.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 24.08.2015\r\n//\r\n// Description:\r\n// Describes the ipxact:monitorInterconnection element in an IP-XACT document.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"MonitorInterconnection.h\"\r\n\r\n#include <IPXACTmodels/utilities/Copy.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MonitorInterconnection::MonitorInterconnection()\r\n//-----------------------------------------------------------------------------\r\nMonitorInterconnection::MonitorInterconnection(QString const& name,\r\n    QSharedPointer<MonitorInterface> activeInterface, QString const& displayName,\r\n    QString const& description) :\r\nNameGroup(name, displayName, description),\r\nmonitoredActiveInterface_(activeInterface)\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MonitorInterconnection::MonitorInterconnection()\r\n//-----------------------------------------------------------------------------\r\nMonitorInterconnection::MonitorInterconnection() :\r\nNameGroup()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MonitorInterconnection::MonitorInterconnection()\r\n//-----------------------------------------------------------------------------\r\nMonitorInterconnection::MonitorInterconnection(const MonitorInterconnection& other) :\r\nNameGroup(other),\r\nisPresent_(other.isPresent_),\r\nmonitoredActiveInterface_(new MonitorInterface(*other.monitoredActiveInterface_))\r\n{\r\n    Copy::copyList(other.monitorInterfaces_, monitorInterfaces_);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MonitorInterconnection::operator=()\r\n//-----------------------------------------------------------------------------\r\nMonitorInterconnection& MonitorInterconnection::operator=(const MonitorInterconnection& other)\r\n{\r\n    if (this != &other)\r\n    {\r\n        NameGroup::operator=(other);\r\n\r\n        isPresent_ = other.isPresent_;\r\n\r\n        monitoredActiveInterface_.clear();\r\n        monitoredActiveInterface_ =\r\n            QSharedPointer<MonitorInterface>(new MonitorInterface(*other.monitoredActiveInterface_));\r\n\r\n        monitorInterfaces_->clear();\r\n\r\n        Copy::copyList(other.monitorInterfaces_, monitorInterfaces_);\r\n    }\r\n\r\n    return *this;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MonitorInterconnection::getMonitoredActiveInterface()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<MonitorInterface> MonitorInterconnection::getMonitoredActiveInterface() const\r\n{\r\n    return monitoredActiveInterface_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MonitorInterconnection::setMonitoredctiveInterface()\r\n//-----------------------------------------------------------------------------\r\nvoid MonitorInterconnection::setMonitoredctiveInterface(QSharedPointer<MonitorInterface> newActiveInterface)\r\n{\r\n    monitoredActiveInterface_ = newActiveInterface;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MonitorInterconnection::getMonitorInterfaces()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<QList<QSharedPointer<MonitorInterface> > > MonitorInterconnection::getMonitorInterfaces() const\r\n{\r\n    return monitorInterfaces_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MonitorInterconnection::setMonitorInterfaces()\r\n//-----------------------------------------------------------------------------\r\nvoid MonitorInterconnection::setMonitorInterfaces(\r\n    QSharedPointer<QList<QSharedPointer<MonitorInterface> > > newMonitorInterfaces)\r\n{\r\n    monitorInterfaces_ = newMonitorInterfaces;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Interconnection::getIsPresent()\r\n//-----------------------------------------------------------------------------\r\nQString MonitorInterconnection::getIsPresent() const\r\n{\r\n    return isPresent_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Interconnection::setIsPresent()\r\n//-----------------------------------------------------------------------------\r\nvoid MonitorInterconnection::setIsPresent(QString const& newIsPresent)\r\n{\r\n    isPresent_ = newIsPresent;\r\n}\r\n"
  },
  {
    "path": "IPXACTmodels/Design/MonitorInterconnection.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: MonitorInterconnection.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 24.08.2015\r\n//\r\n// Description:\r\n// Describes the ipxact:monitorInterconnection element in an IP-XACT document.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef MONITORINTERCONNECTION_H\r\n#define MONITORINTERCONNECTION_H\r\n\r\n#include \"MonitorInterface.h\"\r\n\r\n#include <IPXACTmodels/common/NameGroup.h>\r\n\r\n#include <IPXACTmodels/ipxactmodels_global.h>\r\n\r\n#include <QString>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Describes the ipxact:monitorInterconnection element in an IP-XACT document.\r\n//-----------------------------------------------------------------------------\r\nclass IPXACTMODELS_EXPORT MonitorInterconnection : public NameGroup\r\n{\r\npublic:\r\n\r\n    /*!\r\n     *  The constructor.\r\n     *\r\n     *    @param [in] name                The name of the interconnection.\r\n     *    @param [in] activeInterface     The monitored active interface.\r\n     *    @param [in] displayName         Display name.\r\n     *    @param [in] description         Description.\r\n     */\r\n    MonitorInterconnection(QString const& name, \r\n        QSharedPointer<MonitorInterface> activeInterface = QSharedPointer<MonitorInterface>(0),\r\n        QString const& displayName = QString(), QString const& description = QString());\r\n\r\n    /*!\r\n     *  Constructor.\r\n     */\r\n    MonitorInterconnection();\r\n\r\n    /*!\r\n     *  Copy constructor.\r\n     */\r\n    MonitorInterconnection(const MonitorInterconnection& other);\r\n\r\n    /*!\r\n     *  The destructor.\r\n     */\r\n    ~MonitorInterconnection() final = default;\r\n\r\n    /*!\r\n     *  Assignment operator.\r\n     */\r\n    MonitorInterconnection& operator=(const MonitorInterconnection& other);\r\n\r\n    /*!\r\n     *  Get the monitored active interface.\r\n     *\r\n     *    @return Pointer to the monitored active interface.\r\n     */\r\n    QSharedPointer<MonitorInterface> getMonitoredActiveInterface() const;\r\n\r\n    /*!\r\n     *  Set the monitored active interface.\r\n     *\r\n     *    @param [in] newActiveInterface  The new monitored active interface.\r\n     */\r\n    void setMonitoredctiveInterface(QSharedPointer<MonitorInterface> newActiveInterface);\r\n\r\n    /*!\r\n     *  Get the monitor interfaces.\r\n     *\r\n     *    @return A pointer to a list of monitor interfaces.\r\n     */\r\n    QSharedPointer<QList<QSharedPointer<MonitorInterface> > > getMonitorInterfaces() const;\r\n\r\n    /*!\r\n     *  Set the monitor interfaces.\r\n     *\r\n     *    @param [in] newMonitorInterfaces    The new monitor interfaces.\r\n     */\r\n    void setMonitorInterfaces(QSharedPointer<QList<QSharedPointer<MonitorInterface> > > newMonitorInterfaces);\r\n\r\n    /*!\r\n     *  Get the presence.\r\n     *\r\n     *    @return The presence.\r\n     */\r\n    QString getIsPresent() const;\r\n\r\n    /*!\r\n     *  Set the presence.\r\n     *\r\n     *    @param [in] newIsPresent    The new presence.\r\n     */\r\n    void setIsPresent(QString const& newIsPresent);\r\n\r\nprivate:\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! The presence.\r\n    QString isPresent_;\r\n\r\n    //! The monitored active interface\r\n    QSharedPointer<MonitorInterface> monitoredActiveInterface_ =\r\n        QSharedPointer<MonitorInterface>(new MonitorInterface());\r\n\r\n    //! A list of monitor interfaces.\r\n    QSharedPointer<QList<QSharedPointer<MonitorInterface> > > monitorInterfaces_ =\r\n        QSharedPointer<QList<QSharedPointer<MonitorInterface> > >(new QList<QSharedPointer<MonitorInterface> >());\r\n\r\n};\r\n#endif // MONITORINTERCONNECTION_H\r\n"
  },
  {
    "path": "IPXACTmodels/Design/MonitorInterface.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: MonitorInterface.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 21.08.2015\r\n//\r\n// Description:\r\n// Describes the ipxact:MonitorInterface element in an IP-XACT document.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"MonitorInterface.h\"\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MonitorInterface::MonitorInterface()\r\n//-----------------------------------------------------------------------------\r\nMonitorInterface::MonitorInterface(QString componentRef, QString busRef):\r\nHierInterface(busRef),\r\ncomponentReference_(componentRef)\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MonitorInterface::MonitorInterface()\r\n//-----------------------------------------------------------------------------\r\nMonitorInterface::MonitorInterface(const MonitorInterface& other) :\r\nHierInterface(other),\r\ncomponentReference_(other.componentReference_),\r\npath_(other.path_)\r\n{\r\n   \r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MonitorInterface::operator=()\r\n//-----------------------------------------------------------------------------\r\nMonitorInterface& MonitorInterface::operator=(const MonitorInterface& other)\r\n{\r\n    if (this != &other)\r\n    {\r\n        HierInterface::operator=(other);\r\n        componentReference_ = other.componentReference_;\r\n        path_ = other.path_;\r\n    }\r\n\r\n    return *this;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MonitorInterface::operator==()\r\n//-----------------------------------------------------------------------------\r\nbool MonitorInterface::operator==(const MonitorInterface& other) const\r\n{\r\n    return (HierInterface::operator==(other)) &&\r\n        (componentReference_.compare(other.componentReference_, Qt::CaseInsensitive) == 0);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MonitorInterface::operator!=()\r\n//-----------------------------------------------------------------------------\r\nbool MonitorInterface::operator!=(const MonitorInterface& other) const\r\n{\r\n    return !operator==(other);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MonitorInterface::operator<()\r\n//-----------------------------------------------------------------------------\r\nbool MonitorInterface::operator<(const MonitorInterface& other) const\r\n{\r\n    int busRefeferencecomparison = HierInterface::operator<(other);\r\n    if (busRefeferencecomparison == 0)\r\n    {\r\n        return componentReference_.compare(other.componentReference_, Qt::CaseInsensitive) < 0;\r\n    }\r\n    else\r\n    {\r\n        return busRefeferencecomparison < 0;\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MonitorInterface::references()\r\n//-----------------------------------------------------------------------------\r\nbool MonitorInterface::references(QString const& instanceName, QString const& busInterfaceName) const\r\n{\r\n    return instanceName == componentReference_ && busInterfaceName == getBusReference();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MonitorInterface::getComponentReference()\r\n//-----------------------------------------------------------------------------\r\nQString MonitorInterface::getComponentReference() const\r\n{\r\n    return componentReference_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MonitorInterface::setComponentReference()\r\n//-----------------------------------------------------------------------------\r\nvoid MonitorInterface::setComponentReference(QString const& newComponentReference)\r\n{\r\n    componentReference_ = newComponentReference;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MonitorInterface::getPath()\r\n//-----------------------------------------------------------------------------\r\nQString MonitorInterface::getPath() const\r\n{\r\n    return path_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MonitorInterface::setPath()\r\n//-----------------------------------------------------------------------------\r\nvoid MonitorInterface::setPath(QString const& newPath)\r\n{\r\n    path_ = newPath;\r\n}"
  },
  {
    "path": "IPXACTmodels/Design/MonitorInterface.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: MonitorInterface.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 21.08.2015\r\n//\r\n// Description:\r\n// Describes the ipxact:MonitorInterface element in an IP-XACT document.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef MONITORINTERFACE_H\r\n#define MONITORINTERFACE_H\r\n\r\n#include \"HierInterface.h\"\r\n\r\n#include <IPXACTmodels/ipxactmodels_global.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Ipxact:MonitorInterface element.\r\n//-----------------------------------------------------------------------------\r\nclass IPXACTMODELS_EXPORT MonitorInterface : public HierInterface\r\n{\r\n\r\npublic:\r\n\r\n    /*!\r\n     *  The constructor.\r\n     *\r\n     *    @param [in] componentRef    The name of the referenced component instance.\r\n     *    @param [in] busRef          The name of the referenced bus interface.\r\n     */\r\n    MonitorInterface(QString componentRef = QString(), QString busRef = QString());\r\n\r\n    /*!\r\n     *  Copy constructor.\r\n     */\r\n    MonitorInterface(const MonitorInterface& other);\r\n\r\n    /*!\r\n     *  The destructor.\r\n     */\r\n    ~MonitorInterface() final {};\r\n\r\n    /*!\r\n     *  Assignment operator.\r\n     */\r\n    MonitorInterface& operator=(const MonitorInterface& other);\r\n\r\n    /*!\r\n     *  Comparison operator.\r\n     */\r\n    bool operator==(const MonitorInterface& other) const;\r\n\r\n    /*!\r\n     *  The operator !=.\r\n     */\r\n    bool operator!=(const MonitorInterface& other) const;\r\n\r\n    /*!\r\n     *  The operator <.\r\n     */\r\n    bool operator<(const MonitorInterface& other) const;\r\n\r\n    /*!\r\n     *  Checks if the interface referenced a given instance and a bus interface.\r\n     *\r\n     *    @param [in] instanceName        The name of the component instance to compare to.\r\n     *    @param [in] busInterfaceName    The name of the bus interface to compare to.\r\n     *\r\n     *    @return True, if the given instance and bus interface are reference by the interface.\r\n     */\r\n    bool references(QString const& instanceName, QString const& busInterfaceName) const;\r\n\r\n    /*!\r\n     *  Get the component reference.\r\n     *\r\n     *    @return The name of the referenced component\r\n     */\r\n    QString getComponentReference() const;\r\n\r\n    /*!\r\n     *  Set the component reference.\r\n     *\r\n     *    @param [in] newComponentReference   The new component reference.\r\n     */\r\n    void setComponentReference(QString const& newComponentReference);\r\n\r\n    /*!\r\n     *  Get the path.\r\n     *\r\n     *    @return The path.\r\n     */\r\n    QString getPath() const;\r\n\r\n    /*!\r\n     *  Set the path.\r\n     *\r\n     *    @param [in] newPath     The new path.\r\n     */\r\n    void setPath(QString const& newPath);\r\n\r\nprivate:\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! Component reference.\r\n    QString componentReference_;\r\n\r\n    //! The path.\r\n    QString path_;\r\n};\r\n#endif // MONITORINTERFACE_H\r\n"
  },
  {
    "path": "IPXACTmodels/Design/PortReference.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: PortReference.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 25.08.2015\r\n//\r\n// Description:\r\n// Describes either an internal or external port reference in an ad-hoc connection.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"PortReference.h\"\r\n\r\n#include <IPXACTmodels/utilities/Copy.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PortReference::PortReference()\r\n//-----------------------------------------------------------------------------\r\nPortReference::PortReference(QString const& portRef, QString const& componentRef /* = QString() */) :\r\n    portRef_(portRef),\r\n    componentRef_(componentRef)\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PortReference::PortReference()\r\n//-----------------------------------------------------------------------------\r\nPortReference::PortReference(const PortReference& other):\r\nportRef_(other.portRef_),\r\n    componentRef_(other.componentRef_),\r\n    isPresent_(other.isPresent_)\r\n{\r\n    if (other.partSelect_)\r\n    {\r\n        partSelect_ = QSharedPointer<PartSelect>(new PartSelect(*other.partSelect_));\r\n    }\r\n\r\n    Copy::copyList(other.subPortReferences_, subPortReferences_);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PortReference::operator=()\r\n//-----------------------------------------------------------------------------\r\nPortReference& PortReference::operator=( const PortReference& other)\r\n{\r\n    if (this != &other)\r\n    {\r\n        portRef_ = other.portRef_;\r\n        componentRef_ = other.componentRef_;\r\n        isPresent_ = other.isPresent_;\r\n        partSelect_.clear();\r\n        partSelect_ = QSharedPointer<PartSelect>(new PartSelect(*other.partSelect_));\r\n\r\n        subPortReferences_->clear();\r\n        Copy::copyList(other.subPortReferences_, subPortReferences_);\r\n    }\r\n\r\n    return *this;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PortRef::getPortRef()\r\n//-----------------------------------------------------------------------------\r\nQString PortReference::getPortRef() const\r\n{\r\n    return portRef_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PortRef::getComponentRef()\r\n//-----------------------------------------------------------------------------\r\nQString PortReference::getComponentRef() const\r\n{\r\n    return componentRef_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PortReference::setPortRef()\r\n//-----------------------------------------------------------------------------\r\nvoid PortReference::setPortRef(QString const& newPortRef)\r\n{\r\n    portRef_ = newPortRef;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PortReference::setComponentRef()\r\n//-----------------------------------------------------------------------------\r\nvoid PortReference::setComponentRef(QString const& newComponentRef)\r\n{\r\n    componentRef_ = newComponentRef;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PortReference::getIsPresent()\r\n//-----------------------------------------------------------------------------\r\nQString PortReference::getIsPresent() const\r\n{\r\n    return isPresent_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PortReference::setIsPresent()\r\n//-----------------------------------------------------------------------------\r\nvoid PortReference::setIsPresent(QString const& newIsPresent)\r\n{\r\n    isPresent_ = newIsPresent;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PortReference::setIsPresent()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<QList<QSharedPointer<PortReference> > > PortReference::getSubPortReferences() const\r\n{\r\n    return subPortReferences_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PortReference::getPartSelect()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<PartSelect> PortReference::getPartSelect() const\r\n{\r\n    return partSelect_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PortReference::setPartSelect()\r\n//-----------------------------------------------------------------------------\r\nvoid PortReference::setPartSelect(QSharedPointer<PartSelect> newPartSelect)\r\n{\r\n    partSelect_ = newPartSelect;\r\n}\r\n"
  },
  {
    "path": "IPXACTmodels/Design/PortReference.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: PortReference.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 25.08.2015\r\n//\r\n// Description:\r\n// Describes either an internal or external port reference in an ad-hoc connection.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef PORTREFERENCE_H\r\n#define PORTREFERENCE_H\r\n\r\n#include <IPXACTmodels/ipxactmodels_global.h>\r\n\r\n#include <IPXACTmodels/common/PartSelect.h>\r\n\r\n#include <QString>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Describes either an internal, external or sub port reference in an ad-hoc connection.\r\n//\r\n// Internal port (ipxact:internalPortReference) references a port of a component instance.\r\n//\r\n// External port (ipxact:externalPortReference) references a port of the encompassing component.\r\n//\r\n// External port (ipxact:subPortReference) references a subport of the designated component.\r\n//-----------------------------------------------------------------------------\r\nclass IPXACTMODELS_EXPORT PortReference\r\n{\r\n\r\npublic:\r\n\r\n    /*!\r\n     *  The constructor.\r\n     *\r\n     *    @param [in] portRef         The name of the referenced port.\r\n     *    @param [in] componentRef    The name of the referenced component.\r\n     */\r\n    PortReference(QString const& portRef, QString const& componentRef = QString());\r\n\r\n    /*!\r\n     *  Copy constructor.\r\n     */\r\n    PortReference(const PortReference& other);\r\n\r\n    /*!\r\n     *  The destructor.\r\n     */\r\n    ~PortReference() = default;\r\n\r\n    /*!\r\n     *  Assignment operator.\r\n     */\r\n    PortReference& operator=(const PortReference& other);\r\n\r\n    /*!\r\n     *  Gets the name of the referenced port.     \r\n     *\r\n     *    @return The referenced port.\r\n     */\r\n    QString getPortRef() const;\r\n\r\n    /*!\r\n     *  Gets the name of the referenced component instance.     \r\n     *\r\n     *    @return The name of the referenced component instance.\r\n     *\r\n     *      @remark Only for internal port references.\r\n     */\r\n    QString getComponentRef() const;\r\n\r\n    /*!\r\n     *  Set port reference.\r\n     *\r\n     *    @param [in] newPortRef  The new port reference.\r\n     */\r\n    void setPortRef(QString const& newPortRef);\r\n\r\n    /*!\r\n     *  Set the component reference.\r\n     *\r\n     *    @param [in] newComponentRef     The new component reference.\r\n     */\r\n    void setComponentRef(QString const& newComponentRef);\r\n\r\n    /*!\r\n     *  Get the presence.\r\n     *\r\n     *    @return The presence.\r\n     */\r\n    QString getIsPresent() const;\r\n\r\n    /*!\r\n     *  Set the presence.\r\n     *\r\n     *    @param [in] newIsPresent    The new presence.\r\n     */\r\n    void setIsPresent(QString const& newIsPresent);\r\n\r\n    QSharedPointer<QList<QSharedPointer<PortReference> > > getSubPortReferences() const;\r\n\r\n    /*!\r\n     *  Get the part select.\r\n     *\r\n     *    @return The part select.\r\n     */\r\n    QSharedPointer<PartSelect> getPartSelect() const;\r\n\r\n    /*!\r\n     *  Set the part select.\r\n     *\r\n     *    @param [in] newPartSelect   The new part select.\r\n     */\r\n    void setPartSelect(QSharedPointer<PartSelect> newPartSelect);\r\n\r\nprivate:\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! The name of the referenced port.\r\n    QString portRef_;\r\n\r\n    //! The name of the referenced component instance.\r\n    QString componentRef_;\r\n\r\n    //! The presence.\r\n    QString isPresent_;\r\n\r\n    //! The the subport references of internal or external ports.\r\n    QSharedPointer<QList<QSharedPointer<PortReference> > > subPortReferences_ =\r\n        QSharedPointer<QList<QSharedPointer<PortReference> > >(new QList<QSharedPointer<PortReference> >());\r\n\r\n    //! The part select.\r\n    QSharedPointer<PartSelect> partSelect_;\r\n};\r\n#endif // PORTREFERENCE_H\r\n"
  },
  {
    "path": "IPXACTmodels/Design/validator/AdHocConnectionValidator.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: AdHocConnectionValidator.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 19.01.2016\r\n//\r\n// Description:\r\n// Validator for the ipxact:adHocConnection.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"AdHocConnectionValidator.h\"\r\n\r\n#include <IPXACTmodels/common/validators/CommonItemsValidator.h>\r\n\r\n#include <IPXACTmodels/Component/Component.h>\r\n\r\n#include <IPXACTmodels/Design/AdHocConnection.h>\r\n#include <IPXACTmodels/Design/ComponentInstance.h>\r\n\r\n#include <KactusAPI/include/ExpressionParser.h>\r\n\r\n#include <KactusAPI/include/LibraryInterface.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AdHocConnectionValidator::AdHocConnectionValidator()\r\n//-----------------------------------------------------------------------------\r\nAdHocConnectionValidator::AdHocConnectionValidator(QSharedPointer<ExpressionParser> parser,\r\n    LibraryInterface* library):\r\nparser_(parser),\r\nlibraryHandler_(library)\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AdHocConnectionValidator::~AdHocConnectionValidator()\r\n//-----------------------------------------------------------------------------\r\nAdHocConnectionValidator::~AdHocConnectionValidator()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AdHocConnectionValidator::changeComponentInstances()\r\n//-----------------------------------------------------------------------------\r\nvoid AdHocConnectionValidator::changeComponentInstances(\r\n    QSharedPointer<QList<QSharedPointer<ComponentInstance> > > newInstances)\r\n{\r\n    availableComponentInstances_ = newInstances;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AdHocConnectionValidator::validate()\r\n//-----------------------------------------------------------------------------\r\nbool AdHocConnectionValidator::validate(QSharedPointer<AdHocConnection> connection) const\r\n{\r\n    return hasValidName(connection) && hasValidIsPresent(connection->getIsPresent()) &&\r\n        hasValidTiedValue(connection) && hasValidPortReferences(connection);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AdHocConnectionValidator::hasValidName()\r\n//-----------------------------------------------------------------------------\r\nbool AdHocConnectionValidator::hasValidName(QSharedPointer<AdHocConnection> connection) const\r\n{\r\n    return CommonItemsValidator::hasValidName(connection->name());\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AdHocConnectionValidator::hasValidIsPresent()\r\n//-----------------------------------------------------------------------------\r\nbool AdHocConnectionValidator::hasValidIsPresent(QString const& isPresent) const\r\n{\r\n    return CommonItemsValidator::hasValidIsPresent(isPresent, parser_);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AdHocConnectionValidator::hasValidTiedValue()\r\n//-----------------------------------------------------------------------------\r\nbool AdHocConnectionValidator::hasValidTiedValue(QSharedPointer<AdHocConnection> connection) const\r\n{\r\n    if (!connection->getTiedValue().isEmpty())\r\n    {\r\n        QString tiedValue = connection->getTiedValue();\r\n        bool toInt = true;\r\n        parser_->parseExpression(tiedValue).toInt(&toInt);\r\n\r\n        return toInt || tiedValue.compare(QLatin1String(\"default\"), Qt::CaseInsensitive) == 0 ||\r\n            tiedValue.compare(QLatin1String(\"open\"), Qt::CaseInsensitive) == 0;\r\n    }\r\n\r\n    return true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AdHocConnectionValidator::hasValidPortReferences()\r\n//-----------------------------------------------------------------------------\r\nbool AdHocConnectionValidator::hasValidPortReferences(QSharedPointer<AdHocConnection> connection) const\r\n{\r\n    if (connection->getInternalPortReferences()->isEmpty() && connection->getExternalPortReferences()->isEmpty())\r\n    {\r\n        return false;\r\n    }\r\n\r\n    if (std::any_of(connection->getInternalPortReferences()->cbegin(), connection->getInternalPortReferences()->cend(),\r\n        [this, tiedValue = connection->getTiedValue()](auto const& internalReference)\r\n        {return internalPortReferenceIsValid(internalReference, tiedValue) == false; }))\r\n    {\r\n        return false;\r\n    }\r\n\r\n    if (std::any_of(connection->getExternalPortReferences()->cbegin(), connection->getExternalPortReferences()->cend(),\r\n        [this](auto const& externalReference)\r\n        {return externalPortReferenceIsValid(externalReference) == false; }))\r\n    {\r\n        return false;\r\n    }\r\n\r\n    return true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AdHocConnectionValidator::internalPortReferenceIsValid()\r\n//-----------------------------------------------------------------------------\r\nbool AdHocConnectionValidator::internalPortReferenceIsValid(QSharedPointer<PortReference> portReference,\r\n    QString const& tiedValue) const\r\n{\r\n    if (portReference->getComponentRef().isEmpty())\r\n    {\r\n        return false;\r\n    }\r\n\r\n    if (auto referencedInstance = getReferencedComponentInstance(portReference->getComponentRef()); \r\n        referencedInstance)\r\n    {\r\n        auto referencedComponent = getReferencedComponent(referencedInstance);\r\n        if (referencedComponent)\r\n        {\r\n            auto referencedComponentPort = getReferencedPort(referencedComponent, portReference);\r\n            if (referencedComponentPort)\r\n            {\r\n                return tiedValueIsValidWithReferencedPort(tiedValue, referencedComponentPort) &&\r\n                    hasValidIsPresent(portReference->getIsPresent()) &&\r\n                    portReferencePartSelectIsValid(portReference->getPartSelect());\r\n            }\r\n        }\r\n    }\r\n\r\n    return false;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AdHocConnectionValidator::getReferencedComponentInstance()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<ComponentInstance> AdHocConnectionValidator::getReferencedComponentInstance(\r\n    QString const& instanceReference) const\r\n{\r\n    QSharedPointer<ComponentInstance> foundInstance = nullptr;\r\n    if (instanceReference.isEmpty() || availableComponentInstances_->isEmpty())\r\n    {\r\n        return foundInstance;\r\n    }\r\n\r\n    auto it = std::find_if(availableComponentInstances_->cbegin(), availableComponentInstances_->cend(),\r\n        [&instanceReference](auto const& instance) {return instance->getInstanceName() == instanceReference; });\r\n        \r\n    if (it != availableComponentInstances_->cend())\r\n    {\r\n        foundInstance = *it;\r\n    }\r\n    \r\n    return foundInstance;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AdHocConnectionValidator::getReferencedComponent()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<const Component> AdHocConnectionValidator::getReferencedComponent(\r\n    QSharedPointer<ComponentInstance> referencingInstance) const\r\n{\r\n    if (referencingInstance && referencingInstance->getComponentRef())\r\n    {\r\n        QSharedPointer<const Component> referencedComponent =\r\n            libraryHandler_->getModelReadOnly(*referencingInstance->getComponentRef()).dynamicCast<Component const>();\r\n\r\n        return referencedComponent;\r\n    }\r\n\r\n    return QSharedPointer<const Component> ();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AdHocConnectionValidator::getReferencedPort()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<Port> AdHocConnectionValidator::getReferencedPort(QSharedPointer<const Component> component,\r\n    QSharedPointer<PortReference> portReference) const\r\n{\r\n    QSharedPointer<Port> foundPort = nullptr;\r\n\r\n    if (portReference->getPortRef().isEmpty())\r\n    {\r\n        return foundPort;\r\n    }\r\n\r\n    auto it = std::find_if(component->getPorts()->cbegin(), component->getPorts()->cend(),\r\n        [&portReference](auto const& currentPort) { return currentPort->name() == portReference->getPortRef(); });\r\n\r\n    if (it != component->getPorts()->cend())\r\n    {\r\n        foundPort = *it;\r\n    }\r\n\r\n    return foundPort;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AdHocConnectionValidator::tiedValueIsValidWithReferencedPort()\r\n//-----------------------------------------------------------------------------\r\nbool AdHocConnectionValidator::tiedValueIsValidWithReferencedPort(QString const& tiedValue,\r\n    QSharedPointer<Port> referencedPort) const\r\n{\r\n    return (tiedValue != QLatin1String(\"default\") || referencedPort->getDefaultValue().isEmpty() == false);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AdHocConnectionValidator::externalPortReferenceIsValid()\r\n//-----------------------------------------------------------------------------\r\nbool AdHocConnectionValidator::externalPortReferenceIsValid(QSharedPointer<PortReference> externalPort) const\r\n{\r\n    if (!externalPort->getPortRef().isEmpty())\r\n    {\r\n        return hasValidIsPresent(externalPort->getIsPresent()) &&\r\n            portReferencePartSelectIsValid(externalPort->getPartSelect());\r\n    }\r\n\r\n    return false;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AdHocConnectionValidator::portReferencePartSelectIsValid()\r\n//-----------------------------------------------------------------------------\r\nbool AdHocConnectionValidator::portReferencePartSelectIsValid(QSharedPointer<PartSelect> partSelect) const\r\n{\r\n    if (partSelect == nullptr)\r\n    {\r\n        return true;\r\n    }\r\n\r\n    if ((partSelect->getLeftRange().isEmpty() || partSelect->getRightRange().isEmpty()) &&\r\n        partSelect->getIndices()->isEmpty())\r\n    {\r\n        return false;\r\n    }\r\n\r\n    if (!partSelect->getLeftRange().isEmpty() && !partSelect->getRightRange().isEmpty())\r\n    {\r\n        if (!unsignedIntExpressionIsValid(partSelect->getLeftRange()) ||\r\n            !unsignedIntExpressionIsValid(partSelect->getRightRange()))\r\n        {\r\n            return false;\r\n        }\r\n    }\r\n\r\n    return std::all_of(partSelect->getIndices()->cbegin(), partSelect->getIndices()->cend(),\r\n        [this](auto const& index) { return unsignedIntExpressionIsValid(index); });\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AdHocConnectionValidator::unsignedIntExpressionIsValid()\r\n//-----------------------------------------------------------------------------\r\nbool AdHocConnectionValidator::unsignedIntExpressionIsValid(QString const& expression) const\r\n{\r\n    bool toIntOk = true;\r\n    int parsedExpression = parser_->parseExpression(expression).toInt(&toIntOk);\r\n\r\n    return toIntOk && parsedExpression >= 0;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AdHocConnectionValidator::findErrorsIn()\r\n//-----------------------------------------------------------------------------\r\nvoid AdHocConnectionValidator::findErrorsIn(QVector<QString>& errors, QSharedPointer<AdHocConnection> connection,\r\n    QString const& context) const\r\n{\r\n    QString connectionContext = QObject::tr(\"ad hoc connection %1\").arg(connection->name());\r\n\r\n    findErrorsInName(errors, connection, context);\r\n    findErrorsInIsPresent(errors, connection->getIsPresent(), connectionContext, context);\r\n    findErrorsInTiedValue(errors, connection, context);\r\n    findErrorsInPortReferences(errors, connection, connectionContext, context);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AdHocConnectionValidator::findErrorsInName()\r\n//-----------------------------------------------------------------------------\r\nvoid AdHocConnectionValidator::findErrorsInName(QVector<QString>& errors,\r\n    QSharedPointer<AdHocConnection> connection, QString const& context) const\r\n{\r\n    if (!hasValidName(connection))\r\n    {\r\n        errors.append(QObject::tr(\"Invalid name '%1' set for ad hoc connection within %2\")\r\n            .arg(connection->name(), context));\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AdHocConnectionValidator::findErrorsInIsPresent()\r\n//-----------------------------------------------------------------------------\r\nvoid AdHocConnectionValidator::findErrorsInIsPresent(QVector<QString>& errors, QString const& isPresent,\r\n    QString const& innerContext, QString const& context) const\r\n{\r\n    if (!hasValidIsPresent(isPresent))\r\n    {\r\n        errors.append(QObject::tr(\"Invalid isPresent set for %1 within %2\").arg(innerContext, context));\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AdHocConnectionValidator::findErrorsInTiedValue()\r\n//-----------------------------------------------------------------------------\r\nvoid AdHocConnectionValidator::findErrorsInTiedValue(QVector<QString>& errors,\r\n    QSharedPointer<AdHocConnection> connection, QString const& context) const\r\n{\r\n    if (!hasValidTiedValue(connection))\r\n    {\r\n        errors.append(QObject::tr(\"Invalid tied value set for ad hoc connection %1 within %2\")\r\n            .arg(connection->name(), context));\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AdHocConnectionValidator::findErrorsInPortReferences()\r\n//-----------------------------------------------------------------------------\r\nvoid AdHocConnectionValidator::findErrorsInPortReferences(QVector<QString>& errors,\r\n    QSharedPointer<AdHocConnection> connection, QString const& innerContext, QString const& context) const\r\n{\r\n    if (!connection->getInternalPortReferences()->isEmpty() || !connection->getExternalPortReferences()->isEmpty())\r\n    {\r\n        QString internalElement = QObject::tr(\"internal port reference\");\r\n        QString externalElement = QObject::tr(\"external port reference\");\r\n        \r\n        for (QSharedPointer<PortReference> internalPort : *connection->getInternalPortReferences())\r\n        {\r\n            findErrorsInInternalPortReference(errors, internalPort, connection->getTiedValue(), internalElement,\r\n                innerContext, context);\r\n        }\r\n        for (QSharedPointer<PortReference> externalPort : *connection->getExternalPortReferences())\r\n        {\r\n            findErrorsInExternalPortReference(errors, externalPort, externalElement, innerContext, context);\r\n        }\r\n    }\r\n    else\r\n    {\r\n        errors.append(QObject::tr(\"No port references set for %1 within %2\").arg(innerContext).arg(context));\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AdHocConnectionValidator::findErrorsInInternalPortReference()\r\n//-----------------------------------------------------------------------------\r\nvoid AdHocConnectionValidator::findErrorsInInternalPortReference(QVector<QString>& errors,\r\n    QSharedPointer<PortReference> internalPort, QString const& tiedValue, QString const& elementName,\r\n    QString const& innerContext, QString const& context) const\r\n{\r\n    QSharedPointer<ComponentInstance> referencedInstance =\r\n        getReferencedComponentInstance(internalPort->getComponentRef());\r\n\r\n    if (internalPort->getComponentRef().isEmpty())\r\n    {\r\n        errors.append(QObject::tr(\"No component reference set for internal port reference in %1 within %2\")\r\n            .arg(innerContext, context));\r\n    }\r\n    else if (!referencedInstance)\r\n    {\r\n        errors.append(QObject::tr(\"Component instance %1 referenced by internal port reference in %2 within %3 \"\r\n            \"was not found\")\r\n            .arg(internalPort->getComponentRef(), innerContext, context));\r\n    }\r\n\r\n    QSharedPointer<const Component> referencedComponent = getReferencedComponent(referencedInstance);\r\n\r\n    if (internalPort->getPortRef().isEmpty())\r\n    {\r\n        errors.append(QObject::tr(\"No port reference set for internal port reference in %1 within %2\")\r\n            .arg(innerContext, context));\r\n    }\r\n    else if (referencedComponent)\r\n    {\r\n        QSharedPointer<Port> referencedComponentPort = getReferencedPort(referencedComponent, internalPort);\r\n        if (referencedComponentPort)\r\n        {\r\n            if (!tiedValueIsValidWithReferencedPort(tiedValue, referencedComponentPort))\r\n            {\r\n                errors.append(QObject::tr(\"No default value found for port '%1' referenced by internal port \"\r\n                    \"reference in %2 within %3\")\r\n                    .arg(internalPort->getPortRef(), innerContext, context));\r\n            }\r\n        }\r\n        else\r\n        {\r\n            errors.append(QObject::tr(\"Port '%1' referenced by the internal port reference  in %2 within %3 was \"\r\n                \"not found\")\r\n                .arg(internalPort->getPortRef(), innerContext, context));\r\n        }\r\n    }\r\n\r\n    findErrorsInIsPresent(errors, internalPort->getIsPresent(), elementName, innerContext);\r\n    findErrorsInPortReferencePartSelect(errors, internalPort->getPartSelect(), elementName, innerContext, context);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AdHocConnectionValidator::findErrorsInExternalPortReference()\r\n//-----------------------------------------------------------------------------\r\nvoid AdHocConnectionValidator::findErrorsInExternalPortReference(QVector<QString>& errors,\r\n    QSharedPointer<PortReference> externalPort, QString const& elementName, QString const& innerContext,\r\n    QString const& context) const\r\n{\r\n    if (externalPort->getPortRef().isEmpty())\r\n    {\r\n        errors.append(QObject::tr(\"No port reference set for external port reference in %1 within %2\")\r\n            .arg(innerContext, context));\r\n    }\r\n\r\n    findErrorsInIsPresent(errors, externalPort->getIsPresent(), elementName, innerContext);\r\n    findErrorsInPortReferencePartSelect(errors, externalPort->getPartSelect(), elementName, innerContext, context);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AdHocConnectionValidator::findErrorsInPortReferencePartSelect()\r\n//-----------------------------------------------------------------------------\r\nvoid AdHocConnectionValidator::findErrorsInPortReferencePartSelect(QVector<QString>& errors,\r\n    QSharedPointer<PartSelect> partSelect, QString const& elementName, QString const& innerContext,\r\n    QString const& context) const\r\n{\r\n    if (partSelect == nullptr)\r\n    {\r\n        return;\r\n    }\r\n\r\n    if (partSelect->getLeftRange().isEmpty() && partSelect->getRightRange().isEmpty() &&\r\n        (!partSelect->getIndices() || partSelect->getIndices()->isEmpty()))\r\n    {\r\n        errors.append(QObject::tr(\"No range or index set for part select in %1 in %2 within %3\")\r\n            .arg(elementName, innerContext, context));\r\n    }\r\n    else\r\n    {\r\n        if (!partSelect->getLeftRange().isEmpty() || !partSelect->getRightRange().isEmpty())\r\n        {\r\n            if (!unsignedIntExpressionIsValid(partSelect->getLeftRange()))\r\n            {\r\n                errors.append(QObject::tr(\"Invalid left value '%1' set for %2 part select in %3 within %4\")\r\n                    .arg(partSelect->getLeftRange(), elementName, innerContext, context));\r\n            }\r\n            if (!unsignedIntExpressionIsValid(partSelect->getRightRange()))\r\n            {\r\n                errors.append(QObject::tr(\"Invalid right value '%1' set for %2 part select in %3 within %4\")\r\n                    .arg(partSelect->getRightRange(), elementName, innerContext, context));\r\n            }\r\n        }\r\n        if (!partSelect->getIndices()->isEmpty())\r\n        {\r\n            for (QString const& index : *partSelect->getIndices())\r\n            {\r\n                if (!unsignedIntExpressionIsValid(index))\r\n                {\r\n                    errors.append(QObject::tr(\"Invalid index value '%1' set for %2 part select in %3 within %4\")\r\n                        .arg(index).arg(elementName, innerContext, context));\r\n                }\r\n            }\r\n        }\r\n    }\r\n}\r\n\r\n"
  },
  {
    "path": "IPXACTmodels/Design/validator/AdHocConnectionValidator.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: AdHocConnectionValidator.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 19.01.2016\r\n//\r\n// Description:\r\n// Validator for the ipxact:adHocConnection.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef ADHOCCONNECTIONVALIDATOR_H\r\n#define ADHOCCONNECTIONVALIDATOR_H\r\n\r\n#include <IPXACTmodels/ipxactmodels_global.h>\r\n\r\n#include <QSharedPointer>\r\n#include <QString>\r\n#include <QVector>\r\n\r\nclass LibraryInterface;\r\n\r\nclass ExpressionParser;\r\n\r\nclass AdHocConnection;\r\nclass PortReference;\r\nclass ComponentInstance;\r\nclass PartSelect;\r\n\r\nclass Component;\r\nclass Port;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Validator for the ipxact:adHocConnection.\r\n//-----------------------------------------------------------------------------\r\nclass IPXACTMODELS_EXPORT AdHocConnectionValidator\r\n{\r\npublic:\r\n\r\n    /*!\r\n     *  The constructor.\r\n     *\r\n     *    @param [in] parser      The used expression parser.\r\n     *    @param [in] library     The used library interface.\r\n     */\r\n    AdHocConnectionValidator(QSharedPointer<ExpressionParser> parser, LibraryInterface* library);\r\n\r\n\t//! The destructor.\r\n\t~AdHocConnectionValidator();\r\n    \r\n    /*!\r\n     *  Change the used component instances.\r\n     *\r\n     *    @param [in] newInstances    A list of the new component instances.\r\n     */\r\n    void changeComponentInstances(QSharedPointer<QList<QSharedPointer<ComponentInstance> > > newInstances);\r\n\r\n    /*!\r\n     *  Validates the given ad hoc connection.\r\n     *\r\n     *    @param [in] connection  The selected ad hoc connection.\r\n     *\r\n     *    @return True, if the ad hoc connection is valid IP-XACT, otherwise false.\r\n     */\r\n    bool validate(QSharedPointer<AdHocConnection> connection) const;\r\n\r\n    /*!\r\n     *  Check if the name is valid.\r\n     *\r\n     *    @param [in] connection  The selected ad hoc connection.\r\n     *\r\n     *    @return True, if the name is valid, otherwise false.\r\n     */\r\n    bool hasValidName(QSharedPointer<AdHocConnection> connection) const;\r\n\r\n    /*!\r\n     *  Check if the isPresent is valid.\r\n     *\r\n     *    @param [in] connection  The selected ad hoc connection.\r\n     *\r\n     *    @return True, if the isPresent is valid, otherwise false.\r\n     */\r\n    bool hasValidIsPresent(QString const& isPresent) const;\r\n\r\n    /*!\r\n     *  Check if the tied value is valid.\r\n     *\r\n     *    @param [in] connection  The selected ad hoc connection.\r\n     *\r\n     *    @return True, if the tied value is valid, otherwise false.\r\n     */\r\n    bool hasValidTiedValue(QSharedPointer<AdHocConnection> connection) const;\r\n\r\n    /*!\r\n     *  Check if the port references are valid.\r\n     *\r\n     *    @param [in] connection  The selected ad hoc connection.\r\n     *\r\n     *    @return True, if the port references are valid, otherwise false.\r\n     */\r\n    bool hasValidPortReferences(QSharedPointer<AdHocConnection> connection) const;\r\n\r\n    /*!\r\n     *  Locate errors within an ad hoc connection.\r\n     *\r\n     *    @param [in] errors      List of found errors.\r\n     *    @param [in] connection  The selected ad hoc connection.\r\n     *    @param [in] context     Context to help locate the errors.\r\n     */\r\n    void findErrorsIn(QVector<QString>& errors, QSharedPointer<AdHocConnection> connection, QString const& context)\r\n        const;\r\n\r\nprivate:\r\n\r\n\t// Disable copying.\r\n\tAdHocConnectionValidator(AdHocConnectionValidator const& rhs);\r\n\tAdHocConnectionValidator& operator=(AdHocConnectionValidator const& rhs);\r\n\r\n    /*!\r\n     *  Check if an internal port reference is valid.\r\n     *\r\n     *    @param [in] portReference   The selected internal port reference.\r\n     *    @param [in] tiedValue       Tied value of the ad hoc connection.\r\n     *\r\n     *    @return True, if the internal port reference is valid, otherwise false.\r\n     */\r\n    bool internalPortReferenceIsValid(QSharedPointer<PortReference> portReference, QString const& tiedValue) const;\r\n\r\n    /*!\r\n     *  Get the referenced component instance.\r\n     *\r\n     *    @param [in] instanceReference   The name of the referenced component instance.\r\n     *\r\n     *    @return The referenced component instance, or a null pointer if the component instance is not found.\r\n     */\r\n    QSharedPointer<ComponentInstance> getReferencedComponentInstance(QString const& instanceReference) const;\r\n\r\n    /*!\r\n     *  Get the component referenced by the component instance.\r\n     *\r\n     *    @param [in] referencingInstance     The selected component instance.\r\n     *\r\n     *    @return The referenced component instance, or a null pointer if the component is not found.\r\n     */\r\n    QSharedPointer<const Component> getReferencedComponent(QSharedPointer<ComponentInstance> referencingInstance) const;\r\n\r\n    /*!\r\n     *  Get the port referenced by the port reference.\r\n     *\r\n     *    @param [in] component       The selected component.\r\n     *    @param [in] portReference   The selected port reference.\r\n     *\r\n     *    @return The referenced port, or a null pointer if the port is not found.\r\n     */\r\n    QSharedPointer<Port> getReferencedPort(QSharedPointer<const Component> component,\r\n        QSharedPointer<PortReference> portReference) const;\r\n\r\n    /*!\r\n     *  Check if the referenced port default value is valid.\r\n     *\r\n     *    @param [in] tiedValue       The tied value of the connection.\r\n     *    @param [in] referencedPort  The referenced port.\r\n     *\r\n     *    @return True, if the port default value is valid, otherwise false.\r\n     */\r\n    bool tiedValueIsValidWithReferencedPort(QString const& tiedValue, QSharedPointer<Port> referencedPort) const;\r\n\r\n    /*!\r\n     *  Check if the external port reference is valid.\r\n     *\r\n     *    @param [in] externalPort    The selected external port.\r\n     *\r\n     *    @return True, if the external port reference is valid, otherwise false.\r\n     */\r\n    bool externalPortReferenceIsValid(QSharedPointer<PortReference> externalPort) const;\r\n\r\n    /*!\r\n     *  Check if the port reference part select is valid.\r\n     *\r\n     *    @param [in] partSelect  The selected part select.\r\n     *\r\n     *    @return True, if the port reference part select is valid, otherwise false.\r\n     */\r\n    bool portReferencePartSelectIsValid(QSharedPointer<PartSelect> partSelect) const;\r\n\r\n    /*!\r\n     *  Check if an expression is valid unsigned int expression.\r\n     *\r\n     *    @param [in] expression  The selected expression.\r\n     *\r\n     *    @return True, if the expression is valid, otherwise false.\r\n     */\r\n    bool unsignedIntExpressionIsValid(QString const& expression) const;\r\n\r\n    /*!\r\n     *  Find errors in name.\r\n     *\r\n     *    @param [in] errors      List of found errors.\r\n     *    @param [in] connection  The selected ad hoc connection.\r\n     *    @param [in] context     Context to help locate the errors.\r\n     */\r\n    void findErrorsInName(QVector<QString>& errors, QSharedPointer<AdHocConnection> connection,\r\n        QString const& context) const;\r\n\r\n    /*!\r\n     *  Find errors in isPresent.\r\n     *\r\n     *    @param [in] errors          List of found errors.\r\n     *    @param [in] isPresent       The selected isPresent value.\r\n     *    @param [in] innerContext    Context information of the ad hoc connection.\r\n     *    @param [in] context         Context to help locate the errors.\r\n     */\r\n    void findErrorsInIsPresent(QVector<QString>& errors, QString const& isPresent, QString const& innerContext,\r\n        QString const& context) const;\r\n\r\n    /*!\r\n     *  Find errors in tied value.\r\n     *\r\n     *    @param [in] errors      List of found errors.\r\n     *    @param [in] connection  The selected ad hoc connection.\r\n     *    @param [in] context     Context to help locate the errors.\r\n     */\r\n    void findErrorsInTiedValue(QVector<QString>& errors, QSharedPointer<AdHocConnection> connection,\r\n        QString const& context) const;\r\n\r\n    /*!\r\n     *  Find errors in port references.\r\n     *\r\n     *    @param [in] errors          List of found errors.\r\n     *    @param [in] connection      The selected ad hoc connection.\r\n     *    @param [in] innerContext    Context information of the ad hoc connection.\r\n     *    @param [in] context         Context to help locate the errors.\r\n     */\r\n    void findErrorsInPortReferences(QVector<QString>& errors, QSharedPointer<AdHocConnection> connection,\r\n        QString const& innerContext, QString const& context) const;\r\n\r\n    /*!\r\n     *  Find errors in an internal port reference.\r\n     *\r\n     *    @param [in] errors          List of found errors.\r\n     *    @param [in] internalPort    The selected internal port reference.\r\n     *    @param [in] tiedValue       The tied value of the connection.\r\n     *    @param [in] elementName     Element name of the internal port reference.\r\n     *    @param [in] innerContext    Context information of the ad hoc connection.\r\n     *    @param [in] context         Context to help locate the errors.\r\n     */\r\n    void findErrorsInInternalPortReference(QVector<QString>& errors, QSharedPointer<PortReference> internalPort,\r\n        QString const& tiedValue, QString const& elementName, QString const& innerContext, QString const& context)\r\n        const;\r\n\r\n    /*!\r\n     *  Find errors in an external port reference.\r\n     *\r\n     *    @param [in] errors          List of found errors.\r\n     *    @param [in] externalPort    The selected external port reference.\r\n     *    @param [in] elementName     Element name of the external port reference.\r\n     *    @param [in] innerContext    Context information of the ad hoc connection.\r\n     *    @param [in] context         Context to help locate the errors.\r\n     */\r\n    void findErrorsInExternalPortReference(QVector<QString>& errors, QSharedPointer<PortReference> externalPort,\r\n        QString const& elementName, QString const& innerContext, QString const& context) const;\r\n\r\n    /*!\r\n     *  Find errors in port reference part select.\r\n     *\r\n     *    @param [in] errors          List of found errors.\r\n     *    @param [in] partSelect      The selected part select.\r\n     *    @param [in] elementName     The element name of the port reference.\r\n     *    @param [in] innerContext    Context information of the ad hoc connection.\r\n     *    @param [in] context         Context to help locate the errors.\r\n     */\r\n    void findErrorsInPortReferencePartSelect(QVector<QString>& errors, QSharedPointer<PartSelect> partSelect,\r\n        QString const& elementName, QString const& innerContext, QString const& context) const;\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! The used expression parser.\r\n    QSharedPointer<ExpressionParser> parser_;\r\n\r\n    //! The containing library.\r\n    LibraryInterface* libraryHandler_;\r\n\r\n    //! The currently available component instances.\r\n    QSharedPointer<QList<QSharedPointer<ComponentInstance> > > availableComponentInstances_ =\r\n        QSharedPointer<QList<QSharedPointer<ComponentInstance> > >(new QList<QSharedPointer<ComponentInstance> >());\r\n};\r\n\r\n#endif // ADHOCCONNECTIONVALIDATOR_H\r\n"
  },
  {
    "path": "IPXACTmodels/Design/validator/ComponentInstanceValidator.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ComponentInstanceValidator.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 15.01.2016\r\n//\r\n// Description:\r\n// Validator for the ipxact:componentInstance.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"ComponentInstanceValidator.h\"\r\n\r\n#include <IPXACTmodels/common/validators/CommonItemsValidator.h>\r\n\r\n#include <IPXACTmodels/Component/Component.h>\r\n\r\n#include <IPXACTmodels/Design/ComponentInstance.h>\r\n\r\n#include <KactusAPI/include/ExpressionParser.h>\r\n#include <KactusAPI/include/LibraryInterface.h>\r\n\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentInstanceValidator::ComponentInstanceValidator()\r\n//-----------------------------------------------------------------------------\r\nComponentInstanceValidator::ComponentInstanceValidator(QSharedPointer<ExpressionParser> parser,\r\n    LibraryInterface* library):\r\nparser_(parser),\r\nlibraryHandler_(library)\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentInstanceValidator::~ComponentInstanceValidator()\r\n//-----------------------------------------------------------------------------\r\nComponentInstanceValidator::~ComponentInstanceValidator()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentInstanceValidator::validate()\r\n//-----------------------------------------------------------------------------\r\nbool ComponentInstanceValidator::validate(QSharedPointer<ComponentInstance> instance) const\r\n{\r\n    return hasValidName(instance) && hasValidIsPresent(instance) && hasValidComponentReference(instance);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentInstanceValidator::hasValidName()\r\n//-----------------------------------------------------------------------------\r\nbool ComponentInstanceValidator::hasValidName(QSharedPointer<ComponentInstance> instance) const\r\n{\r\n    return CommonItemsValidator::hasValidName(instance->name());\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentInstanceValidator::hasValidIsPresent()\r\n//-----------------------------------------------------------------------------\r\nbool ComponentInstanceValidator::hasValidIsPresent(QSharedPointer<ComponentInstance> instance) const\r\n{\r\n    return CommonItemsValidator::hasValidIsPresent(instance->getIsPresent(), parser_);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentInstanceValidator::hasValidComponentReference()\r\n//-----------------------------------------------------------------------------\r\nbool ComponentInstanceValidator::hasValidComponentReference(QSharedPointer<ComponentInstance> instance) const\r\n{\r\n    return instance->getComponentRef() && instance->getComponentRef()->isValid() &&\r\n       libraryHandler_->contains(*instance->getComponentRef());\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentInstanceValidator::findErrorsIn()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentInstanceValidator::findErrorsIn(QVector<QString>& errors, QSharedPointer<ComponentInstance> instance,\r\n    QString const& context) const\r\n{\r\n    findErrorsInName(errors, instance, context);\r\n    findErrorsInIsPresent(errors, instance, context);\r\n    findErrorsInComponentReference(errors, instance, context);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentInstanceValidator::findErrorsInName()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentInstanceValidator::findErrorsInName(QVector<QString>& errors,\r\n    QSharedPointer<ComponentInstance> instance, QString const& context) const\r\n{\r\n    if (!hasValidName(instance))\r\n    {\r\n        errors.append(QObject::tr(\"Invalid instance name '%1' set for component instance within %2\")\r\n            .arg(instance->getInstanceName(), context));\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentInstanceValidator::findErrorsInIsPresent()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentInstanceValidator::findErrorsInIsPresent(QVector<QString>& errors,\r\n    QSharedPointer<ComponentInstance> instance, QString const& context) const\r\n{\r\n    if (!hasValidIsPresent(instance))\r\n    {\r\n        errors.append(QObject::tr(\"Invalid isPresent set for component instance %1 within %2\")\r\n            .arg(instance->getInstanceName(), context));\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentInstanceValidator::findErrorsInComponentReference()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentInstanceValidator::findErrorsInComponentReference(QVector<QString>& errors,\r\n    QSharedPointer<ComponentInstance> instance, QString const& context) const\r\n{\r\n    if (!instance->getComponentRef()->isEmpty())\r\n    {\r\n        if (!libraryHandler_->contains(*instance->getComponentRef()))\r\n        {\r\n            errors.append(QObject::tr(\"Component reference %1 in component instance %2 within %3 was not found \"\r\n                \"in the library\")\r\n                .arg(instance->getComponentRef()->toString(), instance->getInstanceName(), context));\r\n        }\r\n\r\n        QString instanceContext =\r\n            QObject::tr(\"component reference in component instance %1\").arg(instance->getInstanceName());\r\n\r\n        instance->getComponentRef()->isValid(errors, instanceContext);\r\n    }\r\n    else\r\n    {\r\n        errors.append(QObject::tr(\"No component reference given in component instance %1 within %2\")\r\n            .arg(instance->getInstanceName(), context));\r\n    }\r\n}\r\n"
  },
  {
    "path": "IPXACTmodels/Design/validator/ComponentInstanceValidator.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ComponentInstanceValidator.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 15.01.2016\r\n//\r\n// Description:\r\n// Validator for the ipxact:componentInstance.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef COMPONENTINSTANCEVALIDATOR_H\r\n#define COMPONENTINSTANCEVALIDATOR_H\r\n\r\n#include <IPXACTmodels/ipxactmodels_global.h>\r\n\r\n#include <QSharedPointer>\r\n#include <QString>\r\n#include <QVector>\r\n\r\nclass ComponentInstance;\r\n\r\nclass LibraryInterface;\r\nclass ExpressionParser;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Validator for the ipxact:componentInstance.\r\n//-----------------------------------------------------------------------------\r\nclass IPXACTMODELS_EXPORT ComponentInstanceValidator\r\n{\r\npublic:\r\n\r\n    /*!\r\n     *  The constructor.\r\n     *\r\n     *    @param [in] parser      The used expression parser.\r\n     *    @param [in] library     The used library interface.\r\n     */\r\n    ComponentInstanceValidator(QSharedPointer<ExpressionParser> parser, LibraryInterface* library);\r\n\r\n\t//! The destructor.\r\n\t~ComponentInstanceValidator();\r\n    \r\n    /*!\r\n     *  Validates the given component instance.\r\n     *\r\n     *    @param [in] instance    The selected component instance.\r\n     *\r\n     *    @return True, if the component instance is valid IP-XACT, otherwise false.\r\n     */\r\n    bool validate(QSharedPointer<ComponentInstance> instance) const;\r\n\r\n    /*!\r\n     *  Check if the name is valid.\r\n     *\r\n     *    @param [in] instance    The selected component instance.\r\n     *\r\n     *    @return True, if the name is valid, otherwise false.\r\n     */\r\n    bool hasValidName(QSharedPointer<ComponentInstance> instance) const;\r\n\r\n    /*!\r\n     *  Check if the isPresent is valid.\r\n     *\r\n     *    @param [in] instance    The selected component instance.\r\n     *\r\n     *    @return True, if the isPresent is valid, otherwise false.\r\n     */\r\n    bool hasValidIsPresent(QSharedPointer<ComponentInstance> instance) const;\r\n\r\n    /*!\r\n     *  Check if the component reference is valid.\r\n     *\r\n     *    @param [in] instance    The selected component instance.\r\n     *\r\n     *    @return True, if the component reference is valid, otherwise false.\r\n     */\r\n    bool hasValidComponentReference(QSharedPointer<ComponentInstance> instance) const;\r\n\r\n    /*!\r\n     *  Locate errors within a component instance.\r\n     *\r\n     *    @param [in] errors      List of found errors.\r\n     *    @param [in] instance    The selected component instance.\r\n     *    @param [in] context     Context to help locate the errors.\r\n     */\r\n    void findErrorsIn(QVector<QString>& errors, QSharedPointer<ComponentInstance> instance, QString const& context)\r\n        const;\r\n\r\nprivate:\r\n\r\n\t// Disable copying.\r\n\tComponentInstanceValidator(ComponentInstanceValidator const& rhs);\r\n\tComponentInstanceValidator& operator=(ComponentInstanceValidator const& rhs);\r\n\r\n    /*!\r\n     *  Find errors in name.\r\n     *\r\n     *    @param [in] errors      List of found errors.\r\n     *    @param [in] instance    The selected component instance.\r\n     *    @param [in] context     Context to help locate the errors.\r\n     */\r\n    void findErrorsInName(QVector<QString>& errors, QSharedPointer<ComponentInstance> instance,\r\n        QString const& context) const;\r\n\r\n    /*!\r\n     *  Find errors in isPresent.\r\n     *\r\n     *    @param [in] errors      List of found errors.\r\n     *    @param [in] instance    The selected component instance.\r\n     *    @param [in] context     Context to help locate the errors.\r\n     */\r\n    void findErrorsInIsPresent(QVector<QString>& errors, QSharedPointer<ComponentInstance> instance,\r\n        QString const& context) const;\r\n\r\n    /*!\r\n     *  Find errors in component reference.\r\n     *\r\n     *    @param [in] errors      List of found errors.\r\n     *    @param [in] instance    The selected component instance.\r\n     *    @param [in] context     Context to help locate the errors.\r\n     */\r\n    void findErrorsInComponentReference(QVector<QString>& errors, QSharedPointer<ComponentInstance> instance,\r\n        QString const& context) const;\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! The used expression parser.\r\n    QSharedPointer<ExpressionParser> parser_;\r\n\r\n    //! The used library interface.\r\n    LibraryInterface* libraryHandler_;\r\n};\r\n\r\n#endif // COMPONENTINSTANCEVALIDATOR_H\r\n"
  },
  {
    "path": "IPXACTmodels/Design/validator/DesignValidator.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: DesignValidator.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 14.01.2016\r\n//\r\n// Description:\r\n// Validator for the ipxact:design.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"DesignValidator.h\"\r\n\r\n#include <IPXACTmodels/Design/Design.h>\r\n#include <IPXACTmodels/Design/ComponentInstance.h>\r\n#include <IPXACTmodels/Design/AdHocConnection.h>\r\n\r\n#include <IPXACTmodels/Design/validator/ComponentInstanceValidator.h>\r\n#include <IPXACTmodels/Design/validator/InterconnectionValidator.h>\r\n#include <IPXACTmodels/Design/validator/AdHocConnectionValidator.h>\r\n\r\n#include <IPXACTmodels/common/Parameter.h>\r\n#include <IPXACTmodels/common/Assertion.h>\r\n\r\n#include <IPXACTmodels/common/validators/ParameterValidator.h>\r\n#include <IPXACTmodels/common/validators/AssertionValidator.h>\r\n\r\n#include <KactusAPI/include/ExpressionParser.h>\r\n\r\n#include <KactusAPI/include/LibraryInterface.h>\r\n\r\n#include <QRegularExpression>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignValidator::DesignValidator()\r\n//-----------------------------------------------------------------------------\r\nDesignValidator::DesignValidator(QSharedPointer<ExpressionParser> parser, LibraryInterface* library):\r\ncomponentInstanceValidator_(new ComponentInstanceValidator(parser, library)),\r\ninterconnectionValidator_(new InterconnectionValidator(parser, library)),\r\nadHocConnectionValidator_(new AdHocConnectionValidator(parser, library)),\r\nassertionValidator_(new AssertionValidator(parser)),\r\nexpressionParser_(parser)\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignValidator::~DesignValidator()\r\n//-----------------------------------------------------------------------------\r\nDesignValidator::~DesignValidator()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignValidator::validate()\r\n//-----------------------------------------------------------------------------\r\nbool DesignValidator::validate(QSharedPointer<Design> design) const\r\n{\r\n    return hasValidVLNV(design) && hasValidComponentInstances(design) && hasValidInterconnections(design) &&\r\n        hasValidMonitorInterconnections(design) && hasValidAdHocConnections(design) &&\r\n        hasValidParameters(design) && hasValidAssertions(design);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignValidator::hasValidVLNV()\r\n//-----------------------------------------------------------------------------\r\nbool DesignValidator::hasValidVLNV(QSharedPointer<Design> design) const\r\n{\r\n    return design->getVlnv().getType() == VLNV::DESIGN && design->getVlnv().isValid();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignValidator::hasValidComponentInstances()\r\n//-----------------------------------------------------------------------------\r\nbool DesignValidator::hasValidComponentInstances(QSharedPointer<Design> design) const\r\n{\r\n    if (design->getComponentInstances()->isEmpty())\r\n    {\r\n        return true;\r\n    }\r\n\r\n    QVector<QString> instanceNames;\r\n    for (QSharedPointer<ComponentInstance> instance : *design->getComponentInstances())\r\n    {\r\n        if (instanceNames.contains(instance->getInstanceName()) ||\r\n            !componentInstanceValidator_->validate(instance))\r\n        {\r\n            return false;\r\n        }\r\n\r\n        instanceNames.append(instance->getInstanceName());\r\n    }\r\n\r\n    return true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignValidator::hasValidInterconnections()\r\n//-----------------------------------------------------------------------------\r\nbool DesignValidator::hasValidInterconnections(QSharedPointer<Design> design) const\r\n{\r\n    if (design->getInterconnections()->isEmpty())\r\n    {\r\n        return true;\r\n    }\r\n\r\n    interconnectionValidator_->changeComponentInstances(design->getComponentInstances());\r\n    QVector<QString> connectionNames;\r\n\r\n    for (QSharedPointer<Interconnection> connection : *design->getInterconnections())\r\n    {\r\n        if (connectionNames.contains(connection->name()) ||\r\n            !interconnectionValidator_->validateInterconnection(connection))\r\n        {\r\n            return false;\r\n        }\r\n\r\n        connectionNames.append(connection->name());\r\n    }\r\n\r\n    return true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignValidator::hasValidMonitorInterconnections()\r\n//-----------------------------------------------------------------------------\r\nbool DesignValidator::hasValidMonitorInterconnections(QSharedPointer<Design> design) const\r\n{\r\n    if (design->getMonitorInterconnecions()->isEmpty())\r\n    {\r\n        return true;\r\n    }\r\n\r\n    interconnectionValidator_->changeComponentInstances(design->getComponentInstances());\r\n    QVector<QString> connectionNames;\r\n\r\n    for (QSharedPointer<MonitorInterconnection> connection : *design->getMonitorInterconnecions())\r\n    {\r\n        if (connectionNames.contains(connection->name()) ||\r\n            !interconnectionValidator_->validateMonitorInterconnection(connection))\r\n        {\r\n            return false;\r\n        }\r\n\r\n        connectionNames.append(connection->name());\r\n    }\r\n\r\n    return true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignValidator::hasValidAdHocConenctions()\r\n//-----------------------------------------------------------------------------\r\nbool DesignValidator::hasValidAdHocConnections(QSharedPointer<Design> design) const\r\n{\r\n    if (design->getAdHocConnections()->isEmpty())\r\n    {\r\n        return true;\r\n    }\r\n\r\n    adHocConnectionValidator_->changeComponentInstances(design->getComponentInstances());\r\n    QVector<QString> connectionNames;\r\n    for (QSharedPointer<AdHocConnection> connection: *design->getAdHocConnections())\r\n    {\r\n        if (connectionNames.contains(connection->name()) || !adHocConnectionValidator_->validate(connection))\r\n        {\r\n            return false;\r\n        }\r\n\r\n        connectionNames.append(connection->name());\r\n    }\r\n\r\n    return true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignValidator::hasValidParameters()\r\n//-----------------------------------------------------------------------------\r\nbool DesignValidator::hasValidParameters(QSharedPointer<Design> design) const\r\n{\r\n    if (design->getParameters()->isEmpty())\r\n    {\r\n        return true;\r\n    }\r\n\r\n    ParameterValidator parameterValidator(expressionParser_, QSharedPointer<QList<QSharedPointer<Choice> > >(), design->getRevision());\r\n\r\n    QVector<QString> parameterNames;\r\n    for (QSharedPointer<Parameter> parameter : *design->getParameters())\r\n    {\r\n        if (parameterNames.contains(parameter->name()) || !parameterValidator.validate(parameter))\r\n        {\r\n            return false;\r\n        }\r\n\r\n        parameterNames.append(parameter->name());\r\n    }\r\n\r\n    return true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignValidator::hasValidAssertions()\r\n//-----------------------------------------------------------------------------\r\nbool DesignValidator::hasValidAssertions(QSharedPointer<Design> design) const\r\n{\r\n    if (design->getAssertions()->isEmpty())\r\n    {\r\n        return true;\r\n    }\r\n\r\n    QVector<QString> assertionNames;\r\n    for (QSharedPointer<Assertion> assertion : *design->getAssertions())\r\n    {\r\n        if (assertionNames.contains(assertion->name()) || !assertionValidator_->validate(assertion))\r\n        {\r\n            return false;\r\n        }\r\n\r\n        assertionNames.append(assertion->name());\r\n    }\r\n\r\n    return true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignValidator::findErrorsIn()\r\n//-----------------------------------------------------------------------------\r\nvoid DesignValidator::findErrorsIn(QVector<QString>& errors, QSharedPointer<Design> design) const\r\n{\r\n    QString context = QObject::tr(\"design %1\").arg(design->getVlnv().toString());\r\n\r\n    findErrorsInVLNV(errors, design);\r\n    findErrorsInComponentInstances(errors, design, context);\r\n    findErrorsInInterconnections(errors, design, context);\r\n    findErrorsInMonitorInterconnections(errors, design, context);\r\n    findErrorsInAdHocConnections(errors, design, context);\r\n    findErrorsInParameters(errors, design, context);\r\n    findErrorsInAssertions(errors, design, context);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignValidator::findErrorsInVLNV()\r\n//-----------------------------------------------------------------------------\r\nvoid DesignValidator::findErrorsInVLNV(QVector<QString>& errors, QSharedPointer<Design> design) const\r\n{\r\n    design->getVlnv().isValid(errors, QLatin1String(\"design\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignValidator::findErrorsInComponentInstances()\r\n//-----------------------------------------------------------------------------\r\nvoid DesignValidator::findErrorsInComponentInstances(QVector<QString>& errors, QSharedPointer<Design> design,\r\n    QString const& context) const\r\n{\r\n    if (design->getComponentInstances()->isEmpty())\r\n    {\r\n        return;\r\n    }\r\n\r\n    QVector<QString> instanceNames;\r\n    QVector<QString> duplicateNames;\r\n    for (QSharedPointer<ComponentInstance> instance : *design->getComponentInstances())\r\n    {\r\n        if (instanceNames.contains(instance->getInstanceName()) &&\r\n            !duplicateNames.contains(instance->getInstanceName()))\r\n        {\r\n            errors.append(QObject::tr(\"Component instance name '%1' within %2 is not unique.\")\r\n                .arg(instance->getInstanceName(), context));\r\n            duplicateNames.append(instance->getInstanceName());\r\n        }\r\n\r\n        instanceNames.append(instance->getInstanceName());\r\n        componentInstanceValidator_->findErrorsIn(errors, instance, context);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignValidator::findErrorsInInterconnections()\r\n//-----------------------------------------------------------------------------\r\nvoid DesignValidator::findErrorsInInterconnections(QVector<QString>& errors, QSharedPointer<Design> design,\r\n    QString const& context) const\r\n{\r\n    if (design->getInterconnections()->isEmpty())\r\n    {\r\n        return;\r\n    }\r\n\r\n    interconnectionValidator_->changeComponentInstances(design->getComponentInstances());\r\n    QVector<QString> connectionNames;\r\n    QVector<QString> duplicateNames;\r\n    for (QSharedPointer<Interconnection> connection : *design->getInterconnections())\r\n    {\r\n        if (connectionNames.contains(connection->name()) && !duplicateNames.contains(connection->name()))\r\n        {\r\n            errors.append(QObject::tr(\"Interconnection name %1 within %2 is not unique\")\r\n                .arg(connection->name(), context));\r\n            duplicateNames.append(connection->name());\r\n        }\r\n\r\n        connectionNames.append(connection->name());\r\n        interconnectionValidator_->findErrorsInInterconnection(errors, connection, context);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignValidator::findErrorsInMonitorInterconnections()\r\n//-----------------------------------------------------------------------------\r\nvoid DesignValidator::findErrorsInMonitorInterconnections(QVector<QString>& errors, QSharedPointer<Design> design,\r\n    QString const& context) const\r\n{\r\n    if (design->getMonitorInterconnecions()->isEmpty())\r\n    {\r\n        return;\r\n    }\r\n\r\n    interconnectionValidator_->changeComponentInstances(design->getComponentInstances());\r\n    QVector<QString> connectionNames;\r\n    QVector<QString> duplicateNames;\r\n    for (QSharedPointer<MonitorInterconnection> connection: *design->getMonitorInterconnecions())\r\n    {\r\n        if (connectionNames.contains(connection->name()) && !duplicateNames.contains(connection->name()))\r\n        {\r\n            errors.append(QObject::tr(\"Monitor interconnection name %1 within %2 is not unique\")\r\n                .arg(connection->name(), context));\r\n            duplicateNames.append(connection->name());\r\n        }\r\n\r\n        connectionNames.append(connection->name());\r\n        interconnectionValidator_->findErrorsInMonitorInterconnection(errors, connection, context);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignValidator::findErrorsInAdHocConnections()\r\n//-----------------------------------------------------------------------------\r\nvoid DesignValidator::findErrorsInAdHocConnections(QVector<QString>& errors, QSharedPointer<Design> design,\r\n    QString const& context) const\r\n{\r\n    if (design->getAdHocConnections()->isEmpty())\r\n    {\r\n        return;\r\n    }\r\n\r\n    adHocConnectionValidator_->changeComponentInstances(design->getComponentInstances());\r\n    QVector<QString> connectionNames;\r\n    QVector<QString> duplicateNames;\r\n    for (QSharedPointer<AdHocConnection> connection: *design->getAdHocConnections())\r\n    {\r\n        if (connectionNames.contains(connection->name()) && !duplicateNames.contains(connection->name()))\r\n        {\r\n            errors.append(QObject::tr(\"Ad hoc connection name %1 within %2 is not unique\")\r\n                .arg(connection->name(), context));\r\n            duplicateNames.append(connection->name());\r\n        }\r\n\r\n        connectionNames.append(connection->name());\r\n        adHocConnectionValidator_->findErrorsIn(errors, connection, context);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignValidator::findErrorsInParameters()\r\n//-----------------------------------------------------------------------------\r\nvoid DesignValidator::findErrorsInParameters(QVector<QString>& errors, QSharedPointer<Design> design,\r\n    QString const& context) const\r\n{\r\n    if (design->getParameters()->isEmpty())\r\n    {\r\n        return;\r\n    }\r\n    ParameterValidator parameterValidator(expressionParser_, QSharedPointer<QList<QSharedPointer<Choice> > >(), design->getRevision());\r\n\r\n    QVector<QString> parameterNames;\r\n    QVector<QString> duplicateNames;\r\n    for (QSharedPointer<Parameter> parameter : *design->getParameters())\r\n    {\r\n        if (parameterNames.contains(parameter->name()) && !duplicateNames.contains(parameter->name()))\r\n        {\r\n            errors.append(QObject::tr(\"Parameter name %1 within %2 is not unique.\")\r\n                .arg(parameter->name(), context));\r\n            duplicateNames.append(parameter->name());\r\n        }\r\n\r\n        parameterNames.append(parameter->name());\r\n        parameterValidator.findErrorsIn(errors, parameter, context);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignValidator::findErrorsInAssertions()\r\n//-----------------------------------------------------------------------------\r\nvoid DesignValidator::findErrorsInAssertions(QVector<QString>& errors, QSharedPointer<Design> design,\r\n    QString const& context) const\r\n{\r\n    if (design->getAssertions()->isEmpty())\r\n    {\r\n        return;\r\n    }\r\n\r\n    QVector<QString> assertionNames;\r\n    QVector<QString> duplicateNames;\r\n    for (QSharedPointer<Assertion> assertion : *design->getAssertions())\r\n    {\r\n        if (assertionNames.contains(assertion->name()) && !duplicateNames.contains(assertion->name()))\r\n        {\r\n            errors.append(QObject::tr(\"Assertion name %1 within %2 is not unique.\")\r\n                .arg(assertion->name(), context));\r\n            duplicateNames.append(assertion->name());\r\n        }\r\n\r\n        assertionNames.append(assertion->name());\r\n        assertionValidator_->findErrorsIn(errors, assertion, context);\r\n    }\r\n}\r\n"
  },
  {
    "path": "IPXACTmodels/Design/validator/DesignValidator.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: DesignValidator.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 14.01.2016\r\n//\r\n// Description:\r\n// Validator for the ipxact:design.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef DESIGNVALIDATOR_H\r\n#define DESIGNVALIDATOR_H\r\n\r\n#include <IPXACTmodels/ipxactmodels_global.h>\r\n\r\n#include <QSharedPointer>\r\n#include <QString>\r\n#include <QVector>\r\n\r\nclass Design;\r\n\r\nclass LibraryInterface;\r\nclass ExpressionParser;\r\n\r\nclass ComponentInstanceValidator;\r\nclass InterconnectionValidator;\r\nclass AdHocConnectionValidator;\r\nclass ParameterValidator;\r\nclass AssertionValidator;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Validator for the ipxact:design.\r\n//-----------------------------------------------------------------------------\r\nclass IPXACTMODELS_EXPORT DesignValidator\r\n{\r\npublic:\r\n\r\n    /*!\r\n     *  The constructor.\r\n     *\r\n     *    @param [in] parser      The used expression parser.\r\n     *    @param [in] library     The used library interface.\r\n     */\r\n    DesignValidator(QSharedPointer<ExpressionParser> parser, LibraryInterface* library);\r\n\r\n\t//! The destructor.\r\n\tvirtual ~DesignValidator();\r\n    \r\n    /*!\r\n     *  Validates the given design.\r\n     *\r\n     *    @param [in] design  The selected design.\r\n     *\r\n     *    @return True, if the design is valid IP-XACT, otherwise false.\r\n     */\r\n    bool validate(QSharedPointer<Design> design) const;\r\n\r\n    /*!\r\n     *  Check if the design vlnv is valid.\r\n     *\r\n     *    @param [in] design  The selected design.\r\n     *\r\n     *    @return True, if the vlnv is valid, otherwise false.\r\n     */\r\n    bool hasValidVLNV(QSharedPointer<Design> design) const;\r\n\r\n    /*!\r\n     *  Check if the component instances are valid.\r\n     *\r\n     *    @param [in] design  The selected design.\r\n     *\r\n     *    @return True, if the component instances are valid, otherwise false.\r\n     */\r\n    bool hasValidComponentInstances(QSharedPointer<Design> design) const;\r\n\r\n    /*!\r\n     *  Check if the interconnections are valid.\r\n     *\r\n     *    @param [in] design  The selected design.\r\n     *\r\n     *    @return True, if the interconnections are valid, otherwise false.\r\n     */\r\n    bool hasValidInterconnections(QSharedPointer<Design> design) const;\r\n\r\n    /*!\r\n     *  Check if the monitor interconnections are valid.\r\n     *\r\n     *    @param [in] design  The selected design.\r\n     *\r\n     *    @return True, if the monitor interconnections are valid, otherwise false.\r\n     */\r\n    bool hasValidMonitorInterconnections(QSharedPointer<Design> design) const;\r\n\r\n    /*!\r\n     *  Check if the ad hoc connections are valid.\r\n     *\r\n     *    @param [in] design  The selected design.\r\n     *\r\n     *    @return True, if the ad hoc connections are valid, otherwise false.\r\n     */\r\n    bool hasValidAdHocConnections(QSharedPointer<Design> design) const;\r\n\r\n    /*!\r\n     *  Check if the parameters are valid.\r\n     *\r\n     *    @param [in] design  The selected design.\r\n     *\r\n     *    @return True, if the parameters are valid, otherwise false.\r\n     */\r\n    bool hasValidParameters(QSharedPointer<Design> design) const;\r\n\r\n    /*!\r\n     *  Check if the assertions are valid.\r\n     *\r\n     *    @param [in] design  The selected design.\r\n     *\r\n     *    @return True, if the assertions are valid, otherwise false.\r\n     */\r\n    bool hasValidAssertions(QSharedPointer<Design> design) const;\r\n\r\n    /*!\r\n     *  Locate errors within a design.\r\n     *\r\n     *    @param [in] errors  List of found errors.\r\n     *    @param [in] design  The selected design.\r\n     */\r\n    void findErrorsIn(QVector<QString>& errors, QSharedPointer<Design> design) const;\r\n\r\nprivate:\r\n\r\n\t// Disable copying.\r\n\tDesignValidator(DesignValidator const& rhs);\r\n\tDesignValidator& operator=(DesignValidator const& rhs);\r\n\r\n    /*!\r\n     *  Find errors in design VLNV.\r\n     *\r\n     *    @param [in] errors  List of found errors.\r\n     *    @param [in] design  The selected design.\r\n     */\r\n    void findErrorsInVLNV(QVector<QString>& errors, QSharedPointer<Design> design) const;\r\n\r\n    /*!\r\n     *  Find errors in component instances.\r\n     *\r\n     *    @param [in] errors      List of found errors.\r\n     *    @param [in] design      The selected design.\r\n     *    @param [in] context     Context to help locate the errors.\r\n     */\r\n    void findErrorsInComponentInstances(QVector<QString>& errors, QSharedPointer<Design> design,\r\n        QString const& context) const;\r\n\r\n    /*!\r\n     *  Find errors in interconnections.\r\n     *\r\n     *    @param [in] errors      List of found errors.\r\n     *    @param [in] design      The selected design.\r\n     *    @param [in] context     Context to help locate the errors.\r\n     */\r\n    void findErrorsInInterconnections(QVector<QString>& errors, QSharedPointer<Design> design,\r\n        QString const& context) const;\r\n\r\n    /*!\r\n     *  Find errors in monitor interconnections.\r\n     *\r\n     *    @param [in] errors      List of found errors.\r\n     *    @param [in] design      The selected design.\r\n     *    @param [in] context     Context to help locate the errors.\r\n     */\r\n    void findErrorsInMonitorInterconnections(QVector<QString>& errors, QSharedPointer<Design> design,\r\n        QString const& context) const;\r\n\r\n    /*!\r\n     *  Find errors in ad hoc connections.\r\n     *\r\n     *    @param [in] errors      List of found errors.\r\n     *    @param [in] design      The selected design.\r\n     *    @param [in] context     Context to help locate the errors.\r\n     */\r\n    void findErrorsInAdHocConnections(QVector<QString>& errors, QSharedPointer<Design> design,\r\n        QString const& context) const;\r\n\r\n    /*!\r\n     *  Find errors in parameters.\r\n     *\r\n     *    @param [in] errors      List of found errors.\r\n     *    @param [in] design      The selected design.\r\n     *    @param [in] context     Context to help locate the errors.\r\n     */\r\n    void findErrorsInParameters(QVector<QString>& errors, QSharedPointer<Design> design, QString const& context)\r\n        const;\r\n\r\n    /*!\r\n     *  Find errors in assertions.\r\n     *\r\n     *    @param [in] errors      List of found errors.\r\n     *    @param [in] design      The selected design.\r\n     *    @param [in] context     Context to help locate the errors.\r\n     */\r\n    void findErrorsInAssertions(QVector<QString>& errors, QSharedPointer<Design> design, QString const& context)\r\n        const;\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! The used component instance validator.\r\n    QSharedPointer<ComponentInstanceValidator> componentInstanceValidator_;\r\n\r\n    //! The used interconnection validator.\r\n    QSharedPointer<InterconnectionValidator> interconnectionValidator_;\r\n\r\n    //! The used ad hoc connection validator.\r\n    QSharedPointer<AdHocConnectionValidator> adHocConnectionValidator_;\r\n\r\n    //! The used assertion validator.\r\n    QSharedPointer<AssertionValidator> assertionValidator_;\r\n\r\n    //! The used expression parser\r\n    QSharedPointer<ExpressionParser> expressionParser_;\r\n};\r\n\r\n#endif // DESIGNVALIDATOR_H\r\n"
  },
  {
    "path": "IPXACTmodels/Design/validator/InterconnectionValidator.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: InterconnectionValidator.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 15.01.2016\r\n//\r\n// Description:\r\n// Validator for the ipxact:interconnection and ipxact:monitorInterconnection.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"InterconnectionValidator.h\"\r\n\r\n#include <IPXACTmodels/common/validators/CommonItemsValidator.h>\r\n\r\n#include <IPXACTmodels/Component/Component.h>\r\n#include <IPXACTmodels/Component/BusInterface.h>\r\n#include <IPXACTmodels/Component/PortMap.h>\r\n\r\n#include <IPXACTmodels/Design/Interconnection.h>\r\n#include <IPXACTmodels/Design/MonitorInterconnection.h>\r\n#include <IPXACTmodels/Design/ActiveInterface.h>\r\n#include <IPXACTmodels/Design/ComponentInstance.h>\r\n\r\n#include <KactusAPI/include/ExpressionParser.h>\r\n\r\n#include <KactusAPI/include/LibraryInterface.h>\r\n\r\n#include <QRegularExpression>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: InterconnectionValidator::InterconnectionValidator()\r\n//-----------------------------------------------------------------------------\r\nInterconnectionValidator::InterconnectionValidator(QSharedPointer<ExpressionParser> parser,\r\n    LibraryInterface* library):\r\nparser_(parser),\r\nlibraryHandler_(library)\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: InterconnectionValidator::~InterconnectionValidator()\r\n//-----------------------------------------------------------------------------\r\nInterconnectionValidator::~InterconnectionValidator()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: InterconnectionValidator::setComponentInstances()\r\n//-----------------------------------------------------------------------------\r\nvoid InterconnectionValidator::changeComponentInstances(\r\n    QSharedPointer<QList<QSharedPointer<ComponentInstance> > > newInstances)\r\n{\r\n    availableComponentInstances_ = newInstances;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: InterconnectionValidator::validateInterconnection()\r\n//-----------------------------------------------------------------------------\r\nbool InterconnectionValidator::validateInterconnection(QSharedPointer<Interconnection> interconnection) const\r\n{\r\n    return hasValidName(interconnection->name()) && hasValidIsPresent(interconnection->getIsPresent()) &&\r\n        hasValidStartInterface(interconnection) && hasValidInterfaces(interconnection);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: InterconnectionValidator::hasValidName()\r\n//-----------------------------------------------------------------------------\r\nbool InterconnectionValidator::hasValidName(QString const& name) const\r\n{\r\n    return CommonItemsValidator::hasValidName(name);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: InterconnectionValidator::hasValidIsPresent()\r\n//-----------------------------------------------------------------------------\r\nbool InterconnectionValidator::hasValidIsPresent(QString const& isPresent) const\r\n{\r\n    return CommonItemsValidator::hasValidIsPresent(isPresent, parser_);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: InterconnectionValidator::hasValidStartInterface()\r\n//-----------------------------------------------------------------------------\r\nbool InterconnectionValidator::hasValidStartInterface(QSharedPointer<Interconnection> interconnection) const\r\n{\r\n    if (interconnection->getStartInterface())\r\n    {\r\n        return activeInterfaceIsValid(interconnection->getStartInterface());\r\n    }\r\n\r\n    return false;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: InterconnectionValidator::activeInterfaceIsValid()\r\n//-----------------------------------------------------------------------------\r\nbool InterconnectionValidator::activeInterfaceIsValid(QSharedPointer<ActiveInterface> activeInterface) const\r\n{\r\n    QSharedPointer<ComponentInstance> referencedInstance =\r\n        getReferencedComponentInstance(activeInterface->getComponentReference());\r\n\r\n    if (referencedInstance)\r\n    {\r\n        QSharedPointer<const Component> referencedComponent = getReferencedComponent(referencedInstance);\r\n\r\n        if (referencedComponent)\r\n        {\r\n            return busReferenceIsValid(referencedComponent, activeInterface->getBusReference()) &&\r\n                hasValidIsPresent(activeInterface->getIsPresent()) &&\r\n                excludePortsAreValid(referencedComponent, activeInterface);\r\n        }\r\n    }\r\n\r\n    return false;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: InterconnectionValidator::getReferencedComponentInstance()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<ComponentInstance> InterconnectionValidator::getReferencedComponentInstance(\r\n    QString const& instanceReference) const\r\n{\r\n    QSharedPointer<ComponentInstance> foundInstance = nullptr;\r\n    if (instanceReference.isEmpty() || availableComponentInstances_->isEmpty())\r\n    {\r\n        return foundInstance;\r\n    }\r\n\r\n    auto it = std::find_if(availableComponentInstances_->cbegin(), availableComponentInstances_->cend(),\r\n        [&instanceReference](auto const& instance) {return instance->getInstanceName() == instanceReference; });\r\n\r\n    if (it != availableComponentInstances_->cend())\r\n    {\r\n        foundInstance = *it;\r\n    }\r\n\r\n    return foundInstance;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: InterconnectionValidator::getReferencedComponent()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<const Component> InterconnectionValidator::getReferencedComponent(\r\n    QSharedPointer<ComponentInstance> referencingInstance) const\r\n{\r\n    if (referencingInstance && referencingInstance->getComponentRef())\r\n    {\r\n        QSharedPointer<const Component> referencedComponent =\r\n            libraryHandler_->getModelReadOnly<Component>(*referencingInstance->getComponentRef());\r\n\r\n        return referencedComponent;\r\n    }\r\n\r\n    return QSharedPointer<const Component> ();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: InterconnectionValidator::busReferenecIsValid()\r\n//-----------------------------------------------------------------------------\r\nbool InterconnectionValidator::busReferenceIsValid(QSharedPointer<const Component> component,\r\n    QString const& busReference) const\r\n{\r\n    if (busReference.isEmpty() || component == nullptr)\r\n    {\r\n        return false;\r\n    }\r\n        \r\n    return std::any_of(component->getBusInterfaces()->cbegin(), component->getBusInterfaces()->cend(),\r\n        [&busReference](auto const& currentBus) { return currentBus->name() == busReference; });\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: InterconnectionValidator::excludePortsAreValid()\r\n//-----------------------------------------------------------------------------\r\nbool InterconnectionValidator::excludePortsAreValid(QSharedPointer<const Component> component,\r\n    QSharedPointer<ActiveInterface> activeInterface) const\r\n{\r\n    if (activeInterface->getExcludePorts()->isEmpty())\r\n    {\r\n        return true;\r\n    }\r\n\r\n    auto busInterface = component->getBusInterface(activeInterface->getBusReference());\r\n\r\n    if (busInterface == nullptr)\r\n    {\r\n        return false;\r\n    }\r\n\r\n    if (busInterface->getAbstractionTypes()->isEmpty())\r\n    {\r\n        return false;\r\n    }\r\n\r\n    auto portMaps = busInterface->getAllPortMaps();\r\n    return std::all_of(activeInterface->getExcludePorts()->cbegin(), activeInterface->getExcludePorts()->cend(),\r\n        [this, &portMaps](auto const& excludePort) { return singleExcludePortIsValid(excludePort, portMaps); });\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: InterconnectionValidator::singleExcludePortIsValid()\r\n//-----------------------------------------------------------------------------\r\nbool InterconnectionValidator::singleExcludePortIsValid(QString const& portReference,\r\n    QSharedPointer<QList<QSharedPointer<PortMap> > > portMaps) const\r\n{\r\n    return std::any_of(portMaps->cbegin(), portMaps->cend(),\r\n        [&portReference](auto const& portMap) { return portMap->getLogicalPort()->name_ == portReference; });\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: InterconnectionValidator::hasValidInterfaces()\r\n//-----------------------------------------------------------------------------\r\nbool InterconnectionValidator::hasValidInterfaces(QSharedPointer<Interconnection> interConnection) const\r\n{\r\n    if (!interConnection->getStartInterface() || (interConnection->getActiveInterfaces()->isEmpty() && \r\n        interConnection->getHierInterfaces()->isEmpty()))\r\n    {\r\n        return false;\r\n    }\r\n    else\r\n    {\r\n        QMap<QString, QString> interfaceReferences;\r\n\r\n        if (interConnection->getStartInterface())\r\n        {\r\n            interfaceReferences.insert(interConnection->getStartInterface()->getComponentReference(),\r\n                interConnection->getStartInterface()->getBusReference());\r\n        }\r\n\r\n        for (auto const& currentInterface: *interConnection->getActiveInterfaces())\r\n        {\r\n            if (!activeInterfaceIsValid(currentInterface) || !referenceCombinationIsUnique(interfaceReferences,\r\n                currentInterface->getComponentReference(), currentInterface->getBusReference()))\r\n            {\r\n                return false;\r\n            }\r\n            else\r\n            {\r\n                interfaceReferences.insert(currentInterface->getComponentReference(),\r\n                    currentInterface->getBusReference());\r\n            }\r\n        }\r\n\r\n        QVector<QString> usedHierBusInterfaces;\r\n        for (auto const& currentInterface : *interConnection->getHierInterfaces())\r\n        {\r\n            if (usedHierBusInterfaces.contains(currentInterface->getBusReference()) ||\r\n                !hasValidIsPresent(currentInterface->getIsPresent()))\r\n            {\r\n                return false;\r\n            }\r\n            else\r\n            {\r\n                usedHierBusInterfaces.append(currentInterface->getBusReference());\r\n            }\r\n        }\r\n\r\n        return true;\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: InterconnectionValidator::referenceCombinationIsUnique()\r\n//-----------------------------------------------------------------------------\r\nbool InterconnectionValidator::referenceCombinationIsUnique(QMap<QString, QString> referenceCombinations,\r\n    QString const& componentReference, QString const& busReference) const\r\n{\r\n    for (auto it = referenceCombinations.cbegin(); it != referenceCombinations.cend(); ++it)\r\n    {\r\n        if (it.key() == componentReference && it.value() == busReference)\r\n        {\r\n            return false;\r\n        }\r\n    }\r\n\r\n    return true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: InterconnectionValidator::validateMonitorInterconnection()\r\n//-----------------------------------------------------------------------------\r\nbool InterconnectionValidator::validateMonitorInterconnection(QSharedPointer<MonitorInterconnection> connection)\r\n    const\r\n{\r\n    return hasValidName(connection->name()) && hasValidIsPresent(connection->getIsPresent()) &&\r\n        hasValidMonitoredActiveInterface(connection) && hasValidMonitorInterfaces(connection);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: InterconnectionValidator::hasValidMonitoredActiveInterface()\r\n//-----------------------------------------------------------------------------\r\nbool InterconnectionValidator::hasValidMonitoredActiveInterface(QSharedPointer<MonitorInterconnection> connection)\r\n    const\r\n{\r\n    if (connection->getMonitoredActiveInterface())\r\n    {\r\n        return monitorInterfaceIsValid(connection->getMonitoredActiveInterface());\r\n    }\r\n\r\n    return false;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: InterconnectionValidator::monitorInterfaceIsValid()\r\n//-----------------------------------------------------------------------------\r\nbool InterconnectionValidator::monitorInterfaceIsValid(QSharedPointer<MonitorInterface> monitorInterface) const\r\n{\r\n    if (QSharedPointer<ComponentInstance> referencedInstance = getReferencedComponentInstance(\r\n            monitorInterface->getComponentReference()); \r\n        referencedInstance)\r\n    {\r\n        QSharedPointer<const Component> referencedComponent = getReferencedComponent(referencedInstance);\r\n\r\n        if (referencedComponent)\r\n        {\r\n            return busReferenceIsValid(referencedComponent, monitorInterface->getBusReference());\r\n        }\r\n    }\r\n\r\n    return false;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: InterconnectionValidator::hasValidMonitorInterfaces()\r\n//-----------------------------------------------------------------------------\r\nbool InterconnectionValidator::hasValidMonitorInterfaces(QSharedPointer<MonitorInterconnection> connection) const\r\n{\r\n    if (connection->getMonitorInterfaces()->isEmpty())\r\n    {\r\n        return false;\r\n    }\r\n\r\n    QMap<QString, QString> interfaceReferences;\r\n    if (connection->getMonitoredActiveInterface())\r\n    {\r\n        interfaceReferences.insert(connection->getMonitoredActiveInterface()->getComponentReference(),\r\n            connection->getMonitoredActiveInterface()->getBusReference());\r\n    }\r\n\r\n    for (auto const& monitorInterface : *connection->getMonitorInterfaces())\r\n    {\r\n        if (!monitorInterfaceIsValid(monitorInterface) ||\r\n            !referenceCombinationIsUnique(interfaceReferences, monitorInterface->getComponentReference(),\r\n                monitorInterface->getBusReference()))\r\n        {\r\n            return false;\r\n        }\r\n        else\r\n        {\r\n            interfaceReferences.insert(monitorInterface->getComponentReference(), monitorInterface->getBusReference());\r\n        }\r\n    }\r\n\r\n    return true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: InterconnectionValidator::findErrorsInInterconnection()\r\n//-----------------------------------------------------------------------------\r\nvoid InterconnectionValidator::findErrorsInInterconnection(QVector<QString>& errors,\r\n    QSharedPointer<Interconnection> interconnection, QString const& context) const\r\n{\r\n    QString interconnectionContext = QObject::tr(\"interconnection '%1'\").arg(interconnection->name());\r\n\r\n    findErrorsInName(errors, interconnection->name(), QLatin1String(\"interconnection\"), context);\r\n    findErrorsInIsPresent(errors, interconnection->getIsPresent(), interconnectionContext, context);\r\n    findErrorsInStartInterface(errors, interconnection, interconnectionContext, context);\r\n    findErrorsInInterfaces(errors, interconnection, interconnectionContext, context);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: InterconnectionValidator::findErrorsInName()\r\n//-----------------------------------------------------------------------------\r\nvoid InterconnectionValidator::findErrorsInName(QVector<QString>& errors, QString const& name,\r\n    QString const& element, QString const& context) const\r\n{\r\n    if (!hasValidName(name))\r\n    {\r\n        errors.append(QObject::tr(\"Invalid name '%1' set for %2 within %3\").arg(name, element, context));\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: InterconnectionValidator::findErrorsInIsPresent()\r\n//-----------------------------------------------------------------------------\r\nvoid InterconnectionValidator::findErrorsInIsPresent(QVector<QString>& errors, QString const& isPresent,\r\n    QString const& innerContext, QString const& context) const\r\n{\r\n    if (!hasValidIsPresent(isPresent))\r\n    {\r\n        errors.append(QObject::tr(\"Invalid isPresent set for %1 within %2\").arg(innerContext, context));\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: InterconnectionValidator::findErrorsInStartInterface()\r\n//-----------------------------------------------------------------------------\r\nvoid InterconnectionValidator::findErrorsInStartInterface(QVector<QString>& errors,\r\n    QSharedPointer<Interconnection> interconnection, QString const& innerContext, QString const& context) const\r\n{\r\n    if (interconnection->getStartInterface() && \r\n        (!interconnection->getStartInterface()->getComponentReference().isEmpty() ||\r\n        !interconnection->getStartInterface()->getBusReference().isEmpty()))\r\n    {\r\n        findErrorsInActiveInterface(errors, interconnection->getStartInterface(), innerContext, context);\r\n    }\r\n    else\r\n    {\r\n        errors.append(QObject::tr(\"No active interface set for %1 within %2\").arg(innerContext, context));\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: InterconnectionValidator::findErrorsInActiveInterface()\r\n//-----------------------------------------------------------------------------\r\nvoid InterconnectionValidator::findErrorsInActiveInterface(QVector<QString>& errors,\r\n    QSharedPointer<ActiveInterface> activeInterface, QString const& innerContext, QString const& context) const\r\n{\r\n    QString elementName = QStringLiteral(\"active interface\");\r\n\r\n    QSharedPointer<ComponentInstance> referencedInstance =\r\n        getReferencedComponentInstance(activeInterface->getComponentReference());\r\n\r\n    findErrorsInComponentReference(errors, activeInterface->getComponentReference(), referencedInstance,\r\n        elementName, innerContext, context);\r\n\r\n    QSharedPointer<const Component> referencedComponent = getReferencedComponent(referencedInstance);\r\n    findErrorsInBusReference(errors, activeInterface->getBusReference(), referencedComponent, elementName,\r\n        innerContext, context);\r\n\r\n    QString interfaceContext = QObject::tr(\"active interface\");\r\n\r\n    findErrorsInIsPresent(errors, activeInterface->getIsPresent(), interfaceContext, innerContext);\r\n    findErrorsInExcludePorts(errors, activeInterface, referencedComponent, innerContext);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: InterconnectionValidator::findErrorsInComponentReference()\r\n//-----------------------------------------------------------------------------\r\nvoid InterconnectionValidator::findErrorsInComponentReference(QVector<QString>& errors,\r\n    QString const& componentReference, QSharedPointer<ComponentInstance> referencedInstance,\r\n    QString const& elementName, QString const& innerContext, QString const& context) const\r\n{\r\n    if (componentReference.isEmpty())\r\n    {\r\n        errors.append(QObject::tr(\"No component reference set for %1 in %2 within %3\")\r\n            .arg(elementName, innerContext, context));\r\n    }\r\n\r\n    else if (!referencedInstance)\r\n    {\r\n        errors.append(QObject::tr(\"Component instance '%1' referenced by the %2 in %3 within %4 was \"\r\n            \"not found\")\r\n            .arg(componentReference, elementName, innerContext, context));\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: InterconnectionValidator::findErrorsInBusReference()\r\n//-----------------------------------------------------------------------------\r\nvoid InterconnectionValidator::findErrorsInBusReference(QVector<QString>& errors, QString const& busReference,\r\n    QSharedPointer<const Component> referencedComponent, QString const& elementName, QString const& innerContext,\r\n    QString const& context) const\r\n{\r\n    if (referencedComponent)\r\n    {\r\n        if (busReference.isEmpty())\r\n        {\r\n            errors.append(QObject::tr(\"No bus reference set for %1 in %2 within %3\")\r\n                .arg(elementName, innerContext, context));\r\n        }\r\n        else\r\n        {\r\n            if (!busReferenceIsValid(referencedComponent, busReference))\r\n            {\r\n                errors.append(QObject::tr(\"Bus interface '%1' referenced by the %2 in %3 within %4 was not found\")\r\n                    .arg(busReference, elementName, innerContext, context));\r\n            }\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: InterconnectionValidator::findErrorsInExcludePorts()\r\n//-----------------------------------------------------------------------------\r\nvoid InterconnectionValidator::findErrorsInExcludePorts(QVector<QString>& errors,\r\n    QSharedPointer<ActiveInterface> activeInterface, QSharedPointer<const Component> referencedComponent,\r\n    QString const& innerContext) const\r\n{\r\n    if (!activeInterface->getExcludePorts()->isEmpty())\r\n    {\r\n        auto busInterface = referencedComponent->getBusInterface(activeInterface->getBusReference());\r\n        if (busInterface == nullptr)\r\n        {\r\n            return;\r\n        }\r\n\r\n        auto portMaps = busInterface->getAllPortMaps();\r\n        for (QString const& excludePort : *activeInterface->getExcludePorts())\r\n        {\r\n            if (!singleExcludePortIsValid(excludePort, portMaps))\r\n            {\r\n                errors.append(QObject::tr(\"Logical port referenced in active interface in %1 was not \"\r\n                    \"found in the port maps of the referenced bus interface %2\")\r\n                    .arg(innerContext,busInterface->name()));\r\n            }\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: InterconnectionValidator::findErrorsInInterfaces()\r\n//-----------------------------------------------------------------------------\r\nvoid InterconnectionValidator::findErrorsInInterfaces(QVector<QString>& errors,\r\n    QSharedPointer<Interconnection> interConnection, QString const& innerContext, QString const& context) const\r\n{\r\n    if (!interConnection->getStartInterface() || (interConnection->getActiveInterfaces()->isEmpty() && \r\n        interConnection->getHierInterfaces()->isEmpty()))\r\n    {\r\n        errors.append(QObject::tr(\"No active interfaces or hierarchical interfaces set for %1 within %2\")\r\n            .arg(innerContext, context));        \r\n    }\r\n    else\r\n    {\r\n        QMap<QString, QString> interfaceReferences;\r\n\r\n        if (interConnection->getStartInterface())\r\n        {\r\n            interfaceReferences.insert(interConnection->getStartInterface()->getComponentReference(),\r\n                interConnection->getStartInterface()->getBusReference());\r\n        }\r\n\r\n        for (QSharedPointer<ActiveInterface> currentInterface : *interConnection->getActiveInterfaces())\r\n        {\r\n            if (!referenceCombinationIsUnique(interfaceReferences, currentInterface->getComponentReference(),\r\n                currentInterface->getBusReference()))\r\n            {\r\n                errors.append(QObject::tr(\"Component reference '%1' and bus reference '%2' pair is not unique in \"\r\n                    \"active interfaces of %3 within %4.\")\r\n                    .arg(currentInterface->getComponentReference(), currentInterface->getBusReference(),\r\n                        innerContext, context));\r\n            }\r\n            else\r\n            {\r\n                interfaceReferences.insert(currentInterface->getComponentReference(),\r\n                    currentInterface->getBusReference());\r\n            }\r\n\r\n            findErrorsInActiveInterface(errors, currentInterface, innerContext, context);\r\n        }\r\n\r\n        QVector<QString> usedHierBusReferences;\r\n        for (QSharedPointer<HierInterface> hierarchicalInterface : *interConnection->getHierInterfaces())\r\n        {\r\n            if (usedHierBusReferences.contains(hierarchicalInterface->getBusReference()))\r\n            {\r\n                errors.append(QObject::tr(\"Bus reference '%1' is not unique in hierarchical interfaces of %2 \"\r\n                    \"within %3.\")\r\n                    .arg(hierarchicalInterface->getBusReference(), innerContext, context));\r\n            }\r\n            else\r\n            {\r\n                usedHierBusReferences.append(hierarchicalInterface->getBusReference());\r\n            }\r\n\r\n            findErrorsInIsPresent(errors, hierarchicalInterface->getIsPresent(), innerContext, context);\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: InterconnectionValidator::findErrorsInMonitorInterconnection()\r\n//-----------------------------------------------------------------------------\r\nvoid InterconnectionValidator::findErrorsInMonitorInterconnection(QVector<QString>& errors,\r\n    QSharedPointer<MonitorInterconnection> connection, QString const& context) const\r\n{\r\n    QString monitorContext = QObject::tr(\"monitor interconnection '%1'\").arg(connection->name());\r\n\r\n    findErrorsInName(errors, connection->name(), QStringLiteral(\"monitor interconnection\"), context);\r\n    findErrorsInIsPresent(errors, connection->getIsPresent(), monitorContext, context);\r\n    findErrorsInMonitoredActiveInterface(errors, connection, monitorContext, context);\r\n    findErrorsInMonitorInterfaces(errors, connection, monitorContext, context);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: InterconnectionValidator::findErrorsInMonitoredActiveInterface()\r\n//-----------------------------------------------------------------------------\r\nvoid InterconnectionValidator::findErrorsInMonitoredActiveInterface(QVector<QString>& errors,\r\n    QSharedPointer<MonitorInterconnection> connection, QString const& innerContext, QString const& context) const\r\n{\r\n    QString elementName = QStringLiteral(\"monitored active interface\");\r\n\r\n    if (connection->getMonitoredActiveInterface() &&\r\n        (!connection->getMonitoredActiveInterface()->getComponentReference().isEmpty() ||\r\n        !connection->getMonitoredActiveInterface()->getBusReference().isEmpty()))\r\n    {\r\n        findErrorsInSingleMonitorInterface(errors, connection->getMonitoredActiveInterface(), elementName,\r\n            innerContext, context);\r\n    }\r\n    else\r\n    {\r\n        errors.append(QObject::tr(\"No %1 set for %2 within %3\").arg(elementName, innerContext, context));\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: InterconnectionValidator::findErrorsInMonitorInterface()\r\n//-----------------------------------------------------------------------------\r\nvoid InterconnectionValidator::findErrorsInSingleMonitorInterface(QVector<QString>& errors,\r\n    QSharedPointer<MonitorInterface> monitorInterface, QString const& elementName, QString const& innerContext,\r\n    QString const& context) const\r\n{\r\n    QSharedPointer<ComponentInstance> referencedInstance =\r\n        getReferencedComponentInstance(monitorInterface->getComponentReference());\r\n\r\n    findErrorsInComponentReference(errors, monitorInterface->getComponentReference(), referencedInstance,\r\n        elementName, innerContext, context);\r\n\r\n    QSharedPointer<const Component> referencedComponent = getReferencedComponent(referencedInstance);\r\n    findErrorsInBusReference(errors, monitorInterface->getBusReference(), referencedComponent, elementName,\r\n        innerContext, context);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: InterconnectionValidator::findErrorsInMonitorInterfaces()\r\n//-----------------------------------------------------------------------------\r\nvoid InterconnectionValidator::findErrorsInMonitorInterfaces(QVector<QString>& errors,\r\n    QSharedPointer<MonitorInterconnection> connection, QString const& innerContext, QString const& context) const\r\n{\r\n    if (!connection->getMonitorInterfaces()->isEmpty())\r\n    {\r\n        QMap<QString, QString> interfaceReferences;\r\n        if (connection->getMonitoredActiveInterface())\r\n        {\r\n            interfaceReferences.insert(connection->getMonitoredActiveInterface()->getComponentReference(),\r\n                connection->getMonitoredActiveInterface()->getBusReference());\r\n        }\r\n\r\n        QString elementName = QLatin1String(\"monitor interface\");\r\n        for (QSharedPointer<MonitorInterface> monitorInterface: *connection->getMonitorInterfaces())\r\n        {\r\n            if (!referenceCombinationIsUnique(interfaceReferences, monitorInterface->getComponentReference(),\r\n                monitorInterface->getBusReference()))\r\n            {\r\n                errors.append(QObject::tr(\"Component reference '%1' and bus reference '%2' pair is not unique in \"\r\n                    \"monitor interfaces of %3 within %4.\")\r\n                    .arg(monitorInterface->getComponentReference(), monitorInterface->getBusReference(),\r\n                    innerContext, context));\r\n            }\r\n            else\r\n            {\r\n                interfaceReferences.insert(monitorInterface->getComponentReference(),\r\n                    monitorInterface->getBusReference());\r\n            }\r\n\r\n            findErrorsInSingleMonitorInterface(errors, monitorInterface, elementName, innerContext, context);\r\n        }\r\n    }\r\n    else\r\n    {\r\n        errors.append(QObject::tr(\"No monitor interfaces set for %1 within %2\").arg(innerContext, context));\r\n    }\r\n}\r\n"
  },
  {
    "path": "IPXACTmodels/Design/validator/InterconnectionValidator.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: InterconnectionValidator.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 15.01.2016\r\n//\r\n// Description:\r\n// Validator for the ipxact:interconnection and ipxact:monitorInterconnection.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef INTERCONNETIONVALIDATOR_H\r\n#define INTERCONNETIONVALIDATOR_H\r\n\r\n#include <IPXACTmodels/ipxactmodels_global.h>\r\n\r\n#include <QSharedPointer>\r\n#include <QString>\r\n#include <QVector>\r\n\r\nclass Interconnection;\r\nclass MonitorInterconnection;\r\n\r\nclass LibraryInterface;\r\nclass ExpressionParser;\r\n\r\nclass ActiveInterface;\r\nclass MonitorInterface;\r\n\r\nclass Component;\r\nclass ComponentInstance;\r\nclass BusInterface;\r\nclass PortMap;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Validator for the ipxact:interconnection and ipxact:monitorInterconnection.\r\n//-----------------------------------------------------------------------------\r\nclass IPXACTMODELS_EXPORT InterconnectionValidator\r\n{\r\npublic:\r\n\r\n    /*!\r\n     *  The constructor.\r\n     *\r\n     *    @param [in] parser      The used expression parser.\r\n     *    @param [in] library     The used library interface.\r\n     */\r\n    InterconnectionValidator(QSharedPointer<ExpressionParser> parser, LibraryInterface* library);\r\n\r\n\t//! The destructor.\r\n\t~InterconnectionValidator();\r\n    \r\n    /*!\r\n     *  Change the available component instances.\r\n     *\r\n     *    @param [in] newInstances    The new component instances.\r\n     */\r\n    void changeComponentInstances(QSharedPointer<QList<QSharedPointer<ComponentInstance> > > newInstances);\r\n\r\n    /*!\r\n     *  Validates the given interconnection.\r\n     *\r\n     *    @param [in] interconnection     The selected interconnection.\r\n     *\r\n     *    @return True, if the interconnection is valid IP-XACT, otherwise false.\r\n     */\r\n    bool validateInterconnection(QSharedPointer<Interconnection> interconnection) const;\r\n\r\n    /*!\r\n     *  Check if the name is valid.\r\n     *\r\n     *    @param [in] name    The selected name.\r\n     *\r\n     *    @return True, if the name is valid, otherwise false.\r\n     */\r\n    bool hasValidName(QString const& name) const;\r\n\r\n    /*!\r\n     *  Check if the isPresent is valid.\r\n     *\r\n     *    @param [in] isPresent   The selected isPresent value.\r\n     *\r\n     *    @return True, if the isPresent is valid, otherwise false.\r\n     */\r\n    bool hasValidIsPresent(QString const& isPresent) const;\r\n\r\n    /*!\r\n     *  Check if the start interface is valid.\r\n     *\r\n     *    @param [in] interconnection     The selected interconnection.\r\n     *\r\n     *    @return True, if the start interface is valid, otherwise false.\r\n     */\r\n    bool hasValidStartInterface(QSharedPointer<Interconnection> interconnection) const;\r\n\r\n    /*!\r\n     *  Check if the interfaces are valid.\r\n     *\r\n     *    @param [in] interconnection     The selected interconnection.\r\n     *\r\n     *    @return True, if the interfaces are valid, otherwise false.\r\n     */\r\n    bool hasValidInterfaces(QSharedPointer<Interconnection> interConnection) const;\r\n\r\n    /*!\r\n     *  Validates the given monitor interconnection.\r\n     *\r\n     *    @param [in] connection  The selected monitor interconnection.\r\n     *\r\n     *    @return True, if the monitor interconnection is valid, otherwise false.\r\n     */\r\n    bool validateMonitorInterconnection(QSharedPointer<MonitorInterconnection> connection) const;\r\n\r\n    /*!\r\n     *  Check if the monitored active interface is valid.\r\n     *\r\n     *    @param [in] connection  The selected monitor interconnection.\r\n     *\r\n     *    @return True, if the monitored active interface is valid, otherwise false.\r\n     */\r\n    bool hasValidMonitoredActiveInterface(QSharedPointer<MonitorInterconnection> connection) const;\r\n\r\n    /*!\r\n     *  Check if the monitor interfaces are valid.\r\n     *\r\n     *    @param [in] connection  The selected monitor interconnection.\r\n     *\r\n     *    @return True, if the monitor interfaces are valid, otherwise false.\r\n     */\r\n    bool hasValidMonitorInterfaces(QSharedPointer<MonitorInterconnection> connection) const;\r\n\r\n    /*!\r\n     *  Locate errors within an interconnection.\r\n     *\r\n     *    @param [in] errors              List of found errors.\r\n     *    @param [in] interconnection     The selected interconnection.\r\n     *    @param [in] context             Context to help locate the errors.\r\n     */\r\n    void findErrorsInInterconnection(QVector<QString>& errors, QSharedPointer<Interconnection> interconnection,\r\n        QString const& context) const;\r\n\r\n    /*!\r\n     *  Locate errors within a monitor interconnection.\r\n     *\r\n     *    @param [in] errors      List of found errors.\r\n     *    @param [in] connection  The selected monitor interconnection.\r\n     *    @param [in] context     Context to help locate the errors.\r\n     */\r\n    void findErrorsInMonitorInterconnection(QVector<QString>& errors,\r\n        QSharedPointer<MonitorInterconnection> connection, QString const& context) const;\r\n\r\nprivate:\r\n\r\n\t// Disable copying.\r\n\tInterconnectionValidator(InterconnectionValidator const& rhs);\r\n\tInterconnectionValidator& operator=(InterconnectionValidator const& rhs);\r\n\r\n    /*!\r\n     *  Check if a reference combination of component and bus interface is valid.\r\n     *\r\n     *    @param [in] referenceCombinations   The used component / bus interface combinations.\r\n     *    @param [in] componentReference      The selected component reference.\r\n     *    @param [in] busReference            The selected bus reference.\r\n     *\r\n     *    @return True, if the component / bus interface reference pair is unique, otherwise false.\r\n     */\r\n    bool referenceCombinationIsUnique(QMap<QString, QString> referenceCombinations,\r\n        QString const& componentReference, QString const& busReference) const;\r\n\r\n    /*!\r\n     *  Check if an active interface is valid.\r\n     *\r\n     *    @param [in] activeInterface     The selected active interface.\r\n     *\r\n     *    @return True, if the active interface is valid, otherwise false.\r\n     */\r\n    bool activeInterfaceIsValid(QSharedPointer<ActiveInterface> activeInterface) const;\r\n\r\n    /*!\r\n     *  Get the reference component instance.\r\n     *\r\n     *    @param [in] instanceReference   The selected component instance reference.\r\n     *\r\n     *    @return The referenced component instance.\r\n     */\r\n    QSharedPointer<ComponentInstance> getReferencedComponentInstance(QString const& instanceReference) const;\r\n\r\n    /*!\r\n     *  Get the component referenced by the component instance.\r\n     *\r\n     *    @param [in] referencingInstance     The selected component instance.\r\n     *\r\n     *    @return The referenced component.\r\n     */\r\n    QSharedPointer<const Component> getReferencedComponent(QSharedPointer<ComponentInstance> referencingInstance) const;\r\n\r\n    /*!\r\n     *  Check if the bus interface reference is valid.\r\n     *\r\n     *    @param [in] component       The referenced component.\r\n     *    @param [in] busReference    The selected bus interface reference.\r\n     *\r\n     *    @return True, if the bus interface reference is valid, otherwise false.\r\n     */\r\n    bool busReferenceIsValid(QSharedPointer<const Component> component, QString const& busReference) const;\r\n\r\n    /*!\r\n     *  Check if the exclude ports of an active interface are valid.\r\n     *\r\n     *    @param [in] component           The referenced component.\r\n     *    @param [in] activeInterface     The selected active interface.\r\n     *\r\n     *    @return True, if the exclude ports are valid, otherwise false.\r\n     */\r\n    bool excludePortsAreValid(QSharedPointer<const Component> component,\r\n        QSharedPointer<ActiveInterface> activeInterface) const;\r\n\r\n    /*!\r\n     *  Check if a single exclude port is valid.\r\n     *\r\n     *    @param [in] portReference   The selected port reference.\r\n     *    @param [in] portMaps        The port maps to search the port for.\r\n     *\r\n     *    @return True, if the exclude port is valid, otherwise false.\r\n     */\r\n    bool singleExcludePortIsValid(QString const& portReference, \r\n        QSharedPointer<QList<QSharedPointer<PortMap> > > portMaps) const;\r\n\r\n    /*!\r\n     *  Check if a monitor interface is valid.\r\n     *\r\n     *    @param [in] monitorInterface    The selected monitor interface.\r\n     *\r\n     *    @return True, if the monitor interface is valid, otherwise false.\r\n     */\r\n    bool monitorInterfaceIsValid(QSharedPointer<MonitorInterface> monitorInterface) const;\r\n\r\n    /*!\r\n     *  Find errors in name.\r\n     *\r\n     *    @param [in] errors      List of found errors.\r\n     *    @param [in] name        The selected name.\r\n     *    @param [in] element     The name of the containing element.\r\n     *    @param [in] context     Context to help locate the errors.\r\n     */\r\n    void findErrorsInName(QVector<QString>& errors, QString const& name, QString const& element,\r\n        QString const& context) const;\r\n\r\n    /*!\r\n     *  Find errors in isPresent.\r\n     *\r\n     *    @param [in] errors          List of found errors.\r\n     *    @param [in] isPresent       The selected isPresent value.\r\n     *    @param [in] innerContext    The item context to help locate the errors.\r\n     *    @param [in] context         Context to help locate the errors.\r\n     */\r\n    void findErrorsInIsPresent(QVector<QString>& errors, QString const& isPresent, QString const& innerContext,\r\n        QString const& context) const;\r\n\r\n    /*!\r\n     *  Find errors in the interconnection start interface.\r\n     *\r\n     *    @param [in] errors              List of found errors.\r\n     *    @param [in] interconnection     The selected interconnection.\r\n     *    @param [in] innerContext        The item context to help locate the errors.\r\n     *    @param [in] context             Context to help locate the errors.\r\n     */\r\n    void findErrorsInStartInterface(QVector<QString>& errors, QSharedPointer<Interconnection> interconnection,\r\n        QString const& innerContext, QString const& context) const;\r\n\r\n    /*!\r\n     *  Find errors in an active interface.\r\n     *\r\n     *    @param [in] errors              List of found errors.\r\n     *    @param [in] activeInterface     The selected active interface.\r\n     *    @param [in] innerContext        The item context to help locate the errors.\r\n     *    @param [in] context             Context to help locate the errors.\r\n     */\r\n    void findErrorsInActiveInterface(QVector<QString>& errors, QSharedPointer<ActiveInterface> activeInterface,\r\n        QString const& innerContext, QString const& context) const;\r\n\r\n    /*!\r\n     *  Find errors in component reference.\r\n     *\r\n     *    @param [in] errors              List of found errors.\r\n     *    @param [in] componentReference  The selected component reference.\r\n     *    @param [in] referencedInstance  The referenced component instance.\r\n     *    @param [in] elementName         The name of the containing element.\r\n     *    @param [in] innerContext        The item context to help locate the errors.\r\n     *    @param [in] context             Context to help locate the errors.\r\n     */\r\n    void findErrorsInComponentReference(QVector<QString>& errors, QString const& componentReference,\r\n        QSharedPointer<ComponentInstance> referencedInstance, QString const& elementName,\r\n        QString const& innerContext, QString const& context) const;\r\n\r\n    /*!\r\n     *  Find errors in bus interface reference.\r\n     *\r\n     *    @param [in] errors                  List of found errors.\r\n     *    @param [in] busReference            The selected bus interface reference.\r\n     *    @param [in] referencedComponent     The referenced component.\r\n     *    @param [in] elementName             The containing element.\r\n     *    @param [in] innerContext            The item context to help locate the errors.\r\n     *    @param [in] context                 Context to help locate the errors.\r\n     */\r\n    void findErrorsInBusReference(QVector<QString>& errors, QString const& busReference,\r\n        QSharedPointer<const Component> referencedComponent, QString const& elementName, QString const& innerContext,\r\n        QString const& context) const;\r\n\r\n    /*!\r\n     *  Find errors in exclude ports.\r\n     *\r\n     *    @param [in] errors                  List of found errors.\r\n     *    @param [in] activeInterface         The selected active interface.\r\n     *    @param [in] referencedComponent     The referenced component\r\n     *    @param [in] innerContext            The item context to help locate the errors.\r\n     *    @param [in] context                 Context to help locate the errors.\r\n     */\r\n    void findErrorsInExcludePorts(QVector<QString>& errors, QSharedPointer<ActiveInterface> activeInterface,\r\n        QSharedPointer<const Component> referencedComponent, QString const& innerContext) const;\r\n\r\n    /*!\r\n     *  Find errors in interfaces.\r\n     *\r\n     *    @param [in] errors              List of found errors.\r\n     *    @param [in] interconnection     The selected interconnection.\r\n     *    @param [in] innerContext        The item context to help locate the errors.\r\n     *    @param [in] context             Context to help locate the errors.\r\n     */\r\n    void findErrorsInInterfaces(QVector<QString>& errors, QSharedPointer<Interconnection> interConnection,\r\n        QString const& innerContext, QString const& context) const;\r\n\r\n    /*!\r\n     *  Find errors in monitored active interface.\r\n     *\r\n     *    @param [in] errors          List of found errors.\r\n     *    @param [in] connection      The selected connection.\r\n     *    @param [in] innerContext    The item context to help locate the errors.\r\n     *    @param [in] context         Context to help locate the errors.\r\n     */\r\n    void findErrorsInMonitoredActiveInterface(QVector<QString>& errors,\r\n        QSharedPointer<MonitorInterconnection> connection, QString const& innerContext, QString const& context)\r\n        const;\r\n\r\n    /*!\r\n     *  Find errors in a monitor interface.\r\n     *\r\n     *    @param [in] errors              List of found errors.\r\n     *    @param [in] monitorInterface    The selected monitor interface.\r\n     *    @param [in] innerContext        The item context to help locate the errors.\r\n     *    @param [in] context             Context to help locate the errors.\r\n     */\r\n    void findErrorsInSingleMonitorInterface(QVector<QString>& errors,\r\n        QSharedPointer<MonitorInterface> monitorInterface, QString const& elementName, QString const& innerContext,\r\n        QString const& context) const;\r\n\r\n    /*!\r\n     *  Find errors in monitor interfaces.\r\n     *\r\n     *    @param [in] errors          List of found errors.\r\n     *    @param [in] connection      The selected monitor interconnection.\r\n     *    @param [in] innerContext    The item context to help locate the errors.\r\n     *    @param [in] context         Context to help locate the errors.\r\n     */\r\n    void findErrorsInMonitorInterfaces(QVector<QString>& errors, QSharedPointer<MonitorInterconnection> connection,\r\n        QString const& innerContext, QString const& context) const;\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! The used expression parser.\r\n    QSharedPointer<ExpressionParser> parser_;\r\n\r\n    //! The containing library.\r\n    LibraryInterface* libraryHandler_;\r\n\r\n    //! The currently available component instances.\r\n    QSharedPointer<QList<QSharedPointer<ComponentInstance> > > availableComponentInstances_ =\r\n        QSharedPointer<QList<QSharedPointer<ComponentInstance> > >(new QList<QSharedPointer<ComponentInstance> >());\r\n};\r\n\r\n#endif // INTERCONNETIONVALIDATOR_H\r\n"
  },
  {
    "path": "IPXACTmodels/DesignConfiguration/AbstractorInstance.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: AbstractorInstance.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 04.08.2015\r\n//\r\n// Description:\r\n// Matches the ipxact:abstractorInstance element.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"AbstractorInstance.h\"\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AbstractorInstance::AbstractorInstance()\r\n//-----------------------------------------------------------------------------\r\nAbstractorInstance::AbstractorInstance():\r\n    Extendable()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AbstractorInstance::AbstractorInstance()\r\n//-----------------------------------------------------------------------------\r\nAbstractorInstance::AbstractorInstance(const AbstractorInstance& other):\r\n    Extendable(other),\r\n    instanceName_(other.instanceName_),\r\n    displayName_(other.displayName_),\r\n    description_(other.description_),\r\n    abstractorRef_(new ConfigurableVLNVReference(*other.abstractorRef_)),\r\n    viewName_(other.viewName_)\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AbstractorInstance::getAbstractorRef()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<ConfigurableVLNVReference> AbstractorInstance::getAbstractorRef() const\r\n{\r\n    return abstractorRef_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AbstractorInstance::getShortDescription()\r\n//-----------------------------------------------------------------------------\r\nQString AbstractorInstance::getShortDescription() const\r\n{\r\n    return shortDescription_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AbstractorInstance::getDescription()\r\n//-----------------------------------------------------------------------------\r\nQString AbstractorInstance::getDescription() const\r\n{\r\n    return description_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AbstractorInstance::getDisplayName()\r\n//-----------------------------------------------------------------------------\r\nQString AbstractorInstance::getDisplayName() const\r\n{\r\n    return displayName_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AbstractorInstance::getInstanceName()\r\n//-----------------------------------------------------------------------------\r\nQString AbstractorInstance::getInstanceName() const\r\n{\r\n    return instanceName_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AbstractorInstance::getViewName()\r\n//-----------------------------------------------------------------------------\r\nQString AbstractorInstance::getViewName() const\r\n{\r\n    return viewName_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AbstractorInstance::setAbstractorRef()\r\n//-----------------------------------------------------------------------------\r\nvoid AbstractorInstance::setAbstractorRef(QSharedPointer<ConfigurableVLNVReference> abstractorRef)\r\n{\r\n    abstractorRef_ = abstractorRef;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AbstractorInstance::setShortDescription()\r\n//-----------------------------------------------------------------------------\r\nvoid AbstractorInstance::setShortDescription(const QString& shortDescription)\r\n{\r\n    shortDescription_ = shortDescription;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AbstractorInstance::setDescription()\r\n//-----------------------------------------------------------------------------\r\nvoid AbstractorInstance::setDescription(const QString& description)\r\n{\r\n    description_ = description;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AbstractorInstance::setDisplayName()\r\n//-----------------------------------------------------------------------------\r\nvoid AbstractorInstance::setDisplayName(const QString& displayName)\r\n{\r\n    displayName_ = displayName;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AbstractorInstance::setInstanceName()\r\n//-----------------------------------------------------------------------------\r\nvoid AbstractorInstance::setInstanceName(const QString& instanceName)\r\n{\r\n    instanceName_ = instanceName;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AbstractorInstance::setViewName()\r\n//-----------------------------------------------------------------------------\r\nvoid AbstractorInstance::setViewName(const QString& viewName)\r\n{\r\n    viewName_ = viewName;\r\n}"
  },
  {
    "path": "IPXACTmodels/DesignConfiguration/AbstractorInstance.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: AbstractorInstance.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 04.08.2015\r\n//\r\n// Description:\r\n// Matches the ipxact:abstractorInstance element.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef ABSTRACTORINSTANCE_H\r\n#define ABSTRACTORINSTANCE_H\r\n\r\n#include <IPXACTmodels/ipxactmodels_global.h>\r\n\r\n#include <IPXACTmodels/common/ConfigurableVLNVReference.h>\r\n#include <IPXACTmodels/common/Extendable.h>\r\n\r\n#include <QString>\r\n#include <QList>\r\n#include <QSharedPointer>\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Matches the ipxact:abstractorInstance element.\r\n//-----------------------------------------------------------------------------\r\nclass IPXACTMODELS_EXPORT AbstractorInstance : public Extendable\r\n{\r\npublic:\r\n\r\n    /*!\r\n     *  The constructor.\r\n     */\r\n    AbstractorInstance();\r\n\r\n    /*!\r\n     *  Copy constructor.\r\n     *\r\n     *    @param [in] other   Target to copy.\r\n     */\r\n    AbstractorInstance(const AbstractorInstance& other);\r\n\r\n    /*!\r\n     *  The destructor.\r\n     */\r\n    ~AbstractorInstance() final = default;\r\n\r\n    /*!\r\n     *  Get the VLNV reference to the abstractor.\r\n     *\r\n     *    @return The configurable VLNV of the abstractor.\r\n     */\r\n    QSharedPointer<ConfigurableVLNVReference> getAbstractorRef() const;\r\n\r\n    /*!\r\n     *  Get the description.\r\n     *\r\n     *    @return The description.\r\n     */\r\n    QString getShortDescription() const;\r\n\r\n    /*!\r\n\t *  Get the description.\r\n\t *\r\n     *    @return The description.\r\n\t */\r\n\tQString getDescription() const;\r\n\r\n    /*!\r\n\t *  Get the display name.\r\n\t *\r\n     *    @return The display name of the abstractor instance.\r\n\t */\r\n\tQString getDisplayName() const;\r\n\r\n    /*!\r\n\t *  Get the instance name.\r\n\t *\r\n     *    @return The name of this instance.\r\n\t */\r\n\tQString getInstanceName() const;\r\n\r\n    /*!\r\n\t *  Get the name of the view associated with this instance.\r\n\t *\r\n     *    @return The selected view name of the instance.\r\n\t */\r\n\tQString getViewName() const;\r\n\r\n    /*!\r\n     *  Set the abstractor reference.\r\n     *\r\n     *    @param [in] abstractorRef   A VLNV tag of the abstractor reference.\r\n     */\r\n    void setAbstractorRef(QSharedPointer<ConfigurableVLNVReference> abstractorRef);\r\n\r\n    /*!\r\n     *  Set the short description.\r\n     *\r\n     *    @param [in] shortDescription     The new short description.\r\n     */\r\n    void setShortDescription(const QString& shortDescription);\r\n\r\n    /*!\r\n\t *  Set the description.\r\n\t *\r\n\t *    @param [in] description     The new description.\r\n\t */\r\n\tvoid setDescription(const QString& description);\r\n\r\n    /*!\r\n\t *  Set the display name.\r\n\t *\r\n\t *    @param [in] displayName     The new display name.\r\n\t */\r\n\tvoid setDisplayName(const QString& displayName);\r\n\r\n    /*!\r\n\t *  Set the name for the instance.\r\n\t *\r\n\t *    @param [in] instanceName    The new instance name.\r\n\t */\r\n\tvoid setInstanceName(const QString& instanceName);\r\n\r\n    /*!\r\n\t *  Set the name of the selected view.\r\n\t *\r\n\t *    @param [in] viewName    The name of the selected view.\r\n\t */\r\n\tvoid setViewName(const QString& viewName);\r\n\r\nprivate:\r\n\r\n    //! The name of this instance.\r\n\tQString instanceName_;\r\n\r\n    //! Descriptive text of the instance.\r\n\tQString displayName_;\r\n\r\n    //! The short description of the instance.\r\n    QString shortDescription_;\r\n\r\n    //! Textual description of the instance.\r\n\tQString description_;\r\n\r\n    //! Configurable VLNV of the abstractor reference.\r\n    QSharedPointer<ConfigurableVLNVReference> abstractorRef_ =\r\n        QSharedPointer<ConfigurableVLNVReference>(new ConfigurableVLNVReference());\r\n\r\n    //! Defines the selected view.\r\n\tQString viewName_;\r\n};\r\n\r\n#endif // ABSTRACTORINSTANCE_H\r\n"
  },
  {
    "path": "IPXACTmodels/DesignConfiguration/DesignConfiguration.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: DesignConfiguration.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 03.08.2015\r\n//\r\n// Description:\r\n// Implementation for ipxact:designConfiguration element.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"DesignConfiguration.h\"\r\n\r\n#include <IPXACTmodels/common/GenericVendorExtension.h>\r\n#include <IPXACTmodels/kactusExtensions/KactusAttribute.h>\r\n#include <IPXACTmodels/kactusExtensions/Kactus2Group.h>\r\n#include <IPXACTmodels/kactusExtensions/Kactus2Placeholder.h>\r\n#include <IPXACTmodels/kactusExtensions/Kactus2Value.h>\r\n\r\n#include <IPXACTmodels/common/VLNV.h>\r\n\r\n#include <IPXACTmodels/utilities/Copy.h>\r\n\r\n#include <QList>\r\n#include <QDomNode>\r\n#include <QMap>\r\n#include <QString>\r\n#include <QSharedPointer>\r\n#include <QDomNamedNodeMap>\r\n#include <QObject>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignConfiguration::DesignConfiguration()\r\n//-----------------------------------------------------------------------------\r\nDesignConfiguration::DesignConfiguration(VLNV const& vlnv, Revision revision):\r\nDocument(vlnv, revision)\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignConfiguration::DesignConfiguration()\r\n//-----------------------------------------------------------------------------\r\nDesignConfiguration::DesignConfiguration(DesignConfiguration const& other):\r\nDocument(other),\r\ndesignRef_(other.designRef_)\r\n{\r\n    Copy::copyList(other.generatorChainConfigurations_, generatorChainConfigurations_);\r\n\r\n    Copy::copyList(other.interconnectionConfigurations_, interconnectionConfigurations_);\r\n\r\n    Copy::copyList(other.viewConfigurations_, viewConfigurations_);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignConfiguration::operator=()\r\n//-----------------------------------------------------------------------------\r\nDesignConfiguration& DesignConfiguration::operator=( const DesignConfiguration& other )\r\n{\r\n\tif (this != &other)\r\n    {\r\n\t\tDocument::operator=(other);\r\n\t\tdesignRef_ = other.designRef_;\r\n\r\n        generatorChainConfigurations_->clear();  \r\n        Copy::copyList(other.generatorChainConfigurations_, generatorChainConfigurations_);\r\n\r\n        interconnectionConfigurations_->clear();\r\n        Copy::copyList(other.interconnectionConfigurations_, interconnectionConfigurations_);\r\n       \r\n        viewConfigurations_->clear();\r\n        Copy::copyList(other.viewConfigurations_, viewConfigurations_);\r\n       \r\n\t}\r\n\treturn *this;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignConfiguration::clone()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<Document> DesignConfiguration::clone() const\r\n{\r\n\treturn QSharedPointer<Document>(new DesignConfiguration(*this));\t\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignConfiguration::setVlnv()\r\n//-----------------------------------------------------------------------------\r\nvoid DesignConfiguration::setVlnv(const VLNV& vlnv)\r\n{\r\n    VLNV designConfigurationVLNV(vlnv);\r\n    designConfigurationVLNV.setType(VLNV::DESIGNCONFIGURATION);\r\n    Document::setVlnv(vlnv);    \r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignConfiguration::setInterconnectionConfs()\r\n//-----------------------------------------------------------------------------\r\nvoid DesignConfiguration::setInterconnectionConfs(\r\n    QSharedPointer<QList<QSharedPointer<InterconnectionConfiguration> > > interconnectionConfs)\r\n{\r\n    interconnectionConfigurations_->clear();\r\n\r\n    interconnectionConfigurations_ = interconnectionConfs;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignConfiguration::setViewConfigurations()\r\n//-----------------------------------------------------------------------------\r\nvoid DesignConfiguration::setViewConfigurations(\r\n    QSharedPointer<QList<QSharedPointer<ViewConfiguration> > > newViewConfigurations)\r\n{\r\n    viewConfigurations_->clear();\r\n\r\n    viewConfigurations_ = newViewConfigurations;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignConfiguration::setDesignRef()\r\n//-----------------------------------------------------------------------------\r\nvoid DesignConfiguration::setDesignRef(const VLNV& designRef)\r\n{\r\n    designRef_ = designRef;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignConfiguration::getInterconnectionConfs()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<QList<QSharedPointer<InterconnectionConfiguration> > > DesignConfiguration::getInterconnectionConfs()\r\n{\r\n    return interconnectionConfigurations_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignConfiguration::getViewConfigurations()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<QList<QSharedPointer<ViewConfiguration> > > DesignConfiguration::getViewConfigurations()\r\n{\r\n    return viewConfigurations_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignConfiguration::setGeneratorChainConfs()\r\n//-----------------------------------------------------------------------------\r\nvoid DesignConfiguration::setGeneratorChainConfs(\r\n    QSharedPointer<QList<QSharedPointer<ConfigurableVLNVReference> > > generatorChainConfs)\r\n{\r\n    generatorChainConfigurations_->clear();\r\n\r\n    generatorChainConfigurations_ = generatorChainConfs;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignConfiguration::getDesignRef()\r\n//-----------------------------------------------------------------------------\r\nVLNV DesignConfiguration::getDesignRef() const\r\n{\r\n    return designRef_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignConfiguration::getGeneratorChainConfs()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<QList<QSharedPointer<ConfigurableVLNVReference> > > DesignConfiguration::getGeneratorChainConfs()\r\n{\r\n    return generatorChainConfigurations_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignConfiguration::getDependentFiles()\r\n//-----------------------------------------------------------------------------\r\nQStringList DesignConfiguration::getDependentFiles() const\r\n{\r\n    return QStringList();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignConfiguration::getDependentVLNVs()\r\n//-----------------------------------------------------------------------------\r\nQList<VLNV> DesignConfiguration::getDependentVLNVs() const\r\n{\r\n\tQList<VLNV> vlnvList;\r\n\r\n\t// Append the vlnv of the design that is associated with this designConfiguration.\r\n\tif (designRef_.isValid())\r\n    {\r\n\t\tvlnvList.append(designRef_);\r\n\t}\r\n\r\n\t// Append all vlnvs representing generator chains associated with this design configuration.\r\n    for (auto const& generatorChainConfiguration : *generatorChainConfigurations_)\r\n    {\r\n        if (generatorChainConfiguration->isValid())\r\n        {\r\n            VLNV generatorChainVLNV = *generatorChainConfiguration;\r\n            vlnvList.append(generatorChainVLNV);\r\n\t\t}\r\n\t}\r\n\r\n\t// Append all vlnvs referencing the abstractors that this designConfiguration depends on.\r\n    for (auto const& interconnectionConfiguration : *interconnectionConfigurations_)\r\n    {\r\n        vlnvList.append(interconnectionConfiguration->getDependantVLNVs());\r\n\t}\r\n\r\n\treturn vlnvList;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignConfiguration::addViewConfiguration()\r\n//-----------------------------------------------------------------------------\r\nvoid DesignConfiguration::addViewConfiguration(QString const& instanceName, QString const& viewName)\r\n{\r\n\tif (!viewName.isEmpty())\r\n    {\r\n        QSharedPointer<ViewConfiguration> newViewConfig (new ViewConfiguration(instanceName));\r\n        newViewConfig->setViewReference(viewName);\r\n\r\n        viewConfigurations_->append(newViewConfig);\r\n\t}\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignConfiguration::removeViewConfiguration()\r\n//-----------------------------------------------------------------------------\r\nvoid DesignConfiguration::removeViewConfiguration(QString const& instanceName)\r\n{\r\n    viewConfigurations_->removeAll(getViewConfiguration(instanceName));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignConfiguration::getViewConfiguration()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<ViewConfiguration> DesignConfiguration::getViewConfiguration(QString const& instanceName) const\r\n{\r\n    QSharedPointer<ViewConfiguration> configuration = nullptr;\r\n\r\n    auto it = std::find_if(viewConfigurations_->cbegin(), viewConfigurations_->cend(),\r\n        [instanceName](auto const& viewConfiguration) {return viewConfiguration->getInstanceName() == instanceName; });\r\n\r\n    if (it != viewConfigurations_->cend())\r\n    {\r\n        configuration = *it;\r\n    }\r\n\r\n    return configuration;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignConfiguration::getActiveView()\r\n//-----------------------------------------------------------------------------\r\nQString DesignConfiguration::getActiveView(QString const& instanceName) const\r\n{\r\n    if (auto configuration = getViewConfiguration(instanceName); \r\n        configuration)\r\n    {\r\n        return configuration->getViewReference();\r\n    }\r\n\r\n    return QString();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignConfiguration::hasActiveView()\r\n//-----------------------------------------------------------------------------\r\nbool DesignConfiguration::hasActiveView(QString const& instanceName) const\r\n{\r\n\treturn !getActiveView(instanceName).isEmpty();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignConfiguration::setDesignConfigImplementation()\r\n//-----------------------------------------------------------------------------\r\nvoid DesignConfiguration::setDesignConfigImplementation(KactusAttribute::Implementation implementation)\r\n{\r\n    setImplementation(implementation);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignConfiguration::getDesignConfigImplementation()\r\n//-----------------------------------------------------------------------------\r\nKactusAttribute::Implementation DesignConfiguration::getDesignConfigImplementation() const\r\n{\r\n    return getImplementation();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: designconfiguration::getKactsu2ViewOverrides()\r\n//-----------------------------------------------------------------------------\r\nQMap<QString, QString> DesignConfiguration::getKactus2ViewOverrides() const\r\n{\r\n    QSharedPointer<Kactus2Group> overrideGroup =\r\n        findVendorExtension(QStringLiteral(\"kactus2:viewOverrides\")).dynamicCast<Kactus2Group>();\r\n\r\n    QMap <QString, QString> viewOverrides;\r\n\r\n    if (overrideGroup)\r\n    {\r\n        auto overrideIndentifier = QStringLiteral(\"kactus2:instanceView\");\r\n        for (QSharedPointer<VendorExtension> extension : \r\n            overrideGroup->getByType(overrideIndentifier))\r\n        {\r\n            QSharedPointer<Kactus2Placeholder> viewExtension = extension.dynamicCast<Kactus2Placeholder>();\r\n\r\n            if (viewExtension)\r\n            {\r\n                QString viewOverrideId = viewExtension->getAttributeValue(QStringLiteral(\"id\"));\r\n                QString viewOverrideValue = viewExtension->getAttributeValue(QStringLiteral(\"viewName\"));\r\n\r\n                viewOverrides.insert(viewOverrideId, viewOverrideValue);\r\n            }\r\n        }\r\n    }\r\n\r\n    return viewOverrides;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: designconfiguration::setKactus2ViewOverrides()\r\n//-----------------------------------------------------------------------------\r\nvoid DesignConfiguration::setKactus2ViewOverrides(QMap<QString, QString> kactus2ViewOverrides)\r\n{\r\n    auto extension = findVendorExtension(QLatin1String(\"kactus2:viewOverrides\"));\r\n\r\n    getVendorExtensions()->removeAll(extension);\r\n\r\n    if (!kactus2ViewOverrides.isEmpty())\r\n    {\r\n        QSharedPointer<Kactus2Group> overrideGroup (new Kactus2Group(QStringLiteral(\"kactus2:viewOverrides\")));\r\n\r\n        for (auto const& id : kactus2ViewOverrides.keys())\r\n        {\r\n            QSharedPointer<Kactus2Placeholder> treeItemExtension(\r\n                new Kactus2Placeholder(QStringLiteral(\"kactus2:instanceView\")));\r\n            treeItemExtension->setAttribute(QStringLiteral(\"id\"), id);\r\n            treeItemExtension->setAttribute(QStringLiteral(\"viewName\"), kactus2ViewOverrides.value(id));\r\n\r\n            overrideGroup->addToGroup(treeItemExtension);\r\n        }\r\n\r\n        getVendorExtensions()->append(overrideGroup);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignConfiguration::findOrCreateInstanceExtension()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<VendorExtension> DesignConfiguration::findOrCreateInstanceExtension(QString const& instanceUUID)\r\n{\r\n    QSharedPointer<Kactus2Group> cevGroup =\r\n        findVendorExtension(QLatin1String(\"kactus2:configurableElementValues\")).dynamicCast<Kactus2Group>();\r\n\r\n    if (cevGroup == nullptr)\r\n    {\r\n        cevGroup = QSharedPointer<Kactus2Group>(new Kactus2Group(QStringLiteral(\"kactus2:configurableElementValues\")));\r\n        getVendorExtensions()->append(cevGroup);\r\n    }\r\n\r\n    QSharedPointer<Kactus2Group> targetInstanceGroup;\r\n    auto instanceIdentifier = QStringLiteral(\"kactus2:componentInstance\");\r\n    for  (QSharedPointer<VendorExtension> instanceNode : cevGroup->getByType(instanceIdentifier))\r\n    {\r\n        QSharedPointer<Kactus2Group> instanceGroup = instanceNode.dynamicCast<Kactus2Group>();\r\n        QString groupUUID;\r\n        QList<QSharedPointer<VendorExtension> > uuidValues = instanceGroup->getByType(QStringLiteral(\"kactus2:uuid\"));\r\n        if (!uuidValues.isEmpty())\r\n        {\r\n            groupUUID = uuidValues.first().dynamicCast<Kactus2Value>()->value();\r\n        }\r\n\r\n        if (groupUUID == instanceUUID)\r\n        {\r\n            targetInstanceGroup  = instanceNode.dynamicCast<Kactus2Group>();\r\n            break;\r\n        }\r\n    }\r\n\r\n    if (targetInstanceGroup.isNull())\r\n    {\r\n        targetInstanceGroup = QSharedPointer<Kactus2Group>(new Kactus2Group(QStringLiteral(\"kactus2:componentInstance\")));\r\n        targetInstanceGroup->addToGroup(QSharedPointer<Kactus2Value>(\r\n            new Kactus2Value(QStringLiteral(\"kactus2:uuid\"), instanceUUID)));\r\n        cevGroup->addToGroup(targetInstanceGroup);\r\n    }\r\n\r\n    return targetInstanceGroup;\r\n}\r\n"
  },
  {
    "path": "IPXACTmodels/DesignConfiguration/DesignConfiguration.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: DesignConfiguration.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 03.08.2015\r\n//\r\n// Description:\r\n// Implementation for ipxact:designConfiguration element.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef DESIGNCONFIGURATION_H\r\n#define DESIGNCONFIGURATION_H\r\n\r\n#include <IPXACTmodels/common/Assertion.h>\r\n#include <IPXACTmodels/common/ConfigurableVLNVReference.h>\r\n#include <IPXACTmodels/common/Document.h>\r\n\r\n#include <IPXACTmodels/DesignConfiguration/InterconnectionConfiguration.h>\r\n#include <IPXACTmodels/DesignConfiguration/ViewConfiguration.h>\r\n\r\n#include <IPXACTmodels/ipxactmodels_global.h>\r\n\r\n#include <QSharedPointer>\r\n#include <QList>\r\n#include <QString>\r\n#include <QMap>\r\n#include <QDomDocument>\r\n#include <QDomNode>\r\n#include <QStringList>\r\n#include <QFile>\r\n#include <QMap>\r\n\r\nclass VLNV;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Implementation for the ipxact:designConfiguration element.\r\n//-----------------------------------------------------------------------------\r\nclass IPXACTMODELS_EXPORT DesignConfiguration : public Document\r\n{\r\n\r\npublic:\r\n\r\n    /*!\r\n\t *  The constructor.\r\n\t *\r\n\t *    @param [in] vlnv    VLNV to be set for the design configuration.\r\n\t */\r\n\tDesignConfiguration(VLNV const& vlnv, Revision revision);\r\n\r\n    /*!\r\n\t *  Copy constructor.\r\n\t */\r\n\tDesignConfiguration(const DesignConfiguration& other);\r\n\r\n    /*!\r\n\t *  Assignment operator.\r\n\t */\r\n\tDesignConfiguration& operator=(const DesignConfiguration& other);\r\n\r\n    /*!\r\n\t *  The destructor.\r\n\t */\r\n\t~DesignConfiguration() final = default;\r\n\r\n    /*!\r\n\t *  Clone this design configuration.\r\n\t */\r\n\tQSharedPointer<Document> clone() const final;\r\n\r\n    /*!\r\n\t *  Set the vlnv.\r\n\t *\r\n\t *    @param [in] vlnv    Reference to the vlnv to be set.\r\n\t */\r\n\tvoid setVlnv(const VLNV& vlnv) final;\r\n\r\n    /*!\r\n     *  Get the design reference.\r\n     *\r\n     *    @return VLNV element representing the design.\r\n     */\r\n    VLNV getDesignRef() const;\r\n\r\n    /*!\r\n     *  Get the list of generator chain configurations.\r\n     *\r\n     *    @return The list containing pointers to the generator chain configurations.\r\n     */\r\n    QSharedPointer<QList<QSharedPointer<ConfigurableVLNVReference> > > getGeneratorChainConfs();\r\n\r\n    /*!\r\n     *  Get the list of interconnection configurations.\r\n     *\r\n     *    @return A list containing pointers to the interconnection configurations.\r\n     */\r\n    QSharedPointer<QList<QSharedPointer<InterconnectionConfiguration> > > getInterconnectionConfs();\r\n\r\n    /*!\r\n     *  Get the list of view configurations.\r\n     *\r\n     *    @return A list containing pointers to the view configurations.\r\n     */\r\n    QSharedPointer<QList<QSharedPointer<ViewConfiguration> > > getViewConfigurations();\r\n\r\n    /*!\r\n     *  Set the design reference.\r\n     *\r\n     *    @param [in] designRef   A VLNV tag that identifies the design.\r\n     */\r\n    void setDesignRef(const VLNV& designRef);\r\n\r\n    /*!\r\n     *  Set the generator chain configurations.\r\n     *\r\n     *    @param [in] generatorChainConfs     A list containing pointers to the generator chain configurations.\r\n     */\r\n    void setGeneratorChainConfs(\r\n        QSharedPointer<QList<QSharedPointer<ConfigurableVLNVReference> > > generatorChainConfs);\r\n\r\n    /*!\r\n     *  Set the interconnection configurations.\r\n     *\r\n     *    @param [in] interconnectionConfs    A list containing pointers to the interconnection configurations.\r\n     */\r\n    void setInterconnectionConfs(\r\n        QSharedPointer<QList<QSharedPointer<InterconnectionConfiguration> > > interconnectionConfs);\r\n\r\n    /*!\r\n     *  Set the view configurations.\r\n     *\r\n     *    @param [in] newViewConfigurations   A list containing pointers to the view configurations.\r\n     */\r\n    void setViewConfigurations(QSharedPointer<QList<QSharedPointer<ViewConfiguration> > > newViewConfigurations);\r\n\r\n    /*!\r\n     *  Get the list of the files needed by this design configuration.\r\n     *\r\n     *    @return Empty QStringlist (contains VLNV dependencies).\r\n     */\r\n    virtual QStringList getDependentFiles() const;\r\n\r\n    /*!\r\n     *  Get the list of VLNVs needed by this design configuration.\r\n     *\r\n     *    @return A list of pointers to VLNVs that are needed in this design configuration.\r\n     */\r\n    virtual QList<VLNV> getDependentVLNVs() const;\r\n\r\n    /*!\r\n\t *  Add a new view configuration to the design configuration.\r\n\t *\r\n\t *    @param [in] instanceName    The name of the component instance that's view is set.\r\n\t *    @param [in] viewName        The name of the component's view that is set as active.\r\n\t */\r\n\tvirtual void addViewConfiguration(QString const& instanceName, QString const& viewName);\r\n\r\n    /*!\r\n\t *  Remove the view configuration.\r\n\t *\r\n\t *    @param [in] instanceName    The instance name of the view configuration to be removed.\r\n\t */\r\n\tvirtual void removeViewConfiguration(QString const& instanceName);\r\n\r\n    /*!\r\n\t *  Get the active view configuration for the given component instance.\r\n\t *\r\n\t *    @param [in] instanceName   Identifies the component instance.\r\n     *\r\n     *    @return The active view configuration.\r\n\t */\r\n\tQSharedPointer<ViewConfiguration> getViewConfiguration(QString const& instanceName) const;\r\n\r\n    /*!\r\n\t *  Get the active view name for the given component instance.\r\n\t *\r\n\t *    @param [in] instanceName   Identifies the component instance.\r\n     *\r\n     *    @return The name of the active view.\r\n\t */\r\n\tQString getActiveView(QString const& instanceName) const;\r\n\r\n    /*!\r\n\t *  Check if an active view has been defined for the given instance.\r\n\t *\r\n\t *    @param [in] instanceName    The name of the component instance that's active view is searched for.\r\n     *\r\n     *    @return True if an active view is found, false otherwise.\r\n\t */\r\n\tbool hasActiveView(QString const& instanceName) const;\r\n\r\n    /*!\r\n\t *  Set the implementation type of the design configuration.\r\n\t *\r\n\t *    @param [in] implementation  The implementation type.\r\n\t */\r\n\tvoid setDesignConfigImplementation(KactusAttribute::Implementation implementation);\r\n\r\n\t/*!\r\n\t *  Get the implementation type.\r\n\t *\r\n     *    @return The implementation type.\r\n\t */\r\n\tKactusAttribute::Implementation getDesignConfigImplementation() const;\r\n    \r\n    /*!\r\n     *  Finds and creates instance extensions.\r\n     *\r\n     *    @param [in] instanceUUID    The id of the instance whose extension is being searched.\r\n     *\r\n     *    @return The instance extension.\r\n     */\r\n    QSharedPointer<VendorExtension> findOrCreateInstanceExtension(QString const& instanceUUID);\r\n\r\n    /*!\r\n     *  Gets the override view configuration.\r\n     *\r\n     *    @return Pairs of instance id and their overridden views.\r\n     */\r\n    QMap<QString, QString> getKactus2ViewOverrides() const;\r\n\r\n    /*!\r\n     *  Sets the override view configuration.\r\n     *\r\n     *    @param [in] kactus2ViewOverrides    The new view overrides.\r\n     */\r\n    void setKactus2ViewOverrides(QMap<QString, QString> kactus2ViewOverrides);\r\n\r\nprivate:\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! The design.\r\n    VLNV designRef_;\r\n\r\n    //! A list containing pointers to the generator chain configurations.\r\n    QSharedPointer<QList<QSharedPointer<ConfigurableVLNVReference> > > generatorChainConfigurations_ =\r\n        QSharedPointer<QList<QSharedPointer<ConfigurableVLNVReference> > >(new QList<QSharedPointer<ConfigurableVLNVReference> >);\r\n\r\n    //! A list containing pointers to the interconnection configurations.\r\n    QSharedPointer<QList<QSharedPointer<InterconnectionConfiguration> > > interconnectionConfigurations_ =\r\n        QSharedPointer<QList<QSharedPointer<InterconnectionConfiguration> > >(new QList<QSharedPointer<InterconnectionConfiguration> >);\r\n\r\n    //! A list containing pointers to the view configurations.\r\n    QSharedPointer<QList<QSharedPointer<ViewConfiguration> > > viewConfigurations_ =\r\n        QSharedPointer<QList<QSharedPointer<ViewConfiguration> > >(new QList<QSharedPointer<ViewConfiguration> >);\r\n\r\n};\r\n\r\n#endif // DESIGNCONFIGURATION_H\r\n"
  },
  {
    "path": "IPXACTmodels/DesignConfiguration/DesignConfigurationReader.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: DesignConfigurationReader.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 11.08.2015\r\n//\r\n// Description:\r\n// XML reader class for IP-XACT design configuration element.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"DesignConfigurationReader.h\"\r\n\r\n#include <IPXACTmodels/common/DocumentReader.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignConfigurationReader::createDesignConfigurationFrom()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<DesignConfiguration> DesignConfigurationReader::createDesignConfigurationFrom(\r\n    QDomDocument const& document)\r\n{\r\n    QDomNode designConfigurationNode = document.firstChildElement();\r\n\r\n    VLNV vlnv = CommonItemsReader::createVLNVFrom(designConfigurationNode, VLNV::DESIGNCONFIGURATION);\r\n    Document::Revision docRevision = DocumentReader::getXMLDocumentRevision(designConfigurationNode);\r\n\r\n    QSharedPointer<DesignConfiguration> newDesignConfiguration (new DesignConfiguration(vlnv, docRevision));\r\n\r\n    DocumentReader::parseTopComments(document, newDesignConfiguration);\r\n\r\n    DocumentReader::parseXMLProcessingInstructions(document, newDesignConfiguration);\r\n\r\n    DocumentReader::parseNamespaceDeclarations(designConfigurationNode, newDesignConfiguration);\r\n\r\n    DocumentReader::parseDocumentNameGroup(designConfigurationNode, newDesignConfiguration);\r\n\r\n    Details::parseDesignReference(designConfigurationNode, newDesignConfiguration);\r\n\r\n    Details::parseGeneratorChainConfigurations(document, newDesignConfiguration);\r\n\r\n    Details::parseInterconnectionConfigurations(document, newDesignConfiguration);\r\n\r\n    Details::parseViewConfigurations(document, newDesignConfiguration);\r\n\r\n    DocumentReader::parseParameters(designConfigurationNode, newDesignConfiguration);\r\n\r\n    DocumentReader::parseAssertions(designConfigurationNode, newDesignConfiguration);\r\n\r\n    Details::parseDesignConfigurationExtensions(designConfigurationNode, newDesignConfiguration);\r\n\r\n    return newDesignConfiguration;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignConfigurationReader::parseDesignReference()\r\n//-----------------------------------------------------------------------------\r\nvoid DesignConfigurationReader::Details::parseDesignReference(QDomNode const& designConfigurationNode,\r\n    QSharedPointer<DesignConfiguration> newDesignConfiguration)\r\n{\r\n    QDomNode designReferenceNode = designConfigurationNode.firstChildElement(QStringLiteral(\"ipxact:designRef\"));\r\n\r\n    QDomNamedNodeMap attributeMap = designReferenceNode.attributes();\r\n\r\n    QString vendor = attributeMap.namedItem(QStringLiteral(\"vendor\")).nodeValue();\r\n    QString library = attributeMap.namedItem(QStringLiteral(\"library\")).nodeValue();\r\n    QString name = attributeMap.namedItem(QStringLiteral(\"name\")).nodeValue();\r\n    QString version = attributeMap.namedItem(QStringLiteral(\"version\")).nodeValue();\r\n\r\n    VLNV designReferenceVLNV(VLNV::DESIGN, vendor, library, name, version);\r\n    newDesignConfiguration->setDesignRef(designReferenceVLNV);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignConfigurationReader::parseGeneratorChainConfigurations()\r\n//-----------------------------------------------------------------------------\r\nvoid DesignConfigurationReader::Details::parseGeneratorChainConfigurations(QDomDocument const& designConfigurationDocument,\r\n    QSharedPointer<DesignConfiguration> newDesignConfiguration)\r\n{\r\n    QDomNodeList chainConfigurationElements =\r\n        designConfigurationDocument.elementsByTagName(QStringLiteral(\"ipxact:generatorChainConfiguration\"));\r\n\r\n    for (int i = 0; i < chainConfigurationElements.size(); ++i)\r\n    {\r\n        parseSingleGeneratorChainConfiguration(chainConfigurationElements.at(i), newDesignConfiguration);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignConfigurationReader::parseSingleGeneratorChainConfiguration()\r\n//-----------------------------------------------------------------------------\r\nvoid DesignConfigurationReader::Details::parseSingleGeneratorChainConfiguration(QDomNode const& chainConfigurationNode,\r\n    QSharedPointer<DesignConfiguration> newDesignConfiguration)\r\n{\r\n    QSharedPointer<ConfigurableVLNVReference> newChainConfiguration = \r\n        CommonItemsReader::parseConfigurableVLNVReference(chainConfigurationNode, VLNV::GENERATORCHAIN);\r\n\r\n    newDesignConfiguration->getGeneratorChainConfs()->append(newChainConfiguration);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignConfigurationReader::parseInterconnectionConfigurations()\r\n//-----------------------------------------------------------------------------\r\nvoid DesignConfigurationReader::Details::parseInterconnectionConfigurations(QDomDocument const& designConfigurationDocument,\r\n    QSharedPointer<DesignConfiguration> newDesignConfiguration)\r\n{\r\n    QDomNodeList interconnectionElements =\r\n        designConfigurationDocument.elementsByTagName(QStringLiteral(\"ipxact:interconnectionConfiguration\"));\r\n\r\n    auto docRevision = newDesignConfiguration->getRevision();\r\n\r\n    for (int interconConfIndex = 0; interconConfIndex < interconnectionElements.size(); ++interconConfIndex)\r\n    {\r\n        QDomNode interconnectionConfigurationNode = interconnectionElements.at(interconConfIndex);\r\n\r\n        QSharedPointer<InterconnectionConfiguration> newInterconnectionConfiguration (\r\n            new InterconnectionConfiguration());\r\n\r\n        if (docRevision == Document::Revision::Std14)\r\n        {\r\n            newInterconnectionConfiguration->setIsPresent(\r\n                interconnectionConfigurationNode.firstChildElement(QStringLiteral(\"ipxact:isPresent\")).firstChild().nodeValue());\r\n        }\r\n\r\n        newInterconnectionConfiguration->setInterconnectionReference(interconnectionConfigurationNode.\r\n            firstChildElement(QStringLiteral(\"ipxact:interconnectionRef\")).firstChild().nodeValue());\r\n\r\n        parseMultipleAbstractors(interconnectionConfigurationNode, newInterconnectionConfiguration, docRevision);\r\n        \r\n        if (docRevision == Document::Revision::Std22)\r\n        {\r\n            CommonItemsReader::parseVendorExtensions(interconnectionConfigurationNode, newInterconnectionConfiguration);\r\n        }\r\n\r\n        newDesignConfiguration->getInterconnectionConfs()->append(newInterconnectionConfiguration);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignConfigurationReader::parseMultipleAbstractors()\r\n//-----------------------------------------------------------------------------\r\nvoid DesignConfigurationReader::Details::parseMultipleAbstractors(QDomNode const& interconnectionConfigurationNode,\r\n    QSharedPointer<InterconnectionConfiguration> newInterconnectionConfiguration, \r\n    Document::Revision docRevision)\r\n{\r\n    QDomNodeList multipleAbstractorsNodes =\r\n        getNamedChildNodes(interconnectionConfigurationNode, QStringLiteral(\"ipxact:abstractorInstances\"));\r\n\r\n    for (int multipleAbstractorsIndex = 0; multipleAbstractorsIndex < multipleAbstractorsNodes.size();\r\n        ++multipleAbstractorsIndex)\r\n    {\r\n        QDomNode multipleAbstractorNode = multipleAbstractorsNodes.at(multipleAbstractorsIndex);\r\n\r\n        QSharedPointer<MultipleAbstractorInstances> newMultipleAbstractors (new MultipleAbstractorInstances());\r\n\r\n        if (docRevision == Document::Revision::Std14)\r\n        {\r\n            newMultipleAbstractors->setIsPresent(\r\n                multipleAbstractorNode.firstChildElement(QStringLiteral(\"ipxact:isPresent\")).firstChild().nodeValue());\r\n        }\r\n\r\n        parseInterfaceReferences(multipleAbstractorNode, newMultipleAbstractors, docRevision);\r\n\r\n        parseAbstractorInstances(multipleAbstractorNode, newMultipleAbstractors, docRevision);\r\n\r\n        newInterconnectionConfiguration->getAbstractorInstances()->append(newMultipleAbstractors);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignConfigurationReader::parseMultipleAbstractors()\r\n//-----------------------------------------------------------------------------\r\nvoid DesignConfigurationReader::Details::parseInterfaceReferences(QDomNode const& multipleAbstractorsNode,\r\n    QSharedPointer<MultipleAbstractorInstances> newMultipleAbstractorInstances, Document::Revision docRevision)\r\n{\r\n    QDomNodeList interfaceRefNodes = getNamedChildNodes(multipleAbstractorsNode, QStringLiteral(\"ipxact:interfaceRef\"));\r\n\r\n    for (int interfaceRefIndex = 0; interfaceRefIndex < interfaceRefNodes.size(); ++interfaceRefIndex)\r\n    {\r\n        QDomNode singleInterfaceRefNode = interfaceRefNodes.at(interfaceRefIndex);\r\n\r\n        QDomNamedNodeMap attributeMap = singleInterfaceRefNode.attributes();\r\n\r\n        QSharedPointer<InterfaceRef> newInterfaceRef (new InterfaceRef());\r\n\r\n        newInterfaceRef->setComponentRef(attributeMap.namedItem(QStringLiteral(\"componentRef\")).nodeValue());\r\n        newInterfaceRef->setBusRef(attributeMap.namedItem(QStringLiteral(\"busRef\")).nodeValue());\r\n        \r\n        if (docRevision == Document::Revision::Std14)\r\n        {\r\n            newInterfaceRef->setIsPresent(\r\n                singleInterfaceRefNode.firstChildElement(QStringLiteral(\"ipxact:isPresent\")).firstChild().nodeValue());\r\n        }\r\n\r\n        if (docRevision == Document::Revision::Std22)\r\n        {\r\n            CommonItemsReader::parseVendorExtensions(singleInterfaceRefNode, newInterfaceRef);\r\n        }\r\n\r\n        newMultipleAbstractorInstances->getInterfaceReferences()->append(newInterfaceRef);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignConfigurationReader::parseAbstractorInstances()\r\n//-----------------------------------------------------------------------------\r\nvoid DesignConfigurationReader::Details::parseAbstractorInstances(QDomNode const& multipleAbstractorsNode,\r\n    QSharedPointer<MultipleAbstractorInstances> newMultipleAbstractorInstances, Document::Revision docRevision)\r\n{\r\n    QDomNodeList abstractorInstanceNodes = getNamedChildNodes(multipleAbstractorsNode, QStringLiteral(\"ipxact:abstractorInstance\"));\r\n\r\n    for (int i = 0; i < abstractorInstanceNodes.size(); ++i)\r\n    {\r\n        QDomNode singleAbstractorInstanceNode = abstractorInstanceNodes.at(i);\r\n\r\n        QSharedPointer<AbstractorInstance> newAbstractorInstance (new AbstractorInstance());\r\n\r\n        newAbstractorInstance->setInstanceName(\r\n            singleAbstractorInstanceNode.firstChildElement(QStringLiteral(\"ipxact:instanceName\")).firstChild().nodeValue());\r\n        newAbstractorInstance->setDisplayName(\r\n            singleAbstractorInstanceNode.firstChildElement(QStringLiteral(\"ipxact:displayName\")).firstChild().nodeValue());\r\n\r\n        if (docRevision == Document::Revision::Std22)\r\n        {\r\n            newAbstractorInstance->setShortDescription(\r\n                singleAbstractorInstanceNode.firstChildElement(QStringLiteral(\"ipxact:shortDescription\")).firstChild().nodeValue());\r\n        }\r\n\r\n        newAbstractorInstance->setDescription(\r\n            singleAbstractorInstanceNode.firstChildElement(QStringLiteral(\"ipxact:description\")).firstChild().nodeValue());\r\n        newAbstractorInstance->setViewName(\r\n            singleAbstractorInstanceNode.firstChildElement(QStringLiteral(\"ipxact:viewName\")).firstChild().nodeValue());\r\n\r\n        QDomNode abstractorReferenceNode\r\n            = singleAbstractorInstanceNode.firstChildElement(QStringLiteral(\"ipxact:abstractorRef\"));\r\n\r\n        QSharedPointer<ConfigurableVLNVReference> newAbstractorRef = \r\n            CommonItemsReader::parseConfigurableVLNVReference(abstractorReferenceNode, VLNV::ABSTRACTOR);\r\n\r\n        if (docRevision == Document::Revision::Std22)\r\n        {\r\n            CommonItemsReader::parseVendorExtensions(singleAbstractorInstanceNode, newAbstractorInstance);\r\n        }\r\n\r\n        newAbstractorInstance->setAbstractorRef(newAbstractorRef);\r\n\r\n        newMultipleAbstractorInstances->getAbstractorInstances()->append(newAbstractorInstance);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignConfigurationReader::getNamedChildNodes()\r\n//-----------------------------------------------------------------------------\r\nQDomNodeList DesignConfigurationReader::Details::getNamedChildNodes(QDomNode const& targetNode, QString elementName)\r\n{\r\n    QDomNodeList allChildNodes = targetNode.childNodes();\r\n\r\n    QDomDocument targetDocument(QStringLiteral(\"temporaryDoc\"));\r\n\r\n    for (int i = 0; i < allChildNodes.size(); ++i)\r\n    {\r\n        QDomNode possibleNode = allChildNodes.at(i);\r\n        if (possibleNode.nodeName() == elementName)\r\n        {\r\n            targetDocument.appendChild(possibleNode);\r\n        }\r\n    }\r\n\r\n    return targetDocument.childNodes();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignConfigurationReader::parseViewConfigurations()\r\n//-----------------------------------------------------------------------------\r\nvoid DesignConfigurationReader::Details::parseViewConfigurations(QDomDocument const& designConfigurationDocument,\r\n    QSharedPointer<DesignConfiguration> newDesignConfiguration)\r\n{\r\n    QDomNodeList viewConfigurationNodes = designConfigurationDocument.elementsByTagName(QStringLiteral(\"ipxact:viewConfiguration\"));\r\n\r\n    auto docRevision = newDesignConfiguration->getRevision();\r\n\r\n    for (int i = 0; i < viewConfigurationNodes.size(); ++i)\r\n    {\r\n        QDomNode singleViewConfigurationNode = viewConfigurationNodes.at(i);\r\n\r\n        QSharedPointer<ViewConfiguration> newViewConfiguration (new ViewConfiguration());\r\n\r\n        newViewConfiguration->setInstanceName(\r\n            singleViewConfigurationNode.firstChildElement(QStringLiteral(\"ipxact:instanceName\")).firstChild().nodeValue());\r\n\r\n        if (docRevision == Document::Revision::Std14)\r\n        {\r\n            newViewConfiguration->setIsPresent(\r\n                singleViewConfigurationNode.firstChildElement(QStringLiteral(\"ipxact:isPresent\")).firstChild().nodeValue());\r\n        }\r\n\r\n        QDomNode viewNode = singleViewConfigurationNode.firstChildElement(QStringLiteral(\"ipxact:view\"));\r\n        \r\n        QDomNamedNodeMap attributeMap = viewNode.attributes();\r\n\r\n        newViewConfiguration->setViewReference(attributeMap.namedItem(QStringLiteral(\"viewRef\")).nodeValue());\r\n\r\n        QDomNode multipleConfigurableElementsNode = viewNode.firstChildElement(QStringLiteral(\"ipxact:configurableElementValues\"));\r\n\r\n        QDomNodeList configurableElementNodes = multipleConfigurableElementsNode.childNodes();\r\n\r\n        for (int j = 0; j < configurableElementNodes.size(); ++j)\r\n        {\r\n            QSharedPointer<ConfigurableElementValue> newConfigurableElementValue =\r\n                CommonItemsReader::parseConfigurableElementValue(configurableElementNodes.at(j));\r\n\r\n            newViewConfiguration->getViewConfigurableElements()->append(newConfigurableElementValue);\r\n        }\r\n\r\n        if (docRevision == Document::Revision::Std22)\r\n        {\r\n            CommonItemsReader::parseVendorExtensions(singleViewConfigurationNode, newViewConfiguration);\r\n        }\r\n\r\n        newDesignConfiguration->getViewConfigurations()->append(newViewConfiguration);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignConfigurationReader::parseDesignConfigurationExtensions()\r\n//-----------------------------------------------------------------------------\r\nvoid DesignConfigurationReader::Details::parseDesignConfigurationExtensions(QDomNode const& designConfigurationNode,\r\n    QSharedPointer<DesignConfiguration> newDesignConfiguration)\r\n{\r\n    QDomNode extensionsNode = designConfigurationNode.firstChildElement(QStringLiteral(\"ipxact:vendorExtensions\"));\r\n\r\n    QDomElement viewOverridesNode = extensionsNode.firstChildElement(QStringLiteral(\"kactus2:viewOverrides\"));\r\n    if (!viewOverridesNode.isNull())\r\n    {\r\n        parseViewOverrides(viewOverridesNode, newDesignConfiguration);\r\n    }\r\n\r\n    DocumentReader::parseKactusAndVendorExtensions(designConfigurationNode, newDesignConfiguration);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignConfigurationReader::parseViewOverrides()\r\n//-----------------------------------------------------------------------------\r\nvoid DesignConfigurationReader::Details::parseViewOverrides(QDomElement const& viewOverridesNode,\r\n    QSharedPointer<DesignConfiguration> newDesignConfiguration)\r\n{\r\n    QMap<QString, QString> newViewOverrides;\r\n\r\n    QDomNodeList viewOverrideList = viewOverridesNode.elementsByTagName(QStringLiteral(\"kactus2:instanceView\"));\r\n    for (int overrideIndex = 0; overrideIndex < viewOverrideList.count(); ++overrideIndex)\r\n    {\r\n        QDomNode viewOverride = viewOverrideList.at(overrideIndex);\r\n\r\n        QDomNamedNodeMap overrideAttributes = viewOverride.attributes();\r\n        QString instanceID = overrideAttributes.namedItem(QStringLiteral(\"id\")).nodeValue();\r\n        QString viewName = overrideAttributes.namedItem(QStringLiteral(\"viewName\")).nodeValue();\r\n\r\n        newViewOverrides.insert(instanceID, viewName);\r\n    }\r\n\r\n    newDesignConfiguration->setKactus2ViewOverrides(newViewOverrides);\r\n}\r\n"
  },
  {
    "path": "IPXACTmodels/DesignConfiguration/DesignConfigurationReader.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: DesignConfigurationReader.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 11.08.2015\r\n//\r\n// Description:\r\n// XML reader class for IP-XACT design configuration element.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef DESIGNCONFIGURATIONREADER_H\r\n#define DESIGNCONFIGURATIONREADER_H\r\n\r\n#include \"DesignConfiguration.h\"\r\n\r\n#include <QDomNode>\r\n#include <QDomNodeList>\r\n\r\n//-----------------------------------------------------------------------------\r\n//! XML reader class for IP-XACT design configuration element.\r\n//-----------------------------------------------------------------------------\r\nnamespace DesignConfigurationReader\r\n{\r\n    /*!\r\n     *  Creates a design configuration from XML definition.\r\n     *\r\n     *    @param [in] document    The XML document to create the design configuration from.\r\n     *\r\n     *    @return The created design configuration.\r\n     */\r\n    IPXACTMODELS_EXPORT QSharedPointer<DesignConfiguration> createDesignConfigurationFrom(QDomDocument const& document);\r\n\r\n    namespace Details\r\n    {\r\n\r\n        /*!\r\n         *  Reads the design reference property from XML to a design configuration.\r\n         *\r\n         *    @param [in] designConfigurationNode     The XML description of the design configuration.\r\n         *    @param [in] newDesignConfiguration      The item where to insert the design reference.\r\n         */\r\n        void parseDesignReference(QDomNode const& designConfigurationNode,\r\n            QSharedPointer<DesignConfiguration> newDesignConfiguration);\r\n\r\n        /*!\r\n         *  Reads the generator chain configurations from XML to a design configuration.\r\n         *\r\n         *    @param [in] designConfigurationDocument     The XML description of the design configuration.\r\n         *    @param [in] newDesignConfiguration          The item where to insert the chain configurations.\r\n         */\r\n        void parseGeneratorChainConfigurations(QDomDocument const& designConfigurationDocument,\r\n            QSharedPointer<DesignConfiguration> newDesignConfiguration);\r\n\r\n        /*!\r\n         *  Reads a single generator chain configurations from XML.\r\n         *\r\n         *    @param [in] chainConfigurationNode      The XML description of a generator chain configuration.\r\n         *    @param [in] newDesignConfiguration      The item where to insert the chain configuration.\r\n         */\r\n        void parseSingleGeneratorChainConfiguration(QDomNode const& chainConfigurationNode,\r\n            QSharedPointer<DesignConfiguration> newDesignConfiguration);\r\n\r\n        /*!\r\n         *  Reads interconnection configurations from XML.\r\n         *\r\n         *    @param [in] designConfigurationDocument     The XML description of a design configuration.\r\n         *    @param [in] newDesignConfiguration          The item where to insert the interconnection configurations.\r\n         */\r\n        void parseInterconnectionConfigurations(QDomDocument const& designConfigurationDocument,\r\n            QSharedPointer<DesignConfiguration> newDesignConfiguration);\r\n\r\n        /*!\r\n         *  Reads multiple abstractor instances from XML.\r\n         *\r\n         *    @param [in] interconnectionConfigurationNode    The XML description of an interconnection configuration.\r\n         *    @param [in] newInterconnectionConfiguration     The item where to insert multiple abstractor instances.\r\n         *    @param [in] docRevision                         The applied IP-XACT standard revision.\r\n         */\r\n        void parseMultipleAbstractors(QDomNode const& interconnectionConfigurationNode,\r\n            QSharedPointer<InterconnectionConfiguration> newInterconnectionConfiguration,\r\n            Document::Revision docRevision);\r\n\r\n        /*!\r\n         *  Reads the interface references from XML.\r\n         *\r\n         *    @param [in] multipleAbstractorsNode             The XML description of multiple abstractor instances.\r\n         *    @param [in] newMultipleAbstractorInstances      The item where to insert the interface references.\r\n         *    @param [in] docRevision                         The applied IP-XACT standard revision.\r\n         */\r\n        void parseInterfaceReferences(QDomNode const& multipleAbstractorsNode,\r\n            QSharedPointer<MultipleAbstractorInstances> newMultipleAbstractorInstances,\r\n            Document::Revision docRevision);\r\n\r\n        /*!\r\n         *  Reads the abstractor instances from XML.\r\n         *\r\n         *    @param [in] multipleAbstractorsNode             The XML description of a multiple abstractor instances.\r\n         *    @param [in] newMultipleAbstractorInstances      The item where to insert the abstractor instances.\r\n         *    @param [in] docRevision                         The applied IP-XACT standard revision.\r\n         */\r\n        void parseAbstractorInstances(QDomNode const& multipleAbstractorsNode,\r\n            QSharedPointer<MultipleAbstractorInstances> newMultipleAbstractorInstances,\r\n            Document::Revision docRevision);\r\n\r\n        /*!\r\n         *  Get a list of name containing QDomNode child nodes.\r\n         *\r\n         *    @param [in] targetNode      The QDomNode from where to get the child nodes.\r\n         *    @param [in] elementName     The tag of the elements to be searched for.\r\n         *\r\n         *    @return A list of child nodes containing the specified element name.\r\n         */\r\n        QDomNodeList getNamedChildNodes(QDomNode const& targetNode, QString elementName);\r\n\r\n        /*!\r\n         *  Reads the view configurations from XML.\r\n         *\r\n         *    @param [in] designConfigurationDocument     The XML description of a design configuration.\r\n         *    @param [in] newDesignConfiguration          The item where to insert the view configurations.\r\n         */\r\n        void parseViewConfigurations(QDomDocument const& designConfigurationDocument,\r\n            QSharedPointer<DesignConfiguration> newDesignConfiguration);\r\n\r\n        /*!\r\n         *  Reads the design configuration extensions.\r\n         *\r\n         *    @param [in] designConfigurationNode     XML description of the design configuration.\r\n         *    @param [in] newDesignConfiguration      The new design configuration item.\r\n         */\r\n        void parseDesignConfigurationExtensions(QDomNode const& designConfigurationNode,\r\n            QSharedPointer<DesignConfiguration> newDesignConfiguration);\r\n\r\n        /*!\r\n         *  Reads the view overrides.\r\n         *\r\n         *    @param [in] viewOverridesNode       XML description of the view overrides.\r\n         *    @param [in] newDesignConfiguration  The new design configuration item.\r\n         */\r\n        void parseViewOverrides(QDomElement const& viewOverridesNode,\r\n            QSharedPointer<DesignConfiguration> newDesignConfiguration);\r\n    };\r\n};\r\n\r\n#endif // DESIGNCONFIGURATIONREADER_H\r\n"
  },
  {
    "path": "IPXACTmodels/DesignConfiguration/DesignConfigurationWriter.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: DesignConfigurationWriter.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 03.08.2015\r\n//\r\n// Description:\r\n// Writer class for IP-XACT Design configuration element.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"DesignConfigurationWriter.h\"\r\n\r\n#include \"DesignConfiguration.h\"\r\n\r\n#include <IPXACTmodels/common/NameGroupWriter.h>\r\n#include <IPXACTmodels/common/ParameterWriter.h>\r\n\r\n#include <IPXACTmodels/common/VLNV.h>\r\n#include <IPXACTmodels/DesignConfiguration/InterconnectionConfiguration.h>\r\n\r\n#include <QMap>\r\n#include <QSharedPointer>\r\n\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignConfigurationWriter::writeDesignConfiguration()\r\n//-----------------------------------------------------------------------------\r\nvoid DesignConfigurationWriter::writeDesignConfiguration(QXmlStreamWriter& writer,\r\n    QSharedPointer<DesignConfiguration> designConfiguration)\r\n{\r\n    writer.writeStartDocument();\r\n\r\n    Details::writeDesignConfigurationStart(writer, designConfiguration);\r\n\r\n    DocumentWriter::writeNamespaceDeclarations(writer, designConfiguration);\r\n\r\n    DocumentWriter::writeDocumentNameGroup(writer, designConfiguration);\r\n\r\n    Details::writeDesignReference(writer, designConfiguration->getDesignRef());\r\n\r\n    Details::writeGeneratorChainConfiguration(writer, designConfiguration);\r\n\r\n    Details::writeInterConnectionConfiguration(writer, designConfiguration);\r\n\r\n    Details::writeViewConfigurations(writer, designConfiguration);\r\n\r\n    if (designConfiguration->getRevision() == Document::Revision::Std14)\r\n    {\r\n        CommonItemsWriter::writeDescription(writer, designConfiguration->getDescription());\r\n    }\r\n\r\n    DocumentWriter::writeParameters(writer, designConfiguration);\r\n\r\n    DocumentWriter::writeAssertions(writer, designConfiguration);\r\n\r\n    CommonItemsWriter::writeVendorExtensions(writer, designConfiguration);\r\n\r\n    writer.writeEndElement(); // ipxact:designConfiguration\r\n    writer.writeEndDocument();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignConfigurationWriter::writeDesignConfigurationStart()\r\n//-----------------------------------------------------------------------------\r\nvoid DesignConfigurationWriter::Details::writeDesignConfigurationStart(QXmlStreamWriter& writer,\r\n    QSharedPointer<DesignConfiguration> designConfiguration)\r\n{\r\n    DocumentWriter::writeTopComments(writer, designConfiguration);\r\n    DocumentWriter::writeXmlProcessingInstructions(writer, designConfiguration);\r\n    writer.writeStartElement(QStringLiteral(\"ipxact:designConfiguration\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignConfigurationWriter::writeDesignReference()\r\n//-----------------------------------------------------------------------------\r\nvoid DesignConfigurationWriter::Details::writeDesignReference(QXmlStreamWriter& writer, VLNV const& designReference)\r\n{\r\n    if (designReference.isValid())\r\n    {\r\n        writer.writeEmptyElement(QStringLiteral(\"ipxact:designRef\"));\r\n\r\n        CommonItemsWriter::writeVLNVAttributes(writer, designReference);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignConfigurationWriter::writeGeneratorChainConfiguration()\r\n//-----------------------------------------------------------------------------\r\nvoid DesignConfigurationWriter::Details::writeGeneratorChainConfiguration(QXmlStreamWriter& writer,\r\n    QSharedPointer<DesignConfiguration> designConfiguration)\r\n{\r\n    for (auto const& currentChain : *designConfiguration->getGeneratorChainConfs())\r\n    {\r\n        writer.writeStartElement(QStringLiteral(\"ipxact:generatorChainConfiguration\"));\r\n\r\n        CommonItemsWriter::writeVLNVAttributes(writer, *currentChain);\r\n\r\n        CommonItemsWriter::writeConfigurableElementValues(writer, currentChain->getConfigurableElementValues());\r\n\r\n        writer.writeEndElement(); // ipxact:generatorChainConfiguration\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignConfigurationWriter::writeInterConnectionConfiguration()\r\n//-----------------------------------------------------------------------------\r\nvoid DesignConfigurationWriter::Details::writeInterConnectionConfiguration(QXmlStreamWriter& writer,\r\n    QSharedPointer<DesignConfiguration> designConfiguration)\r\n{\r\n    auto docRevision = designConfiguration->getRevision();\r\n\r\n    for (auto const& configuration : *designConfiguration->getInterconnectionConfs())\r\n    {\r\n        writer.writeStartElement(QStringLiteral(\"ipxact:interconnectionConfiguration\"));\r\n\r\n        if (docRevision == Document::Revision::Std14)\r\n        {\r\n            CommonItemsWriter::writeIsPresent(writer, configuration->getIsPresent());\r\n        }\r\n\r\n        writer.writeTextElement(QStringLiteral(\"ipxact:interconnectionRef\"), configuration->getInterconnectionReference());\r\n\r\n        writeMultipleAbstractorInstances(writer, configuration->getAbstractorInstances(), docRevision);\r\n\r\n        if (docRevision == Document::Revision::Std22)\r\n        {\r\n            CommonItemsWriter::writeVendorExtensions(writer, configuration);\r\n        }\r\n\r\n        writer.writeEndElement(); // ipxact:interconnectionConfiguration\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignConfigurationWriter::writeMultipleAbstractorInstances()\r\n//-----------------------------------------------------------------------------\r\nvoid DesignConfigurationWriter::Details::writeMultipleAbstractorInstances(QXmlStreamWriter& writer,\r\n    QSharedPointer<QList<QSharedPointer<MultipleAbstractorInstances> > > multipleAbstractors,\r\n    Document::Revision docRevision)\r\n{\r\n    for (QSharedPointer<MultipleAbstractorInstances> multipleAbstractor : *multipleAbstractors)\r\n    {\r\n        writer.writeStartElement(QStringLiteral(\"ipxact:abstractorInstances\"));\r\n\r\n        if (docRevision == Document::Revision::Std14)\r\n        {\r\n            CommonItemsWriter::writeIsPresent(writer, multipleAbstractor->getIsPresent());\r\n        }\r\n\r\n        writeInterfaceReferences(writer, multipleAbstractor->getInterfaceReferences(), docRevision);\r\n        writeAbstractorInstances(writer, multipleAbstractor->getAbstractorInstances(), docRevision);\r\n\r\n        writer.writeEndElement(); // ipxact:abstractorInstances\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignConfigurationWriter::writeInterfaceReferences()\r\n//-----------------------------------------------------------------------------\r\nvoid DesignConfigurationWriter::Details::writeInterfaceReferences(QXmlStreamWriter& writer,\r\n    QSharedPointer<QList<QSharedPointer<InterfaceRef> > > interfaceReferences,\r\n    Document::Revision docRevision)\r\n{\r\n    for (QSharedPointer<InterfaceRef> singleInterface : *interfaceReferences)\r\n    {\r\n        writer.writeStartElement(QStringLiteral(\"ipxact:interfaceRef\"));\r\n        \r\n        writer.writeAttribute(QStringLiteral(\"componentRef\"), singleInterface->getComponentRef());\r\n        writer.writeAttribute(QStringLiteral(\"busRef\"), singleInterface->getBusRef());\r\n\r\n        if (docRevision == Document::Revision::Std14)\r\n        {\r\n            CommonItemsWriter::writeIsPresent(writer, singleInterface->getIsPresent());\r\n        }\r\n        \r\n        if (docRevision == Document::Revision::Std22)\r\n        {\r\n            CommonItemsWriter::writeVendorExtensions(writer, singleInterface);\r\n        }\r\n\r\n        writer.writeEndElement(); // ipxact:interfaceRef\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignConfigurationWriter::writeAbstractorInstances()\r\n//-----------------------------------------------------------------------------\r\nvoid DesignConfigurationWriter::Details::writeAbstractorInstances(QXmlStreamWriter& writer,\r\n    QSharedPointer<QList<QSharedPointer<AbstractorInstance> > > abstractorInstances,\r\n    Document::Revision docRevision)\r\n{\r\n    for (QSharedPointer<AbstractorInstance> abstractorInstance : *abstractorInstances)\r\n    {\r\n        writer.writeStartElement(QStringLiteral(\"ipxact:abstractorInstance\"));\r\n\r\n        writer.writeTextElement(QStringLiteral(\"ipxact:instanceName\"), abstractorInstance->getInstanceName());\r\n\r\n        CommonItemsWriter::writeDisplayName(writer, abstractorInstance->getDisplayName());\r\n\r\n        if (docRevision == Document::Revision::Std22)\r\n        {\r\n            CommonItemsWriter::writeShortDescription(writer, abstractorInstance->getShortDescription());\r\n        }\r\n\r\n        CommonItemsWriter::writeDescription(writer, abstractorInstance->getDescription());\r\n\r\n        writer.writeStartElement(QStringLiteral(\"ipxact:abstractorRef\"));\r\n\r\n        QSharedPointer<ConfigurableVLNVReference> abstractorRef = abstractorInstance->getAbstractorRef();  \r\n\r\n        CommonItemsWriter::writeVLNVAttributes(writer, *abstractorRef);\r\n\r\n        CommonItemsWriter::writeConfigurableElementValues(writer, abstractorRef->getConfigurableElementValues());\r\n\r\n        writer.writeEndElement(); // ipxact:abstractorRef\r\n\r\n        writer.writeTextElement(QStringLiteral(\"ipxact:viewName\"), abstractorInstance->getViewName());\r\n\r\n        if (docRevision == Document::Revision::Std22)\r\n        {\r\n            CommonItemsWriter::writeVendorExtensions(writer, abstractorInstance);\r\n        }\r\n\r\n        writer.writeEndElement(); // ipxact:abstractorInstance\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignConfigurationWriter::writeViewConfigurations()\r\n//-----------------------------------------------------------------------------\r\nvoid DesignConfigurationWriter::Details::writeViewConfigurations(QXmlStreamWriter& writer,\r\n    QSharedPointer<DesignConfiguration> designConfiguration)\r\n{\r\n    auto docRevision = designConfiguration->getRevision();\r\n\r\n    for (QSharedPointer<ViewConfiguration> configuration : *designConfiguration->getViewConfigurations())\r\n    {\r\n        writer.writeStartElement(QStringLiteral(\"ipxact:viewConfiguration\"));\r\n\r\n        writer.writeTextElement(QStringLiteral(\"ipxact:instanceName\"), configuration->getInstanceName());\r\n\r\n        if (docRevision == Document::Revision::Std14)\r\n        {\r\n            CommonItemsWriter::writeIsPresent(writer, configuration->getIsPresent());\r\n        }\r\n\r\n        writer.writeStartElement(QStringLiteral(\"ipxact:view\"));\r\n        writer.writeAttribute(QStringLiteral(\"viewRef\"), configuration->getViewReference());\r\n\r\n        CommonItemsWriter::writeConfigurableElementValues(writer, configuration->getViewConfigurableElements());\r\n\r\n        writer.writeEndElement(); // ipxact:view\r\n\r\n        if (docRevision == Document::Revision::Std22)\r\n        {\r\n            CommonItemsWriter::writeVendorExtensions(writer, configuration);\r\n        }\r\n\r\n        writer.writeEndElement(); // ipxact:viewConfiguration\r\n    }\r\n}\r\n"
  },
  {
    "path": "IPXACTmodels/DesignConfiguration/DesignConfigurationWriter.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: DesignConfigurationWriter.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 03.08.2015\r\n//\r\n// Description:\r\n// Writer class for IP-XACT Design configuration element.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef DESIGNCONFIGURATIONWRITER_H\r\n#define DESIGNCONFIGURATIONWRITER_H\r\n\r\n#include \"DesignConfiguration.h\"\r\n\r\n#include <IPXACTmodels/common/VLNV.h>\r\n#include <IPXACTmodels/ipxactmodels_global.h>\r\n\r\n#include <IPXACTmodels/common/DocumentWriter.h>\r\n\r\n#include <QXmlStreamWriter>\r\n#include <QSharedPointer>\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Writer class for IP-XACT Design configuration element.\r\n//-----------------------------------------------------------------------------\r\nnamespace DesignConfigurationWriter\r\n{\r\n\r\n\r\n    /*!\r\n     *  Writes the given design configuration into xml.\r\n     *\r\n     *    @param [in] writer                  The xml writer to use.\r\n     *    @param [in] designConfiguration     The selected design configuration.\r\n     */\r\n    IPXACTMODELS_EXPORT void writeDesignConfiguration(QXmlStreamWriter& writer,\r\n        QSharedPointer<DesignConfiguration> designConfiguration);\r\n\r\n    namespace Details\r\n    {\r\n        /*!\r\n         *  Write the document start elements.\r\n         *\r\n         *    @param [in] writer                  The used xml writer.\r\n         *    @param [in] designConfiguration     The selected design configuration.\r\n         */\r\n        void writeDesignConfigurationStart(QXmlStreamWriter& writer,\r\n            QSharedPointer<DesignConfiguration> designConfiguration);\r\n\r\n        /*!\r\n         *  Write the VLNV of the design configuration's referenced design.\r\n         *\r\n         *    @param [in] writer              The used xml writer.\r\n         *    @param [in] designReference     The VLNV of the referenced design.\r\n         */\r\n        void writeDesignReference(QXmlStreamWriter& writer, VLNV const& designReference);\r\n\r\n        /*!\r\n         *  Write generator chain configuration.\r\n         *\r\n         *    @param [in] writer                  The used xml writer.\r\n         *    @param [in] designConfiguration     The selected design configuration.\r\n         */\r\n        void writeGeneratorChainConfiguration(QXmlStreamWriter& writer,\r\n            QSharedPointer<DesignConfiguration> designConfiguration);\r\n\r\n        /*!\r\n         *  Write the interconnection configurations.\r\n         *\r\n         *    @param [in] writer                  The used xml writer.\r\n         *    @param [in] designConfiguration     The selected design configuration.\r\n         */\r\n        void writeInterConnectionConfiguration(QXmlStreamWriter& writer,\r\n            QSharedPointer<DesignConfiguration> designConfiguration);\r\n\r\n        /*!\r\n         *  Write the multiple abstractor instances.\r\n         *\r\n         *    @param [in] writer                  The used xml writer.\r\n         *    @param [in] multipleAbstractors     A list of multipleAbastractors.\r\n         */\r\n        void writeMultipleAbstractorInstances(QXmlStreamWriter& writer,\r\n            QSharedPointer<QList<QSharedPointer<MultipleAbstractorInstances> > > multipleAbstractors,\r\n            Document::Revision docRevision);\r\n\r\n        /*!\r\n         *  Write the interface references.\r\n         *\r\n         *    @param [in] writer                  The used xml writer.\r\n         *    @param [in] interfaceReferences     A list of interface references.\r\n         */\r\n        void writeInterfaceReferences(QXmlStreamWriter& writer,\r\n            QSharedPointer<QList<QSharedPointer<InterfaceRef> > > interfaceReferences,\r\n            Document::Revision docRevision);\r\n\r\n        /*!\r\n         *  Write the abstractor instances.\r\n         *\r\n         *    @param [in] writer                  The used xml writer.\r\n         *    @param [in] abstractorInstances     A list of abstractor instances.\r\n         */\r\n        void writeAbstractorInstances(QXmlStreamWriter& writer,\r\n            QSharedPointer<QList<QSharedPointer<AbstractorInstance> > > abstractorInstances,\r\n            Document::Revision docRevision);\r\n\r\n        /*!\r\n         *  Write the view configurations.\r\n         *\r\n         *    @param [in] writer                  The used xml writer.\r\n         *    @param [in] designConfiguration     The selected design configuration.\r\n         */\r\n        void writeViewConfigurations(QXmlStreamWriter& writer,\r\n            QSharedPointer<DesignConfiguration> designConfiguration);\r\n    };\r\n};\r\n\r\n#endif // DESIGNCONFIGURATIONWRITER_H\r\n"
  },
  {
    "path": "IPXACTmodels/DesignConfiguration/InterconnectionConfiguration.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: InterconnectionConfiguration.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 04.08.2015\r\n//\r\n// Description:\r\n// Matches the ipxact:interconnectionConfiguration element.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"InterconnectionConfiguration.h\"\r\n\r\n#include <IPXACTmodels/utilities/Copy.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: InterconnectionConfiguration::InterconnectionConfiguration()\r\n//-----------------------------------------------------------------------------\r\nInterconnectionConfiguration::InterconnectionConfiguration():\r\n    Extendable()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: InterconnectionConfiguration::InterconnectionConfigurationCopy()\r\n//-----------------------------------------------------------------------------\r\nInterconnectionConfiguration::InterconnectionConfiguration(const InterconnectionConfiguration& other):\r\n    Extendable(other),\r\nisPresent_(other.isPresent_),\r\ninterconnectionRef_(other.interconnectionRef_)\r\n{\r\n    Copy::copyList(other.abstractorInstances_, abstractorInstances_);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: InterconnectionConfiguration::getIsPresent()\r\n//-----------------------------------------------------------------------------\r\nQString InterconnectionConfiguration::getIsPresent() const\r\n{\r\n    return isPresent_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: InterconnectionConfiguration::setIsPresent()\r\n//-----------------------------------------------------------------------------\r\nvoid InterconnectionConfiguration::setIsPresent(QString const& newIsPresent)\r\n{\r\n    isPresent_ = newIsPresent;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: InterconnectionConfiguration::getInterconnectionReference()\r\n//-----------------------------------------------------------------------------\r\nQString InterconnectionConfiguration::getInterconnectionReference() const\r\n{\r\n    return interconnectionRef_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: InterconnectionConfiguration::setInterconnectionReference()\r\n//-----------------------------------------------------------------------------\r\nvoid InterconnectionConfiguration::setInterconnectionReference(QString const& newInterconnecionReference)\r\n{\r\n    interconnectionRef_ = newInterconnecionReference;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: InterconnectionConfiguration::getAbstractorInstances()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<QList<QSharedPointer<MultipleAbstractorInstances> > > InterconnectionConfiguration::\r\n    getAbstractorInstances() const\r\n{\r\n    return abstractorInstances_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: InterconnectionConfiguration::setAbstractorInstances()\r\n//-----------------------------------------------------------------------------\r\nvoid InterconnectionConfiguration::setAbstractorInstances(\r\n    QSharedPointer<QList<QSharedPointer<MultipleAbstractorInstances> > > newAbstractorInstances)\r\n{\r\n    abstractorInstances_ = newAbstractorInstances;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: InterconnectionConfiguration::getDependantVLNVs()\r\n//-----------------------------------------------------------------------------\r\nQList<VLNV> InterconnectionConfiguration::getDependantVLNVs() const\r\n{\r\n    QList<VLNV> vlnvList;\r\n\r\n    for (QSharedPointer<MultipleAbstractorInstances> multipleAbstractor : *abstractorInstances_)\r\n    {\r\n        vlnvList.append(multipleAbstractor->getDependantVLNVs());\r\n    }\r\n\r\n    return vlnvList;\r\n}\r\n"
  },
  {
    "path": "IPXACTmodels/DesignConfiguration/InterconnectionConfiguration.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: InterconnectionConfiguration.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 04.08.2015\r\n//\r\n// Description:\r\n// Matches the ipxact:interconnectionConfiguration element.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef INTERCONNECTIONCONFIGURATION_H\r\n#define INTERCONNECTIONCONFIGURATION_H\r\n\r\n#include \"MultipleAbstractorInstances.h\"\r\n\r\n#include <IPXACTmodels/common/Extendable.h>\r\n\r\n#include <IPXACTmodels/ipxactmodels_global.h>\r\n\r\n#include <QString>\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Matches the ipxact:interconnectionConfiguration element.\r\n//-----------------------------------------------------------------------------\r\nclass IPXACTMODELS_EXPORT InterconnectionConfiguration : public Extendable\r\n{\r\npublic:\r\n\r\n    /*!\r\n     *  The constructor.\r\n     */\r\n    InterconnectionConfiguration();\r\n\r\n    /*!\r\n     *  The copy constructor.\r\n     */\r\n    InterconnectionConfiguration(const InterconnectionConfiguration& other);\r\n\r\n    /*!\r\n     *  The destructor.\r\n     */\r\n    ~InterconnectionConfiguration() final = default;\r\n\r\n    /*!\r\n     *  Get the isPresent value.\r\n     *\r\n     *    @return The isPresent value.\r\n     */\r\n    QString getIsPresent() const;\r\n\r\n    /*!\r\n     *  Set the isPresent value.\r\n     *\r\n     *    @param [in] newIsPresent    The new value for the isPresent.\r\n     */\r\n    void setIsPresent(QString const& newIsPresent);\r\n\r\n    /*!\r\n     *  Get the referenced interconnection.\r\n     *\r\n     *    @return The name of the referenced interconnection.\r\n     */\r\n    QString getInterconnectionReference() const;\r\n\r\n    /*!\r\n     *  Set the referenced interconnection.\r\n     *\r\n     *    @param [in] newInterconnecionReference  The name of the referenced interconnection.\r\n     */\r\n    void setInterconnectionReference(QString const& newInterconnecionReference);\r\n\r\n    /*!\r\n     *  Get a list of multipleAbstractorInstances.\r\n     *\r\n     *    @return A list of multipleAbstractorInstances.\r\n     */\r\n    QSharedPointer<QList<QSharedPointer<MultipleAbstractorInstances> > > getAbstractorInstances() const;\r\n\r\n    /*!\r\n     *  Set the multipleAbstractorInstances.\r\n     *\r\n     *    @param [in] newAbstractorInstances  A new list of multipleAbstractorInstances.\r\n     */\r\n    void setAbstractorInstances(\r\n        QSharedPointer<QList<QSharedPointer<MultipleAbstractorInstances> > > newAbstractorInstances);\r\n\r\n    /*!\r\n     *  Get the VLNVs used in this element.\r\n     *\r\n     *    @return A list of the used VLNV elements.\r\n     */\r\n    QList<VLNV> getDependantVLNVs() const;\r\n\r\nprivate:\r\n\r\n    //! Defines whether the element is present in the document (default 1).\r\n    QString isPresent_;\r\n\r\n    //! A reference to the name of a design interconnection.\r\n    QString interconnectionRef_;\r\n\r\n    //! List of multiple abstractor elements.\r\n    QSharedPointer<QList<QSharedPointer<MultipleAbstractorInstances> > > abstractorInstances_ =\r\n        QSharedPointer<QList<QSharedPointer<MultipleAbstractorInstances> > >(new QList<QSharedPointer<MultipleAbstractorInstances> >);\r\n};\r\n\r\n#endif // INTERCONNECTIONCONFIGURATION_H\r\n"
  },
  {
    "path": "IPXACTmodels/DesignConfiguration/InterfaceRef.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: InterfaceRef.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 05.08.2015\r\n//\r\n// Description:\r\n// Matches the ipxact:interfaceRef element.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"InterfaceRef.h\"\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: InterfaceRef::InterfaceRef()\r\n//-----------------------------------------------------------------------------\r\nInterfaceRef::InterfaceRef():\r\n    Extendable()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: InterfaceRef::InterfaceRef()\r\n//-----------------------------------------------------------------------------\r\nInterfaceRef::InterfaceRef(const InterfaceRef& other):\r\n    Extendable(other),\r\ncomponentRef_(other.componentRef_),\r\nbusRef_(other.busRef_),\r\nisPresent_(other.isPresent_)\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: InterfaceRef::getIsPresent()\r\n//-----------------------------------------------------------------------------\r\nQString InterfaceRef::getIsPresent() const\r\n{\r\n    return isPresent_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: InterfaceRef::setIsPresent()\r\n//-----------------------------------------------------------------------------\r\nvoid InterfaceRef::setIsPresent(QString const& newIsPresent)\r\n{\r\n    isPresent_ = newIsPresent;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: InterfaceRef::getComponentRef()\r\n//-----------------------------------------------------------------------------\r\nQString InterfaceRef::getComponentRef() const\r\n{\r\n    return componentRef_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: InterfaceRef::setComponentRef()\r\n//-----------------------------------------------------------------------------\r\nvoid InterfaceRef::setComponentRef(QString const& newComponentRef)\r\n{\r\n    componentRef_ = newComponentRef;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: InterfaceRef::getBusRef()\r\n//-----------------------------------------------------------------------------\r\nQString InterfaceRef::getBusRef() const\r\n{\r\n    return busRef_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: InterfaceRef::setBusRef()\r\n//-----------------------------------------------------------------------------\r\nvoid InterfaceRef::setBusRef(QString const& newBusRef)\r\n{\r\n    busRef_ = newBusRef;\r\n}\r\n"
  },
  {
    "path": "IPXACTmodels/DesignConfiguration/InterfaceRef.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: InterfaceRef.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 05.08.2015\r\n//\r\n// Description:\r\n// Matches the ipxact:interfaceRef element.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef INTERFACEREF_H\r\n#define INTERFACEREF_H\r\n\r\n#include <IPXACTmodels/common/Extendable.h>\r\n\r\n#include <IPXACTmodels/ipxactmodels_global.h>\r\n\r\n#include <QString>\r\n#include <QMap>\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Matches the ipxact:interfaceRef element.\r\n//-----------------------------------------------------------------------------\r\nclass IPXACTMODELS_EXPORT InterfaceRef : public Extendable\r\n{\r\npublic:\r\n\r\n    /*!\r\n     *  The constructor.\r\n     */\r\n    InterfaceRef();\r\n\r\n    /*!\r\n     *  Copy constructor.\r\n     */\r\n    InterfaceRef(const InterfaceRef& other);\r\n\r\n    /*!\r\n     *  The destructor.\r\n     */\r\n    ~InterfaceRef() final = default;\r\n\r\n    /*!\r\n     *  Get the isPresent value.\r\n     *\r\n     *    @return The value of isPresent.\r\n     */\r\n    QString getIsPresent() const;\r\n\r\n    /*!\r\n     *  Set the value for isPresent.\r\n     *\r\n     *    @param [in] newIsPresent    The new value for isPresent.\r\n     */\r\n    void setIsPresent(QString const& newIsPresent);\r\n\r\n    /*!\r\n     *  Get the name of the referenced component.\r\n     *\r\n     *    @return The name of the referenced component.\r\n     */\r\n    QString getComponentRef() const;\r\n\r\n    /*!\r\n     *  Set the referenced component.\r\n     *\r\n     *    @param [in] newComponentRef     The name of the referenced component.\r\n     */\r\n    void setComponentRef(QString const& newComponentRef);\r\n\r\n    /*!\r\n     *  Get the name of the referenced bus interface.\r\n     *\r\n     *    @return The name of the referenced bus interface.\r\n     */\r\n    QString getBusRef() const;\r\n\r\n    /*!\r\n     *  Set the referenced bus interface.\r\n     *\r\n     *    @param [in] newBusRef   The name of the referenced bus interface.\r\n     */\r\n    void setBusRef(QString const& newBusRef);\r\n\r\nprivate:\r\n\r\n    //! The name of the referenced component.\r\n    QString componentRef_;\r\n    \r\n    //! The name of the referenced bus interface.\r\n    QString busRef_;\r\n\r\n    //! Defines the presenced of the element\r\n    QString isPresent_;\r\n};\r\n\r\n#endif // INTERFACEREF_H\r\n"
  },
  {
    "path": "IPXACTmodels/DesignConfiguration/MultipleAbstractorInstances.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: MultipleAbstractorInstances.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 05.08.2015\r\n//\r\n// Description:\r\n// Matches the ipxact:abstractorInstances element.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"MultipleAbstractorInstances.h\"\r\n\r\n#include <IPXACTmodels/utilities/Copy.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MultipleAbstractorInstances::MultipleAbstractorInstances()\r\n//-----------------------------------------------------------------------------\r\nMultipleAbstractorInstances::MultipleAbstractorInstances()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MultipleAbstractorInstances::MultipleAbstractorInstancesCopy()\r\n//-----------------------------------------------------------------------------\r\nMultipleAbstractorInstances::MultipleAbstractorInstances(const MultipleAbstractorInstances& other):\r\nisPresent_(other.isPresent_)\r\n{\r\n    Copy::copyList(other.interfaceReferences_, interfaceReferences_);\r\n\r\n    Copy::copyList(other.abstractorInstances_, abstractorInstances_);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MultipleAbstractorInstances::getIsPresent()\r\n//-----------------------------------------------------------------------------\r\nQString MultipleAbstractorInstances::getIsPresent() const\r\n{\r\n    return isPresent_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MultipleAbstractorInstances::setIsPresent()\r\n//-----------------------------------------------------------------------------\r\nvoid MultipleAbstractorInstances::setIsPresent(QString const& newIsPresent)\r\n{\r\n    isPresent_ = newIsPresent;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MultipleAbstractorInstances::getInterfaceReferences()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<QList<QSharedPointer<InterfaceRef> > > MultipleAbstractorInstances::getInterfaceReferences() const\r\n{\r\n    return interfaceReferences_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MultipleAbstractorInstances::setInterfaceReferences()\r\n//-----------------------------------------------------------------------------\r\nvoid MultipleAbstractorInstances::setInterfaceReferences(\r\n    QSharedPointer<QList<QSharedPointer<InterfaceRef> > > newInterfaceReferences)\r\n{\r\n    interfaceReferences_ = newInterfaceReferences;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MultipleAbstractorInstances::getAbstractorInstances()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<QList<QSharedPointer<AbstractorInstance> > > MultipleAbstractorInstances::getAbstractorInstances() const\r\n{\r\n    return abstractorInstances_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MultipleAbstractorInstances::setAbstractorInstances()\r\n//-----------------------------------------------------------------------------\r\nvoid MultipleAbstractorInstances::setAbstractorInstances(\r\n    QSharedPointer<QList<QSharedPointer<AbstractorInstance> > > newAbstractorInstances)\r\n{\r\n    abstractorInstances_ = newAbstractorInstances;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MultipleAbstractorInstances::getDependantVLNVs()\r\n//-----------------------------------------------------------------------------\r\nQList<VLNV> MultipleAbstractorInstances::getDependantVLNVs() const\r\n{\r\n    QList<VLNV> vlnvList;\r\n\r\n    for (QSharedPointer<AbstractorInstance> abstractor : *abstractorInstances_)\r\n    {\r\n        vlnvList.append(*abstractor->getAbstractorRef());\r\n    }\r\n\r\n    return vlnvList;\r\n}"
  },
  {
    "path": "IPXACTmodels/DesignConfiguration/MultipleAbstractorInstances.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: MultipleAbstractorInstances.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 05.08.2015\r\n//\r\n// Description:\r\n// Matches the ipxact:abstractorInstances element.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef MULTIPLEABSTRACTORINSTANCES_H\r\n#define MULTIPLEABSTRACTORINSTANCES_H\r\n\r\n#include \"AbstractorInstance.h\"\r\n#include \"InterfaceRef.h\"\r\n\r\n#include <IPXACTmodels/ipxactmodels_global.h>\r\n\r\n#include <QString>\r\n#include <QList>\r\n#include <QSharedPointer>\r\n#include <QDomNode>\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Matches the ipxact:abstractorInstances element.\r\n//-----------------------------------------------------------------------------\r\nclass IPXACTMODELS_EXPORT MultipleAbstractorInstances\r\n{\r\npublic:\r\n\r\n    /*!\r\n     *  The constructor.\r\n     */\r\n    MultipleAbstractorInstances();\r\n\r\n    /*!\r\n     *  Copy constructor.\r\n     */\r\n    MultipleAbstractorInstances(const MultipleAbstractorInstances& other);\r\n\r\n    /*!\r\n     *  The destructor.\r\n     */\r\n    ~MultipleAbstractorInstances() = default;\r\n\r\n    //! No assignment.\r\n    MultipleAbstractorInstances& operator=(const MultipleAbstractorInstances& other) = delete;\r\n\r\n    /*!\r\n     *  Get the value for the isPresent.\r\n     *\r\n     *    @return The value of the isPresent.\r\n     */\r\n    QString getIsPresent() const;\r\n\r\n    /*!\r\n     *  Set the value for the isPresent.\r\n     *\r\n     *    @param [in] newIsPresent    The new value for the isPresent.\r\n     */\r\n    void setIsPresent(QString const& newIsPresent);\r\n\r\n    /*!\r\n     *  Get interface references.\r\n     *\r\n     *    @return A list of pointers to the interface references.\r\n     */\r\n    QSharedPointer<QList<QSharedPointer<InterfaceRef> > > getInterfaceReferences() const;\r\n\r\n    /*!\r\n     *  Set the interface references.\r\n     *\r\n     *    @param [in] newInterfaceReferences  A list of pointers to the interface references.\r\n     */\r\n    void setInterfaceReferences(QSharedPointer<QList<QSharedPointer<InterfaceRef> > > newInterfaceReferences);\r\n\r\n    /*!\r\n     *  Get the abstractor instances.\r\n     *\r\n     *    @return A list of pointers to the abstractor instances.\r\n     */\r\n    QSharedPointer<QList<QSharedPointer<AbstractorInstance> > > getAbstractorInstances() const;\r\n\r\n    /*!\r\n     *  Set the abstractor instances.\r\n     *\r\n     *    @param [in] newAbstractorInstances  A list of pointers to the abstractor instances.\r\n     */\r\n    void setAbstractorInstances(QSharedPointer<QList<QSharedPointer<AbstractorInstance> > > newAbstractorInstances);\r\n\r\n    /*!\r\n     *  Get the VLNVs used in the contained elements.\r\n     *\r\n     *    @return A list of used VLNVs.\r\n     */\r\n    QList<VLNV> getDependantVLNVs() const;\r\n\r\nprivate:\r\n\r\n    //! Defines the presence of this element.\r\n    QString isPresent_;\r\n\r\n    //! A list of interface references.\r\n    QSharedPointer<QList<QSharedPointer<InterfaceRef> > > interfaceReferences_ =\r\n        QSharedPointer<QList<QSharedPointer<InterfaceRef> > >(new QList<QSharedPointer<InterfaceRef> >);\r\n\r\n    //! A list of abstractor instances.\r\n    QSharedPointer<QList<QSharedPointer<AbstractorInstance> > > abstractorInstances_ =\r\n        QSharedPointer<QList<QSharedPointer<AbstractorInstance> > >(new QList<QSharedPointer<AbstractorInstance> >);\r\n};\r\n\r\n#endif // MULTIPLEABSTRACTORINSTANCES_H\r\n"
  },
  {
    "path": "IPXACTmodels/DesignConfiguration/ViewConfiguration.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ViewConfiguration.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 05.08.2015\r\n//\r\n// Description:\r\n// Matches the ipxact:viewConfiguration element.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"ViewConfiguration.h\"\r\n\r\n#include <IPXACTmodels/utilities/Copy.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ViewConfiguration::ViewConfiguration()\r\n//-----------------------------------------------------------------------------\r\nViewConfiguration::ViewConfiguration():\r\nExtendable()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ViewConfiguration::ViewConfiguration()\r\n//-----------------------------------------------------------------------------\r\nViewConfiguration::ViewConfiguration(QString const& instanceName):\r\ninstanceName_(instanceName)\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ViewConfiguration::ViewConfiguration()\r\n//-----------------------------------------------------------------------------\r\nViewConfiguration::ViewConfiguration(const ViewConfiguration& other):\r\n    Extendable(other),\r\ninstanceName_(other.instanceName_),\r\nisPresent_(other.isPresent_),\r\nviewRef_(other.viewRef_)\r\n{\r\n    Copy::copyList(other.viewConfigurables_, viewConfigurables_);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ViewConfiguration::getInstanceName()\r\n//-----------------------------------------------------------------------------\r\nQString ViewConfiguration::getInstanceName() const\r\n{\r\n    return instanceName_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ViewConfiguration::setInstanceName()\r\n//-----------------------------------------------------------------------------\r\nvoid ViewConfiguration::setInstanceName(QString const& newInstanceName)\r\n{\r\n    instanceName_ = newInstanceName;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ViewConfiguration::getIsPresent()\r\n//-----------------------------------------------------------------------------\r\nQString ViewConfiguration::getIsPresent() const\r\n{\r\n    return isPresent_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ViewConfiguration::setIsPresent()\r\n//-----------------------------------------------------------------------------\r\nvoid ViewConfiguration::setIsPresent(QString const& newIsPresent)\r\n{\r\n    isPresent_ = newIsPresent;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ViewConfiguration::getViewReference()\r\n//-----------------------------------------------------------------------------\r\nQString ViewConfiguration::getViewReference() const\r\n{\r\n    return viewRef_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ViewConfiguration::setViewReference()\r\n//-----------------------------------------------------------------------------\r\nvoid ViewConfiguration::setViewReference(QString const& newViewReference)\r\n{\r\n    viewRef_ = newViewReference;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ViewConfiguration::getViewConfigurableElements()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<QList<QSharedPointer<ConfigurableElementValue> > > ViewConfiguration::getViewConfigurableElements()\r\n    const\r\n{\r\n    return viewConfigurables_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ViewConfiguration::setViewConfigurableElements()\r\n//-----------------------------------------------------------------------------\r\nvoid ViewConfiguration::setViewConfigurableElements(\r\n    QSharedPointer<QList<QSharedPointer<ConfigurableElementValue> > > newConfigurableElements)\r\n{\r\n    viewConfigurables_ = newConfigurableElements;\r\n}\r\n"
  },
  {
    "path": "IPXACTmodels/DesignConfiguration/ViewConfiguration.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ViewConfiguration.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 05.08.2015\r\n//\r\n// Description:\r\n// Matches the ipxact:viewConfiguration element.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef VIEWCONFIGURATION_H\r\n#define VIEWCONFIGURATION_H\r\n\r\n#include <IPXACTmodels/ipxactmodels_global.h>\r\n\r\n#include <IPXACTmodels/common/ConfigurableElementValue.h>\r\n#include <IPXACTmodels/common/Extendable.h>\r\n\r\n#include <QString>\r\n#include <QMap>\r\n#include <QSharedPointer>\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Matches the ipxact:abstractorInstances element.\r\n//-----------------------------------------------------------------------------\r\nclass IPXACTMODELS_EXPORT ViewConfiguration : public Extendable\r\n{\r\npublic:\r\n\r\n    /*!\r\n     *  The constructor.\r\n     */\r\n    ViewConfiguration();\r\n\r\n    /*!\r\n     *  The constructor.\r\n     *\r\n     *    @param [in] instanceName    The name of this instance.\r\n     */\r\n    explicit ViewConfiguration(QString const& instanceName);\r\n\r\n    /*!\r\n     *  Copy constructor.\r\n     */\r\n    ViewConfiguration(const ViewConfiguration& other);\r\n\r\n    ViewConfiguration& operator=(const ViewConfiguration& other) = delete;\r\n\r\n    /*!\r\n     *  The destructor.\r\n     */\r\n    ~ViewConfiguration() final = default;\r\n\r\n    /*!\r\n     *  Get the name of this instance.\r\n     *\r\n     *    @return The name of this instance.\r\n     */\r\n    QString getInstanceName() const;\r\n\r\n    /*!\r\n     *  Set the name for this instance.\r\n     *\r\n     *    @param [in] newInstanceName     The new name for this instance.\r\n     */\r\n    void setInstanceName(QString const& newInstanceName);\r\n\r\n    /*!\r\n     *  Get the value of isPresent.\r\n     *\r\n     *    @return The value of isPresent.\r\n     */\r\n    QString getIsPresent() const;\r\n\r\n    /*!\r\n     *  Set the value for isPresent.\r\n     *\r\n     *    @param [in] newIsPresent    The new value for isPresent.\r\n     */\r\n    void setIsPresent(QString const& newIsPresent);\r\n\r\n    /*!\r\n     *  Get the referenced view.\r\n     *\r\n     *    @return The referenced view.\r\n     */\r\n    QString getViewReference() const;\r\n\r\n    /*!\r\n     *  Set the referenced view.\r\n     *\r\n     *    @param [in] newViewReference    The new view reference.\r\n     */\r\n    void setViewReference(QString const& newViewReference);\r\n\r\n    /*!\r\n     *  Get the configurable element values of the referenced view.\r\n     *\r\n     *    @return The configurable element values of the referenced view.\r\n     */\r\n    QSharedPointer<QList<QSharedPointer<ConfigurableElementValue> > > getViewConfigurableElements() const;\r\n\r\n    /*!\r\n     *  Set the configurable element values of the referenced view.\r\n     *\r\n     *    @param [in] newConfigurableElements     The new configurable element values for the referenced view.\r\n     */\r\n    void setViewConfigurableElements(\r\n        QSharedPointer<QList<QSharedPointer<ConfigurableElementValue> > > newConfigurableElements);\r\n\r\nprivate:\r\n\r\n    //! The name of this instance.\r\n    QString instanceName_;\r\n\r\n    //! Defines the presence of this element.\r\n    QString isPresent_;\r\n\r\n    //! The referenced view.\r\n    QString viewRef_;\r\n\r\n    //! A list of pointers to the configurable element values of the referenced view.\r\n    QSharedPointer<QList<QSharedPointer<ConfigurableElementValue> > > viewConfigurables_ =\r\n        QSharedPointer<QList<QSharedPointer<ConfigurableElementValue> > >(new QList<QSharedPointer<ConfigurableElementValue> >);\r\n};\r\n\r\n#endif // VIEWCONFIGURATION_H\r\n"
  },
  {
    "path": "IPXACTmodels/DesignConfiguration/validators/DesignConfigurationValidator.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: DesignConfigurationValidator.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 11.01.2016\r\n//\r\n// Description:\r\n// Validator for the ipxact:designConfiguration.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"DesignConfigurationValidator.h\"\r\n\r\n#include <IPXACTmodels/DesignConfiguration/DesignConfiguration.h>\r\n\r\n#include <IPXACTmodels/Design/Design.h>\r\n\r\n#include <IPXACTmodels/common/Parameter.h>\r\n\r\n#include <IPXACTmodels/common/validators/ParameterValidator.h>\r\n#include <IPXACTmodels/common/validators/AssertionValidator.h>\r\n\r\n#include <IPXACTmodels/DesignConfiguration/validators/InterconnectionConfigurationValidator.h>\r\n#include <IPXACTmodels/DesignConfiguration/validators/ViewConfigurationValidator.h>\r\n\r\n#include <KactusAPI/include/ExpressionParser.h>\r\n\r\n#include <KactusAPI/include/LibraryInterface.h>\r\n\r\n#include <QRegularExpression>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignConfigurationValidator::DesignConfigurationValidator()\r\n//-----------------------------------------------------------------------------\r\nDesignConfigurationValidator::DesignConfigurationValidator(QSharedPointer<ExpressionParser> parser,\r\n    LibraryInterface* library):\r\nlibraryHandler_(library),\r\nparameterValidator_(),\r\nassertionValidator_(),\r\ninterconnectionValidator_(),\r\nviewConfigurationValidator_(),\r\nexpressionParser_(parser)\r\n{\r\n    parameterValidator_ = QSharedPointer<ParameterValidator>(\r\n        new ParameterValidator(expressionParser_, QSharedPointer<QList<QSharedPointer<Choice> > >(), Document::Revision::Unknown));\r\n\r\n    assertionValidator_ = QSharedPointer<AssertionValidator>(new AssertionValidator(parser));\r\n\r\n    interconnectionValidator_ = QSharedPointer<InterconnectionConfigurationValidator>(\r\n        new InterconnectionConfigurationValidator(parser, libraryHandler_));\r\n\r\n    viewConfigurationValidator_ =\r\n        QSharedPointer<ViewConfigurationValidator>(new ViewConfigurationValidator(libraryHandler_, parser));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignConfigurationValidator::~DesignConfigurationValidator()\r\n//-----------------------------------------------------------------------------\r\nDesignConfigurationValidator::~DesignConfigurationValidator()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignConfigurationValidator::validate()\r\n//-----------------------------------------------------------------------------\r\nbool DesignConfigurationValidator::validate(QSharedPointer<DesignConfiguration> designConfiguration)\r\n{\r\n    return hasValidVLNV(designConfiguration) && hasValidDesignReference(designConfiguration) &&\r\n        hasValidGeneratorChainConfigurations(designConfiguration) &&\r\n        hasValidInterconnectionConfigurations(designConfiguration) &&\r\n        hasValidViewConfigurations(designConfiguration) &&\r\n        hasValidParameters(designConfiguration) &&\r\n        hasValidAssertions(designConfiguration);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignConfigurationValidator::hasValidVLNV()\r\n//-----------------------------------------------------------------------------\r\nbool DesignConfigurationValidator::hasValidVLNV(QSharedPointer<DesignConfiguration> designConfiguration) const\r\n{\r\n    return designConfiguration->getVlnv().getType() == VLNV::DESIGNCONFIGURATION &&\r\n        designConfiguration->getVlnv().isValid();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignConfigurationValidator::hasValidDesignReference()\r\n//-----------------------------------------------------------------------------\r\nbool DesignConfigurationValidator::hasValidDesignReference(QSharedPointer<DesignConfiguration> designConfiguration)\r\n    const\r\n{\r\n    if (!designConfiguration->getDesignRef().isEmpty())\r\n    {\r\n        return designConfiguration->getDesignRef().getType() == VLNV::DESIGN &&\r\n            libraryHandler_->contains(designConfiguration->getDesignRef()) &&\r\n            designConfiguration->getDesignRef().isValid();\r\n    }\r\n\r\n    return true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignConfigurationValidator::hasValidGeneratorChainConfigurations()\r\n//-----------------------------------------------------------------------------\r\nbool DesignConfigurationValidator::hasValidGeneratorChainConfigurations(\r\n    QSharedPointer<DesignConfiguration> designConfiguration) const\r\n{\r\n    if (!designConfiguration->getGeneratorChainConfs()->isEmpty())\r\n    {\r\n        for (int chainIndex = 0; chainIndex < designConfiguration->getGeneratorChainConfs()->size(); ++chainIndex)\r\n        {\r\n            QSharedPointer<ConfigurableVLNVReference> chainReference =\r\n                designConfiguration->getGeneratorChainConfs()->at(chainIndex);\r\n\r\n            if (chainReference->getType() != VLNV::GENERATORCHAIN || !chainReference->isValid())\r\n            {\r\n                return false;\r\n            }\r\n\r\n            for (int comparisonIndex = chainIndex + 1;\r\n                comparisonIndex < designConfiguration->getGeneratorChainConfs()->size(); ++comparisonIndex)\r\n            {\r\n                QSharedPointer<ConfigurableVLNVReference> comparedReference =\r\n                    designConfiguration->getGeneratorChainConfs()->at(comparisonIndex);\r\n\r\n                if (chainReference->VLNV::operator==(*comparedReference))\r\n                {\r\n                    return false;\r\n                }\r\n            }\r\n        }\r\n    }\r\n\r\n    return true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignConfigurationValidator::hasValidInterconnectionConfigurations()\r\n//-----------------------------------------------------------------------------\r\nbool DesignConfigurationValidator::hasValidInterconnectionConfigurations(\r\n    QSharedPointer<DesignConfiguration> designConfiguration) const\r\n{\r\n    if (!designConfiguration->getInterconnectionConfs()->isEmpty())\r\n    {\r\n        if (designConfiguration->getDesignRef().isValid())\r\n        {\r\n            QSharedPointer<Design> referencedDesign =\r\n                libraryHandler_->getDesign(designConfiguration->getDesignRef());\r\n            interconnectionValidator_->designChanged(referencedDesign);\r\n\r\n            QVector<QString> interconnectionReferences;\r\n            for (QSharedPointer<InterconnectionConfiguration> configuration :\r\n                *designConfiguration->getInterconnectionConfs())\r\n            {\r\n                if (interconnectionReferences.contains(configuration->getInterconnectionReference()) ||\r\n                    !interconnectionValidator_->validate(configuration))\r\n                {\r\n                    return false;\r\n                }\r\n\r\n                interconnectionReferences.append(configuration->getInterconnectionReference());\r\n            }\r\n        }\r\n        else\r\n        {\r\n            return false;\r\n        }\r\n    }\r\n\r\n    return true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignConfigurationValidator::hasValidViewConfigurations()\r\n//-----------------------------------------------------------------------------\r\nbool DesignConfigurationValidator::hasValidViewConfigurations(\r\n    QSharedPointer<DesignConfiguration> designConfiguration) const\r\n{\r\n    if (!designConfiguration->getViewConfigurations()->isEmpty())\r\n    {\r\n        if (designConfiguration->getDesignRef().isValid())\r\n        {\r\n            QSharedPointer<Design> referencedDesign =\r\n                libraryHandler_->getDesign(designConfiguration->getDesignRef());\r\n\r\n            viewConfigurationValidator_->changeComponentInstances(referencedDesign->getComponentInstances());\r\n\r\n            QVector<QString> instanceNames;\r\n            for (QSharedPointer<ViewConfiguration> viewConfiguration :\r\n                *designConfiguration->getViewConfigurations())\r\n            {\r\n                if (instanceNames.contains(viewConfiguration->getInstanceName()) ||\r\n                    !viewConfigurationValidator_->validate(viewConfiguration))\r\n                {\r\n                    return false;\r\n                }\r\n\r\n                instanceNames.append(viewConfiguration->getInstanceName());\r\n            }\r\n        }\r\n        else\r\n        {\r\n            return false;\r\n        }\r\n    }\r\n\r\n    return true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignConfigurationValidator::hasValidParameters()\r\n//-----------------------------------------------------------------------------\r\nbool DesignConfigurationValidator::hasValidParameters(QSharedPointer<DesignConfiguration> designConfiguration) const\r\n{\r\n    parameterValidator_->setStdRevision(designConfiguration->getRevision());\r\n\r\n    if (!designConfiguration->getParameters()->isEmpty())\r\n    {\r\n        QVector<QString> parameterNames;\r\n        for (auto const& parameter : *designConfiguration->getParameters())\r\n        {\r\n            if (parameterNames.contains(parameter->name()) || !parameterValidator_->validate(parameter))\r\n            {\r\n                return false;\r\n            }\r\n\r\n            parameterNames.append(parameter->name());\r\n        }\r\n    }\r\n\r\n    return true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignConfigurationValidator::hasValidAssertions()\r\n//-----------------------------------------------------------------------------\r\nbool DesignConfigurationValidator::hasValidAssertions(QSharedPointer<DesignConfiguration> designConfiguration)\r\n    const\r\n{\r\n    if (!designConfiguration->getAssertions()->isEmpty())\r\n    {\r\n        QVector<QString> assertionNames;\r\n        for (auto const& assertion : *designConfiguration->getAssertions())\r\n        {\r\n            if (assertionNames.contains(assertion->name()) || !assertionValidator_->validate(assertion))\r\n            {\r\n                return false;\r\n            }\r\n\r\n            assertionNames.append(assertion->name());\r\n        }\r\n    }\r\n\r\n    return true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignConfigurationValidator::findErrorsIn()\r\n//-----------------------------------------------------------------------------\r\nvoid DesignConfigurationValidator::findErrorsIn(QVector<QString>& errors,\r\n    QSharedPointer<DesignConfiguration> designConfiguration)\r\n{\r\n    parameterValidator_->setStdRevision(designConfiguration->getRevision());\r\n\r\n    QString context = QObject::tr(\"design configuration %1\").arg(designConfiguration->getVlnv().toString());\r\n\r\n    findErrorsInVLNV(errors, designConfiguration);\r\n    findErrorsInDesignReference(errors, designConfiguration, context);\r\n    findErrorsInGeneratorChainConfigurations(errors, designConfiguration, context);\r\n    findErrorsInInterconnectionConfigurations(errors, designConfiguration, context);\r\n    findErrorsInViewConfigurations(errors, designConfiguration, context);\r\n    findErrorsInParameters(errors, designConfiguration, context);\r\n    findErrorsInAssertions(errors, designConfiguration, context);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignConfigurationValidator::findErrorsInVLNV()\r\n//-----------------------------------------------------------------------------\r\nvoid DesignConfigurationValidator::findErrorsInVLNV(QVector<QString>& errors,\r\n    QSharedPointer<DesignConfiguration> designConfiguration) const\r\n{\r\n    designConfiguration->getVlnv().isValid(errors, QLatin1String(\"design configuration\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignConfigurationValidator::findErrorsInDesignReference()\r\n//-----------------------------------------------------------------------------\r\nvoid DesignConfigurationValidator::findErrorsInDesignReference(QVector<QString>& errors,\r\n    QSharedPointer<DesignConfiguration> designConfiguration, QString const& context) const\r\n{\r\n    if (!designConfiguration->getDesignRef().isEmpty())\r\n    {\r\n        if (!libraryHandler_->contains(designConfiguration->getDesignRef()))\r\n        {\r\n            errors.append(QObject::tr(\"Design reference %1 within %2 was not found in the \"\r\n                \"library\")\r\n                .arg(designConfiguration->getDesignRef().toString(), context));\r\n        }\r\n\r\n        designConfiguration->getDesignRef().isValid(errors, QLatin1String(\"design reference\"));\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignConfigurationValidator::findErrorsInGeneratorChainConfigurations()\r\n//-----------------------------------------------------------------------------\r\nvoid DesignConfigurationValidator::findErrorsInGeneratorChainConfigurations(QVector<QString>& errors,\r\n    QSharedPointer<DesignConfiguration> designConfiguration, QString const& context) const\r\n{\r\n    if (!designConfiguration->getGeneratorChainConfs()->isEmpty())\r\n    {\r\n        for (int chainIndex = 0; chainIndex < designConfiguration->getGeneratorChainConfs()->size(); ++chainIndex)\r\n        {\r\n            QSharedPointer<ConfigurableVLNVReference> chainReference =\r\n                designConfiguration->getGeneratorChainConfs()->at(chainIndex);\r\n\r\n            if (chainReference->getType() != VLNV::GENERATORCHAIN)\r\n            {\r\n                errors.append(QObject::tr(\"The type of the generator chain configuration is invalid within %1.\")\r\n                    .arg(context));\r\n            }\r\n\r\n            chainReference->isValid(errors, QStringLiteral(\"generator chain configuration\"));\r\n\r\n            for (int comparisonIndex = chainIndex + 1;\r\n                comparisonIndex < designConfiguration->getGeneratorChainConfs()->size(); ++comparisonIndex)\r\n            {\r\n                QSharedPointer<ConfigurableVLNVReference> comparedReference =\r\n                    designConfiguration->getGeneratorChainConfs()->at(comparisonIndex);\r\n\r\n                if (chainReference->VLNV::operator==(*comparedReference))\r\n                {\r\n                    errors.append(QObject::tr(\"Generator chain configuration %1 is not unique within %2.\")\r\n                        .arg(chainReference->toString()).arg(context));\r\n                }\r\n            }\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignConfigurationValidator::findErrorsInInterconnectionConfigurations()\r\n//-----------------------------------------------------------------------------\r\nvoid DesignConfigurationValidator::findErrorsInInterconnectionConfigurations(QVector<QString>& errors,\r\n    QSharedPointer<DesignConfiguration> designConfiguration, QString const& context) const\r\n{\r\n    if (!designConfiguration->getInterconnectionConfs()->isEmpty() &&\r\n        designConfiguration->getDesignRef().isValid())\r\n    {\r\n        QSharedPointer<Design> referencedDesign =\r\n            libraryHandler_->getDesign(designConfiguration->getDesignRef());\r\n        interconnectionValidator_->designChanged(referencedDesign);\r\n\r\n        QVector<QString> connectionReferences;\r\n        QVector<QString> duplicateNames;\r\n        for (QSharedPointer<InterconnectionConfiguration> connectionConfiguration :\r\n            *designConfiguration->getInterconnectionConfs())\r\n        {\r\n            if (connectionReferences.contains(connectionConfiguration->getInterconnectionReference()) &&\r\n                !duplicateNames.contains(connectionConfiguration->getInterconnectionReference()))\r\n            {\r\n                errors.append(QObject::tr(\"Interconnection reference '%1' set for interconnection configuration \"\r\n                    \"within %2 is not unique.\")\r\n                    .arg(connectionConfiguration->getInterconnectionReference()).arg(context));\r\n                duplicateNames.append(connectionConfiguration->getInterconnectionReference());\r\n            }\r\n\r\n            interconnectionValidator_->findErrorsIn(errors, connectionConfiguration, context);\r\n            connectionReferences.append(connectionConfiguration->getInterconnectionReference());\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignConfigurationValidator::findErrorsInViewConfigurations()\r\n//-----------------------------------------------------------------------------\r\nvoid DesignConfigurationValidator::findErrorsInViewConfigurations(QVector<QString>& errors,\r\n    QSharedPointer<DesignConfiguration> designConfiguration, QString const& context) const\r\n{\r\n    if (!designConfiguration->getViewConfigurations()->isEmpty())\r\n    {\r\n        if (designConfiguration->getDesignRef().isValid())\r\n        {\r\n            QSharedPointer<Design> referencedDesign =\r\n                libraryHandler_->getDesign(designConfiguration->getDesignRef());\r\n\r\n            if (referencedDesign)\r\n            {\r\n                viewConfigurationValidator_->changeComponentInstances(referencedDesign->getComponentInstances());\r\n            }\r\n\r\n            QVector<QString> instanceNames;\r\n            QVector<QString> duplicateNames;\r\n            for (QSharedPointer<ViewConfiguration> viewConfiguration :\r\n                *designConfiguration->getViewConfigurations())\r\n            {\r\n                if (instanceNames.contains(viewConfiguration->getInstanceName()) &&\r\n                    !duplicateNames.contains(viewConfiguration->getInstanceName()))\r\n                {\r\n                    errors.append(QObject::tr(\"View configuration name '%1' within %2 is not unique.\")\r\n                        .arg(viewConfiguration->getInstanceName()).arg(context));\r\n                    duplicateNames.append(viewConfiguration->getInstanceName());\r\n                }\r\n                else\r\n                {\r\n                    instanceNames.append(viewConfiguration->getInstanceName());\r\n                }\r\n\r\n                viewConfigurationValidator_->findErrorsIn(errors, viewConfiguration, context);\r\n            }\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignConfigurationValidator::findErrorsInParameters()\r\n//-----------------------------------------------------------------------------\r\nvoid DesignConfigurationValidator::findErrorsInParameters(QVector<QString>& errors,\r\n    QSharedPointer<DesignConfiguration> designConfiguration, QString const& context) const\r\n{\r\n    parameterValidator_->setStdRevision(designConfiguration->getRevision());\r\n\r\n    if (!designConfiguration->getParameters()->isEmpty())\r\n    {\r\n        QVector<QString> parameterNames;\r\n        QVector<QString> duplicateNames;\r\n        for (auto const& parameter : *designConfiguration->getParameters())\r\n        {\r\n            if (parameterNames.contains(parameter->name()) && !duplicateNames.contains(parameter->name()))\r\n            {\r\n                errors.append(QObject::tr(\"Parameter name %1 within %2 is not unique.\")\r\n                    .arg(parameter->name(), context));\r\n                duplicateNames.append(parameter->name());\r\n            }\r\n\r\n            parameterNames.append(parameter->name());\r\n            parameterValidator_->findErrorsIn(errors, parameter, context);\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignConfigurationValidator::findErrorsInAssertions()\r\n//-----------------------------------------------------------------------------\r\nvoid DesignConfigurationValidator::findErrorsInAssertions(QVector<QString>& errors,\r\n    QSharedPointer<DesignConfiguration> designConfiguration, QString const& context) const\r\n{\r\n    if (!designConfiguration->getAssertions()->isEmpty())\r\n    {\r\n        QVector<QString> assertionNames;\r\n        QVector<QString> duplicateNames;\r\n        for (auto const& assertion : *designConfiguration->getAssertions())\r\n        {\r\n            if (assertionNames.contains(assertion->name()) && !duplicateNames.contains(assertion->name()))\r\n            {\r\n                errors.append(QObject::tr(\"Assertion name %1 within %2 is not unique.\")\r\n                    .arg(assertion->name(), context));\r\n                duplicateNames.append(assertion->name());\r\n            }\r\n\r\n            assertionNames.append(assertion->name());\r\n            assertionValidator_->findErrorsIn(errors, assertion, context);\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignConfigurationValidator::getViewConfigurationValidator()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<ViewConfigurationValidator> DesignConfigurationValidator::getViewConfigurationValidator() const\r\n{\r\n    return viewConfigurationValidator_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignConfigurationValidator::getLibraryHandler()\r\n//-----------------------------------------------------------------------------\r\nLibraryInterface* DesignConfigurationValidator::getLibraryHandler() const\r\n{\r\n    return libraryHandler_;\r\n}"
  },
  {
    "path": "IPXACTmodels/DesignConfiguration/validators/DesignConfigurationValidator.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: DesignConfigurationValidator.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 11.01.2016\r\n//\r\n// Description:\r\n// Validator for the ipxact:designConfiguration.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef DESIGNCONFIGURATIONVALIDATOR_H\r\n#define DESIGNCONFIGURATIONVALIDATOR_H\r\n\r\n#include <IPXACTmodels/ipxactmodels_global.h>\r\n\r\n#include <QSharedPointer>\r\n#include <QString>\r\n#include <QVector>\r\n\r\nclass DesignConfiguration;\r\n\r\nclass LibraryInterface;\r\nclass ExpressionParser;\r\n\r\nclass ParameterValidator;\r\nclass AssertionValidator;\r\nclass InterconnectionConfigurationValidator;\r\nclass ViewConfigurationValidator;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Validator for the ipxact:designConfiguration.\r\n//-----------------------------------------------------------------------------\r\nclass IPXACTMODELS_EXPORT DesignConfigurationValidator\r\n{\r\npublic:\r\n\r\n    /*!\r\n     *  The constructor.\r\n     *\r\n     *    @param [in] parser      The used expression parser.\r\n     *    @param [in] library     The used library interface.\r\n     */\r\n    DesignConfigurationValidator(QSharedPointer<ExpressionParser> parser, LibraryInterface* library);\r\n\r\n\t//! The destructor.\r\n\tvirtual ~DesignConfigurationValidator();\r\n    \r\n    /*!\r\n     *  Validates the given design configuration.\r\n     *\r\n     *    @param [in] designConfiguration     The selected design configuration.\r\n     *\r\n     *    @return True, if the design configuration is valid IP-XACT, otherwise false.\r\n     */\r\n    bool validate(QSharedPointer<DesignConfiguration> designConfiguration);\r\n\r\n    /*!\r\n     *  Check if the design configuration vlnv is valid.\r\n     *\r\n     *    @param [in] designConfiguration     The selected design configuration.\r\n     *\r\n     *    @return True, if the vlnv is valid, otherwise false.\r\n     */\r\n    bool hasValidVLNV(QSharedPointer<DesignConfiguration> designConfiguration) const;\r\n\r\n    /*!\r\n     *  Check if the design reference is valid.\r\n     *\r\n     *    @param [in] designConfiguration     The selected design configuration.\r\n     *\r\n     *    @return True, if the design reference is valid, otherwise false.\r\n     */\r\n    bool hasValidDesignReference(QSharedPointer<DesignConfiguration> designConfiguration) const;\r\n\r\n    /*!\r\n     *  Check if the generator chain configurations are valid.\r\n     *\r\n     *    @param [in] designConfiguration     The selected design configuration.\r\n     *\r\n     *    @return True, if the generator chain configurations are valid, otherwise false.\r\n     */\r\n    bool hasValidGeneratorChainConfigurations(QSharedPointer<DesignConfiguration> designConfiguration) const;\r\n\r\n    /*!\r\n     *  Check if the interconnection configurations are valid.\r\n     *\r\n     *    @param [in] designConfiguration     The selected design configuration.\r\n     *\r\n     *    @return True, if the interconnection configurations are valid, otherwise false.\r\n     */\r\n    bool hasValidInterconnectionConfigurations(QSharedPointer<DesignConfiguration> designConfiguration) const;\r\n\r\n    /*!\r\n     *  Check if the view configurations are valid.\r\n     *\r\n     *    @param [in] designConfiguration     The selected design configuration.\r\n     *\r\n     *    @return True, if the view configurations are valid, otherwise false.\r\n     */\r\n    virtual bool hasValidViewConfigurations(QSharedPointer<DesignConfiguration> designConfiguration) const;\r\n\r\n    /*!\r\n     *  Check if the parameters are valid.\r\n     *\r\n     *    @param [in] designConfiguration     The selected design configuration.\r\n     *\r\n     *    @return True, if the parameters are valid, otherwise false.\r\n     */\r\n    bool hasValidParameters(QSharedPointer<DesignConfiguration> designConfiguration) const;\r\n\r\n    /*!\r\n     *  Check if the assertions are valid.\r\n     *\r\n     *    @param [in] designConfiguration     The selected design configuration.\r\n     *\r\n     *    @return True, if the assertions are valid, otherwise false.\r\n     */\r\n    bool hasValidAssertions(QSharedPointer<DesignConfiguration> designConfiguration) const;\r\n\r\n    /*!\r\n     *  Locate errors within a design configuration.\r\n     *\r\n     *    @param [in] errors                  List of found errors.\r\n     *    @param [in] designConfiguration     The selected design configuration.\r\n     */\r\n    void findErrorsIn(QVector<QString>& errors, QSharedPointer<DesignConfiguration> designConfiguration);\r\n\r\nprotected:\r\n\r\n    /*!\r\n     *  Get the view configuration validator.\r\n     *\r\n     *    @return The used view configuration validator.\r\n     */\r\n    QSharedPointer<ViewConfigurationValidator> getViewConfigurationValidator() const;\r\n\r\n    /*!\r\n     *  Get the library interface.\r\n     *\r\n     *    @return The used library interface.\r\n     */\r\n    LibraryInterface* getLibraryHandler() const;\r\n\r\nprivate:\r\n\r\n\t// Disable copying.\r\n\tDesignConfigurationValidator(DesignConfigurationValidator const& rhs);\r\n\tDesignConfigurationValidator& operator=(DesignConfigurationValidator const& rhs);\r\n\r\n    /*!\r\n     *  Find errors in design configuration VLNV.\r\n     *\r\n     *    @param [in] errors                  List of found errors.\r\n     *    @param [in] designConfiguration     The selected design configuration.\r\n     */\r\n    void findErrorsInVLNV(QVector<QString>& errors, QSharedPointer<DesignConfiguration> designConfiguration) const;\r\n\r\n    /*!\r\n     *  Find errors in design reference.\r\n     *\r\n     *    @param [in] errors                  List of found errors.\r\n     *    @param [in] designConfiguration     The selected design configuration.\r\n     *    @param [in] context                 Context to help locate the errors.\r\n     */\r\n    void findErrorsInDesignReference(QVector<QString>& errors,\r\n        QSharedPointer<DesignConfiguration> designConfiguration, QString const& context) const;\r\n\r\n    /*!\r\n     *  Find errors in generator chain configurations.\r\n     *\r\n     *    @param [in] errors                  List of found errors.\r\n     *    @param [in] designConfiguration     The selected design configuration.\r\n     *    @param [in] context                 Context to help locate the errors.\r\n     */\r\n    void findErrorsInGeneratorChainConfigurations(QVector<QString>& errors,\r\n        QSharedPointer<DesignConfiguration> designConfiguration, QString const& context) const;\r\n\r\n    /*!\r\n     *  Find errors in interconnection configurations.\r\n     *\r\n     *    @param [in] errors                  List of found errors.\r\n     *    @param [in] designConfiguration     The selected design configuration.\r\n     *    @param [in] context                 Context to help locate the errors.\r\n     */\r\n    void findErrorsInInterconnectionConfigurations(QVector<QString>& errors,\r\n        QSharedPointer<DesignConfiguration> designConfiguration, QString const& context) const;\r\n\r\n    /*!\r\n     *  Find errors in view configurations.\r\n     *\r\n     *    @param [in] errors                  List of found errors.\r\n     *    @param [in] designConfiguration     The selected design configuration.\r\n     *    @param [in] context                 Context to help locate the errors.\r\n     */\r\n    virtual void findErrorsInViewConfigurations(QVector<QString>& errors,\r\n        QSharedPointer<DesignConfiguration> designConfiguration, QString const& context) const;\r\n\r\n    /*!\r\n     *  Find errors in parameters.\r\n     *\r\n     *    @param [in] errors                  List of found errors.\r\n     *    @param [in] designConfiguration     The selected design configuration.\r\n     *    @param [in] context                 Context to help locate the errors.\r\n     */\r\n    void findErrorsInParameters(QVector<QString>& errors, QSharedPointer<DesignConfiguration> designConfiguration,\r\n        QString const& context) const;\r\n\r\n    /*!\r\n     *  Find errors in assertions.\r\n     *\r\n     *    @param [in] errors                  List of found errors.\r\n     *    @param [in] designConfiguration     The selected design configuration.\r\n     *    @param [in] context                 Context to help locate the errors.\r\n     */\r\n    void findErrorsInAssertions(QVector<QString>& errors, QSharedPointer<DesignConfiguration> designConfiguration,\r\n        QString const& context) const;\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! The used library interface.\r\n    LibraryInterface* libraryHandler_;\r\n\r\n    //! The used parameter validator.\r\n    QSharedPointer<ParameterValidator> parameterValidator_;\r\n\r\n    //! The used assertion validator.\r\n    QSharedPointer<AssertionValidator> assertionValidator_;\r\n\r\n    //! The used interconnection configuration validator.\r\n    QSharedPointer<InterconnectionConfigurationValidator> interconnectionValidator_;\r\n\r\n    //! The used view configuration validator.\r\n    QSharedPointer<ViewConfigurationValidator> viewConfigurationValidator_;\r\n\r\n    //! The used expression parser.\r\n    QSharedPointer<ExpressionParser> expressionParser_;\r\n};\r\n\r\n#endif // DESIGNCONFIGURATIONVALIDATOR_H\r\n"
  },
  {
    "path": "IPXACTmodels/DesignConfiguration/validators/InterconnectionConfigurationValidator.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: InterconnectionConfigurationValidator.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 11.01.2016\r\n//\r\n// Description:\r\n// Validator for the ipxact:interconnectionConfiguration.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"InterconnectionConfigurationValidator.h\"\r\n\r\n#include <IPXACTmodels/DesignConfiguration/InterconnectionConfiguration.h>\r\n\r\n#include <KactusAPI/include/LibraryInterface.h>\r\n\r\n#include <IPXACTmodels/Design/Design.h>\r\n#include <IPXACTmodels/Design/Interconnection.h>\r\n#include <IPXACTmodels/Design/MonitorInterconnection.h>\r\n#include <IPXACTmodels/Design/ComponentInstance.h>\r\n\r\n#include <IPXACTmodels/Component/Component.h>\r\n#include <IPXACTmodels/Component/BusInterface.h>\r\n\r\n#include <IPXACTmodels/common/validators/CommonItemsValidator.h>\r\n\r\n#include <KactusAPI/include/ExpressionParser.h>\r\n\r\n#include <QRegularExpression>\r\n//-----------------------------------------------------------------------------\r\n// Function: InterconnectionConfigurationValidator::InterconnectionConfigurationValidator()\r\n//-----------------------------------------------------------------------------\r\n//-----------------------------------------------------------------------------\r\nInterconnectionConfigurationValidator::InterconnectionConfigurationValidator(\r\n    QSharedPointer<ExpressionParser> parser, LibraryInterface* library ):\r\nparser_(parser),\r\nlibraryHandler_(library),\r\navailableInterconnections_(),\r\navailableMonitorInterconnections_(),\r\navailableComponentInstances_(),\r\navailableBusInterfaces_()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: InterconnectionConfigurationValidator::designChanged()\r\n//-----------------------------------------------------------------------------\r\nInterconnectionConfigurationValidator::~InterconnectionConfigurationValidator()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: InterconnectionConfigurationValidator::designChanged()\r\n//-----------------------------------------------------------------------------\r\nvoid InterconnectionConfigurationValidator::designChanged(QSharedPointer<Design> newDesign)\r\n{\r\n    availableInterconnections_ = newDesign->getInterconnections();\r\n    availableMonitorInterconnections_ = newDesign->getMonitorInterconnecions();\r\n    availableComponentInstances_ = newDesign->getComponentInstances();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: InterconnectionConfigurationValidator::validate()\r\n//-----------------------------------------------------------------------------\r\nbool InterconnectionConfigurationValidator::validate(QSharedPointer<InterconnectionConfiguration> configuration)\r\n{\r\n    return hasValidInterconnectionReference(configuration) && \r\n        hasValidIsPresent(configuration->getIsPresent()) &&\r\n        hasValidMultipleAbstractorInstances(configuration);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: InterconnectionConfigurationValidator::hasValidInterconnectionReference()\r\n//-----------------------------------------------------------------------------\r\nbool InterconnectionConfigurationValidator::hasValidInterconnectionReference(\r\n    QSharedPointer<InterconnectionConfiguration> configuration) const\r\n{\r\n    auto matchReference = [configuration](auto const& connection)\r\n    {\r\n        return (configuration->getInterconnectionReference() == connection->name());\r\n    };\r\n\r\n    if (availableInterconnections_)\r\n    {\r\n        auto hasConnection = std::any_of(availableInterconnections_->cbegin(), availableInterconnections_->cend(), matchReference);\r\n        if (hasConnection)\r\n        {\r\n            return true;\r\n        }\r\n    }\r\n\r\n    if (availableMonitorInterconnections_)\r\n    {\r\n        auto hasMonitorConnection = std::any_of(availableMonitorInterconnections_->cbegin(), \r\n            availableMonitorInterconnections_->cend(), matchReference);\r\n\r\n        return hasMonitorConnection;\r\n    }\r\n\r\n    return false;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: InterconnectionConfigurationValidator::hasValidIsPresent()\r\n//-----------------------------------------------------------------------------\r\nbool InterconnectionConfigurationValidator::hasValidIsPresent(QString const& isPresent) const\r\n{\r\n    return CommonItemsValidator::hasValidIsPresent(isPresent, parser_);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: InterconnectionConfigurationValidator::hasValidAbstractorInstances()\r\n//-----------------------------------------------------------------------------\r\nbool InterconnectionConfigurationValidator::hasValidMultipleAbstractorInstances(\r\n    QSharedPointer<InterconnectionConfiguration> configuration)\r\n{\r\n    if (!configuration->getAbstractorInstances() || configuration->getAbstractorInstances()->isEmpty())\r\n    {\r\n        return false;\r\n    }\r\n\r\n    return std::all_of(configuration->getAbstractorInstances()->cbegin(), configuration->getAbstractorInstances()->cend(),\r\n        [this](auto const& instance) { return multipleAbstractorInstanceIsValid(instance); });\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: InterconnectionConfigurationValidator::hasValidMultipleAbstractorInstance()\r\n//-----------------------------------------------------------------------------\r\nbool InterconnectionConfigurationValidator::multipleAbstractorInstanceIsValid(\r\n    QSharedPointer<MultipleAbstractorInstances> multipleInstance)\r\n{\r\n    if (!multipleInstance->getAbstractorInstances() || multipleInstance->getAbstractorInstances()->isEmpty() ||\r\n        !hasValidIsPresent(multipleInstance->getIsPresent()) || !hasValidInterfaceReferences(multipleInstance))\r\n    {\r\n        return false;\r\n    }\r\n\r\n    QVector<QString> instanceNames;\r\n    foreach (QSharedPointer<AbstractorInstance> instance, *multipleInstance->getAbstractorInstances())\r\n    {\r\n        if (instanceNames.contains(instance->getInstanceName()) || !abstractorInstanceIsValid(instance))\r\n        {\r\n            return false;\r\n        }\r\n        else\r\n        {\r\n            instanceNames.append(instance->getInstanceName());\r\n        }\r\n    }\r\n\r\n    return true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: InterconnectionConfigurationValidator::interfaceReferenceIsValid()\r\n//-----------------------------------------------------------------------------\r\nbool InterconnectionConfigurationValidator::hasValidInterfaceReferences(\r\n    QSharedPointer<MultipleAbstractorInstances> multipleInstance)\r\n{\r\n    if (multipleInstance->getInterfaceReferences())\r\n    {\r\n        return std::all_of(multipleInstance->getInterfaceReferences()->cbegin(),\r\n            multipleInstance->getInterfaceReferences()->cend(),\r\n            [this](auto const& interfaceReference)\r\n        {\r\n            return interfaceReferenceComponentReferenceIsValid(interfaceReference) &&\r\n                interfaceReferenceBusReferenceIsValid(interfaceReference) &&\r\n                hasValidIsPresent(interfaceReference->getIsPresent());\r\n        });\r\n    }\r\n\r\n    return true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: InterconnectionConfigurationValidator::interfaceReferenceComponentReferenceIsValid()\r\n//-----------------------------------------------------------------------------\r\nbool InterconnectionConfigurationValidator::interfaceReferenceComponentReferenceIsValid(\r\n    QSharedPointer<InterfaceRef> interfaceReference) const\r\n{\r\n    auto componentRef = interfaceReference->getComponentRef();\r\n    if (componentRef.isEmpty() == false && availableComponentInstances_)\r\n    {\r\n        return std::any_of(availableComponentInstances_->cbegin(), availableComponentInstances_->cend(),\r\n            [&componentRef](auto const& instance)\r\n        {\r\n            return instance->getInstanceName() == componentRef;\r\n        });\r\n    }\r\n\r\n    return false;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: InterconnectionConfigurationValidator::interfaceReferenceBusReferenceIsValid()\r\n//-----------------------------------------------------------------------------\r\nbool InterconnectionConfigurationValidator::interfaceReferenceBusReferenceIsValid(\r\n    QSharedPointer<InterfaceRef> interfaceReference)\r\n{\r\n    changeAvailableBusInterfaces(interfaceReference);\r\n\r\n    auto busRef = interfaceReference->getBusRef();\r\n    if (busRef.isEmpty() == false && availableBusInterfaces_)\r\n    {\r\n        return std::any_of(availableBusInterfaces_->cbegin(), availableBusInterfaces_->cend(),\r\n            [&busRef](auto const& currentInterface)\r\n        {\r\n            return currentInterface->name() == busRef;\r\n        });\r\n    }\r\n\r\n    return false;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: InterconnectionConfigurationValidator::changeAvailableBusInterfaces()\r\n//-----------------------------------------------------------------------------\r\nvoid InterconnectionConfigurationValidator::changeAvailableBusInterfaces(\r\n    QSharedPointer<InterfaceRef> interfaceReference)\r\n{\r\n    if (availableComponentInstances_)\r\n    {\r\n        for (QSharedPointer<ComponentInstance> instance : *availableComponentInstances_)\r\n        {\r\n            if (instance->getInstanceName() == interfaceReference->getComponentRef())\r\n            {\r\n                if (instance->getComponentRef() && instance->getComponentRef()->isValid())\r\n                {\r\n                    QSharedPointer<Component> referencedComponent =\r\n                        libraryHandler_->getModel(*instance->getComponentRef()).dynamicCast<Component>();\r\n\r\n                    if (referencedComponent)\r\n                    {\r\n                        availableBusInterfaces_ = referencedComponent->getBusInterfaces();\r\n                        return;\r\n                    }\r\n                }\r\n\r\n                break;\r\n            }\r\n        }\r\n    }\r\n\r\n    if (availableBusInterfaces_)\r\n    {\r\n        availableBusInterfaces_->clear();\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: InterconnectionConfigurationValidator::abstractorInstanceIsValid()\r\n//-----------------------------------------------------------------------------\r\nbool InterconnectionConfigurationValidator::abstractorInstanceIsValid(QSharedPointer<AbstractorInstance> instance)\r\n    const\r\n{\r\n    return hasValidName(instance->getInstanceName()) &&\r\n        instance->getAbstractorRef()->getType() == VLNV::ABSTRACTOR && instance->getAbstractorRef()->isValid() &&\r\n        hasValidName(instance->getViewName());\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: InterconnectionConfigurationValidator::hasValidName()\r\n//-----------------------------------------------------------------------------\r\nbool InterconnectionConfigurationValidator::hasValidName(QString const& name) const\r\n{\r\n    return CommonItemsValidator::hasValidName(name);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: InterconnectionConfigurationValidator::findErrorsIn()\r\n//-----------------------------------------------------------------------------\r\nvoid InterconnectionConfigurationValidator::findErrorsIn(QVector<QString>& errors,\r\n    QSharedPointer<InterconnectionConfiguration> configuration, QString const& context)\r\n{\r\n    QString interconnectionContext = QObject::tr(\"interconnection configuration %1\")\r\n        .arg(configuration->getInterconnectionReference());\r\n\r\n    findErrorsInInterconnectionReference(errors, configuration, context);\r\n    findErrorsInIsPresent(errors, configuration->getIsPresent(), interconnectionContext, context);\r\n    findErrorsInMultipleAbstractorInstances(errors, configuration, interconnectionContext, context);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: InterconnectionConfigurationValidator::findErrorsInInterconnectionReference()\r\n//-----------------------------------------------------------------------------\r\nvoid InterconnectionConfigurationValidator::findErrorsInInterconnectionReference(QVector<QString>& errors,\r\n    QSharedPointer<InterconnectionConfiguration> configuration, QString const& context) const\r\n{\r\n    if (!hasValidInterconnectionReference(configuration))\r\n    {\r\n        errors.append(QObject::tr(\"Invalid interconnection reference '%1' given for interconnection configuration \"\r\n            \"within %2.\").arg(configuration->getInterconnectionReference()).arg(context));\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: InterconnectionConfigurationValidator::findErrorsInIsPresent()\r\n//-----------------------------------------------------------------------------\r\nvoid InterconnectionConfigurationValidator::findErrorsInIsPresent(QVector<QString>& errors,\r\n    QString const& isPresent, QString const& innerContext, QString const& context) const\r\n{\r\n    if (!hasValidIsPresent(isPresent))\r\n    {\r\n        errors.append(QObject::tr(\"Invalid isPresent set for %1 within %2\").arg(innerContext).arg(context));\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: InterconnectionConfigurationValidator::findErrorsInMultipleAbstractorInstances()\r\n//-----------------------------------------------------------------------------\r\nvoid InterconnectionConfigurationValidator::findErrorsInMultipleAbstractorInstances(QVector<QString>& errors,\r\n    QSharedPointer<InterconnectionConfiguration> configuration, QString const& innerContext,\r\n    QString const& context)\r\n{\r\n    if (!configuration->getAbstractorInstances() || configuration->getAbstractorInstances()->isEmpty())\r\n    {\r\n        errors.append(QObject::tr(\"No abstractor instances found in interconnection configuration '%1' within %2\")\r\n            .arg(configuration->getInterconnectionReference()).arg(context));\r\n    }\r\n\r\n    for (QSharedPointer<MultipleAbstractorInstances> multipleInstance : *configuration->getAbstractorInstances())\r\n    {\r\n        findErrorsInOneMultipleAbstractorInstance(errors, multipleInstance, innerContext);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: InterconnectionConfigurationValidator::findErrorsInOneMultipleAbstractorInstance()\r\n//-----------------------------------------------------------------------------\r\nvoid InterconnectionConfigurationValidator::findErrorsInOneMultipleAbstractorInstance(QVector<QString>& errors,\r\n    QSharedPointer<MultipleAbstractorInstances> multipleInstance, QString const& context)\r\n{\r\n    QString multipleInstanceContext = QObject::tr(\"abstractor instance group\");\r\n    findErrorsInIsPresent(errors, multipleInstance->getIsPresent(), multipleInstanceContext, context);\r\n\r\n    for (QSharedPointer<InterfaceRef> interfaceReference : *multipleInstance->getInterfaceReferences())\r\n    {\r\n        if (!interfaceReferenceComponentReferenceIsValid(interfaceReference))\r\n        {\r\n            errors.append(QObject::tr(\"Invalid component instance reference '%1' set for %2 within %3\")\r\n                .arg(interfaceReference->getComponentRef()).arg(multipleInstanceContext).arg(context));\r\n        }\r\n        if (!interfaceReferenceBusReferenceIsValid(interfaceReference))\r\n        {\r\n            errors.append(QObject::tr(\"Invalid bus interface reference '%1' set for %2 within %3\")\r\n                .arg(interfaceReference->getBusRef()).arg(multipleInstanceContext).arg(context));\r\n        }\r\n        if (!hasValidIsPresent(interfaceReference->getIsPresent()))\r\n        {\r\n            errors.append(QObject::tr(\"Invalid isPresent set for interface reference in %1 within %2\")\r\n                .arg(multipleInstanceContext).arg(context));\r\n        }\r\n    }\r\n\r\n    if (!multipleInstance->getAbstractorInstances() || multipleInstance->getAbstractorInstances()->isEmpty())\r\n    {\r\n        errors.append(QObject::tr(\"No abstractor instances found in %1 within %2\")\r\n            .arg(multipleInstanceContext).arg(context));\r\n    }\r\n    else\r\n    {\r\n        QVector<QString> instanceNames;\r\n        QVector<QString> duplicateNames;\r\n        for (QSharedPointer<AbstractorInstance> instance : *multipleInstance->getAbstractorInstances())\r\n        {\r\n            if (instanceNames.contains(instance->getInstanceName()) &&\r\n                !duplicateNames.contains(instance->getInstanceName()))\r\n            {\r\n                errors.append(QObject::tr(\"Abstractor instance name '%1' within %2 is not unique.\")\r\n                    .arg(instance->getInstanceName()).arg(context));\r\n\r\n                duplicateNames.append(instance->getInstanceName());\r\n            }\r\n\r\n            instanceNames.append(instance->getInstanceName());\r\n            findErrorsInAbstractorInstance(errors, instance, context);\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: InterconnectionConfigurationValidator::findErrorsInAbstractorInstance()\r\n//-----------------------------------------------------------------------------\r\nvoid InterconnectionConfigurationValidator::findErrorsInAbstractorInstance(QVector<QString>& errors,\r\n    QSharedPointer<AbstractorInstance> instance, QString const& context) const\r\n{\r\n    if (!hasValidName(instance->getInstanceName()))\r\n    {\r\n        errors.append(QObject::tr(\"Invalid instance name '%1' set for abstractor instance within %2\")\r\n            .arg(instance->getInstanceName()).arg(context));\r\n    }\r\n\r\n    QString abstractorContext = QObject::tr(\"abstractor instance %1\").arg(instance->getInstanceName());\r\n\r\n    instance->getAbstractorRef()->isValid(errors, abstractorContext);\r\n\r\n    if (!hasValidName(instance->getViewName()))\r\n    {\r\n        errors.append(QObject::tr(\"Invalid view name '%1' set for abstractor instance %2 within %3\")\r\n            .arg(instance->getViewName()).arg(instance->getInstanceName()).arg(context));\r\n    }\r\n}\r\n"
  },
  {
    "path": "IPXACTmodels/DesignConfiguration/validators/InterconnectionConfigurationValidator.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: InterconnectionConfigurationValidator.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 11.01.2016\r\n//\r\n// Description:\r\n// Validator for the ipxact:interconnectionConfiguration.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef INTERCONNECTIONCONFIGURATIONVALIDATOR_H\r\n#define INTERCONNECTIONCONFIGURATIONVALIDATOR_H\r\n\r\n#include <IPXACTmodels/ipxactmodels_global.h>\r\n\r\n#include <QSharedPointer>\r\n#include <QString>\r\n#include <QVector>\r\n\r\nclass InterconnectionConfiguration;\r\nclass MultipleAbstractorInstances;\r\nclass AbstractorInstance;\r\nclass InterfaceRef;\r\n\r\nclass ExpressionParser;\r\n\r\nclass LibraryInterface;\r\n\r\nclass Design;\r\n\r\nclass Interconnection;\r\nclass MonitorInterconnection;\r\nclass ComponentInstance;\r\nclass BusInterface;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Validator for the ipxact:interconnectionConfiguration.\r\n//-----------------------------------------------------------------------------\r\nclass IPXACTMODELS_EXPORT InterconnectionConfigurationValidator\r\n{\r\npublic:\r\n\r\n    /*!\r\n     *  The constructor.\r\n     *\r\n     *    @param [in] parser      The used expression parser.\r\n     *    @param [in] library     The used library interface.\r\n     */\r\n    InterconnectionConfigurationValidator(QSharedPointer<ExpressionParser> parser, LibraryInterface* library);\r\n\r\n\t//! The destructor.\r\n\t~InterconnectionConfigurationValidator();\r\n    \r\n    /*!\r\n     *  Change the available elements contained in a design.\r\n     *\r\n     *    @param [in] newDesign   The new design.\r\n     */\r\n    void designChanged(QSharedPointer<Design> newDesign);\r\n\r\n    /*!\r\n     *  Validates the given interconnection configuration.\r\n     *\r\n     *    @param [in] configuration   The selected interconnection configuration.\r\n     *\r\n     *    @return True, if the interconnection configuration is valid IP-XACT, otherwise false.\r\n     */\r\n    bool validate(QSharedPointer<InterconnectionConfiguration> configuration);\r\n\r\n    /*!\r\n     *  Check if the interconnection reference is valid.\r\n     *\r\n     *    @param [in] configuration   The selected interconnection configuration.\r\n     *\r\n     *    @return True, if the interconnection reference is valid, otherwise false.\r\n     */\r\n    bool hasValidInterconnectionReference(QSharedPointer<InterconnectionConfiguration> configuration) const;\r\n\r\n    /*!\r\n     *  Check if the is present value is valid.\r\n     *\r\n     *    @param [in] isPresent   The selected is present value.\r\n     *\r\n     *    @return True, if the is present value is valid, otherwise false.\r\n     */\r\n    bool hasValidIsPresent(QString const& isPresent) const;\r\n\r\n    /*!\r\n     *  Check if the multiple abstractor instances are valid.\r\n     *\r\n     *    @param [in] configuration   The selected interconnection configuration.\r\n     *\r\n     *    @return True, if the multiple abstractor instances are valid, otherwise false.\r\n     */\r\n    bool hasValidMultipleAbstractorInstances(QSharedPointer<InterconnectionConfiguration> configuration);\r\n\r\n    /*!\r\n     *  Locate errors within an interconnection configuration.\r\n     *\r\n     *    @param [in] errors          List of found errors.\r\n     *    @param [in] configuration   The selected interconnection configuration.\r\n     *    @param [in] context         Context to help locate the errors.\r\n     */\r\n    void findErrorsIn(QVector<QString>& errors, QSharedPointer<InterconnectionConfiguration> configuration,\r\n        QString const& context);\r\n\r\nprivate:\r\n\r\n\t// Disable copying.\r\n\tInterconnectionConfigurationValidator(InterconnectionConfigurationValidator const& rhs);\r\n\tInterconnectionConfigurationValidator& operator=(InterconnectionConfigurationValidator const& rhs);\r\n\r\n    /*!\r\n     *  Check if a multiple abstractor instance is valid.\r\n     *\r\n     *    @param [in] multipleInstance    The selected multiple abstractor instance.\r\n     *\r\n     *    @return True, if the multiple abstractor instance is valid, otherwise false.\r\n     */\r\n    bool multipleAbstractorInstanceIsValid(QSharedPointer<MultipleAbstractorInstances> multipleInstance);\r\n\r\n    /*!\r\n     *  Check if a multiple abstractor instance interface references are valid.\r\n     *\r\n     *    @param [in] multipleInstance    The selected multiple abstractor instance.\r\n     *\r\n     *    @return True, if the multiple abstractor instance interface references are valid, otherwise false.\r\n     */\r\n    bool hasValidInterfaceReferences(QSharedPointer<MultipleAbstractorInstances> multipleInstance);\r\n\r\n    /*!\r\n     *  Check if an interface reference component reference valid.\r\n     *\r\n     *    @param [in] interfaceReference  The selected interface reference.\r\n     *\r\n     *    @return True, if the interface reference component reference is valid, otherwise false.\r\n     */\r\n    bool interfaceReferenceComponentReferenceIsValid(QSharedPointer<InterfaceRef> interfaceReference) const;\r\n\r\n    /*!\r\n     *  Check if an interface reference bus reference is valid.\r\n     *\r\n     *    @param [in] interfaceReference  The selected interface reference.\r\n     *\r\n     *    @return True, if the interface reference bus reference is valid, otherwise false.\r\n     */\r\n    bool interfaceReferenceBusReferenceIsValid(QSharedPointer<InterfaceRef> interfaceReference);\r\n\r\n    /*!\r\n     *  Change the currently available bus interfaces.\r\n     *\r\n     *    @param [in] interfaceReference  The selected interface reference.\r\n     */\r\n    void changeAvailableBusInterfaces(QSharedPointer<InterfaceRef> interfaceReference);\r\n\r\n    /*!\r\n     *  Check if an abstractor instance is valid.\r\n     *\r\n     *    @param [in] instance    The selected abstractor instance.\r\n     *\r\n     *    @return True, if the abstractor instance is valid, otherwise false.\r\n     */\r\n    bool abstractorInstanceIsValid(QSharedPointer<AbstractorInstance> instance) const;\r\n\r\n    /*!\r\n     *  Check if a name is valid.\r\n     *\r\n     *    @param [in] name    The selected name.\r\n     *\r\n     *    @return True, if the name is valid, otherwise false.\r\n     */\r\n    bool hasValidName(QString const& name) const;\r\n\r\n    /*!\r\n     *  Find errors in interconnection reference.\r\n     *\r\n     *    @param [in] errors          List of found errors.\r\n     *    @param [in] configuration   The selected interconnection configuration.\r\n     *    @param [in] context         Context to help locate the errors.\r\n     */\r\n    void findErrorsInInterconnectionReference(QVector<QString>& errors,\r\n        QSharedPointer<InterconnectionConfiguration> configuration, QString const& context) const;\r\n\r\n    /*!\r\n     *  Find errors in is present value.\r\n     *\r\n     *    @param [in] errors      List of found errors.\r\n     *    @param [in] isPresent   The selected is present value.\r\n     *    @param [in] context     Context to help locate the errors.\r\n     */\r\n    void findErrorsInIsPresent(QVector<QString>& errors, QString const& isPresent,\r\n        QString const& innerContext, QString const& context) const;\r\n\r\n    /*!\r\n     *  Find errors in multiple abstractor instances.\r\n     *\r\n     *    @param [in] errors          List of found errors.\r\n     *    @param [in] configuration   The selected interconnection configuration.\r\n     *    @param [in] innerContext    Context of the interconnection configuration to help locate the errors.\r\n     *    @param [in] context         Context to help locate the errors.\r\n     */\r\n    void findErrorsInMultipleAbstractorInstances(QVector<QString>& errors,\r\n        QSharedPointer<InterconnectionConfiguration> configuration, QString const& innerContext,\r\n        QString const& context);\r\n\r\n    /*!\r\n     *  Find errors in a single multiple abstractor instance.\r\n     *\r\n     *    @param [in] errors              List of found errors.\r\n     *    @param [in] multipleInstance    The selected multiple abstractor instance.\r\n     *    @param [in] context             Context to help locate the errors.\r\n     */\r\n    void findErrorsInOneMultipleAbstractorInstance(QVector<QString>& errors,\r\n        QSharedPointer<MultipleAbstractorInstances> multipleInstance, QString const& context);\r\n\r\n    /*!\r\n     *  Find errors in an abstractor instance.\r\n     *\r\n     *    @param [in] errors      List of found errors.\r\n     *    @param [in] instance    The selected abstractor instance.\r\n     *    @param [in] context     Context to help locate the errors.\r\n     */\r\n    void findErrorsInAbstractorInstance(QVector<QString>& errors, QSharedPointer<AbstractorInstance> instance,\r\n        QString const& context) const;\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! The used expression parser.\r\n    QSharedPointer<ExpressionParser> parser_;\r\n\r\n    //! The used library interface.\r\n    LibraryInterface* libraryHandler_;\r\n\r\n    //! The currently available interconnections.\r\n    QSharedPointer<QList<QSharedPointer<Interconnection> > > availableInterconnections_;\r\n    \r\n    //! The currently available monitor interconnections.\r\n    QSharedPointer<QList<QSharedPointer<MonitorInterconnection> > > availableMonitorInterconnections_;\r\n\r\n    //! The currently available component instances.\r\n    QSharedPointer<QList<QSharedPointer<ComponentInstance> > > availableComponentInstances_;\r\n\r\n    //! The currently available bus interfaces.\r\n    QSharedPointer<QList<QSharedPointer<BusInterface> > > availableBusInterfaces_;\r\n};\r\n\r\n#endif // INTERCONNECTIONCONFIGURATIONVALIDATOR_H\r\n"
  },
  {
    "path": "IPXACTmodels/DesignConfiguration/validators/ViewConfigurationValidator.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ViewConfigurationValidator.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 13.01.2016\r\n//\r\n// Description:\r\n// Validator for the ipxact:viewConfiguration.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"ViewConfigurationValidator.h\"\r\n\r\n#include <KactusAPI/include/LibraryInterface.h>\r\n\r\n#include <IPXACTmodels/DesignConfiguration/ViewConfiguration.h>\r\n\r\n#include <IPXACTmodels/Design/ComponentInstance.h>\r\n\r\n#include <IPXACTmodels/Component/Component.h>\r\n#include <IPXACTmodels/Component/View.h>\r\n\r\n#include <IPXACTmodels/common/validators/CommonItemsValidator.h>\r\n\r\n#include <KactusAPI/include/ExpressionParser.h>\r\n\r\n#include <QRegularExpression>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ViewConfigurationValidator::ViewConfigurationValidator()\r\n//-----------------------------------------------------------------------------\r\nViewConfigurationValidator::ViewConfigurationValidator(LibraryInterface* library,\r\n    QSharedPointer<ExpressionParser> parser):\r\nlibraryHandler_(library),\r\nparser_(parser)\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ViewConfigurationValidator::~ViewConfigurationValidator()\r\n//-----------------------------------------------------------------------------\r\nViewConfigurationValidator::~ViewConfigurationValidator()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ViewConfigurationValidator::changeComponentInstances()\r\n//-----------------------------------------------------------------------------\r\nvoid ViewConfigurationValidator::changeComponentInstances(\r\n    QSharedPointer<QList<QSharedPointer<ComponentInstance> > > newInstances)\r\n{\r\n    availableInstances_ = newInstances;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ViewConfigurationValidator::validate()\r\n//-----------------------------------------------------------------------------\r\nbool ViewConfigurationValidator::validate(QSharedPointer<ViewConfiguration> configuration)\r\n{\r\n    return hasValidName(configuration) && hasValidIsPresent(configuration) && hasValidViewReference(configuration);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ViewConfigurationValidator::hasValidName()\r\n//-----------------------------------------------------------------------------\r\nbool ViewConfigurationValidator::hasValidName(QSharedPointer<ViewConfiguration> configuration) const\r\n{\r\n    if (auto nameInConfiguration = configuration->getInstanceName(); \r\n        nameInConfiguration.isEmpty() == false && availableInstances_)\r\n    {\r\n        for (auto const& instance : *availableInstances_)\r\n        {\r\n            if (auto instanceName = instance->getInstanceName(); instanceName == nameInConfiguration)\r\n            {\r\n                return CommonItemsValidator::hasValidName(instanceName);\r\n            }\r\n        }\r\n    }\r\n\r\n    return false;\r\n}\r\n\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ViewConfigurationValidator::hasValidIsPresent()\r\n//-----------------------------------------------------------------------------\r\nbool ViewConfigurationValidator::hasValidIsPresent(QSharedPointer<ViewConfiguration> configuration) const\r\n{\r\n    return CommonItemsValidator::hasValidIsPresent(configuration->getIsPresent(), parser_);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ViewConfigurationValidator::hasValidViewReference()\r\n//-----------------------------------------------------------------------------\r\nbool ViewConfigurationValidator::hasValidViewReference(QSharedPointer<ViewConfiguration> configuration)\r\n{\r\n    changeAvailableViews(configuration);\r\n\r\n    if (auto viewReference = configuration->getViewReference(); viewReference.isEmpty() == false)\r\n    {\r\n        return std::any_of(availableViews_.cbegin(), availableViews_.cend(), \r\n            [&viewReference](auto const& view){ return view == viewReference; });\r\n    }\r\n\r\n    return false;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ViewConfigurationValidator::changeAvailableViews()\r\n//-----------------------------------------------------------------------------\r\nvoid ViewConfigurationValidator::changeAvailableViews(QSharedPointer<ViewConfiguration> configuration)\r\n{\r\n    if (configuration->getInstanceName().isEmpty() == false && availableInstances_)\r\n    {\r\n        for (auto const& instance : *availableInstances_)\r\n        {\r\n            if (instance->getInstanceName() == configuration->getInstanceName())\r\n            {\r\n                if (instance->getComponentRef() && instance->getComponentRef()->isValid())\r\n                {\r\n                    auto component =\r\n                        libraryHandler_->getModelReadOnly<Component>(*instance->getComponentRef());\r\n\r\n                    if (component)\r\n                    {\r\n                        availableViews_.clear();\r\n                        for (auto const& view : component->getViewNames())\r\n                        {\r\n                            availableViews_.append(view);\r\n                        }\r\n\r\n                        return;\r\n                    }\r\n                }\r\n\r\n                break;\r\n            }\r\n        }\r\n    }\r\n\r\n    availableViews_.clear();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ViewConfigurationValidator::findErrorsIn()\r\n//-----------------------------------------------------------------------------\r\nvoid ViewConfigurationValidator::findErrorsIn(QVector<QString>& errors,\r\n    QSharedPointer<ViewConfiguration> configuration, QString const& context)\r\n{\r\n    findErrorsInName(errors, configuration, context);\r\n    findErrorsInIsPresent(errors, configuration, context);\r\n    findErrorsInViewReference(errors, configuration, context);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ViewConfigurationValidator::findErrorsInName()\r\n//-----------------------------------------------------------------------------\r\nvoid ViewConfigurationValidator::findErrorsInName(QVector<QString>& errors,\r\n    QSharedPointer<ViewConfiguration> configuration, QString const& context) const\r\n{\r\n    if (!hasValidName(configuration))\r\n    {\r\n        errors.append(QObject::tr(\"Invalid name '%1' set for view configuration within %2\")\r\n            .arg(configuration->getInstanceName()).arg(context));\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ViewConfigurationValidator::findErrorsInIsPresent()\r\n//-----------------------------------------------------------------------------\r\nvoid ViewConfigurationValidator::findErrorsInIsPresent(QVector<QString>& errors,\r\n    QSharedPointer<ViewConfiguration> configuration, QString const& context) const\r\n{\r\n    if (!hasValidIsPresent(configuration))\r\n    {\r\n        errors.append(QObject::tr(\"Invalid isPresent set for view configuration %1 within %2\")\r\n            .arg(configuration->getInstanceName(), context));\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ViewConfigurationValidator::findErrorsInViewReference()\r\n//-----------------------------------------------------------------------------\r\nvoid ViewConfigurationValidator::findErrorsInViewReference(QVector<QString>& errors,\r\n    QSharedPointer<ViewConfiguration> configuration, QString const& context)\r\n{\r\n    if (!hasValidViewReference(configuration))\r\n    {\r\n        errors.append(QObject::tr(\"Invalid view reference '%1' set for view configuration %2 within %3\").arg(\r\n            configuration->getViewReference(),\r\n            configuration->getInstanceName(),\r\n            context));\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ViewConfigurationValidator::getAvailableInstances()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<QList<QSharedPointer<ComponentInstance> > > ViewConfigurationValidator::getAvailableInstances()\r\n    const\r\n{\r\n    return availableInstances_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ViewConfigurationValidator::getLibraryHandler()\r\n//-----------------------------------------------------------------------------\r\nLibraryInterface* ViewConfigurationValidator::getLibraryHandler() const\r\n{\r\n    return libraryHandler_;\r\n}"
  },
  {
    "path": "IPXACTmodels/DesignConfiguration/validators/ViewConfigurationValidator.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ViewConfigurationValidator.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 13.01.2016\r\n//\r\n// Description:\r\n// Validator for the ipxact:viewConfiguration.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef VIEWCONFIGURATIONVALIDATOR_H\r\n#define VIEWCONFIGURATIONVALIDATOR_H\r\n\r\n#include <IPXACTmodels/ipxactmodels_global.h>\r\n\r\n#include <QSharedPointer>\r\n#include <QString>\r\n#include <QVector>\r\n#include \"QStringList\"\r\n\r\nclass ViewConfiguration;\r\n\r\nclass ExpressionParser;\r\n\r\nclass View;\r\nclass ComponentInstance;\r\n\r\nclass LibraryInterface;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Validator for the ipxact:viewConfiguration.\r\n//-----------------------------------------------------------------------------\r\nclass IPXACTMODELS_EXPORT ViewConfigurationValidator\r\n{\r\npublic:\r\n\r\n    /*!\r\n     *  The constructor.\r\n     *\r\n     *    @param [in] library     The used library interface.\r\n     *    @param [in] parser      The used expression parser.\r\n     */\r\n    ViewConfigurationValidator(LibraryInterface* library, QSharedPointer<ExpressionParser> parser);\r\n\r\n\t//! The destructor.\r\n\tvirtual ~ViewConfigurationValidator();\r\n\r\n    // Disable copying.\r\n    ViewConfigurationValidator(ViewConfigurationValidator const& rhs) = delete;\r\n    ViewConfigurationValidator& operator=(ViewConfigurationValidator const& rhs) = delete;\r\n\r\n    /*!\r\n     *  Change the available component instances.\r\n     *\r\n     *    @param [in] newInstances    The new component instances.\r\n     */\r\n    virtual void changeComponentInstances(QSharedPointer<QList<QSharedPointer<ComponentInstance> > > newInstances);\r\n\r\n    /*!\r\n     *  Validates the given view configuration.\r\n     *\r\n     *    @param [in] configuration   The selected view configuration.\r\n     *\r\n     *    @return True, if the view configuration is valid IP-XACT, otherwise false.\r\n     */\r\n    bool validate(QSharedPointer<ViewConfiguration> configuration);\r\n\r\n    /*!\r\n     *  Check if the name is valid.\r\n     *\r\n     *    @param [in] configuration   The selected view configuration.\r\n     *\r\n     *    @return True, if the name is valid, otherwise false.\r\n     */\r\n    bool hasValidName(QSharedPointer<ViewConfiguration> configuration) const;\r\n\r\n    /*!\r\n     *  Check if the is present value is valid.\r\n     *\r\n     *    @param [in] configuration   The selected view configuration.\r\n     *\r\n     *    @return True, if the is present value is valid, otherwise false.\r\n     */\r\n    bool hasValidIsPresent(QSharedPointer<ViewConfiguration> configuration) const;\r\n\r\n    /*!\r\n     *  Check if the view reference is valid.\r\n     *\r\n     *    @param [in] configuration   The selected view configuration.\r\n     *\r\n     *    @return True, if the view reference is valid, otherwise false.\r\n     */\r\n    virtual bool hasValidViewReference(QSharedPointer<ViewConfiguration> configuration);\r\n\r\n    /*!\r\n     *  Locate errors within a view configuration.\r\n     *\r\n     *    @param [in] errors          List of found errors.\r\n     *    @param [in] configuration   The selected view configuration.\r\n     *    @param [in] context         Context to help locate the errors.\r\n     */\r\n    void findErrorsIn(QVector<QString>& errors, QSharedPointer<ViewConfiguration> configuration,\r\n        QString const& context);\r\n\r\nprotected:\r\n\r\n    /*!\r\n     *  Get the available component instances.\r\n     *\r\n     *    @return A list of the currently available component instances.\r\n     */\r\n    QSharedPointer<QList<QSharedPointer<ComponentInstance> > > getAvailableInstances() const;\r\n\r\n    /*!\r\n     *  Get the library interface.\r\n     *\r\n     *    @return The currently used library interface.\r\n     */\r\n    LibraryInterface* getLibraryHandler() const;\r\n\r\nprivate:\r\n\r\n    /*!\r\n     *  Change the currently available views.\r\n     *\r\n     *    @param [in] configuration   The selected view configuration.\r\n     */\r\n    void changeAvailableViews(QSharedPointer<ViewConfiguration> configuration);\r\n\r\n    /*!\r\n     *  Find errors in name.\r\n     *\r\n     *    @param [in] errors          List of found errors.\r\n     *    @param [in] configuration   The selected view configuration.\r\n     *    @param [in] context         Context to help locate the errors.\r\n     */\r\n    void findErrorsInName(QVector<QString>& errors, QSharedPointer<ViewConfiguration> configuration,\r\n        QString const& context) const;\r\n\r\n    /*!\r\n     *  Find errors in is present value.\r\n     *\r\n     *    @param [in] errors          List of found errors.\r\n     *    @param [in] configuration   The selected view configuration.\r\n     *    @param [in] context         Context to help locate the errors.\r\n     */\r\n    void findErrorsInIsPresent(QVector<QString>& errors, QSharedPointer<ViewConfiguration> configuration,\r\n        QString const& context) const;\r\n\r\n    /*!\r\n     *  Find errors in view reference.\r\n     *\r\n     *    @param [in] errors          List of found errors.\r\n     *    @param [in] configuration   The selected view configuration.\r\n     *    @param [in] context         Context to help locate the errors.\r\n     */\r\n    virtual void findErrorsInViewReference(QVector<QString>& errors,\r\n        QSharedPointer<ViewConfiguration> configuration, QString const& context);\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! The used library handler.\r\n    LibraryInterface* libraryHandler_;\r\n\r\n    //! The used expression parser.\r\n    QSharedPointer<ExpressionParser> parser_;\r\n\r\n    //! The currently available views.\r\n    QStringList availableViews_;\r\n\r\n    //! The currently available component instances.\r\n    QSharedPointer<QList<QSharedPointer<ComponentInstance> > > availableInstances_;\r\n};\r\n\r\n#endif // VIEWCONFIGURATIONVALIDATOR_H\r\n"
  },
  {
    "path": "IPXACTmodels/IPXACTmodels.pri",
    "content": "# ----------------------------------------------------\r\n# This file is generated by the Qt Visual Studio Tools.\r\n# ------------------------------------------------------\r\n\r\nHEADERS += ./generaldeclarations.h \\\r\n    ./ipxactmodels_global.h \\\r\n    ./kactusExtensions/ApiDefinition.h \\\r\n    ./kactusExtensions/ApiFunction.h \\\r\n    ./kactusExtensions/ApiFunctionParameter.h \\\r\n    ./kactusExtensions/ApiInterconnection.h \\\r\n    ./kactusExtensions/ApiInterface.h \\\r\n    ./kactusExtensions/ColumnDesc.h \\\r\n    ./kactusExtensions/ComDefinition.h \\\r\n    ./kactusExtensions/ComInterconnection.h \\\r\n    ./kactusExtensions/ComInterface.h \\\r\n    ./kactusExtensions/ComProperty.h \\\r\n    ./kactusExtensions/ConnectionRoute.h \\\r\n    ./kactusExtensions/FileDependency.h \\\r\n    ./kactusExtensions/HierApiInterconnection.h \\\r\n    ./kactusExtensions/HierComInterconnection.h \\\r\n    ./kactusExtensions/InterfaceGraphicsData.h \\\r\n    ./kactusExtensions/Kactus2Group.h \\\r\n    ./kactusExtensions/Kactus2Placeholder.h \\\r\n    ./kactusExtensions/Kactus2Position.h \\\r\n    ./kactusExtensions/Kactus2Value.h \\\r\n    ./kactusExtensions/KactusAttribute.h \\\r\n    ./kactusExtensions/SystemView.h \\\r\n    ./kactusExtensions/validators/ApiDefinitionValidator.h \\\r\n    ./kactusExtensions/validators/ComDefinitionValidator.h \\\r\n    ./kactusExtensions/ApiDefinitionWriter.h \\\r\n    ./kactusExtensions/ApiDefinitionReader.h \\\r\n    ./kactusExtensions/ComDefinitionWriter.h \\\r\n    ./kactusExtensions/ComDefinitionReader.h \\\r\n    ./kactusExtensions/validators/SystemDesignConfigurationValidator.h \\\r\n    ./kactusExtensions/validators/SystemViewConfigurationValidator.h \\\r\n    ./common/Choice.h \\\r\n    ./common/ChoiceReader.h \\\r\n    ./common/ChoiceWriter.h \\\r\n    ./common/DocumentUtils.h \\\r\n    ./common/FileType.h \\\r\n    ./common/QualifierReader.h \\\r\n    ./common/QualifierWriter.h \\\r\n    ./common/TagData.h \\\r\n    ./common/AccessTypes.h \\\r\n    ./common/Array.h \\\r\n    ./common/Assertion.h \\\r\n    ./common/BooleanValue.h \\\r\n    ./common/BuildModel.h \\\r\n    ./common/CellSpecification.h \\\r\n    ./common/ClockUnit.h \\\r\n    ./common/ConfigurableElementValue.h \\\r\n    ./common/ConfigurableVLNVReference.h \\\r\n    ./common/DirectionTypes.h \\\r\n    ./common/Document.h \\\r\n    ./common/Enumeration.h \\\r\n    ./common/Extendable.h \\\r\n    ./common/FileBuilder.h \\\r\n    ./common/ModuleParameter.h \\\r\n    ./common/ModuleParameterReader.h \\\r\n    ./common/ModuleParameterWriter.h \\\r\n    ./common/NameGroup.h \\\r\n    ./common/NameGroupReader.h \\\r\n    ./common/NameGroupWriter.h \\\r\n    ./common/NameValuePair.h \\\r\n    ./common/Parameter.h \\\r\n    ./common/ParameterReader.h \\\r\n    ./common/ParameterWriter.h \\\r\n    ./common/PartSelect.h \\\r\n    ./common/PortAlignment.h \\\r\n    ./common/PresenceTypes.h \\\r\n    ./common/Protocol.h \\\r\n    ./common/ProtocolReader.h \\\r\n    ./common/ProtocolWriter.h \\\r\n    ./common/Qualifier.h \\\r\n    ./common/Range.h \\\r\n    ./common/TimingConstraint.h \\\r\n    ./common/TransactionalTypes.h \\\r\n    ./common/Vector.h \\\r\n    ./common/VendorExtension.h \\\r\n    ./common/VLNV.h \\\r\n    ./common/CommonItemsReader.h \\\r\n    ./common/CommonItemsWriter.h \\\r\n    ./common/DocumentReader.h \\\r\n    ./common/DocumentWriter.h \\\r\n    ./common/FileBuilderReader.h \\\r\n    ./common/FileBuilderWriter.h \\\r\n    ./common/GenericVendorExtension.h \\\r\n    ./common/validators/ChoiceValidator.h \\\r\n    ./common/validators/CommonItemsValidator.h \\\r\n    ./common/validators/HierarchicalValidator.h \\\r\n    ./common/validators/QualifierValidator.h \\\r\n    ./common/validators/AssertionValidator.h \\\r\n    ./common/validators/CellSpecificationValidator.h \\\r\n    ./common/validators/ParameterValidator.h \\\r\n    ./common/validators/ProtocolValidator.h \\\r\n    ./common/validators/TimingConstraintValidator.h \\\r\n    ./common/validators/ValueFormatter.h \\\r\n    ./common/validators/namevalidator.h \\\r\n    ./common/validators/NMTokenValidator.h \\\r\n    ./BusDefinition/BusDefinition.h \\\r\n    ./BusDefinition/BusDefinitionReader.h \\\r\n    ./BusDefinition/BusDefinitionWriter.h \\\r\n    ./BusDefinition/validators/BusDefinitionValidator.h \\\r\n    ./AbstractionDefinition/AbstractionDefinition.h \\\r\n    ./AbstractionDefinition/Packet.h \\\r\n    ./AbstractionDefinition/PacketField.h \\\r\n    ./AbstractionDefinition/PacketReader.h \\\r\n    ./AbstractionDefinition/PacketWriter.h \\\r\n    ./AbstractionDefinition/PortAbstraction.h \\\r\n    ./AbstractionDefinition/TransactionalAbstraction.h \\\r\n    ./AbstractionDefinition/TransactionalAbstractionReader.h \\\r\n    ./AbstractionDefinition/TransactionalAbstractionWriter.h \\\r\n    ./AbstractionDefinition/TransactionalPort.h \\\r\n    ./AbstractionDefinition/WireAbstraction.h \\\r\n    ./AbstractionDefinition/WireAbstractionReader.h \\\r\n    ./AbstractionDefinition/WireAbstractionWriter.h \\\r\n    ./AbstractionDefinition/WirePort.h \\\r\n    ./AbstractionDefinition/AbstractionDefinitionReader.h \\\r\n    ./AbstractionDefinition/AbstractionDefinitionWriter.h \\\r\n    ./AbstractionDefinition/validators/PacketValidator.h \\\r\n    ./AbstractionDefinition/validators/AbstractionDefinitionValidator.h \\\r\n    ./Design/ActiveInterface.h \\\r\n    ./Design/AdHocConnection.h \\\r\n    ./Design/ComponentInstance.h \\\r\n    ./Design/Design.h \\\r\n    ./Design/HierInterface.h \\\r\n    ./Design/Interconnection.h \\\r\n    ./Design/MonitorInterconnection.h \\\r\n    ./Design/MonitorInterface.h \\\r\n    ./Design/PortReference.h \\\r\n    ./Design/ComponentInstanceReader.h \\\r\n    ./Design/ComponentInstanceWriter.h \\\r\n    ./Design/DesignReader.h \\\r\n    ./Design/DesignWriter.h \\\r\n    ./Design/validator/AdHocConnectionValidator.h \\\r\n    ./Design/validator/ComponentInstanceValidator.h \\\r\n    ./Design/validator/DesignValidator.h \\\r\n    ./Design/validator/InterconnectionValidator.h \\\r\n    ./Component/AccessPolicy.h \\\r\n    ./Component/AccessPolicyReader.h \\\r\n    ./Component/AccessPolicyWriter.h \\\r\n    ./Component/Driver.h \\\r\n    ./Component/ExecutableImage.h \\\r\n    ./Component/FieldAccessPolicy.h \\\r\n    ./Component/FieldAccessPolicyReader.h \\\r\n    ./Component/FieldAccessPolicyWriter.h \\\r\n    ./Component/FieldReference.h \\\r\n    ./Component/FieldReferenceReader.h \\\r\n    ./Component/FieldReferenceWriter.h \\\r\n    ./Component/FieldReset.h \\\r\n    ./Component/FieldSlice.h \\\r\n    ./Component/InitiatorInterface.h \\\r\n    ./Component/FileSetRef.h \\\r\n    ./Component/LanguageTools.h \\\r\n    ./Component/MemoryArray.h \\\r\n    ./Component/MemoryArrayReader.h \\\r\n    ./Component/MemoryArrayWriter.h \\\r\n    ./Component/MemoryBlockBaseReader.h \\\r\n    ./Component/MemoryBlockBaseWriter.h \\\r\n    ./Component/ModeReference.h \\\r\n    ./Component/MirroredTargetInterface.h \\\r\n    ./Component/Mode.h \\\r\n    ./Component/ModeReader.h \\\r\n    ./Component/ModeWriter.h \\\r\n    ./Component/PortSlice.h \\\r\n    ./Component/PowerDomain.h \\\r\n    ./Component/PowerDomainReader.h \\\r\n    ./Component/PowerDomainWriter.h \\\r\n    ./Component/Region.h \\\r\n    ./Component/Structured.h \\\r\n    ./Component/SubPort.h \\\r\n    ./Component/SubSpaceMap.h \\\r\n    ./Component/SubspaceMapReader.h \\\r\n    ./Component/SubSpaceMapWriter.h \\\r\n    ./Component/TargetInterface.h \\\r\n    ./Component/AddressBlock.h \\\r\n    ./Component/AddressSpace.h \\\r\n    ./Component/AlternateRegister.h \\\r\n    ./Component/BuildCommand.h \\\r\n    ./Component/BusInterface.h \\\r\n    ./Component/Channel.h \\\r\n    ./Component/Component.h \\\r\n    ./Component/ComponentGenerator.h \\\r\n    ./Component/ComponentInstantiation.h \\\r\n    ./Component/Cpu.h \\\r\n    ./Component/DesignConfigurationInstantiation.h \\\r\n    ./Component/DesignInstantiation.h \\\r\n    ./Component/EnumeratedValue.h \\\r\n    ./Component/Field.h \\\r\n    ./Component/File.h \\\r\n    ./Component/FileSet.h \\\r\n    ./Component/Function.h \\\r\n    ./Component/IndirectInterface.h \\\r\n    ./Component/IndirectInterfaceReader.h \\\r\n    ./Component/IndirectInterfaceWriter.h \\\r\n    ./Component/MemoryBlockBase.h \\\r\n    ./Component/MemoryMap.h \\\r\n    ./Component/MemoryMapBase.h \\\r\n    ./Component/MemoryRemap.h \\\r\n    ./Component/Model.h \\\r\n    ./Component/AbstractionType.h \\\r\n    ./Component/OtherClockDriver.h \\\r\n    ./Component/OtherClockDriverReader.h \\\r\n    ./Component/Port.h \\\r\n    ./Component/PortMap.h \\\r\n    ./Component/Register.h \\\r\n    ./Component/RegisterBase.h \\\r\n    ./Component/RegisterDefinition.h \\\r\n    ./Component/RegisterFile.h \\\r\n    ./Component/RemapPort.h \\\r\n    ./Component/RemapState.h \\\r\n    ./Component/RemapStateReader.h \\\r\n    ./Component/RemapStateWriter.h \\\r\n    ./Component/Segment.h \\\r\n    ./Component/Transactional.h \\\r\n    ./Component/TransparentBridge.h \\\r\n    ./Component/View.h \\\r\n    ./Component/ViewReader.h \\\r\n    ./Component/ViewWriter.h \\\r\n    ./Component/Wire.h \\\r\n    ./Component/WireTypeDef.h \\\r\n    ./Component/WriteValueConstraint.h \\\r\n    ./Component/AddressBlockReader.h \\\r\n    ./Component/AddressBlockWriter.h \\\r\n    ./Component/AddressSpaceReader.h \\\r\n    ./Component/AddressSpaceWriter.h \\\r\n    ./Component/BusInterfaceReader.h \\\r\n    ./Component/BusInterfaceWriter.h \\\r\n    ./Component/ChannelReader.h \\\r\n    ./Component/ChannelWriter.h \\\r\n    ./Component/ComponentGeneratorReader.h \\\r\n    ./Component/ComponentGeneratorWriter.h \\\r\n    ./Component/ComponentReader.h \\\r\n    ./Component/ComponentWriter.h \\\r\n    ./Component/CPUReader.h \\\r\n    ./Component/CPUWriter.h \\\r\n    ./Component/EnumeratedValueReader.h \\\r\n    ./Component/EnumeratedValueWriter.h \\\r\n    ./Component/FieldReader.h \\\r\n    ./Component/FieldWriter.h \\\r\n    ./Component/FileReader.h \\\r\n    ./Component/FileSetReader.h \\\r\n    ./Component/FileSetWriter.h \\\r\n    ./Component/FileWriter.h \\\r\n    ./Component/InstantiationsReader.h \\\r\n    ./Component/InstantiationsWriter.h \\\r\n    ./Component/MemoryMapBaseReader.h \\\r\n    ./Component/MemoryMapBaseWriter.h \\\r\n    ./Component/MemoryMapReader.h \\\r\n    ./Component/MemoryMapWriter.h \\\r\n    ./Component/PortReader.h \\\r\n    ./Component/PortWriter.h \\\r\n    ./Component/RegisterReader.h \\\r\n    ./Component/RegisterWriter.h \\\r\n    ./Component/OtherClockDriverWriter.h \\\r\n    ./Component/validators/CollectionValidators.h \\\r\n    ./Component/validators/FieldAccessPolicyValidator.h \\\r\n    ./Component/validators/FieldReferenceValidator.h \\\r\n    ./Component/validators/FieldSliceValidator.h \\\r\n    ./Component/validators/MemoryArrayValidator.h \\\r\n    ./Component/validators/MemoryBlockValidator.h \\\r\n    ./Component/validators/ModeValidator.h \\\r\n    ./Component/validators/PortSliceValidator.h \\\r\n    ./Component/validators/PowerDomainValidator.h \\\r\n    ./Component/validators/RegionValidator.h \\\r\n    ./Component/validators/RegisterBaseValidator.h \\\r\n    ./Component/validators/RegisterFileValidator.h \\\r\n    ./Component/validators/SubspaceMapValidator.h \\\r\n    ./Component/validators/AbstractionTypeValidator.h \\\r\n    ./Component/validators/AddressBlockValidator.h \\\r\n    ./Component/validators/AddressSpaceValidator.h \\\r\n    ./Component/validators/BusInterfaceValidator.h \\\r\n    ./Component/validators/ChannelValidator.h \\\r\n    ./Component/validators/ComponentGeneratorValidator.h \\\r\n    ./Component/validators/ComponentValidator.h \\\r\n    ./Component/validators/CPUValidator.h \\\r\n    ./Component/validators/EnumeratedValueValidator.h \\\r\n    ./Component/validators/FieldValidator.h \\\r\n    ./Component/validators/FileSetValidator.h \\\r\n    ./Component/validators/FileValidator.h \\\r\n    ./Component/validators/IndirectInterfaceValidator.h \\\r\n    ./Component/validators/InstantiationsValidator.h \\\r\n    ./Component/validators/PortMapValidator.h \\\r\n    ./Component/validators/OtherClockDriverValidator.h \\\r\n    ./Component/validators/PortTypeValidator.h \\\r\n    ./Component/validators/PortValidator.h \\\r\n    ./Component/validators/RemapStateValidator.h \\\r\n    ./Component/validators/MemoryMapBaseValidator.h \\\r\n    ./Component/validators/MemoryMapValidator.h \\\r\n    ./Component/validators/MemoryReserve.h \\\r\n    ./Component/validators/RegisterValidator.h \\\r\n    ./Component/validators/ViewValidator.h \\\r\n    ./Catalog/Catalog.h \\\r\n    ./Catalog/IpxactFile.h \\\r\n    ./Catalog/CatalogReader.h \\\r\n    ./Catalog/CatalogWriter.h \\\r\n    ./Catalog/validators/CatalogValidator.h \\\r\n    ./utilities/BusDefinitionUtils.h \\\r\n    ./utilities/Copy.h \\\r\n    ./utilities/XmlUtils.h \\\r\n    ./DesignConfiguration/AbstractorInstance.h \\\r\n    ./DesignConfiguration/DesignConfiguration.h \\\r\n    ./DesignConfiguration/DesignConfigurationReader.h \\\r\n    ./DesignConfiguration/DesignConfigurationWriter.h \\\r\n    ./DesignConfiguration/InterconnectionConfiguration.h \\\r\n    ./DesignConfiguration/InterfaceRef.h \\\r\n    ./DesignConfiguration/MultipleAbstractorInstances.h \\\r\n    ./DesignConfiguration/ViewConfiguration.h \\\r\n    ./DesignConfiguration/validators/DesignConfigurationValidator.h \\\r\n    ./DesignConfiguration/validators/InterconnectionConfigurationValidator.h \\\r\n    ./DesignConfiguration/validators/ViewConfigurationValidator.h \\\r\n    ./AbstractionDefinition/validators/PortAbstractionValidator.h\r\nSOURCES += ./Component/validators/CollectionValidators.cpp \\\r\n    ./generaldeclarations.cpp \\\r\n    ./kactusExtensions/ApiDefinition.cpp \\\r\n    ./kactusExtensions/ApiDefinitionReader.cpp \\\r\n    ./kactusExtensions/ApiDefinitionWriter.cpp \\\r\n    ./kactusExtensions/ApiFunction.cpp \\\r\n    ./kactusExtensions/ApiFunctionParameter.cpp \\\r\n    ./kactusExtensions/ApiInterconnection.cpp \\\r\n    ./kactusExtensions/ApiInterface.cpp \\\r\n    ./kactusExtensions/ColumnDesc.cpp \\\r\n    ./kactusExtensions/ComDefinition.cpp \\\r\n    ./kactusExtensions/ComDefinitionReader.cpp \\\r\n    ./kactusExtensions/ComDefinitionWriter.cpp \\\r\n    ./kactusExtensions/ComInterconnection.cpp \\\r\n    ./kactusExtensions/ComInterface.cpp \\\r\n    ./kactusExtensions/ComProperty.cpp \\\r\n    ./kactusExtensions/ConnectionRoute.cpp \\\r\n    ./kactusExtensions/FileDependency.cpp \\\r\n    ./kactusExtensions/HierApiInterconnection.cpp \\\r\n    ./kactusExtensions/HierComInterconnection.cpp \\\r\n    ./kactusExtensions/InterfaceGraphicsData.cpp \\\r\n    ./kactusExtensions/Kactus2Group.cpp \\\r\n    ./kactusExtensions/Kactus2Placeholder.cpp \\\r\n    ./kactusExtensions/Kactus2Position.cpp \\\r\n    ./kactusExtensions/Kactus2Value.cpp \\\r\n    ./kactusExtensions/KactusAttribute.cpp \\\r\n    ./kactusExtensions/SystemView.cpp \\\r\n    ./kactusExtensions/validators/ApiDefinitionValidator.cpp \\\r\n    ./kactusExtensions/validators/ComDefinitionValidator.cpp \\\r\n    ./kactusExtensions/validators/SystemDesignConfigurationValidator.cpp \\\r\n    ./kactusExtensions/validators/SystemViewConfigurationValidator.cpp \\\r\n    ./common/AccessTypes.cpp \\\r\n    ./common/Assertion.cpp \\\r\n    ./common/BooleanValue.cpp \\\r\n    ./common/BuildModel.cpp \\\r\n    ./common/CellSpecification.cpp \\\r\n    ./common/Choice.cpp \\\r\n    ./common/ChoiceReader.cpp \\\r\n    ./common/ChoiceWriter.cpp \\\r\n    ./common/ClockUnit.cpp \\\r\n    ./common/CommonItemsReader.cpp \\\r\n    ./common/CommonItemsWriter.cpp \\\r\n    ./common/ConfigurableElementValue.cpp \\\r\n    ./common/ConfigurableVLNVReference.cpp \\\r\n    ./common/DirectionTypes.cpp \\\r\n    ./common/Document.cpp \\\r\n    ./common/DocumentReader.cpp \\\r\n    ./common/DocumentUtils.cpp \\\r\n    ./common/DocumentWriter.cpp \\\r\n    ./common/Enumeration.cpp \\\r\n    ./common/Extendable.cpp \\\r\n    ./common/FileBuilder.cpp \\\r\n    ./common/FileBuilderReader.cpp \\\r\n    ./common/FileBuilderWriter.cpp \\\r\n    ./common/FileType.cpp \\\r\n    ./common/GenericVendorExtension.cpp \\\r\n    ./common/ModuleParameter.cpp \\\r\n    ./common/ModuleParameterReader.cpp \\\r\n    ./common/ModuleParameterWriter.cpp \\\r\n    ./common/NameGroup.cpp \\\r\n    ./common/NameGroupReader.cpp \\\r\n    ./common/NameGroupWriter.cpp \\\r\n    ./common/NameValuePair.cpp \\\r\n    ./common/Parameter.cpp \\\r\n    ./common/ParameterReader.cpp \\\r\n    ./common/ParameterWriter.cpp \\\r\n    ./common/PartSelect.cpp \\\r\n    ./common/PortAlignment.cpp \\\r\n    ./common/PresenceTypes.cpp \\\r\n    ./common/Protocol.cpp \\\r\n    ./common/ProtocolReader.cpp \\\r\n    ./common/ProtocolWriter.cpp \\\r\n    ./common/Qualifier.cpp \\\r\n    ./common/QualifierReader.cpp \\\r\n    ./common/QualifierWriter.cpp \\\r\n    ./common/Range.cpp \\\r\n    ./common/TimingConstraint.cpp \\\r\n    ./common/TransactionalTypes.cpp \\\r\n    ./common/Vector.cpp \\\r\n    ./common/VLNV.cpp \\\r\n    ./common/validators/AssertionValidator.cpp \\\r\n    ./common/validators/CellSpecificationValidator.cpp \\\r\n    ./common/validators/ChoiceValidator.cpp \\\r\n    ./common/validators/CommonItemsValidator.cpp \\\r\n    ./common/validators/namevalidator.cpp \\\r\n    ./common/validators/NMTokenValidator.cpp \\\r\n    ./common/validators/ParameterValidator.cpp \\\r\n    ./common/validators/ProtocolValidator.cpp \\\r\n    ./common/validators/QualifierValidator.cpp \\\r\n    ./common/validators/TimingConstraintValidator.cpp \\\r\n    ./common/validators/ValueFormatter.cpp \\\r\n    ./BusDefinition/BusDefinition.cpp \\\r\n    ./BusDefinition/BusDefinitionReader.cpp \\\r\n    ./BusDefinition/BusDefinitionWriter.cpp \\\r\n    ./BusDefinition/validators/BusDefinitionValidator.cpp \\\r\n    ./AbstractionDefinition/AbstractionDefinition.cpp \\\r\n    ./AbstractionDefinition/AbstractionDefinitionReader.cpp \\\r\n    ./AbstractionDefinition/AbstractionDefinitionWriter.cpp \\\r\n    ./AbstractionDefinition/Packet.cpp \\\r\n    ./AbstractionDefinition/PacketField.cpp \\\r\n    ./AbstractionDefinition/PacketReader.cpp \\\r\n    ./AbstractionDefinition/PacketWriter.cpp \\\r\n    ./AbstractionDefinition/PortAbstraction.cpp \\\r\n    ./AbstractionDefinition/TransactionalAbstraction.cpp \\\r\n    ./AbstractionDefinition/TransactionalAbstractionReader.cpp \\\r\n    ./AbstractionDefinition/TransactionalAbstractionWriter.cpp \\\r\n    ./AbstractionDefinition/TransactionalPort.cpp \\\r\n    ./AbstractionDefinition/WireAbstraction.cpp \\\r\n    ./AbstractionDefinition/WireAbstractionReader.cpp \\\r\n    ./AbstractionDefinition/WireAbstractionWriter.cpp \\\r\n    ./AbstractionDefinition/WirePort.cpp \\\r\n    ./AbstractionDefinition/validators/AbstractionDefinitionValidator.cpp \\\r\n    ./AbstractionDefinition/validators/PacketValidator.cpp \\\r\n    ./Design/ActiveInterface.cpp \\\r\n    ./Design/AdHocConnection.cpp \\\r\n    ./Design/ComponentInstance.cpp \\\r\n    ./Design/ComponentInstanceReader.cpp \\\r\n    ./Design/ComponentInstanceWriter.cpp \\\r\n    ./Design/Design.cpp \\\r\n    ./Design/DesignReader.cpp \\\r\n    ./Design/DesignWriter.cpp \\\r\n    ./Design/HierInterface.cpp \\\r\n    ./Design/Interconnection.cpp \\\r\n    ./Design/MonitorInterconnection.cpp \\\r\n    ./Design/MonitorInterface.cpp \\\r\n    ./Design/PortReference.cpp \\\r\n    ./Design/validator/AdHocConnectionValidator.cpp \\\r\n    ./Design/validator/ComponentInstanceValidator.cpp \\\r\n    ./Design/validator/DesignValidator.cpp \\\r\n    ./Design/validator/InterconnectionValidator.cpp \\\r\n    ./Component/AccessPolicy.cpp \\\r\n    ./Component/AccessPolicyReader.cpp \\\r\n    ./Component/AccessPolicyWriter.cpp \\\r\n    ./Component/AddressBlock.cpp \\\r\n    ./Component/AddressBlockReader.cpp \\\r\n    ./Component/AddressBlockWriter.cpp \\\r\n    ./Component/AddressSpace.cpp \\\r\n    ./Component/AddressSpaceReader.cpp \\\r\n    ./Component/AddressSpaceWriter.cpp \\\r\n    ./Component/AlternateRegister.cpp \\\r\n    ./Component/BuildCommand.cpp \\\r\n    ./Component/BusInterface.cpp \\\r\n    ./Component/BusInterfaceReader.cpp \\\r\n    ./Component/BusInterfaceWriter.cpp \\\r\n    ./Component/Channel.cpp \\\r\n    ./Component/ChannelReader.cpp \\\r\n    ./Component/ChannelWriter.cpp \\\r\n    ./Component/Component.cpp \\\r\n    ./Component/ComponentGenerator.cpp \\\r\n    ./Component/ComponentGeneratorReader.cpp \\\r\n    ./Component/ComponentGeneratorWriter.cpp \\\r\n    ./Component/ComponentInstantiation.cpp \\\r\n    ./Component/ComponentReader.cpp \\\r\n    ./Component/ComponentWriter.cpp \\\r\n    ./Component/Cpu.cpp \\\r\n    ./Component/CPUReader.cpp \\\r\n    ./Component/CPUWriter.cpp \\\r\n    ./Component/DesignConfigurationInstantiation.cpp \\\r\n    ./Component/DesignInstantiation.cpp \\\r\n    ./Component/Driver.cpp \\\r\n    ./Component/EnumeratedValue.cpp \\\r\n    ./Component/EnumeratedValueReader.cpp \\\r\n    ./Component/EnumeratedValueWriter.cpp \\\r\n    ./Component/ExecutableImage.cpp \\\r\n    ./Component/Field.cpp \\\r\n    ./Component/FieldAccessPolicy.cpp \\\r\n    ./Component/FieldAccessPolicyReader.cpp \\\r\n    ./Component/FieldAccessPolicyWriter.cpp \\\r\n    ./Component/FieldReader.cpp \\\r\n    ./Component/FieldReference.cpp \\\r\n    ./Component/FieldReferenceReader.cpp \\\r\n    ./Component/FieldReferenceWriter.cpp \\\r\n    ./Component/FieldReset.cpp \\\r\n    ./Component/FieldSlice.cpp \\\r\n    ./Component/FieldWriter.cpp \\\r\n    ./Component/File.cpp \\\r\n    ./Component/FileReader.cpp \\\r\n    ./Component/FileSet.cpp \\\r\n    ./Component/FileSetReader.cpp \\\r\n    ./Component/FileSetRef.cpp \\\r\n    ./Component/FileSetWriter.cpp \\\r\n    ./Component/FileWriter.cpp \\\r\n    ./Component/Function.cpp \\\r\n    ./Component/IndirectInterface.cpp \\\r\n    ./Component/IndirectInterfaceReader.cpp \\\r\n    ./Component/IndirectInterfaceWriter.cpp \\\r\n    ./Component/InitiatorInterface.cpp \\\r\n    ./Component/InstantiationsReader.cpp \\\r\n    ./Component/InstantiationsWriter.cpp \\\r\n    ./Component/LanguageTools.cpp \\\r\n    ./Component/MemoryArray.cpp \\\r\n    ./Component/MemoryArrayReader.cpp \\\r\n    ./Component/MemoryArrayWriter.cpp \\\r\n    ./Component/MemoryBlockBase.cpp \\\r\n    ./Component/MemoryBlockBaseReader.cpp \\\r\n    ./Component/MemoryBlockBaseWriter.cpp \\\r\n    ./Component/MemoryMap.cpp \\\r\n    ./Component/MemoryMapBase.cpp \\\r\n    ./Component/MemoryMapBaseReader.cpp \\\r\n    ./Component/MemoryMapBaseWriter.cpp \\\r\n    ./Component/MemoryMapReader.cpp \\\r\n    ./Component/MemoryMapWriter.cpp \\\r\n    ./Component/MemoryRemap.cpp \\\r\n    ./Component/MirroredTargetInterface.cpp \\\r\n    ./Component/Mode.cpp \\\r\n    ./Component/Model.cpp \\\r\n    ./Component/AbstractionType.cpp \\\r\n    ./Component/ModeReference.cpp \\\r\n    ./Component/ModeReader.cpp \\\r\n    ./Component/ModeWriter.cpp \\\r\n    ./Component/OtherClockDriver.cpp \\\r\n    ./Component/OtherClockDriverReader.cpp \\\r\n    ./Component/OtherClockDriverWriter.cpp \\\r\n    ./Component/Port.cpp \\\r\n    ./Component/PortMap.cpp \\\r\n    ./Component/PortReader.cpp \\\r\n    ./Component/PortSlice.cpp \\\r\n    ./Component/PortWriter.cpp \\\r\n    ./Component/PowerDomain.cpp \\\r\n    ./Component/PowerDomainReader.cpp \\\r\n    ./Component/PowerDomainWriter.cpp \\\r\n    ./Component/Region.cpp \\\r\n    ./Component/Register.cpp \\\r\n    ./Component/RegisterBase.cpp \\\r\n    ./Component/RegisterDefinition.cpp \\\r\n    ./Component/RegisterFile.cpp \\\r\n    ./Component/RegisterReader.cpp \\\r\n    ./Component/RegisterWriter.cpp \\\r\n    ./Component/RemapPort.cpp \\\r\n    ./Component/RemapState.cpp \\\r\n    ./Component/RemapStateReader.cpp \\\r\n    ./Component/RemapStateWriter.cpp \\\r\n    ./Component/Segment.cpp \\\r\n    ./Component/Structured.cpp \\\r\n    ./Component/SubPort.cpp \\\r\n    ./Component/SubSpaceMap.cpp \\\r\n    ./Component/SubspaceMapReader.cpp \\\r\n    ./Component/SubSpaceMapWriter.cpp \\\r\n    ./Component/TargetInterface.cpp \\\r\n    ./Component/Transactional.cpp \\\r\n    ./Component/TransparentBridge.cpp \\\r\n    ./Component/View.cpp \\\r\n    ./Component/ViewReader.cpp \\\r\n    ./Component/ViewWriter.cpp \\\r\n    ./Component/Wire.cpp \\\r\n    ./Component/WireTypeDef.cpp \\\r\n    ./Component/WriteValueConstraint.cpp \\\r\n    ./common/validators/HierarchicalValidator.cpp \\\r\n    ./Component/validators/AbstractionTypeValidator.cpp \\\r\n    ./Component/validators/AddressBlockValidator.cpp \\\r\n    ./Component/validators/AddressSpaceValidator.cpp \\\r\n    ./Component/validators/BusInterfaceValidator.cpp \\\r\n    ./Component/validators/ChannelValidator.cpp \\\r\n    ./Component/validators/ComponentGeneratorValidator.cpp \\\r\n    ./Component/validators/ComponentValidator.cpp \\\r\n    ./Component/validators/CPUValidator.cpp \\\r\n    ./Component/validators/EnumeratedValueValidator.cpp \\\r\n    ./Component/validators/FieldAccessPolicyValidator.cpp \\\r\n    ./Component/validators/FieldReferenceValidator.cpp \\\r\n    ./Component/validators/FieldSliceValidator.cpp \\\r\n    ./Component/validators/FieldValidator.cpp \\\r\n    ./Component/validators/FileSetValidator.cpp \\\r\n    ./Component/validators/FileValidator.cpp \\\r\n    ./Component/validators/IndirectInterfaceValidator.cpp \\\r\n    ./Component/validators/InstantiationsValidator.cpp \\\r\n    ./Component/validators/MemoryArrayValidator.cpp \\\r\n    ./Component/validators/MemoryBlockValidator.cpp \\\r\n    ./Component/validators/ModeValidator.cpp \\\r\n    ./Component/validators/PortMapValidator.cpp \\\r\n    ./Component/validators/OtherClockDriverValidator.cpp \\\r\n    ./Component/validators/PortSliceValidator.cpp \\\r\n    ./Component/validators/PortTypeValidator.cpp \\\r\n    ./Component/validators/PortValidator.cpp \\\r\n    ./Component/validators/PowerDomainValidator.cpp \\\r\n    ./Component/validators/RegionValidator.cpp \\\r\n    ./Component/validators/RegisterBaseValidator.cpp \\\r\n    ./Component/validators/RegisterFileValidator.cpp \\\r\n    ./Component/validators/RemapStateValidator.cpp \\\r\n    ./Component/validators/MemoryMapBaseValidator.cpp \\\r\n    ./Component/validators/MemoryMapValidator.cpp \\\r\n    ./Component/validators/MemoryReserve.cpp \\\r\n    ./Component/validators/RegisterValidator.cpp \\\r\n    ./Component/validators/SubspaceMapValidator.cpp \\\r\n    ./Component/validators/ViewValidator.cpp \\\r\n    ./Catalog/Catalog.cpp \\\r\n    ./Catalog/CatalogReader.cpp \\\r\n    ./Catalog/CatalogWriter.cpp \\\r\n    ./Catalog/IpxactFile.cpp \\\r\n    ./Catalog/validators/CatalogValidator.cpp \\\r\n    ./utilities/BusDefinitionUtils.cpp \\\r\n    ./utilities/XmlUtils.cpp \\\r\n    ./DesignConfiguration/AbstractorInstance.cpp \\\r\n    ./DesignConfiguration/DesignConfiguration.cpp \\\r\n    ./DesignConfiguration/DesignConfigurationReader.cpp \\\r\n    ./DesignConfiguration/DesignConfigurationWriter.cpp \\\r\n    ./DesignConfiguration/InterconnectionConfiguration.cpp \\\r\n    ./DesignConfiguration/InterfaceRef.cpp \\\r\n    ./DesignConfiguration/MultipleAbstractorInstances.cpp \\\r\n    ./DesignConfiguration/ViewConfiguration.cpp \\\r\n    ./DesignConfiguration/validators/DesignConfigurationValidator.cpp \\\r\n    ./DesignConfiguration/validators/InterconnectionConfigurationValidator.cpp \\\r\n    ./DesignConfiguration/validators/ViewConfigurationValidator.cpp \\\r\n    ./AbstractionDefinition/validators/PortAbstractionValidator.cpp\r\n"
  },
  {
    "path": "IPXACTmodels/IPXACTmodels.pro",
    "content": "# ----------------------------------------------------\r\n# This file is generated by the Qt Visual Studio Add-in.\r\n# ------------------------------------------------------\r\n\r\nTEMPLATE = lib\r\n\r\nQT += core xml\r\nCONFIG += c++17 dll\r\n\r\nDEFINES += IPXACTMODELS_LIB QT_NO_CAST_FROM_ASCII\r\nINCLUDEPATH += ./ ./..\r\n\r\nCONFIG(debug, debug|release) {\r\n    # debug mode\r\n    TARGET = IPXACTmodelsd\r\n    MOC_DIR += ./GeneratedFiles/Debug\r\n    OBJECTS_DIR += Debug\r\n} else {\r\n    # release mode \r\n    TARGET = IPXACTmodels\r\n    #INCLUDEPATH += ./GeneratedFiles/Release\r\n    MOC_DIR += ./GeneratedFiles/Release\r\n    OBJECTS_DIR += Release\r\n}\r\n\r\nDESTDIR = ../executable\r\n\r\nDEPENDPATH += .\r\nUI_DIR += ./GeneratedFiles\r\nRCC_DIR += ./GeneratedFiles\r\n\r\ninclude(IPXACTmodels.pri)\r\n\r\ntarget.path = $$lib_path\r\nINSTALLS += target\r\n"
  },
  {
    "path": "IPXACTmodels/IPXACTmodels.vcxproj",
    "content": "﻿<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n<Project DefaultTargets=\"Build\" ToolsVersion=\"15.0\" xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">\r\n  <ItemGroup Label=\"ProjectConfigurations\">\r\n    <ProjectConfiguration Include=\"Debug|x64\">\r\n      <Configuration>Debug</Configuration>\r\n      <Platform>x64</Platform>\r\n    </ProjectConfiguration>\r\n    <ProjectConfiguration Include=\"Release|x64\">\r\n      <Configuration>Release</Configuration>\r\n      <Platform>x64</Platform>\r\n    </ProjectConfiguration>\r\n  </ItemGroup>\r\n  <PropertyGroup Label=\"Globals\">\r\n    <ProjectGuid>{5C0CA59D-CFCE-49C6-B62A-9E3065CA34DD}</ProjectGuid>\r\n    <Keyword>QtVS_v304</Keyword>\r\n    <WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>\r\n    <QtMsBuild Condition=\"'$(QtMsBuild)'=='' or !Exists('$(QtMsBuild)\\qt.targets')\">$(MSBuildProjectDirectory)\\QtMsBuild</QtMsBuild>\r\n  </PropertyGroup>\r\n  <Import Project=\"$(VCTargetsPath)\\Microsoft.Cpp.Default.props\" />\r\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\" Label=\"Configuration\">\r\n    <ConfigurationType>DynamicLibrary</ConfigurationType>\r\n    <PlatformToolset>v143</PlatformToolset>\r\n  </PropertyGroup>\r\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\" Label=\"Configuration\">\r\n    <ConfigurationType>DynamicLibrary</ConfigurationType>\r\n    <PlatformToolset>v143</PlatformToolset>\r\n  </PropertyGroup>\r\n  <Import Project=\"$(VCTargetsPath)\\Microsoft.Cpp.props\" />\r\n  <Target Name=\"QtMsBuildNotFound\" BeforeTargets=\"CustomBuild;ClCompile\" Condition=\"!Exists('$(QtMsBuild)\\qt.targets') or !Exists('$(QtMsBuild)\\qt.props')\">\r\n    <Message Importance=\"High\" Text=\"QtMsBuild: could not locate qt.targets, qt.props; project may not build correctly.\" />\r\n  </Target>\r\n  <ImportGroup Label=\"ExtensionSettings\">\r\n  </ImportGroup>\r\n  <ImportGroup Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\" Label=\"PropertySheets\">\r\n    <Import Project=\"$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props\" Condition=\"exists('$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props')\" Label=\"LocalAppDataPlatform\" />\r\n  </ImportGroup>\r\n  <ImportGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\" Label=\"PropertySheets\">\r\n    <Import Project=\"$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props\" Condition=\"exists('$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props')\" Label=\"LocalAppDataPlatform\" />\r\n  </ImportGroup>\r\n  <PropertyGroup Label=\"UserMacros\" />\r\n  <ImportGroup Condition=\"Exists('$(QtMsBuild)\\qt_defaults.props')\">\r\n    <Import Project=\"$(QtMsBuild)\\qt_defaults.props\" />\r\n  </ImportGroup>\r\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n    <OutDir>$(SolutionDir)executable\\</OutDir>\r\n  </PropertyGroup>\r\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n    <OutDir>$(SolutionDir)executable\\</OutDir>\r\n    <TargetName>$(ProjectName)d</TargetName>\r\n  </PropertyGroup>\r\n  <PropertyGroup Label=\"QtSettings\" Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n    <QtInstall>6.2.4</QtInstall>\r\n    <QtModules>core;gui;xml</QtModules>\r\n  </PropertyGroup>\r\n  <PropertyGroup Label=\"QtSettings\" Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n    <QtInstall>6.2.4</QtInstall>\r\n    <QtModules>core;gui;xml</QtModules>\r\n  </PropertyGroup>\r\n  <ImportGroup Condition=\"Exists('$(QtMsBuild)\\qt.props')\">\r\n    <Import Project=\"$(QtMsBuild)\\qt.props\" />\r\n  </ImportGroup>\r\n  <PropertyGroup>\r\n    <_ProjectFileVersion>10.0.40219.1</_ProjectFileVersion>\r\n  </PropertyGroup>\r\n  <ItemDefinitionGroup Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n    <ClCompile>\r\n      <PreprocessorDefinitions>UNICODE;WIN32;WIN64;IPXACTMODELS_LIB;QT_NO_CAST_FROM_ASCII;%(PreprocessorDefinitions)</PreprocessorDefinitions>\r\n      <AdditionalIncludeDirectories>.\\GeneratedFiles\\$(ConfigurationName);.\\GeneratedFiles;.;$(SolutionDir);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\r\n      <Optimization>Disabled</Optimization>\r\n      <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>\r\n      <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>\r\n      <TreatWChar_tAsBuiltInType>true</TreatWChar_tAsBuiltInType>\r\n      <LanguageStandard>stdcpp17</LanguageStandard>\r\n      <AdditionalOptions>/Zc:__cplusplus %(AdditionalOptions)</AdditionalOptions>\r\n      <MultiProcessorCompilation>true</MultiProcessorCompilation>\r\n      <WarningLevel>Level4</WarningLevel>\r\n    </ClCompile>\r\n    <Link>\r\n      <SubSystem>Windows</SubSystem>\r\n      <OutputFile>$(OutDir)\\$(ProjectName)d.dll</OutputFile>\r\n      <AdditionalLibraryDirectories>%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>\r\n      <GenerateDebugInformation>true</GenerateDebugInformation>\r\n      <AdditionalDependencies>%(AdditionalDependencies)</AdditionalDependencies>\r\n    </Link>\r\n    <QtMoc>\r\n      <ExecutionDescription>Moc'ing %(Identity)...</ExecutionDescription>\r\n      <DynamicSource>output</DynamicSource>\r\n      <QtMocDir>.\\GeneratedFiles\\$(ConfigurationName)</QtMocDir>\r\n      <QtMocFileName>moc_%(Filename).cpp</QtMocFileName>\r\n    </QtMoc>\r\n  </ItemDefinitionGroup>\r\n  <ItemDefinitionGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n    <ClCompile>\r\n      <PreprocessorDefinitions>UNICODE;WIN32;WIN64;QT_NO_DEBUG;NDEBUG;QT_NO_CAST_FROM_ASCII;IPXACTMODELS_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>\r\n      <AdditionalIncludeDirectories>.\\GeneratedFiles\\$(ConfigurationName);.\\GeneratedFiles;.;$(SolutionDir);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\r\n      <DebugInformationFormat>\r\n      </DebugInformationFormat>\r\n      <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>\r\n      <TreatWChar_tAsBuiltInType>true</TreatWChar_tAsBuiltInType>\r\n      <LanguageStandard>stdcpp17</LanguageStandard>\r\n      <AdditionalOptions>/Zc:__cplusplus %(AdditionalOptions)</AdditionalOptions>\r\n      <MultiProcessorCompilation>true</MultiProcessorCompilation>\r\n    </ClCompile>\r\n    <Link>\r\n      <SubSystem>Windows</SubSystem>\r\n      <OutputFile>$(OutDir)\\$(ProjectName).dll</OutputFile>\r\n      <AdditionalLibraryDirectories>%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>\r\n      <GenerateDebugInformation>false</GenerateDebugInformation>\r\n      <AdditionalDependencies>%(AdditionalDependencies)</AdditionalDependencies>\r\n    </Link>\r\n    <QtMoc>\r\n      <ExecutionDescription>Moc'ing %(Identity)...</ExecutionDescription>\r\n      <DynamicSource>output</DynamicSource>\r\n      <QtMocDir>.\\GeneratedFiles\\$(ConfigurationName)</QtMocDir>\r\n      <QtMocFileName>moc_%(Filename).cpp</QtMocFileName>\r\n    </QtMoc>\r\n  </ItemDefinitionGroup>\r\n  <ItemGroup>\r\n    <ClCompile Include=\"AbstractionDefinition\\AbstractionDefinition.cpp\" />\r\n    <ClCompile Include=\"AbstractionDefinition\\AbstractionDefinitionReader.cpp\" />\r\n    <ClCompile Include=\"AbstractionDefinition\\AbstractionDefinitionWriter.cpp\" />\r\n    <ClCompile Include=\"AbstractionDefinition\\Packet.cpp\" />\r\n    <ClCompile Include=\"AbstractionDefinition\\PacketField.cpp\" />\r\n    <ClCompile Include=\"AbstractionDefinition\\PacketReader.cpp\" />\r\n    <ClCompile Include=\"AbstractionDefinition\\PacketWriter.cpp\" />\r\n    <ClCompile Include=\"AbstractionDefinition\\PortAbstraction.cpp\" />\r\n    <ClCompile Include=\"AbstractionDefinition\\TransactionalAbstraction.cpp\" />\r\n    <ClCompile Include=\"AbstractionDefinition\\TransactionalAbstractionReader.cpp\" />\r\n    <ClCompile Include=\"AbstractionDefinition\\TransactionalAbstractionWriter.cpp\" />\r\n    <ClCompile Include=\"AbstractionDefinition\\TransactionalPort.cpp\" />\r\n    <ClCompile Include=\"AbstractionDefinition\\validators\\AbstractionDefinitionValidator.cpp\" />\r\n    <ClCompile Include=\"AbstractionDefinition\\validators\\PacketValidator.cpp\" />\r\n    <ClCompile Include=\"AbstractionDefinition\\validators\\PortAbstractionValidator.cpp\" />\r\n    <ClCompile Include=\"AbstractionDefinition\\WireAbstraction.cpp\" />\r\n    <ClCompile Include=\"AbstractionDefinition\\WireAbstractionReader.cpp\" />\r\n    <ClCompile Include=\"AbstractionDefinition\\WireAbstractionWriter.cpp\" />\r\n    <ClCompile Include=\"AbstractionDefinition\\WirePort.cpp\" />\r\n    <ClCompile Include=\"BusDefinition\\BusDefinition.cpp\" />\r\n    <ClCompile Include=\"BusDefinition\\BusDefinitionReader.cpp\" />\r\n    <ClCompile Include=\"BusDefinition\\BusDefinitionWriter.cpp\" />\r\n    <ClCompile Include=\"BusDefinition\\validators\\BusDefinitionValidator.cpp\" />\r\n    <ClCompile Include=\"Catalog\\Catalog.cpp\" />\r\n    <ClCompile Include=\"Catalog\\CatalogReader.cpp\" />\r\n    <ClCompile Include=\"Catalog\\CatalogWriter.cpp\" />\r\n    <ClCompile Include=\"Catalog\\IpxactFile.cpp\" />\r\n    <ClCompile Include=\"Catalog\\validators\\CatalogValidator.cpp\" />\r\n    <ClCompile Include=\"common\\AccessTypes.cpp\" />\r\n    <ClCompile Include=\"common\\Assertion.cpp\" />\r\n    <ClCompile Include=\"common\\BooleanValue.cpp\" />\r\n    <ClCompile Include=\"common\\BuildModel.cpp\" />\r\n    <ClCompile Include=\"common\\CellSpecification.cpp\" />\r\n    <ClCompile Include=\"common\\Choice.cpp\" />\r\n    <ClCompile Include=\"common\\ChoiceReader.cpp\" />\r\n    <ClCompile Include=\"common\\ChoiceWriter.cpp\" />\r\n    <ClCompile Include=\"common\\ClockUnit.cpp\" />\r\n    <ClCompile Include=\"common\\CommonItemsReader.cpp\" />\r\n    <ClCompile Include=\"common\\CommonItemsWriter.cpp\" />\r\n    <ClCompile Include=\"common\\ConfigurableElementValue.cpp\" />\r\n    <ClCompile Include=\"common\\ConfigurableVLNVReference.cpp\" />\r\n    <ClCompile Include=\"common\\DirectionTypes.cpp\" />\r\n    <ClCompile Include=\"common\\Document.cpp\" />\r\n    <ClCompile Include=\"common\\DocumentReader.cpp\" />\r\n    <ClCompile Include=\"common\\DocumentUtils.cpp\" />\r\n    <ClCompile Include=\"common\\DocumentWriter.cpp\" />\r\n    <ClCompile Include=\"common\\Enumeration.cpp\" />\r\n    <ClCompile Include=\"common\\Extendable.cpp\" />\r\n    <ClCompile Include=\"common\\FileBuilder.cpp\" />\r\n    <ClCompile Include=\"common\\FileBuilderReader.cpp\" />\r\n    <ClCompile Include=\"common\\FileBuilderWriter.cpp\" />\r\n    <ClCompile Include=\"common\\FileType.cpp\" />\r\n    <ClCompile Include=\"common\\GenericVendorExtension.cpp\" />\r\n    <ClCompile Include=\"common\\ModuleParameter.cpp\" />\r\n    <ClCompile Include=\"common\\ModuleParameterReader.cpp\" />\r\n    <ClCompile Include=\"common\\ModuleParameterWriter.cpp\" />\r\n    <ClCompile Include=\"common\\NameGroup.cpp\" />\r\n    <ClCompile Include=\"common\\NameGroupReader.cpp\" />\r\n    <ClCompile Include=\"common\\NameGroupWriter.cpp\" />\r\n    <ClCompile Include=\"common\\NameValuePair.cpp\" />\r\n    <ClCompile Include=\"common\\Parameter.cpp\" />\r\n    <ClCompile Include=\"common\\ParameterReader.cpp\" />\r\n    <ClCompile Include=\"common\\ParameterWriter.cpp\" />\r\n    <ClCompile Include=\"common\\PartSelect.cpp\" />\r\n    <ClCompile Include=\"common\\PortAlignment.cpp\" />\r\n    <ClCompile Include=\"common\\PresenceTypes.cpp\" />\r\n    <ClCompile Include=\"common\\Protocol.cpp\" />\r\n    <ClCompile Include=\"common\\ProtocolReader.cpp\" />\r\n    <ClCompile Include=\"common\\ProtocolWriter.cpp\" />\r\n    <ClCompile Include=\"common\\Qualifier.cpp\" />\r\n    <ClCompile Include=\"common\\QualifierReader.cpp\" />\r\n    <ClCompile Include=\"common\\QualifierWriter.cpp\" />\r\n    <ClCompile Include=\"common\\Range.cpp\" />\r\n    <ClCompile Include=\"common\\TimingConstraint.cpp\" />\r\n    <ClCompile Include=\"common\\TransactionalTypes.cpp\" />\r\n    <ClCompile Include=\"common\\validators\\AssertionValidator.cpp\" />\r\n    <ClCompile Include=\"common\\validators\\CellSpecificationValidator.cpp\" />\r\n    <ClCompile Include=\"common\\validators\\ChoiceValidator.cpp\" />\r\n    <ClCompile Include=\"common\\validators\\CommonItemsValidator.cpp\" />\r\n    <ClCompile Include=\"common\\validators\\HierarchicalValidator.cpp\" />\r\n    <ClCompile Include=\"common\\validators\\namevalidator.cpp\" />\r\n    <ClCompile Include=\"common\\validators\\NMTokenValidator.cpp\" />\r\n    <ClCompile Include=\"common\\validators\\ParameterValidator.cpp\" />\r\n    <ClCompile Include=\"common\\validators\\ProtocolValidator.cpp\" />\r\n    <ClCompile Include=\"common\\validators\\QualifierValidator.cpp\" />\r\n    <ClCompile Include=\"common\\validators\\TimingConstraintValidator.cpp\" />\r\n    <ClCompile Include=\"common\\validators\\ValueFormatter.cpp\" />\r\n    <ClCompile Include=\"common\\Vector.cpp\" />\r\n    <ClCompile Include=\"common\\VLNV.cpp\" />\r\n    <ClCompile Include=\"Component\\AccessPolicy.cpp\" />\r\n    <ClCompile Include=\"Component\\AccessPolicyReader.cpp\" />\r\n    <ClCompile Include=\"Component\\AccessPolicyWriter.cpp\" />\r\n    <ClCompile Include=\"Component\\AddressBlock.cpp\" />\r\n    <ClCompile Include=\"Component\\AddressBlockReader.cpp\" />\r\n    <ClCompile Include=\"Component\\AddressBlockWriter.cpp\" />\r\n    <ClCompile Include=\"Component\\AddressSpace.cpp\" />\r\n    <ClCompile Include=\"Component\\AddressSpaceReader.cpp\" />\r\n    <ClCompile Include=\"Component\\AddressSpaceWriter.cpp\" />\r\n    <ClCompile Include=\"Component\\AlternateRegister.cpp\" />\r\n    <ClCompile Include=\"Component\\BuildCommand.cpp\" />\r\n    <ClCompile Include=\"Component\\BusInterface.cpp\" />\r\n    <ClCompile Include=\"Component\\BusInterfaceReader.cpp\" />\r\n    <ClCompile Include=\"Component\\BusInterfaceWriter.cpp\" />\r\n    <ClCompile Include=\"Component\\Channel.cpp\" />\r\n    <ClCompile Include=\"Component\\ChannelReader.cpp\" />\r\n    <ClCompile Include=\"Component\\ChannelWriter.cpp\" />\r\n    <ClCompile Include=\"Component\\Component.cpp\" />\r\n    <ClCompile Include=\"Component\\ComponentGenerator.cpp\" />\r\n    <ClCompile Include=\"Component\\ComponentGeneratorReader.cpp\" />\r\n    <ClCompile Include=\"Component\\ComponentGeneratorWriter.cpp\" />\r\n    <ClCompile Include=\"Component\\ComponentInstantiation.cpp\" />\r\n    <ClCompile Include=\"Component\\ComponentReader.cpp\" />\r\n    <ClCompile Include=\"Component\\ComponentWriter.cpp\" />\r\n    <ClCompile Include=\"Component\\Cpu.cpp\" />\r\n    <ClCompile Include=\"Component\\CPUReader.cpp\" />\r\n    <ClCompile Include=\"Component\\CPUWriter.cpp\" />\r\n    <ClCompile Include=\"Component\\DesignConfigurationInstantiation.cpp\" />\r\n    <ClCompile Include=\"Component\\DesignInstantiation.cpp\" />\r\n    <ClCompile Include=\"Component\\Driver.cpp\" />\r\n    <ClCompile Include=\"Component\\EnumeratedValue.cpp\" />\r\n    <ClCompile Include=\"Component\\EnumeratedValueReader.cpp\" />\r\n    <ClCompile Include=\"Component\\EnumeratedValueWriter.cpp\" />\r\n    <ClCompile Include=\"Component\\ExecutableImage.cpp\" />\r\n    <ClCompile Include=\"Component\\Field.cpp\" />\r\n    <ClCompile Include=\"Component\\FieldAccessPolicy.cpp\" />\r\n    <ClCompile Include=\"Component\\FieldAccessPolicyReader.cpp\" />\r\n    <ClCompile Include=\"Component\\FieldAccessPolicyWriter.cpp\" />\r\n    <ClCompile Include=\"Component\\FieldReader.cpp\" />\r\n    <ClCompile Include=\"Component\\FieldReference.cpp\" />\r\n    <ClCompile Include=\"Component\\FieldReferenceReader.cpp\" />\r\n    <ClCompile Include=\"Component\\FieldReferenceWriter.cpp\" />\r\n    <ClCompile Include=\"Component\\FieldReset.cpp\" />\r\n    <ClCompile Include=\"Component\\FieldSlice.cpp\" />\r\n    <ClCompile Include=\"Component\\FieldWriter.cpp\" />\r\n    <ClCompile Include=\"Component\\File.cpp\" />\r\n    <ClCompile Include=\"Component\\FileReader.cpp\" />\r\n    <ClCompile Include=\"Component\\FileSet.cpp\" />\r\n    <ClCompile Include=\"Component\\FileSetReader.cpp\" />\r\n    <ClCompile Include=\"Component\\FileSetRef.cpp\" />\r\n    <ClCompile Include=\"Component\\FileSetWriter.cpp\" />\r\n    <ClCompile Include=\"Component\\FileWriter.cpp\" />\r\n    <ClCompile Include=\"Component\\Function.cpp\" />\r\n    <ClCompile Include=\"Component\\IndirectInterface.cpp\" />\r\n    <ClCompile Include=\"Component\\IndirectInterfaceReader.cpp\" />\r\n    <ClCompile Include=\"Component\\IndirectInterfaceWriter.cpp\" />\r\n    <ClCompile Include=\"Component\\InitiatorInterface.cpp\" />\r\n    <ClCompile Include=\"Component\\InstantiationsReader.cpp\" />\r\n    <ClCompile Include=\"Component\\InstantiationsWriter.cpp\" />\r\n    <ClCompile Include=\"Component\\LanguageTools.cpp\" />\r\n    <ClCompile Include=\"Component\\MemoryArray.cpp\" />\r\n    <ClCompile Include=\"Component\\MemoryArrayReader.cpp\" />\r\n    <ClCompile Include=\"Component\\MemoryArrayWriter.cpp\" />\r\n    <ClCompile Include=\"Component\\MemoryBlockBase.cpp\" />\r\n    <ClCompile Include=\"Component\\MemoryBlockBaseReader.cpp\" />\r\n    <ClCompile Include=\"Component\\MemoryBlockBaseWriter.cpp\" />\r\n    <ClCompile Include=\"Component\\MemoryMap.cpp\" />\r\n    <ClCompile Include=\"Component\\MemoryMapBase.cpp\" />\r\n    <ClCompile Include=\"Component\\MemoryMapBaseReader.cpp\" />\r\n    <ClCompile Include=\"Component\\MemoryMapBaseWriter.cpp\" />\r\n    <ClCompile Include=\"Component\\MemoryMapReader.cpp\" />\r\n    <ClCompile Include=\"Component\\MemoryMapWriter.cpp\" />\r\n    <ClCompile Include=\"Component\\MemoryRemap.cpp\" />\r\n    <ClCompile Include=\"Component\\MirroredTargetInterface.cpp\" />\r\n    <ClCompile Include=\"Component\\Mode.cpp\" />\r\n    <ClCompile Include=\"Component\\Model.cpp\" />\r\n    <ClCompile Include=\"Component\\AbstractionType.cpp\" />\r\n    <ClCompile Include=\"Component\\ModeReference.cpp\" />\r\n    <ClCompile Include=\"Component\\ModeReader.cpp\" />\r\n    <ClCompile Include=\"Component\\ModeWriter.cpp\" />\r\n    <ClCompile Include=\"Component\\OtherClockDriver.cpp\" />\r\n    <ClCompile Include=\"Component\\OtherClockDriverReader.cpp\" />\r\n    <ClCompile Include=\"Component\\OtherClockDriverWriter.cpp\" />\r\n    <ClCompile Include=\"Component\\Port.cpp\" />\r\n    <ClCompile Include=\"Component\\PortMap.cpp\" />\r\n    <ClCompile Include=\"Component\\PortReader.cpp\" />\r\n    <ClCompile Include=\"Component\\PortSlice.cpp\" />\r\n    <ClCompile Include=\"Component\\PortWriter.cpp\" />\r\n    <ClCompile Include=\"Component\\PowerDomain.cpp\" />\r\n    <ClCompile Include=\"Component\\PowerDomainReader.cpp\" />\r\n    <ClCompile Include=\"Component\\PowerDomainWriter.cpp\" />\r\n    <ClCompile Include=\"Component\\Region.cpp\" />\r\n    <ClCompile Include=\"Component\\Register.cpp\" />\r\n    <ClCompile Include=\"Component\\RegisterBase.cpp\" />\r\n    <ClCompile Include=\"Component\\RegisterDefinition.cpp\" />\r\n    <ClCompile Include=\"Component\\RegisterFile.cpp\" />\r\n    <ClCompile Include=\"Component\\RegisterReader.cpp\" />\r\n    <ClCompile Include=\"Component\\RegisterWriter.cpp\" />\r\n    <ClCompile Include=\"Component\\RemapPort.cpp\" />\r\n    <ClCompile Include=\"Component\\RemapState.cpp\" />\r\n    <ClCompile Include=\"Component\\RemapStateReader.cpp\" />\r\n    <ClCompile Include=\"Component\\RemapStateWriter.cpp\" />\r\n    <ClCompile Include=\"Component\\Segment.cpp\" />\r\n    <ClCompile Include=\"Component\\Structured.cpp\" />\r\n    <ClCompile Include=\"Component\\SubPort.cpp\" />\r\n    <ClCompile Include=\"Component\\SubSpaceMap.cpp\" />\r\n    <ClCompile Include=\"Component\\SubspaceMapReader.cpp\" />\r\n    <ClCompile Include=\"Component\\SubSpaceMapWriter.cpp\" />\r\n    <ClCompile Include=\"Component\\TargetInterface.cpp\" />\r\n    <ClCompile Include=\"Component\\Transactional.cpp\" />\r\n    <ClCompile Include=\"Component\\TransparentBridge.cpp\" />\r\n    <ClCompile Include=\"Component\\validators\\AbstractionTypeValidator.cpp\" />\r\n    <ClCompile Include=\"Component\\validators\\AddressBlockValidator.cpp\" />\r\n    <ClCompile Include=\"Component\\validators\\AddressSpaceValidator.cpp\" />\r\n    <ClCompile Include=\"Component\\validators\\BusInterfaceValidator.cpp\" />\r\n    <ClCompile Include=\"Component\\validators\\ChannelValidator.cpp\" />\r\n    <ClCompile Include=\"Component\\validators\\CollectionValidators.cpp\" />\r\n    <ClCompile Include=\"Component\\validators\\ComponentGeneratorValidator.cpp\" />\r\n    <ClCompile Include=\"Component\\validators\\ComponentValidator.cpp\" />\r\n    <ClCompile Include=\"Component\\validators\\CPUValidator.cpp\" />\r\n    <ClCompile Include=\"Component\\validators\\EnumeratedValueValidator.cpp\" />\r\n    <ClCompile Include=\"Component\\validators\\FieldAccessPolicyValidator.cpp\" />\r\n    <ClCompile Include=\"Component\\validators\\FieldReferenceValidator.cpp\" />\r\n    <ClCompile Include=\"Component\\validators\\FieldSliceValidator.cpp\" />\r\n    <ClCompile Include=\"Component\\validators\\FieldValidator.cpp\" />\r\n    <ClCompile Include=\"Component\\validators\\FileSetValidator.cpp\" />\r\n    <ClCompile Include=\"Component\\validators\\FileValidator.cpp\" />\r\n    <ClCompile Include=\"Component\\validators\\IndirectInterfaceValidator.cpp\" />\r\n    <ClCompile Include=\"Component\\validators\\InstantiationsValidator.cpp\" />\r\n    <ClCompile Include=\"Component\\validators\\MemoryArrayValidator.cpp\" />\r\n    <ClCompile Include=\"Component\\validators\\MemoryBlockValidator.cpp\" />\r\n    <ClCompile Include=\"Component\\validators\\ModeValidator.cpp\" />\r\n    <ClCompile Include=\"Component\\validators\\PortMapValidator.cpp\" />\r\n    <ClCompile Include=\"Component\\validators\\OtherClockDriverValidator.cpp\" />\r\n    <ClCompile Include=\"Component\\validators\\PortSliceValidator.cpp\" />\r\n    <ClCompile Include=\"Component\\validators\\PortTypeValidator.cpp\" />\r\n    <ClCompile Include=\"Component\\validators\\PortValidator.cpp\" />\r\n    <ClCompile Include=\"Component\\validators\\PowerDomainValidator.cpp\" />\r\n    <ClCompile Include=\"Component\\validators\\RegionValidator.cpp\" />\r\n    <ClCompile Include=\"Component\\validators\\RegisterBaseValidator.cpp\" />\r\n    <ClCompile Include=\"Component\\validators\\RegisterFileValidator.cpp\" />\r\n    <ClCompile Include=\"Component\\validators\\RemapStateValidator.cpp\" />\r\n    <ClCompile Include=\"Component\\validators\\MemoryMapBaseValidator.cpp\" />\r\n    <ClCompile Include=\"Component\\validators\\MemoryMapValidator.cpp\" />\r\n    <ClCompile Include=\"Component\\validators\\MemoryReserve.cpp\" />\r\n    <ClCompile Include=\"Component\\validators\\RegisterValidator.cpp\" />\r\n    <ClCompile Include=\"Component\\validators\\SubspaceMapValidator.cpp\" />\r\n    <ClCompile Include=\"Component\\validators\\ViewValidator.cpp\" />\r\n    <ClCompile Include=\"Component\\View.cpp\" />\r\n    <ClCompile Include=\"Component\\ViewReader.cpp\" />\r\n    <ClCompile Include=\"Component\\ViewWriter.cpp\" />\r\n    <ClCompile Include=\"Component\\Wire.cpp\" />\r\n    <ClCompile Include=\"Component\\WireTypeDef.cpp\" />\r\n    <ClCompile Include=\"Component\\WriteValueConstraint.cpp\" />\r\n    <ClCompile Include=\"DesignConfiguration\\AbstractorInstance.cpp\" />\r\n    <ClCompile Include=\"DesignConfiguration\\DesignConfiguration.cpp\" />\r\n    <ClCompile Include=\"DesignConfiguration\\DesignConfigurationReader.cpp\" />\r\n    <ClCompile Include=\"DesignConfiguration\\DesignConfigurationWriter.cpp\" />\r\n    <ClCompile Include=\"DesignConfiguration\\InterconnectionConfiguration.cpp\" />\r\n    <ClCompile Include=\"DesignConfiguration\\InterfaceRef.cpp\" />\r\n    <ClCompile Include=\"DesignConfiguration\\MultipleAbstractorInstances.cpp\" />\r\n    <ClCompile Include=\"DesignConfiguration\\validators\\DesignConfigurationValidator.cpp\" />\r\n    <ClCompile Include=\"DesignConfiguration\\validators\\InterconnectionConfigurationValidator.cpp\" />\r\n    <ClCompile Include=\"DesignConfiguration\\validators\\ViewConfigurationValidator.cpp\" />\r\n    <ClCompile Include=\"DesignConfiguration\\ViewConfiguration.cpp\" />\r\n    <ClCompile Include=\"Design\\ActiveInterface.cpp\" />\r\n    <ClCompile Include=\"Design\\AdHocConnection.cpp\" />\r\n    <ClCompile Include=\"Design\\ComponentInstance.cpp\" />\r\n    <ClCompile Include=\"Design\\ComponentInstanceReader.cpp\" />\r\n    <ClCompile Include=\"Design\\ComponentInstanceWriter.cpp\" />\r\n    <ClCompile Include=\"Design\\Design.cpp\" />\r\n    <ClCompile Include=\"Design\\DesignReader.cpp\" />\r\n    <ClCompile Include=\"Design\\DesignWriter.cpp\" />\r\n    <ClCompile Include=\"Design\\HierInterface.cpp\" />\r\n    <ClCompile Include=\"Design\\Interconnection.cpp\" />\r\n    <ClCompile Include=\"Design\\MonitorInterconnection.cpp\" />\r\n    <ClCompile Include=\"Design\\MonitorInterface.cpp\" />\r\n    <ClCompile Include=\"Design\\PortReference.cpp\" />\r\n    <ClCompile Include=\"Design\\validator\\AdHocConnectionValidator.cpp\" />\r\n    <ClCompile Include=\"Design\\validator\\ComponentInstanceValidator.cpp\" />\r\n    <ClCompile Include=\"Design\\validator\\DesignValidator.cpp\" />\r\n    <ClCompile Include=\"Design\\validator\\InterconnectionValidator.cpp\" />\r\n    <ClCompile Include=\"generaldeclarations.cpp\" />\r\n    <ClCompile Include=\"kactusExtensions\\ApiDefinition.cpp\" />\r\n    <ClCompile Include=\"kactusExtensions\\ApiDefinitionReader.cpp\" />\r\n    <ClCompile Include=\"kactusExtensions\\ApiDefinitionWriter.cpp\" />\r\n    <ClCompile Include=\"kactusExtensions\\ApiFunction.cpp\" />\r\n    <ClCompile Include=\"kactusExtensions\\ApiFunctionParameter.cpp\" />\r\n    <ClCompile Include=\"kactusExtensions\\ApiInterconnection.cpp\" />\r\n    <ClCompile Include=\"kactusExtensions\\ApiInterface.cpp\" />\r\n    <ClCompile Include=\"kactusExtensions\\ColumnDesc.cpp\" />\r\n    <ClCompile Include=\"kactusExtensions\\ComDefinition.cpp\" />\r\n    <ClCompile Include=\"kactusExtensions\\ComDefinitionReader.cpp\" />\r\n    <ClCompile Include=\"kactusExtensions\\ComDefinitionWriter.cpp\" />\r\n    <ClCompile Include=\"kactusExtensions\\ComInterconnection.cpp\" />\r\n    <ClCompile Include=\"kactusExtensions\\ComInterface.cpp\" />\r\n    <ClCompile Include=\"kactusExtensions\\ComProperty.cpp\" />\r\n    <ClCompile Include=\"kactusExtensions\\ConnectionRoute.cpp\" />\r\n    <ClCompile Include=\"kactusExtensions\\FileDependency.cpp\" />\r\n    <ClCompile Include=\"kactusExtensions\\HierApiInterconnection.cpp\" />\r\n    <ClCompile Include=\"kactusExtensions\\HierComInterconnection.cpp\" />\r\n    <ClCompile Include=\"kactusExtensions\\InterfaceGraphicsData.cpp\" />\r\n    <ClCompile Include=\"kactusExtensions\\Kactus2Group.cpp\" />\r\n    <ClCompile Include=\"kactusExtensions\\Kactus2Placeholder.cpp\" />\r\n    <ClCompile Include=\"kactusExtensions\\Kactus2Position.cpp\" />\r\n    <ClCompile Include=\"kactusExtensions\\Kactus2Value.cpp\" />\r\n    <ClCompile Include=\"kactusExtensions\\KactusAttribute.cpp\" />\r\n    <ClCompile Include=\"kactusExtensions\\SystemView.cpp\" />\r\n    <ClCompile Include=\"kactusExtensions\\validators\\ApiDefinitionValidator.cpp\" />\r\n    <ClCompile Include=\"kactusExtensions\\validators\\ComDefinitionValidator.cpp\" />\r\n    <ClCompile Include=\"kactusExtensions\\validators\\SystemDesignConfigurationValidator.cpp\" />\r\n    <ClCompile Include=\"kactusExtensions\\validators\\SystemViewConfigurationValidator.cpp\" />\r\n    <ClCompile Include=\"utilities\\BusDefinitionUtils.cpp\" />\r\n    <ClCompile Include=\"utilities\\XmlUtils.cpp\" />\r\n  </ItemGroup>\r\n  <ItemGroup>\r\n    <ClInclude Include=\"AbstractionDefinition\\AbstractionDefinition.h\" />\r\n    <ClInclude Include=\"AbstractionDefinition\\Packet.h\" />\r\n    <ClInclude Include=\"AbstractionDefinition\\PacketField.h\" />\r\n    <ClInclude Include=\"AbstractionDefinition\\PacketReader.h\" />\r\n    <ClInclude Include=\"AbstractionDefinition\\PacketWriter.h\" />\r\n    <ClInclude Include=\"AbstractionDefinition\\validators\\PacketValidator.h\" />\r\n    <ClInclude Include=\"AbstractionDefinition\\validators\\PortAbstractionValidator.h\" />\r\n    <ClInclude Include=\"common\\Choice.h\" />\r\n    <ClInclude Include=\"common\\ChoiceReader.h\" />\r\n    <ClInclude Include=\"common\\ChoiceWriter.h\" />\r\n    <ClInclude Include=\"common\\DocumentUtils.h\" />\r\n    <ClInclude Include=\"common\\FileType.h\" />\r\n    <ClInclude Include=\"common\\QualifierReader.h\" />\r\n    <ClInclude Include=\"common\\QualifierWriter.h\" />\r\n    <ClInclude Include=\"common\\TagData.h\" />\r\n    <ClInclude Include=\"common\\validators\\ChoiceValidator.h\" />\r\n    <ClInclude Include=\"common\\validators\\CommonItemsValidator.h\" />\r\n    <ClInclude Include=\"common\\validators\\HierarchicalValidator.h\" />\r\n    <ClInclude Include=\"common\\validators\\QualifierValidator.h\" />\r\n    <ClInclude Include=\"Component\\AccessPolicy.h\" />\r\n    <ClInclude Include=\"Component\\AccessPolicyReader.h\" />\r\n    <ClInclude Include=\"Component\\AccessPolicyWriter.h\" />\r\n    <ClInclude Include=\"Component\\Driver.h\" />\r\n    <ClInclude Include=\"Component\\ExecutableImage.h\" />\r\n    <ClInclude Include=\"Component\\FieldAccessPolicy.h\" />\r\n    <ClInclude Include=\"Component\\FieldAccessPolicyReader.h\" />\r\n    <ClInclude Include=\"Component\\FieldAccessPolicyWriter.h\" />\r\n    <ClInclude Include=\"Component\\FieldReference.h\" />\r\n    <ClInclude Include=\"Component\\FieldReferenceReader.h\" />\r\n    <ClInclude Include=\"Component\\FieldReferenceWriter.h\" />\r\n    <ClInclude Include=\"Component\\FieldReset.h\" />\r\n    <ClInclude Include=\"Component\\FieldSlice.h\" />\r\n    <ClInclude Include=\"Component\\InitiatorInterface.h\" />\r\n    <ClInclude Include=\"Component\\FileSetRef.h\" />\r\n    <ClInclude Include=\"Component\\LanguageTools.h\" />\r\n    <ClInclude Include=\"Component\\MemoryArray.h\" />\r\n    <ClInclude Include=\"Component\\MemoryArrayReader.h\" />\r\n    <ClInclude Include=\"Component\\MemoryArrayWriter.h\" />\r\n    <ClInclude Include=\"Component\\MemoryBlockBaseReader.h\" />\r\n    <ClInclude Include=\"Component\\MemoryBlockBaseWriter.h\" />\r\n    <ClInclude Include=\"Component\\ModeReference.h\" />\r\n    <ClInclude Include=\"Component\\MirroredTargetInterface.h\" />\r\n    <ClInclude Include=\"Component\\Mode.h\" />\r\n    <ClInclude Include=\"Component\\ModeReader.h\" />\r\n    <ClInclude Include=\"Component\\ModeWriter.h\" />\r\n    <ClInclude Include=\"Component\\PortSlice.h\" />\r\n    <ClInclude Include=\"Component\\PowerDomain.h\" />\r\n    <ClInclude Include=\"Component\\PowerDomainReader.h\" />\r\n    <ClInclude Include=\"Component\\PowerDomainWriter.h\" />\r\n    <ClInclude Include=\"Component\\Region.h\" />\r\n    <ClInclude Include=\"Component\\Structured.h\" />\r\n    <ClInclude Include=\"Component\\SubPort.h\" />\r\n    <ClInclude Include=\"Component\\SubSpaceMap.h\" />\r\n    <ClInclude Include=\"Component\\SubspaceMapReader.h\" />\r\n    <ClInclude Include=\"Component\\SubSpaceMapWriter.h\" />\r\n    <ClInclude Include=\"Component\\validators\\CollectionValidators.h\" />\r\n    <ClInclude Include=\"Component\\validators\\FieldAccessPolicyValidator.h\" />\r\n    <ClInclude Include=\"Component\\validators\\FieldReferenceValidator.h\" />\r\n    <ClInclude Include=\"Component\\validators\\FieldSliceValidator.h\" />\r\n    <ClInclude Include=\"Component\\validators\\MemoryArrayValidator.h\" />\r\n    <ClInclude Include=\"Component\\TargetInterface.h\" />\r\n    <ClInclude Include=\"Component\\validators\\MemoryBlockValidator.h\" />\r\n    <ClInclude Include=\"Component\\validators\\ModeValidator.h\" />\r\n    <ClInclude Include=\"Component\\validators\\PortSliceValidator.h\" />\r\n    <ClInclude Include=\"Component\\validators\\PowerDomainValidator.h\" />\r\n    <ClInclude Include=\"Component\\validators\\RegionValidator.h\" />\r\n    <ClInclude Include=\"Component\\validators\\RegisterBaseValidator.h\" />\r\n    <ClInclude Include=\"Component\\validators\\RegisterFileValidator.h\" />\r\n    <ClInclude Include=\"Component\\validators\\SubspaceMapValidator.h\" />\r\n    <ClInclude Include=\"DesignConfiguration\\AbstractorInstance.h\" />\r\n    <ClInclude Include=\"DesignConfiguration\\DesignConfiguration.h\" />\r\n    <ClInclude Include=\"DesignConfiguration\\DesignConfigurationReader.h\" />\r\n    <ClInclude Include=\"DesignConfiguration\\DesignConfigurationWriter.h\" />\r\n    <ClInclude Include=\"DesignConfiguration\\InterconnectionConfiguration.h\" />\r\n    <ClInclude Include=\"DesignConfiguration\\InterfaceRef.h\" />\r\n    <ClInclude Include=\"DesignConfiguration\\MultipleAbstractorInstances.h\" />\r\n    <ClInclude Include=\"DesignConfiguration\\validators\\DesignConfigurationValidator.h\" />\r\n    <ClInclude Include=\"DesignConfiguration\\validators\\InterconnectionConfigurationValidator.h\" />\r\n    <ClInclude Include=\"DesignConfiguration\\validators\\ViewConfigurationValidator.h\" />\r\n    <ClInclude Include=\"DesignConfiguration\\ViewConfiguration.h\" />\r\n    <ClInclude Include=\"utilities\\BusDefinitionUtils.h\" />\r\n    <ClInclude Include=\"utilities\\Copy.h\" />\r\n    <ClInclude Include=\"utilities\\XmlUtils.h\" />\r\n    <CustomBuild Include=\"AbstractionDefinition\\AbstractionDefinitionReader.h\">\r\n      <AdditionalInputs Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">%(AdditionalInputs)</AdditionalInputs>\r\n      <Message Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n      </Message>\r\n      <Outputs Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n      </Outputs>\r\n      <Command Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n      </Command>\r\n      <AdditionalInputs Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">%(AdditionalInputs)</AdditionalInputs>\r\n      <Message Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n      </Message>\r\n      <Outputs Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n      </Outputs>\r\n      <Command Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n      </Command>\r\n    </CustomBuild>\r\n    <CustomBuild Include=\"AbstractionDefinition\\AbstractionDefinitionWriter.h\">\r\n      <AdditionalInputs Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">%(AdditionalInputs)</AdditionalInputs>\r\n      <Message Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n      </Message>\r\n      <Outputs Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n      </Outputs>\r\n      <Command Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n      </Command>\r\n      <AdditionalInputs Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">%(AdditionalInputs)</AdditionalInputs>\r\n      <Message Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n      </Message>\r\n      <Outputs Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n      </Outputs>\r\n      <Command Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n      </Command>\r\n    </CustomBuild>\r\n    <ClInclude Include=\"AbstractionDefinition\\PortAbstraction.h\" />\r\n    <ClInclude Include=\"AbstractionDefinition\\TransactionalAbstraction.h\" />\r\n    <ClInclude Include=\"AbstractionDefinition\\TransactionalAbstractionReader.h\" />\r\n    <ClInclude Include=\"AbstractionDefinition\\TransactionalAbstractionWriter.h\" />\r\n    <ClInclude Include=\"AbstractionDefinition\\TransactionalPort.h\" />\r\n    <ClInclude Include=\"AbstractionDefinition\\validators\\AbstractionDefinitionValidator.h\" />\r\n    <ClInclude Include=\"AbstractionDefinition\\WireAbstraction.h\" />\r\n    <ClInclude Include=\"AbstractionDefinition\\WireAbstractionReader.h\" />\r\n    <ClInclude Include=\"AbstractionDefinition\\WireAbstractionWriter.h\" />\r\n    <ClInclude Include=\"AbstractionDefinition\\WirePort.h\" />\r\n    <ClInclude Include=\"BusDefinition\\validators\\BusDefinitionValidator.h\" />\r\n    <ClInclude Include=\"Catalog\\Catalog.h\" />\r\n    <CustomBuild Include=\"Catalog\\CatalogReader.h\">\r\n      <AdditionalInputs Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">%(AdditionalInputs)</AdditionalInputs>\r\n      <Message Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n      </Message>\r\n      <Outputs Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n      </Outputs>\r\n      <Command Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n      </Command>\r\n      <AdditionalInputs Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">%(AdditionalInputs)</AdditionalInputs>\r\n      <Message Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n      </Message>\r\n      <Outputs Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n      </Outputs>\r\n      <Command Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n      </Command>\r\n    </CustomBuild>\r\n    <CustomBuild Include=\"Catalog\\CatalogWriter.h\">\r\n      <AdditionalInputs Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">%(AdditionalInputs)</AdditionalInputs>\r\n      <Message Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n      </Message>\r\n      <Outputs Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n      </Outputs>\r\n      <Command Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n      </Command>\r\n      <AdditionalInputs Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">%(AdditionalInputs)</AdditionalInputs>\r\n      <Message Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n      </Message>\r\n      <Outputs Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n      </Outputs>\r\n      <Command Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n      </Command>\r\n    </CustomBuild>\r\n    <ClInclude Include=\"Catalog\\IpxactFile.h\" />\r\n    <ClInclude Include=\"Catalog\\validators\\CatalogValidator.h\" />\r\n    <ClInclude Include=\"common\\AccessTypes.h\" />\r\n    <ClInclude Include=\"common\\Array.h\" />\r\n    <ClInclude Include=\"common\\Assertion.h\" />\r\n    <ClInclude Include=\"common\\BooleanValue.h\" />\r\n    <ClInclude Include=\"common\\BuildModel.h\" />\r\n    <ClInclude Include=\"common\\CellSpecification.h\" />\r\n    <ClInclude Include=\"common\\ClockUnit.h\" />\r\n    <CustomBuild Include=\"common\\CommonItemsReader.h\">\r\n      <AdditionalInputs Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">%(AdditionalInputs)</AdditionalInputs>\r\n      <Message Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n      </Message>\r\n      <Outputs Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n      </Outputs>\r\n      <Command Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n      </Command>\r\n      <AdditionalInputs Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">%(AdditionalInputs)</AdditionalInputs>\r\n      <Message Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n      </Message>\r\n      <Outputs Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n      </Outputs>\r\n      <Command Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n      </Command>\r\n    </CustomBuild>\r\n    <CustomBuild Include=\"common\\CommonItemsWriter.h\">\r\n      <AdditionalInputs Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">%(AdditionalInputs)</AdditionalInputs>\r\n      <Message Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n      </Message>\r\n      <Outputs Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n      </Outputs>\r\n      <Command Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n      </Command>\r\n      <AdditionalInputs Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">%(AdditionalInputs)</AdditionalInputs>\r\n      <Message Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n      </Message>\r\n      <Outputs Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n      </Outputs>\r\n      <Command Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n      </Command>\r\n    </CustomBuild>\r\n    <ClInclude Include=\"common\\ConfigurableElementValue.h\" />\r\n    <ClInclude Include=\"common\\ConfigurableVLNVReference.h\" />\r\n    <ClInclude Include=\"common\\DirectionTypes.h\" />\r\n    <ClInclude Include=\"common\\Document.h\" />\r\n    <CustomBuild Include=\"common\\DocumentReader.h\">\r\n      <AdditionalInputs Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">%(AdditionalInputs)</AdditionalInputs>\r\n      <Message Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n      </Message>\r\n      <Outputs Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n      </Outputs>\r\n      <Command Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n      </Command>\r\n      <AdditionalInputs Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">%(AdditionalInputs)</AdditionalInputs>\r\n      <Message Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n      </Message>\r\n      <Outputs Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n      </Outputs>\r\n      <Command Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n      </Command>\r\n    </CustomBuild>\r\n    <CustomBuild Include=\"common\\DocumentWriter.h\">\r\n      <AdditionalInputs Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">%(AdditionalInputs)</AdditionalInputs>\r\n      <Message Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n      </Message>\r\n      <Outputs Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n      </Outputs>\r\n      <Command Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n      </Command>\r\n      <AdditionalInputs Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">%(AdditionalInputs)</AdditionalInputs>\r\n      <Message Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n      </Message>\r\n      <Outputs Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n      </Outputs>\r\n      <Command Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n      </Command>\r\n    </CustomBuild>\r\n    <ClInclude Include=\"common\\Enumeration.h\" />\r\n    <ClInclude Include=\"common\\Extendable.h\" />\r\n    <ClInclude Include=\"common\\FileBuilder.h\" />\r\n    <CustomBuild Include=\"common\\FileBuilderReader.h\">\r\n      <AdditionalInputs Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">%(AdditionalInputs)</AdditionalInputs>\r\n      <Message Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n      </Message>\r\n      <Outputs Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n      </Outputs>\r\n      <Command Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n      </Command>\r\n      <AdditionalInputs Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">%(AdditionalInputs)</AdditionalInputs>\r\n      <Message Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n      </Message>\r\n      <Outputs Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n      </Outputs>\r\n      <Command Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n      </Command>\r\n    </CustomBuild>\r\n    <CustomBuild Include=\"common\\FileBuilderWriter.h\">\r\n      <AdditionalInputs Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">%(AdditionalInputs)</AdditionalInputs>\r\n      <Message Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n      </Message>\r\n      <Outputs Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n      </Outputs>\r\n      <Command Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n      </Command>\r\n      <AdditionalInputs Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">%(AdditionalInputs)</AdditionalInputs>\r\n      <Message Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n      </Message>\r\n      <Outputs Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n      </Outputs>\r\n      <Command Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n      </Command>\r\n    </CustomBuild>\r\n    <CustomBuild Include=\"common\\GenericVendorExtension.h\">\r\n      <Message Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n      </Message>\r\n      <Outputs Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n      </Outputs>\r\n      <Command Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n      </Command>\r\n      <Message Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n      </Message>\r\n      <Outputs Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n      </Outputs>\r\n      <Command Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n      </Command>\r\n    </CustomBuild>\r\n    <ClInclude Include=\"common\\ModuleParameter.h\" />\r\n    <ClInclude Include=\"common\\ModuleParameterReader.h\" />\r\n    <ClInclude Include=\"common\\ModuleParameterWriter.h\" />\r\n    <ClInclude Include=\"common\\NameGroup.h\" />\r\n    <ClInclude Include=\"common\\NameGroupReader.h\" />\r\n    <ClInclude Include=\"common\\NameGroupWriter.h\" />\r\n    <ClInclude Include=\"common\\NameValuePair.h\" />\r\n    <ClInclude Include=\"common\\Parameter.h\" />\r\n    <ClInclude Include=\"common\\ParameterReader.h\" />\r\n    <ClInclude Include=\"common\\ParameterWriter.h\" />\r\n    <ClInclude Include=\"common\\PartSelect.h\" />\r\n    <ClInclude Include=\"common\\PortAlignment.h\" />\r\n    <ClInclude Include=\"common\\PresenceTypes.h\" />\r\n    <ClInclude Include=\"common\\Protocol.h\" />\r\n    <ClInclude Include=\"common\\ProtocolReader.h\" />\r\n    <ClInclude Include=\"common\\ProtocolWriter.h\" />\r\n    <ClInclude Include=\"common\\Qualifier.h\" />\r\n    <ClInclude Include=\"common\\Range.h\" />\r\n    <ClInclude Include=\"common\\TimingConstraint.h\" />\r\n    <ClInclude Include=\"common\\TransactionalTypes.h\" />\r\n    <ClInclude Include=\"common\\validators\\AssertionValidator.h\" />\r\n    <ClInclude Include=\"common\\validators\\CellSpecificationValidator.h\" />\r\n    <QtMoc Include=\"common\\validators\\namevalidator.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"common\\validators\\NMTokenValidator.h\">\r\n    </QtMoc>\r\n    <ClInclude Include=\"common\\validators\\ParameterValidator.h\" />\r\n    <ClInclude Include=\"common\\validators\\ProtocolValidator.h\" />\r\n    <ClInclude Include=\"common\\validators\\TimingConstraintValidator.h\" />\r\n    <ClInclude Include=\"common\\validators\\ValueFormatter.h\" />\r\n    <ClInclude Include=\"common\\Vector.h\" />\r\n    <ClInclude Include=\"common\\VendorExtension.h\" />\r\n    <ClInclude Include=\"common\\VLNV.h\" />\r\n    <ClInclude Include=\"Component\\AddressBlock.h\" />\r\n    <CustomBuild Include=\"Component\\AddressBlockReader.h\">\r\n      <AdditionalInputs Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">%(AdditionalInputs)</AdditionalInputs>\r\n      <Message Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n      </Message>\r\n      <Outputs Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n      </Outputs>\r\n      <Command Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n      </Command>\r\n      <AdditionalInputs Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">%(AdditionalInputs)</AdditionalInputs>\r\n      <Message Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n      </Message>\r\n      <Outputs Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n      </Outputs>\r\n      <Command Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n      </Command>\r\n    </CustomBuild>\r\n    <CustomBuild Include=\"Component\\AddressBlockWriter.h\">\r\n      <AdditionalInputs Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">%(AdditionalInputs)</AdditionalInputs>\r\n      <Message Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n      </Message>\r\n      <Outputs Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n      </Outputs>\r\n      <Command Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n      </Command>\r\n      <AdditionalInputs Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">%(AdditionalInputs)</AdditionalInputs>\r\n      <Message Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n      </Message>\r\n      <Outputs Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n      </Outputs>\r\n      <Command Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n      </Command>\r\n    </CustomBuild>\r\n    <ClInclude Include=\"Component\\AddressSpace.h\" />\r\n    <CustomBuild Include=\"Component\\AddressSpaceReader.h\">\r\n      <AdditionalInputs Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">%(AdditionalInputs)</AdditionalInputs>\r\n      <Message Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n      </Message>\r\n      <Outputs Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n      </Outputs>\r\n      <Command Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n      </Command>\r\n      <AdditionalInputs Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">%(AdditionalInputs)</AdditionalInputs>\r\n      <Message Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n      </Message>\r\n      <Outputs Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n      </Outputs>\r\n      <Command Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n      </Command>\r\n    </CustomBuild>\r\n    <CustomBuild Include=\"Component\\AddressSpaceWriter.h\">\r\n      <AdditionalInputs Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">%(AdditionalInputs)</AdditionalInputs>\r\n      <Message Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n      </Message>\r\n      <Outputs Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n      </Outputs>\r\n      <Command Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n      </Command>\r\n      <AdditionalInputs Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">%(AdditionalInputs)</AdditionalInputs>\r\n      <Message Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n      </Message>\r\n      <Outputs Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n      </Outputs>\r\n      <Command Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n      </Command>\r\n    </CustomBuild>\r\n    <ClInclude Include=\"Component\\AlternateRegister.h\" />\r\n    <ClInclude Include=\"Component\\BuildCommand.h\" />\r\n    <ClInclude Include=\"Component\\BusInterface.h\" />\r\n    <CustomBuild Include=\"Component\\BusInterfaceReader.h\">\r\n      <AdditionalInputs Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">%(AdditionalInputs)</AdditionalInputs>\r\n      <Message Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n      </Message>\r\n      <Outputs Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n      </Outputs>\r\n      <Command Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n      </Command>\r\n      <AdditionalInputs Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">%(AdditionalInputs)</AdditionalInputs>\r\n      <Message Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n      </Message>\r\n      <Outputs Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n      </Outputs>\r\n      <Command Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n      </Command>\r\n    </CustomBuild>\r\n    <CustomBuild Include=\"Component\\BusInterfaceWriter.h\">\r\n      <AdditionalInputs Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">%(AdditionalInputs)</AdditionalInputs>\r\n      <Message Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n      </Message>\r\n      <Outputs Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n      </Outputs>\r\n      <Command Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n      </Command>\r\n      <AdditionalInputs Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">%(AdditionalInputs)</AdditionalInputs>\r\n      <Message Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n      </Message>\r\n      <Outputs Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n      </Outputs>\r\n      <Command Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n      </Command>\r\n    </CustomBuild>\r\n    <ClInclude Include=\"Component\\Channel.h\" />\r\n    <CustomBuild Include=\"Component\\ChannelReader.h\">\r\n      <AdditionalInputs Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">%(AdditionalInputs)</AdditionalInputs>\r\n      <Message Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n      </Message>\r\n      <Outputs Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n      </Outputs>\r\n      <Command Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n      </Command>\r\n      <AdditionalInputs Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">%(AdditionalInputs)</AdditionalInputs>\r\n      <Message Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n      </Message>\r\n      <Outputs Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n      </Outputs>\r\n      <Command Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n      </Command>\r\n    </CustomBuild>\r\n    <CustomBuild Include=\"Component\\ChannelWriter.h\">\r\n      <AdditionalInputs Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">%(AdditionalInputs)</AdditionalInputs>\r\n      <Message Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n      </Message>\r\n      <Outputs Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n      </Outputs>\r\n      <Command Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n      </Command>\r\n      <AdditionalInputs Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">%(AdditionalInputs)</AdditionalInputs>\r\n      <Message Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n      </Message>\r\n      <Outputs Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n      </Outputs>\r\n      <Command Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n      </Command>\r\n    </CustomBuild>\r\n    <ClInclude Include=\"Component\\Component.h\" />\r\n    <ClInclude Include=\"Component\\ComponentGenerator.h\" />\r\n    <CustomBuild Include=\"Component\\ComponentGeneratorReader.h\">\r\n      <AdditionalInputs Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">%(AdditionalInputs)</AdditionalInputs>\r\n      <Message Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n      </Message>\r\n      <Outputs Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n      </Outputs>\r\n      <Command Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n      </Command>\r\n      <AdditionalInputs Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">%(AdditionalInputs)</AdditionalInputs>\r\n      <Message Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n      </Message>\r\n      <Outputs Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n      </Outputs>\r\n      <Command Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n      </Command>\r\n    </CustomBuild>\r\n    <CustomBuild Include=\"Component\\ComponentGeneratorWriter.h\">\r\n      <AdditionalInputs Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">%(AdditionalInputs)</AdditionalInputs>\r\n      <Message Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n      </Message>\r\n      <Outputs Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n      </Outputs>\r\n      <Command Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n      </Command>\r\n      <AdditionalInputs Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">%(AdditionalInputs)</AdditionalInputs>\r\n      <Message Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n      </Message>\r\n      <Outputs Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n      </Outputs>\r\n      <Command Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n      </Command>\r\n    </CustomBuild>\r\n    <ClInclude Include=\"Component\\ComponentInstantiation.h\" />\r\n    <CustomBuild Include=\"Component\\ComponentReader.h\">\r\n      <AdditionalInputs Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">%(AdditionalInputs)</AdditionalInputs>\r\n      <Message Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n      </Message>\r\n      <Outputs Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n      </Outputs>\r\n      <Command Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n      </Command>\r\n      <AdditionalInputs Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">%(AdditionalInputs)</AdditionalInputs>\r\n      <Message Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n      </Message>\r\n      <Outputs Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n      </Outputs>\r\n      <Command Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n      </Command>\r\n    </CustomBuild>\r\n    <CustomBuild Include=\"Component\\ComponentWriter.h\">\r\n      <AdditionalInputs Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">%(AdditionalInputs)</AdditionalInputs>\r\n      <Message Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n      </Message>\r\n      <Outputs Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n      </Outputs>\r\n      <Command Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n      </Command>\r\n      <AdditionalInputs Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">%(AdditionalInputs)</AdditionalInputs>\r\n      <Message Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n      </Message>\r\n      <Outputs Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n      </Outputs>\r\n      <Command Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n      </Command>\r\n    </CustomBuild>\r\n    <ClInclude Include=\"Component\\Cpu.h\" />\r\n    <CustomBuild Include=\"Component\\CPUReader.h\">\r\n      <AdditionalInputs Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">%(AdditionalInputs)</AdditionalInputs>\r\n      <Message Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n      </Message>\r\n      <Outputs Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n      </Outputs>\r\n      <Command Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n      </Command>\r\n      <AdditionalInputs Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">%(AdditionalInputs)</AdditionalInputs>\r\n      <Message Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n      </Message>\r\n      <Outputs Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n      </Outputs>\r\n      <Command Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n      </Command>\r\n    </CustomBuild>\r\n    <CustomBuild Include=\"Component\\CPUWriter.h\">\r\n      <AdditionalInputs Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">%(AdditionalInputs)</AdditionalInputs>\r\n      <Message Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n      </Message>\r\n      <Outputs Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n      </Outputs>\r\n      <Command Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n      </Command>\r\n      <AdditionalInputs Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">%(AdditionalInputs)</AdditionalInputs>\r\n      <Message Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n      </Message>\r\n      <Outputs Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n      </Outputs>\r\n      <Command Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n      </Command>\r\n    </CustomBuild>\r\n    <ClInclude Include=\"Component\\DesignConfigurationInstantiation.h\" />\r\n    <ClInclude Include=\"Component\\DesignInstantiation.h\" />\r\n    <ClInclude Include=\"Component\\EnumeratedValue.h\" />\r\n    <CustomBuild Include=\"Component\\EnumeratedValueReader.h\">\r\n      <AdditionalInputs Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">%(AdditionalInputs)</AdditionalInputs>\r\n      <Message Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n      </Message>\r\n      <Outputs Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n      </Outputs>\r\n      <Command Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n      </Command>\r\n      <AdditionalInputs Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">%(AdditionalInputs)</AdditionalInputs>\r\n      <Message Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n      </Message>\r\n      <Outputs Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n      </Outputs>\r\n      <Command Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n      </Command>\r\n    </CustomBuild>\r\n    <CustomBuild Include=\"Component\\EnumeratedValueWriter.h\">\r\n      <AdditionalInputs Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">%(AdditionalInputs)</AdditionalInputs>\r\n      <Message Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n      </Message>\r\n      <Outputs Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n      </Outputs>\r\n      <Command Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n      </Command>\r\n      <AdditionalInputs Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">%(AdditionalInputs)</AdditionalInputs>\r\n      <Message Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n      </Message>\r\n      <Outputs Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n      </Outputs>\r\n      <Command Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n      </Command>\r\n    </CustomBuild>\r\n    <ClInclude Include=\"Component\\Field.h\" />\r\n    <CustomBuild Include=\"Component\\FieldReader.h\">\r\n      <AdditionalInputs Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">%(AdditionalInputs)</AdditionalInputs>\r\n      <Message Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n      </Message>\r\n      <Outputs Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n      </Outputs>\r\n      <Command Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n      </Command>\r\n      <AdditionalInputs Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">%(AdditionalInputs)</AdditionalInputs>\r\n      <Message Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n      </Message>\r\n      <Outputs Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n      </Outputs>\r\n      <Command Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n      </Command>\r\n    </CustomBuild>\r\n    <CustomBuild Include=\"Component\\FieldWriter.h\">\r\n      <AdditionalInputs Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">%(AdditionalInputs)</AdditionalInputs>\r\n      <Message Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n      </Message>\r\n      <Outputs Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n      </Outputs>\r\n      <Command Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n      </Command>\r\n      <AdditionalInputs Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">%(AdditionalInputs)</AdditionalInputs>\r\n      <Message Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n      </Message>\r\n      <Outputs Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n      </Outputs>\r\n      <Command Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n      </Command>\r\n    </CustomBuild>\r\n    <ClInclude Include=\"Component\\File.h\" />\r\n    <CustomBuild Include=\"Component\\FileReader.h\">\r\n      <AdditionalInputs Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">%(AdditionalInputs)</AdditionalInputs>\r\n      <Message Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n      </Message>\r\n      <Outputs Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n      </Outputs>\r\n      <Command Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n      </Command>\r\n      <AdditionalInputs Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">%(AdditionalInputs)</AdditionalInputs>\r\n      <Message Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n      </Message>\r\n      <Outputs Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n      </Outputs>\r\n      <Command Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n      </Command>\r\n    </CustomBuild>\r\n    <ClInclude Include=\"Component\\FileSet.h\" />\r\n    <CustomBuild Include=\"Component\\FileSetReader.h\">\r\n      <AdditionalInputs Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">%(AdditionalInputs)</AdditionalInputs>\r\n      <Message Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n      </Message>\r\n      <Outputs Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n      </Outputs>\r\n      <Command Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n      </Command>\r\n      <AdditionalInputs Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">%(AdditionalInputs)</AdditionalInputs>\r\n      <Message Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n      </Message>\r\n      <Outputs Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n      </Outputs>\r\n      <Command Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n      </Command>\r\n    </CustomBuild>\r\n    <CustomBuild Include=\"Component\\FileSetWriter.h\">\r\n      <AdditionalInputs Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">%(AdditionalInputs)</AdditionalInputs>\r\n      <Message Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n      </Message>\r\n      <Outputs Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n      </Outputs>\r\n      <Command Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n      </Command>\r\n      <AdditionalInputs Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">%(AdditionalInputs)</AdditionalInputs>\r\n      <Message Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n      </Message>\r\n      <Outputs Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n      </Outputs>\r\n      <Command Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n      </Command>\r\n    </CustomBuild>\r\n    <CustomBuild Include=\"Component\\FileWriter.h\">\r\n      <AdditionalInputs Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">%(AdditionalInputs)</AdditionalInputs>\r\n      <Message Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n      </Message>\r\n      <Outputs Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n      </Outputs>\r\n      <Command Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n      </Command>\r\n      <AdditionalInputs Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">%(AdditionalInputs)</AdditionalInputs>\r\n      <Message Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n      </Message>\r\n      <Outputs Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n      </Outputs>\r\n      <Command Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n      </Command>\r\n    </CustomBuild>\r\n    <ClInclude Include=\"Component\\Function.h\" />\r\n    <CustomBuild Include=\"Component\\InstantiationsReader.h\">\r\n      <AdditionalInputs Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">%(AdditionalInputs)</AdditionalInputs>\r\n      <Message Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n      </Message>\r\n      <Outputs Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n      </Outputs>\r\n      <Command Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n      </Command>\r\n      <AdditionalInputs Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">%(AdditionalInputs)</AdditionalInputs>\r\n      <Message Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n      </Message>\r\n      <Outputs Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n      </Outputs>\r\n      <Command Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n      </Command>\r\n    </CustomBuild>\r\n    <CustomBuild Include=\"Component\\InstantiationsWriter.h\">\r\n      <AdditionalInputs Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">%(AdditionalInputs)</AdditionalInputs>\r\n      <Message Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n      </Message>\r\n      <Outputs Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n      </Outputs>\r\n      <Command Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n      </Command>\r\n      <AdditionalInputs Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">%(AdditionalInputs)</AdditionalInputs>\r\n      <Message Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n      </Message>\r\n      <Outputs Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n      </Outputs>\r\n      <Command Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n      </Command>\r\n    </CustomBuild>\r\n    <ClInclude Include=\"Component\\IndirectInterface.h\" />\r\n    <ClInclude Include=\"Component\\IndirectInterfaceReader.h\" />\r\n    <ClInclude Include=\"Component\\IndirectInterfaceWriter.h\" />\r\n    <ClInclude Include=\"Component\\MemoryBlockBase.h\" />\r\n    <ClInclude Include=\"Component\\MemoryMap.h\" />\r\n    <ClInclude Include=\"Component\\MemoryMapBase.h\" />\r\n    <CustomBuild Include=\"Component\\MemoryMapBaseReader.h\">\r\n      <AdditionalInputs Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">%(AdditionalInputs)</AdditionalInputs>\r\n      <Message Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n      </Message>\r\n      <Outputs Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n      </Outputs>\r\n      <Command Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n      </Command>\r\n      <AdditionalInputs Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">%(AdditionalInputs)</AdditionalInputs>\r\n      <Message Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n      </Message>\r\n      <Outputs Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n      </Outputs>\r\n      <Command Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n      </Command>\r\n    </CustomBuild>\r\n    <CustomBuild Include=\"Component\\MemoryMapBaseWriter.h\">\r\n      <AdditionalInputs Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">%(AdditionalInputs)</AdditionalInputs>\r\n      <Message Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n      </Message>\r\n      <Outputs Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n      </Outputs>\r\n      <Command Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n      </Command>\r\n      <AdditionalInputs Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">%(AdditionalInputs)</AdditionalInputs>\r\n      <Message Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n      </Message>\r\n      <Outputs Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n      </Outputs>\r\n      <Command Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n      </Command>\r\n    </CustomBuild>\r\n    <CustomBuild Include=\"Component\\MemoryMapReader.h\">\r\n      <AdditionalInputs Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">%(AdditionalInputs)</AdditionalInputs>\r\n      <Message Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n      </Message>\r\n      <Outputs Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n      </Outputs>\r\n      <Command Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n      </Command>\r\n      <AdditionalInputs Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">%(AdditionalInputs)</AdditionalInputs>\r\n      <Message Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n      </Message>\r\n      <Outputs Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n      </Outputs>\r\n      <Command Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n      </Command>\r\n    </CustomBuild>\r\n    <CustomBuild Include=\"Component\\MemoryMapWriter.h\">\r\n      <AdditionalInputs Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">%(AdditionalInputs)</AdditionalInputs>\r\n      <Message Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n      </Message>\r\n      <Outputs Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n      </Outputs>\r\n      <Command Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n      </Command>\r\n      <AdditionalInputs Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">%(AdditionalInputs)</AdditionalInputs>\r\n      <Message Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n      </Message>\r\n      <Outputs Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n      </Outputs>\r\n      <Command Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n      </Command>\r\n    </CustomBuild>\r\n    <ClInclude Include=\"Component\\MemoryRemap.h\" />\r\n    <ClInclude Include=\"Component\\Model.h\" />\r\n    <ClInclude Include=\"Component\\AbstractionType.h\" />\r\n    <ClInclude Include=\"Component\\OtherClockDriver.h\" />\r\n    <ClInclude Include=\"Component\\OtherClockDriverReader.h\" />\r\n    <QtMoc Include=\"Component\\OtherClockDriverWriter.h\">\r\n    </QtMoc>\r\n    <ClInclude Include=\"Component\\Port.h\" />\r\n    <CustomBuild Include=\"Component\\PortReader.h\">\r\n      <AdditionalInputs Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">%(AdditionalInputs)</AdditionalInputs>\r\n      <Message Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n      </Message>\r\n      <Outputs Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n      </Outputs>\r\n      <Command Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n      </Command>\r\n      <AdditionalInputs Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">%(AdditionalInputs)</AdditionalInputs>\r\n      <Message Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n      </Message>\r\n      <Outputs Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n      </Outputs>\r\n      <Command Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n      </Command>\r\n    </CustomBuild>\r\n    <CustomBuild Include=\"Component\\PortWriter.h\">\r\n      <AdditionalInputs Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">%(AdditionalInputs)</AdditionalInputs>\r\n      <Message Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n      </Message>\r\n      <Outputs Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n      </Outputs>\r\n      <Command Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n      </Command>\r\n      <AdditionalInputs Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">%(AdditionalInputs)</AdditionalInputs>\r\n      <Message Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n      </Message>\r\n      <Outputs Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n      </Outputs>\r\n      <Command Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n      </Command>\r\n    </CustomBuild>\r\n    <ClInclude Include=\"Component\\PortMap.h\" />\r\n    <ClInclude Include=\"Component\\Register.h\" />\r\n    <ClInclude Include=\"Component\\RegisterBase.h\" />\r\n    <ClInclude Include=\"Component\\RegisterDefinition.h\" />\r\n    <ClInclude Include=\"Component\\RegisterFile.h\" />\r\n    <CustomBuild Include=\"Component\\RegisterReader.h\">\r\n      <AdditionalInputs Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">%(AdditionalInputs)</AdditionalInputs>\r\n      <Message Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n      </Message>\r\n      <Outputs Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n      </Outputs>\r\n      <Command Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n      </Command>\r\n      <AdditionalInputs Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">%(AdditionalInputs)</AdditionalInputs>\r\n      <Message Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n      </Message>\r\n      <Outputs Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n      </Outputs>\r\n      <Command Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n      </Command>\r\n    </CustomBuild>\r\n    <CustomBuild Include=\"Component\\RegisterWriter.h\">\r\n      <AdditionalInputs Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">%(AdditionalInputs)</AdditionalInputs>\r\n      <Message Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n      </Message>\r\n      <Outputs Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n      </Outputs>\r\n      <Command Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n      </Command>\r\n      <AdditionalInputs Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">%(AdditionalInputs)</AdditionalInputs>\r\n      <Message Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n      </Message>\r\n      <Outputs Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n      </Outputs>\r\n      <Command Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n      </Command>\r\n    </CustomBuild>\r\n    <ClInclude Include=\"Component\\RemapPort.h\" />\r\n    <ClInclude Include=\"Component\\RemapState.h\" />\r\n    <ClInclude Include=\"Component\\RemapStateReader.h\" />\r\n    <ClInclude Include=\"Component\\RemapStateWriter.h\" />\r\n    <ClInclude Include=\"Component\\Segment.h\" />\r\n    <ClInclude Include=\"Component\\Transactional.h\" />\r\n    <ClInclude Include=\"Component\\TransparentBridge.h\" />\r\n    <ClInclude Include=\"Component\\validators\\AbstractionTypeValidator.h\" />\r\n    <ClInclude Include=\"Component\\validators\\AddressBlockValidator.h\" />\r\n    <ClInclude Include=\"Component\\validators\\AddressSpaceValidator.h\" />\r\n    <ClInclude Include=\"Component\\validators\\BusInterfaceValidator.h\" />\r\n    <ClInclude Include=\"Component\\validators\\ChannelValidator.h\" />\r\n    <ClInclude Include=\"Component\\validators\\ComponentGeneratorValidator.h\" />\r\n    <ClInclude Include=\"Component\\validators\\ComponentValidator.h\" />\r\n    <ClInclude Include=\"Component\\validators\\CPUValidator.h\" />\r\n    <ClInclude Include=\"Component\\validators\\EnumeratedValueValidator.h\" />\r\n    <ClInclude Include=\"Component\\validators\\FieldValidator.h\" />\r\n    <ClInclude Include=\"Component\\validators\\FileSetValidator.h\" />\r\n    <ClInclude Include=\"Component\\validators\\FileValidator.h\" />\r\n    <ClInclude Include=\"Component\\validators\\IndirectInterfaceValidator.h\" />\r\n    <ClInclude Include=\"Component\\validators\\InstantiationsValidator.h\" />\r\n    <ClInclude Include=\"Component\\validators\\PortMapValidator.h\" />\r\n    <ClInclude Include=\"Component\\validators\\OtherClockDriverValidator.h\" />\r\n    <ClInclude Include=\"Component\\validators\\PortTypeValidator.h\" />\r\n    <ClInclude Include=\"Component\\validators\\PortValidator.h\" />\r\n    <ClInclude Include=\"Component\\validators\\RemapStateValidator.h\" />\r\n    <ClInclude Include=\"Component\\validators\\MemoryMapBaseValidator.h\" />\r\n    <ClInclude Include=\"Component\\validators\\MemoryMapValidator.h\" />\r\n    <ClInclude Include=\"Component\\validators\\MemoryReserve.h\" />\r\n    <ClInclude Include=\"Component\\validators\\RegisterValidator.h\" />\r\n    <ClInclude Include=\"Component\\validators\\ViewValidator.h\" />\r\n    <ClInclude Include=\"Component\\View.h\" />\r\n    <ClInclude Include=\"Component\\ViewReader.h\" />\r\n    <ClInclude Include=\"Component\\ViewWriter.h\" />\r\n    <ClInclude Include=\"Component\\Wire.h\" />\r\n    <ClInclude Include=\"Component\\WireTypeDef.h\" />\r\n    <ClInclude Include=\"Component\\WriteValueConstraint.h\" />\r\n    <ClInclude Include=\"Design\\validator\\AdHocConnectionValidator.h\" />\r\n    <ClInclude Include=\"Design\\validator\\ComponentInstanceValidator.h\" />\r\n    <ClInclude Include=\"Design\\validator\\DesignValidator.h\" />\r\n    <ClInclude Include=\"Design\\validator\\InterconnectionValidator.h\" />\r\n    <ClInclude Include=\"kactusExtensions\\ApiDefinition.h\" />\r\n    <CustomBuild Include=\"kactusExtensions\\ApiDefinitionWriter.h\">\r\n      <AdditionalInputs Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">%(AdditionalInputs)</AdditionalInputs>\r\n      <Message Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n      </Message>\r\n      <Outputs Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n      </Outputs>\r\n      <Command Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n      </Command>\r\n      <AdditionalInputs Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">%(AdditionalInputs)</AdditionalInputs>\r\n      <Message Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n      </Message>\r\n      <Outputs Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n      </Outputs>\r\n      <Command Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n      </Command>\r\n    </CustomBuild>\r\n    <CustomBuild Include=\"kactusExtensions\\ApiDefinitionReader.h\">\r\n      <AdditionalInputs Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">%(AdditionalInputs)</AdditionalInputs>\r\n      <Message Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n      </Message>\r\n      <Outputs Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n      </Outputs>\r\n      <Command Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n      </Command>\r\n      <AdditionalInputs Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">%(AdditionalInputs)</AdditionalInputs>\r\n      <Message Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n      </Message>\r\n      <Outputs Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n      </Outputs>\r\n      <Command Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n      </Command>\r\n    </CustomBuild>\r\n    <ClInclude Include=\"kactusExtensions\\ApiFunction.h\" />\r\n    <ClInclude Include=\"kactusExtensions\\ApiFunctionParameter.h\" />\r\n    <ClInclude Include=\"kactusExtensions\\ApiInterconnection.h\" />\r\n    <ClInclude Include=\"kactusExtensions\\ApiInterface.h\" />\r\n    <ClInclude Include=\"kactusExtensions\\ColumnDesc.h\" />\r\n    <ClInclude Include=\"kactusExtensions\\ComDefinition.h\" />\r\n    <CustomBuild Include=\"kactusExtensions\\ComDefinitionWriter.h\">\r\n      <AdditionalInputs Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">%(AdditionalInputs)</AdditionalInputs>\r\n      <Message Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n      </Message>\r\n      <Outputs Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n      </Outputs>\r\n      <Command Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n      </Command>\r\n      <AdditionalInputs Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">%(AdditionalInputs)</AdditionalInputs>\r\n      <Message Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n      </Message>\r\n      <Outputs Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n      </Outputs>\r\n      <Command Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n      </Command>\r\n    </CustomBuild>\r\n    <CustomBuild Include=\"kactusExtensions\\ComDefinitionReader.h\">\r\n      <AdditionalInputs Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">%(AdditionalInputs)</AdditionalInputs>\r\n      <Message Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n      </Message>\r\n      <Outputs Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n      </Outputs>\r\n      <Command Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n      </Command>\r\n      <AdditionalInputs Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">%(AdditionalInputs)</AdditionalInputs>\r\n      <Message Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n      </Message>\r\n      <Outputs Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n      </Outputs>\r\n      <Command Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n      </Command>\r\n    </CustomBuild>\r\n    <ClInclude Include=\"kactusExtensions\\ComInterconnection.h\" />\r\n    <ClInclude Include=\"kactusExtensions\\ComInterface.h\" />\r\n    <ClInclude Include=\"kactusExtensions\\ComProperty.h\" />\r\n    <ClInclude Include=\"kactusExtensions\\ConnectionRoute.h\" />\r\n    <ClInclude Include=\"kactusExtensions\\FileDependency.h\" />\r\n    <ClInclude Include=\"kactusExtensions\\HierApiInterconnection.h\" />\r\n    <ClInclude Include=\"kactusExtensions\\HierComInterconnection.h\" />\r\n    <ClInclude Include=\"kactusExtensions\\InterfaceGraphicsData.h\" />\r\n    <ClInclude Include=\"kactusExtensions\\Kactus2Group.h\" />\r\n    <ClInclude Include=\"kactusExtensions\\Kactus2Placeholder.h\" />\r\n    <ClInclude Include=\"kactusExtensions\\Kactus2Position.h\" />\r\n    <ClInclude Include=\"kactusExtensions\\Kactus2Value.h\" />\r\n    <ClInclude Include=\"kactusExtensions\\KactusAttribute.h\" />\r\n    <ClInclude Include=\"kactusExtensions\\SystemView.h\" />\r\n    <ClInclude Include=\"kactusExtensions\\validators\\ApiDefinitionValidator.h\" />\r\n    <ClInclude Include=\"kactusExtensions\\validators\\ComDefinitionValidator.h\" />\r\n    <ClInclude Include=\"kactusExtensions\\validators\\SystemDesignConfigurationValidator.h\" />\r\n    <ClInclude Include=\"kactusExtensions\\validators\\SystemViewConfigurationValidator.h\" />\r\n    <ClInclude Include=\"BusDefinition\\BusDefinition.h\" />\r\n    <CustomBuild Include=\"BusDefinition\\BusDefinitionReader.h\">\r\n      <AdditionalInputs Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">%(AdditionalInputs)</AdditionalInputs>\r\n      <Message Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n      </Message>\r\n      <Outputs Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n      </Outputs>\r\n      <Command Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n      </Command>\r\n      <AdditionalInputs Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">%(AdditionalInputs)</AdditionalInputs>\r\n      <Message Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n      </Message>\r\n      <Outputs Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n      </Outputs>\r\n      <Command Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n      </Command>\r\n    </CustomBuild>\r\n    <CustomBuild Include=\"BusDefinition\\BusDefinitionWriter.h\">\r\n      <AdditionalInputs Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">%(AdditionalInputs)</AdditionalInputs>\r\n      <Message Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n      </Message>\r\n      <Outputs Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n      </Outputs>\r\n      <Command Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n      </Command>\r\n      <AdditionalInputs Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">%(AdditionalInputs)</AdditionalInputs>\r\n      <Message Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n      </Message>\r\n      <Outputs Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n      </Outputs>\r\n      <Command Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n      </Command>\r\n    </CustomBuild>\r\n    <ClInclude Include=\"Design\\ActiveInterface.h\" />\r\n    <ClInclude Include=\"Design\\AdHocConnection.h\" />\r\n    <ClInclude Include=\"Design\\ComponentInstance.h\" />\r\n    <CustomBuild Include=\"Design\\ComponentInstanceReader.h\">\r\n      <AdditionalInputs Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">%(AdditionalInputs)</AdditionalInputs>\r\n      <Message Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n      </Message>\r\n      <Outputs Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n      </Outputs>\r\n      <Command Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n      </Command>\r\n      <AdditionalInputs Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">%(AdditionalInputs)</AdditionalInputs>\r\n      <Message Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n      </Message>\r\n      <Outputs Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n      </Outputs>\r\n      <Command Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n      </Command>\r\n    </CustomBuild>\r\n    <CustomBuild Include=\"Design\\ComponentInstanceWriter.h\">\r\n      <AdditionalInputs Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">%(AdditionalInputs)</AdditionalInputs>\r\n      <Message Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n      </Message>\r\n      <Outputs Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n      </Outputs>\r\n      <Command Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n      </Command>\r\n      <AdditionalInputs Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">%(AdditionalInputs)</AdditionalInputs>\r\n      <Message Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n      </Message>\r\n      <Outputs Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n      </Outputs>\r\n      <Command Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n      </Command>\r\n    </CustomBuild>\r\n    <ClInclude Include=\"Design\\Design.h\" />\r\n    <CustomBuild Include=\"Design\\DesignReader.h\">\r\n      <AdditionalInputs Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">%(AdditionalInputs)</AdditionalInputs>\r\n      <Message Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n      </Message>\r\n      <Outputs Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n      </Outputs>\r\n      <Command Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n      </Command>\r\n      <AdditionalInputs Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">%(AdditionalInputs)</AdditionalInputs>\r\n      <Message Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n      </Message>\r\n      <Outputs Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n      </Outputs>\r\n      <Command Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n      </Command>\r\n    </CustomBuild>\r\n    <CustomBuild Include=\"Design\\DesignWriter.h\">\r\n      <AdditionalInputs Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">%(AdditionalInputs)</AdditionalInputs>\r\n      <Message Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n      </Message>\r\n      <Outputs Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n      </Outputs>\r\n      <Command Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n      </Command>\r\n      <AdditionalInputs Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">%(AdditionalInputs)</AdditionalInputs>\r\n      <Message Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n      </Message>\r\n      <Outputs Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n      </Outputs>\r\n      <Command Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n      </Command>\r\n    </CustomBuild>\r\n    <ClInclude Include=\"Design\\HierInterface.h\" />\r\n    <ClInclude Include=\"Design\\Interconnection.h\" />\r\n    <ClInclude Include=\"Design\\MonitorInterconnection.h\" />\r\n    <ClInclude Include=\"Design\\MonitorInterface.h\" />\r\n    <ClInclude Include=\"Design\\PortReference.h\" />\r\n    <ClInclude Include=\"generaldeclarations.h\" />\r\n    <ClInclude Include=\"ipxactmodels_global.h\" />\r\n  </ItemGroup>\r\n  <Import Project=\"$(VCTargetsPath)\\Microsoft.Cpp.targets\" />\r\n  <ImportGroup Condition=\"Exists('$(QtMsBuild)\\qt.targets')\">\r\n    <Import Project=\"$(QtMsBuild)\\qt.targets\" />\r\n  </ImportGroup>\r\n  <ImportGroup Label=\"ExtensionTargets\">\r\n  </ImportGroup>\r\n  <ProjectExtensions>\r\n    <VisualStudio>\r\n      <UserProperties />\r\n    </VisualStudio>\r\n  </ProjectExtensions>\r\n</Project>"
  },
  {
    "path": "IPXACTmodels/IPXACTmodels.vcxproj.filters",
    "content": "﻿<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n<Project ToolsVersion=\"4.0\" xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">\r\n  <ItemGroup>\r\n    <Filter Include=\"Source Files\">\r\n      <UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>\r\n      <Extensions>cpp;cxx;c;def</Extensions>\r\n    </Filter>\r\n    <Filter Include=\"Header Files\">\r\n      <UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>\r\n      <Extensions>h</Extensions>\r\n    </Filter>\r\n    <Filter Include=\"Generated Files\">\r\n      <UniqueIdentifier>{71ED8ED8-ACB9-4CE9-BBE1-E00B30144E11}</UniqueIdentifier>\r\n      <Extensions>moc;h;cpp</Extensions>\r\n      <SourceControlFiles>False</SourceControlFiles>\r\n    </Filter>\r\n    <Filter Include=\"Header Files\\kactusExtensions\">\r\n      <UniqueIdentifier>{baefef4c-d901-4edd-a506-4608479a05fc}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Source Files\\kactusExtensions\">\r\n      <UniqueIdentifier>{9a1ab151-3ac8-45ec-910d-4264f073bda9}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Generated Files\\Debug\">\r\n      <UniqueIdentifier>{a1bee4a2-7ee8-4820-9673-b6c6e7a03481}</UniqueIdentifier>\r\n      <Extensions>cpp;moc</Extensions>\r\n      <SourceControlFiles>False</SourceControlFiles>\r\n    </Filter>\r\n    <Filter Include=\"Generated Files\\Release\">\r\n      <UniqueIdentifier>{3512f2ef-cd60-43f9-8388-f194f8eff4e9}</UniqueIdentifier>\r\n      <Extensions>cpp;moc</Extensions>\r\n      <SourceControlFiles>False</SourceControlFiles>\r\n    </Filter>\r\n    <Filter Include=\"Header Files\\common\">\r\n      <UniqueIdentifier>{74b008bb-44e4-4850-b19d-a5c6c4fa24b4}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Source Files\\common\">\r\n      <UniqueIdentifier>{f81db2e0-6b15-4378-a84f-e30cbdb942c3}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Header Files\\BusDefinition\">\r\n      <UniqueIdentifier>{9784a5a1-4c50-4889-8187-b6a3563987d9}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Source Files\\BusDefinition\">\r\n      <UniqueIdentifier>{b3c73ea0-2cec-4b2d-93eb-a9a6e3650ab3}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Header Files\\AbstractionDefinition\">\r\n      <UniqueIdentifier>{e9b14fb4-39de-494f-9933-5cf8c923a03e}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Source Files\\AbstractionDefinition\">\r\n      <UniqueIdentifier>{77c749b9-09e3-42ef-bc9f-febe4f45e004}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Header Files\\Design\">\r\n      <UniqueIdentifier>{3105a439-452c-4dc3-9807-e87a57bfc118}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Source Files\\Design\">\r\n      <UniqueIdentifier>{b950dcd0-9d3d-40cb-a908-a4b49e4c0001}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Source Files\\Component\">\r\n      <UniqueIdentifier>{9bdefd34-268c-40c1-b3a4-93c31334293e}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Header Files\\Component\">\r\n      <UniqueIdentifier>{d70ea028-d12a-4260-8f6a-8f4e96a9e470}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Header Files\\common\\validators\">\r\n      <UniqueIdentifier>{bc49e2f5-b962-4eb8-bcee-ff4575f6267f}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Source Files\\common\\validators\">\r\n      <UniqueIdentifier>{1d95ce5a-b997-4755-bd65-527b1d5afd4b}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Source Files\\BusDefinition\\validators\">\r\n      <UniqueIdentifier>{be9134bf-e797-422d-befb-f9d1e2c8cf51}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Header Files\\BusDefinition\\validators\">\r\n      <UniqueIdentifier>{06ae740e-ae54-4934-9ff6-2fa1ac8d2396}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Header Files\\Component\\validators\">\r\n      <UniqueIdentifier>{8daac011-d12d-41f3-a0d6-788003de5c37}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Source Files\\Component\\validators\">\r\n      <UniqueIdentifier>{c2588e78-c087-4ca0-820f-78ef99341553}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Header Files\\AbstractionDefinition\\validators\">\r\n      <UniqueIdentifier>{fe0e3948-8852-4e01-8cf4-89112e8feaff}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Source Files\\AbstractionDefinition\\validators\">\r\n      <UniqueIdentifier>{95fa34c7-584f-4e11-97ce-905ebabfe1f4}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Header Files\\Design\\validators\">\r\n      <UniqueIdentifier>{4adde65a-aa38-44fb-ba47-3725121b1fe2}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Source Files\\Design\\validators\">\r\n      <UniqueIdentifier>{7167ec92-b7f3-470a-a7cd-7a154a9c3035}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Header Files\\kactusExtensions\\validators\">\r\n      <UniqueIdentifier>{f2b900ef-3d64-4ad0-92d1-592fc252c4e7}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Source Files\\kactusExtensions\\validators\">\r\n      <UniqueIdentifier>{400a4962-d1b4-46a4-a93f-52c4f3b9514d}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Source Files\\Catalog\">\r\n      <UniqueIdentifier>{300d32ff-9bc3-4bc3-b1a8-f5cfc464bd7e}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Header Files\\Catalog\">\r\n      <UniqueIdentifier>{2c69e06e-0636-46ef-9854-26900eb868c6}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Source Files\\Catalog\\validators\">\r\n      <UniqueIdentifier>{9c883f7b-85d7-4788-a56e-2b3c39628e68}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Header Files\\Catalog\\validators\">\r\n      <UniqueIdentifier>{64de22a1-b68b-4616-88ed-eb3641e323ba}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Header Files\\utilities\">\r\n      <UniqueIdentifier>{2f3204f3-1ca5-4000-bf6e-a525ffc7e46c}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Source Files\\utilities\">\r\n      <UniqueIdentifier>{54d2758c-a610-4b1c-9a03-7f22e6644109}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Source Files\\DesignConfiguration\">\r\n      <UniqueIdentifier>{3756b817-3a7e-4d61-aaeb-4228dc0db3b6}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Source Files\\DesignConfiguration\\validators\">\r\n      <UniqueIdentifier>{069e3eba-3a4e-4c79-afa5-f6963520eef9}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Header Files\\DesignConfiguration\">\r\n      <UniqueIdentifier>{08dd8af0-de2a-47a7-9b4c-07b5f19ca328}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Header Files\\DesignConfiguration\\validators\">\r\n      <UniqueIdentifier>{b997b8ac-3800-4bf7-b01f-9f96768da459}</UniqueIdentifier>\r\n    </Filter>\r\n  </ItemGroup>\r\n  <ItemGroup>\r\n    <ClCompile Include=\"BusDefinition\\BusDefinition.cpp\">\r\n      <Filter>Source Files\\BusDefinition</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"BusDefinition\\BusDefinitionReader.cpp\">\r\n      <Filter>Source Files\\BusDefinition</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"BusDefinition\\BusDefinitionWriter.cpp\">\r\n      <Filter>Source Files\\BusDefinition</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"Design\\MonitorInterface.cpp\">\r\n      <Filter>Source Files\\Design</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"Design\\PortReference.cpp\">\r\n      <Filter>Source Files\\Design</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"Design\\ActiveInterface.cpp\">\r\n      <Filter>Source Files\\Design</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"Design\\AdHocConnection.cpp\">\r\n      <Filter>Source Files\\Design</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"Design\\ComponentInstance.cpp\">\r\n      <Filter>Source Files\\Design</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"Design\\Design.cpp\">\r\n      <Filter>Source Files\\Design</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"Design\\DesignReader.cpp\">\r\n      <Filter>Source Files\\Design</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"Design\\DesignWriter.cpp\">\r\n      <Filter>Source Files\\Design</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"Design\\HierInterface.cpp\">\r\n      <Filter>Source Files\\Design</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"Design\\Interconnection.cpp\">\r\n      <Filter>Source Files\\Design</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"Design\\MonitorInterconnection.cpp\">\r\n      <Filter>Source Files\\Design</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"Design\\ComponentInstanceReader.cpp\">\r\n      <Filter>Source Files\\Design</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"Design\\ComponentInstanceWriter.cpp\">\r\n      <Filter>Source Files\\Design</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"common\\Extendable.cpp\">\r\n      <Filter>Source Files\\common</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"generaldeclarations.cpp\">\r\n      <Filter>Source Files</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"AbstractionDefinition\\AbstractionDefinition.cpp\">\r\n      <Filter>Source Files\\AbstractionDefinition</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"AbstractionDefinition\\AbstractionDefinitionReader.cpp\">\r\n      <Filter>Source Files\\AbstractionDefinition</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"AbstractionDefinition\\AbstractionDefinitionWriter.cpp\">\r\n      <Filter>Source Files\\AbstractionDefinition</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"AbstractionDefinition\\PortAbstraction.cpp\">\r\n      <Filter>Source Files\\AbstractionDefinition</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"AbstractionDefinition\\TransactionalAbstraction.cpp\">\r\n      <Filter>Source Files\\AbstractionDefinition</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"AbstractionDefinition\\TransactionalAbstractionReader.cpp\">\r\n      <Filter>Source Files\\AbstractionDefinition</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"AbstractionDefinition\\TransactionalAbstractionWriter.cpp\">\r\n      <Filter>Source Files\\AbstractionDefinition</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"AbstractionDefinition\\TransactionalPort.cpp\">\r\n      <Filter>Source Files\\AbstractionDefinition</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"AbstractionDefinition\\WireAbstraction.cpp\">\r\n      <Filter>Source Files\\AbstractionDefinition</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"AbstractionDefinition\\WireAbstractionReader.cpp\">\r\n      <Filter>Source Files\\AbstractionDefinition</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"AbstractionDefinition\\WireAbstractionWriter.cpp\">\r\n      <Filter>Source Files\\AbstractionDefinition</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"AbstractionDefinition\\WirePort.cpp\">\r\n      <Filter>Source Files\\AbstractionDefinition</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"kactusExtensions\\ApiInterconnection.cpp\">\r\n      <Filter>Source Files\\kactusExtensions</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"kactusExtensions\\ApiInterface.cpp\">\r\n      <Filter>Source Files\\kactusExtensions</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"kactusExtensions\\ColumnDesc.cpp\">\r\n      <Filter>Source Files\\kactusExtensions</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"kactusExtensions\\ComInterconnection.cpp\">\r\n      <Filter>Source Files\\kactusExtensions</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"kactusExtensions\\ComInterface.cpp\">\r\n      <Filter>Source Files\\kactusExtensions</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"kactusExtensions\\ComProperty.cpp\">\r\n      <Filter>Source Files\\kactusExtensions</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"kactusExtensions\\FileDependency.cpp\">\r\n      <Filter>Source Files\\kactusExtensions</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"kactusExtensions\\HierApiInterconnection.cpp\">\r\n      <Filter>Source Files\\kactusExtensions</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"kactusExtensions\\HierComInterconnection.cpp\">\r\n      <Filter>Source Files\\kactusExtensions</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"kactusExtensions\\Kactus2Group.cpp\">\r\n      <Filter>Source Files\\kactusExtensions</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"kactusExtensions\\Kactus2Placeholder.cpp\">\r\n      <Filter>Source Files\\kactusExtensions</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"kactusExtensions\\Kactus2Position.cpp\">\r\n      <Filter>Source Files\\kactusExtensions</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"kactusExtensions\\Kactus2Value.cpp\">\r\n      <Filter>Source Files\\kactusExtensions</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"kactusExtensions\\KactusAttribute.cpp\">\r\n      <Filter>Source Files\\kactusExtensions</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"kactusExtensions\\SystemView.cpp\">\r\n      <Filter>Source Files\\kactusExtensions</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"Component\\AddressBlock.cpp\">\r\n      <Filter>Source Files\\Component</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"Component\\AddressBlockReader.cpp\">\r\n      <Filter>Source Files\\Component</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"Component\\AddressBlockWriter.cpp\">\r\n      <Filter>Source Files\\Component</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"Component\\AddressSpace.cpp\">\r\n      <Filter>Source Files\\Component</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"Component\\AddressSpaceReader.cpp\">\r\n      <Filter>Source Files\\Component</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"Component\\AddressSpaceWriter.cpp\">\r\n      <Filter>Source Files\\Component</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"Component\\AlternateRegister.cpp\">\r\n      <Filter>Source Files\\Component</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"Component\\BuildCommand.cpp\">\r\n      <Filter>Source Files\\Component</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"Component\\BusInterface.cpp\">\r\n      <Filter>Source Files\\Component</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"Component\\BusInterfaceReader.cpp\">\r\n      <Filter>Source Files\\Component</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"Component\\BusInterfaceWriter.cpp\">\r\n      <Filter>Source Files\\Component</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"Component\\Channel.cpp\">\r\n      <Filter>Source Files\\Component</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"Component\\ChannelReader.cpp\">\r\n      <Filter>Source Files\\Component</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"Component\\ChannelWriter.cpp\">\r\n      <Filter>Source Files\\Component</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"Component\\Component.cpp\">\r\n      <Filter>Source Files\\Component</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"Component\\ComponentGenerator.cpp\">\r\n      <Filter>Source Files\\Component</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"Component\\ComponentGeneratorReader.cpp\">\r\n      <Filter>Source Files\\Component</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"Component\\ComponentGeneratorWriter.cpp\">\r\n      <Filter>Source Files\\Component</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"Component\\ComponentInstantiation.cpp\">\r\n      <Filter>Source Files\\Component</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"Component\\ComponentReader.cpp\">\r\n      <Filter>Source Files\\Component</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"Component\\ComponentWriter.cpp\">\r\n      <Filter>Source Files\\Component</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"Component\\Cpu.cpp\">\r\n      <Filter>Source Files\\Component</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"Component\\CPUReader.cpp\">\r\n      <Filter>Source Files\\Component</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"Component\\CPUWriter.cpp\">\r\n      <Filter>Source Files\\Component</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"Component\\DesignConfigurationInstantiation.cpp\">\r\n      <Filter>Source Files\\Component</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"Component\\DesignInstantiation.cpp\">\r\n      <Filter>Source Files\\Component</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"Component\\EnumeratedValue.cpp\">\r\n      <Filter>Source Files\\Component</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"Component\\EnumeratedValueReader.cpp\">\r\n      <Filter>Source Files\\Component</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"Component\\EnumeratedValueWriter.cpp\">\r\n      <Filter>Source Files\\Component</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"Component\\Field.cpp\">\r\n      <Filter>Source Files\\Component</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"Component\\FieldReader.cpp\">\r\n      <Filter>Source Files\\Component</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"Component\\FieldWriter.cpp\">\r\n      <Filter>Source Files\\Component</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"Component\\File.cpp\">\r\n      <Filter>Source Files\\Component</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"Component\\FileReader.cpp\">\r\n      <Filter>Source Files\\Component</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"Component\\FileSet.cpp\">\r\n      <Filter>Source Files\\Component</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"Component\\FileSetReader.cpp\">\r\n      <Filter>Source Files\\Component</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"Component\\FileSetWriter.cpp\">\r\n      <Filter>Source Files\\Component</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"Component\\FileWriter.cpp\">\r\n      <Filter>Source Files\\Component</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"Component\\Function.cpp\">\r\n      <Filter>Source Files\\Component</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"Component\\InstantiationsReader.cpp\">\r\n      <Filter>Source Files\\Component</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"Component\\InstantiationsWriter.cpp\">\r\n      <Filter>Source Files\\Component</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"Component\\MemoryBlockBase.cpp\">\r\n      <Filter>Source Files\\Component</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"Component\\MemoryMap.cpp\">\r\n      <Filter>Source Files\\Component</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"Component\\MemoryMapBase.cpp\">\r\n      <Filter>Source Files\\Component</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"Component\\MemoryMapBaseReader.cpp\">\r\n      <Filter>Source Files\\Component</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"Component\\MemoryMapBaseWriter.cpp\">\r\n      <Filter>Source Files\\Component</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"Component\\MemoryMapReader.cpp\">\r\n      <Filter>Source Files\\Component</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"Component\\MemoryMapWriter.cpp\">\r\n      <Filter>Source Files\\Component</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"Component\\MemoryRemap.cpp\">\r\n      <Filter>Source Files\\Component</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"Component\\Model.cpp\">\r\n      <Filter>Source Files\\Component</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"Component\\OtherClockDriver.cpp\">\r\n      <Filter>Source Files\\Component</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"Component\\OtherClockDriverReader.cpp\">\r\n      <Filter>Source Files\\Component</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"Component\\OtherClockDriverWriter.cpp\">\r\n      <Filter>Source Files\\Component</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"Component\\Port.cpp\">\r\n      <Filter>Source Files\\Component</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"Component\\PortReader.cpp\">\r\n      <Filter>Source Files\\Component</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"Component\\PortWriter.cpp\">\r\n      <Filter>Source Files\\Component</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"Component\\Register.cpp\">\r\n      <Filter>Source Files\\Component</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"Component\\RegisterBase.cpp\">\r\n      <Filter>Source Files\\Component</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"Component\\RegisterDefinition.cpp\">\r\n      <Filter>Source Files\\Component</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"Component\\RegisterFile.cpp\">\r\n      <Filter>Source Files\\Component</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"Component\\RegisterReader.cpp\">\r\n      <Filter>Source Files\\Component</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"Component\\RegisterWriter.cpp\">\r\n      <Filter>Source Files\\Component</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"Component\\RemapPort.cpp\">\r\n      <Filter>Source Files\\Component</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"Component\\RemapState.cpp\">\r\n      <Filter>Source Files\\Component</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"Component\\RemapStateReader.cpp\">\r\n      <Filter>Source Files\\Component</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"Component\\RemapStateWriter.cpp\">\r\n      <Filter>Source Files\\Component</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"Component\\Transactional.cpp\">\r\n      <Filter>Source Files\\Component</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"Component\\View.cpp\">\r\n      <Filter>Source Files\\Component</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"Component\\ViewReader.cpp\">\r\n      <Filter>Source Files\\Component</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"Component\\ViewWriter.cpp\">\r\n      <Filter>Source Files\\Component</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"Component\\Wire.cpp\">\r\n      <Filter>Source Files\\Component</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"Component\\WireTypeDef.cpp\">\r\n      <Filter>Source Files\\Component</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"Component\\WriteValueConstraint.cpp\">\r\n      <Filter>Source Files\\Component</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"common\\Assertion.cpp\">\r\n      <Filter>Source Files\\common</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"common\\BooleanValue.cpp\">\r\n      <Filter>Source Files\\common</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"common\\BuildModel.cpp\">\r\n      <Filter>Source Files\\common</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"common\\CellSpecification.cpp\">\r\n      <Filter>Source Files\\common</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"common\\ClockUnit.cpp\">\r\n      <Filter>Source Files\\common</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"common\\CommonItemsReader.cpp\">\r\n      <Filter>Source Files\\common</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"common\\CommonItemsWriter.cpp\">\r\n      <Filter>Source Files\\common</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"common\\ConfigurableElementValue.cpp\">\r\n      <Filter>Source Files\\common</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"common\\ConfigurableVLNVReference.cpp\">\r\n      <Filter>Source Files\\common</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"common\\DirectionTypes.cpp\">\r\n      <Filter>Source Files\\common</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"common\\Document.cpp\">\r\n      <Filter>Source Files\\common</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"common\\DocumentReader.cpp\">\r\n      <Filter>Source Files\\common</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"common\\DocumentWriter.cpp\">\r\n      <Filter>Source Files\\common</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"common\\Extendable.cpp\">\r\n      <Filter>Source Files\\common</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"common\\FileBuilder.cpp\">\r\n      <Filter>Source Files\\common</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"common\\FileBuilderReader.cpp\">\r\n      <Filter>Source Files\\common</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"common\\FileBuilderWriter.cpp\">\r\n      <Filter>Source Files\\common</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"common\\ModuleParameter.cpp\">\r\n      <Filter>Source Files\\common</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"common\\ModuleParameterReader.cpp\">\r\n      <Filter>Source Files\\common</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"common\\ModuleParameterWriter.cpp\">\r\n      <Filter>Source Files\\common</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"common\\NameGroup.cpp\">\r\n      <Filter>Source Files\\common</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"common\\NameGroupReader.cpp\">\r\n      <Filter>Source Files\\common</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"common\\NameGroupWriter.cpp\">\r\n      <Filter>Source Files\\common</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"common\\NameValuePair.cpp\">\r\n      <Filter>Source Files\\common</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"common\\Parameter.cpp\">\r\n      <Filter>Source Files\\common</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"common\\ParameterReader.cpp\">\r\n      <Filter>Source Files\\common</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"common\\ParameterWriter.cpp\">\r\n      <Filter>Source Files\\common</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"common\\PartSelect.cpp\">\r\n      <Filter>Source Files\\common</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"common\\Protocol.cpp\">\r\n      <Filter>Source Files\\common</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"common\\ProtocolReader.cpp\">\r\n      <Filter>Source Files\\common</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"common\\ProtocolWriter.cpp\">\r\n      <Filter>Source Files\\common</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"common\\Range.cpp\">\r\n      <Filter>Source Files\\common</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"common\\TransactionalTypes.cpp\">\r\n      <Filter>Source Files\\common</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"common\\Vector.cpp\">\r\n      <Filter>Source Files\\common</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"common\\Enumeration.cpp\">\r\n      <Filter>Source Files\\common</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"Component\\Segment.cpp\">\r\n      <Filter>Source Files\\Component</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"Component\\AbstractionType.cpp\">\r\n      <Filter>Source Files\\Component</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"Component\\PortMap.cpp\">\r\n      <Filter>Source Files\\Component</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"kactusExtensions\\ApiDefinition.cpp\">\r\n      <Filter>Source Files\\kactusExtensions</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"kactusExtensions\\ApiFunction.cpp\">\r\n      <Filter>Source Files\\kactusExtensions</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"kactusExtensions\\ApiFunctionParameter.cpp\">\r\n      <Filter>Source Files\\kactusExtensions</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"kactusExtensions\\ComDefinition.cpp\">\r\n      <Filter>Source Files\\kactusExtensions</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"common\\GenericVendorExtension.cpp\">\r\n      <Filter>Source Files\\common</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"common\\VLNV.cpp\">\r\n      <Filter>Source Files\\common</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"common\\validators\\ValueFormatter.cpp\">\r\n      <Filter>Source Files\\common\\validators</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"kactusExtensions\\ConnectionRoute.cpp\">\r\n      <Filter>Source Files\\kactusExtensions</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"BusDefinition\\validators\\BusDefinitionValidator.cpp\">\r\n      <Filter>Source Files\\BusDefinition\\validators</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"Component\\validators\\EnumeratedValueValidator.cpp\">\r\n      <Filter>Source Files\\Component\\validators</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"Component\\validators\\FileValidator.cpp\">\r\n      <Filter>Source Files\\Component\\validators</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"Component\\validators\\FieldValidator.cpp\">\r\n      <Filter>Source Files\\Component\\validators</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"Component\\validators\\FileSetValidator.cpp\">\r\n      <Filter>Source Files\\Component\\validators</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"Component\\validators\\CPUValidator.cpp\">\r\n      <Filter>Source Files\\Component\\validators</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"Component\\validators\\RemapStateValidator.cpp\">\r\n      <Filter>Source Files\\Component\\validators</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"Component\\validators\\RegisterValidator.cpp\">\r\n      <Filter>Source Files\\Component\\validators</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"Component\\validators\\MemoryReserve.cpp\">\r\n      <Filter>Source Files\\Component\\validators</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"Component\\validators\\AddressBlockValidator.cpp\">\r\n      <Filter>Source Files\\Component\\validators</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"Component\\validators\\MemoryMapValidator.cpp\">\r\n      <Filter>Source Files\\Component\\validators</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"Component\\validators\\MemoryMapBaseValidator.cpp\">\r\n      <Filter>Source Files\\Component\\validators</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"Component\\validators\\AddressSpaceValidator.cpp\">\r\n      <Filter>Source Files\\Component\\validators</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"common\\AccessTypes.cpp\">\r\n      <Filter>Source Files\\common</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"Component\\validators\\ChannelValidator.cpp\">\r\n      <Filter>Source Files\\Component\\validators</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"Component\\validators\\PortValidator.cpp\">\r\n      <Filter>Source Files\\Component\\validators</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"common\\TimingConstraint.cpp\">\r\n      <Filter>Source Files\\common</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"common\\PresenceTypes.cpp\">\r\n      <Filter>Source Files\\common</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"kactusExtensions\\ApiDefinitionWriter.cpp\">\r\n      <Filter>Source Files\\kactusExtensions</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"kactusExtensions\\ComDefinitionWriter.cpp\">\r\n      <Filter>Source Files\\kactusExtensions</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"Component\\validators\\InstantiationsValidator.cpp\">\r\n      <Filter>Source Files\\Component\\validators</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"Component\\validators\\ViewValidator.cpp\">\r\n      <Filter>Source Files\\Component\\validators</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"Component\\validators\\OtherClockDriverValidator.cpp\">\r\n      <Filter>Source Files\\Component\\validators</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"Component\\validators\\BusInterfaceValidator.cpp\">\r\n      <Filter>Source Files\\Component\\validators</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"Component\\validators\\PortMapValidator.cpp\">\r\n      <Filter>Source Files\\Component\\validators</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"AbstractionDefinition\\validators\\AbstractionDefinitionValidator.cpp\">\r\n      <Filter>Source Files\\AbstractionDefinition\\validators</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"common\\validators\\TimingConstraintValidator.cpp\">\r\n      <Filter>Source Files\\common\\validators</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"common\\validators\\CellSpecificationValidator.cpp\">\r\n      <Filter>Source Files\\common\\validators</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"common\\validators\\ProtocolValidator.cpp\">\r\n      <Filter>Source Files\\common\\validators</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"Component\\validators\\ComponentGeneratorValidator.cpp\">\r\n      <Filter>Source Files\\Component\\validators</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"Component\\validators\\ComponentValidator.cpp\">\r\n      <Filter>Source Files\\Component\\validators</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"common\\validators\\AssertionValidator.cpp\">\r\n      <Filter>Source Files\\common\\validators</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"Design\\validator\\AdHocConnectionValidator.cpp\">\r\n      <Filter>Source Files\\Design\\validators</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"Design\\validator\\ComponentInstanceValidator.cpp\">\r\n      <Filter>Source Files\\Design\\validators</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"Design\\validator\\DesignValidator.cpp\">\r\n      <Filter>Source Files\\Design\\validators</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"Design\\validator\\InterconnectionValidator.cpp\">\r\n      <Filter>Source Files\\Design\\validators</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"kactusExtensions\\ApiDefinitionReader.cpp\">\r\n      <Filter>Source Files\\kactusExtensions</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"kactusExtensions\\validators\\ApiDefinitionValidator.cpp\">\r\n      <Filter>Source Files\\kactusExtensions</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"kactusExtensions\\ComDefinitionReader.cpp\">\r\n      <Filter>Source Files\\kactusExtensions</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"kactusExtensions\\validators\\ComDefinitionValidator.cpp\">\r\n      <Filter>Source Files\\kactusExtensions</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"common\\PortAlignment.cpp\">\r\n      <Filter>Source Files\\common</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"kactusExtensions\\validators\\SystemDesignConfigurationValidator.cpp\">\r\n      <Filter>Source Files\\kactusExtensions\\validators</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"kactusExtensions\\validators\\SystemViewConfigurationValidator.cpp\">\r\n      <Filter>Source Files\\kactusExtensions\\validators</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"kactusExtensions\\InterfaceGraphicsData.cpp\">\r\n      <Filter>Source Files\\kactusExtensions</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"Catalog\\Catalog.cpp\">\r\n      <Filter>Source Files\\Catalog</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"Catalog\\CatalogReader.cpp\">\r\n      <Filter>Source Files\\Catalog</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"Catalog\\CatalogWriter.cpp\">\r\n      <Filter>Source Files\\Catalog</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"Catalog\\IpxactFile.cpp\">\r\n      <Filter>Source Files\\Catalog</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"Catalog\\validators\\CatalogValidator.cpp\">\r\n      <Filter>Source Files\\Catalog\\validators</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"Component\\IndirectInterface.cpp\">\r\n      <Filter>Source Files\\Component</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"Component\\IndirectInterfaceReader.cpp\">\r\n      <Filter>Source Files\\Component</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"Component\\TransparentBridge.cpp\">\r\n      <Filter>Source Files\\Component</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"Component\\IndirectInterfaceWriter.cpp\">\r\n      <Filter>Source Files\\Component</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"Component\\validators\\IndirectInterfaceValidator.cpp\">\r\n      <Filter>Source Files\\Component\\validators</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"Component\\validators\\PortTypeValidator.cpp\">\r\n      <Filter>Source Files\\Component\\validators</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"Component\\validators\\AbstractionTypeValidator.cpp\">\r\n      <Filter>Source Files\\Component\\validators</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"common\\validators\\ParameterValidator.cpp\">\r\n      <Filter>Source Files\\common\\validators</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"common\\validators\\namevalidator.cpp\">\r\n      <Filter>Source Files\\common\\validators</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"common\\validators\\NMTokenValidator.cpp\">\r\n      <Filter>Source Files\\common\\validators</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"utilities\\XmlUtils.cpp\">\r\n      <Filter>Source Files\\utilities</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"Component\\validators\\RegisterFileValidator.cpp\">\r\n      <Filter>Source Files\\Component\\validators</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"Component\\validators\\RegisterBaseValidator.cpp\">\r\n      <Filter>Source Files\\Component\\validators</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"Component\\FieldReset.cpp\">\r\n      <Filter>Source Files\\Component</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"utilities\\BusDefinitionUtils.cpp\">\r\n      <Filter>Source Files\\utilities</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"Component\\SubSpaceMap.cpp\">\r\n      <Filter>Source Files\\Component</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"Component\\SubSpaceMapWriter.cpp\">\r\n      <Filter>Source Files\\Component</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"Component\\SubspaceMapReader.cpp\">\r\n      <Filter>Source Files\\Component</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"Component\\MemoryBlockBaseReader.cpp\">\r\n      <Filter>Source Files\\Component</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"Component\\MemoryBlockBaseWriter.cpp\">\r\n      <Filter>Source Files\\Component</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"Component\\validators\\MemoryBlockValidator.cpp\">\r\n      <Filter>Source Files\\Component\\validators</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"Component\\validators\\SubspaceMapValidator.cpp\">\r\n      <Filter>Source Files\\Component\\validators</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"common\\validators\\CommonItemsValidator.cpp\">\r\n      <Filter>Source Files\\common\\validators</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"common\\ChoiceWriter.cpp\">\r\n      <Filter>Source Files\\common</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"DesignConfiguration\\validators\\DesignConfigurationValidator.cpp\">\r\n      <Filter>Source Files\\DesignConfiguration\\validators</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"DesignConfiguration\\validators\\InterconnectionConfigurationValidator.cpp\">\r\n      <Filter>Source Files\\DesignConfiguration\\validators</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"DesignConfiguration\\validators\\ViewConfigurationValidator.cpp\">\r\n      <Filter>Source Files\\DesignConfiguration\\validators</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"DesignConfiguration\\AbstractorInstance.cpp\">\r\n      <Filter>Source Files\\DesignConfiguration</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"DesignConfiguration\\DesignConfiguration.cpp\">\r\n      <Filter>Source Files\\DesignConfiguration</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"DesignConfiguration\\DesignConfigurationReader.cpp\">\r\n      <Filter>Source Files\\DesignConfiguration</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"DesignConfiguration\\DesignConfigurationWriter.cpp\">\r\n      <Filter>Source Files\\DesignConfiguration</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"DesignConfiguration\\InterconnectionConfiguration.cpp\">\r\n      <Filter>Source Files\\DesignConfiguration</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"DesignConfiguration\\InterfaceRef.cpp\">\r\n      <Filter>Source Files\\DesignConfiguration</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"DesignConfiguration\\MultipleAbstractorInstances.cpp\">\r\n      <Filter>Source Files\\DesignConfiguration</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"DesignConfiguration\\ViewConfiguration.cpp\">\r\n      <Filter>Source Files\\DesignConfiguration</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"AbstractionDefinition\\Packet.cpp\">\r\n      <Filter>Source Files\\AbstractionDefinition</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"AbstractionDefinition\\PacketField.cpp\">\r\n      <Filter>Source Files\\AbstractionDefinition</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"AbstractionDefinition\\PacketReader.cpp\">\r\n      <Filter>Source Files\\AbstractionDefinition</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"common\\Qualifier.cpp\">\r\n      <Filter>Source Files\\common</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"AbstractionDefinition\\PacketWriter.cpp\">\r\n      <Filter>Source Files\\AbstractionDefinition</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"common\\validators\\QualifierValidator.cpp\">\r\n      <Filter>Source Files\\common\\validators</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"AbstractionDefinition\\validators\\PacketValidator.cpp\">\r\n      <Filter>Source Files\\AbstractionDefinition\\validators</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"common\\FileType.cpp\">\r\n      <Filter>Source Files\\common</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"Component\\Region.cpp\">\r\n      <Filter>Source Files\\Component</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"Component\\ExecutableImage.cpp\">\r\n      <Filter>Source Files\\Component</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"Component\\LanguageTools.cpp\">\r\n      <Filter>Source Files\\Component</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"Component\\validators\\RegionValidator.cpp\">\r\n      <Filter>Source Files\\Component\\validators</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"Component\\MemoryArray.cpp\">\r\n      <Filter>Source Files\\Component</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"Component\\MemoryArrayReader.cpp\">\r\n      <Filter>Source Files\\Component</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"Component\\MemoryArrayWriter.cpp\">\r\n      <Filter>Source Files\\Component</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"Component\\validators\\MemoryArrayValidator.cpp\">\r\n      <Filter>Source Files\\Component\\validators</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"Component\\FieldAccessPolicy.cpp\">\r\n      <Filter>Source Files\\Component</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"Component\\FieldAccessPolicyReader.cpp\">\r\n      <Filter>Source Files\\Component</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"Component\\FieldReference.cpp\">\r\n      <Filter>Source Files\\Component</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"Component\\ModeReference.cpp\">\r\n      <Filter>Source Files\\Component</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"Component\\FieldReferenceWriter.cpp\">\r\n      <Filter>Source Files\\Component</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"Component\\FieldReferenceReader.cpp\">\r\n      <Filter>Source Files\\Component</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"Component\\FieldAccessPolicyWriter.cpp\">\r\n      <Filter>Source Files\\Component</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"Component\\validators\\FieldAccessPolicyValidator.cpp\">\r\n      <Filter>Source Files\\Component\\validators</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"Component\\validators\\FieldReferenceValidator.cpp\">\r\n      <Filter>Source Files\\Component\\validators</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"Component\\AccessPolicy.cpp\">\r\n      <Filter>Source Files\\Component</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"Component\\AccessPolicyReader.cpp\">\r\n      <Filter>Source Files\\Component</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"Component\\AccessPolicyWriter.cpp\">\r\n      <Filter>Source Files\\Component</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"Component\\InitiatorInterface.cpp\">\r\n      <Filter>Source Files\\Component</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"Component\\TargetInterface.cpp\">\r\n      <Filter>Source Files\\Component</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"Component\\MirroredTargetInterface.cpp\">\r\n      <Filter>Source Files\\Component</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"Component\\ModeReader.cpp\">\r\n      <Filter>Source Files\\Component</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"Component\\Mode.cpp\">\r\n      <Filter>Source Files\\Component</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"Component\\ModeWriter.cpp\">\r\n      <Filter>Source Files\\Component</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"Component\\PortSlice.cpp\">\r\n      <Filter>Source Files\\Component</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"Component\\validators\\ModeValidator.cpp\">\r\n      <Filter>Source Files\\Component\\validators</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"Component\\validators\\PortSliceValidator.cpp\">\r\n      <Filter>Source Files\\Component\\validators</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"Component\\FileSetRef.cpp\">\r\n      <Filter>Source Files\\Component</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"Component\\FieldSlice.cpp\">\r\n      <Filter>Source Files\\Component</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"Component\\validators\\FieldSliceValidator.cpp\">\r\n      <Filter>Source Files\\Component\\validators</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"Component\\PowerDomain.cpp\">\r\n      <Filter>Source Files\\Component</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"Component\\PowerDomainReader.cpp\">\r\n      <Filter>Source Files\\Component</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"Component\\PowerDomainWriter.cpp\">\r\n      <Filter>Source Files\\Component</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"Component\\validators\\PowerDomainValidator.cpp\">\r\n      <Filter>Source Files\\Component\\validators</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"common\\QualifierReader.cpp\">\r\n      <Filter>Source Files\\common</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"Component\\Driver.cpp\">\r\n      <Filter>Source Files\\Component</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"common\\QualifierWriter.cpp\">\r\n      <Filter>Source Files\\common</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"common\\Choice.cpp\">\r\n      <Filter>Source Files\\common</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"common\\ChoiceReader.cpp\">\r\n      <Filter>Source Files\\common</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"common\\validators\\ChoiceValidator.cpp\">\r\n      <Filter>Source Files\\common\\validators</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"Component\\SubPort.cpp\">\r\n      <Filter>Source Files\\Component</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"Component\\Structured.cpp\">\r\n      <Filter>Source Files\\Component</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"common\\DocumentUtils.cpp\">\r\n      <Filter>Source Files\\common</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"Component\\validators\\CollectionValidators.cpp\">\r\n      <Filter>Source Files</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"common\\validators\\HierarchicalValidator.cpp\">\r\n      <Filter>Source Files\\Component\\validators</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"AbstractionDefinition\\validators\\PortAbstractionValidator.cpp\">\r\n      <Filter>Source Files\\AbstractionDefinition\\validators</Filter>\r\n    </ClCompile>\r\n  </ItemGroup>\r\n  <ItemGroup>\r\n    <ClInclude Include=\"BusDefinition\\BusDefinition.h\">\r\n      <Filter>Header Files\\BusDefinition</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"Design\\ActiveInterface.h\">\r\n      <Filter>Header Files\\Design</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"Design\\AdHocConnection.h\">\r\n      <Filter>Header Files\\Design</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"Design\\ComponentInstance.h\">\r\n      <Filter>Header Files\\Design</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"Design\\Design.h\">\r\n      <Filter>Header Files\\Design</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"Design\\HierInterface.h\">\r\n      <Filter>Header Files\\Design</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"Design\\Interconnection.h\">\r\n      <Filter>Header Files\\Design</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"Design\\MonitorInterconnection.h\">\r\n      <Filter>Header Files\\Design</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"Design\\MonitorInterface.h\">\r\n      <Filter>Header Files\\Design</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"Design\\PortReference.h\">\r\n      <Filter>Header Files\\Design</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"common\\Extendable.h\">\r\n      <Filter>Header Files\\common</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"generaldeclarations.h\">\r\n      <Filter>Header Files</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"ipxactmodels_global.h\">\r\n      <Filter>Header Files</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"AbstractionDefinition\\AbstractionDefinition.h\">\r\n      <Filter>Header Files\\AbstractionDefinition</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"AbstractionDefinition\\PortAbstraction.h\">\r\n      <Filter>Header Files\\AbstractionDefinition</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"AbstractionDefinition\\TransactionalAbstraction.h\">\r\n      <Filter>Header Files\\AbstractionDefinition</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"AbstractionDefinition\\TransactionalPort.h\">\r\n      <Filter>Header Files\\AbstractionDefinition</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"AbstractionDefinition\\WireAbstraction.h\">\r\n      <Filter>Header Files\\AbstractionDefinition</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"AbstractionDefinition\\WireAbstractionWriter.h\">\r\n      <Filter>Header Files\\AbstractionDefinition</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"AbstractionDefinition\\WirePort.h\">\r\n      <Filter>Header Files\\AbstractionDefinition</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"kactusExtensions\\ApiInterconnection.h\">\r\n      <Filter>Header Files\\kactusExtensions</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"kactusExtensions\\ApiInterface.h\">\r\n      <Filter>Header Files\\kactusExtensions</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"kactusExtensions\\ColumnDesc.h\">\r\n      <Filter>Header Files\\kactusExtensions</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"kactusExtensions\\ComInterconnection.h\">\r\n      <Filter>Header Files\\kactusExtensions</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"kactusExtensions\\ComInterface.h\">\r\n      <Filter>Header Files\\kactusExtensions</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"kactusExtensions\\ComProperty.h\">\r\n      <Filter>Header Files\\kactusExtensions</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"kactusExtensions\\FileDependency.h\">\r\n      <Filter>Header Files\\kactusExtensions</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"kactusExtensions\\HierApiInterconnection.h\">\r\n      <Filter>Header Files\\kactusExtensions</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"kactusExtensions\\HierComInterconnection.h\">\r\n      <Filter>Header Files\\kactusExtensions</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"kactusExtensions\\Kactus2Group.h\">\r\n      <Filter>Header Files\\kactusExtensions</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"kactusExtensions\\Kactus2Placeholder.h\">\r\n      <Filter>Header Files\\kactusExtensions</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"kactusExtensions\\Kactus2Position.h\">\r\n      <Filter>Header Files\\kactusExtensions</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"kactusExtensions\\Kactus2Value.h\">\r\n      <Filter>Header Files\\kactusExtensions</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"kactusExtensions\\KactusAttribute.h\">\r\n      <Filter>Header Files\\kactusExtensions</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"kactusExtensions\\SystemView.h\">\r\n      <Filter>Header Files\\kactusExtensions</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"Component\\AddressBlock.h\">\r\n      <Filter>Header Files\\Component</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"Component\\AddressSpace.h\">\r\n      <Filter>Header Files\\Component</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"Component\\AlternateRegister.h\">\r\n      <Filter>Header Files\\Component</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"Component\\BuildCommand.h\">\r\n      <Filter>Header Files\\Component</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"Component\\BusInterface.h\">\r\n      <Filter>Header Files\\Component</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"Component\\Channel.h\">\r\n      <Filter>Header Files\\Component</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"Component\\Component.h\">\r\n      <Filter>Header Files\\Component</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"Component\\ComponentGenerator.h\">\r\n      <Filter>Header Files\\Component</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"Component\\ComponentInstantiation.h\">\r\n      <Filter>Header Files\\Component</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"Component\\Cpu.h\">\r\n      <Filter>Header Files\\Component</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"Component\\DesignConfigurationInstantiation.h\">\r\n      <Filter>Header Files\\Component</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"Component\\DesignInstantiation.h\">\r\n      <Filter>Header Files\\Component</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"Component\\EnumeratedValue.h\">\r\n      <Filter>Header Files\\Component</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"Component\\Field.h\">\r\n      <Filter>Header Files\\Component</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"Component\\File.h\">\r\n      <Filter>Header Files\\Component</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"Component\\FileSet.h\">\r\n      <Filter>Header Files\\Component</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"Component\\Function.h\">\r\n      <Filter>Header Files\\Component</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"Component\\MemoryBlockBase.h\">\r\n      <Filter>Header Files\\Component</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"Component\\MemoryMap.h\">\r\n      <Filter>Header Files\\Component</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"Component\\MemoryMapBase.h\">\r\n      <Filter>Header Files\\Component</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"Component\\MemoryRemap.h\">\r\n      <Filter>Header Files\\Component</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"Component\\Model.h\">\r\n      <Filter>Header Files\\Component</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"Component\\OtherClockDriver.h\">\r\n      <Filter>Header Files\\Component</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"Component\\Port.h\">\r\n      <Filter>Header Files\\Component</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"Component\\Register.h\">\r\n      <Filter>Header Files\\Component</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"Component\\RegisterBase.h\">\r\n      <Filter>Header Files\\Component</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"Component\\RegisterDefinition.h\">\r\n      <Filter>Header Files\\Component</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"Component\\RegisterFile.h\">\r\n      <Filter>Header Files\\Component</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"Component\\RemapPort.h\">\r\n      <Filter>Header Files\\Component</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"Component\\RemapState.h\">\r\n      <Filter>Header Files\\Component</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"Component\\Transactional.h\">\r\n      <Filter>Header Files\\Component</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"Component\\View.h\">\r\n      <Filter>Header Files\\Component</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"Component\\Wire.h\">\r\n      <Filter>Header Files\\Component</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"Component\\WireTypeDef.h\">\r\n      <Filter>Header Files\\Component</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"Component\\WriteValueConstraint.h\">\r\n      <Filter>Header Files\\Component</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"common\\Array.h\">\r\n      <Filter>Header Files\\common</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"common\\Assertion.h\">\r\n      <Filter>Header Files\\common</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"common\\BooleanValue.h\">\r\n      <Filter>Header Files\\common</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"common\\BuildModel.h\">\r\n      <Filter>Header Files\\common</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"common\\CellSpecification.h\">\r\n      <Filter>Header Files\\common</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"common\\ClockUnit.h\">\r\n      <Filter>Header Files\\common</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"common\\ConfigurableElementValue.h\">\r\n      <Filter>Header Files\\common</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"common\\ConfigurableVLNVReference.h\">\r\n      <Filter>Header Files\\common</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"common\\DirectionTypes.h\">\r\n      <Filter>Header Files\\common</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"common\\Document.h\">\r\n      <Filter>Header Files\\common</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"common\\Extendable.h\">\r\n      <Filter>Header Files\\common</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"common\\FileBuilder.h\">\r\n      <Filter>Header Files\\common</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"common\\ModuleParameter.h\">\r\n      <Filter>Header Files\\common</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"common\\NameGroup.h\">\r\n      <Filter>Header Files\\common</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"common\\NameValuePair.h\">\r\n      <Filter>Header Files\\common</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"common\\Parameter.h\">\r\n      <Filter>Header Files\\common</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"common\\PartSelect.h\">\r\n      <Filter>Header Files\\common</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"common\\Protocol.h\">\r\n      <Filter>Header Files\\common</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"common\\Qualifier.h\">\r\n      <Filter>Header Files\\common</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"common\\Range.h\">\r\n      <Filter>Header Files\\common</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"common\\TransactionalTypes.h\">\r\n      <Filter>Header Files\\common</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"common\\Vector.h\">\r\n      <Filter>Header Files\\common</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"common\\Enumeration.h\">\r\n      <Filter>Header Files\\common</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"Component\\Segment.h\">\r\n      <Filter>Header Files\\Component</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"Component\\AbstractionType.h\">\r\n      <Filter>Header Files\\Component</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"Component\\PortMap.h\">\r\n      <Filter>Header Files\\Component</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"kactusExtensions\\ApiDefinition.h\">\r\n      <Filter>Header Files\\kactusExtensions</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"kactusExtensions\\ApiFunction.h\">\r\n      <Filter>Header Files\\kactusExtensions</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"kactusExtensions\\ApiFunctionParameter.h\">\r\n      <Filter>Header Files\\kactusExtensions</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"kactusExtensions\\ComDefinition.h\">\r\n      <Filter>Header Files\\kactusExtensions</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"common\\VendorExtension.h\">\r\n      <Filter>Header Files\\common</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"common\\VLNV.h\">\r\n      <Filter>Header Files\\common</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"kactusExtensions\\ConnectionRoute.h\">\r\n      <Filter>Header Files\\kactusExtensions</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"common\\validators\\ValueFormatter.h\">\r\n      <Filter>Header Files\\common\\validators</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"BusDefinition\\validators\\BusDefinitionValidator.h\">\r\n      <Filter>Header Files\\BusDefinition\\validators</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"Component\\validators\\FieldValidator.h\">\r\n      <Filter>Header Files\\Component\\validators</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"Component\\validators\\EnumeratedValueValidator.h\">\r\n      <Filter>Header Files\\Component\\validators</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"Component\\validators\\FileValidator.h\">\r\n      <Filter>Header Files\\Component\\validators</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"Component\\validators\\FileSetValidator.h\">\r\n      <Filter>Header Files\\Component\\validators</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"Component\\validators\\CPUValidator.h\">\r\n      <Filter>Header Files\\Component\\validators</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"Component\\validators\\RemapStateValidator.h\">\r\n      <Filter>Header Files\\Component\\validators</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"Component\\validators\\RegisterValidator.h\">\r\n      <Filter>Header Files\\Component\\validators</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"Component\\validators\\MemoryReserve.h\">\r\n      <Filter>Header Files\\Component\\validators</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"Component\\validators\\AddressBlockValidator.h\">\r\n      <Filter>Header Files\\Component\\validators</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"Component\\validators\\MemoryMapBaseValidator.h\">\r\n      <Filter>Header Files\\Component\\validators</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"Component\\validators\\MemoryMapValidator.h\">\r\n      <Filter>Header Files\\Component\\validators</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"Component\\validators\\AddressSpaceValidator.h\">\r\n      <Filter>Header Files\\Component\\validators</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"common\\AccessTypes.h\">\r\n      <Filter>Header Files\\common</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"Component\\validators\\ChannelValidator.h\">\r\n      <Filter>Header Files\\Component\\validators</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"Component\\validators\\PortValidator.h\">\r\n      <Filter>Header Files\\Component\\validators</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"common\\TimingConstraint.h\">\r\n      <Filter>Header Files\\common</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"common\\PresenceTypes.h\">\r\n      <Filter>Header Files\\common</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"Component\\validators\\InstantiationsValidator.h\">\r\n      <Filter>Header Files\\Component\\validators</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"Component\\validators\\ViewValidator.h\">\r\n      <Filter>Header Files\\Component\\validators</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"Component\\validators\\OtherClockDriverValidator.h\">\r\n      <Filter>Header Files\\Component\\validators</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"Component\\validators\\PortMapValidator.h\">\r\n      <Filter>Header Files\\Component\\validators</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"AbstractionDefinition\\validators\\AbstractionDefinitionValidator.h\">\r\n      <Filter>Header Files\\AbstractionDefinition\\validators</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"common\\validators\\ProtocolValidator.h\">\r\n      <Filter>Header Files\\common\\validators</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"common\\validators\\TimingConstraintValidator.h\">\r\n      <Filter>Header Files\\common\\validators</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"common\\validators\\CellSpecificationValidator.h\">\r\n      <Filter>Header Files\\common\\validators</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"Component\\validators\\ComponentValidator.h\">\r\n      <Filter>Header Files\\Component\\validators</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"Component\\validators\\ComponentGeneratorValidator.h\">\r\n      <Filter>Header Files\\Component\\validators</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"common\\validators\\AssertionValidator.h\">\r\n      <Filter>Header Files\\common\\validators</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"Design\\validator\\AdHocConnectionValidator.h\">\r\n      <Filter>Header Files\\Design\\validators</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"Design\\validator\\ComponentInstanceValidator.h\">\r\n      <Filter>Header Files\\Design\\validators</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"Design\\validator\\InterconnectionValidator.h\">\r\n      <Filter>Header Files\\Design\\validators</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"Design\\validator\\DesignValidator.h\">\r\n      <Filter>Header Files\\Design\\validators</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"kactusExtensions\\validators\\ApiDefinitionValidator.h\">\r\n      <Filter>Header Files\\kactusExtensions</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"kactusExtensions\\validators\\ComDefinitionValidator.h\">\r\n      <Filter>Header Files\\kactusExtensions</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"common\\PortAlignment.h\">\r\n      <Filter>Header Files\\common</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"kactusExtensions\\validators\\SystemDesignConfigurationValidator.h\">\r\n      <Filter>Header Files\\kactusExtensions\\validators</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"kactusExtensions\\validators\\SystemViewConfigurationValidator.h\">\r\n      <Filter>Header Files\\kactusExtensions\\validators</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"kactusExtensions\\InterfaceGraphicsData.h\">\r\n      <Filter>Header Files\\kactusExtensions</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"Component\\validators\\BusInterfaceValidator.h\">\r\n      <Filter>Header Files\\Component\\validators</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"Catalog\\Catalog.h\">\r\n      <Filter>Header Files\\Catalog</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"Catalog\\IpxactFile.h\">\r\n      <Filter>Header Files\\Catalog</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"Catalog\\validators\\CatalogValidator.h\">\r\n      <Filter>Header Files\\Catalog\\validators</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"Component\\IndirectInterface.h\">\r\n      <Filter>Header Files\\Component</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"Component\\IndirectInterfaceReader.h\">\r\n      <Filter>Header Files\\Component</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"Component\\TransparentBridge.h\">\r\n      <Filter>Header Files\\Component</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"Component\\IndirectInterfaceWriter.h\">\r\n      <Filter>Header Files\\Component</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"Component\\validators\\IndirectInterfaceValidator.h\">\r\n      <Filter>Header Files\\Component\\validators</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"Component\\validators\\PortTypeValidator.h\">\r\n      <Filter>Header Files\\Component\\validators</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"Component\\validators\\AbstractionTypeValidator.h\">\r\n      <Filter>Header Files\\Component\\validators</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"common\\validators\\ParameterValidator.h\">\r\n      <Filter>Header Files\\common\\validators</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"utilities\\XmlUtils.h\">\r\n      <Filter>Header Files\\utilities</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"Component\\validators\\RegisterFileValidator.h\">\r\n      <Filter>Header Files\\Component\\validators</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"Component\\validators\\RegisterBaseValidator.h\">\r\n      <Filter>Header Files\\Component\\validators</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"Component\\FieldReset.h\">\r\n      <Filter>Header Files\\Component</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"utilities\\BusDefinitionUtils.h\">\r\n      <Filter>Header Files\\utilities</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"common\\TagData.h\">\r\n      <Filter>Header Files\\common</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"Component\\SubSpaceMap.h\">\r\n      <Filter>Header Files\\Component</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"Component\\SubSpaceMapWriter.h\">\r\n      <Filter>Header Files\\Component</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"Component\\SubspaceMapReader.h\">\r\n      <Filter>Header Files\\Component</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"Component\\MemoryBlockBaseReader.h\">\r\n      <Filter>Header Files\\Component</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"Component\\MemoryBlockBaseWriter.h\">\r\n      <Filter>Header Files\\Component</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"Component\\validators\\MemoryBlockValidator.h\">\r\n      <Filter>Header Files\\Component\\validators</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"Component\\validators\\SubspaceMapValidator.h\">\r\n      <Filter>Header Files\\Component\\validators</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"common\\validators\\CommonItemsValidator.h\">\r\n      <Filter>Header Files\\common\\validators</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"common\\ChoiceWriter.h\">\r\n      <Filter>Header Files\\common</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"DesignConfiguration\\AbstractorInstance.h\">\r\n      <Filter>Header Files\\DesignConfiguration</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"DesignConfiguration\\DesignConfiguration.h\">\r\n      <Filter>Header Files\\DesignConfiguration</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"DesignConfiguration\\DesignConfigurationReader.h\">\r\n      <Filter>Header Files\\DesignConfiguration</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"DesignConfiguration\\DesignConfigurationWriter.h\">\r\n      <Filter>Header Files\\DesignConfiguration</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"DesignConfiguration\\InterconnectionConfiguration.h\">\r\n      <Filter>Header Files\\DesignConfiguration</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"DesignConfiguration\\InterfaceRef.h\">\r\n      <Filter>Header Files\\DesignConfiguration</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"DesignConfiguration\\MultipleAbstractorInstances.h\">\r\n      <Filter>Header Files\\DesignConfiguration</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"DesignConfiguration\\ViewConfiguration.h\">\r\n      <Filter>Header Files\\DesignConfiguration</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"DesignConfiguration\\validators\\DesignConfigurationValidator.h\">\r\n      <Filter>Header Files\\DesignConfiguration\\validators</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"DesignConfiguration\\validators\\InterconnectionConfigurationValidator.h\">\r\n      <Filter>Header Files\\DesignConfiguration\\validators</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"DesignConfiguration\\validators\\ViewConfigurationValidator.h\">\r\n      <Filter>Header Files\\DesignConfiguration\\validators</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"AbstractionDefinition\\Packet.h\">\r\n      <Filter>Header Files\\AbstractionDefinition</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"AbstractionDefinition\\PacketField.h\">\r\n      <Filter>Header Files\\AbstractionDefinition</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"AbstractionDefinition\\WireAbstractionReader.h\">\r\n      <Filter>Header Files\\AbstractionDefinition</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"AbstractionDefinition\\TransactionalAbstractionReader.h\">\r\n      <Filter>Header Files\\AbstractionDefinition</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"AbstractionDefinition\\PacketReader.h\">\r\n      <Filter>Header Files\\AbstractionDefinition</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"AbstractionDefinition\\PacketWriter.h\">\r\n      <Filter>Header Files\\AbstractionDefinition</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"common\\NameGroupWriter.h\">\r\n      <Filter>Header Files\\common</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"common\\validators\\QualifierValidator.h\">\r\n      <Filter>Header Files\\common\\validators</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"AbstractionDefinition\\validators\\PacketValidator.h\">\r\n      <Filter>Header Files\\AbstractionDefinition\\validators</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"common\\NameGroupReader.h\">\r\n      <Filter>Header Files\\common</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"common\\NameGroupWriter.h\">\r\n      <Filter>Header Files\\common</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"common\\ModuleParameterWriter.h\">\r\n      <Filter>Header Files\\common</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"common\\ParameterReader.h\">\r\n      <Filter>Header Files\\common</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"common\\ParameterWriter.h\">\r\n      <Filter>Header Files\\common</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"common\\ProtocolReader.h\">\r\n      <Filter>Header Files\\common</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"common\\ProtocolWriter.h\">\r\n      <Filter>Header Files\\common</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"common\\ModuleParameterReader.h\">\r\n      <Filter>Header Files\\common</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"common\\FileType.h\">\r\n      <Filter>Header Files\\common</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"Component\\Region.h\">\r\n      <Filter>Header Files\\Component</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"Component\\ExecutableImage.h\">\r\n      <Filter>Header Files\\Component</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"Component\\LanguageTools.h\">\r\n      <Filter>Header Files\\Component</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"Component\\validators\\RegionValidator.h\">\r\n      <Filter>Header Files\\Component\\validators</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"AbstractionDefinition\\TransactionalAbstractionWriter.h\">\r\n      <Filter>Header Files\\AbstractionDefinition</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"Component\\ViewReader.h\">\r\n      <Filter>Header Files\\Component</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"Component\\ViewWriter.h\">\r\n      <Filter>Header Files\\Component</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"Component\\MemoryArray.h\">\r\n      <Filter>Header Files\\Component</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"Component\\MemoryArrayReader.h\">\r\n      <Filter>Header Files\\Component</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"Component\\MemoryArrayWriter.h\">\r\n      <Filter>Header Files\\Component</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"Component\\validators\\MemoryArrayValidator.h\">\r\n      <Filter>Header Files\\Component\\validators</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"Component\\FieldAccessPolicyReader.h\">\r\n      <Filter>Header Files\\Component</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"Component\\FieldAccessPolicy.h\">\r\n      <Filter>Header Files\\Component</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"Component\\FieldReference.h\">\r\n      <Filter>Header Files\\Component</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"Component\\ModeReference.h\">\r\n      <Filter>Header Files\\Component</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"Component\\FieldReferenceReader.h\">\r\n      <Filter>Header Files\\Component</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"Component\\FieldReferenceWriter.h\">\r\n      <Filter>Header Files\\Component</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"Component\\FieldAccessPolicyWriter.h\">\r\n      <Filter>Header Files\\Component</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"Component\\validators\\FieldAccessPolicyValidator.h\">\r\n      <Filter>Header Files\\Component\\validators</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"Component\\validators\\FieldReferenceValidator.h\">\r\n      <Filter>Header Files\\Component\\validators</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"Component\\AccessPolicy.h\">\r\n      <Filter>Header Files\\Component</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"Component\\AccessPolicyReader.h\">\r\n      <Filter>Header Files\\Component</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"Component\\AccessPolicyWriter.h\">\r\n      <Filter>Header Files\\Component</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"Component\\InitiatorInterface.h\">\r\n      <Filter>Header Files\\Component</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"Component\\TargetInterface.h\">\r\n      <Filter>Header Files\\Component</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"Component\\MirroredTargetInterface.h\">\r\n      <Filter>Header Files\\Component</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"Component\\ModeReader.h\">\r\n      <Filter>Header Files\\Component</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"Component\\Mode.h\">\r\n      <Filter>Header Files\\Component</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"Component\\ModeWriter.h\">\r\n      <Filter>Header Files\\Component</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"Component\\PortSlice.h\">\r\n      <Filter>Header Files\\Component</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"Component\\validators\\ModeValidator.h\">\r\n      <Filter>Header Files\\Component\\validators</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"Component\\validators\\PortSliceValidator.h\">\r\n      <Filter>Header Files\\Component\\validators</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"Component\\FileSetRef.h\">\r\n      <Filter>Header Files\\Component</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"Component\\FieldSlice.h\">\r\n      <Filter>Header Files\\Component</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"Component\\validators\\FieldSliceValidator.h\">\r\n      <Filter>Header Files\\Component\\validators</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"Component\\PowerDomain.h\">\r\n      <Filter>Header Files\\Component</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"Component\\PowerDomainReader.h\">\r\n      <Filter>Header Files\\Component</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"Component\\PowerDomainWriter.h\">\r\n      <Filter>Header Files\\Component</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"Component\\validators\\PowerDomainValidator.h\">\r\n      <Filter>Header Files\\Component\\validators</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"Component\\RemapStateReader.h\">\r\n      <Filter>Header Files\\Component</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"Component\\RemapStateWriter.h\">\r\n      <Filter>Header Files\\Component</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"utilities\\Copy.h\">\r\n      <Filter>Header Files\\utilities</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"common\\QualifierReader.h\">\r\n      <Filter>Header Files\\common</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"Component\\Driver.h\">\r\n      <Filter>Header Files\\Component</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"Component\\OtherClockDriverReader.h\">\r\n      <Filter>Header Files\\Component</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"common\\QualifierWriter.h\">\r\n      <Filter>Header Files\\common</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"common\\Choice.h\">\r\n      <Filter>Header Files\\common</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"common\\ChoiceReader.h\">\r\n      <Filter>Header Files\\common</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"common\\validators\\ChoiceValidator.h\">\r\n      <Filter>Header Files\\common\\validators</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"Component\\SubPort.h\">\r\n      <Filter>Header Files\\Component</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"Component\\Structured.h\">\r\n      <Filter>Header Files\\Component</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"common\\DocumentUtils.h\">\r\n      <Filter>Header Files\\common</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"common\\validators\\HierarchicalValidator.h\">\r\n      <Filter>Header Files\\common\\validators</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"Component\\validators\\CollectionValidators.h\">\r\n      <Filter>Header Files\\Component\\validators</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"AbstractionDefinition\\validators\\PortAbstractionValidator.h\">\r\n      <Filter>Header Files\\AbstractionDefinition\\validators</Filter>\r\n    </ClInclude>\r\n  </ItemGroup>\r\n  <ItemGroup>\r\n    <CustomBuild Include=\"BusDefinition\\BusDefinitionReader.h\">\r\n      <Filter>Header Files\\BusDefinition</Filter>\r\n    </CustomBuild>\r\n    <CustomBuild Include=\"BusDefinition\\BusDefinitionWriter.h\">\r\n      <Filter>Header Files\\BusDefinition</Filter>\r\n    </CustomBuild>\r\n    <CustomBuild Include=\"Design\\DesignReader.h\">\r\n      <Filter>Header Files\\Design</Filter>\r\n    </CustomBuild>\r\n    <CustomBuild Include=\"Design\\DesignWriter.h\">\r\n      <Filter>Header Files\\Design</Filter>\r\n    </CustomBuild>\r\n    <CustomBuild Include=\"Design\\ComponentInstanceReader.h\">\r\n      <Filter>Header Files\\Design</Filter>\r\n    </CustomBuild>\r\n    <CustomBuild Include=\"Design\\ComponentInstanceWriter.h\">\r\n      <Filter>Header Files\\Design</Filter>\r\n    </CustomBuild>\r\n    <CustomBuild Include=\"AbstractionDefinition\\AbstractionDefinitionReader.h\">\r\n      <Filter>Header Files\\AbstractionDefinition</Filter>\r\n    </CustomBuild>\r\n    <CustomBuild Include=\"AbstractionDefinition\\AbstractionDefinitionWriter.h\">\r\n      <Filter>Header Files\\AbstractionDefinition</Filter>\r\n    </CustomBuild>\r\n    <CustomBuild Include=\"Component\\AddressBlockReader.h\">\r\n      <Filter>Header Files\\Component</Filter>\r\n    </CustomBuild>\r\n    <CustomBuild Include=\"Component\\AddressBlockWriter.h\">\r\n      <Filter>Header Files\\Component</Filter>\r\n    </CustomBuild>\r\n    <CustomBuild Include=\"Component\\AddressSpaceReader.h\">\r\n      <Filter>Header Files\\Component</Filter>\r\n    </CustomBuild>\r\n    <CustomBuild Include=\"Component\\AddressSpaceWriter.h\">\r\n      <Filter>Header Files\\Component</Filter>\r\n    </CustomBuild>\r\n    <CustomBuild Include=\"Component\\BusInterfaceReader.h\">\r\n      <Filter>Header Files\\Component</Filter>\r\n    </CustomBuild>\r\n    <CustomBuild Include=\"Component\\BusInterfaceWriter.h\">\r\n      <Filter>Header Files\\Component</Filter>\r\n    </CustomBuild>\r\n    <CustomBuild Include=\"Component\\ChannelReader.h\">\r\n      <Filter>Header Files\\Component</Filter>\r\n    </CustomBuild>\r\n    <CustomBuild Include=\"Component\\ChannelWriter.h\">\r\n      <Filter>Header Files\\Component</Filter>\r\n    </CustomBuild>\r\n    <CustomBuild Include=\"Component\\ComponentGeneratorReader.h\">\r\n      <Filter>Header Files\\Component</Filter>\r\n    </CustomBuild>\r\n    <CustomBuild Include=\"Component\\ComponentGeneratorWriter.h\">\r\n      <Filter>Header Files\\Component</Filter>\r\n    </CustomBuild>\r\n    <CustomBuild Include=\"Component\\ComponentReader.h\">\r\n      <Filter>Header Files\\Component</Filter>\r\n    </CustomBuild>\r\n    <CustomBuild Include=\"Component\\ComponentWriter.h\">\r\n      <Filter>Header Files\\Component</Filter>\r\n    </CustomBuild>\r\n    <CustomBuild Include=\"Component\\CPUReader.h\">\r\n      <Filter>Header Files\\Component</Filter>\r\n    </CustomBuild>\r\n    <CustomBuild Include=\"Component\\CPUWriter.h\">\r\n      <Filter>Header Files\\Component</Filter>\r\n    </CustomBuild>\r\n    <CustomBuild Include=\"Component\\EnumeratedValueReader.h\">\r\n      <Filter>Header Files\\Component</Filter>\r\n    </CustomBuild>\r\n    <CustomBuild Include=\"Component\\EnumeratedValueWriter.h\">\r\n      <Filter>Header Files\\Component</Filter>\r\n    </CustomBuild>\r\n    <CustomBuild Include=\"Component\\FieldReader.h\">\r\n      <Filter>Header Files\\Component</Filter>\r\n    </CustomBuild>\r\n    <CustomBuild Include=\"Component\\FieldWriter.h\">\r\n      <Filter>Header Files\\Component</Filter>\r\n    </CustomBuild>\r\n    <CustomBuild Include=\"Component\\FileReader.h\">\r\n      <Filter>Header Files\\Component</Filter>\r\n    </CustomBuild>\r\n    <CustomBuild Include=\"Component\\FileSetReader.h\">\r\n      <Filter>Header Files\\Component</Filter>\r\n    </CustomBuild>\r\n    <CustomBuild Include=\"Component\\FileSetWriter.h\">\r\n      <Filter>Header Files\\Component</Filter>\r\n    </CustomBuild>\r\n    <CustomBuild Include=\"Component\\FileWriter.h\">\r\n      <Filter>Header Files\\Component</Filter>\r\n    </CustomBuild>\r\n    <CustomBuild Include=\"Component\\InstantiationsReader.h\">\r\n      <Filter>Header Files\\Component</Filter>\r\n    </CustomBuild>\r\n    <CustomBuild Include=\"Component\\InstantiationsWriter.h\">\r\n      <Filter>Header Files\\Component</Filter>\r\n    </CustomBuild>\r\n    <CustomBuild Include=\"Component\\MemoryMapBaseReader.h\">\r\n      <Filter>Header Files\\Component</Filter>\r\n    </CustomBuild>\r\n    <CustomBuild Include=\"Component\\MemoryMapBaseWriter.h\">\r\n      <Filter>Header Files\\Component</Filter>\r\n    </CustomBuild>\r\n    <CustomBuild Include=\"Component\\MemoryMapReader.h\">\r\n      <Filter>Header Files\\Component</Filter>\r\n    </CustomBuild>\r\n    <CustomBuild Include=\"Component\\MemoryMapWriter.h\">\r\n      <Filter>Header Files\\Component</Filter>\r\n    </CustomBuild>\r\n    <QtMoc Include=\"Component\\OtherClockDriverWriter.h\">\r\n      <Filter>Header Files\\Component</Filter>\r\n    </QtMoc>\r\n    <CustomBuild Include=\"Component\\PortReader.h\">\r\n      <Filter>Header Files\\Component</Filter>\r\n    </CustomBuild>\r\n    <CustomBuild Include=\"Component\\PortWriter.h\">\r\n      <Filter>Header Files\\Component</Filter>\r\n    </CustomBuild>\r\n    <CustomBuild Include=\"Component\\RegisterReader.h\">\r\n      <Filter>Header Files\\Component</Filter>\r\n    </CustomBuild>\r\n    <CustomBuild Include=\"Component\\RegisterWriter.h\">\r\n      <Filter>Header Files\\Component</Filter>\r\n    </CustomBuild>\r\n    <CustomBuild Include=\"common\\CommonItemsReader.h\">\r\n      <Filter>Header Files\\common</Filter>\r\n    </CustomBuild>\r\n    <CustomBuild Include=\"common\\CommonItemsWriter.h\">\r\n      <Filter>Header Files\\common</Filter>\r\n    </CustomBuild>\r\n    <CustomBuild Include=\"common\\DocumentReader.h\">\r\n      <Filter>Header Files\\common</Filter>\r\n    </CustomBuild>\r\n    <CustomBuild Include=\"common\\DocumentWriter.h\">\r\n      <Filter>Header Files\\common</Filter>\r\n    </CustomBuild>\r\n    <CustomBuild Include=\"common\\FileBuilderReader.h\">\r\n      <Filter>Header Files\\common</Filter>\r\n    </CustomBuild>\r\n    <CustomBuild Include=\"common\\FileBuilderWriter.h\">\r\n      <Filter>Header Files\\common</Filter>\r\n    </CustomBuild>\r\n    <CustomBuild Include=\"kactusExtensions\\ApiDefinitionWriter.h\">\r\n      <Filter>Header Files\\kactusExtensions</Filter>\r\n    </CustomBuild>\r\n    <CustomBuild Include=\"kactusExtensions\\ComDefinitionWriter.h\">\r\n      <Filter>Header Files\\kactusExtensions</Filter>\r\n    </CustomBuild>\r\n    <CustomBuild Include=\"kactusExtensions\\ApiDefinitionReader.h\">\r\n      <Filter>Header Files\\kactusExtensions</Filter>\r\n    </CustomBuild>\r\n    <CustomBuild Include=\"kactusExtensions\\ComDefinitionReader.h\">\r\n      <Filter>Header Files\\kactusExtensions</Filter>\r\n    </CustomBuild>\r\n    <CustomBuild Include=\"Catalog\\CatalogReader.h\">\r\n      <Filter>Header Files\\Catalog</Filter>\r\n    </CustomBuild>\r\n    <CustomBuild Include=\"Catalog\\CatalogWriter.h\">\r\n      <Filter>Header Files\\Catalog</Filter>\r\n    </CustomBuild>\r\n    <QtMoc Include=\"common\\validators\\namevalidator.h\">\r\n      <Filter>Header Files\\common\\validators</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"common\\validators\\NMTokenValidator.h\">\r\n      <Filter>Header Files\\common\\validators</Filter>\r\n    </QtMoc>\r\n    <CustomBuild Include=\"common\\GenericVendorExtension.h\">\r\n      <Filter>Header Files\\common</Filter>\r\n    </CustomBuild>\r\n  </ItemGroup>\r\n</Project>"
  },
  {
    "path": "IPXACTmodels/common/AccessTypes.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: AccessTypes.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 09.12.2015\r\n//\r\n// Description:\r\n// Namespace AccessTypes is used to store functions related to memory access.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"AccessTypes.h\"\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AccessTypes::str2Access()\r\n//-----------------------------------------------------------------------------\r\nAccessTypes::Access AccessTypes::str2Access(QString str, AccessTypes::Access defaultValue)\r\n{\r\n    if (str == QLatin1String(\"read-write\"))\r\n    {\r\n\t\treturn AccessTypes::READ_WRITE;\r\n\t}\r\n\telse if (str == QLatin1String(\"read-only\"))\r\n    {\r\n\t\treturn AccessTypes::READ_ONLY;\r\n\t}\r\n\telse if (str ==\tQLatin1String(\"write-only\"))\r\n    {\r\n\t\treturn AccessTypes::WRITE_ONLY;\r\n\t}\r\n\telse if (str ==\tQLatin1String(\"read-writeOnce\"))\r\n    {\r\n\t\treturn AccessTypes::READ_WRITEONCE;\r\n\t}\r\n\telse if (str == QLatin1String(\"writeOnce\"))\r\n    {\r\n\t\treturn AccessTypes::WRITEONCE;\r\n\t}\r\n\telse\r\n    {\r\n\t\treturn defaultValue;\r\n\t}\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AccessTypes::access2Str()\r\n//-----------------------------------------------------------------------------\r\nQString AccessTypes::access2Str(const AccessTypes::Access access)\r\n{\r\n    if (access == AccessTypes::READ_WRITE)\r\n    {\r\n        return QStringLiteral(\"read-write\");\r\n    }\r\n    else if (access == AccessTypes::READ_ONLY)\r\n    {\r\n        return QStringLiteral(\"read-only\");\r\n    }\r\n    else if (access == AccessTypes::WRITE_ONLY)\r\n    {\r\n        return QStringLiteral(\"write-only\");\r\n    }\r\n    else if (access == AccessTypes::READ_WRITEONCE)\r\n    {\r\n        return QStringLiteral(\"read-writeOnce\");\r\n    }\r\n    else if (access == AccessTypes::WRITEONCE)\r\n    {\r\n        return QStringLiteral(\"writeOnce\");\r\n    }\r\n    else\r\n    {\r\n        return QStringLiteral(\"\");\r\n    }\r\n}"
  },
  {
    "path": "IPXACTmodels/common/AccessTypes.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: AccessTypes.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 09.12.2015\r\n//\r\n// Description:\r\n// Namespace AccessTypes is used to store functions related to memory access.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef ACCESSTYPES_H\r\n#define ACCESSTYPES_H\r\n\r\n#include <IPXACTmodels/ipxactmodels_global.h>\r\n\r\n#include <QString>\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Namespace AccessTypes is used to store functions related to memory access.\r\n//-----------------------------------------------------------------------------\r\nnamespace AccessTypes\r\n{\r\n    /*!\r\n     *  Equals ipxact:access element within ipxact:memoryBlockData\r\n     *\r\n     * Access specifies the accessibility of the data in the address block.\r\n     */\r\n    enum Access {\r\n        READ_WRITE = 0,\r\n        READ_ONLY,\r\n        WRITE_ONLY,\r\n        READ_WRITEONCE,\r\n        WRITEONCE,\r\n        ACCESS_COUNT\r\n    };\r\n\r\n    /*!\r\n     *  Convert the value of the QString into enum Access\r\n     *\r\n     *  If The str does not match any of the enum values the default value specified as parameter will be returned.\r\n     *\r\n     *    @param [in] str             QString containing the string to be converted.\r\n     *    @param [in] defaultValue    The value that will be returned if no match is found.\r\n     *\r\n     *    @return Access that matches the str or default value.\r\n     */\r\n    IPXACTMODELS_EXPORT AccessTypes::Access str2Access(QString str, AccessTypes::Access defaultValue);\r\n\r\n    /*!\r\n     *  Convert the Access value to QString.\r\n     *\r\n     *    @param [in] access  The Access value to be converted into QString.\r\n     *\r\n     *    @return QString that matches the enum value.\r\n     */\r\n    IPXACTMODELS_EXPORT QString access2Str(const AccessTypes::Access access);\r\n}\r\n\r\n#endif // ACCESSTYPES_H\r\n"
  },
  {
    "path": "IPXACTmodels/common/Array.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: Array.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Esko Pekkarinen\r\n// Date: 03.08.2015\r\n//\r\n// Description:\r\n// Implementation of ipxact:array element.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"Array.h\"\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Array::Array()\r\n//-----------------------------------------------------------------------------\r\nArray::Array(QString left, QString right):\r\nRange(left, right)\r\n{\r\n    \r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Array::Array()\r\n//-----------------------------------------------------------------------------\r\nArray::Array(Array const& other):\r\n    Range(other.getLeft(), other.getRight()),\r\n    arrayId_(other.arrayId_)\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Array::operator=()\r\n//-----------------------------------------------------------------------------\r\nArray& Array::operator=(Array const& other)\r\n{\r\n    if (this != &other)\r\n    {\r\n        Range::operator=(other);\r\n        arrayId_ = other.arrayId_;\r\n    }\r\n\r\n    return *this;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Array::~Array()\r\n//-----------------------------------------------------------------------------\r\nArray::~Array()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Array::setId()\r\n//-----------------------------------------------------------------------------\r\nvoid Array::setId(QString const& id)\r\n{\r\n    arrayId_ = id;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Array::getId()\r\n//-----------------------------------------------------------------------------\r\nQString Array::getId() const\r\n{\r\n    return arrayId_;\r\n}\r\n"
  },
  {
    "path": "IPXACTmodels/common/Array.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: Array.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Esko Pekkarinen\r\n// Date: 03.08.2015\r\n//\r\n// Description:\r\n// Implementation of ipxact:array element.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef ARRAY_H\r\n#define ARRAY_H\r\n\r\n#include \"Vector.h\"\r\n\r\nusing Array = Vector;\r\n\r\n#endif // ARRAY_H\r\n"
  },
  {
    "path": "IPXACTmodels/common/Assertion.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: Assertion.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 05.08.2015\r\n//\r\n// Description:\r\n// Matches the ipxact:assertion element.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"Assertion.h\"\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Assertion::()\r\n//-----------------------------------------------------------------------------\r\nAssertion::Assertion():\r\nNameGroup(),\r\nassert_()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Assertion::Assertion()\r\n//-----------------------------------------------------------------------------\r\nAssertion::Assertion(const Assertion& other):\r\nNameGroup(other),\r\nassert_(other.assert_)\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Assertion::~Assertion()\r\n//-----------------------------------------------------------------------------\r\nAssertion::~Assertion()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Assertion::getAssert()\r\n//-----------------------------------------------------------------------------\r\nQString Assertion::getAssert() const\r\n{\r\n    return assert_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Assertion::setAssert()\r\n//-----------------------------------------------------------------------------\r\nvoid Assertion::setAssert(QString const& newAssert)\r\n{\r\n    assert_ = newAssert;\r\n}"
  },
  {
    "path": "IPXACTmodels/common/Assertion.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: Assertion.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 05.08.2015\r\n//\r\n// Description:\r\n// Matches the ipxact:assertion element.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef ASSERTION_H\r\n#define ASSERTION_H\r\n\r\n#include <IPXACTmodels/common/NameGroup.h>\r\n\r\n#include <IPXACTmodels/ipxactmodels_global.h>\r\n\r\n#include <QString>\r\n#include <QMap>\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Matches the ipxact:assertion element.\r\n//-----------------------------------------------------------------------------\r\nclass IPXACTMODELS_EXPORT Assertion : public NameGroup\r\n{\r\npublic:\r\n\r\n    /*!\r\n     *  The constructor.\r\n     */\r\n    Assertion();\r\n\r\n    /*!\r\n     *  Copy constructor.\r\n     */\r\n    Assertion(const Assertion& other);\r\n\r\n    /*!\r\n     *  The destructor.\r\n     */\r\n    ~Assertion();\r\n\r\n    /*!\r\n     *  Get the assert associated with this assertion.\r\n     *\r\n     *    @return The assert.\r\n     */\r\n    QString getAssert() const;\r\n\r\n    /*!\r\n     *  Set the assert associated with this assertion.\r\n     *\r\n     *    @param [in] newAssert   The new assert value.\r\n     */\r\n    void setAssert(QString const& newAssert);\r\n\r\nprivate:\r\n\r\n    //! The assert value. Expression that is expected to evaluate to true.\r\n    QString assert_;\r\n\r\n};\r\n\r\n#endif // ASSERTION_H\r\n"
  },
  {
    "path": "IPXACTmodels/common/BooleanValue.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: BooleanValue.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Esko Pekkarinen\r\n// Date: 05.08.2015\r\n//\r\n// Description:\r\n// <Short description of the class/file contents>\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"BooleanValue.h\"\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BooleanValue::BooleanValue()\r\n//-----------------------------------------------------------------------------\r\nBooleanValue::BooleanValue() : value_(BOOL_UNSPECIFIED)\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BooleanValue::BooleanValue()\r\n//-----------------------------------------------------------------------------\r\nBooleanValue::BooleanValue(BooleanValue const& other) :\r\n    value_(other.value_)\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BooleanValue::~BooleanValue()\r\n//-----------------------------------------------------------------------------\r\nBooleanValue::~BooleanValue()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BooleanValue::operator=()\r\n//-----------------------------------------------------------------------------\r\nBooleanValue& BooleanValue::operator=(BooleanValue const& other)\r\n{\r\n    if (this != &other)\r\n    {\r\n        value_ = other.value_;\r\n    }\r\n    return *this;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BooleanValue::setValue()\r\n//-----------------------------------------------------------------------------\r\nvoid BooleanValue::setValue(bool value)\r\n{\r\n    if (value)\r\n    {\r\n        value_ = BOOL_TRUE;\r\n    }\r\n    else\r\n    {\r\n        value_ = BOOL_FALSE;\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BooleanValue::toBool()\r\n//-----------------------------------------------------------------------------\r\nbool BooleanValue::toBool() const\r\n{\r\n    if (value_ == BOOL_TRUE)\r\n    {\r\n        return true;\r\n    }\r\n    else\r\n    {\r\n        return false;\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BooleanValue::toString()\r\n//-----------------------------------------------------------------------------\r\nQString BooleanValue::toString() const\r\n{\r\n    if (value_ == BOOL_TRUE)\r\n    {\r\n        return QStringLiteral(\"true\");\r\n    }\r\n    else if (value_ == BOOL_FALSE)\r\n    {\r\n        return QStringLiteral(\"false\");\r\n    }\r\n    else\r\n    {\r\n        return QString();\r\n    }    \r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BooleanValue::setUnspecified()\r\n//-----------------------------------------------------------------------------\r\nvoid BooleanValue::setUnspecified()\r\n{\r\n    value_ = BOOL_UNSPECIFIED;\r\n}"
  },
  {
    "path": "IPXACTmodels/common/BooleanValue.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: BooleanValue.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Esko Pekkarinen\r\n// Date: 05.08.2015\r\n//\r\n// Description:\r\n// Kactus2 vendor extension for a boolean value, that can contain an unspecified value.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef BOOLEANVALUE_H\r\n#define BOOLEANVALUE_H\r\n\r\n#include <QString>\r\n\r\n#include <IPXACTmodels/ipxactmodels_global.h>\r\n\r\nclass IPXACTMODELS_EXPORT BooleanValue \r\n{\r\npublic:\r\n\r\n\t//! The constructor.\r\n\tBooleanValue();\r\n\r\n    //! Copy constructor.\r\n    BooleanValue(BooleanValue const& other);\r\n\r\n\t//! The destructor.\r\n\t~BooleanValue();\r\n\r\n    //! Assignment operator.\r\n    BooleanValue& operator=(BooleanValue const& other);\r\n\r\n    /*!\r\n     *  Set a boolean value.\r\n     *\r\n     *    @param [in] value   The new boolean value.\r\n     */\r\n    void setValue(bool value);\r\n\r\n    /*!\r\n     *  Get the contained value as a boolean value.\r\n     *\r\n     *    @return True for a BOOL_TRUE, otherwise false. \r\n     */\r\n    bool toBool() const;\r\n\r\n    /*!\r\n     *  Gets the value as a string.\r\n     *\r\n     *    @return String of the given value.\r\n     */\r\n    QString toString() const;\r\n\r\n    /*!\r\n     *  Set the value to unspecified.\r\n     */\r\n    void setUnspecified();\r\n\r\nprivate:\r\n\r\n    // Possible boolean values including unspecified.\r\n    enum Boolean {\r\n        BOOL_TRUE,\r\n        BOOL_FALSE,\r\n        BOOL_UNSPECIFIED\r\n    };\r\n\r\n    //! The containing value.\r\n    Boolean value_;\r\n};\r\n\r\n#endif // BOOLEANVALUE_H\r\n"
  },
  {
    "path": "IPXACTmodels/common/BuildModel.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: BuildModel.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 08.09.2015\r\n//\r\n// Description:\r\n// Base class for file builder.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"BuildModel.h\"\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BuildModel::BuildModel()\r\n//-----------------------------------------------------------------------------\r\nBuildModel::BuildModel()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BuildModel::BuildModel()\r\n//-----------------------------------------------------------------------------\r\nBuildModel::BuildModel( const BuildModel &other ):\r\ncommand_(other.command_),\r\nflags_(other.flags_),\r\nreplaceDefaultFlags_(other.replaceDefaultFlags_)\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BuildModel::operator=()\r\n//-----------------------------------------------------------------------------\r\nBuildModel & BuildModel::operator=( const BuildModel &other )\r\n{\r\n\tif (this != &other)\r\n    {\r\n\t\tcommand_ = other.command_;\r\n\t\tflags_ = other.flags_;\r\n\t\treplaceDefaultFlags_ = other.replaceDefaultFlags_;\r\n\t}\r\n\treturn *this;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BuildModel::~BuildModel()\r\n//-----------------------------------------------------------------------------\r\nBuildModel::~BuildModel()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BuildModel::getCommand()\r\n//-----------------------------------------------------------------------------\r\nQString BuildModel::getCommand() const\r\n{\r\n    return command_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BuildModel::getFlags()\r\n//-----------------------------------------------------------------------------\r\nQString BuildModel::getFlags() const\r\n{\r\n    return flags_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BuildModel::getReplaceDefaultFlags()\r\n//-----------------------------------------------------------------------------\r\nQString BuildModel::getReplaceDefaultFlags() const\r\n{\r\n    return replaceDefaultFlags_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BuildModel::setCommand()\r\n//-----------------------------------------------------------------------------\r\nvoid BuildModel::setCommand(const QString &command)\r\n{\r\n    command_ = command;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BuildModel::setFlags()\r\n//-----------------------------------------------------------------------------\r\nvoid BuildModel::setFlags(const QString &flags)\r\n{\r\n    flags_ = flags;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BuildModel::setReplaceDefaultFlags()\r\n//-----------------------------------------------------------------------------\r\nvoid BuildModel::setReplaceDefaultFlags(QString const& newReplaceDefaultFlags)\r\n{\r\n    replaceDefaultFlags_ = newReplaceDefaultFlags;\r\n}\r\n"
  },
  {
    "path": "IPXACTmodels/common/BuildModel.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: BuildModel.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 08.09.2015\r\n//\r\n// Description:\r\n// Base class for file builder.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef BUILDMODEL_H\r\n#define BUILDMODEL_H\r\n\r\n#include <IPXACTmodels/ipxactmodels_global.h>\r\n\r\n#include <QMap>\r\n#include <QString>\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Base class for file builder.\r\n//-----------------------------------------------------------------------------\r\nclass IPXACTMODELS_EXPORT BuildModel\r\n{\r\n\r\npublic:\r\n\r\n\t/*!\r\n\t *  The constructor.\r\n\t */\r\n\tBuildModel();\r\n\r\n\t/*!\r\n\t *  Copy constructor.\r\n\t */\r\n\tBuildModel(const BuildModel &other);\r\n\r\n\t/*!\r\n\t *  Assignment operator.\r\n\t */\r\n\tBuildModel &operator=(const BuildModel &other);\r\n\r\n\t/*!\r\n\t *  The destructor.\r\n\t */\r\n\tvirtual ~BuildModel();\r\n\r\n    /*!\r\n     *  Get the command.\r\n     *\r\n     *    @return The command.\r\n     */\r\n    QString getCommand() const;\r\n\r\n    /*!\r\n     *  Get the flags.\r\n     *\r\n     *    @return The flags.\r\n     */\r\n    QString getFlags() const;\r\n\r\n    /*!\r\n     *  Get the replace default flags expression.\r\n     *\r\n     *    @return An expression determining should the default flags be replaced or not.\r\n     */\r\n    QString getReplaceDefaultFlags() const;\r\n\r\n    /*!\r\n     *  Set the command.\r\n     *\r\n     *    @param [in] newCommand  The new command.\r\n     */\r\n    void setCommand(QString const& newCommand);\r\n\r\n    /*!\r\n     *  Set the flags.\r\n     *\r\n     *    @param [in] newFlags    The new flags.\r\n     */\r\n    void setFlags(QString const& newFlags);\r\n\r\n    /*!\r\n     *  Set the expression for default flags replacement.\r\n     *\r\n     *    @param [in] newReplaceDefaultFlags  The new replacing expression.\r\n     */\r\n    void setReplaceDefaultFlags(QString const& newReplaceDefaultFlags);\r\n\r\nprivate:\r\n\r\n    //! Defines a compiler or assembler tool for processing files.\r\n\tQString command_;\r\n\r\n    //! Documents flags to be passed along with the software tool.\r\n\tQString flags_;\r\n\r\n    //! Indicates the replacing of default flags.\r\n    QString replaceDefaultFlags_;\r\n};\r\n\r\n#endif // BUILDMODEL_H\r\n"
  },
  {
    "path": "IPXACTmodels/common/CellSpecification.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: CellSpecification.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Esko Pekkarinen\r\n// Date: 13.08.2015\r\n//\r\n// Description:\r\n// Implementation for ipxact:cellSpecification.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"CellSpecification.h\"\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: CellSpecification::CellSpecification()\r\n//-----------------------------------------------------------------------------\r\nCellSpecification::CellSpecification() : cellStrength_(UNKNOWN), function_(), cellClass_(NO_CLASS)\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: CellSpecification::CellSpecification()\r\n//-----------------------------------------------------------------------------\r\nCellSpecification::CellSpecification(CellSpecification const& other) :\r\ncellStrength_(other.cellStrength_),\r\n    function_(other.function_),\r\n    cellClass_(other.cellClass_)\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: CellSpecification::~CellSpecification()\r\n//-----------------------------------------------------------------------------\r\nCellSpecification::~CellSpecification()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: CellSpecification::setCellStrength()\r\n//-----------------------------------------------------------------------------\r\nvoid CellSpecification::setCellStrength(CellStrengthType strength)\r\n{\r\n    cellStrength_ = strength;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: CellSpecification::getCellStrength()\r\n//-----------------------------------------------------------------------------\r\nCellSpecification::CellStrengthType CellSpecification::getCellStrength() const\r\n{\r\n    return cellStrength_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: CellSpecification::setCellFunction()\r\n//-----------------------------------------------------------------------------\r\nvoid CellSpecification::setCellFunction(QString const& function)\r\n{\r\n    cellClass_ = NO_CLASS;\r\n    function_ = function;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: CellSpecification::getCellFunction()\r\n//-----------------------------------------------------------------------------\r\nQString CellSpecification::getCellFunction() const\r\n{\r\n    return function_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: CellSpecification::setCellClass()\r\n//-----------------------------------------------------------------------------\r\nvoid CellSpecification::setCellClass(CellClassType cellClass)\r\n{\r\n    function_.clear();\r\n    cellClass_ = cellClass;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: CellSpecification::getCellClass()\r\n//-----------------------------------------------------------------------------\r\nCellSpecification::CellClassType CellSpecification::getCellClass() const\r\n{\r\n    return cellClass_;\r\n}\r\n"
  },
  {
    "path": "IPXACTmodels/common/CellSpecification.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: CellSpecification.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Esko Pekkarinen\r\n// Date: 13.08.2015\r\n//\r\n// Description:\r\n// Implementation for ipxact:cellSpecification.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef CELLSPECIFICATION_H\r\n#define CELLSPECIFICATION_H\r\n\r\n#include <IPXACTmodels/ipxactmodels_global.h>\r\n\r\n#include <QString>\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Implementation for ipxact:cellSpecification.\r\n//-----------------------------------------------------------------------------\r\nclass IPXACTMODELS_EXPORT CellSpecification\r\n{\r\npublic:\r\n\r\n    //! Possible values for cell strength.\r\n    enum CellStrengthType\r\n    {\r\n        LOW = 0,\r\n        MEDIAN,\r\n        HIGH,\r\n        UNKNOWN\r\n    };\r\n\r\n    //! Possible values for cell class.\r\n    enum CellClassType\r\n    {\r\n        COMBINATORIAL = 0,\r\n        SEQUENTIAL,\r\n        NO_CLASS\r\n    };\r\n\r\n    //! The constructor.\r\n    CellSpecification();\r\n\r\n    //! The copy constructor.\r\n    CellSpecification(CellSpecification const& other);\r\n\r\n    //! The destructor.\r\n    ~CellSpecification();\r\n        \r\n    /*!\r\n     *  Sets the cell strength.\r\n     *\r\n     *    @param [in] strength   The strength to set.\r\n     */\r\n    void setCellStrength(CellStrengthType strength);\r\n        \r\n    /*!\r\n     *  Gets the cell strength.\r\n     *\r\n     *    @return The cell strength.\r\n     */\r\n    CellStrengthType getCellStrength() const;\r\n            \r\n    /*!\r\n     *  Sets the cell function.\r\n     *\r\n     *    @param [in] function   The function to set.\r\n     */\r\n    void setCellFunction(QString const& function);\r\n            \r\n    /*!\r\n     *  Gets the cell function.\r\n     *\r\n     *    @return The cell function.\r\n     */\r\n    QString getCellFunction() const;\r\n                \r\n    /*!\r\n     *  Sets the cell class.\r\n     *\r\n     *    @param [in] cellClass   The class to set.\r\n     */\r\n    void setCellClass(CellClassType cellClass);\r\n                \r\n    /*!\r\n     *  Gets the cell class.\r\n     *\r\n     *    @return The cell class.\r\n     */\r\n    CellClassType getCellClass() const;\r\n\r\nprivate:\r\n    // Disable assignment.\r\n    CellSpecification& operator=(CellSpecification const& rhs);\r\n\r\n    //! The cell strength.\r\n    CellStrengthType cellStrength_;\r\n\r\n    //! The cell function.\r\n    QString function_;\r\n\r\n    //! The cell class.\r\n    CellClassType cellClass_;\r\n\r\n};\r\n\r\n#endif // CELLSPECIFICATION_H\r\n"
  },
  {
    "path": "IPXACTmodels/common/Choice.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: choice.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Antti Kamppi\n// Date: 15.10.2010\n//\n// Description:\n// Equals the ipxact:choice element in IP-Xact specification.\n//-----------------------------------------------------------------------------\n\n#include \"Choice.h\"\n\n#include <IPXACTmodels/common/Enumeration.h>\n\n#include <QList>\n#include <QString>\n\n//-----------------------------------------------------------------------------\n// Function: Choice::Choice()\n//-----------------------------------------------------------------------------\nChoice::Choice():\nchoiceName_(),\nenumerations_(new QList<QSharedPointer<Enumeration> >())\n{\n    \n}\n\n//-----------------------------------------------------------------------------\n// Function: Choice::Choice()\n//-----------------------------------------------------------------------------\nChoice::Choice( const Choice& other ):\nchoiceName_(other.choiceName_),\nenumerations_(new QList<QSharedPointer<Enumeration> >())\n{\n    foreach (QSharedPointer<Enumeration> enumeration, *other.enumerations_)\n    {\n        QSharedPointer<Enumeration> copy(new Enumeration(*enumeration));\n        enumerations_->append(copy);\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: Choice::operator=()\n//-----------------------------------------------------------------------------\nChoice& Choice::operator=( const Choice& other )\n{\n\tif (this != &other)\n    {\n\t\tchoiceName_ = other.choiceName_;\n\t\t\n        enumerations_->clear();\n        foreach (QSharedPointer<Enumeration> enumeration, *other.enumerations_)\n        {\n            QSharedPointer<Enumeration> copy(new Enumeration(*enumeration));\n            enumerations_->append(copy);\n        }\n\t}\n\treturn *this;\n}\n\n//-----------------------------------------------------------------------------\n// Function: Choice::~Choice()\n//-----------------------------------------------------------------------------\nChoice::~Choice()\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: Choice::name()\n//-----------------------------------------------------------------------------\nQString Choice::name() const\n{\n\treturn choiceName_;\n}\n\n//-----------------------------------------------------------------------------\n// Function: Choice::setName()\n//-----------------------------------------------------------------------------\nvoid Choice::setName(const QString& name)\n{\n\tchoiceName_ = name;\n}\n\n//-----------------------------------------------------------------------------\n// Function: Choice::hasEnumeration()\n//-----------------------------------------------------------------------------\nbool Choice::hasEnumeration(QString const& enumerationValue) const\n{\n    foreach (QSharedPointer<Enumeration> enumeration, *enumerations_)\n    {\n        if (enumeration->getValue() == enumerationValue)\n        {\n            return true;\n        }\n    }\n\n    return false;\n}\n\n//-----------------------------------------------------------------------------\n// Function: Choice::enumerationCount()\n//-----------------------------------------------------------------------------\nQStringList Choice::getEnumerationValues() const\n{\n    QStringList enumerationValues;\n\n    foreach (QSharedPointer<Enumeration> enumeration, *enumerations_)\n    {\n        if (!enumeration->getText().isEmpty())\n        {\n            enumerationValues.append(enumeration->getText());\n        }\n        else\n        {\n            enumerationValues.append(enumeration->getValue());\n        }\n    }\n\n    return enumerationValues;\n}\n\n//-----------------------------------------------------------------------------\n// Function: Choice::enumerations()\n//-----------------------------------------------------------------------------\nQSharedPointer<QList<QSharedPointer<Enumeration> > > Choice::enumerations() const\n{\n    return enumerations_;\n}\n"
  },
  {
    "path": "IPXACTmodels/common/Choice.h",
    "content": "//-----------------------------------------------------------------------------\n// File: choice.h\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Antti Kamppi\n// Date: 15.10.2010\n//\n// Description:\n// Equals the ipxact:choice element in IP-Xact specification.\n// Choice contains the name of the choice and the enumerations defined in it.\n//-----------------------------------------------------------------------------\n\n#ifndef CHOICE_H_\n#define CHOICE_H_\n\n#include <IPXACTmodels/ipxactmodels_global.h>\n#include <IPXACTmodels/common/Enumeration.h>\n\n#include <QSharedPointer>\n#include <QString>\n#include <QStringList>\n#include <QList>\n\n//-----------------------------------------------------------------------------\n//! Equals the ipxact:choice element in IP-Xact specification.\n//-----------------------------------------------------------------------------\nclass IPXACTMODELS_EXPORT Choice\n{\n\npublic:\n\n\t//! The default constructor.\n\tChoice();\n\n\t//! Copy constructor\n\tChoice(const Choice& other);\n\n\t//! Assignment operator\n\tChoice& operator=(const Choice& other);\n\n\t//! The destructor\n\tvirtual ~Choice();\n\n\t/*!\n     *  Get the name of the choice.\n\t *\n\t *    @return QString containing the name.\n\t */\n\tQString name() const;\n\n\t/*!\n     *  Set the name of the choice.\n\t *\n\t *    @param [in] name QString containing the name.\n\t */\n\tvoid setName(const QString& name);\n    \n    /*!\n     *  Finds if the choice has an enumeration with the given value.\n     *\n     *    @param [in] enumerationValue   The enumeration value to search for.\n     *\n     *    @return True, if the choice has an enumeration with the given value, otherwise false.\n     */\n    bool hasEnumeration(QString const& enumerationValue) const;\n\n    /*!\n     *  Gets the enumeration values of the choice. If a text has been specified for the enumeration,\n     *  it is returned instead of the value.\n     *\n     *    @return The enumeration values.\n     */\n    QStringList getEnumerationValues() const;\n\n    /*!\n     *  Get the enumerations of the choice.\n     *\n     *    @return The enumerations of the choice.\n     */\n    QSharedPointer<QList<QSharedPointer<Enumeration> > > enumerations() const;\n\nprivate:\n\n\t//! Name of the Choice element\n\tQString choiceName_;\n\n\t//! List of enumerations attached to the choice.\n\tQSharedPointer<QList<QSharedPointer<Enumeration> > > enumerations_;\n\n};\n\n#endif /* CHOICE_H_ */\n"
  },
  {
    "path": "IPXACTmodels/common/ChoiceReader.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: ChoiceReader.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Janne Virtanen\n// Date: 21.09.2015\n//\n// Description:\n// Reader class for IP-XACT Choice element.\n//-----------------------------------------------------------------------------\n\n#include \"ChoiceReader.h\"\n\n//-----------------------------------------------------------------------------\n// Function: ChoiceReader::createChoiceFrom()\n//-----------------------------------------------------------------------------\nQSharedPointer<Choice> ChoiceReader::createChoiceFrom(QDomNode const& choiceNode) const\n{\n\t// Create the new CPU.\n\tQSharedPointer<Choice> newChoice (new Choice());\n\n\tQDomNodeList children = choiceNode.childNodes();\n\n\tconst auto CHILD_COUNT = children.size();\n\tfor (int i = 0; i < CHILD_COUNT; ++i)\n    {\n        const QDomNode currentNode = children.at(i);\n\t\t// Get the name,\n\t\tif (currentNode.nodeName() == QLatin1String(\"ipxact:name\"))\n\t\t{\n\t\t\tQString choiceName = currentNode.childNodes().at(0).nodeValue();\n\t\t\tnewChoice->setName(choiceName);\n\t\t}\n\n\t\t// Get the enumerations.\n\t\telse if (currentNode.nodeName() == QLatin1String(\"ipxact:enumeration\"))\n\t\t{\n\t\t\tQSharedPointer<Enumeration> enumeration(new Enumeration);\n\n\n\t\t\t// get the name of the enumeration\n\t\t\tenumeration->setValue(currentNode.childNodes().at(0).nodeValue());\n\n\t\t\tQDomNamedNodeMap attributeMap = currentNode.attributes();\n\t\t\tenumeration->setText(attributeMap.namedItem(QStringLiteral(\"text\")).nodeValue());\n\t\t\tenumeration->setHelp(attributeMap.namedItem(QStringLiteral(\"help\")).nodeValue());\n\n\t\t\tnewChoice->enumerations()->append(enumeration);\n\t\t}\n\t}\n\n    return newChoice;\n}\n"
  },
  {
    "path": "IPXACTmodels/common/ChoiceReader.h",
    "content": "//-----------------------------------------------------------------------------\n// File: ChoiceReader.h\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Janne Virtanen\n// Date: 21.09.2015\n//\n// Description:\n// Reader class for IP-XACT Choice element.\n//-----------------------------------------------------------------------------\n\n#ifndef CHOICE_READER_H\n#define CHOICE_READER_H\n\n#include \"Choice.h\"\n\n#include <IPXACTmodels/ipxactmodels_global.h>\n\n#include <QSharedPointer>\n#include <QDomNode>\n\n//-----------------------------------------------------------------------------\n//! Reader class for IP-XACT Choice element.\n//-----------------------------------------------------------------------------\nclass IPXACTMODELS_EXPORT ChoiceReader\n{\n\npublic:\n\n    /*!\n     *  Creates a new Choice from a given Choice node.\n     *\n     *    @param [in] choiceNode    XML description of the choice.\n     */\n    QSharedPointer<Choice> createChoiceFrom(QDomNode const& choiceNode) const;\n\n};\n\n#endif // CHOICE_READER_H\n"
  },
  {
    "path": "IPXACTmodels/common/ChoiceWriter.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: ChoiceWriter.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Anton Hagqvist\n// Date: 19.05.2023\n//\n// Description:\n// Writer for choice element.\n//-----------------------------------------------------------------------------\n\n#include \"ChoiceWriter.h\"\n#include \"CommonItemsWriter.h\"\n\n//-----------------------------------------------------------------------------\n// Function: ChoiceWriter::writeChoice()\n//-----------------------------------------------------------------------------\nvoid ChoiceWriter::writeChoice(QXmlStreamWriter& writer, QSharedPointer<Choice> choice)\n{\n    writer.writeStartElement(QStringLiteral(\"ipxact:choice\"));\n\n    writer.writeTextElement(QStringLiteral(\"ipxact:name\"), choice->name());\n\n    for (auto const& enumeration : *choice->enumerations())\n    {\n        Details::writeEnumeration(writer, enumeration);\n    }\n\n    writer.writeEndElement(); // ipxact:choice\n}\n\n//-----------------------------------------------------------------------------\n// Function: ChoiceWriter::Details::writeEnumeration()\n//-----------------------------------------------------------------------------\nvoid ChoiceWriter::Details::writeEnumeration(QXmlStreamWriter& writer, QSharedPointer<Enumeration> enumeration)\n{\n    writer.writeStartElement(QStringLiteral(\"ipxact:enumeration\"));\n\n    CommonItemsWriter::writeNonEmptyAttribute(writer, QStringLiteral(\"text\"), enumeration->getText());\n\n    CommonItemsWriter::writeNonEmptyAttribute(writer, QStringLiteral(\"help\"), enumeration->getHelp());\n\n    writer.writeCharacters(enumeration->getValue());\n\n    writer.writeEndElement(); // ipxact:enumeration\n}"
  },
  {
    "path": "IPXACTmodels/common/ChoiceWriter.h",
    "content": "//-----------------------------------------------------------------------------\n// File: ChoiceWriter.h\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Anton Hagqvist\n// Date: 19.05.2023\n//\n// Description:\n// Writer for choice element.\n//-----------------------------------------------------------------------------\n\n#ifndef CHOICEWRITER_H\n#define CHOICEWRITER_H\n\n#include <IPXACTmodels/common/Choice.h>\n#include <IPXACTmodels/common/Enumeration.h>\n\n#include <QXmlStreamWriter>\n#include <QSharedPointer>\n\nnamespace ChoiceWriter\n{\n\n    /*\n     *  Writes a single choice to XML. \n     *  \n     *    @param [in] writer    The XML writer.\n     *    @param [in] choice    The choice to be written.\n     */\n    void writeChoice(QXmlStreamWriter& writer, QSharedPointer<Choice> choice);\n\n    namespace Details\n    {\n        /*\n         *  Writes a single choice enumeration to XML.\n         *\n         *    @param [in] writer    The XML writer.\n         *    @param [in] choice    The enumeration to be written.\n         */\n        void writeEnumeration(QXmlStreamWriter& writer, QSharedPointer<Enumeration> enumeration);\n    }\n}\n\n#endif // CHOICEWRITER_H"
  },
  {
    "path": "IPXACTmodels/common/ClockUnit.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ClockUnit.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 13.10.2015\r\n//\r\n// Description:\r\n// Container for a clock unit.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"ClockUnit.h\"\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ClockUnit::ClockUnit()\r\n//-----------------------------------------------------------------------------\r\nClockUnit::ClockUnit(QString const& value) :\r\nvalue_(value)\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ClockUnit::getValue()\r\n//-----------------------------------------------------------------------------\r\nQString ClockUnit::getValue() const\r\n{\r\n    return value_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ClockUnit::setValue()\r\n//-----------------------------------------------------------------------------\r\nvoid ClockUnit::setValue(QString const& newValue)\r\n{\r\n    value_ = newValue;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ClockUnit::getTimeUnit()\r\n//-----------------------------------------------------------------------------\r\nClockUnit::TimeUnit ClockUnit::getTimeUnit() const\r\n{\r\n    return timeUnit_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ClockUnit::setTimeUnit()\r\n//-----------------------------------------------------------------------------\r\nvoid ClockUnit::setTimeUnit(TimeUnit newTimeUnit)\r\n{\r\n    timeUnit_ = newTimeUnit;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ClockUnit::setTimeUnit()\r\n//-----------------------------------------------------------------------------\r\nvoid ClockUnit::setTimeUnit(QString const& newTimeUnit)\r\n{\r\n    if (newTimeUnit == QLatin1String(\"ns\"))\r\n    {\r\n        setTimeUnit(NS);\r\n    }\r\n    else if (newTimeUnit == QLatin1String(\"ps\"))\r\n    {\r\n        setTimeUnit(PS);\r\n    }\r\n    else\r\n    {\r\n        setTimeUnit(TIMEUNIT_UNSPECIFIED);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ClockUnit::timeUnitToString()\r\n//-----------------------------------------------------------------------------\r\nQString ClockUnit::timeUnitToString() const\r\n{\r\n    if (timeUnit_ == NS)\r\n    {\r\n        return QStringLiteral(\"ns\");\r\n    }\r\n    else if (timeUnit_ == PS)\r\n    {\r\n        return QStringLiteral(\"ps\");\r\n    }\r\n    else\r\n    {\r\n        return QString();\r\n    }\r\n}"
  },
  {
    "path": "IPXACTmodels/common/ClockUnit.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ClockUnit.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 13.10.2015\r\n//\r\n// Description:\r\n// Container for a clock unit.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef CLOCKUNIT_H\r\n#define CLOCKUNIT_H\r\n\r\n#include <IPXACTmodels/ipxactmodels_global.h>\r\n\r\n#include <QString>\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Container for a clock unit.\r\n//-----------------------------------------------------------------------------\r\nclass IPXACTMODELS_EXPORT ClockUnit\r\n{\r\npublic:\r\n\r\n    //! Describes the currently selected time units.\r\n    enum TimeUnit\r\n    {\r\n        NS,\r\n        PS,\r\n        TIMEUNIT_UNSPECIFIED\r\n    };\r\n\r\n    /*!\r\n     *  The constructor.\r\n     *\r\n     *    @param [in] value   The contained value.\r\n     */\r\n    explicit ClockUnit(QString const& value = QString());\r\n\r\n    /*!\r\n     *  Get the assigned value.\r\n     *\r\n     *    @return Value of the clock unit.\r\n     */\r\n    QString getValue() const;\r\n\r\n    /*!\r\n     *  Set the value.\r\n     *\r\n     *    @param [in] newValue    The new value to be set.\r\n     */\r\n    void setValue(QString const& newValue);\r\n\r\n    /*!\r\n     *  Get the used time units.\r\n     *\r\n     *    @return The used time unit.\r\n     */\r\n    TimeUnit getTimeUnit() const;\r\n\r\n    /*!\r\n     *  Set a new time unit.\r\n     *\r\n     *    @param [in] newTimeUnit     The new time unit.\r\n     */\r\n    void setTimeUnit(TimeUnit newTimeUnit);\r\n\r\n    /*!\r\n     *  Set a new time unit.\r\n     *\r\n     *    @param [in] newTimeUnit     String form of the new time unit.\r\n     */\r\n    void setTimeUnit(QString const& newTimeUnit);\r\n\r\n    /*!\r\n     *  Change the used time unit to string.\r\n     *\r\n     *    @return String containing the used time unit.\r\n     */\r\n    QString timeUnitToString() const;\r\n\r\nprivate:\r\n\r\n    //! The contained value.\r\n    QString value_;\r\n\r\n    //! The used time unit.\r\n    TimeUnit timeUnit_{ TIMEUNIT_UNSPECIFIED };\r\n};\r\n\r\n#endif // CLOCKUNIT_H\r\n"
  },
  {
    "path": "IPXACTmodels/common/CommonItemsReader.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: CommonItemsReader.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 07.09.2015\r\n//\r\n// Description:\r\n// Reader class for common IP-XACT elements: VLNV, parameters, assertions, vendor extensions and presence.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"CommonItemsReader.h\"\r\n#include \"ParameterReader.h\"\r\n\r\n#include <IPXACTmodels/common/GenericVendorExtension.h>\r\n\r\n#include <IPXACTmodels/common/ChoiceReader.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: CommonItemsReader::CommonItemsReader()\r\n//-----------------------------------------------------------------------------\r\nCommonItemsReader::CommonItemsReader()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: CommonItemsReader::createVLNVFrom()\r\n//-----------------------------------------------------------------------------\r\nVLNV CommonItemsReader::createVLNVFrom(QDomNode const& vlnvNode, VLNV::IPXactType type)\r\n{\r\n    QString vendor = vlnvNode.firstChildElement(QStringLiteral(\"ipxact:vendor\")).firstChild().nodeValue();\r\n    QString library = vlnvNode.firstChildElement(QStringLiteral(\"ipxact:library\")).firstChild().nodeValue();\r\n    QString name = vlnvNode.firstChildElement(QStringLiteral(\"ipxact:name\")).firstChild().nodeValue();\r\n    QString version = vlnvNode.firstChildElement(QStringLiteral(\"ipxact:version\")).firstChild().nodeValue();\r\n    \r\n    return VLNV(type, vendor, library, name, version);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: CommonItemsReader::parseVLNVAttributes()\r\n//-----------------------------------------------------------------------------\r\nVLNV CommonItemsReader::parseVLNVAttributes(QDomNode const& vlnvNode, VLNV::IPXactType vlnvType)\r\n{\r\n    QDomNamedNodeMap attributes = vlnvNode.attributes();\r\n\r\n    VLNV attributedVLNV;\r\n    attributedVLNV.setType(vlnvType);\r\n    attributedVLNV.setVendor(attributes.namedItem(QStringLiteral(\"vendor\")).nodeValue());\r\n    attributedVLNV.setLibrary(attributes.namedItem(QStringLiteral(\"library\")).nodeValue());\r\n    attributedVLNV.setName(attributes.namedItem(QStringLiteral(\"name\")).nodeValue());\r\n    attributedVLNV.setVersion(attributes.namedItem(QStringLiteral(\"version\")).nodeValue());\r\n\r\n    return attributedVLNV;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: CommonItemsReader::parseAndCreateParameters()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<QList<QSharedPointer<Parameter> > > CommonItemsReader::parseAndCreateParameters(\r\n    QDomNode const& itemNode, Document::Revision revision)\r\n{\r\n    QDomNodeList parameterNodeList = itemNode.firstChildElement(QStringLiteral(\"ipxact:parameters\")).childNodes();\r\n    \r\n    QSharedPointer<QList<QSharedPointer<Parameter> > > newParameters (new QList<QSharedPointer<Parameter> > ());\r\n    if (!parameterNodeList.isEmpty())\r\n    {\r\n        int parameterCount = parameterNodeList.count();\r\n        for (int parameterIndex = 0;parameterIndex < parameterCount; parameterIndex++)\r\n        {\r\n            if (parameterNodeList.at(parameterIndex).isComment() == false)\r\n            {\r\n\t\t\t\tnewParameters->append(ParameterReader::createParameterFrom(parameterNodeList.at(parameterIndex), revision));\r\n            }\r\n        }\r\n    }\r\n    return newParameters;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: CommonItemsReader::parseVendorExtensions()\r\n//-----------------------------------------------------------------------------\r\nvoid CommonItemsReader::parseVendorExtensions(QDomNode const& itemNode, QSharedPointer<Extendable> element)\r\n{\r\n    QDomNodeList extensionNodes = itemNode.firstChildElement(QStringLiteral(\"ipxact:vendorExtensions\")).childNodes();\r\n\r\n    int extensionCount = extensionNodes.count();\r\n    for (int i = 0; i < extensionCount; i++)\r\n    {\r\n        QDomNode extensionNode = extensionNodes.at(i);\r\n\r\n        if (!extensionNode.nodeName().startsWith(QStringLiteral(\"kactus2:\")))\r\n        {\r\n            QSharedPointer<VendorExtension> extension(new GenericVendorExtension(extensionNode));\r\n            element->getVendorExtensions()->append(extension);\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: CommonItemsReader::parseConfigurableVLNVReference()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<ConfigurableVLNVReference> CommonItemsReader::parseConfigurableVLNVReference(\r\n    QDomNode const& configurableVLNVNode, VLNV::IPXactType type)\r\n{\r\n    QDomNamedNodeMap attributeMap = configurableVLNVNode.attributes();\r\n\r\n    QString vendor = attributeMap.namedItem(QStringLiteral(\"vendor\")).nodeValue();\r\n    QString library = attributeMap.namedItem(QStringLiteral(\"library\")).nodeValue();\r\n    QString name = attributeMap.namedItem(QStringLiteral(\"name\")).nodeValue();\r\n    QString version = attributeMap.namedItem(QStringLiteral(\"version\")).nodeValue();\r\n\r\n    QSharedPointer<ConfigurableVLNVReference> vlnvReference(\r\n        new ConfigurableVLNVReference(type, vendor, library, name, version));\r\n\r\n    QDomNode configurableElementsNode = configurableVLNVNode.firstChildElement(QStringLiteral(\"ipxact:configurableElementValues\"));\r\n\r\n    QDomNodeList configurableElementNodeList = configurableElementsNode.childNodes();\r\n    for (int i = 0; i < configurableElementNodeList.size(); ++i)\r\n    {\r\n        QSharedPointer<ConfigurableElementValue> newConfigurableElementValue =\r\n            parseConfigurableElementValue(configurableElementNodeList.at(i));\r\n\r\n        vlnvReference->getConfigurableElementValues()->append(newConfigurableElementValue);\r\n    }\r\n\r\n    return vlnvReference;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: CommonItemsReader::parseConfigurableElementValue()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<ConfigurableElementValue> CommonItemsReader::parseConfigurableElementValue(\r\n    QDomNode const& configurableElementNode)\r\n{\r\n    QSharedPointer<ConfigurableElementValue> newConfigurableElementValue (new ConfigurableElementValue());\r\n\r\n    newConfigurableElementValue->setConfigurableValue(configurableElementNode.firstChild().nodeValue());\r\n\r\n    QDomNamedNodeMap attributeMap = configurableElementNode.attributes();\r\n\r\n    for (int i = 0; i < attributeMap.size(); ++i)\r\n    {\r\n        QDomNode attributeItem = attributeMap.item(i);\r\n        newConfigurableElementValue->insertAttribute(\r\n            attributeItem.nodeName(), attributeItem.firstChild().nodeValue());\r\n    }\r\n\r\n    return newConfigurableElementValue;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: CommonItemsReader::parseAttributes()\r\n//-----------------------------------------------------------------------------\r\nQMap<QString, QString> CommonItemsReader::parseAttributes(QDomNode const& attributedNode)\r\n{\r\n    QMap<QString, QString> attributes;\r\n\r\n    QDomNamedNodeMap attributeMap = attributedNode.attributes();\r\n    for (int j = 0; j < attributeMap.size(); ++j)\r\n    {\r\n        QString name = attributeMap.item(j).nodeName();\r\n        QString value = attributeMap.item(j).nodeValue();\r\n        attributes.insert(name, value);\r\n    }\r\n\r\n    return attributes;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: CommonItemsReader::parseIsPresent()\r\n//-----------------------------------------------------------------------------\r\nQString CommonItemsReader::parseIsPresent(QDomElement const& isPresentElement)\r\n{\r\n    if (!isPresentElement.isNull())\r\n    {\r\n        return isPresentElement.firstChild().nodeValue();\r\n    }\r\n\r\n    return QString();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: CommonItemsReader::parsePoint()\r\n//-----------------------------------------------------------------------------\r\nQPointF CommonItemsReader::parsePoint(QDomNode const& node)\r\n{\r\n    int x = node.attributes().namedItem(QStringLiteral(\"x\")).nodeValue().toInt();\r\n    int y = node.attributes().namedItem(QStringLiteral(\"y\")).nodeValue().toInt();\r\n\r\n    return QPointF(x, y);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: CommonItemsReader::parseChoices()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<QList<QSharedPointer<Choice> > > CommonItemsReader::parseChoices(QDomNode const& itemNode)\r\n{\r\n    QDomElement choicesElement = itemNode.firstChildElement(QStringLiteral(\"ipxact:choices\"));\r\n    \r\n    QSharedPointer<QList<QSharedPointer<Choice> > > parsedChoices(new QList<QSharedPointer<Choice> >);\r\n\r\n    if (!choicesElement.isNull())\r\n    {\r\n        ChoiceReader choiceReader;\r\n\r\n        QDomNodeList choiceNodeList = choicesElement.elementsByTagName(QStringLiteral(\"ipxact:choice\"));\r\n        for (int choiceIndex = 0; choiceIndex < choiceNodeList.count(); ++choiceIndex)\r\n        {\r\n            QDomNode choiceNode = choiceNodeList.at(choiceIndex);\r\n            QSharedPointer<Choice> newChoice = choiceReader.createChoiceFrom(choiceNode);\r\n\r\n            parsedChoices->append(newChoice);\r\n        }\r\n    }\r\n\r\n    return parsedChoices;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: CommonItemsReader::parsePartSelect()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<PartSelect> CommonItemsReader::parsePartSelect(QDomNode const& partSelectNode)\r\n{\r\n    QDomNode rangeNode = partSelectNode.firstChildElement(QStringLiteral(\"ipxact:range\"));\r\n\r\n    QString leftRange = rangeNode.firstChildElement(QStringLiteral(\"ipxact:left\")).firstChild().nodeValue();\r\n    QString rightRange = rangeNode.firstChildElement(QStringLiteral(\"ipxact:right\")).firstChild().nodeValue();\r\n\r\n    QSharedPointer<PartSelect> newPartSelect(new PartSelect(leftRange, rightRange));\r\n\r\n    QDomElement indicesNode = partSelectNode.firstChildElement(QStringLiteral(\"ipxact:indices\"));\r\n\r\n    if (!indicesNode.isNull())\r\n    {\r\n        QDomNodeList indexNodes = indicesNode.elementsByTagName(QStringLiteral(\"ipxact:index\"));\r\n        for (int index = 0; index < indexNodes.size(); ++index)\r\n        {\r\n            QDomNode singleIndexNode = indexNodes.at(index);\r\n            QString indexValue = singleIndexNode.firstChild().nodeValue();\r\n\r\n            newPartSelect->getIndices()->append(indexValue);\r\n        }\r\n    }\r\n\r\n    return newPartSelect;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: CommonItemsReader::parseRange()\r\n//-----------------------------------------------------------------------------\r\nRange CommonItemsReader::parseRange(QDomElement const& rangeElement)\r\n{\r\n    return Range(\r\n        rangeElement.firstChildElement(QStringLiteral(\"ipxact:left\")).firstChild().nodeValue(),\r\n        rangeElement.firstChildElement(QStringLiteral(\"ipxact:right\")).firstChild().nodeValue());\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: CommonItemsReader::parseModeReferences()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<QList<QSharedPointer<ModeReference> > > CommonItemsReader::parseModeReferences(QDomNode const& itemNode)\r\n{\r\n    auto modeRefNodes = itemNode.childNodes();\r\n\r\n    QSharedPointer<QList<QSharedPointer<ModeReference> > >modeRefList(new QList<QSharedPointer<ModeReference> >());\r\n\r\n    for (int i = 0; i < modeRefNodes.size(); ++i)\r\n    {\r\n        if (auto const& modeRefNode = modeRefNodes.at(i);\r\n            modeRefNode.nodeName() == QStringLiteral(\"ipxact:modeRef\"))\r\n        {\r\n            QSharedPointer<ModeReference> newModeRef(new ModeReference());\r\n\r\n            newModeRef->setReference(modeRefNode.firstChild().nodeValue());\r\n\r\n            auto const& priority = modeRefNode.attributes().namedItem(QStringLiteral(\"priority\")).nodeValue();\r\n            newModeRef->setPriority(priority.toUInt());\r\n\r\n            modeRefList->append(newModeRef);\r\n        }\r\n    }\r\n\r\n    return modeRefList;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: CommonItemsReader::parseFileSetReferences()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<QList<QSharedPointer<FileSetRef> > > CommonItemsReader::parseFileSetReferences(\r\n    QDomElement const& itemNode, Document::Revision docRevision)\r\n{\r\n    QDomNodeList fileSetReferenceNodeList = itemNode.elementsByTagName(QStringLiteral(\"ipxact:fileSetRef\"));\r\n\r\n    QSharedPointer<QList<QSharedPointer<FileSetRef> > > newFileSetRefList(new QList<QSharedPointer<FileSetRef> >());\r\n\r\n    for (int i = 0; i < fileSetReferenceNodeList.count(); ++i)\r\n    {\r\n        QDomNode fileSetNode = fileSetReferenceNodeList.at(i);\r\n        QString referenceName = fileSetNode.firstChildElement(QStringLiteral(\"ipxact:localName\")).firstChild().nodeValue();\r\n\r\n        QSharedPointer<FileSetRef> newReference(new FileSetRef());\r\n        \r\n        newReference->setReference(referenceName);\r\n\r\n        if (docRevision == Document::Revision::Std14)\r\n        {\r\n            newReference->setIsPresent(\r\n                fileSetNode.firstChildElement(QStringLiteral(\"ipxact:isPresent\")).firstChild().nodeValue());\r\n        }\r\n        else if (docRevision == Document::Revision::Std22)\r\n        {\r\n            parseVendorExtensions(fileSetNode, newReference);\r\n        }\r\n\r\n        newFileSetRefList->append(newReference);\r\n    }\r\n\r\n    return newFileSetRefList;\r\n}\r\n"
  },
  {
    "path": "IPXACTmodels/common/CommonItemsReader.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: CommonItemsReader.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 07.09.2015\r\n//\r\n// Description:\r\n// Reader class for common IP-XACT elements: VLNV, parameters, assertions, vendor extensions and presence.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef COMMONITEMSREADER_H\r\n#define COMMONITEMSREADER_H\r\n\r\n#include <IPXACTmodels/common/VLNV.h>\r\n\r\n#include <IPXACTmodels/common/Assertion.h>\r\n#include <IPXACTmodels/common/ConfigurableElementValue.h>\r\n#include <IPXACTmodels/common/ConfigurableVLNVReference.h>\r\n#include <IPXACTmodels/common/Document.h>\r\n#include <IPXACTmodels/common/Parameter.h>\r\n#include <IPXACTmodels/common/PartSelect.h>\r\n#include <IPXACTmodels/common/Qualifier.h>\r\n\r\n#include <IPXACTmodels/common/Choice.h>\r\n#include <IPXACTmodels/Component/ModeReference.h>\r\n#include <IPXACTmodels/Component/FileSetRef.h>\r\n\r\n#include <QPointF>\r\n#include <QSharedPointer>\r\n#include <QDomNode>\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Reader class for common IP-XACT elements: VLNV, parameters, assertions, vendor extensions and presence.\r\n//-----------------------------------------------------------------------------\r\nclass IPXACTMODELS_EXPORT CommonItemsReader\r\n{\r\npublic:\r\n\r\n    /*!\r\n     *  The constructor.\r\n     */\r\n    CommonItemsReader();\r\n\r\n    /*!\r\n     *  The destructor.\r\n     */\r\n    virtual ~CommonItemsReader() = default;\r\n\r\n    // Disable copying.\r\n    CommonItemsReader(CommonItemsReader const& rhs) = delete;\r\n    CommonItemsReader& operator=(CommonItemsReader const& rhs) = delete;\r\n\r\n    /*!\r\n    *  Parse and create VLNV from XML file.\r\n    *\r\n    *    @param [in] vlnvNode    XML description of the VLNV.\r\n    *    @param [in] type        The type of the VLNV.\r\n    *\r\n    *    @return The new VLNV.\r\n    */\r\n    static VLNV createVLNVFrom(QDomNode const& vlnvNode, VLNV::IPXactType type);\r\n\r\n    /*!\r\n    *  Parses the VLNV from XML to attributes of an element.\r\n    *\r\n    *    @param [in] vlnvNode    The XML description of the VLNV.\r\n    *    @param [in] vlnvType    The type of the VLNV.\r\n    */\r\n    static VLNV parseVLNVAttributes(QDomNode const& vlnvNode, VLNV::IPXactType vlnvType);\r\n\r\n    /*!\r\n     *  Parses and creates parameters from XML.\r\n     *\r\n     *    @param [in] itemNode    XML description of item containing the parameters.\r\n     *    @param [in] revision    The standard revision of the XML document being read.\r\n     *    @return A list of new parameters.\r\n     */\r\n    static QSharedPointer<QList<QSharedPointer<Parameter> > > parseAndCreateParameters\r\n        (QDomNode const& itemNode, Document::Revision revision = Document::Revision::Std14);\r\n\r\n    /*!\r\n     *  Parses the vendor extensions from XML to a document.\r\n     *\r\n     *    @param [in] itemNode    The XML description of the document.\r\n     *    @param [in] element     The object in which the parsed vendor extensions are stored.\r\n     */\r\n    static void parseVendorExtensions(QDomNode const& itemNode, QSharedPointer<Extendable> element);\r\n\r\n    /*!\r\n     *  Parses a configurable VLNV.\r\n     *\r\n     *    @param [in] configurableVLNVNode    The XML description of the configurable VLNV.\r\n     *    @param [in] type                    The type of the configurable VLNV.\r\n     *\r\n     *    @return A VLNV with configurable element values.\r\n     */\r\n    static QSharedPointer<ConfigurableVLNVReference> parseConfigurableVLNVReference(\r\n        QDomNode const& configurableVLNVNode, VLNV::IPXactType type);\r\n\r\n    /*!\r\n     *  Parses a single configurable element value.\r\n     *\r\n     *    @param [in] configurableElementNode     The XML description of the configurable element value.\r\n     *\r\n     *    @return A configurable element value.\r\n     */\r\n    static QSharedPointer<ConfigurableElementValue> parseConfigurableElementValue(\r\n        QDomNode const& configurableElementNode);\r\n\r\n    /*!\r\n     *  Parse attributes of an element.\r\n     *\r\n     *    @param [in] attributedNode The XML node containing the attributes.\r\n     *\r\n     *    @return The parsed attributes.\r\n     */\r\n    static QMap<QString, QString> parseAttributes(QDomNode const& attributedNode);\r\n\r\n    /*!\r\n     *  Parses the isPresent element.\r\n     *\r\n     *    @param [in] isPresentElement    The is present element.\r\n     *\r\n     *    @return A QString containing the isPresent element for the item.\r\n     */\r\n    static QString parseIsPresent(QDomElement const& isPresentElement);\r\n\r\n    static QPointF parsePoint(QDomNode const& node);\r\n    /*!\r\n     *  Parses choices.\r\n     *\r\n     *    @param [in] itemNode        XML description of the IP-XACT element.\r\n     *    @return A list of choices.\r\n     */\r\n    static QSharedPointer<QList<QSharedPointer<Choice> > > parseChoices(QDomNode const& itemNode);\r\n  \r\n\r\n    static QSharedPointer<PartSelect> parsePartSelect(QDomNode const& partSelectNode);\r\n\r\n    static Range parseRange(QDomElement const& rangeElement);\r\n\r\n\r\n    /*!\r\n     *\tParses mode references.\r\n     *  \r\n     *    @param [in] itemNode       XML description of the IP-XACT element.\r\n     *\r\n     * \t    @return A list of parsed mode references.\r\n     */\r\n    static QSharedPointer<QList<QSharedPointer<ModeReference> > > parseModeReferences(QDomNode const& itemNode);\r\n\r\n    /*!\r\n     *\tParse file set references.\r\n     *  \r\n     *    @param [in] itemNode       XML description of the IP-XACT element.\r\n     *    @param [in] docRevision    The IP-XACT standard revision in use.\r\n     *\t    \r\n     * \t    @return A list of parsed file set references.\r\n     */\r\n    static QSharedPointer<QList<QSharedPointer<FileSetRef> > > parseFileSetReferences(QDomElement const& itemNode,\r\n        Document::Revision docRevision);\r\n};\r\n\r\n#endif // DOCUMENTREADER_H"
  },
  {
    "path": "IPXACTmodels/common/CommonItemsWriter.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: CommonItemsWriter.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 07.09.2015\r\n//\r\n// Description:\r\n// Writer class for common IP-XACT elements: VLNV, parameters, assertions, vendor extensions and presence.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"CommonItemsWriter.h\"\r\n#include \"Extendable.h\"\r\n\r\n#include <IPXACTmodels/common/VendorExtension.h>\r\n#include <IPXACTmodels/common/VLNV.h>\r\n#include <IPXACTmodels/common/ChoiceWriter.h>\r\n\r\n#include <IPXACTmodels/common/Choice.h>\r\n#include <IPXACTmodels/Component/ModeReference.h>\r\n#include <IPXACTmodels/Component/FileSetRef.h>\r\n\r\n#include <IPXACTmodels/common/Assertion.h>\r\n#include <IPXACTmodels/common/ConfigurableElementValue.h>\r\n#include <IPXACTmodels/common/ParameterWriter.h>\r\n#include <IPXACTmodels/common/PartSelect.h>\r\n#include <IPXACTmodels/common/Qualifier.h>\r\n\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: CommonItemsWriter::writeVLNVElements()\r\n//-----------------------------------------------------------------------------\r\nvoid CommonItemsWriter::writeVLNVElements(QXmlStreamWriter& writer, VLNV const& vlnv)\r\n{\r\n    writer.writeTextElement(QStringLiteral(\"ipxact:vendor\"), vlnv.getVendor());\r\n    writer.writeTextElement(QStringLiteral(\"ipxact:library\"), vlnv.getLibrary());\r\n    writer.writeTextElement(QStringLiteral(\"ipxact:name\"), vlnv.getName());\r\n    writer.writeTextElement(QStringLiteral(\"ipxact:version\"), vlnv.getVersion());\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: CommonItemsWriter::writeVLNVAttributes()\r\n//-----------------------------------------------------------------------------\r\nvoid CommonItemsWriter::writeVLNVAttributes(QXmlStreamWriter& writer, VLNV const& vlnv)\r\n{\r\n    writer.writeAttribute(QStringLiteral(\"vendor\"), vlnv.getVendor());\r\n    writer.writeAttribute(QStringLiteral(\"library\"), vlnv.getLibrary());\r\n    writer.writeAttribute(QStringLiteral(\"name\"), vlnv.getName());\r\n    writer.writeAttribute(QStringLiteral(\"version\"), vlnv.getVersion());\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: CommonItemsWriter::writeDisplayName()\r\n//-----------------------------------------------------------------------------\r\nvoid CommonItemsWriter::writeDisplayName(QXmlStreamWriter& writer, QString const& displayName)\r\n{\r\n    writeNonEmptyElement(writer, QStringLiteral(\"ipxact:displayName\"), displayName);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: CommonItemsWriter::writeDescription()\r\n//-----------------------------------------------------------------------------\r\nvoid CommonItemsWriter::writeDescription(QXmlStreamWriter& writer, QString const& description)\r\n{\r\n    writeNonEmptyElement(writer, QStringLiteral(\"ipxact:description\"), description);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: CommonItemsWriter::writeShortDescription()\r\n//-----------------------------------------------------------------------------\r\nvoid CommonItemsWriter::writeShortDescription(QXmlStreamWriter& writer, QString const& shortDescription)\r\n{\r\n    writeNonEmptyElement(writer, QStringLiteral(\"ipxact:shortDescription\"), shortDescription);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: CommonItemsWriter::writeChoices()\r\n//-----------------------------------------------------------------------------\r\nvoid CommonItemsWriter::writeChoices(QXmlStreamWriter& writer, QSharedPointer<QList<QSharedPointer<Choice> > > choices)\r\n{\r\n    if (choices->isEmpty())\r\n    {\r\n        return;\r\n    }\r\n    writer.writeStartElement(QStringLiteral(\"ipxact:choices\"));\r\n\r\n    for (auto const& choice : *choices)\r\n    {\r\n        ChoiceWriter::writeChoice(writer, choice);\r\n    }\r\n\r\n    writer.writeEndElement(); // ipxact:choices\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: CommonItemsWriter::writeChoices()\r\n//-----------------------------------------------------------------------------\r\nvoid CommonItemsWriter::writeParameters(QXmlStreamWriter& writer,\r\n    QSharedPointer<QList<QSharedPointer<Parameter> > > parameters, Document::Revision docRevision)\r\n{\r\n    if (!parameters->isEmpty())\r\n    {\r\n        writer.writeStartElement(QStringLiteral(\"ipxact:parameters\"));\r\n\r\n        for (auto const& parameter : *parameters)\r\n        {\r\n            ParameterWriter::writeParameter(writer, parameter, docRevision);\r\n        }\r\n\r\n        writer.writeEndElement(); // ipxact:parameters\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: CommonItemsWriter::writeVendorExtensions()\r\n//-----------------------------------------------------------------------------\r\nvoid CommonItemsWriter::writeVendorExtensions(QXmlStreamWriter& writer, QSharedPointer<Extendable> element)\r\n{\r\n    if (!element->getVendorExtensions()->isEmpty())\r\n    {\r\n        writer.writeStartElement(QStringLiteral(\"ipxact:vendorExtensions\"));\r\n        for (auto const& extension : *element->getVendorExtensions())\r\n        {\r\n            extension->write(writer);\r\n        }\r\n        writer.writeEndElement(); // ipxact:vendorExtensions\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: CommonItemsWriter::writeAttributes()\r\n//-----------------------------------------------------------------------------\r\nvoid CommonItemsWriter::writeAttributes(QXmlStreamWriter& writer, QMap<QString, QString> const& attributes)\r\n{\r\n    for (auto i = attributes.cbegin(); i != attributes.cend(); ++i)\r\n    {\r\n        writer.writeAttribute(i.key(), i.value());\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: CommonItemsWriter::writeIsPresent()\r\n//-----------------------------------------------------------------------------\r\nvoid CommonItemsWriter::writeIsPresent(QXmlStreamWriter& writer, QString const& isPresent)\r\n{\r\n    writeNonEmptyElement(writer, QStringLiteral(\"ipxact:isPresent\"), isPresent);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: CommonItemsWriter::writeConfigurableElementValues()\r\n//-----------------------------------------------------------------------------\r\nvoid CommonItemsWriter::writeConfigurableElementValues(QXmlStreamWriter& writer,\r\n    QSharedPointer<QList<QSharedPointer<ConfigurableElementValue> > > configurableElements)\r\n{\r\n    if (!configurableElements->isEmpty())\r\n    {\r\n        writer.writeStartElement(QStringLiteral(\"ipxact:configurableElementValues\"));\r\n\r\n        for (auto const& element : *configurableElements)\r\n        {\r\n            writer.writeStartElement(QStringLiteral(\"ipxact:configurableElementValue\"));\r\n\r\n            QMapIterator<QString, QString> attributeIterator(element->getAttributes());\r\n            while (attributeIterator.hasNext())\r\n            {\r\n                attributeIterator.next();\r\n                writer.writeAttribute(attributeIterator.key(), attributeIterator.value());\r\n            }\r\n\r\n            writer.writeCharacters(element->getConfigurableValue());\r\n\r\n            writer.writeEndElement(); // ipxact:configurableElementValue\r\n        }\r\n\r\n        writer.writeEndElement(); // ipxact:configurableElementValues\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: CommonItemsWriter::writeNonEmptyElement()\r\n//-----------------------------------------------------------------------------\r\nvoid CommonItemsWriter::writeNonEmptyElement(QXmlStreamWriter& writer, QString const& elementName, QString const& value)\r\n{\r\n    if (!value.isEmpty())\r\n    {\r\n        writer.writeTextElement(elementName, value);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: CommonItemsWriter::writeNonEmptyElement()\r\n//-----------------------------------------------------------------------------\r\nvoid CommonItemsWriter::writeNonEmptyElement(QXmlStreamWriter& writer, QString const& elementName, std::string const& value)\r\n{\r\n    if (value.empty() == false)\r\n    {\r\n        writer.writeTextElement(elementName, QString::fromStdString(value));\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: CommonItemsWriter::writeNonEmptyAttribute()\r\n//-----------------------------------------------------------------------------\r\nvoid CommonItemsWriter::writeNonEmptyAttribute(QXmlStreamWriter& writer, QString const& attributeName, QString const& value)\r\n{\r\n    if (!value.isEmpty())\r\n    {\r\n        writer.writeAttribute(attributeName, value);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: CommonItemsWriter::writeNonEmptyAttribute()\r\n//-----------------------------------------------------------------------------\r\nvoid CommonItemsWriter::writeNonEmptyAttribute(QXmlStreamWriter& writer, QString const& attributeName, std::string const& value)\r\n{\r\n    if (!value.empty())\r\n    {\r\n        writer.writeAttribute(attributeName, QString::fromStdString(value));\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: CommonItemsWriter::writePartSelect()\r\n//-----------------------------------------------------------------------------\r\nvoid CommonItemsWriter::writePartSelect(QXmlStreamWriter& writer, QSharedPointer<PartSelect> partSelect)\r\n{\r\n    if (partSelect.isNull())\r\n    {\r\n        return;\r\n    }\r\n\r\n    writer.writeStartElement(QStringLiteral(\"ipxact:partSelect\"));\r\n\r\n    writeRange(writer, partSelect->getRange());\r\n\r\n\r\n    // Write all indices of the part select.\r\n    if (partSelect->getIndices()->isEmpty() == false)\r\n    {\r\n        writer.writeStartElement(QStringLiteral(\"ipxact:indices\"));\r\n\r\n        for (QString const& index : *partSelect->getIndices())\r\n        {\r\n            writer.writeTextElement(QStringLiteral(\"ipxact:index\"), index);\r\n        }\r\n\r\n        writer.writeEndElement(); // ipxact:indices\r\n    }\r\n\r\n    writer.writeEndElement(); // ipxact:partSelect\r\n}\r\n\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: CommonItemsWriter::writeRange()\r\n//-----------------------------------------------------------------------------\r\nvoid CommonItemsWriter::writeRange(QXmlStreamWriter& writer, Range const& range)\r\n{\r\n    if (range.getLeft().isEmpty() == false || range.getRight().isEmpty() == false)\r\n    {\r\n        writer.writeStartElement(QStringLiteral(\"ipxact:range\"));\r\n        writer.writeTextElement(QStringLiteral(\"ipxact:left\"), range.getLeft());\r\n        writer.writeTextElement(QStringLiteral(\"ipxact:right\"), range.getRight());\r\n        writer.writeEndElement();\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: CommonItemsWriter::writeModeReferences()\r\n//-----------------------------------------------------------------------------\r\nvoid CommonItemsWriter::writeModeReferences(QXmlStreamWriter& writer,\r\n    QSharedPointer<QList<QSharedPointer<ModeReference> > > modeReferences)\r\n{\r\n    if (!modeReferences || modeReferences->isEmpty())\r\n    {\r\n        return;\r\n    }\r\n\r\n    for (auto const& modeRef : *modeReferences)\r\n    {\r\n        writer.writeStartElement(QStringLiteral(\"ipxact:modeRef\"));\r\n        \r\n        writer.writeAttribute(QStringLiteral(\"priority\"), QString::number(modeRef->getPriority()));\r\n\r\n        writer.writeCharacters(modeRef->getReference());\r\n        writer.writeEndElement(); // ipxact:modeRef\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: CommonItemsWriter::writeFileSetReferences()\r\n//-----------------------------------------------------------------------------\r\nvoid CommonItemsWriter::writeFileSetReferences(QXmlStreamWriter& writer, \r\n    QSharedPointer<QList<QSharedPointer<FileSetRef> > > fileSetRefs, Document::Revision docRevision)\r\n{\r\n    for (auto const& fileSetRef : *fileSetRefs)\r\n    {\r\n        writer.writeStartElement(QStringLiteral(\"ipxact:fileSetRef\"));\r\n\r\n        writer.writeTextElement(QStringLiteral(\"ipxact:localName\"), fileSetRef->getReference());\r\n\r\n        if (docRevision == Document::Revision::Std14)\r\n        {\r\n            CommonItemsWriter::writeIsPresent(writer, fileSetRef->getIsPresent());\r\n        }\r\n        else if (docRevision == Document::Revision::Std22)\r\n        {\r\n            CommonItemsWriter::writeVendorExtensions(writer, fileSetRef);\r\n        }\r\n\r\n        writer.writeEndElement(); // ipxact:fileSetRef\r\n    }\r\n}\r\n"
  },
  {
    "path": "IPXACTmodels/common/CommonItemsWriter.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: CommonItemsWriter.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 07.09.2015\r\n//\r\n// Description:\r\n// Writer class for common IP-XACT elements: VLNV, parameters, assertions, vendor extensions and presence.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef COMMONITEMSWRITER_H\r\n#define COMMONITEMSWRITER_H\r\n\r\n#include \"Document.h\"\r\n\r\n#include <QSharedPointer>\r\n#include <QXmlStreamWriter>\r\n\r\nclass Extendable;\r\nclass VendorExtension;\r\nclass VLNV;\r\nclass Parameter;\r\nclass Choice;\r\nclass Assertion;\r\nclass ConfigurableElementValue;\r\nclass NameGroup;\r\nclass PartSelect;\r\nclass ModeReference;\r\nclass FileSetRef;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Writer class for common IP-XACT elements: VLNV, parameters, assertions, vendor extensions and presence.\r\n//-----------------------------------------------------------------------------\r\nclass CommonItemsWriter\r\n{\r\npublic:\r\n\r\n    virtual ~CommonItemsWriter() = default;\r\n\r\n    /*!\r\n     *  Writes the given VLNV as separate elements into XML.\r\n     *\r\n     *    @param [in] writer      The used XML writer.\r\n     *    @param [in] VLNV        The VLNV to write.\r\n     */\r\n    static void writeVLNVElements(QXmlStreamWriter& writer, VLNV const& vlnv);\r\n    \r\n    /*!\r\n     *  Writes the given VLNV as attributes for the current element into XML.\r\n     *\r\n     *    @param [in] writer      The used XML writer.\r\n     *    @param [in] VLNV        The VLNV to write.\r\n     */\r\n    static void writeVLNVAttributes(QXmlStreamWriter& writer, VLNV const& vlnv);\r\n\r\n    /*!\r\n     *  Writes the description for the current element into XML.\r\n     *\r\n     *    @param [in] writer      The used XML writer.\r\n     *    @param [in] VLNV        The VLNV to write.\r\n     */\r\n    static void writeDisplayName(QXmlStreamWriter& writer, QString const& displayName);\r\n\r\n    /*!\r\n     *  Writes the description for the current element into XML.\r\n     *\r\n     *    @param [in] writer      The used XML writer.\r\n     *    @param [in] VLNV        The VLNV to write.\r\n     */\r\n    static void writeDescription(QXmlStreamWriter& writer, QString const& description);\r\n\r\n    /*!\r\n     *  Writes the short description for the current element into XML.\r\n     *\r\n     *    @param [in] writer      The used XML writer.\r\n     *    @param [in] VLNV        The VLNV to write.\r\n     */\r\n    static void writeShortDescription(QXmlStreamWriter& writer, QString const& shortDescription);\r\n\r\n    /*!\r\n     *  Writes the short description for the current element into XML.\r\n     *\r\n     *    @param [in] writer      The used XML writer.\r\n     *    @param [in] VLNV        The VLNV to write.\r\n     */\r\n    static void writeChoices(QXmlStreamWriter& writer, QSharedPointer<QList<QSharedPointer<Choice> > > choices);\r\n\r\n    /*!\r\n     *  Writes the parameters of a given document into XML.\r\n     *\r\n     *    @param [in] writer      The used XML writer.\r\n     *    @param [in] parameters  A list of the parameters to be written.\r\n     *    @param [in] docRevision The document std revision.\r\n     */\r\n    static void writeParameters(QXmlStreamWriter& writer, \r\n        QSharedPointer<QList<QSharedPointer<Parameter> > > parameters,\r\n        Document::Revision docRevision = Document::Revision::Std14);\r\n\r\n    /*!\r\n     *  Writes the vendor extensions of a given element into XML.\r\n     *\r\n     *    @param [in] writer      The XML writer to use.\r\n     *    @param [in] element     The element whose vendor extensions to write.\r\n     */\r\n    static void writeVendorExtensions(QXmlStreamWriter& writer,  QSharedPointer<Extendable> element);\r\n\r\n    /*! Reads the attributes from the QMap and uses writer to write them. The\r\n     *  element to write the attributes to must be opened by the writer before\r\n     *  calling this function.\r\n     *\r\n     *  @param [in] writer      A QXmlStreamWriter instance that has been set up to write a document.\r\n     *  @param [in] attributes  The attributes to be written.\r\n     */\r\n    static void writeAttributes(QXmlStreamWriter& writer, QMap<QString, QString> const& attributes);\r\n\r\n    /*!\r\n     *  Write the isPresent element.\r\n     *\r\n     *    @param [in] writer      The XML writer to use.\r\n     *    @param [in] isPresent   The value for the isPresent element.\r\n     */\r\n    static void writeIsPresent(QXmlStreamWriter& writer, QString const& isPresent);\r\n\r\n    /*!\r\n     *  Write the configurable element values.\r\n     *\r\n     *    @param [in] writer                  The XML writer to use.\r\n     *    @param [in] configurableElements    The configurable elements.\r\n     */\r\n    static void writeConfigurableElementValues(QXmlStreamWriter& writer,\r\n        QSharedPointer<QList<QSharedPointer<ConfigurableElementValue> > > configurableElements);\r\n\r\n    /*!\r\n     * Writes an XML element, if the provided value is not empty.\r\n     *\r\n     *    @param [in] writer        The XML writer to use.\r\n     *    @param [in] elementName   The name of the element.\r\n     *    @param [in] value         The value of the element.\r\n     *\r\n     *    @return \r\n     */\r\n    static void writeNonEmptyElement(QXmlStreamWriter& writer, QString const& elementName, QString const& value);\r\n\r\n    static void writeNonEmptyElement(QXmlStreamWriter& writer, QString const& elementName, std::string const& value);\r\n\r\n    /*!\r\n     * Writes an XML attribute, if the provided value is not empty.\r\n     *\r\n     *    @param [in] writer        The XML writer to use.\r\n     *    @param [in] elementName   The name of the attribute.\r\n     *    @param [in] value         The value of the attribute.\r\n     */\r\n    static void writeNonEmptyAttribute(QXmlStreamWriter& writer, QString const& attributeName, QString const& value);\r\n    \r\n    static void writeNonEmptyAttribute(QXmlStreamWriter& writer, QString const& attributeName, std::string const& value);\r\n\r\n    /*!\r\n     *  Write a part select.\r\n     *\r\n     *    @param [in] writer      The used XML writer.\r\n     *    @param [in] partSelect  The selected part select.\r\n     */\r\n    static void writePartSelect(QXmlStreamWriter& writer, QSharedPointer<PartSelect> partSelect);\r\n\r\n    static void writeRange(QXmlStreamWriter& writer, Range const& range);\r\n\r\n    /*!\r\n     *\tWrite mode references.\r\n     *  \r\n     *    @param [in] writer          The used XML writer.\r\n     *    @param [in] modeReferences  The mode references to write.\r\n     */\r\n    static void writeModeReferences(QXmlStreamWriter& writer, \r\n        QSharedPointer<QList<QSharedPointer<ModeReference> > > modeReferences);\r\n\r\n    /*!\r\n     *\tWrite file set references.\r\n     *  \r\n     *    @param [in] writer          The used XML writer.\r\n     *    @param [in] fileSetRefs     The file set references to write.\r\n     *    @param [in] docRevision     The IP-XACT standard revision in use.\r\n     */\r\n    static void writeFileSetReferences(QXmlStreamWriter& writer,\r\n        QSharedPointer<QList<QSharedPointer<FileSetRef> > > fileSetRefs,\r\n        Document::Revision docRevision);\r\n};\r\n\r\n#endif // DOCUMENTWRITER_H"
  },
  {
    "path": "IPXACTmodels/common/ConfigurableElementValue.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ConfigurableElementValue.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 04.08.2015\r\n//\r\n// Description:\r\n// Matches the ipxact:configurableElementValue.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"ConfigurableElementValue.h\"\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ConfigurableElementValue::ConfigurableElementValue()\r\n//-----------------------------------------------------------------------------\r\nConfigurableElementValue::ConfigurableElementValue():\r\nvalue_(),\r\nattributes_()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ConfigurableElementValue::ConfigurableElementValue()\r\n//-----------------------------------------------------------------------------\r\nConfigurableElementValue::ConfigurableElementValue(QString const& value, QString const& referenceId):\r\nvalue_(value),\r\nattributes_()\r\n{\r\n    setReferenceId(referenceId);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ConfigurableElementValue::ConfigurableElementValue()\r\n//-----------------------------------------------------------------------------\r\nConfigurableElementValue::ConfigurableElementValue(const ConfigurableElementValue& other):\r\nvalue_(other.value_),\r\nattributes_(other.attributes_)\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ConfigurableElementValue::~ConfigurableElementValue()\r\n//-----------------------------------------------------------------------------\r\nConfigurableElementValue::~ConfigurableElementValue()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ConfigurableElementValue::getConfigurableValue()\r\n//-----------------------------------------------------------------------------\r\nQString ConfigurableElementValue::getConfigurableValue() const\r\n{\r\n    return value_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ConfigurableElementValue::setConfigurableValue()\r\n//-----------------------------------------------------------------------------\r\nvoid ConfigurableElementValue::setConfigurableValue(QString const& newConfigurableValue)\r\n{\r\n    value_ = newConfigurableValue;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ConfigurableElementValue::getReferenceId()\r\n//-----------------------------------------------------------------------------\r\nQString ConfigurableElementValue::getReferenceId() const\r\n{\r\n    return attributes_.value(QStringLiteral(\"referenceId\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ConfigurableElementValue::setReferenceId()\r\n//-----------------------------------------------------------------------------\r\nvoid ConfigurableElementValue::setReferenceId(QString const& newReferenceId)\r\n{\r\n    attributes_.insert(QStringLiteral(\"referenceId\"), newReferenceId);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ConfigurableElementValue::getAttributes()\r\n//-----------------------------------------------------------------------------\r\nQMap<QString, QString> ConfigurableElementValue::getAttributes() const\r\n{\r\n    return attributes_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ConfigurableElementValue::insertAttribute()\r\n//-----------------------------------------------------------------------------\r\nvoid ConfigurableElementValue::insertAttribute(QString attributeKey, QString attributeValue)\r\n{\r\n    attributes_.insert(attributeKey, attributeValue);\r\n}"
  },
  {
    "path": "IPXACTmodels/common/ConfigurableElementValue.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ConfigurableElementValue.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 04.08.2015\r\n//\r\n// Description:\r\n// Matches the ipxact:configurableElementValue.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef CONFIGURABLEELEMENTVALUE_H\r\n#define CONFIGURABLEELEMENTVALUE_H\r\n\r\n#include <IPXACTmodels/ipxactmodels_global.h>\r\n\r\n#include <QMap>\r\n#include <QString>\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Matches the ipxact:configurableElementValue.\r\n//-----------------------------------------------------------------------------\r\nclass IPXACTMODELS_EXPORT ConfigurableElementValue\r\n{\r\npublic:\r\n\r\n    /*!\r\n     *  The basic constructor.\r\n     */\r\n    ConfigurableElementValue();\r\n\r\n    /*!\r\n     *  The constructor.\r\n     *\r\n     *    @param [in] value           The value of the configurable element.\r\n     *    @param [in] referenceId     The reference to the id of an element.\r\n     */\r\n    ConfigurableElementValue(QString const& value, QString const& referenceId);\r\n\r\n    /*!\r\n     *  The copy constructor.\r\n     */\r\n    ConfigurableElementValue(const ConfigurableElementValue& other);\r\n\r\n    /*!\r\n     *  The destructor.\r\n     */\r\n    ~ConfigurableElementValue();\r\n\r\n    /*!\r\n     *  Get the configurable value.\r\n     *\r\n     *    @return The configurable value.\r\n     */\r\n    QString getConfigurableValue() const;\r\n\r\n    /*!\r\n     *  Set the configurable value.\r\n     *\r\n     *    @param [in] newConfigurableValue    The new value for the configurable element.\r\n     */\r\n    void setConfigurableValue(QString const& newConfigurableValue);\r\n\r\n    /*!\r\n     *  Get the id of the referenced element.\r\n     *\r\n     *    @return The id of referenced element.\r\n     */\r\n    QString getReferenceId() const;\r\n\r\n    /*!\r\n     *  Set the id of the referenced element.\r\n     *\r\n     *    @param [in] newReferenceId  The id of the new reference.\r\n     */\r\n    void setReferenceId(QString const& newReferenceId);\r\n\r\n    /*!\r\n     *  Get the attributes associated with this configurable element value.\r\n     *\r\n     *    @return A map containing pairs of attribute names and values.\r\n     */\r\n    QMap<QString, QString> getAttributes() const;\r\n\r\n    /*!\r\n     *  Insert an attribute for the configurable element value.\r\n     *\r\n     *    @param [in] attributeKey    The key for the attribute.\r\n     *    @param [in] attributeValue  The value for the attribute.\r\n     */\r\n    void insertAttribute(QString attributeKey, QString attributeValue);\r\n\r\nprivate:\r\n\r\n    //! The value of the element.\r\n    QString value_;\r\n\r\n    //! The attributes of the element.\r\n    QMap<QString, QString> attributes_;\r\n};\r\n\r\n#endif // CONFIGURABLEELEMENTVALUE_H\r\n"
  },
  {
    "path": "IPXACTmodels/common/ConfigurableVLNVReference.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ConfigurableVLNVReference.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 04.08.2015\r\n//\r\n// Description:\r\n// Configurable VLNV reference matching ipxact type configurableLibraryReference.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"ConfigurableVLNVReference.h\"\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ConfigurableVLNVReference::ConfigurableVLNVReference()\r\n//-----------------------------------------------------------------------------\r\nConfigurableVLNVReference::ConfigurableVLNVReference():\r\nVLNV(),\r\nconfigurableElementValues_(new QList<QSharedPointer<ConfigurableElementValue> >)\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ConfigurableVLNVReference::ConfigurableVLNVReferenceCopy()\r\n//-----------------------------------------------------------------------------\r\nConfigurableVLNVReference::ConfigurableVLNVReference(const ConfigurableVLNVReference& other):\r\nVLNV(other),\r\nconfigurableElementValues_(new QList<QSharedPointer<ConfigurableElementValue> >)\r\n{\r\n    for (QSharedPointer<ConfigurableElementValue> configurable : *other.configurableElementValues_)\r\n    {\r\n            auto copy = QSharedPointer<ConfigurableElementValue>(\r\n                new ConfigurableElementValue(configurable->getConfigurableValue(), configurable->getReferenceId()));\r\n            configurableElementValues_->append(copy);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ConfigurableVLNVReference::ConfigurableVLNVReference()\r\n//-----------------------------------------------------------------------------\r\nConfigurableVLNVReference::ConfigurableVLNVReference(const IPXactType& type, const QString& vendor,\r\n    const QString& library, const QString& name, const QString& version):\r\nVLNV(type, vendor, library, name, version),\r\nconfigurableElementValues_(new QList<QSharedPointer<ConfigurableElementValue> >)\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ConfigurableVLNVReference::ConfigurableVLNVReference()\r\n//-----------------------------------------------------------------------------\r\nConfigurableVLNVReference::ConfigurableVLNVReference(const VLNV& configurableVLNV):\r\nVLNV(configurableVLNV),\r\nconfigurableElementValues_(new QList<QSharedPointer<ConfigurableElementValue> > )\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ConfigurableVLNVReference::operator=()\r\n//-----------------------------------------------------------------------------\r\nConfigurableVLNVReference& ConfigurableVLNVReference::operator=(const ConfigurableVLNVReference& other)\r\n{\r\n    if (this != &other)\r\n    {\r\n        VLNV::operator=(other);\r\n\r\n        configurableElementValues_->clear();\r\n        for (QSharedPointer<ConfigurableElementValue> configurable : *other.configurableElementValues_)\r\n        {\r\n            auto copy = QSharedPointer<ConfigurableElementValue>(\r\n                new ConfigurableElementValue(configurable->getConfigurableValue(), configurable->getReferenceId()));\r\n            configurableElementValues_->append(copy);\r\n        }\r\n    }\r\n    return *this;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ConfigurableVLNVReference::setVLNV()\r\n//-----------------------------------------------------------------------------\r\nvoid ConfigurableVLNVReference::setVLNV(VLNV const& vlnv)\r\n{\r\n    VLNV::operator=(vlnv);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ConfigurableVLNVReference::getConfigurableElementValues()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<QList<QSharedPointer<ConfigurableElementValue> > > ConfigurableVLNVReference::\r\n    getConfigurableElementValues()\r\n{\r\n    return configurableElementValues_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ConfigurableVLNVReference::setConfigurableElementValues()\r\n//-----------------------------------------------------------------------------\r\nvoid ConfigurableVLNVReference::setConfigurableElementValues(\r\n    QSharedPointer<QList<QSharedPointer<ConfigurableElementValue> > > newConfigurableElementValues)\r\n{\r\n    configurableElementValues_.clear();\r\n    configurableElementValues_ = newConfigurableElementValues;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ConfigurableVLNVReference::hasConfigurableElementValue()\r\n//-----------------------------------------------------------------------------\r\nbool ConfigurableVLNVReference::hasConfigurableElementValue(QString const& referenceId) const\r\n{\r\n    return std::any_of(configurableElementValues_->cbegin(), configurableElementValues_->cend(),\r\n        [referenceId](auto const& singleElement) { return referenceId.compare(singleElement->getReferenceId()) == 0; });\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ConfigurableVLNVReference::getSingleConfigurableElementValue()\r\n//-----------------------------------------------------------------------------\r\nQString ConfigurableVLNVReference::getSingleConfigurableElementValue(QString const& referenceId) const\r\n{\r\n    auto element = std::find_if(configurableElementValues_->cbegin(), configurableElementValues_->cend(),\r\n        [referenceId](auto const& singleElement) {return referenceId.compare(singleElement->getReferenceId()) == 0; });\r\n\r\n    if (element != configurableElementValues_->cend())\r\n    {\r\n        return (*element)->getConfigurableValue();\r\n    }\r\n\r\n    return QString();\r\n}\r\n"
  },
  {
    "path": "IPXACTmodels/common/ConfigurableVLNVReference.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ConfigurableVLNVReference.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 04.08.2015\r\n//\r\n// Description:\r\n// Configurable VLNV reference matching ipxact type configurableLibraryReference.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef CONFIGURABLEVLNVREFERENCE_H\r\n#define CONFIGURABLEVLNVREFERENCE_H\r\n\r\n#include <IPXACTmodels/common/VLNV.h>\r\n#include <IPXACTmodels/ipxactmodels_global.h>\r\n#include <IPXACTmodels/common/ConfigurableElementValue.h>\r\n\r\n#include <QSharedPointer>\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Configurable VLNV reference matching ipxact type configurableLibraryReference.\r\n//-----------------------------------------------------------------------------\r\nclass IPXACTMODELS_EXPORT ConfigurableVLNVReference : public VLNV\r\n{\r\n\r\npublic:\r\n\r\n    /*!\r\n     *  The constructor.\r\n     */\r\n    ConfigurableVLNVReference();\r\n\r\n    /*!\r\n     *  The copy constructor.\r\n     */\r\n    ConfigurableVLNVReference(const ConfigurableVLNVReference& other);\r\n\r\n    /*!\r\n     *  The constructor.\r\n     *\r\n     *    @param [in] type        The ipxact type.\r\n     *    @param [in] vendor      The vendor.\r\n     *    @param [in] library     The library.\r\n     *    @param [in] name        The name.\r\n     *    @param [in] version     The version.\r\n     */\r\n    ConfigurableVLNVReference(const IPXactType& type, const QString& vendor, const QString& library,\r\n        const QString& name, const QString& version);\r\n\r\n    /*!\r\n     *  Constructor with VLNV information.\r\n     *\r\n     *    @param [in] configurableVLNV    The configurable VLNV.\r\n     */\r\n    ConfigurableVLNVReference(const VLNV& configurableVLNV);\r\n\r\n    /*!\r\n     *  The destructor.\r\n     */\r\n    ~ConfigurableVLNVReference() final {};\r\n\r\n    /*!\r\n     *  Assignment operator.\r\n     */\r\n    ConfigurableVLNVReference& operator=(const ConfigurableVLNVReference& other);\r\n\r\n    /*!\r\n     *  Sets the VLNV reference.\r\n     *\r\n     *    @param [in] vlnv   The VLNV to set.\r\n     */\r\n    void setVLNV(VLNV const& vlnv);\r\n\r\n    /*!\r\n     *  Get the list of configurable element values.\r\n     *\r\n     *    @return A pointer to the list of configurable element values.\r\n     */\r\n    QSharedPointer<QList<QSharedPointer<ConfigurableElementValue> > > getConfigurableElementValues();\r\n\r\n    /*!\r\n     *  Set the configurable element values.\r\n     *\r\n     *    @param [in] newConfigurableElementValues    The new list of configurable element values.\r\n     */\r\n    void setConfigurableElementValues(\r\n        QSharedPointer<QList<QSharedPointer<ConfigurableElementValue> > > newConfigurableElementValues);\r\n\r\n    /*!\r\n     *  Check if the configurable vlnv contains the given configurable element.\r\n     *\r\n     *    @param [in] referenceId     The ID of the configurable element.\r\n     *\r\n     *    @return True, if the configurable element is found, false otherwise.\r\n     */\r\n    bool hasConfigurableElementValue(QString const& referenceId) const;\r\n\r\n    /*!\r\n     *  Get a single configurable element value.\r\n     *\r\n     *    @param [in] referenceId     The id of the configurable element value.\r\n     *\r\n     *    @return The value of the configurable element.\r\n     */\r\n    QString getSingleConfigurableElementValue(QString const& referenceId) const;\r\n    \r\nprivate:\r\n\r\n    //! A list of configurable element values\r\n    QSharedPointer<QList<QSharedPointer<ConfigurableElementValue> > > configurableElementValues_;\r\n};\r\n\r\n#endif // CONFIGURABLEVLNVREFERENCE_H\r\n"
  },
  {
    "path": "IPXACTmodels/common/DirectionTypes.cpp",
    "content": "#include \"DirectionTypes.h\"\r\n#include \"DirectionTypes.h\"\r\n//-----------------------------------------------------------------------------\r\n// File: DirectionTypes.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 11.09.2015\r\n//\r\n// Description:\r\n// Namespace DirectionTypes is used to store functions related to port directions.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"DirectionTypes.h\"\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DirectionTypes::convert2Mirrored()\r\n//-----------------------------------------------------------------------------\r\nDirectionTypes::Direction DirectionTypes::convert2Mirrored(Direction originalDirection )\r\n{\r\n    if (originalDirection == DirectionTypes::IN)\r\n    {\r\n        return DirectionTypes::OUT;\r\n    }\r\n    else if (originalDirection == DirectionTypes::OUT)\r\n    {\r\n        return DirectionTypes::IN;\r\n    }\r\n    else if (originalDirection == DirectionTypes::INOUT)\r\n    {\r\n        return DirectionTypes::INOUT;\r\n    }\r\n    else if (originalDirection == DirectionTypes::DIRECTION_PHANTOM)\r\n    {\r\n        return DirectionTypes::DIRECTION_PHANTOM;\r\n    }\r\n    else\r\n    {\r\n        return DirectionTypes::DIRECTION_INVALID;\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DirectionTypes::str2Direction()\r\n//-----------------------------------------------------------------------------\r\nDirectionTypes::Direction DirectionTypes::str2Direction(QString const& str, DirectionTypes::Direction defaultValue)\r\n{\r\n\tif (str == QStringLiteral(\"in\"))\r\n    {\r\n\t\treturn DirectionTypes::IN;\r\n\t}\r\n\telse if (str == QStringLiteral(\"out\"))\r\n    {\r\n\t\treturn DirectionTypes::OUT;\r\n\t}\r\n\telse if (str == QStringLiteral(\"inout\"))\r\n    {\r\n\t\treturn DirectionTypes::INOUT;\r\n\t}\r\n\telse if (str == QStringLiteral(\"phantom\"))\r\n    {\r\n\t\treturn DirectionTypes::DIRECTION_PHANTOM;\r\n\t}\r\n\telse\r\n    {\r\n        return defaultValue;\r\n\t}\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DirectionTypes::str2Direction()\r\n//-----------------------------------------------------------------------------\r\nDirectionTypes::Direction DirectionTypes::str2Direction(std::string_view str, DirectionTypes::Direction defaultValue )\r\n{\r\n    if (str == \"in\")\r\n    {\r\n        return DirectionTypes::IN;\r\n    }\r\n    else if (str == \"out\")\r\n    {\r\n        return DirectionTypes::OUT;\r\n    }\r\n    else if (str == \"inout\")\r\n    {\r\n        return DirectionTypes::INOUT;\r\n    }\r\n    else if (str == \"phantom\")\r\n    {\r\n        return DirectionTypes::DIRECTION_PHANTOM;\r\n    }\r\n    else\r\n    {\r\n        return defaultValue;\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DirectionTypes::direction2Str()\r\n//-----------------------------------------------------------------------------\r\nQString DirectionTypes::direction2Str(const DirectionTypes::Direction direction)\r\n{\r\n    if (direction == DirectionTypes::IN)\r\n    {\r\n        return QStringLiteral(\"in\");\r\n    }\r\n    else if (direction == DirectionTypes::OUT)\r\n    {\r\n        return QStringLiteral(\"out\");\r\n    }\r\n    else if (direction == DirectionTypes::INOUT)\r\n    {\r\n        return QStringLiteral(\"inout\");\r\n    }\r\n    else if (direction == DirectionTypes::DIRECTION_PHANTOM)\r\n    {\r\n        return QStringLiteral(\"phantom\");\r\n    }\r\n    else\r\n    {\r\n        return QString();\r\n    }\r\n}\r\n"
  },
  {
    "path": "IPXACTmodels/common/DirectionTypes.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: DirectionTypes.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 11.09.2015\r\n//\r\n// Description:\r\n// Namespace DirectionTypes is used to store functions related to port directions.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef DIRECTIONTYPES_H\r\n#define DIRECTIONTYPES_H\r\n\r\n#include <IPXACTmodels/ipxactmodels_global.h>\r\n\r\n#include <QString>\r\n\r\n#include <string>\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Namespace DirectionTypes is used to store functions related to port directions.\r\n//-----------------------------------------------------------------------------\r\nnamespace DirectionTypes\r\n{\r\n    //! Specifies the direction of the port\r\n    enum Direction {\r\n        IN,\r\n        OUT,\r\n        INOUT,\r\n        DIRECTION_PHANTOM,\r\n        DIRECTION_INVALID\r\n    };\r\n\r\n    /*!\r\n     *  Convert the given direction to mirrored.\r\n     *\r\n     *    @param [in] originalDirection   The direction to convert.\r\n     *\r\n     *    @return The mirrored direction.\r\n     */\r\n    IPXACTMODELS_EXPORT DirectionTypes::Direction convert2Mirrored(\r\n         DirectionTypes::Direction originalDirection);\r\n\r\n    /*!\r\n     *  Convert a given qstring to direction.\r\n     *\r\n     *    @param [in] str             The string to be converted.\r\n     *    @param [in] defaultValue    The value that will be returned if no match is found.\r\n     *\r\n     *    @return Direction that matches the string or default value.\r\n     */\r\n    IPXACTMODELS_EXPORT DirectionTypes::Direction str2Direction(\r\n        QString const& str, DirectionTypes::Direction defaultValue = Direction::DIRECTION_INVALID);\r\n\r\n\r\n    IPXACTMODELS_EXPORT DirectionTypes::Direction str2Direction(\r\n        std::string_view str, DirectionTypes::Direction defaultValue = Direction::DIRECTION_INVALID);\r\n\r\n\r\n    /*!\r\n     *  Convert a given direction to a qstring.\r\n     *\r\n     *    @param [in] direction   Direction value to be converted to QString.\r\n     *\r\n     *    @return QString matching the given direction.\r\n     */\r\n    IPXACTMODELS_EXPORT QString direction2Str(const DirectionTypes::Direction direction);\r\n\r\n}\r\n\r\n#endif // DIRECTIONTYPES_H\r\n"
  },
  {
    "path": "IPXACTmodels/common/Document.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: Document.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Esko Pekkarinen\r\n// Date: 05.08.2015\r\n//\r\n// Description:\r\n// Base class for IP-XACT documents e.g. component and design.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"Document.h\"\r\n\r\n#include <IPXACTmodels/common/GenericVendorExtension.h>\r\n#include <IPXACTmodels/common/VLNV.h>\r\n\r\n#include <IPXACTmodels/utilities/Copy.h>\r\n\r\n#include <IPXACTmodels/generaldeclarations.h>\r\n\r\n#include <IPXACTmodels/kactusExtensions/Kactus2Group.h>\r\n\r\n#include <QString>\r\n#include <QSharedPointer>\r\n#include <QObject>\r\n#include <QList>\r\n#include <QStringList>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Document::Document()\r\n//-----------------------------------------------------------------------------\r\nDocument::Document(const VLNV &vlnv, Revision revision):\r\nExtendable(),\r\n    revision_(revision)\r\n{\r\n    documentNameGroup_.vlnv = vlnv;\r\n    addDefaultNameSpaces(revision);\r\n    setSchemaLocation(revision);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Document::Document()\r\n//-----------------------------------------------------------------------------\r\nDocument::Document(Document const& other):\r\nExtendable(other),\r\n    documentNameGroup_(other.documentNameGroup_),\r\n    revision_(other.revision_),\r\n    topComments_(other.topComments_),\r\n    xmlProcessingInstructions_(other.xmlProcessingInstructions_),\r\n    xmlNameSpaces_(other.xmlNameSpaces_),\r\n    xmlSchemaLocation_(other.xmlSchemaLocation_)\r\n{\r\n    Copy::copyList(other.parameters_, parameters_);\r\n    Copy::copyList(other.assertions_, assertions_);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Document::operator=()\r\n//-----------------------------------------------------------------------------\r\nDocument & Document::operator=( const Document &other )\r\n{\r\n\tif (this != &other)\r\n    {\r\n        Extendable::operator=(other);\r\n\r\n        if (!documentNameGroup_.vlnv.isEmpty())\r\n        {\r\n            documentNameGroup_.vlnv = other.documentNameGroup_.vlnv;\r\n        }\r\n\t\telse\r\n        {\r\n            documentNameGroup_.vlnv = VLNV();\r\n        }\r\n\r\n        documentNameGroup_.description = other.documentNameGroup_.description;\r\n\t\ttopComments_ = other.topComments_;\r\n\r\n        xmlProcessingInstructions_ = other.xmlProcessingInstructions_;\r\n        xmlNameSpaces_ = other.xmlNameSpaces_;\r\n        xmlSchemaLocation_ = other.xmlSchemaLocation_;\r\n\r\n        parameters_->clear();\r\n        Copy::copyList(other.parameters_, parameters_);\r\n\r\n        assertions_->clear();\r\n        Copy::copyList(other.assertions_, assertions_);\r\n\r\n\t}\r\n\treturn *this;\r\n}\r\n\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Document::getVlnv()\r\n//-----------------------------------------------------------------------------\r\nVLNV Document::getVlnv() const\r\n{\r\n\treturn documentNameGroup_.vlnv;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Document::setVlnv()\r\n//-----------------------------------------------------------------------------\r\nvoid Document::setVlnv(VLNV const& vlnv)\r\n{\r\n    documentNameGroup_.vlnv = vlnv;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Document::getDisplayName()\r\n//-----------------------------------------------------------------------------\r\nQString Document::getDisplayName() const\r\n{\r\n    return documentNameGroup_.displayName;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Document::setDisplayName()\r\n//-----------------------------------------------------------------------------\r\nvoid Document::setDisplayName(const QString& displayName)\r\n{\r\n    documentNameGroup_.displayName = displayName;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Document::getShortDescription()\r\n//-----------------------------------------------------------------------------\r\nQString Document::getShortDescription() const\r\n{\r\n    return documentNameGroup_.shortDescription;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Document::setShortDescription()\r\n//-----------------------------------------------------------------------------\r\nvoid Document::setShortDescription(const QString& shortDescription)\r\n{\r\n    documentNameGroup_.shortDescription = shortDescription;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Document::getDescription()\r\n//-----------------------------------------------------------------------------\r\nQString Document::getDescription() const\r\n{\r\n    return documentNameGroup_.description;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Document::setDescription()\r\n//-----------------------------------------------------------------------------\r\nvoid Document::setDescription(QString const& description)\r\n{\r\n    documentNameGroup_.description = description;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Document::getParameters()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<QList<QSharedPointer<Parameter> > > Document::getParameters() const\r\n{\r\n    return parameters_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Document::hasParameters()\r\n//-----------------------------------------------------------------------------\r\nbool Document::hasParameters() const\r\n{\r\n    return !parameters_->isEmpty();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignConfiguration::getAssertions()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<QList<QSharedPointer<Assertion> > > Document::getAssertions() const\r\n{\r\n    return assertions_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Document::setTopComments()\r\n//-----------------------------------------------------------------------------\r\nvoid Document::setTopComments(QString const& comment)\r\n{\r\n    topComments_ = comment.split(QLatin1Char('\\n'));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Document::setTopComments()\r\n//-----------------------------------------------------------------------------\r\nvoid Document::setTopComments( const QStringList& comments )\r\n{\r\n    topComments_ = comments;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Document::getTopComments()\r\n//-----------------------------------------------------------------------------\r\nQStringList Document::getTopComments() const\r\n{\r\n    return topComments_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Document::setXmlProcessingInstructions()\r\n//-----------------------------------------------------------------------------\r\nvoid Document::addXmlProcessingInstructions(QString const& target, QString const& data)\r\n{\r\n    xmlProcessingInstructions_.append(qMakePair(target, data));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Document::getXmlProcessingInstructions()\r\n//-----------------------------------------------------------------------------\r\nQVector<QPair<QString, QString> > Document::getXmlProcessingInstructions() const\r\n{\r\n    return xmlProcessingInstructions_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Document::addXmlNameSpace()\r\n//-----------------------------------------------------------------------------\r\nvoid Document::addXmlNameSpace(QString const& nameSpace, QString const& uri)\r\n{\r\n    // Go through all known xml name spaces.\r\n    // Discard the change if it already exists.\r\n    if (std::any_of(xmlNameSpaces_.cbegin(), xmlNameSpaces_.cend(), \r\n        [nameSpace](auto& xmlNameSpace) {return xmlNameSpace.first == nameSpace;}))\r\n    {\r\n        return;\r\n    }\r\n\r\n    // Otherwise append to the list.\r\n    xmlNameSpaces_.append(qMakePair(nameSpace, uri));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Document::getXmlNameSpaces()\r\n//-----------------------------------------------------------------------------\r\nQVector<QPair<QString, QString> > Document::getXmlNameSpaces() const\r\n{\r\n    return xmlNameSpaces_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Document::setSchemaLocation()\r\n//-----------------------------------------------------------------------------\r\nvoid Document::setSchemaLocation(Document::Revision revision)\r\n{\r\n    if (revision == Revision::Std14)\r\n    {\r\n        xmlSchemaLocation_ = QStringLiteral(\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014 http://www.accellera.org/XMLSchema/IPXACT/1685-2014/index.xsd\");\r\n    }\r\n    else if (revision == Revision::Std22)\r\n    {\r\n        xmlSchemaLocation_ = QStringLiteral(\"http://www.accellera.org/XMLSchema/IPXACT/1685-2022 http://www.accellera.org/XMLSchema/IPXACT/1685-2022/index.xsd\");\r\n    }\r\n    else\r\n    {\r\n        xmlSchemaLocation_ = QString();\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Document::getSchemaLocation()\r\n//-----------------------------------------------------------------------------\r\nQString Document::getSchemaLocation() const\r\n{\r\n    return xmlSchemaLocation_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Document::getDependentDirs()\r\n//-----------------------------------------------------------------------------\r\nQStringList Document::getDependentDirs() const\r\n{\r\n    return QStringList();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Document::setVersion()\r\n//-----------------------------------------------------------------------------\r\nvoid Document::setVersion(QString const& versionNumber)\r\n{\r\n    auto extension = findVendorExtension(QStringLiteral(\"kactus2:version\"));\r\n\r\n    if (extension != nullptr)\r\n    {\r\n        extension.dynamicCast<Kactus2Value>()->setValue(versionNumber);\r\n        return;\r\n    }\r\n\r\n    getVendorExtensions()->append(QSharedPointer<Kactus2Value>(new Kactus2Value(QStringLiteral(\"kactus2:version\"),\r\n        versionNumber)));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Document::getVersion()\r\n//-----------------------------------------------------------------------------\r\nQString Document::getVersion() const\r\n{\r\n    auto extension = findVendorExtension(QStringLiteral(\"kactus2:version\"));\r\n\r\n    if (extension != nullptr)\r\n    {\r\n        return extension.dynamicCast<Kactus2Value>()->value();\r\n    }\r\n\r\n    return QString();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Document::hasKactusAttributes()\r\n//-----------------------------------------------------------------------------\r\nbool Document::hasKactusAttributes() const\r\n{\r\n    return std::any_of(getVendorExtensions()->cbegin(), getVendorExtensions()->cend(), \r\n        [](auto& extension) {return extension->type() == QLatin1String(\"kactus2:extensions\"); });\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Document::hasImplementation()\r\n//-----------------------------------------------------------------------------\r\nbool Document::hasImplementation() const\r\n{\r\n    auto extension = findVendorExtension(QStringLiteral(\"kactus2:extensions\"));\r\n\r\n    if (extension != nullptr)\r\n    {\r\n        QSharedPointer<KactusAttribute> attributes = extension.dynamicCast<KactusAttribute>();\r\n        return attributes->getImplementation() != KactusAttribute::KTS_IMPLEMENTATION_COUNT;\r\n    }\r\n\r\n    return false;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Document::setImplementation()\r\n//-----------------------------------------------------------------------------\r\nvoid Document::setImplementation(KactusAttribute::Implementation implementation)\r\n{\r\n    auto extension = findVendorExtension(QStringLiteral(\"kactus2:extensions\"));\r\n\r\n    if (extension != nullptr)\r\n    {\r\n        return extension.dynamicCast<KactusAttribute>()->setImplementation(implementation);\r\n    }\r\n\r\n    QSharedPointer<KactusAttribute> attributes(new KactusAttribute());\r\n    attributes->setImplementation(implementation);\r\n\r\n    getVendorExtensions()->append(attributes);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Document::getImplementation()\r\n//-----------------------------------------------------------------------------\r\nKactusAttribute::Implementation Document::getImplementation() const\r\n{\r\n    auto extension = findVendorExtension(QStringLiteral(\"kactus2:extensions\"));\r\n\r\n    auto implementationType = KactusAttribute::HW;\r\n\r\n    if (extension != nullptr)\r\n    {\r\n        auto readType = extension.dynamicCast<KactusAttribute>()->getImplementation();\r\n\r\n        if (readType != KactusAttribute::KTS_IMPLEMENTATION_COUNT)\r\n        {\r\n            implementationType = readType;\r\n        }\r\n    }\r\n\r\n    return implementationType;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Document::hasProductHierarchy()\r\n//-----------------------------------------------------------------------------\r\nbool Document::hasProductHierarchy() const\r\n{\r\n    auto extension = findVendorExtension(QStringLiteral(\"kactus2:extensions\"));\r\n\r\n    if (extension != nullptr)\r\n    {\r\n        QSharedPointer<KactusAttribute> attributes = extension.dynamicCast<KactusAttribute>();\r\n        return attributes->getHierarchy() != KactusAttribute::KTS_PRODHIER_COUNT;\r\n    }\r\n\r\n    return false;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Document::setHierarchy()\r\n//-----------------------------------------------------------------------------\r\nvoid Document::setHierarchy(KactusAttribute::ProductHierarchy productHierarchy)\r\n{\r\n    auto extension = findVendorExtension(QStringLiteral(\"kactus2:extensions\"));\r\n\r\n    if (extension != nullptr)\r\n    {\r\n        return extension.dynamicCast<KactusAttribute>()->setHierarchy(productHierarchy);\r\n    }\r\n\r\n    QSharedPointer<KactusAttribute> attributes(new KactusAttribute());\r\n    attributes->setHierarchy(productHierarchy);\r\n\r\n    getVendorExtensions()->append(attributes);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Document::getHierarchy()\r\n//-----------------------------------------------------------------------------\r\nKactusAttribute::ProductHierarchy Document::getHierarchy() const\r\n{\r\n    auto extension = findVendorExtension(QStringLiteral(\"kactus2:extensions\"));\r\n\r\n    if (extension != nullptr)\r\n    {\r\n        return extension.dynamicCast<KactusAttribute>()->getHierarchy();\r\n    }\r\n\r\n    return KactusAttribute::FLAT;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Document::hasFirmness()\r\n//-----------------------------------------------------------------------------\r\nbool Document::hasFirmness() const\r\n{\r\n    auto extension = findVendorExtension(QStringLiteral(\"kactus2:extensions\"));\r\n\r\n    if (extension != nullptr)\r\n    {\r\n        QSharedPointer<KactusAttribute> attributes = extension.dynamicCast<KactusAttribute>();\r\n        return attributes->getFirmness() != KactusAttribute::KTS_REUSE_LEVEL_COUNT;\r\n    }\r\n\r\n    return false;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Document::getFirmness()\r\n//-----------------------------------------------------------------------------\r\nKactusAttribute::Firmness Document::getFirmness() const\r\n{\r\n    auto extension = findVendorExtension(QStringLiteral(\"kactus2:extensions\"));\r\n\r\n    if (extension != nullptr)\r\n    {\r\n        QSharedPointer<KactusAttribute> attributes = extension.dynamicCast<KactusAttribute>();\r\n        return attributes->getFirmness();\r\n    }\r\n\r\n    return KactusAttribute::MUTABLE;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Document::setFirmness()\r\n//-----------------------------------------------------------------------------\r\nvoid Document::setFirmness(KactusAttribute::Firmness firmness)\r\n{\r\n    auto extension = findVendorExtension(QStringLiteral(\"kactus2:extensions\"));\r\n\r\n    if (extension != nullptr)\r\n    {\r\n        return extension.dynamicCast<KactusAttribute>()->setFirmness(firmness);\r\n    }\r\n\r\n    QSharedPointer<KactusAttribute> attributes(new KactusAttribute());\r\n    attributes->setFirmness(firmness);\r\n\r\n    getVendorExtensions()->append(attributes);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Document::getLicense()\r\n//-----------------------------------------------------------------------------\r\nQString Document::getLicense() const\r\n{\r\n    auto extension = findVendorExtension(QStringLiteral(\"kactus2:license\"));\r\n\r\n    if (extension != nullptr)\r\n    {\r\n        QSharedPointer<Kactus2Value> licenseExtension = extension.dynamicCast<Kactus2Value>();\r\n        return licenseExtension->value();\r\n    }\r\n\r\n    return QString();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Document::setLicense()\r\n//-----------------------------------------------------------------------------\r\nvoid Document::setLicense(QString const& license)\r\n{\r\n    auto extension = findVendorExtension(QStringLiteral(\"kactus2:license\"));\r\n\r\n    if (extension != nullptr)\r\n    {\r\n        QSharedPointer<Kactus2Value> licenseExtension = extension.dynamicCast<Kactus2Value>();\r\n        licenseExtension->setValue(license);\r\n    }\r\n    else if (license.isEmpty() == false)\r\n    {\r\n        QSharedPointer<Kactus2Value> licenseValue (new Kactus2Value(QStringLiteral(\"kactus2:license\"), license));\r\n        getVendorExtensions()->append(licenseValue);\r\n    }\r\n    else\r\n    {\r\n        getVendorExtensions()->removeAll(extension);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Document::toString()\r\n//-----------------------------------------------------------------------------\r\nQString Document::toString(Revision revision)\r\n{\r\n    if (revision == Revision::Std14)\r\n    {\r\n        return QStringLiteral(\"1685-2014\");\r\n    }\r\n\r\n    if (revision == Revision::Std22)\r\n    {\r\n        return QStringLiteral(\"1685-2022\");\r\n    }\r\n\r\n    return QStringLiteral(\"Unknown\");\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Document::toStdString()\r\n//-----------------------------------------------------------------------------\r\nstd::string Document::toStdString(Revision revision)\r\n{\r\n    return toString(revision).toStdString();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Document::toRevision()\r\n//-----------------------------------------------------------------------------\r\nDocument::Revision Document::toRevision(QString const& revision)\r\n{\r\n    if (revision == QStringLiteral(\"1685-2014\"))\r\n    {\r\n        return Revision::Std14;\r\n    }\r\n\r\n    if (revision == QStringLiteral(\"1685-2022\"))\r\n    {\r\n        return Revision::Std22;\r\n    }\r\n\r\n    return Revision::Unknown;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Document::addDefaultNameSpaces()\r\n//-----------------------------------------------------------------------------\r\nvoid Document::addDefaultNameSpaces(Revision revision)\r\n{\r\n    xmlNameSpaces_.append(qMakePair(QStringLiteral(\"xsi\"), QStringLiteral(\"http://www.w3.org/2001/XMLSchema-instance\")));\r\n\r\n    if (revision == Revision::Std14)\r\n    {\r\n        xmlNameSpaces_.append(qMakePair(QStringLiteral(\"ipxact\"), QStringLiteral(\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014\")));\r\n    }\r\n    else if (revision == Revision::Std22)\r\n    {\r\n\r\n        xmlNameSpaces_.append(qMakePair(QStringLiteral(\"ipxact\"), QStringLiteral(\"http://www.accellera.org/XMLSchema/IPXACT/1685-2022\")));\r\n    }\r\n\r\n    xmlNameSpaces_.append(qMakePair(QStringLiteral(\"kactus2\"), QStringLiteral(\"http://kactus2.cs.tut.fi\")));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Document::getTags()\r\n//-----------------------------------------------------------------------------\r\nQVector<TagData> Document::getTags() const\r\n{\r\n    QSharedPointer<Kactus2Group> tagGroup = getTagGroup();\r\n    if (tagGroup == nullptr)\r\n    {\r\n        return QVector<TagData>();\r\n    }\r\n\r\n    QVector<TagData> documentTags;\r\n    for (auto singleTag : tagGroup->getByType(QLatin1String(\"kactus2:tag\")))\r\n    {\r\n        QSharedPointer<Kactus2Group> tagValue = singleTag.dynamicCast<Kactus2Group>();\r\n        if (tagValue)\r\n        {\r\n            QString newTagName;\r\n            QString newTagColor;\r\n\r\n            QList<QSharedPointer<VendorExtension> > tagNamesExtension =\r\n                tagValue->getByType(QLatin1String(\"kactus2:name\"));\r\n            if (tagNamesExtension.size() == 1)\r\n            {\r\n                QSharedPointer<Kactus2Value> tagName =\r\n                    tagNamesExtension.first().dynamicCast<Kactus2Value>();\r\n                if (tagName)\r\n                {\r\n                    newTagName = tagName->value();\r\n                }\r\n            }\r\n\r\n            QList<QSharedPointer<VendorExtension> > tagColorsExtension =\r\n                tagValue->getByType(QLatin1String(\"kactus2:color\"));\r\n            if (tagColorsExtension.size() == 1)\r\n            {\r\n                QSharedPointer<Kactus2Value> tagColor =\r\n                    tagColorsExtension.first().dynamicCast<Kactus2Value>();\r\n                if (tagColor)\r\n                {\r\n                    newTagColor = tagColor->value();\r\n                }\r\n            }\r\n\r\n            if (!newTagName.isEmpty() && !newTagColor.isEmpty())\r\n            {\r\n                documentTags.append(TagData({ newTagName, newTagColor }));\r\n            }\r\n        }\r\n    }\r\n\r\n    return documentTags;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Document::getTagGroup()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<Kactus2Group> Document::getTagGroup() const\r\n{\r\n    auto extension = findVendorExtension(QStringLiteral(\"kactus2:tags\"));\r\n\r\n    if (extension != nullptr)\r\n    {\r\n        QSharedPointer<Kactus2Group> tagGroup = extension.dynamicCast<Kactus2Group>();\r\n        if (tagGroup)\r\n        {\r\n            return tagGroup;\r\n        }\r\n    }\r\n\r\n    return QSharedPointer<Kactus2Group>();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Document::setTags()\r\n//-----------------------------------------------------------------------------\r\nvoid Document::setTags(QVector<TagData> newTags) const\r\n{\r\n    QSharedPointer<Kactus2Group> tagGroup = getTagGroup();\r\n\r\n    if (tagGroup)\r\n    {\r\n        if (newTags.isEmpty())\r\n        {\r\n            getVendorExtensions()->removeAll(tagGroup);\r\n        }\r\n        else\r\n        {\r\n            removeNonExistingTags(tagGroup, newTags);\r\n        }\r\n    }\r\n    else if (!tagGroup && !newTags.isEmpty())\r\n    {\r\n        tagGroup = QSharedPointer<Kactus2Group>(new Kactus2Group(QLatin1String(\"kactus2:tags\")));\r\n        getVendorExtensions()->append(tagGroup);\r\n    }\r\n\r\n    for (auto const& tag : newTags)\r\n    {\r\n        QSharedPointer<Kactus2Group> existingTag = getTagByName(tag.name_, tagGroup);\r\n        if (existingTag)\r\n        {\r\n            QList<QSharedPointer<VendorExtension> > colorExtension =\r\n                existingTag->getByType(QLatin1String(\"kactus2:color\"));\r\n            if (colorExtension.size() == 1)\r\n            {\r\n                QSharedPointer<Kactus2Value> tagColorExtension =\r\n                    colorExtension.first().dynamicCast<Kactus2Value>();\r\n                if (tagColorExtension)\r\n                {\r\n                    tagColorExtension->setValue(tag.color_);\r\n                }\r\n            }\r\n        }\r\n        else\r\n        {\r\n            QSharedPointer<Kactus2Value> newTagName(new Kactus2Value(QLatin1String(\"kactus2:name\"), tag.name_));\r\n            QSharedPointer<Kactus2Value> newTagColor(new Kactus2Value(QLatin1String(\"kactus2:color\"), tag.color_));\r\n\r\n            QSharedPointer<Kactus2Group> newTagContainer(new Kactus2Group(QLatin1String(\"kactus2:tag\")));\r\n            newTagContainer->addToGroup(newTagName);\r\n            newTagContainer->addToGroup(newTagColor);\r\n\r\n            tagGroup->addToGroup(newTagContainer);\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Document::getRevision()\r\n//-----------------------------------------------------------------------------\r\nDocument::Revision Document::getRevision() const\r\n{\r\n    return revision_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Document::getTagByName()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<Kactus2Group> Document::getTagByName(QString const& name, QSharedPointer<Kactus2Group> tagGroup) const\r\n{\r\n    for (auto tagExtension : tagGroup->getByType(QLatin1String(\"kactus2:tag\")))\r\n    {\r\n        QSharedPointer<Kactus2Group> tag = tagExtension.dynamicCast<Kactus2Group>();\r\n        if (tag)\r\n        {\r\n            QList<QSharedPointer<VendorExtension> > tagNameContainer =\r\n                tag->getByType(QLatin1String(\"kactus2:name\"));\r\n            if (tagNameContainer.size() == 1)\r\n            {\r\n                QSharedPointer<Kactus2Value> tagName = tagNameContainer.first().dynamicCast<Kactus2Value>();\r\n                if (tagName && tagName->value() == name)\r\n                {\r\n                    return tag;\r\n                }\r\n            }\r\n        }\r\n    }\r\n\r\n    return QSharedPointer<Kactus2Group>();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Document::removeNonExistingTags()\r\n//-----------------------------------------------------------------------------\r\nvoid Document::removeNonExistingTags(QSharedPointer<Kactus2Group> tagContainer, QVector<TagData> const& newTags) const\r\n{\r\n    for (auto tagExtension : tagContainer->getByType(QLatin1String(\"kactus2:tag\")))\r\n    {\r\n        QString tagName = getTagName(tagExtension);\r\n        if (std::none_of(newTags.cbegin(), newTags.cend(), \r\n            [tagName](auto& comparisonTag) {return comparisonTag.name_ == tagName; }))  \r\n        {\r\n            tagContainer->removeFromGroup(tagExtension);\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Document::getTagName()\r\n//-----------------------------------------------------------------------------\r\nQString Document::getTagName(QSharedPointer<VendorExtension> tagExtension) const\r\n{\r\n    QSharedPointer<Kactus2Group> tag = tagExtension.dynamicCast<Kactus2Group>();\r\n    if (tag)\r\n    {\r\n        QList<QSharedPointer<VendorExtension> > tagNameContainer = tag->getByType(QLatin1String(\"kactus2:name\"));\r\n        if (tagNameContainer.size() == 1)\r\n        {\r\n            QSharedPointer<Kactus2Value> tagName = tagNameContainer.first().dynamicCast<Kactus2Value>();\r\n            if (tagName)\r\n            {\r\n                return tagName->value();\r\n            }\r\n        }\r\n    }\r\n\r\n    return QString();\r\n}\r\n"
  },
  {
    "path": "IPXACTmodels/common/Document.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: Document.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Esko Pekkarinen\r\n// Date: 05.08.2015\r\n//\r\n// Description:\r\n// Base class for IP-XACT documents e.g. component and design.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef DOCUMENT_H\r\n#define DOCUMENT_H\r\n\r\n#include \"Assertion.h\"\r\n#include \"Parameter.h\"\r\n\r\n#include <IPXACTmodels/generaldeclarations.h>\r\n#include <IPXACTmodels/ipxactmodels_global.h>\r\n\r\n#include <IPXACTmodels/common/VLNV.h>\r\n#include <IPXACTmodels/common/Extendable.h>\r\n#include <IPXACTmodels/common/TagData.h>\r\n\r\n#include <IPXACTmodels/kactusExtensions/KactusAttribute.h>\r\n#include <IPXACTmodels/kactusExtensions/Kactus2Value.h>\r\n\r\n#include <QString>\r\n#include <QList>\r\n#include <QSharedPointer>\r\n#include <QStringList>\r\n#include <QXmlStreamWriter>\r\n#include <QFile>\r\n\r\nclass VendorExtension;\r\nclass Kactus2Group;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Base class for IP-XACT documents e.g. component and design.\r\n//-----------------------------------------------------------------------------\r\nclass IPXACTMODELS_EXPORT Document : public Extendable\r\n{\r\npublic:\r\n\r\n    //! IP-XACT standard revision information.\r\n    enum class Revision\r\n    {\r\n        Std14, Std22, Unknown\r\n    };\r\n\r\n\t/*!\r\n\t *  The constructor.\r\n\t *\r\n\t *    @param [in] vlnv   The VLNV for the document.\r\n\t */\r\n\tDocument(VLNV const& vlnv, Revision revision = Revision::Unknown);\r\n\r\n    //! Copy constructor.\r\n\tDocument(const Document &other);\r\n\r\n    //! Assignment operator\r\n\tDocument &operator=(const Document &other);\r\n\r\n    //! The destructor.\r\n\tvirtual ~Document() = default;\r\n\r\n    /*!\r\n\t *  Creates a perfect copy of the document.\r\n\t *\r\n\t *    @return Copy of the document.\r\n\t */\r\n\tvirtual QSharedPointer<Document> clone() const = 0;\r\n\r\n\t/*! Get the vlnv of the element described in the document.\r\n\t *\r\n\t *    @return The vlnv element\r\n\t */\r\n\tVLNV getVlnv() const;\r\n    \r\n\t/*! Set the vlnv of the document.\r\n\t *\r\n\t *    @param [in] vlnv The vlnv to set.\r\n\t*/\r\n\tvirtual void setVlnv(const VLNV& vlnv);\r\n    \r\n    /*! Get the display name of the element described in the document.\r\n     *\r\n     *    @return The display name of the document.\r\n     */\r\n    QString getDisplayName() const;\r\n\r\n    /*! Set the display name of the document.\r\n     *\r\n     *    @param [in] displayName The display name to set.\r\n    */\r\n    void setDisplayName(const QString& displayName);\r\n\r\n    /*! Get the short description of the element described in the document.\r\n     *\r\n     *    @return The short description of the document.\r\n     */\r\n    QString getShortDescription() const;\r\n\r\n    /*! Set the short description of the document.\r\n     *\r\n     *    @param [in] shortDescription The short description to set.\r\n    */\r\n    void setShortDescription(const QString& shortDescription);\r\n\r\n\t/*! Get the description of the document.\r\n\t *\r\n\t *    @return QString containing the description of the document.\r\n\t */\r\n\tQString getDescription() const;\r\n\r\n\t/*! Set the description of this document.\r\n\t *\r\n\t *    @param [in] description The description to set.\r\n\t */\r\n\tvoid setDescription(QString const& description);\r\n    \r\n    /*!\r\n     *  Get the parameters for the document.\r\n     *\r\n     *    @return The parameters for the document.\r\n     */\r\n    QSharedPointer<QList<QSharedPointer<Parameter> > > getParameters() const;\r\n\r\n    /*!\r\n     *  Check if the document contains any parameters.\r\n     *\r\n     *    @return True, if parameters are found, false otherwise.\r\n     */\r\n    bool hasParameters() const;\r\n\r\n    /*!\r\n     *  Get the assertions.\r\n     *\r\n     *    @return The assertions for the document.\r\n     */\r\n    QSharedPointer<QList<QSharedPointer<Assertion> > > getAssertions() const;\r\n    \r\n    /*!\r\n     *  Sets the comments to display in the beginning of the XML file.\r\n     *\r\n     *    @param [in] comment   The comments to set.\r\n     */\r\n    void setTopComments(const QString& comment);\r\n\r\n    /*!\r\n     *  Sets the comments to display in the beginning of the XML file.\r\n     *\r\n     *    @param [in] comment   The comments to set.\r\n     */\r\n    void setTopComments(QStringList const& comments);\r\n\r\n\t/*!\r\n\t *   Gets the comments in the beginning of the XML file.\r\n\t *\r\n\t *    @return The comments if any.\r\n\t */\r\n\tQStringList getTopComments() const;\r\n        \r\n    /*!\r\n     *  Adds a new XML processing instruction for the document.\r\n     *\r\n     *    @param [in] target  The target for the instruction.\r\n     *    @param [in] data    The data in the instruction.\r\n     */\r\n    void addXmlProcessingInstructions(QString const& target, QString const& data);\r\n\r\n    /*!\r\n     *  Gets the XML processing instructions for the document.\r\n     *\r\n     *    @return The XML processing instructions as target-data pairs.\r\n     */\r\n    QVector<QPair<QString, QString> > getXmlProcessingInstructions() const;\r\n        \r\n    /*!\r\n     *  Adds a new XML namespace for the document, if it does not already exist within the document.\r\n     *\r\n     *    @param [in] nameSpace  The name of the namespace.\r\n     *    @param [in] uri        The uri of the namespace.\r\n     */\r\n    void addXmlNameSpace(QString const& nameSpace, QString const& uri);\r\n    \r\n    /*!\r\n     *  Gets the XML name spaces for the document.\r\n     */\r\n    QVector<QPair<QString, QString> > getXmlNameSpaces() const;\r\n\r\n    /*!\r\n     *  Set the XML schema location based on std revision.\r\n     *\r\n     *    @param [in] revision    The document std revision.\r\n     */\r\n    void setSchemaLocation(Document::Revision revision);\r\n\r\n    /*!\r\n     *  Get the XML schema location.\r\n     *  \r\n     *    @return The schema location as a string.\r\n     */\r\n    QString getSchemaLocation() const;\r\n\r\n\t/*! A pure virtual function to be implemented by subclasses.\r\n\t *\r\n\t *    @return QStringList containing the file dependencies of the document.\r\n\t */\r\n\tvirtual QStringList getDependentFiles() const = 0;\r\n\r\n\t/*! Get the dependent directories of the object. Default returns empty list.\r\n\t *\r\n\t *    @return empty list, re-implement in sub-classes.\r\n\t*/\r\n\tvirtual QStringList getDependentDirs() const;\r\n\r\n\t/*! A pure virtual function to be implemented by subclasses.\r\n\t *\r\n\t *    @return The VLNVs that are needed by this document.\r\n\t */\r\n\tvirtual QList<VLNV> getDependentVLNVs()const = 0;\r\n\r\n    /*!\r\n     *  Set the version number kactus2 during creation of this document.\r\n     *\r\n     *    @param [in] versionNumber   Version of Kactus2.\r\n     */\r\n    void setVersion(QString const& versionNumber);\r\n\r\n    /*!\r\n     *  Get the version number of Kactus2 used for creating this document.\r\n     *\r\n     *    @return  The used version of Kactus2.\r\n     */\r\n    QString getVersion() const;\r\n\r\n    /*!\r\n     *  Check if the document has Kactus attributes.\r\n     *\r\n     *    @return True, if the document has Kactus attributes, otherwise false.\r\n     */\r\n    bool hasKactusAttributes() const;\r\n\r\n    /*!\r\n     *  Check if the document contains an implementation Kactus attribute.\r\n     *\r\n     *    @return True, if an implementation attribute exists, otherwise false.\r\n     */\r\n    bool hasImplementation() const;\r\n\r\n    /*!\r\n     *  Sets the implementation type for the document.\r\n     *\r\n     *    @param [in] implementation   The new implementation type.\r\n     */\r\n    void setImplementation(KactusAttribute::Implementation implementation);\r\n\r\n    /*!\r\n     *  Gets the implementation type for the document.\r\n     *\r\n     *    @return The implementation type for the document.\r\n     */\r\n    KactusAttribute::Implementation getImplementation() const;\r\n\r\n    /*!\r\n     *  Check if the document has a determined product hierarchy.\r\n     *\r\n     *    @return True, if a product hierarchy exists, otherwise false.\r\n     */\r\n    bool hasProductHierarchy() const;\r\n\r\n    /*!\r\n     *  Set a new product hierarchy.\r\n     *\r\n     *    @param [in] productHierarchy    The new product hierarchy value.\r\n     */\r\n    void setHierarchy(KactusAttribute::ProductHierarchy productHierarchy);\r\n  \r\n    /*!\r\n     *  Get the product hierarhcy of the document.\r\n     *\r\n     *    @return The product hierarchy of the document.\r\n     */\r\n    KactusAttribute::ProductHierarchy getHierarchy() const;\r\n\r\n    /*!\r\n     *  Check if the document has a firmness attribute.\r\n     *\r\n     *    @return True, if a firmness attribute exists, otherwise false.\r\n     */\r\n    bool hasFirmness() const;\r\n\r\n    /*!\r\n     *  Get the firmness attribute.\r\n     *\r\n     *    @return The firmness value of the document.\r\n     */\r\n    KactusAttribute::Firmness getFirmness() const;\r\n\r\n    /*!\r\n     *  Set the firmness attribute.\r\n     *\r\n     *    @param [in] firmness    The new firmness value.\r\n     */\r\n    void setFirmness(KactusAttribute::Firmness firmness);\r\n    \r\n    /*!\r\n     *  Get the document license.\r\n     *\r\n     *    @return The license of the document, if any.\r\n     */\r\n    QString getLicense() const;\r\n\r\n    /*!\r\n     *  Set a new license for the document.\r\n     *\r\n     *    @param [in] license     The new license.\r\n     */\r\n    void setLicense(QString const& license);\r\n\r\n    /*!\r\n     *  Get the document tags.\r\n     *\r\n     *    @return The document tags.\r\n     */\r\n    QVector<TagData> getTags() const;\r\n\r\n    /*!\r\n     *  Set new tags for the document.\r\n     *\r\n     *    @param [in] newTags     The new tags.\r\n     */\r\n    void setTags(QVector<TagData> newTags) const;\r\n\r\n    /*!\r\n     *  Get the IP-XACT document standard revision.\r\n     *\r\n     *    @return The document standard revision.\r\n     */\r\n    Document::Revision getRevision() const;\r\n    \r\n    /*!\r\n     *  Convert document revision to QString.\r\n     *      \r\n     *    @param [in] revision   The document revision.\r\n     * \r\n     *    @return The document standard revision as QString.\r\n     */\r\n    static QString toString(Revision revision);\r\n    \r\n    /*!\r\n     *  Convert document revision to std::string.\r\n     *\r\n     *    @param [in] revision   The document revision.\r\n     *\r\n     *    @return The document standard revision as std::string.\r\n     */\r\n    static std::string toStdString(Revision revision);\r\n\r\n    static Document::Revision toRevision(QString const& revision);\r\n\r\nprivate:\r\n\r\n    /*\r\n     *  Add the default namespaces to the list of namespaces.\r\n     */\r\n    void addDefaultNameSpaces(Revision revision);\r\n\r\n    /*!\r\n     *  Get the group container for document tags.\r\n     *\r\n     *    @return The group container for document tags.\r\n     */\r\n    QSharedPointer<Kactus2Group> getTagGroup() const;\r\n\r\n    /*!\r\n     *  Get a tag container using a name.\r\n     *\r\n     *    @param [in] name        The name of the selected tag.\r\n     *    @param [in] tagGroup    Tag group containing the document tags.\r\n     *\r\n     *    @return The selected tag container.\r\n     */\r\n    QSharedPointer<Kactus2Group> getTagByName(QString const& name, QSharedPointer<Kactus2Group> tagGroup) const;\r\n\r\n    /*!\r\n     *  Remove old non-existing tags.\r\n     *\r\n     *    @param [in] tagContainer    Extension container for tags.\r\n     *    @param [in] newTags         The new tags.\r\n     */\r\n    void removeNonExistingTags(QSharedPointer<Kactus2Group> tagContainer, QVector<TagData> const& newTags) const;\r\n\r\n    /*!\r\n     *  Get the name of the selected tag.\r\n     *\r\n     *    @param [in] tagExtension    The selected tag.\r\n     *\r\n     *    @return Name of the selected tag.\r\n     */\r\n    QString getTagName(QSharedPointer<VendorExtension> tagExtension) const;\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    struct DocumentNameGroup\r\n    {\r\n        // The unique identifier for the document.\r\n\t    VLNV vlnv;\r\n\r\n        //! The document display name.\r\n        QString displayName;\r\n\r\n        //! The short description for the document.\r\n        QString shortDescription;\r\n\r\n        //! The description for the document.\r\n        QString description;\r\n    };\r\n\r\n    //! The document name group\r\n    DocumentNameGroup documentNameGroup_;\r\n\r\n    //! The selected IP-XACT standard revision\r\n\tRevision revision_;\t\r\n\r\n\t//! Contains the comment lines from the beginning of the document.\r\n\tQStringList topComments_;\r\n\r\n    //! Contains the xml processing instructions as target-data pairs.\r\n    QVector<QPair<QString, QString> > xmlProcessingInstructions_;\r\n\r\n    //! The map of xml namespaces with namespace as key and uri as value.\r\n    QVector<QPair<QString, QString> > xmlNameSpaces_;\r\n    \r\n    //! The map of xml attributes with attribute as key and uri as value.\r\n    QString xmlSchemaLocation_;\r\n\r\n    //! A list of parameters for the document.\r\n    QSharedPointer<QList<QSharedPointer<Parameter> > > parameters_ =\r\n        QSharedPointer<QList<QSharedPointer<Parameter> > >(new QList<QSharedPointer<Parameter> >());\r\n\r\n    //! A list of assertions for the document.\r\n    QSharedPointer<QList<QSharedPointer<Assertion> > > assertions_ =\r\n        QSharedPointer<QList<QSharedPointer<Assertion> > >(new QList<QSharedPointer<Assertion> >());\r\n\r\n};\r\n\r\n#endif /* DOCUMENT_H */\r\n"
  },
  {
    "path": "IPXACTmodels/common/DocumentReader.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: DocumentReader.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Mikko Teuho\r\n// Date: 12.08.2015\r\n//\r\n// Description:\r\n// Base class for XML readers.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"DocumentReader.h\"\r\n#include \"ParameterReader.h\"\r\n\r\n#include <IPXACTmodels/common/GenericVendorExtension.h>\r\n#include <IPXACTmodels/common/TagData.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DocumentReader::DocumentReader()\r\n//-----------------------------------------------------------------------------\r\nDocumentReader::DocumentReader() : CommonItemsReader()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DocumentReader::~DocumentReader()\r\n//-----------------------------------------------------------------------------\r\nDocumentReader::~DocumentReader()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DocumentReader::getXMLDocumentRevision()\r\n//-----------------------------------------------------------------------------\r\nDocument::Revision DocumentReader::getXMLDocumentRevision(QDomNode const& document)\r\n{\r\n    QDomNamedNodeMap attributeMap = document.attributes();\r\n\r\n    auto ipxactSchemaAttribute = attributeMap.namedItem(QStringLiteral(\"xmlns:ipxact\"));\r\n    QString schemaURI = ipxactSchemaAttribute.nodeValue();\r\n\r\n    if (schemaURI.contains(QStringLiteral(\"1685-2014\")))\r\n    {\r\n        return Document::Revision::Std14;\r\n    }\r\n    else if (schemaURI.contains(QStringLiteral(\"1685-2022\")))\r\n    {\r\n        return Document::Revision::Std22;\r\n    }\r\n    else\r\n    {\r\n        return Document::Revision::Unknown;\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DocumentReader::parseDocumentNameGroup()\r\n//-----------------------------------------------------------------------------\r\nvoid DocumentReader::parseDocumentNameGroup(QDomNode const& documentNode, QSharedPointer<Document> document)\r\n{\r\n    if (document->getRevision() == Document::Revision::Std22)\r\n    {\r\n        document->setDisplayName(\r\n            documentNode.firstChildElement(QStringLiteral(\"ipxact:displayName\")).firstChild().nodeValue());\r\n        document->setShortDescription(\r\n            documentNode.firstChildElement(QStringLiteral(\"ipxact:shortDescription\")).firstChild().nodeValue());\r\n    }\r\n\r\n    document->setDescription(\r\n        documentNode.firstChildElement(QStringLiteral(\"ipxact:description\")).firstChild().nodeValue());\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DocumentReader::parseTopComments()\r\n//-----------------------------------------------------------------------------\r\nvoid DocumentReader::parseTopComments(QDomNode const& documentNode, QSharedPointer<Document> document)\r\n{\r\n    QStringList comments;\r\n\r\n    QDomNodeList nodeList = documentNode.childNodes();\r\n    QDomNode singleDocumentNode = documentNode.firstChildElement();\r\n\r\n    for (int i = 0; i < nodeList.size() && nodeList.at(i) != singleDocumentNode; ++i)\r\n    {\r\n        if (nodeList.at(i).isComment())\r\n        {\r\n            comments.append(nodeList.at(i).nodeValue());\r\n        }\r\n    }\r\n\r\n    document->setTopComments(comments);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DocumentReader::parseXMLProcessingInstructions()\r\n//-----------------------------------------------------------------------------\r\nvoid DocumentReader::parseXMLProcessingInstructions(QDomNode const& documentNode, \r\n    QSharedPointer<Document> document)\r\n{\r\n    QDomNodeList nodeList = documentNode.childNodes();\r\n    QDomNode singleDocumentNode = documentNode.firstChildElement();\r\n\r\n    for (int i = 0; i < nodeList.size() && nodeList.at(i) != singleDocumentNode; i++)\r\n    {\r\n        if (nodeList.at(i).isProcessingInstruction())\r\n        {\r\n            QDomProcessingInstruction instruction = nodeList.at(i).toProcessingInstruction();\r\n            if (!instruction.data().startsWith(QStringLiteral(\"version\")))\r\n            {\r\n                document->addXmlProcessingInstructions(instruction.target(), instruction.data());\r\n            }            \r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DocumentWriter::parseNamespaceDeclarations()\r\n//-----------------------------------------------------------------------------\r\nvoid DocumentReader::parseNamespaceDeclarations(QDomNode const& documentNode, \r\n    QSharedPointer<Document> document)\r\n{\r\n    QDomNamedNodeMap attributeMap = documentNode.attributes();\r\n    QString nameSpaceIdentifier = QStringLiteral(\"xmlns:\");\r\n\r\n    for (int i = 0; i < attributeMap.count(); ++i)\r\n    {\r\n        QDomNode attr = attributeMap.item(i);\r\n\r\n        QString name = attr.nodeName();\r\n\r\n        // Must be xmlns.\r\n        if (name.startsWith(nameSpaceIdentifier))\r\n        {\r\n            document->addXmlNameSpace(name.remove(nameSpaceIdentifier), attr.nodeValue());\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DocumentReader::parseVLNV()\r\n//-----------------------------------------------------------------------------\r\nvoid DocumentReader::parseVLNVElements(QDomNode const& documentNode, QSharedPointer<Document> document,\r\n    VLNV::IPXactType type)\r\n{\r\n    document->setVlnv(createVLNVFrom(documentNode, type));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DocumentReader::parseDescription()\r\n//-----------------------------------------------------------------------------\r\nvoid DocumentReader::parseDescription(QDomNode const& documentNode, QSharedPointer<Document> document)\r\n{\r\n    document->setDescription(documentNode.firstChildElement(QStringLiteral(\"ipxact:description\")).firstChild().nodeValue());\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DocumentReader::parseParameters()\r\n//-----------------------------------------------------------------------------\r\nvoid DocumentReader::parseParameters(QDomNode const& documentNode, QSharedPointer<Document> document)\r\n{\r\n    QSharedPointer<QList<QSharedPointer<Parameter> > > newParameters = parseAndCreateParameters(\r\n        documentNode, document->getRevision());\r\n\r\n    for (auto parameter : *newParameters)\r\n    {\r\n        document->getParameters()->append(parameter);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DocumentReader::parseAssertions()\r\n//-----------------------------------------------------------------------------\r\nvoid DocumentReader::parseAssertions(QDomNode const& documentNode, QSharedPointer<Document> document)\r\n{\r\n    QDomNodeList assertionNodeList = documentNode.firstChildElement(QStringLiteral(\"ipxact:assertions\")).childNodes();\r\n\r\n    if (!assertionNodeList.isEmpty())\r\n    {\r\n        int assertionCount = assertionNodeList.count();\r\n        for (int i = 0; i < assertionCount; ++i)\r\n        {\r\n            QDomNode assertionNode = assertionNodeList.at(i);\r\n\r\n            QSharedPointer<Assertion> newAssertion (new Assertion());\r\n            newAssertion->setName(assertionNode.firstChildElement(QStringLiteral(\"ipxact:name\")).firstChild().nodeValue());\r\n            newAssertion->setDisplayName(assertionNode.firstChildElement(QStringLiteral(\"ipxact:displayName\")).firstChild().\r\n                nodeValue());\r\n            newAssertion->setDescription(assertionNode.firstChildElement(QStringLiteral(\"ipxact:description\")).firstChild().\r\n                nodeValue());\r\n            newAssertion->setAssert(assertionNode.firstChildElement(QStringLiteral(\"ipxact:assert\")).firstChild().nodeValue());\r\n\r\n            document->getAssertions()->append(newAssertion);\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DocumentReader::parseKactusAndVendorExtensions()\r\n//-----------------------------------------------------------------------------\r\nvoid DocumentReader::parseKactusAndVendorExtensions(QDomNode const& documentNode, \r\n    QSharedPointer<Document> document)\r\n{\r\n    QDomElement extensionNodes = documentNode.firstChildElement(QStringLiteral(\"ipxact:vendorExtensions\"));\r\n\r\n    QDomNode versionNode = extensionNodes.firstChildElement(QStringLiteral(\"kactus2:version\"));\r\n    if (!versionNode.isNull())\r\n    {\r\n        document->setVersion(versionNode.firstChild().nodeValue());\r\n    }\r\n\r\n    QDomNode attributesNode = extensionNodes.firstChildElement(QStringLiteral(\"kactus2:kts_attributes\"));\r\n    if (!attributesNode.isNull())\r\n    {\r\n        parseKactusAttributes(attributesNode, document);\r\n    }\r\n\r\n    QDomNode tagsNode = extensionNodes.firstChildElement(QLatin1String(\"kactus2:tags\"));\r\n    if (!tagsNode.isNull())\r\n    {\r\n        parseTags(tagsNode, document);\r\n    }\r\n\r\n    QDomNode licenseNode = extensionNodes.firstChildElement(QStringLiteral(\"kactus2:license\"));\r\n    if (!licenseNode.isNull())\r\n    {\r\n        document->setLicense(licenseNode.firstChild().nodeValue());\r\n    }\r\n\r\n    parseVendorExtensions(documentNode, document);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DocumentReader::parseKactusAttributes()\r\n//-----------------------------------------------------------------------------\r\nvoid DocumentReader::parseKactusAttributes(QDomNode const& attributesNode, QSharedPointer<Document> document)\r\n{\r\n    QDomNode hierarchyNode = attributesNode.firstChildElement(QStringLiteral(\"kactus2:kts_productHier\"));\r\n    if (!hierarchyNode.isNull())\r\n    {\r\n        KactusAttribute::ProductHierarchy hierarchy = \r\n            KactusAttribute::hierarchyFrom(hierarchyNode.firstChild().nodeValue());\r\n        document->setHierarchy(hierarchy);\r\n    }\r\n\r\n    QDomNode implementationNode = attributesNode.firstChildElement(QStringLiteral(\"kactus2:kts_implementation\"));\r\n    if (!implementationNode.isNull())\r\n    {\r\n        KactusAttribute::Implementation implementation = \r\n            KactusAttribute::implementationFrom(implementationNode.firstChild().nodeValue());\r\n        document->setImplementation(implementation);\r\n    }\r\n\r\n    QDomNode firmnessNode = attributesNode.firstChildElement(QStringLiteral(\"kactus2:kts_firmness\"));\r\n    if (!firmnessNode.isNull())\r\n    {\r\n        KactusAttribute::Firmness firmness = KactusAttribute::firmnessFrom(firmnessNode.firstChild().nodeValue());\r\n        document->setFirmness(firmness);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DocumentReader::parseTags()\r\n//-----------------------------------------------------------------------------\r\nvoid DocumentReader::parseTags(QDomNode const& tagsGroupNode, QSharedPointer<Document> document)\r\n{\r\n    QVector<TagData> documentTags;\r\n\r\n    QDomNodeList tagNodeList = tagsGroupNode.childNodes();\r\n    for (int i = 0; i < tagNodeList.size(); ++i)\r\n    {\r\n        QDomNode tagNode = tagNodeList.at(i);\r\n        QDomElement nameElement = tagNode.firstChildElement(QLatin1String(\"kactus2:name\"));\r\n        QDomElement colorElement = tagNode.firstChildElement(QLatin1String(\"kactus2:color\"));\r\n\r\n        if (!nameElement.isNull() && !colorElement.isNull())\r\n        {\r\n            TagData newTag({ nameElement.text(), colorElement.text() });\r\n\r\n            documentTags.append(newTag);\r\n        }\r\n    }\r\n\r\n    if (!documentTags.isEmpty())\r\n    {\r\n        document->setTags(documentTags);\r\n    }\r\n}\r\n"
  },
  {
    "path": "IPXACTmodels/common/DocumentReader.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: DocumentReader.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Mikko Teuho\r\n// Date: 12.08.2015\r\n//\r\n// Description:\r\n// Base class for XML readers.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef DOCUMENTREADER_H\r\n#define DOCUMENTREADER_H\r\n\r\n#include \"Document.h\"\r\n\r\n#include <IPXACTmodels/common/VLNV.h>\r\n\r\n#include <IPXACTmodels/common/CommonItemsReader.h>\r\n#include <IPXACTmodels/common/ConfigurableVLNVReference.h>\r\n#include <IPXACTmodels/common/ConfigurableElementValue.h>\r\n\r\n#include <QSharedPointer>\r\n#include <QDomNode>\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Base class for XML readers.\r\n//-----------------------------------------------------------------------------\r\nclass IPXACTMODELS_EXPORT DocumentReader : public CommonItemsReader\r\n{    \r\npublic:\r\n\r\n    /*!\r\n     *  The constructor.\r\n     */\r\n    DocumentReader();\r\n\r\n    /*!\r\n     *  The destructor.\r\n     */\r\n    virtual ~DocumentReader();\r\n\r\n    /*!\r\n     *  Parses the document revision from XML.\r\n     *\r\n     *    @param [in] document    The XML description of the document.\r\n     */\r\n    static Document::Revision getXMLDocumentRevision(QDomNode const& document);\r\n\r\n    /*!\r\n     *  Parses the document name group data.\r\n     *\r\n     *    @param [in] documentNode    The XML description of the document.\r\n     *    @param [in] document        The document to insert the parsed data.\r\n     */\r\n    static void parseDocumentNameGroup(QDomNode const& documentNode, QSharedPointer<Document> document);\r\n\r\n    /*!\r\n     *  Parses the comments preceding the document from XML.\r\n     *\r\n     *    @param [in] documentNode    The XML description of the document.\r\n     *    @param [in] document        The document to insert the parsed comments.\r\n     */\r\n    static void parseTopComments(QDomNode const& documentNode, QSharedPointer<Document> document);\r\n\r\n    static void parseXMLProcessingInstructions(QDomNode const& documentNode, QSharedPointer<Document> document);\r\n\r\n    static void parseNamespaceDeclarations(QDomNode const& documentNode, QSharedPointer<Document> document);\r\n\r\n    /*!\r\n     *  Parses the VLNV from XML to a document.\r\n     *\r\n     *    @param [in] documentNode    The XML description of the document.\r\n     *    @param [in] document        The document in which the parsed VLNV is inserted.\r\n     *    @param [in] type            The type of the VLNV.\r\n     */\r\n    static void parseVLNVElements(QDomNode const& documentNode, QSharedPointer<Document> document, VLNV::IPXactType type);\r\n\r\n    /*!\r\n     *  Parses the description from XML to a document.\r\n     *\r\n     *    @param [in] documentNode    The XML description of the document.\r\n     *    @param [in] document        The document in which the parsed description is inserted.\r\n     */\r\n    static void parseDescription(QDomNode const& documentNode, QSharedPointer<Document> document);\r\n\r\n    /*!\r\n     *  Parses the parameters from XLM to a document.\r\n     *\r\n     *    @param [in] documentNode    The XML description of the document.\r\n     *    @param [in] document        The document in which the parsed parameters are inserted.\r\n     */\r\n    static void parseParameters(QDomNode const& documentNode, QSharedPointer<Document> document);\r\n\r\n    /*!\r\n     *  Parses the assertions from XML to a document.\r\n     *\r\n     *    @param [in] documentNode    The XML description of the document.\r\n     *    @param [in] document        The document in which the parsed assertions are inserted.\r\n     */\r\n    static void parseAssertions(QDomNode const& documentNode, QSharedPointer<Document> document);\r\n    \r\n    /*!\r\n     *  Parses Kactus2 specific vendor extensions before other vendor extensions from XML.\r\n     *\r\n     *    @param [in] documentNode    The XML description of the document.\r\n     *    @param [in] document        The document in which the parsed extensions are stored.\r\n     */\r\n     static void parseKactusAndVendorExtensions(QDomNode const& documentNode,\r\n        QSharedPointer<Document> document);\r\n\r\n    /*!\r\n     *  Parses Kactus2 attributes for classifying IP from XML.\r\n     *\r\n     *    @param [in] attributesNode      The XML description of the attributes.\r\n     *    @param [in] document            The document in which the parsed attributes are stored.\r\n     */\r\n     static void parseKactusAttributes(QDomNode const& attributesNode, QSharedPointer<Document> document);\r\n\r\n    /*!\r\n     *  Parses document tags from XML.\r\n     *\r\n     *    @param [in] tagsGroupNode   XML description of the tags.\r\n     *    @param [in] document        The containing component.\r\n     */\r\n     static void parseTags(QDomNode const& tagsGroupNode, QSharedPointer<Document> document);\r\n\r\nprivate:\r\n\r\n\t// Disable copying.\r\n    DocumentReader(DocumentReader const& rhs);\r\n    DocumentReader& operator=(DocumentReader const& rhs);\r\n\r\n};\r\n\r\n#endif // DOCUMENTREADER_H"
  },
  {
    "path": "IPXACTmodels/common/DocumentUtils.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: DocumentUtils.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Anton Hagqvist\n// Date: 31.01.2024\n//\n// Description:\n// Utilities for document compatibility checking.\n//-----------------------------------------------------------------------------\n\n#include \"DocumentUtils.h\"\n\n#include <IPXACTmodels/common/VLNV.h>\n#include <IPXACTmodels/common/Document.h>\n\n#include <KactusAPI/include/LibraryInterface.h>\n\n//-----------------------------------------------------------------------------\n// Function: DocumentUtils::documentsHaveMatchingStdRevisions()\n//-----------------------------------------------------------------------------\nbool DocumentUtils::documentsHaveMatchingStdRevisions(VLNV const& firstVlnv, VLNV const& secondVlnv,\n    LibraryInterface* library)\n{\n    if (!firstVlnv.isValid() || !secondVlnv.isValid())\n    {\n        return false;\n    }\n\n    auto firstDoc = library->getModelReadOnly(firstVlnv);\n    auto secondDoc = library->getModelReadOnly(secondVlnv);\n\n    if (!firstDoc || !secondDoc)\n    {\n        return false;\n    }\n\n    return firstDoc->getRevision() == secondDoc->getRevision();\n}\n"
  },
  {
    "path": "IPXACTmodels/common/DocumentUtils.h",
    "content": "//-----------------------------------------------------------------------------\n// File: DocumentUtils.h\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Anton Hagqvist\n// Date: 31.01.2024\n//\n// Description:\n// Utilities for document compatibility checking.\n//-----------------------------------------------------------------------------\n\n#ifndef DOCUMENTUTILS_H\n#define DOCUMENTUTILS_H\n\n#include <IPXACTmodels/ipxactmodels_global.h>\n\n#include <QString>\n\nclass LibraryInterface;\nclass VLNV;\n\nnamespace DocumentUtils\n{\n\n    /*!\n     *\tChecks if two documents of same type are using the same IP-XACT standard revision.\n     *  \n     *    @param [in] firstVlnv        The VLNV of the first document to check.\n     *    @param [in] secondVlnv       The VLNV of the second document to check.\n     *    @param [in] library          The library handler.\n     *\t    \n     * \t    @return True, if the revisions are the same, false if not or if either document couldn't be found.\n     */\n    IPXACTMODELS_EXPORT bool documentsHaveMatchingStdRevisions(VLNV const& firstVlnv, VLNV const& secondVlnv, \n        LibraryInterface* library);\n\n}\n\n#endif // DOCUMENTUTILS_H\n"
  },
  {
    "path": "IPXACTmodels/common/DocumentWriter.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: DocumentWriter.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Esko Pekkarinen\r\n// Date: 06.08.2015\r\n//\r\n// Description:\r\n// Base class for IP-XACT document writers.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"DocumentWriter.h\"\r\n#include \"Document.h\"\r\n\r\n#include <IPXACTmodels/common/NameGroupWriter.h>\r\n#include <QPair>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DocumentWriter::DocumentWriter()\r\n//-----------------------------------------------------------------------------\r\nDocumentWriter::DocumentWriter() : CommonItemsWriter()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DocumentWriter::writeTopComments()\r\n//-----------------------------------------------------------------------------\r\nvoid DocumentWriter::writeTopComments(QXmlStreamWriter& writer, QSharedPointer<Document> document) \r\n{\r\n    for (QString const& comment : document->getTopComments())\r\n    {\r\n        writer.writeComment(comment);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DocumentWriter::writeXmlProcessingInstructions()\r\n//-----------------------------------------------------------------------------\r\nvoid DocumentWriter::writeXmlProcessingInstructions(QXmlStreamWriter& writer, QSharedPointer<Document> document) \r\n{\r\n    QVector<QPair<QString, QString> > instructions = document->getXmlProcessingInstructions();\r\n\r\n    for (auto const& [target, data] : instructions)\r\n    {\r\n        writer.writeProcessingInstruction(target, data);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DocumentWriter::writeNamespaceDeclarations()\r\n//-----------------------------------------------------------------------------\r\nvoid DocumentWriter::writeNamespaceDeclarations(QXmlStreamWriter& writer, QSharedPointer<Document> document) \r\n{\r\n    QVector<QPair<QString, QString> > nameSpaces = document->getXmlNameSpaces();\r\n\r\n    for (auto const& [name, uri] : nameSpaces)\r\n    {\r\n        writer.writeNamespace(uri, name);\r\n    }\r\n\r\n    // Also write the schema location.\r\n    if (auto revision = document->getRevision(); revision != Document::Revision::Unknown)\r\n    {\r\n        QString schemaLocation = QStringLiteral(\"http://www.accellera.org/XMLSchema/IPXACT/%1 http://www.accellera.org/XMLSchema/IPXACT/%1/index.xsd\")\r\n            .arg(Document::toString(revision));\r\n\r\n        writer.writeAttribute(QStringLiteral(\"xsi:schemaLocation\"), schemaLocation);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DocumentWriter::writeDocumentNameGroup()\r\n//-----------------------------------------------------------------------------\r\nvoid DocumentWriter::writeDocumentNameGroup(QXmlStreamWriter& writer, QSharedPointer<Document> document)\r\n{\r\n    CommonItemsWriter::writeVLNVElements(writer, document->getVlnv());\r\n\r\n    if (auto revision = document->getRevision();\r\n        revision == Document::Revision::Std22)\r\n    {\r\n        CommonItemsWriter::writeDisplayName(writer, document->getDisplayName());\r\n\r\n        CommonItemsWriter::writeShortDescription(writer, document->getShortDescription());\r\n        \r\n        CommonItemsWriter::writeDescription(writer, document->getDescription());\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DocumentWriter::writeParameters()\r\n//-----------------------------------------------------------------------------\r\nvoid DocumentWriter::writeParameters(QXmlStreamWriter& writer, QSharedPointer<Document> document) \r\n{\r\n    CommonItemsWriter::writeParameters(writer, document->getParameters(), document->getRevision());\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DocumentWriter::writeAssertions()\r\n//-----------------------------------------------------------------------------\r\nvoid DocumentWriter::writeAssertions(QXmlStreamWriter& writer, QSharedPointer<Document> document) \r\n{\r\n    if (!document->getAssertions()->isEmpty())\r\n    {\r\n        writer.writeStartElement(QStringLiteral(\"ipxact:assertions\"));\r\n\r\n        for (auto const& assertion : *document->getAssertions())\r\n        {\r\n            writer.writeStartElement(QStringLiteral(\"ipxact:assertion\"));\r\n\r\n            NameGroupWriter::writeNameGroup(writer, assertion);\r\n            writer.writeTextElement(QStringLiteral(\"ipxact:assert\"), assertion->getAssert());\r\n\r\n            writer.writeEndElement(); // ipxact:assertion\r\n        }\r\n\r\n        writer.writeEndElement(); // ipxact:assertions\r\n    }\r\n}\r\n"
  },
  {
    "path": "IPXACTmodels/common/DocumentWriter.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: DocumentWriter.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Esko Pekkarinen\r\n// Date: 06.08.2015\r\n//\r\n// Description:\r\n// Base class for IP-XACT document writers.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef DOCUMENTWRITER_H\r\n#define DOCUMENTWRITER_H\r\n\r\n#include \"CommonItemsWriter.h\"\r\n\r\n#include <QSharedPointer>\r\n#include <QXmlStreamWriter>\r\n\r\nclass Document;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Base class for IP-XACT document writers.\r\n//-----------------------------------------------------------------------------\r\nclass DocumentWriter : public CommonItemsWriter\r\n{\r\npublic:\r\n\r\n    //! The constructor.\r\n    DocumentWriter();\r\n\r\n\t//! The destructor.\r\n\t~DocumentWriter() override = default;\r\n\r\n    /*!\r\n     *  Writes the comments preceding the document into XML.\r\n     *\r\n     *    @param [in] writer      The writer to use.\r\n     *    @param [in] document    The document whose comments to write.\r\n     */\r\n    static void writeTopComments(QXmlStreamWriter& writer, QSharedPointer<Document> document);\r\n    \r\n    /*!\r\n     *  Writes the xml processing instructions for IP-XACT 2014 documents.\r\n     *\r\n     *    @param [in] writer      The writer to use.\r\n     *    @param [in] document    The document whose comments to write.\r\n     */\r\n    static void writeXmlProcessingInstructions(QXmlStreamWriter& writer, QSharedPointer<Document> document);\r\n\r\n    /*!\r\n     *  Writes the namespace declarations for IP-XACT 2014 documents.\r\n     *\r\n     *    @param [in] writer   The writer to use.\r\n     *    @param [in] document    The document whose comments to write.\r\n     */\r\n    static void writeNamespaceDeclarations(QXmlStreamWriter& writer, QSharedPointer<Document> document);\r\n\r\n    static void writeDocumentNameGroup(QXmlStreamWriter& writer, QSharedPointer<Document> document);\r\n\r\n     /*!\r\n     *  Writes the parameters of a given document into XML.\r\n     *\r\n     *    @param [in] writer       The used XML writer.\r\n     *    @param [in] document     The document whose parameters to write.\r\n     */\r\n    static void writeParameters(QXmlStreamWriter& writer, QSharedPointer<Document> document);\r\n\r\n    /*!\r\n     *  Writes the assertions of a given document into XML.\r\n     *\r\n     *    @param [in] writer       The used XML writer.\r\n     *    @param [in] document     The document whose assertions to write.\r\n     */\r\n    static void writeAssertions(QXmlStreamWriter& writer, QSharedPointer<Document> document);\r\n\r\nprivate:\r\n\r\n\t// Disable copying.\r\n\tDocumentWriter(DocumentWriter const& rhs);\r\n\tDocumentWriter& operator=(DocumentWriter const& rhs);\r\n\r\n};\r\n\r\n#endif // DOCUMENTWRITER_H"
  },
  {
    "path": "IPXACTmodels/common/Enumeration.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: Enumeration.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Esko Pekkarinen\r\n// Date: 04.09.2014\r\n//\r\n// Description:\r\n// Enumeration matches the ipxact:enumeration element in IP-XACT.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"Enumeration.h\"\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Enumeration::Enumeration()\r\n//-----------------------------------------------------------------------------\r\nEnumeration::Enumeration()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Enumeration::Enumeration()\r\n//-----------------------------------------------------------------------------\r\nEnumeration::Enumeration(Enumeration const& other):\r\nvalue_(other.value_),\r\ntext_(other.text_),\r\nhelp_(other.help_)\r\n{\r\n\r\n}\r\n\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Enumeration::~Enumeration()\r\n//-----------------------------------------------------------------------------\r\nEnumeration::~Enumeration()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Enumeration::setValue()\r\n//-----------------------------------------------------------------------------\r\nvoid Enumeration::setValue(QString const& value)\r\n{\r\n    value_ = value;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Enumeration::getValue()\r\n//-----------------------------------------------------------------------------\r\nQString Enumeration::getValue() const\r\n{\r\n    return value_;\r\n}\r\n//-----------------------------------------------------------------------------\r\n// Function: Enumeration::setText()\r\n//-----------------------------------------------------------------------------\r\nvoid Enumeration::setText(QString const& text)\r\n{\r\n    text_ = text;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Enumeration::getText()\r\n//-----------------------------------------------------------------------------\r\nQString Enumeration::getText() const\r\n{\r\n    return text_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Enumeration::setHelp()\r\n//-----------------------------------------------------------------------------\r\nvoid Enumeration::setHelp(QString const& help)\r\n{\r\n    help_ = help;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Enumeration::getHelp()\r\n//-----------------------------------------------------------------------------\r\nQString Enumeration::getHelp() const\r\n{\r\n    return help_;\r\n}\r\n"
  },
  {
    "path": "IPXACTmodels/common/Enumeration.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: Enumeration.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Esko Pekkarinen\r\n// Date: 04.09.2014\r\n//\r\n// Description:\r\n// Enumeration matches the ipxact:enumeration element in IP-XACT.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef ENUMERATION_H\r\n#define ENUMERATION_H\r\n\r\n#include <IPXACTmodels/ipxactmodels_global.h>\r\n\r\n#include <QString>\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Enumeration matches the ipxact:enumeration element in IP-XACT.\r\n//-----------------------------------------------------------------------------\r\nclass IPXACTMODELS_EXPORT Enumeration \r\n{\r\npublic:\r\n    \r\n    //! The default constructor.\r\n    Enumeration();\r\n\r\n    /*!\r\n     *  The copy constructor.\r\n     *\r\n     *    @param [in] other   The enumeration to copy.\r\n     */\r\n    Enumeration(Enumeration const& other);\r\n\r\n\t//! The destructor.\r\n\t~Enumeration();\r\n\r\n    /*!\r\n     *  Sets the enumeration value.\r\n     *\r\n     *    @param [in] value   The value to set.\r\n     */\r\n    void setValue(QString const& value);\r\n\r\n    /*!\r\n     *  Gets the enumeration value.\r\n     *\r\n     *    @return The enumeration value.\r\n     */\r\n    QString getValue() const;\r\n    \r\n    /*!\r\n     *  Sets the enumeration text to display instead of value.\r\n     *\r\n     *    @param [in] text   The text to set.\r\n     */\r\n    void setText(QString const& text);\r\n    \r\n    /*!\r\n     *  Gets the enumeration text.\r\n     *\r\n     *    @return The enumeration text.\r\n     */\r\n    QString getText() const;\r\n        \r\n    /*!\r\n     *  Sets the clarifying help text.\r\n     *\r\n     *    @param [in] help   The help text to set.\r\n     */\r\n    void setHelp(QString const& help);\r\n        \r\n    /*!\r\n     *  Gets the clarifying help text.\r\n     *\r\n     *    @return The enumeration help text.\r\n     */\r\n    QString getHelp() const;\r\n\r\nprivate:\r\n\r\n\t// Disable assignment.\r\n\tEnumeration& operator=(Enumeration const& rhs);\r\n\r\n    //! Value of the enumeration.\r\n\tQString value_;\r\n\r\n\t//! If specified, text is displayed in place of the value. \r\n\tQString text_;\r\n\r\n\t//! If specified, help is used to clarify the meaning of the enumeration.\r\n\tQString help_;\r\n};\r\n\r\n#endif // ENUMERATION_H\r\n"
  },
  {
    "path": "IPXACTmodels/common/Extendable.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: Extendable.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Esko Pekkarinen\r\n// Date: 11.08.2015\r\n//\r\n// Description:\r\n// Base class for all IP-XACT implementations with vendor extensions.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"Extendable.h\"\r\n\r\n#include <IPXACTmodels/common/VendorExtension.h>\r\n#include <IPXACTmodels/kactusExtensions/Kactus2Group.h>\r\n#include <IPXACTmodels/kactusExtensions/Kactus2Placeholder.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Extendable::getVendorExtensions()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<QList<QSharedPointer<VendorExtension> > > Extendable::getVendorExtensions() const\r\n{\r\n    return vendorExtensions_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Extendable::Extendable()\r\n//-----------------------------------------------------------------------------\r\nExtendable::Extendable() :\r\nvendorExtensions_(new QList<QSharedPointer<VendorExtension> >())\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Extendable::Extendable()\r\n//-----------------------------------------------------------------------------\r\nExtendable::Extendable(Extendable const& other) : \r\nvendorExtensions_(new QList<QSharedPointer<VendorExtension> >())\r\n{\r\n    copyVendorExtensions(other);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Extendable::operator=()\r\n//-----------------------------------------------------------------------------\r\nExtendable& Extendable::operator=(Extendable const& other)\r\n{\r\n    if (this != &other)\r\n    {\r\n        vendorExtensions_->clear();\r\n        copyVendorExtensions(other);\r\n    }\r\n\r\n    return *this;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Extendable::copyVendorExtensions()\r\n//-----------------------------------------------------------------------------\r\nvoid Extendable::copyVendorExtensions(Extendable const& other)\r\n{\r\n    for (QSharedPointer<VendorExtension> extension : *other.vendorExtensions_)\r\n    {\r\n        vendorExtensions_->append(QSharedPointer<VendorExtension>(extension->clone()));\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Extendable::getGroupedExtensionsByType()\r\n//-----------------------------------------------------------------------------\r\nQList<QSharedPointer<VendorExtension> > Extendable::getGroupedExtensionsByType(QString const& groupName,\r\n    QString const& extensionType) const\r\n{\r\n    auto extension = findVendorExtension(groupName);\r\n\r\n    if (extension != nullptr)\r\n    {\r\n        QSharedPointer<Kactus2Group> extensionGroup = extension.dynamicCast<Kactus2Group>();\r\n        return extensionGroup->getByType(extensionType);\r\n    }\r\n\r\n    return QList<QSharedPointer<VendorExtension> >();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Extendable::setPlaceholderExtension()\r\n//-----------------------------------------------------------------------------\r\nvoid Extendable::setPlaceholderExtension(bool value, QString const& extensionType)\r\n{\r\n    auto extension = findVendorExtension(extensionType).dynamicCast<Kactus2Placeholder>();\r\n\r\n    if (value)\r\n    {\r\n        if (extension == nullptr)\r\n        {\r\n            extension = QSharedPointer<Kactus2Placeholder>(new Kactus2Placeholder(extensionType));\r\n            getVendorExtensions()->append(extension);\r\n        }\r\n    }\r\n    else\r\n    {\r\n        getVendorExtensions()->removeAll(extension);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Extendable::findVendorExtension()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<VendorExtension> Extendable::findVendorExtension(QString const& type) const\r\n{\r\n    auto it = std::find_if(vendorExtensions_->cbegin(), vendorExtensions_->cend(), \r\n        [type](auto& extension) {return extension->type() == type;  });\r\n\r\n    if (it == vendorExtensions_->cend())\r\n    {\r\n        return nullptr;\r\n    }\r\n\r\n    return *it;\r\n}\r\n"
  },
  {
    "path": "IPXACTmodels/common/Extendable.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: Extendable.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Esko Pekkarinen\r\n// Date: 11.08.2015\r\n//\r\n// Description:\r\n// Base class for all IP-XACT implementations with vendor extensions.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef EXTENDABLE_H\r\n#define EXTENDABLE_H\r\n\r\n#include <IPXACTmodels/ipxactmodels_global.h>\r\n\r\n#include <QList>\r\n#include <QSharedPointer>\r\n\r\nclass VendorExtension;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Base class for all IP-XACT implementations with vendor extensions.\r\n//-----------------------------------------------------------------------------\r\nclass IPXACTMODELS_EXPORT Extendable \r\n{\r\npublic:\r\n\r\n\t//! The destructor.\r\n\tvirtual ~Extendable() {};\r\n            \r\n    /*!\r\n     *  Gets the vendor extensions for the element.\r\n     *\r\n     *    @return The vendor extensions for the element.\r\n     */\r\n    QSharedPointer<QList<QSharedPointer<VendorExtension> > > getVendorExtensions() const;\r\n\r\nprotected:\r\n\r\n    //! The constructor.\r\n    Extendable();\r\n\r\n    //! Copy constructor.\r\n    Extendable(Extendable const& rhs);\r\n\r\n    //! Assignment operation.\r\n    Extendable& operator=(Extendable const& rhs);\r\n    \r\n    /*!\r\n     *  Copies vendor extensions from another element.\r\n     *\r\n     *    @param [in] other   The element to copy extensions from.\r\n     */\r\n    void copyVendorExtensions(Extendable const& other);\r\n\r\n    /*!\r\n     *  Get a list of grouped extensions.\r\n     *\r\n     *    @param [in] groupName       Identifier of the extension group.\r\n     *    @param [in] extensionType   Identifier of the extension item.\r\n     *\r\n     *    @return A list of extensions belonging to a group.\r\n     */\r\n    QList<QSharedPointer<VendorExtension> > getGroupedExtensionsByType(QString const& groupName,\r\n        QString const& extensionType) const;\r\n\r\n    /*!\r\n     * Creates a Kactus2 vendor extension with given type, if it does not exist already.\r\n     * If value is false, the extension is removed.\r\n     *\r\n     *    @param [in] value            The value to set.\r\n     *    @param [in] extensionType    The type of the vendor extension.\r\n     */\r\n    void setPlaceholderExtension(bool value, QString const& extensionType);\r\n\r\n    /*!\r\n     *  Find a vendor extension by given type.\r\n     *\r\n     *    @param [in] type        The type of extension to find.\r\n     *\r\n     *    @return The first found extension with the given type.\r\n     */\r\n    QSharedPointer<VendorExtension> findVendorExtension(QString const& type) const;\r\n\r\nprivate:\r\n\r\n    //! Any vendor extensions for the element.\r\n    QSharedPointer<QList<QSharedPointer<VendorExtension> > > vendorExtensions_;\r\n};\r\n\r\n#endif // EXTENDABLE_H\r\n"
  },
  {
    "path": "IPXACTmodels/common/FileBuilder.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: FileBuilder.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 08.09.2015\r\n//\r\n// Description:\r\n// Implementation for ipxact:fileBuilder element.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"FileBuilder.h\"\r\n#include \"FileType.h\"\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileBuilder::FileBuilder()\r\n//-----------------------------------------------------------------------------\r\nFileBuilder::FileBuilder() :\r\nBuildModel(),\r\nExtendable()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileBuilder::FileBuilder()\r\n//-----------------------------------------------------------------------------\r\nFileBuilder::FileBuilder( const QString& fileType ):\r\nBuildModel(),\r\nExtendable()\r\n{\r\n    setFileType(fileType);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileBuilder::FileBuilder()\r\n//-----------------------------------------------------------------------------\r\nFileBuilder::FileBuilder( const FileBuilder &other ):\r\nBuildModel(other),\r\nExtendable(other),\r\nfileType_(other.fileType_)\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileBuilder::operator=()\r\n//-----------------------------------------------------------------------------\r\nFileBuilder & FileBuilder::operator=( const FileBuilder &other )\r\n{\r\n\tif (this != &other)\r\n    {\r\n        BuildModel::operator=(other);\r\n        Extendable::operator=(other);\r\n\r\n        fileType_ = other.fileType_;\r\n\t}\r\n\treturn *this;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileBuilder::~FileBuilder()\r\n//-----------------------------------------------------------------------------\r\nFileBuilder::~FileBuilder()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileBuilder::getFileType()\r\n//-----------------------------------------------------------------------------\r\nFileType FileBuilder::getFileType() const\r\n{\r\n    return fileType_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileBuilder::setFileType()\r\n//-----------------------------------------------------------------------------\r\nvoid FileBuilder::setFileType(QString const& newFileType, QString const& libext)\r\n{\r\n    fileType_.type_ = newFileType;\r\n    fileType_.libext_ = libext;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileBuilder::setFileType()\r\n//-----------------------------------------------------------------------------\r\nvoid FileBuilder::setFileType(FileType const& fileType)\r\n{\r\n    fileType_ = fileType;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileBuilder::hasFileType()\r\n//-----------------------------------------------------------------------------\r\nbool FileBuilder::hasFileType(QString const& fileType) const\r\n{\r\n    return fileType_.type_ == fileType;\r\n}\r\n"
  },
  {
    "path": "IPXACTmodels/common/FileBuilder.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: FileBuilder.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 08.09.2015\r\n//\r\n// Description:\r\n// Implementation for ipxact:fileBuilder element.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef FILEBUILDER_H\r\n#define FILEBUILDER_H\r\n\r\n#include <IPXACTmodels/common/BuildModel.h>\r\n\r\n#include <IPXACTmodels/common/Extendable.h>\r\n#include <IPXACTmodels/common/FileType.h>\r\n\r\n#include <IPXACTmodels/ipxactmodels_global.h>\r\n\r\n#include <QString>\r\n#include <QList>\r\n#include <QStringList>\r\n#include <QSharedPointer>\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Contains flags or commands for building the containing source file types.\r\n//-----------------------------------------------------------------------------\r\nclass IPXACTMODELS_EXPORT FileBuilder : public BuildModel, public Extendable\r\n{\r\n\r\npublic:\r\n\r\n\t/*!\r\n\t *  The default constructor.\r\n\t */\r\n\tFileBuilder();\r\n\r\n\t/*!\r\n\t *  The constructor.\r\n\t *\r\n\t *    @param [in] fileType    The type of the file.\r\n\t */\r\n\tFileBuilder(QString const& fileType);\r\n\r\n\t/*!\r\n\t *  Copy constructor.\r\n\t */\r\n\tFileBuilder(FileBuilder const& other);\r\n\r\n\t/*!\r\n\t *  Assignment operator.\r\n\t */\r\n\tFileBuilder &operator=(const FileBuilder &other);\r\n\r\n\t/*!\r\n\t *  The destructor.\r\n\t */\r\n\tvirtual ~FileBuilder();\r\n\r\n\t/*!\r\n\t *  Get the type of the file.\r\n\t *\r\n     *    @return The type of the file.\r\n\t */\r\n\tFileType getFileType() const;\r\n\r\n\t/*!\r\n\t *  Set a file type.\r\n\t *\r\n\t *    @param [in] newFileType     The new file type.\r\n\t *    @param [in] libext\t\t    The new libext attribute for the type.\r\n\t */\r\n\tvoid setFileType(QString const& newFileType, QString const& libext = QString());\r\n\r\n\t/*!\r\n\t *  Set a file type.\r\n\t *\r\n\t *    @param [in] fileType     The new file type.\r\n\t */\r\n\tvoid setFileType(FileType const& fileType);\r\n\r\n\t/*!\r\n\t *  Check if the file builde is meant for a given file type.\r\n\t *\r\n\t *    @param [in] fileType    The file type to be searched for.\r\n     *\r\n     *    @return True, if the file type is contained within the file builder, false otherwise.\r\n\t */\r\n\tbool hasFileType(QString const& fileType) const;\r\n\r\nprivate:\r\n\r\n    //! The file type.\r\n    FileType fileType_;\r\n};\r\n#endif // FILEBUILDER_H\r\n"
  },
  {
    "path": "IPXACTmodels/common/FileBuilderReader.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: FileBuilderReader.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 22.09.2015\r\n//\r\n// Description:\r\n// Reader class for file builder element.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"FileBuilderReader.h\"\r\n\r\n#include <IPXACTmodels/Component/FileReader.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileBuilderReader::createDefaultFileBuilderFrom()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<FileBuilder> FileBuilderReader::createFileBuilderFrom(QDomNode const& fileBuilderNode, \r\n    Document::Revision docRevision)\r\n{\r\n    QSharedPointer<FileBuilder> newFilebuilder (new FileBuilder());\r\n\r\n    Details::parseFileType(fileBuilderNode, newFilebuilder, docRevision);\r\n\r\n    Details::parseBuildModel(fileBuilderNode, newFilebuilder);\r\n\r\n    if (docRevision == Document::Revision::Std14)\r\n    {\r\n        CommonItemsReader::parseVendorExtensions(fileBuilderNode, newFilebuilder);\r\n    }\r\n\r\n    return newFilebuilder;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileBuilderReader::parseFileType()\r\n//-----------------------------------------------------------------------------\r\nvoid FileBuilderReader::Details::parseFileType(QDomNode const& filebuilderNode, \r\n    QSharedPointer<FileBuilder> newFileBuilder, Document::Revision docRevision)\r\n{\r\n    QDomElement fileTypeElement = filebuilderNode.firstChildElement(QStringLiteral(\"ipxact:fileType\"));\r\n\r\n    newFileBuilder->setFileType(FileReader::parseFileType(fileTypeElement, docRevision));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileBuilderReader::parseBuildModel()\r\n//-----------------------------------------------------------------------------\r\nvoid FileBuilderReader::Details::parseBuildModel(QDomNode const& fileBuilderNode,\r\n    QSharedPointer<FileBuilder> newFileBuilder)\r\n{\r\n    QString command = fileBuilderNode.firstChildElement(QStringLiteral(\"ipxact:command\")).firstChild().nodeValue();\r\n    QString flags = fileBuilderNode.firstChildElement(QStringLiteral(\"ipxact:flags\")).firstChild().nodeValue();\r\n    QString replaceFlags = fileBuilderNode.firstChildElement(QStringLiteral(\"ipxact:replaceDefaultFlags\")).firstChild().nodeValue();\r\n\r\n    newFileBuilder->setCommand(command);\r\n    newFileBuilder->setFlags(flags);\r\n    newFileBuilder->setReplaceDefaultFlags(replaceFlags);\r\n}\r\n"
  },
  {
    "path": "IPXACTmodels/common/FileBuilderReader.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: FileBuilderReader.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 22.09.2015\r\n//\r\n// Description:\r\n// Reader class for file builder element.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef FILEBUILDERREADER_H\r\n#define FILEBUILDERREADER_H\r\n\r\n#include \"FileBuilder.h\"\r\n\r\n#include <IPXACTmodels/ipxactmodels_global.h>\r\n#include <IPXACTmodels/common/CommonItemsReader.h>\r\n\r\n#include \"Document.h\"\r\n\r\n#include <QDomNode>\r\n#include <QSharedPointer>\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Reader class for file builder element.\r\n//-----------------------------------------------------------------------------\r\nnamespace FileBuilderReader\r\n{\r\n    /*!\r\n     *  Reads the default file builder.\r\n     *\r\n     *    @param [in] fileBuilderNode     XML description of the default file builder.\r\n     *    @param [in] docRevision         The applied IP-XACT standard revision.\r\n     *\r\n     *    @return The created default file builder.\r\n     */\r\n    IPXACTMODELS_EXPORT QSharedPointer<FileBuilder> createFileBuilderFrom(QDomNode const& fileBuilderNode,\r\n        Document::Revision docRevision);\r\n\r\n    namespace Details\r\n    {\r\n        /*!\r\n         *  Reads the file builder file type.\r\n         *\r\n         *    @param [in] filebuilderNode     XML description of the file builder.\r\n         *    @param [in] newFileBuilder      The selected file builder.\r\n         *    @param [in] docRevision         The applied IP-XACT standard revision.\r\n         */\r\n        void parseFileType(QDomNode const& filebuilderNode, QSharedPointer<FileBuilder> newFileBuilder,\r\n            Document::Revision docRevision);\r\n\r\n        /*!\r\n         *  Reads the file builder command, flags and replace default flags value.\r\n         *\r\n         *    @param [in] filebuilderNode     XML description of the file builder.\r\n         *    @param [in] newFileBuilder      The selected file builder.\r\n         */\r\n        void parseBuildModel(QDomNode const& fileBuilderNode, QSharedPointer<FileBuilder> newFileBuilder);\r\n    }\r\n};\r\n\r\n#endif // FILEBUILDERREADER_H"
  },
  {
    "path": "IPXACTmodels/common/FileBuilderWriter.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: FileBuilderWriter.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 22.09.2015\r\n//\r\n// Description:\r\n// Writer class for fileBuilder element.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"FileBuilderWriter.h\"\r\n#include \"FileBuilder.h\"\r\n#include \"FileType.h\"\r\n\r\n#include <IPXACTmodels/Component/FileWriter.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileBuilderWriter::writeDefaultFileBuilder()\r\n//-----------------------------------------------------------------------------\r\nvoid FileBuilderWriter::writeDefaultFileBuilder(QXmlStreamWriter& writer, QSharedPointer<FileBuilder> fileBuilder,\r\n    Document::Revision docRevision)\r\n{\r\n    writer.writeStartElement(QStringLiteral(\"ipxact:defaultFileBuilder\"));\r\n\r\n    FileWriter::writeFileType(writer, fileBuilder->getFileType(), docRevision);\r\n\r\n    Details::writeBuildModel(writer, fileBuilder);\r\n\r\n    if (docRevision == Document::Revision::Std14)\r\n    {\r\n        CommonItemsWriter::writeVendorExtensions(writer, fileBuilder);\r\n    }\r\n\r\n    writer.writeEndElement(); // ipxact:defaultFileBuilder\r\n}\r\n\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileBuilderWriter::writeFileBuilder()\r\n//-----------------------------------------------------------------------------\r\nvoid FileBuilderWriter::writeFileBuilder(QXmlStreamWriter& writer, QSharedPointer<FileBuilder>fileBuilder, Document::Revision docRevision)\r\n{\r\n    writer.writeStartElement(QStringLiteral(\"ipxact:fileBuilder\"));\r\n\r\n    FileWriter::writeFileType(writer, fileBuilder->getFileType(), docRevision);\r\n\r\n    Details::writeBuildModel(writer, fileBuilder);\r\n\r\n    if (docRevision == Document::Revision::Std14)\r\n    {\r\n        CommonItemsWriter::writeVendorExtensions(writer, fileBuilder);\r\n    }\r\n\r\n    writer.writeEndElement(); // ipxact:fileBuilder\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileBuilderWriter::writeBuildCommand()\r\n//-----------------------------------------------------------------------------\r\nvoid FileBuilderWriter::Details::writeBuildModel(QXmlStreamWriter& writer, QSharedPointer<FileBuilder> fileBuilder)\r\n{\r\n    writer.writeTextElement(QStringLiteral(\"ipxact:command\"), fileBuilder->getCommand());\r\n\r\n    CommonItemsWriter::writeNonEmptyElement(writer, QStringLiteral(\"ipxact:flags\"), fileBuilder->getFlags());\r\n\r\n    CommonItemsWriter::writeNonEmptyElement(writer, \r\n        QStringLiteral(\"ipxact:replaceDefaultFlags\"), fileBuilder->getReplaceDefaultFlags());\r\n}"
  },
  {
    "path": "IPXACTmodels/common/FileBuilderWriter.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: FileBuilderWriter.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 22.09.2015\r\n//\r\n// Description:\r\n// Writer class for fileBuilder element.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef FILEBUILDERWRITER_H\r\n#define FILEBUILDERWRITER_H\r\n\r\n#include \"CommonItemsWriter.h\"\r\n\r\n#include <IPXACTmodels/ipxactmodels_global.h>\r\n\r\n#include <IPXACTmodels/common/Document.h>\r\n\r\n#include <QXmlStreamWriter>\r\n#include <QSharedPointer>\r\n\r\nclass FileBuilder;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Writer class for fileBuilder element.\r\n//-----------------------------------------------------------------------------\r\nnamespace FileBuilderWriter \r\n{\r\n    /*!\r\n     *  Write the default file builder.\r\n     *\r\n     *    @param [in] writer          The used xml writer.\r\n     *    @param [in] nameGroup       The selected file builder.\r\n     *    @param [in] docRevision     The applied IP-XACT standard revision.\r\n     */\r\n    void writeDefaultFileBuilder(QXmlStreamWriter& writer, QSharedPointer<FileBuilder> fileBuilder,\r\n        Document::Revision docRevision);\r\n    void writeFileBuilder(QXmlStreamWriter& writer, QSharedPointer<FileBuilder>fileBuilder, Document::Revision docRevision);\r\n    namespace Details\r\n    {\r\n\r\n        /*!\r\n         *  Write the build model of the file builder.\r\n         *\r\n         *    @param [in] writer          Used XML writer.\r\n         *    @param [in] fileBuilder     The selected file builder.\r\n         */\r\n        void writeBuildModel(QXmlStreamWriter& writer, QSharedPointer<FileBuilder> fileBuilder);\r\n    }\r\n};\r\n\r\n#endif // FILEBUILDERWRITER_H"
  },
  {
    "path": "IPXACTmodels/common/FileType.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: FileType.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 10.09.2015\r\n//\r\n// Description:\r\n// NameSpace FileTypes is used to store functions related to file types.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"FileType.h\"\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileTypes::isIpXactFileType()\r\n//-----------------------------------------------------------------------------\r\nbool FileTypes::isIpXactFileType(QString const& fileType, Document::Revision docRevision )\r\n{\r\n\tif (docRevision == Document::Revision::Std14)\r\n\t{\r\n\t\treturn FILE_TYPES.contains(fileType);\r\n\t}\r\n\telse if (docRevision == Document::Revision::Std22)\r\n\t{\r\n\r\n\t\treturn FILE_TYPES.contains(fileType) || FILE_TYPES_2022.contains(fileType);\r\n\t}\r\n\telse\r\n\t{\r\n\t\treturn false;\r\n\t}\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileType::getFileTypes()\r\n//-----------------------------------------------------------------------------\r\nQStringList FileTypes::getFileTypes( QSettings& settings, QString const& fileSuffix )\r\n{\r\n    QStringList types;\r\n\r\n\tsettings.beginGroup(QStringLiteral(\"FileTypes\"));\r\n\tfor (QString const& type : settings.childGroups())\r\n    {\r\n\t\tQString extensions = settings.value(type + QStringLiteral(\"/Extensions\")).toString();\r\n\r\n\t\tfor (QString const& extension : extensions.split(QLatin1Char(';'), Qt::SkipEmptyParts))\r\n        {\r\n\t\t\tif (extension.compare(fileSuffix, Qt::CaseInsensitive) == 0)\r\n            {\r\n\t\t\t\ttypes.append(type);\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n    settings.endGroup();\r\n\r\n\treturn types;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileType::getFileTypes()\r\n//-----------------------------------------------------------------------------\r\nQStringList FileTypes::getFileTypes( QSettings& settings, QFileInfo const& file )\r\n{\r\n    return FileTypes::getFileTypes(settings, file.suffix());\r\n}\r\n"
  },
  {
    "path": "IPXACTmodels/common/FileType.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: FileType.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 10.09.2015\r\n//\r\n// Description:\r\n// NameSpace FileTypes is used to store functions related to file types.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef FILETYPE_H\r\n#define FILETYPE_H\r\n\r\n#include <IPXACTmodels/ipxactmodels_global.h>\r\n\r\n#include \"Document.h\"\r\n\r\n#include <QString>\r\n#include <QSettings>\r\n#include <QStringList>\r\n#include <QFileInfo>\r\n\r\nstruct FileType\r\n{\r\n\tQString type_;\r\n\tQString libext_;\r\n\r\n\tFileType() : type_(), libext_() {};\r\n\r\n\texplicit FileType(QString const& fileType, QString const& libext = QString()) :\r\n\t\ttype_(fileType), libext_(libext) {};\r\n\r\n\tbool operator==(FileType const& rhs) const { return type_ == rhs.type_ && libext_ == rhs.libext_; };\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n//! NameSpace FileTypes is used to store functions related to file types.\r\n//-----------------------------------------------------------------------------\r\nnamespace FileTypes\r\n{\r\n\t//! The file types specified in the IP-Xact\r\n\tconst QStringList FILE_TYPES = {\r\n\t\tQStringLiteral(\"asmSource\"),\r\n\t\tQStringLiteral(\"cSource\"),\r\n\t\tQStringLiteral(\"cppSource\"),\r\n\t\tQStringLiteral(\"eSource\"),\r\n\t\tQStringLiteral(\"OVASource\"),\r\n\t\tQStringLiteral(\"perlSource\"),\r\n\t\tQStringLiteral(\"pslSource\"),\r\n\t\tQStringLiteral(\"SVASource\"),\r\n\t\tQStringLiteral(\"tclSource\"),\r\n\t\tQStringLiteral(\"veraSource\"),\r\n\t\tQStringLiteral(\"systemCSource\"),\r\n\t\tQStringLiteral(\"systemCSource-2.0\"),\r\n\t\tQStringLiteral(\"systemCSource-2.0.1\"),\r\n\t\tQStringLiteral(\"systemCSource-2.1\"),\r\n\t\tQStringLiteral(\"systemCSource-2.2\"),\r\n\t\tQStringLiteral(\"systemVerilogSource\"),\r\n\t\tQStringLiteral(\"systemVerilogSource-3.0\"),\r\n\t\tQStringLiteral(\"systemVerilogSource-3.1\"),\r\n\t\tQStringLiteral(\"systemVerilogSource-3.1a\"),\r\n\t\tQStringLiteral(\"verilogSource\"),\r\n\t\tQStringLiteral(\"verilogSource-95\"),\r\n\t\tQStringLiteral(\"verilogSource-2001\"),\r\n\t\tQStringLiteral(\"verilogSource-2005\"),\r\n\t\tQStringLiteral(\"vhdlSource\"),\r\n\t\tQStringLiteral(\"vhdlSource-87\"),\r\n\t\tQStringLiteral(\"vhdlSource-93\"),\r\n\t\tQStringLiteral(\"swObject\"),\r\n\t\tQStringLiteral(\"swObjectLibrary\"),\r\n\t\tQStringLiteral(\"vhdlBinaryLibrary\"),\r\n\t\tQStringLiteral(\"verilogBinaryLibrary\"),\r\n\t\tQStringLiteral(\"executableHdl\"),\r\n\t\tQStringLiteral(\"unelaboratedHdl\"),\r\n\t\tQStringLiteral(\"systemVerilogSource\"),\r\n\t\tQStringLiteral(\"systemVerilogSource-3.0\"),\r\n\t\tQStringLiteral(\"systemVerilogSource-3.1\"),\r\n\t\tQStringLiteral(\"systemVerilogSource-3.1a\"),\r\n\t\tQStringLiteral(\"SDC\"),\r\n\t\tQStringLiteral(\"unknown\")\r\n\t};\r\n\r\n\tconst QStringList FILE_TYPES_2022\r\n\t{\r\n\t\tQStringLiteral(\"vhdlSource2002\"),\r\n\t\tQStringLiteral(\"vhdlSource2008\"),\r\n\t\tQStringLiteral(\"systemVerilogSource-2009\"),\r\n\t\tQStringLiteral(\"systemVerilogSource-2012\"),\r\n\t\tQStringLiteral(\"systemVerilogSource-2017\"),\r\n\t\tQStringLiteral(\"vhdlAmsSource\"),\r\n\t\tQStringLiteral(\"verilogAmsSource\"),\r\n\t\tQStringLiteral(\"systemCAmsSource\"),\r\n\t\tQStringLiteral(\"libertySource\"),\r\n\t\tQStringLiteral(\"spiceSource\"),\r\n\t\tQStringLiteral(\"systemRDL\"),\r\n\t\tQStringLiteral(\"systemRDL-1.0\"),\r\n\t\tQStringLiteral(\"systemRDL-2.0\"),\r\n\t\tQStringLiteral(\"systemCSource-2.3\"),\r\n\t\tQStringLiteral(\"systemCSourceBinaryLibrary\")\r\n\t};\r\n\r\n\t/*!\r\n\t *  Checks if the file type belongs to the specified file types.\r\n\t *\r\n\t *    @param [in] fileType    The file type to check.\r\n     *\r\n     *    @return True if the file type is one of the specified ones, false otherwise.\r\n\t */\r\n\tIPXACTMODELS_EXPORT bool isIpXactFileType(QString const& fileType, Document::Revision docRevision);\r\n\r\n\t/*!\r\n\t *  Get the file types which are associated with the given file suffix.\r\n\t *\r\n\t *    @param [in] settings    The settings instance used to manage Kactus2 settings.\r\n\t *    @param [in] fileSuffix  The file suffix to identify the file type.\r\n     *\r\n     *    @return QStringlist containing the file types.\r\n\t */\r\n\tIPXACTMODELS_EXPORT QStringList getFileTypes(QSettings& settings, QString const& fileSuffix);\r\n\r\n    /*!\r\n\t *  Get the file types which are associated with the given file suffix.\r\n\t *\r\n\t *    @param [in] settings    The settings instance used to manage the Kactus2 settings.\r\n\t *    @param [in] file        Represents the file which file types are searched.\r\n     *\r\n     *    @return The file types.\r\n\t */\r\n\tIPXACTMODELS_EXPORT QStringList getFileTypes(QSettings& settings, QFileInfo const& file);\r\n\r\n}\r\n\r\n#endif // FILETYPE_H\r\n"
  },
  {
    "path": "IPXACTmodels/common/GenericVendorExtension.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: GenericVendorExtension.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Esko Pekkarinen\r\n// Date: 8.5.2014\r\n//\r\n// Description:\r\n// Generic implementation for any vendor extension.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"GenericVendorExtension.h\"\r\n\r\n#include <QDomNode>\r\n#include <QObject>\r\n#include <QStringList>\r\n\r\n//! Description element name.\r\nnamespace\r\n{\r\n    const QString DESCRIPTION = QStringLiteral(\"Description\");\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: GenericVendorExtension::GenericVendorExtension()\r\n//-----------------------------------------------------------------------------\r\nGenericVendorExtension::GenericVendorExtension(QDomNode const& extensionNode, GenericVendorExtension* parent):\r\nparent_(parent)\r\n{\r\n    QStringList combiName = extensionNode.nodeName().split(QLatin1Char(':'));\r\n    if (combiName.size() == 2)\r\n    {\r\n        nameSpace_ = combiName.first();\r\n    }\r\n    name_ = combiName.last();\r\n\r\n    QDomNamedNodeMap attributes = extensionNode.attributes();\r\n    const int attributeCount = attributes.length();\r\n    for (int i = 0; i < attributeCount; ++i)\r\n    {\r\n        QDomNode attribute = attributes.item(i);\r\n        attributes_.append(qMakePair(attribute.nodeName(), attribute.nodeValue()));\r\n    }\r\n\r\n    QDomNode firstChildNode = extensionNode.firstChild();\r\n    if (!firstChildNode.isNull())\r\n    {\r\n        int startIndex = 0;\r\n        if (firstChildNode.isText())\r\n        {\r\n            value_ = firstChildNode.nodeValue();\r\n            startIndex = 1;\r\n        }\r\n\r\n        QDomNodeList childNodes = extensionNode.childNodes();\r\n\r\n        const int childCount = childNodes.count();\r\n        for (int i = startIndex; i < childCount; ++i)\r\n        {\r\n            QDomNode childNode = childNodes.at(i);\r\n            children_.append(new GenericVendorExtension(childNode, this));\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: GenericVendorExtension::~GenericVendorExtension()\r\n//-----------------------------------------------------------------------------\r\nGenericVendorExtension::~GenericVendorExtension()\r\n{\r\n    for (int i = children_.size() - 1; i >= 0; --i)\r\n    {\r\n        GenericVendorExtension* child = children_.at(i);\r\n        delete child;\r\n        child = nullptr;\r\n    }\r\n\r\n    children_.clear();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: GenericVendorExtension::GenericVendorExtension()\r\n//-----------------------------------------------------------------------------\r\nGenericVendorExtension::GenericVendorExtension(GenericVendorExtension const& other) :\r\n    nameSpace_(other.nameSpace_),\r\n    name_(other.name_),\r\n    value_(other.value_),\r\n    attributes_(other.attributes_)\r\n{\r\n    children_.clear();\r\n\r\n    for (auto const& otherChild : other.children_)\r\n    {\r\n        auto newChild = new GenericVendorExtension(*otherChild);\r\n        newChild->setParent(this);\r\n        children_.append(newChild);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: GenericVendorExtension::operator=()\r\n//-----------------------------------------------------------------------------\r\nGenericVendorExtension& GenericVendorExtension::operator=(const GenericVendorExtension& other)\r\n{\r\n    if (this != &other)\r\n    {\r\n        nameSpace_ = other.nameSpace_;\r\n        name_ = other.name_;\r\n        value_ = other.value_;\r\n        attributes_ = other.attributes_;\r\n        children_ = other.children_;\r\n        parent_ = other.parent_;\r\n    }\r\n\r\n    return *this;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: GenericVendorExtension::isSame()\r\n//-----------------------------------------------------------------------------\r\nbool GenericVendorExtension::isSame(const GenericVendorExtension& otherItem) const\r\n{\r\n    return this == &otherItem;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: GenericVendorExtension::clone()\r\n//-----------------------------------------------------------------------------\r\nGenericVendorExtension* GenericVendorExtension::clone() const\r\n{\r\n    return new GenericVendorExtension(*this);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: GenericVendorExtension::type()\r\n//-----------------------------------------------------------------------------\r\nQString GenericVendorExtension::type() const\r\n{\r\n    return name_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: GenericVendorExtension::write()\r\n//-----------------------------------------------------------------------------\r\nvoid GenericVendorExtension::write(QXmlStreamWriter& writer) const\r\n{\r\n    writeNode(*this, writer);    \r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: GenericVendorExtension::nameSpace()\r\n//-----------------------------------------------------------------------------\r\nQString GenericVendorExtension::nameSpace() const\r\n{\r\n    return nameSpace_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: GenericVendorExtension::setNameSpace()\r\n//-----------------------------------------------------------------------------\r\nvoid GenericVendorExtension::setNameSpace(QString const& newNameSpace)\r\n{\r\n    nameSpace_ = newNameSpace;\r\n\r\n    if (hasDescription())\r\n    {\r\n        setDescription(getDescription());\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: GenericVendorExtension::name()\r\n//-----------------------------------------------------------------------------\r\nQString GenericVendorExtension::name() const\r\n{\r\n    return name_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: GenericVendorExtension::setName()\r\n//-----------------------------------------------------------------------------\r\nvoid GenericVendorExtension::setName(QString const& name)\r\n{\r\n    name_ = name;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: GenericVendorExtension::value()\r\n//-----------------------------------------------------------------------------\r\nQString GenericVendorExtension::value() const\r\n{\r\n    return value_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: GenericVendorExtension::setValue()\r\n//-----------------------------------------------------------------------------\r\nvoid GenericVendorExtension::setValue(QString const& value)\r\n{\r\n    value_ = value;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: GenericVendorExtension::attributeValue()\r\n//-----------------------------------------------------------------------------\r\nQString GenericVendorExtension::attributeValue(QString const& attributeName) const\r\n{\r\n    auto target = std::find_if(attributes_.cbegin(), attributes_.cend(), \r\n        [attributeName](QPair<QString, QString> const& attribute) {return attribute.first == attributeName;});\r\n\r\n    if (target == attributes_.cend())\r\n    {\r\n        return QString();\r\n    }\r\n\r\n    return target->second;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: GenericVendorExtension::setAttributeValue()\r\n//-----------------------------------------------------------------------------\r\nvoid GenericVendorExtension::setAttributeValue(QString const& attributeName, QString const& attributeValue)\r\n{\r\n    auto target = std::find_if(attributes_.begin(), attributes_.end(),\r\n        [attributeName](QPair<QString, QString> const& attribute) {return attribute.first == attributeName; });\r\n\r\n    if (target == attributes_.end())\r\n    {\r\n        attributes_.append(qMakePair(attributeName, attributeValue));\r\n    }\r\n    else\r\n    {\r\n        target->second = attributeValue;\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: GenericVendorExtension::description()\r\n//-----------------------------------------------------------------------------\r\nQString GenericVendorExtension::getDescription() const\r\n{\r\n    for (auto childItem : children_)\r\n    {\r\n        if (childItem->name().endsWith(DESCRIPTION))\r\n        {\r\n            return childItem->value();\r\n        }\r\n    }\r\n\r\n    return QString();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: GenericVendorExtension::setDescription()\r\n//-----------------------------------------------------------------------------\r\nvoid GenericVendorExtension::setDescription(QString const& newDescription)\r\n{\r\n    if (auto index = getDescriptionIndex(); index != -1)\r\n    {\r\n        GenericVendorExtension* childItem = children_[index];\r\n\r\n        if (newDescription.isEmpty())\r\n        {\r\n            delete childItem;\r\n            childItem = nullptr;\r\n            children_.remove(index);\r\n        }\r\n        else\r\n        {\r\n            childItem->setValue(newDescription);\r\n            childItem->setNameSpace(nameSpace());\r\n        }\r\n    }\r\n    else if (!newDescription.isEmpty())\r\n    {\r\n        auto newDescriptionChild(new GenericVendorExtension());\r\n        newDescriptionChild->setNameSpace(nameSpace());\r\n        newDescriptionChild->setName(DESCRIPTION);\r\n        newDescriptionChild->setValue(newDescription);\r\n        newDescriptionChild->setParent(this);\r\n\r\n        children_.append(newDescriptionChild);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: GenericVendorExtension::hasDescription()\r\n//-----------------------------------------------------------------------------\r\nbool GenericVendorExtension::hasDescription() const\r\n{\r\n    return std::any_of(children_.cbegin(), children_.cend(),\r\n        [](auto const& child){ return child->name().endsWith(DESCRIPTION); });\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: GenericVendorExtension::getDescriptionIndex()\r\n//-----------------------------------------------------------------------------\r\nint GenericVendorExtension::getDescriptionIndex() const\r\n{\r\n    for (int i = 0; i < children_.count(); ++i)\r\n    {\r\n        if (children_.at(i))\r\n        {\r\n            return i;\r\n        }\r\n    }\r\n\r\n    return -1;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: GenericVendorExtension::writeNode()\r\n//-----------------------------------------------------------------------------\r\nvoid GenericVendorExtension::writeNode(GenericVendorExtension const& node, QXmlStreamWriter& writer) const\r\n{\r\n    if (node.nameSpace().isEmpty() && node.name().isEmpty() && node.value().isEmpty() &&\r\n        node.attributes_.isEmpty() && node.children_.isEmpty())\r\n    {\r\n        return;\r\n    }\r\n\r\n    QString combinedName;\r\n    if (node.nameSpace().isEmpty())\r\n    {\r\n        combinedName = node.name();\r\n    }\r\n    else\r\n    {\r\n        combinedName = node.nameSpace() + QLatin1Char(':') + node.name();\r\n    } \r\n\r\n    writer.writeStartElement(combinedName);\r\n    writeAttributes(node, writer);\r\n    if (node.value().isEmpty() == false)\r\n    {\r\n        writer.writeCharacters(node.value());\r\n    }\r\n    writeChildNodes(node, writer);\r\n    writer.writeEndElement();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: GenericVendorExtension::writeAttributes()\r\n//-----------------------------------------------------------------------------\r\nvoid GenericVendorExtension::writeAttributes(GenericVendorExtension const& node, QXmlStreamWriter& writer) const\r\n{\r\n    for (auto const& [name, value] : node.attributes_)\r\n    {      \r\n        writer.writeAttribute(name, value);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: GenericVendorExtension::writeChildNodes()\r\n//-----------------------------------------------------------------------------\r\nvoid GenericVendorExtension::writeChildNodes(GenericVendorExtension const& node, QXmlStreamWriter& writer) const\r\n{\r\n    for (auto child : node.children_)\r\n    {\r\n        writeNode(*child, writer);                \r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: GenericVendorExtension::getChildExtensions()\r\n//-----------------------------------------------------------------------------\r\nQVector<GenericVendorExtension*>& GenericVendorExtension::getChildExtensions()\r\n{\r\n    return children_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: GenericVendorExtension::removeIndexedChildExtensions()\r\n//-----------------------------------------------------------------------------\r\nvoid GenericVendorExtension::removeIndexedChildExtensions(int const& startIndex, int const& endIndex)\r\n{\r\n    for (int i = endIndex; i >= startIndex; --i)\r\n    {\r\n        GenericVendorExtension* child = children_.at(i);\r\n        children_.removeAt(i);\r\n        delete child;\r\n        child = nullptr;\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: GenericVendorExtension::getParent()\r\n//-----------------------------------------------------------------------------\r\nGenericVendorExtension* GenericVendorExtension::getParent() const\r\n{\r\n    return parent_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: GenericVendorExtension::setParent()\r\n//-----------------------------------------------------------------------------\r\nvoid GenericVendorExtension::setParent(GenericVendorExtension* newParent)\r\n{\r\n    parent_ = newParent;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: GenericVendorExtension::getAttributes()\r\n//-----------------------------------------------------------------------------\r\nQVector<QPair<QString, QString> > GenericVendorExtension::getAttributes() const\r\n{\r\n    return attributes_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: GenericVendorExtension::setNewAttributes()\r\n//-----------------------------------------------------------------------------\r\nvoid GenericVendorExtension::setNewAttributes(QVector<QPair<QString, QString> > newAttributes)\r\n{\r\n    attributes_ = newAttributes;\r\n}\r\n"
  },
  {
    "path": "IPXACTmodels/common/GenericVendorExtension.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: GenericVendorExtension.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Esko Pekkarinen\r\n// Date: 8.5.2014\r\n//\r\n// Description:\r\n// Generic implementation for any vendor extension.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef GENERICVENDOREXTENSION_H\r\n#define GENERICVENDOREXTENSION_H\r\n\r\n#include \"VendorExtension.h\"\r\n\r\n#include <IPXACTmodels/ipxactmodels_global.h>\r\n\r\n#include <QDomNode>\r\n#include <QList>\r\n#include <QObject>\r\n#include <QXmlStreamWriter>\r\n\r\n//-----------------------------------------------------------------------------\r\n// class GenericVendorExtension.\r\n//-----------------------------------------------------------------------------\r\nclass IPXACTMODELS_EXPORT GenericVendorExtension : public VendorExtension\r\n{\r\n\r\npublic:\r\n\r\n    /*!\r\n     *  Default constructor.\r\n     */\r\n    GenericVendorExtension() = default;\r\n\r\n    /*!\r\n\t *  The constructor.\r\n\t *\r\n\t *    @param [in] extensionNode   The DOM node representation of the vendor extension.\r\n     *    @param [in] parent          Parent extension.\r\n\t */\r\n\tGenericVendorExtension(QDomNode const& extensionNode, GenericVendorExtension* parent = nullptr);\r\n\r\n    /*!\r\n     *  Copy constructor.\r\n     *\r\n     *    @param [in] other   The copied generic vendor extension.\r\n     */\r\n    GenericVendorExtension(GenericVendorExtension const& other);\r\n\r\n    /*!\r\n     *  Assignment operator.\r\n     *\r\n     *    @param [in] rhs     The assigned generic vendor extension.\r\n     */\r\n    GenericVendorExtension& operator=(GenericVendorExtension const& rhs);\r\n\r\n    /*!\r\n     *  Check whether this is the selected generic vendor extension.\r\n     *\r\n     *    @param [in] otherItem   The selected generic vendor extension.\r\n     *\r\n     *    @return True, if the selected generic vendor extension is this, false otherwise.\r\n     */\r\n    bool isSame(const GenericVendorExtension& otherItem) const;\r\n\r\n    /*!\r\n     *  Clones the vendor extension.\r\n     *\r\n     *    @return The clone copy of the vendor extension.\r\n     */\r\n    virtual GenericVendorExtension* clone() const;\r\n\r\n\t/*!\r\n\t *  The destructor.\r\n\t */\r\n\tvirtual ~GenericVendorExtension();\r\n\r\n    /*!\r\n     *  Returns a type identifier for the vendor extension.\r\n     *\r\n     *    @return A type identifier of the vendor extension.\r\n     */\r\n    virtual QString type() const;\r\n\r\n    /*!\r\n     *  Writes the vendor extension to XML.\r\n     *\r\n     *    @param [in] writer   The writer used for writing the XML.\r\n     */\r\n    virtual void write(QXmlStreamWriter& writer) const;\r\n\r\n    /*!\r\n     *  Get the name space.\r\n     *\r\n     *    @return The name space.\r\n     */\r\n    QString nameSpace() const;\r\n\r\n    /*!\r\n     *  Set a new name space.\r\n     *\r\n     *    @param [in] newNameSpace    The new name space.\r\n     */\r\n    void setNameSpace(QString const& newNameSpace);\r\n\r\n    /*!\r\n     *  Get the name.\r\n     *\r\n     *    @return The name.\r\n     */\r\n    QString name() const;\r\n\r\n    /*!\r\n     *  Set a new name.\r\n     *\r\n     *    @param [in] name    The new name.\r\n     */\r\n    void setName(QString const& name);\r\n\r\n    /*!\r\n     *  Get the value.\r\n     *\r\n     *    @return The value.\r\n     */\r\n    QString value() const;\r\n\r\n    /*!\r\n     *  Set a new value.\r\n     *\r\n     *    @param [in] value   The new value.\r\n     */\r\n    void setValue(QString const& value);\r\n\r\n    /*!\r\n     *  Get the value of the selected attribute.\r\n     *\r\n     *    @param [in] attributeName   Name of the selected attribute.\r\n     *\r\n     *    @return Value of the selected attribute.\r\n     */\r\n    QString attributeValue(QString const& attributeName) const;\r\n\r\n    /*!\r\n     *  Set a new value for the selected attribute.\r\n     *\r\n     *    @param [in] attributeName   Name of the selected attribute.\r\n     *    @param [in] attributeValue  New value for the selected attribute.\r\n     */\r\n    void setAttributeValue(QString const& attributeName, QString const& attributeValue);\r\n\r\n    /*!\r\n     *  Get extension description.\r\n     *\r\n     *    @return Extension description.\r\n     */\r\n    QString getDescription() const;\r\n\r\n    /*!\r\n     *  Set a new description for the extension.\r\n     *\r\n     *    @param [in] newDescription  The new description.\r\n     */\r\n    void setDescription(QString const& newDescription);\r\n\r\n    /*!\r\n     *  Check if this extension has a description child element.\r\n     *\r\n     *    @return True, if a description is found, false otherwise.\r\n     */\r\n    bool hasDescription() const;\r\n\r\n    /*!\r\n     *  Get the index of the description child element..\r\n     *\r\n     *    @return Index of the description child element.\r\n     */\r\n    int getDescriptionIndex() const;\r\n\r\n    /*!\r\n     *  Get a list of the contained child generic extensions.\r\n     *\r\n     *    @return Reference to the list of child generic extensions.\r\n     */\r\n    QVector<GenericVendorExtension*>& getChildExtensions();\r\n\r\n    /*!\r\n     *  Remove the selected indexed child extensions.\r\n     *\r\n     *    @param [in] startIndex  The first index to be removed.\r\n     *    @param [in] endIndex    The last index to be removed.\r\n     */\r\n    void removeIndexedChildExtensions(int const& startIndex, int const& endIndex);\r\n\r\n    /*!\r\n     *  Get the parent vendor extension.\r\n     *\r\n     *    @return The parent vendor extension.\r\n     */\r\n    GenericVendorExtension* getParent() const;\r\n\r\n    /*!\r\n     *  Set a new parent vendor extension.\r\n     *\r\n     *    @param [in] newParent   The new parent vendor extension.\r\n     */\r\n    void setParent(GenericVendorExtension* newParent);\r\n\r\n    /*!\r\n     *  Get a list of the attributes.\r\n     *\r\n     *    @return List of attribute type / value pairs.\r\n     */\r\n    QVector<QPair<QString, QString> > getAttributes() const;\r\n\r\n    /*!\r\n     *  Set new attributes.\r\n     *\r\n     *    @param [in] newAttributes   List of new attributes.\r\n     */\r\n    void setNewAttributes(QVector<QPair<QString, QString> > newAttributes);\r\n\r\nprivate:\r\n\r\n    /*!\r\n     *  Writes a DOM node to XML using a given XML writer.\r\n     *\r\n     *    @param [in] node        The DOM node to write.\r\n     *    @param [in] writer      The XML writer to use.\r\n     */\r\n    void writeNode(GenericVendorExtension const& node, QXmlStreamWriter& writer) const;\r\n\r\n    /*!\r\n     *  Writes all child noted of a DOM node to XML using a given XML writer.\r\n     *\r\n     *    @param [in] node        The DOM node to write.\r\n     *    @param [in] writer      The XML writer to use.\r\n     */\r\n    void writeChildNodes(GenericVendorExtension const& node, QXmlStreamWriter& writer) const;\r\n\r\n    /*!\r\n     *  Writes all the attributes of a DOM node to XML using a given XML writer.\r\n     *\r\n     *    @param [in] node        The DOM node to write.\r\n     *    @param [in] writer      The XML writer to use.\r\n     */\r\n    void writeAttributes(GenericVendorExtension const& node, QXmlStreamWriter& writer) const;\r\n    \r\n\t//-----------------------------------------------------------------------------\r\n\t// Data.\r\n\t//-----------------------------------------------------------------------------\r\n\r\n    //! Namespace for the element.\r\n    QString nameSpace_;\r\n\r\n    //! Name of the extension.\r\n    QString name_;\r\n\r\n    //! Value of the extension.\r\n    QString value_;\r\n\r\n    //! List of attribute values.\r\n    QVector<QPair<QString, QString> > attributes_;\r\n\r\n    //! List of child extensions.\r\n    QVector<GenericVendorExtension*> children_;\r\n\r\n    //! The parent generic vendor extension.\r\n    GenericVendorExtension* parent_ = nullptr;\r\n};\r\n\r\nQ_DECLARE_METATYPE(GenericVendorExtension*)\r\n\r\n#endif // GENERICVENDOREXTENSION_H\r\n\r\n"
  },
  {
    "path": "IPXACTmodels/common/ModuleParameter.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ModuleParameter.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 08.09.2015\r\n//\r\n// Description:\r\n// Implementation for ipxact:moduleParameter element.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"ModuleParameter.h\"\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ModuleParameter::ModuleParameter()\r\n//-----------------------------------------------------------------------------\r\nModuleParameter::ModuleParameter() :\r\nParameter()\r\n{\r\n    \r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ModuleParameter::ModuleParameter()\r\n//-----------------------------------------------------------------------------\r\nModuleParameter::ModuleParameter(const ModuleParameter& other) :\r\nParameter(other),\r\nisPresent_(other.isPresent_)\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ModuleParameter::~ModuleParameter()\r\n//-----------------------------------------------------------------------------\r\nModuleParameter::~ModuleParameter()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ModuleParameter::operator =()\r\n//-----------------------------------------------------------------------------\r\nModuleParameter& ModuleParameter::operator =(const ModuleParameter& other)\r\n{\r\n    if (this != &other)\r\n    {\r\n        Parameter::operator=(other);\r\n        isPresent_ = other.isPresent_;\r\n    }\r\n\r\n    return *this;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ModuleParameter::getDataType()\r\n//-----------------------------------------------------------------------------\r\nQString ModuleParameter::getDataType() const\r\n{\r\n    return getAttribute(QStringLiteral(\"dataType\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ModuleParameter::setDataType()\r\n//-----------------------------------------------------------------------------\r\nvoid ModuleParameter::setDataType(QString const& newDataType)\r\n{\r\n    setAttribute(QStringLiteral(\"dataType\"), newDataType);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ModuleParameter::getUsageType()\r\n//-----------------------------------------------------------------------------\r\nQString ModuleParameter::getUsageType() const\r\n{\r\n    return getAttribute(QStringLiteral(\"usageType\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ModuleParameter::setUsageType()\r\n//-----------------------------------------------------------------------------\r\nvoid ModuleParameter::setUsageType(QString const& newUsageType)\r\n{\r\n    setAttribute(QStringLiteral(\"usageType\"), newUsageType);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ModuleParameter::getDataTypeDefinition()\r\n//-----------------------------------------------------------------------------\r\nQString ModuleParameter::getDataTypeDefinition() const\r\n{\r\n    return getAttribute(QStringLiteral(\"dataTypeDefinition\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ModuleParameter::setDataTypeDefinition()\r\n//-----------------------------------------------------------------------------\r\nvoid ModuleParameter::setDataTypeDefinition(QString const& dataTypeDef)\r\n{\r\n    setAttribute(QStringLiteral(\"dataTypeDefinition\"), dataTypeDef);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ModuleParameter::getIsPresent()\r\n//-----------------------------------------------------------------------------\r\nQString ModuleParameter::getIsPresent() const\r\n{\r\n    return isPresent_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ModuleParameter::setIsPresent()\r\n//-----------------------------------------------------------------------------\r\nvoid ModuleParameter::setIsPresent(QString const& newIsPresent)\r\n{\r\n    isPresent_ = newIsPresent;\r\n}\r\n"
  },
  {
    "path": "IPXACTmodels/common/ModuleParameter.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ModuleParameter.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 08.09.2015\r\n//\r\n// Description:\r\n// Implementation for ipxact:moduleParameter element.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef MODULEPARAMETER_H\r\n#define MODULEPARAMETER_H\r\n\r\n#include <IPXACTmodels/ipxactmodels_global.h>\r\n\r\n#include \"Parameter.h\"\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Implementation for ipxact:moduleParameter element.\r\n//-----------------------------------------------------------------------------\r\nclass IPXACTMODELS_EXPORT ModuleParameter : public Parameter\r\n{\r\npublic:\r\n\r\n    /*!\r\n     *  The default constructor.\r\n     */\r\n    ModuleParameter();\r\n\r\n\t//! Copy constructor\r\n    ModuleParameter(const ModuleParameter& other);\r\n\r\n    //! The destructor\r\n    virtual ~ModuleParameter();\r\n\r\n\t//! Assignment operator\r\n    ModuleParameter& operator=(const ModuleParameter& other);\r\n\r\n    /*!\r\n     *  Get the data type attribute.\r\n     *\r\n     *    @return The data type.\r\n     */\r\n    QString getDataType() const;\r\n\r\n    /*!\r\n     *  Set the data type attribute.\r\n     *\r\n     *    @param [in] newDataType     The new data type.\r\n     */\r\n    void setDataType(QString const& newDataType);\r\n\r\n    /*!\r\n     *  Get the usage type attribute.\r\n     *\r\n     *    @return The usage type.\r\n     */\r\n    QString getUsageType() const;\r\n\r\n    /*!\r\n     *  Set the usage type attribute.\r\n     *\r\n     *    @param [in] newUsageType    The new usaget type.\r\n     */\r\n    void setUsageType(QString const& newUsageType);\r\n\r\n    /*!\r\n     *  Get the data type definition attribute.\r\n     *\r\n     *    @return The data type definition.\r\n     */\r\n    QString getDataTypeDefinition() const;\r\n\r\n    /*!\r\n     *  Set the data type definition attribute.\r\n     *\r\n     *    @param [in] dataTypeDef    The new data type definition.\r\n     */\r\n    void setDataTypeDefinition(QString const& dataTypeDef);\r\n\r\n    /*!\r\n     *  Get the presence.\r\n     *\r\n     *    @return The presence.\r\n     */\r\n    QString getIsPresent() const;\r\n\r\n    /*!\r\n     *  Set the presence.\r\n     *\r\n     *    @param [in] newIsPresent    The new presence expression.\r\n     */\r\n    void setIsPresent(QString const& newIsPresent);\r\n\r\nprivate:\r\n \r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! The presence of the module parameter.\r\n    QString isPresent_;\r\n};\r\n\r\n#endif /* PARAMETER_H */\r\n"
  },
  {
    "path": "IPXACTmodels/common/ModuleParameterReader.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ModuleParameterReader.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 09.09.2015\r\n//\r\n// Description:\r\n// XML reader for IP-XACT module parameter element.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"ModuleParameterReader.h\"\r\n#include \"CommonItemsReader.h\"\r\n#include \"NameGroupReader.h\"\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ModuleParameterReader::createModuleParameterFrom()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<ModuleParameter> ModuleParameterReader::createModuleParameterFrom(\r\n    QDomNode const& moduleParameterNode, Document::Revision docRevision)\r\n{\r\n    QSharedPointer<ModuleParameter> newModuleParameter (new ModuleParameter());\r\n\r\n    ParameterReader::Details::parseAttributes(moduleParameterNode, newModuleParameter);\r\n\r\n    NameGroupReader::parseNameGroup(moduleParameterNode, newModuleParameter);\r\n\r\n    ParameterReader::Details::parseVectors(moduleParameterNode, newModuleParameter, docRevision);\r\n\r\n    ParameterReader::Details::parseArrays(moduleParameterNode, newModuleParameter, docRevision);\r\n\r\n    ParameterReader::Details::parseValue(moduleParameterNode, newModuleParameter);\r\n\r\n    CommonItemsReader::parseVendorExtensions(moduleParameterNode, newModuleParameter);\r\n\r\n    Details::parseIsPresent(moduleParameterNode, newModuleParameter, docRevision);\r\n\r\n    return newModuleParameter;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ModuleParameterReader::parseIsPresent()\r\n//-----------------------------------------------------------------------------\r\nvoid ModuleParameterReader::Details::parseIsPresent(QDomNode const& moduleParameterNode,\r\n    QSharedPointer<ModuleParameter> moduleParameter, Document::Revision docRevision)\r\n{\r\n    if (docRevision == Document::Revision::Std14)\r\n    {\r\n        QDomElement presenceElement = moduleParameterNode.firstChildElement(QStringLiteral(\"ipxact:isPresent\"));\r\n        moduleParameter->setIsPresent(CommonItemsReader::parseIsPresent(presenceElement));\r\n    }\r\n}"
  },
  {
    "path": "IPXACTmodels/common/ModuleParameterReader.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ModuleParameterReader.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 09.09.2015\r\n//\r\n// Description:\r\n// XML reader for IP-XACT module parameter element.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef MODULEPARAMETERREADER_H\r\n#define MODULEPARAMETERREADER_H\r\n\r\n#include \"ModuleParameter.h\"\r\n#include \"ParameterReader.h\"\r\n\r\n#include <IPXACTmodels/common/Document.h>\r\n\r\n#include <QDomNode>\r\n\r\n//-----------------------------------------------------------------------------\r\n//! XML reader for IP-XACT module parameter element.\r\n//-----------------------------------------------------------------------------\r\nnamespace ModuleParameterReader\r\n{\r\n\r\n    /*!\r\n     *  Creates a module parameter from XML description.\r\n     *\r\n     *    @param [in] moduleParameterNode   The XML description of the module parameter.\r\n     *    @param [in] docRevision           The IP-XACT standard to comply to.\r\n\r\n     *    @return The created module parameter.\r\n     */\r\n    IPXACTMODELS_EXPORT QSharedPointer<ModuleParameter> createModuleParameterFrom(QDomNode const& moduleParameterNode,\r\n        Document::Revision docRevision);\r\n\r\n    namespace Details\r\n    {\r\n\r\n        /*!\r\n         *  Reads the presence of the module parameter.\r\n         *\r\n         *    @param [in] moduleParameterNode     XML description of the module parameter.\r\n         *    @param [in] moduleParameter         The module parameter whose presence is being read.\r\n         *    @param [in] docRevision             The IP-XACT standard to comply to.\r\n         */\r\n        void parseIsPresent(QDomNode const& moduleParameterNode, QSharedPointer<ModuleParameter> moduleParameter,\r\n            Document::Revision docRevision);\r\n    }\r\n};\r\n\r\n#endif // MODULEPARAMETERREADER_H"
  },
  {
    "path": "IPXACTmodels/common/ModuleParameterWriter.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ModuleParameterWriter.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 08.09.2015\r\n//\r\n// Description:\r\n// Writer for IP-XACT Module parameter element.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"ModuleParameterWriter.h\"\r\n#include \"CommonItemsWriter.h\"\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ModuleParameterWriter::writeModuleParameter()\r\n//-----------------------------------------------------------------------------\r\nvoid ModuleParameterWriter::writeModuleParameter(QXmlStreamWriter& writer,\r\n    QSharedPointer<ModuleParameter> moduleParameter, Document::Revision docRevision)\r\n{\r\n    writer.writeStartElement(QStringLiteral(\"ipxact:moduleParameter\"));\r\n\r\n    ParameterWriter::Details::writeAttributes(writer, moduleParameter);\r\n\r\n    ParameterWriter::Details::writeNameGroup(writer, moduleParameter, docRevision);\r\n\r\n    ParameterWriter::Details::writeVectors(writer, moduleParameter, docRevision);\r\n\r\n    ParameterWriter::Details::writeArrays(writer, moduleParameter, docRevision);\r\n\r\n    ParameterWriter::Details::writeValue(writer, moduleParameter);\r\n\r\n    CommonItemsWriter::writeVendorExtensions(writer, moduleParameter);\r\n\r\n    if (docRevision == Document::Revision::Std14)\r\n    {\r\n        CommonItemsWriter::writeIsPresent(writer, moduleParameter->getIsPresent());\r\n    }\r\n\r\n    writer.writeEndElement(); // ipxact:moduleParameter\r\n}\r\n"
  },
  {
    "path": "IPXACTmodels/common/ModuleParameterWriter.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ModuleParameterWriter.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 08.09.2015\r\n//\r\n// Description:\r\n// Writer class for IP-XACT Module parameter element.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef MODULEPARAMETERWRITER_H\r\n#define MODULEPARAMETERWRITER_H\r\n\r\n#include \"ParameterWriter.h\"\r\n#include \"ModuleParameter.h\"\r\n#include \"Document.h\"\r\n\r\n#include <QSharedPointer>\r\n#include <QXmlStreamWriter>\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Writer class for IP-XACT Parameter element.\r\n//-----------------------------------------------------------------------------\r\nnamespace ModuleParameterWriter\r\n{\r\n    /*!\r\n     *  Writes the given module parameter into xml.\r\n     *\r\n     *    @param [in] writer      The xml writer to use.\r\n     *    @param [in] parameter   The module parameter to write.\r\n     *    @param [in] docRevision The document std revision.\r\n     */\r\n    void writeModuleParameter(QXmlStreamWriter& writer, QSharedPointer<ModuleParameter> moduleParameter, \r\n        Document::Revision docRevision = Document::Revision::Std14);\r\n};\r\n\r\n#endif // MODULEPARAMETERWRITER_H\r\n"
  },
  {
    "path": "IPXACTmodels/common/NameGroup.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: NameGroup.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Esko Pekkarinen\r\n// Date: 03.08.2015\r\n//\r\n// Description:\r\n// Implementation for ipxact:nameGroup element.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"NameGroup.h\"\r\n#include <IPXACTmodels/generaldeclarations.h>\r\n\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: NameGroup::NameGroup()\r\n//-----------------------------------------------------------------------------\r\nNameGroup::NameGroup(QString const& name, QString const& displayName, QString const& description):\r\n    name_(name.trimmed()), \r\n    displayName_(displayName),\r\n    description_(description)\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: NameGroup::operator=()\r\n//-----------------------------------------------------------------------------\r\nNameGroup& NameGroup::operator=( const NameGroup& other )\r\n{\r\n    if (this != &other) {\r\n        name_ = other.name_;\r\n        displayName_ = other.displayName_;\r\n        shortDescription_ = other.shortDescription_;\r\n        description_ = other.description_;\r\n    }\r\n    return *this;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: NameGroup::name()\r\n//-----------------------------------------------------------------------------\r\nQString NameGroup::name() const\r\n{\r\n    return name_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: NameGroup::setName()\r\n//-----------------------------------------------------------------------------\r\nvoid NameGroup::setName(QString const& name)\r\n{\r\n    name_ = name.trimmed();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: NameGroup::displayName()\r\n//-----------------------------------------------------------------------------\r\nQString NameGroup::displayName() const\r\n{\r\n    return displayName_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: NameGroup::setDisplayName()\r\n//-----------------------------------------------------------------------------\r\nvoid NameGroup::setDisplayName(QString const& displayName)\r\n{\r\n    displayName_ = displayName;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: NameGroup::shortDescription()\r\n//-----------------------------------------------------------------------------\r\nQString NameGroup::shortDescription() const\r\n{\r\n    return shortDescription_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: NameGroup::setShortDescription()\r\n//-----------------------------------------------------------------------------\r\nvoid NameGroup::setShortDescription(QString const& description)\r\n{\r\n    shortDescription_ = description;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: NameGroup::description()\r\n//-----------------------------------------------------------------------------\r\nQString NameGroup::description() const\r\n{\r\n    return description_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: NameGroup::setDescription()\r\n//-----------------------------------------------------------------------------\r\nvoid NameGroup::setDescription(QString const& description)\r\n{\r\n    description_ = description;\r\n}\r\n"
  },
  {
    "path": "IPXACTmodels/common/NameGroup.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: NameGroup.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Esko Pekkarinen\r\n// Date: 03.08.2015\r\n//\r\n// Description:\r\n// Implementation for ipxact:nameGroup element.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef NAMEGROUP_H\r\n#define NAMEGROUP_H\r\n\r\n#include <IPXACTmodels/ipxactmodels_global.h>\r\n\r\n#include <QString>\r\n#include <QXmlStreamWriter>\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Implementation for ipxact:nameGroup element.\r\n//-----------------------------------------------------------------------------\r\nclass IPXACTMODELS_EXPORT NameGroup\r\n{\r\n\r\npublic:\r\n\r\n\t//! The default constructor\t\r\n\tNameGroup() = default;\r\n\r\n\t/*! The constructor\r\n\t *\r\n\t *    @param [in] name            The initial name.\r\n     *    @param [in] displayName     The initial displayName.\r\n     *    @param [in] description     The initial description.\r\n\t*/\r\n\tNameGroup(QString const& name, QString const& displayName = QString(), QString const& description = QString());\r\n\r\n\t/*! The copy constructor\r\n\t *\r\n\t *    @param [in] other    Reference to the NameGroup to copy.\r\n\t*/\r\n\tNameGroup(const NameGroup& other) = default;\r\n\r\n    //! The destructor.\r\n    virtual ~NameGroup() = default;\r\n\r\n\t/*! The assignment operator\r\n\t *\r\n\t *    @param [in] other   Reference to the NameGroup to assign.\r\n\t *\r\n\t *    @return Reference to this NameGroup.\r\n\t*/\r\n\tNameGroup& operator=(const NameGroup& other);\r\n\r\n    /*!\r\n     *  Gets the name element in the name group.\r\n     *\r\n     *    @return The name element.\r\n     */\r\n    QString name() const;\r\n\r\n    /*!\r\n     *  Sets the name element in the group.\r\n     *\r\n     *    @param [in] name   The name to set.     \r\n     */\r\n    void setName(QString const& name);\r\n\r\n    /*!\r\n     *  Gets the displayName element in the name group.\r\n     *\r\n     *    @return The displayName element.\r\n     */\r\n    QString displayName() const;\r\n\r\n    /*!\r\n     *  Sets the displayName element in the group.\r\n     *\r\n     *    @param [in] displayName   The display name to set.     \r\n     */\r\n    void setDisplayName(QString const& displayName);\r\n\r\n    /*!\r\n     *  Gets the short description element in the name group.\r\n     *\r\n     *    @return The short description element.\r\n     */\r\n    QString shortDescription() const;\r\n\r\n    /*!\r\n     *  Sets the short description element in the group.\r\n     *\r\n     *    @param [in] description   The description to set.\r\n     */\r\n    void setShortDescription(QString const& description);\r\n\r\n    /*!\r\n     *  Gets the description element in the name group.\r\n     *\r\n     *    @return The description element.\r\n     */\r\n    QString description() const;\r\n\r\n    /*!\r\n     *  Sets the description element in the group.\r\n     *\r\n     *    @param [in] description   The description to set.     \r\n     */\r\n    void setDescription(QString const& description);\r\n\r\nprivate:\r\n\r\n    //! The name matches the ipxact:name field within nameGroup.\r\n    QString name_;\r\n\r\n    //! The displayName matches the ipxact:displayName field within nameGroup.\r\n    QString displayName_;\r\n\r\n    //! The shortDescription matches the ipxact:shortDescription field within nameGroup.\r\n    QString shortDescription_;\r\n\r\n    //! description matches the ipxact:description field within nameGroup.\r\n    QString description_;\r\n};\r\n\r\n#endif /* NAMEGROUP_H */"
  },
  {
    "path": "IPXACTmodels/common/NameGroupReader.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: NameGroupReader.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 04.09.2015\r\n//\r\n// Description:\r\n// Reader for name group element.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"NameGroupReader.h\"\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: NameGroupReader::parseNameGroup()\r\n//-----------------------------------------------------------------------------\r\nvoid NameGroupReader::parseNameGroup(QDomNode const& nameGroupNode, QSharedPointer<NameGroup> nameGroup)\r\n{\r\n    nameGroup->setName(Details::parseName(nameGroupNode));\r\n\r\n    nameGroup->setDisplayName(Details::parseDisplayName(nameGroupNode));\r\n\r\n    nameGroup->setShortDescription(Details::parseShortDescription(nameGroupNode));\r\n\r\n    nameGroup->setDescription(Details::parseDescription(nameGroupNode));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: NameGroupReader::Details::parseName()\r\n//-----------------------------------------------------------------------------\r\nQString NameGroupReader::Details::parseName(QDomNode const& nameGroupNode)\r\n{\r\n    return nameGroupNode.firstChildElement(QStringLiteral(\"ipxact:name\")).firstChild().nodeValue();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: NameGroupReader::Details::parseDisplayName()\r\n//-----------------------------------------------------------------------------\r\nQString NameGroupReader::Details::parseDisplayName(QDomNode const& nameGroupNode)\r\n{\r\n    return nameGroupNode.firstChildElement(QStringLiteral(\"ipxact:displayName\")).firstChild().nodeValue();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: NameGroupReader::Details::parseShortDescription()\r\n//-----------------------------------------------------------------------------\r\nQString NameGroupReader::Details::parseShortDescription(QDomNode const& nameGroupNode)\r\n{\r\n    return nameGroupNode.firstChildElement(QStringLiteral(\"ipxact:shortDescription\")).firstChild().nodeValue();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: NameGroupReader::Details::parseDescription()\r\n//-----------------------------------------------------------------------------\r\nQString NameGroupReader::Details::parseDescription(QDomNode const& nameGroupNode)\r\n{\r\n    return nameGroupNode.firstChildElement(QStringLiteral(\"ipxact:description\")).firstChild().nodeValue();\r\n}"
  },
  {
    "path": "IPXACTmodels/common/NameGroupReader.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: NameGroupReader.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 04.09.2015\r\n//\r\n// Description:\r\n// Reader for name group element.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef NAMEGROUPREADER_H\r\n#define NAMEGROUPREADER_H\r\n\r\n#include \"NameGroup.h\"\r\n\r\n#include <IPXACTmodels/ipxactmodels_global.h>\r\n\r\n#include <QDomNode>\r\n#include <QSharedPointer>\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Reader for name group element.\r\n//-----------------------------------------------------------------------------\r\nnamespace NameGroupReader\r\n{\r\n\r\n    /*!\r\n     *  Reads the name group.\r\n     *\r\n     *    @param [in] nameGroupNode   XML description of the name group.\r\n     *    @param [in] nameGroup       The new name group.\r\n     */\r\n    void parseNameGroup(QDomNode const& nameGroupNode, QSharedPointer<NameGroup> nameGroup);\r\n\r\n    namespace Details\r\n    {\r\n        /*!\r\n         *  Reads and creates a name for name group.\r\n         *\r\n         *    @param [in] nameGroupNode   XML description of the name group.\r\n         *\r\n         *    @return The name of the name group.\r\n         */\r\n        QString parseName(QDomNode const& nameGroupNode);\r\n\r\n        /*!\r\n         *  Reads and creates a display name for name group.\r\n         *\r\n         *    @param [in] nameGroupNode   XML description of the name group.\r\n         *\r\n         *    @return The display name of the name group.\r\n         */\r\n        QString parseDisplayName(QDomNode const& nameGroupNode);\r\n\r\n        /*!\r\n         *  Reads and creates a short description for name group.\r\n         *\r\n         *    @param [in] nameGroupNode   XML description of the name group.\r\n         *\r\n         *    @return The short description of the name group.\r\n         */\r\n        QString parseShortDescription(QDomNode const& nameGroupNode);\r\n\r\n        /*!\r\n         *  Reads and creates a description for name group.\r\n         *\r\n         *    @param [in] nameGroupNode   XML description of the name group.\r\n         *\r\n         *    @return The description of the name group.\r\n         */\r\n        QString parseDescription(QDomNode const& nameGroupNode);\r\n    }\r\n};\r\n\r\n#endif // NAMEGROUPREADER_H"
  },
  {
    "path": "IPXACTmodels/common/NameGroupWriter.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: NameGroupWriter.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 05.08.2015\r\n//\r\n// Description:\r\n// Writer for namegroup element.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"NameGroupWriter.h\"\r\n\r\n#include \"CommonItemsWriter.h\"\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: NameGroupWriter::writeNameGroup()\r\n//-----------------------------------------------------------------------------\r\nvoid NameGroupWriter::writeNameGroup(QXmlStreamWriter& writer, QSharedPointer<NameGroup> nameGroup,\r\n    Document::Revision revision)\r\n{\r\n    writer.writeTextElement(QStringLiteral(\"ipxact:name\"), nameGroup->name());\r\n\r\n    CommonItemsWriter::writeNonEmptyElement(writer, QStringLiteral(\"ipxact:displayName\"), nameGroup->displayName());\r\n\r\n    if (revision == Document::Revision::Std22)\r\n    {\r\n        CommonItemsWriter::writeNonEmptyElement(writer, QStringLiteral(\"ipxact:shortDescription\"), nameGroup->shortDescription());\r\n    }\r\n\r\n    CommonItemsWriter::writeNonEmptyElement(writer, QStringLiteral(\"ipxact:description\"), nameGroup->description());\r\n}"
  },
  {
    "path": "IPXACTmodels/common/NameGroupWriter.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: NameGroupWriter.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 05.08.2015\r\n//\r\n// Description:\r\n// Writer for namegroup element.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef NAMEGROUPWRITER_H\r\n#define NAMEGROUPWRITER_H\r\n\r\n#include <IPXACTmodels/ipxactmodels_global.h>\r\n#include <IPXACTmodels/common/Document.h>\r\n#include <IPXACTmodels/common/NameGroup.h>\r\n\r\n#include <QObject>\r\n#include <QXmlStreamWriter>\r\n#include <QSharedPointer>\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Writer for namegroup element.\r\n//-----------------------------------------------------------------------------\r\nnamespace NameGroupWriter\r\n{\r\n    /*!\r\n     *  Write the name group.\r\n     *\r\n     *    @param [in] writer      The used xml writer.\r\n     *    @param [in] nameGroup   The selected name group.\r\n     *    @param [in] revision    The IP-XACT standard to comply to.\r\n     */\r\n    void writeNameGroup(QXmlStreamWriter& writer, QSharedPointer<NameGroup> nameGroup,\r\n        Document::Revision revision = Document::Revision::Std14);\r\n}\r\n\r\n#endif // NAMEGROUPWRITER_H"
  },
  {
    "path": "IPXACTmodels/common/NameValuePair.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: NameValuePair.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 16.09.2015\r\n//\r\n// Description:\r\n// Describes the ipxact:nameValuePair element.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"NameValuePair.h\"\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: NameValuePair::NameValuePair()\r\n//-----------------------------------------------------------------------------\r\nNameValuePair::NameValuePair(QString const& name /* = QString() */, QString const& value /* = QString() */) :\r\nNameGroup(name),\r\nExtendable(),\r\nvalue_(value)\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: NameValuePair::NameValuePair()\r\n//-----------------------------------------------------------------------------\r\nNameValuePair::NameValuePair(const NameValuePair& other):\r\nNameGroup(other),\r\nExtendable(other),\r\nvalue_(other.value_)\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: NameValuePair::operator=()\r\n//-----------------------------------------------------------------------------\r\nNameValuePair& NameValuePair::operator=(const NameValuePair& other)\r\n{\r\n    if (this != &other)\r\n    {\r\n        NameGroup::operator=(other);\r\n        Extendable::operator=(other);\r\n        value_ = other.value_;\r\n    }\r\n\r\n    return *this;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: NameValuePair::~NameValuePair()\r\n//-----------------------------------------------------------------------------\r\nNameValuePair::~NameValuePair()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: NameValuePair::getValue()\r\n//-----------------------------------------------------------------------------\r\nQString NameValuePair::getValue() const\r\n{\r\n    return value_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: NameValuePair::setValue()\r\n//-----------------------------------------------------------------------------\r\nvoid NameValuePair::setValue(QString const& newValue)\r\n{\r\n    value_ = newValue;\r\n}"
  },
  {
    "path": "IPXACTmodels/common/NameValuePair.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: NameValuePair.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 16.09.2015\r\n//\r\n// Description:\r\n// Describes the ipxact:nameValuePair element.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef NAMEVALUEPAIR_H\r\n#define NAMEVALUEPAIR_H\r\n\r\n#include <IPXACTmodels/common/NameGroup.h>\r\n#include <IPXACTmodels/common/Extendable.h>\r\n\r\n#include <QString>\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Describes the ipxact:nameValuePair element.\r\n//-----------------------------------------------------------------------------\r\nclass IPXACTMODELS_EXPORT NameValuePair : public NameGroup, public Extendable\r\n{\r\n\r\npublic:\r\n\r\n    /*!\r\n     *  The constructor.\r\n     *\r\n     *    @param [in] name    Name of the pair.\r\n     *    @param [in] value   Value of the pair.\r\n     */\r\n    NameValuePair(QString const& name = QString(), QString const& value = QString());\r\n\r\n    //! Copy constructor.\r\n    NameValuePair(const NameValuePair& other);\r\n\r\n    //! Assignment operator.\r\n    NameValuePair& operator=(const NameValuePair& other);\r\n\r\n    //! The destructor.\r\n    ~NameValuePair();\r\n\r\n    /*!\r\n     *  Get the contained value.\r\n     *\r\n     *    @return The value.\r\n     */\r\n    QString getValue() const;\r\n\r\n    /*!\r\n     *  Set a value.\r\n     *\r\n     *    @param [in] newValue    The new value.\r\n     */\r\n    void setValue(QString const& newValue);\r\n\r\nprivate:\r\n\r\n    //! The value.\r\n    QString value_;\r\n};\r\n\r\n#endif // NAMEVALUEPAIR_H\r\n"
  },
  {
    "path": "IPXACTmodels/common/Parameter.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: Parameter.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Esko Pekkarinen\r\n// Date: 03.08.2015\r\n//\r\n// Description:\r\n// Implementation for ipxact:parameter element.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"Parameter.h\"\r\n\r\n#include <IPXACTmodels/utilities/Copy.h>\r\n\r\n#include <QString>\r\n#include <QList>\r\n#include <QMap>\r\n\r\n#include <QUuid>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Parameter::Parameter()\r\n//-----------------------------------------------------------------------------\r\nParameter::Parameter(): NameGroup(),\r\n    Extendable()\r\n{\r\n    createUuid();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Parameter::Parameter()\r\n//-----------------------------------------------------------------------------\r\nParameter::Parameter( const Parameter &other ): NameGroup(other),\r\n    Extendable(),\r\n    value_(other.value_),\r\n    attributes_(other.attributes_),\r\n    valueAttributes_(other.valueAttributes_), \r\n    bitWidthVector_(other.bitWidthVector_)\r\n{\r\n    Copy::copyList(other.vectors_, vectors_);\r\n    Copy::copyList(other.arrays_, arrays_);\r\n    copyVendorExtensions(other);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Parameter::~Parameter()\r\n//-----------------------------------------------------------------------------\r\nParameter::~Parameter()\r\n{\r\n    \r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Parameter::operator=()\r\n//-----------------------------------------------------------------------------\r\nParameter & Parameter::operator=(Parameter const& other) \r\n{\r\n\tif (this != &other) \r\n    {\r\n\t\tNameGroup::operator=(other);\r\n        Extendable::operator=(other);\r\n\t\tvalue_ = other.value_;\r\n        attributes_ = other.attributes_;\r\n\t\tvalueAttributes_ = other.valueAttributes_;\r\n\r\n        vectors_->clear();\r\n        Copy::copyList(other.vectors_, vectors_);\r\n\r\n        arrays_->clear();\r\n        Copy::copyList(other.arrays_, arrays_);\r\n\r\n        copyVendorExtensions(other);\r\n\t}\r\n\treturn *this;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Parameter::elementName()\r\n//-----------------------------------------------------------------------------\r\nQString Parameter::elementName() const\r\n{\r\n    return QStringLiteral(\"parameter\");\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Parameter::getValue()\r\n//-----------------------------------------------------------------------------\r\nQString Parameter::getValue() const\r\n{\r\n    return value_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Parameter::setValue()\r\n//-----------------------------------------------------------------------------\r\nvoid Parameter::setValue(QString const& value) \r\n{\r\n\tvalue_ = value;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Parameter::getChoiceRef()\r\n//-----------------------------------------------------------------------------\r\nQString Parameter::getChoiceRef() const\r\n{\r\n    return getAttribute(QStringLiteral(\"choiceRef\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Parameter::setChoiceRef()\r\n//-----------------------------------------------------------------------------\r\nvoid Parameter::setChoiceRef(QString const& choiceRef)\r\n{ \r\n    setAttribute(QStringLiteral(\"choiceRef\"), choiceRef);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: parameter::getType()\r\n//-----------------------------------------------------------------------------\r\nQString Parameter::getType() const\r\n{\r\n    return attributes_.value(QStringLiteral(\"type\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: parameter::setType()\r\n//-----------------------------------------------------------------------------\r\nvoid Parameter::setType(QString const& type)\r\n{\r\n    setAttribute(QStringLiteral(\"type\"), type);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Parameter::getMinimumValue()\r\n//-----------------------------------------------------------------------------\r\nQString Parameter::getMinimumValue() const\r\n{\r\n    return getAttribute(QStringLiteral(\"minimum\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Parameter::setMinimumValue()\r\n//-----------------------------------------------------------------------------\r\nvoid Parameter::setMinimumValue(QString const& minimum)\r\n{\r\n    setAttribute(QStringLiteral(\"minimum\"), minimum);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Parameter::getMaximumValue()\r\n//-----------------------------------------------------------------------------\r\nQString Parameter::getMaximumValue() const\r\n{\r\n    return getAttribute(QStringLiteral(\"maximum\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Parameter::setMaximumValue()\r\n//-----------------------------------------------------------------------------\r\nvoid Parameter::setMaximumValue(QString const& maximum)\r\n{\r\n    setAttribute(QStringLiteral(\"maximum\"), maximum);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Parameter::getValueResolve()\r\n//-----------------------------------------------------------------------------\r\nQString Parameter::getValueResolve() const\r\n{\r\n    return getAttribute(QStringLiteral(\"resolve\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Parameter::setValueResolve()\r\n//-----------------------------------------------------------------------------\r\nvoid Parameter::setValueResolve(QString const& resolve)\r\n{\r\n    setAttribute(QStringLiteral(\"resolve\"), resolve);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Parameter::getValueId()\r\n//-----------------------------------------------------------------------------\r\nQString Parameter::getValueId() const\r\n{\r\n     return getAttribute(QStringLiteral(\"parameterId\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Parameter::setValueId()\r\n//-----------------------------------------------------------------------------\r\nvoid Parameter::setValueId(QString const& id)\r\n{\r\n     setAttribute(QStringLiteral(\"parameterId\"), id);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: parameter::getUsageCount()\r\n//-----------------------------------------------------------------------------\r\nint Parameter::getUsageCount() const\r\n{\r\n    return getAttribute(QStringLiteral(\"kactus2:usageCount\")).toInt();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Parameter::setUsageCount()\r\n//-----------------------------------------------------------------------------\r\nvoid Parameter::setUsageCount(int const& newUsageCount)\r\n{\r\n    attributes_.insert(QStringLiteral(\"kactus2:usageCount\"), QString::number(newUsageCount));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: parameter::increaseUsageCount()\r\n//-----------------------------------------------------------------------------\r\nvoid Parameter::increaseUsageCount()\r\n{\r\n    attributes_.insert(QStringLiteral(\"kactus2:usageCount\"), QString::number(getUsageCount() + 1));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: parameter::decreaseUsageCount()\r\n//-----------------------------------------------------------------------------\r\nvoid Parameter::decreaseUsageCount()\r\n{\r\n    if (getUsageCount() < 2)\r\n    {\r\n        attributes_.remove(QStringLiteral(\"kactus2:usageCount\"));\r\n    }\r\n\r\n    else\r\n    {\r\n        attributes_.insert(QStringLiteral(\"kactus2:usageCount\"), QString::number(getUsageCount() - 1));\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Parameter::hasAttribute()\r\n//-----------------------------------------------------------------------------\r\nbool Parameter::hasAttribute(QString const& attributeName) const\r\n{\r\n    return attributes_.contains(attributeName);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Parameter::getAttribute()\r\n//-----------------------------------------------------------------------------\r\nQString Parameter::getAttribute(QString const& attributeName) const\r\n{\r\n    return attributes_.value(attributeName);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Parameter::setAttribute()\r\n//-----------------------------------------------------------------------------\r\nvoid Parameter::setAttribute(QString const& attributeName, QString const& attributeValue)\r\n{\r\n    if (!attributeValue.isEmpty())\r\n    {\r\n        attributes_.insert(attributeName, attributeValue);\r\n    }\r\n    else\r\n    {\r\n        attributes_.remove(attributeName);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Parameter::getValueAttribute()\r\n//-----------------------------------------------------------------------------\r\nQString Parameter::getValueAttribute(QString const& attributeName) const\r\n{\r\n    return valueAttributes_.value(attributeName);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Parameter::setValueAttribute()\r\n//-----------------------------------------------------------------------------\r\nvoid Parameter::setValueAttribute(QString const& attributeName, QString const& attributeValue)\r\n{\r\n    if (!attributeValue.isEmpty())\r\n    {\r\n        valueAttributes_.insert(attributeName, attributeValue);\r\n    }\r\n    else\r\n    {\r\n        valueAttributes_.remove(attributeName);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Parameter::getAttributeNames()\r\n//-----------------------------------------------------------------------------\r\nQStringList Parameter::getAttributeNames() const\r\n{\r\n    return attributes_.keys();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Parameter::getValueAttributeNames()\r\n//-----------------------------------------------------------------------------\r\nQStringList Parameter::getValueAttributeNames() const\r\n{\r\n    return valueAttributes_.keys();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Parameter::getVectors()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<QList<QSharedPointer<Vector> > > Parameter::getVectors() const\r\n{\r\n    return vectors_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Parameter::getVectorLeft()\r\n//-----------------------------------------------------------------------------\r\nQString Parameter::getVectorLeft() const\r\n{\r\n    if (vectors_->isEmpty())\r\n    {\r\n        return QString();\r\n    }\r\n    return vectors_->first()->getLeft();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Parameter::getVectorRight()\r\n//-----------------------------------------------------------------------------\r\nQString Parameter::getVectorRight() const\r\n{\r\n    if (vectors_->isEmpty())\r\n    {\r\n        return QString();\r\n    }\r\n    return vectors_->first()->getRight();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Parameter::setVectorLeft()\r\n//-----------------------------------------------------------------------------\r\nvoid Parameter::setVectorLeft(QString const& leftExpression)\r\n{\r\n    if (vectors_->isEmpty())\r\n    {\r\n        if (!leftExpression.isEmpty())\r\n        {\r\n            vectors_->append(QSharedPointer<Vector>(new Vector(leftExpression, QString())));\r\n        }\r\n    }\r\n    else\r\n    {\r\n        vectors_->first()->setLeft(leftExpression);\r\n        if (leftExpression.isEmpty() && vectors_->first()->getRight().isEmpty())\r\n        {\r\n            vectors_->removeFirst();\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Parameter::setVectorRight()\r\n//-----------------------------------------------------------------------------\r\nvoid Parameter::setVectorRight(QString const& rightExpression)\r\n{\r\n    if (vectors_->isEmpty())\r\n    {\r\n        if (!rightExpression.isEmpty())\r\n        {\r\n            vectors_->append(QSharedPointer<Vector>(new Vector(QString(), rightExpression)));\r\n        }\r\n    }\r\n    else\r\n    {\r\n        vectors_->first()->setRight(rightExpression);\r\n        if (rightExpression.isEmpty() && vectors_->first()->getLeft().isEmpty())\r\n        {\r\n            vectors_->removeFirst();\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Parameter::setVectorId()\r\n//-----------------------------------------------------------------------------\r\nvoid Parameter::setVectorId(QString const& id)\r\n{\r\n    if (!vectors_->isEmpty())\r\n    {\r\n        vectors_->first()->setId(id);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Parameter::getVectorId()\r\n//-----------------------------------------------------------------------------\r\nQString Parameter::getVectorId() const\r\n{\r\n    if (!vectors_->isEmpty())\r\n    {\r\n        return vectors_->first()->getId();\r\n    }\r\n\r\n    return QString();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Parameter::getArrays()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<QList<QSharedPointer<Array> > > Parameter::getArrays() const\r\n{\r\n    return arrays_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Parameter::getArrayLeft()\r\n//-----------------------------------------------------------------------------\r\nQString Parameter::getArrayLeft() const\r\n{\r\n    if (arrays_->isEmpty())\r\n    {\r\n        return QString();\r\n    }\r\n\r\n    return arrays_->first()->getLeft();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Parameter::getArrayRight()\r\n//-----------------------------------------------------------------------------\r\nQString Parameter::getArrayRight() const\r\n{\r\n    if (arrays_->isEmpty())\r\n    {\r\n        return QString();\r\n    }\r\n\r\n    return arrays_->first()->getRight();\r\n}\r\n//-----------------------------------------------------------------------------\r\n// Function: Parameter::setArrayLeft()\r\n//-----------------------------------------------------------------------------\r\nvoid Parameter::setArrayLeft(QString const& leftExpression)\r\n{\r\n    if (arrays_->isEmpty())\r\n    {\r\n        if (!leftExpression.isEmpty())\r\n        {\r\n             arrays_->append(QSharedPointer<Array>(new Array(leftExpression, QString())));\r\n        }       \r\n    }\r\n    else\r\n    {\r\n        arrays_->first()->setLeft(leftExpression);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Parameter::setArrayRight()\r\n//-----------------------------------------------------------------------------\r\nvoid Parameter::setArrayRight(QString const& rightExpression)\r\n{\r\n    if (arrays_->isEmpty())\r\n    {\r\n        if (!rightExpression.isEmpty())\r\n        {\r\n            arrays_->append(QSharedPointer<Array>(new Array(QString(), rightExpression)));\r\n        }        \r\n    }\r\n    else\r\n    {\r\n        arrays_->first()->setRight(rightExpression);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Parameter::createUuid()\r\n//-----------------------------------------------------------------------------\r\nvoid Parameter::createUuid()\r\n{\r\n    QString formattedUuid = QUuid::createUuid().toString().remove(QLatin1Char('{')).remove(QLatin1Char('}'));\r\n    formattedUuid.replace(QLatin1Char('-'), QLatin1Char('_'));\r\n    formattedUuid.prepend(QStringLiteral(\"uuid_\"));\r\n    setValueId(formattedUuid);\r\n}\r\n"
  },
  {
    "path": "IPXACTmodels/common/Parameter.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: Parameter.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Esko Pekkarinen\r\n// Date: 03.08.2015\r\n//\r\n// Description:\r\n// Implementation for ipxact:parameter element.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef PARAMETER_H\r\n#define PARAMETER_H\r\n\r\n#include <IPXACTmodels/ipxactmodels_global.h>\r\n\r\n#include <IPXACTmodels/common/Extendable.h>\r\n#include <IPXACTmodels/common/NameGroup.h>\r\n\r\n#include \"Array.h\"\r\n#include \"Vector.h\"\r\n\r\n#include <QString>\r\n#include <QMap>\r\n#include <QStringList>\r\n#include <QSharedPointer>\r\n\r\nclass VendorExtension;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Implementation for ipxact:parameter element.\r\n//-----------------------------------------------------------------------------\r\nclass IPXACTMODELS_EXPORT Parameter : public NameGroup, public Extendable\r\n{\r\npublic:\r\n\r\n\t/*! The default constructor\r\n\t *\r\n\t * Constructs an empty invalid parameter.\r\n\t*/\r\n\tParameter();\r\n\r\n\t//! Copy constructor\r\n\tParameter(const Parameter &other);\r\n\r\n    //! The destructor\r\n    virtual ~Parameter();\r\n\r\n\t//! Assignment operator\r\n\tParameter &operator=(const Parameter &other);\r\n    \r\n    virtual QString elementName() const;\r\n\r\n\t/*! Get the value of the parameter\r\n\t *\r\n\t *    @return QString containing the value\r\n\t */\r\n\tQString getValue() const;\r\n\r\n\t/*! Set the value for the parameter\r\n\t *\r\n\t *    @param [in] value QString containing the value\r\n\t */\r\n\tvoid setValue(QString const& value);\r\n    \r\n    /*!\r\n     *  Gets the choice referenced by the parameter value.\r\n     *\r\n     *    @return The choice name referenced by the value or an empty string, if no choice is referenced.\r\n     */\r\n    QString getChoiceRef() const;\r\n\r\n    /*!\r\n     *  Sets the choice to reference by the parameter value.\r\n     *\r\n     *    @param [in] choiceRef   The choice name to reference.\r\n     */\r\n    void setChoiceRef(QString const& choiceRef);\r\n\r\n    /*!\r\n     *  Gets the IP-Xact format type.\r\n     */\r\n    QString getType() const;\r\n\r\n    /*!\r\n     *  Sets the IP-Xact format type.\r\n     *\r\n     *    @param [in] type   The format type.\r\n     */\r\n    void setType(QString const& type);\r\n\r\n    /*!\r\n     *  Gets the minimum value for the parameter value.\r\n     *\r\n     *    @return The minimum value.\r\n     */\r\n    QString getMinimumValue() const;\r\n\r\n    /*!\r\n     *  Sets the minimum value for the parameter value\r\n     *\r\n     *    @param [in] minimum   The minimum value.\r\n     */\r\n    void setMinimumValue(QString const& minimum);\r\n    \r\n    /*!\r\n     *  Gets the maximum value for the parameter value.\r\n     *\r\n     *    @return The maximum value.\r\n     */\r\n    QString getMaximumValue() const;\r\n\r\n    /*!\r\n     *  Sets the maximum value for the parameter value\r\n     *\r\n     *    @param [in] maximum   The maximum value.\r\n     */\r\n    void setMaximumValue(QString const& maximum);\r\n\r\n    /*!\r\n     *  Gets the resolve type for the parameter value.\r\n     *\r\n     *    @return The resolve type for the value.\r\n     */\r\n    QString getValueResolve() const;\r\n\r\n    /*!\r\n     *  Sets the resolve type for the parameter value\r\n     *\r\n     *    @param [in] resolve   The resolve type.\r\n     */\r\n    void setValueResolve(QString const& resolve);\r\n    \r\n    /*!\r\n     *  Gets the unique id for the parameter value.\r\n     *\r\n     *    @return The unique id for the value.\r\n     */\r\n    QString getValueId() const;\r\n\r\n    /*!\r\n     *  Sets the unique id for referencing the parameter value\r\n     *\r\n     *    @param [in] id   The id to set.\r\n     */\r\n     void setValueId(QString const& id);\r\n\r\n     /*!\r\n      *  Get the amount of times the parameter has been referenced.\r\n      *\r\n      *    @return     The amount of times the parameter has been referenced.\r\n      */\r\n     int getUsageCount() const;\r\n\r\n     /*!\r\n      *  Set a new reference count.\r\n      *\r\n      *    @param [in] newUsageCount  The new reference count.\r\n      */\r\n     void setUsageCount(int const& newUsageCount);\r\n\r\n     /*!\r\n      *  Increase the amount of references to this parameter.\r\n      */\r\n     void increaseUsageCount();\r\n\r\n     /*!\r\n      *  Decrease the amount of references to this parameter.\r\n      */\r\n     void decreaseUsageCount();\r\n\r\n    /*!\r\n     *  Checks if the parameter has an attribute with the given name.\r\n     *\r\n     *    @param [in] attributeName   The name of the attribute to find.\r\n     *\r\n     *    @return True, if an attribute with the given name exists, otherwise false.\r\n     */\r\n    bool hasAttribute(QString const& attributeName) const;\r\n\r\n    /*!\r\n     *  Gets the value of an attribute.\r\n     *\r\n     *    @param [in] attributeName       The name of the attribute to get.\r\n     *\r\n     *    @return The attribute value.\r\n     */\r\n    QString getAttribute(QString const& attributeName) const;    \r\n\r\n    /*!\r\n     *  Sets an attribute.\r\n     *\r\n     *    @param [in] attributeName       The name of the attribute to set.\r\n     *    @param [in] attributeValue      The value of the attribute.\r\n     */\r\n    void setAttribute(QString const& attributeName, QString const& attributeValue);\r\n   \r\n    /*!\r\n     *  Gets the value of an attribute of the paraemter value.\r\n     *\r\n     *    @param [in] attributeName       The name of the attribute to get.\r\n     *\r\n     *    @return The value attribute value.\r\n     */\r\n    QString getValueAttribute(QString const& attributeName) const;\r\n\r\n    /*!\r\n     *  Sets an attribute for the value.\r\n     *\r\n     *    @param [in] attributeName       The name of the attribute to set.\r\n     *    @param [in] attributeValue      The value of the attribute.\r\n     */\r\n    void setValueAttribute(QString const& attributeName, QString const& attributeValue);\r\n           \r\n    /*!\r\n     *  Gets the names of the parameter attributes.\r\n     *\r\n     *    @return The parameter attribute names.\r\n     */\r\n    QStringList getAttributeNames() const;\r\n\r\n    /*!\r\n     *  Gets the names of the parameter value attributes.\r\n     *\r\n     *    @return The parameter value attribute names.\r\n     */\r\n    QStringList getValueAttributeNames() const;\r\n\r\n    /*!\r\n     *  Gets the vectors for the parameter.\r\n     *\r\n     *    @return The parameter vectors.\r\n     */\r\n    QSharedPointer<QList<QSharedPointer<Vector> > > getVectors() const;\r\n        \r\n    /*!\r\n     *  Gets the left index of the parameter vector.\r\n     *\r\n     *    @return The left index of the vector.\r\n     */\r\n    QString getVectorLeft() const;\r\n\r\n    /*!\r\n     *  Gets the right index of the parameter vector.\r\n     *\r\n     *    @return The right index of the vector.\r\n     */\r\n    QString getVectorRight() const;\r\n\r\n    /*!\r\n     *  Sets the left index of the parameter vector.\r\n     *\r\n     *    @param [in] leftExpression   The left index to set.\r\n     */\r\n    void setVectorLeft(QString const& leftExpression);\r\n    \r\n    /*!\r\n     *  Sets the right index of the parameter vector.\r\n     *\r\n     *    @param [in] leftExpression   The right index to set.\r\n     */\r\n    void setVectorRight(QString const& rightExpression);\r\n\r\n    /*!\r\n     *\tSets the vector id.\r\n     *  \r\n     *    @param [in] id\tThe id to set.\r\n     */\r\n    void setVectorId(QString const& id);\r\n\r\n    /*!\r\n     *\tGets the vector id.\r\n     *  \r\n     * \t\t@return The vector id.\r\n     */\r\n    QString getVectorId() const;\r\n    \r\n    /*!\r\n     *  Gets the arrays for the parameter.\r\n     *\r\n     *    @return The parameter arrays.\r\n     */\r\n    QSharedPointer<QList<QSharedPointer<Array> > > getArrays() const;\r\n    \r\n    /*!\r\n     *  Gets the left index of the parameter array.\r\n     *\r\n     *    @return The left index of the array.\r\n     */\r\n    QString getArrayLeft() const;\r\n\r\n    /*!\r\n     *  Gets the right index of the parameter array.\r\n     *\r\n     *    @return The right index of the array.\r\n     */\r\n    QString getArrayRight() const;\r\n\r\n    /*!\r\n     *  Sets the left index of the parameter array.\r\n     *\r\n     *    @param [in] leftExpression   The left index to set.\r\n     */\r\n    void setArrayLeft(QString const& leftExpression);\r\n        \r\n    /*!\r\n     *  Sets the right index of the parameter array.\r\n     *\r\n     *    @param [in] leftExpression   The left index to set.\r\n     */\r\n    void setArrayRight(QString const& rightExpression);\r\n\r\nprivate:\r\n \r\n    /*!\r\n     *  Creates an UUID for the parameter.\r\n     */\r\n    void createUuid();\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! The parameter value.\r\n\tQString value_;\r\n\r\n    //! Parameter attributes.\r\n\tQMap<QString, QString> attributes_;\r\n\r\n\t//! The attributes for the value.\r\n\tQMap<QString, QString> valueAttributes_;\r\n\r\n    //! Vector for containing the bit width of the parameter.\r\n    QSharedPointer<Vector> bitWidthVector_{ nullptr };\r\n\r\n    //! Vectors for defining parameter bit width.\r\n    QSharedPointer<QList<QSharedPointer<Vector> > > vectors_ = \r\n        QSharedPointer<QList<QSharedPointer<Vector> > >(new QList<QSharedPointer<Vector> >());\r\n\r\n    //! Arrays for defining parameter as an array of values.\r\n    QSharedPointer<QList<QSharedPointer<Array> > > arrays_ =\r\n        QSharedPointer<QList<QSharedPointer<Array> > >(new QList<QSharedPointer<Array> >());;\r\n\r\n};\r\n\r\n#endif /* PARAMETER_H */\r\n"
  },
  {
    "path": "IPXACTmodels/common/ParameterReader.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ParameterReader.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Esko Pekkarinen\r\n// Date: 03.08.2015\r\n//\r\n// Description:\r\n// XML reader class for IP-XACT Parameter element.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"ParameterReader.h\"\r\n\r\n#include <IPXACTmodels/common/CommonItemsReader.h>\r\n#include <IPXACTmodels/common/Parameter.h>\r\n#include <IPXACTmodels/common/NameGroupReader.h>\r\n#include <IPXACTmodels/common/GenericVendorExtension.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ParameterReader::createParameterFrom()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<Parameter> ParameterReader::createParameterFrom(QDomNode const& parameterNode,\r\n    Document::Revision revision)\r\n{\r\n    QSharedPointer<Parameter> parameter(new Parameter());\r\n    Details::parseAttributes(parameterNode, parameter);\r\n\r\n    NameGroupReader::parseNameGroup(parameterNode, parameter);\r\n\r\n    Details::parseVectors(parameterNode, parameter, revision);\r\n\r\n    Details::parseArrays(parameterNode, parameter, revision);\r\n\r\n    Details::parseValue(parameterNode, parameter);\r\n\r\n    CommonItemsReader::parseVendorExtensions(parameterNode, parameter);\r\n\r\n    return parameter;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ParameterReader::Details::parseAttributes()\r\n//-----------------------------------------------------------------------------\r\nvoid ParameterReader::Details::parseAttributes(QDomNode const& parameterNode, QSharedPointer<Parameter> parameter)\r\n{\r\n    QDomNamedNodeMap attributes = parameterNode.attributes();\r\n    for (int j = 0; j < attributes.size(); ++j) \r\n    {\r\n        QString attributeName = attributes.item(j).nodeName();\r\n        QString attributeValue = attributes.item(j).nodeValue();\r\n\r\n        //! Add missing prefix to Kactus2-specific attribute.\r\n        if (attributeName.compare(QLatin1String(\"usageCount\")) == 0)\r\n        {\r\n            attributeName.prepend(QStringLiteral(\"kactus2:\"));\r\n        }\r\n\r\n        parameter->setAttribute(attributeName, attributeValue);\r\n    }            \r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ParameterReader::Details::parseVectors()\r\n//-----------------------------------------------------------------------------\r\nvoid ParameterReader::Details::parseVectors(QDomNode const& parameterNode, QSharedPointer<Parameter> parameter,\r\n    Document::Revision revision)\r\n{\r\n    QDomNode vectorsNode = parameterNode.firstChildElement(QStringLiteral(\"ipxact:vectors\"));\r\n\r\n    if (vectorsNode.hasChildNodes())\r\n    {\r\n        QSharedPointer<QList<QSharedPointer<Vector> > > vectors = parameter->getVectors();\r\n        \r\n        int vectorCount = vectorsNode.childNodes().size();\r\n        for (int i = 0; i < vectorCount; i++)\r\n        {\r\n            QDomNode vectorNode = vectorsNode.childNodes().at(i);\r\n\r\n            QString left = vectorNode.firstChildElement(QStringLiteral(\"ipxact:left\")).firstChild().nodeValue();\r\n            QString right = vectorNode.firstChildElement(QStringLiteral(\"ipxact:right\")).firstChild().nodeValue();\r\n\r\n            auto parsedVector = QSharedPointer<Vector>(new Vector(left, right));\r\n            \r\n            if (revision == Document::Revision::Std22)\r\n            {\r\n                auto vectorId = vectorNode.attributes().namedItem(QStringLiteral(\"vectorId\")).nodeValue();\r\n                parsedVector->setId(vectorId);\r\n            }\r\n\r\n            vectors->append(parsedVector);\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ParameterReader::Details::parseArrays()\r\n//-----------------------------------------------------------------------------\r\nvoid ParameterReader::Details::parseArrays(QDomNode const& parameterNode, QSharedPointer<Parameter> parameter,\r\n    Document::Revision revision)\r\n{\r\n    QDomNode arraysNode = parameterNode.firstChildElement(QStringLiteral(\"ipxact:arrays\"));\r\n\r\n    if (arraysNode.hasChildNodes())\r\n    {\r\n        QSharedPointer<QList<QSharedPointer<Array> > > arrays = parameter->getArrays();\r\n\r\n        int arrayCount = arraysNode.childNodes().size();\r\n        for (int i = 0; i < arrayCount; i++)\r\n        {\r\n            QDomNode arrayNode = arraysNode.childNodes().at(i);\r\n\r\n            QString left = arrayNode.firstChildElement(QStringLiteral(\"ipxact:left\")).firstChild().nodeValue();\r\n            QString right = arrayNode.firstChildElement(QStringLiteral(\"ipxact:right\")).firstChild().nodeValue();\r\n\r\n            auto newArray = QSharedPointer<Array>(new Array(left, right));\r\n\r\n            if (revision == Document::Revision::Std22)\r\n            {\r\n                newArray->setId(arrayNode.attributes().namedItem(QStringLiteral(\"arrayId\")).firstChild().nodeValue());\r\n            }\r\n\r\n            arrays->append(newArray);\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ParameterReader::Details::parseValue()\r\n//-----------------------------------------------------------------------------\r\nvoid ParameterReader::Details::parseValue(QDomNode const& parameterNode, QSharedPointer<Parameter> parameter)\r\n{\r\n    parameter->setValue(parameterNode.firstChildElement(QStringLiteral(\"ipxact:value\")).firstChild().nodeValue());\r\n\r\n    QDomNamedNodeMap valueAttributes = parameterNode.firstChildElement(QStringLiteral(\"ipxact:value\")).attributes();\r\n    for (int j = 0; j < valueAttributes.size(); ++j) \r\n    {\r\n        QString attributeName = valueAttributes.item(j).nodeName();\r\n        QString attributeValue = valueAttributes.item(j).nodeValue();\r\n\r\n        parameter->setValueAttribute(attributeName, attributeValue);\r\n    }\r\n}\r\n"
  },
  {
    "path": "IPXACTmodels/common/ParameterReader.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ParameterReader.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Esko Pekkarinen\r\n// Date: 03.08.2015\r\n//\r\n// Description:\r\n// XML reader for IP-XACT Parameter element.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef PARAMETERREADER_H\r\n#define PARAMETERREADER_H\r\n\r\n#include <QDomNode>\r\n\r\n#include <IPXACTmodels/common/Document.h>\r\n\r\n#include <IPXACTmodels/ipxactmodels_global.h>\r\n\r\nclass Parameter;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! XML reader for IP-XACT Parameter element.\r\n//-----------------------------------------------------------------------------\r\nnamespace ParameterReader\r\n{\r\n    /*!\r\n     *  Creates a parameter from XML description.\r\n     *\r\n     *    @param [in] parameterNode   The XML description of the parameter.\r\n     *    @param [in] revision        The standard revision of the XML document being read.\r\n     *\r\n     *    @return The created parameter.\r\n     */\r\n    IPXACTMODELS_EXPORT QSharedPointer<Parameter> createParameterFrom(QDomNode const& parameterNode,\r\n        Document::Revision revision = Document::Revision::Std14);\r\n    \r\n    namespace Details\r\n    {\r\n\r\n        /*!\r\n         *  Reads the attributes from XML to a parameter.\r\n         *\r\n         *    @param [in] parameterNode   The XML description of the parameter.\r\n         *    @param [in/out] parameter   The parameter to insert the attributes into.\r\n         */\r\n        void parseAttributes(QDomNode const& parameterNode, QSharedPointer<Parameter> parameter);\r\n\r\n        /*!\r\n         *  Reads the vectors from XML to a parameter.\r\n         *\r\n         *    @param [in] parameterNode   The XML description of the parameter.\r\n         *    @param [in/out] parameter   The parameter to insert the vectors into.\r\n         *    @param [in] revision        The standard revision of the XML document being read.\r\n         */\r\n        void parseVectors(QDomNode const& parameterNode, QSharedPointer<Parameter> parameter,\r\n            Document::Revision revision = Document::Revision::Std14);\r\n\r\n        /*!\r\n         *  Reads the arrays from XML to a parameter.\r\n         *\r\n         *    @param [in] parameterNode   The XML description of the parameter.\r\n         *    @param [in/out] parameter   The parameter to insert the arrays into.\r\n         *    @param [in] revision        The standard revision of the XML document being read.\r\n         */\r\n        void parseArrays(QDomNode const& parameterNode, QSharedPointer<Parameter> parameter,\r\n            Document::Revision revision = Document::Revision::Std14);\r\n\r\n        /*!\r\n         *  Reads the parameter value from XML to a parameter.\r\n         *\r\n         *    @param [in] parameterNode   The XML description of the parameter.\r\n         *    @param [in/out] parameter   The parameter to insert the value into.\r\n         */\r\n        void parseValue(QDomNode const& parameterNode, QSharedPointer<Parameter> parameter);\r\n    }\r\n};\r\n\r\n#endif // PARAMETERREADER_H"
  },
  {
    "path": "IPXACTmodels/common/ParameterWriter.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ParameterWriter.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Esko Pekkarinen\r\n// Date: 31.07.2015\r\n//\r\n// Description:\r\n// Writer for IP-XACT Parameter element.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"ParameterWriter.h\"\r\n\r\n#include <IPXACTmodels/common/Parameter.h>\r\n#include <IPXACTmodels/common/CommonItemsWriter.h>\r\n#include <IPXACTmodels/common/NameGroupWriter.h>\r\n#include <IPXACTmodels/common/VendorExtension.h>\r\n\r\n#include <QSharedPointer>\r\n#include <QXmlStreamWriter>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ParameterWriter::write()\r\n//-----------------------------------------------------------------------------\r\nvoid ParameterWriter::writeParameter(QXmlStreamWriter& writer, QSharedPointer<Parameter> parameter,\r\n    Document::Revision docRevision)\r\n{\r\n    writer.writeStartElement(QStringLiteral(\"ipxact:parameter\"));\r\n    Details::writeAttributes(writer, parameter);\r\n    \r\n    Details::writeNameGroup(writer, parameter, docRevision);\r\n\r\n    Details::writeVectors(writer, parameter, docRevision);\r\n\r\n    Details::writeArrays(writer, parameter, docRevision);\r\n\r\n    Details::writeValue(writer, parameter);\r\n\r\n    CommonItemsWriter::writeVendorExtensions(writer, parameter);\r\n\r\n    writer.writeEndElement(); // ipxact:parameter\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ParameterWriter::Details::writeAttributes()\r\n//-----------------------------------------------------------------------------\r\nvoid ParameterWriter::Details::writeAttributes(QXmlStreamWriter& writer, QSharedPointer<Parameter> parameter)\r\n{\r\n    for (auto const& attribute : parameter->getAttributeNames())\r\n    {\r\n        writer.writeAttribute(attribute, parameter->getAttribute(attribute));\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ParameterWriter::Details::writeNameGroup()\r\n//-----------------------------------------------------------------------------\r\nvoid ParameterWriter::Details::writeNameGroup(QXmlStreamWriter& writer, QSharedPointer<Parameter> parameter, \r\n    Document::Revision docRevision)\r\n{\r\n    NameGroupWriter::writeNameGroup(writer, parameter, docRevision);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ParameterWriter::Details::writeArrays()\r\n//-----------------------------------------------------------------------------\r\nvoid ParameterWriter::Details::writeArrays(QXmlStreamWriter& writer, QSharedPointer<Parameter> parameter,\r\n    Document::Revision docRevision)\r\n{\r\n    QSharedPointer<QList<QSharedPointer<Array> > > arrays = parameter->getArrays();\r\n    if (!arrays->isEmpty())\r\n    {\r\n        writer.writeStartElement(QStringLiteral(\"ipxact:arrays\"));\r\n        for (QSharedPointer<Array> array : *arrays)\r\n        {\r\n            writer.writeStartElement(QStringLiteral(\"ipxact:array\"));\r\n            if (docRevision == Document::Revision::Std22)\r\n            {\r\n                CommonItemsWriter::writeNonEmptyAttribute(writer, QStringLiteral(\"arrayId\"), array->getId());\r\n            }\r\n\r\n            writer.writeTextElement(QStringLiteral(\"ipxact:left\"), array->getLeft());\r\n            writer.writeTextElement(QStringLiteral(\"ipxact:right\"), array->getRight());\r\n            writer.writeEndElement();\r\n        }\r\n        writer.writeEndElement();\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ParameterWriter::Details::writeVectors()\r\n//-----------------------------------------------------------------------------\r\nvoid ParameterWriter::Details::writeVectors(QXmlStreamWriter& writer, QSharedPointer<Parameter> parameter,\r\n    Document::Revision docRevision)\r\n{\r\n    QSharedPointer<QList<QSharedPointer<Vector> > > vectors = parameter->getVectors();\r\n    if (!vectors->isEmpty())\r\n    {\r\n        writer.writeStartElement(QStringLiteral(\"ipxact:vectors\"));\r\n        for (QSharedPointer<Vector> vector : *vectors)\r\n        {\r\n            writer.writeStartElement(QStringLiteral(\"ipxact:vector\"));\r\n\r\n            if (docRevision == Document::Revision::Std22)\r\n            {\r\n                CommonItemsWriter::writeNonEmptyAttribute(writer, QStringLiteral(\"vectorId\"), vector->getId());\r\n            }\r\n\r\n            writer.writeTextElement(QStringLiteral(\"ipxact:left\"), vector->getLeft());\r\n            writer.writeTextElement(QStringLiteral(\"ipxact:right\"), vector->getRight());\r\n            writer.writeEndElement();\r\n        }\r\n        writer.writeEndElement();\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ParameterWriter::Details::writeValue()\r\n//-----------------------------------------------------------------------------\r\nvoid ParameterWriter::Details::writeValue(QXmlStreamWriter& writer, QSharedPointer<Parameter> parameter)\r\n{\r\n    writer.writeStartElement(QStringLiteral(\"ipxact:value\"));\r\n    \r\n    for (auto const& attribute : parameter->getValueAttributeNames())\r\n    {\r\n        writer.writeAttribute(attribute, parameter->getValueAttribute(attribute));\r\n    }\r\n\r\n    writer.writeCharacters(parameter->getValue());\r\n    writer.writeEndElement();\r\n}\r\n"
  },
  {
    "path": "IPXACTmodels/common/ParameterWriter.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ParameterWriter.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Esko Pekkarinen\r\n// Date: 31.07.2015\r\n//\r\n// Description:\r\n// Writer for IP-XACT Parameter element.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef PARAMETERWRITER_H\r\n#define PARAMETERWRITER_H\r\n\r\n#include <QObject>\r\n#include <QSharedPointer>\r\n#include <QXmlStreamWriter>\r\n\r\n#include <IPXACTmodels/ipxactmodels_global.h>\r\n#include <IPXACTmodels/common/Document.h>\r\n\r\nclass Parameter;\r\nclass VendorExtension;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Writer for IP-XACT Parameter element.\r\n//-----------------------------------------------------------------------------\r\nnamespace ParameterWriter\r\n{\r\n\r\n    /*!\r\n     *  Writes the given parameter into xml.\r\n     *\r\n     *    @param [in] writer      The xml writer to use.\r\n     *    @param [in] parameter   The parameter to write.\r\n     *    @param [in] docRevision The document std revision.\r\n     */\r\n    IPXACTMODELS_EXPORT void writeParameter(QXmlStreamWriter& writer, QSharedPointer<Parameter> parameter, \r\n        Document::Revision docRevision);\r\n\r\n    namespace Details\r\n    {\r\n\r\n        /*!\r\n         *  Writes the attributes of a given parameter into xml.\r\n         *\r\n         *    @param [in] writer      The xml writer to use.\r\n         *    @param [in] parameter   The parameter whose attributes to write.\r\n         */\r\n        void writeAttributes(QXmlStreamWriter& writer, QSharedPointer<Parameter> parameter);\r\n\r\n        /*!\r\n         *  Writes the name group of a given parameter into xml.\r\n         *\r\n         *    @param [in] writer      The xml writer to use.\r\n         *    @param [in] parameter   The parameter whose name group to write.\r\n         *    @param [in] docRevision The document std revision.\r\n         */\r\n        void writeNameGroup(QXmlStreamWriter& writer, QSharedPointer<Parameter> parameter,\r\n            Document::Revision docRevision);\r\n\r\n        /*!\r\n         *  Writes the vectors of a given parameter into xml.\r\n         *\r\n         *    @param [in] writer      The xml writer to use.\r\n         *    @param [in] parameter   The parameter whose vectors to write.\r\n         *    @param [in] docRevision The document std revision.\r\n         */\r\n        void writeVectors(QXmlStreamWriter& writer, QSharedPointer<Parameter> parameter, \r\n            Document::Revision docRevision);\r\n\r\n        /*!\r\n         *  Writes the arrays of a given parameter into xml.\r\n         *\r\n         *    @param [in] writer      The xml writer to use.\r\n         *    @param [in] parameter   The parameter whose arrays to write.\r\n         *    @param [in] docRevision The document std revision.\r\n         */\r\n        void writeArrays(QXmlStreamWriter& writer, QSharedPointer<Parameter> parameter,\r\n            Document::Revision docRevision);\r\n\r\n        /*!\r\n         *  Writes the value of a given parameter into xml.\r\n         *\r\n         *    @param [in] writer      The xml writer to use.\r\n         *    @param [in] parameter   The parameter whose value to write.\r\n         */\r\n        void writeValue(QXmlStreamWriter& writer, QSharedPointer<Parameter> parameter);\r\n    }\r\n};\r\n\r\n#endif // PARAMETERWRITER_H\r\n"
  },
  {
    "path": "IPXACTmodels/common/PartSelect.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: PartSelect.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 24.08.2015\r\n//\r\n// Description:\r\n// Describes an ipxact:partSelect element.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"PartSelect.h\"\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PartSelect::PartSelect()\r\n//-----------------------------------------------------------------------------\r\nPartSelect::PartSelect(QString const& leftRange, QString const& rightRange):\r\nrange_(leftRange, rightRange)\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PartSelect::PartSelect()\r\n//-----------------------------------------------------------------------------\r\nPartSelect::PartSelect(const PartSelect& other):\r\nrange_(other.range_)\r\n{\r\n    for (QString const& index : *other.indices_)\r\n    {\r\n        indices_->append(index);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PartSelect::clone()\r\n//-----------------------------------------------------------------------------\r\nPartSelect* PartSelect::clone() const\r\n{\r\n    return new PartSelect(*this);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PartSelect::operator=()\r\n//-----------------------------------------------------------------------------\r\nPartSelect& PartSelect::operator=(const PartSelect& other)\r\n{\r\n    if (this != &other)\r\n    {\r\n        range_ = other.range_;\r\n\r\n        indices_->clear();\r\n        for (QString const& index : *other.indices_)\r\n        {\r\n            indices_->append(index);\r\n        }\r\n    }\r\n\r\n    return *this;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PartSelect::getLeftRange()\r\n//-----------------------------------------------------------------------------\r\nQString PartSelect::getLeftRange() const\r\n{\r\n    return range_.getLeft();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PartSelect::getRightRange()\r\n//-----------------------------------------------------------------------------\r\nQString PartSelect::getRightRange() const\r\n{\r\n    return range_.getRight();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PartSelect::getRange()\r\n//-----------------------------------------------------------------------------\r\nRange PartSelect::getRange() const\r\n{\r\n    return range_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PartSelect::setLeftRange()\r\n//-----------------------------------------------------------------------------\r\nvoid PartSelect::setLeftRange(QString const& newLeftRange)\r\n{\r\n    range_.setLeft(newLeftRange);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PartSelect::setRightRange()\r\n//-----------------------------------------------------------------------------\r\nvoid PartSelect::setRightRange(QString const& newRightRange)\r\n{\r\n    range_.setRight(newRightRange);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PartSelect::getIndices()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<QStringList> PartSelect::getIndices() const\r\n{\r\n    return indices_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PartSelect::setIndices()\r\n//-----------------------------------------------------------------------------\r\nvoid PartSelect::setIndices(QSharedPointer<QStringList> newIndices)\r\n{\r\n    indices_ = newIndices;\r\n}\r\n"
  },
  {
    "path": "IPXACTmodels/common/PartSelect.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: PartSelect.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 24.08.2015\r\n//\r\n// Description:\r\n// Describes an ipxact:partSelect element.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef PARTSELECT_H\r\n#define PARTSELECT_H\r\n\r\n#include \"Range.h\"\r\n\r\n#include <IPXACTmodels/ipxactmodels_global.h>\r\n\r\n\r\n#include <QString>\r\n#include <QStringList>\r\n#include <QSharedPointer>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Describes an ipxact:partSelect element.\r\n//\r\n// PartSelect defines a selection of subelements from within a referenced port element.\r\n//-----------------------------------------------------------------------------\r\nclass IPXACTMODELS_EXPORT PartSelect\r\n{\r\n\r\npublic:\r\n\r\n    /*!\r\n     *  The constructor.\r\n     *\r\n     *    @param [in] leftRange   The left value for the range.\r\n     *    @param [in] rightRange  The right value for the range.\r\n     */\r\n    PartSelect(QString const& leftRange = QString(), QString const& rightRange = QString());\r\n\r\n    /*!\r\n     *  Copy constructor.\r\n     */\r\n    PartSelect(const PartSelect& other);\r\n    \r\n    /*!\r\n     *  The destructor.\r\n     */\r\n    ~PartSelect() = default;\r\n\r\n    /*!\r\n     *  Create a copy of the PartSelect.\r\n     *\r\n     *    @return A PartSelect identical to this.\r\n     */\r\n    PartSelect* clone() const;\r\n\r\n    /*!\r\n     *  Assignment operator.\r\n     */\r\n    PartSelect& operator=(const PartSelect& other);\r\n\r\n    /*!\r\n     *  Get the left value of the range.\r\n     *\r\n     *    @return The left value of the range.\r\n     */\r\n    QString getLeftRange() const;\r\n\r\n    /*!\r\n     *  Get the right value of the range.\r\n     *\r\n     *    @return The right value of the range.\r\n     */\r\n    QString getRightRange() const;\r\n\r\n    Range getRange() const;\r\n\r\n    /*!\r\n     *  Set the left value for the range.\r\n     *\r\n     *    @param [in] newLeftRange    The new value for the left value of the range.\r\n     */\r\n    void setLeftRange(QString const& newLeftRange);\r\n\r\n    /*!\r\n     *  Set the right value for the range.\r\n     *\r\n     *    @param [in] newRightRange   The new value for the right value of the range.\r\n     */\r\n    void setRightRange(QString const& newRightRange);\r\n\r\n    /*!\r\n     *  Get the list of indexes.\r\n     *\r\n     *    @return Pointer to a list of indexes,\r\n     */\r\n    QSharedPointer<QStringList> getIndices() const;\r\n\r\n    /*!\r\n     *  Set the list of indexes.\r\n     *\r\n     *    @param [in] newIndices  A new list of indexes.\r\n     */\r\n    void setIndices(QSharedPointer<QStringList> newIndices);\r\n\r\nprivate:\r\n\r\n    //! The range.\r\n    Range range_;\r\n\r\n    //! The list of indexes.\r\n    QSharedPointer<QStringList> indices_ =\r\n        QSharedPointer<QStringList>(new QStringList());\r\n};\r\n#endif // PARTSELECT_H\r\n"
  },
  {
    "path": "IPXACTmodels/common/PortAlignment.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: PortAlignment.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 27.01.2016\r\n//\r\n// Description:\r\n// Implementation of port alignment class.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"PortAlignment.h\"\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PortAlignment::PortAlignment()\r\n//-----------------------------------------------------------------------------\r\nPortAlignment::PortAlignment(int leftAlignment, int rightAlignment):\r\nleftAlignment_(leftAlignment),\r\n    rightAlignment_(rightAlignment),\r\n    validAlignment_(true)\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PortAlignment::PortAlignment()\r\n//-----------------------------------------------------------------------------\r\nPortAlignment::PortAlignment(PortAlignment const& other):\r\nleftAlignment_(other.leftAlignment_),\r\n    rightAlignment_(other.rightAlignment_),\r\n    validAlignment_(other.validAlignment_)\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PortAlignment::~PortAlignment()\r\n//-----------------------------------------------------------------------------\r\nPortAlignment::~PortAlignment()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PortAlignment::getLeftAlignment()\r\n//-----------------------------------------------------------------------------\r\nint PortAlignment::getLeftAlignment() const\r\n{\r\n    return leftAlignment_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PortAlignment::setLeftAlignment()\r\n//-----------------------------------------------------------------------------\r\nvoid PortAlignment::setLeftAlignment(int newLeftAlignment)\r\n{\r\n    leftAlignment_ = newLeftAlignment;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PortAlignment::getRightAlignment()\r\n//-----------------------------------------------------------------------------\r\nint PortAlignment::getRightAlignment() const\r\n{\r\n    return rightAlignment_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PortAlignment::setRightAlignment()\r\n//-----------------------------------------------------------------------------\r\nvoid PortAlignment::setRightAlignment(int newRightAlignment)\r\n{\r\n    rightAlignment_ = newRightAlignment;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PortAlignment::isValid()\r\n//-----------------------------------------------------------------------------\r\nbool PortAlignment::isValid() const\r\n{\r\n    return validAlignment_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PortAlignment::setAlignmentValidity()\r\n//-----------------------------------------------------------------------------\r\nvoid PortAlignment::setAlignmentValidity(bool validity)\r\n{\r\n    validAlignment_ = validity;\r\n}\r\n"
  },
  {
    "path": "IPXACTmodels/common/PortAlignment.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: PortAlignment.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 27.01.2016\r\n//\r\n// Description:\r\n// Implementation of port alignment class.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef PORTALIGNMENT_H\r\n#define PORTALIGNMENT_H\r\n\r\n#include <IPXACTmodels/ipxactmodels_global.h>\r\n\r\n#include <QString>\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Implementation of port alignment class.\r\n//-----------------------------------------------------------------------------\r\nclass IPXACTMODELS_EXPORT PortAlignment\r\n{\r\npublic:\r\n\r\n    /*!\r\n     *  The constructor.\r\n     *\r\n     *    @param [in] leftAlignment   The higher alignment of the port.\r\n     *    @param [in] right           The lower alignment of the port.\r\n     */\r\n    PortAlignment(int leftAlignment = 0, int rightAlignment = 0);\r\n\r\n    //! The copy constructor.\r\n    PortAlignment(PortAlignment const& other);\r\n\r\n\t/*!\r\n\t *  The destructor.\r\n\t*/\r\n    ~PortAlignment();\r\n\r\n    /*!\r\n     *  Get the higher (left) alignment of the port.\r\n     *\r\n     *    @return The higher (left) alignment of the port.\r\n     */\r\n    int getLeftAlignment() const;\r\n\r\n    /*!\r\n     *  Set the higher (left) alignment of the port.\r\n     *\r\n     *    @param [in] newLeftAlignment    The new higher (left) alignment.\r\n     */\r\n    void setLeftAlignment(int newLeftAlignment);\r\n\r\n    /*!\r\n     *  Get the lower (right) alignment of the port.\r\n     *\r\n     *    @return The lower (right) alignment of the port.\r\n     */\r\n    int getRightAlignment() const;\r\n\r\n    /*!\r\n     *  Set the lower (right) alignment of the port.\r\n     *\r\n     *    @param [in] newRightAlignment   The new lower (right) alignment.\r\n     */\r\n    void setRightAlignment(int newRightAlignment);\r\n\r\n    /*!\r\n     *  Check if the port alignment is valid.\r\n     *\r\n     *    @return True, if the alignment is valid, false otherwise.\r\n     */\r\n    bool isValid() const;\r\n\r\n    /*!\r\n     *  Set the validity of the port alignment.\r\n     *\r\n     *    @param [in] validity    The new validity of the port alignment.\r\n     */\r\n    void setAlignmentValidity(bool validity);\r\n\r\nprivate:\r\n\r\n\t// Disable assignment.\r\n    PortAlignment& operator=(PortAlignment const& rhs);\r\n    \r\n\t//-----------------------------------------------------------------------------\r\n\t// Data.\r\n\t//-----------------------------------------------------------------------------\r\n\r\n    //! The higher (left) bound of the alignment.\r\n    int leftAlignment_;\r\n\r\n    //! The lower (right) bound of the alignment.\r\n    int rightAlignment_;\r\n\r\n    //! The validity of the alignment.\r\n    bool validAlignment_;\r\n};\r\n#endif // PORTALIGNMENT_H\r\n"
  },
  {
    "path": "IPXACTmodels/common/PresenceTypes.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// PresenceTypes: PresenceTypes.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Janne Virtanen\r\n// Date: 08.12.2015\r\n//\r\n// Description:\r\n// Contains definitions and functions for presence types.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"PresenceTypes.h\"\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PresenceTypes::str2Presence()\r\n//-----------------------------------------------------------------------------\r\nPresenceTypes::Presence PresenceTypes::str2Presence(QString str, PresenceTypes::Presence defaultValue)\r\n{\r\n\t// Identify the correct enum value.\r\n\tif (str == QLatin1String(\"illegal\"))\r\n\t{\r\n\t\treturn PresenceTypes::ILLEGAL;\r\n\t}\r\n\telse if (str == QLatin1String(\"required\"))\r\n\t{\r\n\t\treturn PresenceTypes::REQUIRED;\r\n\t}\r\n\telse if (str == QLatin1String(\"optional\"))\r\n\t{\r\n\t\treturn PresenceTypes::OPTIONAL;\r\n\t}\r\n\telse\r\n\t{\r\n\t\treturn defaultValue;\r\n\t}\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PresenceTypes::presence2Str()\r\n//-----------------------------------------------------------------------------\r\nQString PresenceTypes::presence2Str(PresenceTypes::Presence presence)\r\n{\r\n    // Create string based on the enum value.\r\n    if (presence == PresenceTypes::ILLEGAL)\r\n    {\r\n        return QStringLiteral(\"illegal\");\r\n    }\r\n    else if (presence == PresenceTypes::REQUIRED)\r\n    {\r\n        return QStringLiteral(\"required\");\r\n    }\r\n    else if (presence == PresenceTypes::OPTIONAL)\r\n    {\r\n        return QStringLiteral(\"optional\");\r\n    }\r\n    else\r\n    {\r\n        return QString();\r\n    }\r\n}\r\n"
  },
  {
    "path": "IPXACTmodels/common/PresenceTypes.h",
    "content": "//-----------------------------------------------------------------------------\r\n// PresenceTypes: PresenceTypes.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Janne Virtanen\r\n// Date: 08.12.2015\r\n//\r\n// Description:\r\n// Contains definitions and functions for presence types.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef PRESENCETYPES_H\r\n#define PRESENCETYPES_H\r\n\r\n#include <IPXACTmodels/ipxactmodels_global.h>\r\n\r\n#include <QString>\r\n\r\nnamespace PresenceTypes\r\n{\r\n    /*!\r\n    * Provides the capability to require or forbid a port to appear in a\r\n    * bus interface.\r\n    */\r\n\tenum Presence\r\n\t{\r\n\t\tILLEGAL = 1,\r\n\t\tOPTIONAL = 2,\r\n\t\tREQUIRED = 4,\r\n\t\tUNKNOWN = 8,\r\n        ALL = 16\r\n    };\r\n\r\n    /*! Convert the value of the QString into enum Presence\r\n    *\r\n    * if The str does not match any of the enum values the default value\r\n    * specifies as parameter will be returned\r\n    *\r\n    *    @param [in] str QString containing the string to be converted\r\n    *    @param [in] defaultValue The value that will be returned if no match is found\r\n    *\r\n    *    @return General::Presence that matches the str or default value.\r\n    */\r\n    IPXACTMODELS_EXPORT Presence str2Presence(QString str, Presence defaultValue);\r\n\r\n    /*! Convert the enum presence to QString.\r\n    *\r\n    *    @param [in] presence The enum value to be converted\r\n    *\r\n    *    @return QString matching the enum value.\r\n    */\r\n    IPXACTMODELS_EXPORT QString presence2Str(Presence presence);\r\n}\r\n\r\n#endif"
  },
  {
    "path": "IPXACTmodels/common/Protocol.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: Protocol.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Esko Pekkarinen\r\n// Date: 21.08.2015\r\n//\r\n// Description:\r\n// Implementation of ipxact:protocol.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"Protocol.h\"\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Protocol::clone()\r\n//-----------------------------------------------------------------------------\r\nProtocol* Protocol::clone() const\r\n{\r\n    return new Protocol(*this);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Protocol::setType()\r\n//-----------------------------------------------------------------------------\r\nvoid Protocol::setProtocolType(QString const& type)\r\n{\r\n    if (type == QStringLiteral(\"tlm\"))\r\n    {\r\n        protocolType_ = type;\r\n        customProtocolType_.clear();\r\n    }\r\n    else\r\n    {\r\n        protocolType_ = QStringLiteral(\"custom\");\r\n        customProtocolType_ = type;\r\n    }    \r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Protocol::getType()\r\n//-----------------------------------------------------------------------------\r\nQString Protocol::getProtocolType() const\r\n{\r\n    return protocolType_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Protocol::getCustomProtocolType()\r\n//-----------------------------------------------------------------------------\r\nQString Protocol::getCustomProtocolType() const\r\n{\r\n    return customProtocolType_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Protocol::hasPayload()\r\n//-----------------------------------------------------------------------------\r\nbool Protocol::hasPayload() const\r\n{\r\n    return !payloadType_.isEmpty() || !payloadName_.isEmpty() || !payloadExtension_.isEmpty();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Protocol::setPayloadName()\r\n//-----------------------------------------------------------------------------\r\nvoid Protocol::setPayloadName(QString const& payloadName)\r\n{\r\n    payloadName_ = payloadName;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Protocol::getPayloadName()\r\n//-----------------------------------------------------------------------------\r\nQString Protocol::getPayloadName() const\r\n{\r\n    return payloadName_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Protocol::setPayloadType()\r\n//-----------------------------------------------------------------------------\r\nvoid Protocol::setPayloadType(QString const& payloadType)\r\n{\r\n    payloadType_ = payloadType;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Protocol::getPayloadType()\r\n//-----------------------------------------------------------------------------\r\nQString Protocol::getPayloadType() const\r\n{\r\n    return payloadType_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Protocol::setPayloadExtension()\r\n//-----------------------------------------------------------------------------\r\nvoid Protocol::setPayloadExtension(QString const& extension, bool mandatory)\r\n{\r\n    payloadExtension_ = extension;\r\n    mandatoryPayloadExtension_ = mandatory;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Protocol::getPayloadExtension()\r\n//-----------------------------------------------------------------------------\r\nQString Protocol::getPayloadExtension() const\r\n{\r\n    return payloadExtension_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Protocol::hasMandatoryPayloadExtension()\r\n//-----------------------------------------------------------------------------\r\nbool Protocol::hasMandatoryPayloadExtension() const\r\n{\r\n    return mandatoryPayloadExtension_;\r\n}\r\n"
  },
  {
    "path": "IPXACTmodels/common/Protocol.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: Protocol.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Esko Pekkarinen\r\n// Date: 21.08.2015\r\n//\r\n// Description:\r\n// Implementation of ipxact:protocol.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef PROTOCOL_H\r\n#define PROTOCOL_H\r\n\r\n#include \"Extendable.h\"\r\n\r\n#include <IPXACTmodels/ipxactmodels_global.h>\r\n\r\n#include <QString>\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Implementation of ipxact:protocol.\r\n//-----------------------------------------------------------------------------\r\nclass IPXACTMODELS_EXPORT Protocol : public Extendable\r\n{\r\npublic:\r\n\r\n\t//! The destructor.\r\n\t~Protocol() final = default;\r\n\r\n    /*!\r\n     *  Create a copy of the Protocol.\r\n     *\r\n     *    @return A Protocol identical to this.\r\n     */\r\n    Protocol* clone() const;\r\n\r\n    /*!\r\n     *  Sets the protocol type.\r\n     *\r\n     *    @param [in] type   The type to set.\r\n     */\r\n    void setProtocolType(QString const& type);\r\n\r\n    /*!\r\n     *  Gets the protocol type.\r\n     *\r\n     *    @return The protocol type.\r\n     */\r\n    QString getProtocolType() const;\r\n    \r\n    QString getCustomProtocolType() const;\r\n\r\n    /*!\r\n     *  Checks if the protocol has payload defined.\r\n     *\r\n     *    @return True, if payload is defined, otherwise false.\r\n     */\r\n    bool hasPayload() const;\r\n\r\n    /*!\r\n     *  Sets the name for the payload.\r\n     *\r\n     *    @param [in] payloadName   The name to set.\r\n     */\r\n    void setPayloadName(QString const& payloadName);\r\n   \r\n    /*!\r\n     *  Gets the name of the payload.\r\n     *\r\n     *    @return The name of the payload.\r\n     */\r\n    QString getPayloadName() const;\r\n\r\n    /*!\r\n     *  Sets the type for the payload.\r\n     *\r\n     *    @param [in] payloadType   The type to set.\r\n     */\r\n    void setPayloadType(QString const& payloadType);\r\n\r\n    /*!\r\n     *  Gets the payload type.\r\n     *\r\n     *    @return The payload type.\r\n     */\r\n    QString getPayloadType() const;\r\n\r\n    /*!\r\n     *  Sets the extension for the payload.\r\n     *\r\n     *    @param [in] extension   The extension to set.\r\n     *    @param [in] mandatory   Specifies if the extension is mandatory or not.\r\n     */\r\n    void setPayloadExtension(QString const& extension, bool mandatory);\r\n\r\n    /*!\r\n     *  Gets the payload extension.\r\n     *\r\n     *    @return The payload extension.\r\n     */\r\n    QString getPayloadExtension() const;\r\n\r\n    /*!\r\n     *  Checks if the payload extension is mandatory or not.\r\n     *\r\n     *    @return True, if the extension is mandatory, otherwise false.\r\n     */\r\n    bool hasMandatoryPayloadExtension() const;\r\n\r\nprivate:\r\n\r\n    //! The type of the protocol.\r\n    QString protocolType_;\r\n\r\n    //! The type of a custom protocol.\r\n    QString customProtocolType_;\r\n\r\n    //! The name of the payload in the protocol.\r\n    QString payloadName_;\r\n\r\n    //! The type of the payload in the protocol.\r\n    QString payloadType_;\r\n\r\n    //! The extension of the payload in the protocol.\r\n    QString payloadExtension_;\r\n\r\n    //! Specifies if the payload extension is mandatory or not.\r\n    bool mandatoryPayloadExtension_{ false };\r\n};\r\n\r\n#endif // PROTOCOL_H\r\n"
  },
  {
    "path": "IPXACTmodels/common/ProtocolReader.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ProtocolReader.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 15.09.2015\r\n//\r\n// Description:\r\n// Reader class for ipxact:protocl within component.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"ProtocolReader.h\"\r\n#include \"Protocol.h\"\r\n#include \"CommonItemsReader.h\"\r\n\r\n#include <IPXACTmodels/common/GenericVendorExtension.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ProtocolReader::ProtocolReader()\r\n//-----------------------------------------------------------------------------\r\nProtocolReader::ProtocolReader()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ProtocolReader::~ProtocolReader()\r\n//-----------------------------------------------------------------------------\r\nProtocolReader::~ProtocolReader()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ProtocolReader::createProtocolFrom()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<Protocol> ProtocolReader::createProtocolFrom(QDomNode const& protocolNode) const\r\n{\r\n    QSharedPointer<Protocol> protocol(new Protocol());\r\n\r\n    if (!protocolNode.isNull())\r\n    {\r\n        QString protocolType = protocolNode.firstChildElement(\r\n            QStringLiteral(\"ipxact:protocolType\")).firstChild().nodeValue();\r\n        if (protocolType == QLatin1String(\"custom\"))\r\n        {\r\n            QDomElement protocolElement = protocolNode.firstChildElement(QStringLiteral(\"ipxact:protocolType\"));\r\n            protocolType = protocolElement.attribute(QStringLiteral(\"custom\"));\r\n        }\r\n        protocol->setProtocolType(protocolType);\r\n\r\n        QDomNode payloadNode = protocolNode.firstChildElement(QStringLiteral(\"ipxact:payload\"));\r\n\r\n        protocol->setPayloadName(payloadNode.firstChildElement(\r\n            QStringLiteral(\"ipxact:name\")).firstChild().nodeValue());\r\n        protocol->setPayloadType(payloadNode.firstChildElement(\r\n            QStringLiteral(\"ipxact:type\")).firstChild().nodeValue());\r\n\r\n        bool mandatoryExtension = payloadNode.firstChildElement(QStringLiteral(\"ipxact:extension\")).attribute(\r\n            QStringLiteral(\"mandatory\")) == QLatin1String(\"true\");\r\n        protocol->setPayloadExtension(payloadNode.firstChildElement(\r\n            QStringLiteral(\"ipxact:extension\")).firstChild().nodeValue(), mandatoryExtension);\r\n\r\n        CommonItemsReader::parseVendorExtensions(payloadNode, protocol);\r\n    }\r\n\r\n    return protocol;\r\n}\r\n\r\n"
  },
  {
    "path": "IPXACTmodels/common/ProtocolReader.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ProtocolReader.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 15.09.2015\r\n//\r\n// Description:\r\n// Reader class for ipxact:protocl within component.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef PROTOCOLREADER_H\r\n#define PROTOCOLREADER_H\r\n\r\n#include <QDomNode>\r\n#include <QSharedPointer>\r\n\r\nclass Protocol;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Reader class for ipxact:protocl within component.\r\n//-----------------------------------------------------------------------------\r\nclass ProtocolReader\r\n{\r\npublic:\r\n\r\n    /*!\r\n     *  The constructor.\r\n     *\r\n     *    @param [in] parent   The parent object.\r\n     */\r\n    ProtocolReader();\r\n\r\n    //! The destructor.\r\n    ~ProtocolReader();  \r\n\r\n    // Disable copying.\r\n    ProtocolReader(ProtocolReader const& rhs) = delete;\r\n    ProtocolReader& operator=(ProtocolReader const& rhs) = delete;\r\n\r\n    /*!\r\n     *  Creates a protocol from XML description.\r\n     *\r\n     *    @param [in] protocolNode    The XML description of the protocol.\r\n     */\r\n    QSharedPointer<Protocol> createProtocolFrom(QDomNode const& protocolNode) const;\r\n\r\n};\r\n\r\n#endif // PROTOCOLREADER_H\r\n"
  },
  {
    "path": "IPXACTmodels/common/ProtocolWriter.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ProtocolWriter.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 14.09.2015\r\n//\r\n// Description:\r\n// Writer class for IP-XACT protocol element.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"ProtocolWriter.h\"\r\n#include \"Protocol.h\"\r\n#include \"CommonItemsWriter.h\"\r\n\r\n#include <IPXACTmodels/common/VendorExtension.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ProtocolWriter::ProtocolWriter()\r\n//-----------------------------------------------------------------------------\r\nProtocolWriter::ProtocolWriter()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ProtocolWriter::~ProtocolWriter()\r\n//-----------------------------------------------------------------------------\r\nProtocolWriter::~ProtocolWriter()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ProtocolWriter::writePort()\r\n//-----------------------------------------------------------------------------\r\nvoid ProtocolWriter::writeProtocol(QXmlStreamWriter& writer, QSharedPointer<Protocol> protocol) const\r\n{\r\n    if (!protocol.isNull())\r\n    {\r\n        writer.writeStartElement(QStringLiteral(\"ipxact:protocol\"));\r\n\r\n        writeProtocolType(writer, protocol);\r\n        writePayload(writer, protocol);\r\n\r\n        writer.writeEndElement(); // ipxact:protocol\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ProtocolWriter::writeProtocolType()\r\n//-----------------------------------------------------------------------------\r\nvoid ProtocolWriter::writeProtocolType(QXmlStreamWriter& writer, QSharedPointer<Protocol> portProtocol) const\r\n{\r\n    if (portProtocol->getProtocolType() == QLatin1String(\"tlm\"))\r\n    {\r\n        writer.writeTextElement(QStringLiteral(\"ipxact:protocolType\"), QStringLiteral(\"tlm\"));\r\n    }\r\n    else\r\n    {\r\n        writer.writeStartElement(QStringLiteral(\"ipxact:protocolType\"));\r\n        writer.writeAttribute(QStringLiteral(\"custom\"), portProtocol->getCustomProtocolType());\r\n        writer.writeCharacters(QStringLiteral(\"custom\"));\r\n        writer.writeEndElement();\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ProtocolWriter::writePayload()\r\n//-----------------------------------------------------------------------------\r\nvoid ProtocolWriter::writePayload(QXmlStreamWriter& writer, QSharedPointer<Protocol> portProtocol) const\r\n{\r\n    if (!portProtocol->getPayloadType().isEmpty() || !portProtocol->getPayloadName().isEmpty() ||\r\n        !portProtocol->getPayloadExtension().isEmpty())\r\n    {\r\n        writer.writeStartElement(QStringLiteral(\"ipxact:payload\"));\r\n\r\n        if (!portProtocol->getPayloadName().isEmpty())\r\n        {\r\n            writer.writeTextElement(QStringLiteral(\"ipxact:name\"), portProtocol->getPayloadName());\r\n        }\r\n\r\n        writer.writeTextElement(QStringLiteral(\"ipxact:type\"), portProtocol->getPayloadType());\r\n\r\n        if (!portProtocol->getPayloadExtension().isEmpty())\r\n        {\r\n            writer.writeStartElement(QStringLiteral(\"ipxact:extension\"));\r\n         \r\n            if (portProtocol->hasMandatoryPayloadExtension())\r\n            {\r\n                writer.writeAttribute(QStringLiteral(\"mandatory\"), QStringLiteral(\"true\"));\r\n            }\r\n            writer.writeCharacters(portProtocol->getPayloadExtension());\r\n\r\n            writer.writeEndElement();\r\n        }\r\n\r\n        CommonItemsWriter::writeVendorExtensions(writer, portProtocol);\r\n\r\n        writer.writeEndElement();\r\n    }\r\n}\r\n"
  },
  {
    "path": "IPXACTmodels/common/ProtocolWriter.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ProtocolWriter.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 14.09.2015\r\n//\r\n// Description:\r\n// Writer class for IP-XACT protocol element.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef PROTOCOLWRITER_H\r\n#define PROTOCOLWRITER_H\r\n\r\n#include <QSharedPointer>\r\n#include <QXmlStreamWriter>\r\n\r\nclass Protocol;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Writer class for IP-XACT protocol element.\r\n//-----------------------------------------------------------------------------\r\nclass ProtocolWriter\r\n{\r\npublic:\r\n\r\n\t//! The constructor.\r\n    ProtocolWriter();\r\n\r\n\t//! The destructor.\r\n    ~ProtocolWriter(); \r\n\r\n    // Disable copying.\r\n    ProtocolWriter(ProtocolWriter const& rhs) = delete;\r\n    ProtocolWriter& operator=(ProtocolWriter const& rhs) = delete;\r\n\r\n    /*!\r\n     *  Writes the given protocol description into XML.\r\n     *\r\n     *    @param [in] writer      The XML writer to use.\r\n     *    @param [in] protocol    The protocol to write.\r\n     */\r\n    void writeProtocol(QXmlStreamWriter& writer, QSharedPointer<Protocol> protocol) const;\r\n\r\nprivate:\r\n\r\n\r\n    /*!\r\n     *  Writes the transactional port protocol type on system/master/slave into XML.\r\n     *\r\n     *    @param [in] writer          The XML writer to use.\r\n     *    @param [in] portProtocol    The protocol whose type to write.\r\n     */\r\n    void writeProtocolType(QXmlStreamWriter& writer, QSharedPointer<Protocol> portProtocol) const;\r\n       \r\n    /*!\r\n     *  Writes the transactional port protocol payload on system/master/slave into XML.\r\n     *\r\n     *    @param [in] writer          The XML writer to use.\r\n     *    @param [in] portProtocol    The protocol whose payload to write.\r\n     */\r\n    void writePayload(QXmlStreamWriter& writer, QSharedPointer<Protocol> portProtocol) const;\r\n\r\n};\r\n\r\n#endif // TRANSACTIONALABSTRACTIONWRITER_H"
  },
  {
    "path": "IPXACTmodels/common/Qualifier.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: Qualifier.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Esko Pekkarinen\n// Date: 11.08.2015\n//\n// Description:\n// Implementation for ipxact:qualifier group.\n//-----------------------------------------------------------------------------\n\n#include \"Qualifier.h\"\n\nnamespace {\n\n    const QMap<Qualifier::Type, QString> QUALIFIER_TYPE_STRING =\n    {\n        {Qualifier::Type::Address, QStringLiteral(\"address\")},\n        {Qualifier::Type::Data, QStringLiteral(\"data\")},\n        {Qualifier::Type::Clock, QStringLiteral(\"clock\")},\n        {Qualifier::Type::Reset, QStringLiteral(\"reset\")},\n        {Qualifier::Type::Valid, QStringLiteral(\"valid\")},\n        {Qualifier::Type::Interrupt, QStringLiteral(\"interrupt\")},\n        {Qualifier::Type::ClockEnable, QStringLiteral(\"clock enable\")},\n        {Qualifier::Type::PowerEnable, QStringLiteral(\"power enable\")},\n        {Qualifier::Type::Opcode, QStringLiteral(\"opcode\")},\n        {Qualifier::Type::Protection, QStringLiteral(\"protection\")},\n        {Qualifier::Type::FlowControl, QStringLiteral(\"flow control\")},\n        {Qualifier::Type::User, QStringLiteral(\"user\")},\n        {Qualifier::Type::Request, QStringLiteral(\"request\")},\n        {Qualifier::Type::Response, QStringLiteral(\"response\")}\n    };\n}\n\n//-----------------------------------------------------------------------------\n// Function: Qualifier::clone()\n//-----------------------------------------------------------------------------\nQualifier* Qualifier::clone() const\n{\n    return new Qualifier(*this);\n}\n\n//-----------------------------------------------------------------------------\n// Function: Qualifier::isSet()\n//-----------------------------------------------------------------------------\nbool Qualifier::isSet() const\n{\n    return !types_.isEmpty();\n}\n\n//-----------------------------------------------------------------------------\n// Function: Qualifier::clear()\n//-----------------------------------------------------------------------------\nvoid Qualifier::clear()\n{\n    types_.clear();\n    attributes_.fill(QString());\n}\n\n//-----------------------------------------------------------------------------\n// Function: Qualifier::hasType()\n//-----------------------------------------------------------------------------\nbool Qualifier::hasType(Type type) const\n{\n    return types_.contains(type);\n}\n\n//-----------------------------------------------------------------------------\n// Function: Qualifier::setType()\n//-----------------------------------------------------------------------------\nvoid Qualifier::setType(Type type)\n{\n    if (!hasType(type))\n    {\n        types_.append(type);\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: Qualifier::removeType()\n//-----------------------------------------------------------------------------\nvoid Qualifier::removeType(Type type)\n{\n    types_.removeOne(type);\n}\n\n//-----------------------------------------------------------------------------\n// Function: Qualifier::getTypes()\n//-----------------------------------------------------------------------------\nQList<Qualifier::Type> Qualifier::getTypes() const\n{\n    return types_;\n}\n\n//-----------------------------------------------------------------------------\n// Function: Qualifier::getAttribute()\n//-----------------------------------------------------------------------------\nQString Qualifier::getAttribute(Attribute attribute) const\n{   \n    return attributes_[static_cast<unsigned int>(attribute)];\n}\n\n//-----------------------------------------------------------------------------\n// Function: Qualifier::setAttribute()\n//-----------------------------------------------------------------------------\nvoid Qualifier::setAttribute(Attribute attribute, QString const& attributeValue)\n{\n    attributes_[static_cast<unsigned int>(attribute)] = attributeValue;\n}\n\n//-----------------------------------------------------------------------------\n// Function: Qualifier::operator==()\n//-----------------------------------------------------------------------------\nbool Qualifier::operator==(Qualifier const& other) const\n{\n    return (types_ == other.types_ && attributes_ == other.attributes_);\n}\n\n//-----------------------------------------------------------------------------\n// Function: Qualifier::operator!=()\n//-----------------------------------------------------------------------------\nbool Qualifier::operator!=(Qualifier const& other) const\n{\n    return !(*this == other);\n}\n\n//-----------------------------------------------------------------------------\n// Function: Qualifier::typeToString()\n//-----------------------------------------------------------------------------\nQString Qualifier::typeToString(Type type)\n{\n    return QUALIFIER_TYPE_STRING.value(type, QString());\n}\n\n//-----------------------------------------------------------------------------\n// Function: Qualifier::stringToType()\n//-----------------------------------------------------------------------------\nQualifier::Type Qualifier::stringToType(QString const& typeString)\n{\n    return QUALIFIER_TYPE_STRING.key(typeString, Qualifier::Type::Any);\n}\n\n//-----------------------------------------------------------------------------\n// Function: Qualifier::stringToAttributeName()\n//-----------------------------------------------------------------------------\nQualifier::Attribute Qualifier::stringToAttributeName(QString const& attributeName)\n{\n    if (attributeName == QStringLiteral(\"resetLevel\"))\n    {\n        return Attribute::ResetLevel;\n    }\n    else if (attributeName == QStringLiteral(\"clockEnableLevel\"))\n    {\n        return Attribute::ClockEnableLevel;\n    }\n    else if (attributeName == QStringLiteral(\"powerEnableLevel\"))\n    {\n        return Attribute::PowerEnableLevel;\n    }\n    else if (attributeName == QStringLiteral(\"powerDomainReference\"))\n    {\n        return Attribute::PowerDomainReference;\n    }\n    else if (attributeName == QStringLiteral(\"flowType\"))\n    {\n        return Attribute::FlowType;\n    }\n    else if (attributeName == QStringLiteral(\"userFlowType\"))\n    {\n        return Attribute::UserFlowType;\n    }\n    else \n    {\n        return Attribute::UserDefined;\n    }\n}\n"
  },
  {
    "path": "IPXACTmodels/common/Qualifier.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: Qualifier.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Esko Pekkarinen\r\n// Date: 11.08.2015\r\n//\r\n// Description:\r\n// Implementation for ipxact:qualifier group.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef QUALIFIER_H\r\n#define QUALIFIER_H\r\n\r\n#include <IPXACTmodels/ipxactmodels_global.h>\r\n\r\n#include <QString>\r\n#include <QMap>\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Implementation for ipxact:qualifier group.\r\n//-----------------------------------------------------------------------------\r\nclass IPXACTMODELS_EXPORT Qualifier \r\n{\r\npublic:\r\n\r\n    enum class Type\r\n    {\r\n        Address,\r\n        Data,\r\n        Clock,\r\n        Reset,\r\n        Valid,\r\n        Interrupt,\r\n        ClockEnable,\r\n        PowerEnable,\r\n        Opcode,\r\n        Protection,\r\n        FlowControl,\r\n        User,\r\n        Request,\r\n        Response,\r\n        Any\r\n    };\r\n    static constexpr auto TYPE_COUNT = 14;\r\n\r\n    enum class Attribute: unsigned int\r\n    {\r\n        ResetLevel = 0,\r\n        ClockEnableLevel,\r\n        PowerEnableLevel,\r\n        PowerDomainReference,\r\n        FlowType,\r\n        UserFlowType,\r\n        UserDefined\r\n    };\r\n\r\n    static constexpr auto ATTRIBUTE_COUNT = 7;\r\n\r\n    /*!\r\n     *  Create a copy of the Qualifier.\r\n     *\r\n     *    @return A Qualifier identical to this.\r\n     */\r\n    Qualifier* clone() const;\r\n\r\n    /*!\r\n     *\tChecks if the qualifier has been set.\r\n     *\t\t\r\n     * \t\t@return True, if any qualifier type is set, otherwise false.\r\n     */\r\n    bool isSet() const;\r\n\r\n    /*!\r\n     *\tClears any values set to the qualifier.\r\n     */\r\n    void clear();\r\n\r\n    /*!\r\n     *\tChecks if the qualifier has a specific type set.\r\n     *  \r\n     *    @param [in] type\tThe type to check.\r\n     *\t\t\r\n     * \t\t@return True, if the type is set, otherwise false.\r\n     */\r\n    bool hasType(Type type) const;\r\n\r\n    /*!\r\n     *\tSets the qualifier type.\r\n     *  \r\n     *    @param [in] type\tThe type to set.\r\n     */\r\n    void setType(Type type);\r\n\r\n    /*!\r\n     *\tClears the given type from the qualifier.\r\n     */\r\n    void removeType(Type type);\r\n\r\n    /*!\r\n     *\tGets the qualifier types that have been set.\r\n     *  \r\n     *\t\t\r\n     * \t\t@return A list of set types.\r\n     */\r\n    QList<Type> getTypes() const;\r\n    \r\n    /*!\r\n     *\tGet a selected attribute.\r\n     *  \r\n     *    @param [in] attributeName\tThe attribute name.\r\n     *\t\t\r\n     * \t\t@return The attribute as a string.\r\n     */\r\n    QString getAttribute(Attribute attribute) const;\r\n\r\n    /*!\r\n     *\tSets a given qualifier attribute.\r\n     *  \r\n     *    @param [in] attributeName\tThe attribute name to set.\r\n     *    @param [in] attributeValue\tThe attribute value to set.\r\n     */\r\n    void setAttribute(Attribute attribute, QString const& attributeValue);\r\n\r\n    bool operator==(Qualifier const& other) const;\r\n\r\n    bool operator!=(Qualifier const& other) const;\r\n\r\n    /*!\r\n     *\tGets a qualifier type as string.\r\n     *  \r\n     *    @param [in] type\tType to convert to string.\r\n     *\t\t\r\n     * \t\t@return Type as string.\r\n     */\r\n    static QString typeToString(Type type);\r\n\r\n    /*!\r\n     *\tConverts a qualifier type from string to type.\r\n     *\r\n     *    @param [in] typeString\tType as a string to convert to type.\r\n     *\r\n     * \t\t@return Qualifier type.\r\n     */\r\n    static Type stringToType(QString const& typeString);\r\n\r\n    /*!\r\n     *\tConverts a qualifier attribute name string to attribute.\r\n     *  \r\n     *    @param [in] attributeName\tThe attribute as string.\r\n     *\t\t\r\n     * \t\t@return The converted attribute.\r\n     */\r\n    static Attribute stringToAttributeName(QString const& attributeName);\r\n\r\nprivate:\r\n    //! The list of types assigned to this qualifier.\r\n    QList<Type> types_{ };\r\n\r\n    //! The list of attributes set for the qualifier.\r\n    std::array<QString, ATTRIBUTE_COUNT> attributes_;\r\n};\r\n\r\n#endif // QUALIFIER_H\r\n"
  },
  {
    "path": "IPXACTmodels/common/QualifierReader.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: QualifierReader.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Esko Pekkarinen\n// Date: 07.11.2023\n//\n// Description:\n// Reader class for ipxact:qualifier.\n//-----------------------------------------------------------------------------\n\n#include \"QualifierReader.h\"\n\n//-----------------------------------------------------------------------------\n// Function: QualifierReader::parseQualifier()\n//-----------------------------------------------------------------------------\nvoid QualifierReader::parseQualifier(QDomNode const& qualifierNode, QSharedPointer<Qualifier> qualifier,\n    Document::Revision revision)\n{\n    if (qualifierNode.isNull())\n    {\n        return;\n    }\n\n    bool isStd22 = revision == Document::Revision::Std22;\n\n    if (qualifierNode.firstChildElement(QStringLiteral(\"ipxact:isAddress\")).firstChild().nodeValue()\n        == QStringLiteral(\"true\"))\n    {\n        qualifier->setType(Qualifier::Type::Address);\n    }\n\n    if (qualifierNode.firstChildElement(QStringLiteral(\"ipxact:isData\")).firstChild().nodeValue()\n        == QStringLiteral(\"true\"))\n    {\n        qualifier->setType(Qualifier::Type::Data);\n\n    }\n\n    if (qualifierNode.firstChildElement(QStringLiteral(\"ipxact:isClock\")).firstChild().nodeValue()\n        == QStringLiteral(\"true\"))\n    {\n        qualifier->setType(Qualifier::Type::Clock);\n\n    }\n\n    if (auto const& node = qualifierNode.firstChildElement(QStringLiteral(\"ipxact:isReset\"));\n        node.firstChild().nodeValue() == QStringLiteral(\"true\"))\n    {\n        qualifier->setType(Qualifier::Type::Reset);\n        \n        if (isStd22)\n        {\n            qualifier->setAttribute(Qualifier::Attribute::ResetLevel, \n                node.attributes().namedItem(QStringLiteral(\"level\")).nodeValue());\n        }\n    }\n\n    if (!isStd22)\n    {\n        return;\n    }\n\n    if (qualifierNode.firstChildElement(QStringLiteral(\"ipxact:isValid\")).firstChild().nodeValue()\n        == QStringLiteral(\"true\"))\n    {\n        qualifier->setType(Qualifier::Type::Valid);\n    }\n\n    if (qualifierNode.firstChildElement(QStringLiteral(\"ipxact:isInterrupt\")).firstChild().nodeValue()\n        == QStringLiteral(\"true\"))\n    {\n        qualifier->setType(Qualifier::Type::Interrupt);\n    }\n\n    if (auto const& node = qualifierNode.firstChildElement(QStringLiteral(\"ipxact:isClockEn\"));\n        node.firstChild().nodeValue() == QStringLiteral(\"true\"))\n    {\n        qualifier->setType(Qualifier::Type::ClockEnable);\n\n        qualifier->setAttribute(Qualifier::Attribute::ClockEnableLevel, \n            node.attributes().namedItem(QStringLiteral(\"level\")).nodeValue());\n    }\n\n    if (auto const& node = qualifierNode.firstChildElement(QStringLiteral(\"ipxact:isPowerEn\"));\n        node.firstChild().nodeValue() == QStringLiteral(\"true\"))\n    {\n        qualifier->setType(Qualifier::Type::PowerEnable);\n\n        qualifier->setAttribute(Qualifier::Attribute::PowerEnableLevel, \n            node.attributes().namedItem(QStringLiteral(\"level\")).nodeValue());\n        qualifier->setAttribute(Qualifier::Attribute::PowerDomainReference, \n            node.attributes().namedItem(QStringLiteral(\"powerDomainRef\")).nodeValue());\n    }\n\n    if (qualifierNode.firstChildElement(QStringLiteral(\"ipxact:isOpcode\")).firstChild().nodeValue()\n        == QStringLiteral(\"true\"))\n    {\n        qualifier->setType(Qualifier::Type::Opcode);\n\n    }\n\n    if (qualifierNode.firstChildElement(QStringLiteral(\"ipxact:isProtection\")).firstChild().nodeValue()\n        == QStringLiteral(\"true\"))\n    {\n        qualifier->setType(Qualifier::Type::Protection);\n\n    }\n\n    if (auto const& node = qualifierNode.firstChildElement(QStringLiteral(\"ipxact:isFlowControl\"));\n        node.firstChild().nodeValue() == QStringLiteral(\"true\"))\n    {\n        qualifier->setType(Qualifier::Type::FlowControl);\n\n        auto attributes = node.attributes();\n\n        auto flowType = attributes.namedItem(QStringLiteral(\"flowType\")).nodeValue();\n        qualifier->setAttribute(Qualifier::Attribute::FlowType, flowType);\n\n        if (flowType == QStringLiteral(\"user\"))\n        {\n            qualifier->setAttribute(Qualifier::Attribute::UserFlowType, \n                attributes.namedItem(QStringLiteral(\"user\")).nodeValue());\n        }\n    }\n\n    if (auto const& node = qualifierNode.firstChildElement(QStringLiteral(\"ipxact:isUser\"));\n        node.firstChild().nodeValue() == QStringLiteral(\"true\"))\n    {\n        qualifier->setType(Qualifier::Type::User);\n\n        qualifier->setAttribute(Qualifier::Attribute::UserDefined, \n            node.attributes().namedItem(QStringLiteral(\"user\")).nodeValue());\n    }\n\n    if (qualifierNode.firstChildElement(QStringLiteral(\"ipxact:isRequest\")).firstChild().nodeValue()\n        == QStringLiteral(\"true\"))\n    {\n        qualifier->setType(Qualifier::Type::Request);\n\n    }\n\n    if (qualifierNode.firstChildElement(QStringLiteral(\"ipxact:isResponse\")).firstChild().nodeValue()\n        == QStringLiteral(\"true\"))\n    {\n        qualifier->setType(Qualifier::Type::Response);\n\n    }\n}\n"
  },
  {
    "path": "IPXACTmodels/common/QualifierReader.h",
    "content": "//-----------------------------------------------------------------------------\n// File: QualifierReader.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Esko Pekkarinen\n// Date: 07.11.2023\n//\n// Description:\n// XML parsing for ipxact:qualifier.\n//-----------------------------------------------------------------------------\n\n#ifndef QUALIFIER_READER_H\n#define QUALIFIER_READER_H\n\n#include <IPXACTmodels/common/Document.h>\n#include <IPXACTmodels/common/Qualifier.h>\n\n#include <QSharedPointer>\n#include <QDomNode>\n\n//-----------------------------------------------------------------------------\n//! XML parsing for ipxact:qualifier.\n//-----------------------------------------------------------------------------\nnamespace QualifierReader\n{\n\n    /*!\n     *  Parses a qualifier.\n     *\n     *    @param [in] qualifierNode       XML description of the IP-XACT element.\n     *    @param [in] qualifier           The qualifier to read to.\n     *    @param [in] revision            The standard revision of the XML document being read.\n\n     */\n    void parseQualifier(QDomNode const& qualifierNode, QSharedPointer<Qualifier> qualifier,\n        Document::Revision revision);\n\n};\n\n#endif // DOCUMENTREADER_H"
  },
  {
    "path": "IPXACTmodels/common/QualifierWriter.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: QualifierWriter.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Esko Pekkarinen\n// Date: 14.11.2023\n//\n// Description:\n// XML writer for ipxact:qualifier element.\n//-----------------------------------------------------------------------------\n\n#include \"QualifierWriter.h\"\n#include \"Qualifier.h\"\n\n//-----------------------------------------------------------------------------\n// Function: QualifierWriter::writeQualifier()\n//-----------------------------------------------------------------------------\nvoid QualifierWriter::writeQualifier(QXmlStreamWriter& writer, QSharedPointer<Qualifier> qualifier)\n{\n    if (!qualifier->isSet())\n    {\n        return;\n    }\n\n    writer.writeStartElement(QStringLiteral(\"ipxact:qualifier\"));\n\n    if (qualifier->hasType(Qualifier::Type::Address))\n    {\n        writer.writeTextElement(QStringLiteral(\"ipxact:isAddress\"), QStringLiteral(\"true\"));\n    }\n    if (qualifier->hasType(Qualifier::Type::Data))\n    {\n        writer.writeTextElement(QStringLiteral(\"ipxact:isData\"), QStringLiteral(\"true\"));\n    }\n    if (qualifier->hasType(Qualifier::Type::Clock))\n    {\n        writer.writeTextElement(QStringLiteral(\"ipxact:isClock\"), QStringLiteral(\"true\"));\n    }\n    if (qualifier->hasType(Qualifier::Type::Reset))\n    {\n        writer.writeStartElement(QStringLiteral(\"ipxact:isReset\"));\n\n        if (auto level = qualifier->getAttribute(Qualifier::Attribute::ResetLevel); !level.isEmpty())\n        {\n            writer.writeAttribute(QStringLiteral(\"level\"), level);\n        }\n        writer.writeCharacters(QStringLiteral(\"true\"));\n\n        writer.writeEndElement();\n    }\n    if (qualifier->hasType(Qualifier::Type::Valid))\n    {\n        writer.writeTextElement(QStringLiteral(\"ipxact:isValid\"), QStringLiteral(\"true\"));\n    }\n    if (qualifier->hasType(Qualifier::Type::Interrupt))\n    {\n        writer.writeTextElement(QStringLiteral(\"ipxact:isInterrupt\"), QStringLiteral(\"true\"));\n    }\n    if (qualifier->hasType(Qualifier::Type::ClockEnable))\n    {\n        writer.writeStartElement(QStringLiteral(\"ipxact:isClockEn\"));\n\n        if (auto level = qualifier->getAttribute(Qualifier::Attribute::ClockEnableLevel); !level.isEmpty())\n        {\n            writer.writeAttribute(QStringLiteral(\"level\"), level);\n        }\n        writer.writeCharacters(QStringLiteral(\"true\"));\n\n        writer.writeEndElement();\n    }\n    if (qualifier->hasType(Qualifier::Type::PowerEnable))\n    {\n        writer.writeStartElement(QStringLiteral(\"ipxact:isPowerEn\"));\n\n        if (auto level = qualifier->getAttribute(Qualifier::Attribute::PowerEnableLevel); !level.isEmpty())\n        {\n            writer.writeAttribute(QStringLiteral(\"level\"), level);\n        }\n\n        if (auto const& reference = qualifier->getAttribute(Qualifier::Attribute::PowerDomainReference);\n            !reference.isEmpty())\n        {\n            writer.writeAttribute(QStringLiteral(\"powerDomainRef\"), reference);\n        }\n\n        writer.writeCharacters(QStringLiteral(\"true\"));\n\n        writer.writeEndElement();\n    }\n    if (qualifier->hasType(Qualifier::Type::Opcode))\n    {\n        writer.writeTextElement(QStringLiteral(\"ipxact:isOpcode\"), QStringLiteral(\"true\"));\n    }\n    if (qualifier->hasType(Qualifier::Type::Protection))\n    {\n        writer.writeTextElement(QStringLiteral(\"ipxact:isProtection\"), QStringLiteral(\"true\"));\n    }\n    if (qualifier->hasType(Qualifier::Type::FlowControl))\n    {\n        writer.writeStartElement(QStringLiteral(\"ipxact:isFlowControl\"));\n\n        auto const& type = qualifier->getAttribute(Qualifier::Attribute::FlowType);\n        if (!type.isEmpty())\n        {\n            writer.writeAttribute(QStringLiteral(\"flowType\"), type);\n        }\n\n        if (type == QStringLiteral(\"user\"))\n        {\n            if (auto const& userType = qualifier->getAttribute(Qualifier::Attribute::UserFlowType);\n                !userType.isEmpty())\n            {\n                writer.writeAttribute(QStringLiteral(\"user\"), userType);\n            }\n        }\n\n        writer.writeCharacters(QStringLiteral(\"true\"));\n\n        writer.writeEndElement();\n    }\n    if (qualifier->hasType(Qualifier::Type::User))\n    {\n        writer.writeStartElement(QStringLiteral(\"ipxact:isUser\"));\n\n        if (auto const& userDefined = qualifier->getAttribute(Qualifier::Attribute::UserDefined);\n            !userDefined.isEmpty())\n        {\n            writer.writeAttribute(QStringLiteral(\"user\"), userDefined);\n        }\n\n        writer.writeCharacters(QStringLiteral(\"true\"));\n\n        writer.writeEndElement();\n    }\n    if (qualifier->hasType(Qualifier::Type::Request))\n    {\n        writer.writeTextElement(QStringLiteral(\"ipxact:isRequest\"), QStringLiteral(\"true\"));\n    }\n    if (qualifier->hasType(Qualifier::Type::Response))\n    {\n        writer.writeTextElement(QStringLiteral(\"ipxact:isResponse\"), QStringLiteral(\"true\"));\n    }\n\n    writer.writeEndElement(); // ipxact:qualifier\n}\n"
  },
  {
    "path": "IPXACTmodels/common/QualifierWriter.h",
    "content": "//-----------------------------------------------------------------------------\n// File: QualifierWriter.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Esko Pekkarinen\n// Date: 14.11.2023\n//\n// Description:\n// XML writer for ipxact:qualifier element.\n//-----------------------------------------------------------------------------\n\n#ifndef QUALIFIER_WRITER_H\n#define QUALIFIER_WRITER_H\n\n#include <QSharedPointer>\n#include <QXmlStreamWriter>\n\nclass Qualifier;\n\n//-----------------------------------------------------------------------------\n//! XML writer for ipxact:qualifier element.\n//-----------------------------------------------------------------------------\nclass QualifierWriter\n{\npublic:\n\n\n    /*!\n     *  Writes the given protocol description into XML.\n     *\n     *    @param [in] writer      The XML writer to use.\n     *    @param [in] protocol    The protocol to write.\n     */\n    static void writeQualifier(QXmlStreamWriter& writer, QSharedPointer<Qualifier> qualifier);\n\n};\n\n#endif // QUALIFIER_WRITER_H"
  },
  {
    "path": "IPXACTmodels/common/Range.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: Range.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Esko Pekkarinen\r\n// Date: 03.08.2015\r\n//\r\n// Description:\r\n// Implementation for range elements e.g. vector and array.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"Range.h\"\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Range::Range()\r\n//-----------------------------------------------------------------------------\r\nRange::Range(QString const& left, QString const& right) :\r\nleft_(left), right_(right)\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Range::getLeft()\r\n//-----------------------------------------------------------------------------\r\nQString Range::getLeft() const\r\n{\r\n    return left_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Range::getRight()\r\n//-----------------------------------------------------------------------------\r\nQString Range::getRight() const\r\n{\r\n    return right_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Range::setLeft()\r\n//-----------------------------------------------------------------------------\r\nvoid Range::setLeft(QString const& newLeft)\r\n{\r\n    left_ = newLeft;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Range::setRight()\r\n//-----------------------------------------------------------------------------\r\nvoid Range::setRight(QString const& newright)\r\n{\r\n    right_ = newright;\r\n}"
  },
  {
    "path": "IPXACTmodels/common/Range.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: Range.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Esko Pekkarinen\r\n// Date: 03.08.2015\r\n//\r\n// Description:\r\n// Implementation for range elements e.g. vector and array.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef RANGE_H\r\n#define RANGE_H\r\n\r\n#include <QString>\r\n\r\n#include <IPXACTmodels/ipxactmodels_global.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Implementation for range elements e.g. vector and array.\r\n//-----------------------------------------------------------------------------\r\nclass IPXACTMODELS_EXPORT Range \r\n{\r\npublic:\r\n\r\n    Range() = default;\r\n\r\n\t//! The constructor.\r\n\tRange(QString const& left, QString const& right);\r\n\r\n\t//! The destructor.\r\n\tvirtual ~Range() = default;\r\n\r\n    /*!\r\n     *  Gets the left value of the range.\r\n     *\r\n     *    @return The left value of the Vector.\r\n     */\r\n    QString getLeft() const;\r\n\r\n    /*!\r\n     *  Gets the right value of the range.\r\n     *\r\n     *    @return The right value of the Vector.\r\n     */\r\n    QString getRight() const;\r\n\r\n    /*!\r\n     *  Sets the left value for the range.\r\n     *\r\n     *    @param [in] newLeft     The value to be set as left.\r\n     */\r\n    void setLeft(QString const& newLeft);\r\n\r\n    /*!\r\n     *  Sets the right value for the range.\r\n     *\r\n     *    @param [in] newright    The value to be set as right.\r\n     */\r\n    void setRight(QString const& newright);\r\n\r\nprivate:\r\n\r\n    //! The left side of the range.\r\n    QString left_;\r\n\r\n    //! The right side of the range.\r\n    QString right_;\r\n};\r\n\r\n\r\n#endif // RANGE_H\r\n"
  },
  {
    "path": "IPXACTmodels/common/TagData.h",
    "content": "//-----------------------------------------------------------------------------\n// File: TagData.h\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Mikko Teuho\n// Date: 29.08.2019\n//\n// Description:\n// Struct for tag information.\n//-----------------------------------------------------------------------------\n\n#ifndef TAGDATA_H\n#define TAGDATA_H\n\n#include <QString>\n\n//-----------------------------------------------------------------------------\n//! Struct for tag information.\n//-----------------------------------------------------------------------------\nstruct TagData\n{\n    //! Tag name.\n    QString name_;\n\n    //! Tag color in hex code (\"#RRGGBB\").\n    QString color_;\n\n    /*\n     *  Comparison operator for tag data.\n     */\n    bool operator==(TagData const& other) const\n    {\n        return name_ == other.name_ && color_ == other.color_;\n    };\n\n};\n\n#endif // TAGDATA_H\n"
  },
  {
    "path": "IPXACTmodels/common/TimingConstraint.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: TimingConstraint.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Esko Pekkarinen\r\n// Date: 12.08.2015\r\n//\r\n// Description:\r\n// Implementation for ipxact:timingConstraint.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"TimingConstraint.h\"\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: TimingConstraint::TimingConstraint()\r\n//-----------------------------------------------------------------------------\r\nTimingConstraint::TimingConstraint(): value_(), clockEdge_(UNKNOWN), delayType_(BOTH), clockPortName_()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: TimingConstraint::TimingConstraint()\r\n//-----------------------------------------------------------------------------\r\nTimingConstraint::TimingConstraint(TimingConstraint const& other) :\r\nvalue_(other.value_),\r\n    clockEdge_(other.clockEdge_),\r\n    delayType_(other.delayType_),\r\n    clockPortName_(other.clockPortName_)\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: TimingConstraint::~TimingConstraint()\r\n//-----------------------------------------------------------------------------\r\nTimingConstraint::~TimingConstraint()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: TimingConstraint::setValue()\r\n//-----------------------------------------------------------------------------\r\nvoid TimingConstraint::setValue(double delayPercentage)\r\n{\r\n    value_ = delayPercentage;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: TimingConstraint::getValue()\r\n//-----------------------------------------------------------------------------\r\ndouble TimingConstraint::getValue() const\r\n{\r\n    return value_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: TimingConstraint::setClockEdge()\r\n//-----------------------------------------------------------------------------\r\nvoid TimingConstraint::setClockEdge(ClockEdgeType edge)\r\n{\r\n    clockEdge_ = edge;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: TimingConstraint::getClockEdge()\r\n//-----------------------------------------------------------------------------\r\nTimingConstraint::ClockEdgeType TimingConstraint::getClockEdge() const\r\n{\r\n    return clockEdge_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: TimingConstraint::setDelayType()\r\n//-----------------------------------------------------------------------------\r\nvoid TimingConstraint::setDelayType(TimingConstraint::DelayType delayType)\r\n{\r\n    delayType_ = delayType;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: TimingConstraint::getDelayType()\r\n//-----------------------------------------------------------------------------\r\nTimingConstraint::DelayType TimingConstraint::getDelayType() const\r\n{\r\n    return delayType_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: TimingConstraint::setClockName()\r\n//-----------------------------------------------------------------------------\r\nvoid TimingConstraint::setClockName(QString const& clockPort)\r\n{\r\n    clockPortName_ = clockPort;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: TimingConstraint::getClockName()\r\n//-----------------------------------------------------------------------------\r\nQString TimingConstraint::getClockName() const\r\n{\r\n    return clockPortName_;\r\n}\r\n"
  },
  {
    "path": "IPXACTmodels/common/TimingConstraint.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: TimingConstraint.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Esko Pekkarinen\r\n// Date: 12.08.2015\r\n//\r\n// Description:\r\n// Implementation for ipxact:timingConstraint.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef TIMINGCONSTRAINT_H\r\n#define TIMINGCONSTRAINT_H\r\n\r\n#include <QString>\r\n\r\n#include <IPXACTmodels/ipxactmodels_global.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Implementation for ipxact:timingConstraint.\r\n//-----------------------------------------------------------------------------\r\nclass IPXACTMODELS_EXPORT TimingConstraint \r\n{\r\npublic:\r\n\r\n    //! Possible values for clock edge.\r\n    enum ClockEdgeType\r\n    {\r\n        RISE = 0,\r\n        FALL, \r\n        UNKNOWN\r\n    };\r\n\r\n    //! Possible values for delay type.\r\n    enum DelayType\r\n    {\r\n        MINIMUM_DELAY = 0,\r\n        MAXIMUM_DELAY, \r\n        BOTH\r\n    };\r\n\r\n\t//! The constructor.\r\n\tTimingConstraint();\r\n\r\n    //! Copy constructor.\r\n    TimingConstraint(TimingConstraint const& other);\r\n\r\n\t//! The destructor.\r\n\t~TimingConstraint();\r\n\r\n    /*!\r\n     *  Sets the constraint value.\r\n     *\r\n     *    @param [in] delayPercentage   The value percentage.\r\n     */\r\n    void setValue(double delayPercentage);\r\n\r\n    /*!\r\n     *  Gets the constraint value.\r\n     *\r\n     *    @return The constraint value.\r\n     */\r\n    double getValue() const;\r\n\r\n    /*!\r\n     *  Sets the clock edge for the constraint.\r\n     *\r\n     *    @param [in] edge   The edge to set.\r\n     */\r\n    void setClockEdge(TimingConstraint::ClockEdgeType edge);\r\n      \r\n    /*!\r\n     *  Gets the clock edge.\r\n     *\r\n     *    @return The clock edge type.\r\n     */\r\n    ClockEdgeType getClockEdge() const;\r\n\r\n    /*!\r\n     *  Sets the delay type for the constraint.\r\n     *\r\n     *    @param [in] delayType   The delay type to set.\r\n     */\r\n    void setDelayType(TimingConstraint::DelayType delayType);\r\n\r\n    /*!\r\n     *  Gets the delay type.\r\n     *\r\n     *    @return The delay type.\r\n     */\r\n    DelayType getDelayType() const;\r\n        \r\n    /*!\r\n     *  Sets the clock name for the constraint.\r\n     *\r\n     *    @param [in] clockPort   The clock name to set.\r\n     */\r\n    void setClockName(QString const& clockPort);\r\n\r\n    /*!\r\n     *  Gets the clock name for the constraint.\r\n     *\r\n     *    @return The clock name.\r\n     */\r\n    QString getClockName() const;\r\n\r\nprivate:\r\n\r\n\t// Disable copying.\r\n\tTimingConstraint& operator=(TimingConstraint const& rhs);\r\n\r\n    //! The constraint value in percentage.\r\n    double value_;\r\n\r\n    //! The clock edge this constraint applies to.\r\n    ClockEdgeType clockEdge_;\r\n\r\n    //! Specifies the constraint applicability for timing analysis.\r\n    DelayType delayType_;\r\n\r\n    //! Specifies which clock the constraint is relative to.\r\n    QString clockPortName_;\r\n};\r\n\r\n#endif // TIMINGCONSTRAINT_H"
  },
  {
    "path": "IPXACTmodels/common/TransactionalTypes.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: TransactionalTypes.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 10.09.2015\r\n//\r\n// Description:\r\n// NameSpace TransactionalTypes is used to store functions related to transactional ports.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"TransactionalTypes.h\"\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: TransactionalTypes::isIpXactInitiativeType()\r\n//-----------------------------------------------------------------------------\r\nbool TransactionalTypes::isIpXactInitiativeType(QString const& initiativeType)\r\n{\r\n    return INITIATIVE_TYPES.values().contains(initiativeType);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: TransactionalTypes::isIpXactKindType()\r\n//-----------------------------------------------------------------------------\r\nbool TransactionalTypes::isIpXactKindType(QString const& kindType)\r\n{\r\n    return KIND_TYPES.contains(kindType);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: TransactionalTypes::initiativeToString()\r\n//-----------------------------------------------------------------------------\r\nQString TransactionalTypes::initiativeToString(TransactionalTypes::Initiative const& initiative)\r\n{\r\n    return INITIATIVE_TYPES.value(initiative, QString());\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: TransactionalTypes::strToInitiative()\r\n//-----------------------------------------------------------------------------\r\nTransactionalTypes::Initiative TransactionalTypes::strToInitiative(QString const& str)\r\n{\r\n    return INITIATIVE_TYPES.key(str, Initiative::INITIATIVE_INVALID);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: TransactionalTypes::convertToMirrored()\r\n//-----------------------------------------------------------------------------\r\nTransactionalTypes::Initiative TransactionalTypes::convertToMirrored(QString const& initiative)\r\n{\r\n    TransactionalTypes::Initiative mirroredInitiative = TransactionalTypes::strToInitiative(initiative);\r\n    if (mirroredInitiative == Initiative::REQUIRES)\r\n    {\r\n        mirroredInitiative = Initiative::PROVIDES;\r\n    }\r\n    else if (mirroredInitiative == Initiative::PROVIDES)\r\n    {\r\n        mirroredInitiative = Initiative::REQUIRES;\r\n    }\r\n\r\n    return mirroredInitiative;\r\n}\r\n"
  },
  {
    "path": "IPXACTmodels/common/TransactionalTypes.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: TransactionalTypes.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 10.09.2015\r\n//\r\n// Description:\r\n// NameSpace TransactionalTypes is used to store functions related to transactional ports.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef TRANSACTIONALTYPES_H\r\n#define TRANSACTIONALTYPES_H\r\n\r\n#include <IPXACTmodels/ipxactmodels_global.h>\r\n\r\n#include <QMap>\r\n#include <QString>\r\n#include <QStringList>\r\n\r\n//-----------------------------------------------------------------------------\r\n//! NameSpace FileTypes is used to store functions related to file types.\r\n//-----------------------------------------------------------------------------\r\nnamespace TransactionalTypes\r\n{ \r\n    //! Initiative types.\r\n    enum class Initiative {\r\n        REQUIRES,\r\n        PROVIDES,\r\n        BOTH,\r\n        PHANTOM,\r\n        INITIATIVE_INVALID\r\n    };\r\n\r\n    //! Strings for the initiative types.\r\n    QString const INITIATIVE_REQUIRES = QStringLiteral(\"requires\");\r\n    QString const INITIATIVE_PROVIDES = QStringLiteral(\"provides\");\r\n    QString const INITIATIVE_BOTH = QStringLiteral(\"both\");\r\n    QString const INITIATIVE_PHANTOM = QStringLiteral(\"phantom\");\r\n    QString const INITIATIVE_REQUIRES_PROVIDES = QStringLiteral(\"requires/provides\");\r\n\r\n    const QMap<Initiative, QString> INITIATIVE_TYPES =\r\n    {\r\n        {Initiative::REQUIRES, INITIATIVE_REQUIRES},\r\n        {Initiative::PROVIDES, INITIATIVE_PROVIDES},\r\n        {Initiative::BOTH, INITIATIVE_BOTH},\r\n        {Initiative::PHANTOM, INITIATIVE_PHANTOM}\r\n    };\r\n\r\n    /*!\r\n     *  Change the selected initiative value to string.\r\n     *\r\n     *    @param [in] initiative  The selected initiative value.\r\n     *\r\n     *    @return The selected initiative in string format.\r\n     */\r\n    IPXACTMODELS_EXPORT QString initiativeToString(TransactionalTypes::Initiative const& initiative);\r\n\r\n    /*!\r\n     *  Change the selected string to initiative value.\r\n     *\r\n     *    @param [in] str     The selected initiative string.\r\n     *\r\n     *    @return The selected initiative in initiative format.\r\n     */\r\n    IPXACTMODELS_EXPORT TransactionalTypes::Initiative strToInitiative(QString const& str);\r\n\r\n\t/*!\r\n\t *  Checks if the file type belongs to the specified file types.\r\n\t *\r\n\t *    @param [in] fileType    The file type to check.\r\n     *\r\n     *    @return True if the file type is one of the specified ones, false otherwise.\r\n\t */\r\n    IPXACTMODELS_EXPORT bool isIpXactInitiativeType(QString const& initiativeType);\r\n\r\n    /*!\r\n     *  Convert the selected initiative to mirrored initiative.\r\n     *\r\n     *    @param [in] initiative  The selected initiative.\r\n     *\r\n     *    @return The mirrored initiative.\r\n     */\r\n    IPXACTMODELS_EXPORT TransactionalTypes::Initiative convertToMirrored(QString const& initiative);\r\n\r\n    //! The kind types specified in the IP-XACT.\r\n    const QStringList KIND_TYPES = {\r\n        QStringLiteral(\"tlm_port\"),\r\n        QStringLiteral(\"tlm_socket\"),\r\n        QStringLiteral(\"simple_socket\"),\r\n        QStringLiteral(\"multi_socket\"),\r\n        QStringLiteral(\"custom\")\r\n    };\r\n\r\n    /*!\r\n     *  Checks if the kind type belongs to the specified kind types.\r\n     *\r\n     *    @param [in] kindType    The kind type to check.\r\n     *\r\n     *    @return True if the kind type is one of the specified ones, false otherwise.\r\n     */\r\n    IPXACTMODELS_EXPORT bool isIpXactKindType(QString const& kindType);\r\n}\r\n\r\n#endif // TRANSACTIONALTYPES_H\r\n"
  },
  {
    "path": "IPXACTmodels/common/VLNV.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: vlnv.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Antti Kamppi\r\n// Date: 23.6.2010\r\n//\r\n// Description:\r\n// A class to hold VLNV information of a single IP-XACT document.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"VLNV.h\"\r\n\r\n#include <QString>\r\n#include <QStringBuilder>\r\n#include <QStringList>\r\n#include <QObject>\r\n#include <QMap>\r\n\r\nnamespace\r\n{\r\n    const QMap<QString, VLNV::IPXactType> types =\r\n    {\r\n        { QStringLiteral(\"ipxact:abstractionDefinition\"), VLNV::ABSTRACTIONDEFINITION },\r\n        { QStringLiteral(\"ipxact:abstractor\"), VLNV::ABSTRACTOR },\r\n        { QStringLiteral(\"ipxact:busDefinition\"), VLNV::BUSDEFINITION },\r\n        { QStringLiteral(\"ipxact:catalog\"), VLNV::CATALOG },\r\n        { QStringLiteral(\"ipxact:component\"), VLNV::COMPONENT },\r\n        { QStringLiteral(\"ipxact:design\"), VLNV::DESIGN },\r\n        { QStringLiteral(\"ipxact:designConfiguration\"), VLNV::DESIGNCONFIGURATION },\r\n        { QStringLiteral(\"ipxact:generatorChain\"), VLNV::GENERATORCHAIN },\r\n        { QStringLiteral(\"kactus2:comDefinition\"), VLNV::COMDEFINITION },\r\n        { QStringLiteral(\"kactus2:apiDefinition\"), VLNV::APIDEFINITION },\r\n        { QStringLiteral(\"invalid\"), VLNV::INVALID }\r\n\r\n    };\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VLNV::VLNV()\r\n//-----------------------------------------------------------------------------\r\nVLNV::VLNV()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VLNV::VLNV()\r\n//-----------------------------------------------------------------------------\r\nVLNV::VLNV(QString const& type,\r\n    QString const& vendor, QString const& library, QString const& name, QString const& version) :\r\n    vendor_(vendor),\r\n    library_(library),\r\n    name_(name),\r\n    version_(version)\r\n{\r\n\ttype_ = string2Type(type);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VLNV::VLNV()\r\n//-----------------------------------------------------------------------------\r\nVLNV::VLNV(IPXactType const& type,\r\n    QString const& vendor, QString const& library, QString const& name, QString const& version) :\r\n    vendor_(vendor),\r\n    library_(library),\r\n    name_(name),\r\n    version_(version),\r\n    type_(type)\r\n{\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VLNV::VLNV()\r\n//-----------------------------------------------------------------------------\r\nVLNV::VLNV(IPXactType const& type, QString const& parseStr, QString const& separator):\r\n    type_(type)\r\n{\r\n    QStringList vlnvFields = parseStr.split(separator);\r\n    if (vlnvFields.count() == 4)\r\n    {\r\n        vendor_ = vlnvFields.at(0);\r\n        library_ = vlnvFields.at(1);\r\n        name_ = vlnvFields.at(2);\r\n        version_ = vlnvFields.at(3);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VLNV::getVendor()\r\n//-----------------------------------------------------------------------------\r\nQString VLNV::getVendor() const\r\n{\r\n    return vendor_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VLNV::setVendor()\r\n//-----------------------------------------------------------------------------\r\nvoid VLNV::setVendor(QString const& vendor)\r\n{\r\n    vendor_ = vendor.simplified();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VLNV::getLibrary()\r\n//-----------------------------------------------------------------------------\r\nQString VLNV::getLibrary() const\r\n{\r\n    return library_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VLNV::setLibrary()\r\n//-----------------------------------------------------------------------------\r\nvoid VLNV::setLibrary(QString const& library)\r\n{\r\n    library_ = library.simplified();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VLNV::getName()\r\n//-----------------------------------------------------------------------------\r\nQString VLNV::getName() const\r\n{\r\n    return name_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VLNV::setName()\r\n//-----------------------------------------------------------------------------\r\nvoid VLNV::setName(QString const& name)\r\n{\r\n    name_ = name.simplified();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VLNV::getVersion()\r\n//-----------------------------------------------------------------------------\r\nQString VLNV::getVersion() const\r\n{\r\n    return version_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VLNV::setVersion()\r\n//-----------------------------------------------------------------------------\r\nvoid VLNV::setVersion(QString const& version)\r\n{\r\n    version_ = version.simplified();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VLNV::getType()\r\n//-----------------------------------------------------------------------------\r\nVLNV::IPXactType VLNV::getType() const\r\n{\r\n    return type_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VLNV::setType()\r\n//-----------------------------------------------------------------------------\r\nvoid VLNV::setType(IPXactType type)\r\n{\r\n    type_ = type;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VLNV::getTypestr()\r\n//-----------------------------------------------------------------------------\r\nQString VLNV::getTypestr() const\r\n{\r\n\treturn IPXactType2String(type_);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VLNV::isEmpty()\r\n//-----------------------------------------------------------------------------\r\nbool VLNV::isEmpty() const\r\n{\r\n    return vendor_.isEmpty() && library_.isEmpty() && name_.isEmpty() && version_.isEmpty();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VLNV::clear()\r\n//-----------------------------------------------------------------------------\r\nvoid VLNV::clear()\r\n{\r\n    vendor_.clear();\r\n    library_.clear();\r\n    name_.clear();\r\n    version_.clear();\r\n    type_ = VLNV::INVALID;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VLNV::isValid()\r\n//-----------------------------------------------------------------------------\r\nbool VLNV::isValid() const \r\n{\r\n    // If one of the identification fields is empty then this is invalid.\r\n    return type_ != VLNV::INVALID && \r\n        !vendor_.isEmpty() && !library_.isEmpty() && !name_.isEmpty() && !version_.isEmpty();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VLNV::isValid()\r\n//-----------------------------------------------------------------------------\r\nbool VLNV::isValid(QVector<QString>& errors, QString const& parentIdentifier) const\r\n{\r\n    bool valid = true;\r\n\r\n    if (type_ == VLNV::INVALID)\r\n    {\r\n        errors.append(QObject::tr(\"The type of the vlnv is invalid within %1\").arg(parentIdentifier));\r\n        valid = false;\r\n    }\r\n\r\n    if (vendor_.isEmpty())\r\n    {\r\n        errors.append(QObject::tr(\"No vendor specified for vlnv within %1\").arg(parentIdentifier));\r\n        valid = false;\r\n    }\r\n\r\n    if (library_.isEmpty())\r\n    {\r\n        errors.append(QObject::tr(\"No library specified for vlnv within %1\").arg(parentIdentifier));\r\n        valid = false;\r\n    }\r\n\r\n    if (name_.isEmpty())\r\n    {\r\n        errors.append(QObject::tr(\"No name specified for vlnv within %1\").arg(parentIdentifier));\r\n        valid = false;\r\n    }\r\n\r\n    if (version_.isEmpty())\r\n    {\r\n        errors.append(QObject::tr(\"No version specified for vlnv within %1\").arg(parentIdentifier));\r\n        valid = false;\r\n    }\r\n\r\n    return valid;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VLNV::toString()\r\n//-----------------------------------------------------------------------------\r\nQString VLNV::toString(QString const& separator) const\r\n{\r\n    return vendor_ % separator % library_ % separator % name_ % separator % version_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VLNV::operator<()\r\n//-----------------------------------------------------------------------------\r\nbool VLNV::operator<(const VLNV &other) const\r\n{\r\n    int vendorResult = vendor_.compare(other.vendor_);\r\n\r\n\tif (vendorResult == 0)\r\n    {\r\n        int libraryResult = library_.compare(other.library_);\r\n\t\t\r\n        if (libraryResult == 0)\r\n        {\r\n            int nameResult = name_.compare(other.name_);\r\n\r\n\t\t\tif (nameResult == 0)\r\n            {\r\n\t\t\t\treturn version_.compare(other.version_) < 0;\r\n\t\t\t}\r\n\t\t\telse\r\n            {\r\n\t\t\t\treturn (nameResult < 0);\r\n\t\t\t}\r\n\t\t}\r\n\t\telse\r\n        {\r\n\t\t\treturn (libraryResult < 0);\r\n\t\t}\r\n\t}\r\n\telse\r\n    {\r\n\t\treturn (vendorResult < 0);\r\n\t}\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VLNV::operator>()\r\n//-----------------------------------------------------------------------------\r\nbool VLNV::operator>(const VLNV &other) const\r\n{\r\n\tif (vendor_.compare(other.vendor_) == 0)\r\n    {\r\n\t\tif (library_.compare(other.library_) == 0)\r\n        {\r\n\t\t\tif (name_.compare(other.name_) == 0)\r\n            {\r\n\t\t\t\treturn version_.compare(other.version_) > 0;\r\n\t\t\t}\r\n\t\t\telse\r\n            {\r\n\t\t\t\treturn name_.compare(other.name_) > 0;\r\n\t\t\t}\r\n\t\t}\r\n\t\telse \r\n        {\r\n\t\t\treturn library_.compare(other.library_) > 0;\r\n\t\t}\r\n\t}\r\n\telse\r\n    {\r\n\t\treturn vendor_.compare(other.vendor_) > 0;\r\n\t}\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VLNV::operator==()\r\n//-----------------------------------------------------------------------------\r\nbool VLNV::operator==(VLNV const& other) const\r\n{\r\n\treturn vendor_.compare(other.vendor_, Qt::CaseInsensitive) == 0 &&\r\n\t\tlibrary_.compare(other.library_, Qt::CaseInsensitive) == 0 &&\r\n\t\tname_.compare(other.name_, Qt::CaseInsensitive) == 0 &&\r\n\t\tversion_.compare(other.version_, Qt::CaseInsensitive) == 0;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VLNV::operator!=()\r\n//-----------------------------------------------------------------------------\r\nbool VLNV::operator!=(VLNV const& other) const\r\n{\r\n\treturn !operator==(other);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VLNV::string2Type()\r\n//-----------------------------------------------------------------------------\r\nVLNV::IPXactType VLNV::string2Type(QString const& type)\r\n{\r\n    return types.value(type, INVALID);\t\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VLNV::IPXactType2String()\r\n//-----------------------------------------------------------------------------\r\nQString VLNV::IPXactType2String(IPXactType const& type)\r\n{\r\n    return types.key(type, QStringLiteral(\"invalid\"));\t\r\n}\r\n"
  },
  {
    "path": "IPXACTmodels/common/VLNV.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: vlnv.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Antti Kamppi\r\n// Date: 23.6.2010\r\n//\r\n// Description:\r\n// A class to hold VLNV information of a single IP-XACT document.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef VLNV_H\r\n#define VLNV_H\r\n\r\n#include <IPXACTmodels/ipxactmodels_global.h>\r\n\r\n#include <QMetaType>\r\n#include <QString>\r\n#include <QStringList>\r\n#include <QVector>\r\n\r\n//-----------------------------------------------------------------------------\r\n//! A class to hold VLNV information of a single IP-XACT document.\r\n//-----------------------------------------------------------------------------\r\nclass IPXACTMODELS_EXPORT VLNV\r\n{\r\npublic:\r\n\r\n\t//! Type is used to tell the type of IP-XACT document.\r\n\tenum IPXactType\r\n    {\r\n        BUSDEFINITION = 0,      // ipxact:busDefinition\r\n        COMPONENT,\t\t\t\t// ipxact:component\r\n        DESIGN, \t\t\t\t// ipxact:design\r\n        GENERATORCHAIN,         // ipxact:generatorChain\r\n        ABSTRACTOR,             // ipxact:abstractor\r\n        DESIGNCONFIGURATION,    // ipxact:designConfiguration\r\n        ABSTRACTIONDEFINITION,  // ipxact:abstractionDefinition\r\n        CATALOG,                // ipxact:catalog\r\n        TYPEDEFINITION,         // ipxact:typeDefinition\r\n        COMDEFINITION,          // kactus2:comDefinition\r\n        APIDEFINITION,          // kactus2:apiDefinition\r\n\t\tINVALID                 // invalid type\r\n    };\r\n\r\n  \t/*! The default constructor\r\n\t *\r\n\t * Constructs an invalid VLNV instance.\r\n\t*/\r\n\tVLNV();\r\n\r\n\t/*! The Constructor.\r\n\t *\r\n\t *    @param [in] type    The type of the VLNV document (design, component...).\r\n\t *    @param [in] vendor  The name of the vendor.\r\n\t *    @param [in] library The name of the library.\r\n\t *    @param [in] name    The name of the item.\r\n\t *    @param [in] version The version number of the item.\r\n\t */\r\n\tVLNV(QString const& type, QString const& vendor, QString const& library,\r\n\t\tQString const& name, QString const& version);\r\n\r\n\t/*! Constructor that takes type parameter as enum\r\n\t *\r\n\t * This constructor uses enum IPXactType to define the type of the document.\r\n     *\r\n\t *    @param [in] type    IPXactType type parameter defining document type\r\n\t *    @param [in] vendor  The name of the vendor.\r\n\t *    @param [in] library The name of the library.\r\n\t *    @param [in] name    The name of the item.\r\n\t *    @param [in] version The version number of the item.\r\n\t */\r\n\tVLNV(IPXactType const& type, QString const& vendor, QString const& library,\r\n\t\t\tQString const& name, QString const& version);\r\n\r\n\t/*! The constructor.\r\n\t *\r\n\t *    @param [in] type The document type for the vlnv.\r\n\t *    @param [in] parseStr The string which is parsed to find the different vlnv fields.\r\n\t *    @param [in] separator The character used to separate the different vlnv fields in the string.\r\n\t *\r\n\t*/\r\n\tVLNV(IPXactType const& type, QString const& parseStr, QString const& separator = QLatin1String(\":\"));\r\n\r\n\t/*! Copy constructor\r\n\t *\r\n\t *    @param [in] other The VLNV to be copied.\r\n\t */\r\n\tVLNV(VLNV const& other) = default;\r\n\r\n\t//! The destructor\r\n\tvirtual ~VLNV() {};\r\n\r\n    /*! Get the vendor of the VLNV.\r\n\t *\r\n\t *    @return The name of the vendor.\r\n\t */\r\n\tQString getVendor() const;\r\n\r\n\t/*! Set the vendor for the vlnv.\r\n\t *\r\n\t *    @param [in] vendor The vendor name to set.\r\n\t*/\r\n\tvoid setVendor(QString const& vendor);\r\n\r\n\t/*! Get the library of the VLNV.\r\n\t *\r\n\t *    @return The name of the library\r\n\t */\r\n\tQString getLibrary() const;\r\n\r\n\t/*! Set the library for the vlnv.\r\n\t *\r\n\t *    @param [in] library The library name\r\n\t*/\r\n\tvoid setLibrary(QString const& library);\r\n\r\n\t/*! Get the name of the IP item in VLNV.\r\n\t *\r\n\t *    @return The name of the IP item in VLNV.\r\n\t */\r\n\tQString getName() const;\r\n\r\n\t/*! Set the name for the VLNV.\r\n\t *\r\n\t *    @param [in] name The new name.\r\n\t*/\r\n\tvoid setName(QString const& name);\r\n\r\n\t/*! Get the version of the VLNV.\r\n\t *\r\n\t *    @return the The version of the VLNV.\r\n\t */\r\n\tQString getVersion() const;\r\n\r\n\t/*! Set the version of the VLNV.\r\n\t *\r\n\t *    @param [in] version The new version.\r\n\t*/\r\n\tvoid setVersion(QString const& version);\r\n\r\n\t/*! Get the type of the document the VLNV belongs to.\r\n\t *\r\n\t *    @return IPXactType which tells the document type.\r\n\t */\r\n\tIPXactType getType() const;\r\n\r\n\t/*! Set the document type for the vlnv.\r\n\t *\r\n\t *    @param [in] type Specifies the type to set.\r\n\t*/\r\n\tvoid setType(IPXactType type);\r\n    \r\n\t/*! Get the type the VLNV belongs to in a QString.\r\n\t *\r\n\t *    @return The XML document element type.\r\n\t */\r\n\tQString getTypestr() const;\r\n\r\n    /*!\r\n     *  Checks if the VLNV is empty.\r\n     *\r\n     *    @returns True if all VLNV fields are empty, otherwise false.\r\n     */\r\n    bool isEmpty() const;\r\n\r\n    /*! Clear the vlnv (make all fields empty and type = INVALID)\r\n\t *\r\n\t*/\r\n\tvoid clear();\r\n\r\n\t/*! Checks if the vlnv is valid or not.\r\n\t *\r\n\t *    @return True, if the VLNV tag is valid, otherwise false.\r\n\t*/\r\n\tbool isValid() const;\r\n\r\n\t/*! Check if the vlnv is valid.\r\n\t *\r\n\t *    @param [in] errorList The list to add the possible error messages to.\r\n\t *    @param [in] parentIdentifier String from parent to help to identify the location of the error.\r\n\t *\r\n\t *    @return bool True if the state is valid and writing is possible.\r\n\t*/\r\n\tbool isValid(QVector<QString>& errors, QString const& parentIdentifier) const;\r\n    \r\n\t/*! Create a QString that contains the vlnv.\r\n\t *\r\n\t *    @param [in] separator The separator that is placed between each vlnv field\r\n\t *\r\n\t *    @return QString contains the vlnv in one string.\r\n\t*/\r\n\tQString toString(QString const& separator = QLatin1String(\":\")) const;\r\n\r\n\t//! The assignment operator for the class\r\n\tVLNV &operator=(const VLNV &other) = default;\r\n\r\n\t/*! The < operator for comparison of the VLNV info\r\n\t *\r\n\t *    @param [in] other the instance to compare\r\n     *\r\n\t *    @return boolean value of the comparison\r\n\t */\r\n\tbool operator<(const VLNV &other) const;\r\n\r\n\t/*! The > operator for comparison of the VLNV info\r\n\t *\r\n\t *    @param [in] other the instance to compare\r\n     *\r\n\t *    @return the boolean value of the comparison\r\n\t */\r\n\tbool operator>(const VLNV &other) const;\r\n\r\n\t/*! The == comparison operator\r\n\t *\r\n\t *    @param [in] other The other VLNV instance to be compared\r\n     *\r\n\t *    @return boolean value of the comparison operation\r\n\t */\r\n\tbool operator==(const VLNV &other) const;\r\n\r\n\t/*! The != operator\r\n\t *\r\n\t *    @param [in] other the instance to compare\r\n     *\r\n\t *    @return boolean value of the comparison operation\r\n\t */\r\n\tbool operator!=(const VLNV &other) const;\r\n\r\n\t/*! Static function. Convert QString formatted type to enum Type\r\n\t *\r\n\t *    @param [in] type QString that holds the type to get\r\n\t *    @return IPXactType that corresponds to the given string\r\n\t */\r\n\tstatic VLNV::IPXactType string2Type(QString const& type);\r\n\r\n    /*! Static function. Converts type to QString.\r\n\t *\r\n\t *    @param [in] type QString that holds the type to get\r\n     *\r\n\t *    @return IPXactType that corresponds to the given string\r\n\t */\r\n    static QString IPXactType2String(IPXactType const& type);\r\n   \r\nprivate:\r\n\r\n\t//! The name of the vendor\r\n\tQString vendor_;\r\n\r\n\t//! The name of the library\r\n\tQString library_;\r\n\r\n\t//! The name of the IP block\r\n\tQString name_;\r\n\r\n\t//! The version number of the block\r\n\tQString version_;\r\n\r\n\t//! The type of the document the VLNV-tag belongs to\r\n\tIPXactType type_ = VLNV::INVALID;\r\n};\r\n\r\n// With this declaration, VLNV can be used as a QVariant.\r\nQ_DECLARE_METATYPE(VLNV);\r\n\r\nQ_DECLARE_TYPEINFO(VLNV, Q_MOVABLE_TYPE);\r\n\r\n#endif /* VLNV_H */\r\n"
  },
  {
    "path": "IPXACTmodels/common/Vector.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: Vector.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Esko Pekkarinen\r\n// Date: 31.07.2015\r\n//\r\n// Description:\r\n// Implementation of ipxact:vector element.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"Vector.h\"\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Vector::Vector()\r\n//-----------------------------------------------------------------------------\r\nVector::Vector(QString const& left, QString const& right):\r\nRange(left, right)\r\n{\r\n    \r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Vector::clone()\r\n//-----------------------------------------------------------------------------\r\nVector* Vector::clone() const\r\n{\r\n    return new Vector(*this);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Vector::setId()\r\n//-----------------------------------------------------------------------------\r\nvoid Vector::setId(QString const& id)\r\n{\r\n    vectorId_ = id;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Vector::getId()\r\n//-----------------------------------------------------------------------------\r\nQString Vector::getId() const\r\n{\r\n    return vectorId_;\r\n}\r\n"
  },
  {
    "path": "IPXACTmodels/common/Vector.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: Vector.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Esko Pekkarinen\r\n// Date: 31.07.2015\r\n//\r\n// Description:\r\n// Implementation of ipxact:vector element.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef VECTOR_H\r\n#define VECTOR_H\r\n\r\n#include \"Range.h\"\r\n\r\n#include <IPXACTmodels/ipxactmodels_global.h>\r\n\r\n#include <QString>\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Implementation of ipxact:vector element.\r\n//-----------------------------------------------------------------------------\r\nclass IPXACTMODELS_EXPORT Vector : public Range\r\n{\r\npublic:\r\n\r\n    /*!\r\n     *  The constructor.\r\n     */\r\n    Vector() = default;\r\n\r\n    /*!\r\n     *  The constructor.\r\n     *\r\n     *    @param [in] left    The left side of the vector.\r\n     *    @param [in] right   The right side of the vector.\r\n     */\r\n    Vector(QString const& left, QString const& right);\r\n   \r\n    //! The destructor.\r\n    ~Vector() = default;\r\n\r\n    /*!\r\n     *  Create a copy of the Vector.\r\n     *\r\n     *    @return A Vector identical to this.\r\n     */\r\n    Vector* clone() const;\r\n\r\n    /*!\r\n     *\tSets the vector id.\r\n     *  \r\n     *    @param [in] id\tDescription\r\n     */\r\n    void setId(QString const& id);\r\n\r\n    /*!\r\n     *\tGets the vector id.\r\n     *  \r\n     * \t\t@return The vector id as string.\r\n     */\r\n    QString getId() const;\r\n\r\nprivate:\r\n\r\n    //! Name for referencing the vector.\r\n    QString vectorId_;\r\n\r\n};\r\n#endif // VECTOR_H\r\n"
  },
  {
    "path": "IPXACTmodels/common/VendorExtension.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: VendorExtension.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Esko Pekkarinen\r\n// Date: 8.5.2014\r\n//\r\n// Description:\r\n// Common interface for IP-XACT vendor extensions.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef VENDOREXTENSION_H\r\n#define VENDOREXTENSION_H\r\n\r\n#include <IPXACTmodels/ipxactmodels_global.h>\r\n\r\n#include <QXmlStreamWriter>\r\n\r\n//-----------------------------------------------------------------------------\r\n// class VendorExtension.\r\n//-----------------------------------------------------------------------------\r\nclass IPXACTMODELS_EXPORT VendorExtension\r\n{\r\n\r\npublic:\r\n\r\n    //! The destructor.\r\n    virtual ~VendorExtension() {}\r\n\r\n    /*!\r\n     *  Clones the vendor extension.\r\n     *\r\n     *    @return The clone copy of the vendor extension.\r\n     */\r\n    virtual VendorExtension* clone() const = 0;\r\n\r\n    /*!\r\n     *  Returns a type identifier for the vendor extension.\r\n     *\r\n     *    @return A type identifier of the vendor extension.\r\n     */\r\n    virtual QString type() const = 0;\r\n\r\n    /*!\r\n     *  Writes the vendor extension to XML.\r\n     *\r\n     *    @param [in] writer   The writer used for writing the XML.\r\n     */\r\n    virtual void write(QXmlStreamWriter& writer) const = 0;\r\n\r\n};\r\n\r\n#endif // VENDOREXTENSION_H\r\n"
  },
  {
    "path": "IPXACTmodels/common/validators/AssertionValidator.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: AssertionValidator.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 07.01.2016\r\n//\r\n// Description:\r\n// Validator for the ipxact:assertion.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"AssertionValidator.h\"\r\n\r\n#include <KactusAPI/include/ExpressionParser.h>\r\n\r\n#include <IPXACTmodels/common/Assertion.h>\r\n\r\n#include <QRegularExpression>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AssertionValidator::AssertionValidator()\r\n//-----------------------------------------------------------------------------\r\nAssertionValidator::AssertionValidator(QSharedPointer<ExpressionParser> expressionParser):\r\nexpressionParser_(expressionParser)\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AssertionValidator::validate()\r\n//-----------------------------------------------------------------------------\r\nbool AssertionValidator::validate(QSharedPointer<Assertion> assertion) const\r\n{\r\n    return hasValidName(assertion) && hasValidAssert(assertion);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AssertionValidator::hasValidName()\r\n//-----------------------------------------------------------------------------\r\nbool AssertionValidator::hasValidName(QSharedPointer<Assertion> assertion) const\r\n{\r\n    QRegularExpression whiteSpaceExpression;\r\n    whiteSpaceExpression.setPattern(QStringLiteral(\"^\\\\s*$\"));\r\n    QRegularExpressionMatch whiteSpaceMatch = whiteSpaceExpression.match(assertion->name());\r\n\r\n    if (assertion->name().isEmpty() || whiteSpaceMatch.hasMatch())\r\n    {\r\n        return false;\r\n    }\r\n\r\n    return true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AssertionValidator::hasValidAssert()\r\n//-----------------------------------------------------------------------------\r\nbool AssertionValidator::hasValidAssert(QSharedPointer<Assertion> assertion) const\r\n{\r\n    if (!assertion->getAssert().isEmpty())\r\n    {\r\n        QString solvedValue = expressionParser_->parseExpression(assertion->getAssert());\r\n\r\n        bool toIntOk = true;\r\n        int intValue = solvedValue.toInt(&toIntOk);\r\n\r\n        return toIntOk && intValue == 1;\r\n    }\r\n\r\n    return false;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AssertionValidator::findErrorsIn()\r\n//-----------------------------------------------------------------------------\r\nvoid AssertionValidator::findErrorsIn(QVector<QString>& errors, QSharedPointer<Assertion> assertion,\r\n    QString const& context) const\r\n{\r\n    findErrorsInName(errors, assertion, context);\r\n    findErrorsInAssert(errors, assertion, context);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AssertionValidator::findErrorsInName()\r\n//-----------------------------------------------------------------------------\r\nvoid AssertionValidator::findErrorsInName(QVector<QString>& errors, QSharedPointer<Assertion> assertion,\r\n    QString const& context) const\r\n{\r\n    if (!hasValidName(assertion))\r\n    {\r\n        errors.append(QObject::tr(\"Invalid name set for assertion %1 within %2\").\r\n            arg(assertion->name()).arg(context));\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AssertionValidator::findErrorsInAssert()\r\n//-----------------------------------------------------------------------------\r\nvoid AssertionValidator::findErrorsInAssert(QVector<QString>& errors, QSharedPointer<Assertion> assertion,\r\n    QString const& context) const\r\n{\r\n    if (!hasValidAssert(assertion))\r\n    {\r\n        errors.append(QObject::tr(\"Invalid assert set for assertion %1 within %2\").\r\n            arg(assertion->name()).arg(context));\r\n    }\r\n}"
  },
  {
    "path": "IPXACTmodels/common/validators/AssertionValidator.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: AssertionValidator.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 07.01.2016\r\n//\r\n// Description:\r\n// Validator for the ipxact:assertion.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef ASSERTIONVALIDATOR_H\r\n#define ASSERTIONVALIDATOR_H\r\n\r\n#include <IPXACTmodels/ipxactmodels_global.h>\r\n\r\n#include <QSharedPointer>\r\n#include <QString>\r\n#include <QVector>\r\n\r\nclass ExpressionParser;\r\nclass Assertion;\r\n//-----------------------------------------------------------------------------\r\n//! Validator for the ipxact:assertion.\r\n//-----------------------------------------------------------------------------\r\nclass IPXACTMODELS_EXPORT AssertionValidator\r\n{\r\npublic:\r\n\r\n    /*!\r\n     *  The constructor.\r\n     *\r\n     *    @param [in] expressionParser    The parser to use for solving expressions.\r\n     */\r\n    AssertionValidator(QSharedPointer<ExpressionParser> expressionParser);\r\n\r\n\t//! The destructor.\r\n    ~AssertionValidator() = default;\r\n    \r\n    /*!\r\n     *  Validates the given assertion.\r\n     *\r\n     *    @param [in] assertion   The selected assertion.\r\n     *\r\n     *    @return True, if the assertion is valid IP-XACT, otherwise false.\r\n     */\r\n    bool validate(QSharedPointer<Assertion> assertion) const;\r\n\r\n    /*!\r\n     *  Check if the name is valid.\r\n     *\r\n     *    @param [in] assertion   The selected assertion.\r\n     *\r\n     *    @return True, if the name is valid, otherwise false.\r\n     */\r\n    bool hasValidName(QSharedPointer<Assertion> assertion) const;\r\n\r\n    /*!\r\n     *  Check if the assert value is valid.\r\n     *\r\n     *    @param [in] assertion   The selected assertion.\r\n     *\r\n     *    @return True, if the assert value is valid, otherwise false.\r\n     */\r\n    bool hasValidAssert(QSharedPointer<Assertion> assertion) const;\r\n\r\n    /*!\r\n     *  Locate errors within an assertion.\r\n     *\r\n     *    @param [in] errors      List of found errors.\r\n     *    @param [in] assertion   The selected assertion.\r\n     *    @param [in] context     Context to help locate the error.\r\n     */\r\n    void findErrorsIn(QVector<QString>& errors, QSharedPointer<Assertion> assertion,\r\n        QString const& context) const;\r\n\r\nprivate:\r\n\r\n\t// Disable copying.\r\n\tAssertionValidator(AssertionValidator const& rhs);\r\n\tAssertionValidator& operator=(AssertionValidator const& rhs);\r\n\r\n    /*!\r\n     *  Find errors within name.\r\n     *\r\n     *    @param [in] errors      List of found errors.\r\n     *    @param [in] assertion   The selected assertion.\r\n     *    @param [in] context     Context to help locate the error.\r\n     */\r\n    void findErrorsInName(QVector<QString>& errors, QSharedPointer<Assertion> assertion, QString const& context)\r\n        const;\r\n\r\n    /*!\r\n     *  Find errors within assert value.\r\n     *\r\n     *    @param [in] errors      List of found errors.\r\n     *    @param [in] assertion   The selected assertion.\r\n     *    @param [in] context     Context to help locate the error.\r\n     */\r\n    void findErrorsInAssert(QVector<QString>& errors, QSharedPointer<Assertion> assertion, QString const& context)\r\n        const;\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! The expression parser to use.\r\n    QSharedPointer<ExpressionParser> expressionParser_;\r\n};\r\n\r\n#endif // ASSERTIONVALIDATOR_H\r\n"
  },
  {
    "path": "IPXACTmodels/common/validators/CellSpecificationValidator.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// CellSpecification: CellSpecificationValidator.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Janne Virtanen\r\n// Date: 10.12.2015\r\n//\r\n// Description:\r\n// Validator for ipxact:CellSpecification.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"CellSpecificationValidator.h\"\r\n\r\n#include <IPXACTmodels/common/CellSpecification.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: CellSpecificationValidator::CellSpecificationValidator()\r\n//-----------------------------------------------------------------------------\r\nCellSpecificationValidator::CellSpecificationValidator() :\r\nfunctions_({QStringLiteral(\"nd2\"),\r\n    QStringLiteral(\"buf\"),\r\n    QStringLiteral(\"inv\"),\r\n    QStringLiteral(\"mux21\"),\r\n    QStringLiteral(\"dff\"),\r\n    QStringLiteral(\"latch\"),\r\n    QStringLiteral(\"xor2\"),\r\n    QStringLiteral(\"other\")})\r\n{\r\n\t\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: CellSpecificationValidator::validateInstantiation()\r\n//-----------------------------------------------------------------------------\r\nbool CellSpecificationValidator::validate(QSharedPointer<CellSpecification> cellSpecification) const\r\n{\r\n\t// Must be known cell strength.\r\n\tif (cellSpecification->getCellStrength() == CellSpecification::UNKNOWN)\r\n\t{\r\n\t\treturn false;\r\n\t}\r\n\r\n\t// Must be supported function.\r\n\tif (!functions_.contains(cellSpecification->getCellFunction()))\r\n\t{\r\n\t\t// Alternatively, must be known cell strength.\r\n\t\tif (cellSpecification->getCellClass() == CellSpecification::NO_CLASS)\r\n\t\t{\r\n\t\t\treturn false;\r\n\t\t}\r\n\t}\r\n\r\n\treturn true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: CellSpecificationValidator::findErrorsIn()\r\n//-----------------------------------------------------------------------------\r\nvoid CellSpecificationValidator::findErrorsIn(QVector<QString>& errors,\r\n\tQSharedPointer<CellSpecification> cellSpecification, QString const& context) const\r\n{\r\n\t// Must be known cell strength.\r\n\tif (cellSpecification->getCellStrength() == CellSpecification::UNKNOWN)\r\n\t{\r\n\t\terrors.append(QObject::tr(\"Unknown cell strength in cell specification in %1.\").arg(context));\r\n\t}\r\n\r\n\t// Must be supported function.\r\n\tif (!functions_.contains(cellSpecification->getCellFunction()))\r\n\t{\r\n\t\t// Alternatively, must be known cell strength.\r\n\t\tif (cellSpecification->getCellClass() == CellSpecification::NO_CLASS)\r\n\t\t{\r\n\t\t\terrors.append(QObject::tr(\"No class specified for cell specification in %1.\").arg(context));\r\n\t\t}\r\n\t\telse\r\n\t\t{\r\n\t\t\terrors.append(QObject::tr(\"Invalid function '%1' in cell specification in %2.\").arg(\r\n                cellSpecification->getCellFunction(), context));\r\n\t\t}\r\n\t}\r\n}\r\n"
  },
  {
    "path": "IPXACTmodels/common/validators/CellSpecificationValidator.h",
    "content": "//-----------------------------------------------------------------------------\r\n// CellSpecification: CellSpecificationValidator.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Janne Virtanen\r\n// Date: 10.12.2015\r\n//\r\n// Description:\r\n// Validator for ipxact:CellSpecification.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef CELLSPECIFICATIONVALIDATOR_H\r\n#define CELLSPECIFICATIONVALIDATOR_H\r\n\r\n#include <IPXACTmodels/ipxactmodels_global.h>\r\n\r\n#include <QString>\r\n#include <QVector>\r\n#include <QSharedPointer>\r\n#include <QObject>\r\n\r\nclass CellSpecification;\r\n//-----------------------------------------------------------------------------\r\n//! Validator for ipxact:CellSpecification.\r\n//-----------------------------------------------------------------------------\r\nclass IPXACTMODELS_EXPORT CellSpecificationValidator\r\n{\r\npublic:\r\n\r\n\t/*!\r\n\t *  The constructor.\r\n\t *\r\n\t */\r\n    CellSpecificationValidator();\r\n\r\n\t//! The destructor.\r\n\t~CellSpecificationValidator() = default;\r\n\r\n    /*!\r\n     *  Validates the given CellSpecification.\r\n     *\r\n     *    @param [in] CellSpecification           The CellSpecification to validate.\r\n     *\r\n     *    @return True, if the CellSpecification is valid IP-XACT, otherwise false.\r\n     */\r\n    bool validate(QSharedPointer<CellSpecification> cellSpecification) const;\r\n\r\n    /*!\r\n     *  Finds possible errors in a CellSpecification and creates a list of them.\r\n     *\r\n     *    @param [in] errors              List of found errors.\r\n     *    @param [in] CellSpecification   The CellSpecification whose errors to find.\r\n     *    @param [in] context             Context to help locate the errors.\r\n     */\r\n    void findErrorsIn(QVector<QString>& errors, QSharedPointer<CellSpecification> cellSpecification,\r\n\t\tQString const& context) const;\r\n\r\nprivate:\r\n\r\n    // Disable copying.\r\n    CellSpecificationValidator(CellSpecificationValidator const& rhs);\r\n    CellSpecificationValidator& operator=(CellSpecificationValidator const& rhs);\r\n\r\n\t// Contains possible functions.\r\n\tQVector<QString> functions_;\r\n};\r\n\r\n#endif // CELLSPECIFICATIONVALIDATOR_H\r\n"
  },
  {
    "path": "IPXACTmodels/common/validators/ChoiceValidator.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: ChoiceValidator.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Mikko Teuho\n// Date: 07.12.2015\n//\n// Description:\n// Validator for the ipxact:choice.\n//-----------------------------------------------------------------------------\n\n#include \"ChoiceValidator.h\"\n\n#include <KactusAPI/include/ExpressionParser.h>\n\n#include <IPXACTmodels/common/Choice.h>\n\n#include <QRegularExpression>\n\n//-----------------------------------------------------------------------------\n// Function: ChoiceValidator::ChoiceValidator()\n//-----------------------------------------------------------------------------\nChoiceValidator::ChoiceValidator(QSharedPointer<ExpressionParser> expressionParser):\nexpressionParser_(expressionParser)\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: ChoiceValidator::validate()\n//-----------------------------------------------------------------------------\nbool ChoiceValidator::validate(QSharedPointer<Choice> choice) const\n{\n    return hasValidName(choice) && hasValidEnumerations(choice);\n}\n\n//-----------------------------------------------------------------------------\n// Function: ChoiceValidator::hasValidName()\n//-----------------------------------------------------------------------------\nbool ChoiceValidator::hasValidName(QSharedPointer<Choice> choice) const\n{\n    QRegularExpression whiteSpaceExpression;\n    whiteSpaceExpression.setPattern(QStringLiteral(\"^\\\\s*$\"));\n    QRegularExpressionMatch whiteSpaceMatch = whiteSpaceExpression.match(choice->name());\n\n    if (choice->name().isEmpty() || whiteSpaceMatch.hasMatch())\n    {\n        return false;\n    }\n\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: ChoiceValidator::hasValidEnumerations()\n//-----------------------------------------------------------------------------\nbool ChoiceValidator::hasValidEnumerations(QSharedPointer<Choice> choice) const\n{\n    if (!choice->enumerations()->isEmpty())\n    {\n        for (QSharedPointer<Enumeration> const& enumeration : *choice->enumerations())\n        {\n            bool isValidValue = false;\n            expressionParser_->parseExpression(enumeration->getValue(), &isValidValue);\n            if (enumeration->getValue().isEmpty() || isValidValue == false)\n            {\n                return false;\n            }\n        }\n\n        return true;\n    }\n\n    return false;\n}\n\n//-----------------------------------------------------------------------------\n// Function: ChoiceValidator::findErrorsIn()\n//-----------------------------------------------------------------------------\nvoid ChoiceValidator::findErrorsIn(QVector<QString>& errors, QSharedPointer<Choice> choice, QString const& context)\n    const\n{\n    findErrorsInName(errors, choice, context);\n    findErrorsInEnumerations(errors, choice, context);\n}\n\n//-----------------------------------------------------------------------------\n// Function: ChoiceValidator::findErrorsInName()\n//-----------------------------------------------------------------------------\nvoid ChoiceValidator::findErrorsInName(QVector<QString>& errors, QSharedPointer<Choice> choice,\n    QString const& context) const\n{\n    if (!hasValidName(choice))\n    {\n        errors.append(QObject::tr(\"Invalid name set for choice %1 within %2\").arg(choice->name(), context));\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: ChoiceValidator::findErrorsInEnumerations()\n//-----------------------------------------------------------------------------\nvoid ChoiceValidator::findErrorsInEnumerations(QVector<QString>& errors, QSharedPointer<Choice> choice,\n    QString const& context) const\n{\n    if (choice->enumerations()->isEmpty())\n    {\n        errors.append(QObject::tr(\"No enumerations found in choice '%1' within %2\").arg(choice->name(), context));\n    }\n    else\n    {\n        for (QSharedPointer<Enumeration> const& enumeration : *choice->enumerations())\n        {\n            bool isValidValue = false;\n            expressionParser_->parseExpression(enumeration->getValue(), &isValidValue);\n            \n            if (enumeration->getValue().isEmpty() || isValidValue == false)\n            {\n                errors.append(QObject::tr(\"Invalid value '%1' set for enumeration in choice '%2' within %3\").arg(\n                    enumeration->getValue(), choice->name(), context));\n            }\n        }\n    }\n}\n"
  },
  {
    "path": "IPXACTmodels/common/validators/ChoiceValidator.h",
    "content": "//-----------------------------------------------------------------------------\n// File: ChoiceValidator.h\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Mikko Teuho\n// Date: 07.12.2015\n//\n// Description:\n// Validator for the ipxact:choice.\n//-----------------------------------------------------------------------------\n\n#ifndef CHOICEVALIDATOR_H\n#define CHOICEVALIDATOR_H\n\n#include <IPXACTmodels/ipxactmodels_global.h>\n\n#include <QSharedPointer>\n#include <QString>\n#include <QVector>\n\nclass ExpressionParser;\nclass Choice;\n//-----------------------------------------------------------------------------\n//! Validator for the ipxact:choice.\n//-----------------------------------------------------------------------------\nclass IPXACTMODELS_EXPORT ChoiceValidator\n{\npublic:\n\n    /*!\n     *  The constructor.\n     *\n     *    @param [in] expressionParser    The parser to use for solving expressions.\n     */\n    ChoiceValidator(QSharedPointer<ExpressionParser> expressionParser);\n\n\t//! The destructor.\n\t~ChoiceValidator() = default;\n\n    // Disable copying.\n    ChoiceValidator(ChoiceValidator const& rhs) = delete;\n    ChoiceValidator& operator=(ChoiceValidator const& rhs) = delete;\n\n    /*!\n     *  Validates the given choice.\n     *\n     *    @param [in] choice  The selected choice.\n     *\n     *    @return True, if the choice is valid IP-XACT, otherwise false.\n     */\n    bool validate(QSharedPointer<Choice> choice) const;\n\n    /*!\n     *  Check if the name is valid.\n     *\n     *    @param [in] choice  The selected choice.\n     *\n     *    @return True, if the name is valid, otherwise false.\n     */\n    bool hasValidName(QSharedPointer<Choice> choice) const;\n\n    /*!\n     *  Check if the enumerations are valid.\n     *\n     *    @param [in] choice  The selected choice.\n     *\n     *    @return True, if the enumerations are valid, otherwise false.\n     */\n    bool hasValidEnumerations(QSharedPointer<Choice> choice) const;\n\n    /*!\n     *  Locate errors within a choice.\n     *\n     *    @param [in] errors      List of found errors.\n     *    @param [in] choice      The selected choice.\n     *    @param [in] context     Context to help locate the error.\n     */\n    void findErrorsIn(QVector<QString>& errors, QSharedPointer<Choice> choice, QString const& context) const;\n\nprivate:\n\n    /*!\n     *  Find errors within name.\n     *\n     *    @param [in] errors      List of found errors.\n     *    @param [in] choice      The selected choice.\n     *    @param [in] context     Context to help locate the error.\n     */\n    void findErrorsInName(QVector<QString>& errors, QSharedPointer<Choice> choice, QString const& context) const;\n\n    /*!\n     *  Find errors within enumerations.\n     *\n     *    @param [in] errors      List of found errors.\n     *    @param [in] choice      The selected choice.\n     *    @param [in] context     Context to help locate the error.\n     */\n    void findErrorsInEnumerations(QVector<QString>& errors, QSharedPointer<Choice> choice, QString const& context)\n        const;\n\n    //-----------------------------------------------------------------------------\n    // Data.\n    //-----------------------------------------------------------------------------\n\n    //! The expression parser to use.\n    QSharedPointer<ExpressionParser> expressionParser_;\n};\n\n#endif // ADDRESSSPACEVALIDATOR_H\n"
  },
  {
    "path": "IPXACTmodels/common/validators/CommonItemsValidator.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: CommonItemsValidator.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Esko Pekkarinen\n// Date: 19.05.2023\n//\n// Description:\n// Functions for validating common items in IPXACT models.\n//-----------------------------------------------------------------------------\n\n\n#include \"CommonItemsValidator.h\"\n\n#include <IPXACTmodels/Component/RegisterBase.h>\n#include <IPXACTmodels/Component/AccessPolicy.h>\n#include <IPXACTmodels/Component/Mode.h>\n#include <IPXACTmodels/utilities/Search.h>\n\n#include <QRegularExpression>\n\n//-----------------------------------------------------------------------------\n// Function: CommonItemsValidator::hasValidName()\n//-----------------------------------------------------------------------------\nbool CommonItemsValidator::hasValidName(QString const& name)\n{\n    QRegularExpression validNameRegex(QStringLiteral(\"^[a-zA-Z:_][a-zA-Z0-9-_:.]*$\"));\n    return validNameRegex.match(name).hasMatch();\n}\n\n//-----------------------------------------------------------------------------\n// Function: CommonItemsValidator::hasValidIsPresent()\n//-----------------------------------------------------------------------------\nbool CommonItemsValidator::hasValidIsPresent(QString const& isPresent, QSharedPointer<ExpressionParser> parser)\n{\n    if (isPresent.isEmpty())\n    {\n        return true;\n    }\n\n    QString solvedValue = parser->parseExpression(isPresent);\n\n    bool toIntOk = true;\n    int intValue = solvedValue.toInt(&toIntOk);\n\n    return (toIntOk && intValue >= 0 && intValue < 2);\n}\n\n//-----------------------------------------------------------------------------\n// Function: CommonItemsValidator::isValidExpression()\n//-----------------------------------------------------------------------------\nbool CommonItemsValidator::isValidExpression(QString const& expression, QSharedPointer<ExpressionParser> parser)\n{\n    bool expressionOk = false;\n    QString solvedValue = parser->parseExpression(expression, &expressionOk);\n\n    if (expressionOk == false)\n    {\n        return false;\n    }\n\n    bool changeOk = true;\n    quint64 intValue = solvedValue.toULongLong(&changeOk);\n\n    if (changeOk && intValue > 0)\n    {\n        return true;\n    }\n\n    return false;\n}\n\n//-----------------------------------------------------------------------------\n// Function: CommonItemsValidator::hasValidModeRefs()\n//-----------------------------------------------------------------------------\nbool CommonItemsValidator::hasValidModeRefs(QSharedPointer<QList<QSharedPointer<ModeReference> > > modeRefs, \n    QSharedPointer<QList<QSharedPointer<Mode> > > availableModes)\n{\n    QStringList checkedReferences;\n    QList<uint> checkedPriorities;\n\n    QStringList availableModeNames = Search::getNames(availableModes);\n\n    for (auto const& modeRef : *modeRefs)\n    {\n        auto reference = modeRef->getReference();\n        auto priority = modeRef->getPriority();\n\n        if (!CommonItemsValidator::hasValidName(reference))\n        {\n            return false;\n        }\n\n        if (checkedPriorities.contains(priority))\n        {\n            return false;\n        }\n        else\n        {\n            checkedPriorities.append(priority);\n        }\n\n        if (checkedReferences.contains(reference))\n        {\n            return false;\n        }\n        else\n        {\n            checkedReferences.append(reference);\n        }\n\n        if (!availableModeNames.contains(reference))\n        {\n            return false;\n        }\n    }\n\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: CommonItemsValidator::hasValidModeRefs()\n//-----------------------------------------------------------------------------\nbool CommonItemsValidator::hasValidModeRefs(QSharedPointer<QList<QSharedPointer<ModeReference> > > modeRefsToCheck,\n    QSharedPointer<QList<QSharedPointer<ModeReference> > > otherModeReferencesInUse,\n    QSharedPointer<QList<QSharedPointer<Mode> > > availableModes)\n{\n    QStringList checkedReferences;\n    QList<uint> checkedPriorities;\n\n    QStringList availableModeNames = Search::getNames(availableModes);\n\n    std::for_each(otherModeReferencesInUse->cbegin(), otherModeReferencesInUse->cend(),\n        [&checkedReferences, &checkedPriorities](auto modeReference)\n        {\n            checkedReferences << modeReference->getReference();\n            checkedPriorities << modeReference->getPriority();\n        });\n\n    for (auto const& modeRef : *modeRefsToCheck)\n    {\n        auto reference = modeRef->getReference();\n        auto priority = modeRef->getPriority();\n\n        if (!CommonItemsValidator::hasValidName(reference))\n        {\n            return false;\n        }\n\n        if (checkedPriorities.contains(priority))\n        {\n            return false;\n        }\n        else\n        {\n            checkedPriorities.append(priority);\n        }\n\n        if (checkedReferences.contains(reference))\n        {\n            return false;\n        }\n        else\n        {\n            checkedReferences.append(reference);\n        }\n\n        if (!availableModeNames.contains(reference))\n        {\n            return false;\n        }\n    }\n\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: CommonItemsValidator::findErrorsInModeRefs()\n//-----------------------------------------------------------------------------\nvoid CommonItemsValidator::findErrorsInModeRefs(QStringList& errors, \n    QSharedPointer<QList<QSharedPointer<ModeReference> > > modeRefs, QString const& context,\n    QStringList& checkedRefs, QList<unsigned int>& checkedPriorities, bool* duplicateRefErrorIssued, \n    bool* duplicatePriorityErrorIssued, QSharedPointer<QList<QSharedPointer<Mode> > > availableModes)\n{\n    QStringList availableModeNames = Search::getNames(availableModes);\n\n    for (auto const& modeRef : *modeRefs)\n    {\n        auto reference = modeRef->getReference();\n        auto priority = modeRef->getPriority();\n\n        if (!hasValidName(reference) || !availableModeNames.contains(reference))\n        {\n            errors.append(QObject::tr(\n                \"Mode reference in %1 has invalid or empty reference value '%2'.\").arg(context).arg(reference));\n        }\n\n        if (checkedPriorities.contains(priority) && *duplicatePriorityErrorIssued == false)\n        {\n            errors.append(QObject::tr(\n                \"One or more mode references in %1 contain duplicate priority values.\").arg(context));\n            *duplicatePriorityErrorIssued = true;\n        }\n        else\n        {\n            checkedPriorities.append(priority);\n        }\n\n        if (checkedRefs.contains(reference) && *duplicateRefErrorIssued == false)\n        {\n            errors.append(QObject::tr(\n                \"One or more mode references in %1 contain duplicate mode reference values.\")\n                .arg(context));\n            *duplicateRefErrorIssued = true;\n        }\n        else\n        {\n            checkedRefs.append(reference);\n        }\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: CommonItemsValidator::singleModeReferenceIsValid()\n//-----------------------------------------------------------------------------\nbool CommonItemsValidator::singleModeReferenceIsValid(\n    QSharedPointer<QList<QSharedPointer<ModeReference> > > modeRefsInContainingElem, \n    QSharedPointer<ModeReference> modeReferenceToCheck, bool isRemap /*= false*/)\n{\n    if (!CommonItemsValidator::hasValidName(modeReferenceToCheck->getReference()))\n    {\n        return false;\n    }\n\n    for (auto const& modeRef : *modeRefsInContainingElem)\n    {\n        auto reference = modeRef->getReference();\n        auto priority = modeRef->getPriority();\n\n        if (reference == modeReferenceToCheck->getReference())\n        {\n            return false;\n        }\n\n        // Check priority only if mode ref is contained in other element than memory remap. In remaps, priority\n        // doesn't have to be unique.\n        if (!isRemap && priority == modeReferenceToCheck->getPriority())\n        {\n            return false;\n        }\n    }\n\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: CommonItemsValidator::modeReferencePriorityIsValid()\n//-----------------------------------------------------------------------------\nbool CommonItemsValidator::modeReferencePriorityIsValid(QList<unsigned int> const& modeRefPrioritiesInContainingElem,\n    unsigned int modeReferencePriorityToCheck, bool isRemap /*= false*/)\n{\n    if (!isRemap)\n    {\n        for (auto const& modeRef : modeRefPrioritiesInContainingElem)\n        {  \n            // Check priority only if mode ref is contained in other element than memory remap. In remaps, priority\n            // doesn't have to be unique.\n            if (modeRef == modeReferencePriorityToCheck)\n            {\n                return false;\n            }\n        }\n    }\n\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: CommonItemsValidator::modeReferenceValueIsValid()\n//-----------------------------------------------------------------------------\nbool CommonItemsValidator::modeReferenceValueIsValid(std::vector<std::string> const& modeRefsInContainingElem, \n    std::string const& modeReferenceToCheck, QStringList const& availableModes)\n{    \n    auto modeRefToCheckQ = QString::fromStdString(modeReferenceToCheck);\n    if (!CommonItemsValidator::hasValidName(modeRefToCheckQ))\n    {\n        return false;\n    }\n\n    // Check that there are no duplicate mode references in containing element and that a corresponding component\n    // mode is found.\n    return std::none_of(modeRefsInContainingElem.cbegin(), modeRefsInContainingElem.cend(),\n        [&modeReferenceToCheck, &modeRefToCheckQ, &availableModes](auto const& modeRef)\n        {\n            return modeRef == modeReferenceToCheck || !availableModes.contains(modeRefToCheckQ);\n        });\n}\n\n//-----------------------------------------------------------------------------\n// Function: CommonItemsValidator::hasValidAccessPolicies()\n//-----------------------------------------------------------------------------\nbool CommonItemsValidator::hasValidAccessPolicies(\n    QSharedPointer<QList<QSharedPointer<AccessPolicy> > > accessPolicies,\n    QSharedPointer<QList<QSharedPointer<Mode> > > availableModes)\n{\n    int accessPoliciesWithoutModeRef = 0;\n\n    auto allModeRefs = QSharedPointer<QList<QSharedPointer<ModeReference> > >(\n        new QList<QSharedPointer<ModeReference> >());\n\n    for (auto const& accessPolicy : *accessPolicies)\n    {\n        auto modeRefs = accessPolicy->getModeReferences();\n        if (modeRefs->isEmpty())\n        {\n            accessPoliciesWithoutModeRef++;\n        }\n\n        std::for_each(modeRefs->cbegin(), modeRefs->cend(), [&allModeRefs](auto modeRef)\n            {\n                allModeRefs->append(modeRef);\n            });\n    }\n\n    // Check if the mode references of the access policy are valid. Also check for duplicate mode refs between\n    // all access policies.\n    if (!hasValidModeRefs(allModeRefs, availableModes))\n    {\n        return false;\n    }\n\n    // Number of access policies without mode references cannot be greater than one (no mode ref = applies to all\n    // other modes not explicitly defined with mode references).\n    if (accessPoliciesWithoutModeRef > 1)\n    {\n        return false;\n    }\n\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: CommonItemsValidator::findErrorsInAccessPolicies()\n//-----------------------------------------------------------------------------\nvoid CommonItemsValidator::findErrorsInAccessPolicies(QStringList& errors, \n    QSharedPointer<QList<QSharedPointer<AccessPolicy> > > accessPolicies, QSharedPointer<QList<QSharedPointer<Mode> > > componentModes, QString const& context)\n{\n    int accessPoliciesWithoutModeRefs = 0;\n\n    QString accessPolicyContext = QStringLiteral(\"access policies of \") + context;\n\n    bool duplicateModeRefErrorIssued = false;\n    bool duplicateModePriorityErrorIssued = false;\n\n    QStringList checkedModeReferences;\n    QList<unsigned int> checkedModePriorities;\n\n    for (auto const& accessPolicy : *accessPolicies)\n    {\n        if (accessPolicy->getModeReferences()->isEmpty())\n        {\n            accessPoliciesWithoutModeRefs++;\n        }\n\n        // Check mode references in current access policy, and look for duplicate references.\n        CommonItemsValidator::findErrorsInModeRefs(errors, accessPolicy->getModeReferences(), accessPolicyContext,\n            checkedModeReferences, checkedModePriorities, &duplicateModeRefErrorIssued, &duplicateModePriorityErrorIssued, componentModes);\n    }\n\n    // Number of access policies without mode references cannot be greater than one (no mode ref = applies to all\n    // other modes not explicitly defined with mode references).\n    if (accessPoliciesWithoutModeRefs > 1)\n    {\n        errors.append(QObject::tr(\"In %1: multiple access policies without mode references are not allowed.\")\n            .arg(accessPolicyContext));\n    }\n}\n"
  },
  {
    "path": "IPXACTmodels/common/validators/CommonItemsValidator.h",
    "content": "//-----------------------------------------------------------------------------\n// File: CommonItemsValidator.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Esko Pekkarinen\n// Date: 19.05.2023\n//\n// Description:\n// Functions for validating common items in IPXACT models.\n//-----------------------------------------------------------------------------\n\n#ifndef COMMONITEMSVALIDATOR_H\n#define COMMONITEMSVALIDATOR_H\n\n#include <KactusAPI/include/ExpressionParser.h>\n\n#include <IPXACTmodels/ipxactmodels_global.h>\n\n#include <QSharedPointer>\n\nclass ModeReference;\nclass RegisterBase;\nclass AccessPolicy;\nclass Mode;\n\nnamespace CommonItemsValidator\n{\n    /*!\n     * Validates the given name.\n     *\n     *    @param [in] name The name to validate.\n     *\n     *    @return True, if the name is valid, otherwise false.\n     */\n    bool hasValidName(QString const& name);\n\n    /*!\n      * Validates the given isPresent expression.\n      *\n      *    @param [in] isPresent   The expression to validate.\n      *    @param [in] parser      The expression parser to use.\n      *\n      *    @return True, if the isPresent is valid, otherwise false.\n      */\n    bool hasValidIsPresent(QString const& isPresent, QSharedPointer<ExpressionParser> parser);\n\n    bool isValidExpression(QString const& expression, QSharedPointer<ExpressionParser> parser);\n\n    /*!\n     *\tCheck if given mode references are valid. Also look for duplicate values when compared with \n     *  previously checked references.\n     *  \n     *    @param [in] modeRefs              The mode references to check.\n     *    @param [in] availableModes        The available component modes.\n     *\t    \n     * \t    @return True, if the given mode references are valid, otherwise false.\n     */\n    bool hasValidModeRefs(QSharedPointer<QList<QSharedPointer<ModeReference> > > modeRefs, QSharedPointer<QList<QSharedPointer<Mode> > > availableModes);\n\n    /*!\n     *\tCheck if given mode references are valid. Compare with other mode references in the containing element.\n     *  Used for validating mode references of single item, for UI purposes.\n     *  \n     *    @param [in] modeRefsToCheck             The mode references to check.\n     *    @param [in] otherModeReferencesInUse    The other mode references in the containing item.\n     *    @param [in] availableModes              The available component modes.\n     *\t    \n     * \t    @return True, if mode references were valid, otherwise false.\n     */\n    IPXACTMODELS_EXPORT bool hasValidModeRefs(QSharedPointer<QList<QSharedPointer<ModeReference> > > modeRefsToCheck, \n        QSharedPointer<QList<QSharedPointer<ModeReference> > > otherModeReferencesInUse, \n        QSharedPointer<QList<QSharedPointer<Mode> > > availableModes);\n\n    /*!\n     *\tFinds errors in mode references within in a parent element. Mode reference values and priorities must \n     *  be unique not only within the mode references of the parent element, but also the parent's sibling elements.\n     *  For instance, all mode references inside access policy elements of a register must be unique.\n     *  \n     *    @param [in] errors                          The list of found errors.\n     *    @param [in] modeRefs                        The mode references to check.\n     *    @param [in] context                         Context to help locate the error.\n     *    @param [in] checkedRefs                     Already checked mode reference values.\n     *    @param [in] checkedPriorities               Already checked mode reference priorities.\n     *    @param [in] duplicateRefErrorIssued         Flag indicating if an error for duplicate references has been issued.\n     *    @param [in] duplicatePriorityErrorIssued    Flag indicating if an error for duplicate priorities has been issued.\n     */\n    void findErrorsInModeRefs(QStringList& errors, QSharedPointer<QList<QSharedPointer<ModeReference> > > modeRefs,\n        QString const& context, QStringList& checkedRefs, QList<unsigned int>& checkedPriorities, \n        bool* duplicateRefErrorIssued, bool* duplicatePriorityErrorIssued, QSharedPointer<QList<QSharedPointer<Mode> > > availableModes);\n    \n    /*!\n     *\tCheck if a single mode reference is valid. Provide all mode references in containing element to check \n     *  against for duplicates.\n     *  \n     *    @param [in] modeRefsInContainingElem     All other mode references in the containing element.\n     *    @param [in] modeReferenceToCheck         The mode reference to check.\n     *    @param [in] isRemap                      Flag indicating if given mode ref is within a remap or not.\n     *\t    \n     * \t    @return True, if mode reference is valid, otherwise false.\n     */\n    IPXACTMODELS_EXPORT bool singleModeReferenceIsValid(QSharedPointer<QList<QSharedPointer<ModeReference> > > modeRefsInContainingElem,\n        QSharedPointer<ModeReference> modeReferenceToCheck, bool isRemap = false);\n    \n    /*!\n     *\tCheck if the priority of a single mode reference is valid. Provide all other mode reference priorities in \n     *  containing element to check against for duplicates (if not within memory remap).\n     *\n     *    @param [in] modeRefPrioritiesInContainingElem     All other mode references in the containing element.\n     *    @param [in] modeReferencePriorityToCheck          The mode reference whose priority to check.\n     *    @param [in] isRemap                               Flag indicating mode ref priority being checked is \n     *                                                        within a remap or not.\n     *\n     * \t    @return True, if the mode reference priority is valid, otherwise false.\n     */\n    IPXACTMODELS_EXPORT bool modeReferencePriorityIsValid(QList<unsigned int> const& modeRefPrioritiesInContainingElem,\n        unsigned int modeReferencePriorityToCheck, bool isRemap = false);\n\n    /*!\n     *\tCheck if the reference value of a single mode reference is valid. Provide all other mode references in \n     *  containing element to check against for duplicates.\n     *\n     *    @param [in] modeRefsInContainingElem     All other mode references in the containing element.\n     *    @param [in] modeReferenceToCheck         The mode reference whose reference value to check.\n     *    @param [in] availableModes               The available component modes.\n     *\n     * \t    @return True, if the mode reference value is valid, otherwise false.\n     */\n    IPXACTMODELS_EXPORT bool modeReferenceValueIsValid(std::vector<std::string> const& modeRefsInContainingElem,\n        std::string const& modeReferenceToCheck, QStringList const& availableModes);\n\n    /*!\n     *\tValidate given access policies.\n     *  \n     *    @param [in] accessPolicies     The access policies to validate.\n     *\t    \n     * \t    @return True, if the access policies are valid, otherwise false.\n     */\n    IPXACTMODELS_EXPORT bool hasValidAccessPolicies(QSharedPointer<QList<QSharedPointer<AccessPolicy> > > accessPolicies, QSharedPointer<QList<QSharedPointer<Mode> > > availableModes);\n\n    /*!\n     *\tFind errors in given access policies.\n     *  \n     *    @param [in] errors              The list of found errors.\n     *    @param [in] accessPolicies      List of access policies to check.\n     *    @param [in] componentModes      List of available component modes.\n     *    @param [in] context            \n     */\n    IPXACTMODELS_EXPORT void findErrorsInAccessPolicies(QStringList& errors, \n        QSharedPointer<QList<QSharedPointer<AccessPolicy> > > accessPolicies, \n        QSharedPointer<QList<QSharedPointer<Mode> > > componentModes, QString const& context);\n};\n\n\n#endif // COMMONITEMSVALIDATOR_H\n"
  },
  {
    "path": "IPXACTmodels/common/validators/HierarchicalValidator.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: HierarchicalValidator.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: \n// Date: 06.08.2024\n//\n// Description:\n// Parent validator for validators used in component editor to be able to mark child items as invalid.\n//-----------------------------------------------------------------------------\n\n#include \"HierarchicalValidator.h\"\n\n#include <IPXACTmodels/common/NameGroup.h>\n\n#include <QMultiHash>\n\n//-----------------------------------------------------------------------------\n// Function: HierarchicalValidator::checkChildren()\n//-----------------------------------------------------------------------------\nbool HierarchicalValidator::childrenHaveUniqueNames(QSharedPointer<QList<QSharedPointer<NameGroup> > > children)\n{\n    if (children->isEmpty() || !childValidator_)\n    {\n        return true;\n    }\n\n    bool childrenAreValid = true;\n\n    QMultiHash<QString, QSharedPointer<NameGroup> > found;\n    for (auto child : *children)\n    {\n        if (found.contains(child->name()))\n        {\n            found.insert(child->name(), child);\n\n            for (auto duplicate : found.values(child->name()))\n            {\n                childValidator_->setChildItemValidity(duplicate, false);\n            }\n            \n            childrenAreValid = false;\n        }\n        else\n        {\n            found.insert(child->name(), child);\n            childValidator_->setChildItemValidity(child, true);\n        }\n    }\n\n    return childrenAreValid;\n}\n\n//-----------------------------------------------------------------------------\n// Function: HierarchicalValidator::setChildValidator()\n//-----------------------------------------------------------------------------\nvoid HierarchicalValidator::setChildValidator(QSharedPointer<HierarchicalValidator> childValidator)\n{\n    childValidator_ = childValidator;\n}\n\n//-----------------------------------------------------------------------------\n// Function: HierarchicalValidator::validComparedToSiblings()\n//-----------------------------------------------------------------------------\nbool HierarchicalValidator::validComparedToSiblings(QSharedPointer<NameGroup> currentChildItem) const\n{\n    return childItemValidities_.contains(currentChildItem) ? childItemValidities_[currentChildItem] : true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: HierarchicalValidator::setChildItemValidity()\n//-----------------------------------------------------------------------------\nvoid HierarchicalValidator::setChildItemValidity(QSharedPointer<NameGroup> childItem, bool isValid)\n{\n    childItemValidities_.insert(childItem, isValid);\n}\n\n//-----------------------------------------------------------------------------\n// Function: HierarchicalValidator::clearChildItemValidities()\n//-----------------------------------------------------------------------------\nvoid HierarchicalValidator::clearChildItemValidities()\n{\n    childItemValidities_.clear();\n}\n"
  },
  {
    "path": "IPXACTmodels/common/validators/HierarchicalValidator.h",
    "content": "//-----------------------------------------------------------------------------\n// File: HierarchicalValidator.h\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Anton Hagqvist\n// Date: 31.07.2024\n//\n// Description:\n// Parent validator for validators used in component editor to be able to mark child items as invalid.\n//-----------------------------------------------------------------------------\n\n#ifndef HIERARCHICALVALIDATOR_H\n#define HIERARCHICALVALIDATOR_H\n\n#include <IPXACTmodels/ipxactmodels_global.h>\n\n#include <QHash>\n#include <QSharedPointer>\n\nclass NameGroup;\n\nclass IPXACTMODELS_EXPORT HierarchicalValidator\n{\npublic:\t\n\n    HierarchicalValidator() = default;\n\n    /*!\n     *\tCheck and mark validity of child/sibling items. Checks for name uniqueness.\n     *  \n     *    @param [in] children     The items to be validated.\n     *\t    \n     * \t    @return True, if all child items are valid amongst themselves, false otherwise.\n     */\n    virtual bool childrenHaveUniqueNames(QSharedPointer<QList<QSharedPointer<NameGroup> > > children);\n\n    /*!\n     *\tSet the validator to be used when validating child/sibling items.\n     *  \n     *    @param [in] childValidator     The validator to set.\n     */\n    void setChildValidator(QSharedPointer<HierarchicalValidator> childValidator);\n\n    /*!\n     *\tChecks if the item is valid amongst its siblings. The item validity can be set by the parent validator\n     *  on a higher level in the hierarchy and is stored in the childItemValidities map.\n     *  \n     *    @param [in] currentChildItem     The item to check.\n     *\t    \n     * \t    @return True, if the item is valid, otherwise false.\n     */\n    bool validComparedToSiblings(QSharedPointer<NameGroup> currentChildItem) const;\n\n    /*!\n     *\tSet the validitiy of an item. Called by a higher level validator.\n     *  \n     *    @param [in] childItem     The item whose validity to set.\n     *    @param [in] isValid       The validity status to set.\n     */\n    void setChildItemValidity(QSharedPointer<NameGroup> childItem, bool isValid);\n\n    /*!\n     *\tClear the item validities.\n     */\n    void clearChildItemValidities();\n\nprotected:\n\n    //! The validity of the sibling items of the current validator. E.g. for MemoryMapValidator these \n    //  are the validities of the other memory maps.\n    QHash<QSharedPointer<NameGroup>, bool> childItemValidities_;\n\n    //! The validator of the next level in the hierarchy. \n    QSharedPointer<HierarchicalValidator > childValidator_;\n};\n\n\n#endif // HIERARCHICALVALIDATOR_H\n"
  },
  {
    "path": "IPXACTmodels/common/validators/NMTokenValidator.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: NMTokenValidator.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 03.12.2014\r\n//\r\n// Description:\r\n// Validator for IP-Xact's NMtoken-type\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"NMTokenValidator.h\"\r\n\r\n#include <QRegularExpression>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: NMTokenValidator::NMTokenValidator()\r\n//-----------------------------------------------------------------------------\r\nNMTokenValidator::NMTokenValidator(QObject* parent):\r\nQRegularExpressionValidator(parent)\r\n{\r\n    QRegularExpression exp(QStringLiteral(\"([a-zA-Z0-9:_.-]*$)|(^$)\"));\r\n    setRegularExpression(exp);\r\n}\r\n"
  },
  {
    "path": "IPXACTmodels/common/validators/NMTokenValidator.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: NMTokenValidator.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 03.12.2014\r\n//\r\n// Description:\r\n// Validator for IP-Xact's NMtoken-type\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef NMTOKENVALIDATOR_H\r\n#define NMTOKENVALIDATOR_H\r\n\r\n#include <IPXACTmodels/ipxactmodels_global.h>\r\n\r\n#include <QRegularExpressionValidator>\r\n\r\n//-----------------------------------------------------------------------------\r\n//! NMTokenValidator class.\r\n//-----------------------------------------------------------------------------\r\nclass IPXACTMODELS_EXPORT NMTokenValidator : public QRegularExpressionValidator\r\n{\r\n    Q_OBJECT\r\n\r\npublic:\r\n\r\n    /*!\r\n     *  Constructor for the validator.\r\n     *\r\n     *    @param [in] parent   Parent of the validator.\r\n     */\r\n    explicit NMTokenValidator(QObject* parent);\r\n\r\n    //! No copying\r\n    NMTokenValidator(const NMTokenValidator& other) = delete;\r\n    \r\n    //! No assignment\r\n    NMTokenValidator& operator=(const NMTokenValidator& other) = delete;\r\n\r\n    /*!\r\n     *  Destructor of the validator.\r\n     */\r\n    virtual ~NMTokenValidator() = default;\r\n\r\n};\r\n\r\n#endif // NMTOKENVALIDATOR_H\r\n"
  },
  {
    "path": "IPXACTmodels/common/validators/ParameterValidator.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ParameterValidator.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Esko Pekkarinen\r\n// Date: 11.12.2014\r\n//\r\n// Description:\r\n// Validator for ipxact:parameter.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"ParameterValidator.h\"\r\n\r\n#include <IPXACTmodels/common/Parameter.h>\r\n\r\n#include <IPXACTmodels/common/Choice.h>\r\n#include <IPXACTmodels/common/Enumeration.h>\r\n#include <IPXACTmodels/common/Parameter.h>\r\n\r\n#include <IPXACTmodels/common/validators/ValueFormatter.h>\r\n\r\n#include <KactusAPI/include/ExpressionParser.h>\r\n\r\n#include <QRegularExpression>\r\n#include <QStringList>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SystemVerilogValidator::SystemVerilogValidator()\r\n//-----------------------------------------------------------------------------\r\nParameterValidator::ParameterValidator(QSharedPointer<ExpressionParser> expressionParser,\r\n    QSharedPointer<QList<QSharedPointer<Choice> > > availableChoices, Document::Revision docRevision):\r\nexpressionParser_(expressionParser),\r\n    availableChoices_(availableChoices),\r\n    typeValidator_(QRegularExpression(QStringLiteral(\"bit|byte|shortint|int|longint|shortreal|real|string|^$\"))),\r\n    docRevision_(docRevision)\r\n{\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ParameterValidator::componentChange()\r\n//-----------------------------------------------------------------------------\r\nvoid ParameterValidator::componentChange(QSharedPointer<QList<QSharedPointer<Choice> > > newChoices,\r\n    Document::Revision docRevision)\r\n{\r\n    availableChoices_ = newChoices;\r\n    setStdRevision(docRevision);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ParameterValidator::setStdRevision()\r\n//-----------------------------------------------------------------------------\r\nvoid ParameterValidator::setStdRevision(Document::Revision docRevision)\r\n{\r\n    docRevision_ = docRevision;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ParameterValidator::validate()\r\n//-----------------------------------------------------------------------------\r\nbool ParameterValidator::validate(QSharedPointer<const Parameter> parameter) const\r\n{\r\n    return hasValidName(parameter) &&\r\n        hasValidValue(parameter) &&\r\n        hasValidMinimumValue(parameter) &&\r\n        hasValidMaximumValue(parameter) &&\r\n        hasValidChoice(parameter) &&\r\n        hasValidResolve(parameter) &&\r\n        hasValidValueId(parameter) &&\r\n        hasValidVector(parameter);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ParameterValidator::hasValidName()\r\n//-----------------------------------------------------------------------------\r\nbool ParameterValidator::hasValidName(QSharedPointer<const Parameter> parameter) const\r\n{\r\n    return !parameter->name().trimmed().isEmpty();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ParameterValidator::hasValidValue()\r\n//-----------------------------------------------------------------------------\r\nbool ParameterValidator::hasValidValue(QSharedPointer<const Parameter> parameter) const\r\n{\r\n    if (parameter->getValue().isEmpty())\r\n    {\r\n        return false;\r\n    }\r\n\r\n    QString value = expressionParser_->parseExpression(parameter->getValue());\r\n    QString type = parameter->getType();\r\n\r\n    return hasValidValueForType(parameter) &&\r\n        !valueIsLessThanMinimum(parameter, value, type) &&\r\n        !valueIsGreaterThanMaximum(parameter, value, type) &&\r\n        hasValidValueForChoice(parameter);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ParameterValidator::hasValidType()\r\n//-----------------------------------------------------------------------------\r\nbool ParameterValidator::hasValidType(QSharedPointer<const Parameter> parameter) const\r\n{\r\n    int pos = 0;\r\n    QString type = parameter->getType();\r\n    return typeValidator_.validate(type, pos) == QRegularExpressionValidator::Acceptable;  \r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SystemVerilogValidator::hasValidValueForType()\r\n//-----------------------------------------------------------------------------\r\nbool ParameterValidator::hasValidValueForType(QString const& value, QString const& type) const\r\n{\r\n    if (type.isEmpty() || type.compare(QLatin1String(\"string\")) == 0)\r\n    {\r\n        return true;\r\n    }\r\n\r\n    if (value.contains(QLatin1Char('{')))\r\n    {\r\n        return isArrayValidForType(value, type);\r\n    }\r\n\r\n    bool isValidValue = false;\r\n    QString solvedValue = expressionParser_->parseExpression(value, &isValidValue);\r\n\r\n    bool canConvert = false;\r\n    if (type == QLatin1String(\"bit\"))\r\n    {\r\n        solvedValue.toInt(&canConvert);\r\n        if (canConvert)\r\n        {\r\n            ValueFormatter formatter;\r\n            solvedValue = formatter.format(solvedValue, 2);\r\n\r\n            QRegularExpression bitExpression(QStringLiteral(\"^([01]|[1-9]?[0-9]*'([bB][01_]+|[hH][0-9a-fA-F_]+))$\"));\r\n            return bitExpression.match(value).hasMatch() || bitExpression.match(solvedValue).hasMatch();\r\n        }\r\n    }\r\n    else if (type == QLatin1String(\"byte\"))\r\n    {\r\n        solvedValue.toShort(&canConvert);\r\n        return canConvert && -128 <= solvedValue.toShort() && solvedValue.toShort() <= 127;\r\n    }\r\n    else if (type == QLatin1String(\"shortint\"))\r\n    {\r\n        solvedValue.toShort(&canConvert);\r\n    }\r\n    else if (type == QLatin1String(\"int\"))\r\n    {\r\n        solvedValue.toInt(&canConvert);\r\n    }\r\n    else if (type == QLatin1String(\"longint\"))\r\n    {\r\n        if (solvedValue.startsWith(QStringLiteral(\"-\")))\r\n        {\r\n            solvedValue.toLongLong(&canConvert);\r\n        }\r\n        else\r\n        {\r\n            solvedValue.toULongLong(&canConvert);\r\n        }\r\n    }\r\n    else if (type == QLatin1String(\"shortreal\"))\r\n    {\r\n        solvedValue.toFloat(&canConvert);\r\n    }\r\n    else if (type == QLatin1String(\"real\"))\r\n    {\r\n        solvedValue.toDouble(&canConvert);\r\n    }\r\n    else if (type == QLatin1String(\"string\"))\r\n    {\r\n        QRegularExpression stringExpression(QStringLiteral(\"^\\\\s*\\\".*\\\"\\\\s*$\"));\r\n        return stringExpression.match(solvedValue).hasMatch();\r\n    }\r\n\r\n    return canConvert;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ParameterValidator::isArrayValidForType()\r\n//-----------------------------------------------------------------------------\r\nbool ParameterValidator::isArrayValidForType(QString const& arrayExpression, QString const& type) const\r\n{\r\n    QStringList subValues = splitArrayToList(arrayExpression);\r\n\r\n    if (arrayValuesAreSameSize(subValues, type))\r\n    {\r\n        for (QString const& innerValue : subValues)\r\n        {\r\n            if (!hasValidValueForType(innerValue, type))\r\n            {\r\n                return false;\r\n            }\r\n        }\r\n        return true;\r\n    }\r\n\r\n    return false;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ParameterValidator::hasValidVector()\r\n//-----------------------------------------------------------------------------\r\nbool ParameterValidator::hasValidVector(QSharedPointer<const Parameter> parameter) const\r\n{\r\n    if ((!parameter->getVectors()->isEmpty() && parameter->getType() != QLatin1String(\"bit\")) ||\r\n        !validateArrayValues(parameter->getVectorLeft(), parameter->getVectorRight()))\r\n    {\r\n        return false;\r\n    }\r\n\r\n    if (docRevision_ != Document::Revision::Std22 && vectorIdExists(parameter))\r\n    {\r\n        return false;\r\n    }\r\n\r\n    return true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ParameterValidator::vectorIdExists()\r\n//-----------------------------------------------------------------------------\r\nbool ParameterValidator::vectorIdExists(QSharedPointer<const Parameter> parameter) const\r\n{\r\n    auto vectors = parameter->getVectors();\r\n    return std::any_of(vectors->cbegin(), vectors->cend(), [](auto vector)\r\n        {\r\n            return !vector->getId().isEmpty();\r\n        });\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ParameterValidator::hasValidValueForType()\r\n//-----------------------------------------------------------------------------\r\nbool ParameterValidator::hasValidValueForType(QSharedPointer<const Parameter> parameter) const\r\n{\r\n    return hasValidValueForType(parameter->getValue(), parameter->getType());\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ParameterValidator::hasValidMinimumValue()\r\n//-----------------------------------------------------------------------------\r\nbool ParameterValidator::hasValidMinimumValue(QSharedPointer<const Parameter> parameter) const\r\n{\r\n    QString minimumValue = parameter->getMinimumValue();\r\n\r\n    if (!shouldCompareValueAndBoundary(minimumValue, parameter->getType()))\r\n    {\r\n        return true;\r\n    }\r\n\r\n    return hasValidValueForType(minimumValue, parameter->getType());\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ParameterValidator::hasValidMaximumValue()\r\n//-----------------------------------------------------------------------------\r\nbool ParameterValidator::hasValidMaximumValue(QSharedPointer<const Parameter> parameter) const\r\n{\r\n    QString maximumValue = parameter->getMaximumValue();\r\n\r\n    if (!shouldCompareValueAndBoundary(maximumValue, parameter->getType()))\r\n    {\r\n        return true;\r\n    }\r\n\r\n    return hasValidValueForType(maximumValue, parameter->getType());\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ParameterValidator::hasValidChoice()\r\n//-----------------------------------------------------------------------------\r\nbool ParameterValidator::hasValidChoice(QSharedPointer<const Parameter> parameter) const\r\n{\r\n    return parameter->getChoiceRef().isEmpty() || findChoiceByName(parameter->getChoiceRef());\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ParameterValidator::hasValidValueForChoice()\r\n//-----------------------------------------------------------------------------\r\nbool ParameterValidator::hasValidValueForChoice(QSharedPointer<const Parameter> parameter) const\r\n{\r\n    if (parameter->getChoiceRef().isEmpty())\r\n    {\r\n        return true;\r\n    }\r\n\r\n    QSharedPointer<Choice> referencedChoice = findChoiceByName(parameter->getChoiceRef());\r\n\r\n    if (!referencedChoice.isNull() && parameter->getValue().contains(QLatin1Char('{')) &&\r\n        parameter->getValue().contains(QLatin1Char('}')))\r\n    {\r\n        QStringList valueArray = parameter->getValue().split(QLatin1Char(','));\r\n        valueArray.first().remove(QLatin1Char('{'));\r\n        valueArray.last().remove(QLatin1Char('}'));\r\n\r\n        for (QString const& parameterValue : valueArray)\r\n        {\r\n            if (!referencedChoice->hasEnumeration(parameterValue))\r\n            {\r\n                return false;\r\n            }\r\n        }\r\n        return true;\r\n    }\r\n    \r\n    return !referencedChoice.isNull() && \r\n        referencedChoice->hasEnumeration(expressionParser_->parseExpression(parameter->getValue()));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ParameterValidator::hasValidResolve()\r\n//-----------------------------------------------------------------------------\r\nbool ParameterValidator::hasValidResolve(QSharedPointer<const Parameter> parameter) const\r\n{\r\n    QString resolve = parameter->getValueResolve();\r\n\r\n    return resolve.isEmpty() || resolve == QLatin1String(\"immediate\") || resolve == QLatin1String(\"user\") ||\r\n        resolve == QLatin1String(\"generated\");\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ParameterValidator::hasValidValueId()\r\n//-----------------------------------------------------------------------------\r\nbool ParameterValidator::hasValidValueId(QSharedPointer<const Parameter> parameter) const\r\n{\r\n    QString resolve = parameter->getValueResolve();\r\n\r\n    if (resolve == QLatin1String(\"user\") || resolve == QLatin1String(\"generated\"))\r\n    {\r\n        return !parameter->getValueId().isEmpty();\r\n    }\r\n\r\n    return true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ParameterValidator::valueIsLessThanMinimum()\r\n//-----------------------------------------------------------------------------\r\nbool ParameterValidator::valueIsLessThanMinimum(QSharedPointer<const Parameter> parameter) const\r\n{\r\n    QString type = parameter->getType();\r\n    QString value = expressionParser_->parseExpression(parameter->getValue());\r\n\r\n    return valueIsLessThanMinimum(parameter, value, type);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ParameterValidator::valueIsGreaterThanMaximum()\r\n//-----------------------------------------------------------------------------\r\nbool ParameterValidator::valueIsGreaterThanMaximum(QSharedPointer<const Parameter> parameter) const\r\n{\r\n    QString type = parameter->getType();\r\n    QString value = expressionParser_->parseExpression(parameter->getValue());\r\n\r\n    return valueIsGreaterThanMaximum(parameter, value, type);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ParameterValidator::findErrorsIn()\r\n//-----------------------------------------------------------------------------\r\nvoid ParameterValidator::findErrorsIn(QVector<QString>& errors, QSharedPointer<Parameter> parameter,\r\n    QString const& context) const\r\n{\r\n    findErrorsInName(errors, parameter, context);\r\n    findErrorsInValue(errors, parameter, context);\r\n    findErrorsInType(errors, parameter, context);\r\n    findErrorsInMinimumValue(errors, parameter, context);\r\n    findErrorsInMaximumValue(errors, parameter, context);\r\n    findErrorsInChoice(errors, parameter, context);\r\n    findErrorsInResolve(errors, parameter, context);\r\n    findErrorsInValueId(errors, parameter, context);\r\n    findErrorsInVector(errors, parameter, context);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ParameterValidator::shouldCompareValueAndBoundary()\r\n//-----------------------------------------------------------------------------\r\nbool ParameterValidator::shouldCompareValueAndBoundary(QString const& boundaryValue, QString const& type) const\r\n{\r\n    if (boundaryValue.isEmpty() || type.isEmpty())\r\n    {\r\n        return false;\r\n    }\r\n\r\n    bool isValidBoundary = false;\r\n    expressionParser_->parseExpression(boundaryValue, &isValidBoundary);\r\n    return isValidBoundary && type != QLatin1String(\"bit\") && type != QLatin1String(\"string\");\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ParameterValidator::valueOf()\r\n//-----------------------------------------------------------------------------\r\nqreal ParameterValidator::valueOf(QString const& value, QString const& type) const\r\n{\r\n    if (type == QLatin1String(\"real\") || type == QLatin1String(\"shortreal\"))\r\n    {\r\n        return value.toDouble();\r\n    }\r\n    else\r\n    {\r\n        return value.toLongLong();\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ParameterValidator::findErrorsInName()\r\n//-----------------------------------------------------------------------------\r\nvoid ParameterValidator::findErrorsInName(QVector<QString>& errors, QSharedPointer<Parameter> parameter,\r\n    QString const& context) const\r\n{\r\n    if (!hasValidName(parameter))\r\n    {\r\n        errors.append(QObject::tr(\"No valid name specified for %1 %2 within %3\").arg(parameter->elementName(),\r\n            parameter->name(), context));\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ParameterValidator::findErrorsInType()\r\n//-----------------------------------------------------------------------------\r\nvoid ParameterValidator::findErrorsInType(QVector<QString>& errors, QSharedPointer<Parameter> parameter,\r\n    QString const& context) const\r\n{\r\n    if (!hasValidType(parameter))\r\n    {\r\n        errors.append(QObject::tr(\"Invalid type %1 specified for %2 %3 within %4\").arg(\r\n            parameter->getType(), parameter->elementName(), parameter->name(), context));\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ParameterValidator::findErrorsInValue()\r\n//-----------------------------------------------------------------------------\r\nvoid ParameterValidator::findErrorsInValue(QVector<QString>& errors, QSharedPointer<Parameter> parameter,\r\n    QString const& context) const\r\n{\r\n    if (parameter->getValue().isEmpty())\r\n    {\r\n        errors.append(QObject::tr(\"No value specified for %1 %2 within %3\").arg(parameter->elementName(),\r\n            parameter->name(), context));\r\n        return;\r\n    }\r\n\r\n    QString solvedValue = expressionParser_->parseExpression(parameter->getValue());\r\n    QString parameterType = parameter->getType();\r\n\r\n    if (!hasValidValueForType(solvedValue, parameterType))\r\n    {\r\n        errors.append(QObject::tr(\"Value '%1' is not valid for type %2 in %3 %4 within %5\").arg(\r\n            parameter->getValue(), parameter->getType(), parameter->elementName(), parameter->name(), context));\r\n    }\r\n\r\n    if (valueIsLessThanMinimum(parameter, solvedValue, parameterType))\r\n    {\r\n        errors.append(QObject::tr(\"Value '%1' violates minimum value %2 in %3 %4 within %5\").arg(\r\n            parameter->getValue(), parameter->getMinimumValue(), parameter->elementName(), parameter->name(),\r\n            context));\r\n    }\r\n\r\n    if (valueIsGreaterThanMaximum(parameter, solvedValue, parameterType))\r\n    {\r\n        errors.append(QObject::tr(\"Value '%1' violates maximum value %2 in %3 %4 within %5\").arg(\r\n            parameter->getValue(), parameter->getMaximumValue(), parameter->elementName(), parameter->name(), \r\n            context));\r\n    }\r\n\r\n    if (!hasValidValueForChoice(parameter))\r\n    {           \r\n        errors.append(QObject::tr(\"Value '%1' references unknown enumeration for choice %2 in %3 %4 within %5\").arg(\r\n            parameter->getValue(), parameter->getChoiceRef(), parameter->elementName(), parameter->name(), context));\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ParameterValidator::findErrorsInMinimumValue()\r\n//-----------------------------------------------------------------------------\r\nvoid ParameterValidator::findErrorsInMinimumValue(QVector<QString>& errors, QSharedPointer<Parameter> parameter,\r\n    QString const& context) const\r\n{\r\n    if (shouldCompareValueAndBoundary(parameter->getValueAttribute(QStringLiteral(\"ipxact:minimum\")),\r\n        parameter->getType())\r\n        && !hasValidValueForType(parameter->getValueAttribute(QStringLiteral(\"ipxact:minimum\")), parameter->getType()))\r\n    {\r\n        errors.append(QObject::tr(\"Minimum value %1 is not valid for format %2 in %3 %4 within %5\").arg(\r\n            parameter->getValueAttribute(QStringLiteral(\"ipxact:minimum\")), \r\n            parameter->getValueAttribute(QStringLiteral(\"ipxact:format\")),\r\n            parameter->elementName(), parameter->name(), context));\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ParameterValidator::findErrorsInMaximumValue()\r\n//-----------------------------------------------------------------------------\r\nvoid ParameterValidator::findErrorsInMaximumValue(QVector<QString>& errors, QSharedPointer<Parameter> parameter,\r\n    QString const& context) const\r\n{\r\n    if (shouldCompareValueAndBoundary(parameter->getValueAttribute(QStringLiteral(\"ipxact:maximum\")),\r\n        parameter->getType())\r\n        && !hasValidValueForType(parameter->getValueAttribute(QStringLiteral(\"ipxact:maximum\")), parameter->getType()))\r\n    {\r\n        errors.append(QObject::tr(\"Maximum value %1 is not valid for format %2 in %3 %4 within %5\").arg(\r\n            parameter->getValueAttribute(QStringLiteral(\"ipxact:maximum\")),\r\n            parameter->getValueAttribute(QStringLiteral(\"ipxact:format\")),\r\n            parameter->elementName(), parameter->name(), context));\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ParameterValidator::findErrorsInChoice()\r\n//-----------------------------------------------------------------------------\r\nvoid ParameterValidator::findErrorsInChoice(QVector<QString>& errors, QSharedPointer<Parameter> parameter,\r\n    QString const& context) const\r\n{\r\n    if (!hasValidChoice(parameter))\r\n    { \r\n        errors.append(QObject::tr(\"Choice %1 referenced in %2 %3 is not specified within %4\").arg(\r\n            parameter->getChoiceRef(), parameter->elementName(), parameter->name(), context));\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ParameterValidator::findErrorsInResolve()\r\n//-----------------------------------------------------------------------------\r\nvoid ParameterValidator::findErrorsInResolve(QVector<QString>& errors, QSharedPointer<Parameter> parameter,\r\n    QString const& context) const\r\n{\r\n    if (!hasValidResolve(parameter))\r\n    { \r\n        errors.append(QObject::tr(\"Invalid resolve %1 specified for %2 %3 within %4\").arg(\r\n            parameter->getValueResolve(), parameter->elementName(), parameter->name(), context));\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ParameterValidator::findErrorsInValueId()\r\n//-----------------------------------------------------------------------------\r\nvoid ParameterValidator::findErrorsInValueId(QVector<QString>& errors, QSharedPointer<Parameter> parameter,\r\n    QString const& context) const\r\n{\r\n    if (!hasValidValueId(parameter))\r\n    {\r\n        errors.append(QObject::tr(\"No identifier specified for %1 %2 with resolve %3 within %4\").arg(\r\n            parameter->elementName(), parameter->name(), parameter->getValueResolve(), context));\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ParameterValidator::findErrorsInVector()\r\n//-----------------------------------------------------------------------------\r\nvoid ParameterValidator::findErrorsInVector(QVector<QString>& errors, QSharedPointer<Parameter> parameter,\r\n    QString const& context) const\r\n{\r\n    if ((!parameter->getVectors()->isEmpty() && parameter->getType() != QLatin1String(\"bit\")) ||\r\n        !validateArrayValues(parameter->getVectorLeft(), parameter->getVectorRight()))\r\n    {\r\n        errors.append(QObject::tr(\"Invalid bit vector values specified for %1 %2 within %3\").arg(\r\n            parameter->elementName(), parameter->name(), context));\r\n    }\r\n\r\n    if (docRevision_ != Document::Revision::Std22 && vectorIdExists(parameter))\r\n    {\r\n        errors.append(QObject::tr(\"Vector ID specified for %1 %2 within %3 not using IP-XACT standard\"\r\n            \" revision 2022\").arg(parameter->elementName(), parameter->name(), context));\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ParameterValidator::valueIsLessThanMinimum()\r\n//-----------------------------------------------------------------------------\r\nbool ParameterValidator::valueIsLessThanMinimum(QSharedPointer<const Parameter> parameter,\r\n    QString const& solvedValue, QString const& type) const\r\n{\r\n    QString minimum = parameter->getMinimumValue();\r\n    if (type != QLatin1String(\"bit\") && type != QLatin1String(\"string\") && !type.isEmpty())\r\n    {\r\n        QStringList subValues = splitArrayToList(solvedValue);\r\n\r\n        for (QString const& innerValue : subValues)\r\n        {\r\n            if (shouldCompareValueAndBoundary(minimum, type) && valueOf(innerValue, type) < valueOf(minimum, type))\r\n            {\r\n                return true;\r\n            }\r\n        }\r\n\r\n        return false;\r\n    }\r\n\r\n    return shouldCompareValueAndBoundary(minimum, type) && valueOf(solvedValue, type) < valueOf(minimum, type);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ParameterValidator::valueIsGreaterThanMaximum()\r\n//-----------------------------------------------------------------------------\r\nbool ParameterValidator::valueIsGreaterThanMaximum(QSharedPointer<const Parameter> parameter,\r\n    QString const& solvedValue, QString const& type) const\r\n{\r\n    QString maximum = parameter->getMaximumValue();\r\n\r\n    if (type != QLatin1String(\"bit\") && type != QLatin1String(\"string\") && !type.isEmpty())\r\n    {\r\n        QStringList subValues = splitArrayToList(solvedValue);\r\n\r\n        for (QString const& innerValue : subValues)\r\n        {\r\n            if (shouldCompareValueAndBoundary(maximum, type) && valueOf(innerValue, type) > valueOf(maximum, type))\r\n            {\r\n                return true;\r\n            }\r\n        }\r\n\r\n        return false;\r\n    }\r\n\r\n    return shouldCompareValueAndBoundary(maximum, type) && valueOf(solvedValue, type) > valueOf(maximum, type);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ParameterValidator::splitArrayToList()\r\n//-----------------------------------------------------------------------------\r\nQStringList ParameterValidator::splitArrayToList(QString const& arrayValue) const\r\n{\r\n    QStringList subValues = arrayValue.split(QLatin1Char(','));\r\n    QRegularExpression startExpression (QStringLiteral(\"^'?{\"));\r\n    QRegularExpression endExpression(QStringLiteral(\"}\\\\s*$\"));\r\n\r\n    subValues.first().remove(startExpression);\r\n    subValues.last().remove(endExpression);\r\n\r\n    return subValues;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ParameterValidator::arrayValuesAreSameSize()\r\n//-----------------------------------------------------------------------------\r\nbool ParameterValidator::arrayValuesAreSameSize(QStringList const& bitArray, QString const& type) const\r\n{\r\n    if (type == QLatin1String(\"bit\") && bitArray.size() > 1)\r\n    {\r\n        ValueFormatter formatter;\r\n        QString formattedFirst = formatter.format(expressionParser_->parseExpression(bitArray.first()), 2);\r\n        int bitSize = formattedFirst.size();\r\n\r\n        for (int i = 1; i < bitArray.size(); ++i)\r\n        {\r\n            QString solvedValue = expressionParser_->parseExpression(bitArray.at(i));\r\n            QString formattedValue = formatter.format(solvedValue, 2);\r\n\r\n            if (bitSize != formattedValue.size())\r\n            {\r\n                return false;\r\n            }\r\n        }\r\n    }\r\n\r\n    return true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ParameterValidator::hasValidArrayValues()\r\n//-----------------------------------------------------------------------------\r\nbool ParameterValidator::validateArrayValues(QString const& arrayLeft, QString const& arrayRight) const\r\n{\r\n    if (arrayLeft.isEmpty() && arrayRight.isEmpty())\r\n    {\r\n        return true;\r\n    }\r\n\r\n    bool arrayLeftIsOk = true;\r\n    bool arrayRightIsOk = true;\r\n\r\n    QString leftValue = expressionParser_->parseExpression(arrayLeft);\r\n    QString rightValue = expressionParser_->parseExpression(arrayRight);\r\n    leftValue.toInt(&arrayLeftIsOk);\r\n    rightValue.toInt(&arrayRightIsOk);\r\n\r\n    return arrayLeftIsOk && arrayRightIsOk;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AbstractParameterModel::findChoiceByName()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<Choice> ParameterValidator::findChoiceByName(QString const& choiceName) const\r\n{\r\n    if (availableChoices_)\r\n    {\r\n        for (QSharedPointer<Choice> const& choice : *availableChoices_)\r\n        {\r\n            if (choice->name() == choiceName)\r\n            {\r\n                return choice;\r\n            }\r\n        }\t\r\n    }\r\n\r\n    return QSharedPointer<Choice>();\r\n}\r\n"
  },
  {
    "path": "IPXACTmodels/common/validators/ParameterValidator.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ParameterValidator.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Esko Pekkarinen\r\n// Date: 10.12.2014\r\n//\r\n// Description:\r\n// Validator for ipxact:parameter.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef SYSTEMVERILOGVALIDATOR_H\r\n#define SYSTEMVERILOGVALIDATOR_H\r\n\r\n#include <IPXACTmodels/ipxactmodels_global.h>\r\n#include <IPXACTmodels/common/Document.h>\r\n\r\n#include <QRegularExpressionValidator>\r\n#include <QString>\r\n#include <QSharedPointer>\r\n\r\nclass Parameter;\r\nclass Choice;\r\nclass ExpressionParser;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Validator for ipxact:parameter.\r\n//-----------------------------------------------------------------------------\r\nclass IPXACTMODELS_EXPORT ParameterValidator \r\n{\r\npublic:\r\n\r\n\t/*!\r\n\t *  The constructor.\r\n\t *\r\n\t *    @param [in] expressionParser    The parser to use for solving expressions.\r\n     *    @param [in] availavleChocies    The currently available choices.\r\n     *    @param [in] revision            The IP-XACT standard revision of the element being checked.\r\n\t */\r\n    ParameterValidator(QSharedPointer<ExpressionParser> expressionParser,\r\n        QSharedPointer<QList<QSharedPointer<Choice> > > availableChoices, Document::Revision docRevision);\r\n\r\n    // Disable copying.\r\n    ParameterValidator(ParameterValidator const& rhs) = delete;\r\n    ParameterValidator& operator=(ParameterValidator const& rhs) = delete;\r\n\r\n\t//! The destructor.\r\n\tvirtual ~ParameterValidator() = default;\r\n    \r\n    /*!\r\n     *  Change the available choices.\r\n     *\r\n     *    @param [in] newChoices  The new choices.\r\n     */\r\n    void componentChange(QSharedPointer<QList<QSharedPointer<Choice> > > newChoices, Document::Revision docRevision);\r\n\r\n    void setStdRevision(Document::Revision docRevision);\r\n\r\n    /*!\r\n     *  Validates the given parameter.\r\n     *\r\n     *    @param [in] parameter           The parameter to validate.\r\n     * \r\n     *    @return True, if the parameter is valid IP-XACT, otherwise false.\r\n     */\r\n    virtual bool validate(QSharedPointer<const Parameter> parameter) const;\r\n\r\n    /*!\r\n     *  Check if the parameter has a valid name.\r\n     *\r\n     *    @param [in] parameter   The parameter being checked.\r\n     */\r\n    bool hasValidName(QSharedPointer<const Parameter> parameter) const;\r\n\r\n    /*!\r\n     *  Validates the value of the given parameter.\r\n     *\r\n     *    @param [in] parameter           The parameter whose value to validate.\r\n     *\r\n     *    @return True, if the parameter value is valid, otherwise false.\r\n     */\r\n     virtual bool hasValidValue(QSharedPointer<const Parameter> parameter) const;\r\n         \r\n    /*!\r\n     *  Validates the value type of the given parameter.\r\n     *\r\n     *    @param [in] parameter   The parameter whose type to validate.\r\n     *\r\n     *    @return True, if the parameter type is valid, otherwise false.\r\n     */\r\n    virtual bool hasValidType(QSharedPointer<const Parameter> parameter) const;\r\n\r\n    /*!\r\n     *   Checks if the given value is valid for the given type.\r\n     *\r\n     *    @param [in] value   The value to validate.\r\n     *    @param [in] type    The type to which resolve the value.\r\n     *\r\n     *    @return True, if the value is valid for the given type, otherwise false.\r\n     */\r\n    virtual bool hasValidValueForType(QString const& value, QString const& type) const;\r\n\r\n    /*!\r\n     *   Checks if the value of the given parameter is valid for the given type.\r\n     *\r\n     *    @param [in] parameter   The parameter whose value to validate.\r\n     *\r\n     *    @return True, if the value is valid for the given type, otherwise false.\r\n     */\r\n    virtual bool hasValidValueForType(QSharedPointer<const Parameter> parameter) const;\r\n\r\n    /*!\r\n     *  Validates the minimum value of the given parameter.\r\n     *\r\n     *    @param [in] parameter   The parameter whose minimum value to validate.\r\n     *\r\n     *    @return True, if the minimum value is valid, otherwise false.\r\n     */\r\n    virtual bool hasValidMinimumValue(QSharedPointer<const Parameter> parameter) const;\r\n            \r\n    /*!\r\n     *  Validates the maximum value of the given parameter.\r\n     *\r\n     *    @param [in] parameter   The parameter whose maximum value to validate.\r\n     *\r\n     *    @return True, if the maximum value is valid, otherwise false.\r\n     */\r\n    virtual bool hasValidMaximumValue(QSharedPointer<const Parameter> parameter) const;\r\n         \r\n    /*!\r\n     *  Check if the parameter has a valid choice.\r\n     *\r\n     *    @param [in] parameter           The selected parameter.\r\n     *\r\n     *    @return True, if the choice is valid, otherwise false.\r\n     */\r\n    bool hasValidChoice(QSharedPointer<const Parameter> parameter) const;\r\n\r\n    /*!\r\n     *  Check if the parameter has a valid value for a choice.\r\n     *\r\n     *    @param [in] parameter           The selected parameter.\r\n     *\r\n     *    @return True if the value is valid for a choice, otherwise false.\r\n     */\r\n    bool hasValidValueForChoice(QSharedPointer<const Parameter> parameter) const;\r\n\r\n    /*!\r\n     *  Check if the parameter has a valid resolve value.\r\n     *\r\n     *    @param [in] parameter   The selected parameter.\r\n     *\r\n     *    @return True, if the parameter has a valid resolve, otherwise false.\r\n     */\r\n    bool hasValidResolve(QSharedPointer<const Parameter> parameter) const;\r\n\r\n    /*!\r\n     *  Check if the parameter has a valid ID.\r\n     *\r\n     *    @param [in] parameter   The selected parameter.\r\n     *\r\n     *    @return True, if the ID is valid, otherwise false.\r\n     */\r\n    bool hasValidValueId(QSharedPointer<const Parameter> parameter) const;\r\n\r\n    /*!\r\n     *  Checks if the value of the given parameter is less than the specified minimum value.\r\n     *\r\n     *    @param [in] parameter   The parameter whose value to compare to minimum.\r\n     *\r\n     *    @return True, if the value is less than minimum, otherwise false.\r\n     */\r\n    virtual bool valueIsLessThanMinimum(QSharedPointer<const Parameter> parameter) const;\r\n\r\n    /*!\r\n     *  Checks if the value of the given parameter is greater than the specified maximum value.\r\n     *\r\n     *    @param [in] parameter   The parameter whose value to compare to maximum.\r\n     *\r\n     *    @return True, if the value is greater than maximum, otherwise false.\r\n     */   \r\n    virtual bool valueIsGreaterThanMaximum(QSharedPointer<const Parameter> parameter) const;\r\n\r\n    /*!\r\n     *  Finds possible errors in a parameter and creates a list of them.\r\n     *\r\n     *    @param [in] errors      List of found errors.\r\n     *    @param [in] parameter   The parameter whose errors to find.\r\n     *    @param [in] context     Context to help locate the errors.\r\n     */\r\n    virtual void findErrorsIn(QVector<QString>& errors, QSharedPointer<Parameter> parameter, QString const& context)\r\n        const;\r\n\r\n    /*!\r\n     *  Check if the given array is valid.\r\n     *\r\n     *    @param [in] arrayLeft   The left value of the array.\r\n     *    @param [in] arrayRight  The right value of the array.\r\n     *\r\n     *    @return True, if the array has valid values, false otherwise.\r\n     */\r\n    bool validateArrayValues(QString const& arrayLeft, QString const& arrayRight) const;\r\n\r\n    /*!\r\n     *  Check if the given parameter vector is valid.\r\n     *\r\n     *    @param [in] parameter   The parameter being examined.\r\n     * \r\n     *    @return True, if the vector is valid, false otherwise.\r\n     */\r\n    virtual bool hasValidVector(QSharedPointer<const Parameter> parameter) const; \r\n\r\n    /*!\r\n     *\tCheck if any vector of the parameter has a vector ID.\r\n     *  \r\n     *    @param [in] parameter\tThe parameter to check.\r\n     *\t\t\r\n     * \t\t@return True, if vector id is set, otherwise false.\r\n     */\r\n    bool vectorIdExists(QSharedPointer<const Parameter> parameter) const;\r\n\r\nprotected:\r\n             \r\n    /*!\r\n     *  Checks if the parameter value and the given boundary value, minimum or maximum, should be compared.\r\n     *\r\n     *    @param [in] boundaryValue   The boundary value.\r\n     *    @param [in] type            The type format of the parameter.\r\n     *\r\n     *    @return True, if the value and boundary should be compared, otherwise false.\r\n     */  \r\n    virtual bool shouldCompareValueAndBoundary(QString const& boundaryValue, QString const& type) const;\r\n         \r\n    /*!\r\n     *  Evaluates the value of the given value for the given format.\r\n     *\r\n     *    @param [in] value   The value to evaluate.\r\n     *    @param [in] type    The type to use for evaluation. Obsolete.\r\n     *\r\n     *    @return The evaluated value.\r\n     */    \r\n    virtual qreal valueOf(QString const& value, QString const& type) const;\r\n            \r\n    /*!\r\n     *  Finds possible errors in a parameter name.\r\n     *\r\n     *    @param [in] errors      List of found errors.\r\n     *    @param [in] parameter   The parameter whose errors to find.\r\n     *    @param [in] context     Context to help locate the errors.\r\n     */\r\n    void findErrorsInName(QVector<QString>& errors, QSharedPointer<Parameter> parameter, QString const& context)\r\n        const;\r\n\r\n    /*!\r\n     *  Finds possible errors in a parameter value.\r\n     *\r\n     *    @param [in] errors      List of found errors.\r\n     *    @param [in] parameter   The parameter whose errors to find.\r\n     *    @param [in] context     Context to help locate the errors.\r\n     */\r\n    virtual void findErrorsInValue(QVector<QString>& errors, QSharedPointer<Parameter> parameter,\r\n        QString const& context) const;\r\n          \r\n    /*!\r\n     *  Finds the errors in minimum value.\r\n     *\r\n     *    @param [in] errors      List of found errors.\r\n     *    @param [in] parameter   The parameter whose errors to find.\r\n     *    @param [in] context     Context to help locate the errors.\r\n     */\r\n    void findErrorsInMinimumValue(QVector<QString>& errors, QSharedPointer<Parameter> parameter,\r\n        QString const& context) const;\r\n\r\n    /*!\r\n     *  Finds the errors in maximum value.\r\n     *\r\n     *    @param [in] errors      List of found errors.\r\n     *    @param [in] parameter   The parameter whose errors to find.\r\n     *    @param [in] context     Context to help locate the errors.\r\n     */\r\n    void findErrorsInMaximumValue(QVector<QString>& errors, QSharedPointer<Parameter> parameter,\r\n        QString const& context) const;\r\n   \r\n    /*!\r\n     *  Finds the errors in choice value.\r\n     *\r\n     *    @param [in] errors      List of found errors\r\n     *    @param [in] parameter   The parameter whose errors to find.\r\n     *    @param [in] context     Context to help locate the errors.\r\n     */\r\n    void findErrorsInChoice(QVector<QString>& errors, QSharedPointer<Parameter> parameter, QString const& context)\r\n        const;\r\n    \r\n    /*!\r\n     *  Finds the errors in resolve value.\r\n     *\r\n     *    @param [in] errors      List of found errors.\r\n     *    @param [in] parameter   The parameter whose errors to find.\r\n     *    @param [in] context     Context to help locate the errors.\r\n     */\r\n    void findErrorsInResolve(QVector<QString>& errors, QSharedPointer<Parameter> parameter, QString const& context)\r\n        const;\r\n      \r\n    /*!\r\n     *  Finds the errors in value identifier.\r\n     *\r\n     *    @param [in] errors      List of found errors.\r\n     *    @param [in] parameter   The parameter whose errors to find.\r\n     *    @param [in] context     Context to help locate the errors.\r\n     */\r\n    void findErrorsInValueId(QVector<QString>& errors, QSharedPointer<Parameter> parameter,\r\n        QString const& context) const;\r\n\r\n    /*!\r\n     *  Finds possible errors in a parameter value type.\r\n     *\r\n     *    @param [in] errors      List of found errors.\r\n     *    @param [in] parameter   The parameter whose errors to find.\r\n     *    @param [in] context     Context to help locate the errors.\r\n     */\r\n    virtual void findErrorsInType(QVector<QString>& errors, QSharedPointer<Parameter> parameter,\r\n        QString const& context) const;\r\n\r\n    /*!\r\n     *  Check if the values in the array are valid for the given type.\r\n     *\r\n     *    @param [in] arrayExpression     The array.\r\n     *    @param [in] type                The type of the parameter.\r\n     *\r\n     *    @return True, if the contents of the array are valid for type, otherwise false.\r\n     */\r\n    bool isArrayValidForType(QString const& arrayExpression, QString const& type) const;\r\n\r\n    /*!\r\n     *  Finds possible errors in a bit vector.\r\n     *\r\n     *    @param [in] errors      List of found errors.\r\n     *    @param [in] parameter   The parameter whose errors to find.\r\n     *    @param [in] context     Context to help locate the errors.\r\n     */\r\n    void findErrorsInVector(QVector<QString>& errors, QSharedPointer<Parameter> parameter, QString const& context)\r\n        const;\r\n\r\nprivate:\r\n\r\n    /*!\r\n     *  Checks if the value of the given parameter is less than the specified minimum value.\r\n     *\r\n     *    @param [in] parameter       The parameter whose value to compare to minimum.\r\n     *    @param [in] solvedValue     The resolved parameter value.\r\n     *    @param [in] type            The parameter type.\r\n     *\r\n     *    @return True, if the value is less than minimum, otherwise false.\r\n     */\r\n    bool valueIsLessThanMinimum(QSharedPointer<const Parameter> parameter, QString const& solvedValue, \r\n        QString const& type) const;\r\n    \r\n    /*!\r\n     *  Checks if the value of the given parameter is greater than the specified maximum value.\r\n     *\r\n     *    @param [in] parameter   The parameter whose value to compare to maximum.\r\n     *    @param [in] solvedValue     The resolved parameter value.\r\n     *    @param [in] type            The parameter type.\r\n     *\r\n     *    @return True, if the value is greater than maximum, otherwise false.\r\n     */   \r\n    bool valueIsGreaterThanMaximum(QSharedPointer<const Parameter> parameter, QString const& solvedValue,\r\n        QString const& type) const;\r\n\r\n    /*!\r\n     *  Split the given array to a list.\r\n     *\r\n     *    @param [in] arrayValue  The given array.\r\n     *\r\n     *    @return The list of values in the array.\r\n     */\r\n    QStringList splitArrayToList(QString const& arrayValue) const;\r\n\r\n    /*!\r\n     *  Check if all the values in the array are of the same size.\r\n     *\r\n     *    @param [in] bitArray    The array to check.\r\n     *    @param [in] type        The given type of the array.\r\n     *\r\n     *    @return True, if the array values are of the same size, otherwise false.\r\n     */\r\n    bool arrayValuesAreSameSize(QStringList const& bitArray, QString const& type) const;\r\n\r\n    /*!\r\n     *  Finds the choice.\r\n     *\r\n     *    @param [in] choiceName  The name of the choice to be found.\r\n     */\r\n    QSharedPointer<Choice> findChoiceByName(QString const& choiceName) const;\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! The expression parser to use for solving minimum, maximum and value.\r\n    QSharedPointer<ExpressionParser> expressionParser_;\r\n\r\n    //! The available choices for a parameter.\r\n    QSharedPointer<QList<QSharedPointer<Choice> > > availableChoices_;\r\n\r\n    QRegularExpressionValidator typeValidator_;\r\n\r\n    Document::Revision docRevision_;\r\n};\r\n\r\n#endif // SYSTEMVERILOGVALIDATOR_H\r\n"
  },
  {
    "path": "IPXACTmodels/common/validators/ProtocolValidator.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// Protocol: ProtocolValidator.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Janne Virtanen\r\n// Date: 07.12.2015\r\n//\r\n// Description:\r\n// Validator for ipxact:Protocol.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"ProtocolValidator.h\"\r\n#include \"CommonItemsValidator.h\"\r\n\r\n#include <QRegularExpression>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ProtocolValidator::validateInstantiation()\r\n//-----------------------------------------------------------------------------\r\nbool ProtocolValidator::validate(QSharedPointer<Protocol> protocol) const\r\n{\r\n\tif (protocol->getProtocolType() != QLatin1String(\"tlm\") && \r\n        protocol->getProtocolType() != QLatin1String(\"custom\"))\r\n\t{\r\n\t\treturn false;\r\n\t}\r\n\r\n    if (protocol->hasPayload())\r\n    {\r\n        if (!protocol->getPayloadName().isEmpty() && !hasValidName(protocol->getPayloadName()))\r\n        {\r\n            return false;\r\n        }\r\n\r\n        if (protocol->getPayloadType() != QLatin1String(\"generic\") && \r\n            protocol->getPayloadType() != QLatin1String(\"specific\"))\r\n        {\r\n            return false;\r\n        }\r\n    }\r\n\r\n\treturn true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ProtocolValidator::findErrorsIn()\r\n//-----------------------------------------------------------------------------\r\nvoid ProtocolValidator::findErrorsIn(QVector<QString>& errors, \r\n    QSharedPointer<Protocol> protocol, QString const&) const\r\n{\r\n\tif (protocol->getProtocolType() != QLatin1String(\"tlm\") &&\r\n        protocol->getProtocolType() != QLatin1String(\"custom\"))\r\n\t{\r\n\t\terrors.append(QObject::tr(\"The transactional protocol type '%1' is invalid.\").arg(\r\n            protocol->getProtocolType()));\r\n    }\r\n\r\n    if (protocol->hasPayload())\r\n    {\r\n        if (!protocol->getPayloadName().isEmpty() && !hasValidName(protocol->getPayloadName()))\r\n        {\r\n            errors.append(QObject::tr(\"The payload name '%1' is invalid.\").arg(protocol->getPayloadName()));\r\n        }\r\n\r\n        if (protocol->getPayloadType() != QLatin1String(\"generic\") && \r\n            protocol->getPayloadType() != QLatin1String(\"specific\"))\r\n        {\r\n            errors.append(QObject::tr(\"The payload type '%1' is invalid.\").arg(protocol->getPayloadType()));\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ProtocolValidator::hasValidName()\r\n//-----------------------------------------------------------------------------\r\nbool ProtocolValidator::hasValidName(QString const& name) const\r\n{\r\n    return CommonItemsValidator::hasValidName(name);\r\n}\r\n"
  },
  {
    "path": "IPXACTmodels/common/validators/ProtocolValidator.h",
    "content": "//-----------------------------------------------------------------------------\r\n// Protocol: ProtocolValidator.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Janne Virtanen\r\n// Date: 07.12.2015\r\n//\r\n// Description:\r\n// Validator for ipxact:Protocol.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef ProtocolVALIDATOR_H\r\n#define ProtocolVALIDATOR_H\r\n\r\n#include <IPXACTmodels/ipxactmodels_global.h>\r\n\r\n#include <IPXACTmodels/common/Protocol.h>\r\n\r\n#include <QString>\r\n#include <QVector>\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Validator for ipxact:Protocol.\r\n//-----------------------------------------------------------------------------\r\nclass IPXACTMODELS_EXPORT ProtocolValidator\r\n{\r\npublic:\r\n\r\n\t/*!\r\n\t *  The constructor.\r\n\t *\r\n\t */\r\n    ProtocolValidator() = default;\r\n\r\n\t//! The destructor.\r\n\t~ProtocolValidator() = default;\r\n\r\n    // Disable copying.\r\n    ProtocolValidator(ProtocolValidator const& rhs) = delete;\r\n    ProtocolValidator& operator=(ProtocolValidator const& rhs) = delete;\r\n\r\n    /*!\r\n     *  Validates the given Protocol.\r\n     *\r\n     *    @param [in] Protocol           The Protocol to validate.\r\n     *\r\n     *    @return True, if the Protocol is valid IP-XACT, otherwise false.\r\n     */\r\n    virtual bool validate(QSharedPointer<Protocol> Protocol) const;\r\n\r\n    /*!\r\n     *  Finds possible errors in a Protocol and creates a list of them.\r\n     *\r\n     *    @param [in] errors      List of found errors.\r\n     *    @param [in] Protocol   The Protocol whose errors to find.\r\n     *    @param [in] context     Context to help locate the errors.\r\n     */\r\n    virtual void findErrorsIn(QVector<QString>& errors,\r\n\t\tQSharedPointer<Protocol> Protocol, QString const& contex) const;\r\n\r\nprivate:\r\n\r\n    /*!\r\n     *  Check if the name is valid.\r\n     *\r\n     *    @param [in] name    The name to be evaluated.\r\n     *\r\n     *    @return True, if the name is valid, otherwise false.\r\n     */\r\n\tbool hasValidName(QString const& name) const;\r\n\r\n};\r\n\r\n#endif // SYSTEMVERILOGVALIDATOR_H\r\n"
  },
  {
    "path": "IPXACTmodels/common/validators/QualifierValidator.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: QualifierValidator.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Anton Hagqvist\n// Date: 05.06.2023\n//\n// Description:\n// Validator for ipxact:qualifier.\n//-----------------------------------------------------------------------------\n\n#include \"QualifierValidator.h\"\n\n//-----------------------------------------------------------------------------\n// Function: QualifierValidator::validate()\n//-----------------------------------------------------------------------------\nbool QualifierValidator::validate(QSharedPointer<Qualifier> qualifier, Document::Revision revision)\n{\n    // Std14 qualifiers must be checked, std22 can have any combination of qualifier information types\n    if (revision != Document::Revision::Std22)\n    {\n        auto oldRevisionAllowedTypes = QList(\n            {\n                Qualifier::Type::Address,\n                Qualifier::Type::Data,\n                Qualifier::Type::Clock,\n                Qualifier::Type::Reset,\n                Qualifier::Type::Any\n            });\n\n        auto qualifierTypes = qualifier->getTypes();\n\n        for (auto const& type : qualifierTypes)\n        {\n            if (!oldRevisionAllowedTypes.contains(type))\n            {\n                return false;\n            }\n        }\n\n        if (qualifierTypes.size() > 2)\n        {\n            return false;\n        }\n\n        // Only data and address may be combined in a qualifier within an IP-XACT 2014 document\n        if (qualifierTypes.size() == 2)\n        {\n            if (!qualifierTypes.contains(Qualifier::Type::Address) &&\n                !qualifierTypes.contains(Qualifier::Type::Data))\n            {\n                return false;\n            }\n        }\n    }\n\n    return Details::hasValidAttributes(qualifier);\n}\n\n//-----------------------------------------------------------------------------\n// Function: QualifierValidator::findErrorsIn()\n//-----------------------------------------------------------------------------\nvoid QualifierValidator::findErrorsIn(QStringList& errors, QSharedPointer<Qualifier> qualifier, QString const& context,\n    Document::Revision revision)\n{\n    if (revision != Document::Revision::Std22)\n    {\n        auto revisionAllowedTypes = QList(\n            {\n                Qualifier::Type::Address,\n                Qualifier::Type::Data,\n                Qualifier::Type::Clock,\n                Qualifier::Type::Reset,\n                Qualifier::Type::Any\n            });\n\n        auto qualifierTypes = qualifier->getTypes();\n\n        for (auto const& type : qualifierTypes)\n        {\n            if (!revisionAllowedTypes.contains(type))\n            {\n                errors.append(QObject::tr(\"Qualifier in %1 contains illegal qualifier type for IP-XACT revision 2014.\").arg(context));\n            }\n        }\n\n        if (qualifierTypes.size() > 2)\n        {\n            errors.append(QObject::tr(\"Qualifier in %1 contains an illegal number of types for IP-XACT revision 2014.\").arg(context));\n        }\n\n        if (qualifierTypes.size() == 2)\n        {\n            if (!qualifierTypes.contains(Qualifier::Type::Address) &&\n                !qualifierTypes.contains(Qualifier::Type::Data))\n            {\n                errors.append(QObject::tr(\"Qualifier in %1 contains an illegal pairing of types for IP-XACT revision 2014.\").arg(context));\n            }\n        }\n    }\n\n    if (revision == Document::Revision::Std22)\n    {\n        Details::findErrorsInAttributes(errors, qualifier, context);\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: QualifierValidator::Details::hasValidAttributes()\n//-----------------------------------------------------------------------------\nbool QualifierValidator::Details::hasValidAttributes(QSharedPointer<Qualifier> qualifier)\n{\n    auto qualifierTypes = qualifier->getTypes();\n\n    QStringList validResetLevels(QStringList()\n        << QStringLiteral(\"low\")\n        << QStringLiteral(\"high\")\n        << QStringLiteral(\"\")\n    );\n\n    QStringList validFlowTypes(QStringList()\n        << QStringLiteral(\"creditReturn\")\n        << QStringLiteral(\"ready\")\n        << QStringLiteral(\"busy\")\n        << QStringLiteral(\"user\"));\n\n    if (auto const& resetLevel = qualifier->getAttribute(Qualifier::Attribute::ResetLevel);\n        !resetLevel.isEmpty())\n    {\n        if (!validResetLevels.contains(resetLevel))\n        {\n            return false;\n        }\n    }\n\n    if (auto const& clockEnableLevel = qualifier->getAttribute(Qualifier::Attribute::ClockEnableLevel);\n        !clockEnableLevel.isEmpty())\n    {\n        if (!validResetLevels.contains(clockEnableLevel))\n        {\n            return false;\n        }\n    }\n\n    if (auto const& powerEnableLevel = qualifier->getAttribute(Qualifier::Attribute::PowerEnableLevel);\n        !powerEnableLevel.isEmpty())\n    {\n        if (!powerEnableLevel.isEmpty() && !validResetLevels.contains(powerEnableLevel))\n        {\n            return false;\n        }\n    }\n\n    if (auto const& flowType = qualifier->getAttribute(Qualifier::Attribute::FlowType);\n        !flowType.isEmpty())\n    {\n        if (!validFlowTypes.contains(flowType))\n        {\n            return false;\n        }\n    }\n\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: QualifierValidator::Details::findErrorsInAttributes()\n//-----------------------------------------------------------------------------\nvoid QualifierValidator::Details::findErrorsInAttributes(QVector<QString>& errorList,\n    QSharedPointer<Qualifier> qualifier,\n    QString const& context)\n{\n    auto qualifierTypes = qualifier->getTypes();\n\n    QStringList validResetLevels(QStringList()\n        << QStringLiteral(\"low\")\n        << QStringLiteral(\"high\")\n        << QStringLiteral(\"\")\n    );\n\n    QStringList validFlowTypes(QStringList()\n        << QStringLiteral(\"creditReturn\")\n        << QStringLiteral(\"ready\")\n        << QStringLiteral(\"busy\")\n        << QStringLiteral(\"user\"));\n\n    if (auto const& resetLevel = qualifier->getAttribute(Qualifier::Attribute::ResetLevel);\n        !resetLevel.isEmpty())\n    {\n        if (!validResetLevels.contains(resetLevel))\n        {\n            errorList.append(QObject::tr(\"Qualifier isReset in %1 contains an invalid level attribute.\").arg(context));\n        }\n    }\n\n    if (auto const& clockEnableLevel = qualifier->getAttribute(Qualifier::Attribute::ClockEnableLevel);\n        !clockEnableLevel.isEmpty())\n    {\n        if (!validResetLevels.contains(clockEnableLevel))\n        {\n            errorList.append(QObject::tr(\"Qualifier isClockEn in %1 contains an invalid level attribute.\").arg(context));\n        }\n    }\n    \n    if (auto const& powerEnableLevel = qualifier->getAttribute(Qualifier::Attribute::PowerEnableLevel);\n        !powerEnableLevel.isEmpty())\n    {\n        if (!powerEnableLevel.isEmpty() && !validResetLevels.contains(powerEnableLevel))\n        {\n            errorList.append(QObject::tr(\"Qualifier isPowerEn in %1 contains an invalid level attribute.\").arg(context));\n        }\n    }\n\n    if (auto const& flowType = qualifier->getAttribute(Qualifier::Attribute::FlowType);\n        !flowType.isEmpty())\n    {\n        if (!validFlowTypes.contains(flowType))\n        {\n            errorList.append(QObject::tr(\"Qualifier isFlowType in %1 contains an invalid flowType attribute.\").arg(context));\n        }\n    }\n}\n"
  },
  {
    "path": "IPXACTmodels/common/validators/QualifierValidator.h",
    "content": "//-----------------------------------------------------------------------------\n// File: QualifierValidator.h\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Anton Hagqvist\n// Date: 05.06.2023\n//\n// Description:\n// Validator for ipxact:qualifier.\n//-----------------------------------------------------------------------------\n\n#ifndef QUALIFIERVALIDATOR_H\n#define QUALIFIERVALIDATOR_H\n\n#include <IPXACTmodels/ipxactmodels_global.h>\n#include <IPXACTmodels/common/Document.h>\n#include <IPXACTmodels/common/Qualifier.h>\n\n#include <QString>\n#include <QStringList>\n#include <QSharedPointer>\n\n//-----------------------------------------------------------------------------\n//! Validator for ipxact:qualifier.\n//-----------------------------------------------------------------------------\nnamespace QualifierValidator\n{\n    /*!\n     *  Validates the given Qualifier.\n     *\n     *    @param [in] AbstractionDefinition           The Qualifier to validate.\n     *\n     *    @return True, if the Qualifier is valid IP-XACT, otherwise false.\n     */\n    IPXACTMODELS_EXPORT bool validate(QSharedPointer<Qualifier> qualifier, Document::Revision revision);\n\n    /*!\n     *  Finds possible errors in a Qualifier and creates a list of them.\n     *\n     *    @param [in] errors      List of found errors.\n     *    @param [in] AbstractionDefinition   The AbstractionDefinition whose errors to find.\n     */\n    IPXACTMODELS_EXPORT void findErrorsIn(QStringList& errors, QSharedPointer<Qualifier> qualifier,\n        QString const& context, Document::Revision revision);\n\n    namespace Details\n    {\n\n        /*!\n         *\tValidates the attributes of a qualifier.\n         *  \n         *    @param [in] qualifier\tThe qualifier whose attributes are validated.\n         *\t\t\n         * \t\t@return True, if attributes are valid, otherwise false.\n         */\n        bool hasValidAttributes(QSharedPointer<Qualifier> qualifier);\n\n        /*!\n         *\tFinds possible errors in a Qualifier's attributes and creates a list of them.\n         *  \n         *    @param [in] errorList\tList of found errors.\n         *    @param [in] qualifier\tThe qualifier whose attributes are checked.\n         *    @param [in] context\t    The context to help locate the error.\n         */\n        void findErrorsInAttributes(QVector<QString>& errorList, QSharedPointer<Qualifier> qualifier,\n            QString const& context);\n    }\n}\n\n#endif // QUALIFIERVALIDATOR_H\n"
  },
  {
    "path": "IPXACTmodels/common/validators/TimingConstraintValidator.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// TimingConstraint: TimingConstraintValidator.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Janne Virtanen\r\n// Date: 09.12.2015\r\n//\r\n// Description:\r\n// Validator for ipxact:TimingConstraint.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"TimingConstraintValidator.h\"\r\n\r\n#include <IPXACTmodels/AbstractionDefinition/PortAbstraction.h>\r\n\r\n#include <IPXACTmodels/common/TimingConstraint.h>\r\n\r\n#include <QRegularExpression>\r\n#include <QStringList>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: TimingConstraintValidator::validateInstantiation()\r\n//-----------------------------------------------------------------------------\r\nbool TimingConstraintValidator::validate(QSharedPointer<TimingConstraint> timingConstraint,\r\n\tQSharedPointer<QList<QSharedPointer<PortAbstraction> > > ports) const\r\n{\r\n\tif (!hasValidValue(timingConstraint) || !hasValidEdge(timingConstraint))\r\n\t{\r\n\t\treturn false;\r\n\t}\r\n\r\n\t// Must refer to a logical port.\r\n\tfor (QSharedPointer<PortAbstraction> port : *ports)\r\n\t{\r\n\t\tif (port->getLogicalName() == timingConstraint->getClockName())\r\n\t\t{\r\n\t\t\treturn true;\r\n\t\t}\r\n\t}\r\n\r\n\treturn false;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: TimingConstraintValidator::findErrorsIn()\r\n//-----------------------------------------------------------------------------\r\nvoid TimingConstraintValidator::findErrorsIn(QVector<QString>& errors,\r\n\tQSharedPointer<TimingConstraint> timingConstraint, QString const& context,\r\n    QSharedPointer<QList<QSharedPointer<PortAbstraction> > > ports) const\r\n{\r\n\tif (!hasValidValue(timingConstraint))\r\n\t{\r\n\t\terrors.append(QObject::tr(\"Invalid value '%1' in timing constraint in %2.\").arg(\r\n            QString::number(timingConstraint->getValue()), context));\r\n\t}\r\n\t\t\r\n\tif (!hasValidEdge(timingConstraint))\r\n\t{\r\n\t\terrors.append(QObject::tr(\"Invalid edge type in timing constraint in %1.\").arg(context));\r\n\t}\r\n\r\n\t// Must refer to a logical port.\r\n\tfor (QSharedPointer<PortAbstraction> port : *ports)\r\n\t{\r\n\t\tif (port->getLogicalName() == timingConstraint->getClockName())\r\n\t\t{\r\n\t\t\treturn;\r\n\t\t}\r\n\t}\r\n\r\n\terrors.append(QObject::tr(\"Invalid port name '%1' referenced in timing constraint in %2.\").arg(\r\n        timingConstraint->getClockName(), context));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: TimingConstraintValidator::hasValidValue()\r\n//-----------------------------------------------------------------------------\r\nbool TimingConstraintValidator::hasValidValue(QSharedPointer<TimingConstraint> timingConstraint) const\r\n{\r\n\t// Value must be between 0 and 100.\r\n\treturn 0 < timingConstraint->getValue() && timingConstraint->getValue() < 100;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: TimingConstraintValidator::hasValidEdge()\r\n//-----------------------------------------------------------------------------\r\nbool TimingConstraintValidator::hasValidEdge(QSharedPointer<TimingConstraint> timingConstraint) const\r\n{\r\n\t// Clock edge must be rise or fall.\r\n\treturn timingConstraint->getClockEdge() == TimingConstraint::RISE ||\r\n\t\ttimingConstraint->getClockEdge() == TimingConstraint::FALL;\r\n}\r\n"
  },
  {
    "path": "IPXACTmodels/common/validators/TimingConstraintValidator.h",
    "content": "//-----------------------------------------------------------------------------\r\n// TimingConstraint: TimingConstraintValidator.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Janne Virtanen\r\n// Date: 09.12.2015\r\n//\r\n// Description:\r\n// Validator for ipxact:TimingConstraint.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef TIMINGCONSTRAINTVALIDATOR_H\r\n#define TIMINGCONSTRAINTVALIDATOR_H\r\n\r\n#include <IPXACTmodels/ipxactmodels_global.h>\r\n\r\n#include <QList>\r\n#include <QString>\r\n#include <QVector>\r\n#include <QSharedPointer>\r\n\r\nclass PortAbstraction;\r\nclass TimingConstraint;\r\n//-----------------------------------------------------------------------------\r\n//! Validator for ipxact:TimingConstraint.\r\n//-----------------------------------------------------------------------------\r\nclass IPXACTMODELS_EXPORT TimingConstraintValidator\r\n{\r\npublic:\r\n\r\n\t/*!\r\n\t *  The constructor.\r\n\t *\r\n\t */\r\n    TimingConstraintValidator() = default;\r\n\r\n\t//! The destructor.\r\n\t~TimingConstraintValidator() = default;\r\n\r\n    /*!\r\n     *  Validates the given TimingConstraint.\r\n     *\r\n\t *    @param [in] TimingConstraint    The TimingConstraint to validate.\r\n\t *    @param [in] ports               Collection ports where the constraint belongs to.\r\n     *\r\n     *    @return True, if the TimingConstraint is valid IP-XACT, otherwise false.\r\n     */\r\n    bool validate(QSharedPointer<TimingConstraint> timingConstraint,\r\n\t\tQSharedPointer<QList<QSharedPointer<PortAbstraction> > > ports) const;\r\n\r\n    /*!\r\n     *  Finds possible errors in a TimingConstraint and creates a list of them.\r\n     *\r\n     *    @param [in] errors              List of found errors.\r\n     *    @param [in] TimingConstraint    The TimingConstraint whose errors to find.\r\n\t *    @param [in] context             Context to help locate the errors.\r\n\t *    @param [in] ports               Collection ports where the constraint belongs to.\r\n     */\r\n    void findErrorsIn(QVector<QString>& errors,\r\n        QSharedPointer<TimingConstraint> timingConstraint,\r\n\t\tQString const& context, QSharedPointer<QList<QSharedPointer<PortAbstraction> > > ports) const;\r\n\r\nprivate:\r\n\r\n\t/*!\r\n\t *  Returns true, if value of parameter timingConstraint is valid.\r\n\t *\r\n\t *    @param [in] timingConstraint\tThe inspected timing constraint.\r\n\t *\r\n\t *    @return See above.\r\n\t */\r\n\tbool hasValidValue(QSharedPointer<TimingConstraint> timingConstraint) const;\r\n\r\n\t/*!\r\n\t *  Returns true, if edge of parameter timingConstraint is valid.\r\n\t *\r\n\t *    @param [in] timingConstraint\tThe inspected timing constraint.\r\n\t *\r\n\t *    @return See above.\r\n\t */\r\n\tbool hasValidEdge(QSharedPointer<TimingConstraint> timingConstraint) const;\r\n\r\n\t// Disable copying.\r\n\tTimingConstraintValidator(TimingConstraintValidator const& rhs);\r\n\tTimingConstraintValidator& operator=(TimingConstraintValidator const& rhs);\r\n};\r\n\r\n#endif // TIMINGCONSTRAINTVALIDATOR_H\r\n"
  },
  {
    "path": "IPXACTmodels/common/validators/ValueFormatter.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ValueFormatter.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Esko Pekkarinen\r\n// Date: 11.12.2014\r\n//\r\n// Description:\r\n// Formatter for numeric values.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"ValueFormatter.h\"\r\n\r\n#include <QStringBuilder>\r\n#include <QStringList>\r\n#include <QRegularExpression>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ValueFormatter::ValueFormatter()\r\n//-----------------------------------------------------------------------------\r\nValueFormatter::ValueFormatter()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ValueFormatter::format()\r\n//-----------------------------------------------------------------------------\r\nQString ValueFormatter::format(QString const& value, int base) const\r\n{\r\n    if (value.contains(QLatin1Char('{')) && value.contains(QLatin1Char('}')))\r\n    {\r\n        return formatArray(value, base);\r\n    }\r\n\r\n    else if (base == 2)\r\n    {\r\n        return QStringLiteral(\"'b\") % QString::number(value.toLongLong(), 2);\r\n    }\r\n    else if (base == 8)\r\n    {\r\n        return QStringLiteral(\"'o\") % QString::number(value.toLongLong(), 8);\r\n    }\r\n    else if (base == 16)\r\n    {\r\n        return QStringLiteral(\"'h\") % QString::number(value.toLongLong(), 16);\r\n    }\r\n    else\r\n    {\r\n        return value;\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ValueFormatter::formatArray()\r\n//-----------------------------------------------------------------------------\r\nQString ValueFormatter::formatArray(QString const& arrayValue, int& base) const\r\n{\r\n    QStringList subValues = arrayValue.split(QLatin1Char(','));\r\n\r\n    QRegularExpression arrayStart(QStringLiteral(\"^'?{\"));\r\n\r\n    subValues.first().remove(arrayStart);\r\n    subValues.last().chop(1);\r\n\r\n    QString formattedArray(QStringLiteral(\"{\"));\r\n    for (int arrayIndex = 0; arrayIndex < subValues.size(); ++arrayIndex)\r\n    {\r\n        formattedArray.append(format(subValues.at(arrayIndex), base));\r\n        if (arrayIndex < subValues.size() - 1)\r\n        {\r\n            formattedArray.append(QLatin1Char(','));\r\n        }\r\n    }\r\n    formattedArray.append(QLatin1Char('}'));\r\n\r\n    return formattedArray;\r\n}"
  },
  {
    "path": "IPXACTmodels/common/validators/ValueFormatter.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ValueFormatter.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Esko Pekkarinen\r\n// Date: 11.12.2014\r\n//\r\n// Description:\r\n// Formatter for numeric values.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef VALUEFORMATTER_H\r\n#define VALUEFORMATTER_H\r\n\r\n#include <QString>\r\n\r\n#include <IPXACTmodels/ipxactmodels_global.h>\r\n\r\nclass IPXACTMODELS_EXPORT ValueFormatter \r\n{\r\npublic:\r\n\r\n\t//! The constructor.\r\n\tValueFormatter();\r\n\r\n\t//! The destructor.\r\n\tvirtual ~ValueFormatter() = default;\r\n\r\n    /*!\r\n     *  Formats the given value.\r\n     *\r\n     *    @param [in] value   The value to format.\r\n     *    @param [in] base    The base to use in formatting.\r\n     *\r\n     *    @return The formatted value.\r\n     */\r\n    virtual QString format(QString const& value, int base) const;\r\n\r\nprivate:\r\n\r\n\t// Disable copying.\r\n\tValueFormatter(ValueFormatter const& rhs);\r\n\tValueFormatter& operator=(ValueFormatter const& rhs);\r\n\r\n    /*!\r\n     *  Format the given array.\r\n     *\r\n     *    @param [in] arrayValue  The array to be formatted.\r\n     *    @param [in] base        The base to use in formatting.\r\n     */\r\n    QString formatArray(QString const& arrayValue, int& base) const;\r\n};\r\n\r\n#endif // VALUEFORMATTER_H\r\n"
  },
  {
    "path": "IPXACTmodels/common/validators/namevalidator.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: namevalidator.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Antti Kamppi\r\n// Date: 14.02.2011\r\n//\r\n// Description:\r\n// Validator class for IP-Xact's Name-type.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"namevalidator.h\"\r\n\r\n#include <QRegularExpression>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: namevalidator::NameValidator()\r\n//-----------------------------------------------------------------------------\r\nNameValidator::NameValidator(QObject* parent):\r\nQRegularExpressionValidator(parent)\r\n{\r\n    QRegularExpression nameExpression(QStringLiteral(\"(^[a-zA-Z:_]+[a-zA-Z0-9:_.-]*$)|(^$)\"));\r\n    setRegularExpression(nameExpression);\r\n}\r\n"
  },
  {
    "path": "IPXACTmodels/common/validators/namevalidator.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: namevalidator.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Antti Kamppi\r\n// Date: 14.02.2011\r\n//\r\n// Description:\r\n// Validator class for IP-Xact's Name-type.\r\n// This validator can be used to validate user inputs where the input type \r\n// is specified to be Name-type. For example this validator does not accept\r\n// embedded whitespaces in input.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef NAMEVALIDATOR_H\r\n#define NAMEVALIDATOR_H\r\n\r\n#include <IPXACTmodels/ipxactmodels_global.h>\r\n\r\n#include <QRegularExpressionValidator>\r\n\r\n//-----------------------------------------------------------------------------\r\n//! NameValidator class.\r\n//-----------------------------------------------------------------------------\r\nclass IPXACTMODELS_EXPORT NameValidator : public QRegularExpressionValidator\r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\r\n    /*!\r\n     *  Constructor for the name validator.\r\n     *\r\n     *    @param [in] parent   Owner of this validator.\r\n     */\r\n    explicit NameValidator(QObject* parent = 0);\r\n\r\n    //! No copying\r\n    NameValidator(const NameValidator& other) = delete;\r\n\r\n    //! No assignment\r\n    NameValidator& operator=(const NameValidator& other) = delete;\r\n\r\n\t/*!\r\n\t *  Destructor for the name validator.\r\n\t */\r\n\tvirtual ~NameValidator() = default;\r\n\r\n};\r\n\r\n#endif // NAMEVALIDATOR_H\r\n"
  },
  {
    "path": "IPXACTmodels/generaldeclarations.cpp",
    "content": "/* \r\n *\r\n *  Created on: 27.7.2010\r\n *      Author: Antti Kamppi\r\n */\r\n\r\n#include \"generaldeclarations.h\"\r\n\r\n#include <IPXACTmodels/utilities/XmlUtils.h>\r\n\r\n#include <QString>\r\n#include <QDomNamedNodeMap>\r\n#include <QSharedPointer>\r\n#include <QObject>\r\n#include <QMap>\r\n#include <QTextStream>\r\n#include <QFileInfo>\r\n#include <QDir>\r\n#include <QXmlStreamWriter>\r\n#include <QXmlStreamReader>\r\n#include <qmath.h>\r\n\r\n\r\nGeneral::PortBounds::PortBounds( const QString& portName, const int left, const int right ):\r\nportName_(portName),\r\nleft_(left),\r\nright_(right)\r\n{\r\n\r\n}\r\n\r\nbool General::PortBounds::operator<( const PortBounds& other ) const\r\n{\r\n\treturn portName_ < other.portName_;\r\n}\r\n\r\nbool General::PortBounds::operator==( const PortBounds& other ) const\r\n{\r\n\treturn portName_ == other.portName_;\r\n}\r\n\r\nbool General::PortBounds::operator!=( const PortBounds& other ) const\r\n{\r\n\treturn portName_ != other.portName_;\r\n}\r\n\r\nGeneral::PortAlignment::PortAlignment():\r\nport1Left_(),\r\nport1Right_(),\r\nport2Left_(),\r\nport2Right_(),\r\ninvalidAlignment_(true)\r\n{\r\n\r\n}\r\n\r\nQString General::bool2Str(bool value)\r\n{\r\n\tif (value)\r\n    {\r\n\t\treturn QStringLiteral(\"true\");\r\n\t}\r\n\telse\r\n    {\r\n\t\treturn QStringLiteral(\"false\");\r\n\t}\r\n}\r\n\r\nGeneral::Usage General::str2Usage(QString str, General::Usage defaultValue)\r\n{\r\n\tif (str == QLatin1String(\"memory\"))\r\n    {\r\n\t\treturn General::MEMORY;\r\n\t}\r\n\telse if (str == QLatin1String(\"register\"))\r\n    {\r\n\t\treturn General::REGISTER;\r\n\t}\r\n\telse if (str ==\tQLatin1String(\"reserved\"))\r\n    {\r\n\t\treturn General::RESERVED;\r\n\t}\r\n\telse\r\n    {\r\n\t\treturn defaultValue;\r\n\t}\r\n}\r\n\r\nQString General::usage2Str(const General::Usage usage)\r\n{\r\n\tif (usage == General::MEMORY)\r\n    {\r\n\t\treturn QStringLiteral(\"memory\");\r\n\t}\r\n    else if (usage == General::REGISTER)\r\n    {\r\n\t\treturn QStringLiteral(\"register\");\r\n\t}\r\n\telse if (usage == General::RESERVED)\r\n    {\r\n\t\treturn QStringLiteral(\"reserved\");\r\n\t}\r\n    else\r\n    {\r\n        return QString();\t\r\n\t}\r\n}\r\n\r\nGeneral::DriverType General::str2DriverType(QString str, General::DriverType defaultValue)\r\n{\r\n\tif (str == QLatin1String(\"any\"))\r\n    {\r\n\t\treturn General::ANY;\r\n\t}\r\n\telse if (str == QLatin1String(\"clock\"))\r\n    {\r\n\t\treturn General::CLOCK;\r\n\t}\r\n\telse if (str == QLatin1String(\"singleShot\"))\r\n    {\r\n\t\treturn General::SINGLESHOT;\r\n\t}\r\n    else if (str == QLatin1String(\"none\"))\r\n    {\r\n        return General::NO_DRIVER;\r\n    }\r\n\telse\r\n    {\r\n\t\treturn defaultValue;\r\n\t}\r\n}\r\n\r\nQString General::driverType2Str(General::DriverType type)\r\n{\r\n    if (type == General::ANY)\r\n    {\r\n        return QStringLiteral(\"any\");\r\n    }\r\n    else if (type == General::CLOCK)\r\n    {\r\n        return QStringLiteral(\"clock\");\r\n    }\r\n    else if (type == General::SINGLESHOT)\r\n    {\r\n        return QStringLiteral(\"singleShot\");\r\n    }\r\n    else \r\n    {\r\n        return QString();\r\n    }\r\n}\r\n\r\nbool General::str2Bool(const QString str, bool defaultValue)\r\n{\r\n\tif (str == QLatin1String(\"true\"))\r\n    {\r\n\t\treturn true;\r\n\t}\r\n\telse if (str == QLatin1String(\"false\"))\r\n    {\r\n\t\treturn false;\r\n\t}\r\n\telse\r\n    {\r\n\t\treturn defaultValue;\r\n\t}\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: General::modeIsRevision2022()\r\n//-----------------------------------------------------------------------------\r\nIPXACTMODELS_EXPORT bool General::modeIsRevision2022(General::InterfaceMode mode)\r\n{\r\n    return mode == General::INITIATOR || mode == General::TARGET ||\r\n        mode == General::MIRRORED_INITIATOR || mode == General::MIRRORED_TARGET;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: General::str2Interfacemode()\r\n//-----------------------------------------------------------------------------\r\nGeneral::InterfaceMode General::str2Interfacemode(const QString& str, InterfaceMode defaultValue)\r\n{\r\n    if (INTERFACE_MODES.values().contains(str))\r\n    {\r\n        return General::INTERFACE_MODES.key(str);\r\n    }\r\n\r\n    return General::INTERFACE_MODES_2022.key(str, defaultValue);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: General::interfaceMode2Str()\r\n//-----------------------------------------------------------------------------\r\nQString General::interfaceMode2Str(const General::InterfaceMode mode)\r\n{\r\n    if (INTERFACE_MODES.contains(mode))\r\n    {\r\n        return General::INTERFACE_MODES.value(mode);\r\n    }\r\n\r\n    return General::INTERFACE_MODES_2022.value(mode, QStringLiteral(\"undefined\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: General::getCompatibleInterfaceMode()\r\n//-----------------------------------------------------------------------------\r\nGeneral::InterfaceMode General::getCompatibleInterfaceMode(InterfaceMode mode)\r\n{\r\n    if (mode == General::MASTER)\r\n    {\r\n        return MIRRORED_MASTER;\r\n    }\r\n    else if (mode == General::SLAVE)\r\n    {\r\n        return MIRRORED_SLAVE;\r\n    }\r\n    else if (mode == General::SYSTEM)\r\n    {\r\n        return MIRRORED_SYSTEM;\r\n    }\r\n    else if (mode == General::MIRRORED_MASTER)\r\n    {\r\n        return MASTER;\r\n    }\r\n    else if (mode == General::MIRRORED_SLAVE)\r\n    {\r\n        return SLAVE;\r\n    }\r\n    else if (mode == General::MIRRORED_SYSTEM)\r\n    {\r\n        return SYSTEM;\r\n    }\r\n    else if (mode == General::MONITOR)\r\n    {\r\n        return MONITOR;\r\n    }\r\n    else if (mode == General::INITIATOR)\r\n    {\r\n        return MIRRORED_INITIATOR;\r\n    }\r\n    else if (mode == General::TARGET)\r\n    {\r\n        return MIRRORED_TARGET;\r\n    }\r\n    else if (mode == General::MIRRORED_INITIATOR)\r\n    {\r\n        return INITIATOR;\r\n    }\r\n    else if (mode == General::MIRRORED_TARGET)\r\n    {\r\n        return TARGET;\r\n    }\r\n    else\r\n    {\r\n        return INTERFACE_MODE_COUNT;\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: generaldeclarations::getCompatibleInterfaceModeList()\r\n//-----------------------------------------------------------------------------\r\nQVector<General::InterfaceMode> General::getCompatibleInterfaceModesForActiveInterface(General::InterfaceMode mode)\r\n{\r\n    QVector<General::InterfaceMode> compatibleModes;\r\n\r\n    if (mode == General::MASTER)\r\n    {\r\n        //! Master -> slave / mirrored master\r\n        compatibleModes = { General::SLAVE, General::MIRRORED_MASTER, General::MONITOR };\r\n    }\r\n    else if (mode == General::MIRRORED_MASTER)\r\n    {\r\n        //! Mirrored Master -> Master\r\n        compatibleModes = { General::MASTER, General::MONITOR };\r\n    }\r\n    else if (mode == General::SLAVE)\r\n    {\r\n        //! Slave -> master / mirrored slave\r\n        compatibleModes = { General::MASTER, General::MIRRORED_SLAVE, General::MONITOR };\r\n    }\r\n    else if (mode == General::MIRRORED_SLAVE)\r\n    {\r\n        //! Mirrored slave -> slave\r\n        compatibleModes = { General::SLAVE, General::MONITOR };\r\n    }\r\n    else if (mode == General::SYSTEM)\r\n    {\r\n        //! System -> Mirrored system\r\n        compatibleModes = { General::MIRRORED_SYSTEM, General::MONITOR };\r\n    }\r\n    else if (mode == General::MIRRORED_SYSTEM)\r\n    {\r\n        //! Mirrored System -> System\r\n        compatibleModes = { General::SYSTEM, General::MONITOR };\r\n    }\r\n    else if (mode == General::MONITOR)\r\n    {\r\n        //! Monitor Mode -> Mode\r\n        //!     if Mode == System || MirroredSystem\r\n        //!         -> System groups match\r\n        compatibleModes = { General::MASTER, General::MIRRORED_MASTER, General::SLAVE, General::MIRRORED_SLAVE,\r\n            General::INITIATOR, General::TARGET, General::SYSTEM, General::MIRRORED_SYSTEM };\r\n    }\r\n    else if (mode == General::INITIATOR)\r\n    {\r\n        compatibleModes = { General::TARGET, General::MIRRORED_INITIATOR, General::MONITOR };\r\n    }\r\n    else if (mode == General::MIRRORED_INITIATOR)\r\n    {\r\n        compatibleModes = { General::INITIATOR, General::MONITOR };\r\n    }\r\n    else if (mode == General::TARGET)\r\n    {\r\n        compatibleModes = { General::INITIATOR, General::MIRRORED_TARGET, General::MONITOR };\r\n    }\r\n    else if (mode == General::MIRRORED_TARGET)\r\n    {\r\n        compatibleModes = { General::TARGET, General::MONITOR };\r\n    }\r\n\r\n    return compatibleModes;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: generaldeclarations::getCompatibleInterfaceModeForHierarchicalInterface()\r\n//-----------------------------------------------------------------------------\r\nQVector<General::InterfaceMode> General::getCompatibleInterfaceModeForHierarchicalInterface(\r\n    General::InterfaceMode mode)\r\n{\r\n    //! Hierarchical Interface -> Same Mode\r\n\r\n    QVector<General::InterfaceMode> compatibleModes;\r\n    compatibleModes.append(mode);\r\n    return compatibleModes;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: generaldeclarations::getRelativePath()\r\n//-----------------------------------------------------------------------------\r\nQString General::getRelativePath(QString from, QString to)  \r\n{\r\n    if (from.isEmpty() || to.isEmpty())\r\n    {\r\n        return QString();\r\n\t}\r\n\r\n\t// create file info instance to make sure that only the directory of the\r\n\t// from parameter is used\r\n\tQFileInfo fromInfo(from);\r\n\r\n    QString fromPath = fromInfo.absolutePath();\r\n\r\n    if (fromInfo.isDir())\r\n    {\r\n        fromPath = fromInfo.absoluteFilePath();\r\n    }\r\n\r\n\t// if the directory does not exist\r\n\tauto ipXactDir = QDir(fromPath);\r\n\r\n\tif (!ipXactDir.exists()) {\r\n\t\treturn QString();\r\n\t}\r\n\r\n\t// create file info instance to make sure the target file exists and to\r\n\t// use an absolute file path to calculate the relative path.\r\n\tQFileInfo toInfo(to);\r\n\tif (!toInfo.exists()) {\r\n\t\treturn QString();\r\n\t}\r\n\r\n\t// calculate the relative path and return it.\r\n\tQString relPath = ipXactDir.relativeFilePath(toInfo.absoluteFilePath());\r\n\r\n    // Strip the ending slash if found.\r\n    if (relPath.size() > 0 && relPath.at(relPath.size() - 1) == QLatin1Char('/'))\r\n    {\r\n        relPath = relPath.left(relPath.size() - 1);\r\n    }\r\n    else if (relPath.isEmpty())\r\n    {\r\n        relPath = QStringLiteral(\".\");\r\n    }\r\n\r\n    return relPath;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: generaldeclarations::getRelativeSavePath()\r\n//-----------------------------------------------------------------------------\r\nQString General::getRelativeSavePath( const QString& from, const QString& to )\r\n{\r\n\tif (from.isEmpty() || to.isEmpty())\r\n    {\r\n\t\treturn QString();\r\n\t}\r\n\r\n\t// create file info instance to make sure that only the directory of the\r\n\t// from parameter is used\r\n\tQFileInfo fromInfo(from);\r\n\r\n\tQString fromPath = fromInfo.absolutePath();\r\n\r\n\tif (fromInfo.isDir())\r\n\t{\r\n\t\tfromPath = fromInfo.absoluteFilePath();\r\n\t}\r\n\r\n\t// if the directory does not exist\r\n\tauto ipXactDir = QDir(fromPath);\r\n\r\n\tif (!ipXactDir.exists()) {\r\n\t\treturn QString();\r\n\t}\r\n\r\n\t// create file info instance to make sure the target file exists and to\r\n\t// use an absolute file path to calculate the relative path.\r\n\tQFileInfo toInfo(to);\r\n\r\n\t// calculate the relative path and return it.\r\n\treturn ipXactDir.relativeFilePath(toInfo.absoluteFilePath());\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: generaldeclarations::getAbsolutePath()\r\n//-----------------------------------------------------------------------------\r\nQString General::getAbsolutePath(const QString& originalPath, const QString& relativePath)\r\n{\r\n\tif (originalPath.isEmpty() || relativePath.isEmpty())\r\n    {\r\n\t\treturn QString();\r\n\t}\r\n\r\n\tQFileInfo relativeInfo(relativePath);\r\n\tif (relativeInfo.isAbsolute()) {\r\n\t\treturn relativePath;\r\n\t}\r\n\r\n\t// get the directory path of the original path\r\n\tQFileInfo original(originalPath);\r\n\tQDir originalDir(original.absolutePath());\r\n\r\n\t// make sure the path exists\r\n\treturn originalDir.absoluteFilePath(relativePath);\r\n}\r\n\r\nGeneral::ModifiedWrite General::str2ModifiedWrite( const QString& str )\r\n{\t\r\n\t// check all defined strings\r\n\tfor (unsigned int i = 0; i < General::MODIFIED_WRITE_COUNT; ++i)\r\n    {\t\t\t\t\r\n\t\tif (str.compare(General::MODIFIED_WRITE_STRINGS[i], Qt::CaseInsensitive) == 0)\r\n        {\r\n\t\t\treturn static_cast<General::ModifiedWrite>(i);\r\n\t\t}\r\n\t}\r\n\r\n\t// if none of the defined strings matched \r\n\treturn General::MODIFIED_WRITE_COUNT;\r\n}\r\n\r\nQString General::modifiedWrite2Str( const General::ModifiedWrite modWrite )\r\n{\r\n\treturn General::MODIFIED_WRITE_STRINGS[modWrite];\r\n}\r\n\r\nQString General::readAction2Str( const General::ReadAction readAction )\r\n{\r\n\treturn General::READ_ACTION_STRINGS[readAction];\r\n}\r\n\r\nGeneral::ReadAction General::str2ReadAction( const QString& str )\r\n{\r\n\t// check all defined strings\r\n\tfor (unsigned int i = 0; i < General::READ_ACTION_COUNT; ++i)\r\n    {\r\n\t\tif (str.compare(General::READ_ACTION_STRINGS[i], Qt::CaseInsensitive) == 0)\r\n        {\r\n\t\t\treturn static_cast<General::ReadAction>(i);\r\n\t\t}\r\n\t}\r\n\r\n\t// if none of the defined strings matched\r\n\treturn General::READ_ACTION_COUNT;\r\n}\r\n\r\nQString General::testConstraint2Str( const General::TestConstraint testConstraint )\r\n{\r\n\treturn General::TEST_CONSTRAINT_STRINGS[testConstraint];\r\n}\r\n\r\nGeneral::TestConstraint General::str2TestConstraint( const QString& str )\r\n{\r\n\t// check all defined strings\r\n\tfor (unsigned int i = 0; i < General::TESTCONSTRAINT_COUNT; ++i)\r\n    {\r\n\t\tif (str.compare(General::TEST_CONSTRAINT_STRINGS[i], Qt::CaseInsensitive) == 0)\r\n        {\r\n\t\t\treturn static_cast<General::TestConstraint>(i);\r\n\t\t}\r\n\t}\r\n\r\n\t// if none of the defined strings matched\r\n\treturn General::TESTCONSTRAINT_COUNT;\r\n}\r\n"
  },
  {
    "path": "IPXACTmodels/generaldeclarations.h",
    "content": "/*\r\n*\r\n*  Created on: 27.7.2010\r\n*      Author: Antti Kamppi\r\n*/\r\n\r\n#ifndef GENERALDECLARATIONS_H_\r\n#define GENERALDECLARATIONS_H_\r\n\r\n#include <IPXACTmodels/ipxactmodels_global.h>\r\n\r\n#include <QList>\r\n#include <QString>\r\n#include <QSharedPointer>\r\n#include <QMap>\r\n#include <QSettings>\r\n#include <QStringList>\r\n\r\n/*! Namespace General is used to store the commonly used structs and enums\r\n*\r\n* This module holds the information structures that are used by many modules\r\n* in IP-Xact parsing that are not otherwise connected to each other.\r\n*/\r\nnamespace General\r\n{\r\n    //! Describes the mode for an interface.\r\n    enum InterfaceMode {\r\n        MASTER = 0,\r\n        SLAVE,\r\n        INITIATOR,\r\n        TARGET,\r\n        SYSTEM,\r\n        MIRRORED_MASTER,\r\n        MIRRORED_SLAVE,\r\n        MIRRORED_INITIATOR,\r\n        MIRRORED_TARGET,\r\n        MIRRORED_SYSTEM,\r\n        MONITOR,\r\n        INTERFACE_MODE_COUNT\r\n    };\r\n\r\n    //! The names to display that match the enum InterfaceMode\r\n    const QMap<InterfaceMode, QString> INTERFACE_MODES\r\n    {\r\n        {MASTER,          QStringLiteral(\"master\")},\r\n        {SLAVE,           QStringLiteral(\"slave\")},\r\n        {SYSTEM,          QStringLiteral(\"system\")},\r\n        {MIRRORED_MASTER, QStringLiteral(\"mirroredMaster\")},\r\n        {MIRRORED_SLAVE,  QStringLiteral(\"mirroredSlave\")},\r\n        {MIRRORED_SYSTEM, QStringLiteral(\"mirroredSystem\")},\r\n        {MONITOR,         QStringLiteral(\"monitor\")}\r\n    };\r\n\r\n    const QMap<InterfaceMode, QString> INTERFACE_MODES_2022\r\n    {\r\n        {INITIATOR,          QStringLiteral(\"initiator\")},\r\n        {TARGET,             QStringLiteral(\"target\")},\r\n        {SYSTEM,             QStringLiteral(\"system\")},\r\n        {MIRRORED_INITIATOR, QStringLiteral(\"mirroredInitiator\")},\r\n        {MIRRORED_TARGET,    QStringLiteral(\"mirroredTarget\")},\r\n        {MIRRORED_SYSTEM,    QStringLiteral(\"mirroredSystem\")},\r\n        {MONITOR,            QStringLiteral(\"monitor\")}\r\n    };\r\n\r\n    /*!\r\n     *  Check if the selected bus interface mode is compatible with IP-XACT revision 1685-2022.\r\n     *\t\r\n     *    @param [in] mode    The selected bus interface mode.\r\n     *\r\n     *    @return True, if the mode is compatible with revision 1685-2022, false otherwise.\r\n     */\r\n    IPXACTMODELS_EXPORT bool modeIsRevision2022(General::InterfaceMode mode);\r\n\r\n    /*! Convert QString into boolean value\r\n    *\r\n    *    @param [in] str QString containing the string to be converted\r\n    *    @param [in] defaultValue InterfaceMode value that is returned if str is none of the defined values\r\n    *\r\n    *    @return InterfaceMode matching the str or default value\r\n    */\r\n    IPXACTMODELS_EXPORT InterfaceMode str2Interfacemode(const QString& str, InterfaceMode defaultValue);\r\n\r\n    /*! Convert InterfaceMode to QString\r\n    *\r\n    *    @param [in] mode InterfaceMode value that is converted to QString\r\n    *\r\n    *    @return QString that matches the enum value.\r\n    */\r\n    IPXACTMODELS_EXPORT QString interfaceMode2Str(const General::InterfaceMode mode);\r\n\r\n    /*!\r\n    *  Returns an interface mode that is compatible with the given interface mode.\r\n    */\r\n    IPXACTMODELS_EXPORT InterfaceMode getCompatibleInterfaceMode(General::InterfaceMode mode);\r\n\r\n    /*!\r\n     *  Get the compatible active bus interface modes for the selected bus interface mode.\r\n     *\r\n     *    @param [in] mode    The selected bus interface mode.\r\n     *\r\n     *    @return List of compatible bus interface modes.\r\n     */\r\n    IPXACTMODELS_EXPORT QVector<InterfaceMode> getCompatibleInterfaceModesForActiveInterface(\r\n        General::InterfaceMode mode);\r\n\r\n    /*!\r\n     *  Get the compatible hierarchical bus interface modes for the selected bus interface mode.\r\n     *\r\n     *    @param [in] mode    The selected bus interface mode.\r\n     *\r\n     *    @return The connectible bus interface modes.\r\n     */\r\n    IPXACTMODELS_EXPORT QVector<InterfaceMode> getCompatibleInterfaceModeForHierarchicalInterface(\r\n        General::InterfaceMode mode);\r\n\r\n    /*!\r\n    * Specifies the required driver type\r\n    */\r\n    enum DriverType {\r\n        ANY, \t\t// any logic signal or value\r\n        CLOCK, \t\t// repeating type waveform\r\n        SINGLESHOT,\t// non-repeating type waveform\r\n        NO_DRIVER\r\n    };\r\n\r\n    /*! Convert the value of the QString into enum DriverType\r\n    *\r\n    * if The str does not match any of the enum values the default value\r\n    * specifies as parameter will be returned\r\n    *\r\n    *    @param [in] str QString containing the string to be converted\r\n    *    @param [in] defaultValue The value that will be returned if no match is found\r\n    *    @return General::DriverType that matches the str or default value.\r\n    */\r\n    IPXACTMODELS_EXPORT General::DriverType str2DriverType(QString str, General::DriverType defaultValue);\r\n\r\n    /*! Convert the value of the DriverType into QString.\r\n    *\r\n    *    @param [in] type The DriverType to be converted.\r\n    *\r\n    *    @return QString matching the driver type.\r\n    */\r\n    IPXACTMODELS_EXPORT QString driverType2Str(General::DriverType type);\r\n\r\n    /*! Equals to ipxact:usage element within ipxact:memoryBlockData\r\n    *\r\n    * Usage specifies the type of usage for the address block to which it\r\n    * belongs\r\n    */\r\n    enum Usage {\r\n        MEMORY = 0,\r\n        REGISTER,\r\n        RESERVED,\r\n        USAGE_COUNT\r\n    };\r\n\r\n    /*! Convert the value of the QString into enum Usage\r\n    *\r\n    * if The str does not match any of the enum values the default value\r\n    * specifies as parameter will be returned\r\n    *\r\n    *    @param [in] str QString containing the string to be converted\r\n    *    @param [in] defaultValue The value that will be returned if no match is found\r\n    *    @return General::Usage that matches the str or default value.\r\n    */\r\n    IPXACTMODELS_EXPORT General::Usage str2Usage(QString str, General::Usage defaultValue);\r\n\r\n    /*! Convert the Usage value to QString\r\n    *\r\n    *    @param [in] usage Usage value to be converted to QString.\r\n    *\r\n    *    @return QString that matches the enum value.\r\n    */\r\n    IPXACTMODELS_EXPORT QString usage2Str(const General::Usage usage);\r\n\r\n    /*! Equals to ipxact:modifiedWriteValue within ipxact:fieldData.\r\n    *\r\n    * ModifiedWrite describes the manipulation of data written to a field.\r\n    */\r\n    enum ModifiedWrite {\r\n        ONE_TO_CLEAR = 0,\r\n        ONE_TO_SET,\r\n        ONE_TO_TOGGLE,\r\n        ZERO_TO_CLEAR,\r\n        ZERO_TO_SET,\r\n        ZERO_TO_TOGGLE,\r\n        CLEAR,\r\n        SET,\r\n        MODIFY,\r\n        MODIFIED_WRITE_COUNT\r\n    };\r\n\r\n    //! Contains the strings that match the enum ModifiedWrite values.\r\n    const QString MODIFIED_WRITE_STRINGS[] = {\r\n        QLatin1String(\"oneToClear\"),\r\n        QLatin1String(\"oneToSet\"),\r\n        QLatin1String(\"oneToToggle\"),\r\n        QLatin1String(\"zeroToClear\"),\r\n        QLatin1String(\"zeroToSet\"),\r\n        QLatin1String(\"zeroToToggle\"),\r\n        QLatin1String(\"clear\"),\r\n        QLatin1String(\"set\"),\r\n        QLatin1String(\"modify\"),\r\n        QLatin1String(\"\")\r\n    };\r\n\r\n    /*! Convert the value of the QString into enum ModifiedWrite.\r\n    *\r\n    * If the string does not match any of the enum values then General::MODIFIED_WRITE_COUNT\r\n    * is returned.\r\n    *\r\n    *    @param [in] str contains the string to be converted.\r\n    *\r\n    *    @return The enum value that matches the string.\r\n    */\r\n    IPXACTMODELS_EXPORT General::ModifiedWrite str2ModifiedWrite(const QString& str);\r\n\r\n    /*! Convert the enum value to a matching string.\r\n    *\r\n    *    @param [in] modWrite The enum value to be converted to a string.\r\n    *\r\n    *    @return QString that matches the enum value.\r\n    */\r\n    IPXACTMODELS_EXPORT QString modifiedWrite2Str(const General::ModifiedWrite modWrite);\r\n\r\n    /*! Equals the ipxact:readAction within ipxact:fieldData.\r\n    *\r\n    * ReadAction describes an action that happens to a field after a read operation.\r\n    */\r\n    enum ReadAction {\r\n        READ_CLEAR = 0,\r\n        READ_SET,\r\n        READ_MODIFY,\r\n        READ_ACTION_COUNT\r\n    };\r\n\r\n    //! Contains the strings that match the enum ReadAction values.\r\n    const QString READ_ACTION_STRINGS[] = {\r\n        QLatin1String(\"clear\"),\r\n        QLatin1String(\"set\"),\r\n        QLatin1String(\"modify\"),\r\n        QLatin1String(\"\")\r\n    };\r\n\r\n    /*! Convert the enum value to a matching string.\r\n    *\r\n    *    @param [in] readAction The enum value to be converted to a string.\r\n    *\r\n    *    @return QString that matches the enum value.\r\n    */\r\n    IPXACTMODELS_EXPORT QString readAction2Str(const General::ReadAction readAction);\r\n\r\n    /*! Convert the string into matching enum ReadAction value.\r\n    *\r\n    * If the string does not match any of the defined enum values then\r\n    * General::READ_ACTION_COUNT is returned.\r\n    *\r\n    *    @param [in] str Contains the string to be converted.\r\n    *\r\n    *    @return The enum value that matches the string.\r\n    */\r\n    IPXACTMODELS_EXPORT General::ReadAction str2ReadAction(const QString& str);\r\n\r\n    /*! Equals the ipxact:testConstraint attribute within ipxact:fieldData.\r\n    *\r\n    * TestConstraint defines the constraint for the field during automated testing.\r\n    */\r\n    enum TestConstraint {\r\n        TEST_UNCONSTRAINED = 0,\r\n        TEST_RESTORE,\r\n        TEST_WRITE_AS_READ,\r\n        TEST_READ_ONLY,\r\n        TESTCONSTRAINT_COUNT\r\n    };\r\n\r\n    //! Contains the strings that match the enum TestConstraint values.\r\n    const QString TEST_CONSTRAINT_STRINGS[TESTCONSTRAINT_COUNT+1] = {\r\n        QLatin1String(\"unconstrained\"),\r\n        QLatin1String(\"restore\"),\r\n        QLatin1String(\"writeAsRead\"),\r\n        QLatin1String(\"readOnly\"),\r\n        QLatin1String(\"\")\r\n    };\r\n\r\n    /*! Convert the enum value to a matching string.\r\n    *\r\n    *    @param [in] testConstraint The enum value to be converted to a string.\r\n    *\r\n    *    @return QString that matches the enum value.\r\n    */\r\n    IPXACTMODELS_EXPORT QString testConstraint2Str(const General::TestConstraint testConstraint);\r\n\r\n    /*! Convert the string into matching enum TestConstraint value.\r\n    *\r\n    * If the string does not match any of the defined enum values then\r\n    * General::TESTCONSTRAINT_COUNT is returned.\r\n    *\r\n    *    @param [in] str Contains the string to be converted.\r\n    *\r\n    *    @return The enum value that matches the string.\r\n    */\r\n    IPXACTMODELS_EXPORT General::TestConstraint str2TestConstraint(const QString& str);\r\n\r\n    /*! Used in ipxact:clockDriver element in IP-Xact specification.\r\n    *\r\n    * Used to describe elements:\r\n    * ipxact:clockPeriod\r\n    * ipxact:clockPulseOffset\r\n    * ipxact:clockPulseDuration\r\n    */\r\n\r\n    //! Specifies a port name and it's bounds.\r\n    struct IPXACTMODELS_EXPORT PortBounds {\r\n\r\n        //! The name of the port.\r\n        QString portName_;\r\n\r\n        //! The left bound of the port.\r\n        int left_;\r\n\r\n        //! The right bound of the port.\r\n        int right_;\r\n\r\n        /*! The constructor\r\n        *\r\n        *    @param [in] portName The name of the port.\r\n        *    @param [in] left     The left bound of the port.\r\n        *    @param [in] right    The right bound of the port.\r\n        *\r\n        */\r\n        PortBounds(const QString& portName, const int left = 0, const int right = 0);\r\n\r\n        //! Copy constructor\r\n        PortBounds(const PortBounds& other) = default;\r\n\r\n        //! Assignment operator\r\n        PortBounds& operator=(const PortBounds& other) = default;\r\n\r\n        //! Operator <\r\n        bool operator<(const PortBounds& other) const;\r\n\r\n        //! Operator ==\r\n        bool operator==(const PortBounds& other) const;\r\n\r\n        //! Operator !=\r\n        bool operator!=(const PortBounds& other) const;\r\n    };\r\n\r\n    //! Port alignment is used to contain the physical bounds of two ports.\r\n    struct IPXACTMODELS_EXPORT PortAlignment {\r\n\r\n        //! The calculated left bound for port 1.\r\n        QString port1Left_;\r\n\r\n        //! The calculated right bound for port 1.\r\n        QString  port1Right_;\r\n\r\n        //! The calculated left bound for port 2.\r\n        QString  port2Left_;\r\n\r\n        //! The calculated right bound for port 2.\r\n        QString  port2Right_;\r\n\r\n        //! Tells if the calculated alignment is valid or not.\r\n        bool invalidAlignment_;\r\n\r\n        /*! The default constructor\r\n        *\r\n        * Constructs the struct with all bounds valued at -1 and invalid as true.\r\n        */\r\n        PortAlignment();\r\n\r\n        //! Copy constructor\r\n        PortAlignment(const PortAlignment& other) = default;\r\n\r\n        //! Assignment operator\r\n        PortAlignment& operator=(const PortAlignment& other) = default;\r\n    };\r\n\r\n    /*! Convert a boolean value into QString\r\n    *\r\n    *    @param [in] value The variable to convert into QString\r\n    *    @return if value = true, returns \"true\"\r\n    * \t\t\tif value = false, returns \"false\"\r\n    */\r\n    IPXACTMODELS_EXPORT QString bool2Str(bool value);\r\n\r\n    /*! Convert QString into boolean value\r\n    *\r\n    *    @param [in] str QString containing the string to be converted\r\n    *    @param [in] defaultValue boolean value that is returned if str is neither\r\n    * \"true\" or \"false\"\r\n    *\r\n    *    @return if str = \"true\" returns true\r\n    * \t\t\tif str = \"false\" returns false\r\n    * \t\t\tif str is something else returns defaultValue\r\n    */\r\n    bool str2Bool(const QString str, bool defaultValue);\r\n\r\n    /*! Contains the file path for a file and the library for the file.\r\n    *\r\n    * This is used to get a file name from fileSet and the logical name for it.\r\n    */\r\n    struct LibraryFilePair {\r\n\r\n        //! Contains the file path and file name.\r\n        QString filePath_;\r\n\r\n        //! Contains the library name for the file.\r\n        QString libraryName_;\r\n\r\n        /*! The constructor for the struct\r\n        *\r\n        *    @param [in] filePath the path of the file\r\n        *    @param [in] libraryName Name of the library\r\n        */\r\n        LibraryFilePair(const QString filePath, const QString libraryName);\r\n\r\n        //! The destructor.\r\n        ~LibraryFilePair() = default;\r\n        \r\n        /*! The == operator\r\n        *\r\n        *    @param [in] other The other LibaryFilePair to check\r\n        *\r\n        *    @return bool True if they have the same file path and library name.\r\n        */\r\n        bool operator==(const LibraryFilePair& other) const;\r\n\r\n        /*! The copy constructor\r\n        *\r\n        *    @param [in] other Reference to the LibraryFilePair to copy\r\n        *\r\n        */\r\n        LibraryFilePair(const LibraryFilePair& other) = default;\r\n\r\n        /*! The assignment operator\r\n        *\r\n        *    @param [in] other Reference to the LibraryFilePair to assign\r\n        *\r\n        *    @return Reference to this LibraryFilePair.\r\n        */\r\n        LibraryFilePair& operator=(const LibraryFilePair& other) = default;\r\n    };\r\n\r\n    /*! Get a relative file path from one location to another.\r\n    *\r\n    * This function can be used to create a QString that contains the relative\r\n    * file path from a directory to a single file. If either of the parameters\r\n    * doesn't exist in the file system a null string is returned.\r\n    *\r\n    *    @param [in] from Path to the directory that is the base where the path is\r\n    * generated to.\r\n    *    @param [in] to The path to a file which is the target of the generated relative\r\n    * path.\r\n    *\r\n    *    @return QString containing the relative path.\r\n    */\r\n    IPXACTMODELS_EXPORT QString getRelativePath(QString from, QString to);\r\n\r\n    /*! Get a relative file path from one location to another.\r\n    *\r\n    * This function can be used to create a QString that contains the relative\r\n    * file path from a directory to a single file. This function can be used to get\r\n    * relative path to a file that does not exist. The source file must exist.\r\n    *\r\n    *    @param [in] from Path to the directory that is the base where the path is\r\n    * generated to.\r\n    *    @param [in] to The path to a file which is the target of the generated relative\r\n    * path.\r\n    *\r\n    *    @return QString containing the relative path.\r\n    */\r\n    IPXACTMODELS_EXPORT QString getRelativeSavePath(const QString& from, const QString& to);\r\n\r\n    /*! Get an absolute path of a file.\r\n    *\r\n    * This function takes original path and uses it as base. Then the relative\r\n    * path is used from the original path to find the correct location of a file.\r\n    * The absolute path to the file is returned. If the relative path contains a\r\n    * file but it is not found null string is returned. Original path may contain\r\n    * a file path or only a directory path but only directory path is used.\r\n    *\r\n    *    @param [in] originalPath The absolute path that is used as base for relative path\r\n    *    @param [in] relativePath The relative path that is used to find the file or\r\n    * directory.\r\n    *\r\n    *    @return The absolute path of the target directory/file\r\n    */\r\n    IPXACTMODELS_EXPORT QString getAbsolutePath(const QString& originalPath, const QString& relativePath);\r\n\r\n}\r\n\r\n#endif /* GENERALDECLARATIONS_H_ */\r\n"
  },
  {
    "path": "IPXACTmodels/ipxactmodels_global.h",
    "content": "#ifndef IPXACTMODELS_GLOBAL_H\r\n#define IPXACTMODELS_GLOBAL_H\r\n\r\n#include <QSharedPointer>\r\n#include <QList>\r\n\r\n#ifdef IPXACTMODELS_LIB\r\n# define IPXACTMODELS_EXPORT Q_DECL_EXPORT\r\n#else\r\n# define IPXACTMODELS_EXPORT Q_DECL_IMPORT\r\n#endif\r\n\r\n\r\n#endif // IPXACTMODELS_GLOBAL_H\r\n"
  },
  {
    "path": "IPXACTmodels/kactusExtensions/ApiDefinition.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ApiDefinition.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Joni-Matti Maatta\r\n// Date: 3.4.2012\r\n//\r\n// Description:\r\n// Class which encapsulates the handling of custom API definition object.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"ApiDefinition.h\"\r\n#include \"ApiFunction.h\"\r\n\r\n#include <IPXACTmodels/common/GenericVendorExtension.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ApiDefinition::ApiDefinition()\r\n//-----------------------------------------------------------------------------\r\nApiDefinition::ApiDefinition(VLNV const& vlnv, Document::Revision revision) :\r\n    Document(vlnv, revision),\r\n    language_(),\r\n    comDefRef_(),\r\n    dataTypes_(new QStringList),\r\n    functions_(new QList<QSharedPointer<ApiFunction> >)\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ApiDefinition::ApiDefinition()\r\n//-----------------------------------------------------------------------------\r\nApiDefinition::ApiDefinition(ApiDefinition const& rhs) : Document(rhs),\r\n                                                         language_(rhs.language_),\r\n                                                         comDefRef_(rhs.comDefRef_),\r\n                                                         dataTypes_(new QStringList(*rhs.dataTypes_)),\r\n                                                         functions_(new QList<QSharedPointer<ApiFunction> >)\r\n{\r\n    for (QSharedPointer<ApiFunction> func : *rhs.functions_)\r\n    {\r\n        functions_->append(QSharedPointer<ApiFunction>(new ApiFunction(*func.data())));\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ApiDefinition::~ApiDefinition()\r\n//-----------------------------------------------------------------------------\r\nApiDefinition::~ApiDefinition()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ApiDefinition::clone()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<Document> ApiDefinition::clone() const\r\n{\r\n    return QSharedPointer<Document>(new ApiDefinition(*this));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ApiDefinition::getDependentFiles()\r\n//-----------------------------------------------------------------------------\r\nQStringList ApiDefinition::getDependentFiles() const\r\n{\r\n    return QStringList();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ApiDefinition::getDependentVLNVs()\r\n//-----------------------------------------------------------------------------\r\nQList<VLNV> ApiDefinition::getDependentVLNVs() const\r\n{\r\n    QList<VLNV> vlnvs;\r\n\r\n    if (comDefRef_.isValid())\r\n    {\r\n        vlnvs.append(comDefRef_);\r\n    }\r\n\r\n    return vlnvs;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ApiDefinition::setLanguage()\r\n//-----------------------------------------------------------------------------\r\nvoid ApiDefinition::setLanguage(QString const& language)\r\n{\r\n    language_ = language;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ApiDefinition::addDataType()\r\n//-----------------------------------------------------------------------------\r\nvoid ApiDefinition::addDataType(QString const& type)\r\n{\r\n    if (!dataTypes_->contains(type))\r\n    {\r\n        dataTypes_->append(type);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ApiDefinition::removeDataType()\r\n//-----------------------------------------------------------------------------\r\nvoid ApiDefinition::removeDataType(QString const& type)\r\n{\r\n    dataTypes_->removeOne(type);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ApiDefinition::setDataTypes()\r\n//-----------------------------------------------------------------------------\r\nvoid ApiDefinition::setDataTypes(QStringList const& types)\r\n{\r\n    dataTypes_ = QSharedPointer<QStringList>( new QStringList( types ) );\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ApiDefinition::removeFunctions()\r\n//-----------------------------------------------------------------------------\r\nvoid ApiDefinition::removeFunctions()\r\n{\r\n    functions_->clear();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ApiDefinition::getLanguage()\r\n//-----------------------------------------------------------------------------\r\nQString const& ApiDefinition::getLanguage() const\r\n{\r\n    return language_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ApiDefinition::getDataTypes()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<QStringList> ApiDefinition::getDataTypes() const\r\n{\r\n    return dataTypes_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Document::getFunctions()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<QList<QSharedPointer<ApiFunction> > > ApiDefinition::getFunctions() const\r\n{\r\n\treturn functions_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ApiDefinition::setComDefinitionRef()\r\n//-----------------------------------------------------------------------------\r\nvoid ApiDefinition::setComDefinitionRef(VLNV const& vlnv)\r\n{\r\n    comDefRef_ = vlnv;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ApiDefinition::getComDefinitionRef()\r\n//-----------------------------------------------------------------------------\r\nVLNV const& ApiDefinition::getComDefinitionRef() const\r\n{\r\n    return comDefRef_;\r\n}\r\n"
  },
  {
    "path": "IPXACTmodels/kactusExtensions/ApiDefinition.h",
    "content": "////-----------------------------------------------------------------------------\r\n// File: ApiDefinition.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Joni-Matti Maatta\r\n// Date: 29.3.2012\r\n//\r\n// Description:\r\n// Class which encapsulates the handling of custom API definition object.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef APIDEFINITION_H\r\n#define APIDEFINITION_H\r\n\r\n#include <IPXACTmodels/common/Document.h>\r\n#include \"ApiFunction.h\"\r\n\r\n#include <IPXACTmodels/ipxactmodels_global.h>\r\n\r\n#include <QStringList>\r\n#include <QDomDocument>\r\n\r\nclass VLNV;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Communication definition class.\r\n//-----------------------------------------------------------------------------\r\nclass IPXACTMODELS_EXPORT ApiDefinition : public Document\r\n{\r\npublic:\r\n    /*!\r\n     *  Constructor which creates an empty API definition.\r\n     *\r\n     *    @param [in] vlnv The VLNV of the API definition.\r\n     */\r\n    ApiDefinition(VLNV const& vlnv, Document::Revision revision);\r\n\r\n    /*!\r\n     *  Copy constructor.\r\n     */\r\n    ApiDefinition(ApiDefinition const& rhs);\r\n\r\n    /*!\r\n     *  Destructor.\r\n     */\r\n    virtual ~ApiDefinition();\r\n\r\n    /*!\r\n     *  Makes a copy of the document.\r\n     *\r\n     *    @return The created copy of the API definition.\r\n     */\r\n    virtual QSharedPointer<Document> clone()  const;\r\n\r\n    /*!\r\n     *  Returns the dependent files (none).\r\n     */\r\n    virtual QStringList getDependentFiles() const;\r\n\r\n    /*!\r\n     *  Returns the dependent VLNVs (none).\r\n     */\r\n    virtual QList<VLNV> getDependentVLNVs() const;\r\n\r\n    /*!\r\n     *  Sets the API programming language.\r\n     *\r\n     *    @param [in] language The name of the programming language.\r\n     */\r\n    void setLanguage(QString const& language);\r\n\r\n    /*!\r\n     *  Sets the COM definition reference.\r\n     *\r\n     *    @param [in] vlnv The VLNV of the COM definition to reference.\r\n     */\r\n    void setComDefinitionRef(VLNV const& vlnv);\r\n\r\n    /*!\r\n     *  Adds a new data type to the API definition.\r\n     *\r\n     *    @param [in] type The name of the data type to add.\r\n     */\r\n    void addDataType(QString const& type);\r\n\r\n    /*!\r\n     *  Removes a data type from the API definition.\r\n     *\r\n     *    @param [in] type The name of the data type to remove.\r\n     */\r\n    void removeDataType(QString const& type);\r\n\r\n    /*!\r\n     *  Sets the API's data types.\r\n     *\r\n     *    @param [in] types A list of data type names.\r\n     */\r\n    void setDataTypes(QStringList const& types);\r\n\r\n    /*!\r\n     *  Removes all functions.\r\n     */\r\n    void removeFunctions();\r\n\r\n    /*!\r\n     *  Returns the API programming language.\r\n     */\r\n    QString const& getLanguage() const;\r\n\r\n    /*!\r\n     *  Returns the COM definition reference.\r\n     */\r\n    VLNV const& getComDefinitionRef() const;\r\n\r\n    /*!\r\n     *  Returns the supported data types.\r\n     */\r\n    QSharedPointer<QStringList> getDataTypes() const;\r\n\r\n    /*!\r\n     *  Get the functions of the API definition.\r\n     */\r\n    QSharedPointer<QList<QSharedPointer<ApiFunction> > > getFunctions() const;\r\n\r\n    /*!\r\n     *  Returns the function at the given index.\r\n     */\r\n    QSharedPointer<ApiFunction> getFunction(int index);\r\n\r\n    /*!\r\n     *  Returns the function at the given index.\r\n     */\r\n    QSharedPointer<ApiFunction const> getFunction(int index) const;\r\n    \r\nprivate:\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! The name of the programming language for documentation purposes.\r\n    QString language_;\r\n\r\n    //! The COM definition reference.\r\n    VLNV comDefRef_;\r\n\r\n    //! The API data types.\r\n    QSharedPointer< QStringList > dataTypes_;\r\n\r\n    //! The API functions.\r\n    QSharedPointer< QList< QSharedPointer<ApiFunction> > > functions_;\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n\r\n#endif // APIDEFINITION_H\r\n"
  },
  {
    "path": "IPXACTmodels/kactusExtensions/ApiDefinitionReader.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ApiDefinitionReader.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Janne Virtanen\r\n// Date: 28.01.2016\r\n//\r\n// Description:\r\n// XML reader class for Kactus2 API definition.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"ApiDefinitionReader.h\"\r\n\r\n#include \"ApiDefinition.h\"\r\n\r\n#include <IPXACTmodels/common/GenericVendorExtension.h>\r\n#include <IPXACTmodels/common/CommonItemsReader.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ApiDefinitionReader::createApiDefinitionFrom()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<ApiDefinition> ApiDefinitionReader::createApiDefinitionFrom(QDomNode const& document)\r\n{\r\n    QDomElement apiNode = document.firstChildElement();\r\n\tauto vlnv = DocumentReader::createVLNVFrom(apiNode, VLNV::APIDEFINITION);\r\n\r\n\tauto revision = DocumentReader::getXMLDocumentRevision(apiNode);\r\n\tif (revision == Document::Revision::Unknown)\r\n\t{\r\n\t\trevision = Document::Revision::Std22;\r\n\t}\r\n\r\n    QSharedPointer<ApiDefinition> apiDefinition(new ApiDefinition(vlnv, revision));\r\n\r\n    DocumentReader::parseTopComments(document, apiDefinition);\r\n\r\n\tDocumentReader::parseXMLProcessingInstructions(document, apiDefinition);\r\n\r\n\tDocumentReader::parseNamespaceDeclarations(apiNode, apiDefinition);\r\n\r\n    DocumentReader::parseDocumentNameGroup(apiNode, apiDefinition);\r\n\r\n\t// Parse child nodes.\r\n\tfor (int i = 0; i < apiNode.childNodes().count(); ++i)\r\n\t{\r\n\t\tQDomNode childNode = apiNode.childNodes().at(i);\r\n\r\n\t\tif (childNode.isComment())\r\n\t\t{\r\n\t\t\tcontinue;\r\n\t\t}\r\n\r\n\t\tif (childNode.nodeName() == QLatin1String(\"kactus2:language\"))\r\n\t\t{\r\n\t\t\tapiDefinition->setLanguage( childNode.childNodes().at(0).nodeValue() );\r\n\t\t}\r\n\t\telse if (childNode.nodeName() == QLatin1String(\"kactus2:comDefinitionRef\"))\r\n\t\t{\r\n\t\t\tapiDefinition->setComDefinitionRef(\r\n                CommonItemsReader::parseVLNVAttributes(childNode, VLNV::COMDEFINITION));\r\n\t\t}\r\n\t\telse if (childNode.nodeName() == QLatin1String(\"kactus2:dataTypes\"))\r\n\t\t{\r\n\t\t\tDetails::parseDataTypes(childNode, apiDefinition);\r\n\t\t}\r\n\t\telse if (childNode.nodeName() == QLatin1String(\"kactus2:functions\"))\r\n\t\t{\r\n\t\t\tDetails::parseFunctions(childNode, apiDefinition);\r\n\t\t}\r\n    }\r\n\r\n\tDocumentReader::parseKactusAndVendorExtensions(apiNode, apiDefinition);\r\n\r\n    return apiDefinition;\r\n}\r\n\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ApiDefinitionReaderReader::parseDataTypes()\r\n//-----------------------------------------------------------------------------\r\nvoid ApiDefinitionReader::Details::parseDataTypes(QDomNode& node, QSharedPointer<ApiDefinition> apiDefinition)\r\n{\r\n\tfor (int i = 0; i < node.childNodes().count(); ++i)\r\n\t{\r\n\t\tQDomNode typeNode = node.childNodes().at(i);\r\n\r\n\t\tif (typeNode.nodeName() == QLatin1String(\"kactus2:dataType\"))\r\n\t\t{\r\n\t\t\tQString name = typeNode.attributes().namedItem(QStringLiteral(\"name\")).nodeValue();\r\n\t\t\tapiDefinition->getDataTypes()->append(name);\r\n\t\t}\r\n\t}\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ApiDefinitionReader::parseFunctions()\r\n//-----------------------------------------------------------------------------\r\nvoid ApiDefinitionReader::Details::parseFunctions(QDomNode& node, QSharedPointer<ApiDefinition> apiDefinition)\r\n{\r\n\tfor (int i = 0; i < node.childNodes().count(); ++i)\r\n\t{\r\n\t\tQDomNode propNode = node.childNodes().at(i);\r\n\r\n\t\tif (propNode.nodeName() == QLatin1String(\"kactus2:function\"))\r\n\t\t{\r\n\t\t\tQSharedPointer<ApiFunction> func(new ApiFunction(propNode));\r\n\t\t\tapiDefinition->getFunctions()->append(func);\r\n\t\t}\r\n\t}\r\n}"
  },
  {
    "path": "IPXACTmodels/kactusExtensions/ApiDefinitionReader.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ApiDefinitionReader.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Janne Virtanen\r\n// Date: 28.01.2016\r\n//\r\n// Description:\r\n// XML reader class for Kactus2 API definition.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef APIDEFINITIONREADER_H\r\n#define APIDEFINITIONREADER_H\r\n\r\n#include <IPXACTmodels/common/DocumentReader.h>\r\n#include <IPXACTmodels/ipxactmodels_global.h>\r\n\r\n#include <QDomNode>\r\n#include <QSharedPointer>\r\n\r\nclass ApiDefinition;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! XML reader class for IP-XACT Parameter element.\r\n//-----------------------------------------------------------------------------\r\nnamespace ApiDefinitionReader\r\n{\r\n    /*!\r\n     *  Creates a Api definition from XML description.\r\n     *\r\n     *    @param [in] document   The XML document to create the Api definition from.\r\n     *\r\n     *    @return The created Api definition.\r\n     */\r\n    IPXACTMODELS_EXPORT QSharedPointer<ApiDefinition> createApiDefinitionFrom(QDomNode const& document);\r\n\r\n\r\n    namespace Details\r\n    {\r\n\r\n        /*!\r\n         *  Parses all found data types from the given XML node.\r\n         *\r\n         *    @param [in] node The source XML node.\r\n         */\r\n        void parseDataTypes(QDomNode& node, QSharedPointer<ApiDefinition> apiDefinition);\r\n\r\n        /*!\r\n         *  Parses all found API functions from the given XML node.\r\n         *\r\n         *    @param [in] node The source XML node.\r\n         */\r\n        void parseFunctions(QDomNode& node, QSharedPointer<ApiDefinition> apiDefinition);\r\n    }\r\n};\r\n\r\n#endif // ApiDEFINITIONREADER_H"
  },
  {
    "path": "IPXACTmodels/kactusExtensions/ApiDefinitionWriter.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ApiDefinitionWriter.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Janne Virtanen\r\n// Date: 11.12.2015\r\n//\r\n// Description:\r\n// Writer class for IP-XACT ApiDefinition element.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"ApiDefinitionWriter.h\"\r\n\r\n#include <IPXACTmodels/common/NameGroupWriter.h>\r\n\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ApiDefinitionWriter::writeApiDefinitionFrom()\r\n//-----------------------------------------------------------------------------\r\nvoid ApiDefinitionWriter::writeApiDefinition(QXmlStreamWriter& writer, QSharedPointer<ApiDefinition> apiDefinition)\r\n{\r\n    writer.writeStartDocument();\r\n    \r\n    DocumentWriter::writeTopComments(writer, apiDefinition);\r\n\r\n    writer.writeStartElement(QStringLiteral(\"kactus2:apiDefinition\"));\r\n\tDocumentWriter::writeNamespaceDeclarations(writer, apiDefinition);\r\n\r\n\tDocumentWriter::writeDocumentNameGroup(writer, apiDefinition);\r\n\r\n\t// Write COM definition reference.\r\n\tVLNV comDefRef = apiDefinition->getComDefinitionRef();\r\n\r\n\twriter.writeEmptyElement(QStringLiteral(\"kactus2:comDefinitionRef\"));\r\n\tCommonItemsWriter::writeVLNVAttributes(writer, comDefRef);\r\n\r\n\t// Write data types.\r\n\twriter.writeStartElement(QStringLiteral(\"kactus2:dataTypes\"));\r\n\r\n\tfor (QString const& type : *apiDefinition->getDataTypes())\r\n\t{\r\n\t\twriter.writeEmptyElement(QStringLiteral(\"kactus2:dataType\"));\r\n\t\twriter.writeAttribute(QStringLiteral(\"name\"), type);\r\n\t}\r\n\r\n\twriter.writeEndElement(); // kactus2:dataTypes\r\n\r\n\t// Write properties.\r\n\twriter.writeStartElement(QStringLiteral(\"kactus2:functions\"));\r\n\r\n\tfor (QSharedPointer<ApiFunction> func : *apiDefinition->getFunctions())\r\n\t{\r\n\t\tfunc->write(writer);\r\n\t}\r\n\r\n\twriter.writeEndElement(); // kactus2:functions\r\n\r\n    CommonItemsWriter::writeVendorExtensions(writer, apiDefinition);\r\n\r\n\twriter.writeEndElement(); // kactus2:apiDefinition\r\n\twriter.writeEndDocument();\r\n}\r\n"
  },
  {
    "path": "IPXACTmodels/kactusExtensions/ApiDefinitionWriter.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ApiDefinitionWriter.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Janne Virtanen\r\n// Date: 11.12.2015\r\n//\r\n// Description:\r\n// Writer class for IP-XACT ApiDefinition element.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef ApiDefinitionWriter_H\r\n#define ApiDefinitionWriter_H\r\n\r\n#include \"ApiDefinition.h\"\r\n\r\n#include <IPXACTmodels/common/DocumentWriter.h>\r\n\r\n#include <QXmlStreamWriter>\r\n#include <QSharedPointer>\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Writer class for IP-XACT ApiDefinition element.\r\n//-----------------------------------------------------------------------------\r\nnamespace ApiDefinitionWriter\r\n{\r\n\r\n    /*!\r\n     *  Write a view to an XML file.\r\n     *\r\n     *    @param [in] writer  The used xml writer.\r\n     *    @param [in] ApiDefinition\t\tThe ApiDefinition to be written.\r\n     */\r\n    IPXACTMODELS_EXPORT void writeApiDefinition(QXmlStreamWriter& writer, \r\n        QSharedPointer<ApiDefinition> apiDefinition);\r\n\r\n};\r\n\r\n#endif // ApiDefinitionWriter_H\r\n"
  },
  {
    "path": "IPXACTmodels/kactusExtensions/ApiFunction.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ApiFunction.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Joni-Matti Maatta\r\n// Date: 2.4.2012\r\n//\r\n// Description:\r\n// Class for managing one API function and its information.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"ApiFunction.h\"\r\n\r\n#include \"ApiFunctionParameter.h\"\r\n\r\n#include <QStringList>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ApiFunction::ApiFunction()\r\n//-----------------------------------------------------------------------------\r\nApiFunction::ApiFunction()\r\n    : name_(),\r\n      returnType_(QStringLiteral(\"void\")),\r\n      returnValueDesc_(),\r\n      desc_(),\r\n      params_()\r\n{\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ApiFunction::ApiFunction()\r\n//-----------------------------------------------------------------------------\r\nApiFunction::ApiFunction(ApiFunction const& rhs) : name_(rhs.name_),\r\n                                                   returnType_(rhs.returnType_),\r\n                                                   returnValueDesc_(rhs.returnValueDesc_),\r\n                                                   desc_(rhs.desc_),\r\n                                                   params_()\r\n{\r\n    for (QSharedPointer<ApiFunctionParameter> param : rhs.params_)\r\n    {\r\n        params_.append(QSharedPointer<ApiFunctionParameter>(new ApiFunctionParameter(*param)));\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ApiFunction::ApiFunction()\r\n//-----------------------------------------------------------------------------\r\nApiFunction::ApiFunction(QDomNode& node)\r\n    : name_(),\r\n      returnType_(QStringLiteral(\"void\")),\r\n      returnValueDesc_(),\r\n      desc_(),\r\n      params_()\r\n{\r\n    Q_ASSERT(node.nodeName() == QLatin1String(\"kactus2:function\"));\r\n\r\n    // Read basic information from attributes.\r\n    name_ = node.attributes().namedItem(QStringLiteral(\"name\")).nodeValue();\r\n    returnType_ = node.attributes().namedItem(QStringLiteral(\"returnType\")).nodeValue();\r\n    desc_ = node.attributes().namedItem(QStringLiteral(\"description\")).nodeValue();\r\n\r\n    // Parse return value and parameters from the child nodes.\r\n    for (int i = 0; i < node.childNodes().count(); ++i)\r\n    {\r\n        QDomNode paramNode = node.childNodes().at(i);\r\n\r\n        if (paramNode.nodeName() == QLatin1String(\"kactus2:returnValue\"))\r\n        {\r\n            returnType_ = paramNode.attributes().namedItem(QStringLiteral(\"type\")).nodeValue();\r\n            returnValueDesc_ = paramNode.attributes().namedItem(QStringLiteral(\"description\")).nodeValue();\r\n        }\r\n        if (paramNode.nodeName() == QLatin1String(\"kactus2:functionParameter\"))\r\n        {\r\n            QSharedPointer<ApiFunctionParameter> param(new ApiFunctionParameter(paramNode));\r\n            params_.append(param);\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ApiFunction::~ApiFunction()\r\n//-----------------------------------------------------------------------------\r\nApiFunction::~ApiFunction()\r\n{\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ApiFunction::write()\r\n//-----------------------------------------------------------------------------\r\nvoid ApiFunction::write(QXmlStreamWriter& writer)\r\n{\r\n    writer.writeStartElement(QStringLiteral(\"kactus2:function\"));\r\n    writer.writeAttribute(QStringLiteral(\"name\"), name_);\r\n    writer.writeAttribute(QStringLiteral(\"description\"), desc_);\r\n\r\n    writer.writeEmptyElement(QStringLiteral(\"kactus2:returnValue\"));\r\n    writer.writeAttribute(QStringLiteral(\"type\"), returnType_);\r\n    writer.writeAttribute(QStringLiteral(\"description\"), returnValueDesc_);\r\n\r\n    for (QSharedPointer<ApiFunctionParameter> param : params_)\r\n    {\r\n        param->write(writer);\r\n    }\r\n\r\n    writer.writeEndElement(); // kactus2:function\r\n}\r\n\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ApiFunction::findErrors()\r\n//-----------------------------------------------------------------------------\r\nvoid ApiFunction::findErrors(QVector<QString>& errorList, QString const& parentId) const\r\n{\r\n    QString const thisId = QObject::tr(\"API function '%1'\").arg(name_);\r\n\r\n    if (name_.isEmpty())\r\n    {\r\n        errorList.append(QObject::tr(\"No name specified for an API function in %1\").arg(parentId));\r\n    } \r\n\r\n    if (returnType_.isEmpty())\r\n    {\r\n        errorList.append(QObject::tr(\"No return value type specified for %1\").arg(thisId));\r\n    }\r\n\r\n    // Validate the function parameters.\r\n    QStringList paramNames;\r\n\r\n    for (QSharedPointer<ApiFunctionParameter> param : params_)\r\n    {\r\n        if (paramNames.contains(param->name()))\r\n        {\r\n            errorList.append(QObject::tr(\"Multiple definitions of function parameter '%1' in %2\").arg(\r\n                param->name(), thisId));\r\n        }\r\n        else\r\n        {\r\n            paramNames.append(param->name());\r\n        }\r\n\r\n        param->findErrors(errorList, thisId);     \r\n    }\r\n}\r\n\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ApiFunction::validate()\r\n//-----------------------------------------------------------------------------\r\nbool ApiFunction::validate() const\r\n{\r\n    if (name_.isEmpty() || returnType_.isEmpty())\r\n    {\r\n        return false;\r\n    }\r\n\r\n    // Validate the function parameters.\r\n    QStringList paramNames;\r\n\r\n    for (QSharedPointer<ApiFunctionParameter> param : params_)\r\n    {\r\n        if (paramNames.contains(param->name()))\r\n        {\r\n            return false;\r\n        }\r\n\r\n        paramNames.append(param->name());\r\n\r\n        if (!param->validate())\r\n        {\r\n            return false;\r\n        }\r\n    }\r\n\r\n    return true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ApiFunction::setName()\r\n//-----------------------------------------------------------------------------\r\nvoid ApiFunction::setName(QString const& name)\r\n{\r\n    name_ = name;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ApiFunction::setReturnValueType()\r\n//-----------------------------------------------------------------------------\r\nvoid ApiFunction::setReturnValueType(QString const& type)\r\n{\r\n    returnType_ = type;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ApiFunction::setReturnValueDescription()\r\n//-----------------------------------------------------------------------------\r\nvoid ApiFunction::setReturnValueDescription(QString const& desc)\r\n{\r\n    returnValueDesc_ = desc;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ApiFunction::setDescription()\r\n//-----------------------------------------------------------------------------\r\nvoid ApiFunction::setDescription(QString const& desc)\r\n{\r\n    desc_ = desc;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ApiFunction::addParam()\r\n//-----------------------------------------------------------------------------\r\nvoid ApiFunction::addParam(QSharedPointer<ApiFunctionParameter> param, int index)\r\n{\r\n    Q_ASSERT(!params_.contains(param));\r\n\r\n    if (index < 0)\r\n    {\r\n        params_.append(param);\r\n    }\r\n    else\r\n    {\r\n        params_.insert(index, param);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ApiFunction::removeParam()\r\n//-----------------------------------------------------------------------------\r\nvoid ApiFunction::removeParam(int index)\r\n{\r\n    Q_ASSERT(index >= 0 && index < params_.count());\r\n    params_.removeAt(index);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ApiFunction::name()\r\n//-----------------------------------------------------------------------------\r\nQString const& ApiFunction::name() const\r\n{\r\n    return name_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ApiFunction::getReturnValueType()\r\n//-----------------------------------------------------------------------------\r\nQString const& ApiFunction::getReturnValueType() const\r\n{\r\n    return returnType_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ApiFunction::getReturnValueDescription()\r\n//-----------------------------------------------------------------------------\r\nQString const& ApiFunction::getReturnValueDescription() const\r\n{\r\n    return returnValueDesc_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ApiFunction::getDescription()\r\n//-----------------------------------------------------------------------------\r\nQString const& ApiFunction::getDescription() const\r\n{\r\n    return desc_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ApiFunction::getParam()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<ApiFunctionParameter> ApiFunction::getParam(int index)\r\n{\r\n    Q_ASSERT(index >= 0 && index < params_.count());\r\n    return params_.at(index);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ApiFunction::getParam()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<ApiFunctionParameter const> ApiFunction::getParam(int index) const\r\n{\r\n    Q_ASSERT(index >= 0 && index < params_.count());\r\n    return params_.at(index);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ApiFunction::getParamCount()\r\n//-----------------------------------------------------------------------------\r\nint ApiFunction::getParamCount() const\r\n{\r\n    return params_.count();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ApiFunction::generateToolTipText()\r\n//-----------------------------------------------------------------------------\r\nvoid ApiFunction::generateToolTipText(int paramIndex, QString& text) const\r\n{\r\n    text.clear();\r\n\r\n    text = QStringLiteral(\"<p style='white-space:pre'>\");\r\n\r\n    // First add the return value hint and the function name.\r\n    text.append(returnType_);\r\n    text.append(QLatin1Char(' '));\r\n    text.append(name_);\r\n    text.append(QLatin1Char('('));\r\n\r\n    // Then add the function parameters.\r\n    for (int i = 0; i < params_.count(); ++i)\r\n    {\r\n        // Highlight the parameter of the given index.\r\n        if (i == paramIndex)\r\n        {\r\n            text.append(QStringLiteral(\"<b>\"));\r\n            text.append(params_.at(i)->getType());\r\n            text.append(QLatin1Char(' '));\r\n            text.append(params_.at(i)->name());\r\n            text.append(QStringLiteral(\"</b>\"));\r\n        }\r\n        else\r\n        {\r\n            text.append(params_.at(i)->getType());\r\n            text.append(QLatin1Char(' '));\r\n            text.append(params_.at(i)->name());\r\n        }\r\n\r\n        // Add comma only if this is not the last parameter.\r\n        if (i < params_.count() - 1)\r\n        {\r\n            text.append(QStringLiteral(\", \"));\r\n        }\r\n    }\r\n\r\n    text.append(QStringLiteral(\")<br>\"));\r\n    text.append(desc_);\r\n    \r\n    if (paramIndex < params_.size())\r\n    {\r\n        text.append(QStringLiteral(\"<br><b>Parameter:</b> \"));\r\n        text.append(params_.at(paramIndex)->getDescription());\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ApiFunction::operator=()\r\n//-----------------------------------------------------------------------------\r\nApiFunction& ApiFunction::operator=(ApiFunction const& rhs)\r\n{\r\n    if (&rhs != this)\r\n    {\r\n        name_ = rhs.name_;\r\n        returnType_ = rhs.returnType_;\r\n        desc_ = rhs.desc_;\r\n\r\n        params_.clear();\r\n\r\n        for (QSharedPointer<ApiFunctionParameter> param : rhs.params_)\r\n        {\r\n            params_.append(QSharedPointer<ApiFunctionParameter>(new ApiFunctionParameter(*param)));\r\n        }\r\n    }\r\n\r\n    return *this;\r\n}\r\n"
  },
  {
    "path": "IPXACTmodels/kactusExtensions/ApiFunction.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ApiFunction.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Joni-Matti Maatta\r\n// Date: 29.3.2012\r\n//\r\n// Description:\r\n// Class for managing one API function and its information.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef APIFUNCTION_H\r\n#define APIFUNCTION_H\r\n\r\n#include <IPXACTmodels/ipxactmodels_global.h>\r\n\r\n#include <QString>\r\n#include <QDomNode>\r\n#include <QSharedPointer>\r\n#include <QXmlStreamWriter>\r\n\r\nclass ApiFunctionParameter;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! API function class.\r\n//-----------------------------------------------------------------------------\r\nclass IPXACTMODELS_EXPORT ApiFunction\r\n{\r\npublic:\r\n    /*!\r\n     *  Default constructor.\r\n     */\r\n    ApiFunction();\r\n\r\n    /*!\r\n     *  Copy constructor.\r\n     */\r\n    ApiFunction(ApiFunction const& rhs);\r\n\r\n    /*!\r\n     *  Constructor which reads the function from an XML node.\r\n     *\r\n     *    @param [in] node The source XML node.\r\n     */\r\n    ApiFunction(QDomNode& node);\r\n\r\n    /*!\r\n     *  Destructor.\r\n     */\r\n    ~ApiFunction();\r\n\r\n    /*!\r\n     *  Writes the contents to an XML stream.\r\n     *\r\n     *    @param [in] writer The XML stream writer.\r\n     */\r\n    void write(QXmlStreamWriter& writer);\r\n\r\n    /*!\r\n     *  Returns true if the function contents are valid.\r\n     *\r\n     *    @param [out] errorList  The list of errors found in the contents.\r\n     *    @param [in]  parentId   The identifier of the containing API definition.\r\n     */\r\n    void findErrors(QVector<QString>& errorList, QString const& parentId) const;\r\n\r\n    /*!\r\n     *  Returns true if the function contents are valid.\r\n     */\r\n    bool validate() const;\r\n\r\n    /*!\r\n     *  Sets the name of the function.\r\n     *\r\n     *    @param [in] name The name to set.\r\n     */\r\n    void setName(QString const& name);\r\n\r\n    /*!\r\n     *  Sets the return value type.\r\n     *\r\n     *    @param [in] type The name of the return value type.\r\n     */\r\n    void setReturnValueType(QString const& type);\r\n\r\n    /*!\r\n     *  Sets the return value description.\r\n     *\r\n     *    @param [in] desc The return value description to set.\r\n     */\r\n    void setReturnValueDescription(QString const& desc);\r\n\r\n    /*!\r\n     *  Sets the function description.\r\n     *\r\n     *    @param [in] desc The description.\r\n     */\r\n    void setDescription(QString const& desc);\r\n\r\n    /*!\r\n     *  Adds a new parameter to the function.\r\n     *\r\n     *    @param [in] param  The parameter object.\r\n     *    @param [in] index  The index of the parameter. If -1, the parameter is added as the last one.\r\n     */\r\n    void addParam(QSharedPointer<ApiFunctionParameter> param, int index = -1);\r\n\r\n    /*!\r\n     *  Removes a parameter from the function.\r\n     *\r\n     *    @param [in] index The index of the parameter.\r\n     */\r\n    void removeParam(int index);\r\n\r\n    /*!\r\n     *  Returns the name of the function.\r\n     */\r\n    QString const& name() const;\r\n\r\n    /*!\r\n     *  Returns the return value type.\r\n     */\r\n    QString const& getReturnValueType() const;\r\n\r\n    /*!\r\n     *  Returns the return value description.\r\n     */\r\n    QString const& getReturnValueDescription() const;\r\n\r\n    /*!\r\n     *  Returns the function description.\r\n     */\r\n    QString const& getDescription() const;\r\n\r\n    /*!\r\n     *  Returns the parameter at the given index.\r\n     *\r\n     *    @param [in] index The parameter index.\r\n     */\r\n    QSharedPointer<ApiFunctionParameter> getParam(int index);\r\n\r\n    /*!\r\n     *  Returns the parameter at the given index.\r\n     *\r\n     *    @param [in] index The parameter index.\r\n     */\r\n    QSharedPointer<ApiFunctionParameter const> getParam(int index) const;\r\n\r\n    /*!\r\n     *  Returns the number of parameters in the function.\r\n     */\r\n    int getParamCount() const;\r\n\r\n    /*!\r\n     *  Generates a tooltip text for the function prototype.\r\n     *\r\n     *    @param [in]  paramIndex  The index of the parameter to highlight.\r\n     *    @param [out] text        The tool tip text.\r\n     */\r\n    void generateToolTipText(int paramIndex, QString& text) const;\r\n\r\n    /*!\r\n     *  Assignment operator.\r\n     */\r\n    ApiFunction& operator=(ApiFunction const& rhs);\r\n\r\nprivate:\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! The name of the function.\r\n    QString name_;\r\n\r\n    //! The return value type.\r\n    QString returnType_;\r\n\r\n    //! The return value description.\r\n    QString returnValueDesc_;\r\n\r\n    //! The function description.\r\n    QString desc_;\r\n\r\n    //! The function parameters.\r\n    QList< QSharedPointer<ApiFunctionParameter> > params_;\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n\r\n#endif // APIFUNCTION_H\r\n"
  },
  {
    "path": "IPXACTmodels/kactusExtensions/ApiFunctionParameter.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ApiFunctionParameter.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Joni-Matti Maatta\r\n// Date: 2.4.2012\r\n//\r\n// Description:\r\n// API function parameter class for API definitions.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"ApiFunctionParameter.h\"\r\n\r\n#include <QStringList>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ApiFunctionParameter::ApiFunctionParameter()\r\n//-----------------------------------------------------------------------------\r\nApiFunctionParameter::ApiFunctionParameter()\r\n{\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ApiFunctionParameter::ApiFunctionParameter()\r\n//-----------------------------------------------------------------------------\r\nApiFunctionParameter::ApiFunctionParameter(ApiFunctionParameter const& rhs)\r\n    : name_(rhs.name_),\r\n      type_(rhs.type_),\r\n      comTransferType_(rhs.comTransferType_),\r\n      comDirection_(rhs.comDirection_),\r\n      contentSource_(rhs.contentSource_),\r\n      dependentParamIndex_(rhs.dependentParamIndex_),\r\n      description_(rhs.description_)\r\n{\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ApiFunctionParameter::ApiFunctionParameter()\r\n//-----------------------------------------------------------------------------\r\nApiFunctionParameter::ApiFunctionParameter(QDomNode& node)\r\n{\r\n    Q_ASSERT(node.nodeName() == QStringLiteral(\"kactus2:functionParameter\"));\r\n\r\n    name_ = node.attributes().namedItem(QStringLiteral(\"name\")).nodeValue();\r\n    type_ = node.attributes().namedItem(QStringLiteral(\"type\")).nodeValue();\r\n\r\n    comTransferType_ = node.attributes().namedItem(QStringLiteral(\"transferType\")).nodeValue();\r\n\r\n    comDirection_ = DirectionTypes::str2Direction(node.attributes().namedItem(\r\n        QStringLiteral(\"comDirection\")).nodeValue(), DirectionTypes::DIRECTION_INVALID);\r\n\r\n    contentSource_ = node.attributes().namedItem(QStringLiteral(\"contentSource\")).nodeValue();\r\n    dependentParamIndex_ = node.attributes().namedItem(QStringLiteral(\"dependentParamIndex\")).nodeValue().toInt();\r\n    description_ = node.attributes().namedItem(QStringLiteral(\"description\")).nodeValue();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ApiFunctionParameter::~ApiFunctionParameter()\r\n//-----------------------------------------------------------------------------\r\nApiFunctionParameter::~ApiFunctionParameter()\r\n{\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ApiFunctionParameter::write()\r\n//-----------------------------------------------------------------------------\r\nvoid ApiFunctionParameter::write(QXmlStreamWriter& writer)\r\n{\r\n    writer.writeEmptyElement(QStringLiteral(\"kactus2:functionParameter\"));\r\n    writer.writeAttribute(QStringLiteral(\"name\"), name_);\r\n    writer.writeAttribute(QStringLiteral(\"type\"), type_);\r\n    writer.writeAttribute(QStringLiteral(\"transferType\"), comTransferType_);\r\n\r\n    if (comDirection_ != DirectionTypes::DIRECTION_INVALID)\r\n    {\r\n        writer.writeAttribute(QStringLiteral(\"comDirection\"), DirectionTypes::direction2Str(comDirection_));\r\n    }\r\n\r\n    writer.writeAttribute(QStringLiteral(\"contentSource\"), contentSource_);\r\n    writer.writeAttribute(QStringLiteral(\"dependentParamIndex\"), QString::number(dependentParamIndex_));\r\n    writer.writeAttribute(QStringLiteral(\"description\"), description_);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ApiFunctionParameter::findErrors()\r\n//-----------------------------------------------------------------------------\r\nvoid ApiFunctionParameter::findErrors(QVector<QString>& errorList, QString const& parentId) const\r\n{\r\n    QString const thisId = QObject::tr(\"function parameter '%1'\").arg(name_);\r\n\r\n    if (name_.isEmpty())\r\n    {\r\n        errorList.append(QObject::tr(\"No name specified for a function parameter in %1\").arg(parentId));\r\n    }\r\n\r\n    if (type_.isEmpty())\r\n    {\r\n        errorList.append(QObject::tr(\"No type specified for %1\").arg(thisId));\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ApiFunctionParameter::isValid()\r\n//-----------------------------------------------------------------------------\r\nbool ApiFunctionParameter::validate() const\r\n{\r\n    return (!name_.isEmpty() && !type_.isEmpty());\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ApiFunctionParameter::setName()\r\n//-----------------------------------------------------------------------------\r\nvoid ApiFunctionParameter::setName(QString const& name)\r\n{\r\n    name_ = name;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ApiFunctionParameter::setType()\r\n//-----------------------------------------------------------------------------\r\nvoid ApiFunctionParameter::setType(QString const& type)\r\n{\r\n    type_ = type;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ApiFunctionParameter::setComTransferType()\r\n//-----------------------------------------------------------------------------\r\nvoid ApiFunctionParameter::setComTransferType(QString const& comTransferType)\r\n{\r\n    comTransferType_ = comTransferType;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ApiFunctionParameter::setComDirection()\r\n//-----------------------------------------------------------------------------\r\nvoid ApiFunctionParameter::setComDirection(DirectionTypes::Direction comDirection)\r\n{\r\n    comDirection_ = comDirection;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ApiFunctionParameter::setContentSource()\r\n//-----------------------------------------------------------------------------\r\nvoid ApiFunctionParameter::setContentSource(QString const& contentSource)\r\n{\r\n    contentSource_ = contentSource;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ApiFunctionParameter::setDependentParameterIndex()\r\n//-----------------------------------------------------------------------------\r\nvoid ApiFunctionParameter::setDependentParameterIndex(int index)\r\n{\r\n    dependentParamIndex_ = index;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ApiFunctionParameter::setDescription()\r\n//-----------------------------------------------------------------------------\r\nvoid ApiFunctionParameter::setDescription(QString const& desc)\r\n{\r\n    description_ = desc;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ApiFunctionParameter::name()\r\n//-----------------------------------------------------------------------------\r\nQString ApiFunctionParameter::name() const\r\n{\r\n    return name_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ApiFunctionParameter::getType()\r\n//-----------------------------------------------------------------------------\r\nQString ApiFunctionParameter::getType() const\r\n{\r\n    return type_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ApiFunctionParameter::getComTransferType()\r\n//-----------------------------------------------------------------------------\r\nQString ApiFunctionParameter::getComTransferType() const\r\n{\r\n    return comTransferType_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ApiFunctionParameter::getComDirection()\r\n//-----------------------------------------------------------------------------\r\nDirectionTypes::Direction ApiFunctionParameter::getComDirection() const\r\n{\r\n    return comDirection_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ApiFunctionParameter::getContentSource()\r\n//-----------------------------------------------------------------------------\r\nQString ApiFunctionParameter::getContentSource() const\r\n{\r\n    return contentSource_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ApiFunctionParameter::getDependentParameterIndex()\r\n//-----------------------------------------------------------------------------\r\nint ApiFunctionParameter::getDependentParameterIndex() const\r\n{\r\n    return dependentParamIndex_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ApiFunctionParameter::getDescription()\r\n//-----------------------------------------------------------------------------\r\nQString const& ApiFunctionParameter::getDescription() const\r\n{\r\n    return description_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ApiFunctionParameter::operator=()\r\n//-----------------------------------------------------------------------------\r\nApiFunctionParameter& ApiFunctionParameter::operator=(ApiFunctionParameter const& rhs)\r\n{\r\n    if (&rhs != this)\r\n    {\r\n        name_ = rhs.name_;\r\n        type_ = rhs.type_;\r\n        comTransferType_ = rhs.comTransferType_;\r\n        comDirection_ = rhs.comDirection_;\r\n        contentSource_ = rhs.contentSource_;\r\n        dependentParamIndex_ = rhs.dependentParamIndex_;\r\n        description_ = rhs.description_;\r\n    }\r\n\r\n    return *this;\r\n}\r\n\r\n"
  },
  {
    "path": "IPXACTmodels/kactusExtensions/ApiFunctionParameter.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ApiFunctionParameter.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Joni-Matti Maatta\r\n// Date: 2.4.2012\r\n//\r\n// Description:\r\n// API function parameter class for API definitions.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef APIFUNCTIONPARAMETER_H\r\n#define APIFUNCTIONPARAMETER_H\r\n\r\n#include <IPXACTmodels/common/DirectionTypes.h>\r\n\r\n#include <IPXACTmodels/ipxactmodels_global.h>\r\n\r\n#include <QString>\r\n#include <QDomNode>\r\n#include <QXmlStreamWriter>\r\n\r\n//-----------------------------------------------------------------------------\r\n//! API function parameter class for API definitions.\r\n//-----------------------------------------------------------------------------\r\nclass IPXACTMODELS_EXPORT ApiFunctionParameter\r\n{\r\npublic:\r\n    /*!\r\n     *  Default constructor.\r\n     */\r\n    ApiFunctionParameter();\r\n\r\n    /*!\r\n     *  Copy constructor.\r\n     */\r\n    ApiFunctionParameter(ApiFunctionParameter const& rhs);\r\n\r\n    /*!\r\n     *  Constructor which read the function parameter from an XML node.\r\n     *\r\n     *    @param [in] node The source XML node.\r\n     */\r\n    ApiFunctionParameter(QDomNode& node);\r\n\r\n    /*!\r\n     *  Destructor.\r\n     */\r\n    ~ApiFunctionParameter();\r\n\r\n    /*!\r\n     *  Writes the function parameter to an XML stream.\r\n     *\r\n     *    @param [in] writer The XML stream writer.\r\n     */\r\n    void write(QXmlStreamWriter& writer);\r\n\r\n    /*!\r\n     *  Returns true if the function parameter is valid.\r\n     *\r\n     *    @param [out] errorList  The list of errors found in the contents.\r\n     *    @param [in]  parentId   The identifier of the containing API function.\r\n     */\r\n    void findErrors(QVector<QString>& errorList, QString const& parentId) const;\r\n\r\n    /*!\r\n     *  Returns true if the function parameter is valid.\r\n     */\r\n    bool validate() const;\r\n\r\n    /*!\r\n     *  Sets the name of the parameter.\r\n     *\r\n     *    @param [in] name The name to set.\r\n     */\r\n    void setName(QString const& name);\r\n\r\n    /*!\r\n     *  Sets the type of the parameter.\r\n     *\r\n     *    @param [in] type The type name to set.\r\n     */\r\n    void setType(QString const& type);\r\n\r\n    /*!\r\n     *  Sets the allowed COM transfer type.\r\n     *\r\n     *    @param [in] comTransferType The COM transfer type to set.\r\n     */\r\n    void setComTransferType(QString const& comTransferType);\r\n\r\n    /*!\r\n     *  Sets the allowed COM direction.\r\n     *\r\n     *    @param [in] comDirection The COM direction to set.\r\n     */\r\n    void setComDirection(DirectionTypes::Direction comDirection);\r\n\r\n    /*!\r\n     *  Sets the COM content source.\r\n     *\r\n     *    @param [in] contentSource The name of the content source.\r\n     *                                \"name\" = name of a COM interface, otherwise any name of a COM property\r\n     */\r\n    void setContentSource(QString const& contentSource);\r\n\r\n    /*!\r\n     *  Sets the dependent parameter index.\r\n     *\r\n     *    @param [in] index The dependent parameter index. -1 if not set.\r\n     */\r\n    void setDependentParameterIndex(int index);\r\n\r\n    /*!\r\n     *  Sets the parameter description.\r\n     *\r\n     *    @param [in] desc The description.\r\n     */\r\n    void setDescription(QString const& desc);\r\n\r\n    /*!\r\n     *  Returns the name of the parameter.\r\n     */\r\n    QString name() const;\r\n\r\n    /*!\r\n     *  Returns the type of the parameter.\r\n     */\r\n    QString getType() const;\r\n\r\n    /*!\r\n     *  Returns the allowed COM transfer type.\r\n     */\r\n    QString getComTransferType() const;\r\n\r\n    /*!\r\n     *  Returns the allowed COM direction.\r\n     */\r\n    DirectionTypes::Direction getComDirection() const;\r\n\r\n    /*!\r\n     *  Returns the name of the COM content source.\r\n     */\r\n    QString getContentSource() const;\r\n\r\n    /*!\r\n     *  Returns the index of the dependent parameter, or -1 if not used.\r\n     */\r\n    int getDependentParameterIndex() const;\r\n\r\n    /*!\r\n     *  Returns the parameter description.\r\n     */\r\n    QString const& getDescription() const;\r\n\r\n    /*!\r\n     *  Assignment operator.\r\n     */\r\n    ApiFunctionParameter& operator=(ApiFunctionParameter const& rhs);\r\n\r\nprivate:\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! The name of the parameter.\r\n    QString name_;\r\n\r\n    //! The type of the parameter.\r\n    QString type_;\r\n\r\n    //! COM transfer type.\r\n    QString comTransferType_;\r\n\r\n    //! COM direction.\r\n    DirectionTypes::Direction comDirection_ = DirectionTypes::DIRECTION_INVALID;\r\n\r\n    //! The name of the source for content assist.\r\n    QString contentSource_;\r\n\r\n    //! Dependent parameter index.\r\n    int dependentParamIndex_ = -1;\r\n\r\n    //! The parameter description.\r\n    QString description_;\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n\r\n#endif // APIFUNCTIONPARAMETER_H\r\n"
  },
  {
    "path": "IPXACTmodels/kactusExtensions/ApiInterconnection.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ApiInterconnection.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 28.08.2015\r\n//\r\n// Description:\r\n// Class encapsulating API connection data.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"ApiInterconnection.h\"\r\n\r\n#include <IPXACTmodels/common/CommonItemsWriter.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ApiInterconnection::ApiInterconnection()\r\n//-----------------------------------------------------------------------------\r\nApiInterconnection::ApiInterconnection() :\r\nInterconnection()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ApiInterconnection::ApiInterconnection()\r\n//-----------------------------------------------------------------------------\r\nApiInterconnection::ApiInterconnection(QString const& name, QString const& displayName, QString const& description,\r\n                                       QSharedPointer<HierInterface> ref1, QSharedPointer<HierInterface> ref2,\r\n                                       bool imported):\r\nInterconnection(),\r\nimported_(imported)\r\n{\r\n    setName(name);\r\n    setDisplayName(displayName);\r\n    setDescription(description);\r\n\r\n    setInterface(ref1);\r\n    setInterface(ref2);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ApiInterconnection::ApiInterconnection()\r\n//-----------------------------------------------------------------------------\r\nApiInterconnection::ApiInterconnection(ApiInterconnection const& other) :\r\nInterconnection(other),\r\nimported_(other.imported_)\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ApiDependency::ApiDependency()\r\n//-----------------------------------------------------------------------------\r\nApiInterconnection::ApiInterconnection(QDomNode& node) :\r\nInterconnection(),\r\nimported_()\r\n{\r\n    setName(node.firstChildElement(QStringLiteral(\"ipxact:name\")).firstChild().nodeValue());\r\n    setDisplayName(node.firstChildElement(QStringLiteral(\"ipxact:displayName\")).firstChild().nodeValue());\r\n    setDescription(node.firstChildElement(QStringLiteral(\"ipxact:description\")).firstChild().nodeValue());\r\n\r\n    QDomElement apiConnectionElement = node.toElement();\r\n\r\n    if (!apiConnectionElement.isNull())\r\n    {\r\n        QDomNodeList apiInterfaceNodes =\r\n            apiConnectionElement.elementsByTagName(QStringLiteral(\"kactus2:activeApiInterface\"));\r\n\r\n        for (int connectionIndex = 0; connectionIndex < apiInterfaceNodes.count(); ++connectionIndex)\r\n        {\r\n            QDomNode activeInterfaceNode = apiInterfaceNodes.at(connectionIndex);\r\n            QDomNamedNodeMap activeAttributes = activeInterfaceNode.attributes();\r\n            QString componentReference = activeAttributes.namedItem(QStringLiteral(\"componentRef\")).nodeValue();\r\n            QString apiReference = activeAttributes.namedItem(QStringLiteral(\"apiRef\")).nodeValue();\r\n\r\n            QSharedPointer<ActiveInterface> apiInterface(new ActiveInterface(componentReference, apiReference));\r\n            setInterface(apiInterface);\r\n        }\r\n\r\n        QDomElement hierInterfaceElement = \r\n            apiConnectionElement.firstChildElement(QStringLiteral(\"kactus2:hierApiInterface\"));\r\n        if (!hierInterfaceElement.isNull())\r\n        {\r\n            QString apiReference = hierInterfaceElement.attribute(QStringLiteral(\"apiRef\"));\r\n            QSharedPointer<HierInterface> hierarchicalInterface (new HierInterface(apiReference));\r\n            setInterface(hierarchicalInterface);\r\n        }\r\n    }\r\n\r\n    QDomNode importedNode = node.firstChildElement(QStringLiteral(\"kactus2:imported\"));\r\n    imported_ = !importedNode.isNull();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ApiInterconnection::~ApiInterconnection()\r\n//-----------------------------------------------------------------------------\r\nApiInterconnection::~ApiInterconnection()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ApiInterconnection::clone()\r\n//-----------------------------------------------------------------------------\r\nApiInterconnection* ApiInterconnection::clone() const\r\n{\r\n    return new ApiInterconnection(*this);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ApiInterconnection::type()\r\n//-----------------------------------------------------------------------------\r\nQString ApiInterconnection::type() const\r\n{\r\n    return QStringLiteral(\"kactus2:apiConnection\");\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ApiInterconnection::write()\r\n//-----------------------------------------------------------------------------\r\nvoid ApiInterconnection::write(QXmlStreamWriter& writer) const\r\n{\r\n    writer.writeStartElement(QStringLiteral(\"kactus2:apiConnection\"));\r\n\r\n    writer.writeTextElement(QStringLiteral(\"ipxact:name\"), name());\r\n\r\n    CommonItemsWriter::writeDisplayName(writer, displayName());\r\n\r\n    CommonItemsWriter::writeDescription(writer, description());\r\n\r\n    writer.writeEmptyElement(QStringLiteral(\"kactus2:activeApiInterface\"));\r\n    writer.writeAttribute(QStringLiteral(\"componentRef\"), getStartInterface()->getComponentReference());\r\n    writer.writeAttribute(QStringLiteral(\"apiRef\"), getStartInterface()->getBusReference());\r\n\r\n    writeEndInterface(writer);\r\n\r\n    if (imported_)\r\n    {\r\n        writer.writeEmptyElement(QStringLiteral(\"kactus2:imported\"));\r\n    }\r\n\r\n    writer.writeEndElement(); // kactus2:apiConnection\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ApiInterconnection::writeEndInterface()\r\n//-----------------------------------------------------------------------------\r\nvoid ApiInterconnection::writeEndInterface(QXmlStreamWriter& writer) const\r\n{\r\n    QSharedPointer<ActiveInterface> activeEndInterface = getEndInterface().dynamicCast<ActiveInterface>();\r\n    if (activeEndInterface)\r\n    {\r\n        writer.writeEmptyElement(QStringLiteral(\"kactus2:activeApiInterface\"));\r\n        writer.writeAttribute(QStringLiteral(\"componentRef\"), activeEndInterface->getComponentReference());\r\n    }\r\n    else\r\n    {\r\n        writer.writeEmptyElement(QStringLiteral(\"kactus2:hierApiInterface\"));\r\n    }\r\n\r\n    writer.writeAttribute(QStringLiteral(\"apiRef\"), getEndInterface()->getBusReference());\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ApiInterconnection::setInterface()\r\n//-----------------------------------------------------------------------------\r\nvoid ApiInterconnection::setInterface(QSharedPointer<HierInterface> interfaceReference)\r\n{\r\n    QSharedPointer<ActiveInterface> activeInterface = interfaceReference.dynamicCast<ActiveInterface>();\r\n    if (activeInterface)\r\n    {\r\n        if (!getStartInterface())\r\n        {\r\n            setStartInterface(activeInterface);\r\n        }\r\n        else\r\n        {\r\n            if (!getActiveInterfaces()->isEmpty())\r\n            {\r\n                getActiveInterfaces()->clear();\r\n            }\r\n\r\n            getActiveInterfaces()->append(activeInterface);\r\n        }\r\n    }\r\n    else\r\n    {\r\n        if (!getHierInterfaces()->isEmpty())\r\n        {\r\n            getHierInterfaces()->clear();\r\n        }\r\n\r\n        getHierInterfaces()->append(interfaceReference);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ApiInterconnection::setImported()\r\n//-----------------------------------------------------------------------------\r\nvoid ApiInterconnection::setImported(bool imported)\r\n{\r\n    imported_ = imported;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ApiInterconnection::getEndInterface()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<HierInterface> ApiInterconnection::getEndInterface() const\r\n{\r\n    if (!getActiveInterfaces()->isEmpty())\r\n    {\r\n        return getActiveInterfaces()->first();\r\n    }\r\n    else if (!getHierInterfaces()->isEmpty())\r\n    {\r\n        return getHierInterfaces()->first();\r\n    }\r\n    else\r\n    {\r\n        return QSharedPointer<ActiveInterface>(new ActiveInterface());\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ApiInterconnection::isImported()\r\n//-----------------------------------------------------------------------------\r\nbool ApiInterconnection::isImported() const\r\n{\r\n    return imported_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ApiInterconnection::operator=()\r\n//-----------------------------------------------------------------------------\r\nApiInterconnection& ApiInterconnection::operator=(ApiInterconnection const& other)\r\n{\r\n    if (&other != this)\r\n    {\r\n        Interconnection::operator=(other);\r\n        imported_ = other.imported_;\r\n    }\r\n\r\n    return *this;\r\n}\r\n"
  },
  {
    "path": "IPXACTmodels/kactusExtensions/ApiInterconnection.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ApiInterconnection.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 28.08.2015\r\n//\r\n// Description:\r\n// Class encapsulating API connection data.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef APIINTERCONNECTION_H\r\n#define APIINTERCONNECTION_H\r\n\r\n#include <IPXACTmodels/Design/Interconnection.h>\r\n\r\n#include <IPXACTmodels/common/VendorExtension.h>\r\n\r\n#include <QDomNode>\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Class encapsulating API dependency connection data.\r\n//-----------------------------------------------------------------------------\r\nclass IPXACTMODELS_EXPORT ApiInterconnection : public Interconnection, public VendorExtension\r\n{\r\npublic:\r\n    /*!\r\n     *  Default constructor.\r\n     */\r\n    ApiInterconnection();\r\n\r\n    /*!\r\n     *  Constructor which sets all the values as given.\r\n     *\r\n     *    @param [in] name         The name to set.\r\n     *    @param [in] displayName  The display name to set.\r\n     *    @param [in] description  The description to set.\r\n     *    @param [in] ref1         The first interface reference.\r\n     *    @param [in] ref2         The second interface reference.\r\n     *    @param [in] imported     If true, the connection is an imported one.\r\n     */\r\n    ApiInterconnection(QString const& name, QString const& displayName, QString const& description,\r\n                  QSharedPointer<HierInterface> ref1, QSharedPointer<HierInterface> ref2,\r\n                  bool imported = false);\r\n\r\n    /*!\r\n     *  Copy constructor.\r\n     */\r\n    ApiInterconnection(ApiInterconnection const& other);\r\n\r\n    /*!\r\n     *  QDomNode constructor.\r\n     *\r\n     *    @param [in] node    The node containing the api interconnection.\r\n     */\r\n    ApiInterconnection(QDomNode& node);\r\n\r\n    /*!\r\n     *  Destructor.\r\n     */\r\n    ~ApiInterconnection();\r\n\r\n    /*!\r\n     *  Copy constructor.\r\n     */\r\n    virtual ApiInterconnection* clone() const;\r\n\r\n    /*!\r\n     *  Gets the type of the extension.\r\n     *\r\n     *    @return The type of the extension.\r\n     */\r\n    virtual QString type() const;\r\n\r\n    /*!\r\n     *  Writes the contents to an XML stream.\r\n     *\r\n     *    @param [in] writer  The selected XML stream.\r\n     */\r\n    virtual void write(QXmlStreamWriter& writer) const;\r\n\r\n    /*!\r\n     *  Set an interface. First active interface is set as the start interface.\r\n     *\r\n     *    @param [in] interfaceReference  The selected interface.\r\n     */\r\n    void setInterface(QSharedPointer<HierInterface> interfaceReference);\r\n\r\n    /*!\r\n     *  Sets the flag whether the connection is an imported one and should be auto-synced.\r\n     *\r\n     *    @param [in] imported    If true, the connection is set as imported.\r\n     */\r\n    void setImported(bool imported);\r\n\r\n    /*!\r\n     *  Get the end interface.\r\n     *\r\n     *    @return The end interface.\r\n     */\r\n    QSharedPointer<HierInterface> getEndInterface() const;\r\n\r\n    /*!\r\n     *  Returns true if the connection is an imported one.\r\n     */\r\n    bool isImported() const;\r\n\r\n    /*!\r\n     *  Assignment operator.\r\n     */\r\n    ApiInterconnection& operator=(ApiInterconnection const& rhs);\r\n\r\nprivate:\r\n\r\n    /*!\r\n     *  Write the end interface.\r\n     *\r\n     *    @param [in] writer  The writer used to write.\r\n     */\r\n    void writeEndInterface(QXmlStreamWriter& writer) const;\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! If true, the connection is an imported one.\r\n    bool imported_ = false;\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n\r\n#endif // APIDEPENDENCY_H\r\n"
  },
  {
    "path": "IPXACTmodels/kactusExtensions/ApiInterface.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ApiInterface.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Joni-Matti Maatta\r\n// Date: 3.4.2012\r\n//\r\n// Description:\r\n// API interface class for defining properties of a specific API interface\r\n// in a SW component.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"ApiInterface.h\"\r\n\r\n#include <IPXACTmodels/common/CommonItemsReader.h>\r\n#include <IPXACTmodels/common/CommonItemsWriter.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: str2DependencyDirection()\r\n//-----------------------------------------------------------------------------\r\nDependencyDirection str2DependencyDirection(QString const& str, DependencyDirection defaultValue)\r\n{\r\n    if (str == QLatin1String(\"provider\"))\r\n    {\r\n        return DEPENDENCY_PROVIDER;\r\n    }\r\n    else if (str == QLatin1String(\"requester\"))\r\n    {\r\n        return DEPENDENCY_REQUESTER;\r\n    }\r\n    else\r\n    {\r\n        return defaultValue;\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: dependencyDirection2Str()\r\n//-----------------------------------------------------------------------------\r\nQString dependencyDirection2Str(DependencyDirection dir)\r\n{\r\n    if (dir == DEPENDENCY_PROVIDER)\r\n    {\r\n        return QStringLiteral(\"provider\");\r\n    }\r\n    else\r\n    {\r\n        return QStringLiteral(\"requester\");\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ApiInterface::ApiInterface()\r\n//-----------------------------------------------------------------------------\r\nApiInterface::ApiInterface() :\r\nNameGroup()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ApiInterface::ApiInterface()\r\n//-----------------------------------------------------------------------------\r\nApiInterface::ApiInterface(ApiInterface const& rhs) :\r\nNameGroup(rhs),\r\napiType_(rhs.apiType_),\r\ndependencyDir_(rhs.dependencyDir_),\r\ndefaultPos_(rhs.getDefaultPos())\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ApiInterface::ApiInterface()\r\n//-----------------------------------------------------------------------------\r\nApiInterface::ApiInterface(QDomNode& node) :\r\nNameGroup()\r\n{\r\n    for (int i = 0; i < node.childNodes().count(); ++i)\r\n    {\r\n        QDomNode childNode = node.childNodes().at(i);\r\n\r\n        if (childNode.isComment())\r\n        {\r\n            continue;\r\n        }\r\n\r\n        if (childNode.nodeName() == QLatin1String(\"ipxact:name\"))\r\n        {\r\n            setName(childNode.firstChild().nodeValue());\r\n        }\r\n        else if (childNode.nodeName() == QLatin1String(\"ipxact:displayName\"))\r\n        {\r\n            setDisplayName(childNode.firstChild().nodeValue());\r\n        }\r\n        else if (childNode.nodeName() == QLatin1String(\"ipxact:shortDescription\"))\r\n        {\r\n            setShortDescription(childNode.firstChild().nodeValue());\r\n        }\r\n        else if (childNode.nodeName() == QLatin1String(\"ipxact:description\"))\r\n        {\r\n            setDescription(childNode.firstChild().nodeValue());\r\n        }\r\n        else if (childNode.nodeName() == QLatin1String(\"kactus2:apiType\"))\r\n        {\r\n            apiType_ = CommonItemsReader::parseVLNVAttributes(childNode, VLNV::APIDEFINITION);\r\n        }\r\n        else if (childNode.nodeName() == QLatin1String(\"kactus2:dependencyDirection\"))\r\n        {\r\n            dependencyDir_ = str2DependencyDirection(childNode.childNodes().at(0).nodeValue(), DEPENDENCY_PROVIDER);\r\n        }\r\n        else if (childNode.nodeName() == QLatin1String(\"kactus2:position\"))\r\n        {\r\n            defaultPos_.parsePosition(childNode);\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ApiInterface::~ApiInterface()\r\n//-----------------------------------------------------------------------------\r\nApiInterface::~ApiInterface()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ApiInterface::clone()\r\n//-----------------------------------------------------------------------------\r\nApiInterface* ApiInterface::clone() const\r\n{\r\n    return new ApiInterface(*this);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ApiInterface::type()\r\n//-----------------------------------------------------------------------------\r\nQString ApiInterface::type() const\r\n{\r\n    return QStringLiteral(\"kactus2:apiInterface\");\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ApiInterface::write()\r\n//-----------------------------------------------------------------------------\r\nvoid ApiInterface::write(QXmlStreamWriter& writer) const\r\n{\r\n    writer.writeStartElement(QStringLiteral(\"kactus2:apiInterface\"));\r\n\r\n    writer.writeTextElement(QStringLiteral(\"ipxact:name\"), name());\r\n\r\n    CommonItemsWriter::writeDisplayName(writer, displayName());\r\n\r\n    CommonItemsWriter::writeShortDescription(writer, shortDescription());\r\n\r\n    CommonItemsWriter::writeDescription(writer, description());\r\n\r\n    writer.writeEmptyElement(QStringLiteral(\"kactus2:apiType\"));\r\n    CommonItemsWriter::writeVLNVAttributes(writer, apiType_);\r\n\r\n    writer.writeTextElement(QStringLiteral(\"kactus2:dependencyDirection\"), dependencyDirection2Str(dependencyDir_));\r\n\r\n    if (!defaultPos_.position().isNull())\r\n    {\r\n        defaultPos_.write(writer);\r\n    }\r\n\r\n    writer.writeEndElement(); // kactus2:apiInterface\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ApiInterface::isValid()\r\n//-----------------------------------------------------------------------------\r\nbool ApiInterface::isValid(QStringList& errorList, QString const& parentId) const\r\n{\r\n    QString const thisId = QObject::tr(\"API interface '%1'\").arg(name());\r\n    bool valid = true;\r\n\r\n    if (name().isEmpty())\r\n    {\r\n        errorList.append(QObject::tr(\"No name specified for an API interface in %1\").arg(parentId));\r\n        valid = false;\r\n    }\r\n\r\n    if (!apiType_.isEmpty() && !apiType_.isValid())\r\n    {\r\n        errorList.append(QObject::tr(\"Invalid API type set in %1\").arg(thisId));\r\n        valid = false;\r\n    }\r\n\r\n    return valid;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ApiInterface::isValid()\r\n//-----------------------------------------------------------------------------\r\nbool ApiInterface::isValid() const\r\n{\r\n    return (!name().isEmpty() && (apiType_.isEmpty() || apiType_.isValid()));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ApiInterface::setApiType()\r\n//-----------------------------------------------------------------------------\r\nvoid ApiInterface::setApiType(VLNV const& vlnv)\r\n{\r\n    apiType_ = vlnv;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ApiInterface::setDependencyDirection()\r\n//-----------------------------------------------------------------------------\r\nvoid ApiInterface::setDependencyDirection(DependencyDirection dir)\r\n{\r\n    dependencyDir_ = dir;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ApiInterface::getApiType()\r\n//-----------------------------------------------------------------------------\r\nVLNV const& ApiInterface::getApiType() const\r\n{\r\n    return apiType_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ApiInterface::getDependencyDirection()\r\n//-----------------------------------------------------------------------------\r\nDependencyDirection ApiInterface::getDependencyDirection() const\r\n{\r\n    return dependencyDir_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ApiInterface::operator=()\r\n//-----------------------------------------------------------------------------\r\nApiInterface& ApiInterface::operator=(ApiInterface const& rhs)\r\n{\r\n    if (&rhs != this)\r\n    {\r\n        NameGroup::operator=(rhs);\r\n        apiType_ = rhs.apiType_;\r\n        dependencyDir_ = rhs.dependencyDir_;\r\n    }\r\n\r\n    return *this;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ApiInterface::setDefaultPos()\r\n//-----------------------------------------------------------------------------\r\nvoid ApiInterface::setDefaultPos(QPointF const& pos)\r\n{\r\n    defaultPos_.setPosition(pos);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ApiInterface::getDefaultPos()\r\n//-----------------------------------------------------------------------------\r\nQPointF ApiInterface::getDefaultPos() const\r\n{\r\n    return defaultPos_.position();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ApiInterface::writePosition()\r\n//-----------------------------------------------------------------------------\r\nvoid ApiInterface::writePosition(QXmlStreamWriter& writer, QPointF const& pos) const\r\n{\r\n    writer.writeEmptyElement(QStringLiteral(\"kactus2:position\"));\r\n    writer.writeAttribute(QStringLiteral(\"x\"), QString::number(int(pos.x())));\r\n    writer.writeAttribute(QStringLiteral(\"y\"), QString::number(int(pos.y())));\r\n}"
  },
  {
    "path": "IPXACTmodels/kactusExtensions/ApiInterface.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ApiInterface.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Joni-Matti Maatta\r\n// Date: 3.4.2012\r\n//\r\n// Description:\r\n// API interface class for defining properties of a specific API interface\r\n// in a SW component.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef APIINTERFACE_H\r\n#define APIINTERFACE_H\r\n\r\n#include <IPXACTmodels/common/VLNV.h>\r\n\r\n#include <IPXACTmodels/common/NameGroup.h>\r\n\r\n#include <IPXACTmodels/ipxactmodels_global.h>\r\n#include <IPXACTmodels/common/VendorExtension.h>\r\n\r\n#include \"Kactus2Position.h\"\r\n\r\n#include <QString>\r\n#include <QDomNode>\r\n#include <QXmlStreamWriter>\r\n#include <QPointF>\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Dependency direction enumeration.\r\n//-----------------------------------------------------------------------------\r\nenum DependencyDirection\r\n{\r\n    DEPENDENCY_REQUESTER = 0,   //!< The API interface requires the API.\r\n    DEPENDENCY_PROVIDER         //!< The API interface provides the API for those who need it.\r\n};\r\n\r\n/*!\r\n *  Converts the string to an equivalent enumeration value.\r\n */\r\nIPXACTMODELS_EXPORT DependencyDirection str2DependencyDirection(QString const& str, DependencyDirection defaultValue);\r\n\r\n/*!\r\n *  Converts the enumeration value to an equivalent string.\r\n *\r\n *    @param [in] dir The dependency direction enum value.\r\n *\r\n *    @return The equivalent string.\r\n */\r\nIPXACTMODELS_EXPORT QString dependencyDirection2Str(DependencyDirection dir);\r\n\r\n//-----------------------------------------------------------------------------\r\n//! API interface class for defining properties of a specific API interface\r\n//! in a SW component.\r\n//-----------------------------------------------------------------------------\r\nclass IPXACTMODELS_EXPORT ApiInterface : public NameGroup, public VendorExtension\r\n{\r\npublic:\r\n\r\n    /*!\r\n     *  Default constructor.\r\n     */\r\n    ApiInterface();\r\n\r\n    /*!\r\n     *  Copy constructor.\r\n     */\r\n    ApiInterface(ApiInterface const& rhs);\r\n\r\n    /*!\r\n     *  Constructor which reads the API interface from an XML node.\r\n     *\r\n     *    @param [in] node The source XML node.\r\n     */\r\n    ApiInterface(QDomNode& node);\r\n\r\n    /*!\r\n     *  Destructor.\r\n     */\r\n    ~ApiInterface();\r\n\r\n    /*!\r\n     *  Clones the api interface.\r\n     *\r\n     *    @return A cloned api interface.\r\n     */\r\n    ApiInterface* clone() const final;\r\n\r\n    /*!\r\n     *  Gets the api interface type.\r\n     *\r\n     *    @return The type of the api interface.\r\n     */\r\n    QString type() const final;\r\n\r\n    /*!\r\n     *  Writes the contents of the API interface to an XML stream.\r\n     */\r\n    void write(QXmlStreamWriter& writer) const final;\r\n\r\n    /*!\r\n     *  Returns true if the contents of the API interface are valid.\r\n     *\r\n     *    @param [out] errorList  Error list which is appended with errors if found while validating.\r\n     *    @param [in]  parentId   The identifier of the containing component.\r\n     */\r\n    bool isValid(QStringList& errorList, QString const& parentId) const;\r\n\r\n    /*!\r\n     *  Returns true if the contents of the API interface are valid.\r\n     */\r\n    bool isValid() const;\r\n\r\n    /*!\r\n     *  Sets the API type.\r\n     *\r\n     *    @param [in] vlnv The API definition VLNV.\r\n     */\r\n    void setApiType(VLNV const& vlnv);\r\n\r\n    /*!\r\n     *  Sets the dependency direction.\r\n     *\r\n     *    @param [in] dir The dependency direction.\r\n     */\r\n    void setDependencyDirection(DependencyDirection dir);\r\n\r\n    /*!\r\n     *  Sets the default position in the parent component's graphical representation.\r\n     *\r\n     *    @param [in] pos The position to set.\r\n     */\r\n    void setDefaultPos(QPointF const& pos);\r\n\r\n    /*!\r\n     *  Returns the API type (API definition VLNV).\r\n     */\r\n    VLNV const& getApiType() const;\r\n\r\n    /*!\r\n     *  Returns the dependency direction.\r\n     */\r\n    DependencyDirection getDependencyDirection() const;\r\n\r\n    /*!\r\n     *  Returns the default position in the parent component's graphical representation.\r\n     */\r\n    QPointF getDefaultPos() const;\r\n\r\n    /*!\r\n     *  Assignment operator.\r\n     */\r\n    ApiInterface& operator=(ApiInterface const& rhs);\r\n\r\nprivate:\r\n\r\n    void writePosition(QXmlStreamWriter& writer, QPointF const& pos) const;\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! The API type (i.e. a VLNV reference to an API definition).\r\n    VLNV apiType_;\r\n\r\n    //! Dependency direction.\r\n    DependencyDirection dependencyDir_ = DEPENDENCY_PROVIDER;\r\n\r\n    //! The default position in the parent component's graphical representation (optional).\r\n    Kactus2Position defaultPos_ = Kactus2Position(QPoint());\r\n\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n\r\n#endif // APIINTERFACE_H\r\n"
  },
  {
    "path": "IPXACTmodels/kactusExtensions/ColumnDesc.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ColumnDesc.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Joni-Matti Maatta\r\n// Date: 12.4.2012\r\n//\r\n// Description:\r\n// ColumnDesc structure describes the kactus2:column vendor extension element in an IP-XACT design.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"ColumnDesc.h\"\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ColumnDesc::ColumnDesc()\r\n//-----------------------------------------------------------------------------\r\nColumnDesc::ColumnDesc()\r\n    : name_(),\r\n      contentType_(ColumnTypes::IO),\r\n      allowedItems_(ColumnTypes::NONE),\r\n      width_(119),\r\n      minWidth_(119),\r\n      xPosition_(0)\r\n{\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ColumnDesc()\r\n//-----------------------------------------------------------------------------\r\nColumnDesc::ColumnDesc(QString const& name, ColumnTypes::ColumnContentType contentType,\r\n                       unsigned int allowedItems, unsigned int minWidth)\r\n    : name_(name),\r\n      contentType_(contentType),\r\n      allowedItems_(allowedItems),\r\n      width_(minWidth),\r\n      minWidth_(minWidth),\r\n      xPosition_(0)\r\n{\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ColumnDesc::clone()\r\n//-----------------------------------------------------------------------------\r\nColumnDesc* ColumnDesc::clone() const\r\n{\r\n    return new ColumnDesc(*this);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ColumnDesc::type()\r\n//-----------------------------------------------------------------------------\r\nQString ColumnDesc::type() const\r\n{\r\n    return QStringLiteral(\"kactus2:column\");\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ColumnDesc::write()\r\n//-----------------------------------------------------------------------------\r\nvoid ColumnDesc::write(QXmlStreamWriter& writer) const\r\n{\r\n    writer.writeEmptyElement(QStringLiteral(\"kactus2:column\"));\r\n    writer.writeAttribute(QStringLiteral(\"name\"), name_);\r\n    writer.writeAttribute(QStringLiteral(\"contentType\"), QString::number(contentType_));\r\n    writer.writeAttribute(QStringLiteral(\"allowedItems\"), QString::number(allowedItems_));\r\n    writer.writeAttribute(QStringLiteral(\"minWidth\"), QString::number(minWidth_));\r\n    writer.writeAttribute(QStringLiteral(\"width\"), QString::number(width_));\r\n    writer.writeAttribute(QStringLiteral(\"x\"), QString::number(xPosition_));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ColumnDesc::ColumnDesc()\r\n//-----------------------------------------------------------------------------\r\nColumnDesc::ColumnDesc(const ColumnDesc& other)\r\n    : name_(other.name_),\r\n      contentType_(other.contentType_),\r\n      allowedItems_(other.allowedItems_),\r\n      width_(other.width_),\r\n      minWidth_(other.minWidth_),\r\n      xPosition_(other.xPosition_)\r\n{\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ColumnDesc::ColumnDesc()\r\n//-----------------------------------------------------------------------------\r\nColumnDesc& ColumnDesc::operator=(const ColumnDesc& other)\r\n{\r\n    if (this != &other)\r\n    {\r\n        name_ = other.name_;\r\n        contentType_ = other.contentType_;\r\n        allowedItems_ = other.allowedItems_;\r\n        width_ = other.width_;\r\n        minWidth_ = other.minWidth_;\r\n        xPosition_ = other.xPosition_;\r\n    }\r\n\r\n    return *this;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ColumnDesc::setName()\r\n//-----------------------------------------------------------------------------\r\nvoid ColumnDesc::setName(QString const& name)\r\n{\r\n    name_ = name;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ColumnDesc::setContentType()\r\n//-----------------------------------------------------------------------------\r\nvoid ColumnDesc::setContentType(ColumnTypes::ColumnContentType contentType)\r\n{\r\n    contentType_ = contentType;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ColumnDesc::setAllowedItems()\r\n//-----------------------------------------------------------------------------\r\nvoid ColumnDesc::setAllowedItems(unsigned int allowedItems)\r\n{\r\n    allowedItems_ = allowedItems;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ColumnDesc::setWidth()\r\n//-----------------------------------------------------------------------------\r\nvoid ColumnDesc::setWidth(unsigned int width)\r\n{\r\n    width_ = qMax(minWidth_, width);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ColumnDesc::setMinimumWidth()\r\n//-----------------------------------------------------------------------------\r\nvoid ColumnDesc::setMinimumWidth(int minimum)\r\n{\r\n    minWidth_ = minimum;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ColumnDesc::name()\r\n//-----------------------------------------------------------------------------\r\nQString ColumnDesc::name() const\r\n{\r\n    return name_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ColumnDesc::getContentType()\r\n//-----------------------------------------------------------------------------\r\nColumnTypes::ColumnContentType ColumnDesc::getContentType() const\r\n{\r\n    return contentType_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ColumnDesc::getAllowedItems()\r\n//-----------------------------------------------------------------------------\r\nunsigned int ColumnDesc::getAllowedItems() const\r\n{\r\n    return allowedItems_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ColumnDesc::getWidth()\r\n//-----------------------------------------------------------------------------\r\nunsigned int ColumnDesc::getWidth() const\r\n{\r\n    return width_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ColumnDesc::getPosition()\r\n//-----------------------------------------------------------------------------\r\nunsigned int ColumnDesc::getPosition() const\r\n{\r\n    return xPosition_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ColumnDesc::setPosition()\r\n//-----------------------------------------------------------------------------\r\nvoid ColumnDesc::setPosition(unsigned int x)\r\n{\r\n    xPosition_ = x;\r\n}\r\n"
  },
  {
    "path": "IPXACTmodels/kactusExtensions/ColumnDesc.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ColumnDesc.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Joni-Matti Maatta\r\n// Date: 12.4.2012\r\n//\r\n// Description:\r\n// ColumnDesc structure describes the kactus2:column vendor extension element in an IP-XACT design.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef COLUMNDESC_H\r\n#define COLUMNDESC_H\r\n\r\n#include <IPXACTmodels/common/VendorExtension.h>\r\n#include <IPXACTmodels/ipxactmodels_global.h>\r\n\r\n#include <editors/common/ColumnTypes.h>\r\n\r\n#include <QString>\r\n#include <QDomNode>\r\n#include <QXmlStreamWriter>\r\n\r\n//-----------------------------------------------------------------------------\r\n//! ColumnDesc structure describes the kactus2:column vendor extension element in an IP-XACT design.\r\n//-----------------------------------------------------------------------------\r\nclass IPXACTMODELS_EXPORT ColumnDesc : public VendorExtension\r\n{\r\npublic:\r\n    /*!\r\n     *  Default constructor.\r\n     */\r\n    ColumnDesc();\r\n\r\n    /*!\r\n     *  Constructor which initializes the column description fully.\r\n     */\r\n    ColumnDesc(QString const& name, ColumnTypes::ColumnContentType contentType,\r\n               unsigned int allowedItems = ColumnTypes::NONE, unsigned int minWidth = 259);\r\n\r\n    /*!\r\n     *  Clone constructor.\r\n     */\r\n    virtual ColumnDesc* clone() const;\r\n\r\n    /*!\r\n     *  Get the type of the extension.\r\n     *\r\n     *    @return The type of the extension.\r\n     */\r\n    virtual QString type() const;\r\n\r\n    /*!\r\n     *  Writes the column description to an XML stream.\r\n     */\r\n    virtual void write(QXmlStreamWriter& writer) const;\r\n\r\n    /*!\r\n     *  Sets the name of the column.\r\n     *\r\n     *    @param [in] name The name of the column.\r\n     */\r\n    void setName(QString const& name);\r\n\r\n    /*!\r\n     *  Sets the content type.\r\n     *\r\n     *    @param [in] contentType The content type.\r\n     */\r\n    void setContentType(ColumnTypes::ColumnContentType contentType);\r\n\r\n    /*!\r\n     *  Sets the allowed items.\r\n     *\r\n     *    @param [in] allowedItems The allowed items as bit flags.\r\n     */\r\n    void setAllowedItems(unsigned int allowedItems);\r\n\r\n    /*!\r\n     *  Sets the width of the column.\r\n     *\r\n     *    @param [in] width The width of the column.\r\n     */\r\n    void setWidth(unsigned int width);\r\n\r\n        \r\n    void setMinimumWidth(int minimum);\r\n\r\n    /*!\r\n     *  Returns the name of the column.\r\n     */\r\n    QString name() const;\r\n\r\n    /*!\r\n     *  Returns the content type.\r\n     */\r\n    ColumnTypes::ColumnContentType getContentType() const;\r\n\r\n    /*!\r\n     *  Returns the allowed items.\r\n     */\r\n    unsigned int getAllowedItems() const;\r\n\r\n    /*!\r\n     *  Returns the width of the column.\r\n     */\r\n    unsigned int getWidth() const;\r\n\r\n    unsigned int getPosition() const;\r\n\r\n    void setPosition(unsigned int x);\r\n\r\n    //! Copy constructor\r\n    ColumnDesc(const ColumnDesc& other);\r\n\r\n    //! Assignment operator\r\n    ColumnDesc& operator=(const ColumnDesc& other);\r\n\r\nprivate:\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! The name of the column.\r\n    QString name_;\r\n\r\n    //! The content type for the column.\r\n    ColumnTypes::ColumnContentType contentType_;\r\n\r\n    //! The allowed items for the column.\r\n    unsigned int allowedItems_;\r\n\r\n    //! The width of the column.\r\n    unsigned int width_;\r\n\r\n    //! The minimum width for the column.\r\n    unsigned int minWidth_;\r\n\r\n    unsigned int xPosition_;\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n\r\n#endif // COLUMNDESC_H\r\n"
  },
  {
    "path": "IPXACTmodels/kactusExtensions/ComDefinition.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ComDefinition.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Joni-Matti Maatta\r\n// Date: 2.4.2012\r\n//\r\n// Description:\r\n// Class which encapsulates the handling of a custom communication definition\r\n// object.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"ComDefinition.h\"\r\n\r\n#include <IPXACTmodels/common/GenericVendorExtension.h>\r\n\r\n#include <IPXACTmodels/kactusExtensions/ComProperty.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComDefinition::ComDefinition()\r\n//-----------------------------------------------------------------------------\r\nComDefinition::ComDefinition(VLNV const& vlnv, Document::Revision revision) : \r\n    Document(vlnv, revision),\r\n    transferTypes_(new QStringList),\r\n    properties_(new QList<QSharedPointer<ComProperty> >)\r\n{\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComDefinition::ComDefinition()\r\n//-----------------------------------------------------------------------------\r\nComDefinition::ComDefinition(ComDefinition const& rhs) : Document(rhs),\r\n    transferTypes_(new QStringList(*rhs.transferTypes_)),\r\n    properties_(new QList<QSharedPointer<ComProperty> >)\r\n{\r\n    // Make deep copies of the properties.\r\n    for (QSharedPointer<ComProperty> property : *rhs.properties_)\r\n    {\r\n        properties_->append(QSharedPointer<ComProperty>(new ComProperty(*property)));\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComDefinition::~ComDefinition()\r\n//-----------------------------------------------------------------------------\r\nComDefinition::~ComDefinition()\r\n{\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComDefinition::clone()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<Document> ComDefinition::clone() const\r\n{\r\n    return QSharedPointer<Document>(new ComDefinition(*this));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComDefinition::getDependentFiles()\r\n//-----------------------------------------------------------------------------\r\nQStringList ComDefinition::getDependentFiles() const\r\n{\r\n    return QStringList();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComDefinition::getDependentVLNVs()\r\n//-----------------------------------------------------------------------------\r\nQList<VLNV> ComDefinition::getDependentVLNVs() const\r\n{\r\n    return QList<VLNV>();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComDefinition::addTransferType()\r\n//-----------------------------------------------------------------------------\r\nvoid ComDefinition::addTransferType(QString const& type)\r\n{\r\n    // Check for duplicates.\r\n    if (!transferTypes_->contains(type))\r\n    {\r\n        transferTypes_->append(type);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComDefinition::removeTransferType()\r\n//-----------------------------------------------------------------------------\r\nvoid ComDefinition::removeTransferType(QString const& type)\r\n{\r\n    transferTypes_->removeAll(type);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComDefinition::setTransferTypes()\r\n//-----------------------------------------------------------------------------\r\nvoid ComDefinition::setTransferTypes(QStringList const& types)\r\n{\r\n    transferTypes_ = QSharedPointer<QStringList>( new QStringList( types ) );\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComDefinition::addProperty()\r\n//-----------------------------------------------------------------------------\r\nvoid ComDefinition::addProperty(QSharedPointer<ComProperty> prop)\r\n{\r\n    properties_->append(prop);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComDefinition::removeProperty()\r\n//-----------------------------------------------------------------------------\r\nvoid ComDefinition::removeProperty(QString const& name)\r\n{\r\n    for (QSharedPointer<ComProperty> property : *properties_)\r\n    {\r\n        if (property->name() == name)\r\n        {\r\n            properties_->removeOne(property);\r\n            break;\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComDefinition::setProperties()\r\n//-----------------------------------------------------------------------------\r\nvoid ComDefinition::setProperties(QList< QSharedPointer<ComProperty> > const& properties)\r\n{\r\n    properties_ = QSharedPointer< QList< QSharedPointer<ComProperty> > >\r\n\t\t( new QList<QSharedPointer<ComProperty> >( properties ) );\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComDefinition::getTransferTypes()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer< QStringList > ComDefinition::getTransferTypes() const\r\n{\r\n    return transferTypes_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComDefinition::getProperties()\r\n//-----------------------------------------------------------------------------\r\nQList< QSharedPointer<ComProperty> >  ComDefinition::getProperties() const\r\n{\r\n    return *properties_;\r\n}\r\n"
  },
  {
    "path": "IPXACTmodels/kactusExtensions/ComDefinition.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ComDefinition.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Joni-Matti Maatta\r\n// Date: 29.3.2012\r\n//\r\n// Description:\r\n// Class which encapsulates the handling of custom communication definition\r\n// object.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef COMDEFINITION_H\r\n#define COMDEFINITION_H\r\n\r\n#include <IPXACTmodels/common/Document.h>\r\n#include <IPXACTmodels/kactusExtensions/ComProperty.h>\r\n\r\n#include <IPXACTmodels/ipxactmodels_global.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Communication definition class.\r\n//-----------------------------------------------------------------------------\r\nclass IPXACTMODELS_EXPORT ComDefinition : public Document\r\n{\r\npublic:\r\n    /*!\r\n     *  Constructor which creates an empty communication definition.\r\n     *\r\n     *    @param [in] vlnv The VLNV of the communication definition.\r\n     */\r\n    ComDefinition(VLNV const& vlnv, Document::Revision revision);\r\n\r\n    /*!\r\n     *  Copy constructor.\r\n     */\r\n    ComDefinition(ComDefinition const& rhs);\r\n\r\n    /*!\r\n     *  Destructor.\r\n     */\r\n    virtual ~ComDefinition();\r\n\r\n    /*!\r\n     *  Makes a copy of the document.\r\n     *\r\n     *    @return The created copy of the COM definition.\r\n     */\r\n    virtual QSharedPointer<Document> clone()  const;\r\n\r\n    /*!\r\n     *  Returns the dependent files (none).\r\n     */\r\n    virtual QStringList getDependentFiles() const;\r\n\r\n    /*!\r\n     *  Returns the dependent VLNVs (none).\r\n     */\r\n    virtual QList<VLNV> getDependentVLNVs() const;\r\n\r\n    /*!\r\n     *  Adds a new transfer type to the communication definition.\r\n     *\r\n     *    @param [in] type The name of the transfer type to add.\r\n     */\r\n    void addTransferType(QString const& type);\r\n\r\n    /*!\r\n     *  Removes a transfer type from the communication definition.\r\n     *\r\n     *    @param [in] type The name of the transfer type to remove.\r\n     */\r\n    void removeTransferType(QString const& type);\r\n\r\n    /*!\r\n     *  Sets the supported transfer types.\r\n     *\r\n     *    @param [in] types A list of transfer type names.\r\n     */\r\n    void setTransferTypes(QStringList const& types);\r\n\r\n    /*!\r\n     *  Adds a property to the definition.\r\n     *\r\n     *    @param [in] prop The property to add.\r\n     */\r\n    void addProperty(QSharedPointer<ComProperty> prop);\r\n\r\n    /*!\r\n     *  Removes a property from the definition.\r\n     *\r\n     *    @param [in] name The name of the property to remove.\r\n     */\r\n    void removeProperty(QString const& name);\r\n\r\n    /*!\r\n     *  Sets the properties.\r\n     *\r\n     *    @param [in] properties A list of properties to set.\r\n     */\r\n    void setProperties(QList< QSharedPointer<ComProperty> > const& properties);\r\n\r\n    /*!\r\n     *  Returns the supported transfer types.\r\n     */\r\n    QSharedPointer< QStringList > getTransferTypes() const;\r\n\r\n    /*!\r\n     *  Returns the list of properties.\r\n     */\r\n     QList< QSharedPointer<ComProperty> > getProperties() const;\r\n\r\nprivate:\r\n    \r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! The list of transfer types.\r\n    QSharedPointer< QStringList > transferTypes_;\r\n\r\n    //! The list of properties.\r\n    QSharedPointer< QList< QSharedPointer<ComProperty> > > properties_;\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n\r\n#endif // COMDEFINITION_H\r\n"
  },
  {
    "path": "IPXACTmodels/kactusExtensions/ComDefinitionReader.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ComDefinitionReader.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Janne Virtanen\r\n// Date: 28.01.2016\r\n//\r\n// Description:\r\n// XML reader class for Kactus2 Com definition.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"ComDefinitionReader.h\"\r\n\r\n#include \"ComDefinition.h\"\r\n\r\n#include <IPXACTmodels/common/GenericVendorExtension.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComDefinitionReader::createComDefinitionFrom()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<ComDefinition> ComDefinitionReader::createComDefinitionFrom(QDomNode const& document)\r\n{\r\n    QDomElement comNode = document.firstChildElement();\r\n\tauto vlnv = DocumentReader::createVLNVFrom(comNode, VLNV::COMDEFINITION);\r\n\tauto revision = DocumentReader::getXMLDocumentRevision(comNode);\r\n\tif (revision == Document::Revision::Unknown)\r\n\t{\r\n\t\trevision = Document::Revision::Std22;\r\n\t}\r\n\r\n    QSharedPointer<ComDefinition> comDefinition(new ComDefinition(vlnv, revision));\r\n\r\n    DocumentReader::parseTopComments(document, comDefinition);\r\n\r\n\tDocumentReader::parseXMLProcessingInstructions(document, comDefinition);\r\n\r\n\tDocumentReader::parseNamespaceDeclarations(comNode, comDefinition);\r\n\r\n\tDocumentReader::parseDocumentNameGroup(document, comDefinition);\r\n\r\n\t// Parse child nodes.\r\n\tfor (int i = 0; i < comNode.childNodes().count(); ++i)\r\n\t{\r\n\t\tQDomNode childNode = comNode.childNodes().at(i);\r\n\r\n\t\tif (childNode.isComment())\r\n\t\t{\r\n\t\t\tcontinue;\r\n\t\t}\r\n\r\n\t\tif (childNode.nodeName() == QLatin1String(\"kactus2:transferTypes\"))\r\n\t\t{\r\n\t\t\tDetails::parseTransferTypes(childNode, comDefinition);\r\n\t\t}\r\n\t\telse if (childNode.nodeName() == QLatin1String(\"kactus2:properties\"))\r\n\t\t{\r\n\t\t\tDetails::parseProperties(childNode, comDefinition);\r\n\t\t}\r\n    }\r\n\r\n\tDocumentReader::parseKactusAndVendorExtensions(comNode, comDefinition);\r\n\r\n\treturn comDefinition;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComDefinitionReader::parseTransferTypes()\r\n//-----------------------------------------------------------------------------\r\nvoid ComDefinitionReader::Details::parseTransferTypes(QDomNode const& node, QSharedPointer<ComDefinition> comDefinition)\r\n{\r\n\tfor (int i = 0; i < node.childNodes().count(); ++i)\r\n\t{\r\n\t\tQDomNode typeNode = node.childNodes().at(i);\r\n\r\n\t\tif (typeNode.nodeName() == QLatin1String(\"kactus2:transferType\"))\r\n\t\t{\r\n\t\t\tQString name = typeNode.attributes().namedItem(QStringLiteral(\"name\")).nodeValue();\r\n\t\t\tcomDefinition->getTransferTypes()->append(name);\r\n\t\t}\r\n\t}\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComDefinitionReader::parseProperties()\r\n//-----------------------------------------------------------------------------\r\nvoid ComDefinitionReader::Details::parseProperties(QDomNode const& node, QSharedPointer<ComDefinition> comDefinition)\r\n{\r\n\tQList<QSharedPointer<ComProperty> > properties;\r\n\tfor (int i = 0; i < node.childNodes().count(); ++i)\r\n\t{\r\n\t\tQDomNode propNode = node.childNodes().at(i);\r\n\r\n\t\tif (propNode.nodeName() == QLatin1String(\"kactus2:property\"))\r\n\t\t{\r\n\t\t\tQSharedPointer<ComProperty> prop(new ComProperty(propNode));\r\n\t\t\tproperties.append(prop);\r\n\t\t}\r\n\t}\r\n\r\n\tcomDefinition->setProperties(properties);\r\n}\r\n"
  },
  {
    "path": "IPXACTmodels/kactusExtensions/ComDefinitionReader.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ComDefinitionReader.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Janne Virtanen\r\n// Date: 28.01.2016\r\n//\r\n// Description:\r\n// XML reader class for Kactus2 Com definition.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef COMDEFINITIONREADER_H\r\n#define COMDEFINITIONREADER_H\r\n\r\n#include <IPXACTmodels/common/DocumentReader.h>\r\n#include <IPXACTmodels/ipxactmodels_global.h>\r\n\r\n#include <QDomNode>\r\n#include <QSharedPointer>\r\n\r\nclass ComDefinition;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! XML reader class for IP-XACT Parameter element.\r\n//-----------------------------------------------------------------------------\r\nnamespace  ComDefinitionReader\r\n{\r\n\r\n    /*!\r\n     *  Creates a Com definition from XML description.\r\n     *\r\n     *    @param [in] document   The XML document to create the Com definition from.\r\n     *\r\n     *    @return The created Com definition.\r\n     */\r\n    IPXACTMODELS_EXPORT QSharedPointer<ComDefinition> createComDefinitionFrom(QDomNode const& document);\r\n \r\n    namespace Details\r\n    {\r\n        /*!\r\n         *  Parses all found transfer types from the given XML node.\r\n         *\r\n         *    @param [in] node The source XML node.\r\n         */\r\n        void parseTransferTypes(QDomNode const& node, QSharedPointer<ComDefinition> comDefinition);\r\n\r\n        /*!\r\n         *  Parses all found properties from the given XML node.\r\n         *\r\n         *    @param [in] node The source XML node.\r\n         */\r\n        void parseProperties(QDomNode const& node, QSharedPointer<ComDefinition> comDefinition);\r\n    }\r\n};\r\n\r\n#endif // COMDEFINITIONREADER_H"
  },
  {
    "path": "IPXACTmodels/kactusExtensions/ComDefinitionWriter.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ComDefinitionWriter.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Janne Virtanen\r\n// Date: 11.12.2015\r\n//\r\n// Description:\r\n// Writer class for IP-XACT ComDefinition element.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"ComDefinitionWriter.h\"\r\n\r\n#include <IPXACTmodels/common/NameGroupWriter.h>\r\n\r\n\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComDefinitionWriter::writeComDefinitionFrom()\r\n//-----------------------------------------------------------------------------\r\nvoid ComDefinitionWriter::writeComDefinition(QXmlStreamWriter& writer, QSharedPointer<ComDefinition> comDefinition)\r\n{\r\n    writer.writeStartDocument();\r\n    \r\n    DocumentWriter::writeTopComments(writer, comDefinition);\r\n\t\r\n    writer.writeStartElement(QStringLiteral(\"kactus2:comDefinition\"));\r\n    DocumentWriter::writeNamespaceDeclarations(writer, comDefinition);\r\n\r\n\t// Write basic information.\r\n    DocumentWriter::writeDocumentNameGroup(writer, comDefinition);\r\n\r\n    // Write data types.\r\n    writer.writeStartElement(QStringLiteral(\"kactus2:transferTypes\"));\r\n\r\n    for (QString const& type : *comDefinition->getTransferTypes())\r\n    {\r\n        writer.writeEmptyElement(QStringLiteral(\"kactus2:transferType\"));\r\n        writer.writeAttribute(QStringLiteral(\"name\"), type);\r\n    }\r\n\r\n    writer.writeEndElement(); // kactus2:transferTypes\r\n\r\n    // Write properties.\r\n    writer.writeStartElement(QStringLiteral(\"kactus2:properties\"));\r\n\r\n    for (QSharedPointer<ComProperty> prop : comDefinition->getProperties())\r\n\t{\r\n\t\tprop->write(writer);\r\n    }\r\n\r\n\twriter.writeEndElement(); // kactus2:properties\r\n\r\n    DocumentWriter::writeVendorExtensions(writer, comDefinition);\r\n\r\n    writer.writeEndElement(); // kactus2:comDefinition\r\n    writer.writeEndDocument();\r\n}\r\n"
  },
  {
    "path": "IPXACTmodels/kactusExtensions/ComDefinitionWriter.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ComDefinitionWriter.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Janne Virtanen\r\n// Date: 11.12.2015\r\n//\r\n// Description:\r\n// Writer class for IP-XACT ComDefinition element.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef ComDefinitionWriter_H\r\n#define ComDefinitionWriter_H\r\n\r\n#include \"ComDefinition.h\"\r\n\r\n#include <IPXACTmodels/common/DocumentWriter.h>\r\n\r\n#include <QObject>\r\n#include <QSharedPointer>\r\n#include <QXmlStreamWriter>\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Writer class for IP-XACT ComDefinition element.\r\n//-----------------------------------------------------------------------------\r\nnamespace ComDefinitionWriter \r\n{\r\n\r\n    /*!\r\n     *  Write a view to an XML file.\r\n     *\r\n     *    @param [in] writer  The used xml writer.\r\n     *    @param [in] ComDefinition\t\tThe ComDefinition to be written.\r\n     */\r\n    IPXACTMODELS_EXPORT void writeComDefinition(QXmlStreamWriter& writer,\r\n        QSharedPointer<ComDefinition> ComDefinition);\r\n};\r\n\r\n#endif // ComDefinitionWriter_H\r\n"
  },
  {
    "path": "IPXACTmodels/kactusExtensions/ComInterconnection.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ComInterconnection.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 28.08.2015\r\n//\r\n// Description:\r\n// Class encapsulating communication connection data.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"ComInterconnection.h\"\r\n\r\n#include <IPXACTmodels/common/CommonItemsWriter.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComInterconnection::ComInterconnection()\r\n//-----------------------------------------------------------------------------\r\nComInterconnection::ComInterconnection() :\r\nInterconnection()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComInterconnection::ComInterconnection()\r\n//-----------------------------------------------------------------------------\r\nComInterconnection::ComInterconnection(QString const& name, QString const& displayName, QString const& description,\r\n                                       QSharedPointer<HierInterface> ref1, QSharedPointer<HierInterface> ref2):\r\nInterconnection()\r\n{\r\n    setName(name);\r\n    setDisplayName(displayName);\r\n    setDescription(description);\r\n\r\n    setInterface(ref1);\r\n    setInterface(ref2);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComInterconnection::ComInterconnection()\r\n//-----------------------------------------------------------------------------\r\nComInterconnection::ComInterconnection(ComInterconnection const& rhs) :\r\nInterconnection(rhs)\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComInterconnection::ComInterconnection()\r\n//-----------------------------------------------------------------------------\r\nComInterconnection::ComInterconnection(QDomNode& connectionNode) :\r\nInterconnection()\r\n{\r\n    QDomElement connectionElement = connectionNode.toElement();\r\n    if (!connectionElement.isNull())\r\n    {\r\n        setName(connectionElement.firstChildElement(QStringLiteral(\"ipxact:name\")).firstChild().nodeValue());\r\n        setDisplayName(connectionElement.firstChildElement(QStringLiteral(\"ipxact:displayName\")).firstChild().nodeValue());\r\n        setDescription(connectionElement.firstChildElement(QStringLiteral(\"ipxact:description\")).firstChild().nodeValue());\r\n\r\n        QDomNodeList interfaceList = connectionElement.elementsByTagName(QStringLiteral(\"kactus2:activeComInterface\"));\r\n        for (int interfaceIndex = 0; interfaceIndex < interfaceList.count(); ++interfaceIndex)\r\n        {\r\n            QDomNode activeInterfaceNode = interfaceList.at(interfaceIndex);\r\n            QDomNamedNodeMap startInterfaceAttributes = activeInterfaceNode.attributes();\r\n            QString componentReference = startInterfaceAttributes.namedItem(QStringLiteral(\"componentRef\")).nodeValue();\r\n            QString comReference = startInterfaceAttributes.namedItem(QStringLiteral(\"comRef\")).nodeValue();\r\n\r\n            QSharedPointer<ActiveInterface> comInterface (new ActiveInterface(componentReference, comReference));\r\n            setInterface(comInterface);\r\n        }\r\n\r\n        QDomElement hierInterfaceElement = connectionElement.firstChildElement(QStringLiteral(\"kactus2:hierComInterface\"));\r\n        if (!hierInterfaceElement.isNull())\r\n        {\r\n            QString comReference = hierInterfaceElement.attribute(QStringLiteral(\"comRef\"));\r\n            QSharedPointer<HierInterface> hierarchicalInterface (new HierInterface(comReference));\r\n            setInterface(hierarchicalInterface);\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComInterconnection::~ComInterconnection()\r\n//-----------------------------------------------------------------------------\r\nComInterconnection::~ComInterconnection()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComInterconnection::clone()\r\n//-----------------------------------------------------------------------------\r\nComInterconnection* ComInterconnection::clone() const\r\n{\r\n    return new ComInterconnection(*this);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComInterconnection::type()\r\n//-----------------------------------------------------------------------------\r\nQString ComInterconnection::type() const\r\n{\r\n    return QStringLiteral(\"kactus2:comConnection\");\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComConnection::write()\r\n//-----------------------------------------------------------------------------\r\nvoid ComInterconnection::write(QXmlStreamWriter& writer) const\r\n{\r\n    writer.writeStartElement(QStringLiteral(\"kactus2:comConnection\"));\r\n\r\n    writer.writeTextElement(QStringLiteral(\"ipxact:name\"), name());\r\n\r\n    CommonItemsWriter::writeDisplayName(writer, displayName());\r\n\r\n    CommonItemsWriter::writeDescription(writer, description());\r\n\r\n    writer.writeEmptyElement(QStringLiteral(\"kactus2:activeComInterface\"));\r\n    writer.writeAttribute(QStringLiteral(\"componentRef\"), getStartInterface()->getComponentReference());\r\n    writer.writeAttribute(QStringLiteral(\"comRef\"), getStartInterface()->getBusReference());\r\n\r\n    writeEndInterface(writer);\r\n\r\n    writer.writeEndElement(); // kactus2:comConnection\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComInterconnection::writeEndInterface()\r\n//-----------------------------------------------------------------------------\r\nvoid ComInterconnection::writeEndInterface(QXmlStreamWriter& writer) const\r\n{\r\n    QSharedPointer<ActiveInterface> activeEndInterface = getEndInterface().dynamicCast<ActiveInterface>();\r\n    if (activeEndInterface)\r\n    {\r\n        writer.writeEmptyElement(QStringLiteral(\"kactus2:activeComInterface\"));\r\n        writer.writeAttribute(QStringLiteral(\"componentRef\"), activeEndInterface->getComponentReference());\r\n    }\r\n    else\r\n    {\r\n        writer.writeEmptyElement(QStringLiteral(\"kactus2:hierComInterface\"));\r\n    }\r\n\r\n    writer.writeAttribute(QStringLiteral(\"comRef\"), getEndInterface()->getBusReference());\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComInterconnection::setInterface()\r\n//-----------------------------------------------------------------------------\r\nvoid ComInterconnection::setInterface(QSharedPointer<HierInterface> interfaceReference)\r\n{\r\n    QSharedPointer<ActiveInterface> activeInterface = interfaceReference.dynamicCast<ActiveInterface>();\r\n    if (activeInterface)\r\n    {\r\n        if (!getStartInterface())\r\n        {\r\n            setStartInterface(activeInterface);\r\n        }\r\n        else\r\n        {\r\n            if (!getActiveInterfaces()->isEmpty())\r\n            {\r\n                getActiveInterfaces()->clear();\r\n            }\r\n\r\n            getActiveInterfaces()->append(activeInterface);\r\n        }\r\n    }\r\n    else\r\n    {\r\n        if (!getHierInterfaces()->isEmpty())\r\n        {\r\n            getHierInterfaces()->clear();\r\n        }\r\n\r\n        getHierInterfaces()->append(interfaceReference);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComConnection::getInterface2()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<HierInterface> ComInterconnection::getEndInterface() const\r\n{\r\n    if (!getActiveInterfaces()->isEmpty())\r\n    {\r\n        return getActiveInterfaces()->first();\r\n    }\r\n    else if (!getHierInterfaces()->isEmpty())\r\n    {\r\n        return getHierInterfaces()->first();\r\n    }\r\n    else\r\n    {\r\n        return QSharedPointer<ActiveInterface>(new ActiveInterface());\r\n    }\r\n}\r\n"
  },
  {
    "path": "IPXACTmodels/kactusExtensions/ComInterconnection.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ComInterconnection.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 28.08.2015\r\n//\r\n// Description:\r\n// Class encapsulating communication connection data.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef COMINTERCONNECTION_H\r\n#define COMINTERCONNECTION_H\r\n\r\n#include <IPXACTmodels/Design/Interconnection.h>\r\n\r\n#include <IPXACTmodels/common/VendorExtension.h>\r\n\r\n#include <QDomNode>\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Class encapsulating API connection connection data.\r\n//-----------------------------------------------------------------------------\r\nclass IPXACTMODELS_EXPORT ComInterconnection : public Interconnection, public VendorExtension\r\n{\r\npublic:\r\n    /*!\r\n     *  Default constructor.\r\n     */\r\n    ComInterconnection();\r\n\r\n    /*!\r\n     *  Constructor which sets all the values as given.\r\n     *\r\n     *    @param [in] name         The name to set.\r\n     *    @param [in] displayName  The display name to set.\r\n     *    @param [in] description  The description to set.\r\n     *    @param [in] ref1         A reference to the first COM interface.\r\n     *    @param [in] ref2         A reference to the second COM interface.\r\n     */\r\n    ComInterconnection(QString const& name, QString const& displayName, QString const& description,\r\n                       QSharedPointer<HierInterface> ref1, QSharedPointer<HierInterface> ref2);\r\n\r\n    /*!\r\n     *  Copy constructor.\r\n     */\r\n    ComInterconnection(ComInterconnection const& rhs);\r\n\r\n    /*!\r\n     *  QDomNode constructor.\r\n     *\r\n     *    @param [in] connectionNode  The node containing the com connection.\r\n     */\r\n    ComInterconnection(QDomNode& connectionNode);\r\n\r\n    /*!\r\n     *  Destructor.\r\n     */\r\n    ~ComInterconnection();\r\n\r\n    /*!\r\n     *  Clone constructor.\r\n     */\r\n    virtual ComInterconnection* clone() const;\r\n\r\n    /*!\r\n     *  Gets the type of the extension.\r\n     *\r\n     *    @return The type of the extension.\r\n     */\r\n    virtual QString type() const;\r\n\r\n    /*!\r\n     *  Writes the contents to an XML stream.\r\n     */\r\n    virtual void write(QXmlStreamWriter& writer) const;\r\n\r\n    /*!\r\n     *  Set an interface. First active interface is set as the start interface.\r\n     *\r\n     *    @param [in] interfaceReference  The selected interface.\r\n     */\r\n    void setInterface(QSharedPointer<HierInterface> interfaceReference);\r\n\r\n    /*!\r\n     *  Returns the end interface.\r\n     *\r\n     *    @return Pointer to the end interface.\r\n     */\r\n    QSharedPointer<HierInterface> getEndInterface() const;\r\n\r\nprivate:\r\n\r\n    /*!\r\n     *  Write the end interface.\r\n     *\r\n     *    @param [in] writer  The writer used to write the end interface.\r\n     */\r\n    void writeEndInterface(QXmlStreamWriter& writer) const;\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n\r\n#endif // COMINTERCONNECTION_H\r\n"
  },
  {
    "path": "IPXACTmodels/kactusExtensions/ComInterface.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ComInterface.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Joni-Matti Maatta\r\n// Date: 5.4.2012\r\n//\r\n// Description:\r\n// COM interface class for defining properties of a specific COM interface\r\n// in a SW component.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"ComInterface.h\"\r\n\r\n#include <IPXACTmodels/common/CommonItemsReader.h>\r\n#include <IPXACTmodels/common/CommonItemsWriter.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComInterface::ComInterface()\r\n//-----------------------------------------------------------------------------\r\nComInterface::ComInterface() :\r\nNameGroup()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComInterface::ComInterface()\r\n//-----------------------------------------------------------------------------\r\nComInterface::ComInterface(ComInterface const& rhs) :\r\nNameGroup(rhs),\r\ncomType_(rhs.comType_),\r\ntransferType_(rhs.transferType_),\r\ndir_(rhs.dir_),\r\npropertyValues_(rhs.propertyValues_),\r\ncomImplementation_(rhs.comImplementation_),\r\ndefaultPos_(rhs.getDefaultPos())\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComInterface::ComInterface()\r\n//-----------------------------------------------------------------------------\r\nComInterface::ComInterface(QDomNode& node) :\r\nNameGroup()\r\n{\r\n    for (int i = 0; i < node.childNodes().count(); ++i)\r\n    {\r\n        QDomNode childNode = node.childNodes().at(i);\r\n\r\n        if (childNode.isComment())\r\n        {\r\n            continue;\r\n        }\r\n\r\n        if (childNode.nodeName() == QLatin1String(\"ipxact:name\"))\r\n        {\r\n            setName(childNode.firstChild().nodeValue());\r\n        }\r\n        else if (childNode.nodeName() == QLatin1String(\"ipxact:displayName\"))\r\n        {\r\n            setDisplayName(childNode.firstChild().nodeValue());\r\n        }\r\n        else if (childNode.nodeName() == QLatin1String(\"ipxact:shortDescription\"))\r\n        {\r\n            setShortDescription(childNode.firstChild().nodeValue());\r\n        }\r\n        else if (childNode.nodeName() == QLatin1String(\"ipxact:description\"))\r\n        {\r\n            setDescription(childNode.firstChild().nodeValue());\r\n        }\r\n        else if (childNode.nodeName() == QLatin1String(\"kactus2:comType\"))\r\n        {\r\n            comType_ = CommonItemsReader::parseVLNVAttributes(childNode, VLNV::COMDEFINITION);\r\n        }\r\n        else if (childNode.nodeName() == QLatin1String(\"kactus2:transferType\"))\r\n        {\r\n            transferType_ = childNode.childNodes().at(0).nodeValue();\r\n        }\r\n        else if (childNode.nodeName() == QLatin1String(\"kactus2:comDirection\"))\r\n        {\r\n            dir_ = DirectionTypes::str2Direction(childNode.childNodes().at(0).nodeValue(), DirectionTypes::INOUT);\r\n        }\r\n        else if (childNode.nodeName() == QLatin1String(\"kactus2:propertyValues\"))\r\n        {\r\n            parsePropertyValues(childNode);\r\n        }\r\n        else if (childNode.nodeName() == QLatin1String(\"kactus2:comImplementationRef\"))\r\n        {\r\n            comImplementation_ = CommonItemsReader::parseVLNVAttributes(childNode, VLNV::COMPONENT);\r\n        }\r\n        else if (childNode.nodeName() == QLatin1String(\"kactus2:position\"))\r\n        {\r\n            defaultPos_.parsePosition(childNode);\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComInterface::~ComInterface()\r\n//-----------------------------------------------------------------------------\r\nComInterface::~ComInterface()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComInterface::clone()\r\n//-----------------------------------------------------------------------------\r\nComInterface* ComInterface::clone() const\r\n{\r\n    return new ComInterface(*this);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComInterface::type()\r\n//-----------------------------------------------------------------------------\r\nQString ComInterface::type() const\r\n{\r\n    return QStringLiteral(\"kactus2:comInterface\");\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComInterface::write()\r\n//-----------------------------------------------------------------------------\r\nvoid ComInterface::write(QXmlStreamWriter& writer) const\r\n{\r\n    writer.writeStartElement(QStringLiteral(\"kactus2:comInterface\"));\r\n\r\n    writer.writeTextElement(QStringLiteral(\"ipxact:name\"), name());\r\n\r\n    CommonItemsWriter::writeDisplayName(writer, displayName());\r\n\r\n    CommonItemsWriter::writeDescription(writer, description());\r\n\r\n    // Write communication type, data type and communication direction.\r\n    writer.writeEmptyElement(QStringLiteral(\"kactus2:comType\"));\r\n    CommonItemsWriter::writeVLNVAttributes(writer, comType_);\r\n\r\n    writer.writeTextElement(QStringLiteral(\"kactus2:transferType\"), transferType_);\r\n    writer.writeTextElement(QStringLiteral(\"kactus2:comDirection\"), DirectionTypes::direction2Str(dir_));\r\n\r\n    writer.writeStartElement(QStringLiteral(\"kactus2:propertyValues\"));\r\n\r\n    // Write property values.\r\n    QMapIterator<QString, QString> iter(propertyValues_);\r\n\r\n    while (iter.hasNext())\r\n    {\r\n        iter.next();\r\n\r\n        writer.writeEmptyElement(QStringLiteral(\"kactus2:propertyValue\"));\r\n        writer.writeAttribute(QStringLiteral(\"name\"), iter.key());\r\n        writer.writeAttribute(QStringLiteral(\"value\"), iter.value());\r\n    }\r\n\r\n    writer.writeEndElement(); // kactus2:propertyValues\r\n\r\n\twriter.writeEmptyElement(QStringLiteral(\"kactus2:comImplementationRef\"));\r\n    CommonItemsWriter::writeVLNVAttributes(writer, comImplementation_);\r\n\r\n    if (getDefaultPos().isNull() == false)\r\n    {\r\n        defaultPos_.write(writer);\r\n    }\r\n\r\n    writer.writeEndElement(); // kactus2:comInterface\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComInterface::isValid()\r\n//-----------------------------------------------------------------------------\r\nbool ComInterface::isValid(QStringList& errorList, QString const& parentId) const\r\n{\r\n    QString const thisId = QObject::tr(\"COM interface '%1'\").arg(name());\r\n    bool valid = true;\r\n\r\n    if (name().isEmpty())\r\n    {\r\n        errorList.append(QObject::tr(\"No name specified for a COM interface in %1\").arg(parentId));\r\n        valid = false;\r\n    }\r\n\r\n    if (!comType_.isEmpty() && !comType_.isValid())\r\n    {\r\n        errorList.append(QObject::tr(\"Invalid COM type set in %1\").arg(thisId));\r\n        valid = false;\r\n    }\r\n\r\n    // Check for property values having no name.\r\n    QMapIterator<QString, QString> iter(propertyValues_);\r\n\r\n    while (iter.hasNext())\r\n    {\r\n        iter.next();\r\n\r\n        if (iter.key().isEmpty())\r\n        {\r\n            errorList.append(QObject::tr(\"No name specified for a property value in %1\").arg(thisId));\r\n            valid = false;\r\n        }\r\n    }\r\n\r\n\t if (!comImplementation_.isEmpty() && !comImplementation_.isValid()) {\r\n\t\t errorList.append(QObject::tr(\"Invalid COM implementation reference in %1\").arg(thisId));\r\n\t\t valid = false;\r\n\t }\r\n\r\n    return valid;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComInterface::isValid()\r\n//-----------------------------------------------------------------------------\r\nbool ComInterface::isValid() const\r\n{\r\n    if (name().isEmpty())\r\n    {\r\n        return false;\r\n    }\r\n\r\n    if (!comType_.isEmpty() && !comType_.isValid())\r\n    {\r\n        return false;\r\n    }\r\n\r\n    // Check for property values having no name.\r\n    QMapIterator<QString, QString> iter(propertyValues_);\r\n\r\n    while (iter.hasNext())\r\n    {\r\n        iter.next();\r\n\r\n        if (iter.key().isEmpty())\r\n        {\r\n            return false;\r\n        }\r\n    }\r\n\r\n\t if (!comImplementation_.isEmpty() && !comImplementation_.isValid()) {\r\n\t\t return false;\r\n\t }\r\n\r\n    return true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComInterface::setComType()\r\n//-----------------------------------------------------------------------------\r\nvoid ComInterface::setComType(VLNV const& vlnv, QList< QSharedPointer<ComProperty> > const* properties)\r\n{\r\n\tcomType_ = vlnv;\r\n\r\n\tif ( properties != nullptr )\r\n\t{\r\n\t\tfor (QSharedPointer<ComProperty const> prop : *properties)\r\n\t\t{\r\n\t\t\tpropertyValues_[prop->name()] = prop->getDefaultValue();\r\n\t\t}\r\n\t}\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComInterface::setTransferType()\r\n//-----------------------------------------------------------------------------\r\nvoid ComInterface::setTransferType(QString const& transferType)\r\n{\r\n    transferType_ = transferType;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComInterface::setDirection()\r\n//-----------------------------------------------------------------------------\r\nvoid ComInterface::setDirection(DirectionTypes::Direction dir)\r\n{\r\n    dir_ = dir;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComInterface::setPropertyValues()\r\n//-----------------------------------------------------------------------------\r\nvoid ComInterface::setPropertyValues(QMap<QString, QString> const& values)\r\n{\r\n    propertyValues_ = values;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComInterface::getComType()\r\n//-----------------------------------------------------------------------------\r\nVLNV const& ComInterface::getComType() const\r\n{\r\n    return comType_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComInterface::getTransferType()\r\n//-----------------------------------------------------------------------------\r\nQString const& ComInterface::getTransferType() const\r\n{\r\n    return transferType_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComInterface::getDirection()\r\n//-----------------------------------------------------------------------------\r\nDirectionTypes::Direction ComInterface::getDirection() const\r\n{\r\n    return dir_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComInterface::getPropertyValues()\r\n//-----------------------------------------------------------------------------\r\nQMap<QString, QString> const& ComInterface::getPropertyValues() const\r\n{\r\n    return propertyValues_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComInterface::operator=()\r\n//-----------------------------------------------------------------------------\r\nComInterface& ComInterface::operator=(ComInterface const& rhs)\r\n{\r\n    if (&rhs != this)\r\n    {\r\n        NameGroup::operator=(rhs);\r\n        comType_ = rhs.comType_;\r\n        dir_ = rhs.dir_;\r\n    }\r\n\r\n    return *this;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComInterface::parsePropertyValues()\r\n//-----------------------------------------------------------------------------\r\nvoid ComInterface::parsePropertyValues(QDomNode& node)\r\n{\r\n    for (int i = 0; i < node.childNodes().count(); ++i)\r\n    {\r\n        QDomNode propNode = node.childNodes().at(i);\r\n\r\n        if (propNode.nodeName() == QLatin1String(\"kactus2:propertyValue\"))\r\n        {\r\n            QString name = propNode.attributes().namedItem(QStringLiteral(\"name\")).nodeValue();\r\n            QString value = propNode.attributes().namedItem(QStringLiteral(\"value\")).nodeValue();\r\n\r\n            propertyValues_.insert(name, value);\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComInterface::getComImplementation()\r\n//-----------------------------------------------------------------------------\r\nconst VLNV& ComInterface::getComImplementation() const\r\n{\r\n    return comImplementation_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComInterface::setComImplementation()\r\n//-----------------------------------------------------------------------------\r\nvoid ComInterface::setComImplementation( const VLNV& implementationVLNV )\r\n{\r\n\tcomImplementation_ = implementationVLNV;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComInterface::setDefaultPos()\r\n//-----------------------------------------------------------------------------\r\nvoid ComInterface::setDefaultPos(QPointF const& pos)\r\n{\r\n    defaultPos_.setPosition(pos);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComInterface::getDefaultPos()\r\n//-----------------------------------------------------------------------------\r\nQPointF ComInterface::getDefaultPos() const\r\n{\r\n    return defaultPos_.position();\r\n}\r\n"
  },
  {
    "path": "IPXACTmodels/kactusExtensions/ComInterface.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ComInterface.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Joni-Matti Maatta\r\n// Date: 5.4.2012\r\n//\r\n// Description:\r\n// COM interface class for defining properties of a specific COM interface\r\n// in a SW component.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef COMINTERFACE_H\r\n#define COMINTERFACE_H\r\n\r\n#include <IPXACTmodels/common/DirectionTypes.h>\r\n#include <IPXACTmodels/common/NameGroup.h>\r\n\r\n#include <IPXACTmodels/ipxactmodels_global.h>\r\n#include <IPXACTmodels/common/VLNV.h>\r\n#include <IPXACTmodels/common/VendorExtension.h>\r\n\r\n#include \"Kactus2Position.h\"\r\n\r\n#include <QString>\r\n#include <QDomNode>\r\n#include <QXmlStreamWriter>\r\n#include <QMap>\r\n#include <QPointF>\r\n#include <QSharedPointer>\r\n\r\n#include <IPXACTmodels/kactusExtensions/ComProperty.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n//! COM interface class for defining properties of a specific COM interface\r\n//! in a SW component.\r\n//-----------------------------------------------------------------------------\r\nclass IPXACTMODELS_EXPORT ComInterface : public NameGroup, public VendorExtension\r\n{\r\npublic:\r\n    /*!\r\n     *  Default constructor.\r\n     */\r\n    ComInterface();\r\n\r\n    /*!\r\n     *  Copy constructor.\r\n     */\r\n    ComInterface(ComInterface const& rhs);\r\n\r\n    /*!\r\n     *  Constructor which reads the COM interface from an XML node.\r\n     *\r\n     *    @param [in] node The source XML node.\r\n     */\r\n    ComInterface(QDomNode& node);\r\n\r\n    /*!\r\n     *  Destructor.\r\n     */\r\n    ~ComInterface();\r\n\r\n    /*!\r\n     *  Copies the com interface.\r\n     *\r\n     *    @return The copied com interface.\r\n     */\r\n    virtual ComInterface* clone() const;\r\n\r\n    /*!\r\n     *  Get the type of the com interface.\r\n     *\r\n     *    @return The com interface type.\r\n     */\r\n    virtual QString type() const;\r\n\r\n    /*!\r\n     *  Writes the contents of the COM interface to an XML stream.\r\n     */\r\n    virtual void write(QXmlStreamWriter& writer) const;\r\n\r\n    /*!\r\n     *  Returns true if the contents of the COM interface are valid.\r\n     *\r\n     *    @param [out] errorList Error list which is appended with errors if found while validating.\r\n     *    @param [in]  parentId  The identifier of the containing component.\r\n     */\r\n    bool isValid(QStringList& errorList, QString const& parentId) const;\r\n\r\n    /*!\r\n     *  Returns true if the contents of the COM interface are valid.\r\n     */\r\n    bool isValid() const;\r\n\r\n    /*!\r\n     *  Sets the COM type.\r\n     *\r\n     *    @param [in] vlnv The COM definition VLNV.\r\n     */\r\n    void setComType(VLNV const& vlnv, QList< QSharedPointer<ComProperty> > const* properties = NULL);\r\n\r\n    /*!\r\n     *  Sets the transfer type.\r\n     *\r\n     *    @param [in] transferType The transfer type to set.\r\n     */\r\n    void setTransferType(QString const& transferType);\r\n\r\n    /*!\r\n     *  Sets the direction.\r\n     *\r\n     *    @param [in] dir The direction.\r\n     */\r\n    void setDirection(DirectionTypes::Direction dir);\r\n\r\n    /*!\r\n     *  Sets the property values.\r\n     *\r\n     *    @param [in] values The property values.\r\n     */\r\n    void setPropertyValues(QMap<QString, QString> const& values);\r\n\r\n    /*!\r\n     *  Sets the default position in the parent component's graphical representation.\r\n     *\r\n     *    @param [in] pos The position to set.\r\n     */\r\n    void setDefaultPos(QPointF const& pos);\r\n\r\n    /*!\r\n     *  Returns the COM type (COM definition VLNV).\r\n     */\r\n    VLNV const& getComType() const;\r\n\r\n    /*!\r\n     *  Returns the transfer type.\r\n     */\r\n    QString const& getTransferType() const;\r\n\r\n    /*!\r\n     *  Returns the direction.\r\n     */\r\n    DirectionTypes::Direction getDirection() const;\r\n\r\n    /*!\r\n     *  Returns the property values.\r\n     */\r\n    QMap<QString, QString> const& getPropertyValues() const;\r\n\r\n    /*!\r\n     *  Returns the default position in the parent component's graphical representation.\r\n     */\r\n    QPointF getDefaultPos() const;\r\n\r\n    /*!\r\n     *  Assignment operator.\r\n     */\r\n    ComInterface& operator=(ComInterface const& rhs);\r\n\r\n\t/*!\r\n     *  Get reference to the COM interface implementation driver.\r\n\t *\r\n     *    @return VLNV identifying the implementation driver.\r\n\t */\r\n\tconst VLNV& getComImplementation() const;\r\n\r\n\t/*!\r\n     *  Set the COM interface implementation driver.\r\n     *\r\n\t *    @param [in] implementationVLNV  Reference to the driver which implements the COM interface.\r\n\t */\r\n\tvoid setComImplementation(const VLNV& implementationVLNV);\r\n\r\nprivate:\r\n    /*!\r\n     *  Parses the property values from the given XML node.\r\n     *\r\n     *    @param [in] node The source XML node.\r\n     */\r\n    void parsePropertyValues(QDomNode& node);\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! The COM type (i.e. a VLNV reference to a COM definition).\r\n    VLNV comType_;\r\n\r\n    //! The transfer type that is transmitted through the interface.\r\n    QString transferType_;\r\n\r\n    //! Dependency direction.\r\n    DirectionTypes::Direction dir_ = DirectionTypes::INOUT;\r\n\r\n    //! The set property values.\r\n    QMap<QString, QString> propertyValues_;\r\n\r\n\t//! Reference to the implementation driver.\r\n\t VLNV comImplementation_;\r\n\r\n     //! The default position in the parent component's graphical representation (optional).\r\n     Kactus2Position defaultPos_ = Kactus2Position(QPoint());\r\n\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n\r\n#endif // COMINTERFACE_H\r\n"
  },
  {
    "path": "IPXACTmodels/kactusExtensions/ComProperty.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ComProperty.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Joni-Matti Maatta\r\n// Date: 2.4.2012\r\n//\r\n// Description:\r\n// Property class for communication definitions.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"ComProperty.h\"\r\n\r\n#include <IPXACTmodels/generaldeclarations.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComProperty::ComProperty()\r\n//-----------------------------------------------------------------------------\r\nComProperty::ComProperty()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComProperty::ComProperty()\r\n//-----------------------------------------------------------------------------\r\nComProperty::ComProperty(ComProperty const& rhs):\r\nname_(rhs.name_),\r\n    required_(rhs.required_),\r\n    type_(rhs.type_),\r\n    defaultValue_(rhs.defaultValue_),\r\n    description_(rhs.description_)\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComProperty::ComProperty()\r\n//-----------------------------------------------------------------------------\r\nComProperty::ComProperty(QDomNode const& node)\r\n{\r\n    name_ = node.attributes().namedItem(QStringLiteral(\"name\")).nodeValue();\r\n    required_ = General::str2Bool(node.attributes().namedItem(QStringLiteral(\"required\")).nodeValue(), false);\r\n    type_ = node.attributes().namedItem(QStringLiteral(\"propertyType\")).nodeValue();\r\n    defaultValue_ = node.attributes().namedItem(QStringLiteral(\"defaultValue\")).nodeValue();\r\n    description_ = node.attributes().namedItem(QStringLiteral(\"description\")).nodeValue();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComProperty::~ComProperty()\r\n//-----------------------------------------------------------------------------\r\nComProperty::~ComProperty()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComProperty::clone()\r\n//-----------------------------------------------------------------------------\r\nComProperty* ComProperty::clone() const\r\n{\r\n    return new ComProperty(*this);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComProperty::type()\r\n//-----------------------------------------------------------------------------\r\nQString ComProperty::type() const\r\n{\r\n    return QStringLiteral(\"kactus2:property\");\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComProperty::write()\r\n//-----------------------------------------------------------------------------\r\nvoid ComProperty::write(QXmlStreamWriter& writer) const\r\n{\r\n    writer.writeEmptyElement(QStringLiteral(\"kactus2:property\"));\r\n    writer.writeAttribute(QStringLiteral(\"name\"), name_);\r\n    writer.writeAttribute(QStringLiteral(\"required\"), General::bool2Str(required_));\r\n    writer.writeAttribute(QStringLiteral(\"propertyType\"), type_);\r\n    writer.writeAttribute(QStringLiteral(\"defaultValue\"), defaultValue_);\r\n    writer.writeAttribute(QStringLiteral(\"description\"), description_);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ApiFunctionParameter::findErrors()\r\n//-----------------------------------------------------------------------------\r\nvoid ComProperty::findErrors(QVector<QString>& errorList, QString const& parentId) const\r\n{\r\n    QString const thisId = QObject::tr(\"COM property '%1'\").arg(name_);\r\n\r\n    if (name_.isEmpty())\r\n    {\r\n        errorList.append(QObject::tr(\"No name specified for a COM property in %1\").arg(parentId));\r\n    }\r\n\r\n    if (type_.isEmpty())\r\n    {\r\n        errorList.append(QObject::tr(\"No type specified for %1\").arg(thisId));\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComProperty::validate()\r\n//-----------------------------------------------------------------------------\r\nbool ComProperty::validate() const\r\n{\r\n    return (!name_.isEmpty() && !type_.isEmpty());\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComProperty::setName()\r\n//-----------------------------------------------------------------------------\r\nvoid ComProperty::setName(QString const& name)\r\n{\r\n    name_ = name;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComProperty::setRequired()\r\n//-----------------------------------------------------------------------------\r\nvoid ComProperty::setRequired(bool required)\r\n{\r\n    required_ = required;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComProperty::setType()\r\n//-----------------------------------------------------------------------------\r\nvoid ComProperty::setType(QString const& type)\r\n{\r\n    type_ = type;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComProperty::setDefaultValue()\r\n//-----------------------------------------------------------------------------\r\nvoid ComProperty::setDefaultValue(QString const& defaultValue)\r\n{\r\n    defaultValue_ = defaultValue;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComProperty::setDescription()\r\n//-----------------------------------------------------------------------------\r\nvoid ComProperty::setDescription(QString const& description)\r\n{\r\n    description_ = description;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComProperty::name()\r\n//-----------------------------------------------------------------------------\r\nQString ComProperty::name() const\r\n{\r\n    return name_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComProperty::isRequired()\r\n//-----------------------------------------------------------------------------\r\nbool ComProperty::isRequired() const\r\n{\r\n    return required_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComProperty::getType()\r\n//-----------------------------------------------------------------------------\r\nQString ComProperty::getType() const\r\n{\r\n    return type_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComProperty::getDefaultValue()\r\n//-----------------------------------------------------------------------------\r\nQString ComProperty::getDefaultValue() const\r\n{\r\n    return defaultValue_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComProperty::getDescription()\r\n//-----------------------------------------------------------------------------\r\nQString ComProperty::getDescription() const\r\n{\r\n    return description_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComProperty::operator=()\r\n//-----------------------------------------------------------------------------\r\nComProperty& ComProperty::operator=(ComProperty const& rhs)\r\n{\r\n    if (&rhs != this)\r\n    {\r\n        name_ = rhs.name_;\r\n        required_ = rhs.required_;\r\n        type_ = rhs.type_;\r\n        defaultValue_ = rhs.defaultValue_;\r\n        description_ = rhs.description_;\r\n    }\r\n\r\n    return *this;\r\n}\r\n"
  },
  {
    "path": "IPXACTmodels/kactusExtensions/ComProperty.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ComProperty.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Joni-Matti Maatta\r\n// Date: 2.4.2012\r\n//\r\n// Description:\r\n// Property class for communication definitions.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef COMPROPERTY_H\r\n#define COMPROPERTY_H\r\n\r\n#include <IPXACTmodels/ipxactmodels_global.h>\r\n#include <IPXACTmodels/common/VendorExtension.h>\r\n\r\n#include <QString>\r\n#include <QDomNode>\r\n#include <QXmlStreamWriter>\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Property class for communication definitions.\r\n//-----------------------------------------------------------------------------\r\nclass IPXACTMODELS_EXPORT ComProperty : public VendorExtension\r\n{\r\npublic:\r\n    /*!\r\n     *  Default constructor.\r\n     */\r\n    ComProperty();\r\n\r\n    /*!\r\n     *  Copy constructor.\r\n     */\r\n    ComProperty(ComProperty const& rhs);\r\n\r\n    /*!\r\n     *  Constructor which reads the property from an XML node.\r\n     */\r\n    ComProperty(QDomNode const& node);\r\n\r\n    /*!\r\n     *  Destructor.\r\n     */\r\n    ~ComProperty();\r\n\r\n    /*!\r\n     *  Copy the com property.\r\n     *\r\n     *    @return The copied com property.\r\n     */\r\n    virtual ComProperty* clone() const;\r\n\r\n    /*!\r\n     *  Get the type of the com property extension.\r\n     *\r\n     *    @return The type of this extension.\r\n     */\r\n    virtual QString type() const;\r\n\r\n    /*!\r\n     *  Writes the contents of the property to an XML stream.\r\n     *\r\n     *    @param [in] write The XML stream writer.\r\n     */\r\n    virtual void write(QXmlStreamWriter& writer) const;\r\n\r\n    /*!\r\n     *  Returns true if the property contents are valid.\r\n     *\r\n     *    @param [out] errorList  The list of errors found in the contents.\r\n     *    @param [in]  parentId   The identifier of the containing COM definition.\r\n     */\r\n    void findErrors(QVector<QString>& errorList, QString const& parentId) const;\r\n\r\n    /*!\r\n     *  Returns true if the property contents are valid.\r\n     */\r\n    bool validate() const;\r\n\r\n    /*!\r\n     *  Sets the name of the property.\r\n     */\r\n    void setName(QString const& name);\r\n\r\n    /*!\r\n     *  Sets the property required/optional.\r\n     *\r\n     *    @param [in] required If true, the property is a required one; otherwise it is optional.\r\n     */\r\n    void setRequired(bool required);\r\n\r\n    /*!\r\n     *  Sets the property type.\r\n     *\r\n     *    @param [in] type The property type as a string.\r\n     */\r\n    void setType(QString const& type);\r\n\r\n    /*!\r\n     *  Sets the default value for the property.\r\n     *\r\n     *    @param [in] defaultValue The default value to set.\r\n     */\r\n    void setDefaultValue(QString const& defaultValue);\r\n\r\n    /*!\r\n     *  Sets the description of the property.\r\n     *\r\n     *    @param [in] description The description to set.\r\n     */\r\n    void setDescription(QString const& description);\r\n\r\n    /*!\r\n     *  Returns the name of the property.\r\n     */\r\n    QString name() const;\r\n\r\n    /*!\r\n     *  Returns true if the property is required.\r\n     */\r\n    bool isRequired() const;\r\n\r\n    /*!\r\n     *  Returns the property type.\r\n     */\r\n    QString getType() const;\r\n\r\n    /*!\r\n     *  Returns the default value for the property.\r\n     */\r\n    QString getDefaultValue() const;\r\n\r\n    /*!\r\n     *  Returns the description of the property.\r\n     */\r\n    QString getDescription() const;\r\n\r\n    /*!\r\n     *  Assignment operator.\r\n     */\r\n    ComProperty& operator=(ComProperty const& rhs);\r\n\r\nprivate:\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! The name of the property.\r\n    QString name_;\r\n\r\n    //! If true, the property is a required one.\r\n    bool required_ = true;\r\n\r\n    //! The property type.\r\n    QString type_ = QStringLiteral(\"string\");\r\n\r\n    //! The default value.\r\n    QString defaultValue_;\r\n\r\n    //! The property description.\r\n    QString description_;\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n\r\n#endif // COMPROPERTY_H\r\n"
  },
  {
    "path": "IPXACTmodels/kactusExtensions/ConnectionRoute.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ConnectionRoute.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Esko Pekkarinen\r\n// Date: 28.09.2015\r\n//\r\n// Description:\r\n// Vendor extension for storing connection routes in design.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"ConnectionRoute.h\"\r\n\r\n#include <QPointF>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ConnectionRoute::ConnectionRoute()\r\n//-----------------------------------------------------------------------------\r\nConnectionRoute::ConnectionRoute(QString const& connectionName) :\r\nname_(connectionName)\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ConnectionRoute::~ConnectionRoute()\r\n//-----------------------------------------------------------------------------\r\nConnectionRoute::~ConnectionRoute()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ConnectionRoute::ConnectionRoute()\r\n//-----------------------------------------------------------------------------\r\nConnectionRoute::ConnectionRoute(ConnectionRoute const& other) :\r\n    name_(other.name_),\r\n    offpage_(other.offpage_),\r\n    route_(other.route_)\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ConnectionRoute::clone()\r\n//-----------------------------------------------------------------------------\r\nVendorExtension* ConnectionRoute::clone() const\r\n{\r\n    return new ConnectionRoute(*this);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ConnectionRoute::type()\r\n//-----------------------------------------------------------------------------\r\nQString ConnectionRoute::type() const\r\n{\r\n    return QStringLiteral(\"kactus2:route\");\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ConnectionRoute::write()\r\n//-----------------------------------------------------------------------------\r\nvoid ConnectionRoute::write(QXmlStreamWriter& writer) const\r\n{\r\n    writer.writeStartElement(QStringLiteral(\"kactus2:route\"));\r\n    \r\n    writer.writeAttribute(QStringLiteral(\"kactus2:connRef\"), name());\r\n    if (isOffpage())\r\n    {\r\n        writer.writeAttribute(QStringLiteral(\"kactus2:offPage\"), QStringLiteral(\"true\"));\r\n    }\r\n    else\r\n    {\r\n        writer.writeAttribute(QStringLiteral(\"kactus2:offPage\"), QStringLiteral(\"false\"));\r\n    }\r\n\r\n    for (auto const& routePoint : route_)\r\n    {\r\n        writer.writeEmptyElement(QStringLiteral(\"kactus2:position\"));\r\n        writer.writeAttribute(QStringLiteral(\"x\"), QString::number(routePoint.x()));\r\n        writer.writeAttribute(QStringLiteral(\"y\"), QString::number(routePoint.y()));\r\n    }\r\n\r\n    writer.writeEndElement();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ConnectionRoute::setName()\r\n//-----------------------------------------------------------------------------\r\nvoid ConnectionRoute::setName(QString const& name)\r\n{\r\n    name_ = name;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ConnectionRoute::name()\r\n//-----------------------------------------------------------------------------\r\nQString ConnectionRoute::name() const\r\n{\r\n    return name_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ConnectionRoute::setOffpage()\r\n//-----------------------------------------------------------------------------\r\nvoid ConnectionRoute::setOffpage(bool offpage)\r\n{\r\n    offpage_ = offpage;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ConnectionRoute::isOffpage()\r\n//-----------------------------------------------------------------------------\r\nbool ConnectionRoute::isOffpage() const\r\n{\r\n    return offpage_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ConnectionRoute::addPoint()\r\n//-----------------------------------------------------------------------------\r\nvoid ConnectionRoute::addPoint(QPointF const& point)\r\n{\r\n    route_.append(point);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ConnectionRoute::setRoute()\r\n//-----------------------------------------------------------------------------\r\nvoid ConnectionRoute::setRoute(QList<QPointF> const& route)\r\n{\r\n    route_ = route;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ConnectionRoute::getRoute()\r\n//-----------------------------------------------------------------------------\r\nQList<QPointF> ConnectionRoute::getRoute() const\r\n{\r\n    return route_;\r\n}\r\n"
  },
  {
    "path": "IPXACTmodels/kactusExtensions/ConnectionRoute.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ConnectionRoute.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Esko Pekkarinen\r\n// Date: 28.09.2015\r\n//\r\n// Description:\r\n// Vendor extension for storing connection routes in design.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef CONNECTIONROUTE_H\r\n#define CONNECTIONROUTE_H\r\n\r\n#include <IPXACTmodels/ipxactmodels_global.h>\r\n\r\n#include <IPXACTmodels/common/VendorExtension.h>\r\n\r\n#include <QXmlStreamWriter>\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Vendor extension for storing connection routes in design.\r\n//-----------------------------------------------------------------------------\r\nclass IPXACTMODELS_EXPORT ConnectionRoute : public VendorExtension\r\n{\r\npublic:\r\n    //! The constructor.\r\n    ConnectionRoute(QString const& connectionName);\r\n\r\n    //! The destructor.\r\n    ~ConnectionRoute() final;\r\n\r\n    ConnectionRoute(ConnectionRoute const& other);\r\n\r\n\r\n    // Disable assignment.\r\n    ConnectionRoute& operator=(ConnectionRoute const& rhs) = delete;\r\n\r\n    /*!\r\n     *  Clones the vendor extension.\r\n     *\r\n     *    @return The clone copy of the vendor extension.\r\n     */\r\n    virtual VendorExtension* clone() const;\r\n    \r\n    /*!\r\n     *  Returns a type identifier for the vendor extension.\r\n     *\r\n     *    @return A type identifier of the vendor extension.\r\n     */\r\n    virtual QString type() const;\r\n    \r\n    /*!\r\n     *  Writes the vendor extension to XML.\r\n     *\r\n     *    @param [in] writer   The writer used for writing the XML.\r\n     */\r\n    virtual void write(QXmlStreamWriter& writer) const;\r\n\r\n    /*!\r\n     *  Sets the connection name.\r\n     *\r\n     *    @param [in] name   The name of the connection.\r\n     */\r\n    void setName(QString const& name);\r\n\r\n    /*!\r\n     *  Gets the name of the connection the route is stored for.\r\n     *\r\n     *    @return The name of the route represented by the item.\r\n     */\r\n    QString  name() const;\r\n\r\n    /*!\r\n     *  Sets the connection to offpage mode or normal mode.\r\n     *\r\n     *    @param [in] offpage   Offpage mode to set.\r\n     */\r\n    void setOffpage(bool offpage);\r\n\r\n    /*!\r\n     *  Checks if the connection is set for offpage mode.\r\n     *\r\n     *    @return True, if the connection is in offpage mode, otherwise false.\r\n     */\r\n    bool isOffpage() const;\r\n\r\n    /*!\r\n     *  Adds a route point in the connection.\r\n     *\r\n     *    @param [in] point   The point to add.\r\n     */\r\n    void addPoint(QPointF const& point);\r\n\r\n    /*!\r\n     *  Sets the route points for the connection.\r\n     *\r\n     *    @param [in] route   The route points to set.\r\n     */\r\n    void setRoute(QList<QPointF> const& route);\r\n\r\n    /*!\r\n     *  Gets the route points for the connection.\r\n     *\r\n     *    @return The route points.\r\n     */\r\n    QList<QPointF> getRoute() const;\r\n\r\nprivate:\r\n\r\n    //! The name of the connection.\r\n    QString name_;\r\n\r\n    //! Whether or not the connection is drawn in off-page mode.\r\n    bool offpage_ = false;\r\n\r\n    //! The corner points on the route.\r\n    QList<QPointF> route_;\r\n};\r\n\r\n#endif // CONNECTIONROUTE_H"
  },
  {
    "path": "IPXACTmodels/kactusExtensions/FileDependency.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: FileDependency.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Joni-Matti Maatta\r\n// Date: 21.01.2013\r\n//\r\n// Description:\r\n// File dependency class.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"FileDependency.h\"\r\n\r\n#include <IPXACTmodels/generaldeclarations.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileDependency::FileDependency()\r\n//-----------------------------------------------------------------------------\r\nFileDependency::FileDependency()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileDependency::FileDependency()\r\n//-----------------------------------------------------------------------------\r\nFileDependency::FileDependency(FileDependency const& rhs) :\r\nfile1_(rhs.file1_),\r\nfile2_(rhs.file2_),\r\ndesc_(rhs.desc_),\r\nlocked_(rhs.locked_),\r\nbidirectional_(rhs.bidirectional_),\r\nmanual_(rhs.manual_),\r\nstatus_(rhs.status_)\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileDependency::FileDependency()\r\n//-----------------------------------------------------------------------------\r\nFileDependency::FileDependency(QDomNode const& node)\r\n{\r\n    for (int i = 0; i < node.childNodes().count(); ++i)\r\n    {\r\n        QDomNode childNode = node.childNodes().at(i);\r\n\r\n        if (childNode.isComment())\r\n        {\r\n            continue;\r\n        }\r\n\r\n        if (childNode.nodeName() == QLatin1String(\"kactus2:fileRef1\"))\r\n        {\r\n            file1_ = childNode.childNodes().at(0).nodeValue();\r\n        }\r\n        else if (childNode.nodeName() == QLatin1String(\"kactus2:fileRef2\"))\r\n        {\r\n            file2_ = childNode.childNodes().at(0).nodeValue();\r\n        }\r\n        else if (childNode.nodeName() == QLatin1String(\"ipxact:description\"))\r\n        {\r\n            desc_ = childNode.childNodes().at(0).nodeValue();\r\n        }\r\n    }\r\n\r\n    locked_ = General::str2Bool(node.attributes().namedItem(QStringLiteral(\"kactus2:locked\")).nodeValue(), false);\r\n    bidirectional_ = General::str2Bool(node.attributes().namedItem(QStringLiteral(\"kactus2:bidirectional\")).nodeValue(), false);\r\n    manual_ = General::str2Bool(node.attributes().namedItem(QStringLiteral(\"kactus2:manual\")).nodeValue(), false);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileDependency::~FileDependency()\r\n//-----------------------------------------------------------------------------\r\nFileDependency::~FileDependency()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileDependency::clone()\r\n//-----------------------------------------------------------------------------\r\nFileDependency* FileDependency::clone() const\r\n{\r\n    return new FileDependency(*this);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileDependency::type()\r\n//-----------------------------------------------------------------------------\r\nQString FileDependency::type() const\r\n{\r\n    return QStringLiteral(\"kactus2:fileDependency\");\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileDependency::write()\r\n//-----------------------------------------------------------------------------\r\nvoid FileDependency::write(QXmlStreamWriter& writer) const\r\n{\r\n    writer.writeStartElement(QStringLiteral(\"kactus2:fileDependency\"));\r\n    writer.writeAttribute(QStringLiteral(\"manual\"), General::bool2Str(manual_));\r\n    writer.writeAttribute(QStringLiteral(\"bidirectional\"), General::bool2Str(bidirectional_));\r\n    writer.writeAttribute(QStringLiteral(\"locked\"), General::bool2Str(locked_));\r\n\r\n    writer.writeTextElement(QStringLiteral(\"kactus2:fileRef1\"), file1_);\r\n    writer.writeTextElement(QStringLiteral(\"kactus2:fileRef2\"), file2_);\r\n    writer.writeTextElement(QStringLiteral(\"ipxact:description\"), desc_);\r\n\r\n    writer.writeEndElement(); // kactus2:fileDependency\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileDependency::setFile1()\r\n//-----------------------------------------------------------------------------\r\nvoid FileDependency::setFile1(QString const& filename)\r\n{\r\n    file1_ = filename;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileDependency::setFile2()\r\n//-----------------------------------------------------------------------------\r\nvoid FileDependency::setFile2(QString const& filename)\r\n{\r\n    file2_ = filename;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileDependency::setDescription()\r\n//-----------------------------------------------------------------------------\r\nvoid FileDependency::setDescription(QString const& desc)\r\n{\r\n    desc_ = desc;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileDependency::setLocked()\r\n//-----------------------------------------------------------------------------\r\nvoid FileDependency::setLocked(bool locked)\r\n{\r\n    locked_ = locked;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileDependency::setBidirectional()\r\n//-----------------------------------------------------------------------------\r\nvoid FileDependency::setBidirectional(bool bidirectional)\r\n{\r\n    bidirectional_ = bidirectional;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileDependency::setManual()\r\n//-----------------------------------------------------------------------------\r\nvoid FileDependency::setManual(bool manual)\r\n{\r\n    manual_ = manual;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileDependency::getFile1()\r\n//-----------------------------------------------------------------------------\r\nQString const& FileDependency::getFile1() const\r\n{\r\n    return file1_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileDependency::getFile2()\r\n//-----------------------------------------------------------------------------\r\nQString const& FileDependency::getFile2() const\r\n{\r\n    return file2_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileDependency::getDescription()\r\n//-----------------------------------------------------------------------------\r\nQString const& FileDependency::getDescription() const\r\n{\r\n    return desc_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileDependency::isLocked()\r\n//-----------------------------------------------------------------------------\r\nbool FileDependency::isLocked() const\r\n{\r\n    return locked_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileDependency::isBidirectional()\r\n//-----------------------------------------------------------------------------\r\nbool FileDependency::isBidirectional() const\r\n{\r\n    return bidirectional_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileDependency::isManual()\r\n//-----------------------------------------------------------------------------\r\nbool FileDependency::isManual() const\r\n{\r\n    return manual_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileDependency::operator=()\r\n//-----------------------------------------------------------------------------\r\nFileDependency& FileDependency::operator=(FileDependency const& rhs)\r\n{\r\n    if (&rhs != this)\r\n    {\r\n        file1_ = rhs.file1_;\r\n        file2_ = rhs.file2_;\r\n        desc_ = rhs.desc_;\r\n        locked_ = rhs.locked_;\r\n        bidirectional_ = rhs.bidirectional_;\r\n        manual_ = rhs.manual_;\r\n        status_ = rhs.status_;\r\n    }\r\n\r\n    return *this;\r\n}\r\n\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileDependency::reverse()\r\n//-----------------------------------------------------------------------------\r\nvoid FileDependency::reverse()\r\n{\r\n    qSwap(file1_, file2_);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileDependency::setStatus()\r\n//-----------------------------------------------------------------------------\r\nvoid FileDependency::setStatus(Status status)\r\n{\r\n    status_ = status;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileDependency::getStatus()\r\n//-----------------------------------------------------------------------------\r\nFileDependency::Status FileDependency::getStatus() const\r\n{\r\n    return status_;\r\n}\r\n"
  },
  {
    "path": "IPXACTmodels/kactusExtensions/FileDependency.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: FileDependency.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Joni-Matti Maatta\r\n// Date: 19.01.2013\r\n//\r\n// Description:\r\n// File dependency class.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef FILEDEPENDENCY_H\r\n#define FILEDEPENDENCY_H\r\n\r\n#include <IPXACTmodels/ipxactmodels_global.h>\r\n#include <IPXACTmodels/common/VendorExtension.h>\r\n\r\n#include <QString>\r\n#include <QDomNode>\r\n#include <QXmlStreamWriter>\r\n\r\n//-----------------------------------------------------------------------------\r\n//! File dependency class.\r\n//-----------------------------------------------------------------------------\r\nclass IPXACTMODELS_EXPORT FileDependency : public VendorExtension\r\n{\r\npublic:\r\n    //-----------------------------------------------------------------------------\r\n    //! Status enumeration.\r\n    //-----------------------------------------------------------------------------\r\n    enum Status\r\n    {\r\n        STATUS_UNCHANGED = 0,\r\n        STATUS_ADDED,\r\n        STATUS_REMOVED\r\n    };\r\n\r\n    /*!\r\n     *  Constructor.\r\n     */\r\n    FileDependency();\r\n\r\n    /*!\r\n     *  Copy constructor.\r\n     */\r\n    FileDependency(FileDependency const& rhs);\r\n\r\n    /*!\r\n     *  Constructor which reads the file dependency from an XML node.\r\n     *\r\n     *    @param [in] node The source XML node.\r\n     */\r\n    FileDependency(QDomNode const& node);\r\n    \r\n    /*!\r\n     *  Destructor.\r\n     */\r\n    ~FileDependency();\r\n\r\n    /*!\r\n     *  Clone the file dependency.\r\n     *\r\n     *    @return The cloned file dependency.\r\n     */\r\n    virtual FileDependency* clone() const;\r\n\r\n    /*!\r\n     *  Get the type of this extension.\r\n     *\r\n     *    @return The type of this extension.\r\n     */\r\n    virtual QString type() const;\r\n\r\n    /*!\r\n     *  Writes the contents of the file dependency to an XML stream.\r\n     *\r\n     *    @param [in] write The XML stream writer.\r\n     */\r\n    virtual void write(QXmlStreamWriter& writer) const;\r\n\r\n    /*!\r\n     *  Reverses the dependency.\r\n     */\r\n    void reverse();\r\n\r\n    /*!\r\n     *  Sets the 'from' file.\r\n     *\r\n     *    @param [in] filename The name of the file.\r\n     */\r\n    void setFile1(QString const& filename);\r\n\r\n    /*!\r\n     *  Sets the 'to' file.\r\n     *\r\n     *    @param [in] filename The name of the file.\r\n     */\r\n    void setFile2(QString const& filename);\r\n\r\n    /*!\r\n     *  Sets the description.\r\n     *\r\n     *    @param [in] desc The description to set.\r\n     */\r\n    void setDescription(QString const& desc);\r\n\r\n    /*!\r\n     *  Sets the dependency locked/unlocked.\r\n     *\r\n     *    @param [in] locked If true, the dependency is set locked; false for unlocked.\r\n     */\r\n    void setLocked(bool locked);\r\n\r\n    /*!\r\n     *  Sets the dependency bidirectional.\r\n     *\r\n     *    @param [in] bidiretional If true, the dependency is set as bidirectional (two-way);\r\n     *                               false for one-way dependency.\r\n     */\r\n    void setBidirectional(bool bidirectional);\r\n\r\n    /*!\r\n     *  Sets the dependency manual.\r\n     *\r\n     *    @param [in] manual If true, the dependency is treated as a manual dependency;\r\n     *                         otherwise it is treated as an automatic (generated) one.\r\n     */\r\n    void setManual(bool manual);\r\n\r\n    /*!\r\n     *  Sets the status of the dependency.\r\n     *\r\n     *    @param [in] status The status to set.\r\n     */\r\n    void setStatus(Status status);\r\n\r\n    /*!\r\n     *  Returns the name of the 'from' file.\r\n     */\r\n    QString const& getFile1() const;\r\n\r\n    /*!\r\n     *  Returns the name of the 'to' file.\r\n     */\r\n    QString const& getFile2() const;\r\n\r\n    /*!\r\n     *  Returns the description.\r\n     */\r\n    QString const& getDescription() const;\r\n\r\n    /*!\r\n     *  Returns true if the dependency is locked.\r\n     */\r\n    bool isLocked() const;\r\n\r\n    /*!\r\n     *  Returns true if the dependency is bidirectional.\r\n     */\r\n    bool isBidirectional() const;\r\n\r\n    /*!\r\n     *  Returns true if the dependency is manual.\r\n     */\r\n    bool isManual() const;\r\n\r\n    /*!\r\n     *  Returns the status.\r\n     */\r\n    Status getStatus() const;\r\n\r\n    /*!\r\n     *  Assignment operator.\r\n     */\r\n    FileDependency& operator=(FileDependency const& rhs);\r\n\r\n\r\nprivate:\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! The name of the first (from) file.\r\n    QString file1_;\r\n\r\n    //! The name of the second (to) file.\r\n    QString file2_;\r\n\r\n    //! The dependency description.\r\n    QString desc_;\r\n\r\n    //! If true, the dependency is locked and cannot be modified.\r\n    bool locked_ = false;\r\n\r\n    //! If true, the dependency is bidirectional.\r\n    bool bidirectional_ = false;\r\n\r\n    //! If true, the dependency is a manually created one.\r\n    bool manual_ = false;\r\n\r\n    //! The status of the dependency.\r\n    Status status_ = STATUS_UNCHANGED;\r\n};\r\n\r\n#endif // FILEDEPENDENCY_H\r\n"
  },
  {
    "path": "IPXACTmodels/kactusExtensions/HierApiInterconnection.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: HierApiInterconnection.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 28.08.2015\r\n//\r\n// Description:\r\n// Hierarchical API connection.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"HierApiInterconnection.h\"\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HierApiInterconnection::HierApiInterconnection ()\r\n//-----------------------------------------------------------------------------\r\nHierApiInterconnection::HierApiInterconnection() :\r\nInterconnection(),\r\ntopInterfaceRef_(),\r\nposition_(),\r\ndirection_()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HierApiInterconnection::HierApiInterconnection()\r\n//-----------------------------------------------------------------------------\r\nHierApiInterconnection::HierApiInterconnection(QString const& name, QString const& displayName,\r\n    QString const& description, QString const& interfaceRef, QSharedPointer<ActiveInterface> ref,\r\n    QPointF const& position, QVector2D const& direction, QList<QPointF> const& route) :\r\nInterconnection(name, ref, displayName, description),\r\ntopInterfaceRef_(interfaceRef),\r\nposition_(position),\r\ndirection_(direction)\r\n{\r\n    setRoute(route);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HierApiInterconnection::HierApiInterconnection()\r\n//-----------------------------------------------------------------------------\r\nHierApiInterconnection::HierApiInterconnection(HierApiInterconnection const& rhs) :\r\nInterconnection(rhs),\r\ntopInterfaceRef_(rhs.topInterfaceRef_),\r\nposition_(rhs.position_),\r\ndirection_(rhs.position_)\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HierApiInterconnection::HierApiInterconnection()\r\n//-----------------------------------------------------------------------------\r\nHierApiInterconnection::HierApiInterconnection(QDomNode& connectionNode) :\r\nInterconnection(),\r\ntopInterfaceRef_(),\r\nposition_(),\r\ndirection_()\r\n{\r\n    setName(connectionNode.firstChildElement(QStringLiteral(\"ipxact:name\")).firstChild().nodeValue());\r\n    setDisplayName(connectionNode.firstChildElement(QStringLiteral(\"ipxact:displayName\")).firstChild().nodeValue());\r\n    setDescription(connectionNode.firstChildElement(QStringLiteral(\"ipxact:description\")).firstChild().nodeValue());\r\n\r\n    QDomNamedNodeMap connectionAttributes = connectionNode.attributes();\r\n    setTopInterfaceRef(connectionAttributes.namedItem(QStringLiteral(\"interfaceRef\")).nodeValue());\r\n\r\n    QDomElement apiInterfaceElement = connectionNode.firstChildElement(QStringLiteral(\"kactus2:activeApiInterface\"));\r\n    QDomNamedNodeMap interfaceAttributes = apiInterfaceElement.attributes();\r\n    QString interfaceComponentRef = interfaceAttributes.namedItem(QStringLiteral(\"componentRef\")).nodeValue();\r\n    QString interfaceApiRef = interfaceAttributes.namedItem(QStringLiteral(\"apiRef\")).nodeValue();\r\n    QSharedPointer<ActiveInterface> newApiInterface(new ActiveInterface(interfaceComponentRef, interfaceApiRef));\r\n    setInterface(newApiInterface);\r\n\r\n    QDomElement positionElement = connectionNode.firstChildElement(QStringLiteral(\"kactus2:position\"));\r\n    QDomNamedNodeMap positionAttributers = positionElement.attributes();\r\n    int positionX = positionAttributers.namedItem(QStringLiteral(\"x\")).nodeValue().toInt();\r\n    int positionY = positionAttributers.namedItem(QStringLiteral(\"y\")).nodeValue().toInt();\r\n    setPosition(QPointF(positionX, positionY));\r\n\r\n    QDomElement directionElement = connectionNode.firstChildElement(QStringLiteral(\"kactus2:direction\"));\r\n    QDomNamedNodeMap directionAttributes = directionElement.attributes();\r\n    int directionX = directionAttributes.namedItem(QStringLiteral(\"x\")).nodeValue().toInt();\r\n    int directionY = directionAttributes.namedItem(QStringLiteral(\"y\")).nodeValue().toInt();\r\n    setDirection(QVector2D(directionX, directionY));\r\n\r\n    QDomElement routeElement = connectionNode.firstChildElement(QStringLiteral(\"kactus2:route\"));\r\n    if (!routeElement.isNull())\r\n    {\r\n        setOffPage(routeElement.attribute(QStringLiteral(\"kactus2:offPage\")) == QLatin1String(\"true\"));\r\n\r\n        QList<QPointF> newRoute;\r\n\r\n        QDomNodeList positionList = routeElement.childNodes();\r\n        for (int i = 0; i < positionList.count(); ++i)\r\n        {\r\n            QDomNode routePositionNode = positionList.at(i);\r\n            QDomNamedNodeMap routePositionAttributes = routePositionNode.attributes();\r\n            int routePositionX = routePositionAttributes.namedItem(QStringLiteral(\"x\")).nodeValue().toInt();\r\n            int routePositionY = routePositionAttributes.namedItem(QStringLiteral(\"y\")).nodeValue().toInt();\r\n            newRoute.append(QPointF(routePositionX, routePositionY));\r\n        }\r\n\r\n        setRoute(newRoute);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HierApiInterconnection::HierApiInterconnection()\r\n//-----------------------------------------------------------------------------\r\nHierApiInterconnection::~HierApiInterconnection()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HierApiInterconnection::clone()\r\n//-----------------------------------------------------------------------------\r\nHierApiInterconnection* HierApiInterconnection::clone() const\r\n{\r\n    return new HierApiInterconnection(*this);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HierApiInterconnection::type()\r\n//-----------------------------------------------------------------------------\r\nQString HierApiInterconnection::type() const\r\n{\r\n    return QStringLiteral(\"kactus2:hierApiDependency\");\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HierApiInterconnection::write()\r\n//-----------------------------------------------------------------------------\r\nvoid HierApiInterconnection::write(QXmlStreamWriter& writer) const\r\n{\r\n    writer.writeStartElement(QStringLiteral(\"kactus2:hierApiDependency\"));\r\n    writer.writeAttribute(QStringLiteral(\"interfaceRef\"), getTopInterfaceRef());\r\n\r\n    writer.writeTextElement(QStringLiteral(\"ipxact:name\"), name());\r\n    writer.writeTextElement(QStringLiteral(\"ipxact:displayName\"), displayName());\r\n    writer.writeTextElement(QStringLiteral(\"ipxact:description\"), description());\r\n\r\n    writer.writeEmptyElement(QStringLiteral(\"kactus2:activeApiInterface\"));\r\n    writer.writeAttribute(QStringLiteral(\"componentRef\"), getInterface()->getComponentReference());\r\n    writer.writeAttribute(QStringLiteral(\"apiRef\"), getInterface()->getBusReference());\r\n    \r\n    writePosition(writer);\r\n    writeVectorDirection(writer);\r\n\r\n    if (!getRoute().isEmpty())\r\n    {\r\n        writer.writeStartElement(QStringLiteral(\"kactus2:route\"));\r\n\r\n        if (isOffPage())\r\n        {\r\n            writer.writeAttribute(QStringLiteral(\"kactus2:offPage\"), QStringLiteral(\"true\"));\r\n        }\r\n        else\r\n        {\r\n            writer.writeAttribute(QStringLiteral(\"kactus2:offPage\"), QStringLiteral(\"false\"));\r\n        }\r\n\r\n        for (QPointF const& point : getRoute())\r\n        {\r\n            writer.writeEmptyElement(QStringLiteral(\"kactus2:position\"));\r\n            writer.writeAttribute(QStringLiteral(\"x\"), QString::number(int(point.x())));\r\n            writer.writeAttribute(QStringLiteral(\"y\"), QString::number(int(point.y())));\r\n        }\r\n\r\n        writer.writeEndElement();\r\n    }\r\n\r\n    writer.writeEndElement(); // kactus2:hierApiDependency\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HierApiInterconnection::setTopInterfaceRef()\r\n//-----------------------------------------------------------------------------\r\nvoid HierApiInterconnection::setTopInterfaceRef(QString const& interfaceRef)\r\n{\r\n    topInterfaceRef_ = interfaceRef;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HierApiInterconnection::setInterface()\r\n//-----------------------------------------------------------------------------\r\nvoid HierApiInterconnection::setInterface(QSharedPointer<ActiveInterface> ref)\r\n{\r\n    setStartInterface(ref);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HierApiInterconnection::getTopInterfaceRef()\r\n//-----------------------------------------------------------------------------\r\nQString const& HierApiInterconnection::getTopInterfaceRef() const\r\n{\r\n    return topInterfaceRef_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HierApiInterconnection::getInterface()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<ActiveInterface> HierApiInterconnection::getInterface() const\r\n{\r\n    return getStartInterface();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HierApiInterconnection::getPosition()\r\n//-----------------------------------------------------------------------------\r\nQPointF const& HierApiInterconnection::getPosition() const\r\n{\r\n    return position_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HierApiInterconnection::getDirection()\r\n//-----------------------------------------------------------------------------\r\nQVector2D const& HierApiInterconnection::getDirection() const\r\n{\r\n    return direction_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HierApiInterconnection::operator=()\r\n//-----------------------------------------------------------------------------\r\nHierApiInterconnection& HierApiInterconnection::operator=(HierApiInterconnection const& other)\r\n{\r\n    if (&other != this)\r\n    {\r\n        Interconnection::operator=(other);\r\n        topInterfaceRef_ = other.topInterfaceRef_;\r\n        position_ = other.position_;\r\n        direction_ = other.direction_;\r\n    }\r\n\r\n    return *this;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HierApiInterconnection::writePosition()\r\n//-----------------------------------------------------------------------------\r\nvoid HierApiInterconnection::writePosition(QXmlStreamWriter& writer) const\r\n{\r\n    writer.writeEmptyElement(QStringLiteral(\"kactus2:position\"));\r\n    writer.writeAttribute(QStringLiteral(\"x\"), QString::number(int(position_.x())));\r\n    writer.writeAttribute(QStringLiteral(\"y\"), QString::number(int(position_.y())));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HierApiInterconnection::writeVectorDirection()\r\n//-----------------------------------------------------------------------------\r\nvoid HierApiInterconnection::writeVectorDirection(QXmlStreamWriter& writer) const\r\n{\r\n    writer.writeEmptyElement(QStringLiteral(\"kactus2:direction\"));\r\n    writer.writeAttribute(QStringLiteral(\"x\"), QString::number(int(direction_.x())));\r\n    writer.writeAttribute(QStringLiteral(\"y\"), QString::number(int(direction_.y())));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HierApiInterconnection::setPosition()\r\n//-----------------------------------------------------------------------------\r\nvoid HierApiInterconnection::setPosition(QPointF const& newPosition)\r\n{\r\n    position_ = newPosition;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HierApiInterconnection::setDirection()\r\n//-----------------------------------------------------------------------------\r\nvoid HierApiInterconnection::setDirection(QVector2D const& newDirection)\r\n{\r\n    direction_ = newDirection;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HierApiInterconnection::setRoute()\r\n//-----------------------------------------------------------------------------\r\nvoid HierApiInterconnection::setRoute(QList<QPointF> newRoute)\r\n{\r\n    getInterface()->setRoute(newRoute);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HierApiInterconnection::getRoute()\r\n//-----------------------------------------------------------------------------\r\nQList<QPointF> HierApiInterconnection::getRoute() const\r\n{\r\n    return getInterface()->getRoute();\r\n}"
  },
  {
    "path": "IPXACTmodels/kactusExtensions/HierApiInterconnection.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: HierApiInterconnection.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 28.08.2015\r\n//\r\n// Description:\r\n// Hierarchical API connection.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef HIERAPIINTERCONNECTION_H\r\n#define HIERAPIINTERCONNECTION_H\r\n\r\n#include <QPointF>\r\n#include <QVector2D>\r\n\r\n#include <IPXACTmodels/Design/Interconnection.h>\r\n#include <IPXACTmodels/common/VendorExtension.h>\r\n\r\n#include <QDomNode>\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Class encapsulating API dependency connection data.\r\n//-----------------------------------------------------------------------------\r\nclass IPXACTMODELS_EXPORT HierApiInterconnection : public Interconnection, public VendorExtension\r\n{\r\npublic:\r\n    /*!\r\n     *  Default constructor.\r\n     */\r\n    HierApiInterconnection();\r\n\r\n    /*!\r\n     *  Constructor which sets all the values as given.\r\n     *\r\n     *    @param [in] name          The name to set.\r\n     *    @param [in] displayName   The display name to set.\r\n     *    @param [in] description   The description to set.\r\n     *    @param [in] interfaceRef  Name reference to an API interface in the top-level component.\r\n     *    @param [in] ref           The interface reference to a contained SW component instance.\r\n     *    @param [in] position      The position of the top-level interface in the design diagram.\r\n     *    @param [in] direction     The direction of the top-level interface in the design diagram.\r\n     *    @param [in] route         The connection route.\r\n     */\r\n    HierApiInterconnection(QString const& name, QString const& displayName, QString const& description,\r\n                      QString const& interfaceRef,\r\n                      QSharedPointer<ActiveInterface> ref,\r\n                      QPointF const& position, QVector2D const& direction,\r\n                      QList<QPointF> const& route);\r\n\r\n    /*!\r\n     *  Copy constructor.\r\n     */\r\n    HierApiInterconnection(HierApiInterconnection const& rhs);\r\n\r\n    /*!\r\n     *  QDomNode constructor.\r\n     *\r\n     *    @param [in] connectionNode  The node containing the connection.\r\n     */\r\n    HierApiInterconnection(QDomNode& connectionNode);\r\n\r\n    /*!\r\n     *  Destructor.\r\n     */\r\n    ~HierApiInterconnection();\r\n\r\n    /*!\r\n     *  The clone constructor.\r\n     */\r\n    virtual HierApiInterconnection* clone() const;\r\n\r\n    /*!\r\n     *  Get the type of the extension.\r\n     *\r\n     *    @return The type of the extension.\r\n     */\r\n    virtual QString type() const;\r\n\r\n    /*!\r\n     *  Writes the contents to an XML stream.\r\n     */\r\n    virtual void write(QXmlStreamWriter& writer) const;\r\n\r\n\t/*! \\brief Check if the hierarchical API dependency is in valid state.\r\n\t *\r\n\t * \\param errorList The string list to add the possible error messages to.\r\n\t * \\param instanceNames The HW/SW instance names contained in the containing design.\r\n\t * \\param parentId The identifier for the design containing the dependencies.\r\n\t *\r\n\t * \\return True if the API dependency is in valid state.\r\n\t*/\r\n\t//bool isValid(QStringList& errorList, QStringList const& instanceNames,\r\n\t//\tQString const& parentId) const;\r\n\r\n\t/*! \\brief Check if the hierarchical API dependency is in valid state.\r\n\t *\r\n\t * \\param instanceNames The HW/SW instance names contained in the containing design.\r\n\t *\r\n\t * \\return True if the API dependency is in valid state.\r\n\t*/\r\n\t//bool isValid(const QStringList& instanceNames) const;\r\n\r\n    /*!\r\n     *  Sets the top-level API interface reference.\r\n     *\r\n     *    @param [in] interfaceRef    Name reference to an API interface in the top-level component.\r\n     */\r\n    void setTopInterfaceRef(QString const& interfaceRef);\r\n\r\n    /*!\r\n     *  Sets the interface reference to an API interface in a contained SW component instance.\r\n     *\r\n     *    @param [in] ref     The interface reference.\r\n     */\r\n    void setInterface(QSharedPointer<ActiveInterface> ref);\r\n\r\n    /*!\r\n     *  Returns the name reference to an API interface in the top-level component.\r\n     *\r\n     *    @return The name of the referenced API interface in the top-level component.\r\n     */\r\n    QString const& getTopInterfaceRef() const;\r\n\r\n    /*!\r\n     *  Returns the interface reference to an API interface in a contained SW component instance.\r\n     *\r\n     *    @return The used interface.\r\n     */\r\n    QSharedPointer<ActiveInterface> getInterface() const;\r\n\r\n    /*!\r\n     *  Returns the position of the interface in the top-level design diagram.\r\n     */\r\n    QPointF const& getPosition() const;\r\n\r\n    /*!\r\n     *  Returns the direction of the interface in the top-level design diagram.\r\n     */\r\n    QVector2D const& getDirection() const;\r\n\r\n    /*!\r\n     *  Set the position of the interface.\r\n     *\r\n     *    @param [in] newPosition     The new position for the interface.\r\n     */\r\n    void setPosition(QPointF const& newPosition);\r\n\r\n    /*!\r\n     *  Set the direction of the interface.\r\n     *\r\n     *    @param [in] newDirection    The new direction of the interface.\r\n     */\r\n    void setDirection(QVector2D const& newDirection);\r\n\r\n    /*!\r\n     *  Assignment operator.\r\n     */\r\n    HierApiInterconnection& operator=(HierApiInterconnection const& rhs);\r\n\r\n    /*!\r\n     *  Set a route for the connection.\r\n     *\r\n     *    @param [in] newRoute    The new route.\r\n     */\r\n    void setRoute(QList<QPointF> newRoute);\r\n\r\n    /*!\r\n     *  Get the route for the connection.\r\n     *\r\n     *    @return A list of positions determining the route.\r\n     */\r\n    QList<QPointF> getRoute() const;\r\n\r\nprivate:\r\n\r\n    /*!\r\n     *  Writes the position of the hierarchical interface.\r\n     *\r\n     *    @param [in] writer  The selected XML writer.\r\n     */\r\n    void writePosition(QXmlStreamWriter& writer) const;\r\n\r\n    /*!\r\n     *  Writes the direction of the hierarchical interface.\r\n     *\r\n     *    @param [in] writer   [Description].\r\n     */\r\n    void writeVectorDirection(QXmlStreamWriter& writer) const;\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! The interface reference in the top-level component.\r\n    QString topInterfaceRef_;\r\n\r\n    //! The position of the top-level interface in the design diagram.\r\n    QPointF position_;\r\n\r\n    //! The direction of the top-level interface in the design diagram.\r\n    QVector2D direction_;\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n\r\n#endif // HIERAPIINTERCONNECTION_H\r\n"
  },
  {
    "path": "IPXACTmodels/kactusExtensions/HierComInterconnection.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: HierComInterconnection.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 28.8.2015\r\n//\r\n// Description:\r\n// Hierarchical COM connection.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"HierComInterconnection.h\"\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HierComInterconnection::HierComInterconnection()\r\n//-----------------------------------------------------------------------------\r\nHierComInterconnection::HierComInterconnection() :\r\nInterconnection(),\r\ntopInterfaceRef_(),\r\nposition_(),\r\ndirection_()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HierComInterconnection::HierComInterconnection()\r\n//-----------------------------------------------------------------------------\r\nHierComInterconnection::HierComInterconnection(QString const& name, QString const& displayName,\r\n    QString const& description, QString const& interfaceRef, QSharedPointer<ActiveInterface> ref,\r\n    QPointF const& position, QVector2D const& direction, QList<QPointF> const& route) :\r\nInterconnection(name, ref, displayName, description),\r\ntopInterfaceRef_(interfaceRef),\r\nposition_(position),\r\ndirection_(direction)\r\n{\r\n    setRoute(route);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HierComInterconnection::HierComInterconnection()\r\n//-----------------------------------------------------------------------------\r\nHierComInterconnection::HierComInterconnection(HierComInterconnection const& rhs) :\r\nInterconnection(rhs),\r\ntopInterfaceRef_(rhs.topInterfaceRef_),\r\nposition_(rhs.position_),\r\ndirection_(rhs.direction_)\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HierComInterconnection::HierComInterconnection()\r\n//-----------------------------------------------------------------------------\r\nHierComInterconnection::HierComInterconnection(QDomNode& connectionNode) :\r\nInterconnection(),\r\ntopInterfaceRef_(),\r\nposition_(),\r\ndirection_()\r\n{\r\n    setName(connectionNode.firstChildElement(QStringLiteral(\"ipxact:name\")).firstChild().nodeValue());\r\n    setDisplayName(connectionNode.firstChildElement(QStringLiteral(\"ipxact:displayName\")).firstChild().nodeValue());\r\n    setDescription(connectionNode.firstChildElement(QStringLiteral(\"ipxact:description\")).firstChild().nodeValue());\r\n\r\n    QDomNamedNodeMap connectionAttributes = connectionNode.attributes();\r\n    setTopInterfaceRef(connectionAttributes.namedItem(QStringLiteral(\"interfaceRef\")).nodeValue());\r\n\r\n    QDomElement comInterfaceElement = connectionNode.firstChildElement(QStringLiteral(\"kactus2:activeComInterface\"));\r\n    QDomNamedNodeMap interfaceAttributes = comInterfaceElement.attributes();\r\n    QString interfaceComponentRef = interfaceAttributes.namedItem(QStringLiteral(\"componentRef\")).nodeValue();\r\n    QString interfaceApiRef = interfaceAttributes.namedItem(QStringLiteral(\"comRef\")).nodeValue();\r\n    QSharedPointer<ActiveInterface> newApiInterface(new ActiveInterface(interfaceComponentRef, interfaceApiRef));\r\n    setInterface(newApiInterface);\r\n\r\n    QDomElement positionElement = connectionNode.firstChildElement(QStringLiteral(\"kactus2:position\"));\r\n    int positionX = positionElement.attribute(QStringLiteral(\"x\")).toInt();\r\n    int positionY = positionElement.attribute(QStringLiteral(\"y\")).toInt();\r\n    setPosition(QPointF(positionX, positionY));\r\n\r\n    QDomElement directionElement = connectionNode.firstChildElement(QStringLiteral(\"kactus2:direction\"));\r\n    int directionX = directionElement.attribute(QStringLiteral(\"x\")).toInt();\r\n    int directionY = directionElement.attribute(QStringLiteral(\"y\")).toInt();\r\n    setDirection(QVector2D(directionX, directionY));\r\n\r\n    QDomElement routeElement = connectionNode.firstChildElement(QStringLiteral(\"kactus2:route\"));\r\n    if (!routeElement.isNull())\r\n    {\r\n        QList<QPointF> newRoute;\r\n        if (routeElement.attribute(QStringLiteral(\"kactus2:offPage\")) == QLatin1String(\"true\"))\r\n        {\r\n            setOffPage(true);\r\n        }\r\n        else\r\n        {\r\n            setOffPage(false);\r\n        }\r\n\r\n        QDomNodeList positionList = routeElement.childNodes();\r\n        for (int i = 0; i < positionList.count(); ++i)\r\n        {\r\n            QDomNode routePositionNode = positionList.at(i);\r\n            QDomNamedNodeMap routePositionAttributes = routePositionNode.attributes();\r\n            int routePositionX = routePositionAttributes.namedItem(QStringLiteral(\"x\")).nodeValue().toInt();\r\n            int routePositionY = routePositionAttributes.namedItem(QStringLiteral(\"y\")).nodeValue().toInt();\r\n            newRoute.append(QPointF(routePositionX, routePositionY));\r\n        }\r\n\r\n        setRoute(newRoute);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HierComInterconnection::~HierComInterconnection()\r\n//-----------------------------------------------------------------------------\r\nHierComInterconnection::~HierComInterconnection()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HierComInterconnection::clone()\r\n//-----------------------------------------------------------------------------\r\nHierComInterconnection* HierComInterconnection::clone() const\r\n{\r\n    return new HierComInterconnection(*this);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HierComInterconnection::type()\r\n//-----------------------------------------------------------------------------\r\nQString HierComInterconnection::type() const\r\n{\r\n    return QStringLiteral(\"kactus2:hierComConnection\");\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HierComInterconnection::write()\r\n//-----------------------------------------------------------------------------\r\nvoid HierComInterconnection::write(QXmlStreamWriter& writer) const\r\n{\r\n    writer.writeStartElement(QStringLiteral(\"kactus2:hierComConnection\"));\r\n    writer.writeAttribute(QStringLiteral(\"interfaceRef\"), topInterfaceRef_);\r\n\r\n    writer.writeTextElement(QStringLiteral(\"ipxact:name\"), name());\r\n    writer.writeTextElement(QStringLiteral(\"ipxact:displayName\"), displayName());\r\n    writer.writeTextElement(QStringLiteral(\"ipxact:description\"), description());\r\n\r\n    writer.writeEmptyElement(QStringLiteral(\"kactus2:activeComInterface\"));\r\n    writer.writeAttribute(QStringLiteral(\"componentRef\"), getInterface()->getComponentReference());\r\n    writer.writeAttribute(QStringLiteral(\"comRef\"), getInterface()->getBusReference());\r\n\r\n    writePosition(writer);\r\n    writeVectorDirection(writer);\r\n\r\n    if (!getRoute().isEmpty())\r\n    {\r\n        writer.writeStartElement(QStringLiteral(\"kactus2:route\"));\r\n\r\n        if (isOffPage())\r\n        {\r\n            writer.writeAttribute(QStringLiteral(\"offPage\"), QStringLiteral(\"true\"));\r\n        }\r\n        else\r\n        {\r\n            writer.writeAttribute(QStringLiteral(\"offPage\"), QStringLiteral(\"false\"));\r\n        }\r\n\r\n        for (QPointF const& point : getRoute())\r\n        {\r\n            writer.writeEmptyElement(QStringLiteral(\"kactus2:position\"));\r\n            writer.writeAttribute(QStringLiteral(\"x\"), QString::number(int(point.x())));\r\n            writer.writeAttribute(QStringLiteral(\"y\"), QString::number(int(point.y())));\r\n        }\r\n\r\n        writer.writeEndElement();\r\n    }\r\n\r\n    writer.writeEndElement(); // kactus2:hierComConnection\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HierComInterconnection::setInterface()\r\n//-----------------------------------------------------------------------------\r\nvoid HierComInterconnection::setInterface(QSharedPointer<ActiveInterface> ref)\r\n{\r\n    setStartInterface(ref);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HierComInterconnection::setTopInterfaceRef()\r\n//-----------------------------------------------------------------------------\r\nvoid HierComInterconnection::setTopInterfaceRef(QString const& interfaceRef)\r\n{\r\n    topInterfaceRef_ = interfaceRef;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HierComInterconnection::getTopInterfaceRef()\r\n//-----------------------------------------------------------------------------\r\nQString const& HierComInterconnection::getTopInterfaceRef() const\r\n{\r\n    return topInterfaceRef_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HierComInterconnection::getInterface()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<ActiveInterface> HierComInterconnection::getInterface() const\r\n{\r\n    return getStartInterface();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HierComInterconnection::getPosition()\r\n//-----------------------------------------------------------------------------\r\nQPointF const& HierComInterconnection::getPosition() const\r\n{\r\n    return position_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HierComInterconnection::getDirection()\r\n//-----------------------------------------------------------------------------\r\nQVector2D const& HierComInterconnection::getDirection() const\r\n{\r\n    return direction_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HierComInterconnection::operator=()\r\n//-----------------------------------------------------------------------------\r\nHierComInterconnection& HierComInterconnection::operator=(HierComInterconnection const& other)\r\n{\r\n    if (&other != this)\r\n    {\r\n        Interconnection::operator=(other);\r\n        topInterfaceRef_ = other.topInterfaceRef_;\r\n        position_ = other.position_;\r\n        direction_ = other.direction_;\r\n    }\r\n\r\n    return *this;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HierApiDependency::writePosition()\r\n//-----------------------------------------------------------------------------\r\nvoid HierComInterconnection::writePosition(QXmlStreamWriter& writer) const\r\n{\r\n    writer.writeEmptyElement(QStringLiteral(\"kactus2:position\"));\r\n    writer.writeAttribute(QStringLiteral(\"x\"), QString::number(int(position_.x())));\r\n    writer.writeAttribute(QStringLiteral(\"y\"), QString::number(int(position_.y())));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HierApiDependency::writeVectorDirection()\r\n//-----------------------------------------------------------------------------\r\nvoid HierComInterconnection::writeVectorDirection(QXmlStreamWriter& writer) const\r\n{\r\n    writer.writeEmptyElement(QStringLiteral(\"kactus2:direction\"));\r\n    writer.writeAttribute(QStringLiteral(\"x\"), QString::number(int(direction_.x())));\r\n    writer.writeAttribute(QStringLiteral(\"y\"), QString::number(int(direction_.y())));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HierComInterconnection::setPosition()\r\n//-----------------------------------------------------------------------------\r\nvoid HierComInterconnection::setPosition(QPointF const& newPosition)\r\n{\r\n    position_ = newPosition;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HierComInterconnection::setDirection()\r\n//-----------------------------------------------------------------------------\r\nvoid HierComInterconnection::setDirection(QVector2D const& newDirection)\r\n{\r\n    direction_ = newDirection;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HierComInterconnection::setRoute()\r\n//-----------------------------------------------------------------------------\r\nvoid HierComInterconnection::setRoute(QList<QPointF> newRoute)\r\n{\r\n    getInterface()->setRoute(newRoute);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HierComInterconnection::getRoute()\r\n//-----------------------------------------------------------------------------\r\nQList<QPointF> HierComInterconnection::getRoute() const\r\n{\r\n    return getInterface()->getRoute();\r\n}"
  },
  {
    "path": "IPXACTmodels/kactusExtensions/HierComInterconnection.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: HierComInterconnection.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 28.8.2015\r\n//\r\n// Description:\r\n// Hierarchical COM connection.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef HIERCOMINTERCONNECTION_H\r\n#define HIERCOMINTERCONNECTION_H\r\n\r\n#include <IPXACTmodels/Design/Interconnection.h>\r\n\r\n#include <IPXACTmodels/common/VendorExtension.h>\r\n\r\n#include <QVector2D>\r\n#include <QDomNode>\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Class encapsulating COM dependency connection data.\r\n//-----------------------------------------------------------------------------\r\nclass IPXACTMODELS_EXPORT HierComInterconnection: public Interconnection, public VendorExtension\r\n{\r\npublic:\r\n    /*!\r\n     *  Default constructor.\r\n     */\r\n    HierComInterconnection();\r\n\r\n    /*!\r\n     *  Constructor which sets all the values as given.\r\n     *\r\n     *    @param [in] name          The name to set.\r\n     *    @param [in] displayName   The display name to set.\r\n     *    @param [in] description   The description to set.\r\n     *    @param [in] interfaceRef  Name reference to an COM interface in the top-level component.\r\n     *    @param [in] ref           The interface reference to a contained SW component instance.\r\n     *    @param [in] position      The position of the top-level interface in the design diagram.\r\n     *    @param [in] direction     The direction of the top-level interface in the design diagram.\r\n     *    @param [in] route         The connection route.\r\n     */\r\n    HierComInterconnection(QString const& name, QString const& displayName, QString const& description,\r\n                      QString const& interfaceRef,\r\n                      QSharedPointer<ActiveInterface> ref,\r\n                      QPointF const& position, QVector2D const& direction,\r\n                      QList<QPointF> const& route);\r\n\r\n    /*!\r\n     *  Copy constructor.\r\n     */\r\n    HierComInterconnection(HierComInterconnection const& rhs);\r\n\r\n    /*!\r\n     *  The QDomNode constructor.\r\n     *\r\n     *    @param [in] connectionNode  The node containing the hierarchical com connection.\r\n     */\r\n    HierComInterconnection(QDomNode& connectionNode);\r\n\r\n    /*!\r\n     *  Destructor.\r\n     */\r\n    ~HierComInterconnection();\r\n\r\n    /*!\r\n     *  Clone constructor.\r\n     */\r\n    virtual HierComInterconnection* clone() const;\r\n\r\n    /*!\r\n     *  Get the type of the extension.\r\n     *\r\n     *    @return The type of the extension.\r\n     */\r\n    virtual QString type() const;\r\n\r\n    /*!\r\n     *  Writes the contents to an XML stream.\r\n     */\r\n    virtual void write(QXmlStreamWriter& writer) const;\r\n\r\n\t/*! \\brief Check if the hierarchical COM connection is in valid state.\r\n\t *\r\n\t * \\param errorList The string list to contain the possible error messages.\r\n\t * \\param instanceNames The names of the HW/SW instances in the parent design.\r\n\t * \\param parentId The identifier of the containing design.\r\n\t *\r\n\t * \\return True if the hierarchical COM connection is in valid state.\r\n\t*/\r\n\t//bool isValid(QStringList& errorList, QStringList const& instanceNames,\r\n    //             QString const& parentId) const;\r\n\r\n\t/*! \\brief Check if the hierarchical COM connection is in valid state.\r\n\t *\r\n\t * \\param instanceNames The names of the HW/SW instances in the parent design.\r\n\t *\r\n\t * \\return True if the hierarchical COM connection is in valid state.\r\n\t*/\r\n\t//bool isValid(const QStringList& instanceNames) const;\r\n\r\n    /*!\r\n     *  Sets the top-level COM interface reference.\r\n     *\r\n     *    @param [in] interfaceRef Name reference to an COM interface in the top-level component.\r\n     */\r\n    void setTopInterfaceRef(QString const& interfaceRef);\r\n\r\n    /*!\r\n     *  Sets the interface reference to an COM interface in a contained SW component instance.\r\n     *\r\n     *    @param [in] ref The interface reference.\r\n     */\r\n    void setInterface(QSharedPointer<ActiveInterface> ref);\r\n\r\n    /*!\r\n     *  Returns the name reference to an COM interface in the top-level component.\r\n     */\r\n    QString const& getTopInterfaceRef() const;\r\n\r\n    /*!\r\n     *  Returns the interface reference to an COM interface in a contained SW component instance.\r\n     */\r\n    QSharedPointer<ActiveInterface> getInterface() const;\r\n\r\n    /*!\r\n     *  Returns the position of the interface in the top-level design diagram.\r\n     */\r\n    QPointF const& getPosition() const;\r\n\r\n    /*!\r\n     *  Returns the direction of the interface in the top-level design diagram.\r\n     */\r\n    QVector2D const& getDirection() const;\r\n\r\n    /*!\r\n     *  Set the position of the interface.\r\n     *\r\n     *    @param [in] newPosition     The new position for the interface.\r\n     */\r\n    void setPosition(QPointF const& newPosition);\r\n\r\n    /*!\r\n     *  Set the direction of the interface.\r\n     *\r\n     *    @param [in] newDirection    The new direction for the interface.\r\n     */\r\n    void setDirection(QVector2D const& newDirection);\r\n\r\n    /*!\r\n     *  Assignment operator.\r\n     */\r\n    HierComInterconnection& operator=(HierComInterconnection const& other);\r\n\r\n    /*!\r\n     *  Set a route for the connection.\r\n     *\r\n     *    @param [in] newRoute    The new route.\r\n     */\r\n    void setRoute(QList<QPointF> newRoute);\r\n\r\n    /*!\r\n     *  Get the route for the connection.\r\n     *\r\n     *    @return A list of positions determining the route.\r\n     */\r\n    QList<QPointF> getRoute() const;\r\n\r\nprivate:\r\n\r\n    /*!\r\n     *  Write the position of the hierarchical com interface.\r\n     *\r\n     *    @param [in] xmlWriter   The used XML writer.\r\n     */\r\n    void writePosition(QXmlStreamWriter& xmlWriter) const;\r\n\r\n    /*!\r\n     *  Write the direction of the hierarchical com interface.\r\n     *\r\n     *    @param [in] xmlWriter   The used XML writer.\r\n     */\r\n    void writeVectorDirection(QXmlStreamWriter& xmlWriter) const;\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! The interface reference in the top-level component.\r\n    QString topInterfaceRef_;\r\n\r\n    //! The position of the top-level interface in the design diagram.\r\n    QPointF position_;\r\n\r\n    //! The direction of the top-level interface in the design diagram.\r\n    QVector2D direction_;\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n\r\n#endif // HIERCOMINTERCONNECTION_H\r\n"
  },
  {
    "path": "IPXACTmodels/kactusExtensions/InterfaceGraphicsData.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: InterfaceGraphicsData.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 24.02.2016\r\n//\r\n// Description:\r\n// Interface graphics class for defining properties of graphical interfaces in designs.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"InterfaceGraphicsData.h\"\r\n\r\n#include <IPXACTmodels/kactusExtensions/Kactus2Position.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: InterfaceGraphicsData::InterfaceGraphicsData()\r\n//-----------------------------------------------------------------------------\r\nInterfaceGraphicsData::InterfaceGraphicsData(QString const& name, QPointF position, QVector2D direction):\r\nname_(name),\r\npositionExtension_(new Kactus2Position(position)),\r\ndirection_(direction)\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: InterfaceGraphicsData::InterfaceGraphics()\r\n//-----------------------------------------------------------------------------\r\nInterfaceGraphicsData::InterfaceGraphicsData(const InterfaceGraphicsData& other):\r\nname_(other.name_),\r\npositionExtension_(other.positionExtension_->clone()),\r\ndirection_(other.direction_)\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: InterfaceGraphicsData::InterfaceGraphicsData()\r\n//-----------------------------------------------------------------------------\r\nInterfaceGraphicsData::InterfaceGraphicsData(QDomNode& node):\r\nname_(),\r\npositionExtension_(),\r\ndirection_()\r\n{\r\n    QDomElement nameElement = node.firstChildElement(QStringLiteral(\"kactus2:name\"));\r\n    if (!nameElement.isNull())\r\n    {\r\n        setName(nameElement.nodeValue());\r\n    }\r\n\r\n    QDomElement positionElement = node.firstChildElement(QStringLiteral(\"kactus2:position\"));\r\n    if (!positionElement.isNull())\r\n    {\r\n        int positionX = positionElement.attribute(QStringLiteral(\"x\")).toInt();\r\n        int positionY = positionElement.attribute(QStringLiteral(\"y\")).toInt();\r\n\r\n        QPointF loadPosition(positionX, positionY);\r\n        positionExtension_ = QSharedPointer<Kactus2Position> (new Kactus2Position(loadPosition));\r\n    }\r\n\r\n    QDomElement directionElement = node.firstChildElement(QStringLiteral(\"kactus2:direction\"));\r\n    if (!directionElement.isNull())\r\n    {\r\n        int directionX = directionElement.attribute(QStringLiteral(\"x\")).toInt();\r\n        int directionY = directionElement.attribute(QStringLiteral(\"y\")).toInt();\r\n\r\n        QVector2D loadDirection(directionX, directionY);\r\n        setDirection(loadDirection);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: InterfaceGraphicsData::~InterfaceGraphicsData()\r\n//-----------------------------------------------------------------------------\r\nInterfaceGraphicsData::~InterfaceGraphicsData()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: InterfaceGraphicsData::clone()\r\n//-----------------------------------------------------------------------------\r\nInterfaceGraphicsData* InterfaceGraphicsData::clone() const\r\n{\r\n    return new InterfaceGraphicsData(*this);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: InterfaceGraphicsData::operator=()\r\n//-----------------------------------------------------------------------------\r\nInterfaceGraphicsData& InterfaceGraphicsData::operator=(InterfaceGraphicsData const& other)\r\n{\r\n    if (&other != this)\r\n    {\r\n        name_ = other.name_;\r\n        direction_ = other.direction_;\r\n\r\n        positionExtension_.clear();\r\n        positionExtension_ = QSharedPointer<Kactus2Position>(other.positionExtension_->clone());\r\n    }\r\n\r\n    return *this;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: InterfaceGraphicsData::type()\r\n//-----------------------------------------------------------------------------\r\nQString InterfaceGraphicsData::type() const\r\n{\r\n    return QStringLiteral(\"kactus2:interfaceGraphics\");\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: InterfaceGraphicsData::write()\r\n//-----------------------------------------------------------------------------\r\nvoid InterfaceGraphicsData::write(QXmlStreamWriter& writer) const\r\n{\r\n    writer.writeStartElement(type());\r\n\r\n    writer.writeTextElement(QStringLiteral(\"kactus2:name\"), name_);\r\n\r\n    positionExtension_->write(writer);\r\n\r\n    writer.writeEmptyElement(QStringLiteral(\"kactus2:direction\"));\r\n    writer.writeAttribute(QStringLiteral(\"x\"), QString::number(direction_.x()));\r\n    writer.writeAttribute(QStringLiteral(\"y\"), QString::number(direction_.y()));\r\n\r\n    writer.writeEndElement(); // kactus2:interfaceGraphics\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: InterfaceGraphicsData::setName()\r\n//-----------------------------------------------------------------------------\r\nvoid InterfaceGraphicsData::setName(QString const& newName)\r\n{\r\n    name_ = newName;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: InterfaceGraphicsData::getName()\r\n//-----------------------------------------------------------------------------\r\nQString InterfaceGraphicsData::getName() const\r\n{\r\n    return name_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: InterfaceGraphicsData::setPosition()\r\n//-----------------------------------------------------------------------------\r\nvoid InterfaceGraphicsData::setPosition(QPointF const& newPosition)\r\n{\r\n    positionExtension_->setPosition(newPosition);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: InterfaceGraphicsData::getPosition()\r\n//-----------------------------------------------------------------------------\r\nQPointF InterfaceGraphicsData::getPosition() const\r\n{\r\n    return positionExtension_->position();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: InterfaceGraphicsData::hasPosition()\r\n//-----------------------------------------------------------------------------\r\nbool InterfaceGraphicsData::hasPosition() const\r\n{\r\n    return positionExtension_ && !positionExtension_->position().isNull();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: InterfaceGraphicsData::setDirection()\r\n//-----------------------------------------------------------------------------\r\nvoid InterfaceGraphicsData::setDirection(QVector2D const& newDirection)\r\n{\r\n    direction_ = newDirection;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: InterfaceGraphicsData::getDirection()\r\n//-----------------------------------------------------------------------------\r\nQVector2D InterfaceGraphicsData::getDirection() const\r\n{\r\n    return direction_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: InterfaceGraphicsData::hasDirection()\r\n//-----------------------------------------------------------------------------\r\nbool InterfaceGraphicsData::hasDirection() const\r\n{\r\n    return !direction_.isNull();\r\n}\r\n"
  },
  {
    "path": "IPXACTmodels/kactusExtensions/InterfaceGraphicsData.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: InterfaceGraphicsData.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 24.02.2016\r\n//\r\n// Description:\r\n// Interface graphics class for defining properties of graphical interfaces in designs.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef INTERFACEGRAPHICSDATA_H\r\n#define INTERFACEGRAPHICSDATA_H\r\n\r\n#include <IPXACTmodels/common/VendorExtension.h>\r\n\r\n// #include <IPXACTmodels/kactusExtensions/Kactus2Position.h>\r\n\r\n#include <QString>\r\n#include <QDomNode>\r\n#include <QXmlStreamWriter>\r\n#include <QPointF>\r\n#include <QVector2D>\r\n#include <QSharedPointer>\r\n\r\nclass Kactus2Position;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Interface graphics class for defining properties of graphical interfaces in designs.\r\n//-----------------------------------------------------------------------------\r\nclass IPXACTMODELS_EXPORT InterfaceGraphicsData : public VendorExtension\r\n{\r\npublic:\r\n\r\n    /*!\r\n     *  The constructor.\r\n     *\r\n     *    @param [in] name        Name of the interface.\r\n     *    @param [in] position    Position of the interface.\r\n     *    @param [in] direction   Direction of the interface.\r\n     */\r\n    InterfaceGraphicsData(QString const& name, QPointF position = QPointF(), QVector2D direction = QVector2D());\r\n\r\n    /*!\r\n     *  Copy constructor.\r\n     */\r\n    InterfaceGraphicsData(const InterfaceGraphicsData& other);\r\n\r\n    /*!\r\n     *  Constructor which reads the interface graphics data from an XML node.\r\n     *\r\n     *    @param [in] node    The source XML node.\r\n     */\r\n    InterfaceGraphicsData(QDomNode& node);\r\n\r\n    /*!\r\n     *  Destructor.\r\n     */\r\n    virtual ~InterfaceGraphicsData();\r\n\r\n    /*!\r\n     *  Clones the interface graphics data.\r\n     *\r\n     *    @return Cloned interface graphics data.\r\n     */\r\n    virtual InterfaceGraphicsData* clone() const;\r\n    \r\n    /*!\r\n     *  Assignment operator.\r\n     */\r\n    InterfaceGraphicsData& operator=(InterfaceGraphicsData const& rhs);\r\n\r\n    /*!\r\n     *  Gets the interface graphics data type.\r\n     *\r\n     *    @return The type of the interface graphics data.\r\n     */\r\n    virtual QString type() const;\r\n\r\n    /*!\r\n     *  Writes the contents of the interface graphics data to an XML stream.\r\n     */\r\n    virtual void write(QXmlStreamWriter& writer) const;\r\n\r\n    /*!\r\n     *  Set a name.\r\n     *\r\n     *    @param [in] newName     The new name.\r\n     */\r\n    void setName(QString const& newName);\r\n\r\n    /*!\r\n     *  Get the name.\r\n     *\r\n     *    @return The name of the interface.\r\n     */\r\n    QString getName() const;\r\n\r\n    /*!\r\n     *  Set the position for the interface.\r\n     *\r\n     *    @param [in] newPosition     The new position.\r\n     */\r\n    void setPosition(QPointF const& newPosition);\r\n\r\n    /*!\r\n     *  Get the position.\r\n     *\r\n     *    @return The position of the interface.\r\n     */\r\n    QPointF getPosition() const;\r\n\r\n    /*!\r\n     *  Check if the interface has been given a position.\r\n     *\r\n     *    @return True, if the interface has a position, false otherwise.\r\n     */\r\n    bool hasPosition() const;\r\n\r\n    /*!\r\n     *  Set a direction for the interface.\r\n     *\r\n     *    @param [in] newDirection    The new interface direction.\r\n     */\r\n    void setDirection(QVector2D const& newDirection);\r\n\r\n    /*!\r\n     *  Get the direction of the interface.\r\n     *\r\n     *    @return The direction of the interface.\r\n     */\r\n    QVector2D getDirection() const;\r\n\r\n    /*!\r\n     *  Check if the interface has been given a direction.\r\n     *\r\n     *    @return True, if the interface has been given a direction, otherwise false.\r\n     */\r\n    bool hasDirection() const;\r\n\r\nprivate:\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! The name of the interface graphics data.\r\n    QString name_;\r\n\r\n    //! Extension containing the position of the interface.\r\n    QSharedPointer<Kactus2Position> positionExtension_;\r\n\r\n    //! The direction of the interface.\r\n    QVector2D direction_;\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n\r\n#endif // INTERFACEGRAPHICSDATA_H\r\n"
  },
  {
    "path": "IPXACTmodels/kactusExtensions/Kactus2Group.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: Kactus2Group.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Esko Pekkarinen\r\n// Date: 05.06.2014\r\n//\r\n// Description:\r\n// Kactus2 vendor extension for a group of extensions.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"Kactus2Group.h\"\r\n\r\n#include <IPXACTmodels/common/VendorExtension.h>\r\n\r\n#include <QSharedPointer>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Kactus2Flag::Kactus2Flag()\r\n//-----------------------------------------------------------------------------\r\nKactus2Group::Kactus2Group(QString name):\r\n    name_(name),\r\n    groupExtensions_()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Kactus2Group::Kactus2Group()\r\n//-----------------------------------------------------------------------------\r\nKactus2Group::Kactus2Group(Kactus2Group const& other):\r\n    name_(other.name_),\r\n    groupExtensions_()\r\n{\r\n    foreach(QSharedPointer<VendorExtension> extension, other.groupExtensions_)\r\n    {\r\n        groupExtensions_.append(QSharedPointer<VendorExtension>(extension->clone()));\r\n    }\r\n}\r\n\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Kactus2Flag::~Kactus2Flag()\r\n//-----------------------------------------------------------------------------\r\nKactus2Group::~Kactus2Group()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Kactus2Group::clone()\r\n//-----------------------------------------------------------------------------\r\nKactus2Group* Kactus2Group::clone() const\r\n{\r\n    Kactus2Group* cloned = new Kactus2Group(name_);\r\n\r\n    for (QSharedPointer<VendorExtension> extension : groupExtensions_)\r\n    {\r\n        cloned->groupExtensions_.append(QSharedPointer<VendorExtension>(extension->clone()));\r\n    }\r\n\r\n    return cloned;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Kactus2Group::type()\r\n//-----------------------------------------------------------------------------\r\nQString Kactus2Group::type() const\r\n{\r\n    return name_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Kactus2Group::write()\r\n//-----------------------------------------------------------------------------\r\nvoid Kactus2Group::write(QXmlStreamWriter& writer) const\r\n{\r\n    writer.writeStartElement(name_);\r\n\r\n    for (QSharedPointer<VendorExtension> extension : groupExtensions_)\r\n    {\r\n        extension->write(writer);\r\n    }\r\n\r\n    writer.writeEndElement();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Kactus2Group::addExtension()\r\n//-----------------------------------------------------------------------------\r\nvoid Kactus2Group::addToGroup(QSharedPointer<VendorExtension> extension)\r\n{\r\n    if (!groupExtensions_.contains(extension))\r\n    {\r\n        groupExtensions_.append(extension);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Kactus2Group::removeFromGroup()\r\n//-----------------------------------------------------------------------------\r\nvoid Kactus2Group::removeFromGroup(QSharedPointer<VendorExtension> extension)\r\n{\r\n    groupExtensions_.removeOne(extension);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Kactus2Group::getExtensionForType()\r\n//-----------------------------------------------------------------------------\r\nQList<QSharedPointer<VendorExtension> > Kactus2Group::getByType(QString const& type) const\r\n{\r\n    QList<QSharedPointer<VendorExtension> > typedExtensions;\r\n\r\n    for (QSharedPointer<VendorExtension> extension : groupExtensions_)\r\n    {\r\n        if (extension->type() == type)\r\n        {\r\n            typedExtensions.append(extension);\r\n        }\r\n    }\r\n\r\n    return typedExtensions;\r\n}\r\n"
  },
  {
    "path": "IPXACTmodels/kactusExtensions/Kactus2Group.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: Kactus2Group.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Esko Pekkarinen\r\n// Date: 05.06.2014\r\n//\r\n// Description:\r\n// Kactus2 vendor extension for a group of extensions.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef KACTUS2GROUP_H\r\n#define KACTUS2GROUP_H\r\n\r\n#include <IPXACTmodels/common/VendorExtension.h>\r\n#include <IPXACTmodels/ipxactmodels_global.h>\r\n\r\n#include <QMap>\r\n\r\n//-----------------------------------------------------------------------------\r\n// class Kactus2Group.\r\n//-----------------------------------------------------------------------------\r\nclass IPXACTMODELS_EXPORT Kactus2Group : public VendorExtension\r\n{\r\npublic:\r\n\t/*!\r\n\t *  The constructor.\r\n\t *\r\n\t *    @param [in] name   The name of the placeholder.\r\n\t */\r\n    Kactus2Group(QString name);\r\n\r\n    //! Copy constructor.\r\n    Kactus2Group(Kactus2Group const& other);\r\n\r\n\t/*!\r\n\t *  The destructor.\r\n\t*/\r\n    virtual ~Kactus2Group();\r\n\r\n    /*!\r\n     *  Clones the vendor extension.\r\n     *\r\n     *    @return The clone copy of the vendor extension.\r\n     */\r\n    virtual Kactus2Group* clone() const;\r\n\r\n    /*!\r\n     *  Returns a type identifier for the vendor extension.\r\n     *\r\n     *    @return A type identifier of the vendor extension.\r\n     */\r\n    virtual QString type() const;\r\n\r\n    /*!\r\n     *  Writes the vendor extension to XML.\r\n     *\r\n     *    @param [in] writer   The writer used for writing the XML.\r\n     */\r\n    virtual void write(QXmlStreamWriter& writer) const;\r\n\r\n    /*!\r\n     *  Adds a vendor extension to the group.\r\n     *\r\n     *    @param [in] extension   The extension to add.\r\n     */\r\n    void addToGroup(QSharedPointer<VendorExtension> extension);\r\n\r\n    /*!\r\n     *  Removes a vendor extension from the group.\r\n     *\r\n     *    @param [in] extension   The extension to remove.     \r\n     */\r\n    void removeFromGroup(QSharedPointer<VendorExtension> extension);\r\n\r\n    /*!\r\n     *  Gets all the extensions with the given type.\r\n     *\r\n     *    @param [in] type   The type to search for.\r\n     *\r\n     *    @return The vendor extensions with the given type.\r\n     */\r\n    QList<QSharedPointer<VendorExtension> > getByType(QString const& type) const;\r\n\r\nprivate:\r\n\t//! Disable assignment.\r\n\tKactus2Group& operator=(Kactus2Group const& rhs);\r\n\r\n    //-----------------------------------------------------------------------------\r\n\t// Data.\r\n\t//-----------------------------------------------------------------------------\r\n\r\n    //! Name of the group.\r\n    QString name_;\r\n\r\n    //! The extensions composing the group.\r\n    QList<QSharedPointer<VendorExtension> > groupExtensions_;\r\n\r\n};\r\n#endif // KACTUS2GROUP_H\r\n"
  },
  {
    "path": "IPXACTmodels/kactusExtensions/Kactus2Placeholder.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: Kactus2Placeholder.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Esko Pekkarinen\r\n// Date: 19.5.2014\r\n//\r\n// Description:\r\n// Kactus2 vendor extension for single values.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"Kactus2Placeholder.h\"\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Kactus2Flag::Kactus2Flag()\r\n//-----------------------------------------------------------------------------\r\nKactus2Placeholder::Kactus2Placeholder(QString name):\r\n    name_(name),\r\n    attributes_()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Kactus2Placeholder::Kactus2Placeholder()\r\n//-----------------------------------------------------------------------------\r\nKactus2Placeholder::Kactus2Placeholder(Kactus2Placeholder const& other):\r\n    name_(other.name_),\r\n    attributes_(other.attributes_)\r\n{\r\n\r\n}\r\n\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Kactus2Flag::~Kactus2Flag()\r\n//-----------------------------------------------------------------------------\r\nKactus2Placeholder::~Kactus2Placeholder()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Kactus2Placeholder::clone()\r\n//-----------------------------------------------------------------------------\r\nKactus2Placeholder* Kactus2Placeholder::clone() const\r\n{\r\n    Kactus2Placeholder* cloned = new Kactus2Placeholder(name_);\r\n    cloned->attributes_ = attributes_;\r\n    return cloned;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Kactus2Placeholder::type()\r\n//-----------------------------------------------------------------------------\r\nQString Kactus2Placeholder::type() const\r\n{\r\n    return name_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Kactus2Placeholder::write()\r\n//-----------------------------------------------------------------------------\r\nvoid Kactus2Placeholder::write(QXmlStreamWriter& writer) const\r\n{\r\n    writer.writeEmptyElement(name_);\r\n\r\n    for (auto const& attribute : attributes_.keys())\r\n    {\r\n        writer.writeAttribute(attribute, attributes_.value(attribute));\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Kactus2Placeholder::setAttribute()\r\n//-----------------------------------------------------------------------------\r\nvoid Kactus2Placeholder::setAttribute(QString const& attributeName, QString const& attributeValue)\r\n{\r\n    attributes_.insert(attributeName, attributeValue);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Kactus2Placeholder::getAttributeValue()\r\n//-----------------------------------------------------------------------------\r\nQString Kactus2Placeholder::getAttributeValue(QString const& attributeName)\r\n{\r\n    return attributes_.value(attributeName);    \r\n}\r\n"
  },
  {
    "path": "IPXACTmodels/kactusExtensions/Kactus2Placeholder.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: Kactus2Placeholder.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Esko Pekkarinen\r\n// Date: 19.5.2014\r\n//\r\n// Description:\r\n// Kactus2 vendor extension for single values.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef KACTUS2PLACEHOLDER_H\r\n#define KACTUS2PLACEHOLDER_H\r\n\r\n#include <IPXACTmodels/common/VendorExtension.h>\r\n#include <IPXACTmodels/ipxactmodels_global.h>\r\n\r\n#include <QMap>\r\n\r\n//-----------------------------------------------------------------------------\r\n// class Kactus2Placeholder.\r\n//-----------------------------------------------------------------------------\r\nclass IPXACTMODELS_EXPORT Kactus2Placeholder : public VendorExtension\r\n{\r\npublic:\r\n\t/*!\r\n\t *  The constructor.\r\n\t *\r\n\t *    @param [in] name   The name of the placeholder.\r\n\t */\r\n    Kactus2Placeholder(QString name);\r\n\r\n    //! Copy constructor.\r\n    Kactus2Placeholder(Kactus2Placeholder const& other);\r\n\r\n\t/*!\r\n\t *  The destructor.\r\n\t*/\r\n    virtual ~Kactus2Placeholder();\r\n\r\n    /*!\r\n     *  Clones the vendor extension.\r\n     *\r\n     *    @return The clone copy of the vendor extension.\r\n     */\r\n    virtual Kactus2Placeholder* clone() const;\r\n\r\n    /*!\r\n     *  Returns a type identifier for the vendor extension.\r\n     *\r\n     *    @return A type identifier of the vendor extension.\r\n     */\r\n    virtual QString type() const;\r\n\r\n    /*!\r\n     *  Writes the vendor extension to XML.\r\n     *\r\n     *    @param [in] writer   The writer used for writing the XML.\r\n     */\r\n    virtual void write(QXmlStreamWriter& writer) const;\r\n\r\n    /*!\r\n     *  Sets a value of an attribute. If the attribute does not exist, it is created.\r\n     *\r\n     *    @param [in] attributeName   The name of the attribute.\r\n     *    @param [in] attributeValue  The value to set.\r\n     */\r\n    void setAttribute(QString const& attributeName, QString const& attributeValue);\r\n\r\n    /*!\r\n     *  Gets the value of a given attribute.\r\n     *\r\n     *    @param [in] attributeName   The name of the attribute whose value to get.\r\n     *\r\n     *    @return The value of the attribute or empty string if the given attribute is not found.\r\n     */\r\n    QString getAttributeValue(QString const& attributeName);\r\n\r\nprivate:\r\n\t//! Disable assignment.\r\n\tKactus2Placeholder& operator=(Kactus2Placeholder const& rhs);\r\n\r\n\t//-----------------------------------------------------------------------------\r\n\t// Data.\r\n\t//-----------------------------------------------------------------------------\r\n\r\n    //! Name of the placeholder extension.\r\n    QString name_;\r\n\r\n    //! The attributes of the extension.\r\n    QMap<QString, QString> attributes_;\r\n\r\n};\r\n#endif // KACTUS2PLACEHOLDER_H\r\n"
  },
  {
    "path": "IPXACTmodels/kactusExtensions/Kactus2Position.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: Kactus2Position.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Esko Pekkarinen\r\n// Date: 19.5.2014\r\n//\r\n// Description:\r\n// Kactus2 vendor extension for position.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"Kactus2Position.h\"\r\n\r\n#include <IPXACTmodels/common/CommonItemsReader.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Kactus2Position::Kactus2Position()\r\n//-----------------------------------------------------------------------------\r\nKactus2Position::Kactus2Position(QPointF position):\r\n    position_(position)\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Kactus2Position::~Kactus2Position()\r\n//-----------------------------------------------------------------------------\r\nKactus2Position::~Kactus2Position()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Kactus2Position::clone()\r\n//-----------------------------------------------------------------------------\r\nKactus2Position* Kactus2Position::clone() const\r\n{\r\n    return new Kactus2Position(position_);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Kactus2Position::type()\r\n//-----------------------------------------------------------------------------\r\nQString Kactus2Position::type() const\r\n{\r\n    return QStringLiteral(\"kactus2:position\");\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Kactus2Extension::write()\r\n//-----------------------------------------------------------------------------\r\nvoid Kactus2Position::write(QXmlStreamWriter& writer) const\r\n{\r\n    writer.writeEmptyElement(type());\r\n    writer.writeAttribute(QStringLiteral(\"x\"), QString::number(int(position_.x())));\r\n    writer.writeAttribute(QStringLiteral(\"y\"), QString::number(int(position_.y())));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Kactus2Extension::parsePosition()\r\n//-----------------------------------------------------------------------------\r\nvoid Kactus2Position::parsePosition(QDomNode const& positionNode)\r\n{\r\n    position_ = CommonItemsReader::parsePoint(positionNode);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Kactus2Position::position()\r\n//-----------------------------------------------------------------------------\r\nQPointF Kactus2Position::position() const\r\n{\r\n    return position_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Kactus2Position::setPosition()\r\n//-----------------------------------------------------------------------------\r\nvoid Kactus2Position::setPosition(QPointF const& pos)\r\n{\r\n    position_ = pos;\r\n}\r\n"
  },
  {
    "path": "IPXACTmodels/kactusExtensions/Kactus2Position.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: Kactus2Position.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Esko Pekkarinen\r\n// Date: 19.5.2014\r\n//\r\n// Description:\r\n// Kactus2 vendor extension for position.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef KACTUS2POSITION_H\r\n#define KACTUS2POSITION_H\r\n\r\n#include <IPXACTmodels/common/VendorExtension.h>\r\n#include <IPXACTmodels/ipxactmodels_global.h>\r\n\r\n#include <QDomNode>\r\n#include <QPointF>\r\n\r\n//-----------------------------------------------------------------------------\r\n// class Kactus2Position.\r\n//-----------------------------------------------------------------------------\r\nclass IPXACTMODELS_EXPORT Kactus2Position : public VendorExtension\r\n{\r\npublic:\r\n\t/*!\r\n\t *  The constructor.\r\n\t *\r\n\t *    @param [in] position   The initial position of represented by the extension.\r\n\t */\r\n    Kactus2Position(QPointF position);\r\n\r\n\t/*!\r\n\t *  The destructor.\r\n\t*/\r\n    virtual ~Kactus2Position();\r\n\r\n    // Disable copying.\r\n    Kactus2Position(Kactus2Position const& rhs) = delete;\r\n\r\n    // Disable assignment.\r\n    Kactus2Position& operator=(Kactus2Position const& rhs) = delete;\r\n\r\n    /*!\r\n     *  Clones the vendor extension.\r\n     *\r\n     *    @return The clone copy of the vendor extension.\r\n     */\r\n    virtual Kactus2Position* clone() const;\r\n\r\n    /*!\r\n     *  Returns a type identifier for the vendor extension.\r\n     *\r\n     *    @return A type identifier of the vendor extension.\r\n     */\r\n    virtual QString type() const;\r\n\r\n    /*!\r\n     *  Writes the vendor extension to XML.\r\n     *\r\n     *    @param [in] writer   The writer used for writing the XML.\r\n     */\r\n    virtual void write(QXmlStreamWriter& writer) const;\r\n\r\n    void parsePosition(QDomNode const& positionNode);\r\n\r\n    /*!\r\n     *  Gets the position.\r\n     *\r\n     *    @return The position represented by the extension.\r\n     */\r\n    QPointF position() const;\r\n\r\n    /*!\r\n     *  Sets the position.\r\n     *\r\n     *    @param [in] pos   The position to set.\r\n     */\r\n    void setPosition(QPointF const& pos);\r\n\r\nprivate:\r\n\t//-----------------------------------------------------------------------------\r\n\t// Data.\r\n\t//-----------------------------------------------------------------------------\r\n\r\n    //! The position of represented by the extension.\r\n    QPointF position_;\r\n\r\n};\r\n#endif // KACTUS2POSITION_H\r\n"
  },
  {
    "path": "IPXACTmodels/kactusExtensions/Kactus2Value.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: Kactus2Value.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Esko Pekkarinen\r\n// Date: 20.5.2014\r\n//\r\n// Description:\r\n// Kactus2 vendor extension for name-value pairs.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"Kactus2Value.h\"\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Kactus2Value::Kactus2Value()\r\n//-----------------------------------------------------------------------------\r\nKactus2Value::Kactus2Value(QString name, QString value):\r\n    name_(name),\r\n    value_(value)\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Kactus2Value::~Kactus2Value()\r\n//-----------------------------------------------------------------------------\r\nKactus2Value::~Kactus2Value()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Kactus2Value::clone()\r\n//-----------------------------------------------------------------------------\r\nKactus2Value* Kactus2Value::clone() const\r\n{\r\n    return new Kactus2Value(name_, value_);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Kactus2Value::type()\r\n//-----------------------------------------------------------------------------\r\nQString Kactus2Value::type() const\r\n{\r\n    return name_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Kactus2Value::write()\r\n//-----------------------------------------------------------------------------\r\nvoid Kactus2Value::write(QXmlStreamWriter& writer) const\r\n{    \r\n    writer.writeTextElement(name_, value_);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Kactus2Value::value()\r\n//-----------------------------------------------------------------------------\r\nQString Kactus2Value::value() const\r\n{\r\n    return value_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Kactus2Value::setValue()\r\n//-----------------------------------------------------------------------------\r\nvoid Kactus2Value::setValue(QString const& newValue)\r\n{\r\n    value_ = newValue;\r\n}\r\n"
  },
  {
    "path": "IPXACTmodels/kactusExtensions/Kactus2Value.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: Kactus2Value.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Esko Pekkarinen\r\n// Date: 20.5.2014\r\n//\r\n// Description:\r\n// Kactus2 vendor extension for name-value pairs.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef KACTUS2VALUE_H\r\n#define KACTUS2VALUE_H\r\n\r\n#include <IPXACTmodels/ipxactmodels_global.h>\r\n\r\n#include <IPXACTmodels/common/VendorExtension.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// class Kactus2Value.\r\n//-----------------------------------------------------------------------------\r\nclass IPXACTMODELS_EXPORT Kactus2Value : public VendorExtension\r\n{\r\npublic:\r\n\t/*!\r\n\t *  The constructor.\r\n\t *\r\n     *    @param [in] name        Corresponds name of XML element.\r\n     *    @param [in] value       Corresponds the value of XML element.\r\n\t */\r\n    Kactus2Value(QString name, QString value);\r\n\r\n\t/*!\r\n\t *  The destructor.\r\n\t*/\r\n\tvirtual ~Kactus2Value();\r\n\r\n    /*!\r\n     *  Clones the vendor extension.\r\n     *\r\n     *    @return The clone copy of the vendor extension.\r\n     */\r\n    virtual Kactus2Value* clone() const;\r\n\r\n    /*!\r\n     *  Returns a type identifier for the vendor extension.\r\n     *\r\n     *    @return A type identifier of the vendor extension.\r\n     */\r\n    virtual QString type() const;\r\n\r\n    /*!\r\n     *  Writes the vendor extension to XML.\r\n     *\r\n     *    @param [in] writer   The writer used for writing the XML.\r\n     */\r\n    virtual void write(QXmlStreamWriter& writer) const;\r\n\r\n    /*!\r\n     *  Gets the value of the vendor extension.\r\n     *\r\n     *    @return The stored value.\r\n     */\r\n    QString value() const;\r\n\r\n    /*!\r\n     *  Sets the value of the vendor extension.\r\n     *\r\n     *    @param [in] newValue   The value to set.\r\n     */\r\n    void setValue(QString const& newValue);\r\n\r\nprivate:\r\n    //! Disable copying.\r\n    Kactus2Value(Kactus2Value const& other);\r\n\r\n\t// Disable assignment.\r\n\tKactus2Value& operator=(Kactus2Value const& rhs);\r\n    \r\n\t//-----------------------------------------------------------------------------\r\n\t// Data.\r\n\t//-----------------------------------------------------------------------------\r\n\r\n    //! The name identifier of the vendor extension.\r\n    QString name_;\r\n\r\n    //! The value of the vendor extension.\r\n    QString value_;\r\n\r\n};\r\n#endif // KACTUS2VALUE_H\r\n"
  },
  {
    "path": "IPXACTmodels/kactusExtensions/KactusAttribute.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: KactusAttribute.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Joni-Matti Maatta\r\n// Date: 23.6.2011\r\n//\r\n// Description:\r\n// Kactus attribute definitions and related utility functions.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"KactusAttribute.h\"\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: KactusAttribute::KactusAttribute()\r\n//-----------------------------------------------------------------------------\r\nKactusAttribute::KactusAttribute():\r\nproductHierarchy_(KactusAttribute::KTS_PRODHIER_COUNT),\r\n    implementation_(KactusAttribute::KTS_IMPLEMENTATION_COUNT),\r\n    firmness_(KactusAttribute::KTS_REUSE_LEVEL_COUNT)\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: KactusAttribute::~KactusAttribute()\r\n//-----------------------------------------------------------------------------\r\nKactusAttribute::~KactusAttribute()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: KactusAttribute::clone()\r\n//-----------------------------------------------------------------------------\r\nVendorExtension* KactusAttribute::clone() const\r\n{\r\n    return new KactusAttribute(*this);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: KactusAttribute::type()\r\n//-----------------------------------------------------------------------------\r\nQString KactusAttribute::type() const\r\n{\r\n    return QStringLiteral(\"kactus2:extensions\");\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: KactusAttribute::write()\r\n//-----------------------------------------------------------------------------\r\nvoid KactusAttribute::write(QXmlStreamWriter& writer) const\r\n{\r\n    writer.writeStartElement(QStringLiteral(\"kactus2:kts_attributes\"));\r\n\r\n    if (productHierarchy_ != KTS_PRODHIER_COUNT)\r\n    {\r\n        writer.writeTextElement(QStringLiteral(\"kactus2:kts_productHier\"), hierarchyToString(productHierarchy_));\r\n    }\r\n   \r\n    if (implementation_ != KTS_IMPLEMENTATION_COUNT)\r\n    {\r\n        writer.writeTextElement(QStringLiteral(\"kactus2:kts_implementation\"), implementationToString(implementation_));\r\n    }\r\n   \r\n    if (firmness_ != KTS_REUSE_LEVEL_COUNT)\r\n    {\r\n        writer.writeTextElement(QStringLiteral(\"kactus2:kts_firmness\"), firmnessToString(firmness_));\r\n    }\r\n\r\n    writer.writeEndElement(); // kactus2:kts_attributes\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: KactusAttribute::setHierarchy()\r\n//-----------------------------------------------------------------------------\r\nvoid KactusAttribute::setHierarchy(KactusAttribute::ProductHierarchy hierarchy)\r\n{\r\n    productHierarchy_ = hierarchy;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: KactusAttribute::getHierarchy()\r\n//-----------------------------------------------------------------------------\r\nKactusAttribute::ProductHierarchy KactusAttribute::getHierarchy() const\r\n{\r\n    return productHierarchy_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: KactusAttribute::setImplementation()\r\n//-----------------------------------------------------------------------------\r\nvoid KactusAttribute::setImplementation(KactusAttribute::Implementation implementation)\r\n{\r\n    implementation_ = implementation;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: KactusAttribute::setImplementation()\r\n//-----------------------------------------------------------------------------\r\nKactusAttribute::Implementation KactusAttribute::getImplementation() const\r\n{\r\n    return implementation_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: KactusAttribute::setFirmness()\r\n//-----------------------------------------------------------------------------\r\nvoid KactusAttribute::setFirmness(Firmness firmness)\r\n{\r\n    firmness_ = firmness;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: KactusAttribute::getFirmness()\r\n//-----------------------------------------------------------------------------\r\nKactusAttribute::Firmness KactusAttribute::getFirmness() const\r\n{\r\n    return firmness_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: KactusAttribute::hierarchyFrom()\r\n//-----------------------------------------------------------------------------\r\nKactusAttribute::ProductHierarchy KactusAttribute::hierarchyFrom(QString const& string)\r\n{\r\n    QString lowStr = string.toLower();\r\n    for (unsigned int i = 0; i < KactusAttribute::KTS_PRODHIER_COUNT; ++i)\r\n    {\r\n        if (lowStr == hierarchyToString(static_cast<ProductHierarchy>(i)).toLower())\r\n        {\r\n            return static_cast<ProductHierarchy>(i);\r\n        }\r\n    }\r\n\r\n    return KactusAttribute::KTS_PRODHIER_COUNT;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: KactusAttribute::implementationFrom()\r\n//-----------------------------------------------------------------------------\r\nKactusAttribute::Implementation KactusAttribute::implementationFrom(QString const& string)\r\n{\r\n    QString lowStr = string.toLower();\r\n\r\n    for (unsigned int i = 0; i < KactusAttribute::KTS_IMPLEMENTATION_COUNT; i++)\r\n    {\r\n        if (lowStr == implementationToString(static_cast<Implementation>(i)).toLower())\r\n        {\r\n            return static_cast<KactusAttribute::Implementation>(i);            \r\n        }\r\n    }\r\n\r\n    return KactusAttribute::KTS_IMPLEMENTATION_COUNT;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: KactusAttribute::firmnessFrom()\r\n//-----------------------------------------------------------------------------\r\nKactusAttribute::Firmness KactusAttribute::firmnessFrom(QString const& string)\r\n{\r\n    QString lowStr = string.toLower();\r\n\r\n    for (unsigned int i = 0; i < KactusAttribute::KTS_REUSE_LEVEL_COUNT; ++i)\r\n    {\r\n        if (lowStr == firmnessToString(static_cast<Firmness>(i)).toLower())\r\n        {\r\n            return static_cast<Firmness>(i);\r\n            \r\n        }\r\n    }\r\n\r\n    return KactusAttribute::KTS_REUSE_LEVEL_COUNT;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: KactusAttribute::hierarchyToString()\r\n//-----------------------------------------------------------------------------\r\nQString KactusAttribute::hierarchyToString(ProductHierarchy prodHier)\r\n{\r\n    if (prodHier == KTS_PRODHIER_COUNT)\r\n    {\r\n        return QString();\r\n    }\r\n\r\n    static QString const PROD_HIER_NAMES[KactusAttribute::KTS_PRODHIER_COUNT] =\r\n    {\r\n        QLatin1String(\"Flat\"),\r\n        QLatin1String(\"Product\"),\r\n        QLatin1String(\"Board\"),\r\n        QLatin1String(\"Chip\"),\r\n        QLatin1String(\"SoC\"),\r\n        QLatin1String(\"IP\")\r\n    };\r\n\r\n    return PROD_HIER_NAMES[prodHier];\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: KactusAttribute::firmnessToString()\r\n//-----------------------------------------------------------------------------\r\nQString KactusAttribute::firmnessToString(Firmness firmness)\r\n{\r\n    if (firmness == KTS_REUSE_LEVEL_COUNT)\r\n    {\r\n        return QString();\r\n    }\r\n\r\n    static QString const FIRMNESS_NAMES[KactusAttribute::KTS_REUSE_LEVEL_COUNT] =\r\n    {\r\n        QLatin1String(\"Mutable\"),\r\n        QLatin1String(\"Template\"),\r\n        QLatin1String(\"Fixed\")\r\n    };\r\n\r\n    return FIRMNESS_NAMES[firmness];\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: KactusAttribute::implementationToString()\r\n//-----------------------------------------------------------------------------\r\nQString KactusAttribute::implementationToString(Implementation implementation)\r\n{\r\n    if (implementation == KTS_IMPLEMENTATION_COUNT)\r\n    {\r\n        return QString();\r\n    }\r\n\r\n    static QString const IMPLEMENTATION_NAMES[KactusAttribute::KTS_IMPLEMENTATION_COUNT] =\r\n    {\r\n        QLatin1String(\"HW\"),\r\n        QLatin1String(\"SW\"),\r\n        QLatin1String(\"SYS\")\r\n    };\r\n\r\n    return IMPLEMENTATION_NAMES[implementation];\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: KactusAttribute::KactusAttribute()\r\n//-----------------------------------------------------------------------------\r\nKactusAttribute::KactusAttribute(KactusAttribute const& rhs):\r\nproductHierarchy_(rhs.productHierarchy_),\r\n    implementation_(rhs.implementation_),\r\n    firmness_(rhs.firmness_)\r\n{\r\n\r\n}\r\n"
  },
  {
    "path": "IPXACTmodels/kactusExtensions/KactusAttribute.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: KactusAttribute.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Joni-Matti Maatta\r\n// Date: 23.6.2011\r\n//\r\n// Description:\r\n// Kactus attribute definitions and related utility functions.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef KACTUSATTRIBUTE_H\r\n#define KACTUSATTRIBUTE_H\r\n\r\n#include <IPXACTmodels/ipxactmodels_global.h>\r\n\r\n#include <IPXACTmodels/common/VendorExtension.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Kactus attribute definitions and related utility functions.\r\n//-----------------------------------------------------------------------------\r\nclass IPXACTMODELS_EXPORT KactusAttribute : public VendorExtension\r\n{\r\npublic:\r\n\r\n    //-----------------------------------------------------------------------------\r\n    //! ProductHierarchy enumeration.\r\n    //-----------------------------------------------------------------------------\r\n    enum ProductHierarchy\r\n    {\r\n        FLAT = 0,\r\n        PRODUCT,\r\n        BOARD,\r\n        CHIP,\r\n        SOC,\r\n        IP,\r\n        KTS_PRODHIER_COUNT\r\n    };\r\n\r\n    //-----------------------------------------------------------------------------\r\n    //! Firmness enumeration.\r\n    //-----------------------------------------------------------------------------\r\n    enum Firmness\r\n    {\r\n        MUTABLE = 0,\r\n        TEMPLATE,\r\n        FIXED,\r\n        KTS_REUSE_LEVEL_COUNT\r\n    };\r\n\r\n    //--------------------------------------------------------------------------\r\n    //! Implementation enumeration.\r\n    //--------------------------------------------------------------------------\r\n    enum Implementation\r\n    {\r\n        HW = 0,\r\n        SW,\r\n        SYSTEM,\r\n        KTS_IMPLEMENTATION_COUNT\r\n    };\r\n\r\n\t//! The constructor.\r\n\tKactusAttribute();\r\n\r\n\t//! The destructor.\r\n\t~KactusAttribute();\r\n\r\n    /*!\r\n     *  Clones the vendor extension.\r\n     *\r\n     *    @return The clone copy of the vendor extension.\r\n     */\r\n    virtual VendorExtension* clone() const;\r\n\r\n    /*!\r\n     *  Returns a type identifier for the vendor extension.\r\n     *\r\n     *    @return A type identifier of the vendor extension.\r\n     */\r\n    virtual QString type() const;\r\n\r\n    /*!\r\n     *  Writes the vendor extension to XML.\r\n     *\r\n     *    @param [in] writer   The writer used for writing the XML.\r\n     */\r\n    virtual void write(QXmlStreamWriter& writer) const;\r\n\r\n    /*!\r\n     *  Sets the product hierarchy in the attributes.\r\n     *\r\n     *    @param [in] hierarchy   The hierarchy level to set.\r\n     */\r\n    void setHierarchy(KactusAttribute::ProductHierarchy hierarchy);\r\n\r\n    /*!\r\n     *  Gets the product hierarchy in the attributes.\r\n     *\r\n     *    @return The product hierarchy.\r\n     */\r\n    KactusAttribute::ProductHierarchy getHierarchy() const;\r\n    \r\n    /*!\r\n     *  Sets the product implementation in the attributes.\r\n     *\r\n     *    @param [in] implementation   The implementation type to set.\r\n     */\r\n    void setImplementation(KactusAttribute::Implementation implementation);\r\n    \r\n    /*!\r\n     *  Gets the product implementation in the attributes.\r\n     *\r\n     *    @return The implementation.\r\n     */\r\n    KactusAttribute::Implementation getImplementation() const;\r\n        \r\n    /*!\r\n     *  Sets the product firmness in the attributes.\r\n     *\r\n     *    @param [in] firmness   The firmness to set.\r\n     */\r\n    void setFirmness(KactusAttribute::Firmness firmness);\r\n        \r\n    /*!\r\n     *  Gets the product firmness in the attributes.\r\n     *\r\n     *    @return The firmness.\r\n     */\r\n    KactusAttribute::Firmness getFirmness() const;\r\n    \r\n    /*!\r\n     *  Converts the given string to a product hierarchy.\r\n     *\r\n     *    @param [in] string The string to convert.\r\n     *\r\n     *    @return The equivalent hierarchy level.\r\n     */\r\n    static ProductHierarchy hierarchyFrom(QString const& string);\r\n        \r\n    /*!\r\n     *  Converts the given string to a product implementation.\r\n     *\r\n     *    @param [in] string The string to convert.\r\n     *\r\n     *    @return The equivalent implementation type.\r\n     */\r\n    static Implementation implementationFrom(QString const& string);\r\n        \r\n    /*!\r\n     *  Converts the given string to a firmness type.\r\n     *\r\n     *    @param [in] string The string to convert.\r\n     *\r\n     *    @return The equivalent firmness type.\r\n     */\r\n    static Firmness firmnessFrom(QString const& string);\r\n\r\n    /*!\r\n     *  Converts the given product hierarchy to a string.\r\n     *\r\n     *    @param [in] prodHier The product hierarchy.\r\n     *\r\n     *    @return The equivalent string.\r\n     */\r\n    static QString hierarchyToString(ProductHierarchy prodHier);\r\n\r\n    /*!\r\n     *  Converts the given firmness to a string.\r\n     *\r\n     *    @param [in] firmness specifies the firmness.\r\n     *\r\n     *    @return The equivalent string.\r\n     */\r\n    static QString firmnessToString(Firmness firmness);\r\n    \r\n    /*!\r\n     *  Converts the given firmness to a string.\r\n     *\r\n     *    @param [in] firmness The firmness.\r\n     *\r\n     *    @return The equivalent string.\r\n     */\r\n    static QString implementationToString(Implementation implementation);\r\n\r\nprivate:\r\n\r\n\t// Disable copying.\r\n\tKactusAttribute(KactusAttribute const& rhs);\r\n\tKactusAttribute& operator=(KactusAttribute const& rhs);\r\n\r\n    //! The product hierarchy level for the attributes.\r\n    ProductHierarchy productHierarchy_;\r\n\r\n    //! The product implementation type for the attributes.\r\n    Implementation implementation_;\r\n\r\n    //! The product firmness level for the attributes.\r\n    Firmness firmness_;\r\n};\r\n\r\n#endif // KACTUSATTRIBUTE_H\r\n"
  },
  {
    "path": "IPXACTmodels/kactusExtensions/SystemView.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: SystemView.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Joni-Matti Maatta\r\n// Date: 22.5.2012\r\n//\r\n// Description:\r\n// System view class.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"SystemView.h\"\r\n\r\n#include <IPXACTmodels/common/CommonItemsReader.h>\r\n#include <IPXACTmodels/common/CommonItemsWriter.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SystemView::SystemView()\r\n//-----------------------------------------------------------------------------\r\nSystemView::SystemView(QDomNode& viewNode) :\r\n    NameGroup()\r\n{\r\n    QDomElement systemViewElement = viewNode.toElement();\r\n\r\n    setName(systemViewElement.firstChildElement(QStringLiteral(\"ipxact:name\")).firstChild().nodeValue());\r\n\r\n    setDisplayName(systemViewElement.firstChildElement(QStringLiteral(\"ipxact:displayName\")).firstChild().nodeValue());\r\n\r\n    setShortDescription(systemViewElement.firstChildElement(QStringLiteral(\"ipxact:shortDescription\")).firstChild().nodeValue());\r\n\r\n    setDescription(systemViewElement.firstChildElement(QStringLiteral(\"ipxact:description\")).firstChild().nodeValue());\r\n    \r\n    QDomElement hierarchyRefElement = systemViewElement.firstChildElement(QStringLiteral(\"ipxact:hierarchyRef\"));\r\n    if (!hierarchyRefElement.isNull())\r\n    {\r\n        hierarchyRef_ = CommonItemsReader::parseVLNVAttributes(hierarchyRefElement, VLNV::DESIGN);\r\n    }\r\n\r\n    hwViewRef_ = systemViewElement.firstChildElement(QStringLiteral(\"kactus2:hwViewRef\")).childNodes().at(0).nodeValue();\r\n\r\n    QDomNodeList fileSetRefNodes = systemViewElement.elementsByTagName(QStringLiteral(\"kactus2:fileSetRef\"));\r\n    int fileSetRefCount = fileSetRefNodes.count();\r\n    for (int i = 0; i < fileSetRefCount; i++)\r\n    {\r\n        QDomNode filesetNode = fileSetRefNodes.at(i);\r\n        fileSetRefs_.append(filesetNode.childNodes().at(0).nodeValue());\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SystemView::SystemView()\r\n//-----------------------------------------------------------------------------\r\nSystemView::SystemView(QString const& name): \r\n    NameGroup(name)\r\n{\r\n\r\n}\r\n\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SystemView::SystemView()\r\n//-----------------------------------------------------------------------------\r\nSystemView::SystemView(const SystemView &other) :\r\nNameGroup(other),\r\n    hierarchyRef_(other.hierarchyRef_),\r\n    hwViewRef_(other.hwViewRef_),\r\n    fileSetRefs_(other.fileSetRefs_)\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SystemView::operator=()\r\n//-----------------------------------------------------------------------------\r\nSystemView& SystemView::operator=(const SystemView &other)\r\n{\r\n    if (this != &other)\r\n    {\r\n        NameGroup::operator=(other);\r\n        hierarchyRef_ = other.hierarchyRef_;\r\n        hwViewRef_ = other.hwViewRef_;\r\n        fileSetRefs_ = other.fileSetRefs_;\r\n    }\r\n\r\n    return *this;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SystemView::~SystemView()\r\n//-----------------------------------------------------------------------------\r\nSystemView::~SystemView()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SystemView::clone()\r\n//-----------------------------------------------------------------------------\r\nSystemView* SystemView::clone() const\r\n{\r\n    return new SystemView(*this);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SystemView::type()\r\n//-----------------------------------------------------------------------------\r\nQString SystemView::type() const\r\n{\r\n    return QStringLiteral(\"kactus2:systemView\");\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SystemView::write()\r\n//-----------------------------------------------------------------------------\r\nvoid SystemView::write(QXmlStreamWriter& writer) const\r\n{\r\n    writer.writeStartElement(QStringLiteral(\"kactus2:systemView\"));\r\n\r\n    writer.writeTextElement(QStringLiteral(\"ipxact:name\"), name());\r\n\r\n    CommonItemsWriter::writeDisplayName(writer, displayName());\r\n\r\n    CommonItemsWriter::writeShortDescription(writer, shortDescription());\r\n\r\n    CommonItemsWriter::writeDescription(writer, description());\r\n\r\n    // write hierarchyRef if one exists\r\n    if (!hierarchyRef_.isEmpty())\r\n    {\r\n        writer.writeEmptyElement(QStringLiteral(\"kactus2:hierarchyRef\"));\r\n        CommonItemsWriter::writeVLNVAttributes(writer, hierarchyRef_);\r\n    }\r\n\r\n    // Write HW view reference.\r\n    writer.writeTextElement(QStringLiteral(\"kactus2:hwViewRef\"), hwViewRef_);\r\n\r\n\t for (QString const& fileSetName : fileSetRefs_)\r\n     {\r\n\t\t writer.writeTextElement(QStringLiteral(\"kactus2:fileSetRef\"), fileSetName);\r\n\t }\r\n\r\n    writer.writeEndElement(); // kactus2:systemView\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SystemView::isValid()\r\n//-----------------------------------------------------------------------------\r\nbool SystemView::isValid(QStringList const& fileSetNames, QStringList const& HWViewNames,\r\n    QVector<QString>& errorList, QString const& parentIdentifier) const\r\n{\r\n    bool valid = true;\r\n    const QString thisIdentifier(QObject::tr(\"system view %1\").arg(name()));\r\n\r\n    if (name().isEmpty())\r\n    {\r\n        errorList.append(QObject::tr(\"No name specified for system view in %1\").arg(parentIdentifier));\r\n        valid = false;\r\n    }\r\n\r\n    if (!hierarchyRef_.isValid(errorList, thisIdentifier))\r\n    {\r\n        valid = false;\r\n    }\r\n\r\n\t // make sure the referenced file sets are found\r\n\t for (QString const& fileSetRef : fileSetRefs_)\r\n     {\r\n\t\t if (!fileSetNames.contains(fileSetRef))\r\n         {\r\n\t\t\t errorList.append(QObject::tr(\"System View %1 contained reference to file set %2 which is not found \"\r\n                 \"within %3\").arg(name()).arg(fileSetRef).arg(parentIdentifier));\r\n\t\t\t valid = false;\r\n\t\t }\r\n\t }\r\n\r\n\t // if HW view is specified but not found\r\n\t if (!hwViewRef_.isEmpty() && !HWViewNames.contains(hwViewRef_))\r\n     {\r\n\t\t errorList.append(QObject::tr(\"System view %1 contained reference to HW view %2 which is not found \"\r\n             \"withing %3.\").arg(name()).arg(hwViewRef_).arg(parentIdentifier));\r\n\t\t valid = false;\r\n\t }\r\n\r\n    return valid;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SystemView::isValid()\r\n//-----------------------------------------------------------------------------\r\nbool SystemView::isValid(QStringList const& fileSetNames, QStringList const& HWViewNames) const\r\n{\r\n    if (name().isEmpty())\r\n    {\r\n        return false;\r\n    }\r\n\r\n    if (!hierarchyRef_.isValid())\r\n    {\r\n        return false;\r\n    }\r\n\r\n\t // make sure the referenced file sets are found\r\n\t for (QString const& fileSetRef : fileSetRefs_)\r\n     {\r\n\t\t if (!fileSetNames.contains(fileSetRef))\r\n         {\r\n\t\t\t return false;\r\n\t\t }\r\n\t }\r\n\r\n\t // if HW view is specified but not found\r\n\t if (!hwViewRef_.isEmpty() && !HWViewNames.contains(hwViewRef_))\r\n     {\r\n\t\t return false;\r\n\t }\r\n\r\n    return true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SystemView::setHierarchyRef()\r\n//-----------------------------------------------------------------------------\r\nvoid SystemView::setHierarchyRef(VLNV const& hierarchyRef)\r\n{\r\n    hierarchyRef_ = hierarchyRef;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SystemView::setHWViewRef()\r\n//-----------------------------------------------------------------------------\r\nvoid SystemView::setHWViewRef(QString const& viewName)\r\n{\r\n    hwViewRef_ = viewName;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SystemView::getHierarchyRef()\r\n//-----------------------------------------------------------------------------\r\nVLNV SystemView::getHierarchyRef() const\r\n{\r\n    return hierarchyRef_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SystemView::getHWViewRef()\r\n//-----------------------------------------------------------------------------\r\nQString SystemView::getHWViewRef() const\r\n{\r\n    return hwViewRef_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SystemView::getFileSetRefs()\r\n//-----------------------------------------------------------------------------\r\nQStringList SystemView::getFileSetRefs() const\r\n{\r\n\treturn fileSetRefs_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SystemView::setFileSetRefs()\r\n//-----------------------------------------------------------------------------\r\nvoid SystemView::setFileSetRefs(QStringList const& fileSetRefs)\r\n{\r\n\tfileSetRefs_ = fileSetRefs;\r\n}\r\n"
  },
  {
    "path": "IPXACTmodels/kactusExtensions/SystemView.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: SystemView.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Joni-Matti Maatta\r\n// Date: 22.5.2012\r\n//\r\n// Description:\r\n// System view class for making VLNV references to System designs.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef SYSTEMVIEW_H\r\n#define SYSTEMVIEW_H\r\n\r\n#include <IPXACTmodels/common/NameGroup.h>\r\n\r\n#include <IPXACTmodels/ipxactmodels_global.h>\r\n#include <IPXACTmodels/common/VendorExtension.h>\r\n#include <IPXACTmodels/common/VLNV.h>\r\n\r\n#include <QDomNode>\r\n#include <QString>\r\n#include <QStringList>\r\n#include <QXmlStreamWriter>\r\n\r\n//-----------------------------------------------------------------------------\r\n//! System view class for making VLNV references to system designs.\r\n//-----------------------------------------------------------------------------\r\nclass IPXACTMODELS_EXPORT SystemView : public NameGroup, public VendorExtension\r\n{\r\npublic:\r\n    /*!\r\n     *  Constructor.\r\n\t *\r\n\t *    @param [in] viewNode A reference to a QDomNode to parse the information from.\r\n\t */\r\n\tSystemView(QDomNode &viewNode);\r\n\r\n\t/*!\r\n     *  The constructor\r\n     *\r\n\t *    @param [in] name The name of the view.\r\n\t */\r\n\tSystemView(QString const& name = QString());\r\n\r\n\r\n\t//! Copy constructor.\r\n\tSystemView(const SystemView &other);\r\n\r\n\t//! Assignment operator.\r\n\tSystemView &operator=(const SystemView &other);\r\n\r\n\t/*!\r\n     *  Destructor.\r\n\t */\r\n\t~SystemView();\r\n\r\n    /*!\r\n     *  Clone this system view.\r\n     *\r\n     *    @return The cloned system view.\r\n     */\r\n    virtual SystemView* clone() const;\r\n\r\n    /*!\r\n     *  Get the type of this extension.\r\n     *\r\n     *    @return The type of this extension.\r\n     */\r\n    virtual QString type() const;\r\n\r\n\t/*! \r\n     *  Writes the contents of the class using the writer.\r\n\t *\r\n\t *  Uses the specified writer to write the class contents into file as valid IP-Xact.\r\n\t *\r\n\t *    @param [in] writer A QXmlStreamWriter instance that is used to write the document into file.\r\n\t */\r\n\tvirtual void write(QXmlStreamWriter& writer) const;\r\n\r\n\t/*!\r\n     *  Checks if the view is in a valid state.\r\n\t * \r\n\t *\t\t@param [in] fileSetNames\t File set names of the containing component.\r\n\t *\t\t@param [in] HWViewNames\t\t Names of the HW views in the containing component.\r\n\t *    @param [in] errorList        The list to add the possible error messages to.\r\n\t *    @param [in] parentIdentifier String from parent to help to identify the location of the error.\r\n\t *\r\n\t *    @return True if contents are valid.\r\n\t */\r\n\tbool isValid(QStringList const& fileSetNames, QStringList const& HWViewNames, QVector<QString>& errorList,\r\n        QString const& parentIdentifier) const;\r\n\r\n\t/*!\r\n     *  Checks if the view is in a valid state.\r\n\t * \r\n\t *\t\t  @param [in] fileSetNames  File set names of the containing component.\r\n\t *\t\t  @param [in] HWViewNames   Names of the HW views in the containing component.\r\n\t * \r\n\t *    @return True if contents are valid.\r\n\t*/\r\n\tbool isValid(QStringList const& fileSetNames, QStringList const& HWViewNames) const;\r\n\r\n    /*!\r\n     *  Set the hierarchyRef for this view.\r\n\t *\r\n\t *    @param [in] hierarchyRef    The new hierarchyRef.\r\n\t */\r\n\tvoid setHierarchyRef(VLNV const& hierarchyRef);\r\n\r\n    /*!\r\n     *  Sets the reference to HW view to which the system is mapped.\r\n     *\r\n     *    @param [in] viewName The name of the HW view.\r\n     */\r\n    void setHWViewRef(QString const& viewName);\r\n\r\n\t/*!\r\n     *  Get pointer to the hierarchical design for this view.\r\n\t *\r\n\t *    @return The vlnv of a hierarchical design if the view is used to reference a hierarchical design.\r\n\t */\r\n\tVLNV getHierarchyRef() const;\r\n\r\n    /*!\r\n     *  Returns the reference to HW view to which the system is mapped.\r\n     */\r\n    QString getHWViewRef() const;\r\n\r\n\t/*!\r\n     *  Get the file set references of the system view.\r\n\t *\r\n\t *    @return QStringList containing the file set names.\r\n\t */\r\n\tQStringList getFileSetRefs() const;\r\n\r\n\t/*!\r\n     *  Set the file set references for the system view.\r\n\t *\r\n\t *    @param [in] fileSetRefs     Contains the file set names.\r\n\t */\r\n\tvoid setFileSetRefs(QStringList const& fileSetRefs);\r\n\r\nprivate:\r\n\r\n\t//! References a hierarchical design, mandatory only if the view is used to reference a hierarchical design.\r\n\tVLNV hierarchyRef_;\r\n\r\n    //! The name of the HW view to which the system references.\r\n    QString hwViewRef_;\r\n\r\n\t//! Contains the references to file sets of the containing component.\r\n\tQStringList fileSetRefs_;\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n\r\n#endif // SYSTEMVIEW_H\r\n"
  },
  {
    "path": "IPXACTmodels/kactusExtensions/validators/ApiDefinitionValidator.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ApiDefinitionValidator.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Janne Virtanen\r\n// Date: 28.01.2016\r\n//\r\n// Description:\r\n// Validator for kactus2:ApiDefinition.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"ApiDefinitionValidator.h\"\r\n\r\n#include <IPXACTmodels/kactusExtensions/ApiDefinition.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ApiDefinitionValidator::ApiDefinitionValidator()\r\n//-----------------------------------------------------------------------------\r\nApiDefinitionValidator::ApiDefinitionValidator()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ApiDefinitionValidator::~ApiDefinitionValidator()\r\n//-----------------------------------------------------------------------------\r\nApiDefinitionValidator::~ApiDefinitionValidator()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ApiDefinitionValidator::validate()\r\n//-----------------------------------------------------------------------------\r\nbool ApiDefinitionValidator::validate(QSharedPointer<const ApiDefinition> apiDefinition) const\r\n{\r\n\tif (!apiDefinition->getVlnv().isValid() )\r\n\t{\r\n\t\treturn false;\r\n\t}\r\n\r\n\t// Check that the COM definition reference is valid.\r\n\tif (!apiDefinition->getComDefinitionRef().isEmpty() &&\r\n\t\t!apiDefinition->getComDefinitionRef().isValid())\r\n\t{\r\n\t\treturn false;\r\n\t}\r\n\r\n\t// Check for multiple definitions of same data type.\r\n\tQStringList dataTypeNames;\r\n\r\n    for (QString const& dataType : *apiDefinition->getDataTypes())\r\n    {\r\n        if (dataTypeNames.contains(dataType))\r\n        {\r\n            return false;\r\n        }\r\n\r\n        dataTypeNames.push_back(dataType);\r\n    }\r\n\r\n    // Validate the functions.\r\n    QStringList funcNames;\r\n\r\n    for (QSharedPointer<ApiFunction> func : *apiDefinition->getFunctions())\r\n    {\r\n        if (funcNames.contains(func->name()))\r\n        {\r\n            return false;\r\n        }\r\n\r\n        funcNames.append(func->name());\r\n\r\n        if (!func->validate())\r\n        {\r\n            return false;\r\n        }\r\n    }\r\n\r\n    return true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ApiDefinitionValidator::findErrorsIn()\r\n//-----------------------------------------------------------------------------\r\nvoid ApiDefinitionValidator::findErrorsIn(QVector<QString>& errorList,\r\n    QSharedPointer<const ApiDefinition> apiDefinition) const\r\n{\r\n\tQString thisIdentifier(QObject::tr(\"the containing API definition\"));\r\n\r\n\tif (apiDefinition->getVlnv().isValid(errorList, thisIdentifier))\r\n\t{\r\n\t\tthisIdentifier = QObject::tr(\"API definition '%1'\").arg(apiDefinition->getVlnv().toString());\r\n\t}\r\n\r\n\t// Check that the COM definition reference is valid.\r\n\tif (!apiDefinition->getComDefinitionRef().isEmpty())\r\n\t{\r\n\t\tapiDefinition->getComDefinitionRef().isValid(errorList, thisIdentifier);\r\n\t}\r\n\r\n\t// Check for multiple definitions of same data type.\r\n\tQStringList dataTypeNames;\r\n\r\n\tfor (QString const& dataType : *apiDefinition->getDataTypes())\r\n\t{\r\n\t\tif (dataTypeNames.contains(dataType))\r\n\t\t{\r\n\t\t\terrorList.append(QObject::tr(\"Data type '%1' defined multiple times in '%2'\").arg(dataType, \r\n\t\t\t\tthisIdentifier));\r\n\t\t}\r\n\t\telse\r\n\t\t{\r\n\t\t\tdataTypeNames.push_back(dataType);\r\n\t\t}\r\n\t}\r\n\r\n\t// Validate the functions.\r\n\tQStringList funcNames;\r\n\r\n\tfor (QSharedPointer<ApiFunction> func : *apiDefinition->getFunctions())\r\n\t{\r\n\t\tif (funcNames.contains(func->name()))\r\n\t\t{\r\n\t\t\terrorList.append(QObject::tr(\"Function with name '%1' defined multiple times in %2\").arg(func->name(),\r\n\t\t\t\tthisIdentifier));\r\n\t\t}\r\n\t\telse\r\n\t\t{\r\n\t\t\tfuncNames.append(func->name());\r\n\t\t}\r\n\r\n\t\tfunc->findErrors(errorList, thisIdentifier);\r\n\t}\r\n}\r\n"
  },
  {
    "path": "IPXACTmodels/kactusExtensions/validators/ApiDefinitionValidator.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ApiDefinitionValidator.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Janne Virtanen\r\n// Date: 28.01.2016\r\n//\r\n// Description:\r\n// Validator for kactus2:ApiDefinition.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef APIDEFINITIONVALIDATOR_H\r\n#define APIDEFINITIONVALIDATOR_H\r\n\r\n#include <IPXACTmodels/ipxactmodels_global.h>\r\n\r\n#include <QString>\r\n#include <QSharedPointer>\r\n#include <QVector>\r\n\r\nclass ApiDefinition;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Validator for ipxact:ApiDefinition.\r\n//-----------------------------------------------------------------------------\r\nclass IPXACTMODELS_EXPORT ApiDefinitionValidator\r\n{\r\npublic:\r\n\r\n\t/*!\r\n\t *  The constructor.\r\n\t *\r\n     *    @param [in] expressionParser    The expression parser to use.\r\n\t */\r\n    ApiDefinitionValidator();\r\n\r\n\t//! The destructor.\r\n\t~ApiDefinitionValidator();\r\n    \r\n    /*!\r\n     *  Validates the given ApiDefinition.\r\n     *\r\n     *    @param [in] ApiDefinition           The ApiDefinition to validate.\r\n     *\r\n     *    @return True, if the ApiDefinition is valid IP-XACT, otherwise false.\r\n     */\r\n    virtual bool validate(QSharedPointer<const ApiDefinition> apiDefinition) const;\r\n\r\n    /*!\r\n     *  Finds possible errors in a ApiDefinition and creates a list of them.\r\n     *\r\n     *    @param [out] errors         List of found errors.\r\n     *    @param [in] ApiDefinition   The ApiDefinition whose errors to find.\r\n     */\r\n    virtual void findErrorsIn(QVector<QString>& errorList, QSharedPointer<const ApiDefinition> apiDefinition) const;\r\n\r\nprivate:\r\n\r\n\t// Disable copying.\r\n\tApiDefinitionValidator(ApiDefinitionValidator const& rhs);\r\n\tApiDefinitionValidator& operator=(ApiDefinitionValidator const& rhs);\r\n};\r\n\r\n#endif\r\n"
  },
  {
    "path": "IPXACTmodels/kactusExtensions/validators/ComDefinitionValidator.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ComDefinitionValidator.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Janne Virtanen\r\n// Date: 28.01.2016\r\n//\r\n// Description:\r\n// Validator for kactus2:ComDefinition.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"ComDefinitionValidator.h\"\r\n\r\n#include <IPXACTmodels/kactusExtensions/ComDefinition.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComDefinitionValidator::ComDefinitionValidator()\r\n//-----------------------------------------------------------------------------\r\nComDefinitionValidator::ComDefinitionValidator()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComDefinitionValidator::~ComDefinitionValidator()\r\n//-----------------------------------------------------------------------------\r\nComDefinitionValidator::~ComDefinitionValidator()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComDefinitionValidator::validate()\r\n//-----------------------------------------------------------------------------\r\nbool ComDefinitionValidator::validate(QSharedPointer<const ComDefinition> comDefinition) const\r\n{\r\n\tif (!comDefinition->getVlnv().isValid())\r\n\t{\r\n\t\treturn false;\r\n\t}\r\n\r\n\t// Check for multiple definitions of same transfer type.\r\n\tQStringList transferTypeNames;\r\n\r\n\tfor (QString const& transferType : *comDefinition->getTransferTypes())\r\n\t{\r\n\t\tif (transferTypeNames.contains(transferType))\r\n        {\r\n            return false;\r\n        }\r\n\r\n        transferTypeNames.push_back(transferType);\r\n    }\r\n\r\n    // Validate the properties.\r\n    QStringList propertyNames;\r\n\r\n\tfor (QSharedPointer<ComProperty> prop : comDefinition->getProperties())\r\n\t{\r\n        if (propertyNames.contains(prop->name()))\r\n        {\r\n            return false;\r\n        }\r\n\r\n        propertyNames.append(prop->name());\r\n\r\n        if (!prop->validate())\r\n        {\r\n            return false;\r\n        }\r\n    }\r\n\r\n    return true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComDefinitionValidator::findErrorsIn()\r\n//-----------------------------------------------------------------------------\r\nvoid ComDefinitionValidator::findErrorsIn(QVector<QString>& errorList,\r\n    QSharedPointer<const ComDefinition> comDefinition) const\r\n{\r\n\tQString thisIdentifier(QObject::tr(\"the containing COM definition\"));\r\n\r\n\tif (comDefinition->getVlnv().isValid(errorList, thisIdentifier))\r\n\t{\r\n\t\tthisIdentifier = QObject::tr(\"COM definition '%1'\").arg(comDefinition->getVlnv().toString());\r\n\t}\r\n\r\n\t// Check for multiple definitions of same data type.\r\n\tQStringList dataTypeNames;\r\n    for (QString const& dataType : *comDefinition->getTransferTypes())\r\n    {\r\n        if (dataTypeNames.contains(dataType))\r\n        {\r\n            errorList.append(QObject::tr(\"Data type '%1' defined multiple times in '%2'\").arg(dataType,\r\n                thisIdentifier));\r\n        }\r\n\r\n        dataTypeNames.push_back(dataType);\r\n    }\r\n\r\n    // Validate the properties.\r\n    QStringList propertyNames;\r\n    for (QSharedPointer<ComProperty> comProperty : comDefinition->getProperties())\r\n    {\r\n        if (propertyNames.contains(comProperty->name()))\r\n        {\r\n            errorList.append(QObject::tr(\"Property '%1' defined multiple times in %2\").arg(comProperty->name(),\r\n                thisIdentifier));\r\n        }\r\n\r\n        propertyNames.append(comProperty->name());\r\n\r\n\t\tcomProperty->findErrors(errorList, thisIdentifier);\r\n\t}\r\n}\r\n"
  },
  {
    "path": "IPXACTmodels/kactusExtensions/validators/ComDefinitionValidator.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ComDefinitionValidator.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Janne Virtanen\r\n// Date: 28.01.2016\r\n//\r\n// Description:\r\n// Validator for kactus2:ComDefinition.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef COMDEFINITIONVALIDATOR_H\r\n#define COMDEFINITIONVALIDATOR_H\r\n\r\n#include <IPXACTmodels/ipxactmodels_global.h>\r\n\r\n#include <QString>\r\n#include <QSharedPointer>\r\n#include <QVector>\r\n\r\nclass ComDefinition;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Validator for ipxact:ComDefinition.\r\n//-----------------------------------------------------------------------------\r\nclass IPXACTMODELS_EXPORT ComDefinitionValidator\r\n{\r\npublic:\r\n\r\n\t/*!\r\n\t *  The constructor.\r\n\t *\r\n     *    @param [in] expressionParser    The expression parser to use.\r\n\t */\r\n    ComDefinitionValidator();\r\n\r\n\t//! The destructor.\r\n\t~ComDefinitionValidator();\r\n    \r\n    /*!\r\n     *  Validates the given ComDefinition.\r\n     *\r\n     *    @param [in] ComDefinition           The ComDefinition to validate.\r\n     *\r\n     *    @return True, if the ComDefinition is valid IP-XACT, otherwise false.\r\n     */\r\n    virtual bool validate(QSharedPointer<const ComDefinition> comDefinition) const;\r\n\r\n    /*!\r\n     *  Finds possible errors in a ComDefinition and creates a list of them.\r\n     *\r\n     *    @param [out] errors         List of found errors.\r\n     *    @param [in] ComDefinition   The ComDefinition whose errors to find.\r\n     */\r\n    virtual void findErrorsIn(QVector<QString>& errorList, QSharedPointer<const ComDefinition> comDefinition) const;\r\n\r\nprivate:\r\n\r\n\t// Disable copying.\r\n\tComDefinitionValidator(ComDefinitionValidator const& rhs);\r\n\tComDefinitionValidator& operator=(ComDefinitionValidator const& rhs);\r\n};\r\n\r\n#endif // SYSTEMVERILOGVALIDATOR_H\r\n"
  },
  {
    "path": "IPXACTmodels/kactusExtensions/validators/SystemDesignConfigurationValidator.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: SystemDesignConfigurationValidator.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 09.02.2016\r\n//\r\n// Description:\r\n// Validator for the kactus2:systemDesignConfiguration.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"SystemDesignConfigurationValidator.h\"\r\n\r\n#include <IPXACTmodels/kactusExtensions/validators/SystemViewConfigurationValidator.h>\r\n\r\n#include <IPXACTmodels/DesignConfiguration/DesignConfiguration.h>\r\n\r\n#include <IPXACTmodels/Design/Design.h>\r\n#include <IPXACTmodels/Design/ComponentInstance.h>\r\n\r\n#include <IPXACTmodels/DesignConfiguration/validators/ViewConfigurationValidator.h>\r\n\r\n#include <KactusAPI/include/LibraryInterface.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SystemDesignConfigurationValidator::SystemDesignConfigurationValidator()\r\n//-----------------------------------------------------------------------------\r\nSystemDesignConfigurationValidator::SystemDesignConfigurationValidator(QSharedPointer<ExpressionParser> parser,\r\n    LibraryInterface* library):\r\nDesignConfigurationValidator(parser, library),\r\nsystemViewConfigurationValidator_()\r\n{\r\n    systemViewConfigurationValidator_ =\r\n        QSharedPointer<SystemViewConfigurationValidator>(new SystemViewConfigurationValidator(library, parser));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SystemDesignConfigurationValidator::~DesignConfigurationValidator()\r\n//-----------------------------------------------------------------------------\r\nSystemDesignConfigurationValidator::~SystemDesignConfigurationValidator()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SystemDesignConfigurationValidator::hasValidViewConfigurations()\r\n//-----------------------------------------------------------------------------\r\nbool SystemDesignConfigurationValidator::hasValidViewConfigurations(\r\n    QSharedPointer<DesignConfiguration> designConfiguration) const\r\n{\r\n    if (!designConfiguration->getViewConfigurations()->isEmpty())\r\n    {\r\n        if (designConfiguration->getDesignRef().isValid())\r\n        {\r\n            QSharedPointer<Design> referencedDesign =\r\n                getLibraryHandler()->getDesign(designConfiguration->getDesignRef());\r\n\r\n            QSharedPointer<QList<QSharedPointer<ComponentInstance> > > hwInstances =\r\n                referencedDesign->getComponentInstances();\r\n\r\n            getViewConfigurationValidator()->changeComponentInstances(hwInstances);\r\n            systemViewConfigurationValidator_->changeComponentInstances(hwInstances);\r\n\r\n            QVector<QString> instanceNames;\r\n            foreach (QSharedPointer<ViewConfiguration> viewConfiguration,\r\n                *designConfiguration->getViewConfigurations())\r\n            {\r\n\t\t\t\tif ( instanceNames.contains(viewConfiguration->getInstanceName() ) )\r\n\t\t\t\t{\r\n\t\t\t\t\treturn false;\r\n\t\t\t\t}\r\n\t\t\t\t\t\r\n\t\t\t\tif ( viewConfigurationReferencesHWInstance(viewConfiguration, hwInstances) )\r\n\t\t\t\t{\r\n\t\t\t\t\tif ( !getViewConfigurationValidator()->validate(viewConfiguration) )\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\treturn false;\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t\telse if ( !systemViewConfigurationValidator_->validate(viewConfiguration) )\r\n                {\r\n                    return false;\r\n                }\r\n\r\n                instanceNames.append(viewConfiguration->getInstanceName());\r\n            }\r\n        }\r\n        else\r\n        {\r\n            return false;\r\n        }\r\n    }\r\n\r\n    return true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SystemDesignConfigurationValidator::viewConfigurationReferencesHWInstance()\r\n//-----------------------------------------------------------------------------\r\nbool SystemDesignConfigurationValidator::viewConfigurationReferencesHWInstance(\r\n    QSharedPointer<ViewConfiguration> viewConfiguration,\r\n    QSharedPointer<QList<QSharedPointer<ComponentInstance> > > hwInstances) const\r\n{\r\n    for (QSharedPointer<ComponentInstance> instance : *hwInstances)\r\n    {\r\n        if (viewConfiguration->getInstanceName() == instance->getInstanceName())\r\n        {\r\n            return true;\r\n        }\r\n    }\r\n\r\n    return false;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SystemDesignConfigurationValidator::findErrorsInViewConfigurations()\r\n//-----------------------------------------------------------------------------\r\nvoid SystemDesignConfigurationValidator::findErrorsInViewConfigurations(QVector<QString>& errors,\r\n    QSharedPointer<DesignConfiguration> designConfiguration, QString const& context) const\r\n{\r\n    if (!designConfiguration->getViewConfigurations()->isEmpty())\r\n    {\r\n        if (designConfiguration->getDesignRef().isValid())\r\n        {\r\n            QSharedPointer<Design> referencedDesign =\r\n                getLibraryHandler()->getDesign(designConfiguration->getDesignRef());\r\n\r\n            QSharedPointer<QList<QSharedPointer<ComponentInstance> > > hwInstances;\r\n\r\n            if (referencedDesign)\r\n            {\r\n                hwInstances = referencedDesign->getComponentInstances();\r\n\r\n                getViewConfigurationValidator()->changeComponentInstances(hwInstances);\r\n                systemViewConfigurationValidator_->changeComponentInstances(hwInstances);\r\n            }\r\n\r\n            QVector<QString> instanceNames;\r\n            QVector<QString> duplicateNames;\r\n            foreach (QSharedPointer<ViewConfiguration> viewConfiguration,\r\n                *designConfiguration->getViewConfigurations())\r\n            {\r\n                if (instanceNames.contains(viewConfiguration->getInstanceName()) &&\r\n                    !duplicateNames.contains(viewConfiguration->getInstanceName()))\r\n                {\r\n                    errors.append(QObject::tr(\"View configuration name '%1' within %2 is not unique.\")\r\n                        .arg(viewConfiguration->getInstanceName()).arg(context));\r\n                    duplicateNames.append(viewConfiguration->getInstanceName());\r\n                }\r\n                else\r\n                {\r\n                    instanceNames.append(viewConfiguration->getInstanceName());\r\n                }\r\n\r\n                if (hwInstances && viewConfigurationReferencesHWInstance(viewConfiguration, hwInstances))\r\n                {\r\n                    getViewConfigurationValidator()->findErrorsIn(errors, viewConfiguration, context);\r\n                }\r\n                else\r\n                {\r\n                    systemViewConfigurationValidator_->findErrorsIn(errors, viewConfiguration, context);\r\n                }\r\n            }\r\n        }\r\n    }\r\n}\r\n"
  },
  {
    "path": "IPXACTmodels/kactusExtensions/validators/SystemDesignConfigurationValidator.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: SystemDesignConfigurationValidator.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 09.02.2016\r\n//\r\n// Description:\r\n// Validator for the kactus2:systemDesignConfiguration.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef SYSTEMDESIGNCONFIGURATIONVALIDATOR_H\r\n#define SYSTEMDESIGNCONFIGURATIONVALIDATOR_H\r\n\r\n#include <IPXACTmodels/ipxactmodels_global.h>\r\n\r\n#include <IPXACTmodels/DesignConfiguration/validators/DesignConfigurationValidator.h>\r\n\r\n#include <QSharedPointer>\r\n#include <QString>\r\n#include <QVector>\r\n\r\nclass DesignConfiguration;\r\nclass Design;\r\nclass ComponentInstance;\r\nclass ViewConfiguration;\r\n\r\nclass LibraryInterface;\r\nclass ExpressionParser;\r\n\r\nclass SystemViewConfigurationValidator;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Validator for the kactus2:systemDesignConfiguration.\r\n//-----------------------------------------------------------------------------\r\nclass IPXACTMODELS_EXPORT SystemDesignConfigurationValidator : public DesignConfigurationValidator\r\n{\r\npublic:\r\n\r\n    /*!\r\n     *  The constructor.\r\n     *\r\n     *    @param [in] parser      The used expression parser.\r\n     *    @param [in] library     The used library interface.\r\n     */\r\n    SystemDesignConfigurationValidator(QSharedPointer<ExpressionParser> parser, LibraryInterface* library);\r\n\r\n\t//! The destructor.\r\n\t~SystemDesignConfigurationValidator();\r\n    \r\n    /*!\r\n     *  Check if the view configurations are valid.\r\n     *\r\n     *    @param [in] designConfiguration     The selected design configuration.\r\n     *\r\n     *    @return True, if the view configurations are valid, otherwise false.\r\n     */\r\n    virtual bool hasValidViewConfigurations(QSharedPointer<DesignConfiguration> designConfiguration) const;\r\n\r\nprivate:\r\n\r\n\t// Disable copying.\r\n\tSystemDesignConfigurationValidator(SystemDesignConfigurationValidator const& rhs);\r\n\tSystemDesignConfigurationValidator& operator=(SystemDesignConfigurationValidator const& rhs);\r\n\r\n    /*!\r\n     *  Check if the view configuration references a hw component instances.\r\n     *\r\n     *    @param [in] viewConfiguration   The view configuration to check.\r\n     *    @param [in] hwInstances         The currently available hw component instances.\r\n     */\r\n    bool viewConfigurationReferencesHWInstance(QSharedPointer<ViewConfiguration> viewConfiguration,\r\n        QSharedPointer<QList<QSharedPointer<ComponentInstance> > > hwInstances) const;\r\n\r\n    /*!\r\n     *  Find errors in view configurations.\r\n     *\r\n     *    @param [in] errors                  List of found errors.\r\n     *    @param [in] designConfiguration     The selected design configuration.\r\n     *    @param [in] context                 Context to help locate the errors.\r\n     */\r\n    virtual void findErrorsInViewConfigurations(QVector<QString>& errors,\r\n        QSharedPointer<DesignConfiguration> designConfiguration, QString const& context) const;\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! The used system view configuration validator.\r\n    QSharedPointer<SystemViewConfigurationValidator> systemViewConfigurationValidator_;\r\n};\r\n\r\n#endif // SYSTEMDESIGNCONFIGURATIONVALIDATOR_H\r\n"
  },
  {
    "path": "IPXACTmodels/kactusExtensions/validators/SystemViewConfigurationValidator.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: SystemViewConfigurationValidator.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 09.02.2016\r\n//\r\n// Description:\r\n// Validator for the kactus2:SystemViewConfiguration.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"SystemViewConfigurationValidator.h\"\r\n\r\n#include <KactusAPI/include/LibraryInterface.h>\r\n\r\n#include <IPXACTmodels/Design/ComponentInstance.h>\r\n\r\n#include <IPXACTmodels/DesignConfiguration/ViewConfiguration.h>\r\n\r\n#include <IPXACTmodels/Component/Component.h>\r\n#include <IPXACTmodels/kactusExtensions/SystemView.h>\r\n\r\n#include <QRegularExpression>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SystemViewConfigurationValidator::SystemViewConfigurationValidator()\r\n//-----------------------------------------------------------------------------\r\nSystemViewConfigurationValidator::SystemViewConfigurationValidator(LibraryInterface* library,\r\n    QSharedPointer<ExpressionParser> parser):\r\nViewConfigurationValidator(library, parser),\r\navailableViews_()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SystemViewConfigurationValidator::~SystemViewConfigurationValidator()\r\n//-----------------------------------------------------------------------------\r\nSystemViewConfigurationValidator::~SystemViewConfigurationValidator()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SystemViewConfigurationValidator::hasValidViewReference()\r\n//-----------------------------------------------------------------------------\r\nbool SystemViewConfigurationValidator::hasValidViewReference(QSharedPointer<ViewConfiguration> configuration)\r\n{\r\n    changeAvailableSystemViews(configuration);\r\n\r\n    if (!configuration->getViewReference().isEmpty() && !availableViews_.isEmpty())\r\n    {\r\n        foreach (QString currentView, availableViews_)\r\n        {\r\n            if (configuration->getViewReference() == currentView)\r\n            {\r\n                return true;\r\n            }\r\n        }\r\n    }\r\n\r\n    return false;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SystemViewConfigurationValidator::changeAvailableSystemViews()\r\n//-----------------------------------------------------------------------------\r\nvoid SystemViewConfigurationValidator::changeAvailableSystemViews(QSharedPointer<ViewConfiguration> configuration)\r\n{\r\n    if (!configuration->getInstanceName().isEmpty() && getAvailableInstances())\r\n    {\r\n        foreach (QSharedPointer<ComponentInstance> instance, *getAvailableInstances())\r\n        {\r\n            if (instance->getInstanceName() == configuration->getInstanceName())\r\n            {\r\n                if (instance->getComponentRef() && instance->getComponentRef()->isValid())\r\n                {\r\n                    QSharedPointer<Component> component = getLibraryHandler()->getModel(\r\n                        *instance->getComponentRef().data()).dynamicCast<Component>();\r\n\r\n                    if (component)\r\n                    {\r\n                        availableViews_ = component->getViewNames();\r\n\t\t\t\t\t\tavailableViews_.append( component->getSystemViewNames() );\r\n                        return;\r\n                    }\r\n                }\r\n\r\n                break;\r\n            }\r\n        }\r\n    }\r\n    \r\n    if (!availableViews_.isEmpty())\r\n    {\r\n        availableViews_.clear();\r\n    }\r\n}\r\n"
  },
  {
    "path": "IPXACTmodels/kactusExtensions/validators/SystemViewConfigurationValidator.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: SystemViewConfigurationValidator.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 09.02.2016\r\n//\r\n// Description:\r\n// Validator for the kactus2:SystemViewConfiguration.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef SYSTEMVIEWCONFIGURATIONVALIDATOR_H\r\n#define SYSTEMVIEWCONFIGURATIONVALIDATOR_H\r\n\r\n#include <IPXACTmodels/ipxactmodels_global.h>\r\n\r\n#include <IPXACTmodels/DesignConfiguration/validators/ViewConfigurationValidator.h>\r\n\r\n#include <QSharedPointer>\r\n#include <QString>\r\n#include <QVector>\r\n\r\nclass SystemView;\r\nclass SWInstance;\r\n\r\nclass ExpressionParser;\r\nclass LibraryInterface;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Validator for the kactus2:SystemViewConfiguration.\r\n//-----------------------------------------------------------------------------\r\nclass IPXACTMODELS_EXPORT SystemViewConfigurationValidator: public ViewConfigurationValidator\r\n{\r\npublic:\r\n\r\n    /*!\r\n     *  The constructor.\r\n     *\r\n     *    @param [in] library     The used library interface.\r\n     *    @param [in] parser      The used expression parser.\r\n     */\r\n    SystemViewConfigurationValidator(LibraryInterface* library, QSharedPointer<ExpressionParser> parser);\r\n\r\n\t//! The destructor.\r\n\t~SystemViewConfigurationValidator();\r\n\r\n    /*!\r\n     *  Check if the view reference is valid.\r\n     *\r\n     *    @param [in] configuration   The selected view configuration.\r\n     *\r\n     *    @return True, if the view reference is valid, otherwise false.\r\n     */\r\n    virtual bool hasValidViewReference(QSharedPointer<ViewConfiguration> configuration);\r\n\r\nprivate:\r\n\r\n\t// Disable copying.\r\n\tSystemViewConfigurationValidator(SystemViewConfigurationValidator const& rhs);\r\n\tSystemViewConfigurationValidator& operator=(SystemViewConfigurationValidator const& rhs);\r\n\r\n    /*!\r\n     *  Change the currently available views.\r\n     *\r\n     *    @param [in] configuration   The selected view configuration.\r\n     */\r\n    void changeAvailableSystemViews(QSharedPointer<ViewConfiguration> configuration);\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! The currently available system views.\r\n    QStringList availableViews_;\r\n};\r\n\r\n#endif // SYSTEMVIEWCONFIGURATIONVALIDATOR_H\r\n"
  },
  {
    "path": "IPXACTmodels/utilities/BusDefinitionUtils.cpp",
    "content": "////-----------------------------------------------------------------------------\n// File: BusDefinitionUtils.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 29.03.2019\n//\n// Description:\n// Utilities for Bus Definitions and abstraction definitions.\n//-----------------------------------------------------------------------------\n\n#include \"BusDefinitionUtils.h\"\n\n#include <IPXACTmodels/AbstractionDefinition/AbstractionDefinition.h>\n#include <IPXACTmodels/AbstractionDefinition/PortAbstraction.h>\n\n#include <IPXACTmodels/BusDefinition/BusDefinition.h>\n\n#include <KactusAPI/include/LibraryInterface.h>\n\n//-----------------------------------------------------------------------------\n// Function: BusDefinitionUtils::getSystemGroups()\n//-----------------------------------------------------------------------------\nIPXACTMODELS_EXPORT QStringList BusDefinitionUtils::getSystemGroups(QSharedPointer<const BusDefinition> bus,\n    LibraryInterface* libraryAccess)\n{\n    QStringList systemGroups = bus->getSystemGroupNames();\n\n    VLNV const extendVLNV = bus->getExtends();\n    if (extendVLNV.isValid() && extendVLNV.getType() == VLNV::BUSDEFINITION && extendVLNV != bus->getVlnv())\n    {\n        QSharedPointer<const Document> extendDocument = libraryAccess->getModelReadOnly(extendVLNV);\n        if (extendDocument)\n        {\n            QSharedPointer<const BusDefinition> extendBus = extendDocument.dynamicCast<const BusDefinition>();\n            if (extendBus)\n            {\n                for (auto extendedSystem : getSystemGroups(extendBus, libraryAccess))\n                {\n                    if (!systemGroups.contains(extendedSystem))\n                    {\n                        systemGroups.append(extendedSystem);\n                    }\n                }\n            }\n        }\n    }\n\n    return systemGroups;\n}\n\n//-----------------------------------------------------------------------------\n// Function: BusDefinitionUtils::getExtendedLogicalSignals()\n//-----------------------------------------------------------------------------\nIPXACTMODELS_EXPORT QList<QSharedPointer<PortAbstraction> > BusDefinitionUtils::getExtendedLogicalSignals(\n    QSharedPointer<const AbstractionDefinition> abstraction, LibraryInterface* libraryAccess)\n{\n    QList<QSharedPointer<PortAbstraction> > extendsignals = *abstraction->getLogicalPorts();\n\n    VLNV const extendVLNV = abstraction->getExtends();\n    if (extendVLNV.isValid() && extendVLNV.getType() == VLNV::BUSDEFINITION && \n        extendVLNV != abstraction->getVlnv())\n    {\n        QSharedPointer<const Document> extendDocument = libraryAccess->getModelReadOnly(extendVLNV);\n        if (extendDocument)\n        {\n            QSharedPointer<const AbstractionDefinition> extendAbstraction =\n                extendDocument.dynamicCast<const AbstractionDefinition>();\n            if (extendAbstraction)\n            {\n                extendsignals.append(getExtendedLogicalSignals(extendAbstraction, libraryAccess));\n            }\n        }\n    }\n\n    return extendsignals;\n}\n"
  },
  {
    "path": "IPXACTmodels/utilities/BusDefinitionUtils.h",
    "content": "////-----------------------------------------------------------------------------\n// File: BusDefinitionUtils.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 29.03.2019\n//\n// Description:\n// Utilities for Bus Definitions and abstraction definitions.\n//-----------------------------------------------------------------------------\n\n#ifndef BUSDEFINITIONUTILS_H\n#define BUSDEFINITIONUTILS_H\n\n#include <IPXACTmodels/ipxactmodels_global.h>\n\n#include <QSharedPointer>\n#include <QString>\n\nclass AbstractionDefinition;\nclass BusDefinition;\nclass PortAbstraction;\nclass LibraryInterface;\n\n//-----------------------------------------------------------------------------\n//! Utilities for Bus Definitions and abstraction definitions.\n//-----------------------------------------------------------------------------\nnamespace BusDefinitionUtils\n{\n    /*!\n     *  Get a list of the system groups from the selected bus definition.\n     *\n     *    @param [in] bus             The selected bus definition.\n     *    @param [in] libraryAccess   Interface to the library.\n     *\n     *    @return List of bus definition system groups.\n     */\n    IPXACTMODELS_EXPORT QStringList getSystemGroups(QSharedPointer<const BusDefinition> bus,\n        LibraryInterface* libraryAccess);\n\n    /*!\n     *  Get a list of the extended port abstractions of the selected abstraction definition.\n     *\n     *    @param [in] abstraction     The selected abstraction definition.\n     *    @param [in] libraryAccess   Interface to the library.\n     *\n     *    @return List of extended port abstractions.\n     */\n    IPXACTMODELS_EXPORT QList<QSharedPointer<PortAbstraction> > getExtendedLogicalSignals(\n        QSharedPointer<const AbstractionDefinition> abstraction, LibraryInterface* libraryAccess);\n};\n\n//-----------------------------------------------------------------------------\n\n#endif // BUSDEFINITIONUTILS_H\n"
  },
  {
    "path": "IPXACTmodels/utilities/ComponentSearch.cpp",
    "content": "////-----------------------------------------------------------------------------\n// File: ComponentSearch.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Esko Pekkarinen\n// Date: 26.06.2018\n//\n// Description:\n// Utilities for searching items in Component.\n//-----------------------------------------------------------------------------\n\n#include \"ComponentSearch.h\"\n\n#include \"Search.h\"\n\n#include <IPXACTmodels/Component/Model.h>\n#include <IPXACTmodels/DesignConfiguration/DesignConfiguration.h>\n#include <IPXACTmodels/Design/Design.h>\n\n#include <KactusAPI/include/LibraryInterface.h>\n\n//-----------------------------------------------------------------------------\n// Function: ComponentSearch::findDesignReference()\n//-----------------------------------------------------------------------------\nVLNV ComponentSearch::findDesignReference(QSharedPointer<Component> component, LibraryInterface* libraryHandler, \n    QString const& viewName)\n{\n    return findDesignReference(component, libraryHandler, Search::findByName(viewName, *component->getViews()));\n}\n\n//-----------------------------------------------------------------------------\n// Function: ComponentSearch::findDesignReference()\n//-----------------------------------------------------------------------------\nVLNV ComponentSearch::findDesignReference(QSharedPointer<Component> component, LibraryInterface* libraryHandler, \n    QSharedPointer<View> view)\n{\n    if (view.isNull() == false)\n    {\n        if (auto designInstantion = Search::findByName(view->getDesignInstantiationRef(),\n            *component->getDesignInstantiations()))\n        {\n            return VLNV(*designInstantion->getDesignReference());\n        }\n\n        // Look for design reference in design configuration if no design instantiation.\n        auto designConfigRef = findDesignConfigurationReference(component, view);\n\n        if (auto designCfg = libraryHandler->getModelReadOnly<DesignConfiguration>(designConfigRef))\n        {\n            return designCfg->getDesignRef();\n        }\n    }\n\n    return VLNV();\n}\n\n//-----------------------------------------------------------------------------\n// Function: ComponentSearch::findDesignConfigurationReference()\n//-----------------------------------------------------------------------------\nVLNV ComponentSearch::findDesignConfigurationReference(QSharedPointer<Component> component, QSharedPointer<View> view)\n{\n    if (view.isNull() == false)\n    {\n        auto configurationInstantiation = Search::findByName(view->getDesignConfigurationInstantiationRef(),\n            *component->getDesignConfigurationInstantiations());\n\n        if (configurationInstantiation)\n        {\n            return  VLNV(*configurationInstantiation->getDesignConfigurationReference());\n        }\n    }\n\n    return VLNV();\n}\n\n//-----------------------------------------------------------------------------\n// Function: ComponentSearch::findView()\n//-----------------------------------------------------------------------------\nQSharedPointer<View> ComponentSearch::findView(QSharedPointer<Component> component, QString const& viewName)\n{\n    return Search::findByName(viewName, *component->getViews());\n}\n\n//-----------------------------------------------------------------------------\n// Function: ComponentSearch::findComponentInstantiation()\n//-----------------------------------------------------------------------------\nQSharedPointer<ComponentInstantiation> ComponentSearch::findComponentInstantiation(\n    QSharedPointer<Component> component, QString const& viewName)\n{\n    if (QSharedPointer<View> view = findView(component, viewName))\n    {\n        for (auto const& instantiation : *component->getComponentInstantiations())\n        {\n            if (instantiation->name() == view->getComponentInstantiationRef())\n            {\n                return instantiation;\n            }\n        }\n    }\n\n    return QSharedPointer<ComponentInstantiation>();\n}"
  },
  {
    "path": "IPXACTmodels/utilities/ComponentSearch.h",
    "content": "////-----------------------------------------------------------------------------\n// File: ComponentSearch.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Esko Pekkarinen\n// Date: 26.06.2018\n//\n// Description:\n// Utilities for searching items in Component.\n//-----------------------------------------------------------------------------\n\n#ifndef COMPONENT_SEARCH_H\n#define COMPONENT_SEARCH_H\n\n#include <IPXACTmodels/common/VLNV.h>\n\n#include <IPXACTmodels/Component/Component.h>\n#include <IPXACTmodels/Component/View.h>\n\n#include <QSharedPointer>\n\nclass LibraryInterface;\n\n//-----------------------------------------------------------------------------\n//! Utilities for searching items in Component.\n//-----------------------------------------------------------------------------\nnamespace ComponentSearch\n{\n    VLNV findDesignReference(QSharedPointer<Component> component, LibraryInterface* libraryHandler, QString const& viewName);\n\n    VLNV findDesignReference(QSharedPointer<Component> component, LibraryInterface* libraryHandler, QSharedPointer<View> view);\n\n    VLNV findDesignConfigurationReference(QSharedPointer<Component> component, QSharedPointer<View> view);\n\n    QSharedPointer<View> findView(QSharedPointer<Component> component, QString const& viewName);\n\n    QSharedPointer<ComponentInstantiation> findComponentInstantiation(QSharedPointer<Component> component,\n        QString const& viewName);\n};\n\n//-----------------------------------------------------------------------------\n\n#endif // COMPONENT_SEARCH_H\n"
  },
  {
    "path": "IPXACTmodels/utilities/Copy.h",
    "content": "//-----------------------------------------------------------------------------\n// File: Copy.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Esko Pekkarinen\n// Date: 24.10.2023\n//\n// Description:\n// Utilities for copying objects.\n//-----------------------------------------------------------------------------\n\n#ifndef COPY_H\n#define COPY_H\n\n#include <QSharedPointer>\n#include <QList>\n\n//-----------------------------------------------------------------------------\n//! Utilities for copying objects.\n//-----------------------------------------------------------------------------\nnamespace Copy\n{\n\n    template <typename Item>\n    void copyList(QSharedPointer<QList<QSharedPointer<Item> > > from,\n        QSharedPointer<QList<QSharedPointer<Item> > > to)\n    {\n        if (from.isNull() || to.isNull())\n        {\n            return;\n        }\n\n        std::for_each(from->cbegin(), from->cend(), [&to](auto const& item) \n            { to->append(QSharedPointer<Item>(new Item(*item))); });\n\n    };\n\n    template <typename Item>\n    void copyList(QSharedPointer<QList<Item>  > from, QSharedPointer<QList<Item> > to)\n    {\n        if (from.isNull() || to.isNull())\n        {\n            return;\n        }\n\n        std::for_each(from->cbegin(), from->cend(), [&to](auto const& item)\n            { to->append(Item(item)); });\n\n    };\n};\n\n//-----------------------------------------------------------------------------\n\n#endif // COPY_H\n"
  },
  {
    "path": "IPXACTmodels/utilities/Search.h",
    "content": "////-----------------------------------------------------------------------------\n// File: Search.hh\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Esko Pekkarinen\n// Date: 26.06.2018\n//\n// Description:\n// Utilities for generic searching of items.\n//-----------------------------------------------------------------------------\n\n#ifndef SEARCH_H\n#define SEARCH_H\n\n#include <QSharedPointer>\n\n//-----------------------------------------------------------------------------\n//! Utilities for generic searching of items.\n//-----------------------------------------------------------------------------\nnamespace Search\n{\n    template <typename Container>\n    QStringList getNames(QSharedPointer<Container> items)\n    {\n        if (items == nullptr)\n        {\n            return QStringList();\n        }\n\n        QStringList names;\n        if (items.isNull() == false)\n        {\n            std::for_each(items->cbegin(), items->cend(), [&names](auto const& it) { names.append(it->name()); });\n        }\n\n        return names;\n    };\n\n\n    template <typename Container>\n    QStringList getNames(Container const& items)\n    {\n        QStringList names;\n        std::for_each(items.cbegin(), items.cend(), [&names](auto const& it) { names.append(it->name()); });\n        return names;\n    };\n\n    template <typename ContainerItem, template <typename> class Container>\n    QSharedPointer<ContainerItem> findByName(QStringView name,\n        QSharedPointer<Container<QSharedPointer<ContainerItem> > > container)\n    {\n        if (container == nullptr)\n        {\n            return nullptr;\n        }\n\n        auto item = std::find_if(container->constBegin(), container->constEnd(),\n            [&name](QSharedPointer<ContainerItem> const& item) { return item->name().compare(name) == 0; });\n\n        if (item == container->constEnd())\n        {\n            return nullptr;\n        }\n\n        return *item;\n    }\n\n    template <typename ContainerItem, template <typename> class Container>\n    QSharedPointer<ContainerItem> findByName(QStringView name,\n        Container<QSharedPointer<ContainerItem> > container)\n    {\n        auto item = std::find_if(container.constBegin(), container.constEnd(),\n            [&name](QSharedPointer<ContainerItem> const& item) { return item->name().compare(name) == 0; });\n\n        if (item == container.constEnd())\n        {\n            return nullptr;\n        }\n\n        return *item;\n    }\n};\n\n//-----------------------------------------------------------------------------\n\n#endif // SEARCH_H\n"
  },
  {
    "path": "IPXACTmodels/utilities/XmlUtils.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: Utils.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Joni-Matti Maatta\r\n// Date: 9.5.2012\r\n//\r\n// Description:\r\n// Common utilities for writing/parsing IP-XACT documents.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"XmlUtils.h\"\r\n\r\n#include <QSharedPointer>\r\n\r\n//-----------------------------------------------------------------------------\r\n\r\nnamespace XmlUtils\r\n{\r\n    //-----------------------------------------------------------------------------\r\n    // Function: removeWhiteSpace()\r\n    //-----------------------------------------------------------------------------\r\n    IPXACTMODELS_EXPORT QString removeWhiteSpace(QString const& str)\r\n    {\r\n        return str.simplified().replace(QLatin1Char(' '), QLatin1Char('_'));\r\n    }\r\n\r\n}\r\n"
  },
  {
    "path": "IPXACTmodels/utilities/XmlUtils.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: Utils.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Joni-Matti Maatta\r\n// Date: 9.5.2012\r\n//\r\n// Description:\r\n// Common utilities for writing/parsing IP-XACT documents.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef XMLUTILS_H\r\n#define XMLUTILS_H\r\n\r\n#include <IPXACTmodels/ipxactmodels_global.h>\r\n\r\n#include <QXmlStreamWriter>\r\n#include <QDomNode>\r\n#include <QString>\r\n#include <QMap>\r\n#include <QPointF>\r\n#include <QSharedPointer>\r\n\r\n//-----------------------------------------------------------------------------\r\n\r\nnamespace XmlUtils\r\n{\r\n\r\n    /*! \\brief removes white spaces from the given QString\r\n     *\r\n     *\tThis function removes white spaces from the beginning and end of the string\r\n     *\tand also replaces any embedded whitespaces with characted '_'. If you only\r\n     *\twant to remove the white spaces from the start and end use\r\n     *\tQString::trimmed() instead of this.\r\n     *\r\n     *\tIP-Xact types used for this function:\r\n     *\t-Name\r\n     *\t-NMTOKEN\r\n     *\t-PortName\r\n     *\t-ID\r\n     *\t-IDREF\r\n     *\r\n     * \\param str A reference to the QString where white spaces are wanted to\r\n     * be removed from.\r\n     *\r\n     * \\return QString containing the string that has been stripped from\r\n     * whitespaces and embedded whitespaces have been replaces with '_'\r\n     */\r\n    IPXACTMODELS_EXPORT QString removeWhiteSpace(QString const& str);\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n\r\n#endif // XMLUTILS_H\r\n"
  },
  {
    "path": "Kactus2.pri",
    "content": "# ----------------------------------------------------\r\n# This file is generated by the Qt Visual Studio Tools.\r\n# ------------------------------------------------------\r\n\r\n# This is a reminder that you are using a generated .pro file.\r\n# Remove it when you are finished editing this file.\r\nmessage(\"You are running qmake on a generated .pro file. This may not work!\")\r\n\r\n\r\nHEADERS += ./common/widgets/instanceWidgets/InstanceWidgets.h \\\r\n    ./common/NameGenerationPolicy.h \\\r\n    ./common/KactusColors.h \\\r\n    ./common/TextEditProvider.h \\\r\n    ./common/IEditProvider.h \\\r\n    ./common/GenericEditProvider.h \\\r\n    ./common/widgets/listManager/dirlistmanagermodel.h \\\r\n    ./common/widgets/listManager/listmanagermodel.h \\\r\n    ./common/widgets/listManager/listmanager.h \\\r\n    ./common/widgets/listManager/listeditor.h \\\r\n    ./common/widgets/listManager/dirlistmanager.h \\\r\n    ./common/widgets/nameGroupBox/namegroupbox.h \\\r\n    ./common/widgets/assistedLineEdit/BasicLineContentMatcher.h \\\r\n    ./common/widgets/assistedLineEdit/ILineContentMatcher.h \\\r\n    ./common/widgets/assistedLineEdit/LineContentAssistWidget.h \\\r\n    ./common/widgets/assistedLineEdit/AssistedLineEdit.h \\\r\n    ./common/widgets/vlnvDisplayer/vlnvdisplayer.h \\\r\n    ./common/widgets/booleanComboBox/booleancombobox.h \\\r\n    ./common/widgets/tabDocument/TabDocument.h \\\r\n    ./common/widgets/assistedTextEdit/HighlightStyleDesc.h \\\r\n    ./common/widgets/assistedTextEdit/ITextContentMatcher.h \\\r\n    ./common/widgets/assistedTextEdit/TextContentAssistWidget.h \\\r\n    ./common/widgets/assistedTextEdit/ToolTipHintWidget.h \\\r\n    ./common/widgets/assistedTextEdit/AssistedTextEdit.h \\\r\n    ./common/widgets/vlnvEditor/VLNVContentMatcher.h \\\r\n    ./common/widgets/vlnvEditor/VLNVDataTree.h \\\r\n    ./common/widgets/vlnvEditor/vlnveditor.h \\\r\n    ./common/widgets/colorBox/ColorBox.h \\\r\n    ./common/widgets/kactusAttributeEditor/KactusAttributeEditor.h \\\r\n    ./common/widgets/componentPreviewBox/ComponentPreviewBox.h \\\r\n    ./common/widgets/ParameterGroupBox/parametergroupbox.h \\\r\n    ./common/widgets/nameGroupEditor/namegroupeditor.h \\\r\n    ./common/widgets/summaryLabel/summarylabel.h \\\r\n    ./common/widgets/interfaceModeSelector/interfacemodeselector.h \\\r\n    ./common/widgets/interfaceSelector/interfaceselector.h \\\r\n    ./common/widgets/LineEditEx/LineEditEx.h \\\r\n    ./common/widgets/SnippetTextEdit/SnippetHighlighter.h \\\r\n    ./common/widgets/SnippetTextEdit/SnippetTextEdit.h \\\r\n    ./common/widgets/usageComboBox/usagecombobox.h \\\r\n    ./common/widgets/accessComboBox/accesscombobox.h \\\r\n    ./common/widgets/modWriteComboBox/modwritecombobox.h \\\r\n    ./common/widgets/readActionComboBox/readactioncombobox.h \\\r\n    ./common/widgets/testConstraintComboBox/testconstraintcombobox.h \\\r\n    ./common/widgets/viewSelector/viewselector.h \\\r\n    ./common/widgets/fileTypeSelector/filetypeselector.h \\\r\n    ./common/widgets/EnumCollectionEditor/EnumerationEditor.h \\\r\n    ./common/widgets/EnumCollectionEditor/InterfaceEnumEditor.h \\\r\n    ./common/widgets/EnumCollectionEditor/EnumCollectionEditor.h \\\r\n    ./common/widgets/FileSelector/fileselector.h \\\r\n    ./common/widgets/LibrarySelectorWidget/LibrarySelectorWidget.h \\\r\n    ./common/widgets/LibrarySelectorWidget/LibraryPathEditor/librarypatheditor.h \\\r\n    ./common/widgets/LibrarySelectorWidget/LibraryPathSelector/librarypathselector.h \\\r\n    ./common/widgets/DirectoryListSelector/DirectoryListSelector.h \\\r\n    ./common/widgets/tagEditor/FlowLayout.h \\\r\n    ./common/widgets/tagEditor/TagLabel.h \\\r\n    ./common/widgets/tagEditor/TagContainer.h \\\r\n    ./common/widgets/tagEditor/TagEditor.h \\\r\n    ./common/widgets/tagEditor/TagCompleterModel.h \\\r\n    ./common/widgets/tagEditor/TagEditorContainer.h \\\r\n    ./common/widgets/tagEditor/TagDisplay.h \\\r\n    ./common/widgets/tagEditor/TagSelectorContainer.h \\\r\n    ./common/widgets/tagEditor/TagSelector.h \\\r\n    ./common/widgets/busReferenceComboBox/BusReferenceComboBox.h \\\r\n    ./common/widgets/segmentComboBox/SegmentComboBox.h \\\r\n    ./common/widgets/TreeItemSelector/TreeItem.h \\\r\n    ./common/widgets/TreeItemSelector/TreeItemEditor.h \\\r\n    ./common/widgets/TreeItemSelector/TreeItemModel.h \\\r\n    ./common/widgets/TreeItemSelector/FramedTreeItemEditor.h \\\r\n    ./common/widgets/GroupBoxWithAlertSign/StyleOptionGroupBoxWithAlertSign.h \\\r\n    ./common/widgets/GroupBoxWithAlertSign/GroupBoxWithAlertSign.h \\\r\n    ./common/widgets/GroupBoxWithAlertSign/StyleGroupBoxWithAlertSign.h \\\r\n    ./common/validators/LibraryPathValidator/librarypathvalidator.h \\\r\n    ./common/layouts/VNoCollisionNoMovementLayout.h \\\r\n    ./common/layouts/HCollisionLayout.h \\\r\n    ./common/layouts/HStackedLayout.h \\\r\n    ./common/layouts/IHGraphicsLayout.h \\\r\n    ./common/layouts/IVGraphicsLayout.h \\\r\n    ./common/layouts/VCollisionLayout.h \\\r\n    ./common/layouts/VStackedLayout.h \\\r\n    ./common/layouts/VStaticLayout.h \\\r\n    ./common/graphicsItems/ConnectionItem.h \\\r\n    ./common/graphicsItems/GraphicsColumnAddCommand.h \\\r\n    ./common/graphicsItems/ConnectionUndoCommands.h \\\r\n    ./common/graphicsItems/GraphicsColumnUndoCommands.h \\\r\n    ./common/graphicsItems/GraphicsItemTypes.h \\\r\n    ./common/graphicsItems/IGraphicsItemStack.h \\\r\n    ./common/graphicsItems/GraphicsColumnConstants.h \\\r\n    ./common/graphicsItems/CommonGraphicsUndoCommands.h \\\r\n    ./common/graphicsItems/visualizeritem.h \\\r\n    ./common/graphicsItems/GraphicsRectButton.h \\\r\n    ./common/graphicsItems/GraphicsLineEdit.h \\\r\n    ./common/graphicsItems/graphicsexpandcollapseitem.h \\\r\n    ./common/graphicsItems/GraphicsConnection.h \\\r\n    ./common/graphicsItems/GraphicsColumnLayout.h \\\r\n    ./common/graphicsItems/GraphicsColumn.h \\\r\n    ./common/graphicsItems/expandableitem.h \\\r\n    ./common/graphicsItems/ConnectionEndpoint.h \\\r\n    ./common/graphicsItems/ComponentItem.h \\\r\n    ./common/delegates/ComboDelegate/combodelegate.h \\\r\n    ./common/delegates/LineEditDelegate/lineeditdelegate.h \\\r\n    ./common/views/EditableTableView/editabletableview.h \\\r\n    ./common/views/EditableListView/editablelistview.h \\\r\n    ./common/views/EditableTreeView/EditableTreeView.h \\\r\n    ./common/views/EditableTreeView/EditableTreeSortFilter.h \\\r\n    ./common/views/ExpandingTreeView/ExpandingTreeView.h \\\r\n    ./common/dialogs/comboSelector/comboselector.h \\\r\n    ./common/dialogs/propertyPageDialog/PropertyPageView.h \\\r\n    ./common/dialogs/propertyPageDialog/PropertyPageDialog.h \\\r\n    ./common/dialogs/newObjectDialog/newobjectdialog.h \\\r\n    ./common/dialogs/listSelectDialog/ListSelectDialog.h \\\r\n    ./common/dialogs/NewDesignDialog/NewDesignDialog.h \\\r\n    ./common/dialogs/LibrarySettingsDialog/LibrarySettingsColumns.h \\\r\n    ./common/dialogs/LibrarySettingsDialog/librarysettingsdelegate.h \\\r\n    ./common/dialogs/LibrarySettingsDialog/LibrarySettingsDialog.h \\\r\n    ./common/dialogs/createConfigurationDialog/createconfigurationdialog.h \\\r\n    ./common/dialogs/NewBusDialog/NewBusDialog.h \\\r\n    ./common/ui/GraphicalMessageMediator.h \\\r\n    ./common/expressions/utilities.h \\\r\n    ./mainwindow/CommandLineParser.h \\\r\n    ./mainwindow/SplashScreen.h \\\r\n    ./mainwindow/DockWidgetHandler.h \\\r\n    ./mainwindow/WorkspaceSettings.h \\\r\n    ./mainwindow/NewWorkspaceDialog.h \\\r\n    ./mainwindow/DeleteWorkspaceDialog.h \\\r\n    ./mainwindow/mainwindow.h \\\r\n    ./mainwindow/MessageConsole/messageconsole.h \\\r\n    ./mainwindow/Ribbon/RibbonTheme.h \\\r\n    ./mainwindow/Ribbon/Ribbon.h \\\r\n    ./mainwindow/Ribbon/RibbonGroup.h \\\r\n    ./mainwindow/NewPages/NewCatalogPage.h \\\r\n    ./mainwindow/NewPages/NewApiDefinitionPage.h \\\r\n    ./mainwindow/NewPages/NewBusDefinitionPage.h \\\r\n    ./mainwindow/NewPages/NewComDefinitionPage.h \\\r\n    ./mainwindow/NewPages/NewComponentPage.h \\\r\n    ./mainwindow/NewPages/NewDesignPage.h \\\r\n    ./mainwindow/NewPages/NewPage.h \\\r\n    ./mainwindow/NewPages/NewSWComponentPage.h \\\r\n    ./mainwindow/NewPages/NewSWDesignPage.h \\\r\n    ./mainwindow/NewPages/NewSystemPage.h \\\r\n    ./mainwindow/DrawingBoard/DrawingBoard.h \\\r\n    ./mainwindow/SaveHierarchy/DocumentTreeBuilder.h \\\r\n    ./mainwindow/SaveHierarchy/HierarchicalSaveColumns.h \\\r\n    ./mainwindow/SaveHierarchy/SaveAsItem.h \\\r\n    ./mainwindow/SaveHierarchy/SaveHierarchyDelegate.h \\\r\n    ./mainwindow/SaveHierarchy/HierarchicalSaveBuildStrategy.h \\\r\n    ./mainwindow/SaveHierarchy/SaveHierarchyDialog.h \\\r\n    ./settings/FileTypeColumns.h \\\r\n    ./settings/SettingsUpdater.h \\\r\n    ./settings/ComponentEditorSettingsPage.h \\\r\n    ./settings/NewPluginsDialog.h \\\r\n    ./settings/SettingsPage.h \\\r\n    ./settings/PluginSettingsPage.h \\\r\n    ./settings/FileTypeSettingsPage.h \\\r\n    ./settings/FileTypesModel.h \\\r\n    ./settings/FileTypesDelegate.h \\\r\n    ./settings/filetypesview.h \\\r\n    ./settings/k2envvariablesettingspage.h \\\r\n    ./settings/k2envvarmodel.h \\\r\n    ./settings/SettingsDialog.h \\\r\n    ./settings/NamingPolicySettingsPage.h \\\r\n    ./settings/GeneralSettingsPage.h \\\r\n    ./settings/CodeEditorSettingsPage.h \\\r\n    ./wizards/ComponentWizard/ComponentWizardDependencyPage.h \\\r\n    ./wizards/ComponentWizard/ComponentWizardIntroPage.h \\\r\n    ./wizards/ComponentWizard/ComponentWizardPages.h \\\r\n    ./wizards/ComponentWizard/InstanceData.h \\\r\n    ./wizards/ComponentWizard/ImportEditor.h \\\r\n    ./wizards/ComponentWizard/ViewListModel.h \\\r\n    ./wizards/ComponentWizard/ComponentWizardViewsPage.h \\\r\n    ./wizards/ComponentWizard/ComponentWizard.h \\\r\n    ./wizards/ComponentWizard/ComponentWizardConclusionPage.h \\\r\n    ./wizards/ComponentWizard/ComponentWizardImportPage.h \\\r\n    ./wizards/ComponentWizard/ComponentWizardGeneralInfoPage.h \\\r\n    ./wizards/BusInterfaceWizard/BusInterfaceWizardBusDefinitionPage.h \\\r\n    ./wizards/BusInterfaceWizard/BusInterfaceWizard.h \\\r\n    ./wizards/BusInterfaceWizard/BusInterfaceWizardAbsDefinitionPage.h \\\r\n    ./wizards/BusInterfaceWizard/BusInterfaceWizardConclusionPage.h \\\r\n    ./wizards/BusInterfaceWizard/BusInterfaceWizardGeneralOptionsPage.h \\\r\n    ./wizards/BusInterfaceWizard/BusInterfaceWizardIntroPage.h \\\r\n    ./wizards/BusInterfaceWizard/BusInterfaceWizardPortMapPage.h \\\r\n    ./wizards/ImportWizard/ImportWizardIntroPage.h \\\r\n    ./wizards/ImportWizard/ImportWizardPages.h \\\r\n    ./wizards/ImportWizard/ImportWizardInstancesPage.h \\\r\n    ./wizards/ImportWizard/ImportWizardImportPage.h \\\r\n    ./wizards/ImportWizard/ImportWizard.h \\\r\n    ./wizards/ImportWizard/ImportInstancesEditor/ImportInstancesColumns.h \\\r\n    ./wizards/ImportWizard/ImportInstancesEditor/ImportInstancesEditor.h \\\r\n    ./wizards/ImportWizard/ImportInstancesEditor/ImportInstancesDelegate.h \\\r\n    ./wizards/common/IPXactDiff.h \\\r\n    ./wizards/common/IPXactElementComparator.h \\\r\n    ./wizards/common/ListComparator.h \\\r\n    ./wizards/common/ComponentComparator/ComponentComparator.h \\\r\n    ./wizards/common/ComponentDiffWidget/ComponentDiffWidget.h \\\r\n    ./wizards/common/VLNVComparator/VLNVComparator.h \\\r\n    ./wizards/common/ViewComparator/ViewComparator.h \\\r\n    ./wizards/common/PortComparator/PortComparator.h \\\r\n    ./wizards/common/ParameterComparator/ParameterComparator.h \\\r\n    ./wizards/common/ModuleParameterComparator/ModuleParameterComparator.h \\\r\n    ./Help/HelpSystem/HelpWindow.h \\\r\n    ./Help/HelpSystem/ContextHelpBrowser.h \\\r\n    ./Help/HelpSystem/HelpSearchWidget.h \\\r\n    ./Plugins/common/ConnectivityGraphUtilities.h \\\r\n    ./Plugins/common/CpuRoutesContainer.h \\\r\n    ./Plugins/common/SingleCpuRoutesContainer.h \\\r\n    ./Plugins/common/SourceHighlightStyle.h \\\r\n    ./Plugins/common/LanguageHighlighter.h \\\r\n    ./Plugins/PluginSystem/GeneratorPlugin/AddToFilesetWidget.h \\\r\n    ./library/LibraryInterface.h \\\r\n    ./library/LibraryItemSelectionFactory.h \\\r\n    ./library/LibraryUtils.h \\\r\n    ./library/ObjectSelectionListItem.h \\\r\n    ./library/TableViewDialog.h \\\r\n    ./library/LibraryFilter.h \\\r\n    ./library/LibraryErrorModel.h \\\r\n    ./library/ItemExporter.h \\\r\n    ./library/LibraryTreeFilter.h \\\r\n    ./library/LibraryTreeWidget.h \\\r\n    ./library/LibraryTreeView.h \\\r\n    ./library/LibraryWidget.h \\\r\n    ./library/objectremovedialog.h \\\r\n    ./library/ObjectSelectionDialog.h \\\r\n    ./library/ObjectExportDialog.h \\\r\n    ./library/VLNVDialer/filterwidget.h \\\r\n    ./library/VLNVDialer/firmnessgroup.h \\\r\n    ./library/VLNVDialer/hierarchygroup.h \\\r\n    ./library/VLNVDialer/implementationgroup.h \\\r\n    ./library/VLNVDialer/typegroup.h \\\r\n    ./library/VLNVDialer/vlnvdialer.h \\\r\n    ./library/VLNVDialer/FilterGroup.h \\\r\n    ./library/VLNVDialer/ValidityGroup.h \\\r\n    ./library/VLNVDialer/RevisionGroup.h \\\r\n    ./library/HierarchyView/hierarchywidget.h \\\r\n    ./library/HierarchyView/hierarchyview.h \\\r\n    ./library/HierarchyView/hierarchyfilter.h \\\r\n    ./editors/ApiDefinitionEditor/ApiFunctionColumns.h \\\r\n    ./editors/ApiDefinitionEditor/ApiDefinitionEditor.h \\\r\n    ./editors/ApiDefinitionEditor/ApiFunctionEditor.h \\\r\n    ./editors/ApiDefinitionEditor/ApiFunctionModel.h \\\r\n    ./editors/ApiDefinitionEditor/ApiFunctionParameterDelegate.h \\\r\n    ./editors/ApiDefinitionEditor/ApiFunctionParameterModel.h \\\r\n    ./editors/ComDefinitionEditor/ComPropertyColumns.h \\\r\n    ./editors/ComDefinitionEditor/ComDefinitionEditor.h \\\r\n    ./editors/ComDefinitionEditor/ComPropertyDelegate.h \\\r\n    ./editors/ComDefinitionEditor/ComPropertyEditor.h \\\r\n    ./editors/ComDefinitionEditor/ComPropertyModel.h \\\r\n    ./editors/ComponentEditor/ParameterItemEditor.h \\\r\n    ./editors/ComponentEditor/componenteditor.h \\\r\n    ./editors/ComponentEditor/itemeditor.h \\\r\n    ./editors/ComponentEditor/itemvisualizer.h \\\r\n    ./editors/ComponentEditor/general/generaleditor.h \\\r\n    ./editors/ComponentEditor/ports/PortsEditorFactory.h \\\r\n    ./editors/ComponentEditor/ports/PortSummaryColumns.h \\\r\n    ./editors/ComponentEditor/ports/PortSummaryEditorFactory.h \\\r\n    ./editors/ComponentEditor/ports/PortTypeDefinitionDelegate.h \\\r\n    ./editors/ComponentEditor/ports/PortWireTypeColumns.h \\\r\n    ./editors/ComponentEditor/ports/TransactionalPortColumns.h \\\r\n    ./editors/ComponentEditor/ports/TransactionalPortsEditorFactory.h \\\r\n    ./editors/ComponentEditor/ports/WirePortColumns.h \\\r\n    ./editors/ComponentEditor/ports/WirePortsEditorFactory.h \\\r\n    ./editors/ComponentEditor/ports/MasterPortsEditor.h \\\r\n    ./editors/ComponentEditor/ports/PortTagEditorDelegate.h \\\r\n    ./editors/ComponentEditor/ports/PortWireTypeEditor.h \\\r\n    ./editors/ComponentEditor/ports/PortWireTypeModel.h \\\r\n    ./editors/ComponentEditor/ports/PortWireTypeDelegate.h \\\r\n    ./editors/ComponentEditor/ports/PortsFilter.h \\\r\n    ./editors/ComponentEditor/ports/PortSummaryModel.h \\\r\n    ./editors/ComponentEditor/ports/PortSummaryFilter.h \\\r\n    ./editors/ComponentEditor/ports/PortSummaryDelegate.h \\\r\n    ./editors/ComponentEditor/ports/PortSummaryView.h \\\r\n    ./editors/ComponentEditor/ports/PortTypeDefinitionEditor.h \\\r\n    ./editors/ComponentEditor/ports/PortWireTypeView.h \\\r\n    ./editors/ComponentEditor/ports/TransactionalPortsDelegate.h \\\r\n    ./editors/ComponentEditor/ports/TransactionalPortsModel.h \\\r\n    ./editors/ComponentEditor/ports/TransactionalPortsFilter.h \\\r\n    ./editors/ComponentEditor/ports/TypedPortEditor.h \\\r\n    ./editors/ComponentEditor/ports/WirePortsModel.h \\\r\n    ./editors/ComponentEditor/ports/WirePortsFilter.h \\\r\n    ./editors/ComponentEditor/ports/WirePortsDelegate.h \\\r\n    ./editors/ComponentEditor/ports/TypedPortsView.h \\\r\n    ./editors/ComponentEditor/ports/portsdelegate.h \\\r\n    ./editors/ComponentEditor/ports/portseditor.h \\\r\n    ./editors/ComponentEditor/ports/portsmodel.h \\\r\n    ./editors/ComponentEditor/ports/PortsView.h \\\r\n    ./editors/ComponentEditor/parameters/ComponentParameterColumns.h \\\r\n    ./editors/ComponentEditor/parameters/LockableParametersModel.h \\\r\n    ./editors/ComponentEditor/parameters/ParameterColumns.h \\\r\n    ./editors/ComponentEditor/parameters/ParameterEditorHeaderView.h \\\r\n    ./editors/ComponentEditor/parameters/parametersmodel.h \\\r\n    ./editors/ComponentEditor/parameters/ComponentParameterModel.h \\\r\n    ./editors/ComponentEditor/parameters/ChoiceCreatorDelegate.h \\\r\n    ./editors/ComponentEditor/parameters/ParameterDelegate.h \\\r\n    ./editors/ComponentEditor/parameters/ParametersView.h \\\r\n    ./editors/ComponentEditor/parameters/parameterseditor.h \\\r\n    ./editors/ComponentEditor/parameters/Array/ArrayColumns.h \\\r\n    ./editors/ComponentEditor/parameters/Array/ArrayDelegate.h \\\r\n    ./editors/ComponentEditor/parameters/Array/ParameterArrayModel.h \\\r\n    ./editors/ComponentEditor/parameters/Array/ArrayView.h \\\r\n    ./editors/ComponentEditor/otherClockDrivers/OtherClockDriverColumns.h \\\r\n    ./editors/ComponentEditor/otherClockDrivers/otherclockdriversmodel.h \\\r\n    ./editors/ComponentEditor/otherClockDrivers/clockdriversdelegate.h \\\r\n    ./editors/ComponentEditor/otherClockDrivers/otherclockdriverseditor.h \\\r\n    ./editors/ComponentEditor/channels/ChannelColumns.h \\\r\n    ./editors/ComponentEditor/channels/channelsdelegate.h \\\r\n    ./editors/ComponentEditor/channels/channelseditor.h \\\r\n    ./editors/ComponentEditor/channels/channelsmodel.h \\\r\n    ./editors/ComponentEditor/busInterfaces/AbstractionTypesConstants.h \\\r\n    ./editors/ComponentEditor/busInterfaces/BusInterfaceColumns.h \\\r\n    ./editors/ComponentEditor/busInterfaces/AbstractionTypesEditor.h \\\r\n    ./editors/ComponentEditor/busInterfaces/AbstractionTypesModel.h \\\r\n    ./editors/ComponentEditor/busInterfaces/AbstractionTypesDelegate.h \\\r\n    ./editors/ComponentEditor/busInterfaces/businterfaceeditor.h \\\r\n    ./editors/ComponentEditor/busInterfaces/businterfacesdelegate.h \\\r\n    ./editors/ComponentEditor/busInterfaces/businterfaceseditor.h \\\r\n    ./editors/ComponentEditor/busInterfaces/businterfacesmodel.h \\\r\n    ./editors/ComponentEditor/busInterfaces/portmaps/PortMapHeaderView.h \\\r\n    ./editors/ComponentEditor/busInterfaces/portmaps/PortMappingColumns.h \\\r\n    ./editors/ComponentEditor/busInterfaces/portmaps/PortMapsColumns.h \\\r\n    ./editors/ComponentEditor/busInterfaces/portmaps/PortMapSortFilter.h \\\r\n    ./editors/ComponentEditor/busInterfaces/portmaps/JaroWinklerAlgorithm.h \\\r\n    ./editors/ComponentEditor/busInterfaces/portmaps/PhysicalPortMappingTableView.h \\\r\n    ./editors/ComponentEditor/busInterfaces/portmaps/PhysicalPortMappingTableModel.h \\\r\n    ./editors/ComponentEditor/busInterfaces/portmaps/PortMapAutoConnector.h \\\r\n    ./editors/ComponentEditor/busInterfaces/portmaps/BusInterfacePortMapTab.h \\\r\n    ./editors/ComponentEditor/busInterfaces/portmaps/PortMapDelegate.h \\\r\n    ./editors/ComponentEditor/busInterfaces/portmaps/PortMapModel.h \\\r\n    ./editors/ComponentEditor/busInterfaces/portmaps/PortMappingTableView.h \\\r\n    ./editors/ComponentEditor/busInterfaces/portmaps/PortMappingTableModel.h \\\r\n    ./editors/ComponentEditor/busInterfaces/portmaps/PortMapView.h \\\r\n    ./editors/ComponentEditor/busInterfaces/portmaps/PortListSortProxyModel.h \\\r\n    ./editors/ComponentEditor/busInterfaces/general/BridgeColumns.h \\\r\n    ./editors/ComponentEditor/busInterfaces/general/MirroredInitiatorModeEditor.h \\\r\n    ./editors/ComponentEditor/busInterfaces/general/MirroredMasterModeEditor.h \\\r\n    ./editors/ComponentEditor/busInterfaces/general/bridgesdelegate.h \\\r\n    ./editors/ComponentEditor/busInterfaces/general/bridgeseditor.h \\\r\n    ./editors/ComponentEditor/busInterfaces/general/bridgesmodel.h \\\r\n    ./editors/ComponentEditor/busInterfaces/general/busifgeneraldetails.h \\\r\n    ./editors/ComponentEditor/busInterfaces/general/busifgeneraltab.h \\\r\n    ./editors/ComponentEditor/busInterfaces/general/interfacemodestack.h \\\r\n    ./editors/ComponentEditor/busInterfaces/general/MasterModeEditor.h \\\r\n    ./editors/ComponentEditor/busInterfaces/general/ModeEditorBase.h \\\r\n    ./editors/ComponentEditor/busInterfaces/general/SlaveModeEditor.h \\\r\n    ./editors/ComponentEditor/busInterfaces/general/MirroredSlaveModeEditor.h \\\r\n    ./editors/ComponentEditor/busInterfaces/general/InitiatorModeEditor.h \\\r\n    ./editors/ComponentEditor/busInterfaces/general/MonitorModeEditor.h \\\r\n    ./editors/ComponentEditor/busInterfaces/general/SystemModeEditor.h \\\r\n    ./editors/ComponentEditor/busInterfaces/general/TargetModeEditor.h \\\r\n    ./editors/ComponentEditor/busInterfaces/general/MirroredTargetModeEditor.h \\\r\n    ./editors/ComponentEditor/fileBuilders/FileBuilderColumns.h \\\r\n    ./editors/ComponentEditor/fileBuilders/filebuildersdelegate.h \\\r\n    ./editors/ComponentEditor/fileBuilders/filebuilderseditor.h \\\r\n    ./editors/ComponentEditor/fileBuilders/filebuildersmodel.h \\\r\n    ./editors/ComponentEditor/software/PropertyValueModel.h \\\r\n    ./editors/ComponentEditor/software/SWPropertiesEditor.h \\\r\n    ./editors/ComponentEditor/software/PropertyValueDelegate.h \\\r\n    ./editors/ComponentEditor/software/PropertyValueEditor.h \\\r\n    ./editors/ComponentEditor/software/apiInterface/ApiInterfaceColumns.h \\\r\n    ./editors/ComponentEditor/software/apiInterface/apiinterfaceseditor.h \\\r\n    ./editors/ComponentEditor/software/apiInterface/apiinterfacesmodel.h \\\r\n    ./editors/ComponentEditor/software/apiInterface/ApiInterfaceEditor.h \\\r\n    ./editors/ComponentEditor/software/apiInterface/apiinterfacesdelegate.h \\\r\n    ./editors/ComponentEditor/software/comInterface/ComInterfaceColumns.h \\\r\n    ./editors/ComponentEditor/software/comInterface/cominterfaceseditor.h \\\r\n    ./editors/ComponentEditor/software/comInterface/cominterfacesmodel.h \\\r\n    ./editors/ComponentEditor/software/comInterface/ComInterfaceEditor.h \\\r\n    ./editors/ComponentEditor/software/comInterface/cominterfacesdelegate.h \\\r\n    ./editors/ComponentEditor/software/systemView/SystemViewEditor.h \\\r\n    ./editors/ComponentEditor/software/systemView/SystemViewsEditor.h \\\r\n    ./editors/ComponentEditor/software/systemView/SystemViewsModel.h \\\r\n    ./editors/ComponentEditor/addressSpaces/AddressSpaceColumns.h \\\r\n    ./editors/ComponentEditor/addressSpaces/SegmentColumns.h \\\r\n    ./editors/ComponentEditor/addressSpaces/SegmentDelegate.h \\\r\n    ./editors/ComponentEditor/addressSpaces/addressspaceeditor.h \\\r\n    ./editors/ComponentEditor/addressSpaces/addressspacegeneraleditor.h \\\r\n    ./editors/ComponentEditor/addressSpaces/addressspacesdelegate.h \\\r\n    ./editors/ComponentEditor/addressSpaces/addressspaceseditor.h \\\r\n    ./editors/ComponentEditor/addressSpaces/addressspacesmodel.h \\\r\n    ./editors/ComponentEditor/addressSpaces/segmenteditor.h \\\r\n    ./editors/ComponentEditor/addressSpaces/segmentsmodel.h \\\r\n    ./editors/ComponentEditor/addressSpaces/localMemoryMap/localmemorymapeditor.h \\\r\n    ./editors/ComponentEditor/addressSpaces/localMemoryMap/localmemorymapgraphitem.h \\\r\n    ./editors/ComponentEditor/addressSpaces/addressSpaceVisualizer/AddressSpaceConflictedItem.h \\\r\n    ./editors/ComponentEditor/addressSpaces/addressSpaceVisualizer/addressspacegapitem.h \\\r\n    ./editors/ComponentEditor/addressSpaces/addressSpaceVisualizer/addressspacescene.h \\\r\n    ./editors/ComponentEditor/addressSpaces/addressSpaceVisualizer/addressspacevisualizationitem.h \\\r\n    ./editors/ComponentEditor/addressSpaces/addressSpaceVisualizer/addressspacevisualizer.h \\\r\n    ./editors/ComponentEditor/addressSpaces/addressSpaceVisualizer/localaddrblockgraphitem.h \\\r\n    ./editors/ComponentEditor/addressSpaces/addressSpaceVisualizer/segmentgraphitem.h \\\r\n    ./editors/ComponentEditor/cpus/CpuColumns.h \\\r\n    ./editors/ComponentEditor/cpus/RegionColumns.h \\\r\n    ./editors/ComponentEditor/cpus/SingleCpuEditor.h \\\r\n    ./editors/ComponentEditor/cpus/CpuDetailsEditor.h \\\r\n    ./editors/ComponentEditor/cpus/RegionsModel.h \\\r\n    ./editors/ComponentEditor/cpus/CpuVisualizer.h \\\r\n    ./editors/ComponentEditor/cpus/RegionsEditor.h \\\r\n    ./editors/ComponentEditor/cpus/RegionsDelegate.h \\\r\n    ./editors/ComponentEditor/cpus/RegionScene.h \\\r\n    ./editors/ComponentEditor/cpus/cpusdelegate.h \\\r\n    ./editors/ComponentEditor/cpus/cpuseditor.h \\\r\n    ./editors/ComponentEditor/cpus/cpusmodel.h \\\r\n    ./editors/ComponentEditor/views/EnvIdentifiersColumns.h \\\r\n    ./editors/ComponentEditor/views/ViewColumns.h \\\r\n    ./editors/ComponentEditor/views/ViewsDelegate.h \\\r\n    ./editors/ComponentEditor/views/vieweditor.h \\\r\n    ./editors/ComponentEditor/views/viewseditor.h \\\r\n    ./editors/ComponentEditor/views/viewsmodel.h \\\r\n    ./editors/ComponentEditor/views/envidentifiereditor.h \\\r\n    ./editors/ComponentEditor/views/envidentifiersmodel.h \\\r\n    ./editors/ComponentEditor/fileSet/FileSetColumns.h \\\r\n    ./editors/ComponentEditor/fileSet/fileseteditor.h \\\r\n    ./editors/ComponentEditor/fileSet/filesetsdelegate.h \\\r\n    ./editors/ComponentEditor/fileSet/filesetseditor.h \\\r\n    ./editors/ComponentEditor/fileSet/filesetsmodel.h \\\r\n    ./editors/ComponentEditor/fileSet/groupmanager.h \\\r\n    ./editors/ComponentEditor/fileSet/groupmanagerdelegate.h \\\r\n    ./editors/ComponentEditor/fileSet/file/FileColumns.h \\\r\n    ./editors/ComponentEditor/fileSet/file/filegeneraleditor.h \\\r\n    ./editors/ComponentEditor/fileSet/file/filenameeditor.h \\\r\n    ./editors/ComponentEditor/fileSet/file/filesdelegate.h \\\r\n    ./editors/ComponentEditor/fileSet/file/fileseditor.h \\\r\n    ./editors/ComponentEditor/fileSet/file/filesmodel.h \\\r\n    ./editors/ComponentEditor/fileSet/file/filesview.h \\\r\n    ./editors/ComponentEditor/fileSet/file/filetypeeditor.h \\\r\n    ./editors/ComponentEditor/fileSet/file/filetypeeditordelegate.h \\\r\n    ./editors/ComponentEditor/fileSet/file/filebuildcommand.h \\\r\n    ./editors/ComponentEditor/fileSet/file/filedefinemodel.h \\\r\n    ./editors/ComponentEditor/fileSet/file/filedefineview.h \\\r\n    ./editors/ComponentEditor/fileSet/file/fileeditor.h \\\r\n    ./editors/ComponentEditor/fileSet/dependencyAnalysis/FileDependencyColumns.h \\\r\n    ./editors/ComponentEditor/fileSet/dependencyAnalysis/FileDependencySortFilter.h \\\r\n    ./editors/ComponentEditor/fileSet/dependencyAnalysis/FileDependencyDelegate.h \\\r\n    ./editors/ComponentEditor/fileSet/dependencyAnalysis/FileDependencyEditor.h \\\r\n    ./editors/ComponentEditor/fileSet/dependencyAnalysis/FileDependencyGraphWidget.h \\\r\n    ./editors/ComponentEditor/fileSet/dependencyAnalysis/FileDependencyGraphView.h \\\r\n    ./editors/ComponentEditor/fileSet/dependencyAnalysis/FileDependencyInfoWidget.h \\\r\n    ./editors/ComponentEditor/fileSet/dependencyAnalysis/FileDependencyItem.h \\\r\n    ./editors/ComponentEditor/fileSet/dependencyAnalysis/FileDependencyModel.h \\\r\n    ./editors/ComponentEditor/fileSet/dependencyAnalysis/FileDependencySourceEditor.h \\\r\n    ./editors/ComponentEditor/treeStructure/ComponentEditorChoicesItem.h \\\r\n    ./editors/ComponentEditor/memoryMaps/AccessPoliciesEditor.h \\\r\n    ./editors/ComponentEditor/memoryMaps/AccessPoliciesDelegate.h \\\r\n    ./editors/ComponentEditor/memoryMaps/AccessPoliciesModel.h \\\r\n    ./editors/ComponentEditor/treeStructure/SingleRemapStateItem.h \\\r\n    ./editors/ComponentEditor/treeStructure/RemapStatesItem.h \\\r\n    ./editors/ComponentEditor/treeStructure/MemoryRemapItem.h \\\r\n    ./editors/ComponentEditor/treeStructure/InstantiationsItem.h \\\r\n    ./editors/ComponentEditor/treeStructure/ComponentInstantiationsItem.h \\\r\n    ./editors/ComponentEditor/treeStructure/DesignConfigurationInstantiationsItem.h \\\r\n    ./editors/ComponentEditor/treeStructure/DesignInstantiationsItem.h \\\r\n    ./editors/ComponentEditor/treeStructure/SingleComponentInstantiationItem.h \\\r\n    ./editors/ComponentEditor/treeStructure/SingleDesignConfigurationInstantiationItem.h \\\r\n    ./editors/ComponentEditor/treeStructure/SingleDesignInstantiationItem.h \\\r\n    ./editors/ComponentEditor/treeStructure/ComponentEditorIndirectInterfacesItem.h \\\r\n    ./editors/ComponentEditor/treeStructure/SingleIndirectInterfaceItem.h \\\r\n    ./editors/ComponentEditor/treeStructure/ParameterizableItem.h \\\r\n    ./editors/ComponentEditor/treeStructure/componenteditorregisterfileitem.h \\\r\n    ./editors/ComponentEditor/treeStructure/ResetTypesItem.h \\\r\n    ./editors/ComponentEditor/treeStructure/SubspaceMapItem.h \\\r\n    ./editors/ComponentEditor/treeStructure/ComponentEditorTreeDelegate.h \\\r\n    ./editors/ComponentEditor/treeStructure/SingleCpuItem.h \\\r\n    ./editors/ComponentEditor/treeStructure/ModesItem.h \\\r\n    ./editors/ComponentEditor/treeStructure/SingleModeItem.h \\\r\n    ./editors/ComponentEditor/treeStructure/PowerDomainsItem.h \\\r\n    ./editors/ComponentEditor/treeStructure/TypeDefinitionsItem.h \\\r\n    ./editors/ComponentEditor/treeStructure/WirePortsItem.h \\\r\n    ./editors/ComponentEditor/treeStructure/TransactionalPortsItem.h \\\r\n    ./editors/ComponentEditor/treeStructure/componenteditorrootitem.h \\\r\n    ./editors/ComponentEditor/treeStructure/componenteditorswpropertiesitem.h \\\r\n    ./editors/ComponentEditor/treeStructure/ComponentEditorSystemViewItem.h \\\r\n    ./editors/ComponentEditor/treeStructure/ComponentEditorSystemViewsItem.h \\\r\n    ./editors/ComponentEditor/treeStructure/componenteditortreemodel.h \\\r\n    ./editors/ComponentEditor/treeStructure/ComponentEditorTreeSortProxyModel.h \\\r\n    ./editors/ComponentEditor/treeStructure/componenteditorviewitem.h \\\r\n    ./editors/ComponentEditor/treeStructure/componenteditorviewsitem.h \\\r\n    ./editors/ComponentEditor/treeStructure/componenttreeview.h \\\r\n    ./editors/ComponentEditor/treeStructure/componenteditoraddrblockitem.h \\\r\n    ./editors/ComponentEditor/treeStructure/componenteditoraddrspaceitem.h \\\r\n    ./editors/ComponentEditor/treeStructure/componenteditoraddrspacesitem.h \\\r\n    ./editors/ComponentEditor/treeStructure/componenteditorapiinterfaceitem.h \\\r\n    ./editors/ComponentEditor/treeStructure/componenteditorapiinterfacesitem.h \\\r\n    ./editors/ComponentEditor/treeStructure/componenteditorbusinterfaceitem.h \\\r\n    ./editors/ComponentEditor/treeStructure/componenteditorbusinterfacesitem.h \\\r\n    ./editors/ComponentEditor/treeStructure/componenteditorchannelsitem.h \\\r\n    ./editors/ComponentEditor/treeStructure/componenteditorcominterfaceitem.h \\\r\n    ./editors/ComponentEditor/treeStructure/componenteditorcominterfacesitem.h \\\r\n    ./editors/ComponentEditor/treeStructure/componenteditorcpusitem.h \\\r\n    ./editors/ComponentEditor/treeStructure/componenteditorfielditem.h \\\r\n    ./editors/ComponentEditor/treeStructure/componenteditorfileitem.h \\\r\n    ./editors/ComponentEditor/treeStructure/componenteditorfilesetitem.h \\\r\n    ./editors/ComponentEditor/treeStructure/componenteditorfilesetsitem.h \\\r\n    ./editors/ComponentEditor/treeStructure/componenteditorgeneralitem.h \\\r\n    ./editors/ComponentEditor/treeStructure/componenteditorgroupslot.h \\\r\n    ./editors/ComponentEditor/treeStructure/componenteditoritem.h \\\r\n    ./editors/ComponentEditor/treeStructure/componenteditormemmapitem.h \\\r\n    ./editors/ComponentEditor/treeStructure/componenteditormemmapsitem.h \\\r\n    ./editors/ComponentEditor/treeStructure/componenteditorotherclocksitem.h \\\r\n    ./editors/ComponentEditor/treeStructure/componenteditorparametersitem.h \\\r\n    ./editors/ComponentEditor/treeStructure/componenteditorportsitem.h \\\r\n    ./editors/ComponentEditor/treeStructure/componenteditorregisteritem.h \\\r\n    ./editors/ComponentEditor/visualization/AddressableItem.h \\\r\n    ./editors/ComponentEditor/visualization/fieldgapitem.h \\\r\n    ./editors/ComponentEditor/visualization/memorygapitem.h \\\r\n    ./editors/ComponentEditor/visualization/memoryvisualizationitem.h \\\r\n    ./editors/ComponentEditor/choices/ChoiceColumns.h \\\r\n    ./editors/ComponentEditor/choices/EnumerationColumns.h \\\r\n    ./editors/ComponentEditor/choices/ChoicesEditor.h \\\r\n    ./editors/ComponentEditor/choices/ChoicesModel.h \\\r\n    ./editors/ComponentEditor/choices/EnumerationModel.h \\\r\n    ./editors/ComponentEditor/common/ConfigurableElementFinder.h \\\r\n    ./editors/ComponentEditor/common/DesignConfigurationInstantiationParameterFinder.h \\\r\n    ./editors/ComponentEditor/common/MasterExpressionEditor.h \\\r\n    ./editors/ComponentEditor/common/MemoryTreeFactory.h \\\r\n    ./editors/ComponentEditor/common/ParameterizableTable.h \\\r\n    ./editors/ComponentEditor/common/AbstractParameterModel.h \\\r\n    ./editors/ComponentEditor/common/ExpressionDelegate.h \\\r\n    ./editors/ComponentEditor/common/ExpressionEditor.h \\\r\n    ./editors/ComponentEditor/common/InstantiationConfigurableElementEditor.h \\\r\n    ./editors/ComponentEditor/common/MultilineDescriptionDelegate.h \\\r\n    ./editors/ComponentEditor/common/ReferencingTableModel.h \\\r\n    ./editors/ComponentEditor/common/ExpressionLineEditor.h \\\r\n    ./editors/ComponentEditor/common/EnumerationEditorConstructorDelegate.h \\\r\n    ./editors/ComponentEditor/common/FloatingModeReferenceEditor.h \\\r\n    ./editors/ComponentEditor/common/ModeReferenceEditor.h \\\r\n    ./editors/ComponentEditor/common/ModeReferenceDelegate.h \\\r\n    ./editors/ComponentEditor/common/ModeReferenceModel.h \\\r\n    ./editors/ComponentEditor/common/MemoryAlignScene.h \\\r\n    ./editors/ComponentEditor/common/ReferenceSelector/ReferenceSelector.h \\\r\n    ./editors/ComponentEditor/referenceCounter/ParameterReferenceCounter.h \\\r\n    ./editors/ComponentEditor/referenceCounter/ReferenceCounter.h \\\r\n    ./editors/ComponentEditor/referenceCounter/ComponentParameterReferenceCounter.h \\\r\n    ./editors/ComponentEditor/parameterReferenceTree/ParameterReferenceTree.h \\\r\n    ./editors/ComponentEditor/parameterReferenceTree/ComponentParameterReferenceTree.h \\\r\n    ./editors/ComponentEditor/parameterReferenceTree/ParameterReferenceTreeWindow.h \\\r\n    ./editors/ComponentEditor/remapStates/RemapConditionColumns.h \\\r\n    ./editors/ComponentEditor/remapStates/RemapStatesEditor.h \\\r\n    ./editors/ComponentEditor/remapStates/RemapStatesModel.h \\\r\n    ./editors/ComponentEditor/remapStates/SingleRemapStateEditor.h \\\r\n    ./editors/ComponentEditor/remapStates/RemapConditionModel.h \\\r\n    ./editors/ComponentEditor/remapStates/RemapConditionEditor.h \\\r\n    ./editors/ComponentEditor/remapStates/RemapConditionDelegate.h \\\r\n    ./editors/ComponentEditor/remapStates/ValueOrIndexedValueEditor.h \\\r\n    ./editors/ComponentEditor/instantiations/ComponentInstantiationDisplayer.h \\\r\n    ./editors/ComponentEditor/instantiations/ComponentInstantiationsColumns.h \\\r\n    ./editors/ComponentEditor/instantiations/DesignInstantiationColumns.h \\\r\n    ./editors/ComponentEditor/instantiations/ModuleParameterColumns.h \\\r\n    ./editors/ComponentEditor/instantiations/ModuleParameterHeaderView.h \\\r\n    ./editors/ComponentEditor/instantiations/DesignConfigurationInstantiationEditor.h \\\r\n    ./editors/ComponentEditor/instantiations/DesignInstantiationEditor.h \\\r\n    ./editors/ComponentEditor/instantiations/ComponentInstantiationsEditor.h \\\r\n    ./editors/ComponentEditor/instantiations/ComponentInstantiationsModel.h \\\r\n    ./editors/ComponentEditor/instantiations/ComponentInstantiationEditor.h \\\r\n    ./editors/ComponentEditor/instantiations/InstantiationsEditor.h \\\r\n    ./editors/ComponentEditor/instantiations/DesignInstantiationsEditor.h \\\r\n    ./editors/ComponentEditor/instantiations/DesignInstantiationsModel.h \\\r\n    ./editors/ComponentEditor/instantiations/DesignConfigurationInstantiationsModel.h \\\r\n    ./editors/ComponentEditor/instantiations/DesignConfigurationInstantiationsEditor.h \\\r\n    ./editors/ComponentEditor/instantiations/DesignInstantiationsDelegate.h \\\r\n    ./editors/ComponentEditor/instantiations/filesetrefeditordelegate.h \\\r\n    ./editors/ComponentEditor/instantiations/filesetrefmodel.h \\\r\n    ./editors/ComponentEditor/instantiations/filesetrefeditor.h \\\r\n    ./editors/ComponentEditor/instantiations/ModuleParameterDelegate.h \\\r\n    ./editors/ComponentEditor/instantiations/ModuleParameterEditor.h \\\r\n    ./editors/ComponentEditor/instantiations/ModuleParameterModel.h \\\r\n    ./editors/ComponentEditor/indirectInterfaces/IndirectInterfaceColumns.h \\\r\n    ./editors/ComponentEditor/indirectInterfaces/IndirectInterfacesEditor.h \\\r\n    ./editors/ComponentEditor/indirectInterfaces/IndirectInterfacesModel.h \\\r\n    ./editors/ComponentEditor/indirectInterfaces/IndirectInterfacesDelegate.h \\\r\n    ./editors/ComponentEditor/indirectInterfaces/SingleIndirectInterfaceEditor.h \\\r\n    ./editors/ComponentEditor/memoryMaps/AddressBlockColumns.h \\\r\n    ./editors/ComponentEditor/memoryMaps/EnumeratedValueColumns.h \\\r\n    ./editors/ComponentEditor/memoryMaps/FieldAccessPolicyColumns.h \\\r\n    ./editors/ComponentEditor/memoryMaps/MemoryMapColumns.h \\\r\n    ./editors/ComponentEditor/memoryMaps/MemoryMapsColumns.h \\\r\n    ./editors/ComponentEditor/memoryMaps/RegisterColumns.h \\\r\n    ./editors/ComponentEditor/memoryMaps/RegisterFileColumns.h \\\r\n    ./editors/ComponentEditor/memoryMaps/ResetColumns.h \\\r\n    ./editors/ComponentEditor/memoryMaps/SubspaceMapColumns.h \\\r\n    ./editors/ComponentEditor/memoryMaps/FieldAccessPoliciesDelegate.h \\\r\n    ./editors/ComponentEditor/memoryMaps/FieldAccessPoliciesEditor.h \\\r\n    ./editors/ComponentEditor/memoryMaps/FieldAccessPoliciesModel.h \\\r\n    ./editors/ComponentEditor/memoryMaps/ExpressionProxyModel.h \\\r\n    ./editors/ComponentEditor/memoryMaps/MemoryBlockModel.h \\\r\n    ./editors/ComponentEditor/memoryMaps/MemoryBlockDelegate.h \\\r\n    ./editors/ComponentEditor/memoryMaps/MemoryBlockFilter.h \\\r\n    ./editors/ComponentEditor/memoryMaps/MemoryMapsView.h \\\r\n    ./editors/ComponentEditor/memoryMaps/SingleMemoryMapEditor.h \\\r\n    ./editors/ComponentEditor/memoryMaps/SingleAddressBlockEditor.h \\\r\n    ./editors/ComponentEditor/memoryMaps/SingleRegisterEditor.h \\\r\n    ./editors/ComponentEditor/memoryMaps/SingleFieldEditor.h \\\r\n    ./editors/ComponentEditor/memoryMaps/WriteValueConstraintComboBox.h \\\r\n    ./editors/ComponentEditor/memoryMaps/SingleRegisterFileEditor.h \\\r\n    ./editors/ComponentEditor/memoryMaps/registerfiledelegate.h \\\r\n    ./editors/ComponentEditor/memoryMaps/registerfileeditor.h \\\r\n    ./editors/ComponentEditor/memoryMaps/registerfilemodel.h \\\r\n    ./editors/ComponentEditor/memoryMaps/ResetsEditor.h \\\r\n    ./editors/ComponentEditor/memoryMaps/ResetsModel.h \\\r\n    ./editors/ComponentEditor/memoryMaps/RemapModeReferenceEditor.h \\\r\n    ./editors/ComponentEditor/memoryMaps/ResetsDelegate.h \\\r\n    ./editors/ComponentEditor/memoryMaps/SubspaceMapsEditor.h \\\r\n    ./editors/ComponentEditor/memoryMaps/SingleSubspaceMapEditor.h \\\r\n    ./editors/ComponentEditor/memoryMaps/SubspaceMapModel.h \\\r\n    ./editors/ComponentEditor/memoryMaps/SubspaceMapDelegate.h \\\r\n    ./editors/ComponentEditor/memoryMaps/memorymapdelegate.h \\\r\n    ./editors/ComponentEditor/memoryMaps/memorymapeditor.h \\\r\n    ./editors/ComponentEditor/memoryMaps/memorymapmodel.h \\\r\n    ./editors/ComponentEditor/memoryMaps/memorymapsdelegate.h \\\r\n    ./editors/ComponentEditor/memoryMaps/memorymapseditor.h \\\r\n    ./editors/ComponentEditor/memoryMaps/memorymapsmodel.h \\\r\n    ./editors/ComponentEditor/memoryMaps/registerdelegate.h \\\r\n    ./editors/ComponentEditor/memoryMaps/registereditor.h \\\r\n    ./editors/ComponentEditor/memoryMaps/registertablemodel.h \\\r\n    ./editors/ComponentEditor/memoryMaps/addressblockdelegate.h \\\r\n    ./editors/ComponentEditor/memoryMaps/addressblockeditor.h \\\r\n    ./editors/ComponentEditor/memoryMaps/addressblockmodel.h \\\r\n    ./editors/ComponentEditor/memoryMaps/enumeratedvaluedelegate.h \\\r\n    ./editors/ComponentEditor/memoryMaps/enumeratedvaluemodel.h \\\r\n    ./editors/ComponentEditor/memoryMaps/fieldeditor.h \\\r\n    ./editors/ComponentEditor/memoryMaps/memoryMapsVisualizer/registerfilegraphitem.h \\\r\n    ./editors/ComponentEditor/memoryMaps/memoryMapsVisualizer/MemoryBlockGraphItem.h \\\r\n    ./editors/ComponentEditor/memoryMaps/memoryMapsVisualizer/SubspaceMapGraphItem.h \\\r\n    ./editors/ComponentEditor/memoryMaps/memoryMapsVisualizer/addressblockgraphitem.h \\\r\n    ./editors/ComponentEditor/memoryMaps/memoryMapsVisualizer/fieldgraphitem.h \\\r\n    ./editors/ComponentEditor/memoryMaps/memoryMapsVisualizer/memorymapgraphitem.h \\\r\n    ./editors/ComponentEditor/memoryMaps/memoryMapsVisualizer/memorymapscene.h \\\r\n    ./editors/ComponentEditor/memoryMaps/memoryMapsVisualizer/memorymapsvisualizer.h \\\r\n    ./editors/ComponentEditor/memoryMaps/memoryMapsVisualizer/memorymapview.h \\\r\n    ./editors/ComponentEditor/memoryMaps/memoryMapsVisualizer/registergraphitem.h \\\r\n    ./editors/ComponentEditor/memoryMaps/memoryMapsExpressionCalculators/ReferenceCalculator.h \\\r\n    ./editors/ComponentEditor/resetTypes/ResetTypeColumns.h \\\r\n    ./editors/ComponentEditor/resetTypes/ResetTypesEditor.h \\\r\n    ./editors/ComponentEditor/resetTypes/ResetTypesModel.h \\\r\n    ./editors/ComponentEditor/resetTypes/ResetTypesDelegate.h \\\r\n    ./editors/ComponentEditor/modes/FieldSliceColumns.h \\\r\n    ./editors/ComponentEditor/modes/ModeColumns.h \\\r\n    ./editors/ComponentEditor/modes/PortSliceColumns.h \\\r\n    ./editors/ComponentEditor/modes/FieldSliceEditor.h \\\r\n    ./editors/ComponentEditor/modes/FieldSliceModel.h \\\r\n    ./editors/ComponentEditor/modes/FieldSliceDelegate.h \\\r\n    ./editors/ComponentEditor/modes/ModesEditor.h \\\r\n    ./editors/ComponentEditor/modes/ModesModel.h \\\r\n    ./editors/ComponentEditor/modes/SingleModeEditor.h \\\r\n    ./editors/ComponentEditor/modes/PortSliceEditor.h \\\r\n    ./editors/ComponentEditor/modes/PortSliceModel.h \\\r\n    ./editors/ComponentEditor/modes/PortSliceDelegate.h \\\r\n    ./editors/ComponentEditor/powerDomains/PowerDomainColumns.h \\\r\n    ./editors/ComponentEditor/powerDomains/PowerDomainsEditor.h \\\r\n    ./editors/ComponentEditor/powerDomains/PowerDomainsModel.h \\\r\n    ./editors/ComponentEditor/powerDomains/PowerDomainsDelegate.h \\\r\n    ./editors/CSourceEditor/CSourceHighlight.h \\\r\n    ./editors/CSourceEditor/CSourceContentMatcher.h \\\r\n    ./editors/CSourceEditor/CSourceHighlighter.h \\\r\n    ./editors/CSourceEditor/CSourceTextEdit.h \\\r\n    ./editors/CSourceEditor/CSourceWidget.h \\\r\n    ./editors/ConfigurationTools/ViewConfigurerColumns.h \\\r\n    ./editors/ConfigurationTools/ViewConfigurer.h \\\r\n    ./editors/ConfigurationTools/ViewConfigurerDelegate.h \\\r\n    ./editors/CatalogEditor/CatalogFileColumns.h \\\r\n    ./editors/CatalogEditor/CatalogEditor.h \\\r\n    ./editors/CatalogEditor/CatalogFileModel.h \\\r\n    ./editors/CatalogEditor/CatalogFileDelegate.h \\\r\n    ./editors/CatalogEditor/CatalogFileFilter.h \\\r\n    ./editors/CatalogEditor/CatalogFileView.h \\\r\n    ./editors/BusDefinitionEditor/LogicalPortColumns.h \\\r\n    ./editors/BusDefinitionEditor/busdefgroup.h \\\r\n    ./editors/BusDefinitionEditor/BusDefinitionEditor.h \\\r\n    ./editors/BusDefinitionEditor/BusDefinitionParameterReferenceTree.h \\\r\n    ./editors/BusDefinitionEditor/SystemGroupListEditor.h \\\r\n    ./editors/common/ColumnTypes.h \\\r\n    ./editors/common/DefaultRouting.h \\\r\n    ./editors/common/DesignDiagramResolver.h \\\r\n    ./editors/common/DesignWidgetFactory.h \\\r\n    ./editors/common/DesignWidgetFactoryImplementation.h \\\r\n    ./editors/common/diagramgrid.h \\\r\n    ./editors/common/DiagramUtil.h \\\r\n    ./editors/common/DrawMode.h \\\r\n    ./editors/common/ExpressionSet.h \\\r\n    ./editors/common/GraphicsItemLabel.h \\\r\n    ./editors/common/ImageExporter.h \\\r\n    ./editors/common/NamelabelWidth.h \\\r\n    ./editors/common/PortUtilities.h \\\r\n    ./editors/common/TopComponentParameterFinder.h \\\r\n    ./editors/common/ComponentDesignDiagram.h \\\r\n    ./editors/common/DesignCompletionModel.h \\\r\n    ./editors/common/DesignDiagram.h \\\r\n    ./editors/common/DesignWidget.h \\\r\n    ./editors/common/DocumentNameGroupEditor.h \\\r\n    ./editors/common/Association/Associable.h \\\r\n    ./editors/common/Association/Association.h \\\r\n    ./editors/common/Association/AssociationAddCommand.h \\\r\n    ./editors/common/Association/AssociationChangeEndpointCommand.h \\\r\n    ./editors/common/Association/AssociationRemoveCommand.h \\\r\n    ./editors/common/ComponentInstanceEditor/ConfigurableElementsColumns.h \\\r\n    ./editors/common/ComponentInstanceEditor/EditorConfigurableElement.h \\\r\n    ./editors/common/ComponentInstanceEditor/PowerDomainLinkColumns.h \\\r\n    ./editors/common/ComponentInstanceEditor/ComponentInstanceConfigurableElementsEditor.h \\\r\n    ./editors/common/ComponentInstanceEditor/ComponentInstanceConfigurableElementsFilter.h \\\r\n    ./editors/common/ComponentInstanceEditor/ComponentInstanceConfigurableElementsModel.h \\\r\n    ./editors/common/ComponentInstanceEditor/componentinstanceeditor.h \\\r\n    ./editors/common/ComponentInstanceEditor/configurableelementdelegate.h \\\r\n    ./editors/common/ComponentInstanceEditor/configurableelementeditor.h \\\r\n    ./editors/common/ComponentInstanceEditor/ConfigurableElementsFilter.h \\\r\n    ./editors/common/ComponentInstanceEditor/ConfigurableElementsModel.h \\\r\n    ./editors/common/ComponentInstanceEditor/ConfigurableElementsView.h \\\r\n    ./editors/common/ComponentInstanceEditor/MissingConfigurableElementsFilter.h \\\r\n    ./editors/common/ComponentInstanceEditor/ParameterConfigurableElementsFilter.h \\\r\n    ./editors/common/ComponentInstanceEditor/PowerDomainLinkModel.h \\\r\n    ./editors/common/ComponentInstanceEditor/PowerDomainLinkEditor.h \\\r\n    ./editors/common/ComponentInstanceEditor/PowerDomainLinkDelegate.h \\\r\n    ./editors/common/ConfigurationEditor/configurationeditor.h \\\r\n    ./editors/common/ConfigurationEditor/activeviewdelegate.h \\\r\n    ./editors/common/ConfigurationEditor/activevieweditor.h \\\r\n    ./editors/common/ConfigurationEditor/activeviewmodel.h \\\r\n    ./editors/common/ConnectionEditor/AdHocBoundColumns.h \\\r\n    ./editors/common/ConnectionEditor/AdHocBoundsModel.h \\\r\n    ./editors/common/ConnectionEditor/connectioneditor.h \\\r\n    ./editors/common/DesignParameterReferenceTree/DesignParameterReferenceCounter.h \\\r\n    ./editors/common/DesignParameterReferenceTree/DesignParameterReferenceTree.h \\\r\n    ./editors/common/InterfaceEditor/InterfacePortMapColumns.h \\\r\n    ./editors/common/InterfaceEditor/interfaceeditor.h \\\r\n    ./editors/common/InterfaceEditor/InterfacePortMapDelegate.h \\\r\n    ./editors/common/InterfaceEditor/InterfacePortMapModel.h \\\r\n    ./editors/common/StickyNote/StickyNoteEditCommand.h \\\r\n    ./editors/common/StickyNote/StickyNoteMoveCommand.h \\\r\n    ./editors/common/StickyNote/ColorFillTextItem.h \\\r\n    ./editors/common/StickyNote/StickyNote.h \\\r\n    ./editors/common/StickyNote/StickyNoteAddCommand.h \\\r\n    ./editors/common/StickyNote/StickyNoteRemoveCommand.h \\\r\n    ./editors/common/ComponentItemAutoConnector/BusInterfaceItemMatcher.h \\\r\n    ./editors/common/ComponentItemAutoConnector/BusInterfaceListFiller.h \\\r\n    ./editors/common/ComponentItemAutoConnector/BusInterfaceTableAutoConnector.h \\\r\n    ./editors/common/ComponentItemAutoConnector/HierarchicalBusInterfaceItemMatcher.h \\\r\n    ./editors/common/ComponentItemAutoConnector/HierarchicalBusInterfaceTableAutoConnector.h \\\r\n    ./editors/common/ComponentItemAutoConnector/HierarchicalPortItemMatcher.h \\\r\n    ./editors/common/ComponentItemAutoConnector/HierarchicalPortTableAutoConnector.h \\\r\n    ./editors/common/ComponentItemAutoConnector/ListFiller.h \\\r\n    ./editors/common/ComponentItemAutoConnector/PortItemMatcher.h \\\r\n    ./editors/common/ComponentItemAutoConnector/PortTableAutoConnector.h \\\r\n    ./editors/common/ComponentItemAutoConnector/TableAutoConnector.h \\\r\n    ./editors/common/ComponentItemAutoConnector/TableItemMatcher.h \\\r\n    ./editors/common/ComponentItemAutoConnector/AutoConnectorItem.h \\\r\n    ./editors/common/ComponentItemAutoConnector/PortListFiller.h \\\r\n    ./editors/common/ComponentItemAutoConnector/ComponentItemAutoConnector.h \\\r\n    ./editors/common/ComponentItemAutoConnector/AutoConnectorConnectionTable.h \\\r\n    ./editors/common/ComponentItemAutoConnector/AutoConnector.h \\\r\n    ./editors/common/ComponentItemAutoConnector/AutoConnectorConnectionDelegate.h \\\r\n    ./editors/common/ComponentItemAutoConnector/AutoConnectorListFilter.h \\\r\n    ./editors/HWDesign/AdHocEnabled.h \\\r\n    ./editors/HWDesign/HWAddCommands.h \\\r\n    ./editors/HWDesign/HWMoveCommands.h \\\r\n    ./editors/HWDesign/InterfaceGraphics.h \\\r\n    ./editors/HWDesign/PortmapDialog.h \\\r\n    ./editors/HWDesign/WarningSymbol.h \\\r\n    ./editors/HWDesign/AdHocConnectionItem.h \\\r\n    ./editors/HWDesign/ActiveBusInterfaceItem.h \\\r\n    ./editors/HWDesign/ActivePortItem.h \\\r\n    ./editors/HWDesign/AdHocItem.h \\\r\n    ./editors/HWDesign/SelectItemTypeDialog.h \\\r\n    ./editors/HWDesign/BusInterfaceDialog.h \\\r\n    ./editors/HWDesign/BusInterfaceEndPoint.h \\\r\n    ./editors/HWDesign/HierarchicalBusInterfaceItem.h \\\r\n    ./editors/HWDesign/HierarchicalPortItem.h \\\r\n    ./editors/HWDesign/HWChangeCommands.h \\\r\n    ./editors/HWDesign/HWComponentItem.h \\\r\n    ./editors/HWDesign/HWConnection.h \\\r\n    ./editors/HWDesign/HWConnectionEndpoint.h \\\r\n    ./editors/HWDesign/HWDesignDiagram.h \\\r\n    ./editors/HWDesign/HWDesignWidget.h \\\r\n    ./editors/HWDesign/OffPageConnectorItem.h \\\r\n    ./editors/HWDesign/columnview/ColumnEditDialog.h \\\r\n    ./editors/HWDesign/columnview/HWColumn.h \\\r\n    ./editors/HWDesign/AdhocEditor/AdHocVisibilityColumns.h \\\r\n    ./editors/HWDesign/AdhocEditor/AdHocVisibilityModel.h \\\r\n    ./editors/HWDesign/AdhocEditor/AdHocVisibilityPolicy.h \\\r\n    ./editors/HWDesign/AdhocEditor/AdhocEditor.h \\\r\n    ./editors/HWDesign/AdhocEditor/AdhocPortEditor.h \\\r\n    ./editors/HWDesign/AdhocEditor/AdHocVisibilityDelegate.h \\\r\n    ./editors/HWDesign/AdhocEditor/AdHocVisibilityEditor.h \\\r\n    ./editors/HWDesign/undoCommands/AdHocConnectionAddCommand.h \\\r\n    ./editors/HWDesign/undoCommands/AdHocConnectionDeleteCommand.h \\\r\n    ./editors/HWDesign/undoCommands/AdHocTiedValueCommand.h \\\r\n    ./editors/HWDesign/undoCommands/AdHocTieOffBoundsChangeCommand.h \\\r\n    ./editors/HWDesign/undoCommands/AdHocTieOffConnectionDeleteCommand.h \\\r\n    ./editors/HWDesign/undoCommands/AdHocVisibilityChangeCommand.h \\\r\n    ./editors/HWDesign/undoCommands/ColumnDeleteCommand.h \\\r\n    ./editors/HWDesign/undoCommands/ComponentInstancePasteCommand.h \\\r\n    ./editors/HWDesign/undoCommands/ComponentItemMoveCommand.h \\\r\n    ./editors/HWDesign/undoCommands/ConnectionDeleteCommand.h \\\r\n    ./editors/HWDesign/undoCommands/HWColumnAddCommand.h \\\r\n    ./editors/HWDesign/undoCommands/PortDeleteCommand.h \\\r\n    ./editors/HWDesign/undoCommands/PortPasteCommand.h \\\r\n    ./editors/HWDesign/undoCommands/TopAdHocVisibilityChangeCommand.h \\\r\n    ./editors/HWDesign/undoCommands/PhysicalPortDeleteCommand.h \\\r\n    ./editors/HWDesign/undoCommands/AdHocBoundsChangeCommand.h \\\r\n    ./editors/HWDesign/undoCommands/AdHocTieOffChangeCommand.h \\\r\n    ./editors/HWDesign/undoCommands/ComponentDeleteCommand.h \\\r\n    ./editors/HWDesign/undoCommands/ConfigurableElementChangeCommand.h \\\r\n    ./editors/HWDesign/undoCommands/ConfigurableElementRemoveCommand.h \\\r\n    ./editors/HWDesign/undoCommands/HWComponentAddCommand.h \\\r\n    ./editors/HWDesign/undoCommands/InterfaceDeleteCommand.h \\\r\n    ./editors/HWDesign/undoCommands/ReplaceComponentCommand.h \\\r\n    ./editors/MemoryDesigner/AddressBlockGraphicsItem.h \\\r\n    ./editors/MemoryDesigner/AddressSegmentGraphicsItem.h \\\r\n    ./editors/MemoryDesigner/AddressSpaceGraphicsItem.h \\\r\n    ./editors/MemoryDesigner/ConnectivityComponent.h \\\r\n    ./editors/MemoryDesigner/ConnectivityConnection.h \\\r\n    ./editors/MemoryDesigner/ConnectivityGraph.h \\\r\n    ./editors/MemoryDesigner/ConnectivityGraphFactory.h \\\r\n    ./editors/MemoryDesigner/ConnectivityInterface.h \\\r\n    ./editors/MemoryDesigner/FieldGraphicsItem.h \\\r\n    ./editors/MemoryDesigner/FieldOverlapItem.h \\\r\n    ./editors/MemoryDesigner/MainMemoryGraphicsItem.h \\\r\n    ./editors/MemoryDesigner/MasterSlavePathSearch.h \\\r\n    ./editors/MemoryDesigner/MemoryCollisionItem.h \\\r\n    ./editors/MemoryDesigner/MemoryColumnHandler.h \\\r\n    ./editors/MemoryDesigner/MemoryConnectionAddressCalculator.h \\\r\n    ./editors/MemoryDesigner/MemoryConnectionHandler.h \\\r\n    ./editors/MemoryDesigner/MemoryConnectionItem.h \\\r\n    ./editors/MemoryDesigner/MemoryDesignerChildGraphicsItem.h \\\r\n    ./editors/MemoryDesigner/MemoryDesignerConstants.h \\\r\n    ./editors/MemoryDesigner/MemoryExtensionGraphicsItem.h \\\r\n    ./editors/MemoryDesigner/MemoryItem.h \\\r\n    ./editors/MemoryDesigner/MemoryMapGraphicsItem.h \\\r\n    ./editors/MemoryDesigner/RegisterGraphicsItem.h \\\r\n    ./editors/MemoryDesigner/SubMemoryLayout.h \\\r\n    ./editors/MemoryDesigner/MemoryColumn.h \\\r\n    ./editors/MemoryDesigner/MemoryDesignConstructor.h \\\r\n    ./editors/MemoryDesigner/MemoryDesignDocument.h \\\r\n    ./editors/MemoryDesigner/MemoryDesignerDiagram.h \\\r\n    ./editors/MemoryDesigner/MemoryDesignerGraphicsItem.h \\\r\n    ./editors/MemoryDesigner/MemoryGraphicsItemHandler.h \\\r\n    ./editors/SystemDesign/HWMappingItem.h \\\r\n    ./editors/SystemDesign/SystemDesignWidget.h \\\r\n    ./editors/SystemDesign/ApiGraphicsConnection.h \\\r\n    ./editors/SystemDesign/ComGraphicsConnection.h \\\r\n    ./editors/SystemDesign/SWComponentItem.h \\\r\n    ./editors/SystemDesign/SWConnectionEndpoint.h \\\r\n    ./editors/SystemDesign/SWInterfaceItem.h \\\r\n    ./editors/SystemDesign/SWPortItem.h \\\r\n    ./editors/SystemDesign/SystemColumn.h \\\r\n    ./editors/SystemDesign/SystemComponentItem.h \\\r\n    ./editors/SystemDesign/SystemDesignDiagram.h \\\r\n    ./editors/SystemDesign/SystemDetailsEditor/SystemDetailsEditor.h \\\r\n    ./editors/SystemDesign/SystemDetailsEditor/ExportSWDialog.h \\\r\n    ./editors/SystemDesign/SystemDetailsEditor/SwitchHWDialog.h \\\r\n    ./editors/SystemDesign/UndoCommands/ApiConnectionAddCommand.h \\\r\n    ./editors/SystemDesign/UndoCommands/ApiConnectionDeleteCommand.h \\\r\n    ./editors/SystemDesign/UndoCommands/ApiConnectionExchangeCommand.h \\\r\n    ./editors/SystemDesign/UndoCommands/ComConnectionAddCommand.h \\\r\n    ./editors/SystemDesign/UndoCommands/ComConnectionDeleteCommand.h \\\r\n    ./editors/SystemDesign/UndoCommands/ComConnectionExchangeCommand.h \\\r\n    ./editors/SystemDesign/UndoCommands/SWInterfaceAddCommand.h \\\r\n    ./editors/SystemDesign/UndoCommands/SWInterfaceDeleteCommand.h \\\r\n    ./editors/SystemDesign/UndoCommands/SWInterfaceMoveCommand.h \\\r\n    ./editors/SystemDesign/UndoCommands/SWPortDeleteCommand.h \\\r\n    ./editors/SystemDesign/UndoCommands/SystemAddCommands.h \\\r\n    ./editors/SystemDesign/UndoCommands/SystemChangeCommands.h \\\r\n    ./editors/SystemDesign/UndoCommands/SystemDeleteCommands.h \\\r\n    ./editors/SystemDesign/UndoCommands/SystemMoveCommands.h \\\r\n    ./editors/SystemDesign/UndoCommands/ReplaceSystemComponentCommand.h \\\r\n    ./editors/SystemDesign/UndoCommands/SystemComponentAddCommand.h \\\r\n    ./editors/SystemDesign/UndoCommands/SystemComponentDeleteCommand.h \\\r\n    ./editors/common/VendorExtensionEditor/VendorExtensionColumns.h \\\r\n    ./editors/common/VendorExtensionEditor/VendorExtensionsGeneral.h \\\r\n    ./editors/common/VendorExtensionEditor/VendorExtensionsEditor.h \\\r\n    ./editors/common/VendorExtensionEditor/VendorExtensionsModel.h \\\r\n    ./editors/common/VendorExtensionEditor/VendorExtensionsDelegate.h \\\r\n    ./editors/common/VendorExtensionEditor/VendorExtensionsFilter.h \\\r\n    ./editors/common/VendorExtensionEditor/VendorExtensionAttributesEditor/VendorExtensionAttributesColumns.h \\\r\n    ./editors/common/VendorExtensionEditor/VendorExtensionAttributesEditor/VendorExtensionAttributesModel.h \\\r\n    ./editors/PythonSourceEditor/PythonSourceHighlight.h \\\r\n    ./editors/PythonSourceEditor/ScriptingSideArea.h \\\r\n    ./editors/PythonSourceEditor/PythonSourceEditor.h \\\r\n    ./editors/PythonSourceEditor/ScriptInputEditor.h \\\r\n    ./editors/PythonSourceEditor/ScriptViewEditor.h \\\r\n    ./editors/AbstractionDefinitionEditor/AbstractionDefinitionPortsSortFilter.h \\\r\n    ./editors/AbstractionDefinitionEditor/AbstractionDefinitionSignalRow.h \\\r\n    ./editors/AbstractionDefinitionEditor/AbstractionTransactionalPortsSortFilter.h \\\r\n    ./editors/AbstractionDefinitionEditor/AbstractionWirePortsSortFilter.h \\\r\n    ./editors/AbstractionDefinitionEditor/LogicalPortColumns.h \\\r\n    ./editors/AbstractionDefinitionEditor/QualifierData.h \\\r\n    ./editors/AbstractionDefinitionEditor/absdefgroup.h \\\r\n    ./editors/AbstractionDefinitionEditor/AbstractionDefinitionEditor.h \\\r\n    ./editors/AbstractionDefinitionEditor/AbsDefParameterReferenceCounter.h \\\r\n    ./editors/AbstractionDefinitionEditor/AbsDefParameterReferenceTree.h \\\r\n    ./editors/AbstractionDefinitionEditor/AbstractionPortsDelegate.h \\\r\n    ./editors/AbstractionDefinitionEditor/AbstractionPortsEditor.h \\\r\n    ./editors/AbstractionDefinitionEditor/AbstractionPortsModel.h \\\r\n    ./editors/AbstractionDefinitionEditor/AbstractionPortsView.h \\\r\n    ./editors/AbstractionDefinitionEditor/AbstractionTransactionalPortsDelegate.h \\\r\n    ./editors/AbstractionDefinitionEditor/AbstractionWirePortsDelegate.h \\\r\n    ./editors/AbstractionDefinitionEditor/QualifierEditor.h \\\r\n    ./editors/InterconnectGenerator/InterconnectAddressHelper.h \\\r\n    ./editors/InterconnectGenerator/InterconnectDataModel.h \\\r\n    ./editors/InterconnectGenerator/InterconnectGeneratorDialog.h \\\r\n    ./editors/InterconnectGenerator/InstanceInterfacesEditor.h \\\r\n    ./kactusGenerators/DocumentGenerator/DocumentationWriter.h \\\r\n    ./kactusGenerators/DocumentGenerator/HtmlWriter.h \\\r\n    ./kactusGenerators/DocumentGenerator/MarkdownWriter.h \\\r\n    ./kactusGenerators/DocumentGenerator/documentgenerator.h \\\r\n    ./PythonAPI/WriteChannel.h \\\r\n    ./PythonAPI/ChannelRelay.h \\\r\n    ./PythonAPI/FileChannel.h \\\r\n    ./PythonAPI/PythonInterpreter.h \\\r\n    ./PythonAPI/StdInputListener.h \\\r\n    ./PythonAPI/extensions/IOCatcher.h \\\r\n    ./editors/ComponentEditor/ports/PortsImportSummaryEditor.h\r\nSOURCES += ./editors/ComponentEditor/busInterfaces/general/MasterModeEditor.cpp \\\r\n    ./common/GenericEditProvider.cpp \\\r\n    ./common/NameGenerationPolicy.cpp \\\r\n    ./common/TextEditProvider.cpp \\\r\n    ./common/dialogs/comboSelector/comboselector.cpp \\\r\n    ./common/dialogs/propertyPageDialog/PropertyPageDialog.cpp \\\r\n    ./common/dialogs/propertyPageDialog/PropertyPageView.cpp \\\r\n    ./common/dialogs/newObjectDialog/newobjectdialog.cpp \\\r\n    ./common/dialogs/createConfigurationDialog/createconfigurationdialog.cpp \\\r\n    ./common/dialogs/listSelectDialog/ListSelectDialog.cpp \\\r\n    ./common/dialogs/NewDesignDialog/NewDesignDialog.cpp \\\r\n    ./common/dialogs/LibrarySettingsDialog/librarysettingsdelegate.cpp \\\r\n    ./common/dialogs/LibrarySettingsDialog/LibrarySettingsDialog.cpp \\\r\n    ./common/dialogs/NewBusDialog/NewBusDialog.cpp \\\r\n    ./common/validators/LibraryPathValidator/librarypathvalidator.cpp \\\r\n    ./common/widgets/assistedLineEdit/AssistedLineEdit.cpp \\\r\n    ./common/widgets/assistedLineEdit/BasicLineContentMatcher.cpp \\\r\n    ./common/widgets/assistedLineEdit/LineContentAssistWidget.cpp \\\r\n    ./common/widgets/listManager/dirlistmanager.cpp \\\r\n    ./common/widgets/listManager/dirlistmanagermodel.cpp \\\r\n    ./common/widgets/listManager/listeditor.cpp \\\r\n    ./common/widgets/listManager/listmanager.cpp \\\r\n    ./common/widgets/listManager/listmanagermodel.cpp \\\r\n    ./common/widgets/nameGroupBox/namegroupbox.cpp \\\r\n    ./common/widgets/vlnvDisplayer/vlnvdisplayer.cpp \\\r\n    ./common/widgets/assistedTextEdit/AssistedTextEdit.cpp \\\r\n    ./common/widgets/assistedTextEdit/TextContentAssistWidget.cpp \\\r\n    ./common/widgets/assistedTextEdit/ToolTipHintWidget.cpp \\\r\n    ./common/widgets/vlnvEditor/VLNVContentMatcher.cpp \\\r\n    ./common/widgets/vlnvEditor/VLNVDataTree.cpp \\\r\n    ./common/widgets/vlnvEditor/vlnveditor.cpp \\\r\n    ./common/widgets/kactusAttributeEditor/KactusAttributeEditor.cpp \\\r\n    ./common/widgets/componentPreviewBox/ComponentPreviewBox.cpp \\\r\n    ./common/widgets/tabDocument/TabDocument.cpp \\\r\n    ./common/widgets/booleanComboBox/booleancombobox.cpp \\\r\n    ./common/widgets/ParameterGroupBox/parametergroupbox.cpp \\\r\n    ./common/widgets/nameGroupEditor/namegroupeditor.cpp \\\r\n    ./common/widgets/summaryLabel/summarylabel.cpp \\\r\n    ./common/widgets/interfaceModeSelector/interfacemodeselector.cpp \\\r\n    ./common/widgets/interfaceSelector/interfaceselector.cpp \\\r\n    ./common/widgets/LineEditEx/LineEditEx.cpp \\\r\n    ./common/widgets/SnippetTextEdit/SnippetHighlighter.cpp \\\r\n    ./common/widgets/SnippetTextEdit/SnippetTextEdit.cpp \\\r\n    ./common/widgets/usageComboBox/usagecombobox.cpp \\\r\n    ./common/widgets/accessComboBox/accesscombobox.cpp \\\r\n    ./common/widgets/modWriteComboBox/modwritecombobox.cpp \\\r\n    ./common/widgets/readActionComboBox/readactioncombobox.cpp \\\r\n    ./common/widgets/testConstraintComboBox/testconstraintcombobox.cpp \\\r\n    ./common/widgets/viewSelector/viewselector.cpp \\\r\n    ./common/widgets/fileTypeSelector/filetypeselector.cpp \\\r\n    ./common/widgets/EnumCollectionEditor/EnumCollectionEditor.cpp \\\r\n    ./common/widgets/EnumCollectionEditor/EnumerationEditor.cpp \\\r\n    ./common/widgets/EnumCollectionEditor/InterfaceEnumEditor.cpp \\\r\n    ./common/widgets/FileSelector/fileselector.cpp \\\r\n    ./common/widgets/LibrarySelectorWidget/LibrarySelectorWidget.cpp \\\r\n    ./common/widgets/LibrarySelectorWidget/LibraryPathEditor/librarypatheditor.cpp \\\r\n    ./common/widgets/LibrarySelectorWidget/LibraryPathSelector/librarypathselector.cpp \\\r\n    ./common/widgets/DirectoryListSelector/DirectoryListSelector.cpp \\\r\n    ./common/widgets/colorBox/ColorBox.cpp \\\r\n    ./common/widgets/tagEditor/FlowLayout.cpp \\\r\n    ./common/widgets/tagEditor/TagCompleterModel.cpp \\\r\n    ./common/widgets/tagEditor/TagContainer.cpp \\\r\n    ./common/widgets/tagEditor/TagDisplay.cpp \\\r\n    ./common/widgets/tagEditor/TagEditor.cpp \\\r\n    ./common/widgets/tagEditor/TagEditorContainer.cpp \\\r\n    ./common/widgets/tagEditor/TagLabel.cpp \\\r\n    ./common/widgets/tagEditor/TagSelector.cpp \\\r\n    ./common/widgets/tagEditor/TagSelectorContainer.cpp \\\r\n    ./common/widgets/busReferenceComboBox/BusReferenceComboBox.cpp \\\r\n    ./common/widgets/segmentComboBox/SegmentComboBox.cpp \\\r\n    ./common/widgets/TreeItemSelector/FramedTreeItemEditor.cpp \\\r\n    ./common/widgets/TreeItemSelector/TreeItemEditor.cpp \\\r\n    ./common/widgets/TreeItemSelector/TreeItemModel.cpp \\\r\n    ./common/widgets/GroupBoxWithAlertSign/GroupBoxWithAlertSign.cpp \\\r\n    ./common/widgets/GroupBoxWithAlertSign/StyleGroupBoxWithAlertSign.cpp \\\r\n    ./common/widgets/GroupBoxWithAlertSign/StyleOptionGroupBoxWithAlertSign.cpp \\\r\n    ./common/widgets/instanceWidgets/InstanceWidgets.cpp \\\r\n    ./common/graphicsItems/GraphicsColumnAddCommand.cpp \\\r\n    ./common/graphicsItems/CommonGraphicsUndoCommands.cpp \\\r\n    ./common/graphicsItems/ComponentItem.cpp \\\r\n    ./common/graphicsItems/ConnectionEndpoint.cpp \\\r\n    ./common/graphicsItems/ConnectionUndoCommands.cpp \\\r\n    ./common/graphicsItems/expandableitem.cpp \\\r\n    ./common/graphicsItems/GraphicsColumn.cpp \\\r\n    ./common/graphicsItems/GraphicsColumnLayout.cpp \\\r\n    ./common/graphicsItems/GraphicsColumnUndoCommands.cpp \\\r\n    ./common/graphicsItems/GraphicsConnection.cpp \\\r\n    ./common/graphicsItems/graphicsexpandcollapseitem.cpp \\\r\n    ./common/graphicsItems/GraphicsLineEdit.cpp \\\r\n    ./common/graphicsItems/GraphicsRectButton.cpp \\\r\n    ./common/graphicsItems/visualizeritem.cpp \\\r\n    ./common/delegates/ComboDelegate/combodelegate.cpp \\\r\n    ./common/delegates/LineEditDelegate/lineeditdelegate.cpp \\\r\n    ./common/views/EditableTableView/editabletableview.cpp \\\r\n    ./common/views/EditableListView/editablelistview.cpp \\\r\n    ./common/views/EditableTreeView/EditableTreeSortFilter.cpp \\\r\n    ./common/views/EditableTreeView/EditableTreeView.cpp \\\r\n    ./common/views/ExpandingTreeView/ExpandingTreeView.cpp \\\r\n    ./common/ui/GraphicalMessageMediator.cpp \\\r\n    ./common/expressions/utilities.cpp \\\r\n    ./mainwindow/CommandLineParser.cpp \\\r\n    ./mainwindow/DeleteWorkspaceDialog.cpp \\\r\n    ./mainwindow/DockWidgetHandler.cpp \\\r\n    ./mainwindow/main.cpp \\\r\n    ./mainwindow/mainwindow.cpp \\\r\n    ./mainwindow/NewWorkspaceDialog.cpp \\\r\n    ./mainwindow/SplashScreen.cpp \\\r\n    ./mainwindow/WorkspaceSettings.cpp \\\r\n    ./mainwindow/NewPages/NewApiDefinitionPage.cpp \\\r\n    ./mainwindow/NewPages/NewBusDefinitionPage.cpp \\\r\n    ./mainwindow/NewPages/NewCatalogPage.cpp \\\r\n    ./mainwindow/NewPages/NewComDefinitionPage.cpp \\\r\n    ./mainwindow/NewPages/NewComponentPage.cpp \\\r\n    ./mainwindow/NewPages/NewDesignPage.cpp \\\r\n    ./mainwindow/NewPages/NewPage.cpp \\\r\n    ./mainwindow/NewPages/NewSWComponentPage.cpp \\\r\n    ./mainwindow/NewPages/NewSWDesignPage.cpp \\\r\n    ./mainwindow/NewPages/NewSystemPage.cpp \\\r\n    ./mainwindow/MessageConsole/messageconsole.cpp \\\r\n    ./mainwindow/Ribbon/Ribbon.cpp \\\r\n    ./mainwindow/Ribbon/RibbonGroup.cpp \\\r\n    ./mainwindow/DrawingBoard/DrawingBoard.cpp \\\r\n    ./mainwindow/SaveHierarchy/DocumentTreeBuilder.cpp \\\r\n    ./mainwindow/SaveHierarchy/HierarchicalSaveBuildStrategy.cpp \\\r\n    ./mainwindow/SaveHierarchy/SaveAsItem.cpp \\\r\n    ./mainwindow/SaveHierarchy/SaveHierarchyDelegate.cpp \\\r\n    ./mainwindow/SaveHierarchy/SaveHierarchyDialog.cpp \\\r\n    ./settings/ComponentEditorSettingsPage.cpp \\\r\n    ./settings/FileTypesDelegate.cpp \\\r\n    ./settings/FileTypeSettingsPage.cpp \\\r\n    ./settings/FileTypesModel.cpp \\\r\n    ./settings/filetypesview.cpp \\\r\n    ./settings/k2envvariablesettingspage.cpp \\\r\n    ./settings/k2envvarmodel.cpp \\\r\n    ./settings/NewPluginsDialog.cpp \\\r\n    ./settings/PluginInfoWidget.cpp \\\r\n    ./settings/PluginSettingsPage.cpp \\\r\n    ./settings/CodeEditorSettingsPage.cpp \\\r\n    ./settings/GeneralSettingsPage.cpp \\\r\n    ./settings/NamingPolicySettingsPage.cpp \\\r\n    ./settings/SettingsDialog.cpp \\\r\n    ./settings/SettingsPage.cpp \\\r\n    ./settings/SettingsUpdater.cpp \\\r\n    ./wizards/ComponentWizard/ComponentWizard.cpp \\\r\n    ./wizards/ComponentWizard/ComponentWizardConclusionPage.cpp \\\r\n    ./wizards/ComponentWizard/ComponentWizardDependencyPage.cpp \\\r\n    ./wizards/ComponentWizard/ComponentWizardGeneralInfoPage.cpp \\\r\n    ./wizards/ComponentWizard/ComponentWizardImportPage.cpp \\\r\n    ./wizards/ComponentWizard/ComponentWizardIntroPage.cpp \\\r\n    ./wizards/ComponentWizard/ComponentWizardViewsPage.cpp \\\r\n    ./wizards/ComponentWizard/ImportEditor.cpp \\\r\n    ./wizards/ComponentWizard/ViewListModel.cpp \\\r\n    ./wizards/BusInterfaceWizard/BusInterfaceWizard.cpp \\\r\n    ./wizards/BusInterfaceWizard/BusInterfaceWizardAbsDefinitionPage.cpp \\\r\n    ./wizards/BusInterfaceWizard/BusInterfaceWizardBusDefinitionPage.cpp \\\r\n    ./wizards/BusInterfaceWizard/BusInterfaceWizardConclusionPage.cpp \\\r\n    ./wizards/BusInterfaceWizard/BusInterfaceWizardGeneralOptionsPage.cpp \\\r\n    ./wizards/BusInterfaceWizard/BusInterfaceWizardIntroPage.cpp \\\r\n    ./wizards/BusInterfaceWizard/BusInterfaceWizardPortMapPage.cpp \\\r\n    ./wizards/ImportWizard/ImportWizard.cpp \\\r\n    ./wizards/ImportWizard/ImportWizardImportPage.cpp \\\r\n    ./wizards/ImportWizard/ImportWizardInstancesPage.cpp \\\r\n    ./wizards/ImportWizard/ImportWizardIntroPage.cpp \\\r\n    ./wizards/ImportWizard/ImportInstancesEditor/ImportInstancesDelegate.cpp \\\r\n    ./wizards/ImportWizard/ImportInstancesEditor/ImportInstancesEditor.cpp \\\r\n    ./wizards/common/IPXactDiff.cpp \\\r\n    ./wizards/common/ComponentComparator/ComponentComparator.cpp \\\r\n    ./wizards/common/ComponentDiffWidget/ComponentDiffWidget.cpp \\\r\n    ./wizards/common/VLNVComparator/VLNVComparator.cpp \\\r\n    ./wizards/common/ViewComparator/ViewComparator.cpp \\\r\n    ./wizards/common/PortComparator/PortComparator.cpp \\\r\n    ./wizards/common/ParameterComparator/ParameterComparator.cpp \\\r\n    ./wizards/common/ModuleParameterComparator/ModuleParameterComparator.cpp \\\r\n    ./Help/HelpSystem/ContextHelpBrowser.cpp \\\r\n    ./Help/HelpSystem/HelpSearchWidget.cpp \\\r\n    ./Help/HelpSystem/HelpWindow.cpp \\\r\n    ./Plugins/common/ConnectivityGraphUtilities.cpp \\\r\n    ./Plugins/common/CpuRoutesContainer.cpp \\\r\n    ./Plugins/common/LanguageHighlighter.cpp \\\r\n    ./Plugins/common/SingleCpuRoutesContainer.cpp \\\r\n    ./Plugins/common/SourceHighlightStyle.cpp \\\r\n    ./Plugins/PluginSystem/GeneratorPlugin/AddToFilesetWidget.cpp \\\r\n    ./library/ItemExporter.cpp \\\r\n    ./library/LibraryErrorModel.cpp \\\r\n    ./library/LibraryFilter.cpp \\\r\n    ./library/LibraryItemSelectionFactory.cpp \\\r\n    ./library/LibraryTreeFilter.cpp \\\r\n    ./library/LibraryTreeView.cpp \\\r\n    ./library/LibraryTreeWidget.cpp \\\r\n    ./library/LibraryUtils.cpp \\\r\n    ./library/LibraryWidget.cpp \\\r\n    ./library/ObjectExportDialog.cpp \\\r\n    ./library/objectremovedialog.cpp \\\r\n    ./library/TableViewDialog.cpp \\\r\n    ./library/ObjectSelectionDialog.cpp \\\r\n    ./library/ObjectSelectionListItem.cpp \\\r\n    ./library/VLNVDialer/FilterGroup.cpp \\\r\n    ./library/VLNVDialer/filterwidget.cpp \\\r\n    ./library/VLNVDialer/firmnessgroup.cpp \\\r\n    ./library/VLNVDialer/hierarchygroup.cpp \\\r\n    ./library/VLNVDialer/implementationgroup.cpp \\\r\n    ./library/VLNVDialer/RevisionGroup.cpp \\\r\n    ./library/VLNVDialer/typegroup.cpp \\\r\n    ./library/VLNVDialer/ValidityGroup.cpp \\\r\n    ./library/VLNVDialer/vlnvdialer.cpp \\\r\n    ./library/HierarchyView/hierarchyfilter.cpp \\\r\n    ./library/HierarchyView/hierarchyview.cpp \\\r\n    ./library/HierarchyView/hierarchywidget.cpp \\\r\n    ./editors/ApiDefinitionEditor/ApiDefinitionEditor.cpp \\\r\n    ./editors/ApiDefinitionEditor/ApiFunctionEditor.cpp \\\r\n    ./editors/ApiDefinitionEditor/ApiFunctionModel.cpp \\\r\n    ./editors/ApiDefinitionEditor/ApiFunctionParameterDelegate.cpp \\\r\n    ./editors/ApiDefinitionEditor/ApiFunctionParameterModel.cpp \\\r\n    ./editors/ComDefinitionEditor/ComDefinitionEditor.cpp \\\r\n    ./editors/ComDefinitionEditor/ComPropertyDelegate.cpp \\\r\n    ./editors/ComDefinitionEditor/ComPropertyEditor.cpp \\\r\n    ./editors/ComDefinitionEditor/ComPropertyModel.cpp \\\r\n    ./editors/ComponentEditor/componenteditor.cpp \\\r\n    ./editors/ComponentEditor/itemeditor.cpp \\\r\n    ./editors/ComponentEditor/itemvisualizer.cpp \\\r\n    ./editors/ComponentEditor/ParameterItemEditor.cpp \\\r\n    ./editors/ComponentEditor/busInterfaces/AbstractionTypesDelegate.cpp \\\r\n    ./editors/ComponentEditor/busInterfaces/AbstractionTypesEditor.cpp \\\r\n    ./editors/ComponentEditor/busInterfaces/AbstractionTypesModel.cpp \\\r\n    ./editors/ComponentEditor/busInterfaces/businterfaceeditor.cpp \\\r\n    ./editors/ComponentEditor/busInterfaces/businterfacesdelegate.cpp \\\r\n    ./editors/ComponentEditor/busInterfaces/businterfaceseditor.cpp \\\r\n    ./editors/ComponentEditor/busInterfaces/businterfacesmodel.cpp \\\r\n    ./editors/ComponentEditor/busInterfaces/portmaps/BusInterfacePortMapTab.cpp \\\r\n    ./editors/ComponentEditor/busInterfaces/portmaps/JaroWinklerAlgorithm.cpp \\\r\n    ./editors/ComponentEditor/busInterfaces/portmaps/PhysicalPortMappingTableModel.cpp \\\r\n    ./editors/ComponentEditor/busInterfaces/portmaps/PhysicalPortMappingTableView.cpp \\\r\n    ./editors/ComponentEditor/busInterfaces/portmaps/PortListSortProxyModel.cpp \\\r\n    ./editors/ComponentEditor/busInterfaces/portmaps/PortMapAutoConnector.cpp \\\r\n    ./editors/ComponentEditor/busInterfaces/portmaps/PortMapDelegate.cpp \\\r\n    ./editors/ComponentEditor/busInterfaces/portmaps/PortMapHeaderView.cpp \\\r\n    ./editors/ComponentEditor/busInterfaces/portmaps/PortMapModel.cpp \\\r\n    ./editors/ComponentEditor/busInterfaces/portmaps/PortMappingTableModel.cpp \\\r\n    ./editors/ComponentEditor/busInterfaces/portmaps/PortMappingTableView.cpp \\\r\n    ./editors/ComponentEditor/busInterfaces/portmaps/PortMapSortFilter.cpp \\\r\n    ./editors/ComponentEditor/busInterfaces/portmaps/PortMapView.cpp \\\r\n    ./editors/ComponentEditor/busInterfaces/general/bridgesdelegate.cpp \\\r\n    ./editors/ComponentEditor/busInterfaces/general/bridgeseditor.cpp \\\r\n    ./editors/ComponentEditor/busInterfaces/general/bridgesmodel.cpp \\\r\n    ./editors/ComponentEditor/busInterfaces/general/busifgeneraldetails.cpp \\\r\n    ./editors/ComponentEditor/busInterfaces/general/busifgeneraltab.cpp \\\r\n    ./editors/ComponentEditor/busInterfaces/general/InitiatorModeEditor.cpp \\\r\n    ./editors/ComponentEditor/busInterfaces/general/interfacemodestack.cpp \\\r\n    ./editors/ComponentEditor/busInterfaces/general/MirroredInitiatorModeEditor.cpp \\\r\n    ./editors/ComponentEditor/busInterfaces/general/MirroredMasterModeEditor.cpp \\\r\n    ./editors/ComponentEditor/busInterfaces/general/MirroredSlaveModeEditor.cpp \\\r\n    ./editors/ComponentEditor/busInterfaces/general/MirroredTargetModeEditor.cpp \\\r\n    ./editors/ComponentEditor/busInterfaces/general/ModeEditorBase.cpp \\\r\n    ./editors/ComponentEditor/busInterfaces/general/MonitorModeEditor.cpp \\\r\n    ./editors/ComponentEditor/busInterfaces/general/SlaveModeEditor.cpp \\\r\n    ./editors/ComponentEditor/busInterfaces/general/SystemModeEditor.cpp \\\r\n    ./editors/ComponentEditor/busInterfaces/general/TargetModeEditor.cpp \\\r\n    ./editors/ComponentEditor/channels/channelsdelegate.cpp \\\r\n    ./editors/ComponentEditor/channels/channelseditor.cpp \\\r\n    ./editors/ComponentEditor/channels/channelsmodel.cpp \\\r\n    ./editors/ComponentEditor/fileBuilders/filebuildersdelegate.cpp \\\r\n    ./editors/ComponentEditor/fileBuilders/filebuilderseditor.cpp \\\r\n    ./editors/ComponentEditor/fileBuilders/filebuildersmodel.cpp \\\r\n    ./editors/ComponentEditor/fileSet/fileseteditor.cpp \\\r\n    ./editors/ComponentEditor/fileSet/filesetsdelegate.cpp \\\r\n    ./editors/ComponentEditor/fileSet/filesetseditor.cpp \\\r\n    ./editors/ComponentEditor/fileSet/filesetsmodel.cpp \\\r\n    ./editors/ComponentEditor/fileSet/groupmanager.cpp \\\r\n    ./editors/ComponentEditor/fileSet/groupmanagerdelegate.cpp \\\r\n    ./editors/ComponentEditor/fileSet/file/filebuildcommand.cpp \\\r\n    ./editors/ComponentEditor/fileSet/file/filedefinemodel.cpp \\\r\n    ./editors/ComponentEditor/fileSet/file/filedefineview.cpp \\\r\n    ./editors/ComponentEditor/fileSet/file/fileeditor.cpp \\\r\n    ./editors/ComponentEditor/fileSet/file/filegeneraleditor.cpp \\\r\n    ./editors/ComponentEditor/fileSet/file/filenameeditor.cpp \\\r\n    ./editors/ComponentEditor/fileSet/file/filesdelegate.cpp \\\r\n    ./editors/ComponentEditor/fileSet/file/fileseditor.cpp \\\r\n    ./editors/ComponentEditor/fileSet/file/filesmodel.cpp \\\r\n    ./editors/ComponentEditor/fileSet/file/filesview.cpp \\\r\n    ./editors/ComponentEditor/fileSet/file/filetypeeditor.cpp \\\r\n    ./editors/ComponentEditor/fileSet/file/filetypeeditordelegate.cpp \\\r\n    ./editors/ComponentEditor/fileSet/dependencyAnalysis/FileDependencyDelegate.cpp \\\r\n    ./editors/ComponentEditor/fileSet/dependencyAnalysis/FileDependencyEditor.cpp \\\r\n    ./editors/ComponentEditor/fileSet/dependencyAnalysis/FileDependencyGraphView.cpp \\\r\n    ./editors/ComponentEditor/fileSet/dependencyAnalysis/FileDependencyGraphWidget.cpp \\\r\n    ./editors/ComponentEditor/fileSet/dependencyAnalysis/FileDependencyInfoWidget.cpp \\\r\n    ./editors/ComponentEditor/fileSet/dependencyAnalysis/FileDependencyItem.cpp \\\r\n    ./editors/ComponentEditor/fileSet/dependencyAnalysis/FileDependencyModel.cpp \\\r\n    ./editors/ComponentEditor/fileSet/dependencyAnalysis/FileDependencySortFilter.cpp \\\r\n    ./editors/ComponentEditor/fileSet/dependencyAnalysis/FileDependencySourceEditor.cpp \\\r\n    ./editors/ComponentEditor/general/generaleditor.cpp \\\r\n    ./editors/ComponentEditor/parameters/ChoiceCreatorDelegate.cpp \\\r\n    ./editors/ComponentEditor/parameters/ComponentParameterModel.cpp \\\r\n    ./editors/ComponentEditor/parameters/LockableParametersModel.cpp \\\r\n    ./editors/ComponentEditor/parameters/ParameterDelegate.cpp \\\r\n    ./editors/ComponentEditor/parameters/ParameterEditorHeaderView.cpp \\\r\n    ./editors/ComponentEditor/parameters/parameterseditor.cpp \\\r\n    ./editors/ComponentEditor/parameters/parametersmodel.cpp \\\r\n    ./editors/ComponentEditor/parameters/ParametersView.cpp \\\r\n    ./editors/ComponentEditor/parameters/Array/ArrayDelegate.cpp \\\r\n    ./editors/ComponentEditor/parameters/Array/ArrayView.cpp \\\r\n    ./editors/ComponentEditor/parameters/Array/ParameterArrayModel.cpp \\\r\n    ./editors/ComponentEditor/ports/MasterPortsEditor.cpp \\\r\n    ./editors/ComponentEditor/ports/portsdelegate.cpp \\\r\n    ./editors/ComponentEditor/ports/portseditor.cpp \\\r\n    ./editors/ComponentEditor/ports/PortsFilter.cpp \\\r\n    ./editors/ComponentEditor/ports/portsmodel.cpp \\\r\n    ./editors/ComponentEditor/ports/PortSummaryDelegate.cpp \\\r\n    ./editors/ComponentEditor/ports/PortSummaryEditorFactory.cpp \\\r\n    ./editors/ComponentEditor/ports/PortSummaryModel.cpp \\\r\n    ./editors/ComponentEditor/ports/PortSummaryView.cpp \\\r\n    ./editors/ComponentEditor/ports/PortsView.cpp \\\r\n    ./editors/ComponentEditor/ports/PortTagEditorDelegate.cpp \\\r\n    ./editors/ComponentEditor/ports/PortTypeDefinitionDelegate.cpp \\\r\n    ./editors/ComponentEditor/ports/PortTypeDefinitionEditor.cpp \\\r\n    ./editors/ComponentEditor/ports/PortWireTypeDelegate.cpp \\\r\n    ./editors/ComponentEditor/ports/PortWireTypeEditor.cpp \\\r\n    ./editors/ComponentEditor/ports/PortWireTypeModel.cpp \\\r\n    ./editors/ComponentEditor/ports/PortWireTypeView.cpp \\\r\n    ./editors/ComponentEditor/ports/TransactionalPortsDelegate.cpp \\\r\n    ./editors/ComponentEditor/ports/TransactionalPortsEditorFactory.cpp \\\r\n    ./editors/ComponentEditor/ports/TransactionalPortsFilter.cpp \\\r\n    ./editors/ComponentEditor/ports/TransactionalPortsModel.cpp \\\r\n    ./editors/ComponentEditor/ports/TypedPortEditor.cpp \\\r\n    ./editors/ComponentEditor/ports/WirePortsDelegate.cpp \\\r\n    ./editors/ComponentEditor/ports/WirePortsEditorFactory.cpp \\\r\n    ./editors/ComponentEditor/ports/WirePortsFilter.cpp \\\r\n    ./editors/ComponentEditor/ports/WirePortsModel.cpp \\\r\n    ./editors/ComponentEditor/ports/TypedPortsView.cpp \\\r\n    ./editors/ComponentEditor/views/envidentifiereditor.cpp \\\r\n    ./editors/ComponentEditor/views/envidentifiersmodel.cpp \\\r\n    ./editors/ComponentEditor/views/vieweditor.cpp \\\r\n    ./editors/ComponentEditor/views/ViewsDelegate.cpp \\\r\n    ./editors/ComponentEditor/views/viewseditor.cpp \\\r\n    ./editors/ComponentEditor/views/viewsmodel.cpp \\\r\n    ./editors/ComponentEditor/software/PropertyValueDelegate.cpp \\\r\n    ./editors/ComponentEditor/software/PropertyValueEditor.cpp \\\r\n    ./editors/ComponentEditor/software/PropertyValueModel.cpp \\\r\n    ./editors/ComponentEditor/software/SWPropertiesEditor.cpp \\\r\n    ./editors/ComponentEditor/software/apiInterface/ApiInterfaceEditor.cpp \\\r\n    ./editors/ComponentEditor/software/apiInterface/apiinterfacesdelegate.cpp \\\r\n    ./editors/ComponentEditor/software/apiInterface/apiinterfaceseditor.cpp \\\r\n    ./editors/ComponentEditor/software/apiInterface/apiinterfacesmodel.cpp \\\r\n    ./editors/ComponentEditor/software/comInterface/ComInterfaceEditor.cpp \\\r\n    ./editors/ComponentEditor/software/comInterface/cominterfacesdelegate.cpp \\\r\n    ./editors/ComponentEditor/software/comInterface/cominterfaceseditor.cpp \\\r\n    ./editors/ComponentEditor/software/comInterface/cominterfacesmodel.cpp \\\r\n    ./editors/ComponentEditor/software/systemView/SystemViewEditor.cpp \\\r\n    ./editors/ComponentEditor/software/systemView/SystemViewsEditor.cpp \\\r\n    ./editors/ComponentEditor/software/systemView/SystemViewsModel.cpp \\\r\n    ./editors/ComponentEditor/addressSpaces/addressspaceeditor.cpp \\\r\n    ./editors/ComponentEditor/addressSpaces/addressspacegeneraleditor.cpp \\\r\n    ./editors/ComponentEditor/addressSpaces/addressspacesdelegate.cpp \\\r\n    ./editors/ComponentEditor/addressSpaces/addressspaceseditor.cpp \\\r\n    ./editors/ComponentEditor/addressSpaces/addressspacesmodel.cpp \\\r\n    ./editors/ComponentEditor/addressSpaces/SegmentDelegate.cpp \\\r\n    ./editors/ComponentEditor/addressSpaces/segmenteditor.cpp \\\r\n    ./editors/ComponentEditor/addressSpaces/segmentsmodel.cpp \\\r\n    ./editors/ComponentEditor/addressSpaces/localMemoryMap/localmemorymapeditor.cpp \\\r\n    ./editors/ComponentEditor/addressSpaces/localMemoryMap/localmemorymapgraphitem.cpp \\\r\n    ./editors/ComponentEditor/addressSpaces/addressSpaceVisualizer/AddressSpaceConflictedItem.cpp \\\r\n    ./editors/ComponentEditor/addressSpaces/addressSpaceVisualizer/addressspacegapitem.cpp \\\r\n    ./editors/ComponentEditor/addressSpaces/addressSpaceVisualizer/addressspacescene.cpp \\\r\n    ./editors/ComponentEditor/addressSpaces/addressSpaceVisualizer/addressspacevisualizationitem.cpp \\\r\n    ./editors/ComponentEditor/addressSpaces/addressSpaceVisualizer/addressspacevisualizer.cpp \\\r\n    ./editors/ComponentEditor/addressSpaces/addressSpaceVisualizer/localaddrblockgraphitem.cpp \\\r\n    ./editors/ComponentEditor/addressSpaces/addressSpaceVisualizer/segmentgraphitem.cpp \\\r\n    ./editors/ComponentEditor/cpus/CpuDetailsEditor.cpp \\\r\n    ./editors/ComponentEditor/cpus/cpusdelegate.cpp \\\r\n    ./editors/ComponentEditor/cpus/cpuseditor.cpp \\\r\n    ./editors/ComponentEditor/cpus/cpusmodel.cpp \\\r\n    ./editors/ComponentEditor/cpus/CpuVisualizer.cpp \\\r\n    ./editors/ComponentEditor/cpus/RegionScene.cpp \\\r\n    ./editors/ComponentEditor/cpus/RegionsDelegate.cpp \\\r\n    ./editors/ComponentEditor/cpus/RegionsEditor.cpp \\\r\n    ./editors/ComponentEditor/cpus/RegionsModel.cpp \\\r\n    ./editors/ComponentEditor/cpus/SingleCpuEditor.cpp \\\r\n    ./editors/ComponentEditor/memoryMaps/AccessPoliciesDelegate.cpp \\\r\n    ./editors/ComponentEditor/memoryMaps/AccessPoliciesEditor.cpp \\\r\n    ./editors/ComponentEditor/memoryMaps/AccessPoliciesModel.cpp \\\r\n    ./editors/ComponentEditor/memoryMaps/FieldAccessPoliciesDelegate.cpp \\\r\n    ./editors/ComponentEditor/memoryMaps/FieldAccessPoliciesEditor.cpp \\\r\n    ./editors/ComponentEditor/memoryMaps/FieldAccessPoliciesModel.cpp \\\r\n    ./editors/ComponentEditor/memoryMaps/addressblockdelegate.cpp \\\r\n    ./editors/ComponentEditor/memoryMaps/addressblockeditor.cpp \\\r\n    ./editors/ComponentEditor/memoryMaps/addressblockmodel.cpp \\\r\n    ./editors/ComponentEditor/memoryMaps/enumeratedvaluedelegate.cpp \\\r\n    ./editors/ComponentEditor/memoryMaps/enumeratedvaluemodel.cpp \\\r\n    ./editors/ComponentEditor/memoryMaps/ExpressionProxyModel.cpp \\\r\n    ./editors/ComponentEditor/memoryMaps/fieldeditor.cpp \\\r\n    ./editors/ComponentEditor/memoryMaps/MemoryBlockDelegate.cpp \\\r\n    ./editors/ComponentEditor/memoryMaps/MemoryBlockFilter.cpp \\\r\n    ./editors/ComponentEditor/memoryMaps/MemoryBlockModel.cpp \\\r\n    ./editors/ComponentEditor/memoryMaps/memorymapdelegate.cpp \\\r\n    ./editors/ComponentEditor/memoryMaps/memorymapeditor.cpp \\\r\n    ./editors/ComponentEditor/memoryMaps/memorymapmodel.cpp \\\r\n    ./editors/ComponentEditor/memoryMaps/memorymapsdelegate.cpp \\\r\n    ./editors/ComponentEditor/memoryMaps/memorymapseditor.cpp \\\r\n    ./editors/ComponentEditor/memoryMaps/memorymapsmodel.cpp \\\r\n    ./editors/ComponentEditor/memoryMaps/MemoryMapsView.cpp \\\r\n    ./editors/ComponentEditor/memoryMaps/registerdelegate.cpp \\\r\n    ./editors/ComponentEditor/memoryMaps/registereditor.cpp \\\r\n    ./editors/ComponentEditor/memoryMaps/registerfiledelegate.cpp \\\r\n    ./editors/ComponentEditor/memoryMaps/registerfileeditor.cpp \\\r\n    ./editors/ComponentEditor/memoryMaps/registerfilemodel.cpp \\\r\n    ./editors/ComponentEditor/memoryMaps/registertablemodel.cpp \\\r\n    ./editors/ComponentEditor/memoryMaps/RemapModeReferenceEditor.cpp \\\r\n    ./editors/ComponentEditor/memoryMaps/ResetsDelegate.cpp \\\r\n    ./editors/ComponentEditor/memoryMaps/ResetsEditor.cpp \\\r\n    ./editors/ComponentEditor/memoryMaps/ResetsModel.cpp \\\r\n    ./editors/ComponentEditor/memoryMaps/SingleAddressBlockEditor.cpp \\\r\n    ./editors/ComponentEditor/memoryMaps/SingleFieldEditor.cpp \\\r\n    ./editors/ComponentEditor/memoryMaps/SingleMemoryMapEditor.cpp \\\r\n    ./editors/ComponentEditor/memoryMaps/SingleRegisterEditor.cpp \\\r\n    ./editors/ComponentEditor/memoryMaps/SingleRegisterFileEditor.cpp \\\r\n    ./editors/ComponentEditor/memoryMaps/SingleSubspaceMapEditor.cpp \\\r\n    ./editors/ComponentEditor/memoryMaps/SubspaceMapDelegate.cpp \\\r\n    ./editors/ComponentEditor/memoryMaps/SubspaceMapModel.cpp \\\r\n    ./editors/ComponentEditor/memoryMaps/SubspaceMapsEditor.cpp \\\r\n    ./editors/ComponentEditor/memoryMaps/WriteValueConstraintComboBox.cpp \\\r\n    ./editors/ComponentEditor/memoryMaps/memoryMapsVisualizer/addressblockgraphitem.cpp \\\r\n    ./editors/ComponentEditor/memoryMaps/memoryMapsVisualizer/fieldgraphitem.cpp \\\r\n    ./editors/ComponentEditor/memoryMaps/memoryMapsVisualizer/MemoryBlockGraphItem.cpp \\\r\n    ./editors/ComponentEditor/memoryMaps/memoryMapsVisualizer/memorymapgraphitem.cpp \\\r\n    ./editors/ComponentEditor/memoryMaps/memoryMapsVisualizer/memorymapscene.cpp \\\r\n    ./editors/ComponentEditor/memoryMaps/memoryMapsVisualizer/memorymapsvisualizer.cpp \\\r\n    ./editors/ComponentEditor/memoryMaps/memoryMapsVisualizer/memorymapview.cpp \\\r\n    ./editors/ComponentEditor/memoryMaps/memoryMapsVisualizer/registerfilegraphitem.cpp \\\r\n    ./editors/ComponentEditor/memoryMaps/memoryMapsVisualizer/registergraphitem.cpp \\\r\n    ./editors/ComponentEditor/memoryMaps/memoryMapsVisualizer/SubspaceMapGraphItem.cpp \\\r\n    ./editors/ComponentEditor/memoryMaps/memoryMapsExpressionCalculators/ReferenceCalculator.cpp \\\r\n    ./editors/ComponentEditor/instantiations/DesignInstantiationsModel.cpp \\\r\n    ./editors/ComponentEditor/treeStructure/componenteditoraddrblockitem.cpp \\\r\n    ./editors/ComponentEditor/treeStructure/componenteditoraddrspaceitem.cpp \\\r\n    ./editors/ComponentEditor/treeStructure/componenteditoraddrspacesitem.cpp \\\r\n    ./editors/ComponentEditor/treeStructure/componenteditorapiinterfaceitem.cpp \\\r\n    ./editors/ComponentEditor/treeStructure/componenteditorapiinterfacesitem.cpp \\\r\n    ./editors/ComponentEditor/treeStructure/componenteditorbusinterfaceitem.cpp \\\r\n    ./editors/ComponentEditor/treeStructure/componenteditorbusinterfacesitem.cpp \\\r\n    ./editors/ComponentEditor/treeStructure/componenteditorchannelsitem.cpp \\\r\n    ./editors/ComponentEditor/treeStructure/ComponentEditorChoicesItem.cpp \\\r\n    ./editors/ComponentEditor/treeStructure/componenteditorcominterfaceitem.cpp \\\r\n    ./editors/ComponentEditor/treeStructure/componenteditorcominterfacesitem.cpp \\\r\n    ./editors/ComponentEditor/treeStructure/componenteditorcpusitem.cpp \\\r\n    ./editors/ComponentEditor/treeStructure/componenteditorfielditem.cpp \\\r\n    ./editors/ComponentEditor/treeStructure/componenteditorfileitem.cpp \\\r\n    ./editors/ComponentEditor/treeStructure/componenteditorfilesetitem.cpp \\\r\n    ./editors/ComponentEditor/treeStructure/componenteditorfilesetsitem.cpp \\\r\n    ./editors/ComponentEditor/treeStructure/componenteditorgeneralitem.cpp \\\r\n    ./editors/ComponentEditor/treeStructure/componenteditorgroupslot.cpp \\\r\n    ./editors/ComponentEditor/treeStructure/ComponentEditorIndirectInterfacesItem.cpp \\\r\n    ./editors/ComponentEditor/treeStructure/componenteditoritem.cpp \\\r\n    ./editors/ComponentEditor/treeStructure/componenteditormemmapitem.cpp \\\r\n    ./editors/ComponentEditor/treeStructure/componenteditormemmapsitem.cpp \\\r\n    ./editors/ComponentEditor/treeStructure/componenteditorotherclocksitem.cpp \\\r\n    ./editors/ComponentEditor/treeStructure/componenteditorparametersitem.cpp \\\r\n    ./editors/ComponentEditor/treeStructure/componenteditorportsitem.cpp \\\r\n    ./editors/ComponentEditor/treeStructure/componenteditorregisterfileitem.cpp \\\r\n    ./editors/ComponentEditor/treeStructure/componenteditorregisteritem.cpp \\\r\n    ./editors/ComponentEditor/treeStructure/componenteditorrootitem.cpp \\\r\n    ./editors/ComponentEditor/treeStructure/componenteditorswpropertiesitem.cpp \\\r\n    ./editors/ComponentEditor/treeStructure/ComponentEditorSystemViewItem.cpp \\\r\n    ./editors/ComponentEditor/treeStructure/ComponentEditorSystemViewsItem.cpp \\\r\n    ./editors/ComponentEditor/treeStructure/ComponentEditorTreeDelegate.cpp \\\r\n    ./editors/ComponentEditor/treeStructure/componenteditortreemodel.cpp \\\r\n    ./editors/ComponentEditor/treeStructure/ComponentEditorTreeSortProxyModel.cpp \\\r\n    ./editors/ComponentEditor/treeStructure/componenteditorviewitem.cpp \\\r\n    ./editors/ComponentEditor/treeStructure/componenteditorviewsitem.cpp \\\r\n    ./editors/ComponentEditor/treeStructure/ComponentInstantiationsItem.cpp \\\r\n    ./editors/ComponentEditor/treeStructure/componenttreeview.cpp \\\r\n    ./editors/ComponentEditor/treeStructure/DesignConfigurationInstantiationsItem.cpp \\\r\n    ./editors/ComponentEditor/treeStructure/DesignInstantiationsItem.cpp \\\r\n    ./editors/ComponentEditor/treeStructure/InstantiationsItem.cpp \\\r\n    ./editors/ComponentEditor/treeStructure/MemoryRemapItem.cpp \\\r\n    ./editors/ComponentEditor/treeStructure/ModesItem.cpp \\\r\n    ./editors/ComponentEditor/treeStructure/ParameterizableItem.cpp \\\r\n    ./editors/ComponentEditor/treeStructure/PowerDomainsItem.cpp \\\r\n    ./editors/ComponentEditor/treeStructure/RemapStatesItem.cpp \\\r\n    ./editors/ComponentEditor/treeStructure/ResetTypesItem.cpp \\\r\n    ./editors/ComponentEditor/treeStructure/SingleComponentInstantiationItem.cpp \\\r\n    ./editors/ComponentEditor/treeStructure/SingleCpuItem.cpp \\\r\n    ./editors/ComponentEditor/treeStructure/SingleDesignConfigurationInstantiationItem.cpp \\\r\n    ./editors/ComponentEditor/treeStructure/SingleDesignInstantiationItem.cpp \\\r\n    ./editors/ComponentEditor/treeStructure/SingleIndirectInterfaceItem.cpp \\\r\n    ./editors/ComponentEditor/treeStructure/SingleModeItem.cpp \\\r\n    ./editors/ComponentEditor/treeStructure/SingleRemapStateItem.cpp \\\r\n    ./editors/ComponentEditor/treeStructure/SubspaceMapItem.cpp \\\r\n    ./editors/ComponentEditor/treeStructure/TransactionalPortsItem.cpp \\\r\n    ./editors/ComponentEditor/treeStructure/TypeDefinitionsItem.cpp \\\r\n    ./editors/ComponentEditor/treeStructure/WirePortsItem.cpp \\\r\n    ./editors/ComponentEditor/visualization/AddressableItem.cpp \\\r\n    ./editors/ComponentEditor/visualization/fieldgapitem.cpp \\\r\n    ./editors/ComponentEditor/visualization/memorygapitem.cpp \\\r\n    ./editors/ComponentEditor/visualization/memoryvisualizationitem.cpp \\\r\n    ./editors/ComponentEditor/choices/ChoicesEditor.cpp \\\r\n    ./editors/ComponentEditor/choices/ChoicesModel.cpp \\\r\n    ./editors/ComponentEditor/choices/EnumerationModel.cpp \\\r\n    ./editors/ComponentEditor/common/AbstractParameterModel.cpp \\\r\n    ./editors/ComponentEditor/common/ConfigurableElementFinder.cpp \\\r\n    ./editors/ComponentEditor/common/DesignConfigurationInstantiationParameterFinder.cpp \\\r\n    ./editors/ComponentEditor/common/EnumerationEditorConstructorDelegate.cpp \\\r\n    ./editors/ComponentEditor/common/ExpressionDelegate.cpp \\\r\n    ./editors/ComponentEditor/common/ExpressionEditor.cpp \\\r\n    ./editors/ComponentEditor/common/ExpressionLineEditor.cpp \\\r\n    ./editors/ComponentEditor/common/FloatingModeReferenceEditor.cpp \\\r\n    ./editors/ComponentEditor/common/InstantiationConfigurableElementEditor.cpp \\\r\n    ./editors/ComponentEditor/common/MasterExpressionEditor.cpp \\\r\n    ./editors/ComponentEditor/common/MemoryAlignScene.cpp \\\r\n    ./editors/ComponentEditor/common/MemoryTreeFactory.cpp \\\r\n    ./editors/ComponentEditor/common/ModeReferenceDelegate.cpp \\\r\n    ./editors/ComponentEditor/common/ModeReferenceEditor.cpp \\\r\n    ./editors/ComponentEditor/common/ModeReferenceModel.cpp \\\r\n    ./editors/ComponentEditor/common/MultilineDescriptionDelegate.cpp \\\r\n    ./editors/ComponentEditor/common/ParameterizableTable.cpp \\\r\n    ./editors/ComponentEditor/common/ReferencingTableModel.cpp \\\r\n    ./editors/ComponentEditor/common/ReferenceSelector/ReferenceSelector.cpp \\\r\n    ./editors/ComponentEditor/referenceCounter/ComponentParameterReferenceCounter.cpp \\\r\n    ./editors/ComponentEditor/referenceCounter/ParameterReferenceCounter.cpp \\\r\n    ./editors/ComponentEditor/parameterReferenceTree/ComponentParameterReferenceTree.cpp \\\r\n    ./editors/ComponentEditor/parameterReferenceTree/ParameterReferenceTree.cpp \\\r\n    ./editors/ComponentEditor/parameterReferenceTree/ParameterReferenceTreeWindow.cpp \\\r\n    ./editors/ComponentEditor/remapStates/RemapConditionDelegate.cpp \\\r\n    ./editors/ComponentEditor/remapStates/RemapConditionEditor.cpp \\\r\n    ./editors/ComponentEditor/remapStates/RemapConditionModel.cpp \\\r\n    ./editors/ComponentEditor/remapStates/RemapStatesEditor.cpp \\\r\n    ./editors/ComponentEditor/remapStates/RemapStatesModel.cpp \\\r\n    ./editors/ComponentEditor/remapStates/SingleRemapStateEditor.cpp \\\r\n    ./editors/ComponentEditor/remapStates/ValueOrIndexedValueEditor.cpp \\\r\n    ./editors/ComponentEditor/instantiations/ComponentInstantiationDisplayer.cpp \\\r\n    ./editors/ComponentEditor/instantiations/ComponentInstantiationEditor.cpp \\\r\n    ./editors/ComponentEditor/instantiations/ComponentInstantiationsEditor.cpp \\\r\n    ./editors/ComponentEditor/instantiations/ComponentInstantiationsModel.cpp \\\r\n    ./editors/ComponentEditor/instantiations/DesignConfigurationInstantiationEditor.cpp \\\r\n    ./editors/ComponentEditor/instantiations/DesignConfigurationInstantiationsEditor.cpp \\\r\n    ./editors/ComponentEditor/instantiations/DesignConfigurationInstantiationsModel.cpp \\\r\n    ./editors/ComponentEditor/instantiations/DesignInstantiationEditor.cpp \\\r\n    ./editors/ComponentEditor/instantiations/DesignInstantiationsDelegate.cpp \\\r\n    ./editors/ComponentEditor/instantiations/DesignInstantiationsEditor.cpp \\\r\n    ./editors/ComponentEditor/instantiations/filesetrefeditor.cpp \\\r\n    ./editors/ComponentEditor/instantiations/filesetrefeditordelegate.cpp \\\r\n    ./editors/ComponentEditor/instantiations/filesetrefmodel.cpp \\\r\n    ./editors/ComponentEditor/instantiations/InstantiationsEditor.cpp \\\r\n    ./editors/ComponentEditor/instantiations/ModuleParameterDelegate.cpp \\\r\n    ./editors/ComponentEditor/instantiations/ModuleParameterEditor.cpp \\\r\n    ./editors/ComponentEditor/instantiations/ModuleParameterHeaderView.cpp \\\r\n    ./editors/ComponentEditor/instantiations/ModuleParameterModel.cpp \\\r\n    ./editors/ComponentEditor/otherClockDrivers/clockdriversdelegate.cpp \\\r\n    ./editors/ComponentEditor/otherClockDrivers/otherclockdriverseditor.cpp \\\r\n    ./editors/ComponentEditor/otherClockDrivers/otherclockdriversmodel.cpp \\\r\n    ./editors/ComponentEditor/indirectInterfaces/IndirectInterfacesDelegate.cpp \\\r\n    ./editors/ComponentEditor/indirectInterfaces/IndirectInterfacesEditor.cpp \\\r\n    ./editors/ComponentEditor/indirectInterfaces/IndirectInterfacesModel.cpp \\\r\n    ./editors/ComponentEditor/indirectInterfaces/SingleIndirectInterfaceEditor.cpp \\\r\n    ./editors/ComponentEditor/resetTypes/ResetTypesDelegate.cpp \\\r\n    ./editors/ComponentEditor/resetTypes/ResetTypesEditor.cpp \\\r\n    ./editors/ComponentEditor/resetTypes/ResetTypesModel.cpp \\\r\n    ./editors/ComponentEditor/modes/FieldSliceDelegate.cpp \\\r\n    ./editors/ComponentEditor/modes/FieldSliceEditor.cpp \\\r\n    ./editors/ComponentEditor/modes/FieldSliceModel.cpp \\\r\n    ./editors/ComponentEditor/modes/ModesEditor.cpp \\\r\n    ./editors/ComponentEditor/modes/ModesModel.cpp \\\r\n    ./editors/ComponentEditor/modes/PortSliceDelegate.cpp \\\r\n    ./editors/ComponentEditor/modes/PortSliceEditor.cpp \\\r\n    ./editors/ComponentEditor/modes/PortSliceModel.cpp \\\r\n    ./editors/ComponentEditor/modes/SingleModeEditor.cpp \\\r\n    ./editors/ComponentEditor/powerDomains/PowerDomainsDelegate.cpp \\\r\n    ./editors/ComponentEditor/powerDomains/PowerDomainsEditor.cpp \\\r\n    ./editors/ComponentEditor/powerDomains/PowerDomainsModel.cpp \\\r\n    ./editors/CSourceEditor/CSourceContentMatcher.cpp \\\r\n    ./editors/CSourceEditor/CSourceHighlight.cpp \\\r\n    ./editors/CSourceEditor/CSourceHighlighter.cpp \\\r\n    ./editors/CSourceEditor/CSourceTextEdit.cpp \\\r\n    ./editors/CSourceEditor/CSourceWidget.cpp \\\r\n    ./editors/ConfigurationTools/ViewConfigurer.cpp \\\r\n    ./editors/ConfigurationTools/ViewConfigurerDelegate.cpp \\\r\n    ./editors/BusDefinitionEditor/busdefgroup.cpp \\\r\n    ./editors/BusDefinitionEditor/BusDefinitionEditor.cpp \\\r\n    ./editors/BusDefinitionEditor/BusDefinitionParameterReferenceTree.cpp \\\r\n    ./editors/BusDefinitionEditor/SystemGroupListEditor.cpp \\\r\n    ./editors/CatalogEditor/CatalogEditor.cpp \\\r\n    ./editors/CatalogEditor/CatalogFileDelegate.cpp \\\r\n    ./editors/CatalogEditor/CatalogFileFilter.cpp \\\r\n    ./editors/CatalogEditor/CatalogFileModel.cpp \\\r\n    ./editors/CatalogEditor/CatalogFileView.cpp \\\r\n    ./editors/common/ComponentDesignDiagram.cpp \\\r\n    ./editors/common/DefaultRouting.cpp \\\r\n    ./editors/common/DesignCompletionModel.cpp \\\r\n    ./editors/common/DesignDiagram.cpp \\\r\n    ./editors/common/DesignDiagramResolver.cpp \\\r\n    ./editors/common/DesignWidget.cpp \\\r\n    ./editors/common/DesignWidgetFactoryImplementation.cpp \\\r\n    ./editors/common/DocumentNameGroupEditor.cpp \\\r\n    ./editors/common/GraphicsItemLabel.cpp \\\r\n    ./editors/common/ImageExporter.cpp \\\r\n    ./editors/common/NamelabelWidth.cpp \\\r\n    ./editors/common/PortUtilities.cpp \\\r\n    ./editors/common/TopComponentParameterFinder.cpp \\\r\n    ./editors/common/Association/Associable.cpp \\\r\n    ./editors/common/Association/Association.cpp \\\r\n    ./editors/common/Association/AssociationAddCommand.cpp \\\r\n    ./editors/common/Association/AssociationChangeEndpointCommand.cpp \\\r\n    ./editors/common/Association/AssociationRemoveCommand.cpp \\\r\n    ./editors/common/ComponentInstanceEditor/ComponentInstanceConfigurableElementsEditor.cpp \\\r\n    ./editors/common/ComponentInstanceEditor/ComponentInstanceConfigurableElementsFilter.cpp \\\r\n    ./editors/common/ComponentInstanceEditor/ComponentInstanceConfigurableElementsModel.cpp \\\r\n    ./editors/common/ComponentInstanceEditor/componentinstanceeditor.cpp \\\r\n    ./editors/common/ComponentInstanceEditor/configurableelementdelegate.cpp \\\r\n    ./editors/common/ComponentInstanceEditor/configurableelementeditor.cpp \\\r\n    ./editors/common/ComponentInstanceEditor/ConfigurableElementsFilter.cpp \\\r\n    ./editors/common/ComponentInstanceEditor/ConfigurableElementsModel.cpp \\\r\n    ./editors/common/ComponentInstanceEditor/ConfigurableElementsView.cpp \\\r\n    ./editors/common/ComponentInstanceEditor/EditorConfigurableElement.cpp \\\r\n    ./editors/common/ComponentInstanceEditor/MissingConfigurableElementsFilter.cpp \\\r\n    ./editors/common/ComponentInstanceEditor/ParameterConfigurableElementsFilter.cpp \\\r\n    ./editors/common/ComponentInstanceEditor/PowerDomainLinkDelegate.cpp \\\r\n    ./editors/common/ComponentInstanceEditor/PowerDomainLinkEditor.cpp \\\r\n    ./editors/common/ComponentInstanceEditor/PowerDomainLinkModel.cpp \\\r\n    ./editors/common/ConfigurationEditor/activeviewdelegate.cpp \\\r\n    ./editors/common/ConfigurationEditor/activevieweditor.cpp \\\r\n    ./editors/common/ConfigurationEditor/activeviewmodel.cpp \\\r\n    ./editors/common/ConfigurationEditor/configurationeditor.cpp \\\r\n    ./editors/common/ConnectionEditor/AdHocBoundsModel.cpp \\\r\n    ./editors/common/ConnectionEditor/connectioneditor.cpp \\\r\n    ./editors/common/DesignParameterReferenceTree/DesignParameterReferenceCounter.cpp \\\r\n    ./editors/common/DesignParameterReferenceTree/DesignParameterReferenceTree.cpp \\\r\n    ./editors/common/InterfaceEditor/interfaceeditor.cpp \\\r\n    ./editors/common/InterfaceEditor/InterfacePortMapDelegate.cpp \\\r\n    ./editors/common/InterfaceEditor/InterfacePortMapModel.cpp \\\r\n    ./editors/common/StickyNote/ColorFillTextItem.cpp \\\r\n    ./editors/common/StickyNote/StickyNote.cpp \\\r\n    ./editors/common/StickyNote/StickyNoteAddCommand.cpp \\\r\n    ./editors/common/StickyNote/StickyNoteEditCommand.cpp \\\r\n    ./editors/common/StickyNote/StickyNoteMoveCommand.cpp \\\r\n    ./editors/common/StickyNote/StickyNoteRemoveCommand.cpp \\\r\n    ./editors/common/ComponentItemAutoConnector/AutoConnector.cpp \\\r\n    ./editors/common/ComponentItemAutoConnector/AutoConnectorConnectionDelegate.cpp \\\r\n    ./editors/common/ComponentItemAutoConnector/AutoConnectorConnectionTable.cpp \\\r\n    ./editors/common/ComponentItemAutoConnector/AutoConnectorItem.cpp \\\r\n    ./editors/common/ComponentItemAutoConnector/AutoConnectorListFilter.cpp \\\r\n    ./editors/common/ComponentItemAutoConnector/BusInterfaceItemMatcher.cpp \\\r\n    ./editors/common/ComponentItemAutoConnector/BusInterfaceListFiller.cpp \\\r\n    ./editors/common/ComponentItemAutoConnector/BusInterfaceTableAutoConnector.cpp \\\r\n    ./editors/common/ComponentItemAutoConnector/ComponentItemAutoConnector.cpp \\\r\n    ./editors/common/ComponentItemAutoConnector/HierarchicalBusInterfaceItemMatcher.cpp \\\r\n    ./editors/common/ComponentItemAutoConnector/HierarchicalBusInterfaceTableAutoConnector.cpp \\\r\n    ./editors/common/ComponentItemAutoConnector/HierarchicalPortItemMatcher.cpp \\\r\n    ./editors/common/ComponentItemAutoConnector/HierarchicalPortTableAutoConnector.cpp \\\r\n    ./editors/common/ComponentItemAutoConnector/PortItemMatcher.cpp \\\r\n    ./editors/common/ComponentItemAutoConnector/PortListFiller.cpp \\\r\n    ./editors/common/ComponentItemAutoConnector/PortTableAutoConnector.cpp \\\r\n    ./editors/common/ComponentItemAutoConnector/TableAutoConnector.cpp \\\r\n    ./editors/common/ComponentItemAutoConnector/TableItemMatcher.cpp \\\r\n    ./editors/HWDesign/ActiveBusInterfaceItem.cpp \\\r\n    ./editors/HWDesign/ActivePortItem.cpp \\\r\n    ./editors/HWDesign/AdHocConnectionItem.cpp \\\r\n    ./editors/HWDesign/AdHocEnabled.cpp \\\r\n    ./editors/HWDesign/AdHocItem.cpp \\\r\n    ./editors/HWDesign/BusInterfaceDialog.cpp \\\r\n    ./editors/HWDesign/BusInterfaceEndPoint.cpp \\\r\n    ./editors/HWDesign/HierarchicalBusInterfaceItem.cpp \\\r\n    ./editors/HWDesign/HierarchicalPortItem.cpp \\\r\n    ./editors/HWDesign/HWAddCommands.cpp \\\r\n    ./editors/HWDesign/HWChangeCommands.cpp \\\r\n    ./editors/HWDesign/HWComponentItem.cpp \\\r\n    ./editors/HWDesign/HWConnection.cpp \\\r\n    ./editors/HWDesign/HWConnectionEndPoint.cpp \\\r\n    ./editors/HWDesign/HWDesignDiagram.cpp \\\r\n    ./editors/HWDesign/HWDesignWidget.cpp \\\r\n    ./editors/HWDesign/HWMoveCommands.cpp \\\r\n    ./editors/HWDesign/OffPageConnectorItem.cpp \\\r\n    ./editors/HWDesign/PortmapDialog.cpp \\\r\n    ./editors/HWDesign/SelectItemTypeDialog.cpp \\\r\n    ./editors/HWDesign/WarningSymbol.cpp \\\r\n    ./editors/HWDesign/columnview/ColumnEditDialog.cpp \\\r\n    ./editors/HWDesign/columnview/HWColumn.cpp \\\r\n    ./editors/HWDesign/AdhocEditor/AdhocEditor.cpp \\\r\n    ./editors/HWDesign/AdhocEditor/AdhocPortEditor.cpp \\\r\n    ./editors/HWDesign/AdhocEditor/AdHocVisibilityDelegate.cpp \\\r\n    ./editors/HWDesign/AdhocEditor/AdHocVisibilityEditor.cpp \\\r\n    ./editors/HWDesign/AdhocEditor/AdHocVisibilityModel.cpp \\\r\n    ./editors/HWDesign/AdhocEditor/AdHocVisibilityPolicy.cpp \\\r\n    ./editors/HWDesign/undoCommands/AdHocBoundsChangeCommand.cpp \\\r\n    ./editors/HWDesign/undoCommands/AdHocConnectionAddCommand.cpp \\\r\n    ./editors/HWDesign/undoCommands/AdHocConnectionDeleteCommand.cpp \\\r\n    ./editors/HWDesign/undoCommands/AdHocTiedValueCommand.cpp \\\r\n    ./editors/HWDesign/undoCommands/AdHocTieOffBoundsChangeCommand.cpp \\\r\n    ./editors/HWDesign/undoCommands/AdHocTieOffChangeCommand.cpp \\\r\n    ./editors/HWDesign/undoCommands/AdHocTieOffConnectionDeleteCommand.cpp \\\r\n    ./editors/HWDesign/undoCommands/AdHocVisibilityChangeCommand.cpp \\\r\n    ./editors/HWDesign/undoCommands/ColumnDeleteCommand.cpp \\\r\n    ./editors/HWDesign/undoCommands/ComponentDeleteCommand.cpp \\\r\n    ./editors/HWDesign/undoCommands/ComponentInstancePasteCommand.cpp \\\r\n    ./editors/HWDesign/undoCommands/ComponentItemMoveCommand.cpp \\\r\n    ./editors/HWDesign/undoCommands/ConfigurableElementChangeCommand.cpp \\\r\n    ./editors/HWDesign/undoCommands/ConfigurableElementRemoveCommand.cpp \\\r\n    ./editors/HWDesign/undoCommands/ConnectionDeleteCommand.cpp \\\r\n    ./editors/HWDesign/undoCommands/HWColumnAddCommand.cpp \\\r\n    ./editors/HWDesign/undoCommands/HWComponentAddCommand.cpp \\\r\n    ./editors/HWDesign/undoCommands/InterfaceDeleteCommand.cpp \\\r\n    ./editors/HWDesign/undoCommands/PhysicalPortDeleteCommand.cpp \\\r\n    ./editors/HWDesign/undoCommands/PortDeleteCommand.cpp \\\r\n    ./editors/HWDesign/undoCommands/PortPasteCommand.cpp \\\r\n    ./editors/HWDesign/undoCommands/ReplaceComponentCommand.cpp \\\r\n    ./editors/HWDesign/undoCommands/TopAdHocVisibilityChangeCommand.cpp \\\r\n    ./editors/MemoryDesigner/AddressBlockGraphicsItem.cpp \\\r\n    ./editors/MemoryDesigner/AddressSegmentGraphicsItem.cpp \\\r\n    ./editors/MemoryDesigner/AddressSpaceGraphicsItem.cpp \\\r\n    ./editors/MemoryDesigner/ConnectivityComponent.cpp \\\r\n    ./editors/MemoryDesigner/ConnectivityConnection.cpp \\\r\n    ./editors/MemoryDesigner/ConnectivityGraph.cpp \\\r\n    ./editors/MemoryDesigner/ConnectivityGraphFactory.cpp \\\r\n    ./editors/MemoryDesigner/ConnectivityInterface.cpp \\\r\n    ./editors/MemoryDesigner/FieldGraphicsItem.cpp \\\r\n    ./editors/MemoryDesigner/FieldOverlapItem.cpp \\\r\n    ./editors/MemoryDesigner/MainMemoryGraphicsItem.cpp \\\r\n    ./editors/MemoryDesigner/MasterSlavePathSearch.cpp \\\r\n    ./editors/MemoryDesigner/MemoryCollisionItem.cpp \\\r\n    ./editors/MemoryDesigner/MemoryColumn.cpp \\\r\n    ./editors/MemoryDesigner/MemoryColumnHandler.cpp \\\r\n    ./editors/MemoryDesigner/MemoryConnectionAddressCalculator.cpp \\\r\n    ./editors/MemoryDesigner/MemoryConnectionHandler.cpp \\\r\n    ./editors/MemoryDesigner/MemoryConnectionItem.cpp \\\r\n    ./editors/MemoryDesigner/MemoryDesignConstructor.cpp \\\r\n    ./editors/MemoryDesigner/MemoryDesignDocument.cpp \\\r\n    ./editors/MemoryDesigner/MemoryDesignerChildGraphicsItem.cpp \\\r\n    ./editors/MemoryDesigner/MemoryDesignerConstants.cpp \\\r\n    ./editors/MemoryDesigner/MemoryDesignerDiagram.cpp \\\r\n    ./editors/MemoryDesigner/MemoryDesignerGraphicsItem.cpp \\\r\n    ./editors/MemoryDesigner/MemoryExtensionGraphicsItem.cpp \\\r\n    ./editors/MemoryDesigner/MemoryGraphicsItemHandler.cpp \\\r\n    ./editors/MemoryDesigner/MemoryItem.cpp \\\r\n    ./editors/MemoryDesigner/MemoryMapGraphicsItem.cpp \\\r\n    ./editors/MemoryDesigner/RegisterGraphicsItem.cpp \\\r\n    ./editors/MemoryDesigner/SubMemoryLayout.cpp \\\r\n    ./editors/SystemDesign/ApiGraphicsConnection.cpp \\\r\n    ./editors/SystemDesign/ComGraphicsConnection.cpp \\\r\n    ./editors/SystemDesign/HWMappingItem.cpp \\\r\n    ./editors/SystemDesign/SWComponentItem.cpp \\\r\n    ./editors/SystemDesign/SWConnectionEndpoint.cpp \\\r\n    ./editors/SystemDesign/SWInterfaceItem.cpp \\\r\n    ./editors/SystemDesign/SWPortItem.cpp \\\r\n    ./editors/SystemDesign/SystemColumn.cpp \\\r\n    ./editors/SystemDesign/SystemComponentItem.cpp \\\r\n    ./editors/SystemDesign/SystemDesignDiagram.cpp \\\r\n    ./editors/SystemDesign/SystemDesignWidget.cpp \\\r\n    ./editors/SystemDesign/SystemDetailsEditor/ExportSWDialog.cpp \\\r\n    ./editors/SystemDesign/SystemDetailsEditor/SwitchHWDialog.cpp \\\r\n    ./editors/SystemDesign/SystemDetailsEditor/SystemDetailsEditor.cpp \\\r\n    ./editors/SystemDesign/UndoCommands/ApiConnectionAddCommand.cpp \\\r\n    ./editors/SystemDesign/UndoCommands/ApiConnectionDeleteCommand.cpp \\\r\n    ./editors/SystemDesign/UndoCommands/ApiConnectionExchangeCommand.cpp \\\r\n    ./editors/SystemDesign/UndoCommands/ComConnectionAddCommand.cpp \\\r\n    ./editors/SystemDesign/UndoCommands/ComConnectionDeleteCommand.cpp \\\r\n    ./editors/SystemDesign/UndoCommands/ComConnectionExchangeCommand.cpp \\\r\n    ./editors/SystemDesign/UndoCommands/ReplaceSystemComponentCommand.cpp \\\r\n    ./editors/SystemDesign/UndoCommands/SWInterfaceAddCommand.cpp \\\r\n    ./editors/SystemDesign/UndoCommands/SWInterfaceDeleteCommand.cpp \\\r\n    ./editors/SystemDesign/UndoCommands/SWInterfaceMoveCommand.cpp \\\r\n    ./editors/SystemDesign/UndoCommands/SWPortDeleteCommand.cpp \\\r\n    ./editors/SystemDesign/UndoCommands/SystemAddCommands.cpp \\\r\n    ./editors/SystemDesign/UndoCommands/SystemChangeCommands.cpp \\\r\n    ./editors/SystemDesign/UndoCommands/SystemComponentAddCommand.cpp \\\r\n    ./editors/SystemDesign/UndoCommands/SystemComponentDeleteCommand.cpp \\\r\n    ./editors/SystemDesign/UndoCommands/SystemDeleteCommands.cpp \\\r\n    ./editors/SystemDesign/UndoCommands/SystemMoveCommands.cpp \\\r\n    ./editors/common/VendorExtensionEditor/VendorExtensionsDelegate.cpp \\\r\n    ./editors/common/VendorExtensionEditor/VendorExtensionsEditor.cpp \\\r\n    ./editors/common/VendorExtensionEditor/VendorExtensionsFilter.cpp \\\r\n    ./editors/common/VendorExtensionEditor/VendorExtensionsModel.cpp \\\r\n    ./editors/common/VendorExtensionEditor/VendorExtensionAttributesEditor/VendorExtensionAttributesModel.cpp \\\r\n    ./editors/PythonSourceEditor/PythonSourceEditor.cpp \\\r\n    ./editors/PythonSourceEditor/PythonSourceHighlight.cpp \\\r\n    ./editors/PythonSourceEditor/ScriptingSideArea.cpp \\\r\n    ./editors/PythonSourceEditor/ScriptInputEditor.cpp \\\r\n    ./editors/PythonSourceEditor/ScriptViewEditor.cpp \\\r\n    ./editors/AbstractionDefinitionEditor/absdefgroup.cpp \\\r\n    ./editors/AbstractionDefinitionEditor/AbsDefParameterReferenceCounter.cpp \\\r\n    ./editors/AbstractionDefinitionEditor/AbsDefParameterReferenceTree.cpp \\\r\n    ./editors/AbstractionDefinitionEditor/AbstractionDefinitionEditor.cpp \\\r\n    ./editors/AbstractionDefinitionEditor/AbstractionDefinitionPortsSortFilter.cpp \\\r\n    ./editors/AbstractionDefinitionEditor/AbstractionDefinitionSignalRow.cpp \\\r\n    ./editors/AbstractionDefinitionEditor/AbstractionPortsDelegate.cpp \\\r\n    ./editors/AbstractionDefinitionEditor/AbstractionPortsEditor.cpp \\\r\n    ./editors/AbstractionDefinitionEditor/AbstractionPortsModel.cpp \\\r\n    ./editors/AbstractionDefinitionEditor/AbstractionPortsView.cpp \\\r\n    ./editors/AbstractionDefinitionEditor/AbstractionTransactionalPortsDelegate.cpp \\\r\n    ./editors/AbstractionDefinitionEditor/AbstractionTransactionalPortsSortFilter.cpp \\\r\n    ./editors/AbstractionDefinitionEditor/AbstractionWirePortsDelegate.cpp \\\r\n    ./editors/AbstractionDefinitionEditor/AbstractionWirePortsSortFilter.cpp \\\r\n    ./editors/AbstractionDefinitionEditor/QualifierEditor.cpp \\\r\n    ./editors/InterconnectGenerator/InstanceInterfacesEditor.cpp \\\r\n    ./editors/InterconnectGenerator/InterconnectAddressHelper.cpp \\\r\n    ./editors/InterconnectGenerator/InterconnectDataModel.cpp \\\r\n    ./editors/InterconnectGenerator/InterconnectGeneratorDialog.cpp \\\r\n    ./kactusGenerators/DocumentGenerator/DocumentationWriter.cpp \\\r\n    ./kactusGenerators/DocumentGenerator/documentgenerator.cpp \\\r\n    ./kactusGenerators/DocumentGenerator/HtmlWriter.cpp \\\r\n    ./kactusGenerators/DocumentGenerator/MarkdownWriter.cpp \\\r\n    ./PythonAPI/ChannelRelay.cpp \\\r\n    ./PythonAPI/FileChannel.cpp \\\r\n    ./PythonAPI/PythonInterpreter.cpp \\\r\n    ./PythonAPI/StdInputListener.cpp \\\r\n    ./PythonAPI/extensions/IOCatcher.cpp \\\r\n    ./editors/ComponentEditor/ports/PortsImportSummaryEditor.cpp\r\nRESOURCES += kactus.qrc\r\n"
  },
  {
    "path": "Kactus2.pro",
    "content": "# ----------------------------------------------------\r\n# This file is generated by the Qt Visual Studio Add-in.\r\n# ------------------------------------------------------\r\n\r\nTEMPLATE = app\r\n\r\nQT += core xml widgets gui printsupport help svg\r\nCONFIG += c++17\r\n\r\nDEFINES += _WINDOWS QT_DLL QT_HAVE_MMX QT_HAVE_3DNOW QT_HAVE_SSE QT_HAVE_MMXEXT QT_HAVE_SSE2\r\n\r\nINCLUDEPATH += . \\\r\n    ./GeneratedFiles \\\r\n    ./KactusAPI/include\r\n\r\nLIBS += $$PYTHON_LIBS\r\n\r\nQMAKE_CXXFLAGS += $$PYTHON_C_FLAGS\r\n\r\nDESTDIR = ./executable\r\nDEPENDPATH += .\r\n\r\nCONFIG(debug, debug|release) {\r\n    # debug mode\r\n    LIBS += -L\"./executable\" \\\r\n        -lIPXACTmodelsd \\\r\n        -L\"./executable\" \\\r\n        -lKactusAPId\r\n\r\n    MOC_DIR += ./GeneratedFiles/Debug\r\n    OBJECTS_DIR += Debug\r\n    TARGET = kactus2d\r\n\r\n} else {\r\n    # release mode \r\n    LIBS += -L\"./executable\" \\\r\n        -lIPXACTmodels \\\r\n        -L\"./executable\" \\\r\n        -lKactusAPI\r\n\r\n    MOC_DIR += ./GeneratedFiles/Release\r\n    OBJECTS_DIR += Release\r\n    TARGET = kactus2\r\n}\r\n\r\nUI_DIR += ./GeneratedFiles\r\nRCC_DIR += ./GeneratedFiles\r\n\r\ninclude(Kactus2.pri)\r\n\r\nlinux-g++*:QMAKE_CXXFLAGS += -fPIE\r\nlinux-g++*:LIBS += -pie -rdynamic\r\nunix:QMAKE_POST_LINK = ./createhelp\r\n\r\nwin32:RC_FILE = Kactus2.rc\r\n\r\nconfig.files = ./Administrative/releaseFiles/Kactus2.ini\r\n\r\n# bin_path and other install targets set in .qmake.conf\r\ntarget.path = $$bin_path\r\n\r\nINSTALLS += target help doc upgrade config library icons desktop\r\n\r\n"
  },
  {
    "path": "Kactus2.rc",
    "content": "// Microsoft Visual C++ generated resource script.\r\n//\r\n#include \"resource.h\"\r\n\r\n#define APSTUDIO_READONLY_SYMBOLS\r\n/////////////////////////////////////////////////////////////////////////////\r\n//\r\n// Generated from the TEXTINCLUDE 2 resource.\r\n//\r\n#include \"afxres.h\"\r\n\r\n/////////////////////////////////////////////////////////////////////////////\r\n#undef APSTUDIO_READONLY_SYMBOLS\r\n\r\n/////////////////////////////////////////////////////////////////////////////\r\n// English (United States) resources\r\n\r\n#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)\r\nLANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US\r\n#pragma code_page(1252)\r\n\r\n#ifdef APSTUDIO_INVOKED\r\n/////////////////////////////////////////////////////////////////////////////\r\n//\r\n// TEXTINCLUDE\r\n//\r\n\r\n1 TEXTINCLUDE \r\nBEGIN\r\n    \"resource.h\\0\"\r\nEND\r\n\r\n2 TEXTINCLUDE \r\nBEGIN\r\n    \"#include \"\"afxres.h\"\"\\r\\n\"\r\n    \"\\0\"\r\nEND\r\n\r\n3 TEXTINCLUDE \r\nBEGIN\r\n    \"\\r\\n\"\r\n    \"\\0\"\r\nEND\r\n\r\n#endif    // APSTUDIO_INVOKED\r\n\r\n#endif    // English (United States) resources\r\n/////////////////////////////////////////////////////////////////////////////\r\n\r\n\r\n/////////////////////////////////////////////////////////////////////////////\r\n// Finnish (Finland) resources\r\n\r\n#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_FIN)\r\nLANGUAGE LANG_FINNISH, SUBLANG_DEFAULT\r\n#pragma code_page(1252)\r\n\r\n/////////////////////////////////////////////////////////////////////////////\r\n//\r\n// Icon\r\n//\r\n\r\n// Icon with lowest ID value placed first to ensure application icon\r\n// remains consistent on all systems.\r\nIDI_ICON1               ICON                    \"appicon.ico\"\r\n#endif    // Finnish (Finland) resources\r\n/////////////////////////////////////////////////////////////////////////////\r\n\r\n\r\n\r\n#ifndef APSTUDIO_INVOKED\r\n/////////////////////////////////////////////////////////////////////////////\r\n//\r\n// Generated from the TEXTINCLUDE 3 resource.\r\n//\r\n\r\n\r\n/////////////////////////////////////////////////////////////////////////////\r\n#endif    // not APSTUDIO_INVOKED\r\n\r\n"
  },
  {
    "path": "Kactus2.vcxproj",
    "content": "﻿<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n<Project DefaultTargets=\"Build\" ToolsVersion=\"15.0\" xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">\r\n  <ItemGroup Label=\"ProjectConfigurations\">\r\n    <ProjectConfiguration Include=\"Debug|x64\">\r\n      <Configuration>Debug</Configuration>\r\n      <Platform>x64</Platform>\r\n    </ProjectConfiguration>\r\n    <ProjectConfiguration Include=\"Release|x64\">\r\n      <Configuration>Release</Configuration>\r\n      <Platform>x64</Platform>\r\n    </ProjectConfiguration>\r\n    <ProjectConfiguration Include=\"Template|x64\">\r\n      <Configuration>Template</Configuration>\r\n      <Platform>x64</Platform>\r\n    </ProjectConfiguration>\r\n  </ItemGroup>\r\n  <PropertyGroup Label=\"Globals\">\r\n    <ProjectGuid>{09486B51-70A7-3073-B15B-6D4BAF3EC8C6}</ProjectGuid>\r\n    <RootNamespace>Kactus2</RootNamespace>\r\n    <Keyword>QtVS_v304</Keyword>\r\n    <WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>\r\n    <QtMsBuild Condition=\"'$(QtMsBuild)'=='' or !Exists('$(QtMsBuild)\\qt.targets')\">$(MSBuildProjectDirectory)\\QtMsBuild</QtMsBuild>\r\n  </PropertyGroup>\r\n  <Import Project=\"$(VCTargetsPath)\\Microsoft.Cpp.Default.props\" />\r\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Template|x64'\" Label=\"Configuration\">\r\n    <ConfigurationType>Application</ConfigurationType>\r\n    <PlatformToolset>v143</PlatformToolset>\r\n  </PropertyGroup>\r\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\" Label=\"Configuration\">\r\n    <ConfigurationType>Application</ConfigurationType>\r\n    <UseOfMfc>false</UseOfMfc>\r\n    <PlatformToolset>v143</PlatformToolset>\r\n  </PropertyGroup>\r\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\" Label=\"Configuration\">\r\n    <ConfigurationType>Application</ConfigurationType>\r\n    <UseOfMfc>false</UseOfMfc>\r\n    <PlatformToolset>v143</PlatformToolset>\r\n  </PropertyGroup>\r\n  <Import Project=\"$(VCTargetsPath)\\Microsoft.Cpp.props\" />\r\n  <Target Name=\"QtMsBuildNotFound\" BeforeTargets=\"CustomBuild;ClCompile\" Condition=\"!Exists('$(QtMsBuild)\\qt.targets') or !Exists('$(QtMsBuild)\\qt.props')\">\r\n    <Message Importance=\"High\" Text=\"QtMsBuild: could not locate qt.targets, qt.props; project may not build correctly.\" />\r\n  </Target>\r\n  <ImportGroup Label=\"ExtensionSettings\">\r\n  </ImportGroup>\r\n  <ImportGroup Condition=\"'$(Configuration)|$(Platform)'=='Template|x64'\" Label=\"PropertySheets\">\r\n    <Import Project=\"$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props\" Condition=\"exists('$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props')\" Label=\"LocalAppDataPlatform\" />\r\n  </ImportGroup>\r\n  <ImportGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\" Label=\"PropertySheets\">\r\n    <Import Project=\"$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props\" Condition=\"exists('$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props')\" Label=\"LocalAppDataPlatform\" />\r\n  </ImportGroup>\r\n  <ImportGroup Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\" Label=\"PropertySheets\">\r\n    <Import Project=\"$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props\" Condition=\"exists('$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props')\" Label=\"LocalAppDataPlatform\" />\r\n  </ImportGroup>\r\n  <PropertyGroup Label=\"UserMacros\" />\r\n  <ImportGroup Condition=\"Exists('$(QtMsBuild)\\qt_defaults.props')\">\r\n    <Import Project=\"$(QtMsBuild)\\qt_defaults.props\" />\r\n  </ImportGroup>\r\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Template|x64'\">\r\n    <OutDir>$(SolutionDir)executable\\</OutDir>\r\n    <IntDir>$(Platform)\\$(Configuration)\\</IntDir>\r\n  </PropertyGroup>\r\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n    <OutDir>$(SolutionDir)executable\\</OutDir>\r\n    <IntDir>$(ProjectDir)\\$(Platform)\\$(Configuration)\\</IntDir>\r\n    <IgnoreImportLibrary>true</IgnoreImportLibrary>\r\n    <LinkIncremental>false</LinkIncremental>\r\n  </PropertyGroup>\r\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n    <OutDir>$(SolutionDir)executable\\</OutDir>\r\n    <IntDir>$(ProjectDir)\\$(Platform)\\$(Configuration)\\</IntDir>\r\n    <IgnoreImportLibrary>true</IgnoreImportLibrary>\r\n    <TargetName>$(ProjectName)_d</TargetName>\r\n  </PropertyGroup>\r\n  <PropertyGroup Label=\"QtSettings\" Condition=\"'$(Configuration)|$(Platform)'=='Template|x64'\">\r\n    <QtInstall>6.2.4</QtInstall>\r\n    <QtModules>core;gui;widgets;help;printsupport;svg;xml</QtModules>\r\n  </PropertyGroup>\r\n  <PropertyGroup Label=\"QtSettings\" Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n    <QtInstall>6.2.4</QtInstall>\r\n    <QtModules>core;gui;widgets;help;printsupport;svg;xml</QtModules>\r\n  </PropertyGroup>\r\n  <PropertyGroup Label=\"QtSettings\" Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n    <QtInstall>6.2.4</QtInstall>\r\n    <QtModules>core;gui;widgets;help;printsupport;svg;xml</QtModules>\r\n  </PropertyGroup>\r\n  <ImportGroup Condition=\"Exists('$(QtMsBuild)\\qt.props')\">\r\n    <Import Project=\"$(QtMsBuild)\\qt.props\" />\r\n  </ImportGroup>\r\n  <PropertyGroup>\r\n    <_ProjectFileVersion>10.0.40219.1</_ProjectFileVersion>\r\n  </PropertyGroup>\r\n  <ItemDefinitionGroup Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n    <PreBuildEvent>\r\n      <Command>\r\n      </Command>\r\n    </PreBuildEvent>\r\n    <Midl>\r\n      <WarningLevel>0</WarningLevel>\r\n      <DefaultCharType>Unsigned</DefaultCharType>\r\n      <TargetEnvironment>X64</TargetEnvironment>\r\n      <EnableErrorChecks>None</EnableErrorChecks>\r\n    </Midl>\r\n    <ClCompile>\r\n      <AdditionalOptions>-Zm200 -w34100 -w34189 /MP /Zc:__cplusplus %(AdditionalOptions)</AdditionalOptions>\r\n      <Optimization>Disabled</Optimization>\r\n      <AdditionalIncludeDirectories>.\\GeneratedFiles\\$(ConfigurationName);.\\GeneratedFiles;.;$(PYTHON_DIR)\\include;$(SolutionDir)KactusAPI/include/;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\r\n      <PreprocessorDefinitions>_DEBUG;_WINDOWS;UNICODE;WIN32;QT_XMLPATTERNS_LIB;QT_HAVE_MMX;QT_HAVE_3DNOW;QT_HAVE_SSE;QT_HAVE_MMXEXT;QT_HAVE_SSE2;QT_THREAD_SUPPORT;%(PreprocessorDefinitions)</PreprocessorDefinitions>\r\n      <PreprocessToFile>false</PreprocessToFile>\r\n      <PreprocessSuppressLineNumbers>false</PreprocessSuppressLineNumbers>\r\n      <ExceptionHandling>Sync</ExceptionHandling>\r\n      <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>\r\n      <BufferSecurityCheck>false</BufferSecurityCheck>\r\n      <DisableLanguageExtensions>false</DisableLanguageExtensions>\r\n      <TreatWChar_tAsBuiltInType>true</TreatWChar_tAsBuiltInType>\r\n      <RuntimeTypeInfo>true</RuntimeTypeInfo>\r\n      <AssemblerListingLocation>x64\\debug\\</AssemblerListingLocation>\r\n      <ObjectFileName>x64\\debug\\</ObjectFileName>\r\n      <ProgramDataBaseFileName>.\\x64\\</ProgramDataBaseFileName>\r\n      <WarningLevel>Level3</WarningLevel>\r\n      <SuppressStartupBanner>true</SuppressStartupBanner>\r\n      <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>\r\n      <ShowIncludes>false</ShowIncludes>\r\n      <LanguageStandard>stdcpp17</LanguageStandard>\r\n      <MultiProcessorCompilation>true</MultiProcessorCompilation>\r\n    </ClCompile>\r\n    <ResourceCompile>\r\n      <PreprocessorDefinitions>_WINDOWS;UNICODE;WIN32;QT_LARGEFILE_SUPPORT;QT_DLL;QT_XMLPATTERNS_LIB;QT_XML_LIB;QT_GUI_LIB;QT_CORE_LIB;QT_HAVE_MMX;QT_HAVE_3DNOW;QT_HAVE_SSE;QT_HAVE_MMXEXT;QT_HAVE_SSE2;QT_THREAD_SUPPORT;_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>\r\n    </ResourceCompile>\r\n    <PreLinkEvent>\r\n      <Command>\r\n      </Command>\r\n    </PreLinkEvent>\r\n    <Link>\r\n      <AdditionalOptions>\"/MANIFESTDEPENDENCY:type=%27win32%27 name=%27Microsoft.Windows.Common-Controls%27 version=%276.0.0.0%27 publicKeyToken=%276595b64144ccf1df%27 language=%27*%27 processorArchitecture=%27*%27\" %(AdditionalOptions)</AdditionalOptions>\r\n      <AdditionalDependencies>IPXACTmodelsd.lib;KactusAPId.lib;python310_d.lib;%(AdditionalDependencies)</AdditionalDependencies>\r\n      <OutputFile>executable\\Kactus2_d.exe</OutputFile>\r\n      <SuppressStartupBanner>true</SuppressStartupBanner>\r\n      <AdditionalLibraryDirectories>executable;$(PYTHON_DIR)\\libs;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>\r\n      <GenerateDebugInformation>true</GenerateDebugInformation>\r\n      <ProgramDatabaseFile>\r\n      </ProgramDatabaseFile>\r\n      <SubSystem>Console</SubSystem>\r\n      <LinkTimeCodeGeneration>\r\n      </LinkTimeCodeGeneration>\r\n      <TargetMachine>MachineX64</TargetMachine>\r\n    </Link>\r\n    <PostBuildEvent>\r\n      <Command>verbuild version.h *.*.+.* -xFp -b0.0.0.0  -e99.99.9999.0 -s\r\nCreateHelp\r\n</Command>\r\n    </PostBuildEvent>\r\n    <QtMoc>\r\n      <ExecutionDescription>Moc'ing %(Identity)...</ExecutionDescription>\r\n      <DynamicSource>output</DynamicSource>\r\n      <QtMocDir>.\\GeneratedFiles</QtMocDir>\r\n      <QtMocFileName>moc_%(Filename).cpp</QtMocFileName>\r\n    </QtMoc>\r\n    <QtRcc>\r\n      <InitFuncName>%(Filename)</InitFuncName>\r\n      <Compression>default</Compression>\r\n      <NoCompression>true</NoCompression>\r\n      <ExecutionDescription>Rcc'ing %(Identity)...</ExecutionDescription>\r\n      <QtRccDir>.\\GeneratedFiles</QtRccDir>\r\n      <QtRccFileName>qrc_%(Filename).cpp</QtRccFileName>\r\n    </QtRcc>\r\n  </ItemDefinitionGroup>\r\n  <ItemDefinitionGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n    <Midl>\r\n      <WarningLevel>0</WarningLevel>\r\n      <DefaultCharType>Unsigned</DefaultCharType>\r\n      <TargetEnvironment>X64</TargetEnvironment>\r\n      <EnableErrorChecks>None</EnableErrorChecks>\r\n    </Midl>\r\n    <ClCompile>\r\n      <AdditionalOptions>-Zm200 -w34100 -w34189 /MP /Zc:__cplusplus %(AdditionalOptions)</AdditionalOptions>\r\n      <Optimization>MaxSpeed</Optimization>\r\n      <WholeProgramOptimization>true</WholeProgramOptimization>\r\n      <AdditionalIncludeDirectories>.\\GeneratedFiles\\$(ConfigurationName);.\\GeneratedFiles;.;$(PYTHON_DIR)\\include;$(SolutinDir)KactusAPI\\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\r\n      <PreprocessorDefinitions>QT_NO_DEBUG;NDEBUG;_WINDOWS;UNICODE;WIN32;QT_XMLPATTERNS_LIB;QT_HAVE_MMX;QT_HAVE_3DNOW;QT_HAVE_SSE;QT_HAVE_MMXEXT;QT_HAVE_SSE2;%(PreprocessorDefinitions)</PreprocessorDefinitions>\r\n      <PreprocessToFile>false</PreprocessToFile>\r\n      <PreprocessSuppressLineNumbers>false</PreprocessSuppressLineNumbers>\r\n      <ExceptionHandling>Sync</ExceptionHandling>\r\n      <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>\r\n      <BufferSecurityCheck>false</BufferSecurityCheck>\r\n      <TreatWChar_tAsBuiltInType>true</TreatWChar_tAsBuiltInType>\r\n      <RuntimeTypeInfo>true</RuntimeTypeInfo>\r\n      <AssemblerListingLocation>x64\\release\\</AssemblerListingLocation>\r\n      <ObjectFileName>x64\\release\\</ObjectFileName>\r\n      <ProgramDataBaseFileName>.\\x64\\</ProgramDataBaseFileName>\r\n      <WarningLevel>Level3</WarningLevel>\r\n      <SuppressStartupBanner>true</SuppressStartupBanner>\r\n      <DebugInformationFormat>\r\n      </DebugInformationFormat>\r\n      <LanguageStandard>stdcpp17</LanguageStandard>\r\n      <MultiProcessorCompilation>true</MultiProcessorCompilation>\r\n    </ClCompile>\r\n    <ResourceCompile>\r\n      <PreprocessorDefinitions>QT_NO_DEBUG;NDEBUG;_WINDOWS;UNICODE;WIN32;QT_LARGEFILE_SUPPORT;QT_DLL;QT_NO_DEBUG;QT_XMLPATTERNS_LIB;QT_XML_LIB;QT_GUI_LIB;QT_CORE_LIB;QT_HAVE_MMX;QT_HAVE_3DNOW;QT_HAVE_SSE;QT_HAVE_MMXEXT;QT_HAVE_SSE2;QT_THREAD_SUPPORT;%(PreprocessorDefinitions)</PreprocessorDefinitions>\r\n    </ResourceCompile>\r\n    <Link>\r\n      <AdditionalOptions>\"/MANIFESTDEPENDENCY:type=%27win32%27 name=%27Microsoft.Windows.Common-Controls%27 version=%276.0.0.0%27 publicKeyToken=%276595b64144ccf1df%27 language=%27*%27 processorArchitecture=%27*%27\" %(AdditionalOptions)</AdditionalOptions>\r\n      <AdditionalDependencies>IPXACTmodels.lib;Python310.lib;KactusAPI.lib;%(AdditionalDependencies)</AdditionalDependencies>\r\n      <OutputFile>executable\\Kactus2.exe</OutputFile>\r\n      <SuppressStartupBanner>true</SuppressStartupBanner>\r\n      <AdditionalLibraryDirectories>executable;$(PYTHON_DIR)\\libs;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>\r\n      <GenerateDebugInformation>false</GenerateDebugInformation>\r\n      <ProgramDatabaseFile>\r\n      </ProgramDatabaseFile>\r\n      <SubSystem>Console</SubSystem>\r\n      <LinkTimeCodeGeneration>UseLinkTimeCodeGeneration</LinkTimeCodeGeneration>\r\n      <TargetMachine>MachineX64</TargetMachine>\r\n    </Link>\r\n    <PostBuildEvent>\r\n      <Command>RunDeploy\r\n</Command>\r\n    </PostBuildEvent>\r\n    <QtMoc>\r\n      <ExecutionDescription>Moc'ing %(Identity)...</ExecutionDescription>\r\n      <DynamicSource>output</DynamicSource>\r\n      <QtMocDir>.\\GeneratedFiles</QtMocDir>\r\n      <QtMocFileName>moc_%(Filename).cpp</QtMocFileName>\r\n    </QtMoc>\r\n    <QtRcc>\r\n      <InitFuncName>%(Filename)</InitFuncName>\r\n      <Compression>default</Compression>\r\n      <NoCompression>true</NoCompression>\r\n      <ExecutionDescription>Rcc'ing %(Identity)...</ExecutionDescription>\r\n      <QtRccDir>.\\GeneratedFiles</QtRccDir>\r\n      <QtRccFileName>qrc_%(Filename).cpp</QtRccFileName>\r\n    </QtRcc>\r\n  </ItemDefinitionGroup>\r\n  <ItemDefinitionGroup Condition=\"'$(Configuration)|$(Platform)'=='Template|x64'\">\r\n    <Link>\r\n      <AdditionalDependencies>%(AdditionalDependencies)</AdditionalDependencies>\r\n      <AdditionalLibraryDirectories>..\\..\\executable;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>\r\n    </Link>\r\n    <ClCompile>\r\n      <PreprocessorDefinitions>%(PreprocessorDefinitions)</PreprocessorDefinitions>\r\n      <AdditionalIncludeDirectories>.\\GeneratedFiles\\$(ConfigurationName);.\\GeneratedFiles;.\\IPXactWrapper\\ComponentEditor\\software\\swView;.\\common\\widgets\\cpuSelector;.\\common\\widgets\\fileTypeSelector;.\\common\\dialogs\\commandLineGeneratorDialog;.\\editors\\ComponentEditor\\common;.\\editors\\ComponentEditor\\addressSpaces;.\\mainwindow;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\r\n      <MultiProcessorCompilation>true</MultiProcessorCompilation>\r\n    </ClCompile>\r\n    <QtMoc>\r\n      <ExecutionDescription>Moc'ing %(Identity)...</ExecutionDescription>\r\n      <DynamicSource>output</DynamicSource>\r\n      <QtMocDir>.\\GeneratedFiles</QtMocDir>\r\n      <QtMocFileName>moc_%(Filename).cpp</QtMocFileName>\r\n    </QtMoc>\r\n  </ItemDefinitionGroup>\r\n  <ItemGroup>\r\n    <ClCompile Include=\"common\\dialogs\\LibrarySettingsDialog\\librarysettingsdelegate.cpp\" />\r\n    <ClCompile Include=\"common\\dialogs\\NewBusDialog\\NewBusDialog.cpp\" />\r\n    <ClCompile Include=\"common\\expressions\\utilities.cpp\" />\r\n    <ClCompile Include=\"common\\GenericEditProvider.cpp\" />\r\n    <ClCompile Include=\"common\\graphicsItems\\GraphicsColumnAddCommand.cpp\" />\r\n    <ClCompile Include=\"common\\NameGenerationPolicy.cpp\" />\r\n    <ClCompile Include=\"common\\TextEditProvider.cpp\" />\r\n    <ClCompile Include=\"common\\ui\\GraphicalMessageMediator.cpp\" />\r\n    <ClCompile Include=\"common\\dialogs\\comboSelector\\comboselector.cpp\" />\r\n    <ClCompile Include=\"common\\dialogs\\propertyPageDialog\\PropertyPageDialog.cpp\" />\r\n    <ClCompile Include=\"common\\dialogs\\propertyPageDialog\\PropertyPageView.cpp\" />\r\n    <ClCompile Include=\"common\\dialogs\\newObjectDialog\\newobjectdialog.cpp\" />\r\n    <ClCompile Include=\"common\\dialogs\\createConfigurationDialog\\createconfigurationdialog.cpp\" />\r\n    <ClCompile Include=\"common\\dialogs\\listSelectDialog\\ListSelectDialog.cpp\" />\r\n    <ClCompile Include=\"common\\dialogs\\NewDesignDialog\\NewDesignDialog.cpp\" />\r\n    <ClCompile Include=\"common\\dialogs\\LibrarySettingsDialog\\LibrarySettingsDialog.cpp\" />\r\n    <ClCompile Include=\"common\\validators\\LibraryPathValidator\\librarypathvalidator.cpp\" />\r\n    <ClCompile Include=\"common\\views\\EditableTreeView\\EditableTreeSortFilter.cpp\" />\r\n    <ClCompile Include=\"common\\views\\EditableTreeView\\EditableTreeView.cpp\" />\r\n    <ClCompile Include=\"common\\views\\ExpandingTreeView\\ExpandingTreeView.cpp\" />\r\n    <ClCompile Include=\"common\\widgets\\assistedLineEdit\\AssistedLineEdit.cpp\" />\r\n    <ClCompile Include=\"common\\widgets\\assistedLineEdit\\BasicLineContentMatcher.cpp\" />\r\n    <ClCompile Include=\"common\\widgets\\assistedLineEdit\\LineContentAssistWidget.cpp\" />\r\n    <ClCompile Include=\"common\\widgets\\busReferenceComboBox\\BusReferenceComboBox.cpp\" />\r\n    <ClCompile Include=\"common\\widgets\\DirectoryListSelector\\DirectoryListSelector.cpp\" />\r\n    <ClCompile Include=\"common\\widgets\\EnumCollectionEditor\\EnumCollectionEditor.cpp\" />\r\n    <ClCompile Include=\"common\\widgets\\EnumCollectionEditor\\EnumerationEditor.cpp\" />\r\n    <ClCompile Include=\"common\\widgets\\EnumCollectionEditor\\InterfaceEnumEditor.cpp\" />\r\n    <ClCompile Include=\"common\\widgets\\FileSelector\\fileselector.cpp\" />\r\n    <ClCompile Include=\"common\\widgets\\fileTypeSelector\\filetypeselector.cpp\" />\r\n    <ClCompile Include=\"common\\widgets\\GroupBoxWithAlertSign\\GroupBoxWithAlertSign.cpp\" />\r\n    <ClCompile Include=\"common\\widgets\\GroupBoxWithAlertSign\\StyleGroupBoxWithAlertSign.cpp\" />\r\n    <ClCompile Include=\"common\\widgets\\GroupBoxWithAlertSign\\StyleOptionGroupBoxWithAlertSign.cpp\" />\r\n    <ClCompile Include=\"common\\widgets\\instanceWidgets\\InstanceWidgets.cpp\" />\r\n    <ClCompile Include=\"common\\widgets\\LibrarySelectorWidget\\LibraryPathEditor\\librarypatheditor.cpp\" />\r\n    <ClCompile Include=\"common\\widgets\\LibrarySelectorWidget\\LibraryPathSelector\\librarypathselector.cpp\" />\r\n    <ClCompile Include=\"common\\widgets\\LibrarySelectorWidget\\LibrarySelectorWidget.cpp\" />\r\n    <ClCompile Include=\"common\\widgets\\listManager\\dirlistmanager.cpp\" />\r\n    <ClCompile Include=\"common\\widgets\\listManager\\dirlistmanagermodel.cpp\" />\r\n    <ClCompile Include=\"common\\widgets\\listManager\\listeditor.cpp\" />\r\n    <ClCompile Include=\"common\\widgets\\listManager\\listmanager.cpp\" />\r\n    <ClCompile Include=\"common\\widgets\\listManager\\listmanagermodel.cpp\" />\r\n    <ClCompile Include=\"common\\widgets\\nameGroupBox\\namegroupbox.cpp\" />\r\n    <ClCompile Include=\"common\\widgets\\ParameterGroupBox\\parametergroupbox.cpp\" />\r\n    <ClCompile Include=\"common\\widgets\\segmentComboBox\\SegmentComboBox.cpp\" />\r\n    <ClCompile Include=\"common\\widgets\\tagEditor\\FlowLayout.cpp\" />\r\n    <ClCompile Include=\"common\\widgets\\tagEditor\\TagCompleterModel.cpp\" />\r\n    <ClCompile Include=\"common\\widgets\\tagEditor\\TagContainer.cpp\" />\r\n    <ClCompile Include=\"common\\widgets\\tagEditor\\TagDisplay.cpp\" />\r\n    <ClCompile Include=\"common\\widgets\\tagEditor\\TagEditor.cpp\" />\r\n    <ClCompile Include=\"common\\widgets\\tagEditor\\TagEditorContainer.cpp\" />\r\n    <ClCompile Include=\"common\\widgets\\tagEditor\\TagLabel.cpp\" />\r\n    <ClCompile Include=\"common\\widgets\\tagEditor\\TagSelector.cpp\" />\r\n    <ClCompile Include=\"common\\widgets\\tagEditor\\TagSelectorContainer.cpp\" />\r\n    <ClCompile Include=\"common\\widgets\\TreeItemSelector\\FramedTreeItemEditor.cpp\" />\r\n    <ClCompile Include=\"common\\widgets\\TreeItemSelector\\TreeItemEditor.cpp\" />\r\n    <ClCompile Include=\"common\\widgets\\TreeItemSelector\\TreeItemModel.cpp\" />\r\n    <ClCompile Include=\"common\\widgets\\viewSelector\\viewselector.cpp\" />\r\n    <ClCompile Include=\"common\\widgets\\vlnvDisplayer\\vlnvdisplayer.cpp\" />\r\n    <ClCompile Include=\"common\\widgets\\assistedTextEdit\\AssistedTextEdit.cpp\" />\r\n    <ClCompile Include=\"common\\widgets\\assistedTextEdit\\TextContentAssistWidget.cpp\" />\r\n    <ClCompile Include=\"common\\widgets\\assistedTextEdit\\ToolTipHintWidget.cpp\" />\r\n    <ClCompile Include=\"common\\widgets\\vlnvEditor\\VLNVContentMatcher.cpp\" />\r\n    <ClCompile Include=\"common\\widgets\\vlnvEditor\\VLNVDataTree.cpp\" />\r\n    <ClCompile Include=\"common\\widgets\\vlnvEditor\\vlnveditor.cpp\" />\r\n    <ClCompile Include=\"common\\widgets\\colorBox\\ColorBox.cpp\" />\r\n    <ClCompile Include=\"common\\widgets\\kactusAttributeEditor\\KactusAttributeEditor.cpp\" />\r\n    <ClCompile Include=\"common\\widgets\\componentPreviewBox\\ComponentPreviewBox.cpp\" />\r\n    <ClCompile Include=\"common\\widgets\\tabDocument\\TabDocument.cpp\" />\r\n    <ClCompile Include=\"common\\widgets\\booleanComboBox\\booleancombobox.cpp\" />\r\n    <ClCompile Include=\"common\\widgets\\nameGroupEditor\\namegroupeditor.cpp\" />\r\n    <ClCompile Include=\"common\\widgets\\summaryLabel\\summarylabel.cpp\" />\r\n    <ClCompile Include=\"common\\widgets\\interfaceModeSelector\\interfacemodeselector.cpp\" />\r\n    <ClCompile Include=\"common\\widgets\\interfaceSelector\\interfaceselector.cpp\" />\r\n    <ClCompile Include=\"common\\widgets\\LineEditEx\\LineEditEx.cpp\" />\r\n    <ClCompile Include=\"common\\widgets\\SnippetTextEdit\\SnippetHighlighter.cpp\" />\r\n    <ClCompile Include=\"common\\widgets\\SnippetTextEdit\\SnippetTextEdit.cpp\" />\r\n    <ClCompile Include=\"common\\widgets\\usageComboBox\\usagecombobox.cpp\" />\r\n    <ClCompile Include=\"common\\widgets\\accessComboBox\\accesscombobox.cpp\" />\r\n    <ClCompile Include=\"common\\widgets\\modWriteComboBox\\modwritecombobox.cpp\" />\r\n    <ClCompile Include=\"common\\widgets\\readActionComboBox\\readactioncombobox.cpp\" />\r\n    <ClCompile Include=\"common\\widgets\\testConstraintComboBox\\testconstraintcombobox.cpp\" />\r\n    <ClCompile Include=\"common\\graphicsItems\\CommonGraphicsUndoCommands.cpp\" />\r\n    <ClCompile Include=\"common\\graphicsItems\\ComponentItem.cpp\" />\r\n    <ClCompile Include=\"common\\graphicsItems\\ConnectionEndpoint.cpp\" />\r\n    <ClCompile Include=\"common\\graphicsItems\\ConnectionUndoCommands.cpp\" />\r\n    <ClCompile Include=\"common\\graphicsItems\\expandableitem.cpp\" />\r\n    <ClCompile Include=\"common\\graphicsItems\\GraphicsColumn.cpp\" />\r\n    <ClCompile Include=\"common\\graphicsItems\\GraphicsColumnLayout.cpp\" />\r\n    <ClCompile Include=\"common\\graphicsItems\\GraphicsColumnUndoCommands.cpp\" />\r\n    <ClCompile Include=\"common\\graphicsItems\\GraphicsConnection.cpp\" />\r\n    <ClCompile Include=\"common\\graphicsItems\\graphicsexpandcollapseitem.cpp\" />\r\n    <ClCompile Include=\"common\\graphicsItems\\GraphicsLineEdit.cpp\" />\r\n    <ClCompile Include=\"common\\graphicsItems\\GraphicsRectButton.cpp\" />\r\n    <ClCompile Include=\"common\\graphicsItems\\visualizeritem.cpp\" />\r\n    <ClCompile Include=\"common\\delegates\\ComboDelegate\\combodelegate.cpp\" />\r\n    <ClCompile Include=\"common\\delegates\\LineEditDelegate\\lineeditdelegate.cpp\" />\r\n    <ClCompile Include=\"common\\views\\EditableTableView\\editabletableview.cpp\" />\r\n    <ClCompile Include=\"common\\views\\EditableListView\\editablelistview.cpp\" />\r\n    <ClCompile Include=\"editors\\AbstractionDefinitionEditor\\absdefgroup.cpp\" />\r\n    <ClCompile Include=\"editors\\AbstractionDefinitionEditor\\AbsDefParameterReferenceCounter.cpp\" />\r\n    <ClCompile Include=\"editors\\AbstractionDefinitionEditor\\AbsDefParameterReferenceTree.cpp\" />\r\n    <ClCompile Include=\"editors\\AbstractionDefinitionEditor\\AbstractionDefinitionEditor.cpp\" />\r\n    <ClCompile Include=\"editors\\AbstractionDefinitionEditor\\AbstractionDefinitionPortsSortFilter.cpp\" />\r\n    <ClCompile Include=\"editors\\AbstractionDefinitionEditor\\AbstractionDefinitionSignalRow.cpp\" />\r\n    <ClCompile Include=\"editors\\AbstractionDefinitionEditor\\AbstractionPortsDelegate.cpp\" />\r\n    <ClCompile Include=\"editors\\AbstractionDefinitionEditor\\AbstractionPortsEditor.cpp\" />\r\n    <ClCompile Include=\"editors\\AbstractionDefinitionEditor\\AbstractionPortsModel.cpp\" />\r\n    <ClCompile Include=\"editors\\AbstractionDefinitionEditor\\AbstractionPortsView.cpp\" />\r\n    <ClCompile Include=\"editors\\AbstractionDefinitionEditor\\AbstractionTransactionalPortsDelegate.cpp\" />\r\n    <ClCompile Include=\"editors\\AbstractionDefinitionEditor\\AbstractionTransactionalPortsSortFilter.cpp\" />\r\n    <ClCompile Include=\"editors\\AbstractionDefinitionEditor\\AbstractionWirePortsDelegate.cpp\" />\r\n    <ClCompile Include=\"editors\\AbstractionDefinitionEditor\\AbstractionWirePortsSortFilter.cpp\" />\r\n    <ClCompile Include=\"editors\\AbstractionDefinitionEditor\\QualifierEditor.cpp\" />\r\n    <ClCompile Include=\"editors\\ApiDefinitionEditor\\ApiDefinitionEditor.cpp\" />\r\n    <ClCompile Include=\"editors\\ApiDefinitionEditor\\ApiFunctionEditor.cpp\" />\r\n    <ClCompile Include=\"editors\\ApiDefinitionEditor\\ApiFunctionModel.cpp\" />\r\n    <ClCompile Include=\"editors\\ApiDefinitionEditor\\ApiFunctionParameterDelegate.cpp\" />\r\n    <ClCompile Include=\"editors\\ApiDefinitionEditor\\ApiFunctionParameterModel.cpp\" />\r\n    <ClCompile Include=\"editors\\BusDefinitionEditor\\busdefgroup.cpp\" />\r\n    <ClCompile Include=\"editors\\BusDefinitionEditor\\BusDefinitionEditor.cpp\" />\r\n    <ClCompile Include=\"editors\\BusDefinitionEditor\\BusDefinitionParameterReferenceTree.cpp\" />\r\n    <ClCompile Include=\"editors\\BusDefinitionEditor\\SystemGroupListEditor.cpp\" />\r\n    <ClCompile Include=\"editors\\CatalogEditor\\CatalogEditor.cpp\" />\r\n    <ClCompile Include=\"editors\\CatalogEditor\\CatalogFileDelegate.cpp\" />\r\n    <ClCompile Include=\"editors\\CatalogEditor\\CatalogFileFilter.cpp\" />\r\n    <ClCompile Include=\"editors\\CatalogEditor\\CatalogFileModel.cpp\" />\r\n    <ClCompile Include=\"editors\\CatalogEditor\\CatalogFileView.cpp\" />\r\n    <ClCompile Include=\"editors\\ComDefinitionEditor\\ComDefinitionEditor.cpp\" />\r\n    <ClCompile Include=\"editors\\ComDefinitionEditor\\ComPropertyDelegate.cpp\" />\r\n    <ClCompile Include=\"editors\\ComDefinitionEditor\\ComPropertyEditor.cpp\" />\r\n    <ClCompile Include=\"editors\\ComDefinitionEditor\\ComPropertyModel.cpp\" />\r\n    <ClCompile Include=\"editors\\common\\Association\\Associable.cpp\" />\r\n    <ClCompile Include=\"editors\\common\\Association\\Association.cpp\" />\r\n    <ClCompile Include=\"editors\\common\\Association\\AssociationAddCommand.cpp\" />\r\n    <ClCompile Include=\"editors\\common\\Association\\AssociationChangeEndpointCommand.cpp\" />\r\n    <ClCompile Include=\"editors\\common\\Association\\AssociationRemoveCommand.cpp\" />\r\n    <ClCompile Include=\"editors\\common\\ComponentDesignDiagram.cpp\" />\r\n    <ClCompile Include=\"editors\\common\\ComponentInstanceEditor\\ComponentInstanceConfigurableElementsEditor.cpp\" />\r\n    <ClCompile Include=\"editors\\common\\ComponentInstanceEditor\\ComponentInstanceConfigurableElementsFilter.cpp\" />\r\n    <ClCompile Include=\"editors\\common\\ComponentInstanceEditor\\ComponentInstanceConfigurableElementsModel.cpp\" />\r\n    <ClCompile Include=\"editors\\common\\ComponentInstanceEditor\\componentinstanceeditor.cpp\" />\r\n    <ClCompile Include=\"editors\\common\\ComponentInstanceEditor\\configurableelementdelegate.cpp\" />\r\n    <ClCompile Include=\"editors\\common\\ComponentInstanceEditor\\configurableelementeditor.cpp\" />\r\n    <ClCompile Include=\"editors\\common\\ComponentInstanceEditor\\ConfigurableElementsFilter.cpp\" />\r\n    <ClCompile Include=\"editors\\common\\ComponentInstanceEditor\\ConfigurableElementsModel.cpp\" />\r\n    <ClCompile Include=\"editors\\common\\ComponentInstanceEditor\\ConfigurableElementsView.cpp\" />\r\n    <ClCompile Include=\"editors\\common\\ComponentInstanceEditor\\EditorConfigurableElement.cpp\" />\r\n    <ClCompile Include=\"editors\\common\\ComponentInstanceEditor\\MissingConfigurableElementsFilter.cpp\" />\r\n    <ClCompile Include=\"editors\\common\\ComponentInstanceEditor\\ParameterConfigurableElementsFilter.cpp\" />\r\n    <ClCompile Include=\"editors\\common\\ComponentInstanceEditor\\PowerDomainLinkDelegate.cpp\" />\r\n    <ClCompile Include=\"editors\\common\\ComponentInstanceEditor\\PowerDomainLinkEditor.cpp\" />\r\n    <ClCompile Include=\"editors\\common\\ComponentInstanceEditor\\PowerDomainLinkModel.cpp\" />\r\n    <ClCompile Include=\"editors\\common\\ComponentItemAutoConnector\\AutoConnector.cpp\" />\r\n    <ClCompile Include=\"editors\\common\\ComponentItemAutoConnector\\AutoConnectorConnectionDelegate.cpp\" />\r\n    <ClCompile Include=\"editors\\common\\ComponentItemAutoConnector\\AutoConnectorConnectionTable.cpp\" />\r\n    <ClCompile Include=\"editors\\common\\ComponentItemAutoConnector\\AutoConnectorItem.cpp\" />\r\n    <ClCompile Include=\"editors\\common\\ComponentItemAutoConnector\\AutoConnectorListFilter.cpp\" />\r\n    <ClCompile Include=\"editors\\common\\ComponentItemAutoConnector\\BusInterfaceItemMatcher.cpp\" />\r\n    <ClCompile Include=\"editors\\common\\ComponentItemAutoConnector\\BusInterfaceListFiller.cpp\" />\r\n    <ClCompile Include=\"editors\\common\\ComponentItemAutoConnector\\BusInterfaceTableAutoConnector.cpp\" />\r\n    <ClCompile Include=\"editors\\common\\ComponentItemAutoConnector\\ComponentItemAutoConnector.cpp\" />\r\n    <ClCompile Include=\"editors\\common\\ComponentItemAutoConnector\\HierarchicalBusInterfaceItemMatcher.cpp\" />\r\n    <ClCompile Include=\"editors\\common\\ComponentItemAutoConnector\\HierarchicalBusInterfaceTableAutoConnector.cpp\" />\r\n    <ClCompile Include=\"editors\\common\\ComponentItemAutoConnector\\HierarchicalPortItemMatcher.cpp\" />\r\n    <ClCompile Include=\"editors\\common\\ComponentItemAutoConnector\\HierarchicalPortTableAutoConnector.cpp\" />\r\n    <ClCompile Include=\"editors\\common\\ComponentItemAutoConnector\\PortItemMatcher.cpp\" />\r\n    <ClCompile Include=\"editors\\common\\ComponentItemAutoConnector\\PortListFiller.cpp\" />\r\n    <ClCompile Include=\"editors\\common\\ComponentItemAutoConnector\\PortTableAutoConnector.cpp\" />\r\n    <ClCompile Include=\"editors\\common\\ComponentItemAutoConnector\\TableAutoConnector.cpp\" />\r\n    <ClCompile Include=\"editors\\common\\ComponentItemAutoConnector\\TableItemMatcher.cpp\" />\r\n    <ClCompile Include=\"editors\\common\\ConfigurationEditor\\activeviewdelegate.cpp\" />\r\n    <ClCompile Include=\"editors\\common\\ConfigurationEditor\\activevieweditor.cpp\" />\r\n    <ClCompile Include=\"editors\\common\\ConfigurationEditor\\activeviewmodel.cpp\" />\r\n    <ClCompile Include=\"editors\\common\\ConfigurationEditor\\configurationeditor.cpp\" />\r\n    <ClCompile Include=\"editors\\common\\ConnectionEditor\\AdHocBoundsModel.cpp\" />\r\n    <ClCompile Include=\"editors\\common\\ConnectionEditor\\connectioneditor.cpp\" />\r\n    <ClCompile Include=\"editors\\common\\DefaultRouting.cpp\" />\r\n    <ClCompile Include=\"editors\\common\\DesignCompletionModel.cpp\" />\r\n    <ClCompile Include=\"editors\\common\\DesignDiagram.cpp\" />\r\n    <ClCompile Include=\"editors\\common\\DesignDiagramResolver.cpp\" />\r\n    <ClCompile Include=\"editors\\common\\DesignParameterReferenceTree\\DesignParameterReferenceCounter.cpp\" />\r\n    <ClCompile Include=\"editors\\common\\DesignParameterReferenceTree\\DesignParameterReferenceTree.cpp\" />\r\n    <ClCompile Include=\"editors\\common\\DesignWidget.cpp\" />\r\n    <ClCompile Include=\"editors\\common\\DesignWidgetFactoryImplementation.cpp\" />\r\n    <ClCompile Include=\"editors\\common\\DocumentNameGroupEditor.cpp\" />\r\n    <ClCompile Include=\"editors\\common\\GraphicsItemLabel.cpp\" />\r\n    <ClCompile Include=\"editors\\common\\ImageExporter.cpp\" />\r\n    <ClCompile Include=\"editors\\common\\InterfaceEditor\\interfaceeditor.cpp\" />\r\n    <ClCompile Include=\"editors\\common\\InterfaceEditor\\InterfacePortMapDelegate.cpp\" />\r\n    <ClCompile Include=\"editors\\common\\InterfaceEditor\\InterfacePortMapModel.cpp\" />\r\n    <ClCompile Include=\"editors\\common\\NamelabelWidth.cpp\" />\r\n    <ClCompile Include=\"editors\\common\\PortUtilities.cpp\" />\r\n    <ClCompile Include=\"editors\\common\\StickyNote\\ColorFillTextItem.cpp\" />\r\n    <ClCompile Include=\"editors\\common\\StickyNote\\StickyNote.cpp\" />\r\n    <ClCompile Include=\"editors\\common\\StickyNote\\StickyNoteAddCommand.cpp\" />\r\n    <ClCompile Include=\"editors\\common\\StickyNote\\StickyNoteEditCommand.cpp\" />\r\n    <ClCompile Include=\"editors\\common\\StickyNote\\StickyNoteMoveCommand.cpp\" />\r\n    <ClCompile Include=\"editors\\common\\StickyNote\\StickyNoteRemoveCommand.cpp\" />\r\n    <ClCompile Include=\"editors\\common\\TopComponentParameterFinder.cpp\" />\r\n    <ClCompile Include=\"editors\\common\\VendorExtensionEditor\\VendorExtensionAttributesEditor\\VendorExtensionAttributesModel.cpp\" />\r\n    <ClCompile Include=\"editors\\common\\VendorExtensionEditor\\VendorExtensionsDelegate.cpp\" />\r\n    <ClCompile Include=\"editors\\common\\VendorExtensionEditor\\VendorExtensionsEditor.cpp\" />\r\n    <ClCompile Include=\"editors\\common\\VendorExtensionEditor\\VendorExtensionsFilter.cpp\" />\r\n    <ClCompile Include=\"editors\\common\\VendorExtensionEditor\\VendorExtensionsModel.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\addressSpaces\\addressspaceeditor.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\addressSpaces\\addressspacegeneraleditor.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\addressSpaces\\addressspacesdelegate.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\addressSpaces\\addressspaceseditor.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\addressSpaces\\addressspacesmodel.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\addressSpaces\\addressSpaceVisualizer\\AddressSpaceConflictedItem.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\addressSpaces\\addressSpaceVisualizer\\addressspacegapitem.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\addressSpaces\\addressSpaceVisualizer\\addressspacescene.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\addressSpaces\\addressSpaceVisualizer\\addressspacevisualizationitem.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\addressSpaces\\addressSpaceVisualizer\\addressspacevisualizer.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\addressSpaces\\addressSpaceVisualizer\\localaddrblockgraphitem.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\addressSpaces\\addressSpaceVisualizer\\segmentgraphitem.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\addressSpaces\\localMemoryMap\\localmemorymapeditor.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\addressSpaces\\localMemoryMap\\localmemorymapgraphitem.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\addressSpaces\\SegmentDelegate.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\addressSpaces\\segmenteditor.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\addressSpaces\\segmentsmodel.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\busInterfaces\\AbstractionTypesDelegate.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\busInterfaces\\AbstractionTypesEditor.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\busInterfaces\\AbstractionTypesModel.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\busInterfaces\\businterfaceeditor.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\busInterfaces\\businterfacesdelegate.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\busInterfaces\\businterfaceseditor.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\busInterfaces\\businterfacesmodel.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\busInterfaces\\general\\bridgesdelegate.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\busInterfaces\\general\\bridgeseditor.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\busInterfaces\\general\\bridgesmodel.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\busInterfaces\\general\\busifgeneraldetails.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\busInterfaces\\general\\busifgeneraltab.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\busInterfaces\\general\\InitiatorModeEditor.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\busInterfaces\\general\\interfacemodestack.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\busInterfaces\\general\\MasterModeEditor.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\busInterfaces\\general\\MirroredInitiatorModeEditor.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\busInterfaces\\general\\MirroredMasterModeEditor.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\busInterfaces\\general\\MirroredSlaveModeEditor.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\busInterfaces\\general\\MirroredTargetModeEditor.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\busInterfaces\\general\\ModeEditorBase.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\busInterfaces\\general\\MonitorModeEditor.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\busInterfaces\\general\\SlaveModeEditor.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\busInterfaces\\general\\SystemModeEditor.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\busInterfaces\\general\\TargetModeEditor.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\busInterfaces\\portmaps\\BusInterfacePortMapTab.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\busInterfaces\\portmaps\\JaroWinklerAlgorithm.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\busInterfaces\\portmaps\\PhysicalPortMappingTableModel.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\busInterfaces\\portmaps\\PhysicalPortMappingTableView.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\busInterfaces\\portmaps\\PortListSortProxyModel.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\busInterfaces\\portmaps\\PortMapAutoConnector.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\busInterfaces\\portmaps\\PortMapDelegate.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\busInterfaces\\portmaps\\PortMapHeaderView.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\busInterfaces\\portmaps\\PortMapModel.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\busInterfaces\\portmaps\\PortMappingTableModel.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\busInterfaces\\portmaps\\PortMappingTableView.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\busInterfaces\\portmaps\\PortMapSortFilter.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\busInterfaces\\portmaps\\PortMapView.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\channels\\channelsdelegate.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\channels\\channelseditor.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\channels\\channelsmodel.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\choices\\ChoicesEditor.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\choices\\ChoicesModel.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\choices\\EnumerationModel.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\common\\AbstractParameterModel.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\common\\ConfigurableElementFinder.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\common\\DesignConfigurationInstantiationParameterFinder.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\common\\EnumerationEditorConstructorDelegate.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\common\\ExpressionDelegate.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\common\\ExpressionEditor.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\common\\ExpressionLineEditor.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\common\\FloatingModeReferenceEditor.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\common\\InstantiationConfigurableElementEditor.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\common\\MasterExpressionEditor.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\common\\MemoryAlignScene.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\common\\MemoryTreeFactory.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\common\\ModeReferenceDelegate.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\common\\ModeReferenceEditor.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\common\\ModeReferenceModel.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\common\\MultilineDescriptionDelegate.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\common\\ParameterizableTable.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\common\\ReferenceSelector\\ReferenceSelector.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\common\\ReferencingTableModel.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\componenteditor.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\cpus\\CpuDetailsEditor.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\cpus\\cpusdelegate.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\cpus\\cpuseditor.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\cpus\\cpusmodel.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\cpus\\CpuVisualizer.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\cpus\\RegionScene.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\cpus\\RegionsDelegate.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\cpus\\RegionsEditor.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\cpus\\RegionsModel.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\cpus\\SingleCpuEditor.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\fileBuilders\\filebuildersdelegate.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\fileBuilders\\filebuilderseditor.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\fileBuilders\\filebuildersmodel.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\fileSet\\dependencyAnalysis\\FileDependencyDelegate.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\fileSet\\dependencyAnalysis\\FileDependencyEditor.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\fileSet\\dependencyAnalysis\\FileDependencyGraphView.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\fileSet\\dependencyAnalysis\\FileDependencyGraphWidget.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\fileSet\\dependencyAnalysis\\FileDependencyInfoWidget.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\fileSet\\dependencyAnalysis\\FileDependencyItem.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\fileSet\\dependencyAnalysis\\FileDependencyModel.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\fileSet\\dependencyAnalysis\\FileDependencySortFilter.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\fileSet\\dependencyAnalysis\\FileDependencySourceEditor.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\fileSet\\fileseteditor.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\fileSet\\filesetsdelegate.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\fileSet\\filesetseditor.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\fileSet\\filesetsmodel.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\fileSet\\file\\filebuildcommand.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\fileSet\\file\\filedefinemodel.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\fileSet\\file\\filedefineview.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\fileSet\\file\\fileeditor.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\fileSet\\file\\filegeneraleditor.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\fileSet\\file\\filenameeditor.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\fileSet\\file\\filesdelegate.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\fileSet\\file\\fileseditor.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\fileSet\\file\\filesmodel.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\fileSet\\file\\filesview.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\fileSet\\file\\filetypeeditor.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\fileSet\\file\\filetypeeditordelegate.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\fileSet\\groupmanager.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\fileSet\\groupmanagerdelegate.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\general\\generaleditor.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\indirectInterfaces\\IndirectInterfacesDelegate.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\indirectInterfaces\\IndirectInterfacesEditor.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\indirectInterfaces\\IndirectInterfacesModel.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\indirectInterfaces\\SingleIndirectInterfaceEditor.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\instantiations\\ComponentInstantiationDisplayer.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\instantiations\\ComponentInstantiationEditor.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\instantiations\\ComponentInstantiationsEditor.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\instantiations\\ComponentInstantiationsModel.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\instantiations\\DesignConfigurationInstantiationEditor.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\instantiations\\DesignConfigurationInstantiationsEditor.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\instantiations\\DesignConfigurationInstantiationsModel.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\instantiations\\DesignInstantiationEditor.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\instantiations\\DesignInstantiationsDelegate.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\instantiations\\DesignInstantiationsEditor.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\instantiations\\DesignInstantiationsModel.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\instantiations\\filesetrefeditor.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\instantiations\\filesetrefeditordelegate.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\instantiations\\filesetrefmodel.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\instantiations\\InstantiationsEditor.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\instantiations\\ModuleParameterDelegate.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\instantiations\\ModuleParameterEditor.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\instantiations\\ModuleParameterHeaderView.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\instantiations\\ModuleParameterModel.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\itemeditor.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\itemvisualizer.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\memoryMaps\\AccessPoliciesDelegate.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\memoryMaps\\AccessPoliciesEditor.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\memoryMaps\\AccessPoliciesModel.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\memoryMaps\\FieldAccessPoliciesDelegate.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\memoryMaps\\FieldAccessPoliciesEditor.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\memoryMaps\\FieldAccessPoliciesModel.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\memoryMaps\\addressblockdelegate.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\memoryMaps\\addressblockeditor.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\memoryMaps\\addressblockmodel.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\memoryMaps\\enumeratedvaluedelegate.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\memoryMaps\\enumeratedvaluemodel.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\memoryMaps\\ExpressionProxyModel.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\memoryMaps\\fieldeditor.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\memoryMaps\\MemoryBlockDelegate.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\memoryMaps\\MemoryBlockFilter.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\memoryMaps\\MemoryBlockModel.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\memoryMaps\\memorymapdelegate.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\memoryMaps\\memorymapeditor.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\memoryMaps\\memorymapmodel.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\memoryMaps\\memorymapsdelegate.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\memoryMaps\\memorymapseditor.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\memoryMaps\\memoryMapsExpressionCalculators\\ReferenceCalculator.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\memoryMaps\\memorymapsmodel.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\memoryMaps\\MemoryMapsView.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\memoryMaps\\memoryMapsVisualizer\\addressblockgraphitem.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\memoryMaps\\memoryMapsVisualizer\\fieldgraphitem.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\memoryMaps\\memoryMapsVisualizer\\MemoryBlockGraphItem.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\memoryMaps\\memoryMapsVisualizer\\memorymapgraphitem.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\memoryMaps\\memoryMapsVisualizer\\memorymapscene.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\memoryMaps\\memoryMapsVisualizer\\memorymapsvisualizer.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\memoryMaps\\memoryMapsVisualizer\\memorymapview.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\memoryMaps\\memoryMapsVisualizer\\registerfilegraphitem.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\memoryMaps\\memoryMapsVisualizer\\registergraphitem.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\memoryMaps\\memoryMapsVisualizer\\SubspaceMapGraphItem.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\memoryMaps\\registerdelegate.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\memoryMaps\\registereditor.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\memoryMaps\\registerfiledelegate.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\memoryMaps\\registerfileeditor.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\memoryMaps\\registerfilemodel.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\memoryMaps\\registertablemodel.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\memoryMaps\\RemapModeReferenceEditor.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\memoryMaps\\ResetsDelegate.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\memoryMaps\\ResetsEditor.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\memoryMaps\\ResetsModel.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\memoryMaps\\SingleAddressBlockEditor.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\memoryMaps\\SingleFieldEditor.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\memoryMaps\\SingleMemoryMapEditor.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\memoryMaps\\SingleRegisterEditor.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\memoryMaps\\SingleRegisterFileEditor.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\memoryMaps\\SingleSubspaceMapEditor.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\memoryMaps\\SubspaceMapDelegate.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\memoryMaps\\SubspaceMapModel.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\memoryMaps\\SubspaceMapsEditor.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\memoryMaps\\WriteValueConstraintComboBox.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\modes\\FieldSliceDelegate.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\modes\\FieldSliceEditor.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\modes\\FieldSliceModel.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\modes\\ModesEditor.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\modes\\ModesModel.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\modes\\PortSliceDelegate.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\modes\\PortSliceEditor.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\modes\\PortSliceModel.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\modes\\SingleModeEditor.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\otherClockDrivers\\clockdriversdelegate.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\otherClockDrivers\\otherclockdriverseditor.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\otherClockDrivers\\otherclockdriversmodel.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\ParameterItemEditor.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\parameterReferenceTree\\ComponentParameterReferenceTree.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\parameterReferenceTree\\ParameterReferenceTree.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\parameterReferenceTree\\ParameterReferenceTreeWindow.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\parameters\\Array\\ArrayDelegate.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\parameters\\Array\\ArrayView.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\parameters\\Array\\ParameterArrayModel.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\parameters\\ChoiceCreatorDelegate.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\parameters\\ComponentParameterModel.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\parameters\\LockableParametersModel.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\parameters\\ParameterDelegate.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\parameters\\ParameterEditorHeaderView.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\parameters\\parameterseditor.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\parameters\\parametersmodel.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\parameters\\ParametersView.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\ports\\MasterPortsEditor.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\ports\\portsdelegate.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\ports\\portseditor.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\ports\\PortsFilter.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\ports\\PortsImportSummaryEditor.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\ports\\portsmodel.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\ports\\PortSummaryDelegate.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\ports\\PortSummaryEditorFactory.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\ports\\PortSummaryModel.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\ports\\PortSummaryView.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\ports\\PortsView.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\ports\\PortTagEditorDelegate.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\ports\\PortTypeDefinitionDelegate.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\ports\\PortTypeDefinitionEditor.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\ports\\PortWireTypeDelegate.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\ports\\PortWireTypeEditor.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\ports\\PortWireTypeModel.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\ports\\PortWireTypeView.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\ports\\TransactionalPortsDelegate.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\ports\\TransactionalPortsEditorFactory.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\ports\\TransactionalPortsFilter.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\ports\\TransactionalPortsModel.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\ports\\TypedPortEditor.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\ports\\WirePortsDelegate.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\ports\\WirePortsEditorFactory.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\ports\\WirePortsFilter.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\ports\\WirePortsModel.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\ports\\TypedPortsView.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\powerDomains\\PowerDomainsDelegate.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\powerDomains\\PowerDomainsEditor.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\powerDomains\\PowerDomainsModel.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\referenceCounter\\ComponentParameterReferenceCounter.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\referenceCounter\\ParameterReferenceCounter.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\remapStates\\RemapConditionDelegate.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\remapStates\\RemapConditionEditor.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\remapStates\\RemapConditionModel.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\remapStates\\RemapStatesEditor.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\remapStates\\RemapStatesModel.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\remapStates\\SingleRemapStateEditor.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\remapStates\\ValueOrIndexedValueEditor.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\resetTypes\\ResetTypesDelegate.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\resetTypes\\ResetTypesEditor.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\resetTypes\\ResetTypesModel.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\software\\apiInterface\\ApiInterfaceEditor.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\software\\apiInterface\\apiinterfacesdelegate.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\software\\apiInterface\\apiinterfaceseditor.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\software\\apiInterface\\apiinterfacesmodel.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\software\\comInterface\\ComInterfaceEditor.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\software\\comInterface\\cominterfacesdelegate.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\software\\comInterface\\cominterfaceseditor.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\software\\comInterface\\cominterfacesmodel.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\software\\PropertyValueDelegate.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\software\\PropertyValueEditor.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\software\\PropertyValueModel.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\software\\SWPropertiesEditor.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\software\\systemView\\SystemViewEditor.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\software\\systemView\\SystemViewsEditor.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\software\\systemView\\SystemViewsModel.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\treeStructure\\componenteditoraddrblockitem.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\treeStructure\\componenteditoraddrspaceitem.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\treeStructure\\componenteditoraddrspacesitem.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\treeStructure\\componenteditorapiinterfaceitem.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\treeStructure\\componenteditorapiinterfacesitem.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\treeStructure\\componenteditorbusinterfaceitem.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\treeStructure\\componenteditorbusinterfacesitem.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\treeStructure\\componenteditorchannelsitem.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\treeStructure\\ComponentEditorChoicesItem.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\treeStructure\\componenteditorcominterfaceitem.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\treeStructure\\componenteditorcominterfacesitem.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\treeStructure\\componenteditorcpusitem.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\treeStructure\\componenteditorfielditem.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\treeStructure\\componenteditorfileitem.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\treeStructure\\componenteditorfilesetitem.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\treeStructure\\componenteditorfilesetsitem.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\treeStructure\\componenteditorgeneralitem.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\treeStructure\\componenteditorgroupslot.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\treeStructure\\ComponentEditorIndirectInterfacesItem.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\treeStructure\\componenteditoritem.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\treeStructure\\componenteditormemmapitem.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\treeStructure\\componenteditormemmapsitem.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\treeStructure\\componenteditorotherclocksitem.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\treeStructure\\componenteditorparametersitem.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\treeStructure\\componenteditorportsitem.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\treeStructure\\componenteditorregisterfileitem.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\treeStructure\\componenteditorregisteritem.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\treeStructure\\componenteditorrootitem.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\treeStructure\\componenteditorswpropertiesitem.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\treeStructure\\ComponentEditorSystemViewItem.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\treeStructure\\ComponentEditorSystemViewsItem.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\treeStructure\\ComponentEditorTreeDelegate.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\treeStructure\\componenteditortreemodel.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\treeStructure\\ComponentEditorTreeSortProxyModel.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\treeStructure\\componenteditorviewitem.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\treeStructure\\componenteditorviewsitem.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\treeStructure\\ComponentInstantiationsItem.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\treeStructure\\componenttreeview.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\treeStructure\\DesignConfigurationInstantiationsItem.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\treeStructure\\DesignInstantiationsItem.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\treeStructure\\InstantiationsItem.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\treeStructure\\MemoryRemapItem.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\treeStructure\\ModesItem.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\treeStructure\\ParameterizableItem.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\treeStructure\\PowerDomainsItem.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\treeStructure\\RemapStatesItem.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\treeStructure\\ResetTypesItem.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\treeStructure\\SingleComponentInstantiationItem.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\treeStructure\\SingleCpuItem.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\treeStructure\\SingleDesignConfigurationInstantiationItem.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\treeStructure\\SingleDesignInstantiationItem.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\treeStructure\\SingleIndirectInterfaceItem.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\treeStructure\\SingleModeItem.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\treeStructure\\SingleRemapStateItem.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\treeStructure\\SubspaceMapItem.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\treeStructure\\TransactionalPortsItem.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\treeStructure\\TypeDefinitionsItem.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\treeStructure\\WirePortsItem.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\views\\envidentifiereditor.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\views\\envidentifiersmodel.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\views\\vieweditor.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\views\\ViewsDelegate.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\views\\viewseditor.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\views\\viewsmodel.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\visualization\\AddressableItem.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\visualization\\fieldgapitem.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\visualization\\memorygapitem.cpp\" />\r\n    <ClCompile Include=\"editors\\ComponentEditor\\visualization\\memoryvisualizationitem.cpp\" />\r\n    <ClCompile Include=\"editors\\ConfigurationTools\\ViewConfigurer.cpp\" />\r\n    <ClCompile Include=\"editors\\ConfigurationTools\\ViewConfigurerDelegate.cpp\" />\r\n    <ClCompile Include=\"editors\\CSourceEditor\\CSourceContentMatcher.cpp\" />\r\n    <ClCompile Include=\"editors\\CSourceEditor\\CSourceHighlight.cpp\" />\r\n    <ClCompile Include=\"editors\\CSourceEditor\\CSourceHighlighter.cpp\" />\r\n    <ClCompile Include=\"editors\\CSourceEditor\\CSourceTextEdit.cpp\" />\r\n    <ClCompile Include=\"editors\\CSourceEditor\\CSourceWidget.cpp\" />\r\n    <ClCompile Include=\"editors\\HWDesign\\ActiveBusInterfaceItem.cpp\" />\r\n    <ClCompile Include=\"editors\\HWDesign\\ActivePortItem.cpp\" />\r\n    <ClCompile Include=\"editors\\HWDesign\\AdHocConnectionItem.cpp\" />\r\n    <ClCompile Include=\"editors\\HWDesign\\AdhocEditor\\AdhocEditor.cpp\" />\r\n    <ClCompile Include=\"editors\\HWDesign\\AdhocEditor\\AdhocPortEditor.cpp\" />\r\n    <ClCompile Include=\"editors\\HWDesign\\AdhocEditor\\AdHocVisibilityDelegate.cpp\" />\r\n    <ClCompile Include=\"editors\\HWDesign\\AdhocEditor\\AdHocVisibilityEditor.cpp\" />\r\n    <ClCompile Include=\"editors\\HWDesign\\AdhocEditor\\AdHocVisibilityModel.cpp\" />\r\n    <ClCompile Include=\"editors\\HWDesign\\AdhocEditor\\AdHocVisibilityPolicy.cpp\" />\r\n    <ClCompile Include=\"editors\\HWDesign\\AdHocEnabled.cpp\" />\r\n    <ClCompile Include=\"editors\\HWDesign\\AdHocItem.cpp\" />\r\n    <ClCompile Include=\"editors\\HWDesign\\BusInterfaceDialog.cpp\" />\r\n    <ClCompile Include=\"editors\\HWDesign\\BusInterfaceEndPoint.cpp\" />\r\n    <ClCompile Include=\"editors\\HWDesign\\columnview\\ColumnEditDialog.cpp\" />\r\n    <ClCompile Include=\"editors\\HWDesign\\columnview\\HWColumn.cpp\" />\r\n    <ClCompile Include=\"editors\\HWDesign\\HierarchicalBusInterfaceItem.cpp\" />\r\n    <ClCompile Include=\"editors\\HWDesign\\HierarchicalPortItem.cpp\" />\r\n    <ClCompile Include=\"editors\\HWDesign\\HWAddCommands.cpp\" />\r\n    <ClCompile Include=\"editors\\HWDesign\\HWChangeCommands.cpp\" />\r\n    <ClCompile Include=\"editors\\HWDesign\\HWComponentItem.cpp\" />\r\n    <ClCompile Include=\"editors\\HWDesign\\HWConnection.cpp\" />\r\n    <ClCompile Include=\"editors\\HWDesign\\HWConnectionEndPoint.cpp\" />\r\n    <ClCompile Include=\"editors\\HWDesign\\HWDesignDiagram.cpp\" />\r\n    <ClCompile Include=\"editors\\HWDesign\\HWDesignWidget.cpp\" />\r\n    <ClCompile Include=\"editors\\HWDesign\\HWMoveCommands.cpp\" />\r\n    <ClCompile Include=\"editors\\HWDesign\\OffPageConnectorItem.cpp\" />\r\n    <ClCompile Include=\"editors\\HWDesign\\PortmapDialog.cpp\" />\r\n    <ClCompile Include=\"editors\\HWDesign\\SelectItemTypeDialog.cpp\" />\r\n    <ClCompile Include=\"editors\\HWDesign\\undoCommands\\AdHocBoundsChangeCommand.cpp\" />\r\n    <ClCompile Include=\"editors\\HWDesign\\undoCommands\\AdHocConnectionAddCommand.cpp\" />\r\n    <ClCompile Include=\"editors\\HWDesign\\undoCommands\\AdHocConnectionDeleteCommand.cpp\" />\r\n    <ClCompile Include=\"editors\\HWDesign\\undoCommands\\AdHocTiedValueCommand.cpp\" />\r\n    <ClCompile Include=\"editors\\HWDesign\\undoCommands\\AdHocTieOffBoundsChangeCommand.cpp\" />\r\n    <ClCompile Include=\"editors\\HWDesign\\undoCommands\\AdHocTieOffChangeCommand.cpp\" />\r\n    <ClCompile Include=\"editors\\HWDesign\\undoCommands\\AdHocTieOffConnectionDeleteCommand.cpp\" />\r\n    <ClCompile Include=\"editors\\HWDesign\\undoCommands\\AdHocVisibilityChangeCommand.cpp\" />\r\n    <ClCompile Include=\"editors\\HWDesign\\undoCommands\\ColumnDeleteCommand.cpp\" />\r\n    <ClCompile Include=\"editors\\HWDesign\\undoCommands\\ComponentDeleteCommand.cpp\" />\r\n    <ClCompile Include=\"editors\\HWDesign\\undoCommands\\ComponentInstancePasteCommand.cpp\" />\r\n    <ClCompile Include=\"editors\\HWDesign\\undoCommands\\ComponentItemMoveCommand.cpp\" />\r\n    <ClCompile Include=\"editors\\HWDesign\\undoCommands\\ConfigurableElementChangeCommand.cpp\" />\r\n    <ClCompile Include=\"editors\\HWDesign\\undoCommands\\ConfigurableElementRemoveCommand.cpp\" />\r\n    <ClCompile Include=\"editors\\HWDesign\\undoCommands\\ConnectionDeleteCommand.cpp\" />\r\n    <ClCompile Include=\"editors\\HWDesign\\undoCommands\\HWColumnAddCommand.cpp\" />\r\n    <ClCompile Include=\"editors\\HWDesign\\undoCommands\\HWComponentAddCommand.cpp\" />\r\n    <ClCompile Include=\"editors\\HWDesign\\undoCommands\\InterfaceDeleteCommand.cpp\" />\r\n    <ClCompile Include=\"editors\\HWDesign\\undoCommands\\PhysicalPortDeleteCommand.cpp\" />\r\n    <ClCompile Include=\"editors\\HWDesign\\undoCommands\\PortDeleteCommand.cpp\" />\r\n    <ClCompile Include=\"editors\\HWDesign\\undoCommands\\PortPasteCommand.cpp\" />\r\n    <ClCompile Include=\"editors\\HWDesign\\undoCommands\\ReplaceComponentCommand.cpp\" />\r\n    <ClCompile Include=\"editors\\HWDesign\\undoCommands\\TopAdHocVisibilityChangeCommand.cpp\" />\r\n    <ClCompile Include=\"editors\\HWDesign\\WarningSymbol.cpp\" />\r\n    <ClCompile Include=\"editors\\InterconnectGenerator\\InstanceInterfacesEditor.cpp\" />\r\n    <ClCompile Include=\"editors\\InterconnectGenerator\\InterconnectAddressHelper.cpp\" />\r\n    <ClCompile Include=\"editors\\InterconnectGenerator\\InterconnectDataModel.cpp\" />\r\n    <ClCompile Include=\"editors\\InterconnectGenerator\\InterconnectGeneratorDialog.cpp\" />\r\n    <ClCompile Include=\"editors\\MemoryDesigner\\AddressBlockGraphicsItem.cpp\" />\r\n    <ClCompile Include=\"editors\\MemoryDesigner\\AddressSegmentGraphicsItem.cpp\" />\r\n    <ClCompile Include=\"editors\\MemoryDesigner\\AddressSpaceGraphicsItem.cpp\" />\r\n    <ClCompile Include=\"editors\\MemoryDesigner\\ConnectivityComponent.cpp\" />\r\n    <ClCompile Include=\"editors\\MemoryDesigner\\ConnectivityConnection.cpp\" />\r\n    <ClCompile Include=\"editors\\MemoryDesigner\\ConnectivityGraph.cpp\" />\r\n    <ClCompile Include=\"editors\\MemoryDesigner\\ConnectivityGraphFactory.cpp\" />\r\n    <ClCompile Include=\"editors\\MemoryDesigner\\ConnectivityInterface.cpp\" />\r\n    <ClCompile Include=\"editors\\MemoryDesigner\\FieldGraphicsItem.cpp\" />\r\n    <ClCompile Include=\"editors\\MemoryDesigner\\FieldOverlapItem.cpp\" />\r\n    <ClCompile Include=\"editors\\MemoryDesigner\\MainMemoryGraphicsItem.cpp\" />\r\n    <ClCompile Include=\"editors\\MemoryDesigner\\MasterSlavePathSearch.cpp\" />\r\n    <ClCompile Include=\"editors\\MemoryDesigner\\MemoryCollisionItem.cpp\" />\r\n    <ClCompile Include=\"editors\\MemoryDesigner\\MemoryColumn.cpp\" />\r\n    <ClCompile Include=\"editors\\MemoryDesigner\\MemoryColumnHandler.cpp\" />\r\n    <ClCompile Include=\"editors\\MemoryDesigner\\MemoryConnectionAddressCalculator.cpp\" />\r\n    <ClCompile Include=\"editors\\MemoryDesigner\\MemoryConnectionHandler.cpp\" />\r\n    <ClCompile Include=\"editors\\MemoryDesigner\\MemoryConnectionItem.cpp\" />\r\n    <ClCompile Include=\"editors\\MemoryDesigner\\MemoryDesignConstructor.cpp\" />\r\n    <ClCompile Include=\"editors\\MemoryDesigner\\MemoryDesignDocument.cpp\" />\r\n    <ClCompile Include=\"editors\\MemoryDesigner\\MemoryDesignerChildGraphicsItem.cpp\" />\r\n    <ClCompile Include=\"editors\\MemoryDesigner\\MemoryDesignerConstants.cpp\" />\r\n    <ClCompile Include=\"editors\\MemoryDesigner\\MemoryDesignerDiagram.cpp\" />\r\n    <ClCompile Include=\"editors\\MemoryDesigner\\MemoryDesignerGraphicsItem.cpp\" />\r\n    <ClCompile Include=\"editors\\MemoryDesigner\\MemoryExtensionGraphicsItem.cpp\" />\r\n    <ClCompile Include=\"editors\\MemoryDesigner\\MemoryGraphicsItemHandler.cpp\" />\r\n    <ClCompile Include=\"editors\\MemoryDesigner\\MemoryItem.cpp\" />\r\n    <ClCompile Include=\"editors\\MemoryDesigner\\MemoryMapGraphicsItem.cpp\" />\r\n    <ClCompile Include=\"editors\\MemoryDesigner\\RegisterGraphicsItem.cpp\" />\r\n    <ClCompile Include=\"editors\\MemoryDesigner\\SubMemoryLayout.cpp\" />\r\n    <ClCompile Include=\"editors\\PythonSourceEditor\\PythonSourceEditor.cpp\" />\r\n    <ClCompile Include=\"editors\\PythonSourceEditor\\PythonSourceHighlight.cpp\" />\r\n    <ClCompile Include=\"editors\\PythonSourceEditor\\ScriptingSideArea.cpp\" />\r\n    <ClCompile Include=\"editors\\PythonSourceEditor\\ScriptInputEditor.cpp\" />\r\n    <ClCompile Include=\"editors\\PythonSourceEditor\\ScriptViewEditor.cpp\" />\r\n    <ClCompile Include=\"editors\\SystemDesign\\ApiGraphicsConnection.cpp\" />\r\n    <ClCompile Include=\"editors\\SystemDesign\\ComGraphicsConnection.cpp\" />\r\n    <ClCompile Include=\"editors\\SystemDesign\\HWMappingItem.cpp\" />\r\n    <ClCompile Include=\"editors\\SystemDesign\\SWComponentItem.cpp\" />\r\n    <ClCompile Include=\"editors\\SystemDesign\\SWConnectionEndpoint.cpp\" />\r\n    <ClCompile Include=\"editors\\SystemDesign\\SWInterfaceItem.cpp\" />\r\n    <ClCompile Include=\"editors\\SystemDesign\\SWPortItem.cpp\" />\r\n    <ClCompile Include=\"editors\\SystemDesign\\SystemColumn.cpp\" />\r\n    <ClCompile Include=\"editors\\SystemDesign\\SystemComponentItem.cpp\" />\r\n    <ClCompile Include=\"editors\\SystemDesign\\SystemDesignDiagram.cpp\" />\r\n    <ClCompile Include=\"editors\\SystemDesign\\SystemDesignWidget.cpp\" />\r\n    <ClCompile Include=\"editors\\SystemDesign\\SystemDetailsEditor\\ExportSWDialog.cpp\" />\r\n    <ClCompile Include=\"editors\\SystemDesign\\SystemDetailsEditor\\SwitchHWDialog.cpp\" />\r\n    <ClCompile Include=\"editors\\SystemDesign\\SystemDetailsEditor\\SystemDetailsEditor.cpp\" />\r\n    <ClCompile Include=\"editors\\SystemDesign\\UndoCommands\\ApiConnectionAddCommand.cpp\" />\r\n    <ClCompile Include=\"editors\\SystemDesign\\UndoCommands\\ApiConnectionDeleteCommand.cpp\" />\r\n    <ClCompile Include=\"editors\\SystemDesign\\UndoCommands\\ApiConnectionExchangeCommand.cpp\" />\r\n    <ClCompile Include=\"editors\\SystemDesign\\UndoCommands\\ComConnectionAddCommand.cpp\" />\r\n    <ClCompile Include=\"editors\\SystemDesign\\UndoCommands\\ComConnectionDeleteCommand.cpp\" />\r\n    <ClCompile Include=\"editors\\SystemDesign\\UndoCommands\\ComConnectionExchangeCommand.cpp\" />\r\n    <ClCompile Include=\"editors\\SystemDesign\\UndoCommands\\ReplaceSystemComponentCommand.cpp\" />\r\n    <ClCompile Include=\"editors\\SystemDesign\\UndoCommands\\SWInterfaceAddCommand.cpp\" />\r\n    <ClCompile Include=\"editors\\SystemDesign\\UndoCommands\\SWInterfaceDeleteCommand.cpp\" />\r\n    <ClCompile Include=\"editors\\SystemDesign\\UndoCommands\\SWInterfaceMoveCommand.cpp\" />\r\n    <ClCompile Include=\"editors\\SystemDesign\\UndoCommands\\SWPortDeleteCommand.cpp\" />\r\n    <ClCompile Include=\"editors\\SystemDesign\\UndoCommands\\SystemAddCommands.cpp\" />\r\n    <ClCompile Include=\"editors\\SystemDesign\\UndoCommands\\SystemChangeCommands.cpp\" />\r\n    <ClCompile Include=\"editors\\SystemDesign\\UndoCommands\\SystemComponentAddCommand.cpp\" />\r\n    <ClCompile Include=\"editors\\SystemDesign\\UndoCommands\\SystemComponentDeleteCommand.cpp\" />\r\n    <ClCompile Include=\"editors\\SystemDesign\\UndoCommands\\SystemDeleteCommands.cpp\" />\r\n    <ClCompile Include=\"editors\\SystemDesign\\UndoCommands\\SystemMoveCommands.cpp\" />\r\n    <ClCompile Include=\"Help\\HelpSystem\\ContextHelpBrowser.cpp\" />\r\n    <ClCompile Include=\"Help\\HelpSystem\\HelpSearchWidget.cpp\" />\r\n    <ClCompile Include=\"Help\\HelpSystem\\HelpWindow.cpp\" />\r\n    <ClCompile Include=\"kactusGenerators\\DocumentGenerator\\DocumentationWriter.cpp\" />\r\n    <ClCompile Include=\"kactusGenerators\\DocumentGenerator\\documentgenerator.cpp\" />\r\n    <ClCompile Include=\"kactusGenerators\\DocumentGenerator\\HtmlWriter.cpp\" />\r\n    <ClCompile Include=\"kactusGenerators\\DocumentGenerator\\MarkdownWriter.cpp\" />\r\n    <ClCompile Include=\"library\\HierarchyView\\hierarchyfilter.cpp\" />\r\n    <ClCompile Include=\"library\\HierarchyView\\hierarchyview.cpp\" />\r\n    <ClCompile Include=\"library\\HierarchyView\\hierarchywidget.cpp\" />\r\n    <ClCompile Include=\"library\\ItemExporter.cpp\" />\r\n    <ClCompile Include=\"library\\LibraryErrorModel.cpp\" />\r\n    <ClCompile Include=\"library\\LibraryFilter.cpp\" />\r\n    <ClCompile Include=\"library\\LibraryItemSelectionFactory.cpp\" />\r\n    <ClCompile Include=\"library\\LibraryTreeFilter.cpp\" />\r\n    <ClCompile Include=\"library\\LibraryTreeView.cpp\" />\r\n    <ClCompile Include=\"library\\LibraryTreeWidget.cpp\" />\r\n    <ClCompile Include=\"library\\LibraryUtils.cpp\" />\r\n    <ClCompile Include=\"library\\LibraryWidget.cpp\" />\r\n    <ClCompile Include=\"library\\ObjectExportDialog.cpp\" />\r\n    <ClCompile Include=\"library\\objectremovedialog.cpp\" />\r\n    <ClCompile Include=\"library\\ObjectSelectionDialog.cpp\" />\r\n    <ClCompile Include=\"library\\ObjectSelectionListItem.cpp\" />\r\n    <ClCompile Include=\"library\\TableViewDialog.cpp\" />\r\n    <ClCompile Include=\"library\\VLNVDialer\\FilterGroup.cpp\" />\r\n    <ClCompile Include=\"library\\VLNVDialer\\filterwidget.cpp\" />\r\n    <ClCompile Include=\"library\\VLNVDialer\\firmnessgroup.cpp\" />\r\n    <ClCompile Include=\"library\\VLNVDialer\\hierarchygroup.cpp\" />\r\n    <ClCompile Include=\"library\\VLNVDialer\\implementationgroup.cpp\" />\r\n    <ClCompile Include=\"library\\VLNVDialer\\RevisionGroup.cpp\" />\r\n    <ClCompile Include=\"library\\VLNVDialer\\typegroup.cpp\" />\r\n    <ClCompile Include=\"library\\VLNVDialer\\ValidityGroup.cpp\" />\r\n    <ClCompile Include=\"library\\VLNVDialer\\vlnvdialer.cpp\" />\r\n    <ClCompile Include=\"mainwindow\\CommandLineParser.cpp\" />\r\n    <ClCompile Include=\"mainwindow\\DeleteWorkspaceDialog.cpp\" />\r\n    <ClCompile Include=\"mainwindow\\DockWidgetHandler.cpp\" />\r\n    <ClCompile Include=\"mainwindow\\DrawingBoard\\DrawingBoard.cpp\" />\r\n    <ClCompile Include=\"mainwindow\\main.cpp\" />\r\n    <ClCompile Include=\"mainwindow\\mainwindow.cpp\" />\r\n    <ClCompile Include=\"mainwindow\\MessageConsole\\messageconsole.cpp\" />\r\n    <ClCompile Include=\"mainwindow\\NewPages\\NewApiDefinitionPage.cpp\" />\r\n    <ClCompile Include=\"mainwindow\\NewPages\\NewBusDefinitionPage.cpp\" />\r\n    <ClCompile Include=\"mainwindow\\NewPages\\NewCatalogPage.cpp\" />\r\n    <ClCompile Include=\"mainwindow\\NewPages\\NewComDefinitionPage.cpp\" />\r\n    <ClCompile Include=\"mainwindow\\NewPages\\NewComponentPage.cpp\" />\r\n    <ClCompile Include=\"mainwindow\\NewPages\\NewDesignPage.cpp\" />\r\n    <ClCompile Include=\"mainwindow\\NewPages\\NewPage.cpp\" />\r\n    <ClCompile Include=\"mainwindow\\NewPages\\NewSWComponentPage.cpp\" />\r\n    <ClCompile Include=\"mainwindow\\NewPages\\NewSWDesignPage.cpp\" />\r\n    <ClCompile Include=\"mainwindow\\NewPages\\NewSystemPage.cpp\" />\r\n    <ClCompile Include=\"mainwindow\\NewWorkspaceDialog.cpp\" />\r\n    <ClCompile Include=\"mainwindow\\Ribbon\\Ribbon.cpp\" />\r\n    <ClCompile Include=\"mainwindow\\Ribbon\\RibbonGroup.cpp\" />\r\n    <ClCompile Include=\"mainwindow\\SaveHierarchy\\DocumentTreeBuilder.cpp\" />\r\n    <ClCompile Include=\"mainwindow\\SaveHierarchy\\HierarchicalSaveBuildStrategy.cpp\" />\r\n    <ClCompile Include=\"mainwindow\\SaveHierarchy\\SaveAsItem.cpp\" />\r\n    <ClCompile Include=\"mainwindow\\SaveHierarchy\\SaveHierarchyDelegate.cpp\" />\r\n    <ClCompile Include=\"mainwindow\\SaveHierarchy\\SaveHierarchyDialog.cpp\" />\r\n    <ClCompile Include=\"mainwindow\\SplashScreen.cpp\" />\r\n    <ClCompile Include=\"mainwindow\\WorkspaceSettings.cpp\" />\r\n    <ClCompile Include=\"Plugins\\common\\ConnectivityGraphUtilities.cpp\" />\r\n    <ClCompile Include=\"Plugins\\common\\CpuRoutesContainer.cpp\" />\r\n    <ClCompile Include=\"Plugins\\common\\LanguageHighlighter.cpp\" />\r\n    <ClCompile Include=\"Plugins\\common\\SingleCpuRoutesContainer.cpp\" />\r\n    <ClCompile Include=\"Plugins\\common\\SourceHighlightStyle.cpp\" />\r\n    <ClCompile Include=\"Plugins\\PluginSystem\\GeneratorPlugin\\AddToFilesetWidget.cpp\" />\r\n    <ClCompile Include=\"PythonAPI\\ChannelRelay.cpp\" />\r\n    <ClCompile Include=\"PythonAPI\\extensions\\IOCatcher.cpp\" />\r\n    <ClCompile Include=\"PythonAPI\\FileChannel.cpp\" />\r\n    <ClCompile Include=\"PythonAPI\\PythonInterpreter.cpp\" />\r\n    <ClCompile Include=\"PythonAPI\\StdInputListener.cpp\" />\r\n    <ClCompile Include=\"settings\\ComponentEditorSettingsPage.cpp\" />\r\n    <ClCompile Include=\"settings\\FileTypesDelegate.cpp\" />\r\n    <ClCompile Include=\"settings\\FileTypeSettingsPage.cpp\" />\r\n    <ClCompile Include=\"settings\\FileTypesModel.cpp\" />\r\n    <ClCompile Include=\"settings\\filetypesview.cpp\" />\r\n    <ClCompile Include=\"settings\\k2envvariablesettingspage.cpp\" />\r\n    <ClCompile Include=\"settings\\k2envvarmodel.cpp\" />\r\n    <ClCompile Include=\"settings\\NewPluginsDialog.cpp\" />\r\n    <ClCompile Include=\"settings\\PluginInfoWidget.cpp\" />\r\n    <ClCompile Include=\"settings\\PluginSettingsPage.cpp\" />\r\n    <ClCompile Include=\"settings\\CodeEditorSettingsPage.cpp\" />\r\n    <ClCompile Include=\"settings\\GeneralSettingsPage.cpp\" />\r\n    <ClCompile Include=\"settings\\NamingPolicySettingsPage.cpp\" />\r\n    <ClCompile Include=\"settings\\SettingsDialog.cpp\" />\r\n    <ClCompile Include=\"settings\\SettingsPage.cpp\" />\r\n    <ClCompile Include=\"settings\\SettingsUpdater.cpp\" />\r\n    <ClCompile Include=\"wizards\\BusInterfaceWizard\\BusInterfaceWizard.cpp\" />\r\n    <ClCompile Include=\"wizards\\BusInterfaceWizard\\BusInterfaceWizardAbsDefinitionPage.cpp\" />\r\n    <ClCompile Include=\"wizards\\BusInterfaceWizard\\BusInterfaceWizardBusDefinitionPage.cpp\" />\r\n    <ClCompile Include=\"wizards\\BusInterfaceWizard\\BusInterfaceWizardConclusionPage.cpp\" />\r\n    <ClCompile Include=\"wizards\\BusInterfaceWizard\\BusInterfaceWizardGeneralOptionsPage.cpp\" />\r\n    <ClCompile Include=\"wizards\\BusInterfaceWizard\\BusInterfaceWizardIntroPage.cpp\" />\r\n    <ClCompile Include=\"wizards\\BusInterfaceWizard\\BusInterfaceWizardPortMapPage.cpp\" />\r\n    <ClCompile Include=\"wizards\\common\\ComponentComparator\\ComponentComparator.cpp\" />\r\n    <ClCompile Include=\"wizards\\common\\ComponentDiffWidget\\ComponentDiffWidget.cpp\" />\r\n    <ClCompile Include=\"wizards\\common\\IPXactDiff.cpp\" />\r\n    <ClCompile Include=\"wizards\\common\\ModuleParameterComparator\\ModuleParameterComparator.cpp\" />\r\n    <ClCompile Include=\"wizards\\common\\ParameterComparator\\ParameterComparator.cpp\" />\r\n    <ClCompile Include=\"wizards\\common\\PortComparator\\PortComparator.cpp\" />\r\n    <ClCompile Include=\"wizards\\common\\ViewComparator\\ViewComparator.cpp\" />\r\n    <ClCompile Include=\"wizards\\common\\VLNVComparator\\VLNVComparator.cpp\" />\r\n    <ClCompile Include=\"wizards\\ComponentWizard\\ComponentWizard.cpp\" />\r\n    <ClCompile Include=\"wizards\\ComponentWizard\\ComponentWizardConclusionPage.cpp\" />\r\n    <ClCompile Include=\"wizards\\ComponentWizard\\ComponentWizardDependencyPage.cpp\" />\r\n    <ClCompile Include=\"wizards\\ComponentWizard\\ComponentWizardGeneralInfoPage.cpp\" />\r\n    <ClCompile Include=\"wizards\\ComponentWizard\\ComponentWizardImportPage.cpp\" />\r\n    <ClCompile Include=\"wizards\\ComponentWizard\\ComponentWizardIntroPage.cpp\" />\r\n    <ClCompile Include=\"wizards\\ComponentWizard\\ComponentWizardViewsPage.cpp\" />\r\n    <ClCompile Include=\"wizards\\ComponentWizard\\ImportEditor.cpp\" />\r\n    <ClCompile Include=\"wizards\\ComponentWizard\\ViewListModel.cpp\" />\r\n    <ClCompile Include=\"wizards\\ImportWizard\\ImportInstancesEditor\\ImportInstancesDelegate.cpp\" />\r\n    <ClCompile Include=\"wizards\\ImportWizard\\ImportInstancesEditor\\ImportInstancesEditor.cpp\" />\r\n    <ClCompile Include=\"wizards\\ImportWizard\\ImportWizard.cpp\" />\r\n    <ClCompile Include=\"wizards\\ImportWizard\\ImportWizardImportPage.cpp\" />\r\n    <ClCompile Include=\"wizards\\ImportWizard\\ImportWizardInstancesPage.cpp\" />\r\n    <ClCompile Include=\"wizards\\ImportWizard\\ImportWizardIntroPage.cpp\" />\r\n  </ItemGroup>\r\n  <ItemGroup>\r\n    <CustomBuild Include=\"common\\layouts\\HCollisionLayout.inl\">\r\n      <Message Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">Performing Custom Build Step</Message>\r\n      <Command Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n      </Command>\r\n      <AdditionalInputs Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">%(AdditionalInputs)</AdditionalInputs>\r\n      <Outputs Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">%(Outputs)</Outputs>\r\n      <Message Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">Performing Custom Build Step</Message>\r\n      <Command Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n      </Command>\r\n      <AdditionalInputs Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">%(AdditionalInputs)</AdditionalInputs>\r\n      <Outputs Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">%(Outputs)</Outputs>\r\n    </CustomBuild>\r\n    <CustomBuild Include=\"common\\layouts\\HStackedLayout.inl\">\r\n      <Message Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">Performing Custom Build Step</Message>\r\n      <Command Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n      </Command>\r\n      <AdditionalInputs Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">%(AdditionalInputs)</AdditionalInputs>\r\n      <Outputs Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">%(Outputs)</Outputs>\r\n      <Message Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">Performing Custom Build Step</Message>\r\n      <Command Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n      </Command>\r\n      <AdditionalInputs Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">%(AdditionalInputs)</AdditionalInputs>\r\n      <Outputs Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">%(Outputs)</Outputs>\r\n    </CustomBuild>\r\n    <CustomBuild Include=\"common\\layouts\\VCollisionLayout.inl\">\r\n      <Message Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">Performing Custom Build Step</Message>\r\n      <Command Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n      </Command>\r\n      <AdditionalInputs Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">%(AdditionalInputs)</AdditionalInputs>\r\n      <Outputs Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">%(Outputs)</Outputs>\r\n      <Message Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">Performing Custom Build Step</Message>\r\n      <Command Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n      </Command>\r\n      <AdditionalInputs Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">%(AdditionalInputs)</AdditionalInputs>\r\n      <Outputs Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">%(Outputs)</Outputs>\r\n    </CustomBuild>\r\n    <CustomBuild Include=\"common\\layouts\\VStackedLayout.inl\">\r\n      <Message Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">Performing Custom Build Step</Message>\r\n      <Command Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n      </Command>\r\n      <AdditionalInputs Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">%(AdditionalInputs)</AdditionalInputs>\r\n      <Outputs Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">%(Outputs)</Outputs>\r\n      <Message Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">Performing Custom Build Step</Message>\r\n      <Command Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n      </Command>\r\n      <AdditionalInputs Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">%(AdditionalInputs)</AdditionalInputs>\r\n      <Outputs Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">%(Outputs)</Outputs>\r\n    </CustomBuild>\r\n    <CustomBuild Include=\"common\\layouts\\VStaticLayout.inl\">\r\n      <Message Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">Performing Custom Build Step</Message>\r\n      <Command Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n      </Command>\r\n      <AdditionalInputs Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">%(AdditionalInputs)</AdditionalInputs>\r\n      <Outputs Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">%(Outputs)</Outputs>\r\n      <Message Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">Performing Custom Build Step</Message>\r\n      <Command Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n      </Command>\r\n      <AdditionalInputs Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">%(AdditionalInputs)</AdditionalInputs>\r\n      <Outputs Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">%(Outputs)</Outputs>\r\n    </CustomBuild>\r\n    <QtRcc Include=\"kactus.qrc\">\r\n    </QtRcc>\r\n    <CustomBuild Include=\"Help\\kactus2help.qhcp\">\r\n      <Message Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">Performing Custom Build Step</Message>\r\n      <Command Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n      </Command>\r\n      <AdditionalInputs Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">%(AdditionalInputs)</AdditionalInputs>\r\n      <Outputs Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">%(Outputs)</Outputs>\r\n      <Message Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">Performing Custom Build Step</Message>\r\n      <Command Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n      </Command>\r\n      <AdditionalInputs Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">%(AdditionalInputs)</AdditionalInputs>\r\n      <Outputs Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">%(Outputs)</Outputs>\r\n    </CustomBuild>\r\n    <CustomBuild Include=\"Help\\kactus2help.qhp\">\r\n      <Message Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">Performing Custom Build Step</Message>\r\n      <Command Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n      </Command>\r\n      <AdditionalInputs Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">%(AdditionalInputs)</AdditionalInputs>\r\n      <Outputs Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">%(Outputs)</Outputs>\r\n      <Message Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">Performing Custom Build Step</Message>\r\n      <Command Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n      </Command>\r\n      <AdditionalInputs Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">%(AdditionalInputs)</AdditionalInputs>\r\n      <Outputs Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">%(Outputs)</Outputs>\r\n      <SubType>Designer</SubType>\r\n    </CustomBuild>\r\n    <CustomBuild Include=\"Kactus2.pri\">\r\n      <Message Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">Performing Custom Build Step</Message>\r\n      <Command Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n      </Command>\r\n      <AdditionalInputs Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">%(AdditionalInputs)</AdditionalInputs>\r\n      <Outputs Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">%(Outputs)</Outputs>\r\n      <Message Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">Performing Custom Build Step</Message>\r\n      <Command Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n      </Command>\r\n      <AdditionalInputs Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">%(AdditionalInputs)</AdditionalInputs>\r\n      <Outputs Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">%(Outputs)</Outputs>\r\n    </CustomBuild>\r\n    <CustomBuild Include=\"Kactus2.pro\">\r\n      <Message Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">Performing Custom Build Step</Message>\r\n      <Command Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n      </Command>\r\n      <AdditionalInputs Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">%(AdditionalInputs)</AdditionalInputs>\r\n      <Outputs Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">%(Outputs)</Outputs>\r\n      <Message Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">Performing Custom Build Step</Message>\r\n      <Command Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n      </Command>\r\n      <AdditionalInputs Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">%(AdditionalInputs)</AdditionalInputs>\r\n      <Outputs Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">%(Outputs)</Outputs>\r\n    </CustomBuild>\r\n  </ItemGroup>\r\n  <ItemGroup>\r\n    <CustomBuild Include=\"version.h\">\r\n      <ExcludedFromBuild Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">true</ExcludedFromBuild>\r\n      <Message Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">Performing Custom Build Step</Message>\r\n      <Command Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n      </Command>\r\n      <AdditionalInputs Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">%(AdditionalInputs)</AdditionalInputs>\r\n      <Outputs Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">%(Outputs)</Outputs>\r\n      <Message Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">Performing Custom Build Step</Message>\r\n      <Command Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n      </Command>\r\n      <AdditionalInputs Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">%(AdditionalInputs)</AdditionalInputs>\r\n      <Outputs Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">%(Outputs)</Outputs>\r\n    </CustomBuild>\r\n  </ItemGroup>\r\n  <ItemGroup>\r\n    <QtMoc Include=\"wizards\\common\\ComponentDiffWidget\\ComponentDiffWidget.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\treeStructure\\ComponentEditorChoicesItem.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\choices\\ChoicesEditor.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\choices\\ChoicesModel.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\choices\\EnumerationModel.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"common\\widgets\\ParameterGroupBox\\parametergroupbox.h\">\r\n    </QtMoc>\r\n    <CustomBuild Include=\"common\\dialogs\\LibrarySettingsDialog\\LibrarySettingsColumns.h\">\r\n      <AdditionalInputs Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">%(AdditionalInputs)</AdditionalInputs>\r\n      <Message Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n      </Message>\r\n      <Outputs Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n      </Outputs>\r\n      <Command Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n      </Command>\r\n      <AdditionalInputs Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">%(AdditionalInputs)</AdditionalInputs>\r\n      <Message Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n      </Message>\r\n      <Outputs Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n      </Outputs>\r\n      <Command Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n      </Command>\r\n      <AdditionalInputs Condition=\"'$(Configuration)|$(Platform)'=='Template|x64'\">%(AdditionalInputs)</AdditionalInputs>\r\n      <Message Condition=\"'$(Configuration)|$(Platform)'=='Template|x64'\">\r\n      </Message>\r\n      <Outputs Condition=\"'$(Configuration)|$(Platform)'=='Template|x64'\">\r\n      </Outputs>\r\n      <Command Condition=\"'$(Configuration)|$(Platform)'=='Template|x64'\">\r\n      </Command>\r\n    </CustomBuild>\r\n    <ClInclude Include=\"common\\expressions\\utilities.h\" />\r\n    <ClInclude Include=\"common\\graphicsItems\\ConnectionItem.h\" />\r\n    <ClInclude Include=\"common\\graphicsItems\\GraphicsColumnAddCommand.h\" />\r\n    <CustomBuild Include=\"common\\graphicsItems\\GraphicsColumnConstants.h\">\r\n      <AdditionalInputs Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">%(AdditionalInputs)</AdditionalInputs>\r\n      <Message Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n      </Message>\r\n      <Outputs Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n      </Outputs>\r\n      <Command Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n      </Command>\r\n      <AdditionalInputs Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">%(AdditionalInputs)</AdditionalInputs>\r\n      <Message Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n      </Message>\r\n      <Outputs Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n      </Outputs>\r\n      <Command Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n      </Command>\r\n      <AdditionalInputs Condition=\"'$(Configuration)|$(Platform)'=='Template|x64'\">%(AdditionalInputs)</AdditionalInputs>\r\n      <Message Condition=\"'$(Configuration)|$(Platform)'=='Template|x64'\">\r\n      </Message>\r\n      <Outputs Condition=\"'$(Configuration)|$(Platform)'=='Template|x64'\">\r\n      </Outputs>\r\n      <Command Condition=\"'$(Configuration)|$(Platform)'=='Template|x64'\">\r\n      </Command>\r\n    </CustomBuild>\r\n    <ClInclude Include=\"common\\layouts\\VNoCollisionNoMovementLayout.h\" />\r\n    <ClInclude Include=\"common\\NameGenerationPolicy.h\" />\r\n    <QtMoc Include=\"common\\views\\EditableTreeView\\EditableTreeView.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"common\\views\\EditableTreeView\\EditableTreeSortFilter.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"common\\ui\\GraphicalMessageMediator.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\common\\AbstractParameterModel.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\common\\ExpressionDelegate.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\common\\ExpressionEditor.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\addressSpaces\\SegmentDelegate.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"common\\widgets\\tagEditor\\TagLabel.h\">\r\n    </QtMoc>\r\n    <CustomBuild Include=\"common\\widgets\\tagEditor\\FlowLayout.h\">\r\n      <Message Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n      </Message>\r\n      <Outputs Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n      </Outputs>\r\n      <Command Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n      </Command>\r\n      <Message Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n      </Message>\r\n      <Outputs Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n      </Outputs>\r\n      <Command Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n      </Command>\r\n      <Message Condition=\"'$(Configuration)|$(Platform)'=='Template|x64'\">\r\n      </Message>\r\n      <Outputs Condition=\"'$(Configuration)|$(Platform)'=='Template|x64'\">\r\n      </Outputs>\r\n      <Command Condition=\"'$(Configuration)|$(Platform)'=='Template|x64'\">\r\n      </Command>\r\n    </CustomBuild>\r\n    <QtMoc Include=\"common\\widgets\\tagEditor\\TagContainer.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"common\\widgets\\tagEditor\\TagEditor.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"common\\widgets\\tagEditor\\TagCompleterModel.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"common\\widgets\\tagEditor\\TagEditorContainer.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"common\\widgets\\tagEditor\\TagDisplay.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"common\\widgets\\busReferenceComboBox\\BusReferenceComboBox.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"common\\widgets\\segmentComboBox\\SegmentComboBox.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"common\\widgets\\tagEditor\\TagSelectorContainer.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"common\\widgets\\tagEditor\\TagSelector.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"common\\views\\ExpandingTreeView\\ExpandingTreeView.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"common\\widgets\\EnumCollectionEditor\\EnumerationEditor.h\" />\r\n    <QtMoc Include=\"editors\\AbstractionDefinitionEditor\\absdefgroup.h\" />\r\n    <QtMoc Include=\"editors\\AbstractionDefinitionEditor\\AbstractionDefinitionEditor.h\" />\r\n    <QtMoc Include=\"common\\widgets\\TreeItemSelector\\TreeItemEditor.h\" />\r\n    <QtMoc Include=\"common\\widgets\\TreeItemSelector\\TreeItemModel.h\" />\r\n    <QtMoc Include=\"common\\widgets\\TreeItemSelector\\FramedTreeItemEditor.h\" />\r\n    <QtMoc Include=\"common\\widgets\\GroupBoxWithAlertSign\\GroupBoxWithAlertSign.h\" />\r\n    <QtMoc Include=\"common\\widgets\\GroupBoxWithAlertSign\\StyleGroupBoxWithAlertSign.h\" />\r\n    <QtMoc Include=\"common\\widgets\\EnumCollectionEditor\\InterfaceEnumEditor.h\" />\r\n    <ClInclude Include=\"common\\widgets\\GroupBoxWithAlertSign\\StyleOptionGroupBoxWithAlertSign.h\" />\r\n    <QtMoc Include=\"common\\widgets\\instanceWidgets\\InstanceWidgets.h\" />\r\n    <ClInclude Include=\"common\\widgets\\TreeItemSelector\\TreeItem.h\" />\r\n    <QtMoc Include=\"editors\\AbstractionDefinitionEditor\\AbsDefParameterReferenceCounter.h\" />\r\n    <QtMoc Include=\"editors\\AbstractionDefinitionEditor\\AbsDefParameterReferenceTree.h\" />\r\n    <ClInclude Include=\"editors\\AbstractionDefinitionEditor\\AbstractionDefinitionPortsSortFilter.h\" />\r\n    <ClInclude Include=\"editors\\AbstractionDefinitionEditor\\AbstractionDefinitionSignalRow.h\" />\r\n    <QtMoc Include=\"editors\\AbstractionDefinitionEditor\\AbstractionPortsDelegate.h\" />\r\n    <QtMoc Include=\"editors\\AbstractionDefinitionEditor\\AbstractionPortsEditor.h\" />\r\n    <QtMoc Include=\"editors\\AbstractionDefinitionEditor\\AbstractionPortsModel.h\" />\r\n    <QtMoc Include=\"editors\\AbstractionDefinitionEditor\\AbstractionPortsView.h\" />\r\n    <QtMoc Include=\"editors\\AbstractionDefinitionEditor\\AbstractionTransactionalPortsDelegate.h\" />\r\n    <ClInclude Include=\"editors\\AbstractionDefinitionEditor\\AbstractionTransactionalPortsSortFilter.h\" />\r\n    <QtMoc Include=\"editors\\AbstractionDefinitionEditor\\AbstractionWirePortsDelegate.h\" />\r\n    <ClInclude Include=\"editors\\AbstractionDefinitionEditor\\AbstractionWirePortsSortFilter.h\" />\r\n    <ClInclude Include=\"editors\\AbstractionDefinitionEditor\\LogicalPortColumns.h\" />\r\n    <QtMoc Include=\"editors\\AbstractionDefinitionEditor\\QualifierEditor.h\" />\r\n    <ClInclude Include=\"editors\\AbstractionDefinitionEditor\\QualifierData.h\" />\r\n    <ClInclude Include=\"editors\\ApiDefinitionEditor\\ApiFunctionColumns.h\" />\r\n    <QtMoc Include=\"editors\\BusDefinitionEditor\\busdefgroup.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\BusDefinitionEditor\\BusDefinitionEditor.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\BusDefinitionEditor\\BusDefinitionParameterReferenceTree.h\" />\r\n    <ClInclude Include=\"editors\\BusDefinitionEditor\\LogicalPortColumns.h\" />\r\n    <QtMoc Include=\"editors\\CatalogEditor\\CatalogEditor.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\CatalogEditor\\CatalogFileModel.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\BusDefinitionEditor\\SystemGroupListEditor.h\">\r\n    </QtMoc>\r\n    <ClInclude Include=\"editors\\CatalogEditor\\CatalogFileColumns.h\" />\r\n    <QtMoc Include=\"editors\\CatalogEditor\\CatalogFileDelegate.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\CatalogEditor\\CatalogFileFilter.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\CatalogEditor\\CatalogFileView.h\">\r\n    </QtMoc>\r\n    <ClInclude Include=\"editors\\ComDefinitionEditor\\ComPropertyColumns.h\" />\r\n    <ClInclude Include=\"editors\\common\\Association\\Associable.h\" />\r\n    <ClInclude Include=\"editors\\common\\Association\\Association.h\" />\r\n    <ClInclude Include=\"editors\\common\\Association\\AssociationAddCommand.h\" />\r\n    <ClInclude Include=\"editors\\common\\Association\\AssociationChangeEndpointCommand.h\" />\r\n    <ClInclude Include=\"editors\\common\\Association\\AssociationRemoveCommand.h\" />\r\n    <QtMoc Include=\"editors\\common\\ComponentInstanceEditor\\ComponentInstanceConfigurableElementsEditor.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\common\\ComponentInstanceEditor\\ComponentInstanceConfigurableElementsFilter.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\common\\ComponentInstanceEditor\\ComponentInstanceConfigurableElementsModel.h\">\r\n    </QtMoc>\r\n    <ClInclude Include=\"editors\\common\\ColumnTypes.h\" />\r\n    <QtMoc Include=\"editors\\common\\ComponentDesignDiagram.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\common\\ComponentInstanceEditor\\componentinstanceeditor.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\common\\ComponentInstanceEditor\\configurableelementdelegate.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\common\\ComponentInstanceEditor\\configurableelementeditor.h\">\r\n    </QtMoc>\r\n    <ClInclude Include=\"editors\\common\\ComponentInstanceEditor\\ConfigurableElementsColumns.h\" />\r\n    <QtMoc Include=\"editors\\common\\ComponentInstanceEditor\\ConfigurableElementsFilter.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\common\\ComponentInstanceEditor\\ConfigurableElementsModel.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\common\\ComponentInstanceEditor\\ConfigurableElementsView.h\">\r\n    </QtMoc>\r\n    <ClInclude Include=\"editors\\common\\ComponentInstanceEditor\\EditorConfigurableElement.h\" />\r\n    <QtMoc Include=\"editors\\common\\ComponentInstanceEditor\\MissingConfigurableElementsFilter.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\common\\ComponentInstanceEditor\\ParameterConfigurableElementsFilter.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\common\\ConfigurationEditor\\configurationeditor.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\common\\ConfigurationEditor\\activeviewdelegate.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\common\\ConfigurationEditor\\activevieweditor.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\common\\ConfigurationEditor\\activeviewmodel.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\common\\ComponentItemAutoConnector\\ComponentItemAutoConnector.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\common\\ComponentItemAutoConnector\\AutoConnectorConnectionTable.h\">\r\n    </QtMoc>\r\n    <CustomBuild Include=\"editors\\common\\ComponentItemAutoConnector\\AutoConnectorItem.h\">\r\n      <Message Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n      </Message>\r\n      <Outputs Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n      </Outputs>\r\n      <Command Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n      </Command>\r\n      <Message Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n      </Message>\r\n      <Outputs Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n      </Outputs>\r\n      <Command Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n      </Command>\r\n      <Message Condition=\"'$(Configuration)|$(Platform)'=='Template|x64'\">\r\n      </Message>\r\n      <Outputs Condition=\"'$(Configuration)|$(Platform)'=='Template|x64'\">\r\n      </Outputs>\r\n      <Command Condition=\"'$(Configuration)|$(Platform)'=='Template|x64'\">\r\n      </Command>\r\n    </CustomBuild>\r\n    <QtMoc Include=\"editors\\common\\ComponentItemAutoConnector\\AutoConnector.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\common\\ComponentItemAutoConnector\\AutoConnectorConnectionDelegate.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\common\\ComponentItemAutoConnector\\AutoConnectorListFilter.h\">\r\n    </QtMoc>\r\n    <ClInclude Include=\"editors\\common\\ComponentInstanceEditor\\PowerDomainLinkColumns.h\" />\r\n    <QtMoc Include=\"editors\\common\\ComponentInstanceEditor\\PowerDomainLinkModel.h\" />\r\n    <QtMoc Include=\"editors\\common\\ComponentInstanceEditor\\PowerDomainLinkEditor.h\" />\r\n    <QtMoc Include=\"editors\\common\\ComponentInstanceEditor\\PowerDomainLinkDelegate.h\" />\r\n    <ClInclude Include=\"editors\\common\\ComponentItemAutoConnector\\BusInterfaceItemMatcher.h\" />\r\n    <ClInclude Include=\"editors\\common\\ComponentItemAutoConnector\\BusInterfaceListFiller.h\" />\r\n    <ClInclude Include=\"editors\\common\\ComponentItemAutoConnector\\BusInterfaceTableAutoConnector.h\" />\r\n    <ClInclude Include=\"editors\\common\\ComponentItemAutoConnector\\HierarchicalBusInterfaceItemMatcher.h\" />\r\n    <ClInclude Include=\"editors\\common\\ComponentItemAutoConnector\\HierarchicalBusInterfaceTableAutoConnector.h\" />\r\n    <ClInclude Include=\"editors\\common\\ComponentItemAutoConnector\\HierarchicalPortItemMatcher.h\" />\r\n    <ClInclude Include=\"editors\\common\\ComponentItemAutoConnector\\HierarchicalPortTableAutoConnector.h\" />\r\n    <ClInclude Include=\"editors\\common\\ComponentItemAutoConnector\\ListFiller.h\" />\r\n    <CustomBuild Include=\"editors\\common\\ComponentItemAutoConnector\\PortListFiller.h\">\r\n      <Message Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n      </Message>\r\n      <Outputs Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n      </Outputs>\r\n      <Command Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n      </Command>\r\n      <Message Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n      </Message>\r\n      <Outputs Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n      </Outputs>\r\n      <Command Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n      </Command>\r\n      <Message Condition=\"'$(Configuration)|$(Platform)'=='Template|x64'\">\r\n      </Message>\r\n      <Outputs Condition=\"'$(Configuration)|$(Platform)'=='Template|x64'\">\r\n      </Outputs>\r\n      <Command Condition=\"'$(Configuration)|$(Platform)'=='Template|x64'\">\r\n      </Command>\r\n    </CustomBuild>\r\n    <ClInclude Include=\"editors\\common\\ComponentItemAutoConnector\\PortItemMatcher.h\" />\r\n    <ClInclude Include=\"editors\\common\\ComponentItemAutoConnector\\PortTableAutoConnector.h\" />\r\n    <ClInclude Include=\"editors\\common\\ComponentItemAutoConnector\\TableAutoConnector.h\" />\r\n    <ClInclude Include=\"editors\\common\\ComponentItemAutoConnector\\TableItemMatcher.h\" />\r\n    <ClInclude Include=\"editors\\common\\ConnectionEditor\\AdHocBoundColumns.h\" />\r\n    <QtMoc Include=\"editors\\common\\ConnectionEditor\\AdHocBoundsModel.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\common\\DesignParameterReferenceTree\\DesignParameterReferenceCounter.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\common\\DesignParameterReferenceTree\\DesignParameterReferenceTree.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\common\\ConnectionEditor\\connectioneditor.h\">\r\n    </QtMoc>\r\n    <ClInclude Include=\"editors\\common\\DefaultRouting.h\" />\r\n    <QtMoc Include=\"editors\\common\\DesignCompletionModel.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\common\\DesignDiagram.h\">\r\n    </QtMoc>\r\n    <ClInclude Include=\"editors\\common\\DesignDiagramResolver.h\" />\r\n    <QtMoc Include=\"editors\\common\\DesignWidget.h\">\r\n    </QtMoc>\r\n    <ClInclude Include=\"editors\\common\\DesignWidgetFactory.h\" />\r\n    <ClInclude Include=\"editors\\common\\DesignWidgetFactoryImplementation.h\" />\r\n    <ClInclude Include=\"editors\\common\\diagramgrid.h\" />\r\n    <ClInclude Include=\"editors\\common\\DiagramUtil.h\" />\r\n    <QtMoc Include=\"editors\\common\\DocumentNameGroupEditor.h\" />\r\n    <ClInclude Include=\"editors\\common\\DrawMode.h\" />\r\n    <ClInclude Include=\"editors\\common\\ExpressionSet.h\" />\r\n    <ClInclude Include=\"editors\\common\\GraphicsItemLabel.h\" />\r\n    <ClInclude Include=\"editors\\common\\ImageExporter.h\" />\r\n    <QtMoc Include=\"editors\\common\\InterfaceEditor\\interfaceeditor.h\">\r\n    </QtMoc>\r\n    <ClInclude Include=\"editors\\common\\InterfaceEditor\\InterfacePortMapColumns.h\" />\r\n    <QtMoc Include=\"editors\\common\\InterfaceEditor\\InterfacePortMapDelegate.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\common\\InterfaceEditor\\InterfacePortMapModel.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\common\\StickyNote\\ColorFillTextItem.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\common\\StickyNote\\StickyNote.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\common\\StickyNote\\StickyNoteAddCommand.h\">\r\n    </QtMoc>\r\n    <ClInclude Include=\"editors\\common\\NamelabelWidth.h\" />\r\n    <ClInclude Include=\"editors\\common\\PortUtilities.h\" />\r\n    <ClInclude Include=\"editors\\common\\StickyNote\\StickyNoteEditCommand.h\" />\r\n    <ClInclude Include=\"editors\\common\\StickyNote\\StickyNoteMoveCommand.h\" />\r\n    <QtMoc Include=\"editors\\common\\StickyNote\\StickyNoteRemoveCommand.h\">\r\n    </QtMoc>\r\n    <ClInclude Include=\"editors\\common\\TopComponentParameterFinder.h\" />\r\n    <QtMoc Include=\"editors\\common\\VendorExtensionEditor\\VendorExtensionAttributesEditor\\VendorExtensionAttributesModel.h\">\r\n    </QtMoc>\r\n    <ClInclude Include=\"editors\\common\\VendorExtensionEditor\\VendorExtensionAttributesEditor\\VendorExtensionAttributesColumns.h\" />\r\n    <ClInclude Include=\"editors\\common\\VendorExtensionEditor\\VendorExtensionColumns.h\" />\r\n    <QtMoc Include=\"editors\\common\\VendorExtensionEditor\\VendorExtensionsEditor.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\common\\VendorExtensionEditor\\VendorExtensionsModel.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\common\\VendorExtensionEditor\\VendorExtensionsDelegate.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\common\\VendorExtensionEditor\\VendorExtensionsFilter.h\">\r\n    </QtMoc>\r\n    <CustomBuild Include=\"editors\\common\\VendorExtensionEditor\\VendorExtensionsGeneral.h\">\r\n      <Message Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n      </Message>\r\n      <Outputs Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n      </Outputs>\r\n      <Command Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n      </Command>\r\n      <Message Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n      </Message>\r\n      <Outputs Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n      </Outputs>\r\n      <Command Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n      </Command>\r\n      <Message Condition=\"'$(Configuration)|$(Platform)'=='Template|x64'\">\r\n      </Message>\r\n      <Outputs Condition=\"'$(Configuration)|$(Platform)'=='Template|x64'\">\r\n      </Outputs>\r\n      <Command Condition=\"'$(Configuration)|$(Platform)'=='Template|x64'\">\r\n      </Command>\r\n    </CustomBuild>\r\n    <ClInclude Include=\"editors\\ComponentEditor\\addressSpaces\\AddressSpaceColumns.h\" />\r\n    <QtMoc Include=\"editors\\ComponentEditor\\busInterfaces\\AbstractionTypesEditor.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\busInterfaces\\AbstractionTypesModel.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\busInterfaces\\AbstractionTypesDelegate.h\">\r\n    </QtMoc>\r\n    <ClInclude Include=\"editors\\ComponentEditor\\busInterfaces\\AbstractionTypesConstants.h\" />\r\n    <ClInclude Include=\"editors\\ComponentEditor\\busInterfaces\\BusInterfaceColumns.h\" />\r\n    <QtMoc Include=\"editors\\ComponentEditor\\busInterfaces\\portmaps\\PhysicalPortMappingTableView.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\busInterfaces\\portmaps\\PhysicalPortMappingTableModel.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\busInterfaces\\portmaps\\PortMapAutoConnector.h\">\r\n    </QtMoc>\r\n    <CustomBuild Include=\"editors\\ComponentEditor\\busInterfaces\\portmaps\\JaroWinklerAlgorithm.h\">\r\n      <AdditionalInputs Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">%(AdditionalInputs)</AdditionalInputs>\r\n      <Message Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n      </Message>\r\n      <Outputs Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n      </Outputs>\r\n      <Command Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n      </Command>\r\n      <AdditionalInputs Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">%(AdditionalInputs)</AdditionalInputs>\r\n      <Message Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n      </Message>\r\n      <Outputs Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n      </Outputs>\r\n      <Command Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n      </Command>\r\n      <AdditionalInputs Condition=\"'$(Configuration)|$(Platform)'=='Template|x64'\">%(AdditionalInputs)</AdditionalInputs>\r\n      <Message Condition=\"'$(Configuration)|$(Platform)'=='Template|x64'\">\r\n      </Message>\r\n      <Outputs Condition=\"'$(Configuration)|$(Platform)'=='Template|x64'\">\r\n      </Outputs>\r\n      <Command Condition=\"'$(Configuration)|$(Platform)'=='Template|x64'\">\r\n      </Command>\r\n    </CustomBuild>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\busInterfaces\\businterfaceeditor.h\">\r\n    </QtMoc>\r\n    <ClInclude Include=\"editors\\ComponentEditor\\busInterfaces\\general\\BridgeColumns.h\" />\r\n    <QtMoc Include=\"editors\\ComponentEditor\\busInterfaces\\general\\bridgesdelegate.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\busInterfaces\\general\\bridgeseditor.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\busInterfaces\\general\\bridgesmodel.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\busInterfaces\\general\\busifgeneraldetails.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\busInterfaces\\general\\busifgeneraltab.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\busInterfaces\\general\\interfacemodestack.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\busInterfaces\\portmaps\\BusInterfacePortMapTab.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\busInterfaces\\portmaps\\PortMapDelegate.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\busInterfaces\\general\\MasterModeEditor.h\" />\r\n    <QtMoc Include=\"editors\\ComponentEditor\\busInterfaces\\general\\ModeEditorBase.h\" />\r\n    <QtMoc Include=\"editors\\ComponentEditor\\busInterfaces\\general\\SlaveModeEditor.h\" />\r\n    <QtMoc Include=\"editors\\ComponentEditor\\busInterfaces\\general\\MirroredSlaveModeEditor.h\" />\r\n    <QtMoc Include=\"editors\\ComponentEditor\\busInterfaces\\general\\InitiatorModeEditor.h\" />\r\n    <ClInclude Include=\"editors\\ComponentEditor\\busInterfaces\\general\\MirroredInitiatorModeEditor.h\" />\r\n    <ClInclude Include=\"editors\\ComponentEditor\\busInterfaces\\general\\MirroredMasterModeEditor.h\" />\r\n    <QtMoc Include=\"editors\\ComponentEditor\\busInterfaces\\general\\MonitorModeEditor.h\" />\r\n    <QtMoc Include=\"editors\\ComponentEditor\\busInterfaces\\general\\SystemModeEditor.h\" />\r\n    <QtMoc Include=\"editors\\ComponentEditor\\busInterfaces\\general\\TargetModeEditor.h\" />\r\n    <QtMoc Include=\"editors\\ComponentEditor\\busInterfaces\\general\\MirroredTargetModeEditor.h\" />\r\n    <ClInclude Include=\"editors\\ComponentEditor\\busInterfaces\\portmaps\\PortMapHeaderView.h\" />\r\n    <QtMoc Include=\"editors\\ComponentEditor\\busInterfaces\\portmaps\\PortMapModel.h\">\r\n    </QtMoc>\r\n    <ClInclude Include=\"editors\\ComponentEditor\\busInterfaces\\portmaps\\PortMappingColumns.h\" />\r\n    <QtMoc Include=\"editors\\ComponentEditor\\busInterfaces\\portmaps\\PortMappingTableView.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\busInterfaces\\portmaps\\PortMappingTableModel.h\">\r\n    </QtMoc>\r\n    <ClInclude Include=\"editors\\ComponentEditor\\busInterfaces\\portmaps\\PortMapsColumns.h\" />\r\n    <QtMoc Include=\"editors\\ComponentEditor\\busInterfaces\\portmaps\\PortMapView.h\">\r\n    </QtMoc>\r\n    <ClInclude Include=\"editors\\ComponentEditor\\busInterfaces\\portmaps\\PortMapSortFilter.h\" />\r\n    <ClInclude Include=\"editors\\ComponentEditor\\channels\\ChannelColumns.h\" />\r\n    <ClInclude Include=\"editors\\ComponentEditor\\addressSpaces\\SegmentColumns.h\" />\r\n    <ClInclude Include=\"editors\\ComponentEditor\\choices\\ChoiceColumns.h\" />\r\n    <ClInclude Include=\"editors\\ComponentEditor\\choices\\EnumerationColumns.h\" />\r\n    <ClInclude Include=\"editors\\ComponentEditor\\common\\ConfigurableElementFinder.h\" />\r\n    <ClInclude Include=\"editors\\ComponentEditor\\common\\DesignConfigurationInstantiationParameterFinder.h\" />\r\n    <QtMoc Include=\"editors\\ComponentEditor\\common\\InstantiationConfigurableElementEditor.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\common\\MultilineDescriptionDelegate.h\">\r\n    </QtMoc>\r\n    <CustomBuild Include=\"editors\\ComponentEditor\\common\\ParameterizableTable.h\">\r\n      <AdditionalInputs Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">%(AdditionalInputs)</AdditionalInputs>\r\n      <Message Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n      </Message>\r\n      <Outputs Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n      </Outputs>\r\n      <Command Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n      </Command>\r\n      <AdditionalInputs Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">%(AdditionalInputs)</AdditionalInputs>\r\n      <Message Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n      </Message>\r\n      <Outputs Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n      </Outputs>\r\n      <Command Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n      </Command>\r\n      <AdditionalInputs Condition=\"'$(Configuration)|$(Platform)'=='Template|x64'\">%(AdditionalInputs)</AdditionalInputs>\r\n      <Message Condition=\"'$(Configuration)|$(Platform)'=='Template|x64'\">\r\n      </Message>\r\n      <Outputs Condition=\"'$(Configuration)|$(Platform)'=='Template|x64'\">\r\n      </Outputs>\r\n      <Command Condition=\"'$(Configuration)|$(Platform)'=='Template|x64'\">\r\n      </Command>\r\n    </CustomBuild>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\common\\ReferencingTableModel.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\common\\ReferenceSelector\\ReferenceSelector.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\common\\ExpressionLineEditor.h\" />\r\n    <QtMoc Include=\"editors\\ComponentEditor\\common\\EnumerationEditorConstructorDelegate.h\" />\r\n    <QtMoc Include=\"editors\\ComponentEditor\\common\\FloatingModeReferenceEditor.h\" />\r\n    <ClInclude Include=\"editors\\ComponentEditor\\common\\MasterExpressionEditor.h\" />\r\n    <QtMoc Include=\"editors\\ComponentEditor\\common\\ModeReferenceEditor.h\" />\r\n    <QtMoc Include=\"editors\\ComponentEditor\\common\\ModeReferenceDelegate.h\" />\r\n    <QtMoc Include=\"editors\\ComponentEditor\\common\\ModeReferenceModel.h\" />\r\n    <QtMoc Include=\"editors\\ComponentEditor\\common\\MemoryAlignScene.h\" />\r\n    <ClInclude Include=\"editors\\ComponentEditor\\common\\MemoryTreeFactory.h\" />\r\n    <ClInclude Include=\"editors\\ComponentEditor\\cpus\\CpuColumns.h\" />\r\n    <QtMoc Include=\"editors\\ComponentEditor\\cpus\\SingleCpuEditor.h\" />\r\n    <QtMoc Include=\"editors\\ComponentEditor\\cpus\\CpuDetailsEditor.h\" />\r\n    <QtMoc Include=\"editors\\ComponentEditor\\cpus\\RegionsModel.h\" />\r\n    <QtMoc Include=\"editors\\ComponentEditor\\cpus\\CpuVisualizer.h\" />\r\n    <ClInclude Include=\"editors\\ComponentEditor\\cpus\\RegionColumns.h\" />\r\n    <QtMoc Include=\"editors\\ComponentEditor\\cpus\\RegionsEditor.h\" />\r\n    <QtMoc Include=\"editors\\ComponentEditor\\cpus\\RegionsDelegate.h\" />\r\n    <QtMoc Include=\"editors\\ComponentEditor\\cpus\\RegionScene.h\" />\r\n    <ClInclude Include=\"editors\\ComponentEditor\\fileBuilders\\FileBuilderColumns.h\" />\r\n    <ClInclude Include=\"editors\\ComponentEditor\\fileSet\\dependencyAnalysis\\FileDependencyColumns.h\" />\r\n    <ClInclude Include=\"editors\\ComponentEditor\\fileSet\\FileSetColumns.h\" />\r\n    <ClInclude Include=\"editors\\ComponentEditor\\fileSet\\file\\FileColumns.h\" />\r\n    <QtMoc Include=\"editors\\ComponentEditor\\instantiations\\DesignConfigurationInstantiationEditor.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\instantiations\\DesignInstantiationEditor.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\indirectInterfaces\\IndirectInterfacesEditor.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\indirectInterfaces\\IndirectInterfacesModel.h\">\r\n    </QtMoc>\r\n    <ClInclude Include=\"editors\\ComponentEditor\\indirectInterfaces\\IndirectInterfaceColumns.h\" />\r\n    <QtMoc Include=\"editors\\ComponentEditor\\indirectInterfaces\\IndirectInterfacesDelegate.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\indirectInterfaces\\SingleIndirectInterfaceEditor.h\">\r\n    </QtMoc>\r\n    <ClInclude Include=\"editors\\ComponentEditor\\instantiations\\ComponentInstantiationDisplayer.h\" />\r\n    <QtMoc Include=\"editors\\ComponentEditor\\instantiations\\ComponentInstantiationsEditor.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\instantiations\\ComponentInstantiationsModel.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\instantiations\\ComponentInstantiationEditor.h\">\r\n    </QtMoc>\r\n    <ClInclude Include=\"editors\\ComponentEditor\\instantiations\\ComponentInstantiationsColumns.h\" />\r\n    <QtMoc Include=\"editors\\ComponentEditor\\instantiations\\InstantiationsEditor.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\instantiations\\DesignInstantiationsEditor.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\instantiations\\DesignInstantiationsModel.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\instantiations\\DesignConfigurationInstantiationsModel.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\instantiations\\DesignConfigurationInstantiationsEditor.h\">\r\n    </QtMoc>\r\n    <ClInclude Include=\"editors\\ComponentEditor\\instantiations\\DesignInstantiationColumns.h\" />\r\n    <QtMoc Include=\"editors\\ComponentEditor\\instantiations\\DesignInstantiationsDelegate.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\instantiations\\filesetrefeditordelegate.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\instantiations\\filesetrefmodel.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\instantiations\\filesetrefeditor.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\instantiations\\ModuleParameterDelegate.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\instantiations\\ModuleParameterEditor.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\instantiations\\ModuleParameterModel.h\">\r\n    </QtMoc>\r\n    <ClInclude Include=\"editors\\ComponentEditor\\instantiations\\ModuleParameterColumns.h\" />\r\n    <ClInclude Include=\"editors\\ComponentEditor\\instantiations\\ModuleParameterHeaderView.h\" />\r\n    <QtMoc Include=\"editors\\ComponentEditor\\memoryMaps\\FieldAccessPoliciesDelegate.h\" />\r\n    <QtMoc Include=\"editors\\ComponentEditor\\memoryMaps\\FieldAccessPoliciesEditor.h\" />\r\n    <QtMoc Include=\"editors\\ComponentEditor\\memoryMaps\\FieldAccessPoliciesModel.h\" />\r\n    <QtMoc Include=\"editors\\ComponentEditor\\memoryMaps\\AccessPoliciesEditor.h\" />\r\n    <QtMoc Include=\"editors\\ComponentEditor\\memoryMaps\\AccessPoliciesDelegate.h\" />\r\n    <QtMoc Include=\"editors\\ComponentEditor\\memoryMaps\\AccessPoliciesModel.h\" />\r\n    <ClInclude Include=\"editors\\ComponentEditor\\memoryMaps\\AddressBlockColumns.h\" />\r\n    <QtMoc Include=\"editors\\ComponentEditor\\memoryMaps\\ExpressionProxyModel.h\">\r\n    </QtMoc>\r\n    <ClInclude Include=\"editors\\ComponentEditor\\memoryMaps\\EnumeratedValueColumns.h\" />\r\n    <QtMoc Include=\"editors\\ComponentEditor\\memoryMaps\\MemoryBlockModel.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\memoryMaps\\MemoryBlockDelegate.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\memoryMaps\\MemoryBlockFilter.h\">\r\n    </QtMoc>\r\n    <ClInclude Include=\"editors\\ComponentEditor\\memoryMaps\\FieldAccessPolicyColumns.h\" />\r\n    <ClInclude Include=\"editors\\ComponentEditor\\memoryMaps\\MemoryMapColumns.h\" />\r\n    <ClInclude Include=\"editors\\ComponentEditor\\memoryMaps\\MemoryMapsColumns.h\" />\r\n    <QtMoc Include=\"editors\\ComponentEditor\\memoryMaps\\MemoryMapsView.h\">\r\n    </QtMoc>\r\n    <ClInclude Include=\"editors\\ComponentEditor\\memoryMaps\\memoryMapsExpressionCalculators\\ReferenceCalculator.h\" />\r\n    <QtMoc Include=\"editors\\ComponentEditor\\memoryMaps\\memoryMapsVisualizer\\MemoryBlockGraphItem.h\">\r\n    </QtMoc>\r\n    <ClInclude Include=\"editors\\ComponentEditor\\memoryMaps\\memoryMapsVisualizer\\registerfilegraphitem.h\" />\r\n    <QtMoc Include=\"editors\\ComponentEditor\\memoryMaps\\memoryMapsVisualizer\\SubspaceMapGraphItem.h\">\r\n    </QtMoc>\r\n    <ClInclude Include=\"editors\\ComponentEditor\\memoryMaps\\RegisterColumns.h\" />\r\n    <QtMoc Include=\"editors\\ComponentEditor\\memoryMaps\\SingleMemoryMapEditor.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\memoryMaps\\SingleAddressBlockEditor.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\memoryMaps\\SingleRegisterEditor.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\memoryMaps\\SingleFieldEditor.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\memoryMaps\\WriteValueConstraintComboBox.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\parameters\\parametersmodel.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\parameters\\ComponentParameterModel.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\parameterReferenceTree\\ParameterReferenceTree.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\parameters\\Array\\ArrayDelegate.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\parameters\\Array\\ParameterArrayModel.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\parameters\\Array\\ArrayView.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\memoryMaps\\SingleRegisterFileEditor.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\memoryMaps\\registerfiledelegate.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\memoryMaps\\registerfileeditor.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\memoryMaps\\registerfilemodel.h\">\r\n    </QtMoc>\r\n    <ClInclude Include=\"editors\\ComponentEditor\\memoryMaps\\RegisterFileColumns.h\" />\r\n    <QtMoc Include=\"editors\\ComponentEditor\\memoryMaps\\ResetsEditor.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\memoryMaps\\ResetsModel.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\memoryMaps\\RemapModeReferenceEditor.h\" />\r\n    <ClInclude Include=\"editors\\ComponentEditor\\memoryMaps\\ResetColumns.h\" />\r\n    <QtMoc Include=\"editors\\ComponentEditor\\memoryMaps\\ResetsDelegate.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\memoryMaps\\SubspaceMapsEditor.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\memoryMaps\\SingleSubspaceMapEditor.h\">\r\n    </QtMoc>\r\n    <ClInclude Include=\"editors\\ComponentEditor\\memoryMaps\\SubspaceMapColumns.h\" />\r\n    <QtMoc Include=\"editors\\ComponentEditor\\memoryMaps\\SubspaceMapModel.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\memoryMaps\\SubspaceMapDelegate.h\">\r\n    </QtMoc>\r\n    <ClInclude Include=\"editors\\ComponentEditor\\modes\\FieldSliceColumns.h\" />\r\n    <QtMoc Include=\"editors\\ComponentEditor\\modes\\FieldSliceEditor.h\" />\r\n    <QtMoc Include=\"editors\\ComponentEditor\\modes\\FieldSliceModel.h\" />\r\n    <QtMoc Include=\"editors\\ComponentEditor\\modes\\FieldSliceDelegate.h\" />\r\n    <ClInclude Include=\"editors\\ComponentEditor\\modes\\ModeColumns.h\" />\r\n    <QtMoc Include=\"editors\\ComponentEditor\\modes\\ModesEditor.h\" />\r\n    <QtMoc Include=\"editors\\ComponentEditor\\modes\\ModesModel.h\" />\r\n    <QtMoc Include=\"editors\\ComponentEditor\\modes\\SingleModeEditor.h\" />\r\n    <QtMoc Include=\"editors\\ComponentEditor\\modes\\PortSliceEditor.h\" />\r\n    <QtMoc Include=\"editors\\ComponentEditor\\modes\\PortSliceModel.h\" />\r\n    <ClInclude Include=\"editors\\ComponentEditor\\modes\\PortSliceColumns.h\" />\r\n    <QtMoc Include=\"editors\\ComponentEditor\\modes\\PortSliceDelegate.h\" />\r\n    <ClInclude Include=\"editors\\ComponentEditor\\otherClockDrivers\\OtherClockDriverColumns.h\" />\r\n    <QtMoc Include=\"editors\\ComponentEditor\\parameterReferenceTree\\ComponentParameterReferenceTree.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\parameterReferenceTree\\ParameterReferenceTreeWindow.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\ParameterItemEditor.h\">\r\n    </QtMoc>\r\n    <ClInclude Include=\"editors\\ComponentEditor\\parameters\\Array\\ArrayColumns.h\" />\r\n    <QtMoc Include=\"editors\\ComponentEditor\\parameters\\ChoiceCreatorDelegate.h\">\r\n    </QtMoc>\r\n    <ClInclude Include=\"editors\\ComponentEditor\\parameters\\ComponentParameterColumns.h\" />\r\n    <QtMoc Include=\"editors\\ComponentEditor\\parameters\\LockableParametersModel.h\" />\r\n    <ClInclude Include=\"editors\\ComponentEditor\\parameters\\ParameterColumns.h\" />\r\n    <QtMoc Include=\"editors\\ComponentEditor\\parameters\\ParameterDelegate.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"settings\\ComponentEditorSettingsPage.h\">\r\n    </QtMoc>\r\n    <CustomBuild Include=\"editors\\ComponentEditor\\parameters\\ParameterEditorHeaderView.h\">\r\n      <AdditionalInputs Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">%(AdditionalInputs)</AdditionalInputs>\r\n      <Message Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n      </Message>\r\n      <Outputs Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n      </Outputs>\r\n      <Command Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n      </Command>\r\n      <AdditionalInputs Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">%(AdditionalInputs)</AdditionalInputs>\r\n      <Message Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n      </Message>\r\n      <Outputs Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n      </Outputs>\r\n      <Command Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n      </Command>\r\n      <AdditionalInputs Condition=\"'$(Configuration)|$(Platform)'=='Template|x64'\">%(AdditionalInputs)</AdditionalInputs>\r\n      <Message Condition=\"'$(Configuration)|$(Platform)'=='Template|x64'\">\r\n      </Message>\r\n      <Outputs Condition=\"'$(Configuration)|$(Platform)'=='Template|x64'\">\r\n      </Outputs>\r\n      <Command Condition=\"'$(Configuration)|$(Platform)'=='Template|x64'\">\r\n      </Command>\r\n    </CustomBuild>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\referenceCounter\\ParameterReferenceCounter.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\referenceCounter\\ReferenceCounter.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\parameters\\ParametersView.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\ports\\MasterPortsEditor.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"mainwindow\\DrawingBoard\\DrawingBoard.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\treeStructure\\SingleRemapStateItem.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\treeStructure\\RemapStatesItem.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\remapStates\\RemapStatesEditor.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\remapStates\\RemapStatesModel.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\remapStates\\SingleRemapStateEditor.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\ports\\PortTagEditorDelegate.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\referenceCounter\\ComponentParameterReferenceCounter.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\ports\\PortWireTypeEditor.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\ports\\PortWireTypeModel.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\ports\\PortWireTypeDelegate.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\ports\\PortsFilter.h\">\r\n    </QtMoc>\r\n    <ClInclude Include=\"editors\\ComponentEditor\\ports\\PortsEditorFactory.h\" />\r\n    <QtMoc Include=\"editors\\ComponentEditor\\ports\\PortSummaryModel.h\" />\r\n    <QtMoc Include=\"editors\\ComponentEditor\\ports\\PortsImportSummaryEditor.h\" />\r\n    <ClInclude Include=\"editors\\ComponentEditor\\ports\\PortSummaryColumns.h\" />\r\n    <QtMoc Include=\"editors\\ComponentEditor\\ports\\PortSummaryFilter.h\" />\r\n    <QtMoc Include=\"editors\\ComponentEditor\\ports\\PortSummaryDelegate.h\" />\r\n    <ClInclude Include=\"editors\\ComponentEditor\\ports\\PortSummaryEditorFactory.h\" />\r\n    <QtMoc Include=\"editors\\ComponentEditor\\ports\\PortSummaryView.h\" />\r\n    <ClInclude Include=\"editors\\ComponentEditor\\ports\\PortTypeDefinitionDelegate.h\" />\r\n    <QtMoc Include=\"editors\\ComponentEditor\\ports\\PortTypeDefinitionEditor.h\">\r\n    </QtMoc>\r\n    <ClInclude Include=\"editors\\ComponentEditor\\ports\\PortWireTypeColumns.h\" />\r\n    <QtMoc Include=\"editors\\ComponentEditor\\ports\\PortWireTypeView.h\">\r\n    </QtMoc>\r\n    <ClInclude Include=\"editors\\ComponentEditor\\ports\\TransactionalPortColumns.h\" />\r\n    <QtMoc Include=\"editors\\ComponentEditor\\ports\\TransactionalPortsDelegate.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\ports\\TransactionalPortsModel.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\ports\\TransactionalPortsFilter.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\ports\\TypedPortEditor.h\" />\r\n    <ClInclude Include=\"editors\\ComponentEditor\\ports\\TransactionalPortsEditorFactory.h\" />\r\n    <ClInclude Include=\"editors\\ComponentEditor\\ports\\WirePortColumns.h\" />\r\n    <QtMoc Include=\"editors\\ComponentEditor\\ports\\WirePortsModel.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\ports\\WirePortsFilter.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\ports\\WirePortsDelegate.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\powerDomains\\PowerDomainsEditor.h\" />\r\n    <QtMoc Include=\"editors\\ComponentEditor\\powerDomains\\PowerDomainsModel.h\" />\r\n    <ClInclude Include=\"editors\\ComponentEditor\\ports\\WirePortsEditorFactory.h\" />\r\n    <QtMoc Include=\"editors\\ComponentEditor\\ports\\TypedPortsView.h\" />\r\n    <ClInclude Include=\"editors\\ComponentEditor\\powerDomains\\PowerDomainColumns.h\" />\r\n    <QtMoc Include=\"editors\\ComponentEditor\\powerDomains\\PowerDomainsDelegate.h\" />\r\n    <ClInclude Include=\"editors\\ComponentEditor\\remapStates\\RemapConditionColumns.h\" />\r\n    <QtMoc Include=\"editors\\ComponentEditor\\remapStates\\RemapConditionModel.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\remapStates\\RemapConditionEditor.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\remapStates\\RemapConditionDelegate.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\treeStructure\\MemoryRemapItem.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\remapStates\\ValueOrIndexedValueEditor.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\resetTypes\\ResetTypesEditor.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\resetTypes\\ResetTypesModel.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\resetTypes\\ResetTypesDelegate.h\">\r\n    </QtMoc>\r\n    <ClInclude Include=\"editors\\ComponentEditor\\resetTypes\\ResetTypeColumns.h\" />\r\n    <ClInclude Include=\"editors\\ComponentEditor\\software\\apiInterface\\ApiInterfaceColumns.h\" />\r\n    <ClInclude Include=\"editors\\ComponentEditor\\software\\comInterface\\ComInterfaceColumns.h\" />\r\n    <QtMoc Include=\"editors\\ComponentEditor\\treeStructure\\InstantiationsItem.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\treeStructure\\ComponentInstantiationsItem.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\treeStructure\\DesignConfigurationInstantiationsItem.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\treeStructure\\DesignInstantiationsItem.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\treeStructure\\SingleComponentInstantiationItem.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\treeStructure\\SingleDesignConfigurationInstantiationItem.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\treeStructure\\SingleDesignInstantiationItem.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\treeStructure\\ComponentEditorIndirectInterfacesItem.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\treeStructure\\SingleIndirectInterfaceItem.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\treeStructure\\ParameterizableItem.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\treeStructure\\componenteditorregisterfileitem.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\treeStructure\\ResetTypesItem.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\treeStructure\\SubspaceMapItem.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\treeStructure\\ComponentEditorTreeDelegate.h\" />\r\n    <QtMoc Include=\"editors\\ComponentEditor\\treeStructure\\SingleCpuItem.h\" />\r\n    <QtMoc Include=\"editors\\ComponentEditor\\treeStructure\\ModesItem.h\" />\r\n    <QtMoc Include=\"editors\\ComponentEditor\\treeStructure\\SingleModeItem.h\" />\r\n    <QtMoc Include=\"editors\\ComponentEditor\\treeStructure\\PowerDomainsItem.h\" />\r\n    <QtMoc Include=\"editors\\ComponentEditor\\treeStructure\\TypeDefinitionsItem.h\" />\r\n    <QtMoc Include=\"editors\\ComponentEditor\\treeStructure\\WirePortsItem.h\" />\r\n    <QtMoc Include=\"editors\\ComponentEditor\\treeStructure\\TransactionalPortsItem.h\" />\r\n    <ClInclude Include=\"editors\\ComponentEditor\\views\\EnvIdentifiersColumns.h\" />\r\n    <QtMoc Include=\"editors\\ConfigurationTools\\ViewConfigurer.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ConfigurationTools\\ViewConfigurerDelegate.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\views\\ViewsDelegate.h\">\r\n    </QtMoc>\r\n    <ClInclude Include=\"editors\\ComponentEditor\\views\\ViewColumns.h\" />\r\n    <QtMoc Include=\"editors\\ComponentEditor\\visualization\\AddressableItem.h\" />\r\n    <ClInclude Include=\"editors\\ConfigurationTools\\ViewConfigurerColumns.h\" />\r\n    <ClInclude Include=\"editors\\CSourceEditor\\CSourceHighlight.h\" />\r\n    <QtMoc Include=\"mainwindow\\NewPages\\NewCatalogPage.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"library\\LibraryFilter.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"library\\LibraryErrorModel.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"library\\HierarchyView\\hierarchywidget.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"library\\HierarchyView\\hierarchyview.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"library\\HierarchyView\\hierarchyfilter.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\HWDesign\\AdhocEditor\\AdhocEditor.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\HWDesign\\AdHocConnectionItem.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\HWDesign\\ActiveBusInterfaceItem.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\HWDesign\\ActivePortItem.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\HWDesign\\AdhocEditor\\AdhocPortEditor.h\" />\r\n    <ClInclude Include=\"editors\\HWDesign\\AdhocEditor\\AdHocVisibilityColumns.h\" />\r\n    <QtMoc Include=\"editors\\HWDesign\\AdhocEditor\\AdHocVisibilityDelegate.h\" />\r\n    <QtMoc Include=\"editors\\HWDesign\\AdhocEditor\\AdHocVisibilityEditor.h\" />\r\n    <ClInclude Include=\"editors\\HWDesign\\AdhocEditor\\AdHocVisibilityModel.h\" />\r\n    <ClInclude Include=\"editors\\HWDesign\\AdhocEditor\\AdHocVisibilityPolicy.h\" />\r\n    <ClInclude Include=\"editors\\HWDesign\\AdHocEnabled.h\" />\r\n    <QtMoc Include=\"editors\\HWDesign\\AdHocItem.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\HWDesign\\columnview\\ColumnEditDialog.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\HWDesign\\columnview\\HWColumn.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\HWDesign\\undoCommands\\AdHocBoundsChangeCommand.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\HWDesign\\SelectItemTypeDialog.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\HWDesign\\BusInterfaceDialog.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\HWDesign\\BusInterfaceEndPoint.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\HWDesign\\HierarchicalBusInterfaceItem.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\HWDesign\\HierarchicalPortItem.h\">\r\n    </QtMoc>\r\n    <ClInclude Include=\"editors\\HWDesign\\HWAddCommands.h\" />\r\n    <QtMoc Include=\"editors\\HWDesign\\HWChangeCommands.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\HWDesign\\HWComponentItem.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\HWDesign\\HWConnection.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\HWDesign\\HWConnectionEndpoint.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\HWDesign\\HWDesignDiagram.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\HWDesign\\HWDesignWidget.h\">\r\n    </QtMoc>\r\n    <ClInclude Include=\"editors\\HWDesign\\HWMoveCommands.h\" />\r\n    <ClInclude Include=\"editors\\HWDesign\\InterfaceGraphics.h\" />\r\n    <QtMoc Include=\"editors\\HWDesign\\OffPageConnectorItem.h\">\r\n    </QtMoc>\r\n    <ClInclude Include=\"editors\\HWDesign\\PortmapDialog.h\" />\r\n    <ClInclude Include=\"editors\\HWDesign\\undoCommands\\AdHocConnectionAddCommand.h\" />\r\n    <ClInclude Include=\"editors\\HWDesign\\undoCommands\\AdHocConnectionDeleteCommand.h\" />\r\n    <ClInclude Include=\"editors\\HWDesign\\undoCommands\\AdHocTiedValueCommand.h\" />\r\n    <ClInclude Include=\"editors\\HWDesign\\undoCommands\\AdHocTieOffBoundsChangeCommand.h\" />\r\n    <QtMoc Include=\"editors\\HWDesign\\undoCommands\\AdHocTieOffChangeCommand.h\">\r\n    </QtMoc>\r\n    <ClInclude Include=\"editors\\HWDesign\\undoCommands\\AdHocTieOffConnectionDeleteCommand.h\" />\r\n    <ClInclude Include=\"editors\\HWDesign\\undoCommands\\AdHocVisibilityChangeCommand.h\" />\r\n    <ClInclude Include=\"editors\\HWDesign\\undoCommands\\ColumnDeleteCommand.h\" />\r\n    <QtMoc Include=\"editors\\HWDesign\\undoCommands\\ComponentDeleteCommand.h\">\r\n    </QtMoc>\r\n    <ClInclude Include=\"editors\\HWDesign\\undoCommands\\ComponentInstancePasteCommand.h\" />\r\n    <ClInclude Include=\"editors\\HWDesign\\undoCommands\\ComponentItemMoveCommand.h\" />\r\n    <QtMoc Include=\"editors\\HWDesign\\undoCommands\\ConfigurableElementChangeCommand.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\HWDesign\\undoCommands\\ConfigurableElementRemoveCommand.h\">\r\n    </QtMoc>\r\n    <ClInclude Include=\"editors\\HWDesign\\undoCommands\\ConnectionDeleteCommand.h\" />\r\n    <ClInclude Include=\"editors\\HWDesign\\undoCommands\\HWColumnAddCommand.h\" />\r\n    <QtMoc Include=\"editors\\HWDesign\\undoCommands\\HWComponentAddCommand.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\HWDesign\\undoCommands\\InterfaceDeleteCommand.h\">\r\n    </QtMoc>\r\n    <CustomBuild Include=\"editors\\HWDesign\\undoCommands\\PhysicalPortDeleteCommand.h\">\r\n      <AdditionalInputs Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">%(AdditionalInputs)</AdditionalInputs>\r\n      <Message Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n      </Message>\r\n      <Outputs Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n      </Outputs>\r\n      <Command Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n      </Command>\r\n      <AdditionalInputs Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">%(AdditionalInputs)</AdditionalInputs>\r\n      <Message Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n      </Message>\r\n      <Outputs Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n      </Outputs>\r\n      <Command Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n      </Command>\r\n      <AdditionalInputs Condition=\"'$(Configuration)|$(Platform)'=='Template|x64'\">%(AdditionalInputs)</AdditionalInputs>\r\n      <Message Condition=\"'$(Configuration)|$(Platform)'=='Template|x64'\">\r\n      </Message>\r\n      <Outputs Condition=\"'$(Configuration)|$(Platform)'=='Template|x64'\">\r\n      </Outputs>\r\n      <Command Condition=\"'$(Configuration)|$(Platform)'=='Template|x64'\">\r\n      </Command>\r\n    </CustomBuild>\r\n    <ClInclude Include=\"editors\\HWDesign\\undoCommands\\PortDeleteCommand.h\" />\r\n    <ClInclude Include=\"editors\\HWDesign\\undoCommands\\PortPasteCommand.h\" />\r\n    <QtMoc Include=\"editors\\HWDesign\\undoCommands\\ReplaceComponentCommand.h\">\r\n    </QtMoc>\r\n    <ClInclude Include=\"editors\\HWDesign\\undoCommands\\TopAdHocVisibilityChangeCommand.h\" />\r\n    <CustomBuild Include=\"editors\\HWDesign\\WarningSymbol.h\">\r\n      <Message Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n      </Message>\r\n      <Outputs Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n      </Outputs>\r\n      <Command Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n      </Command>\r\n      <Message Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n      </Message>\r\n      <Outputs Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n      </Outputs>\r\n      <Command Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n      </Command>\r\n      <Message Condition=\"'$(Configuration)|$(Platform)'=='Template|x64'\">\r\n      </Message>\r\n      <Outputs Condition=\"'$(Configuration)|$(Platform)'=='Template|x64'\">\r\n      </Outputs>\r\n      <Command Condition=\"'$(Configuration)|$(Platform)'=='Template|x64'\">\r\n      </Command>\r\n    </CustomBuild>\r\n    <QtMoc Include=\"editors\\InterconnectGenerator\\InterconnectGeneratorDialog.h\" />\r\n    <QtMoc Include=\"editors\\interconnectgenerator\\InstanceInterfacesEditor.h\" />\r\n    <ClInclude Include=\"editors\\InterconnectGenerator\\InterconnectAddressHelper.h\" />\r\n    <ClInclude Include=\"editors\\InterconnectGenerator\\InterconnectDataModel.h\" />\r\n    <ClInclude Include=\"editors\\MemoryDesigner\\AddressBlockGraphicsItem.h\" />\r\n    <ClInclude Include=\"editors\\MemoryDesigner\\AddressSegmentGraphicsItem.h\" />\r\n    <ClInclude Include=\"editors\\MemoryDesigner\\AddressSpaceGraphicsItem.h\" />\r\n    <ClInclude Include=\"editors\\MemoryDesigner\\ConnectivityComponent.h\" />\r\n    <ClInclude Include=\"editors\\MemoryDesigner\\ConnectivityConnection.h\" />\r\n    <ClInclude Include=\"editors\\MemoryDesigner\\ConnectivityGraph.h\" />\r\n    <ClInclude Include=\"editors\\MemoryDesigner\\ConnectivityGraphFactory.h\" />\r\n    <ClInclude Include=\"editors\\MemoryDesigner\\ConnectivityInterface.h\" />\r\n    <ClInclude Include=\"editors\\MemoryDesigner\\FieldGraphicsItem.h\" />\r\n    <ClInclude Include=\"editors\\MemoryDesigner\\FieldOverlapItem.h\" />\r\n    <ClInclude Include=\"editors\\MemoryDesigner\\MainMemoryGraphicsItem.h\" />\r\n    <ClInclude Include=\"editors\\MemoryDesigner\\MasterSlavePathSearch.h\" />\r\n    <ClInclude Include=\"editors\\MemoryDesigner\\MemoryCollisionItem.h\" />\r\n    <QtMoc Include=\"editors\\MemoryDesigner\\MemoryColumn.h\">\r\n    </QtMoc>\r\n    <ClInclude Include=\"editors\\MemoryDesigner\\MemoryColumnHandler.h\" />\r\n    <ClInclude Include=\"editors\\MemoryDesigner\\MemoryConnectionAddressCalculator.h\" />\r\n    <ClInclude Include=\"editors\\MemoryDesigner\\MemoryConnectionHandler.h\" />\r\n    <ClInclude Include=\"editors\\MemoryDesigner\\MemoryConnectionItem.h\" />\r\n    <QtMoc Include=\"editors\\MemoryDesigner\\MemoryDesignConstructor.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\MemoryDesigner\\MemoryDesignDocument.h\">\r\n    </QtMoc>\r\n    <ClInclude Include=\"editors\\MemoryDesigner\\MemoryDesignerChildGraphicsItem.h\" />\r\n    <ClInclude Include=\"editors\\MemoryDesigner\\MemoryDesignerConstants.h\" />\r\n    <QtMoc Include=\"editors\\MemoryDesigner\\MemoryDesignerDiagram.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\MemoryDesigner\\MemoryDesignerGraphicsItem.h\">\r\n    </QtMoc>\r\n    <ClInclude Include=\"editors\\MemoryDesigner\\MemoryExtensionGraphicsItem.h\" />\r\n    <QtMoc Include=\"editors\\MemoryDesigner\\MemoryGraphicsItemHandler.h\">\r\n    </QtMoc>\r\n    <ClInclude Include=\"editors\\MemoryDesigner\\MemoryItem.h\" />\r\n    <ClInclude Include=\"editors\\MemoryDesigner\\MemoryMapGraphicsItem.h\" />\r\n    <ClInclude Include=\"editors\\MemoryDesigner\\RegisterGraphicsItem.h\" />\r\n    <ClInclude Include=\"editors\\MemoryDesigner\\SubMemoryLayout.h\" />\r\n    <QtMoc Include=\"editors\\SystemDesign\\SystemDetailsEditor\\SystemDetailsEditor.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\SystemDesign\\SystemDetailsEditor\\ExportSWDialog.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\SystemDesign\\SystemDetailsEditor\\SwitchHWDialog.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\SystemDesign\\SystemDesignWidget.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\SystemDesign\\ApiGraphicsConnection.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\SystemDesign\\ComGraphicsConnection.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\PythonSourceEditor\\PythonSourceEditor.h\">\r\n    </QtMoc>\r\n    <ClInclude Include=\"editors\\PythonSourceEditor\\PythonSourceHighlight.h\" />\r\n    <ClInclude Include=\"editors\\PythonSourceEditor\\ScriptingSideArea.h\" />\r\n    <QtMoc Include=\"editors\\PythonSourceEditor\\ScriptInputEditor.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\PythonSourceEditor\\ScriptViewEditor.h\">\r\n    </QtMoc>\r\n    <ClInclude Include=\"editors\\SystemDesign\\HWMappingItem.h\" />\r\n    <QtMoc Include=\"editors\\SystemDesign\\SWComponentItem.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\SystemDesign\\SWConnectionEndpoint.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\SystemDesign\\SWInterfaceItem.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\SystemDesign\\SWPortItem.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\SystemDesign\\SystemColumn.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\SystemDesign\\SystemComponentItem.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\SystemDesign\\SystemDesignDiagram.h\">\r\n    </QtMoc>\r\n    <ClInclude Include=\"editors\\SystemDesign\\UndoCommands\\ApiConnectionAddCommand.h\" />\r\n    <ClInclude Include=\"editors\\SystemDesign\\UndoCommands\\ApiConnectionDeleteCommand.h\" />\r\n    <ClInclude Include=\"editors\\SystemDesign\\UndoCommands\\ApiConnectionExchangeCommand.h\" />\r\n    <ClInclude Include=\"editors\\SystemDesign\\UndoCommands\\ComConnectionAddCommand.h\" />\r\n    <ClInclude Include=\"editors\\SystemDesign\\UndoCommands\\ComConnectionDeleteCommand.h\" />\r\n    <ClInclude Include=\"editors\\SystemDesign\\UndoCommands\\ComConnectionExchangeCommand.h\" />\r\n    <QtMoc Include=\"editors\\SystemDesign\\UndoCommands\\ReplaceSystemComponentCommand.h\">\r\n    </QtMoc>\r\n    <ClInclude Include=\"editors\\SystemDesign\\UndoCommands\\SWInterfaceAddCommand.h\" />\r\n    <ClInclude Include=\"editors\\SystemDesign\\UndoCommands\\SWInterfaceDeleteCommand.h\" />\r\n    <ClInclude Include=\"editors\\SystemDesign\\UndoCommands\\SWInterfaceMoveCommand.h\" />\r\n    <ClInclude Include=\"editors\\SystemDesign\\UndoCommands\\SWPortDeleteCommand.h\" />\r\n    <ClInclude Include=\"editors\\SystemDesign\\UndoCommands\\SystemAddCommands.h\" />\r\n    <ClInclude Include=\"editors\\SystemDesign\\UndoCommands\\SystemChangeCommands.h\" />\r\n    <QtMoc Include=\"editors\\SystemDesign\\UndoCommands\\SystemComponentAddCommand.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\SystemDesign\\UndoCommands\\SystemComponentDeleteCommand.h\">\r\n    </QtMoc>\r\n    <ClInclude Include=\"editors\\SystemDesign\\UndoCommands\\SystemDeleteCommands.h\" />\r\n    <ClInclude Include=\"editors\\SystemDesign\\UndoCommands\\SystemMoveCommands.h\" />\r\n    <ClInclude Include=\"kactusGenerators\\DocumentGenerator\\DocumentationWriter.h\" />\r\n    <QtMoc Include=\"library\\ItemExporter.h\">\r\n    </QtMoc>\r\n    <ClInclude Include=\"kactusGenerators\\DocumentGenerator\\HtmlWriter.h\" />\r\n    <ClInclude Include=\"kactusGenerators\\DocumentGenerator\\MarkdownWriter.h\" />\r\n    <ClInclude Include=\"library\\LibraryInterface.h\" />\r\n    <QtMoc Include=\"library\\LibraryTreeFilter.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"library\\LibraryTreeWidget.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"library\\LibraryTreeView.h\">\r\n    </QtMoc>\r\n    <ClInclude Include=\"library\\LibraryItemSelectionFactory.h\" />\r\n    <ClInclude Include=\"library\\LibraryUtils.h\" />\r\n    <QtMoc Include=\"library\\LibraryWidget.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"library\\objectremovedialog.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"library\\ObjectSelectionDialog.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"library\\ObjectExportDialog.h\">\r\n    </QtMoc>\r\n    <ClInclude Include=\"library\\ObjectSelectionListItem.h\" />\r\n    <ClInclude Include=\"library\\TableViewDialog.h\" />\r\n    <QtMoc Include=\"library\\VLNVDialer\\filterwidget.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"library\\VLNVDialer\\firmnessgroup.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"library\\VLNVDialer\\hierarchygroup.h\" />\r\n    <QtMoc Include=\"library\\VLNVDialer\\implementationgroup.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"library\\VLNVDialer\\typegroup.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"library\\VLNVDialer\\vlnvdialer.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"mainwindow\\DockWidgetHandler.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"library\\VLNVDialer\\FilterGroup.h\" />\r\n    <QtMoc Include=\"library\\VLNVDialer\\ValidityGroup.h\" />\r\n    <QtMoc Include=\"library\\VLNVDialer\\RevisionGroup.h\" />\r\n    <ClInclude Include=\"mainwindow\\CommandLineParser.h\" />\r\n    <ClInclude Include=\"mainwindow\\Ribbon\\RibbonTheme.h\" />\r\n    <ClInclude Include=\"mainwindow\\SaveHierarchy\\DocumentTreeBuilder.h\" />\r\n    <QtMoc Include=\"mainwindow\\SaveHierarchy\\HierarchicalSaveBuildStrategy.h\">\r\n    </QtMoc>\r\n    <ClInclude Include=\"mainwindow\\SaveHierarchy\\HierarchicalSaveColumns.h\" />\r\n    <ClInclude Include=\"mainwindow\\SaveHierarchy\\SaveAsItem.h\" />\r\n    <QtMoc Include=\"mainwindow\\SaveHierarchy\\SaveHierarchyDialog.h\">\r\n    </QtMoc>\r\n    <ClInclude Include=\"mainwindow\\SaveHierarchy\\SaveHierarchyDelegate.h\" />\r\n    <QtMoc Include=\"Plugins\\common\\LanguageHighlighter.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"mainwindow\\WorkspaceSettings.h\" />\r\n    <ClInclude Include=\"Plugins\\common\\ConnectivityGraphUtilities.h\" />\r\n    <ClInclude Include=\"Plugins\\common\\CpuRoutesContainer.h\" />\r\n    <ClInclude Include=\"Plugins\\common\\SingleCpuRoutesContainer.h\" />\r\n    <ClInclude Include=\"Plugins\\common\\SourceHighlightStyle.h\" />\r\n    <QtMoc Include=\"wizards\\BusInterfaceWizard\\BusInterfaceWizardBusDefinitionPage.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"wizards\\BusInterfaceWizard\\BusInterfaceWizard.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"PythonAPI\\ChannelRelay.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"Plugins\\PluginSystem\\GeneratorPlugin\\AddToFilesetWidget.h\" />\r\n    <ClInclude Include=\"PythonAPI\\extensions\\IOCatcher.h\" />\r\n    <QtMoc Include=\"PythonAPI\\FileChannel.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"PythonAPI\\PythonInterpreter.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"PythonAPI\\StdInputListener.h\">\r\n    </QtMoc>\r\n    <CustomBuild Include=\"PythonAPI\\WriteChannel.h\">\r\n      <Message Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n      </Message>\r\n      <Outputs Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n      </Outputs>\r\n      <Command Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n      </Command>\r\n      <Message Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n      </Message>\r\n      <Outputs Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n      </Outputs>\r\n      <Command Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n      </Command>\r\n      <Message Condition=\"'$(Configuration)|$(Platform)'=='Template|x64'\">\r\n      </Message>\r\n      <Outputs Condition=\"'$(Configuration)|$(Platform)'=='Template|x64'\">\r\n      </Outputs>\r\n      <Command Condition=\"'$(Configuration)|$(Platform)'=='Template|x64'\">\r\n      </Command>\r\n    </CustomBuild>\r\n    <ClInclude Include=\"settings\\FileTypeColumns.h\" />\r\n    <QtMoc Include=\"settings\\NewPluginsDialog.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"wizards\\BusInterfaceWizard\\BusInterfaceWizardAbsDefinitionPage.h\" />\r\n    <ClInclude Include=\"wizards\\common\\ComponentComparator\\ComponentComparator.h\" />\r\n    <ClInclude Include=\"wizards\\common\\IPXactDiff.h\" />\r\n    <ClInclude Include=\"wizards\\common\\IPXactElementComparator.h\" />\r\n    <ClInclude Include=\"wizards\\common\\ListComparator.h\" />\r\n    <ClInclude Include=\"wizards\\common\\ModuleParameterComparator\\ModuleParameterComparator.h\" />\r\n    <ClInclude Include=\"wizards\\common\\ParameterComparator\\ParameterComparator.h\" />\r\n    <ClInclude Include=\"wizards\\common\\PortComparator\\PortComparator.h\" />\r\n    <ClInclude Include=\"wizards\\common\\ViewComparator\\ViewComparator.h\" />\r\n    <ClInclude Include=\"wizards\\common\\VLNVComparator\\VLNVComparator.h\" />\r\n    <QtMoc Include=\"wizards\\ImportWizard\\ImportInstancesEditor\\ImportInstancesEditor.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"wizards\\ImportWizard\\ImportWizardInstancesPage.h\">\r\n    </QtMoc>\r\n    <CustomBuild Include=\"wizards\\ComponentWizard\\InstanceData.h\">\r\n      <Message Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n      </Message>\r\n      <Outputs Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n      </Outputs>\r\n      <Command Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n      </Command>\r\n      <Message Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n      </Message>\r\n      <Outputs Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n      </Outputs>\r\n      <Command Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n      </Command>\r\n      <Message Condition=\"'$(Configuration)|$(Platform)'=='Template|x64'\">\r\n      </Message>\r\n      <Outputs Condition=\"'$(Configuration)|$(Platform)'=='Template|x64'\">\r\n      </Outputs>\r\n      <Command Condition=\"'$(Configuration)|$(Platform)'=='Template|x64'\">\r\n      </Command>\r\n    </CustomBuild>\r\n    <QtMoc Include=\"wizards\\ComponentWizard\\ImportEditor.h\">\r\n    </QtMoc>\r\n    <ClInclude Include=\"wizards\\ImportWizard\\ImportInstancesEditor\\ImportInstancesColumns.h\" />\r\n    <QtMoc Include=\"wizards\\ImportWizard\\ImportInstancesEditor\\ImportInstancesDelegate.h\">\r\n    </QtMoc>\r\n    <ClInclude Include=\"wizards\\ImportWizard\\ImportWizardIntroPage.h\" />\r\n    <ClInclude Include=\"wizards\\ImportWizard\\ImportWizardPages.h\" />\r\n    <QtMoc Include=\"wizards\\ImportWizard\\ImportWizardImportPage.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"wizards\\ImportWizard\\ImportWizard.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"wizards\\ComponentWizard\\ViewListModel.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"wizards\\ComponentWizard\\ComponentWizardViewsPage.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"Help\\HelpSystem\\ContextHelpBrowser.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"Help\\HelpSystem\\HelpSearchWidget.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ApiDefinitionEditor\\ApiDefinitionEditor.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ApiDefinitionEditor\\ApiFunctionEditor.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ApiDefinitionEditor\\ApiFunctionModel.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ApiDefinitionEditor\\ApiFunctionParameterDelegate.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ApiDefinitionEditor\\ApiFunctionParameterModel.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComDefinitionEditor\\ComDefinitionEditor.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComDefinitionEditor\\ComPropertyDelegate.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComDefinitionEditor\\ComPropertyEditor.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComDefinitionEditor\\ComPropertyModel.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\addressSpaces\\addressspaceeditor.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\addressSpaces\\addressspacegeneraleditor.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\addressSpaces\\addressspacesdelegate.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\addressSpaces\\addressspaceseditor.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\addressSpaces\\addressspacesmodel.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\addressSpaces\\segmenteditor.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\addressSpaces\\segmentsmodel.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\addressSpaces\\addressSpaceVisualizer\\AddressSpaceConflictedItem.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\addressSpaces\\addressSpaceVisualizer\\addressspacegapitem.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\addressSpaces\\addressSpaceVisualizer\\addressspacescene.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\addressSpaces\\addressSpaceVisualizer\\addressspacevisualizationitem.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\addressSpaces\\addressSpaceVisualizer\\addressspacevisualizer.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\addressSpaces\\addressSpaceVisualizer\\localaddrblockgraphitem.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\addressSpaces\\addressSpaceVisualizer\\segmentgraphitem.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\addressSpaces\\localMemoryMap\\localmemorymapeditor.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\addressSpaces\\localMemoryMap\\localmemorymapgraphitem.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\busInterfaces\\portmaps\\PortListSortProxyModel.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\busInterfaces\\businterfacesdelegate.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\busInterfaces\\businterfaceseditor.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\busInterfaces\\businterfacesmodel.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\channels\\channelsdelegate.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\channels\\channelseditor.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\channels\\channelsmodel.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\cpus\\cpusdelegate.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\cpus\\cpuseditor.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\cpus\\cpusmodel.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\fileBuilders\\filebuildersdelegate.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\fileBuilders\\filebuilderseditor.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\fileBuilders\\filebuildersmodel.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\fileSet\\fileseteditor.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\fileSet\\filesetsdelegate.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\fileSet\\filesetseditor.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\fileSet\\filesetsmodel.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\fileSet\\groupmanager.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\fileSet\\groupmanagerdelegate.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\fileSet\\dependencyAnalysis\\FileDependencyDelegate.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\fileSet\\dependencyAnalysis\\FileDependencyEditor.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\fileSet\\dependencyAnalysis\\FileDependencyGraphWidget.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\fileSet\\dependencyAnalysis\\FileDependencyGraphView.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\fileSet\\dependencyAnalysis\\FileDependencyInfoWidget.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\fileSet\\dependencyAnalysis\\FileDependencyItem.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\fileSet\\dependencyAnalysis\\FileDependencyModel.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\componenteditor.h\">\r\n    </QtMoc>\r\n    <ClInclude Include=\"editors\\ComponentEditor\\fileSet\\dependencyAnalysis\\FileDependencySortFilter.h\" />\r\n    <QtMoc Include=\"editors\\ComponentEditor\\fileSet\\dependencyAnalysis\\FileDependencySourceEditor.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\fileSet\\file\\filegeneraleditor.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\fileSet\\file\\filenameeditor.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\fileSet\\file\\filesdelegate.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\fileSet\\file\\fileseditor.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\fileSet\\file\\filesmodel.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\fileSet\\file\\filesview.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\fileSet\\file\\filetypeeditor.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\fileSet\\file\\filetypeeditordelegate.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\fileSet\\file\\filebuildcommand.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\fileSet\\file\\filedefinemodel.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\fileSet\\file\\filedefineview.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\fileSet\\file\\fileeditor.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\general\\generaleditor.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\memoryMaps\\memorymapdelegate.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\memoryMaps\\memorymapeditor.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\memoryMaps\\memorymapmodel.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\memoryMaps\\memorymapsdelegate.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\memoryMaps\\memorymapseditor.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\memoryMaps\\memorymapsmodel.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\memoryMaps\\registerdelegate.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\memoryMaps\\registereditor.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\memoryMaps\\registertablemodel.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\memoryMaps\\addressblockdelegate.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\memoryMaps\\addressblockeditor.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\memoryMaps\\addressblockmodel.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\memoryMaps\\enumeratedvaluedelegate.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\memoryMaps\\enumeratedvaluemodel.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\memoryMaps\\fieldeditor.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\memoryMaps\\memoryMapsVisualizer\\addressblockgraphitem.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\memoryMaps\\memoryMapsVisualizer\\fieldgraphitem.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\memoryMaps\\memoryMapsVisualizer\\memorymapgraphitem.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\memoryMaps\\memoryMapsVisualizer\\memorymapscene.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\memoryMaps\\memoryMapsVisualizer\\memorymapsvisualizer.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\memoryMaps\\memoryMapsVisualizer\\memorymapview.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\memoryMaps\\memoryMapsVisualizer\\registergraphitem.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\otherClockDrivers\\otherclockdriversmodel.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\otherClockDrivers\\clockdriversdelegate.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\otherClockDrivers\\otherclockdriverseditor.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\parameters\\parameterseditor.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\ports\\portsdelegate.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\ports\\portseditor.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\ports\\portsmodel.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\ports\\PortsView.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\software\\PropertyValueModel.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\software\\SWPropertiesEditor.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\software\\PropertyValueDelegate.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\software\\PropertyValueEditor.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\software\\apiInterface\\apiinterfaceseditor.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\software\\apiInterface\\apiinterfacesmodel.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\software\\apiInterface\\ApiInterfaceEditor.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\software\\apiInterface\\apiinterfacesdelegate.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\software\\comInterface\\cominterfaceseditor.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\software\\comInterface\\cominterfacesmodel.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\software\\comInterface\\ComInterfaceEditor.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\software\\comInterface\\cominterfacesdelegate.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\software\\systemView\\SystemViewEditor.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\software\\systemView\\SystemViewsEditor.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\software\\systemView\\SystemViewsModel.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\treeStructure\\componenteditorrootitem.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\treeStructure\\componenteditorswpropertiesitem.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\treeStructure\\ComponentEditorSystemViewItem.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\treeStructure\\ComponentEditorSystemViewsItem.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\treeStructure\\componenteditortreemodel.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\treeStructure\\ComponentEditorTreeSortProxyModel.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\treeStructure\\componenteditorviewitem.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\treeStructure\\componenteditorviewsitem.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\treeStructure\\componenttreeview.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\treeStructure\\componenteditoraddrblockitem.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\treeStructure\\componenteditoraddrspaceitem.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\treeStructure\\componenteditoraddrspacesitem.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\treeStructure\\componenteditorapiinterfaceitem.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\treeStructure\\componenteditorapiinterfacesitem.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\treeStructure\\componenteditorbusinterfaceitem.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\treeStructure\\componenteditorbusinterfacesitem.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\treeStructure\\componenteditorchannelsitem.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\treeStructure\\componenteditorcominterfaceitem.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\treeStructure\\componenteditorcominterfacesitem.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\treeStructure\\componenteditorcpusitem.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\treeStructure\\componenteditorfielditem.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\treeStructure\\componenteditorfileitem.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\treeStructure\\componenteditorfilesetitem.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\treeStructure\\componenteditorfilesetsitem.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\treeStructure\\componenteditorgeneralitem.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\treeStructure\\componenteditorgroupslot.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\treeStructure\\componenteditoritem.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\treeStructure\\componenteditormemmapitem.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\treeStructure\\componenteditormemmapsitem.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\treeStructure\\componenteditorotherclocksitem.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\treeStructure\\componenteditorparametersitem.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\treeStructure\\componenteditorportsitem.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\treeStructure\\componenteditorregisteritem.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\views\\vieweditor.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\views\\viewseditor.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\views\\viewsmodel.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\views\\envidentifiereditor.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\views\\envidentifiersmodel.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\visualization\\fieldgapitem.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\visualization\\memorygapitem.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\visualization\\memoryvisualizationitem.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\itemeditor.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\itemvisualizer.h\">\r\n    </QtMoc>\r\n    <ClInclude Include=\"editors\\CSourceEditor\\CSourceContentMatcher.h\" />\r\n    <QtMoc Include=\"editors\\CSourceEditor\\CSourceHighlighter.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\CSourceEditor\\CSourceTextEdit.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\CSourceEditor\\CSourceWidget.h\">\r\n    </QtMoc>\r\n    <ClInclude Include=\"Help\\HelpSystem\\HelpWindow.h\" />\r\n    <QtMoc Include=\"kactusGenerators\\DocumentGenerator\\documentgenerator.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"mainwindow\\MessageConsole\\messageconsole.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"mainwindow\\NewPages\\NewApiDefinitionPage.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"mainwindow\\NewPages\\NewBusDefinitionPage.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"mainwindow\\NewPages\\NewComDefinitionPage.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"mainwindow\\NewPages\\NewComponentPage.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"mainwindow\\NewPages\\NewDesignPage.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"mainwindow\\NewPages\\NewPage.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"mainwindow\\NewPages\\NewSWComponentPage.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"mainwindow\\NewPages\\NewSWDesignPage.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"mainwindow\\NewPages\\NewSystemPage.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"mainwindow\\Ribbon\\Ribbon.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"mainwindow\\Ribbon\\RibbonGroup.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"settings\\SettingsPage.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"wizards\\BusInterfaceWizard\\BusInterfaceWizardConclusionPage.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"wizards\\BusInterfaceWizard\\BusInterfaceWizardGeneralOptionsPage.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"wizards\\BusInterfaceWizard\\BusInterfaceWizardIntroPage.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"wizards\\BusInterfaceWizard\\BusInterfaceWizardPortMapPage.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"wizards\\ComponentWizard\\ComponentWizard.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"wizards\\ComponentWizard\\ComponentWizardConclusionPage.h\">\r\n    </QtMoc>\r\n    <ClInclude Include=\"wizards\\ComponentWizard\\ComponentWizardDependencyPage.h\" />\r\n    <QtMoc Include=\"wizards\\ComponentWizard\\ComponentWizardImportPage.h\">\r\n    </QtMoc>\r\n    <ClInclude Include=\"wizards\\ComponentWizard\\ComponentWizardIntroPage.h\" />\r\n    <ClInclude Include=\"wizards\\ComponentWizard\\ComponentWizardPages.h\" />\r\n    <QtMoc Include=\"wizards\\ComponentWizard\\ComponentWizardGeneralInfoPage.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"common\\dialogs\\LibrarySettingsDialog\\librarysettingsdelegate.h\">\r\n    </QtMoc>\r\n    <ClInclude Include=\"common\\dialogs\\NewBusDialog\\NewBusDialog.h\" />\r\n    <ClInclude Include=\"common\\KactusColors.h\" />\r\n    <ClInclude Include=\"common\\TextEditProvider.h\" />\r\n    <QtMoc Include=\"common\\widgets\\fileTypeSelector\\filetypeselector.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"common\\widgets\\DirectoryListSelector\\DirectoryListSelector.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"common\\widgets\\EnumCollectionEditor\\EnumCollectionEditor.h\">\r\n      <AdditionalInputs Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">%(AdditionalInputs)</AdditionalInputs>\r\n      <Message Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n      </Message>\r\n      <Outputs Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n      </Outputs>\r\n      <Command Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n      </Command>\r\n      <AdditionalInputs Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">%(AdditionalInputs)</AdditionalInputs>\r\n      <Message Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n      </Message>\r\n      <Outputs Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n      </Outputs>\r\n      <Command Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n      </Command>\r\n      <AdditionalInputs Condition=\"'$(Configuration)|$(Platform)'=='Template|x64'\">%(AdditionalInputs)</AdditionalInputs>\r\n      <Message Condition=\"'$(Configuration)|$(Platform)'=='Template|x64'\">\r\n      </Message>\r\n      <Outputs Condition=\"'$(Configuration)|$(Platform)'=='Template|x64'\">\r\n      </Outputs>\r\n      <Command Condition=\"'$(Configuration)|$(Platform)'=='Template|x64'\">\r\n      </Command>\r\n    </QtMoc>\r\n    <QtMoc Include=\"common\\widgets\\listManager\\dirlistmanagermodel.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"common\\widgets\\FileSelector\\fileselector.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"common\\widgets\\LibrarySelectorWidget\\LibrarySelectorWidget.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"common\\widgets\\LibrarySelectorWidget\\LibraryPathEditor\\librarypatheditor.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"common\\widgets\\LibrarySelectorWidget\\LibraryPathSelector\\librarypathselector.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"common\\widgets\\viewSelector\\viewselector.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"mainwindow\\NewWorkspaceDialog.h\">\r\n    </QtMoc>\r\n    <ClInclude Include=\"mainwindow\\SplashScreen.h\" />\r\n    <QtMoc Include=\"mainwindow\\DeleteWorkspaceDialog.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"settings\\PluginSettingsPage.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"settings\\FileTypeSettingsPage.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"settings\\FileTypesModel.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"settings\\FileTypesDelegate.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"settings\\filetypesview.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"settings\\k2envvariablesettingspage.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"settings\\k2envvarmodel.h\">\r\n    </QtMoc>\r\n    <ClInclude Include=\"settings\\SettingsUpdater.h\" />\r\n    <QtMoc Include=\"settings\\SettingsDialog.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"settings\\NamingPolicySettingsPage.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"settings\\GeneralSettingsPage.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"settings\\CodeEditorSettingsPage.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"mainwindow\\mainwindow.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"common\\IEditProvider.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"common\\GenericEditProvider.h\">\r\n    </QtMoc>\r\n    <ClInclude Include=\"common\\dialogs\\listSelectDialog\\ListSelectDialog.h\" />\r\n    <ClInclude Include=\"common\\graphicsItems\\ConnectionUndoCommands.h\" />\r\n    <ClInclude Include=\"common\\graphicsItems\\GraphicsColumnUndoCommands.h\" />\r\n    <ClInclude Include=\"common\\graphicsItems\\GraphicsItemTypes.h\" />\r\n    <ClInclude Include=\"common\\graphicsItems\\IGraphicsItemStack.h\" />\r\n    <ClInclude Include=\"common\\layouts\\HCollisionLayout.h\" />\r\n    <ClInclude Include=\"common\\layouts\\HStackedLayout.h\" />\r\n    <ClInclude Include=\"common\\layouts\\IHGraphicsLayout.h\" />\r\n    <ClInclude Include=\"common\\layouts\\IVGraphicsLayout.h\" />\r\n    <ClInclude Include=\"common\\layouts\\VCollisionLayout.h\" />\r\n    <ClInclude Include=\"common\\layouts\\VStackedLayout.h\" />\r\n    <ClInclude Include=\"common\\layouts\\VStaticLayout.h\" />\r\n    <ClInclude Include=\"common\\widgets\\assistedLineEdit\\BasicLineContentMatcher.h\" />\r\n    <ClInclude Include=\"common\\widgets\\assistedLineEdit\\ILineContentMatcher.h\" />\r\n    <ClInclude Include=\"common\\widgets\\assistedLineEdit\\LineContentAssistWidget.h\" />\r\n    <ClInclude Include=\"common\\widgets\\assistedTextEdit\\HighlightStyleDesc.h\" />\r\n    <ClInclude Include=\"common\\widgets\\assistedTextEdit\\ITextContentMatcher.h\" />\r\n    <ClInclude Include=\"common\\widgets\\assistedTextEdit\\TextContentAssistWidget.h\" />\r\n    <ClInclude Include=\"common\\widgets\\SnippetTextEdit\\SnippetHighlighter.h\" />\r\n    <ClInclude Include=\"common\\widgets\\vlnvEditor\\VLNVContentMatcher.h\" />\r\n    <ClInclude Include=\"common\\widgets\\vlnvEditor\\VLNVDataTree.h\" />\r\n    <QtMoc Include=\"common\\widgets\\vlnvEditor\\vlnveditor.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"common\\widgets\\vlnvDisplayer\\vlnvdisplayer.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"common\\widgets\\usageComboBox\\usagecombobox.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"common\\widgets\\testConstraintComboBox\\testconstraintcombobox.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"common\\widgets\\tabDocument\\TabDocument.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"common\\widgets\\summaryLabel\\summarylabel.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"common\\widgets\\SnippetTextEdit\\SnippetTextEdit.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"common\\widgets\\readActionComboBox\\readactioncombobox.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"common\\widgets\\nameGroupEditor\\namegroupeditor.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"common\\widgets\\nameGroupBox\\namegroupbox.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"common\\widgets\\modWriteComboBox\\modwritecombobox.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"common\\widgets\\listManager\\listmanagermodel.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"common\\widgets\\listManager\\listmanager.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"common\\widgets\\listManager\\listeditor.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"common\\widgets\\listManager\\dirlistmanager.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"common\\widgets\\LineEditEx\\LineEditEx.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"common\\widgets\\kactusAttributeEditor\\KactusAttributeEditor.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"common\\widgets\\interfaceSelector\\interfaceselector.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"common\\widgets\\interfaceModeSelector\\interfacemodeselector.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"common\\widgets\\componentPreviewBox\\ComponentPreviewBox.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"common\\widgets\\colorBox\\ColorBox.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"common\\widgets\\booleanComboBox\\booleancombobox.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"common\\widgets\\assistedTextEdit\\ToolTipHintWidget.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"common\\widgets\\assistedTextEdit\\AssistedTextEdit.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"common\\widgets\\assistedLineEdit\\AssistedLineEdit.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"common\\widgets\\accessComboBox\\accesscombobox.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"common\\views\\EditableTableView\\editabletableview.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"common\\views\\EditableListView\\editablelistview.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"common\\validators\\LibraryPathValidator\\librarypathvalidator.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"common\\graphicsItems\\visualizeritem.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"common\\graphicsItems\\GraphicsRectButton.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"common\\graphicsItems\\GraphicsLineEdit.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"common\\graphicsItems\\graphicsexpandcollapseitem.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"common\\graphicsItems\\GraphicsConnection.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"common\\graphicsItems\\GraphicsColumnLayout.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"common\\graphicsItems\\GraphicsColumn.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"common\\graphicsItems\\expandableitem.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"common\\graphicsItems\\ConnectionEndpoint.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"common\\graphicsItems\\ComponentItem.h\">\r\n    </QtMoc>\r\n    <CustomBuild Include=\"common\\graphicsItems\\CommonGraphicsUndoCommands.h\">\r\n      <AdditionalInputs Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">%(AdditionalInputs)</AdditionalInputs>\r\n      <Message Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n      </Message>\r\n      <Outputs Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n      </Outputs>\r\n      <AdditionalInputs Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">%(AdditionalInputs)</AdditionalInputs>\r\n      <Message Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n      </Message>\r\n      <Outputs Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n      </Outputs>\r\n      <AdditionalInputs Condition=\"'$(Configuration)|$(Platform)'=='Template|x64'\">%(AdditionalInputs)</AdditionalInputs>\r\n      <Message Condition=\"'$(Configuration)|$(Platform)'=='Template|x64'\">\r\n      </Message>\r\n      <Outputs Condition=\"'$(Configuration)|$(Platform)'=='Template|x64'\">\r\n      </Outputs>\r\n      <Command Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n      </Command>\r\n      <Command Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n      </Command>\r\n      <Command Condition=\"'$(Configuration)|$(Platform)'=='Template|x64'\">\r\n      </Command>\r\n    </CustomBuild>\r\n    <QtMoc Include=\"common\\dialogs\\propertyPageDialog\\PropertyPageView.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"common\\dialogs\\propertyPageDialog\\PropertyPageDialog.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"common\\dialogs\\newObjectDialog\\newobjectdialog.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"common\\dialogs\\NewDesignDialog\\NewDesignDialog.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"common\\dialogs\\LibrarySettingsDialog\\LibrarySettingsDialog.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"common\\dialogs\\createConfigurationDialog\\createconfigurationdialog.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"common\\dialogs\\comboSelector\\comboselector.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"common\\delegates\\LineEditDelegate\\lineeditdelegate.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"common\\delegates\\ComboDelegate\\combodelegate.h\">\r\n    </QtMoc>\r\n  </ItemGroup>\r\n  <ItemGroup>\r\n    <None Include=\"common\\graphicsItems\\ConnectionItem.inl\" />\r\n    <None Include=\"common\\layouts\\VNoCollisionNoMovementLayout.inl\" />\r\n    <None Include=\"wizards\\common\\IPXactElementComparator.inl\" />\r\n    <None Include=\"wizards\\common\\ListComparator.inl\" />\r\n  </ItemGroup>\r\n  <ItemGroup>\r\n    <Image Include=\"appicon.ico\" />\r\n  </ItemGroup>\r\n  <Import Project=\"$(VCTargetsPath)\\Microsoft.Cpp.targets\" />\r\n  <ImportGroup Condition=\"Exists('$(QtMsBuild)\\qt.targets')\">\r\n    <Import Project=\"$(QtMsBuild)\\qt.targets\" />\r\n  </ImportGroup>\r\n  <ImportGroup Label=\"ExtensionTargets\">\r\n  </ImportGroup>\r\n  <ProjectExtensions>\r\n    <VisualStudio>\r\n      <UserProperties BuildVersion_AssemblyInfoFilename=\"VersionInfo.h\" BuildVersion_BuildVersioningStyle=\"None.None.Increment.None\" QtVersion_x0020_Win32=\"4.8.3\" QtVersion_x0020_x64=\"4.8.3 x64\" />\r\n    </VisualStudio>\r\n  </ProjectExtensions>\r\n</Project>"
  },
  {
    "path": "Kactus2.vcxproj.filters",
    "content": "﻿<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n<Project ToolsVersion=\"4.0\" xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">\r\n  <ItemGroup>\r\n    <Filter Include=\"Source Files\">\r\n      <UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>\r\n      <Extensions>cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>\r\n    </Filter>\r\n    <Filter Include=\"Source Files\\common\">\r\n      <UniqueIdentifier>{792edc79-02fb-4ce2-bc23-ea28b4bca535}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Source Files\\common\\dialogs\">\r\n      <UniqueIdentifier>{128d8c08-5d81-4b17-a027-fe5abee57430}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Source Files\\common\\dialogs\\comboSelector\">\r\n      <UniqueIdentifier>{0982a198-ea3b-4b12-8727-d97a825328eb}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Source Files\\common\\dialogs\\propertyPageDialog\">\r\n      <UniqueIdentifier>{d0a6998c-b8be-44d9-990c-5bae5098f4b4}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Source Files\\common\\dialogs\\newObjectDialog\">\r\n      <UniqueIdentifier>{537c1c46-d688-4418-81d8-9b93df040ad7}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Source Files\\common\\dialogs\\createConfigurationDialog\">\r\n      <UniqueIdentifier>{010cadd1-66f5-471c-9703-9704e3644b33}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Source Files\\common\\dialogs\\listSelectDialog\">\r\n      <UniqueIdentifier>{38b93673-aaa0-4212-87f5-3500dd285e0f}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Source Files\\common\\dialogs\\NewDesignDialog\">\r\n      <UniqueIdentifier>{7c710c32-349c-4574-8c04-d597c3aa6914}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Source Files\\common\\dialogs\\LibrarySettingsDialog\">\r\n      <UniqueIdentifier>{7dec263d-8a76-4954-89df-3c0936f40a92}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Source Files\\common\\validators\">\r\n      <UniqueIdentifier>{9599a4e0-6552-4be6-8137-6e14f125627f}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Source Files\\common\\validators\\LibraryPathValidator\">\r\n      <UniqueIdentifier>{b1695f49-12de-4829-b90d-500b8fdd0d38}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Source Files\\common\\widgets\">\r\n      <UniqueIdentifier>{c1129187-0057-4433-b8da-1bfef46e6ddf}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Source Files\\common\\widgets\\assistedLineEdit\">\r\n      <UniqueIdentifier>{19f9c0a7-402c-4d71-83fd-40ce94b287fa}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Source Files\\common\\widgets\\listManager\">\r\n      <UniqueIdentifier>{e015c02b-66b4-460c-97c8-90cb481826d7}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Source Files\\common\\widgets\\nameGroupBox\">\r\n      <UniqueIdentifier>{e7e74448-026d-43cb-94f1-9d7fde390615}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Source Files\\common\\widgets\\vlnvDisplayer\">\r\n      <UniqueIdentifier>{92b3960c-d9ae-4d9f-8f6e-ef2500695fd2}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Source Files\\common\\widgets\\assistedTextEdit\">\r\n      <UniqueIdentifier>{81107c0b-459e-4f73-908c-9d98eb5ddd88}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Source Files\\common\\widgets\\vlnvEditor\">\r\n      <UniqueIdentifier>{25082fa5-fab4-4915-b95c-4bc09cb36d2c}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Source Files\\common\\widgets\\kactusAttributeEditor\">\r\n      <UniqueIdentifier>{01864007-5bc7-48a4-833c-99ad0494ed72}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Source Files\\common\\widgets\\componentPreviewBox\">\r\n      <UniqueIdentifier>{fcfcd609-7a07-4253-8135-d0832d9c38ac}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Source Files\\common\\widgets\\tabDocument\">\r\n      <UniqueIdentifier>{1dd8f03d-6a4c-479f-a374-c8627b2b14e0}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Source Files\\common\\widgets\\booleanComboBox\">\r\n      <UniqueIdentifier>{996434f3-7697-4fb2-9356-3df1f317ec3b}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Source Files\\common\\widgets\\ParameterGroupBox\">\r\n      <UniqueIdentifier>{ad13bc80-2bc0-4bec-96bc-d47541c21bde}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Source Files\\common\\widgets\\nameGroupEditor\">\r\n      <UniqueIdentifier>{7bd57c00-0edd-431f-b688-641e72257559}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Source Files\\common\\widgets\\summaryLabel\">\r\n      <UniqueIdentifier>{8cfa5833-dc8b-40c8-a126-aa5e581ccad1}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Source Files\\common\\widgets\\interfaceModeSelector\">\r\n      <UniqueIdentifier>{f98df068-5745-46d9-b18d-f5c32817fad6}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Source Files\\common\\widgets\\interfaceSelector\">\r\n      <UniqueIdentifier>{83f927c0-235c-44d5-901f-0e0f720be325}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Source Files\\common\\widgets\\LineEditEx\">\r\n      <UniqueIdentifier>{64aa0fcf-fb37-41dd-a6c8-fd01f4dfbc80}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Source Files\\common\\widgets\\SnippetTextEdit\">\r\n      <UniqueIdentifier>{df803563-6875-4e92-9a16-e11f3f55a516}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Source Files\\common\\widgets\\usageComboBox\">\r\n      <UniqueIdentifier>{4c144899-a8e8-45b4-9a31-5d3508fbf503}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Source Files\\common\\widgets\\accessComboBox\">\r\n      <UniqueIdentifier>{6e475f73-23e8-4759-a54f-1150e3cc403d}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Source Files\\common\\widgets\\modWriteComboBox\">\r\n      <UniqueIdentifier>{d70d0e3d-078f-4868-a7c0-29900cc4beaa}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Source Files\\common\\widgets\\readActionComboBox\">\r\n      <UniqueIdentifier>{84c56f1c-444c-4c3f-bc76-4e8d4a6944d1}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Source Files\\common\\widgets\\testConstraintComboBox\">\r\n      <UniqueIdentifier>{8486f35a-40d2-4693-87a2-103a252494f2}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Source Files\\common\\layouts\">\r\n      <UniqueIdentifier>{77f79776-02af-4c9b-a1d5-4005fb5f8f83}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Source Files\\common\\graphicsItems\">\r\n      <UniqueIdentifier>{56756a23-9341-4dd6-86ee-7b207ac3ef2b}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Source Files\\common\\delegates\">\r\n      <UniqueIdentifier>{e97f2593-ddfb-45f7-95cf-659ed2647a24}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Source Files\\common\\delegates\\ComboDelegate\">\r\n      <UniqueIdentifier>{da1cc137-e842-4fbd-9189-7e733add7519}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Source Files\\common\\delegates\\LineEditDelegate\">\r\n      <UniqueIdentifier>{f86a2c88-b4a4-4172-8a70-69647d3808aa}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Source Files\\common\\views\">\r\n      <UniqueIdentifier>{141e5351-c06a-4c45-8930-b416eae62ba1}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Source Files\\common\\views\\EditableTableView\">\r\n      <UniqueIdentifier>{d6590e70-2139-408b-a8e4-87599d9ff04b}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Source Files\\common\\views\\EditableListView\">\r\n      <UniqueIdentifier>{6de0a5bf-1732-4f2d-a253-187552c618a9}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Source Files\\mainwindow\">\r\n      <UniqueIdentifier>{5632e02c-bce4-40b7-b3e1-fa2400380d5e}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Source Files\\settings\">\r\n      <UniqueIdentifier>{78fb2d79-16b8-4d2b-9ee0-4ac09b03b0f5}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Header Files\">\r\n      <UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>\r\n      <Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>\r\n    </Filter>\r\n    <Filter Include=\"Header Files\\common\">\r\n      <UniqueIdentifier>{74c0b989-0f15-49e5-88ed-8848d2189d79}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Header Files\\common\\widgets\">\r\n      <UniqueIdentifier>{f6f5f3e0-6e98-4f04-92e8-de7d11fc9525}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Header Files\\common\\widgets\\listManager\">\r\n      <UniqueIdentifier>{46aae604-21e9-4d2d-b59e-aa4a1d490d44}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Header Files\\common\\widgets\\nameGroupBox\">\r\n      <UniqueIdentifier>{19886b51-94c4-4e94-86bc-f397b610f64d}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Header Files\\common\\widgets\\assistedLineEdit\">\r\n      <UniqueIdentifier>{e30fe0ab-418e-448b-87d7-d9195b7fd258}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Header Files\\common\\widgets\\vlnvDisplayer\">\r\n      <UniqueIdentifier>{4fdecffa-ac07-42c8-b9f6-6f1135e5f99c}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Header Files\\common\\widgets\\booleanComboBox\">\r\n      <UniqueIdentifier>{420c19f9-c40b-4cd3-aeab-b6c4ae973e3f}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Header Files\\common\\widgets\\tabDocument\">\r\n      <UniqueIdentifier>{10b24e58-7d7a-4ebb-b44b-815bcd42d095}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Header Files\\common\\widgets\\assistedTextEdit\">\r\n      <UniqueIdentifier>{4740aa99-89b1-4c84-b85d-157b0dffa221}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Header Files\\common\\widgets\\vlnvEditor\">\r\n      <UniqueIdentifier>{5cf40f57-045c-497d-9d2f-9b6db938d0d9}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Header Files\\common\\widgets\\colorBox\">\r\n      <UniqueIdentifier>{5a13fc49-6863-46b9-a6fc-78b6b9f5fc77}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Header Files\\common\\widgets\\kactusAttributeEditor\">\r\n      <UniqueIdentifier>{b4ffe796-62f0-434f-8de7-00c4cd275685}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Header Files\\common\\widgets\\componentPreviewBox\">\r\n      <UniqueIdentifier>{b5d5c333-036b-4276-a7ef-a400082b82be}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Header Files\\common\\widgets\\ParameterGroupBox\">\r\n      <UniqueIdentifier>{84b4b9a9-cae5-43bc-bac4-f574ebe3ece8}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Header Files\\common\\widgets\\nameGroupEditor\">\r\n      <UniqueIdentifier>{dd95d98f-650f-4006-948c-7b6c4ea8ec8f}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Header Files\\common\\widgets\\summaryLabel\">\r\n      <UniqueIdentifier>{e769d5d7-e794-4127-a49e-32d3c0781559}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Header Files\\common\\widgets\\interfaceModeSelector\">\r\n      <UniqueIdentifier>{866f1e78-b5de-4717-b036-11a2bee9084c}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Header Files\\common\\widgets\\interfaceSelector\">\r\n      <UniqueIdentifier>{0b8eccd5-4625-4845-ad73-d4c055dd0a1f}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Header Files\\common\\widgets\\LineEditEx\">\r\n      <UniqueIdentifier>{7ca967c2-4ac3-4cd5-b437-e1ecef333f23}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Header Files\\common\\widgets\\SnippetTextEdit\">\r\n      <UniqueIdentifier>{16679fa2-a994-4220-b63f-52219810726e}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Header Files\\common\\widgets\\usageComboBox\">\r\n      <UniqueIdentifier>{f292d53a-6e1d-4cf0-adbb-0afb5e156322}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Header Files\\common\\widgets\\accessComboBox\">\r\n      <UniqueIdentifier>{81ed486f-8158-4fe1-ae5c-9f4de8c55edd}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Header Files\\common\\widgets\\modWriteComboBox\">\r\n      <UniqueIdentifier>{a609d021-477e-41f3-8560-e65f1ff25fb3}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Header Files\\common\\widgets\\readActionComboBox\">\r\n      <UniqueIdentifier>{b5890c53-8af0-4e62-9ede-f11d0799f1e5}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Header Files\\common\\widgets\\testConstraintComboBox\">\r\n      <UniqueIdentifier>{d9507c86-d89b-4a67-89e9-27307109e139}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Header Files\\common\\validators\">\r\n      <UniqueIdentifier>{f5ae2583-95fe-4538-a9a4-9bbdcf0d40fd}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Header Files\\common\\validators\\LibraryPathValidator\">\r\n      <UniqueIdentifier>{db8e622f-3a71-4cbe-ba2a-483c24c45b56}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Header Files\\common\\layouts\">\r\n      <UniqueIdentifier>{bda358f4-ebe0-4c2f-93ab-1f16b28d1ebd}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Header Files\\common\\graphicsItems\">\r\n      <UniqueIdentifier>{582267be-1476-4823-a215-511b7bc1de15}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Header Files\\common\\delegates\">\r\n      <UniqueIdentifier>{2908f74c-a3ff-4a40-b475-82d29db38b9c}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Header Files\\common\\delegates\\ComboDelegate\">\r\n      <UniqueIdentifier>{13136b63-143e-49e3-9f33-19e833ce3ecd}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Header Files\\common\\delegates\\LineEditDelegate\">\r\n      <UniqueIdentifier>{c8eed9a0-3e9c-493b-a912-4c956376812e}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Header Files\\common\\views\">\r\n      <UniqueIdentifier>{51426a3d-cf84-481d-bc6d-8123694ee947}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Header Files\\common\\views\\EditableTableView\">\r\n      <UniqueIdentifier>{d09b5f63-ae79-46a2-834f-d53e1d96b856}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Header Files\\common\\views\\EditableListView\">\r\n      <UniqueIdentifier>{86e93b71-14bb-409e-b879-04d76b89c463}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Header Files\\common\\dialogs\">\r\n      <UniqueIdentifier>{748059de-87cd-4e11-b299-00c41a923369}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Header Files\\common\\dialogs\\comboSelector\">\r\n      <UniqueIdentifier>{29cb5044-f4e8-42ce-a210-4f58af3072fc}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Header Files\\common\\dialogs\\propertyPageDialog\">\r\n      <UniqueIdentifier>{c0ff59ef-39b3-4373-9bc0-7119fed57e95}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Header Files\\common\\dialogs\\newObjectDialog\">\r\n      <UniqueIdentifier>{d72f5ab7-c217-4da3-9cf1-426c8ecd81ba}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Header Files\\common\\dialogs\\listSelectDialog\">\r\n      <UniqueIdentifier>{b0e0cdc7-b4f9-4aa8-b8f7-64a71cb6361b}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Header Files\\common\\dialogs\\NewDesignDialog\">\r\n      <UniqueIdentifier>{9464f315-a3ce-41fc-8a42-a00ac607406f}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Header Files\\common\\dialogs\\LibrarySettingsDialog\">\r\n      <UniqueIdentifier>{585407e1-18a2-4d99-b824-49e1d45a1c12}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Header Files\\mainwindow\">\r\n      <UniqueIdentifier>{4de4886d-eb93-4769-b4b0-303692e58ea9}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Header Files\\settings\">\r\n      <UniqueIdentifier>{4fc7a21e-ab99-4732-b9b6-6f34021bdfb5}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Generated Files\">\r\n      <UniqueIdentifier>{71ED8ED8-ACB9-4CE9-BBE1-E00B30144E11}</UniqueIdentifier>\r\n      <Extensions>cpp;c;cxx;moc;h;def;odl;idl;res;</Extensions>\r\n    </Filter>\r\n    <Filter Include=\"Resource Files\">\r\n      <UniqueIdentifier>{D9D6E242-F8AF-46E4-B9FD-80ECBC20BA3E}</UniqueIdentifier>\r\n      <Extensions>qrc;*</Extensions>\r\n      <ParseFiles>false</ParseFiles>\r\n    </Filter>\r\n    <Filter Include=\"Form Files\">\r\n      <UniqueIdentifier>{99349809-55BA-4b9d-BF79-8FDBB0286EB3}</UniqueIdentifier>\r\n      <Extensions>ui</Extensions>\r\n      <ParseFiles>false</ParseFiles>\r\n    </Filter>\r\n    <Filter Include=\"Help Files\">\r\n      <UniqueIdentifier>{f5e527a5-3192-4d49-a325-436847f9e56b}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Header Files\\common\\dialogs\\createConfigurationDialog\">\r\n      <UniqueIdentifier>{4595fd3d-b102-46cb-8a5a-006537a68009}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Header Files\\common\\widgets\\viewSelector\">\r\n      <UniqueIdentifier>{64bfed55-d553-4a9b-a952-2e3d75498098}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Source Files\\common\\widgets\\viewSelector\">\r\n      <UniqueIdentifier>{c5987bbc-cec0-4224-b130-741ebd52633c}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Header Files\\common\\widgets\\fileTypeSelector\">\r\n      <UniqueIdentifier>{aa88d710-14c3-4611-ac07-75de94c2ea04}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Source Files\\common\\widgets\\fileTypeSelector\">\r\n      <UniqueIdentifier>{578b0af8-5300-460b-9009-b78db3e75e39}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Header Files\\common\\widgets\\EnumCollectionEditor\">\r\n      <UniqueIdentifier>{8e6e4587-2335-4cac-9734-29f279623065}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Source Files\\common\\widgets\\EnumCollectionEditor\">\r\n      <UniqueIdentifier>{91f601a7-3b40-46ca-948c-9db2dfa372e6}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Header Files\\common\\widgets\\FileSelector\">\r\n      <UniqueIdentifier>{e1b5c92c-2ad8-4366-8766-0e0dd5845044}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Source Files\\common\\widgets\\FileSelector\">\r\n      <UniqueIdentifier>{4fd994f9-e99b-4608-a6c2-0fbc6df9d786}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Source Files\\mainwindow\\NewPages\">\r\n      <UniqueIdentifier>{c5f861cd-161d-40dd-85cf-5c9af8ab6f37}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Source Files\\common\\widgets\\LibrarySelectorWidget\">\r\n      <UniqueIdentifier>{3669727f-e908-4e09-adb1-aea2788442e6}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Source Files\\common\\widgets\\LibrarySelectorWidget\\LibraryPathEditor\">\r\n      <UniqueIdentifier>{f6c762d1-f5d0-45dc-af47-6c6e95ae42c5}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Source Files\\common\\widgets\\LibrarySelectorWidget\\LibraryPathSelector\">\r\n      <UniqueIdentifier>{7a26ce2c-5f00-4280-8cd3-d85eb3768d1d}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Header Files\\common\\widgets\\LibrarySelectorWidget\">\r\n      <UniqueIdentifier>{35329cc7-3c1f-4065-a502-3f9c53f2455d}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Header Files\\common\\widgets\\LibrarySelectorWidget\\LibraryPathEditor\">\r\n      <UniqueIdentifier>{80b21f11-faa3-43e2-9790-7cdb70b46c2e}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Header Files\\common\\widgets\\LibrarySelectorWidget\\LibraryPathSelector\">\r\n      <UniqueIdentifier>{fe661274-ed8d-468f-a1ad-3834f52ccb6c}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Source Files\\common\\dialogs\\NewBusDialog\">\r\n      <UniqueIdentifier>{c24945c3-2148-4814-9d5b-16b984c5d5a5}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Header Files\\common\\dialogs\\NewBusDialog\">\r\n      <UniqueIdentifier>{afbcd084-85b3-425a-ae67-9016aae1e368}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Header Files\\common\\widgets\\DirectoryListSelector\">\r\n      <UniqueIdentifier>{f99fc9aa-a4b0-444d-a7e0-56017f38b79f}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Source Files\\common\\widgets\\DirectoryListSelector\">\r\n      <UniqueIdentifier>{d67f21c2-7206-4fe7-999d-98b1a6c4dc6f}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Source Files\\wizards\">\r\n      <UniqueIdentifier>{e9e5cd81-a0fc-4d98-a648-af5178ac26f9}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Source Files\\wizards\\ComponentWizard\">\r\n      <UniqueIdentifier>{190bc156-118d-4358-89b7-bcb53a73473e}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Header Files\\wizards\">\r\n      <UniqueIdentifier>{a0326c42-2235-4dee-bb2a-69019ebc7bc7}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Header Files\\wizards\\ComponentWizard\">\r\n      <UniqueIdentifier>{be6e1e65-e2a7-44ab-8df0-5daa1ac8ab14}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Header Files\\Help\">\r\n      <UniqueIdentifier>{49a211ee-ccfc-4853-a9a6-099a139b1dab}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Header Files\\Help\\HelpSystem\">\r\n      <UniqueIdentifier>{8b73cc82-7417-45d5-bf0f-a4bf81811ba5}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Source Files\\Help\">\r\n      <UniqueIdentifier>{2103255c-ef97-4919-a66a-5cc5f99f57e1}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Source Files\\Help\\HelpSystem\">\r\n      <UniqueIdentifier>{59279986-79fb-4355-9e6f-673e09806d31}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Header Files\\Plugins\">\r\n      <UniqueIdentifier>{8d955ae9-b301-48c4-ae1e-9bb92a65f3d9}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Source Files\\Plugins\">\r\n      <UniqueIdentifier>{85e8249e-7bf8-4c41-b66f-1a5255b75589}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Source Files\\library\">\r\n      <UniqueIdentifier>{700d0d99-bb8f-470d-a447-fb12cee9e11e}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Header Files\\library\">\r\n      <UniqueIdentifier>{94c09cd0-96f3-499b-8b78-8c00ee7f60c7}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Source Files\\wizards\\BusInterfaceWizard\">\r\n      <UniqueIdentifier>{043b6ec6-2d86-48dc-a6f2-dac4de1c28c0}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Header Files\\wizards\\BusInterfaceWizard\">\r\n      <UniqueIdentifier>{ad4d9bad-60d2-4149-a58c-991a136ac275}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Source Files\\editors\">\r\n      <UniqueIdentifier>{9e068034-a111-444f-a74a-9ac8f145a712}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Header Files\\editors\">\r\n      <UniqueIdentifier>{f023e626-bcd3-4d6b-8588-36fb28c685d7}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Source Files\\kactusGenerators\">\r\n      <UniqueIdentifier>{9e2200b5-c8b4-434a-9926-39ab71cf426e}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Source Files\\kactusGenerators\\DocumentGenerator\">\r\n      <UniqueIdentifier>{69521121-c455-4608-9dc4-da1c622addad}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Header Files\\kactusGenerators\">\r\n      <UniqueIdentifier>{92fda97e-e51f-4e8f-94dc-dd7b59575d10}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Header Files\\kactusGenerators\\DocumentGenerator\">\r\n      <UniqueIdentifier>{9e423b88-6032-4541-9a86-aa8855635370}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Source Files\\mainwindow\\MessageConsole\">\r\n      <UniqueIdentifier>{d0c9547c-34a4-4a9f-9160-deefc67f0b9a}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Header Files\\mainwindow\\MessageConsole\">\r\n      <UniqueIdentifier>{69d6b3ac-9838-45fb-9bf5-130aae3d6f7d}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Header Files\\mainwindow\\Ribbon\">\r\n      <UniqueIdentifier>{1e809727-d38c-4093-b47d-bffaf465f21c}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Source Files\\mainwindow\\Ribbon\">\r\n      <UniqueIdentifier>{e45d8aa5-fb2d-46f1-8109-f0af75e113c6}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Header Files\\mainwindow\\NewPages\">\r\n      <UniqueIdentifier>{ff1f42da-f845-43f9-b706-9e6abf435097}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Header Files\\editors\\ApiDefinitionEditor\">\r\n      <UniqueIdentifier>{ea420432-6c58-4982-a06f-60ed86e52e1a}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Source Files\\editors\\ApiDefinitionEditor\">\r\n      <UniqueIdentifier>{116be889-2be7-4118-b11d-c894fe24fb4a}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Source Files\\editors\\ComDefinitionEditor\">\r\n      <UniqueIdentifier>{3edee860-beea-4eda-b7b5-7a916e6da570}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Header Files\\editors\\ComDefinitionEditor\">\r\n      <UniqueIdentifier>{5a68258a-9267-4385-83ab-253c65f1d395}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Header Files\\editors\\ComponentEditor\">\r\n      <UniqueIdentifier>{9e482888-9857-4f14-9eac-b6d62e023456}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Header Files\\editors\\ComponentEditor\\general\">\r\n      <UniqueIdentifier>{ff4ccbc0-6562-4420-953b-ae15689a5ff3}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Header Files\\editors\\ComponentEditor\\ports\">\r\n      <UniqueIdentifier>{36f2127c-d40c-49c0-9e8b-27180b97b3ed}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Header Files\\editors\\ComponentEditor\\parameters\">\r\n      <UniqueIdentifier>{54465741-7a8d-4de6-99f2-deeb18d4e7a7}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Header Files\\editors\\ComponentEditor\\otherClockDrivers\">\r\n      <UniqueIdentifier>{9f06662d-2f45-4a1c-ac5c-3797e21e022e}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Header Files\\editors\\ComponentEditor\\channels\">\r\n      <UniqueIdentifier>{3b38b71b-f987-4acc-a558-57ae2adf5f7e}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Header Files\\editors\\ComponentEditor\\busInterfaces\">\r\n      <UniqueIdentifier>{b83d333e-6a5f-40c4-8f87-ce77eb2e694e}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Header Files\\editors\\ComponentEditor\\busInterfaces\\portmaps\">\r\n      <UniqueIdentifier>{555814dd-1c10-4892-a559-0aad50e0f1e4}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Header Files\\editors\\ComponentEditor\\fileBuilders\">\r\n      <UniqueIdentifier>{fc4ce65a-9e6b-4615-9994-01efe2c3f174}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Header Files\\editors\\ComponentEditor\\software\">\r\n      <UniqueIdentifier>{7b86e5b5-9424-41b4-ba6e-9f84608ed64f}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Header Files\\editors\\ComponentEditor\\software\\apiInterface\">\r\n      <UniqueIdentifier>{0ba740f9-1bbe-4c7e-99fc-9132a1237add}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Header Files\\editors\\ComponentEditor\\software\\comInterface\">\r\n      <UniqueIdentifier>{66c807c2-a1e3-495d-a098-0e1c76cee48f}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Header Files\\editors\\ComponentEditor\\software\\systemView\">\r\n      <UniqueIdentifier>{f5038f92-84e7-4b3d-be25-0457cda1d875}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Header Files\\editors\\ComponentEditor\\addressSpaces\">\r\n      <UniqueIdentifier>{49a8c9d8-63b6-4d8c-be8a-578dce9b5e3e}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Header Files\\editors\\ComponentEditor\\addressSpaces\\localMemoryMap\">\r\n      <UniqueIdentifier>{b83c0ee3-4734-4339-b8a5-06dfcd99d2f7}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Header Files\\editors\\ComponentEditor\\addressSpaces\\AddressSpaceVisualizer\">\r\n      <UniqueIdentifier>{54820ee4-b7b8-44fa-af96-cd562623dea1}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Header Files\\editors\\ComponentEditor\\cpus\">\r\n      <UniqueIdentifier>{ab3025bf-853a-457e-877d-5a6cfff0f887}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Header Files\\editors\\ComponentEditor\\views\">\r\n      <UniqueIdentifier>{aed53cc6-08e0-429d-a053-f145829c90b4}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Header Files\\editors\\ComponentEditor\\fileSet\">\r\n      <UniqueIdentifier>{03946b4b-6ab5-4a23-a82a-617a4f966ac9}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Header Files\\editors\\ComponentEditor\\fileSet\\file\">\r\n      <UniqueIdentifier>{7046cfbf-9a34-49b7-b84f-7fd75c49fb77}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Header Files\\editors\\ComponentEditor\\fileSet\\dependencyAnalysis\">\r\n      <UniqueIdentifier>{494842c1-c5c6-4ef7-b456-d173c72d786d}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Header Files\\editors\\ComponentEditor\\treeStructure\">\r\n      <UniqueIdentifier>{bee9b152-6eb9-4b85-9016-63516b0c60c3}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Header Files\\editors\\ComponentEditor\\visualization\">\r\n      <UniqueIdentifier>{ec63cac5-5b23-443d-a5d7-0dbb4cb79c21}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Source Files\\editors\\ComponentEditor\">\r\n      <UniqueIdentifier>{52e31645-c27d-494e-9a83-334ef6359ca0}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Source Files\\editors\\ComponentEditor\\busInterfaces\">\r\n      <UniqueIdentifier>{8a8f6ce9-b0c5-4ced-a292-5bd881867158}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Source Files\\editors\\ComponentEditor\\busInterfaces\\portmaps\">\r\n      <UniqueIdentifier>{44fe1f7a-326d-41eb-a91c-8bd6c9507e77}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Source Files\\editors\\ComponentEditor\\channels\">\r\n      <UniqueIdentifier>{fc3ff167-9e56-4ee6-a14c-88f1895b701c}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Source Files\\editors\\ComponentEditor\\fileBuilders\">\r\n      <UniqueIdentifier>{3ee6c93d-efb1-46bf-997c-67ee480d6bbd}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Source Files\\editors\\ComponentEditor\\fileSet\">\r\n      <UniqueIdentifier>{7b559bcf-9da5-493b-b61d-2140b0c92cb8}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Source Files\\editors\\ComponentEditor\\fileSet\\file\">\r\n      <UniqueIdentifier>{98ed010c-b145-48c6-9be6-d6e0bce5b575}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Source Files\\editors\\ComponentEditor\\fileSet\\dependencyAnalysis\">\r\n      <UniqueIdentifier>{febffc03-0aad-480e-b92d-e776f61887f2}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Source Files\\editors\\ComponentEditor\\general\">\r\n      <UniqueIdentifier>{900b90ab-3bb9-46cf-a0bd-681c45eb04dc}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Source Files\\editors\\ComponentEditor\\parameters\">\r\n      <UniqueIdentifier>{c9b71249-7b36-434d-b4b9-19a3e7c4e787}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Source Files\\editors\\ComponentEditor\\ports\">\r\n      <UniqueIdentifier>{5ed2a8a2-f394-4aeb-bb7c-e1f1580881e5}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Source Files\\editors\\ComponentEditor\\views\">\r\n      <UniqueIdentifier>{40db45f3-9af6-48b6-b46a-cca86dde8e5a}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Source Files\\editors\\ComponentEditor\\software\">\r\n      <UniqueIdentifier>{f63cc637-db09-4f6c-b0c9-f350cc9862f8}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Source Files\\editors\\ComponentEditor\\software\\apiInterface\">\r\n      <UniqueIdentifier>{15e9dbdf-cf7e-4d49-bebb-f6d2b5a7f40e}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Source Files\\editors\\ComponentEditor\\software\\comInterface\">\r\n      <UniqueIdentifier>{54646408-17d2-49d4-af9d-2c74b5fa2cd8}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Source Files\\editors\\ComponentEditor\\software\\systemView\">\r\n      <UniqueIdentifier>{4b04b8f3-ce92-415d-9e1b-6aa39a486c05}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Source Files\\editors\\ComponentEditor\\addressSpaces\">\r\n      <UniqueIdentifier>{0c3cf187-6d5e-419b-b949-d6e0230193c0}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Source Files\\editors\\ComponentEditor\\addressSpaces\\localMemoryMap\">\r\n      <UniqueIdentifier>{25c8eba8-f607-4ca8-a2cd-d76cd2e42a6f}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Source Files\\editors\\ComponentEditor\\addressSpaces\\addressSpaceVisualizer\">\r\n      <UniqueIdentifier>{01f05afe-7ee2-4f80-aef7-2e637da1ffe9}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Source Files\\editors\\ComponentEditor\\cpus\">\r\n      <UniqueIdentifier>{1cc7b764-e10e-42b8-afba-9ab1614f7c5c}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Source Files\\editors\\ComponentEditor\\memoryMaps\">\r\n      <UniqueIdentifier>{e0f2661f-44f5-48f2-ab77-993c7dc6ee4d}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Source Files\\editors\\ComponentEditor\\memoryMaps\\memoryMapsVisualizer\">\r\n      <UniqueIdentifier>{f89e3fcc-b137-429f-adcd-d8e5e9eef8dd}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Source Files\\editors\\ComponentEditor\\treeStructure\">\r\n      <UniqueIdentifier>{45142286-562d-484c-8328-60ce57fe5ceb}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Source Files\\editors\\ComponentEditor\\visualization\">\r\n      <UniqueIdentifier>{8548c639-7a0c-4828-894c-1badeb9906d2}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Header Files\\editors\\CSourceEditor\">\r\n      <UniqueIdentifier>{0d6b0b85-6278-4e56-919e-ea7d6f9c1d58}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Source Files\\editors\\CSourceEditor\">\r\n      <UniqueIdentifier>{b3a65de6-002a-4ddf-a213-84e64c40de2e}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Source Files\\wizards\\ImportWizard\">\r\n      <UniqueIdentifier>{79e351da-6711-4900-a6e8-9c4458cf05b6}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Header Files\\wizards\\ImportWizard\">\r\n      <UniqueIdentifier>{6f42427e-c506-4580-9696-80e379d55645}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Source Files\\wizards\\common\">\r\n      <UniqueIdentifier>{2cbe03c7-4c87-4b43-b27f-c503469aea86}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Source Files\\wizards\\common\\ComponentComparator\">\r\n      <UniqueIdentifier>{78aaebcf-d7ff-4b74-8ddf-3d403c57567f}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Source Files\\wizards\\common\\ComponentDiffWidget\">\r\n      <UniqueIdentifier>{66b96a4c-637e-491b-b711-a2867749e617}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Source Files\\wizards\\common\\VLNVComparator\">\r\n      <UniqueIdentifier>{58b89f97-2030-4f6a-975d-68304a6d8c9b}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Header Files\\wizards\\common\">\r\n      <UniqueIdentifier>{d49974e3-fb2b-4058-97cf-c009c4cfba8f}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Header Files\\wizards\\common\\ComponentComparator\">\r\n      <UniqueIdentifier>{d7ac841c-e3a1-4f32-8131-4ff1e19ddcc3}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Header Files\\wizards\\common\\ComponentDiffWidget\">\r\n      <UniqueIdentifier>{320f1e99-893c-4529-9c81-78f5fb9efe47}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Header Files\\wizards\\common\\VLNVComparator\">\r\n      <UniqueIdentifier>{a731797b-1fa9-4096-9996-badb0678bc16}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Source Files\\wizards\\common\\ViewComparator\">\r\n      <UniqueIdentifier>{6cbed638-9038-44ab-bfe3-bbb67577f03a}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Header Files\\wizards\\common\\ViewComparator\">\r\n      <UniqueIdentifier>{4708f5f6-8ad7-4679-8c24-3e608fd64fa5}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Header Files\\wizards\\common\\PortComparator\">\r\n      <UniqueIdentifier>{b8553848-2169-48b3-902d-606dabbc6e56}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Source Files\\wizards\\common\\PortComparator\">\r\n      <UniqueIdentifier>{3b832046-1d83-4d92-afcb-650eef30f7f7}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Header Files\\editors\\ComponentEditor\\choices\">\r\n      <UniqueIdentifier>{1257e1ed-a818-4b74-a60d-b43044f8e3cb}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Source Files\\editors\\ComponentEditor\\choices\">\r\n      <UniqueIdentifier>{6e2cfaa5-fd19-4942-b503-224f59debfe6}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Source Files\\editors\\ComponentEditor\\common\">\r\n      <UniqueIdentifier>{3559219f-8f07-404d-83e6-419e4871e352}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Header Files\\editors\\ComponentEditor\\common\">\r\n      <UniqueIdentifier>{43667a89-3a58-492a-84ec-fe02b42dd193}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Source Files\\editors\\ComponentEditor\\referenceCounter\">\r\n      <UniqueIdentifier>{1f3d8e2d-084f-475e-be3b-56108121f86b}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Header Files\\editors\\ComponentEditor\\referenceCounter\">\r\n      <UniqueIdentifier>{28fdf3eb-4df2-404e-bc43-e27180093cb0}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Source Files\\editors\\ComponentEditor\\parameterReferenceTree\">\r\n      <UniqueIdentifier>{249fcb85-c022-4690-a4c2-4a3f70792a22}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Header Files\\editors\\ComponentEditor\\parameterReferenceTree\">\r\n      <UniqueIdentifier>{0ff10db8-2913-41a7-87d9-036f51058cbc}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Source Files\\mainwindow\\DrawingBoard\">\r\n      <UniqueIdentifier>{5d10dd83-4ddd-4ae6-805b-f798032d6864}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Header Files\\mainwindow\\DrawingBoard\">\r\n      <UniqueIdentifier>{0d1ef851-a3cc-48b8-8a4e-c2cd9153c690}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Source Files\\common\\widgets\\colorBox\">\r\n      <UniqueIdentifier>{9b05bee6-46c8-4ad5-9f89-361f31037f76}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Header Files\\editors\\ComponentEditor\\parameters\\Array\">\r\n      <UniqueIdentifier>{515bd76a-649f-4059-9f79-7cf861fbc9ae}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Source Files\\editors\\ComponentEditor\\parameters\\Array\">\r\n      <UniqueIdentifier>{fab22ef7-a0eb-4485-a6c1-2ef9fd88c332}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Header Files\\editors\\ComponentEditor\\common\\ReferenceSelector\">\r\n      <UniqueIdentifier>{fa3c13ca-7838-4467-809a-0a23fa49ae7f}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Source Files\\editors\\ComponentEditor\\common\\ReferenceSelector\">\r\n      <UniqueIdentifier>{896f6f47-c2da-4e57-aff5-95c29a0c8de5}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Source Files\\wizards\\common\\ParameterComparator\">\r\n      <UniqueIdentifier>{9f305af1-83c6-43c5-bde4-1cc9c03e5720}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Header Files\\wizards\\common\\ParameterComparator\">\r\n      <UniqueIdentifier>{d6bba5c6-b242-428e-958c-f810131842c4}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Source Files\\editors\\ComponentEditor\\remapStates\">\r\n      <UniqueIdentifier>{49dba170-1c06-41a5-9e6c-71655c613648}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Header Files\\editors\\ComponentEditor\\remapStates\">\r\n      <UniqueIdentifier>{ac8149ce-8f18-4742-a635-c4f7239aeabc}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Source Files\\editors\\ComponentEditor\\memoryMaps\\memoryMapsExpressionCalculators\">\r\n      <UniqueIdentifier>{f21aaa0e-dde2-4784-b98b-f98a327c86ce}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Header Files\\editors\\ConfigurationTools\">\r\n      <UniqueIdentifier>{3f49035a-f56d-4986-a5fc-61b3c9feaa4a}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Source Files\\editors\\ConfigurationTools\">\r\n      <UniqueIdentifier>{8f5efcc6-1e11-42fd-8f57-33e0401ba98f}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Header Files\\mainwindow\\SaveHierarchy\">\r\n      <UniqueIdentifier>{caf9e3b7-62f0-44f4-ae6c-519b73d27903}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Source Files\\mainwindow\\SaveHierarchy\">\r\n      <UniqueIdentifier>{9682689d-893a-453f-b6f7-58188d71bb3d}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Header Files\\wizards\\common\\ModuleParameterComparator\">\r\n      <UniqueIdentifier>{21c42cbe-4288-4fdb-99fc-e4fc280a0c48}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Source Files\\wizards\\common\\ModuleParameterComparator\">\r\n      <UniqueIdentifier>{85b2c4f0-5af7-4565-8c9a-489765ce003e}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Source Files\\Plugins\\common\">\r\n      <UniqueIdentifier>{b2f9f4ec-55f9-4e40-9993-0e5d00bce443}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Header Files\\Plugins\\common\">\r\n      <UniqueIdentifier>{7d63f833-ab5e-4052-a982-955281e77f33}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Source Files\\editors\\ComponentEditor\\instantiations\">\r\n      <UniqueIdentifier>{2e98be12-c1a3-4049-aa53-58208ea6d410}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Header Files\\editors\\ComponentEditor\\instantiations\">\r\n      <UniqueIdentifier>{27883311-ca70-47a0-a731-9e11b320ed2f}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Source Files\\editors\\BusDefinitionEditor\">\r\n      <UniqueIdentifier>{259357d4-028a-437b-b212-8514a8af1434}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Source Files\\editors\\ComponentEditor\\busInterfaces\\general\">\r\n      <UniqueIdentifier>{f9968764-1d5f-41c2-bfaf-4661455bbeef}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Header Files\\editors\\ComponentEditor\\busInterfaces\\general\">\r\n      <UniqueIdentifier>{3d510153-5ef7-4250-ab35-ec03ca108191}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Source Files\\editors\\ComponentEditor\\otherClockDrivers\">\r\n      <UniqueIdentifier>{3cc0e478-f0f1-4286-b4a8-74b708d06637}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Source Files\\editors\\CatalogEditor\">\r\n      <UniqueIdentifier>{efa480c3-3005-4460-8ce6-b937c3534e44}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Header Files\\editors\\CatalogEditor\">\r\n      <UniqueIdentifier>{7bc5bd4f-48d9-404f-9960-2993778e9613}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Header Files\\library\\VLNVDialer\">\r\n      <UniqueIdentifier>{b6c29c59-5e53-4df0-a32b-c94a30cff042}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Header Files\\library\\HierarchyView\">\r\n      <UniqueIdentifier>{1c024b55-6d6a-47c4-92eb-8772f2098a0c}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Source Files\\library\\VLNVDialer\">\r\n      <UniqueIdentifier>{9c9f2379-1000-4bf6-a128-96108b4d6443}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Source Files\\library\\HierarchyView\">\r\n      <UniqueIdentifier>{930d34af-2acf-42ed-a2eb-06f5fcdacf9e}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Source Files\\editors\\ComponentEditor\\indirectInterfaces\">\r\n      <UniqueIdentifier>{eb1a9347-a208-4b57-b504-2d56bd8075f0}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Header Files\\editors\\ComponentEditor\\indirectInterfaces\">\r\n      <UniqueIdentifier>{8fba88bc-527a-4d9a-a0f1-543f2a45b28f}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Header Files\\editors\\BusDefinitionEditor\">\r\n      <UniqueIdentifier>{cde09ff6-5bc5-4b7e-9974-552b151c81b8}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Header Files\\common\\views\\EditableTreeView\">\r\n      <UniqueIdentifier>{fed4b9d0-dc32-4bd5-9ce4-c279ea264331}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Source Files\\common\\views\\EditableTreeView\">\r\n      <UniqueIdentifier>{b85af0c9-7149-4008-9c0c-40fe9e875e07}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Header Files\\common\\ui\">\r\n      <UniqueIdentifier>{8dc23ac2-3118-4a28-8b12-565ef28553d1}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Source Files\\common\\ui\">\r\n      <UniqueIdentifier>{06c71fd6-81fc-4a20-bbbf-6ae3a08cfa38}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Source Files\\editors\\common\">\r\n      <UniqueIdentifier>{1d73b226-7359-405a-b86f-6e207dfba415}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Header Files\\editors\\common\">\r\n      <UniqueIdentifier>{8cde759f-9554-40f4-a2e8-5677a93a06a9}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Header Files\\editors\\common\\Association\">\r\n      <UniqueIdentifier>{3ab50375-cf15-48ef-ba99-2c58276e2aa0}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Source Files\\editors\\common\\Association\">\r\n      <UniqueIdentifier>{dbe5e1d1-034e-482b-a60b-347f33f10b4b}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Header Files\\editors\\common\\ComponentInstanceEditor\">\r\n      <UniqueIdentifier>{c5149e3d-d2d3-4f70-be34-151d24326d5f}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Source Files\\editors\\common\\ComponentInstanceEditor\">\r\n      <UniqueIdentifier>{3f9a4b65-132b-4530-afa4-986219c4a712}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Header Files\\editors\\common\\ConfigurationEditor\">\r\n      <UniqueIdentifier>{6fcddc32-1665-45b6-bf22-0d483e98283f}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Source Files\\editors\\common\\ConfigurationEditor\">\r\n      <UniqueIdentifier>{2dc276ac-367c-431d-92f8-b88190726818}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Header Files\\editors\\common\\ConnectionEditor\">\r\n      <UniqueIdentifier>{013b9dc1-1772-4667-8187-59beaba2a089}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Source Files\\editors\\common\\ConnectionEditor\">\r\n      <UniqueIdentifier>{81c5a5b7-334a-4e6c-b083-9ffdd264f194}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Header Files\\editors\\common\\DesignParameterReferenceTree\">\r\n      <UniqueIdentifier>{e0a7e3c8-c8db-40f5-b44c-fe96577a8962}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Source Files\\editors\\common\\DesignParameterReferenceTree\">\r\n      <UniqueIdentifier>{38c5f4f3-fedf-4cea-b968-32eaea847e99}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Header Files\\editors\\common\\InterfaceEditor\">\r\n      <UniqueIdentifier>{24d43316-7ba4-4376-b703-b518c9a71891}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Header Files\\editors\\common\\StickyNote\">\r\n      <UniqueIdentifier>{60a1878c-c463-4f8a-85fc-364e6d5d7cb9}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Source Files\\editors\\common\\InterfaceEditor\">\r\n      <UniqueIdentifier>{ca518071-cb34-4ef1-bea9-4e53c8cdbb47}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Source Files\\editors\\common\\StickyNote\">\r\n      <UniqueIdentifier>{c6b6557d-000a-4c10-8dd6-09d7dd3b4645}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Header Files\\editors\\HWDesign\">\r\n      <UniqueIdentifier>{7dde318d-74f5-47ee-bbc5-8863ccfeafad}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Header Files\\editors\\HWDesign\\columnview\">\r\n      <UniqueIdentifier>{fbc7bdf7-d3b5-4030-b470-178ac88791da}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Source Files\\editors\\HWDesign\">\r\n      <UniqueIdentifier>{0c7dffdc-2062-4560-8709-d0d093ac7c1e}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Source Files\\editors\\HWDesign\\columnview\">\r\n      <UniqueIdentifier>{af62a80d-ef25-4e59-be26-578debf59af6}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Source Files\\editors\\HWDesign\\AdhocEditor\">\r\n      <UniqueIdentifier>{4d4e6c3c-1f87-43df-b058-2eef2e1f8998}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Header Files\\editors\\HWDesign\\AdhocEditor\">\r\n      <UniqueIdentifier>{d3111f77-c57b-4353-97b6-69e1f6b4bc59}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Header Files\\editors\\HWDesign\\undoCommands\">\r\n      <UniqueIdentifier>{b8d889f3-d9d0-4a66-b871-e72c08000c41}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Source Files\\editors\\HWDesign\\undoCommands\">\r\n      <UniqueIdentifier>{b445be90-d358-4e8f-8386-e4bcbad56c57}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Header Files\\editors\\MemoryDesigner\">\r\n      <UniqueIdentifier>{31349e16-c160-4684-863a-0fcb240bc3ac}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Source Files\\editors\\MemoryDesigner\">\r\n      <UniqueIdentifier>{5bc93d72-cec2-4629-b2fb-ac66cf79cfdd}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Source Files\\editors\\SystemDesign\">\r\n      <UniqueIdentifier>{8413defc-1a98-4dbf-b358-cfd3718e250e}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Source Files\\editors\\SystemDesign\\SystemDetailsEditor\">\r\n      <UniqueIdentifier>{227d8f43-cd18-461c-afcf-05a9fc4dae29}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Header Files\\editors\\SystemDesign\">\r\n      <UniqueIdentifier>{fab5d17e-f1c8-42b6-bc26-9d3d506362ac}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Header Files\\editors\\SystemDesign\\SystemDetailsEditor\">\r\n      <UniqueIdentifier>{6428d254-44aa-4356-9d03-89ae280fe432}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Header Files\\editors\\SystemDesign\\UndoCommands\">\r\n      <UniqueIdentifier>{1bc0b24c-5201-4d55-963c-40dab4d36092}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Source Files\\editors\\SystemDesign\\UndoCommands\">\r\n      <UniqueIdentifier>{87135939-f2a4-40bd-ab3e-9e28211d32d5}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Header Files\\editors\\ComponentEditor\\memoryMaps\">\r\n      <UniqueIdentifier>{ad772e57-ad34-43d0-b8e3-4c52f9a91dad}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Header Files\\editors\\ComponentEditor\\memoryMaps\\memoryMapsVisualizer\">\r\n      <UniqueIdentifier>{e2826d14-3a54-47cb-bdba-b3789841d570}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Header Files\\editors\\ComponentEditor\\memoryMaps\\memoryMapsExpressionCalculators\">\r\n      <UniqueIdentifier>{0383a24a-2477-42e1-a186-544e70d7a570}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Source Files\\editors\\VendorExtensionEditor\">\r\n      <UniqueIdentifier>{d618ac6f-9995-49ff-aab7-7afac04ece0e}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Header Files\\editors\\VendorExtensionEditor\">\r\n      <UniqueIdentifier>{5b82831b-a7a3-4563-9043-c059b8dc5130}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Header Files\\editors\\ComponentEditor\\resetTypes\">\r\n      <UniqueIdentifier>{72ce03f5-060b-4d23-b5c2-cef8f7ea107e}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Source Files\\editors\\ComponentEditor\\resetTypes\">\r\n      <UniqueIdentifier>{0f12853c-c767-42a8-b933-8619ad2c25e5}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Source Files\\editors\\common\\ComponentItemAutoConnector\">\r\n      <UniqueIdentifier>{b19bcb03-5261-4a26-bc2b-0a5a52a78cc4}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Header Files\\editors\\common\\ComponentItemAutoConnector\">\r\n      <UniqueIdentifier>{8029a13a-32fe-4c57-8ddb-679bc640eb95}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Header Files\\editors\\VendorExtensionEditor\\VendorExtensionAttributesEditor\">\r\n      <UniqueIdentifier>{d8656ca0-4c6a-4863-af09-2dc2d853c2c8}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Source Files\\editors\\VendorExtensionEditor\\VendorExtensionsAttributesEditor\">\r\n      <UniqueIdentifier>{66aec384-7d98-4bc2-b79f-2420c590071c}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Header Files\\wizards\\ImportWizard\\ImportInstancesEditor\">\r\n      <UniqueIdentifier>{a5d372ab-915a-4ab4-ba97-69fd866f4e7f}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Source Files\\wizards\\ImportWizard\\ImportInstancesEditor\">\r\n      <UniqueIdentifier>{9f761e61-b26d-4858-bcff-de9aead9a679}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Header Files\\common\\expressions\">\r\n      <UniqueIdentifier>{e1889aeb-d22a-4c23-9392-ee4107a7a552}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Source Files\\common\\expressions\">\r\n      <UniqueIdentifier>{e067188b-7c08-4e68-82df-7de63c587d49}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Source Files\\common\\widgets\\tagEditor\">\r\n      <UniqueIdentifier>{1c290e27-81b0-4485-a82e-6483f74386b3}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Header Files\\common\\widgets\\tagEditor\">\r\n      <UniqueIdentifier>{1b390fb1-0cfa-4143-b40e-95a7467acb7c}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Source Files\\editors\\ComponentEditor\\memoryMaps\\interfaces\">\r\n      <UniqueIdentifier>{c34883a7-39da-429d-a472-68966f4183c3}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Header Files\\editors\\ComponentEditor\\memoryMaps\\interfaces\">\r\n      <UniqueIdentifier>{214bede0-fbd8-4fa3-8988-455278b915e3}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Header Files\\editors\\ComponentEditor\\fileSet\\interfaces\">\r\n      <UniqueIdentifier>{87070864-35d7-43b4-b521-35c12ad9742a}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Source Files\\editors\\BusDefinitionEditor\\interfaces\">\r\n      <UniqueIdentifier>{a7c8e980-018f-4596-aad8-996bf453851a}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Source Files\\PythonAPI\">\r\n      <UniqueIdentifier>{c7179758-fd64-4532-9cc8-e0608bd5db93}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Source Files\\PythonAPI\\extensions\">\r\n      <UniqueIdentifier>{e7fa917a-5229-4219-8191-6994ee849e8e}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Header Files\\PythonAPI\">\r\n      <UniqueIdentifier>{827f9f2e-fa60-4b4b-b68c-dcc8411d01a2}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Header Files\\PythonAPI\\extensions\">\r\n      <UniqueIdentifier>{346878db-88ad-478f-a0fd-621e9a4d02fc}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Header Files\\editors\\common\\FileHandler\">\r\n      <UniqueIdentifier>{1f5c20b3-cd33-42d6-844a-9d3eaccfa9ca}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Source Files\\editors\\common\\FileHandler\">\r\n      <UniqueIdentifier>{dbbab44d-61c3-4e98-8091-f4654fcdbc6b}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Source Files\\editors\\HWDesign\\interfaces\">\r\n      <UniqueIdentifier>{8ff47ee3-a8ad-4457-af2f-38e47da9402b}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Header Files\\editors\\HWDesign\\interfaces\">\r\n      <UniqueIdentifier>{968fe741-7d53-4209-9dc2-3274b9a45ebb}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Header Files\\common\\widgets\\busReferenceCombobBox\">\r\n      <UniqueIdentifier>{084c78a3-2712-4e3a-801e-01620648f90e}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Source Files\\common\\widgets\\busReferenceComboBox\">\r\n      <UniqueIdentifier>{11e5ccc3-455c-4182-9589-806d8fd32b5a}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Header Files\\common\\widgets\\segmentComboBox\">\r\n      <UniqueIdentifier>{d805a9dc-f141-4c79-aa66-3571837ec3ce}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Source Files\\common\\widgets\\segmentComboBox\">\r\n      <UniqueIdentifier>{0701fe02-73ac-47fd-9e97-b661dd63045c}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Source Files\\editors\\PythonSourceEditor\">\r\n      <UniqueIdentifier>{9ac9cff0-06e0-4da9-93e6-3d7adac47e30}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Header Files\\editors\\PythonSourceEditor\">\r\n      <UniqueIdentifier>{2c530190-ab81-4ee2-8f33-70cabb06fddd}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Source Files\\common\\views\\ExpandingTreeView\">\r\n      <UniqueIdentifier>{28d7fd91-dbb0-40d8-85f0-c4097cfe1eb9}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Header Files\\common\\views\\ExpandingTreeView\">\r\n      <UniqueIdentifier>{6b22f01c-62dd-440c-b783-a6595960ebb3}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Source Files\\editors\\AbstractionDefinitionEditor\">\r\n      <UniqueIdentifier>{afe1bfda-9c24-4fe6-8ddf-a6d6deae40c3}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Header Files\\editors\\AbstractionDefinitionEditor\">\r\n      <UniqueIdentifier>{ab39fec5-dbe0-4925-a046-20a4922a8a01}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Header Files\\editors\\ComponentEditor\\modes\">\r\n      <UniqueIdentifier>{c2d52d36-3801-4e3b-8247-31b42bbbd29b}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Source Files\\editors\\ComponentEditor\\modes\">\r\n      <UniqueIdentifier>{3a45f3a2-1937-47a0-bd0b-6979b8663878}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Source Files\\common\\widgets\\TreeItemSelector\">\r\n      <UniqueIdentifier>{75f50c07-a7aa-4363-a0b5-3d958b0dc52a}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Header Files\\common\\widgets\\TreeItemSelector\">\r\n      <UniqueIdentifier>{c43541ee-dc36-4e8b-b40d-ddd33b0768f1}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Source Files\\editors\\ComponentEditor\\powerDomains\">\r\n      <UniqueIdentifier>{49cb35f3-ce1d-4f50-ab6f-ca1303e609b6}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Header Files\\editors\\ComponentEditor\\powerDomains\">\r\n      <UniqueIdentifier>{45dc464a-4192-4641-8242-c0b1f055534f}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Header Files\\common\\widgets\\GroupBoxWithAlertSign\">\r\n      <UniqueIdentifier>{3c58c97d-2039-4bdd-8c31-12f7920606d2}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Source Files\\common\\widgets\\GroupBoxWithAlertSign\">\r\n      <UniqueIdentifier>{8783df90-961a-4171-916f-62da55f95112}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Header Files\\editors\\InterconnectGenerator\">\r\n      <UniqueIdentifier>{41453352-75c2-4c2b-be09-2e22922cea62}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Source Files\\editors\\InterconnectGenerator\">\r\n      <UniqueIdentifier>{2de64eba-cd04-4c07-afc2-10efb43217fd}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Source Files\\common\\widgets\\instanceWidgets\">\r\n      <UniqueIdentifier>{b0a2d456-f4eb-4af6-91e7-2ef4f1d68d6e}</UniqueIdentifier>\r\n    </Filter>\r\n  </ItemGroup>\r\n  <ItemGroup>\r\n    <ClCompile Include=\"common\\GenericEditProvider.cpp\">\r\n      <Filter>Source Files\\common</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"common\\TextEditProvider.cpp\">\r\n      <Filter>Source Files\\common</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"common\\dialogs\\comboSelector\\comboselector.cpp\">\r\n      <Filter>Source Files\\common\\dialogs\\comboSelector</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"common\\dialogs\\propertyPageDialog\\PropertyPageDialog.cpp\">\r\n      <Filter>Source Files\\common\\dialogs\\propertyPageDialog</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"common\\dialogs\\propertyPageDialog\\PropertyPageView.cpp\">\r\n      <Filter>Source Files\\common\\dialogs\\propertyPageDialog</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"common\\dialogs\\newObjectDialog\\newobjectdialog.cpp\">\r\n      <Filter>Source Files\\common\\dialogs\\newObjectDialog</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"common\\dialogs\\createConfigurationDialog\\createconfigurationdialog.cpp\">\r\n      <Filter>Source Files\\common\\dialogs\\createConfigurationDialog</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"common\\dialogs\\listSelectDialog\\ListSelectDialog.cpp\">\r\n      <Filter>Source Files\\common\\dialogs\\listSelectDialog</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"common\\dialogs\\NewDesignDialog\\NewDesignDialog.cpp\">\r\n      <Filter>Source Files\\common\\dialogs\\NewDesignDialog</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"common\\dialogs\\LibrarySettingsDialog\\LibrarySettingsDialog.cpp\">\r\n      <Filter>Source Files\\common\\dialogs\\LibrarySettingsDialog</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"common\\validators\\LibraryPathValidator\\librarypathvalidator.cpp\">\r\n      <Filter>Source Files\\common\\validators\\LibraryPathValidator</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"common\\widgets\\assistedLineEdit\\AssistedLineEdit.cpp\">\r\n      <Filter>Source Files\\common\\widgets\\assistedLineEdit</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"common\\widgets\\assistedLineEdit\\BasicLineContentMatcher.cpp\">\r\n      <Filter>Source Files\\common\\widgets\\assistedLineEdit</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"common\\widgets\\assistedLineEdit\\LineContentAssistWidget.cpp\">\r\n      <Filter>Source Files\\common\\widgets\\assistedLineEdit</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"common\\widgets\\listManager\\dirlistmanager.cpp\">\r\n      <Filter>Source Files\\common\\widgets\\listManager</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"common\\widgets\\listManager\\listeditor.cpp\">\r\n      <Filter>Source Files\\common\\widgets\\listManager</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"common\\widgets\\listManager\\listmanager.cpp\">\r\n      <Filter>Source Files\\common\\widgets\\listManager</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"common\\widgets\\listManager\\listmanagermodel.cpp\">\r\n      <Filter>Source Files\\common\\widgets\\listManager</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"common\\widgets\\nameGroupBox\\namegroupbox.cpp\">\r\n      <Filter>Source Files\\common\\widgets\\nameGroupBox</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"common\\widgets\\vlnvDisplayer\\vlnvdisplayer.cpp\">\r\n      <Filter>Source Files\\common\\widgets\\vlnvDisplayer</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"common\\widgets\\assistedTextEdit\\AssistedTextEdit.cpp\">\r\n      <Filter>Source Files\\common\\widgets\\assistedTextEdit</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"common\\widgets\\assistedTextEdit\\TextContentAssistWidget.cpp\">\r\n      <Filter>Source Files\\common\\widgets\\assistedTextEdit</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"common\\widgets\\assistedTextEdit\\ToolTipHintWidget.cpp\">\r\n      <Filter>Source Files\\common\\widgets\\assistedTextEdit</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"common\\widgets\\vlnvEditor\\VLNVContentMatcher.cpp\">\r\n      <Filter>Source Files\\common\\widgets\\vlnvEditor</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"common\\widgets\\vlnvEditor\\VLNVDataTree.cpp\">\r\n      <Filter>Source Files\\common\\widgets\\vlnvEditor</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"common\\widgets\\vlnvEditor\\vlnveditor.cpp\">\r\n      <Filter>Source Files\\common\\widgets\\vlnvEditor</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"common\\widgets\\colorBox\\ColorBox.cpp\">\r\n      <Filter>Source Files\\common\\widgets\\colorBox</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"common\\widgets\\kactusAttributeEditor\\KactusAttributeEditor.cpp\">\r\n      <Filter>Source Files\\common\\widgets\\kactusAttributeEditor</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"common\\widgets\\componentPreviewBox\\ComponentPreviewBox.cpp\">\r\n      <Filter>Source Files\\common\\widgets\\componentPreviewBox</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"common\\widgets\\tabDocument\\TabDocument.cpp\">\r\n      <Filter>Source Files\\common\\widgets\\tabDocument</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"common\\widgets\\booleanComboBox\\booleancombobox.cpp\">\r\n      <Filter>Source Files\\common\\widgets\\booleanComboBox</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"common\\widgets\\nameGroupEditor\\namegroupeditor.cpp\">\r\n      <Filter>Source Files\\common\\widgets\\nameGroupEditor</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"common\\widgets\\summaryLabel\\summarylabel.cpp\">\r\n      <Filter>Source Files\\common\\widgets\\summaryLabel</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"common\\widgets\\interfaceModeSelector\\interfacemodeselector.cpp\">\r\n      <Filter>Source Files\\common\\widgets\\interfaceModeSelector</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"common\\widgets\\interfaceSelector\\interfaceselector.cpp\">\r\n      <Filter>Source Files\\common\\widgets\\interfaceSelector</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"common\\widgets\\LineEditEx\\LineEditEx.cpp\">\r\n      <Filter>Source Files\\common\\widgets\\LineEditEx</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"common\\widgets\\SnippetTextEdit\\SnippetHighlighter.cpp\">\r\n      <Filter>Source Files\\common\\widgets\\SnippetTextEdit</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"common\\widgets\\SnippetTextEdit\\SnippetTextEdit.cpp\">\r\n      <Filter>Source Files\\common\\widgets\\SnippetTextEdit</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"common\\widgets\\usageComboBox\\usagecombobox.cpp\">\r\n      <Filter>Source Files\\common\\widgets\\usageComboBox</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"common\\widgets\\accessComboBox\\accesscombobox.cpp\">\r\n      <Filter>Source Files\\common\\widgets\\accessComboBox</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"common\\widgets\\modWriteComboBox\\modwritecombobox.cpp\">\r\n      <Filter>Source Files\\common\\widgets\\modWriteComboBox</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"common\\widgets\\readActionComboBox\\readactioncombobox.cpp\">\r\n      <Filter>Source Files\\common\\widgets\\readActionComboBox</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"common\\widgets\\testConstraintComboBox\\testconstraintcombobox.cpp\">\r\n      <Filter>Source Files\\common\\widgets\\testConstraintComboBox</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"common\\graphicsItems\\CommonGraphicsUndoCommands.cpp\">\r\n      <Filter>Source Files\\common\\graphicsItems</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"common\\graphicsItems\\ComponentItem.cpp\">\r\n      <Filter>Source Files\\common\\graphicsItems</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"common\\graphicsItems\\ConnectionEndpoint.cpp\">\r\n      <Filter>Source Files\\common\\graphicsItems</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"common\\graphicsItems\\ConnectionUndoCommands.cpp\">\r\n      <Filter>Source Files\\common\\graphicsItems</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"common\\graphicsItems\\expandableitem.cpp\">\r\n      <Filter>Source Files\\common\\graphicsItems</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"common\\graphicsItems\\GraphicsColumn.cpp\">\r\n      <Filter>Source Files\\common\\graphicsItems</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"common\\graphicsItems\\GraphicsColumnLayout.cpp\">\r\n      <Filter>Source Files\\common\\graphicsItems</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"common\\graphicsItems\\GraphicsColumnUndoCommands.cpp\">\r\n      <Filter>Source Files\\common\\graphicsItems</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"common\\graphicsItems\\GraphicsConnection.cpp\">\r\n      <Filter>Source Files\\common\\graphicsItems</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"common\\graphicsItems\\graphicsexpandcollapseitem.cpp\">\r\n      <Filter>Source Files\\common\\graphicsItems</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"common\\graphicsItems\\GraphicsLineEdit.cpp\">\r\n      <Filter>Source Files\\common\\graphicsItems</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"common\\graphicsItems\\GraphicsRectButton.cpp\">\r\n      <Filter>Source Files\\common\\graphicsItems</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"common\\graphicsItems\\visualizeritem.cpp\">\r\n      <Filter>Source Files\\common\\graphicsItems</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"common\\delegates\\ComboDelegate\\combodelegate.cpp\">\r\n      <Filter>Source Files\\common\\delegates\\ComboDelegate</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"common\\delegates\\LineEditDelegate\\lineeditdelegate.cpp\">\r\n      <Filter>Source Files\\common\\delegates\\LineEditDelegate</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"common\\views\\EditableTableView\\editabletableview.cpp\">\r\n      <Filter>Source Files\\common\\views\\EditableTableView</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"common\\views\\EditableListView\\editablelistview.cpp\">\r\n      <Filter>Source Files\\common\\views\\EditableListView</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"mainwindow\\DeleteWorkspaceDialog.cpp\">\r\n      <Filter>Source Files\\mainwindow</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"mainwindow\\main.cpp\">\r\n      <Filter>Source Files\\mainwindow</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"mainwindow\\mainwindow.cpp\">\r\n      <Filter>Source Files\\mainwindow</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"mainwindow\\NewWorkspaceDialog.cpp\">\r\n      <Filter>Source Files\\mainwindow</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"mainwindow\\SplashScreen.cpp\">\r\n      <Filter>Source Files\\mainwindow</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"settings\\CodeEditorSettingsPage.cpp\">\r\n      <Filter>Source Files\\settings</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"settings\\GeneralSettingsPage.cpp\">\r\n      <Filter>Source Files\\settings</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"settings\\NamingPolicySettingsPage.cpp\">\r\n      <Filter>Source Files\\settings</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"settings\\SettingsDialog.cpp\">\r\n      <Filter>Source Files\\settings</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"settings\\SettingsUpdater.cpp\">\r\n      <Filter>Source Files\\settings</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"common\\dialogs\\LibrarySettingsDialog\\librarysettingsdelegate.cpp\">\r\n      <Filter>Source Files\\common\\dialogs\\LibrarySettingsDialog</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"settings\\PluginSettingsPage.cpp\">\r\n      <Filter>Source Files\\settings</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"settings\\FileTypeSettingsPage.cpp\">\r\n      <Filter>Source Files\\settings</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"settings\\FileTypesModel.cpp\">\r\n      <Filter>Source Files\\settings</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"settings\\FileTypesDelegate.cpp\">\r\n      <Filter>Source Files\\settings</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"common\\widgets\\viewSelector\\viewselector.cpp\">\r\n      <Filter>Source Files\\common\\widgets\\viewSelector</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"common\\widgets\\fileTypeSelector\\filetypeselector.cpp\">\r\n      <Filter>Source Files\\common\\widgets\\fileTypeSelector</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"settings\\filetypesview.cpp\">\r\n      <Filter>Source Files\\settings</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"common\\widgets\\EnumCollectionEditor\\EnumCollectionEditor.cpp\">\r\n      <Filter>Source Files\\common\\widgets\\EnumCollectionEditor</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"common\\widgets\\listManager\\dirlistmanagermodel.cpp\">\r\n      <Filter>Source Files\\common\\widgets\\listManager</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"settings\\k2envvariablesettingspage.cpp\">\r\n      <Filter>Source Files\\settings</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"settings\\k2envvarmodel.cpp\">\r\n      <Filter>Source Files\\settings</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"common\\widgets\\FileSelector\\fileselector.cpp\">\r\n      <Filter>Source Files\\common\\widgets\\FileSelector</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"common\\widgets\\LibrarySelectorWidget\\LibrarySelectorWidget.cpp\">\r\n      <Filter>Source Files\\common\\widgets\\LibrarySelectorWidget</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"common\\widgets\\LibrarySelectorWidget\\LibraryPathSelector\\librarypathselector.cpp\">\r\n      <Filter>Source Files\\common\\widgets\\LibrarySelectorWidget\\LibraryPathSelector</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"common\\widgets\\LibrarySelectorWidget\\LibraryPathEditor\\librarypatheditor.cpp\">\r\n      <Filter>Source Files\\common\\widgets\\LibrarySelectorWidget\\LibraryPathEditor</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"common\\dialogs\\NewBusDialog\\NewBusDialog.cpp\">\r\n      <Filter>Source Files\\common\\dialogs\\NewBusDialog</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"common\\widgets\\DirectoryListSelector\\DirectoryListSelector.cpp\">\r\n      <Filter>Source Files\\common\\widgets\\DirectoryListSelector</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"wizards\\ComponentWizard\\ComponentWizard.cpp\">\r\n      <Filter>Source Files\\wizards\\ComponentWizard</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"wizards\\ComponentWizard\\ComponentWizardConclusionPage.cpp\">\r\n      <Filter>Source Files\\wizards\\ComponentWizard</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"wizards\\ComponentWizard\\ComponentWizardDependencyPage.cpp\">\r\n      <Filter>Source Files\\wizards\\ComponentWizard</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"wizards\\ComponentWizard\\ComponentWizardGeneralInfoPage.cpp\">\r\n      <Filter>Source Files\\wizards\\ComponentWizard</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"wizards\\ComponentWizard\\ComponentWizardIntroPage.cpp\">\r\n      <Filter>Source Files\\wizards\\ComponentWizard</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"Help\\HelpSystem\\ContextHelpBrowser.cpp\">\r\n      <Filter>Source Files\\Help\\HelpSystem</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"Help\\HelpSystem\\HelpSearchWidget.cpp\">\r\n      <Filter>Source Files\\Help\\HelpSystem</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"Help\\HelpSystem\\HelpWindow.cpp\">\r\n      <Filter>Source Files\\Help\\HelpSystem</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"wizards\\BusInterfaceWizard\\BusInterfaceWizard.cpp\">\r\n      <Filter>Source Files\\wizards\\BusInterfaceWizard</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"wizards\\BusInterfaceWizard\\BusInterfaceWizardBusDefinitionPage.cpp\">\r\n      <Filter>Source Files\\wizards\\BusInterfaceWizard</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"wizards\\BusInterfaceWizard\\BusInterfaceWizardConclusionPage.cpp\">\r\n      <Filter>Source Files\\wizards\\BusInterfaceWizard</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"wizards\\BusInterfaceWizard\\BusInterfaceWizardGeneralOptionsPage.cpp\">\r\n      <Filter>Source Files\\wizards\\BusInterfaceWizard</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"wizards\\BusInterfaceWizard\\BusInterfaceWizardIntroPage.cpp\">\r\n      <Filter>Source Files\\wizards\\BusInterfaceWizard</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"wizards\\BusInterfaceWizard\\BusInterfaceWizardPortMapPage.cpp\">\r\n      <Filter>Source Files\\wizards\\BusInterfaceWizard</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"kactusGenerators\\DocumentGenerator\\documentgenerator.cpp\">\r\n      <Filter>Source Files\\kactusGenerators\\DocumentGenerator</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"mainwindow\\MessageConsole\\messageconsole.cpp\">\r\n      <Filter>Source Files\\mainwindow\\MessageConsole</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"mainwindow\\Ribbon\\Ribbon.cpp\">\r\n      <Filter>Source Files\\mainwindow\\Ribbon</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"mainwindow\\Ribbon\\RibbonGroup.cpp\">\r\n      <Filter>Source Files\\mainwindow\\Ribbon</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"mainwindow\\NewPages\\NewApiDefinitionPage.cpp\">\r\n      <Filter>Source Files\\mainwindow\\NewPages</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"mainwindow\\NewPages\\NewComDefinitionPage.cpp\">\r\n      <Filter>Source Files\\mainwindow\\NewPages</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"mainwindow\\NewPages\\NewComponentPage.cpp\">\r\n      <Filter>Source Files\\mainwindow\\NewPages</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"mainwindow\\NewPages\\NewDesignPage.cpp\">\r\n      <Filter>Source Files\\mainwindow\\NewPages</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"mainwindow\\NewPages\\NewPage.cpp\">\r\n      <Filter>Source Files\\mainwindow\\NewPages</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"mainwindow\\NewPages\\NewSWComponentPage.cpp\">\r\n      <Filter>Source Files\\mainwindow\\NewPages</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"mainwindow\\NewPages\\NewSWDesignPage.cpp\">\r\n      <Filter>Source Files\\mainwindow\\NewPages</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"mainwindow\\NewPages\\NewSystemPage.cpp\">\r\n      <Filter>Source Files\\mainwindow\\NewPages</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ApiDefinitionEditor\\ApiDefinitionEditor.cpp\">\r\n      <Filter>Source Files\\editors\\ApiDefinitionEditor</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ApiDefinitionEditor\\ApiFunctionEditor.cpp\">\r\n      <Filter>Source Files\\editors\\ApiDefinitionEditor</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ApiDefinitionEditor\\ApiFunctionModel.cpp\">\r\n      <Filter>Source Files\\editors\\ApiDefinitionEditor</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ApiDefinitionEditor\\ApiFunctionParameterDelegate.cpp\">\r\n      <Filter>Source Files\\editors\\ApiDefinitionEditor</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ApiDefinitionEditor\\ApiFunctionParameterModel.cpp\">\r\n      <Filter>Source Files\\editors\\ApiDefinitionEditor</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComDefinitionEditor\\ComDefinitionEditor.cpp\">\r\n      <Filter>Source Files\\editors\\ComDefinitionEditor</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComDefinitionEditor\\ComPropertyDelegate.cpp\">\r\n      <Filter>Source Files\\editors\\ComDefinitionEditor</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComDefinitionEditor\\ComPropertyEditor.cpp\">\r\n      <Filter>Source Files\\editors\\ComDefinitionEditor</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComDefinitionEditor\\ComPropertyModel.cpp\">\r\n      <Filter>Source Files\\editors\\ComDefinitionEditor</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\itemvisualizer.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\itemeditor.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\addressSpaces\\localMemoryMap\\localmemorymapeditor.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\addressSpaces\\localMemoryMap</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\addressSpaces\\localMemoryMap\\localmemorymapgraphitem.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\addressSpaces\\localMemoryMap</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\addressSpaces\\addressspaceeditor.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\addressSpaces</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\addressSpaces\\addressspacegeneraleditor.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\addressSpaces</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\addressSpaces\\addressspacesdelegate.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\addressSpaces</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\addressSpaces\\addressspaceseditor.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\addressSpaces</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\addressSpaces\\addressspacesmodel.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\addressSpaces</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\addressSpaces\\segmenteditor.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\addressSpaces</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\addressSpaces\\segmentsmodel.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\addressSpaces</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\addressSpaces\\addressSpaceVisualizer\\AddressSpaceConflictedItem.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\addressSpaces\\addressSpaceVisualizer</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\addressSpaces\\addressSpaceVisualizer\\addressspacegapitem.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\addressSpaces\\addressSpaceVisualizer</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\addressSpaces\\addressSpaceVisualizer\\addressspacescene.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\addressSpaces\\addressSpaceVisualizer</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\addressSpaces\\addressSpaceVisualizer\\addressspacevisualizationitem.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\addressSpaces\\addressSpaceVisualizer</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\addressSpaces\\addressSpaceVisualizer\\addressspacevisualizer.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\addressSpaces\\addressSpaceVisualizer</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\addressSpaces\\addressSpaceVisualizer\\localaddrblockgraphitem.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\addressSpaces\\addressSpaceVisualizer</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\addressSpaces\\addressSpaceVisualizer\\segmentgraphitem.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\addressSpaces\\addressSpaceVisualizer</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\busInterfaces\\businterfacesdelegate.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\busInterfaces</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\busInterfaces\\businterfaceseditor.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\busInterfaces</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\busInterfaces\\businterfacesmodel.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\busInterfaces</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\busInterfaces\\portmaps\\PortListSortProxyModel.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\busInterfaces\\portmaps</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\channels\\channelsdelegate.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\channels</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\channels\\channelseditor.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\channels</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\channels\\channelsmodel.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\channels</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\cpus\\cpusdelegate.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\cpus</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\cpus\\cpuseditor.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\cpus</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\cpus\\cpusmodel.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\cpus</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\fileBuilders\\filebuildersdelegate.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\fileBuilders</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\fileBuilders\\filebuilderseditor.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\fileBuilders</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\fileBuilders\\filebuildersmodel.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\fileBuilders</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\fileSet\\fileseteditor.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\fileSet</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\fileSet\\filesetsdelegate.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\fileSet</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\fileSet\\filesetseditor.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\fileSet</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\fileSet\\filesetsmodel.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\fileSet</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\fileSet\\groupmanager.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\fileSet</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\fileSet\\dependencyAnalysis\\FileDependencyDelegate.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\fileSet\\dependencyAnalysis</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\fileSet\\dependencyAnalysis\\FileDependencyEditor.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\fileSet\\dependencyAnalysis</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\fileSet\\dependencyAnalysis\\FileDependencyGraphView.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\fileSet\\dependencyAnalysis</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\fileSet\\dependencyAnalysis\\FileDependencyGraphWidget.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\fileSet\\dependencyAnalysis</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\fileSet\\dependencyAnalysis\\FileDependencyInfoWidget.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\fileSet\\dependencyAnalysis</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\fileSet\\dependencyAnalysis\\FileDependencyItem.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\fileSet\\dependencyAnalysis</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\fileSet\\dependencyAnalysis\\FileDependencyModel.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\fileSet\\dependencyAnalysis</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\fileSet\\dependencyAnalysis\\FileDependencySortFilter.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\fileSet\\dependencyAnalysis</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\fileSet\\dependencyAnalysis\\FileDependencySourceEditor.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\fileSet\\dependencyAnalysis</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\fileSet\\file\\filebuildcommand.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\fileSet\\file</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\fileSet\\file\\filedefinemodel.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\fileSet\\file</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\fileSet\\file\\filedefineview.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\fileSet\\file</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\fileSet\\file\\fileeditor.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\fileSet\\file</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\fileSet\\file\\filegeneraleditor.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\fileSet\\file</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\fileSet\\file\\filenameeditor.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\fileSet\\file</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\fileSet\\file\\filesdelegate.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\fileSet\\file</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\fileSet\\file\\fileseditor.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\fileSet\\file</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\fileSet\\file\\filesmodel.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\fileSet\\file</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\fileSet\\file\\filesview.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\fileSet\\file</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\fileSet\\file\\filetypeeditor.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\fileSet\\file</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\fileSet\\file\\filetypeeditordelegate.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\fileSet\\file</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\general\\generaleditor.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\general</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\memoryMaps\\addressblockdelegate.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\memoryMaps</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\memoryMaps\\addressblockeditor.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\memoryMaps</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\memoryMaps\\addressblockmodel.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\memoryMaps</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\memoryMaps\\enumeratedvaluedelegate.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\memoryMaps</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\memoryMaps\\enumeratedvaluemodel.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\memoryMaps</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\memoryMaps\\fieldeditor.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\memoryMaps</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\memoryMaps\\memorymapdelegate.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\memoryMaps</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\memoryMaps\\memorymapeditor.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\memoryMaps</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\memoryMaps\\memorymapmodel.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\memoryMaps</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\memoryMaps\\memorymapsdelegate.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\memoryMaps</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\memoryMaps\\memorymapseditor.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\memoryMaps</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\memoryMaps\\memorymapsmodel.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\memoryMaps</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\memoryMaps\\registerdelegate.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\memoryMaps</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\memoryMaps\\registereditor.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\memoryMaps</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\memoryMaps\\registertablemodel.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\memoryMaps</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\memoryMaps\\memoryMapsVisualizer\\addressblockgraphitem.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\memoryMaps\\memoryMapsVisualizer</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\memoryMaps\\memoryMapsVisualizer\\fieldgraphitem.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\memoryMaps\\memoryMapsVisualizer</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\memoryMaps\\memoryMapsVisualizer\\memorymapgraphitem.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\memoryMaps\\memoryMapsVisualizer</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\memoryMaps\\memoryMapsVisualizer\\memorymapscene.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\memoryMaps\\memoryMapsVisualizer</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\memoryMaps\\memoryMapsVisualizer\\memorymapsvisualizer.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\memoryMaps\\memoryMapsVisualizer</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\memoryMaps\\memoryMapsVisualizer\\memorymapview.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\memoryMaps\\memoryMapsVisualizer</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\memoryMaps\\memoryMapsVisualizer\\registergraphitem.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\memoryMaps\\memoryMapsVisualizer</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\otherClockDrivers\\clockdriversdelegate.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\otherClockDrivers</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\otherClockDrivers\\otherclockdriverseditor.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\otherClockDrivers</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\otherClockDrivers\\otherclockdriversmodel.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\otherClockDrivers</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\parameters\\parameterseditor.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\parameters</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\ports\\portsdelegate.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\ports</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\ports\\portseditor.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\ports</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\ports\\portsmodel.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\ports</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\ports\\PortsView.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\ports</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\software\\PropertyValueDelegate.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\software</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\software\\PropertyValueEditor.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\software</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\software\\PropertyValueModel.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\software</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\software\\SWPropertiesEditor.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\software</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\software\\apiInterface\\ApiInterfaceEditor.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\software\\apiInterface</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\software\\apiInterface\\apiinterfacesdelegate.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\software\\apiInterface</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\software\\apiInterface\\apiinterfaceseditor.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\software\\apiInterface</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\software\\apiInterface\\apiinterfacesmodel.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\software\\apiInterface</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\software\\comInterface\\ComInterfaceEditor.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\software\\comInterface</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\software\\comInterface\\cominterfacesdelegate.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\software\\comInterface</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\software\\comInterface\\cominterfaceseditor.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\software\\comInterface</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\software\\comInterface\\cominterfacesmodel.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\software\\comInterface</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\software\\systemView\\SystemViewsModel.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\software\\systemView</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\software\\systemView\\SystemViewsEditor.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\software\\systemView</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\software\\systemView\\SystemViewEditor.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\software\\systemView</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\treeStructure\\componenteditorswpropertiesitem.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\treeStructure</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\treeStructure\\ComponentEditorSystemViewItem.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\treeStructure</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\treeStructure\\ComponentEditorSystemViewsItem.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\treeStructure</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\treeStructure\\componenteditortreemodel.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\treeStructure</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\treeStructure\\ComponentEditorTreeSortProxyModel.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\treeStructure</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\treeStructure\\componenteditorviewitem.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\treeStructure</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\treeStructure\\componenteditorviewsitem.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\treeStructure</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\treeStructure\\componenttreeview.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\treeStructure</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\treeStructure\\componenteditoraddrblockitem.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\treeStructure</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\treeStructure\\componenteditoraddrspaceitem.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\treeStructure</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\treeStructure\\componenteditoraddrspacesitem.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\treeStructure</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\treeStructure\\componenteditorapiinterfaceitem.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\treeStructure</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\treeStructure\\componenteditorapiinterfacesitem.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\treeStructure</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\treeStructure\\componenteditorbusinterfaceitem.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\treeStructure</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\treeStructure\\componenteditorbusinterfacesitem.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\treeStructure</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\treeStructure\\componenteditorchannelsitem.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\treeStructure</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\treeStructure\\componenteditorcominterfaceitem.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\treeStructure</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\treeStructure\\componenteditorcominterfacesitem.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\treeStructure</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\treeStructure\\componenteditorcpusitem.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\treeStructure</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\treeStructure\\componenteditorfielditem.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\treeStructure</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\treeStructure\\componenteditorfileitem.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\treeStructure</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\treeStructure\\componenteditorfilesetitem.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\treeStructure</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\treeStructure\\componenteditorfilesetsitem.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\treeStructure</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\treeStructure\\componenteditorgeneralitem.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\treeStructure</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\treeStructure\\componenteditorgroupslot.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\treeStructure</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\treeStructure\\componenteditoritem.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\treeStructure</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\treeStructure\\componenteditormemmapitem.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\treeStructure</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\treeStructure\\componenteditormemmapsitem.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\treeStructure</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\treeStructure\\componenteditorotherclocksitem.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\treeStructure</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\treeStructure\\componenteditorparametersitem.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\treeStructure</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\treeStructure\\componenteditorportsitem.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\treeStructure</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\treeStructure\\componenteditorregisteritem.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\treeStructure</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\treeStructure\\componenteditorrootitem.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\treeStructure</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\views\\vieweditor.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\views</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\views\\viewseditor.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\views</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\views\\viewsmodel.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\views</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\views\\envidentifiereditor.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\views</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\views\\envidentifiersmodel.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\views</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\visualization\\memorygapitem.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\visualization</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\visualization\\memoryvisualizationitem.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\visualization</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\visualization\\fieldgapitem.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\visualization</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\CSourceEditor\\CSourceContentMatcher.cpp\">\r\n      <Filter>Source Files\\editors\\CSourceEditor</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\CSourceEditor\\CSourceHighlighter.cpp\">\r\n      <Filter>Source Files\\editors\\CSourceEditor</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\CSourceEditor\\CSourceTextEdit.cpp\">\r\n      <Filter>Source Files\\editors\\CSourceEditor</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\CSourceEditor\\CSourceWidget.cpp\">\r\n      <Filter>Source Files\\editors\\CSourceEditor</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\componenteditor.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"settings\\SettingsPage.cpp\">\r\n      <Filter>Source Files\\settings</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"wizards\\ComponentWizard\\ComponentWizardImportPage.cpp\">\r\n      <Filter>Source Files\\wizards\\ComponentWizard</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"wizards\\ComponentWizard\\ComponentWizardViewsPage.cpp\">\r\n      <Filter>Source Files\\wizards\\ComponentWizard</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"wizards\\ComponentWizard\\ViewListModel.cpp\">\r\n      <Filter>Source Files\\wizards\\ComponentWizard</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"wizards\\ImportWizard\\ImportWizard.cpp\">\r\n      <Filter>Source Files\\wizards\\ImportWizard</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"wizards\\ImportWizard\\ImportWizardImportPage.cpp\">\r\n      <Filter>Source Files\\wizards\\ImportWizard</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"wizards\\common\\IPXactDiff.cpp\">\r\n      <Filter>Source Files\\wizards\\common</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"wizards\\common\\ComponentComparator\\ComponentComparator.cpp\">\r\n      <Filter>Source Files\\wizards\\common\\ComponentComparator</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"wizards\\common\\ComponentDiffWidget\\ComponentDiffWidget.cpp\">\r\n      <Filter>Source Files\\wizards\\common\\ComponentDiffWidget</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"wizards\\common\\VLNVComparator\\VLNVComparator.cpp\">\r\n      <Filter>Source Files\\wizards\\common\\VLNVComparator</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"wizards\\common\\ViewComparator\\ViewComparator.cpp\">\r\n      <Filter>Source Files\\wizards\\common\\ViewComparator</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"wizards\\common\\PortComparator\\PortComparator.cpp\">\r\n      <Filter>Source Files\\wizards\\common\\PortComparator</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"wizards\\ImportWizard\\ImportWizardIntroPage.cpp\">\r\n      <Filter>Source Files\\wizards\\ImportWizard</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\treeStructure\\ComponentEditorChoicesItem.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\treeStructure</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\choices\\ChoicesEditor.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\choices</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\choices\\ChoicesModel.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\choices</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\choices\\EnumerationModel.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\choices</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\parameters\\parametersmodel.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\parameters</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\parameters\\ParameterDelegate.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\parameters</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"settings\\ComponentEditorSettingsPage.cpp\">\r\n      <Filter>Source Files\\settings</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\common\\AbstractParameterModel.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\common</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\parameters\\ParameterEditorHeaderView.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\parameters</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\referenceCounter\\ParameterReferenceCounter.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\referenceCounter</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\parameterReferenceTree\\ParameterReferenceTree.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\parameterReferenceTree</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\common\\ParameterizableTable.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\common</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\common\\ExpressionDelegate.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\common</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\common\\ExpressionEditor.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\common</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\parameters\\ComponentParameterModel.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\parameters</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"mainwindow\\DrawingBoard\\DrawingBoard.cpp\">\r\n      <Filter>Source Files\\mainwindow\\DrawingBoard</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\parameters\\Array\\ParameterArrayModel.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\parameters\\Array</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\parameters\\Array\\ArrayDelegate.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\parameters\\Array</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\parameters\\Array\\ArrayView.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\parameters\\Array</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\parameters\\ChoiceCreatorDelegate.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\parameters</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\common\\ReferenceSelector\\ReferenceSelector.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\common\\ReferenceSelector</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\common\\ReferencingTableModel.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\common</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"wizards\\common\\ParameterComparator\\ParameterComparator.cpp\">\r\n      <Filter>Source Files\\wizards\\common\\ParameterComparator</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\treeStructure\\RemapStatesItem.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\treeStructure</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\treeStructure\\SingleRemapStateItem.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\treeStructure</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\remapStates\\RemapStatesModel.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\remapStates</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\remapStates\\RemapStatesEditor.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\remapStates</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\remapStates\\SingleRemapStateEditor.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\remapStates</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\remapStates\\RemapConditionModel.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\remapStates</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\remapStates\\RemapConditionEditor.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\remapStates</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\remapStates\\RemapConditionDelegate.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\remapStates</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\memoryMaps\\SingleMemoryMapEditor.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\memoryMaps</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\treeStructure\\MemoryRemapItem.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\treeStructure</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\memoryMaps\\MemoryMapsView.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\memoryMaps</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\memoryMaps\\SingleAddressBlockEditor.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\memoryMaps</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\memoryMaps\\SingleRegisterEditor.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\memoryMaps</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\memoryMaps\\SingleFieldEditor.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\memoryMaps</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\memoryMaps\\WriteValueConstraintComboBox.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\memoryMaps</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\memoryMaps\\memoryMapsExpressionCalculators\\ReferenceCalculator.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\memoryMaps\\memoryMapsExpressionCalculators</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\addressSpaces\\SegmentDelegate.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\addressSpaces</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ConfigurationTools\\ViewConfigurer.cpp\">\r\n      <Filter>Source Files\\editors\\ConfigurationTools</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ConfigurationTools\\ViewConfigurerDelegate.cpp\">\r\n      <Filter>Source Files\\editors\\ConfigurationTools</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"mainwindow\\SaveHierarchy\\DocumentTreeBuilder.cpp\">\r\n      <Filter>Source Files\\mainwindow\\SaveHierarchy</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"mainwindow\\SaveHierarchy\\HierarchicalSaveBuildStrategy.cpp\">\r\n      <Filter>Source Files\\mainwindow\\SaveHierarchy</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"mainwindow\\SaveHierarchy\\SaveAsItem.cpp\">\r\n      <Filter>Source Files\\mainwindow\\SaveHierarchy</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"mainwindow\\SaveHierarchy\\SaveHierarchyDelegate.cpp\">\r\n      <Filter>Source Files\\mainwindow\\SaveHierarchy</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"mainwindow\\SaveHierarchy\\SaveHierarchyDialog.cpp\">\r\n      <Filter>Source Files\\mainwindow\\SaveHierarchy</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\memoryMaps\\ExpressionProxyModel.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\memoryMaps</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\common\\MultilineDescriptionDelegate.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\common</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\views\\ViewsDelegate.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\views</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\ports\\PortTagEditorDelegate.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\ports</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"wizards\\common\\ModuleParameterComparator\\ModuleParameterComparator.cpp\">\r\n      <Filter>Source Files\\wizards\\common\\ModuleParameterComparator</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\treeStructure\\InstantiationsItem.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\treeStructure</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\treeStructure\\ComponentInstantiationsItem.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\treeStructure</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\treeStructure\\DesignConfigurationInstantiationsItem.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\treeStructure</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\treeStructure\\DesignInstantiationsItem.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\treeStructure</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\treeStructure\\SingleComponentInstantiationItem.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\treeStructure</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\instantiations\\DesignConfigurationInstantiationEditor.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\instantiations</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\treeStructure\\SingleDesignConfigurationInstantiationItem.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\treeStructure</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\instantiations\\DesignInstantiationEditor.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\instantiations</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\treeStructure\\SingleDesignInstantiationItem.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\treeStructure</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\instantiations\\ComponentInstantiationDisplayer.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\instantiations</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\instantiations\\ComponentInstantiationsEditor.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\instantiations</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\instantiations\\ComponentInstantiationsModel.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\instantiations</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\instantiations\\InstantiationsEditor.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\instantiations</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\instantiations\\DesignInstantiationsModel.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\treeStructure</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\instantiations\\DesignConfigurationInstantiationsModel.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\instantiations</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\instantiations\\DesignConfigurationInstantiationsEditor.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\instantiations</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\instantiations\\DesignInstantiationsDelegate.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\instantiations</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\instantiations\\ModuleParameterDelegate.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\instantiations</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\instantiations\\ModuleParameterEditor.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\instantiations</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\instantiations\\ModuleParameterModel.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\instantiations</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\instantiations\\ComponentInstantiationEditor.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\instantiations</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\instantiations\\filesetrefeditor.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\instantiations</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\instantiations\\filesetrefeditordelegate.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\instantiations</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\instantiations\\filesetrefmodel.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\instantiations</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\remapStates\\ValueOrIndexedValueEditor.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\remapStates</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\busInterfaces\\portmaps\\PortMappingTableView.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\busInterfaces\\portmaps</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\busInterfaces\\portmaps\\PhysicalPortMappingTableView.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\busInterfaces\\portmaps</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\busInterfaces\\portmaps\\PortMappingTableModel.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\busInterfaces\\portmaps</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\busInterfaces\\portmaps\\PhysicalPortMappingTableModel.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\busInterfaces\\portmaps</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\busInterfaces\\portmaps\\PortMapAutoConnector.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\busInterfaces\\portmaps</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\busInterfaces\\portmaps\\PortMapHeaderView.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\busInterfaces\\portmaps</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"mainwindow\\NewPages\\NewBusDefinitionPage.cpp\">\r\n      <Filter>Source Files\\mainwindow\\NewPages</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\BusDefinitionEditor\\busdefgroup.cpp\">\r\n      <Filter>Source Files\\editors\\BusDefinitionEditor</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\BusDefinitionEditor\\BusDefinitionEditor.cpp\">\r\n      <Filter>Source Files\\editors\\BusDefinitionEditor</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"common\\widgets\\ParameterGroupBox\\parametergroupbox.cpp\">\r\n      <Filter>Source Files\\common\\widgets\\ParameterGroupBox</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\busInterfaces\\portmaps\\JaroWinklerAlgorithm.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\busInterfaces\\portmaps</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\busInterfaces\\general\\bridgesdelegate.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\busInterfaces\\general</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\busInterfaces\\general\\bridgeseditor.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\busInterfaces\\general</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\busInterfaces\\general\\bridgesmodel.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\busInterfaces\\general</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\busInterfaces\\general\\busifgeneraldetails.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\busInterfaces\\general</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\busInterfaces\\general\\busifgeneraltab.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\busInterfaces\\general</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\busInterfaces\\general\\interfacemodestack.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\busInterfaces\\general</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\busInterfaces\\portmaps\\BusInterfacePortMapTab.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\busInterfaces\\portmaps</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\busInterfaces\\businterfaceeditor.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\busInterfaces</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\instantiations\\ModuleParameterHeaderView.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\instantiations</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"mainwindow\\NewPages\\NewCatalogPage.cpp\">\r\n      <Filter>Source Files\\mainwindow\\NewPages</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\CatalogEditor\\CatalogEditor.cpp\">\r\n      <Filter>Source Files\\editors\\CatalogEditor</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\CatalogEditor\\CatalogFileModel.cpp\">\r\n      <Filter>Source Files\\editors\\CatalogEditor</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\CatalogEditor\\CatalogFileDelegate.cpp\">\r\n      <Filter>Source Files\\editors\\CatalogEditor</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\CatalogEditor\\CatalogFileFilter.cpp\">\r\n      <Filter>Source Files\\editors\\CatalogEditor</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\CatalogEditor\\CatalogFileView.cpp\">\r\n      <Filter>Source Files\\editors\\CatalogEditor</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"Plugins\\common\\LanguageHighlighter.cpp\">\r\n      <Filter>Source Files\\Plugins\\common</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\CSourceEditor\\CSourceHighlight.cpp\">\r\n      <Filter>Source Files\\editors\\CSourceEditor</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"Plugins\\common\\SourceHighlightStyle.cpp\">\r\n      <Filter>Source Files\\Plugins\\common</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\fileSet\\groupmanagerdelegate.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\fileSet</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"library\\LibraryErrorModel.cpp\">\r\n      <Filter>Source Files\\library</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"library\\LibraryFilter.cpp\">\r\n      <Filter>Source Files\\library</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"library\\LibraryTreeFilter.cpp\">\r\n      <Filter>Source Files\\library</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"library\\LibraryTreeWidget.cpp\">\r\n      <Filter>Source Files\\library</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"library\\LibraryTreeView.cpp\">\r\n      <Filter>Source Files\\library</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"library\\LibraryUtils.cpp\">\r\n      <Filter>Source Files\\library</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"library\\TableViewDialog.cpp\">\r\n      <Filter>Source Files\\library</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"library\\VLNVDialer\\filterwidget.cpp\">\r\n      <Filter>Source Files\\library\\VLNVDialer</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"library\\VLNVDialer\\firmnessgroup.cpp\">\r\n      <Filter>Source Files\\library\\VLNVDialer</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"library\\VLNVDialer\\hierarchygroup.cpp\">\r\n      <Filter>Source Files\\library\\VLNVDialer</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"library\\VLNVDialer\\implementationgroup.cpp\">\r\n      <Filter>Source Files\\library\\VLNVDialer</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"library\\VLNVDialer\\typegroup.cpp\">\r\n      <Filter>Source Files\\library\\VLNVDialer</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"library\\VLNVDialer\\vlnvdialer.cpp\">\r\n      <Filter>Source Files\\library\\VLNVDialer</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"library\\HierarchyView\\hierarchywidget.cpp\">\r\n      <Filter>Source Files\\library\\HierarchyView</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"library\\HierarchyView\\hierarchyview.cpp\">\r\n      <Filter>Source Files\\library\\HierarchyView</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"library\\HierarchyView\\hierarchyfilter.cpp\">\r\n      <Filter>Source Files\\library\\HierarchyView</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"common\\NameGenerationPolicy.cpp\">\r\n      <Filter>Source Files\\common</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\common\\DesignConfigurationInstantiationParameterFinder.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\common</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"library\\LibraryWidget.cpp\">\r\n      <Filter>Source Files\\library</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\indirectInterfaces\\IndirectInterfacesEditor.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\indirectInterfaces</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\indirectInterfaces\\IndirectInterfacesModel.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\indirectInterfaces</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\indirectInterfaces\\IndirectInterfacesDelegate.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\indirectInterfaces</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\treeStructure\\ComponentEditorIndirectInterfacesItem.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\treeStructure</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\treeStructure\\SingleIndirectInterfaceItem.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\treeStructure</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\indirectInterfaces\\SingleIndirectInterfaceEditor.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\indirectInterfaces</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\common\\ConfigurableElementFinder.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\common</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\parameterReferenceTree\\ComponentParameterReferenceTree.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\parameterReferenceTree</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\parameterReferenceTree\\ParameterReferenceTreeWindow.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\parameterReferenceTree</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\parameters\\ParametersView.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\parameters</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\referenceCounter\\ComponentParameterReferenceCounter.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\referenceCounter</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\ParameterItemEditor.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\treeStructure\\ParameterizableItem.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\treeStructure</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"mainwindow\\DockWidgetHandler.cpp\">\r\n      <Filter>Source Files\\mainwindow</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"common\\graphicsItems\\GraphicsColumnAddCommand.cpp\">\r\n      <Filter>Source Files\\common\\graphicsItems</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\ports\\PortWireTypeEditor.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\ports</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\ports\\PortWireTypeDelegate.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\ports</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\ports\\PortWireTypeModel.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\ports</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"common\\views\\EditableTreeView\\EditableTreeView.cpp\">\r\n      <Filter>Source Files\\common\\views\\EditableTreeView</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\ports\\PortWireTypeView.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\ports</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"common\\views\\EditableTreeView\\EditableTreeSortFilter.cpp\">\r\n      <Filter>Source Files\\common\\views\\EditableTreeView</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\ports\\PortTypeDefinitionDelegate.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\ports</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\ports\\PortTypeDefinitionEditor.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\ports</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\busInterfaces\\AbstractionTypesEditor.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\busInterfaces</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\busInterfaces\\AbstractionTypesModel.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\busInterfaces</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\busInterfaces\\AbstractionTypesDelegate.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\busInterfaces</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"mainwindow\\CommandLineParser.cpp\">\r\n      <Filter>Source Files\\mainwindow</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"common\\ui\\GraphicalMessageMediator.cpp\">\r\n      <Filter>Source Files\\common\\ui</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\common\\Association\\Associable.cpp\">\r\n      <Filter>Source Files\\editors\\common\\Association</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\common\\Association\\Association.cpp\">\r\n      <Filter>Source Files\\editors\\common\\Association</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\common\\Association\\AssociationAddCommand.cpp\">\r\n      <Filter>Source Files\\editors\\common\\Association</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\common\\Association\\AssociationChangeEndpointCommand.cpp\">\r\n      <Filter>Source Files\\editors\\common\\Association</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\common\\Association\\AssociationRemoveCommand.cpp\">\r\n      <Filter>Source Files\\editors\\common\\Association</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\common\\ComponentInstanceEditor\\ComponentInstanceConfigurableElementsEditor.cpp\">\r\n      <Filter>Source Files\\editors\\common\\ComponentInstanceEditor</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\common\\ComponentInstanceEditor\\ComponentInstanceConfigurableElementsFilter.cpp\">\r\n      <Filter>Source Files\\editors\\common\\ComponentInstanceEditor</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\common\\ComponentInstanceEditor\\ComponentInstanceConfigurableElementsModel.cpp\">\r\n      <Filter>Source Files\\editors\\common\\ComponentInstanceEditor</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\common\\ComponentInstanceEditor\\ConfigurableElementsFilter.cpp\">\r\n      <Filter>Source Files\\editors\\common\\ComponentInstanceEditor</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\common\\ComponentInstanceEditor\\ConfigurableElementsModel.cpp\">\r\n      <Filter>Source Files\\editors\\common\\ComponentInstanceEditor</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\common\\ComponentInstanceEditor\\ConfigurableElementsView.cpp\">\r\n      <Filter>Source Files\\editors\\common\\ComponentInstanceEditor</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\common\\ComponentInstanceEditor\\EditorConfigurableElement.cpp\">\r\n      <Filter>Source Files\\editors\\common\\ComponentInstanceEditor</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\common\\ComponentInstanceEditor\\MissingConfigurableElementsFilter.cpp\">\r\n      <Filter>Source Files\\editors\\common\\ComponentInstanceEditor</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\common\\ComponentInstanceEditor\\ParameterConfigurableElementsFilter.cpp\">\r\n      <Filter>Source Files\\editors\\common\\ComponentInstanceEditor</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\common\\ConnectionEditor\\AdHocBoundsModel.cpp\">\r\n      <Filter>Source Files\\editors\\common\\ConnectionEditor</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\common\\DesignParameterReferenceTree\\DesignParameterReferenceCounter.cpp\">\r\n      <Filter>Source Files\\editors\\common\\DesignParameterReferenceTree</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\common\\DesignParameterReferenceTree\\DesignParameterReferenceTree.cpp\">\r\n      <Filter>Source Files\\editors\\common\\DesignParameterReferenceTree</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\common\\InterfaceEditor\\InterfacePortMapDelegate.cpp\">\r\n      <Filter>Source Files\\editors\\common\\InterfaceEditor</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\common\\InterfaceEditor\\InterfacePortMapModel.cpp\">\r\n      <Filter>Source Files\\editors\\common\\InterfaceEditor</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\common\\StickyNote\\StickyNoteRemoveCommand.cpp\">\r\n      <Filter>Source Files\\editors\\common\\StickyNote</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\common\\StickyNote\\ColorFillTextItem.cpp\">\r\n      <Filter>Source Files\\editors\\common\\StickyNote</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\common\\StickyNote\\StickyNote.cpp\">\r\n      <Filter>Source Files\\editors\\common\\StickyNote</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\common\\StickyNote\\StickyNoteAddCommand.cpp\">\r\n      <Filter>Source Files\\editors\\common\\StickyNote</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\common\\StickyNote\\StickyNoteEditCommand.cpp\">\r\n      <Filter>Source Files\\editors\\common\\StickyNote</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\common\\StickyNote\\StickyNoteMoveCommand.cpp\">\r\n      <Filter>Source Files\\editors\\common\\StickyNote</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\common\\TopComponentParameterFinder.cpp\">\r\n      <Filter>Source Files\\editors\\common</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\common\\ComponentDesignDiagram.cpp\">\r\n      <Filter>Source Files\\editors\\common</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\common\\DefaultRouting.cpp\">\r\n      <Filter>Source Files\\editors\\common</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\common\\DesignCompletionModel.cpp\">\r\n      <Filter>Source Files\\editors\\common</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\common\\DesignDiagram.cpp\">\r\n      <Filter>Source Files\\editors\\common</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\common\\DesignDiagramResolver.cpp\">\r\n      <Filter>Source Files\\editors\\common</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\common\\DesignWidget.cpp\">\r\n      <Filter>Source Files\\editors\\common</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\common\\DesignWidgetFactoryImplementation.cpp\">\r\n      <Filter>Source Files\\editors\\common</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\common\\GraphicsItemLabel.cpp\">\r\n      <Filter>Source Files\\editors\\common</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\common\\ImageExporter.cpp\">\r\n      <Filter>Source Files\\editors\\common</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\common\\NamelabelWidth.cpp\">\r\n      <Filter>Source Files\\editors\\common</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\HWDesign\\AdhocEditor\\AdhocEditor.cpp\">\r\n      <Filter>Source Files\\editors\\HWDesign\\AdhocEditor</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\HWDesign\\columnview\\ColumnEditDialog.cpp\">\r\n      <Filter>Source Files\\editors\\HWDesign\\columnview</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\HWDesign\\columnview\\HWColumn.cpp\">\r\n      <Filter>Source Files\\editors\\HWDesign\\columnview</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\HWDesign\\undoCommands\\HWColumnAddCommand.cpp\">\r\n      <Filter>Source Files\\editors\\HWDesign\\undoCommands</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\HWDesign\\undoCommands\\HWComponentAddCommand.cpp\">\r\n      <Filter>Source Files\\editors\\HWDesign\\undoCommands</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\HWDesign\\undoCommands\\InterfaceDeleteCommand.cpp\">\r\n      <Filter>Source Files\\editors\\HWDesign\\undoCommands</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\HWDesign\\undoCommands\\PhysicalPortDeleteCommand.cpp\">\r\n      <Filter>Source Files\\editors\\HWDesign\\undoCommands</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\HWDesign\\undoCommands\\PortDeleteCommand.cpp\">\r\n      <Filter>Source Files\\editors\\HWDesign\\undoCommands</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\HWDesign\\undoCommands\\PortPasteCommand.cpp\">\r\n      <Filter>Source Files\\editors\\HWDesign\\undoCommands</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\HWDesign\\undoCommands\\ReplaceComponentCommand.cpp\">\r\n      <Filter>Source Files\\editors\\HWDesign\\undoCommands</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\HWDesign\\undoCommands\\TopAdHocVisibilityChangeCommand.cpp\">\r\n      <Filter>Source Files\\editors\\HWDesign\\undoCommands</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\HWDesign\\undoCommands\\AdHocBoundsChangeCommand.cpp\">\r\n      <Filter>Source Files\\editors\\HWDesign\\undoCommands</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\HWDesign\\undoCommands\\AdHocConnectionAddCommand.cpp\">\r\n      <Filter>Source Files\\editors\\HWDesign\\undoCommands</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\HWDesign\\undoCommands\\AdHocConnectionDeleteCommand.cpp\">\r\n      <Filter>Source Files\\editors\\HWDesign\\undoCommands</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\HWDesign\\undoCommands\\AdHocTiedValueCommand.cpp\">\r\n      <Filter>Source Files\\editors\\HWDesign\\undoCommands</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\HWDesign\\undoCommands\\AdHocTieOffBoundsChangeCommand.cpp\">\r\n      <Filter>Source Files\\editors\\HWDesign\\undoCommands</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\HWDesign\\undoCommands\\AdHocTieOffChangeCommand.cpp\">\r\n      <Filter>Source Files\\editors\\HWDesign\\undoCommands</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\HWDesign\\undoCommands\\AdHocTieOffConnectionDeleteCommand.cpp\">\r\n      <Filter>Source Files\\editors\\HWDesign\\undoCommands</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\HWDesign\\undoCommands\\AdHocVisibilityChangeCommand.cpp\">\r\n      <Filter>Source Files\\editors\\HWDesign\\undoCommands</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\HWDesign\\undoCommands\\ColumnDeleteCommand.cpp\">\r\n      <Filter>Source Files\\editors\\HWDesign\\undoCommands</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\HWDesign\\undoCommands\\ComponentDeleteCommand.cpp\">\r\n      <Filter>Source Files\\editors\\HWDesign\\undoCommands</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\HWDesign\\undoCommands\\ComponentInstancePasteCommand.cpp\">\r\n      <Filter>Source Files\\editors\\HWDesign\\undoCommands</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\HWDesign\\undoCommands\\ComponentItemMoveCommand.cpp\">\r\n      <Filter>Source Files\\editors\\HWDesign\\undoCommands</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\HWDesign\\undoCommands\\ConfigurableElementChangeCommand.cpp\">\r\n      <Filter>Source Files\\editors\\HWDesign\\undoCommands</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\HWDesign\\undoCommands\\ConfigurableElementRemoveCommand.cpp\">\r\n      <Filter>Source Files\\editors\\HWDesign\\undoCommands</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\HWDesign\\undoCommands\\ConnectionDeleteCommand.cpp\">\r\n      <Filter>Source Files\\editors\\HWDesign\\undoCommands</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\HWDesign\\HWDesignDiagram.cpp\">\r\n      <Filter>Source Files\\editors\\HWDesign</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\HWDesign\\HWDesignWidget.cpp\">\r\n      <Filter>Source Files\\editors\\HWDesign</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\HWDesign\\HWMoveCommands.cpp\">\r\n      <Filter>Source Files\\editors\\HWDesign</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\HWDesign\\OffPageConnectorItem.cpp\">\r\n      <Filter>Source Files\\editors\\HWDesign</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\HWDesign\\PortmapDialog.cpp\">\r\n      <Filter>Source Files\\editors\\HWDesign</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\HWDesign\\SelectItemTypeDialog.cpp\">\r\n      <Filter>Source Files\\editors\\HWDesign</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\HWDesign\\AdHocConnectionItem.cpp\">\r\n      <Filter>Source Files\\editors\\HWDesign</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\HWDesign\\AdHocEnabled.cpp\">\r\n      <Filter>Source Files\\editors\\HWDesign</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\HWDesign\\AdHocItem.cpp\">\r\n      <Filter>Source Files\\editors\\HWDesign</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\HWDesign\\BusInterfaceDialog.cpp\">\r\n      <Filter>Source Files\\editors\\HWDesign</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\HWDesign\\BusInterfaceEndPoint.cpp\">\r\n      <Filter>Source Files\\editors\\HWDesign</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\HWDesign\\HWAddCommands.cpp\">\r\n      <Filter>Source Files\\editors\\HWDesign</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\HWDesign\\HWChangeCommands.cpp\">\r\n      <Filter>Source Files\\editors\\HWDesign</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\HWDesign\\HWComponentItem.cpp\">\r\n      <Filter>Source Files\\editors\\HWDesign</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\HWDesign\\HWConnection.cpp\">\r\n      <Filter>Source Files\\editors\\HWDesign</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\HWDesign\\HWConnectionEndPoint.cpp\">\r\n      <Filter>Source Files\\editors\\HWDesign</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\common\\ComponentInstanceEditor\\configurableelementeditor.cpp\">\r\n      <Filter>Source Files\\editors\\common\\ComponentInstanceEditor</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\common\\ComponentInstanceEditor\\componentinstanceeditor.cpp\">\r\n      <Filter>Source Files\\editors\\common\\ComponentInstanceEditor</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\common\\ComponentInstanceEditor\\configurableelementdelegate.cpp\">\r\n      <Filter>Source Files\\editors\\common\\ComponentInstanceEditor</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\common\\ConfigurationEditor\\configurationeditor.cpp\">\r\n      <Filter>Source Files\\editors\\common\\ConfigurationEditor</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\common\\ConfigurationEditor\\activeviewdelegate.cpp\">\r\n      <Filter>Source Files\\editors\\common\\ConfigurationEditor</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\common\\ConfigurationEditor\\activevieweditor.cpp\">\r\n      <Filter>Source Files\\editors\\common\\ConfigurationEditor</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\common\\ConfigurationEditor\\activeviewmodel.cpp\">\r\n      <Filter>Source Files\\editors\\common\\ConfigurationEditor</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\common\\ConnectionEditor\\connectioneditor.cpp\">\r\n      <Filter>Source Files\\editors\\common\\ConnectionEditor</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\common\\InterfaceEditor\\interfaceeditor.cpp\">\r\n      <Filter>Source Files\\editors\\common\\InterfaceEditor</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\MemoryDesigner\\MemoryGraphicsItemHandler.cpp\">\r\n      <Filter>Source Files\\editors\\MemoryDesigner</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\MemoryDesigner\\MemoryItem.cpp\">\r\n      <Filter>Source Files\\editors\\MemoryDesigner</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\MemoryDesigner\\MemoryMapGraphicsItem.cpp\">\r\n      <Filter>Source Files\\editors\\MemoryDesigner</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\MemoryDesigner\\RegisterGraphicsItem.cpp\">\r\n      <Filter>Source Files\\editors\\MemoryDesigner</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\MemoryDesigner\\SubMemoryLayout.cpp\">\r\n      <Filter>Source Files\\editors\\MemoryDesigner</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\MemoryDesigner\\AddressBlockGraphicsItem.cpp\">\r\n      <Filter>Source Files\\editors\\MemoryDesigner</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\MemoryDesigner\\AddressSegmentGraphicsItem.cpp\">\r\n      <Filter>Source Files\\editors\\MemoryDesigner</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\MemoryDesigner\\AddressSpaceGraphicsItem.cpp\">\r\n      <Filter>Source Files\\editors\\MemoryDesigner</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\MemoryDesigner\\ConnectivityComponent.cpp\">\r\n      <Filter>Source Files\\editors\\MemoryDesigner</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\MemoryDesigner\\ConnectivityConnection.cpp\">\r\n      <Filter>Source Files\\editors\\MemoryDesigner</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\MemoryDesigner\\ConnectivityGraph.cpp\">\r\n      <Filter>Source Files\\editors\\MemoryDesigner</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\MemoryDesigner\\ConnectivityGraphFactory.cpp\">\r\n      <Filter>Source Files\\editors\\MemoryDesigner</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\MemoryDesigner\\ConnectivityInterface.cpp\">\r\n      <Filter>Source Files\\editors\\MemoryDesigner</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\MemoryDesigner\\FieldGraphicsItem.cpp\">\r\n      <Filter>Source Files\\editors\\MemoryDesigner</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\MemoryDesigner\\FieldOverlapItem.cpp\">\r\n      <Filter>Source Files\\editors\\MemoryDesigner</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\MemoryDesigner\\MainMemoryGraphicsItem.cpp\">\r\n      <Filter>Source Files\\editors\\MemoryDesigner</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\MemoryDesigner\\MasterSlavePathSearch.cpp\">\r\n      <Filter>Source Files\\editors\\MemoryDesigner</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\MemoryDesigner\\MemoryCollisionItem.cpp\">\r\n      <Filter>Source Files\\editors\\MemoryDesigner</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\MemoryDesigner\\MemoryColumn.cpp\">\r\n      <Filter>Source Files\\editors\\MemoryDesigner</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\MemoryDesigner\\MemoryColumnHandler.cpp\">\r\n      <Filter>Source Files\\editors\\MemoryDesigner</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\MemoryDesigner\\MemoryConnectionHandler.cpp\">\r\n      <Filter>Source Files\\editors\\MemoryDesigner</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\MemoryDesigner\\MemoryConnectionItem.cpp\">\r\n      <Filter>Source Files\\editors\\MemoryDesigner</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\MemoryDesigner\\MemoryDesignConstructor.cpp\">\r\n      <Filter>Source Files\\editors\\MemoryDesigner</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\MemoryDesigner\\MemoryDesignDocument.cpp\">\r\n      <Filter>Source Files\\editors\\MemoryDesigner</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\MemoryDesigner\\MemoryDesignerChildGraphicsItem.cpp\">\r\n      <Filter>Source Files\\editors\\MemoryDesigner</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\MemoryDesigner\\MemoryDesignerConstants.cpp\">\r\n      <Filter>Source Files\\editors\\MemoryDesigner</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\MemoryDesigner\\MemoryDesignerDiagram.cpp\">\r\n      <Filter>Source Files\\editors\\MemoryDesigner</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\MemoryDesigner\\MemoryDesignerGraphicsItem.cpp\">\r\n      <Filter>Source Files\\editors\\MemoryDesigner</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\MemoryDesigner\\MemoryExtensionGraphicsItem.cpp\">\r\n      <Filter>Source Files\\editors\\MemoryDesigner</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\SystemDesign\\SystemDetailsEditor\\SystemDetailsEditor.cpp\">\r\n      <Filter>Source Files\\editors\\SystemDesign\\SystemDetailsEditor</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\SystemDesign\\SystemDetailsEditor\\ExportSWDialog.cpp\">\r\n      <Filter>Source Files\\editors\\SystemDesign\\SystemDetailsEditor</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\SystemDesign\\SystemDetailsEditor\\SwitchHWDialog.cpp\">\r\n      <Filter>Source Files\\editors\\SystemDesign\\SystemDetailsEditor</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\SystemDesign\\UndoCommands\\ComConnectionAddCommand.cpp\">\r\n      <Filter>Source Files\\editors\\SystemDesign\\UndoCommands</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\SystemDesign\\UndoCommands\\ComConnectionDeleteCommand.cpp\">\r\n      <Filter>Source Files\\editors\\SystemDesign\\UndoCommands</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\SystemDesign\\UndoCommands\\ComConnectionExchangeCommand.cpp\">\r\n      <Filter>Source Files\\editors\\SystemDesign\\UndoCommands</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\SystemDesign\\UndoCommands\\ReplaceSystemComponentCommand.cpp\">\r\n      <Filter>Source Files\\editors\\SystemDesign\\UndoCommands</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\SystemDesign\\UndoCommands\\SWInterfaceAddCommand.cpp\">\r\n      <Filter>Source Files\\editors\\SystemDesign\\UndoCommands</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\SystemDesign\\UndoCommands\\SWInterfaceDeleteCommand.cpp\">\r\n      <Filter>Source Files\\editors\\SystemDesign\\UndoCommands</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\SystemDesign\\UndoCommands\\SWInterfaceMoveCommand.cpp\">\r\n      <Filter>Source Files\\editors\\SystemDesign\\UndoCommands</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\SystemDesign\\UndoCommands\\SWPortDeleteCommand.cpp\">\r\n      <Filter>Source Files\\editors\\SystemDesign\\UndoCommands</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\SystemDesign\\UndoCommands\\SystemAddCommands.cpp\">\r\n      <Filter>Source Files\\editors\\SystemDesign\\UndoCommands</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\SystemDesign\\UndoCommands\\SystemChangeCommands.cpp\">\r\n      <Filter>Source Files\\editors\\SystemDesign\\UndoCommands</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\SystemDesign\\UndoCommands\\SystemComponentAddCommand.cpp\">\r\n      <Filter>Source Files\\editors\\SystemDesign\\UndoCommands</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\SystemDesign\\UndoCommands\\SystemComponentDeleteCommand.cpp\">\r\n      <Filter>Source Files\\editors\\SystemDesign\\UndoCommands</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\SystemDesign\\UndoCommands\\SystemDeleteCommands.cpp\">\r\n      <Filter>Source Files\\editors\\SystemDesign\\UndoCommands</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\SystemDesign\\UndoCommands\\SystemMoveCommands.cpp\">\r\n      <Filter>Source Files\\editors\\SystemDesign\\UndoCommands</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\SystemDesign\\UndoCommands\\ApiConnectionAddCommand.cpp\">\r\n      <Filter>Source Files\\editors\\SystemDesign\\UndoCommands</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\SystemDesign\\UndoCommands\\ApiConnectionDeleteCommand.cpp\">\r\n      <Filter>Source Files\\editors\\SystemDesign\\UndoCommands</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\SystemDesign\\UndoCommands\\ApiConnectionExchangeCommand.cpp\">\r\n      <Filter>Source Files\\editors\\SystemDesign\\UndoCommands</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\SystemDesign\\SystemDesignWidget.cpp\">\r\n      <Filter>Source Files\\editors\\SystemDesign</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\SystemDesign\\ApiGraphicsConnection.cpp\">\r\n      <Filter>Source Files\\editors\\SystemDesign</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\SystemDesign\\ComGraphicsConnection.cpp\">\r\n      <Filter>Source Files\\editors\\SystemDesign</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\SystemDesign\\HWMappingItem.cpp\">\r\n      <Filter>Source Files\\editors\\SystemDesign</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\SystemDesign\\SWComponentItem.cpp\">\r\n      <Filter>Source Files\\editors\\SystemDesign</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\SystemDesign\\SWConnectionEndpoint.cpp\">\r\n      <Filter>Source Files\\editors\\SystemDesign</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\SystemDesign\\SWInterfaceItem.cpp\">\r\n      <Filter>Source Files\\editors\\SystemDesign</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\SystemDesign\\SWPortItem.cpp\">\r\n      <Filter>Source Files\\editors\\SystemDesign</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\SystemDesign\\SystemColumn.cpp\">\r\n      <Filter>Source Files\\editors\\SystemDesign</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\SystemDesign\\SystemComponentItem.cpp\">\r\n      <Filter>Source Files\\editors\\SystemDesign</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\SystemDesign\\SystemDesignDiagram.cpp\">\r\n      <Filter>Source Files\\editors\\SystemDesign</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\MemoryDesigner\\MemoryConnectionAddressCalculator.cpp\">\r\n      <Filter>Source Files\\editors\\MemoryDesigner</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\BusDefinitionEditor\\SystemGroupListEditor.cpp\">\r\n      <Filter>Source Files\\editors\\BusDefinitionEditor</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\memoryMaps\\memoryMapsVisualizer\\registerfilegraphitem.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\memoryMaps\\memoryMapsVisualizer</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\memoryMaps\\SingleRegisterFileEditor.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\memoryMaps</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\treeStructure\\componenteditorregisterfileitem.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\treeStructure</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\memoryMaps\\registerfilemodel.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\memoryMaps</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\memoryMaps\\registerfiledelegate.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\memoryMaps</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\memoryMaps\\registerfileeditor.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\memoryMaps</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\common\\VendorExtensionEditor\\VendorExtensionsModel.cpp\">\r\n      <Filter>Source Files\\editors\\VendorExtensionEditor</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\common\\VendorExtensionEditor\\VendorExtensionsEditor.cpp\">\r\n      <Filter>Source Files\\editors\\VendorExtensionEditor</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\treeStructure\\ResetTypesItem.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\treeStructure</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\resetTypes\\ResetTypesEditor.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\resetTypes</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\resetTypes\\ResetTypesModel.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\resetTypes</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\resetTypes\\ResetTypesDelegate.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\resetTypes</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\memoryMaps\\ResetsEditor.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\memoryMaps</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\memoryMaps\\ResetsModel.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\memoryMaps</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\memoryMaps\\ResetsDelegate.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\memoryMaps</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\common\\VendorExtensionEditor\\VendorExtensionsDelegate.cpp\">\r\n      <Filter>Source Files\\editors\\VendorExtensionEditor</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\common\\ComponentItemAutoConnector\\ComponentItemAutoConnector.cpp\">\r\n      <Filter>Source Files\\editors\\common\\ComponentItemAutoConnector</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\common\\ComponentItemAutoConnector\\AutoConnectorConnectionTable.cpp\">\r\n      <Filter>Source Files\\editors\\common\\ComponentItemAutoConnector</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\common\\ComponentItemAutoConnector\\AutoConnectorItem.cpp\">\r\n      <Filter>Source Files\\editors\\common\\ComponentItemAutoConnector</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\common\\ComponentItemAutoConnector\\AutoConnector.cpp\">\r\n      <Filter>Source Files\\editors\\common\\ComponentItemAutoConnector</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\common\\ComponentItemAutoConnector\\PortListFiller.cpp\">\r\n      <Filter>Source Files\\editors\\common\\ComponentItemAutoConnector</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\common\\ComponentItemAutoConnector\\AutoConnectorConnectionDelegate.cpp\">\r\n      <Filter>Source Files\\editors\\common\\ComponentItemAutoConnector</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\common\\ComponentItemAutoConnector\\PortTableAutoConnector.cpp\">\r\n      <Filter>Source Files\\editors\\common\\ComponentItemAutoConnector</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\common\\ComponentItemAutoConnector\\TableAutoConnector.cpp\">\r\n      <Filter>Source Files\\editors\\common\\ComponentItemAutoConnector</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\common\\ComponentItemAutoConnector\\BusInterfaceListFiller.cpp\">\r\n      <Filter>Source Files\\editors\\common\\ComponentItemAutoConnector</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\common\\ComponentItemAutoConnector\\BusInterfaceTableAutoConnector.cpp\">\r\n      <Filter>Source Files\\editors\\common\\ComponentItemAutoConnector</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\HWDesign\\HierarchicalBusInterfaceItem.cpp\">\r\n      <Filter>Source Files\\editors\\HWDesign</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\HWDesign\\ActiveBusInterfaceItem.cpp\">\r\n      <Filter>Source Files\\editors\\HWDesign</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\HWDesign\\HierarchicalPortItem.cpp\">\r\n      <Filter>Source Files\\editors\\HWDesign</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\HWDesign\\ActivePortItem.cpp\">\r\n      <Filter>Source Files\\editors\\HWDesign</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\common\\ComponentItemAutoConnector\\AutoConnectorListFilter.cpp\">\r\n      <Filter>Source Files\\editors\\common\\ComponentItemAutoConnector</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\common\\ComponentItemAutoConnector\\PortItemMatcher.cpp\">\r\n      <Filter>Source Files\\editors\\common\\ComponentItemAutoConnector</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\common\\ComponentItemAutoConnector\\TableItemMatcher.cpp\">\r\n      <Filter>Source Files\\editors\\common\\ComponentItemAutoConnector</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\common\\ComponentItemAutoConnector\\BusInterfaceItemMatcher.cpp\">\r\n      <Filter>Source Files\\editors\\common\\ComponentItemAutoConnector</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\common\\PortUtilities.cpp\">\r\n      <Filter>Source Files\\editors\\common</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\common\\ComponentItemAutoConnector\\HierarchicalPortTableAutoConnector.cpp\">\r\n      <Filter>Source Files\\editors\\common\\ComponentItemAutoConnector</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\common\\ComponentItemAutoConnector\\HierarchicalPortItemMatcher.cpp\">\r\n      <Filter>Source Files\\editors\\common\\ComponentItemAutoConnector</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\common\\ComponentItemAutoConnector\\HierarchicalBusInterfaceItemMatcher.cpp\">\r\n      <Filter>Source Files\\editors\\common\\ComponentItemAutoConnector</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\common\\ComponentItemAutoConnector\\HierarchicalBusInterfaceTableAutoConnector.cpp\">\r\n      <Filter>Source Files\\editors\\common\\ComponentItemAutoConnector</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\common\\VendorExtensionEditor\\VendorExtensionsFilter.cpp\">\r\n      <Filter>Source Files\\editors\\VendorExtensionEditor</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\common\\VendorExtensionEditor\\VendorExtensionAttributesEditor\\VendorExtensionAttributesModel.cpp\">\r\n      <Filter>Source Files\\editors\\VendorExtensionEditor\\VendorExtensionsAttributesEditor</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"wizards\\ImportWizard\\ImportInstancesEditor\\ImportInstancesEditor.cpp\">\r\n      <Filter>Source Files\\wizards\\ImportWizard\\ImportInstancesEditor</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"wizards\\ImportWizard\\ImportWizardInstancesPage.cpp\">\r\n      <Filter>Source Files\\wizards\\ImportWizard</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"common\\expressions\\utilities.cpp\">\r\n      <Filter>Source Files\\common\\expressions</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"wizards\\ImportWizard\\ImportInstancesEditor\\ImportInstancesDelegate.cpp\">\r\n      <Filter>Source Files\\wizards\\ImportWizard\\ImportInstancesEditor</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\ports\\MasterPortsEditor.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\ports</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\ports\\WirePortsModel.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\ports</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\ports\\TransactionalPortsModel.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\ports</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\ports\\WirePortsFilter.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\ports</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\ports\\TransactionalPortsFilter.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\ports</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\ports\\WirePortsDelegate.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\ports</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\ports\\TransactionalPortsDelegate.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\ports</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\ports\\PortsFilter.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\ports</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"common\\widgets\\tagEditor\\TagLabel.cpp\">\r\n      <Filter>Source Files\\common\\widgets\\tagEditor</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"common\\widgets\\tagEditor\\FlowLayout.cpp\">\r\n      <Filter>Source Files\\common\\widgets\\tagEditor</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"common\\widgets\\tagEditor\\TagContainer.cpp\">\r\n      <Filter>Source Files\\common\\widgets\\tagEditor</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"common\\widgets\\tagEditor\\TagEditor.cpp\">\r\n      <Filter>Source Files\\common\\widgets\\tagEditor</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"common\\widgets\\tagEditor\\TagCompleterModel.cpp\">\r\n      <Filter>Source Files\\common\\widgets\\tagEditor</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"common\\widgets\\tagEditor\\TagEditorContainer.cpp\">\r\n      <Filter>Source Files\\common\\widgets\\tagEditor</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"common\\widgets\\tagEditor\\TagDisplay.cpp\">\r\n      <Filter>Source Files\\common\\widgets\\tagEditor</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"common\\widgets\\tagEditor\\TagSelectorContainer.cpp\">\r\n      <Filter>Source Files\\common\\widgets\\tagEditor</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"common\\widgets\\tagEditor\\TagSelector.cpp\">\r\n      <Filter>Source Files\\common\\widgets\\tagEditor</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"PythonAPI\\PythonInterpreter.cpp\">\r\n      <Filter>Source Files\\PythonAPI</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"PythonAPI\\ChannelRelay.cpp\">\r\n      <Filter>Source Files\\PythonAPI</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"PythonAPI\\FileChannel.cpp\">\r\n      <Filter>Source Files\\PythonAPI</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"PythonAPI\\StdInputListener.cpp\">\r\n      <Filter>Source Files\\PythonAPI</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"PythonAPI\\extensions\\IOCatcher.cpp\">\r\n      <Filter>Source Files\\PythonAPI\\extensions</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\HWDesign\\WarningSymbol.cpp\">\r\n      <Filter>Source Files\\editors\\HWDesign</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\memoryMaps\\SubspaceMapsEditor.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\memoryMaps</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\memoryMaps\\SubspaceMapModel.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\memoryMaps</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\memoryMaps\\MemoryBlockModel.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\memoryMaps</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\memoryMaps\\MemoryBlockDelegate.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\memoryMaps</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\memoryMaps\\SubspaceMapDelegate.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\memoryMaps</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\memoryMaps\\MemoryBlockFilter.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\memoryMaps</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\treeStructure\\SubspaceMapItem.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\treeStructure</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\memoryMaps\\SingleSubspaceMapEditor.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\memoryMaps</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"common\\widgets\\busReferenceComboBox\\BusReferenceComboBox.cpp\">\r\n      <Filter>Source Files\\common\\widgets\\busReferenceComboBox</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"common\\widgets\\segmentComboBox\\SegmentComboBox.cpp\">\r\n      <Filter>Source Files\\common\\widgets\\segmentComboBox</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\memoryMaps\\memoryMapsVisualizer\\SubspaceMapGraphItem.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\memoryMaps\\memoryMapsVisualizer</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\memoryMaps\\memoryMapsVisualizer\\MemoryBlockGraphItem.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\memoryMaps\\memoryMapsVisualizer</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"settings\\NewPluginsDialog.cpp\">\r\n      <Filter>Source Files\\settings</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"settings\\PluginInfoWidget.cpp\">\r\n      <Filter>Source Files\\settings</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"wizards\\ComponentWizard\\ImportEditor.cpp\">\r\n      <Filter>Source Files\\wizards\\ComponentWizard</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"library\\objectremovedialog.cpp\">\r\n      <Filter>Source Files\\library</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"library\\ObjectSelectionDialog.cpp\">\r\n      <Filter>Source Files\\library\\VLNVDialer</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"library\\ObjectSelectionListItem.cpp\">\r\n      <Filter>Source Files\\library\\VLNVDialer</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"library\\LibraryItemSelectionFactory.cpp\">\r\n      <Filter>Source Files\\library</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"library\\ItemExporter.cpp\">\r\n      <Filter>Source Files\\library</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"library\\ObjectExportDialog.cpp\">\r\n      <Filter>Source Files\\library</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\PythonSourceEditor\\ScriptingSideArea.cpp\">\r\n      <Filter>Source Files\\editors\\PythonSourceEditor</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\PythonSourceEditor\\ScriptInputEditor.cpp\">\r\n      <Filter>Source Files\\editors\\PythonSourceEditor</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\PythonSourceEditor\\ScriptViewEditor.cpp\">\r\n      <Filter>Source Files\\editors\\PythonSourceEditor</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\PythonSourceEditor\\PythonSourceEditor.cpp\">\r\n      <Filter>Source Files\\editors\\PythonSourceEditor</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\PythonSourceEditor\\PythonSourceHighlight.cpp\">\r\n      <Filter>Source Files\\editors\\PythonSourceEditor</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\busInterfaces\\portmaps\\PortMapView.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\busInterfaces\\portmaps</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\busInterfaces\\portmaps\\PortMapModel.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\busInterfaces\\portmaps</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\busInterfaces\\portmaps\\PortMapSortFilter.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\busInterfaces\\portmaps</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\busInterfaces\\portmaps\\PortMapDelegate.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\busInterfaces\\portmaps</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"common\\views\\ExpandingTreeView\\ExpandingTreeView.cpp\">\r\n      <Filter>Source Files\\common\\views\\ExpandingTreeView</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\common\\ExpressionLineEditor.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\common</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\common\\MasterExpressionEditor.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\common</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\common\\EnumerationEditorConstructorDelegate.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\common</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"common\\widgets\\EnumCollectionEditor\\EnumerationEditor.cpp\">\r\n      <Filter>Source Files\\common\\widgets\\EnumCollectionEditor</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"Plugins\\common\\ConnectivityGraphUtilities.cpp\">\r\n      <Filter>Source Files\\Plugins\\common</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"mainwindow\\WorkspaceSettings.cpp\">\r\n      <Filter>Source Files\\mainwindow</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"library\\VLNVDialer\\FilterGroup.cpp\">\r\n      <Filter>Source Files\\library\\VLNVDialer</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\HWDesign\\AdhocEditor\\AdhocPortEditor.cpp\">\r\n      <Filter>Source Files\\editors\\HWDesign\\AdhocEditor</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\HWDesign\\AdhocEditor\\AdHocVisibilityDelegate.cpp\">\r\n      <Filter>Source Files\\editors\\HWDesign\\AdhocEditor</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\HWDesign\\AdhocEditor\\AdHocVisibilityEditor.cpp\">\r\n      <Filter>Source Files\\editors\\HWDesign\\AdhocEditor</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\HWDesign\\AdhocEditor\\AdHocVisibilityModel.cpp\">\r\n      <Filter>Source Files\\editors\\HWDesign\\AdhocEditor</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\HWDesign\\AdhocEditor\\AdHocVisibilityPolicy.cpp\">\r\n      <Filter>Source Files\\editors\\HWDesign\\AdhocEditor</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"Plugins\\common\\CpuRoutesContainer.cpp\">\r\n      <Filter>Source Files\\Plugins\\common</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"Plugins\\common\\SingleCpuRoutesContainer.cpp\">\r\n      <Filter>Source Files\\Plugins\\common</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"kactusGenerators\\DocumentGenerator\\DocumentationWriter.cpp\">\r\n      <Filter>Source Files\\kactusGenerators\\DocumentGenerator</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"kactusGenerators\\DocumentGenerator\\MarkdownWriter.cpp\">\r\n      <Filter>Source Files\\kactusGenerators\\DocumentGenerator</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"kactusGenerators\\DocumentGenerator\\HtmlWriter.cpp\">\r\n      <Filter>Source Files\\kactusGenerators\\DocumentGenerator</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\AbstractionDefinitionEditor\\AbstractionDefinitionEditor.cpp\">\r\n      <Filter>Source Files\\editors\\AbstractionDefinitionEditor</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\AbstractionDefinitionEditor\\AbstractionDefinitionPortsSortFilter.cpp\">\r\n      <Filter>Source Files\\editors\\AbstractionDefinitionEditor</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\AbstractionDefinitionEditor\\AbstractionDefinitionSignalRow.cpp\">\r\n      <Filter>Source Files\\editors\\AbstractionDefinitionEditor</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\AbstractionDefinitionEditor\\AbstractionPortsDelegate.cpp\">\r\n      <Filter>Source Files\\editors\\AbstractionDefinitionEditor</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\AbstractionDefinitionEditor\\AbstractionPortsEditor.cpp\">\r\n      <Filter>Source Files\\editors\\AbstractionDefinitionEditor</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\AbstractionDefinitionEditor\\AbstractionPortsModel.cpp\">\r\n      <Filter>Source Files\\editors\\AbstractionDefinitionEditor</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\AbstractionDefinitionEditor\\AbstractionPortsView.cpp\">\r\n      <Filter>Source Files\\editors\\AbstractionDefinitionEditor</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\AbstractionDefinitionEditor\\AbstractionTransactionalPortsDelegate.cpp\">\r\n      <Filter>Source Files\\editors\\AbstractionDefinitionEditor</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\AbstractionDefinitionEditor\\AbstractionTransactionalPortsSortFilter.cpp\">\r\n      <Filter>Source Files\\editors\\AbstractionDefinitionEditor</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\AbstractionDefinitionEditor\\AbstractionWirePortsDelegate.cpp\">\r\n      <Filter>Source Files\\editors\\AbstractionDefinitionEditor</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\AbstractionDefinitionEditor\\AbstractionWirePortsSortFilter.cpp\">\r\n      <Filter>Source Files\\editors\\AbstractionDefinitionEditor</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\AbstractionDefinitionEditor\\absdefgroup.cpp\">\r\n      <Filter>Source Files\\editors\\AbstractionDefinitionEditor</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\common\\DocumentNameGroupEditor.cpp\">\r\n      <Filter>Source Files\\editors\\common</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"wizards\\BusInterfaceWizard\\BusInterfaceWizardAbsDefinitionPage.cpp\">\r\n      <Filter>Source Files\\wizards\\BusInterfaceWizard</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\treeStructure\\ComponentEditorTreeDelegate.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\treeStructure</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\treeStructure\\SingleCpuItem.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\treeStructure</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\cpus\\SingleCpuEditor.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\cpus</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\cpus\\CpuDetailsEditor.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\cpus</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\cpus\\RegionsModel.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\cpus</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\cpus\\RegionsEditor.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\cpus</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\cpus\\RegionsDelegate.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\cpus</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\AbstractionDefinitionEditor\\QualifierEditor.cpp\">\r\n      <Filter>Source Files\\editors\\AbstractionDefinitionEditor</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\memoryMaps\\FieldAccessPoliciesEditor.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\memoryMaps</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\memoryMaps\\FieldAccessPoliciesDelegate.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\memoryMaps</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\memoryMaps\\FieldAccessPoliciesModel.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\memoryMaps</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\common\\ModeReferenceEditor.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\common</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\common\\ModeReferenceDelegate.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\common</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\common\\ModeReferenceModel.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\common</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\busInterfaces\\general\\ModeEditorBase.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\busInterfaces\\general</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\busInterfaces\\general\\SlaveModeEditor.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\busInterfaces\\general</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\busInterfaces\\general\\MirroredSlaveModeEditor.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\busInterfaces\\general</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\busInterfaces\\general\\MirroredMasterModeEditor.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\busInterfaces\\general</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\busInterfaces\\general\\MonitorModeEditor.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\busInterfaces\\general</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\busInterfaces\\general\\SystemModeEditor.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\busInterfaces\\general</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\busInterfaces\\general\\InitiatorModeEditor.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\busInterfaces\\general</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\busInterfaces\\general\\TargetModeEditor.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\busInterfaces\\general</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\busInterfaces\\general\\MirroredInitiatorModeEditor.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\busInterfaces\\general</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\busInterfaces\\general\\MirroredTargetModeEditor.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\busInterfaces\\general</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\busInterfaces\\general\\MasterModeEditor.cpp\">\r\n      <Filter>Source Files</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\modes\\ModesEditor.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\modes</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\modes\\ModesModel.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\modes</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\modes\\SingleModeEditor.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\modes</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\treeStructure\\ModesItem.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\treeStructure</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\treeStructure\\SingleModeItem.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\treeStructure</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\modes\\PortSliceEditor.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\modes</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\modes\\PortSliceModel.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\modes</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\modes\\PortSliceDelegate.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\modes</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\modes\\FieldSliceEditor.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\modes</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\modes\\FieldSliceModel.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\modes</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\common\\InstantiationConfigurableElementEditor.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\common</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\memoryMaps\\AccessPoliciesEditor.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\memoryMaps</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\memoryMaps\\AccessPoliciesModel.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\memoryMaps</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\memoryMaps\\AccessPoliciesDelegate.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\memoryMaps</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"common\\widgets\\TreeItemSelector\\TreeItemEditor.cpp\">\r\n      <Filter>Source Files\\common\\widgets\\TreeItemSelector</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"common\\widgets\\TreeItemSelector\\TreeItemModel.cpp\">\r\n      <Filter>Source Files\\common\\widgets\\TreeItemSelector</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\common\\MemoryTreeFactory.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\common</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\modes\\FieldSliceDelegate.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\modes</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"common\\widgets\\TreeItemSelector\\FramedTreeItemEditor.cpp\">\r\n      <Filter>Source Files\\common\\widgets\\TreeItemSelector</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"library\\VLNVDialer\\ValidityGroup.cpp\">\r\n      <Filter>Source Files\\library\\VLNVDialer</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\common\\MemoryAlignScene.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\common</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\cpus\\RegionScene.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\cpus</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\cpus\\CpuVisualizer.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\cpus</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\treeStructure\\PowerDomainsItem.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\treeStructure</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\powerDomains\\PowerDomainsEditor.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\powerDomains</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\powerDomains\\PowerDomainsModel.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\powerDomains</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\powerDomains\\PowerDomainsDelegate.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\powerDomains</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\visualization\\AddressableItem.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\visualization</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\treeStructure\\TypeDefinitionsItem.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\treeStructure</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\instantiations\\DesignInstantiationsEditor.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\instantiations</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\common\\FloatingModeReferenceEditor.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\common</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\memoryMaps\\RemapModeReferenceEditor.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\memoryMaps</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\common\\ComponentInstanceEditor\\PowerDomainLinkEditor.cpp\">\r\n      <Filter>Source Files\\editors\\common\\ComponentInstanceEditor</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\common\\ComponentInstanceEditor\\PowerDomainLinkModel.cpp\">\r\n      <Filter>Source Files\\editors\\common\\ComponentInstanceEditor</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\common\\ComponentInstanceEditor\\PowerDomainLinkDelegate.cpp\">\r\n      <Filter>Source Files\\editors\\common\\ComponentInstanceEditor</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\treeStructure\\WirePortsItem.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\treeStructure</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\treeStructure\\TransactionalPortsItem.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\treeStructure</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\ports\\TypedPortEditor.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\ports</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\ports\\WirePortsEditorFactory.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\ports</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\ports\\TransactionalPortsEditorFactory.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\ports</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\ports\\PortSummaryModel.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\ports</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\ports\\PortSummaryDelegate.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\ports</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\ports\\PortSummaryEditorFactory.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\ports</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\ports\\PortSummaryView.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\ports</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"library\\VLNVDialer\\RevisionGroup.cpp\">\r\n      <Filter>Source Files\\library\\VLNVDialer</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\ports\\TypedPortsView.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\ports</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"common\\widgets\\GroupBoxWithAlertSign\\StyleGroupBoxWithAlertSign.cpp\">\r\n      <Filter>Source Files\\common\\widgets\\GroupBoxWithAlertSign</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"common\\widgets\\GroupBoxWithAlertSign\\StyleOptionGroupBoxWithAlertSign.cpp\">\r\n      <Filter>Source Files\\common\\widgets\\GroupBoxWithAlertSign</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"common\\widgets\\GroupBoxWithAlertSign\\GroupBoxWithAlertSign.cpp\">\r\n      <Filter>Source Files\\common\\widgets\\GroupBoxWithAlertSign</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\BusDefinitionEditor\\BusDefinitionParameterReferenceTree.cpp\">\r\n      <Filter>Source Files\\editors\\BusDefinitionEditor</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\AbstractionDefinitionEditor\\AbsDefParameterReferenceCounter.cpp\">\r\n      <Filter>Source Files\\editors\\AbstractionDefinitionEditor</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\AbstractionDefinitionEditor\\AbsDefParameterReferenceTree.cpp\">\r\n      <Filter>Source Files\\editors\\AbstractionDefinitionEditor</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\ports\\PortsImportSummaryEditor.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\ports</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\InterconnectGenerator\\InterconnectGeneratorDialog.cpp\">\r\n      <Filter>Source Files\\editors\\InterconnectGenerator</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"common\\widgets\\EnumCollectionEditor\\InterfaceEnumEditor.cpp\">\r\n      <Filter>Source Files\\common\\widgets\\EnumCollectionEditor</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"common\\widgets\\instanceWidgets\\InstanceWidgets.cpp\">\r\n      <Filter>Source Files\\common\\widgets\\instanceWidgets</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\InterconnectGenerator\\InterconnectDataModel.cpp\">\r\n      <Filter>Source Files\\editors\\InterconnectGenerator</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\InterconnectGenerator\\InterconnectAddressHelper.cpp\">\r\n      <Filter>Source Files\\editors\\InterconnectGenerator</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\InterconnectGenerator\\InstanceInterfacesEditor.cpp\">\r\n      <Filter>Source Files\\editors\\InterconnectGenerator</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"editors\\ComponentEditor\\parameters\\LockableParametersModel.cpp\">\r\n      <Filter>Source Files\\editors\\ComponentEditor\\parameters</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"Plugins\\PluginSystem\\GeneratorPlugin\\AddToFilesetWidget.cpp\">\r\n      <Filter>Source Files\\Plugins\\common</Filter>\r\n    </ClCompile>\r\n  </ItemGroup>\r\n  <ItemGroup>\r\n    <CustomBuild Include=\"common\\layouts\\HCollisionLayout.inl\">\r\n      <Filter>Source Files\\common\\layouts</Filter>\r\n    </CustomBuild>\r\n    <CustomBuild Include=\"common\\layouts\\HStackedLayout.inl\">\r\n      <Filter>Source Files\\common\\layouts</Filter>\r\n    </CustomBuild>\r\n    <CustomBuild Include=\"common\\layouts\\VCollisionLayout.inl\">\r\n      <Filter>Source Files\\common\\layouts</Filter>\r\n    </CustomBuild>\r\n    <CustomBuild Include=\"common\\layouts\\VStackedLayout.inl\">\r\n      <Filter>Source Files\\common\\layouts</Filter>\r\n    </CustomBuild>\r\n    <CustomBuild Include=\"common\\layouts\\VStaticLayout.inl\">\r\n      <Filter>Source Files\\common\\layouts</Filter>\r\n    </CustomBuild>\r\n    <CustomBuild Include=\"version.h\">\r\n      <Filter>Header Files</Filter>\r\n    </CustomBuild>\r\n    <QtRcc Include=\"kactus.qrc\">\r\n      <Filter>Resource Files</Filter>\r\n    </QtRcc>\r\n    <CustomBuild Include=\"Help\\kactus2help.qhcp\">\r\n      <Filter>Help Files</Filter>\r\n    </CustomBuild>\r\n    <CustomBuild Include=\"Help\\kactus2help.qhp\">\r\n      <Filter>Help Files</Filter>\r\n    </CustomBuild>\r\n    <CustomBuild Include=\"Kactus2.pri\" />\r\n    <CustomBuild Include=\"Kactus2.pro\" />\r\n    <QtMoc Include=\"common\\delegates\\ComboDelegate\\combodelegate.h\">\r\n      <Filter>Header Files\\common\\delegates\\ComboDelegate</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"common\\delegates\\LineEditDelegate\\lineeditdelegate.h\">\r\n      <Filter>Header Files\\common\\delegates\\LineEditDelegate</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"common\\dialogs\\comboSelector\\comboselector.h\">\r\n      <Filter>Header Files\\common\\dialogs\\comboSelector</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"common\\dialogs\\createConfigurationDialog\\createconfigurationdialog.h\">\r\n      <Filter>Header Files\\common\\dialogs\\createConfigurationDialog</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"common\\dialogs\\LibrarySettingsDialog\\LibrarySettingsDialog.h\">\r\n      <Filter>Header Files\\common\\dialogs\\LibrarySettingsDialog</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"common\\dialogs\\NewDesignDialog\\NewDesignDialog.h\">\r\n      <Filter>Header Files\\common\\dialogs\\NewDesignDialog</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"common\\dialogs\\newObjectDialog\\newobjectdialog.h\">\r\n      <Filter>Header Files\\common\\dialogs\\newObjectDialog</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"common\\dialogs\\propertyPageDialog\\PropertyPageDialog.h\">\r\n      <Filter>Header Files\\common\\dialogs\\propertyPageDialog</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"common\\dialogs\\propertyPageDialog\\PropertyPageView.h\">\r\n      <Filter>Header Files\\common\\dialogs\\propertyPageDialog</Filter>\r\n    </QtMoc>\r\n    <CustomBuild Include=\"common\\graphicsItems\\CommonGraphicsUndoCommands.h\">\r\n      <Filter>Header Files\\common\\graphicsItems</Filter>\r\n    </CustomBuild>\r\n    <QtMoc Include=\"common\\graphicsItems\\ComponentItem.h\">\r\n      <Filter>Header Files\\common\\graphicsItems</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"common\\graphicsItems\\ConnectionEndpoint.h\">\r\n      <Filter>Header Files\\common\\graphicsItems</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"common\\graphicsItems\\expandableitem.h\">\r\n      <Filter>Header Files\\common\\graphicsItems</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"common\\graphicsItems\\GraphicsColumn.h\">\r\n      <Filter>Header Files\\common\\graphicsItems</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"common\\graphicsItems\\GraphicsColumnLayout.h\">\r\n      <Filter>Header Files\\common\\graphicsItems</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"common\\graphicsItems\\GraphicsConnection.h\">\r\n      <Filter>Header Files\\common\\graphicsItems</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"common\\graphicsItems\\graphicsexpandcollapseitem.h\">\r\n      <Filter>Header Files\\common\\graphicsItems</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"common\\graphicsItems\\GraphicsLineEdit.h\">\r\n      <Filter>Header Files\\common\\graphicsItems</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"common\\graphicsItems\\GraphicsRectButton.h\">\r\n      <Filter>Header Files\\common\\graphicsItems</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"common\\graphicsItems\\visualizeritem.h\">\r\n      <Filter>Header Files\\common\\graphicsItems</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"common\\validators\\LibraryPathValidator\\librarypathvalidator.h\">\r\n      <Filter>Header Files\\common\\validators\\LibraryPathValidator</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"common\\views\\EditableListView\\editablelistview.h\">\r\n      <Filter>Header Files\\common\\views\\EditableListView</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"common\\views\\EditableTableView\\editabletableview.h\">\r\n      <Filter>Header Files\\common\\views\\EditableTableView</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"common\\widgets\\accessComboBox\\accesscombobox.h\">\r\n      <Filter>Header Files\\common\\widgets\\accessComboBox</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"common\\widgets\\assistedLineEdit\\AssistedLineEdit.h\">\r\n      <Filter>Header Files\\common\\widgets\\assistedLineEdit</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"common\\widgets\\assistedTextEdit\\AssistedTextEdit.h\">\r\n      <Filter>Header Files\\common\\widgets\\assistedTextEdit</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"common\\widgets\\assistedTextEdit\\ToolTipHintWidget.h\">\r\n      <Filter>Header Files\\common\\widgets\\assistedTextEdit</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"common\\widgets\\booleanComboBox\\booleancombobox.h\">\r\n      <Filter>Header Files\\common\\widgets\\booleanComboBox</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"common\\widgets\\colorBox\\ColorBox.h\">\r\n      <Filter>Header Files\\common\\widgets\\colorBox</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"common\\widgets\\componentPreviewBox\\ComponentPreviewBox.h\">\r\n      <Filter>Header Files\\common\\widgets\\componentPreviewBox</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"common\\widgets\\interfaceModeSelector\\interfacemodeselector.h\">\r\n      <Filter>Header Files\\common\\widgets\\interfaceModeSelector</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"common\\widgets\\interfaceSelector\\interfaceselector.h\">\r\n      <Filter>Header Files\\common\\widgets\\interfaceSelector</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"common\\widgets\\kactusAttributeEditor\\KactusAttributeEditor.h\">\r\n      <Filter>Header Files\\common\\widgets\\kactusAttributeEditor</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"common\\widgets\\LineEditEx\\LineEditEx.h\">\r\n      <Filter>Header Files\\common\\widgets\\LineEditEx</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"common\\widgets\\listManager\\dirlistmanager.h\">\r\n      <Filter>Header Files\\common\\widgets\\listManager</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"common\\widgets\\listManager\\listeditor.h\">\r\n      <Filter>Header Files\\common\\widgets\\listManager</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"common\\widgets\\listManager\\listmanager.h\">\r\n      <Filter>Header Files\\common\\widgets\\listManager</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"common\\widgets\\listManager\\listmanagermodel.h\">\r\n      <Filter>Header Files\\common\\widgets\\listManager</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"common\\widgets\\modWriteComboBox\\modwritecombobox.h\">\r\n      <Filter>Header Files\\common\\widgets\\modWriteComboBox</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"common\\widgets\\nameGroupBox\\namegroupbox.h\">\r\n      <Filter>Header Files\\common\\widgets\\nameGroupBox</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"common\\widgets\\nameGroupEditor\\namegroupeditor.h\">\r\n      <Filter>Header Files\\common\\widgets\\nameGroupEditor</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"common\\widgets\\readActionComboBox\\readactioncombobox.h\">\r\n      <Filter>Header Files\\common\\widgets\\readActionComboBox</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"common\\widgets\\SnippetTextEdit\\SnippetTextEdit.h\">\r\n      <Filter>Header Files\\common\\widgets\\SnippetTextEdit</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"common\\widgets\\summaryLabel\\summarylabel.h\">\r\n      <Filter>Header Files\\common\\widgets\\summaryLabel</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"common\\widgets\\tabDocument\\TabDocument.h\">\r\n      <Filter>Header Files\\common\\widgets\\tabDocument</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"common\\widgets\\testConstraintComboBox\\testconstraintcombobox.h\">\r\n      <Filter>Header Files\\common\\widgets\\testConstraintComboBox</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"common\\widgets\\usageComboBox\\usagecombobox.h\">\r\n      <Filter>Header Files\\common\\widgets\\usageComboBox</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"common\\widgets\\vlnvDisplayer\\vlnvdisplayer.h\">\r\n      <Filter>Header Files\\common\\widgets\\vlnvDisplayer</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"common\\widgets\\vlnvEditor\\vlnveditor.h\">\r\n      <Filter>Header Files\\common\\widgets\\vlnvEditor</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"common\\GenericEditProvider.h\">\r\n      <Filter>Header Files\\common</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"common\\IEditProvider.h\">\r\n      <Filter>Header Files\\common</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"mainwindow\\mainwindow.h\">\r\n      <Filter>Header Files\\mainwindow</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"settings\\CodeEditorSettingsPage.h\">\r\n      <Filter>Header Files\\settings</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"settings\\GeneralSettingsPage.h\">\r\n      <Filter>Header Files\\settings</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"settings\\NamingPolicySettingsPage.h\">\r\n      <Filter>Header Files\\settings</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"settings\\SettingsDialog.h\">\r\n      <Filter>Header Files\\settings</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"mainwindow\\DeleteWorkspaceDialog.h\">\r\n      <Filter>Header Files\\mainwindow</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"mainwindow\\NewWorkspaceDialog.h\">\r\n      <Filter>Header Files\\mainwindow</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"common\\dialogs\\LibrarySettingsDialog\\librarysettingsdelegate.h\">\r\n      <Filter>Header Files\\common\\dialogs\\LibrarySettingsDialog</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"settings\\PluginSettingsPage.h\">\r\n      <Filter>Header Files\\settings</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"settings\\FileTypeSettingsPage.h\">\r\n      <Filter>Header Files\\settings</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"settings\\FileTypesModel.h\">\r\n      <Filter>Header Files\\settings</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"settings\\FileTypesDelegate.h\">\r\n      <Filter>Header Files\\settings</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"common\\widgets\\viewSelector\\viewselector.h\">\r\n      <Filter>Header Files\\common\\widgets\\viewSelector</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"common\\widgets\\fileTypeSelector\\filetypeselector.h\">\r\n      <Filter>Header Files\\common\\widgets\\fileTypeSelector</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"settings\\filetypesview.h\">\r\n      <Filter>Header Files\\settings</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"common\\widgets\\listManager\\dirlistmanagermodel.h\">\r\n      <Filter>Header Files\\common\\widgets\\listManager</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"settings\\k2envvariablesettingspage.h\">\r\n      <Filter>Header Files\\settings</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"settings\\k2envvarmodel.h\">\r\n      <Filter>Header Files\\settings</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"common\\widgets\\FileSelector\\fileselector.h\">\r\n      <Filter>Header Files\\common\\widgets\\FileSelector</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"common\\widgets\\LibrarySelectorWidget\\LibrarySelectorWidget.h\">\r\n      <Filter>Header Files\\common\\widgets\\LibrarySelectorWidget</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"common\\widgets\\LibrarySelectorWidget\\LibraryPathEditor\\librarypatheditor.h\">\r\n      <Filter>Header Files\\common\\widgets\\LibrarySelectorWidget\\LibraryPathEditor</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"common\\widgets\\LibrarySelectorWidget\\LibraryPathSelector\\librarypathselector.h\">\r\n      <Filter>Header Files\\common\\widgets\\LibrarySelectorWidget\\LibraryPathSelector</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"common\\widgets\\DirectoryListSelector\\DirectoryListSelector.h\">\r\n      <Filter>Header Files\\common\\widgets\\DirectoryListSelector</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"wizards\\ComponentWizard\\ComponentWizardGeneralInfoPage.h\">\r\n      <Filter>Header Files\\wizards\\ComponentWizard</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"Help\\HelpSystem\\ContextHelpBrowser.h\">\r\n      <Filter>Header Files\\Help\\HelpSystem</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"Help\\HelpSystem\\HelpSearchWidget.h\">\r\n      <Filter>Header Files\\Help\\HelpSystem</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"wizards\\BusInterfaceWizard\\BusInterfaceWizardConclusionPage.h\">\r\n      <Filter>Header Files\\wizards\\BusInterfaceWizard</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"wizards\\BusInterfaceWizard\\BusInterfaceWizardIntroPage.h\">\r\n      <Filter>Header Files\\wizards\\BusInterfaceWizard</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"wizards\\BusInterfaceWizard\\BusInterfaceWizardPortMapPage.h\">\r\n      <Filter>Header Files\\wizards\\BusInterfaceWizard</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"kactusGenerators\\DocumentGenerator\\documentgenerator.h\">\r\n      <Filter>Header Files\\kactusGenerators\\DocumentGenerator</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"mainwindow\\MessageConsole\\messageconsole.h\">\r\n      <Filter>Header Files\\mainwindow\\MessageConsole</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"mainwindow\\Ribbon\\RibbonGroup.h\">\r\n      <Filter>Header Files\\mainwindow\\Ribbon</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"mainwindow\\NewPages\\NewApiDefinitionPage.h\">\r\n      <Filter>Header Files\\mainwindow\\NewPages</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"mainwindow\\NewPages\\NewComDefinitionPage.h\">\r\n      <Filter>Header Files\\mainwindow\\NewPages</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"mainwindow\\NewPages\\NewComponentPage.h\">\r\n      <Filter>Header Files\\mainwindow\\NewPages</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"mainwindow\\NewPages\\NewDesignPage.h\">\r\n      <Filter>Header Files\\mainwindow\\NewPages</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"mainwindow\\NewPages\\NewPage.h\">\r\n      <Filter>Header Files\\mainwindow\\NewPages</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"mainwindow\\NewPages\\NewSWComponentPage.h\">\r\n      <Filter>Header Files\\mainwindow\\NewPages</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"mainwindow\\NewPages\\NewSWDesignPage.h\">\r\n      <Filter>Header Files\\mainwindow\\NewPages</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"mainwindow\\NewPages\\NewSystemPage.h\">\r\n      <Filter>Header Files\\mainwindow\\NewPages</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ApiDefinitionEditor\\ApiDefinitionEditor.h\">\r\n      <Filter>Header Files\\editors\\ApiDefinitionEditor</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ApiDefinitionEditor\\ApiFunctionEditor.h\">\r\n      <Filter>Header Files\\editors\\ApiDefinitionEditor</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ApiDefinitionEditor\\ApiFunctionModel.h\">\r\n      <Filter>Header Files\\editors\\ApiDefinitionEditor</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ApiDefinitionEditor\\ApiFunctionParameterDelegate.h\">\r\n      <Filter>Header Files\\editors\\ApiDefinitionEditor</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ApiDefinitionEditor\\ApiFunctionParameterModel.h\">\r\n      <Filter>Header Files\\editors\\ApiDefinitionEditor</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComDefinitionEditor\\ComDefinitionEditor.h\">\r\n      <Filter>Header Files\\editors\\ComDefinitionEditor</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComDefinitionEditor\\ComPropertyDelegate.h\">\r\n      <Filter>Header Files\\editors\\ComDefinitionEditor</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComDefinitionEditor\\ComPropertyEditor.h\">\r\n      <Filter>Header Files\\editors\\ComDefinitionEditor</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComDefinitionEditor\\ComPropertyModel.h\">\r\n      <Filter>Header Files\\editors\\ComDefinitionEditor</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\addressSpaces\\addressspaceeditor.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\addressSpaces</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\addressSpaces\\addressspacegeneraleditor.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\addressSpaces</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\addressSpaces\\addressspacesdelegate.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\addressSpaces</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\addressSpaces\\addressspaceseditor.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\addressSpaces</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\addressSpaces\\addressspacesmodel.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\addressSpaces</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\addressSpaces\\segmenteditor.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\addressSpaces</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\addressSpaces\\segmentsmodel.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\addressSpaces</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\addressSpaces\\addressSpaceVisualizer\\AddressSpaceConflictedItem.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\addressSpaces\\AddressSpaceVisualizer</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\addressSpaces\\addressSpaceVisualizer\\addressspacegapitem.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\addressSpaces\\AddressSpaceVisualizer</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\addressSpaces\\addressSpaceVisualizer\\addressspacescene.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\addressSpaces\\AddressSpaceVisualizer</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\addressSpaces\\addressSpaceVisualizer\\addressspacevisualizationitem.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\addressSpaces\\AddressSpaceVisualizer</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\addressSpaces\\addressSpaceVisualizer\\addressspacevisualizer.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\addressSpaces\\AddressSpaceVisualizer</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\addressSpaces\\addressSpaceVisualizer\\localaddrblockgraphitem.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\addressSpaces\\AddressSpaceVisualizer</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\addressSpaces\\addressSpaceVisualizer\\segmentgraphitem.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\addressSpaces\\AddressSpaceVisualizer</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\addressSpaces\\localMemoryMap\\localmemorymapeditor.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\addressSpaces\\localMemoryMap</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\addressSpaces\\localMemoryMap\\localmemorymapgraphitem.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\addressSpaces\\localMemoryMap</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\busInterfaces\\portmaps\\PortListSortProxyModel.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\busInterfaces\\portmaps</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\busInterfaces\\businterfacesdelegate.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\busInterfaces</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\busInterfaces\\businterfaceseditor.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\busInterfaces</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\busInterfaces\\businterfacesmodel.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\busInterfaces</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\channels\\channelsdelegate.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\channels</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\channels\\channelseditor.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\channels</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\channels\\channelsmodel.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\channels</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\cpus\\cpusdelegate.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\cpus</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\cpus\\cpuseditor.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\cpus</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\cpus\\cpusmodel.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\cpus</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\fileBuilders\\filebuildersdelegate.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\fileBuilders</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\fileBuilders\\filebuilderseditor.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\fileBuilders</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\fileBuilders\\filebuildersmodel.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\fileBuilders</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\fileSet\\fileseteditor.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\fileSet</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\fileSet\\filesetsdelegate.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\fileSet</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\fileSet\\filesetseditor.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\fileSet</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\fileSet\\filesetsmodel.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\fileSet</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\fileSet\\groupmanager.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\fileSet</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\fileSet\\groupmanagerdelegate.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\fileSet</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\fileSet\\dependencyAnalysis\\FileDependencyDelegate.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\fileSet\\dependencyAnalysis</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\fileSet\\dependencyAnalysis\\FileDependencyEditor.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\fileSet\\dependencyAnalysis</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\fileSet\\dependencyAnalysis\\FileDependencyGraphWidget.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\fileSet\\dependencyAnalysis</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\fileSet\\dependencyAnalysis\\FileDependencyGraphView.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\fileSet\\dependencyAnalysis</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\fileSet\\dependencyAnalysis\\FileDependencyInfoWidget.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\fileSet\\dependencyAnalysis</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\fileSet\\dependencyAnalysis\\FileDependencyItem.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\fileSet\\dependencyAnalysis</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\fileSet\\dependencyAnalysis\\FileDependencyModel.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\fileSet\\dependencyAnalysis</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\fileSet\\dependencyAnalysis\\FileDependencySourceEditor.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\fileSet\\dependencyAnalysis</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\fileSet\\file\\filegeneraleditor.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\fileSet\\file</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\fileSet\\file\\filenameeditor.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\fileSet\\file</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\fileSet\\file\\filesdelegate.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\fileSet\\file</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\fileSet\\file\\fileseditor.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\fileSet\\file</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\fileSet\\file\\filesmodel.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\fileSet\\file</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\fileSet\\file\\filesview.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\fileSet\\file</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\fileSet\\file\\filetypeeditor.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\fileSet\\file</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\fileSet\\file\\filetypeeditordelegate.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\fileSet\\file</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\fileSet\\file\\filebuildcommand.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\fileSet\\file</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\fileSet\\file\\filedefinemodel.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\fileSet\\file</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\fileSet\\file\\filedefineview.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\fileSet\\file</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\fileSet\\file\\fileeditor.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\fileSet\\file</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\general\\generaleditor.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\general</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\memoryMaps\\memorymapdelegate.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\memoryMaps</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\memoryMaps\\memorymapeditor.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\memoryMaps</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\memoryMaps\\memorymapmodel.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\memoryMaps</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\memoryMaps\\memorymapsdelegate.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\memoryMaps</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\memoryMaps\\memorymapseditor.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\memoryMaps</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\memoryMaps\\memorymapsmodel.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\memoryMaps</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\memoryMaps\\registerdelegate.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\memoryMaps</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\memoryMaps\\registereditor.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\memoryMaps</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\memoryMaps\\registertablemodel.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\memoryMaps</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\memoryMaps\\addressblockdelegate.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\memoryMaps</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\memoryMaps\\addressblockeditor.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\memoryMaps</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\memoryMaps\\addressblockmodel.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\memoryMaps</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\memoryMaps\\enumeratedvaluedelegate.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\memoryMaps</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\memoryMaps\\enumeratedvaluemodel.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\memoryMaps</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\memoryMaps\\fieldeditor.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\memoryMaps</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\memoryMaps\\memoryMapsVisualizer\\addressblockgraphitem.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\memoryMaps\\memoryMapsVisualizer</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\memoryMaps\\memoryMapsVisualizer\\fieldgraphitem.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\memoryMaps\\memoryMapsVisualizer</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\memoryMaps\\memoryMapsVisualizer\\memorymapgraphitem.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\memoryMaps\\memoryMapsVisualizer</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\memoryMaps\\memoryMapsVisualizer\\memorymapscene.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\memoryMaps\\memoryMapsVisualizer</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\memoryMaps\\memoryMapsVisualizer\\memorymapsvisualizer.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\memoryMaps\\memoryMapsVisualizer</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\memoryMaps\\memoryMapsVisualizer\\memorymapview.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\memoryMaps\\memoryMapsVisualizer</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\memoryMaps\\memoryMapsVisualizer\\registergraphitem.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\memoryMaps\\memoryMapsVisualizer</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\otherClockDrivers\\otherclockdriversmodel.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\otherClockDrivers</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\otherClockDrivers\\clockdriversdelegate.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\otherClockDrivers</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\otherClockDrivers\\otherclockdriverseditor.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\otherClockDrivers</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\parameters\\parameterseditor.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\parameters</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\ports\\portsdelegate.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\ports</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\ports\\portseditor.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\ports</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\ports\\portsmodel.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\ports</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\ports\\PortsView.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\ports</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\software\\PropertyValueModel.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\software</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\software\\SWPropertiesEditor.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\software</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\software\\PropertyValueDelegate.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\software</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\software\\PropertyValueEditor.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\software</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\software\\apiInterface\\apiinterfaceseditor.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\software\\apiInterface</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\software\\apiInterface\\apiinterfacesmodel.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\software\\apiInterface</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\software\\apiInterface\\ApiInterfaceEditor.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\software\\apiInterface</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\software\\apiInterface\\apiinterfacesdelegate.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\software\\apiInterface</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\software\\comInterface\\cominterfaceseditor.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\software\\comInterface</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\software\\comInterface\\cominterfacesmodel.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\software\\comInterface</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\software\\comInterface\\ComInterfaceEditor.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\software\\comInterface</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\software\\comInterface\\cominterfacesdelegate.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\software\\comInterface</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\software\\systemView\\SystemViewEditor.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\software\\systemView</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\software\\systemView\\SystemViewsEditor.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\software\\systemView</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\software\\systemView\\SystemViewsModel.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\software\\systemView</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\treeStructure\\componenteditorrootitem.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\treeStructure</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\treeStructure\\componenteditorswpropertiesitem.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\treeStructure</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\treeStructure\\ComponentEditorSystemViewItem.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\treeStructure</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\treeStructure\\ComponentEditorSystemViewsItem.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\treeStructure</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\treeStructure\\componenteditortreemodel.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\treeStructure</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\treeStructure\\ComponentEditorTreeSortProxyModel.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\treeStructure</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\treeStructure\\componenteditorviewitem.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\treeStructure</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\treeStructure\\componenteditorviewsitem.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\treeStructure</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\treeStructure\\componenttreeview.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\treeStructure</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\treeStructure\\componenteditoraddrblockitem.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\treeStructure</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\treeStructure\\componenteditoraddrspaceitem.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\treeStructure</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\treeStructure\\componenteditoraddrspacesitem.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\treeStructure</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\treeStructure\\componenteditorapiinterfaceitem.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\treeStructure</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\treeStructure\\componenteditorapiinterfacesitem.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\treeStructure</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\treeStructure\\componenteditorbusinterfaceitem.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\treeStructure</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\treeStructure\\componenteditorbusinterfacesitem.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\treeStructure</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\treeStructure\\componenteditorchannelsitem.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\treeStructure</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\treeStructure\\componenteditorcominterfaceitem.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\treeStructure</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\treeStructure\\componenteditorcominterfacesitem.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\treeStructure</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\treeStructure\\componenteditorcpusitem.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\treeStructure</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\treeStructure\\componenteditorfielditem.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\treeStructure</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\treeStructure\\componenteditorfileitem.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\treeStructure</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\treeStructure\\componenteditorfilesetitem.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\treeStructure</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\treeStructure\\componenteditorfilesetsitem.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\treeStructure</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\treeStructure\\componenteditorgeneralitem.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\treeStructure</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\treeStructure\\componenteditorgroupslot.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\treeStructure</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\treeStructure\\componenteditoritem.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\treeStructure</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\treeStructure\\componenteditormemmapitem.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\treeStructure</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\treeStructure\\componenteditormemmapsitem.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\treeStructure</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\treeStructure\\componenteditorotherclocksitem.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\treeStructure</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\treeStructure\\componenteditorparametersitem.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\treeStructure</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\treeStructure\\componenteditorportsitem.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\treeStructure</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\treeStructure\\componenteditorregisteritem.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\treeStructure</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\views\\vieweditor.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\views</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\views\\viewseditor.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\views</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\views\\viewsmodel.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\views</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\views\\envidentifiereditor.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\views</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\views\\envidentifiersmodel.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\views</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\visualization\\fieldgapitem.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\visualization</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\visualization\\memorygapitem.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\visualization</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\visualization\\memoryvisualizationitem.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\visualization</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\itemeditor.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\itemvisualizer.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\CSourceEditor\\CSourceHighlighter.h\">\r\n      <Filter>Header Files\\editors\\CSourceEditor</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\CSourceEditor\\CSourceTextEdit.h\">\r\n      <Filter>Header Files\\editors\\CSourceEditor</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\CSourceEditor\\CSourceWidget.h\">\r\n      <Filter>Header Files\\editors\\CSourceEditor</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\componenteditor.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"settings\\SettingsPage.h\">\r\n      <Filter>Header Files\\settings</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"wizards\\ComponentWizard\\ComponentWizardImportPage.h\">\r\n      <Filter>Header Files\\wizards\\ComponentWizard</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"wizards\\ComponentWizard\\ComponentWizard.h\">\r\n      <Filter>Header Files\\wizards\\ComponentWizard</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"wizards\\ComponentWizard\\ComponentWizardViewsPage.h\">\r\n      <Filter>Header Files\\wizards\\ComponentWizard</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"wizards\\ComponentWizard\\ViewListModel.h\">\r\n      <Filter>Header Files\\wizards\\ComponentWizard</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"wizards\\ImportWizard\\ImportWizard.h\">\r\n      <Filter>Header Files\\wizards\\ImportWizard</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"wizards\\ImportWizard\\ImportWizardImportPage.h\">\r\n      <Filter>Header Files\\wizards\\ImportWizard</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"wizards\\ComponentWizard\\ComponentWizardConclusionPage.h\">\r\n      <Filter>Header Files\\wizards\\ComponentWizard</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"wizards\\common\\ComponentDiffWidget\\ComponentDiffWidget.h\">\r\n      <Filter>Header Files\\wizards\\common\\ComponentDiffWidget</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\treeStructure\\ComponentEditorChoicesItem.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\treeStructure</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\choices\\ChoicesEditor.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\choices</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\choices\\ChoicesModel.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\choices</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\choices\\EnumerationModel.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\choices</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\parameters\\parametersmodel.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\parameters</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\parameters\\ParameterDelegate.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\parameters</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"settings\\ComponentEditorSettingsPage.h\">\r\n      <Filter>Header Files\\settings</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\common\\AbstractParameterModel.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\common</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"mainwindow\\Ribbon\\Ribbon.h\">\r\n      <Filter>Header Files\\mainwindow\\Ribbon</Filter>\r\n    </QtMoc>\r\n    <CustomBuild Include=\"editors\\ComponentEditor\\parameters\\ParameterEditorHeaderView.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\parameters</Filter>\r\n    </CustomBuild>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\parameterReferenceTree\\ParameterReferenceTree.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\parameterReferenceTree</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\parameters\\ComponentParameterModel.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\parameters</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\common\\ExpressionEditor.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\common</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\common\\ExpressionDelegate.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\common</Filter>\r\n    </QtMoc>\r\n    <CustomBuild Include=\"editors\\ComponentEditor\\common\\ParameterizableTable.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\common</Filter>\r\n    </CustomBuild>\r\n    <QtMoc Include=\"mainwindow\\DrawingBoard\\DrawingBoard.h\">\r\n      <Filter>Header Files\\mainwindow\\DrawingBoard</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\parameters\\Array\\ArrayDelegate.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\parameters\\Array</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\parameters\\Array\\ParameterArrayModel.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\parameters\\Array</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\parameters\\Array\\ArrayView.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\parameters\\Array</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\parameters\\ChoiceCreatorDelegate.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\parameters</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\common\\ReferenceSelector\\ReferenceSelector.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\common\\ReferenceSelector</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\common\\ReferencingTableModel.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\common</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\treeStructure\\SingleRemapStateItem.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\treeStructure</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\treeStructure\\RemapStatesItem.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\treeStructure</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\remapStates\\RemapStatesEditor.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\remapStates</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\remapStates\\RemapStatesModel.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\remapStates</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\remapStates\\SingleRemapStateEditor.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\remapStates</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\remapStates\\RemapConditionModel.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\remapStates</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\remapStates\\RemapConditionEditor.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\remapStates</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\remapStates\\RemapConditionDelegate.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\remapStates</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\memoryMaps\\SingleMemoryMapEditor.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\memoryMaps</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\treeStructure\\MemoryRemapItem.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\treeStructure</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\memoryMaps\\MemoryMapsView.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\memoryMaps</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\memoryMaps\\SingleAddressBlockEditor.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\memoryMaps</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\memoryMaps\\SingleRegisterEditor.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\memoryMaps</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\memoryMaps\\SingleFieldEditor.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\memoryMaps</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\memoryMaps\\WriteValueConstraintComboBox.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\memoryMaps</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\addressSpaces\\SegmentDelegate.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\addressSpaces</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ConfigurationTools\\ViewConfigurerDelegate.h\">\r\n      <Filter>Header Files\\editors\\ConfigurationTools</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ConfigurationTools\\ViewConfigurer.h\">\r\n      <Filter>Header Files\\editors\\ConfigurationTools</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"mainwindow\\SaveHierarchy\\SaveHierarchyDialog.h\">\r\n      <Filter>Header Files\\mainwindow\\SaveHierarchy</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"mainwindow\\SaveHierarchy\\HierarchicalSaveBuildStrategy.h\">\r\n      <Filter>Header Files\\mainwindow\\SaveHierarchy</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\memoryMaps\\ExpressionProxyModel.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\memoryMaps</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\common\\MultilineDescriptionDelegate.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\common</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\views\\ViewsDelegate.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\views</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\ports\\PortTagEditorDelegate.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\ports</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"wizards\\BusInterfaceWizard\\BusInterfaceWizardGeneralOptionsPage.h\">\r\n      <Filter>Header Files\\wizards\\BusInterfaceWizard</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\treeStructure\\InstantiationsItem.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\treeStructure</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\treeStructure\\ComponentInstantiationsItem.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\treeStructure</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\treeStructure\\DesignConfigurationInstantiationsItem.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\treeStructure</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\treeStructure\\DesignInstantiationsItem.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\treeStructure</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\treeStructure\\SingleComponentInstantiationItem.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\treeStructure</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\instantiations\\DesignConfigurationInstantiationEditor.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\instantiations</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\treeStructure\\SingleDesignConfigurationInstantiationItem.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\treeStructure</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\instantiations\\DesignInstantiationEditor.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\instantiations</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\treeStructure\\SingleDesignInstantiationItem.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\treeStructure</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\instantiations\\ComponentInstantiationsEditor.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\instantiations</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\instantiations\\ComponentInstantiationsModel.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\instantiations</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\instantiations\\InstantiationsEditor.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\instantiations</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\instantiations\\DesignInstantiationsEditor.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\instantiations</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\instantiations\\DesignInstantiationsModel.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\instantiations</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\instantiations\\DesignConfigurationInstantiationsModel.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\instantiations</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\instantiations\\DesignConfigurationInstantiationsEditor.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\instantiations</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\instantiations\\DesignInstantiationsDelegate.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\instantiations</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\instantiations\\filesetrefeditordelegate.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\instantiations</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\instantiations\\filesetrefmodel.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\instantiations</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\instantiations\\filesetrefeditor.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\instantiations</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\instantiations\\ModuleParameterModel.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\instantiations</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\instantiations\\ModuleParameterDelegate.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\instantiations</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\instantiations\\ComponentInstantiationEditor.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\instantiations</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\instantiations\\ModuleParameterEditor.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\instantiations</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\remapStates\\ValueOrIndexedValueEditor.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\remapStates</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\busInterfaces\\portmaps\\PortMappingTableView.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\busInterfaces\\portmaps</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\busInterfaces\\portmaps\\PhysicalPortMappingTableView.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\busInterfaces\\portmaps</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\busInterfaces\\portmaps\\PortMappingTableModel.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\busInterfaces\\portmaps</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\busInterfaces\\portmaps\\PhysicalPortMappingTableModel.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\busInterfaces\\portmaps</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\busInterfaces\\portmaps\\PortMapAutoConnector.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\busInterfaces\\portmaps</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"mainwindow\\NewPages\\NewBusDefinitionPage.h\">\r\n      <Filter>Header Files\\mainwindow\\NewPages</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\BusDefinitionEditor\\busdefgroup.h\">\r\n      <Filter>Header Files\\editors\\BusDefinitionEditor</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\BusDefinitionEditor\\BusDefinitionEditor.h\">\r\n      <Filter>Header Files\\editors\\BusDefinitionEditor</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"wizards\\BusInterfaceWizard\\BusInterfaceWizardBusDefinitionPage.h\">\r\n      <Filter>Header Files\\wizards\\BusInterfaceWizard</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"wizards\\BusInterfaceWizard\\BusInterfaceWizard.h\">\r\n      <Filter>Header Files\\wizards\\BusInterfaceWizard</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"common\\widgets\\ParameterGroupBox\\parametergroupbox.h\">\r\n      <Filter>Header Files\\common\\widgets\\ParameterGroupBox</Filter>\r\n    </QtMoc>\r\n    <CustomBuild Include=\"editors\\ComponentEditor\\busInterfaces\\portmaps\\JaroWinklerAlgorithm.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\busInterfaces\\portmaps</Filter>\r\n    </CustomBuild>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\busInterfaces\\general\\bridgesdelegate.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\busInterfaces\\general</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\busInterfaces\\general\\bridgeseditor.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\busInterfaces\\general</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\busInterfaces\\general\\bridgesmodel.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\busInterfaces\\general</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\busInterfaces\\general\\busifgeneraldetails.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\busInterfaces\\general</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\busInterfaces\\general\\busifgeneraltab.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\busInterfaces\\general</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\busInterfaces\\general\\interfacemodestack.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\busInterfaces\\general</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\busInterfaces\\portmaps\\BusInterfacePortMapTab.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\busInterfaces\\portmaps</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\busInterfaces\\businterfaceeditor.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\busInterfaces</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"mainwindow\\NewPages\\NewCatalogPage.h\">\r\n      <Filter>Header Files\\mainwindow\\NewPages</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\CatalogEditor\\CatalogEditor.h\">\r\n      <Filter>Header Files\\editors\\CatalogEditor</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\CatalogEditor\\CatalogFileModel.h\">\r\n      <Filter>Header Files\\editors\\CatalogEditor</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\CatalogEditor\\CatalogFileDelegate.h\">\r\n      <Filter>Header Files\\editors\\CatalogEditor</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\CatalogEditor\\CatalogFileFilter.h\">\r\n      <Filter>Header Files\\editors\\CatalogEditor</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\CatalogEditor\\CatalogFileView.h\">\r\n      <Filter>Header Files\\editors\\CatalogEditor</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"Plugins\\common\\LanguageHighlighter.h\">\r\n      <Filter>Header Files\\Plugins\\common</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"library\\LibraryFilter.h\">\r\n      <Filter>Header Files\\library</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"library\\LibraryTreeFilter.h\">\r\n      <Filter>Header Files\\library</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"library\\LibraryTreeWidget.h\">\r\n      <Filter>Header Files\\library</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"library\\LibraryTreeView.h\">\r\n      <Filter>Header Files\\library</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"library\\LibraryErrorModel.h\">\r\n      <Filter>Header Files\\library</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"library\\HierarchyView\\hierarchywidget.h\">\r\n      <Filter>Header Files\\library\\HierarchyView</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"library\\HierarchyView\\hierarchyview.h\">\r\n      <Filter>Header Files\\library\\HierarchyView</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"library\\HierarchyView\\hierarchyfilter.h\">\r\n      <Filter>Header Files\\library\\HierarchyView</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"library\\VLNVDialer\\filterwidget.h\">\r\n      <Filter>Header Files\\library\\VLNVDialer</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"library\\VLNVDialer\\firmnessgroup.h\">\r\n      <Filter>Header Files\\library\\VLNVDialer</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"library\\VLNVDialer\\implementationgroup.h\">\r\n      <Filter>Header Files\\library\\VLNVDialer</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"library\\VLNVDialer\\typegroup.h\">\r\n      <Filter>Header Files\\library\\VLNVDialer</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"library\\VLNVDialer\\vlnvdialer.h\">\r\n      <Filter>Header Files\\library\\VLNVDialer</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"library\\LibraryWidget.h\">\r\n      <Filter>Header Files\\library</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\indirectInterfaces\\IndirectInterfacesEditor.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\indirectInterfaces</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\indirectInterfaces\\IndirectInterfacesModel.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\indirectInterfaces</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\indirectInterfaces\\IndirectInterfacesDelegate.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\indirectInterfaces</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\treeStructure\\ComponentEditorIndirectInterfacesItem.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\treeStructure</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\indirectInterfaces\\SingleIndirectInterfaceEditor.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\indirectInterfaces</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\common\\InstantiationConfigurableElementEditor.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\common</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\parameterReferenceTree\\ComponentParameterReferenceTree.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\parameterReferenceTree</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\parameterReferenceTree\\ParameterReferenceTreeWindow.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\parameterReferenceTree</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\parameters\\ParametersView.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\parameters</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\referenceCounter\\ComponentParameterReferenceCounter.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\referenceCounter</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\ParameterItemEditor.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\treeStructure\\ParameterizableItem.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\treeStructure</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"mainwindow\\DockWidgetHandler.h\">\r\n      <Filter>Header Files\\mainwindow</Filter>\r\n    </QtMoc>\r\n    <CustomBuild Include=\"common\\dialogs\\LibrarySettingsDialog\\LibrarySettingsColumns.h\">\r\n      <Filter>Header Files\\common\\dialogs\\LibrarySettingsDialog</Filter>\r\n    </CustomBuild>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\ports\\PortWireTypeEditor.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\ports</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\ports\\PortWireTypeModel.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\ports</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\ports\\PortWireTypeDelegate.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\ports</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"common\\views\\EditableTreeView\\EditableTreeView.h\">\r\n      <Filter>Header Files\\common\\views\\EditableTreeView</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\ports\\PortWireTypeView.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\ports</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"common\\views\\EditableTreeView\\EditableTreeSortFilter.h\">\r\n      <Filter>Header Files\\common\\views\\EditableTreeView</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\ports\\PortTypeDefinitionEditor.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\ports</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\busInterfaces\\AbstractionTypesEditor.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\busInterfaces</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\busInterfaces\\AbstractionTypesModel.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\busInterfaces</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\busInterfaces\\AbstractionTypesDelegate.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\busInterfaces</Filter>\r\n    </QtMoc>\r\n    <CustomBuild Include=\"common\\graphicsItems\\GraphicsColumnConstants.h\">\r\n      <Filter>Header Files\\common\\graphicsItems</Filter>\r\n    </CustomBuild>\r\n    <QtMoc Include=\"editors\\common\\ComponentInstanceEditor\\ComponentInstanceConfigurableElementsEditor.h\">\r\n      <Filter>Header Files\\editors\\common\\ComponentInstanceEditor</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\common\\ComponentInstanceEditor\\ComponentInstanceConfigurableElementsFilter.h\">\r\n      <Filter>Header Files\\editors\\common\\ComponentInstanceEditor</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\common\\ComponentInstanceEditor\\ComponentInstanceConfigurableElementsModel.h\">\r\n      <Filter>Header Files\\editors\\common\\ComponentInstanceEditor</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\common\\ComponentInstanceEditor\\ConfigurableElementsFilter.h\">\r\n      <Filter>Header Files\\editors\\common\\ComponentInstanceEditor</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\common\\ComponentInstanceEditor\\ConfigurableElementsModel.h\">\r\n      <Filter>Header Files\\editors\\common\\ComponentInstanceEditor</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\common\\ComponentInstanceEditor\\ConfigurableElementsView.h\">\r\n      <Filter>Header Files\\editors\\common\\ComponentInstanceEditor</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\common\\ComponentInstanceEditor\\MissingConfigurableElementsFilter.h\">\r\n      <Filter>Header Files\\editors\\common\\ComponentInstanceEditor</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\common\\ComponentInstanceEditor\\ParameterConfigurableElementsFilter.h\">\r\n      <Filter>Header Files\\editors\\common\\ComponentInstanceEditor</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\common\\ConnectionEditor\\AdHocBoundsModel.h\">\r\n      <Filter>Header Files\\editors\\common\\ConnectionEditor</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\common\\DesignParameterReferenceTree\\DesignParameterReferenceCounter.h\">\r\n      <Filter>Header Files\\editors\\common\\DesignParameterReferenceTree</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\common\\DesignParameterReferenceTree\\DesignParameterReferenceTree.h\">\r\n      <Filter>Header Files\\editors\\common\\DesignParameterReferenceTree</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\common\\InterfaceEditor\\InterfacePortMapDelegate.h\">\r\n      <Filter>Header Files\\editors\\common\\InterfaceEditor</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\common\\InterfaceEditor\\InterfacePortMapModel.h\">\r\n      <Filter>Header Files\\editors\\common\\InterfaceEditor</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\common\\StickyNote\\ColorFillTextItem.h\">\r\n      <Filter>Header Files\\editors\\common\\StickyNote</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\common\\StickyNote\\StickyNote.h\">\r\n      <Filter>Header Files\\editors\\common\\StickyNote</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\common\\StickyNote\\StickyNoteAddCommand.h\">\r\n      <Filter>Header Files\\editors\\common\\StickyNote</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\common\\StickyNote\\StickyNoteRemoveCommand.h\">\r\n      <Filter>Header Files\\editors\\common\\StickyNote</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\common\\ComponentDesignDiagram.h\">\r\n      <Filter>Header Files\\editors\\common</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\common\\DesignCompletionModel.h\">\r\n      <Filter>Header Files\\editors\\common</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\common\\DesignDiagram.h\">\r\n      <Filter>Header Files\\editors\\common</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\common\\DesignWidget.h\">\r\n      <Filter>Header Files\\editors\\common</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\HWDesign\\AdhocEditor\\AdhocEditor.h\">\r\n      <Filter>Header Files\\editors\\HWDesign\\AdhocEditor</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\HWDesign\\columnview\\ColumnEditDialog.h\">\r\n      <Filter>Header Files\\editors\\HWDesign\\columnview</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\HWDesign\\columnview\\HWColumn.h\">\r\n      <Filter>Header Files\\editors\\HWDesign\\columnview</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\HWDesign\\undoCommands\\ReplaceComponentCommand.h\">\r\n      <Filter>Header Files\\editors\\HWDesign\\undoCommands</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\HWDesign\\undoCommands\\AdHocBoundsChangeCommand.h\">\r\n      <Filter>Header Files\\editors\\HWDesign\\undoCommands</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\HWDesign\\undoCommands\\AdHocTieOffChangeCommand.h\">\r\n      <Filter>Header Files\\editors\\HWDesign\\undoCommands</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\HWDesign\\undoCommands\\ComponentDeleteCommand.h\">\r\n      <Filter>Header Files\\editors\\HWDesign\\undoCommands</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\HWDesign\\undoCommands\\ConfigurableElementChangeCommand.h\">\r\n      <Filter>Header Files\\editors\\HWDesign\\undoCommands</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\HWDesign\\undoCommands\\ConfigurableElementRemoveCommand.h\">\r\n      <Filter>Header Files\\editors\\HWDesign\\undoCommands</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\HWDesign\\undoCommands\\HWComponentAddCommand.h\">\r\n      <Filter>Header Files\\editors\\HWDesign\\undoCommands</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\HWDesign\\undoCommands\\InterfaceDeleteCommand.h\">\r\n      <Filter>Header Files\\editors\\HWDesign\\undoCommands</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\HWDesign\\SelectItemTypeDialog.h\">\r\n      <Filter>Header Files\\editors\\HWDesign</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\HWDesign\\AdHocConnectionItem.h\">\r\n      <Filter>Header Files\\editors\\HWDesign</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\HWDesign\\AdHocItem.h\">\r\n      <Filter>Header Files\\editors\\HWDesign</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\HWDesign\\BusInterfaceDialog.h\">\r\n      <Filter>Header Files\\editors\\HWDesign</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\HWDesign\\BusInterfaceEndPoint.h\">\r\n      <Filter>Header Files\\editors\\HWDesign</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\HWDesign\\HWChangeCommands.h\">\r\n      <Filter>Header Files\\editors\\HWDesign</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\HWDesign\\HWComponentItem.h\">\r\n      <Filter>Header Files\\editors\\HWDesign</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\HWDesign\\HWConnection.h\">\r\n      <Filter>Header Files\\editors\\HWDesign</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\HWDesign\\HWConnectionEndpoint.h\">\r\n      <Filter>Header Files\\editors\\HWDesign</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\HWDesign\\HWDesignDiagram.h\">\r\n      <Filter>Header Files\\editors\\HWDesign</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\HWDesign\\HWDesignWidget.h\">\r\n      <Filter>Header Files\\editors\\HWDesign</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\HWDesign\\OffPageConnectorItem.h\">\r\n      <Filter>Header Files\\editors\\HWDesign</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\common\\ComponentInstanceEditor\\componentinstanceeditor.h\">\r\n      <Filter>Header Files\\editors\\common\\ComponentInstanceEditor</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\common\\ComponentInstanceEditor\\configurableelementdelegate.h\">\r\n      <Filter>Header Files\\editors\\common\\ComponentInstanceEditor</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\common\\ComponentInstanceEditor\\configurableelementeditor.h\">\r\n      <Filter>Header Files\\editors\\common\\ComponentInstanceEditor</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\common\\ConfigurationEditor\\configurationeditor.h\">\r\n      <Filter>Header Files\\editors\\common\\ConfigurationEditor</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\common\\ConfigurationEditor\\activeviewdelegate.h\">\r\n      <Filter>Header Files\\editors\\common\\ConfigurationEditor</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\common\\ConfigurationEditor\\activevieweditor.h\">\r\n      <Filter>Header Files\\editors\\common\\ConfigurationEditor</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\common\\ConfigurationEditor\\activeviewmodel.h\">\r\n      <Filter>Header Files\\editors\\common\\ConfigurationEditor</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\common\\ConnectionEditor\\connectioneditor.h\">\r\n      <Filter>Header Files\\editors\\common\\ConnectionEditor</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\common\\InterfaceEditor\\interfaceeditor.h\">\r\n      <Filter>Header Files\\editors\\common\\InterfaceEditor</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\MemoryDesigner\\MemoryColumn.h\">\r\n      <Filter>Header Files\\editors\\MemoryDesigner</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\MemoryDesigner\\MemoryDesignConstructor.h\">\r\n      <Filter>Header Files\\editors\\MemoryDesigner</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\MemoryDesigner\\MemoryDesignDocument.h\">\r\n      <Filter>Header Files\\editors\\MemoryDesigner</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\MemoryDesigner\\MemoryDesignerDiagram.h\">\r\n      <Filter>Header Files\\editors\\MemoryDesigner</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\MemoryDesigner\\MemoryDesignerGraphicsItem.h\">\r\n      <Filter>Header Files\\editors\\MemoryDesigner</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\MemoryDesigner\\MemoryGraphicsItemHandler.h\">\r\n      <Filter>Header Files\\editors\\MemoryDesigner</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\SystemDesign\\SystemDetailsEditor\\SystemDetailsEditor.h\">\r\n      <Filter>Header Files\\editors\\SystemDesign\\SystemDetailsEditor</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\SystemDesign\\SystemDetailsEditor\\ExportSWDialog.h\">\r\n      <Filter>Header Files\\editors\\SystemDesign\\SystemDetailsEditor</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\SystemDesign\\SystemDetailsEditor\\SwitchHWDialog.h\">\r\n      <Filter>Header Files\\editors\\SystemDesign\\SystemDetailsEditor</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\SystemDesign\\UndoCommands\\ReplaceSystemComponentCommand.h\">\r\n      <Filter>Header Files\\editors\\SystemDesign\\UndoCommands</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\SystemDesign\\UndoCommands\\SystemComponentAddCommand.h\">\r\n      <Filter>Header Files\\editors\\SystemDesign\\UndoCommands</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\SystemDesign\\UndoCommands\\SystemComponentDeleteCommand.h\">\r\n      <Filter>Header Files\\editors\\SystemDesign\\UndoCommands</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\SystemDesign\\SystemDesignWidget.h\">\r\n      <Filter>Header Files\\editors\\SystemDesign</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\SystemDesign\\ApiGraphicsConnection.h\">\r\n      <Filter>Header Files\\editors\\SystemDesign</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\SystemDesign\\ComGraphicsConnection.h\">\r\n      <Filter>Header Files\\editors\\SystemDesign</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\SystemDesign\\SWComponentItem.h\">\r\n      <Filter>Header Files\\editors\\SystemDesign</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\SystemDesign\\SWConnectionEndpoint.h\">\r\n      <Filter>Header Files\\editors\\SystemDesign</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\SystemDesign\\SWInterfaceItem.h\">\r\n      <Filter>Header Files\\editors\\SystemDesign</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\SystemDesign\\SWPortItem.h\">\r\n      <Filter>Header Files\\editors\\SystemDesign</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\SystemDesign\\SystemColumn.h\">\r\n      <Filter>Header Files\\editors\\SystemDesign</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\SystemDesign\\SystemComponentItem.h\">\r\n      <Filter>Header Files\\editors\\SystemDesign</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\SystemDesign\\SystemDesignDiagram.h\">\r\n      <Filter>Header Files\\editors\\SystemDesign</Filter>\r\n    </QtMoc>\r\n    <CustomBuild Include=\"editors\\HWDesign\\undoCommands\\PhysicalPortDeleteCommand.h\">\r\n      <Filter>Header Files\\editors\\HWDesign\\undoCommands</Filter>\r\n    </CustomBuild>\r\n    <QtMoc Include=\"editors\\BusDefinitionEditor\\SystemGroupListEditor.h\">\r\n      <Filter>Header Files\\editors\\BusDefinitionEditor</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\memoryMaps\\SingleRegisterFileEditor.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\memoryMaps</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\treeStructure\\componenteditorregisterfileitem.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\treeStructure</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\memoryMaps\\registerfiledelegate.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\memoryMaps</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\memoryMaps\\registerfileeditor.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\memoryMaps</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\memoryMaps\\registerfilemodel.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\memoryMaps</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\common\\VendorExtensionEditor\\VendorExtensionsEditor.h\">\r\n      <Filter>Header Files\\editors\\VendorExtensionEditor</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\common\\VendorExtensionEditor\\VendorExtensionsModel.h\">\r\n      <Filter>Header Files\\editors\\VendorExtensionEditor</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\treeStructure\\ResetTypesItem.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\treeStructure</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\resetTypes\\ResetTypesEditor.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\resetTypes</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\resetTypes\\ResetTypesModel.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\resetTypes</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\resetTypes\\ResetTypesDelegate.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\resetTypes</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\memoryMaps\\ResetsEditor.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\memoryMaps</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\memoryMaps\\ResetsModel.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\memoryMaps</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\memoryMaps\\ResetsDelegate.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\memoryMaps</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\common\\VendorExtensionEditor\\VendorExtensionsDelegate.h\">\r\n      <Filter>Header Files\\editors\\VendorExtensionEditor</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\common\\ComponentItemAutoConnector\\ComponentItemAutoConnector.h\">\r\n      <Filter>Header Files\\editors\\common\\ComponentItemAutoConnector</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\common\\ComponentItemAutoConnector\\AutoConnectorConnectionTable.h\">\r\n      <Filter>Header Files\\editors\\common\\ComponentItemAutoConnector</Filter>\r\n    </QtMoc>\r\n    <CustomBuild Include=\"editors\\common\\ComponentItemAutoConnector\\AutoConnectorItem.h\">\r\n      <Filter>Header Files\\editors\\common\\ComponentItemAutoConnector</Filter>\r\n    </CustomBuild>\r\n    <QtMoc Include=\"editors\\common\\ComponentItemAutoConnector\\AutoConnector.h\">\r\n      <Filter>Header Files\\editors\\common\\ComponentItemAutoConnector</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\common\\ComponentItemAutoConnector\\AutoConnectorConnectionDelegate.h\">\r\n      <Filter>Header Files\\editors\\common\\ComponentItemAutoConnector</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\HWDesign\\HierarchicalBusInterfaceItem.h\">\r\n      <Filter>Header Files\\editors\\HWDesign</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\HWDesign\\ActiveBusInterfaceItem.h\">\r\n      <Filter>Header Files\\editors\\HWDesign</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\HWDesign\\HierarchicalPortItem.h\">\r\n      <Filter>Header Files\\editors\\HWDesign</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\HWDesign\\ActivePortItem.h\">\r\n      <Filter>Header Files\\editors\\HWDesign</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\common\\ComponentItemAutoConnector\\AutoConnectorListFilter.h\">\r\n      <Filter>Header Files\\editors\\common\\ComponentItemAutoConnector</Filter>\r\n    </QtMoc>\r\n    <CustomBuild Include=\"editors\\common\\ComponentItemAutoConnector\\PortListFiller.h\">\r\n      <Filter>Header Files\\editors\\common\\ComponentItemAutoConnector</Filter>\r\n    </CustomBuild>\r\n    <QtMoc Include=\"editors\\common\\VendorExtensionEditor\\VendorExtensionsFilter.h\">\r\n      <Filter>Header Files\\editors\\VendorExtensionEditor</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\common\\VendorExtensionEditor\\VendorExtensionAttributesEditor\\VendorExtensionAttributesModel.h\">\r\n      <Filter>Header Files\\editors\\VendorExtensionEditor\\VendorExtensionAttributesEditor</Filter>\r\n    </QtMoc>\r\n    <CustomBuild Include=\"editors\\common\\VendorExtensionEditor\\VendorExtensionsGeneral.h\">\r\n      <Filter>Header Files\\editors\\VendorExtensionEditor</Filter>\r\n    </CustomBuild>\r\n    <QtMoc Include=\"wizards\\ImportWizard\\ImportInstancesEditor\\ImportInstancesEditor.h\">\r\n      <Filter>Header Files\\wizards\\ImportWizard\\ImportInstancesEditor</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"wizards\\ImportWizard\\ImportWizardInstancesPage.h\">\r\n      <Filter>Header Files\\wizards\\ImportWizard</Filter>\r\n    </QtMoc>\r\n    <CustomBuild Include=\"wizards\\ComponentWizard\\InstanceData.h\">\r\n      <Filter>Header Files\\wizards\\ComponentWizard</Filter>\r\n    </CustomBuild>\r\n    <QtMoc Include=\"wizards\\ImportWizard\\ImportInstancesEditor\\ImportInstancesDelegate.h\">\r\n      <Filter>Header Files\\wizards\\ImportWizard\\ImportInstancesEditor</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\ports\\MasterPortsEditor.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\ports</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\ports\\WirePortsModel.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\ports</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\ports\\TransactionalPortsModel.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\ports</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\ports\\WirePortsFilter.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\ports</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\ports\\TransactionalPortsFilter.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\ports</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\ports\\WirePortsDelegate.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\ports</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\ports\\TransactionalPortsDelegate.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\ports</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\ports\\PortsFilter.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\ports</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"common\\widgets\\tagEditor\\TagLabel.h\">\r\n      <Filter>Header Files\\common\\widgets\\tagEditor</Filter>\r\n    </QtMoc>\r\n    <CustomBuild Include=\"common\\widgets\\tagEditor\\FlowLayout.h\">\r\n      <Filter>Header Files\\common\\widgets\\tagEditor</Filter>\r\n    </CustomBuild>\r\n    <QtMoc Include=\"common\\widgets\\tagEditor\\TagContainer.h\">\r\n      <Filter>Header Files\\common\\widgets\\tagEditor</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"common\\widgets\\tagEditor\\TagEditor.h\">\r\n      <Filter>Header Files\\common\\widgets\\tagEditor</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"common\\widgets\\tagEditor\\TagCompleterModel.h\">\r\n      <Filter>Header Files\\common\\widgets\\tagEditor</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"common\\widgets\\tagEditor\\TagEditorContainer.h\">\r\n      <Filter>Header Files\\common\\widgets\\tagEditor</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"common\\widgets\\tagEditor\\TagDisplay.h\">\r\n      <Filter>Header Files\\common\\widgets\\tagEditor</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"common\\widgets\\tagEditor\\TagSelectorContainer.h\">\r\n      <Filter>Header Files\\common\\widgets\\tagEditor</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"common\\widgets\\tagEditor\\TagSelector.h\">\r\n      <Filter>Header Files\\common\\widgets\\tagEditor</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"PythonAPI\\ChannelRelay.h\">\r\n      <Filter>Header Files\\PythonAPI</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"PythonAPI\\PythonInterpreter.h\">\r\n      <Filter>Header Files\\PythonAPI</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"PythonAPI\\StdInputListener.h\">\r\n      <Filter>Header Files\\PythonAPI</Filter>\r\n    </QtMoc>\r\n    <CustomBuild Include=\"PythonAPI\\WriteChannel.h\">\r\n      <Filter>Header Files\\PythonAPI</Filter>\r\n    </CustomBuild>\r\n    <CustomBuild Include=\"editors\\HWDesign\\WarningSymbol.h\">\r\n      <Filter>Header Files\\editors\\HWDesign</Filter>\r\n    </CustomBuild>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\memoryMaps\\SubspaceMapsEditor.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\memoryMaps</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\memoryMaps\\SubspaceMapModel.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\memoryMaps</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\memoryMaps\\MemoryBlockModel.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\memoryMaps</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\memoryMaps\\MemoryBlockDelegate.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\memoryMaps</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\memoryMaps\\SubspaceMapDelegate.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\memoryMaps</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\memoryMaps\\MemoryBlockFilter.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\memoryMaps</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\treeStructure\\SubspaceMapItem.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\treeStructure</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\memoryMaps\\SingleSubspaceMapEditor.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\memoryMaps</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"common\\widgets\\busReferenceComboBox\\BusReferenceComboBox.h\">\r\n      <Filter>Header Files\\common\\widgets\\busReferenceCombobBox</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"common\\widgets\\segmentComboBox\\SegmentComboBox.h\">\r\n      <Filter>Header Files\\common\\widgets\\segmentComboBox</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\memoryMaps\\memoryMapsVisualizer\\SubspaceMapGraphItem.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\memoryMaps\\memoryMapsVisualizer</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\memoryMaps\\memoryMapsVisualizer\\MemoryBlockGraphItem.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\memoryMaps\\memoryMapsVisualizer</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"settings\\NewPluginsDialog.h\">\r\n      <Filter>Header Files\\settings</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"wizards\\ComponentWizard\\ImportEditor.h\">\r\n      <Filter>Header Files\\wizards\\ComponentWizard</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"library\\objectremovedialog.h\">\r\n      <Filter>Header Files\\library</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"library\\ObjectSelectionDialog.h\">\r\n      <Filter>Header Files\\library</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"library\\ItemExporter.h\">\r\n      <Filter>Header Files\\library</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"library\\ObjectExportDialog.h\">\r\n      <Filter>Header Files\\library</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"PythonAPI\\FileChannel.h\">\r\n      <Filter>Header Files\\PythonAPI</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"common\\ui\\GraphicalMessageMediator.h\">\r\n      <Filter>Header Files\\common\\ui</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\PythonSourceEditor\\ScriptInputEditor.h\">\r\n      <Filter>Header Files\\editors\\PythonSourceEditor</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\PythonSourceEditor\\ScriptViewEditor.h\">\r\n      <Filter>Header Files\\editors\\PythonSourceEditor</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\PythonSourceEditor\\PythonSourceEditor.h\">\r\n      <Filter>Header Files\\editors\\PythonSourceEditor</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\busInterfaces\\portmaps\\PortMapView.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\busInterfaces\\portmaps</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\busInterfaces\\portmaps\\PortMapModel.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\busInterfaces\\portmaps</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\busInterfaces\\portmaps\\PortMapDelegate.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\busInterfaces\\portmaps</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"common\\views\\ExpandingTreeView\\ExpandingTreeView.h\">\r\n      <Filter>Header Files\\common\\views\\ExpandingTreeView</Filter>\r\n    </QtMoc>\r\n  </ItemGroup>\r\n  <ItemGroup>\r\n    <ClInclude Include=\"common\\dialogs\\listSelectDialog\\ListSelectDialog.h\">\r\n      <Filter>Header Files\\common\\dialogs\\listSelectDialog</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"common\\graphicsItems\\ConnectionUndoCommands.h\">\r\n      <Filter>Header Files\\common\\graphicsItems</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"common\\graphicsItems\\GraphicsColumnUndoCommands.h\">\r\n      <Filter>Header Files\\common\\graphicsItems</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"common\\graphicsItems\\GraphicsItemTypes.h\">\r\n      <Filter>Header Files\\common\\graphicsItems</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"common\\graphicsItems\\IGraphicsItemStack.h\">\r\n      <Filter>Header Files\\common\\graphicsItems</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"common\\layouts\\HCollisionLayout.h\">\r\n      <Filter>Header Files\\common\\layouts</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"common\\layouts\\HStackedLayout.h\">\r\n      <Filter>Header Files\\common\\layouts</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"common\\layouts\\IHGraphicsLayout.h\">\r\n      <Filter>Header Files\\common\\layouts</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"common\\layouts\\IVGraphicsLayout.h\">\r\n      <Filter>Header Files\\common\\layouts</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"common\\layouts\\VCollisionLayout.h\">\r\n      <Filter>Header Files\\common\\layouts</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"common\\layouts\\VStackedLayout.h\">\r\n      <Filter>Header Files\\common\\layouts</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"common\\layouts\\VStaticLayout.h\">\r\n      <Filter>Header Files\\common\\layouts</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"common\\widgets\\assistedLineEdit\\BasicLineContentMatcher.h\">\r\n      <Filter>Header Files\\common\\widgets\\assistedLineEdit</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"common\\widgets\\assistedLineEdit\\ILineContentMatcher.h\">\r\n      <Filter>Header Files\\common\\widgets\\assistedLineEdit</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"common\\widgets\\assistedLineEdit\\LineContentAssistWidget.h\">\r\n      <Filter>Header Files\\common\\widgets\\assistedLineEdit</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"common\\widgets\\assistedTextEdit\\HighlightStyleDesc.h\">\r\n      <Filter>Header Files\\common\\widgets\\assistedTextEdit</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"common\\widgets\\assistedTextEdit\\ITextContentMatcher.h\">\r\n      <Filter>Header Files\\common\\widgets\\assistedTextEdit</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"common\\widgets\\assistedTextEdit\\TextContentAssistWidget.h\">\r\n      <Filter>Header Files\\common\\widgets\\assistedTextEdit</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"common\\widgets\\SnippetTextEdit\\SnippetHighlighter.h\">\r\n      <Filter>Header Files\\common\\widgets\\SnippetTextEdit</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"common\\widgets\\vlnvEditor\\VLNVContentMatcher.h\">\r\n      <Filter>Header Files\\common\\widgets\\vlnvEditor</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"common\\widgets\\vlnvEditor\\VLNVDataTree.h\">\r\n      <Filter>Header Files\\common\\widgets\\vlnvEditor</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"common\\KactusColors.h\">\r\n      <Filter>Header Files\\common</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"common\\TextEditProvider.h\">\r\n      <Filter>Header Files\\common</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"settings\\SettingsUpdater.h\">\r\n      <Filter>Header Files\\settings</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"mainwindow\\SplashScreen.h\">\r\n      <Filter>Header Files\\mainwindow</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"common\\dialogs\\NewBusDialog\\NewBusDialog.h\">\r\n      <Filter>Header Files\\common\\dialogs\\NewBusDialog</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"wizards\\ComponentWizard\\ComponentWizardDependencyPage.h\">\r\n      <Filter>Header Files\\wizards\\ComponentWizard</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"wizards\\ComponentWizard\\ComponentWizardIntroPage.h\">\r\n      <Filter>Header Files\\wizards\\ComponentWizard</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"Help\\HelpSystem\\HelpWindow.h\">\r\n      <Filter>Header Files\\Help\\HelpSystem</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"editors\\ComponentEditor\\fileSet\\dependencyAnalysis\\FileDependencySortFilter.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\fileSet\\dependencyAnalysis</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"editors\\CSourceEditor\\CSourceContentMatcher.h\">\r\n      <Filter>Header Files\\editors\\CSourceEditor</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"wizards\\ComponentWizard\\ComponentWizardPages.h\">\r\n      <Filter>Header Files\\wizards\\ComponentWizard</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"wizards\\ImportWizard\\ImportWizardPages.h\">\r\n      <Filter>Header Files\\wizards\\ImportWizard</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"wizards\\common\\IPXactDiff.h\">\r\n      <Filter>Header Files\\wizards\\common</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"wizards\\common\\IPXactElementComparator.h\">\r\n      <Filter>Header Files\\wizards\\common</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"wizards\\common\\VLNVComparator\\VLNVComparator.h\">\r\n      <Filter>Header Files\\wizards\\common\\VLNVComparator</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"wizards\\common\\ComponentComparator\\ComponentComparator.h\">\r\n      <Filter>Header Files\\wizards\\common\\ComponentComparator</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"wizards\\common\\ViewComparator\\ViewComparator.h\">\r\n      <Filter>Header Files\\wizards\\common\\ViewComparator</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"wizards\\common\\ListComparator.h\">\r\n      <Filter>Header Files\\wizards\\common</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"wizards\\common\\PortComparator\\PortComparator.h\">\r\n      <Filter>Header Files\\wizards\\common\\PortComparator</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"wizards\\ImportWizard\\ImportWizardIntroPage.h\">\r\n      <Filter>Header Files\\wizards\\ImportWizard</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"editors\\ComponentEditor\\parameters\\ParameterColumns.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\parameters</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"mainwindow\\Ribbon\\RibbonTheme.h\">\r\n      <Filter>Header Files\\mainwindow\\Ribbon</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"editors\\ComponentEditor\\parameters\\ComponentParameterColumns.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\parameters</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"editors\\ComponentEditor\\memoryMaps\\AddressBlockColumns.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\memoryMaps</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"editors\\ComponentEditor\\memoryMaps\\RegisterColumns.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\memoryMaps</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"editors\\ComponentEditor\\memoryMaps\\MemoryMapColumns.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\memoryMaps</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"editors\\ComponentEditor\\parameters\\Array\\ArrayColumns.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\parameters\\Array</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"wizards\\common\\ParameterComparator\\ParameterComparator.h\">\r\n      <Filter>Header Files\\wizards\\common\\ParameterComparator</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"editors\\ComponentEditor\\remapStates\\RemapConditionColumns.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\remapStates</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"editors\\ComponentEditor\\memoryMaps\\MemoryMapsColumns.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\memoryMaps</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"editors\\ComponentEditor\\memoryMaps\\memoryMapsExpressionCalculators\\ReferenceCalculator.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\memoryMaps\\memoryMapsExpressionCalculators</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"editors\\ComponentEditor\\addressSpaces\\AddressSpaceColumns.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\addressSpaces</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"editors\\ConfigurationTools\\ViewConfigurerColumns.h\">\r\n      <Filter>Header Files\\editors\\ConfigurationTools</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"mainwindow\\SaveHierarchy\\HierarchicalSaveColumns.h\">\r\n      <Filter>Header Files\\mainwindow\\SaveHierarchy</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"mainwindow\\SaveHierarchy\\SaveAsItem.h\">\r\n      <Filter>Header Files\\mainwindow\\SaveHierarchy</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"mainwindow\\SaveHierarchy\\DocumentTreeBuilder.h\">\r\n      <Filter>Header Files\\mainwindow\\SaveHierarchy</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"mainwindow\\SaveHierarchy\\SaveHierarchyDelegate.h\">\r\n      <Filter>Header Files\\mainwindow\\SaveHierarchy</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"editors\\ComponentEditor\\memoryMaps\\EnumeratedValueColumns.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\memoryMaps</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"editors\\ComponentEditor\\busInterfaces\\BusInterfaceColumns.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\busInterfaces</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"editors\\ComDefinitionEditor\\ComPropertyColumns.h\">\r\n      <Filter>Header Files\\editors\\ComDefinitionEditor</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"editors\\ComponentEditor\\software\\comInterface\\ComInterfaceColumns.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\software\\comInterface</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"editors\\ComponentEditor\\otherClockDrivers\\OtherClockDriverColumns.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\otherClockDrivers</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"editors\\ComponentEditor\\cpus\\CpuColumns.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\cpus</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"editors\\ComponentEditor\\channels\\ChannelColumns.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\channels</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"editors\\ComponentEditor\\fileBuilders\\FileBuilderColumns.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\fileBuilders</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"editors\\ComponentEditor\\fileSet\\FileSetColumns.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\fileSet</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"editors\\ComponentEditor\\fileSet\\file\\FileColumns.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\fileSet\\file</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"editors\\ComponentEditor\\fileSet\\dependencyAnalysis\\FileDependencyColumns.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\fileSet\\dependencyAnalysis</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"editors\\ComponentEditor\\choices\\ChoiceColumns.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\choices</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"editors\\ComponentEditor\\addressSpaces\\SegmentColumns.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\addressSpaces</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"editors\\ComponentEditor\\views\\EnvIdentifiersColumns.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\views</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"editors\\ApiDefinitionEditor\\ApiFunctionColumns.h\">\r\n      <Filter>Header Files\\editors\\ApiDefinitionEditor</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"editors\\ComponentEditor\\views\\ViewColumns.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\views</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"wizards\\common\\ModuleParameterComparator\\ModuleParameterComparator.h\">\r\n      <Filter>Header Files\\wizards\\common\\ModuleParameterComparator</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"editors\\ComponentEditor\\software\\apiInterface\\ApiInterfaceColumns.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\software\\apiInterface</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"editors\\ComponentEditor\\instantiations\\ComponentInstantiationDisplayer.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\instantiations</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"editors\\ComponentEditor\\instantiations\\ComponentInstantiationsColumns.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\instantiations</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"editors\\ComponentEditor\\instantiations\\DesignInstantiationColumns.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\instantiations</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"editors\\ComponentEditor\\busInterfaces\\portmaps\\PortMappingColumns.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\busInterfaces\\portmaps</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"editors\\ComponentEditor\\busInterfaces\\portmaps\\PortMapsColumns.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\busInterfaces\\portmaps</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"editors\\ComponentEditor\\busInterfaces\\portmaps\\PortMapHeaderView.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\busInterfaces\\portmaps</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"editors\\BusDefinitionEditor\\LogicalPortColumns.h\">\r\n      <Filter>Header Files\\editors\\BusDefinitionEditor</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"editors\\ComponentEditor\\busInterfaces\\general\\BridgeColumns.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\busInterfaces\\general</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"editors\\ComponentEditor\\instantiations\\ModuleParameterColumns.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\instantiations</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"editors\\ComponentEditor\\instantiations\\ModuleParameterHeaderView.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\instantiations</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"editors\\CatalogEditor\\CatalogFileColumns.h\">\r\n      <Filter>Header Files\\editors\\CatalogEditor</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"editors\\CSourceEditor\\CSourceHighlight.h\">\r\n      <Filter>Header Files\\editors\\CSourceEditor</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"Plugins\\common\\SourceHighlightStyle.h\">\r\n      <Filter>Header Files\\Plugins\\common</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"settings\\FileTypeColumns.h\">\r\n      <Filter>Header Files\\settings</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"library\\LibraryInterface.h\">\r\n      <Filter>Header Files\\library</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"library\\LibraryUtils.h\">\r\n      <Filter>Header Files\\library</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"library\\TableViewDialog.h\">\r\n      <Filter>Header Files\\library</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"common\\NameGenerationPolicy.h\">\r\n      <Filter>Header Files\\common</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"editors\\ComponentEditor\\common\\DesignConfigurationInstantiationParameterFinder.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\common</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"editors\\ComponentEditor\\indirectInterfaces\\IndirectInterfaceColumns.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\indirectInterfaces</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"editors\\ComponentEditor\\common\\ConfigurableElementFinder.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\common</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"common\\graphicsItems\\GraphicsColumnAddCommand.h\">\r\n      <Filter>Header Files\\common\\graphicsItems</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"editors\\ComponentEditor\\ports\\PortWireTypeColumns.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\ports</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"editors\\ComponentEditor\\ports\\PortTypeDefinitionDelegate.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\ports</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"editors\\ComponentEditor\\busInterfaces\\AbstractionTypesConstants.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\busInterfaces</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"mainwindow\\CommandLineParser.h\">\r\n      <Filter>Header Files\\mainwindow</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"editors\\common\\Association\\Associable.h\">\r\n      <Filter>Header Files\\editors\\common\\Association</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"editors\\common\\Association\\Association.h\">\r\n      <Filter>Header Files\\editors\\common\\Association</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"editors\\common\\Association\\AssociationAddCommand.h\">\r\n      <Filter>Header Files\\editors\\common\\Association</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"editors\\common\\Association\\AssociationChangeEndpointCommand.h\">\r\n      <Filter>Header Files\\editors\\common\\Association</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"editors\\common\\Association\\AssociationRemoveCommand.h\">\r\n      <Filter>Header Files\\editors\\common\\Association</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"editors\\common\\ComponentInstanceEditor\\ConfigurableElementsColumns.h\">\r\n      <Filter>Header Files\\editors\\common\\ComponentInstanceEditor</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"editors\\common\\ComponentInstanceEditor\\EditorConfigurableElement.h\">\r\n      <Filter>Header Files\\editors\\common\\ComponentInstanceEditor</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"editors\\common\\ConnectionEditor\\AdHocBoundColumns.h\">\r\n      <Filter>Header Files\\editors\\common\\ConnectionEditor</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"editors\\common\\InterfaceEditor\\InterfacePortMapColumns.h\">\r\n      <Filter>Header Files\\editors\\common\\InterfaceEditor</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"editors\\common\\StickyNote\\StickyNoteEditCommand.h\">\r\n      <Filter>Header Files\\editors\\common\\StickyNote</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"editors\\common\\StickyNote\\StickyNoteMoveCommand.h\">\r\n      <Filter>Header Files\\editors\\common\\StickyNote</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"editors\\common\\ColumnTypes.h\">\r\n      <Filter>Header Files\\editors\\common</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"editors\\common\\DefaultRouting.h\">\r\n      <Filter>Header Files\\editors\\common</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"editors\\common\\DesignDiagramResolver.h\">\r\n      <Filter>Header Files\\editors\\common</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"editors\\common\\DesignWidgetFactory.h\">\r\n      <Filter>Header Files\\editors\\common</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"editors\\common\\DesignWidgetFactoryImplementation.h\">\r\n      <Filter>Header Files\\editors\\common</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"editors\\common\\diagramgrid.h\">\r\n      <Filter>Header Files\\editors\\common</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"editors\\common\\DiagramUtil.h\">\r\n      <Filter>Header Files\\editors\\common</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"editors\\common\\DrawMode.h\">\r\n      <Filter>Header Files\\editors\\common</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"editors\\common\\GraphicsItemLabel.h\">\r\n      <Filter>Header Files\\editors\\common</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"editors\\common\\ImageExporter.h\">\r\n      <Filter>Header Files\\editors\\common</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"editors\\common\\NamelabelWidth.h\">\r\n      <Filter>Header Files\\editors\\common</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"editors\\common\\TopComponentParameterFinder.h\">\r\n      <Filter>Header Files\\editors\\common</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"editors\\HWDesign\\undoCommands\\PortDeleteCommand.h\">\r\n      <Filter>Header Files\\editors\\HWDesign\\undoCommands</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"editors\\HWDesign\\undoCommands\\PortPasteCommand.h\">\r\n      <Filter>Header Files\\editors\\HWDesign\\undoCommands</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"editors\\HWDesign\\undoCommands\\TopAdHocVisibilityChangeCommand.h\">\r\n      <Filter>Header Files\\editors\\HWDesign\\undoCommands</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"editors\\HWDesign\\undoCommands\\AdHocConnectionAddCommand.h\">\r\n      <Filter>Header Files\\editors\\HWDesign\\undoCommands</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"editors\\HWDesign\\undoCommands\\AdHocConnectionDeleteCommand.h\">\r\n      <Filter>Header Files\\editors\\HWDesign\\undoCommands</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"editors\\HWDesign\\undoCommands\\AdHocTiedValueCommand.h\">\r\n      <Filter>Header Files\\editors\\HWDesign\\undoCommands</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"editors\\HWDesign\\undoCommands\\AdHocTieOffBoundsChangeCommand.h\">\r\n      <Filter>Header Files\\editors\\HWDesign\\undoCommands</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"editors\\HWDesign\\undoCommands\\AdHocTieOffConnectionDeleteCommand.h\">\r\n      <Filter>Header Files\\editors\\HWDesign\\undoCommands</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"editors\\HWDesign\\undoCommands\\AdHocVisibilityChangeCommand.h\">\r\n      <Filter>Header Files\\editors\\HWDesign\\undoCommands</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"editors\\HWDesign\\undoCommands\\ColumnDeleteCommand.h\">\r\n      <Filter>Header Files\\editors\\HWDesign\\undoCommands</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"editors\\HWDesign\\undoCommands\\ComponentInstancePasteCommand.h\">\r\n      <Filter>Header Files\\editors\\HWDesign\\undoCommands</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"editors\\HWDesign\\undoCommands\\ComponentItemMoveCommand.h\">\r\n      <Filter>Header Files\\editors\\HWDesign\\undoCommands</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"editors\\HWDesign\\undoCommands\\ConnectionDeleteCommand.h\">\r\n      <Filter>Header Files\\editors\\HWDesign\\undoCommands</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"editors\\HWDesign\\undoCommands\\HWColumnAddCommand.h\">\r\n      <Filter>Header Files\\editors\\HWDesign\\undoCommands</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"editors\\HWDesign\\AdHocEnabled.h\">\r\n      <Filter>Header Files\\editors\\HWDesign</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"editors\\HWDesign\\HWAddCommands.h\">\r\n      <Filter>Header Files\\editors\\HWDesign</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"editors\\HWDesign\\HWMoveCommands.h\">\r\n      <Filter>Header Files\\editors\\HWDesign</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"editors\\HWDesign\\InterfaceGraphics.h\">\r\n      <Filter>Header Files\\editors\\HWDesign</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"editors\\HWDesign\\PortmapDialog.h\">\r\n      <Filter>Header Files\\editors\\HWDesign</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"editors\\MemoryDesigner\\SubMemoryLayout.h\">\r\n      <Filter>Header Files\\editors\\MemoryDesigner</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"editors\\MemoryDesigner\\AddressBlockGraphicsItem.h\">\r\n      <Filter>Header Files\\editors\\MemoryDesigner</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"editors\\MemoryDesigner\\AddressSegmentGraphicsItem.h\">\r\n      <Filter>Header Files\\editors\\MemoryDesigner</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"editors\\MemoryDesigner\\AddressSpaceGraphicsItem.h\">\r\n      <Filter>Header Files\\editors\\MemoryDesigner</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"editors\\MemoryDesigner\\ConnectivityComponent.h\">\r\n      <Filter>Header Files\\editors\\MemoryDesigner</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"editors\\MemoryDesigner\\ConnectivityConnection.h\">\r\n      <Filter>Header Files\\editors\\MemoryDesigner</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"editors\\MemoryDesigner\\ConnectivityGraph.h\">\r\n      <Filter>Header Files\\editors\\MemoryDesigner</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"editors\\MemoryDesigner\\ConnectivityGraphFactory.h\">\r\n      <Filter>Header Files\\editors\\MemoryDesigner</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"editors\\MemoryDesigner\\ConnectivityInterface.h\">\r\n      <Filter>Header Files\\editors\\MemoryDesigner</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"editors\\MemoryDesigner\\FieldGraphicsItem.h\">\r\n      <Filter>Header Files\\editors\\MemoryDesigner</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"editors\\MemoryDesigner\\FieldOverlapItem.h\">\r\n      <Filter>Header Files\\editors\\MemoryDesigner</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"editors\\MemoryDesigner\\MainMemoryGraphicsItem.h\">\r\n      <Filter>Header Files\\editors\\MemoryDesigner</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"editors\\MemoryDesigner\\MasterSlavePathSearch.h\">\r\n      <Filter>Header Files\\editors\\MemoryDesigner</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"editors\\MemoryDesigner\\MemoryCollisionItem.h\">\r\n      <Filter>Header Files\\editors\\MemoryDesigner</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"editors\\MemoryDesigner\\MemoryColumnHandler.h\">\r\n      <Filter>Header Files\\editors\\MemoryDesigner</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"editors\\MemoryDesigner\\MemoryConnectionHandler.h\">\r\n      <Filter>Header Files\\editors\\MemoryDesigner</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"editors\\MemoryDesigner\\MemoryConnectionItem.h\">\r\n      <Filter>Header Files\\editors\\MemoryDesigner</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"editors\\MemoryDesigner\\MemoryDesignerChildGraphicsItem.h\">\r\n      <Filter>Header Files\\editors\\MemoryDesigner</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"editors\\MemoryDesigner\\MemoryDesignerConstants.h\">\r\n      <Filter>Header Files\\editors\\MemoryDesigner</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"editors\\MemoryDesigner\\MemoryExtensionGraphicsItem.h\">\r\n      <Filter>Header Files\\editors\\MemoryDesigner</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"editors\\MemoryDesigner\\MemoryItem.h\">\r\n      <Filter>Header Files\\editors\\MemoryDesigner</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"editors\\MemoryDesigner\\MemoryMapGraphicsItem.h\">\r\n      <Filter>Header Files\\editors\\MemoryDesigner</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"editors\\MemoryDesigner\\RegisterGraphicsItem.h\">\r\n      <Filter>Header Files\\editors\\MemoryDesigner</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"editors\\SystemDesign\\UndoCommands\\ApiConnectionAddCommand.h\">\r\n      <Filter>Header Files\\editors\\SystemDesign\\UndoCommands</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"editors\\SystemDesign\\UndoCommands\\ApiConnectionDeleteCommand.h\">\r\n      <Filter>Header Files\\editors\\SystemDesign\\UndoCommands</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"editors\\SystemDesign\\UndoCommands\\ApiConnectionExchangeCommand.h\">\r\n      <Filter>Header Files\\editors\\SystemDesign\\UndoCommands</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"editors\\SystemDesign\\UndoCommands\\ComConnectionAddCommand.h\">\r\n      <Filter>Header Files\\editors\\SystemDesign\\UndoCommands</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"editors\\SystemDesign\\UndoCommands\\ComConnectionDeleteCommand.h\">\r\n      <Filter>Header Files\\editors\\SystemDesign\\UndoCommands</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"editors\\SystemDesign\\UndoCommands\\ComConnectionExchangeCommand.h\">\r\n      <Filter>Header Files\\editors\\SystemDesign\\UndoCommands</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"editors\\SystemDesign\\UndoCommands\\SWInterfaceAddCommand.h\">\r\n      <Filter>Header Files\\editors\\SystemDesign\\UndoCommands</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"editors\\SystemDesign\\UndoCommands\\SWInterfaceDeleteCommand.h\">\r\n      <Filter>Header Files\\editors\\SystemDesign\\UndoCommands</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"editors\\SystemDesign\\UndoCommands\\SWInterfaceMoveCommand.h\">\r\n      <Filter>Header Files\\editors\\SystemDesign\\UndoCommands</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"editors\\SystemDesign\\UndoCommands\\SWPortDeleteCommand.h\">\r\n      <Filter>Header Files\\editors\\SystemDesign\\UndoCommands</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"editors\\SystemDesign\\UndoCommands\\SystemAddCommands.h\">\r\n      <Filter>Header Files\\editors\\SystemDesign\\UndoCommands</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"editors\\SystemDesign\\UndoCommands\\SystemChangeCommands.h\">\r\n      <Filter>Header Files\\editors\\SystemDesign\\UndoCommands</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"editors\\SystemDesign\\UndoCommands\\SystemDeleteCommands.h\">\r\n      <Filter>Header Files\\editors\\SystemDesign\\UndoCommands</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"editors\\SystemDesign\\UndoCommands\\SystemMoveCommands.h\">\r\n      <Filter>Header Files\\editors\\SystemDesign\\UndoCommands</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"editors\\SystemDesign\\HWMappingItem.h\">\r\n      <Filter>Header Files\\editors\\SystemDesign</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"editors\\MemoryDesigner\\MemoryConnectionAddressCalculator.h\">\r\n      <Filter>Header Files\\editors\\MemoryDesigner</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"editors\\ComponentEditor\\memoryMaps\\memoryMapsVisualizer\\registerfilegraphitem.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\memoryMaps\\memoryMapsVisualizer</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"editors\\ComponentEditor\\memoryMaps\\RegisterFileColumns.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\memoryMaps</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"editors\\common\\VendorExtensionEditor\\VendorExtensionColumns.h\">\r\n      <Filter>Header Files\\editors\\VendorExtensionEditor</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"editors\\ComponentEditor\\resetTypes\\ResetTypeColumns.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\resetTypes</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"editors\\ComponentEditor\\memoryMaps\\ResetColumns.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\memoryMaps</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"editors\\common\\ComponentItemAutoConnector\\ListFiller.h\">\r\n      <Filter>Header Files\\editors\\common\\ComponentItemAutoConnector</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"editors\\common\\ComponentItemAutoConnector\\PortTableAutoConnector.h\">\r\n      <Filter>Header Files\\editors\\common\\ComponentItemAutoConnector</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"editors\\common\\ComponentItemAutoConnector\\TableAutoConnector.h\">\r\n      <Filter>Header Files\\editors\\common\\ComponentItemAutoConnector</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"editors\\common\\ComponentItemAutoConnector\\BusInterfaceListFiller.h\">\r\n      <Filter>Header Files\\editors\\common\\ComponentItemAutoConnector</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"editors\\common\\ComponentItemAutoConnector\\BusInterfaceTableAutoConnector.h\">\r\n      <Filter>Header Files\\editors\\common\\ComponentItemAutoConnector</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"editors\\common\\ComponentItemAutoConnector\\TableItemMatcher.h\">\r\n      <Filter>Header Files\\editors\\common\\ComponentItemAutoConnector</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"editors\\common\\ComponentItemAutoConnector\\PortItemMatcher.h\">\r\n      <Filter>Header Files\\editors\\common\\ComponentItemAutoConnector</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"editors\\common\\ComponentItemAutoConnector\\BusInterfaceItemMatcher.h\">\r\n      <Filter>Header Files\\editors\\common\\ComponentItemAutoConnector</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"editors\\common\\PortUtilities.h\">\r\n      <Filter>Header Files\\editors\\common</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"editors\\common\\ComponentItemAutoConnector\\HierarchicalPortTableAutoConnector.h\">\r\n      <Filter>Header Files\\editors\\common\\ComponentItemAutoConnector</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"editors\\common\\ComponentItemAutoConnector\\HierarchicalPortItemMatcher.h\">\r\n      <Filter>Header Files\\editors\\common\\ComponentItemAutoConnector</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"editors\\common\\ComponentItemAutoConnector\\HierarchicalBusInterfaceItemMatcher.h\">\r\n      <Filter>Header Files\\editors\\common\\ComponentItemAutoConnector</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"editors\\common\\ComponentItemAutoConnector\\HierarchicalBusInterfaceTableAutoConnector.h\">\r\n      <Filter>Header Files\\editors\\common\\ComponentItemAutoConnector</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"editors\\common\\VendorExtensionEditor\\VendorExtensionAttributesEditor\\VendorExtensionAttributesColumns.h\">\r\n      <Filter>Header Files\\editors\\VendorExtensionEditor\\VendorExtensionAttributesEditor</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"common\\expressions\\utilities.h\">\r\n      <Filter>Header Files\\common\\expressions</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"wizards\\ImportWizard\\ImportInstancesEditor\\ImportInstancesColumns.h\">\r\n      <Filter>Header Files\\wizards\\ImportWizard\\ImportInstancesEditor</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"editors\\ComponentEditor\\ports\\WirePortColumns.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\ports</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"editors\\ComponentEditor\\ports\\TransactionalPortColumns.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\ports</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"PythonAPI\\extensions\\IOCatcher.h\">\r\n      <Filter>Header Files\\PythonAPI\\extensions</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"editors\\ComponentEditor\\memoryMaps\\SubspaceMapColumns.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\memoryMaps</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"library\\ObjectSelectionListItem.h\">\r\n      <Filter>Header Files\\library</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"library\\LibraryItemSelectionFactory.h\">\r\n      <Filter>Header Files\\library</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"editors\\PythonSourceEditor\\ScriptingSideArea.h\">\r\n      <Filter>Header Files\\editors\\PythonSourceEditor</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"editors\\PythonSourceEditor\\PythonSourceHighlight.h\">\r\n      <Filter>Header Files\\editors\\PythonSourceEditor</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"editors\\ComponentEditor\\busInterfaces\\portmaps\\PortMapSortFilter.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\busInterfaces\\portmaps</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"editors\\ComponentEditor\\choices\\EnumerationColumns.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\choices</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"editors\\ComponentEditor\\common\\MasterExpressionEditor.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\common</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"Plugins\\common\\ConnectivityGraphUtilities.h\">\r\n      <Filter>Header Files\\Plugins\\common</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"editors\\HWDesign\\AdhocEditor\\AdHocVisibilityColumns.h\">\r\n      <Filter>Header Files\\editors\\HWDesign\\AdhocEditor</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"editors\\HWDesign\\AdhocEditor\\AdHocVisibilityModel.h\">\r\n      <Filter>Header Files\\editors\\HWDesign\\AdhocEditor</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"editors\\HWDesign\\AdhocEditor\\AdHocVisibilityPolicy.h\">\r\n      <Filter>Header Files\\editors\\HWDesign\\AdhocEditor</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"editors\\AbstractionDefinitionEditor\\AbstractionDefinitionPortsSortFilter.h\">\r\n      <Filter>Header Files\\editors\\AbstractionDefinitionEditor</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"editors\\AbstractionDefinitionEditor\\AbstractionDefinitionSignalRow.h\">\r\n      <Filter>Header Files\\editors\\AbstractionDefinitionEditor</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"editors\\AbstractionDefinitionEditor\\AbstractionTransactionalPortsSortFilter.h\">\r\n      <Filter>Header Files\\editors\\AbstractionDefinitionEditor</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"editors\\AbstractionDefinitionEditor\\AbstractionWirePortsSortFilter.h\">\r\n      <Filter>Header Files\\editors\\AbstractionDefinitionEditor</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"Plugins\\common\\CpuRoutesContainer.h\">\r\n      <Filter>Header Files\\Plugins\\common</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"Plugins\\common\\SingleCpuRoutesContainer.h\">\r\n      <Filter>Header Files\\Plugins\\common</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"editors\\AbstractionDefinitionEditor\\LogicalPortColumns.h\">\r\n      <Filter>Header Files\\editors\\AbstractionDefinitionEditor</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"kactusGenerators\\DocumentGenerator\\MarkdownWriter.h\">\r\n      <Filter>Header Files\\kactusGenerators\\DocumentGenerator</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"kactusGenerators\\DocumentGenerator\\HtmlWriter.h\">\r\n      <Filter>Header Files\\kactusGenerators\\DocumentGenerator</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"kactusGenerators\\DocumentGenerator\\DocumentationWriter.h\">\r\n      <Filter>Header Files\\kactusGenerators\\DocumentGenerator</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"common\\graphicsItems\\ConnectionItem.h\">\r\n      <Filter>Header Files\\common\\graphicsItems</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"editors\\ComponentEditor\\cpus\\RegionColumns.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\cpus</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"editors\\common\\ExpressionSet.h\">\r\n      <Filter>Header Files\\editors\\common</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"editors\\AbstractionDefinitionEditor\\QualifierData.h\">\r\n      <Filter>Header Files\\editors\\AbstractionDefinitionEditor</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"editors\\ComponentEditor\\memoryMaps\\FieldAccessPolicyColumns.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\memoryMaps</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"editors\\ComponentEditor\\busInterfaces\\general\\MirroredMasterModeEditor.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\busInterfaces\\general</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"editors\\ComponentEditor\\busInterfaces\\general\\MirroredInitiatorModeEditor.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\busInterfaces\\general</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"editors\\ComponentEditor\\modes\\ModeColumns.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\modes</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"editors\\ComponentEditor\\modes\\PortSliceColumns.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\modes</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"editors\\ComponentEditor\\modes\\FieldSliceColumns.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\modes</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"common\\widgets\\TreeItemSelector\\TreeItem.h\">\r\n      <Filter>Header Files\\common\\widgets\\TreeItemSelector</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"editors\\ComponentEditor\\common\\MemoryTreeFactory.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\common</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"editors\\ComponentEditor\\powerDomains\\PowerDomainColumns.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\powerDomains</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"editors\\common\\ComponentInstanceEditor\\PowerDomainLinkColumns.h\">\r\n      <Filter>Header Files\\editors\\common\\ComponentInstanceEditor</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"editors\\ComponentEditor\\ports\\PortsEditorFactory.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\ports</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"editors\\ComponentEditor\\ports\\WirePortsEditorFactory.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\ports</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"editors\\ComponentEditor\\ports\\TransactionalPortsEditorFactory.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\ports</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"editors\\ComponentEditor\\ports\\PortSummaryColumns.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\ports</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"editors\\ComponentEditor\\ports\\PortSummaryEditorFactory.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\ports</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"common\\widgets\\GroupBoxWithAlertSign\\StyleOptionGroupBoxWithAlertSign.h\">\r\n      <Filter>Header Files\\common\\widgets\\GroupBoxWithAlertSign</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"editors\\InterconnectGenerator\\InterconnectDataModel.h\">\r\n      <Filter>Header Files\\editors\\InterconnectGenerator</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"editors\\InterconnectGenerator\\InterconnectAddressHelper.h\">\r\n      <Filter>Header Files\\editors\\InterconnectGenerator</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"common\\layouts\\VNoCollisionNoMovementLayout.h\">\r\n      <Filter>Header Files\\common\\layouts</Filter>\r\n    </ClInclude>\r\n  </ItemGroup>\r\n  <ItemGroup>\r\n    <None Include=\"wizards\\common\\IPXactElementComparator.inl\">\r\n      <Filter>Source Files\\wizards\\common</Filter>\r\n    </None>\r\n    <None Include=\"wizards\\common\\ListComparator.inl\">\r\n      <Filter>Source Files\\wizards\\common</Filter>\r\n    </None>\r\n    <None Include=\"common\\graphicsItems\\ConnectionItem.inl\">\r\n      <Filter>Source Files\\common\\graphicsItems</Filter>\r\n    </None>\r\n    <None Include=\"common\\layouts\\VNoCollisionNoMovementLayout.inl\">\r\n      <Filter>Source Files\\common\\layouts</Filter>\r\n    </None>\r\n  </ItemGroup>\r\n  <ItemGroup>\r\n    <Image Include=\"appicon.ico\" />\r\n  </ItemGroup>\r\n  <ItemGroup>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\common\\ExpressionLineEditor.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\common</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\common\\EnumerationEditorConstructorDelegate.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\common</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"common\\widgets\\EnumCollectionEditor\\EnumerationEditor.h\">\r\n      <Filter>Header Files\\common\\widgets\\EnumCollectionEditor</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"common\\widgets\\EnumCollectionEditor\\EnumCollectionEditor.h\">\r\n      <Filter>Header Files\\common\\widgets\\EnumCollectionEditor</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"mainwindow\\WorkspaceSettings.h\">\r\n      <Filter>Header Files\\mainwindow</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"library\\VLNVDialer\\FilterGroup.h\">\r\n      <Filter>Header Files\\library\\VLNVDialer</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"library\\VLNVDialer\\hierarchygroup.h\">\r\n      <Filter>Header Files\\library\\VLNVDialer</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\HWDesign\\AdhocEditor\\AdhocPortEditor.h\">\r\n      <Filter>Header Files\\editors\\HWDesign\\AdhocEditor</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\HWDesign\\AdhocEditor\\AdHocVisibilityDelegate.h\">\r\n      <Filter>Header Files\\editors\\HWDesign\\AdhocEditor</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\HWDesign\\AdhocEditor\\AdHocVisibilityEditor.h\">\r\n      <Filter>Header Files\\editors\\HWDesign\\AdhocEditor</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\referenceCounter\\ParameterReferenceCounter.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\referenceCounter</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\referenceCounter\\ReferenceCounter.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\referenceCounter</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\AbstractionDefinitionEditor\\absdefgroup.h\">\r\n      <Filter>Header Files\\editors\\AbstractionDefinitionEditor</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\AbstractionDefinitionEditor\\AbstractionDefinitionEditor.h\">\r\n      <Filter>Header Files\\editors\\AbstractionDefinitionEditor</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\AbstractionDefinitionEditor\\AbstractionPortsDelegate.h\">\r\n      <Filter>Header Files\\editors\\AbstractionDefinitionEditor</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\AbstractionDefinitionEditor\\AbstractionPortsEditor.h\">\r\n      <Filter>Header Files\\editors\\AbstractionDefinitionEditor</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\AbstractionDefinitionEditor\\AbstractionPortsModel.h\">\r\n      <Filter>Header Files\\editors\\AbstractionDefinitionEditor</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\AbstractionDefinitionEditor\\AbstractionPortsView.h\">\r\n      <Filter>Header Files\\editors\\AbstractionDefinitionEditor</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\AbstractionDefinitionEditor\\AbstractionTransactionalPortsDelegate.h\">\r\n      <Filter>Header Files\\editors\\AbstractionDefinitionEditor</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\AbstractionDefinitionEditor\\AbstractionWirePortsDelegate.h\">\r\n      <Filter>Header Files\\editors\\AbstractionDefinitionEditor</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\common\\DocumentNameGroupEditor.h\">\r\n      <Filter>Header Files\\editors\\common</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"wizards\\BusInterfaceWizard\\BusInterfaceWizardAbsDefinitionPage.h\">\r\n      <Filter>Header Files\\wizards\\BusInterfaceWizard</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\treeStructure\\ComponentEditorTreeDelegate.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\treeStructure</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\AbstractionDefinitionEditor\\QualifierEditor.h\">\r\n      <Filter>Header Files\\editors\\AbstractionDefinitionEditor</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\treeStructure\\SingleCpuItem.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\treeStructure</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\cpus\\SingleCpuEditor.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\cpus</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\cpus\\CpuDetailsEditor.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\cpus</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\cpus\\RegionsModel.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\cpus</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\cpus\\RegionsEditor.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\cpus</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\cpus\\RegionsDelegate.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\cpus</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\memoryMaps\\FieldAccessPoliciesModel.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\memoryMaps</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\memoryMaps\\FieldAccessPoliciesDelegate.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\memoryMaps</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\memoryMaps\\FieldAccessPoliciesEditor.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\memoryMaps</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\common\\ModeReferenceEditor.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\common</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\common\\ModeReferenceDelegate.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\common</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\common\\ModeReferenceModel.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\common</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\busInterfaces\\general\\MasterModeEditor.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\busInterfaces\\general</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\busInterfaces\\general\\ModeEditorBase.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\busInterfaces\\general</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\busInterfaces\\general\\SlaveModeEditor.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\busInterfaces\\general</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\busInterfaces\\general\\MirroredSlaveModeEditor.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\busInterfaces\\general</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\busInterfaces\\general\\MonitorModeEditor.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\busInterfaces\\general</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\busInterfaces\\general\\SystemModeEditor.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\busInterfaces\\general</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\busInterfaces\\general\\InitiatorModeEditor.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\busInterfaces\\general</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\busInterfaces\\general\\TargetModeEditor.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\busInterfaces\\general</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\busInterfaces\\general\\MirroredTargetModeEditor.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\busInterfaces\\general</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\modes\\ModesEditor.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\modes</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\modes\\ModesModel.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\modes</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\modes\\SingleModeEditor.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\modes</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\treeStructure\\ModesItem.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\treeStructure</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\treeStructure\\SingleModeItem.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\treeStructure</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\modes\\PortSliceEditor.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\modes</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\modes\\PortSliceModel.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\modes</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\modes\\PortSliceDelegate.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\modes</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\memoryMaps\\AccessPoliciesEditor.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\treeStructure</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\memoryMaps\\AccessPoliciesModel.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\treeStructure</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\memoryMaps\\AccessPoliciesDelegate.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\treeStructure</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\modes\\FieldSliceModel.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\modes</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\modes\\FieldSliceEditor.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\modes</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"common\\widgets\\TreeItemSelector\\TreeItemEditor.h\">\r\n      <Filter>Header Files\\common\\widgets\\TreeItemSelector</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"common\\widgets\\TreeItemSelector\\TreeItemModel.h\">\r\n      <Filter>Header Files\\common\\widgets\\TreeItemSelector</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\modes\\FieldSliceDelegate.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\modes</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"common\\widgets\\TreeItemSelector\\FramedTreeItemEditor.h\">\r\n      <Filter>Header Files\\common\\widgets\\TreeItemSelector</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"library\\VLNVDialer\\ValidityGroup.h\">\r\n      <Filter>Header Files\\library\\VLNVDialer</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\common\\MemoryAlignScene.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\common</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\cpus\\RegionScene.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\cpus</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\cpus\\CpuVisualizer.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\cpus</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\treeStructure\\SingleIndirectInterfaceItem.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\treeStructure</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\treeStructure\\PowerDomainsItem.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\treeStructure</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\powerDomains\\PowerDomainsEditor.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\powerDomains</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\powerDomains\\PowerDomainsModel.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\powerDomains</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\powerDomains\\PowerDomainsDelegate.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\powerDomains</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\visualization\\AddressableItem.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\visualization</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\treeStructure\\TypeDefinitionsItem.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\treeStructure</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\common\\FloatingModeReferenceEditor.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\common</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\memoryMaps\\RemapModeReferenceEditor.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\memoryMaps</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\common\\ComponentInstanceEditor\\PowerDomainLinkModel.h\">\r\n      <Filter>Header Files\\editors\\common\\ComponentInstanceEditor</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\common\\ComponentInstanceEditor\\PowerDomainLinkEditor.h\">\r\n      <Filter>Header Files\\editors\\common\\ComponentInstanceEditor</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\common\\ComponentInstanceEditor\\PowerDomainLinkDelegate.h\">\r\n      <Filter>Header Files\\editors\\common\\ComponentInstanceEditor</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\treeStructure\\WirePortsItem.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\treeStructure</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\treeStructure\\TransactionalPortsItem.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\treeStructure</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\ports\\TypedPortEditor.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\ports</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\ports\\PortSummaryModel.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\ports</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\ports\\PortSummaryFilter.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\ports</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\ports\\PortSummaryDelegate.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\ports</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\ports\\PortSummaryView.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\ports</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"library\\VLNVDialer\\RevisionGroup.h\">\r\n      <Filter>Header Files\\library\\VLNVDialer</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\ports\\TypedPortsView.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\ports</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"common\\widgets\\GroupBoxWithAlertSign\\StyleGroupBoxWithAlertSign.h\">\r\n      <Filter>Header Files\\common\\widgets\\GroupBoxWithAlertSign</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"common\\widgets\\GroupBoxWithAlertSign\\GroupBoxWithAlertSign.h\">\r\n      <Filter>Header Files\\common\\widgets\\GroupBoxWithAlertSign</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\BusDefinitionEditor\\BusDefinitionParameterReferenceTree.h\">\r\n      <Filter>Header Files\\editors\\BusDefinitionEditor</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\AbstractionDefinitionEditor\\AbsDefParameterReferenceTree.h\">\r\n      <Filter>Header Files\\editors\\AbstractionDefinitionEditor</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\AbstractionDefinitionEditor\\AbsDefParameterReferenceCounter.h\">\r\n      <Filter>Header Files\\editors\\AbstractionDefinitionEditor</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\ports\\PortsImportSummaryEditor.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\ports</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\InterconnectGenerator\\InterconnectGeneratorDialog.h\">\r\n      <Filter>Header Files\\editors\\InterconnectGenerator</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"common\\widgets\\EnumCollectionEditor\\InterfaceEnumEditor.h\">\r\n      <Filter>Header Files\\common\\widgets\\EnumCollectionEditor</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"common\\widgets\\instanceWidgets\\InstanceWidgets.h\">\r\n      <Filter>Source Files\\common\\widgets\\instanceWidgets</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\interconnectgenerator\\InstanceInterfacesEditor.h\">\r\n      <Filter>Header Files\\editors\\InterconnectGenerator</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"Plugins\\PluginSystem\\GeneratorPlugin\\AddToFilesetWidget.h\">\r\n      <Filter>Header Files\\Plugins\\common</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"editors\\ComponentEditor\\parameters\\LockableParametersModel.h\">\r\n      <Filter>Header Files\\editors\\ComponentEditor\\parameters</Filter>\r\n    </QtMoc>\r\n  </ItemGroup>\r\n</Project>"
  },
  {
    "path": "Kactus2_Solution.pro",
    "content": "# ----------------------------------------------------\r\n# This file is generated by the Qt Visual Studio Add-in.\r\n# ------------------------------------------------------\r\n\r\nTEMPLATE = subdirs\r\n\r\nSUBDIRS = \\\r\n    IPXACTmodels \\\r\n    KactusAPI \\\r\n    Kactus2 \\\r\n    PythonAPI \\\r\n    MCAPICodeGenerator \\\r\n    CppSourceAnalyzer \\\r\n    VHDLSourceAnalyzer \\\r\n    MemoryMapHeaderGenerator \\\r\n    ModelSimGenerator \\\r\n    AlteraBSPGenerator \\\r\n    QuartusPinImportPlugin \\\r\n    PadsPartGenerator \\\r\n    MakefileGenerator \\\r\n    VerilogGeneratorPlugin \\\r\n    VHDLGenerator \\\r\n    VHDLimport \\\r\n    VerilogImport \\\r\n    VerilogIncludeImport \\\r\n    VerilogSourceAnalyzer \\\r\n    QuartusProjectGenerator \\\r\n    MemoryViewGenerator \\\r\n    LinuxDeviceTreeGenerator \\\r\n    SVDGenerator \\\r\n\tRenodeGenerator\r\n\r\nCONFIG(test) {\r\n    SUBDIRS += test_all\r\n}\r\n\r\nIPXACTmodels.subdir = IPXACTmodels\r\n\r\nKactus2.file = Kactus2.pro\r\nKactus2.depends = IPXACTmodels KactusAPI\r\nKactus2.makefile = Makefile.Kactus2\r\n\r\nKactusAPI.subdir = KactusAPI\r\nKactusAPI.depends = IPXACTmodels\r\n\r\nPythonAPI.subdir = PythonAPI\r\nPythonAPI.depends = IPXACTmodels KactusAPI\r\n\r\nMCAPICodeGenerator.subdir = Plugins/MCAPICodeGenerator\r\nMCAPICodeGenerator.depends = IPXACTmodels KactusAPI\r\n\r\nCppSourceAnalyzer.subdir = Plugins/CppSourceAnalyzer\r\nCppSourceAnalyzer.depends = IPXACTmodels\r\n\r\nVHDLSourceAnalyzer.file = Plugins/VHDLAnalyzer/VHDLSourceAnalyzer.pro\r\nVHDLSourceAnalyzer.depends = IPXACTmodels KactusAPI\r\n\r\nMemoryMapHeaderGenerator.subdir = Plugins/MemoryMapHeaderGenerator\r\nMemoryMapHeaderGenerator.depends = IPXACTmodels KactusAPI\r\n\r\nModelSimGenerator.subdir = Plugins/ModelSimGenerator\r\nModelSimGenerator.depends = IPXACTmodels KactusAPI\r\n\r\nAlteraBSPGenerator.subdir = Plugins/AlteraBSPGenerator\r\nAlteraBSPGenerator.depends = IPXACTmodels\r\n\r\nQuartusPinImportPlugin.subdir = Plugins/QuartusPinImportPlugin\r\nQuartusPinImportPlugin.depends = IPXACTmodels\r\n\r\nPadsPartGenerator.subdir = Plugins/PadsPartGenerator\r\nPadsPartGenerator.depends = IPXACTmodels KactusAPI\r\n\r\nMakefileGenerator.subdir = Plugins/MakefileGenerator\r\nMakefileGenerator.depends = IPXACTmodels KactusAPI\r\n\r\nVerilogGeneratorPlugin.file = Plugins/VerilogGenerator/VerilogGeneratorPlugin.pro\r\nVerilogGeneratorPlugin.depends = IPXACTmodels KactusAPI\r\n\r\nVHDLGenerator.subdir = Plugins/VHDLGenerator\r\nVHDLGenerator.depends = IPXACTmodels KactusAPI\r\n\r\nVHDLimport.subdir = Plugins/VHDLimport\r\nVHDLimport.depends = IPXACTmodels\r\n\r\nVerilogImport.subdir = Plugins/VerilogImport\r\nVerilogImport.depends = IPXACTmodels KactusAPI\r\n\r\nVerilogIncludeImport.subdir = Plugins/VerilogIncludeImport\r\nVerilogIncludeImport.depends = IPXACTmodels\r\n\r\nVerilogSourceAnalyzer.subdir = Plugins/VerilogSourceAnalyzer\r\nVerilogSourceAnalyzer.depends = IPXACTmodels\r\n\r\nQuartusProjectGenerator.subdir = Plugins/QuartusProjectGenerator\r\nQuartusProjectGenerator.depends = IPXACTmodels\r\n\r\nMemoryViewGenerator.subdir = Plugins/MemoryViewGenerator\r\nMemoryViewGenerator.depends = IPXACTmodels KactusAPI\r\n\r\nLinuxDeviceTreeGenerator.file = Plugins/LinuxDeviceTree/LinuxDeviceTreeGenerator.pro\r\nLinuxDeviceTreeGenerator.depends = IPXACTmodels KactusAPI\r\n\r\nSVDGenerator.file = Plugins/SVDGenerator/SVDGeneratorPlugin.pro\r\nSVDGenerator.depends = IPXACTmodels KactusAPI\r\n\r\nRenodeGenerator.file = Plugins/RenodeGenerator/RenodeGeneratorPlugin.pro\r\nRenodeGenerator.depends = IPXACTmodels KactusAPI\r\n\r\ntest_all.file = tests/test_all.pro\r\ntest_all.depends = IPXACTmodels KactusAPI\r\n\r\n"
  },
  {
    "path": "Kactus2_Solution_vs2022.sln",
    "content": "﻿\r\nMicrosoft Visual Studio Solution File, Format Version 12.00\r\n# Visual Studio Version 17\r\nVisualStudioVersion = 17.2.32602.215\r\nMinimumVisualStudioVersion = 10.0.40219.1\r\nProject(\"{2150E333-8FDC-42A3-9474-1A3956D46DE8}\") = \"Plugins\", \"Plugins\", \"{90EC3FAA-DA36-47D5-97B5-9D463272C406}\"\r\nEndProject\r\nProject(\"{2150E333-8FDC-42A3-9474-1A3956D46DE8}\") = \"Libraries\", \"Libraries\", \"{9AC1D5FF-D209-4186-8C80-027639ACC2A3}\"\r\nEndProject\r\nProject(\"{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}\") = \"Kactus2\", \"Kactus2.vcxproj\", \"{09486B51-70A7-3073-B15B-6D4BAF3EC8C6}\"\r\n\tProjectSection(ProjectDependencies) = postProject\r\n\t\t{3B9FF5B3-3B2B-4294-B6E3-D8E9885B6B8A} = {3B9FF5B3-3B2B-4294-B6E3-D8E9885B6B8A}\r\n\t\t{5C0CA59D-CFCE-49C6-B62A-9E3065CA34DD} = {5C0CA59D-CFCE-49C6-B62A-9E3065CA34DD}\r\n\tEndProjectSection\r\nEndProject\r\nProject(\"{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}\") = \"CppSourceAnalyzer\", \"Plugins\\CppSourceAnalyzer\\CppSourceAnalyzer.vcxproj\", \"{D47FBAF4-1642-4F73-837C-F289DCB9E8FE}\"\r\n\tProjectSection(ProjectDependencies) = postProject\r\n\t\t{3B9FF5B3-3B2B-4294-B6E3-D8E9885B6B8A} = {3B9FF5B3-3B2B-4294-B6E3-D8E9885B6B8A}\r\n\t\t{5C0CA59D-CFCE-49C6-B62A-9E3065CA34DD} = {5C0CA59D-CFCE-49C6-B62A-9E3065CA34DD}\r\n\tEndProjectSection\r\nEndProject\r\nProject(\"{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}\") = \"VHDLSourceAnalyzer\", \"Plugins\\VHDLAnalyzer\\VHDLSourceAnalyzer.vcxproj\", \"{FD8026D5-50C6-4D30-B082-899FA4226C48}\"\r\n\tProjectSection(ProjectDependencies) = postProject\r\n\t\t{5C0CA59D-CFCE-49C6-B62A-9E3065CA34DD} = {5C0CA59D-CFCE-49C6-B62A-9E3065CA34DD}\r\n\tEndProjectSection\r\nEndProject\r\nProject(\"{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}\") = \"MemoryMapHeaderGenerator\", \"Plugins\\MemoryMapHeaderGenerator\\MemoryMapHeaderGenerator.vcxproj\", \"{C846486D-4A9D-4212-89A8-D25BEFED7FC5}\"\r\n\tProjectSection(ProjectDependencies) = postProject\r\n\t\t{3B9FF5B3-3B2B-4294-B6E3-D8E9885B6B8A} = {3B9FF5B3-3B2B-4294-B6E3-D8E9885B6B8A}\r\n\t\t{5C0CA59D-CFCE-49C6-B62A-9E3065CA34DD} = {5C0CA59D-CFCE-49C6-B62A-9E3065CA34DD}\r\n\tEndProjectSection\r\nEndProject\r\nProject(\"{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}\") = \"AlteraBSPGenerator\", \"Plugins\\AlteraBSPGenerator\\AlteraBSPGenerator.vcxproj\", \"{16C73FC5-A179-4B2C-983C-59B9D1431703}\"\r\n\tProjectSection(ProjectDependencies) = postProject\r\n\t\t{5C0CA59D-CFCE-49C6-B62A-9E3065CA34DD} = {5C0CA59D-CFCE-49C6-B62A-9E3065CA34DD}\r\n\tEndProjectSection\r\nEndProject\r\nProject(\"{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}\") = \"MCAPICodeGenerator\", \"Plugins\\MCAPICodeGenerator\\MCAPICodeGenerator.vcxproj\", \"{AA63BE2D-A701-4C68-9760-C71655FFE66D}\"\r\n\tProjectSection(ProjectDependencies) = postProject\r\n\t\t{5C0CA59D-CFCE-49C6-B62A-9E3065CA34DD} = {5C0CA59D-CFCE-49C6-B62A-9E3065CA34DD}\r\n\tEndProjectSection\r\nEndProject\r\nProject(\"{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}\") = \"PadsPartGenerator\", \"Plugins\\PadsPartGenerator\\PadsPartGenerator.vcxproj\", \"{A84E0600-2A1B-4593-9D89-25098A0150AA}\"\r\n\tProjectSection(ProjectDependencies) = postProject\r\n\t\t{3B9FF5B3-3B2B-4294-B6E3-D8E9885B6B8A} = {3B9FF5B3-3B2B-4294-B6E3-D8E9885B6B8A}\r\n\t\t{5C0CA59D-CFCE-49C6-B62A-9E3065CA34DD} = {5C0CA59D-CFCE-49C6-B62A-9E3065CA34DD}\r\n\tEndProjectSection\r\nEndProject\r\nProject(\"{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}\") = \"QuartusPinImportPlugin\", \"Plugins\\QuartusPinImportPlugin\\QuartusPinImportPlugin.vcxproj\", \"{C0DBF909-F12F-473F-8AC3-2248ABA68B92}\"\r\n\tProjectSection(ProjectDependencies) = postProject\r\n\t\t{5C0CA59D-CFCE-49C6-B62A-9E3065CA34DD} = {5C0CA59D-CFCE-49C6-B62A-9E3065CA34DD}\r\n\tEndProjectSection\r\nEndProject\r\nProject(\"{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}\") = \"VerilogGeneratorPlugin\", \"Plugins\\VerilogGenerator\\VerilogGeneratorPlugin.vcxproj\", \"{DF1D0F97-B7D8-4DF3-AB71-B2350E08F0F4}\"\r\n\tProjectSection(ProjectDependencies) = postProject\r\n\t\t{3B9FF5B3-3B2B-4294-B6E3-D8E9885B6B8A} = {3B9FF5B3-3B2B-4294-B6E3-D8E9885B6B8A}\r\n\t\t{5C0CA59D-CFCE-49C6-B62A-9E3065CA34DD} = {5C0CA59D-CFCE-49C6-B62A-9E3065CA34DD}\r\n\tEndProjectSection\r\nEndProject\r\nProject(\"{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}\") = \"MakefileGenerator\", \"Plugins\\MakefileGenerator\\MakefileGenerator.vcxproj\", \"{7ED945F7-9538-4306-A770-4A186327F8BF}\"\r\n\tProjectSection(ProjectDependencies) = postProject\r\n\t\t{3B9FF5B3-3B2B-4294-B6E3-D8E9885B6B8A} = {3B9FF5B3-3B2B-4294-B6E3-D8E9885B6B8A}\r\n\t\t{5C0CA59D-CFCE-49C6-B62A-9E3065CA34DD} = {5C0CA59D-CFCE-49C6-B62A-9E3065CA34DD}\r\n\tEndProjectSection\r\nEndProject\r\nProject(\"{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}\") = \"VHDLimport\", \"Plugins\\VHDLimport\\VHDLimport.vcxproj\", \"{939C5230-35C3-455B-98F6-51E47E9E3DBB}\"\r\n\tProjectSection(ProjectDependencies) = postProject\r\n\t\t{5C0CA59D-CFCE-49C6-B62A-9E3065CA34DD} = {5C0CA59D-CFCE-49C6-B62A-9E3065CA34DD}\r\n\tEndProjectSection\r\nEndProject\r\nProject(\"{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}\") = \"VerilogImport\", \"Plugins\\VerilogImport\\VerilogImport.vcxproj\", \"{85A166AC-D2CF-496C-9EFD-648765C4AC72}\"\r\n\tProjectSection(ProjectDependencies) = postProject\r\n\t\t{3B9FF5B3-3B2B-4294-B6E3-D8E9885B6B8A} = {3B9FF5B3-3B2B-4294-B6E3-D8E9885B6B8A}\r\n\t\t{5C0CA59D-CFCE-49C6-B62A-9E3065CA34DD} = {5C0CA59D-CFCE-49C6-B62A-9E3065CA34DD}\r\n\tEndProjectSection\r\nEndProject\r\nProject(\"{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}\") = \"VerilogIncludeImport\", \"Plugins\\VerilogIncludeImport\\VerilogIncludeImport.vcxproj\", \"{2480AD41-D429-460B-9DAC-B1BA784F0FE1}\"\r\n\tProjectSection(ProjectDependencies) = postProject\r\n\t\t{5C0CA59D-CFCE-49C6-B62A-9E3065CA34DD} = {5C0CA59D-CFCE-49C6-B62A-9E3065CA34DD}\r\n\tEndProjectSection\r\nEndProject\r\nProject(\"{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}\") = \"VerilogSourceAnalyzer\", \"Plugins\\VerilogSourceAnalyzer\\VerilogSourceAnalyzer.vcxproj\", \"{537BFE8E-F268-4BED-8CF0-0E5C2A630F0F}\"\r\n\tProjectSection(ProjectDependencies) = postProject\r\n\t\t{5C0CA59D-CFCE-49C6-B62A-9E3065CA34DD} = {5C0CA59D-CFCE-49C6-B62A-9E3065CA34DD}\r\n\tEndProjectSection\r\nEndProject\r\nProject(\"{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}\") = \"QuartusProjectGenerator\", \"Plugins\\QuartusProjectGenerator\\QuartusProjectGenerator.vcxproj\", \"{19FABF05-9AD2-4437-84E9-5A60DF6E7BAE}\"\r\n\tProjectSection(ProjectDependencies) = postProject\r\n\t\t{5C0CA59D-CFCE-49C6-B62A-9E3065CA34DD} = {5C0CA59D-CFCE-49C6-B62A-9E3065CA34DD}\r\n\tEndProjectSection\r\nEndProject\r\nProject(\"{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}\") = \"ModelSimGenerator\", \"Plugins\\ModelSimGenerator\\ModelSimGenerator.vcxproj\", \"{09C39723-AF6B-4F3B-81C7-3233E7F8A22E}\"\r\n\tProjectSection(ProjectDependencies) = postProject\r\n\t\t{3B9FF5B3-3B2B-4294-B6E3-D8E9885B6B8A} = {3B9FF5B3-3B2B-4294-B6E3-D8E9885B6B8A}\r\n\t\t{5C0CA59D-CFCE-49C6-B62A-9E3065CA34DD} = {5C0CA59D-CFCE-49C6-B62A-9E3065CA34DD}\r\n\tEndProjectSection\r\nEndProject\r\nProject(\"{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}\") = \"MemoryViewGenerator\", \"Plugins\\MemoryViewGenerator\\MemoryViewGenerator.vcxproj\", \"{8FC8D073-3D03-4DE6-8605-D906431FF5E8}\"\r\n\tProjectSection(ProjectDependencies) = postProject\r\n\t\t{3B9FF5B3-3B2B-4294-B6E3-D8E9885B6B8A} = {3B9FF5B3-3B2B-4294-B6E3-D8E9885B6B8A}\r\n\t\t{5C0CA59D-CFCE-49C6-B62A-9E3065CA34DD} = {5C0CA59D-CFCE-49C6-B62A-9E3065CA34DD}\r\n\tEndProjectSection\r\nEndProject\r\nProject(\"{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}\") = \"VHDLGenerator\", \"Plugins\\VHDLGenerator\\VHDLGenerator.vcxproj\", \"{733888AA-F653-4A92-817D-25EE4AB2BE54}\"\r\n\tProjectSection(ProjectDependencies) = postProject\r\n\t\t{3B9FF5B3-3B2B-4294-B6E3-D8E9885B6B8A} = {3B9FF5B3-3B2B-4294-B6E3-D8E9885B6B8A}\r\n\t\t{5C0CA59D-CFCE-49C6-B62A-9E3065CA34DD} = {5C0CA59D-CFCE-49C6-B62A-9E3065CA34DD}\r\n\tEndProjectSection\r\nEndProject\r\nProject(\"{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}\") = \"IPXACTmodels\", \"IPXACTmodels\\IPXACTmodels.vcxproj\", \"{5C0CA59D-CFCE-49C6-B62A-9E3065CA34DD}\"\r\nEndProject\r\nProject(\"{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}\") = \"LinuxDeviceTreeGenerator\", \"Plugins\\LinuxDeviceTree\\LinuxDeviceTreeGenerator.vcxproj\", \"{E5EC0C47-17DE-4E2F-8F13-731D5EECB70B}\"\r\n\tProjectSection(ProjectDependencies) = postProject\r\n\t\t{3B9FF5B3-3B2B-4294-B6E3-D8E9885B6B8A} = {3B9FF5B3-3B2B-4294-B6E3-D8E9885B6B8A}\r\n\tEndProjectSection\r\nEndProject\r\nProject(\"{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}\") = \"SVDGeneratorPlugin\", \"Plugins\\SVDGenerator\\SVDGeneratorPlugin.vcxproj\", \"{81A006F2-4FC4-4187-93E9-98C5EB8523C3}\"\r\n\tProjectSection(ProjectDependencies) = postProject\r\n\t\t{3B9FF5B3-3B2B-4294-B6E3-D8E9885B6B8A} = {3B9FF5B3-3B2B-4294-B6E3-D8E9885B6B8A}\r\n\t\t{5C0CA59D-CFCE-49C6-B62A-9E3065CA34DD} = {5C0CA59D-CFCE-49C6-B62A-9E3065CA34DD}\r\n\tEndProjectSection\r\nEndProject\r\nProject(\"{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}\") = \"PythonAPI\", \"PythonAPI\\PythonAPI.vcxproj\", \"{E8D9DD36-B0CA-4043-9B08-CEA96BED5266}\"\r\n\tProjectSection(ProjectDependencies) = postProject\r\n\t\t{3B9FF5B3-3B2B-4294-B6E3-D8E9885B6B8A} = {3B9FF5B3-3B2B-4294-B6E3-D8E9885B6B8A}\r\n\t\t{5C0CA59D-CFCE-49C6-B62A-9E3065CA34DD} = {5C0CA59D-CFCE-49C6-B62A-9E3065CA34DD}\r\n\tEndProjectSection\r\nEndProject\r\nProject(\"{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}\") = \"KactusAPI\", \"KactusAPI\\KactusAPI.vcxproj\", \"{3B9FF5B3-3B2B-4294-B6E3-D8E9885B6B8A}\"\r\n\tProjectSection(ProjectDependencies) = postProject\r\n\t\t{5C0CA59D-CFCE-49C6-B62A-9E3065CA34DD} = {5C0CA59D-CFCE-49C6-B62A-9E3065CA34DD}\r\n\tEndProjectSection\r\nEndProject\r\nProject(\"{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}\") = \"RenodeGeneratorPlugin\", \"Plugins\\RenodeGenerator\\RenodeGeneratorPlugin.vcxproj\", \"{57BB9FA6-BA0C-4E70-83B3-DD973FED0FB4}\"\r\n\tProjectSection(ProjectDependencies) = postProject\r\n\t\t{3B9FF5B3-3B2B-4294-B6E3-D8E9885B6B8A} = {3B9FF5B3-3B2B-4294-B6E3-D8E9885B6B8A}\r\n\t\t{5C0CA59D-CFCE-49C6-B62A-9E3065CA34DD} = {5C0CA59D-CFCE-49C6-B62A-9E3065CA34DD}\r\n\tEndProjectSection\r\nEndProject\r\nGlobal\r\n\tGlobalSection(SolutionConfigurationPlatforms) = preSolution\r\n\t\tDebug|x64 = Debug|x64\r\n\t\tRelease|x64 = Release|x64\r\n\t\tTemplate|x64 = Template|x64\r\n\tEndGlobalSection\r\n\tGlobalSection(ProjectConfigurationPlatforms) = postSolution\r\n\t\t{09486B51-70A7-3073-B15B-6D4BAF3EC8C6}.Debug|x64.ActiveCfg = Debug|x64\r\n\t\t{09486B51-70A7-3073-B15B-6D4BAF3EC8C6}.Debug|x64.Build.0 = Debug|x64\r\n\t\t{09486B51-70A7-3073-B15B-6D4BAF3EC8C6}.Debug|x64.Deploy.0 = Debug|x64\r\n\t\t{09486B51-70A7-3073-B15B-6D4BAF3EC8C6}.Release|x64.ActiveCfg = Release|x64\r\n\t\t{09486B51-70A7-3073-B15B-6D4BAF3EC8C6}.Release|x64.Build.0 = Release|x64\r\n\t\t{09486B51-70A7-3073-B15B-6D4BAF3EC8C6}.Release|x64.Deploy.0 = Release|x64\r\n\t\t{09486B51-70A7-3073-B15B-6D4BAF3EC8C6}.Template|x64.ActiveCfg = Template|x64\r\n\t\t{09486B51-70A7-3073-B15B-6D4BAF3EC8C6}.Template|x64.Build.0 = Template|x64\r\n\t\t{09486B51-70A7-3073-B15B-6D4BAF3EC8C6}.Template|x64.Deploy.0 = Template|x64\r\n\t\t{D47FBAF4-1642-4F73-837C-F289DCB9E8FE}.Debug|x64.ActiveCfg = Debug|x64\r\n\t\t{D47FBAF4-1642-4F73-837C-F289DCB9E8FE}.Debug|x64.Build.0 = Debug|x64\r\n\t\t{D47FBAF4-1642-4F73-837C-F289DCB9E8FE}.Debug|x64.Deploy.0 = Debug|x64\r\n\t\t{D47FBAF4-1642-4F73-837C-F289DCB9E8FE}.Release|x64.ActiveCfg = Release|x64\r\n\t\t{D47FBAF4-1642-4F73-837C-F289DCB9E8FE}.Release|x64.Build.0 = Release|x64\r\n\t\t{D47FBAF4-1642-4F73-837C-F289DCB9E8FE}.Release|x64.Deploy.0 = Release|x64\r\n\t\t{D47FBAF4-1642-4F73-837C-F289DCB9E8FE}.Template|x64.ActiveCfg = Template|x64\r\n\t\t{D47FBAF4-1642-4F73-837C-F289DCB9E8FE}.Template|x64.Build.0 = Template|x64\r\n\t\t{D47FBAF4-1642-4F73-837C-F289DCB9E8FE}.Template|x64.Deploy.0 = Template|x64\r\n\t\t{FD8026D5-50C6-4D30-B082-899FA4226C48}.Debug|x64.ActiveCfg = Debug|x64\r\n\t\t{FD8026D5-50C6-4D30-B082-899FA4226C48}.Debug|x64.Build.0 = Debug|x64\r\n\t\t{FD8026D5-50C6-4D30-B082-899FA4226C48}.Debug|x64.Deploy.0 = Debug|x64\r\n\t\t{FD8026D5-50C6-4D30-B082-899FA4226C48}.Release|x64.ActiveCfg = Release|x64\r\n\t\t{FD8026D5-50C6-4D30-B082-899FA4226C48}.Release|x64.Build.0 = Release|x64\r\n\t\t{FD8026D5-50C6-4D30-B082-899FA4226C48}.Release|x64.Deploy.0 = Release|x64\r\n\t\t{FD8026D5-50C6-4D30-B082-899FA4226C48}.Template|x64.ActiveCfg = Template|x64\r\n\t\t{FD8026D5-50C6-4D30-B082-899FA4226C48}.Template|x64.Build.0 = Template|x64\r\n\t\t{FD8026D5-50C6-4D30-B082-899FA4226C48}.Template|x64.Deploy.0 = Template|x64\r\n\t\t{C846486D-4A9D-4212-89A8-D25BEFED7FC5}.Debug|x64.ActiveCfg = Debug|x64\r\n\t\t{C846486D-4A9D-4212-89A8-D25BEFED7FC5}.Debug|x64.Build.0 = Debug|x64\r\n\t\t{C846486D-4A9D-4212-89A8-D25BEFED7FC5}.Debug|x64.Deploy.0 = Debug|x64\r\n\t\t{C846486D-4A9D-4212-89A8-D25BEFED7FC5}.Release|x64.ActiveCfg = Release|x64\r\n\t\t{C846486D-4A9D-4212-89A8-D25BEFED7FC5}.Release|x64.Build.0 = Release|x64\r\n\t\t{C846486D-4A9D-4212-89A8-D25BEFED7FC5}.Release|x64.Deploy.0 = Release|x64\r\n\t\t{C846486D-4A9D-4212-89A8-D25BEFED7FC5}.Template|x64.ActiveCfg = Release|x64\r\n\t\t{C846486D-4A9D-4212-89A8-D25BEFED7FC5}.Template|x64.Build.0 = Release|x64\r\n\t\t{C846486D-4A9D-4212-89A8-D25BEFED7FC5}.Template|x64.Deploy.0 = Release|x64\r\n\t\t{16C73FC5-A179-4B2C-983C-59B9D1431703}.Debug|x64.ActiveCfg = Debug|x64\r\n\t\t{16C73FC5-A179-4B2C-983C-59B9D1431703}.Debug|x64.Build.0 = Debug|x64\r\n\t\t{16C73FC5-A179-4B2C-983C-59B9D1431703}.Debug|x64.Deploy.0 = Debug|x64\r\n\t\t{16C73FC5-A179-4B2C-983C-59B9D1431703}.Release|x64.ActiveCfg = Release|x64\r\n\t\t{16C73FC5-A179-4B2C-983C-59B9D1431703}.Release|x64.Build.0 = Release|x64\r\n\t\t{16C73FC5-A179-4B2C-983C-59B9D1431703}.Release|x64.Deploy.0 = Release|x64\r\n\t\t{16C73FC5-A179-4B2C-983C-59B9D1431703}.Template|x64.ActiveCfg = Release|x64\r\n\t\t{16C73FC5-A179-4B2C-983C-59B9D1431703}.Template|x64.Build.0 = Release|x64\r\n\t\t{16C73FC5-A179-4B2C-983C-59B9D1431703}.Template|x64.Deploy.0 = Release|x64\r\n\t\t{AA63BE2D-A701-4C68-9760-C71655FFE66D}.Debug|x64.ActiveCfg = Debug|x64\r\n\t\t{AA63BE2D-A701-4C68-9760-C71655FFE66D}.Debug|x64.Build.0 = Debug|x64\r\n\t\t{AA63BE2D-A701-4C68-9760-C71655FFE66D}.Debug|x64.Deploy.0 = Debug|x64\r\n\t\t{AA63BE2D-A701-4C68-9760-C71655FFE66D}.Release|x64.ActiveCfg = Release|x64\r\n\t\t{AA63BE2D-A701-4C68-9760-C71655FFE66D}.Release|x64.Build.0 = Release|x64\r\n\t\t{AA63BE2D-A701-4C68-9760-C71655FFE66D}.Release|x64.Deploy.0 = Release|x64\r\n\t\t{AA63BE2D-A701-4C68-9760-C71655FFE66D}.Template|x64.ActiveCfg = Template|x64\r\n\t\t{AA63BE2D-A701-4C68-9760-C71655FFE66D}.Template|x64.Build.0 = Template|x64\r\n\t\t{AA63BE2D-A701-4C68-9760-C71655FFE66D}.Template|x64.Deploy.0 = Template|x64\r\n\t\t{A84E0600-2A1B-4593-9D89-25098A0150AA}.Debug|x64.ActiveCfg = Debug|x64\r\n\t\t{A84E0600-2A1B-4593-9D89-25098A0150AA}.Debug|x64.Build.0 = Debug|x64\r\n\t\t{A84E0600-2A1B-4593-9D89-25098A0150AA}.Debug|x64.Deploy.0 = Debug|x64\r\n\t\t{A84E0600-2A1B-4593-9D89-25098A0150AA}.Release|x64.ActiveCfg = Release|x64\r\n\t\t{A84E0600-2A1B-4593-9D89-25098A0150AA}.Release|x64.Build.0 = Release|x64\r\n\t\t{A84E0600-2A1B-4593-9D89-25098A0150AA}.Release|x64.Deploy.0 = Release|x64\r\n\t\t{A84E0600-2A1B-4593-9D89-25098A0150AA}.Template|x64.ActiveCfg = Release|x64\r\n\t\t{A84E0600-2A1B-4593-9D89-25098A0150AA}.Template|x64.Build.0 = Release|x64\r\n\t\t{A84E0600-2A1B-4593-9D89-25098A0150AA}.Template|x64.Deploy.0 = Release|x64\r\n\t\t{C0DBF909-F12F-473F-8AC3-2248ABA68B92}.Debug|x64.ActiveCfg = Debug|x64\r\n\t\t{C0DBF909-F12F-473F-8AC3-2248ABA68B92}.Debug|x64.Build.0 = Debug|x64\r\n\t\t{C0DBF909-F12F-473F-8AC3-2248ABA68B92}.Debug|x64.Deploy.0 = Debug|x64\r\n\t\t{C0DBF909-F12F-473F-8AC3-2248ABA68B92}.Release|x64.ActiveCfg = Release|x64\r\n\t\t{C0DBF909-F12F-473F-8AC3-2248ABA68B92}.Release|x64.Build.0 = Release|x64\r\n\t\t{C0DBF909-F12F-473F-8AC3-2248ABA68B92}.Release|x64.Deploy.0 = Release|x64\r\n\t\t{C0DBF909-F12F-473F-8AC3-2248ABA68B92}.Template|x64.ActiveCfg = Release|x64\r\n\t\t{C0DBF909-F12F-473F-8AC3-2248ABA68B92}.Template|x64.Build.0 = Release|x64\r\n\t\t{C0DBF909-F12F-473F-8AC3-2248ABA68B92}.Template|x64.Deploy.0 = Release|x64\r\n\t\t{DF1D0F97-B7D8-4DF3-AB71-B2350E08F0F4}.Debug|x64.ActiveCfg = Debug|x64\r\n\t\t{DF1D0F97-B7D8-4DF3-AB71-B2350E08F0F4}.Debug|x64.Build.0 = Debug|x64\r\n\t\t{DF1D0F97-B7D8-4DF3-AB71-B2350E08F0F4}.Debug|x64.Deploy.0 = Debug|x64\r\n\t\t{DF1D0F97-B7D8-4DF3-AB71-B2350E08F0F4}.Release|x64.ActiveCfg = Release|x64\r\n\t\t{DF1D0F97-B7D8-4DF3-AB71-B2350E08F0F4}.Release|x64.Build.0 = Release|x64\r\n\t\t{DF1D0F97-B7D8-4DF3-AB71-B2350E08F0F4}.Release|x64.Deploy.0 = Release|x64\r\n\t\t{DF1D0F97-B7D8-4DF3-AB71-B2350E08F0F4}.Template|x64.ActiveCfg = Release|x64\r\n\t\t{DF1D0F97-B7D8-4DF3-AB71-B2350E08F0F4}.Template|x64.Build.0 = Release|x64\r\n\t\t{DF1D0F97-B7D8-4DF3-AB71-B2350E08F0F4}.Template|x64.Deploy.0 = Release|x64\r\n\t\t{7ED945F7-9538-4306-A770-4A186327F8BF}.Debug|x64.ActiveCfg = Debug|x64\r\n\t\t{7ED945F7-9538-4306-A770-4A186327F8BF}.Debug|x64.Build.0 = Debug|x64\r\n\t\t{7ED945F7-9538-4306-A770-4A186327F8BF}.Debug|x64.Deploy.0 = Debug|x64\r\n\t\t{7ED945F7-9538-4306-A770-4A186327F8BF}.Release|x64.ActiveCfg = Release|x64\r\n\t\t{7ED945F7-9538-4306-A770-4A186327F8BF}.Release|x64.Build.0 = Release|x64\r\n\t\t{7ED945F7-9538-4306-A770-4A186327F8BF}.Release|x64.Deploy.0 = Release|x64\r\n\t\t{7ED945F7-9538-4306-A770-4A186327F8BF}.Template|x64.ActiveCfg = Release|x64\r\n\t\t{7ED945F7-9538-4306-A770-4A186327F8BF}.Template|x64.Build.0 = Release|x64\r\n\t\t{7ED945F7-9538-4306-A770-4A186327F8BF}.Template|x64.Deploy.0 = Release|x64\r\n\t\t{939C5230-35C3-455B-98F6-51E47E9E3DBB}.Debug|x64.ActiveCfg = Debug|x64\r\n\t\t{939C5230-35C3-455B-98F6-51E47E9E3DBB}.Debug|x64.Build.0 = Debug|x64\r\n\t\t{939C5230-35C3-455B-98F6-51E47E9E3DBB}.Debug|x64.Deploy.0 = Debug|x64\r\n\t\t{939C5230-35C3-455B-98F6-51E47E9E3DBB}.Release|x64.ActiveCfg = Release|x64\r\n\t\t{939C5230-35C3-455B-98F6-51E47E9E3DBB}.Release|x64.Build.0 = Release|x64\r\n\t\t{939C5230-35C3-455B-98F6-51E47E9E3DBB}.Release|x64.Deploy.0 = Release|x64\r\n\t\t{939C5230-35C3-455B-98F6-51E47E9E3DBB}.Template|x64.ActiveCfg = Release|x64\r\n\t\t{939C5230-35C3-455B-98F6-51E47E9E3DBB}.Template|x64.Build.0 = Release|x64\r\n\t\t{939C5230-35C3-455B-98F6-51E47E9E3DBB}.Template|x64.Deploy.0 = Release|x64\r\n\t\t{85A166AC-D2CF-496C-9EFD-648765C4AC72}.Debug|x64.ActiveCfg = Debug|x64\r\n\t\t{85A166AC-D2CF-496C-9EFD-648765C4AC72}.Debug|x64.Build.0 = Debug|x64\r\n\t\t{85A166AC-D2CF-496C-9EFD-648765C4AC72}.Debug|x64.Deploy.0 = Debug|x64\r\n\t\t{85A166AC-D2CF-496C-9EFD-648765C4AC72}.Release|x64.ActiveCfg = Release|x64\r\n\t\t{85A166AC-D2CF-496C-9EFD-648765C4AC72}.Release|x64.Build.0 = Release|x64\r\n\t\t{85A166AC-D2CF-496C-9EFD-648765C4AC72}.Release|x64.Deploy.0 = Release|x64\r\n\t\t{85A166AC-D2CF-496C-9EFD-648765C4AC72}.Template|x64.ActiveCfg = Release|x64\r\n\t\t{85A166AC-D2CF-496C-9EFD-648765C4AC72}.Template|x64.Build.0 = Release|x64\r\n\t\t{85A166AC-D2CF-496C-9EFD-648765C4AC72}.Template|x64.Deploy.0 = Release|x64\r\n\t\t{2480AD41-D429-460B-9DAC-B1BA784F0FE1}.Debug|x64.ActiveCfg = Debug|x64\r\n\t\t{2480AD41-D429-460B-9DAC-B1BA784F0FE1}.Debug|x64.Build.0 = Debug|x64\r\n\t\t{2480AD41-D429-460B-9DAC-B1BA784F0FE1}.Debug|x64.Deploy.0 = Debug|x64\r\n\t\t{2480AD41-D429-460B-9DAC-B1BA784F0FE1}.Release|x64.ActiveCfg = Release|x64\r\n\t\t{2480AD41-D429-460B-9DAC-B1BA784F0FE1}.Release|x64.Build.0 = Release|x64\r\n\t\t{2480AD41-D429-460B-9DAC-B1BA784F0FE1}.Release|x64.Deploy.0 = Release|x64\r\n\t\t{2480AD41-D429-460B-9DAC-B1BA784F0FE1}.Template|x64.ActiveCfg = Release|x64\r\n\t\t{2480AD41-D429-460B-9DAC-B1BA784F0FE1}.Template|x64.Build.0 = Release|x64\r\n\t\t{2480AD41-D429-460B-9DAC-B1BA784F0FE1}.Template|x64.Deploy.0 = Release|x64\r\n\t\t{537BFE8E-F268-4BED-8CF0-0E5C2A630F0F}.Debug|x64.ActiveCfg = Debug|x64\r\n\t\t{537BFE8E-F268-4BED-8CF0-0E5C2A630F0F}.Debug|x64.Build.0 = Debug|x64\r\n\t\t{537BFE8E-F268-4BED-8CF0-0E5C2A630F0F}.Debug|x64.Deploy.0 = Debug|x64\r\n\t\t{537BFE8E-F268-4BED-8CF0-0E5C2A630F0F}.Release|x64.ActiveCfg = Release|x64\r\n\t\t{537BFE8E-F268-4BED-8CF0-0E5C2A630F0F}.Release|x64.Build.0 = Release|x64\r\n\t\t{537BFE8E-F268-4BED-8CF0-0E5C2A630F0F}.Release|x64.Deploy.0 = Release|x64\r\n\t\t{537BFE8E-F268-4BED-8CF0-0E5C2A630F0F}.Template|x64.ActiveCfg = Release|x64\r\n\t\t{537BFE8E-F268-4BED-8CF0-0E5C2A630F0F}.Template|x64.Build.0 = Release|x64\r\n\t\t{537BFE8E-F268-4BED-8CF0-0E5C2A630F0F}.Template|x64.Deploy.0 = Release|x64\r\n\t\t{19FABF05-9AD2-4437-84E9-5A60DF6E7BAE}.Debug|x64.ActiveCfg = Debug|x64\r\n\t\t{19FABF05-9AD2-4437-84E9-5A60DF6E7BAE}.Debug|x64.Build.0 = Debug|x64\r\n\t\t{19FABF05-9AD2-4437-84E9-5A60DF6E7BAE}.Debug|x64.Deploy.0 = Debug|x64\r\n\t\t{19FABF05-9AD2-4437-84E9-5A60DF6E7BAE}.Release|x64.ActiveCfg = Release|x64\r\n\t\t{19FABF05-9AD2-4437-84E9-5A60DF6E7BAE}.Release|x64.Build.0 = Release|x64\r\n\t\t{19FABF05-9AD2-4437-84E9-5A60DF6E7BAE}.Release|x64.Deploy.0 = Release|x64\r\n\t\t{19FABF05-9AD2-4437-84E9-5A60DF6E7BAE}.Template|x64.ActiveCfg = Release|x64\r\n\t\t{19FABF05-9AD2-4437-84E9-5A60DF6E7BAE}.Template|x64.Build.0 = Release|x64\r\n\t\t{19FABF05-9AD2-4437-84E9-5A60DF6E7BAE}.Template|x64.Deploy.0 = Release|x64\r\n\t\t{09C39723-AF6B-4F3B-81C7-3233E7F8A22E}.Debug|x64.ActiveCfg = Debug|x64\r\n\t\t{09C39723-AF6B-4F3B-81C7-3233E7F8A22E}.Debug|x64.Build.0 = Debug|x64\r\n\t\t{09C39723-AF6B-4F3B-81C7-3233E7F8A22E}.Debug|x64.Deploy.0 = Debug|x64\r\n\t\t{09C39723-AF6B-4F3B-81C7-3233E7F8A22E}.Release|x64.ActiveCfg = Release|x64\r\n\t\t{09C39723-AF6B-4F3B-81C7-3233E7F8A22E}.Release|x64.Build.0 = Release|x64\r\n\t\t{09C39723-AF6B-4F3B-81C7-3233E7F8A22E}.Release|x64.Deploy.0 = Release|x64\r\n\t\t{09C39723-AF6B-4F3B-81C7-3233E7F8A22E}.Template|x64.ActiveCfg = Release|x64\r\n\t\t{09C39723-AF6B-4F3B-81C7-3233E7F8A22E}.Template|x64.Build.0 = Release|x64\r\n\t\t{09C39723-AF6B-4F3B-81C7-3233E7F8A22E}.Template|x64.Deploy.0 = Release|x64\r\n\t\t{8FC8D073-3D03-4DE6-8605-D906431FF5E8}.Debug|x64.ActiveCfg = Debug|x64\r\n\t\t{8FC8D073-3D03-4DE6-8605-D906431FF5E8}.Debug|x64.Build.0 = Debug|x64\r\n\t\t{8FC8D073-3D03-4DE6-8605-D906431FF5E8}.Debug|x64.Deploy.0 = Debug|x64\r\n\t\t{8FC8D073-3D03-4DE6-8605-D906431FF5E8}.Release|x64.ActiveCfg = Release|x64\r\n\t\t{8FC8D073-3D03-4DE6-8605-D906431FF5E8}.Release|x64.Build.0 = Release|x64\r\n\t\t{8FC8D073-3D03-4DE6-8605-D906431FF5E8}.Release|x64.Deploy.0 = Release|x64\r\n\t\t{8FC8D073-3D03-4DE6-8605-D906431FF5E8}.Template|x64.ActiveCfg = Release|x64\r\n\t\t{8FC8D073-3D03-4DE6-8605-D906431FF5E8}.Template|x64.Build.0 = Release|x64\r\n\t\t{8FC8D073-3D03-4DE6-8605-D906431FF5E8}.Template|x64.Deploy.0 = Release|x64\r\n\t\t{733888AA-F653-4A92-817D-25EE4AB2BE54}.Debug|x64.ActiveCfg = Debug|x64\r\n\t\t{733888AA-F653-4A92-817D-25EE4AB2BE54}.Debug|x64.Build.0 = Debug|x64\r\n\t\t{733888AA-F653-4A92-817D-25EE4AB2BE54}.Debug|x64.Deploy.0 = Debug|x64\r\n\t\t{733888AA-F653-4A92-817D-25EE4AB2BE54}.Release|x64.ActiveCfg = Release|x64\r\n\t\t{733888AA-F653-4A92-817D-25EE4AB2BE54}.Release|x64.Build.0 = Release|x64\r\n\t\t{733888AA-F653-4A92-817D-25EE4AB2BE54}.Release|x64.Deploy.0 = Release|x64\r\n\t\t{733888AA-F653-4A92-817D-25EE4AB2BE54}.Template|x64.ActiveCfg = Release|x64\r\n\t\t{733888AA-F653-4A92-817D-25EE4AB2BE54}.Template|x64.Build.0 = Release|x64\r\n\t\t{733888AA-F653-4A92-817D-25EE4AB2BE54}.Template|x64.Deploy.0 = Release|x64\r\n\t\t{5C0CA59D-CFCE-49C6-B62A-9E3065CA34DD}.Debug|x64.ActiveCfg = Debug|x64\r\n\t\t{5C0CA59D-CFCE-49C6-B62A-9E3065CA34DD}.Debug|x64.Build.0 = Debug|x64\r\n\t\t{5C0CA59D-CFCE-49C6-B62A-9E3065CA34DD}.Debug|x64.Deploy.0 = Debug|x64\r\n\t\t{5C0CA59D-CFCE-49C6-B62A-9E3065CA34DD}.Release|x64.ActiveCfg = Release|x64\r\n\t\t{5C0CA59D-CFCE-49C6-B62A-9E3065CA34DD}.Release|x64.Build.0 = Release|x64\r\n\t\t{5C0CA59D-CFCE-49C6-B62A-9E3065CA34DD}.Release|x64.Deploy.0 = Release|x64\r\n\t\t{5C0CA59D-CFCE-49C6-B62A-9E3065CA34DD}.Template|x64.ActiveCfg = Release|x64\r\n\t\t{5C0CA59D-CFCE-49C6-B62A-9E3065CA34DD}.Template|x64.Build.0 = Release|x64\r\n\t\t{5C0CA59D-CFCE-49C6-B62A-9E3065CA34DD}.Template|x64.Deploy.0 = Release|x64\r\n\t\t{E5EC0C47-17DE-4E2F-8F13-731D5EECB70B}.Debug|x64.ActiveCfg = Debug|x64\r\n\t\t{E5EC0C47-17DE-4E2F-8F13-731D5EECB70B}.Debug|x64.Build.0 = Debug|x64\r\n\t\t{E5EC0C47-17DE-4E2F-8F13-731D5EECB70B}.Release|x64.ActiveCfg = Release|x64\r\n\t\t{E5EC0C47-17DE-4E2F-8F13-731D5EECB70B}.Release|x64.Build.0 = Release|x64\r\n\t\t{E5EC0C47-17DE-4E2F-8F13-731D5EECB70B}.Template|x64.ActiveCfg = Release|x64\r\n\t\t{E5EC0C47-17DE-4E2F-8F13-731D5EECB70B}.Template|x64.Build.0 = Release|x64\r\n\t\t{81A006F2-4FC4-4187-93E9-98C5EB8523C3}.Debug|x64.ActiveCfg = Debug|x64\r\n\t\t{81A006F2-4FC4-4187-93E9-98C5EB8523C3}.Debug|x64.Build.0 = Debug|x64\r\n\t\t{81A006F2-4FC4-4187-93E9-98C5EB8523C3}.Release|x64.ActiveCfg = Release|x64\r\n\t\t{81A006F2-4FC4-4187-93E9-98C5EB8523C3}.Release|x64.Build.0 = Release|x64\r\n\t\t{81A006F2-4FC4-4187-93E9-98C5EB8523C3}.Template|x64.ActiveCfg = Release|x64\r\n\t\t{81A006F2-4FC4-4187-93E9-98C5EB8523C3}.Template|x64.Build.0 = Release|x64\r\n\t\t{E8D9DD36-B0CA-4043-9B08-CEA96BED5266}.Debug|x64.ActiveCfg = Debug|x64\r\n\t\t{E8D9DD36-B0CA-4043-9B08-CEA96BED5266}.Debug|x64.Build.0 = Debug|x64\r\n\t\t{E8D9DD36-B0CA-4043-9B08-CEA96BED5266}.Release|x64.ActiveCfg = Release|x64\r\n\t\t{E8D9DD36-B0CA-4043-9B08-CEA96BED5266}.Release|x64.Build.0 = Release|x64\r\n\t\t{E8D9DD36-B0CA-4043-9B08-CEA96BED5266}.Template|x64.ActiveCfg = Release|x64\r\n\t\t{E8D9DD36-B0CA-4043-9B08-CEA96BED5266}.Template|x64.Build.0 = Release|x64\r\n\t\t{3B9FF5B3-3B2B-4294-B6E3-D8E9885B6B8A}.Debug|x64.ActiveCfg = Debug|x64\r\n\t\t{3B9FF5B3-3B2B-4294-B6E3-D8E9885B6B8A}.Debug|x64.Build.0 = Debug|x64\r\n\t\t{3B9FF5B3-3B2B-4294-B6E3-D8E9885B6B8A}.Release|x64.ActiveCfg = Release|x64\r\n\t\t{3B9FF5B3-3B2B-4294-B6E3-D8E9885B6B8A}.Release|x64.Build.0 = Release|x64\r\n\t\t{3B9FF5B3-3B2B-4294-B6E3-D8E9885B6B8A}.Template|x64.ActiveCfg = Release|x64\r\n\t\t{3B9FF5B3-3B2B-4294-B6E3-D8E9885B6B8A}.Template|x64.Build.0 = Release|x64\r\n\t\t{57BB9FA6-BA0C-4E70-83B3-DD973FED0FB4}.Debug|x64.ActiveCfg = Debug|x64\r\n\t\t{57BB9FA6-BA0C-4E70-83B3-DD973FED0FB4}.Debug|x64.Build.0 = Debug|x64\r\n\t\t{57BB9FA6-BA0C-4E70-83B3-DD973FED0FB4}.Release|x64.ActiveCfg = Release|x64\r\n\t\t{57BB9FA6-BA0C-4E70-83B3-DD973FED0FB4}.Release|x64.Build.0 = Release|x64\r\n\t\t{57BB9FA6-BA0C-4E70-83B3-DD973FED0FB4}.Template|x64.ActiveCfg = Debug|x64\r\n\t\t{57BB9FA6-BA0C-4E70-83B3-DD973FED0FB4}.Template|x64.Build.0 = Debug|x64\r\n\tEndGlobalSection\r\n\tGlobalSection(SolutionProperties) = preSolution\r\n\t\tHideSolutionNode = FALSE\r\n\tEndGlobalSection\r\n\tGlobalSection(NestedProjects) = preSolution\r\n\t\t{D47FBAF4-1642-4F73-837C-F289DCB9E8FE} = {90EC3FAA-DA36-47D5-97B5-9D463272C406}\r\n\t\t{FD8026D5-50C6-4D30-B082-899FA4226C48} = {90EC3FAA-DA36-47D5-97B5-9D463272C406}\r\n\t\t{C846486D-4A9D-4212-89A8-D25BEFED7FC5} = {90EC3FAA-DA36-47D5-97B5-9D463272C406}\r\n\t\t{16C73FC5-A179-4B2C-983C-59B9D1431703} = {90EC3FAA-DA36-47D5-97B5-9D463272C406}\r\n\t\t{AA63BE2D-A701-4C68-9760-C71655FFE66D} = {90EC3FAA-DA36-47D5-97B5-9D463272C406}\r\n\t\t{A84E0600-2A1B-4593-9D89-25098A0150AA} = {90EC3FAA-DA36-47D5-97B5-9D463272C406}\r\n\t\t{C0DBF909-F12F-473F-8AC3-2248ABA68B92} = {90EC3FAA-DA36-47D5-97B5-9D463272C406}\r\n\t\t{DF1D0F97-B7D8-4DF3-AB71-B2350E08F0F4} = {90EC3FAA-DA36-47D5-97B5-9D463272C406}\r\n\t\t{7ED945F7-9538-4306-A770-4A186327F8BF} = {90EC3FAA-DA36-47D5-97B5-9D463272C406}\r\n\t\t{939C5230-35C3-455B-98F6-51E47E9E3DBB} = {90EC3FAA-DA36-47D5-97B5-9D463272C406}\r\n\t\t{85A166AC-D2CF-496C-9EFD-648765C4AC72} = {90EC3FAA-DA36-47D5-97B5-9D463272C406}\r\n\t\t{2480AD41-D429-460B-9DAC-B1BA784F0FE1} = {90EC3FAA-DA36-47D5-97B5-9D463272C406}\r\n\t\t{537BFE8E-F268-4BED-8CF0-0E5C2A630F0F} = {90EC3FAA-DA36-47D5-97B5-9D463272C406}\r\n\t\t{19FABF05-9AD2-4437-84E9-5A60DF6E7BAE} = {90EC3FAA-DA36-47D5-97B5-9D463272C406}\r\n\t\t{09C39723-AF6B-4F3B-81C7-3233E7F8A22E} = {90EC3FAA-DA36-47D5-97B5-9D463272C406}\r\n\t\t{8FC8D073-3D03-4DE6-8605-D906431FF5E8} = {90EC3FAA-DA36-47D5-97B5-9D463272C406}\r\n\t\t{733888AA-F653-4A92-817D-25EE4AB2BE54} = {90EC3FAA-DA36-47D5-97B5-9D463272C406}\r\n\t\t{5C0CA59D-CFCE-49C6-B62A-9E3065CA34DD} = {9AC1D5FF-D209-4186-8C80-027639ACC2A3}\r\n\t\t{E5EC0C47-17DE-4E2F-8F13-731D5EECB70B} = {90EC3FAA-DA36-47D5-97B5-9D463272C406}\r\n\t\t{81A006F2-4FC4-4187-93E9-98C5EB8523C3} = {90EC3FAA-DA36-47D5-97B5-9D463272C406}\r\n\t\t{E8D9DD36-B0CA-4043-9B08-CEA96BED5266} = {9AC1D5FF-D209-4186-8C80-027639ACC2A3}\r\n\t\t{3B9FF5B3-3B2B-4294-B6E3-D8E9885B6B8A} = {9AC1D5FF-D209-4186-8C80-027639ACC2A3}\r\n\t\t{57BB9FA6-BA0C-4E70-83B3-DD973FED0FB4} = {90EC3FAA-DA36-47D5-97B5-9D463272C406}\r\n\tEndGlobalSection\r\n\tGlobalSection(ExtensibilityGlobals) = postSolution\r\n\t\tQt5Version = 6.2.4\r\n\t\tBuildVersion_UpdateFileVersion = True\r\n\t\tBuildVersion_UpdateAssemblyVersion = True\r\n\t\tAMDCaProjectFile = D:\\user\\maattaj\\FunBase\\public\\trunk\\CodeAnalyst\\Kactus2_Solution.caw\r\n\t\tSolutionGuid = {7616A0E1-C309-4245-8839-FDBE7354DBC5}\r\n\tEndGlobalSection\r\n\tGlobalSection(Performance) = preSolution\r\n\t\tHasPerformanceSessions = true\r\n\tEndGlobalSection\r\n\tGlobalSection(Performance) = preSolution\r\n\t\tHasPerformanceSessions = true\r\n\tEndGlobalSection\r\n\tGlobalSection(Performance) = preSolution\r\n\t\tHasPerformanceSessions = true\r\n\tEndGlobalSection\r\nEndGlobal\r\n"
  },
  {
    "path": "KactusAPI/KactusAPI.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: KactusAPI.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Esko Pekkarinen\n// Date: 25.02.2021\n//\n// Description:\n// Defines the operations available for accessing Kactus2 core.\n//-----------------------------------------------------------------------------\n\n#include \"KactusAPI.h\"\n\n#include <KactusAPI/include/VersionHelper.h>\n#include <KactusAPI/include/ConsoleMediator.h>\n\n#include <IPXACTmodels/Component/Component.h>\n#include <IPXACTmodels/Design/Design.h>\n#include <IPXACTmodels/DesignConfiguration/DesignConfiguration.h>\n\n#include <KactusAPI/include/IPXactSystemVerilogParser.h>\n\n#include <KactusAPI/include/LibraryHandler.h>\n\n#include <IPlugin.h>\n#include <IGeneratorPlugin.h>\n#include <PluginUtilityAdapter.h>\n#include <CLIGenerator.h>\n\n#include <KactusAPI/include/ImportRunner.h>\n\n#include <QFileInfo>\n\n//-----------------------------------------------------------------------------\n// Function: KactusAPI::KactusAPI()\n//-----------------------------------------------------------------------------\nKactusAPI::KactusAPI(MessageMediator* messageChannel)\n{\n    if (messageChannel != nullptr)\n    {\n        messageChannel_ = messageChannel;\n        LibraryHandler::getInstance().setOutputChannel(messageChannel_);\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: KactusAPI::getLibrary()\n//-----------------------------------------------------------------------------\nLibraryInterface* KactusAPI::getLibrary()\n{\n    return library_;\n}\n\n//-----------------------------------------------------------------------------\n// Function: KactusAPI::getMessageChannel()\n//-----------------------------------------------------------------------------\nMessageMediator* KactusAPI::getMessageChannel()\n{\n    return messageChannel_;\n}\n\n//-----------------------------------------------------------------------------\n// Function: KactusAPI::getVersion()\n//-----------------------------------------------------------------------------\nQString KactusAPI::getVersion()\n{\n    return QStringLiteral(\"Kactus2 \") + VersionHelper::versionFull();\n}\n\n//-----------------------------------------------------------------------------\n// Function: KactusAPI::getVersionFileString()\n//-----------------------------------------------------------------------------\nQString KactusAPI::getVersionFileString()\n{\n    return VersionHelper::versionFileStr();\n}\n\n//-----------------------------------------------------------------------------\n// Function: KactusAPI::getLibraryPaths()\n//-----------------------------------------------------------------------------\nQStringList KactusAPI::getActiveLibraryPaths()\n{\n    QSettings settings;\n    return settings.value(QStringLiteral(\"Library/ActiveLocations\")).toStringList();\n}\n\n//-----------------------------------------------------------------------------\n// Function: KactusAPI::getAllLibraryPaths()\n//-----------------------------------------------------------------------------\nQStringList KactusAPI::getAllLibraryPaths()\n{\n    QSettings settings;\n    return settings.value(QStringLiteral(\"Library/Locations\")).toStringList();\n}\n\n//-----------------------------------------------------------------------------\n// Function: KactusAPI::setLibraryPaths()\n//-----------------------------------------------------------------------------\nvoid KactusAPI::setLibraryPaths(QStringList const& activeLocations, QStringList const& allLocations)\n{\n    QSettings settings;\n\n    QStringList oldLocations = settings.value(QStringLiteral(\"Library/Locations\")).toStringList();\n    QStringList newLocations = allLocations;\n\n    if (allLocations.empty())\n    {\n        newLocations = oldLocations;\n    }\n\n    QStringList oldActives = settings.value(QStringLiteral(\"Library/ActiveLocations\")).toStringList();\n    QStringList newActives = activeLocations;\n\n    for (auto const& location : newActives)\n    {\n        if (newLocations.contains(location) == false)\n        {\n            newLocations.append(location);\n        }\n    }\n\n    if (newLocations != oldLocations || newActives != oldActives)\n    {\n        settings.setValue(QStringLiteral(\"Library/Locations\"), newLocations);\n        settings.setValue(QStringLiteral(\"Library/ActiveLocations\"), newActives);\n        settings.setValue(QStringLiteral(\"Library/DefaultLocation\"), newActives.first());\n        library_->searchForIPXactFiles();\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: KactusAPI::setLibraryPathActive()\n//-----------------------------------------------------------------------------\nvoid KactusAPI::setLibraryPathActive(QString const& path, bool isActive)\n{\n    QSettings settings;\n\n    QStringList activePaths = settings.value(QStringLiteral(\"Library/ActiveLocations\")).toStringList();\n    QStringList allPaths = settings.value(QStringLiteral(\"Library/Locations\")).toStringList();\n\n    if (isActive)\n    {\n        if (activePaths.contains(path))\n        {\n            return;\n        }\n\n        activePaths.append(path);\n        settings.setValue(QStringLiteral(\"Library/ActiveLocations\"), activePaths);\n\n        // Add path also if it doesn't exist at all\n        if (!allPaths.contains(path))\n        {\n            allPaths.append(path);\n            settings.setValue(QStringLiteral(\"Library/Locations\"), allPaths);\n        }\n    }\n    else\n    {\n        if (activePaths.contains(path))\n        {\n            activePaths.removeOne(path);\n            settings.setValue(QStringLiteral(\"Library/ActiveLocations\"), activePaths);\n        }\n    }\n\n    library_->searchForIPXactFiles();\n}\n\n//-----------------------------------------------------------------------------\n// Function: KactusAPI::addLibraryPath()\n//-----------------------------------------------------------------------------\nvoid KactusAPI::addLibraryPath(QString const& path, bool isActive)\n{\n    QSettings settings;\n\n    QStringList activePaths = settings.value(QStringLiteral(\"Library/ActiveLocations\")).toStringList();\n    QStringList allPaths = settings.value(QStringLiteral(\"Library/Locations\")).toStringList();\n    \n    if (!allPaths.contains(path))\n    {\n        allPaths.append(path);\n        settings.setValue(QStringLiteral(\"Library/Locations\"), allPaths);\n    }\n\n    if (isActive)\n    {\n        activePaths.append(path);\n        settings.setValue(QStringLiteral(\"Library/ActiveLocations\"), activePaths);\n    }\n\n    library_->searchForIPXactFiles();\n}\n\n//-----------------------------------------------------------------------------\n// Function: KactusAPI::removeLibraryPath()\n//-----------------------------------------------------------------------------\nbool KactusAPI::removeLibraryPath(QString const& path)\n{\n    QSettings settings;\n    QString defaultPath = settings.value(QStringLiteral(\"Library/DefaultLocation\")).toString();\n    QStringList activePaths = settings.value(QStringLiteral(\"Library/ActiveLocations\")).toStringList();\n    QStringList allPaths = settings.value(QStringLiteral(\"Library/Locations\")).toStringList();\n\n    if (path.compare(defaultPath) == 0)\n    {\n        return false;\n    }\n\n    if (activePaths.contains(path))\n    {\n        activePaths.removeOne(path);\n        settings.setValue(QStringLiteral(\"Library/ActiveLocations\"), activePaths);\n    }\n\n    if (allPaths.contains(path))\n    {\n        allPaths.removeOne(path);\n        settings.setValue(QStringLiteral(\"Library/Locations\"), allPaths);\n    }\n\n    library_->searchForIPXactFiles();\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: KactusAPI::setLibraryPaths()\n//-----------------------------------------------------------------------------\nQString KactusAPI::getDefaultLibraryPath()\n{\n    QSettings settings;\n    return settings.value(QStringLiteral(\"Library/DefaultLocation\")).toString();\n}\n\n//-----------------------------------------------------------------------------\n// Function: KactusAPI::setLibraryPaths()\n//-----------------------------------------------------------------------------\nvoid KactusAPI::setDefaultLibraryPath(QString const& path)\n{\n    QSettings settings;\n\n    QStringList locations = settings.value(QStringLiteral(\"Library/Locations\")).toStringList();\n    if (locations.contains(path))\n    {\n        settings.setValue(QStringLiteral(\"Library/DefaultLocation\"), path);\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: KactusAPI::importFile()\n//-----------------------------------------------------------------------------\nint KactusAPI::importFile(QString const& filePath, VLNV const& targetVLNV, bool overwrite)\n{\n    bool existing = library_->contains(targetVLNV);\n\n    if (existing && overwrite == false)\n    {\n        return 0;\n    }\n\n    QSharedPointer<Component const> existingComponent(nullptr);\n    QString xmlPath = getDefaultLibraryPath() + QStringLiteral(\"/\") + targetVLNV.toString(QStringLiteral(\"/\")) +\n        QStringLiteral(\"/\") + targetVLNV.getName() + QStringLiteral(\".xml\");\n\n    if (existing)\n    {\n        existingComponent = library_->getModel<Component>(targetVLNV);\n        xmlPath = library_->getPath(targetVLNV);\n    }\n    else\n    {\n        existingComponent = QSharedPointer<Component const>(new Component(targetVLNV, Document::Revision::Std14));\n    }\n\n    QSharedPointer<ComponentParameterFinder> parameterFinder(new ComponentParameterFinder(existingComponent));\n    QSharedPointer<ExpressionParser> expressionParser(new IPXactSystemVerilogParser(parameterFinder));\n\n    ImportRunner runner(parameterFinder, nullptr, nullptr);\n    runner.setExpressionParser(expressionParser);\n    runner.loadPlugins(PluginManager::getInstance());\n\n    QStringList names = runner.constructComponentDataFromFile(filePath, xmlPath, existingComponent);\n\n    if (names.isEmpty() == false)\n    {\n        QSharedPointer<Component> importedComponent = \n            runner.run(names.first(), filePath, xmlPath, existingComponent);\n  \n        if (existing)\n        {\n            library_->writeModelToFile(importedComponent);\n        }\n        else\n        {\n            library_->writeModelToFile(xmlPath, importedComponent);\n        }\n\n        return 1;\n    }\n\n    return 0;\n}\n\n//-----------------------------------------------------------------------------\n// Function: KactusAPI::runGenerator()\n//-----------------------------------------------------------------------------\nvoid KactusAPI::runGenerator(IGeneratorPlugin* plugin, VLNV const& componentVLNV, QString const& viewName,\n    QString const& outputDirectory, KactusAttribute::Implementation implementation, QWidget* parentWidget)\n{\n    QSharedPointer<Component> component = library_->getModel<Component>(componentVLNV);\n    if (component == nullptr)\n    {\n        return;\n    }\n\n    VLNV designVLNV; \n    QSharedPointer<Design> design;\n    \n    VLNV configVLNV;\n    if (implementation == KactusAttribute::SYSTEM)\n    {\n        configVLNV = component->getHierSystemRef(viewName);\n    }\n    else\n    {\n        configVLNV = component->getHierRef(viewName);\n    }\n\n    QSharedPointer<DesignConfiguration> designConfiguration;\n    if (configVLNV.getType() == VLNV::DESIGNCONFIGURATION)\n    {        \n        designConfiguration = library_->getModel<DesignConfiguration>(configVLNV);\n        designVLNV = designConfiguration->getDesignRef();\n    }\n    else if (configVLNV.getType() == VLNV::DESIGN)\n    {\n        designVLNV = configVLNV;\n        configVLNV.clear();\n    }\n\n    if (designVLNV.isEmpty() == false)\n    {\n        design = library_->getModel<Design>(designVLNV);\n    }\n\n    PluginUtilityAdapter adapter(library_, messageChannel_, VersionHelper::createVersionString(), parentWidget);\n\n    CLIGenerator* cliRunnable = dynamic_cast<CLIGenerator*>(plugin);\n    if (parentWidget == nullptr && cliRunnable)\n    {\n        cliRunnable->runGenerator(&adapter, component, design, designConfiguration, viewName, outputDirectory);\n    }\n    else if (plugin != nullptr)\n    {\n        plugin->runGenerator(&adapter, component, design, designConfiguration);\n    }    \n}\n\n//-----------------------------------------------------------------------------\n// Function: KactusAPI::getPlugins()\n//-----------------------------------------------------------------------------\nQList<IPlugin*> KactusAPI::getPlugins()\n{    \n    return PluginManager::getInstance().getAllPlugins();\n}\n\n//-----------------------------------------------------------------------------\n// Function: KactusAPI::getDocumentFilePath()\n//-----------------------------------------------------------------------------\nQString KactusAPI::getDocumentFilePath(VLNV const& vlnv)\n{\n    return QFileInfo(library_->getPath(vlnv)).absolutePath();\n}\n"
  },
  {
    "path": "KactusAPI/KactusAPI.h",
    "content": "//-----------------------------------------------------------------------------\n// File: KactusAPI.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Esko Pekkarinen\n// Date: 25.02.2021\n//\n// Description:\n// Defines the operations available for accessing Kactus2 core.\n//-----------------------------------------------------------------------------\n\n#ifndef KACTUSAPI_H\n#define KACTUSAPI_H\n\n#include \"KactusAPIGlobal.h\"\n\n#include <KactusAPI/include/LibraryHandler.h>\n\n#include <KactusAPI/include/ConsoleMediator.h>\n\n\nclass IPlugin;\nclass IGeneratorPlugin;\n\nclass MessageMediator;\n\n\n//-----------------------------------------------------------------------------\n//! Defines the operations available for accessing Kactus2 core.\n//-----------------------------------------------------------------------------\nclass KACTUS2_API KactusAPI\n{\npublic:\n\n    //! The constructor.\n    KactusAPI(MessageMediator* messageChannel = nullptr);\n    \n    //! The destructor.\n    ~KactusAPI() = default;    \n\n    //! No copying.\n    KactusAPI(const KactusAPI &other) = delete;\n\n    //! No assignment.\n    KactusAPI &operator=(const KactusAPI &other) = delete;\n\n    /*!\n     * Get the active IP-XACT library manager in the core.\n     *\n     *    @return The active IP-XACT library manager.\n     */\n    static LibraryInterface* getLibrary();\n\n    /*!\n     * Get the channel for output and error messages.\n     *\n     *    @return The channel for messages.\n     */\n    static MessageMediator* getMessageChannel();\n\n    /*!\n     * Get the Kactus2 version.\n     *\n     *    @return The current Kactus2 version.\n     */\n    static QString getVersion();\n\n    /*!\n     *  Get the version number.\n     *\n     *    @return The current version number.\n     */\n    static QString getVersionFileString();\n\n    /*!\n     * Gets the active paths where IP-XACT files are stored.\n     *\n     *    @return The active paths where IP-XACT files are stored.\n     */\n    static QStringList getActiveLibraryPaths();\n\n    /*!\n     * Gets all paths where IP-XACT files are stored.\n     *\n     *    @return All of the paths where IP-XACT files are stored.\n     */\n    static QStringList getAllLibraryPaths();\n\n    /*!\n     * Set the paths where IP-XACT files are stored. The first active path is set as default, if there are changes.\n     *\n     *    @param [in] activeLocations  The locations that are currently available to store the files.\n     *    @param [in] allLocations     All the locations available, but not all need to be active.\n     */\n    static void setLibraryPaths(QStringList const& activeLocations,\n        QStringList const& allLocations = QStringList() );\n\n    /*!\n     *\tSet a given library path as active or inactive. If set as active, also add the path if not found.\n     *  \n     *    @param [in] path         The path to set active.\n     *    @param [in] isActive     Indicates if the path should be set active or inactive.\n     */\n    static void setLibraryPathActive(QString const& path, bool isActive);\n\n    /*!\n     *\tAdd a new library path and set it active or inactive.\n     *  \n     *    @param [in] path         The path to add.\n     *    @param [in] isActive     Flag to indicate if path should be set active or inactive.\n     */\n    static void addLibraryPath(QString const& path, bool isActive);\n\n    /*!\n     *\tRemoves selected library path, if selected path is not the default path. If path to remove is not found\n     *  in settings, nothing is removed.\n     *  \n     *    @param [in] path     The path to remove\n     *\t    \n     *    @return True, if path removal was successful (or nothing was done). False, if the path to remove is the default path.\n     */\n    static bool removeLibraryPath(QString const& path);\n\n    /*!\n     * Get the default library path for IP-XACT files.\n     *\n     *    @return The default path for IP-XACT files.\n     */\n    static QString getDefaultLibraryPath();\n\n    /*!\n     * Set the default library path for IP-XACT files.\n     *\n     *    @param [in] path  The default path to set for IP-XACT files.\n     */\n    static void setDefaultLibraryPath(QString const& path);\n\n    /*!\n     * Import a source file (RTL) into the library as a component.\n     *\n     *    @param [in] filePath     The path to the file to import.\n     *    @param [in] targetVLNV   The VLNV to use for the imported component.\n     *    @param [in] overwrite    Overwrite the component in the library, if it already exists.\n     *\n     *    @return The number of imported IP-XACT documents.\n     */\n    static int importFile(QString const& filePath, VLNV const& targetVLNV, bool overwrite);\n\n    /*!\n     * Run a generation plugin for a component.\n     *\n     *    @param [in] plugin              The plugin to run.\n     *    @param [in] componentVLNV       The component to run the generation for.\n     *    @param [in] viewName            The component view to run the generation for.\n     *    @param [in] outputDirectory     The target directory for generated output files.\n     *    @param [in] implementation      The implementation type for which the generator is run.\n     *    @param [in] parentWidget        The parent widget for dialogs if GUI is used.\n     */\n    static void runGenerator(IGeneratorPlugin* plugin, VLNV const& componentVLNV, QString const& viewName,\n        QString const& outputDirectory, KactusAttribute::Implementation implementation, QWidget* parentWidget = nullptr);\n\n    /*!\n     * Get the list of available plugins.     \n     *\n     *    @return The list of available plugins.\n     */\n     static QList<IPlugin*> getPlugins();\n\n     /*!\n      *  Get the file path of the selected VLNV document.\n      *\n      *    @param [in] vlnv   VLNV of the selected document.\n      *\n      *    @return File path of the selected VLNV document.\n      */\n     static QString getDocumentFilePath(VLNV const& vlnv);\n\nprivate:\n\n    // All members are defined static to enforce coherent state of the API regardless of instances.\n\n    //! The active library manager in the core.\n    inline static LibraryInterface* library_{ &LibraryHandler::getInstance() };\n\n    //! The active message channel for output and errors.\n    inline static ConsoleMediator defaultChannel_{ };\n\n    //! The active message channel for output and errors.\n    inline static MessageMediator* messageChannel_{ &defaultChannel_ };\n\n};\n\n\n#endif // KACTUSAPI_H\n"
  },
  {
    "path": "KactusAPI/KactusAPI.pri",
    "content": "# ----------------------------------------------------\n# This file is generated by the Qt Visual Studio Tools.\n# ------------------------------------------------------\n\nHEADERS += ./KactusAPI.h \\\n    ./KactusAPIGlobal.h \\\n    ./include/AbstractionTypeInterface.h \\\n    ./include/AbstractParameterInterface.h \\\n    ./include/AccessPolicyInterface.h \\\n    ./include/AddressBlockExpressionsGatherer.h \\\n    ./include/AddressBlockInterface.h \\\n    ./include/AddressSpaceExpressionsGatherer.h \\\n    ./include/AdHocConnectionInterface.h \\\n    ./include/BusInterfaceInterface.h \\\n    ./include/BusInterfaceInterfaceFactory.h \\\n    ./include/BusInterfaceUtilities.h \\\n    ./include/CLIGenerator.h \\\n    ./include/CommonInterface.h \\\n    ./include/ComponentAndInstantiationsParameterFinder.h \\\n    ./include/ComponentInstanceInterface.h \\\n    ./include/ComponentInstantiationInterface.h \\\n    ./include/ComponentInstantiationParameterFinder.h \\\n    ./include/ComponentParameterFinder.h \\\n    ./include/ConfigJsonParser.h \\\n    ./include/ParameterConfigurableElementFinder.h \\\n    ./include/ConsoleMediator.h \\\n    ./include/DesignParameterFinder.h \\\n    ./include/DocumentFileAccess.h \\\n    ./include/DocumentValidator.h \\\n    ./include/ExpressionFormatter.h \\\n    ./include/ExpressionFormatterFactory.h \\\n    ./include/ExpressionFormatterFactoryImplementation.h \\\n    ./include/ExpressionParser.h \\\n    ./include/ExpressionSupport.h \\\n    ./include/FieldInterface.h \\\n    ./include/FileBuilderInterface.h \\\n    ./include/FileHandler.h \\\n    ./include/FileInterface.h \\\n    ./include/FileSetInterface.h \\\n    ./include/Highlighter.h \\\n    ./include/HighlightSource.h \\\n    ./include/IGeneratorPlugin.h \\\n    ./include/ImportColors.h \\\n    ./include/ImportPlugin.h \\\n    ./include/IncludeImportPlugin.h \\\n    ./include/InterconnectGenerator.h \\\n    ./include/InterconnectionInterface.h \\\n    ./include/InterconnectRTLWriter.h \\\n    ./include/IPlugin.h \\\n    ./include/IPluginUtility.h \\\n    ./include/IPXactSystemVerilogParser.h \\\n    ./include/LibraryInterface.h \\\n    ./include/LibraryLoader.h \\\n    ./include/ListHelper.h \\\n    ./include/ListParameterFinder.h \\\n    ./include/MasterPortInterface.h \\\n    ./include/MemoryBlockInterface.h \\\n    ./include/MemoryMapExpressionsGatherer.h \\\n    ./include/MemoryMapInterface.h \\\n    ./include/MemoryRemapExpressionGatherer.h \\\n    ./include/MessageMediator.h \\\n    ./include/ModeConditionParser.h \\\n    ./include/ExpressionParserInterface.h \\\n    ./include/ModeConditionParserInterface.h \\\n    ./include/ModelParameterSource.h \\\n    ./include/ModelParameterVisualizer.h \\\n    ./include/ModeReferenceInterface.h \\\n    ./include/ModuleParameterInterface.h \\\n    ./include/MultipleParameterFinder.h \\\n    ./include/NameGroupInterface.h \\\n    ./include/NullChannel.h \\\n    ./include/NullParser.h \\\n    ./include/ParameterFinder.h \\\n    ./include/ParameterizableInterface.h \\\n    ./include/ParametersInterface.h \\\n    ./include/PluginManager.h \\\n    ./include/PluginSettingsModel.h \\\n    ./include/PluginUtilityAdapter.h \\\n    ./include/PortAbstractionInterface.h \\\n    ./include/PortMapInterface.h \\\n    ./include/PortsInterface.h \\\n    ./include/RegisterExpressionsGatherer.h \\\n    ./include/RegisterFileExpressionsGatherer.h \\\n    ./include/RegisterInterface.h \\\n    ./include/ResetInterface.h \\\n    ./include/SubspaceMapInterface.h \\\n    ./include/SystemVerilogExpressionParser.h \\\n    ./include/SystemVerilogSyntax.h \\\n    ./include/TagManager.h \\\n    ./include/TransparentBridgeInterface.h \\\n    ./include/utils.h \\\n    ./include/VersionHelper.h \\\n    ./include/ComponentInstanceParameterFinder.h \\\n    ./include/hierarchyitem.h \\\n    ./include/hierarchymodel.h \\\n    ./include/ImportHighlighter.h \\\n    ./include/ImportRunner.h \\\n    ./include/LibraryHandler.h \\\n    ./include/LibraryItem.h \\\n    ./include/LibraryTreeModel.h \\\n    ./include/ParameterCache.h\nSOURCES += ./KactusAPI.cpp \\\n    ./expressions/AddressBlockExpressionsGatherer.cpp \\\n    ./expressions/AddressSpaceExpressionsGatherer.cpp \\\n    ./expressions/ComponentAndInstantiationsParameterFinder.cpp \\\n    ./expressions/ComponentInstanceParameterFinder.cpp \\\n    ./expressions/ComponentInstantiationParameterFinder.cpp \\\n    ./expressions/ComponentParameterFinder.cpp \\\n    ./expressions/ParameterConfigurableElementFinder.cpp \\\n    ./expressions/DesignParameterFinder.cpp \\\n    ./expressions/ExpressionFormatter.cpp \\\n    ./expressions/ExpressionFormatterFactoryImplementation.cpp \\\n    ./expressions/FieldExpressionsGatherer.cpp \\\n    ./expressions/IPXactSystemVerilogParser.cpp \\\n    ./expressions/ListParameterFinder.cpp \\\n    ./expressions/MemoryMapExpressionsGatherer.cpp \\\n    ./expressions/MemoryRemapExpressionGatherer.cpp \\\n    ./expressions/ModeConditionParser.cpp \\\n    ./expressions/ModeConditionParserInterface.cpp \\\n    ./expressions/MultipleParameterFinder.cpp \\\n    ./expressions/NullParser.cpp \\\n    ./expressions/ParameterCache.cpp \\\n    ./expressions/RegisterExpressionsGatherer.cpp \\\n    ./expressions/RegisterFileExpressionsGatherer.cpp \\\n    ./expressions/SystemVerilogExpressionParser.cpp \\\n    ./interfaces/bus/AbstractionTypeInterface.cpp \\\n    ./interfaces/bus/PortAbstractionInterface.cpp \\\n    ./interfaces/component/AccessPolicyInterface.cpp \\\n    ./interfaces/component/AddressBlockInterface.cpp \\\n    ./interfaces/component/BusInterfaceInterface.cpp \\\n    ./interfaces/component/BusInterfaceInterfaceFactory.cpp \\\n    ./interfaces/component/BusInterfaceUtilities.cpp \\\n    ./interfaces/component/ComponentInstantiationInterface.cpp \\\n    ./interfaces/component/FieldInterface.cpp \\\n    ./interfaces/component/FileBuilderInterface.cpp \\\n    ./interfaces/component/FileInterface.cpp \\\n    ./interfaces/component/FileSetInterface.cpp \\\n    ./interfaces/component/MasterPortInterface.cpp \\\n    ./interfaces/component/MemoryBlockInterface.cpp \\\n    ./interfaces/component/MemoryMapInterface.cpp \\\n    ./interfaces/component/ModeReferenceInterface.cpp \\\n    ./interfaces/component/ModuleParameterInterface.cpp \\\n    ./interfaces/component/PortMapInterface.cpp \\\n    ./interfaces/component/PortsInterface.cpp \\\n    ./interfaces/component/RegisterInterface.cpp \\\n    ./interfaces/component/ResetInterface.cpp \\\n    ./interfaces/component/SubspaceMapInterface.cpp \\\n    ./interfaces/component/TransparentBridgeInterface.cpp \\\n    ./interfaces/common/AbstractParameterInterface.cpp \\\n    ./interfaces/common/CommonInterface.cpp \\\n    ./interfaces/common/NameGroupInterface.cpp \\\n    ./interfaces/common/ParameterizableInterface.cpp \\\n    ./interfaces/common/ParametersInterface.cpp \\\n    ./interfaces/design/AdHocConnectionInterface.cpp \\\n    ./interfaces/design/ComponentInstanceInterface.cpp \\\n    ./interfaces/design/InterconnectionInterface.cpp \\\n    ./plugins/ImportHighlighter.cpp \\\n    ./plugins/ImportRunner.cpp \\\n    ./plugins/PluginManager.cpp \\\n    ./plugins/PluginUtilityAdapter.cpp \\\n    ./plugins/InterconnectGenerator/ConfigJsonParser.cpp \\\n    ./plugins/InterconnectGenerator/InterconnectGenerator.cpp \\\n    ./plugins/InterconnectGenerator/InterconnectRTLWriter.cpp \\\n    ./utilities/ConsoleMediator.cpp \\\n    ./utilities/FileHandler.cpp \\\n    ./utilities/NullChannel.cpp \\\n    ./utilities/utils.cpp \\\n    ./utilities/VersionHelper.cpp \\\n    ./library/DocumentFileAccess.cpp \\\n    ./library/DocumentValidator.cpp \\\n    ./library/hierarchyitem.cpp \\\n    ./library/hierarchymodel.cpp \\\n    ./library/LibraryHandler.cpp \\\n    ./library/LibraryItem.cpp \\\n    ./library/LibraryLoader.cpp \\\n    ./library/LibraryTreeModel.cpp \\\n    ./library/TagManager.cpp\n"
  },
  {
    "path": "KactusAPI/KactusAPI.pro",
    "content": "# ----------------------------------------------------\n# This file is generated by the Qt Visual Studio Tools.\n# ------------------------------------------------------\n\nTEMPLATE = lib\nDESTDIR = ../executable\nCONFIG += c++17\nQT += xml widgets\nDEFINES +=  KACTUS2_EXPORTS\n\t\nINCLUDEPATH += . .. ./include\n\nCONFIG(debug, debug|release) {\n    # debug mode\n    LIBS += -L\"../executable\" \\\n        -lIPXACTmodelsd\n    \n    MOC_DIR += ./GeneratedFiles/Debug\n    OBJECTS_DIR += Debug\n    TARGET = KactusAPId\n\n} else {\n    # release mode \n    LIBS += -L\"../executable\" \\\n        -lIPXACTmodels\n\n    MOC_DIR += ./GeneratedFiles/Release\n    OBJECTS_DIR += Release\n    TARGET = KactusAPI\n}\n\nDEPENDPATH += .\nUI_DIR += ./GeneratedFiles\nRCC_DIR += ./GeneratedFiles\n\ninclude(KactusAPI.pri)\n\ntarget.path = $$lib_path\nINSTALLS += target\n"
  },
  {
    "path": "KactusAPI/KactusAPI.vcxproj",
    "content": "﻿<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<Project DefaultTargets=\"Build\" ToolsVersion=\"15.0\" xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">\n  <ItemGroup Label=\"ProjectConfigurations\">\n    <ProjectConfiguration Include=\"Debug|x64\">\n      <Configuration>Debug</Configuration>\n      <Platform>x64</Platform>\n    </ProjectConfiguration>\n    <ProjectConfiguration Include=\"Release|x64\">\n      <Configuration>Release</Configuration>\n      <Platform>x64</Platform>\n    </ProjectConfiguration>\n  </ItemGroup>\n  <ItemGroup>\n    <ClInclude Include=\"include\\AbstractionTypeInterface.h\" />\n    <ClInclude Include=\"include\\AbstractParameterInterface.h\" />\n    <ClInclude Include=\"include\\AccessPolicyInterface.h\" />\n    <ClInclude Include=\"include\\AddressBlockExpressionsGatherer.h\" />\n    <ClInclude Include=\"include\\AddressBlockInterface.h\" />\n    <ClInclude Include=\"include\\AddressSpaceExpressionsGatherer.h\" />\n    <ClInclude Include=\"include\\AdHocConnectionInterface.h\" />\n    <ClInclude Include=\"include\\BusInterfaceInterface.h\" />\n    <ClInclude Include=\"include\\BusInterfaceInterfaceFactory.h\" />\n    <ClInclude Include=\"include\\BusInterfaceUtilities.h\" />\n    <ClInclude Include=\"include\\CLIGenerator.h\" />\n    <ClInclude Include=\"include\\CommonInterface.h\" />\n    <ClInclude Include=\"include\\ComponentAndInstantiationsParameterFinder.h\" />\n    <ClInclude Include=\"include\\ComponentInstanceInterface.h\" />\n    <QtMoc Include=\"include\\ComponentInstanceParameterFinder.h\" />\n    <ClInclude Include=\"include\\ComponentInstantiationInterface.h\" />\n    <ClInclude Include=\"include\\ComponentInstantiationParameterFinder.h\" />\n    <ClInclude Include=\"include\\ComponentParameterFinder.h\" />\n    <ClInclude Include=\"include\\ConfigJsonParser.h\" />\n    <ClInclude Include=\"include\\ConsoleMediator.h\" />\n    <ClInclude Include=\"include\\DesignParameterFinder.h\" />\n    <ClInclude Include=\"include\\DocumentFileAccess.h\" />\n    <ClInclude Include=\"include\\DocumentValidator.h\" />\n    <ClInclude Include=\"include\\ExpressionFormatter.h\" />\n    <ClInclude Include=\"include\\ExpressionFormatterFactory.h\" />\n    <ClInclude Include=\"include\\ExpressionFormatterFactoryImplementation.h\" />\n    <ClInclude Include=\"include\\ExpressionParser.h\" />\n    <ClInclude Include=\"include\\ExpressionSupport.h\" />\n    <ClInclude Include=\"include\\FieldInterface.h\" />\n    <ClInclude Include=\"include\\FileBuilderInterface.h\" />\n    <ClInclude Include=\"include\\FileHandler.h\" />\n    <ClInclude Include=\"include\\FileInterface.h\" />\n    <ClInclude Include=\"include\\FileSetInterface.h\" />\n    <QtMoc Include=\"include\\hierarchyitem.h\" />\n    <QtMoc Include=\"include\\hierarchymodel.h\" />\n    <ClInclude Include=\"include\\Highlighter.h\" />\n    <ClInclude Include=\"include\\HighlightSource.h\" />\n    <ClInclude Include=\"include\\IGeneratorPlugin.h\" />\n    <ClInclude Include=\"include\\ImportColors.h\" />\n    <QtMoc Include=\"include\\ImportHighlighter.h\" />\n    <ClInclude Include=\"include\\ImportPlugin.h\" />\n    <QtMoc Include=\"include\\ImportRunner.h\" />\n    <ClInclude Include=\"include\\IncludeImportPlugin.h\" />\n    <ClInclude Include=\"include\\InterconnectGenerator.h\" />\n    <ClInclude Include=\"include\\InterconnectionInterface.h\" />\n    <ClInclude Include=\"include\\InterconnectRTLWriter.h\" />\n    <ClInclude Include=\"include\\IPlugin.h\" />\n    <ClInclude Include=\"include\\IPluginUtility.h\" />\n    <ClInclude Include=\"include\\IPXactSystemVerilogParser.h\" />\n    <QtMoc Include=\"include\\LibraryHandler.h\" />\n    <ClInclude Include=\"include\\LibraryInterface.h\" />\n    <QtMoc Include=\"include\\LibraryItem.h\" />\n    <ClInclude Include=\"include\\LibraryLoader.h\" />\n    <QtMoc Include=\"include\\LibraryTreeModel.h\" />\n    <ClInclude Include=\"include\\ListHelper.h\" />\n    <ClInclude Include=\"include\\ListParameterFinder.h\" />\n    <ClInclude Include=\"include\\MasterPortInterface.h\" />\n    <ClInclude Include=\"include\\MemoryBlockInterface.h\" />\n    <ClInclude Include=\"include\\MemoryMapExpressionsGatherer.h\" />\n    <ClInclude Include=\"include\\MemoryMapInterface.h\" />\n    <ClInclude Include=\"include\\MemoryRemapExpressionGatherer.h\" />\n    <ClInclude Include=\"include\\MessageMediator.h\" />\n    <ClInclude Include=\"include\\ModeConditionParser.h\" />\n    <ClInclude Include=\"include\\ExpressionParserInterface.h\" />\n    <ClInclude Include=\"include\\ModeConditionParserInterface.h\" />\n    <ClInclude Include=\"include\\ModelParameterSource.h\" />\n    <ClInclude Include=\"include\\ModelParameterVisualizer.h\" />\n    <ClInclude Include=\"include\\ModeReferenceInterface.h\" />\n    <ClInclude Include=\"include\\ModuleParameterInterface.h\" />\n    <ClInclude Include=\"include\\MultipleParameterFinder.h\" />\n    <QtMoc Include=\"include\\ParameterCache.h\" />\n    <ClInclude Include=\"include\\NameGroupInterface.h\" />\n    <ClInclude Include=\"include\\NullChannel.h\" />\n    <ClInclude Include=\"include\\NullParser.h\" />\n    <ClInclude Include=\"include\\ParameterConfigurableElementFinder.h\" />\n    <ClInclude Include=\"include\\ParameterFinder.h\" />\n    <ClInclude Include=\"include\\ParameterizableInterface.h\" />\n    <ClInclude Include=\"include\\ParametersInterface.h\" />\n    <ClInclude Include=\"include\\PluginManager.h\" />\n    <ClInclude Include=\"include\\PluginSettingsModel.h\" />\n    <ClInclude Include=\"include\\PluginUtilityAdapter.h\" />\n    <ClInclude Include=\"include\\PortAbstractionInterface.h\" />\n    <ClInclude Include=\"include\\PortMapInterface.h\" />\n    <ClInclude Include=\"include\\PortsInterface.h\" />\n    <ClInclude Include=\"include\\RegisterExpressionsGatherer.h\" />\n    <ClInclude Include=\"include\\RegisterFileExpressionsGatherer.h\" />\n    <ClInclude Include=\"include\\RegisterInterface.h\" />\n    <ClInclude Include=\"include\\ResetInterface.h\" />\n    <ClInclude Include=\"include\\SubspaceMapInterface.h\" />\n    <ClInclude Include=\"include\\SystemVerilogExpressionParser.h\" />\n    <ClInclude Include=\"include\\SystemVerilogSyntax.h\" />\n    <ClInclude Include=\"include\\TagManager.h\" />\n    <ClInclude Include=\"include\\TransparentBridgeInterface.h\" />\n    <ClInclude Include=\"include\\utils.h\" />\n    <ClInclude Include=\"include\\VersionHelper.h\" />\n    <ClInclude Include=\"KactusAPI.h\" />\n    <ClInclude Include=\"KactusAPIGlobal.h\" />\n  </ItemGroup>\n  <ItemGroup>\n    <ClCompile Include=\"expressions\\AddressBlockExpressionsGatherer.cpp\" />\n    <ClCompile Include=\"expressions\\AddressSpaceExpressionsGatherer.cpp\" />\n    <ClCompile Include=\"expressions\\ComponentAndInstantiationsParameterFinder.cpp\" />\n    <ClCompile Include=\"expressions\\ComponentInstanceParameterFinder.cpp\" />\n    <ClCompile Include=\"expressions\\ComponentInstantiationParameterFinder.cpp\" />\n    <ClCompile Include=\"expressions\\ComponentParameterFinder.cpp\" />\n    <ClCompile Include=\"expressions\\DesignParameterFinder.cpp\" />\n    <ClCompile Include=\"expressions\\ExpressionFormatter.cpp\" />\n    <ClCompile Include=\"expressions\\ExpressionFormatterFactoryImplementation.cpp\" />\n    <ClCompile Include=\"expressions\\FieldExpressionsGatherer.cpp\" />\n    <ClCompile Include=\"expressions\\IPXactSystemVerilogParser.cpp\" />\n    <ClCompile Include=\"expressions\\ListParameterFinder.cpp\" />\n    <ClCompile Include=\"expressions\\MemoryMapExpressionsGatherer.cpp\" />\n    <ClCompile Include=\"expressions\\MemoryRemapExpressionGatherer.cpp\" />\n    <ClCompile Include=\"expressions\\ModeConditionParser.cpp\" />\n    <ClCompile Include=\"expressions\\ModeConditionParserInterface.cpp\" />\n    <ClCompile Include=\"expressions\\MultipleParameterFinder.cpp\" />\n    <ClCompile Include=\"expressions\\NullParser.cpp\" />\n    <ClCompile Include=\"expressions\\ParameterCache.cpp\" />\n    <ClCompile Include=\"expressions\\ParameterConfigurableElementFinder.cpp\" />\n    <ClCompile Include=\"expressions\\RegisterExpressionsGatherer.cpp\" />\n    <ClCompile Include=\"expressions\\RegisterFileExpressionsGatherer.cpp\" />\n    <ClCompile Include=\"expressions\\SystemVerilogExpressionParser.cpp\" />\n    <ClCompile Include=\"interfaces\\bus\\AbstractionTypeInterface.cpp\" />\n    <ClCompile Include=\"interfaces\\bus\\PortAbstractionInterface.cpp\" />\n    <ClCompile Include=\"interfaces\\common\\AbstractParameterInterface.cpp\" />\n    <ClCompile Include=\"interfaces\\common\\CommonInterface.cpp\" />\n    <ClCompile Include=\"interfaces\\common\\NameGroupInterface.cpp\" />\n    <ClCompile Include=\"interfaces\\common\\ParameterizableInterface.cpp\" />\n    <ClCompile Include=\"interfaces\\common\\ParametersInterface.cpp\" />\n    <ClCompile Include=\"interfaces\\component\\AccessPolicyInterface.cpp\" />\n    <ClCompile Include=\"interfaces\\component\\AddressBlockInterface.cpp\" />\n    <ClCompile Include=\"interfaces\\component\\BusInterfaceInterface.cpp\" />\n    <ClCompile Include=\"interfaces\\component\\BusInterfaceInterfaceFactory.cpp\" />\n    <ClCompile Include=\"interfaces\\component\\BusInterfaceUtilities.cpp\" />\n    <ClCompile Include=\"interfaces\\component\\ComponentInstantiationInterface.cpp\" />\n    <ClCompile Include=\"interfaces\\component\\FieldInterface.cpp\" />\n    <ClCompile Include=\"interfaces\\component\\FileBuilderInterface.cpp\" />\n    <ClCompile Include=\"interfaces\\component\\FileInterface.cpp\" />\n    <ClCompile Include=\"interfaces\\component\\FileSetInterface.cpp\" />\n    <ClCompile Include=\"interfaces\\component\\MasterPortInterface.cpp\" />\n    <ClCompile Include=\"interfaces\\component\\MemoryBlockInterface.cpp\" />\n    <ClCompile Include=\"interfaces\\component\\MemoryMapInterface.cpp\" />\n    <ClCompile Include=\"interfaces\\component\\ModeReferenceInterface.cpp\" />\n    <ClCompile Include=\"interfaces\\component\\ModuleParameterInterface.cpp\" />\n    <ClCompile Include=\"interfaces\\component\\PortMapInterface.cpp\" />\n    <ClCompile Include=\"interfaces\\component\\PortsInterface.cpp\" />\n    <ClCompile Include=\"interfaces\\component\\RegisterInterface.cpp\" />\n    <ClCompile Include=\"interfaces\\component\\ResetInterface.cpp\" />\n    <ClCompile Include=\"interfaces\\component\\SubspaceMapInterface.cpp\" />\n    <ClCompile Include=\"interfaces\\component\\TransparentBridgeInterface.cpp\" />\n    <ClCompile Include=\"interfaces\\design\\AdHocConnectionInterface.cpp\" />\n    <ClCompile Include=\"interfaces\\design\\ComponentInstanceInterface.cpp\" />\n    <ClCompile Include=\"interfaces\\design\\InterconnectionInterface.cpp\" />\n    <ClCompile Include=\"KactusAPI.cpp\" />\n    <ClCompile Include=\"library\\DocumentFileAccess.cpp\" />\n    <ClCompile Include=\"library\\DocumentValidator.cpp\" />\n    <ClCompile Include=\"library\\hierarchyitem.cpp\" />\n    <ClCompile Include=\"library\\hierarchymodel.cpp\" />\n    <ClCompile Include=\"library\\LibraryHandler.cpp\" />\n    <ClCompile Include=\"library\\LibraryItem.cpp\" />\n    <ClCompile Include=\"library\\LibraryLoader.cpp\" />\n    <ClCompile Include=\"library\\LibraryTreeModel.cpp\" />\n    <ClCompile Include=\"library\\TagManager.cpp\" />\n    <ClCompile Include=\"plugins\\ImportHighlighter.cpp\" />\n    <ClCompile Include=\"plugins\\ImportRunner.cpp\" />\n    <ClCompile Include=\"plugins\\InterconnectGenerator\\ConfigJsonParser.cpp\" />\n    <ClCompile Include=\"plugins\\InterconnectGenerator\\InterconnectGenerator.cpp\" />\n    <ClCompile Include=\"plugins\\InterconnectGenerator\\InterconnectRTLWriter.cpp\" />\n    <ClCompile Include=\"plugins\\PluginManager.cpp\" />\n    <ClCompile Include=\"plugins\\PluginUtilityAdapter.cpp\" />\n    <ClCompile Include=\"utilities\\ConsoleMediator.cpp\" />\n    <ClCompile Include=\"utilities\\FileHandler.cpp\" />\n    <ClCompile Include=\"utilities\\NullChannel.cpp\" />\n    <ClCompile Include=\"utilities\\utils.cpp\" />\n    <ClCompile Include=\"utilities\\VersionHelper.cpp\" />\n  </ItemGroup>\n  <PropertyGroup Label=\"Globals\">\n    <ProjectGuid>{3B9FF5B3-3B2B-4294-B6E3-D8E9885B6B8A}</ProjectGuid>\n    <Keyword>QtVS_v304</Keyword>\n    <QtMsBuild Condition=\"'$(QtMsBuild)'=='' OR !Exists('$(QtMsBuild)\\qt.targets')\">$(MSBuildProjectDirectory)\\QtMsBuild</QtMsBuild>\n    <WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>\n  </PropertyGroup>\n  <Import Project=\"$(VCTargetsPath)\\Microsoft.Cpp.Default.props\" />\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)' == 'Debug|x64'\" Label=\"Configuration\">\n    <ConfigurationType>DynamicLibrary</ConfigurationType>\n    <PlatformToolset>v143</PlatformToolset>\n  </PropertyGroup>\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)' == 'Release|x64'\" Label=\"Configuration\">\n    <ConfigurationType>DynamicLibrary</ConfigurationType>\n    <PlatformToolset>v143</PlatformToolset>\n  </PropertyGroup>\n  <Import Project=\"$(VCTargetsPath)\\Microsoft.Cpp.props\" />\n  <ImportGroup Condition=\"Exists('$(QtMsBuild)\\qt_defaults.props')\">\n    <Import Project=\"$(QtMsBuild)\\qt_defaults.props\" />\n  </ImportGroup>\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)' == 'Debug|x64'\" Label=\"QtSettings\">\n    <QtInstall>6.2.4</QtInstall>\n    <QtModules>core;xml;widgets</QtModules>\n    <QtBuildConfig>debug</QtBuildConfig>\n  </PropertyGroup>\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)' == 'Release|x64'\" Label=\"QtSettings\">\n    <QtInstall>6.2.4</QtInstall>\n    <QtModules>core;xml;widgets</QtModules>\n    <QtBuildConfig>release</QtBuildConfig>\n  </PropertyGroup>\n  <Target Name=\"QtMsBuildNotFound\" BeforeTargets=\"CustomBuild;ClCompile\" Condition=\"!Exists('$(QtMsBuild)\\qt.targets') or !Exists('$(QtMsBuild)\\qt.props')\">\n    <Message Importance=\"High\" Text=\"QtMsBuild: could not locate qt.targets, qt.props; project may not build correctly.\" />\n  </Target>\n  <ImportGroup Label=\"ExtensionSettings\" />\n  <ImportGroup Label=\"Shared\" />\n  <ImportGroup Label=\"PropertySheets\" Condition=\"'$(Configuration)|$(Platform)' == 'Debug|x64'\">\n    <Import Project=\"$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props\" Condition=\"exists('$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props')\" Label=\"LocalAppDataPlatform\" />\n    <Import Project=\"$(QtMsBuild)\\Qt.props\" />\n  </ImportGroup>\n  <ImportGroup Label=\"PropertySheets\" Condition=\"'$(Configuration)|$(Platform)' == 'Release|x64'\">\n    <Import Project=\"$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props\" Condition=\"exists('$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props')\" Label=\"LocalAppDataPlatform\" />\n    <Import Project=\"$(QtMsBuild)\\Qt.props\" />\n  </ImportGroup>\n  <PropertyGroup Label=\"UserMacros\" />\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)' == 'Debug|x64'\">\n    <OutDir>$(SolutionDir)executable\\</OutDir>\n    <TargetName>$(ProjectName)d</TargetName>\n  </PropertyGroup>\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)' == 'Release|x64'\">\n    <OutDir>$(SolutionDir)executable\\</OutDir>\n  </PropertyGroup>\n  <ItemDefinitionGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\n    <ClCompile>\n      <AdditionalIncludeDirectories>%(AdditionalIncludeDirectories);$(Qt_INCLUDEPATH_);$(SolutionDir);$(ProjectDir)include/</AdditionalIncludeDirectories>\n      <AdditionalOptions>/Zc:__cplusplus %(AdditionalOptions)</AdditionalOptions>\n      <LanguageStandard>stdcpp17</LanguageStandard>\n    </ClCompile>\n    <Link>\n      <OutputFile>$(OutDir)\\$(ProjectName).dll</OutputFile>\n      <AdditionalLibraryDirectories>$(SolutionDir)executable</AdditionalLibraryDirectories>\n      <AdditionalDependencies>IPXACTmodels.lib;%(AdditionalDependencies);$(Qt_LIBS_)</AdditionalDependencies>\n    </Link>\n  </ItemDefinitionGroup>\n  <ItemDefinitionGroup Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\n    <ClCompile>\n      <AdditionalIncludeDirectories>%(AdditionalIncludeDirectories);$(Qt_INCLUDEPATH_);$(SolutionDir);$(ProjectDir)include/</AdditionalIncludeDirectories>\n      <AdditionalOptions>/Zc:__cplusplus %(AdditionalOptions)</AdditionalOptions>\n      <LanguageStandard>stdcpp17</LanguageStandard>\n      <WarningLevel>Level4</WarningLevel>\n    </ClCompile>\n    <Link>\n      <OutputFile>$(OutDir)\\$(ProjectName)d.dll</OutputFile>\n      <AdditionalDependencies>IPXACTmodelsd.lib;%(AdditionalDependencies);$(Qt_LIBS_)</AdditionalDependencies>\n      <AdditionalLibraryDirectories>$(SolutionDir)executable</AdditionalLibraryDirectories>\n    </Link>\n  </ItemDefinitionGroup>\n  <ItemDefinitionGroup Condition=\"'$(Configuration)|$(Platform)' == 'Debug|x64'\" Label=\"Configuration\">\n    <ClCompile>\n      <TreatWChar_tAsBuiltInType>true</TreatWChar_tAsBuiltInType>\n      <MultiProcessorCompilation>true</MultiProcessorCompilation>\n      <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>\n      <Optimization>Disabled</Optimization>\n      <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>\n      <PreprocessorDefinitions>_DEBUG;_WINDOWS;UNICODE;WIN64;KACTUS2_EXPORTS;QT_DISABLE_DEPRECATED_BEFORE=0x050F00;%(PreprocessorDefinitions)</PreprocessorDefinitions>\n    </ClCompile>\n    <Link>\n      <SubSystem>Windows</SubSystem>\n      <GenerateDebugInformation>true</GenerateDebugInformation>\n    </Link>\n  </ItemDefinitionGroup>\n  <ItemDefinitionGroup Condition=\"'$(Configuration)|$(Platform)' == 'Release|x64'\" Label=\"Configuration\">\n    <ClCompile>\n      <TreatWChar_tAsBuiltInType>true</TreatWChar_tAsBuiltInType>\n      <MultiProcessorCompilation>true</MultiProcessorCompilation>\n      <DebugInformationFormat>None</DebugInformationFormat>\n      <Optimization>MaxSpeed</Optimization>\n      <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>\n      <PreprocessorDefinitions>_WINDOWS;UNICODE;WIN64;KACTUS2_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>\n    </ClCompile>\n    <Link>\n      <SubSystem>Windows</SubSystem>\n      <GenerateDebugInformation>true</GenerateDebugInformation>\n    </Link>\n  </ItemDefinitionGroup>\n  <Import Project=\"$(VCTargetsPath)\\Microsoft.Cpp.targets\" />\n  <ImportGroup Condition=\"Exists('$(QtMsBuild)\\qt.targets')\">\n    <Import Project=\"$(QtMsBuild)\\qt.targets\" />\n  </ImportGroup>\n  <ImportGroup Label=\"ExtensionTargets\">\n  </ImportGroup>\n</Project>"
  },
  {
    "path": "KactusAPI/KactusAPI.vcxproj.filters",
    "content": "﻿<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<Project xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">\n  <ItemGroup>\n    <Filter Include=\"Generated Files\">\n      <UniqueIdentifier>{71ED8ED8-ACB9-4CE9-BBE1-E00B30144E11}</UniqueIdentifier>\n      <Extensions>cpp;c;cxx;moc;h;def;odl;idl;res;</Extensions>\n    </Filter>\n    <Filter Include=\"Generated Files\">\n      <UniqueIdentifier>{71ED8ED8-ACB9-4CE9-BBE1-E00B30144E11}</UniqueIdentifier>\n      <Extensions>cpp;c;cxx;moc;h;def;odl;idl;res;</Extensions>\n    </Filter>\n    <Filter Include=\"Header Files\">\n      <UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>\n      <Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>\n    </Filter>\n    <Filter Include=\"Header Files\">\n      <UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>\n      <Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>\n    </Filter>\n    <Filter Include=\"Source Files\">\n      <UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>\n      <Extensions>cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>\n    </Filter>\n    <Filter Include=\"Source Files\">\n      <UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>\n      <Extensions>cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>\n    </Filter>\n    <Filter Include=\"Source Files\\expressions\">\n      <UniqueIdentifier>{947bd3dc-0c42-47cd-a131-bf7a49768ec5}</UniqueIdentifier>\n    </Filter>\n    <Filter Include=\"Source Files\\interfaces\">\n      <UniqueIdentifier>{15e65c51-6431-43f1-8553-72c5fd7e5863}</UniqueIdentifier>\n    </Filter>\n    <Filter Include=\"Source Files\\plugins\">\n      <UniqueIdentifier>{307dabcd-0561-44e2-ad25-0aa874141166}</UniqueIdentifier>\n    </Filter>\n    <Filter Include=\"Source Files\\utilities\">\n      <UniqueIdentifier>{9804f280-29ab-4524-88bf-7d3f8086ce49}</UniqueIdentifier>\n    </Filter>\n    <Filter Include=\"Source Files\\interfaces\\bus\">\n      <UniqueIdentifier>{09ed363a-e5b7-41fb-a43d-78ab6adb73ce}</UniqueIdentifier>\n    </Filter>\n    <Filter Include=\"Source Files\\interfaces\\component\">\n      <UniqueIdentifier>{500c5bf6-7d3f-484f-abdb-31f4fe709406}</UniqueIdentifier>\n    </Filter>\n    <Filter Include=\"Source Files\\interfaces\\common\">\n      <UniqueIdentifier>{3dd93eea-434d-41e0-a572-2b3cb85a646c}</UniqueIdentifier>\n    </Filter>\n    <Filter Include=\"Source Files\\interfaces\\design\">\n      <UniqueIdentifier>{07fda30c-154a-4b8f-8df3-3b6aff999620}</UniqueIdentifier>\n    </Filter>\n    <Filter Include=\"Header Files\\include\">\n      <UniqueIdentifier>{79331bd6-220b-4437-96c9-ac82f0a2ee64}</UniqueIdentifier>\n    </Filter>\n    <Filter Include=\"Source Files\\library\">\n      <UniqueIdentifier>{2f4a90c3-f66c-4301-bbde-ec7309e674bb}</UniqueIdentifier>\n    </Filter>\n    <Filter Include=\"Source Files\\plugins\\InterconnectGenerator\">\n      <UniqueIdentifier>{9ff628aa-2962-4e53-9cba-88fa287f611c}</UniqueIdentifier>\n    </Filter>\n  </ItemGroup>\n  <ItemGroup>\n    <ClInclude Include=\"include\\AbstractionTypeInterface.h\">\n      <Filter>Header Files\\include</Filter>\n    </ClInclude>\n    <ClInclude Include=\"include\\AbstractParameterInterface.h\">\n      <Filter>Header Files\\include</Filter>\n    </ClInclude>\n    <ClInclude Include=\"include\\AddressBlockExpressionsGatherer.h\">\n      <Filter>Header Files\\include</Filter>\n    </ClInclude>\n    <ClInclude Include=\"include\\AddressBlockInterface.h\">\n      <Filter>Header Files\\include</Filter>\n    </ClInclude>\n    <ClInclude Include=\"include\\AddressSpaceExpressionsGatherer.h\">\n      <Filter>Header Files\\include</Filter>\n    </ClInclude>\n    <ClInclude Include=\"include\\AdHocConnectionInterface.h\">\n      <Filter>Header Files\\include</Filter>\n    </ClInclude>\n    <ClInclude Include=\"include\\BusInterfaceInterface.h\">\n      <Filter>Header Files\\include</Filter>\n    </ClInclude>\n    <ClInclude Include=\"include\\BusInterfaceInterfaceFactory.h\">\n      <Filter>Header Files\\include</Filter>\n    </ClInclude>\n    <ClInclude Include=\"include\\BusInterfaceUtilities.h\">\n      <Filter>Header Files\\include</Filter>\n    </ClInclude>\n    <ClInclude Include=\"include\\CLIGenerator.h\">\n      <Filter>Header Files\\include</Filter>\n    </ClInclude>\n    <ClInclude Include=\"include\\CommonInterface.h\">\n      <Filter>Header Files\\include</Filter>\n    </ClInclude>\n    <ClInclude Include=\"include\\ComponentAndInstantiationsParameterFinder.h\">\n      <Filter>Header Files\\include</Filter>\n    </ClInclude>\n    <ClInclude Include=\"include\\ComponentInstantiationInterface.h\">\n      <Filter>Header Files\\include</Filter>\n    </ClInclude>\n    <ClInclude Include=\"include\\ComponentInstantiationParameterFinder.h\">\n      <Filter>Header Files\\include</Filter>\n    </ClInclude>\n    <ClInclude Include=\"include\\ComponentParameterFinder.h\">\n      <Filter>Header Files\\include</Filter>\n    </ClInclude>\n    <ClInclude Include=\"include\\DesignParameterFinder.h\">\n      <Filter>Header Files\\include</Filter>\n    </ClInclude>\n    <ClInclude Include=\"include\\ExpressionFormatter.h\">\n      <Filter>Header Files\\include</Filter>\n    </ClInclude>\n    <ClInclude Include=\"include\\ExpressionFormatterFactory.h\">\n      <Filter>Header Files\\include</Filter>\n    </ClInclude>\n    <ClInclude Include=\"include\\ExpressionFormatterFactoryImplementation.h\">\n      <Filter>Header Files\\include</Filter>\n    </ClInclude>\n    <ClInclude Include=\"include\\ExpressionParser.h\">\n      <Filter>Header Files\\include</Filter>\n    </ClInclude>\n    <ClInclude Include=\"include\\ExpressionSupport.h\">\n      <Filter>Header Files\\include</Filter>\n    </ClInclude>\n    <ClInclude Include=\"include\\FieldInterface.h\">\n      <Filter>Header Files\\include</Filter>\n    </ClInclude>\n    <ClInclude Include=\"include\\FileBuilderInterface.h\">\n      <Filter>Header Files\\include</Filter>\n    </ClInclude>\n    <ClInclude Include=\"include\\FileHandler.h\">\n      <Filter>Header Files\\include</Filter>\n    </ClInclude>\n    <ClInclude Include=\"include\\FileInterface.h\">\n      <Filter>Header Files\\include</Filter>\n    </ClInclude>\n    <ClInclude Include=\"include\\FileSetInterface.h\">\n      <Filter>Header Files\\include</Filter>\n    </ClInclude>\n    <ClInclude Include=\"include\\Highlighter.h\">\n      <Filter>Header Files\\include</Filter>\n    </ClInclude>\n    <ClInclude Include=\"include\\HighlightSource.h\">\n      <Filter>Header Files\\include</Filter>\n    </ClInclude>\n    <ClInclude Include=\"include\\IGeneratorPlugin.h\">\n      <Filter>Header Files\\include</Filter>\n    </ClInclude>\n    <ClInclude Include=\"include\\ImportColors.h\">\n      <Filter>Header Files\\include</Filter>\n    </ClInclude>\n    <ClInclude Include=\"include\\ImportPlugin.h\">\n      <Filter>Header Files\\include</Filter>\n    </ClInclude>\n    <ClInclude Include=\"include\\IncludeImportPlugin.h\">\n      <Filter>Header Files\\include</Filter>\n    </ClInclude>\n    <ClInclude Include=\"include\\InterconnectionInterface.h\">\n      <Filter>Header Files\\include</Filter>\n    </ClInclude>\n    <ClInclude Include=\"include\\IPlugin.h\">\n      <Filter>Header Files\\include</Filter>\n    </ClInclude>\n    <ClInclude Include=\"include\\IPluginUtility.h\">\n      <Filter>Header Files\\include</Filter>\n    </ClInclude>\n    <ClInclude Include=\"include\\IPXactSystemVerilogParser.h\">\n      <Filter>Header Files\\include</Filter>\n    </ClInclude>\n    <ClInclude Include=\"include\\ListParameterFinder.h\">\n      <Filter>Header Files\\include</Filter>\n    </ClInclude>\n    <ClInclude Include=\"include\\MasterPortInterface.h\">\n      <Filter>Header Files\\include</Filter>\n    </ClInclude>\n    <ClInclude Include=\"include\\MemoryBlockInterface.h\">\n      <Filter>Header Files\\include</Filter>\n    </ClInclude>\n    <ClInclude Include=\"include\\MemoryMapExpressionsGatherer.h\">\n      <Filter>Header Files\\include</Filter>\n    </ClInclude>\n    <ClInclude Include=\"include\\MemoryMapInterface.h\">\n      <Filter>Header Files\\include</Filter>\n    </ClInclude>\n    <ClInclude Include=\"include\\MemoryRemapExpressionGatherer.h\">\n      <Filter>Header Files\\include</Filter>\n    </ClInclude>\n    <ClInclude Include=\"include\\MessageMediator.h\">\n      <Filter>Header Files\\include</Filter>\n    </ClInclude>\n    <ClInclude Include=\"include\\ModelParameterSource.h\">\n      <Filter>Header Files\\include</Filter>\n    </ClInclude>\n    <ClInclude Include=\"include\\ModelParameterVisualizer.h\">\n      <Filter>Header Files\\include</Filter>\n    </ClInclude>\n    <ClInclude Include=\"include\\ModuleParameterInterface.h\">\n      <Filter>Header Files\\include</Filter>\n    </ClInclude>\n    <ClInclude Include=\"include\\MultipleParameterFinder.h\">\n      <Filter>Header Files\\include</Filter>\n    </ClInclude>\n    <ClInclude Include=\"include\\NameGroupInterface.h\">\n      <Filter>Header Files\\include</Filter>\n    </ClInclude>\n    <ClInclude Include=\"include\\ParameterFinder.h\">\n      <Filter>Header Files\\include</Filter>\n    </ClInclude>\n    <ClInclude Include=\"include\\ParameterizableInterface.h\">\n      <Filter>Header Files\\include</Filter>\n    </ClInclude>\n    <ClInclude Include=\"include\\ParametersInterface.h\">\n      <Filter>Header Files\\include</Filter>\n    </ClInclude>\n    <ClInclude Include=\"include\\PluginManager.h\">\n      <Filter>Header Files\\include</Filter>\n    </ClInclude>\n    <ClInclude Include=\"include\\PluginSettingsModel.h\">\n      <Filter>Header Files\\include</Filter>\n    </ClInclude>\n    <ClInclude Include=\"include\\PluginUtilityAdapter.h\">\n      <Filter>Header Files\\include</Filter>\n    </ClInclude>\n    <ClInclude Include=\"include\\PortAbstractionInterface.h\">\n      <Filter>Header Files\\include</Filter>\n    </ClInclude>\n    <ClInclude Include=\"include\\PortMapInterface.h\">\n      <Filter>Header Files\\include</Filter>\n    </ClInclude>\n    <ClInclude Include=\"include\\PortsInterface.h\">\n      <Filter>Header Files\\include</Filter>\n    </ClInclude>\n    <ClInclude Include=\"include\\RegisterExpressionsGatherer.h\">\n      <Filter>Header Files\\include</Filter>\n    </ClInclude>\n    <ClInclude Include=\"include\\RegisterFileExpressionsGatherer.h\">\n      <Filter>Header Files\\include</Filter>\n    </ClInclude>\n    <ClInclude Include=\"include\\RegisterInterface.h\">\n      <Filter>Header Files\\include</Filter>\n    </ClInclude>\n    <ClInclude Include=\"include\\ResetInterface.h\">\n      <Filter>Header Files\\include</Filter>\n    </ClInclude>\n    <ClInclude Include=\"include\\SubspaceMapInterface.h\">\n      <Filter>Header Files\\include</Filter>\n    </ClInclude>\n    <ClInclude Include=\"include\\SystemVerilogExpressionParser.h\">\n      <Filter>Header Files\\include</Filter>\n    </ClInclude>\n    <ClInclude Include=\"include\\SystemVerilogSyntax.h\">\n      <Filter>Header Files\\include</Filter>\n    </ClInclude>\n    <ClInclude Include=\"include\\TransparentBridgeInterface.h\">\n      <Filter>Header Files\\include</Filter>\n    </ClInclude>\n    <ClInclude Include=\"include\\VersionHelper.h\">\n      <Filter>Header Files\\include</Filter>\n    </ClInclude>\n    <ClInclude Include=\"KactusAPI.h\">\n      <Filter>Header Files</Filter>\n    </ClInclude>\n    <ClInclude Include=\"KactusAPIGlobal.h\">\n      <Filter>Header Files</Filter>\n    </ClInclude>\n    <ClInclude Include=\"include\\LibraryInterface.h\">\n      <Filter>Header Files\\include</Filter>\n    </ClInclude>\n    <ClInclude Include=\"include\\DocumentFileAccess.h\">\n      <Filter>Header Files\\include</Filter>\n    </ClInclude>\n    <ClInclude Include=\"include\\DocumentValidator.h\">\n      <Filter>Header Files\\include</Filter>\n    </ClInclude>\n    <ClInclude Include=\"include\\utils.h\">\n      <Filter>Header Files\\include</Filter>\n    </ClInclude>\n    <ClInclude Include=\"include\\TagManager.h\">\n      <Filter>Header Files\\include</Filter>\n    </ClInclude>\n    <ClInclude Include=\"include\\ConsoleMediator.h\">\n      <Filter>Header Files\\include</Filter>\n    </ClInclude>\n    <ClInclude Include=\"include\\AccessPolicyInterface.h\">\n      <Filter>Header Files\\include</Filter>\n    </ClInclude>\n    <ClInclude Include=\"include\\ModeConditionParser.h\">\n      <Filter>Header Files\\include</Filter>\n    </ClInclude>\n    <ClInclude Include=\"include\\ListHelper.h\">\n      <Filter>Header Files\\include</Filter>\n    </ClInclude>\n    <ClInclude Include=\"include\\ModeReferenceInterface.h\">\n      <Filter>Header Files\\include</Filter>\n    </ClInclude>\n    <ClInclude Include=\"include\\LibraryLoader.h\">\n      <Filter>Header Files\\include</Filter>\n    </ClInclude>\n    <ClInclude Include=\"include\\NullChannel.h\">\n      <Filter>Header Files\\include</Filter>\n    </ClInclude>\n    <ClInclude Include=\"include\\ExpressionParserInterface.h\">\n      <Filter>Header Files\\include</Filter>\n    </ClInclude>\n    <ClInclude Include=\"include\\ModeConditionParserInterface.h\">\n      <Filter>Header Files\\include</Filter>\n    </ClInclude>\n    <ClInclude Include=\"include\\InterconnectGenerator.h\">\n      <Filter>Header Files\\include</Filter>\n    </ClInclude>\n    <ClInclude Include=\"include\\ConfigJsonParser.h\">\n      <Filter>Header Files\\include</Filter>\n    </ClInclude>\n    <ClInclude Include=\"include\\InterconnectRTLWriter.h\">\n      <Filter>Header Files\\include</Filter>\n    </ClInclude>\n    <ClInclude Include=\"include\\ParameterConfigurableElementFinder.h\">\n      <Filter>Header Files\\include</Filter>\n    </ClInclude>\n  </ItemGroup>\n  <ItemGroup>\n    <ClCompile Include=\"utilities\\ConsoleMediator.cpp\">\n      <Filter>Source Files\\utilities</Filter>\n    </ClCompile>\n    <ClCompile Include=\"utilities\\FileHandler.cpp\">\n      <Filter>Source Files\\utilities</Filter>\n    </ClCompile>\n    <ClCompile Include=\"utilities\\VersionHelper.cpp\">\n      <Filter>Source Files\\utilities</Filter>\n    </ClCompile>\n    <ClCompile Include=\"plugins\\ImportRunner.cpp\">\n      <Filter>Source Files\\plugins</Filter>\n    </ClCompile>\n    <ClCompile Include=\"plugins\\PluginManager.cpp\">\n      <Filter>Source Files\\plugins</Filter>\n    </ClCompile>\n    <ClCompile Include=\"plugins\\PluginUtilityAdapter.cpp\">\n      <Filter>Source Files\\plugins</Filter>\n    </ClCompile>\n    <ClCompile Include=\"plugins\\ImportHighlighter.cpp\">\n      <Filter>Source Files\\plugins</Filter>\n    </ClCompile>\n    <ClCompile Include=\"interfaces\\bus\\PortAbstractionInterface.cpp\">\n      <Filter>Source Files\\interfaces\\bus</Filter>\n    </ClCompile>\n    <ClCompile Include=\"interfaces\\bus\\AbstractionTypeInterface.cpp\">\n      <Filter>Source Files\\interfaces\\bus</Filter>\n    </ClCompile>\n    <ClCompile Include=\"interfaces\\common\\CommonInterface.cpp\">\n      <Filter>Source Files\\interfaces\\common</Filter>\n    </ClCompile>\n    <ClCompile Include=\"interfaces\\common\\NameGroupInterface.cpp\">\n      <Filter>Source Files\\interfaces\\common</Filter>\n    </ClCompile>\n    <ClCompile Include=\"interfaces\\common\\ParameterizableInterface.cpp\">\n      <Filter>Source Files\\interfaces\\common</Filter>\n    </ClCompile>\n    <ClCompile Include=\"interfaces\\common\\ParametersInterface.cpp\">\n      <Filter>Source Files\\interfaces\\common</Filter>\n    </ClCompile>\n    <ClCompile Include=\"interfaces\\common\\AbstractParameterInterface.cpp\">\n      <Filter>Source Files\\interfaces\\common</Filter>\n    </ClCompile>\n    <ClCompile Include=\"interfaces\\component\\ComponentInstantiationInterface.cpp\">\n      <Filter>Source Files\\interfaces\\component</Filter>\n    </ClCompile>\n    <ClCompile Include=\"interfaces\\component\\FieldInterface.cpp\">\n      <Filter>Source Files\\interfaces\\component</Filter>\n    </ClCompile>\n    <ClCompile Include=\"interfaces\\component\\FileBuilderInterface.cpp\">\n      <Filter>Source Files\\interfaces\\component</Filter>\n    </ClCompile>\n    <ClCompile Include=\"interfaces\\component\\FileInterface.cpp\">\n      <Filter>Source Files\\interfaces\\component</Filter>\n    </ClCompile>\n    <ClCompile Include=\"interfaces\\component\\FileSetInterface.cpp\">\n      <Filter>Source Files\\interfaces\\component</Filter>\n    </ClCompile>\n    <ClCompile Include=\"interfaces\\component\\MasterPortInterface.cpp\">\n      <Filter>Source Files\\interfaces\\component</Filter>\n    </ClCompile>\n    <ClCompile Include=\"interfaces\\component\\MemoryBlockInterface.cpp\">\n      <Filter>Source Files\\interfaces\\component</Filter>\n    </ClCompile>\n    <ClCompile Include=\"interfaces\\component\\MemoryMapInterface.cpp\">\n      <Filter>Source Files\\interfaces\\component</Filter>\n    </ClCompile>\n    <ClCompile Include=\"interfaces\\component\\ModuleParameterInterface.cpp\">\n      <Filter>Source Files\\interfaces\\component</Filter>\n    </ClCompile>\n    <ClCompile Include=\"interfaces\\component\\PortMapInterface.cpp\">\n      <Filter>Source Files\\interfaces\\component</Filter>\n    </ClCompile>\n    <ClCompile Include=\"interfaces\\component\\PortsInterface.cpp\">\n      <Filter>Source Files\\interfaces\\component</Filter>\n    </ClCompile>\n    <ClCompile Include=\"interfaces\\component\\RegisterInterface.cpp\">\n      <Filter>Source Files\\interfaces\\component</Filter>\n    </ClCompile>\n    <ClCompile Include=\"interfaces\\component\\ResetInterface.cpp\">\n      <Filter>Source Files\\interfaces\\component</Filter>\n    </ClCompile>\n    <ClCompile Include=\"interfaces\\component\\SubspaceMapInterface.cpp\">\n      <Filter>Source Files\\interfaces\\component</Filter>\n    </ClCompile>\n    <ClCompile Include=\"interfaces\\component\\TransparentBridgeInterface.cpp\">\n      <Filter>Source Files\\interfaces\\component</Filter>\n    </ClCompile>\n    <ClCompile Include=\"interfaces\\component\\AddressBlockInterface.cpp\">\n      <Filter>Source Files\\interfaces\\component</Filter>\n    </ClCompile>\n    <ClCompile Include=\"interfaces\\component\\BusInterfaceInterface.cpp\">\n      <Filter>Source Files\\interfaces\\component</Filter>\n    </ClCompile>\n    <ClCompile Include=\"interfaces\\component\\BusInterfaceInterfaceFactory.cpp\">\n      <Filter>Source Files\\interfaces\\component</Filter>\n    </ClCompile>\n    <ClCompile Include=\"interfaces\\component\\BusInterfaceUtilities.cpp\">\n      <Filter>Source Files\\interfaces\\component</Filter>\n    </ClCompile>\n    <ClCompile Include=\"expressions\\AddressBlockExpressionsGatherer.cpp\">\n      <Filter>Source Files\\expressions</Filter>\n    </ClCompile>\n    <ClCompile Include=\"expressions\\AddressSpaceExpressionsGatherer.cpp\">\n      <Filter>Source Files\\expressions</Filter>\n    </ClCompile>\n    <ClCompile Include=\"expressions\\ComponentAndInstantiationsParameterFinder.cpp\">\n      <Filter>Source Files\\expressions</Filter>\n    </ClCompile>\n    <ClCompile Include=\"expressions\\ComponentInstantiationParameterFinder.cpp\">\n      <Filter>Source Files\\expressions</Filter>\n    </ClCompile>\n    <ClCompile Include=\"expressions\\ComponentParameterFinder.cpp\">\n      <Filter>Source Files\\expressions</Filter>\n    </ClCompile>\n    <ClCompile Include=\"expressions\\DesignParameterFinder.cpp\">\n      <Filter>Source Files\\expressions</Filter>\n    </ClCompile>\n    <ClCompile Include=\"expressions\\ExpressionFormatter.cpp\">\n      <Filter>Source Files\\expressions</Filter>\n    </ClCompile>\n    <ClCompile Include=\"expressions\\ExpressionFormatterFactoryImplementation.cpp\">\n      <Filter>Source Files\\expressions</Filter>\n    </ClCompile>\n    <ClCompile Include=\"expressions\\FieldExpressionsGatherer.cpp\">\n      <Filter>Source Files\\expressions</Filter>\n    </ClCompile>\n    <ClCompile Include=\"expressions\\IPXactSystemVerilogParser.cpp\">\n      <Filter>Source Files\\expressions</Filter>\n    </ClCompile>\n    <ClCompile Include=\"expressions\\ListParameterFinder.cpp\">\n      <Filter>Source Files\\expressions</Filter>\n    </ClCompile>\n    <ClCompile Include=\"expressions\\MemoryMapExpressionsGatherer.cpp\">\n      <Filter>Source Files\\expressions</Filter>\n    </ClCompile>\n    <ClCompile Include=\"expressions\\MemoryRemapExpressionGatherer.cpp\">\n      <Filter>Source Files\\expressions</Filter>\n    </ClCompile>\n    <ClCompile Include=\"expressions\\MultipleParameterFinder.cpp\">\n      <Filter>Source Files\\expressions</Filter>\n    </ClCompile>\n    <ClCompile Include=\"expressions\\NullParser.cpp\">\n      <Filter>Source Files\\expressions</Filter>\n    </ClCompile>\n    <ClCompile Include=\"expressions\\ParameterCache.cpp\">\n      <Filter>Source Files\\expressions</Filter>\n    </ClCompile>\n    <ClCompile Include=\"expressions\\RegisterExpressionsGatherer.cpp\">\n      <Filter>Source Files\\expressions</Filter>\n    </ClCompile>\n    <ClCompile Include=\"expressions\\RegisterFileExpressionsGatherer.cpp\">\n      <Filter>Source Files\\expressions</Filter>\n    </ClCompile>\n    <ClCompile Include=\"expressions\\SystemVerilogExpressionParser.cpp\">\n      <Filter>Source Files\\expressions</Filter>\n    </ClCompile>\n    <ClCompile Include=\"KactusAPI.cpp\">\n      <Filter>Source Files</Filter>\n    </ClCompile>\n    <ClCompile Include=\"interfaces\\design\\AdHocConnectionInterface.cpp\">\n      <Filter>Source Files\\interfaces\\design</Filter>\n    </ClCompile>\n    <ClCompile Include=\"interfaces\\design\\ComponentInstanceInterface.cpp\">\n      <Filter>Source Files\\interfaces\\design</Filter>\n    </ClCompile>\n    <ClCompile Include=\"interfaces\\design\\InterconnectionInterface.cpp\">\n      <Filter>Source Files\\interfaces\\design</Filter>\n    </ClCompile>\n    <ClCompile Include=\"library\\LibraryHandler.cpp\">\n      <Filter>Source Files\\library</Filter>\n    </ClCompile>\n    <ClCompile Include=\"library\\LibraryLoader.cpp\">\n      <Filter>Source Files\\library</Filter>\n    </ClCompile>\n    <ClCompile Include=\"library\\DocumentFileAccess.cpp\">\n      <Filter>Source Files\\library</Filter>\n    </ClCompile>\n    <ClCompile Include=\"library\\DocumentValidator.cpp\">\n      <Filter>Source Files\\library</Filter>\n    </ClCompile>\n    <ClCompile Include=\"utilities\\utils.cpp\">\n      <Filter>Source Files\\utilities</Filter>\n    </ClCompile>\n    <ClCompile Include=\"library\\hierarchymodel.cpp\">\n      <Filter>Source Files\\library</Filter>\n    </ClCompile>\n    <ClCompile Include=\"library\\LibraryItem.cpp\">\n      <Filter>Source Files\\library</Filter>\n    </ClCompile>\n    <ClCompile Include=\"library\\LibraryTreeModel.cpp\">\n      <Filter>Source Files\\library</Filter>\n    </ClCompile>\n    <ClCompile Include=\"library\\hierarchyitem.cpp\">\n      <Filter>Source Files\\library</Filter>\n    </ClCompile>\n    <ClCompile Include=\"library\\TagManager.cpp\">\n      <Filter>Source Files\\library</Filter>\n    </ClCompile>\n    <ClCompile Include=\"expressions\\ComponentInstanceParameterFinder.cpp\">\n      <Filter>Source Files\\expressions</Filter>\n    </ClCompile>\n    <ClCompile Include=\"expressions\\ModeConditionParser.cpp\">\n      <Filter>Source Files\\expressions</Filter>\n    </ClCompile>\n    <ClCompile Include=\"interfaces\\component\\ModeReferenceInterface.cpp\">\n      <Filter>Source Files\\interfaces\\component</Filter>\n    </ClCompile>\n    <ClCompile Include=\"interfaces\\component\\AccessPolicyInterface.cpp\">\n      <Filter>Source Files\\interfaces\\component</Filter>\n    </ClCompile>\n    <ClCompile Include=\"utilities\\NullChannel.cpp\">\n      <Filter>Source Files\\utilities</Filter>\n    </ClCompile>\n    <ClCompile Include=\"expressions\\ModeConditionParserInterface.cpp\">\n      <Filter>Source Files\\expressions</Filter>\n    </ClCompile>\n    <ClCompile Include=\"plugins\\InterconnectGenerator\\ConfigJsonParser.cpp\">\n      <Filter>Source Files\\plugins\\InterconnectGenerator</Filter>\n    </ClCompile>\n    <ClCompile Include=\"plugins\\InterconnectGenerator\\InterconnectGenerator.cpp\">\n      <Filter>Source Files\\plugins\\InterconnectGenerator</Filter>\n    </ClCompile>\n    <ClCompile Include=\"plugins\\InterconnectGenerator\\InterconnectRTLWriter.cpp\">\n      <Filter>Source Files\\plugins\\InterconnectGenerator</Filter>\n    </ClCompile>\n    <ClCompile Include=\"expressions\\ParameterConfigurableElementFinder.cpp\">\n      <Filter>Source Files\\expressions</Filter>\n    </ClCompile>\n  </ItemGroup>\n  <ItemGroup>\n    <ClInclude Include=\"include\\ComponentInstanceInterface.h\">\n      <Filter>Header Files\\include</Filter>\n    </ClInclude>\n    <ClInclude Include=\"include\\NullParser.h\">\n      <Filter>Header Files\\include</Filter>\n    </ClInclude>\n  </ItemGroup>\n  <ItemGroup>\n    <QtMoc Include=\"include\\ImportHighlighter.h\">\n      <Filter>Header Files\\include</Filter>\n    </QtMoc>\n    <QtMoc Include=\"include\\ImportRunner.h\">\n      <Filter>Header Files\\include</Filter>\n    </QtMoc>\n    <QtMoc Include=\"include\\ParameterCache.h\">\n      <Filter>Header Files\\include</Filter>\n    </QtMoc>\n    <QtMoc Include=\"include\\LibraryHandler.h\">\n      <Filter>Header Files\\include</Filter>\n    </QtMoc>\n    <QtMoc Include=\"include\\hierarchyitem.h\">\n      <Filter>Header Files\\include</Filter>\n    </QtMoc>\n    <QtMoc Include=\"include\\hierarchymodel.h\">\n      <Filter>Header Files\\include</Filter>\n    </QtMoc>\n    <QtMoc Include=\"include\\LibraryTreeModel.h\">\n      <Filter>Header Files\\include</Filter>\n    </QtMoc>\n    <QtMoc Include=\"include\\LibraryItem.h\">\n      <Filter>Header Files\\include</Filter>\n    </QtMoc>\n    <QtMoc Include=\"include\\ComponentInstanceParameterFinder.h\">\n      <Filter>Header Files\\include</Filter>\n    </QtMoc>\n  </ItemGroup>\n</Project>"
  },
  {
    "path": "KactusAPI/KactusAPIGlobal.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: Global.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Joni-Matti Maatta\r\n// Date: 27.6.2012\r\n//\r\n// Description:\r\n// Global definitions.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef GLOBAL_H\r\n#define GLOBAL_H\r\n\r\n#ifdef KACTUS2_EXPORTS\r\n#define KACTUS2_API Q_DECL_EXPORT\r\n#else\r\n#define KACTUS2_API Q_DECL_IMPORT\r\n#endif\r\n\r\n//-----------------------------------------------------------------------------\r\n\r\n#endif // GLOBAL_H\r\n"
  },
  {
    "path": "KactusAPI/expressions/AddressBlockExpressionsGatherer.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: AddressBlockExpressionGatherer.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Mikko Teuho\r\n// Date: 29.04.2015\r\n//\r\n// Description:\r\n// Gathers expressions from an address block and its registers.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"AddressBlockExpressionsGatherer.h\"\r\n#include \"RegisterExpressionsGatherer.h\"\r\n#include \"RegisterFileExpressionsGatherer.h\"\r\n#include <IPXACTmodels/Component/RegisterBase.h>\r\n#include <IPXACTmodels/Component/Register.h>\r\n#include <IPXACTmodels/Component/RegisterFile.h>\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressBlockExpressionsGatherer::AddressBlockExpressionGatherer()\r\n//-----------------------------------------------------------------------------\r\nAddressBlockExpressionGatherer::AddressBlockExpressionGatherer()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressBlockExpressionsGatherer::~AddressBlockExpressionGatherer()\r\n//-----------------------------------------------------------------------------\r\nAddressBlockExpressionGatherer::~AddressBlockExpressionGatherer()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressBlockExpressionsGatherer::getExpressions()\r\n//-----------------------------------------------------------------------------\r\nQStringList AddressBlockExpressionGatherer::getExpressions(QSharedPointer<AddressBlock> currentAddressBlock) const\r\n{\r\n    QStringList expressionList;\r\n\r\n    expressionList.append(currentAddressBlock->getBaseAddress());\r\n    expressionList.append(currentAddressBlock->getRange());\r\n    expressionList.append(currentAddressBlock->getWidth());\r\n    expressionList.append(currentAddressBlock->getIsPresent());\r\n\r\n    RegisterExpressionsGatherer registerGatherer;\r\n    RegisterFileExpressionsGatherer registerFileGatherer;\r\n\r\n    foreach (QSharedPointer<RegisterBase> registerModel, *currentAddressBlock->getRegisterData())\r\n    {\r\n        QSharedPointer<Register> targetRegister = registerModel.dynamicCast<Register>();\r\n        QSharedPointer<RegisterFile> targetRegisterFile = registerModel.dynamicCast<RegisterFile>();\r\n        if (targetRegister)\r\n        {\r\n          expressionList.append(registerGatherer.getExpressions(targetRegister));\r\n        }\r\n        else if(targetRegisterFile){\r\n          expressionList.append(registerFileGatherer.getExpressions(targetRegisterFile));\r\n        }\r\n    }\r\n\r\n    return expressionList;\r\n}\r\n"
  },
  {
    "path": "KactusAPI/expressions/AddressSpaceExpressionsGatherer.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: AddressSpaceExpressionsGatherer.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Mikko Teuho\r\n// Date: 29.04.2015\r\n//\r\n// Description:\r\n// Gathers expressions from an address space and its memory maps.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"AddressSpaceExpressionsGatherer.h\"\r\n\r\n#include <MemoryMapExpressionsGatherer.h>\r\n\r\n#include <IPXACTmodels/Component/MemoryMapBase.h>\r\n#include <IPXACTmodels/Component/MemoryMap.h>\r\n#include <IPXACTmodels/Component/AddressSpace.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressSpaceExpressionsGatherer::AddressSpaceExpressionGatherer()\r\n//-----------------------------------------------------------------------------\r\nAddressSpaceExpressionGatherer::AddressSpaceExpressionGatherer()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressSpaceExpressionsGatherer::~AddressSpaceExpressionGatherer()\r\n//-----------------------------------------------------------------------------\r\nAddressSpaceExpressionGatherer::~AddressSpaceExpressionGatherer()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressSpaceExpressionsGatherer::getExpressions()\r\n//-----------------------------------------------------------------------------\r\nQStringList AddressSpaceExpressionGatherer::getExpressions(QSharedPointer<AddressSpace> addressSpace) const\r\n{\r\n    QStringList expressionList;\r\n\r\n    expressionList.append(addressSpace->getRange());\r\n    expressionList.append(addressSpace->getWidth());\r\n    expressionList.append(getExpressionsFromSegments(addressSpace->getSegments()));\r\n\r\n    if (addressSpace->hasLocalMemoryMap())\r\n    {\r\n        MemoryMapExpressionGatherer memoryMapGatherer;\r\n\r\n        QSharedPointer<MemoryMap> transformedMemoryMap (new MemoryMap(addressSpace->getLocalMemoryMap()->name()));\r\n        transformedMemoryMap->setAddressUnitBits(addressSpace->getAddressUnitBits());\r\n\r\n        foreach (QSharedPointer<MemoryBlockBase> memoryBlock, *addressSpace->getLocalMemoryMap()->getMemoryBlocks())\r\n        {\r\n            transformedMemoryMap->getMemoryBlocks()->append(memoryBlock);\r\n        }\r\n\r\n        expressionList.append(memoryMapGatherer.getExpressions(transformedMemoryMap));\r\n    }\r\n\r\n    return expressionList;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressSpaceExpressionsGatherer::getExpressionsFromSegments()\r\n//-----------------------------------------------------------------------------\r\nQStringList AddressSpaceExpressionGatherer::getExpressionsFromSegments(\r\n    QSharedPointer<QList<QSharedPointer<Segment> > > segmentList) const\r\n{\r\n    QStringList segmentExpressions;\r\n\r\n    foreach (QSharedPointer<Segment> segment, *segmentList)\r\n    {\r\n        segmentExpressions.append(segment->getAddressOffset());\r\n        segmentExpressions.append(segment->getRange());\r\n    }\r\n\r\n    return segmentExpressions;\r\n}\r\n"
  },
  {
    "path": "KactusAPI/expressions/ComponentAndInstantiationsParameterFinder.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: ComponentAndInstantiationsParameterFinder.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 02.04.2020\n//\n// Description:\n// The implementation for finding parameters from the full component with the correct ID.\n//-----------------------------------------------------------------------------\n\n#include \"ComponentAndInstantiationsParameterFinder.h\"\n\n#include <IPXACTmodels/Component/Component.h>\n#include <IPXACTmodels/Component/ComponentInstantiation.h>\n#include <IPXACTmodels/Component/DesignConfigurationInstantiation.h>\n\n//-----------------------------------------------------------------------------\n// Function: ComponentAndInstantiationsParameterFinder::ComponentAndInstantiationsParameterFinder()\n//-----------------------------------------------------------------------------\nComponentAndInstantiationsParameterFinder::ComponentAndInstantiationsParameterFinder(\n    QSharedPointer<Component const> component) noexcept:\nComponentParameterFinder(component)\n{\n}\n\n//-----------------------------------------------------------------------------\n// Function: ComponentAndInstantiationsParameterFinder::getAllParameterIds()\n//-----------------------------------------------------------------------------\nQStringList ComponentAndInstantiationsParameterFinder::getAllParameterIds() const\n{\n    QStringList allParameterIds = ComponentParameterFinder::getAllParameterIds();\n\n    for (auto instantiationParameter : allInstantiationsParameters())\n    {\n        allParameterIds.append(instantiationParameter->getValueId());\n    }\n\n    allParameterIds.removeAll(QString());\n    return allParameterIds;\n}\n\n//-----------------------------------------------------------------------------\n// Function: ComponentAndInstantiationsParameterFinder::getNumberOfParameters()\n//-----------------------------------------------------------------------------\nint ComponentAndInstantiationsParameterFinder::getNumberOfParameters() const\n{\n    int parameterCount = ComponentParameterFinder::getNumberOfParameters();\n    parameterCount += allInstantiationsParameters().count();\n    \n    return parameterCount;\n}\n\n//-----------------------------------------------------------------------------\n// Function: ComponentAndInstantiationsParameterFinder::searchParameter()\n//-----------------------------------------------------------------------------\nQSharedPointer<Parameter> ComponentAndInstantiationsParameterFinder::searchParameter(QStringView parameterId)\n    const\n{\n    if (QSharedPointer<Parameter> parameter = ComponentParameterFinder::searchParameter(parameterId); \n        parameter)\n    {\n        return parameter;\n    }\n\n    for (auto const& instantiationParameter : allInstantiationsParameters())\n    {\n        if (instantiationParameter->getValueId() == parameterId)\n        {\n            return instantiationParameter;\n        }\n    }\n\n    return QSharedPointer<Parameter>();\n}\n\n//-----------------------------------------------------------------------------\n// Function: ComponentAndInstantiationsParameterFinder::allInstantiationsParameters()\n//-----------------------------------------------------------------------------\nQList<QSharedPointer<Parameter> > ComponentAndInstantiationsParameterFinder::allInstantiationsParameters() const\n{\n    QList<QSharedPointer<Parameter> > instantiationsParameters;\n    for (auto instantiation : *getComponent()->getComponentInstantiations())\n    {\n        instantiationsParameters.append(*instantiation->getParameters());\n\n        for (auto moduleParameter : *instantiation->getModuleParameters())\n        {\n            instantiationsParameters.append(moduleParameter);\n        }\n    }\n\n    for (auto instantiation : *getComponent()->getDesignConfigurationInstantiations())\n    {\n        instantiationsParameters.append(*instantiation->getParameters());\n    }\n\n    return instantiationsParameters;\n}\n"
  },
  {
    "path": "KactusAPI/expressions/ComponentInstanceParameterFinder.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: ComponentInstanceParameterFinder.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Esko Pekkarinen\n// Date: 13.01.2017\n//\n// Description:\n// The implementation for finding parameters for component instance.\n//-----------------------------------------------------------------------------\n\n#include \"ComponentInstanceParameterFinder.h\"\n\n#include <IPXACTmodels/common/ConfigurableElementValue.h>\n\n#include <IPXACTmodels/Design/ComponentInstance.h>\n\n//-----------------------------------------------------------------------------\n// Function: ComponentInstanceParameterFinder::ComponentInstanceParameterFinder()\n//-----------------------------------------------------------------------------\nComponentInstanceParameterFinder::ComponentInstanceParameterFinder(\n    QSharedPointer<const ComponentInstance> componentInstance,\n    QSharedPointer<const Component> component) : \nParameterCache(component),\n    componentInstance_(componentInstance)\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: ComponentInstanceParameterFinder::valueForId()\n//-----------------------------------------------------------------------------\nQString ComponentInstanceParameterFinder::valueForId(QStringView id) const\n{\n    for (QSharedPointer<ConfigurableElementValue> element : *componentInstance_->getConfigurableElementValues())\n    {\n        if (element->getReferenceId().compare(id) == 0)\n        {\n            return element->getConfigurableValue();\n        }\n    }\n\n    return ParameterCache::valueForId(id);\n}\n"
  },
  {
    "path": "KactusAPI/expressions/ComponentInstantiationParameterFinder.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: ComponentInstantiationParameterFinder.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Janne Virtanen\n// Date: 05.05.2017\n//\n// Description:\n// For finding parameters with the correct ID.\n//-----------------------------------------------------------------------------\n\n#include \"ComponentInstantiationParameterFinder.h\"\n\n#include <IPXACTmodels/Component/ComponentInstantiation.h>\n#include <IPXACTmodels/common/Parameter.h>\n\n//-----------------------------------------------------------------------------\n// Function: ComponentInstantiationParameterFinder::ComponentInstantiationParameterFinder()\n//-----------------------------------------------------------------------------\nComponentInstantiationParameterFinder::ComponentInstantiationParameterFinder\n    (QSharedPointer<ComponentInstantiation const> componentInstantiation) :\n    componentInstantiation_(componentInstantiation)\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: ComponentInstantiationParameterFinder::ComponentInstantiationParameterFinder()\n//-----------------------------------------------------------------------------\nQSharedPointer<Parameter> ComponentInstantiationParameterFinder::getParameterWithID(QStringView parameterId) const\n{\n    return searchParameter(parameterId);\n}\n\n//-----------------------------------------------------------------------------\n// Function: ComponentInstantiationParameterFinder::hasId()\n//-----------------------------------------------------------------------------\nbool ComponentInstantiationParameterFinder::hasId(QStringView id) const\n{\n    return !componentInstantiation_.isNull() && searchParameter(id);\n}\n\n//-----------------------------------------------------------------------------\n// Function: ComponentInstantiationParameterFinder::nameForId()\n//-----------------------------------------------------------------------------\nQString ComponentInstantiationParameterFinder::nameForId(QStringView id) const\n{\n    if (QSharedPointer <Parameter> targetParameter = getParameterWithID(id); \n        targetParameter)\n    {\n        return targetParameter->name();\n    }\n\n    return QString();\n}\n\n//-----------------------------------------------------------------------------\n// Function: ComponentInstantiationParameterFinder::valueForId()\n//-----------------------------------------------------------------------------\nQString ComponentInstantiationParameterFinder::valueForId(QStringView id) const\n{\n    if (QSharedPointer<Parameter> targetParameter = getParameterWithID(id); \n        targetParameter)\n    {\n        return targetParameter->getValue();\n    }\n\n    return QString();\n}\n\n//-----------------------------------------------------------------------------\n// Function: ComponentInstantiationParameterFinder::getAllParameterIds()\n//-----------------------------------------------------------------------------\nQStringList ComponentInstantiationParameterFinder::getAllParameterIds() const\n{\n    QStringList allParameterIds;\n\n    if (componentInstantiation_)\n    {\n        for (QSharedPointer<ModuleParameter> parameter : *componentInstantiation_->getModuleParameters())\n        {\n            allParameterIds.append(parameter->getValueId());\n        }\n\n        for (QSharedPointer<Parameter> parameter : *componentInstantiation_->getParameters())\n        {\n            allParameterIds.append(parameter->getValueId());\n        }\n    }\n\n    allParameterIds.removeAll(QString());\n    return allParameterIds;\n}\n\n//-----------------------------------------------------------------------------\n// Function: ComponentInstantiationParameterFinder::getNumberOfParameters()\n//-----------------------------------------------------------------------------\nint ComponentInstantiationParameterFinder::getNumberOfParameters() const\n{\n    int parameterCount = 0;\n    if (componentInstantiation_)\n    {\n        parameterCount += componentInstantiation_->getModuleParameters()->count();\n        parameterCount += componentInstantiation_->getParameters()->count();\n    }\n    return parameterCount;\n}\n\n//-----------------------------------------------------------------------------\n// Function: ComponentInstantiationParameterFinder::setComponentInstantiation()\n//-----------------------------------------------------------------------------\nvoid ComponentInstantiationParameterFinder::setComponentInstantiation(QSharedPointer<ComponentInstantiation const> componentInstantiation)\n{\n    componentInstantiation_ = componentInstantiation;\n}\n\n//-----------------------------------------------------------------------------\n// Function: ComponentInstantiationParameterFinder::registerParameterModel()\n//-----------------------------------------------------------------------------\nvoid ComponentInstantiationParameterFinder::registerParameterModel(QAbstractItemModel const* /*model*/)\n{\n    // Nothing to do.\n}\n\n//-----------------------------------------------------------------------------\n// Function: ComponentInstantiationParameterFinder::searchParameter()\n//-----------------------------------------------------------------------------\nQSharedPointer<Parameter> ComponentInstantiationParameterFinder::searchParameter(QStringView parameterId) const\n{\n    if (componentInstantiation_)\n    {\n        for (QSharedPointer<ModuleParameter> parameter : *componentInstantiation_->getModuleParameters())\n        {\n            if (parameter->getValueId() == parameterId)\n            {\n                return parameter;\n            }\n        }\n\n        for (QSharedPointer<Parameter> parameter : *componentInstantiation_->getParameters())\n        {\n            if (parameter->getValueId() == parameterId)\n            {\n                return parameter;\n            }\n        }\n    }    \n\n    return QSharedPointer<Parameter>();\n}"
  },
  {
    "path": "KactusAPI/expressions/ComponentParameterFinder.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ComponentParameterFinder.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Mikko Teuho\r\n// Date: 15.01.2015\r\n//\r\n// Description:\r\n// The implementation for finding parameters with the correct ID.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"ComponentParameterFinder.h\"\r\n\r\n#include <IPXACTmodels/common/Parameter.h>\r\n#include <IPXACTmodels/Component/Component.h>\r\n#include <IPXACTmodels/Component/AddressSpace.h>\r\n#include <IPXACTmodels/Component/AddressBlock.h>\r\n#include <IPXACTmodels/Component/BusInterface.h>\r\n#include <IPXACTmodels/Component/Cpu.h>\r\n#include <IPXACTmodels/Component/ComponentGenerator.h>\r\n#include <IPXACTmodels/Component/MemoryMap.h>\r\n#include <IPXACTmodels/Component/MemoryBlockBase.h>\r\n#include <IPXACTmodels/Component/RegisterBase.h>\r\n#include <IPXACTmodels/Component/IndirectInterface.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentParameterFinder::ComponentParameterFinder()\r\n//-----------------------------------------------------------------------------\r\nComponentParameterFinder::ComponentParameterFinder(QSharedPointer<Component const> component) noexcept :\r\ncomponent_(component)\r\n{\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentParameterFinder::ComponentParameterFinder()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<Parameter> ComponentParameterFinder::getParameterWithID(QStringView parameterId) const\r\n{\r\n    return searchParameter(parameterId);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentParameterFinder::hasId()\r\n//-----------------------------------------------------------------------------\r\nbool ComponentParameterFinder::hasId(QStringView id) const\r\n{\r\n    return !component_.isNull() && searchParameter(id);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentParameterFinder::nameForId()\r\n//-----------------------------------------------------------------------------\r\nQString ComponentParameterFinder::nameForId(QStringView id) const\r\n{\r\n    if (QSharedPointer <Parameter> targetParameter = getParameterWithID(id); \r\n        targetParameter)\r\n    {\r\n        return targetParameter->name();\r\n    }\r\n\r\n    return QString();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentParameterFinder::valueForId()\r\n//-----------------------------------------------------------------------------\r\nQString ComponentParameterFinder::valueForId(QStringView id) const\r\n{\r\n    if (QSharedPointer<Parameter> targetParameter = getParameterWithID(id); \r\n        targetParameter)\r\n    {\r\n        return targetParameter->getValue();\r\n    }\r\n\r\n    return QString();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentParameterFinder::getAllParameterIds()\r\n//-----------------------------------------------------------------------------\r\nQStringList ComponentParameterFinder::getAllParameterIds() const\r\n{\r\n    QStringList allParameterIds;\r\n\r\n    if (!component_.isNull())\r\n    {\r\n        for (QSharedPointer<Parameter> parameter : *component_->getParameters())\r\n        {\r\n            allParameterIds.append(parameter->getValueId());\r\n        }\r\n\r\n        for (QSharedPointer<Parameter> cpuParameter : allCpuParameters())\r\n        {\r\n            allParameterIds.append(cpuParameter->getValueId());\r\n        }\r\n\r\n        for (QSharedPointer<Parameter> generatorParameter : allGeneratorParameters())\r\n        {\r\n            allParameterIds.append(generatorParameter->getValueId());\r\n        }\r\n\r\n        for (QSharedPointer<Parameter> busInterfaceParameter : allBusInterfaceParameters())\r\n        {\r\n            allParameterIds.append(busInterfaceParameter->getValueId());\r\n        }\r\n\r\n        for (QSharedPointer<Parameter> addressSpaceParameter : allAddressSpaceParameters())\r\n        {\r\n            allParameterIds.append(addressSpaceParameter->getValueId());\r\n        }\r\n\r\n        for (QSharedPointer<Parameter> registerParameter : allRegisterParameters())\r\n        {\r\n            allParameterIds.append(registerParameter->getValueId());\r\n        }\r\n\r\n        for (auto indirectInterfaceParameter : allIndirectInterfacesParameters())\r\n        {\r\n            allParameterIds.append(indirectInterfaceParameter->getValueId());\r\n        }\r\n    }\r\n\r\n    allParameterIds.removeAll(QString());\r\n    return allParameterIds;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentParameterFinder::getNumberOfParameters()\r\n//-----------------------------------------------------------------------------\r\nint ComponentParameterFinder::getNumberOfParameters() const\r\n{\r\n    int parameterCount = 0;\r\n    if (!component_.isNull())\r\n    {\r\n        parameterCount += component_->getParameters()->count();\r\n        parameterCount += allGeneratorParameters().count();\r\n        parameterCount += allCpuParameters().count();\r\n        parameterCount += allAddressSpaceParameters().count();\r\n        parameterCount += busInterfaceParameterCount();\r\n        parameterCount += registerParameterCount();\r\n        parameterCount += allIndirectInterfacesParameters().count();\r\n    }\r\n    return parameterCount;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentParameterFinder::registerParameterModel()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentParameterFinder::registerParameterModel(QAbstractItemModel const* /*model*/)\r\n{\r\n    // Nothing to do.\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentParameterFinder::setComponent()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentParameterFinder::setComponent(QSharedPointer<Component const> component)\r\n{\r\n    component_ = component;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentParameterFinder::searchParameter()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<Parameter> ComponentParameterFinder::searchParameter(QStringView parameterId) const\r\n{\r\n    if (component_ == nullptr)\r\n    {\r\n        return nullptr;\r\n    }\r\n\r\n    for (QSharedPointer<Parameter> parameter : *component_->getParameters())\r\n    {\r\n        if (parameter->getValueId() == parameterId)\r\n        {\r\n            return parameter;\r\n        }\r\n    }\r\n\r\n    for (QSharedPointer<Parameter> busInterfaceParameter : allBusInterfaceParameters())\r\n    {\r\n        if (busInterfaceParameter->getValueId() == parameterId)\r\n        {\r\n            return busInterfaceParameter;\r\n        }\r\n    }\r\n\r\n    for (QSharedPointer<Parameter> cpuParameter : allCpuParameters())\r\n    {\r\n        if (cpuParameter->getValueId() == parameterId)\r\n        {\r\n            return cpuParameter;\r\n        }\r\n    }\r\n\r\n    for (QSharedPointer<Parameter> generatorParameter : allGeneratorParameters())\r\n    {\r\n        if (generatorParameter->getValueId() == parameterId)\r\n        {\r\n            return generatorParameter;\r\n        }\r\n    }\r\n\r\n    for (QSharedPointer<Parameter> addressSpaceParameter : allAddressSpaceParameters())\r\n    {\r\n        if (addressSpaceParameter->getValueId() == parameterId)\r\n        {\r\n            return addressSpaceParameter;\r\n        }\r\n    }\r\n\r\n    for (QSharedPointer<Parameter> registerParameter : allRegisterParameters())\r\n    {\r\n        if (registerParameter->getValueId() == parameterId)\r\n        {\r\n            return registerParameter;\r\n        }\r\n    }\r\n\r\n    for (auto indirectInterfaceParameter : allIndirectInterfacesParameters())\r\n    {\r\n        if (indirectInterfaceParameter->getValueId() == parameterId)\r\n        {\r\n            return indirectInterfaceParameter;\r\n        }\r\n    }\r\n\r\n    return QSharedPointer<Parameter>();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentParameterFinder::allBusInterfaceParameters()\r\n//-----------------------------------------------------------------------------\r\nQList<QSharedPointer<Parameter> > ComponentParameterFinder::allBusInterfaceParameters() const\r\n{\r\n    QList<QSharedPointer<Parameter> > busInterfaceParameters;\r\n    for (QSharedPointer<BusInterface> busInterface : *component_->getBusInterfaces())\r\n    {\r\n        busInterfaceParameters.append(*busInterface->getParameters());\r\n    }\r\n\r\n    return busInterfaceParameters;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentParameterFinder::allCpuParameters()\r\n//-----------------------------------------------------------------------------\r\nQList<QSharedPointer<Parameter> > ComponentParameterFinder::allCpuParameters() const\r\n{\r\n    QList<QSharedPointer<Parameter> > cpuParameters;\r\n    for (QSharedPointer<Cpu> cpu : *component_->getCpus())\r\n    {\r\n        cpuParameters.append(*cpu->getParameters());\r\n    }\r\n\r\n    return cpuParameters;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentParameterFinder::allGeneratorParameters()\r\n//-----------------------------------------------------------------------------\r\nQList<QSharedPointer<Parameter> > ComponentParameterFinder::allGeneratorParameters() const\r\n{\r\n    QList<QSharedPointer<Parameter> > generatorParameters;\r\n    for (QSharedPointer<ComponentGenerator> generator : *component_->getComponentGenerators())\r\n    {\r\n        generatorParameters.append(*generator->getParameters());\r\n    }\r\n\r\n    return generatorParameters;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentParameterFinder::allAddressSpaceParameters()\r\n//-----------------------------------------------------------------------------\r\nQList<QSharedPointer<Parameter> > ComponentParameterFinder::allAddressSpaceParameters() const\r\n{\r\n    QList<QSharedPointer<Parameter> > parameters;\r\n    for (QSharedPointer<AddressSpace> addressSpace : *component_->getAddressSpaces())\r\n    {\r\n        parameters.append(*addressSpace->getParameters());\r\n\r\n        if (addressSpace->getLocalMemoryMap())\r\n        {\r\n            for (QSharedPointer<MemoryBlockBase> memoryBlock : *addressSpace->getLocalMemoryMap()->getMemoryBlocks())\r\n            {\r\n                QSharedPointer<AddressBlock> addressBlock = memoryBlock.dynamicCast<AddressBlock>();\r\n                if (addressBlock)\r\n                {\r\n                    for (QSharedPointer<RegisterBase> registerBase : *addressBlock->getRegisterData())\r\n                    {\r\n                        parameters.append(*registerBase->getParameters());\r\n                    }\r\n                }\r\n            }\r\n        }\r\n    }\r\n\r\n    return parameters;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentParameterFinder::allRegisterParameters()\r\n//-----------------------------------------------------------------------------\r\nQList<QSharedPointer<Parameter> > ComponentParameterFinder::allRegisterParameters() const\r\n{\r\n    QList<QSharedPointer<Parameter> > registerParameters;\r\n    for (QSharedPointer<MemoryMapBase> memoryMap : *component_->getMemoryMaps())\r\n    {\r\n        for (QSharedPointer<MemoryBlockBase> memoryBlock : *memoryMap->getMemoryBlocks())\r\n        {\r\n            QSharedPointer<AddressBlock> addressBlock = memoryBlock.dynamicCast<AddressBlock>();\r\n            if (addressBlock)\r\n            {\r\n                for (QSharedPointer<RegisterBase> registerBase : *addressBlock->getRegisterData())\r\n                {\r\n                    registerParameters.append(*registerBase->getParameters());\r\n                }\r\n            }\r\n        }\r\n    }\r\n\r\n    return registerParameters;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentParameterFinder::busInterfaceParameterCount()\r\n//-----------------------------------------------------------------------------\r\nint ComponentParameterFinder::busInterfaceParameterCount() const\r\n{\r\n    int parameterCount = 0;\r\n    for (QSharedPointer<BusInterface> busInterface : *component_->getBusInterfaces())\r\n    {\r\n        parameterCount += busInterface->getParameters()->count();\r\n    }\r\n\r\n    return parameterCount;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentParameterFinder::registerParameterCount()\r\n//-----------------------------------------------------------------------------\r\nint ComponentParameterFinder::registerParameterCount() const\r\n{\r\n    int parameterCount = 0;\r\n\r\n    for (QSharedPointer<MemoryMapBase> memoryMap : *component_->getMemoryMaps())\r\n    {\r\n        for (QSharedPointer<MemoryBlockBase> memoryBlock : *memoryMap->getMemoryBlocks())\r\n        {\r\n            QSharedPointer<AddressBlock> addressBlock = memoryBlock.dynamicCast<AddressBlock>();\r\n            if (addressBlock)\r\n            {\r\n                for (QSharedPointer<RegisterBase> registerBase : *addressBlock->getRegisterData())\r\n                {\r\n                    parameterCount += registerBase->getParameters()->count();\r\n                }\r\n            }\r\n        }\r\n    }\r\n\r\n    return parameterCount;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentParameterFinder::allIndirectInterfacesParameters()\r\n//-----------------------------------------------------------------------------\r\nQList<QSharedPointer<Parameter> > ComponentParameterFinder::allIndirectInterfacesParameters() const\r\n{\r\n    QList<QSharedPointer<Parameter> > indirectInterfacesParameters;\r\n\r\n    for (auto indirectInterface : *component_->getIndirectInterfaces())\r\n    {\r\n        indirectInterfacesParameters.append(*indirectInterface->getParameters());\r\n    }\r\n\r\n    return indirectInterfacesParameters;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentParameterFinder::getComponent()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<const Component> ComponentParameterFinder::getComponent() const noexcept\r\n{\r\n    return component_;\r\n}\r\n"
  },
  {
    "path": "KactusAPI/expressions/DesignParameterFinder.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: DesignParameterFinder.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 04.04.2022\n//\n// Description:\n// The implementation for finding parameters for designs.\n//-----------------------------------------------------------------------------\n\n#include \"DesignParameterFinder.h\"\n\n#include <IPXACTmodels/common/ConfigurableVLNVReference.h>\n#include <IPXACTmodels/common/ConfigurableElementValue.h>\n#include <IPXACTmodels/Component/DesignInstantiation.h>\n\n//-----------------------------------------------------------------------------\n// Function: ComponentInstanceParameterFinder::ComponentInstanceParameterFinder()\n//-----------------------------------------------------------------------------\nDesignParameterFinder::DesignParameterFinder(QSharedPointer<DesignInstantiation> designInstantiation):\nListParameterFinder()\n{\n    if (designInstantiation && designInstantiation->getDesignReference())\n    {\n        configurableElementValues_ = designInstantiation->getDesignReference()->getConfigurableElementValues();\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: DesignParameterFinder::valueForId()\n//-----------------------------------------------------------------------------\nQString DesignParameterFinder::valueForId(QStringView id) const\n{\n    if (configurableElementValues_)\n    {\n        for (QSharedPointer<ConfigurableElementValue> element : *configurableElementValues_)\n        {\n            if (element->getReferenceId().compare(id) == 0)\n            {\n                return element->getConfigurableValue();\n            }\n        }\n    }\n\n    return ListParameterFinder::valueForId(id);\n}\n"
  },
  {
    "path": "KactusAPI/expressions/ExpressionFormatter.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ExpressionFormatter.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Mikko Teuho\r\n// Date: 26.01.2015\r\n//\r\n// Description:\r\n// Formatter for parameter expressions consisting of references.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"ExpressionFormatter.h\"\r\n\r\n#include \"ExpressionParser.h\"\r\n\r\n#include <IPXACTmodels/common/validators/ValueFormatter.h>\r\n\r\n#include <QStringList>\r\n#include <QRegularExpression>\r\n\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ExpressionFormatter::ExpressionFormatter()\r\n//-----------------------------------------------------------------------------\r\nExpressionFormatter::ExpressionFormatter(QSharedPointer<ParameterFinder> parameterFinder):\r\nparameterFinder_(parameterFinder)\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ExpressionFormatter::~ExpressionFormatter()\r\n//-----------------------------------------------------------------------------\r\nExpressionFormatter::~ExpressionFormatter()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ExpressionFormatter::format()\r\n//-----------------------------------------------------------------------------\r\nQString ExpressionFormatter::format(QString const& expression, QSharedPointer<ExpressionParser> parser, bool* expressionIsValid /*= nullptr*/)\r\n{\r\n    if (expressionIsValid != nullptr)\r\n    {\r\n        return getFormattedValue(expression, parser, expressionIsValid);\r\n    }\r\n    else\r\n    {\r\n\t\tbool isValidExpression = false;\r\n        return getFormattedValue(expression, parser, &isValidExpression);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ExpressionFormatter::getFormattedValue()\r\n//-----------------------------------------------------------------------------\r\nQString ExpressionFormatter::getFormattedValue(QString const& expression, QSharedPointer<ExpressionParser> parser, bool* expressionIsValid)\r\n{\r\n    QString value = parser->parseExpression(expression, expressionIsValid);\r\n\r\n    if (expressionIsValid && *expressionIsValid == true)\r\n    {\r\n        ValueFormatter formatter;\r\n        return formatter.format(value, parser->baseForExpression(expression));\r\n    }\r\n    else\r\n    {\r\n        return \"n/a\";\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ExpressionFormatter::formatExpressionWithReference()\r\n//-----------------------------------------------------------------------------\r\nQString ExpressionFormatter::formatReferringExpression(QString const& expression) const\r\n{\r\n    static const QRegularExpression NON_ALPHA_CHARACTERS(\"[^a-zA-Z0-9:_.]+\");\r\n\r\n    QString formattedExpression = expression;\r\n\r\n    for (QString const& valueID : expression.split(NON_ALPHA_CHARACTERS, Qt::SkipEmptyParts))\r\n    {\r\n        if (parameterFinder_->hasId(valueID))\r\n        {\r\n            formattedExpression.replace(valueID, parameterFinder_->nameForId(valueID));\r\n        }\r\n    }\r\n\r\n    return formattedExpression;\r\n}\r\n"
  },
  {
    "path": "KactusAPI/expressions/ExpressionFormatterFactoryImplementation.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ExpressionFormatterFactoryImplementation.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Mikko Teuho\r\n// Date: 16.02.2015\r\n//\r\n// Description:\r\n// Class for expression formatter factory.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"ExpressionFormatterFactoryImplementation.h\"\r\n\r\n#include \"ComponentParameterFinder.h\"\r\n#include \"ListParameterFinder.h\"\r\n#include \"MultipleParameterFinder.h\"\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ExpressionFormatterFactoryImplementation::ExpressionFormatterFactoryImplementation()\r\n//-----------------------------------------------------------------------------\r\nExpressionFormatterFactoryImplementation::ExpressionFormatterFactoryImplementation()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ExpressionFormatterFactoryImplementation::~ExpressionFormatterFactoryImplementation()\r\n//-----------------------------------------------------------------------------\r\nExpressionFormatterFactoryImplementation::~ExpressionFormatterFactoryImplementation()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ExpressionFormatterFactoryImplementation::makeExpressionFormatter()\r\n//-----------------------------------------------------------------------------\r\nExpressionFormatter* ExpressionFormatterFactoryImplementation::makeExpressionFormatter(\r\n    QSharedPointer<Component> component)\r\n{\r\n    QSharedPointer<ParameterFinder> parameterFinder (new ComponentParameterFinder(component));\r\n\r\n    ExpressionFormatter* expressionFormatter = new ExpressionFormatter(parameterFinder);\r\n\r\n    return expressionFormatter;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ExpressionFormatterFactoryImplementation::createDesignInstanceFormatter()\r\n//-----------------------------------------------------------------------------\r\nExpressionFormatter* ExpressionFormatterFactoryImplementation::createDesignInstanceFormatter(\r\n    QSharedPointer<Component> component, QSharedPointer<Design> design)\r\n{\r\n    QSharedPointer<ListParameterFinder> designFinder(new ListParameterFinder());\r\n    designFinder->setParameterList(design->getParameters());\r\n\r\n    QSharedPointer<ComponentParameterFinder> componentFinder(new ComponentParameterFinder(component));\r\n\r\n    QSharedPointer<MultipleParameterFinder> designInstanceFinder(new MultipleParameterFinder());\r\n    designInstanceFinder->addFinder(designFinder);\r\n    designInstanceFinder->addFinder(componentFinder);\r\n\r\n    ExpressionFormatter* formatter = new ExpressionFormatter(designInstanceFinder);\r\n    return formatter;\r\n}\r\n"
  },
  {
    "path": "KactusAPI/expressions/FieldExpressionsGatherer.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: FieldExpressionsGatherer.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Mikko Teuho\r\n// Date: 29.04.2015\r\n//\r\n// Description:\r\n// Gathers expressions from a field.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"FieldExpressionsGatherer.h\"\r\n\r\n#include <IPXACTmodels/Component/Field.h>\r\n#include <IPXACTmodels/Component/FieldReset.h>\r\n#include <IPXACTmodels/Component/WriteValueConstraint.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FieldExpressionGatherer::FieldExpressionGatherer()\r\n//-----------------------------------------------------------------------------\r\nFieldExpressionsGatherer::FieldExpressionsGatherer()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FieldExpressionsGatherer::~FieldExpressionsGatherer()\r\n//-----------------------------------------------------------------------------\r\nFieldExpressionsGatherer::~FieldExpressionsGatherer()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FieldExpressionGatherer::getExpressions()\r\n//-----------------------------------------------------------------------------\r\nQStringList FieldExpressionsGatherer::getExpressions(QSharedPointer<Field> field) const\r\n{\r\n    QStringList expressionList;\r\n\r\n    expressionList.append(field->getBitOffset());\r\n    expressionList.append(field->getBitWidth());\r\n    expressionList.append(field->getIsPresent());\r\n\r\n    if (field->getResets())\r\n    {\r\n        for (auto fieldReset : *field->getResets())\r\n        {\r\n            expressionList.append(fieldReset->getResetValue());\r\n            expressionList.append(fieldReset->getResetMask());\r\n        }\r\n    }\r\n\r\n    if (field->getWriteConstraint())\r\n    {\r\n        expressionList.append(field->getWriteConstraint()->getMinimum());\r\n        expressionList.append(field->getWriteConstraint()->getMaximum());\r\n    }\r\n\r\n    return expressionList;\r\n}\r\n"
  },
  {
    "path": "KactusAPI/expressions/IPXactSystemVerilogParser.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: IPXactSystemVerilogParser.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Esko Pekkarinen\r\n// Date: 02.12.2014\r\n//\r\n// Description:\r\n// Parser for SystemVerilog expressions with parameter references.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"IPXactSystemVerilogParser.h\"\r\n\r\n#include \"ParameterFinder.h\"\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: IPXactSystemVerilogParser::IPXactSystemVerilogParser()\r\n//-----------------------------------------------------------------------------\r\nIPXactSystemVerilogParser::IPXactSystemVerilogParser(QSharedPointer<ParameterFinder> finder):\r\nSystemVerilogExpressionParser(), finder_(finder)\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: IPXactSystemVerilogParser::isSymbol()\r\n//-----------------------------------------------------------------------------\r\nbool IPXactSystemVerilogParser::isSymbol(QStringView expression) const\r\n{\r\n    return finder_->hasId(expression);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: IPXactSystemVerilogParser::findSymbolValue()\r\n//-----------------------------------------------------------------------------\r\nQString IPXactSystemVerilogParser::findSymbolValue(QStringView expression) const\r\n{\r\n    // Check for ring references.\r\n    if (symbolStack_.contains(expression))\r\n    {\r\n        symbolStack_.clear();\r\n        return QStringLiteral(\"x\");\r\n    }\r\n\r\n    symbolStack_.append(expression);\r\n    QString value = parseExpression(finder_->valueForId(expression));\r\n    if (symbolStack_.isEmpty() == false)\r\n    {\r\n        symbolStack_.removeLast();\r\n    }\r\n\r\n    return value;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: IPXactSystemVerilogParser::findSymbolValue()\r\n//-----------------------------------------------------------------------------\r\nint IPXactSystemVerilogParser::getBaseForSymbol(QStringView symbol) const\r\n{\r\n    return baseForExpression(finder_->valueForId(symbol));\r\n}\r\n"
  },
  {
    "path": "KactusAPI/expressions/ListParameterFinder.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ListParameterFinder.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Mikko Teuho\r\n// Date: 24.03.2015\r\n//\r\n// Description:\r\n// The implementation for finding parameters from a list with the correct ID.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"ListParameterFinder.h\"\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ListParameterFinder::ListParameterFinder()\r\n//-----------------------------------------------------------------------------\r\nListParameterFinder::ListParameterFinder():\r\nParameterFinder()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ListParameterFinder::getParameterWithID()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<Parameter> ListParameterFinder::getParameterWithID(QStringView parameterId) const\r\n{\r\n    if (parameterList_)\r\n    {\r\n        for (QSharedPointer<Parameter> parameter : *parameterList_)\r\n        {\r\n            if (parameter->getValueId().compare(parameterId) == 0)\r\n            {\r\n                return parameter;\r\n            }\r\n        }\r\n    }\r\n\r\n    return QSharedPointer<Parameter>();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ListParameterFinder::hasId()\r\n//-----------------------------------------------------------------------------\r\nbool ListParameterFinder::hasId(QStringView id) const\r\n{\r\n    if (parameterList_ == nullptr)\r\n    {\r\n        return false;\r\n    }\r\n\r\n    return std::any_of(parameterList_->cbegin(), parameterList_->cend(), \r\n        [id](auto const& parameter) { return parameter->getValueId().compare(id) == 0; });\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ListParameterFinder::nameForId()\r\n//-----------------------------------------------------------------------------\r\nQString ListParameterFinder::nameForId(QStringView id) const\r\n{\r\n    if (QSharedPointer<Parameter> targetParameter = getParameterWithID(id); \r\n        targetParameter)\r\n    {\r\n        return targetParameter->name();\r\n    }\r\n\r\n    return QString();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ListParameterFinder::valueForId()\r\n//-----------------------------------------------------------------------------\r\nQString ListParameterFinder::valueForId(QStringView id) const\r\n{\r\n    \r\n    if (QSharedPointer<Parameter> targetParameter = getParameterWithID(id); \r\n        targetParameter)\r\n    {\r\n        return targetParameter->getValue();\r\n    }\r\n\r\n    return QString();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ListParameterFinder::getAllParameterIds()\r\n//-----------------------------------------------------------------------------\r\nQStringList ListParameterFinder::getAllParameterIds() const\r\n{\r\n    QStringList allParameterIds;\r\n\r\n    if (parameterList_)\r\n    {\r\n        for (QSharedPointer<Parameter> parameter : *parameterList_)\r\n        {\r\n            allParameterIds.append(parameter->getValueId());\r\n        }\r\n    }\r\n\r\n    allParameterIds.removeAll(QString());\r\n    return allParameterIds;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ListParameterFinder::getNumberOfParameters()\r\n//-----------------------------------------------------------------------------\r\nint ListParameterFinder::getNumberOfParameters() const noexcept\r\n{\r\n    return parameterList_->size();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ListParameterFinder::setParameterList()\r\n//-----------------------------------------------------------------------------\r\nvoid ListParameterFinder::setParameterList(QSharedPointer<QList<QSharedPointer<Parameter> > > parameterList) noexcept\r\n{\r\n    parameterList_ = parameterList;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ListParameterFinder::registerParameterModel()\r\n//-----------------------------------------------------------------------------\r\nvoid ListParameterFinder::registerParameterModel(QAbstractItemModel const* /*model*/)\r\n{\r\n    // Nothing to do.\r\n}\r\n"
  },
  {
    "path": "KactusAPI/expressions/MemoryMapExpressionsGatherer.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: MemoryMapExpressionsGatherer.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Mikko Teuho\r\n// Date: 29.04.2015\r\n//\r\n// Description:\r\n// Gathers expressions from a memory map and its memory remaps.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"MemoryMapExpressionsGatherer.h\"\r\n#include \"MemoryRemapExpressionGatherer.h\"\r\n\r\n#include <IPXACTmodels/Component/MemoryMap.h>\r\n#include <IPXACTmodels/Component/MemoryRemap.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryMapExpressionsGatherer::MemoryMapExpressionGatherer()\r\n//-----------------------------------------------------------------------------\r\nMemoryMapExpressionGatherer::MemoryMapExpressionGatherer()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryMapExpressionsGatherer::~MemoryMapExpressionGatherer()\r\n//-----------------------------------------------------------------------------\r\nMemoryMapExpressionGatherer::~MemoryMapExpressionGatherer()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryMapExpressionsGatherer::getExpressions()\r\n//-----------------------------------------------------------------------------\r\nQStringList MemoryMapExpressionGatherer::getExpressions(QSharedPointer<MemoryMap> memoryMap) const\r\n{\r\n    QStringList expressionList;\r\n\r\n    MemoryRemapExpressionGatherer memoryRemapGatherer;\r\n\r\n    expressionList.append(memoryRemapGatherer.getExpressions(memoryMap));\r\n\r\n    foreach (QSharedPointer<MemoryRemap> memoryRemap, *memoryMap->getMemoryRemaps())\r\n    {\r\n        expressionList.append(memoryRemapGatherer.getExpressions(memoryRemap));\r\n    }\r\n\r\n    return expressionList;\r\n}\r\n"
  },
  {
    "path": "KactusAPI/expressions/MemoryRemapExpressionGatherer.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: MemoryRemapExpressionsGatherer.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Mikko Teuho\r\n// Date: 29.04.2015\r\n//\r\n// Description:\r\n// Gathers expressions from a memory remap and its address blocks.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"MemoryRemapExpressionGatherer.h\"\r\n#include \"AddressBlockExpressionsGatherer.h\"\r\n\r\n#include <IPXACTmodels/Component/MemoryMapBase.h>\r\n#include <IPXACTmodels/Component/MemoryBlockBase.h>\r\n#include <IPXACTmodels/Component/AddressBlock.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryRemapExpressionGatherer::MemoryRemapExpressionGatherer()\r\n//-----------------------------------------------------------------------------\r\nMemoryRemapExpressionGatherer::MemoryRemapExpressionGatherer()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryRemapExpressionGatherer::~MemoryRemapExpressionGatherer()\r\n//-----------------------------------------------------------------------------\r\nMemoryRemapExpressionGatherer::~MemoryRemapExpressionGatherer()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryRemapExpressionsGatherer::getExpressions()\r\n//-----------------------------------------------------------------------------\r\nQStringList MemoryRemapExpressionGatherer::getExpressions(QSharedPointer<MemoryMapBase> memoryMap) const\r\n{\r\n    QStringList expressionList;\r\n\r\n    expressionList.append(memoryMap->getIsPresent());\r\n\r\n    AddressBlockExpressionGatherer addressBlockGatherer;\r\n\r\n    foreach(QSharedPointer<MemoryBlockBase> memoryBlock, *memoryMap->getMemoryBlocks())\r\n    {\r\n        QSharedPointer<AddressBlock> addressBlock = memoryBlock.dynamicCast<AddressBlock>();\r\n        if (addressBlock)\r\n        {\r\n            expressionList.append(addressBlockGatherer.getExpressions(addressBlock));\r\n        }\r\n    }\r\n\r\n    return expressionList;\r\n}\r\n"
  },
  {
    "path": "KactusAPI/expressions/ModeConditionParser.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: ModeConditionParser.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Esko Pekkarinen\n// Date: 16.10.2023\n//\n// Description:\n// Parser for Mode condition expressions.\n//-----------------------------------------------------------------------------\n\n#include \"ModeConditionParser.h\"\n#include \"IPXactSystemVerilogParser.h\"\n\n#include <IPXACTmodels/utilities/Search.h>\n\n//-----------------------------------------------------------------------------\n// Function: ModeConditionParser::ModeConditionParser()\n//-----------------------------------------------------------------------------\nModeConditionParser::ModeConditionParser(QSharedPointer<ParameterFinder> finder,\n    PortSlice::List portSlices,\n    FieldSlice::List fieldSlices,\n    Mode::List modes):\n    IPXactSystemVerilogParser(finder),\n    portSlices_(portSlices),\n    fieldSlices_(fieldSlices),\n    modes_(modes)\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: ModeConditionParser::setFieldSlices()\n//-----------------------------------------------------------------------------\nvoid ModeConditionParser::setFieldSlices(FieldSlice::List fieldSlices)\n{\n    fieldSlices_ = fieldSlices;\n}\n\n//-----------------------------------------------------------------------------\n// Function: ModeConditionParser::setPortSlices()\n//-----------------------------------------------------------------------------\nvoid ModeConditionParser::setPortSlices(PortSlice::List portSlices)\n{\n    portSlices_ = portSlices;\n}\n\n//-----------------------------------------------------------------------------\n// Function: ModeConditionParser::setModes()\n//-----------------------------------------------------------------------------\nvoid ModeConditionParser::setModes(Mode::List modes)\n{\n    modes_ = modes;\n}\n\n//-----------------------------------------------------------------------------\n// Function: ModeConditionParser::isSymbol()\n//-----------------------------------------------------------------------------\nbool ModeConditionParser::isSymbol(QStringView expression) const\n{\n    return isModeReference(expression) || IPXactSystemVerilogParser::isSymbol(expression);\n}\n\n//-----------------------------------------------------------------------------\n// Function: ModeConditionParser::findSymbolValue()\n//-----------------------------------------------------------------------------\nQString ModeConditionParser::findSymbolValue(QStringView symbol) const\n{\n    if (isModeReference(symbol))\n    {\n        return symbol.toString();\n    }\n\n    return IPXactSystemVerilogParser::findSymbolValue(symbol);\n}\n\n//-----------------------------------------------------------------------------\n// Function: ModeConditionParser::isUnaryOperator()\n//-----------------------------------------------------------------------------\nbool ModeConditionParser::isUnaryOperator(QStringView token) const\n{\n    return token == QLatin1String(\"$ipxact_port_value\") ||\n        token == QLatin1String(\"$ipxact_field_value\") || \n        token == QLatin1String(\"$ipxact_mode_condition\") ||\n        IPXactSystemVerilogParser::isUnaryOperator(token);\n}\n\n//-----------------------------------------------------------------------------\n// Function: SystemVerilogExpressionParser::solveUnary()\n//-----------------------------------------------------------------------------\nQString ModeConditionParser::solveUnary(QStringView operation, QString const& term) const\n{\n    if (operation.compare(QLatin1String(\"$ipxact_port_value\")) == 0)\n    {\n        return solveCondition(term, portSlices_);\n    }\n    else if (operation.compare(QLatin1String(\"$ipxact_field_value\")) == 0)\n    {\n        return solveCondition(term, fieldSlices_);\n    }\n    else if (operation.compare(QLatin1String(\"$ipxact_mode_condition\")) == 0)\n    {\n        return solveCondition(term, modes_);\n    }\n\n    return SystemVerilogExpressionParser::solveUnary(operation, term);\n}\n\n//-----------------------------------------------------------------------------\n// Function: ModeConditionParser::isModeReference()\n//-----------------------------------------------------------------------------\nbool ModeConditionParser::isModeReference(QStringView expression) const\n{\n    return Search::findByName(expression, *portSlices_) != nullptr ||\n        Search::findByName(expression, *fieldSlices_) != nullptr ||\n        Search::findByName(expression, *modes_) != nullptr;\n}\n"
  },
  {
    "path": "KactusAPI/expressions/ModeConditionParserInterface.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: ModeConditionParserInterface.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Anton Hagqvist\n// Date: 27.09.2024\n//\n// Description:\n// Interface for creating and handling expression parsers for mode conditions. The base interface is independent of \n// KactusAPI and should be used in IPXACTmodels validators.\n//-----------------------------------------------------------------------------\n\n#include \"ModeConditionParserInterface.h\"\n\n#include <KactusAPI/include/ModeConditionParser.h>\n\n//-----------------------------------------------------------------------------\n// Function: ModeConditionParserInterface::ModeConditionParserInterface()\n//-----------------------------------------------------------------------------\nModeConditionParserInterface::ModeConditionParserInterface(QSharedPointer<ParameterFinder> parameterFinder):\n    parameterFinder_(parameterFinder)\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: ModeConditionParserInterface::createParser()\n//-----------------------------------------------------------------------------\nQSharedPointer<ExpressionParser> ModeConditionParserInterface::createParser()\n{\n    return QSharedPointer<ModeConditionParser>(new ModeConditionParser(parameterFinder_, nullptr, nullptr, nullptr));\n}\n\n//-----------------------------------------------------------------------------\n// Function: ModeConditionParserInterface::setFieldSlices()\n//-----------------------------------------------------------------------------\nvoid ModeConditionParserInterface::setFieldSlices(QSharedPointer<ExpressionParser> expressionParser, FieldSlice::List fieldSlices)\n{\n    expressionParser.staticCast<ModeConditionParser>()->setFieldSlices(fieldSlices);\n}\n\n//-----------------------------------------------------------------------------\n// Function: ModeConditionParserInterface::setPortSlices()\n//-----------------------------------------------------------------------------\nvoid ModeConditionParserInterface::setPortSlices(QSharedPointer<ExpressionParser> expressionParser, PortSlice::List portSlices)\n{\n    expressionParser.staticCast<ModeConditionParser>()->setPortSlices(portSlices);\n}\n\n//-----------------------------------------------------------------------------\n// Function: ModeConditionParserInterface::setModes()\n//-----------------------------------------------------------------------------\nvoid ModeConditionParserInterface::setModes(QSharedPointer<ExpressionParser> expressionParser, Mode::List modes)\n{\n    expressionParser.staticCast<ModeConditionParser>()->setModes(modes);\n}\n"
  },
  {
    "path": "KactusAPI/expressions/MultipleParameterFinder.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: MultipleParameterFinder.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Mikko Teuho\r\n// Date: 29.01.2015\r\n//\r\n// Description:\r\n// Finds parameters from multiple components.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"MultipleParameterFinder.h\"\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MultipleParameterFinder::MultipleParameterFinder()\r\n//-----------------------------------------------------------------------------\r\nMultipleParameterFinder::MultipleParameterFinder()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MultipleParameterFinder::addFinder()\r\n//-----------------------------------------------------------------------------\r\nvoid MultipleParameterFinder::addFinder(QSharedPointer<ParameterFinder> finder)\r\n{\r\n    if (!finders_.contains(finder))\r\n    {\r\n        finders_.append(finder);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MultipleParameterFinder::removeFinder()\r\n//-----------------------------------------------------------------------------\r\nvoid MultipleParameterFinder::removeFinder(QSharedPointer<ParameterFinder> finder)\r\n{\r\n    finders_.removeAll(finder);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MultipleParameterFinder::removeAllFinders()\r\n//-----------------------------------------------------------------------------\r\nvoid MultipleParameterFinder::removeAllFinders()\r\n{\r\n    finders_.clear();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MultipleParameterFinder::getParameterWithID()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<Parameter> MultipleParameterFinder::getParameterWithID(QStringView parameterId) const\r\n{\r\n    for (QSharedPointer<ParameterFinder> finder : finders_)\r\n    {\r\n        if (finder->hasId(parameterId))\r\n        {\r\n            return finder->getParameterWithID(parameterId);\r\n        }\r\n    }\r\n\r\n    return QSharedPointer<Parameter>(new Parameter);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MultipleParameterFinder::hasId()\r\n//-----------------------------------------------------------------------------\r\nbool MultipleParameterFinder::hasId(QStringView id) const\r\n{\r\n    return std::any_of(finders_.cbegin(), finders_.cend(), [id](const auto& finder) { return finder->hasId(id); });\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MultipleParameterFinder::nameForId()\r\n//-----------------------------------------------------------------------------\r\nQString MultipleParameterFinder::nameForId(QStringView id) const\r\n{\r\n    return getParameterWithID(id)->name();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MultipleParameterFinder::valueForId()\r\n//-----------------------------------------------------------------------------\r\nQString MultipleParameterFinder::valueForId(QStringView id) const\r\n{\r\n    for (QSharedPointer<ParameterFinder> finder : finders_)\r\n    {\r\n        if (finder->hasId(id))\r\n        {\r\n            return finder->valueForId(id);\r\n        }\r\n    }\r\n\r\n    return QString();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MultipleParameterFinder::getAllParameterIds()\r\n//-----------------------------------------------------------------------------\r\nQStringList MultipleParameterFinder::getAllParameterIds() const\r\n{\r\n    QStringList allParameterIds;\r\n\r\n    for (QSharedPointer<ParameterFinder> finder : finders_)\r\n    {\r\n        QStringList finderParameters = finder->getAllParameterIds();\r\n        allParameterIds.append(finderParameters);\r\n    }\r\n    \r\n    return allParameterIds;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MultipleParameterFinder::getNumberOfParameters()\r\n//-----------------------------------------------------------------------------\r\nint MultipleParameterFinder::getNumberOfParameters() const noexcept\r\n{\r\n    return getAllParameterIds().size();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MultipleParameterFinder::registerParameterModel()\r\n//-----------------------------------------------------------------------------\r\nvoid MultipleParameterFinder::registerParameterModel(QAbstractItemModel const* /*model*/)\r\n{\r\n    // Nothing to do.\r\n}\r\n"
  },
  {
    "path": "KactusAPI/expressions/NullParser.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: NullParser.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Esko Pekkarinen\r\n// Date: 02.02.2015\r\n//\r\n// Description:\r\n// Expression parser implementation that does nothing.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"NullParser.h\"\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: NullParser::()\r\n//-----------------------------------------------------------------------------\r\nNullParser::NullParser() : ExpressionParser()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: NullParser::parseExpression()\r\n//-----------------------------------------------------------------------------\r\nQString NullParser::parseExpression(QStringView expression, bool* /*isValidExpression*/) const\r\n{\r\n    return expression.toString();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: NullParser::isPlainValue()\r\n//-----------------------------------------------------------------------------\r\nbool NullParser::isPlainValue(QStringView /*expression*/) const\r\n{\r\n    return true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: NullParser::baseForExpression()\r\n//-----------------------------------------------------------------------------\r\nint NullParser::baseForExpression(QStringView /*expression*/) const\r\n{\r\n    return 0;\r\n}"
  },
  {
    "path": "KactusAPI/expressions/ParameterCache.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ParameterCache.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Esko Pekkarinen\r\n// Date: 06.09.2016\r\n//\r\n// Description:\r\n// The cached implementation for finding parameters with the correct ID.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"ParameterCache.h\"\r\n\r\n#include <IPXACTmodels/common/Parameter.h>\r\n\r\n#include <QAbstractItemModel>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ParameterCache::ParameterCache()\r\n//-----------------------------------------------------------------------------\r\nParameterCache::ParameterCache(QSharedPointer<const Component> component) : QObject(nullptr),\r\nComponentParameterFinder(component)\r\n{\r\n    resetCache();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ParameterCache::hasId()\r\n//-----------------------------------------------------------------------------\r\nbool ParameterCache::hasId(QStringView id) const\r\n{\r\n    return availableParameters_.contains(id.toString());\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ParameterCache::getAllParameterIds()\r\n//-----------------------------------------------------------------------------\r\nQStringList ParameterCache::getAllParameterIds() const\r\n{\r\n    return availableParameters_.keys();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ParameterCache::getParameterWithID()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<Parameter> ParameterCache::getParameterWithID(QStringView parameterId) const\r\n{\r\n\treturn availableParameters_.value(parameterId.toString());\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ParameterCache::getNumberOfParameters()\r\n//-----------------------------------------------------------------------------\r\nint ParameterCache::getNumberOfParameters() const\r\n{\r\n\treturn availableParameters_.count();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ParameterCache::setComponent()\r\n//-----------------------------------------------------------------------------\r\nvoid ParameterCache::setComponent(QSharedPointer<Component const> component)\r\n{\r\n\tComponentParameterFinder::setComponent(component);\r\n\t\r\n    resetCache();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ParameterCache::registerParameterModel()\r\n//-----------------------------------------------------------------------------\r\nvoid ParameterCache::registerParameterModel(QAbstractItemModel const* model)\r\n{\r\n    ComponentParameterFinder::registerParameterModel(model);\r\n\r\n    connect(model, SIGNAL(modelReset()), this, SLOT(resetCache()), Qt::UniqueConnection);\r\n    connect(model, SIGNAL(rowsRemoved(QModelIndex const&, int, int)), this, SLOT(resetCache()), Qt::UniqueConnection);\r\n    connect(model, SIGNAL(rowsInserted(QModelIndex const&, int, int)), this, SLOT(resetCache()), Qt::UniqueConnection);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ParameterCache::resetCache()\r\n//-----------------------------------------------------------------------------\r\nvoid ParameterCache::resetCache()\r\n{\r\n    availableParameters_.clear();\r\n    for(QString const& id : ComponentParameterFinder::getAllParameterIds())\r\n    {\r\n        availableParameters_.insert(id, ComponentParameterFinder::getParameterWithID(id));\r\n    }\r\n}\r\n"
  },
  {
    "path": "KactusAPI/expressions/ParameterConfigurableElementFinder.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: ParameterConfigurableElementFinder.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 18.02.2026\n//\n// Description:\n// The implementation for finding configurable elements from a list with the correct ID.\n//-----------------------------------------------------------------------------\n\n#include \"ParameterConfigurableElementFinder.h\"\n\n#include <IPXACTmodels/common/Parameter.h>\n#include <IPXACTmodels/common/ConfigurableElementValue.h>\n\n//-----------------------------------------------------------------------------\n// Function: ParameterConfigurableElementFinder::ParameterConfigurableElementFinder()\n//-----------------------------------------------------------------------------\nParameterConfigurableElementFinder::ParameterConfigurableElementFinder():\nListParameterFinder()\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: ParameterConfigurableElementFinder::setCEVList()\n//-----------------------------------------------------------------------------\nvoid ParameterConfigurableElementFinder::setCEVList(QSharedPointer<QList<QSharedPointer<ConfigurableElementValue> > > elementList) noexcept\n{\n    cevList_ = elementList;\n}\n\n//-----------------------------------------------------------------------------\n// Function: ParameterConfigurableElementFinder::valueForId()\n//-----------------------------------------------------------------------------\nQString ParameterConfigurableElementFinder::valueForId(QStringView id) const\n{\n    if (cevList_ != nullptr)\n    {\n\t\tfor (auto element : *cevList_)\n\t\t{\n\t\t\tif (element->getReferenceId() == id)\n\t\t\t{\n\t\t\t\treturn element->getConfigurableValue();\n\t\t\t}\n\t\t}\n    }\n\n    return ListParameterFinder::valueForId(id);\n}\n"
  },
  {
    "path": "KactusAPI/expressions/RegisterExpressionsGatherer.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: RegisterExpressionGatherer.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Mikko Teuho\r\n// Date: 29.04.2015\r\n//\r\n// Description:\r\n// Gathers expressions from a register and its fields.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"RegisterExpressionsGatherer.h\"\r\n#include \"FieldExpressionsGatherer.h\"\r\n\r\n#include <IPXACTmodels/Component/Register.h>\r\n#include <IPXACTmodels/Component/Field.h>\r\n#include <IPXACTmodels/Component/MemoryArray.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: RegisterExpressionsGatherer::RegisterExpressionsGatherer()\r\n//-----------------------------------------------------------------------------\r\nRegisterExpressionsGatherer::RegisterExpressionsGatherer()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: RegisterExpressionsGatherer::~RegisterExpressionsGatherer()\r\n//-----------------------------------------------------------------------------\r\nRegisterExpressionsGatherer::~RegisterExpressionsGatherer()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: RegisterExpressionsGatherer::getExpressions()\r\n//-----------------------------------------------------------------------------\r\nQStringList RegisterExpressionsGatherer::getExpressions(QSharedPointer<Register> currentRegister) const\r\n{\r\n    QStringList expressionList;\r\n\r\n    expressionList.append(currentRegister->getAddressOffset());\r\n    expressionList.append(currentRegister->getSize());\r\n\r\n    if (auto memArray = currentRegister->getMemoryArray())\r\n    {\r\n        for (auto const& dim : *memArray->getDimensions())\r\n        {\r\n            expressionList.append(dim->value_);\r\n        }\r\n    }\r\n\r\n    expressionList.append(currentRegister->getIsPresent());\r\n\r\n    FieldExpressionsGatherer fieldGatherer;\r\n\r\n    foreach (QSharedPointer<Field> field, *currentRegister->getFields())\r\n    {\r\n        expressionList.append(fieldGatherer.getExpressions(field));\r\n    }\r\n\r\n    return expressionList;\r\n}\r\n"
  },
  {
    "path": "KactusAPI/expressions/RegisterFileExpressionsGatherer.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: RegisterExpressionGatherer.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Dan Chianucci\n// Date: 11.06.2018\n//\n// Description:\n// Gathers expressions from a register file and its registers.\n//-----------------------------------------------------------------------------\n\n#include \"RegisterFileExpressionsGatherer.h\"\n#include \"RegisterExpressionsGatherer.h\"\n\n#include <IPXACTmodels/Component/RegisterFile.h>\n#include <IPXACTmodels/Component/Register.h>\n#include <IPXACTmodels/Component/MemoryArray.h>\n\n//-----------------------------------------------------------------------------\n// Function: RegisterFileExpressionsGatherer::RegisterFileExpressionsGatherer()\n//-----------------------------------------------------------------------------\nRegisterFileExpressionsGatherer::RegisterFileExpressionsGatherer()\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: RegisterFileExpressionsGatherer::getExpressions()\n//-----------------------------------------------------------------------------\nQStringList RegisterFileExpressionsGatherer::getExpressions(QSharedPointer<RegisterFile> currentRegisterFile) const\n{\n    QStringList expressionList;\n\n    expressionList.append(currentRegisterFile->getAddressOffset());\n    expressionList.append(currentRegisterFile->getRange());\n    \n    if (auto memArray = currentRegisterFile->getMemoryArray())\n    {\n        for (auto const& dim : *memArray->getDimensions())\n        {\n            expressionList.append(dim->value_);\n        }\n    }\n\n    expressionList.append(currentRegisterFile->getIsPresent());\n\n    RegisterExpressionsGatherer regGatherer;\n\n    foreach (QSharedPointer<RegisterBase> regBase, *currentRegisterFile->getRegisterData())\n    {\n        QSharedPointer<Register> regItem = regBase.dynamicCast<Register>();\n        QSharedPointer<RegisterFile> regFileItem = regBase.dynamicCast<RegisterFile >();\n\n        if(regItem)\n        {\n            expressionList.append(regGatherer.getExpressions(regItem));\n        }\n        else if(regFileItem)\n        {\n            expressionList.append(getExpressions(regFileItem));\n        }\n    }\n\n    return expressionList;\n}\n"
  },
  {
    "path": "KactusAPI/expressions/SystemVerilogExpressionParser.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: SystemVerilogExpressionParser.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Esko Pekkarinen\r\n// Date: 25.11.2014\r\n//\r\n// Description:\r\n// Parser for SystemVerilog expressions.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"SystemVerilogExpressionParser.h\"\r\n#include \"SystemVerilogSyntax.h\"\r\n\r\n#include <QRegularExpression>\r\n#include <QMap>\r\n#include <QStringBuilder>\r\n#include <QStringList>\r\n#include <QVector>\r\n\r\n#include <qmath.h>\r\n\r\n#include <algorithm>\r\n\r\nnamespace\r\n{\r\n    const QRegularExpression PRIMARY_LITERAL(SystemVerilogSyntax::REAL_NUMBER % QStringLiteral(\"|\") %\r\n        SystemVerilogSyntax::INTEGRAL_NUMBER % QStringLiteral(\"|\") %\r\n        SystemVerilogSyntax::BOOLEAN_VALUE % QStringLiteral(\"|\") %\r\n        SystemVerilogSyntax::STRING_LITERAL);\r\n\r\n    const QRegularExpression BINARY_OPERATOR(QStringLiteral(\"[/%^+-]|<<|>>|<=?|>=?|!==?|===?|[&|*]{1,2}|[$]pow\"));\r\n\r\n    const QRegularExpression UNARY_OPERATOR(QStringLiteral(\r\n        \"[$]clog2|[$]exp|[$]sqrt|[$]ipxact_mode_condition|[$]ipxact_port_value|[$]ipxact_field_value|~|`\"));\r\n\r\n    const QRegularExpression TERNARY_OPERATOR(QStringLiteral(\"[?:]\"));\r\n\r\n    const QLatin1Char OPEN_PARENTHESIS('(');\r\n    const QLatin1Char CLOSE_PARENTHESIS(')');\r\n    const QLatin1Char OPEN_ARRAY('{');\r\n    const QLatin1Char CLOSE_ARRAY('}');\r\n\r\n    const QString OPEN_PARENTHESIS_STRING(QStringLiteral(\"(\"));\r\n    const QString OPEN_ARRAY_STRING(QStringLiteral(\"{\"));\r\n    const QString CLOSE_ARRAY_STRING(QStringLiteral(\"}\"));\r\n\r\n    const QString TERNARY_QUESTION_STRING(QStringLiteral(\"?\"));\r\n    const QString TERNARY_COLON_STRING(QStringLiteral(\":\"));\r\n\r\n    const QRegularExpression ANY_OPERATOR(\r\n        BINARY_OPERATOR.pattern() % QStringLiteral(\"|\") %\r\n        UNARY_OPERATOR.pattern() % QStringLiteral(\"|\") %\r\n        TERNARY_OPERATOR.pattern());\r\n\r\n    const QRegularExpression LITERAL_EXPRESSION(QStringLiteral(\"^\\\\s*(\") % SystemVerilogSyntax::INTEGRAL_NUMBER%\r\n        QStringLiteral(\"|\") % SystemVerilogSyntax::REAL_NUMBER% QStringLiteral(\")\\\\s*$\"));\r\n\r\n    const QRegularExpression BASE_FORMAT(QStringLiteral(\"'[sS]?([dDbBoOhH]?)\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SystemVerilogExpressionParser::parseExpression()\r\n//-----------------------------------------------------------------------------\r\nQString SystemVerilogExpressionParser::parseExpression(QStringView expression, bool* validExpression) const\r\n{\r\n\t// Copy of expression needs to be created for replacing unary minuses with special character.\r\n\tQString expressionCopy = expression.toString();\r\n\treturn solveRPN(convertToRPN(expressionCopy), validExpression);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SystemVerilogExpressionParser::isArrayExpression()\r\n//-----------------------------------------------------------------------------\r\nbool SystemVerilogExpressionParser::isArrayExpression(QStringView expression) const noexcept\r\n{\r\n    return expression.contains(OPEN_ARRAY) && expression.contains(CLOSE_ARRAY);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SystemVerilogExpressionParser::isPlainValue()\r\n//-----------------------------------------------------------------------------\r\nbool SystemVerilogExpressionParser::isPlainValue(QStringView expression) const\r\n{\r\n    return expression.isEmpty() || isLiteral(expression) || isStringLiteral(expression);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SystemVerilogExpressionParser::baseForExpression()\r\n//-----------------------------------------------------------------------------\r\nint SystemVerilogExpressionParser::baseForExpression(QStringView expression) const\r\n{\r\n    int greatestBase = 0;\r\n    QString asStr = expression.toString();\r\n    for (auto const& token : convertToRPN(asStr))\r\n    {\r\n        if (isLiteral(token))\r\n        {\r\n            greatestBase = qMax(greatestBase, baseOf(token));\r\n        }\r\n        else if (isSymbol(token))\r\n        {\r\n            greatestBase = qMax(greatestBase, getBaseForSymbol(token));\r\n        }\r\n    }\r\n\r\n    return greatestBase;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SystemVerilogExpressionParser::convertToRPN()\r\n//-----------------------------------------------------------------------------\r\nQVector<QStringView> SystemVerilogExpressionParser::convertToRPN(QString& expression)\r\n{\r\n    // Convert expression to Reverse Polish Notation (RPN) using the Shunting Yard algorithm.\r\n    QVector<QStringView> output;\r\n    QVector<QStringView> stack;\r\n\r\n    int openParenthesis = 0;\r\n    bool nextMayBeLiteral = true;\r\n\r\n    qsizetype previousIndex = -1;\r\n    const auto SIZE = expression.size();\r\n\r\n    // Convert unary minuses to backticks. Needs to be done before main loop, otherwise string views will be invalidated.\r\n    // SolveRPN knows to treat backticks as unary minus.\r\n    for (qsizetype index = 0; index < SIZE; ++index)\r\n    {\r\n        const QChar current = expression.at(index);\r\n        if (current.isSpace())\r\n        {\r\n            continue;\r\n        }\r\n\r\n        // Minus == unary minus if preceded by opening parenthesis or if first token\r\n        if (current == QLatin1Char('-') && (previousIndex == -1 || expression.at(previousIndex) == OPEN_PARENTHESIS_STRING))\r\n        {\r\n            expression[index] = QLatin1Char('`');\r\n        }\r\n\r\n        previousIndex = index;\r\n    }\r\n\r\n    for (qsizetype index = 0; index < SIZE; /*index incremented inside loop*/)\r\n    {\r\n        const QChar current = expression.at(index);\r\n        if (current.isSpace())\r\n        {\r\n            ++index;\r\n            continue;\r\n        }\r\n\r\n        if (QRegularExpressionMatch literalMatch = PRIMARY_LITERAL.match(expression, index,\r\n            QRegularExpression::NormalMatch, QRegularExpression::AnchorAtOffsetMatchOption);\r\n            nextMayBeLiteral && literalMatch.hasMatch())\r\n        {\r\n            output.append(literalMatch.capturedView());\r\n\r\n            index += literalMatch.capturedLength();\r\n            nextMayBeLiteral = false;\r\n        }\r\n        else if (QRegularExpressionMatch operatorMatch = ANY_OPERATOR.match(expression, index,\r\n                 QRegularExpression::NormalMatch, QRegularExpression::AnchorAtOffsetMatchOption); \r\n            operatorMatch.hasMatch())\r\n        {\r\n            const auto operation = operatorMatch.capturedView();\r\n            while (stack.isEmpty() == false &&\r\n                stack.last() != OPEN_PARENTHESIS_STRING &&\r\n                stack.last() != TERNARY_QUESTION_STRING &&\r\n                operatorPrecedence(stack.last()) >= operatorPrecedence(operation))\r\n            {\r\n                output.append(stack.takeLast());\r\n            }\r\n\r\n            stack.append(operation);\r\n\r\n            index += operation.length();\r\n            nextMayBeLiteral = true;\r\n        }\r\n        else if (current == OPEN_PARENTHESIS)\r\n        {\r\n            stack.append(OPEN_PARENTHESIS_STRING);\r\n            ++index;\r\n            ++openParenthesis;\r\n            nextMayBeLiteral = true;\r\n        }\r\n        else if (current == CLOSE_PARENTHESIS)\r\n        {\r\n            while (stack.isEmpty() == false && (stack.last() != OPEN_PARENTHESIS_STRING))\r\n            {\r\n                output.append(stack.takeLast());\r\n            }\r\n\r\n            if (stack.isEmpty() == false)\r\n            {\r\n                stack.removeLast(); //!< Remove open parenthesis.\r\n            }\r\n\r\n            ++index;\r\n            --openParenthesis;\r\n            nextMayBeLiteral = false;\r\n        }\r\n        else if (current == OPEN_ARRAY)\r\n        {\r\n            output.append(OPEN_ARRAY_STRING);\r\n            ++index;\r\n            ++openParenthesis;\r\n            nextMayBeLiteral = true;\r\n        }\r\n        else if (current == CLOSE_ARRAY)\r\n        {\r\n            while (stack.isEmpty() == false && stack.last() != OPEN_ARRAY_STRING)\r\n            {\r\n                output.append(stack.takeLast());\r\n            }\r\n\r\n            if (stack.isEmpty() == false)\r\n            {\r\n                output.append(stack.takeLast()); //!< Add open array.\r\n            }\r\n            stack.append(CLOSE_ARRAY_STRING); //!< Add close array.\r\n\r\n            ++index;\r\n            --openParenthesis;\r\n            nextMayBeLiteral = false;\r\n        }\r\n        else if (current == QLatin1Char(','))\r\n        {\r\n            while (stack.isEmpty() == false &&\r\n                (stack.last() != OPEN_ARRAY_STRING && stack.last() != OPEN_PARENTHESIS_STRING))\r\n            {\r\n                output.append(stack.takeLast());\r\n            }\r\n\r\n            ++index;\r\n            nextMayBeLiteral = true;\r\n        }\r\n        else\r\n        {\r\n            static const QRegularExpression separator(ANY_OPERATOR.pattern() % QStringLiteral(\"|[(){},]\"));\r\n            auto unknown = QStringView(expression);\r\n            unknown = unknown.mid(index, separator.match(expression, index).capturedStart() - index);\r\n\r\n            output.append(unknown.trimmed());\r\n\r\n            index += unknown.length();\r\n            nextMayBeLiteral = false;\r\n        }\r\n    }\r\n\r\n    if (openParenthesis != 0)\r\n    {\r\n        output.clear();\r\n        output.append(QStringLiteral(\"x\"));\r\n    }\r\n\r\n    while (stack.isEmpty() == false)\r\n    {\r\n        output.append(stack.takeLast());\r\n    }\r\n\r\n    return output;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SystemVerilogExpressionParser::solveRPN()\r\n//-----------------------------------------------------------------------------\r\nQString SystemVerilogExpressionParser::solveRPN(QVector<QStringView> rpn, bool* validExpression) const\r\n{\r\n    QStringList result;\r\n    bool isWellFormed = true;\r\n    int ternaryCount = 0;\r\n\r\n    for (auto const& token : rpn)\r\n    {\r\n        if (isUnaryOperator(token))\r\n        {\r\n            if (result.isEmpty())\r\n            {\r\n                isWellFormed = false;\r\n            }\r\n            else\r\n            {\r\n                result.append(solveUnary(token, result.takeLast()));\r\n            }\r\n        }\r\n        else if (isBinaryOperator(token))\r\n        {\r\n            if (result.size() < 2)\r\n            {\r\n                isWellFormed = false;\r\n            }\r\n            else\r\n            {\r\n                result.append(solveBinary(token, result.takeLast(), result.takeLast()));\r\n            }\r\n        }\r\n        else if (isTernaryOperator(token))\r\n        {\r\n            if (token.compare(TERNARY_COLON_STRING) == 0)\r\n            {\r\n                ++ternaryCount;\r\n\r\n                if (result.size() < 3)\r\n                {\r\n                    isWellFormed = false;\r\n                }\r\n                else\r\n                {\r\n                    result.append(solveTernary(result.takeLast(), result.takeLast(), result.takeLast()));\r\n                }\r\n            }\r\n            else\r\n            {\r\n                --ternaryCount;\r\n            }\r\n        }\r\n        else if (token.compare(OPEN_ARRAY_STRING) == 0)\r\n        {\r\n            result.append(token.toString());\r\n        }\r\n        else if (token.compare(CLOSE_ARRAY_STRING) == 0)\r\n        {\r\n            QStringList items;\r\n            while (result.isEmpty() == false && result.last().compare(OPEN_ARRAY_STRING) != 0)\r\n            {\r\n                items.prepend(result.takeLast());\r\n            }\r\n\r\n            if (result.isEmpty())\r\n            {\r\n                isWellFormed = false;\r\n            }\r\n            else\r\n            {\r\n                QString arrayItem(result.takeLast() % items.join(QLatin1Char(',')) % token);\r\n                result.append(arrayItem);\r\n            }\r\n        }\r\n        else if (token.compare(QLatin1String(\"true\"), Qt::CaseInsensitive) == 0)\r\n        {\r\n            result.append(QStringLiteral(\"1\"));\r\n        }\r\n        else if (token.compare(QLatin1String(\"false\"), Qt::CaseInsensitive) == 0)\r\n        {\r\n            result.append(QStringLiteral(\"0\"));\r\n        }\r\n        else if (isStringLiteral(token))\r\n        {\r\n            result.append(token.toString());\r\n        }\r\n        else if (isSymbol(token))\r\n        {\r\n            result.append(findSymbolValue(token));\r\n        }\r\n        else\r\n        {\r\n            const auto constant = parseConstant(token);\r\n\r\n            if (constant == QLatin1String(\"x\"))\r\n            {\r\n                isWellFormed = false;\r\n            }\r\n\r\n            result.append(constant);\r\n        }\r\n\r\n        if (isWellFormed == false)\r\n        {\r\n            break;\r\n        }\r\n    }\r\n\r\n    if (validExpression != nullptr)\r\n    {\r\n        *validExpression = (isWellFormed && result.contains(QLatin1String(\"x\")) == false && ternaryCount == 0);\r\n    }\r\n\r\n    return result.join(QString());\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SystemVerilogExpressionParser::isStringLiteral()\r\n//-----------------------------------------------------------------------------\r\nbool SystemVerilogExpressionParser::isStringLiteral(QStringView expression) const noexcept\r\n{\r\n    return expression.startsWith(QLatin1Char('\"')) && expression.endsWith(QLatin1Char('\"'));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SystemVerilogExpressionParser::isLiteral()\r\n//-----------------------------------------------------------------------------\r\nbool SystemVerilogExpressionParser::isLiteral(QStringView expression) const\r\n{\r\n    return LITERAL_EXPRESSION.match(expression).hasMatch();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SystemVerilogExpressionParser::isUnaryOperator()\r\n//-----------------------------------------------------------------------------\r\nbool SystemVerilogExpressionParser::isUnaryOperator(QStringView token) const\r\n{\r\n    return UNARY_OPERATOR.match(token).hasMatch();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SystemVerilogExpressionParser::isBinaryOperator()\r\n//-----------------------------------------------------------------------------\r\nbool SystemVerilogExpressionParser::isBinaryOperator(QStringView token) const\r\n{\r\n    //! Check for operator length so e.g. negative numbers are not interpret as operators.\r\n    auto match = BINARY_OPERATOR.match(token);\r\n    return match.hasMatch() && match.capturedLength() == token.length();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SystemVerilogExpressionParser::isTernaryOperator()\r\n//-----------------------------------------------------------------------------\r\nbool SystemVerilogExpressionParser::isTernaryOperator(QStringView token) const\r\n{\r\n    return TERNARY_OPERATOR.match(token).hasMatch();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SystemVerilogExpressionParser::solveTernary()\r\n//-----------------------------------------------------------------------------\r\nQString SystemVerilogExpressionParser::solveTernary(QStringView condition,\r\n    QString const& trueCase, QString const& falseCase) const\r\n{\r\n    if (condition.toDouble() != 0)\r\n    {\r\n        return trueCase;\r\n    }\r\n    else\r\n    {\r\n        return falseCase;\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SystemVerilogExpressionParser::solveBinary()\r\n//-----------------------------------------------------------------------------\r\nQString SystemVerilogExpressionParser::solveBinary(QStringView operation, QString const& leftTerm,\r\n    QString const& rightTerm) const\r\n{\r\n    if (isLiteral(leftTerm))\r\n    {\r\n        const auto leftOperand = leftTerm.toDouble();\r\n        const auto rightOperand = rightTerm.toDouble();\r\n\r\n        qreal result = 0;\r\n\r\n        if (operation.compare(QLatin1String(\"**\")) == 0 || operation.compare(QLatin1String(\"$pow\")) == 0)\r\n        {\r\n            if (leftOperand == 0 && rightOperand < 0)\r\n            {\r\n                return QStringLiteral(\"x\");\r\n            }\r\n\r\n            result = qPow(leftOperand, rightOperand);\r\n        }\r\n\r\n        else if (operation.compare(QLatin1String(\"*\")) == 0)\r\n        {\r\n            result = leftOperand * rightOperand;\r\n        }\r\n\r\n        else if (operation.compare(QLatin1String(\"/\")) == 0)\r\n        {\r\n            if (rightOperand == 0)\r\n            {\r\n                return QStringLiteral(\"x\");\r\n            }\r\n\r\n            result = leftOperand / rightOperand;\r\n        }\r\n\r\n        else if (operation.compare(QLatin1String(\"%\")) == 0)\r\n        {\r\n            if (rightOperand == 0 || leftTerm.contains(QLatin1Char('.')) || rightTerm.contains(QLatin1Char('.')))\r\n            {\r\n                return QStringLiteral(\"x\");\r\n            }\r\n\r\n            result = leftTerm.toLongLong() % rightTerm.toLongLong();\r\n        }\r\n\r\n        else if (operation.compare(QLatin1String(\"+\")) == 0)\r\n        {\r\n            result = leftOperand + rightOperand;\r\n        }\r\n\r\n        else if (operation.compare(QLatin1String(\"-\")) == 0)\r\n        {\r\n            result = leftOperand - rightOperand;\r\n        }\r\n\r\n        else if (operation.compare(QLatin1String(\"<<\")) == 0)\r\n        {\r\n            if (leftTerm.contains(QLatin1Char('.')) || rightTerm.contains(QLatin1Char('.')))\r\n            {\r\n                return QStringLiteral(\"x\");\r\n            }\r\n\r\n            result = leftTerm.toLongLong() << rightTerm.toLongLong();\r\n        }\r\n\r\n        else if (operation.compare(QLatin1String(\">>\")) == 0)\r\n        {\r\n            if (leftTerm.contains(QLatin1Char('.')) || rightTerm.contains(QLatin1Char('.')))\r\n            {\r\n                return QStringLiteral(\"x\");\r\n            }\r\n\r\n            result = leftTerm.toLongLong() >> rightTerm.toLongLong();\r\n        }\r\n\r\n        else if ((operation.compare(QLatin1String(\">\")) == 0 && leftOperand > rightOperand) ||\r\n            (operation.compare(QLatin1String(\"<\")) == 0 && leftOperand < rightOperand) ||\r\n            (operation.compare(QLatin1String(\"==\")) == 0 && leftOperand == rightOperand) ||\r\n            (operation.compare(QLatin1String(\">=\")) == 0 && leftOperand >= rightOperand) ||\r\n            (operation.compare(QLatin1String(\"<=\")) == 0 && leftOperand <= rightOperand) ||\r\n            (operation.compare(QLatin1String(\"!=\")) == 0 && leftOperand != rightOperand))\r\n        {\r\n            return QStringLiteral(\"1\");\r\n        }\r\n\r\n        else if (operation.compare(QLatin1String(\"||\")) == 0)\r\n        {\r\n            result = leftTerm.toLongLong() || rightTerm.toLongLong();\r\n        }\r\n\r\n        else if (operation.compare(QLatin1String(\"&&\")) == 0)\r\n        {\r\n            result = leftTerm.toLongLong() && rightTerm.toLongLong();\r\n        }\r\n\r\n        else if (operation.compare(QLatin1String(\"|\")) == 0)\r\n        {\r\n            if (leftTerm.contains(QLatin1Char('.')) || rightTerm.contains(QLatin1Char('.')))\r\n            {\r\n                return QStringLiteral(\"x\");\r\n            }\r\n\r\n            result = leftTerm.toLongLong() | rightTerm.toLongLong();\r\n        }\r\n\r\n        else if (operation.compare(QLatin1String(\"^\")) == 0)\r\n        {\r\n            if (leftTerm.contains(QLatin1Char('.')) || rightTerm.contains(QLatin1Char('.')))\r\n            {\r\n                return QStringLiteral(\"x\");\r\n            }\r\n\r\n            result = leftTerm.toLongLong() ^ rightTerm.toLongLong();\r\n        }\r\n\r\n        else if (operation.compare(QLatin1String(\"&\")) == 0)\r\n        {\r\n            if (leftTerm.contains(QLatin1Char('.')) || rightTerm.contains(QLatin1Char('.')))\r\n            {\r\n                return QStringLiteral(\"x\");\r\n            }\r\n\r\n            result = leftTerm.toLongLong() & rightTerm.toLongLong();\r\n        }\r\n\r\n        if (!leftTerm.contains(QLatin1Char('.')) && (operation.compare(QLatin1String(\"/\")) == 0 ||\r\n            (operation.compare(QLatin1String(\"**\")) == 0 && rightOperand < 0)))\r\n        {\r\n            return QString::number(static_cast<int>(result));\r\n        }\r\n        else\r\n        {\r\n            return QString::number(result, 'f', qMax(precisionOf(leftTerm), precisionOf(rightTerm)));\r\n        }\r\n    }\r\n\r\n    else if (isStringLiteral(leftTerm) && isStringLiteral(rightTerm))\r\n    {\r\n        if ((operation.compare(QLatin1String(\"==\")) == 0 && leftTerm.compare(rightTerm) == 0) ||\r\n            (operation.compare(QLatin1String(\"!=\")) == 0 && leftTerm.compare(rightTerm) != 0))\r\n        {\r\n            return QStringLiteral(\"1\");\r\n        }\r\n        else\r\n        {\r\n            return QStringLiteral(\"0\");\r\n        }\r\n    }\r\n\r\n    return QStringLiteral(\"x\");\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SystemVerilogExpressionParser::solveUnary()\r\n//-----------------------------------------------------------------------------\r\nQString SystemVerilogExpressionParser::solveUnary(QStringView operation, QString const& term) const\r\n{\r\n    if (operation.compare(QLatin1String(\"$clog2\")) == 0)\r\n    {\r\n        return solveClog2(term);\r\n    }\r\n    else if (operation.compare(QLatin1String(\"$exp\")) == 0)\r\n    {\r\n        return QString::number(qExp(term.toLongLong()));\r\n    }\r\n    else if (operation.compare(QLatin1String(\"$sqrt\")) == 0)\r\n    {\r\n        return solveSqrt(term);\r\n    }\r\n    else if (operation.compare(QLatin1String(\"~\")) == 0)\r\n    {\r\n        return QString::number(~term.toLongLong());\r\n    }\r\n    else if (operation.compare(QLatin1String(\"`\")) == 0)\r\n    {\r\n        if (!term.contains(QLatin1Char('.')))\r\n        {\r\n            return QString::number(-term.toLongLong());\r\n        }\r\n        \r\n        return QString::number(-term.toDouble(), 'f', precisionOf(term));\r\n    }\r\n\r\n    return QStringLiteral(\"x\");\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SystemVerilogExpressionParser::solveClog2()\r\n//-----------------------------------------------------------------------------\r\nQString SystemVerilogExpressionParser::solveClog2(QString const& value) const\r\n{\r\n    qreal quotient = value.toLongLong();\r\n\r\n    if (quotient < 0)\r\n    {\r\n        return QStringLiteral(\"x\");\r\n    }\r\n\r\n    int answer = 0;\r\n    while (quotient > 1)\r\n    {\r\n        quotient /= 2;\r\n        ++answer;\r\n    }\r\n\r\n    return QString::number(answer);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SystemVerilogExpressionParser::solveSqrt()\r\n//-----------------------------------------------------------------------------\r\nQString SystemVerilogExpressionParser::solveSqrt(QString const& value) const\r\n{\r\n    const qreal radicand = value.toLongLong();\r\n    if (radicand < 0)\r\n    {\r\n        return QStringLiteral(\"x\");\r\n    }\r\n\r\n    return QString::number(qSqrt(radicand));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SystemVerilogExpressionParser::parseConstant()\r\n//-----------------------------------------------------------------------------\r\nQString SystemVerilogExpressionParser::parseConstant(QStringView token) const\r\n{\r\n    if (token.contains(QLatin1Char('.')))\r\n    {\r\n        return token.toString();\r\n    }\r\n\r\n    const auto base = baseOf(token);\r\n\r\n    // Remove formating of the number.\r\n    auto formattedToken = token.toString();\r\n    static QRegularExpression prefix(QStringLiteral(\"^([1-9][0-9_]*)?'[sS]?[dDbBoOhH]?\"));\r\n    formattedToken.remove(0, prefix.match(token).capturedLength());\r\n    formattedToken.remove(QLatin1Char('_'));\r\n\r\n    bool valid = false;\r\n    const qlonglong value = formattedToken.toLongLong(&valid, base);\r\n    if (valid == false)\r\n    {\r\n        return QStringLiteral(\"x\");\r\n    }\r\n\r\n    return QString::number(value);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SystemVerilogExpressionParser::isSymbol()\r\n//-----------------------------------------------------------------------------\r\nbool SystemVerilogExpressionParser::isSymbol(QStringView /*expression*/) const\r\n{\r\n    return false;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SystemVerilogExpressionParser::findSymbolValue()\r\n//-----------------------------------------------------------------------------\r\nQString SystemVerilogExpressionParser::findSymbolValue(QStringView symbol) const\r\n{\r\n    return symbol.toString();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SystemVerilogExpressionParser::getBaseForSymbol()\r\n//-----------------------------------------------------------------------------\r\nint SystemVerilogExpressionParser::getBaseForSymbol(QStringView symbol) const\r\n{\r\n    return baseOf(symbol);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SystemVerilogExpressionParser::operatorPrecedence()\r\n//-----------------------------------------------------------------------------\r\nunsigned int SystemVerilogExpressionParser::operatorPrecedence(QStringView oper)\r\n{\r\n    // Higher value means higher precedence.\r\n    const static QMap<QStringView, int> operator_precedence =\r\n    {\r\n        {QStringLiteral(\":\")      , 1},\r\n        {QStringLiteral(\"?\")      , 2},\r\n        {QStringLiteral(\"||\")     , 3},\r\n        {QStringLiteral(\"&&\")     , 4},\r\n        {QStringLiteral(\"|\")      , 5},\r\n        {QStringLiteral(\"^\" )     , 6},\r\n        {QStringLiteral(\"&\")      , 7},\r\n        {QStringLiteral(\"==\")     , 8},\r\n        {QStringLiteral(\"!=\")     , 8},\r\n        {QStringLiteral(\"<\")      , 9},\r\n        {QStringLiteral(\">\")      , 9},\r\n        {QStringLiteral(\"<=\")     , 9},\r\n        {QStringLiteral(\">=\")     , 9},\r\n        {QStringLiteral(\"<<\")     , 10},\r\n        {QStringLiteral(\">>\")     , 10},\r\n        {QStringLiteral(\"+\")      , 11},\r\n        {QStringLiteral(\"-\")      , 11},\r\n        {QStringLiteral(\"%\")      , 12},\r\n        {QStringLiteral(\"*\")      , 12},\r\n        {QStringLiteral(\"/\")      , 12},\r\n        {QStringLiteral(\"**\")     , 13},\r\n        {QStringLiteral(\"`\")      , 13}, // unary minus\r\n        {QStringLiteral(\"~\")      , 14},\r\n        {QStringLiteral(\"$clog2\") , 14},\r\n        {QStringLiteral(\"$pow\")   , 14},\r\n        {QStringLiteral(\"$sqrt\")  , 14},\r\n        {QStringLiteral(\"$exp\")   , 14},\r\n        {QStringLiteral(\"$ipxact_port_value\"), 14},\r\n        {QStringLiteral(\"$ipxact_field_value\"), 14},\r\n        {QStringLiteral(\"$ipxact_mode_condition\"), 14},\r\n        {QStringLiteral(\"(\")      , 15},\r\n        {QStringLiteral(\")\")      , 15},\r\n        {QStringLiteral(\"{\")      , 15},\r\n        {QStringLiteral(\"}\")      , 15}\r\n    };\r\n\r\n    return operator_precedence.value(oper, 0);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SystemVerilogExpressionParser::getBaseForNumber()\r\n//-----------------------------------------------------------------------------\r\nint SystemVerilogExpressionParser::baseOf(QStringView constantNumber)\r\n{\r\n    const static QMap<QStringView, int> base_formats =\r\n    {\r\n        { QString(), 10 },\r\n        { QStringLiteral(\"d\"), 10 },\r\n        { QStringLiteral(\"D\"), 10 },\r\n        { QStringLiteral(\"h\"), 16 },\r\n        { QStringLiteral(\"H\"), 16 },\r\n        { QStringLiteral(\"o\"), 8 },\r\n        { QStringLiteral(\"O\"), 8 },\r\n        { QStringLiteral(\"b\"), 2 },\r\n        { QStringLiteral(\"B\"), 2 },\r\n    };\r\n\r\n    const auto format = BASE_FORMAT.match(constantNumber).capturedView(1);\r\n\r\n    return base_formats.value(format, 0);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SystemVerilogExpressionParser::getDecimalPrecision()\r\n//-----------------------------------------------------------------------------\r\nint SystemVerilogExpressionParser::precisionOf(QStringView term) noexcept\r\n{\r\n    int decimalLength = 0;\r\n    \r\n    if  (const int commaPosition = term.indexOf(QLatin1Char('.')); commaPosition != -1)\r\n    {\r\n        decimalLength = term.length() - commaPosition - 1;\r\n    }\r\n\r\n    return decimalLength;\r\n}\r\n"
  },
  {
    "path": "KactusAPI/include/AbstractParameterInterface.h",
    "content": "//-----------------------------------------------------------------------------\n// File: AbstractParametersInterface.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 22.09.2020\n//\n// Description:\n// Abstraction for parameter interfaces.\n//-----------------------------------------------------------------------------\n\n#ifndef ABSTRACTPARAMETERSINTERFACE_H\n#define ABSTRACTPARAMETERSINTERFACE_H\n\n#include <KactusAPI/KactusAPIGlobal.h>\n\n#include \"ParameterizableInterface.h\"\n#include \"NameGroupInterface.h\"\n\nclass Choice;\nclass Component;\nclass Parameter;\nclass ParameterValidator;\n\n//-----------------------------------------------------------------------------\n//! Interface for editing parameters.\n//-----------------------------------------------------------------------------\nclass KACTUS2_API AbstractParameterInterface: public ParameterizableInterface, public NameGroupInterface\n{\npublic:\n\n\t/*!\n     *  The constructor.\n     *\n     *    @param [in] validator               Validator for parameters.\n     *    @param [in] expressionParser        Parser for expressions.\n     *    @param [in] expressionFormatter     Formatter for expressions.\n     */\n    AbstractParameterInterface(QSharedPointer<ParameterValidator> validator,\n        QSharedPointer<ExpressionParser> expressionParser,\n        QSharedPointer<ExpressionFormatter> expressionFormatter);\n\t\n\t/*!\n     *  The destructor.\n     */\n    virtual ~AbstractParameterInterface() = default;\n\n    /*!\n     *  Set available choices.\n     *\n     *    @param [in] newChoices  The new choices.\n     */\n    void setChoices(QSharedPointer<QList<QSharedPointer<Choice> > > newChoices);\n    \n    /*!\n     *  Set a new name for the selected item.\n     *\n     *    @param [in] currentName     Name of the selected item.\n     *    @param [in] newName         New name for the item.\n     *\n     *    @return True, if successful, false otherwise.\n     */\n    virtual bool setName(std::string const& currentName, std::string const& newName) override final;\n\n    /*!\n     *  Calculate all the references to the selected ID in the selected item.\n     *\n     *    @param [in] itemName    Name of the selected item.\n     *    @param [in] valueID     The selected ID.\n     *\n     *    @return Number of references to the selected ID in the selected item.\n     */\n    virtual int getAllReferencesToIdInItem(const std::string& itemName, std::string const&  valueID) const override final;\n    \n    /*!\n     *  Get the expressions in the selected parameters.\n     *\n     *    @param [in] parameterNames  Names of the selected parameters.\n     *\n     *    @return Expressions in the selected parameters.\n     */\n    std::vector<std::string> getExpressionsInSelectedItems(std::vector<std::string> parameterNames) const;\n\n    /*!\n     *  Validates the contained items.\n     *\n     *    @return True, if all the items are valid, false otherwise.\n     */\n    virtual bool validateItems() const override final;\n    \n    /*!\n     *  Check if the selected item has a valid name.\n     *\n     *    @param [in] itemName    Name of the selected item.\n     *\n     *    @return True, if the name is valid, false otherwise.\n     */\n    virtual bool itemHasValidName(std::string const& itemName) const override final;\n    \n    /*!\n     *  Get the display name of the selected parameter.\n     *\n     *    @param [in] parameterName   Name of the selected parameter.\n     *\n     *    @return Name of the selected parameter.\n     */\n    std::string getDisplayName(std::string const& parameterName) const;\n\n    /*!\n     *  Set the display name of the selected parameter.\n     *\n     *    @param [in] parameterName   Name of the selected parameter.\n     *    @param [in] newDisplayName  New display name for the parameter.\n     *\n     *    @return True, if successful, false otherwise.\n     */\n    bool setDisplayName(std::string const& parameterName, std::string const& newDisplayName);\n\n    /*!\n     *  Get the type of the selected parameter.\n     *\n     *    @param [in] parameterName   Name of the selected parameter.\n     *\n     *    @return Type of the selected parameter.\n     */\n    std::string getType(std::string const& parameterName) const;\n\n    /*!\n     *  Set the type of the selected parameter.\n     *\n     *    @param [in] parameterName   Name of the selected parameter.\n     *    @param [in] newType         New type for the parameter.\n     *\n     *    @return True, if successful, false otherwise.\n     */\n    bool setType(std::string const& parameterName, std::string const& newType);\n\n    /*!\n     *  Get the calculated bit width left value of the selected parameter.\n     *\n     *    @param [in] parameterName   Name of the selected parameter.\n     *    @param [in] baseNumber      Base for displaying the value.\n     *\n     *    @return Calculated bit width left value of the selected parameter.\n     */\n    std::string getBitWidthLeftValue(std::string const& parameterName, int const& baseNumber = 0) const;\n\n    /*!\n     *  Get the formatted bit width left expression of the selected parameter.\n     *\n     *    @param [in] parameterName   Name of the selected parameter.\n     *\n     *    @return Formatted bit width left expression of the selected parameter.\n     */\n    std::string getBitWidthLeftFormattedExpression(std::string const& parameterName) const;\n\n    /*!\n     *  Get the bit width left expression of the selected parameter.\n     *\n     *    @param [in] parameterName   Name of the selected parameter.\n     *\n     *    @return Bit width left expression of the selected parameter.\n     */\n    std::string getBitWidthLeftExpression(std::string const& parameterName) const;\n\n    /*!\n     *  Set a new bit width left value for the selected parameter.\n     *\n     *    @param [in] parameterName       Name of the selected parameter.\n     *    @param [in] newBitWidthLeft     New bit width left value.\n     *\n     *    @return True, if successful, false otherwise.\n     */\n    bool setBitWidthLeft(std::string const& parameterName, std::string const& newBitWidthLeft);\n\n    /*!\n     *  Get the calculated bit width right value of the selected parameter.\n     *\n     *    @param [in] parameterName   Name of the selected parameter.\n     *    @param [in] baseNumber      Base for displaying the value.\n     *\n     *    @return Calculated bit width right value of the selected port.\n     */\n    std::string getBitWidthRightValue(std::string const& parameterName, int const& baseNumber = 0) const;\n\n    /*!\n     *  Get the formatted bit width right expression of the selected parameter.\n     *\n     *    @param [in] parameterName   Name of the selected parameter.\n     *\n     *    @return Formatted bit width right expression of the selected parameter.\n     */\n    std::string getBitWidthRightFormattedExpression(std::string const& parameterName) const;\n\n    /*!\n     *  Get the bit width right expression of the selected parameter.\n     *\n     *    @param [in] parameterName   Name of the selected parameter.\n     *\n     *    @return Bit width right expression of the selected parameter.\n     */\n    std::string getBitWidthRightExpression(std::string const& parameterName) const;\n\n    /*!\n     *  Set a new bit width right value for the selected parameter.\n     *\n     *    @param [in] parameterName       Name of the selected parameter.\n     *    @param [in] newBitWidthRight    New bit width right value.\n     *\n     *    @return True, if successful, false otherwise.\n     */\n    bool setBitWidthRight(std::string const& parameterName, std::string const& newBitWidthRight);\n\n    /*!\n     *  Get the minimum value the selected parameter.\n     *\n     *    @param [in] parameterName   Name of the selected parameter.\n     *\n     *    @return Minimum value of the selected parameter.\n     */\n    std::string getMinimum(std::string const& parameterName) const;\n\n    /*!\n     *  Set the minimum value for the selected parameter.\n     *\n     *    @param [in] parameterName   Name of the selected parameter.\n     *    @param [in] newMinimum      New minimum value of the parameter.\n     *\n     *    @return True, if successful, false otherwise.\n     */\n    bool setMinimum(std::string const& parameterName, std::string const& newMinimum);\n\n    /*!\n     *  Get the maximum value the selected parameter.\n     *\n     *    @param [in] parameterName   Name of the selected parameter.\n     *\n     *    @return Maximum value of the selected parameter.\n     */\n    std::string getMaximum(std::string const& parameterName) const;\n\n    /*!\n     *  Set the maximum value for the selected parameter.\n     *\n     *    @param [in] parameterName   Name of the selected parameter.\n     *    @param [in] newMaximum      New maximum value of the parameter.\n     *\n     *    @return True, if successful, false otherwise.\n     */\n    bool setMaximum(std::string const& parameterName, std::string const& newMaximum);\n\n    /*!\n     *  Get the choice reference of the selected parameter.\n     *\n     *    @param [in] parameterName   Name of the selected parameter.\n     *\n     *    @return Choice reference of the selected parameter.\n     */\n    std::string getChoice(std::string const& parameterName) const;\n\n    /*!\n     *  Set the choice reference for the selected parameter.\n     *\n     *    @param [in] parameterName   Name of the selected parameter.\n     *    @param [in] newChoice       The new choice reference.\n     *\n     *    @return True, if successful, false otherwise.\n     */\n    bool setChoice(std::string const& parameterName, std::string const& newChoice);\n\n    /*!\n     *  Get the calculated value of the selected parameter.\n     *\n     *    @param [in] parameterName   Name of the selected parameter.\n     *    @param [in] baseNumber      Base for displaying the value.\n     *\n     *    @return Calculated value of the selected port.\n     */\n    std::string getValue(std::string const& parameterName, int const& baseNumber = 0) const;\n\n    /*!\n     *  Get the formatted value expression of the selected parameter.\n     *\n     *    @param [in] parameterName   Name of the selected parameter.\n     *\n     *    @return Formatted value expression of the selected parameter.\n     */\n    std::string getValueFormattedExpression(std::string const& parameterName) const;\n\n    /*!\n     *  Get the value expression of the selected parameter.\n     *\n     *    @param [in] parameterName   Name of the selected parameter.\n     *\n     *    @return Value expression of the selected parameter.\n     */\n    std::string getValueExpression(std::string const& parameterName) const;\n\n    /*!\n     *  Set a new value for the selected parameter.\n     *\n     *    @param [in] parameterName   Name of the selected parameter.\n     *    @param [in] newValue        New value.\n     *\n     *    @return True, if successful, false otherwise.\n     */\n    bool setValue(std::string const& parameterName, std::string const& newValue);\n\n    /*!\n     *  Get the resolve of the selected parameter.\n     *\n     *    @param [in] parameterName   Name of the selected parameter.\n     *\n     *    @return Resolve of the selected parameter.\n     */\n    std::string getResolve(std::string const& parameterName) const;\n\n    /*!\n     *  Set a resolve for the selected parameter.\n     *\n     *    @param [in] parameterName   Name of the selected parameter.\n     *    @param [in] newResolve      New resolve.\n     *\n     *    @return True, if successful, false otherwise.\n     */\n    bool setResolve(std::string const& parameterName, std::string const& newResolve);\n\n    /*!\n     *  Get the calculated array left value of the selected parameter.\n     *\n     *    @param [in] parameterName   Name of the selected parameter.\n     *    @param [in] baseNumber      Base for displaying the value.\n     *\n     *    @return Calculated array left value of the selected port.\n     */\n    std::string getArrayLeftValue(std::string const& parameterName, int const& baseNumber = 0) const;\n\n    /*!\n     *  Get the formatted array left expression of the selected parameter.\n     *\n     *    @param [in] parameterName   Name of the selected parameter.\n     *\n     *    @return Formatted array left expression of the selected parameter.\n     */\n    std::string getArrayLeftFormattedExpression(std::string const& parameterName) const;\n\n    /*!\n     *  Get the array left expression of the selected parameter.\n     *\n     *    @param [in] parameterName   Name of the selected parameter.\n     *\n     *    @return Array left expression of the selected parameter.\n     */\n    std::string getArrayLeftExpression(std::string const& parameterName) const;\n\n    /*!\n     *  Set a new array left value for the selected parameter.\n     *\n     *    @param [in] parameterName   Name of the selected parameter.\n     *    @param [in] newArrayLeft    New array left value.\n     *\n     *    @return True, if successful, false otherwise.\n     */\n    bool setArrayLeft(std::string const& parameterName, std::string const& newArrayLeft);\n\n    /*!\n     *  Get the calculated array right value of the selected parameter.\n     *\n     *    @param [in] parameterName   Name of the selected parameter.\n     *    @param [in] baseNumber      Base for displaying the value.\n     *\n     *    @return Calculated array right value of the selected port.\n     */\n    std::string getArrayRightValue(std::string const& parameterName, int const& baseNumber = 0) const;\n\n    /*!\n     *  Get the formatted array right expression of the selected parameter.\n     *\n     *    @param [in] parameterName   Name of the selected parameter.\n     *\n     *    @return Formatted array right expression of the selected parameter.\n     */\n    std::string getArrayRightFormattedExpression(std::string const& parameterName) const;\n\n    /*!\n     *  Get the array right expression of the selected parameter.\n     *\n     *    @param [in] parameterName   Name of the selected parameter.\n     *\n     *    @return Array right expression of the selected parameter.\n     */\n    std::string getArrayRightExpression(std::string const& parameterName) const;\n\n    /*!\n     *  Set a new array right value for the selected parameter.\n     *\n     *    @param [in] parameterName   Name of the selected parameter.\n     *    @param [in] newArrayRight   New array right value.\n     *\n     *    @return True, if successful, false otherwise.\n     */\n    bool setArrayRight(std::string const& parameterName, std::string const& newArrayRight);\n\n    /*!\n     *  Get the ID of the selected parameter.\n     *\n     *    @param [in] parameterName   Name of the selected parameter.\n     *\n     *    @return ID of the selected parameter.\n     */\n    std::string getID(std::string const& parameterName) const;\n\n    /*!\n     *  Set a new ID for the selected parameter.\n     *\n     *    @param [in] parameterName   Name of the selected parameter.\n     *    @param [in] newID           New ID.\n     *\n     *    @return True, if successful, false otherwise.\n     */\n    bool setID(std::string const& parameterName, std::string const& newID);\n\n    /*!\n     *  Get the usage count of the selected parameter.\n     *\n     *    @param [in] parameterName   Name of the selected parameter.\n     *\n     *    @return Usage count of the selected parameter.\n     */\n    int getUsageCount(std::string const& parameterName) const;\n\n    /*!\n     *  Set a new usage count for the selected parameter.\n     *\n     *    @param [in] parameterName   Name of the selected parameter.\n     *    @param [in] newUsageCount   New usage count.\n     *\n     *    @return True, if successful, false otherwise.\n     */\n    bool setUsageCount(std::string const& parameterName, int const& newUsageCount);\n\n    /*!\n     *  Increase the usage count of the selected parameter.\n     *\n     *    @param [in] parameterName   Name of the selected parameter.\n     *\n     *    @return True, if successful, false otherwise.\n     */\n    bool increaseUsageCount(std::string const& parameterName);\n\n    /*!\n     *  Decrease the usage count of the selected parameter.\n     *\n     *    @param [in] parameterName   Name of the selected parameter.\n     *\n     *    @return True, if successful, false otherwise.\n     */\n    bool reduceUsageCount(std::string const& parameterName);\n\n    /*!\n     *  Check if the selected parameter has a valid type.\n     *\n     *    @param [in] parameterName   New of the selected parameter.\n     *\n     *    @return True, if the type is valid, false otherwise.\n     */\n    bool hasValidType(std::string const& parameterName) const;\n\n    /*!\n     *  Check if the selected parameter has a valid bit width.\n     *\n     *    @param [in] parameterName   New of the selected parameter.\n     *\n     *    @return True, if the bit width is valid, false otherwise.\n     */\n    bool hasValidBitWidth(std::string const& parameterName) const;\n\n    /*!\n     *  Check if the selected parameter has a valid minimum.\n     *\n     *    @param [in] parameterName   New of the selected parameter.\n     *\n     *    @return True, if the minimum is valid, false otherwise.\n     */\n    bool hasValidMinimum(std::string const& parameterName) const;\n\n    /*!\n     *  Check if the selected parameter has a valid maximum.\n     *\n     *    @param [in] parameterName   New of the selected parameter.\n     *\n     *    @return True, if the maximum is valid, false otherwise.\n     */\n    bool hasValidMaximum(std::string const& parameterName) const;\n\n    /*!\n     *  Check if the selected parameter has a valid choice.\n     *\n     *    @param [in] parameterName   New of the selected parameter.\n     *\n     *    @return True, if the choice is valid, false otherwise.\n     */\n    bool hasValidChoice(std::string const& parameterName) const;\n\n    /*!\n     *  Check if the selected parameter has a valid value.\n     *\n     *    @param [in] parameterName   New of the selected parameter.\n     *\n     *    @return True, if the value is valid, false otherwise.\n     */\n    bool hasValidValue(std::string const& parameterName) const;\n\n    /*!\n     *  Check if the selected parameter has a valid resolve.\n     *\n     *    @param [in] parameterName   New of the selected parameter.\n     *\n     *    @return True, if the resolve is valid, false otherwise.\n     */\n    bool hasValidResolve(std::string const& parameterName) const;\n\n    /*!\n     *  Check if the selected parameter has valid array values.\n     *\n     *    @param [in] parameterName   New of the selected parameter.\n     *\n     *    @return True, if the array values are valid, false otherwise.\n     */\n    bool hasValidArrayValues(std::string const& parameterName) const;\n\n    //! No copying. No assignment.\n    AbstractParameterInterface(const AbstractParameterInterface& other) = delete;\n    AbstractParameterInterface& operator=(const AbstractParameterInterface& other) = delete;\n\nprivate:\n    \n    /*!\n     *  Get the selected parameter.\n     *\n     *    @param [in] parameterName   Name of the selected parameter.\n     *\n     *    @return The selected parameter.\n     */\n    virtual QSharedPointer<Parameter> getParameter(std::string const& parameterName) const = 0;\n\n    /*!\n     *  Evaluate the value of the selected parameter.\n     *\n     *    @param [in] parameter   The selected parameter.\n     *\n     *    @return Evaluated value of the selected parameter.\n     */\n    QString evaluateValue(QSharedPointer<Parameter> parameter) const;\n\n    /*!\n     *  Find the selected choice.\n     *\n     *    @param [in] choiceName  Name of the selected choice.\n     *\n     *    @return The selected choice.\n     */\n    QSharedPointer<Choice> findChoice(QString const& choiceName) const;\n\n    /*!\n     *  Changes the array value to match the current choice.\n     *\n     *    @param [in] choice          The currently active choice.\n     *    @param [in] arrayValue      The array value to be changed.\n     *\n     *    @return Array whose values have been changed to match the currently selected choice.\n     */\n    QString matchArrayValuesToSelectedChoice(QSharedPointer<Choice> choice, QString const& arrayValue) const;\n\n    /*!\n     *  Finds a human-readable value to display for a given enumeration.\n     *\n     *    @param [in] choice              The choice whose enumeration to find.\n     *    @param [in] enumerationValue    The value used to search the enumeration.\n     *\n     *    @return A value for the enumeration to display.\n     */\n    QString findDisplayValueForEnumeration(QSharedPointer<Choice> choice, QString const& enumerationValue) const;\n\n    //-----------------------------------------------------------------------------\n    // Data.\n    //-----------------------------------------------------------------------------\n\n    //! List of available choices.\n    QSharedPointer<QList<QSharedPointer<Choice> > > choices_ = nullptr;\n\n    //! The parameter validator.\n    QSharedPointer<ParameterValidator> parameterValidator_ = nullptr;\n};\n\n#endif // ABSTRACTPARAMETERSINTERFACE_H\n"
  },
  {
    "path": "KactusAPI/include/AbstractionTypeInterface.h",
    "content": "//-----------------------------------------------------------------------------\n// File: AbstractionTypeInterface.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 01.03.2021\n//\n// Description:\n// Interface for accessing abstraction types.\n//-----------------------------------------------------------------------------\n\n#ifndef ABSTRACTIONTYPEINTERFACE_H\n#define ABSTRACTIONTYPEINTERFACE_H\n\n#include <IPXACTmodels/generaldeclarations.h>\n\n#include \"KactusAPI/KactusAPIGlobal.h\"\n\n#include <CommonInterface.h>\n\n#include <QSharedPointer>\n\nclass AbstractionDefinition;\nclass AbstractionType;\nclass AbstractionTypeValidator;\nclass Component;\nclass ConfigurableVLNVReference;\nclass PortMapInterface;\nclass LibraryInterface;\n\n//-----------------------------------------------------------------------------\n//! Interface for accessing abstraction types.\n//-----------------------------------------------------------------------------\nclass KACTUS2_API AbstractionTypeInterface: public CommonInterface\n{\npublic:\n\n    /*!\n     *  The constructor.\n     *\n     *    @param [in] portMapInterface    Interface for accessing port maps.\n     *    @param [in] validator           Validator for abstraction types.\n     *    @param [in] library             Interface for the VLNV library.\n     */\n    AbstractionTypeInterface(PortMapInterface* portMapInterface,\n        QSharedPointer<AbstractionTypeValidator> validator, LibraryInterface* library);\n\n    /*!\n     *  The destructor.\n     */\n    virtual ~AbstractionTypeInterface() = default;\n\n    /*!\n     *  Setup the abstraction types.\n     *\n     *    @param [in] newAbstractions     The new abstraction types.\n     *    @param [in] busMode             The new bus interface mode.\n     *    @param [in] systemGroup         The new system group.\n     */\n    void setAbstractionTypes(QSharedPointer<QList<QSharedPointer<AbstractionType> > > newAbstractions,\n        General::InterfaceMode busMode, QString const& systemGroup);\n\n    /*!\n     *  Setup a new bus interface mode.\n     *\n     *    @param [in] busMode     The selected bus interface mode.\n     */\n    void setBusMode(General::InterfaceMode busMode);\n\n    /*!\n     *  Setup a new system group.\n     *\n     *    @param [in] systemGroup     The selected system group.\n     */\n    void setSystemGroup(QString const& systemGroup);\n\n    /*!\n     *  Get the selected abstraction type.\n     *\n     *    @param [in] abstractionIndex    Index of the selected abstraction type.\n     *\n     *    @return The selected abstraction type.\n     */\n    QSharedPointer<AbstractionType> getAbstraction(int const& abstractionIndex) const;\n\n    /*!\n     *  Setup the containing port map interface.\n     *\n     *    @param [in] abstractionTypeIndex    Index of the selected abstraction type.\n     *\n     *    @return True, if succesfull, false otherwise.\n     */\n    bool setupAbstractionTypeForPortMapInterface(int const& abstractionTypeIndex);\n\n    /*!\n     *  Setup the abstraction definition for port map interface.\n     *\n     *    @param [in] abstractionTypeIndex    Index of the selected abstraction definition.\n     *\n     *    @return True, if succesfull, false otherwise.\n     */\n    bool setupAbstractionDefinitionForPortMapInterface(int const& abstractionTypeIndex);\n\n    /*!\n     *  Get the abstraction reference string of the selected abstraction type.\n     *\n     *    @param [in] itemIndex   Index of the selected abstraction type.\n     *\n     *    @return Abstraction reference string of the selected abstraction type.\n     */\n    std::string getIndexedAbstraction(int const& itemIndex) const;\n\n    /*!\n     *  Get the abstraction reference of the selected abstraction type.\n     *\n     *    @param [in] typeIndex   Index of the selected abstraction type.\n     *\n     *    @return Abstraction reference of the selected abstraction type.\n     */\n    QSharedPointer<ConfigurableVLNVReference> getAbstractionReference(int const& typeIndex) const;\n\n    /*!\n     *  Get the abstraction reference string.\n     *\n     *    @return Abstraction reference if only a single abstraction type exists, otherwise [multiple].\n     */\n    std::string getAbstractionReferenceString() const;\n\n    /*!\n     *  Get the list of abstraction references.\n     *\n     *    @return String list of the abstraction references.\n     */\n    std::vector<std::string> getAbstractionReferences() const;\n\n    /*!\n     *  Check if the selected abstraction type has an abstraction reference.\n     *\n     *    @param [in] typeIndex   Index of the selected abstraction type.\n     *\n     *    @return True, if the selected abstraction type has an abstraction reference, false otherwise.\n     */\n    bool hasAbstractionReference(int const& typeIndex) const;\n\n    /*!\n     *  Get the number of available abstraction types.\n     *\n     *    @return Number of available abstraction types.\n     */\n    virtual int itemCount() const override final;\n\n    /*!\n     *  Get the abstraction references of the available abstraction types.\n     *\n     *    @return Abstraction references of the available abstraction types.\n     */\n    virtual std::vector<std::string> getItemNames() const override final;\n\n    /*!\n     *  Set a new abstraction reference for the selected abstraction type.\n     *\n     *    @param [in] abstractionIndex    Index of the selected abstraction type.\n     *    @param [in] newVendor           Vendor of the new abstraction reference.\n     *    @param [in] newLibrary          Library of the new abstraction reference.\n     *    @param [in] newName             Name of the new abstraction reference.\n     *    @param [in] newVersion          Version of the new abstraction reference.\n     *\n     *    @return True, if successful, false otherwise.\n     */\n    bool setAbstraction(int const& abstractionIndex, std::string const& newVendor, std::string const& newLibrary,\n        std::string const& newName, std::string const& newVersion);\n\n    /*!\n     *  Get the view references of the selected abstraction type.\n     *\n     *    @param [in] abstractionIndex    Index of the abstraction type.\n     *\n     *    @return View references of the selected abstraction type.\n     */\n    std::vector<std::string> getViewReferences(int const& abstractionIndex) const;\n\n    /*!\n     *  Get the view references of the selected abstraction type as a single string.\n     *\n     *    @param [in] abstractionIndex    Index of the selected abstraction type.\n     *\n     *    @return String containing the view references of the selected abstraction type.\n     */\n    std::string getCombinedViews(int const& abstractionIndex) const;\n\n    /*!\n     *  Set view references for the selected abstraction type.\n     *\n     *    @param [in] abstractionIndex    Index of the selected abstraction type.\n     *    @param [in] newViews            The new view references.\n     *\n     *    @return True, if successful, false otherwise.\n     */\n    bool setViewReferences(int const& abstractionIndex, std::vector<std::string> newViews);\n\n    /*!\n     *  Get the physical port names from all the contained port maps of the selected abstraction type.\n     *\n     *    @param [in] abstractionIndex    Index of the selected abstraction type.\n     *\n     *    @return Physical port names.\n     */\n    std::vector<std::string> getPhysicalPortsFromPortMaps(int const& abstractionIndex) const;\n\n    /*!\n     *  Validates the contained abstraction types.\n     *\n     *    @return True, if all the abstraction types are valid, false otherwise.\n     */\n    virtual bool validateItems() const override final;\n\n    /*!\n     *  Check if the selected abstraction type has a valid abstraction reference.\n     *\n     *    @param [in] typeIndex   Index of the selected abstraction type.\n     *\n     *    @return True, if the selected abstraction type has a valid abstraction reference.\n     */\n    bool hasValidAbstractionReference(int const& typeIndex) const;\n\n    /*!\n     *  Check if the selected abstraction type has valid view references.\n     *\n     *    @param [in] typeIndex   Index of the selected abstraction type.\n     *\n     *    @return True, if the selected abstraction type has valid view references.\n     */\n    bool hasValidViewReferences(int const& typeIndex) const;\n\n    /*!\n     *  Add an abstraction type.\n     *\n     *    @param [in] typeIndex   Index of the selected abstraction type.\n     */\n    void addAbstraction(int const& typeIndex);\n\n    /*!\n     *  Add the selected abstraction type.\n     *\n     *    @param [in] newVendor   Vendor of the new abstraction reference.\n     *    @param [in] newLibrary  Library of the new abstraction reference.\n     *    @param [in] newName     Name of the new abstraction reference.\n     *    @param [in] newVersion  Version of the new abstraction reference.\n     */\n    void addAbstractionType(std::string const& newVendor, std::string const& newLibrary,\n        std::string const& newName, std::string const& newVersion) const;\n\n    /*!\n     *  Remove the selected abstraction type.\n     *\n     *    @param [in] typeIndex   Index of the selected abstraction type.\n     *\n     *    @return True, if successful, false otherwise.\n     */\n    bool removeAbstraction(int const& typeIndex);\n\n    /*!\n     *  Get the contained port map interface.\n     *\n     *    @return The port map interface.\n     */\n    PortMapInterface* getPortMapInterface() const;\n\n    //! No copying. No assignment.\n    AbstractionTypeInterface(const AbstractionTypeInterface& other) = delete;\n    AbstractionTypeInterface& operator=(const AbstractionTypeInterface& other) = delete;\n\nprivate:\n\n    //-----------------------------------------------------------------------------\n    // Data.\n    //-----------------------------------------------------------------------------\n\n    //! List of the available abstraction types.\n    QSharedPointer<QList<QSharedPointer<AbstractionType> > > abstractions_{ nullptr };\n\n    //! Interface for accessing port maps.\n    PortMapInterface* portMapInterface_;\n\n    //! Validator for abstraction types.\n    QSharedPointer<AbstractionTypeValidator> validator_;\n\n    //! Interface for the VLNV library.\n    LibraryInterface* library_;\n};\n\n#endif // BUSINTERFACEINTERFACE_H\n"
  },
  {
    "path": "KactusAPI/include/AccessPolicyInterface.h",
    "content": "//-----------------------------------------------------------------------------\n// File: AccessPolicyInterface.h\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Anton Hagqvist\n// Date: 20.9.2023\n//\n// Description:\n// Interface for editing access policies.\n//-----------------------------------------------------------------------------\n\n#ifndef ACCESSPOLICYINTERFACE_H\n#define ACCESSPOLICYINTERFACE_H\n\n#include <KactusAPI/KactusAPIGlobal.h>\n\n#include <IPXACTmodels/common/AccessTypes.h>\n\n#include <QList>\n#include <QSharedPointer>\n\nclass AccessPolicy;\nclass ModeReferenceInterface;\nclass ModeReference;\nclass Mode;\n\n//-----------------------------------------------------------------------------\n//! Interface for editing access policies.\n//-----------------------------------------------------------------------------\nclass KACTUS2_API AccessPolicyInterface\n{\npublic:\n\n    /*!\n     *\tThe constructor.\n     *  \n     *    @param [in] modeRefInterface     Interface for accessing mode references.\n     */\n    explicit AccessPolicyInterface(ModeReferenceInterface* modeRefInterface);\n\n    virtual ~AccessPolicyInterface() = default;\n\n    //! No copying.\n    AccessPolicyInterface(AccessPolicyInterface const& other) = delete;\n    AccessPolicyInterface& operator=(AccessPolicyInterface const& other) = delete;\n\n    /*!\n     *\tSet available access policies.\n     *  \n     *    @param [in] accessPolicies     Access policies to set.\n     */\n    void setAccessPolicies(QSharedPointer<QList<QSharedPointer<AccessPolicy> > > accessPolicies);\n\n    /*!\n     *\tSet the available component modes for the interface.\n     *  \n     *    @param [in] componentModes     The available component modes.\n     */\n    void setComponentModes(QSharedPointer<QList<QSharedPointer<Mode> > > componentModes);\n\n    /*!\n     *\tGet the access policy count.\n     *\t    \n     * \t    @return The number of available access policies.\n     */\n    int getAccessPolicyCount() const;\n\n    /*!\n     *\tAdd a new access policy.\n     */\n    void addAccessPolicy(int row);\n\n    /*!\n     *\tRemove an access policy given by index.\n     *  \n     *    @param [in] accessPolicyIndex     The index of the access policy to remove.\n     *\t    \n     * \t    @return True, if the removal was successful, otherwise false.\n     */\n    bool removeAccessPolicy(int accessPolicyIndex);\n\n    /*!\n     *\tSet the access value for a given accesspolicy.\n     *  \n     *    @param [in] newAccess             The new access value to set.\n     *    @param [in] accessPolicyIndex     The index of the access policy to set the access for.\n     *\t    \n     * \t    @return True, if the access value was successfully set, otherwise false.\n     */\n    bool setAccess(std::string const& newAccess, int accessPolicyIndex);\n\n    /*!\n     *\tGet the access value as a string of a given access policy.\n     *  \n     *    @param [in] accessPolicyIndex     The index of the access policy.\n     *\n     * \t    @return The access value as a string.\n     */\n    std::string getAccessString(int accessPolicyIndex) const;\n\n    /*!\n     *\tGet the access value of a given access policy.\n     *  \n     *    @param [in] accessPolicyIndex     The index of the access policy.\n     *\t    \n     * \t    @return The access value.\n     */\n    AccessTypes::Access getAccess(int accessPolicyIndex) const;\n\n    /*!\n     *\tGet the mode reference interface.\n     *  \n     * \t    @return The mode reference interface.\n     */\n    ModeReferenceInterface* getModeReferenceInterface() const;\n\n    /*!\n     *\tGet the mode references of given access policy.\n     *  \n     *    @param [in] accessPolicyIndex     The index of the access policy whose mode references to get.\n     *\t    \n     * \t    @return  The mode references of access policy given by index.\n     */\n    std::vector<std::pair<unsigned int, std::string> > getAccesPolicyModeReferences(int accessPolicyIndex) const;\n\n    /*!\n     *\tSet mode references of an access policy.\n     *  \n     *    @param [in] accessPolicyIndex       The index of the access policy whose mode references to be set.\n     *    @param [in] newModeRefs             The modereferences to be set.\n     *\t    \n     * \t    @return True, if the operation was successful, otherwise false.\n     */\n    bool setAccessPolicyModeReferences(int accessPolicyIndex, std::vector<std::pair<unsigned int, std::string> > const& newModeRefs);\n\n    /*!\n     *\tGet the mode references in use by other than selected access policy given by index.\n     *  \n     *    @param [in] accessPolicyIndex     The index of the access policy whose mode references are not to be\n     *                                        included in the returned list.\n     *\t    \n     * \t    @return All other mode references in use.\n     */\n    std::vector<std::pair<unsigned int, std::string> > getModeReferencesInUse(int accessPolicyIndex) const;\n\n    /*!\n     *\tValidates the mode references of selected access policy. Compares against all mode references \n     *  in other access policies.\n     *  \n     *    @param [in] accessPolicyIndex     The index of the access policy whose mode references are validated.\n     *\t    \n     * \t    @return True, if the mode references of selected accesspolicy are valid, otherwise false.\n     */\n    bool accessPolicyHasValidModeReferences(int accessPolicyIndex) const;\n\nprivate:\n\n    //! Available access policies.\n    QSharedPointer<QList<QSharedPointer<AccessPolicy> > > accessPolicies_ =\n        QSharedPointer<QList<QSharedPointer<AccessPolicy> > >(new QList<QSharedPointer<AccessPolicy> >());\n    \n    //! The interface for accessing access policy mode references.\n    ModeReferenceInterface* modeRefInterface_;\n\n    //! Available component modes.\n    QSharedPointer<QList<QSharedPointer<Mode> > > componentModes_;\n};\n\n\n#endif // ACCESSPOLICYINTERFACE_H\n\n"
  },
  {
    "path": "KactusAPI/include/AdHocConnectionInterface.h",
    "content": "//-----------------------------------------------------------------------------\n// File: AdHocconnectionInterface.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 10.09.2021\n//\n// Description:\n// Interface for accessing design ad hoc connections.\n//-----------------------------------------------------------------------------\n\n#ifndef ADHOCCONNECTIONINTERFACE_H\n#define ADHOCCONNECTIONINTERFACE_H\n\n#include <NameGroupInterface.h>\n\n#include <QSharedPointer>\n\nclass Design;\nclass AdHocConnection;\n\n//-----------------------------------------------------------------------------\n//! Interface for accessing design ad hoc connections.\n//-----------------------------------------------------------------------------\nclass KACTUS2_API AdHocConnectionInterface : public NameGroupInterface\n{\npublic:\n\n    /*!\n     *  The constructor.\n     */\n    AdHocConnectionInterface();\n\n    /*!\n     *  The destructor.\n     */\n    virtual ~AdHocConnectionInterface() = default;\n\n    /*!\n     *  Setup the ad hoc connections.\n     *\n     *    @param [in] newDesign   Design containing the ad hoc connections.\n     */\n    void setConnections(QSharedPointer<Design> newDesign);\n\n    /*!\n     *  Get index of the selected ad hoc connection.\n     *\n     *    @param [in] itemName    Name of the selected ad hoc connection.\n     *\n     *    @return Index of the selected ad hoc connection.\n     */\n    virtual int getItemIndex(std::string const& itemName) const override final;\n\n    /*!\n     *  Get name of the indexed ad hoc connection.\n     *\n     *    @param [in] itemIndex   Index of the selected ad hoc connection.\n     *\n     *    @return Name of the selected ad hoc connection.\n     */\n    std::string getIndexedItemName(int itemIndex) const final;\n\n    /*!\n     *  Get the name of the selected ad hoc connection.\n     *\n     *    @param [in] startInstanceName   Name of the instance containing the first port.\n     *    @param [in] startPortName       Name of the first port.\n     *    @param [in] endInstanceName     Name of the instance containing the second port.\n     *    @param [in] endPortName         Name of the second port.\n     *\n     *    @return Name of the selected ad hoc connection.\n     */\n    std::string getConnectionName(std::string const& startInstanceName, std::string const& startPortName,\n        std::string const& endInstanceName, std::string const& endPortName) const;\n\n    /*!\n     *  Get the name of the selected hierarchical ad hoc connection.\n     *\n     *    @param [in] instanceName    Name of the component instance containing the selected port.\n     *    @param [in] instancePort    Name of the selected component instance port.\n     *    @param [in] topPort         Name of the top component port.\n     *\n     *    @return Name of the selected ad hoc connection.\n     */\n    std::string getHierarchicalConnectionName(std::string const& instanceName, std::string const& instancePort,\n        std::string const& topPort) const;\n\n    /*!\n     *  Get the number of available ad hoc connections.\n     *\n     *    @return Number of available ad hoc connections.\n     */\n    virtual int itemCount() const override final;\n\n    /*!\n     *  Get the names of the available bus interfaces.\n     *\n     *    @return Names of the available bus interfaces.\n     */\n    virtual std::vector<std::string> getItemNames() const override final;\n\n    /*!\n     *  Set a new name for the selected ad hoc connection.\n     *\n     *    @param [in] currentName     Name of the selected ad hoc connection.\n     *    @param [in] newName         New name for the ad hoc connection.\n     *\n     *    @return True, if successful, false otherwise.\n     */\n    virtual bool setName(std::string const& currentName, std::string const& newName) override final;\n\n    /*!\n     *  Get the description of the selected ad hoc connection.\n     *\n     *    @param [in] itemName    Name of the selected ad hoc connection.\n     *\n     *    @return Description of the selected ad hoc connection.\n     */\n    virtual std::string getDescription(std::string const& itemName) const override final;\n\n    /*!\n     *  Set a new description for the selected ad hoc connection.\n     *\n     *    @param [in] itemName        Name of the selected ad hoc connection.\n     *    @param [in] newDescription  New description.\n     *\n     *    @return True, if successful, false otherwise.\n     */\n    virtual bool setDescription(std::string const& itemName, std::string const& newDescription) override final;\n\n    /*!\n     *  Validates the contained ad hoc connections.\n     *\n     *    @return True, if all the ad hoc connections are valid, false otherwise.\n     */\n    virtual bool validateItems() const override final;\n\n    /*!\n     *  Check if the selected ad hoc connection has a valid name.\n     *\n     *    @param [in] itemName    Name of the selected ad hoc connection.\n     *\n     *    @return True, if the name is valid, false otherwise.\n     */\n    virtual bool itemHasValidName(std::string const& itemName) const override final;\n\n    /*!\n     *  Add a new ad hoc connection.\n     *\n     *    @param [in] startComponentInstance  Name of the component instance containing the first port.\n     *    @param [in] startPort               Name of the first port.\n     *    @param [in] endComponentInstance    Name of the component instance containing the second port.\n     *    @param [in] endPort                 Name of the second port.\n     *    @param [in] connectionName          Name of the new ad hoc connection.\n     */\n    void addAdHocConnection(std::string const& startComponentInstance, std::string const& startPort,\n        std::string const& endComponentInstance, std::string const& endPort,\n        std::string const& connectionName = \"\");\n\n    /*!\n     *  Add a new hierarchical ad hoc connection. \n     *\n     *    @param [in] instanceName        Name of the component instance containing the selected port.\n     *    @param [in] instancePort        Name of the selected port.\n     *    @param [in] topPort             Name of the top component port.\n     *    @param [in] connectionName      Name of the new ad hoc connection.\n     */\n    void addHierarchicalAdHocConnection(std::string const& instanceName, std::string const& instancePort,\n        std::string const& topPort, std::string const& connectionName = \"\");\n\n    /*!\n     *  Remove the selected ad hoc connection.\n     *\n     *    @param [in] busName     Name of the selected ad hoc connection.\n     *\n     *    @return True, if successful, false otherwise.\n     */\n    bool removeAdHocConnection(std::string const& connectionName);\n\n    /*!\n     *  Remove ad hoc connections connected to the selected component instance.\n     *\n     *    @param [in] instanceName    Name of the selected component instance.\n     *\n     *    @return True, if successful, false otherwise.\n     */\n    bool removeInstanceAdHocConnections(std::string const& instanceName);\n\n    /*!\n     *  Check if the selected ad hoc connection exists.\n     *\n     *    @param [in] connectionName  Name of the selected ad hoc connection.\n     *\n     *    @return True, if the ad hoc connection exists, false otherwise.\n     */\n    bool adHocConnectionExists(std::string const& connectionName) const;\n\n    /*!\n     *  Rename the component references in connections.\n     *\n     *    @param [in] currentName     Current name of the component instance.\n     *    @param [in] newName         New name for the component instance.\n     */\n    void renameComponentReferences(std::string const& currentName, std::string const& newName);\n\n    //! No copying. No assignment.\n    AdHocConnectionInterface(const AdHocConnectionInterface& other) = delete;\n    AdHocConnectionInterface& operator=(const AdHocConnectionInterface& other) = delete;\n\nprivate:\n\n    /*!\n     *  Get the selected ad hoc connection.\n     *\n     *    @param [in] connectionName     Name of the selected ad hoc connection.\n     *\n     *    @return The selected ad hoc connection.\n     */\n    QSharedPointer<AdHocConnection> getAdHocConnection(std::string const& connectionName) const;\n\n    /*!\n     *  Get the ad hoc connection with the selected name, sliced to a NameGroup.\n     *\n     *    @param [in] connectionName   Name of the selected ad hoc connection.\n     *\n     *    @return The sliced ad hoc connection with the selected name.\n     */\n    QSharedPointer<NameGroup> getItem(std::string const& connectionName) const;\n\n    //-----------------------------------------------------------------------------\n    // Data.\n    //-----------------------------------------------------------------------------\n\n    //! The available ad hoc connections.\n    QSharedPointer<QList<QSharedPointer<AdHocConnection> > > connections_;\n};\n\n#endif // ADHOCCONNECTIONINTERFACE_H\n"
  },
  {
    "path": "KactusAPI/include/AddressBlockExpressionsGatherer.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: AddressBlockExpressionGatherer.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Mikko Teuho\r\n// Date: 29.04.2015\r\n//\r\n// Description:\r\n// Gathers expressions from an address block and its registers.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef ADDRESSBLOCKEXPRESSIONSGATHERER_H\r\n#define ADDRESSBLOCKEXPRESSIONSGATHERER_H\r\n\r\n#include <IPXACTmodels/Component/AddressBlock.h>\r\n\r\n#include \"KactusAPI/KactusAPIGlobal.h\"\r\n\r\n#include <QSharedPointer>\r\n#include <QStringList>\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Gathers expressions from an address block and its registers.\r\n//-----------------------------------------------------------------------------\r\nclass KACTUS2_API AddressBlockExpressionGatherer\r\n{\r\n\r\npublic:\r\n\r\n    /*!\r\n     *  The constructor.\r\n     */\r\n    AddressBlockExpressionGatherer();\r\n\r\n    /*!\r\n     *  The destructor.\r\n     */\r\n    virtual ~AddressBlockExpressionGatherer();\r\n\r\n    /*!\r\n     *  Get the expressions from the given address block.\r\n     *\r\n     *    @param [in] currentAddressBlock     The given address block.\r\n     *\r\n     *    @return A list of all the expressions used in address block.\r\n     */\r\n    QStringList getExpressions(QSharedPointer<AddressBlock> currentAddressBlock) const;\r\n\r\nprivate:\r\n\t\r\n\t//! No copying.\r\n    AddressBlockExpressionGatherer(const AddressBlockExpressionGatherer& other);\r\n\r\n\t//! No assignment.\r\n    AddressBlockExpressionGatherer& operator=(const AddressBlockExpressionGatherer& other);\r\n\r\n};\r\n\r\n#endif // ADDRESSBLOCKEXPRESSIONSGATHERER_H\r\n"
  },
  {
    "path": "KactusAPI/include/AddressBlockInterface.h",
    "content": "//-----------------------------------------------------------------------------\n// File: AddressBlockInterface.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 05.05.2020\n//\n// Description:\n// Interface for editing address blocks.\n//-----------------------------------------------------------------------------\n\n#ifndef ADDRESSBLOCKINTERFACE_H\n#define ADDRESSBLOCKINTERFACE_H\n\n#include <KactusAPI/KactusAPIGlobal.h>\n\n#include <MemoryBlockInterface.h>\n\n#include <IPXACTmodels/generaldeclarations.h>\n#include <IPXACTmodels/common/AccessTypes.h>\n\nclass AddressBlock;\nclass MemoryBlockBase;\nclass AddressBlockValidator;\nclass RegisterInterface;\nclass BusInterfaceInterface;\n\n#include <QVector>\n#include <QMap>\n\n//-----------------------------------------------------------------------------\n//! Interface for editing address blocks.\n//-----------------------------------------------------------------------------\nclass KACTUS2_API AddressBlockInterface : public MemoryBlockInterface\n{\n\npublic:\n\n    /*!\n     *  The constructor.\n     *\n     *    @param [in] blockValidator          Validator for address blocks.\n     *    @param [in] expressionParser        Parser for expressions.\n     *    @param [in] expressionFormatter     Formatter for expressions.\n     *    @param [in] busInterface            Interface for accessing bus interfaces.\n     *    @param [in] subInterface            Interface for accessing registers.\n     *    @param [in] parameterInterface      Interface for accessing parameters.\n     */\n    AddressBlockInterface(QSharedPointer<AddressBlockValidator> blockValidator,\n        QSharedPointer<ExpressionParser> expressionParser,\n        QSharedPointer<ExpressionFormatter> expressionFormatter,\n        BusInterfaceInterface* busInterface,\n        RegisterInterface* subInterface,\n        ParametersInterface* parameterInterface);\n\t\n\t/*!\n     *  The destructor.\n     */\n    virtual ~AddressBlockInterface() = default;\n\n    /*!\n     *  Check if the selected memory block is an address block.\n     *\n     *    @param [in] blockName   Name of the selected memory block.\n     *\n     *    @return True, if the memory block is an address block, false otherwise.\n     */\n    virtual bool acceptBlock(std::string const& blockName) const final;\n\n    /*!\n     *  Get the formatted range expression of the selected address block.\n     *\n     *    @param [in] blockName   Name of the selected address block.\n     *\n     *    @return Formatted range expression of the selected address block.\n     */\n    std::string getRangeFormattedExpression(std::string const& blockName) const;\n\n    /*!\n     *  Get the range expression of the selected address block.\n     *\n     *    @param [in] blockName   Name of the selected address block.\n     *\n     *    @return Range expression of the selected address block.\n     */\n    std::string getRangeExpression(std::string const& blockName) const;\n\n    /*!\n     *  Set a new range value for the selected address block.\n     *\n     *    @param [in] blockName   Name of the selected address block.\n     *    @param [in] newRange    New range value.\n     *\n     *    @return True, if successful, false otherwise.\n     */\n    bool setRange(std::string const& blockName, std::string const& newRange) const;\n\n    /*!\n     *  Get the calculated width value of the selected address block.\n     *\n     *    @param [in] blockName   Name of the selected address block.\n     *    @param [in] baseNumber  Base for displaying the value.\n     *\n     *    @return Calculated width value of the selected address block.\n     */\n    std::string getWidthValue(std::string const& blockName, int const& baseNumber = 0) const;\n\n    /*!\n     *  Get the formatted width expression of the selected address block.\n     *\n     *    @param [in] blockName   Name of the selected address block.\n     *\n     *    @return Formatted width expression of the selected address block.\n     */\n    std::string getWidthFormattedExpression(std::string const& blockName) const;\n\n    /*!\n     *  Get the width expression of the selected address block.\n     *\n     *    @param [in] blockName   Name of the selected address block.\n     *\n     *    @return Width expression of the selected address block.\n     */\n    std::string getWidthExpression(std::string const& blockName) const;\n\n    /*!\n     *  Set a new width value for the selected address block.\n     *\n     *    @param [in] blockName   Name of the selected address block.\n     *    @param [in] newWidth    New width value.\n     *\n     *    @return True, if successful, false otherwise.\n     */\n    bool setWidth(std::string const& blockName, std::string const& newWidth) const;\n    \n    /*!\n     *  Get the usage string of the selected address block.\n     *\n     *    @param [in] blockName   Name of the selected address block.\n     *\n     *    @return Usage string of the selected address block.\n     */\n    std::string getUsageString(std::string const& blockName) const;\n\n    /*!\n     *  Get the usage of the selected address block.\n     *\n     *    @param [in] blockName   Name of the selected address block.\n     *\n     *    @return Usage of the selected address block.\n     */\n    General::Usage getUsage(std::string const& blockName) const;\n\n    /*!\n     *  Set a new usage value for the selected address block.\n     *\n     *    @param [in] blockName   Name of the selected address block.\n     *    @param [in] newUsage    New usage value.\n     *\n     *    @return True, if successful, false otherwise.\n     */\n    bool setUsage(std::string const& blockName, std::string const& newUsage) const;\n    \n    /*!\n     *  Get the access string of the selected address block or one of its access policies specified by the\n     *  accessPolicyIndex parameter. The default value of -1 returns the address block's access value. 0 and above\n     *  returns an indexed access policy's access value.\n     *\n     *    @param [in] blockName               Name of the selected address block.\n     *    @param [in] getAccessPolicyAccess   Flag indicating if access is fetched from access policy or directly\n     *                                          from address block.\n     *\n     *    @return Access string of the selected address block or its access policy.\n     */\n    std::string getAccessString(std::string const& blockName, bool getAccessPolicyAccess = false) const;\n\n    /*!\n     *  Get the access of the selected address block. Used in std14 access editor.\n     *\n     *    @param [in] blockName           Name of the selected address block.\n     *\n     *    @return Access of the selected address block.\n     */\n    AccessTypes::Access getAccess(std::string const& blockName) const;\n\n    /*!\n     *  Set a new access for the selected address block.\n     *\n     *    @param [in] blockName               Name of the selected address block.\n     *    @param [in] newAccess               New access value.\n     *    @param [in] getAccessPolicyAccess   Flag indicating if access is set to access policy or directly to\n     *                                          address block.\n     *\n     *    @return True, if successful, false otherwise.\n     */\n    bool setAccess(std::string const& blockName, std::string const& newAccess, bool setAccessPolicyAccess = false) const;\n\n    /*!\n     *  Get the volatile value of the selected address block.\n     *\n     *    @param [in] blockName   Name of the selected address block.\n     *\n     *    @return Volatile value of the selected address block.\n     */\n    std::string getVolatile(std::string const& blockName) const;\n\n    /*!\n     *  Set a new volatile value for the selected address block.\n     *\n     *    @param [in] blockName       Name of the selected address block.\n     *    @param [in] newVolatile     New volatile value.\n     *\n     *    @return True, if successful, false otherwise.\n     */\n    bool setVolatile(std::string const& blockName, bool newVolatile) const;\n\n    /*!\n     *  Set a new volatile value for the selected address block.\n     *\n     *    @param [in] blockName           Name of the selected address block.\n     *    @param [in] newVolatileValue    The new volatile value.\n     *\n     *    @return True, if successful, false otherwise.\n     */\n    bool setVolatile(std::string const& blockName, std::string const& newVolatileValue);\n\n    /*!\n     *  Calculate all the references to the selected ID in the selected item.\n     *\n     *    @param [in] itemName    Name of the selected item.\n     *    @param [in] valueID     The selected ID.\n     *\n     *    @return Number of references to the selected ID in the selected item.\n     */\n    virtual int getAllReferencesToIdInItem(const std::string& itemName, std::string const&  valueID) const final;\n\n    /*!\n     *  Validates the contained items.\n     *\n     *    @return True, if all the ports are valid, false otherwise.\n     */\n    virtual bool validateItems() const override final;\n\n    /*!\n     *  Check if the selected address block has a valid range.\n     *\n     *    @param [in] itemName    Name of the selected address block.\n     *\n     *    @return True, if the range is valid, false otherwise.\n     */\n    bool hasValidRange(std::string const& itemName) const;\n\n    /*!\n     *  Check if the selected address block has a valid width.\n     *\n     *    @param [in] itemName    Name of the selected address block.\n     *\n     *    @return True, if the width is valid, false otherwise.\n     */\n    bool hasValidWidth(std::string const& itemName) const;\n\n    /*!\n     *  Check if the selected address block has a valid usage.\n     *\n     *    @param [in] itemName    Name of the selected address block.\n     *\n     *    @return True, if the usage is valid, false otherwise.\n     */\n    bool hasValidUsage(std::string const& itemName) const;\n\n    /*!\n     *  Add a new address block.\n     *\n     *    @param [in] row             Row of the new address block.\n     *    @param [in] newBlockName    Name of the new address block.\n     */\n    virtual void addBlock(int const& row, std::string const& newBlockName = std::string(\"\")) final;\n\n    /*!\n     *  Get the expressions in the selected items.\n     *\n     *    @param [in] itemNames   Names of the selected items.\n     *\n     *    @return The expressions of the selected items.\n     */\n    virtual std::vector<std::string> getExpressionsInSelectedItems(std::vector<std::string> const& itemNames) const final;\n\n    /*!\n     *  Get the sub interface.\n     *\n     *    @return Interface for accessing registers.\n     */\n    RegisterInterface* getSubInterface() const;\n\n    /*!\n     *  Check if the selected address block contains registers.\n     *\n     *    @param [in] blockName   Name of the selected address block.\n     *\n     *    @return True, if the address block contains registers, false otherwise.\n     */\n    bool hasRegisters(std::string const& blockName) const;\n\n    /*!\n     *\tGet the number of access policies an address block has.\n     *  \n     *    @param [in] blockName     Name of the selected address block.\n     *\t    \n     * \t    @return The number of access policies of the selected address block.\n     */\n    int getAccessPolicyCount(std::string const& blockName) const;\n\n    /*!\n     *\tAdd a new access policy to an address block.\n     *  \n     *    @param [in] blockName     Name of the selected address block.\n     * \n     *    @return True, if the operation was successful, otherwise false.\n     */\n    bool addAccessPolicy(std::string const& blockName) const;\n\n\nprivate:\n\n    /*!\n     *  Get the selected address block.\n     *\n     *    @param [in] blockName   Name of the selected address block.\n     *\n     *    @return The selected address block.\n     */\n    QSharedPointer<AddressBlock> getAddressBlock(std::string const& itemName) const;\n\n    /*!\n     *  Get the default name for an address block.\n     *\n     *    @return Default name for an address block.\n     */\n    virtual std::string getDefaultName() const final;\n\n    /*!\n     *  Get a list of the copied address blocks.\n     *\n     *    @param [in] selectedRows    Rows of the copied address blocks.\n     *\n     *    @return List of the copied memory blocks.\n     */\n    virtual QList<QSharedPointer<MemoryBlockBase> > getCopiedBlocks(std::vector<int> const& selectedRows) const final;\n\n    /*!\n     *  Get the mime type of the address block.\n     *\n     *    @return The mime type of the address block.\n     */\n    virtual QString getMimeType() const override final;\n\n    /*!\n     *  Create a copy of the selected address block.\n     *\n     *    @param [in] copiedItem  The selected address block-\n     *\n     *    @return Copy of the selected address block.\n     */\n    virtual QSharedPointer<MemoryBlockBase> createCopyBlock(QSharedPointer<MemoryBlockBase> copiedItem) const final;\n\n    /*!\n     *  Count the address block items in the selected list.\n     *\n     *    @param [in] itemList    List of address block items.\n     *\n     *    @return Number of address block items in the selected list.\n     */\n    virtual int countItems(QList<QSharedPointer<MemoryBlockBase> > itemList) const final;\n\n    /*!\n     *  Get the address block validator.\n     *\n     *    @return The address block validator.\n     */\n    virtual QSharedPointer<MemoryBlockValidator> getValidator() const final;\n\n    /*!\n     *  Get the address block with the selected name, sliced to a NameGroup.\n     *\n     *    @param [in] itemName    Name of the selected address block.\n     *\n     *    @return The sliced address block with the selected name.\n     */\n    QSharedPointer<NameGroup> getItem(std::string const& itemName) const override;\n\n    //-----------------------------------------------------------------------------\n    // Data.\n    //-----------------------------------------------------------------------------\n\n    //! Validator for registers.\n    QSharedPointer<AddressBlockValidator> validator_;\n\n    //! Interface for accessing registers.\n    RegisterInterface* subInterface_;\n};\n\n#endif // ADDRESSBLOCKINTERFACE_H\n"
  },
  {
    "path": "KactusAPI/include/AddressSpaceExpressionsGatherer.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: AddressSpaceExpressionsGatherer.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Mikko Teuho\r\n// Date: 29.04.2015\r\n//\r\n// Description:\r\n// Gathers expressions from an address space and its memory maps.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef ADDRESSSPACEEXPRESSIONGATHERER_H\r\n#define ADDRESSSPACEEXPRESSIONGATHERER_H\r\n\r\n#include <QSharedPointer>\r\n#include <QStringList>\r\n\r\n#include <KactusAPI/KactusAPIGlobal.h>\r\n\r\nclass AddressSpace;\r\nclass Segment;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Gathers expressions from an address space and its memory maps.\r\n//-----------------------------------------------------------------------------\r\nclass KACTUS2_API AddressSpaceExpressionGatherer\r\n{\r\n\r\npublic:\r\n\r\n    /*!\r\n     *  The constructor.\r\n     */\r\n    AddressSpaceExpressionGatherer();\r\n\r\n    /*!\r\n     *  The destructor.\r\n     */\r\n    virtual ~AddressSpaceExpressionGatherer();\r\n\r\n    /*!\r\n     *  Get the expressions from a given address space.\r\n     *\r\n     *    @param [in] addressSpace    The given address space.\r\n     *\r\n     *    @return A list containing all the expressions used in an address space.\r\n     */\r\n    QStringList getExpressions(QSharedPointer<AddressSpace> addressSpace) const;\r\n\r\nprivate:\r\n\t\r\n    /*!\r\n     *  Get the expressions from segments.\r\n     *\r\n     *    @param [in] segmentList     A list of the selected segments.\r\n     *\r\n     *    @return A list of expressions contained within the segments.\r\n     */\r\n    QStringList getExpressionsFromSegments(QSharedPointer<QList<QSharedPointer<Segment> > > segmentList) const;\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n\t//! No copying.\r\n    AddressSpaceExpressionGatherer(const AddressSpaceExpressionGatherer& other);\r\n\r\n\t//! No assignment.\r\n    AddressSpaceExpressionGatherer& operator=(const AddressSpaceExpressionGatherer& other);\r\n};\r\n\r\n#endif // ADDRESSSPACEEXPRESSIONGATHERER_H\r\n"
  },
  {
    "path": "KactusAPI/include/BusInterfaceInterface.h",
    "content": "//-----------------------------------------------------------------------------\n// File: BusInterfaceInterface.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 17.02.2021\n//\n// Description:\n// Interface for accessing bus interfaces.\n//-----------------------------------------------------------------------------\n\n#ifndef BUSINTERFACEINTERFACE_H\n#define BUSINTERFACEINTERFACE_H\n\n#include <NameGroupInterface.h>\n#include <ParameterizableInterface.h>\n\n#include <IPXACTmodels/generaldeclarations.h>\n#include <IPXACTmodels/common/ConfigurableVLNVReference.h>\n#include <IPXACTmodels/common/Document.h>\n#include <IPXACTmodels/Component/BusInterface.h>\n\n#include <QSharedPointer>\n\nclass Component;\nclass InitiatorInterface;\nclass TargetInterface;\nclass MirroredTargetInterface;\nclass TransparentBridge;\nclass BusInterfaceValidator;\nclass TransparentBridgeInterface;\nclass FileSetInterface;\nclass MemoryMapInterface;\nclass AbstractionTypeInterface;\nclass ParametersInterface;\n\n//-----------------------------------------------------------------------------\n//! Interface for accessing bus interfaces.\n//-----------------------------------------------------------------------------\nclass KACTUS2_API BusInterfaceInterface : public ParameterizableInterface, public NameGroupInterface\n{\npublic:\n\n    /*!\n     *  The constructor.\n     *\n     *    @param [in] busValidator                Validator for bus interfaces.\n     *    @param [in] expressionParser            Parser for expressions.\n     *    @param [in] expressionFormatter         Formatter for expressions.\n     */\n    BusInterfaceInterface(QSharedPointer<BusInterfaceValidator> busValidator,\n        QSharedPointer<ExpressionParser> expressionParser,\n        QSharedPointer<ExpressionFormatter> expressionFormatter);\n\n    /*!\n     *  The destructor.\n     */\n    virtual ~BusInterfaceInterface() = default;\n\n    /*!\n     *  Set a new file set interface.\n     *\n     *    @param [in] newFileSetInterface     The new file set interface.\n     */\n    void setFileSetInterface(FileSetInterface* newFileSetInterface);\n    \n    /*!\n     *  Set a new memory map interface.\n     *\n     *    @param [in] newMapInterface     The new memory map interface.\n     */\n    void setMemoryMapInterface(MemoryMapInterface* newMapInterface);\n    \n    /*!\n     *  Set a new abstraction type interface.\n     *\n     *    @param [in] newAbstractionTypeInterface     The new abstraction type interface.\n     */\n    void setAbstractionTypeInterface(AbstractionTypeInterface* newAbstractionTypeInterface);\n    \n    /*!\n     *  Set a new transparent bridge interface.\n     *\n     *    @param [in] newBridgeInterface  The new transparent bridge interface.\n     */\n    void setTransparentBridgeInterface(TransparentBridgeInterface* newBridgeInterface);\n    \n    /*!\n     *  Set a new parameter interface.\n     *\n     *    @param [in] newParameterInterface     The new parameter interface.\n     */\n    void setParameterInterface(ParametersInterface* newParameterInterface);\n\n    /*!\n     *  Setup the bus interfaces.\n     *\n     *    @param [in] newComponent    Component containing the bus interfaces.\n     */\n    void setBusInterfaces(QSharedPointer<Component> newComponent);\n\n    /*!\n     *  Setup the sub interfaces for the selected bus interface.\n     *\n     *    @param [in] busName     Name of the selected bus interface.\n     */\n    void setupSubInterfaces(std::string const& busName);\n\n    /*!\n     *  Get index of the selected bus interface.\n     *\n     *    @param [in] itemName    Name of the selected bus interface.\n     *\n     *    @return Index of the selected bus interface.\n     */\n    virtual int getItemIndex(std::string const& itemName) const override final;\n\n    /*!\n     *  Get name of the indexed bus interface.\n     *\n     *    @param [in] itemIndex   Index of the selected bus interface.\n     *\n     *    @return Name of the selected bus interface.\n     */\n    std::string getIndexedItemName(int itemIndex) const final;\n\n    /*!\n     *  Get the number of available bus interfaces.\n     *\n     *    @return Number of available bus interfaces.\n     */\n    virtual int itemCount() const override final;\n\n    /*!\n     *  Get the names of the available bus interfaces.\n     *\n     *    @return Names of the available bus interfaces.\n     */\n    virtual std::vector<std::string> getItemNames() const override final;\n\n    /*!\n     *  Set a new name for the selected bus interface.\n     *\n     *    @param [in] currentName     Name of the selected bus interface.\n     *    @param [in] newName         New name for the bus interface.\n     *\n     *    @return True, if successful, false otherwise.\n     */\n    virtual bool setName(std::string const& currentName, std::string const& newName) override final;\n\n    /*!\n     *  Validates the contained bus interfaces.\n     *\n     *    @return True, if all the bus interfaces are valid, false otherwise.\n     */\n    virtual bool validateItems() const override final;\n\n    /*!\n     *  Validate the selected bus interface.\n     *\n     *    @param [in] busName     Name of the selected bus interface.\n     *\n     *    @return True, if the bus interface is valid, false otherwise.\n     */\n    bool validateBusInterface(std::string const& busName) const;\n\n    /*!\n     *  Check if the selected bus interface has a valid name.\n     *\n     *    @param [in] itemName    Name of the selected bus interface.\n     *\n     *    @return True, if the name is valid, false otherwise.\n     */\n    virtual bool itemHasValidName(std::string const& itemName) const override final;\n\n    /*!\n     *  Check if the selected bus interface has a valid bus type.\n     *\n     *    @param [in] busName     Name of the selected bus interface.\n     *\n     *    @return True, if the bus type is valid, false otherwise.\n     */\n    bool hasValidBusType(std::string const& busName) const;\n\n    /*!\n     *  Check if the selected bus interface has valid abstraction types.\n     *\n     *    @param [in] busName     Name of the selected bus interface.\n     *\n     *    @return True, if the abstraction types is valid, false otherwise.\n     */\n    bool hasValidAbstractionTypes(std::string const& busName) const;\n\n    /*!\n     *  Get the interface mode of the selected bus interface.\n     *\n     *    @param [in] busName     Name of the selected bus interface.\n     *\n     *    @return Interface mode of the selected bus interface.\n     */\n    General::InterfaceMode getMode(std::string const& busName) const;\n\n    /*!\n     *  Get the active / monitored bus interface mode of the selected bus interface.\n     *\n     *    @param [in] busName     Name of the selected bus interface.\n     *\n     *    @return Active / monitored bus interface mode of the seleced bus interface.\n     */\n    General::InterfaceMode getActiveMode(std::string const& busName) const;\n\n\n    /*!\n     *  Get the interface mode of the selected bus interface in string form.\n     *\n     *    @param [in] busName     Name of the selected bus interface.\n     *\n     *    @return Interface mode string of the selected bus interface.\n     */\n    std::string getModeString(std::string const& busName) const;\n\n    /*!\n     *  Set the interface mode for the selected bus interface.\n     *\n     *    @param [in] busName     Name of the selected bus interface.\n     *    @param [in] newMode     The new interface mode.\n     *\n     *    @return True, if successful, false otherwise.\n     */\n    bool setMode(std::string const& busName, std::string const& newMode);\n\n    /*!\n     *  Get the system group of the selected bus interface.\n     *\n     *    @param [in] busName     Name of the selected bus interface.\n     *\n     *    @return System group of the selected bus interface.\n     */\n    std::string getSystemGroup(std::string const& busName) const;\n\n    /*!\n     *  Get the active / monitored system group of the selected bus interface.\n     *\n     *    @param [in] busName     Name of the selected bus interface.\n     *\n     *    @return Active / monitored system group of the seleced bus interface.\n     */\n    QString getActiveSystemGroup(std::string const& busName) const;\n\n    /*!\n     *  Set the system group for the selected bus interface.\n     *\n     *    @param [in] busName     Name of the selected bus interface.\n     *    @param [in] newSystem   The new system group.\n     *\n     *    @return True, if successful, false otherwise.\n     */\n    bool setSystemGroup(std::string const& busName, std::string const& newSystem);\n\n    /*!\n     *  Get the connection required value of the selected bus interface.\n     *\n     *    @param [in] busName     Name of the selected bus interface.\n     *\n     *    @return The connection required value of the selected bus interface.\n     */\n    std::string connectionIsRequired(std::string const& busName) const;\n\n    /*!\n     *  Set the connection required value for the selected bus interface.\n     *\n     *    @param [in] busName     Name of the selected bus interface.\n     *    @param [in] newValue    New connection required value.\n     *\n     *    @return True, if successful, false otherwise.\n     */\n    bool setConnectionIsRequired(std::string const& busName, bool newValue);\n\n    /*!\n     *  Get the bits in lau value of the selected bus interface.\n     *\n     *    @param [in] busName     Name of the selected bus interface.\n     *\n     *    @return Bits in lau value of the selected bus interface.\n     */\n    std::string getBitsInLau(std::string const& busName) const;\n\n    /*!\n     *  Set the bits in value for the selected bus interface.\n     *\n     *    @param [in] busName     Name of the selected bus interface.\n     *    @param [in] newBits     New bits in lau value.\n     *\n     *    @return True, if successful, false otherwise.\n     */\n    bool setBitsInLau(std::string const& busName, std::string const& newBits);\n\n    /*!\n     *  Get the endianness of the selected bus interface.\n     *\n     *    @param [in] busName     Name of the selected bus interface.\n     *\n     *    @return BIG, LITTLE or UNSPECIFIED.\n     */\n    BusInterface::Endianness getEndianness(std::string const& busName) const;\n\n    /*!\n     *  Set the endianness of the selected bus interface.\n     *\n     *    @param [in] busName         Name of the selected bus interface.\n     *    @param [in] newEndianness   New endianness value.\n     *\n     *    @return True, if successful, false otherwise.\n     */\n    bool setEndianness(std::string const& busName, std::string const& newEndianness);\n\n    /*!\n     *  Get the bit steering value of the selected bus interface.\n\t *\n     *    @param [in] busName     Name of the selected bus interface.\n     *\n\t *    @return The bit steering of the selected bus interface.\n\t */\n\tstd::string getBitSteering(std::string const& busName) const;\n\n    /*!\n     *  Set the bit steering value for the selected bus interface.\n     *\n     *    @param [in] busName         Name of the selected bus interface.\n     *    @param [in] newBitSteering  New bit steering value.\n     *\n     *    @return True, if successful, false otherwise.\n     */\n    bool setBitSteering(std::string const& busName, std::string const& newBitSteering);\n\n    /*!\n     *  Get the address space reference of the selected bus interface.\n     *\n     *    @param [in] busName     Name of the selected bus interface.\n     *\n     *    @return Address space reference of the selected bus interface.\n     */\n    std::string getAddressSpaceReference(std::string const& busName) const;\n    \n    /*!\n     *  Set a new address space reference for the selected bus interface.\n     *\n     *    @param [in] busName     Name of the selected bus interface.\n     *    @param [in] newSpace    New address space reference.\n     *\n     *    @return True, if successful, false otherwise.\n     */\n    bool setAddressSpaceReference(std::string const& busName, std::string const& newSpace);\n\n    /*!\n     *  Get the calculated base address value of the selected bus interface.\n     *\n     *    @param [in] busName     Name of the selected bus interface.\n     *    @param [in] baseNumber  Base for displaying the value.\n     *\n     *    @return Calculated base address value of the selected bus interface.\n     */\n    std::string getBaseAddressValue(std::string const& busName, int const& baseNumber = 0) const;\n\n    /*!\n     *  Get the formatted base address expression of the selected bus interface.\n     *\n     *    @param [in] busName     Name of the selected bus interface.\n     *\n     *    @return Formatted base address expression of the selected bus interface.\n     */\n    std::string getBaseAddressFormattedExpression(std::string const& busName) const;\n\n    /*!\n     *  Get the base address expression of the selected bus interface.\n     *\n     *    @param [in] busName     Name of the selected bus interface.\n     *\n     *    @return Base address expression of the selected bus interface.\n     */\n    std::string getBaseAddressExpression(std::string const& busName) const;\n\n    /*!\n     *  Set the base address for the selected bus interface.\n     *\n     *    @param [in] busName         Name of the selected bus interface.\n     *    @param [in] newBaseAddress  New base address.\n     *\n     *    @return True, if successful, false otherwise.\n     */\n    bool setBaseAddress(std::string const& busName, std::string const& newBaseAddress);\n\n    /*!\n     *  Get the memory map reference of the selected bus interface.\n     *\n     *    @param [in] busName     Name of the selected bus interface.\n     *\n     *    @return Memory map reference of the selected bus interface.\n     */\n    std::string getMemoryMapReference(std::string const& busName) const;\n\n    /*!\n     *  Set a new memory map reference for the selected bus interface.\n     *\n     *    @param [in] busName             Name of the selected bus interface.\n     *    @param [in] newMapReference     New memory map reference.\n     *\n     *    @return True, if successful, false otherwise.\n     */\n    bool setMemoryMapReference(std::string const& busName, std::string const& newMapReference);\n\n    /*!\n     *  Get the file set references of the selected bus interface.\n     *\n     *    @param [in] busName     Name of the selected bus interface.\n     *\n     *    @return File set references of the selected bus interface.\n     */\n    std::vector<std::string> getFileSetReferences(std::string const& busName) const;\n\n    /*!\n     *  Set the file set references for the selected bus interface.\n     *\n     *    @param [in] busName                 Name of the selected bus interface.\n     *    @param [in] newFileSetReferences    New file set references.\n     *\n     *    @return True, if successful, false otherwise.\n     */\n    bool setFileSetReferences(std::string const& busName, std::vector<std::string>  const& newFileSetReferences);\n\n    /*!\n     *  Get the bus type of the selected bus interface.\n     *\n     *    @param [in] busName     Name of the selected bus interface.\n     *\n     *    @return Bus type of the selected bus interface.\n     */\n    ConfigurableVLNVReference getBusType(std::string const& busName) const;\n\n    /*!\n     *  Get the bus type of the selected bus interface as a string.\n     *\n     *    @param [in] busName     Name of the selected bus interface.\n     *\n     *    @return Bus type of the selected bus interface in string format.\n     */\n    std::string getBusTypeString(std::string const& busName) const;\n\n    /*!\n     *  Set the bus type of the selected bus interface.\n     *\n     *    @param [in] busName     Name of the selected bus interface.\n     *    @param [in] newVLNV     New bus type VLNV.\n     *\n     *    @return True, if successful, false otherwise.\n     */\n    bool setBustype(std::string const& busName, ConfigurableVLNVReference const& newVLNV);\n\n    /*!\n     *  Set the bus type for the selected bus interface.\n     *\n     *    @param [in] busName     Name of the selected bus interface.\n     *    @param [in] newVendor   Vendor of the new bus type.\n     *    @param [in] newLibrary  Library of the new bus type.\n     *    @param [in] newName     Name of the new bus type.\n     *    @param [in] newVersion  Version of the new bus type.\n     *\n     *    @return True, if successful, false otherwise.\n     */\n    bool setBustype(std::string const& busName, std::string const& newVendor, std::string const& newLibrary,\n        std::string const& newName, std::string const& newVersion) const;\n\n    /*!\n     *  Get the abstraction reference string of the selected bus interface.\n     *\n     *    @param [in] busName     Name of the selected bus interface.\n     *\n     *    @return Abstraction reference if only a single abstraction type exists, otherwise [multiple].\n     */\n    std::string getAbstractionReferenceString(std::string const& busName) const;\n\n    /*!\n     *  Get the list of abstraction references of the selected bus interface.\n     *\n     *    @param [in] busName     Name of the selected bus interface.\n     *\n     *    @return String list of the abstraction references.\n     */\n    std::vector<std::string> getAbstractionReferences(std::string const& busName) const;\n\n    /*!\n     *  Add a new abstraction type to the selected bus interface.\n     *\n     *    @param [in] busName     Name of the selected bus interface.\n     *    @param [in] newVendor   Vendor of the new abstraction type.\n     *    @param [in] newLibrary  Library of the new abstraction type.\n     *    @param [in] newName     Name of the new abstraction  type.\n     *    @param [in] newVersion  Version of the new abstraction type.\n     *\n     *    @return True, if successful, false otherwise.\n     */\n    bool addAbstractionType(std::string const& busName, std::string const& newVendor,\n        std::string const& newLibrary, std::string const& newName, std::string const& newVersion) const;\n\n    /*!\n     *  Remove all the abstraction types from the selected bus interface.\n     *\n     *    @param [in] busName     Name of the selected bus interface.\n     *\n     *    @return True, if successfull, false otherwise.\n     */\n    bool removeAbstractionTypes(std::string const& busName);\n\n    /*!\n     *  Get the calculated range value of the selected bus interface.\n     *\n     *    @param [in] busName     Name of the selected bus interface.\n     *    @param [in] baseNumber  Base for displaying the value.\n     *\n     *    @return Calculated range value of the selected bus interface.\n     */\n    std::string getRangeValue(std::string const& busName, int const& baseNumber = 0) const;\n\n    /*!\n     *  Get the formatted range expression of the selected bus interface.\n     *\n     *    @param [in] busName     Name of the selected bus interface.\n     *\n     *    @return Formatted range expression of the selected bus interface.\n     */\n    std::string getRangeFormattedExpression(std::string const& busName) const;\n\n    /*!\n     *  Get the range expression of the selected bus interface.\n     *\n     *    @param [in] busName     Name of the selected bus interface.\n     *\n     *    @return Range expression of the selected bus interface.\n     */\n    std::string getRangeExpression(std::string const& busName) const;\n\n    /*!\n     *  Set the range for the selected bus interface.\n     *\n     *    @param [in] busName     Name of the selected bus interface.\n     *    @param [in] newRange    New range value.\n     *\n     *    @return True, if successful, false otherwise.\n     */\n    bool setRange(std::string const& busName, std::string const& newRange);\n\n    /*!\n     *  Get the calculated remap address value of the selected bus interface.\n     *\n     *    @param [in] busName     Name of the selected bus interface.\n     *    @param [in] baseNumber  Base for displaying the value.\n     *\n     *    @return Calculated remap address value of the selected bus interface.\n     */\n    std::string getRemapAddressValue(std::string const& busName, int const& baseNumber = 0) const;\n\n    /*!\n     *  Get the formatted remap address expression of the selected bus interface.\n     *\n     *    @param [in] busName     Name of the selected bus interface.\n     *\n     *    @return Formatted remap address expression of the selected bus interface.\n     */\n    std::string getRemapAddressFormattedExpression(std::string const& busName) const;\n\n    /*!\n     *  Get the remap address expression of the selected bus interface.\n     *\n     *    @param [in] busName     Name of the selected bus interface.\n     *\n     *    @return Remap address expression of the selected bus interface.\n     */\n    std::string getRemapAddressExpression(std::string const& busName) const;\n\n    /*!\n     *  Set the remap address for the selected bus interface.\n     *\n     *    @param [in] busName             Name of the selected bus interface.\n     *    @param [in] newRemapAddress     New remap address value.\n     *\n     *    @return True, if successful, false otherwise.\n     */\n    bool setRemapAddress(std::string const& busName, std::string const& newRemapAddress);\n\n    /*!\n     *  Get the monitor interface mode of the selected bus interface.\n     *\n     *    @param [in] busName     Name of the selected bus interface.\n     *\n     *    @return Monitor interface mode of the selected bus interface.\n     */\n    General::InterfaceMode getMonitorMode(std::string const& busName) const;\n\n    /*!\n     *  Set the monitor interface mode for the selected bus interface.\n     *\n     *    @param [in] busName     Name of the selected bus interface.\n     *    @param [in] newMode     New monitor interface mode.\n     *\n     *    @return True, if successful, false otherwise.\n     */\n    bool setMonitorMode(std::string const& busName, std::string const& newMode);\n\n    /*!\n     *  Get the monitor system group of the selected bus interface.\n     *\n     *    @param [in] busName     Name of the selected bus interface.\n     *\n     *    @return Monitor system group of the selected bus interface.\n     */\n    std::string getMonitorGroup(std::string const& busName) const;\n\n    /*!\n     *  Set the monitor system group for the selected bus interface.\n     *\n     *    @param [in] busName     Name of the selected bus interface.\n     *    @param [in] newGroup    New monitor system group.\n     *\n     *    @return True, if successful, false otherwise.\n     */\n    bool setMonitorGroup(std::string const& busName, std::string const& newGroup);\n\n    /*!\n     *  Add a new bus interface, insert at specific position given by newBusIndex.\n     *\n     *    @param [in] newBusIndex     Index of the new bus interface.\n     *    @param [in] busName         Name of the new bus interface.\n     */\n    void addBusInterface(int const& newBusIndex, std::string const& busName = \"\");\n    \n    /*!\n     *  Add a new bus interface.\n     *  This overload should be preferred when using Python.\n     *\n     *    @param [in] busName         Name of the new bus interface.\n     */\n    void addBusInterface(std::string const& busName = \"\");\n\n    /*!\n     *  Swap the selected bus interfaces.\n     *\n     *    @param [in] firstIndex      Index of the first bus interface.\n     *    @param [in] secondIndex     Index of the second bus interface.\n     */\n    void swapBusInterfaces(int const& firstIndex, int const& secondIndex);\n\n    /*!\n     *  Remove the selected bus interface.\n     *\n     *    @param [in] busName     Name of the selected bus interface.\n     *\n     *    @return True, if successful, false otherwise.\n     */\n    bool removeBusInterface(std::string const& busName);\n\n    /*!\n     *  Check if the selected bus interface exists.\n     *\n     *    @param [in] busName     Name of the selected bus interface.\n     *\n     *    @return True, if the bus interface exists, false otherwise.\n     */\n    bool busInterfaceExists(std::string const& busName) const;\n\n    /*!\n     *  Get the interface for accessing transparent bridges.\n     *\n     *    @return Interface for accessing transparent bridges.\n     */\n    TransparentBridgeInterface* getBridgeInterface();\n\n    /*!\n     *  Get the interface for accessing file sets.\n     *\n     *    @return Interface for accessing file sets.\n     */\n    FileSetInterface* getFileSetInterface() const;\n\n    /*!\n     *  Get the interface for accessing memory maps.\n     *\n     *    @return Interface for accessing memory maps.\n     */\n    MemoryMapInterface* getMemoryMapInterface() const;\n\n    /*!\n     *  Get the interface for accessing abstraction types.\n     *\n     *    @return Interface for accessing abstraction types.\n     */\n    AbstractionTypeInterface* getAbstractionTypeInterface() const;\n\n    /*!\n     *  Get the validator for bus interfaces.\n     *\n     *    @return Validator for bus interfaces.\n     */\n    QSharedPointer<BusInterfaceValidator> getValidator() const;\n\n    /*!\n     *  Get the transparent bridges of the selected bus interface.\n     *\n     *    @param [in] busName     Name of the selected bus interface.\n     *\n     *    @return Transparent bridges of the selected bus interface.\n     */\n    QSharedPointer<QList<QSharedPointer<TransparentBridge> > > getBridges(std::string const& busName) const;\n\n    /*!\n     *  Create or get existing transparent bridges pointer of the selected bus interface.\n     *\n     *    @param [in] busName     Name of the selected bus interface.\n     *\n     *    @return Pointer to the transparent bridges of the selected bus interface.\n     */\n    QSharedPointer<QList<QSharedPointer<TransparentBridge> > > createBridges(std::string const& busName);\n\n    /*!\n     *  Get all the references made to the selected parameter in the selected bus interface.\n     *\n     *    @param [in] itemName    Name of the selected bus interface.\n     *    @param [in] valueID     ID of the target parameter.\n     *\n     *    @return Number of references made to the given parameter in the selected bus interface.\n     */\n    virtual int getAllReferencesToIdInItem(const std::string& itemName, std::string const&  valueID) const\n        override;\n\n    /*!\n     *  Get all the expressions in the selected bus interface.\n     *\n     *    @param [in] busName     Name of the selected bus interface.\n     *\n     *    @return List of the expressions in the selected bus interface.\n     */\n    std::vector<std::string> getAllExpressions(std::string const& busName) const;\n\n    /*!\n     *  Copy the selected bus interfaces.\n     *\n     *    @param [in] selectedRows    Indexes of the selected bus interfaces.\n     */\n    void copyRows(std::vector<int> selectedRows);\n\n    /*!\n     *  Paste the selected bus interfaces.\n     *\n     *    @return Names of the pasted bus interfaces.\n     */\n    std::vector<std::string> pasteRows();\n\n    /*!\n     *  Get the number of pasted bus interfaces.\n     *\n     *    @return Number of the pasted bus interfaces.\n     */\n    int getPasteRowCount() const;\n\n    //! No copying. No assignment.\n    BusInterfaceInterface(const BusInterfaceInterface& other) = delete;\n    BusInterfaceInterface& operator=(const BusInterfaceInterface& other) = delete;\n\nprivate:\n\n    /*!\n     *  Get the selected bus interface.\n     *\n     *    @param [in] busName     Name of the selected bus interface.\n     *\n     *    @return The selected bus interface.\n     */\n    QSharedPointer<BusInterface> getBusInterface(std::string const& busName) const;\n\n    /*!\n     *  Get the bus interface with the selected name, sliced to a NameGroup.\n     *\n     *    @param [in] portName    Name of the selected port.\n     *\n     *    @return The sliced port abstraction with the selected name.\n     */\n    QSharedPointer<NameGroup> getItem(std::string const& busName) const override;\n\n    /*!\n     *  Get the selected master bus interface.\n     *\n     *    @param [in] busName     Name of the containing bus interface.\n     *\n     *    @return The selected master bus interface.\n     */\n    QSharedPointer<InitiatorInterface> getInitiatorInterface(std::string const& busName) const;\n\n    /*!\n     *  Create or get an existing master for the selected bus interface.\n     *\n     *    @param [in] busName     Name of the containing bus interface.\n     *\n     *    @return The selected master bus interface.\n     */\n    QSharedPointer<InitiatorInterface> createInitiatorForBusInterface(std::string const& busName);\n\n    /*!\n     *  Get the selected slave bus interface.\n     *\n     *    @param [in] busName     Name of the containing bus interface.\n     *\n     *    @return The selected slave bus interface.\n     */\n    QSharedPointer<TargetInterface> getTargetInterface(std::string const& busName) const;\n\n    /*!\n     *  Create or get an existing slave for the selected bus interface.\n     *\n     *    @param [in] busName     Name of the containing bus interface.\n     *\n     *    @return The selected slave bus interface.\n     */\n    QSharedPointer<TargetInterface> createTargetForBusInterface(std::string const& busName);\n\n    /*!\n     *  Get the selected mirrored slave bus interface.\n     *\n     *    @param [in] busName     Name of the containing bus interface.\n     *\n     *    @return The selected mirrored slave bus interface.\n     */\n    QSharedPointer<MirroredTargetInterface> getMirroredSlaveInterface(std::string const& busName) const;\n\n    /*!\n     *  Create or get an existing mirrored slave for the selected bus interface.\n     *\n     *    @param [in] busName     Name of the containing bus interface.\n     *\n     *    @return The selected mirrored slave bus interface.\n     */\n    QSharedPointer<MirroredTargetInterface> createMirrorSlaveForBusInterface(std::string const& busName);\n\n    /*!\n     *  Get the selected monitor bus interface.\n     *\n     *    @param [in] busName     Name of the containing bus interface.\n     *\n     *    @return The selected monitor bus interface.\n     */\n    QSharedPointer<BusInterface::MonitorInterface> getMonitorInterface(std::string const& busName) const;\n\n    /*!\n     *  Create or get an existing monitor for the selected bus interface.\n     *\n     *    @param [in] busName     Name of the containing bus interface.\n     *\n     *    @return The selected monitor bus interface.\n     */\n    QSharedPointer<BusInterface::MonitorInterface> createMonitorForBusInterface(std::string const& busName);\n\n    //-----------------------------------------------------------------------------\n    // Data.\n    //-----------------------------------------------------------------------------\n\n    //! The available bus interfaces.\n    QSharedPointer<QList<QSharedPointer<BusInterface> > > busInterfaces_;\n\n    //! Validator for bus interfaces.\n    QSharedPointer<BusInterfaceValidator> busValidator_;\n\n    //! Interface for accessing transparent bridges.\n    TransparentBridgeInterface* bridgeInterface_;\n\n    //! Interface for accessing file sets.\n    FileSetInterface* fileSetInterface_;\n\n    //! Interface for accessing memory maps.\n    MemoryMapInterface* mapInterface_;\n\n    //! Interface for accessing abstraction types\n    AbstractionTypeInterface* abstractionTypeInterface_;\n\n    //! Interface for accessing parameters.\n    ParametersInterface* parameterInterface_;\n\n    //! The IP-XACT standard revision in use.\n    Document::Revision docRevision_ = Document::Revision::Unknown;\n};\n\n#endif // BUSINTERFACEINTERFACE_H\n"
  },
  {
    "path": "KactusAPI/include/BusInterfaceInterfaceFactory.h",
    "content": "//-----------------------------------------------------------------------------\n// File: BusInterfaceInterfaceFactory.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 24.03.2021\n//\n// Description:\n// Constructs the bus interface interface.\n//-----------------------------------------------------------------------------\n\n#ifndef BUSINTERFACEINTERFACEFACTORY_H\n#define BUSINTERFACEINTERFACEFACTORY_H\n\n#include <QSharedPointer>\n\n#include <KactusAPI/KactusAPIGlobal.h>\n\nclass LibraryInterface;\n\nclass Component;\n\nclass ParameterValidator;\nclass PortMapValidator;\n\nclass ParameterFinder;\nclass ExpressionFormatter;\nclass ExpressionParser;\n\nclass BusInterfaceInterface;\nclass AbstractionTypeInterface;\nclass PortMapInterface;\nclass TransparentBridgeInterface;\nclass FileSetInterface;\nclass MemoryMapInterface;\nclass ParametersInterface;\n\n//-----------------------------------------------------------------------------\n//! Constructs the bus interface interface.\n//-----------------------------------------------------------------------------\nnamespace BusInterfaceInterfaceFactory\n{\n    /*!\n     *  Create the interface for accessing bus interfaces.\n     *\n     *    @param [in] parameterFinder         The parameter finder.\n     *    @param [in] expressionFormatter     Formatter for expressions.\n     *    @param [in] expressionParser        Parser for expressions.\n     *    @param [in] component               The containing component.\n     *    @param [in] library                 Interface for accessing the library.\n     *\n     *    @return Interface for accessing bus interfaces.\n     */\n    KACTUS2_API BusInterfaceInterface* createBusInterface(\n        QSharedPointer<ParameterFinder> parameterFinder,\n        QSharedPointer<ExpressionFormatter> expressionFormatter,\n        QSharedPointer<ExpressionParser> expressionParser,\n        QSharedPointer<Component> component,\n        LibraryInterface* library);\n\n    namespace Details\n    {\n        /*!\n         *  Create the common items in an interface for accessing bus interfaces.\n         *\n         *    @param [in] parameterFinder         The parameter finder.\n         *    @param [in] expressionFormatter     Formatter for expressions.\n         *    @param [in] expressionParser        Parser for expressions.\n         *    @param [in] component               The containing component.\n         *    @param [in] library                 Interface for accessing the library.\n         *    @param [in] portMapValidator        Validator for port maps.\n         *    @param [in] abstractionInterface    Interface for accessing abstraction types.\n         *\n         *    @return Interface for accessing bus interfaces.\n         */\n        BusInterfaceInterface* createCommonBusInterfaceItems(\n            QSharedPointer<ParameterFinder> parameterFinder,\n            QSharedPointer<ExpressionFormatter> expressionFormatter,\n            QSharedPointer<ExpressionParser> expressionParser,\n            QSharedPointer<Component> component,\n            LibraryInterface* library,\n            QSharedPointer<PortMapValidator> portMapValidator,\n            AbstractionTypeInterface* abstractionInterface);\n\n        /*!\n         *  Create the interface for accessing file sets.\n         *\n         *    @param [in] parameterFinder         The parameter finder.\n         *    @param [in] expressionFormatter     Formatter for expressions.\n         *    @param [in] expressionParser        Parser for expressions.\n         *    @param [in] component               The containing component.\n         *\n         *    @return Interface for accessing file sets.\n         */\n        FileSetInterface* createFileSetInterface(QSharedPointer<ParameterFinder> parameterFinder,\n            QSharedPointer<ExpressionFormatter> expressionFormatter,\n            QSharedPointer<ExpressionParser> expressionParser,\n            QSharedPointer<Component> component);\n\n        /*!\n         *  Create the interface for accessing memory maps.\n         *\n         *    @param [in] parameterFinder         The parameter finder.\n         *    @param [in] expressionFormatter     Formatter for expressions.\n         *    @param [in] expressionParser        Parser for expressions.\n         *    @param [in] parameterValidator      Validator for parameters.\n         *    @param [in] component               The containing component.\n         *\n         *    @return Interface for accessing memory maps.\n         */\n        MemoryMapInterface* createMapInterface(QSharedPointer<ParameterFinder> parameterFinder,\n            QSharedPointer<ExpressionFormatter> expressionFormatter,\n            QSharedPointer<ExpressionParser> expressionParser,\n            QSharedPointer<ParameterValidator> parameterValidator,\n            QSharedPointer<Component> component);\n\n        /*!\n         *  Create the interface for accessing abstraction types.\n         *\n         *    @param [in] parameterFinder         The parameter finder.\n         *    @param [in] expressionFormatter     Formatter for expressions.\n         *    @param [in] expressionParser        Parser for expressions.\n         *    @param [in] portMapValidator        The VLNV library.\n         *    @param [in] component               The containing component.\n         *    @param [in] library                 Interface for accessing the library.\n         *\n         *    @return Interface for accessing abstraction types.\n         */\n        AbstractionTypeInterface* createAbstractionTypeInterface(\n            QSharedPointer<ParameterFinder> parameterFinder,\n            QSharedPointer<ExpressionFormatter> expressionFormatter,\n            QSharedPointer<ExpressionParser> expressionParser,\n            QSharedPointer<PortMapValidator> portMapValidator,\n            QSharedPointer<Component> component,\n            LibraryInterface* library);\n\n        /*!\n         *  Create the common properties of an abstraction type interface.\n         *\n         *    @param [in] expressionParser    Parser for expressions.\n         *    @param [in] component           The containing component.\n         *    @param [in] portMapValidator    Validator for port maps.\n         *    @param [in] library             The VLNV library.\n         *    @param [in] portMapInterface    Interface for accessing the port maps.\n         *\n         *    @return Interface for accessing the abstraction types.\n         */\n        AbstractionTypeInterface* createCommonAbstractionTypeInterface(\n            QSharedPointer<ExpressionParser> expressionParser,\n            QSharedPointer<Component> component,\n            QSharedPointer<PortMapValidator> portMapValidator,\n            LibraryInterface* library,\n            PortMapInterface* portMapInterface);\n\n        /*!\n         *  Create the interface for accessing port maps.\n         *\n         *    @param [in] parameterFinder         The parameter finder.\n         *    @param [in] expressionFormatter     Formatter for expressions.\n         *    @param [in] expressionParser        Parser for expressions.\n         *    @param [in] portMapValidator        Validator for port maps.\n         *    @param [in] component               The containing component.\n         *\n         *    @return Interface for accessing port maps.\n         */\n        PortMapInterface* createPortMapInterface(\n            QSharedPointer<ParameterFinder> parameterFinder,\n            QSharedPointer<ExpressionFormatter> expressionFormatter,\n            QSharedPointer<ExpressionParser> expressionParser,\n            QSharedPointer<PortMapValidator> portMapValidator,\n            QSharedPointer<Component> component);\n\n        /*!\n         *  Create the interface for accessing transparent bridges.\n         *\n         *    @param [in] expressionFormatter     Formatter for expressions.\n         *    @param [in] expressionParser        Parser for expressions.\n         *\n         *    @return Interface for accessing transparent bridges.\n         */\n        TransparentBridgeInterface* createBridgeInterface(QSharedPointer<ExpressionFormatter> expressionFormatter,\n            QSharedPointer<ExpressionParser> expressionParser);\n\n        /*!\n         *  Create the interface for accessing parameters.\n         *\n         *    @param [in] validator               Validator for parameters.\n         *    @param [in] expressionFormatter     Formatter for expressions.\n         *    @param [in] expressionParser        Parser for expressions.\n         *\n         *    @return The interface for accessing parameters.\n         */\n        ParametersInterface* createParameterInterface(QSharedPointer<ParameterValidator> validator,\n            QSharedPointer<ExpressionParser> expressionParser,\n            QSharedPointer<ExpressionFormatter> expressionFormatter);\n\n    };\n}\n\n#endif /* BUSINTERFACEINTERFACEFACTORY_H */\n"
  },
  {
    "path": "KactusAPI/include/BusInterfaceUtilities.h",
    "content": "//-----------------------------------------------------------------------------\n// File: BusInterfaceUtilities.h\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Mikko Teuho\n// Date: 15.02.2019\n//\n// Description:\n// Utilities for bus interface mode compatibilities.\n//-----------------------------------------------------------------------------\n\n#ifndef BUSINTERFACECOMPATIBILITIES_H\n#define BUSINTERFACECOMPATIBILITIES_H\n\n#include <KactusAPI/KactusAPIGlobal.h>\n\n#include <QSharedPointer>\n\n#include <IPXACTmodels/generaldeclarations.h>\n\n\nclass BusDefinition;\nclass VLNV;\nclass LibraryInterface;\n\n//-----------------------------------------------------------------------------\n//! Utilities for bus interface mode compatibilities.\n//-----------------------------------------------------------------------------\nnamespace BusInterfaceUtilities\n{\n    /*!\n     *  Checks if the selected bus definitions match.\n     *\n     *    @param [in] firstDefinition         The first bus definition.\n     *    @param [in] secondDefinitionVLNV    VLNV of the second bus definition.\n     *\n     *    @return True, if the bus definitions match, false otherwise.\n     */\n    KACTUS2_API bool hasMatchingBusDefinitions(QSharedPointer<const BusDefinition> firstDefinition,\n        VLNV const& secondDefinitionVLNV, LibraryInterface* library);\n\n    /*!\n     *  Check if the selected bus definition VLNVs can be connected.\n     *\n     *    @param [in] firstDefinitionVLNV     The first VLNV.\n     *    @param [in] secondDefinitionVLNV    The second VLNV.\n     *    @param [in] library                 Access to the library.\n     *\n     *    @return True, if the selected bus definition VLNVs can be connected, false otherwise.\n     */\n    KACTUS2_API bool busDefinitionVLNVsMatch(VLNV const& firstDefinitionVLNV, VLNV const& secondDefinitionVLNV,\n        LibraryInterface* library);\n\n    /*!\n     *  Get the path for the icon of the bus interface mode.\n     *\n     *    @param [in] busMode     The selected bus interface mode.\n     *\n     *    @return Path for the bus interface mode icon.\n     */\n    KACTUS2_API QString getIconPath(General::InterfaceMode busMode);\n}\n\n//-----------------------------------------------------------------------------\n\n#endif // BUSINTERFACECOMPATIBILITIES_H\n"
  },
  {
    "path": "KactusAPI/include/CLIGenerator.h",
    "content": "//-----------------------------------------------------------------------------\n// File: CLIGenerator.h\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Esko Pekkarinen\n// Date: 05.02.2018\n//\n// Description:\n// Interface for enabling plugin run using the command line arguments.\n//-----------------------------------------------------------------------------\n\n#ifndef CLI_GENERATOR_H\n#define CLI_GENERATOR_H\n\n#include <QString>\n#include <QStringList>\n#include <QList>\n#include <QSharedPointer>\n\nclass IPluginUtility;\nclass Component;\nclass Design;\nclass DesignConfiguration;\n\n//-----------------------------------------------------------------------------\n//! Interface for enabling plugin run using the command line arguments.\n//-----------------------------------------------------------------------------\nclass CLIGenerator \n{\npublic:\n\n\t//! The destructor.\n    virtual ~CLIGenerator() {};\n\n    /*!\n     *  Gets the output format generated by the plugin.\n     *\n     *    @return The output file format generated by the plugin.\n     */\n    virtual QString getOutputFormat() const = 0;\n\n    /*!\n     * Runs the generation.\n     *\n     *    @param [in] utility              Utilities for enabling plugin execution.\n     *    @param [in] component            The component to run the generation for.\n     *    @param [in] design               The design to run the generation for.\n     *    @param [in] designConfiguration  The design configuration to run the generation for.\n     *    @param [in] viewName             The component view name to run the generation for.\n     *    @param [in] outputDirectory      The output directory for the generation results.\n     */\n     virtual void runGenerator(IPluginUtility* utility,\n        QSharedPointer<Component> component,\n        QSharedPointer<Design> design,\n        QSharedPointer<DesignConfiguration> designConfiguration,\n        QString const& viewName,\n        QString const& outputDirectory) = 0;\n};\n\n#endif // CLI_GENERATOR_H\n"
  },
  {
    "path": "KactusAPI/include/CommonInterface.h",
    "content": "//-----------------------------------------------------------------------------\n// File: CommonInterface.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 21.04.2020\n//\n// Description:\n// Common functions for interfaces.\n//-----------------------------------------------------------------------------\n\n#ifndef COMMONINTERFACE_H\n#define COMMONINTERFACE_H\n\n#include <KactusAPI/KactusAPIGlobal.h>\n\n#include <string>\n#include <vector>\n#include <QString>\n\n//-----------------------------------------------------------------------------\n//! Common functions for interfaces.\n//-----------------------------------------------------------------------------\nclass KACTUS2_API CommonInterface\n{\npublic:\n\n    /*!\n     *  The constructor.\n     */\n    CommonInterface() = default;\n\n\t/*!\n     *  The destructor.\n     */\n    virtual ~CommonInterface() = default;\n\n    /*!\n     *  Get the names of the available items.\n     *\n     *    @return Names of the available items.\n     */\n    virtual std::vector<std::string> getItemNames() const = 0;\n\n    /*!\n     *  Get the number of available items.\n     *\n     *    @return Number of available items.\n     */\n    virtual int itemCount() const = 0;\n\n    /*!\n     *  Validates the contained items.\n     *\n     *    @return True, if all the items are valid, false otherwise.\n     */\n    virtual bool validateItems() const = 0;\n\n    //! No copying. No assignment.\n    CommonInterface(const CommonInterface& other) = delete;\n    CommonInterface& operator=(const CommonInterface& other) = delete;\n\nprotected:\n\n    /*!\n     *  Transform the selected name to a unique item name.\n     *\n     *    @param [in] newName     The selected name.\n     *\n     *    @return A unique name derived from the selected name.\n     */\n    QString getUniqueName(std::string const& newName, std::string const& itemTypeName) const;\n\n    /*!\n     *  Check if the new name is different from the current name.\n     *\n     *    @param [in] newName     The new name.\n     *    @param [in] oldName     The current name.\n     *\n     *    @return True, if the new name is different, false otherwise.\n     */\n    bool nameHasChanged(std::string const& newName, std::string const& oldName) const;\n\nprivate:\n\n    /*!\n     *  Check if the selected name is unique.\n     *\n     *    @param [in] portName    The selected name.\n     *\n     *    @return True, if the selected name is unique, false otherwise.\n     */\n    bool nameIsUnique(std::string_view name, std::vector<std::string> const& reservedNamed) const;\n};\n\n#endif // COMMONINTERFACE_H\n"
  },
  {
    "path": "KactusAPI/include/ComponentAndInstantiationsParameterFinder.h",
    "content": "//-----------------------------------------------------------------------------\n// File: ComponentAndInstantiationsParameterFinder.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 02.04.2020\n//\n// Description:\n// The implementation for finding parameters from the full component with the correct ID.\n//-----------------------------------------------------------------------------\n\n#ifndef COMPONENTANDINSTANTIATIONSPARAMETERFINDER_H\n#define COMPONENTANDINSTANTIATIONSPARAMETERFINDER_H\n\n#include <KactusAPI/KactusAPIGlobal.h>\n\n#include \"ComponentParameterFinder.h\"\n\nclass Component;\n\n//-----------------------------------------------------------------------------\n//! The implementation for finding parameters from the full component with the correct ID.\n//-----------------------------------------------------------------------------\nclass KACTUS2_API ComponentAndInstantiationsParameterFinder : public ComponentParameterFinder\n{\n\npublic:\n\n    /*!\n     *  Constructor.\n     *\n\t *    @param [in] component\t\tThe component which parameters are being searched for.\n     */\n    explicit ComponentAndInstantiationsParameterFinder(QSharedPointer<Component const> component) noexcept;\n\n    //! No copying. No assignment.\n    ComponentAndInstantiationsParameterFinder(const ComponentAndInstantiationsParameterFinder& other) = delete;\n    ComponentAndInstantiationsParameterFinder& operator=(const ComponentAndInstantiationsParameterFinder& other)\n        = delete;\n\n    /*!\n     *  Destructor.\n     */\n    ~ComponentAndInstantiationsParameterFinder() final = default;\n\n    /*!\n     *  Gets all of the ids of components parameters.\n     *\n     *    @return A list containing all of the ids.\n     */\n    QStringList getAllParameterIds() const final;\n\n    /*!\n     *  Gets the number of parameters in the component.\n     *\n     *    @return The number of parameters in the component.\n     */\n    int getNumberOfParameters() const final;\n\n    /*!\n     *  Get all the instantiation parameters.\n     *\n     *    @return The instantiation parameters.\n     */\n    QList<QSharedPointer<Parameter> > allInstantiationsParameters() const;\n\nprivate:\n\n\t/*!\n\t *  Get the selected parameter.\n     *\n     *    @param [in] parameterId     ID of the selected parameter.\n     *\n     *    @return The selected parameter.\n     */\n\tQSharedPointer<Parameter> searchParameter(QStringView parameterId) const final;\n};\n\n#endif // COMPONENTPARAMETERFINDER_H\n"
  },
  {
    "path": "KactusAPI/include/ComponentInstanceInterface.h",
    "content": "//-----------------------------------------------------------------------------\n// File: ComponentInstanceInterface.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 09.09.2021\n//\n// Description:\n// Interface for accessing component instances.\n//-----------------------------------------------------------------------------\n\n#ifndef COMPONENTINSTANCEINTERFACE_H\n#define COMPONENTINSTANCEINTERFACE_H\n\n#include <NameGroupInterface.h>\n\n#include <QSharedPointer>\n\nclass Design;\nclass ComponentInstance;\nclass ConfigurableVLNVReference;\n\nclass InterconnectionInterface;\nclass AdHocConnectionInterface;\n\n//-----------------------------------------------------------------------------\n//! Interface for accessing component instances.\n//-----------------------------------------------------------------------------\nclass KACTUS2_API ComponentInstanceInterface : public NameGroupInterface\n{\npublic:\n\n    /*!\n     *  The constructor.\n     *\n     *    @param [in] connectionInterface     Interface for accessing interconnections.\n     *    @param [in] adHocInterface          Interface for accessing ad hoc connections.\n     */\n    ComponentInstanceInterface(InterconnectionInterface* connectionInterface,\n        AdHocConnectionInterface* adHocInterface);\n\n    /*!\n     *  The destructor.\n     */\n    virtual ~ComponentInstanceInterface() = default;\n\n    /*!\n     *  Setup the component instances.\n     *\n     *    @param [in] newDesign   Design containing the component instances.\n     */\n    void setComponentInstances(QSharedPointer<Design> newDesign);\n\n    /*!\n     *  Get index of the selected component instance.\n     *\n     *    @param [in] itemName    Name of the selected component instance.\n     *\n     *    @return Index of the selected component instance.\n     */\n    virtual int getItemIndex(std::string const& itemName) const override final;\n\n    /*!\n     *  Get name of the indexed component instance.\n     *\n     *    @param [in] itemIndex   Index of the selected component instance.\n     *\n     *    @return Name of the selected component instance.\n     */\n    std::string getIndexedItemName(int itemIndex) const final;\n\n    /*!\n     *  Get the number of available component instances.\n     *\n     *    @return Number of available component instances.\n     */\n    virtual int itemCount() const override final;\n\n    /*!\n     *  Get the names of the available component instances.\n     *\n     *    @return Names of the available component instances.\n     */\n    virtual std::vector<std::string> getItemNames() const override final;\n\n    /*!\n     *  Set a new name for the selected component instance.\n     *\n     *    @param [in] currentName     Name of the selected component instance.\n     *    @param [in] newName         New name for the component instance.\n     *\n     *    @return True, if successful, false otherwise.\n     */\n    virtual bool setName(std::string const& currentName, std::string const& newName) override final;\n\n    /*!\n     *  Get the description of the selected component instance.\n     *\n     *    @param [in] itemName    Name of the selected component instance.\n     *\n     *    @return Description of the selected component instance.\n     */\n    virtual std::string getDescription(std::string const& itemName) const override final;\n\n    /*!\n     *  Set a new description for the selected component instance.\n     *\n     *    @param [in] itemName        Name of the selected component instance.\n     *    @param [in] newDescription  New description.\n     *\n     *    @return True, if successful, false otherwise.\n     */\n    virtual bool setDescription(std::string const& itemName, std::string const& newDescription) override final;\n\n    /*!\n     *  Validates the contained component instances.\n     *\n     *    @return True, if all the component instances are valid, false otherwise.\n     */\n    virtual bool validateItems() const override final;\n\n    /*!\n     *  Check if the selected component instance has a valid name.\n     *\n     *    @param [in] itemName    Name of the selected component instance.\n     *\n     *    @return True, if the name is valid, false otherwise.\n     */\n    virtual bool itemHasValidName(std::string const& itemName) const override final;\n\n    /*!\n     *  Get the VLNV of the referenced component of the selected component instance.\n     *\n     *    @param [in] instanceName    Name of the selected component instance.\n     *\n     *    @return VLNV of the referenced component.\n     */\n    QSharedPointer<ConfigurableVLNVReference> getComponentReference(std::string const& instanceName) const;\n\n    /*!\n     *  Set a new component reference for the selected component instance.\n     *\n     *    @param [in] instanceName    Name of the selected component instance.\n     *    @param [in] newVendor       Vendor of the new component reference.\n     *    @param [in] newLibrary      Library of the new component reference.\n     *    @param [in] newName         Name of the new component reference.\n     *    @param [in] newVersion      Version of the new component reference.\n     *\n     *    @return True, if successful, false otherwise.\n     */\n    bool setComponentReference(std::string const& instanceName, std::string const& newVendor,\n        std::string const& newLibrary, std::string const& newName, std::string const& newVersion);\n\n    /*!\n     *  Add a new component instance.\n     *\n     *    @param [in] instanceName    Name of the new component instance.\n     */\n    void addComponentInstance(std::string const& instanceName = \"\");\n\n    /*!\n     *  Remove the selected component instance.\n     *\n     *    @param [in] instanceName    Name of the selected component instance.\n     *\n     *    @return True, if successful, false otherwise.\n     */\n    bool removeComponentInstance(std::string const& instanceName);\n\n    /*!\n     *  Check if the selected component instance exists.\n     *\n     *    @param [in] instanceName    Name of the selected component instance.\n     *\n     *    @return True, if the component instance exists, false otherwise.\n     */\n    bool instanceExists(std::string const& instanceName) const;\n\n    //! No copying. No assignment.\n    ComponentInstanceInterface(const ComponentInstanceInterface& other) = delete;\n    ComponentInstanceInterface& operator=(const ComponentInstanceInterface& other) = delete;\n\nprivate:\n\n    /*!\n     *  Get the selected component instance.\n     *\n     *    @param [in] instanceName    Name of the selected component instance.\n     *\n     *    @return The selected component instance.\n     */\n    QSharedPointer<ComponentInstance> getComponentInstance(std::string const& instanceName) const;\n\n    /*!\n     *  Get the paracomponent instancemeter with the selected name, sliced to a NameGroup.\n     *\n     *    @param [in] instanceName   Name of the selected component instance.\n     *\n     *    @return The sliced component instance with the selected name.\n     */\n    QSharedPointer<NameGroup> getItem(std::string const& instanceName) const;\n\n    //-----------------------------------------------------------------------------\n    // Data.\n    //-----------------------------------------------------------------------------\n\n    //! The available component instances.\n    QSharedPointer<QList<QSharedPointer<ComponentInstance> > > componentInstances_;\n\n    //! Interface for accessing design interconnections.\n    InterconnectionInterface* connectionInterface_;\n\n    //! Interface for accessing design ad hoc connections.\n    AdHocConnectionInterface* adHocConnectionInterface_;\n};\n\n#endif // COMPONENTINSTANCEINTERFACE_H\n"
  },
  {
    "path": "KactusAPI/include/ComponentInstanceParameterFinder.h",
    "content": "//-----------------------------------------------------------------------------\n// File: ComponentInstanceParameterFinder.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Esko Pekkarinen\n// Date: 13.01.2017\n//\n// Description:\n// The implementation for finding parameters for component instance.\n//-----------------------------------------------------------------------------\n\n#ifndef COMPONENTINSTANCEPARAMETERFINDER_H\n#define COMPONENTINSTANCEPARAMETERFINDER_H\n\n#include <KactusAPI/include/ParameterCache.h>\n\n#include <KactusAPI/KactusAPIGlobal.h>\n\n#include <QSharedPointer>\n\nclass Component;\nclass ComponentInstance;\nclass Parameter;\n\n//-----------------------------------------------------------------------------\n//! The implementation for finding parameters for component instance.\n//-----------------------------------------------------------------------------\nclass KACTUS2_API ComponentInstanceParameterFinder : public ParameterCache\n{\n    Q_OBJECT\n\npublic:\n\n    /*!\n     *  Constructor.\n     *\n     *    @param [in] componentInstance\tThe component instance whose parameters are being searched for.\n\t *    @param [in] component\t\t    The instantiated component.\n     */\n    ComponentInstanceParameterFinder(QSharedPointer<const ComponentInstance> componentInstance,\n        QSharedPointer<const Component> component);\n\n    /*!\n     *  Destructor.\n     */\n    ~ComponentInstanceParameterFinder() final = default;\n\n    //! No copying\n    ComponentInstanceParameterFinder(const ParameterCache& other) = delete;\n    //! No assignment\n    ComponentInstanceParameterFinder& operator=(const ParameterCache& other) = delete;\n\n    /*!\n     *  Finds the value of the parameter with the given id.\n     *\n     *    @param [in] id      The id of the parameter to search for.\n     *\n     *    @return The value of the parameter.\n     */\n    QString valueForId(QStringView id) const final;\n\nprivate:\n\n    // The component instance whose parameters are being searched for.\n    QSharedPointer<const ComponentInstance> componentInstance_;\n};\n\n#endif // COMPONENTINSTANCEPARAMETERFINDER_H\n"
  },
  {
    "path": "KactusAPI/include/ComponentInstantiationInterface.h",
    "content": "//-----------------------------------------------------------------------------\n// File: ComponentInstantiationInterface.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 23.09.2020\n//\n// Description:\n// Interface for editing component instantiations.\n//-----------------------------------------------------------------------------\n\n#ifndef COMPONENTINSTANTIATIONINTERFACE_H\n#define COMPONENTINSTANTIATIONINTERFACE_H\n\n#include <KactusAPI/KactusAPIGlobal.h>\n\n#include <ParameterizableInterface.h>\n#include <NameGroupInterface.h>\n\nclass InstantiationsValidator;\nclass ComponentInstantiation;\nclass FileBuilderInterface;\nclass ParametersInterface;\nclass ModuleParameterInterface;\nclass FileSetInterface;\n\n//-----------------------------------------------------------------------------\n//! Interface for editing component instantiations.\n//-----------------------------------------------------------------------------\nclass KACTUS2_API ComponentInstantiationInterface : public ParameterizableInterface, public NameGroupInterface\n{\n\npublic:\n\n    /*!\n     *  The constructor.\n     *\n     *    @param [in] validator                   Validator for address blocks.\n     *    @param [in] expressionParser            Parser for expressions.\n     *    @param [in] expressionFormatter         Formatter for expressions.\n     *    @param [in] parameterInterface          Interface for accessing parameters.\n     *    @param [in] moduleParameterInterface    Interface for accessing module parameters\n     *    @param [in] fileBuilderInterface        Interface for accessing file builders.\n     *    @param [in] fileSetInterface            Interface for accessing file sets.\n     */\n    ComponentInstantiationInterface(QSharedPointer<InstantiationsValidator> validator,\n        QSharedPointer<ExpressionParser> expressionParser,\n        QSharedPointer<ExpressionFormatter> expressionFormatter,\n        ParametersInterface* parameterInterface,\n        ModuleParameterInterface* moduleParameterInterface,\n        FileBuilderInterface* fileBuilderInterface,\n        FileSetInterface* fileSetInterface);\n\n\t/*!\n     *  The destructor.\n     */\n    virtual ~ComponentInstantiationInterface() = default;\n\n    /*!\n     *  Set available component instantiations.\n     *\n     *    @param [in] newInstantiations   The new component instantiations.\n     */\n    void setComponentInstantiations(\n        QSharedPointer<QList<QSharedPointer<ComponentInstantiation> > > newInstantiations);\n\n    /*!\n     *  Get index of the selected item.\n     *\n     *    @param [in] itemName    Name of the selected item.\n     *\n     *    @return Index of the selected item.\n     */\n    virtual int getItemIndex(std::string const& itemName) const override final;\n\n    /*!\n     *  Get name of the indexed item.\n     *\n     *    @param [in] itemIndex   Index of the selected item.\n     *\n     *    @return Name of the selected item.\n     */\n    std::string getIndexedItemName(int itemIndex) const final;\n\n    /*!\n     *  Get the number of available items.\n     *\n     *    @return Number of available items.\n     */\n    virtual int itemCount() const override final;\n\n    /*!\n     *  Get the names of the available items.\n     *\n     *    @return Names of the available items.\n     */\n    virtual std::vector<std::string> getItemNames() const override final;\n\n    /*!\n     *  Set a new name for the selected item.\n     *\n     *    @param [in] currentName     Name of the selected item.\n     *    @param [in] newName         New name for the item.\n     *\n     *    @return True, if successful, false otherwise.\n     */\n    virtual bool setName(std::string const& currentName, std::string const& newName) override final;\n\n    /*!\n     *  Get the display name of the selected item.\n     *\n     *    @param [in] itemName    Name of the selected item.\n     *\n     *    @return Display name of the selected item.\n     */\n    std::string getDisplayName(std::string const& itemName) const;\n\n    /*!\n     *  Set the display name of the selected item.\n     *\n     *    @param [in] itemName        Name of the selected item.\n     *    @param [in] newDisplayName  New display name for the item.\n     *\n     *    @return True, if successful, false otherwise.\n     */\n    bool setDisplayName(std::string const& itemName, std::string const& newDisplayName);\n\n    /*!\n     *  Calculate all the references to the selected ID in the selected item.\n     *\n     *    @param [in] itemName    Name of the selected item.\n     *    @param [in] valueID     The selected ID.\n     *\n     *    @return Number of references to the selected ID in the selected item.\n     */\n    virtual int getAllReferencesToIdInItem(const std::string& itemName, std::string const&  valueID) const override\n        final;\n\n    /*!\n     *  Get the expressions in the selected component instantiations.\n     *\n     *    @param [in] instantiationNames  Names of the selected component instantiations.\n     *\n     *    @return Expressions in the selected component instantiations.\n     */\n    std::vector<std::string> getExpressionsInSelectedItems(std::vector<std::string> instantiationNames) const;\n\n    /*!\n     *  Validates the contained items.\n     *\n     *    @return True, if all the ports are valid, false otherwise.\n     */\n    virtual bool validateItems() const override final;\n\n    /*!\n     *  Check if the selected item has a valid name.\n     *\n     *    @param [in] itemName    Name of the selected item.\n     *\n     *    @return True, if the name is valid, false otherwise.\n     */\n    virtual bool itemHasValidName(std::string const& itemName) const override final;\n\n    /*!\n     *  Add a new component instantiation.\n     *\n     *    @param [in] row                     Row of the new component instantiation.\n     *    @param [in] newInstantiationName    Name of the new component instantiation.\n     */\n    void addComponentInstantiation(int const& row, std::string const& newInstantiationName = std::string(\"\"));\n\n    /*!\n     *  Remove the selected component instantiation.\n     *\n     *    @param [in] instantiationName   Name of the selected component instantiation.\n     *\n     *    @return True, if successful, false otherwise.\n     */\n    bool removeComponentInstantiation(std::string const& instantiationName);\n\n    /*!\n     *  Get the parameter interface.\n     *\n     *    @return Interface for accessing parameters.\n     */\n    ParametersInterface* getParameterInterface() const;\n\n    /*!\n     *  Get the module parameter interface.\n     *\n     *    @return Interface for accessing module parameters.\n     */\n    ModuleParameterInterface* getModuleParameterInterface() const;\n\n    /*!\n     *  Get the file builder interface.\n     *\n     *    @return Interface for accessing file builders.\n     */\n    FileBuilderInterface* getFileBuilderInterface() const;\n    \n    /*!\n     *  Get the file set interface.\n     *\n     *    @return Interface for accessing file sets.\n     */\n    FileSetInterface* getFileSetInterface() const;\n\n    /*!\n     *  Get the language of the selected component instantiation.\n     *\n     *    @param [in] instantiationName   Name of the selected component instantiation.\n     *\n     *    @return Language of the selected component instantiation.\n     */\n    std::string getLanguage(std::string const& instantiationName) const;\n\n    /*!\n     *  Set a new language for the selected component instantiation.\n     *\n     *    @param [in] instantiationName   Name of the selected component instantiation.\n     *    @param [in] newLanguage         New language.\n     *\n     *    @return True, if successful, false otherwise.\n     */\n    bool setLanguage(std::string const& instantiationName, std::string const& newLanguage);\n\n    /*!\n     *  Check if the language of the selected component instantiation is strict.\n     *\n     *    @param [in] instantiationName   Name of the selected component instantiation.\n     *\n     *    @return Language strictness of the selected component instantiation.\n     */\n    bool isLanguageStrict(std::string const& instantiationName) const;\n\n    /*!\n     *  Set language strictness for the selected component instantiation.\n     *\n     *    @param [in] instantiationName   Name of the selected component instantiation.\n     *    @param [in] newStrictness       The new language strictness.\n     *\n     *    @return True, if successful, false otherwise.\n     */\n    bool setLanguageStrictness(std::string const& instantiationName, bool newStrictness);\n\n    /*!\n     *  Get the library name of the selected component instantiation.\n     *\n     *    @param [in] instantiationName   Name of the selected component instantiation.\n     *\n     *    @return Library name of the selected component instantiation.\n     */\n    std::string getLibraryName(std::string const& instantiationName) const;\n\n    /*!\n     *  Set a new library name for the selected component instantiation.\n     *\n     *    @param [in] instantiationName   Name of the selected component instantiation.\n     *    @param [in] newLibraryName      The new library name.\n     *\n     *    @return True, if successful, false otherwise.\n     */\n    bool setLibraryName(std::string const& instantiationName, std::string const& newLibraryName);\n\n    /*!\n     *  Get the package name of the selected component instantiation.\n     *\n     *    @param [in] instantiationName   Name of the selected component instantiation.\n     *\n     *    @return Package name of the selected component instantiation.\n     */\n    std::string getPackageName(std::string const& instantiationName) const;\n\n    /*!\n     *  Set a new package name for the selected component instantiation.\n     *\n     *    @param [in] instantiationName   Name of the selected component instantiation.\n     *    @param [in] newPackageName      The new library name.\n     *\n     *    @return True, if successful, false otherwise.\n     */\n    bool setPackageName(std::string const& instantiationName, std::string const& newPackageName);\n\n    /*!\n     *  Get the module name of the selected component instantiation.\n     *\n     *    @param [in] instantiationName   Name of the selected component instantiation.\n     *\n     *    @return Module name of the selected component instantiation.\n     */\n    std::string getModuleName(std::string const& instantiationName) const;\n\n    /*!\n     *  Set a new module name for the selected component instantiation.\n     *\n     *    @param [in] instantiationName   Name of the selected component instantiation.\n     *    @param [in] newModuleName       The new module name.\n     *\n     *    @return True, if successful, false otherwise.\n     */\n    bool setModuleName(std::string const& instantiationName, std::string const& newModuleName);\n\n    /*!\n     *  Get the architecture name of the selected component instantiation.\n     *\n     *    @param [in] instantiationName   Name of the selected component instantiation.\n     *\n     *    @return Architecture name of the selected component instantiation.\n     */\n    std::string getArchitectureName(std::string const& instantiationName) const;\n\n    /*!\n     *  Set a new architecture name for the selected component instantiation.\n     *\n     *    @param [in] instantiationName       Name of the selected component instantiation.\n     *    @param [in] newArchitectureName     The new module name.\n     *\n     *    @return True, if successful, false otherwise.\n     */\n    bool setArchitectureName(std::string const& instantiationName, std::string const& newArchitectureName);\n\n    /*!\n     *  Get the configuration name of the selected component instantiation.\n     *\n     *    @param [in] instantiationName   Name of the selected component instantiation.\n     *\n     *    @return Configuration name of the selected component instantiation.\n     */\n    std::string getConfigurationName(std::string const& instantiationName) const;\n\n    /*!\n     *  Set a new configuration name for the selected component instantiation.\n     *\n     *    @param [in] instantiationName       Name of the selected component instantiation.\n     *    @param [in] newConfigurationName    The new module name.\n     *\n     *    @return True, if successful, false otherwise.\n     */\n    bool setConfigurationName(std::string const& instantiationName, std::string const& newConfigurationName);\n\n    /*!\n     *  Get the file set references of the selected component instantiation.\n     *\n     *    @param [in] instantiationName   Name of the selected component instantiation.\n     *\n     *    @return File set references of the selected component instantiation.\n     */\n    std::vector<std::string> getFileSetReferences(std::string const& instantiationName) const;\n\n    /*!\n     *  Set new file set references for the selected component instantiation.\n     *\n     *    @param [in] instantiationName   Name of the selected component instantiation.\n     *    @param [in] newReferences       The new file set references.\n     *\n     *    @return True, if successful, false otherwise.\n     */\n    bool setFileSetReferences(std::string const& instantiationName, std::vector<std::string> const& newReferences);\n\n\nprivate:\n\n    /*!\n     *  Get the selected component instantiation.\n     *\n     *    @param [in] itemName   Name of the selected component instantiation.\n     *\n     *    @return The selected component instantiation.\n     */\n    QSharedPointer<ComponentInstantiation> getComponentInstantiation(std::string const& itemName) const;\n    \n\n    /*!\n     *  Get the component instantiation with the selected name, sliced to a NameGroup.\n     *\n     *    @param [in] itemName    Name of the selected component instantiation.\n     *\n     *    @return The sliced component instantiation with the selected name.\n     */\n    QSharedPointer<NameGroup> getItem(std::string const& itemName) const override;\n\n    //-----------------------------------------------------------------------------\n    // Data.\n    //-----------------------------------------------------------------------------\n\n    //! List of the contained component instantiations.\n    QSharedPointer<QList<QSharedPointer<ComponentInstantiation> > > instantiations_;\n\n    //! Validator for instantiations.\n    QSharedPointer<InstantiationsValidator> validator_;\n\n    //! Interface for accessing parameters.\n    ParametersInterface* parameterInterface_;\n\n    //! Interface for accessing module parameters.\n    ModuleParameterInterface* moduleParameterInterface_;\n\n    //! Interface for accessing file builders.\n    FileBuilderInterface* fileBuilderInterface_;\n\n    //! Interface for accessing file sets.\n    FileSetInterface* fileSetInterface_;\n};\n\n#endif // COMPONENTINSTANTIATIONINTERFACE_H\n"
  },
  {
    "path": "KactusAPI/include/ComponentInstantiationParameterFinder.h",
    "content": "//-----------------------------------------------------------------------------\n// File: ComponentInstantiationParameterFinder.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Janne Virtanen\n// Date: 05.05.2017\n//\n// Description:\n// For finding parameters with the correct ID.\n//-----------------------------------------------------------------------------\n\n#ifndef COMPONENTINSTANTIATIONPARAMETERFINDER_H\n#define COMPONENTINSTANTIATIONPARAMETERFINDER_H\n\n#include <KactusAPI/KactusAPIGlobal.h>\n\n#include \"ParameterFinder.h\"\n\n\nclass AbstractParameterModel;\nclass ComponentInstantiation;\n\n//-----------------------------------------------------------------------------\n//! The implementation for finding parameters with the correct ID.\n//-----------------------------------------------------------------------------\nclass KACTUS2_API ComponentInstantiationParameterFinder : public ParameterFinder\n{\n\npublic:\n\n    /*!\n     *  Constructor.\n     *\n\t *    @param [in] componentInstantiation  The element which parameters are being searched for.\n     */\n    explicit ComponentInstantiationParameterFinder(QSharedPointer<ComponentInstantiation const> componentInstantiation);\n\n    /*!\n     *  Destructor.\n     */\n    ~ComponentInstantiationParameterFinder() override = default;\n\n    //! No copying\n    ComponentInstantiationParameterFinder(const ComponentInstantiationParameterFinder& other) = delete;\n    //! No assignment\n    ComponentInstantiationParameterFinder& operator=(const ComponentInstantiationParameterFinder& other) = delete;\n\n    /*!\n     *  Get the parameter with the given id.\n     *\n     *    @param [in] parameterId     The id of the parameter being searched for.\n     */\n    QSharedPointer<Parameter> getParameterWithID(QStringView parameterId) const final;\n\n    /*!\n     *  Checks if a parameter with the given id exists.\n     *\n     *    @param [in] id      The id to search for.\n     *\n     *    @return True, if the parameter with the given id exists, otherwise false.\n     */\n    bool hasId(QStringView id) const final;\n\n    /*!\n     *  Finds the name of the parameter with the given id.\n     *\n     *    @param [in] id      The id to search for.\n     *\n     *    @return The name of the parameter.\n     */\n    QString nameForId(QStringView id) const final;\n\n    /*!\n     *  Finds the value of the parameter with the given id.\n     *\n     *    @param [in] id      The id of the parameter to search for.\n     *\n     *    @return The value of the parameter.\n     */\n    QString valueForId(QStringView id) const final;\n\n    /*!\n     *  Gets all of the ids of components instantiation parameters.\n     *\n     *    @return A list containing all of the ids.\n     */\n    QStringList getAllParameterIds() const final;\n\n    /*!\n     *  Gets the number of parameters in the component instantiation.\n     *\n     *    @return The number of parameters in the component instantiation.\n     */\n    int getNumberOfParameters() const final;\n\n    /*!\n     *  Sets a new component instantiation for the parameter finder.\n     */\n    virtual void setComponentInstantiation(QSharedPointer<ComponentInstantiation const> componentInstantiation);\n    \n    /*!\n     *  Registers a parameter model that can modify parameters for the finder.\n     *\n     *    @param [in] model   The model to register.\n     */\n    void registerParameterModel(QAbstractItemModel const* model) final;\n\nprivate:\n\n\t/*!\n\t *  Returns a parameter corresponding given id, if any exists.\n\t*/\n\tQSharedPointer<Parameter> searchParameter(QStringView parameterId) const;\n\n    //-----------------------------------------------------------------------------\n    // Data.\n    //-----------------------------------------------------------------------------\n\n    //! The parameters are searched from this component instantiation.\n    QSharedPointer<ComponentInstantiation const> componentInstantiation_;\n};\n\n#endif // COMPONENTINSTANTIATIONPARAMETERFINDER_H\n"
  },
  {
    "path": "KactusAPI/include/ComponentParameterFinder.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ComponentParameterFinder.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Mikko Teuho\r\n// Date: 15.01.2015\r\n//\r\n// Description:\r\n// The implementation for finding parameters with the correct ID.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef COMPONENTPARAMETERFINDER_H\r\n#define COMPONENTPARAMETERFINDER_H\r\n\r\n#include \"ParameterFinder.h\"\r\n\r\n#include \"KactusAPI/KactusAPIGlobal.h\"\r\n\r\nclass AbstractParameterModel;\r\nclass Component;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! The implementation for finding parameters with the correct ID.\r\n//-----------------------------------------------------------------------------\r\nclass KACTUS2_API ComponentParameterFinder : public ParameterFinder\r\n{\r\n\r\npublic:\r\n\r\n    /*!\r\n     *  Constructor.\r\n     *\r\n\t *    @param [in] component\t\tThe component which parameters are being searched for.\r\n     */\r\n    explicit ComponentParameterFinder(QSharedPointer<Component const> component) noexcept;\r\n\r\n    //! No copying\r\n    ComponentParameterFinder(const ComponentParameterFinder& other) = delete;\r\n\r\n    //! No assignment\r\n    ComponentParameterFinder& operator=(const ComponentParameterFinder& other) = delete;\r\n\r\n    /*!\r\n     *  Destructor.\r\n     */\r\n    ~ComponentParameterFinder() override = default;\r\n\r\n    /*!\r\n     *  Get the parameter with the given id.\r\n     *\r\n     *    @param [in] parameterId     The id of the parameter being searched for.\r\n     */\r\n    QSharedPointer<Parameter> getParameterWithID(QStringView parameterId) const override;\r\n\r\n    /*!\r\n     *  Checks if a parameter with the given id exists.\r\n     *\r\n     *    @param [in] id      The id to search for.\r\n     *\r\n     *    @return True, if the parameter with the given id exists, otherwise false.\r\n     */\r\n    bool hasId(QStringView id) const override;\r\n\r\n    /*!\r\n     *  Finds the name of the parameter with the given id.\r\n     *\r\n     *    @param [in] id      The id to search for.\r\n     *\r\n     *    @return The name of the parameter.\r\n     */\r\n    QString nameForId(QStringView id) const override;\r\n\r\n    /*!\r\n     *  Finds the value of the parameter with the given id.\r\n     *\r\n     *    @param [in] id      The id of the parameter to search for.\r\n     *\r\n     *    @return The value of the parameter.\r\n     */\r\n    QString valueForId(QStringView id) const override;\r\n\r\n    /*!\r\n     *  Gets all of the ids of components parameters.\r\n     *\r\n     *    @return A list containing all of the ids.\r\n     */\r\n    virtual QStringList getAllParameterIds() const override;\r\n\r\n    /*!\r\n     *  Gets the number of parameters in the component.\r\n     *\r\n     *    @return The number of parameters in the component.\r\n     */\r\n    virtual int getNumberOfParameters() const override;\r\n\r\n    /*!\r\n    *  Registers a parameter model that can modify parameters for the finder.\r\n    *\r\n    *    @param [in] model   The model to register.\r\n    */\r\n    virtual void registerParameterModel(QAbstractItemModel const* model) override;\r\n\r\n    /*!\r\n     *  Set a new component for the parameter finder.\r\n     *\r\n     *    @param [in] component   The new component.\r\n     */\r\n    virtual void setComponent(QSharedPointer<Component const> component);\r\n\r\n    /*!\r\n     *  Returns all the parameters in component address spaces.\r\n     */\r\n    QList<QSharedPointer<Parameter> > allAddressSpaceParameters() const;\r\n\r\n    /*!\r\n     *  Finds all the parameters in component bus interfaces.\r\n     *\r\n     *    @return The parameters in all bus interfaces.\r\n     */\r\n    QList<QSharedPointer<Parameter> > allBusInterfaceParameters() const;\r\n    \r\n    /*!\r\n     *  Returns all the parameters in component cpus.\r\n     */\r\n    QList<QSharedPointer<Parameter> > allCpuParameters() const;\r\n    \r\n    /*!\r\n     *  Returns all the parameters in component generators.\r\n     */\r\n    QList<QSharedPointer<Parameter> > allGeneratorParameters() const;\r\n\r\n    /*!\r\n     *  Finds all the parameters in component registers.\r\n     *\r\n     *    @return The parameters in all registers.\r\n     */\r\n    QList<QSharedPointer<Parameter> > allRegisterParameters() const;\r\n\r\n    /*!\r\n     *  Get all the parameters in indirect interfaces.\r\n     *\r\n     *    @return The parameters in indirect interfaces.\r\n     */\r\n    QList<QSharedPointer<Parameter> > allIndirectInterfacesParameters() const;\r\n\r\nprotected:\r\n\r\n    /*!\r\n     *  Returns a parameter corresponding given id, if any exists.\r\n     */\r\n    virtual QSharedPointer<Parameter> searchParameter(QStringView parameterId) const;\r\n\r\n    /*!\r\n     *  Get the component.\r\n     *\r\n     *    @return The contained component.\r\n     */\r\n    QSharedPointer<const Component> getComponent() const noexcept;\r\n\r\nprivate:\r\n    \r\n    /*!\r\n     *  Returns number of parameters in bus interfaces.\r\n     */\r\n    int busInterfaceParameterCount() const;\r\n    \r\n    /*!\r\n     *  Returns number of parameters in registers.\r\n     */\r\n    int registerParameterCount() const;\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! The parameters are searched from this component.\r\n    QSharedPointer<Component const> component_;\r\n};\r\n\r\n#endif // COMPONENTPARAMETERFINDER_H\r\n"
  },
  {
    "path": "KactusAPI/include/ConfigJsonParser.h",
    "content": "#ifndef CONFIGJSONPARSER_H\n#define CONFIGJSONPARSER_H\n\n#include <IPXACTmodels/common/Parameter.h>\n\n#include <KactusAPI/KactusAPIGlobal.h>\n\n#include <QtCore>\n#include <QDir>\n\nnamespace InterconnectGeneration\n{\n    struct AddressPair\n    {\n\n        QString start;\n        QString end;\n\n    };\n\n    struct InitStruct\n    {\n\n        int index;\n        QString name;\n\n    };\n\n    struct TargetStruct\n    {\n\n        int index;\n        QString name;\n        QList<AddressPair> addressRegions;\n\n    };\n\n    enum class BusType {\n        AXI4,\n        AXI4LITE,\n        OBI,\n        UNKNOWN\n    };\n\n    // Currently used for CLI version\n    struct ConfigStruct\n    {\n\n        QString interconVLNV;\n        QString designVLNV;\n        QString busVLNV;\n        QString clkVLNV;\n        QString rstVLNV;\n        QString filesetToGenerate;\n        BusType busType;\n        QString addressWidth;\n        QString dataWidth;\n        int parsedAddressWidth = -1;\n        int idWidth = -1;\n        int userWidth = -1;\n        bool isChannel = false;\n        QString addressWidthParamName;\n        QString dataWidthParamName;\n        QList<QSharedPointer<Parameter>> interconnectParams;\n        QList<InitStruct> initList;\n        QList<TargetStruct> targetList;\n\n    };\n\n    class KACTUS2_API ConfigJsonParser\n    {\n    public:\n\n        //! The constructor\n        ConfigJsonParser();\n\n        //! The destructor\n        ~ConfigJsonParser() = default;\n\n        ConfigStruct* readFile();\n\n        //! No copying. No assignment.\n        ConfigJsonParser(const ConfigJsonParser& other) = delete;\n        ConfigJsonParser& operator=(const ConfigJsonParser& other) = delete;\n        \n        static BusType strToBusType(QString const& busTypeStr);\n        static QString busTypeToStr(BusType busType);\n\n    private:\n\n        ConfigStruct config_;\n        QString path_ = QDir::currentPath() + \"/KactusAPI/include/config.json\";\n    };\n\n}\n\n#endif // CONFIGJSONPARSER_H\n"
  },
  {
    "path": "KactusAPI/include/ConsoleMediator.h",
    "content": "//-----------------------------------------------------------------------------\n// File: ConsoleMediator.h\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Esko Pekkarinen\n// Date: 13.02.2018\n//\n// Description:\n// Console output for user messages.\n//-----------------------------------------------------------------------------\n\n#ifndef CONSOLEMEDIATOR_H\n#define CONSOLEMEDIATOR_H\n\n#include <KactusAPI/KactusAPIGlobal.h>\n\n#include \"MessageMediator.h\"\n//-----------------------------------------------------------------------------\n//! Console output for user messages.\n//-----------------------------------------------------------------------------\nclass KACTUS2_API ConsoleMediator: public MessageMediator\n{\npublic:\n\n    //! The constructor.\n    explicit ConsoleMediator() = default;\n\n    //! The destructor.\n    ~ConsoleMediator() final = default;\n        \n    //! Show the given message to the user.\n    void showMessage(QString const& message) const final;\n    \n    //! Show the given error to the user.\n    void showError(QString const& error) const final;\n\n    //! Show the given failure message to the user.\n    void showFailure(QString const& error) const final;\n\n    //! Show the given status to the user.\n    void showStatusMessage(QString const& status) const final;\n\n};\n\n#endif // CONSOLEMEDIATOR_H\n"
  },
  {
    "path": "KactusAPI/include/DesignParameterFinder.h",
    "content": "//-----------------------------------------------------------------------------\n// File: DesignParameterFinder.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 04.04.2022\n//\n// Description:\n// The implementation for finding parameters for designs.\n//-----------------------------------------------------------------------------\n\n#ifndef DESIGNPARAMETERFINDER_H\n#define DESIGNPARAMETERFINDER_H\n\n#include <KactusAPI/include/ListParameterFinder.h>\n\n#include <KactusAPI/KactusAPIGlobal.h>\n\n#include <QSharedPointer>\n\nclass ConfigurableElementValue;\nclass DesignInstantiation;\n\n//-----------------------------------------------------------------------------\n//! The implementation for finding parameters for designs.\n//-----------------------------------------------------------------------------\nclass KACTUS2_API DesignParameterFinder : public ListParameterFinder\n{\npublic:\n\n    /*!\n     *  The constructor.\n     *\n     *    @param [in] designInstantiation     The design instantiation whose parameters are being searched for.\n     */\n    DesignParameterFinder(QSharedPointer<DesignInstantiation> designInstantiation);\n\n    /*!\n     *  The destructor.\n     */\n    ~DesignParameterFinder() final = default;\n\n\n    //! No copying. No assignment.\n    DesignParameterFinder(const DesignParameterFinder& other) = delete;\n    DesignParameterFinder& operator=(const DesignParameterFinder& other) = delete;\n\n    /*!\n     *  Finds the value of the parameter with the given id.\n     *\n     *    @param [in] id      The id of the parameter to search for.\n     *\n     *    @return The value of the parameter.\n     */\n    QString valueForId(QStringView id) const final;\n\nprivate:\n\n    //! A list of configurable element values\n    QSharedPointer<QList<QSharedPointer<ConfigurableElementValue> > > configurableElementValues_ = nullptr;\n};\n\n#endif // DESIGNPARAMETERFINDER_H\n"
  },
  {
    "path": "KactusAPI/include/DocumentFileAccess.h",
    "content": "//-----------------------------------------------------------------------------\n// File: DocumentFileAccess.h\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Esko Pekkarinen\n// Date: 09.02.2018\n//\n// Description:\n// Reading and writing of IP-XACT documents using a standard file system.\n//-----------------------------------------------------------------------------\n\n#ifndef DOCUMENTFILEACCESS_H\n#define DOCUMENTFILEACCESS_H\n\n#include <KactusAPI/KactusAPIGlobal.h>\n\n#include <QSharedPointer>\n#include <QString>\n\n\nclass Document;\nclass MessageMediator;\n\n//-----------------------------------------------------------------------------\n//! Reading and writing of IP-XACT documents using a standard file system.\n//-----------------------------------------------------------------------------\nnamespace DocumentFileAccess \n{\n    //! Reads the document from given path.\n    KACTUS2_API QSharedPointer<Document> readDocument(QString const& path);\n\n    //! Writes to document model to the given path.\n    KACTUS2_API bool writeDocument(QSharedPointer<Document> model, QString const& path);\n\n};\n\n#endif // DOCUMENTFILEACCESS_H\n"
  },
  {
    "path": "KactusAPI/include/DocumentValidator.h",
    "content": "//-----------------------------------------------------------------------------\n// File: DocumentValidator.h\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Esko Pekkarinen\n// Date: 09.02.2018\n//\n// Description:\n// <Short description of the class/file contents>\n//-----------------------------------------------------------------------------\n\n#ifndef DOCUMENTVALIDATOR_H\n#define DOCUMENTVALIDATOR_H\n\n#include <QSharedPointer>\n#include <QString>\n#include <QVector>\n\n\n#include <IPXACTmodels/AbstractionDefinition/validators/AbstractionDefinitionValidator.h>\n#include <IPXACTmodels/BusDefinition/validators/BusDefinitionValidator.h>\n#include <IPXACTmodels/Catalog/validators/CatalogValidator.h>\n#include <IPXACTmodels/Component/validators/ComponentValidator.h>\n#include <IPXACTmodels/Design/validator/DesignValidator.h>\n#include <IPXACTmodels/DesignConfiguration/validators/DesignConfigurationValidator.h>\n#include <IPXACTmodels/kactusExtensions/validators/SystemDesignConfigurationValidator.h>\n\n#include <KactusAPI/include/ListParameterFinder.h>\n#include <KactusAPI/include/ParameterCache.h>\n\nclass Document;\nclass AbstractionDefinition;\nclass BusDefinition;\nclass Catalog;\nclass Component;\nclass ComponentParameterFinder;\nclass Design;\nclass DesignConfiguration;\nclass LibraryInterface;\n\nclass DocumentValidator \n{\npublic:\n\n    //! The constructor.\n    explicit DocumentValidator(LibraryInterface* library);\n\n    //! The destructor.\n    ~DocumentValidator() = default;\n\n    // Disable copying.\n    DocumentValidator(DocumentValidator const& rhs) = delete;\n    DocumentValidator& operator=(DocumentValidator const& rhs) = delete;\n\n    bool validate(QSharedPointer<Document> document);\n\n    void findErrorsIn(QSharedPointer<Document> document, QVector<QString>& errorList);\n\n   \nprivate:\n\n     \n    /*!\n     *  Change the component used in the component validator parameter finder.\n     *\n     *    @param [in] targetComponent     The new component.\n     */\n    void changeComponentValidatorParameterFinder(QSharedPointer<Component> targetComponent);\n\n\n  /*!\n     *  Finds any errors within a given bus definition document.\n     *\n     *    @param [in]  busDefinition   The bus definition to search in.\n     *    @param [out] errorList      The list of errors to add any found errors.\n     */\n    void findErrorsInBusDefinition(QSharedPointer<BusDefinition> busDefinition, QVector<QString>& errorList);\n    \n    /*!\n     *  Finds any errors within a given abstraction definition document.\n     *\n     *    @param [in]  abstraction    The bus definition to search in.\n     *    @param [out] errorList      The list of errors to add any found errors.\n     */\n    void findErrorsInAbstractionDefinition(QSharedPointer<AbstractionDefinition> abstraction, QVector<QString>& errorList);\n\n    /*!\n     *  Finds any errors within a given component.\n     *\n     *    @param [in] component   The selected component.\n     *    @param [in] errorList   The list of errors.\n     */\n    void findErrorsInComponent(QSharedPointer<Component> component, QVector<QString>& errorList);\n\n    /*!\n     *  Finds any errors within a given design.\n     *\n     *    @param [in] design      The selected design.\n     *    @param [in] errorList   The list of errors.\n     */\n    void findErrorsInDesign(QSharedPointer<Design> design, QVector<QString>& errorList);\n\n    /*!\n     *  Finds any errors within a given design configuration.\n     *\n     *    @param [in] configuration   The selected design configuration.\n     *    @param [in] errorList       The list of errors.\n     */\n    void findErrorsInDesignConfiguration(QSharedPointer<DesignConfiguration> configuration,\n        QVector<QString>& errorList);\n\n    //-----------------------------------------------------------------------------\n    // Data.\n    //-----------------------------------------------------------------------------\n\n     LibraryInterface* library_;\n\n     //! The parameter finder used in the component validator.\n     QSharedPointer<ComponentParameterFinder> componentValidatorFinder_{ new ParameterCache(QSharedPointer<Component>()) };\n\n     //! The parameter finder used in the abstraction definition validator.\n     QSharedPointer<ListParameterFinder> absDefParameterFinder_{ new ListParameterFinder() };\n\n     //! The used abstraction definition validator.\n     AbstractionDefinitionValidator abstractionValidator_;\n\n     //! The used bus definition validator.\n     BusDefinitionValidator busValidator_;\n\n     //! The used catalog validator.\n     CatalogValidator catalogValidator_;\n\n     //! The parameter finder used in the design validator.\n     QSharedPointer<ListParameterFinder> designValidatorFinder_{ new ListParameterFinder() };\n\n     //! The used design validator.\n     DesignValidator designValidator_;\n\n     //! The used design configuration validator.\n     DesignConfigurationValidator designConfigurationValidator_;\n\n     //! The used system design configuration validator.\n     SystemDesignConfigurationValidator systemDesignConfigurationValidator_;\n};\n\n#endif // DOCUMENTVALIDATOR_H\n"
  },
  {
    "path": "KactusAPI/include/ExpressionFormatter.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ExpressionFormatter.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Mikko Teuho\r\n// Date: 26.01.2015\r\n//\r\n// Description:\r\n// Formatter for parameter expressions consisting of references.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef EXPRESSIONFORMATTER_H\r\n#define EXPRESSIONFORMATTER_H\r\n\r\n#include \"ParameterFinder.h\"\r\n\r\n#include \"KactusAPI/KactusAPIGlobal.h\"\r\n\r\n#include <QSharedPointer>\r\n\r\nclass ExpressionParser;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Expression formatter.\r\n//-----------------------------------------------------------------------------\r\nclass KACTUS2_API ExpressionFormatter\r\n{\r\n\r\npublic:\r\n\r\n    /*!\r\n     *  Constructor.\r\n     *\r\n     *    @param [in] parameterFinder     Parameter finder used to search the components parameters.\r\n     */\r\n    ExpressionFormatter(QSharedPointer<ParameterFinder> parameterFinder);\r\n\r\n    /*!\r\n     *  Destructor.\r\n     */\r\n    ~ExpressionFormatter();\r\n\r\n    /*!\r\n     *  Format an expression containing a reference to another parameter.\r\n     *\r\n     *    @param [in] expression  The expression being worked on.\r\n     *\r\n     *    @return Formatted expression.\r\n     */\r\n    QString formatReferringExpression(QString const& expression) const;\r\n\r\n    /*!\r\n     *  Format an expression to its largest base number.\r\n     *\r\n     *    @param [in] expression            The selected expression.\r\n     *    @param [in] parser                The used expression parser.\r\n     *    @param [in] expressionIsValid     Flag for informing of a valid expression.\r\n     *\r\n     *    @return Formatted expression.\r\n     */\r\n    static QString format(QString const& expression, QSharedPointer<ExpressionParser> parser, bool* expressionIsValid = nullptr);\r\n\r\nprivate:\r\n\r\n    /*!\r\n     *  Format an expression to its largest base number.\r\n     *\r\n     *    @param [in] expression            The selected expression.\r\n     *    @param [in] parser                The used expression parser.\r\n     *    @param [in] expressionIsValid     Flag for informing of a valid expression.\r\n     *\r\n     *    @return Formatted expression.\r\n     */\r\n    static QString getFormattedValue(QString const& expression, QSharedPointer<ExpressionParser> parser, bool* expressionIsValid);\r\n\r\n\t//! No copying\r\n    ExpressionFormatter(const ExpressionFormatter& other);\r\n\t//! No assignment\r\n    ExpressionFormatter& operator=(const ExpressionFormatter& other);\r\n\r\n    //! Used to search the components parameters.\r\n    QSharedPointer<ParameterFinder> parameterFinder_;\r\n};\r\n\r\n#endif // EXPRESSIONFORMATTER_H\r\n"
  },
  {
    "path": "KactusAPI/include/ExpressionFormatterFactory.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ExpressionFormatterFactory.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Mikko Teuho\r\n// Date: 16.02.2015\r\n//\r\n// Description:\r\n// Interface for expression formatter factory.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef EXPRESSIONFORMATTERFACTORY_H\r\n#define EXPRESSIONFORMATTERFACTORY_H\r\n\r\n#include <KactusAPI/include/ExpressionFormatter.h>\r\n\r\n#include <IPXACTmodels/Component/Component.h>\r\n#include <IPXACTmodels/Design/Design.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Interface for constructing design widgets.\r\n//-----------------------------------------------------------------------------\r\nclass ExpressionFormatterFactory\r\n{\r\n\r\npublic:\r\n\r\n    /*!\r\n     *  Destructor.\r\n     */\r\n    virtual ~ExpressionFormatterFactory() {};\r\n\r\n    /*!\r\n     *  Create an expression formatter using the given component.\r\n     *\r\n     *    @param [in] component   Pointer to the component, whose parameters are used in the formatter.\r\n     */\r\n    virtual ExpressionFormatter* makeExpressionFormatter(QSharedPointer<Component> component) = 0;\r\n\r\n    /*!\r\n     *  Create an expression formatter for a component instance within a design.\r\n     *\r\n     *    @param [in] component   The component of the selected component instance.\r\n     *    @param [in] design      Design containing the component instance.\r\n     */\r\n    virtual ExpressionFormatter* createDesignInstanceFormatter(QSharedPointer<Component> component,\r\n        QSharedPointer<Design> design) = 0;\r\n};\r\n\r\n#endif // EXPRESSIONFORMATTERFACTORY_H\r\n"
  },
  {
    "path": "KactusAPI/include/ExpressionFormatterFactoryImplementation.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ExpressionFormatterFactoryImplementation.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Mikko Teuho\r\n// Date: 16.02.2015\r\n//\r\n// Description:\r\n// Class for expression formatter factory.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef EXPRESSIONFORMATTERFACTORYIMPLEMENTATION_H\r\n#define EXPRESSIONFORMATTERFACTORYIMPLEMENTATION_H\r\n\r\n#include <KactusAPI/KactusAPIGlobal.h>\r\n\r\n#include \"ExpressionFormatterFactory.h\"\r\n\r\n#include <KactusAPI/include/ExpressionFormatter.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Class for constructing expression formatters.\r\n//-----------------------------------------------------------------------------\r\nclass KACTUS2_API ExpressionFormatterFactoryImplementation : public ExpressionFormatterFactory\r\n{\r\n\r\npublic:\r\n    /*!\r\n     *  Constructor.\r\n     */\r\n    ExpressionFormatterFactoryImplementation();\r\n\r\n    /*!\r\n     *  Destructor.\r\n     */\r\n    ~ExpressionFormatterFactoryImplementation();\r\n\r\n    /*!\r\n     *  Create an expression formatter using the given component.\r\n     *\r\n     *    @param [in] component   Pointer to the component, whose parameters are used in the formatter.\r\n     */\r\n    virtual ExpressionFormatter* makeExpressionFormatter(QSharedPointer<Component> component);\r\n    \r\n    /*!\r\n     *  Create an expression formatter for a component instance within a design.\r\n     *\r\n     *    @param [in] component   The component of the selected component instance.\r\n     *    @param [in] design      Design containing the component instance.\r\n     */\r\n    virtual ExpressionFormatter* createDesignInstanceFormatter(QSharedPointer<Component> component,\r\n        QSharedPointer<Design> design);\r\n\r\nprivate:\r\n    // Disable copying.\r\n    ExpressionFormatterFactoryImplementation(ExpressionFormatterFactoryImplementation const& rhs);\r\n    ExpressionFormatterFactoryImplementation& operator=(ExpressionFormatterFactoryImplementation const& rhs);\r\n};\r\n\r\n#endif // DESIGNWIDGETFACTORYIMPLEMENTATION_H\r\n"
  },
  {
    "path": "KactusAPI/include/ExpressionParser.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ExpressionParser.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Esko Pekkarinen\r\n// Date: 04.12.2014\r\n//\r\n// Description:\r\n// Interface for expression parsers.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef EXPRESSIONPARSER_H\r\n#define EXPRESSIONPARSER_H\r\n\r\n#include <QString>\r\n#include <QPair>\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Interface for expression parsers.\r\n//-----------------------------------------------------------------------------\r\nclass ExpressionParser \r\n{\r\npublic:\r\n\r\n\t//! The destructor.\r\n    virtual ~ExpressionParser() = default;\r\n\r\n    /*!\r\n     *  Parses an expression to decimal number.\r\n     *\r\n     *    @param [in]  expression         The expression to parse.\r\n     *    @param [out] validExpression    Set to true, if the parsing was successful, otherwise false.\r\n     *\r\n     *    @return The decimal value of the evaluated expression.\r\n     */\r\n    virtual QString parseExpression(QStringView expression, bool* validExpression = nullptr) const = 0;\r\n\r\n    /*!\r\n     *  Checks if the given expression is a plain value and does not need evaluation.\r\n     *\r\n     *    @param [in] expression   The expression to check.\r\n     *\r\n     *    @return True, if the expression is a plain value, otherwise false.\r\n     */\r\n    virtual bool isPlainValue(QStringView expression) const = 0;\r\n\r\n    /*!\r\n     *  Finds the common base in the expression.\r\n     *\r\n     *    @param [in] expression   The expression to search in.\r\n     *\r\n     *    @return The common base for the expression.\r\n     */\r\n    virtual int baseForExpression(QStringView expression) const = 0;\r\n};\r\n\r\n#endif // EXPRESSIONPARSER_H\r\n"
  },
  {
    "path": "KactusAPI/include/ExpressionParserInterface.h",
    "content": "//-----------------------------------------------------------------------------\n// File: ExpressionParserInterface.h\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Anton Hagqvist\n// Date: 26.09.2024\n//\n// Description:\n// Base class for parser interfaces for creating and handling expression parsers.\n//-----------------------------------------------------------------------------\n\n#ifndef EXPRESSIONPARSERINTERFACE_H\n#define EXPRESSIONPARSERINTERFACE_H\n\n#include <IPXACTmodels/Component/PortSlice.h>\n#include <IPXACTmodels/Component/FieldSlice.h>\n\n#include <KactusAPI/include/ExpressionParser.h>\n\nclass ExpressionParserInterface\n{\npublic:\n\n\tExpressionParserInterface() = default;\n\tvirtual ~ExpressionParserInterface() = default;\n\n\tExpressionParserInterface(const ExpressionParserInterface& other) = delete;\n\tExpressionParserInterface& operator=(const ExpressionParserInterface& other) = delete;\n\n\t/*!\n\t *\tCreate the expression parser.\n\t *  \n\t * \t    @return The created expression parser.\n\t */\n\tvirtual QSharedPointer<ExpressionParser> createParser() = 0;\n\n};\n\n#endif // EXPRESSIONPARSERINTERFACE_H"
  },
  {
    "path": "KactusAPI/include/ExpressionSupport.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ExpressionSupport.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Esko Pekkarinen\r\n// Date: 04.02.2015\r\n//\r\n// Description:\r\n// Interface for import plugins supporting expressions.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef EXPRESSIONSUPPORT_H\r\n#define EXPRESSIONSUPPORT_H\r\n\r\nclass ExpressionSupport \r\n{\r\npublic:\r\n\t//! The destructor.\r\n    virtual ~ExpressionSupport(){};\r\n\r\n    /*!\r\n     *  Sets the expression parser to use for parsing expressions.\r\n     *\r\n     *    @param [in] parser   The expression parser to use.\r\n     */\r\n    virtual void setExpressionParser(QSharedPointer<ExpressionParser> parser) = 0;\r\n};\r\n\r\n#endif // EXPRESSIONSUPPORT_H\r\n"
  },
  {
    "path": "KactusAPI/include/FieldExpressionsGatherer.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: FieldExpressionsGatherer.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Mikko Teuho\r\n// Date: 29.04.2015\r\n//\r\n// Description:\r\n// Gathers expressions from a field.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef FIELDEXPRESSIONSGATHERER_H\r\n#define FIELDEXPRESSIONSGATHERER_H\r\n\r\nclass Field;\r\n\r\n#include <QSharedPointer>\r\n#include <QStringList>\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Gathers expressions from a field.\r\n//-----------------------------------------------------------------------------\r\nclass FieldExpressionsGatherer\r\n{\r\n\r\npublic:\r\n\r\n    /*!\r\n     *  The constructor.\r\n     */\r\n    FieldExpressionsGatherer();\r\n\r\n    /*!\r\n     *  The destructor.\r\n     */\r\n    virtual ~FieldExpressionsGatherer();\r\n\r\n    /*!\r\n     *  Get the expressions from a given field.\r\n     *\r\n     *    @param [in] field   The given field.\r\n     *\r\n     *    @return A list containing all the expressions used in a field.\r\n     */\r\n    QStringList getExpressions(QSharedPointer<Field> field) const;\r\n\r\nprivate:\r\n\t\r\n\t//! No copying\r\n    FieldExpressionsGatherer(const FieldExpressionsGatherer& other);\r\n\r\n\t//! No assignment\r\n    FieldExpressionsGatherer& operator=(const FieldExpressionsGatherer& other);\r\n\r\n};\r\n\r\n#endif // FIELDEXPRESSIONSGATHERER_H\r\n"
  },
  {
    "path": "KactusAPI/include/FieldInterface.h",
    "content": "//-----------------------------------------------------------------------------\n// File: FieldInterface.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 07.04.2020\n//\n// Description:\n// Interface for editing fields.\n//-----------------------------------------------------------------------------\n\n#ifndef FIELDINTERFACE_H\n#define FIELDINTERFACE_H\n\n#include <KactusAPI/KactusAPIGlobal.h>\n\n#include <ParameterizableInterface.h>\n#include <NameGroupInterface.h>\n\n#include <IPXACTmodels/generaldeclarations.h>\n#include <IPXACTmodels/common/AccessTypes.h>\n\n#include <IPXACTmodels/Component/validators/FieldAccessPolicyValidator.h>\n\n#include <QVector>\n#include <QMap>\n\nclass Field;\nclass FieldValidator;\nclass ResetInterface;\nclass WriteValueConstraint;\nclass ModeReference;\nclass ModeReferenceInterface;\n\n//-----------------------------------------------------------------------------\n//! Interface for editing fields.\n//-----------------------------------------------------------------------------\nclass KACTUS2_API FieldInterface : public ParameterizableInterface, public NameGroupInterface\n{\n\npublic:\n\n    /*!\n     *  The constructor.\n     *\n     *    @param [in] validator               Validator for fields.\n     *    @param [in] expressionParser        Parser for expressions.\n     *    @param [in] expressionFormatter     Formatter for expressions.\n     *    @param [in] subInterface            Interface for accessing resets.\n     */\n    FieldInterface(QSharedPointer<FieldValidator> validator,\n        QSharedPointer<ExpressionParser> expressionParser,\n        QSharedPointer<ExpressionFormatter> expressionFormatter,\n        ResetInterface* subInterface);\n\t\n\t/*!\n     *  The destructor.\n     */\n    virtual ~FieldInterface() = default;\n\n    /*!\n     *  Set available fields.\n     *\n     *    @param [in] newFields   The new fields.\n     */\n    void setFields(QSharedPointer<QList<QSharedPointer<Field> > > newFields);\n\n    /*!\n     *  Get index of the selected item.\n     *\n     *    @param [in] itemName    Name of the selected item.\n     *\n     *    @return Index of the selected item.\n     */\n    virtual int getItemIndex(std::string const& itemName) const override final;\n\n    /*!\n     *  Get name of the indexed item.\n     *\n     *    @param [in] itemIndex   Index of the selected item.\n     *\n     *    @return Name of the selected item.\n     */\n    std::string getIndexedItemName(int itemIndex) const final;\n\n    /*!\n     *  Get the number of available items.\n     *\n     *    @return Number of available items.\n     */\n    virtual int itemCount() const override final;\n\n    /*!\n     *  Get the names of the available items.\n     *\n     *    @return Names of the available items.\n     */\n    virtual std::vector<std::string> getItemNames() const override final;\n\n    /*!\n     *  Set a new name for the selected item.\n     *\n     *    @param [in] currentName     Name of the selected item.\n     *    @param [in] newName         New name for the item.\n     *\n     *    @return True, if successful, false otherwise.\n     */\n    virtual bool setName(std::string const& currentName, std::string const& newName) override final;\n\n    /*!\n     *  Get the calculated offset value of the selected field.\n     *\n     *    @param [in] fieldName   Name of the selected field.\n     *    @param [in] baseNumber  Base for displaying the value.\n     *\n     *    @return Calculated offset value of the selected field.\n     */\n    std::string getOffsetValue(std::string const& fieldName, int const& baseNumber = 0) const;\n\n    /*!\n     *  Get the formatted offset expression of the selected field.\n     *\n     *    @param [in] fieldName   Name of the selected field.\n     *\n     *    @return Formatted offset expression of the selected field.\n     */\n    std::string getOffsetFormattedExpression(std::string const& fieldName) const;\n\n    /*!\n     *  Get the offset expression of the selected field.\n     *\n     *    @param [in] fieldName   Name of the selected field.\n     *\n     *    @return Offset expression of the selected field.\n     */\n    std::string getOffsetExpression(std::string const& fieldName) const;\n\n    /*!\n     *  Set a new offset value for the selected field.\n     *\n     *    @param [in] fieldName   Name of the selected field.\n     *    @param [in] newOffset   New offset value.\n     *\n     *    @return True, if successful, false otherwise.\n     */\n    bool setOffset(std::string const& fieldName, std::string const& newOffset);\n\n    /*!\n     *  Get the calculated bit width value of the selected field.\n     *\n     *    @param [in] fieldName   Name of the selected field.\n     *    @param [in] baseNumber  Base for displaying the value.\n     *\n     *    @return Calculated bit width value of the selected parameter.\n     */\n    std::string getWidthValue(std::string const& fieldName, int const& baseNumber = 0) const;\n    \n    /*!\n     *  Get the formatted bit width expression of the selected field.\n     *\n     *    @param [in] fieldName   Name of the selected field.\n     *\n     *    @return Formatted bit width expression of the selected field.\n     */\n    std::string getWidthFormattedExpression(std::string const& fieldName) const;\n\n    /*!\n     *  Get the bit width expression of the selected field.\n     *\n     *    @param [in] fieldName   Name of the selected field.\n     *\n     *    @return Bit width expression of the selected field.\n     */\n    std::string getWidthExpression(std::string const& fieldName) const;\n\n    /*!\n     *  Set a new bit width value for the selected field.\n     *\n     *    @param [in] fieldName   Name of the selected field.\n     *    @param [in] newWidth    New bit width value.\n     *\n     *    @return True, if successful, false otherwise.\n     */\n    bool setWidth(std::string const& fieldName, std::string const& newWidth);\n\n    /*!\n     *  Get the reset values of the selected field.\n     *\n     *    @param [in] fieldName   Name of the selected field.\n     *\n     *    @return Reset values of the selected field.\n     */\n    std::string getResets(std::string const& fieldName) const;\n\n    /*!\n     *  Get the tooltip of the reset values of the selected field.\n     *\n     *    @param [in] fieldName   Name of the selected field.\n     *\n     *    @return Tooltip constructed from the reset values of the selected field.\n     */\n    std::string getResetsToolTip(std::string const& fieldName) const;\n\n    /*!\n     *  Get the volatile status of the selected field.\n     *\n     *    @param [in] fieldName   Name of the selected field.\n     *\n     *    @return Volatile status of the selected field.\n     */\n    std::string getVolatile(std::string const& fieldName) const;\n\n    /*!\n     *  Set the volatile status of the selected field.\n     *\n     *    @param [in] fieldName       Name of the selected field.\n     *    @param [in] newVolatile     The new volatile status of the selected field.\n     *\n     *    @return True, if successful, false otherwise.\n     */\n    bool setVolatile(std::string const& fieldName, std::string const& newVolatile);\n\n    /*!\n     *  Get the access string of the selected field or field access policy.\n     *\n     *    @param [in] fieldName   Name of the selected field.\n     *    @param [in] accessPolicyIndex   Index of the selected field access policy.\n     *\n     *    @return Access string of the selected field or field access policy.\n     */\n    std::string getAccessString(std::string const& fieldName, int accessPolicyIndex = -1) const;\n\n    /*!\n     *  Get the access of the selected field or field access policy.\n     *\n     *    @param [in] fieldName           Name of the selected field.\n     *    @param [in] accessPolicyIndex   Index of the selected field access policy.\n     *\n     *    @return Access of the selected field or field access policy.\n     */\n    AccessTypes::Access getAccessType(std::string const& fieldName, int accessPolicyIndex = -1) const;\n\n    /*!\n     *  Set the access of the selected field or field access policy.\n     *\n     *    @param [in] fieldName           Name of the selected field.\n     *    @param [in] newAccess           The new access of the selected field.\n     *    @param [in] accessPolicyIndex   Index of the selected field access policy.\n     *\n     *    @return True, if successful, false otherwise.\n     */\n    bool setAccess(std::string const& fieldName, std::string const& accessType, int accessPolicyIndex = -1) const;\n\n    /*!\n     *  Get the modified write value string of the selected field or field access policy.\n     *\n     *    @param [in] fieldName           Name of the selected field.\n     *    @param [in] accessPolicyIndex   Index of the selected field access policy.\n     *\n     *    @return Modified write value string of the selected field or field access policy.\n     */\n    std::string getModifiedWriteString(std::string const& fieldName, int accessPolicyIndex = -1) const;\n\n    /*!\n     *  Get the modified write value of the selected field.\n     *\n     *    @param [in] fieldName   Name of the selected field.\n     *\n     *    @return Modified write value of the selected field.\n     */\n    General::ModifiedWrite getModifiedWriteValue(std::string const& fieldName) const;\n\n    /*!\n     *  Set the modified write value of the selected field or field access policy.\n     *\n     *    @param [in] fieldName           Name of the selected field.\n     *    @param [in] newModifiedWrite    The new modified write value of the selected field.\n     *    @param [in] accessPolicyIndex   Index of the selected field access policy.\n     *\n     *    @return True, if successful, false otherwise.\n     */\n    bool setModifiedWrite(std::string const& fieldName, std::string const& newModifiedWrite, \n        int accessPolicyIndex = -1);\n\n    /*!\n     *  Get the read action string of the selected field or field access policy.\n     *\n     *    @param [in] fieldName           Name of the selected field.\n     *    @param [in] accessPolicyIndex   Index of the selected field access policy.\n     *\n     *    @return Read action string of the selected field access policy of selected field.\n     */\n    std::string getReadActionString(std::string const& fieldName, int accessPolicyIndex = -1) const;\n\n    /*!\n     *  Get the read action of the selected field or field access policy.\n     *\n     *    @param [in] fieldName           Name of the selected field.\n     *    @param [in] accessPolicyIndex   The index of the selected field.\n     *\n     *    @return Read action of the selected field or field access policy.\n     */\n    General::ReadAction getReadAction(std::string const& fieldName, int accessPolicyIndex = -1) const;\n\n    /*!\n     *  Set the read action of the selected field or field access policy.\n     *\n     *    @param [in] fieldName               Name of the selected field.\n     *    @param [in] newReadAction           The new read action.\n     *    @param [in] accessPolicyIndex       Index of the selected field access policy.\n     *\n     *    @return True, if successful, false otherwise.\n     */\n    bool setReadAction(std::string const& fieldName, std::string const& newReadAction, int accessPolicyIndex = -1);\n\n    /*!\n     *  Get the testable string of the selected field access policy of a selected field.\n     *\n     *    @param [in] fieldName   Name of the selected field.\n     *    @param [in] accessPolicyIndex   Index of the selected field access policy.\n     *\n     *    @return Testable string of the selected field access policy.\n     */\n    std::string getTestableValue(std::string const& fieldName, int accessPolicyIndex = -1) const;\n\n    /*!\n     *  Get the testable bool of the selected field or field access policy. Access policy index is provided\n     *  only when getting the testable value of a field access policy within a 2022 std revision field.\n     *\n     *    @param [in] fieldName           Name of the selected field.\n     *    @param [in] accessPolicyIndex   The index of the selected field access policy.\n     *\n     *    @return Testable bool of the selected field.\n     */\n    bool getTestableBool(std::string const& fieldName, int accessPolicyIndex = -1) const;\n\n    /*!\n     *  Set the testable value of either a selected field or a selected field access policy within a field.\n     *  Access policy index is provided only when setting a testable value of a field access policy within a \n     *  std revision 2022 field.\n     *\n     *    @param [in] fieldName           Name of the selected field.\n     *    @param [in] newTestable         The new testable value of the selected field.\n     *    @param [in] accessPolicyIndex   The index of the selected field access policy.\n     *\n     *    @return True, if successful, false otherwise.\n     */\n    bool setTestable(std::string const& fieldName, std::string const& newTestable, int accessPolicyIndex = -1) const;\n\n    /*!\n     *  Get the test constraint string of the selected field.\n     *  Access policy index is provided only when getting the test constraint of a field access policy within a\n     *  2022 std revision field.\n     * \n     *    @param [in] fieldName           Name of the selected field.\n     *    @param [in] accessPolicyIndex   The index of the selected field access policy.\n     *\n     *    @return Test constraint string of the selected field.\n     */\n    std::string getTestConstraintString(std::string const& fieldName, int accessPolicyIndex = -1) const;\n\n    /*!\n     *  Get the test constraint of the selected field or field access policy. Access policy index is provided \n     *  only when getting the test constraint of a field access policy within a 2022 std revision field.\n     *\n     *    @param [in] fieldName           Name of the selected field.\n     *    @param [in] accessPolicyIndex   The index of the selected field access policy.\n     *\n     *    @return Test constraint of the selected field.\n     */\n    General::TestConstraint getTestConstraint(std::string const& fieldName, int accessPolicyIndex = -1) const;\n\n    /*!\n     *  Set the test constraint of the selected field or field access policy. Access policy index is provided\n     *  only when setting the test constraint of a field access policy within a 2022 std revision field.\n     *\n     *    @param [in] fieldName           Name of the selected field.\n     *    @param [in] newTestConstraint   The new test constraint of the selected field.\n     *    @param [in] accessPolicyIndex   The index of the selected field access policy.\n     *\n     *    @return True, if successful, false otherwise.\n     */\n    bool setTestConstraint(std::string const& fieldName, std::string const& newTestConstraint, int accessPolicyIndex = -1) const;\n\n    /*!\n     *  Get the calculated is present value of the selected field.\n     *\n     *    @param [in] fieldName   Name of the selected field.\n     *    @param [in] baseNumber  Base for displaying the value.\n     *\n     *    @return Calculated is present value of the selected field.\n     */\n    std::string getIsPresentValue(std::string const& fieldName, int const& baseNumber = 0) const;\n\n    /*!\n     *  Get the formatted is present expression of the selected field.\n     *\n     *    @param [in] fieldName   Name of the selected field.\n     *\n     *    @return Formatted is present expression of the selected field.\n     */\n    std::string getIsPresentFormattedExpression(std::string const& fieldName) const;\n\n    /*!\n     *  Get the is present expression of the selected field.\n     *\n     *    @param [in] fieldName   Name of the selected field.\n     *\n     *    @return Is present expression of the selected parameter.\n     */\n    std::string getIsPresentExpression(std::string const& fieldName) const;\n\n    /*!\n     *  Set a new is present value for the selected field.\n     *\n     *    @param [in] parameterName   Name of the selected parameter.\n     *    @param [in] newIsPresent    New is present value.\n     *\n     *    @return True, if successful, false otherwise.\n     */\n    bool setIsPresent(std::string const& fieldName, std::string const& newIsPresent);\n\n    /*!\n     *  Calculate all the references to the selected ID in the selected item.\n     *\n     *    @param [in] itemName    Name of the selected item.\n     *    @param [in] valueID     The selected ID.\n     *\n     *    @return Number of references to the selected ID in the selected item.\n     */\n    virtual int getAllReferencesToIdInItem(const std::string& itemName, std::string const&  valueID) const override final;\n\n    /*!\n     *  Validates the contained items.\n     *\n     *    @return True, if all the ports are valid, false otherwise.\n     */\n    virtual bool validateItems() const override final;\n\n    /*!\n     *  Check if the selected item has a valid name.\n     *\n     *    @param [in] itemName    Name of the selected item.\n     *\n     *    @return True, if the name is valid, false otherwise.\n     */\n    virtual bool itemHasValidName(std::string const& itemName) const override final;\n\n    /*!\n     *  Check if the selected field has a valid offset.\n     *\n     *    @param [in] fieldName   Name of the selected field.\n     *\n     *    @return True, if the offset is valid, false otherwise.\n     */\n    bool hasValidOffset(std::string const& fieldName) const;\n\n    /*!\n     *  Check if the selected field has a valid bit width.\n     *\n     *    @param [in] fieldName   Name of the selected field.\n     *\n     *    @return True, if the bit width is valid, false otherwise.\n     */\n    bool hasValidWidth(std::string const& fieldName) const;\n\n    /*!\n     *  Check if the selected field has valid reset values.\n     *\n     *    @param [in] fieldName   Name of the selected field.\n     *\n     *    @return True, if the reset values are valid, false otherwise.\n     */\n    bool hasValidResets(std::string const& fieldName) const;\n\n    /*!\n     *  Check if the selected field has a valid is present.\n     *\n     *    @param [in] fieldName   Name of the selected field.\n     *\n     *    @return True, if the is present is valid, false otherwise.\n     */\n    bool hasValidIsPresent(std::string const& fieldName) const;\n\n    /*!\n     *  Check if the selected field or field access policy has a valid access.\n     *\n     *    @param [in] fieldName           Name of the selected field.\n     *    @param [in] accessPolicyIndex   Index of the field access policy to validate.\n     *\n     *    @return True, if the access is valid, false otherwise.\n     */\n    bool hasValidAccess(std::string const& fieldName, int accessPolicyIndex = -1) const;\n\n    /*!\n     *  Check if the selected field access policy has a valid read response.\n     *\n     *    @param [in] fieldName           Name of the selected field.\n     *    @param [in] accessPolicyIndex   Index of the field access policy to validate.\n     *\n     *    @return True, if the read response is valid, false otherwise.\n     */\n    bool hasValidReadResponse(std::string const& fieldName, int accessPolicyIndex) const;\n\n    /*!\n     *  Check if the selected field access policy has a valid reserved value.\n     *\n     *    @param [in] fieldName           Name of the selected field.\n     *    @param [in] accessPolicyIndex   Index of the field access policy to validate.\n     *\n     *    @return True, if the reserved is valid, false otherwise.\n     */\n    bool hasValidReserved(std::string const& fieldName, int accessPolicyIndex) const;\n\n    /*!\n     *  Check if the selected field access policy has a valid write value constraint.\n     *\n     *    @param [in] fieldName           Name of the selected field.\n     *    @param [in] accessPolicyIndex   Index of the field access policy to validate.\n     *\n     *    @return True, if the write value constraint is valid, false otherwise.\n     */\n    bool hasValidWriteValueConstraint(std::string const& fieldName, int accessPolicyIndex) const;\n\n    /*!\n     *  Add a new field, inserting it to specified position given by row.\n     *\n     *    @param [in] row             Row of the new field.\n     *    @param [in] newFieldName    Name of the new field.\n     */\n    void addField(int const& row, std::string const& newFieldName = std::string(\"\"));\n\n    /*!\n     *  Add a new field.\n     *  This overload should be preferred when using Python.\n     *\n     *    @param [in] newFieldName    Name of the new field.\n     */\n    void addField(std::string const& newFieldName = std::string(\"\"));\n\n    /*!\n     *  Remove the selected field.\n     *\n     *    @param [in] FieldName   Name of the selected field.\n     *\n     *    @return True, if successful, false otherwise.\n     */\n    bool removeField(std::string const& fieldName);\n\n    /*!\n     *  Copy the selected fields.\n     *\n     *    @param [in] selectedRows    Indexes of the selected fields.\n     */\n    void copyRows(std::vector<int> const& selectedRows);\n\n    /*!\n     *  Paste the selected fields.\n     *\n     *    @return Names of the pasted fields.\n     */\n    std::vector<std::string> pasteRows();\n\n    /*!\n     *  Get the number of pasted fields.\n     *\n     *    @return Number of the pasted fields.\n     */\n    int getPasteRowCount() const;\n\n    /*!\n     *  Get the expressions in the selected fields.\n     *\n     *    @param [in] fieldNames  Names of the selected fields.\n     *\n     *    @return The expressions of the selected fields.\n     */\n    std::vector<std::string> getExpressionsInSelectedFields(std::vector<std::string> const& fieldNames) const;\n\n    /*!\n     *  Get the sub interface.\n     *\n     *    @return Interface for accessing resets.\n     */\n    ResetInterface* getSubInterface() const;\n\n    /*!\n     *  Check if the selected field or field access policy has a write value constraint. Access policy index is \n     *  provided only when checking the existence of a write constraint of a field access policy within a 2022 \n     *  std revision field.\n     *\n     *    @param [in] fieldName           Name of the selected field.\n     *\n     *    @return True, if the selected field or field access policy has write value constraint, false otherwise.\n     */\n    bool hasWriteConstraint(std::string const& fieldName) const;\n\n    /*!\n     *  Get the write value constraint type of the selected field or field access policy.\n     *\n     *    @param [in] fieldName           Name of the selected field.\n     *    @param [in] accessPolicyIndex   The index of the selected field access policy.\n     *\n     *    @return The write value constraint type of the selected field or field access policy.\n     */\n    std::string getWriteConstraint(std::string const& fieldName, int accessPolicyIndex = -1) const;\n\n    /*!\n     *  Set a new write value constraint type for the selected field or field access policy.\n     * \n     *    @param [in] fieldName           Name of the selected field.\n     *    @param [in] newConstraintText   The new write value constraint type.\n     *    @param [in] accessPolicyIndex   The index of the selected field access policy.\n     *\n     *    @return True, if successful, false otherwise.\n     */\n    bool setWriteConstraint(std::string const& fieldName, std::string const& newConstraintText,\n        int accessPolicyIndex = -1);\n\n    /*!\n     *  Get the calculated write value constraint minimum value of the selected field or field access policy.\n     *\n     *    @param [in] fieldName           Name of the selected field.\n     *    @param [in] accessPolicyIndex   The index of the selected field access policy.\n     *    @param [in] baseNumber          Base for displaying the value.\n     *\n     *    @return Calculated write value constraint minimum value of the selected field or field access policy.\n     */\n    std::string getWriteConstraintMinimumValue(std::string const& fieldName, int accessPolicyIndex = -1,\n        int const& baseNumber = 0) const;\n\n    /*!\n     *  Get the formatted write value constraint minimum expression of the selected field or field access policy.\n     *\n     *    @param [in] fieldName           Name of the selected field.\n     *    @param [in] accessPolicyIndex   The index of the selected field access policy.\n     * \n     *    @return Formatted write value constraint minimum expression of the selected field or field access policy.\n     */\n    std::string getWriteConstraintMinimumFormattedExpression(std::string const& fieldName,\n        int accessPolicyIndex = -1) const;\n\n    /*!\n     *  Get the write value constraint minimum expression of the selected field or field access policy.\n     *\n     *    @param [in] fieldName           Name of the selected field.\n     *    @param [in] accessPolicyIndex   The index of the selected field access policy.\n     *\n     *    @return Write value constraint minimum expression of the selected parameter.\n     */\n    std::string getWriteConstraintMinimumExpression(std::string const& fieldName, int accessPolicyIndex = -1) const;\n\n    /*!\n     *  Set a new write value constraint minimum value for the selected field or field access policy.\n     *\n     *    @param [in] parameterName               Name of the selected parameter.\n     *    @param [in] newWriteConstraintMinimum   New write value constraint minimum value.\n     *    @param [in] accessPolicyIndex           The index of the selected field access policy.\n     *\n     *    @return True, if successful, false otherwise.\n     */\n    bool setWriteConstraintMinimum(std::string const& fieldName, std::string const& newWriteConstraintMinimum,\n        int accessPolicyIndex = -1);\n\n    /*!\n     *  Get the calculated write value constraint maximum value of the selected field or field access policy.\n     *\n     *    @param [in] fieldName           Name of the selected field.\n     *    @param [in] accessPolicyIndex   The index of the selected field access policy.\n     *    @param [in] baseNumber          Base for displaying the value.\n     *\n     *    @return Calculated write value constraint maximum value of the selected field or field access policy.\n     */\n    std::string getWriteConstraintMaximumValue(std::string const& fieldName, int accessPolicyIndex = -1,\n        int const& baseNumber = 0) const;\n\n    /*!\n     *  Get the formatted write value constraint maximum expression of the selected field or field access policy.\n     *\n     *    @param [in] fieldName           Name of the selected field.\n     *    @param [in] accessPolicyIndex   The index of the selected field access policy.\n     *\n     *    @return Formatted write value constraint maximum expression of the selected field or field access policy.\n     */\n    std::string getWriteConstraintMaximumFormattedExpression(std::string const& fieldName,\n        int accessPolicyIndex = -1) const;\n\n    /*!\n     *  Get the write value constraint maximum expression of the selected field or field access policy.\n     *\n     *    @param [in] fieldName           Name of the selected field.\n     *    @param [in] accessPolicyIndex   The index of the selected field access policy.\n     *\n     *    @return Write value constraint maximum expression of the selected parameter.\n     */\n    std::string getWriteConstraintMaximumExpression(std::string const& fieldName, int accessPolicyIndex = -1) const;\n\n    /*!\n     *  Set a new write value constraint maximum value for the selected field or field access policy.\n     *\n     *    @param [in] parameterName               Name of the selected parameter.\n     *    @param [in] newWriteConstraintMaximum   New write value constraint maximum value.\n     *    @param [in] accessPolicyIndex           The index of the selected field access policy.\n     *\n     *    @return True, if successful, false otherwise.\n     */\n    bool setWriteConstraintMaximum(std::string const& fieldName, std::string const& newWriteConstraintMaximum,\n        int accessPolicyIndex = -1);\n\n    /*!\n     *  Get the calculated reserved value of the selected field or field access policy, which can be specified\n     *  by index, for getting the reserved value from a field access policy of a 2022 standard compliant field.\n     *\n     *    @param [in] fieldName           Name of the selected field.\n     *    @param [in] accessPolicyIndex   The selected access policy index.\n     *    @param [in] baseNumber          Base for displaying the value.\n     *\n     *    @return Calculated reserved value of the selected field.\n     */\n    std::string getReservedValue(std::string const& fieldName, int accessPolicyIndex = -1,\n        int const& baseNumber = 0) const;\n\n    /*!\n     *  Get the formatted reserved expression of the selected field or field access policy.\n     *\n     *    @param [in] fieldName           Name of the selected field.\n     *    @param [in] accessPolicyIndex   The index of the selected field access policy.\n     *\n     *    @return Formatted reserved expression of the selected field or field access policy.\n     */\n    std::string getReservedFormattedExpression(std::string const& fieldName, int accessPolicyIndex = -1) const;\n\n    /*!\n     *  Get the reserved expression of the selected field or field access policy.\n     *\n     *    @param [in] fieldName           Name of the selected field.\n     *    @param [in] accessPolicyIndex   The index of the selected field access policy.\n     *\n     *    @return Reserved expression of the selected parameter.\n     */\n    std::string getReservedExpression(std::string const& fieldName, int accessPolicyIndex = -1) const;\n\n    /*!\n     *  Set a new reserved value for the selected field or field access policy.\n     *\n     *    @param [in] parameterName       Name of the selected parameter.\n     *    @param [in] newReserved         New reserved value.\n     *    @param [in] accessPolicyIndex   The index of the selected field access policy.\n     *\n     *    @return True, if successful, false otherwise.\n     */\n    bool setReserved(std::string const& fieldName, std::string const& newReserved, int accessPolicyIndex = -1);\n\n    /*!\n     *  Get the ID of the selected field.\n     *\n     *    @param [in] fieldName   Name of the selected field.\n     *\n     *    @return ID of the selected field.\n     */\n    std::string getID(std::string const& fieldName);\n\n    /*!\n     *  Set a ID for the selected field.\n     *\n     *    @param [in] parameterName   Name of the selected parameter.\n     *    @param [in] newID           New ID.\n     *\n     *    @return True, if successful, false otherwise.\n     */\n    bool setID(std::string const& fieldName, std::string const& newID);\n\n    /*!\n     *\tAdd a new field access policy to a selected field.\n     *  \n     *    @param [in] fieldName     The field to add a new access policy to.\n     *\t    \n     * \t    @return True, if successful, otherwise false.\n     */\n    bool addFieldAccessPolicy(std::string const& fieldName);\n\n    /*!\n     *\tRemove the given field access policy from a specific field.\n     *  \n     *    @param [in] fieldName             The name of the field.\n     *    @param [in] accessPolicyIndex     The index of the field access policy to be removed.\n     *\t    \n     * \t    @return True, if successful, otherwise false.\n     */\n    bool removeFieldAccessPolicy(std::string const& fieldName, int accessPolicyIndex);\n\n    /*!\n     *\tGet the mode references of a given field access policy.\n     *  \n     *    @param [in] fieldName               The name of the field.\n     *    @param [in] accessPolicyIndex       Index of the field access policy.\n     *\t    \n     * \t    @return A vector containing the mode references as a string-int pair.\n     */\n    std::vector<std::pair<std::string, unsigned int> > getModeRefs(std::string const& fieldName, int accessPolicyIndex) const;\n\n    /*!\n     *\tGet all mode references of field access policies except for the one given by index.\n     *  \n     *    @param [in] fieldName               The field containing the field access policies.\n     *    @param [in] accessPolicyIndex       The index of the access policy whose mode references are not to get.\n     *\t    \n     * \t    @return  All mode references, except for mode references of field access policy given by index.\n     */\n    std::vector<std::pair<unsigned int, std::string> > getModeReferencesInUse(std::string const& fieldName, int accessPolicyIndex) const;\n\n    /*!\n     *\tGet mode references of given field access policy.\n     *  \n     *    @param [in] fieldName               The name of the field, which contains the field access policy.\n     *    @param [in] accessPolicyIndex       Index of the field access policy whose mode references to get.\n     *\t    \n     * \t    @return  The mode references of the field access policy.\n     */\n    std::vector<std::pair<unsigned int, std::string> > getModeReferences(std::string const& fieldName, int accessPolicyIndex) const;\n\n    /*!\n     *\tSet the mode references of a field access policy.\n     *  \n     *    @param [in] fieldName               The name of the field, which contains the field access policy.\n     *    @param [in] accessPolicyIndex       Index of the field access policy whose mode references to set.\n     *    @param [in] newModeRefs             The mode references to set.\n     *\t    \n     * \t    @return True, if the operation was successful, otherwise false.\n     */\n    bool setModeReferences(std::string const& fieldName, int accessPolicyIndex, std::vector<std::pair<unsigned int, std::string> > const& newModeRefs);\n\n    /*!\n     *\tGet the access policy count of the given field.\n     *  \n     *    @param [in] fieldName     Description\n     *\t    \n     * \t    @return The number of field access policies in the given field.\n     */\n    int getAccessPolicyCount(std::string const& fieldName) const;\n\n    /*!\n     *\tGet the read response of a field access policy as an expression.\n     *  \n     *    @param [in] fieldName               The name of the field.\n     *    @param [in] accessPolicyIndex       Index of the field access policy.\n     *\n     * \t    @return The read response as an expression.\n     */\n    std::string getReadResponseExpression(std::string const& fieldName, int accessPolicyIndex) const;\n\n    /*!\n     *\tGet the read response of a field access policy as a formatted expression.\n     *  \n     *    @param [in] fieldName               The name of the field.\n     *    @param [in] accessPolicyIndex       Index of the field access policy.\n     *\n     * \t    @return The read response as a formatted expression.\n     */\n    std::string getReadResponseFormattedExpression(std::string const& fieldName, int accessPolicyIndex) const;\n\n    /*!\n     *\tGet the evaluated read response value of a field access policy.\n     *  \n     *    @param [in] fieldName             The name of the field.\n     *    @param [in] accessPolicyIndex     Index of the field access policy.\n     *    @param [in] baseNumber            Base for displaying the value.\n     *\t    \n     * \t    @return The evaluated read response.\n     */\n    std::string getReadResponseValue(std::string const& fieldName, int accessPolicyIndex, int baseNumber = 0) const;\n\n    /*!\n     *\tSet the read response of a selected field access policy.\n     *  \n     *    @param [in] fieldName             The name of the field.\n     *    @param [in] accessPolicyIndex     Index of the field access policy.\n     *    @param [in] newReadResponse       The read response to set.\n     *\t    \n     * \t    @return True, if successful, otherwise false.\n     */\n    bool setReadResponse(std::string const& fieldName, int accessPolicyIndex, std::string const& newReadResponse) const;\n\n    /*!\n     *\tGet the number of references to a parameter used in the different sub-elements of the field access policy.\n     *  \n     *    @param [in] fieldName             The name of the field.\n     *    @param [in] accessPolicyIndex     Index of the field access policy.\n     *    @param [in] valueID               The parameter (ID) to check.\n     *\t    \n     * \t    @return The number of references to a parameter used within the field access policy.\n     */\n    int getAllReferencesToIdInFieldAccessPolicy(std::string const& fieldName, int accessPolicyIndex, std::string const& valueID) const;\n\n    /*!\n     *\tChecks if the field access policy given by index has valid mode references.\n     *  \n     *    @param [in] fieldName               The name of the field.\n     *    @param [in] accessPolicyIndex       The index of the field access policy to check.\n     *\t    \n     * \t    @return True, if the field access policy's mode references are valid, otherwise false.\n     */\n    bool hasValidAccessPolicyModeRefs(std::string const& fieldName, int accessPolicyIndex) const;\n\n    /*!\n     *\tCopy selected field access policies to clipboard.\n     *  \n     *    @param [in] fieldName                  The field containing the access policies.\n     *    @param [in] selectedAccessPolicies     List containing the indices of the selected access policies.\n     */\n    void copyFieldAccessPolicies(std::string const& fieldName, std::vector<int> const& selectedAccessPolicies);\n    \n    /*!\n     *\tPaste the selected field access policies.\n     *  \n     *    @param [in] fieldName     The name of the field to paste into.\n     *\t    \n     * \t    @return  The number of pasted field access policies.\n     */\n    int pasteFieldaccessPolicies(std::string const& fieldName);\n\n    /*!\n     *\tSet the mode reference interface to be used.\n     *  \n     *    @param [in] modeRefInterface     The mode reference interface to be used.\n     */\n    void setModeReferenceInterface(ModeReferenceInterface* modeRefInterface);\n\n    /*!\n     *\tGet the mode reference interface in use.\n     *  \n     * \t    @return The mode reference interface.\n     */\n    ModeReferenceInterface* getModeReferenceInterface() const;\n\nprivate:\n\n    /*!\n     *  Get the selected field.\n     *\n     *    @param [in] fieldName   Name of the selected field.\n     *\n     *    @return The selected field.\n     */\n    QSharedPointer<Field> getField(std::string const& fieldName) const;\n    \n    /*!\n     *  Get the field with the selected name, sliced to a NameGroup.\n     *\n     *    @param [in] fieldName    Name of the selected field.\n     *\n     *    @return The sliced field with the selected name.\n     */\n    QSharedPointer<NameGroup> getItem(std::string const& fieldName) const override;\n\n    /*!\n     *  Get the write value constraing of the selected field.\n     *\n     *    @param [in] fieldName   Name of the selected field.\n     *\n     *    @return Write value constraint of the selected field.\n     */\n    QSharedPointer<WriteValueConstraint> getWriteValueConstraint(std::string const& fieldName, int accessPolicyIndex = -1) const;\n\n    //-----------------------------------------------------------------------------\n    // Data.\n    //-----------------------------------------------------------------------------\n\n    //! List of the contained fields.\n    QSharedPointer<QList<QSharedPointer<Field> > > fields_;\n\n    //! Validator for fields.\n    QSharedPointer<FieldValidator> validator_;\n\n    //! Validator for field access policies.\n    FieldAccessPolicyValidator accessPolicyValidator_;\n\n    //! Interface for accessing resets.\n    ResetInterface* subInterface_;\n\n    //! Interface for accessing mode references.\n    ModeReferenceInterface* modeReferenceInterface_;\n    \n};\n\n#endif // REGISTERTABLEMODEL_H\n"
  },
  {
    "path": "KactusAPI/include/FileBuilderInterface.h",
    "content": "//-----------------------------------------------------------------------------\n// File: FileBuilderInterface.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 03.09.2020\n//\n// Description:\n// Interface for editing file builders.\n//-----------------------------------------------------------------------------\n\n#ifndef FILEBUILDERINTERFACE_H\n#define FILEBUILDERINTERFACE_H\n\n#include <KactusAPI/KactusAPIGlobal.h>\n\n#include <ParameterizableInterface.h>\n#include <CommonInterface.h>\n\n#include <QSharedPointer>\n#include <QVector>\n#include <QMap>\n\nclass FileBuilder;\n\n//-----------------------------------------------------------------------------\n//! Interface for editing file builders.\n//-----------------------------------------------------------------------------\nclass KACTUS2_API FileBuilderInterface : public ParameterizableInterface, public CommonInterface\n{\n\npublic:\n\n    /*!\n     *  The constructor.\n     *\n     *    @param [in] expressionParser        Parser for expressions.\n     *    @param [in] expressionFormatter     Formatter for expressions.\n     */\n    FileBuilderInterface(QSharedPointer<ExpressionParser> expressionParser,\n        QSharedPointer<ExpressionFormatter> expressionFormatter);\n\n\t/*!\n     *  The destructor.\n     */\n    virtual ~FileBuilderInterface() = default;\n\n    /*!\n     *  Set available file builders.\n     *\n     *    @param [in] newFileBuilders     The new file builders.\n     */\n    void setFileBuilders(QSharedPointer<QList<QSharedPointer<FileBuilder> > > newFileBuilders);\n\n    /*!\n     *  Get the number of available items.\n     *\n     *    @return Number of available items.\n     */\n    virtual int itemCount() const override final;\n\n    /*!\n     *  Validates the contained items.\n     *\n     *    @return True, if all the items are valid, false otherwise.\n     */\n    virtual bool validateItems() const;\n\n    /*!\n     *  Get the names of the available items.\n     *\n     *    @return Names of the available items.\n     */\n    virtual std::vector<std::string> getItemNames() const override final;\n\n    /*!\n     *  Calculate all the references to the selected ID in the selected item.\n     *\n     *    @param [in] itemName    Name of the selected item.\n     *    @param [in] valueID     The selected ID.\n     *\n     *    @return Number of references to the selected ID in the selected item.\n     */\n    virtual int getAllReferencesToIdInItem(const std::string& itemName, std::string const& valueID) const override\n        final;\n\n    /*!\n     *  Get the expressions in the selected file builders.\n     *\n     *    @param [in] fileBuilderNames    Names of the selected file builders.\n     *\n     *    @return The expressions of the selected file builders.\n     */\n    std::vector<std::string> getExpressionsInSelectedFileBuilders(std::vector<std::string> fileBuilderNames) const;\n\n     /*!\n      *  Add a new file builder, inserting it to the position given by row.\n      *\n      *    @param [in] row                 Row of the new file builder.\n      *    @param [in] newFileBuilderName  Name of the new file builder.\n      */\n    void addFileBuilder(int const& row, std::string const& newFileBuilderName = std::string(\"\"));\n    \n    /*!\n     *  Add a new file builder.\n     *  This overload should be preferred when using Python.\n     * \n     *    @param [in] newFileBuilderName  Name of the new file builder.\n     */\n    void addFileBuilder(std::string const& newFileBuilderName = std::string(\"\"));\n\n    /*!\n     *  Remove the selected file builder.\n     *\n     *    @param [in] fileBuilderName     Name of the selected file builder.\n     *\n     *    @return True, if successful, false otherwise.\n     */\n    bool removeFileBuilder(std::string const& fileBuilderName);\n\n    /*!\n     *  Get the file type of the indexed file builder.\n     *\n     *    @param [in] itemIndex   Index of the selected file builder.\n     *\n     *    @return File type of the selected file builder.\n     */\n    std::string getIndexedFileType(int const& itemIndex);\n\n    /*!\n     *  Set a new file type for the selected item.\n     *\n     *    @param [in] currentFileType     File type of the selected item.\n     *    @param [in] newFileType         The new file type for the item.\n     *\n     *    @return True, if successful, false otherwise.\n     */\n    bool setFileType(std::string const& currentFileType, std::string const& newFileType);\n\n    /*!\n     *  Get the command of the selected item.\n     *\n     *    @param [in] fileType    File type of the selected item.\n     *\n     *    @return Command of the selected item.\n     */\n    std::string getCommand(std::string const& fileType) const;\n\n    /*!\n     *  Set a new command for the selected item.\n     *\n     *    @param [in] fileType    File type of the selected item.\n     *    @param [in] newCommand  The new command for the item.\n     *\n     *    @return True, if successful, false otherwise.\n     */\n    bool setCommand(std::string const& fileType, std::string const& newCommand);\n\n    /*!\n     *  Get the flags of the selected item.\n     *\n     *    @param [in] fileType    File type of the selected item.\n     *\n     *    @return Flags of the selected item.\n     */\n    std::string getFlags(std::string const& fileType) const;\n\n    /*!\n     *  Set new flags value for the selected item.\n     *\n     *    @param [in] fileType    File type of the selected item.\n     *    @param [in] newFlags    The new flags value.\n     *\n     *    @return True, if successful, false otherwise.\n     */\n    bool setFlags(std::string const& fileType, std::string const& newFlags);\n\n    /*!\n     *  Get the calculated replace default flags value of the selected item.\n     *\n     *    @param [in] fileType    The selected file type.\n     *    @param [in] baseNumber  Base for displaying the value.\n     *\n     *    @return Calculated replace default flags value of the selected item.\n     */\n    std::string getReplaceDefaultFlagsValue(std::string const& fileType, int const& baseNumber = 0) const;\n\n    /*!\n     *  Get the formatted replace default flags expression of the selected item.\n     *\n     *    @param [in] fileType    The selected file type.\n     *\n     *    @return Formatted replace default flags expression of the selected item.\n     */\n    std::string getReplaceDefaultFlagsFormattedExpression(std::string const& fileType) const;\n\n    /*!\n     *  Get the replace default flags expression of the selected item.\n     *\n     *    @param [in] fileType    The selected file type.\n     *\n     *    @return Replace default flags expression of the selected file.\n     */\n    std::string getReplaceDefaultFlagsExpression(std::string const& fileType) const;\n\n    /*!\n     *  Set a new replace default flags value for the selected item.\n     *\n     *    @param [in] fileType                The selected file type.\n     *    @param [in] newReplaceDefaultFlags  New replace default flags value.\n     *\n     *    @return True, if successful, false otherwise.\n     */\n    bool setReplaceDefaultFlags(std::string const& filetype, std::string const& newReplaceDefaultFlags);\n\nprivate:\n\n    /*!\n     *  Get the selected file builder.\n     *\n     *    @param [in] fileBuilderName     Name of the selected file builder.\n     *\n     *    @return The selected file builder.\n     */\n    QSharedPointer<FileBuilder> getFileBuilder(std::string const& fileBuilderName) const;\n\n    //-----------------------------------------------------------------------------\n    // Data.\n    //-----------------------------------------------------------------------------\n\n    //! List of the contained file builders.\n    QSharedPointer<QList<QSharedPointer<FileBuilder> > > fileBuilders_;\n};\n\n#endif // FILEBUILDCOMMANDINTERFACE_H\n"
  },
  {
    "path": "KactusAPI/include/FileHandler.h",
    "content": "//-----------------------------------------------------------------------------\n// File: FileHandler.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 08.10.2019\n//\n// Description:\n// Handles data regarding files.\n//-----------------------------------------------------------------------------\n\n#ifndef FILEHANDLER_H\n#define FILEHANDLER_H\n\n#include \"KactusAPI/KactusAPIGlobal.h\"\n\n#include <QMultiMap>\n#include <QRegularExpression>\n#include <QString>\n\n//-----------------------------------------------------------------------------\n//! Handles data regarding files.\n//-----------------------------------------------------------------------------\nnamespace FileHandler\n{\n    //! Regular expression to validate URLs.\n    const QRegularExpression URL_VALIDITY_REG_EXP = QRegularExpression(\n        \"^[a-z]{3,9}[:][/]{2}[a-z0-9]+([-.][a-z0-9]+)*([/][-a-z0-9_.;,?=&%#~+]*)*$\",\n        QRegularExpression::CaseInsensitiveOption);\n\n    /*!\n     *  Construct a table for file types.\n     *\n     *    @return Table with file extension as key and file type as value.\n     */\n    KACTUS2_API QMultiMap<QString, QString> constructFileSuffixTable();\n\n    /*!\n     *  Get a file type for the selected file extension.\n     *\n     *    @param [in] fileSuffixTable     Table containing file types combined with file name extensions.\n     *    @param [in] suffix              The selected extension.\n     *\n     *    @return File type matching the selected extension.\n     */\n    KACTUS2_API QString getFileTypeForSuffix(QMultiMap<QString, QString> const& fileSuffixTable, QString const& suffix);\n\n    /*!\n     *  Resolve environment variables in a given URI to form a file path.\n     *\n     *    @param [in] ipxactURI\n     *\n     *    @return The resolved file path.\n     */\n    KACTUS2_API QString resolvePath(QString const& ipxactURI);\n\n    /*!\n     *  Resolve environment variables in a given URI to form a URI.\n     *\n     *    @param [in] ipxactURI\n     *\n     *    @return The resolved URI.\n     */\n    KACTUS2_API QString resolveURI(QString const& ipxactURI);\n\n    /*!\n     *  Check if given ipxactURI is valid.\n     *\n     *    @param [in] relativeTo  Path to resolve relative file paths from.\n     *    @param [in] ipxactURI   The URI to check.\n     *\n     *    @return True, if the ipxactURI is valid, otherwise false.\n     */\n    KACTUS2_API bool isValidURI(QString const& relativeTo, QString const& ipxactURI);\n\n    /*!\n     *  Check if given file path exists in the file system.\n     *\n     *    @param [in] relativeTo  Path to resolve relative file paths from.\n     *    @param [in] filePath    The path to check.\n     *\n     *    @return True, if the path exists, otherwise false.\n     */\n    KACTUS2_API bool filePathExists(QString const& relativeTo, QString const& filePath);\n\n    /*!\n     *  Check if given input is a URI.\n     *\n     *    @param [in] uri The input to check.\n     *\n     *    @return True, if the input is a URI, otherwise false.\n     */\n    KACTUS2_API bool isURI(QString const& uri);\n\n    /*!\n     *  Modify the selected path to include the selected extension in the end.\n     *\n     *    @param [in] filePath      The selected file path.\n     *    @param [in] extension     The selected file extension.\n     *\n     *    @return The modified file path.\n     */\n    KACTUS2_API QString getModifiedPathWithExtension(QString const& filePath, QString const& extension);\n};\n\n#endif // FILEHANDLER_H\n\n"
  },
  {
    "path": "KactusAPI/include/FileInterface.h",
    "content": "//-----------------------------------------------------------------------------\n// File: FileInterface.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 29.06.2020\n//\n// Description:\n// Interface for editing files.\n//-----------------------------------------------------------------------------\n\n#ifndef FILEINTERFACE_H\n#define FILEINTERFACE_H\n\n#include <KactusAPI/KactusAPIGlobal.h>\n\n#include <ParameterizableInterface.h>\n#include <NameGroupInterface.h>\n#include <IPXACTmodels/common/NameGroup.h>\n\nclass File;\nclass BuildCommand;\nclass FileValidator;\n\n#include <QSharedPointer>\n#include <QVector>\n#include <QMap>\n\n//-----------------------------------------------------------------------------\n//! Interface for editing files.\n//-----------------------------------------------------------------------------\nclass KACTUS2_API FileInterface: public ParameterizableInterface, public NameGroupInterface\n{\n\npublic:\n\n    /*!\n     *  The constructor.\n     *\n     *    @param [in] validator               Validator for files.\n     *    @param [in] expressionParser        Parser for expressions.\n     *    @param [in] expressionFormatter     Formatter for expressions.\n     */\n    FileInterface(QSharedPointer<FileValidator> validator, QSharedPointer<ExpressionParser> expressionParser,\n        QSharedPointer<ExpressionFormatter> expressionFormatter);\n\t\n\t/*!\n     *  The destructor.\n     */\n     virtual ~FileInterface() = default;\n\n    /*!\n     *  Set available files.\n     *\n     *    @param [in] newFiles    The new files.\n     */\n    void setFiles(QSharedPointer<QList<QSharedPointer<File> > > newFiles);\n\n    /*!\n     *  Get index of the selected item.\n     *\n     *    @param [in] itemName    Name of the selected item.\n     *\n     *    @return Index of the selected item.\n     */\n    virtual int getItemIndex(std::string const& itemName) const override final;\n\n    /*!\n     *  Get name of the indexed item.\n     *\n     *    @param [in] itemIndex   Index of the selected item.\n     *\n     *    @return Name of the selected item.\n     */\n    std::string getIndexedItemName(int itemIndex) const final;\n\n    /*!\n     *  Get the number of available items.\n     *\n     *    @return Number of available items.\n     */\n    virtual int itemCount() const override final;\n\n    /*!\n     *  Get the names of the available items.\n     *\n     *    @return Names of the available items.\n     */\n    virtual std::vector<std::string> getItemNames() const override final;\n\n    /*!\n     *  Set a new name for the selected item.\n     *\n     *    @param [in] currentName     Name of the selected item.\n     *    @param [in] newName         New name for the item.\n     *\n     *    @return True, if successful, false otherwise.\n     */\n    virtual bool setName(std::string const& currentName, std::string const& newName) override final;\n\n    /*!\n     *  Get the description of the selected item.\n     *  Can't inherit this function from NameGroupInterface, as File doesn't inherit from NameGroup.\n     *\n     *    @param [in] itemName    Name of the selected item.\n     *\n     *    @return Description of the selected item.\n     */\n    std::string getDescription(std::string const& itemName) const override;\n\n    /*!\n     *  Set a new description for the selected item.\n     *  Can't inherit this function from NameGroupInterface, as File doesn't inherit from NameGroup.\n     * \n     *    @param [in] itemName        Name of the selected item.\n     *    @param [in] newDescription  New description.\n     *\n     *    @return True, if successful, false otherwise.\n     */\n    bool setDescription(std::string const& itemName, std::string const& newDescription) override;\n\n    /*!\n     *  Validates the contained items.\n     *\n     *    @return True, if all the ports are valid, false otherwise.\n     */\n    virtual bool validateItems() const override final;\n\n    /*!\n     *  Check if the selected item has a valid name.\n     *\n     *    @param [in] itemName    Name of the selected item.\n     *\n     *    @return True, if the name is valid, false otherwise.\n     */\n    virtual bool itemHasValidName(std::string const& itemName) const override final;\n\n    /*!\n     *  Calculate all the references to the selected ID in the selected file.\n     *\n     *    @param [in] fileName    Name of the selected item.\n     *    @param [in] valueID     The selected ID.\n     *\n     *    @return Number of references to the selected ID in the selected file.\n     */\n    virtual int getAllReferencesToIdInItem(const std::string& fileName, std::string const& valueID) const override\n        final;\n\n    /*!\n     *  Get the expressions in the selected files.\n     *\n     *    @param [in] fileNames   Names of the selected files.\n     *\n     *    @return The expressions of the selected files.\n     */\n    std::vector<std::string> getExpressionsInSelectedFiles(std::vector<std::string> fileNames) const;\n\n    /*!\n     *  Add a new file, inserting it to a specified position given by row.\n     *\n     *    @param [in] row             Row of the new file.\n     *    @param [in] newFileName     Name of the new file.\n     */\n    void addFile(int const& row, std::string const& newFileName = std::string(\"\"));\n\n    /*!\n     *  Add a new file.\n     *  This overload should be preferred when using Python.\n     * \n     *    @param [in] newFileName     Name of the new file.\n     */\n    void addFile(std::string const& newFileName = std::string(\"\"));\n\n    /*!\n     *  Remove the selected file.\n     *\n     *    @param [in] fileName    Name of the selected file.\n     *\n     *    @return True, if successful, false otherwise.\n     */\n    bool removeFile(std::string const& fileName);\n\n    /*!\n     *  Swap the positions of the selected files.\n     *\n     *    @param [in] firstIndex      Index of the first file.\n     *    @param [in] secondIndex     Index of the second file.\n     */\n    void swapFiles(int const& firstIndex, int const& secondIndex);\n\n    /*!\n     *  Get the logical name of a file.\n     *\n     *    @param [in] fileName    Name of the selected file.\n     *\n     *    @return Logical name of the selected file.\n     */\n    std::string getLogicalName(std::string const& fileName) const;\n\n    /*!\n     *  Set a new logical name.\n     *\n     *    @param [in] fileName        Name of the selected file.\n     *    @param [in] newLogicalName  The new logical name.\n     *\n     *    @return True, if successful, false otherwise.\n     */\n    bool setLogicalName(std::string const& fileName, std::string newLogicalName);\n\n    /*!\n     *  Get the default-attribute value of the logicalName element.\n     *\n     *    @param [in] fileName    Name of the selected file.\n     *\n     *    @return True of the logical name is default, otherwise false.\n     */\n    bool isLogicalNameDefault(std::string const& fileName) const;\n\n    /*!\n     *  Set the logical name attribute default.\n     *\n     *    @param [in] fileName            Name of the selected file.\n     *    @param [in] newLogicalDefault   Boolean value of the attribute.\n     *\n     *    @return True, if successful, false otherwise.\n     */\n    bool setLogicalNameDefault(std::string const& fileName, bool newLogicalDefault);\n\n    /*!\n     *  Check if the file contains a structural RTL or not.\n     *\n     *    @param [in] fileName    Name of the selected file.\n     *\n     *    @return True, if the file contains a structural RTL, false otherwise.\n     */\n    bool isStructural(std::string const& fileName) const;\n\n    /*!\n     *  Set the file to contain structural RTL.\n     *\n     *    @param [in] fileName            Name of the selected file.\n     *    @param [in] structuralStatus    The new structural status.\n     *\n     *    @return True, if successful, false otherwise.\n     */\n    bool setStructural(std::string const& fileName, bool structuralStatus);\n    \n    /*!\n     *  Get the isIncludeFile setting.\n\t *\n     *    @param [in] fileName    Name of the selected file.\n     *\n\t *    @return True if the file is an include file, otherwise false.\n\t */\n\tbool isIncludeFile(std::string const& fileName) const;\n\n\t/*! \n     *  Set the isIncludeFile setting for this file.\n\t *\n     *    @param [in] fileName            Name of the selected file.\n\t *    @param [in] includeFileStatus   Boolean value to be set.\n     *\n     *    @return True, if successful, false otherwise.\n     */\n\tbool setIncludeFile(std::string const& fileName, bool includeFileStatus);\n    \n    /*! \n     *  Get attribute value of external declarations.\n\t *\n     *    @param [in] fileName    Name of the selected file.\n     *\n\t *    @return True of the file has external declarations, otherwise false.\n\t */\n\tbool hasExternalDeclarations(std::string const& fileName) const;\n\n\t/*! \n     *  Set the externalDeclarations setting\n\t *\n     *    @param [in] fileName                    Name of the selected file.\n\t *    @param [in] externalDeclarationsStatus  Boolean value to be set.\n     *\n     *    @return True, if successful, false otherwise.\n\t */\n\tbool setExternalDeclarations(std::string const& fileName, bool externalDeclarationsStatus);\n\n    /*!\n     *  Clear all the fileTypes and userFileTypes.\n     *\n     *    @param [in] fileName    Name of the selected file.\n     */\n    void clearFileTypes(std::string const& fileName);\n\n    /*!\n     *  Set file types for the selected file.\n     *\n     *    @param [in] fileName        Name of the selected file.\n     *    @param [in] newFileTypes    The new file types.\n     *\n     *    @return True, if successful, false otherwise.\n     */\n    bool setFileTypes(std::string const& fileName, std::vector<std::string> const newFileTypes);\n\n    /*!\n     *  Add the selected file type to the selected file.\n     *\n     *    @param [in] fileName        Name of the selected file.\n     *    @param [in] newFileType     The new file type.\n     *\n     *    @return True, if successful, false otherwise.\n     */\n    bool addFileType(std::string const& fileName, std::string const newFileType);\n\n    /*!\n     *  Add multiple file type to the selected file.\n     *\n     *    @param [in] fileName        Name of the selected file.\n     *    @param [in] newFileTypes    The new file types.\n     *\n     *    @return True, if successful, false otherwise.\n     */\n    bool addMultipleFileTypes(std::string const& fileName, std::vector<std::string> const newFileTypes);\n\n    /*!\n     *  Get the dependencies of a file.\n     *\n     *    @param [in] fileName    Name of the selected file.\n     *\n     *    @return Dependencies of the selected file.\n     */\n    std::vector<std::string> getDependencies(std::string const& fileName) const;\n\n    /*!\n     *  Clear all the dependencies on the selected file.\n     *\n     *    @param [in] fileName    Name of the selected file.\n     */\n    void clearDependencies(std::string const& fileName);\n\n    /*!\n     *  Add the selected dependency to the selected file.\n     *\n     *    @param [in] fileName        Name of the selected file.\n     *    @param [in] newDependency   The new dependency.\n     *\n     *    @return True, if successful, false otherwise.\n     */\n    bool addDependency(std::string const& fileName, std::string const newDependency);\n\n    /*!\n     *  Add multiple dependencies to the selected file.\n     *\n     *    @param [in] fileName            Name of the selected file.\n     *    @param [in] newDependencies     The new dependencies.\n     *\n     *    @return True, if successful, false otherwise.\n     */\n    bool addMultipleDependencies(std::string const& fileName, std::vector<std::string> const newDependencies);\n\n    /*!\n     *  Get the exported names of a file.\n     *\n     *    @param [in] fileName    Name of the selected file.\n     *\n     *    @return Exported names of the selected file.\n     */\n    std::vector<std::string> getExportedNames(std::string const& fileName) const;\n\n    /*!\n     *  Clear all the exported names of the selected file.\n     *\n     *    @param [in] fileName    Name of the selected file.\n     */\n    void clearExportedNames(std::string const& fileName);\n\n    /*!\n     *  Add the selected exported name to the selected file.\n     *\n     *    @param [in] fileName            Name of the selected file.\n     *    @param [in] newExportedName     The new exported name.\n     *\n     *    @return True, if successful, false otherwise.\n     */\n    bool addExportedName(std::string const& fileName, std::string const newExportedName);\n\n    /*!\n     *  Add multiple exported names to the selected file.\n     *\n     *    @param [in] fileName            Name of the selected file.\n     *    @param [in] newExportedNames    The new exported names.\n     *\n     *    @return True, if successful, false otherwise.\n     */\n    bool addMultipleExportedNames(std::string const& fileName, std::vector<std::string> const newExportedNames);\n\n    /*!\n     *  Get the image types of a file.\n     *\n     *    @param [in] fileName    Name of the selected file.\n     *\n     *    @return Image types of the selected file.\n     */\n    std::vector<std::string> getImageTypes(std::string const& fileName) const;\n\n    /*!\n     *  Clear all the image types on the selected file.\n     *\n     *    @param [in] fileName    Name of the selected file.\n     */\n    void clearImageTypes(std::string const& fileName);\n\n    /*!\n     *  Add the selected image type to the selected file.\n     *\n     *    @param [in] fileName        Name of the selected file.\n     *    @param [in] newImageType    The new image type.\n     *\n     *    @return True, if successful, false otherwise.\n     */\n    bool addImageType(std::string const& fileName, std::string const newImageType);\n\n    /*!\n     *  Add multiple image types to the selected file.\n     *\n     *    @param [in] fileName        Name of the selected file.\n     *    @param [in] newImageTypes   The new image types.\n     *\n     *    @return True, if successful, false otherwise.\n     */\n    bool addMultipleImageTypes(std::string const& fileName, std::vector<std::string> const newImageTypes);\n\n    /*!\n     *   Get the file types of the selected file.\n     *\n     *    @param [in] fileName    Name of the selected file.\n     *\n     *    @return List containing the file types.\n     */\n    std::vector<std::string> getFileTypes(std::string const& fileName) const;\n\n    /*!\n     *   Get the build command of selected file.\n     *\n     *    @param [in] fileName    Name of the selected file.\n     *\n     *    @return Build command of the selected file.\n     */\n    std::string getBuildCommandText(std::string const& fileName) const;\n\n   \t/*! \n     *  Set the build command for the selected file.\n\t *\n     *    @param [in] fileName            Name of the selected file.\n\t *    @param [in] newBuildCommand     The new build command.\n     *\n     *    @return True, if successful, false otherwise.\n\t */\n\tbool setBuildCommand(std::string const& fileName, std::string const& newBuildCommand);\n\n    /*!\n     *   Get the build command flags of selected file.\n     *\n     *    @param [in] fileName    Name of the selected file.\n     *\n     *    @return Build command flags of the selected file.\n     */\n    std::string getBuildCommandFlags(std::string const& fileName) const;\n\n    /*! \n     *  Set the build flags for the selected file.\n\t *\n     *    @param [in] fileName    Name of the selected file.\n\t *    @param [in] newFlags    The new flags.\n     *\n     *    @return True, if successful, false otherwise.\n\t */\n\tbool setBuildCommandFlags(std::string const& fileName, std::string const& newFlags);\n\n    /*!\n     *  Get the calculated build command replace default flags value of the selected file.\n     *\n     *    @param [in] fileName    Name of the selected file.\n     *    @param [in] baseNumber  Base for displaying the value.\n     *\n     *    @return Calculated build command replace default flags value of the selected file.\n     */\n    std::string getBuildCommandReplaceDefaultFlagsValue(std::string const& fileName, int const& baseNumber = 0)\n        const;\n\n    /*!\n     *  Get the formatted build command replace default flags expression of the selected file.\n     *\n     *    @param [in] fileName    Name of the selected file.\n     *\n     *    @return Formatted build command replace default flags expression of the selected file.\n     */\n    std::string getBuildCommandReplaceDefaultFlagsFormattedExpression(std::string const& fileName) const;\n\n    /*!\n     *  Get the build command replace default flags expression of the selected file.\n     *\n     *    @param [in] fileName    Name of the selected file.\n     *\n     *    @return Build command replace default flags expression of the selected file.\n     */\n    std::string getBuildCommandReplaceDefaultFlagsExpression(std::string const& fileName) const;\n\n    /*!\n     *  Set a new build command replace default flags value for the selected file.\n     *\n     *    @param [in] fileName                Name of the selected file.\n     *    @param [in] newReplaceDefaultFlags  New build command replace default flags value.\n     *\n     *    @return True, if successful, false otherwise.\n     */\n    bool setbuildCommandReplaceDefaultFlags(std::string const& fileName,\n        std::string const& newReplaceDefaultFlags);\n\n    /*!\n     *   Get the build command target of selected file.\n     *\n     *    @param [in] fileName    Name of the selected file.\n     *\n     *    @return Build command target of the selected file.\n     */\n    std::string getBuildCommandTarget(std::string const& fileName) const;\n\n    /*!\n     *  Set the build target for the selected file.\n     *\n     *    @param [in] fileName    Name of the selected file.\n     *    @param [in] newTarget   The new target.\n     *\n     *    @return True, if successful, false otherwise.\n     */\n    bool setBuildCommandTarget(std::string const& fileName, std::string const& newTarget);\n\nprivate:\n\n    /*!\n     *  Get the selected file.\n     *\n     *    @param [in] fileName    Name of the selected file.\n     *\n     *    @return The selected file.\n     */\n    QSharedPointer<File> getFile(std::string const& fileName) const;\n\n    /*!\n     *  Get the file with the selected name, sliced to a NameGroup.\n     *  Dummy function, return nullptr, as file doesn't contain a name group.\n     *\n     *    @param [in] file    Name of the selected file.\n     *\n     *    @return Always nullptr.\n     */\n    QSharedPointer<NameGroup> getItem(std::string const& itemName) const override;\n\n    /*!\n     *  Get the build command of the selected file.\n     *\n     *    @param [in] fileName    Name of the selected file.\n     *\n     *    @return The build command of the selected file.\n     */\n    QSharedPointer<BuildCommand> getBuildCommand(std::string const& fileName) const;\n\n    /*!\n     *  Remove an empty build command from the selected file.\n     *\n     *    @param [in] containingFile  The selected file.\n     */\n    void removeEmptyBuildCommand(QSharedPointer<File> containingFile) const;\n\n    //-----------------------------------------------------------------------------\n    // Data.\n    //-----------------------------------------------------------------------------\n\n    //! List of the contained files.\n    QSharedPointer<QList<QSharedPointer<File> > > files_;\n\n    //! Validator for files.\n    QSharedPointer<FileValidator> validator_;\n};\n\n#endif // FILEINTERFACE_H\n"
  },
  {
    "path": "KactusAPI/include/FileSetInterface.h",
    "content": "//-----------------------------------------------------------------------------\n// File: FileSetInterface.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 01.09.2020\n//\n// Description:\n// Interface for editing file sets.\n//-----------------------------------------------------------------------------\n\n#ifndef FILESETINTERFACE_H\n#define FILESETINTERFACE_H\n\n#include <KactusAPI/KactusAPIGlobal.h>\n\n#include <ParameterizableInterface.h>\n#include <NameGroupInterface.h>\n\n#include <QSharedPointer>\n#include <QVector>\n#include <QMap>\n\nclass FileSet;\nclass FileSetValidator;\nclass FileInterface;\nclass FileBuilderInterface;\n\n//-----------------------------------------------------------------------------\n//! Interface for editing filesets.\n//-----------------------------------------------------------------------------\nclass KACTUS2_API FileSetInterface: public ParameterizableInterface, public NameGroupInterface\n{\n\npublic:\n\n    /*!\n     *  The constructor.\n     *\n     *    @param [in] validator               Validator for files.\n     *    @param [in] expressionParser        Parser for expressions.\n     *    @param [in] expressionFormatter     Formatter for expressions.\n     *    @param [in] fileInterface           Sub interface for files.\n     *    @param [in] fileBuilderInterface    Sub interface for file builders.\n     */\n    FileSetInterface(QSharedPointer<FileSetValidator> validator,\n        QSharedPointer<ExpressionParser> expressionParser,\n        QSharedPointer<ExpressionFormatter> expressionFormatter,\n        FileInterface* fileInterface,\n        FileBuilderInterface* fileBuilderInterface);\n\n\t/*!\n     *  The destructor.\n     */\n    virtual ~FileSetInterface() = default;\n\n    /*!\n     *  Set available file sets.\n     *\n     *    @param [in] newFileSets     The new file sets.\n     */\n    void setFileSets(QSharedPointer<QList<QSharedPointer<FileSet> > > newFileSets);\n\n    /*!\n     *  Get index of the selected item.\n     *\n     *    @param [in] itemName    Name of the selected item.\n     *\n     *    @return Index of the selected item.\n     */\n    virtual int getItemIndex(std::string const& itemName) const override final;\n\n    /*!\n     *  Get name of the indexed item.\n     *\n     *    @param [in] itemIndex   Index of the selected item.\n     *\n     *    @return Name of the selected item.\n     */\n    std::string getIndexedItemName(int itemIndex) const final;\n\n    /*!\n     *  Get the number of available items.\n     *\n     *    @return Number of available items.\n     */\n    virtual int itemCount() const override final;\n\n    /*!\n     *  Get the names of the available items.\n     *\n     *    @return Names of the available items.\n     */\n    virtual std::vector<std::string> getItemNames() const override final;\n\n    /*!\n     *  Set a new name for the selected item.\n     *\n     *    @param [in] currentName     Name of the selected item.\n     *    @param [in] newName         New name for the item.\n     *\n     *    @return True, if successful, false otherwise.\n     */\n    virtual bool setName(std::string const& currentName, std::string const& newName) override final;\n\n    /*!\n     *  Validates the contained items.\n     *\n     *    @return True, if all the ports are valid, false otherwise.\n     */\n    virtual bool validateItems() const override final;\n\n    /*!\n     *  Check if the selected item has a valid name.\n     *\n     *    @param [in] itemName    Name of the selected item.\n     *\n     *    @return True, if the name is valid, false otherwise.\n     */\n    virtual bool itemHasValidName(std::string const& itemName) const override final;\n\n    /*!\n     *  Get the groups of the selected file set.\n     *\n     *    @param [in] fileSetName     Name of the selected file set.\n     *\n     *    @return Groups of the selected file set.\n     */\n    std::vector<std::string> getGroups(std::string const& fileSetName) const;\n    \n    /*!\n     *  Set new groups for the selected item.\n     *\n     *    @param [in] fileSetName     Name of the selected file set.\n     *    @param [in] newGroups       The new groups.\n     *\n     *    @return True, if successful, false otherwise.\n     */\n    bool setGroups(std::string const& fileSetName, std::vector<std::string> const& newGroups);\n\n    /*!\n     *  Get the dependencies of the selected file set.\n     *\n     *    @param [in] fileSetName     Name of the selected file set.\n     *\n     *    @return Dependencies of the selected file set.\n     */\n    std::vector<std::string> getDependencies(std::string const& fileSetName) const;\n\n    /*!\n     *  Set new dependencies for the selected item.\n     *\n     *    @param [in] fileSetName         Name of the selected file set.\n     *    @param [in] newDependencies     The new dependencies.\n     *\n     *    @return True, if successful, false otherwise.\n     */\n    bool setDependencies(std::string const& fileSetName, std::vector<std::string> const& newDependencies);\n\n    /*!\n     *  Add a new file set, inserting it to a specified position given by row.\n     *\n     *    @param [in] row             Row of the new file set.\n     *    @param [in] newFileSetName  Name of the new file set.\n     */\n    void addFileSet(int const& row, std::string const& newFileSetName = std::string(\"\"));\n\n    /*!\n     *  Add a new file set.\n     *  This overload should be preferred when using Python.\n     *\n     *    @param [in] newFileSetName  Name of the new file set.\n     */\n    void addFileSet(std::string const& newFileSetName = std::string(\"\"));\n\n    /*!\n     *  Remove the selected file set.\n     *\n     *    @param [in] fileSetName     Name of the selected file set.\n     *\n     *    @return True, if successful, false otherwise.\n     */\n    bool removeFileSet(std::string const& fileSetName);\n\n    /*!\n     *  Get the interface for accessing files.\n     *\n     *    @return Interface for accessing files.\n     */\n    FileInterface* getFileInterface() const;\n\n    /*!\n     *  Get the interface for accessing file builders.\n     *\n     *    @return Interface for accessing file builders.\n     */\n    FileBuilderInterface* getFileBuilderInterface() const;\n\n    /*!\n     *  Calculate all the references to the selected ID in the selected item.\n     *\n     *    @param [in] itemName    Name of the selected item.\n     *    @param [in] valueID     The selected ID.\n     *\n     *    @return Number of references to the selected ID in the selected item.\n     */\n    virtual int getAllReferencesToIdInItem(const std::string& itemName, std::string const& valueID) const override\n        final;\n\n    /*!\n     *  Get the expressions in the selected file sets.\n     *\n     *    @param [in] fileSetNames    Names of the selected file sets.\n     *\n     *    @return The expressions of the selected file sets.\n     */\n    std::vector<std::string> getExpressionsInSelectedFileSets(std::vector<std::string> fileSetNames) const;\n\n    /*!\n     *  Check if the selected file set exists.\n     *\n     *    @param [in] fileSetName     Name of the selected file set.\n     *\n     *    @return True, if the file set exists, false otherwise.\n     */\n    bool fileSetExists(std::string const& fileSetName) const;\n\nprivate:\n\n    /*!\n     *  Get the selected file set.\n     *\n     *    @param [in] fileSetName     Name of the selected file set.\n     *\n     *    @return The selected file set.\n     */\n    QSharedPointer<FileSet> getFileSet(std::string const& fileSetName) const;\n\n    /*!\n     *  Get the file set with the selected name, sliced to a NameGroup.\n     *\n     *    @param [in] fileSetName    Name of the selected file set.\n     *\n     *    @return The sliced file set with the selected name.\n     */\n    QSharedPointer<NameGroup> getItem(std::string const& fileSetName) const override;\n\n    //-----------------------------------------------------------------------------\n    // Data.\n    //-----------------------------------------------------------------------------\n\n    //! List of the contained file sets.\n    QSharedPointer<QList<QSharedPointer<FileSet> > > fileSets_;\n\n    //! Validator for file sets.\n    QSharedPointer<FileSetValidator> validator_;\n\n    //! Sub interface for accessing files.\n    FileInterface* fileInterface_;\n\n    //! Sub interface for accessing file builders.\n    FileBuilderInterface* fileBuilderInterface_;\n};\n\n#endif // FILESETINTERFACE_H\n"
  },
  {
    "path": "KactusAPI/include/HighlightSource.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: HighlightSource.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Esko Pekkarinen\r\n// Date: 18.09.2014\r\n//\r\n// Description:\r\n// Interface for all highlighting import plugins.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef HIGHLIGHTSOURCE_H\r\n#define HIGHLIGHTSOURCE_H\r\n\r\n#include \"Highlighter.h\"\r\n\r\nclass HighlightSource\r\n{\r\npublic:\r\n\r\n\t//! The destructor.\r\n    virtual ~HighlightSource() {};\r\n\r\n    /*!\r\n     *  Sets the given highlighter to be used by the source.\r\n     *\r\n     *    @param [in] highlighter   The highlighter to use.          \r\n     */\r\n    virtual void setHighlighter(Highlighter* highlighter) = 0;\r\n\r\n};\r\n\r\n#endif // HIGHLIGHTSOURCE_H\r\n"
  },
  {
    "path": "KactusAPI/include/Highlighter.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: Highlighter.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Esko Pekkarinen\r\n// Date: 18.09.2014\r\n//\r\n// Description:\r\n// Interface for syntax highlighter.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef HIGHLIGHTER_H\r\n#define HIGHLIGHTER_H\r\n\r\n#include <QString>\r\n#include <QColor>\r\n\r\nclass Highlighter\r\n{\r\npublic:\r\n\r\n\t//! The destructor.\r\n    virtual ~Highlighter() {};\r\n\r\n    /*!\r\n     *  Called when the text should be highlighted with the given color.\r\n     *\r\n     *    @param [in] text            The text to highlight.\r\n     *    @param [in] highlightColor  The color of the highlight.\r\n     *    @param [in] subSection      Subsection where the text is located.\r\n     */\r\n    virtual void applyHighlight(QString const& text, QColor const& highlightColor, QString const& subSection = QString()) = 0;\r\n\r\n    /*!\r\n     *  Called when a section should be highlighted with the given color.\r\n     *\r\n     *    @param [in] beginPosition   The beginning character index.\r\n     *    @param [in] endPosition     The end character index.\r\n     *    @param [in] highlightColor  The color of the highlight.\r\n     */\r\n    virtual void applyHighlight(int beginPosition, int endPosition, QColor const& highlightColor) = 0;\r\n\r\n    /*!\r\n     *  Called when the font color of a text should be changed to the given color.\r\n     *\r\n     *    @param [in] text    The text whose font to change.\r\n     *    @param [in] color   The color of the text.     \r\n     */\r\n    virtual void applyFontColor(QString const& text, QColor const& color) = 0;\r\n};\r\n\r\n#endif // HIGHLIGHTER_H\r\n"
  },
  {
    "path": "KactusAPI/include/IGeneratorPlugin.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: IGeneratorPlugin.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Joni-Matti Maatta\r\n// Date: 27.6.2012\r\n//\r\n// Description:\r\n// Interface for plugins that are used to generate content for different IP-XACT documents.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef IGENERATORPLUGIN_H\r\n#define IGENERATORPLUGIN_H\r\n\r\n#include \"IPlugin.h\"\r\n\r\n#include <QSharedPointer>\r\n#include <QIcon>\r\n\r\nclass Component;\r\nclass Design;\r\nclass DesignConfiguration;\r\nclass IPluginUtility;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Generator plugins can be used in the component editor and design editors to generate content for the currently\r\n//! active document. The content can //! be, e.g., new source files or direct modifications to the IP-XACT\r\n//! metadata of the document. Plugin generators will automatically appear in the Kactus2 ribbon menu under\r\n//! the Generation group.\r\n//-----------------------------------------------------------------------------\r\nclass IGeneratorPlugin : public IPlugin\r\n{\r\npublic:\r\n    /*!\r\n     *  Destructor.\r\n     */\r\n    virtual ~IGeneratorPlugin() {}\r\n\r\n    /*!\r\n     *  Returns the icon for the generator.\r\n     */\r\n    virtual QIcon getIcon() const = 0;\r\n\r\n    /*!\r\n     *  Checks whether the generator may run for the given component or design. \r\n     *\r\n     *    @param [in] component\t        The component for which to check support. If design is not null, component\r\n\t *                                      will refer to design or designConfiguration.\r\n     *    @param [in] design\t            The design, if the generator is ran for a design.\r\n     *    @param [in] designConfiguration The design configuration for design, if it is not null.\r\n     *\r\n     *    @return True, if the generator may run the given component. Otherwise false.\r\n     */\r\n    virtual bool checkGeneratorSupport(QSharedPointer<Component const> component,\r\n        QSharedPointer<Design const> design,\r\n        QSharedPointer<DesignConfiguration const> designConfiguration) const = 0;\r\n\r\n    /*!\r\n     *  Runs the generation, creating new files and/or modifying the IP-XACT metadata. The function has\r\n\t *  also access to the parent window widget, so that it can show dialogs for the user to aid the generation.\r\n     *\r\n     *    @param [in] utility\t\t\t    The plugin utility interface.\r\n     *    @param [in] component\t        The component for which to check support. If design is not null, component\r\n     *                                      will refer to design or designConfiguration.\r\n     *    @param [in] design\t            The design, if the generator is ran for a design.\r\n     *    @param [in] designConfiguration The design configuration for design, if it is not null.\r\n     */\r\n    virtual void runGenerator(IPluginUtility* utility, \r\n        QSharedPointer<Component> component,\r\n        QSharedPointer<Design> design,\r\n        QSharedPointer<DesignConfiguration> designConfiguration) = 0;\r\n};\r\n\r\nQ_DECLARE_INTERFACE(IGeneratorPlugin, \"com.tut.Kactus2.IGeneratorPlugin/1.0\")\r\n\r\n//-----------------------------------------------------------------------------\r\n\r\n#endif // IGENERATORPLUGIN_H\r\n"
  },
  {
    "path": "KactusAPI/include/IPXactSystemVerilogParser.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: IPXactSystemVerilogParser.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Esko Pekkarinen\r\n// Date: 02.12.2014\r\n//\r\n// Description:\r\n// Parser for SystemVerilog expressions with parameter references.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef IPXACTSYSTEMVERILOGPARSER_H\r\n#define IPXACTSYSTEMVERILOGPARSER_H\r\n\r\n#include \"SystemVerilogExpressionParser.h\"\r\n\r\n#include \"KactusAPI/KactusAPIGlobal.h\"\r\n\r\n#include <QSharedPointer>\r\n#include <QString>\r\n#include <QVector>\r\n\r\nclass ParameterFinder;\r\n\r\n//-----------------------------------------------------------------------------\r\n// Parser for SystemVerilog expressions with parameter references.\r\n//-----------------------------------------------------------------------------\r\nclass KACTUS2_API IPXactSystemVerilogParser : public SystemVerilogExpressionParser\r\n{\r\npublic:\r\n\r\n    /*!\r\n     *  The constructor.\r\n     *\r\n     *    @param [in] finder   The finder for parameters available in the SystemVerilog expressions.\r\n     */\r\n    explicit IPXactSystemVerilogParser(QSharedPointer<ParameterFinder> finder);\r\n    \r\n    //! The destructor.\r\n    virtual ~IPXactSystemVerilogParser() = default;\r\n\r\n    // Disable copying.\r\n    IPXactSystemVerilogParser(IPXactSystemVerilogParser const& rhs) = delete;\r\n    IPXactSystemVerilogParser& operator=(IPXactSystemVerilogParser const& rhs) = delete;\r\n\r\n    /*!\r\n     *  Checks if the given expression is a symbol e.g. reference.\r\n     *\r\n     *    @param [in] expression   The expression to check.\r\n     *\r\n     *    @return True, if the expression is a symbol, otherwise false.\r\n     */\r\n    bool isSymbol(QStringView expression) const override;\r\n\r\n    /*!\r\n     *  Finds the value for given symbol.\r\n     *\r\n     *    @param [in] symbol  The symbol whose value to find.\r\n     *\r\n     *    @return The found symbol value.\r\n     */\r\n    QString findSymbolValue(QStringView symbol) const override;\r\n\r\n    /*!\r\n     *  Finds the base in the symbol.\r\n     *\r\n     *    @param [in] symbol   The symbol whose base to find.\r\n     *\r\n     *    @return The base for the symbol.\r\n     */\r\n    int getBaseForSymbol(QStringView symbol) const final;\r\n\r\nprivate:\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n    \r\n    //! The finder for parameters available in the SystemVerilog expressions.\r\n    QSharedPointer<ParameterFinder> finder_;\r\n\r\n    //! Stack for tracking already evaluated symbols to check for loops in references.\r\n    mutable QVector<QStringView> symbolStack_;\r\n};\r\n\r\n#endif // IPXACTSYSTEMVERILOGPARSER_H\r\n"
  },
  {
    "path": "KactusAPI/include/IPlugin.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: IPlugin.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Joni-Matti Maatta\r\n// Date: 27.6.2012\r\n//\r\n// Description:\r\n// Base plugin interface.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef IPLUGIN_H\r\n#define IPLUGIN_H\r\n\r\n#include \"PluginSettingsModel.h\"\r\n\r\n#include <QString>\r\n#include <QList>\r\n#include <QtPlugin>\r\n#include <QWidget>\r\n\r\n//-----------------------------------------------------------------------------\r\n//! All plugin interfaces inherit from a common IPlugin interface which all plugins must implement.\r\n//! It is used by Kactus2 to acquire plugin information.\r\n//! Most of the plugins do not inherit this interface directly, but some derived interface.\r\n//-----------------------------------------------------------------------------\r\nclass IPlugin\r\n{\r\npublic:\r\n\r\n\t//! \\brief Contains options for required external program paths for plugin.\r\n\tstruct ExternalProgramRequirement {\r\n\t\t\r\n\t\t//! \\brief Identifies the program to run.\r\n\t\tQString name_;\r\n\r\n\t\t//! \\brief Explains the required program for user.\r\n\t\tQString description_;\r\n\r\n\t\t//! \\brief Contains the filters for the QFileDialog to select correct type of files.\r\n\t\tQString filters_;\r\n\t};\r\n\r\n    /*!\r\n     *  Destructor.\r\n     */\r\n    virtual ~IPlugin() {}\r\n\r\n    /*!\r\n     *  Returns the name of the plugin.\r\n     */\r\n    virtual QString getName() const = 0;\r\n\r\n    /*!\r\n     *  Returns the version of the plugin.\r\n     */\r\n    virtual QString getVersion() const = 0;\r\n\r\n    /*!\r\n     *  Returns the description of the plugin.\r\n     */\r\n    virtual QString getDescription() const = 0;\r\n\r\n    /*!\r\n     *  Returns the vendor of the plugin.\r\n     */\r\n    virtual QString getVendor() const = 0;\r\n\r\n    /*!\r\n     *  Returns the license of the plugin (e.g. GPL2).\r\n     */\r\n    virtual QString getLicense() const = 0;\r\n\r\n    /*!\r\n     *  Returns the license holder i.e. who is the plugin licensed to (e.g. Public or Tampere University of Technology).\r\n     */\r\n    virtual QString getLicenseHolder() const = 0;\r\n\r\n    /*!\r\n     *  This can be used to show custom plugin-specific settings UI in the Kactus2 settings dialog.\r\n\t *  A QWidget should be returned even if the plugin has no custom settings.\r\n     */\r\n    virtual QWidget* getSettingsWidget() = 0;\r\n\r\n    /*!\r\n     *  This is used to access the settings modified by function getSettingsWidget().\r\n     */\r\n    virtual PluginSettingsModel* getSettingsModel() = 0;\r\n\r\n    /*!\r\n     *  This can be used to indicate what external programs the plugin needs in order to operate correctly.\r\n\t *  This allows Kactus2 to show settings to set paths where those external program are located.\r\n     */\r\n\tvirtual QList<ExternalProgramRequirement> getProgramRequirements() = 0;\r\n};\r\n\r\nQ_DECLARE_INTERFACE(IPlugin, \"com.tut.Kactus2.IPlugin/1.0\")\r\n\r\n//-----------------------------------------------------------------------------\r\n\r\n#endif // IPLUGIN_H\r\n"
  },
  {
    "path": "KactusAPI/include/IPluginUtility.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: IPluginUtility.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Joni-Matti Maatta\r\n// Date: 28.6.2012\r\n//\r\n// Description:\r\n// Interface which offers core utilities for plugins, namely access to the console, the parent widget, and most\r\n// importantly the library interface. It is provided for a plugin via the implemented plugin interface.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef IPLUGINUTILITY_H\r\n#define IPLUGINUTILITY_H\r\n\r\n#include <QWidget>\r\n#include <QString>\r\n\r\nclass LibraryInterface;\r\n\r\nclass IPluginUtility\r\n{\r\npublic:\r\n\r\n    /*!\r\n     *  Destructor.\r\n     */\r\n    virtual ~IPluginUtility() {}\r\n\r\n    /*!\r\n     *  Returns the library interface.\r\n     */\r\n    virtual LibraryInterface* getLibraryInterface() = 0;\r\n\r\n    /*!\r\n     *  Returns the parent widget to be used for e.g. dialogs.\r\n     */\r\n\tvirtual QWidget* getParentWidget() = 0;\r\n\r\n\t//! Returns the current version of the Kactus2 build.\r\n\tvirtual QString getKactusVersion() const = 0;\r\n  \r\n    /*!\r\n     *  Prints an error message to the console window.\r\n     *\r\n     *    @param [in] message The error message to print.\r\n     */\r\n    virtual void printError(QString const& message) = 0;\r\n\r\n    /*!\r\n     *  Prints an info message to the console window.\r\n     *\r\n     *    @param [in] message The info message to print.\r\n     */\r\n    virtual void printInfo(QString const& message) = 0;\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n\r\n#endif // IPLUGINUTILITY_H\r\n"
  },
  {
    "path": "KactusAPI/include/ISourceAnalyzerPlugin.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ISourceAnalyzerPlugin.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Joni-Matti Maatta\r\n// Date: 14.01.2013\r\n//\r\n// Description:\r\n// Source analyzer plugin interface for dependency analysis.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef ISOURCEANALYZER_H\r\n#define ISOURCEANALYZER_H\r\n\r\n#include \"IPlugin.h\"\r\n#include \"IPluginUtility.h\"\r\n\r\n#include <QString>\r\n#include <QStringList>\r\n#include <QSharedPointer>\r\n#include <QList>\r\n#include <QtPlugin>\r\n\r\nclass Component;\r\nclass FileDependency;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! File dependency description structure.\r\n//-----------------------------------------------------------------------------\r\nstruct FileDependencyDesc\r\n{\r\n\t//! The name of the dependent file, for example \"componentName.vhd\".\r\n    QString filename;\r\n\t//! Possible automatically deduced description for the dependency, for example\r\n\t//! \"Component instantiation for entity componentName\".\r\n    QString description;    \r\n\r\n    /*!\r\n     *  Default constructor.\r\n     */\r\n    FileDependencyDesc() : filename(), description()\r\n    {\r\n    }\r\n\r\n\tbool operator==(const FileDependencyDesc& lhs) const\r\n\t{\r\n\t\treturn lhs.filename == filename;\r\n\t}\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Kactus2 contains a dependency analyzer to manage and visualize dependencies between source files of\r\n//! a component. Source analyzer plugins are used in the dependency analyzer to add support for different code\r\n//! languages and even custom file types. Single source analyzer plugin implements support for a single language\r\n//! or predefined file types.\r\n//-----------------------------------------------------------------------------\r\nclass ISourceAnalyzerPlugin : public IPlugin\r\n{\r\npublic:\r\n    /*!\r\n     *  Destructor.\r\n     */\r\n    virtual ~ISourceAnalyzerPlugin() {}\r\n\r\n    /*!\r\n     *  Returns the list of file types this plugin can run analysis for. File type is described as an IP-XACT style string,\r\n\t *  e.g. cppSource or vhdlSource. Kactus2 includes a settings page for setting which file extensions map to which\r\n\t *  file types so that the analyzer plugin doesn't have to hard-code the supported extensions.\r\n     */\r\n    virtual QStringList getSupportedFileTypes() const = 0;\r\n\r\n    /*!\r\n     *  Calculates a language-dependent hash for the analyzed file. Hash calculation here may ignore\r\n\t *  whitespace and comments.\r\n     *\r\n     *    @param [in] filename  The name of the file.\r\n     *\r\n     *    @return The hash value for the file.\r\n     */\r\n    virtual QString calculateHash(QString const& filename) = 0;\r\n\r\n    /*!\r\n     *  This function is called once when the dependency analysis scan is started. It gives the plugin the\r\n\t *  ability to do preparations before any file is analyzed.\r\n     *\r\n     *    @param [in] component       The component to which the dependency scan is being run.\r\n     *    @param [in] componentPath  The path to the directory where the component is located.\r\n     *\r\n     *      @remarks Any preparations needed for the file dependency analysis should be made here.\r\n     */\r\n    virtual void beginAnalysis(Component const* component, QString const& componentPath) = 0;\r\n\r\n    /*!\r\n     *  This function is called once after the dependency analysis scan has completed. It allows the plugin to\r\n\t *  make cleanup operations after the dependency scan has been finished, e.g destroy internal data structures.\r\n     *\r\n     *    @param [in] component       The component to which the dependency scan is being run.\r\n     *    @param [in] componentPath  The path to the directory where the component is located.\r\n     *\r\n     *      @remarks Any cleanups needed should be made here.\r\n     */\r\n    virtual void endAnalysis(Component const* component, QString const& componentPath) = 0;\r\n\r\n    /*!\r\n     *  Retrieves all file dependencies the given file has.\r\n\t *\r\n     *    @param [in]  component      The component to which the dependency scan is being run.\r\n     *    @param [in]  componentPath  The path to the directory where the component is located.\r\n     *    @param [in]  filename       The name of the file to which the analysis is run.\r\n     *\r\n     *    @return The list of found dependencies.\r\n     */\r\n    virtual QList<FileDependencyDesc> getFileDependencies(Component const* component,\r\n        QString const& componentPath, \r\n        QString const& filename) = 0;\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n\r\nQ_DECLARE_INTERFACE(ISourceAnalyzerPlugin, \"com.tut.Kactus2.ISourceAnalyzerPlugin/1.0\")\r\n\r\n#endif // ISOURCEANALYZER_H\r\n"
  },
  {
    "path": "KactusAPI/include/ImportColors.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ImportColors.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Esko Pekkarinen\r\n// Date: 29.09.2014\r\n//\r\n// Description:\r\n// Common highlight colors for imported elements.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef IMPORTCOLORS_H\r\n#define IMPORTCOLORS_H\r\n\r\n#include <QColor>\r\n#include <common/KactusColors.h>\r\n\r\nnamespace ImportColors\r\n{\r\n    QColor const PORT = KactusColors::SW_COMPONENT;\r\n\r\n    QColor const MODELPARAMETER = KactusColors::HW_BUS_COMPONENT;\r\n\r\n    QColor const PARAMETER = KactusColors::MEMORY_BLOCK;\r\n\r\n    QColor const VIEWNAME = QColor(\"Moccasin\");\r\n\r\n    QColor const INSTANCECOLOR = QColor(201, 82, 251);\r\n}\r\n\r\n#endif // IMPORTCOLORS_H\r\n"
  },
  {
    "path": "KactusAPI/include/ImportHighlighter.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ImportHighlighter.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Esko Pekkarinen\r\n// Date: 11.09.2014\r\n//\r\n// Description:\r\n// Source file highlighter for import files.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef IMPORTHIGHLIGHTER_H\r\n#define IMPORTHIGHLIGHTER_H\r\n\r\n#include <Highlighter.h>\r\n\r\n#include <QObject>\r\n#include <QTextCharFormat>\r\n#include <QPlainTextEdit>\r\n\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Source file highlighter for import files.\r\n//-----------------------------------------------------------------------------\r\nclass ImportHighlighter : public QObject, public Highlighter\r\n{\r\n    Q_OBJECT\r\n\r\npublic:\r\n    /*!\r\n     * The constructor.\r\n     *\r\n     *    @param [in] display   The display widget for the parsed source file content.\r\n     *    @param [in] parent    The parent object.\r\n     */\r\n\tImportHighlighter(QPlainTextEdit* display, QObject* parent);\r\n\r\n\t//! The destructor.\r\n\t~ImportHighlighter();\r\n\r\n    /*!\r\n     *  Called when the text should be highlighted with the given color.\r\n     *\r\n     *    @param [in] text            The text to highlight.\r\n     *    @param [in] highlightColor  The color of the highlight.\r\n     *    @param [in] subSection      The current subsection containing the selected text.\r\n     */\r\n    virtual void applyHighlight(QString const& text, QColor const& highlightColor, QString const& subSection = QString());\r\n\r\n    /*!\r\n     *  Called when a section should be highlighted with the given color>.\r\n     *\r\n     *    @param [in] beginPosition   The beginning character index.\r\n     *    @param [in] endPosition     The end character index.\r\n     *    @param [in] highlightColor  The color of the highlight.\r\n     */\r\n    virtual void applyHighlight(int beginPosition, int endPosition, QColor const& highlightColor);\r\n\r\n    /*!\r\n     *  Called when the font color of a text should be changed to the given color.\r\n     *\r\n     *    @param [in] text    The text whose font to change.\r\n     *    @param [in] color   The color of the text.     \r\n     */\r\n    virtual void applyFontColor(QString const& text, QColor const& color);\r\n\r\nprivate:\r\n\r\n\t// Disable copying.\r\n\tImportHighlighter(ImportHighlighter const& rhs);\r\n\tImportHighlighter& operator=(ImportHighlighter const& rhs);\r\n \r\n    //! Display widget for the source file content.\r\n    QPlainTextEdit* display_;\r\n};\r\n\r\n#endif // IMPORTHIGHLIGHTER_H\r\n"
  },
  {
    "path": "KactusAPI/include/ImportPlugin.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ImportParser.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Esko Pekkarinen\r\n// Date: 17.09.2014\r\n//\r\n// Description:\r\n// Import plugins can be used to create elements e.g. ports in components from implementation source files\r\n// e.g. VHDL files. The import can be run in component wizard. After selecting the top-level file, all active\r\n// import plugins, whose accepted file ypes match the selected file, will be run.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef IMPORTPARSER_H\r\n#define IMPORTPARSER_H\r\n\r\n#include <KactusAPI/include/IPlugin.h>\r\n\r\n#include <QSharedPointer>\r\n#include <QtPlugin>\r\n\r\nclass Component;\r\n\r\nclass ImportPlugin : public IPlugin\r\n{\r\npublic:\r\n    \r\n    /*!\r\n     *  The destructor.\r\n     */\r\n    virtual ~ImportPlugin() = default;\r\n\r\n    /*!\r\n     *  Returns the file types supported by the plugin.\r\n     *\r\n     *    @return The file types the import plugin supports.\r\n     */\r\n    virtual QStringList getSupportedFileTypes() const = 0;\r\n\r\n    /*!\r\n     *  Returns a compatibility warning concerning the import plugin usage. Can be empty.\r\n     *\r\n     *    @return The warning text.\r\n     */\r\n    virtual QString getCompatibilityWarnings() const = 0;\r\n\r\n    /*!\r\n     *  Get component declarations from the selected input file.\r\n     *\r\n     *    @param [in] input   The selected input file.\r\n     *\r\n     *    @return List of component declarations found in the selected input.\r\n     */\r\n    virtual QStringList getFileComponents(QString const& input) const = 0;\r\n\r\n    /*!\r\n     *  Get the name of the selected component declaration.\r\n     *\r\n     *    @param [in] componentDeclaration    The selected component declaration.\r\n     *\r\n     *    @return Name of the selected component declaration.\r\n     */\r\n    virtual QString getComponentName(QString const& componentDeclaration) const = 0;\r\n\r\n    /*!\r\n     *  Runs the import by parsing the given input and applying the parsed elements to the given component.\r\n     *\r\n     *    @param [in] input                   The input text to parse.\r\n     *    @param [in] componentDeclaration    Declaration of the selected component.\r\n     *    @param [in] targetComponent         The component to apply all imported changes to.\r\n     */\r\n    virtual void import(QString const& input, QString const& componentDeclaration,\r\n        QSharedPointer<Component> targetComponent) = 0;\r\n\r\n};\r\n\r\nQ_DECLARE_INTERFACE(ImportPlugin, \"com.tut.Kactus2.ImportPlugin/1.0\")\r\n\r\n#endif // IMPORTPARSER_H\r\n"
  },
  {
    "path": "KactusAPI/include/ImportRunner.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ImportRunner.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Esko Pekkarinen\r\n// Date: 18.09.2014\r\n//\r\n// Description:\r\n// Runs import plugins for a given file and component.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef IMPORTRUNNER_H\r\n#define IMPORTRUNNER_H\r\n\r\n#include <KactusAPI/KactusAPIGlobal.h>\r\n\r\n#include <PluginManager.h>\r\n\r\n#include <ComponentParameterFinder.h>\r\n\r\n#include <QObject>\r\n#include <QSharedPointer>\r\n#include <QTabWidget>\r\n#include <QPlainTextEdit>\r\n#include <QMap>\r\n\r\nclass Component;\r\nclass ExpressionParser;\r\nclass FileSet;\r\nclass Highlighter;\r\nclass ImportPlugin;\r\nclass ISourceAnalyzerPlugin;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Runs import plugins for a given file and component.\r\n//-----------------------------------------------------------------------------\r\nclass KACTUS2_API ImportRunner : public QObject\r\n{\r\n    Q_OBJECT\r\npublic:\r\n\r\n\t/*!\r\n\t *  The constructor.\r\n\t *\r\n\t *    @param [in] parameterFinder     Pointer to the parameter finder.\r\n     *    @param [in] displayTabs         The container widget for read and displayed source files.\r\n\t *    @param [in] parent              Pointer to the owner of this runner.\r\n\t */\r\n\tImportRunner(QSharedPointer<ComponentParameterFinder> parameterFinder, QTabWidget* displayTabs, \r\n        QObject* parent);\r\n\r\n\t//! The destructor.\r\n\tvirtual ~ImportRunner() = default;\r\n  \r\n    /*!\r\n     *  Sets the expression parser to be used by all importers.\r\n     *\r\n     *    @param [in] parser   The parser to use.          \r\n     */\r\n    void setExpressionParser(QSharedPointer<ExpressionParser> parser);\r\n\r\n    /*!\r\n     *  Loads all available import plugins.\r\n     *\r\n     *    @param [in] pluginManager   The plugin manager owning all the plugins.\r\n     */\r\n    void loadPlugins(PluginManager const& pluginManager);\r\n\r\n    /*!\r\n     *  Locates component declarations from the selected file.\r\n     *\r\n     *    @param [in] filePath            Path to the selected file.\r\n     *    @param [in] componentXMLPath    Path to the target component XML file.\r\n     *    @param [in] targetComponent     Target component to which import all parsed elements.\r\n     *\r\n     *    @return List of component declarations found in the selected file.\r\n     */\r\n    QStringList constructComponentDataFromFile(QString const& filePath, QString const& componentXMLPath,\r\n        QSharedPointer<const Component> targetComponent);\r\n\r\n    /*!\r\n     *  Runs all import plugins with matching file types for a given file and component.\r\n     *\r\n     *    @param [in] componentName       Name of thes selected component.\r\n     *    @param [in] filePath            The relative path to the input file.\r\n     *    @param [in] componentXmlPath    The path to the target component XML file.\r\n     *    @param [in] targetComponent     The target component to which import all parsed elements.     \r\n     *\r\n     *    @return The component with all the imported elements.     \r\n     */\r\n    QSharedPointer<Component> run(QString const& componentName, QString const& filePath,\r\n        QString const& componentXmlPath, QSharedPointer<const Component> targetComponent);\r\n\r\n    /*!\r\n     *  Gets all file types for which a import parser(s) can be run.\r\n     *\r\n     *    @return List of possible file types.\r\n     */\r\n    QStringList importFileTypes() const;\r\n\r\nsignals:\r\n    \r\n    //! Emitted to notice user.\r\n    void noticeMessage(QString const& message);\r\n\r\nprivate:\r\n\r\n\t// Disable copying.\r\n\tImportRunner(ImportRunner const& rhs);\r\n    ImportRunner& operator=(ImportRunner const& rhs);\r\n   \r\n    /*!\r\n     *  Adds expression parser to a given import plugin if possible.\r\n     *\r\n     *    @param [in] parser   The plugin to add expression parser to.     \r\n     */\r\n    void addExpressionParserIfPossible(ImportPlugin* importPlugin) const;\r\n\r\n    /*!\r\n     *  Scrolls the given display widget to the first highlighted row.\r\n     *\r\n     *    @param [in] sourceDisplay   The display to scroll.\r\n     */\r\n    void scrollSourceDisplayToFirstHighlight(QPlainTextEdit* sourceDisplay) const;\r\n    \r\n    /*!\r\n     *  Imports all includes from the dependency files of a given file.\r\n     *\r\n     *    @param [in] filePath            The file whose dependency files to import.\r\n     *    @param [in] componentXmlPath    The path to the target component XML file.\r\n     *    @param [in] importComponent     The component to import to.\r\n     */\r\n    void importIncludes(QString const& filePath, QString const& componentXmlPath, \r\n        QSharedPointer<Component> importComponent);\r\n    \r\n    /*!\r\n     *  Finds the include import plugins for the given file types.\r\n     *\r\n     *    @param [in] filetypes   The file types to find plugins for.\r\n     *\r\n     *    @return The found include import plugins.\r\n     */\r\n    QList<ImportPlugin*> includeImportPluginsForFileTypes(QStringList const& filetypes) const;\r\n\r\n    /*!\r\n     *  Finds the file types of a given file.\r\n     *\r\n     *    @param [in] importFile          The relative path to the file.\r\n     *    @param [in] fileSets            The file sets to find the file and its file types from.\r\n     *\r\n     *    @return File types of the given file.\r\n     */\r\n    QStringList filetypesOf(QString const& fileName, QList<QSharedPointer<FileSet> > const& fileSets) const;\r\n\r\n    /*!\r\n     *  Finds possible source analyzer plugins for given file types.\r\n     *\r\n     *    @param [in] filetypes   The file types to search for.\r\n     *\r\n     *    @return Import source analyzers capable of analyzing the given file types.\r\n     */\r\n    QList<ISourceAnalyzerPlugin*> analyzerPluginsForFileTypes(QStringList filetypes) const;\r\n\r\n    /*!\r\n     *  Imports a file to the given component.\r\n     *\r\n     *    @param [in] componentName           Name of the selected component.\r\n     *    @param [in] filePath                The path to the file to import.\r\n     *    @param [in] absoluteBasePath        The absolute base path for relative filePaths.\r\n     *    @param [in] importPluginsForFile    The import plugins to use.\r\n     *    @param [in] importComponent         The component to import to.\r\n     */\r\n    void importFile(QString const& componentName, QString const& filePath, QString const& absoluteBasePath,\r\n        QList<ImportPlugin*> importPluginsForFile, QSharedPointer<Component> importComponent);\r\n\r\n    /*!\r\n     *  Reads the content of a given file.\r\n     *\r\n     *    @param [in] relativePath    Relative path to the file from basePath.\r\n     *    @param [in] basePath        The from which to begin the relative path.\r\n     *\r\n     *    @return The file content.\r\n     */\r\n    QString readInputFile(QString const& relativePath, QString const& basePath) const;\r\n\r\n    /*!\r\n     *  Creates a display widget for the given file.\r\n     *\r\n     *    @param [in] filePath    Path to the file.\r\n     *\r\n     *    @return A display widget for the given file.\r\n     */\r\n    QPlainTextEdit* createSourceDisplayForFile(QString const& filePath) const;\r\n      \r\n    /*!\r\n     *  Finds possible import plugins for given file types.\r\n     *\r\n     *    @param [in] filetypes   The file types to search for.\r\n     *\r\n     *    @return Import plugins capable of reading the given file types.\r\n     */\r\n    QList<ImportPlugin*> importPluginsForFileTypes(QStringList const& filetypes) const;\r\n    \r\n    /*!\r\n     *  Get the selected component declaration.\r\n     *\r\n     *    @param [in] componentName   Name of the selected component declaration.\r\n     *\r\n     *    @return The selected component declaration.\r\n     */\r\n    QString getComponentFromFile(QString const& componentName) const;\r\n\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! Container for component declarations.\r\n    struct AvailableComponent\r\n    {\r\n        //! Name of the component.\r\n        QString componentName_;\r\n\r\n        //! The component declaration.\r\n        QString componentFile_;\r\n    };\r\n\r\n    //! The expression parser to use for verilog expressions.\r\n    QSharedPointer<ExpressionParser> expressionParser_;\r\n\r\n    //! All loaded import plugins.\r\n    QList<ImportPlugin*> ImportPlugins_;\r\n\r\n    //! All loaded analyzer plugins.\r\n    QList<ISourceAnalyzerPlugin*> analyzerPlugins_;\r\n\r\n    //! The parameter finder.\r\n    QSharedPointer <ComponentParameterFinder> parameterFinder_;\r\n\r\n    //! The container widget for source display widgets.\r\n    QTabWidget* displayTabs_;\r\n\r\n    //! Table containing file extensions as key combined with file types as value.\r\n    QMultiMap<QString, QString> fileSuffixTable_;\r\n\r\n    //! List of currently available component declarations.\r\n    QVector<AvailableComponent> componentsInFile_;\r\n};\r\n\r\n#endif // IMPORTRUNNER_H\r\n"
  },
  {
    "path": "KactusAPI/include/IncludeImportPlugin.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: IncludeImportPlugin.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Esko Pekkarinen\r\n// Date: 09.04.2015\r\n//\r\n// Description:\r\n// Marker interface for include import plugins.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef INCLUDEIMPORTPLUGIN_H\r\n#define INCLUDEIMPORTPLUGIN_H\r\n\r\n#include \"ImportPlugin.h\"\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Marker interface for include import plugins.\r\n//-----------------------------------------------------------------------------\r\nclass IncludeImportPlugin : public ImportPlugin\r\n{\r\npublic:\r\n    \r\n    //! The destructor.\r\n    virtual ~IncludeImportPlugin() {};\r\n\r\n};\r\n\r\nQ_DECLARE_INTERFACE(IncludeImportPlugin, \"com.tut.Kactus2.IncludeImportPlugin/1.0\")\r\n\r\n#endif // INCLUDEIMPORTPLUGIN_H\r\n"
  },
  {
    "path": "KactusAPI/include/InterconnectGenerator.h",
    "content": "#ifndef INTERCONNECTGENERATOR_H\n#define INTERCONNECTGENERATOR_H\n\n#include <IPXACTmodels/Component/validators/PortValidator.h>\n#include <IPXACTmodels/Component/BusInterface.h>\n#include <IPXACTmodels/Component/Component.h>\n#include <IPXACTmodels/Design/Design.h>\n#include <IPXACTmodels/DesignConfiguration/DesignConfiguration.h>\n#include <IPXACTmodels/Component/TransparentBridge.h>\n#include <IPXACTmodels/Component/AddressSpace.h>\n\n#include <KactusAPI/include/ConfigJsonParser.h>\n#include <KactusAPI/include/BusInterfaceInterfaceFactory.h>\n#include <KactusAPI/include/BusInterfaceInterface.h>\n#include <KactusAPI/include/TransparentBridgeInterface.h>\n#include <KactusAPI/include/LibraryInterface.h>\n#include <KactusAPI/include/ComponentAndInstantiationsParameterFinder.h>\n#include <KactusAPI/include/IPXactSystemVerilogParser.h>\n#include <KactusAPI/include/PortsInterface.h>\n#include <KactusAPI/include/PortAbstractionInterface.h>\n#include <KactusAPI/include/ComponentInstanceInterface.h>\n#include <KactusAPI/include/InterconnectionInterface.h>\n#include <KactusAPI/include/AdHocConnectionInterface.h>\n#include <KactusAPI/include/MessageMediator.h>\n#include <KactusAPI/include/AbstractionTypeInterface.h>\n\n#include <QSharedPointer>\n#include <QHash>\n#include <QString>\n\nnamespace InterconnectGeneration\n{\n\n    /*!\n     *  Struct representing address-bound bus interface used as an endpoint.\n     */\n    struct EndpointData\n    {\n        QSharedPointer<BusInterface> endpointBus;  //!< Endpoint bus interface.\n        QString start;                             //!< Start address.\n        QString range;                             //!< Address range.\n    };\n\n    /*!\n     *  Struct representing bus interface information used for generation.\n     */\n    struct BusInterfaceInfo\n    {\n        std::string name;  //!< Name of the bus interface.\n        std::string mode;  //!< Mode of the interface.\n        QString start;     //!< Optional start address.\n        QString range;     //!< Optional address range.\n    };\n\n    /*!\n     *  Generator class responsible for creating an interconnect component and related IP-XACT data.\n     */\n    class KACTUS2_API Generator\n    {\n    public:\n        /*!\n         *  Constructor.\n         *\n         *  @param [in] library   Library interface to load/save IP-XACT models.\n         *  @param [in] messager  Message mediator for reporting status/errors.\n         */\n        Generator(LibraryInterface* library, MessageMediator* messager);\n\n        //! Default destructor.\n        ~Generator() = default;\n\n        /*!\n         *  Generate an interconnect component based on configuration loaded from JSON.\n         *  Starting point to generation from CLI\n         *\n         *  @return The VLNV of the generated component.\n         */\n        VLNV generate();\n\n        /*!\n         *  Generate an interconnect component from explicit configuration and connection data.\n         *  Starting point to genration from UI configuration dialog\n         *\n         *  @param [in] config         Interconnect generation configuration.\n         *  @param [in] startingPoints Map of initiator instances and interfaces.\n         *  @param [in] endPoints      Map of endpoint instances and interfaces.\n         *  @param [in] generateRtl    Flag indicating if RTL code should be generated.\n         */\n        void generate(ConfigStruct* config,\n            const QHash<QString, QList<QSharedPointer<BusInterface>>>& startingPoints,\n            const QHash<QString, QList<QSharedPointer<EndpointData>>>& endPoints,\n            bool generateRtl);\n\n        //! No copy constructor.\n        Generator(const Generator& other) = delete;\n\n        //! No assignment.\n        Generator& operator=(const Generator& other) = delete;\n\n    private:\n        /*!\n         *  Opens the design referenced by the provided VLNV and initializes the internal model.\n         *\n         *  @param [in] designVLNV  VLNV of the top-level design component.\n         */\n        void openDesign(VLNV designVLNV);\n\n        /*!\n         *  Creates a new interconnect component based on the given VLNV.\n         *  Replaces any existing component with the same VLNV.\n         *\n         *  @param [in] VLNV  VLNV of the component to create.\n         */\n        void createInterconComponent(VLNV VLNV);\n\n        /*!\n         *  Searches the current design for unconnected interfaces matching the bus definition,\n         *  and connects them to the generated interconnect.\n         */\n        void findUnconnectedInterfaces();\n\n        /*!\n         *  Processes starting points and endpoints and creates all related interfaces and connections.\n         *\n         *  @param [in] startingPoints  Map of initiators.\n         *  @param [in] endpoints       Map of endpoints.\n         */\n        void processStartingPointsAndEndpoints(\n            const QHash<QString, QList<QSharedPointer<BusInterface>>>& startingPoints,\n            const QHash<QString, QList<QSharedPointer<EndpointData>>>& endpoints);\n\n        /*!\n         *  Processes all endpoint interfaces and returns their metadata.\n         *\n         *  @param [in] endpoints  Endpoint interface mapping.\n         *  @param [in,out] index  Running index for naming.\n         *\n         *  @return List of created bus interface metadata.\n         */\n        std::vector<BusInterfaceInfo> processEndpointSide(\n            const QHash<QString, QList<QSharedPointer<EndpointData>>>& endpoints, int& index);\n\n        /*!\n         *  Processes all initiator interfaces and returns their metadata.\n         *\n         *  @param [in] startingPoints  Initiator interface mapping.\n         *  @param [in,out] index       Running index for naming.\n         *\n         *  @return List of created bus interface metadata.\n         */\n        std::vector<BusInterfaceInfo> processStartingSide(\n            const QHash<QString, QList<QSharedPointer<BusInterface>>>& startingPoints, int& index);\n\n        /*!\n         *  Creates a new interface for a bus and returns its metadata.\n         *\n         *  @param [in] instanceName  Instance name the bus belongs to.\n         *  @param [in] bus           Bus interface to replicate.\n         *  @param [in] isTop         True if bus belongs to top-level component.\n         *  @param [in] isEndpoint    True if the interface is a target.\n         *  @param [in,out] index     Index used for interface naming.\n         *\n         *  @return Metadata of created interface.\n         */\n        BusInterfaceInfo createInterfaceForBus(\n            const QString& instanceName, const QSharedPointer<BusInterface>& bus,\n            bool isTop, bool isEndpoint, int& index);\n\n        /*!\n         *  Creates a named bus interface with mode and type, used for auto-generated naming.\n         *\n         *  @param [in] busName     Logical name for the interface.\n         *  @param [in] modeString  Interface mode string.\n         *  @param [in] index       Index to insert at.\n         */\n        void createBusInterface(std::string busName, std::string modeString, int index);\n\n        /*!\n         *  Creates a fully defined bus interface and returns its name.\n         *\n         *  @param [in] busVLNV     Bus type definition.\n         *  @param [in] busName     Base name for the interface.\n         *  @param [in] modeString  Interface mode string.\n         *  @param [in] index       Insertion index.\n         *\n         *  @return Name of the created interface.\n         */\n        std::string createBusInterface(VLNV busVLNV, std::string busName, std::string modeString, int index);\n\n        /*!\n         *  Creates a clock or reset interface and maps ports appropriately.\n         *\n         *  @param [in] busName  Must be either \"clk\" or \"rst\".\n         *  @param [in] index    Index for interface insertion.\n         */\n        void createRstorClkInterface(std::string busName, int index);\n\n        /*!\n         *  Creates port maps for a given bus and interface mode.\n         *\n         *  @param [in] modeString  Interface mode (e.g. \"target\").\n         *  @param [in] busInf      Source bus interface.\n         */\n        void createPortMaps(std::string modeString, QSharedPointer<BusInterface> busInf);\n\n        /*!\n         *  Clones and adds physical ports from a component to the interconnect.\n         *\n         *  @param [in] comp     Source component.\n         *  @param [in] busName  Bus interface name.\n         *  @param [in] isTop    True if the port belongs to top-level component.\n         */\n        void createPhysPorts(QSharedPointer<Component> comp, QString busName, bool isTop = false);\n\n        /*!\n         *  Applies address space, subinterfaces, and bridges to the bus interfaces.\n         *\n         *  @param [in] createdBuses  List of bus interface metadata.\n         */\n        void finalizeBusInterfaceCustomization(const std::vector<BusInterfaceInfo>& createdBuses);\n\n        /*!\n         *  Creates an address space with provided name, range, and width.\n         *\n         *  @param [in] spaceName  Name of the address space.\n         *  @param [in] range      Address range in IP-XACT format.\n         *  @param [in] width      Address width (default = 32).\n         */\n        void createAddressSpace(std::string spaceName, QString range, QString width = \"32\");\n\n        /*!\n         *  Analyzes endpoint ranges and creates a shared global address space.\n         *\n         *  @param [in] endpoints  Endpoint mapping including start/range data.\n         */\n        void createGlobalAddressSpaceFromEndpoints(\n            const QHash<QString, QList<QSharedPointer<EndpointData>>>& endpoints);\n\n        /*!\n         *  Creates a channel and assigns all appropriate interfaces to it.\n         */\n        void createChannel();\n\n        /*!\n         *  Resolves the VLNV of a component instance from the design.\n         *\n         *  @param [in] instanceName  Instance name.\n         *  @param [in] isTop         Whether the instance is the top-level component.\n         *\n         *  @return VLNV reference if found.\n         */\n        QSharedPointer<ConfigurableVLNVReference> resolveComponentVLNV(\n            const QString& instanceName, bool isTop) const;\n\n        /*!\n         *  Determines if a bus is a target based on its interface mode.\n         *\n         *  @param [in] bus  Bus interface to evaluate.\n         *\n         *  @return True if it's a target interface.\n         */\n        bool isTargetInterface(const QSharedPointer<BusInterface>& bus) const;\n\n        /*!\n         *  Computes correct interface mode string based on revision and context.\n         *\n         *  @param [in] bus         Bus to evaluate.\n         *  @param [in] isTarget    True if it's a target.\n         *  @param [in] isChannel   True if interconnect is channel-based.\n         *  @param [in] isTop       True if it's a top-level interface.\n         *\n         *  @return Corresponding interface mode string.\n         */\n        std::string getInterfaceMode(QSharedPointer<BusInterface> bus, bool isTarget, bool isChannel, bool isTop);\n\n        /*!\n         *  Extracts the logical port name from a physical port.\n         *\n         *  @param [in] comp          Component owning the port.\n         *  @param [in] busName       Name of the bus interface.\n         *  @param [in] physicalName  Name of the physical port.\n         *\n         *  @return Matching logical port name if found.\n         */\n        std::string getLogicalPortName(QSharedPointer<Component> comp, QString busName, QString physicalName) const;\n\n        /*!\n         *  Gets the width bounds from the abstraction layer for a logical port.\n         *\n         *  @param [in] logicalName  Logical port name.\n         *\n         *  @return Pair of left and right bounds as strings.\n         */\n        std::pair<QString, QString> getWidthBoundsFromAbstraction(const std::string& logicalName) const;\n\n        /*!\n         *  Retrieves mirrored bounds (left/right) for a given physical port.\n         *\n         *  @param [in] physicalName  Name of the physical port.\n         *\n         *  @return Pair of bounds as strings.\n         */\n        std::pair<QString, QString> getMirroredWidthBounds(const QString& physicalName) const;\n\n        /*!\n         *  Parses a hexadecimal string from IP-XACT format into an integer.\n         *\n         *  @param [in] str  Input string.\n         *  @param [out] ok  Will be set true if conversion succeeds.\n         *\n         *  @return Parsed 64-bit value.\n         */\n        quint64 parseIpxactHex(const QString& str, bool* ok);\n\n        /*!\n         *\tCreates file and file set for generated rtl\n         */\n        void createFileAndFileset();\n\n        //-----------------------------------------------------------------------------\n        // Data.\n        //-----------------------------------------------------------------------------\n\n        //! Message handler.\n        MessageMediator* messager_{ nullptr };\n\n        //! Library interface for model IO.\n        LibraryInterface* library_{ nullptr };\n\n        //! Interconnect component under construction.\n        QSharedPointer<Component> interconComponent_{ nullptr };\n\n        //! Currently loaded design.\n        QSharedPointer<Design> design_{ nullptr };\n\n        //! Parameter finder for expression parsing.\n        QSharedPointer<ComponentParameterFinder> parameterFinder_{\n            new ComponentAndInstantiationsParameterFinder(nullptr) };\n\n        //! Expression parser.\n        QSharedPointer<ExpressionParser> expressionParser_{\n            new IPXactSystemVerilogParser(parameterFinder_) };\n\n        //! Expression formatter.\n        QSharedPointer<ExpressionFormatter> expressionFormatter_{\n            new ExpressionFormatter(parameterFinder_) };\n\n        //! Interface for managing bus interfaces.\n        BusInterfaceInterface* busInfInterface_{ nullptr };\n\n        //! Validator for ports.\n        QSharedPointer<PortValidator> portValidator_{\n            new PortValidator(expressionParser_,\n                QSharedPointer<QList<QSharedPointer<View>> >()) };\n\n        //! Interface for managing physical ports.\n        PortsInterface* portsInterface_{\n            new PortsInterface(portValidator_, expressionParser_, expressionFormatter_) };\n\n        //! Interface for logical/physical abstraction mappings.\n        PortAbstractionInterface* portAbsInterface_{\n            new PortAbstractionInterface(expressionParser_, expressionFormatter_) };\n\n        //! Interface for interconnections.\n        InterconnectionInterface* connectionInterface_{ new InterconnectionInterface() };\n\n        //! Interface for ad hoc connections.\n        AdHocConnectionInterface* adhocConnectionInterface_{ new AdHocConnectionInterface() };\n\n        //! Interface for managing component instances.\n        ComponentInstanceInterface* instanceInterface_{\n            new ComponentInstanceInterface(connectionInterface_, adhocConnectionInterface_) };\n\n        //! Interface for abstraction type resolution.\n        AbstractionTypeInterface* absTypeInf_{ nullptr };\n\n        //! Configuration data for generation.\n        ConfigStruct* config_;\n\n\n\n        //! List of initiator interfaces.\n        QList<QSharedPointer<BusInterface>> initiators_;\n\n        //! List of target interfaces.\n        QList<QSharedPointer<BusInterface>> targets_;\n\n        //! Path to component save directory.\n        QString directory_;\n\n        //! Naming prefix for generated ports/interfaces.\n        std::string prefix_;\n\n        //! Name of the global address space.\n        std::string globalAddressSpaceName_;\n\n        //! Generated clock port/interface name.\n        std::string clockName_;\n\n        //! Generated reset port/interface name.\n        std::string rstName_;\n\n        //! VLNV of the main bus definition.\n        VLNV busDefVLNV_;\n\n        //! VLNV of the reset signal.\n        VLNV rstVLNV_;\n\n        //! VLNV of the clock signal.\n        VLNV clkVLNV_;\n\n        //! Logical port name for clock.\n        QString clkPort_;\n\n        //! Logical port name for reset.\n        QString rstPort_;\n    };\n}\n\n#endif // INTERCONNECTGENERATOR_H\n"
  },
  {
    "path": "KactusAPI/include/InterconnectRTLWriter.h",
    "content": "//-----------------------------------------------------------------------------\n// File: InterconnectRTLWriter.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Teemu Hanhisuanto, Linda Virtanen\n// Date: 07.2025\n//\n// Description:\n// Generates top-level Verilog interconnects for supported bus types utilizing\n// Pulp Platform libraries (https://github.com/pulp-platform).\n//-----------------------------------------------------------------------------\n\n#ifndef INTERCONNECTRTLWRITER_H\n#define INTERCONNECTRTLWRITER_H\n\n#include \"ConfigJsonParser.h\"\n\n#include <QtCore>\n\n#include <IPXACTmodels/Component/Component.h>\n\n#include <KactusAPI/include/LibraryInterface.h>\n#include <KactusAPI/include/MessageMediator.h>\n#include <KactusAPI/include/PluginManager.h>\n#include <KactusAPI/include/CLIGenerator.h>\n#include <KactusAPI/include/IPlugin.h>\n#include <KactusAPI/include/PluginUtilityAdapter.h>\n#include <KactusAPI/include/VersionHelper.h>\n\nnamespace InterconnectGeneration\n{\n\n    class InterconnectRTLWriter\n    {\n    public:\n        //! The constructor\n        InterconnectRTLWriter(QSharedPointer<Component> component, LibraryInterface* library,\n            MessageMediator* messager, QString directory, ConfigStruct* config,\n            QString clk, QString rst);\n\n        //! The destructor\n        ~InterconnectRTLWriter() = default;\n\n        //! Called externally to generate the interconnect code\n        void generateRTL();\n\n        //! No copying. No assignment.\n        InterconnectRTLWriter(const InterconnectRTLWriter& other) = delete;\n        InterconnectRTLWriter& operator=(const InterconnectRTLWriter& other) = delete;\n\n    private:\n\n        /*!\n         *  Calls method 'writeAxiParams' and outputs 'AXI_BUS' bus instances to the\n         *  given stream.\n         *\n         *    @param [in] stream    Verilog file output stream\n         */\n        void writeAXI4(QTextStream& stream);\n\n\n        /*!\n         *  Calls method 'writeAxiParams' and outputs 'AXI_LITE' bus instances to\n         *  the given stream.\n         *\n         *    @param [in] stream    Verilog file output stream\n         */\n        void writeAXI4LITE(QTextStream& stream);\n\n\n        /*!\n         *  Outputs local parameters for numbers of initiators, targets, and ID width.\n         *\n         *    @param [in] stream    Verilog file output stream\n         */\n        void writeAxiParams(QTextStream& stream);\n\n\n        /*!\n         *  Outputs AddrMapXbar-specific content, including typedef for\n         *  'axi_pkg::xbar_rule_', initialization of AddrMapXbar, and calls to\n         *  'parseAddress' to get correct memory addresses in hexadecimal form.\n         *\n         *    @param [in] stream    Verilog file output stream\n         */\n        void writeAxiAddrMap(QTextStream& stream);\n\n\n        /*!\n         *  Outputs a localparam for configuring the submodule of an AXI crossbar.\n         *\n         *    @param [in] stream    Verilog file output stream\n         */\n        void writeAxiXbarCfg(QTextStream& stream);\n\n\n        /*!\n         *  Checks that 'InitList' and 'TargetList' contain at least one object.\n         *  Then outputs initialization of an AXI or AXI Lite crossbar submodule.\n         *\n         *    @param [in] stream    Verilog file output stream\n         */\n        void writeAxiXbar(QTextStream& stream);\n\n\n        /*!\n         *  Outputs signal assignments between initiator/target and the\n         *  corresponding interface module. Performs null pointer checks for\n         *  'component_' and each of its ports\n         *\n         *    @param [in] stream    Verilog file output stream\n         *    @param [in] busName   Name of the current interface\n         *                          (e.g. 'jtag_dbg_wrapper_OBI_T')\n         *    @param [in] index     Index of the current interface\n         *    @param [in] isInit    Boolean indicating whether the interface\n         *                          represents an initiator or target\n         */\n        void writeSignalAssignments(QTextStream& stream, QString busName, int index, bool isInit);\n\n\n        /*!\n         *  Returns immediately if 'TargetList' is empty. Iterates through each\n         *  target and calls the 'writeSignalAssignments' function.\n         *\n         *    @param [in] stream    Verilog file output stream\n         */\n        void writeTargetAssign(QTextStream& stream);\n\n\n        /*!\n         *  Returns immediately if 'InitList' is empty. Iterates through each\n         *  initiator and calls the 'writeSignalAssignments' function.\n         *\n         *    @param [in] stream    Verilog file output stream\n         */\n        void writeInitAssign(QTextStream& stream);\n\n\n        /*!\n         *  Outputs OBI-specific local parameters for various integers and the\n         *  'obi_cfg' parameter used in initialization of submodules.\n         *\n         *    @param [in] stream    Verilog file output stream\n         */\n        void writeObiParams(QTextStream& stream);\n\n\n        /*!\n         *  Outputs instantiations of interface modules for initiators and targets.\n         *\n         *    @note Due to a known issue in the used library when only one initiator\n         *          is present, an extra initiator interface is added in that case.\n         *\n         *    @param [in] stream  Verilog file output stream\n         */\n        void writeObiInterfaces(QTextStream& stream);\n\n\n        /*!\n         *  Outputs a packed struct and address map array for OBI target address\n         *  regions. Calls 'parseAddress' and modifies address ranges for ObiAddrXbar.\n         *\n         *    @param [in] stream    Verilog file output stream\n         */\n        void writeObiAddrMap(QTextStream& stream);\n\n\n        /*!\n         *  Outputs initialization of an OBI crossbar interface.\n         *\n         *    @param [in] stream    Verilog file output stream\n         */\n        void writeObiXbar(QTextStream& stream);\n\n\n        /*!\n         *  Iterates through a Verilog file and removes the line containing the old\n         *  'endmodule' in order to place a new one at the end.\n         *\n         *    @param [in] file    Verilog file that will be modified\n         */\n        void removeEndmodule(QFile& file);\n\n\n        /*!\n         *  Returns an n*4-width QString of spaces to create indentation.\n         *\n         *    @param [in] n   Depth of the indentation\n         *    @return         A QString containing n*4 spaces\n         */\n        QString indent(int n = 1);\n\n\n        /*!\n         *  Tries to parse an address from hexadecimal, binary, or decimal format into\n         *  hexadecimal format with an \"<AddressWidth>'h\" prefix. If parsing fails,\n         *  returns the trimmed original input value.\n         *\n         *    @param [in] original   String that is tried to be parsed\n         *    @return   A QString containing either the parsed address or trimmed\n         *              original input\n         */\n        QString parseAddress(QString original);\n\n\n        /*!\n         *  Returns a section comment with given title and possible subtitle.\n         *\n         *    @param [in] title     Title, text that is written first\n         *    @param [in] subtitle  Subtitle, text that is written second\n         *    @return               A QString containing the section comment\n         */\n        QString commentWriter(QString title, QString subtitle = \"\");\n\n        QSharedPointer<Component> component_{ nullptr };\n\n        MessageMediator* messager_{ nullptr };\n\n        LibraryInterface* library_{ nullptr };\n\n        //! Configure struct defined in 'ConfigJsonParser.h'\n        ConfigStruct* config_;\n\n        QString directory_;\n        QString clkPort_;\n        QString rstPort_;\n\n        //! Based on ports defined in 'axi/src/axi_intf.sv'\n        QStringList axiPorts_ = {\n            // Write address channel\n            \"aw_id\", \"aw_addr\", \"aw_len\", \"aw_size\", \"aw_burst\", \"aw_lock\", \"aw_cache\",\n            \"aw_prot\", \"aw_qos\", \"aw_region\", \"aw_atop\", \"aw_user\", \"aw_writetoken\", \"aw_readpointer\",\n\n            // Write data channel\n            \"w_data\", \"w_strb\", \"w_last\", \"w_user\", \"w_writetoken\", \"w_readpointer\",\n\n            // Write response channel\n            \"b_id\", \"b_resp\", \"b_user\", \"b_writetoken\", \"b_readpointer\",\n\n            // Read address channel\n            \"ar_id\", \"ar_addr\", \"ar_len\", \"ar_size\", \"ar_burst\", \"ar_lock\", \"ar_cache\",\n            \"ar_prot\", \"ar_qos\", \"ar_region\", \"ar_user\", \"ar_writetoken\", \"ar_readpointer\",\n\n            // Read data channel\n            \"r_id\", \"r_data\", \"r_resp\", \"r_last\", \"r_user\", \"r_writetoken\", \"r_readpointer\"\n        };\n\n\n        //! Based on ports defined in 'axi/src/axi_intf.sv'\n        QStringList axiLitePorts_ = {\n            // Write address channel\n            \"aw_addr\", \"aw_prot\", \"aw_valid\", \"aw_ready\",\n\n            // Write data channel\n            \"w_data\", \"w_strb\", \"w_valid\", \"w_ready\",\n\n            // Write response channel\n            \"b_resp\", \"b_valid\", \"b_ready\",\n\n            // Read address channel\n            \"ar_addr\", \"ar_prot\", \"ar_valid\", \"ar_ready\",\n\n            // Read data channel\n            \"r_data\", \"r_resp\", \"r_valid\", \"r_ready\"\n        };\n\n\n        //! Based on ports defined in 'obi/src/obi_intf.sv'\n        QStringList obiPorts_ = {\n            // Output\n            \"req\", \"reqpar\", \"gnt\", \"gntpar\", \"addr\", \"we\", \"be\", \"wdata\", \"aid\", \"a_optional\",\n\n            // Input\n            \"rvalid\", \"rvalidpar\", \"rready\", \"rreadypar\", \"rdata\", \"rid\", \"err\", \"r_optional\"\n        };\n\n        QStringList supportedInterfaces = { \"axi4\", \"axi4lite\", \"obi\" };\n\n        QString axiTargetBus_ = \"_target\";\n        QString axiInitBus_ = \"_init\";\n        QString axiXbar_;\n\n        QString axiTargetParam_ = \"AXI_TARGETS\";\n        QString axiInitParam_ = \"AXI_INITIATORS\";\n        QString IdWidthInits_ = \"IdWidthInits\";\n        QString addrRulesParam_ = \"NoAddrRules\";\n        QString ruleType_ = \"rule_t\";\n        QString addrMapXBAR_ = \"AddrMapXBAR\";\n        QString axiCfg_ = \"xbar_cfg\";\n\n        QString obiTargetParam_ = \"OBI_TARGETS\";\n        QString obiInitParam_ = \"OBI_INITIATORS\";\n        QString obiAddrRule_ = \"addr_rule_t\";\n        QString obiInitInterface_ = \"obi_init_bus\";\n        QString obiTargetInterface_ = \"obi_target_bus\";\n\n        //! Defined in 'obi/src/obi_pkg.sv'\n        QStringList obiXbarCfgParams_ = {\n            \"ADDR_WIDTH\",\n            \"DATA_WIDTH\",\n            IdWidthInits_,\n            \"obi_pkg::ObiMinimalOptionalConfig\"\n        };\n\n        /*QStringList obiXbarCfgParams_ = {\n            /*\"AUSER_WIDTH\",\n            \"WUSER_WIDTH\",\n            \"RUSER_WIDTH\",\n            \"MID_WIDTH\",\n            \"ACHK_WIDTH\",\n            \"RCHK_WIDTH\"\n        };*/\n    };\n}\n\n#endif // INTERCONNECTRTLWRITER_H\n"
  },
  {
    "path": "KactusAPI/include/InterconnectionInterface.h",
    "content": "//-----------------------------------------------------------------------------\n// File: InterconnectionInterface.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 09.09.2021\n//\n// Description:\n// Interface for accessing design interconnections.\n//-----------------------------------------------------------------------------\n\n#ifndef INTERCONNECTIONINTERFACE_H\n#define INTERCONNECTIONINTERFACE_H\n\n#include <NameGroupInterface.h>\n\n#include <QSharedPointer>\n\nclass Design;\nclass Interconnection;\n\n//-----------------------------------------------------------------------------\n//! Interface for accessing design interconnections.\n//-----------------------------------------------------------------------------\nclass KACTUS2_API InterconnectionInterface : public NameGroupInterface\n{\npublic:\n\n    /*!\n     *  The constructor.\n     */\n    InterconnectionInterface();\n\n    /*!\n     *  The destructor.\n     */\n    virtual ~InterconnectionInterface() = default;\n\n    /*!\n     *  Setup the interconnections.\n     *\n     *    @param [in] newDesign   Design containing the interconnections.\n     */\n    void setInterconnections(QSharedPointer<Design> newDesign);\n\n    /*!\n     *  Get index of the selected interconnection.\n     *\n     *    @param [in] itemName    Name of the selected interconnection.\n     *\n     *    @return Index of the selected interconnection.\n     */\n    virtual int getItemIndex(std::string const& itemName) const override final;\n\n    /*!\n     *  Get name of the indexed interconnection.\n     *\n     *    @param [in] itemIndex   Index of the selected interconnection.\n     *\n     *    @return Name of the selected interconnection.\n     */\n    std::string getIndexedItemName(int itemIndex) const final;\n\n    /*!\n     *  Get the name of the selected interconnection.\n     *\n     *    @param [in] startInstanceName   Name of the component instance containing the first bus interface.\n     *    @param [in] startBusName        Name of the first bus interface.\n     *    @param [in] endInstanceName     Name of the component instance containing the second bus interface.\n     *    @param [in] endBusName          Name of the second bus interface.\n     *\n     *    @return Name of the selected interconnection.\n     */\n    std::string getConnectionName(std::string const& startInstanceName, std::string const& startBusName,\n        std::string const& endInstanceName, std::string const& endBusName) const;\n\n    /*!\n     *  Get the name of the selected hierarchical interconnection.\n     *\n     *    @param [in] instanceName    Name of the component instance containing the selected bus interface.\n     *    @param [in] instanceBus     Name of the selected component instance bus interface.\n     *    @param [in] topBus          Name of the top component bus interface.\n     *\n     *    @return Name of the selected interconnection.\n     */\n    std::string getHierarchicalConnectionName(std::string const& instanceName, std::string const& instanceBus,\n        std::string const& topBus) const;\n\n    /*!\n     *  Get the number of available interconnections.\n     *\n     *    @return Number of available interconnections.\n     */\n    virtual int itemCount() const override final;\n\n    /*!\n     *  Get the names of the available interconnections.\n     *\n     *    @return Names of the available interconnections.\n     */\n    virtual std::vector<std::string> getItemNames() const override final;\n\n    /*!\n     *  Set a new name for the selected interconnection.\n     *\n     *    @param [in] currentName     Name of the selected interconnection.\n     *    @param [in] newName         New name for the interconnection.\n     *\n     *    @return True, if successful, false otherwise.\n     */\n    virtual bool setName(std::string const& currentName, std::string const& newName) override final;\n\n    /*!\n     *  Get the description of the selected interconnection.\n     *\n     *    @param [in] itemName    Name of the selected interconnection.\n     *\n     *    @return Description of the selected interconnection.\n     */\n    virtual std::string getDescription(std::string const& itemName) const override final;\n\n    /*!\n     *  Set a new description for the selected interconnection.\n     *\n     *    @param [in] itemName        Name of the selected interconnection.\n     *    @param [in] newDescription  New description.\n     *\n     *    @return True, if successful, false otherwise.\n     */\n    virtual bool setDescription(std::string const& itemName, std::string const& newDescription) override final;\n\n    /*!\n     *  Validates the contained interconnections.\n     *\n     *    @return True, if all the interconnections are valid, false otherwise.\n     */\n    virtual bool validateItems() const override final;\n\n    /*!\n     *  Check if the selected interconnection has a valid name.\n     *\n     *    @param [in] itemName    Name of the selected interconnection.\n     *\n     *    @return True, if the name is valid, false otherwise.\n     */\n    virtual bool itemHasValidName(std::string const& itemName) const override final;\n\n    /*!\n     *  Add a new interconnection.\n     *\n     *    @param [in] startComponentInstance  Name of the component instance containing the first bus interface.\n     *    @param [in] startBus                Name of the first bus interface.\n     *    @param [in] endComponentInstance    Name of the component instance containing the second bus interface.\n     *    @param [in] endBus                  Name of the second bus interface.\n     *    @param [in] connectionName          Name of the connection.\n     */\n    void addInterconnection(std::string const& startComponentInstance, std::string const& startBus,\n        std::string const& endComponentInstance, std::string const& endBus, std::string const& connectionName = \"\");\n\n    /*!\n     *  Add a new hierarchical interconnection.\n     *\n     *    @param [in] instanceName        Name of the component instance containing the selected bus interface.\n     *    @param [in] instanceBus         Name of the selected component instance bus interface.\n     *    @param [in] topBus              Name of the selected top component bus interface.\n     *    @param [in] connectionName      Name of the connection.\n     */\n    void addHierarchicalInterconnection(std::string const& instanceName, std::string const& instanceBus,\n        std::string const& topBus, std::string const& connectionName = \"\");\n\n    /*!\n     *  Remove the selected interconnection.\n     *\n     *    @param [in] connectionName  Name of the selected interconnection.\n     *\n     *    @return True, if successful, false otherwise.\n     */\n    bool removeInterconnection(std::string const& connectionName);\n\n    /*!\n     *  Remove interconnections connected to the selected component instance.\n     *\n     *    @param [in] instanceName    Name of the selected component instance.\n     *\n     *    @return True, if successful, false otherwise.\n     */\n    bool removeInstanceInterconnections(std::string const& instanceName);\n\n    /*!\n     *  Check if the selected interconnection exists.\n     *\n     *    @param [in] connectionName  Name of the selected interconnection.\n     *\n     *    @return True, if the interconnection exists, false otherwise.\n     */\n    bool interconnectionExists(std::string const& connectionName) const;\n\n    /*!\n     *  Rename the component references in connections.\n     *\n     *    @param [in] currentName     Current name of the component instance.\n     *    @param [in] newName         New name for the component instance.\n     */\n    void renameComponentReferences(std::string const& currentName, std::string const& newName);\n\n    //! No copying. No assignment.\n    InterconnectionInterface(const InterconnectionInterface& other) = delete;\n    InterconnectionInterface& operator=(const InterconnectionInterface& other) = delete;\n\nprivate:\n\n    /*!\n     *  Get the selected interconnection.\n     *\n     *    @param [in] connectionName  Name of the selected interconnection.\n     *\n     *    @return The selected interconnection.\n     */\n    QSharedPointer<Interconnection> getInterconnection(std::string const& connectionName) const;\n\n    /*!\n     *  Get the interconnection with the selected name, sliced to a NameGroup.\n     *\n     *    @param [in] connectionName   Name of the selected parameter.\n     *\n     *    @return The sliced interconnection with the selected name.\n     */\n    QSharedPointer<NameGroup> getItem(std::string const& connectionName) const;\n\n    //-----------------------------------------------------------------------------\n    // Data.\n    //-----------------------------------------------------------------------------\n\n    //! The available interconnections.\n    QSharedPointer<QList<QSharedPointer<Interconnection> > > interconnections_;\n};\n\n#endif // INTERCONNECTIONINTERFACE_H\n"
  },
  {
    "path": "KactusAPI/include/LibraryHandler.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: libraryhandler.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Antti Kamppi\r\n// Date: 20.12.2010\r\n//\r\n// Description:\r\n// LibraryHandler is the class that implements the services to manage the IP-XACT library.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef LIBRARYHANDLER_H\r\n#define LIBRARYHANDLER_H\r\n\r\n#include \"LibraryInterface.h\"\r\n#include \"LibraryLoader.h\"\r\n#include \"LibraryTreeModel.h\"\r\n#include \"hierarchymodel.h\"\r\n\r\n#include \"NullChannel.h\"\r\n#include \"utils.h\"\r\n\r\n#include \"DocumentFileAccess.h\"\r\n#include \"DocumentValidator.h\"\r\n\r\n#include <IPXACTmodels/common/Document.h>\r\n#include <IPXACTmodels/common/TagData.h>\r\n\r\n#include <IPXACTmodels/kactusExtensions/KactusAttribute.h>\r\n\r\n#include <KactusAPI/KactusAPIGlobal.h>\r\n\r\n#include <QString>\r\n#include <QStringList>\r\n#include <QList>\r\n#include <QSharedPointer>\r\n#include <QObject>\r\n\r\nclass LibraryItem;\r\nclass MessageMediator;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! LibraryHandler is the class that implements the services to manage the IP-XACT library.\r\n//-----------------------------------------------------------------------------\r\nclass KACTUS2_API LibraryHandler : public QObject, public LibraryInterface\r\n{\r\n    Q_OBJECT\r\n\r\npublic:\r\n\r\n    //! The the instance of the library.\r\n    static LibraryHandler& getInstance();\r\n\r\n    //! No copying\r\n    LibraryHandler(const LibraryHandler &other) = delete;\r\n\r\n    //! No assignment\r\n    LibraryHandler& operator=(const LibraryHandler& other) = delete;\r\n\r\n    //! The destructor\r\n    ~LibraryHandler() final = default;\r\n\r\n    void setOutputChannel(MessageMediator* messageChannel);\r\n\r\n    /*! Get a model that matches given VLNV.\r\n     *\r\n     * This function can be called to get a model that matches an IP-Xact document.\r\n     * \r\n     *    @param [in] vlnv Identifies the desired document.\r\n     *\r\n     *    @return The model that matches the document.\r\n    */\r\n    QSharedPointer<Document> getModel(VLNV const& vlnv) final;\r\n\r\n    /*! Get a model that matches given VLNV for read-only access.\r\n     *\r\n     * This function can be called to get a model that matches an IP-Xact document.\r\n     * \r\n     *    @param [in] vlnv Identifies the desired document.\r\n     *\r\n     *    @return The model that matches the document.\r\n    */\r\n    QSharedPointer<Document const> getModelReadOnly(VLNV const& vlnv) final;\r\n\r\n    /*! Gets all the VLNVs currently in the library.\r\n     *\r\n     *    @return All known VLNVs in the library.\r\n    */\r\n    QList<VLNV> getAllVLNVs() const final;\r\n\r\n    /*! Checks if the library already contains the specified vlnv.\r\n     *\r\n     *    @param [in] vlnv The vlnv that is searched within the library.\r\n     *\r\n     *    @return True if the vlnv was found\r\n    */\r\n    bool contains(VLNV const& vlnv) const final;\r\n\r\n    /*! Get a path to the specified IP-Xact document.\r\n     *\r\n     *    @param [in] vlnv Specifies the wanted IP-Xact document.\r\n     *\r\n     *    @return The path to the document. If vlnv is not found then empty string is returned.\r\n    */\r\n    const QString getPath(VLNV const& vlnv) const final;\r\n\r\n    /*! Get the directory path to the specified IP-XACT document.\r\n     *\r\n     *    @param [in] vlnv Specifies the wanted IP-XACT document.\r\n     *\r\n     *    @return The directory path to the document. Does not contain the xml file name.\r\n    */\r\n    QString getDirectoryPath(VLNV const& vlnv) const final;\r\n\r\n    /*! Write the model to file system to given file path\r\n     *\r\n     * This function takes the given directory path and writes the given model to\r\n     * that directory. The path must not contain the file name.\r\n     * If file already exists in file system it is written over.\r\n     * \r\n     * When model is saved using this function it is not necessary to call \r\n     * onItemSaved() because it is called by this function.\r\n     *\r\n     *    @param [in] path            Directory path that specifies the directory to save to file into.\r\n     *    @param [in] model           The library component that is written.\r\n     * \r\n     *    @return True if the model was in valid state and was successfully written.\r\n     */\r\n    bool writeModelToFile(QString const& path, QSharedPointer<Document> model) final;\r\n\r\n    /*! Write the already registered model to file system.\r\n     *\r\n     * This function demands that the model is already part of the library and\r\n     * it's file path can be found. The changes made to the model are written\r\n     * to the previous file so the model can not be restored to it's previous \r\n     * state after this operation.\r\n     * \r\n     *    @param [in] model           The model to be written.\r\n     * \r\n     *    @return True if the model was in valid state and was successfully written.\r\n    */\r\n    bool writeModelToFile(QSharedPointer<Document> model) final;\r\n\r\n    //! Search for IP-Xact files in the file system and add them to library\r\n    void searchForIPXactFiles() final;\r\n    \r\n    /*! Get list of vlnvs that are needed by given document.\r\n     *\r\n     * This function takes an IP-Xact document and searches it and returns list\r\n     * of all vlnvs that are needed by that document. Function also searches\r\n     * all possible sub vlnvs that need other vlnvs and adds them to the list.\r\n     * The list doesn't contain single vlnv twice.\r\n     *\r\n     *    @param [in] vlnv Reference to the vlnv that is used as starting point for the search.\r\n     *    @param [out] list Reference to the list where all vlnvs are added to.\r\n     *\r\n     *    @return List containing all vlnvs that are referenced in any of the documents.\r\n     */\r\n     void getNeededVLNVs(VLNV const& vlnv, QList<VLNV>& list) final;\r\n\r\n     /*! Get list of files that are needed by the given document.\r\n     *\r\n     * This function returns a list of file paths that are converted as\r\n     * absolute file paths to the needed files. This function searches files\r\n     * only from this document, it does not search possible subcomponents.\r\n     *\r\n     *    @param [in] vlnv    Reference to the vlnv that is used for the search.\r\n     *    @param [out] list   The files are appended to the list if they are not already on the list.\r\n     */\r\n     void getDependencyFiles(VLNV const& vlnv, QStringList& list) final;\r\n\r\n     /*! Get the library tree's root item\r\n     *\r\n     *    @return The root item.\r\n     */\r\n     LibraryItem const* getTreeRoot() const final;\r\n\r\n     /*! Get the document type of given vlnv.\r\n     * \r\n     * If vlnv is not found in the library then VLNV::INVALID is returned.\r\n     *\r\n     *    @param [in] vlnv Specifies the document that's type is wanted.\r\n     *\r\n     *    @return Type of the document.\r\n    */\r\n    VLNV::IPXactType getDocumentType(VLNV const& vlnv) final;\r\n\r\n    /*! Count how many times the given component is instantiated in the library.\r\n     *\r\n     *    @param [in] vlnv Identifies the component that's instances are searched.\r\n     *\r\n     *    @return Number of found instances.\r\n     */\r\n    int referenceCount(VLNV const& vlnv) const final;\r\n\r\n    /*! Get the items that have referenced the given vlnv in their meta data.\r\n     *\r\n     *    @param [out] list           The search results.\r\n     *    @param [in] vlnvToSearch    Identifies the item to search for.\r\n     * \r\n     *    @return Number of owners found.\r\n    */\r\n    int getOwners(QList<VLNV>& list, VLNV const& vlnvToSearch) const final;\r\n\r\n    /*! Get the items that are needed by the specified item.\r\n     *\r\n     *    @param [in] list QList where the search results are appended.\r\n     *    @param [in] vlnvToSearch Identifies the item thats child-items are wanted.\r\n     *\r\n     *    @return int The number of found children.\r\n    */\r\n    int getChildren(QList<VLNV>& list, VLNV const& vlnvToSearch) const final;\r\n\r\n    /*! Get the VLNV of the design for a given hierarchy reference.\r\n     *\r\n     * This function can be used by calling it with a hierarchy reference found\r\n     * if a component's hierarchical view. Function checks if the reference is\r\n     * directly for a design and returns the design vlnv. If reference is for a\r\n     * configuration then the design vlnv is searched from the configuration and\r\n     * design vlnv is returned. If design is not found then invalid vlnv is \r\n     * returned.\r\n     * \r\n     *    @param [in] hierarchyRef The hierarchical reference obtained from component's view.\r\n     *\r\n     *    @return VLNV The vlnv identifying the design object.\r\n    */\r\n    VLNV getDesignVLNV(VLNV const& hierarchyRef) final;\r\n\r\n    /*! Get pointer to the design for a given hierarchy reference.\r\n     * \r\n     * * This function can be used by calling it with a hierarchy reference found\r\n     * if a component's hierarchical view. Function checks if the reference is\r\n     * directly for a design and returns the design pointer. If reference is for a\r\n     * configuration then the design vlnv is searched from the configuration and\r\n     * design pointer is returned. If design is not found then null pointer is \r\n     * returned.\r\n     * \r\n     *    @param [in] hierarchyRef The hierarchical reference obtained from component's view.\r\n     *\r\n     *    @return QSharedPointer<Design> The design.\r\n    */\r\n    QSharedPointer<Design> getDesign(VLNV const& hierarchyRef) final;\r\n\r\n    /*! Check if the identified object is in valid state.\r\n     *\r\n     *    @param [in] vlnv Identifies the object to check.\r\n     *\r\n     *    @return bool True if the object was valid. False if invalid or object was not found in library.\r\n    */\r\n    bool isValid(VLNV const& vlnv) final;\r\n\r\n    HierarchyModel* getHierarchyModel();\r\n\r\n    LibraryTreeModel* getTreeModel();\r\n\r\n    /*!\r\n     *  Find errors in the given document.\r\n     *\r\n     *    @param [in] document           The document to check.\r\n     *    @param [in] documentPath       The path to the document file on disk.\r\n     *\r\n     *    @return List of errors in the document.\r\n     */\r\n    QVector<QString> findErrorsInDocument(QSharedPointer<Document> document, QString const& path);\r\n\r\npublic slots:\r\n\r\n    /*! Check the library items for validity\r\n     * \r\n     * This function automatically removes the invalid library items.\r\n     *\r\n    */\r\n    void onCheckLibraryIntegrity() final;\r\n\r\n    /*! Edit an item in the library\r\n     *\r\n     *    @param [in] vlnv Reference to the vlnv that identifies the object to edit.\r\n     *\r\n    */\r\n    void onEditItem(VLNV const& vlnv) final;\r\n\r\n    /*! Open the specified component design\r\n     *\r\n     *    @param [in] vlnv         Identifies the component that's design is wanted\r\n     *    @param [in] viewName     Identifies the view for the design.\r\n     *\r\n    */\r\n    void onOpenDesign(VLNV const& vlnv, QString const& viewName) final;\r\n\r\n    /*!\r\n     *  Opens the memory design of the given HW design.\r\n     *  \r\n     *    @param [in] vlnv        The vlnv of the HW design.\r\n     *    @param [in] activeView  The active view of the selected HW design.\r\n     */\r\n    void onOpenMemoryDesign(VLNV const& vlnv, QString const& activeView);\r\n\r\n    /*! Open the specified component SW design\r\n     *\r\n     *    @param [in] vlnv Identifies the component that's SW design is wanted\r\n     *\r\n    */\r\n    void onOpenSWDesign(VLNV const& vlnv);\r\n\r\n    /*!\r\n     *  Open the specified component system design\r\n     *\r\n     *    @param [in] vlnv          Identifies the component that's system design is wanted\r\n     *    @param [in] activeView    The selected view for the system design.\r\n     */\r\n    void onOpenSystemDesign(VLNV const& vlnv, QString const& activeView);\r\n\r\n\r\n    /*! Remove the specified library object from the library and file system.\r\n     * \r\n     * This function does not ask user to verify the deletion, it just removes the object and\r\n     * it's xml file. If vlnv is for component the component's files are not removed.\r\n     * \r\n     *    @param [in] vlnv Identifies the object.\r\n     *\r\n    */\r\n    void removeObject(VLNV const& vlnv) final;\r\n\r\n    /*! Remove the specified library objects from the library and file system.\r\n     * \r\n     * This function opens a dialog that asks user to confirm the deletion of the objects.\r\n     * \r\n     *    @param [in] vlnvList Identifies the objects to remove.\r\n     *\r\n    */\r\n    void removeObjects(const QList<VLNV>& vlnvList) final;\r\n\r\n    /*! Call this function before saving several objects to library.\r\n    *\r\n    * When calling this before saving and then using writeModelToFile() the \r\n    * library is not update between each save operation thus making the program\r\n    * faster.\r\n    * \r\n    * Be sure to call endSave() after all items are saved.\r\n    */\r\n    void beginSave();\r\n\r\n    /*! End the saving operation and update the library.\r\n    *\r\n    * This function must be called always after calling the beginSave().\r\n    */\r\n    void endSave();\r\n\r\nsignals:\r\n\r\n\r\n    void progressStatus();\r\n\r\n    //! Signal that user wants to open the specified component for editing.\r\n    void openDesign(VLNV const& vlnv, const QString& viewName);\r\n\r\n    //! Signal that user wants to open the memory design of the specified component for editing.\r\n    void openMemoryDesign(VLNV const& vlnv, const QString& viewName);\r\n\r\n    //! Signal that user wants to open the specified software design for editing.\r\n    void openSWDesign(VLNV const& vlnv, QString const& viewName);\r\n\r\n    //! Signal that user wants to open a system for editing.\r\n    void openSystemDesign(VLNV const& vlnv, QString const& viewName);\r\n\r\n    //! Signal that user wants to open specified bus for editing\r\n    void openBus(VLNV const& busDefVLNV);\r\n\r\n    //! Signal that user wants to open specified abstraction for editing\r\n    void openAbsDef(VLNV const& absDefVLNV);\r\n\r\n    //! Signal that user wants to open specified component for editing\r\n    void openComponent(VLNV const& vlnv);\r\n\r\n    //! Signal that user wants to open specified catalog for editing\r\n    void openCatalog(VLNV const& vlnv);\r\n\r\n    //! Signal that user wants to open specified COM definition for editing\r\n    void openComDefinition(VLNV const& vlnv);\r\n\r\n    //! Signal that user wants to open specified API definition for editing\r\n    void openApiDefinition(VLNV const& vlnv);\r\n\r\n    //! Signal that the library item specified by vlnv is selected in one of the views.\r\n    void itemSelected(VLNV const& vlnv);\r\n\r\n    //! Signal that user wants to open a platform component.\r\n    void openPlatformComponent(VLNV const& vlnv);\r\n\r\n    //! Inform that object has been updated.\r\n    void updatedVLNV(VLNV const& vlnv);\r\n\r\n    //! Inform tree model that a vlnv is to be added to the tree.\r\n    void addVLNV(VLNV const& vlnv);\r\n\r\n    //! Inform tree model that a vlnv is to be removed from the tree.\r\n    void removeVLNV(VLNV const& vlnv);\r\n\r\n    //! Inform both models that the content must be reset.\r\n    void resetModel();\r\n\r\nprivate slots:\r\n    \r\n    /*! This function should be called every time an object is written to disk.\r\n    * \r\n    * This function makes sure that the library object is displayed correctly \r\n    * on library views and possible changes made to the object are updated to\r\n    * views.\r\n    * \r\n    *    @param [in] vlnv Identifies the object that was saved.\r\n    *\r\n    */\r\n    void onItemSaved(VLNV const& vlnv);\r\n\r\nprivate:\r\n\r\n    //! All relevant data about an IP-XACT document is stored in DocumentInfo.\r\n    struct DocumentInfo\r\n    {\r\n        QSharedPointer<Document> document;  //<! The model for the document.\r\n        QString path;                       //<! The path to the file containing the document.\r\n        bool isValid;                       //<! Flag for well-formed content.\r\n\r\n        //! Constructor.\r\n        explicit DocumentInfo(QString const& filePath = QString(), \r\n            QSharedPointer<Document> doc = QSharedPointer<Document>(),\r\n            bool valid = false): document(doc), path(filePath), isValid(valid) {}\r\n    };\r\n\r\n    //! Struct for collecting document statistics e.g. in export.\r\n    struct DocumentStatistics\r\n    {\r\n        int fileCount = 0;\r\n        int documentCount = 0;\r\n    };\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // The private functions used by public class methods\r\n    //-----------------------------------------------------------------------------\r\n\r\n    /*! The constructor\r\n *\r\n *    @param [in] dialer  The dialer that provides search options.\r\n *    @param [in] parent  The parent widget of this instance.\r\n */\r\n    LibraryHandler();\r\n\r\n\r\n    //! Connect the signals and slots that keep the data models synchronized.\r\n    void syncronizeModels();\r\n\r\n    //! Show error message for VLNV not found in the library.\r\n    void showNotFoundError(VLNV const& vlnv) const;\r\n\r\n    //! Adds a IP-XACT document into the library cache.\r\n    bool addObject(QSharedPointer<Document> model, QString const& filePath);\r\n\r\n    //! Clears the library cache of documents.\r\n    void clearCache();\r\n\r\n    //! Loads all available VLNVs into the library cache.\r\n    void loadAvailableVLNVs();\r\n\r\n    //! Resets the tree and hierarchy model.\r\n    void resetModels();\r\n\r\n    //! Shows the results of the library integrity check.\r\n    void showIntegrityResults() const;\r\n\r\n    /*!\r\n     * Removes the given file from the file system.\r\n     *\r\n     *    @param [in] filePath  Path to the file to be removed.\r\n     *\r\n     *    @return True, if the file was successfully removed, otherwise false.\r\n     */\r\n     bool removeFile(QString const& filePath) const;\r\n\r\n    /*!\r\n     *  Check if the given document is valid IP-XACT.\r\n     *\r\n     *    @param [in] document           The document to check.\r\n     *    @param [in] documentPath       The path to the document file on disk.\r\n     *\r\n     *    @return True, if the document is valid, otherwise false.\r\n     */\r\n    bool validateDocument(QSharedPointer<Document> document, QString const& documentPath);\r\n\r\n\r\n    /*! Check the validity of VLNV references within a document.\r\n     *\r\n     *    @param [in] document    The document to check.\r\n     *\r\n     *    @return True if the VLVN references are valid, otherwise false.\r\n     */\r\n    bool validateDependentVLNVReferencences(QSharedPointer<Document> document);\r\n\r\n    /*!\r\n     *  Finds any errors within a given document VLNV references.\r\n     *\r\n     *    @param [in] document    The document whose VLNV references to check.\r\n     *    @param [out] errorList  The list of errors to add any found errors.\r\n     */\r\n    void findErrorsInDependentVLNVReferencences(QSharedPointer<const Document> document, QVector<QString>& errorList);\r\n\r\n    /*! Check the validity of directory references within a document.\r\n     *\r\n     * \r\n     *    @param [in] document    The document to check.\r\n     *    @param [in] documentPath    The path to the document XML file.\r\n     *\r\n     *    @return True if the directory references are valid, otherwise false.\r\n     */\r\n    bool validateDependentDirectories(QSharedPointer<Document> document, QString const& documentPath);\r\n\r\n    /*!\r\n     *  Finds any errors within a given document directory references.\r\n     *\r\n     *    @param [in] document        The document whose directory references to check.\r\n     *    @param [in] documentPath    The path to the document XML file.\r\n     *    @param [out] errorList      The list of errors to add any found errors.\r\n     */\r\n    void findErrorsInDependentDirectories(QSharedPointer<const Document> document, QString const& documentPath,\r\n        QVector<QString>& errorList);\r\n\r\n    /*! Check the validity of file references within a document.\r\n     *\r\n     *    @param [in] document    The document to check.\r\n     *\r\n     *    @return True if the file references are valid, otherwise false.\r\n     */\r\n    bool validateDependentFiles(QSharedPointer<Document> document, QString const& documentPath);\r\n\r\n    /*!\r\n     *  Finds any errors within a given document file references.\r\n     *\r\n     *    @param [in] document        The document whose file references to check.\r\n     *    @param [in] documentPath    The path to the document XML file.\r\n     *    @param [out] errorList      The list of errors to add any found errors.\r\n     */\r\n    void findErrorsInDependentFiles(QSharedPointer<const Document> document, QString const& documentPath,\r\n        QVector<QString>& errorList);\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n\r\n    //! Default message channel for errors/informations.\r\n    NullChannel defaultChannel;\r\n\r\n    //! Message channel for errors/informations.\r\n    MessageMediator* messageChannel_{ &defaultChannel };\r\n\r\n    //! Loads the library content.\r\n    LibraryLoader loader_{ };\r\n\r\n    /*! Cache of documents in the library.\r\n     *\r\n     * Key = VLNV that identifies the library object.\r\n     * Value = Information on the document.\r\n     */\r\n    QMap<VLNV, DocumentInfo> documentCache_;\r\n\r\n    //! Checks if the given string is a URL (invalids are allowed) or not.\r\n    QRegularExpressionValidator urlTester_{ Utils::URL_VALIDITY_REG_EXP, this };\r\n\r\n    //! Validator for IP-XACT documents in the library.\r\n    DocumentValidator validator_{ this };\r\n\r\n    //! The model for the tree view\r\n    LibraryTreeModel treeModel_{ this, this };\r\n\r\n    //! The model for the hierarchy view\r\n    HierarchyModel hierarchyModel_{ this, this };\r\n\r\n    //! If true then items are being saved and library is not refreshed\r\n    bool saveInProgress_{ false };\r\n\r\n    //! Statistics for library integrity check.\r\n    DocumentStatistics checkResults_;\r\n\r\n};\r\n\r\n#endif // LIBRARYHANDLER_H\r\n"
  },
  {
    "path": "KactusAPI/include/LibraryInterface.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: libraryinterface.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Antti Kamppi\r\n// Date: 22.02.2011\r\n//\r\n// Description:\r\n// LibraryInterface defines an interface to operate the IP-XACT-library.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef LIBRARYINTERFACE_H\r\n#define LIBRARYINTERFACE_H\r\n\r\n#include <IPXACTmodels/common/VLNV.h>\r\n\r\n#include <QObject>\r\n#include <QSharedPointer>\r\n\r\nclass Design;\r\nclass LibraryItem;\r\nclass Document;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! LibraryInterface defines an interface to operate the IP-XACT-library.\r\n//-----------------------------------------------------------------------------\r\nclass LibraryInterface\r\n{\r\n\r\npublic:\r\n\r\n    /*! Get a model that matches given VLNV. Must be used when changes are made to the document.\r\n     *  The provided document is a copy, meaning that it must be explicitly saved after the changes.\r\n     * \r\n     *    @param [in] vlnv    Identifies the desired document.\r\n     *\r\n     *    @return The model that matches the document. The ownership of the object remains on Library Handler.\r\n    */\r\n    virtual QSharedPointer<Document> getModel(VLNV const& vlnv) = 0;\r\n\r\n    /*! Convenience function for getting the model that matches given VLNV, if the type is known beforehand.\r\n    *\r\n    *    @param [in] vlnv    Identifies the desired document.\r\n    *\r\n    *    @return The model that matches the document.\r\n    */\r\n    template <class T>\r\n    QSharedPointer<T> getModel(VLNV const& vlnv)\r\n    {\r\n        return getModel(vlnv).dynamicCast<T>();\r\n    }\r\n\r\n    /*! Get a model that matches given VLNV for read-only access. May be used when no changes are to be made\r\n     *  for the document.\r\n     * \r\n     *    @param [in] vlnv    Identifies the desired document.\r\n     *\r\n     *    @return The model that matches the document. The ownership of the object remains on Library Handler.\r\n    */\r\n    virtual QSharedPointer<Document const> getModelReadOnly(VLNV const& vlnv) = 0;\r\n\r\n    /*! Convenience function for getting the model that matches given VLNV, if the type is known beforehand.\r\n    *\r\n    *    @param [in] vlnv    Identifies the desired document.\r\n    *\r\n    *    @return The read-only model that matches the document.\r\n    */\r\n    template <class T>\r\n    QSharedPointer<T const> getModelReadOnly(VLNV const& vlnv)\r\n    {\r\n        return getModelReadOnly(vlnv).dynamicCast<T const>();\r\n    }\r\n\r\n    /*! Checks if the library already contains the specified VLNV.\r\n     *\r\n     *    @param [in] vlnv    The VLNV that is searched within the library.\r\n     *\r\n     *    @return True if the vlnv was found, otherwise false.\r\n    */\r\n    virtual bool contains(VLNV const& vlnv) const = 0;\r\n\r\n    /*! Gets all the VLNVs currently in the library.\r\n     *\r\n     *    @return All known VLNVs in the library.\r\n    */\r\n    virtual QList<VLNV> getAllVLNVs() const = 0;\r\n\r\n    /*! Get a path to the specified IP-XACT document.\r\n     *\r\n     *    @param [in] vlnv    Specifies the wanted IP-XACT document.\r\n     *\r\n     *    @return The path to the document. If VLNV is not found then empty string is returned.\r\n    */\r\n    virtual const QString getPath(VLNV const& vlnv) const = 0;\r\n\r\n    /*! Get the directory path to the specified IP-XACT document.\r\n     *\r\n     *    @param [in] vlnv    Specifies the wanted IP-XACT document.\r\n     *\r\n     *    @return The directory path to the document. Does not contain the XML file name.\r\n    */\r\n    virtual QString getDirectoryPath(VLNV const& vlnv) const = 0;\r\n\r\n    /*! Write the model to file system to given file path.\r\n     *\r\n     *    @param [in] path            Directory path that specifies the directory to save to file into.\r\n     *    @param [in] model           The library component that is written.\r\n     * \r\n     *    @return True if the model was in valid state and was successfully written.\r\n     *\r\n     *      @remark The path must not contain the file name.\r\n     *      @remark If file already exists in file system it is overwritten.\r\n     *      @remark It is not necessary to call onItemSaved() because it is called by this function.\r\n     */\r\n    virtual bool writeModelToFile(QString const& path, QSharedPointer<Document> model) = 0;\r\n\r\n    /*! Write the already registered model to file system.\r\n     * \r\n     *    @param [in] modelThe        model to be written.\r\n     * \r\n     *    @return True if the model was in valid state and was successfully written.\r\n     *\r\n     *      @remark The model must be already part of the library and it's file path can be found.\r\n     *      @remark This operation cannot be undone.\r\n    */\r\n    virtual bool writeModelToFile(QSharedPointer<Document> model) = 0;\r\n\r\n    //! Search for IP-XACT files in the file system and add them to library.\r\n    virtual void searchForIPXactFiles() = 0;\r\n\r\n    /*! Get list of VLNVs that are needed by given document.\r\n    *\r\n    * This function takes an IP-XACT document and searches it and returns list\r\n    * of all VLNVs that are needed by that document. Function also searches\r\n    * all possible sub VLNVs that need other VLNVs and adds them to the list.\r\n    * The list doesn't contain single VLNV twice.\r\n    *\r\n    *    @param [in] vlnv     The VLNV that is used as starting point for the search.\r\n    *    @param [out] list    The list where all VLNVs are added to.\r\n    */\r\n    virtual void getNeededVLNVs(VLNV const& vlnv, QList<VLNV>& list) = 0;\r\n\r\n    /*! Get list of files that are needed by the given document.\r\n    *\r\n    * This function returns a list of file paths that are converted as\r\n    * absolute file paths to the needed files. This function searches files\r\n    * only from this document, it does not search possible subcomponents.\r\n    *\r\n    *    @param [in] vlnv     The VLNV that is used for the search.\r\n    *    @param [out] list    The files are appended to the list if they are not already on the list.\r\n    */\r\n    virtual void getDependencyFiles(VLNV const& vlnv, QStringList& list) = 0;\r\n\r\n    /*! \r\n    *      Returns const-pointer to the library tree's root item\r\n    */\r\n    virtual LibraryItem const* getTreeRoot() const = 0;\r\n\r\n    /*! Get the document type of given vlnv.\r\n     * \r\n     * If vlnv is not found in the library then VLNV::INVALID is returned.\r\n     *\r\n     *    @param [in] vlnv Specifies the document that's type is wanted.\r\n     *\r\n     *    @return The type of the document.\r\n    */\r\n    virtual VLNV::IPXactType getDocumentType(VLNV const& vlnv) = 0;\r\n\r\n    /*! Count how many times the given component is instantiated in the library.\r\n     *\r\n     *    @param [in] vlnv Identifies the component that's instances are searched.\r\n     *\r\n     *    @return Number of found instances.\r\n     */\r\n    virtual int referenceCount(VLNV const& vlnv) const = 0;\r\n\r\n    /*! Get the components that have instantiated the given vlnv in their design.\r\n     *\r\n     *    @param [out] list           The search results.\r\n     *    @param [in] vlnvToSearch    Identifies the component to search for.\r\n     * \r\n     *    @return Number of owners found.\r\n    */\r\n    virtual int getOwners(QList<VLNV>& list, VLNV const& vlnvToSearch) const = 0;\r\n\r\n    /*! Get the items that are needed by the specified item.\r\n     *\r\n     *    @param [out] list           The search results.\r\n     *    @param [in] vlnvToSearch    Identifies the item thats child-items are wanted.\r\n     *\r\n     *    @return int The number of found children.\r\n    */\r\n    virtual int getChildren(QList<VLNV>& list, VLNV const& vlnvToSearch) const = 0;\r\n\r\n    /*! Get the VLNV of the design for a given hierarchy reference.\r\n     *\r\n     * This function can be used by calling it with a hierarchy reference found\r\n     * in a component's hierarchical view. Function checks if the reference is\r\n     * directly for a design and returns the design VLNV. If reference is for a\r\n     * configuration then the design VLNV is searched from the configuration and\r\n     * design VLNV is returned. If design is not found then invalid VLNV is \r\n     * returned.\r\n     * \r\n     *    @param [in] hierarchyRef The hierarchical reference obtained from component's view.\r\n     *\r\n     *    @return VLNV The VLNV identifying the design object.\r\n    */\r\n    virtual VLNV getDesignVLNV(VLNV const& hierarchyRef) = 0;\r\n\r\n    /*! Get the design for a given hierarchy reference.\r\n     * \r\n     * This function can be used by calling it with a hierarchy reference found\r\n     * if a component's hierarchical view. Function checks if the reference is\r\n     * directly for a design and returns the design pointer. If reference is for a\r\n     * configuration then the design VLNV is searched from the configuration and\r\n     * design pointer is returned. If design is not found then null pointer is \r\n     * returned.\r\n     * \r\n     *    @param [in] hierarchyRef The hierarchical reference obtained from component's view.\r\n     *\r\n     *    @return The design.\r\n    */\r\n    virtual QSharedPointer<Design> getDesign(VLNV const& hierarchyRef) = 0;\r\n\r\n    /*! Check if the identified object is in valid state.\r\n     *\r\n     *    @param [in] VLNV Identifies the object to check.\r\n     *\r\n     *    @return bool True if the object was valid. False if invalid or object was not found in library.\r\n    */\r\n    virtual bool isValid(VLNV const& vlnv) = 0;\r\n\r\npublic slots:\r\n\r\n    /*! Check the library items for validity\r\n     * \r\n     *      @remark This function automatically removes the invalid library items.\r\n     *\r\n    */\r\n    virtual void onCheckLibraryIntegrity() = 0;\r\n\r\n    /*! Edit an item in the library\r\n     *\r\n     *    @param [in] vlnv Reference to the vlnv that identifies the object to edit.\r\n    */\r\n    virtual void onEditItem(VLNV const& vlnv) = 0;\r\n\r\n    /*! Open the specified component design\r\n     *\r\n     *    @param [in] vlnv \t\tIdentifies the component that's design is wanted\r\n     *    @param [in] viewName \tIdentifies the view for the design.\r\n    */\r\n    virtual void onOpenDesign(VLNV const& vlnv, QString const& viewName) = 0;\r\n\r\n    /*! Remove the specified library object from the library and file system.\r\n     * \r\n     * This function does not ask user to verify the deletion, it just removes the object and\r\n     * it's xml file. If vlnv is for component the component's files are not removed.\r\n     * \r\n     *    @param [in] vlnv Identifies the object.\r\n    */\r\n    virtual void removeObject(VLNV const& vlnv) = 0;\r\n\r\n    /*! Remove the specified library objects from the library and file system.\r\n     * \r\n     * This function opens a dialog that asks user to confirm the deletion of the objects.\r\n     * \r\n     *    @param [in] vlnvList Identifies the objects to remove.\r\n    */\r\n    virtual void removeObjects(const QList<VLNV>& vlnvList) = 0;\r\n\r\n    /*! Call this function before saving several objects to library.\r\n    *\r\n    * When calling this before saving and then using writeModelToFile() the \r\n    * library is not update between each save operation thus making the program\r\n    * faster.\r\n    * \r\n    * Be sure to call endSave() after all items are saved.\r\n    */\r\n    virtual void beginSave() = 0;\r\n\r\n    /*! End the saving operation and update the library.\r\n    *\r\n    * This function must be called always after calling the beginSave().\r\n    */\r\n    virtual void endSave() = 0;\r\n\r\nsignals:\r\n\r\n    //! Signal that user wants to open the specified component for editing.\r\n    void openDesign(VLNV const& vlnv, QString const& viewName);\r\n\r\n    //! Signal that user wants to open specified bus for editing\r\n    void openBus(VLNV const& busDefVLNV, VLNV const& absDefVLNV, bool disableBusDef);\r\n\r\n    //! Signal that user wants to open specified component for editing\r\n    void openComponent(VLNV const& vlnv);\r\n\r\n    //! Signal that user wants to create a new abstraction definition for given bus definition.\r\n    void createAbsDef(VLNV const& busDefVLNV, QString const& directory, bool disableBusDef);\r\n\r\n    //! Signal that the library item specified by vlnv is selected in one of the views.\r\n    void itemSelected(VLNV const& vlnv);\r\n\r\n    //! Signal that user wants to open a system for editing.\r\n    void openSystemDesign(VLNV const& vlnv);\r\n\r\n    //! Signal that user wants to open a platform component.\r\n    void openPlatformComponent(VLNV const& vlnv);\r\n\r\n};\r\n\r\n#endif // LIBRARYINTERFACE_H\r\n"
  },
  {
    "path": "KactusAPI/include/LibraryItem.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: libraryitem.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Antti Kamppi\r\n// Date: 24.06.2010\r\n//\r\n// Description:\r\n// LibraryItem class is used to create the hierarchical structure of IP library.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef LIBRARYITEM_H\r\n#define LIBRARYITEM_H\r\n\r\n#include <QVector>\r\n#include <QString>\r\n#include <QObject>\r\n\r\n#include <IPXACTmodels/common/VLNV.h>\r\n\r\n#include <KactusAPI/KactusAPIGlobal.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n//! LibraryItem class is used to create the hierarchical structure of IP library.\r\n//-----------------------------------------------------------------------------\r\nclass KACTUS2_API LibraryItem : public QObject\r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\r\n\t/*! enum Level is used in constructing new items in library.\r\n\t *\r\n\t * Level is used to tell what information to use from VLNV tag in creating new component in hierarchy.\r\n\t */\r\n\tenum class Level\r\n    {\r\n        ROOT = 0, \r\n\t\tVENDOR, \r\n\t\tLIBRARY,\r\n\t\tNAME,\r\n\t\tVERSION\r\n    };\r\n\r\n\t/*! The default constructor.\r\n\t*\r\n\t*       @remark Only used when creating a root item for a tree structure.\r\n\t*/\r\n\tLibraryItem(QObject* parent);\r\n\r\n\t/*! The constructor\r\n\t*\r\n\t*    @param [in] vlnv     A VLNV tag that is to be added to database.\r\n\t*    @param [in] level    The level of the item in the hierarchy.\r\n\t*    @param [in] parent   The parent of this item.\r\n\t*/\r\n\tLibraryItem(VLNV const& vlnv, Level level, LibraryItem *parent);\r\n\r\n\t//! The destructor of the class LibraryItem.\r\n\tvirtual ~LibraryItem();\r\n\r\n\t/*! Create a new child for an existing item.\r\n\t*\r\n\t*    @param [in] vlnv A VLNV tag that is to be added to database.\r\n\t*    @param [in] level The level of the item in the hierarchy.\r\n\t*/\r\n\tvoid createChild(VLNV const& vlnv, Level level);\r\n\r\n\t/*! Get the parent of the current node.\r\n\t *\r\n\t *    @return The parent of the item.\r\n\t */\r\n\tLibraryItem* parent() const;\r\n\r\n\t/*! Get the name of the item.\r\n\t *\r\n\t *    @return The name of the item.\r\n\t */\r\n\tQString name() const;\r\n\r\n\t/*! Get the level of the item in the hierarchy.\r\n\t *\r\n\t *    @return The level the item is in.\r\n\t */\r\n\tLevel getLevel() const;\r\n\r\n\t/*! Get the child item.\r\n\t *\r\n\t *    @param [in] index   index of the child item.\r\n     *\r\n\t *    @return The child.\r\n\t */\r\n\tLibraryItem* child(int index) const;\r\n\r\n\t/*! Get the row number of the child item.\r\n\t *\r\n\t *    @return The row number where the item is located in its parents list.\r\n\t */\r\n\tint row();\r\n\r\n\t/*! Get the number of child items the item has.\r\n\t *\r\n\t *    @return How many children item owns.\r\n\t */\r\n\tint getNumberOfChildren() const;\r\n\r\n\t/*! Get the VLNV tag of this item.\r\n\t *\r\n     *    @return A VLNV instance that is represented by this item.\r\n     *\r\n\t *      @remark Valid VLNV pointer can only be returned if this item is level VERSION.\r\n\t */\r\n\tVLNV getVLNV() const;\r\n\r\n\t/*! Get the index of the specified item.\r\n\t *\r\n\t *    @param [in] item    The library item that's row number is searched.\r\n\t *\r\n\t *    @return The row number of the specified item.\r\n\t */\r\n\tint getIndexOf(LibraryItem* item);\r\n\r\n\r\n\t/*! Check if this item has children or not.\r\n\t *\r\n\t *    @return True if item has child-items, otherwise false.\r\n\t */\r\n\tbool hasChildren() const;\r\n\r\n\t/*! Get list of all VLNV tags that exist under this item.\r\n\t *\r\n\t *    @return List of all VLNVs.\r\n\t */\r\n\tQVector<VLNV> getVLNVs() const;\r\n\r\n\t/*! Remove a child of this item.\r\n\t *\r\n\t *    @param [in] childItem The child item that should be removed.\r\n\t */\r\n\tvoid removeChild(LibraryItem* childItem);\r\n\r\n\t/*! Find the highest level LibraryItem that still identifies a single item.\r\n\t * \r\n\t * This function checks if there are other children. If no other children\r\n\t * are found then this function calls parent item to check if it can be\r\n\t * used to identify a single item.\r\n\t * \r\n\t *    @param [in] childItem   The item that is currently the highest possible item.\r\n\t *\r\n\t *    @return LibraryItem* The item that is to be removed.\r\n\t */\r\n\tLibraryItem* findHighestUnique(LibraryItem* childItem = 0);\r\n\r\n\t/*! Find the highest level LibraryItem that still identifies a single item.\r\n\t * \r\n\t * This function finds the highest level possible to identify a single item.\r\n\t *\r\n\t *    @param [in] vlnv The vlnv element that must be matched.\r\n\t *\r\n\t *    @return The item that is the highest level item.\r\n\t */\r\n\tLibraryItem* findHighestUnique(VLNV const& vlnv);\r\n\r\n\t/*! Find the library item that uniquely represents the specified vlnv.\r\n\t *\r\n\t *    @param [in] vlnv The vlnv that identifies the item to find.\r\n\t *\r\n\t *    @return The LibraryItem that represents the vlnv in the tree.\r\n\t */\r\n\tLibraryItem* findItem(VLNV const& vlnv);\r\n\r\n\t/*! Set the vlnv to match the tree structure of this item\r\n\t *\r\n\t *    @param [out] vlnv The vlnv instance to set.\r\n\t */\r\n\tvoid setVlnv(VLNV& vlnv);\r\n\r\n\t//! Remove the children of this item.\r\n\tvoid clear();\r\n\r\n\t/*! Get all vendor items.\r\n\t *\r\n\t *    @return All vendor items under this item.\r\n\t*/\r\n\tQVector<LibraryItem*> getVendors() const;\r\n\r\n\t/*! Get all library items.\r\n\t *\r\n\t *    @return All library items under this item.\r\n\t*/\r\n\tQVector<LibraryItem*> getLibraries() const;\r\n\r\n\t/*! Get all name items.\r\n\t *\r\n\t *    @return All name items under this item.\r\n\t*/\r\n\tQVector<LibraryItem*> getNames() const;\r\n\r\n\t/*! Get all version items.\r\n\t *\r\n\t *    @return All version items under this item.\r\n\t*/\r\n\tQVector<LibraryItem*> getVersions() const;\r\n\r\n    /*!\r\n     *  Checks if the item is valid.\r\n     *\r\n     *    @return True, if the item is valid, otherwise false.\r\n     */\r\n    bool isValid() const;\r\n\r\n    /*!\r\n     *  Sets the validity of the item.\r\n     *\r\n     *    @param [in] valid   The validity to set.\r\n     */\r\n    void setValid(bool valid);\r\n\r\nprivate:\r\n\r\n\t//! No copying\r\n\tLibraryItem(const LibraryItem &other);\r\n\r\n\t//! No assignment\r\n\tLibraryItem &operator=(const LibraryItem &other);\r\n\r\n\r\n    /*!\r\n     *  Finds the child item on the given level from the given VLNV.\r\n     *\r\n     *    @param [in] level   The level to get the item for.\r\n     *    @param [in] vlnv    The VLNV to get the item from.\r\n     *\r\n     *    @return The child item on the given level.\r\n     */\r\n    LibraryItem* findChildForLevel(Level level, VLNV const& vlnv);\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! The name of the item on the level (i.e. TUT in vendor-level).\r\n\tQString name_;\r\n\r\n\t//! The level of the item.\r\n\tLevel level_;\r\n\r\n\t//! The child items of current item in the hierarchy.\r\n\tQVector<LibraryItem*> childItems_;\r\n\r\n\t//! The parent of the item.\r\n\tLibraryItem *parentItem_;\r\n\r\n\t//! A VLNV tag that matches the version.\r\n\tVLNV vlnv_;\r\n\r\n    bool valid_;\r\n};\r\n\r\n#endif // LIBRARYITEM_H\r\n"
  },
  {
    "path": "KactusAPI/include/LibraryLoader.h",
    "content": "//-----------------------------------------------------------------------------\n// File: LibraryLoader.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Esko Pekkarinen\n// Date: 07.04.2018\n//\n// Description:\n// Class for IP-XACT file search and type parsing.\n//-----------------------------------------------------------------------------\n\n#ifndef LIBRARYLOADER_H\n#define LIBRARYLOADER_H\n\n#include \"DocumentFileAccess.h\"\n\n#include <KactusAPI/include/MessageMediator.h>\n\n#include <IPXACTmodels/common/VLNV.h>\n\n#include <QObject>\n\n//-----------------------------------------------------------------------------\n//! Class for IP-XACT file search and type parsing.\n//-----------------------------------------------------------------------------\nclass LibraryLoader \n{\npublic:\n\n\t//! Struct for load targets.\n    struct LoadTarget\n    {\n        QString path; //!< The path to IP-XACT file.\n        VLNV vlnv;    //!< The VLNV defined in the file.\n\n\t\t//! Constructor.\n        LoadTarget(VLNV const& targetVLNV = VLNV(), QString targetPath = QString()): \n            path(targetPath), vlnv(targetVLNV) {}\n    };\n\n\t/*! Cleans the directory structure.\n\t*\n\t*    @param [in] changedDirectories\tChanged directories (e.g. after a remove).\n\t*/\n    void clean(QStringList const& changedDirectories) const;\n\n\t/*! Searches for IP-XACT files and returns any found targets.\n\t*\n\t*    @return The found IP-XACT targets.\n\t*/\n    QVector<LoadTarget> parseLibrary(MessageMediator const* messageChannel) const;\n\nprivate:\n\n    /*! Finds the VLNV in the given file.\n    *\n    *    @param [in]\t\tpath\tThe file path to search.\n    *\n    *    @return The VLNV found in the given file.\n    */\n    VLNV getDocumentVLNV(QString const& path, MessageMediator const* messageChannel) const;\n\n    /*! Clear the empty directories from the disk within given path.\n     *\n     *    @param [in] dirPath The path that is removed until one of the base library locations is reached.\n     *    @param [in] libraryLocations Contains the base library locations user has defined.\n     *\n    */\n    void clearDirectoryStructure(QString const& dirPath, QStringList const& libraryLocations) const;\n\n    /*! Check if the path contains one of the given paths.\n     *\n     *    @param [in] path The path to a directory.\n     *    @param [in] pathsToSearch Paths that are checked if they are contained in the given path.\n     *\n    */\n    bool containsPath(QString const& path, QStringList const& pathsToSearch) const;\n};\n\nQ_DECLARE_TYPEINFO(LibraryLoader::LoadTarget, Q_MOVABLE_TYPE);\n\n#endif // LIBRARYLOADER_H\n"
  },
  {
    "path": "KactusAPI/include/LibraryTreeModel.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: librarytreemodel.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 20.12.2010\r\n//\r\n// Description:\r\n// The model that contains the LibraryItems to display library hierarchically.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef LIBRARYTREEMODEL_H\r\n#define LIBRARYTREEMODEL_H\r\n\r\n#include \"LibraryItem.h\"\r\n\r\n#include <IPXACTmodels/common/VLNV.h>\r\n\r\n#include <KactusAPI/KactusAPIGlobal.h>\r\n\r\n#include <QAbstractItemModel>\r\n#include <QModelIndex>\r\n#include <QVariant>\r\n#include <QSharedPointer>\r\n#include <QList>\r\n\r\nclass LibraryInterface;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! The model that contains the LibraryItems to display library hierarchically.\r\n//-----------------------------------------------------------------------------\r\nclass KACTUS2_API LibraryTreeModel : public QAbstractItemModel\r\n{\r\n    Q_OBJECT\r\n\r\npublic:\r\n\r\n\t/*! The constructor\r\n\t*\r\n\t*    @param [in] handler          The instance that manages the library.\r\n\t*    @param [in] parent           The owner of this class\r\n\t*\r\n\t*/\r\n    LibraryTreeModel(LibraryInterface* handler, QObject* parent = 0);\r\n\r\n\t//! The destructor\r\n\tvirtual ~LibraryTreeModel();\r\n\r\n\t/*! Get the data for the headers of this model.\r\n\t*\r\n\t*    @param [in] section          Specifies the column of the header.\r\n\t*    @param [in] orientation      The orientation of the header, only Qt::Horizontal supported.\r\n\t*    @param [in] role             Specifies the role of the data.\r\n\t*\r\n\t*    @return QVariant containing the data.\r\n\t*/\r\n\tvirtual QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole ) const;\r\n\r\n\t/*! Get the number of columns in this model\r\n\t*\r\n\t*    @param [in] parent Model index identifying the item that's column count is  wanted.\r\n\t*\r\n\t*    @return Number of columns.\r\n\t*/\r\n\tvirtual int columnCount(QModelIndex const& parent = QModelIndex()) const;\r\n\r\n\t/*! Get the number of rows an item has.\r\n\t*\r\n\t*    @param [in] parent Model index identifying the item that's row count is wanted\r\n\t*\r\n\t*    @return Number of rows the item has.\r\n\t*/\r\n\tvirtual int rowCount(QModelIndex const& parent = QModelIndex()) const;\r\n\r\n\t/*! Get the model index of the specified object.\r\n\t*\r\n\t*    @param [in] row      Row number of the object.\r\n\t*    @param [in] column   Column number of the object.\r\n\t*    @param [in] parent   Model index of the parent of the object.\r\n\t*\r\n\t*    @return QModelIndex that identifies the object.\r\n\t*/\r\n\tvirtual QModelIndex index(int row, int column, QModelIndex const& parent = QModelIndex()) const;\r\n\r\n\t/*! Get the model index of the parent of the object\r\n\t*\r\n\t*    @param [in] child Model index that identifies the child of the object.\r\n\t*\r\n\t*    @return QModelIndex that identifies the parent of the given object.\r\n\t*/\r\n\tvirtual QModelIndex parent(QModelIndex const& child) const;\r\n\r\n\t/*! Get the data associated with given object.\r\n\t*\r\n\t*    @param [in] index    Model index that identifies the object that's data is wanted.\r\n\t*    @param [in] role     Specifies the type of data wanted.\r\n\t*\r\n\t*    @return QVariant Containing the requested data.\r\n\t*/\r\n\tvirtual QVariant data(QModelIndex const& index, int role = Qt::DisplayRole) const;\r\n\r\n\t/*! Does the specified item have child items or not.\r\n\t*\r\n\t*    @param [in] parent Model index identifying the object that's children are asked.\r\n\t*\r\n\t*    @return True if object has child objects.\r\n\t*/\r\n\tvirtual bool hasChildren(QModelIndex const& parent = QModelIndex()) const;\r\n\r\n\t/*! Get the flags that identify possible methods for given object.\r\n\t*\r\n\t*    @param [in] index Model index identifying the object that's flags are requested.\r\n\t*\r\n\t*    @return Qt::ItemFlags that specify how the object can be handled.\r\n\t*/\r\n\tQt::ItemFlags flags(QModelIndex const& index) const;\r\n\r\n\t/*! Get the root item of the tree.\r\n\t*\r\n\t*    @return The root item\r\n\t*/\r\n\tLibraryItem* getRoot() const;\r\n\r\n\t/*! Create a model index for a library item\r\n\t*\r\n\t*    @param [in] item The LibraryItem that's model index is wanted\r\n\t*\r\n\t*    @return QModelIndex that identifies the libraryItem.\r\n\t*/\r\n\tQModelIndex index(LibraryItem* item);\r\n\r\nsignals:\r\n\r\n\t//! Emit an error message to be printed to user.\r\n\tvoid errorMessage(const QString& message);\r\n\r\n\t//! Emit a notice message to be printed to user.\r\n\tvoid noticeMessage(const QString& message);\r\n\r\n\t//! Open the design of a component.\r\n\tvoid openDesign(VLNV const& vlnv, QString const& viewName);\r\n\r\n\t//! Open the SW design of a component.\r\n\tvoid openSWDesign(VLNV const& vlnv);\r\n\r\n\t//! Open the system design of a component.\r\n\tvoid openSystemDesign(VLNV const& vlnv, QString const& viewName);\r\n\r\n    //! Open the memory design of a HW design.\r\n    void openMemoryDesign(VLNV const& vlnv, QString const& viewName);\r\n\r\n\t//! Open the component in a component editor.\r\n\tvoid editItem(VLNV const& vlnv);\r\n\r\n\t//! Create a new abstraction definition for given bus definition.\r\n\tvoid createAbsDef(VLNV const& vlnv);\r\n\r\n\t//! Create new design with given vlnv.\r\n\tvoid createDesign(VLNV const& vlnv);\r\n\r\n\t//! Create new SW design with given vlnv.\r\n\tvoid createSWDesign(VLNV const& vlnv);\r\n\r\n\t//! Create new system design with given vlnv.\r\n\tvoid createSystemDesign(VLNV const& vlnv);\r\n\r\n\t//! Remove the specified VLNV from the library\r\n\tvoid removeVLNV(QList<VLNV> vlnvs);\r\n\r\n\t//! Export a list of vlnv items to a new location.\r\n\tvoid exportItems(const QList<VLNV> list);\r\n\r\n\t//! Shows errors about the item at the given index.\r\n\tvoid showErrors(VLNV const& vlnv);\r\n\r\n\t//! Refresh the item filtering because changes have been made\r\n\tvoid invalidateFilter();\r\n\r\npublic slots:\r\n\r\n\t//! Open the selected hierarchical design\r\n\tvoid onOpenDesign(QModelIndex const& index, QString const& viewName);\r\n\r\n    //! Open the selected memory design.\r\n    void onOpenMemoryDesign(QModelIndex const& index, QString const& viewName);\r\n\r\n\t//! Open the selected hierarchical SW design\r\n\tvoid onOpenSWDesign(QModelIndex const& index);\r\n\r\n\t//! Open the selected hierarchical system design\r\n\tvoid onOpenSystemDesign(QModelIndex const& index, QString const& viewName);\r\n\r\n\t//! Open the selected document e.g. component or bus definition.\r\n\tvoid onOpenDocument(QModelIndex const& index);\r\n\r\n\t//! Create new design\r\n\tvoid onCreateNewDesign(QModelIndex const& index);\r\n\r\n\t//! Create new SW design\r\n\tvoid onCreateNewSWDesign(QModelIndex const& index);\r\n\r\n\t//! Create new system design\r\n\tvoid onCreateNewSystemDesign(QModelIndex const& index);\r\n\r\n\t//! When delete is selected in search view\r\n\tvoid onDeleteItem(QModelIndex const& index);\r\n\r\n\t//! When export is selected in search view\r\n\tvoid onExportItem(QModelIndex const& index);\r\n\r\n\t//! Shows errors about the item at the given index.\r\n\tvoid onShowErrors(QModelIndex const& index);\r\n\r\n\t//! Create a new abstraction definition for given bus definition.\r\n\tvoid onCreateAbsDef(QModelIndex const& index);\r\n\r\n\t//! Remove the specified vlnv branch from the tree.\r\n\tvoid onRemoveVLNV(VLNV const& vlnv);\r\n\r\n\t//! Add the specified vlnv branch to the tree.\r\n\tvoid onAddVLNV(VLNV const& vlnv);\r\n\r\n\t//! Reset the model.\r\n\tvoid onResetModel();\r\n\r\n    /*! This function should be called when an IP-XACT document has changed.\r\n     *\r\n     * Function updates the hierarchical model so that changes made to the document are visible.\r\n     *\r\n     *    @param [in] vlnv Identifies the document that changed.\r\n    */\r\n    void onDocumentUpdated(VLNV const& vlnv);\r\n\r\nprivate:\r\n\r\n\t//! No copying\r\n\tLibraryTreeModel(const LibraryTreeModel& other);\r\n\r\n\t//! No assignment\r\n\tLibraryTreeModel& operator=(const LibraryTreeModel& other);\r\n\r\n\t/*! Removes an item from the treeModel\r\n\t*\r\n\t*    @param [in] toRemove     The LibraryItem that is the highest-level item to remove.\r\n\t*/\r\n\tvoid removeLibraryItem(LibraryItem* toRemove);\r\n    \r\n    /*!\r\n     *  Validates the given item and possible sub-items.\r\n     *\r\n     *    @param [in] item   The item to validate.\r\n     *\r\n     *    @return True, if the item is valid, otherwise false.\r\n     */\r\n    bool validate(LibraryItem* item);\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n\t/*! The root of the tree.\r\n\t*\r\n\t* The LibraryTreeFilter owns the root item and the root item owns it's child items.\r\n\t*/\r\n\tLibraryItem* rootItem_;\r\n\r\n\t//! The instance that manages the library.\r\n\tLibraryInterface* handler_;\r\n};\r\n\r\n#endif // LIBRARYTREEMODEL_H\r\n"
  },
  {
    "path": "KactusAPI/include/ListHelper.h",
    "content": "//-----------------------------------------------------------------------------\n// File: ListHelper.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Esko Pekkarinen\n// Date: 1.11.2023\n//\n// Description:\n// \n//-----------------------------------------------------------------------------\n\n#ifndef LIST_HELPER_H \n#define LIST_HELPER_H \n\n#include <vector>\n#include <string>\n\nnamespace ListHelper\n{\n    template <typename T>\n    std::vector<std::string> listNames(QSharedPointer<QList<QSharedPointer<T> > > container)\n    {\n        std::vector<std::string> names;\n        std::for_each(container->cbegin(), container->cend(), [&names](auto const& item)\n            {\n                names.push_back(item->name().toStdString());\n            });\n        return names;\n    }\n\n    template <typename T>\n    int itemIndex(std::string const& itemName, QSharedPointer<QList<QSharedPointer<T> > > container)\n    {\n        if (container == nullptr)\n        {\n            return -1;\n        }\n\n        const QString name = QString::fromStdString(itemName);\n\n        const auto pos = std::find_if(container->cbegin(), container->cend(), [&name](auto const& item)\n            {\n                return item->name().compare(name) == 0;\n            });\n\n        if (pos == container->cend())\n        {\n            return -1;\n        }\n\n        return std::distance(container->cbegin(), pos);\n    }\n};\n\n#endif // LIST_HELPER_H "
  },
  {
    "path": "KactusAPI/include/ListParameterFinder.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ListParameterFinder.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Mikko Teuho\r\n// Date: 24.03.2015\r\n//\r\n// Description:\r\n// The implementation for finding parameters from a list with the correct ID.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef LISTPARAMETERFINDER_H\r\n#define LISTPARAMETERFINDER_H\r\n\r\n#include \"ParameterFinder.h\"\r\n\r\n#include <IPXACTmodels/common/Parameter.h>\r\n\r\n#include \"KactusAPI/KactusAPIGlobal.h\"\r\n\r\n#include <QSharedPointer>\r\n#include <QList>\r\n\r\n//-----------------------------------------------------------------------------\r\n//! The implementation for finding parameters from a list with the correct ID.\r\n//-----------------------------------------------------------------------------\r\nclass KACTUS2_API ListParameterFinder : public ParameterFinder\r\n{\r\n\r\npublic:\r\n\r\n    /*!\r\n     *  The constructor.\r\n     */\r\n    ListParameterFinder();\r\n\r\n    /*!\r\n     *  The Destructor.\r\n     */\r\n    ~ListParameterFinder() override = default;\r\n\r\n    //! No copying\r\n    ListParameterFinder(const ListParameterFinder& other) = delete;\r\n    //! No assignment\r\n    ListParameterFinder& operator=(const ListParameterFinder& other) = delete;\r\n\r\n    /*!\r\n     *  Get the parameter with the given id.\r\n     *\r\n     *    @param [in] parameterId     The id of the parameter being searched for.\r\n     */\r\n    QSharedPointer<Parameter> getParameterWithID(QStringView parameterId) const override;\r\n\r\n    /*!\r\n     *  Checks if a parameter with the given id exists.\r\n     *\r\n     *    @param [in] id      The id to search for.\r\n     *\r\n     *    @return True, if the parameter with the given id exists, otherwise false.\r\n     */\r\n    bool hasId(QStringView id) const override;\r\n\r\n    /*!\r\n     *  Finds the name of the parameter with the given id.\r\n     *\r\n     *    @param [in] id      The id to search for.\r\n     *\r\n     *    @return The name of the parameter.\r\n     */\r\n    QString nameForId(QStringView id) const override;\r\n\r\n    /*!\r\n     *  Finds the value of the parameter with the given id.\r\n     *\r\n     *    @param [in] id      The id of the parameter to search for.\r\n     *\r\n     *    @return The value of the parameter.\r\n     */\r\n    QString valueForId(QStringView id) const override;\r\n\r\n    /*!\r\n     *  Gets all of the ids of parameters in the list.\r\n     *\r\n     *    @return A list containing all of the ids.\r\n     */\r\n    QStringList getAllParameterIds() const override;\r\n\r\n    /*!\r\n     *  Gets the number of parameters in the list.\r\n     *\r\n     *    @return The number of parameters in the list.\r\n     */\r\n    int getNumberOfParameters() const noexcept override;\r\n\r\n    /*!\r\n     *  Set the parameter list.\r\n     *\r\n     *    @param [in] parameterList   [Description].\r\n     */\r\n    void setParameterList(QSharedPointer<QList<QSharedPointer<Parameter> > > parameterList) noexcept;\r\n    \r\n    /*!\r\n     *  Registers a parameter model that can modify parameters for the finder.\r\n     *\r\n     *    @param [in] model   The model to register.\r\n     */\r\n    void registerParameterModel(QAbstractItemModel const* model) final;\r\n\r\nprivate:\r\n\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! The parameters are searched from this list.\r\n    QSharedPointer<QList<QSharedPointer<Parameter> > > parameterList_ =\r\n        QSharedPointer<QList<QSharedPointer<Parameter> > >(new QList<QSharedPointer<Parameter> >());\r\n};\r\n\r\n#endif // LISTPARAMETERFINDER_H\r\n"
  },
  {
    "path": "KactusAPI/include/MasterPortInterface.h",
    "content": "//-----------------------------------------------------------------------------\n// File: MasterPortInterface.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 14.12.2020\n//\n// Description:\n// Master interface for editing component ports and port abstractions.\n//-----------------------------------------------------------------------------\n\n#ifndef MASTERPORTINTERFACE_H\n#define MASTERPORTINTERFACE_H\n\n#include <KactusAPI/KactusAPIGlobal.h>\n\n#include <NameGroupInterface.h>\n\n#include <IPXACTmodels/common/DirectionTypes.h>\n\n//-----------------------------------------------------------------------------\n//! Master interface for editing component ports and port abstractions.\n//-----------------------------------------------------------------------------\nclass KACTUS2_API MasterPortInterface : public NameGroupInterface\n{\npublic:\n\n    /*!\n     *  The constructor.\n     */\n    MasterPortInterface();\n\n    /*!\n     *  The destructor.\n     */\n    virtual ~MasterPortInterface() = default;\n\n    /*!\n     *  Add a wire port.\n     *\n     *    @param [in] newPortName     Name of the new port.\n     */\n    virtual void addWirePort(std::string const& newPortName = std::string()) = 0;\n\n    /*!\n     *  Add a transactional port.\n     *\n     *    @param [in] newPortName     Name of the new port.\n     */\n    virtual void addTransactionalPort(std::string const& newPortName = std::string()) = 0;\n\n    /*!\n     *  Check if the selected port is a wire.\n     *\n     *    @param [in] portName    Name of the selected port.\n     *\n     *    @return True, if the selected port is a wire, false otherwise.\n     */\n    virtual bool portIsWire(std::string const& portName) const = 0;\n\n    /*!\n     *  Check if the selected port is transactional.\n     *\n     *    @param [in] portName    Name of the selected port.\n     *\n     *    @return True, if the selected port is transactional, false otherwise.\n     */\n    virtual bool portIsTransactional(std::string const& portName) const = 0;\n\n    /*!\n     *  Get the icon path of a missing port.\n     *\n     *    @return Icon path for the selected port.\n     */\n    std::string getIconPathForMissingPort() const;\n\n    /*!\n     *  Get the icon path of the selected direction.\n     *\n     *    @param [in] direction   Direction of the selected port.\n     *\n     *    @return Icon path for the selected direction.\n     */\n    std::string getIconPathForDirection(DirectionTypes::Direction direction) const;\n\n    /*!\n     *  Get the icon path of the selected initiative.\n     *\n     *    @param [in] initiative  The selected initiative.\n     *\n     *    @return Icon path for the selected initiative.\n     */\n    std::string getIconPathForInitiative(QString const& initiative) const;\n\n    //! No copying. No assignment.\n    MasterPortInterface(const MasterPortInterface& other) = delete;\n    MasterPortInterface& operator=(const MasterPortInterface& other) = delete;\n};\n\n#endif // MASTERPORTINTERFACE_H\n"
  },
  {
    "path": "KactusAPI/include/MemoryBlockInterface.h",
    "content": "//-----------------------------------------------------------------------------\n// File: MemoryBlockInterface.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 31.01.2022\n//\n// Description:\n// Parent interface for editing memory blocks.\n//-----------------------------------------------------------------------------\n\n#ifndef MEMORYBLOCKINTERFACE_H\n#define MEMORYBLOCKINTERFACE_H\n\n#include <KactusAPI/KactusAPIGlobal.h>\n\n#include <ParameterizableInterface.h>\n#include <NameGroupInterface.h>\n\n#include <QVector>\n#include <QMap>\n\nclass MemoryBlockBase;\nclass AddressSpace;\nclass Segment;\nclass ParametersInterface;\nclass MemoryBlockValidator;\nclass BusInterfaceInterface;\nclass Component;\n\n//-----------------------------------------------------------------------------\n//! Parent interface for editing memory blocks.\n//-----------------------------------------------------------------------------\nclass KACTUS2_API MemoryBlockInterface : public ParameterizableInterface, public NameGroupInterface\n{\n\npublic:\n\n    /*!\n     *  The constructor.\n     *\n     *    @param [in] expressionParser        Parser for expressions.\n     *    @param [in] expressionFormatter     Formatter for expressions.\n     *    @param [in] busInterface            Interface for accessing bus interfaces.\n     *    @param [in] parameterInterface      Interface for accessing parameters.\n     */\n    MemoryBlockInterface(QSharedPointer<ExpressionParser> expressionParser,\n        QSharedPointer<ExpressionFormatter> expressionFormatter,\n        BusInterfaceInterface* busInterface,\n        ParametersInterface* parameterInterface);\n\t\n\t/*!\n     *  The destructor.\n     */\n    virtual ~MemoryBlockInterface() = default;\n\n    /*!\n     *  Set available memory blocks.\n     *\n     *    @param [in] newMemoryBlocks     The new memory block data.\n     */\n    void setMemoryBlocks(QSharedPointer<QList<QSharedPointer<MemoryBlockBase> > > newMemoryBlocks);\n\n    /*!\n     *  Setup the sub interfaces.\n     *\n     *    @param [in] newComponent    Component containing the available items.\n     */\n    void setupSubInterfaces(QSharedPointer<Component> newComponent);\n\n    /*!\n     *  Get the interface for accessing bus interfaces.\n     *\n     *    @return Interface for accessing bus interfaces.\n     */\n    BusInterfaceInterface* getBusInterface() const;\n\n    /*!\n     *  Check if the selected memory block is accepted. \n     *\n     *    @param [in] blockName   Name of the selected memory block.\n     *\n     *    @return True, if the memory block is accepted, false otherwise.\n     */\n    virtual bool acceptBlock(std::string const& blockName) const = 0;\n\n    /*!\n     *  Get index of the selected item.\n     *\n     *    @param [in] itemName    Name of the selected item.\n     *\n     *    @return Index of the selected item.\n     */\n    virtual int getItemIndex(std::string const& itemName) const override final;\n\n    /*!\n     *  Get name of the indexed item.\n     *\n     *    @param [in] itemIndex   Index of the selected item.\n     *\n     *    @return Name of the selected item.\n     */\n    std::string getIndexedItemName(int itemIndex) const final;\n\n    /*!\n     *  Get the number of available items.\n     *\n     *    @return Number of available items.\n     */\n    virtual int itemCount() const override final;\n\n    /*!\n     *  Get the names of the available items.\n     *\n     *    @return Names of the available items.\n     */\n    virtual std::vector<std::string> getItemNames() const override final;\n\n    /*!\n     *  Set a new name for the selected item.\n     *\n     *    @param [in] currentName     Name of the selected item.\n     *    @param [in] newName         New name for the item.\n     *\n     *    @return True, if successful, false otherwise.\n     */\n    virtual bool setName(std::string const& currentName, std::string const& newName) override final;\n\n    /*!\n     *  Get the calculated base address value of the selected memory block.\n     *\n     *    @param [in] blockName   Name of the selected memory block.\n     *    @param [in] baseNumber  Base for displaying the value.\n     *\n     *    @return Calculated base address value of the selected memory block.\n     */\n    std::string getBaseAddressValue(std::string const& blockName, int const& baseNumber = 0) const;\n\n    /*!\n     *  Get the formatted base address expression of the selected memory block.\n     *\n     *    @param [in] blockName   Name of the selected memory block.\n     *\n     *    @return Formatted base address expression of the selected memory block.\n     */\n    std::string getBaseAddressFormattedExpression(std::string const& blockName) const;\n\n    /*!\n     *  Get the base address expression of the selected memory block.\n     *\n     *    @param [in] blockName   Name of the selected memory block.\n     *\n     *    @return Base address expression of the selected memory block.\n     */\n    std::string getBaseAddressExpression(std::string const& blockName) const;\n\n    /*!\n     *  Set a new base address value for the selected memory block.\n     *\n     *    @param [in] blockName       Name of the selected memory block.\n     *    @param [in] newBaseAddress  New base memory value.\n     *\n     *    @return True, if successful, false otherwise.\n     */\n    bool setBaseAddress(std::string const& blockName, std::string const& newBaseAdress) const;\n    \n    /*!\n     *  Get the calculated is present value of the selected memory block.\n     *\n     *    @param [in] blockName   Name of the selected memory block.\n     *    @param [in] baseNumber  Base for displaying the value.\n     *\n     *    @return Calculated is present value of the selected memory block.\n     */\n    std::string getIsPresentValue(std::string const& blockName, int const& baseNumber = 0) const;\n\n    /*!\n     *  Get the formatted is present expression of the selected memory block.\n     *\n     *    @param [in] blockName   Name of the selected memory block.\n     *\n     *    @return Formatted is present expression of the selected memory block.\n     */\n    std::string getIsPresentFormattedExpression(std::string const& blockName) const;\n\n    /*!\n     *  Get the is present expression of the selected memory block.\n     *\n     *    @param [in] blockName   Name of the selected memory block.\n     *\n     *    @return Is present expression of the selected memory block.\n     */\n    std::string getIsPresentExpression(std::string const& blockName) const;\n\n    /*!\n     *  Set a new is present value for the selected memory block.\n     *\n     *    @param [in] blockName       Name of the selected memory block.\n     *    @param [in] newIsPresent    New is present value.\n     *\n     *    @return True, if successful, false otherwise.\n     */\n    bool setIsPresent(std::string const& blockName, std::string const& newIsPresent) const;\n\n    /*!\n     *  Get the calculated range value of the selected memory block.\n     *\n     *    @param [in] blockName   Name of the selected memory block.\n     *    @param [in] baseNumber  Base for displaying the value.\n     *\n     *    @return Calculated range value of the selected memory block.\n     */\n    std::string getRangeValue(std::string const& blockName, int const& baseNumber = 0) const;\n\n    /*!\n     *  Calculate all the references to the selected ID in the selected item.\n     *\n     *    @param [in] itemName    Name of the selected item.\n     *    @param [in] valueID     The selected ID.\n     *\n     *    @return Number of references to the selected ID in the selected item.\n     */\n    virtual int getAllReferencesToIdInItem(const std::string& itemName, std::string const&  valueID) const override;\n\n    /*!\n     *  Validates the contained items.\n     *\n     *    @return True, if all the ports are valid, false otherwise.\n     */\n    virtual bool validateItems() const override = 0;\n\n    /*!\n     *  Check if the selected item has a valid name.\n     *\n     *    @param [in] itemName    Name of the selected item.\n     *\n     *    @return True, if the name is valid, false otherwise.\n     */\n    bool itemHasValidName(std::string const& itemName) const;\n\n    /*!\n     *  Check if the selected memory block has a valid base address.\n     *\n     *    @param [in] itemName    Name of the selected memory block.\n     *\n     *    @return True, if the base address is valid, false otherwise.\n     */\n    bool hasValidBaseAddress(std::string const& itemName) const;\n\n    /*!\n     *  Check if the selected memory block has a valid is present value.\n     *\n     *    @param [in] itemName    Name of the selected memory block.\n     *\n     *    @return True, if the is present value is valid, false otherwise.\n     */\n    bool hasValidIsPresent(std::string const& itemName) const;\n\n    /*!\n     *  Add a new memory block, inserting it to specified position given by row.\n     *\n     *    @param [in] row             Row of the new memory block.\n     *    @param [in] newBlockName    Name of the new memory block.\n     */\n    virtual void addBlock(int const& row, std::string const& newBlockName = std::string(\"\")) = 0;\n\n    /*!\n     *  Add a new memory block.\n     *  This overload should be preferred when using Python.\n     *\n     *    @param [in] newBlockName    Name of the new memory block.\n     */\n    virtual void addBlock(std::string const& newBlockName = std::string(\"\"));\n\n    /*!\n     *  Remove the selected memory block.\n     *\n     *    @param [in] blockName   Name of the selected memory block.\n     *\n     *    @return True, if successful, false otherwise.\n     */\n    bool removeBlock(std::string const& blockName);\n\n    /*!\n     *  Copy the selected items.\n     *\n     *    @param [in] selectedRows    Indexes of the selected items.\n     */\n    void copyRows(std::vector<int> selectedRows);\n\n    /*!\n     *  Paste the selected items.\n     *\n     *    @return Names of the pasted items.\n     */\n    std::vector<std::string> pasteRows();\n\n    /*!\n     *  Get the number of pasted items.\n     *\n     *    @return Number of the pasted items.\n     */\n    int getPasteRowCount() const;\n\n    /*!\n     *  Get the expressions in the selected items.\n     *\n     *    @param [in] itemNames   Names of the selected items.\n     *\n     *    @return The expressions of the selected items.\n     */\n    virtual std::vector<std::string> getExpressionsInSelectedItems(std::vector<std::string> const& itemNames) const = 0;\n\n    /*!\n     *  Change the value for address unit bits.\n     *\n     *    @param [in] newAddressUnitbits  The new value for address unit bits.\n     */\n    void setAddressUnitBits(std::string const& newAddressUnitbits);\n\nprotected:\n\n    /*!\n     *  Get the available memory blocks.\n     *\n     *    @return List of available memory blocks.\n     */\n    QSharedPointer<QList<QSharedPointer<MemoryBlockBase> > > getBlocksData();\n\n    /*!\n     *  Get the base address for a new memory block.\n     *\n     *    @return Base address for a new memory block.\n     */\n    QString getNewBlockBaseAddress() const;\n\n    /*!\n     *  Get the selected memory block.\n     *\n     *    @param [in] blockName   Name of the selected memory block.\n     *\n     *    @return The selected memory block.\n     */\n    QSharedPointer<MemoryBlockBase> getBlock(std::string const& itemName) const;\n\n    /*!\n     *  Get the address unit bits.\n     *\n     *    @return The address unit bits.\n     */\n    QString getAddressUnitBits() const;\n\n    /*!\n     *  Get the address space within the selected bus interface.\n     *\n     *    @param [in] masterBusReference  Name of the selected bus interface.\n     *\n     *    @return Address space within the selected bus interface.\n     */\n    QSharedPointer<AddressSpace> getReferencedAddressSpace(QString const& masterBusReference) const;\n\nprivate:\n\n    /*!\n     *  Get the default name for a memory block.\n     *\n     *    @return Default name for a memory block.\n     */\n    virtual std::string getDefaultName() const = 0;\n\n    /*!\n     *  Get a list of the copied memory blocks.\n     *\n     *    @param [in] selectedRows    Rows of the copied memory blocks.\n     *\n     *    @return List of the copied memory blocks.\n     */\n    virtual QList<QSharedPointer<MemoryBlockBase> > getCopiedBlocks(std::vector<int> const& selectedRows) const = 0;\n\n    /*!\n     *  Get the mime type of the memory block.\n     *\n     *    @return The mime type of the memory block.\n     */\n    virtual QString getMimeType() const = 0;\n\n    /*!\n     *  Create a copy of the selected memory block.\n     *\n     *    @param [in] copiedItem  The selected memory block-\n     *\n     *    @return Copy of the selected memory block.\n     */\n    virtual QSharedPointer<MemoryBlockBase> createCopyBlock(QSharedPointer<MemoryBlockBase> copiedItem) const = 0;\n\n    /*!\n     *  Count the memory block items in the selected list.\n     *\n     *    @param [in] itemList    List of memory block items.\n     *\n     *    @return Number of memory block items in the selected list.\n     */\n    virtual int countItems(QList<QSharedPointer<MemoryBlockBase> > itemList) const = 0;\n\n    /*!\n     *  Get the memory block validator.\n     *\n     *    @return The memory block validator.\n     */\n    virtual QSharedPointer<MemoryBlockValidator> getValidator() const = 0;\n\n    /*!\n     *  Get the segment referenced by the selected subspace map.\n     *\n     *    @param [in] referencedSpace     Address space within the master bus interface referenced by the\n     *                                      selected subspace map.\n     *    @param [in] segmentReference    Name of the selected segment.\n     *\n     *    @return Segment referenced by the selected subspace map.\n     */\n    QSharedPointer<Segment> getReferencedSegment(QSharedPointer<AddressSpace> referencedSpace,\n        QString const& segmentReference) const;\n\n    //-----------------------------------------------------------------------------\n    // Data.\n    //-----------------------------------------------------------------------------\n\n    //! List of available address spaces.\n    QSharedPointer<QList<QSharedPointer<AddressSpace> > > availableAddressSpaces_{ nullptr };\n\n    //! Interface for accessing bus interfaces.\n    BusInterfaceInterface* busInterfaceInterface_{ nullptr };\n\n    //! List of the contained memory blocks.\n    QSharedPointer<QList<QSharedPointer<MemoryBlockBase> > > blockData_{ nullptr };\n\n    //! The address unit bits of the containing memory map.\n    QString addressUnitBits_;\n\n    //! Interface for accessing parameters.\n    ParametersInterface* parameterInterface_{ nullptr };\n};\n\n#endif // MEMORYBLOCKINTERFACE_H\n"
  },
  {
    "path": "KactusAPI/include/MemoryMapExpressionsGatherer.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: MemoryMapExpressionsGatherer.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Mikko Teuho\r\n// Date: 29.04.2015\r\n//\r\n// Description:\r\n// Gathers expressions from a memory map and its memory remaps.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef MEMORYMAPEXPRESSIONGATHERER_H\r\n#define MEMORYMAPEXPRESSIONGATHERER_H\r\n\r\n#include <QSharedPointer>\r\n#include <QStringList>\r\n\r\nclass MemoryMap;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Gathers expressions from a memory map and its memory remaps.\r\n//-----------------------------------------------------------------------------\r\nclass MemoryMapExpressionGatherer\r\n{\r\n\r\npublic:\r\n\r\n    /*!\r\n     *  The constructor.\r\n     */\r\n    MemoryMapExpressionGatherer();\r\n\r\n    /*!\r\n     *  The destructor.\r\n     */\r\n    virtual ~MemoryMapExpressionGatherer();\r\n\r\n    /*!\r\n     *  Get the expressions from a given memory map.\r\n     *\r\n     *    @param [in] memoryMap   The given memory map.\r\n     *\r\n     *    @return A list containing all the expressions used in a memory map.\r\n     */\r\n    QStringList getExpressions(QSharedPointer<MemoryMap> memoryMap) const;\r\n\r\nprivate:\r\n\t\r\n\t//! No copying.\r\n    MemoryMapExpressionGatherer(const MemoryMapExpressionGatherer& other);\r\n\r\n\t//! No assignment.\r\n    MemoryMapExpressionGatherer& operator=(const MemoryMapExpressionGatherer& other);\r\n};\r\n\r\n#endif // MEMORYMAPEXPRESSIONGATHERER_H\r\n"
  },
  {
    "path": "KactusAPI/include/MemoryMapInterface.h",
    "content": "//-----------------------------------------------------------------------------\n// File: MemoryMapInterface.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 15.05.2020\n//\n// Description:\n// Interface for editing memory maps and remaps.\n//-----------------------------------------------------------------------------\n\n#ifndef MEMORYMAPINTERFACE_H\n#define MEMORYMAPINTERFACE_H\n\n#include <KactusAPI/KactusAPIGlobal.h>\n\n#include <ParameterizableInterface.h>\n#include <NameGroupInterface.h>\n\nclass Component;\nclass MemoryMap;\nclass MemoryRemap;\n\nclass MemoryMapValidator;\nclass AddressBlockInterface;\nclass SubspaceMapInterface;\nclass ModeReferenceInterface;\nclass ModeReference;\n\n//-----------------------------------------------------------------------------\n//! Interface for editing memory maps and remaps.\n//-----------------------------------------------------------------------------\nclass KACTUS2_API MemoryMapInterface : public ParameterizableInterface, public NameGroupInterface\n{\n\npublic:\n\n    /*!\n     *  The constructor.\n     *\n     *    @param [in] mapValidator            Validator for memory maps.\n     *    @param [in] expressionParser        Parser for expressions.\n     *    @param [in] expressionFormatter     Formatter for expressions.\n     */\n    MemoryMapInterface(QSharedPointer<MemoryMapValidator> mapValidator,\n        QSharedPointer<ExpressionParser> expressionParser,\n        QSharedPointer<ExpressionFormatter> expressionFormatter);\n\n\t/*!\n     *  The destructor.\n     */\n    virtual ~MemoryMapInterface() = default;\n\n    /*!\n     *  Set a new address block interface.\n     *\n     *    @param [in] blockInterface  The new address block interface.\n     */\n    void setAddressBlockInterface(AddressBlockInterface* blockInterface);\n\n    /*!\n     *  Set a new subspace map interface.\n     *\n     *    @param [in] submapInterface     The new subspace map interface.\n     */\n    void setSubspaceMapInterface(SubspaceMapInterface* submapInterface);\n\n    /*!\n     *  Set available memory maps.\n     *\n     *    @param [in] component   Component containing the memory maps.\n     */\n    void setMemoryMaps(QSharedPointer<Component> component);\n\n    /*!\n     *  Get index of the selected memory map.\n     *\n     *    @param [in] itemName    Name of the selected item.\n     *\n     *    @return Index of the selected item.\n     */\n    virtual int getItemIndex(std::string const& itemName) const override final;\n\n    /*!\n     *  Get index of the selected memory remap.\n     *\n     *    @param [in] mapName     Name of the memory map containing the selected memory remap.\n     *    @param [in] remapName   Name of the selected memory remap.\n     *\n     *    @return Index of the selected memory remap.\n     */\n    int getMemoryRemapIndex(std::string const& mapName, std::string const& remapName) const;\n\n    /*!\n     *  Get name of the indexed memory map.\n     *\n     *    @param [in] itemIndex   Index of the selected memory map.\n     *\n     *    @return Name of the selected memory map.\n     */\n    std::string getIndexedItemName(int itemIndex) const final;\n    \n    /*\n     *  Get name of the indexed memory remap.\n     *\n     *    @param [in] mapName     Name of the memory map containing the selected memory remap.\n     *    @param [in] itemIndex   Index of the selected memory remap.\n     *\n     *    @return Name of the selected memory remap.\n     */\n    std::string getIndexedRemapName(std::string mapName, int const& itemIndex) const;\n\n    /*!\n     *  Get the number of available items.\n     *\n     *    @return Number of available items.\n     */\n    virtual int itemCount() const override final;\n\n    /*!\n     *  Get the number of available memory remaps in the selected memory map.\n     *\n     *    @param [in] mapName     Name of the selected memory map.\n     *\n     *    @return Number of available memory remaps in the selected memory map.\n     */\n    int remapCount(std::string const& mapName) const;\n\n    /*!\n     *  Get the names of the available items.\n     *\n     *    @return Names of the available items.\n     */\n    virtual std::vector<std::string> getItemNames() const override final;\n\n    /*!\n     *  Get the names of available memory remaps in the selected memory map.\n     *\n     *    @param [in] mapName     Name of the selected memory map.\n     *\n     *    @return Names of the available memory remaps in the selected memory map.\n     */\n    std::vector<std::string> getRemapNames(std::string const& mapName) const;\n\n    /*!\n     *  Set a new name for the selected item.\n     *\n     *    @param [in] currentName     Name of the selected item.\n     *    @param [in] newName         New name for the item.\n     *\n     *    @return True, if successful, false otherwise.\n     */\n    virtual bool setName(std::string const& currentName, std::string const& newName) override final;\n\n    /*!\n     *  Set a new name for the selected memory remap.\n     *\n     *    @param [in] mapName         Name of the memory map containing the selected memory remap.\n     *    @param [in] currentName     Name of the selected memory remap.\n     *    @param [in] newName         New name for the memory remap.\n     *\n     *    @return True, if successful, false otherwise.\n     */\n    bool setRemapName(std::string const& mapName, std::string const& currentName, std::string const& newName);\n\n    /*!\n     *  Get the description of the selected memory remap.\n     *\n     *    @param [in] mapName     Name of the memory map containing the selected memory remap.\n     *    @param [in] remapName   Name of the selected memory remap.\n     *\n     *    @return Description of the selected memory remap.\n     */\n    std::string getRemapDescription(std::string const& mapName, std::string const& remapName) const;\n\n    /*!\n     *  Set a new description for the selected memory remap.\n     *\n     *    @param [in] mapName         Name of the memory map containing the selected memory remap.\n     *    @param [in] itemName        Name of the selected memory remap.\n     *    @param [in] newDescription  New description.\n     *\n     *    @return True, if successful, false otherwise.\n     */\n    bool setRemapDescription(std::string const& mapName, std::string const& itemName,\n        std::string const& newDescription);\n\n    /*!\n     *  Get the calculated is present value of the selected item.\n     *\n     *    @param [in] mapName     Name of the selected memory map.\n     *    @param [in] remapName   Name of the selected memory remap.\n     *    @param [in] baseNumber  Base for displaying the value.\n     *\n     *    @return Calculated is present value of the selected item.\n     */\n    std::string getIsPresentValue(std::string const& mapName, std::string const& remapName = \"\",\n        int const& baseNumber = 0) const;\n\n    /*!\n     *  Get the formatted is present expression of the selected item.\n     *\n     *    @param [in] mapName     Name of the selected memory map.\n     *    @param [in] remapName   Name of the selected memory remap.\n     *\n     *    @return Formatted is present expression of the selected item.\n     */\n    std::string getIsPresentFormattedExpression(std::string const& mapName, std::string const& remapName = \"\") const;\n\n    /*!\n     *  Get the is present expression of the selected item.\n     *\n     *    @param [in] mapName     Name of the selected memory map.\n     *    @param [in] remapName   Name of the selected memory remap.\n     *\n     *    @return Is present expression of the selected item.\n     */\n    std::string getIsPresentExpression(std::string const& mapName, std::string const& remapName = \"\") const;\n\n    /*!\n     *  Set a new is present value for the selected item.\n     *\n     *    @param [in] mapName         Name of the selected memory map.\n     *    @param [in] remapName       Name of the selected memory remap.\n     *    @param [in] newIsPresent    New is present value.\n     *\n     *    @return True, if successful, false otherwise.\n     */\n    bool setIsPresent(std::string const& mapName, std::string const& newIsPresent,\n        std::string const& remapName = \"\");\n\n    /*!\n     *  Get the remap state of the selected item.\n     *\n     *    @param [in] mapName         Name of the selected memory map.\n     *    @param [in] remapName       Name of the selected memory remap.\n     *\n     *    @return Remap state of the selected item.\n     */\n    std::string getRemapState(std::string const& mapName, std::string const& remapName = \"\") const;\n\n    /*!\n     *  Set the remap state for the selected item.\n     *\n     *    @param [in] mapName         Name of the selected memory map.\n     *    @param [in] remapName       Name of the selected memory remap.\n     *    @param [in] newRemapState   New remap state.\n     *\n     *    @return True, if successful, false otherwise.\n     */\n    bool setRemapState(std::string const& mapName, std::string const& remapName, std::string const& newRemapState);\n\n    /*!\n     *  Get the address unit bits expression of the selected memory map.\n     *\n     *    @param [in] mapName     Name of the selected memory map.\n     *\n     *    @return Address unit bits expression of the selected memory map.\n     */\n    std::string getAddressUnitBitsExpression(std::string const& mapName) const;\n\n    /*!\n     *\tGet the address unit bits value of the selected memory map.\n     *  \n     *    @param [in] mapName     Name of the selected memory map.\n     *\t    \n     * \t    @return Address unit bits of the selected memory map.\n     */\n    std::string getAddressUnitBitsValue(std::string const& mapName, int const& baseNumber = 0) const;\n\n    /*!\n     *\tGet the formatted address unit bits expression of the selected memory map.\n     *\n     *    @param [in] mapName     Name of the selected memory map.\n     *\n     * \t    @return Formatted address unit bits expression of the selected memory map.\n     */\n    std::string getAddressUnitBitsFormattedExpression(std::string const& mapName) const;\n\n    /*!\n     *  Set the address unit bits for the selected memory map.\n     *\n     *    @param [in] mapName             Name of the selected memory map.\n     *    @param [in] newAddressUnitBits  New address unit bits.\n     *\n     *    @return True, if successful, false otherwise.\n     */\n    bool setAddressUnitBits(std::string const& mapName, std::string const& newAddressUnitBits) const;\n\n    /*!\n     *  Get the slave interface binding of the selected memory map.\n     *\n     *    @param [in] mapName     Name of the selected memory map.\n     *\n     *    @return Slave interface binding of the selected memory map.\n     */\n    std::string getInterfaceBinding(std::string const& mapName) const;\n\n    /*!\n     *  Get the associated slave interface of the selected memory map.\n     *\n     *    @param [in] mapName     Name of the selected memory map.\n     *\n     *    @return The associated slave interfaces of the selected memory map.\n     */\n    std::vector<std::string> getAssociatedSlaveInterfaces(std::string const& mapName) const;\n\n    /*!\n     *  Calculate all the references to the selected ID in the selected item.\n     *\n     *    @param [in] itemName    Name of the selected item.\n     *    @param [in] valueID     The selected ID.\n     *\n     *    @return Number of references to the selected ID in the selected item.\n     */\n    virtual int getAllReferencesToIdInItem(const std::string& itemName, std::string const& valueID) const override\n        final;\n\n    /*!\n     *  Get the expressions in the selected memory item.\n     *\n     *    @param [in] mapName     Name of the selected memory map.\n     *    @param [in] remapName   Name of the selected memory remap.\n     *\n     *    @return List of expressions in the selected memory item.\n     */\n    std::vector<std::string> getMapExpressions(std::string const& mapName, std::string const& remapName) const;\n\n    /*!\n     *  Get the number of references made to the selected parameter in the selected memory remap.\n     *\n     *    @param [in] mapName     Name of the selected memory map.\n     *    @param [in] remapName   Name of the selected memory remap.\n     *    @param [in] valueID     ID of the selected parameter.\n     *\n     *    @return The number of references made to the selected parameter in the selected memory remap.\n     */\n    int getAllReferencesToIdInRemapItem(std::string const& mapName, std::string const& remapName,\n        std::string const& valueID) const;\n\n    /*!\n     *  Validates the contained items.\n     *\n     *    @return True, if all the ports are valid, false otherwise.\n     */\n    virtual bool validateItems() const override final;\n\n    /*!\n     *  Check if the selected item has a valid name.\n     *\n     *    @param [in] itemName    Name of the selected item.\n     *\n     *    @return True, if the name is valid, false otherwise.\n     */\n    virtual bool itemHasValidName(std::string const& itemName) const override final;\n\n    /*!\n     *  Check if the selected memory remap has a valid name.\n     *\n     *    @param [in] mapName     Name of the memory map containing the selected memory remap.\n     *    @param [in] itemName    Name of the selected memory remap.\n     *\n     *    @return True, if the name is valid, false otherwise.\n     */\n    bool remapHasValidName(std::string const& mapName, std::string const& itemName) const;\n\n    /*!\n     *  Check if the selected memory remap has a valid remap state.\n     *\n     *    @param [in] mapName     Name of the memory map containing the selected memory remap.\n     *    @param [in] itemName    Name of the selected memory remap.\n     *\n     *    @return True, if the remap state is valid, false otherwise.\n     */\n    bool remapHasValidRemapState(std::string const& mapName, std::string const& itemName) const;\n\n    /*!\n     *  Check if the selected memory item has a valid is present.\n     *\n     *    @param [in] mapName     Name of the memory map containing the selected memory remap.\n     *    @param [in] remapName   Name of the selected memory remap.\n     *\n     *    @return True, if the is present is valid, false otherwise.\n     */\n    bool itemHasValidIsPresent(std::string const& mapName, std::string const& remapName = \"\") const;\n\n    /*!\n     *  Check if the selected memory map has a valid address unit bits value.\n     *\n     *    @param [in] mapName     Name of the selected memory map.\n     *\n     *    @return True, if the address unit bits value is valid, false otherwise.\n     */\n    bool memoryMapHasValidAddressUnitBits(std::string const& mapName) const;\n\n    /*!\n     *  Add a new memory map, inserting it to specific position given by row.\n     *\n     *    @param [in] row         Row of the new memory map.\n     *    @param [in] newMapName  Name of the new memory map.\n     */\n    void addMemoryMap(int const& row, std::string const& newMapName = std::string(\"\"));\n\n    /*!\n     *  Add a new memory map.\n     *  This overload should be preferred when using Python.\n     *\n     *    @param [in] newMapName  Name of the new memory map.\n     */\n    void addMemoryMap(std::string const& newMapName = std::string(\"\"));\n\n    /*!\n     *  Add a new memory remap.\n     *\n     *    @param [in] mapName         Name of the memory map containing the new memory remap.\n     *    @param [in] newRemapName    Name of the new memory map.\n     */\n    void addMemoryRemap(std::string const& mapName, std::string const& newRemapName = std::string(\"\"));\n\n    /*!\n     *  Remove the selected memory map.\n     *\n     *    @param [in] mapName     Name of the selected memory map.\n     *\n     *    @return True, if successful, false otherwise.\n     */\n    bool removeMap(std::string const& mapName);\n\n    /*!\n     *  Remove the selected memory remap.\n     *\n     *    @param [in] mapName     Name of the memory map containing the selected memory remap.\n     *    @param [in] remapName   Name of the selected memory remap.\n     *\n     *    @return True, if successful, false otherwise.\n     */\n    bool removeRemap(std::string const& mapName, std::string remapName);\n\n    /*!\n     *  Copy the selected items.\n     *\n     *    @param [in] selectedRows    Indexes of the selected items.\n     */\n    void copyRows(std::vector<std::string> const& selectedRows);\n\n    /*!\n     *  Paste the selected memory maps.\n     *\n     *    @return Names of the pasted items.\n     */\n    std::vector<std::string> pasteMemoryMaps();\n\n    /*!\n     *  Paste the selected memory remaps.\n     *\n     *    @param [in] memoryMapName   Name of the memory map containing the pasted memory remaps.\n     *\n     *    @return Names of the pasted items.\n     */\n    std::vector<std::string> pasteMemoryRemaps(std::string const& memoryMapName);\n\n    /*!\n     *  Get the address block interface.\n     *\n     *    @return Interface for accessing address blocks.\n     */\n    AddressBlockInterface* getAddressBlockInterface() const;\n\n    /*!\n     *  Get the subspace map interface.\n     *\n     *    @return Interface for accessing subspace maps.\n     */\n    SubspaceMapInterface* getSubspaceMapInterface() const;\n\n    /*!\n     *  Get a pointer to the selected memory map (for index construction).\n     *\n     *    @param [in] mapName     Name of the selected memory map.\n     *\n     *    @return Pointer to the selected memory map.\n     */\n    MemoryMap* getMapPointer(std::string const& mapName) const;\n\n    /*!\n     *  Get a pointer to the selected memory remap (for index construction).\n     *\n     *    @param [in] mapName     Name of the memory map containing the selected memory remap.\n     *    @param [in] remapName   Name of the selected memory remap.\n     *\n     *    @return Pointer to the selected memory remap.\n     */\n    MemoryRemap* getRemapPointer(std::string const& mapName, std::string const& remapName) const;\n\n    /*!\n     *\tGet the number of mode references for a selected remap.\n     *  \n     *    @param [in] mapName       Memory map containing the remap.\n     *    @param [in] remapName     The name of the remap.\n     *\t    \n     * \t    @return The number of mode references within the remap.\n     */\n    int getRemapModeReferenceCount(std::string const& mapName, std::string const& remapName) const;\n\n    /*!\n     *\tGet the mode references of a selected remap.\n     *  \n     *    @param [in] mapName             The containing memory map.\n     *    @param [in] remapName           The name of the remap.\n     *\t    \n     * \t    @return The mode references of selected remap.\n     */\n    std::vector<std::pair<unsigned int, std::string> > getRemapModeReferences(std::string const& mapName, std::string const& remapName) const;\n\n    /*!\n     *\tGet string to display in mode references editor, depending on if remap has no mode references, \n     *  one mode reference or multiple mode references. Returns an empty string if remap is not found.\n     *  \n     *    @param [in] mapName         The containing memory map.\n     *    @param [in] remapName       The name of the remap.\n     *\n     * \t    @return Empty string if remap is not found, or \"None\", \"<mode>\" or \"[multiple]\" \n     *              depending on mode references of the remap.\n     */\n    std::string getRemapModeReferenceString(std::string const& mapName, std::string const& remapName) const;\n\n    /*!\n     *\tSet the mode references of given remap.\n     *  \n     *    @param [in] mapName             The containing memory map.\n     *    @param [in] remapName           The name of the remap whose mode references are set.\n     *    @param [in] newModeRefs         The mode references to set.\n     *\t    \n     * \t    @return True, if the operation was successful, otherwise false.\n     */\n    bool setRemapModeReferences(std::string const& mapName, std::string const& remapName, std::vector<std::pair<unsigned int, std::string> > const& newModeRefs);\n\n    /*!\n     *\tAdd a new mode reference to a selected remap.\n     *  \n     *    @param [in] mapName             The containing memory map.\n     *    @param [in] remapName           The name of the remap to add a mode reference to.\n     *\n     * \t    @return True, if the operation was successful, otherwise false.\n     */\n    bool addRemapModeReference(std::string const& mapName, std::string const& remapName);\n\n    /*!\n     *\tRemove a selected mode reference of a given remap.\n     *  \n     *    @param [in] mapName                 The containing memory map.\n     *    @param [in] remapName               The name of the remap to remove a mode reference of.\n     *    @param [in] modeReferenceIndex      The index of the mode reference to be removed.\n     *\t    \n     * \t    @return True, if the operation was successful, otherwise false.\n     */\n    bool removeRemapModeReference(std::string const& mapName, std::string const& remapName, int modeReferenceIndex);\n\n    /*!\n     *\tGet the mode reference interface used for accessing remap mode references.\n     *  \n     * \t    @return  The mode reference interface.\n     */\n    ModeReferenceInterface* getModeReferenceInterface() const;\n\n    /*!\n     *\tSet the mode reference interface used for accessing remap mode references.\n     *  \n     *    @param [in] modeRefInterface     Description\n     */\n    void setModeReferenceInterface(ModeReferenceInterface* modeRefInterface);\n\n    /*!\n     *\tGet the mode references of all remaps in memory map (excluding selected remap) as a list of priority, \n     *  reference pairs.\n     *  \n     *    @param [in] mapName             The containing memory map.\n     *    @param [in] remapName           The name of the remap to exclude from the mode ref list.\n     *\n     * \t    @return  The mode references of remaps in memory map, excluding selected remap.\n     */\n    std::vector<std::pair<unsigned int, std::string> > getRemapModeReferencesExcludingRemap(\n        std::string const& mapName, std::string const& remapName) const;\n\nprivate:\n\n    /*!\n     *  Get the selected memory map.\n     *\n     *    @param [in] itemName    Name of the selected memory map.\n     *\n     *    @return The selected memory map.\n     */\n    QSharedPointer<MemoryMap> getMemoryMap(std::string const& itemName) const;\n\n    /*!\n     *  Get the memory map with the selected name, sliced to a NameGroup.\n     *\n     *    @param [in] itemName    Name of the selected memory map.\n     *\n     *    @return The sliced memory map with the selected name.\n     */\n    QSharedPointer<NameGroup> getItem(std::string const& itemName) const override;\n\n    /*!\n     *  Get the selected memory remap.\n     *\n     *    @param [in] mapName     Name of the memory map containing the selected memory remap.\n     *    @param [in] itemName    Name of the selected memory remap.\n     *\n     *    @return The selected memory remap.\n     */\n    QSharedPointer<MemoryRemap> getMemoryRemap(std::string const& mapName, std::string const& itemName) const;\n\n    /*!\n     *  Paste a single memory map.\n     *\n     *    @param [in] mapCopy     The selected memory map to copy.\n     *\n     *    @return Name of the pasted memory map.\n     */\n    QString pasteMemoryMap(QSharedPointer<MemoryMap> mapCopy);\n\n    /*!\n     *  Paste a single memory remap.\n     *\n     *    @param [in] remapCopy       The selected memory remap to copy.\n     *    @param [in] parentMapName   Name of the memory map containing the copied memory remap.\n     *\n     *    @return Name of the pasted memory remap.\n     */\n    QString pasteMemoryRemap(QSharedPointer<MemoryRemap> remapCopy, std::string const& parentMapName);\n\n    /*!\n     *  Transform the selected name to a unique memory remap name.\n     *\n     *    @param [in] mapName         Name of the memory map containing the memory remaps.\n     *    @param [in] newName         The selected name.\n     *    @param [in] itemTypeName    The type of the item.\n     *\n     *    @return A unique name derived from the selected name.\n     */\n    QString getUniqueRemapName(std::string const& mapName, std::string const& newName,\n        std::string const& itemTypeName) const;\n\n    /*!\n     *  Check if the selected memory remap name is unique.\n     *\n     *    @param [in] mapName     Name of the memory map containing the memory remaps.\n     *    @param [in] remapName   The selected memory remap name.\n     *\n     *    @return True, if the selected name is unique, false otherwise.\n     */\n    bool remapNameIsUnique(std::string const& mapName, QString const& remapName) const;\n\n    //-----------------------------------------------------------------------------\n    // Data.\n    //-----------------------------------------------------------------------------\n\n    //! Component containing the memory maps.\n    QSharedPointer<Component> component_;\n\n    //! List of the contained memory maps.\n    QSharedPointer<QList<QSharedPointer<MemoryMap> > > mapData_;\n\n    //! Validator for memory maps.\n    QSharedPointer<MemoryMapValidator> validator_;\n\n    //! Interface for accessing address blocks.\n    AddressBlockInterface* addressBlockInterface_;\n\n    //! Interface for accessing subspace maps.\n    SubspaceMapInterface* subspaceInterface_;\n\n    //! Interface for accessing remap mode references.\n    ModeReferenceInterface* modeReferenceInterface_;\n};\n\n#endif // MEMORYMAPINTERFACE_H\n"
  },
  {
    "path": "KactusAPI/include/MemoryRemapExpressionGatherer.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: MemoryRemapExpressionsGatherer.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Mikko Teuho\r\n// Date: 29.04.2015\r\n//\r\n// Description:\r\n// Gathers expressions from a memory remap and its address blocks.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef MEMORYREMAPEXPRESSIONGATHERER_H\r\n#define MEMORYREMAPEXPRESSIONGATHERER_H\r\n\r\n#include <QSharedPointer>\r\n#include <QStringList>\r\n\r\n#include \"KactusAPI/KactusAPIGlobal.h\"\r\n\r\nclass MemoryMapBase;\r\n//-----------------------------------------------------------------------------\r\n//! Gathers expressions from a memory remap and its address blocks.\r\n//-----------------------------------------------------------------------------\r\nclass KACTUS2_API MemoryRemapExpressionGatherer\r\n{\r\n\r\npublic:\r\n\r\n    /*!\r\n     *  The constructor.\r\n     */\r\n    MemoryRemapExpressionGatherer();\r\n\r\n    /*!\r\n     *  The destructor.\r\n     */\r\n    virtual ~MemoryRemapExpressionGatherer();\r\n\r\n    /*!\r\n     *  Get the expressions from a given memory remap.\r\n     *\r\n     *    @param [in] memoryRemap     The given memory remap.\r\n     *\r\n     *    @return A list containing all the expressions used in a memory remap\r\n     */\r\n    QStringList getExpressions(QSharedPointer<MemoryMapBase> memoryRemap) const;\r\n\r\nprivate:\r\n\t\r\n\t//! No copying.\r\n    MemoryRemapExpressionGatherer(const MemoryRemapExpressionGatherer& other);\r\n\r\n\t//! No assignment.\r\n    MemoryRemapExpressionGatherer& operator=(const MemoryRemapExpressionGatherer& other);\r\n};\r\n\r\n#endif // MEMORYREMAPEXPRESSIONGATHERER_H\r\n"
  },
  {
    "path": "KactusAPI/include/MessageMediator.h",
    "content": "//-----------------------------------------------------------------------------\n// File: MessageMediator.h\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Esko Pekkarinen\n// Date: 13.02.2018\n//\n// Description:\n// Interface for outputting messages to the user.\n//-----------------------------------------------------------------------------\n\n#ifndef MESSAGEMEDIATOR_H\n#define MESSAGEMEDIATOR_H\n\n#include <QString>\n\n//-----------------------------------------------------------------------------\n//! Interface for outputting messages to the user.\n//-----------------------------------------------------------------------------\nclass MessageMediator \n{\npublic:\n\n    //! The destructor.\n    virtual ~MessageMediator() {};\n\n    //! Show the given message to the user.\n    virtual void showMessage(QString const& message) const = 0;\n\n    //! Show the given error to the user.\n    virtual void showError(QString const& error) const = 0;\n\n    //! Show the given failure message to the user.\n    virtual void showFailure(QString const& error) const = 0;\n\n    //! Show the given status to the user.\n    virtual void showStatusMessage(QString const& status) const = 0;\n};\n\n#endif // MESSAGEMEDIATOR_H\n"
  },
  {
    "path": "KactusAPI/include/ModeConditionParser.h",
    "content": "//-----------------------------------------------------------------------------\n// File: ModeConditionParser.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Esko Pekkarinen\n// Date: 16.10.2023\n//\n// Description:\n// Parser for Mode condition expressions.\n//-----------------------------------------------------------------------------\n\n#ifndef MODECONDITIONPARSER_H\n#define MODECONDITIONPARSER_H\n\n#include \"IPXactSystemVerilogParser.h\"\n\n#include \"KactusAPI/KactusAPIGlobal.h\"\n\n#include <IPXACTmodels/Component/Mode.h>\n\n#include <IPXACTmodels/utilities/Search.h>\n\n#include <QString>\n#include <QMap>\n\n//-----------------------------------------------------------------------------\n//! Parser for Mode condition expressions.\n//-----------------------------------------------------------------------------\nclass KACTUS2_API ModeConditionParser : public IPXactSystemVerilogParser\n{\npublic:\n\n\t//! The constructor.\n    ModeConditionParser(QSharedPointer<ParameterFinder> finder,\n        PortSlice::List portSlices,\n        FieldSlice::List fieldSlices,\n        Mode::List modes);\n\n\t//! The destructor.\n    ~ModeConditionParser() override = default;\n\n    // Disable copying.\n    ModeConditionParser(ModeConditionParser const& rhs) = delete;\n    ModeConditionParser& operator=(ModeConditionParser const& rhs) = delete;\n\n    /*!\n     *\tSet the mode-specific field slices to use while parsing expressions.\n     *\n     *    @param [in] fieldSlices             The field slices to set.\n     */\n    void setFieldSlices(FieldSlice::List fieldSlices);\n\n    /*!\n     *\tSet the mode-specific port slices to use while parsing expressions.\n     *\n     *    @param [in] portSlices             The port slices to set.\n     */\n    void setPortSlices(PortSlice::List portSlices);\n\n    /*!\n     *\tSet the available modes to use while parsing expressions.\n     *\n     *    @param [in] modes                   The modes to set.\n     */\n    void setModes(Mode::List modes);\n\nprotected:\n\n    /*!\n     *  Checks if the given expression is a symbol e.g. reference.\n     *\n     *    @param [in] expression   The expression to check.\n     *\n     *    @return True, if the expression is a symbol, otherwise false.\n     */\n    bool isSymbol(QStringView expression) const final;\n\n    /*!\n     *  Finds the value for given symbol.\n     *\n     *    @param [in] symbol  The symbol whose value to find.\n     *\n     *    @return The found symbol value.\n     */\n    QString findSymbolValue(QStringView symbol) const override;\n\n    /*!\n     *  Checks if the given token is a unary operator.\n     *\n     *    @param [in] expression   The token to check.\n     *\n     *    @return True, if the token is a unary operator, otherwise false.\n     */\n    bool isUnaryOperator(QStringView token) const final;\n\n    /*!\n     *  Solves a binary operation.\n     *\n     *    @param [in] operation    The operation to solve.\n     *    @param [in] term         The term for the operation.\n     *\n     *    @return The result of the operation.\n     */\n    QString solveUnary(QStringView operation, QString const& term) const final;\n\nprivate:\n\n    /*!\n     *  Check if the given expression is a valid reference within a mode.\n     *\n     *    @param [in] expression  The expression to check.\n     *\n     *    @return True, if the expression is a valid reference, otherwise false.\n     */\n    bool isModeReference(QStringView expression) const;\n\n\n    /*!\n     *  Solve condition to a value.\n     *\n     *    @param [in] reference       The reference to solve.\n     *    @param [in] availableItems  The available items to reference.\n     *\n     *    @return 1, if the reference is to a valid item, otherwise x.\n     */\n    template <typename T> \n    QString solveCondition(QStringView reference, QSharedPointer<QList<QSharedPointer<T> > > availableItems) const\n    {\n        if (auto item = Search::findByName(reference, *availableItems); item.isNull())\n        {\n            return QStringLiteral(\"x\");\n        }\n\n        return QStringLiteral(\"1\");\n    };\n\n    //! The list of available port slices in expressions.\n    PortSlice::List portSlices_;\n\n    //! The list of available field slices in expressions.\n    FieldSlice::List fieldSlices_;\n\n    //! The list of available modes in expressions.\n    Mode::List modes_;\n};\n\n#endif // MODECONDITIONPARSER_H\n"
  },
  {
    "path": "KactusAPI/include/ModeConditionParserInterface.h",
    "content": "//-----------------------------------------------------------------------------\n// File: ModeConditionParserFactory.h\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Anton Hagqvist\n// Date: 27.09.2024\n//\n// Description:\n// Interface for creating and handling expression parsers for mode conditions. The base interface is independent of \n// KactusAPI and should be used in IPXACTmodels validators.\n//-----------------------------------------------------------------------------\n\n#ifndef MODECONDITIONPARSERINTERFACE_H\n#define MODECONDITIONPARSERINTERFACE_H\n\n#include \"ExpressionParserInterface.h\"\n#include <KactusAPI/KactusAPIGlobal.h>\n\n#include <IPXACTmodels/Component/FieldSlice.h>\n#include <IPXACTmodels/Component/PortSlice.h>\n#include <IPXACTmodels/Component/Mode.h>\n\nclass ExpressionParser;\nclass ParameterFinder;\n\nclass ModeConditionParserBaseInterface : public ExpressionParserInterface\n{\npublic:\n\n\tModeConditionParserBaseInterface() = default;\n\t~ModeConditionParserBaseInterface() override = default;\n\n    //! No copying, no assignment.\n    ModeConditionParserBaseInterface(ModeConditionParserBaseInterface const& other) = delete;\n    ModeConditionParserBaseInterface& operator=(ModeConditionParserBaseInterface const& other) = delete;\n\n\t/*!\n\t *\tSet the field slices of the selected mode condition parser.\n\t *  \n\t *    @param [in] expressionParser     The mode condition parser to set the field slices to.\n\t *    @param [in] fieldSlices          The field slices to set.\n\t */\n\tvirtual void setFieldSlices(QSharedPointer<ExpressionParser> expressionParser, FieldSlice::List fieldSlices) = 0;\n\t\n\t/*!\n\t *\tSet the port slices of the selected mode condition parser.\n\t *\n\t *    @param [in] expressionParser     The mode condition parser to set the port slices to.\n\t *    @param [in] portSlices           The port slices to set.\n\t */\n    virtual void setPortSlices(QSharedPointer<ExpressionParser> expressionParser, PortSlice::List portSlices) = 0;\n\n    /*!\n     *\tSet the available modes to the selected mode condition parser.\n     *  \n     *    @param [in] expressionParser     The mode condition parser to update.\n     *    @param [in] modes                The modes to set.\n     */\n    virtual void setModes(QSharedPointer<ExpressionParser> expressionParser, Mode::List modes) = 0;\n};\n\nclass KACTUS2_API ModeConditionParserInterface : public ModeConditionParserBaseInterface\n{\npublic:\n    explicit ModeConditionParserInterface(QSharedPointer<ParameterFinder> parameterFinder);\n    ~ModeConditionParserInterface() final = default;\n\n    ModeConditionParserInterface(ModeConditionParserInterface const& other) = delete;\n    ModeConditionParserInterface& operator=(ModeConditionParserInterface const& other) = delete;\n\n    /*!\n     *\tCreate the expression parser.\n     *\n     * \t    @return The created expression parser.\n     */\n    [[nodiscard]] QSharedPointer<ExpressionParser> createParser() final;\n\n    /*!\n     *\tSet the mode-specific field slices to use while parsing expressions.\n     *  \n     *    @param [in] expressionParser        The parser whose field slices to set.\n     *    @param [in] fieldSlices             The field slices to set.\n     */\n    void setFieldSlices(QSharedPointer<ExpressionParser> expressionParser, FieldSlice::List fieldSlices) final;\n\n    /*!\n     *\tSet the mode-specific port slices to use while parsing expressions.\n     *\n     *    @param [in] expressionParser        The parser whose port slices to set.\n     *    @param [in] portSlices              The port slices to set.\n     */\n    void setPortSlices(QSharedPointer<ExpressionParser> expressionParser, PortSlice::List portSlices) final;\n\n    /*!\n     *\tSet the available modes to use while parsing expressions.\n     *\n     *    @param [in] expressionParser        The parser whose modes to set.\n     *    @param [in] modes                   The modes to set.\n     */\n    void setModes(QSharedPointer<ExpressionParser> expressionParser, Mode::List modes) final;\n\nprivate:\n\n    //! Parameter finder to use in the expression parser.\n    QSharedPointer<ParameterFinder> parameterFinder_;\n};\n\n#endif // MODECONDITIONPARSERINTERFACE_H\n"
  },
  {
    "path": "KactusAPI/include/ModeReferenceInterface.h",
    "content": "//-----------------------------------------------------------------------------\n// File: ModeReferenceInterface.h\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Anton Hagqvist\n// Date: 26.10.2023\n//\n// Description:\n// Interface for accessing mode references.\n//-----------------------------------------------------------------------------\n\n#ifndef MODEREFERENCEINTERFACE_H\n#define MODEREFERENCEINTERFACE_H\n\n#include <KactusAPI/KactusAPIGlobal.h>\n\n#include <QList>\n#include <QSharedPointer>\n\nclass ModeReference;\nclass Mode;\n\nclass KACTUS2_API ModeReferenceInterface\n{\n\npublic:\n\n    ModeReferenceInterface() = default;\n\n    virtual ~ModeReferenceInterface() = default;\n\n    /*!\n     *\tSet the available mode references.\n     *  \n     *    @param [in] modeReferences     The mode references to set.\n     */\n    void setModeReferences(std::vector<std::pair<unsigned int, std::string> > const& modeReferences);\n\n    /*!\n     *\tGet the number of mode references.\n     *\n     * \t    @return The number of mode references within the containing element.\n     */\n    int getModeReferenceCount() const;\n\n    /*!\n     *\tGet the mode reference value for a selected mode reference.\n     *\n     *    @param [in] modeReferenceIndex  The index of the mode reference whose reference value to get.\n     *\n     * \t    @return The mode reference value.\n     */\n    std::string getModeReferenceValue(int modeReferenceIndex) const;\n\n    /*!\n     *\tGet the mode reference priority for a selected mode reference.\n     *\n     *    @param [in] modeReferenceIndex  The index of the mode reference whose priority to get.\n     *\n     * \t    @return The mode reference priority.\n     */\n    int getModeReferencePriority(int modeReferenceIndex) const;\n\n    /*!\n     *\tSet the mode reference value for a selected mode reference.\n     *\n     *    @param [in] modeReferenceIndex  The index of the mode reference whose reference value to set.\n     *    @param [in] newValue            The new reference to set.\n     *\n     * \t    @return True, if the operation was successful, otherwise false.\n     */\n    bool setModeReferenceValue(int modeReferenceIndex, std::string const& newValue);\n\n    /*!\n     *\tSet the mode reference priority for a selected mode reference.\n     *\n     *    @param [in] modeReferenceIndex  The index of the mode reference whose reference priority to set.\n     *    @param [in] newPriority         The new priority value to set.\n     *\n     * \t    @return True, if the operation was successful, otherwise false.\n     */\n    bool setModeReferencePriority(int modeReferenceIndex, unsigned int newPriority);\n\n    /*!\n     *\tAdd a new mode reference.\n     *\n     * \t    @return True, if the operation was successful, otherwise false.\n     */\n    bool addModeReference(int row);\n\n    /*!\n     *\tRemove a selected mode reference.\n     *\n     *    @param [in] modeReferenceIndex      The index of the mode reference to be removed.\n     *\n     * \t    @return True, if the operation was successful, otherwise false.\n     */\n    bool removeModeReference(int modeReferenceIndex);\n\n    /*!\n     *\tValidate the reference value of given mode reference.\n     *  \n     *    @param [in] modeReferenceIndex     The index of the mode reference to validate.\n     *\t    \n     * \t    @return True, if the mode reference value is valid, otherwise false.\n     */\n    bool modeReferenceValueIsValid(int modeReferenceIndex) const;\n    \n    /*!\n     *\tValidate the priority value of given mode reference.\n     *\n     *    @param [in] modeReferenceIndex     The index of the mode reference to validate.\n     *\n     * \t    @return True, if the mode reference priority is valid, otherwise false.\n     */\n    bool modeReferencePriorityIsValid(int modeReferenceIndex) const;\n    \n    /*!\n     *\tGet all mode references of the current element as a vector of strings.\n     *  \n     * \t    @return Vector containing the mode references.\n     */\n    std::vector<std::string> getModeReferencesString() const;\n\n    /*!\n     *\tSet to indicate that the current element is a memory remap.\n     *  \n     *    @param [in] isRemap     Flag to set, if element is remap.\n     */\n    void setContainingElementIsRemap(bool isRemap);\n\n    /*!\n     *\tSet mode references in the containing element, eg. mode references of all remaps within a memory map.\n     *  Should set all mode references except for the mode refs of access policy/remap currently being edited.\n     *  \n     *    @param [in] modeRefs     The mode references to set.\n     */\n    void setContainingElementModeReferences(std::vector<std::pair<unsigned int, std::string> > const& modeReferences);\n\n    /*!\n     *\tGet the available component modes.\n     *  \n     * \t    @return The available component modes.\n     */\n    std::vector<std::string> getComponentModes() const;\n\n    /*!\n     *\tSet the available component modes.\n     *  \n     *    @param [in] newModes     The modes to set.\n     */\n    void setComponentModes(QSharedPointer<QList<QSharedPointer<Mode> > > newModes);\n\n    /*!\n     *\tGet all currently set mode references for the current element.\n     *  \n     * \t    @return The currently set mode references.\n     */\n    std::vector<std::pair<unsigned int, std::string> > getModeReferences() const;\n\n    /*!\n     *\tChecks if all mode references are errorless.\n     *\n     * \t    @return Boolean true if componentModes_ is not empty and every item is errorless, overwise false\n     */\n    bool areAllModeReferencesValid();\n\nprivate:\n    \n    /*!\n     *\tGet the mode references that are currently in use, except for the mode reference being validated.\n     *  \n     *    @param [in] modeReferenceIndex     The index of the mode references to validate.\n     *\t    \n     * \t    @return The mode references currently in use by other elements.\n     */\n    std::vector<std::pair<unsigned int, std::string> > getModeReferencesInUse(int modeReferenceIndex) const;\n\n    //! Should contain all mode references except for the mode refs of access policy/remap currently being edited.\n    std::vector<std::pair<unsigned int, std::string> > containingElementModeReferences_;\n\n    //! The mode references of the item currently being edited.\n    std::vector<std::pair<unsigned int, std::string> > modeReferences_;\n\n    //! List of available component modes.\n    QSharedPointer<QList<QSharedPointer<Mode> > > componentModes_;\n\n    //! For validation purposes. Indicates if the mode refs are within a memory remap or not.\n    bool containingElementIsRemap_ = false;\n\n};\n\n#endif // MODEREFERENCEINTERFACE_H\n"
  },
  {
    "path": "KactusAPI/include/ModelParameterSource.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ModelParameterSource.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Esko Pekkarinen\r\n// Date: 18.09.2014\r\n//\r\n// Description:\r\n// Interface for import plugins creating model parameters.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef MODELPARAMETERSOURCE_H\r\n#define MODELPARAMETERSOURCE_H\r\n\r\n#include \"ModelParameterVisualizer.h\"\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Interface for import plugins creating model parameters.\r\n//-----------------------------------------------------------------------------\r\nclass ModelParameterSource\r\n{\r\npublic:\r\n\r\n\t//! The destructor.\r\n    virtual ~ModelParameterSource() {};\r\n    \r\n    /*!\r\n     *  Sets the given visualizer to be used by the source.\r\n     *\r\n     *    @param [in] visualizer   The visualizer to use.          \r\n     */\r\n    virtual void setModelParameterVisualizer(ModelParameterVisualizer* visualizer) = 0;\r\n\r\n};\r\n\r\n#endif // MODELPARAMETERSOURCE_H\r\n"
  },
  {
    "path": "KactusAPI/include/ModelParameterVisualizer.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ModelParameterVisualizer.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Esko Pekkarinen\r\n// Date: 18.09.2014\r\n//\r\n// Description:\r\n// Interface for model parameter visualizers in component import.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef MODELPARAMTERVISUALIZER_H\r\n#define MODELPARAMTERVISUALIZER_H\r\n\r\n#include <QSharedPointer>\r\n\r\nclass ModelParameter;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Interface for model parameter visualizers in component import.\r\n//-----------------------------------------------------------------------------\r\nclass ModelParameterVisualizer\r\n{\r\npublic:\r\n\r\n\t//! The destructor.\r\n    virtual ~ModelParameterVisualizer() {};\r\n\r\n    /*!\r\n     *  Called to receive future notifications of model parameter changes in the visualization.\r\n     *\r\n     *    @param [in] listener   The the listener to receive notifications in.\r\n     */\r\n    virtual void registerChangeListener(QObject const* listener) = 0;\r\n};\r\n\r\n#endif // MODELPARAMTERVISUALIZER_H\r\n"
  },
  {
    "path": "KactusAPI/include/ModuleParameterInterface.h",
    "content": "//-----------------------------------------------------------------------------\n// File: ModuleParameterInterface.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 22.09.2020\n//\n// Description:\n// Interface for editing module parameters.\n//-----------------------------------------------------------------------------\n\n#ifndef MODULEPARAMETERINTERFACE_H\n#define MODULEPARAMETERINTERFACE_H\n\n#include <KactusAPI/KactusAPIGlobal.h>\n\n#include <AbstractParameterInterface.h>\n\nclass ComponentInstantiationParameterFinder;\nclass ComponentInstantiation;\nclass ModuleParameter;\n\n//-----------------------------------------------------------------------------\n//! Interface for editing module parameters.\n//-----------------------------------------------------------------------------\nclass KACTUS2_API ModuleParameterInterface : public AbstractParameterInterface\n{\npublic:\n\n    /*!\n     *  The constructor.\n     *\n     *    @param [ni] validator               Validator for parameters.\n     *    @param [ni] expressionParser        Parser for expressions.\n     *    @param [ni] expressionFormatter     Formatter for expressions.\n     *    @param [ni] parameterFinder         Parameter finder for component instantiation parameters.\n     */\n    ModuleParameterInterface(QSharedPointer<ParameterValidator> validator,\n        QSharedPointer<ExpressionParser> expressionParser,\n        QSharedPointer<ExpressionFormatter> expressionFormatter,\n        QSharedPointer<ComponentInstantiationParameterFinder> parameterFinder);\n\n    /*!\n     *  The destructor.\n     */\n    virtual ~ModuleParameterInterface() = default;\n\n    /*!\n     *  Set available module parameters.\n     *\n     *    @param [in] instantiation   Component instantiation containing the new module parameters.\n     */\n    void setModuleParameters(QSharedPointer<ComponentInstantiation> instantiation);\n\n    /*!\n     *  Get index of the selected item.\n     *\n     *    @param [in] itemName    Name of the selected item.\n     *\n     *    @return Index of the selected item.\n     */\n    virtual int getItemIndex(std::string const& itemName) const override;\n\n    /*!\n     *  Get name of the indexed item.\n     *\n     *    @param [in] itemIndex   Index of the selected item.\n     *\n     *    @return Name of the selected item.\n     */\n    std::string getIndexedItemName(int itemIndex) const override;\n\n    /*!\n     *  Get the number of available items.\n     *\n     *    @return Number of available items.\n     */\n    virtual int itemCount() const override;\n\n    /*!\n     *  Get the names of the available items.\n     *\n     *    @return Names of the available items.\n     */\n    virtual std::vector<std::string> getItemNames() const override;\n\n    /*!\n     *  Get the data type of the selected module parameter.\n     *\n     *    @param [in] parameterName   Name of the selected module parameter.\n     *\n     *    @return Data type of the selected module parameter.\n     */\n    std::string getDataType(std::string const& parameterName) const;\n    \n    /*!\n     *  Set a new data type for the selected module parameter.\n     *\n     *    @param [in] parameterName   Name of the selected module parameter.\n     *    @param [in] newDataType     New data type.\n     *\n     *    @return True, if successful, false otherwise.\n     */\n    bool setDataType(std::string const& parameterName, std::string const& newDataType);\n\n    /*!\n     *  Get the usage type of the selected module parameter.\n     *\n     *    @param [in] parameterName   Name of the selected module parameter.\n     *\n     *    @return Usage type of the selected module parameter.\n     */\n    std::string getUsageType(std::string const& parameterName) const;\n\n    /*!\n     *  Set a new usage type for the selected module parameter.\n     *\n     *    @param [in] parameterName   Name of the selected module parameter.\n     *    @param [in] newUsageType    New usage type.\n     *\n     *    @return True, if successful, false otherwise.\n     */\n    bool setUsageType(std::string const& parameterName, std::string const& newUsageType);\n\n    /*!\n     *  Add a new module parameter.\n     *\n     *    @param [in] row                 Index of the new parameter.\n     *    @param [in] newParameterName    New of the new parameter.\n     */\n    void addModuleParameter(int const& row, std::string const& newParameterName = std::string(\"\"));\n\n    /*!\n     *  Remove the selected module parameter.\n     *\n     *    @param [in] parameterName   New of the selected parameter.\n     *\n     *    @return True, if successful, false otherwise.\n     */\n    bool removeModuleParameter(std::string const& parameterName);\n    \n\n    //! No copying. No assignment.\n    ModuleParameterInterface(const ModuleParameterInterface& other) = delete;\n    ModuleParameterInterface& operator=(const ModuleParameterInterface& other) = delete;\n\nprivate:\n\n    /*!\n     *  Get the selected parameter.\n     *\n     *    @param [in] parameterName   Name of the selected parameter.\n     *\n     *    @return The selected parameter.\n     */\n    virtual QSharedPointer<Parameter> getParameter(std::string const& parameterName) const override final;\n\n    /*!\n     *  Get the parameter with the selected name, sliced to a NameGroup.\n     *\n     *    @param [in] parameterName   Name of the selected parameter.\n     *\n     *    @return The sliced parameter with the selected name.\n     */\n    QSharedPointer<NameGroup> getItem(std::string const& parameterName) const override;\n\n    /*!\n     *  Get the selected module parameter.\n     *\n     *    @param [in] parameterName   Name of the selected module parameter.\n     *\n     *    @return The selected module parameter.\n     */\n    QSharedPointer<ModuleParameter> getModuleParameter(std::string const& parameterName) const;\n    \n    //-----------------------------------------------------------------------------\n    // Data.\n    //-----------------------------------------------------------------------------\n\n    //! List of available module parameters.\n    QSharedPointer<QList<QSharedPointer<ModuleParameter> > > moduleParameters_;\n\n    //! Parameter finder for component instantiation parameters.\n    QSharedPointer<ComponentInstantiationParameterFinder> parameterFinder_;\n};\n\n#endif // MODULEPARAMETERINTERFACE_H\n"
  },
  {
    "path": "KactusAPI/include/MultipleParameterFinder.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: MultipleParameterFinder.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Mikko Teuho\r\n// Date: 29.01.2015\r\n//\r\n// Description:\r\n// Finds parameters from multiple components.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef MULTIPLEPARAMETERFINDER_H\r\n#define MULTIPLEPARAMETERFINDER_H\r\n\r\n#include \"ParameterFinder.h\"\r\n\r\n#include <IPXACTmodels/common/Parameter.h>\r\n\r\n#include \"KactusAPI/KactusAPIGlobal.h\"\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Parameter finder of multiple components.\r\n//-----------------------------------------------------------------------------\r\nclass KACTUS2_API MultipleParameterFinder : public ParameterFinder\r\n{\r\n\r\npublic:\r\n\r\n    /*!\r\n     *  Constructor.\r\n     *\r\n     *    @param [in] component   The component which parameters are being searched for.\r\n     */\r\n    MultipleParameterFinder();\r\n\r\n    /*!\r\n     *  Destructor.\r\n     */\r\n    ~MultipleParameterFinder() final = default;\r\n\r\n\r\n    //! No copying\r\n    MultipleParameterFinder(const MultipleParameterFinder& other) = delete;\r\n    //! No assignment\r\n    MultipleParameterFinder& operator=(const MultipleParameterFinder& other) = delete;\r\n\r\n     /*!\r\n      *  Adds a finder to be used in searches.\r\n      *\r\n      *    @param [in] finder   The finder to add.\r\n      */\r\n     void addFinder(QSharedPointer<ParameterFinder> finder);\r\n\r\n     /*!\r\n      *  Removes a finder from searches.\r\n      *\r\n      *    @param [in] finder   The finder to remove.\r\n      */\r\n     void removeFinder(QSharedPointer<ParameterFinder> finder);\r\n\r\n     /*!\r\n      *  Remove all attached parameter finders.\r\n      */\r\n     void removeAllFinders();\r\n\r\n    /*!\r\n     *  Get the parameter with the given id.\r\n     *\r\n     *    @param [in] parameterId     The id of the parameter being searched for.\r\n     */\r\n    QSharedPointer<Parameter> getParameterWithID(QStringView parameterId) const final;\r\n\r\n    /*!\r\n     *  Checks if a parameter with the given id exists.\r\n     *\r\n     *    @param [in] id      The id to search for.\r\n     *\r\n     *    @return True, if the parameter with the given id exists, otherwise false.\r\n     */\r\n    bool hasId(QStringView id) const final;\r\n\r\n    /*!\r\n     *  Finds the name of the parameter with the given id.\r\n     *\r\n     *    @param [in] id      The id to search for.\r\n     *\r\n     *    @return The name of the parameter.\r\n     */\r\n    QString nameForId(QStringView id) const final;\r\n\r\n    /*!\r\n     *  Finds the value of the parameter with the given id.\r\n     *\r\n     *    @param [in] id      The id of the parameter to search for.\r\n     *\r\n     *    @return The value of the parameter.\r\n     */\r\n    QString valueForId(QStringView id) const final;\r\n\r\n    /*!\r\n     *  Gets all of the ids of components parameters.\r\n     *\r\n     *    @return A list containing all of the ids.\r\n     */\r\n    QStringList getAllParameterIds() const final;\r\n\r\n    /*!\r\n     *  Gets the number of parameters in the component.\r\n     *\r\n     *    @return The number of parameters in the component.\r\n     */\r\n    int getNumberOfParameters() const noexcept final;\r\n    \r\n    /*!\r\n     *  Registers a parameter model that can modify parameters for the finder.\r\n     *\r\n     *    @param [in] model   The model to register.\r\n     */\r\n    void registerParameterModel(QAbstractItemModel const* model) final;\r\n\r\nprivate:\r\n\r\n    //! The finders to use in searches.\r\n    QList<QSharedPointer<ParameterFinder> > finders_;\r\n};\r\n\r\n#endif // MULTIPLEPARAMETERFINDER_H\r\n"
  },
  {
    "path": "KactusAPI/include/NameGroupInterface.h",
    "content": "//-----------------------------------------------------------------------------\n// File: NameGroupInterface.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 21.04.2020\n//\n// Description:\n// Interface for name groups.\n//-----------------------------------------------------------------------------\n\n#ifndef NAMEGROUPINTERFACE_H\n#define NAMEGROUPINTERFACE_H\n\n#include <KactusAPI/KactusAPIGlobal.h>\n\n#include <IPXACTmodels/common/NameGroup.h>\n\n#include \"CommonInterface.h\"\n\n#include <QString>\n\n//-----------------------------------------------------------------------------\n//! Interface for name groups.\n//-----------------------------------------------------------------------------\nclass KACTUS2_API NameGroupInterface : public CommonInterface\n{\npublic:\n\n    /*!\n     *  The constructor.\n     */\n    NameGroupInterface();\n\n\t/*!\n     *  The destructor.\n     */\n    virtual ~NameGroupInterface() = default;\n    \n    /*!\n     *  Get index of the selected item.\n     *\n     *    @param [in] itemName    Name of the selected item.\n     *\n     *    @return Index of the selected item.\n     */\n    virtual int getItemIndex(std::string const& itemName) const = 0;\n\n    /*!\n     *  Get name of the indexed item.\n     *\n     *    @param [in] itemIndex   Index of the selected item.\n     *\n     *    @return Name of the selected item.\n     */\n    virtual std::string getIndexedItemName(int itemIndex) const = 0;\n\n    /*!\n     *  Set a new name for the selected item.\n     *\n     *    @param [in] currentName     Name of the selected item.\n     *    @param [in] newName         New name for the item.\n     *\n     *    @return True, if successful, false otherwise.\n     */\n    virtual bool setName(std::string const& currentName, std::string const& newName) = 0;\n    \n    /*!\n     *\tGet the display name of the selected item.\n     *  \n     *    @param [in] itemName\tThe name of the item whose display name to get.\n     *\t\t\n     * \t\t@return The item display name.\n     */\n    virtual std::string getDisplayName(std::string const& itemName) const;\n\n    /*!\n     *\tSet the display name of the selected item.\n     *  \n     *    @param [in] itemName\tDescription\n     *    @param [in] newDisplayName\tDescription\n     *\t\t\n     * \t\t@return True, if display name was set successfully, otherwise false.\n     */\n    virtual bool setDisplayName(std::string const& itemName, std::string const& newDisplayName) const;\n\n    /*!\n     *  Get the description of the selected item.\n     *\n     *    @param [in] itemName    Name of the selected item.\n     *\n     *    @return Description of the selected item.\n     */\n    virtual std::string getDescription(std::string const& itemName) const;\n\n    /*!\n     *  Set a new description for the selected item.\n     *\n     *    @param [in] itemName        Name of the selected item.\n     *    @param [in] newDescription  New description.\n     *\n     *    @return True, if successful, false otherwise.\n     */\n    virtual bool setDescription(std::string const& itemName, std::string const& newDescription);\n\n    /*!\n     *\tGet the short description of an item.\n     *  \n     *    @param [in] itemName\tName of the selected item.\n     *\t\t\n     * \t\t@return Short description of the selected item.\n     */\n    virtual std::string getShortDescription(std::string const& itemName) const;\n    \n    /*!\n     *\tSet a new short description for the selected item.\n     *  \n     *    @param [in] itemName\tDescription\n     *    @param [in] newShortDescription\tDescription\n     *\t\t\n     * \t\t@return True, if successful, otherwise false.\n     */\n    bool setShortDescription(std::string const& itemName, std::string const& newShortDescription) const;\n\n    /*!\n     *  Check if the selected item has a valid name.\n     *\n     *    @param [in] itemName    Name of the selected item.\n     *\n     *    @return True, if the name is valid, false otherwise.\n     */\n    virtual bool itemHasValidName(std::string const& itemName) const = 0;\n\n    //! No copying. No assignment.\n    NameGroupInterface(const NameGroupInterface& other) = delete;\n    NameGroupInterface& operator=(const NameGroupInterface& other) = delete;\n\nprivate:\n\n    /*!\n     *  Get the item with the selected name, sliced to a NameGroup.\n     *\n     *    @param [in] itemName    Name of the selected item.\n     *\n     *    @return The sliced item with the selected name.\n     */\n    virtual QSharedPointer<NameGroup> getItem(std::string const& itemName) const = 0;\n};\n\n#endif // NAMEGROUPINTERFACE_H\n"
  },
  {
    "path": "KactusAPI/include/NullChannel.h",
    "content": "//-----------------------------------------------------------------------------\n// File: NullChannel.h\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Esko Pekkarinen\n// Date: 09.11.2023\n//\n// Description:\n// Null output for user messages.\n//-----------------------------------------------------------------------------\n\n#ifndef NULL_CHANNEL_H\n#define NULL_CHANNEL_H\n\n#include \"MessageMediator.h\"\n\n//-----------------------------------------------------------------------------\n//! Null output for user messages.\n//-----------------------------------------------------------------------------\nclass NullChannel: public MessageMediator\n{\npublic:\n\n    //! The constructor.\n    explicit NullChannel() = default;\n\n    //! The destructor.\n    ~NullChannel() final = default;\n        \n    //! Show the given message to the user.\n    void showMessage([[maybe_unused]] QString const& message) const final;\n    \n    //! Show the given error to the user.\n    void showError([[maybe_unused]] QString const& error) const final;\n\n    //! Show the given failure message to the user.\n    void showFailure([[maybe_unused]] QString const& error) const final;\n\n    //! Show the given status to the user.\n    void showStatusMessage([[maybe_unused]] QString const& status) const final;\n\n};\n\n#endif // NULL_CHANNEL_H\n"
  },
  {
    "path": "KactusAPI/include/NullParser.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: NullParser.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Esko Pekkarinen\r\n// Date: 03.02.2015\r\n//\r\n// Description:\r\n// Expression parser implementation that does nothing.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef NULLPARSER_H\r\n#define NULLPARSER_H\r\n\r\n#include <KactusAPI/include/ExpressionParser.h>\r\n\r\n#include \"KactusAPI/KactusAPIGlobal.h\"\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Expression parser implementation that does nothing.\r\n//-----------------------------------------------------------------------------\r\nclass KACTUS2_API NullParser : public ExpressionParser\r\n{\r\npublic:\r\n\r\n\t//! The constructor.\r\n\tNullParser();\r\n\r\n\t//! The destructor.\r\n\t~NullParser() final = default;\r\n\r\n    // Disable copying.\r\n    NullParser(NullParser const& rhs) = delete;\r\n    NullParser& operator=(NullParser const& rhs) = delete;\r\n\r\n    /*!\r\n     *  Parses an expression to decimal number.\r\n     *\r\n     *    @param [in] expression   The expression to parse.\r\n     *\r\n     *    @return The decimal value of the constant.\r\n     */\r\n    QString parseExpression(QStringView expression, bool* isValidExpression) const final;\r\n\r\n    /*!\r\n     *  Checks if the given expression is a plain value and does not need evaluation.\r\n     *\r\n     *    @param [in] expression   The expression to check.\r\n     *\r\n     *    @return True, if the expression is a plain value, otherwise false.\r\n     */\r\n    bool isPlainValue(QStringView expression) const final;\r\n    \r\n    /*!\r\n     *  Finds the common base in the expression.\r\n     *\r\n     *    @param [in] expression   The expression to search in.\r\n     *\r\n     *    @return The common base for the expression.\r\n     */\r\n    int baseForExpression(QStringView expression) const final;\r\n\r\n};\r\n\r\n#endif // NULLPARSER_H"
  },
  {
    "path": "KactusAPI/include/ParameterCache.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ParameterCache.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Esko Pekkarinen\r\n// Date: 06.09.2016\r\n//\r\n// Description:\r\n// The cached implementation for finding parameters with the correct ID.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef PARAMETERCACHE_H\r\n#define PARAMETERCACHE_H\r\n\r\n#include <KactusAPI/KactusAPIGlobal.h>\r\n\r\n#include \"ParameterFinder.h\"\r\n#include \"ComponentParameterFinder.h\"\r\n\r\n#include <QHash>\r\n#include <QObject>\r\n\r\nclass Component;\r\nclass Parameter;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! The cached implementation for finding parameters with the correct ID.\r\n//-----------------------------------------------------------------------------\r\nclass KACTUS2_API ParameterCache : public QObject, public ComponentParameterFinder\r\n{\r\n    Q_OBJECT\r\npublic:\r\n\r\n    /*!\r\n     *  Constructor.\r\n     *\r\n\t *    @param [in] component\t\tThe component which parameters are being searched for.\r\n     */\r\n    ParameterCache(QSharedPointer<const Component> component);\r\n\r\n    /*!\r\n     *  Destructor.\r\n     */\r\n    ~ParameterCache() override = default;\r\n\r\n    //! No copying\r\n    ParameterCache(const ParameterCache& other) = delete;\r\n    //! No assignment\r\n    ParameterCache& operator=(const ParameterCache& other) = delete;\r\n\r\n    /*!\r\n     *  Get the parameter corresponding the id.\r\n     *\r\n     *    @param [in] parameterId     The id of the parameter being searched for.\r\n     */\r\n    QSharedPointer<Parameter> getParameterWithID(QStringView parameterId) const final;\r\n\r\n    /*!\r\n     *  Checks if a parameter with the given id exists.\r\n     *\r\n     *    @param [in] id      The id to search for.\r\n     *\r\n     *    @return True, if the parameter with the given id exists, otherwise false.\r\n     */\r\n    bool hasId(QStringView id) const final;\r\n\r\n    /*!\r\n     *  Gets all of the ids of components parameters.\r\n     *\r\n     *    @return A list containing all of the ids.\r\n     */\r\n    QStringList getAllParameterIds() const final;\r\n\r\n\t/*!\r\n     *  Gets the number of parameters in the component.\r\n     *\r\n     *    @return The number of parameters in the component.\r\n     */\r\n    int getNumberOfParameters() const final;\r\n\r\n    /*!\r\n     *  Set a new component for the parameter finder.\r\n     *\r\n     *    @param [in] component   The new component.\r\n     */\r\n    void setComponent(QSharedPointer<Component const> component) final;\r\n    \r\n    /*!\r\n     *  Registers a parameter model that can modify parameters for the finder.\r\n     *\r\n     *    @param [in] model   The model to register.\r\n     */\r\n    void registerParameterModel(QAbstractItemModel const* model) final;\r\n\r\nprivate slots:\r\n\r\n    void resetCache(); \r\n\r\nprivate:\r\n\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! Parameters available in the cache. Key is the parameterID.\r\n\tQHash<QString, QSharedPointer<Parameter> > availableParameters_;\r\n\r\n};\r\n\r\n#endif // PARAMETERCACHE_H\r\n"
  },
  {
    "path": "KactusAPI/include/ParameterConfigurableElementFinder.h",
    "content": "//-----------------------------------------------------------------------------\n// File: ParameterConfigurableElementFinder.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 18.02.2026\n//\n// Description:\n// The implementation for finding configurable elements from a list with the correct ID.\n//-----------------------------------------------------------------------------\n\n#ifndef PARAMETERCONFIGURABLEELEMENTFINDER_H\n#define PARAMETERCONFIGURABLEELEMENTFINDER_H\n\n#include \"ListParameterFinder.h\"\n\n#include \"KactusAPI/KactusAPIGlobal.h\"\n\n#include <QSharedPointer>\n#include <QList>\n\nclass ConfigurableElementValue;\n\n//-----------------------------------------------------------------------------\n//! The implementation for finding configurable elements from a list with the correct ID.\n//-----------------------------------------------------------------------------\nclass KACTUS2_API ParameterConfigurableElementFinder : public ListParameterFinder\n{\n\npublic:\n\n    /*!\n     *  The constructor.\n     */\n    ParameterConfigurableElementFinder();\n\n    /*!\n     *  The Destructor.\n     */\n    ~ParameterConfigurableElementFinder() override = default;\n\n\t//! No copying. No assignment. No regret.\n    ParameterConfigurableElementFinder(const ParameterConfigurableElementFinder& other) = delete;\n    ParameterConfigurableElementFinder& operator=(const ParameterConfigurableElementFinder& other) = delete;\n\n    /*!\n     *  Finds the value of the parameter with the given id.\n     *\n     *    @param [in] id      The id of the parameter to search for.\n     *\n     *    @return The value of the parameter.\n     */\n    QString valueForId(QStringView id) const override;\n\n    /*!\n     *  Set the parameter list.\n     *\n     *    @param [in] elementList   List of the available configurable element values.\n     */\n\tvoid setCEVList(QSharedPointer<QList<QSharedPointer<ConfigurableElementValue> > > elementList) noexcept;\n\nprivate:\n\n    //-----------------------------------------------------------------------------\n    // Data.\n    //-----------------------------------------------------------------------------\n\n    //! The configurable element values are searched from this list.\n    QSharedPointer<QList<QSharedPointer<ConfigurableElementValue> > > cevList_ =\n        QSharedPointer<QList<QSharedPointer<ConfigurableElementValue> > >(new QList<QSharedPointer<ConfigurableElementValue> >());\n};\n\n#endif // PARAMETERCONFIGURABLEELEMENTFINDER_H\n"
  },
  {
    "path": "KactusAPI/include/ParameterFinder.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ParameterFinder.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Mikko Teuho\r\n// Date: 15.01.2015\r\n//\r\n// Description:\r\n// The interface for finding parameters with the correct ID.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef PARAMETERFINDER_H\r\n#define PARAMETERFINDER_H\r\n\r\n#include <QSharedPointer>\r\n\r\nclass QAbstractItemModel;\r\nclass Parameter;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Parameter finder.\r\n//-----------------------------------------------------------------------------\r\nclass ParameterFinder\r\n{\r\n\r\npublic:\r\n\r\n    /*!\r\n     *  The destructor.\r\n     */\r\n    virtual ~ParameterFinder() = default;\r\n\r\n    /*!\r\n     *  Get the parameter corresponding the id.\r\n     *\r\n     *    @param [in] parameterId     The id of the parameter being searched for.\r\n     */\r\n    virtual QSharedPointer<Parameter> getParameterWithID(QStringView parameterId) const = 0;\r\n\r\n    /*!\r\n     *  Checks if a parameter with the given id exists.\r\n     *\r\n     *    @param [in] id      The id to search for.\r\n     *\r\n     *    @return True, if the parameter with the given id exists, otherwise false.\r\n     */\r\n    virtual bool hasId(QStringView id) const = 0;\r\n\r\n    /*!\r\n     *  Finds the name of the parameter with the given id.\r\n     *\r\n     *    @param [in] id      The id to search for.\r\n     *\r\n     *    @return The name of the parameter\r\n     */\r\n    virtual QString nameForId(QStringView id) const = 0;\r\n\r\n    /*!\r\n     *  Finds the value of the parameter with the given id.\r\n     *\r\n     *    @param [in] id      The id of the parameter to search for.\r\n     *\r\n     *    @return The value of the parameter\r\n     */\r\n    virtual QString valueForId(QStringView id) const = 0;\r\n\r\n    /*!\r\n     *  Gets all of the ids of components parameters.\r\n     *\r\n     *    @return A list containing all of the ids of parameters.\r\n     */\r\n    virtual QStringList getAllParameterIds() const = 0;\r\n\r\n    /*!\r\n     *  Gets the number of parameters in the component.\r\n     *\r\n     *    @return The number of parameters.\r\n     */\r\n    virtual int getNumberOfParameters() const = 0;\r\n\r\n    /*!\r\n     *  Registers a parameter model that can modify parameters for the finder.\r\n     *\r\n     *    @param [in] model   The model to register.\r\n     */\r\n    virtual void registerParameterModel(QAbstractItemModel const* model) = 0;\r\n\r\n};\r\n\r\n#endif // PARAMETERFINDER_H\r\n"
  },
  {
    "path": "KactusAPI/include/ParameterizableInterface.h",
    "content": "//-----------------------------------------------------------------------------\n// File: ParameterizableInterface.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 13.03.2020\n//\n// Description:\n// Interface for parameterizable items.\n//-----------------------------------------------------------------------------\n\n#ifndef PARAMETERIZABLEINTERFACE_H\n#define PARAMETERIZABLEINTERFACE_H\n\n#include <KactusAPI/KactusAPIGlobal.h>\n\n#include <KactusAPI/include/ExpressionFormatter.h>\n#include <KactusAPI/include/ParameterFinder.h>\n\nclass ExpressionFormatter;\nclass ValueFormatter;\n\n//-----------------------------------------------------------------------------\n//! Interface for parameterizable items.\n//-----------------------------------------------------------------------------\nclass KACTUS2_API ParameterizableInterface\n{\npublic:\n\n    /*!\n     *  The constructor.\n     *\n     *    @param [in] expressionParser        Parser for expressions.\n     *    @param [in] expressionFormatter     Formatter for expressions.\n     */\n    ParameterizableInterface(QSharedPointer<ExpressionParser> expressionParser,\n        QSharedPointer<ExpressionFormatter> expressionFormatter);\n\n\t/*!\n     *  The destructor.\n     */\n    virtual ~ParameterizableInterface() = default;\n\n    /*!\n     *  Calculate all the references to the selected ID in the selected item.\n     *\n     *    @param [in] itemName    Name of the selected item.\n     *    @param [in] valueID     The selected ID.\n     *\n     *    @return Number of references to the selected ID in the selected item.\n     */\n    virtual int getAllReferencesToIdInItem(const std::string& itemName, std::string const&  valueID) const = 0;\n\n    //! No copying. No assignment.\n    ParameterizableInterface(const ParameterizableInterface& other) = delete;\n    ParameterizableInterface& operator=(const ParameterizableInterface& other) = delete;\n\nprotected:\n\n    /*!\n     *  Get the formatted value for the given expression.\n     *\n     *    @param [in] expression  The selected expression.\n     *\n     *    @return The formatted expression.\n     */\n    QString formattedValueFor(QString const& expression) const;\n\n    /*!\n     *  Parse the selected expression to decimal.\n     *\n     *    @param [in] expression  The selected expression.\n     *\n     *    @return The value of the expression in decimal form.\n     */\n    QString parseExpressionToDecimal(QString const& expression, bool* expressionIsValid = nullptr) const;\n\n    /*!\n     *  Parse the selected expression to the selected base number.\n     *\n     *    @param [in] expression  The selected expression.\n     *    @param [in] baseNumber  The selected base number.\n     *\n     *    @return The value of the expression in the base number form.\n     */\n    QString parseExpressionToBaseNumber(QString const& expression, unsigned int const& baseNumber, bool* expressionIsValid = nullptr) const;\n\nprivate:\n\n    //-----------------------------------------------------------------------------\n    // Data.\n    //-----------------------------------------------------------------------------\n\n    //! Expression parser for solving expressions.\n    QSharedPointer<ExpressionParser> expressionParser_;\n\n    //! Expression formatter, formats the referencing expressions to show parameter names.\n    QSharedPointer<ExpressionFormatter> formatter_;\n\n    //! Formatter for values.\n    QSharedPointer<ValueFormatter> valueFormatter_;\n};\n\n#endif // PARAMETERIZABLEINTERFACE_H\n"
  },
  {
    "path": "KactusAPI/include/ParametersInterface.h",
    "content": "//-----------------------------------------------------------------------------\n// File: ParametersInterface.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 13.03.2020\n//\n// Description:\n// Interface for editing parameters.\n//-----------------------------------------------------------------------------\n\n#ifndef PARAMETERSINTERFACE_H\n#define PARAMETERSINTERFACE_H\n\n#include <KactusAPI/KactusAPIGlobal.h>\n\n#include <AbstractParameterInterface.h>\n\nclass Parameter;\n\n//-----------------------------------------------------------------------------\n//! Interface for editing parameters.\n//-----------------------------------------------------------------------------\nclass KACTUS2_API ParametersInterface : public AbstractParameterInterface\n{\npublic:\n\n\t/*!\n     *  The constructor.\n     *\n     *    @param [in] validator               Validator for parameters.\n     *    @param [in] expressionParser        Parser for expressions.\n     *    @param [in] expressionFormatter     Formatter for expressions.\n     */\n    ParametersInterface(QSharedPointer<ParameterValidator> validator,\n        QSharedPointer<ExpressionParser> expressionParser,\n        QSharedPointer<ExpressionFormatter> expressionFormatter);\n\t\n\t/*!\n     *  The destructor.\n     */\n    virtual ~ParametersInterface() = default;\n\n    /*!\n     *  Set available parameters.\n     *\n     *    @param [in] newParameters   The new parameters.\n     */\n    void setParameters(QSharedPointer<QList<QSharedPointer<Parameter> > > newParameters);\n\n    /*!\n     *  Get index of the selected item.\n     *\n     *    @param [in] itemName    Name of the selected item.\n     *\n     *    @return Index of the selected item.\n     */\n    virtual int getItemIndex(std::string const& itemName) const override final;\n    \n    /*!\n     *  Get name of the indexed item.\n     *\n     *    @param [in] itemIndex   Index of the selected item.\n     *\n     *    @return Name of the selected item.\n     */\n    std::string getIndexedItemName(int itemIndex) const final;\n    \n    /*!\n     *  Get the number of available items.\n     *\n     *    @return Number of available items.\n     */\n    virtual int itemCount() const override final;\n    \n    /*!\n     *  Get the names of the available items.\n     *\n     *    @return Names of the available items.\n     */\n    virtual std::vector<std::string> getItemNames() const override final;\n    \n    /*!\n     *  Add a new parameter.\n     *\n     *    @param [in] row                 Index of the new parameter.\n     *    @param [in] newParameterName    New of the new parameter.\n     */\n    void addParameter(int const& row, std::string const& newParameterName = std::string(\"\"));\n\n    /*!\n     *  Remove the selected parameter.\n     *\n     *    @param [in] parameterName   New of the selected parameter.\n     *\n     *    @return True, if successful, false otherwise.\n     */\n    bool removeParameter(std::string const& parameterName);\n\n\n    //! No copying. No assignment.\n    ParametersInterface(const ParametersInterface& other) = delete;\n    ParametersInterface& operator=(const ParametersInterface& other) = delete;\n\nprivate:\n    \n    /*!\n     *  Get the selected parameter.\n     *\n     *    @param [in] parameterName   Name of the selected parameter.\n     *\n     *    @return The selected parameter.\n     */\n    QSharedPointer<Parameter> getParameter(std::string const& parameterName) const final;\n\n    /*!\n     *  Get the parameter with the selected name, sliced to a NameGroup.\n     *\n     *    @param [in] parameterName   Name of the selected parameter.\n     *\n     *    @return The sliced parameter with the selected name.\n     */\n    QSharedPointer<NameGroup> getItem(std::string const& parameterName) const override;\n\n    //-----------------------------------------------------------------------------\n    // Data.\n    //-----------------------------------------------------------------------------\n\n    //! List of available parameters.\n    QSharedPointer<QList<QSharedPointer<Parameter> > > parameters_ = nullptr;\n};\n\n#endif // PARAMETERSINTERFACE_H\n"
  },
  {
    "path": "KactusAPI/include/PluginManager.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: PluginManager.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Joni-Matti Maatta\r\n// Date: 27.6.2012\r\n//\r\n// Description:\r\n// Plugin manager which manages loaded plugins.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef PLUGINMANAGER_H\r\n#define PLUGINMANAGER_H\r\n\r\n#include <QString>\r\n#include <QList>\r\n#include <QObject>\r\n\r\n#include <KactusAPI/KactusAPIGlobal.h>\r\n\r\nclass IPlugin;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Plugin manager which manages loaded plugins.\r\n//-----------------------------------------------------------------------------\r\nclass KACTUS2_API PluginManager\r\n{\r\npublic:\r\n\r\n    //! The destructor.     \r\n    ~PluginManager() = default;\r\n\r\n    /*!\r\n     *  Adds the given plugin to the available plugins.\r\n     *\r\n     *    @param [in] plugin   The plugin to add\r\n     */\r\n    void addPlugin(IPlugin* plugin);\r\n\r\n    /*!\r\n     *  returns the list of active plugins.\r\n     */\r\n    QList<IPlugin*> getActivePlugins() const;\r\n\r\n    /*!\r\n     *  Returns the list of all loaded plugins.\r\n     */\r\n    QList<IPlugin*> getAllPlugins() const;\r\n\r\n    /*!\r\n     *  Loads the plugins from given paths.\r\n     *\r\n     *    @param [in] pluginPaths   The paths containing the plugins.\r\n     */\r\n    void setPluginPaths(QStringList const& pluginPaths);\r\n    \r\n    /*!\r\n     *  Find all plugins in the given paths.\r\n     *\r\n     *    @param [in] pluginPaths   Paths to directories to search for plugins.\r\n     *\r\n     *    @return All plugins found in the given directories.\r\n     */\r\n    static QList<IPlugin*> findPluginsInPaths(QStringList const& pluginPaths);\r\n   \r\n    /*!\r\n     *  Get the singleton instance of the PluginManager.\r\n     *\r\n     *    @return The PluginManager instance.\r\n     */\r\n    static PluginManager& getInstance();\r\n\r\nprivate:\r\n    // Disable copying.\r\n    PluginManager(PluginManager const& rhs);\r\n    PluginManager& operator=(PluginManager const& rhs);\r\n     \r\n    //! The constructor. Private to enforce the use of getInstance() to get access.\r\n    PluginManager();\r\n    \r\n    static bool isUnique(IPlugin* plugin, QList<IPlugin*> const& plugins);\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n    \r\n    //! The list of loaded plugins.\r\n    QList<IPlugin*> plugins_;\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n\r\n#endif // PLUGINMANAGER_H\r\n"
  },
  {
    "path": "KactusAPI/include/PluginSettingsModel.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: PluginSettingsWidget.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Joni-Matti Maatta\r\n// Date: 20.02.2013\r\n//\r\n// Description:\r\n// Base interface for plugin settings model.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef PLUGINSETTINGSMODEL_H\r\n#define PLUGINSETTINGSMODEL_H\r\n\r\n#include <QSettings>\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Base interface for plugin settings model.\r\n//-----------------------------------------------------------------------------\r\nclass PluginSettingsModel\r\n{\r\npublic:\r\n    /*!\r\n     *  Constructor.\r\n     */\r\n    PluginSettingsModel() {}\r\n\r\n    /*!\r\n     *  Destructor.\r\n     */\r\n    virtual ~PluginSettingsModel() {}\r\n    \r\n    /*!\r\n     *  Loads plugin settings from the given settings store. Is called when Kactus2 loads the plugin.\r\n     *\r\n     *    @param [in] settings The settings store.\r\n     */\r\n    virtual void loadSettings(QSettings& /*settings*/) {/* By default, do nothing. */}\r\n    \r\n    /*!\r\n     *  Saves plugin settings to the given settings store. Is called when Kactus2 applies changes to settings.\r\n     *\r\n     *    @param [in,out] settings The settings store.\r\n     */\r\n    virtual void saveSettings(QSettings& /*settings*/) {/* By default, do nothing. */ }\r\n\r\n    /*!\r\n     *  Validates the settings of the plugin.\r\n     */\r\n    virtual bool validateSettings() const {return true;}\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n\r\n#endif // PLUGINSETTINGSMODEL_H\r\n"
  },
  {
    "path": "KactusAPI/include/PluginUtilityAdapter.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: PluginUtilityAdapter.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Esko Pekkarinen\r\n// Date: 7.7.2014\r\n//\r\n// Description:\r\n// Generic utility for passing parent window and library interface for generator plugins.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef PLUGINUTILITYADAPTER_H\r\n#define PLUGINUTILITYADAPTER_H\r\n\r\n#include <KactusAPI/KactusAPIGlobal.h>\r\n#include <KactusAPI/include/IPluginUtility.h>\r\n\r\n#include <QObject>\r\n#include <QWidget>\r\n\r\nclass LibraryInterface;\r\nclass MessageMediator;\r\n\r\n//-----------------------------------------------------------------------------\r\n// class PluginUtilityAdapter.\r\n//-----------------------------------------------------------------------------\r\nclass KACTUS2_API PluginUtilityAdapter : public IPluginUtility\r\n{\r\npublic:\r\n\r\n\t/*!\r\n\t *  The constructor.\r\n\t *\r\n     *    @param [in] libraryInterface    The available library of IP-XACT objects.\r\n     *    @param [in] messageChannel      The channel for displaying messages to the user.\r\n     *    @param [in] versionString       The current version of the Kactus2 build.\r\n     *    @param [in] parentWidget        The parent widget.\r\n     *    @param [in] parent              The parent object.\r\n\t */\r\n\tPluginUtilityAdapter(LibraryInterface* libraryInterface, MessageMediator* messageChannel,\r\n        QString const& versionString, QWidget* parentWidget = 0);\r\n\r\n\t/*!\r\n\t *  The destructor.\r\n\t*/\r\n\tvirtual ~PluginUtilityAdapter() = default;\r\n\r\n    // Disable copying.\r\n    PluginUtilityAdapter(PluginUtilityAdapter const& rhs) =delete;\r\n\r\n    // Disable assignment.\r\n    PluginUtilityAdapter& operator=(PluginUtilityAdapter const& rhs) = delete;\r\n\r\n    //! Returns the library interface.\r\n    virtual LibraryInterface* getLibraryInterface() override final;\r\n\r\n    //! Returns the parent widget to be used for e.g. dialogs.\r\n    virtual QWidget* getParentWidget() override final;\r\n\r\n\t//! Returns the current version of the Kactus2 build.\r\n\tvirtual QString getKactusVersion() const override final;\r\n \r\n    /*!\r\n     *  Prints an error message to the console window.\r\n     *\r\n     *    @param [in] message The error message to print.\r\n     *\r\n     *      @remark  Requires signal errorMessage to be connected by the user.\r\n     */\r\n    virtual void printError(QString const& message) override final;\r\n\r\n    /*!\r\n     *  Prints an info message to the console window.\r\n     *\r\n     *    @param [in] message The info message to print.\r\n     *\r\n     *      @remark  Requires signal infoMessage to be connected by the user.\r\n     */\r\n    virtual void printInfo(QString const& message) override final;\r\n\r\nprivate:\r\n\r\n\t//-----------------------------------------------------------------------------\r\n\t// Data.\r\n\t//-----------------------------------------------------------------------------\r\n\r\n    //! The library interface to use.\r\n\tLibraryInterface* libraryInterface_;\r\n\r\n    //! The channel for displaying messages to the user.\r\n    MessageMediator* messageChannel_;\r\n\r\n\t//! The parent widget to use.\r\n\tQWidget* parentWidget_;\r\n\r\n\t//! The string denoting the current Kactus version.\r\n\tQString versionString_;\r\n};\r\n#endif // PLUGINUTILITYADAPTER_H\r\n"
  },
  {
    "path": "KactusAPI/include/PortAbstractionInterface.h",
    "content": "//-----------------------------------------------------------------------------\n// File: PortAbstractionInterface.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 10.12.2020\n//\n// Description:\n// Interface for editing abstraction definition port abstractions.\n//-----------------------------------------------------------------------------\n\n#ifndef PORTABSTRACTIONINTERFACE_H\n#define PORTABSTRACTIONINTERFACE_H\n\n#include <MasterPortInterface.h>\n#include <KactusAPI/include/ParameterizableInterface.h>\n\n#include \"KactusAPI/KactusAPIGlobal.h\"\n\n#include <IPXACTmodels/common/DirectionTypes.h>\n#include <IPXACTmodels/common/PresenceTypes.h>\n#include <IPXACTmodels/common/Qualifier.h>\n#include <IPXACTmodels/common/Document.h>\n#include <IPXACTmodels/AbstractionDefinition/PortAbstraction.h>\n\n#include <IPXACTmodels/generaldeclarations.h>\n\nclass PortAbstraction;\nclass TransactionalPort;\nclass WirePort;\nclass Protocol;\nclass AbstractionDefinition;\nclass PortAbstractionValidator;\nclass ExpressionParser;\nclass ExpressionFormatter;\n\n//-----------------------------------------------------------------------------\n//! Interface for editing abstraction definition port abstractions.\n//-----------------------------------------------------------------------------\nclass KACTUS2_API PortAbstractionInterface : public MasterPortInterface, public ParameterizableInterface\n{\npublic:\n\n    /*!\n     *\tThe constructor.\n     *  \n     *    @param [in] expressionParser        The expression parser to use.\n     *    @param [in] expressionFormatter     The expression formatter to use.\n     */\n    PortAbstractionInterface(QSharedPointer<ExpressionParser> expressionParser, \n        QSharedPointer<ExpressionFormatter> expressionFormatter);\n\n    /*!\n     *  The destructor.\n     */\n    virtual ~PortAbstractionInterface() = default;\n\n    /*!\n     *  Setup the port abstractions.\n     *\n     *    @param [in] absDef  Abstraction definition containing the port abstractions.\n     */\n    void setAbsDef(QSharedPointer<AbstractionDefinition const> absDef);\n\n    /*!\n     *\tSet the validator to use.\n     *  \n     *    @param [in] validator     The validator to use.\n     */\n    void setPortAbstractionValidator(QSharedPointer<PortAbstractionValidator> validator);\n\n    /*!\n     *  Get index of the first signal containing the selected port abstraction.\n     *\n     *    @param [in] itemName    Name of the selected port abstraction.\n     *\n     *    @return Index of the selected signal.\n     */\n    virtual int getItemIndex(std::string const& itemName) const override final;\n\n    /*!\n     *  Get index of the signal containing the selected port abstraction with the given mode.\n     *\n     *    @param [in] itemName    Name of the selected port abstraction.\n     *    @param [in] mode        Mode of the selected port abstraction.\n     *\n     *    @return Index of the selected signal.\n     */\n    virtual int getItemIndex(std::string const& itemName, General::InterfaceMode mode,\n        std::string const& systemGroup = std::string()) const;\n\n    /*!\n     *  Get name of the indexed port.\n     *\n     *    @param [in] itemIndex   Index of the selected port.\n     *\n     *    @return Name of the selected port.\n     */\n    std::string getIndexedItemName(int itemIndex) const final;\n\n    /*!\n     *  Get the number of available port abstractions.\n     *\n     *    @return Number of available port abstractions.\n     */\n    virtual int itemCount() const override final;\n\n    /*!\n     *  Get the number of available signals in the selected port abstraction.\n     *\n     *    @param [in] portName    Name of the selected port abstraction.\n     *\n     *    @return Number of available signals in the selected port abstraction.\n     */\n    int signalCount(std::string const& portName) const;\n\n    /*!\n     *  Check if the selected port abstraction has multiples of the selected interface mode.\n     *\n     *    @param [in] portName    Name of the selected port abstraction.\n     *    @param [in] mode        The selected interface mode.\n     *\n     *    @return True, if the selected port abstraction has multiples of the selected mode, false if the\n     *              selected port abstraction has only a single signal of the selected mode or the interface\n     *              mode is system.\n     */\n    bool portHasMultiplesOfMasterOrSlave(std::string const& portName, std::string const& mode);\n\n    /*!\n     *  Set a new name for the selected port abstraction.\n     *\n     *    @param [in] currentName     Name of the selected port abstraction.\n     *    @param [in] newName         New name for the port abstraction.\n     *\n     *    @return True, if successful, false otherwise.\n     */\n    bool setName(std::string const& currentName, std::string const& newName) final;\n\n    /*!\n     *  Validates the contained port abstractions.\n     *\n     *    @return True, if all the port abstractions are valid, false otherwise.\n     */\n    bool validateItems() const final;\n\n    /*!\n     *  Check if the selected port abstraction has a valid name.\n     *\n     *    @param [in] portName    Name of the selected port abstraction.\n     *\n     *    @return True, if the name is valid, false otherwise.\n     */\n    bool itemHasValidName(std::string const& itemName) const final;\n\n    /*!\n     *\tCheck if the width of the wire port is valid.\n     *  \n     *    @param [in] portIndex     The index of the selected signal.\n     *\t    \n     * \t    @return True, if the widht is valid, otherwise false.\n     */\n    bool wireHasValidWidth(int portIndex) const;\n\n    /*!\n     *\tCheck if the default value of the wire port is valid.\n     *  \n     *    @param [in] portIndex     The index of the selected signal.\n     *\t    \n     * \t    @return True, if the default value is valid, otherwise false.\n     */\n    bool wireHasValidDefaultValue(int portIndex) const;\n\n    /*!\n     *\tGet the match status of the selected signal.\n     *  \n     *    @param [in] portIndex\tIndex of the selected signal.\n     *\t\t\n     * \t\t@return True, if signal port has match, otherwise false.\n     */\n    bool getMatch(int const& portIndex) const;\n\n    /*!\n     *\tSet the match status of the selected signal.\n     *\n     *    @param [in] portIndex\tIndex of the selected signal.\n     *    @param [in] match       Match flag to set.\n     *\n     * \t\t@return True, if match could be set, otherwise false.\n     */\n    bool setMatch(int const& portIndex, bool match) const;\n\n    /*!\n     *  Get the names of the available port abstractions.\n     *\n     *    @return Names of the available ports abstractions.\n     */\n    std::vector<std::string> getItemNames() const final;\n\n    /*!\n     *  Get the list of logical ports with the selected bus interface mode and system group.\n     *\n     *    @param [in] busModeString   The selected bus interface mode in string form.\n     *    @param [in] systemGroup     The selected system group.\n     *\n     *    @return A list of logical ports names.\n     */\n    std::vector<std::string> getItemNamesWithModeAndGroup(std::string const& busModeString,\n        std::string systemGroup) const;\n\n    /*!\n     *  Get the interface mode of the selected signal.\n     *\n     *    @param [in] portIndex   Index of the selected signal.\n     *\n     *    @return Interface mode of the selected signal.\n     */\n    General::InterfaceMode getMode(int const& portIndex) const;\n\n    /*!\n     *  Get the interface mode of the selected signal in string form.\n     *\n     *    @param [in] portIndex   Index of the selected signal.\n     *\n     *    @return Interface mode string of the selected signal.\n     */\n    std::string getModeString(int const& portIndex) const;\n\n    /*!\n     *  Set the interface mode for the selected signal.\n     *\n     *    @param [in] portIndex   Index of the selected signal.\n     *    @param [in] newMode     The new interface mode.\n     *\n     *    @return True, if successful, false otherwise.\n     */\n    bool setMode(int const& portIndex, std::string const& newMode);\n\n    /*!\n     *  Get the system group of the selected signal.\n     *\n     *    @param [in] portIndex   Index of the selected signal.\n     *\n     *    @return System group of the selected signal.\n     */\n    std::string getSystemGroup(int const& portIndex) const;\n\n    /*!\n     *  Get the system groups of the selected port abstraction.\n     *\n     *    @param [in] portName    Name of the selected port abstraction.\n     *\n     *    @return System groups of the selected port abstraction.\n     */\n    std::vector<std::string> getSystemGroupsForPort(std::string const& portName) const;\n\n    /*!\n     *  Set the system group for the selected signal.\n     *\n     *    @param [in] portIndex   Index of the selected signal.\n     *    @param [in] newSystem   The new system group.\n     *\n     *    @return True, if successful, false otherwise.\n     */\n    bool setSystemGroup(int const& portIndex, std::string const& newSystem);\n\n    /*!\n     *  Get the list of qualifiers of the selected signal.\n     *\n     *    @param [in] portIndex   Index of the selected signal.\n     *\n     *    @return List of qualifiers of the selected signal.\n     */\n    std::vector<std::string> getQualifierStringList(int const& portIndex) const;\n\n    /*!\n     *  Set the qualifier for the selected signal.\n     *\n     *    @param [in] portIndex       Index of the selected signal.\n     *    @param [in] newQualifier    The new qualifier.\n     *\n     *    @return True, if successful, false otherwise.\n     */\n    bool setQualifier(int const& portIndex, std::string const& newQualifier);\n\n    /*!\n     *  Set a new list of qualifiers for the selected signal.\n     *\n     *    @param [in] portIndex           Index of the selected signal.\n     *    @param [in] newQualifierList    The new list of qualifiers.\n     *\n     *    @return True, if successful, false otherwise.\n     */\n    bool setQualifierStringList(int const& portIndex, std::vector<std::string> const& newQualifierList);\n\n    /*!\n     *\tGet a chosen attribute of a qualifier.\n     *  \n     *    @param [in] portIndex\t            Index of the selected signal.\n     *    @param [in] attributeName\t        The name of the attribute to get.\n     *    @param [in] qualifierTypeString\t    The qualifier type.\n     *\t\t\n     * \t\t@return The chosen attribute.\n     */\n    std::string getQualifierAttribute(int const& portIndex, std::string const& attributeName) const;\n\n    /*!\n     *\tSet a qualifier attribute for a specific qualifier type.\n     *  \n     *    @param [in] portIndex\t            Index of the selected signal.\n     *    @param [in] attributeName\t        The name of the attribute to set.\n     *    @param [in] attributeValue\t        The value of the attribute to set.\n     *    @param [in] qualifierTypeString\t    The qualifier type.\n     *\t\t\n     * \t\t@return True, if attribute was successfully set, otherwise false.\n     */\n    bool setQualifierAttribute(int const& portIndex, std::string const& attributeName, \n        std::string const& attributeValue) const;\n\n    /*!\n     *\tSet all qualifier attributes at once.\n     *  \n     *    @param [in] portIndex\tIndex of the selected signal.\n     *    @param [in] attributes\tMap of attributes to set as name-value pairs.\n     *\t\t\n     * \t\t@return True, if attributes were set, otherwise false.\n     */\n    bool setQualifierAttributes(int const& portIndex, std::vector<std::string> const& attributes) const;\n\n    /*!\n     *\tGet all of the qualifier's attributes.\n     *  \n     *    @param [in] portIndex\tIndex of the selected signal.\n     *\t\t\n     * \t\t@return A map of attributes as name-value pairs.\n     */\n    std::vector<std::string> getQualifierAttributes(int const& portIndex) const;\n\n    /*!\n     *  Get the direction of the selected signal in string form.\n     *\n     *    @param [in] portIndex   Index of the selected signal.\n     *\n     *    @return Direction string of the selected signal.\n     */\n    std::string getDirectionString(int const& portIndex) const;\n\n    /*!\n     *  Get the direction of the selected signal.\n     *\n     *    @param [in] portIndex   Index of the selected signal.\n     *\n     *    @return Direction of the selected signal.\n     */\n    DirectionTypes::Direction getDirection(int const& portIndex) const;\n\n    /*!\n     *  Get the direction of the selected signal.\n     *\n     *    @param [in] portName        The selected signal name.\n     *    @param [in] mode            The selected bus interface mode.\n     *    @param [in] systemGroup     The selected system group.\n     *\n     *    @return Direction of the selected signal.\n     */\n    DirectionTypes::Direction getDirection(std::string const& portName, General::InterfaceMode mode,\n        std::string const& systemGroup) const;\n\n    /*!\n     *  Set a new direction for the selected signal.\n     *\n     *    @param [in] portIndex       Index of the selected signal.\n     *    @param [in] newDirection    The new direction.\n     *\n     *    @return True, if successful, false otherwise.\n     */\n    bool setDirection(int const& portIndex, std::string const& newDirection);\n\n    /*!\n     *  Get the width expression of the selected signal.\n     *\n     *    @param [in] portIndex   Index of the selected signal.\n     *\n     *    @return Width of the selected signal.\n     */\n    std::string getWidthExpression(int const& portIndex) const;\n\n    /*!\n     *  Get the width expression of the selected signal.\n     *\n     *    @param [in] portName        Name of the selected port.\n     *    @param [in] interfaceMode   The selected bus interface mode in string form.\n     *    @param [in] systemGroup     The selected system group.\n     *\n     *    @return Width of the selected signal.\n     */\n    std::string getWidthExpression(std::string const& portName, std::string const& interfaceMode,\n        std::string const& systemGroup) const;\n\n    /*!\n     *  Get the width expression of the selected signal.\n     *\n     *    @param [in] portName        Name of the selected port.\n     *    @param [in] interfaceMode   The selected bus interface mode.\n     *    @param [in] systemGroup     The selected system group.\n     *\n     *    @return Width of the selected signal.\n     */\n    std::string getWidthExpression(std::string const& portName, General::InterfaceMode interfaceMode,\n        std::string const& systemGroup) const;\n\n    /*!\n     *\tGet the formatted expression for the width of the selected wire port.\n     *  \n     *    @param [in] portIndex     Index of the selected signal.\n     *\t    \n     *    @return The formatted expression of the width.\n     */\n    std::string getWidthFormattedExpression(int portIndex) const;\n\n    /*!\n     *\tGet the width value of the selected signal.\n     *  \n     *    @param [in] portIndex      Index of the selected signal.\n     *    @param [in] baseNumber     Base number to format the value to.\n     *\t    \n     *    @return The evaluated value of the wire width.\n     */\n    std::string getWidthValue(int portIndex, int const& baseNumber = 0) const;\n\n    /*!\n     *\tGet the width value of the selected signal.\n     *  \n     *    @param [in] portName          Name of the selected port.\n     *    @param [in] interfaceMode     The interface mode of the port.\n     *    @param [in] systemGroup       The port system group.\n     *    @param [in] baseNumber        Base number to format the value to.\n     *\n     *    @return The evaluated value of the wire width.\n     */\n    std::string getWidthValue(std::string const& portName,\n        General::InterfaceMode interfaceMode,\n        std::string const& systemGroup,\n        int const& baseNumber = 0) const;\n\n    /*!\n     *  Set a new width for the selected signal.\n     *\n     *    @param [in] portIndex   Index of the selected signal.\n     *    @param [in] newWidth    The new width.\n     *\n     *    @return True, if successful, false otherwise.\n     */\n    bool setWidth(int const& portIndex, std::string const& newWidth);\n\n    /*!\n     *  Get the presence of the selected signal.\n     *\n     *    @param [in] portIndex   Index of the selected signal.\n     *\n     *    @return Presence of the selected signal.\n     */\n    PresenceTypes::Presence getPresence(int const& portIndex) const;\n\n    /*!\n     *  Get the presence of the selected signal.\n     *\n     *    @param [in] portName        Name of the selected port.\n     *    @param [in] interfaceMode   The selected bus interface mode.\n     *    @param [in] systemGroup     The selected system group.\n     *\n     *    @return Presence of the selected signal.\n     */\n    PresenceTypes::Presence getPresence(std::string const& portName, std::string const& interfaceMode,\n        std::string const& systemGroup) const;\n\n    /*!\n     *  Get the presence of the selected signal in string form.\n     *\n     *    @param [in] portIndex   Index of the selected signal.\n     *\n     *    @return Presence string of the selected signal.\n     */\n    std::string getPresenceString(int const& portIndex) const;\n\n    /*!\n     *  Get the presence of the selected signal in string form.\n     *\n     *    @param [in] portName        Name of the selected port.\n     *    @param [in] interfaceMode   The selected bus interface mode.\n     *    @param [in] systemGroup     The selected system group.\n     *\n     *    @return Presence string of the selected signal.\n     */\n    std::string getPresenceString(std::string const& portName, std::string const& interfaceMode,\n        std::string const& systemGroup) const;\n\n    /*!\n     *  Set a new presence for the selected signal.\n     *\n     *    @param [in] portIndex       Index of the selected signal.\n     *    @param [in] newPresence     The new presence.\n     *\n     *    @return True, if successful, false otherwise.\n     */\n    bool setPresence(int const& portIndex, std::string const& newPresence);\n\n    /*!\n     *  Get the default value expression of the selected signal.\n     *\n     *    @param [in] portIndex   Index of the selected signal.\n     *\n     *    @return Default value of the selected signal.\n     */\n    std::string getDefaultValueExpression(int const& portIndex) const;\n    \n    /*!\n     *  Get the formatted expression default value of the selected signal.\n     *\n     *    @param [in] portIndex   Index of the selected signal.\n     *\n     *    @return Default value of the selected signal.\n     */\n    std::string getDefaultValueFormattedExpression(int const& portIndex) const;\n\n    /*!\n     *  Get the evaluated default value of the selected signal.\n     *\n     *    @param [in] portIndex   Index of the selected signal.\n     *    @param [in] baseNumber  The base to format the value to.\n     *\n     *    @return Default value of the selected signal.\n     */\n    std::string getDefaultValueValue(int const& portIndex, int baseNumber = 0) const;\n\n    /*!\n     *  Set a new default value for the selected signal.\n     *\n     *    @param [in] portIndex           Index of the selected signal.\n     *    @param [in] newDefaultValue     The new default value.\n     *\n     *    @return True, if successful, false otherwise.\n     */\n    bool setDefaultValue(int const& portIndex, std::string const& newDefaultValue);\n\n    /*!\n     *  Get the driver of the selected signal in string form.\n     *\n     *    @param [in] portIndex   Index of the selected signal.\n     *\n     *    @return Driver string of the selected signal.\n     */\n    std::string getDriverString(int const& portIndex) const;\n\n    /*!\n     *  Set a new driver type for the selected signal.\n     *\n     *    @param [in] portIndex   Index of the selected signal.\n     *    @param [in] newDriver   The new driver type.\n     *\n     *    @return True, if successful, false otherwise.\n     */\n    bool setDriverType(int const& portIndex, std::string const& newDriver);\n\n    /*!\n     *  Get the bus width expression of the selected signal.\n     *\n     *    @param [in] portIndex   Index of the selected signal.\n     *\n     *    @return Bus width of the selected signal.\n     */\n    std::string getBusWidthExpression(int const& portIndex) const;\n\n    /*!\n     *  Get the bus width expression of the selected signal.\n     *\n     *    @param [in] portName        Name of the selected port.\n     *    @param [in] interfaceMode   The selected bus interface mode.\n     *    @param [in] systemGroup     The selected system group.\n     *\n     *    @return Bus width of the selected signal.\n     */\n    std::string getBusWidthExpression(std::string const& portName, std::string const& interfaceMode,\n        std::string const& systemGroup) const;\n\n    /*!\n     *  Get the formatted expression of the bus width of the selected signal.\n     *\n     *    @param [in] portIndex   Index of the selected signal.\n     *\n     *    @return Bus width of the selected signal.\n     */\n    std::string getBusWidthFormattedExpression(int signalIndex) const;\n    \n    /*!\n     *  Get the evaluated value of the bus width of the selected signal.\n     *\n     *    @param [in] portIndex   Index of the selected signal.\n     *    @param [in] baseNumber  The base to format the value to.\n     *\n     *    @return Bus width of the selected signal.\n     */\n    std::string getBusWidthValue(int portIndex, int baseNumber = 0) const;\n\n    /*!\n     *  Set a new bus width for the selected signal.\n     *\n     *    @param [in] portIndex       Index of the selected signal.\n     *    @param [in] newBusWidth     The new bus width.\n     *\n     *    @return True, if successful, false otherwise.\n     */\n    bool setBusWidth(int const& portIndex, std::string const& newBusWidth);\n\n    bool transactionalHasValidBusWidth(int portIndex) const;\n\n    /*!\n     *  Get the initiative of the selected signal.\n     *\n     *    @param [in] portIndex   Index of the selected signal.\n     *\n     *    @return Initiative of the selected signal.\n     */\n    std::string getInitiative(int const& portIndex) const;\n\n    /*!\n     *  Get the initiative of the selected signal.\n     *\n     *    @param [in] portName        Name of the selected port.\n     *    @param [in] interfaceMode   The selected bus interface mode.\n     *    @param [in] systemGroup     The selected system group.\n     *\n     *    @return Initiative of the selected signal.\n     */\n    std::string getInitiative(std::string const& portName, std::string const& interfaceMode,\n        std::string const& systemGroup) const;\n\n    /*!\n     *  Set a new initiative for the selected signal.\n     *\n     *    @param [in] portIndex       Index of the selected signal.\n     *    @param [in] newInitiative   The new initiative.\n     *\n     *    @return True, if successful, false otherwise.\n     */\n    bool setInitiative(int const& portIndex, std::string const& newInitiative);\n\n    /*!\n     *  Get the kind of the selected signal.\n     *\n     *    @param [in] portIndex   Index of the selected signal.\n     *\n     *    @return Kind of the selected signal.\n     */\n    std::string getKind(int const& portIndex) const;\n\n    /*!\n     *  Set a new kind for the selected signal.\n     *\n     *    @param [in] portIndex   Index of the selected signal.\n     *    @param [in] newKind     The new kind.\n     *\n     *    @return True, if successful, false otherwise.\n     */\n    bool setKind(int const& portIndex, std::string const& newKind);\n\n    /*!\n     *  Check if the selected signal contains protocol.\n     *\n     *    @param [in] portIndex   Index of the selected signal.\n     *\n     *    @return True, if the selected signal has protocol, false otherwise.\n     */\n    bool hasProtocol(int const& portIndex) const;\n\n    /*!\n     *  Get the protocol type of the selected signal.\n     *\n     *    @param [in] portIndex   Index of the selected signal.\n     *\n     *    @return Protocol type of the selected signal.\n     */\n    std::string getProtocolType(int const& portIndex) const;\n\n    /*!\n     *  Set a new protocol type for the selected signal.\n     *\n     *    @param [in] portIndex           Index of the selected signal.\n     *    @param [in] newProtocolType     The new protocol type.\n     *\n     *    @return True, if successful, false otherwise.\n     */\n    bool setProtocolType(int const& portIndex, std::string const& newProtocolType);\n\n    /*!\n     *  Get the payload name of the selected signal.\n     *\n     *    @param [in] portIndex   Index of the selected signal.\n     *\n     *    @return Payload name of the selected signal.\n     */\n    std::string getPayloadName(int const& portIndex);\n\n    /*!\n     *  Set a new payload name for the selected signal.\n     *\n     *    @param [in] portIndex       Index of the selected signal.\n     *    @param [in] newPayloadName  The new payload name.\n     *\n     *    @return True, if successful, false otherwise.\n     */\n    bool setPayloadName(int const& portIndex, std::string const& newPayloadName);\n\n    /*!\n     *  Get the payload type of the selected signal.\n     *\n     *    @param [in] portIndex   Index of the selected signal.\n     *\n     *    @return Payload type of the selected signal.\n     */\n    std::string getPayloadType(int const& portIndex);\n\n    /*!\n     *  Set a new payload type for the selected signal.\n     *\n     *    @param [in] portIndex       Index of the selected signal.\n     *    @param [in] newPayloadType  The new payload type.\n     *\n     *    @return True, if successful, false otherwise.\n     */\n    bool setPayloadType(int const& portIndex, std::string const& newPayloadType);\n\n    /*!\n     *  Get the payload extension of the selected signal.\n     *\n     *    @param [in] portIndex   Index of the selected signal.\n     *\n     *    @return Payload extension of the selected signal.\n     */\n    std::string getPayloadExtension(int const& portIndex);\n\n    /*!\n     *  Set a new payload extension for the selected signal.\n     *\n     *    @param [in] portIndex               Index of the selected signal.\n     *    @param [in] newPayloadExtension     The new payload extension.\n     *\n     *    @return True, if successful, false otherwise.\n     */\n    bool setPayloadExtension(int const& portIndex, std::string const& newPayloadExtension);\n\n    /*!\n     *  Add a port abstraction containing wire.\n     *\n     *    @param [in] newPortName     Name of the new port.\n     */\n    void addWirePort(std::string const& newPortName = std::string(\"\")) final;\n\n    /*!\n     *  Add a port abstraction containing transactional.\n     *\n     *    @param [in] newPortName     Name of the new port.\n     */\n    void addTransactionalPort(std::string const& newPortName = std::string(\"\")) final;\n\n    /*!\n     *  Add a wire signal with the selected interface mode to the selected port abstraction.\n     *\n     *    @param [in] portName    Name of the selected port abstraction.\n     *    @param [in] newMode     The selected interface mode.\n     */\n    void addModeSpecificWireSignal(std::string const& portName, General::InterfaceMode const& newMode);\n\n    /*!\n     *  Add a new wire signal with the selected system group.\n     *\n     *    @param [in] portName        Name of port abstraction containing the signal.\n     *    @param [in] systemGroup     The new system group.\n     */\n    void addWireSystemSignal(std::string const& portName, std::string const& systemGroup);\n\n    /*!\n     *  Add a transactional signal with the selected interface mode to the selected port abstraction.\n     *\n     *    @param [in] portName    Name of the selected port abstraction.\n     *    @param [in] newMode     The selected interface mode.\n     */\n    void addModeSpecificTransactionalSignal(std::string const& portName, General::InterfaceMode const& newMode);\n\n    /*!\n     *  Add a new transactional signal with the selected system group.\n     *\n     *    @param [in] portName        Name of port abstraction containing the signal.\n     *    @param [in] systemGroup     The new system group.\n     */\n    void addTransactionalSystemSignal(std::string const& portName, std::string const& systemGroup);\n\n    /*!\n     *  Remove the selected signal.\n     *\n     *    @param [in] signalIndex     Index of the selected signal.\n     *\n     *    @return True, if successful, false otherwise.\n     */\n    bool removeSignal(int const& signalIndex);\n\n    /*!\n     *  Check if the selected port abstraction contains a wire.\n     *\n     *    @param [in] portName    Name of the selected port abstraction.\n     *\n     *    @return True, if the selected port abstraction contains a wire, false otherwise.\n     */\n    bool portIsWire(std::string const& portName) const final;\n    \n    /*!\n     *  Check if the selected port abstraction contains a transactional.\n     *\n     *    @param [in] portName    Name of the selected port.\n     *\n     *    @return True, if the selected port abstraction contains a transactional, false otherwise.\n     */\n    bool portIsTransactional(std::string const& portName) const final;\n    \n    /*!\n     *  Get the icon path of the selected signal.\n     *\n     *    @param [in] signalIndex     Index of the selected signal.\n     *\n     *    @return Icon path for the selected signal.\n     */\n    std::string getIconPathForSignal(int const& signalIndex) const;\n\n    /*!\n     *  Get the icon path of the selected signal.\n     *\n     *    @param [in] portName        Name of the selected port.\n     *    @param [in] interfaceMode   The selected bus interface mode.\n     *    @param [in] systemGroup     The selected system group.\n     *\n     *    @return Icon path for the selected signal.\n     */\n    std::string getIconPathForSignal(std::string const& portName, std::string const& interfaceMode,\n        std::string const& systemGroup) const;\n\n    /*!\n     *  Write the ports from the table to the abstraction definition.\n     */\n    void save();\n\n    /*!\n     *  Check if the selected port has the selected bus interface mode and system group.\n     *\n     *    @param [in] portName        Name of the selected port.\n     *    @param [in] interfaceMode   The selected bus interface mode.\n     *    @param [in] systemGroup     The selected system group.\n     *\n     *    @return True, if the port has the selected bus interface mode with the selected system group, false\n     *              otherwise.\n     */\n    bool portHasMode(std::string const& portName, std::string const& interfaceMode, std::string const& systemGroup)\n        const;\n\n    /*!\n     *  Get the port abstraction with the selected name.\n     *\n     *    @param [in] portName    Name of the selected port.\n     *\n     *    @return The port abstraction with the selected name.\n     */\n    QSharedPointer<PortAbstraction> getPort(std::string const& portName) const;\n\n    /*!\n     *\tGet the standard revision of the abstraction definition.\n     *  \n     * \t\t@return The standard revision used.\n     */\n    Document::Revision getRevision() const;\n\n    \n    /*!\n     *\tGet the number of references made to itemID on a given signal row.\n     *  \n     *    @param [in] signalIndex     The index of the signal row.\n     *    @param [in] itemID          The parameter itemID to look for.\n     *\t    \n     * \t    @return Return the number of references made to itemID.\n     */\n    int getAllReferencesToIdInRow(int signalIndex, std::string const& itemID) const;\n\n    //! No copying. No assignment.\n    PortAbstractionInterface(const PortAbstractionInterface& other) = delete;\n    PortAbstractionInterface& operator=(const PortAbstractionInterface& other) = delete;\n\nprivate:\n\n    /*!\n     *  Get the port abstraction with the selected name, sliced to a NameGroup.\n     *\n     *    @param [in] portName    Name of the selected port.\n     *\n     *    @return The sliced port abstraction with the selected name.\n     */\n    QSharedPointer<NameGroup> getItem(std::string const& portName) const override;\n\n    //! SignalRow represents a single row in the table by grouping the port abstraction and transactional elements.\n    struct SignalRow\n    {\n        //! Defines the Port represented in the row.\n        QSharedPointer<PortAbstraction> abstraction_{ QSharedPointer<PortAbstraction>(new PortAbstraction()) };\n\n        //! Defines the mode of the signal (master, slave or system).\n        General::InterfaceMode mode_{ General::INTERFACE_MODE_COUNT };\n\n        //! Defines the wirePort represented on the row.\n        QSharedPointer<WirePort> wire_{ nullptr };\n\n        //! Defines the transactionalPort represented on the row.\n        QSharedPointer<TransactionalPort> transactional_{ nullptr };\n\n        /*!\n         *  The default constructor.\n         *\n         *    @param [in] isWirePort              Flag for wire ports.\n         *    @param [in] isTransactionalPort     Flag for transactional ports.\n         */\n        SignalRow(bool isWirePort, bool isTransactionalPort);\n\n        /*!\n         *  Copy constructor\n         */\n        SignalRow(SignalRow const& other) = default;\n\n        /*!\n         *  Comparison of two SignalRows.\n         *\n         *    @param [in] other   The SignalRow to compare this to.\n         *\n         *    @return True, if the SignalRows are equal, otherwise false.\n         */\n        bool operator==(SignalRow const& other) const;\n\n        /*!\n         *  Comparison of two SignalRows.\n         *\n         *    @param [in] other   The SignalRow to compare this to.\n         *\n         *    @return True, if the SignalRows are not equal, otherwise false.\n         */\n        bool operator!=(SignalRow const& other) const;\n\n        /*!\n         *  Less than comparison of two SignalRows for table ordering.\n         *\n         *    @param [in] other   The SignalRow to compare this to.\n         *\n         *    @return True, if this precedes other, otherwise false.\n         */\n        bool operator<(SignalRow const& other) const;\n    };\n \n    /*!\n     *  Get the signal of the selected index.\n     *\n     *    @param [in] signalIndex     The selected index.\n     *\n     *    @return The selected signal.\n     */\n    QSharedPointer<SignalRow> getSignal(int const& signalIndex) const;\n\n    /*!\n     *  Get or create a transactional protocol for the selected signal.\n     *\n     *    @param [in] signalIndex     Index of the selected signal.\n     *\n     *    @return Protocol of the selected signal.\n     */\n    QSharedPointer<Protocol> getOrCreateProtocol(int const& signalIndex) const;\n\n    /*!\n     *  Check if the selected protocol is empty and remove it if it is.\n     *\n     *    @param [in] signalIndex     Index of the containing signal.\n     *    @param [in] signalProtocol  The selected protocol.\n     */\n    void removeEmptyProtocol(int const& signalIndex, QSharedPointer<Protocol> signalProtocol);\n\n    /*!\n     *  Check if the protocol type of the selected protocol is empty.\n     *\n     *    @param [in] portProtocol    The selected protocol.\n     *\n     *    @return True, if the port protocol is empty, false otherwise.\n     */\n    bool portProcotolTypeIsEmpty(QSharedPointer<Protocol> portProtocol) const;\n\n    /*!\n     *  Get the protocol type of the selected protocol.\n     *\n     *    @param [in] portProtocol    The selected protocol.\n     *\n     *    @return The type of the selected protocol.\n     */\n    QString getProtocolTypeText(QSharedPointer<Protocol> portProtocol) const;\n    \n    /*!\n     *  Create a wire signal.\n     *\n     *    @param [in] portAbs         Port abstraction containing the signal.\n     *    @param [in] modeSpesific    Wire port data.\n     *    @param [in] mode            The interface mode.\n     */\n    void createWireSignal(QSharedPointer<PortAbstraction> portAbs, QSharedPointer<WirePort> modeSpesific,\n        General::InterfaceMode mode);\n\n    /*!\n     *  Create a transactional signal.\n     *\n     *    @param [in] portAbs         Port abstraction containing the signal.\n     *    @param [in] modeSpesific    Transactional port data.\n     *    @param [in] mode            The interface mode.\n     */\n    void createTransactionalSignal(QSharedPointer<PortAbstraction> portAbs,\n        QSharedPointer<TransactionalPort> modeSpesific, General::InterfaceMode mode);\n\n    /*!\n     *  Write the selected signal to the selected port abstraction.\n     *\n     *    @param [in] portAbs     The selected port abstraction.\n     *    @param [in] i           Index of the selected signal.\n     */\n    void savePort(QSharedPointer<PortAbstraction> portAbs, int i);\n\n    /*!\n     *  Check if the selected port already contains the selected signal.\n     *\n     *    @param [in] mode            The selected signal.\n     *    @param [in] portName        Name of the selected port.\n     *    @param [in] systemGroup     The selected system group.\n     *\n     *    @return True, if the selected port already contains the selected signal, false otherwise.\n     */\n    bool modeExistsForPort(General::InterfaceMode const& mode, QString const& portName,\n        QString const& systemGroup = \"\") const;\n\n    /*!\n     *  Construct a copy signal of the selected signal.\n     *\n     *    @param [in] signal  The selected port signal.\n     *\n     *    @return The constructed copy of the signal.\n     */\n     QSharedPointer<PortAbstractionInterface::SignalRow> constructCopySignal(QSharedPointer<PortAbstraction> port,\n         bool isWire, bool isTransactional) const;\n    \n    /*!\n     *  Get the mirrored direction for the selected signal.\n     *\n     *    @param [in] portName        Name of the selected port.\n     *    @param [in] opposingMode    The opposite interface mode of the selected signal.\n     *\n     *    @return The mirrored direction for the selected signal.\n     */\n    DirectionTypes::Direction getMirroredDirectionForSignal(QString const& portName,\n        General::InterfaceMode const& opposingMode) const;\n\n    /*!\n     *\tGet the corresponding qualifier attribute for a given string.\n     *  \n     *    @param [in] attributeName\tThe attribute name to convert to attribute type.\n     *\t\t\n     * \t\t@return The matching qualifier attribute type, or attribute type COUNT if there was no match.\n     */\n    Qualifier::Attribute getQualifierAttributeType(std::string const& attributeName) const;\n\n    /*!\n     *  Calculate all the references to the selected ID in the selected item. Does nothing useful in this interface.\n     *  Replaced by getAllReferencesToIdInRow().\n     *\n     *    @param [in] itemName    Name of the selected item.\n     *    @param [in] valueID     The selected ID.\n     *\n     *    @return Number of references to the selected ID in the selected item.\n     */\n    int getAllReferencesToIdInItem(const std::string& itemName, std::string const& valueID) const final;\n\n    //-----------------------------------------------------------------------------\n    // Data.\n    //-----------------------------------------------------------------------------\n    \n    //! Pointer to the available port abstractions.\n    QSharedPointer<QList<QSharedPointer<PortAbstraction> > > ports_;\n\n    //! List of signals.\n    QList<QSharedPointer<SignalRow> > signals_;\n\n    //! The standard revision of the abstraction definition.\n    Document::Revision abstractionStandardRevision_ = Document::Revision::Unknown;\n\n    //! The port valudator to use.\n    QSharedPointer<PortAbstractionValidator> portValidator_ = nullptr;\n};\n\n#endif // PORTABSTRACTIONINTERFACE_H\n"
  },
  {
    "path": "KactusAPI/include/PortMapInterface.h",
    "content": "//-----------------------------------------------------------------------------\n// File: PortMapInterface.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 22.10.2020\n//\n// Description:\n// Interface for editing port maps.\n//-----------------------------------------------------------------------------\n\n#ifndef PORTMAPINTERFACE_H\n#define PORTMAPINTERFACE_H\n\n#include <CommonInterface.h>\n#include <ParameterizableInterface.h>\n\n#include <IPXACTmodels/common/PresenceTypes.h>\n#include <IPXACTmodels/Component/PortMap.h>\n#include <IPXACTmodels/Component/Port.h>\n#include <IPXACTmodels/generaldeclarations.h>\n\n#include \"KactusAPI/KactusAPIGlobal.h\"\n\nclass PortMap;\nclass PortMapValidator;\nclass PortAbstraction;\nclass AbstractionDefinition;\nclass AbstractionType;\nclass Component;\nclass PortsInterface;\nclass PortAbstractionInterface;\n\n//-----------------------------------------------------------------------------\n//! Interface for editing port maps.\n//-----------------------------------------------------------------------------\nclass KACTUS2_API PortMapInterface : public ParameterizableInterface, public CommonInterface\n{\n\npublic:\n\n    /*!\n     *  The constructor.\n     *\n     *    @param [in] validator               Validator for address blocks.\n     *    @param [in] expressionParser        Parser for expressions.\n     *    @param [in] expressionFormatter     Formatter for expressions.\n     *    @param [in] physicalPortInterface   Interface for accessing physical ports.\n     *    @param [in] logicalPortInterface    Interface for accessing logical ports.\n     */\n    PortMapInterface(QSharedPointer<PortMapValidator> validator,\n        QSharedPointer<ExpressionParser> expressionParser,\n        QSharedPointer<ExpressionFormatter> expressionFormatter,\n        PortsInterface* physicalPortInterface,\n        PortAbstractionInterface* logicalPortInterface);\n\n\t/*!\n     *  The destructor.\n     */\n    virtual ~PortMapInterface() = default;\n\n    /*!\n     *  Setup the abstraction definition.\n     *\n     *    @param [in] absDef  The new abstraction definition.\n     */\n    void setupAbstractionDefinition(QSharedPointer<AbstractionDefinition const> absDef);\n\n    /*!\n     *  Setup the available physical ports.\n     *\n     *    @param [in] component   Component containing the selected ports.\n     */\n    void setupPhysicalPorts(Port::List ports);\n\n    /*!\n     *  Setup the available port maps.\n     *\n     *    @param [in] abstractionType     Abstraction type containing the available port maps.\n     */\n    virtual void setupPortMaps(QSharedPointer<AbstractionType> abstractionType);\n\n    /*!\n     *  Setup the bus interface mode.\n     *\n     *    @param [in] busMode     The new bus interface mode.\n     */\n    void setupBusMode(General::InterfaceMode busMode);\n\n    /*!\n     *  Setup the system group.\n     *\n     *    @param [in] systemGroup     The new system group.\n     */\n    void setupSystemGroup(QString const& systemGroup);\n\n    /*!\n     *  Get name of the indexed logical port.\n     *\n     *    @param [in] itemIndex   Index of the selected logical port.\n     *\n     *    @return Name of the selected logical port.\n     */\n    virtual std::string getIndexedItemName(int const& itemIndex) const;\n\n    /*!\n     *  Get the number of available port maps.\n     *\n     *    @return Number of available port maps.\n     */\n    virtual int itemCount() const override final;\n\n    /*!\n     *  Get the names of the available logical ports.\n     *\n     *    @return Names of the available logical ports.\n     */\n    virtual std::vector<std::string> getItemNames() const override final;\n\n    /*!\n     *  Get the logical port name modified by the port map index.\n     *\n     *    @param [in] portMapIndex    Index of the selected port map.\n     *\n     *    @return Modified logical port name.\n     */\n    std::string getLogicalPortName(int const& portMapIndex) const;\n\n    /*!\n     *  Set a new name for the selected logical port.\n     *\n     *    @param [in] portMapIndex    Index of the selected port map.\n     *    @param [in] newName         New name for the item.\n     *\n     *    @return True, if successful, false otherwise.\n     */\n    bool setLogicalPort(int const& portMapIndex, std::string const& newName);\n\n    /*!\n     *  Check if the selected port map has a connected physical port.\n     *\n     *    @param [in] portMapIndex    Index of the selected port map.\n     *\n     *    @return True, if the selected port map is connected to a logical port, false otherwise.\n     */\n    bool hasPhysicalPort(int const& portMapIndex) const;\n\n    /*!\n     *  Get the name of the connected physical port in the selected port map.\n     *\n     *    @param [in] portMapIndex    Index of the selected port map.\n     *\n     *    @return Name of the connected physical port in the selected port map.\n     */\n    std::string getPhysicalPortName(int const& portMapIndex) const;\n\n    /*!\n     *  Set a new name for the connected physical port in the selected port map.\n     *\n     *    @param [in] portMapIndex        Index of the selected port map.\n     *    @param [in] newPhysicalName     New name for the physical port.\n     *\n     *    @return True, if successful, false otherwise.\n     */\n    bool setPhysicalPort(int const& portMapIndex, std::string const& newPhysicalName);\n\n    /*!\n     *  Get the logical presence of the logical port in the selected port map.\n     *\n     *    @param [in] portMapIndex    Index of the selected port map.\n     *\n     *    @return Logical presence.\n     */\n    std::string getLogicalPresence(int const& portMapIndex);\n\n    /*!\n     *  Get the logical presence of the selected logical port.\n     *\n     *    @param [in] logicalPortName     Name of the selected logical port.\n     *\n     *    @return Logical presence of the selected logical port.\n     */\n    std::string getLogicalPresenceWithLogicalPort(std::string const& logicalName);\n\n    /*!\n     *  Get the invert value of the logical port  of the selected port map in string form.\n     *\n     *    @param [in] portMapIndex    Index of the selected port map.\n     *\n     *    @return Invert value of the selected logical port in string form.\n     */\n    std::string getInvertString(int const& portMapIndex) const;\n\n    /*!\n     *  Get the invert value of the logical port  of the selected port map.\n     *\n     *    @param [in] portMapIndex    Index of the selected port map.\n     *\n     *    @return Invert value.\n     */\n    BooleanValue getInvertValue(int const& portMapIndex) const;\n\n    /*!\n     *  Get the invert value of the logical port  of the selected port map.\n     *\n     *    @param [in] portMapIndex    Index of the selected port map.\n     *\n     *    @return Invert value.\n     */\n    bool getInvertBool(int const& portMapIndex) const;\n\n    /*!\n     *  Set a new invert value for the selected logical port.\n     *\n     *    @param [in] portMapIndex    Index of the selected port map.\n     *    @param [in] newInvertValue  The new invert value.\n     *\n     *    @return True, if successful, false otherwise.\n     */\n    bool setInvertValue(int const& portMapIndex, bool newInvertValue) const;\n\n    /*!\n     *  Get the is informative value of the selected port map in string form.\n     *\n     *    @param [in] portMapIndex    Index of the selected port map.\n     *\n     *    @return Is informative value of the selected port map in string form.\n     */\n    std::string getIsInformativeString(int const& portMapIndex) const;\n\n    /*!\n     *  Get the is informative value of the selected port map.\n     *\n     *    @param [in] portMapIndex    Index of the selected port map.\n     *\n     *    @return Is informative value of the selected port map.\n     */\n    bool getIsInformativeValue(int const& portMapIndex) const;\n\n    /*!\n     *  Set a new is informative value for the selected port map.\n     *\n     *    @param [in] portMapIndex        Index of the selected port map.\n     *\n     *    @return True, if successful, false otherwise.\n     */\n    bool setIsInformativeValue(int const& portMapIndex, bool newIsInformativeValue) const;\n\n    /*!\n     *  Get the calculated logical tie off of the selected item.\n     *\n     *    @param [in] portMapIndex        Index of the selected port map.\n     *    @param [in] baseNumber          Base for displaying the value.\n     *\n     *    @return Calculated logical tie off value of the selected item.\n     */\n    std::string getLogicalTieOffValue(int const& portMapIndex, int const& baseNumber = 0) const;\n\n    /*!\n     *  Get the formatted logical tie off expression of the selected item.\n     *\n     *    @param [in] portMapIndex    Index of the selected port map.\n     *\n     *    @return Formatted logical tie off expression of the selected item.\n     */\n    std::string getLogicalTieOffFormattedExpression(int const& portMapIndex) const;\n\n    /*!\n     *  Get the logical tie off expression of the selected item.\n     *\n     *    @param [in] portMapIndex    Index of the selected port map.\n     *\n     *    @return Logical tie off expression of the selected item.\n     */\n    std::string getLogicalTieOffExpression(int const& portMapIndex) const;\n\n    /*!\n     *  Set a new logical tie off value for the selected item.\n     *\n     *    @param [in] portMapIndex    Index of the selected port map.\n     *    @param [in] newTieOff       New logical tie off value.\n     *\n     *    @return True, if successful, false otherwise.\n     */\n    bool setLogicalTieOff(int const& portMapIndex, std::string const& newTieOff);\n\n    /*!\n     *  Get the calculated logical left bound of the selected item.\n     *\n     *    @param [in] portMapIndex    Index of the selected port map.\n     *    @param [in] baseNumber      Base for displaying the value.\n     *\n     *    @return Calculated logical left bound value of the selected item.\n     */\n    std::string getLogicalLeftBoundValue(int const& portMapIndex, int const& baseNumber = 0) const;\n\n    /*!\n     *  Get the formatted logical left bound expression of the selected item.\n     *\n     *    @param [in] portMapIndex    Index of the selected port map.\n     *\n     *    @return Formatted logical left bound expression of the selected item.\n     */\n    std::string getLogicalLeftBoundFormattedExpression(int const& portMapIndex) const;\n\n    /*!\n     *  Get the logical left bound expression of the selected item.\n     *\n     *    @param [in] portMapIndex    Index of the selected port map.\n     *\n     *    @return Logical left bound expression of the selected item.\n     */\n    std::string getLogicalLeftBoundExpression(int const& portMapIndex) const;\n\n    /*!\n     *  Set a new logical left value for the selected item.\n     *\n     *    @param [in] portMapIndex        Index of the selected port map.\n     *    @param [in] newLogicalLeft      New logical left value.\n     *\n     *    @return True, if successful, false otherwise.\n     */\n    bool setLogicalLeftBound(int const& portMapIndex, std::string const& newLogicalLeft);\n\n    /*!\n     *  Get the calculated logical right bound of the selected item.\n     *\n     *    @param [in] portMapIndex    Index of the selected port map.\n     *    @param [in] baseNumber      Base for displaying the value.\n     *\n     *    @return Calculated logical right bound value of the selected item.\n     */\n    std::string getLogicalRightBoundValue(int const& portMapIndex, int const& baseNumber = 0) const;\n\n    /*!\n     *  Get the formatted logical right bound expression of the selected item.\n     *\n     *    @param [in] portMapIndex    Index of the selected port map.\n     *\n     *    @return Formatted logical right bound expression of the selected item.\n     */\n    std::string getLogicalRightBoundFormattedExpression(int const& portMapIndex) const;\n\n    /*!\n     *  Get the logical right bound expression of the selected item.\n     *\n     *    @param [in] portMapIndex    Index of the selected port map.\n     *\n     *    @return Logical right bound expression of the selected item.\n     */\n    std::string getLogicalRightBoundExpression(int const& portMapIndex) const;\n\n    /*!\n     *  Set a new logical right value for the selected item.\n     *\n     *    @param [in] portMapIndex        Index of the selected port map.\n     *    @param [in] newLogicalRight     New logical right value.\n     *\n     *    @return True, if successful, false otherwise.\n     */\n    bool setLogicalRightBound(int const& portMapIndex, std::string const& newLogicalRight);\n\n    /*!\n     *  Get the calculated physical left bound of the selected item.\n     *\n     *    @param [in] portMapIndex    Index of the selected port map.\n     *    @param [in] baseNumber      Base for displaying the value.\n     *\n     *    @return Calculated physical left bound value of the selected item.\n     */\n    std::string getPhysicalLeftBoundValue(int const& portMapIndex, int const& baseNumber = 0) const;\n\n    /*!\n     *  Get the formatted physical left bound expression of the selected item.\n     *\n     *    @param [in] portMapIndex    Index of the selected port map.\n     *\n     *    @return Formatted physical left bound expression of the selected item.\n     */\n    std::string getPhysicalLeftBoundFormattedExpression(int const& portMapIndex) const;\n\n    /*!\n     *  Get the physical left bound expression of the selected item.\n     *\n     *    @param [in] portMapIndex    Index of the selected port map.\n     *\n     *    @return Physical left bound expression of the selected item.\n     */\n    std::string getPhysicalLeftBoundExpression(int const& portMapIndex) const;\n\n    /*!\n     *  Set a new physical left bound value for the selected item.\n     *\n     *    @param [in] portMapIndex        Index of the selected port map.\n     *    @param [in] newPhysicalLeft     New physical left value.\n     *\n     *    @return True, if successful, false otherwise.\n     */\n    bool setPhysicalLeftBound(int const& portMapIndex, std::string const& newPhysicalLeft);\n\n    /*!\n     *  Get the calculated physical right bound of the selected item.\n     *\n     *    @param [in] portMapIndex    Index of the selected port map.\n     *    @param [in] baseNumber      Base for displaying the value.\n     *\n     *    @return Calculated physical right bound value of the selected item.\n     */\n    std::string getPhysicalRightBoundValue(int const& portMapIndex, int const& baseNumber = 0) const;\n\n    /*!\n     *  Get the formatted physical right bound expression of the selected item.\n     *\n     *    @param [in] portMapIndex    Index of the selected port map.\n     *\n     *    @return Formatted physical right bound expression of the selected item.\n     */\n    std::string getPhysicalRightBoundFormattedExpression(int const& portMapIndex) const;\n\n    /*!\n     *  Get the physical right bound expression of the selected item.\n     *\n     *    @param [in] portMapIndex    Index of the selected port map.\n     *\n     *    @return Physical right bound expression of the selected item.\n     */\n    std::string getPhysicalRightBoundExpression(int const& portMapIndex) const;\n\n    /*!\n     *  Set a new physical right bound value for the selected item.\n     *\n     *    @param [in] portMapIndex        Index of the selected port map.\n     *    @param [in] newPhysicalRight    New physical right value.\n     *\n     *    @return True, if successful, false otherwise.\n     */\n    bool setPhysicalRightBound(int const& portMapIndex, std::string const& newPhysicalRight);\n\n    /*!\n     *  Get the icon path for the logical port of the selected port map.\n     *\n     *    @param [in] portMapIndex    Index of the selected port map.\n     *\n     *    @return Icon path.\n     */\n    std::string getLogicalPortIconPath(int const& portMapIndex) const;\n\n    /*!\n     *  Get the icon path for the physical port of the selected port map.\n     *\n     *    @param [in] portMapIndex    Index of the selected port map.\n     *\n     *    @return Icon path for the physical port in the selected port map.\n     */\n    std::string getPhysicalPortIconPath(int const& portMapIndex) const;\n\n    /*!\n     *  Check if the logical port of the selected port map exists.\n     *\n     *    @param [in] portMapIndex    Index of the selected port map.\n     *\n     *    @return True, if the logical port exists, false otherwise.\n     */\n    bool logicalPortExists(int const& portMapIndex) const;\n\n    /*!\n     *  Calculate all the references to the selected ID in the selected item.\n     *\n     *    @param [in] itemName    Name of the selected item.\n     *    @param [in] valueID     The selected ID.\n     *\n     *    @return Number of references to the selected ID in the selected item.\n     */\n    virtual int getAllReferencesToIdInItem(const std::string& itemName, std::string const&  valueID) const override\n        final;\n\n    /*!\n     *  Get the expressions in the selected port map.\n     *\n     *    @param [in] portMapIndex    Index of the selected port map.\n     *\n     *    @return Expressions in the selected component instantiations.\n     */\n    std::vector<std::string> getExpressionsInSelectedPortMap(int const& portMapIndex) const;\n\n    /*!\n     *  Validates the contained items.\n     *\n     *    @return True, if all the port maps are valid, false otherwise.\n     */\n    virtual bool validateItems() const override final;\n\n    /*!\n     *  Check if the logical port of the selected port map is valid.\n     *\n     *    @param [in] portMapIndex    Index of the selected port map.\n     *\n     *    @return True, if the logical port is valid, false otherwise.\n     */\n    bool logicalPortIsValid(int const& portMapIndex) const;\n\n    /*!\n     *  Check if the physical port of the selected port map is valid\n     *\n     *    @param [in] portMapIndex    Index of the selected port map.\n     *\n     *    @return True, if the physical port is valid, false otherwise.\n     */\n    bool physicalPortIsValid(int const& portMapIndex) const;\n\n    /*!\n     *  Check if the physical mapping of the selected port map is valid\n     *\n     *    @param [in] portMapIndex    Index of the selected port map.\n     *\n     *    @return True, if the physical mapping is valid, false otherwise.\n     */\n    bool physicalMappingIsValid(int const& portMapIndex) const;\n\n    /*!\n     *  Check if the mapped ports have valid port types.\n     *\n     *    @param [in] portMapIndex    Index of the selected port map.\n     *\n     *    @return True, if the mapped ports have valid types, otherwise false.\n     */\n    bool connectedPortsHaveValidPortTypes(int const& portMapIndex) const;\n\n    /*!\n     *  Check if the connected ports of the selected port map have valid directions.\n     *\n     *    @param [in] portMapIndex    Index of the selected port map.\n     *\n     *    @return True, if the directions are valid, otherwise false.\n     */\n    bool connectedPortsHaveValidDirections(int const& portMapIndex) const;\n\n    /*!\n     *  Check if the connected ports of the selected port map have valid initiatives.\n     *\n     *    @param [in] portMapIndex    Index of the selected port map.\n     *\n     *    @return True, if the initiatives are valid, otherwise false.\n     */\n    bool connectedPortsHaveValidInitiatives(int const& portMapIndex) const;\n\n    /*!\n     *  Check if the connected ports of the selected port map have the same range.\n     *\n     *    @param [in] portMapIndex    Index of the selected port map.\n     *\n     *    @return True, if the connected ports have the same range, otherwise false.\n     */\n    bool connectedPortsHaveSameRange(int const& portMapIndex) const;\n\n    /*!\n     *  Check if the tie off value of the selected port map is valid.\n     *\n     *    @param [in] portMapIndex    Index of the selected port map.\n     *\n     *    @return True, if the tie off value of the selected port map is valid, otherwise false.\n     */\n    bool tieOffIsValid(int const& portMapIndex) const;\n\n    /*!\n     * Checks if the logical port of the selected port map has a valid range.\n     *\n     *    @param [in] portMapIndex    Index of the selected port map.\n     *\n     *    @return True, if the range is valid, otherwise false.\n     */\n    bool logicalPortHasValidRange(int const& portMapIndex) const;\n\n    /*!\n     *  Connect the selected logical port to the selected physical port.\n     *\n     *    @param [in] logicalPortName     Name of the selected logical port.\n     *    @param [in] physicalPortName    Name of the selected physical port.\n     *\n     *    @return True, if successful, false otherwise.\n     */\n    bool connectPorts(std::string const& logicalPortName, std::string const& physicalPortName);\n\n    /*!\n     *  Add a new port map.\n     *\n     *    @param [in] row     Row of the new port map.\n     */\n    void addPortMap(int const& row);\n\n    /*!\n     *  Remove the selected port map.\n     *\n     *    @param [in] portMapIndex    Index of the selected port map.\n     *\n     *    @return True, if successful, false otherwise.\n     */\n    bool removePortMap(int const& portMapIndex);\n\n    /*!\n     *  Remove all the port maps from the selected logical port.\n     *\n     *    @param [in] logicalPortName     Name of the selected logical port.\n     *\n     *    @return List of connected physical port names.\n     */\n    std::vector<std::string> removeAllPortMapsFromLogicalPort(std::string const& logicalPortName);\n\n    /*!\n     *  Get a pointer to the selected port map.\n     *\n     *    @param [in] portMapIndex    Index of the selected port map.\n     *\n     *    @return Pointer to the selected port map.\n     */\n    PortMap* getPortMapPointer(int const& portMapIndex) const;\n\n    /*!\n     *  Get the interface for accessing physical ports.\n     *\n     *    @return Interface for accessing physical ports.\n     */\n    PortsInterface* getPhysicalPortInterface() const;\n\n    /*!\n     *  Get the interface for accessing logical ports.\n     *\n     *    @return Interface for accessing logical ports.\n     */\n    PortAbstractionInterface* getLogicalPortInterface() const;\n\n    /*!\n     *  Create port maps from signals with required presence.\n     */\n    void createRequiredSignals();\n\n    /*!\n     *  Create port maps from signals with optional presence.\n     */\n    void createOptionalSignals();\n\n    /*!\n     *  Create port maps from all signals.\n     */\n    void createAllSignals();\n\n    /*!\n     *  Get the currently active bus interface mode.\n     *\n     *    @return The active interface mode.\n     */\n    General::InterfaceMode getInterfaceMode() const;\n\n    /*!\n     *  Get the currently active system group.\n     *\n     *    @return The active system group.\n     */\n    std::string getSystemGroup() const;\n\nprivate:\n\n    /*!\n     *  Get a port map with the selected logical signal without connected physical port or assigned tie off.\n     *\n     *    @param [in] logicalPortName     Name of the selected logical signal.\n     *\n     *    @return Port map with the connected logical port and unconnected physical.\n     */\n    QSharedPointer<PortMap> getUnconnectedPortMap(std::string const& logicalPortName) const;\n\n    /*!\n     *  Get the selected port map.\n     *\n     *    @param [in] portMapIndex    Index of the selected port map.\n     *\n     *    @return The selected port map.\n     */\n    QSharedPointer<PortMap> getPortMap(int const& portMapIndex) const;\n\n    /*!\n     *  Remove an empty logical port from the selected port map.\n     *\n     *    @param [in] editedPortMap   The selected port map.\n     *\n     *    @return True, if the logical port was removed, false otherwise.\n     */\n    bool removeEmptyLogicalPort(QSharedPointer<PortMap> editedPortMap);\n\n    /*!\n     *  Remove an empty range container from the selected logical port.\n     *\n     *    @param [in] editedPortLogical   The selected logical port.\n     */\n    bool removeEmptyRange(QSharedPointer<PortMap::LogicalPort> editedPortLogical);\n\n    /*!\n     *  Remove an empty physical port container from the selected port map.\n     *\n     *    @param [in] editedPortMap   The selected port map.\n     *\n     *    @return True, if successful, false otherwise.\n     */\n    bool removeEmptyPhysicalPort(QSharedPointer<PortMap> editedPortMap);\n\n    /*!\n     *  Remove an empty physical part select container from the selected physical port.\n     *\n     *    @param [in] editedPortMap   The selected port map.\n     *\n     *    @return True, if successful, false otherwise.\n     */\n    bool removeEmptyPhysicalPartSelect(QSharedPointer<PortMap::PhysicalPort> physicalPort);\n\n    /*!\n     *  Create a part select container for the physical port in the selected port map.\n     *\n     *    @param [in] portMapIndex    Index of the selected port map.\n     *\n     *    @return The created part select.\n     */\n    QSharedPointer<PartSelect> getPhysicalPartSelect(int const& portMapIndex);\n\n    /*!\n     *  Create port maps with the selected presence.\n     *\n     *    @param [in] presence    The selected presence.\n     */\n    void createPortMapsWithPresence(int presence);\n\n    /*!\n     *  Check if a port map exists for the selected signal.\n     *\n     *    @param [in] signalName  Name of the selected logical signal.\n     *\n     *    @return True, if a port map exists for the selected signal, false otherwise.\n     */\n    bool portMapExistsForLogicalSignal(std::string const& signalName) const;\n\n    //-----------------------------------------------------------------------------\n    // Data.\n    //-----------------------------------------------------------------------------\n\n    //! List of the contained port maps.\n    QSharedPointer<QList<QSharedPointer<PortMap> > > portMaps_{ nullptr };\n\n    //! Specifies the currently active interface mode.\n    General::InterfaceMode interfaceMode_;\n\n    //! The system group name in case of system mode.\n    std::string systemGroup_;\n\n    //! The abstraction definition referenced by the abstraction type.\n    QSharedPointer<AbstractionDefinition const> abstractionDef_{ nullptr };\n\n    //! Validator for port maps.\n    QSharedPointer<PortMapValidator> validator_{ nullptr };\n\n    //! Interface for accessing physical ports.\n    PortsInterface* physicalPortInterface_{ nullptr };\n\n    //! Interface for accessing logical ports.\n    PortAbstractionInterface* logicalPortInterface_{ nullptr };\n};\n\n#endif // PORTMAPINTERFACE_H\n"
  },
  {
    "path": "KactusAPI/include/PortsInterface.h",
    "content": "//-----------------------------------------------------------------------------\n// File: PortsInterface.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 25.02.2020\n//\n// Description:\n// Interface for editing component ports.\n//-----------------------------------------------------------------------------\n\n#ifndef PORTSINTERFACE_H\n#define PORTSINTERFACE_H\n\n#include <KactusAPI/KactusAPIGlobal.h>\n\n#include <ParameterizableInterface.h>\n#include <MasterPortInterface.h>\n\n#include <IPXACTmodels/common/DirectionTypes.h>\n#include <IPXACTmodels/Component/Port.h>\n\n\nclass PortValidator;\n\n//-----------------------------------------------------------------------------\n//! Interface for editing component ports.\n//-----------------------------------------------------------------------------\nclass KACTUS2_API PortsInterface : public ParameterizableInterface, public MasterPortInterface\n{\npublic:\n\n    /*!\n     *  The constructor.\n     *\n     *    @param [in] validator               Validator for ports.\n     *    @param [in] expressionParser        Parser for expressions.\n     *    @param [in] expressionFormatter     Formatter for expressions.\n     */\n    PortsInterface(QSharedPointer<PortValidator> validator,\n        QSharedPointer<ExpressionParser> expressionParser,\n        QSharedPointer<ExpressionFormatter> expressionFormatter);\n\n\t/*!\n     *  The destructor.\n     */\n    virtual ~PortsInterface() = default;\n\n    /*!\n     *  Set available ports.\n     *\n     *    @param [in] ports   The ports to set.\n     */\n    void setPorts(Port::List ports);\n\n    /*!\n     *  Check if the there are any available ports.\n     *\n     *    @return True, if there are available ports, false otherwise.\n     */\n    bool hasPorts() const;\n\n    /*!\n     *  Get index of the selected port.\n     *\n     *    @param [in] itemName    Name of the selected port.\n     *\n     *    @return Index of the selected port.\n     */\n    int getItemIndex(std::string const& itemName) const final;\n\n    /*!\n     *  Get name of the indexed port.\n     *\n     *    @param [in] portIndex   Index of the selected port.\n     *\n     *    @return Name of the selected port.\n     */\n    std::string getIndexedItemName(int itemIndex) const final;\n\n    /*!\n     *  Get the number of available ports.\n     *\n     *    @return Number of available ports.\n     */\n    int itemCount() const final;\n\n    /*!\n     *  Get the names of the available ports.\n     *\n     *    @return Names of the available ports.\n     */\n    std::vector<std::string> getItemNames() const final;\n\n    /*!\n     *  Set a new name for the selected port.\n     *\n     *    @param [in] currentPortName     Name of the selected port.\n     *    @param [in] newPortName         New name for the port.\n     *\n     *    @return True, if successful, false otherwise.\n     */\n    bool setName(std::string const& currentName, std::string const& newName) final;\n\n    /*!\n     *  Calculate all the references to the selected ID in the selected port.\n     *\n     *    @param [in] portName    Name of the selected port.\n     *    @param [in] valueID     The selected ID.\n     *\n     *    @return Number of references to the selected ID in the selected port.\n     */\n    int getAllReferencesToIdInItem(const std::string& itemName, std::string const&  valueID) const final;\n\n    /*!\n     *  Check if the selected port exists.\n     *\n     *    @param [in] portName    Name of the selected port.\n     *\n     *    @return True, if the port exists, false otherwise.\n     */\n    bool portExists(std::string const& portName) const;\n\n    /*!\n     *  Validates the contained ports.\n     *\n     *    @return True, if all the ports are valid, false otherwise.\n     */\n    bool validateItems() const final;\n\n    /*!\n     *  Check if the selected port has a valid name.\n     *\n     *    @param [in] portName    Name of the selected port.\n     *\n     *    @return True, if the name is valid, false otherwise.\n     */\n    bool itemHasValidName(std::string const& itemName) const final;\n\n    /*!\n     *  Get the type name of the selected port.\n     *\n     *    @param [in] portName    Name of the selected port.\n     *\n     *    @return Type name of the selected port.\n     */\n    std::string getTypeName(std::string const& portName) const;\n\n    /*!\n     *\tGet the type name and type view references as pairs.\n     *  \n     *    @param [in] portName     Name of the selected port.\n     *\t    \n     * \t    @return Vector of pairs of type names and vectors of view references.\n     */\n    std::vector<std::pair<std::string, std::vector<std::string> > > getTypeNameViews(std::string const& portName) const;\n\n    /*!\n     *\tGet the type name and type definitions as a list of pairs.\n     *  \n     *    @param [in] portName     Name of the selected port.\n     *\t    \n     * \t    @return Vector containing pairs of type names and type definition vectors.\n     */\n    std::vector<std::pair<std::string, std::vector<std::string> > > getTypeDefinitions(std::string const& portName) const;\n\n    /*!\n     *\tSet the port type definition view refs. Should only be used in copy pasting, updates or overwrites existing type def view refs.\n     *  \n     *    @param [in] portName            Name of the selected port.\n     *    @param [in] typeNameViews       The type def name-view reference pairs to set.\n     *\t    \n     * \t    @return True, if the operation was successful, otherwise false.\n     */\n    bool setTypeDefViewRefs(std::string const& portName, std::vector<std::pair<std::string, std::vector<std::string> > > const& typeNameViews);\n\n    /*!\n     *\tSet the port type definition type definitions.\n     *  \n     *    @param [in] portName            Name of the selected port.\n     *    @param [in] typeDefinitions     The type def name-typeDef pairs to set.\n     *\t    \n     * \t    @return True, if the operation was successful, otherwise false.\n     */\n    bool setTypeDefDefinitions(std::string const& portName, std::vector<std::pair<std::string, std::vector<std::string> > > const& typeDefinitions);\n\n    /*!\n     *\tClear the type definitions of a selected port.\n     *  \n     *    @param [in] portName     Name of the selected port.\n     *\t    \n     * \t    @return True, if the selected port is found, otherwise false.\n     */\n    bool clearTypeDefinitions(std::string const& portName);\n\n    /*!\n     *  Set a new type name for the selected port.\n     *\n     *    @param [in] portName    Name of the selected port.\n     *    @param [in] newType     New type name.\n     *\n     *    @return True, if successful, false otherwise.\n     */\n    bool setTypeName(std::string const& portName, std::string const& newType) const;\n\n    /*!\n     *  Get the calculated array left value of the selected port.\n     *\n     *    @param [in] portName    Name of the selected port.\n     *    @param [in] baseNumber  Base for displaying the value.\n     *\n     *    @return Calculated array left value of the selected port.\n     */\n    std::string getArrayLeftValue(std::string const& portName, unsigned int baseNumber = 0) const;\n\n    /*!\n     *  Get the formatted array left expression of the selected port.\n     *\n     *    @param [in] portName    Name of the selected port.\n     *\n     *    @return Formatted array left expression of the selected port.\n     */\n    std::string getArrayLeftFormattedExpression(std::string const& portName) const;\n\n    /*!\n     *  Get the array left expression of the selected port.\n     *\n     *    @param [in] portName    Name of the selected port.\n     *\n     *    @return Array left expression of the selected port.\n     */\n    std::string getArrayLeftExpression(std::string const& portName) const;\n\n    /*!\n     *  Set a new array left value for the selected port.\n     *\n     *    @param [in] portName        Name of the selected port.\n     *    @param [in] newArrayLeft    New array left value.\n     *\n     *    @return True, if successful, false otherwise.\n     */\n    bool setArrayLeft(std::string const& portName, std::string const& newArrayLeft) const;\n\n    /*!\n     *  Get the calculated array right value of the selected port.\n     *\n     *    @param [in] portName    Name of the selected port.\n     *    @param [in] baseNumber  Base for displaying the value.\n     *\n     *    @return Calculated array right value of the selected port.\n     */\n    std::string getArrayRightValue(std::string const& portName, unsigned int baseNumber = 0) const;\n\n    /*!\n     *  Get the formatted array right expression of the selected port.\n     *\n     *    @param [in] portName    Name of the selected port.\n     *\n     *    @return Formatted array right expression of the selected port.\n     */\n    std::string getArrayRightFormattedExpression(std::string const& portName) const;\n\n    /*!\n     *  Get the array right expression of the selected port.\n     *\n     *    @param [in] portName    Name of the selected port.\n     *\n     *    @return Array right expression of the selected port.\n     */\n    std::string getArrayRightExpression(std::string const& portName) const;\n\n    /*!\n     *  Set a new array right value for the selected port.\n     *\n     *    @param [in] portName        Name of the selected port.\n     *    @param [in] newArrayRight   New array right value.\n     *\n     *    @return True, if successful, false otherwise.\n     */\n    bool setArrayRight(std::string const& portName, std::string const& newArrayRight) const;\n\n    /*!\n     *  Get the tags of the selected port.\n     *\n     *    @param [in] portName    Name of the selected port.\n     *\n     *    @return Tags of the selected port.\n     */\n    std::string getTags(std::string const& portName) const;\n\n    /*!\n     *  Set new tags for the selected port.\n     *\n     *    @param [in] portName    Name of the selected port.\n     *    @param [in] tagList     List of the new tags separated by ','.\n     *\n     *    @return True, if successful, false otherwise.\n     */\n    bool setTags(std::string const& portName, std::string const& tagList) const;\n\n    /*!\n     *  Check if the selected port is ad hoc.\n     *\n     *    @param [in] portName    Name of the selected port.\n     *\n     *    @return True, if the selected port is ad hoc, false otherwise.\n     */\n    bool isAdHoc(std::string const& portName) const;\n\n    /*!\n     *  Set a new ad hoc visibility flag for the selected port.\n     *\n     *    @param [in] portName            Name of the selected port.\n     *    @param [in] newAdHocVisibility  Flag for ad hoc visibility.\n     *\n     *    @return True, if successful, false otherwise.\n     */\n    bool setAdHoc(std::string const& portName, bool newAdHocVisibility) const;\n\n    /*!\n     *  Get the direction of the selected port.\n     *\n     *    @param [in] portName    Name of the selected port.\n     *\n     *    @return Direction of the selected port.\n     */\n    std::string getDirection(std::string const& portName) const;\n\n    /*!\n     *  Get the direction of the selected port.\n     *\n     *    @param [in] portName    Name of the selected port.\n     *\n     *    @return Direction of the selected port.\n     */\n    DirectionTypes::Direction getDirectionType(std::string const& portName) const;\n\n    /*!\n     *  Set direction for the selected port.\n     *\n     *    @param [in] portName        Name of the selected port.\n     *    @param [in] newDirection    New direction.\n     *\n     *    @return True, if successful, false otherwise.\n     */\n    bool setDirection(std::string const& portName, std::string const& newDirection) const;\n\n    /*!\n     *  Get the calculated left bound value of the selected port.\n     *\n     *    @param [in] portName    Name of the selected port.\n     *    @param [in] baseNumber  Base for displaying the value.\n     *\n     *    @return Calculated left bound value of the selected port.\n     */\n    std::string getLeftBoundValue(std::string const& portName, unsigned int baseNumber = 0) const;\n\n    /*!\n     *  Get the formatted left bound expression of the selected port.\n     *\n     *    @param [in] portName    Name of the selected port.\n     *\n     *    @return Formatted left bound expression of the selected port.\n     */\n    std::string getLeftBoundFormattedExpression(std::string const& portName) const;\n\n    /*!\n     *  Get the left bound expression of the selected port.\n     *\n     *    @param [in] portName    Name of the selected port.\n     *\n     *    @return Left bound expression of the selected port.\n     */\n    std::string getLeftBoundExpression(std::string const& portName) const;\n\n    /*!\n     *  Set a new left bound value for the selected port.\n     *\n     *    @param [in] portName        Name of the selected port.\n     *    @param [in] newLeftBound    New left bound value.\n     *\n     *    @return True, if successful, false otherwise.\n     */\n    bool setLeftBound(std::string const& portName, std::string const& newLeftBound) const;\n\n    /*!\n     *  Get the calculated right bound value of the selected port.\n     *\n     *    @param [in] portName    Name of the selected port.\n     *    @param [in] baseNumber  Base for displaying the value.\n     *\n     *    @return Calculated right bound value of the selected port.\n     */\n    std::string getRightBoundValue(std::string const& portName, unsigned int baseNumber = 0) const;\n\n    /*!\n     *  Get the formatted right bound expression of the selected port.\n     *\n     *    @param [in] portName    Name of the selected port.\n     *\n     *    @return Formatted right bound expression of the selected port.\n     */\n    std::string getRightBoundFormattedExpression(std::string const& portName) const;\n\n    /*!\n     *  Get the right bound expression of the selected port.\n     *\n     *    @param [in] portName    Name of the selected port.\n     *\n     *    @return Right bound expression of the selected port.\n     */\n    std::string getRightBoundExpression(std::string const& portName) const;\n    \n    /*!\n     *  Set a new right bound value for the selected port.\n     *\n     *    @param [in] portName        Name of the selected port.\n     *    @param [in] newRightBound   New right bound value.\n     *\n     *    @return True, if successful, false otherwise.\n     */\n    bool setRightBound(std::string const& portName, std::string const& newRightBound) const;\n\n    /*!\n     *  Check if the selected port has an expression in the left or right bound values.\n     *\n     *    @param [in] portName    Name of the selected port.\n     *\n     *    @return True, if the port has an expression in the left or right bound values, false otherwise.\n     */\n    bool hasExpressionInLeftOrRightBound(std::string const& portName) const;\n\n    /*!\n     *  Get the calculated width of the selected port.\n     *\n     *    @param [in] portName    Name of the selected port.\n     *\n     *    @return Calculated width of the selected port.\n     */\n    std::string getWidth(std::string const& portName) const;\n\n    /*!\n     *  Set new values for the left and right bounds of the selected port.\n     *\n     *    @param [in] portName    Name of the selected port.\n     *    @param [in] newWidth    New width.\n     *\n     *    @return True, if successful, false otherwise.\n     */\n    bool setWidth(std::string const& portName, std::string const& newWidth) const;\n\n    /*!\n     *  Get the calculated default value of the selected port.\n     *\n     *    @param [in] portName    Name of the selected port.\n     *    @param [in] baseNumber  Base for displaying the value.\n     *\n     *    @return Calculated default value of the selected port.\n     */\n    std::string getDefaultValue(std::string const& portName, unsigned int baseNumber = 0) const;\n\n    /*!\n     *  Get the formatted default value expression of the selected port.\n     *\n     *    @param [in] portName    Name of the selected port.\n     *\n     *    @return Formatted default value expression of the selected port.\n     */\n    std::string getDefaultValueFormattedExpression(std::string const& portName) const;\n\n    /*!\n     *  Get the default value expression of the selected port.\n     *\n     *    @param [in] portName    Name of the selected port.\n     *\n     *    @return Default value expression of the selected port.\n     */\n    std::string getDefaultValueExpression(std::string const& portName) const;\n    \n    /*!\n     *  Set a new default value for the selected port.\n     *\n     *    @param [in] portName            Name of the selected port.\n     *    @param [in] newDefaultValue     New default value.\n     *\n     *    @return True, if successful, false otherwise.\n     */\n    bool setDefaultValue(std::string const& portName, std::string const& newDefaultValue) const;\n\n    /*!\n     *  Get the calculated bus width value of the selected port.\n     *\n     *    @param [in] portName    Name of the selected port.\n     *    @param [in] baseNumber  Base for displaying the value.\n     *\n     *    @return Calculated bus width value of the selected port.\n     */\n    std::string getBusWidthValue(std::string const& portName, unsigned int baseNumber = 0) const;\n\n    /*!\n     *  Get the formatted bus width expression of the selected port.\n     *\n     *    @param [in] portName    Name of the selected port.\n     *\n     *    @return Formatted bus width expression of the selected port.\n     */\n    std::string getBusWidthFormattedExpression(std::string const& portName) const;\n\n    /*!\n     *  Get the bus width expression of the selected port.\n     *\n     *    @param [in] portName    Name of the selected port.\n     *\n     *    @return Bus width expression of the selected port.\n     */\n    std::string getBusWidthExpression(std::string const& portName) const;\n\n    /*!\n     *  Set a new bus width for the selected port.\n     *\n     *    @param [in] portName        Name of the selected port.\n     *    @param [in] newBusWidth     New bus width.\n     *\n     *    @return True, if successful, false otherwise.\n     */\n    bool setBusWidth(std::string const& portName, std::string const& newBusWidth) const;\n\n    /*!\n     *  Get the initiative of the selected port.\n     *\n     *    @param [in] portName    Name of the selected port.\n     *\n     *    @return Initiative of the selected port.\n     */\n    std::string getInitiative(std::string const& portName) const;\n\n    /*!\n     *  Set initiative for the selected port.\n     *\n     *    @param [in] portName        Name of the selected port.\n     *    @param [in] newInitiative   New initiative.\n     *\n     *    @return True, if successful, false otherwise.\n     */\n    bool setInitiative(std::string const& portName, std::string const& newInitiative) const;\n\n    /*!\n     *  Get the kind of the selected port.\n     *\n     *    @param [in] portName    Name of the selected port.\n     *\n     *    @return Kind of the selected port.\n     */\n    std::string getKind(std::string const& portName) const;\n\n    /*!\n     *  Set kind for the selected port.\n     *\n     *    @param [in] portName    Name of the selected port.\n     *    @param [in] newKind     New kind.\n     *\n     *    @return True, if successful, false otherwise.\n     */\n    bool setKind(std::string const& portName, std::string const& newKind) const;\n\n    /*!\n     *  Get the protocol type of the selected port.\n     *\n     *    @param [in] portName    Name of the selected port.\n     *\n     *    @return Protocol type of the selected port.\n     */\n    std::string getProtocolType(std::string const& portName) const;\n\n    /*!\n     *  Set protocol type for the selected port.\n     *\n     *    @param [in] portName            Name of the selected port.\n     *    @param [in] newProtocolType     New protocol type.\n     *\n     *    @return True, if successful, false otherwise.\n     */\n    bool setProtocolType(std::string const& portName, std::string const& newProtocolType) const;\n\n    /*!\n     *  Get the calculated max connections value of the selected port.\n     *\n     *    @param [in] portName    Name of the selected port.\n     *    @param [in] baseNumber  Base for displaying the value.\n     *\n     *    @return Calculated max connections value of the selected port.\n     */\n    std::string getMaxConnectionsValue(std::string const& portName, unsigned int baseNumber = 0) const;\n\n    /*!\n     *  Get the formatted max connections expression of the selected port.\n     *\n     *    @param [in] portName    Name of the selected port.\n     *\n     *    @return Formatted max connections expression of the selected port.\n     */\n    std::string getMaxConnectionsFormattedExpression(std::string const& portName) const;\n\n    /*!\n     *  Get the max connections expression of the selected port.\n     *\n     *    @param [in] portName    Name of the selected port.\n     *\n     *    @return Max connections expression of the selected port.\n     */\n    std::string getMaxConnectionsExpression(std::string const& portName) const;\n\n    /*!\n     *  Set a new max connections value for the selected port.\n     *\n     *    @param [in] portName            Name of the selected port.\n     *    @param [in] newMaxConnections   New max connections value.\n     *\n     *    @return True, if successful, false otherwise.\n     */\n    bool setMaxConnections(std::string const& portName, std::string const& newMaxConnections) const;\n\n    /*!\n     *  Get the calculated min connections value of the selected port.\n     *\n     *    @param [in] portName    Name of the selected port.\n     *    @param [in] baseNumber  Base for displaying the value.\n     *\n     *    @return Calculated min connections value of the selected port.\n     */\n    std::string getMinConnectionsValue(std::string const& portName, unsigned int baseNumber = 0) const;\n\n    /*!\n     *  Get the formatted min connections expression of the selected port.\n     *\n     *    @param [in] portName    Name of the selected port.\n     *\n     *    @return Formatted min connections expression of the selected port.\n     */\n    std::string getMinConnectionsFormattedExpression(std::string const& portName) const;\n\n    /*!\n     *  Get the min connections expression of the selected port.\n     *\n     *    @param [in] portName    Name of the selected port.\n     *\n     *    @return Min connections expression of the selected port.\n     */\n    std::string getMinConnectionsExpression(std::string const& portName) const;\n\n    /*!\n     *  Set a new min connections value for the selected port.\n     *\n     *    @param [in] portName            Name of the selected port.\n     *    @param [in] newMinConnections   New max connections value.\n     *\n     *    @return True, if successful, false otherwise.\n     */\n    bool setMinConnections(std::string const& portName, std::string const& newMinConnections) const;\n\n\t/*!\n\t *  Add a wire port.\n\t *\n\t *    @param [in] newPortName     Name of the new port.\n\t */\n\tvoid addWirePort(std::string const& newPortName = std::string()) final;\n\n    /*!\n     *  Add a transactional port.\n     *\n     *    @param [in] newPortName     Name of the new port.\n     */\n    void addTransactionalPort(std::string const& newPortName = std::string()) final;\n\n    /*!\n     *  Remove the selected port.\n\t *\n\t *    @param [in] portName    Name of the selected port.\n     */\n    bool removePort(std::string const& portName) const;\n\n    /*!\n     *  Check if the selected port has a valid left array value.\n     *\n     *    @param [in] portName    Name of the selected port.\n     *\n     *    @return True, if the left array value is valid, false otherwise.\n     */\n    bool portLeftArrayValueIsValid(std::string const& portName) const;\n\n    /*!\n     *  Check if the selected port has a valid right array value.\n     *\n     *    @param [in] portName    Name of the selected port.\n     *\n     *    @return True, if the right array value is valid, false otherwise.\n     */\n    bool portRightArrayValueIsValid(std::string const& portName) const;\n\n    /*!\n     *  Check if the selected port has valid types.\n     *\n     *    @param [in] portName    Name of the selected port.\n     *\n     *    @return True, if the types is valid, false otherwise.\n     */\n    bool portHasValidTypes(std::string const& portName) const;\n\n    /*!\n     *  Check if the selected port is a wire.\n     *\n     *    @param [in] portName    Name of the selected port.\n     *\n     *    @return True, if the selected port is a wire, false otherwise.\n     */\n    bool portIsWire(std::string const& portName) const final;\n\n    /*!\n     *  Check if the selected port is a wire.\n     *\n     *    @param [in] port    The selected port.\n     *\n     *    @return True, if the selected port is a wire, false otherwise.\n     */\n    bool portIsWire(QSharedPointer<Port> port) const;\n\n    /*!\n     *  Check if the selected port has a valid left bound value.\n     *\n     *    @param [in] portName    Name of the selected port.\n     *\n     *    @return True, if the left bound value is valid, false otherwise.\n     */\n    bool portHasValidLeftBound(std::string const& portName) const;\n\n    /*!\n     *  Check if the selected port has a valid right bound value.\n     *\n     *    @param [in] portName    Name of the selected port.\n     *\n     *    @return True, if the right bound value is valid, false otherwise.\n     */\n    bool portHasValidRightBound(std::string const& portName) const;\n\n    /*!\n     *  Check if the selected port has a valid default value.\n     *\n     *    @param [in] portName    Name of the selected port.\n     *\n     *    @return True, if the default value is valid, false otherwise.\n     */\n    bool portHasValidDefaultValue(std::string const& portName) const;\n\n    /*!\n     *  Check if the selected port is transactional.\n     *\n     *    @param [in] portName    Name of the selected port.\n     *\n     *    @return True, if the selected port is transactional, false otherwise.\n     */\n    bool portIsTransactional(std::string const& portName) const final;\n\n    /*!\n     *  Check if the selected port is transactional.\n     *\n     *    @param [in] port    The selected port.\n     *\n     *    @return True, if the selected port is transactional, false otherwise.\n     */\n    bool portIsTransactional(QSharedPointer<Port> port) const;\n\n    /*!\n     *  Check if the selected port has a valid bus width.\n     *\n     *    @param [in] portName    Name of the selected port.\n     *\n     *    @return True, if the bus width is valid, false otherwise.\n     */\n    bool portHasValidBusWidth(std::string const& portName) const;\n\n    /*!\n     *  Check if the selected port has a valid initiative.\n     *\n     *    @param [in] portName    Name of the selected port.\n     *\n     *    @return True, if the initiative is valid, false otherwise.\n     */\n    bool portHasValidInitiative(std::string const& portName) const;\n\n    /*!\n     *  Check if the selected port has a valid kind.\n     *\n     *    @param [in] portName    Name of the selected port.\n     *\n     *    @return True, if the kind is valid, false otherwise.\n     */\n    bool portHasValidKind(std::string const& portName) const;\n\n    /*!\n     *  Check if the selected port has a valid protocol.\n     *\n     *    @param [in] portName    Name of the selected port.\n     *\n     *    @return True, if the protocol is valid, false otherwise.\n     */\n    bool portHasValidProtocol(std::string const& portName) const;\n\n    /*!\n     *  Check if the selected port has a valid max connections value.\n     *\n     *    @param [in] portName    Name of the selected port.\n     *\n     *    @return True, if the max connections value is valid, false otherwise.\n     */\n    bool portHasValidMaxConnections(std::string const& portName) const;\n\n    /*!\n     *  Check if the selected port has a valid min connections value.\n     *\n     *    @param [in] portName    Name of the selected port.\n     *\n     *    @return True, if the min connections value is valid, false otherwise.\n     */\n    bool portHasValidMinConnections(std::string const& portName) const;\n\n    /*!\n     *  Get the icon path of the selected port.\n     *\n     *    @param [in] portName    Name of the selected port.\n     *\n     *    @return Icon path for the selected port.\n     */\n    std::string getIconPathForPort(std::string const& portName) const;\n\n    /*!\n     *  Get the port with the selected name.\n     *\n     *    @param [in] portName    Name of the selected port.\n     *\n     *    @return The port with the selected name.\n     */\n    QSharedPointer<Port> getPort(std::string const& portName) const;\n\n    QSharedPointer<NameGroup> getItem(std::string const& portName) const final;\n\n    //! No copying. No assignment.\n    PortsInterface(const PortsInterface& other) = delete;\n    PortsInterface& operator=(const PortsInterface& other) = delete;\n\nprivate:\n\n    /*!\n     *  Set the type name and definition of a port.\n     *\n     *    @param [in] port    The selected port.\n     */\n    void setTypeNameAndDefinition(QSharedPointer<Port> port) const;\n\n    //-----------------------------------------------------------------------------\n    // Data.\n    //-----------------------------------------------------------------------------\n\n    //! Pointer to the available ports.\n    Port::List ports_ = nullptr;\n\n    //! The validator used for ports.\n    QSharedPointer<PortValidator> portValidator_;\n};\n\n#endif // PORTSMODEL_H\n"
  },
  {
    "path": "KactusAPI/include/RegisterExpressionsGatherer.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: RegisterExpressionGatherer.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Mikko Teuho\r\n// Date: 29.04.2015\r\n//\r\n// Description:\r\n// Gathers expressions from a register and its fields.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef REGISTEREXPRESSIONSGATHERER_H\r\n#define REGISTEREXPRESSIONSGATHERER_H\r\n\r\n#include <QSharedPointer>\r\n#include <QStringList>\r\n\r\nclass Register;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Gathers expressions from a register and its fields.\r\n//-----------------------------------------------------------------------------\r\nclass RegisterExpressionsGatherer\r\n{\r\n\r\npublic:\r\n\r\n    /*!\r\n     *  The constructor.\r\n     */\r\n    RegisterExpressionsGatherer();\r\n\r\n    /*!\r\n     *  The destructor.\r\n     */\r\n    virtual ~RegisterExpressionsGatherer();\r\n\r\n    /*!\r\n     *  Get the expressions from a given register.\r\n     *\r\n     *    @param [in] currentRegister     The given register.\r\n     *\r\n     *    @return A list containing all the expressions used in a register.\r\n     */\r\n    QStringList getExpressions(QSharedPointer<Register> currentRegister) const;\r\n\r\nprivate:\r\n\t\r\n\t//! No copying\r\n    RegisterExpressionsGatherer(const RegisterExpressionsGatherer& other);\r\n\r\n\t//! No assignment\r\n    RegisterExpressionsGatherer& operator=(const RegisterExpressionsGatherer& other);\r\n\r\n};\r\n\r\n#endif // REGISTEREXPRESSIONSGATHERER_H\r\n"
  },
  {
    "path": "KactusAPI/include/RegisterFileExpressionsGatherer.h",
    "content": "#ifndef REGISTERFILEEXPRESSIONGATHERER_H\n#define REGISTERFILEEXPRESSIONGATHERER_H\n\n#include <KactusAPI/KactusAPIGlobal.h>\n\n#include <QSharedPointer>\n#include <QStringList>\n\nclass RegisterFile;\n\n//-----------------------------------------------------------------------------\n//! Gathers expressions from a register file and its registers\n//-----------------------------------------------------------------------------\nclass KACTUS2_API RegisterFileExpressionsGatherer\n{\n\npublic:\n\n    /*!\n     *  The constructor.\n     */\n    RegisterFileExpressionsGatherer();\n\n    /*!\n     *  The destructor.\n     */\n    virtual ~RegisterFileExpressionsGatherer() = default;\n\n    //! No copying\n    RegisterFileExpressionsGatherer(const RegisterFileExpressionsGatherer& other) = delete;\n\n    //! No assignment\n    RegisterFileExpressionsGatherer& operator=(const RegisterFileExpressionsGatherer& other) = delete;\n\n    /*!\n     *  Get the expressions from a given register file.\n     *\n     *    @param [in] currentRegister     The given register file.\n     *\n     *    @return A list containing all the expressions used in a register file.\n     */\n    QStringList getExpressions(QSharedPointer<RegisterFile> currentRegisterFile) const;\n\n};\n\n#endif // REGISTERFILEEXPRESSIONGATHERER_H\n"
  },
  {
    "path": "KactusAPI/include/RegisterInterface.h",
    "content": "//-----------------------------------------------------------------------------\n// File: RegisterInterface.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 27.04.2020\n//\n// Description:\n// Interface for editing registers.\n//-----------------------------------------------------------------------------\n\n#ifndef REGISTERINTERFACE_H\n#define REGISTERINTERFACE_H\n\n#include <KactusAPI/KactusAPIGlobal.h>\n\n#include <ParameterizableInterface.h>\n#include <NameGroupInterface.h>\n\n#include <IPXACTmodels/common/AccessTypes.h>\n\nclass Register;\nclass RegisterBase;\nclass RegisterValidator;\nclass FieldInterface;\nclass AccessPolicyInterface;\n\n#include <QVector>\n#include <QMap>\n\n//-----------------------------------------------------------------------------\n//! Interface for editing registers.\n//-----------------------------------------------------------------------------\nclass KACTUS2_API RegisterInterface : public ParameterizableInterface, public NameGroupInterface\n{\n\npublic:\n\n    /*!\n     *  The constructor.\n     *\n     *    @param [in] validator               Validator for registers.\n     *    @param [in] expressionParser        Parser for expressions.\n     *    @param [in] expressionFormatter     Formatter for expressions.\n     *    @param [in] subInterface            Interface for accessing fields.\n     */\n    RegisterInterface(QSharedPointer<RegisterValidator> validator,\n        QSharedPointer<ExpressionParser> expressionParser,\n        QSharedPointer<ExpressionFormatter> expressionFormatter,\n        FieldInterface* subInterface,\n        AccessPolicyInterface* accessPolicyInterface);\n\t\n\t/*!\n     *  The destructor.\n     */\n    virtual ~RegisterInterface() = default;\n\n    /*!\n     *  Set available registers.\n     *\n     *    @param [in] newRegisterData     The new register data.\n     */\n    void setRegisters(QSharedPointer<QList<QSharedPointer<RegisterBase> > > newRegisterData);\n\n    /*!\n     *  Get index of the selected item.\n     *\n     *    @param [in] itemName    Name of the selected item.\n     *\n     *    @return Index of the selected item.\n     */\n    virtual int getItemIndex(std::string const& itemName) const override final;\n\n    /*!\n     *  Get name of the indexed item.\n     *\n     *    @param [in] itemIndex   Index of the selected item.\n     *\n     *    @return Name of the selected item.\n     */\n    std::string getIndexedItemName(int itemIndex) const final;\n\n    /*!\n     *  Get the number of available items.\n     *\n     *    @return Number of available items.\n     */\n    virtual int itemCount() const override final;\n\n    /*!\n     *  Get the number of register data.\n     *\n     *    @return Number of register data.\n     */\n    int registerDataCount() const;\n\n    /*!\n     *  Get the selected index as the index of register data.\n     *\n     *    @param [in] index   The selected index.\n     *\n     *    @return The selected index transformed to register data index.\n     */\n    int indexInRegisterData(int const& index) const;\n\n    /*!\n     *  Get the names of the available items.\n     *\n     *    @return Names of the available items.\n     */\n    virtual std::vector<std::string> getItemNames() const override final;\n\n    /*!\n     *  Set a new name for the selected item.\n     *\n     *    @param [in] currentName     Name of the selected item.\n     *    @param [in] newName         New name for the item.\n     *\n     *    @return True, if successful, false otherwise.\n     */\n    virtual bool setName(std::string const& currentName, std::string const& newName) override final;\n\n    /*!\n     *  Get the calculated offset value of the selected register.\n     *\n     *    @param [in] registerName    Name of the selected register.\n     *    @param [in] baseNumber      Base for displaying the value.\n     *\n     *    @return Calculated offset value of the selected register.\n     */\n    std::string getOffsetValue(std::string const& registerName, int const& baseNumber = 0) const;\n\n    /*!\n     *  Get the formatted offset expression of the selected register.\n     *\n     *    @param [in] registerName    Name of the selected register.\n     *\n     *    @return Formatted offset expression of the selected register.\n     */\n    std::string getOffsetFormattedExpression(std::string const& registerName) const;\n\n    /*!\n     *  Get the offset expression of the selected register.\n     *\n     *    @param [in] registerName    Name of the selected register.\n     *\n     *    @return Offset expression of the selected register.\n     */\n    std::string getOffsetExpression(std::string const& registerName) const;\n\n    /*!\n     *  Set a new offset value for the selected register.\n     *\n     *    @param [in] registerName    Name of the selected register.\n     *    @param [in] newOffset       New offset value.\n     *\n     *    @return True, if successful, false otherwise.\n     */\n    bool setOffset(std::string const& registerName, std::string const& newOffset);\n    \n    /*!\n     *  Get the calculated dimension value of the selected register.\n     *\n     *    @param [in] registerName    Name of the selected register.\n     *    @param [in] baseNumber      Base for displaying the value.\n     *\n     *    @return Calculated dimension value of the selected register.\n     */\n    std::string getDimensionValue(std::string const& registerName, int const& baseNumber = 0) const;\n\n    /*!\n     *  Get the formatted dimension expression of the selected register.\n     *\n     *    @param [in] registerName    Name of the selected register.\n     *\n     *    @return Formatted dimension expression of the selected register.\n     */\n    std::string getDimensionFormattedExpression(std::string const& registerName) const;\n\n    /*!\n     *  Get the dimension expression of the selected register.\n     *\n     *    @param [in] registerName    Name of the selected register.\n     *\n     *    @return Dimension expression of the selected register.\n     */\n    std::string getDimensionExpression(std::string const& registerName) const;\n\n    /*!\n     *  Set a new dimension value for the selected register.\n     *\n     *    @param [in] registerName    Name of the selected register.\n     *    @param [in] newDimension    New dimension value.\n     *\n     *    @return True, if successful, false otherwise.\n     */\n    bool setDimension(std::string const& registerName, std::string const& newDimension);\n    \n    /*!\n     *  Get the calculated is present value of the selected register.\n     *\n     *    @param [in] registerName    Name of the selected register.\n     *    @param [in] baseNumber      Base for displaying the value.\n     *\n     *    @return Calculated is present value of the selected register.\n     */\n    std::string getIsPresentValue(std::string const& registerName, int const& baseNumber = 0) const;\n\n    /*!\n     *  Get the formatted is present expression of the selected register.\n     *\n     *    @param [in] registerName    Name of the selected register.\n     *\n     *    @return Formatted is present expression of the selected register.\n     */\n    std::string getIsPresentFormattedExpression(std::string const& registerName) const;\n\n    /*!\n     *  Get the is present expression of the selected register.\n     *\n     *    @param [in] registerName    Name of the selected register.\n     *\n     *    @return Is present expression of the selected register.\n     */\n    std::string getIsPresentExpression(std::string const& registerName) const;\n\n    /*!\n     *  Set a new is present value for the selected register.\n     *\n     *    @param [in] registerName    Name of the selected register.\n     *    @param [in] newIsPresent    New is present value.\n     *\n     *    @return True, if successful, false otherwise.\n     */\n    bool setIsPresent(std::string const& registerName, std::string const& newIsPresent);\n    \n    /*!\n     *  Get the calculated size value of the selected register.\n     *\n     *    @param [in] registerName    Name of the selected register.\n     *    @param [in] baseNumber      Base for displaying the value.\n     *\n     *    @return Calculated size value of the selected register.\n     */\n    std::string getSizeValue(std::string const& registerName, int const& baseNumber = 0) const;\n\n    /*!\n     *  Get the formatted size expression of the selected register.\n     *\n     *    @param [in] registerName    Name of the selected register.\n     *\n     *    @return Formatted size expression of the selected register.\n     */\n    std::string getSizeFormattedExpression(std::string const& registerName) const;\n\n    /*!\n     *  Get the size expression of the selected register.\n     *\n     *    @param [in] registerName    Name of the selected register.\n     *\n     *    @return Size expression of the selected register.\n     */\n    std::string getSizeExpression(std::string const& registerName) const;\n\n    /*!\n     *  Set a new size value for the selected register.\n     *\n     *    @param [in] registerName    Name of the selected register.\n     *    @param [in] newSize         New size value.\n     *\n     *    @return True, if successful, false otherwise.\n     */\n    bool setSize(std::string const& registerName, std::string const& newSize);\n\n    /*!\n     *  Get the volatile of the selected register.\n     *\n     *    @param [in] registerName    Name of the selected register.\n     *\n     *    @return The volatile value of the selected register.\n     */\n    std::string getVolatile(std::string const& registerName) const;\n\n    /*!\n     *  Set the volatile for the selected register.\n     *\n     *    @param [in] registerName    Name of the selected register.\n     *    @param [in] newVolatile     The new volatile value.\n     *\n     *    @return True, if successful, false otherwise.\n     */\n    bool setVolatile(std::string const& registerName, std::string const& newVolatile);\n    \n    /*!\n     *  Get the access string of the selected register or first access policy.\n     *\n     *    @param [in] registerName            Name of the selected register.\n     *    @param [in] getAccessPolicyAccess   Flag indicating if access is fetched from access policy or directly\n     *                                          from register. Access is fetched from first access policy, if true.\n     *\n     *    @return The access string of the selected register.\n     */\n    std::string getAccessString(std::string const& registerName, bool getAccessPolicyAccess = false) const;\n\n    /*!\n     *  Get the access of the selected register or access policy given by the access policy index.\n     *\n     *    @param [in] registerName        Name of the selected register.\n     *    @param [in] accessPolicyIndex   The index of the selected access policy.\n     *\n     *    @return The access value of the selected register.\n     */\n    AccessTypes::Access getAccess(std::string const& registerName) const;\n\n    /*!\n     *  Set the access value for the selected register or its access policy given by the access policy index.\n     *\n     *    @param [in] registerName            Name of the selected register.\n     *    @param [in] newAccess               The new access value.\n     *    @param [in] getAccessPolicyAccess   Flag indicating if access is set to access policy or directly\n     *                                          to register. Access is set to first access policy, if true.\n     *\n     *    @return True, if successful, false otherwise.\n     */\n    bool setAccess(std::string const& registerName, std::string const& newAccess, bool setAccessPolicyAccess = false);\n\n    /*!\n     *\tGet the number of access policies for a given register.\n     *  \n     *    @param [in] registerName     The name of the register to get the number off access policies of.\n     *\t    \n     * \t    @return The number of access policies for the given register.\n     */\n    int getAccessPolicyCount(std::string const& registerName) const;\n\n    /*!\n     *\tAdds a new access policy to the selected register.\n     *  \n     *    @param [in] registerName     The selected register.\n     *\t    \n     * \t    @return True, if operation was successful, otherwise false.\n     */\n    bool addAccessPolicy(std::string const& registerName);\n\n    /*!\n     *  Calculate all the references to the selected ID in the selected item.\n     *\n     *    @param [in] itemName    Name of the selected item.\n     *    @param [in] valueID     The selected ID.\n     *\n     *    @return Number of references to the selected ID in the selected item.\n     */\n    virtual int getAllReferencesToIdInItem(const std::string& itemName, std::string const&  valueID) const override\n        final;\n\n    /*!\n     *  Validates the contained items.\n     *\n     *    @return True, if all the ports are valid, false otherwise.\n     */\n    virtual bool validateItems() const override final;\n\n    /*!\n     *  Check if the selected item has a valid name.\n     *\n     *    @param [in] itemName    Name of the selected item.\n     *\n     *    @return True, if the name is valid, false otherwise.\n     */\n    virtual bool itemHasValidName(std::string const& itemName) const override final;\n\n    /*!\n     *  Check if the selected register has a valid dimension.\n     *\n     *    @param [in] registerName    Name of the selected register.\n     *\n     *    @return True, if the dimension is valid, false otherwise.\n     */\n    bool hasValidDimension(std::string const& registerName) const;\n\n    /*!\n     *  Check if the selected register has a valid offset.\n     *\n     *    @param [in] registerName    Name of the selected register.\n     *\n     *    @return True, if the offset is valid, false otherwise.\n     */\n    bool hasValidOffset(std::string const& registerName) const;\n\n    /*!\n     *  Check if the selected register has a valid is present value.\n     *\n     *    @param [in] registerName    Name of the selected register.\n     *\n     *    @return True, if the is present value is valid, false otherwise.\n     */\n    bool hasValidIsPresent(std::string const& registerName) const;\n\n    /*!\n     *  Check if the selected register has a valid size.\n     *\n     *    @param [in] registerName    Name of the selected register.\n     *\n     *    @return True, if the size is valid, false otherwise.\n     */\n    bool hasValidSize(std::string const& registerName) const;\n\n    /*!\n     *  Add a new register, inserting it to position specified by row and dataIndex.\n     *\n     *    @param [in] row                 Row of the new register.\n     *    @param [in] dataIndex           Index of the new register in the register data.\n     *    @param [in] newRegisterName     Name of the new register.\n     */\n    void addRegister(int const& row, int const& dataIndex, std::string const& newRegisterName = std::string(\"\"));\n    \n    /*!\n     *  Add a new register.\n     *  This overload should be preferred when using Python.\n     *\n     *    @param [in] newRegisterName     Name of the new register.\n     */\n    void addRegister(std::string const& newRegisterName = std::string(\"\"));\n    \n    /*!\n     *  Remove the selected register.\n     *\n     *    @param [in] registerName    Name of the selected register.\n     *    @param [in] dataIndex       Index of the removed register in the register data.\n     *\n     *    @return True, if successful, false otherwise.\n     */\n    bool removeRegister(std::string const& registerName, int const& dataIndex);\n\n    /*!\n     *  Copy the selected registers.\n     *\n     *    @param [in] selectedRows    Indexes of the selected registers.\n     */\n    void copyRows(std::vector<int> const& selectedRows);\n\n    /*!\n     *  Paste the selected registers.\n     *\n     *    @return Names of the pasted registers.\n     */\n    std::vector<std::string> pasteRows();\n\n    /*!\n     *  Get the number of pasted registers.\n     *\n     *    @return Number of the pasted registers.\n     */\n    int getPasteRowCount() const;\n\n    /*!\n     *  Get the expressions in the selected registers.\n     *\n     *    @param [in] registerNames   Names of the selected registers.\n     *\n     *    @return The expressions of the selected registers.\n     */\n    std::vector<std::string> getExpressionsInSelectedRegisters(std::vector<std::string> const& registerNames) const;\n\n    /*!\n     *  Change the value for address unit bits.\n     *\n     *    @param [in] newAddressUnitbits  The new value for address unit bits.\n     */\n    void setAddressUnitBits(int const& newAddressUnitbits);\n\n    /*!\n     *  Get the sub interface.\n     *\n     *    @return Interface for accessing fields.\n     */\n    FieldInterface* getSubInterface() const;\n\n    /*!\n     *\tGet the access policy interface.\n     *  \n     * \t    @return Interface for accessing the register access policies.\n     */\n    AccessPolicyInterface* getAccessPolicyInterface() const;\n\nprivate:\n\n    /*!\n     *  Get the selected register.\n     *\n     *    @param [in] registerName    Name of the selected register.\n     *\n     *    @return The selected register.\n     */\n    QSharedPointer<Register> getRegister(std::string const& registerName) const;\n\n    /*!\n     *  Get the register with the selected name, sliced to a NameGroup.\n     *\n     *    @param [in] registerName    Name of the selected register.\n     *\n     *    @return The sliced register with the selected name.\n     */\n    QSharedPointer<NameGroup> getItem(std::string const& registerName) const;\n\n    /*!\n     *\tCalculate the offset of the next register to be added.\n     *  \n     *    @return The offset for the new register\n     */\n    QString getNextRegisterOffset() const;\n\n    //-----------------------------------------------------------------------------\n    // Data.\n    //-----------------------------------------------------------------------------\n\n    //! List of the contained register data.\n    QSharedPointer<QList<QSharedPointer<RegisterBase> > > registerData_;\n\n    //! List of contained registers.\n    QList<QSharedPointer<Register> > registers_;\n\n    //! Validator for registers.\n    QSharedPointer<RegisterValidator> validator_;\n\n    //! Interface for accessing fields.\n    FieldInterface* subInterface_;\n\n    //! Interface for accessing register access policies.\n    AccessPolicyInterface* accessPolicyInterface_;\n\n    //! The address unit bits of the memory map.\n    unsigned int addressUnitBits_;\n};\n\n#endif // REGISTERINTERFACE_H\n"
  },
  {
    "path": "KactusAPI/include/ResetInterface.h",
    "content": "//-----------------------------------------------------------------------------\n// File: ResetInterface.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 20.04.2020\n//\n// Description:\n// Interface for editing resets.\n//-----------------------------------------------------------------------------\n\n#ifndef RESETINTERFACE_H\n#define RESETINTERFACE_H\n\n#include <KactusAPI/KactusAPIGlobal.h>\n\n#include <ParameterizableInterface.h>\n#include <CommonInterface.h>\n\nclass Field;\nclass FieldReset;\nclass FieldValidator;\n\n//-----------------------------------------------------------------------------\n//! Interface for editing resets.\n//-----------------------------------------------------------------------------\nclass KACTUS2_API ResetInterface : public ParameterizableInterface, public CommonInterface\n{\n\npublic:\n\n    /*!\n     *  The constructor.\n     *\n     *    @param [in] validator               Validator for fields.\n     *    @param [in] expressionParser        Parser for expressions.\n     *    @param [in] expressionFormatter     Formatter for expressions.\n     */\n    ResetInterface(QSharedPointer<FieldValidator> validator,\n        QSharedPointer<ExpressionParser> expressionParser,\n        QSharedPointer<ExpressionFormatter> expressionFormatter);\n\n    /*!\n     *  The destructor.\n     */\n    virtual ~ResetInterface() = default;\n\n    /*!\n     *  Set available resets.\n     *\n     *    @param [in] containingField     Field containing the resets.\n     */\n    void setResets(QSharedPointer<Field> containingField);\n\n    /*!\n     *  Get the names of the available items.\n     *\n     *    @return Names of the available items.\n     */\n    virtual std::vector<std::string> getItemNames() const;\n\n    /*!\n     *  Get the number of available items.\n     *\n     *    @return Number of available items.\n     */\n    virtual int itemCount() const override final;\n    \n    /*!\n     *  Get the reset type reference of the selected reset.\n     *\n     *    @param [in] itemIndex   Index of the selected reset.\n     *\n     *    @return Reset type reference of the selected reset.\n     */\n    std::string getResetTypeReference(int const& itemIndex) const;\n\n    /*!\n     *  Set the reset type reference for the selected reset.\n     *\n     *    @param [in] resetIndex      Index of the selected reset.\n     *    @param [in] newResetType    The new reset type reference.\n     *\n     *    @return True, if successful, false otherwise.\n     */\n    bool setResetTypeReference(int const& resetIndex, std::string const& newResetType);\n\n    /*!\n     *  Get the calculated reset value of the selected reset type.\n     *\n     *    @param [in] resetIndex  Index of the selected reset.\n     *    @param [in] baseNumber  Base for displaying the value.\n     *\n     *    @return Calculated reset value of the selected port.\n     */\n    std::string getResetValue(int const& resetIndex, int const& baseNumber = 0) const;\n\n    /*!\n     *  Get the formatted reset value expression of the selected reset type.\n     *\n     *    @param [in] resetIndex  Index of the selected reset.\n     *\n     *    @return Formatted reset value expression of the selected reset.\n     */\n    std::string getResetValueFormattedExpression(int const& resetIndex) const;\n\n    /*!\n     *  Get the reset value expression of the selected reset type.\n     *\n     *    @param [in] resetIndex  Index of the selected reset.\n     *\n     *    @return Reset value expression of the selected reset.\n     */\n    std::string getResetValueExpression(int const& resetIndex) const;\n\n    /*!\n     *  Set a new reset value for the selected reset type.\n     *\n     *    @param [in] resetIndex      Index of the selected reset.\n     *    @param [in] newResetValue   New reset value.\n     *\n     *    @return True, if successful, false otherwise.\n     */\n    bool setResetValue(int const& resetIndex, std::string const& newResetValue);\n\n    /*!\n     *  Get the calculated reset mask value of the selected reset type.\n     *\n     *    @param [in] resetIndex  Index of the selected reset.\n     *    @param [in] baseNumber  Base for displaying the value.\n     *\n     *    @return Calculated reset mask value of the selected port.\n     */\n    std::string getResetMaskValue(int const& resetIndex, int const& baseNumber = 0) const;\n\n    /*!\n     *  Get the formatted reset mask expression of the selected reset type.\n     *\n     *    @param [in] resetIndex  Index of the selected reset.\n     *\n     *    @return Formatted reset mask expression of the selected reset.\n     */\n    std::string getResetMaskFormattedExpression(int const& resetIndex) const;\n\n    /*!\n     *  Get the reset mask expression of the selected reset type.\n     *\n     *    @param [in] resetIndex  Index of the selected reset.\n     *\n     *    @return Reset mask expression of the selected reset.\n     */\n    std::string getResetMaskExpression(int const& resetIndex) const;\n\n    /*!\n     *  Set a new reset mask for the selected reset type.\n     *\n     *    @param [in] resetIndex      Index of the selected reset.\n     *    @param [in] newResetMask    New reset mask.\n     *\n     *    @return True, if successful, false otherwise.\n     */\n    bool setResetMask(int const& resetIndex, std::string const& newResetMask);\n\n    /*!\n     *  Validates the contained items.\n     *\n     *    @return True, if all the ports are valid, false otherwise.\n     */\n    virtual bool validateItems() const override final;\n\n    /*!\n     *  Check if the reset type reference of the selected reset is valid.\n     *\n     *    @param [in] resetIndex  Index of the selected reset.\n     *\n     *    @return True, if the selected reset type reference is valid, false otherwise.\n     */\n    bool hasValidResetType(int const& resetIndex) const;\n\n    /*!\n     *  Check if the reset value of the selected reset is valid.\n     *\n     *    @param [in] resetIndex  Index of the selected reset.\n     *\n     *    @return True, if the selected reset value is valid, false otherwise.\n     */\n    bool hasValidResetValue(int const& resetIndex) const;\n\n    /*!\n     *  Check if the reset mask of the selected reset is valid.\n     *\n     *    @param [in] resetIndex  Index of the selected reset.\n     *\n     *    @return True, if the selected reset mask is valid, false otherwise.\n     */\n    bool hasValidResetMask(int const& resetIndex) const;\n\n    /*!\n     *  Add a new reset.\n     *\n     *    @param [in] row             Row of the new reset.\n     */\n    void addReset(int const& row);\n\n    /*!\n     *  Remove the selected reset.\n     *\n     *    @param [in] resetName   Name of the selected reset.\n     *\n     *    @return True, if successful, false otherwise.\n     */\n    bool removeReset(int const& resetIndex);\n\n    /*!\n     *  Get all the references made to the selected ID in the selected reset.\n     *\n     *    @param [in] itemName    The reset type reference of the selected reset.\n     *    @param [in] valueID     The selected ID.\n     *\n     *    @return Number of references made to the selected ID in the selected reset.\n     */\n    virtual int getAllReferencesToIdInItem(const std::string& itemName, std::string const&  valueID) const\n        override final;\n\n    /*!\n     *  Get all the references made to the selected ID in the selected reset.\n     *\n     *    @param [in] itemIndex   Index of the selected reset.\n     *    @param [in] valueID     The selected ID.\n     *\n     *    @return Number of references made to the selected ID in the selected reset.\n     */\n    int getAllReferencesToIdInIndex(int const& itemIndex, std::string const& valueID) const;\n\nprivate:\n\n    /*!\n     *  Get the selected reset.\n     *\n     *    @param [in] resetIndex  Index of the selected reset.\n     *\n     *    @return The selected reset.\n     */\n    QSharedPointer<FieldReset> getReset(int const& resetIndex) const;\n\n    //-----------------------------------------------------------------------------\n    // Data.\n    //-----------------------------------------------------------------------------\n\n    //! Field containing the resets.\n    QSharedPointer<Field> containingField_;\n\n    //! List of the contained fields.\n    QSharedPointer<QList<QSharedPointer<FieldReset> > > resets_;\n\n    //! Validator for fields.\n    QSharedPointer<FieldValidator> validator_;\n};\n\n#endif // RESETINTERFACE_H\n"
  },
  {
    "path": "KactusAPI/include/SubspaceMapInterface.h",
    "content": "//-----------------------------------------------------------------------------\n// File: SubspaceMapInterface.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 25.01.2022\n//\n// Description:\n// Interface for editing subspace maps.\n//-----------------------------------------------------------------------------\n\n#ifndef SUBSPACEMAPINTERFACE_H\n#define SUBSPACEMAPINTERFACE_H\n\n#include <KactusAPI/KactusAPIGlobal.h>\n\n#include <KactusAPI/include/MemoryBlockInterface.h>\n\nclass Component;\nclass SubSpaceMap;\nclass AddressSpace;\nclass Segment;\n\nclass BusInterfaceInterface;\nclass ParametersInterface;\nclass SubspaceMapValidator;\n\n//-----------------------------------------------------------------------------\n//! Interface for editing subspace maps.\n//-----------------------------------------------------------------------------\nclass KACTUS2_API SubspaceMapInterface : public MemoryBlockInterface\n{\n\npublic:\n\n    /*!\n     *  The constructor.\n     *\n     *    @param [in] subspaceValidator       Validator for subspace maps.\n     *    @param [in] expressionParser        Parser for expressions.\n     *    @param [in] expressionFormatter     Formatter for expressions.\n     *    @param [in] busInterfaceInterface   Interface for accessing bus interfaces.\n     *    @param [in] parameterInterface      Interface for accessing parameters.\n     */\n    SubspaceMapInterface(QSharedPointer<SubspaceMapValidator> subspaceValidator,\n        QSharedPointer<ExpressionParser> expressionParser,\n        QSharedPointer<ExpressionFormatter> expressionFormatter,\n        BusInterfaceInterface* busInterface,\n        ParametersInterface* parameterInterface);\n\n\t/*!\n     *  The destructor.\n     */\n    virtual ~SubspaceMapInterface() = default;\n\n    /*!\n     *  Check if the selected memory block is accepted.\n     *\n     *    @param [in] blockName   Name of the selected memory block.\n     *\n     *    @return True, if the memory block is accepted, false otherwise.\n     */\n    virtual bool acceptBlock(std::string const& blockName) const final;\n\n    /*!\n     *  Get the master bus interface reference of the selected subspace map.\n     *\n     *    @param [in] itemName    Name of the selected subspace map.\n     *\n     *    @return The master bus interface reference of the selected subspace map.\n     */\n    std::string getInitiatorReference(std::string const& itemName) const;\n\n    /*!\n     *  Set the master bus interface reference of the selected subspace map.\n     *\n     *    @param [in] itemName            Name of the selected subspace map.\n     *    @param [in] newMasterReference  New master bus interface reference for the selected subspace map.\n     *\n     *    @return True, if successful, false otherwise.\n     */\n    bool setMasterReference(std::string const& itemName, std::string const& newMasterReference);\n\n    /*!\n     *  Get the segment reference of the selected subspace map.\n     *\n     *    @param [in] itemName    Name of the selected subspace map.\n     *\n     *    @return Segment reference of the selected subspace map.\n     */\n    std::string getSegmentReference(std::string const& itemName) const;\n\n    /*!\n     *  Set a new segment reference for the selected subspace map.\n     *\n     *    @param [in] itemName                Name of the selected subspace map.\n     *    @param [in] newSegmentReference     The new segment reference.\n     *\n     *    @return True, if successful, false otherwise.\n     */\n    bool setSegmentReference(std::string const& itemName, std::string const& newSegmentReference);\n\n    /*!\n     *  Get the calculated width value of the selected address block.\n     *\n     *    @param [in] blockName   Name of the selected address block.\n     *    @param [in] baseNumber  Base for displaying the value.\n     *\n     *    @return Calculated width value of the selected address block.\n     */\n    std::string getWidthValue(std::string const& subspaceName, int const& baseNumber = 0) const;\n\n    /*!\n     *  Validates the contained items.\n     *\n     *    @return True, if all the ports are valid, false otherwise.\n     */\n    virtual bool validateItems() const final;\n\n    /*!\n     *  Check if the selected subspace map has a valid master bus interface reference.\n     *\n     *    @param [in] itemName    Name of the selected subspace map.\n     *\n     *    @return True, if the master bus interface reference is valid, false otherwise.\n     */\n    bool hasValidMasterReference(std::string const& itemName) const;\n\n    /*!\n     *  Check if the selected subspace map has a valid segment reference.\n     *\n     *    @param [in] itemName    Name of the selected subspace map.\n     *\n     *    @return True, if the segment reference is valid, false otherwise.\n     */\n    bool hasValidSegmentReference(std::string const& itemName) const;\n\n    /*!\n     *  Add a new subspace map.\n     *\n     *    @param [in] row             Row of the new subspace map.\n     *    @param [in] newBlockName    Name of the new subspace map.\n     */\n    virtual void addBlock(int const& row, std::string const& newBlockName = std::string(\"\")) final;\n\n    /*!\n     *  Get the expressions in the selected items.\n     *\n     *    @param [in] itemNames   Names of the selected items.\n     *\n     *    @return The expressions of the selected items.\n     */\n    virtual std::vector<std::string> getExpressionsInSelectedItems(std::vector<std::string> const& itemNames) const final;\n\n    //! No copying. No assignment.\n    SubspaceMapInterface(const SubspaceMapInterface& other) = delete;\n    SubspaceMapInterface& operator=(const SubspaceMapInterface& other) = delete;\n\nprivate:\n\n    /*!\n     *  Get the selected subspace map.\n     *\n     *    @param [in] itemName    Name of the selected subspace map.\n     *\n     *    @return The selected subspace map.\n     */\n    QSharedPointer<SubSpaceMap> getSubspaceMap(std::string const& itemName) const;\n\n    /*!\n     *  Get the subspace map with the selected name, sliced to a NameGroup.\n     *\n     *    @param [in] itemName    Name of the selected subspace map.\n     *\n     *    @return The sliced subspace map with the selected name.\n     */\n    QSharedPointer<NameGroup> getItem(std::string const& itemName) const override;\n\n    /*!\n     *  Get the default name for a subspace map.\n     *\n     *    @return Default name for a subspace map.\n     */\n    virtual std::string getDefaultName() const final;\n\n    /*!\n     *  Get a list of the copied subspace maps.\n     *\n     *    @param [in] selectedRows    Rows of the copied subspace maps.\n     *\n     *    @return List of the copied subspace maps.\n     */\n    virtual QList<QSharedPointer<MemoryBlockBase> > getCopiedBlocks(std::vector<int> const& selectedRows) const final;\n\n    /*!\n     *  Get the mime type of the subspace map.\n     *\n     *    @return The mime type of the subspace map.\n     */\n    virtual QString getMimeType() const final;\n\n    /*!\n     *  Create a copy of the selected subspace map.\n     *\n     *    @param [in] copiedItem  The selected subspace map-\n     *\n     *    @return Copy of the selected subspace map.\n     */\n    virtual QSharedPointer<MemoryBlockBase> createCopyBlock(QSharedPointer<MemoryBlockBase> copiedItem) const\n        final;\n\n    /*!\n     *  Count the subspace map items in the selected list.\n     *\n     *    @param [in] itemList    List of subspace map items.\n     *\n     *    @return Number of subspace map items in the selected list.\n     */\n    virtual int countItems(QList<QSharedPointer<MemoryBlockBase> > itemList) const final;\n\n    /*!\n     *  Get the subspace map validator.\n     *\n     *    @return The subspace map validator.\n     */\n    virtual QSharedPointer<MemoryBlockValidator> getValidator() const final;\n\n    //-----------------------------------------------------------------------------\n    // Data.\n    //-----------------------------------------------------------------------------\n\n    //! The subspace map validator.\n    QSharedPointer<SubspaceMapValidator> validator_;\n};\n\n#endif // SUBSPACEMAPINTERFACE_H\n"
  },
  {
    "path": "KactusAPI/include/SystemVerilogExpressionParser.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: SystemVerilogExpressionParser.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Esko Pekkarinen\r\n// Date: 25.11.2014\r\n//\r\n// Description:\r\n// Parser for SystemVerilog expressions.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef SYSTEMVERILOGEXPRESSIONPARSER_H\r\n#define SYSTEMVERILOGEXPRESSIONPARSER_H\r\n\r\n#include \"ExpressionParser.h\"\r\n\r\n#include \"KactusAPI/KactusAPIGlobal.h\"\r\n\r\n#include <QString>\r\n#include <QMap>\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Parser for SystemVerilog expressions.\r\n//-----------------------------------------------------------------------------\r\nclass KACTUS2_API SystemVerilogExpressionParser : public ExpressionParser\r\n{\r\npublic:\r\n\r\n\t//! The constructor.\r\n\tSystemVerilogExpressionParser() = default;\r\n\r\n\t//! The destructor.\r\n    ~SystemVerilogExpressionParser() override = default;\r\n\r\n    // Disable copying.\r\n    SystemVerilogExpressionParser(SystemVerilogExpressionParser const& rhs) = delete;\r\n    SystemVerilogExpressionParser& operator=(SystemVerilogExpressionParser const& rhs) = delete;\r\n\r\n    /*!\r\n     *  Parses an expression to decimal number.\r\n     *\r\n     *    @param [in]  expression         The expression to parse.\r\n     *    @param [out] validExpression    Set to true, if the parsing was successful, otherwise false.\r\n     *\r\n     *    @return The decimal value of the evaluated expression.\r\n     */\r\n    QString parseExpression(QStringView expression, bool* validExpression = nullptr) const override;\r\n\r\n    /*!\r\n     *  Check if the given expression is an array.\r\n     *\r\n     *    @param [in] expression   The expression to check.\r\n     *\r\n     *    @return True, if the expression is an array, otherwise false.\r\n     */\r\n    virtual bool isArrayExpression(QStringView expression) const noexcept;\r\n\r\n    /*!\r\n     *  Checks if the given expression is a plain value and does not need evaluation.\r\n     *\r\n     *    @param [in] expression   The expression to check.\r\n     *\r\n     *    @return True, if the expression is a plain value, otherwise false.\r\n     */\r\n    bool isPlainValue(QStringView expression) const override;\r\n\r\n    /*!\r\n     *  Finds the common base in the expression.\r\n     *\r\n     *    @param [in] expression   The expression to search in.\r\n     *\r\n     *    @return The common base for the expression.\r\n     */\r\n    int baseForExpression(QStringView expression) const override;\r\n\r\nprotected:\r\n     \r\n    /*!\r\n     *  Parses a token to a decimal number or string.\r\n     *\r\n     *    @param [in] token   The constant to parse.\r\n     *\r\n     *    @return The decimal value of the constant or the given string.\r\n     */\r\n    QString parseConstant(QStringView token) const;\r\n\r\n    /*!\r\n     *  Checks if the given expression is a symbol e.g. reference.\r\n     *\r\n     *    @param [in] expression   The expression to check.\r\n     *\r\n     *    @return True, if the expression is a symbol, otherwise false.\r\n     */\r\n    virtual bool isSymbol(QStringView expression) const;\r\n\r\n    /*!\r\n     *  Finds the value for given symbol.\r\n     *\r\n     *    @param [in] symbol  The symbol whose value to find.\r\n     *\r\n     *    @return The found symbol value.\r\n     */\r\n    virtual QString findSymbolValue(QStringView symbol) const;\r\n\r\n    /*!\r\n     *  Finds the base in the symbol.\r\n     *\r\n     *    @param [in] symbol   The symbol whose base to find.\r\n     *\r\n     *    @return The base for the symbol.\r\n     */\r\n    virtual int getBaseForSymbol(QStringView symbol) const;\r\n\r\n    /*!\r\n    *  Get the operator precedence value for the given operator.\r\n    *\r\n    *    @param [in] oper  The operator whose precedence to get.\r\n    *\r\n    *    @return The precedence value where bigger value has higher precedence.\r\n    */\r\n    static unsigned int operatorPrecedence(QStringView oper);\r\n\r\n    /*!\r\n     *  Checks if the given token is a unary operator.\r\n     *\r\n     *    @param [in] expression   The token to check.\r\n     *\r\n     *    @return True, if the token is a unary operator, otherwise false.\r\n     */\r\n    virtual bool isUnaryOperator(QStringView token) const;\r\n\r\n    /*!\r\n     *  Solves a binary operation.\r\n     *\r\n     *    @param [in] operation    The operation to solve.\r\n     *    @param [in] term         The term for the operation.\r\n     *\r\n     *    @return The result of the operation.\r\n     */\r\n    virtual QString solveUnary(QStringView operation, QString const& term) const;\r\n\r\nprivate:\r\n\r\n    /*!\r\n     *  Converts the given expression to Reverse Polish Notation (RPN) format.\r\n     *  RPN is used to ensure the operations are calculated in the correct precedence order.\r\n     *\r\n     *    @param [in] expression   The expression to convert.\r\n     *\r\n     *    @return The conversion result.\r\n     */\r\n    static QVector<QStringView> convertToRPN(QString& expression);\r\n\r\n    /*!\r\n     *  Solves the given RPN expression.\r\n     *\r\n     *    @param [in]     rpn                The expression to solve.\r\n     *    @param [out]    validExpression    Set to true, if the parsing was successful, otherwise false.\r\n     *\r\n     *    @return The solved result.\r\n     */\r\n    QString solveRPN(QVector<QStringView> rpn, bool* validExpression) const;\r\n\r\n    /*!\r\n     *  Checks if the given expression is a string.\r\n     *\r\n     *    @param [in] expression   The expression to check.\r\n     *\r\n     *    @return True, if the expression is a string, otherwise false.\r\n     */\r\n    bool isStringLiteral(QStringView expression) const noexcept;\r\n\r\n    /*!\r\n     *  Checks if the given expression is a numeric literal.\r\n     *\r\n     *    @param [in] expression   The expression to check.\r\n     *\r\n     *    @return True, if the expression is a literal, otherwise false.\r\n     */\r\n    bool isLiteral(QStringView expression) const;\r\n\r\n    /*!\r\n     *  Checks if the given token is a binary operator.\r\n     *\r\n     *    @param [in] expression   The token to check.\r\n     *\r\n     *    @return True, if the token is a binary operator, otherwise false.\r\n     */\r\n    bool isBinaryOperator(QStringView token) const;\r\n\r\n    /*!\r\n     *  Checks if the given token is a ternary operator.\r\n     *\r\n     *    @param [in] expression   The token to check.\r\n     *\r\n     *    @return True, if the token is a ternary operator, otherwise false.\r\n     */\r\n    bool isTernaryOperator(QStringView token) const;\r\n\r\n    /*!\r\n     *  Solves a Ternary operation.\r\n     *\r\n     *    @param [in] condition   The selecting condition of the ternary operation.\r\n     *    @param [in] trueCase    The value for true condition.\r\n     *    @param [in] falseCase   The value for false condition.\r\n     *\r\n     *    @return The result of the operation.\r\n     */\r\n    QString solveTernary(QStringView condition, QString const& trueCase, QString const& falseCase) const;\r\n\r\n\r\n    /*!\r\n     *  Solves a binary operation.\r\n     *\r\n     *    @param [in] operation   The operation to solve.\r\n     *    @param [in] leftTerm    The first term of the operation.\r\n     *    @param [in] rightTerm   The second term of the operation.\r\n     *\r\n     *    @return The result of the operation.\r\n     */\r\n    QString solveBinary(QStringView operation, QString const& leftTerm, QString const& rightTerm) const;\r\n\r\n    /*!\r\n     *  Solves the SystemVerilog $clog2 function.\r\n     *\r\n     *    @param [in] value   The value for which the function is called.\r\n     *\r\n     *    @return The solved value.\r\n     */\r\n    QString solveClog2(QString const& value) const;\r\n\r\n    /*!\r\n     *  Solves the SystemVerilog $sqrt function.\r\n     *\r\n     *    @param [in] value   The value for which the function is called.\r\n     *\r\n     *    @return The solved value.\r\n     */\r\n    QString solveSqrt(QString const& value) const;\r\n\r\n    /*!\r\n     *  Get the precision used from the term.\r\n     *\r\n     *    @param [in] term   The first term of the operation.\r\n     *\r\n     *    @return The precision of the decimal used in the given term.\r\n     */\r\n    static int precisionOf(QStringView term) noexcept;\r\n\r\n    /*!\r\n     *  Get the base for a given number.\r\n     *\r\n     *    @param [in] constantNumber  The selected number.\r\n     *\r\n     *    @return The base for the selected number. Either 2, 8, 10 or 16.\r\n     */\r\n    static int baseOf(QStringView constantNumber);\r\n};\r\n\r\n#endif // SYSTEMVERILOGEXPRESSIONPARSER_H\r\n"
  },
  {
    "path": "KactusAPI/include/SystemVerilogSyntax.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: SystemVerilogSyntax.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Esko Pekkarinen\r\n// Date: 11.12.2014\r\n//\r\n// Description:\r\n// Common elements of SystemVerilog.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include <QString>\r\n\r\nnamespace SystemVerilogSyntax\r\n{\r\n    const QString SIZE = QStringLiteral(\"[1-9]?[0-9]*\");\r\n    const QString SIGNED = QStringLiteral(\"[sS]?\");\r\n\r\n    const QString BOOLEAN_VALUE = QStringLiteral(\"(?i)true|(?i)false\");\r\n    const QString REAL_NUMBER = QStringLiteral(\"[-+]?[0-9_]+[.][0-9_]+\");\r\n    const QString DECIMAL_NUMBER = QStringLiteral(\"(?:\") + SIZE + QStringLiteral(\"'\") + SIGNED + QStringLiteral(\"[dD]?)?[0-9_]{1,18}\");\r\n    const QString HEXADECIMAL_NUMBER = SIZE + QStringLiteral(\"'\") + SIGNED + QStringLiteral(\"[hH][0-9a-fA-F_]{1,15}\");\r\n    const QString OCTAL_NUMBER = SIZE + QStringLiteral(\"'\") + SIGNED + QStringLiteral(\"[oO][0-7_]{1,20}\");\r\n    const QString BINARY_NUMBER = SIZE + QStringLiteral(\"'\") + SIGNED + QStringLiteral(\"[bB][01_]{1,62}\");\r\n\r\n    const QString INTEGRAL_NUMBER = QStringLiteral(\"[+-]?(?:\") + HEXADECIMAL_NUMBER + QStringLiteral(\"|\") +\r\n        OCTAL_NUMBER + QStringLiteral(\"|\") + BINARY_NUMBER + QStringLiteral(\"|\") + DECIMAL_NUMBER + QStringLiteral(\")\");\r\n\r\n    const QString STRING_LITERAL = QStringLiteral(\"\\\"[^\\\"]*\\\"\");\r\n\r\n    inline const QString MATH_FUNCTION = QStringLiteral(\"[$]pow|[$]clog2|[$]exp|[$]sqrt\");\r\n}\r\n"
  },
  {
    "path": "KactusAPI/include/TagManager.h",
    "content": "//-----------------------------------------------------------------------------\n// File: TagManager.h\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Mikko Teuho\n// Date: 27.08.2019\n//\n// Description:\n// Manager for loaded tags.\n//-----------------------------------------------------------------------------\n\n#ifndef TAGMANAGER_H\n#define TAGMANAGER_H\n\n#include <IPXACTmodels/common/TagData.h>\n\n#include <KactusAPI/KactusAPIGlobal.h>\n\n#include <QVector>\n\n//-----------------------------------------------------------------------------\n//! Manager for loaded tags.\n//-----------------------------------------------------------------------------\nclass KACTUS2_API TagManager\n{\npublic:\n\n    /*!\n     *  The destructor.\n     */\n    ~TagManager() = default;\n\n    /*!\n     *  Add new tags from the selected list.\n     *\n     *    @param [in] newTags     The selected list of new tags.\n     */\n    void addNewTags(QVector<TagData> newTags);\n\n    /*!\n     *  Set new tags.\n     *\n     *    @param [in] newTags     The selected list of new tags.\n     */\n    void setTags(QVector<TagData> newTags);\n\n    /*!\n     *  Get a list of the active tags.\n     *\n     *    @return List of the active tags.\n     */\n    QVector<TagData> getTags() const;\n\n    /*!\n     *  Clear the list of tags.\n     */\n    void clearTags();\n\n    /*!\n     *  Get the singleton instance of the tag manager.\n     *\n     *    @return The tag manager instance.\n     */\n    static TagManager& getInstance();\n\nprivate:\n    // Disable copying.\n    TagManager(TagManager const& rhs);\n    TagManager& operator=(TagManager const& rhs);\n     \n    /*!\n     *  The constructor. Private to enforce the use of getInstance() to get access.\n     */\n    TagManager();\n    \n    /*!\n     *  Check if the selected tag exists in the list.\n     *\n     *    @param [in] tag     The selected tag.\n     *\n     *    @return True, if the selected tag exists in the list, false otherwise.\n     */\n    bool tagExists(TagData const& tag) const;\n\n    //-----------------------------------------------------------------------------\n    // Data.\n    //-----------------------------------------------------------------------------\n    \n    //! The list of loaded tags.\n    QVector<TagData> tags_;\n};\n\n//-----------------------------------------------------------------------------\n\n#endif // TAGMANAGER_H\n"
  },
  {
    "path": "KactusAPI/include/TransparentBridgeInterface.h",
    "content": "//-----------------------------------------------------------------------------\n// File: TransparentBridgeInterface.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 24.02.2021\n//\n// Description:\n// Interface for accessing transparent bridges.\n//-----------------------------------------------------------------------------\n\n#ifndef TRANSPARENTBRIDGEINTERFACE_H\n#define TRANSPARENTBRIDGEINTERFACE_H\n\n#include <ParameterizableInterface.h>\n#include <CommonInterface.h>\n\n#include <QSharedPointer>\n\n#include <KactusAPI/KactusAPIGlobal.h>\n\nclass TransparentBridge;\nclass BusInterfaceValidator;\nclass IndirectInterfaceValidator;\n\n//-----------------------------------------------------------------------------\n//! Interface for accessing transparent bridges.\n//-----------------------------------------------------------------------------\nclass KACTUS2_API TransparentBridgeInterface : public ParameterizableInterface, public CommonInterface\n{\npublic:\n\n    /*!\n     *  The constructor.\n     *\n     *    @param [in] expressionParser            Parser for expressions.\n     *    @param [in] expressionFormatter         Formatter for expressions.\n     */\n    TransparentBridgeInterface(QSharedPointer<ExpressionParser> expressionParser,\n        QSharedPointer<ExpressionFormatter> expressionFormatter);\n\n    /*!\n     *  The destructor.\n     */\n    virtual ~TransparentBridgeInterface() = default;\n\n    /*!\n     *  Setup the transparent bridges.\n     *\n     *    @param [in] newBridges  The new transparent bridges.\n     */\n    void setBridges(QSharedPointer<QList<QSharedPointer<TransparentBridge> > > newBridges);\n\n    /*!\n     *  Get index of the transparent bridge containing the selected master bus interface reference.\n     *\n     *    @param [in] masterReference     The selected master bus interface reference.\n     *\n     *    @return Index of the selected transparent bridge.\n     */\n    int getItemIndex(std::string const& masterReference) const;\n\n    /*!\n     *  Get master bus interface reference of the indexed transparent bridge.\n     *\n     *    @param [in] itemIndex   Index of the selected transparent bridge.\n     *\n     *    @return Master bus interface reference of the selected transparent bridge.\n     */\n    std::string getIndexedMasterReference(int const& itemIndex) const;\n\n    /*!\n     *  Get the number of available transparent bridges.\n     *\n     *    @return Number of available transparent bridges.\n     */\n    virtual int itemCount() const override final;\n\n    /*!\n     *  Get the master bus interface references of the available transparent bridges.\n     *\n     *    @return Master bus interface references of the available ports abstractions.\n     */\n    virtual std::vector<std::string> getItemNames() const override final;\n\n    /*!\n     *  Set a new master bus interface reference for the selected transparent bridge.\n     *\n     *    @param [in] currentMaster   Master bus interface reference of the selected transparent bridge.\n     *    @param [in] newMaster       New master bus interface reference for the selected transparent bridge.\n     *\n     *    @return True, if successful, false otherwise.\n     */\n    bool setMasterReference(std::string const& currentMaster, std::string const& newMaster);\n\n    /*!\n     *  Validates the contained transparent bridges.\n     *\n     *    @return True, if all the transparent bridges are valid, false otherwise.\n     */\n    virtual bool validateItems() const override final;\n\n    /*!\n     *  Get the calculated is present value of the selected transparent bridge.\n     *\n     *    @param [in] masterReference     Master bus interface reference of the selected transparent bridge.\n     *    @param [in] baseNumber          Base for displaying the value.\n     *\n     *    @return Calculated is present value of the selected transparent bridge.\n     */\n    std::string getIsPresentValue(std::string const& masterReference, int const& baseNumber = 0) const;\n\n    /*!\n     *  Get the formatted is present expression of the selected transparent bridge.\n     *\n     *    @param [in] masterReference     Master bus interface reference of the selected transparent bridge.\n     *\n     *    @return Formatted is present expression of the selected transparent bridge.\n     */\n    std::string getIsPresentFormattedExpression(std::string const& masterReference) const;\n\n    /*!\n     *  Get the is present expression of the selected transparent bridge.\n     *\n     *    @param [in] masterReference     Master bus interface reference of the selected transparent bridge.\n     *\n     *    @return Is present expression of the selected transparent bridge.\n     */\n    std::string getIsPresentExpression(std::string const& masterReference) const;\n\n    /*!\n     *  Set the is present expression for the selected transparent bridge.\n     *\n     *    @param [in] masterReference     Master bus interface reference of the selected transparent bridge.\n     *    @param [in] newIsPresent        New is present expression.\n     *\n     *    @return True, if successful, false otherwise.\n     */\n    bool setIsPresent(std::string const& masterReference, std::string const& newIsPresent);\n    \n    /*!\n     *  Add a new transparent bridge.\n     *\n     *    @param [in] bridgeIndex     Index of the new transparent bridge.\n     *    @param [in] bridgeName      Master bus interface reference of the new transparent bridge.\n     *\n     *    @return True, if successful, false otherwise.\n     */\n    bool addBridge(int const& bridgeIndex, std::string const& bridgeName = \"\") const;\n\n    /*!\n     *  Remove the selected transparent bridge.\n     *\n     *    @param [in] masterReference     Master bus interface reference of the selected transparent bridge.\n     *\n     *    @return True, if successful, false otherwise.\n     */\n    bool removeTransparentBridge(std::string const& masterReference);\n\n    /*!\n     *  Get all the references made to the selected ID in the selected transparent bridge.\n     *\n     *    @param [in] itemName    Master bus interface reference of the selected transparent bridge.\n     *    @param [in] valueID     The selected ID.\n     *\n     *    @return Number of references made to the selected ID.\n     */\n    virtual int getAllReferencesToIdInItem(const std::string& itemName, std::string const&  valueID) const;\n\n    /*!\n     *  Get all the expressions from the selected transparent bridge.\n     *\n     *    @param [in] masterReference     Master reference of the selected transparent bridge.\n     *\n     *    @return List of expressions in the selected transparent bridge.\n     */\n    std::vector<std::string> getAllExpressions(std::string const& masterReference) const;\n\n    //! No copying. No assignment.\n    TransparentBridgeInterface(const TransparentBridgeInterface& other) = delete;\n    TransparentBridgeInterface& operator=(const TransparentBridgeInterface& other) = delete;\n\nprivate:\n\n    /*!\n     *  Get the selected transparent bridge.\n     *\n     *    @param [in] masterReference     Master bus interface reference of the selected transparent bridge.\n     *\n     *    @return The selected transparent bridge.\n     */\n    QSharedPointer<TransparentBridge> getTransparentBridge(std::string const& masterReference) const;\n\n    //-----------------------------------------------------------------------------\n    // Data.\n    //-----------------------------------------------------------------------------\n\n    //! List of available transparent bridges.\n    QSharedPointer<QList<QSharedPointer<TransparentBridge> > > bridges_;\n\n    //! Validator for bus interfaces.\n    QSharedPointer<BusInterfaceValidator> busValidator_;\n\n    //! Validator for indirect interfaces.\n    QSharedPointer<IndirectInterfaceValidator> indirectValidator_;\n};\n\n#endif // TRANSPARENTBRIDGEINTERFACE_H\n"
  },
  {
    "path": "KactusAPI/include/VersionHelper.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: VersionHelper.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Janne Virtanen\r\n// Date: 31.8.2016\r\n//\r\n// Description:\r\n// A module that returns variations version number.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef VERSIONHELPER_H\r\n#define VERSIONHELPER_H\r\n\r\n#include <KactusAPI/KactusAPIGlobal.h>\r\n\r\n#include \"QString\"\r\n\r\nnamespace VersionHelper\r\n{\r\n    /*!\r\n     *  Returns a formatted full version info including the bit information of the build.\r\n     */\r\n    KACTUS2_API QString createVersionString();\r\n\r\n    /*!\r\n     *  Returns full version info, separated by dots.\r\n     */\r\n    KACTUS2_API QString versionFull();\r\n\r\n    /*!\r\n    *  Returns full version info, separated by commas.\r\n     */\r\n    KACTUS2_API QString versionFileStr();\r\n}\r\n\r\n#endif // VERSIONHELPER_H"
  },
  {
    "path": "KactusAPI/include/config.json",
    "content": "{\n  \"intercon\": \"test:gen:intercon:1.0\",\n  \"top\": \"tuni.fi:subsystem:SysCtrl_SS:1.0\",\n  \"bus\": \"tuni.fi:interface:AXI4LITE:1.0\",\n  \"clk\": \"tuni.fi:interface:clock:1.0\",\n  \"rst\": \"tuni.fi:interface:reset:1.0\",\n  \"filesetToGenerate\": \"example_fileset\",\n  \"busType\": \"AXI4LITE\",\n  \"addressWidth\": \"32\",\n  \"dataWidth\": \"32\",\n  \"idWidth\": 8,\n  \"userWidth\": 1,\n  \"initiators\": [\n  \t{\"index\": 0,\n  \t\"name\": \"i_SysCtrl_peripherals\"},\n  \t{\"index\": 1,\n  \t\"name\": \"initComp2\"}],\n  \"targets\":[\n\t{\"index\": 0,\n\t\"name\": \"core_imem_bridge\",\n\t\"addressRegions\":[\n\t\t{\"start\": \"0x00000000\",\n\t\t\"end\": \"0x0000ffff\"},\n\t\t{\"start\": \"0x00010000\",\n\t\t\"end\": \"0x0001ffff\"}]},\n\t{\"index\": 1,\n\t\"name\": \"jtag_dbg_wrapper\",\n\t\"addressRegions\":[\n\t\t{\"start\": \"0x00020000\",\n\t\t\"end\": \"0x0002ffff\"}]}\n\t]\n}\n"
  },
  {
    "path": "KactusAPI/include/hierarchyitem.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: hierarchyitem.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Antti Kamppi\r\n// Date: 01.07.2011\r\n//\r\n// Description:\r\n// Represents a single component in the library in hierarchy view.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef HIERARCHYITEM_H\r\n#define HIERARCHYITEM_H\r\n\r\n#include <IPXACTmodels/Catalog/Catalog.h>\r\n#include <IPXACTmodels/Component/Component.h>\r\n\r\n#include <IPXACTmodels/BusDefinition/BusDefinition.h>\r\n#include <IPXACTmodels/AbstractionDefinition/AbstractionDefinition.h>\r\n#include <IPXACTmodels/kactusExtensions/ApiDefinition.h>\r\n#include <IPXACTmodels/kactusExtensions/ComDefinition.h>\r\n#include <IPXACTmodels/Design/Design.h>\r\n\r\n#include <IPXACTmodels/kactusExtensions/KactusAttribute.h>\r\n\r\n#include <KactusAPI/KactusAPIGlobal.h>\r\n\r\n#include <QObject>\r\n#include <QSharedPointer>\r\n#include <QList>\r\n#include <QMap>\r\n\r\nclass LibraryInterface;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Represents a single component in the library in hierarchy view.\r\n//-----------------------------------------------------------------------------\r\nclass KACTUS2_API HierarchyItem : public QObject\r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\r\n\t//! Defines the type of the hierarchy item.\r\n\tenum ObjectType\r\n    {\r\n\t\tROOT = 0,\r\n\t\tCOMPONENT,\r\n\t\tBUSDEFINITION,\r\n\t\tABSDEFINITION,\r\n        COMDEFINITION,\r\n        APIDEFINITION,\r\n\t\tHW_DESIGN,\r\n\t\tSW_DESIGN,\r\n\t\tSYS_DESIGN,\r\n        CATALOG\r\n\t};\r\n\r\n\t/*! The constructor\r\n\t *\r\n\t *    @param [in] handler         The instance that manages the library.\r\n\t *    @param [in] parent          The owner of this object.\r\n\t *    @param [in] vlnv            The vlnv to construct the item for.\r\n\t *    @param [in] implementation  The implementation attribute needed by designs.\r\n\t *    @param [in] viewName        The name of the view the design belongs to.\r\n\t */\r\n\tHierarchyItem(LibraryInterface* handler, HierarchyItem* parent, VLNV const& vlnv,\r\n\t\tKactusAttribute::Implementation implementation = KactusAttribute::KTS_IMPLEMENTATION_COUNT,\r\n\t\tQString const& viewName = QString());\r\n\r\n\t/*! The constructor for the root item.\r\n\t * \r\n\t * This constructor should only be used to create the root item and no other hierarchy items.\r\n\t * \r\n\t *    @param [in] handler The instance that manages the library.\r\n\t *    @param [in] parent The owner of this item.\r\n\t */\r\n\tHierarchyItem(LibraryInterface* handler, QObject* parent);\r\n\r\n    //! The destructor\r\n    virtual ~HierarchyItem() = default;\r\n\r\n\t/*! Create a child for the HierarchyItem that represents the given VLNV.\r\n\t * \r\n\t * This function should only be called for the root item to create the tree.\r\n\t * \r\n\t *    @param [in] vlnv Identifies the component to represent.\r\n\t */\r\n\tvoid createChild(const VLNV& vlnv);\r\n\r\n\r\n\t/*! Get the parent of this item.\r\n\t *\r\n\t *    @return The parent of this item\r\n\t*/\r\n\tHierarchyItem* parent() const;\r\n\r\n\t/*! Get the vlnv of this item.\r\n\t *\r\n\t *    @return VLNV of the component this item represents.\r\n\t*/\r\n\tVLNV const& getVLNV() const;\r\n\r\n\t/*! Get pointer to the child item with given index.\r\n\t * \r\n\t * If child with given index does not exist then return null pointer.\r\n\t * \r\n\t *    @param [in] index Row number of the child that's pointer is wanted.\r\n\t *\r\n\t *    @return HierarchyItem*\r\n\t*/\r\n\tHierarchyItem* child(int index) const;\r\n\r\n\t/*!  Get the row number of this item on this item's parent.\r\n\t *\r\n\t *    @return The row number.\r\n\t*/\r\n\tint row();\r\n\r\n\t/*! Get the number of children this item has.\r\n\t *\r\n\t *    @return The number of child items this item has.\r\n\t*/\r\n\tint getNumberOfChildren() const;\r\n\r\n\t/*! Get the index of specified item.\r\n\t *\r\n\t *    @param [in] item The HierarchyItem that's row number is requested.\r\n\t *\r\n\t *    @return The row number of given item. Returns -1 if item is not found.\r\n\t*/\r\n\tint getIndexOf(HierarchyItem* item);\r\n\r\n\t/*! Check if this item has children or not.\r\n\t *\r\n\t *    @return True if at least one child item exists.\r\n\t*/\r\n\tbool hasChildren() const;\r\n\r\n\t/*! Check if this item is valid or not.\r\n\t *\r\n\t *    @return True if item is valid.\r\n\t*/\r\n\tbool isValid() const;\r\n\r\n\t/*! Set the validity of this item.\r\n\t *\r\n\t *    @param [in] valid Sets the valid value of the item.\r\n\t *\r\n\t*/\r\n\tvoid setValidity(bool valid);\r\n\r\n\t/*! Checks if the component or one of it's sub-components contains the vlnv.\r\n\t *\r\n\t *    @param [in] vlnv The vlnv that is searched in hierarchy.\r\n\t *\r\n\t *    @return bool True if the vlnv is found.\r\n\t*/\r\n\tbool contains(const VLNV& vlnv) const;\r\n\r\n\t/*! Removes the child items that are contained in one or several other components.\r\n\t * \r\n\t * Note: This function should be called only for the root item.\r\n\t *\r\n\t *    @return void\r\n\t*/\r\n\tvoid cleanUp();\r\n\t\r\n\t/*! Get pointer to the component that this item represents\r\n\t *\r\n\t *    @return QSharedPointer<Component> The component model.\r\n\t*/\r\n\tQSharedPointer<Component const> component() const;\r\n\r\n\t/*! Count how many instances of given vlnv is found under this item.\r\n\t *\r\n\t * This function does not check if the same owner is counted multiple times\r\n\t * if same sub-component is instantiated in several components. If count that \r\n\t * contains only unique owners then you should use getOwners().\r\n\t * \r\n\t *    @param [in] vlnv Identifies the component that's instances are searched.\r\n\t *\r\n\t *    @return Number of found instances.\r\n\t*/\r\n\tint referenceCount(const VLNV& vlnv) const;\r\n\r\n\t/*! Get list of objects that have instantiated the given vlnv.\r\n\t *\r\n\t * This function makes sure each owner is appended to the list only once.\r\n\t *\r\n\t *    @param [out] list QList where owner vlnvs is appended.\r\n\t *    @param [in] vlnvToSearch The vlnv to that's parents are wanted.\r\n\t * \r\n\t *    @return Number of unique owners found.\r\n\t*/\r\n\tint getOwners(QList<VLNV>& list, const VLNV& vlnvToSearch) const;\r\n\r\n\t/*! Remove the child items with given vlnv.\r\n\t *\r\n\t *    @param [in] vlnv Identifies the items to remove.\r\n\t * \r\n\t *    @return Amount of child items removed from this item.\r\n\t*/\r\n\tint removeItems(const VLNV& vlnv);\r\n\r\n\t/*! Find the hierarchyItems that represent the given vlnv.\r\n\t *\r\n\t *    @param [in] vlnv Identifies the items.\r\n\t *\r\n\t *    @return QList<HierarchyItem*> contains pointers to the hierarchy items.\r\n\t*/\r\n\tQVector<HierarchyItem*> findItems(const VLNV& vlnv);\r\n\r\n\t/*! Update hierarchy items with given vlnv.\r\n\t *\r\n\t *    @param [in] vlnv Identifies the objects to update.\r\n\t *\r\n\t*/\r\n\tvoid updateItems(const VLNV& vlnv);\r\n\r\n\t/*! Checks if the item has parent on some hierarchy-level with given vlnv.\r\n\t * \r\n\t * Function does not just search the direct parent but the whole parent-chain\r\n\t * up to the root item.\r\n\t * \r\n\t *    @param [in] vlnv Identifies the parent to search.\r\n\t *\r\n\t *    @return bool True if parent with given vlnv is found.\r\n\t*/\r\n\tbool hasParent(const VLNV& vlnv);\r\n\r\n\t/*! Check if the parent of this item is the root item.\r\n\t *\r\n\t *    @return bool true if the parent item is root item. If this is the root or \r\n\t * parent is normal item then returns false.\r\n\t*/\r\n\tbool parentIsRoot() const;\r\n\r\n\t/*! Check if this is the root item or not.\r\n\t *\r\n\t *    @return bool True if this is the root item.\r\n\t*/\r\n\tbool isRoot() const;\r\n\r\n\t/*! Check if this item is instantiated in some item or not.\r\n\t *\r\n\t *    @return bool true if item is contained as some item's child.\r\n\t*/\r\n\tbool isDuplicate() const;\r\n\r\n\t/*! Set the duplicate value for this item.\r\n\t *\r\n\t *    @param [in] isDuplicate If true then this item is set as duplicate.\r\n\t *\r\n\t*/\r\n\tvoid setDuplicate(bool isDuplicate);\r\n\r\n\t/*! Get the list of vlnvs this item and it's parents contain.\r\n\t *\r\n\t *    @return QList<VLNV> contains the list of vlnvs\r\n\t*/\r\n\tQVector<VLNV> getVLNVs() const;\r\n\r\n\t/*! Remove all children from item.\r\n\t *\r\n\t*/\r\n\tvoid clear();\r\n\r\n\t/*! Checks if the component this item represents is hierarchical or not.\r\n\t *\r\n\t *    @return bool true if the component is hierarchical.\r\n\t*/\r\n\tbool isHierarchical() const;\r\n\r\n\t/*! Get the implementation of this item.\r\n\t * \r\n\t * Note: This function can only be called for items of type component.\r\n\t *\r\n\t *    @return KactusAttribute::Implementation Specifies the implementation.\r\n\t*/\r\n\tKactusAttribute::Implementation getImplementation() const;\r\n\r\n\t/*! Get the type of this hierarchy item.\r\n\t *\r\n\t *    @return ObjectType defines the type of the item.\r\n\t*/\r\n\tObjectType type() const;\r\n\r\n\t/*! Get the child items of given object.\r\n\t * \r\n\t * This function must only be called to the root item.\r\n\t * \r\n\t *    @param [in] childList The list where the vlnvs of the children are appended.\r\n\t *    @param [in] owner Identifies the object that's children are searched.\r\n\t *\r\n\t*/\r\n\tvoid getChildren(QList<VLNV>& childList, const VLNV& owner) const;\r\n\r\n\t/*! Get the vlnvs of the items that are this item's children.\r\n\t *\r\n\t *    @param [in] itemList The list where the vlnvs are appended to.\r\n\t *\r\n\t*/\r\n\tvoid getChildItems(QList<VLNV>& itemList) const;\r\n\r\n\t/*! Count how many times this component has been instantiated in a containing design.\r\n\t * \r\n\t * For items that are not components this function returns -1\r\n\t *\r\n\t *    @return The instance count in the containing design.\r\n\t*/\r\n\tint instanceCount() const;\r\n\r\n\t/*! Get the name of the view the design belongs to.\r\n\t * \r\n\t * If type() is other than design an empty string is returned.\r\n\t *\r\n\t *    @return QString containing the view name.\r\n\t*/\r\n\tQString getViewName() const;\r\n\r\nsignals:\r\n\r\n\t//! Send a notification to be printed to user.\r\n\tvoid noticeMessage(QString const& msg);\r\n\r\n\t//! Send an error message to be printed to user.\r\n\tvoid errorMessage(QString const& msg);\r\n\r\nprotected:\r\n\r\n\t/*! Count the number of instances for the given vlnv.\r\n\t *\r\n\t *    @param [in] componentVLNV The vlnv of the component that's instance count is counted.\r\n\t *\r\n\t *    @return The number of instantiation times.\r\n\t*/\r\n\tint countInstances(const VLNV& componentVLNV);\r\n\r\nprivate:\r\n\t//! No copying\r\n\tHierarchyItem(const HierarchyItem& other);\r\n\r\n\t//! No assignment\r\n\tHierarchyItem& operator=(const HierarchyItem& other);\r\n\r\n\t/*! Checks if this HierarchyItem already has child for given vlnv.\r\n\t *\r\n\t *    @param [in] vlnv Identifies the child.\r\n\t *\r\n\t *    @return bool True if child with given vlnv is found.\r\n\t*/\r\n\tbool hasChild(const VLNV& vlnv);\r\n\r\n\t/*! Parse this hierarchy item to match a component\r\n\t *\r\n\t *    @param [in] vlnv The vlnv of the component.\r\n\t *\r\n\t*/\r\n\tvoid parseComponent(const VLNV& vlnv);\r\n\r\n    void parseCatalog(VLNV const& vlnv);\r\n\r\n    /*!\r\n     *  Finds the referenced design in a component view.\r\n     *\r\n     *    @param [in] view   The view whose reference to find.\r\n     *\r\n     *    @return The design referenced in the view.\r\n     */\r\n    VLNV findDesignReference(QSharedPointer<View> view);\r\n\r\n    /*!\r\n     *  Creates a child item for the given design.\r\n     *\r\n     *    @param [in] designVLNV          The design to represent with the child.\r\n     *    @param [in] implementation      The implementation type of the design.\r\n     *    @param [in] viewName            The name of the view referencing the design.\r\n     */\r\n    void createChildItemForDesign(VLNV const& designVLNV,\r\n        QString const& viewName);\r\n\r\n\t/*! Parse this hierarchy item to match a bus definition.\r\n\t *\r\n\t *    @param [in] vlnv The vlnv of the bus definition.\r\n\t *\r\n\t*/\r\n\tvoid parseBusDefinition(const VLNV& vlnv);\r\n\r\n\t/*! Parse this hierarchy item to match an abstraction definition.\r\n\t *\r\n\t *    @param [in] vlnv The vlnv of the abstraction definition.\r\n\t *\r\n\t*/\r\n\tvoid parseAbsDefinition(const VLNV& vlnv);\r\n\r\n    /*! Parse this hierarchy item to match a COM definition.\r\n\t *\r\n\t *    @param [in] vlnv The vlnv of the COM definition.\r\n\t *\r\n\t*/\r\n\tvoid parseComDefinition(const VLNV& vlnv);\r\n\r\n    /*! Parse this hierarchy item to match an API definition.\r\n\t *\r\n\t *    @param [in] vlnv The vlnv of the API definition.\r\n\t *\r\n\t*/\r\n\tvoid parseApiDefinition(const VLNV& vlnv);\r\n\r\n\t/*! Parse this hierarchy item to match a design.\r\n\t *\r\n\t *    @param [in] vlnv The vlnv of the design.\r\n\t*/\r\n\tvoid parseDesign(const VLNV& vlnv, KactusAttribute::Implementation implementation, QString const& viewName);\r\n\r\n    /*!\r\n     *  Finds the valid component references in a design item.\r\n     *\r\n     *    @return The valid VLVN references.\r\n     */\r\n    QVector<VLNV> getValidComponentsInDesign(QSharedPointer<Design const> design);\r\n\r\n    /*!\r\n     *  Checks if the given VLNV reference to a component is valid.\r\n     *\r\n     *    @param [in] componentVLNV   The VLNV to check.\r\n     *\r\n     *    @return True, if the VLVN reference is valid, otherwise false.\r\n     */\r\n    bool isValidComponentInstanceVLNV(VLNV const& componentVLNV);\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! The VLNV this item represents.\r\n    VLNV vlnv_;\r\n\r\n\t//! The component that this hierarhcyItem represents.\r\n\tQSharedPointer<Component const> component_;\r\n\r\n\t//! The object that manages the library.\r\n\tLibraryInterface* library_;\r\n\r\n\t//! List of children of this item.\r\n\tQVector<HierarchyItem*> childItems_;\r\n\r\n\t//! The parent of this item.\r\n\tHierarchyItem* parentItem_;\r\n\r\n\t//! Specifies the validity of this item.\r\n\tbool isValid_;\r\n\r\n\t//! Contains info that tell is this item is contained in some item as child.\r\n\tbool isDuplicate_;\r\n\r\n\t//! Defines the type of this hierarchy item.\r\n\tObjectType type_;\r\n\r\n\t//! Contains the instance count for the sub items.\r\n\tQMap<VLNV, int> instanceCount_;\r\n\r\n\t//! The name of the view a design belongs to.\r\n\tQString viewName_;\r\n};\r\n\r\n#endif // HIERARCHYITEM_H\r\n"
  },
  {
    "path": "KactusAPI/include/hierarchymodel.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: hierarchymodel.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 01.07.2011\r\n//\r\n// Description:\r\n// Contains the items to display the library component hierarchy to user.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef HIERARCHYMODEL_H\r\n#define HIERARCHYMODEL_H\r\n\r\n#include \"hierarchyitem.h\"\r\n\r\n#include <KactusAPI/KactusAPIGlobal.h>\r\n\r\n#include <QAbstractItemModel>\r\n#include <QSharedPointer>\r\n\r\nclass LibraryInterface;\r\nclass LibraryData;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Contains the items to display the library component hierarchy to user.\r\n//-----------------------------------------------------------------------------\r\nclass KACTUS2_API HierarchyModel : public QAbstractItemModel\r\n{\r\n    Q_OBJECT\r\n\r\npublic:\r\n\r\n    //! Defines the columns for the model.\r\n    enum Column\r\n    {\r\n    \tOBJECT_COLUMN = 0,\r\n    \tINSTANCE_COLUMN,\r\n    \tCOLUMN_COUNT\r\n    };\r\n\r\n    /*! The constructor\r\n     * \r\n     *    @param [in] handler         The instance that manages the library.\r\n     *    @param [in] parent          The owner of this model.\r\n     */\r\n    HierarchyModel(LibraryInterface* handler, QObject* parent);\r\n    \r\n    //! The destructor\r\n    virtual ~HierarchyModel() = default;\r\n\r\n    /*! Get the data for the headers of this model.\r\n     *\r\n     *    @param [in] section         Specifies the column of the header.\r\n     *    @param [in] orientation     The orientation of the header, only Qt::Horizontal supported.\r\n     *    @param [in] role            Specifies the role of the data.\r\n     *\r\n     *    @return QVariant containing the data.\r\n    */\r\n    virtual QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;\r\n\r\n    /*! Get the number of columns in this model\r\n     *\r\n     *    @param [in] parent Model index identifying the item that's column count is \r\n     * wanted.\r\n     *\r\n     *    @return Number of columns.\r\n    */\r\n    virtual int columnCount(QModelIndex const& parent = QModelIndex()) const;\r\n\r\n    /*! Get the number of rows an item has.\r\n     *\r\n     *    @param [in] parent Model index identifying the item that's row count is wanted\r\n     *\r\n     *    @return Number of rows the item has.\r\n    */\r\n    virtual int rowCount(QModelIndex const& parent = QModelIndex()) const;\r\n\r\n    /*! Get the model index of the specified object.\r\n     *\r\n     *    @param [in] row         Row number of the object.\r\n     *    @param [in] column      Column number of the object.\r\n     *    @param [in] parent      Model index of the parent of the object.\r\n     *\r\n     *    @return QModelIndex that identifies the object.\r\n    */\r\n    virtual QModelIndex index(int row, int column, QModelIndex const& parent = QModelIndex()) const;\r\n\r\n    /*! Get the model index of the parent of the object\r\n     *\r\n     *    @param [in] child Model index that identifies the child of the object.\r\n     *\r\n     *    @return QModelIndex that identifies the parent of the given object.\r\n    */\r\n    virtual QModelIndex parent(QModelIndex const& child) const;\r\n\r\n    /*! Get the data associated with given object.\r\n     *\r\n     *    @param [in] index Model index that identifies the object that's data is wanted.\r\n     *    @param [in] role Specifies the type of data wanted.\r\n     *\r\n     *    @return QVariant Containing the requested data.\r\n    */\r\n    virtual QVariant data(QModelIndex const& index, int role = Qt::DisplayRole) const;\r\n\r\n    /*! Does the specified item have child items or not.\r\n     *\r\n     *    @param [in] parent Model index identifying the object that's children are asked.\r\n     *\r\n     *    @return True if object has child objects.\r\n    */\r\n    virtual bool hasChildren(QModelIndex const& parent = QModelIndex()) const;\r\n\r\n    /*! Get the flags that identify possible methods for given object.\r\n     *\r\n     *    @param [in] index Model index identifying the object that's flags are requested.\r\n     *\r\n     *    @return Qt::ItemFlags that specify how the object can be handled.\r\n    */\r\n    Qt::ItemFlags flags(QModelIndex const& index) const;\r\n\r\n    /*! Create a model index for a library item\r\n     *\r\n     *    @param [in] item The LibraryItem that's model index is wanted\r\n     *\r\n     *    @return QModelIndex that identifies the libraryItem.\r\n    */\r\n    QModelIndex index(HierarchyItem* item) const;\r\n\r\n    /*! Count how many times the given component is instantiated in the library.\r\n     * \r\n     * This function does not check if the same owner is counted multiple times\r\n     * if same sub-component is instantiated in several components. If count that \r\n     * contains only unique owners then you should use getOwners().\r\n     * \r\n     *    @param [in] vlnv Identifies the component that's instances are searched.\r\n     *\r\n     *    @return Number of found instances.\r\n     */\r\n    int referenceCount(VLNV const& vlnv) const;\r\n\r\n    /*! Get the components that have instantiated the given vlnv in their design.\r\n     * \r\n     * This function makes sure each owner is appended to the list only once.\r\n     *\r\n     *    @param [out] list           QList where the search results are appended.\r\n     *    @param [in] vlnvToSearch    Identifies the component to search for.\r\n     * \r\n     *    @return Number of owners found.\r\n     *\r\n    */\r\n    virtual int getOwners(QList<VLNV>& list, VLNV const& vlnvToSearch) const;\r\n\r\n    /*! Find model indexes of items that represent given vlnv.\r\n     *\r\n     *    @param [in] vlnv Identifies the objects to search for.\r\n     *\r\n     *    @return QModelIndexList contains indexes of items with given vlnv.\r\n    */\r\n    QModelIndexList findIndexes(VLNV const& vlnv);\r\n\r\n    /*! Get the child items of given object.\r\n     *\r\n     *    @param [out] childList  The list where the vlnvs of the children are appended.\r\n     *    @param [in] owner       Identifies the object that's children are searched.\r\n     *\r\n    */\r\n    void getChildren(QList<VLNV>& childList, VLNV const& owner) const;\r\n\r\npublic slots:\r\n\r\n    //! Reset the model\r\n    void onResetModel();\r\n\r\n    //! Open the selected hierarchical design\r\n    void onOpenDesign(QModelIndex const& index);\r\n\r\n    //! Open the memory design of the selected design.\r\n    void onOpenMemoryDesign(QModelIndex const& index);\r\n\r\n   //! Open the selected component.\r\n    void onOpenItem(QModelIndex const& index);\r\n\r\n    //! Create new design\r\n    void onCreateNewDesign(QModelIndex const& index);\r\n\r\n    //! Create new SW design\r\n    void onCreateNewSWDesign(QModelIndex const& index);\r\n\r\n    //! Create new system design\r\n    void onCreateNewSystemDesign(QModelIndex const& index);\r\n\r\n    //! Create new abstraction definition\r\n    void onCreateNewAbsDef(QModelIndex const& index);\r\n\r\n    //! When export is selected in search view\r\n    void onExportItem(QModelIndex const& index);\r\n\r\n    //! When delete is selected.\r\n    void onDeleteItem(QModelIndex const& index);\r\n\r\n    //! Shows errors about the item at the given index.\r\n    void onShowErrors(QModelIndex const& index);\r\n\r\n    //! Remove the specified vlnv from the tree.\r\n    void onRemoveVLNV(VLNV const& vlnv);\r\n    \r\n    /*! This function should be called when an IP-XACT document has changed.\r\n     * \r\n     * Function updates the hierarchical model so that changes made to the document are visible.\r\n     * \r\n     *    @param [in] vlnv Identifies the document that changed.\r\n    */\r\n    void onDocumentUpdated(VLNV const& vlnv);\r\n\r\nsignals:\r\n\r\n    //! Send an error message to be printed to user.\r\n    void errorMessage(const QString& msg);\r\n\r\n    //! Send a notification to be printed to user.\r\n    void noticeMessage(const QString& msg);\r\n\r\n    //! Open the design of a component.\r\n    void openDesign(VLNV const& vlnv, const QString& viewName);\r\n\r\n    //! Open the memory design of a component.\r\n    void openMemoryDesign(VLNV const& vlnv, const QString& viewName);\r\n\r\n    //! Open the SW design of a component.\r\n    void openSWDesign(VLNV const& vlnv, const QString& viewName);\r\n\r\n    //! Open the system design of a component.\r\n    void openSystemDesign(VLNV const& vlnv, const QString& viewName);\r\n\r\n    //! Open the component in a component editor.\r\n    void editItem(VLNV const& vlnv);\r\n\r\n    //! Create a new abstraction definition for given bus definition.\r\n    void createAbsDef(VLNV const& busDefVLNV);\r\n\r\n    //! Create new design with given vlnv.\r\n    void createDesign(VLNV const& vlnv);\r\n\r\n    //! Create new SW design with given vlnv.\r\n    void createSWDesign(VLNV const& vlnv);\r\n\r\n    //! Create new system design with given vlnv.\r\n    void createSystemDesign(VLNV const& vlnv);\r\n\r\n    //! Export an item to a new location.\r\n    void exportItem(VLNV const& vlnv);\r\n\r\n    //! Remove the specified VLNV from the library\r\n    void removeVLNV(QList<VLNV> vlnv);\r\n\r\n    //! Shows errors about the item at the given index.\r\n    void showErrors(VLNV const& vlnv);\r\n\r\n    //! Refresh the item filtering because changes have been made\r\n    void invalidateFilter();\r\n\r\nprivate:\r\n    //! No copying\r\n    HierarchyModel(const HierarchyModel& other);\r\n\r\n    //! No assignment\r\n    HierarchyModel& operator=(const HierarchyModel& other);\r\n\r\n    //! The root item of the model\r\n    HierarchyItem* rootItem_;\r\n\r\n    //! The instance that manages the library.\r\n    LibraryInterface* handler_;\r\n};\r\n\r\n#endif // HIERARCHYMODEL_H\r\n"
  },
  {
    "path": "KactusAPI/include/utils.h",
    "content": "/* \r\n *\r\n *  Created on: 7.2.2011\r\n *      Author: Antti Kamppi\r\n *         filename: utils.h\r\n *         \r\n *         Description: This file contains declarations for general purpose \r\n *         functions that can be used in the whole software.\r\n */\r\n\r\n#ifndef UTILS_H\r\n#define UTILS_H\r\n\r\n#include <KactusAPI/KactusAPIGlobal.h>\r\n\r\n#include <QObject>\r\n#include <QRegularExpression>\r\n\r\nnamespace Utils\r\n{\r\n    //! Contains firmness search settings.\r\n    struct ImplementationOptions\r\n    {\r\n        //! If true then hardware components should be included in search.\r\n        bool hw_{ true };\r\n\r\n        //! If true then software components should be included in search.\r\n        bool sw_{ true };\r\n\r\n        //! If true then system components should be included in search.\r\n        bool system_{ true };\r\n\r\n        /*! The default constructor\r\n         *\r\n         * Constructs struct with all options set to true.\r\n        */\r\n        KACTUS2_API ImplementationOptions() = default;\r\n    };\r\n\r\n    //! Contains the search settings for hierarchy.\r\n    struct HierarchyOptions\r\n    {\r\n        //! If true then global objects should be included in search.\r\n        bool flat_{ true };\r\n\r\n        //! If true then product objects should be included in search.\r\n        bool product_{ true };\r\n\r\n        //! If true then board objects should be included in search.\r\n        bool board_{ true };\r\n\r\n        //! If true then chip objects should be included in search.\r\n        bool chip_{ true };\r\n\r\n        //! If true then soc objects should be included in search.\r\n        bool soc_{ true };\r\n\r\n        //! If true then ip objects should be included in search.\r\n        bool ip_{ true };\r\n\r\n        /*! The default constructor.\r\n         *\r\n         * Constructs struct with all options set to true.\r\n        */\r\n        KACTUS2_API HierarchyOptions() = default;\r\n    };\r\n\r\n    //! Contains the Re-usability search filters.\r\n    struct FirmnessOptions\r\n    {\r\n        //! If true then templates should be included in search.\r\n        bool templates_{ true };\r\n\r\n        //! If true then mutables should be included in search.\r\n        bool mutable_{ true };\r\n\r\n        //! If true then fixeds should be included in search.\r\n        bool fixed_{ true };\r\n\r\n        /*! The default constructor\r\n         *\r\n         * Constructs struct with all options set to true\r\n        */\r\n        KACTUS2_API FirmnessOptions() = default;\r\n    };\r\n\r\n    //! Contains the search options for document types.\r\n    struct TypeOptions\r\n    {\r\n        //! If true then components should be included in search.\r\n        bool components_{ true };\r\n\r\n        //! If true then bus definitions should be included in search.\r\n        bool buses_{ true };\r\n\r\n        //! If true then catalogs should be included in search.\r\n        bool catalogs_{ true };\r\n\r\n        //! If true then APIs/Coms should be included in search.\r\n        bool apis_{ true };\r\n\r\n        //! If true then other IP-Xact types should be included in search.\r\n        bool advanced_{ true };\r\n\r\n        /*! The default constructor\r\n         *\r\n         * Constructs struct with all options set to true.\r\n        */\r\n        KACTUS2_API TypeOptions() = default;\r\n    };\r\n\r\n    struct ValidityOptions\r\n    {\r\n        //! If true then valid objects should be included in search.\r\n        bool valid_{ true };\r\n\r\n        //! If true then invalid objects should be included in search.\r\n        bool invalid_{ true };\r\n\r\n        /*! The default constructor\r\n         *\r\n         * Constructs struct with all options set to true.\r\n         */\r\n        KACTUS2_API ValidityOptions() = default;\r\n    };\r\n\r\n    struct RevisionOptions\r\n    {\r\n        //! If true then 2014 std objects should be included in search.\r\n        bool std14_{ true };\r\n\r\n        //! If true then 2022 std objects should be included in search.\r\n        bool std22_{ true };\r\n\r\n        /*! The default constructor\r\n         *\r\n         * Constructs struct with all options set to true.\r\n         */\r\n        KACTUS2_API RevisionOptions() = default;\r\n    };\r\n\r\n    struct FilterOptions\r\n    {\r\n        //! Contains Type settings.\r\n        Utils::TypeOptions type{};\r\n\r\n        //! Contains Implementation settings.\r\n        Utils::ImplementationOptions implementation{};\r\n\r\n        //! Contains Hierarchy settings.\r\n        Utils::HierarchyOptions hierarchy{};\r\n\r\n        //! Contains Firmness settings.\r\n        Utils::FirmnessOptions firmness{};\r\n\r\n        //! Contains Revision settings.\r\n        Utils::RevisionOptions revision{};\r\n\r\n        //! Contains Validity settings.\r\n        Utils::ValidityOptions validity{};\r\n\r\n        /*! The default constructor\r\n         *\r\n         * Constructs struct with all options set to true.\r\n        */\r\n        KACTUS2_API FilterOptions() = default;\r\n    };\r\n\r\n\r\n    //! Regular expression to validate URLs.\r\n    inline const QRegularExpression URL_VALIDITY_REG_EXP(\r\n        \"^[a-z]{3,9}[:][/]{2}[a-z0-9]+([-.][a-z0-9]+)*([/][-a-z0-9_.;,?=&%#~+]*)*$\",\r\n        QRegularExpression::CaseInsensitiveOption);\r\n\r\n    /*!\r\n     *  Retrieves and returns the name of the current user.\r\n     */\r\n    KACTUS2_API QString getCurrentUser();\r\n}\r\n\r\n#endif // UTILS_H\r\n"
  },
  {
    "path": "KactusAPI/interfaces/bus/AbstractionTypeInterface.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: AbstractionTypeInterface.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 01.03.2021\n//\n// Description:\n// Interface for accessing abstraction types.\n//-----------------------------------------------------------------------------\n\n#include <AbstractionTypeInterface.h>\n\n#include <IPXACTmodels/AbstractionDefinition/AbstractionDefinition.h>\n#include <IPXACTmodels/common/Document.h>\n#include <IPXACTmodels/common/ConfigurableVLNVReference.h>\n#include <IPXACTmodels/Component/AbstractionType.h>\n#include <IPXACTmodels/Component/validators/AbstractionTypeValidator.h>\n\n#include <PortMapInterface.h>\n\n#include <KactusAPI/include/LibraryInterface.h>\n\nnamespace\n{\n    const QString VIEW_SEPARATOR = QLatin1String(\"; \");\n};\n\n//-----------------------------------------------------------------------------\n// Function: AbstractionTypeInterface::AbstractionTypeInterface()\n//-----------------------------------------------------------------------------\nAbstractionTypeInterface::AbstractionTypeInterface(PortMapInterface* portMapInterface,\n    QSharedPointer<AbstractionTypeValidator> validator, LibraryInterface* library):\nportMapInterface_(portMapInterface),\nvalidator_(validator),\nlibrary_(library)\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: AbstractionTypeInterface::setAbstractionTypes()\n//-----------------------------------------------------------------------------\nvoid AbstractionTypeInterface::setAbstractionTypes(\n    QSharedPointer<QList<QSharedPointer<AbstractionType>>> newAbstractions, General::InterfaceMode busMode,\n    QString const& systemGroup)\n{\n    abstractions_ = newAbstractions;\n\n    portMapInterface_->setupBusMode(busMode);\n    portMapInterface_->setupSystemGroup(systemGroup);\n}\n\n//-----------------------------------------------------------------------------\n// Function: AbstractionTypeInterface::setBusMode()\n//-----------------------------------------------------------------------------\nvoid AbstractionTypeInterface::setBusMode(General::InterfaceMode busMode)\n{\n    portMapInterface_->setupBusMode(busMode);\n}\n\n//-----------------------------------------------------------------------------\n// Function: AbstractionTypeInterface::()\n//-----------------------------------------------------------------------------\nvoid AbstractionTypeInterface::setSystemGroup(QString const& systemGroup)\n{\n    portMapInterface_->setupSystemGroup(systemGroup);\n}\n\n//-----------------------------------------------------------------------------\n// Function: AbstractionTypeInterface::setupAbstractionForPortMapInterface()\n//-----------------------------------------------------------------------------\nbool AbstractionTypeInterface::setupAbstractionTypeForPortMapInterface(int const& abstractionTypeIndex)\n{\n    QSharedPointer<AbstractionType> abstraction = getAbstraction(abstractionTypeIndex);\n    if (abstraction)\n    {\n        portMapInterface_->setupPortMaps(abstraction);\n\n        return setupAbstractionDefinitionForPortMapInterface(abstractionTypeIndex);\n    }\n\n    return false;\n}\n\n//-----------------------------------------------------------------------------\n// Function: AbstractionTypeInterface::setupAbstractionDefinitionForPortMapInterface()\n//-----------------------------------------------------------------------------\nbool AbstractionTypeInterface::setupAbstractionDefinitionForPortMapInterface(int const& abstractionTypeIndex)\n{\n    QSharedPointer<ConfigurableVLNVReference> absDefReference = getAbstractionReference(abstractionTypeIndex);\n    if (absDefReference)\n    {\n        QSharedPointer<const Document> absDefDocument = library_->getModelReadOnly(*absDefReference.data());\n        if (absDefDocument)\n        {\n            QSharedPointer<const AbstractionDefinition> absDef =\n                absDefDocument.dynamicCast<const AbstractionDefinition>();\n\n            if (absDef)\n            {\n                portMapInterface_->setupAbstractionDefinition(absDef);\n                return true;\n            }\n        }\n    }\n\n    return false;\n}\n\n//-----------------------------------------------------------------------------\n// Function: AbstractionTypeInterface::getAbstraction()\n//-----------------------------------------------------------------------------\nQSharedPointer<AbstractionType> AbstractionTypeInterface::getAbstraction(int const& abstractionIndex) const\n{\n    if (abstractionIndex >= 0 && abstractionIndex < itemCount())\n    {\n        return abstractions_->at(abstractionIndex);\n    }\n    else\n    {\n        return QSharedPointer<AbstractionType>();\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: AbstractionTypeInterface::getIndexedAbstraction()\n//-----------------------------------------------------------------------------\nstd::string AbstractionTypeInterface::getIndexedAbstraction(int const& itemIndex) const\n{\n    std::string abstractionString = \"\";\n\n    if (itemIndex >= 0 && itemIndex < itemCount())\n    {\n        abstractionString = abstractions_->at(itemIndex)->getAbstractionRef()->toString().toStdString();\n    }\n\n    return abstractionString;\n}\n\n//-----------------------------------------------------------------------------\n// Function: AbstractionTypeInterface::getAbstractionReference()\n//-----------------------------------------------------------------------------\nQSharedPointer<ConfigurableVLNVReference> AbstractionTypeInterface::getAbstractionReference(int const& typeIndex)\nconst\n{\n    QSharedPointer<AbstractionType> selectedType = getAbstraction(typeIndex);\n    if (selectedType)\n    {\n        return selectedType->getAbstractionRef();\n    }\n\n    return QSharedPointer<ConfigurableVLNVReference>();\n}\n\n//-----------------------------------------------------------------------------\n// Function: AbstractionTypeInterface::getAbstractionReferenceString()\n//-----------------------------------------------------------------------------\nstd::string AbstractionTypeInterface::getAbstractionReferenceString() const\n{\n    std::string referenceString = \"\";\n    int count = itemCount();\n    if (count == 1)\n    {\n        referenceString = abstractions_->first()->getAbstractionRef()->toString().toStdString();\n    }\n    else if (count > 1)\n    {\n        referenceString = \"[multiple]\";\n    }\n\n    return referenceString;\n}\n\n//-----------------------------------------------------------------------------\n// Function: AbstractionTypeInterface::getAbstractionReferences()\n//-----------------------------------------------------------------------------\nstd::vector<std::string> AbstractionTypeInterface::getAbstractionReferences() const\n{\n    std::vector<std::string> references;\n\n    for (auto abstractionType : *abstractions_)\n    {\n        references.push_back(abstractionType->getAbstractionRef()->toString().toStdString());\n    }\n\n    return references;\n}\n\n//-----------------------------------------------------------------------------\n// Function: AbstractionTypeInterface::hasAbstractionReference()\n//-----------------------------------------------------------------------------\nbool AbstractionTypeInterface::hasAbstractionReference(int const& typeIndex) const\n{\n    QSharedPointer<AbstractionType> selectedType = getAbstraction(typeIndex);\n    if (selectedType && selectedType->getAbstractionRef())\n    {\n        return true;\n    }\n\n    return false;\n}\n\n//-----------------------------------------------------------------------------\n// Function: AbstractionTypeInterface::itemCount()\n//-----------------------------------------------------------------------------\nint AbstractionTypeInterface::itemCount() const\n{\n    if (abstractions_)\n    {\n        return abstractions_->count();\n    }\n    else\n    {\n        return -1;\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: AbstractionTypeInterface::getItemNames()\n//-----------------------------------------------------------------------------\nstd::vector<std::string> AbstractionTypeInterface::getItemNames() const\n{\n    std::vector<std::string> abstractionVLNVs;\n\n    if (abstractions_)\n    {\n        for (auto abstraction : *abstractions_)\n        {\n            abstractionVLNVs.push_back(abstraction->getAbstractionRef()->toString().toStdString());\n        }\n    }\n\n    return abstractionVLNVs;\n}\n\n//-----------------------------------------------------------------------------\n// Function: AbstractionTypeInterface::setAbstraction ()\n//-----------------------------------------------------------------------------\nbool AbstractionTypeInterface::setAbstraction(int const& abstractionIndex, std::string const& newVendor,\n    std::string const& newLibrary, std::string const& newName, std::string const& newVersion)\n{\n    QSharedPointer<AbstractionType> selectedAbstractionType = getAbstraction(abstractionIndex);\n    if (!selectedAbstractionType)\n    {\n        return false;\n    }\n\n\n    QSharedPointer<ConfigurableVLNVReference> newAbstractionReference(new ConfigurableVLNVReference());\n    newAbstractionReference->setVendor(QString::fromStdString(newVendor));\n    newAbstractionReference->setLibrary(QString::fromStdString(newLibrary));\n    newAbstractionReference->setName(QString::fromStdString(newName));\n    newAbstractionReference->setVersion(QString::fromStdString(newVersion));\n\n    if (selectedAbstractionType->getAbstractionRef())\n    {\n        QSharedPointer<ConfigurableVLNVReference> oldAbstractionReference =\n            selectedAbstractionType->getAbstractionRef();\n\n        newAbstractionReference->setConfigurableElementValues(\n            oldAbstractionReference->getConfigurableElementValues());\n        newAbstractionReference->setType(oldAbstractionReference->getType());\n    }\n    else\n    {\n        newAbstractionReference->setType(VLNV::ABSTRACTIONDEFINITION);\n    }\n\n    selectedAbstractionType->setAbstractionRef(newAbstractionReference);\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: AbstractionTypeInterface::getViewReferences()\n//-----------------------------------------------------------------------------\nstd::vector<std::string> AbstractionTypeInterface::getViewReferences(int const& abstractionIndex) const\n{\n    std::vector<std::string> viewReferences;\n    QSharedPointer<AbstractionType> selectedType = getAbstraction(abstractionIndex);\n    if (selectedType && selectedType->getViewReferences())\n    {\n        for (auto view : *selectedType->getViewReferences())\n        {\n            viewReferences.push_back(view.toStdString());\n        }\n    }\n\n    return viewReferences;\n}\n\n//-----------------------------------------------------------------------------\n// Function: AbstractionTypeInterface::getCombinedViews()\n//-----------------------------------------------------------------------------\nstd::string AbstractionTypeInterface::getCombinedViews(int const& abstractionIndex) const\n{\n    QString combiViews;\n    QSharedPointer<AbstractionType> selectedType = getAbstraction(abstractionIndex);\n    if (selectedType && selectedType->getViewReferences())\n    {\n        combiViews = selectedType->getViewReferences()->join(VIEW_SEPARATOR);\n    }\n\n    return combiViews.toStdString();\n}\n\n//-----------------------------------------------------------------------------\n// Function: AbstractionTypeInterface::setViewReferences()\n//-----------------------------------------------------------------------------\nbool AbstractionTypeInterface::setViewReferences(int const& abstractionIndex, std::vector<std::string> newViews)\n{\n    QSharedPointer<AbstractionType> selectedAbstractionType = getAbstraction(abstractionIndex);\n    if (!selectedAbstractionType)\n    {\n        return false;\n    }\n\n    QSharedPointer<QStringList> viewReferences(new QStringList());\n    for (auto view : newViews)\n    {\n        viewReferences->append(QString::fromStdString(view));\n    }\n\n    selectedAbstractionType->setViewReferences(viewReferences);\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: AbstractionTypeInterface::getPhysicalPortsFromPortMaps()\n//-----------------------------------------------------------------------------\nstd::vector<std::string> AbstractionTypeInterface::getPhysicalPortsFromPortMaps(int const& abstractionIndex) const\n{\n    std::vector<std::string> physicalPorts;\n\n    QSharedPointer<AbstractionType> selectedAbstractionType = getAbstraction(abstractionIndex);\n    if (selectedAbstractionType)\n    {\n        for (auto portName : selectedAbstractionType->getPhysicalPortNames())\n        {\n            physicalPorts.push_back(portName.toStdString());\n        }\n    }\n\n    return physicalPorts;\n}\n\n//-----------------------------------------------------------------------------\n// Function: AbstractionTypeInterface::validateItems()\n//-----------------------------------------------------------------------------\nbool AbstractionTypeInterface::validateItems() const\n{\n    for (int i = 0; i < abstractions_->size(); ++i)\n    {\n        if (!hasValidAbstractionReference(i) || !hasValidViewReferences(i))\n        {\n            return false;\n        }\n    }\n\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: AbstractionTypeInterface::hasValidAbstractionReference()\n//-----------------------------------------------------------------------------\nbool AbstractionTypeInterface::hasValidAbstractionReference(int const& typeIndex) const\n{\n    QSharedPointer<AbstractionType> selectedType = getAbstraction(typeIndex);\n    if (!selectedType)\n    {\n        return false;\n    }\n\n    return validator_->hasValidAbstractionReference(selectedType);\n}\n\n//-----------------------------------------------------------------------------\n// Function: AbstractionTypeInterface::hasValidViewReferences()\n//-----------------------------------------------------------------------------\nbool AbstractionTypeInterface::hasValidViewReferences(int const& typeIndex) const\n{\n    QSharedPointer<AbstractionType> selectedType = getAbstraction(typeIndex);\n    if (!selectedType)\n    {\n        return false;\n    }\n\n    return validator_->hasValidViewReferences(selectedType, abstractions_);\n}\n\n//-----------------------------------------------------------------------------\n// Function: AbstractionTypeInterface::addAbstraction()\n//-----------------------------------------------------------------------------\nvoid AbstractionTypeInterface::addAbstraction(int const& typeIndex)\n{\n    QSharedPointer<AbstractionType> newAbstraction(new AbstractionType());\n\n    abstractions_->insert(typeIndex, newAbstraction);\n}\n\n//-----------------------------------------------------------------------------\n// Function: AbstractionTypeInterface::addAbstractionType()\n//-----------------------------------------------------------------------------\nvoid AbstractionTypeInterface::addAbstractionType(std::string const& newVendor, std::string const& newLibrary,\n    std::string const& newName, std::string const& newVersion) const\n{\n    QSharedPointer<ConfigurableVLNVReference> abstractionReference(new ConfigurableVLNVReference());\n    abstractionReference->setType(VLNV::ABSTRACTIONDEFINITION);\n    abstractionReference->setVendor(QString::fromStdString(newVendor));\n    abstractionReference->setLibrary(QString::fromStdString(newLibrary));\n    abstractionReference->setName(QString::fromStdString(newName));\n    abstractionReference->setVersion(QString::fromStdString(newVersion));\n    abstractionReference->setType(VLNV::ABSTRACTIONDEFINITION);\n\n    QSharedPointer<AbstractionType> newAbstractionType(new AbstractionType());\n    newAbstractionType->setAbstractionRef(abstractionReference);\n\n    abstractions_->append(newAbstractionType);\n}\n\n//-----------------------------------------------------------------------------\n// Function: AbstractionTypeInterface::removeAbstraction()\n//-----------------------------------------------------------------------------\nbool AbstractionTypeInterface::removeAbstraction(int const& typeIndex)\n{\n    if (typeIndex >= 0 && typeIndex < itemCount())\n    {\n        abstractions_->removeAt(typeIndex);\n        return true;\n    }\n    else\n    {\n        return false;\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: AbstractionTypeInterface::getPortMapInterface()\n//-----------------------------------------------------------------------------\nPortMapInterface* AbstractionTypeInterface::getPortMapInterface() const\n{\n    return portMapInterface_;\n}\n"
  },
  {
    "path": "KactusAPI/interfaces/bus/PortAbstractionInterface.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: PortAbstractionInterface.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 10.12.2020\n//\n// Description:\n// Interface for editing abstraction definition port abstractions.\n//-----------------------------------------------------------------------------\n\n#include \"PortAbstractionInterface.h\"\n\n#include <IPXACTmodels/AbstractionDefinition/PortAbstraction.h>\n#include <IPXACTmodels/AbstractionDefinition/WireAbstraction.h>\n#include <IPXACTmodels/AbstractionDefinition/TransactionalAbstraction.h>\n#include <IPXACTmodels/AbstractionDefinition/WirePort.h>\n#include <IPXACTmodels/AbstractionDefinition/TransactionalPort.h>\n#include <IPXACTmodels/AbstractionDefinition/AbstractionDefinition.h>\n#include <IPXACTmodels/AbstractionDefinition/validators/PortAbstractionValidator.h>\n\n#include <IPXACTmodels/common/Protocol.h>\n\nnamespace\n{\n    std::string const DEFAULT_NAME(\"port\");\n};\n\n//-----------------------------------------------------------------------------\n// Function: PortAbstractionInterface::PortAbstractionInterface()\n//-----------------------------------------------------------------------------\nPortAbstractionInterface::PortAbstractionInterface(QSharedPointer<ExpressionParser> expressionParser,\n    QSharedPointer<ExpressionFormatter> expressionFormatter) :\nMasterPortInterface(),\nParameterizableInterface(expressionParser, expressionFormatter),\nports_(0),\nsignals_()\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortAbstractionInterface::setAbsDef()\n//-----------------------------------------------------------------------------\nvoid PortAbstractionInterface::setAbsDef(QSharedPointer<AbstractionDefinition const> absDef)\n{\n    signals_.clear();\n    ports_.clear();\n    if (absDef.isNull())\n    {\n        return;\n    }\n\n    abstractionStandardRevision_ = absDef->getRevision();\n\n    // Set the right mode depending on std revision.\n    General::InterfaceMode initiatorMode = General::INITIATOR;\n    General::InterfaceMode targetMode = General::TARGET;\n    if (abstractionStandardRevision_ != Document::Revision::Std22)\n    {\n        initiatorMode = General::MASTER;\n        targetMode = General::SLAVE;\n    }\n\n    ports_ = absDef->getLogicalPorts();\n\n    for (auto port : *ports_)\n    {\n        if (port->hasWire())\n        {\n            bool hasValidPort = false;\n            QSharedPointer<WireAbstraction> wire = port->getWire();\n            if (wire->hasInitiatorPort())\n            {\n                createWireSignal(port, wire->getInitiatorPort(), initiatorMode);\n                hasValidPort = true;\n            }\n            if (port->getWire()->hasTargetPort())\n            {\n                createWireSignal(port, wire->getTargetPort(), targetMode);\n                hasValidPort = true;\n            }\n            for (auto systemPort : *wire->getSystemPorts())\n            {\n                createWireSignal(port, systemPort, General::SYSTEM);\n                hasValidPort = true;\n            }\n\n            if (!hasValidPort)\n            {\n                createWireSignal(port, QSharedPointer<WirePort>(new WirePort()), General::INTERFACE_MODE_COUNT);\n            }\n        }\n        if (port->hasTransactional())\n        {\n            bool hasValidPort = false;\n            QSharedPointer<TransactionalAbstraction> transactional = port->getTransactional();\n            if (transactional->hasInitiatorPort())\n            {\n                createTransactionalSignal(port, transactional->getInitiatorPort(), initiatorMode);\n                hasValidPort = true;\n            }\n            if (transactional->hasTargetPort())\n            {\n                createTransactionalSignal(port, transactional->getTargetPort(), targetMode);\n                hasValidPort = true;\n            }\n            for (auto systemPort : *transactional->getSystemPorts())\n            {\n                createTransactionalSignal(port, systemPort, General::SYSTEM);\n                hasValidPort = true;\n            }\n\n            if (!hasValidPort)\n            {\n                createTransactionalSignal(port, QSharedPointer<TransactionalPort>(new TransactionalPort()),\n                    General::INTERFACE_MODE_COUNT);\n            }\n        }\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortAbstractionInterface::setPortAbstractionValidator()\n//-----------------------------------------------------------------------------\nvoid PortAbstractionInterface::setPortAbstractionValidator(QSharedPointer<PortAbstractionValidator> validator)\n{\n    portValidator_ = validator;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortAbstractionInterface::createWireSignal()\n//-----------------------------------------------------------------------------\nvoid PortAbstractionInterface::createWireSignal(QSharedPointer<PortAbstraction> portAbs,\n    QSharedPointer<WirePort> wireModeSpesific, General::InterfaceMode mode)\n{\n    QSharedPointer<PortAbstractionInterface::SignalRow> newRow(\n        new PortAbstractionInterface::SignalRow(true, false));\n    newRow->mode_ = mode;\n    newRow->abstraction_ = portAbs;\n    newRow->wire_ = wireModeSpesific;\n\n    signals_.append(newRow);\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortAbstractionInterface::createTransactionalSignal()\n//-----------------------------------------------------------------------------\nvoid PortAbstractionInterface::createTransactionalSignal(QSharedPointer<PortAbstraction> portAbs,\n    QSharedPointer<TransactionalPort> transactionalModeSpesific, General::InterfaceMode mode)\n{\n    QSharedPointer<PortAbstractionInterface::SignalRow> newRow(\n        new PortAbstractionInterface::SignalRow(false, true));\n    newRow->mode_ = mode;\n    newRow->abstraction_ = portAbs;\n    newRow->transactional_ = transactionalModeSpesific;\n\n    signals_.append(newRow);\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortAbstractionInterface::getPort()\n//-----------------------------------------------------------------------------\nQSharedPointer<PortAbstraction> PortAbstractionInterface::getPort(std::string const& portName) const\n{\n    QString portNameQ(QString::fromStdString(portName));\n    for (auto port : *ports_)\n    {\n        if (port->name() == portNameQ)\n        {\n            return port;\n        }\n    }\n\n    return QSharedPointer<PortAbstraction>();\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortAbstractionInterface::getRevision()\n//-----------------------------------------------------------------------------\nDocument::Revision PortAbstractionInterface::getRevision() const\n{\n    return abstractionStandardRevision_;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortAbstractionInterface::getAllReferencesToIdInRow()\n//-----------------------------------------------------------------------------\nint PortAbstractionInterface::getAllReferencesToIdInRow(int signalIndex, std::string const& itemID) const\n{\n    int referenceCount = 0;\n    if (auto signal = getSignal(signalIndex))\n    {\n        if (signal->wire_)\n        {\n            referenceCount += signal->wire_->getWidth().count(QString::fromStdString(itemID));\n            referenceCount += signal->abstraction_->getDefaultValue().count(QString::fromStdString(itemID));\n        }\n        else if (signal->transactional_)\n        {\n            referenceCount += signal->transactional_->getBusWidth().count(QString::fromStdString(itemID));\n        }\n    }\n\n    return referenceCount;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortAbstractionInterface::getItem()\n//-----------------------------------------------------------------------------\nQSharedPointer<NameGroup> PortAbstractionInterface::getItem(std::string const& portName) const\n{\n    return getPort(portName);\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortAbstractionInterface::getSignal()\n//-----------------------------------------------------------------------------\nQSharedPointer<PortAbstractionInterface::SignalRow> PortAbstractionInterface::getSignal(int const& signalIndex)\nconst\n{\n    if (signalIndex < 0 || signalIndex >= signals_.size())\n    {\n        return QSharedPointer<PortAbstractionInterface::SignalRow>();\n    }\n\n    return signals_.at(signalIndex);\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortAbstractionInterface::getItemIndex()\n//-----------------------------------------------------------------------------\nint PortAbstractionInterface::getItemIndex(std::string const& itemName) const\n{\n    QString itemNameQ(QString::fromStdString(itemName));\n    for (int i = 0; i < signals_.size(); ++i)\n    {\n        if (signals_.at(i)->abstraction_->name() == itemNameQ)\n        {\n            return i;\n        }\n    }\n\n    return -1;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortAbstractionInterface::getItemIndex()\n//-----------------------------------------------------------------------------\nint PortAbstractionInterface::getItemIndex(std::string const& itemName, General::InterfaceMode mode,\n    std::string const& systemGroup) const\n{\n    QString itemNameQ(QString::fromStdString(itemName));\n    QString systemGroupQ(QString::fromStdString(systemGroup));\n    for (int i = 0; i < signals_.size(); ++i)\n    {\n        if (signals_.at(i)->abstraction_->name() == itemNameQ && signals_.at(i)->mode_ == mode)\n        {\n            if (mode == General::SYSTEM)\n            {\n                QSharedPointer<WirePort> wirePort = signals_.at(i)->wire_;\n                if (wirePort && wirePort->getSystemGroup() == systemGroupQ)\n                {\n                    return i;\n                }\n                QSharedPointer<TransactionalPort> transactional = signals_.at(i)->transactional_;\n                if (transactional && transactional->getSystemGroup() == systemGroupQ)\n                {\n                    return i;\n                }\n            }\n            else\n            {\n                return i;\n\n            }\n        }\n    }\n\n    return -1;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortAbstractionInterface::getIndexedItemName()\n//-----------------------------------------------------------------------------\nstd::string PortAbstractionInterface::getIndexedItemName(int itemIndex) const\n{\n    std::string portName(\"\");\n    if (itemIndex >= 0 && itemIndex < signals_.size())\n    {\n        portName = signals_.at(itemIndex)->abstraction_->getLogicalName().toStdString();\n    }\n\n    return portName;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortAbstractionInterface::itemCount()\n//-----------------------------------------------------------------------------\nint PortAbstractionInterface::itemCount() const\n{\n    return signals_.count();\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortAbstractionInterface::signalCount()\n//-----------------------------------------------------------------------------\nint PortAbstractionInterface::signalCount(std::string const& portName) const\n{\n    int portSignalCount = 0;\n    QString portNameQ(QString::fromStdString(portName));\n    for (auto currentSignal : signals_)\n    {\n        if (currentSignal->abstraction_->name() == portNameQ)\n        {\n            portSignalCount++;\n        }\n    }\n\n    return portSignalCount;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortAbstractionInterface::portHasMultiplesOfMasterOrSlave()\n//-----------------------------------------------------------------------------\nbool PortAbstractionInterface::portHasMultiplesOfMasterOrSlave(std::string const& portName,\n    std::string const& mode)\n{\n    General::InterfaceMode initiatorMode = General::INITIATOR;\n    General::InterfaceMode targetMode = General::TARGET;\n\n    General::InterfaceMode actualMode =\n        General::str2Interfacemode(QString::fromStdString(mode), General::INTERFACE_MODE_COUNT);\n    if (actualMode == General::MASTER || actualMode == General::SLAVE ||\n        actualMode == General::INITIATOR || actualMode == General::TARGET)\n    {\n        if (actualMode == General::MASTER || actualMode == General::SLAVE)\n        {\n            initiatorMode = General::MASTER;\n            targetMode = General::SLAVE;\n        }\n\n        QString portNameQ(QString::fromStdString(portName));\n        int initiatorModes = 0;\n        int targetModes = 0;\n        for (auto currentSignal : signals_)\n        {\n            if (currentSignal->abstraction_->name() == portNameQ)\n            {\n                if (currentSignal->mode_ == initiatorMode)\n                {\n                    initiatorModes++;\n                }\n                else if (currentSignal->mode_ == targetMode)\n                {\n                    targetModes++;\n                }\n            }\n        }\n\n        if (actualMode == initiatorMode && initiatorModes > 1)\n        {\n            return true;\n        }\n        else if (actualMode == targetMode && targetModes > 1)\n        {\n            return true;\n        }\n    }\n\n    return false;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortAbstractionInterface::getItemNames()\n//-----------------------------------------------------------------------------\nstd::vector<std::string> PortAbstractionInterface::getItemNames() const\n{\n    std::vector<std::string> portNames;\n    if (ports_)\n    {\n        for (auto port : *ports_)\n        {\n            std::string currentPortName(port->name().toStdString());\n            if (std::find(portNames.cbegin(), portNames.cend(), currentPortName) == portNames.cend())\n            {\n                portNames.push_back(currentPortName);\n            }\n        }\n    }\n\n    return portNames;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortAbstractionInterface::getItemNamesWithModeAndGroup()\n//-----------------------------------------------------------------------------\nstd::vector<std::string> PortAbstractionInterface::getItemNamesWithModeAndGroup(std::string const& busModeString,\n    std::string systemGroup) const\n{\n    std::vector<std::string> portNames;\n    if (ports_)\n    {\n        for (auto port : *ports_)\n        {\n            std::string currentPortName(port->name().toStdString());\n            if (std::find(portNames.cbegin(), portNames.cend(), currentPortName) == portNames.cend() &&\n                portHasMode(currentPortName, busModeString, systemGroup))\n            {\n                portNames.push_back(currentPortName);\n            }\n        }\n    }\n\n    return portNames;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortAbstractionInterface::setName()\n//-----------------------------------------------------------------------------\nbool PortAbstractionInterface::setName(std::string const& currentName, std::string const& newName)\n{\n    QSharedPointer<PortAbstraction> editedPort = getPort(currentName);\n    if (editedPort && nameHasChanged(newName, currentName))\n    {\n        QString uniqueNewName(getUniqueName(newName, DEFAULT_NAME));\n\n        editedPort->setLogicalName(uniqueNewName);\n        return true;\n    }\n    else\n    {\n        return false;\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortAbstractionInterface::getMatch()\n//-----------------------------------------------------------------------------\nbool PortAbstractionInterface::getMatch(int const& portIndex) const\n{\n    if (auto const& signal = getSignal(portIndex); signal)\n    {\n        return signal->abstraction_->getMatch();\n    }\n\n    return false;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortAbstractionInterface::setMatch()\n//-----------------------------------------------------------------------------\nbool PortAbstractionInterface::setMatch(int const& portIndex, bool match) const\n{\n    auto const& signal = getSignal(portIndex);\n    if (!signal)\n    {\n        return false;\n    }\n\n    signal->abstraction_->setMatch(match);\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortAbstractionInterface::validateItems()\n//-----------------------------------------------------------------------------\nbool PortAbstractionInterface::validateItems() const\n{\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortAbstractionInterface::itemHasValidName()\n//-----------------------------------------------------------------------------\nbool PortAbstractionInterface::itemHasValidName(std::string const& itemName) const\n{\n    if (auto port = getPort(itemName); portValidator_ && port)\n    {\n        return portValidator_->hasValidName(port);\n    }\n\n    return false;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortAbstractionInterface::wireHasValidWidth()\n//-----------------------------------------------------------------------------\nbool PortAbstractionInterface::wireHasValidWidth(int portIndex) const\n{\n    if (auto signal = getSignal(portIndex); portValidator_ && signal)\n    {\n        return portValidator_->wireHasValidWidth(signal->wire_);\n    }\n\n    return false;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortAbstractionInterface::wireHasValidDefaultValue()\n//-----------------------------------------------------------------------------\nbool PortAbstractionInterface::wireHasValidDefaultValue(int portIndex) const\n{\n    if (auto signal = getSignal(portIndex); portValidator_ && signal)\n    {\n        return portValidator_->wireHasValidDefaultValue(signal->abstraction_->getWire());\n    }\n\n    return false;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortAbstractionInterface::getMode()\n//-----------------------------------------------------------------------------\nGeneral::InterfaceMode PortAbstractionInterface::getMode(int const& portIndex) const\n{\n    QSharedPointer<SignalRow> selectedSignal = getSignal(portIndex);\n    if (!selectedSignal)\n    {\n        return General::INTERFACE_MODE_COUNT;\n    }\n\n    return selectedSignal->mode_;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortAbstractionInterface::getModeString()\n//-----------------------------------------------------------------------------\nstd::string PortAbstractionInterface::getModeString(int const& portIndex) const\n{\n    QSharedPointer<SignalRow> selectedSignal = getSignal(portIndex);\n    if (!selectedSignal)\n    {\n        return std::string(\"\");\n    }\n\n    return General::interfaceMode2Str(selectedSignal->mode_).toStdString();\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortAbstractionInterface::setMode()\n//-----------------------------------------------------------------------------\nbool PortAbstractionInterface::setMode(int const& portIndex, std::string const& newMode)\n{\n    QSharedPointer<SignalRow> selectedSignal = getSignal(portIndex);\n    if (!selectedSignal)\n    {\n        return false;\n    }\n\n    selectedSignal->mode_ =\n        General::str2Interfacemode(QString::fromStdString(newMode), General::INTERFACE_MODE_COUNT);\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortAbstractionInterface::getSystemGroup()\n//-----------------------------------------------------------------------------\nstd::string PortAbstractionInterface::getSystemGroup(int const& portIndex) const\n{\n    std::string signalSystem(\"\");\n    QSharedPointer<SignalRow> selectedSignal = getSignal(portIndex);\n    if (selectedSignal)\n    {\n        if (selectedSignal->wire_)\n        {\n            signalSystem = selectedSignal->wire_->getSystemGroup().toStdString();\n        }\n        else if (selectedSignal->transactional_)\n        {\n            signalSystem = selectedSignal->transactional_->getSystemGroup().toStdString();\n        }\n    }\n\n    return signalSystem;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortAbstractionInterface::getSystemGroupsForPort()\n//-----------------------------------------------------------------------------\nstd::vector<std::string> PortAbstractionInterface::getSystemGroupsForPort(std::string const& portName) const\n{\n    std::vector<std::string> systemGroups;\n    QString portNameQ(QString::fromStdString(portName));\n\n    for (auto currentSignal : signals_)\n    {\n        if (currentSignal->abstraction_->name() == portNameQ)\n        {\n            QSharedPointer<WirePort> wire = currentSignal->wire_;\n            QSharedPointer<TransactionalPort> transactional = currentSignal->transactional_;\n            if (wire && !wire->getSystemGroup().isEmpty())\n            {\n                std::string newSystemGroup(wire->getSystemGroup().toStdString());\n                if (std::find(systemGroups.cbegin(), systemGroups.cend(), newSystemGroup) == systemGroups.cend())\n                {\n                    systemGroups.push_back(newSystemGroup);\n                }\n            }\n            if (transactional && !transactional->getSystemGroup().isEmpty())\n            {\n                std::string newSystemGroup(transactional->getSystemGroup().toStdString());\n                if (std::find(systemGroups.cbegin(), systemGroups.cend(), newSystemGroup) == systemGroups.cend())\n                {\n                    systemGroups.push_back(newSystemGroup);\n                }\n            }\n        }\n    }\n\n    return systemGroups;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortAbstractionInterface::setSystemGroup()\n//-----------------------------------------------------------------------------\nbool PortAbstractionInterface::setSystemGroup(int const& portIndex, std::string const& newSystem)\n{\n    QSharedPointer<SignalRow> selectedSignal = getSignal(portIndex);\n    if (selectedSignal)\n    {\n        if (selectedSignal->wire_)\n        {\n            selectedSignal->wire_->setSystemGroup(QString::fromStdString(newSystem));\n        }\n        else if (selectedSignal->transactional_)\n        {\n            selectedSignal->transactional_->setSystemGroup(QString::fromStdString(newSystem));\n        }\n    }\n\n    return false;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortAbstractionInterface::getQualifierList()\n//-----------------------------------------------------------------------------\nstd::vector<std::string> PortAbstractionInterface::getQualifierStringList(int const& portIndex) const\n{\n    std::vector<std::string> qualifierList;\n\n    QSharedPointer<SignalRow> selectedSignal = getSignal(portIndex);\n    if (selectedSignal)\n    {\n        QSharedPointer<Qualifier> portQualifier;\n        if (selectedSignal->wire_)\n        {\n            portQualifier = selectedSignal->abstraction_->getWire()->getQualifier();\n        }\n        if (selectedSignal->transactional_)\n        {\n            portQualifier = selectedSignal->abstraction_->getTransactional()->getQualifier();\n        }\n\n        for (auto const& type : portQualifier->getTypes())\n        {\n            qualifierList.push_back(Qualifier::typeToString(type).toStdString());\n        }\n    }\n\n    return qualifierList;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortAbstractionInterface::setQualifier()\n//-----------------------------------------------------------------------------\nbool PortAbstractionInterface::setQualifier(int const& portIndex, std::string const& newQualifier)\n{\n    QSharedPointer<SignalRow> selectedSignal = getSignal(portIndex);\n    if (selectedSignal)\n    {\n        if (selectedSignal->wire_)\n        {\n            selectedSignal->abstraction_->getWire()->addQualifier(\n                Qualifier::stringToType(QString::fromStdString(newQualifier)));\n        }\n        else if (selectedSignal->transactional_)\n        {\n            selectedSignal->abstraction_->getTransactional()->addQualifier(\n                Qualifier::stringToType(QString::fromStdString(newQualifier)));\n        }\n\n        return true;\n    }\n\n    return false;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortAbstractionInterface::setQualifierStringList()\n//-----------------------------------------------------------------------------\nbool PortAbstractionInterface::setQualifierStringList(int const& portIndex, std::vector<std::string> const& newQualifierList)\n{\n    QSharedPointer<SignalRow> selectedSignal = getSignal(portIndex);\n    if (!selectedSignal)\n    {\n        return false;\n    }\n\n    QSharedPointer<Qualifier> activeQualifier;\n\n    if (selectedSignal->wire_)\n    {\n        activeQualifier = selectedSignal->abstraction_->getWire()->getQualifier();\n    }\n    else if (selectedSignal->transactional_)\n    {\n        activeQualifier = selectedSignal->abstraction_->getTransactional()->getQualifier();\n    }\n    else\n    {\n        return false;\n    }\n\n    activeQualifier->clear();\n\n    for (auto const& qualifier : newQualifierList)\n    {\n        activeQualifier->setType(Qualifier::stringToType(QString::fromStdString(qualifier)));\n    }\n\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortAbstractionInterface::getQualifierAttribute()\n//-----------------------------------------------------------------------------\nstd::string PortAbstractionInterface::getQualifierAttribute(int const& portIndex,\n    std::string const& attributeName) const\n{\n    auto selectedSignal = getSignal(portIndex);\n    if (!selectedSignal)\n    {\n        return std::string(\"\");\n    }\n    \n    std::string attribute;\n\n    if (selectedSignal->wire_)\n    {\n        attribute = selectedSignal->abstraction_->getWire()->getQualifier()->getAttribute(\n            getQualifierAttributeType(attributeName)).toStdString();\n    }\n    else if (selectedSignal->transactional_)\n    {\n        attribute = selectedSignal->abstraction_->getTransactional()->getQualifier()->getAttribute(\n            getQualifierAttributeType(attributeName)).toStdString();\n    }\n\n    return attribute;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortAbstractionInterface::setQualifierAttribute()\n//-----------------------------------------------------------------------------\nbool PortAbstractionInterface::setQualifierAttribute(int const& portIndex, std::string const& attributeName,\n    std::string const& attributeValue) const\n{\n    QSharedPointer<SignalRow> selectedSignal = getSignal(portIndex);\n    if (!selectedSignal)\n    {\n        return false;\n    }\n\n    if (selectedSignal->wire_)\n    {\n        selectedSignal->abstraction_->getWire()->getQualifier()->setAttribute(\n            getQualifierAttributeType(attributeName), QString::fromStdString(attributeValue));\n    }\n    else if (selectedSignal->transactional_)\n    {\n        selectedSignal->abstraction_->getTransactional()->getQualifier()->setAttribute(\n            getQualifierAttributeType(attributeName), QString::fromStdString(attributeValue));\n    }\n    else\n    {\n        return false;\n    }\n\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortAbstractionInterface::setQualifierAttributes()\n//-----------------------------------------------------------------------------\nbool PortAbstractionInterface::setQualifierAttributes(int const& portIndex, std::vector<std::string> const& attributes) const\n{\n    QSharedPointer<SignalRow> selectedSignal = getSignal(portIndex);\n    if (!selectedSignal)\n    {\n        return false;\n    }\n\n    if (!selectedSignal->wire_ && !selectedSignal->transactional_)\n    {\n        return false;\n    }\n\n    if (attributes.size() != Qualifier::ATTRIBUTE_COUNT * 2)\n    {\n        return false;\n    }\n\n    QSharedPointer<Qualifier> activeQualifier;\n\n    if (selectedSignal->wire_)\n    {\n        activeQualifier = selectedSignal->abstraction_->getWire()->getQualifier();\n    }\n    else\n    {\n        activeQualifier = selectedSignal->abstraction_->getTransactional()->getQualifier();\n    }\n\n    for (size_t i = 0; i + 1 < attributes.size(); i += 2)\n    {\n        auto const& attributeName = attributes.at(i);\n        auto const& value = attributes.at(i + 1);\n\n        activeQualifier->setAttribute(getQualifierAttributeType(attributeName), QString::fromStdString(value));\n    }\n\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortAbstractionInterface::getQualifierAttributes()\n//-----------------------------------------------------------------------------\nstd::vector<std::string> PortAbstractionInterface::getQualifierAttributes(int const& portIndex) const\n{\n    std::vector<std::string> attributes;\n\n    QSharedPointer<SignalRow> selectedSignal = getSignal(portIndex);\n    if (!selectedSignal)\n    {\n        return attributes;\n    }\n\n    if (!selectedSignal->wire_ && !selectedSignal->transactional_)\n    {\n        return attributes;\n    }\n\n    QSharedPointer<Qualifier> activeQualifier;\n\n    if (selectedSignal->wire_)\n    {\n        activeQualifier = selectedSignal->abstraction_->getWire()->getQualifier();\n    }\n    else\n    {\n        activeQualifier = selectedSignal->abstraction_->getTransactional()->getQualifier();\n    }\n\n    static const std::vector<std::string> attributeNames = {\n        std::string(\"resetLevel\"),\n        std::string(\"clockEnableLevel\"),\n        std::string(\"powerEnableLevel\"),\n        std::string(\"powerDomainReference\"),\n        std::string(\"flowType\"),\n        std::string(\"userFlowType\"),\n        std::string(\"userDefined\")\n    };\n\n    for (auto const& name : attributeNames)\n    {\n        attributes.push_back(name);\n        auto attributeType = Qualifier::stringToAttributeName(QString::fromStdString(name));\n        attributes.push_back(activeQualifier->getAttribute(attributeType).toStdString());\n    }\n\n    return attributes;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortAbstractionInterface::getDirectionString()\n//-----------------------------------------------------------------------------\nstd::string PortAbstractionInterface::getDirectionString(int const& portIndex) const\n{\n    QSharedPointer<SignalRow> selectedSignal = getSignal(portIndex);\n    if (selectedSignal && selectedSignal->wire_)\n    {\n        return DirectionTypes::direction2Str(selectedSignal->wire_->getDirection()).toStdString();\n    }\n\n    return std::string(\"\");\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortAbstractionInterface::getDirection()\n//-----------------------------------------------------------------------------\nDirectionTypes::Direction PortAbstractionInterface::getDirection(int const& portIndex) const\n{\n    QSharedPointer<SignalRow> selectedSignal = getSignal(portIndex);\n    if (selectedSignal && selectedSignal->wire_)\n    {\n        return selectedSignal->wire_->getDirection();\n    }\n\n    return DirectionTypes::DIRECTION_INVALID;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortAbstractionInterface::getDirection()\n//-----------------------------------------------------------------------------\nDirectionTypes::Direction PortAbstractionInterface::getDirection(std::string const& portName,\n    General::InterfaceMode mode, std::string const& systemGroup) const\n{\n    DirectionTypes::Direction portDirection(DirectionTypes::DIRECTION_INVALID);\n\n    QSharedPointer<PortAbstraction> port = getPort(portName);\n    if (port && port->getWire() && mode != General::INTERFACE_MODE_COUNT)\n    {\n        portDirection =\n            port->getWire()->getDirection(mode, QString::fromStdString(systemGroup));\n    }\n\n    return portDirection;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortAbstractionInterface::setDirection()\n//-----------------------------------------------------------------------------\nbool PortAbstractionInterface::setDirection(int const& portIndex, std::string const& newDirection)\n{\n    QSharedPointer<SignalRow> selectedSignal = getSignal(portIndex);\n    if (!selectedSignal || !selectedSignal->wire_)\n    {\n        return false;\n    }\n\n    QString directionQ = QString::fromStdString(newDirection);\n    selectedSignal->wire_->setDirection(\n        DirectionTypes::str2Direction(directionQ, DirectionTypes::DIRECTION_INVALID));\n\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortAbstractionInterface::getWidth()\n//-----------------------------------------------------------------------------\nstd::string PortAbstractionInterface::getWidthExpression(int const& portIndex) const\n{\n    QSharedPointer<SignalRow> selectedSignal = getSignal(portIndex);\n    if (selectedSignal && selectedSignal->wire_)\n    {\n        return selectedSignal->wire_->getWidth().toStdString();\n    }\n\n    return std::string(\"\");\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortAbstractionInterface::getWidth()\n//-----------------------------------------------------------------------------\nstd::string PortAbstractionInterface::getWidthExpression(std::string const& portName, std::string const& interfaceMode,\n    std::string const& systemGroup) const\n{\n    QString signalWidth(\"\");\n\n    QSharedPointer<PortAbstraction> port = getPort(portName);\n    General::InterfaceMode busMode = General::str2Interfacemode(QString::fromStdString(interfaceMode),\n        General::INTERFACE_MODE_COUNT);\n    if (port && port->getWire() && busMode != General::INTERFACE_MODE_COUNT)\n    {\n        signalWidth = port->getWire()->getWidth(busMode, QString::fromStdString(systemGroup));\n    }\n\n    return signalWidth.toStdString();\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortAbstractionInterface::getWidth()\n//-----------------------------------------------------------------------------\nstd::string PortAbstractionInterface::getWidthExpression(std::string const& portName, General::InterfaceMode interfaceMode,\n    std::string const& systemGroup) const\n{\n    QString signalWidth(\"\");\n\n    QSharedPointer<PortAbstraction> port = getPort(portName);\n    if (port && port->getWire() && interfaceMode != General::INTERFACE_MODE_COUNT)\n    {\n        signalWidth = port->getWire()->getWidth(interfaceMode, QString::fromStdString(systemGroup));\n    }\n\n    return signalWidth.toStdString();\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortAbstractionInterface::getWidthFormattedExpression()\n//-----------------------------------------------------------------------------\nstd::string PortAbstractionInterface::getWidthFormattedExpression(int portIndex) const\n{\n    QSharedPointer<SignalRow> selectedSignal = getSignal(portIndex);\n    if (!selectedSignal || !selectedSignal->wire_)\n    {\n        return std::string();\n    }\n\n    auto widthExpression = selectedSignal->wire_->getWidth();\n\n    if (widthExpression.isEmpty())\n    {\n        return widthExpression.toStdString();\n    }\n\n    return formattedValueFor(widthExpression).toStdString();\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortAbstractionInterface::getWidthValue()\n//-----------------------------------------------------------------------------\nstd::string PortAbstractionInterface::getWidthValue(int portIndex, int const& baseNumber /*= 0*/) const\n{\n    if (auto selectedSignal = getSignal(portIndex); selectedSignal && selectedSignal->wire_)\n    {\n        bool expressionIsValid = true;\n        auto value = parseExpressionToBaseNumber(\n            selectedSignal->wire_->getWidth(), baseNumber, &expressionIsValid).toStdString();\n\n        return expressionIsValid ? value : std::string(\"x\");\n    }\n\n    return std::string(\"x\");\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortAbstractionInterface::getWidthValue()\n//-----------------------------------------------------------------------------\nstd::string PortAbstractionInterface::getWidthValue(\n    std::string const& portName,\n    General::InterfaceMode interfaceMode,\n    std::string const& systemGroup,\n    int const& baseNumber) const\n{\n    if (QSharedPointer<PortAbstraction> port = getPort(portName); port && port->getWire() && interfaceMode != General::INTERFACE_MODE_COUNT)\n    {\n        auto width = port->getWire()->getWidth(interfaceMode, QString::fromStdString(systemGroup));\n        bool expressionOk = false;\n        auto widthAsValue = parseExpressionToBaseNumber(width, baseNumber, &expressionOk);\n\n        if (expressionOk)\n        {\n            return widthAsValue.toStdString();\n        }\n    }\n\n    return std::string();\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortAbstractionInterface::setWidth()\n//-----------------------------------------------------------------------------\nbool PortAbstractionInterface::setWidth(int const& portIndex, std::string const& newWidth)\n{\n    QSharedPointer<SignalRow> selectedSignal = getSignal(portIndex);\n    if (!selectedSignal || !selectedSignal->wire_)\n    {\n        return false;\n    }\n\n    selectedSignal->wire_->setWidth(QString::fromStdString(newWidth));\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortAbstractionInterface::getPresence()\n//-----------------------------------------------------------------------------\nPresenceTypes::Presence PortAbstractionInterface::getPresence(int const& portIndex) const\n{\n    QSharedPointer<SignalRow> selectedSignal = getSignal(portIndex);\n    if (selectedSignal && (selectedSignal->wire_ || selectedSignal->transactional_))\n    {\n        if (selectedSignal->wire_)\n        {\n            return selectedSignal->wire_->getPresence();\n        }\n        if (selectedSignal->transactional_)\n        {\n            return selectedSignal->transactional_->getPresence();\n        }\n    }\n\n    return PresenceTypes::UNKNOWN;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortAbstractionInterface::getPresenceString()\n//-----------------------------------------------------------------------------\nPresenceTypes::Presence PortAbstractionInterface::getPresence(std::string const& portName,\n    std::string const& interfaceMode, std::string const& systemGroup) const\n{\n    QSharedPointer<PortAbstraction> port = getPort(portName);\n    General::InterfaceMode busMode = General::str2Interfacemode(QString::fromStdString(interfaceMode),\n        General::INTERFACE_MODE_COUNT);\n    if (port && busMode != General::INTERFACE_MODE_COUNT)\n    {\n        return port->getPresence(busMode, QString::fromStdString(systemGroup));\n    }\n\n    return PresenceTypes::UNKNOWN;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortAbstractionInterface::getPresenceString()\n//-----------------------------------------------------------------------------\nstd::string PortAbstractionInterface::getPresenceString(int const& portIndex) const\n{\n    QSharedPointer<SignalRow> selectedSignal = getSignal(portIndex);\n    if (selectedSignal && (selectedSignal->wire_ || selectedSignal->transactional_))\n    {\n        if (selectedSignal->wire_)\n        {\n            return PresenceTypes::presence2Str(selectedSignal->wire_->getPresence()).toStdString();\n        }\n        if (selectedSignal->transactional_)\n        {\n            return PresenceTypes::presence2Str(selectedSignal->transactional_->getPresence()).toStdString();\n        }\n    }\n\n    return std::string(\"\");\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortAbstractionInterface::getPresenceString()\n//-----------------------------------------------------------------------------\nstd::string PortAbstractionInterface::getPresenceString(std::string const& portName,\n    std::string const& interfaceMode, std::string const& systemGroup) const\n{\n    std::string presence(\"\");\n\n    QSharedPointer<PortAbstraction> port = getPort(portName);\n    General::InterfaceMode busMode = General::str2Interfacemode(QString::fromStdString(interfaceMode),\n        General::INTERFACE_MODE_COUNT);\n    if (port && busMode != General::INTERFACE_MODE_COUNT)\n    {\n        presence = PresenceTypes::presence2Str(\n            port->getPresence(busMode, QString::fromStdString(systemGroup))).toStdString();\n    }\n\n    return presence;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortAbstractionInterface::setPresence()\n//-----------------------------------------------------------------------------\nbool PortAbstractionInterface::setPresence(int const& portIndex, std::string const& newPresence)\n{\n    QSharedPointer<SignalRow> selectedSignal = getSignal(portIndex);\n    if (selectedSignal && (selectedSignal->wire_ || selectedSignal->transactional_))\n    {\n        PresenceTypes::Presence formattedPresence =\n            PresenceTypes::str2Presence(QString::fromStdString(newPresence), PresenceTypes::UNKNOWN);\n        if (selectedSignal->wire_)\n        {\n            selectedSignal->wire_->setPresence(formattedPresence);\n        }\n        if (selectedSignal->transactional_)\n        {\n            selectedSignal->transactional_->setPresence(formattedPresence);\n        }\n\n        return true;\n    }\n\n    return false;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortAbstractionInterface::getDefaultValue()\n//-----------------------------------------------------------------------------\nstd::string PortAbstractionInterface::getDefaultValueExpression(int const& portIndex) const\n{\n    QSharedPointer<SignalRow> selectedSignal = getSignal(portIndex);\n    if (selectedSignal && selectedSignal->abstraction_ && selectedSignal->abstraction_->hasWire())\n    {\n        return selectedSignal->abstraction_->getWire()->getDefaultValue().toStdString();\n    }\n\n    return std::string(\"\");\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortAbstractionInterface::getDefaultValueFormattedExpression()\n//-----------------------------------------------------------------------------\nstd::string PortAbstractionInterface::getDefaultValueFormattedExpression(int const& portIndex) const\n{\n    QSharedPointer<SignalRow> selectedSignal = getSignal(portIndex);\n    if (!selectedSignal || !selectedSignal->wire_)\n    {\n        return std::string();\n    }\n\n    auto defaultValueExpression = selectedSignal->abstraction_->getDefaultValue();\n\n    if (defaultValueExpression.isEmpty())\n    {\n        return defaultValueExpression.toStdString();\n    }\n\n    return formattedValueFor(defaultValueExpression).toStdString();\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortAbstractionInterface::getDefaultValueValue()\n//-----------------------------------------------------------------------------\nstd::string PortAbstractionInterface::getDefaultValueValue(int const& portIndex, int baseNumber /*= 0*/) const\n{\n    if (auto selectedSignal = getSignal(portIndex); selectedSignal && selectedSignal->wire_)\n    {\n        bool expressionIsValid = false;\n        auto value = parseExpressionToBaseNumber(\n            selectedSignal->abstraction_->getDefaultValue(), baseNumber, &expressionIsValid).toStdString();\n\n        return expressionIsValid ? value : std::string(\"x\");\n    }\n\n    return std::string(\"x\");\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortAbstractionInterface::setDefaultValue()\n//-----------------------------------------------------------------------------\nbool PortAbstractionInterface::setDefaultValue(int const& portIndex, std::string const& newDefaultValue)\n{\n    QSharedPointer<SignalRow> selectedSignal = getSignal(portIndex);\n    if (!selectedSignal || !selectedSignal->abstraction_ || !selectedSignal->abstraction_->getWire())\n    {\n        return false;\n    }\n\n    selectedSignal->abstraction_->getWire()->setDefaultValue(QString::fromStdString(newDefaultValue));\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortAbstractionInterface::getDriverString()\n//-----------------------------------------------------------------------------\nstd::string PortAbstractionInterface::getDriverString(int const& portIndex) const\n{\n    QSharedPointer<SignalRow> selectedSignal = getSignal(portIndex);\n    if (selectedSignal && selectedSignal->abstraction_ && selectedSignal->abstraction_->hasWire())\n    {\n        return General::driverType2Str(selectedSignal->abstraction_->getWire()->getDriverType()).toStdString();\n    }\n\n    return std::string(\"\");\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortAbstractionInterface::setDriverType()\n//-----------------------------------------------------------------------------\nbool PortAbstractionInterface::setDriverType(int const& portIndex, std::string const& newDriver)\n{\n    QSharedPointer<SignalRow> selectedSignal = getSignal(portIndex);\n    if (!selectedSignal || !selectedSignal->abstraction_ || !selectedSignal->abstraction_->getWire())\n    {\n        return false;\n    }\n\n    selectedSignal->abstraction_->getWire()->setDriverType(\n        General::str2DriverType(QString::fromStdString(newDriver), General::NO_DRIVER));\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortAbstractionInterface::()\n//-----------------------------------------------------------------------------\nstd::string PortAbstractionInterface::getBusWidthExpression(int const& portIndex) const\n{\n    QSharedPointer<SignalRow> selectedSignal = getSignal(portIndex);\n    if (selectedSignal && selectedSignal->transactional_)\n    {\n        return selectedSignal->transactional_->getBusWidth().toStdString();\n    }\n\n    return std::string(\"\");\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortAbstractionInterface::getBusWidthValue()\n//-----------------------------------------------------------------------------\nstd::string PortAbstractionInterface::getBusWidthExpression(std::string const& portName,\n    std::string const& interfaceMode, std::string const& systemGroup) const\n{\n    QString signalWidth(\"\");\n\n    QSharedPointer<PortAbstraction> port = getPort(portName);\n    General::InterfaceMode busMode = General::str2Interfacemode(QString::fromStdString(interfaceMode),\n        General::INTERFACE_MODE_COUNT);\n    if (port && port->getTransactional() && busMode != General::INTERFACE_MODE_COUNT)\n    {\n        signalWidth = port->getTransactional()->getWidth(busMode, QString::fromStdString(systemGroup));\n    }\n\n    return signalWidth.toStdString();\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortAbstractionInterface::getBusWidthFormattedExpression()\n//-----------------------------------------------------------------------------\nstd::string PortAbstractionInterface::getBusWidthFormattedExpression(int signalIndex) const\n{\n    QSharedPointer<SignalRow> selectedSignal = getSignal(signalIndex);\n    if (!selectedSignal || !selectedSignal->transactional_)\n    {\n        return std::string();\n    }\n\n    auto busWidthExpression = selectedSignal->transactional_->getBusWidth();\n\n    if (busWidthExpression.isEmpty())\n    {\n        return busWidthExpression.toStdString();\n    }\n\n    return formattedValueFor(busWidthExpression).toStdString();\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortAbstractionInterface::getBusWidthValue()\n//-----------------------------------------------------------------------------\nstd::string PortAbstractionInterface::getBusWidthValue(int portIndex, int baseNumber /*= 0*/) const\n{\n    if (auto selectedSignal = getSignal(portIndex); selectedSignal && selectedSignal->transactional_)\n    {\n        bool expressionIsValid = false;\n        auto value = parseExpressionToBaseNumber(\n            selectedSignal->transactional_->getBusWidth(), baseNumber, &expressionIsValid).toStdString();\n\n        return expressionIsValid ? value : std::string(\"x\");\n    }\n\n    return std::string(\"x\");\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortAbstractionInterface::setBusWidth()\n//-----------------------------------------------------------------------------\nbool PortAbstractionInterface::setBusWidth(int const& portIndex, std::string const& newBusWidth)\n{\n    QSharedPointer<SignalRow> selectedSignal = getSignal(portIndex);\n    if (!selectedSignal || !selectedSignal->transactional_)\n    {\n        return false;\n    }\n\n    QString busWidthQ(QString::fromStdString(newBusWidth));\n    selectedSignal->transactional_->setBusWidth(busWidthQ);\n\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortAbstractionInterface::transactionalHasValidBusWidth()\n//-----------------------------------------------------------------------------\nbool PortAbstractionInterface::transactionalHasValidBusWidth(int portIndex) const\n{\n    if (auto signal = getSignal(portIndex); portValidator_ && signal)\n    {\n        return portValidator_->transactionalHasValidBusWidth(signal->transactional_);\n    }\n\n    return false;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortAbstractionInterface::getInitiative()\n//-----------------------------------------------------------------------------\nstd::string PortAbstractionInterface::getInitiative(int const& portIndex) const\n{\n    QSharedPointer<PortAbstractionInterface::SignalRow> selectedSignal = getSignal(portIndex);\n    if (selectedSignal && selectedSignal->transactional_)\n    {\n        QString portInitiative = selectedSignal->transactional_->getInitiative();\n        if (portInitiative.compare(QStringLiteral(\"both\"), Qt::CaseInsensitive) == 0)\n        {\n            return QStringLiteral(\"requires/provides\").toStdString();\n        }\n        else\n        {\n            return portInitiative.toStdString();\n        }\n    }\n\n    return std::string(\"\");\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortAbstractionInterface::getInitiative()\n//-----------------------------------------------------------------------------\nstd::string PortAbstractionInterface::getInitiative(std::string const& portName, std::string const& interfaceMode,\n    std::string const& systemGroup) const\n{\n    std::string portInitiative(\"\");\n\n    QSharedPointer<PortAbstraction> port = getPort(portName);\n    General::InterfaceMode busMode = General::str2Interfacemode(QString::fromStdString(interfaceMode),\n        General::INTERFACE_MODE_COUNT);\n    if (port && port->getTransactional() && busMode != General::INTERFACE_MODE_COUNT)\n    {\n        portInitiative =\n            port->getTransactional()->getInitiative(busMode, QString::fromStdString(systemGroup)).toStdString();\n    }\n\n    return portInitiative;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortAbstractionInterface::setInitiative()\n//-----------------------------------------------------------------------------\nbool PortAbstractionInterface::setInitiative(int const& portIndex, std::string const& newInitiative)\n{\n    QSharedPointer<SignalRow> selectedSignal = getSignal(portIndex);\n    if (!selectedSignal || !selectedSignal->transactional_)\n    {\n        return false;\n    }\n\n    QString initiativeQ(QString::fromStdString(newInitiative));\n    if (initiativeQ.compare(QStringLiteral(\"requires/provides\"), Qt::CaseInsensitive) == 0)\n    {\n        initiativeQ = QLatin1String(\"both\");\n    }\n    else if (initiativeQ.compare(QStringLiteral(\"requires\"), Qt::CaseInsensitive) != 0 && initiativeQ.compare(QStringLiteral(\"provides\"), Qt::CaseInsensitive) != 0)\n    {\n        initiativeQ = QLatin1String(\"\");\n    }\n\n    selectedSignal->transactional_->setInitiative(initiativeQ);\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortAbstractionInterface::getKind()\n//-----------------------------------------------------------------------------\nstd::string PortAbstractionInterface::getKind(int const& portIndex) const\n{\n    QSharedPointer<SignalRow> selectedSignal = getSignal(portIndex);\n    if (selectedSignal && selectedSignal->transactional_)\n    {\n        return selectedSignal->transactional_->getKind().toStdString();\n    }\n\n    return std::string(\"\");\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortAbstractionInterface::setKind()\n//-----------------------------------------------------------------------------\nbool PortAbstractionInterface::setKind(int const& portIndex, std::string const& newKind)\n{\n    QSharedPointer<SignalRow> selectedSignal = getSignal(portIndex);\n    if (!selectedSignal || !selectedSignal->transactional_)\n    {\n        return false;\n    }\n\n    QString kindQ(QString::fromStdString(newKind));\n    selectedSignal->transactional_->setKind(kindQ);\n\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortAbstractionInterface::hasProtocol()\n//-----------------------------------------------------------------------------\nbool PortAbstractionInterface::hasProtocol(int const& portIndex) const\n{\n    QSharedPointer<SignalRow> selectedSignal = getSignal(portIndex);\n    if (selectedSignal && selectedSignal->transactional_ && selectedSignal->transactional_->getProtocol())\n    {\n        return true;\n    }\n\n    return false;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortAbstractionInterface::getProtocolType()\n//-----------------------------------------------------------------------------\nstd::string PortAbstractionInterface::getProtocolType(int const& portIndex) const\n{\n    QSharedPointer<SignalRow> selectedSignal = getSignal(portIndex);\n    if (selectedSignal && selectedSignal->transactional_ && selectedSignal->transactional_->getProtocol())\n    {\n        return getProtocolTypeText(selectedSignal->transactional_->getProtocol()).toStdString();\n    }\n\n    return std::string(\"\");\n}\n\n//-----------------------------------------------------------------------------\n// Function: AbstractionTransactionalPortsModel::getProtocolTypeText()\n//-----------------------------------------------------------------------------\nQString PortAbstractionInterface::getProtocolTypeText(QSharedPointer<Protocol> portProtocol) const\n{\n    QString protocolType(portProtocol->getProtocolType());\n    if (protocolType.compare(QLatin1String(\"tlm\"), Qt::CaseSensitive) != 0)\n    {\n        protocolType = portProtocol->getCustomProtocolType();\n    }\n\n    return protocolType;\n} \n\n//-----------------------------------------------------------------------------\n// Function: PortAbstractionInterface::setProtocolType()\n//-----------------------------------------------------------------------------\nbool PortAbstractionInterface::setProtocolType(int const& portIndex, std::string const& newProtocolType)\n{\n    QSharedPointer<Protocol> selectedProtocol = getOrCreateProtocol(portIndex);\n    if (!selectedProtocol)\n    {\n        return false;\n    }\n\n    selectedProtocol->setProtocolType(QString::fromStdString(newProtocolType));\n    removeEmptyProtocol(portIndex, selectedProtocol);\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortAbstractionInterface::getProtocol()\n//-----------------------------------------------------------------------------\nQSharedPointer<Protocol> PortAbstractionInterface::getOrCreateProtocol(int const& signalIndex) const\n{\n    QSharedPointer<SignalRow> selectedSignal = getSignal(signalIndex);\n    if (selectedSignal && selectedSignal->transactional_)\n    {\n        QSharedPointer<Protocol> portProtocol = selectedSignal->transactional_->getProtocol();\n        if (!portProtocol)\n        {\n            portProtocol = QSharedPointer<Protocol>(new Protocol());\n            selectedSignal->transactional_->setProtocol(portProtocol);\n        }\n\n        return portProtocol;\n    }\n\n    return QSharedPointer<Protocol>();\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortAbstractionInterface::removeEmptyProtocol()\n//-----------------------------------------------------------------------------\nvoid PortAbstractionInterface::removeEmptyProtocol(int const& signalIndex, QSharedPointer<Protocol> signalProtocol)\n{\n    if (signalProtocol && portProcotolTypeIsEmpty(signalProtocol) &&\n        signalProtocol->getPayloadName().isEmpty() && signalProtocol->getPayloadType().isEmpty() &&\n        signalProtocol->getPayloadExtension().isEmpty())\n    {\n        QSharedPointer<PortAbstractionInterface::SignalRow> containingSignal = getSignal(signalIndex);\n        if (containingSignal)\n        {\n            containingSignal->transactional_->setProtocol(QSharedPointer<Protocol>());\n        }\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortAbstractionInterface::portProcotolTypeIsEmpty()\n//-----------------------------------------------------------------------------\nbool PortAbstractionInterface::portProcotolTypeIsEmpty(QSharedPointer<Protocol> portProtocol) const\n{\n    return portProtocol->getProtocolType().isEmpty() ||\n        (portProtocol->getProtocolType().compare(QLatin1String(\"custom\"), Qt::CaseInsensitive) == 0 &&\n            portProtocol->getCustomProtocolType().isEmpty());\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortAbstractionInterface::getPayloadName()\n//-----------------------------------------------------------------------------\nstd::string PortAbstractionInterface::getPayloadName(int const& portIndex)\n{\n    QSharedPointer<SignalRow> selectedSignal = getSignal(portIndex);\n    if (selectedSignal && selectedSignal->transactional_ && selectedSignal->transactional_->getProtocol())\n    {\n        QSharedPointer<Protocol> protocol = selectedSignal->transactional_->getProtocol();\n        return protocol->getPayloadName().toStdString();\n    }\n\n    return std::string(\"\");\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortAbstractionInterface::setPayloadName()\n//-----------------------------------------------------------------------------\nbool PortAbstractionInterface::setPayloadName(int const& portIndex, std::string const& newPayloadName)\n{\n    QSharedPointer<Protocol> selectedProtocol = getOrCreateProtocol(portIndex);\n    if (!selectedProtocol)\n    {\n        return false;\n    }\n\n    selectedProtocol->setPayloadName(QString::fromStdString(newPayloadName));\n    if (newPayloadName.empty())\n    {\n        removeEmptyProtocol(portIndex, selectedProtocol);\n    }\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortAbstractionInterface::getPayloadType()\n//-----------------------------------------------------------------------------\nstd::string PortAbstractionInterface::getPayloadType(int const& portIndex)\n{\n    QSharedPointer<SignalRow> selectedSignal = getSignal(portIndex);\n    if (selectedSignal && selectedSignal->transactional_ && selectedSignal->transactional_->getProtocol())\n    {\n        QSharedPointer<Protocol> protocol = selectedSignal->transactional_->getProtocol();\n        return protocol->getPayloadType().toStdString();\n    }\n\n    return std::string(\"\");\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortAbstractionInterface::setPayloadType()\n//-----------------------------------------------------------------------------\nbool PortAbstractionInterface::setPayloadType(int const& portIndex, std::string const& newPayloadType)\n{\n    QSharedPointer<Protocol> selectedProtocol = getOrCreateProtocol(portIndex);\n    if (!selectedProtocol)\n    {\n        return false;\n    }\n\n    QString payloadType = QString::fromStdString(newPayloadType);\n    if (payloadType.compare(QStringLiteral(\"none\"), Qt::CaseInsensitive) == 0)\n    {\n        payloadType = QStringLiteral(\"\");\n    }\n    selectedProtocol->setPayloadType(payloadType);\n    if (payloadType.isEmpty())\n    {\n        removeEmptyProtocol(portIndex, selectedProtocol);\n    }\n\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortAbstractionInterface::getPayloadExtension()\n//-----------------------------------------------------------------------------\nstd::string PortAbstractionInterface::getPayloadExtension(int const& portIndex)\n{\n    QSharedPointer<SignalRow> selectedSignal = getSignal(portIndex);\n    if (selectedSignal && selectedSignal->transactional_ && selectedSignal->transactional_->getProtocol())\n    {\n        QSharedPointer<Protocol> protocol = selectedSignal->transactional_->getProtocol();\n        return protocol->getPayloadExtension().toStdString();\n    }\n\n    return std::string(\"\");\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortAbstractionInterface::setPayloadExtension()\n//-----------------------------------------------------------------------------\nbool PortAbstractionInterface::setPayloadExtension(int const& portIndex, std::string const& newPayloadExtension)\n{\n    QSharedPointer<Protocol> selectedProtocol = getOrCreateProtocol(portIndex);\n    if (!selectedProtocol)\n    {\n        return false;\n    }\n\n    selectedProtocol->setPayloadExtension(QString::fromStdString(newPayloadExtension), false);\n    if (newPayloadExtension.empty())\n    {\n        removeEmptyProtocol(portIndex, selectedProtocol);\n    }\n\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortAbstractionInterface:: WirePort()\n//-----------------------------------------------------------------------------\nvoid PortAbstractionInterface::addWirePort(std::string const& newPortName)\n{\n    QString uniqueNewName(getUniqueName(newPortName, DEFAULT_NAME));\n\n    QSharedPointer<PortAbstractionInterface::SignalRow> newPort(\n        new PortAbstractionInterface::SignalRow(true, false));\n    newPort->abstraction_ = QSharedPointer<PortAbstraction>(new PortAbstraction());\n    newPort->abstraction_->setLogicalName(uniqueNewName);\n    newPort->abstraction_->setWire(QSharedPointer<WireAbstraction>(new WireAbstraction()));\n    newPort->wire_ = QSharedPointer<WirePort>(new WirePort());    \n    \n    signals_.append(newPort);\n    ports_->append(newPort->abstraction_);\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortAbstractionInterface::addTransactionalPort()\n//-----------------------------------------------------------------------------\nvoid PortAbstractionInterface::addTransactionalPort(std::string const& newPortName)\n{\n    QString uniqueNewName = getUniqueName(newPortName, DEFAULT_NAME);\n\n    QSharedPointer<PortAbstractionInterface::SignalRow> newPort(\n        new PortAbstractionInterface::SignalRow(false, true));\n    newPort->abstraction_ = QSharedPointer<PortAbstraction>(new PortAbstraction());\n    newPort->abstraction_->setLogicalName(uniqueNewName);\n    newPort->abstraction_->setTransactional(\n        QSharedPointer<TransactionalAbstraction>(new TransactionalAbstraction()));\n    newPort->transactional_ = QSharedPointer<TransactionalPort>(new TransactionalPort());\n\n    signals_.append(newPort);\n    ports_->append(newPort->abstraction_);\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortAbstractionInterface::addModeSpecificWireSignal()\n//-----------------------------------------------------------------------------\nvoid PortAbstractionInterface::addModeSpecificWireSignal(std::string const& portName,\n    General::InterfaceMode const& newMode)\n{\n    if (newMode == General::SYSTEM || !modeExistsForPort(newMode, QString::fromStdString(portName)))\n    {\n        QSharedPointer<PortAbstraction> selectedPort = getPort(portName);\n        QSharedPointer<PortAbstractionInterface::SignalRow> newSignal;\n        if (selectedPort.isNull())\n        {\n            addWirePort(portName);\n            selectedPort = ports_->last();\n            newSignal = signals_.last();\n        }\n        else\n        {\n            newSignal = constructCopySignal(selectedPort, true, false);\n            signals_.append(newSignal);\n        }\n\n        newSignal->mode_ = newMode;\n        newSignal->wire_->setSystemGroup(\"\");\n\n        if (newMode != General::SYSTEM)\n        {\n            General::InterfaceMode opposingSignal = General::MASTER;\n            if (newMode == General::MASTER)\n            {\n                opposingSignal = General::SLAVE;\n            }\n            else if (newMode == General::INITIATOR)\n            {\n                opposingSignal = General::TARGET;\n            }\n            else if (newMode == General::TARGET)\n            {\n                opposingSignal = General::INITIATOR;\n            }\n\n            DirectionTypes::Direction mirroredDirection =\n                getMirroredDirectionForSignal(selectedPort->getLogicalName(), opposingSignal);\n            if (mirroredDirection != DirectionTypes::DIRECTION_INVALID)\n            {\n                newSignal->wire_->setDirection(mirroredDirection);\n            }\n        }\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortAbstractionInterface::addWireSystemSignal()\n//-----------------------------------------------------------------------------\nvoid PortAbstractionInterface::addWireSystemSignal(std::string const& portName, std::string const& systemGroup)\n{\n    QSharedPointer<PortAbstraction> selectedPort = getPort(portName);\n    QSharedPointer<PortAbstractionInterface::SignalRow> newSignal;\n    \n    if (selectedPort.isNull())\n    {\n        addWirePort(portName);\n        selectedPort = ports_->last();\n        newSignal = signals_.last();\n    }\n    else\n    {\n        newSignal = constructCopySignal(selectedPort, true, false);        \n        signals_.append(newSignal);\n    }\n\n    newSignal->mode_ = General::SYSTEM;\n    newSignal->wire_->setSystemGroup(QString::fromStdString(systemGroup));\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortAbstractionInterface::addModeSpecificTransactionalSignal()\n//-----------------------------------------------------------------------------\nvoid PortAbstractionInterface::addModeSpecificTransactionalSignal(std::string const& portName,\n    General::InterfaceMode const& newMode)\n{\n    if (newMode == General::SYSTEM || !modeExistsForPort(newMode, QString::fromStdString(portName)))\n    {\n        QSharedPointer<PortAbstraction> selectedPort = getPort(portName);\n        QSharedPointer<PortAbstractionInterface::SignalRow> newSignal;\n        if (selectedPort.isNull())\n        {\n            addTransactionalPort(portName);\n            selectedPort = ports_->last();\n            newSignal = signals_.last();\n        }\n        else\n        {\n            newSignal = constructCopySignal(selectedPort, false, true);\n            signals_.append(newSignal);\n        }\n\n        newSignal->mode_ = newMode;\n        newSignal->transactional_->setSystemGroup(\"\");\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortAbstractionInterface::addTransactionalSystemSignal()\n//-----------------------------------------------------------------------------\nvoid PortAbstractionInterface::addTransactionalSystemSignal(std::string const& portName,\n    std::string const& systemGroup)\n{\n    QSharedPointer<PortAbstraction> selectedPort = getPort(portName);\n    QSharedPointer<PortAbstractionInterface::SignalRow> newSignal = constructCopySignal(selectedPort, false, true);\n    newSignal->mode_ = General::SYSTEM;\n    newSignal->transactional_->setSystemGroup(QString::fromStdString(systemGroup));\n\n    signals_.append(newSignal);\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortAbstractionInterface::modeExistsForPort()\n//-----------------------------------------------------------------------------\nbool PortAbstractionInterface::modeExistsForPort(General::InterfaceMode const& mode, QString const& portName,\n    QString const& systemGroup /* = \"\" */) const\n{\n    General::InterfaceMode initiatorMode = General::INITIATOR;\n    General::InterfaceMode targetMode = General::TARGET;\n    General::InterfaceMode mirroredInitiatorMode = General::MIRRORED_INITIATOR;\n    General::InterfaceMode mirroredTargetMode = General::MIRRORED_TARGET;\n\n    if (abstractionStandardRevision_ != Document::Revision::Std22)\n    {\n        initiatorMode = General::MASTER;\n        targetMode = General::SLAVE;\n        mirroredInitiatorMode = General::MIRRORED_MASTER;\n        mirroredTargetMode = General::MIRRORED_SLAVE;\n    }\n\n    General::InterfaceMode selectedMode = mode;\n    if (selectedMode == mirroredInitiatorMode)\n    {\n        selectedMode = initiatorMode;\n    }\n    else if (selectedMode == mirroredTargetMode)\n    {\n        selectedMode = targetMode;\n    }\n    else if (selectedMode == General::MIRRORED_SYSTEM)\n    {\n        selectedMode = General::SYSTEM;\n    }\n\n    for (auto signal : signals_)\n    {\n        if (signal->abstraction_->getLogicalName().compare(portName) == 0 && signal->mode_ == selectedMode)\n        {\n            if (selectedMode == General::SYSTEM)\n            {\n                if (systemGroup.isEmpty() ||\n                    (signal->wire_ && signal->wire_->getSystemGroup() == systemGroup) ||\n                    (signal->transactional_ && signal->transactional_->getSystemGroup() == systemGroup))\n                {\n                    return true;\n                }\n            }\n            else\n            {\n                return true;\n            }\n        }\n    }\n\n    return false;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortAbstractionInterface::constructCopySignal()\n//-----------------------------------------------------------------------------\nQSharedPointer<PortAbstractionInterface::SignalRow> PortAbstractionInterface::constructCopySignal(\n    QSharedPointer<PortAbstraction> port, bool isWire, bool isTransactional) const\n{\n    QSharedPointer<PortAbstractionInterface::SignalRow> newSignal(\n        new PortAbstractionInterface::SignalRow(isWire, isTransactional));\n    newSignal->abstraction_ = port;\n\n    return newSignal;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortAbstractionInterface::getMirroredDirectionForSignal()\n//-----------------------------------------------------------------------------\nDirectionTypes::Direction PortAbstractionInterface::getMirroredDirectionForSignal(QString const& portName,\n    General::InterfaceMode const& opposingMode) const\n{\n    for (auto signal : signals_)\n    {\n        if (signal->mode_ == opposingMode && signal->abstraction_->getLogicalName().compare(portName) == 0)\n        {\n            return DirectionTypes::convert2Mirrored(signal->wire_->getDirection());\n        }\n    }\n\n    return DirectionTypes::DIRECTION_INVALID;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortAbstractionInterface::getQualifierAttributeType()\n//-----------------------------------------------------------------------------\nQualifier::Attribute PortAbstractionInterface::getQualifierAttributeType(std::string const& attributeName) const\n{\n    if (attributeName == \"resetLevel\")\n    {\n        return Qualifier::Attribute::ResetLevel;\n    }\n    else if (attributeName == \"clockEnableLevel\")\n    {\n        return Qualifier::Attribute::ClockEnableLevel;\n    }\n    else if (attributeName == \"powerEnableLevel\")\n    {\n        return Qualifier::Attribute::PowerEnableLevel;\n    }\n    else if (attributeName == \"powerDomainReference\")\n    {\n        return Qualifier::Attribute::PowerDomainReference;\n    }\n    else if (attributeName == \"flowType\")\n    {\n        return Qualifier::Attribute::FlowType;\n    }\n    else if (attributeName == \"userFlowType\")\n    {\n        return Qualifier::Attribute::UserFlowType;\n    }\n    else \n    {\n        return Qualifier::Attribute::UserDefined;\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortAbstractionInterface::getAllReferencesToIdInItem()\n//-----------------------------------------------------------------------------\nint PortAbstractionInterface::getAllReferencesToIdInItem(const std::string&, std::string const&) const\n{\n    return 0; /* AbstractionPortsModel uses getAllReferencesToIdInRow() instead */\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortAbstractionInterface::removeSignal()\n//-----------------------------------------------------------------------------\nbool PortAbstractionInterface::removeSignal(int const& signalIndex)\n{\n    QSharedPointer<SignalRow> removedSignal = getSignal(signalIndex);\n    if (!removedSignal)\n    {\n        return false;\n    }\n\n    signals_.removeAll(removedSignal);\n\n    bool removeAbstraction = true;\n    for (auto currentSignal : signals_)\n    {\n        if (currentSignal->abstraction_ == removedSignal->abstraction_)\n        {\n            removeAbstraction = false;\n        }\n    }\n\n    if (removeAbstraction)\n    {\n        ports_->removeOne(removedSignal->abstraction_);\n    }\n\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortAbstractionInterface::portIsWire()\n//-----------------------------------------------------------------------------\nbool PortAbstractionInterface::portIsWire(std::string const& portName) const\n{\n    QSharedPointer<PortAbstraction> selectedPort = getPort(portName);\n    if (selectedPort && selectedPort->getWire())\n    {\n        return true;\n    }\n\n    return false;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortAbstractionInterface::portIsTransactional()\n//-----------------------------------------------------------------------------\nbool PortAbstractionInterface::portIsTransactional(std::string const& portName) const\n{\n    QSharedPointer<PortAbstraction> selectedPort = getPort(portName);\n    if (selectedPort && selectedPort->getTransactional())\n    {\n        return true;\n    }\n\n    return false;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortAbstractionInterface::getIconPathForSignal()\n//-----------------------------------------------------------------------------\nstd::string PortAbstractionInterface::getIconPathForSignal(int const& signalIndex) const\n{\n    std::string path(\"\");\n    QSharedPointer<SignalRow> selectedSignal = getSignal(signalIndex);\n    if (!selectedSignal)\n    {\n        path = getIconPathForMissingPort();\n    }\n    else\n    {\n        if (selectedSignal->wire_)\n        {\n            DirectionTypes::Direction direction = selectedSignal->wire_->getDirection();\n            if (direction != DirectionTypes::DIRECTION_INVALID)\n            {\n                path = getIconPathForDirection(direction);\n            }\n        }\n        else if (selectedSignal->transactional_)\n        {\n            QString initiative(selectedSignal->transactional_->getInitiative());\n            if (!initiative.isEmpty())\n            {\n                path = getIconPathForInitiative(initiative);\n            }\n        }\n    }\n\n    return path;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortAbstractionInterface::getIconPathForSignal()\n//-----------------------------------------------------------------------------\nstd::string PortAbstractionInterface::getIconPathForSignal(std::string const& portName,\n    std::string const& interfaceMode, std::string const& systemGroup) const\n{\n    std::string path(\"\");\n\n    QSharedPointer<PortAbstraction> port = getPort(portName);\n    if (!port)\n    {\n        path = getIconPathForMissingPort();\n    }\n    else\n    {\n        General::InterfaceMode busMode = General::str2Interfacemode(QString::fromStdString(interfaceMode),\n            General::INTERFACE_MODE_COUNT);\n        if (port && busMode != General::INTERFACE_MODE_COUNT)\n        {\n            if (port->getWire())\n            {\n                DirectionTypes::Direction portDirection =\n                    port->getWire()->getDirection(busMode, QString::fromStdString(systemGroup));\n                path = getIconPathForDirection(portDirection);\n            }\n            else if (port->getTransactional())\n            {\n                QString portInitiative =\n                    port->getTransactional()->getInitiative(busMode, QString::fromStdString(systemGroup));\n                path = getIconPathForInitiative(portInitiative);\n            }\n        }\n    }\n\n    return path;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortAbstractionInterface::SignalRow::SignalRow()\n//-----------------------------------------------------------------------------\nPortAbstractionInterface::SignalRow::SignalRow(bool isWirePort, bool isTransactionalPort)\n{\n    if (isWirePort)\n    {\n        wire_ = QSharedPointer<WirePort>(new WirePort());\n    }\n    else if (isTransactionalPort)\n    {\n        transactional_ = QSharedPointer<TransactionalPort>(new TransactionalPort());\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortAbstractionInterface::SignalRow::operator==()\n//-----------------------------------------------------------------------------\nbool PortAbstractionInterface::SignalRow::operator==(SignalRow const& other) const\n{\n    bool isEquals = false;\n    if (wire_)\n    {\n        isEquals = abstraction_->getLogicalName() == other.abstraction_->getLogicalName() &&\n            mode_ == other.mode_ && (mode_ != General::SYSTEM\n                || wire_->getSystemGroup() == other.wire_->getSystemGroup());\n    }\n    else if (transactional_)\n    {\n        isEquals = abstraction_->getLogicalName() == other.abstraction_->getLogicalName() &&\n            mode_ == other.mode_ && (mode_ != General::SYSTEM ||\n                transactional_->getSystemGroup() == other.transactional_->getSystemGroup());\n    }\n\n    return isEquals;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortAbstractionInterface::SignalRow::operator!=()\n//-----------------------------------------------------------------------------\nbool PortAbstractionInterface::SignalRow::operator!=(SignalRow const& other) const\n{\n    bool isNotEquals = false;\n    if (wire_)\n    {\n        isNotEquals = abstraction_->getLogicalName() != other.abstraction_->getLogicalName() ||\n            mode_ != other.mode_ || wire_->getSystemGroup() != other.wire_->getSystemGroup();\n    }\n    else if (transactional_)\n    {\n        isNotEquals = abstraction_->getLogicalName() != other.abstraction_->getLogicalName() ||\n            mode_ != other.mode_ || transactional_->getSystemGroup() != other.transactional_->getSystemGroup();\n    }\n\n    return isNotEquals;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortAbstractionInterface::SignalRow::operator<()\n//-----------------------------------------------------------------------------\nbool PortAbstractionInterface::SignalRow::operator<(const SignalRow& other) const\n{\n    // Order by name, mode and system group.\n    if (abstraction_->getLogicalName() == other.abstraction_->getLogicalName())\n    {\n        if (mode_ == other.mode_)\n        {\n            if (wire_)\n            {\n                return wire_->getSystemGroup() < other.wire_->getSystemGroup();\n            }\n            else if (transactional_)\n            {\n                return transactional_->getSystemGroup() < other.transactional_->getSystemGroup();\n            }\n        }\n\n        return mode_ < other.mode_;\n    }\n    else\n    {\n        return abstraction_->getLogicalName() < other.abstraction_->getLogicalName();\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortAbstractionInterface::save()\n//-----------------------------------------------------------------------------\nvoid PortAbstractionInterface::save()\n{\n    QVector<QSharedPointer<PortAbstraction> > savedPorts;\n    for (int i = 0; i < itemCount(); i++)\n    {\n        QSharedPointer<PortAbstractionInterface::SignalRow> currentSignal = signals_.at(i);\n        QSharedPointer<PortAbstraction> currentPort = currentSignal->abstraction_;\n\n        if (!savedPorts.contains(currentPort))\n        {\n            QSharedPointer<WireAbstraction> wire = currentPort->getWire();\n            QSharedPointer<TransactionalAbstraction> transactional = currentPort->getTransactional();\n            if (wire)\n            {\n                currentPort->getWire()->setInitiatorPort(QSharedPointer<WirePort>());\n                currentPort->getWire()->setTargetPort(QSharedPointer<WirePort>());\n                currentPort->getWire()->getSystemPorts()->clear();\n\n                // Save the port for the first mode.\n                savePort(currentPort, i);\n\n                // Save different modes for the port abstraction.\n                for (int j = i + 1; j < itemCount(); j++)\n                {\n                    if (signals_.at(j)->abstraction_ == currentPort)\n                    {\n                        savePort(currentPort, j);\n                    }\n                }\n            }\n            if (transactional)\n            {\n                transactional->setInitiatorPort(QSharedPointer<TransactionalPort>());\n                transactional->setTargetPort(QSharedPointer<TransactionalPort>());\n                transactional->getSystemPorts()->clear();\n\n                // Save the port for the first mode.\n                savePort(currentPort, i);\n\n                // Save different modes for the port abstraction.\n                for (int j = i + 1; j < itemCount(); j++)\n                {\n                    if (signals_.at(j)->abstraction_ == currentPort)\n                    {\n                        savePort(currentPort, j);\n                    }\n                }\n            }\n\n            savedPorts.append(currentPort);\n        }\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortAbstractionInterface::savePort()\n//-----------------------------------------------------------------------------\nvoid PortAbstractionInterface::savePort(QSharedPointer<PortAbstraction> portAbs, int i)\n{\n    QSharedPointer<PortAbstractionInterface::SignalRow> sourceSignal = signals_.at(i);\n\n    General::InterfaceMode initiatorMode = General::INITIATOR;\n    General::InterfaceMode targetMode = General::TARGET;\n    if (abstractionStandardRevision_ != Document::Revision::Std22)\n    {\n        initiatorMode = General::MASTER;\n        targetMode = General::SLAVE;\n    }\n\n    if (sourceSignal->wire_)\n    {\n        // Set the wirePort placement according to the mode in the table.\n        if (sourceSignal->mode_ == initiatorMode)\n        {\n            portAbs->getWire()->setInitiatorPort(sourceSignal->wire_);\n        }\n        else if (sourceSignal->mode_ == targetMode)\n        {\n            portAbs->getWire()->setTargetPort(sourceSignal->wire_);\n        }\n        else if (sourceSignal->mode_ == General::SYSTEM)\n        {\n            portAbs->getWire()->addSystemPort(sourceSignal->wire_);\n        }\n    }\n    if (sourceSignal->transactional_)\n    {\n        if (sourceSignal->mode_ == initiatorMode)\n        {\n            portAbs->getTransactional()->setInitiatorPort(sourceSignal->transactional_);\n        }\n        else if (sourceSignal->mode_ == targetMode)\n        {\n            portAbs->getTransactional()->setTargetPort(sourceSignal->transactional_);\n        }\n        else if (sourceSignal->mode_ == General::SYSTEM)\n        {\n            portAbs->getTransactional()->addSystemPort(sourceSignal->transactional_);\n        }\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortAbstractionInterface::portHasMode()\n//-----------------------------------------------------------------------------\nbool PortAbstractionInterface::portHasMode(std::string const& portName, std::string const& interfaceMode,\n    std::string const& systemGroup) const\n{\n    General::InterfaceMode busMode =\n        General::str2Interfacemode(QString::fromStdString(interfaceMode), General::INTERFACE_MODE_COUNT);\n\n    return modeExistsForPort(busMode, QString::fromStdString(portName), QString::fromStdString(systemGroup));\n}\n"
  },
  {
    "path": "KactusAPI/interfaces/common/AbstractParameterInterface.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: AbstractParametersInterface.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 22.09.2020\n//\n// Description:\n// Interface for editing parameters.\n//-----------------------------------------------------------------------------\n\n#include \"AbstractParameterInterface.h\"\n\n#include <IPXACTmodels/common/Choice.h>\n#include <IPXACTmodels/common/Parameter.h>\n#include <IPXACTmodels/common/validators/ParameterValidator.h>\n\n\n#include <IPXACTmodels/utilities/Search.h>\n\nnamespace\n{\n    QString const ARRAY_LEFT_ATTRIBTE = QLatin1String(\"kactus2:arrayLeft\");\n    QString const ARRAY_RIGHT_ATTRIBUTE = QLatin1String(\"kactus2:arrayRight\");\n};\n\n//-----------------------------------------------------------------------------\n// Function: AbstractParameterInterface::AbstractParameterInterface()\n//-----------------------------------------------------------------------------\nAbstractParameterInterface::AbstractParameterInterface(QSharedPointer<ParameterValidator> validator,\n    QSharedPointer<ExpressionParser> expressionParser, QSharedPointer<ExpressionFormatter> expressionFormatter):\nParameterizableInterface(expressionParser, expressionFormatter),\nparameterValidator_(validator)\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: AbstractParameterInterface::setChoices()\n//-----------------------------------------------------------------------------\nvoid AbstractParameterInterface::setChoices(QSharedPointer<QList<QSharedPointer<Choice> > > newChoices)\n{\n    choices_ = newChoices;\n}\n\n//-----------------------------------------------------------------------------\n// Function: AbstractParameterInterface::setName()\n//-----------------------------------------------------------------------------\nbool AbstractParameterInterface::setName(std::string const& currentName, std::string const& newName)\n{\n    QSharedPointer<Parameter> editedParameter = getParameter(currentName);\n    if (editedParameter && nameHasChanged(newName, currentName))\n    {\n        QString uniqueNewName = getUniqueName(newName, \"parameter\");\n\n        editedParameter->setName(uniqueNewName);\n        return true;\n    }\n    else\n    {\n        return false;\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: AbstractParameterInterface::getDisplayName()\n//-----------------------------------------------------------------------------\nstd::string AbstractParameterInterface::getDisplayName(std::string const& parameterName) const\n{\n    QSharedPointer<Parameter> editedParameter = getParameter(parameterName);\n    if (editedParameter)\n    {\n        return editedParameter->displayName().toStdString();\n    }\n\n    return std::string();\n}\n\n//-----------------------------------------------------------------------------\n// Function: AbstractParameterInterface::setDisplayName()\n//-----------------------------------------------------------------------------\nbool AbstractParameterInterface::setDisplayName(std::string const& parameterName, std::string const& newDisplayName)\n{\n    QSharedPointer<Parameter> editedParameter = getParameter(parameterName);\n    if (!editedParameter)\n    {\n        return false;\n    }\n\n    editedParameter->setDisplayName(QString::fromStdString(newDisplayName));\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: AbstractParameterInterface::getType()\n//-----------------------------------------------------------------------------\nstd::string AbstractParameterInterface::getType(std::string const& parameterName) const\n{\n    QSharedPointer<Parameter> editedParameter = getParameter(parameterName);\n    if (editedParameter)\n    {\n        return editedParameter->getType().toStdString();\n    }\n\n    return std::string();\n}\n\n//-----------------------------------------------------------------------------\n// Function: AbstractParameterInterface::setType()\n//-----------------------------------------------------------------------------\nbool AbstractParameterInterface::setType(std::string const& parameterName, std::string const& newType)\n{\n    QSharedPointer<Parameter> editedParameter = getParameter(parameterName);\n    if (!editedParameter)\n    {\n        return false;\n    }\n\n    editedParameter->setType(QString::fromStdString(newType));\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: AbstractParameterInterface::getBitWidthLeftValue()\n//-----------------------------------------------------------------------------\nstd::string AbstractParameterInterface::getBitWidthLeftValue(std::string const& parameterName,\n    int const& baseNumber) const\n{\n    QSharedPointer<Parameter> editedParameter = getParameter(parameterName);\n    if (editedParameter)\n    {\n        return parseExpressionToBaseNumber(editedParameter->getVectorLeft(), baseNumber).toStdString();\n    }\n\n    return std::string();\n}\n\n//-----------------------------------------------------------------------------\n// Function: AbstractParameterInterface::getBitWidthLeftFormattedExpression()\n//-----------------------------------------------------------------------------\nstd::string AbstractParameterInterface::getBitWidthLeftFormattedExpression(std::string const& parameterName) const\n{\n    QSharedPointer<Parameter> editedParameter = getParameter(parameterName);\n    if (editedParameter)\n    {\n        return formattedValueFor(editedParameter->getVectorLeft()).toStdString();\n    }\n\n    return std::string();\n}\n\n//-----------------------------------------------------------------------------\n// Function: AbstractParameterInterface::getBitWidthLeftExpression()\n//-----------------------------------------------------------------------------\nstd::string AbstractParameterInterface::getBitWidthLeftExpression(std::string const& parameterName) const\n{\n    QSharedPointer<Parameter> editedParameter = getParameter(parameterName);\n    if (editedParameter)\n    {\n        return editedParameter->getVectorLeft().toStdString();\n    }\n\n    return std::string();\n}\n\n//-----------------------------------------------------------------------------\n// Function: AbstractParameterInterface::setBitWidthLeft()\n//-----------------------------------------------------------------------------\nbool AbstractParameterInterface::setBitWidthLeft(std::string const& parameterName,\n    std::string const& newBitWidthLeft)\n{\n    QSharedPointer<Parameter> editedParameter = getParameter(parameterName);\n    if (!editedParameter)\n    {\n        return false;\n    }\n\n    editedParameter->setVectorLeft(QString::fromStdString(newBitWidthLeft));\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: AbstractParameterInterface::getBitWidthRightValue()\n//-----------------------------------------------------------------------------\nstd::string AbstractParameterInterface::getBitWidthRightValue(std::string const& parameterName,\n    int const& baseNumber) const\n{\n    QSharedPointer<Parameter> editedParameter = getParameter(parameterName);\n    if (editedParameter)\n    {\n        return parseExpressionToBaseNumber(editedParameter->getVectorRight(), baseNumber).toStdString();\n    }\n\n    return std::string();\n}\n\n//-----------------------------------------------------------------------------\n// Function: AbstractParameterInterface::getBitWidthRightFormattedExpression()\n//-----------------------------------------------------------------------------\nstd::string AbstractParameterInterface::getBitWidthRightFormattedExpression(std::string const& parameterName) const\n{\n    QSharedPointer<Parameter> editedParameter = getParameter(parameterName);\n    if (editedParameter)\n    {\n        return formattedValueFor(editedParameter->getVectorRight()).toStdString();\n    }\n\n    return std::string();\n}\n\n//-----------------------------------------------------------------------------\n// Function: AbstractParameterInterface::getBitWidthRightExpression()\n//-----------------------------------------------------------------------------\nstd::string AbstractParameterInterface::getBitWidthRightExpression(std::string const& parameterName) const\n{\n    QSharedPointer<Parameter> editedParameter = getParameter(parameterName);\n    if (editedParameter)\n    {\n        return editedParameter->getVectorRight().toStdString();\n    }\n\n    return std::string();\n}\n\n//-----------------------------------------------------------------------------\n// Function: AbstractParameterInterface::setBitWidthRight()\n//-----------------------------------------------------------------------------\nbool AbstractParameterInterface::setBitWidthRight(std::string const& parameterName,\n    std::string const& newBitWidthRight)\n{\n    QSharedPointer<Parameter> editedParameter = getParameter(parameterName);\n    if (!editedParameter)\n    {\n        return false;\n    }\n\n    editedParameter->setVectorRight(QString::fromStdString(newBitWidthRight));\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: AbstractParameterInterface::getMinimum()\n//-----------------------------------------------------------------------------\nstd::string AbstractParameterInterface::getMinimum(std::string const& parameterName) const\n{\n    QSharedPointer<Parameter> parameter = getParameter(parameterName);\n    if (parameter)\n    {\n        return parameter->getMinimumValue().toStdString();\n    }\n\n    return std::string();\n}\n\n//-----------------------------------------------------------------------------\n// Function: AbstractParameterInterface::setMinimum()\n//-----------------------------------------------------------------------------\nbool AbstractParameterInterface::setMinimum(std::string const& parameterName, std::string const& newMinimum)\n{\n    QSharedPointer<Parameter> parameter = getParameter(parameterName);\n    if (!parameter)\n    {\n        return false;\n    }\n\n    parameter->setMinimumValue(QString::fromStdString(newMinimum));\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: AbstractParameterInterface::getMaximum()\n//-----------------------------------------------------------------------------\nstd::string AbstractParameterInterface::getMaximum(std::string const& parameterName) const\n{\n    QSharedPointer<Parameter> parameter = getParameter(parameterName);\n    if (parameter)\n    {\n        return parameter->getMaximumValue().toStdString();\n    }\n\n    return std::string();\n}\n\n//-----------------------------------------------------------------------------\n// Function: AbstractParameterInterface::setMaximum()\n//-----------------------------------------------------------------------------\nbool AbstractParameterInterface::setMaximum(std::string const& parameterName, std::string const& newMaximum)\n{\n    QSharedPointer<Parameter> parameter = getParameter(parameterName);\n    if (!parameter)\n    {\n        return false;\n    }\n\n    parameter->setMaximumValue(QString::fromStdString(newMaximum));\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: AbstractParameterInterface::getChoice()\n//-----------------------------------------------------------------------------\nstd::string AbstractParameterInterface::getChoice(std::string const& parameterName) const\n{\n    QSharedPointer<Parameter> parameter = getParameter(parameterName);\n    if (parameter)\n    {\n        return parameter->getChoiceRef().toStdString();\n    }\n\n    return std::string();\n}\n\n//-----------------------------------------------------------------------------\n// Function: AbstractParameterInterface::setChoice()\n//-----------------------------------------------------------------------------\nbool AbstractParameterInterface::setChoice(std::string const& parameterName, std::string const& newChoice)\n{\n    QSharedPointer<Parameter> parameter = getParameter(parameterName);\n    if (!parameter)\n    {\n        return false;\n    }\n\n    parameter->setChoiceRef(QString::fromStdString(newChoice));\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: AbstractParameterInterface::getValue()\n//-----------------------------------------------------------------------------\nstd::string AbstractParameterInterface::getValue(std::string const& parameterName, int const& baseNumber) const\n{\n    QSharedPointer<Parameter> parameter = getParameter(parameterName);\n    if (parameter)\n    {\n        if (parameter->getType() == QStringLiteral(\"string\"))\n        {\n            return parameter->getValue().toStdString();\n        }\n        else\n        {\n            bool expressionIsValid = false;\n            auto value = parseExpressionToBaseNumber(parameter->getValue(), baseNumber, &expressionIsValid).toStdString();\n            \n            return expressionIsValid ? value : std::string(\"x\");\n        }\n    }\n\n    return std::string();\n}\n\n//-----------------------------------------------------------------------------\n// Function: AbstractParameterInterface::getValueFormattedExpression()\n//-----------------------------------------------------------------------------\nstd::string AbstractParameterInterface::getValueFormattedExpression(std::string const& parameterName) const\n{\n    QSharedPointer<Parameter> parameter = getParameter(parameterName);\n    if (parameter)\n    {\n        return evaluateValue(parameter).toStdString();\n    }\n\n    return std::string();\n}\n\n//-----------------------------------------------------------------------------\n// Function: AbstractParameterInterface::evaluateValue()\n//-----------------------------------------------------------------------------\nQString AbstractParameterInterface::evaluateValue(QSharedPointer<Parameter> parameter) const\n{\n    if (!parameter->getChoiceRef().isEmpty())\n    {\n        QSharedPointer<Choice> choice = findChoice(parameter->getChoiceRef());\n\n        if (parameter->getValue().contains('{') && parameter->getValue().contains('}'))\n        {\n            return matchArrayValuesToSelectedChoice(choice, parameter->getValue());\n        }\n\n        else\n        {\n            return findDisplayValueForEnumeration(choice, parameter->getValue());\n        }\n    }\n    else\n    {\n        return formattedValueFor(parameter->getValue());\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: ParametersInterface::findChoice()\n//-----------------------------------------------------------------------------\nQSharedPointer<Choice> AbstractParameterInterface::findChoice(QString const& choiceName) const\n{\n    if (choices_)\n    {\n        return Search::findByName(choiceName, choices_);\n    }\n\n    return nullptr;\n}\n\n//-----------------------------------------------------------------------------\n// Function: AbstractParameterInterface::matchArrayValuesToSelectedChoice()\n//-----------------------------------------------------------------------------\nQString AbstractParameterInterface::matchArrayValuesToSelectedChoice(QSharedPointer<Choice> choice,\n    QString const& arrayValue) const\n{\n    QStringList parameterArray = arrayValue.split(',');\n    parameterArray.first().remove('{');\n    parameterArray.last().remove('}');\n\n    QStringList resultingArray;\n\n    for (QString const& value : parameterArray)\n    {\n        resultingArray.append(findDisplayValueForEnumeration(choice, value));\n    }\n    QString choiceValue = resultingArray.join(',');\n    choiceValue.prepend('{');\n    choiceValue.append('}');\n\n    return choiceValue;\n}\n\n//-----------------------------------------------------------------------------\n// Function: ParametersInterface::findDisplayValueForEnumeration()\n//-----------------------------------------------------------------------------\nQString AbstractParameterInterface::findDisplayValueForEnumeration(QSharedPointer<Choice> choice,\n    QString const& enumerationValue) const\n{\n    QString formattedValue = formattedValueFor(enumerationValue);\n    for (QSharedPointer<Enumeration> enumeration : *choice->enumerations())\n    {\n        QString enumerationFormattedValue = formattedValueFor(enumeration->getValue());\n        if (enumerationFormattedValue == formattedValue && !enumeration->getText().isEmpty())\n        {\n            return enumeration->getText();\n        }\n    }\n\n    QString value = formattedValueFor(enumerationValue);\n\n    for (QSharedPointer<Enumeration> enumeration : *choice->enumerations())\n    {\n        if (enumeration->getValue() == value && !enumeration->getText().isEmpty())\n        {\n            return enumeration->getText();\n        }\n    }\n\n    return value;\n}\n\n//-----------------------------------------------------------------------------\n// Function: AbstractParameterInterface::getValueExpression()\n//-----------------------------------------------------------------------------\nstd::string AbstractParameterInterface::getValueExpression(std::string const& parameterName) const\n{\n    QSharedPointer<Parameter> parameter = getParameter(parameterName);\n    if (parameter)\n    {\n        return parameter->getValue().toStdString();\n    }\n\n    return std::string();\n}\n\n//-----------------------------------------------------------------------------\n// Function: AbstractParameterInterface::setValue()\n//-----------------------------------------------------------------------------\nbool AbstractParameterInterface::setValue(std::string const& parameterName, std::string const& newValue)\n{\n    QSharedPointer<Parameter> parameter = getParameter(parameterName);\n    if (!parameter)\n    {\n        return false;\n    }\n\n    parameter->setValue(QString::fromStdString(newValue));\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: ParametersInterface::getResolve()\n//-----------------------------------------------------------------------------\nstd::string AbstractParameterInterface::getResolve(std::string const& parameterName) const\n{\n    QSharedPointer<Parameter> parameter = getParameter(parameterName);\n    if (parameter)\n    {\n        return parameter->getValueResolve().toStdString();\n    }\n\n    return std::string();\n}\n\n//-----------------------------------------------------------------------------\n// Function: AbstractParameterInterface::setResolve()\n//-----------------------------------------------------------------------------\nbool AbstractParameterInterface::setResolve(std::string const& parameterName, std::string const& newResolve)\n{\n    QSharedPointer<Parameter> parameter = getParameter(parameterName);\n    if (!parameter)\n    {\n        return false;\n    }\n\n    parameter->setValueResolve(QString::fromStdString(newResolve));\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: AbstractParameterInterface::getArrayLeftValue()\n//-----------------------------------------------------------------------------\nstd::string AbstractParameterInterface::getArrayLeftValue(std::string const& parameterName, int const& baseNumber)\nconst\n{\n    QSharedPointer<Parameter> parameter = getParameter(parameterName);\n    if (parameter)\n    {\n        return parseExpressionToBaseNumber(parameter->getAttribute(ARRAY_LEFT_ATTRIBTE), baseNumber).toStdString();\n    }\n\n    return std::string();\n}\n\n//-----------------------------------------------------------------------------\n// Function: AbstractParameterInterface::getArrayLeftFormattedExpression()\n//-----------------------------------------------------------------------------\nstd::string AbstractParameterInterface::getArrayLeftFormattedExpression(std::string const& parameterName) const\n{\n    QSharedPointer<Parameter> parameter = getParameter(parameterName);\n    if (parameter)\n    {\n        return formattedValueFor(parameter->getAttribute(ARRAY_LEFT_ATTRIBTE)).toStdString();\n    }\n\n    return std::string();\n}\n\n//-----------------------------------------------------------------------------\n// Function: AbstractParameterInterface::getArrayLeftExpression()\n//-----------------------------------------------------------------------------\nstd::string AbstractParameterInterface::getArrayLeftExpression(std::string const& parameterName) const\n{\n    QSharedPointer<Parameter> parameter = getParameter(parameterName);\n    if (parameter)\n    {\n        return parameter->getAttribute(ARRAY_LEFT_ATTRIBTE).toStdString();\n    }\n\n    return std::string();\n}\n\n//-----------------------------------------------------------------------------\n// Function: AbstractParameterInterface::setArrayLeft()\n//-----------------------------------------------------------------------------\nbool AbstractParameterInterface::setArrayLeft(std::string const& parameterName, std::string const& newArrayLeft)\n{\n    QSharedPointer<Parameter> parameter = getParameter(parameterName);\n    if (!parameter)\n    {\n        return false;\n    }\n    \n    parameter->setAttribute(ARRAY_LEFT_ATTRIBTE, QString::fromStdString(newArrayLeft));\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: AbstractParameterInterface::getArrayRightValue()\n//-----------------------------------------------------------------------------\nstd::string AbstractParameterInterface::getArrayRightValue(std::string const& parameterName, int const& baseNumber)\nconst\n{\n    QSharedPointer<Parameter> parameter = getParameter(parameterName);\n    if (parameter)\n    {\n        return parseExpressionToBaseNumber(\n            parameter->getAttribute(ARRAY_RIGHT_ATTRIBUTE), baseNumber).toStdString();\n    }\n\n    return std::string();\n}\n\n//-----------------------------------------------------------------------------\n// Function: AbstractParameterInterface::getArrayRightFormattedExpression()\n//-----------------------------------------------------------------------------\nstd::string AbstractParameterInterface::getArrayRightFormattedExpression(std::string const& parameterName) const\n{\n    QSharedPointer<Parameter> parameter = getParameter(parameterName);\n    if (parameter)\n    {\n        return formattedValueFor(parameter->getAttribute(ARRAY_RIGHT_ATTRIBUTE)).toStdString();\n    }\n\n    return std::string();\n}\n\n//-----------------------------------------------------------------------------\n// Function: AbstractParameterInterface::getArrayRightExpression()\n//-----------------------------------------------------------------------------\nstd::string AbstractParameterInterface::getArrayRightExpression(std::string const& parameterName) const\n{\n    QSharedPointer<Parameter> parameter = getParameter(parameterName);\n    if (parameter)\n    {\n        return parameter->getAttribute(ARRAY_RIGHT_ATTRIBUTE).toStdString();\n    }\n\n    return std::string();\n}\n\n//-----------------------------------------------------------------------------\n// Function: AbstractParameterInterface::setArrayRight()\n//-----------------------------------------------------------------------------\nbool AbstractParameterInterface::setArrayRight(std::string const& parameterName, std::string const& newArrayRight)\n{\n    QSharedPointer<Parameter> parameter = getParameter(parameterName);\n    if (!parameter)\n    {\n        return false;\n    }\n\n    parameter->setAttribute(ARRAY_RIGHT_ATTRIBUTE, QString::fromStdString(newArrayRight));\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: AbstractParameterInterface::getID()\n//-----------------------------------------------------------------------------\nstd::string AbstractParameterInterface::getID(std::string const& parameterName) const\n{\n    QSharedPointer<Parameter> parameter = getParameter(parameterName);\n    if (parameter)\n    {\n        return parameter->getValueId().toStdString();\n    }\n\n    return std::string();\n}\n\n//-----------------------------------------------------------------------------\n// Function: AbstractParameterInterface::setID()\n//-----------------------------------------------------------------------------\nbool AbstractParameterInterface::setID(std::string const& parameterName, std::string const& newID)\n{\n    QSharedPointer<Parameter> parameter = getParameter(parameterName);\n    if (!parameter)\n    {\n        return false;\n    }\n\n    parameter->setValueId(QString::fromStdString(newID));\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: AbstractParameterInterface::getUsageCount()\n//-----------------------------------------------------------------------------\nint AbstractParameterInterface::getUsageCount(std::string const& parameterName) const\n{\n    QSharedPointer<Parameter> parameter = getParameter(parameterName);\n    if (parameter)\n    {\n        return parameter->getUsageCount();\n    }\n\n    return 0;\n}\n\n//-----------------------------------------------------------------------------\n// Function: AbstractParameterInterface::setUsageCount()\n//-----------------------------------------------------------------------------\nbool AbstractParameterInterface::setUsageCount(std::string const& parameterName, int const& newUsageCount)\n{\n    QSharedPointer<Parameter> parameter = getParameter(parameterName);\n    if (!parameter)\n    {\n        return false;\n    }\n\n    parameter->setUsageCount(newUsageCount);\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: AbstractParameterInterface::setUsageCount()\n//-----------------------------------------------------------------------------\nbool AbstractParameterInterface::increaseUsageCount(std::string const& parameterName)\n{\n    QSharedPointer<Parameter> parameter = getParameter(parameterName);\n    if (!parameter)\n    {\n        return false;\n    }\n\n    parameter->increaseUsageCount();\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: AbstractParameterInterface::reduceUsageCount()\n//-----------------------------------------------------------------------------\nbool AbstractParameterInterface::reduceUsageCount(std::string const& parameterName)\n{\n    QSharedPointer<Parameter> parameter = getParameter(parameterName);\n    if (!parameter)\n    {\n        return false;\n    }\n\n    parameter->decreaseUsageCount();\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: AbstractParameterInterface::getAllReferencesToIdInItem()\n//-----------------------------------------------------------------------------\nint AbstractParameterInterface::getAllReferencesToIdInItem(const std::string& itemName,\n    std::string const&  valueID) const\n{\n    QSharedPointer<Parameter> parameter = getParameter(itemName);\n\n    QString idString = QString::fromStdString(valueID);\n\n    int referencesInValue = parameter->getValue().count(idString);\n    int referencesInBitWidthLeft = parameter->getVectorLeft().count(idString);\n    int referencesInBitWidthRight = parameter->getVectorRight().count(idString);\n    int referencesInArrayLeft = parameter->getAttribute(\"kactus2:arrayLeft\").count(idString);\n    int referencesinArrayRight = parameter->getAttribute(\"kactus2:arrayRight\").count(idString);\n\n    int totalReferencesToParameter = referencesInValue + referencesInBitWidthLeft + referencesInBitWidthRight +\n        referencesInArrayLeft + referencesinArrayRight;\n\n    return totalReferencesToParameter;\n}\n\n//-----------------------------------------------------------------------------\n// Function: AbstractParameterInterface::getExpressionsInSelectedItems()\n//-----------------------------------------------------------------------------\nstd::vector<std::string> AbstractParameterInterface::getExpressionsInSelectedItems(\n    std::vector<std::string> parameterNames) const\n{\n    std::vector<std::string> expressions;\n\n    for (auto const& name : parameterNames)\n    {\n        QSharedPointer<Parameter> parameter = getParameter(name);\n        if (parameter)\n        {\n            expressions.push_back(parameter->getValue().toStdString());\n            expressions.push_back(parameter->getVectorLeft().toStdString());\n            expressions.push_back(parameter->getVectorRight().toStdString());\n            expressions.push_back(parameter->getAttribute(\"kactus2:arrayLeft\").toStdString());\n            expressions.push_back(parameter->getAttribute(\"kactus2:arrayRight\").toStdString());\n        }\n    }\n\n    return expressions;\n}\n\n//-----------------------------------------------------------------------------\n// Function: AbstractParameterInterface::validateItems()\n//-----------------------------------------------------------------------------\nbool AbstractParameterInterface::validateItems() const\n{\n    for (auto const& parameterName : getItemNames())\n    {\n        QSharedPointer<Parameter> parameter = getParameter(parameterName);\n        if (parameter && !parameterValidator_->validate(parameter))\n        {\n            return false;\n        }\n    }\n\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: AbstractParameterInterface::itemHasValidName()\n//-----------------------------------------------------------------------------\nbool AbstractParameterInterface::itemHasValidName(std::string const& itemName) const\n{\n    return parameterValidator_->hasValidName(getParameter(itemName));\n}\n\n//-----------------------------------------------------------------------------\n// Function: AbstractParameterInterface::hasValidType()\n//-----------------------------------------------------------------------------\nbool AbstractParameterInterface::hasValidType(std::string const& parameterName) const\n{\n    QSharedPointer<Parameter> parameter = getParameter(parameterName);\n    if (parameter)\n    {\n        return parameterValidator_->hasValidValueForType(parameter->getValue(), parameter->getType());\n    }\n\n    return false;\n}\n\n//-----------------------------------------------------------------------------\n// Function: AbstractParameterInterface::hasValidBitWidth()\n//-----------------------------------------------------------------------------\nbool AbstractParameterInterface::hasValidBitWidth(std::string const& parameterName) const\n{\n    QSharedPointer<Parameter> parameter = getParameter(parameterName);\n    if (parameter)\n    {\n        return parameterValidator_->hasValidVector(parameter);\n    }\n\n    return false;\n}\n\n//-----------------------------------------------------------------------------\n// Function: AbstractParameterInterface::hasValidMinimum()\n//-----------------------------------------------------------------------------\nbool AbstractParameterInterface::hasValidMinimum(std::string const& parameterName) const\n{\n    QSharedPointer<Parameter> parameter = getParameter(parameterName);\n    if (parameter)\n    {\n        return parameterValidator_->hasValidMinimumValue(parameter) &&\n            !parameterValidator_->valueIsLessThanMinimum(parameter);\n    }\n\n    return false;\n}\n\n//-----------------------------------------------------------------------------\n// Function: AbstractParameterInterface::hasValidMaximum()\n//-----------------------------------------------------------------------------\nbool AbstractParameterInterface::hasValidMaximum(std::string const& parameterName) const\n{\n    QSharedPointer<Parameter> parameter = getParameter(parameterName);\n    if (parameter)\n    {\n        return parameterValidator_->hasValidMaximumValue(parameter) &&\n            !parameterValidator_->valueIsGreaterThanMaximum(parameter);\n    }\n\n    return false;\n}\n\n//-----------------------------------------------------------------------------\n// Function: AbstractParameterInterface::hasValidChoice()\n//-----------------------------------------------------------------------------\nbool AbstractParameterInterface::hasValidChoice(std::string const& parameterName) const\n{\n    QSharedPointer<Parameter> parameter = getParameter(parameterName);\n    if (parameter)\n    {\n        return parameterValidator_->hasValidChoice(parameter) &&\n            parameterValidator_->hasValidValueForChoice(parameter);\n    }\n\n    return false;\n}\n\n//-----------------------------------------------------------------------------\n// Function: AbstractParameterInterface::hasValidValue()\n//-----------------------------------------------------------------------------\nbool AbstractParameterInterface::hasValidValue(std::string const& parameterName) const\n{\n    QSharedPointer<Parameter> parameter = getParameter(parameterName);\n    if (parameter)\n    {\n        return parameterValidator_->hasValidValue(parameter);\n    }\n\n    return false;\n}\n\n//-----------------------------------------------------------------------------\n// Function: AbstractParameterInterface::hasValidResolve()\n//-----------------------------------------------------------------------------\nbool AbstractParameterInterface::hasValidResolve(std::string const& parameterName) const\n{\n    QSharedPointer<Parameter> parameter = getParameter(parameterName);\n    if (parameter)\n    {\n        return parameterValidator_->hasValidResolve(parameter);\n    }\n\n    return false;\n}\n\n//-----------------------------------------------------------------------------\n// Function: AbstractParameterInterface::hasValidArrayValues()\n//-----------------------------------------------------------------------------\nbool AbstractParameterInterface::hasValidArrayValues(std::string const& parameterName) const\n{\n    QSharedPointer<Parameter> parameter = getParameter(parameterName);\n    if (parameter)\n    {\n        return parameterValidator_->validateArrayValues(parameter->getAttribute(\"kactus2:arrayLeft\"),\n            parameter->getAttribute(\"kactus2:arrayRight\"));\n    }\n\n    return false;\n}\n"
  },
  {
    "path": "KactusAPI/interfaces/common/CommonInterface.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: CommonInterface.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 21.04.2020\n//\n// Description:\n// Common functions for interfaces.\n//-----------------------------------------------------------------------------\n\n#include \"CommonInterface.h\"\n\n//-----------------------------------------------------------------------------\n// Function: CommonInterface::getUniqueName()\n//-----------------------------------------------------------------------------\nQString CommonInterface::getUniqueName(std::string const& newName, std::string const& itemTypeName) const\n{\n    std::string referenceName = newName;\n    if (referenceName.empty())\n    {\n        referenceName = itemTypeName;\n    }\n\n    std::string name = referenceName;\n    int runningNumber = 0;\n    auto const items = getItemNames();\n    while (!nameIsUnique(name, items))\n    {\n        name = referenceName + \"_\" + std::to_string(runningNumber);\n        runningNumber++;\n    }\n\n    return QString::fromStdString(name);\n}\n\n//-----------------------------------------------------------------------------\n// Function: CommonInterface::nameHasChanged()\n//-----------------------------------------------------------------------------\nbool CommonInterface::nameHasChanged(std::string const& newName, std::string const& oldName) const\n{\n    return newName != oldName;\n}\n\n//-----------------------------------------------------------------------------\n// Function: CommonInterface::nameIsUnique()\n//-----------------------------------------------------------------------------\nbool CommonInterface::nameIsUnique(std::string_view name, std::vector<std::string> const& reservedNamed) const\n{\n    return std::find(reservedNamed.cbegin(), reservedNamed.cend(), name) == reservedNamed.cend();\n}\n"
  },
  {
    "path": "KactusAPI/interfaces/common/NameGroupInterface.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: NameGroupInterface.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 21.04.2020\n//\n// Description:\n// Interface for name groups.\n//-----------------------------------------------------------------------------\n\n#include \"NameGroupInterface.h\"\n\n//-----------------------------------------------------------------------------\n// Function: NameGroupInterface::getDisplayName()\n//-----------------------------------------------------------------------------\nstd::string NameGroupInterface::getDisplayName(std::string const& itemName) const\n{\n    if (QSharedPointer<NameGroup> item = getItem(itemName))\n    {\n        return item->displayName().toStdString();\n    }\n\n    return std::string();\n}\n\n//-----------------------------------------------------------------------------\n// Function: NameGroupInterface::setDisplayName()\n//-----------------------------------------------------------------------------\nbool NameGroupInterface::setDisplayName(std::string const& itemName, std::string const& newDisplayName) const\n{\n    if (QSharedPointer<NameGroup> item = getItem(itemName))\n    {\n        item->setDisplayName(QString::fromStdString(newDisplayName));\n        return true;\n    }\n\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: NameGroupInterface::getDescription()\n//-----------------------------------------------------------------------------\nstd::string NameGroupInterface::getDescription(std::string const& itemName) const\n{\n    if (QSharedPointer<NameGroup> item = getItem(itemName))\n    {\n        return item->description().toStdString();\n    }\n\n    return std::string();\n}\n\n//-----------------------------------------------------------------------------\n// Function: NameGroupInterface::setDescription()\n//-----------------------------------------------------------------------------\nbool NameGroupInterface::setDescription(std::string const& itemName, std::string const& newDescription)\n{\n    if (QSharedPointer<NameGroup> item = getItem(itemName))\n    {\n        item->setDescription(QString::fromStdString(newDescription));\n        return true;\n    }\n\n    return false;\n}\n\n//-----------------------------------------------------------------------------\n// Function: NameGroupInterface::getShortDescription()\n//-----------------------------------------------------------------------------\nstd::string NameGroupInterface::getShortDescription(std::string const& itemName) const\n{\n    if (QSharedPointer<NameGroup> item = getItem(itemName))\n    {\n        return item->shortDescription().toStdString();\n    }\n\n    return std::string();\n}\n\n//-----------------------------------------------------------------------------\n// Function: NameGroupInterface::setShortDescription()\n//-----------------------------------------------------------------------------\nbool NameGroupInterface::setShortDescription(std::string const& itemName, std::string const& newShortDescription) const\n{\n    if (QSharedPointer<NameGroup> item = getItem(itemName))\n    {\n        item->shortDescription() = QString::fromStdString(newShortDescription);\n        return true;\n    }\n\n    return false;\n}\n\n//-----------------------------------------------------------------------------\n// Function: NameGroupInterface::NameGroupInterface()\n//-----------------------------------------------------------------------------\nNameGroupInterface::NameGroupInterface():\nCommonInterface()\n{\n\n}\n"
  },
  {
    "path": "KactusAPI/interfaces/common/ParameterizableInterface.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: ParameterizableInterface.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 13.03.2020\n//\n// Description:\n// Interface for parameterizable items.\n//-----------------------------------------------------------------------------\n\n#include <ParameterizableInterface.h>\n\n#include <KactusAPI/include/ExpressionFormatter.h>\n#include <KactusAPI/include/ExpressionParser.h>\n\n#include <IPXACTmodels/common/validators/ValueFormatter.h>\n\n//-----------------------------------------------------------------------------\n// Function: ParameterizableInterface::ParameterizableInterface()\n//-----------------------------------------------------------------------------\nParameterizableInterface::ParameterizableInterface(QSharedPointer<ExpressionParser> expressionParser,\n    QSharedPointer<ExpressionFormatter> expressionFormatter):\nexpressionParser_(expressionParser),\nformatter_(expressionFormatter),\nvalueFormatter_(new ValueFormatter())\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: ParameterizableInterface::formattedValueFor()\n//-----------------------------------------------------------------------------\nQString ParameterizableInterface::formattedValueFor(QString const& expression) const\n{\n    return formatter_->formatReferringExpression(expression);\n}\n\n//-----------------------------------------------------------------------------\n// Function: ParameterizableInterface::parseExpressionToDecimal()\n//-----------------------------------------------------------------------------\nQString ParameterizableInterface::parseExpressionToDecimal(QString const& expression, bool* expressionIsValid /*= nullptr*/) const\n{\n    return expressionParser_->parseExpression(expression, expressionIsValid);\n}\n\n//-----------------------------------------------------------------------------\n// Function: ParameterizableInterface::parseExpressionToBaseNumber()\n//-----------------------------------------------------------------------------\nQString ParameterizableInterface::parseExpressionToBaseNumber(QString const& expression, unsigned int const& baseNumber, bool* expressionIsValid /*= nullptr*/) const\n{\n    if (baseNumber == 0)\n    {\n        return ExpressionFormatter::format(expression, expressionParser_, expressionIsValid);\n    }\n    else\n    {\n        return valueFormatter_->format(parseExpressionToDecimal(expression, expressionIsValid), baseNumber);\n    }\n}\n"
  },
  {
    "path": "KactusAPI/interfaces/common/ParametersInterface.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: ParametersInterface.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 13.03.2020\n//\n// Description:\n// Interface for editing parameters.\n//-----------------------------------------------------------------------------\n\n#include \"ParametersInterface.h\"\n\n#include <IPXACTmodels/common/Parameter.h>\n\n#include <KactusAPI/include/ListHelper.h>\n\nnamespace\n{\n    QString const ARRAY_LEFT_ATTRIBTE = QLatin1String(\"kactus2:arrayLeft\");\n    QString const ARRAY_RIGHT_ATTRIBUTE = QLatin1String(\"kactus2:arrayRight\");\n};\n\n//-----------------------------------------------------------------------------\n// Function: ParametersInterface::ParametersInterface()\n//-----------------------------------------------------------------------------\nParametersInterface::ParametersInterface(QSharedPointer<ParameterValidator> validator,\n    QSharedPointer<ExpressionParser> expressionParser, QSharedPointer<ExpressionFormatter> expressionFormatter):\nAbstractParameterInterface(validator, expressionParser, expressionFormatter)\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: ParametersInterface::setParameters()\n//-----------------------------------------------------------------------------\nvoid ParametersInterface::setParameters(QSharedPointer<QList<QSharedPointer<Parameter> > > newParameters)\n{\n    parameters_ = newParameters;\n}\n\n//-----------------------------------------------------------------------------\n// Function: ParametersInterface::getItemIndex()\n//-----------------------------------------------------------------------------\nint ParametersInterface::getItemIndex(std::string const& itemName) const\n{\n    return ListHelper::itemIndex(itemName, parameters_);\n}\n\n//-----------------------------------------------------------------------------\n// Function: ParametersInterface::getIndexedItemName()\n//-----------------------------------------------------------------------------\nstd::string ParametersInterface::getIndexedItemName(int itemIndex) const\n{\n    if (parameters_ && (itemIndex >= 0 && itemIndex < parameters_->size()))\n    {\n        return parameters_->at(itemIndex)->name().toStdString();\n    }\n\n    return std::string();\n}\n\n//-----------------------------------------------------------------------------\n// Function: ParametersInterface::itemCount()\n//-----------------------------------------------------------------------------\nint ParametersInterface::itemCount() const\n{\n    if (parameters_)\n    {\n        return parameters_->count();\n    }\n\n    return 0;\n}\n\n//-----------------------------------------------------------------------------\n// Function: ParametersInterface::getItemNames()\n//-----------------------------------------------------------------------------\nstd::vector<std::string> ParametersInterface::getItemNames() const\n{\n    if (parameters_)\n    {\n        return ListHelper::listNames(parameters_);\n    }\n\n    return std::vector<std::string>();\n}\n\n//-----------------------------------------------------------------------------\n// Function: ParametersInterface::addParameter()\n//-----------------------------------------------------------------------------\nvoid ParametersInterface::addParameter(int const& row, std::string const& newParameterName)\n{\n    QString parameterName = getUniqueName(newParameterName, \"parameter\");\n\n    QSharedPointer<Parameter> newParameter(new Parameter());\n    newParameter->setName(parameterName);\n\n    parameters_->insert(row, newParameter);\n}\n\n//-----------------------------------------------------------------------------\n// Function: ParametersInterface::removeParameter()\n//-----------------------------------------------------------------------------\nbool ParametersInterface::removeParameter(std::string const& parameterName)\n{\n    QSharedPointer<Parameter> removedParameter = getParameter(parameterName);\n    if (!removedParameter)\n    {\n        return false;\n    }\n\n    return parameters_->removeOne(removedParameter);\n}\n\n//-----------------------------------------------------------------------------\n// Function: ParametersInterface::getItem()\n//-----------------------------------------------------------------------------\nQSharedPointer<NameGroup> ParametersInterface::getItem(std::string const& parameterName) const\n{\n    return getParameter(parameterName);\n}\n\n//-----------------------------------------------------------------------------\n// Function: ParametersInterface::getParameter()\n//-----------------------------------------------------------------------------\nQSharedPointer<Parameter> ParametersInterface::getParameter(std::string const& parameterName) const\n{\n    if (parameters_)\n    {\n        for (auto parameter : *parameters_)\n        {\n            if (parameter->name().toStdString() == parameterName)\n            {\n                return parameter;\n            }\n        }\n    }\n\n    return QSharedPointer<Parameter>();\n}\n"
  },
  {
    "path": "KactusAPI/interfaces/component/AccessPolicyInterface.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: AccessPolicyInterface.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Anton Hagqvist\n// Date: 20.9.2023\n//\n// Description:\n// Interface for editing access policies.\n//-----------------------------------------------------------------------------\n\n#include \"AccessPolicyInterface.h\"\n#include \"ModeReferenceInterface.h\"\n\n#include <IPXACTmodels/common/validators/CommonItemsValidator.h>\n\n#include <IPXACTmodels/Component/AccessPolicy.h>\n#include <IPXACTmodels/Component/ModeReference.h>\n#include <IPXACTmodels/Component/Mode.h>\n\n//-----------------------------------------------------------------------------\n// Function: AccessPolicyInterface::AccessPolicyInterface()\n//-----------------------------------------------------------------------------\nAccessPolicyInterface::AccessPolicyInterface(ModeReferenceInterface* modeRefInterface):\n    modeRefInterface_(modeRefInterface)\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: AccessPolicyInterface::setAccessPolicies()\n//-----------------------------------------------------------------------------\nvoid AccessPolicyInterface::setAccessPolicies(QSharedPointer<QList<QSharedPointer<AccessPolicy> > > accessPolicies)\n{\n    accessPolicies_ = accessPolicies;\n}\n\n//-----------------------------------------------------------------------------\n// Function: AccessPolicyInterface::setAvailableModes()\n//-----------------------------------------------------------------------------\nvoid AccessPolicyInterface::setComponentModes(QSharedPointer<QList<QSharedPointer<Mode> > > componentModes)\n{\n    componentModes_ = componentModes;\n}\n\n//-----------------------------------------------------------------------------\n// Function: AccessPolicyInterface::getAccessPolicyCount()\n//-----------------------------------------------------------------------------\nint AccessPolicyInterface::getAccessPolicyCount() const\n{\n    return accessPolicies_->size();\n}\n\n//-----------------------------------------------------------------------------\n// Function: AccessPolicyInterface::addAccessPolicy()\n//-----------------------------------------------------------------------------\nvoid AccessPolicyInterface::addAccessPolicy(int row)\n{\n    QSharedPointer<AccessPolicy> newAccessPolicy(new AccessPolicy());\n    accessPolicies_->insert(row, newAccessPolicy);\n}\n\n//-----------------------------------------------------------------------------\n// Function: AccessPolicyInterface::removeAccessPolicy()\n//-----------------------------------------------------------------------------\nbool AccessPolicyInterface::removeAccessPolicy(int accessPolicyIndex)\n{\n    if (accessPolicyIndex <= accessPolicies_->size() - 1)\n    {\n        accessPolicies_->removeAt(accessPolicyIndex);\n        return true;\n    }\n\n    return false;\n}\n\n//-----------------------------------------------------------------------------\n// Function: AccessPolicyInterface::setAccess()\n//-----------------------------------------------------------------------------\nbool AccessPolicyInterface::setAccess(std::string const& newAccess, int accessPolicyIndex)\n{\n    if (accessPolicyIndex <= accessPolicies_->size() - 1)\n    {\n        auto newAccessType = AccessTypes::str2Access(QString::fromStdString(newAccess), AccessTypes::ACCESS_COUNT);\n\n        accessPolicies_->at(accessPolicyIndex)->setAccess(newAccessType);\n        return true;\n    }\n\n    return false;\n}\n\n//-----------------------------------------------------------------------------\n// Function: AccessPolicyInterface::getAccessString()\n//-----------------------------------------------------------------------------\nstd::string AccessPolicyInterface::getAccessString(int accessPolicyIndex) const\n{\n    if (accessPolicyIndex <= accessPolicies_->size() - 1)\n    {\n        return AccessTypes::access2Str(accessPolicies_->at(accessPolicyIndex)->getAccess()).toStdString();\n    }\n\n    return std::string();\n}\n\n//-----------------------------------------------------------------------------\n// Function: AccessPolicyInterface::getAccess()\n//-----------------------------------------------------------------------------\nAccessTypes::Access AccessPolicyInterface::getAccess(int accessPolicyIndex) const\n{\n    if (accessPolicyIndex <= accessPolicies_->size() - 1)\n    {\n        return accessPolicies_->at(accessPolicyIndex)->getAccess();\n    }\n\n    return AccessTypes::ACCESS_COUNT;\n}\n\n//-----------------------------------------------------------------------------\n// Function: AccessPolicyInterface::getModeReferenceInterface()\n//-----------------------------------------------------------------------------\nModeReferenceInterface* AccessPolicyInterface::getModeReferenceInterface() const\n{\n    return modeRefInterface_;\n}\n\n//-----------------------------------------------------------------------------\n// Function: AccessPolicyInterface::getAccesPolicyModeReferences()\n//-----------------------------------------------------------------------------\nstd::vector<std::pair<unsigned int, std::string> > AccessPolicyInterface::getAccesPolicyModeReferences(int accessPolicyIndex) const\n{\n    std::vector<std::pair<unsigned int, std::string> > modeRefs;\n    if (accessPolicyIndex >= 0 && accessPolicyIndex < accessPolicies_->size())\n    {\n        auto modeReferences = accessPolicies_->at(accessPolicyIndex)->getModeReferences();\n\n        std::transform(modeReferences->cbegin(), modeReferences->cend(), std::back_inserter(modeRefs),\n            [](auto modeReference)\n            {\n                return std::make_pair(modeReference->getPriority(), modeReference->getReference().toStdString());\n            });\n    }\n\n    return modeRefs;\n}\n\n//-----------------------------------------------------------------------------\n// Function: AccessPolicyInterface::setAccessPolicyModeReferences()\n//-----------------------------------------------------------------------------\nbool AccessPolicyInterface::setAccessPolicyModeReferences(int accessPolicyIndex, \n    std::vector<std::pair<unsigned int, std::string> > const& newModeRefs)\n{\n    if (accessPolicyIndex >= 0 && accessPolicyIndex < accessPolicies_->size())\n    {\n        QSharedPointer<QList<QSharedPointer<ModeReference> > > createdModeRefs(\n            new QList<QSharedPointer<ModeReference> >());\n\n        for (auto const& [priority, reference] : newModeRefs)\n        {\n            QSharedPointer<ModeReference> createdModeRef(new ModeReference());\n            createdModeRef->setReference(QString::fromStdString(reference));\n            createdModeRef->setPriority(priority);\n            createdModeRefs->append(createdModeRef);\n        }\n\n        accessPolicies_->at(accessPolicyIndex)->setModeReferences(createdModeRefs);\n        return true;\n    }\n\n    return false;\n}\n\n//-----------------------------------------------------------------------------\n// Function: AccessPolicyInterface::getModeReferencesInUse()\n//-----------------------------------------------------------------------------\nstd::vector<std::pair<unsigned int, std::string> > AccessPolicyInterface::getModeReferencesInUse(int accessPolicyIndex) const\n{\n    std::vector<std::pair<unsigned int, std::string> > modeRefsInUse;\n\n    int currentIndex = 0;\n    for (auto const& accessPolicy : *accessPolicies_)\n    {\n        // Get all mode references, excluding mode references in given access policy.\n        if (currentIndex != accessPolicyIndex)\n        {\n            auto modeReferences = accessPolicy->getModeReferences();\n            std::transform(modeReferences->cbegin(), modeReferences->cend(), std::back_inserter(modeRefsInUse),\n                [](auto modeReference)\n                {\n                    return std::make_pair(modeReference->getPriority(), modeReference->getReference().toStdString());\n                });\n        }\n        ++currentIndex;\n    }\n\n    return modeRefsInUse;\n}\n\n//-----------------------------------------------------------------------------\n// Function: AccessPolicyInterface::accessPolicyHasValidModeReferences()\n//-----------------------------------------------------------------------------\nbool AccessPolicyInterface::accessPolicyHasValidModeReferences(int accessPolicyIndex) const\n{\n    if (accessPolicyIndex >= 0 && accessPolicyIndex < accessPolicies_->size())\n    {\n        auto accessPolicyModeRefs = accessPolicies_->at(accessPolicyIndex)->getModeReferences();\n\n        // Get mode refs of other access policies.\n        QSharedPointer<QList<QSharedPointer<ModeReference> > > otherModeRefs(\n            new QList<QSharedPointer<ModeReference> >());\n\n        for (int i = 0; i < accessPolicies_->size(); ++i)\n        {\n            if (i != accessPolicyIndex)\n            {\n                auto currentAccessPolicyModeRefs = accessPolicies_->at(i)->getModeReferences();\n                otherModeRefs->append(currentAccessPolicyModeRefs->cbegin(), currentAccessPolicyModeRefs->cend());\n            }\n        }\n\n        return CommonItemsValidator::hasValidModeRefs(accessPolicyModeRefs, otherModeRefs, componentModes_);\n    }\n\n    return false;\n}\n"
  },
  {
    "path": "KactusAPI/interfaces/component/AddressBlockInterface.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: AddressBlockInterface.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 05.05.2020\n//\n// Description:\n// Interface for editing address blocks.\n//-----------------------------------------------------------------------------\n\n#include \"AddressBlockInterface.h\"\n\n#include <AddressBlockExpressionsGatherer.h>\n\n#include <IPXACTmodels/Component/MemoryBlockBase.h>\n#include <IPXACTmodels/Component/AddressBlock.h>\n#include <IPXACTmodels/Component/AccessPolicy.h>\n#include <IPXACTmodels/Component/validators/AddressBlockValidator.h>\n\nnamespace\n{\n    std::string const BLOCK_TYPE = \"addressBlock\";\n};\n\n//-----------------------------------------------------------------------------\n// Function: AddressBlockInterface::AddressBlockInterface()\n//-----------------------------------------------------------------------------\nAddressBlockInterface::AddressBlockInterface(QSharedPointer<AddressBlockValidator> blockValidator,\n    QSharedPointer<ExpressionParser> expressionParser, QSharedPointer<ExpressionFormatter> expressionFormatter,\n    BusInterfaceInterface* busInterface, RegisterInterface* subInterface, ParametersInterface* parameterInterface):\nMemoryBlockInterface(expressionParser, expressionFormatter, busInterface, parameterInterface),\nvalidator_(blockValidator),\nsubInterface_(subInterface)\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: AddressBlockInterface::getValidator()\n//-----------------------------------------------------------------------------\nQSharedPointer<MemoryBlockValidator> AddressBlockInterface::getValidator() const\n{\n    return validator_;\n}\n\n//-----------------------------------------------------------------------------\n// Function: AddressBlockInterface::getDefaultName()\n//-----------------------------------------------------------------------------\nstd::string AddressBlockInterface::getDefaultName() const\n{\n    return BLOCK_TYPE;\n}\n\n//-----------------------------------------------------------------------------\n// Function: AddressBlockInterface::acceptBlock()\n//-----------------------------------------------------------------------------\nbool AddressBlockInterface::acceptBlock(std::string const& blockName) const\n{\n    QSharedPointer<AddressBlock> block = getAddressBlock(blockName);\n    if (block)\n    {\n        return true;\n    }\n\n    return false;\n}\n\n//-----------------------------------------------------------------------------\n// Function: AddressBlockInterface::getRangeFormattedExpression()\n//-----------------------------------------------------------------------------\nstd::string AddressBlockInterface::getRangeFormattedExpression(std::string const& blockName) const\n{\n    QSharedPointer<AddressBlock> selectedBlock = getAddressBlock(blockName);\n    if (selectedBlock)\n    {\n        return formattedValueFor(selectedBlock->getRange()).toStdString();\n    }\n\n    return std::string();\n}\n\n//-----------------------------------------------------------------------------\n// Function: AddressBlockInterface::getRangeExpression()\n//-----------------------------------------------------------------------------\nstd::string AddressBlockInterface::getRangeExpression(std::string const& blockName) const\n{\n    QSharedPointer<AddressBlock> selectedBlock = getAddressBlock(blockName);\n    if (selectedBlock)\n    {\n        return selectedBlock->getRange().toStdString();\n    }\n\n    return std::string();\n}\n\n//-----------------------------------------------------------------------------\n// Function: AddressBlockInterface::setRange()\n//-----------------------------------------------------------------------------\nbool AddressBlockInterface::setRange(std::string const& blockName, std::string const& newRange) const\n{\n    QSharedPointer<AddressBlock> selectedBlock = getAddressBlock(blockName);\n    if (!selectedBlock)\n    {\n        return false;\n    }\n\n    selectedBlock->setRange(QString::fromStdString(newRange));\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: AddressBlockInterface::getWidthValue()\n//-----------------------------------------------------------------------------\nstd::string AddressBlockInterface::getWidthValue(std::string const& blockName, int const& baseNumber) const\n{\n    QSharedPointer<AddressBlock> selectedBlock = getAddressBlock(blockName);\n    if (selectedBlock)\n    {\n        return parseExpressionToBaseNumber(selectedBlock->getWidth(), baseNumber).toStdString();\n    }\n\n    return std::string();\n}\n\n//-----------------------------------------------------------------------------\n// Function: AddressBlockInterface::getWidthFormattedExpression()\n//-----------------------------------------------------------------------------\nstd::string AddressBlockInterface::getWidthFormattedExpression(std::string const& blockName) const\n{\n    QSharedPointer<AddressBlock> selectedBlock = getAddressBlock(blockName);\n    if (selectedBlock)\n    {\n        return formattedValueFor(selectedBlock->getWidth()).toStdString();\n    }\n\n    return std::string();\n}\n\n//-----------------------------------------------------------------------------\n// Function: AddressBlockInterface::getWidthExpression()\n//-----------------------------------------------------------------------------\nstd::string AddressBlockInterface::getWidthExpression(std::string const& blockName) const\n{\n    QSharedPointer<AddressBlock> selectedBlock = getAddressBlock(blockName);\n    if (selectedBlock)\n    {\n        return selectedBlock->getWidth().toStdString();\n    }\n\n    return std::string();\n}\n\n//-----------------------------------------------------------------------------\n// Function: AddressBlockInterface::setWidth()\n//-----------------------------------------------------------------------------\nbool AddressBlockInterface::setWidth(std::string const& blockName, std::string const& newWidth) const\n{\n    QSharedPointer<AddressBlock> selectedBlock = getAddressBlock(blockName);\n    if (!selectedBlock)\n    {\n        return false;\n    }\n\n    selectedBlock->setWidth(QString::fromStdString(newWidth));\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: AddressBlockInterface::getUsageString()\n//-----------------------------------------------------------------------------\nstd::string AddressBlockInterface::getUsageString(std::string const& blockName) const\n{\n    QSharedPointer<AddressBlock> selectedBlock = getAddressBlock(blockName);\n    if (selectedBlock)\n    {\n        return General::usage2Str(selectedBlock->getUsage()).toStdString();\n    }\n\n    return std::string(\"\");\n}\n\n//-----------------------------------------------------------------------------\n// Function: AddressBlockInterface::getUsage()\n//-----------------------------------------------------------------------------\nGeneral::Usage AddressBlockInterface::getUsage(std::string const& blockName) const\n{\n    QSharedPointer<AddressBlock> selectedBlock = getAddressBlock(blockName);\n    if (selectedBlock)\n    {\n        return selectedBlock->getUsage();\n    }\n\n    return General::USAGE_COUNT;\n}\n\n//-----------------------------------------------------------------------------\n// Function: AddressBlockInterface::setUsage()\n//-----------------------------------------------------------------------------\nbool AddressBlockInterface::setUsage(std::string const& blockName, std::string const& newUsage) const\n{\n    QSharedPointer<AddressBlock> selectedBlock = getAddressBlock(blockName);\n    if (!selectedBlock)\n    {\n        return false;\n    }\n\n    selectedBlock->setUsage(General::str2Usage(QString::fromStdString(newUsage), General::USAGE_COUNT));\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: AddressBlockInterface::getAccessString()\n//-----------------------------------------------------------------------------\nstd::string AddressBlockInterface::getAccessString(std::string const& blockName, bool getAccessPolicyAccess /*= false*/) const\n{\n    if (auto selectedBlock = getAddressBlock(blockName))\n    {\n        if (!getAccessPolicyAccess)\n        {\n            return AccessTypes::access2Str(selectedBlock->getAccess()).toStdString();\n        }\n        else\n        {\n            auto accessPolicies = selectedBlock->getAccessPolicies();\n\n            if (!accessPolicies->isEmpty())\n            {\n                return AccessTypes::access2Str(accessPolicies->first()->getAccess()).toStdString();\n            }\n        }\n    }\n\n    return std::string(\"\");\n}\n\n//-----------------------------------------------------------------------------\n// Function: AddressBlockInterface::getAccess()\n//-----------------------------------------------------------------------------\nAccessTypes::Access AddressBlockInterface::getAccess(std::string const& blockName) const\n{\n    if (auto selectedBlock = getAddressBlock(blockName))\n    {\n        return selectedBlock->getAccess();\n    }\n\n    return AccessTypes::ACCESS_COUNT;\n}\n\n//-----------------------------------------------------------------------------\n// Function: AddressBlockInterface::setAccess()\n//-----------------------------------------------------------------------------\nbool AddressBlockInterface::setAccess(std::string const& blockName, std::string const& newAccess, bool setAccessPolicyAccess /*= false*/) const\n{\n    auto selectedBlock = getAddressBlock(blockName);\n    if (!selectedBlock)\n    {\n        return false;\n    }\n\n    if (!setAccessPolicyAccess)\n    {\n        selectedBlock->setAccess(AccessTypes::str2Access(QString::fromStdString(newAccess), AccessTypes::ACCESS_COUNT));\n        return true;\n    }\n    else\n    {\n        if (auto accessPolicies = selectedBlock->getAccessPolicies(); accessPolicies->isEmpty() == false)\n        {\n            auto accessPolicy = selectedBlock->getAccessPolicies()->first();\n\n            // Remove access policy, if new access is empty.\n            if (accessPolicy && newAccess.empty())\n            {\n                selectedBlock->getAccessPolicies()->clear();\n                return true;\n            }\n\n            accessPolicy->setAccess(AccessTypes::str2Access(QString::fromStdString(newAccess), \n                AccessTypes::ACCESS_COUNT));\n            return true;\n        }\n    }\n    \n    return false;\n}\n\n//-----------------------------------------------------------------------------\n// Function: AddressBlockInterface::getVolatile()\n//-----------------------------------------------------------------------------\nstd::string AddressBlockInterface::getVolatile(std::string const& blockName) const\n{\n    QSharedPointer<AddressBlock> selectedBlock = getAddressBlock(blockName);\n    if (selectedBlock)\n    {\n        return selectedBlock->getVolatile().toStdString();\n    }\n\n    return std::string(\"\");\n}\n\n//-----------------------------------------------------------------------------\n// Function: AddressBlockInterface::setVolatile()\n//-----------------------------------------------------------------------------\nbool AddressBlockInterface::setVolatile(std::string const& blockName, bool newVolatile) const\n{\n    QSharedPointer<AddressBlock> selectedBlock = getAddressBlock(blockName);\n    if (!selectedBlock)\n    {\n        return false;\n    }\n\n    selectedBlock->setVolatile(newVolatile);\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: AddressBlockInterface::setVolatile()\n//-----------------------------------------------------------------------------\nbool AddressBlockInterface::setVolatile(std::string const& blockName, std::string const& newVolatileValue)\n{\n    QSharedPointer<AddressBlock> selectedBlock = getAddressBlock(blockName);\n    if (!selectedBlock)\n    {\n        return false;\n    }\n\n    if (newVolatileValue == (\"true\"))\n    {\n        selectedBlock->setVolatile(true);\n    }\n    else if (newVolatileValue == (\"false\"))\n    {\n        selectedBlock->setVolatile(false);\n    }\n    else\n    {\n        selectedBlock->clearVolatile();\n    }\n\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: AddressBlockInterface::getAllReferencesToIdInItem()\n//-----------------------------------------------------------------------------\nint AddressBlockInterface::getAllReferencesToIdInItem(const std::string& itemName, std::string const&  valueID) const\n{\n    int referencesInMemoryBlock = MemoryBlockInterface::getAllReferencesToIdInItem(itemName, valueID);\n    int totalReferencesToParameter = 0;\n\n    QSharedPointer<AddressBlock> selectedItem = getAddressBlock(itemName);\n    if (selectedItem)\n    {\n        QString idString = QString::fromStdString(valueID);\n\n        int referencesInRange = selectedItem->getRange().count(idString);\n        int referencesInWidth = selectedItem->getWidth().count(idString);\n\n        totalReferencesToParameter = referencesInMemoryBlock + referencesInRange + referencesInWidth;\n    }\n\n    return totalReferencesToParameter;\n}\n\n//-----------------------------------------------------------------------------\n// Function: AddressBlockInterface::validateItems()\n//-----------------------------------------------------------------------------\nbool AddressBlockInterface::validateItems() const\n{\n    for (auto const& currentItemName : getItemNames())\n    {\n        QSharedPointer<AddressBlock> block = getAddressBlock(currentItemName);\n        if (block)\n        {\n            if (!validator_->validate(block, getAddressUnitBits()))\n            {\n                return false;\n            }\n        }\n    }\n\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: AddressBlockInterface::hasValidRange()\n//-----------------------------------------------------------------------------\nbool AddressBlockInterface::hasValidRange(std::string const& itemName) const\n{\n    QSharedPointer<AddressBlock> block = getAddressBlock(itemName);\n    if (block)\n    {\n        return validator_->hasValidRange(block);\n    }\n\n    return false;\n}\n\n//-----------------------------------------------------------------------------\n// Function: AddressBlockInterface::hasValidWidth()\n//-----------------------------------------------------------------------------\nbool AddressBlockInterface::hasValidWidth(std::string const& itemName) const\n{\n    QSharedPointer<AddressBlock> block = getAddressBlock(itemName);\n    if (block)\n    {\n        return validator_->hasValidWidth(block);\n    }\n\n    return false;\n}\n\n//-----------------------------------------------------------------------------\n// Function: AddressBlockInterface::hasValidUsage()\n//-----------------------------------------------------------------------------\nbool AddressBlockInterface::hasValidUsage(std::string const& itemName) const\n{\n    QSharedPointer<AddressBlock> block = getAddressBlock(itemName);\n    if (block)\n    {\n        return validator_->hasValidUsage(block);\n    }\n\n    return false;\n}\n\n//-----------------------------------------------------------------------------\n// Function: AddressBlockInterface::getBlock()\n//-----------------------------------------------------------------------------\nQSharedPointer<AddressBlock> AddressBlockInterface::getAddressBlock(std::string const& itemName) const\n{\n    QSharedPointer<MemoryBlockBase> selectedBlock = getBlock(itemName);\n    if (selectedBlock)\n    {\n        QSharedPointer<AddressBlock> selectedAddressBlock = selectedBlock.dynamicCast<AddressBlock>();\n        if (selectedAddressBlock)\n        {\n            return selectedAddressBlock;\n        }\n    }\n\n    return QSharedPointer<AddressBlock>();\n}\n\n//-----------------------------------------------------------------------------\n// Function: AddressBlockInterface::addBlock()\n//-----------------------------------------------------------------------------\nvoid AddressBlockInterface::addBlock(int const& row, std::string const& newBlockName)\n{\n    QString newBase = getNewBlockBaseAddress();\n\n    QSharedPointer<AddressBlock> newBlock(new AddressBlock());\n    newBlock->setWidth(\"32\");\n    newBlock->setRange(\"4\");\n    newBlock->setBaseAddress(newBase);\n    newBlock->setName(getUniqueName(newBlockName, BLOCK_TYPE));\n\n    getBlocksData()->insert(row, newBlock);\n}\n\n//-----------------------------------------------------------------------------\n// Function: AddressBlockInterface::getCopiedBlocks()\n//-----------------------------------------------------------------------------\nQList<QSharedPointer<MemoryBlockBase> > AddressBlockInterface::getCopiedBlocks(std::vector<int> const& selectedRows) const\n{\n    QList<QSharedPointer<MemoryBlockBase> > copiedBlocks;\n    for (auto index : selectedRows)\n    {\n        QSharedPointer<AddressBlock> block = getAddressBlock(getIndexedItemName(index));\n        if (block)\n        {\n            copiedBlocks.append(block);\n        }\n    }\n\n    return copiedBlocks;\n}\n\n//-----------------------------------------------------------------------------\n// Function: AddressBlockInterface::getMimeType()\n//-----------------------------------------------------------------------------\nQString AddressBlockInterface::getMimeType() const\n{\n    return QString(\"text/xml/ipxact:addressBlock\");\n}\n\n//-----------------------------------------------------------------------------\n// Function: AddressBlockInterface::createCopyBlock()\n//-----------------------------------------------------------------------------\nQSharedPointer<MemoryBlockBase> AddressBlockInterface::createCopyBlock(QSharedPointer<MemoryBlockBase> copiedItem)\nconst\n{\n    QSharedPointer<AddressBlock> copiedBlock = copiedItem.dynamicCast<AddressBlock>();\n    if (copiedBlock)\n    {\n        QSharedPointer<AddressBlock> newBlock(new AddressBlock(*copiedBlock.data()));\n        newBlock->setName(getUniqueName(newBlock->name().toStdString(), BLOCK_TYPE));\n\n        return newBlock;\n    }\n\n    return QSharedPointer<MemoryBlockBase>();\n}\n\n//-----------------------------------------------------------------------------\n// Function: AddressBlockInterface::countItems()\n//-----------------------------------------------------------------------------\nint AddressBlockInterface::countItems(QList<QSharedPointer<MemoryBlockBase> > itemList) const\n{\n    int itemCount = 0;\n    for (auto blockItem : itemList)\n    {\n        QSharedPointer<AddressBlock> addressBlockItem = blockItem.dynamicCast<AddressBlock>();\n        if (addressBlockItem)\n        {\n            itemCount++;\n        }\n    }\n\n    return itemCount;\n}\n\n//-----------------------------------------------------------------------------\n// Function: AddressBlockInterface::getExpressionsInSelectedItems()\n//-----------------------------------------------------------------------------\nstd::vector<std::string> AddressBlockInterface::getExpressionsInSelectedItems(std::vector<std::string> const& itemNames) const\n{\n    std::vector<std::string> expressionList;\n\n    AddressBlockExpressionGatherer gatherer;\n\n    for (auto const& name : itemNames)\n    {\n        QSharedPointer<AddressBlock> currentBlock = getAddressBlock(name);\n        QStringList itemExpressions = gatherer.getExpressions(currentBlock);\n        for (auto const& expression : itemExpressions)\n        {\n            expressionList.push_back(expression.toStdString());\n        }\n    }\n\n    return expressionList;\n}\n\n//-----------------------------------------------------------------------------\n// Function: AddressBlockInterface::getSubInterface()\n//-----------------------------------------------------------------------------\nRegisterInterface* AddressBlockInterface::getSubInterface() const\n{\n    return subInterface_;\n}\n\n//-----------------------------------------------------------------------------\n// Function: AddressBlockInterface::hasRegisters()\n//-----------------------------------------------------------------------------\nbool AddressBlockInterface::hasRegisters(std::string const& blockName) const\n{\n    QSharedPointer<AddressBlock> block = getAddressBlock(blockName);\n    if (block && block->getRegisterData() && !block->getRegisterData()->isEmpty())\n    {\n        return true;\n    }\n\n    return false;\n}\n\n//-----------------------------------------------------------------------------\n// Function: AddressBlockInterface::getAccessPolicyCount()\n//-----------------------------------------------------------------------------\nint AddressBlockInterface::getAccessPolicyCount(std::string const& blockName) const\n{\n    if (auto block = getAddressBlock(blockName))\n    {\n        return block->getAccessPolicies()->size();\n    }\n\n    return 0;\n}\n\n//-----------------------------------------------------------------------------\n// Function: AddressBlockInterface::addAccessPolicy()\n//-----------------------------------------------------------------------------\nbool AddressBlockInterface::addAccessPolicy(std::string const& blockName) const\n{\n    if (auto block = getAddressBlock(blockName))\n    {\n        QSharedPointer<AccessPolicy> newAccessPolicy(new AccessPolicy());\n        block->getAccessPolicies()->append(newAccessPolicy);\n        return true;\n    }\n\n    return false;\n}\n\n//-----------------------------------------------------------------------------\n// Function: AddressBlockInterface::getItem()\n//-----------------------------------------------------------------------------\nQSharedPointer<NameGroup> AddressBlockInterface::getItem(std::string const& itemName) const\n{\n    return getAddressBlock(itemName);\n}\n"
  },
  {
    "path": "KactusAPI/interfaces/component/BusInterfaceInterface.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: BusInterfaceInterface.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 17.02.2021\n//\n// Description:\n// Interface for accessing bus interfaces.\n//-----------------------------------------------------------------------------\n\n#include \"BusInterfaceInterface.h\"\n\n#include <IPXACTmodels/Component/Component.h>\n#include <IPXACTmodels/Component/BusInterface.h>\n#include <IPXACTmodels/Component/InitiatorInterface.h>\n#include <IPXACTmodels/Component/TargetInterface.h>\n#include <IPXACTmodels/Component/TransparentBridge.h>\n#include <IPXACTmodels/Component/validators/BusInterfaceValidator.h>\n\n#include <TransparentBridgeInterface.h>\n#include <AbstractionTypeInterface.h>\n#include <ParametersInterface.h>\n#include <FileSetInterface.h>\n#include <MemoryMapInterface.h>\n\n#include <QMimeData>\n#include <QApplication>\n#include <QClipboard>\n\nnamespace\n{\n    QString const DEFAULT_NAME = QLatin1String(\"bus_interface\");\n    QString const DEFAULT_FILEGROUP = QLatin1String(\"default\");\n};\n\n//-----------------------------------------------------------------------------\n// Function: BusInterfaceInterface::BusInterfaceInterface()\n//-----------------------------------------------------------------------------\nBusInterfaceInterface::BusInterfaceInterface(QSharedPointer<BusInterfaceValidator> busValidator,\n    QSharedPointer<ExpressionParser> expressionParser, QSharedPointer<ExpressionFormatter> expressionFormatter):\nParameterizableInterface(expressionParser, expressionFormatter),\nNameGroupInterface(),\nbusInterfaces_(0),\nbusValidator_(busValidator),\nbridgeInterface_(0),\nfileSetInterface_(0),\nmapInterface_(0),\nabstractionTypeInterface_(0),\nparameterInterface_(0)\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: BusInterfaceInterface::setFileSetInterface()\n//-----------------------------------------------------------------------------\nvoid BusInterfaceInterface::setFileSetInterface(FileSetInterface* newFileSetInterface)\n{\n    fileSetInterface_ = newFileSetInterface;\n}\n\n//-----------------------------------------------------------------------------\n// Function: BusInterfaceInterface::setMemoryMapInterface()\n//-----------------------------------------------------------------------------\nvoid BusInterfaceInterface::setMemoryMapInterface(MemoryMapInterface* newMapInterface)\n{\n    mapInterface_ = newMapInterface;\n}\n\n//-----------------------------------------------------------------------------\n// Function: BusInterfaceInterface::setAbstractionTypeInterface()\n//-----------------------------------------------------------------------------\nvoid BusInterfaceInterface::setAbstractionTypeInterface(AbstractionTypeInterface* newAbstractionTypeInterface)\n{\n    abstractionTypeInterface_ = newAbstractionTypeInterface;\n}\n\n//-----------------------------------------------------------------------------\n// Function: BusInterfaceInterface::setTransparentBridgeInterface()\n//-----------------------------------------------------------------------------\nvoid BusInterfaceInterface::setTransparentBridgeInterface(TransparentBridgeInterface* newBridgeInterface)\n{\n    bridgeInterface_ = newBridgeInterface;\n}\n\n//-----------------------------------------------------------------------------\n// Function: BusInterfaceInterface::setParameterInterface()\n//-----------------------------------------------------------------------------\nvoid BusInterfaceInterface::setParameterInterface(ParametersInterface* newParameterInterface)\n{\n    parameterInterface_ = newParameterInterface;\n}\n\n//-----------------------------------------------------------------------------\n// Function: BusInterfaceInterface::setBusInterfaces()\n//-----------------------------------------------------------------------------\nvoid BusInterfaceInterface::setBusInterfaces(QSharedPointer<Component> newComponent)\n{\n    busInterfaces_ = newComponent->getBusInterfaces();\n    docRevision_ = newComponent->getRevision();\n\n    if (fileSetInterface_ != NULL)\n    {\n        fileSetInterface_->setFileSets(newComponent->getFileSets());\n    }\n    if (mapInterface_ != NULL)\n    {\n        mapInterface_->setMemoryMaps(newComponent);\n    }\n\n    busValidator_->componentChange(newComponent->getChoices(), newComponent->getViews(), newComponent->getPorts(),\n        newComponent->getAddressSpaces(), newComponent->getMemoryMaps(), busInterfaces_,\n        newComponent->getFileSets(), newComponent->getRemapStates(), newComponent->getModes());\n}\n\n//-----------------------------------------------------------------------------\n// Function: BusInterfaceInterface::setupSubInterfaces()\n//-----------------------------------------------------------------------------\nvoid BusInterfaceInterface::setupSubInterfaces(std::string const& busName)\n{\n    QSharedPointer<BusInterface> selectedBus = getBusInterface(busName);\n    if (selectedBus)\n    {\n        auto mode = selectedBus->getInterfaceMode();\n        if (mode == General::SLAVE || mode == General::TARGET)\n        {\n            bridgeInterface_->setBridges(selectedBus->getSlave()->getBridges());\n        }\n        else\n        {\n            bridgeInterface_->setBridges(QSharedPointer<QList<QSharedPointer<TransparentBridge> > >());\n        }\n\n        General::InterfaceMode busMode = getActiveMode(busName);\n        QString systemGroup = getActiveSystemGroup(busName);\n\n        abstractionTypeInterface_->setAbstractionTypes(selectedBus->getAbstractionTypes(), busMode, systemGroup);\n        parameterInterface_->setParameters(selectedBus->getParameters());\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: BusInterfaceInterface::getActiveMode()\n//-----------------------------------------------------------------------------\nGeneral::InterfaceMode BusInterfaceInterface::getActiveMode(std::string const& busName) const\n{\n    General::InterfaceMode busMode = getMode(busName);\n    if (busMode == General::MONITOR)\n    {\n        busMode = getMonitorMode(busName);\n    }\n\n    return busMode;\n}\n\n//-----------------------------------------------------------------------------\n// Function: BusInterfaceInterface::getActiveSystemGroup()\n//-----------------------------------------------------------------------------\nQString BusInterfaceInterface::getActiveSystemGroup(std::string const& busName) const\n{\n    std::string systemGroup = getSystemGroup(busName);\n    General::InterfaceMode busMode = getMode(busName);\n    if (busMode == General::MONITOR)\n    {\n        systemGroup = getMonitorGroup(busName);\n    }\n\n    return QString::fromStdString(systemGroup);\n}\n\n//-----------------------------------------------------------------------------\n// Function: BusInterfaceInterface::getBusInterface()\n//-----------------------------------------------------------------------------\nQSharedPointer<BusInterface> BusInterfaceInterface::getBusInterface(std::string const& busName) const\n{\n    QString busNameQ = QString::fromStdString(busName);\n    for (auto bus : *busInterfaces_)\n    {\n        if (bus->name() == busNameQ)\n        {\n            return bus;\n        }\n    }\n\n    return QSharedPointer<BusInterface>();\n}\n\n//-----------------------------------------------------------------------------\n// Function: BusInterfaceInterface::getItem()\n//-----------------------------------------------------------------------------\nQSharedPointer<NameGroup> BusInterfaceInterface::getItem(std::string const& busName) const\n{\n    return getBusInterface(busName);\n}\n\n//-----------------------------------------------------------------------------\n// Function: BusInterfaceInterface::getInitiatorInterface()\n//-----------------------------------------------------------------------------\nQSharedPointer<InitiatorInterface> BusInterfaceInterface::getInitiatorInterface(std::string const& busName) const\n{\n    QSharedPointer<InitiatorInterface> selectedInitiator;\n\n    QSharedPointer<BusInterface> selectedBus = getBusInterface(busName);\n    if (selectedBus)\n    {\n        selectedInitiator = selectedBus->getInitiator();\n    }\n\n    return selectedInitiator;\n}\n\n//-----------------------------------------------------------------------------\n// Function: BusInterfaceInterface::createInitiatorForBusInterface()\n//-----------------------------------------------------------------------------\nQSharedPointer<InitiatorInterface> BusInterfaceInterface::createInitiatorForBusInterface(std::string const& busName)\n{\n    QSharedPointer<InitiatorInterface> selectedInitiator = getInitiatorInterface(busName);\n    if (!selectedInitiator)\n    {\n        QSharedPointer<BusInterface> containingBus = getBusInterface(busName);\n        if (containingBus)\n        {\n            selectedInitiator = QSharedPointer<InitiatorInterface>(new InitiatorInterface());\n\n            if (docRevision_ == Document::Revision::Std22)\n            {\n                containingBus->setInitiator(selectedInitiator);\n            }\n            else\n            {\n                containingBus->setMaster(selectedInitiator);\n            }\n        }\n    }\n\n    return selectedInitiator;\n}\n\n//-----------------------------------------------------------------------------\n// Function: BusInterfaceInterface::getTargetInterface()\n//-----------------------------------------------------------------------------\nQSharedPointer<TargetInterface> BusInterfaceInterface::getTargetInterface(std::string const& busName) const\n{\n    QSharedPointer<TargetInterface> selectedTarget;\n\n    QSharedPointer<BusInterface> selectedBus = getBusInterface(busName);\n    if (selectedBus)\n    {\n        selectedTarget = selectedBus->getTarget();\n    }\n\n    return selectedTarget;\n}\n\n//-----------------------------------------------------------------------------\n// Function: BusInterfaceInterface::createTargetForBusInterface()\n//-----------------------------------------------------------------------------\nQSharedPointer<TargetInterface> BusInterfaceInterface::createTargetForBusInterface(std::string const& busName)\n{\n    QSharedPointer<TargetInterface> selectedTarget = getTargetInterface(busName);\n    if (!selectedTarget)\n    {\n        QSharedPointer<BusInterface> containingBus = getBusInterface(busName);\n        if (containingBus)\n        {\n            selectedTarget = QSharedPointer<TargetInterface>(new TargetInterface());\n            if (docRevision_ == Document::Revision::Std22)\n            {\n                containingBus->setTarget(selectedTarget);\n            }\n            else\n            {\n                containingBus->setSlave(selectedTarget);\n            }\n        }\n    }\n\n    return selectedTarget;\n}\n\n//-----------------------------------------------------------------------------\n// Function: BusInterfaceInterface::getMirroredSlaveInterface()\n//-----------------------------------------------------------------------------\nQSharedPointer<MirroredTargetInterface> BusInterfaceInterface::getMirroredSlaveInterface(std::string const& busName)\nconst\n{\n    QSharedPointer<MirroredTargetInterface> selectedMirrorSlave;\n\n    QSharedPointer<BusInterface> selectedBus = getBusInterface(busName);\n    if (selectedBus)\n    {\n        selectedMirrorSlave = selectedBus->getMirroredSlave();\n    }\n\n    return selectedMirrorSlave;\n}\n\n//-----------------------------------------------------------------------------\n// Function: BusInterfaceInterface::createMirrorSlaveForBusInterface()\n//-----------------------------------------------------------------------------\nQSharedPointer<MirroredTargetInterface> BusInterfaceInterface::createMirrorSlaveForBusInterface(\n    std::string const& busName)\n{\n    QSharedPointer<MirroredTargetInterface> mirrorSlave = getMirroredSlaveInterface(busName);\n    if (!mirrorSlave)\n    {\n        QSharedPointer<BusInterface> containingBus = getBusInterface(busName);\n        if (containingBus)\n        {\n            mirrorSlave = QSharedPointer<MirroredTargetInterface>(new MirroredTargetInterface());\n            containingBus->setMirroredSlave(mirrorSlave);\n        }\n    }\n\n    return mirrorSlave;\n}\n\n//-----------------------------------------------------------------------------\n// Function: BusInterfaceInterface::getMonitorInterface()\n//-----------------------------------------------------------------------------\nQSharedPointer<BusInterface::MonitorInterface> BusInterfaceInterface::getMonitorInterface(\n    std::string const& busName) const\n{\n    QSharedPointer<BusInterface::MonitorInterface> selectedMonitor;\n\n    QSharedPointer<BusInterface> selectedBus = getBusInterface(busName);\n    if (selectedBus)\n    {\n        selectedMonitor = selectedBus->getMonitor();\n    }\n\n    return selectedMonitor;\n}\n\n//-----------------------------------------------------------------------------\n// Function: BusInterfaceInterface::createMonitorForBusInterface()\n//-----------------------------------------------------------------------------\nQSharedPointer<BusInterface::MonitorInterface> BusInterfaceInterface::createMonitorForBusInterface(\n    std::string const& busName)\n{\n    QSharedPointer<BusInterface::MonitorInterface> selectedMonitor = getMonitorInterface(busName);\n    if (!selectedMonitor)\n    {\n        QSharedPointer<BusInterface> containingBus = getBusInterface(busName);\n        if (containingBus)\n        {\n            selectedMonitor = QSharedPointer<BusInterface::MonitorInterface>(new BusInterface::MonitorInterface());\n            containingBus->setMonitor(selectedMonitor);\n        }\n    }\n\n    return selectedMonitor;\n}\n\n//-----------------------------------------------------------------------------\n// Function: BusInterfaceInterface::getItemIndex()\n//-----------------------------------------------------------------------------\nint BusInterfaceInterface::getItemIndex(std::string const& itemName) const\n{\n    QString itemNameQ = QString::fromStdString(itemName);\n    for (int i = 0; i < busInterfaces_->size(); ++i)\n    {\n        if (busInterfaces_->at(i)->name() == itemNameQ)\n        {\n            return i;\n        }\n    }\n\n    return -1;\n}\n\n//-----------------------------------------------------------------------------\n// Function: BusInterfaceInterface::getIndexedItemName()\n//-----------------------------------------------------------------------------\nstd::string BusInterfaceInterface::getIndexedItemName(int itemIndex) const\n{\n    std::string portName = \"\";\n    if (itemIndex >= 0 && itemIndex < itemCount())\n    {\n        portName = busInterfaces_->at(itemIndex)->name().toStdString();\n    }\n\n    return portName;\n}\n\n//-----------------------------------------------------------------------------\n// Function: BusInterfaceInterface::itemCount()\n//-----------------------------------------------------------------------------\nint BusInterfaceInterface::itemCount() const\n{\n    return busInterfaces_->count();\n}\n\n//-----------------------------------------------------------------------------\n// Function: BusInterfaceInterface::getItemNames()\n//-----------------------------------------------------------------------------\nstd::vector<std::string> BusInterfaceInterface::getItemNames() const\n{\n    QVector<QString> busNamesQ;\n    for (auto bus : *busInterfaces_)\n    {\n        if (!busNamesQ.contains(bus->name()))\n        {\n            busNamesQ.append(bus->name());\n        }\n    }\n\n    std::vector<std::string> busNames;\n    for (auto busName : busNamesQ)\n    {\n        busNames.push_back(busName.toStdString());\n    }\n\n    return busNames;\n}\n\n//-----------------------------------------------------------------------------\n// Function: BusInterfaceInterface::setName()\n//-----------------------------------------------------------------------------\nbool BusInterfaceInterface::setName(std::string const& currentName, std::string const& newName)\n{\n    QSharedPointer<BusInterface> editedBus = getBusInterface(currentName);\n    if (editedBus && nameHasChanged(newName, currentName))\n    {\n        QString uniqueNewName = getUniqueName(newName, DEFAULT_NAME.toStdString());\n\n        editedBus->setName(uniqueNewName);\n        return true;\n    }\n    else\n    {\n        return false;\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: BusInterfaceInterface::validateItems()\n//-----------------------------------------------------------------------------\nbool BusInterfaceInterface::validateItems() const\n{\n    for (auto bus : *busInterfaces_)\n    {\n        if (!busValidator_->validate(bus, Document::Revision::Std14))\n        {\n            return false;\n        }\n    }\n\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: BusInterfaceInterface::validateBusInterface()\n//-----------------------------------------------------------------------------\nbool BusInterfaceInterface::validateBusInterface(std::string const& busName) const\n{\n    QSharedPointer<BusInterface> selectedBus = getBusInterface(busName);\n    if (!selectedBus)\n    {\n        return false;\n    }\n\n    return busValidator_->validate(selectedBus, Document::Revision::Std14);\n}\n\n//-----------------------------------------------------------------------------\n// Function: BusInterfaceInterface::itemHasValidName()\n//-----------------------------------------------------------------------------\nbool BusInterfaceInterface::itemHasValidName(std::string const& itemName) const\n{\n    QSharedPointer<BusInterface> selectedBus = getBusInterface(itemName);\n    if (selectedBus)\n    {\n        return busValidator_->hasValidName(selectedBus);\n    }\n\n    return false;\n}\n\n//-----------------------------------------------------------------------------\n// Function: BusInterfaceInterface::hasValidBusType()\n//-----------------------------------------------------------------------------\nbool BusInterfaceInterface::hasValidBusType(std::string const& busName) const\n{\n    QSharedPointer<BusInterface> selectedBus = getBusInterface(busName);\n    if (selectedBus)\n    {\n        return busValidator_->hasValidBusType(selectedBus);\n    }\n\n    return false;\n}\n\n//-----------------------------------------------------------------------------\n// Function: BusInterfaceInterface::hasValidAbstractionTypes()\n//-----------------------------------------------------------------------------\nbool BusInterfaceInterface::hasValidAbstractionTypes(std::string const& busName) const\n{\n    QSharedPointer<BusInterface> selectedBus = getBusInterface(busName);\n    if (selectedBus)\n    {\n        return busValidator_->hasValidAbstractionTypes(selectedBus);\n    }\n\n    return false;\n}\n\n//-----------------------------------------------------------------------------\n// Function: BusInterfaceInterface::getMode()\n//-----------------------------------------------------------------------------\nGeneral::InterfaceMode BusInterfaceInterface::getMode(std::string const& busName) const\n{\n    QSharedPointer<BusInterface> selectedBus = getBusInterface(busName);\n    if (!selectedBus)\n    {\n        return General::INTERFACE_MODE_COUNT;\n    }\n\n    return selectedBus->getInterfaceMode();\n}\n\n//-----------------------------------------------------------------------------\n// Function: BusInterfaceInterface::getModeString()\n//-----------------------------------------------------------------------------\nstd::string BusInterfaceInterface::getModeString(std::string const& busName) const\n{\n    QSharedPointer<BusInterface> selectedBus = getBusInterface(busName);\n    if (!selectedBus)\n    {\n        return std::string();\n    }\n\n    return General::interfaceMode2Str(selectedBus->getInterfaceMode()).toStdString();\n}\n\n//-----------------------------------------------------------------------------\n// Function: BusInterfaceInterface::setMode()\n//-----------------------------------------------------------------------------\nbool BusInterfaceInterface::setMode(std::string const& busName, std::string const& newMode)\n{\n    QSharedPointer<BusInterface> selectedBus = getBusInterface(busName);\n    if (!selectedBus)\n    {\n        return false;\n    }\n\n    General::InterfaceMode newInterfaceMode =\n        General::str2Interfacemode(QString::fromStdString(newMode), General::INTERFACE_MODE_COUNT);\n    selectedBus->setInterfaceMode(newInterfaceMode);\n\n    abstractionTypeInterface_->setBusMode(newInterfaceMode);\n\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: BusInterfaceInterface::getSystemGroup()\n//-----------------------------------------------------------------------------\nstd::string BusInterfaceInterface::getSystemGroup(std::string const& busName) const\n{\n    std::string systemGroup = \"\";\n    QSharedPointer<BusInterface> selectedBus = getBusInterface(busName);\n    if (selectedBus)\n    {\n        systemGroup = selectedBus->getSystem().toStdString();\n    }\n\n    return systemGroup;\n}\n\n//-----------------------------------------------------------------------------\n// Function: BusInterfaceInterface::setSystemGroup()\n//-----------------------------------------------------------------------------\nbool BusInterfaceInterface::setSystemGroup(std::string const& busName, std::string const& newSystem)\n{\n    QSharedPointer<BusInterface> selectedBus = getBusInterface(busName);\n    if (!selectedBus)\n    {\n        return false;\n    }\n\n    QString newSystemQ = QString::fromStdString(newSystem);\n\n    selectedBus->setSystem(newSystemQ);\n\n    abstractionTypeInterface_->setSystemGroup(newSystemQ);\n\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: BusInterfaceInterface::connectionIsRequired()\n//-----------------------------------------------------------------------------\nstd::string BusInterfaceInterface::connectionIsRequired(std::string const& busName) const\n{\n    std::string requirement = \"\";\n\n    QSharedPointer<BusInterface> selectedBus = getBusInterface(busName);\n    if (selectedBus)\n    {\n        requirement = selectedBus->getConnectionRequired().toStdString();\n    }\n\n    return requirement;\n}\n\n//-----------------------------------------------------------------------------\n// Function: BusInterfaceInterface::setConnectionIsRequired()\n//-----------------------------------------------------------------------------\nbool BusInterfaceInterface::setConnectionIsRequired(std::string const& busName, bool newValue)\n{\n    QSharedPointer<BusInterface> selectedBus = getBusInterface(busName);\n    if (!selectedBus)\n    {\n        return false;\n    }\n\n    selectedBus->setConnectionRequired(newValue);\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: BusInterfaceInterface::getBitsInLau()\n//-----------------------------------------------------------------------------\nstd::string BusInterfaceInterface::getBitsInLau(std::string const& busName) const\n{\n    std::string bitsInLau = \"\";\n\n    QSharedPointer<BusInterface> selectedBus = getBusInterface(busName);\n    if (selectedBus)\n    {\n        bitsInLau = selectedBus->getBitsInLau().toStdString();\n    }\n\n    return bitsInLau;\n}\n\n//-----------------------------------------------------------------------------\n// Function: BusInterfaceInterface::setBitsInLau()\n//-----------------------------------------------------------------------------\nbool BusInterfaceInterface::setBitsInLau(std::string const& busName, std::string const& newBits)\n{\n    QSharedPointer<BusInterface> selectedBus = getBusInterface(busName);\n    if (!selectedBus)\n    {\n        return false;\n    }\n\n    selectedBus->setBitsInLau(QString::fromStdString(newBits));\n    return true;\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: BusInterfaceInterface::getEndianness()\n//-----------------------------------------------------------------------------\nBusInterface::Endianness BusInterfaceInterface::getEndianness(std::string const& busName) const\n{\n    BusInterface::Endianness endianness = BusInterface::ENDIANNESS_UNSPECIFIED;\n\n    QSharedPointer<BusInterface> selectedBus = getBusInterface(busName);\n    if (selectedBus)\n    {\n        endianness = selectedBus->getEndianness();\n    }\n\n    return endianness;\n}\n\n//-----------------------------------------------------------------------------\n// Function: BusInterfaceInterface::setEndianness()\n//-----------------------------------------------------------------------------\nbool BusInterfaceInterface::setEndianness(std::string const& busName, std::string const& newEndianness)\n{\n    QSharedPointer<BusInterface> selectedBus = getBusInterface(busName);\n    if (!selectedBus)\n    {\n        return false;\n    }\n\n    QString newEndiannessQ = QString::fromStdString(newEndianness);\n    if (newEndiannessQ == QLatin1String(\"little\"))\n    {\n        selectedBus->setEndianness(BusInterface::LITTLE);\n    }\n    else if (newEndiannessQ == QLatin1String(\"big\"))\n    {\n        selectedBus->setEndianness(BusInterface::BIG);\n    }\n    else\n    {\n        selectedBus->setEndianness(BusInterface::ENDIANNESS_UNSPECIFIED);\n    }\n\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: BusInterfaceInterface::getBitSteering()\n//-----------------------------------------------------------------------------\nstd::string BusInterfaceInterface::getBitSteering(std::string const& busName) const\n{\n    auto bitSteering = QString();\n\n    QSharedPointer<BusInterface> selectedBus = getBusInterface(busName);\n    if (selectedBus)\n    {\n        bitSteering = selectedBus->getBitSteering();\n    }\n\n    return bitSteering.toStdString();\n}\n\n//-----------------------------------------------------------------------------\n// Function: BusInterfaceInterface::setBitSteering()\n//-----------------------------------------------------------------------------\nbool BusInterfaceInterface::setBitSteering(std::string const& busName, std::string const& newBitSteering)\n{\n    QSharedPointer<BusInterface> selectedBus = getBusInterface(busName);\n    if (!selectedBus)\n    {\n        return false;\n    }\n\n    QString newBitsQ = QString::fromStdString(newBitSteering);\n\n    selectedBus->setBitSteering(newBitsQ);\n\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: BusInterfaceInterface::addBusInterface()\n//-----------------------------------------------------------------------------\nvoid BusInterfaceInterface::addBusInterface(int const& newBusIndex, std::string const& busName)\n{\n    QSharedPointer<BusInterface> newBus(new BusInterface());\n    newBus->setName(getUniqueName(busName, DEFAULT_NAME.toStdString()));\n\n    busInterfaces_->insert(newBusIndex, newBus);\n}\n\n//-----------------------------------------------------------------------------\n// Function: BusInterfaceInterface::addBusInterface()\n//-----------------------------------------------------------------------------\nvoid BusInterfaceInterface::addBusInterface(std::string const& busName /*= \"\"*/)\n{\n    addBusInterface(busInterfaces_->size(), busName);\n}\n\n//-----------------------------------------------------------------------------\n// Function: BusInterfaceInterface::removeBusInterface()\n//-----------------------------------------------------------------------------\nbool BusInterfaceInterface::removeBusInterface(std::string const& busName)\n{\n    QSharedPointer<BusInterface> removedItem = getBusInterface(busName);\n    if (!removedItem)\n    {\n        return false;\n    }\n\n    return busInterfaces_->removeOne(removedItem);\n}\n\n//-----------------------------------------------------------------------------\n// Function: BusInterfaceInterface::busInterfaceExists()\n//-----------------------------------------------------------------------------\nbool BusInterfaceInterface::busInterfaceExists(std::string const& busName) const\n{\n    for (auto const& name : getItemNames())\n    {\n        if (name == busName)\n        {\n            return true;\n        }\n    }\n\n    return false;\n}\n\n//-----------------------------------------------------------------------------\n// Function: BusInterfaceInterface::swapBusInterfaces()\n//-----------------------------------------------------------------------------\nvoid BusInterfaceInterface::swapBusInterfaces(int const& firstIndex, int const& secondIndex)\n{\n    if (firstIndex < 0 || firstIndex >= itemCount())\n    {\n        return;\n    }\n    if (secondIndex < 0 || secondIndex >= itemCount())\n    {\n        QSharedPointer<BusInterface> selectedBus = busInterfaces_->takeAt(firstIndex);\n        busInterfaces_->append(selectedBus);\n    }\n    else\n    {\n        busInterfaces_->swapItemsAt(firstIndex, secondIndex);\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: BusInterfaceInterface::getAddressSpaceReference()\n//-----------------------------------------------------------------------------\nstd::string BusInterfaceInterface::getAddressSpaceReference(std::string const& busName) const\n{\n    std::string spaceReference = \"\";\n    QSharedPointer<BusInterface> selectedBus = getBusInterface(busName);\n    if (selectedBus)\n    {\n        spaceReference = selectedBus->getAddressSpaceRef().toStdString();\n    }\n\n    return spaceReference;\n}\n\n//-----------------------------------------------------------------------------\n// Function: BusInterfaceInterface::setAddressSpaceReferemce()\n//-----------------------------------------------------------------------------\nbool BusInterfaceInterface::setAddressSpaceReference(std::string const& busName, std::string const& newSpace)\n{\n    QSharedPointer<InitiatorInterface> master = createInitiatorForBusInterface(busName);\n    if (!master)\n    {\n        return false;\n    }\n\n    master->setAddressSpaceRef(QString::fromStdString(newSpace));\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: BusInterfaceInterface::getBaseAddressValue()\n//-----------------------------------------------------------------------------\nstd::string BusInterfaceInterface::getBaseAddressValue(std::string const& busName, int const& baseNumber) const\n{\n    QSharedPointer<InitiatorInterface> selectedMaster = getInitiatorInterface(busName);\n    if (selectedMaster)\n    {\n        QString baseAddress = selectedMaster->getBaseAddress();\n        return parseExpressionToBaseNumber(baseAddress, baseNumber).toStdString();\n    }\n\n    return std::string(\"\");\n}\n\n//-----------------------------------------------------------------------------\n// Function: BusInterfaceInterface::getBaseAddressFormattedExpression()\n//-----------------------------------------------------------------------------\nstd::string BusInterfaceInterface::getBaseAddressFormattedExpression(std::string const& busName) const\n{\n    QSharedPointer<InitiatorInterface> selectedMaster = getInitiatorInterface(busName);\n    if (selectedMaster)\n    {\n        QString baseAddress = selectedMaster->getBaseAddress();\n        return formattedValueFor(baseAddress).toStdString();\n    }\n\n    return std::string(\"\");\n}\n\n//-----------------------------------------------------------------------------\n// Function: BusInterfaceInterface::getBaseAddressExpression()\n//-----------------------------------------------------------------------------\nstd::string BusInterfaceInterface::getBaseAddressExpression(std::string const& busName) const\n{\n    QSharedPointer<InitiatorInterface> selectedMaster = getInitiatorInterface(busName);\n    if (selectedMaster)\n    {\n        return selectedMaster->getBaseAddress().toStdString();\n    }\n\n    return std::string(\"\");\n}\n\n//-----------------------------------------------------------------------------\n// Function: BusInterfaceInterface::setBaseAddress()\n//-----------------------------------------------------------------------------\nbool BusInterfaceInterface::setBaseAddress(std::string const& busName, std::string const& newBaseAddress)\n{\n    QSharedPointer<InitiatorInterface> master = createInitiatorForBusInterface(busName);\n    if (!master)\n    {\n        return false;\n    }\n\n    master->setBaseAddress(QString::fromStdString(newBaseAddress));\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: BusInterfaceInterface::getMemoryMapReference()\n//-----------------------------------------------------------------------------\nstd::string BusInterfaceInterface::getMemoryMapReference(std::string const& busName) const\n{\n    QSharedPointer<TargetInterface> slave = getTargetInterface(busName);\n    if (slave)\n    {\n        return slave->getMemoryMapRef().toStdString();\n    }\n\n    return std::string(\"\");\n}\n\n//-----------------------------------------------------------------------------\n// Function: BusInterfaceInterface::setMemoryMapReference()\n//-----------------------------------------------------------------------------\nbool BusInterfaceInterface::setMemoryMapReference(std::string const& busName, std::string const& newMapReference)\n{\n    QSharedPointer<TargetInterface> slave = createTargetForBusInterface(busName);\n    if (!slave)\n    {\n        return false;\n    }\n\n    slave->setMemoryMapRef(QString::fromStdString(newMapReference));\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: BusInterfaceInterface::getFileSetReferences()\n//-----------------------------------------------------------------------------\nstd::vector<std::string> BusInterfaceInterface::getFileSetReferences(std::string const& busName) const\n{\n    std::vector<std::string> newFileSetItems;\n\n    QSharedPointer<TargetInterface> slave = getTargetInterface(busName);\n    if (slave && slave->getFileSetRefGroup())\n    {\n        for (auto fileGroup : *slave->getFileSetRefGroup())\n        {\n            if (fileGroup->group_.compare(DEFAULT_FILEGROUP) == 0)\n            {\n                for (auto fileReference : *fileGroup->fileSetRefs_)\n                {\n                    newFileSetItems.push_back(fileReference->getReference().toStdString());\n                }\n            }\n        }\n    }\n\n    return newFileSetItems;\n}\n\n//-----------------------------------------------------------------------------\n// Function: BusInterfaceInterface::setFileSetReferences()\n//-----------------------------------------------------------------------------\nbool BusInterfaceInterface::setFileSetReferences(std::string const& busName,\n    std::vector<std::string>  const& newFileSetReferences)\n{\n    QSharedPointer<TargetInterface> slave = createTargetForBusInterface(busName);\n    if (!slave)\n    {\n        return false;\n    }\n\n    // Convert to QString once.\n    QStringList newFileSetReferencesQ;\n    for (auto const& ref : newFileSetReferences)\n    {\n        newFileSetReferencesQ << QString::fromStdString(ref);\n    }\n\n    QSharedPointer<QList<QSharedPointer<FileSetRef> > > allExistingFileSetRefs(\n        new QList<QSharedPointer<FileSetRef> >());\n\n    // References as strings.\n    QStringList allExistingReferencesStr;\n    \n    // Group all file set refs together.\n    for (auto const& fileSetRefGroup : *slave->getFileSetRefGroup())\n    {\n        for (auto const& fileSetInGroup : *fileSetRefGroup->fileSetRefs_)\n        {\n            allExistingFileSetRefs->append(fileSetInGroup);\n            allExistingReferencesStr << fileSetInGroup->getReference();\n        }\n    }\n\n    std::vector<int> indexesToDelete;\n\n    // Check for removed references.\n    for (int i = 0; i < allExistingReferencesStr.size(); ++i)\n    {\n        auto const& currentExistingRef = allExistingReferencesStr.at(i);\n\n        bool currentItemStillExists = false;\n\n        for (auto const& newRef : newFileSetReferencesQ)\n        {\n            if (currentExistingRef == newRef)\n            {\n                currentItemStillExists = true;\n            }\n        }\n\n        if (!currentItemStillExists)\n        {\n            indexesToDelete.push_back(i);\n        }\n    }\n\n    // Remove deleted file set refs.\n    for (auto index : indexesToDelete)\n    {\n        allExistingFileSetRefs->removeAt(index);\n        allExistingReferencesStr.removeAt(index);\n    }\n    \n    // Check for new refs.\n    for (auto const& newRef : newFileSetReferencesQ)\n    {\n        if (allExistingReferencesStr.contains(newRef) == false)\n        {\n            QSharedPointer<FileSetRef> newFileSetRef(new FileSetRef());\n            newFileSetRef->setReference(newRef);\n            allExistingFileSetRefs->append(newFileSetRef);\n        }\n    }\n\n    slave->getFileSetRefGroup()->clear();\n    \n    // Put all file set refs to same group, if there are file set references.\n    if (!allExistingFileSetRefs->isEmpty())\n    {\n        QSharedPointer<TargetInterface::FileSetRefGroup> fileSetRefGroup(new TargetInterface::FileSetRefGroup());\n        fileSetRefGroup->fileSetRefs_ = allExistingFileSetRefs;\n        fileSetRefGroup->group_ = DEFAULT_FILEGROUP;\n    \n        slave->getFileSetRefGroup()->append(fileSetRefGroup);\n    }\n\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: BusInterfaceInterface::getBusType()\n//-----------------------------------------------------------------------------\nConfigurableVLNVReference BusInterfaceInterface::getBusType(std::string const& busName) const\n{\n    QSharedPointer<BusInterface> selectedBus = getBusInterface(busName);\n    if(selectedBus)\n    {\n        return selectedBus->getBusType();\n    }\n    else\n    {\n        return ConfigurableVLNVReference();\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: BusInterfaceInterface::getBusTypeString()\n//-----------------------------------------------------------------------------\nstd::string BusInterfaceInterface::getBusTypeString(std::string const& busName) const\n{\n    QSharedPointer<BusInterface> selectedBus = getBusInterface(busName);\n    if (selectedBus)\n    {\n        return selectedBus->getBusType().toString().toStdString();\n    }\n\n    return \"\";\n}\n\n//-----------------------------------------------------------------------------\n// Function: BusInterfaceInterface::setBustype()\n//-----------------------------------------------------------------------------\nbool BusInterfaceInterface::setBustype(std::string const& busName, ConfigurableVLNVReference const& newVLNV)\n{\n    QSharedPointer<BusInterface> selectedBus = getBusInterface(busName);\n    if (!selectedBus)\n    {\n        return false;\n    }\n\n    selectedBus->setBusType(newVLNV);\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: BusInterfaceInterface::setBustype()\n//-----------------------------------------------------------------------------\nbool BusInterfaceInterface::setBustype(std::string const& busName, std::string const& newVendor,\n    std::string const& newLibrary, std::string const& newName, std::string const& newVersion) const\n{\n    QSharedPointer<BusInterface> selectedBus = getBusInterface(busName);\n    if (!selectedBus)\n    {\n        return false;\n    }\n\n    ConfigurableVLNVReference newAbstractionReference;\n    newAbstractionReference.setVendor(QString::fromStdString(newVendor));\n    newAbstractionReference.setLibrary(QString::fromStdString(newLibrary));\n    newAbstractionReference.setName(QString::fromStdString(newName));\n    newAbstractionReference.setVersion(QString::fromStdString(newVersion));\n\n    newAbstractionReference.setType(VLNV::BUSDEFINITION);\n\n    selectedBus->setBusType(newAbstractionReference);\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: BusInterfaceInterface::getAbstractionReferenceString()\n//-----------------------------------------------------------------------------\nstd::string BusInterfaceInterface::getAbstractionReferenceString(std::string const& busName) const\n{\n    QSharedPointer<BusInterface> busInterface = getBusInterface(busName);\n    if (busInterface)\n    {\n        General::InterfaceMode busMode = getActiveMode(busName);\n        QString systemGroup = getActiveSystemGroup(busName);\n\n        abstractionTypeInterface_->setAbstractionTypes(busInterface->getAbstractionTypes(), busMode, systemGroup);\n        return abstractionTypeInterface_->getAbstractionReferenceString();\n    }\n\n    return std::string(\"\");\n}\n\n//-----------------------------------------------------------------------------\n// Function: BusInterfaceInterface::getAbstractionReferences()\n//-----------------------------------------------------------------------------\nstd::vector<std::string> BusInterfaceInterface::getAbstractionReferences(std::string const& busName) const\n{\n    std::vector<std::string> references;\n\n    QSharedPointer<BusInterface> busInterface = getBusInterface(busName);\n    if (busInterface)\n    {\n        General::InterfaceMode busMode = getActiveMode(busName);\n        QString systemGroup = getActiveSystemGroup(busName);\n\n        abstractionTypeInterface_->setAbstractionTypes(busInterface->getAbstractionTypes(), busMode, systemGroup);\n        references = abstractionTypeInterface_->getAbstractionReferences();\n    }\n\n    return references;\n}\n\n//-----------------------------------------------------------------------------\n// Function: BusInterfaceInterface::addAbstractionType()\n//-----------------------------------------------------------------------------\nbool BusInterfaceInterface::addAbstractionType(std::string const& busName, std::string const& newVendor,\n    std::string const& newLibrary, std::string const& newName, std::string const& newVersion) const\n{\n    QSharedPointer<BusInterface> busInterface = getBusInterface(busName);\n    if (!busInterface)\n    {\n        return false;\n    }\n\n    General::InterfaceMode busMode = getActiveMode(busName);\n    QString systemGroup = getActiveSystemGroup(busName);\n\n    abstractionTypeInterface_->setAbstractionTypes(busInterface->getAbstractionTypes(), busMode, systemGroup);\n    abstractionTypeInterface_->addAbstractionType(newVendor, newLibrary, newName, newVersion);\n\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: BusInterfaceInterface::removeAbstractionTypes()\n//-----------------------------------------------------------------------------\nbool BusInterfaceInterface::removeAbstractionTypes(std::string const& busName)\n{\n    QSharedPointer<BusInterface> busInterface = getBusInterface(busName);\n    if (!busInterface)\n    {\n        return false;\n    }\n\n    General::InterfaceMode busMode = getActiveMode(busName);\n    QString systemGroup = getActiveSystemGroup(busName);\n\n    abstractionTypeInterface_->setAbstractionTypes(busInterface->getAbstractionTypes(), busMode, systemGroup);\n    for (int i = abstractionTypeInterface_->itemCount(); i >= 0; i--)\n    {\n        abstractionTypeInterface_->removeAbstraction(i);\n    }\n\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: BusInterfaceInterface::getRangeValue()\n//-----------------------------------------------------------------------------\nstd::string BusInterfaceInterface::getRangeValue(std::string const& busName, int const& baseNumber) const\n{\n    QSharedPointer<MirroredTargetInterface> selectedMirrorSlave = getMirroredSlaveInterface(busName);\n    if (selectedMirrorSlave)\n    {\n        QString range = selectedMirrorSlave->getRange();\n        return parseExpressionToBaseNumber(range, baseNumber).toStdString();\n    }\n\n    return std::string(\"\");\n}\n\n//-----------------------------------------------------------------------------\n// Function: BusInterfaceInterface::getRangeFormattedExpression()\n//-----------------------------------------------------------------------------\nstd::string BusInterfaceInterface::getRangeFormattedExpression(std::string const& busName) const\n{\n    QSharedPointer<MirroredTargetInterface> selectedMirrorSlave = getMirroredSlaveInterface(busName);\n    if (selectedMirrorSlave)\n    {\n        QString range = selectedMirrorSlave->getRange();\n        return formattedValueFor(range).toStdString();\n    }\n\n    return std::string(\"\");\n}\n\n//-----------------------------------------------------------------------------\n// Function: BusInterfaceInterface::getRangeExpression()\n//-----------------------------------------------------------------------------\nstd::string BusInterfaceInterface::getRangeExpression(std::string const& busName) const\n{\n    QSharedPointer<MirroredTargetInterface> selectedMirrorSlave = getMirroredSlaveInterface(busName);\n    if (selectedMirrorSlave)\n    {\n        return selectedMirrorSlave->getRange().toStdString();\n    }\n\n    return std::string(\"\");\n}\n\n//-----------------------------------------------------------------------------\n// Function: BusInterfaceInterface::setRange()\n//-----------------------------------------------------------------------------\nbool BusInterfaceInterface::setRange(std::string const& busName, std::string const& newRange)\n{\n    QSharedPointer<MirroredTargetInterface> mirrorSlave = createMirrorSlaveForBusInterface(busName);\n    if (!mirrorSlave)\n    {\n        return false;\n    }\n\n    mirrorSlave->setRange(QString::fromStdString(newRange));\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: BusInterfaceInterface::getRemapAddressValue()\n//-----------------------------------------------------------------------------\nstd::string BusInterfaceInterface::getRemapAddressValue(std::string const& busName, int const& baseNumber) const\n{\n    QSharedPointer<MirroredTargetInterface> selectedMirrorSlave = getMirroredSlaveInterface(busName);\n    if (selectedMirrorSlave && !selectedMirrorSlave->getRemapAddresses()->isEmpty())\n    {\n        QString remapAddress = selectedMirrorSlave->getRemapAddresses()->first()->remapAddress_;\n        return parseExpressionToBaseNumber(remapAddress, baseNumber).toStdString();\n    }\n\n    return std::string(\"\");\n}\n\n//-----------------------------------------------------------------------------\n// Function: BusInterfaceInterface::getRemapAddressFormattedExpression()\n//-----------------------------------------------------------------------------\nstd::string BusInterfaceInterface::getRemapAddressFormattedExpression(std::string const& busName) const\n{\n    QSharedPointer<MirroredTargetInterface> selectedMirrorSlave = getMirroredSlaveInterface(busName);\n    if (selectedMirrorSlave && !selectedMirrorSlave->getRemapAddresses()->isEmpty())\n    {\n        QString remapAddress = selectedMirrorSlave->getRemapAddresses()->first()->remapAddress_;\n        return formattedValueFor(remapAddress).toStdString();\n    }\n\n    return std::string(\"\");\n}\n\n//-----------------------------------------------------------------------------\n// Function: BusInterfaceInterface::getRemapAddressExpression()\n//-----------------------------------------------------------------------------\nstd::string BusInterfaceInterface::getRemapAddressExpression(std::string const& busName) const\n{\n    QSharedPointer<MirroredTargetInterface> selectedMirrorSlave = getMirroredSlaveInterface(busName);\n    if (selectedMirrorSlave && !selectedMirrorSlave->getRemapAddresses()->isEmpty())\n    {\n        return selectedMirrorSlave->getRemapAddresses()->first()->remapAddress_.toStdString();\n    }\n\n    return std::string(\"\");\n}\n\n//-----------------------------------------------------------------------------\n// Function: BusInterfaceInterface::setRemapAddress()\n//-----------------------------------------------------------------------------\nbool BusInterfaceInterface::setRemapAddress(std::string const& busName, std::string const& newRemapAddress)\n{\n    QSharedPointer<MirroredTargetInterface> selectedMirrorSlave = createMirrorSlaveForBusInterface(busName);\n    if (!selectedMirrorSlave)\n    {\n        return false;\n    }\n\n    selectedMirrorSlave->setRemapAddress(QString::fromStdString(newRemapAddress));\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: BusInterfaceInterface::getMonitorMode()\n//-----------------------------------------------------------------------------\nGeneral::InterfaceMode BusInterfaceInterface::getMonitorMode(std::string const& busName) const\n{\n    QSharedPointer<BusInterface::MonitorInterface> selectedMonitor = getMonitorInterface(busName);\n    if (selectedMonitor)\n    {\n        return selectedMonitor->interfaceMode_;\n    }\n\n    return General::INTERFACE_MODE_COUNT;\n}\n\n//-----------------------------------------------------------------------------\n// Function: BusInterfaceInterface::setMonitorMode()\n//-----------------------------------------------------------------------------\nbool BusInterfaceInterface::setMonitorMode(std::string const& busName, std::string const& newMode)\n{\n    QSharedPointer<BusInterface::MonitorInterface> selectedMonitor = createMonitorForBusInterface(busName);\n    if (!selectedMonitor)\n    {\n        return false;\n    }\n\n    General::InterfaceMode newInterfaceMode =\n        General::str2Interfacemode(QString::fromStdString(newMode), General::INTERFACE_MODE_COUNT);\n    selectedMonitor->interfaceMode_ = newInterfaceMode;\n\n    abstractionTypeInterface_->setBusMode(newInterfaceMode);\n\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: BusInterfaceInterface::getMonitorGroup()\n//-----------------------------------------------------------------------------\nstd::string BusInterfaceInterface::getMonitorGroup(std::string const& busName) const\n{\n    QSharedPointer<BusInterface::MonitorInterface> selectedMonitor = getMonitorInterface(busName);\n    if (selectedMonitor)\n    {\n        return selectedMonitor->group_.toStdString();\n    }\n\n    return \"\";\n}\n\n//-----------------------------------------------------------------------------\n// Function: BusInterfaceInterface::setMonitorGroup()\n//-----------------------------------------------------------------------------\nbool BusInterfaceInterface::setMonitorGroup(std::string const& busName, std::string const& newGroup)\n{\n    QSharedPointer<BusInterface::MonitorInterface> selectedMonitor = createMonitorForBusInterface(busName);\n    if (!selectedMonitor)\n    {\n        return false;\n    }\n\n    QString newGroupQ = QString::fromStdString(newGroup);\n\n    selectedMonitor->group_ = newGroupQ;\n\n    abstractionTypeInterface_->setSystemGroup(newGroupQ);\n\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: BusInterfaceInterface::getBridgeInterface()\n//-----------------------------------------------------------------------------\nTransparentBridgeInterface* BusInterfaceInterface::getBridgeInterface()\n{\n    return bridgeInterface_;\n}\n\n//-----------------------------------------------------------------------------\n// Function: BusInterfaceInterface::getFileSetInterface()\n//-----------------------------------------------------------------------------\nFileSetInterface* BusInterfaceInterface::getFileSetInterface() const\n{\n    return fileSetInterface_;\n}\n\n//-----------------------------------------------------------------------------\n// Function: BusInterfaceInterface::getMemoryMapInterface()\n//-----------------------------------------------------------------------------\nMemoryMapInterface* BusInterfaceInterface::getMemoryMapInterface() const\n{\n    return mapInterface_;\n}\n\n//-----------------------------------------------------------------------------\n// Function: BusInterfaceInterface::getAbstractionTypeInterface()\n//-----------------------------------------------------------------------------\nAbstractionTypeInterface* BusInterfaceInterface::getAbstractionTypeInterface() const\n{\n    return abstractionTypeInterface_;\n}\n\n//-----------------------------------------------------------------------------\n// Function: BusInterfaceInterface::getValidator()\n//-----------------------------------------------------------------------------\nQSharedPointer<BusInterfaceValidator> BusInterfaceInterface::getValidator() const\n{\n    return busValidator_;\n}\n\n//-----------------------------------------------------------------------------\n// Function: BusInterfaceInterface::getBridges()\n//-----------------------------------------------------------------------------\nQSharedPointer<QList<QSharedPointer<TransparentBridge> > > BusInterfaceInterface::getBridges(\n    std::string const& busName) const\n{\n    QSharedPointer<TargetInterface> slave = getTargetInterface(busName);\n    if (slave)\n    {\n        return slave->getBridges();\n    }\n\n    return QSharedPointer<QList<QSharedPointer<TransparentBridge> > >();\n}\n\n//-----------------------------------------------------------------------------\n// Function: BusInterfaceInterface::createBridges()\n//-----------------------------------------------------------------------------\nQSharedPointer<QList<QSharedPointer<TransparentBridge> > > BusInterfaceInterface::createBridges(\n    std::string const& busName)\n{\n    QSharedPointer<TargetInterface> slave = createTargetForBusInterface(busName);\n    if (slave)\n    {\n        return slave->getBridges();\n    }\n\n    return QSharedPointer<QList<QSharedPointer<TransparentBridge> > >();\n}\n\n//-----------------------------------------------------------------------------\n// Function: BusInterfaceInterface::getAllReferencesToIdInItem()\n//-----------------------------------------------------------------------------\nint BusInterfaceInterface::getAllReferencesToIdInItem(const std::string& itemName, std::string const& valueID) const\n{\n    int totalReferencesToParameter = 0;\n\n    QSharedPointer<BusInterface> selectedBus = getBusInterface(itemName);\n    if (selectedBus)\n    {\n        QString idString = QString::fromStdString(valueID);\n\n        QSharedPointer<InitiatorInterface> master = getInitiatorInterface(itemName);\n        if (master)\n        {\n            totalReferencesToParameter += QString::fromStdString(getBaseAddressExpression(itemName)).count(idString);\n        }\n\n\n        QSharedPointer<TargetInterface> slave = getTargetInterface(itemName);\n        if (slave)\n        {\n            totalReferencesToParameter += QString::fromStdString(getRangeExpression(itemName)).count(idString);\n            totalReferencesToParameter += QString::fromStdString(getRemapAddressExpression(itemName)).count(idString);\n\n            QSharedPointer<QList<QSharedPointer<TransparentBridge> > > bridges = slave->getBridges();\n            if (bridges)\n            {\n                bridgeInterface_->setBridges(bridges);\n                for (auto bridge : *bridges)\n                {\n                    totalReferencesToParameter +=\n                        bridgeInterface_->getAllReferencesToIdInItem(bridge->getMasterRef().toStdString(), valueID);\n                }\n            }\n        }\n\n        parameterInterface_->setParameters(selectedBus->getParameters());\n        for (auto parameterName : parameterInterface_->getItemNames())\n        {\n            totalReferencesToParameter += parameterInterface_->getAllReferencesToIdInItem(parameterName, valueID);\n        }\n    }\n\n    return totalReferencesToParameter;\n}\n\n//-----------------------------------------------------------------------------\n// Function: BusInterfaceInterface::getAllExpressions()\n//-----------------------------------------------------------------------------\nstd::vector<std::string> BusInterfaceInterface::getAllExpressions(std::string const& busName) const\n{\n    std::vector<std::string> expressionList;\n\n    QSharedPointer<BusInterface> selectedBus = getBusInterface(busName);\n    if (selectedBus)\n    {\n        QString baseAddress = QString::fromStdString(getBaseAddressExpression(busName));\n\n        if (!baseAddress.isEmpty())\n        {\n            expressionList.push_back(baseAddress.toStdString());\n        }\n\n        QSharedPointer<TargetInterface> slave = getTargetInterface(busName);\n        if (slave)\n        {\n            QString range = QString::fromStdString(getRangeExpression(busName));\n            QString remapAddress = QString::fromStdString(getRemapAddressExpression(busName));\n            if (!range.isEmpty())\n            {\n                expressionList.push_back(range.toStdString());\n            }\n            if (!remapAddress.isEmpty())\n            {\n                expressionList.push_back(remapAddress.toStdString());\n            }\n\n            QSharedPointer<QList<QSharedPointer<TransparentBridge> > > bridges = slave->getBridges();\n            if (bridges)\n            {\n                bridgeInterface_->setBridges(bridges);\n                for (auto bridge : *bridges)\n                {\n                    for (auto bridgeExpression :\n                        bridgeInterface_->getAllExpressions(bridge->getMasterRef().toStdString()))\n                    {\n                        expressionList.push_back(bridgeExpression);\n                    }\n                }\n            }\n        }\n\n        parameterInterface_->setParameters(selectedBus->getParameters());\n        for (auto expression :\n            parameterInterface_->getExpressionsInSelectedItems(parameterInterface_->getItemNames()))\n        {\n            expressionList.push_back(expression);\n        }\n    }\n\n    return expressionList;\n}\n\n//-----------------------------------------------------------------------------\n// Function: BusInterfaceInterface::copyRows()\n//-----------------------------------------------------------------------------\nvoid BusInterfaceInterface::copyRows(std::vector<int> selectedRows)\n{\n    QList<QSharedPointer<BusInterface> > copiedBuses;\n    for (auto index : selectedRows)\n    {\n        QSharedPointer<BusInterface> currentBus = busInterfaces_->at(index);\n        copiedBuses.append(currentBus);\n    }\n\n    QVariant registerVariant;\n    registerVariant.setValue(copiedBuses);\n\n    QMimeData* newMimeData = new QMimeData();\n    newMimeData->setData(\"text/xml/ipxact:register\", QByteArray());\n    newMimeData->setImageData(registerVariant);\n\n    QApplication::clipboard()->setMimeData(newMimeData);\n}\n\n//-----------------------------------------------------------------------------\n// Function: BusInterfaceInterface::pasteRows()\n//-----------------------------------------------------------------------------\nstd::vector<std::string> BusInterfaceInterface::pasteRows()\n{\n    std::vector<std::string> pastedBusNames;\n\n    const QMimeData* pasteData = QApplication::clipboard()->mimeData();\n\n    if (pasteData->hasImage())\n    {\n        QVariant pasteVariant = pasteData->imageData();\n        if (pasteVariant.canConvert<QList<QSharedPointer<BusInterface> > >())\n        {\n            QList<QSharedPointer<BusInterface> > copiedBusList =\n                pasteVariant.value<QList<QSharedPointer<BusInterface>>>();\n\n            for (auto copiedBus : copiedBusList)\n            {\n                QSharedPointer<BusInterface> newBus(new BusInterface(*copiedBus.data()));\n                newBus->setName(getUniqueName(newBus->name().toStdString(), DEFAULT_NAME.toStdString()));\n                busInterfaces_->append(newBus);\n\n                pastedBusNames.push_back(newBus->name().toStdString());\n            }\n        }\n    }\n\n    return pastedBusNames;\n}\n\n//-----------------------------------------------------------------------------\n// Function: BusInterfaceInterface::getPasteRowCount()\n//-----------------------------------------------------------------------------\nint BusInterfaceInterface::getPasteRowCount() const\n{\n    const QMimeData* pasteData = QApplication::clipboard()->mimeData();\n    if (pasteData->hasImage())\n    {\n        QVariant pasteVariant = pasteData->imageData();\n        if (pasteVariant.canConvert<QList<QSharedPointer<BusInterface> > >())\n        {\n            QList<QSharedPointer<BusInterface> > newBuses =\n                pasteVariant.value<QList<QSharedPointer<BusInterface> > >();\n            return newBuses.count();\n        }\n    }\n\n    return 0;\n}\n"
  },
  {
    "path": "KactusAPI/interfaces/component/BusInterfaceInterfaceFactory.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: BusInterfaceInterfaceFactory.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 24.03.2021\n//\n// Description:\n// Constructs the bus interface interface.\n//-----------------------------------------------------------------------------\n\n#include <BusInterfaceInterfaceFactory.h>\n\n#include <IPXACTmodels/Component/Component.h>\n#include <IPXACTmodels/Component/validators/PortMapValidator.h>\n#include <IPXACTmodels/Component/validators/BusInterfaceValidator.h>\n#include <IPXACTmodels/Component/validators/FileValidator.h>\n#include <IPXACTmodels/Component/validators/FileSetValidator.h>\n#include <IPXACTmodels/Component/validators/EnumeratedValueValidator.h>\n#include <IPXACTmodels/Component/validators/FieldValidator.h>\n#include <IPXACTmodels/Component/validators/RegisterValidator.h>\n#include <IPXACTmodels/Component/validators/RegisterFileValidator.h>\n#include <IPXACTmodels/Component/validators/AddressBlockValidator.h>\n#include <IPXACTmodels/Component/validators/MemoryMapValidator.h>\n#include <IPXACTmodels/Component/validators/AbstractionTypeValidator.h>\n#include <IPXACTmodels/Component/validators/PortValidator.h>\n#include <IPXACTmodels/Component/validators/SubspaceMapValidator.h>\n#include <IPXACTmodels/common/validators/ParameterValidator.h>\n\n#include <PortAbstractionInterface.h>\n#include <BusInterfaceInterface.h>\n#include <AbstractionTypeInterface.h>\n#include <TransparentBridgeInterface.h>\n#include <PortMapInterface.h>\n#include <FileSetInterface.h>\n#include <FileInterface.h>\n#include <FileBuilderInterface.h>\n#include <MemoryMapInterface.h>\n#include <ParametersInterface.h>\n#include <PortsInterface.h>\n\n//-----------------------------------------------------------------------------\n// Function: BusInterfaceInterfaceFactory::createBusInterface()\n//-----------------------------------------------------------------------------\nBusInterfaceInterface* BusInterfaceInterfaceFactory::createBusInterface(\n    QSharedPointer<ParameterFinder> parameterFinder, QSharedPointer<ExpressionFormatter> expressionFormatter,\n    QSharedPointer<ExpressionParser> expressionParser, QSharedPointer<Component> component,\n    LibraryInterface* library)\n{\n    QSharedPointer<PortMapValidator> portMapValidator(\n        new PortMapValidator(expressionParser, component->getPorts(), library));\n\n    AbstractionTypeInterface* abstractionInterface = Details::createAbstractionTypeInterface(\n        parameterFinder, expressionFormatter, expressionParser, portMapValidator, component, library);\n\n    return Details::createCommonBusInterfaceItems(parameterFinder, expressionFormatter, expressionParser,\n        component, library, portMapValidator, abstractionInterface);\n}\n\n//-----------------------------------------------------------------------------\n// Function: BusInterfaceInterfaceFactory::createCommonBusInterfaceItems()\n//-----------------------------------------------------------------------------\nBusInterfaceInterface* BusInterfaceInterfaceFactory::Details::createCommonBusInterfaceItems(\n    QSharedPointer<ParameterFinder> parameterFinder, QSharedPointer<ExpressionFormatter> expressionFormatter,\n    QSharedPointer<ExpressionParser> expressionParser, QSharedPointer<Component> component,\n    LibraryInterface* library, QSharedPointer<PortMapValidator> portMapValidator,\n    AbstractionTypeInterface* abstractionInterface)\n{\n    FileSetInterface* fileSetInterface =\n        Details::createFileSetInterface(parameterFinder, expressionFormatter, expressionParser, component);\n    fileSetInterface->setFileSets(component->getFileSets());\n\n    QSharedPointer<ParameterValidator> parameterValidator(new ParameterValidator(expressionParser,\n        component->getChoices(), component->getRevision()));\n\n    ParametersInterface* parameterInterface =\n        Details::createParameterInterface(parameterValidator, expressionParser, expressionFormatter);\n\n    MemoryMapInterface* mapInterface =\n        Details::createMapInterface(parameterFinder, expressionFormatter, expressionParser, parameterValidator, component);\n\n    TransparentBridgeInterface* bridgeInterface =\n        Details::createBridgeInterface(expressionFormatter, expressionParser);\n\n    QSharedPointer<BusInterfaceValidator> busValidator(new BusInterfaceValidator(expressionParser,\n        component->getChoices(), component->getViews(), component->getPorts(), component->getAddressSpaces(),\n        component->getMemoryMaps(), component->getBusInterfaces(), component->getFileSets(),\n        component->getRemapStates(), component->getModes(), portMapValidator, parameterValidator, library));\n\n    BusInterfaceInterface* busInterface(new BusInterfaceInterface(busValidator, expressionParser,\n        expressionFormatter));\n\n    busInterface->setFileSetInterface(fileSetInterface);\n    busInterface->setMemoryMapInterface(mapInterface);\n    busInterface->setAbstractionTypeInterface(abstractionInterface);\n    busInterface->setTransparentBridgeInterface(bridgeInterface);\n    busInterface->setParameterInterface(parameterInterface);\n\n    busInterface->setBusInterfaces(component);\n    return busInterface;\n}\n\n//-----------------------------------------------------------------------------\n// Function: BusInterfaceInterfaceFactory::createFileSetInterface()\n//-----------------------------------------------------------------------------\nFileSetInterface* BusInterfaceInterfaceFactory::Details::createFileSetInterface(\n    QSharedPointer<ParameterFinder> parameterFinder, QSharedPointer<ExpressionFormatter> expressionFormatter,\n    QSharedPointer<ExpressionParser> expressionParser, QSharedPointer<Component> component)\n{\n    QSharedPointer<FileValidator> fileValidator(new FileValidator(expressionParser));\n    QSharedPointer<FileSetValidator> fileSetValidator(new FileSetValidator(fileValidator, expressionParser));\n\n    FileInterface* fileInterface(new FileInterface(fileValidator, expressionParser, expressionFormatter));\n    FileBuilderInterface* fileBuilderInterface(new FileBuilderInterface(expressionParser, expressionFormatter));\n\n    FileSetInterface* fileSetInterface(new FileSetInterface(\n        fileSetValidator, expressionParser, expressionFormatter, fileInterface, fileBuilderInterface));\n\n    fileSetInterface->setFileSets(component->getFileSets());\n\n    return fileSetInterface;\n}\n\n//-----------------------------------------------------------------------------\n// Function: BusInterfaceInterfaceFactory::createMapInterface()\n//-----------------------------------------------------------------------------\nMemoryMapInterface* BusInterfaceInterfaceFactory::Details::createMapInterface(\n    QSharedPointer<ParameterFinder> parameterFinder, QSharedPointer<ExpressionFormatter> expressionFormatter,\n    QSharedPointer<ExpressionParser> expressionParser, QSharedPointer<ParameterValidator> parameterValidator,\n    QSharedPointer<Component> component)\n{\n    QSharedPointer<EnumeratedValueValidator> enumValidator(new EnumeratedValueValidator(expressionParser));\n    QSharedPointer<FieldValidator> fieldValidator(\n        new FieldValidator(expressionParser, enumValidator, parameterValidator));\n    QSharedPointer<RegisterValidator> registerValidator(\n        new RegisterValidator(expressionParser, fieldValidator, parameterValidator));\n    QSharedPointer<RegisterFileValidator> registerFileValidator(\n        new RegisterFileValidator(expressionParser, registerValidator, parameterValidator, component->getRevision()));\n\n    QSharedPointer<AddressBlockValidator> blockValidator(\n        new AddressBlockValidator(expressionParser, registerValidator, registerFileValidator, parameterValidator, \n            component->getRevision()));\n\n    QSharedPointer<SubspaceMapValidator> subspaceValidator(\n        new SubspaceMapValidator(expressionParser, parameterValidator, component->getRevision()));\n\n    QSharedPointer<MemoryMapValidator> memoryMapValidator(\n        new MemoryMapValidator(expressionParser, blockValidator, subspaceValidator, component));\n\n    memoryMapValidator->componentChange(component);\n\n    MemoryMapInterface* mapInterface =\n        new MemoryMapInterface(memoryMapValidator, expressionParser, expressionFormatter);\n\n    mapInterface->setMemoryMaps(component);\n\n    return mapInterface;\n}\n\n//-----------------------------------------------------------------------------\n// Function: BusInterfaceInterfaceFactory::createAbstractionTypeInterface()\n//-----------------------------------------------------------------------------\nAbstractionTypeInterface* BusInterfaceInterfaceFactory::Details::createAbstractionTypeInterface(\n    QSharedPointer<ParameterFinder> parameterFinder, QSharedPointer<ExpressionFormatter> expressionFormatter,\n    QSharedPointer<ExpressionParser> expressionParser, QSharedPointer<PortMapValidator> portMapValidator,\n    QSharedPointer<Component> component, LibraryInterface* library)\n{\n    PortMapInterface* portMapInterface = createPortMapInterface(parameterFinder, expressionFormatter,\n        expressionParser, portMapValidator, component);\n\n    return createCommonAbstractionTypeInterface(\n        expressionParser, component, portMapValidator, library, portMapInterface);\n}\n\n//-----------------------------------------------------------------------------\n// Function: BusInterfaceInterfaceFactory::createCommonAbstractionTypeInterface()\n//-----------------------------------------------------------------------------\nAbstractionTypeInterface* BusInterfaceInterfaceFactory::Details::createCommonAbstractionTypeInterface(\n    QSharedPointer<ExpressionParser> expressionParser, QSharedPointer<Component> component,\n    QSharedPointer<PortMapValidator> portMapValidator, LibraryInterface* library,\n    PortMapInterface* portMapInterface)\n{\n    QSharedPointer<AbstractionTypeValidator> validator(\n        new AbstractionTypeValidator(expressionParser, component->getViews(), portMapValidator, library));\n\n    AbstractionTypeInterface* abstractionInterface(\n        new AbstractionTypeInterface(portMapInterface, validator, library));\n    return abstractionInterface;\n}\n\n//-----------------------------------------------------------------------------\n// Function: BusInterfaceInterfaceFactory::createPortMapInterface()\n//-----------------------------------------------------------------------------\nPortMapInterface* BusInterfaceInterfaceFactory::Details::createPortMapInterface(\n    QSharedPointer<ParameterFinder> parameterFinder, QSharedPointer<ExpressionFormatter> expressionFormatter,\n    QSharedPointer<ExpressionParser> expressionParser, QSharedPointer<PortMapValidator> portMapValidator,\n    QSharedPointer<Component> component)\n{\n    QSharedPointer<PortValidator> portValidator(new PortValidator(expressionParser, component->getViews()));\n\n    PortsInterface* physicalPortInterface(new PortsInterface(portValidator, expressionParser, expressionFormatter));\n    physicalPortInterface->setPorts(component->getPorts());\n\n    PortAbstractionInterface* logicalPortInterface(new PortAbstractionInterface(expressionParser, expressionFormatter));\n    PortMapInterface* portMapInterface(new PortMapInterface(\n        portMapValidator, expressionParser, expressionFormatter, physicalPortInterface, logicalPortInterface));\n\n    return portMapInterface;\n}\n\n//-----------------------------------------------------------------------------\n// Function: BusInterfaceInterfaceFactory::createBridgeInterface()\n//-----------------------------------------------------------------------------\nTransparentBridgeInterface* BusInterfaceInterfaceFactory::Details::createBridgeInterface(\n    QSharedPointer<ExpressionFormatter> expressionFormatter, QSharedPointer<ExpressionParser> expressionParser)\n{\n    TransparentBridgeInterface* bridgeInterface(\n        new TransparentBridgeInterface(expressionParser, expressionFormatter));\n    return bridgeInterface;\n}\n\n//-----------------------------------------------------------------------------\n// Function: BusInterfaceInterfaceFactory::createParameterInterface()\n//-----------------------------------------------------------------------------\nParametersInterface* BusInterfaceInterfaceFactory::Details::createParameterInterface(\n    QSharedPointer<ParameterValidator> validator, QSharedPointer<ExpressionParser> expressionParser,\n    QSharedPointer<ExpressionFormatter> expressionFormatter)\n{\n    ParametersInterface* parameterInterface =\n        new ParametersInterface(validator, expressionParser, expressionFormatter);\n\n    return parameterInterface;\n}\n\n"
  },
  {
    "path": "KactusAPI/interfaces/component/BusInterfaceUtilities.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: BusInterfaceUtilities.h\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Mikko Teuho\n// Date: 15.02.2019\n//\n// Description:\n// Utilities for bus interface mode compatibilities.\n//-----------------------------------------------------------------------------\n\n#include <KactusAPI/include/BusInterfaceUtilities.h>\n\n#include <IPXACTmodels/BusDefinition/BusDefinition.h>\n\n#include <KactusAPI/include/LibraryInterface.h>\n\n//-----------------------------------------------------------------------------\n// Function: BusInterfaceUtilities::hasMatchingBusDefinitions()\n//-----------------------------------------------------------------------------\nbool BusInterfaceUtilities::hasMatchingBusDefinitions(QSharedPointer<const BusDefinition> firstDefinition,\n    VLNV const& secondDefinitionVLNV, LibraryInterface* library)\n{\n    if (firstDefinition)\n    {\n        QSharedPointer<const BusDefinition> comparisonDefinition =\n            library->getModelReadOnly(secondDefinitionVLNV).dynamicCast<const BusDefinition>();\n        if (comparisonDefinition)\n        {\n            if (firstDefinition == comparisonDefinition)\n            {\n                return true;\n            }\n            else\n            {\n                VLNV comparisonExtendVLNV = comparisonDefinition->getExtends();\n                VLNV firstExtendVLNV = firstDefinition->getExtends();\n\n                if ((comparisonExtendVLNV.isValid() &&\n                    hasMatchingBusDefinitions(firstDefinition, comparisonExtendVLNV, library)) ||\n                    (firstExtendVLNV.isValid() &&\n                        hasMatchingBusDefinitions(comparisonDefinition, firstExtendVLNV, library)))\n                {\n                    return true;\n                }\n            }\n        }\n    }\n\n    return false;\n}\n\n//-----------------------------------------------------------------------------\n// Function: BusInterfaceUtilities::hasMatchingBusDefinitions()\n//-----------------------------------------------------------------------------\nbool BusInterfaceUtilities::busDefinitionVLNVsMatch(VLNV const& firstDefinitionVLNV,\n    VLNV const& secondDefinitionVLNV, LibraryInterface* library)\n{\n    QSharedPointer<const BusDefinition> firstDefinition =\n        library->getModelReadOnly(firstDefinitionVLNV).dynamicCast<const BusDefinition>();\n    if (firstDefinition)\n    {\n        return BusInterfaceUtilities::hasMatchingBusDefinitions(firstDefinition, secondDefinitionVLNV, library);\n    }\n\n    return false;\n}\n\n//-----------------------------------------------------------------------------\n// Function: BusInterfaceUtilities::getIconPath()\n//-----------------------------------------------------------------------------\nQString BusInterfaceUtilities::getIconPath(General::InterfaceMode busMode)\n{\n    QString iconPath(\"\");\n    if (busMode == General::MASTER || busMode == General::INITIATOR)\n    {\n        iconPath = \":icons/common/graphics/busInterfaceMaster.png\";\n    }\n    else if (busMode == General::MIRRORED_MASTER || busMode == General::MIRRORED_INITIATOR)\n    {\n        iconPath = \":icons/common/graphics/busInterfaceMirroredMaster.png\";\n    }\n    else if (busMode == General::SLAVE || busMode == General::TARGET)\n    {\n        iconPath = \":icons/common/graphics/busInterfaceSlave.png\";\n    }\n    else if (busMode == General::MIRRORED_SLAVE || busMode == General::MIRRORED_TARGET)\n    {\n        iconPath = \":icons/common/graphics/busInterfaceMirroredSlave.png\";\n    }\n    else if (busMode == General::SYSTEM)\n    {\n        iconPath = \":icons/common/graphics/busInterfaceSystem.png\";\n    }\n    else if (busMode == General::MIRRORED_SYSTEM)\n    {\n        iconPath = \":icons/common/graphics/busInterfaceMirroredSystem.png\";\n    }\n    else if (busMode == General::MONITOR)\n    {\n        iconPath = \":icons/common/graphics/busInterfaceMonitor.png\";\n    }\n\n    return iconPath;\n}\n"
  },
  {
    "path": "KactusAPI/interfaces/component/ComponentInstantiationInterface.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: ComponentInstantiationInterface.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 23.09.2020\n//\n// Description:\n// Interface for editing component instantiations.\n//-----------------------------------------------------------------------------\n\n#include \"ComponentInstantiationInterface.h\"\n\n#include <IPXACTmodels/Component/ComponentInstantiation.h>\n#include <IPXACTmodels/Component/validators/InstantiationsValidator.h>\n\n#include <ParametersInterface.h>\n#include <ModuleParameterInterface.h>\n#include <FileBuilderInterface.h>\n\nnamespace\n{\n    std::string const COMPONENT_INSTANTIATION_TYPE = \"instantiation\";\n    QString const USERFILETYPE = \"user\";\n};\n\n//-----------------------------------------------------------------------------\n// Function: ComponentInstantiationInterface::ComponentInstantiationInterface()\n//-----------------------------------------------------------------------------\nComponentInstantiationInterface::ComponentInstantiationInterface(QSharedPointer<InstantiationsValidator> validator,\n    QSharedPointer<ExpressionParser> expressionParser, QSharedPointer<ExpressionFormatter> expressionFormatter,\n    ParametersInterface* parameterInterface, ModuleParameterInterface* moduleParameterInterface,\n    FileBuilderInterface* fileBuilderInterface, FileSetInterface* fileSetInterface):\nParameterizableInterface(expressionParser, expressionFormatter),\ninstantiations_(),\nvalidator_(validator),\nparameterInterface_(parameterInterface),\nmoduleParameterInterface_(moduleParameterInterface),\nfileBuilderInterface_(fileBuilderInterface),\nfileSetInterface_(fileSetInterface)\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: ComponentInstantiationInterface::setAddressBlocks()\n//-----------------------------------------------------------------------------\nvoid ComponentInstantiationInterface::setComponentInstantiations(\n    QSharedPointer<QList<QSharedPointer<ComponentInstantiation>>> newInstantiations)\n{\n    instantiations_ = newInstantiations;\n}\n\n//-----------------------------------------------------------------------------\n// Function: ComponentInstantiationInterface::getItemIndex()\n//-----------------------------------------------------------------------------\nint ComponentInstantiationInterface::getItemIndex(std::string const& itemName) const\n{\n    for (int i = 0; i < instantiations_->size(); ++i)\n    {\n        if (instantiations_->at(i)->name().toStdString() == itemName)\n        {\n            return i;\n        }\n    }\n\n    return -1;\n}\n\n//-----------------------------------------------------------------------------\n// Function: ComponentInstantiationInterface::getIndexedItemName()\n//-----------------------------------------------------------------------------\nstd::string ComponentInstantiationInterface::getIndexedItemName(int itemIndex) const\n{\n    std::string instantiationName = \"\";\n    if (itemIndex >= 0 && itemIndex < instantiations_->size())\n    {\n        instantiationName = instantiations_->at(itemIndex)->name().toStdString();\n    }\n\n    return instantiationName;\n}\n\n//-----------------------------------------------------------------------------\n// Function: ComponentInstantiationInterface::itemCount()\n//-----------------------------------------------------------------------------\nint ComponentInstantiationInterface::itemCount() const\n{\n    return instantiations_->count();\n}\n\n//-----------------------------------------------------------------------------\n// Function: ComponentInstantiationInterface::getItemNames()\n//-----------------------------------------------------------------------------\nstd::vector<std::string> ComponentInstantiationInterface::getItemNames() const\n{\n    std::vector<std::string> names;\n    for (auto instantiation : *instantiations_)\n    {\n        names.push_back(instantiation->name().toStdString());\n    }\n\n    return names;\n}\n\n//-----------------------------------------------------------------------------\n// Function: ComponentInstantiationInterface::setName()\n//-----------------------------------------------------------------------------\nbool ComponentInstantiationInterface::setName(std::string const& currentName, std::string const& newName)\n{\n    QSharedPointer<ComponentInstantiation> editedItem = getComponentInstantiation(currentName);\n    if (editedItem && nameHasChanged(newName, currentName))\n    {\n        QString uniqueNewName = getUniqueName(newName, COMPONENT_INSTANTIATION_TYPE);\n\n        editedItem->setName(uniqueNewName);\n        return true;\n    }\n    else\n    {\n        return false;\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: ComponentInstantiationInterface::getDisplayName()\n//-----------------------------------------------------------------------------\nstd::string ComponentInstantiationInterface::getDisplayName(std::string const& itemName) const\n{\n    QSharedPointer<ComponentInstantiation> editedItem = getComponentInstantiation(itemName);\n    if (editedItem)\n    {\n        return editedItem->displayName().toStdString();\n    }\n\n    return std::string(\"\");\n}\n\n//-----------------------------------------------------------------------------\n// Function: ComponentInstantiationInterface::setDisplayName()\n//-----------------------------------------------------------------------------\nbool ComponentInstantiationInterface::setDisplayName(std::string const& itemName,\n    std::string const& newDisplayName)\n{\n    QSharedPointer<ComponentInstantiation> editedItem = getComponentInstantiation(itemName);\n    if (!editedItem)\n    {\n        return false;\n    }\n\n    editedItem->setDisplayName(QString::fromStdString(newDisplayName));\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: ComponentInstantiationInterface::getAllReferencesToIdInItem()\n//-----------------------------------------------------------------------------\nint ComponentInstantiationInterface::getAllReferencesToIdInItem(\n    const std::string& itemName, std::string const&  valueID) const\n{\n    int totalReferencesToParameter = 0;\n\n    QSharedPointer<ComponentInstantiation> selectedItem = getComponentInstantiation(itemName);\n    if (selectedItem)\n    {\n        QString idString = QString::fromStdString(valueID);\n\n        int referencesInParameters = 0;\n        parameterInterface_->setParameters(selectedItem->getParameters());\n        for (auto parameter : *selectedItem->getParameters())\n        {\n            referencesInParameters +=\n                parameterInterface_->getAllReferencesToIdInItem(parameter->name().toStdString(), valueID);\n        }\n\n        int referencesInModuleParameters = 0;\n        moduleParameterInterface_->setModuleParameters(selectedItem);\n        for (auto parameter : *selectedItem->getModuleParameters())\n        {\n            referencesInModuleParameters +=\n                parameterInterface_->getAllReferencesToIdInItem(parameter->name().toStdString(), valueID);\n        }\n\n        int referencesInFileBuilders = 0;\n        fileBuilderInterface_->setFileBuilders(selectedItem->getDefaultFileBuilders());\n        for (auto builder : *selectedItem->getDefaultFileBuilders())\n        {\n            QString builderID = builder->getFileType().type_;\n\n            referencesInFileBuilders +=\n                fileBuilderInterface_->getAllReferencesToIdInItem(builderID.toStdString(), valueID);\n        }\n\n\n        totalReferencesToParameter =\n            referencesInParameters + referencesInModuleParameters + referencesInFileBuilders;\n    }\n\n    return totalReferencesToParameter;\n}\n\n//-----------------------------------------------------------------------------\n// Function: ComponentInstantiationInterface::getExpressionsInSelectedItems()\n//-----------------------------------------------------------------------------\nstd::vector<std::string> ComponentInstantiationInterface::getExpressionsInSelectedItems(\n    std::vector<std::string> instantiationNames) const\n{\n    std::vector<std::string> expressionList;\n\n    for (auto name : instantiationNames)\n    {\n        QSharedPointer<ComponentInstantiation> selectedItem = getComponentInstantiation(name);\n        if (selectedItem)\n        {\n            parameterInterface_->setParameters(selectedItem->getParameters());\n            for (auto expression :\n                parameterInterface_->getExpressionsInSelectedItems(parameterInterface_->getItemNames()))\n            {\n                expressionList.push_back(expression);\n            }\n\n            moduleParameterInterface_->setModuleParameters(selectedItem);\n            for (auto expression : moduleParameterInterface_->getExpressionsInSelectedItems(\n                moduleParameterInterface_->getItemNames()))\n            {\n                expressionList.push_back(expression);\n            }\n\n            fileBuilderInterface_->setFileBuilders(selectedItem->getDefaultFileBuilders());\n            for (auto expression :\n                fileBuilderInterface_->getExpressionsInSelectedFileBuilders(fileBuilderInterface_->getItemNames()))\n            {\n                expressionList.push_back(expression);\n            }\n        }\n    }\n\n    return expressionList;\n}\n\n//-----------------------------------------------------------------------------\n// Function: ComponentInstantiationInterface::validateItems()\n//-----------------------------------------------------------------------------\nbool ComponentInstantiationInterface::validateItems() const\n{\n    for (auto currentItem : *instantiations_)\n    {\n        if (!validator_->validateComponentInstantiation(currentItem))\n        {\n            return false;\n        }\n    }\n\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: ComponentInstantiationInterface::itemHasValidName()\n//-----------------------------------------------------------------------------\nbool ComponentInstantiationInterface::itemHasValidName(std::string const& itemName) const\n{\n    return validator_->hasValidName(QString::fromStdString(itemName));\n}\n\n//-----------------------------------------------------------------------------\n// Function: ComponentInstantiationInterface::getComponentInstantiation()\n//-----------------------------------------------------------------------------\nQSharedPointer<ComponentInstantiation> ComponentInstantiationInterface::getComponentInstantiation(\n    std::string const& itemName) const\n{\n    for (auto instantiation : *instantiations_)\n    {\n        if (instantiation->name().toStdString() == itemName)\n        {\n            return instantiation;\n        }\n    }\n\n    return QSharedPointer<ComponentInstantiation>();\n}\n\n//-----------------------------------------------------------------------------\n// Function: ComponentInstantiationInterface::addComponentInstantiation()\n//-----------------------------------------------------------------------------\nvoid ComponentInstantiationInterface::addComponentInstantiation(int const& row,\n    std::string const& newInstantiationName)\n{\n    QSharedPointer<ComponentInstantiation> newInstantiation(new ComponentInstantiation());\n    newInstantiation->setName(getUniqueName(newInstantiationName, COMPONENT_INSTANTIATION_TYPE));\n\n    instantiations_->insert(row, newInstantiation);\n}\n\n//-----------------------------------------------------------------------------\n// Function: ComponentInstantiationInterface::removeComponentInstantiation()\n//-----------------------------------------------------------------------------\nbool ComponentInstantiationInterface::removeComponentInstantiation(std::string const& instantiationName)\n{\n    QSharedPointer<ComponentInstantiation> removedItem = getComponentInstantiation(instantiationName);\n    if (!removedItem)\n    {\n        return false;\n    }\n\n    return instantiations_->removeOne(removedItem);\n}\n\n//-----------------------------------------------------------------------------\n// Function: ComponentInstantiationInterface::getParameterInterface()\n//-----------------------------------------------------------------------------\nParametersInterface* ComponentInstantiationInterface::getParameterInterface() const\n{\n    return parameterInterface_;\n}\n\n//-----------------------------------------------------------------------------\n// Function: ComponentInstantiationInterface::getModuleParameterInterface()\n//-----------------------------------------------------------------------------\nModuleParameterInterface* ComponentInstantiationInterface::getModuleParameterInterface() const\n{\n    return moduleParameterInterface_;\n}\n\n//-----------------------------------------------------------------------------\n// Function: ComponentInstantiationInterface::getFileBuilderInterface()\n//-----------------------------------------------------------------------------\nFileBuilderInterface* ComponentInstantiationInterface::getFileBuilderInterface() const\n{\n    return fileBuilderInterface_;\n}\n\n//-----------------------------------------------------------------------------\n// Function: ComponentInstantiationInterface::getFileSetInterface()\n//-----------------------------------------------------------------------------\nFileSetInterface* ComponentInstantiationInterface::getFileSetInterface() const\n{\n    return fileSetInterface_;\n}\n\n//-----------------------------------------------------------------------------\n// Function: ComponentInstantiationInterface::getLanguage()\n//-----------------------------------------------------------------------------\nstd::string ComponentInstantiationInterface::getLanguage(std::string const& instantiationName) const\n{\n    QSharedPointer<ComponentInstantiation> editedInstantiation = getComponentInstantiation(instantiationName);\n    if (editedInstantiation)\n    {\n        return editedInstantiation->getLanguage().toStdString();\n    }\n\n    return std::string(\"\");\n}\n\n//-----------------------------------------------------------------------------\n// Function: ComponentInstantiationInterface::setLanguage()\n//-----------------------------------------------------------------------------\nbool ComponentInstantiationInterface::setLanguage(std::string const& instantiationName,\n    std::string const& newLanguage)\n{\n    QSharedPointer<ComponentInstantiation> editedItem = getComponentInstantiation(instantiationName);\n    if (!editedItem)\n    {\n        return false;\n    }\n\n    editedItem->setLanguage(QString::fromStdString(newLanguage));\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: ComponentInstantiationInterface::isLanguageStrict()\n//-----------------------------------------------------------------------------\nbool ComponentInstantiationInterface::isLanguageStrict(std::string const& instantiationName) const\n{\n    QSharedPointer<ComponentInstantiation> editedInstantiation = getComponentInstantiation(instantiationName);\n    if (editedInstantiation)\n    {\n        return editedInstantiation->isLanguageStrict();\n    }\n\n    return false;\n}\n\n//-----------------------------------------------------------------------------\n// Function: ComponentInstantiationInterface::setLanguageStrictness()\n//-----------------------------------------------------------------------------\nbool ComponentInstantiationInterface::setLanguageStrictness(std::string const& instantiationName,\n    bool newStrictness)\n{\n    QSharedPointer<ComponentInstantiation> editedItem = getComponentInstantiation(instantiationName);\n    if (!editedItem)\n    {\n        return false;\n    }\n\n    editedItem->setLanguageStrictness(newStrictness);\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: ComponentInstantiationInterface::getLibraryName()\n//-----------------------------------------------------------------------------\nstd::string ComponentInstantiationInterface::getLibraryName(std::string const& instantiationName) const\n{\n    QSharedPointer<ComponentInstantiation> editedInstantiation = getComponentInstantiation(instantiationName);\n    if (editedInstantiation)\n    {\n        return editedInstantiation->getLibraryName().toStdString();\n    }\n\n    return std::string(\"\");\n}\n\n//-----------------------------------------------------------------------------\n// Function: ComponentInstantiationInterface::setLibraryName()\n//-----------------------------------------------------------------------------\nbool ComponentInstantiationInterface::setLibraryName(std::string const& instantiationName,\n    std::string const& newLibraryName)\n{\n    QSharedPointer<ComponentInstantiation> editedItem = getComponentInstantiation(instantiationName);\n    if (!editedItem)\n    {\n        return false;\n    }\n\n    editedItem->setLibraryName(QString::fromStdString(newLibraryName));\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: ComponentInstantiationInterface::getPackageName()\n//-----------------------------------------------------------------------------\nstd::string ComponentInstantiationInterface::getPackageName(std::string const& instantiationName) const\n{\n    QSharedPointer<ComponentInstantiation> editedInstantiation = getComponentInstantiation(instantiationName);\n    if (editedInstantiation)\n    {\n        return editedInstantiation->getPackageName().toStdString();\n    }\n\n    return std::string(\"\");\n}\n\n//-----------------------------------------------------------------------------\n// Function: ComponentInstantiationInterface::setPackageName()\n//-----------------------------------------------------------------------------\nbool ComponentInstantiationInterface::setPackageName(std::string const& instantiationName,\n    std::string const& newPackageName)\n{\n    QSharedPointer<ComponentInstantiation> editedItem = getComponentInstantiation(instantiationName);\n    if (!editedItem)\n    {\n        return false;\n    }\n\n    editedItem->setPackageName(QString::fromStdString(newPackageName));\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: ComponentInstantiationInterface::getModuleName()\n//-----------------------------------------------------------------------------\nstd::string ComponentInstantiationInterface::getModuleName(std::string const& instantiationName) const\n{\n    QSharedPointer<ComponentInstantiation> editedInstantiation = getComponentInstantiation(instantiationName);\n    if (editedInstantiation)\n    {\n        return editedInstantiation->getModuleName().toStdString();\n    }\n\n    return std::string(\"\");\n}\n\n//-----------------------------------------------------------------------------\n// Function: ComponentInstantiationInterface::setModuleName()\n//-----------------------------------------------------------------------------\nbool ComponentInstantiationInterface::setModuleName(std::string const& instantiationName,\n    std::string const& newModuleName)\n{\n    QSharedPointer<ComponentInstantiation> editedItem = getComponentInstantiation(instantiationName);\n    if (!editedItem)\n    {\n        return false;\n    }\n\n    editedItem->setModuleName(QString::fromStdString(newModuleName));\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: ComponentInstantiationInterface::getArchitectureName()\n//-----------------------------------------------------------------------------\nstd::string ComponentInstantiationInterface::getArchitectureName(std::string const& instantiationName) const\n{\n    QSharedPointer<ComponentInstantiation> editedInstantiation = getComponentInstantiation(instantiationName);\n    if (editedInstantiation)\n    {\n        return editedInstantiation->getArchitectureName().toStdString();\n    }\n\n    return std::string(\"\");\n}\n\n//-----------------------------------------------------------------------------\n// Function: ComponentInstantiationInterface::setArchitectureName()\n//-----------------------------------------------------------------------------\nbool ComponentInstantiationInterface::setArchitectureName(std::string const& instantiationName,\n    std::string const& newArchitectureName)\n{\n    QSharedPointer<ComponentInstantiation> editedItem = getComponentInstantiation(instantiationName);\n    if (!editedItem)\n    {\n        return false;\n    }\n\n    editedItem->setArchitectureName(QString::fromStdString(newArchitectureName));\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: ComponentInstantiationInterface::getConfigurationName()\n//-----------------------------------------------------------------------------\nstd::string ComponentInstantiationInterface::getConfigurationName(std::string const& instantiationName) const\n{\n    QSharedPointer<ComponentInstantiation> editedInstantiation = getComponentInstantiation(instantiationName);\n    if (editedInstantiation)\n    {\n        return editedInstantiation->getConfigurationName().toStdString();\n    }\n\n    return std::string(\"\");\n}\n\n//-----------------------------------------------------------------------------\n// Function: ComponentInstantiationInterface::setConfigurationName()\n//-----------------------------------------------------------------------------\nbool ComponentInstantiationInterface::setConfigurationName(std::string const& instantiationName,\n    std::string const& newConfigurationName)\n{\n    QSharedPointer<ComponentInstantiation> editedItem = getComponentInstantiation(instantiationName);\n    if (!editedItem)\n    {\n        return false;\n    }\n\n    editedItem->setConfigurationName(QString::fromStdString(newConfigurationName));\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: ComponentInstantiationInterface::getFileSetReferences()\n//-----------------------------------------------------------------------------\nstd::vector<std::string> ComponentInstantiationInterface::getFileSetReferences(\n    std::string const& instantiationName) const\n{\n    std::vector<std::string> fileSetReferences;\n\n    if (auto editedInstantiation = getComponentInstantiation(instantiationName))\n    {\n        for (auto fileReference : *editedInstantiation->getFileSetReferences())\n        {\n            fileSetReferences.push_back(fileReference->getReference().toStdString());\n        }\n    }\n\n    return fileSetReferences;\n}\n\n//-----------------------------------------------------------------------------\n// Function: ComponentInstantiationInterface::setFileSetReferences()\n//-----------------------------------------------------------------------------\nbool ComponentInstantiationInterface::setFileSetReferences(std::string const& instantiationName,\n    std::vector<std::string> const& newReferences)\n{\n    QSharedPointer<ComponentInstantiation> editedItem = getComponentInstantiation(instantiationName);\n    if (!editedItem)\n    {\n        return false;\n    }\n    \n    // Convert to QString once.\n    QStringList newReferencesQ;\n    for (auto const& ref : newReferences)\n    {\n        newReferencesQ << QString::fromStdString(ref);\n    }\n\n    auto existingFileSetRefs = editedItem->getFileSetReferences();\n\n    // Extract reference names\n    QStringList existingReferencesStr;\n    for (auto const& reference : *existingFileSetRefs)\n    {\n        existingReferencesStr.append(reference->getReference());\n    }\n    \n    std::vector<int> indexesToDelete;\n\n    // Check for removed references.\n    for (int i = 0; i < existingReferencesStr.size(); ++i)\n    {\n        auto const& currentExistingRef = existingReferencesStr.at(i);\n\n        bool currentItemStillExists = false;\n\n        for (auto const& newRef : newReferencesQ)\n        {\n            if (currentExistingRef == newRef)\n            {\n                currentItemStillExists = true;\n            }\n        }\n\n        if (!currentItemStillExists)\n        {\n            indexesToDelete.push_back(i);\n        }\n    }\n\n    // Remove deleted file set refs.\n    for (auto index : indexesToDelete)\n    {\n        existingFileSetRefs->removeAt(index);\n        existingReferencesStr.removeAt(index);\n    }\n\n    // Check for new refs.\n    for (auto const& newRef : newReferencesQ)\n    {\n        if (existingReferencesStr.contains(newRef) == false)\n        {\n            QSharedPointer<FileSetRef> newFileSetRef(new FileSetRef());\n            newFileSetRef->setReference(newRef);\n            existingFileSetRefs->append(newFileSetRef);\n        }\n    }\n\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: ComponentInstantiationInterface::getItem()\n//-----------------------------------------------------------------------------\nQSharedPointer<NameGroup> ComponentInstantiationInterface::getItem(std::string const& itemName) const\n{\n    return getComponentInstantiation(itemName);\n}\n"
  },
  {
    "path": "KactusAPI/interfaces/component/FieldInterface.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: FieldInterface.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 07.04.2020\n//\n// Description:\n// Interface for editing registers.\n//-----------------------------------------------------------------------------\n\n#include \"FieldInterface.h\"\n\n#include <IPXACTmodels/generaldeclarations.h>\n#include <IPXACTmodels/common/AccessTypes.h>\n#include <IPXACTmodels/Component/Field.h>\n#include <IPXACTmodels/Component/WriteValueConstraint.h>\n#include <IPXACTmodels/Component/validators/FieldValidator.h>\n\n#include <FieldExpressionsGatherer.h>\n#include <editors/ComponentEditor/memoryMaps/memoryMapsExpressionCalculators/ReferenceCalculator.h>\n#include <ResetInterface.h>\n\n#include <QMimeData>\n#include <QApplication>\n#include <QClipboard>\n\nnamespace\n{\n    QString const TRUE_STRING = QLatin1String(\"true\");\n    QString const FALSE_STRING = QLatin1String(\"false\");\n\n    std::string const FIELD_TYPE = \"field\";\n};\n\n//-----------------------------------------------------------------------------\n// Function: FieldInterface::FieldInterface()\n//-----------------------------------------------------------------------------\nFieldInterface::FieldInterface(QSharedPointer<FieldValidator> validator,\n    QSharedPointer<ExpressionParser> expressionParser, QSharedPointer<ExpressionFormatter> expressionFormatter,\n    ResetInterface* subInterface):\nParameterizableInterface(expressionParser, expressionFormatter),\nvalidator_(validator),\naccessPolicyValidator_(expressionParser),\nsubInterface_(subInterface)\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: FieldInterface::setFields()\n//-----------------------------------------------------------------------------\nvoid FieldInterface::setFields(QSharedPointer<QList<QSharedPointer<Field> > > newFields)\n{\n    fields_ = newFields;\n}\n\n//-----------------------------------------------------------------------------\n// Function: FieldInterface::getItemIndex()\n//-----------------------------------------------------------------------------\nint FieldInterface::getItemIndex(std::string const& itemName) const\n{\n    if (fields_)\n    {\n        for (int i = 0; i < fields_->size(); ++i)\n        {\n            if (fields_->at(i)->name().toStdString() == itemName)\n            {\n                return i;\n            }\n        }\n    }\n\n    return -1;\n}\n\n//-----------------------------------------------------------------------------\n// Function: FieldInterface::getIndexedItemName()\n//-----------------------------------------------------------------------------\nstd::string FieldInterface::getIndexedItemName(int itemIndex) const\n{\n    std::string fieldName = \"\";\n    if (fields_&& (itemIndex >= 0 && itemIndex < fields_->size()))\n    {\n        fieldName = fields_->at(itemIndex)->name().toStdString();\n    }\n\n    return fieldName;\n}\n\n//-----------------------------------------------------------------------------\n// Function: FieldInterface::itemCount()\n//-----------------------------------------------------------------------------\nint FieldInterface::itemCount() const\n{\n    if (fields_)\n    {\n        return fields_->count();\n    }\n\n    return 0;\n}\n\n//-----------------------------------------------------------------------------\n// Function: FieldInterface::getItemNames()\n//-----------------------------------------------------------------------------\nstd::vector<std::string> FieldInterface::getItemNames() const\n{\n    std::vector<std::string> names;\n    if (fields_)\n    {\n        for (auto field : *fields_)\n        {\n            names.push_back(field->name().toStdString());\n        }\n    }\n\n    return names;\n}\n\n//-----------------------------------------------------------------------------\n// Function: FieldInterface::setName()\n//-----------------------------------------------------------------------------\nbool FieldInterface::setName(std::string const& currentName, std::string const& newName)\n{\n    QSharedPointer<Field> editedField = getField(currentName);\n    if (editedField && nameHasChanged(newName, currentName))\n    {\n        QString uniqueNewName = getUniqueName(newName, FIELD_TYPE);\n\n        editedField->setName(uniqueNewName);\n        return true;\n    }\n    else\n    {\n        return false;\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: FieldInterface::getOffsetValue()\n//-----------------------------------------------------------------------------\nstd::string FieldInterface::getOffsetValue(std::string const& fieldName, int const& baseNumber) const\n{\n    QSharedPointer<Field> field = getField(fieldName);\n    if (field)\n    {\n        return parseExpressionToBaseNumber(field->getBitOffset(), baseNumber).toStdString();\n    }\n\n    return std::string();\n}\n\n//-----------------------------------------------------------------------------\n// Function: FieldInterface::getOffsetFormattedExpression()\n//-----------------------------------------------------------------------------\nstd::string FieldInterface::getOffsetFormattedExpression(std::string const& fieldName) const\n{\n    QSharedPointer<Field> field = getField(fieldName);\n    if (field)\n    {\n        return formattedValueFor(field->getBitOffset()).toStdString();\n    }\n\n    return std::string();\n}\n\n//-----------------------------------------------------------------------------\n// Function: FieldInterface::getOffsetExpression()\n//-----------------------------------------------------------------------------\nstd::string FieldInterface::getOffsetExpression(std::string const& fieldName) const\n{\n    QSharedPointer<Field> field = getField(fieldName);\n    if (field)\n    {\n        return field->getBitOffset().toStdString();\n    }\n\n    return std::string();\n}\n\n//-----------------------------------------------------------------------------\n// Function: FieldInterface::setOffset()\n//-----------------------------------------------------------------------------\nbool FieldInterface::setOffset(std::string const& fieldName, std::string const& newOffset)\n{\n    QSharedPointer<Field> field = getField(fieldName);\n    if (!field)\n    {\n        return false;\n    }\n\n    field->setBitOffset(QString::fromStdString(newOffset));\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: FieldInterface::getWidthValue()\n//-----------------------------------------------------------------------------\nstd::string FieldInterface::getWidthValue(std::string const& fieldName, int const& baseNumber) const\n{\n    QSharedPointer<Field> field = getField(fieldName);\n    if (field)\n    {\n        return parseExpressionToBaseNumber(field->getBitWidth(), baseNumber).toStdString();\n    }\n\n    return std::string();\n}\n\n//-----------------------------------------------------------------------------\n// Function: FieldInterface::getWidthFormattedExpression()\n//-----------------------------------------------------------------------------\nstd::string FieldInterface::getWidthFormattedExpression(std::string const& fieldName) const\n{\n    QSharedPointer<Field> field = getField(fieldName);\n    if (field)\n    {\n        return formattedValueFor(field->getBitWidth()).toStdString();\n    }\n\n    return std::string();\n}\n\n//-----------------------------------------------------------------------------\n// Function: FieldInterface::getWidthExpression()\n//-----------------------------------------------------------------------------\nstd::string FieldInterface::getWidthExpression(std::string const& fieldName) const\n{\n    QSharedPointer<Field> field = getField(fieldName);\n    if (field)\n    {\n        return field->getBitWidth().toStdString();\n    }\n\n    return std::string();\n}\n\n//-----------------------------------------------------------------------------\n// Function: FieldInterface::setWidth()\n//-----------------------------------------------------------------------------\nbool FieldInterface::setWidth(std::string const& fieldName, std::string const& newWidth)\n{\n    QSharedPointer<Field> field = getField(fieldName);\n    if (!field)\n    {\n        return false;\n    }\n\n    field->setBitWidth(QString::fromStdString(newWidth));\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: FieldInterface::getResets()\n//-----------------------------------------------------------------------------\nstd::string FieldInterface::getResets(std::string const& fieldName) const\n{\n    QSharedPointer<Field> field = getField(fieldName);\n    if (!field)\n    {\n        return std::string();\n    }\n\n    QSharedPointer<QList<QSharedPointer<FieldReset> > > indexedResets = field->getResets();\n    if (indexedResets->isEmpty())\n    {\n        return std::string();\n    }\n    else if (indexedResets->count() == 1)\n    {\n        return indexedResets->first()->getResetValue().toStdString();\n    }\n    else\n    {\n        return std::string(\"[multiple]\");\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: FieldInterface::getResetsToolTip()\n//-----------------------------------------------------------------------------\nstd::string FieldInterface::getResetsToolTip(std::string const& fieldName) const\n{\n    QSharedPointer<Field> field = getField(fieldName);\n    if (field)\n    {\n        QSharedPointer<QList<QSharedPointer<FieldReset> > > resets = field->getResets();\n        if (resets && !resets->isEmpty())\n        {\n            QString tooltip = \"<html><head/><body><p>\";\n            for (int i = 0; i < resets->size(); ++i)\n            {\n                if (i > 0)\n                {\n                    tooltip.append(\"<br>\");\n                }\n\n                QSharedPointer<FieldReset> fieldReset = resets->at(i);\n                QString resetReference = fieldReset->getResetTypeReference();\n                if (resetReference.isEmpty())\n                {\n                    resetReference = \"HARD\";\n                }\n\n                QString resetValue = formattedValueFor(fieldReset->getResetValue());\n\n                tooltip.append(resetReference + \" : \" + resetValue);\n            }\n\n            tooltip.append(\"</p></body></html>\");\n\n            return tooltip.toStdString();\n        }\n    }\n\n    return std::string();\n}\n\n//-----------------------------------------------------------------------------\n// Function: FieldInterface::getVolatile()\n//-----------------------------------------------------------------------------\nstd::string FieldInterface::getVolatile(std::string const& fieldName) const\n{\n    QSharedPointer<Field> field = getField(fieldName);\n    if (field)\n    {\n        return field->getVolatile().toString().toStdString();\n    }\n\n    return std::string();\n}\n\n//-----------------------------------------------------------------------------\n// Function: FieldInterface::setVolatile()\n//-----------------------------------------------------------------------------\nbool FieldInterface::setVolatile(std::string const& fieldName, std::string const& newVolatile)\n{\n    QSharedPointer<Field> field = getField(fieldName);\n    if (!field)\n    {\n        return false;\n    }\n\n    QString newVolatileQT = QString::fromStdString(newVolatile);\n\n    if (newVolatileQT == TRUE_STRING)\n    {\n        field->setVolatile(true);\n    }\n    else if (newVolatileQT == FALSE_STRING)\n    {\n        field->setVolatile(false);\n    }\n    else\n    {\n        field->clearVolatile();\n    }\n\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: FieldInterface::getAccessString()\n//-----------------------------------------------------------------------------\nstd::string FieldInterface::getAccessString(std::string const& fieldName, int accessPolicyIndex /*= -1*/) const\n{\n    if (auto field = getField(fieldName); field)\n    {\n        if (accessPolicyIndex == -1)\n        {\n            return AccessTypes::access2Str(field->getAccess()).toStdString();\n        }\n        else if (accessPolicyIndex >= 0)\n        {\n            if (auto accessPolicies = field->getFieldAccessPolicies();\n                accessPolicyIndex <= accessPolicies->size() - 1)\n            {\n                return AccessTypes::access2Str(accessPolicies->at(accessPolicyIndex)->getAccess()).toStdString();\n            }   \n        }\n    }\n\n    return std::string();\n}\n\n//-----------------------------------------------------------------------------\n// Function: FieldInterface::getModeRefs()\n//-----------------------------------------------------------------------------\nstd::vector<std::pair<std::string, unsigned int> > FieldInterface::getModeRefs(std::string const& fieldName, \n    int accessPolicyIndex) const\n{\n    if (auto field = getField(fieldName); field)\n    {\n        auto fieldAccessPolicies = field->getFieldAccessPolicies();\n\n        if (accessPolicyIndex <= fieldAccessPolicies->size() - 1)\n        {\n            auto modeRefs = fieldAccessPolicies->at(accessPolicyIndex)->getModeReferences();\n            std::vector<std::pair<std::string, unsigned int> > modeRefList;\n            std::transform(modeRefs->cbegin(), modeRefs->cend(), std::back_inserter(modeRefList), \n                [](QSharedPointer<ModeReference> const& modeRef)\n                {\n                    return std::make_pair<std::string, unsigned int >(modeRef->getReference().toStdString(), \n                        modeRef->getPriority());\n                });\n\n            return modeRefList;\n        }\n    }\n\n    return std::vector<std::pair<std::string, unsigned int> >();\n}\n\n//-----------------------------------------------------------------------------\n// Function: FieldInterface::getAccessPolicyCount()\n//-----------------------------------------------------------------------------\nint FieldInterface::getAccessPolicyCount(std::string const& fieldName) const\n{\n    if (auto field = getField(fieldName); field)\n    {\n        return field->getFieldAccessPolicies()->size();\n    }\n\n    return 0;\n}\n\n//-----------------------------------------------------------------------------\n// Function: FieldInterface::getReadResponse()\n//-----------------------------------------------------------------------------\nstd::string FieldInterface::getReadResponseExpression(std::string const& fieldName, int accessPolicyIndex) const\n{\n    auto field = getField(fieldName);\n\n    if (!field)\n    {\n        return std::string();\n    }\n\n    if (auto accessPolicies = field->getFieldAccessPolicies();\n        accessPolicyIndex <= accessPolicies->size() - 1)\n    {\n        return accessPolicies->at(accessPolicyIndex)->getReadResponse().toStdString();\n    }\n\n    return std::string();\n}\n\n//-----------------------------------------------------------------------------\n// Function: FieldInterface::getReadResponseFormattedExpression()\n//-----------------------------------------------------------------------------\nstd::string FieldInterface::getReadResponseFormattedExpression(std::string const& fieldName, int accessPolicyIndex) const\n{\n    if (auto field = getField(fieldName); field)\n    {\n        if (auto accessPolicies = field->getFieldAccessPolicies();\n            accessPolicyIndex <= accessPolicies->size() - 1)\n        {\n            return formattedValueFor(accessPolicies->at(accessPolicyIndex)->getReadResponse()).toStdString();\n        }\n    }\n\n    return std::string();\n}\n\n//-----------------------------------------------------------------------------\n// Function: FieldInterface::getReadResponseValue()\n//-----------------------------------------------------------------------------\nstd::string FieldInterface::getReadResponseValue(std::string const& fieldName, int accessPolicyIndex, int baseNumber /*= 0*/) const\n{\n    if (auto field = getField(fieldName); field)\n    {\n        if (auto accessPolicies = field->getFieldAccessPolicies();\n            accessPolicyIndex <= accessPolicies->size() - 1)\n        {\n            return parseExpressionToBaseNumber(\n                accessPolicies->at(accessPolicyIndex)->getReadResponse(), baseNumber).toStdString();\n        }\n    }\n\n    return std::string();\n}\n\n//-----------------------------------------------------------------------------\n// Function: FieldInterface::setReadResponse()\n//-----------------------------------------------------------------------------\nbool FieldInterface::setReadResponse(std::string const& fieldName, int accessPolicyIndex,\n    std::string const& newReadResponse) const\n{\n    auto field = getField(fieldName);\n\n    if (!field)\n    {\n        return false;\n    }\n\n    if (auto accessPolicies = field->getFieldAccessPolicies();\n        accessPolicyIndex <= accessPolicies->size() - 1)\n    {\n        accessPolicies->at(accessPolicyIndex)->setReadResponse(QString::fromStdString(newReadResponse));\n        return true;\n    }\n\n    return false;\n}\n\n//-----------------------------------------------------------------------------\n// Function: FieldInterface::getAllReferencesToIdInFieldAccessPolicy()\n//-----------------------------------------------------------------------------\nint FieldInterface::getAllReferencesToIdInFieldAccessPolicy(std::string const& fieldName, int accessPolicyIndex, \n    std::string const& valueID) const\n{\n    auto field = getField(fieldName);\n    if (!field)\n    {\n        return 0;\n    }\n\n    if (auto accessPolicies = field->getFieldAccessPolicies();\n        accessPolicyIndex <= accessPolicies->size() - 1)\n    {\n        QString id(QString::fromStdString(valueID));\n\n        auto accessPolicy = accessPolicies->at(accessPolicyIndex);\n\n        int referencesInReadResponse = accessPolicy->getReadResponse().count(id);\n        int referencesInReserved = accessPolicy->getReserved().count(id);\n\n        int referencesInWriteConstraint = 0;\n\n        if (auto writeConstraint = accessPolicy->getWriteValueConstraint();\n            writeConstraint)\n        {\n            if (writeConstraint->getType() == WriteValueConstraint::MIN_MAX)\n            {\n                referencesInWriteConstraint += accessPolicy->getWriteValueConstraint()->getMaximum().count(id);\n                referencesInWriteConstraint += accessPolicy->getWriteValueConstraint()->getMinimum().count(id);\n            }\n        }\n\n        return referencesInReadResponse + referencesInReserved + referencesInWriteConstraint;\n    }\n\n    return 0;\n}\n\n//-----------------------------------------------------------------------------\n// Function: FieldInterface::hasUniqueModeRefs()\n//-----------------------------------------------------------------------------\nbool FieldInterface::hasValidAccessPolicyModeRefs(std::string const& fieldName, int accessPolicyIndex) const\n{\n    if (auto field = getField(fieldName); field)\n    {\n        if (auto accessPolicies = field->getFieldAccessPolicies();\n            accessPolicyIndex <= accessPolicies->size() - 1)\n        {\n            return validator_->singleFieldAccessPolicyHasValidModeRefs(field, accessPolicyIndex);\n        }\n    }\n\n    return false;\n}\n\n//-----------------------------------------------------------------------------\n// Function: FieldInterface::copyFieldAccessPolicies()\n//-----------------------------------------------------------------------------\nvoid FieldInterface::copyFieldAccessPolicies(std::string const& fieldName,\n    std::vector<int> const& selectedAccessPolicies)\n{\n    if (auto const& field = getField(fieldName))\n    {\n        QList<QSharedPointer<FieldAccessPolicy> > copiedFieldAccessPolicies;\n        for (auto index : selectedAccessPolicies)\n        {\n            auto accessPolicy = field->getFieldAccessPolicies()->at(index);\n            copiedFieldAccessPolicies.append(accessPolicy);\n        }\n\n        QVariant accessPolicyVariant;\n        accessPolicyVariant.setValue(copiedFieldAccessPolicies);\n\n        QMimeData* newMimeData = new QMimeData();\n        newMimeData->setData(\"text/xml/ipxact:fieldAccessPolicy\", QByteArray());\n        newMimeData->setImageData(accessPolicyVariant);\n\n        QApplication::clipboard()->setMimeData(newMimeData);\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: FieldInterface::pasteFieldaccessPolicies()\n//-----------------------------------------------------------------------------\nint FieldInterface::pasteFieldaccessPolicies(std::string const& fieldName)\n{\n    auto field = getField(fieldName);\n    if (!field)\n    {\n        return 0;\n    }\n\n    const QMimeData* pasteData = QApplication::clipboard()->mimeData();\n    \n    int numPasted = 0;\n\n    if (pasteData->hasImage())\n    {\n        QVariant pasteVariant = pasteData->imageData();\n        if (pasteVariant.canConvert<QList<QSharedPointer<FieldAccessPolicy> > >())\n        {\n            auto copiedFieldAccessPolicies = pasteVariant.value<QList<QSharedPointer<FieldAccessPolicy> > >();\n\n            for (auto copiedFieldAccessPolicy : copiedFieldAccessPolicies)\n            {\n                QSharedPointer<FieldAccessPolicy> newFieldAccessPolicy(new FieldAccessPolicy(*copiedFieldAccessPolicy));\n                field->getFieldAccessPolicies()->append(newFieldAccessPolicy);\n\n                numPasted++;\n            }\n        }\n    }\n\n    return numPasted;\n}\n\n//-----------------------------------------------------------------------------\n// Function: FieldInterface::setModeReferenceInterface()\n//-----------------------------------------------------------------------------\nvoid FieldInterface::setModeReferenceInterface(ModeReferenceInterface* modeRefInterface)\n{\n    modeReferenceInterface_ = modeRefInterface;\n}\n\n//-----------------------------------------------------------------------------\n// Function: FieldInterface::getModeReferenceInterface()\n//-----------------------------------------------------------------------------\nModeReferenceInterface* FieldInterface::getModeReferenceInterface() const\n{\n    return modeReferenceInterface_;\n}\n\n//-----------------------------------------------------------------------------\n// Function: FieldInterface::getAccessType()\n//-----------------------------------------------------------------------------\nAccessTypes::Access FieldInterface::getAccessType(std::string const& fieldName, int accessPolicyIndex /*= -1*/)\n    const\n{\n    if (auto field = getField(fieldName); field)\n    {\n        if (accessPolicyIndex == -1)\n        {\n            return field->getAccess();\n        }\n        else if (accessPolicyIndex >= 0)\n        {\n            if (auto accessPolicies = field->getFieldAccessPolicies();\n                accessPolicyIndex <= accessPolicies->size() - 1)\n            {\n                return accessPolicies->at(accessPolicyIndex)->getAccess();\n            }\n        }\n    }\n\n    return AccessTypes::ACCESS_COUNT;\n}\n\n//-----------------------------------------------------------------------------\n// Function: FieldInterface::setAccess()\n//-----------------------------------------------------------------------------\nbool FieldInterface::setAccess(std::string const& fieldName, std::string const& accessType,\n    int accessPolicyIndex /*= -1*/) const\n{\n    \n    if (auto field = getField(fieldName); field)\n    {\n        auto newAccess = AccessTypes::str2Access(QString::fromStdString(accessType), AccessTypes::ACCESS_COUNT);\n\n        if (accessPolicyIndex == -1)\n        {\n            field->setAccess(newAccess);\n            return true;\n        }\n        \n        if (auto accessPolicies = field->getFieldAccessPolicies();\n            accessPolicyIndex <= accessPolicies->size() - 1 && accessPolicyIndex >= 0)\n        {\n            accessPolicies->at(accessPolicyIndex)->setAccess(newAccess);\n            return true;\n        }\n    }\n\n    return false;\n}\n\n//-----------------------------------------------------------------------------\n// Function: FieldInterface::getModifiedWriteValue()\n//-----------------------------------------------------------------------------\nGeneral::ModifiedWrite FieldInterface::getModifiedWriteValue(std::string const& fieldName) const\n{\n    QSharedPointer<Field> field = getField(fieldName);\n    if (field)\n    {\n        return field->getModifiedWrite();\n    }\n\n    return General::MODIFIED_WRITE_COUNT;\n}\n\n//-----------------------------------------------------------------------------\n// Function: FieldInterface::getModifiedWriteString()\n//-----------------------------------------------------------------------------\nstd::string FieldInterface::getModifiedWriteString(std::string const& fieldName, int accessPolicyIndex /*= -1*/) const\n{\n    if (auto field = getField(fieldName); field)\n    {\n        if (accessPolicyIndex == -1)\n        {\n            return General::modifiedWrite2Str(field->getModifiedWrite()).toStdString();\n        }\n        else if (accessPolicyIndex >= 0)\n        {\n            if (auto accessPolicies = field->getFieldAccessPolicies();\n                accessPolicyIndex <= accessPolicies->size() - 1)\n            {\n                return General::modifiedWrite2Str(accessPolicies->at(accessPolicyIndex)->getModifiedWrite()).toStdString();\n            }\n        }\n    }\n\n    return std::string();\n}\n\n//-----------------------------------------------------------------------------\n// Function: FieldInterface::setModifiedWrite()\n//-----------------------------------------------------------------------------\nbool FieldInterface::setModifiedWrite(std::string const& fieldName, std::string const& newModifiedWrite,\n    int accessPolicyIndex /*= -1*/)\n{\n    if (auto field = getField(fieldName); field)\n    {\n        if (accessPolicyIndex == -1)\n        {\n            field->setModifiedWrite(General::str2ModifiedWrite(QString::fromStdString(newModifiedWrite)));\n            return true;\n        }\n        else if (accessPolicyIndex >= 0)\n        {\n            if (auto accessPolicies = field->getFieldAccessPolicies();\n                accessPolicyIndex <= accessPolicies->size() - 1)\n            {\n                General::ModifiedWrite modifiedWrite = General::str2ModifiedWrite(QString::fromStdString(newModifiedWrite));\n                accessPolicies->at(accessPolicyIndex)->setModifiedWrite(modifiedWrite);\n                return true;\n            }\n        }\n    }\n\n    return false;\n}\n\n//-----------------------------------------------------------------------------\n// Function: FieldInterface::getReadActionString()\n//-----------------------------------------------------------------------------\nstd::string FieldInterface::getReadActionString(std::string const& fieldName, int accessPolicyIndex /*= -1*/) const\n{\n    auto readAction = getReadAction(fieldName, accessPolicyIndex);\n    return General::readAction2Str(readAction).toStdString();\n}\n\n//-----------------------------------------------------------------------------\n// Function: FieldInterface::getReadAction()\n//-----------------------------------------------------------------------------\nGeneral::ReadAction FieldInterface::getReadAction(std::string const& fieldName,int accessPolicyIndex /*= -1*/)\n    const\n{\n    if (auto field = getField(fieldName); field)\n    {\n        if (accessPolicyIndex == -1)\n        {\n            return field->getReadAction();\n        }\n        else if (accessPolicyIndex >= 0)\n        {\n            if (auto accessPolicies = field->getFieldAccessPolicies();\n                accessPolicyIndex <= accessPolicies->size() - 1)\n            {\n                return accessPolicies->at(accessPolicyIndex)->getReadAction();\n            }\n        }\n    }\n\n    return General::READ_ACTION_COUNT;\n}\n\n//-----------------------------------------------------------------------------\n// Function: FieldInterface::setReadAction()\n//-----------------------------------------------------------------------------\nbool FieldInterface::setReadAction(std::string const& fieldName, std::string const& newReadAction,\n    int accessPolicyIndex /*= -1*/)\n{\n    if (auto field = getField(fieldName); field)\n    {\n        if (accessPolicyIndex == -1)\n        {\n            field->setReadAction(General::str2ReadAction(QString::fromStdString(newReadAction)));\n            return true;\n        }\n        else if (accessPolicyIndex >= 0)\n        {\n            if (auto accessPolicies = field->getFieldAccessPolicies();\n                accessPolicyIndex <= accessPolicies->size() - 1)\n            {\n                accessPolicies->at(accessPolicyIndex)->setReadAction(General::str2ReadAction(\n                    QString::fromStdString(newReadAction)));\n                return true;\n            }\n        }\n    }\n\n    return false;\n}\n\n//-----------------------------------------------------------------------------\n// Function: FieldInterface::getTestable()\n//-----------------------------------------------------------------------------\nstd::string FieldInterface::getTestableValue(std::string const& fieldName, int accessPolicyIndex) const\n{\n    if (auto field = getField(fieldName); field)\n    {\n        if (accessPolicyIndex == -1)\n        {\n            return field->getTestable().toString().toStdString();\n        }\n        else if (accessPolicyIndex >= 0)\n        {\n            if (auto accessPolicies = field->getFieldAccessPolicies();\n                accessPolicyIndex <= accessPolicies->size() - 1)\n            {\n                return accessPolicies->at(accessPolicyIndex)->getTestable().toString().toStdString();\n            }\n        }\n    }\n    \n    return std::string();\n}\n\n//-----------------------------------------------------------------------------\n// Function: FieldInterface::getTestableBool()\n//-----------------------------------------------------------------------------\nbool FieldInterface::getTestableBool(std::string const& fieldName, int accessPolicyIndex /*= -1*/) const\n{\n    if (auto field = getField(fieldName); field)\n    {\n        if (accessPolicyIndex == -1)\n        {\n            return field->getTestable().toBool();\n        }\n        else if (accessPolicyIndex >= 0)\n        {\n            if (auto accessPolicies = field->getFieldAccessPolicies();\n                accessPolicyIndex <= accessPolicies->size() - 1)\n            {\n                return accessPolicies->at(accessPolicyIndex)->getTestable().toBool();\n            }\n        }\n    }\n\n    return false;\n}\n\n//-----------------------------------------------------------------------------\n// Function: FieldInterface::setTestable()\n//-----------------------------------------------------------------------------\nbool FieldInterface::setTestable(std::string const& fieldName, std::string const& newTestable,\n    int accessPolicyIndex /*= -1*/) const\n{\n    auto field = getField(fieldName);\n    if (!field)\n    {\n        return false;\n    }\n\n    QString newTestableQT = QString::fromStdString(newTestable);\n\n    if (accessPolicyIndex == -1)\n    {\n        if (newTestableQT == TRUE_STRING)\n        {\n            field->setTestable(true);\n        }\n        else if (newTestableQT == FALSE_STRING)\n        {\n            field->setTestable(false);\n            field->setTestConstraint(General::TESTCONSTRAINT_COUNT);\n        }\n        else\n        {\n            field->clearTestable();\n        }\n\n        return true;\n    }\n    else if (accessPolicyIndex >= 0)\n    {\n        if (auto accessPolicies = field->getFieldAccessPolicies();\n            accessPolicyIndex <= accessPolicies->size() - 1)\n        {\n            auto accessPolicy = accessPolicies->at(accessPolicyIndex);\n            \n            if (newTestableQT == TRUE_STRING)\n            {\n                accessPolicy->setTestable(true);\n            }\n            else if (newTestableQT == FALSE_STRING)\n            {\n                accessPolicy->setTestable(false);\n                accessPolicy->setTestConstraint(General::TESTCONSTRAINT_COUNT);\n            }\n            else\n            {\n                accessPolicy->clearTestable();\n            }\n\n            return true;\n        }\n    }\n\n    return false;\n}\n\n//-----------------------------------------------------------------------------\n// Function: FieldInterface::getTestConstraintString()\n//-----------------------------------------------------------------------------\nstd::string FieldInterface::getTestConstraintString(std::string const& fieldName,\n    int accessPolicyIndex /*= -1*/) const\n{\n    if (auto field = getField(fieldName); field)\n    {\n        if (accessPolicyIndex == -1)\n        {\n            return General::testConstraint2Str(field->getTestConstraint()).toStdString();\n        }\n        else if (accessPolicyIndex >= 0)\n        {\n            if (auto accessPolicies = field->getFieldAccessPolicies();\n                accessPolicyIndex <= accessPolicies->size() - 1)\n            {\n                return General::testConstraint2Str(\n                    accessPolicies->at(accessPolicyIndex)->getTestConstraint()).toStdString();\n            }\n        }\n    }\n\n    return std::string();\n}\n\n//-----------------------------------------------------------------------------\n// Function: FieldInterface::getTestConstraint()\n//-----------------------------------------------------------------------------\nGeneral::TestConstraint FieldInterface::getTestConstraint(std::string const& fieldName,\n    int accessPolicyIndex /*= -1*/) const\n{\n    if (auto field = getField(fieldName); field)\n    {\n        if (accessPolicyIndex == -1)\n        {\n            return field->getTestConstraint();\n        }\n        else if (accessPolicyIndex >= 0)\n        {\n            if (auto accessPolicies = field->getFieldAccessPolicies();\n                accessPolicyIndex <= accessPolicies->size() - 1)\n            {\n                return accessPolicies->at(accessPolicyIndex)->getTestConstraint();\n            }\n        }\n    }\n\n    return General::TESTCONSTRAINT_COUNT;\n}\n\n//-----------------------------------------------------------------------------\n// Function: FieldInterface::setTestConstraint()\n//-----------------------------------------------------------------------------\nbool FieldInterface::setTestConstraint(std::string const& fieldName, std::string const& newTestConstraint,\n    int accessPolicyIndex /*= -1*/) const\n{\n    if (auto field = getField(fieldName); field)\n    {\n        if (accessPolicyIndex == -1)\n        {\n            field->setTestConstraint(General::str2TestConstraint(QString::fromStdString(newTestConstraint)));\n            return true;\n        }\n        else if (accessPolicyIndex >= 0)\n        {\n            if (auto accessPolicies = field->getFieldAccessPolicies();\n                accessPolicyIndex <= accessPolicies->size() - 1)\n            {\n                accessPolicies->at(accessPolicyIndex)->setTestConstraint(\n                    General::str2TestConstraint(QString::fromStdString(newTestConstraint)));\n            }\n            return true;\n        }\n    }\n    \n    return false;\n}\n\n//-----------------------------------------------------------------------------\n// Function: FieldInterface::getIsPresentValue()\n//-----------------------------------------------------------------------------\nstd::string FieldInterface::getIsPresentValue(std::string const& fieldName, int const& baseNumber) const\n{\n    QSharedPointer<Field> field = getField(fieldName);\n    if (field)\n    {\n        return parseExpressionToBaseNumber(field->getIsPresent(), baseNumber).toStdString();\n    }\n\n    return std::string();\n}\n\n//-----------------------------------------------------------------------------\n// Function: FieldInterface::getIsPresentFormattedExpression()\n//-----------------------------------------------------------------------------\nstd::string FieldInterface::getIsPresentFormattedExpression(std::string const& fieldName) const\n{\n    QSharedPointer<Field> field = getField(fieldName);\n    if (field)\n    {\n        return formattedValueFor(field->getIsPresent()).toStdString();\n    }\n\n    return std::string();\n}\n\n//-----------------------------------------------------------------------------\n// Function: FieldInterface::getIsPresentExpression()\n//-----------------------------------------------------------------------------\nstd::string FieldInterface::getIsPresentExpression(std::string const& fieldName) const\n{\n    QSharedPointer<Field> field = getField(fieldName);\n    if (field)\n    {\n        return field->getIsPresent().toStdString();\n    }\n\n    return std::string();\n}\n\n//-----------------------------------------------------------------------------\n// Function: FieldInterface::setIsPresent()\n//-----------------------------------------------------------------------------\nbool FieldInterface::setIsPresent(std::string const& fieldName, std::string const& newIsPresent)\n{\n    QSharedPointer<Field> field = getField(fieldName);\n    if (!field)\n    {\n        return false;\n    }\n\n    field->setIsPresent(QString::fromStdString(newIsPresent));\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: FieldInterface::getAllReferencesToIdInItem()\n//-----------------------------------------------------------------------------\nint FieldInterface::getAllReferencesToIdInItem(const std::string& itemName, std::string const&  valueID) const\n{\n    QSharedPointer<Field> field = getField(itemName);\n\n    QString idString = QString::fromStdString(valueID);\n\n    int referencesInOffset = field->getBitOffset().count(idString);\n    int referencesInWidth = field->getBitWidth().count(idString);\n    int refrencesInIsPresent = field->getIsPresent().count(idString);\n\n    int totalReferencesToParameter = referencesInOffset + referencesInWidth + refrencesInIsPresent;\n\n    return totalReferencesToParameter;\n}\n\n//-----------------------------------------------------------------------------\n// Function: FieldInterface::validateItems()\n//-----------------------------------------------------------------------------\nbool FieldInterface::validateItems() const\n{\n    for (auto field : *fields_)\n    {\n        if (!validator_->validate(field))\n        {\n            return false;\n        }\n    }\n\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: FieldInterface::itemHasValidName()\n//-----------------------------------------------------------------------------\nbool FieldInterface::itemHasValidName(std::string const& itemName) const\n{\n    return validator_->hasValidName(getField(itemName));\n}\n\n//-----------------------------------------------------------------------------\n// Function: FieldInterface::hasValidOffset()\n//-----------------------------------------------------------------------------\nbool FieldInterface::hasValidOffset(std::string const& fieldName) const\n{\n    QSharedPointer<Field> field = getField(fieldName);\n    if (field)\n    {\n        return validator_->hasValidBitOffset(field);\n    }\n\n    return false;\n}\n\n//-----------------------------------------------------------------------------\n// Function: FieldInterface::hasValidWidth()\n//-----------------------------------------------------------------------------\nbool FieldInterface::hasValidWidth(std::string const& fieldName) const\n{\n    QSharedPointer<Field> field = getField(fieldName);\n    if (field)\n    {\n        return validator_->hasValidBitWidth(field);\n    }\n\n    return false;\n}\n\n//-----------------------------------------------------------------------------\n// Function: FieldInterface::hasValidResets()\n//-----------------------------------------------------------------------------\nbool FieldInterface::hasValidResets(std::string const& fieldName) const\n{\n    QSharedPointer<Field> field = getField(fieldName);\n    if (field)\n    {\n        return validator_->hasValidResets(field);\n    }\n\n    return false;\n}\n\n//-----------------------------------------------------------------------------\n// Function: FieldInterface::hasValidIsPresent()\n//-----------------------------------------------------------------------------\nbool FieldInterface::hasValidIsPresent(std::string const& fieldName) const\n{\n    QSharedPointer<Field> field = getField(fieldName);\n    if (field)\n    {\n        return validator_->hasValidIsPresent(field);\n    }\n\n    return false;\n}\n\n//-----------------------------------------------------------------------------\n// Function: FieldInterface::hasValidAccess()\n//-----------------------------------------------------------------------------\nbool FieldInterface::hasValidAccess(std::string const& fieldName, int accessPolicyIndex /*= -1*/) const\n{\n    if (auto field = getField(fieldName); field)\n    {\n        if (accessPolicyIndex == -1)\n        {\n            return validator_->hasValidAccess(field);\n        }\n\n        else if (accessPolicyIndex >= 0)\n        {\n            if (auto accessPolicies = field->getFieldAccessPolicies();\n                accessPolicyIndex <= accessPolicies->size() - 1)\n            {\n                return accessPolicyValidator_.hasValidAccess(accessPolicies->at(accessPolicyIndex));\n            }\n        }\n    }\n\n    return false;\n}\n\n//-----------------------------------------------------------------------------\n// Function: FieldInterface::hasValidReadResponse()\n//-----------------------------------------------------------------------------\nbool FieldInterface::hasValidReadResponse(std::string const& fieldName, int accessPolicyIndex) const\n{\n    if (auto field = getField(fieldName); field)\n    {\n        if (auto accessPolicies = field->getFieldAccessPolicies();\n            accessPolicyIndex <= accessPolicies->size() - 1)\n        {\n            return accessPolicyValidator_.hasValidReadResponse(accessPolicies->at(accessPolicyIndex));\n        }\n    }\n\n    return false;\n}\n\n//-----------------------------------------------------------------------------\n// Function: FieldInterface::hasValidReserved()\n//-----------------------------------------------------------------------------\nbool FieldInterface::hasValidReserved(std::string const& fieldName, int accessPolicyIndex) const\n{\n    if (auto field = getField(fieldName); field)\n    {\n        if (auto accessPolicies = field->getFieldAccessPolicies();\n            accessPolicyIndex <= accessPolicies->size() - 1)\n        {\n            return accessPolicyValidator_.hasValidReserved(accessPolicies->at(accessPolicyIndex));\n        }\n    }\n\n    return false;\n}\n\n//-----------------------------------------------------------------------------\n// Function: FieldInterface::hasValidMinimumWriteValueConstraint()\n//-----------------------------------------------------------------------------\nbool FieldInterface::hasValidWriteValueConstraint(std::string const& fieldName, int accessPolicyIndex) const\n{\n    if (auto field = getField(fieldName); field)\n    {\n        if (auto accessPolicies = field->getFieldAccessPolicies();\n            accessPolicyIndex <= accessPolicies->size() - 1)\n        {\n            return accessPolicyValidator_.hasValidWriteValueConstraint(\n                field->getFieldAccessPolicies()->at(accessPolicyIndex));\n        }\n    }\n\n    return false;\n}\n\n//-----------------------------------------------------------------------------\n// Function: FieldInterface::getField()\n//-----------------------------------------------------------------------------\nQSharedPointer<Field> FieldInterface::getField(std::string const& fieldName) const\n{\n    if (fields_)\n    {\n        for (auto field : *fields_)\n        {\n            if (field->name().toStdString() == fieldName)\n            {\n                return field;\n            }\n        }\n    }\n\n    return QSharedPointer<Field>();\n}\n\n//-----------------------------------------------------------------------------\n// Function: FieldInterface::addField()\n//-----------------------------------------------------------------------------\nvoid FieldInterface::addField(int const& row, std::string const& newFieldName /*= std::string(\"\")*/)\n{\n    QString fieldName = getUniqueName(newFieldName, FIELD_TYPE);\n\n    QSharedPointer<Field> newField(new Field());\n    newField->setName(fieldName);\n\n    fields_->insert(row, newField);\n}\n\n//-----------------------------------------------------------------------------\n// Function: FieldInterface::addField()\n//-----------------------------------------------------------------------------\nvoid FieldInterface::addField(std::string const& newFieldName /*= std::string(\"\")*/)\n{\n    addField(fields_->size(), newFieldName);\n}\n\n//-----------------------------------------------------------------------------\n// Function: FieldInterface::removeField()\n//-----------------------------------------------------------------------------\nbool FieldInterface::removeField(std::string const& fieldName)\n{\n    QSharedPointer<Field> removedField = getField(fieldName);\n    if (!removedField)\n    {\n        return false;\n    }\n\n    return fields_->removeOne(removedField);\n}\n\n//-----------------------------------------------------------------------------\n// Function: FieldInterface::copyRows()\n//-----------------------------------------------------------------------------\nvoid FieldInterface::copyRows(std::vector<int> const& selectedRows)\n{\n    QList<QSharedPointer<Field> > copiedFields;\n    for (auto index : selectedRows)\n    {\n        QSharedPointer<Field> field = fields_->at(index);\n        copiedFields.append(field);\n    }\n\n    QVariant fieldVariant;\n    fieldVariant.setValue(copiedFields);\n\n    QMimeData* newMimeData = new QMimeData();\n    newMimeData->setData(\"text/xml/ipxact:field\", QByteArray());\n    newMimeData->setImageData(fieldVariant);\n\n    QApplication::clipboard()->setMimeData(newMimeData);\n}\n\n//-----------------------------------------------------------------------------\n// Function: FieldInterface::pasteRows()\n//-----------------------------------------------------------------------------\nstd::vector<std::string> FieldInterface::pasteRows()\n{\n    std::vector<std::string> pastedFieldNames;\n\n    const QMimeData* pasteData = QApplication::clipboard()->mimeData();\n\n    if (pasteData->hasImage())\n    {\n        QVariant pasteVariant = pasteData->imageData();\n        if (pasteVariant.canConvert<QList<QSharedPointer<Field> > >())\n        {\n            QList<QSharedPointer<Field> > newFields = pasteVariant.value<QList<QSharedPointer<Field> > >();\n\n            for (auto const& field : newFields)\n            {\n                QSharedPointer<Field> newField(new Field(*field));\n                newField->setName(getUniqueName(newField->name().toStdString(), FIELD_TYPE));\n                fields_->append(newField);\n\n                pastedFieldNames.push_back(newField->name().toStdString());\n            }\n        }\n    }\n\n    return pastedFieldNames;\n}\n\n//-----------------------------------------------------------------------------\n// Function: FieldInterface::getPasteRowCount()\n//-----------------------------------------------------------------------------\nint FieldInterface::getPasteRowCount() const\n{\n    const QMimeData* pasteData = QApplication::clipboard()->mimeData();\n    if (pasteData->hasImage())\n    {\n        QVariant pasteVariant = pasteData->imageData();\n        if (pasteVariant.canConvert<QList<QSharedPointer<Field> > >())\n        {\n            QList<QSharedPointer<Field> > newFields = pasteVariant.value<QList<QSharedPointer<Field> > >();\n            return newFields.count();\n        }\n    }\n    \n    return 0;\n}\n\n//-----------------------------------------------------------------------------\n// Function: FieldInterface::getExpressionsInSelectedFields()\n//-----------------------------------------------------------------------------\nstd::vector<std::string> FieldInterface::getExpressionsInSelectedFields(std::vector<std::string> const& fieldNames) const\n{\n    std::vector<std::string> expressionList;\n\n    FieldExpressionsGatherer gatherer;\n\n    for (auto const& name : fieldNames)\n    {\n        QSharedPointer<Field> field = getField(name);\n        QStringList fieldExpressions = gatherer.getExpressions(field);\n        for (auto const& expression : fieldExpressions)\n        {\n            expressionList.push_back(expression.toStdString());\n        }\n    }\n\n    return expressionList;\n}\n\n//-----------------------------------------------------------------------------\n// Function: FieldInterface::getSubInterface()\n//-----------------------------------------------------------------------------\nResetInterface* FieldInterface::getSubInterface() const\n{\n    return subInterface_;\n}\n\n//-----------------------------------------------------------------------------\n// Function: FieldInterface::hasWriteConstraint()\n//-----------------------------------------------------------------------------\nbool FieldInterface::hasWriteConstraint(std::string const& fieldName) const\n{\n    QSharedPointer<WriteValueConstraint> fieldWriteConstraint = getWriteValueConstraint(fieldName);\n    if (fieldWriteConstraint)\n    {\n        return true;\n    }\n    else\n    {\n        return false;\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: FieldInterface::getWriteConstraint()\n//-----------------------------------------------------------------------------\nstd::string FieldInterface::getWriteConstraint(std::string const& fieldName, int accessPolicyIndex /*= -1*/) const\n{\n    std::string writeConstraintText =\n        WriteValueConversions::typeToString(WriteValueConstraint::TYPE_COUNT).toStdString();\n\n    if (auto fieldWriteConstraint = getWriteValueConstraint(fieldName, accessPolicyIndex))\n    {\n        writeConstraintText = WriteValueConversions::typeToString(fieldWriteConstraint->getType()).toStdString();\n    }\n\n    return writeConstraintText;\n}\n\n//-----------------------------------------------------------------------------\n// Function: FieldInterface::getWriteValueConstraint()\n//-----------------------------------------------------------------------------\nQSharedPointer<WriteValueConstraint> FieldInterface::getWriteValueConstraint(std::string const& fieldName, int accessPolicyIndex /*= -1*/) const\n{\n    QSharedPointer<Field> field = getField(fieldName);\n    if (!field)\n    {\n        return QSharedPointer<WriteValueConstraint>();\n    }\n    \n    if (accessPolicyIndex == -1)\n    {\n        QSharedPointer<WriteValueConstraint> fieldWriteConstraint = field->getWriteConstraint();\n        if (fieldWriteConstraint)\n        {\n            return fieldWriteConstraint;\n        }\n    }\n\n    else if (accessPolicyIndex >= 0)\n    {\n        if (auto accessPolicies = field->getFieldAccessPolicies();\n            accessPolicyIndex <= accessPolicies->size() - 1)\n        {\n            return accessPolicies->at(accessPolicyIndex)->getWriteValueConstraint();\n        }\n    }\n\n    return QSharedPointer<WriteValueConstraint>();\n}\n\n\n//-----------------------------------------------------------------------------\n// Function: FieldInterface::setWriteConstraint()\n//-----------------------------------------------------------------------------\nbool FieldInterface::setWriteConstraint(std::string const& fieldName, std::string const& newConstraintText, int accessPolicyIndex /*= -1*/)\n{\n    QSharedPointer<Field> selectedField = getField(fieldName);\n    if (!selectedField)\n    {\n        return false;\n    }\n\n    // Returns non-null write constraint if it exists either as std14 or std22. No need to check \n    // the access policy index later.\n    auto writeConstraint = getWriteValueConstraint(fieldName, accessPolicyIndex);\n\n    bool isStd14 = accessPolicyIndex == -1;\n\n    if (writeConstraint)\n    {\n        WriteValueConstraint::Type constraintType =\n            WriteValueConversions::stringToType(QString::fromStdString(newConstraintText));\n\n        if (constraintType == WriteValueConstraint::TYPE_COUNT)\n        {\n            if (isStd14)\n            {\n                selectedField->setWriteConstraint(nullptr);\n            }\n            else\n            {\n                selectedField->getFieldAccessPolicies()->at(accessPolicyIndex)->setWriteValueConstraint(nullptr);\n            }\n        }\n        else\n        {\n            writeConstraint->setType(constraintType);\n        }\n    }\n    else\n    {\n        QSharedPointer<WriteValueConstraint> newConstraint(new WriteValueConstraint());\n        WriteValueConstraint::Type constraintType =\n            WriteValueConversions::stringToType(QString::fromStdString(newConstraintText));\n\n        if (constraintType != WriteValueConstraint::TYPE_COUNT)\n        {\n            newConstraint->setType(constraintType);\n            \n            if (isStd14)\n            {\n                selectedField->setWriteConstraint(newConstraint);\n            }\n            else\n            {\n                selectedField->getFieldAccessPolicies()->at(accessPolicyIndex)->setWriteValueConstraint(newConstraint);\n            }\n        }\n    }\n\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: FieldInterface::getWriteConstraintMinimumValue()\n//-----------------------------------------------------------------------------\nstd::string FieldInterface::getWriteConstraintMinimumValue(std::string const& fieldName, int accessPolicyIndex /*= -1*/, int const& baseNumber /*= 0*/) const\n{\n    QSharedPointer<WriteValueConstraint> constraint = getWriteValueConstraint(fieldName, accessPolicyIndex);\n    if (constraint)\n    {\n        return parseExpressionToBaseNumber(constraint->getMinimum(), baseNumber).toStdString();\n    }\n\n    return std::string();\n}\n\n//-----------------------------------------------------------------------------\n// Function: FieldInterface::getWriteConstraintMinimumFormattedExpression()\n//-----------------------------------------------------------------------------\nstd::string FieldInterface::getWriteConstraintMinimumFormattedExpression(std::string const& fieldName, int accessPolicyIndex /*= -1*/) const\n{\n    QSharedPointer<WriteValueConstraint> constraint = getWriteValueConstraint(fieldName, accessPolicyIndex);\n    if (constraint)\n    {\n        return formattedValueFor(constraint->getMinimum()).toStdString();\n    }\n\n    return std::string();\n}\n\n//-----------------------------------------------------------------------------\n// Function: FieldInterface::getWriteConstraintMinimumExpression()\n//-----------------------------------------------------------------------------\nstd::string FieldInterface::getWriteConstraintMinimumExpression(std::string const& fieldName, int accessPolicyIndex /*= -1*/) const\n{\n    QSharedPointer<WriteValueConstraint> constraint = getWriteValueConstraint(fieldName, accessPolicyIndex);\n    if (constraint)\n    {\n        return constraint->getMinimum().toStdString();\n    }\n\n    return std::string();\n}\n\n//-----------------------------------------------------------------------------\n// Function: FieldInterface::setWriteConstraintMinimum()\n//-----------------------------------------------------------------------------\nbool FieldInterface::setWriteConstraintMinimum(std::string const& fieldName,\n    std::string const& newWriteConstraintMinimum,\n    int accessPolicyIndex /*= -1*/)\n{\n    QSharedPointer<WriteValueConstraint> constraint = getWriteValueConstraint(fieldName, accessPolicyIndex);\n    if (!constraint)\n    {\n        return false;\n    }\n\n    constraint->setMinimum(QString::fromStdString(newWriteConstraintMinimum));\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: FieldInterface::getWriteConstraintMaximumValue()\n//-----------------------------------------------------------------------------\nstd::string FieldInterface::getWriteConstraintMaximumValue(std::string const& fieldName, int accessPolicyIndex /*= -1*/, int const& baseNumber /*= 0*/) const\n{\n    QSharedPointer<WriteValueConstraint> constraint = getWriteValueConstraint(fieldName, accessPolicyIndex);\n    if (constraint)\n    {\n        return parseExpressionToBaseNumber(constraint->getMaximum(), baseNumber).toStdString();\n    }\n\n    return std::string();\n}\n\n//-----------------------------------------------------------------------------\n// Function: FieldInterface::getWriteConstraintMaximumFormattedExpression()\n//-----------------------------------------------------------------------------\nstd::string FieldInterface::getWriteConstraintMaximumFormattedExpression(std::string const& fieldName, int accessPolicyIndex /*= -1*/) const\n{\n    QSharedPointer<WriteValueConstraint> constraint = getWriteValueConstraint(fieldName, accessPolicyIndex);\n    if (constraint)\n    {\n        return formattedValueFor(constraint->getMaximum()).toStdString();\n    }\n\n    return std::string();\n}\n\n//-----------------------------------------------------------------------------\n// Function: FieldInterface::getWriteConstraintMaximumExpression()\n//-----------------------------------------------------------------------------\nstd::string FieldInterface::getWriteConstraintMaximumExpression(std::string const& fieldName, int accessPolicyIndex /*= -1*/) const\n{\n    QSharedPointer<WriteValueConstraint> constraint = getWriteValueConstraint(fieldName, accessPolicyIndex);\n    if (constraint)\n    {\n        return constraint->getMaximum().toStdString();\n    }\n\n    return std::string();\n}\n\n//-----------------------------------------------------------------------------\n// Function: FieldInterface::setWriteConstraintMaximum()\n//-----------------------------------------------------------------------------\nbool FieldInterface::setWriteConstraintMaximum(std::string const& fieldName,\n    std::string const& newWriteConstraintMaximum,\n    int accessPolicyIndex /*= -1*/)\n{\n    QSharedPointer<WriteValueConstraint> constraint = getWriteValueConstraint(fieldName, accessPolicyIndex);\n    if (!constraint)\n    {\n        return false;\n    }\n\n    constraint->setMaximum(QString::fromStdString(newWriteConstraintMaximum));\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: FieldInterface::getReservedValue()\n//-----------------------------------------------------------------------------\nstd::string FieldInterface::getReservedValue(std::string const& fieldName, int accessPolicyIndex, int const& baseNumber) const\n{\n    QSharedPointer<Field> field = getField(fieldName);\n    \n    if (!field)\n    {\n        return std::string();\n    }\n    \n    // Std14\n    if (accessPolicyIndex == -1)\n    {\n        return parseExpressionToBaseNumber(field->getReserved(), baseNumber).toStdString();\n    }\n    // Std22\n    else if (accessPolicyIndex >= 0)\n    {\n        if (auto accessPolicies = field->getFieldAccessPolicies();\n            accessPolicyIndex <= accessPolicies->size() - 1)\n        {\n            return parseExpressionToBaseNumber(\n                accessPolicies->at(accessPolicyIndex)->getReserved(), baseNumber).toStdString();\n        }\n    }\n\n    return std::string();\n}\n\n//-----------------------------------------------------------------------------\n// Function: FieldInterface::getReservedFormattedExpression()\n//-----------------------------------------------------------------------------\nstd::string FieldInterface::getReservedFormattedExpression(std::string const& fieldName, int accessPolicyIndex /*= -1*/) const\n{\n    QSharedPointer<Field> field = getField(fieldName);\n    if (!field)\n    {\n        return std::string();\n    }\n    \n    if (accessPolicyIndex == -1)\n    {\n        return formattedValueFor(field->getReserved()).toStdString();\n    }\n\n    else if (accessPolicyIndex >= 0)\n    {\n        if (auto accessPolicies = field->getFieldAccessPolicies();\n            accessPolicyIndex <= accessPolicies->size() - 1)\n        {\n            return formattedValueFor(accessPolicies->at(accessPolicyIndex)->getReserved()).toStdString();\n        }\n    }\n\n    return std::string();\n}\n\n//-----------------------------------------------------------------------------\n// Function: FieldInterface::getReservedExpression()\n//-----------------------------------------------------------------------------\nstd::string FieldInterface::getReservedExpression(std::string const& fieldName, int accessPolicyIndex /*= -1*/) const\n{\n    QSharedPointer<Field> field = getField(fieldName);\n    if (!field)\n    {\n        return std::string();\n    }\n\n    if (accessPolicyIndex == -1)\n    {\n        return field->getReserved().toStdString();\n    }\n\n    else if (accessPolicyIndex >= 0)\n    {\n        if (auto accessPolicies = field->getFieldAccessPolicies();\n            accessPolicyIndex <= accessPolicies->size() - 1)\n        {\n            return accessPolicies->at(accessPolicyIndex)->getReserved().toStdString();\n        }\n    }\n\n    return std::string();\n}\n\n//-----------------------------------------------------------------------------\n// Function: FieldInterface::setReserved()\n//-----------------------------------------------------------------------------\nbool FieldInterface::setReserved(std::string const& fieldName, std::string const& newReserved, int accessPolicyIndex /*= -1*/)\n{\n    QSharedPointer<Field> field = getField(fieldName);\n    if (!field)\n    {\n        return false;\n    }\n\n    if (accessPolicyIndex == -1)\n    {\n        field->setReserved(QString::fromStdString(newReserved));\n        return true;\n    }\n\n    else if (accessPolicyIndex >= 0)\n    {\n        if (auto accessPolicies = field->getFieldAccessPolicies();\n            accessPolicyIndex <= accessPolicies->size() - 1)\n        {\n            accessPolicies->at(accessPolicyIndex)->setReserved(QString::fromStdString(newReserved));\n            return true;\n        }\n    }\n\n    return false;\n}\n\n//-----------------------------------------------------------------------------\n// Function: FieldInterface::getID()\n//-----------------------------------------------------------------------------\nstd::string FieldInterface::getID(std::string const& fieldName)\n{\n    QSharedPointer<Field> field = getField(fieldName);\n    if (field)\n    {\n        return field->getId().toStdString();\n    }\n\n    return std::string();\n}\n\n//-----------------------------------------------------------------------------\n// Function: FieldInterface::setID()\n//-----------------------------------------------------------------------------\nbool FieldInterface::setID(std::string const& fieldName, std::string const& newID)\n{\n    QSharedPointer<Field> field = getField(fieldName);\n    if (!field)\n    {\n        return false;\n    }\n\n    field->setId(QString::fromStdString(newID));\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: FieldInterface::addFieldAccessPolicy()\n//-----------------------------------------------------------------------------\nbool FieldInterface::addFieldAccessPolicy(std::string const& fieldName)\n{\n    auto field = getField(fieldName);\n    if (!field)\n    {\n        return false;\n    }\n\n    QSharedPointer<FieldAccessPolicy> newAccessPolicy(new FieldAccessPolicy());\n    field->getFieldAccessPolicies()->append(newAccessPolicy);\n\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: FieldInterface::removeFieldAccessPolicy()\n//-----------------------------------------------------------------------------\nbool FieldInterface::removeFieldAccessPolicy(std::string const& fieldName, int accessPolicyIndex)\n{\n    auto field = getField(fieldName);\n    if (!field || accessPolicyIndex > field->getFieldAccessPolicies()->size() - 1)\n    {\n        return false;\n    }\n\n    field->getFieldAccessPolicies()->removeAt(accessPolicyIndex);\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: FieldInterface::getModeReferencesInUse()\n//-----------------------------------------------------------------------------\nstd::vector<std::pair<unsigned int, std::string> > FieldInterface::getModeReferencesInUse(std::string const& fieldName, int accessPolicyIndex) const\n{\n    std::vector<std::pair<unsigned int, std::string> > modeRefsInUse;\n\n    auto field = getField(fieldName);\n    \n    if (!field)\n    {\n        return modeRefsInUse;\n    }\n\n    auto fieldAccessPolicies = field->getFieldAccessPolicies();\n\n    int currentIndex = 0;\n    for (auto const& accessPolicy : *fieldAccessPolicies)\n    {\n        // Get all mode references, excluding mode references in given field access policy.\n        if (currentIndex != accessPolicyIndex)\n        {\n            auto modeReferences = accessPolicy->getModeReferences();\n            std::transform(modeReferences->cbegin(), modeReferences->cend(), std::back_inserter(modeRefsInUse),\n                [](auto modeReference)\n                {\n                    return std::make_pair(modeReference->getPriority(), modeReference->getReference().toStdString());\n                });\n        }\n        ++currentIndex;\n    }\n\n    return modeRefsInUse;\n}\n\n//-----------------------------------------------------------------------------\n// Function: FieldInterface::getModeReferences()\n//-----------------------------------------------------------------------------\nstd::vector<std::pair<unsigned int, std::string> > FieldInterface::getModeReferences(\n    std::string const& fieldName, int accessPolicyIndex) const\n{\n    std::vector<std::pair<unsigned int, std::string> > modeRefs;\n    if (auto field = getField(fieldName))\n    {\n        auto accessPolicies = field->getFieldAccessPolicies();\n        if (accessPolicyIndex >= 0 && accessPolicyIndex < accessPolicies->size())\n        {\n            auto modeReferences = accessPolicies->at(accessPolicyIndex)->getModeReferences();\n\n            std::transform(modeReferences->cbegin(), modeReferences->cend(), std::back_inserter(modeRefs),\n                [](auto modeReference)\n                {\n                    return std::make_pair(modeReference->getPriority(), modeReference->getReference().toStdString());\n                });\n        }\n    }\n\n    return modeRefs;\n}\n\n//-----------------------------------------------------------------------------\n// Function: FieldInterface::setModeReferences()\n//-----------------------------------------------------------------------------\nbool FieldInterface::setModeReferences(std::string const& fieldName, int accessPolicyIndex, \n    std::vector<std::pair<unsigned int, std::string> > const& newModeRefs)\n{\n    if (auto field = getField(fieldName))\n    {\n        auto fieldAccessPolicies = field->getFieldAccessPolicies();\n\n        if (accessPolicyIndex >= 0 && accessPolicyIndex < fieldAccessPolicies->size())\n        {\n            QSharedPointer<QList<QSharedPointer<ModeReference> > > createdModeRefs(\n                new QList<QSharedPointer<ModeReference> >());\n\n            for (auto const& [priority, reference] : newModeRefs)\n            {\n                QSharedPointer<ModeReference> createdModeRef(new ModeReference());\n                createdModeRef->setReference(QString::fromStdString(reference));\n                createdModeRef->setPriority(priority);\n                createdModeRefs->append(createdModeRef);\n            }\n\n            fieldAccessPolicies->at(accessPolicyIndex)->setModeReferences(createdModeRefs);\n            return true;\n        }\n    }\n\n    return false;\n}\n\n//-----------------------------------------------------------------------------\n// Function: FieldInterface::getItem()\n//-----------------------------------------------------------------------------\nQSharedPointer<NameGroup> FieldInterface::getItem(std::string const& fieldName) const\n{\n    return getField(fieldName);\n}\n"
  },
  {
    "path": "KactusAPI/interfaces/component/FileBuilderInterface.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: FileBuilderInterface.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 03.09.2020\n//\n// Description:\n// Interface for editing file builders.\n//-----------------------------------------------------------------------------\n\n#include \"FileBuilderInterface.h\"\n\n#include <IPXACTmodels/common/FileBuilder.h>\n\nnamespace\n{\n    std::string const DEFAULT_TYPE = \"unknown\";\n    QString const USERFILETYPE = \"user\";\n};\n\n//-----------------------------------------------------------------------------\n// Function: FileBuilderInterface::FileBuilderInterface()\n//-----------------------------------------------------------------------------\nFileBuilderInterface::FileBuilderInterface(QSharedPointer<ExpressionParser> expressionParser,\n    QSharedPointer<ExpressionFormatter> expressionFormatter):\nParameterizableInterface(expressionParser, expressionFormatter),\nCommonInterface(),\nfileBuilders_()\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: FileBuilderInterface::setFileBuilders()\n//-----------------------------------------------------------------------------\nvoid FileBuilderInterface::setFileBuilders(QSharedPointer<QList<QSharedPointer<FileBuilder>>> newFileBuilders)\n{\n    fileBuilders_ = newFileBuilders;\n}\n\n//-----------------------------------------------------------------------------\n// Function: FileBuilderInterface::itemCount()\n//-----------------------------------------------------------------------------\nint FileBuilderInterface::itemCount() const\n{\n    if (fileBuilders_)\n    {\n        return fileBuilders_->count();\n    }\n\n    return 0;\n}\n\n//-----------------------------------------------------------------------------\n// Function: FileBuilderInterface::validateItems()\n//-----------------------------------------------------------------------------\nbool FileBuilderInterface::validateItems() const\n{\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: FileBuilderInterface::getItemNames()\n//-----------------------------------------------------------------------------\nstd::vector<std::string> FileBuilderInterface::getItemNames() const\n{\n    std::vector<std::string> names;\n    if (fileBuilders_)\n    {\n        for (auto builder : *fileBuilders_)\n        {\n            QString builderID = builder->getFileType().type_;\n\n            names.push_back(builderID.toStdString());\n        }\n    }\n\n    return names;\n}\n\n//-----------------------------------------------------------------------------\n// Function: FileBuilderInterface::getAllReferencesToIdInItem()\n//-----------------------------------------------------------------------------\nint FileBuilderInterface::getAllReferencesToIdInItem(const std::string& itemName, std::string const& valueID) const\n{\n    int totalReferencesToParameter = 0;\n\n    QSharedPointer<FileBuilder> selectedFileBuilder = getFileBuilder(itemName);\n    if (selectedFileBuilder)\n    {\n        QString idString = QString::fromStdString(valueID);\n\n        int referencesInReplaceDefaultFlags(selectedFileBuilder->getReplaceDefaultFlags().count(idString));\n\n        totalReferencesToParameter = referencesInReplaceDefaultFlags;\n    }\n\n    return totalReferencesToParameter;\n}\n\n//-----------------------------------------------------------------------------\n// Function: FileBuilderInterface::getExpressionsInSelectedFileBuilders()\n//-----------------------------------------------------------------------------\nstd::vector<std::string> FileBuilderInterface::getExpressionsInSelectedFileBuilders(\n    std::vector<std::string> fileBuilderNames) const\n{\n    std::vector<std::string> expressionList;\n\n    for (auto name : fileBuilderNames)\n    {\n        QSharedPointer<FileBuilder> currentFileBuilder = getFileBuilder(name);\n        if (currentFileBuilder)\n        {\n            expressionList.push_back(currentFileBuilder->getReplaceDefaultFlags().toStdString());\n        }\n    }\n\n    return expressionList;\n}\n\n//-----------------------------------------------------------------------------\n// Function: FileBuilderInterface::addFileBuilder()\n//-----------------------------------------------------------------------------\nvoid FileBuilderInterface::addFileBuilder(int const& row, std::string const& newFileBuilderName)\n{\n    QString uniqueFileBuilderName = getUniqueName(newFileBuilderName, DEFAULT_TYPE);\n\n    QSharedPointer<FileBuilder> newFileBuilder(new FileBuilder());\n\n    newFileBuilder->setFileType(uniqueFileBuilderName);\n\n    fileBuilders_->insert(row, newFileBuilder);\n}\n\n//-----------------------------------------------------------------------------\n// Function: FileBuilderInterface::addFileBuilder()\n//-----------------------------------------------------------------------------\nvoid FileBuilderInterface::addFileBuilder(std::string const& newFileBuilderName /*= std::string(\"\")*/)\n{\n    addFileBuilder(fileBuilders_->size(), newFileBuilderName);\n}\n\n//-----------------------------------------------------------------------------\n// Function: FileBuilderInterface::removeFileBuilder()\n//-----------------------------------------------------------------------------\nbool FileBuilderInterface::removeFileBuilder(std::string const& fileBuilderName)\n{\n    QSharedPointer<FileBuilder> removedFileBuilder = getFileBuilder(fileBuilderName);\n    if (!removedFileBuilder)\n    {\n        return false;\n    }\n\n    return fileBuilders_->removeOne(removedFileBuilder);\n}\n\n//-----------------------------------------------------------------------------\n// Function: FileBuilderInterface::getFileBuilder()\n//-----------------------------------------------------------------------------\nQSharedPointer<FileBuilder> FileBuilderInterface::getFileBuilder(std::string const& fileBuilderName) const\n{\n    if (fileBuilders_)\n    {\n        for (auto builder : *fileBuilders_)\n        {\n            if (builder->getFileType().type_ == QString::fromStdString(fileBuilderName))\n            {\n                return builder;\n            }\n        }\n    }\n\n    return QSharedPointer<FileBuilder>();\n}\n\n//-----------------------------------------------------------------------------\n// Function: FileBuilderInterface::getIndexedFileType()\n//-----------------------------------------------------------------------------\nstd::string FileBuilderInterface::getIndexedFileType(int const& itemIndex)\n{\n    std::string fileType = \"\";\n\n    if (fileBuilders_ && (itemIndex >= 0 && itemIndex < fileBuilders_->size()))\n    {\n        QSharedPointer<FileBuilder> builder = fileBuilders_->at(itemIndex);\n        fileType = builder->getFileType().type_.toStdString();\n    }\n\n    return fileType;\n}\n\n//-----------------------------------------------------------------------------\n// Function: FileBuilderInterface::setFileType()\n//-----------------------------------------------------------------------------\nbool FileBuilderInterface::setFileType(std::string const& currentFileType, std::string const& newFileType)\n{\n    QSharedPointer<FileBuilder> editedFileBuilder = getFileBuilder(currentFileType);\n    if (editedFileBuilder && nameHasChanged(newFileType, currentFileType))\n    {\n        QString uniqueNewFileType = getUniqueName(newFileType, DEFAULT_TYPE);\n\n        editedFileBuilder->setFileType(uniqueNewFileType);\n        return true;\n    }\n    else\n    {\n        return false;\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: FileBuilderInterface::getCommand()\n//-----------------------------------------------------------------------------\nstd::string FileBuilderInterface::getCommand(std::string const& fileType) const\n{\n    QSharedPointer<FileBuilder> selectedBuilder = getFileBuilder(fileType);\n    if (selectedBuilder)\n    {\n        return selectedBuilder->getCommand().toStdString();\n    }\n\n    return std::string(\"\");\n}\n\n//-----------------------------------------------------------------------------\n// Function: FileBuilderInterface::setCommand()\n//-----------------------------------------------------------------------------\nbool FileBuilderInterface::setCommand(std::string const& fileType, std::string const& newCommand)\n{\n    QSharedPointer<FileBuilder> editedFileBuilder = getFileBuilder(fileType);\n    if (!editedFileBuilder)\n    {\n        return false;\n    }\n\n    editedFileBuilder->setCommand(QString::fromStdString(newCommand));\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: FileBuilderInterface::getFlags()\n//-----------------------------------------------------------------------------\nstd::string FileBuilderInterface::getFlags(std::string const& fileType) const\n{\n    QSharedPointer<FileBuilder> selectedBuilder = getFileBuilder(fileType);\n    if (selectedBuilder)\n    {\n        return selectedBuilder->getFlags().toStdString();\n    }\n\n    return std::string(\"\");\n}\n\n//-----------------------------------------------------------------------------\n// Function: FileBuilderInterface::setFlags()\n//-----------------------------------------------------------------------------\nbool FileBuilderInterface::setFlags(std::string const& fileType, std::string const& newFlags)\n{\n    QSharedPointer<FileBuilder> editedFileBuilder = getFileBuilder(fileType);\n    if (!editedFileBuilder)\n    {\n        return false;\n    }\n\n    editedFileBuilder->setFlags(QString::fromStdString(newFlags));\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: FileBuilderInterface::getReplaceDefaultFlagsValue()\n//-----------------------------------------------------------------------------\nstd::string FileBuilderInterface::getReplaceDefaultFlagsValue(std::string const& fileType, int const& baseNumber)\n    const\n{\n    QSharedPointer<FileBuilder> selectedBuilder = getFileBuilder(fileType);\n    if (selectedBuilder)\n    {\n        return parseExpressionToBaseNumber(selectedBuilder->getReplaceDefaultFlags(), baseNumber).toStdString();\n    }\n\n    return std::string(\"\");\n}\n\n//-----------------------------------------------------------------------------\n// Function: FileBuilderInterface::getReplaceDefaultFlagsFormattedExpression()\n//-----------------------------------------------------------------------------\nstd::string FileBuilderInterface::getReplaceDefaultFlagsFormattedExpression(std::string const& fileType) const\n{\n    QSharedPointer<FileBuilder> selectedBuilder = getFileBuilder(fileType);\n    if (selectedBuilder)\n    {\n        return formattedValueFor(selectedBuilder->getReplaceDefaultFlags()).toStdString();\n    }\n\n    return std::string(\"\");\n}\n\n//-----------------------------------------------------------------------------\n// Function: FileBuilderInterface::getReplaceDefaultFlagsExpression()\n//-----------------------------------------------------------------------------\nstd::string FileBuilderInterface::getReplaceDefaultFlagsExpression(std::string const& fileType) const\n{\n    QSharedPointer<FileBuilder> selectedBuilder = getFileBuilder(fileType);\n    if (selectedBuilder)\n    {\n        return selectedBuilder->getReplaceDefaultFlags().toStdString();\n    }\n\n    return std::string(\"\");\n}\n\n//-----------------------------------------------------------------------------\n// Function: FileBuilderInterface::setReplaceDefaultFlags()\n//-----------------------------------------------------------------------------\nbool FileBuilderInterface::setReplaceDefaultFlags(std::string const& filetype,\n    std::string const& newReplaceDefaultFlags)\n{\n    QSharedPointer<FileBuilder> selectedBuilder = getFileBuilder(filetype);\n    if (!selectedBuilder)\n    {\n        return false;\n    }\n\n    selectedBuilder->setReplaceDefaultFlags(QString::fromStdString(newReplaceDefaultFlags));\n    return true;\n}\n"
  },
  {
    "path": "KactusAPI/interfaces/component/FileInterface.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: FileInterface.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 29.06.2020\n//\n// Description:\n// Interface for editing files.\n//-----------------------------------------------------------------------------\n\n#include <FileInterface.h>\n\n#include <IPXACTmodels/Component/File.h>\n#include <IPXACTmodels/Component/validators/FileValidator.h>\n\nnamespace\n{\n    std::string const FILE_TYPE = \"file\";\n};\n\n//-----------------------------------------------------------------------------\n// Function: FileInterface::FileInterface()\n//-----------------------------------------------------------------------------\nFileInterface::FileInterface(QSharedPointer<FileValidator> validator,\n    QSharedPointer<ExpressionParser> expressionParser, QSharedPointer<ExpressionFormatter> expressionFormatter):\nParameterizableInterface(expressionParser, expressionFormatter),\nNameGroupInterface(),\nfiles_(),\nvalidator_(validator)\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: FileInterface::setFiles()\n//-----------------------------------------------------------------------------\nvoid FileInterface::setFiles(QSharedPointer<QList<QSharedPointer<File>>> newFiles)\n{\n    files_ = newFiles;\n}\n\n//-----------------------------------------------------------------------------\n// Function: FileInterface::getItemIndex()\n//-----------------------------------------------------------------------------\nint FileInterface::getItemIndex(std::string const& itemName) const\n{\n    if (files_)\n    {\n        for (int i = 0; i < files_->size(); ++i)\n        {\n            if (files_->at(i)->name().toStdString() == itemName)\n            {\n                return i;\n            }\n        }\n    }\n\n    return -1;\n}\n\n//-----------------------------------------------------------------------------\n// Function: FileInterface::getIndexedItemName()\n//-----------------------------------------------------------------------------\nstd::string FileInterface::getIndexedItemName(int itemIndex) const\n{\n    std::string fileName = \"\";\n    if (files_ && (itemIndex >= 0 && itemIndex < files_->size()))\n    {\n        fileName = files_->at(itemIndex)->name().toStdString();\n    }\n\n    return fileName;\n}\n\n//-----------------------------------------------------------------------------\n// Function: FileInterface::itemCount()\n//-----------------------------------------------------------------------------\nint FileInterface::itemCount() const\n{\n    if (files_)\n    {\n        return files_->count();\n    }\n\n    return 0;\n}\n\n//-----------------------------------------------------------------------------\n// Function: FileInterface::getItemNames()\n//-----------------------------------------------------------------------------\nstd::vector<std::string> FileInterface::getItemNames() const\n{\n    std::vector<std::string> names;\n    if (files_)\n    {\n        for (auto file : *files_)\n        {\n            names.push_back(file->name().toStdString());\n        }\n    }\n\n    return names;\n}\n\n//-----------------------------------------------------------------------------\n// Function: FileInterface::setName()\n//-----------------------------------------------------------------------------\nbool FileInterface::setName(std::string const& currentName, std::string const& newName)\n{\n    QSharedPointer<File> editedFile = getFile(currentName);\n    if (editedFile && nameHasChanged(newName, currentName))\n    {\n        QString uniqueNewName = getUniqueName(newName, FILE_TYPE);\n\n        editedFile->setName(uniqueNewName);\n        return true;\n    }\n    else\n    {\n        return false;\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: FileInterface::getDescription()\n//-----------------------------------------------------------------------------\nstd::string FileInterface::getDescription(std::string const& itemName) const\n{\n    QSharedPointer<File> editedFile = getFile(itemName);\n    if (editedFile)\n    {\n        return editedFile->getDescription().toStdString();\n    }\n\n    return std::string(\"\");\n}\n\n//-----------------------------------------------------------------------------\n// Function: FileInterface::setDescription()\n//-----------------------------------------------------------------------------\nbool FileInterface::setDescription(std::string const& itemName, std::string const& newDescription)\n{\n    QSharedPointer<File> editedFile = getFile(itemName);\n    if (!editedFile)\n    {\n        return false;\n    }\n\n    editedFile->setDescription(QString::fromStdString(newDescription));\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: FileInterface::validateItems()\n//-----------------------------------------------------------------------------\nbool FileInterface::validateItems() const\n{\n    for (auto file : *files_)\n    {\n        if (!validator_->validate(file))\n        {\n            return false;\n        }\n    }\n\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: FileInterface::itemHasValidName()\n//-----------------------------------------------------------------------------\nbool FileInterface::itemHasValidName(std::string const& itemName) const\n{\n    QSharedPointer<File> file = getFile(itemName);\n    if (file)\n    {\n        return validator_->hasValidName(file->name());\n    }\n\n    return false;\n}\n\n//-----------------------------------------------------------------------------\n// Function: FileInterface::getAllReferencesToIdInItem()\n//-----------------------------------------------------------------------------\nint FileInterface::getAllReferencesToIdInItem(const std::string& fileName, std::string const& valueID) const\n{\n    int totalReferencesToParameter = 0;\n\n    QSharedPointer<BuildCommand> selectedBuildCommand = getBuildCommand(fileName);\n    if (selectedBuildCommand)\n    {\n        QString idString = QString::fromStdString(valueID);\n\n        int referencesInBuildCommandReplaceDefaultFlags =\n            selectedBuildCommand->getReplaceDefaultFlags().count(idString);\n\n        totalReferencesToParameter = referencesInBuildCommandReplaceDefaultFlags;\n    }\n\n\n    return totalReferencesToParameter;\n}\n\n//-----------------------------------------------------------------------------\n// Function: FileInterface::getExpressionsInSelectedFiles()\n//-----------------------------------------------------------------------------\nstd::vector<std::string> FileInterface::getExpressionsInSelectedFiles(std::vector<std::string> fileNames) const\n{\n    std::vector<std::string> expressionList;\n\n    for (auto name : fileNames)\n    {\n        QSharedPointer<BuildCommand> currentBuild = getBuildCommand(name);\n        if (currentBuild)\n        {\n            expressionList.push_back(currentBuild->getReplaceDefaultFlags().toStdString());\n        }\n    }\n\n    return expressionList;\n}\n\n//-----------------------------------------------------------------------------\n// Function: FileInterface::addFile()\n//-----------------------------------------------------------------------------\nvoid FileInterface::addFile(int const& row, std::string const& newFileName)\n{\n    QString fileName = getUniqueName(newFileName, FILE_TYPE);\n\n    QSharedPointer<File> newFile(new File(fileName));\n\n    QSettings settings;\n    newFile->setFileTypes(settings);\n\n    files_->insert(row, newFile);\n}\n\n//-----------------------------------------------------------------------------\n// Function: FileInterface::addFile()\n//-----------------------------------------------------------------------------\nvoid FileInterface::addFile(std::string const& newFileName /*= std::string(\"\")*/)\n{\n    addFile(files_->size(), newFileName);\n}\n\n//-----------------------------------------------------------------------------\n// Function: FileInterface::removeFile()\n//-----------------------------------------------------------------------------\nbool FileInterface::removeFile(std::string const& fileName)\n{\n    QSharedPointer<File> removedFile = getFile(fileName);\n    if (!removedFile)\n    {\n        return false;\n    }\n\n    return files_->removeOne(removedFile);\n}\n\n//-----------------------------------------------------------------------------\n// Function: FileInterface::swapFiles()\n//-----------------------------------------------------------------------------\nvoid FileInterface::swapFiles(int const& firstIndex, int const& secondIndex)\n{\n    files_->swapItemsAt(firstIndex, secondIndex);\n}\n\n//-----------------------------------------------------------------------------\n// Function: FileInterface::getFile()\n//-----------------------------------------------------------------------------\nQSharedPointer<File> FileInterface::getFile(std::string const& fileName) const\n{\n    if (files_)\n    {\n        for (auto file : *files_)\n        {\n            if (file->name().toStdString() == fileName)\n            {\n                return file;\n            }\n        }\n    }\n\n    return QSharedPointer<File>();\n}\n\n//-----------------------------------------------------------------------------\n// Function: FileInterface::getLogicalName()\n//-----------------------------------------------------------------------------\nstd::string FileInterface::getLogicalName(std::string const& fileName) const\n{\n    QSharedPointer<File> selectedFile = getFile(fileName);\n    if (selectedFile)\n    {\n        return selectedFile->getLogicalName().toStdString();\n    }\n\n    return \"\";\n}\n\n//-----------------------------------------------------------------------------\n// Function: FileInterface::setLogicalName()\n//-----------------------------------------------------------------------------\nbool FileInterface::setLogicalName(std::string const& fileName, std::string newLogicalName)\n{\n    QSharedPointer<File> editedFile = getFile(fileName);\n    if (!editedFile)\n    {\n        return false;\n    }\n\n    editedFile->setLogicalName(QString::fromStdString(newLogicalName));\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: FileInterface::isLogicalNameDefault()\n//-----------------------------------------------------------------------------\nbool FileInterface::isLogicalNameDefault(std::string const& fileName) const\n{\n    QSharedPointer<File> selectedFile = getFile(fileName);\n    if (selectedFile)\n    {\n        return selectedFile->isLogicalNameDefault();\n    }\n\n    return false;\n}\n\n//-----------------------------------------------------------------------------\n// Function: FileInterface::setLogicalNameDefault()\n//-----------------------------------------------------------------------------\nbool FileInterface::setLogicalNameDefault(std::string const& fileName, bool newLogicalDefault)\n{\n    QSharedPointer<File> editedFile = getFile(fileName);\n    if (!editedFile)\n    {\n        return false;\n    }\n\n    editedFile->setLogicalNameDefault(newLogicalDefault);\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: FileInterface::isStructural()\n//-----------------------------------------------------------------------------\nbool FileInterface::isStructural(std::string const& fileName) const\n{\n    QSharedPointer<File> selectedFile = getFile(fileName);\n    if (selectedFile)\n    {\n        return selectedFile->isStructural();\n    }\n\n    return false;\n}\n\n//-----------------------------------------------------------------------------\n// Function: FileInterface::setLogicalNameDefault()\n//-----------------------------------------------------------------------------\nbool FileInterface::setStructural(std::string const& fileName, bool structuralStatus)\n{\n    QSharedPointer<File> editedFile = getFile(fileName);\n    if (!editedFile)\n    {\n        return false;\n    }\n\n    editedFile->setStructural(structuralStatus);\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: FileInterface::isIncludeFile()\n//-----------------------------------------------------------------------------\nbool FileInterface::isIncludeFile(std::string const& fileName) const\n{\n    QSharedPointer<File> selectedFile = getFile(fileName);\n    if (selectedFile)\n    {\n        return selectedFile->isIncludeFile();\n    }\n\n    return false;\n}\n\n//-----------------------------------------------------------------------------\n// Function: FileInterface::setIncludeFile()\n//-----------------------------------------------------------------------------\nbool FileInterface::setIncludeFile(std::string const& fileName, bool includeFileStatus)\n{\n    QSharedPointer<File> editedFile = getFile(fileName);\n    if (!editedFile)\n    {\n        return false;\n    }\n\n    editedFile->setIncludeFile(includeFileStatus);\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: FileInterface::hasExternalDeclarations()\n//-----------------------------------------------------------------------------\nbool FileInterface::hasExternalDeclarations(std::string const& fileName) const\n{\n    QSharedPointer<File> selectedFile = getFile(fileName);\n    if (selectedFile)\n    {\n        return selectedFile->hasExternalDeclarations();\n    }\n\n    return false;\n}\n\n//-----------------------------------------------------------------------------\n// Function: FileInterface::setExternalDeclarations()\n//-----------------------------------------------------------------------------\nbool FileInterface::setExternalDeclarations(std::string const& fileName, bool externalDeclarationsStatus)\n{\n    QSharedPointer<File> editedFile = getFile(fileName);\n    if (!editedFile)\n    {\n        return false;\n    }\n\n    editedFile->setExternalDeclarations(externalDeclarationsStatus);\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: FileInterface::clearFileTypes()\n//-----------------------------------------------------------------------------\nvoid FileInterface::clearFileTypes(std::string const& fileName)\n{\n    QSharedPointer<File> editedFile = getFile(fileName);\n    if (editedFile)\n    {\n        editedFile->clearFileTypes();\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: FileInterface::setFileTypes()\n//-----------------------------------------------------------------------------\nbool FileInterface::setFileTypes(std::string const& fileName, std::vector<std::string> const newFileTypes)\n{\n    QSharedPointer<File> editedFile = getFile(fileName);\n    if (!editedFile)\n    {\n        return false;\n    }\n\n    clearFileTypes(fileName);\n    addMultipleFileTypes(fileName, newFileTypes);\n\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: FileInterface::addFileType()\n//-----------------------------------------------------------------------------\nbool FileInterface::addFileType(std::string const& fileName, std::string const newFileType)\n{\n    QSharedPointer<File> editedFile = getFile(fileName);\n    if (!editedFile)\n    {\n        return false;\n    }\n\n    editedFile->getFileTypes()->append(FileType(QString::fromStdString(newFileType)));\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: FileInterface::addMultipleFileTypes()\n//-----------------------------------------------------------------------------\nbool FileInterface::addMultipleFileTypes(std::string const& fileName, std::vector<std::string> const newFileTypes)\n{\n    QSharedPointer<File> editedFile = getFile(fileName);\n    if (!editedFile)\n    {\n        return false;\n    }\n\n    for (auto const& fileType : newFileTypes)\n    {\n        editedFile->getFileTypes()->append(FileType(QString::fromStdString(fileType)));\n    }\n\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: FileInterface::getDependencies()\n//-----------------------------------------------------------------------------\nstd::vector<std::string> FileInterface::getDependencies(std::string const& fileName) const\n{\n    std::vector<std::string> dependencies;\n    QSharedPointer<File> selectedFile = getFile(fileName);\n    if (selectedFile)\n    {\n        for (auto singleDependency : *selectedFile->getDependencies())\n        {\n            dependencies.push_back(singleDependency.toStdString());\n        }\n    }\n\n    return dependencies;\n}\n\n//-----------------------------------------------------------------------------\n// Function: FileInterface::clearDependencies()\n//-----------------------------------------------------------------------------\nvoid FileInterface::clearDependencies(std::string const& fileName)\n{\n    QSharedPointer<File> editedFile = getFile(fileName);\n    if (editedFile)\n    {\n        editedFile->getDependencies()->clear();\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: FileInterface::addDependency()\n//-----------------------------------------------------------------------------\nbool FileInterface::addDependency(std::string const& fileName, std::string const newDependency)\n{\n    QSharedPointer<File> editedFile = getFile(fileName);\n    if (!editedFile)\n    {\n        return false;\n    }\n\n    editedFile->getDependencies()->append(QString::fromStdString(newDependency));\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: FileInterface::addMultipleDependencies()\n//-----------------------------------------------------------------------------\nbool FileInterface::addMultipleDependencies(std::string const& fileName,\n    std::vector<std::string> const newDependencies)\n{\n    QSharedPointer<File> editedFile = getFile(fileName);\n    if (!editedFile)\n    {\n        return false;\n    }\n\n    for (auto dependency : newDependencies)\n    {\n        editedFile->getDependencies()->append(QString::fromStdString(dependency));\n    }\n\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: FileInterface::getExportedNames()\n//-----------------------------------------------------------------------------\nstd::vector<std::string> FileInterface::getExportedNames(std::string const& fileName) const\n{\n    std::vector<std::string> exportedNames;\n    QSharedPointer<File> selectedFile = getFile(fileName);\n    if (selectedFile)\n    {\n        for (auto singleName : *selectedFile->getExportedNames())\n        {\n            exportedNames.push_back(singleName.toStdString());\n        }\n    }\n\n    return exportedNames;\n}\n\n//-----------------------------------------------------------------------------\n// Function: FileInterface::clearExportedNames()\n//-----------------------------------------------------------------------------\nvoid FileInterface::clearExportedNames(std::string const& fileName)\n{\n    QSharedPointer<File> editedFile = getFile(fileName);\n    if (editedFile)\n    {\n        editedFile->getExportedNames()->clear();\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: FileInterface::addExportedName()\n//-----------------------------------------------------------------------------\nbool FileInterface::addExportedName(std::string const& fileName, std::string const newExportedName)\n{\n    QSharedPointer<File> editedFile = getFile(fileName);\n    if (!editedFile)\n    {\n        return false;\n    }\n\n    editedFile->getExportedNames()->append(QString::fromStdString(newExportedName));\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: FileInterface::addMultipleExportedNames()\n//-----------------------------------------------------------------------------\nbool FileInterface::addMultipleExportedNames(std::string const& fileName,\n    std::vector<std::string> const newExportedNames)\n{\n    QSharedPointer<File> editedFile = getFile(fileName);\n    if (!editedFile)\n    {\n        return false;\n    }\n\n    for (auto name : newExportedNames)\n    {\n        editedFile->getExportedNames()->append(QString::fromStdString(name));\n    }\n\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: FileInterface::getImageTypes()\n//-----------------------------------------------------------------------------\nstd::vector<std::string> FileInterface::getImageTypes(std::string const& fileName) const\n{\n    std::vector<std::string> imageTypes;\n    QSharedPointer<File> selectedFile = getFile(fileName);\n    if (selectedFile)\n    {\n        for (auto singleType : *selectedFile->getImageTypes())\n        {\n            imageTypes.push_back(singleType.toStdString());\n        }\n    }\n\n    return imageTypes;\n}\n\n//-----------------------------------------------------------------------------\n// Function: FileInterface::clearImageTypes()\n//-----------------------------------------------------------------------------\nvoid FileInterface::clearImageTypes(std::string const& fileName)\n{\n    QSharedPointer<File> editedFile = getFile(fileName);\n    if (editedFile)\n    {\n        editedFile->getImageTypes()->clear();\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: FileInterface::addImageType()\n//-----------------------------------------------------------------------------\nbool FileInterface::addImageType(std::string const& fileName, std::string const newImageType)\n{\n    QSharedPointer<File> editedFile = getFile(fileName);\n    if (!editedFile)\n    {\n        return false;\n    }\n\n    editedFile->getImageTypes()->append(QString::fromStdString(newImageType));\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: FileInterface::addMultipleImageTypes()\n//-----------------------------------------------------------------------------\nbool FileInterface::addMultipleImageTypes(std::string const& fileName,\n    std::vector<std::string> const newImageTypes)\n{\n    QSharedPointer<File> editedFile = getFile(fileName);\n    if (!editedFile)\n    {\n        return false;\n    }\n\n    for (auto imageType : newImageTypes)\n    {\n        editedFile->getImageTypes()->append(QString::fromStdString(imageType));\n    }\n\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: FileInterface::getFileTypes()\n//-----------------------------------------------------------------------------\nstd::vector<std::string> FileInterface::getFileTypes(std::string const& fileName) const\n{\n    std::vector<std::string> fileTypes;\n    QSharedPointer<File> editedFile = getFile(fileName);\n    if (editedFile)\n    {\n        for (auto const& type : *editedFile->getFileTypes())\n        {\n            fileTypes.push_back(type.type_.toStdString());\n        }\n    }\n\n    return fileTypes;\n}\n\n//-----------------------------------------------------------------------------\n// Function: FileInterface::getBuildCommandText()\n//-----------------------------------------------------------------------------\nstd::string FileInterface::getBuildCommandText(std::string const& fileName) const\n{\n    std::string buildCommandText = \"\";\n\n    QSharedPointer<BuildCommand> fileBuild = getBuildCommand(fileName);\n    if (fileBuild)\n    {\n        buildCommandText = fileBuild->getCommand().toStdString();\n    }\n\n    return buildCommandText;\n}\n\n//-----------------------------------------------------------------------------\n// Function: FileInterface::getBuildCommand()\n//-----------------------------------------------------------------------------\nQSharedPointer<BuildCommand> FileInterface::getBuildCommand(std::string const& fileName) const\n{\n    QSharedPointer<File> editedFile = getFile(fileName);\n    if (editedFile)\n    {\n        QSharedPointer<BuildCommand> fileBuild = editedFile->getBuildCommand();\n        if (fileBuild)\n        {\n            return fileBuild;\n        }\n    }\n\n    return QSharedPointer<BuildCommand>();\n}\n\n//-----------------------------------------------------------------------------\n// Function: FileInterface::setBuildCommand()\n//-----------------------------------------------------------------------------\nbool FileInterface::setBuildCommand(std::string const& fileName, std::string const& newBuildCommand)\n{\n    QSharedPointer<File> editedFile = getFile(fileName);\n    if (!editedFile)\n    {\n        return false;\n    }\n\n    QSharedPointer<BuildCommand> fileBuild = getBuildCommand(fileName);\n    if (fileBuild)\n    {\n        fileBuild->setCommand(QString::fromStdString(newBuildCommand));\n    }\n    else if (!newBuildCommand.empty())\n    {\n        QSharedPointer<BuildCommand> newFileBuild(new BuildCommand());\n        newFileBuild->setCommand(QString::fromStdString(newBuildCommand));\n\n        editedFile->setBuildcommand(newFileBuild);\n    }\n\n    if (newBuildCommand.empty())\n    {\n        removeEmptyBuildCommand(editedFile);\n    }\n\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: FileInterface::removeEmptyBuildCommand()\n//-----------------------------------------------------------------------------\nvoid FileInterface::removeEmptyBuildCommand(QSharedPointer<File> containingFile) const\n{\n    QSharedPointer<BuildCommand> buildCommand = containingFile->getBuildCommand();\n    if (buildCommand && buildCommand->getCommand().isEmpty() && buildCommand->getFlags().isEmpty() &&\n        buildCommand->getReplaceDefaultFlags().isEmpty() && buildCommand->getTargetName().isEmpty())\n    {\n        containingFile->setBuildcommand(QSharedPointer<BuildCommand>());\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: FileInterface::setBuildCommandFlags()\n//-----------------------------------------------------------------------------\nbool FileInterface::setBuildCommandFlags(std::string const& fileName, std::string const& newFlags)\n{\n    QSharedPointer<File> editedFile = getFile(fileName);\n    if (!editedFile)\n    {\n        return false;\n    }\n\n    QSharedPointer<BuildCommand> fileBuild = getBuildCommand(fileName);\n    if (fileBuild)\n    {\n        fileBuild->setFlags(QString::fromStdString(newFlags));\n    }\n    else if (!newFlags.empty())\n    {\n        QSharedPointer<BuildCommand> newFileBuild(new BuildCommand());\n        newFileBuild->setFlags(QString::fromStdString(newFlags));\n\n        editedFile->setBuildcommand(newFileBuild);\n    }\n\n    if (newFlags.empty())\n    {\n        removeEmptyBuildCommand(editedFile);\n    }\n\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: FileInterface::getBuildCommandFlags()\n//-----------------------------------------------------------------------------\nstd::string FileInterface::getBuildCommandFlags(std::string const& fileName) const\n{\n    std::string buildCommandFlags = \"\";\n\n    QSharedPointer<BuildCommand> fileBuild = getBuildCommand(fileName);\n    if (fileBuild)\n    {\n        buildCommandFlags = fileBuild->getFlags().toStdString();\n    }\n\n    return buildCommandFlags;\n}\n\n//-----------------------------------------------------------------------------\n// Function: FileInterface::getBuildCommandReplaceDefaultFlagsValue()\n//-----------------------------------------------------------------------------\nstd::string FileInterface::getBuildCommandReplaceDefaultFlagsValue(std::string const& fileName,\n    int const& baseNumber) const\n{\n    QSharedPointer<BuildCommand> fileBuild = getBuildCommand(fileName);\n    if (fileBuild)\n    {\n        return parseExpressionToBaseNumber(fileBuild->getReplaceDefaultFlags(), baseNumber).toStdString();\n    }\n\n    return std::string(\"\");\n}\n\n//-----------------------------------------------------------------------------\n// Function: FileInterface::getBuildCommandReplaceDefaultFlagsFormattedExpression()\n//-----------------------------------------------------------------------------\nstd::string FileInterface::getBuildCommandReplaceDefaultFlagsFormattedExpression(std::string const& fileName) const\n{\n    QSharedPointer<BuildCommand> fileBuild = getBuildCommand(fileName);\n    if (fileBuild)\n    {\n        return formattedValueFor(fileBuild->getReplaceDefaultFlags()).toStdString();\n    }\n\n    return std::string(\"\");\n}\n\n//-----------------------------------------------------------------------------\n// Function: FileInterface::getBuildCommandReplaceDefaultFlagsExpression()\n//-----------------------------------------------------------------------------\nstd::string FileInterface::getBuildCommandReplaceDefaultFlagsExpression(std::string const& fileName) const\n{\n    QSharedPointer<BuildCommand> fileBuild = getBuildCommand(fileName);\n    if (fileBuild)\n    {\n        return fileBuild->getReplaceDefaultFlags().toStdString();\n    }\n\n    return std::string(\"\");\n}\n\n//-----------------------------------------------------------------------------\n// Function: FileInterface::setbuildCommandReplaceDefaultFlags()\n//-----------------------------------------------------------------------------\nbool FileInterface::setbuildCommandReplaceDefaultFlags(std::string const& fileName,\n    std::string const& newReplaceDefaultFlags)\n{\n    QSharedPointer<File> editedFile = getFile(fileName);\n    if (!editedFile)\n    {\n        return false;\n    }\n\n    QSharedPointer<BuildCommand> fileBuild = getBuildCommand(fileName);\n    if (fileBuild)\n    {\n        fileBuild->setReplaceDefaultFlags(QString::fromStdString(newReplaceDefaultFlags));\n    }\n    else if (!newReplaceDefaultFlags.empty())\n    {\n        QSharedPointer<BuildCommand> newFileBuild(new BuildCommand());\n        newFileBuild->setReplaceDefaultFlags(QString::fromStdString(newReplaceDefaultFlags));\n\n        editedFile->setBuildcommand(newFileBuild);\n    }\n\n    if (newReplaceDefaultFlags.empty())\n    {\n        removeEmptyBuildCommand(editedFile);\n    }\n\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: FileInterface::getBuildCommandTarget()\n//-----------------------------------------------------------------------------\nstd::string FileInterface::getBuildCommandTarget(std::string const& fileName) const\n{\n    std::string buildCommandTarget = \"\";\n\n    QSharedPointer<BuildCommand> fileBuild = getBuildCommand(fileName);\n    if (fileBuild)\n    {\n        buildCommandTarget = fileBuild->getTargetName().toStdString();\n    }\n\n    return buildCommandTarget;\n}\n\n//-----------------------------------------------------------------------------\n// Function: FileInterface::setBuildCommandTarget()\n//-----------------------------------------------------------------------------\nbool FileInterface::setBuildCommandTarget(std::string const& fileName, std::string const& newTarget)\n{\n    QSharedPointer<File> editedFile = getFile(fileName);\n    if (!editedFile)\n    {\n        return false;\n    }\n\n    QSharedPointer<BuildCommand> fileBuild = getBuildCommand(fileName);\n    if (fileBuild)\n    {\n        fileBuild->setTargetName(QString::fromStdString(newTarget));\n    }\n    else if (!newTarget.empty())\n    {\n        QSharedPointer<BuildCommand> newFileBuild(new BuildCommand());\n        newFileBuild->setTargetName(QString::fromStdString(newTarget));\n\n        editedFile->setBuildcommand(newFileBuild);\n    }\n\n    if (newTarget.empty())\n    {\n        removeEmptyBuildCommand(editedFile);\n    }\n\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: FileInterface::getItem()\n//-----------------------------------------------------------------------------\nQSharedPointer<NameGroup> FileInterface::getItem(std::string const& fileName) const\n{\n    return nullptr;\n}"
  },
  {
    "path": "KactusAPI/interfaces/component/FileSetInterface.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: FileSetInterface.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 01.09.2020\n//\n// Description:\n// Interface for editing file sets.\n//-----------------------------------------------------------------------------\n\n#include \"FileSetInterface.h\"\n\n#include <IPXACTmodels/Component/FileSet.h>\n#include <IPXACTmodels/Component/validators/FileSetValidator.h>\n\n#include <FileBuilderInterface.h>\n#include <FileInterface.h>\n\nnamespace\n{\n    std::string const FILESET_TYPE = \"fileSet\";\n};\n\n//-----------------------------------------------------------------------------\n// Function: FileSetInterface::FileSetInterface()\n//-----------------------------------------------------------------------------\nFileSetInterface::FileSetInterface(QSharedPointer<FileSetValidator> validator,\n    QSharedPointer<ExpressionParser> expressionParser, QSharedPointer<ExpressionFormatter> expressionFormatter,\n    FileInterface* fileInterface, FileBuilderInterface* fileBuilderInterface):\nParameterizableInterface(expressionParser, expressionFormatter),\nNameGroupInterface(),\nfileSets_(),\nvalidator_(validator),\nfileInterface_(fileInterface),\nfileBuilderInterface_(fileBuilderInterface)\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: FileSetInterface::setFileSets()\n//-----------------------------------------------------------------------------\nvoid FileSetInterface::setFileSets(QSharedPointer<QList<QSharedPointer<FileSet>>> newFileSets)\n{\n    fileSets_ = newFileSets;\n}\n\n//-----------------------------------------------------------------------------\n// Function: FileSetInterface::getItemIndex()\n//-----------------------------------------------------------------------------\nint FileSetInterface::getItemIndex(std::string const& itemName) const\n{\n    if (fileSets_)\n    {\n        for (int i = 0; i < fileSets_->size(); ++i)\n        {\n            if (fileSets_->at(i)->name().toStdString() == itemName)\n            {\n                return i;\n            }\n        }\n    }\n\n    return -1;\n}\n\n//-----------------------------------------------------------------------------\n// Function: FileSetInterface::getIndexedItemName()\n//-----------------------------------------------------------------------------\nstd::string FileSetInterface::getIndexedItemName(int itemIndex) const\n{\n    std::string fileSetName = \"\";\n    if (fileSets_ && (itemIndex >= 0 && itemIndex < fileSets_->size()))\n    {\n        fileSetName = fileSets_->at(itemIndex)->name().toStdString();\n    }\n\n    return fileSetName;\n}\n\n//-----------------------------------------------------------------------------\n// Function: FileSetInterface::itemCount()\n//-----------------------------------------------------------------------------\nint FileSetInterface::itemCount() const\n{\n    if (fileSets_)\n    {\n        return fileSets_->count();\n    }\n\n    return 0;\n}\n\n//-----------------------------------------------------------------------------\n// Function: FileSetInterface::getItemNames()\n//-----------------------------------------------------------------------------\nstd::vector<std::string> FileSetInterface::getItemNames() const\n{\n    std::vector<std::string> names;\n    if (fileSets_)\n    {\n        for (auto fileSet : *fileSets_)\n        {\n            names.push_back(fileSet->name().toStdString());\n        }\n    }\n\n    return names;\n}\n\n//-----------------------------------------------------------------------------\n// Function: FileSetInterface::setName()\n//-----------------------------------------------------------------------------\nbool FileSetInterface::setName(std::string const& currentName, std::string const& newName)\n{\n    QSharedPointer<FileSet> editedFileSet = getFileSet(currentName);\n    if (editedFileSet && nameHasChanged(newName, currentName))\n    {\n        QString uniqueNewName = getUniqueName(newName, FILESET_TYPE);\n\n        editedFileSet->setName(uniqueNewName);\n        return true;\n    }\n    else\n    {\n        return false;\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: FileSetInterface::validateItems()\n//-----------------------------------------------------------------------------\nbool FileSetInterface::validateItems() const\n{\n    for (auto fileSet : *fileSets_)\n    {\n        if (!validator_->validate(fileSet))\n        {\n            return false;\n        }\n    }\n\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: FileSetInterface::itemHasValidName()\n//-----------------------------------------------------------------------------\nbool FileSetInterface::itemHasValidName(std::string const& itemName) const\n{\n    QSharedPointer<FileSet> fileSet = getFileSet(itemName);\n    if (fileSet)\n    {\n        return validator_->hasValidName(fileSet->name());\n    }\n\n    return false;\n}\n\n//-----------------------------------------------------------------------------\n// Function: FileSetInterface::getGroups()\n//-----------------------------------------------------------------------------\nstd::vector<std::string> FileSetInterface::getGroups(std::string const& fileSetName) const\n{\n    std::vector<std::string> groups;\n\n    QSharedPointer<FileSet> selectedFileSet = getFileSet(fileSetName);\n    if (selectedFileSet)\n    {\n        for (auto fileSetGroup : *selectedFileSet->getGroups())\n        {\n            groups.push_back(fileSetGroup.toStdString());\n        }\n    }\n\n    return groups;\n}\n\n//-----------------------------------------------------------------------------\n// Function: FileSetInterface::setGroups()\n//-----------------------------------------------------------------------------\nbool FileSetInterface::setGroups(std::string const& fileSetName, std::vector<std::string> const& newGroups)\n{\n    QSharedPointer<FileSet> editedFileSet = getFileSet(fileSetName);\n    if (!editedFileSet)\n    {\n        return false;\n    }\n\n    editedFileSet->getGroups()->clear();\n\n    QStringList newFileSetGroups;\n    for (auto singleGroup : newGroups)\n    {\n        newFileSetGroups.append(QString::fromStdString(singleGroup));\n    }\n\n    editedFileSet->getGroups()->append(newFileSetGroups);\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: FileSetInterface::getDependencies()\n//-----------------------------------------------------------------------------\nstd::vector<std::string> FileSetInterface::getDependencies(std::string const& fileSetName) const\n{\n    std::vector<std::string> dependencies;\n\n    QSharedPointer<FileSet> selectedFileSet = getFileSet(fileSetName);\n    if (selectedFileSet)\n    {\n        for (auto fileSetDependency : *selectedFileSet->getDependencies())\n        {\n            dependencies.push_back(fileSetDependency.toStdString());\n        }\n    }\n\n    return dependencies;\n}\n\n//-----------------------------------------------------------------------------\n// Function: FileSetInterface::setDependencies()\n//-----------------------------------------------------------------------------\nbool FileSetInterface::setDependencies(std::string const& fileSetName,\n    std::vector<std::string> const& newDependencies)\n{\n    QSharedPointer<FileSet> editedFileSet = getFileSet(fileSetName);\n    if (!editedFileSet)\n    {\n        return false;\n    }\n\n    editedFileSet->getDependencies()->clear();\n\n    QStringList newFileSetDependencies;\n    for (auto singleDependency : newDependencies)\n    {\n        newFileSetDependencies.append(QString::fromStdString(singleDependency));\n    }\n\n    editedFileSet->getDependencies()->append(newFileSetDependencies);\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: FileSetInterface::addFileSet()\n//-----------------------------------------------------------------------------\nvoid FileSetInterface::addFileSet(int const& row, std::string const& newFileSetName)\n{\n    QString fileSetName = getUniqueName(newFileSetName, FILESET_TYPE);\n\n    QSharedPointer<FileSet> newFileSet(new FileSet());\n    newFileSet->setName(fileSetName);\n\n    fileSets_->insert(row, newFileSet);\n}\n\n//-----------------------------------------------------------------------------\n// Function: FileSetInterface::addFileSet()\n//-----------------------------------------------------------------------------\nvoid FileSetInterface::addFileSet(std::string const& newFileSetName /*= std::string(\"\")*/)\n{\n    addFileSet(fileSets_->size(), newFileSetName);\n}\n\n//-----------------------------------------------------------------------------\n// Function: FileSetInterface::removeFileSet()\n//-----------------------------------------------------------------------------\nbool FileSetInterface::removeFileSet(std::string const& fileName)\n{\n    QSharedPointer<FileSet> removedFileSet = getFileSet(fileName);\n    if (!removedFileSet)\n    {\n        return false;\n    }\n\n    return fileSets_->removeOne(removedFileSet);\n}\n\n//-----------------------------------------------------------------------------\n// Function: FileSetInterface::getFileSet()\n//-----------------------------------------------------------------------------\nQSharedPointer<FileSet> FileSetInterface::getFileSet(std::string const& fileSetName) const\n{\n    if (fileSets_)\n    {\n        for (auto fileSet : *fileSets_)\n        {\n            if (fileSet->name().toStdString() == fileSetName)\n            {\n                return fileSet;\n            }\n        }\n    }\n\n    return QSharedPointer<FileSet>();\n}\n\n//-----------------------------------------------------------------------------\n// Function: FileSetInterface::getFileInterface()\n//-----------------------------------------------------------------------------\nFileInterface* FileSetInterface::getFileInterface() const\n{\n    return fileInterface_;\n}\n\n//-----------------------------------------------------------------------------\n// Function: FileSetInterface::getFileBuilderInterface()\n//-----------------------------------------------------------------------------\nFileBuilderInterface* FileSetInterface::getFileBuilderInterface() const\n{\n    return fileBuilderInterface_;\n}\n\n//-----------------------------------------------------------------------------\n// Function: FileSetInterface::getAllReferencesToIdInItem()\n//-----------------------------------------------------------------------------\nint FileSetInterface::getAllReferencesToIdInItem(const std::string& itemName, std::string const& valueID) const\n{\n    int totalReferencesToParameter = 0;\n\n    QSharedPointer<FileSet> selectedFileSet = getFileSet(itemName);\n    if (selectedFileSet)\n    {\n        fileBuilderInterface_->setFileBuilders(selectedFileSet->getDefaultFileBuilders());\n        for (auto builder : *selectedFileSet->getDefaultFileBuilders())\n        {\n            totalReferencesToParameter +=\n                fileBuilderInterface_->getAllReferencesToIdInItem(builder->getFileType().type_.toStdString(), valueID);\n        }\n    }\n\n    return totalReferencesToParameter;\n}\n\n//-----------------------------------------------------------------------------\n// Function: FileSetInterface::getExpressionsInSelectedFileSets()\n//-----------------------------------------------------------------------------\nstd::vector<std::string> FileSetInterface::getExpressionsInSelectedFileSets(std::vector<std::string> fileSetNames)\nconst\n{\n    std::vector<std::string> expressionList;\n\n    for (auto name : fileSetNames)\n    {\n        QSharedPointer<FileSet> currentFileSet = getFileSet(name);\n\n        if (currentFileSet)\n        {\n            fileBuilderInterface_->setFileBuilders(currentFileSet->getDefaultFileBuilders());\n            std::vector<std::string> fileBuilderExpressions =\n                fileBuilderInterface_->getExpressionsInSelectedFileBuilders(fileBuilderInterface_->getItemNames());\n\n            for (auto expression : fileBuilderExpressions)\n            {\n                expressionList.push_back(expression);\n            }\n\n            fileInterface_->setFiles(currentFileSet->getFiles());\n            std::vector<std::string> fileExpressions =\n                fileInterface_->getExpressionsInSelectedFiles(fileInterface_->getItemNames());\n\n            for (auto expression : fileExpressions)\n            {\n                expressionList.push_back(expression);\n            }\n        }\n    }\n\n    return expressionList;\n}\n\n//-----------------------------------------------------------------------------\n// Function: FileSetInterface::getItem()\n//-----------------------------------------------------------------------------\nQSharedPointer<NameGroup> FileSetInterface::getItem(std::string const& fileSetName) const\n{\n    return getFileSet(fileSetName);\n}\n\n//-----------------------------------------------------------------------------\n// Function: FileSetInterface::fileSetExists()\n//-----------------------------------------------------------------------------\nbool FileSetInterface::fileSetExists(std::string const& fileSetName) const\n{\n\n\n    QString fileSetNameQ = QString::fromStdString(fileSetName);\n    foreach(QSharedPointer<FileSet> fileSet, *fileSets_)\n    {\n        if (fileSet->name() == fileSetNameQ)\n        {\n            return true;\n        }\n    }\n    return false;\n}\n"
  },
  {
    "path": "KactusAPI/interfaces/component/MasterPortInterface.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: MasterPortInterface.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 14.12.2020\n//\n// Description:\n// Master interface for editing component ports and port abstractions.\n//-----------------------------------------------------------------------------\n\n#include <MasterPortInterface.h>\n\n#include <IPXACTmodels/common/TransactionalTypes.h>\n\n//-----------------------------------------------------------------------------\n// Function: MasterPortInterface::MasterPortInterface()\n//-----------------------------------------------------------------------------\nMasterPortInterface::MasterPortInterface():\nNameGroupInterface()\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: MasterPortInterface::getIconPathForMissingPort()\n//-----------------------------------------------------------------------------\nstd::string MasterPortInterface::getIconPathForMissingPort() const\n{\n    return (\":icons/common/graphics/cross.png\");\n}\n\n//-----------------------------------------------------------------------------\n// Function: MasterPortInterface::getIconPathForDirection()\n//-----------------------------------------------------------------------------\nstd::string MasterPortInterface::getIconPathForDirection(DirectionTypes::Direction direction) const\n{\n    std::string directionPath(\":icons/common/graphics/cross.png\");\n    if (direction == DirectionTypes::IN)\n    {\n        directionPath = \":icons/common/graphics/input.png\";\n    }\n    else if (direction == DirectionTypes::OUT)\n    {\n        directionPath = \":icons/common/graphics/output.png\";\n    }\n    else if (direction == DirectionTypes::INOUT)\n    {\n        directionPath = \":icons/common/graphics/inout.png\";\n    }\n    else if (direction == DirectionTypes::DIRECTION_PHANTOM)\n    {\n        directionPath = \":icons/common/graphics/phantom.png\";\n    }\n\n    return directionPath;\n}\n\n//-----------------------------------------------------------------------------\n// Function: MasterPortInterface::getIconPathForInitiative()\n//-----------------------------------------------------------------------------\nstd::string MasterPortInterface::getIconPathForInitiative(QString const& initiative) const\n{\n    std::string iconPath(\":icons/common/graphics/cross.png\");\n    if (initiative.compare(TransactionalTypes::INITIATIVE_PROVIDES, Qt::CaseInsensitive) == 0)\n    {\n        iconPath = \":icons/common/graphics/provides.png\";\n    }\n    else if (initiative.compare(TransactionalTypes::INITIATIVE_REQUIRES, Qt::CaseInsensitive) == 0)\n    {\n        iconPath = \":icons/common/graphics/requires.png\";\n    }\n    else if (initiative.compare(TransactionalTypes::INITIATIVE_BOTH, Qt::CaseInsensitive) == 0)\n    {\n        iconPath = \":icons/common/graphics/requires_provides.png\";\n    }\n    else if (initiative.compare(TransactionalTypes::INITIATIVE_PHANTOM, Qt::CaseInsensitive) == 0)\n    {\n        iconPath = \":icons/common/graphics/phantom.png\";\n    }\n\n    return iconPath;\n}"
  },
  {
    "path": "KactusAPI/interfaces/component/MemoryBlockInterface.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: MemoryBlockInterface.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 31.01.2022\n//\n// Description:\n// Parent interface for editing memory blocks.\n//-----------------------------------------------------------------------------\n\n#include <MemoryBlockInterface.h>\n\n#include <IPXACTmodels/Component/Component.h>\n#include <IPXACTmodels/Component/MemoryBlockBase.h>\n#include <IPXACTmodels/Component/AddressBlock.h>\n#include <IPXACTmodels/Component/SubSpaceMap.h>\n#include <IPXACTmodels/Component/AddressSpace.h>\n#include <IPXACTmodels/Component/Segment.h>\n#include <IPXACTmodels/Component/validators/MemoryBlockValidator.h>\n\n#include <ParametersInterface.h>\n#include <BusInterfaceInterface.h>\n\n#include <QMimeData>\n#include <QApplication>\n#include <QClipboard>\n\n//-----------------------------------------------------------------------------\n// Function: MemoryBlockInterface::MemoryBlockInterface()\n//-----------------------------------------------------------------------------\nMemoryBlockInterface::MemoryBlockInterface(QSharedPointer<ExpressionParser> expressionParser,\n    QSharedPointer<ExpressionFormatter> expressionFormatter, BusInterfaceInterface* busInterface,\n    ParametersInterface* parameterInterface):\nParameterizableInterface(expressionParser, expressionFormatter),\nNameGroupInterface(),\nbusInterfaceInterface_(busInterface),\nparameterInterface_(parameterInterface)\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: MemoryBlockInterface::setAddressBlocks()\n//-----------------------------------------------------------------------------\nvoid MemoryBlockInterface::setMemoryBlocks(QSharedPointer<QList<QSharedPointer<MemoryBlockBase>>> newMemoryBlocks)\n{\n    blockData_ = newMemoryBlocks;\n}\n\n//-----------------------------------------------------------------------------\n// Function: MemoryBlockInterface::setupAddressSpaces()\n//-----------------------------------------------------------------------------\nvoid MemoryBlockInterface::setupSubInterfaces(QSharedPointer<Component> newComponent)\n{\n    availableAddressSpaces_ = newComponent->getAddressSpaces();\n    busInterfaceInterface_->setBusInterfaces(newComponent);\n}\n\n//-----------------------------------------------------------------------------\n// Function: MemoryBlockInterface::getBusInterface()\n//-----------------------------------------------------------------------------\nBusInterfaceInterface* MemoryBlockInterface::getBusInterface() const\n{\n    return busInterfaceInterface_;\n}\n\n//-----------------------------------------------------------------------------\n// Function: MemoryBlockInterface::getBlocksData()\n//-----------------------------------------------------------------------------\nQSharedPointer<QList<QSharedPointer<MemoryBlockBase> > > MemoryBlockInterface::getBlocksData()\n{\n    return blockData_;\n}\n\n//-----------------------------------------------------------------------------\n// Function: AddressBlockInterface::MemoryBlockBase()\n//-----------------------------------------------------------------------------\nQSharedPointer<MemoryBlockBase> MemoryBlockInterface::getBlock(std::string const& itemName) const\n{\n    for (auto currentBlock : *blockData_)\n    {\n        if (currentBlock->name().toStdString() == itemName)\n        {\n            return currentBlock;\n        }\n    }\n\n    return QSharedPointer<MemoryBlockBase>();\n}\n\n//-----------------------------------------------------------------------------\n// Function: MemoryBlockInterface::getAddressUnitBits()\n//-----------------------------------------------------------------------------\nQString MemoryBlockInterface::getAddressUnitBits() const\n{\n    return addressUnitBits_;\n}\n\n//-----------------------------------------------------------------------------\n// Function: MemoryBlockInterface::getItemIndex()\n//-----------------------------------------------------------------------------\nint MemoryBlockInterface::getItemIndex(std::string const& itemName) const\n{\n    for (int i = 0; i < blockData_->size(); ++i)\n    {\n        if (blockData_->at(i)->name().toStdString() == itemName)\n        {\n            return i;\n        }\n    }\n\n    return -1;\n}\n\n//-----------------------------------------------------------------------------\n// Function: MemoryBlockInterface::getIndexedItemName()\n//-----------------------------------------------------------------------------\nstd::string MemoryBlockInterface::getIndexedItemName(int itemIndex) const\n{\n    std::string blockName = \"\";\n    if (itemIndex >= 0 && itemIndex < blockData_->size())\n    {\n        blockName = blockData_->at(itemIndex)->name().toStdString();\n    }\n\n    return blockName;\n}\n\n//-----------------------------------------------------------------------------\n// Function: MemoryBlockInterface::itemCount()\n//-----------------------------------------------------------------------------\nint MemoryBlockInterface::itemCount() const\n{\n    return blockData_->count();\n}\n\n//-----------------------------------------------------------------------------\n// Function: MemoryBlockInterface::getItemNames()\n//-----------------------------------------------------------------------------\nstd::vector<std::string> MemoryBlockInterface::getItemNames() const\n{\n    std::vector<std::string> names;\n    for (auto block : *blockData_)\n    {\n        names.push_back(block->name().toStdString());\n    }\n\n    return names;\n}\n\n//-----------------------------------------------------------------------------\n// Function: MemoryBlockInterface::setName()\n//-----------------------------------------------------------------------------\nbool MemoryBlockInterface::setName(std::string const& currentName, std::string const& newName)\n{\n    QSharedPointer<MemoryBlockBase> editedItem = getBlock(currentName);\n    if (editedItem && nameHasChanged(newName, currentName))\n    {\n        QString uniqueNewName = getUniqueName(newName, getDefaultName());\n        editedItem->setName(uniqueNewName);\n\n        return true;\n    }\n    else\n    {\n        return false;\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: MemoryBlockInterface::getBaseAddressValue()\n//-----------------------------------------------------------------------------\nstd::string MemoryBlockInterface::getBaseAddressValue(std::string const& blockName, int const& baseNumber) const\n{\n    QSharedPointer<MemoryBlockBase> selectedBlock = getBlock(blockName);\n    if (selectedBlock)\n    {\n        return parseExpressionToBaseNumber(selectedBlock->getBaseAddress(), baseNumber).toStdString();\n    }\n\n    return std::string();\n}\n\n//-----------------------------------------------------------------------------\n// Function: MemoryBlockInterface::getBaseAddressFormattedExpression()\n//-----------------------------------------------------------------------------\nstd::string MemoryBlockInterface::getBaseAddressFormattedExpression(std::string const& blockName) const\n{\n    QSharedPointer<MemoryBlockBase> selectedBlock = getBlock(blockName);\n    if (selectedBlock)\n    {\n        return formattedValueFor(selectedBlock->getBaseAddress()).toStdString();\n    }\n\n    return std::string();\n}\n\n//-----------------------------------------------------------------------------\n// Function: MemoryBlockInterface::getBaseAddressExpression()\n//-----------------------------------------------------------------------------\nstd::string MemoryBlockInterface::getBaseAddressExpression(std::string const& blockName) const\n{\n    QSharedPointer<MemoryBlockBase> selectedBlock = getBlock(blockName);\n    if (selectedBlock)\n    {\n        return selectedBlock->getBaseAddress().toStdString();\n    }\n\n    return std::string();\n}\n\n//-----------------------------------------------------------------------------\n// Function: MemoryBlockInterface::setBaseAddress()\n//-----------------------------------------------------------------------------\nbool MemoryBlockInterface::setBaseAddress(std::string const& blockName, std::string const& newBaseAdress) const\n{\n    QSharedPointer<MemoryBlockBase> selectedBlock = getBlock(blockName);\n    if (!selectedBlock)\n    {\n        return false;\n    }\n    \n    selectedBlock->setBaseAddress(QString::fromStdString(newBaseAdress));\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: MemoryBlockInterface::getIsPresentValue()\n//-----------------------------------------------------------------------------\nstd::string MemoryBlockInterface::getIsPresentValue(std::string const& blockName, int const& baseNumber) const\n{\n    QSharedPointer<MemoryBlockBase> selectedBlock = getBlock(blockName);\n    if (selectedBlock)\n    {\n        return parseExpressionToBaseNumber(selectedBlock->getIsPresent(), baseNumber).toStdString();\n    }\n\n    return std::string();\n}\n\n//-----------------------------------------------------------------------------\n// Function: AddressBlockInterface::getIsPresentFormattedExpression()\n//-----------------------------------------------------------------------------\nstd::string MemoryBlockInterface::getIsPresentFormattedExpression(std::string const& blockName) const\n{\n    QSharedPointer<MemoryBlockBase> selectedBlock = getBlock(blockName);\n    if (selectedBlock)\n    {\n        return formattedValueFor(selectedBlock->getIsPresent()).toStdString();\n    }\n\n    return std::string();\n}\n\n//-----------------------------------------------------------------------------\n// Function: MemoryBlockInterface::getIsPresentExpression()\n//-----------------------------------------------------------------------------\nstd::string MemoryBlockInterface::getIsPresentExpression(std::string const& blockName) const\n{\n    QSharedPointer<MemoryBlockBase> selectedBlock = getBlock(blockName);\n    if (selectedBlock)\n    {\n        return selectedBlock->getIsPresent().toStdString();\n    }\n\n    return std::string();\n}\n\n//-----------------------------------------------------------------------------\n// Function: MemoryBlockInterface::setIsPresent()\n//-----------------------------------------------------------------------------\nbool MemoryBlockInterface::setIsPresent(std::string const& blockName, std::string const& newIsPresent) const\n{\n    QSharedPointer<MemoryBlockBase> selectedBlock = getBlock(blockName);\n    if (!selectedBlock)\n    {\n        return false;\n    }\n\n    selectedBlock->setIsPresent(QString::fromStdString(newIsPresent));\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: MemoryBlockInterface::getRangeValue()\n//-----------------------------------------------------------------------------\nstd::string MemoryBlockInterface::getRangeValue(std::string const& blockName, int const& baseNumber) const\n{\n    std::string rangeValue = \"0\";\n\n    QSharedPointer<MemoryBlockBase> selectedBlock = getBlock(blockName);\n    if (selectedBlock)\n    {\n        QSharedPointer<AddressBlock> addressBlock = selectedBlock.dynamicCast<AddressBlock>();\n        QSharedPointer<SubSpaceMap> subspace = selectedBlock.dynamicCast<SubSpaceMap>();\n        if (addressBlock)\n        {\n            rangeValue = parseExpressionToBaseNumber(addressBlock->getRange(), baseNumber).toStdString();\n        }\n        else if (subspace)\n        {\n            quint64 memoryRange = 1;\n\n            QSharedPointer<AddressSpace> referencedSpace =\n                getReferencedAddressSpace(subspace->getInitiatorReference());\n            if (referencedSpace)\n            {\n                QSharedPointer<Segment> referencedSegment =\n                    getReferencedSegment(referencedSpace, subspace->getSegmentReference());\n\n                if (referencedSegment)\n                {\n                    memoryRange = parseExpressionToDecimal(referencedSegment->getRange()).toULongLong();\n                }\n                else\n                {\n                    memoryRange = parseExpressionToDecimal(referencedSpace->getRange()).toULongLong();\n                }\n\n            }\n\n            QString rangeQ = QString::number(memoryRange);\n            rangeValue = parseExpressionToBaseNumber(rangeQ, baseNumber).toStdString();\n        }\n    }\n\n    return rangeValue;\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: MemoryBlockInterface::getReferencedAddressSpace()\n//-----------------------------------------------------------------------------\nQSharedPointer<AddressSpace> MemoryBlockInterface::getReferencedAddressSpace(QString const& masterBusReference)\nconst\n{\n    QString spaceReference =\n        QString::fromStdString(busInterfaceInterface_->getAddressSpaceReference(masterBusReference.toStdString()));\n    if (!spaceReference.isEmpty())\n    {\n        for (auto space : *availableAddressSpaces_)\n        {\n            if (space->name() == spaceReference)\n            {\n                return space;\n            }\n        }\n    }\n\n    return QSharedPointer<AddressSpace>();\n}\n\n//-----------------------------------------------------------------------------\n// Function: MemoryBlockInterface::getReferencedSegment()\n//-----------------------------------------------------------------------------\nQSharedPointer<Segment> MemoryBlockInterface::getReferencedSegment(QSharedPointer<AddressSpace> referencedSpace,\n    QString const& segmentReference) const\n{\n    if (!segmentReference.isEmpty())\n    {\n        for (auto segment : *referencedSpace->getSegments())\n        {\n            if (segment->name() == segmentReference)\n            {\n                return segment;\n            }\n        }\n    }\n\n    return QSharedPointer<Segment>();\n}\n\n//-----------------------------------------------------------------------------\n// Function: MemoryBlockInterface::getAllReferencesToIdInItem()\n//-----------------------------------------------------------------------------\nint MemoryBlockInterface::getAllReferencesToIdInItem(const std::string& itemName, std::string const&  valueID) const\n{\n    QSharedPointer<MemoryBlockBase> selectedItem = getBlock(itemName);\n\n    QString idString = QString::fromStdString(valueID);\n\n    int referencesInBaseAddress = selectedItem->getBaseAddress().count(idString);\n    int referencesInIsPresent = selectedItem->getIsPresent().count(idString);\n\n    int totalReferencesToParameter = referencesInBaseAddress + referencesInIsPresent;\n\n    return totalReferencesToParameter;\n}\n\n//-----------------------------------------------------------------------------\n// Function: MemoryBlockInterface::setAddressUnitBits()\n//-----------------------------------------------------------------------------\nvoid MemoryBlockInterface::setAddressUnitBits(std::string const& newAddressUnitbits)\n{\n    addressUnitBits_ = QString::fromStdString(newAddressUnitbits);\n}\n\n//-----------------------------------------------------------------------------\n// Function: MemoryBlockInterface::getNewBlockBaseAddress()\n//-----------------------------------------------------------------------------\nQString MemoryBlockInterface::getNewBlockBaseAddress() const\n{\n    quint64 lastBaseAddress = 0;\n    quint64 lastRange = 0;\n\n    for (int itemIndex = 0; itemIndex < itemCount(); ++itemIndex)\n    {\n        std::string itemName = getIndexedItemName(itemIndex);\n        QString calculatedExpression = QString::fromStdString(getBaseAddressValue(itemName, 10));\n        quint64 blockBaseAddress = calculatedExpression.toULongLong();\n\n        if (blockBaseAddress > lastBaseAddress || (itemIndex == itemCount() - 1 && lastBaseAddress == 0))\n        {\n            QSharedPointer<AddressBlock> addressBlock = blockData_->at(itemIndex).dynamicCast<AddressBlock>();\n            QSharedPointer<SubSpaceMap> subspaceMap = blockData_->at(itemIndex).dynamicCast<SubSpaceMap>();\n            if (addressBlock || subspaceMap)\n            {\n                lastBaseAddress = blockBaseAddress;\n                lastRange = QString::fromStdString(getRangeValue(itemName, 10)).toULongLong();\n            }\n        }\n    }\n\n    // convert the address to hexadecimal form\n    QString newBase = QString::number(lastBaseAddress + lastRange, 16);\n    newBase = newBase.toUpper();\n    newBase.prepend(\"'h\");\n\n    return newBase;\n}\n\n//-----------------------------------------------------------------------------\n// Function: MemoryBlockInterface::addBlock()\n//-----------------------------------------------------------------------------\nvoid MemoryBlockInterface::addBlock(std::string const& newBlockName /*= std::string(\"\")*/)\n{\n    addBlock(blockData_->size(), newBlockName);\n}\n\n//-----------------------------------------------------------------------------\n// Function: MemoryBlockInterface::removeBlock()\n//-----------------------------------------------------------------------------\nbool MemoryBlockInterface::removeBlock(std::string const& blockName)\n{\n    QSharedPointer<MemoryBlockBase> removedItem = getBlock(blockName);\n    if (!removedItem)\n    {\n        return false;\n    }\n\n    return blockData_->removeOne(removedItem);\n}\n\n//-----------------------------------------------------------------------------\n// Function: MemoryBlockInterface::copyRows()\n//-----------------------------------------------------------------------------\nvoid MemoryBlockInterface::copyRows(std::vector<int> selectedRows)\n{\n    QList<QSharedPointer<MemoryBlockBase> > copiedBlocks = getCopiedBlocks(selectedRows);\n\n    QVariant memoryBlockVariant;\n    memoryBlockVariant.setValue(copiedBlocks);\n\n    QMimeData* newMimeData = new QMimeData();\n    newMimeData->setData(getMimeType(), QByteArray());\n    newMimeData->setImageData(memoryBlockVariant);\n\n    QApplication::clipboard()->setMimeData(newMimeData);\n}\n\n//-----------------------------------------------------------------------------\n// Function: MemoryBlockInterface::pasteRows()\n//-----------------------------------------------------------------------------\nstd::vector<std::string> MemoryBlockInterface::pasteRows()\n{\n    std::vector<std::string> pastedItemNames;\n\n    const QMimeData* pasteData = QApplication::clipboard()->mimeData();\n\n    if (pasteData->hasImage())\n    {\n        QVariant pasteVariant = pasteData->imageData();\n        if (pasteVariant.canConvert<QList<QSharedPointer<MemoryBlockBase> > >())\n        {\n            QList<QSharedPointer<MemoryBlockBase> > copiedItemList =\n                pasteVariant.value<QList<QSharedPointer<MemoryBlockBase>>>();\n\n            for (auto const& copiedItem : copiedItemList)\n            {\n                QSharedPointer<MemoryBlockBase> newBlock = createCopyBlock(copiedItem);\n                if (newBlock)\n                {\n                    blockData_->append(newBlock);\n                    pastedItemNames.push_back(newBlock->name().toStdString());\n                }\n            }\n        }\n    }\n\n    return pastedItemNames;\n}\n\n//-----------------------------------------------------------------------------\n// Function: MemoryBlockInterface::getPasteRowCount()\n//-----------------------------------------------------------------------------\nint MemoryBlockInterface::getPasteRowCount() const\n{\n    const QMimeData* pasteData = QApplication::clipboard()->mimeData();\n    if (pasteData->hasImage())\n    {\n        QVariant pasteVariant = pasteData->imageData();\n        if (pasteVariant.canConvert<QList<QSharedPointer<MemoryBlockBase> > >())\n        {\n            QList<QSharedPointer<MemoryBlockBase> > newBlocks =\n                pasteVariant.value<QList<QSharedPointer<MemoryBlockBase> > >();\n\n            return countItems(newBlocks);\n        }\n    }\n    \n    return 0;\n}\n\n//-----------------------------------------------------------------------------\n// Function: MemoryBlockInterface::itemHasValidName()\n//-----------------------------------------------------------------------------\nbool MemoryBlockInterface::itemHasValidName(std::string const& itemName) const\n{\n    QSharedPointer<MemoryBlockBase> block = getBlock(itemName);\n    if (block)\n    {\n        return getValidator()->hasValidName(block);\n    }\n\n    return false;\n}\n\n//-----------------------------------------------------------------------------\n// Function: MemoryBlockInterface::hasValidBaseAddress()\n//-----------------------------------------------------------------------------\nbool MemoryBlockInterface::hasValidBaseAddress(std::string const& itemName) const\n{\n    QSharedPointer<MemoryBlockBase> block = getBlock(itemName);\n    if (block)\n    {\n        return getValidator()->hasValidBaseAddress(block);\n    }\n\n    return false;\n}\n\n//-----------------------------------------------------------------------------\n// Function: MemoryBlockInterface::hasValidIsPresent()\n//-----------------------------------------------------------------------------\nbool MemoryBlockInterface::hasValidIsPresent(std::string const& itemName) const\n{\n    QSharedPointer<MemoryBlockBase> block = getBlock(itemName);\n    if (block)\n    {\n        return getValidator()->hasValidIsPresent(block);\n    }\n\n    return false;\n}\n"
  },
  {
    "path": "KactusAPI/interfaces/component/MemoryMapInterface.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: MemoryMapInterface.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 15.05.2020\n//\n// Description:\n// Interface for editing memory maps and remaps.\n//-----------------------------------------------------------------------------\n\n#include <MemoryMapInterface.h>\n\n#include <MemoryMapExpressionsGatherer.h>\n#include <MemoryRemapExpressionGatherer.h>\n\n#include <IPXACTmodels/Component/Component.h>\n#include <IPXACTmodels/Component/MemoryMap.h>\n#include <IPXACTmodels/Component/MemoryRemap.h>\n#include <IPXACTmodels/Component/validators/MemoryMapValidator.h>\n#include <IPXACTmodels/Component/ModeReference.h>\n\n#include <QMimeData>\n#include <QApplication>\n#include <QClipboard>\n\nnamespace\n{\n    std::string const MEMORYMAP_TYPE = \"memoryMap\";\n    std::string const MEMORYREMAP_TYPE = \"memoryRemap\";\n\n    std::string const DEFAULT_REMAP_STATE = \"Default\";\n    std::string const NO_REMAP_STATE = \"No remap state selected.\";\n\n    std::string const NO_INTERFACE_BINDING = \"No binding\";\n};\n\n//-----------------------------------------------------------------------------\n// Function: MemoryMapInterface::MemoryMapInterface()\n//-----------------------------------------------------------------------------\nMemoryMapInterface::MemoryMapInterface(QSharedPointer<MemoryMapValidator> mapValidator,\n    QSharedPointer<ExpressionParser> expressionParser, QSharedPointer<ExpressionFormatter> expressionFormatter):\nParameterizableInterface(expressionParser, expressionFormatter),\ncomponent_(),\nmapData_(),\nvalidator_(mapValidator),\naddressBlockInterface_(0),\nsubspaceInterface_(0)\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: MemoryMapInterface::setAddressBlockInterface()\n//-----------------------------------------------------------------------------\nvoid MemoryMapInterface::setAddressBlockInterface(AddressBlockInterface* blockInterface)\n{\n    addressBlockInterface_ = blockInterface;\n}\n\n//-----------------------------------------------------------------------------\n// Function: MemoryMapInterface::setSubspaceMapInterface()\n//-----------------------------------------------------------------------------\nvoid MemoryMapInterface::setSubspaceMapInterface(SubspaceMapInterface* submapInterface)\n{\n    subspaceInterface_ = submapInterface;\n}\n\n//-----------------------------------------------------------------------------\n// Function: MemoryMapInterface::setMemoryMaps()\n//-----------------------------------------------------------------------------\nvoid MemoryMapInterface::setMemoryMaps(QSharedPointer<Component> component)\n{\n    component_ = component;\n    mapData_ = component->getMemoryMaps();\n}\n\n//-----------------------------------------------------------------------------\n// Function: MemoryMapInterface::getMemoryMap()\n//-----------------------------------------------------------------------------\nQSharedPointer<MemoryMap> MemoryMapInterface::getMemoryMap(std::string const& itemName) const\n{\n    QString itemNameQ = QString::fromStdString(itemName);\n\n    for (auto currentMap : *mapData_)\n    {\n        if (currentMap->name() == itemNameQ)\n        {\n            return currentMap;\n        }\n    }\n\n    return QSharedPointer<MemoryMap>();\n}\n\n//-----------------------------------------------------------------------------\n// Function: MemoryMapInterface::getMemoryRemap()\n//-----------------------------------------------------------------------------\nQSharedPointer<MemoryRemap> MemoryMapInterface::getMemoryRemap(std::string const& mapName,\n    std::string const& itemName) const\n{\n    QSharedPointer<MemoryMap> containingMap = getMemoryMap(mapName);\n    if (!containingMap)\n    {\n        return QSharedPointer<MemoryRemap>();\n    }\n\n    for (auto remap : *containingMap->getMemoryRemaps())\n    {\n        if (remap->name().toStdString() == itemName)\n        {\n            return remap;\n        }\n    }\n\n    return QSharedPointer<MemoryRemap>();\n}\n\n//-----------------------------------------------------------------------------\n// Function: MemoryMapInterface::getItemIndex()\n//-----------------------------------------------------------------------------\nint MemoryMapInterface::getItemIndex(std::string const& itemName) const\n{\n    for (int i = 0; i < mapData_->size(); ++i)\n    {\n        if (mapData_->at(i)->name().toStdString() == itemName)\n        {\n            return i;\n        }\n    }\n\n    return -1;\n}\n\n//-----------------------------------------------------------------------------\n// Function: MemoryMapInterface::getMemoryRemapIndex()\n//-----------------------------------------------------------------------------\nint MemoryMapInterface::getMemoryRemapIndex(std::string const& mapName, std::string const& remapName) const\n{\n    QSharedPointer<MemoryMap> parentMap = getMemoryMap(mapName);\n    if (parentMap)\n    {\n        QSharedPointer<QList<QSharedPointer<MemoryRemap> > > remapList = parentMap->getMemoryRemaps();\n        for (int i = 0; i < remapList->size(); ++i)\n        {\n            if (remapList->at(i)->name().toStdString() == remapName)\n            {\n                return i;\n            }\n        }\n    }\n\n    return -1;\n}\n\n//-----------------------------------------------------------------------------\n// Function: MemoryMapInterface::getIndexedItemName()\n//-----------------------------------------------------------------------------\nstd::string MemoryMapInterface::getIndexedItemName(int itemIndex) const\n{\n    std::string blockName = \"\";\n    if (itemIndex >= 0 && itemIndex < mapData_->size())\n    {\n        blockName = mapData_->at(itemIndex)->name().toStdString();\n    }\n\n    return blockName;\n}\n\n//-----------------------------------------------------------------------------\n// Function: MemoryMapInterface::getIndexedRemapName()\n//-----------------------------------------------------------------------------\nstd::string MemoryMapInterface::getIndexedRemapName(std::string mapName, int const& itemIndex) const\n{\n    std::string remapName = \"\";\n\n    QSharedPointer<MemoryMap> parentMap = getMemoryMap(mapName);\n    if (parentMap)\n    {\n        QSharedPointer<QList<QSharedPointer<MemoryRemap> > > remapList = parentMap->getMemoryRemaps();\n        if (itemIndex >= 0 && itemIndex < remapList->size())\n        {\n            remapName = remapList->at(itemIndex)->name().toStdString();\n        }\n    }\n\n    return remapName;\n}\n\n//-----------------------------------------------------------------------------\n// Function: MemoryMapInterface::itemCount()\n//-----------------------------------------------------------------------------\nint MemoryMapInterface::itemCount() const\n{\n    return mapData_->count();\n}\n\n//-----------------------------------------------------------------------------\n// Function: MemoryMapInterface::remapCount()\n//-----------------------------------------------------------------------------\nint MemoryMapInterface::remapCount(std::string const& mapName) const\n{\n    std::string remapName = \"\";\n\n    QSharedPointer<MemoryMap> parentMap = getMemoryMap(mapName);\n    if (parentMap)\n    {\n        return parentMap->getMemoryRemaps()->count();\n    }\n\n    return -1;\n}\n\n//-----------------------------------------------------------------------------\n// Function: MemoryMapInterface::getItemNames()\n//-----------------------------------------------------------------------------\nstd::vector<std::string> MemoryMapInterface::getItemNames() const\n{\n    std::vector<std::string> names;\n    for (auto map : *mapData_)\n    {\n        names.push_back(map->name().toStdString());\n    }\n\n    return names;\n}\n\n//-----------------------------------------------------------------------------\n// Function: MemoryMapInterface::getRemapNames()\n//-----------------------------------------------------------------------------\nstd::vector<std::string> MemoryMapInterface::getRemapNames(std::string const& mapName) const\n{\n    std::vector<std::string> names;\n    QSharedPointer<MemoryMap> containingMap = getMemoryMap(mapName);\n    if (containingMap)\n    {\n        for (auto remap : *containingMap->getMemoryRemaps())\n        {\n            names.push_back(remap->name().toStdString());\n        }\n    }\n\n    return names;\n}\n\n//-----------------------------------------------------------------------------\n// Function: MemoryMapInterface::setName()\n//-----------------------------------------------------------------------------\nbool MemoryMapInterface::setName(std::string const& currentName, std::string const& newName)\n{\n    QSharedPointer<MemoryMap> editedItem = getMemoryMap(currentName);\n    if (editedItem && nameHasChanged(newName, currentName))\n    {\n        QString uniqueNewName = getUniqueName(newName, MEMORYMAP_TYPE);\n\n        editedItem->setName(uniqueNewName);\n        return true;\n    }\n    else\n    {\n        return false;\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: MemoryMapInterface::setRemapName()\n//-----------------------------------------------------------------------------\nbool MemoryMapInterface::setRemapName(std::string const& mapName, std::string const& currentName,\n    std::string const& newName)\n{\n    QSharedPointer<MemoryRemap> editedItem = getMemoryRemap(mapName, currentName);\n    if (editedItem && nameHasChanged(newName, currentName))\n    {\n        QString uniqueNewName = getUniqueRemapName(mapName, newName, MEMORYREMAP_TYPE);\n\n        editedItem->setName(uniqueNewName);\n        return true;\n    }\n    else\n    {\n        return false;\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: MemoryMapInterface::setRemapDescription()\n//-----------------------------------------------------------------------------\nstd::string MemoryMapInterface::getRemapDescription(std::string const& mapName, std::string const& remapName) const\n{\n    QSharedPointer<MemoryRemap> editedItem = getMemoryRemap(mapName, remapName);\n    if (editedItem)\n    {\n        return editedItem->description().toStdString();\n    }\n\n    return std::string();\n}\n\n//-----------------------------------------------------------------------------\n// Function: MemoryMapInterface::setRemapDescription()\n//-----------------------------------------------------------------------------\nbool MemoryMapInterface::setRemapDescription(std::string const& mapName, std::string const& itemName,\n    std::string const& newDescription)\n{\n    QSharedPointer<MemoryRemap> editedItem = getMemoryRemap(mapName, itemName);\n    if (!editedItem)\n    {\n        return false;\n    }\n\n    editedItem->setDescription(QString::fromStdString(newDescription));\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: MemoryMapInterface::getIsPresentValue()\n//-----------------------------------------------------------------------------\nstd::string MemoryMapInterface::getIsPresentValue(std::string const& mapName, std::string const& remapName,\n    int const& baseNumber) const\n{\n    QSharedPointer<MemoryMapBase> baseMap;\n    if (remapName.empty())\n    {\n        baseMap = getMemoryMap(mapName);\n    }\n    else\n    {\n        baseMap = getMemoryRemap(mapName, remapName);\n    }\n\n    if (baseMap)\n    {\n        return parseExpressionToBaseNumber(baseMap->getIsPresent(), baseNumber).toStdString();\n    }\n\n    return std::string();\n}\n\n//-----------------------------------------------------------------------------\n// Function: MemoryMapInterface::getIsPresentFormattedExpression()\n//-----------------------------------------------------------------------------\nstd::string MemoryMapInterface::getIsPresentFormattedExpression(std::string const& mapName,\n    std::string const& remapName) const\n{\n    QSharedPointer<MemoryMapBase> baseMap;\n    if (remapName.empty())\n    {\n        baseMap = getMemoryMap(mapName);\n    }\n    else\n    {\n        baseMap = getMemoryRemap(mapName, remapName);\n    }\n\n    if (baseMap)\n    {\n        return formattedValueFor(baseMap->getIsPresent()).toStdString();\n    }\n\n    return std::string();\n}\n\n//-----------------------------------------------------------------------------\n// Function: MemoryMapInterface::getIsPresentExpression()\n//-----------------------------------------------------------------------------\nstd::string MemoryMapInterface::getIsPresentExpression(std::string const& mapName, std::string const& remapName)\n    const\n{\n    QSharedPointer<MemoryMapBase> baseMap;\n    if (remapName.empty())\n    {\n        baseMap = getMemoryMap(mapName);\n    }\n    else\n    {\n        baseMap = getMemoryRemap(mapName, remapName);\n    }\n\n    if (baseMap)\n    {\n        return baseMap->getIsPresent().toStdString();\n    }\n\n    return std::string();\n}\n\n//-----------------------------------------------------------------------------\n// Function: MemoryMapInterface::setIsPresent()\n//-----------------------------------------------------------------------------\nbool MemoryMapInterface::setIsPresent(std::string const& mapName, std::string const& newIsPresent,\n    std::string const& remapName)\n{\n    QSharedPointer<MemoryMapBase> baseMap;\n    if (remapName.empty())\n    {\n        baseMap = getMemoryMap(mapName);\n    }\n    else\n    {\n        baseMap = getMemoryRemap(mapName, remapName);\n    }\n\n    if (!baseMap)\n    {\n        return false;\n    }\n    \n    baseMap->setIsPresent(QString::fromStdString(newIsPresent));\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: MemoryMapInterface::getRemapState()\n//-----------------------------------------------------------------------------\nstd::string MemoryMapInterface::getRemapState(std::string const& mapName, std::string const& remapName) const\n{\n    if (remapName.empty())\n    {\n        return DEFAULT_REMAP_STATE;\n    }\n\n    QSharedPointer<MemoryRemap> selectedItem = getMemoryRemap(mapName, remapName);\n    if (!selectedItem->getRemapState().isEmpty())\n    {\n        return selectedItem->getRemapState().toStdString();\n    }\n    else\n    {\n        return NO_REMAP_STATE;\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: MemoryMapInterface::setRemapState()\n//-----------------------------------------------------------------------------\nbool MemoryMapInterface::setRemapState(std::string const& mapName, std::string const& remapName,\n    std::string const& newRemapState)\n{\n    QSharedPointer<MemoryRemap> selectedItem = getMemoryRemap(mapName, remapName);\n    if (!selectedItem)\n    {\n        return false;\n    }\n\n    selectedItem->setRemapState(QString::fromStdString(newRemapState));\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: MemoryMapInterface::getAddressUnitBits()\n//-----------------------------------------------------------------------------\nstd::string MemoryMapInterface::getAddressUnitBitsExpression(std::string const& mapName) const\n{\n    QSharedPointer<MemoryMap> map = getMemoryMap(mapName);\n    if (map)\n    {\n        return map->getAddressUnitBits(false).toStdString();\n    }\n\n    return \"\";\n}\n\n//-----------------------------------------------------------------------------\n// Function: MemoryMapInterface::getAddressUnitBitsValue()\n//-----------------------------------------------------------------------------\nstd::string MemoryMapInterface::getAddressUnitBitsValue(std::string const& mapName, int const& baseNumber) const\n{\n    if (auto map = getMemoryMap(mapName))\n    {\n        return parseExpressionToBaseNumber(map->getAddressUnitBits(false), baseNumber).toStdString();\n    }\n\n    return std::string();\n}\n\n//-----------------------------------------------------------------------------\n// Function: MemoryMapInterface::getAddressUnitBitsFormattedExpression()\n//-----------------------------------------------------------------------------\nstd::string MemoryMapInterface::getAddressUnitBitsFormattedExpression(std::string const& mapName) const\n{\n    if (auto map = getMemoryMap(mapName))\n    {\n        return formattedValueFor(map->getAddressUnitBits(false)).toStdString();\n    }\n\n    return std::string();\n}\n\n//-----------------------------------------------------------------------------\n// Function: MemoryMapInterface::setAddressUnitBits()\n//-----------------------------------------------------------------------------\nbool MemoryMapInterface::setAddressUnitBits(std::string const& mapName, std::string const& newAddressUnitBits)\nconst\n{\n    QSharedPointer<MemoryMap> map = getMemoryMap(mapName);\n    if (!map)\n    {\n        return false;\n    }\n\n    map->setAddressUnitBits(QString::fromStdString(newAddressUnitBits));\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: MemoryMapInterface::getInterfaceBinding()\n//-----------------------------------------------------------------------------\nstd::string MemoryMapInterface::getInterfaceBinding(std::string const& mapName) const\n{\n    QSharedPointer<MemoryMap> map = getMemoryMap(mapName);\n    if (!map)\n    {\n        return \"\";\n    }\n\n    QStringList interfaceNames = component_->getTargetInterfaces(map->name());\n    if (interfaceNames.isEmpty())\n    {\n        return NO_INTERFACE_BINDING;\n    }\n    else\n    {\n        return interfaceNames.join(\", \").toStdString();\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: MemoryMapInterface::getAssociatedSlaveInterfaces()\n//-----------------------------------------------------------------------------\nstd::vector<std::string> MemoryMapInterface::getAssociatedSlaveInterfaces(std::string const& mapName) const\n{\n    std::vector<std::string> associatedSlaves;\n\n    for (auto const& slave : component_->getTargetInterfaces(QString::fromStdString(mapName)))\n    {\n        associatedSlaves.push_back(slave.toStdString());\n    }\n\n    return associatedSlaves;\n}\n\n//-----------------------------------------------------------------------------\n// Function: MemoryMapInterface::getAllReferencesToIdInItem()\n//-----------------------------------------------------------------------------\nint MemoryMapInterface::getAllReferencesToIdInItem(const std::string& itemName, std::string const&  valueID) const\n{\n    QSharedPointer<MemoryMap> selectedItem = getMemoryMap(itemName);\n\n    QString idString = QString::fromStdString(valueID);\n\n    int referencesInIsPresent = selectedItem->getIsPresent().count(idString);\n    int totalReferencesToParameter = referencesInIsPresent;\n\n    return totalReferencesToParameter;\n}\n\n//-----------------------------------------------------------------------------\n// Function: MemoryMapInterface::getReferencedParameters()\n//-----------------------------------------------------------------------------\nstd::vector<std::string> MemoryMapInterface::getMapExpressions(std::string const& mapName,\n    std::string const& remapName) const\n{\n    QStringList mapExpressions;\n\n    if (remapName.empty())\n    {\n        QSharedPointer<MemoryMap> selectedMap = getMemoryMap(mapName);\n        MemoryMapExpressionGatherer* expressionGatherer = new MemoryMapExpressionGatherer();\n        mapExpressions = expressionGatherer->getExpressions(selectedMap);\n    }\n    else\n    {\n        QSharedPointer<MemoryRemap> selectedMap = getMemoryRemap(mapName, remapName);\n        MemoryRemapExpressionGatherer* expressionGatherer = new MemoryRemapExpressionGatherer();\n        mapExpressions = expressionGatherer->getExpressions(selectedMap);\n    }\n\n    std::vector<std::string> expressionList;\n\n    for (auto const& expression : mapExpressions)\n    {\n        expressionList.push_back(expression.toStdString());\n    }\n\n    return expressionList;\n}\n\n//-----------------------------------------------------------------------------\n// Function: MemoryMapInterface::getAllReferencesToIdInRemapItem()\n//-----------------------------------------------------------------------------\nint MemoryMapInterface::getAllReferencesToIdInRemapItem(std::string const& mapName, std::string const& remapName,\n    std::string const& valueID) const\n{\n    QSharedPointer<MemoryRemap> selectedItem = getMemoryRemap(mapName, remapName);\n\n    QString idString = QString::fromStdString(valueID);\n\n    int referencesInIsPresent = selectedItem->getIsPresent().count(idString);\n    int totalReferencesToParameter = referencesInIsPresent;\n\n    return totalReferencesToParameter;\n}\n\n//-----------------------------------------------------------------------------\n// Function: MemoryMapInterface::validateItems()\n//-----------------------------------------------------------------------------\nbool MemoryMapInterface::validateItems() const\n{\n    for (auto currentItem : *mapData_)\n    {\n        if (!validator_->validate(currentItem))\n        {\n            return false;\n        }\n    }\n\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: MemoryMapInterface::itemHasValidName()\n//-----------------------------------------------------------------------------\nbool MemoryMapInterface::itemHasValidName(std::string const& itemName) const\n{\n    QSharedPointer<MemoryMap> selectedItem = getMemoryMap(itemName);\n    if (selectedItem)\n    {\n        return validator_->hasValidName(selectedItem);\n    }\n\n    return false;\n}\n\n//-----------------------------------------------------------------------------\n// Function: MemoryMapInterface::remapHasValidName()\n//-----------------------------------------------------------------------------\nbool MemoryMapInterface::remapHasValidName(std::string const& mapName, std::string const& itemName) const\n{\n    QSharedPointer<MemoryRemap> selectedItem = getMemoryRemap(mapName, itemName);\n    if (selectedItem)\n    {\n        return validator_->hasValidName(selectedItem);\n    }\n\n    return false;\n}\n\n//-----------------------------------------------------------------------------\n// Function: MemoryMapInterface::remapHasValidRemapState()\n//-----------------------------------------------------------------------------\nbool MemoryMapInterface::remapHasValidRemapState(std::string const& mapName, std::string const& itemName) const\n{\n    QSharedPointer<MemoryRemap> remap = getMemoryRemap(mapName, itemName);\n    if (remap)\n    {\n        return !validator_->remapStateIsNotValid(remap);\n    }\n\n    return false;\n}\n\n//-----------------------------------------------------------------------------\n// Function: MemoryMapInterface::itemHasValidIsPresent()\n//-----------------------------------------------------------------------------\nbool MemoryMapInterface::itemHasValidIsPresent(std::string const& mapName, std::string const& remapName) const\n{\n    QSharedPointer<MemoryMapBase> selectedItem;\n    if (remapName.empty())\n    {\n        selectedItem = getMemoryMap(mapName);\n    }\n    else\n    {\n        selectedItem = getMemoryRemap(mapName, remapName);\n    }\n\n    if (selectedItem)\n    {\n        return validator_->hasValidIsPresent(selectedItem);\n    }\n\n    return false;\n}\n\n//-----------------------------------------------------------------------------\n// Function: MemoryMapInterface::memoryMapHasValidAddressUnitBits()\n//-----------------------------------------------------------------------------\nbool MemoryMapInterface::memoryMapHasValidAddressUnitBits(std::string const& mapName) const\n{\n    QSharedPointer<MemoryMap> map = getMemoryMap(mapName);\n    if (map)\n    {\n        return validator_->hasValidAddressUnitBits(map);\n    }\n\n    return false;\n}\n\n//-----------------------------------------------------------------------------\n// Function: MemoryMapInterface::addBlock()\n//-----------------------------------------------------------------------------\nvoid MemoryMapInterface::addMemoryMap(int const& row, std::string const& newMapName /*= std::string(\"\")*/)\n{\n    QSharedPointer<MemoryMap> newMap(new MemoryMap());\n    newMap->setName(getUniqueName(newMapName, MEMORYMAP_TYPE));\n\n    mapData_->insert(row, newMap);\n}\n\n//-----------------------------------------------------------------------------\n// Function: MemoryMapInterface::addMemoryMap()\n//-----------------------------------------------------------------------------\nvoid MemoryMapInterface::addMemoryMap(std::string const& newMapName /*= std::string(\"\")*/)\n{\n    addMemoryMap(mapData_->size(), newMapName);\n}\n\n//-----------------------------------------------------------------------------\n// Function: MemoryMapInterface::addMemoryRemap()\n//-----------------------------------------------------------------------------\nvoid MemoryMapInterface::addMemoryRemap(std::string const& mapName, std::string const& newRemapName)\n{\n    QSharedPointer<MemoryMap> containingMap = getMemoryMap(mapName);\n    if (!containingMap)\n    {\n        return;\n    }\n\n    QSharedPointer<MemoryRemap> newRemap(new MemoryRemap());\n    newRemap->setName(getUniqueRemapName(mapName, newRemapName, MEMORYREMAP_TYPE));\n    for (auto mapBlock : *containingMap->getMemoryBlocks())\n    {\n        QSharedPointer<MemoryBlockBase> remapBlock = mapBlock->clone();\n        newRemap->getMemoryBlocks()->append(remapBlock);\n    }\n\n    containingMap->getMemoryRemaps()->append(newRemap);\n}\n\n//-----------------------------------------------------------------------------\n// Function: MemoryMapInterface::removeMap()\n//-----------------------------------------------------------------------------\nbool MemoryMapInterface::removeMap(std::string const& mapName)\n{\n    QSharedPointer<MemoryMap> removedItem = getMemoryMap(mapName);\n    if (!removedItem)\n    {\n        return false;\n    }\n\n    return mapData_->removeOne(removedItem);\n}\n\n//-----------------------------------------------------------------------------\n// Function: MemoryMapInterface::removeRemap()\n//-----------------------------------------------------------------------------\nbool MemoryMapInterface::removeRemap(std::string const& mapName, std::string remapName)\n{\n    QSharedPointer<MemoryMap> containingMap = getMemoryMap(mapName);\n    if (!containingMap)\n    {\n        return false;\n    }\n\n    QSharedPointer<MemoryRemap> removedItem = getMemoryRemap(mapName, remapName);\n    if (!removedItem)\n    {\n        return false;\n    }\n\n    return containingMap->getMemoryRemaps()->removeOne(removedItem);\n}\n\n//-----------------------------------------------------------------------------\n// Function: MemoryMapInterface::copyRows()\n//-----------------------------------------------------------------------------\nvoid MemoryMapInterface::copyRows(std::vector<std::string> const& selectedRows)\n{\n    QList<QSharedPointer<MemoryMapBase> > copiedMemories;\n    QList<QSharedPointer<MemoryRemap> > copiedRemaps;\n    for (auto const& row : selectedRows)\n    {\n        QStringList rowData = QString::fromStdString(row).split(\"_\");\n        int mapIndex = rowData.first().toInt();\n\n        std::string mapName = getIndexedItemName(mapIndex);\n\n        if (rowData.size() == 2)\n        {\n            int remapIndex = rowData.last().toInt();\n            std::string remapName = getIndexedRemapName(mapName, remapIndex);\n\n            QSharedPointer<MemoryRemap> remap = getMemoryRemap(mapName, remapName);\n            if (remap && !copiedRemaps.contains(remap))\n            {\n                copiedRemaps.append(remap);\n            }\n        }\n        else\n        {\n            QSharedPointer<MemoryMap> memoryMap = getMemoryMap(mapName);\n            if (memoryMap && !copiedMemories.contains(memoryMap))\n            {\n                copiedMemories.append(memoryMap);\n            }\n        }\n    }\n\n    for (auto remap : copiedRemaps)\n    {\n        copiedMemories.append(remap);\n    }\n\n    QVariant memoryBlockVariant;\n    memoryBlockVariant.setValue(copiedMemories);\n\n    QMimeData* newMimeData = new QMimeData();\n    newMimeData->setData(\"text/xml/ipxact:memoryMap\", QByteArray());\n    newMimeData->setImageData(memoryBlockVariant);\n\n    QApplication::clipboard()->setMimeData(newMimeData);\n}\n\n//-----------------------------------------------------------------------------\n// Function: MemoryMapInterface::pasteMemoryMaps()\n//-----------------------------------------------------------------------------\nstd::vector<std::string> MemoryMapInterface::pasteMemoryMaps()\n{\n    std::vector<std::string> pastedItemNames;\n\n    const QMimeData* pasteData = QApplication::clipboard()->mimeData();\n\n    if (pasteData->hasImage())\n    {\n        QVariant pasteVariant = pasteData->imageData();\n        if (pasteVariant.canConvert<QList<QSharedPointer<MemoryMapBase> > >())\n        {\n            QList<QSharedPointer<MemoryMapBase> > copiedMapList =\n                pasteVariant.value<QList<QSharedPointer<MemoryMapBase>>>();\n\n            foreach(QSharedPointer<MemoryMapBase> copiedMap, copiedMapList)\n            {\n                QSharedPointer<MemoryMap> copyMap = copiedMap.dynamicCast<MemoryMap>();\n                if (copyMap)\n                {\n                    pastedItemNames.push_back(pasteMemoryMap(copyMap).toStdString());\n                }\n            }\n        }\n    }\n\n    return pastedItemNames;\n}\n\n//-----------------------------------------------------------------------------\n// Function: MemoryMapInterface::pasteMemoryRemaps()\n//-----------------------------------------------------------------------------\nstd::vector<std::string> MemoryMapInterface::pasteMemoryRemaps(std::string const& memoryMapName)\n{\n    std::vector<std::string> pastedItemNames;\n\n    const QMimeData* pasteData = QApplication::clipboard()->mimeData();\n\n    if (!memoryMapName.empty() && pasteData->hasImage())\n    {\n        QVariant pasteVariant = pasteData->imageData();\n        if (pasteVariant.canConvert<QList<QSharedPointer<MemoryMapBase> > >())\n        {\n            QList<QSharedPointer<MemoryMapBase> > copiedMapList =\n                pasteVariant.value<QList<QSharedPointer<MemoryMapBase>>>();\n\n            for (auto const& copiedMap : copiedMapList)\n            {\n                QSharedPointer<MemoryRemap> copyRemap = copiedMap.dynamicCast<MemoryRemap>();\n                if (copyRemap)\n                {\n                    QString newRemapName = pasteMemoryRemap(copyRemap, memoryMapName);\n                    if (!newRemapName.isEmpty())\n                    {\n                        pastedItemNames.push_back(newRemapName.toStdString());\n                    }\n                }\n            }\n        }\n    }\n\n    return pastedItemNames;\n}\n\n//-----------------------------------------------------------------------------\n// Function: MemoryMapInterface::pasteMemoryMap()\n//-----------------------------------------------------------------------------\nQString MemoryMapInterface::pasteMemoryMap(QSharedPointer<MemoryMap> mapCopy)\n{\n    QSharedPointer<MemoryMap> newMap(new MemoryMap(*mapCopy.data()));\n    newMap->setName(getUniqueName(newMap->name().toStdString(), MEMORYMAP_TYPE));\n    mapData_->append(newMap);\n    \n    return newMap->name();\n}\n\n//-----------------------------------------------------------------------------\n// Function: MemoryMapInterface::pasteMemoryRemap()\n//-----------------------------------------------------------------------------\nQString MemoryMapInterface::pasteMemoryRemap(QSharedPointer<MemoryRemap> remapCopy,\n    std::string const& parentMapName)\n{\n    if (!parentMapName.empty())\n    {\n        QSharedPointer<MemoryMap> parentMap = getMemoryMap(parentMapName);\n        if (parentMap)\n        {\n            QSharedPointer<MemoryRemap> newRemap(new MemoryRemap(*remapCopy.data()));\n            newRemap->setName(getUniqueRemapName(parentMapName, newRemap->name().toStdString(), MEMORYREMAP_TYPE));\n            parentMap->getMemoryRemaps()->append(newRemap);\n\n            return newRemap->name();\n        }\n    }\n\n    return QString(\"\");\n}\n\n//-----------------------------------------------------------------------------\n// Function: MemoryMapInterface::getAddressBlockInterface()\n//-----------------------------------------------------------------------------\nAddressBlockInterface* MemoryMapInterface::getAddressBlockInterface() const\n{\n    return addressBlockInterface_;\n}\n\n//-----------------------------------------------------------------------------\n// Function: MemoryMapInterface::getSubspaceMapInterface()\n//-----------------------------------------------------------------------------\nSubspaceMapInterface* MemoryMapInterface::getSubspaceMapInterface() const\n{\n    return subspaceInterface_;\n}\n\n//-----------------------------------------------------------------------------\n// Function: MemoryMapInterface::getMapPointer()\n//-----------------------------------------------------------------------------\nMemoryMap* MemoryMapInterface::getMapPointer(std::string const& mapName) const\n{\n    MemoryMap* mapPointer = nullptr;\n\n    QSharedPointer<MemoryMap> selectedMap = getMemoryMap(mapName);\n    if (selectedMap)\n    {\n        mapPointer = selectedMap.data();\n    }\n\n    return mapPointer;\n}\n\n//-----------------------------------------------------------------------------\n// Function: MemoryMapInterface::getRemapPointer()\n//-----------------------------------------------------------------------------\nMemoryRemap* MemoryMapInterface::getRemapPointer(std::string const& mapName, std::string const& remapName) const\n{\n    MemoryRemap* reMapPointer = nullptr;\n\n    QSharedPointer<MemoryRemap> selectedRemap = getMemoryRemap(mapName, remapName);\n    if (selectedRemap)\n    {\n        reMapPointer = selectedRemap.data();\n    }\n\n    return reMapPointer;\n}\n\n//-----------------------------------------------------------------------------\n// Function: MemoryMapInterface::getRemapModeReferenceCount()\n//-----------------------------------------------------------------------------\nint MemoryMapInterface::getRemapModeReferenceCount(std::string const& mapName, std::string const& remapName) const\n{\n    auto remap = getMemoryRemap(mapName, remapName);\n    if (!remap)\n    {\n        return 0;\n    }\n\n    return remap->getModeReferences()->size();\n}\n\n//-----------------------------------------------------------------------------\n// Function: MemoryMapInterface::getRemapModeReferences()\n//-----------------------------------------------------------------------------\nstd::vector<std::pair<unsigned int, std::string> > MemoryMapInterface::getRemapModeReferences(std::string const& mapName, std::string const& remapName) const\n{\n    std::vector<std::pair<unsigned int, std::string> > modeRefs;\n\n    if (auto remap = getMemoryRemap(mapName, remapName))\n    {\n        auto modeReferences = remap->getModeReferences();\n\n        std::transform(modeReferences->cbegin(), modeReferences->cend(), std::back_inserter(modeRefs),\n            [](auto modeReference)\n            {\n                return std::make_pair(modeReference->getPriority(), modeReference->getReference().toStdString());\n            });\n    }\n\n    return modeRefs;\n}\n\n//-----------------------------------------------------------------------------\n// Function: MemoryMapInterface::getRemapModeReferenceString()\n//-----------------------------------------------------------------------------\nstd::string MemoryMapInterface::getRemapModeReferenceString(std::string const& mapName, std::string const& remapName) const\n{\n    if (auto remap = getMemoryRemap(mapName, remapName))\n    {\n        auto modeRefs = remap->getModeReferences();\n\n        if (modeRefs->isEmpty())\n        {\n            return std::string(\"None\");\n        }\n        else if (modeRefs->size() > 1)\n        {\n            return std::string(\"[multiple]\");\n        }\n\n        return modeRefs->first()->getReference().toStdString();\n    }\n\n    return std::string();\n}\n\n//-----------------------------------------------------------------------------\n// Function: MemoryMapInterface::setRemapModeReferences()\n//-----------------------------------------------------------------------------\nbool MemoryMapInterface::setRemapModeReferences(std::string const& mapName, std::string const& remapName, \n    std::vector<std::pair<unsigned int, std::string> > const& newModeRefs)\n{\n    if (auto remap = getMemoryRemap(mapName, remapName))\n    {\n        QSharedPointer<QList<QSharedPointer<ModeReference> > > createdModeRefs(\n            new QList<QSharedPointer<ModeReference> >());\n\n        for (auto const& [priority, reference] : newModeRefs)\n        {\n            QSharedPointer<ModeReference> createdModeRef(new ModeReference());\n            createdModeRef->setReference(QString::fromStdString(reference));\n            createdModeRef->setPriority(priority);\n            createdModeRefs->append(createdModeRef);\n        }\n\n        remap->setModeReferences(createdModeRefs);\n        return true;\n    }\n\n    return false;\n}\n\n//-----------------------------------------------------------------------------\n// Function: MemoryMapInterface::addRemapModeReference()\n//-----------------------------------------------------------------------------\nbool MemoryMapInterface::addRemapModeReference(std::string const& mapName, std::string const& remapName)\n{\n    auto remap = getMemoryRemap(mapName, remapName);\n    if (!remap)\n    {\n        return false;\n    }\n\n    QSharedPointer<ModeReference> newModeRef(new ModeReference());\n    remap->getModeReferences()->append(newModeRef);\n\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: MemoryMapInterface::removeRemapModeReference()\n//-----------------------------------------------------------------------------\nbool MemoryMapInterface::removeRemapModeReference(std::string const& mapName, std::string const& remapName, int modeReferenceIndex)\n{\n    auto remap = getMemoryRemap(mapName, remapName);\n    if (!remap || modeReferenceIndex < 0 || modeReferenceIndex >= getRemapModeReferenceCount(mapName, remapName))\n    {\n        return false;\n    }\n\n    remap->getModeReferences()->removeAt(modeReferenceIndex);\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: MemoryMapInterface::getModeReferenceInterface()\n//-----------------------------------------------------------------------------\nModeReferenceInterface* MemoryMapInterface::getModeReferenceInterface() const\n{\n    return modeReferenceInterface_;\n}\n\n//-----------------------------------------------------------------------------\n// Function: MemoryMapInterface::setModeReferenceInterface()\n//-----------------------------------------------------------------------------\nvoid MemoryMapInterface::setModeReferenceInterface(ModeReferenceInterface* modeRefInterface)\n{\n    modeReferenceInterface_ = modeRefInterface;\n}\n\n//-----------------------------------------------------------------------------\n// Function: MemoryMapInterface::getRemapModeReferencesExcludingRemap()\n//-----------------------------------------------------------------------------\nstd::vector<std::pair<unsigned int, std::string> > MemoryMapInterface::getRemapModeReferencesExcludingRemap(\n    std::string const& mapName, std::string const& remapName) const\n{\n    std::vector<std::pair<unsigned int, std::string> > allModeRefs;\n\n    if (auto selectedMap = getMemoryMap(mapName))\n    {\n        QString remapNameQ = QString::fromStdString(remapName);\n        for (auto const& remap : *selectedMap->getMemoryRemaps())\n        {\n            // Get all other mode references, excluding mode references in given remap.\n            if (remap->name() != remapNameQ)\n            {\n                std::transform(remap->getModeReferences()->cbegin(), remap->getModeReferences()->cend(), \n                    std::back_inserter(allModeRefs),\n                    [](auto modeRef)\n                    {\n                        return std::make_pair(modeRef->getPriority(), modeRef->getReference().toStdString());\n                    });\n            }\n        }\n    }\n\n    return allModeRefs;\n}\n\n//-----------------------------------------------------------------------------\n// Function: MemoryMapInterface::getItem()\n//-----------------------------------------------------------------------------\nQSharedPointer<NameGroup> MemoryMapInterface::getItem(std::string const& itemName) const\n{\n    return getMemoryMap(itemName);\n}\n\n//-----------------------------------------------------------------------------\n// Function: MemoryMapInterface::getUniqueRemapName()\n//-----------------------------------------------------------------------------\nQString MemoryMapInterface::getUniqueRemapName(std::string const& mapName, std::string const& newName,\n    std::string const& itemTypeName) const\n{\n    QString referenceRemapName = QString::fromStdString(newName);\n    if (referenceRemapName.isEmpty())\n    {\n        referenceRemapName = QString::fromStdString(itemTypeName);\n    }\n\n    QString newRemapName = referenceRemapName;\n\n    QString format = \"$itemName$_$itemNumber$\";\n    int runningNumber = 0;\n    while (!remapNameIsUnique(mapName, newRemapName))\n    {\n        newRemapName = format;\n        newRemapName.replace(\"$itemName$\", referenceRemapName);\n        newRemapName.replace(\"$itemNumber$\", QString::number(runningNumber));\n\n        runningNumber++;\n    }\n\n    return newRemapName;\n}\n\n//-----------------------------------------------------------------------------\n// Function: MemoryMapInterface::remapNameIsUnique()\n//-----------------------------------------------------------------------------\nbool MemoryMapInterface::remapNameIsUnique(std::string const& mapName, QString const& remapName) const\n{\n    for (auto const& containedName : getRemapNames(mapName))\n    {\n        QString convertedName = QString::fromStdString(containedName);\n        if (convertedName == remapName)\n        {\n            return false;\n        }\n    }\n\n    return true;\n}\n"
  },
  {
    "path": "KactusAPI/interfaces/component/ModeReferenceInterface.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: ModeReferenceInterface.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Anton Hagqvist\n// Date: 26.10.2023\n//\n// Description:\n// Interface for accessing mode references.\n//-----------------------------------------------------------------------------\n\n#include <KactusAPI/include/ModeReferenceInterface.h>\n\n#include <IPXACTmodels/common/validators/CommonItemsValidator.h>\n#include <IPXACTmodels/Component/ModeReference.h>\n#include <IPXACTmodels/Component/Mode.h>\n\n//-----------------------------------------------------------------------------\n// Function: ModeReferenceInterface::setModeReferences()\n//-----------------------------------------------------------------------------\nvoid ModeReferenceInterface::setModeReferences(std::vector<std::pair<unsigned int, std::string> > const& modeReferences)\n{\n    modeReferences_ = modeReferences;\n}\n\n//-----------------------------------------------------------------------------\n// Function: ModeReferenceInterface::getModeReferenceCount()\n//-----------------------------------------------------------------------------\nint ModeReferenceInterface::getModeReferenceCount() const\n{\n    return static_cast<int>(modeReferences_.size());\n}\n\n//-----------------------------------------------------------------------------\n// Function: ModeReferenceInterface::getModeReferenceValue()\n//-----------------------------------------------------------------------------\nstd::string ModeReferenceInterface::getModeReferenceValue(int modeReferenceIndex) const\n{\n    if (modeReferenceIndex >= 0 && modeReferenceIndex < modeReferences_.size())\n    {\n        return modeReferences_.at(modeReferenceIndex).second;\n    }\n\n    return std::string();\n}\n\n//-----------------------------------------------------------------------------\n// Function: ModeReferenceInterface::getModeReferencePriority()\n//-----------------------------------------------------------------------------\nint ModeReferenceInterface::getModeReferencePriority(int modeReferenceIndex) const\n{\n    if (modeReferenceIndex >= 0 && modeReferenceIndex < modeReferences_.size())\n    {\n        return modeReferences_.at(modeReferenceIndex).first;\n    }\n\n    return 0;\n}\n\n//-----------------------------------------------------------------------------\n// Function: ModeReferenceInterface::setModeReferenceValue()\n//-----------------------------------------------------------------------------\nbool ModeReferenceInterface::setModeReferenceValue(int modeReferenceIndex, std::string const& newValue)\n{\n    if (modeReferenceIndex >= 0 && modeReferenceIndex < modeReferences_.size())\n    {\n        modeReferences_.at(modeReferenceIndex).second = newValue;\n        return true;\n    }\n\n    return false;\n}\n\n//-----------------------------------------------------------------------------\n// Function: ModeReferenceInterface::setModeReferencePriority()\n//-----------------------------------------------------------------------------\nbool ModeReferenceInterface::setModeReferencePriority(int modeReferenceIndex, unsigned int newPriority)\n{\n    if (modeReferenceIndex >= 0 && modeReferenceIndex < modeReferences_.size())\n    {\n        modeReferences_.at(modeReferenceIndex).first = newPriority;\n        return true;\n    }\n\n    return false;\n}\n\n//-----------------------------------------------------------------------------\n// Function: ModeReferenceInterface::addModeReference()\n//-----------------------------------------------------------------------------\nbool ModeReferenceInterface::addModeReference(int row)\n{\n    modeReferences_.emplace(modeReferences_.begin() + row, std::pair(0, std::string()));\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: ModeReferenceInterface::removeModeReference()\n//-----------------------------------------------------------------------------\nbool ModeReferenceInterface::removeModeReference(int modeReferenceIndex)\n{\n    if (modeReferenceIndex >= 0 && modeReferenceIndex < modeReferences_.size())\n    {\n        modeReferences_.erase(modeReferences_.begin() + modeReferenceIndex);\n        return true;\n    }\n\n    return false;\n}\n\n//-----------------------------------------------------------------------------\n// Function: ModeReferenceInterface::modeReferenceValueIsValid()\n//-----------------------------------------------------------------------------\nbool ModeReferenceInterface::modeReferenceValueIsValid(int modeReferenceIndex) const\n{\n    if (!(modeReferenceIndex >= 0 && modeReferenceIndex < modeReferences_.size()))\n    {\n        return false;\n    }\n\n    // Get the mode reference to check from the remap/access policy mode references. Check against mode references\n    // in all remaps/access policies.\n    auto const& modeRefToCheck = modeReferences_.at(modeReferenceIndex);\n\n    auto allModeRefs = getModeReferencesInUse(modeReferenceIndex);\n\n    std::vector<std::string> modeRefValuesInUse;\n    modeRefValuesInUse.reserve(allModeRefs.size());\n    std::transform(allModeRefs.cbegin(), allModeRefs.cend(), std::back_inserter(modeRefValuesInUse),\n        [](auto const& tuple)\n        {\n            return tuple.second;\n        });\n\n    QStringList availableModeNames;\n    for (auto const& mode : *componentModes_)\n    {\n        availableModeNames << mode->name();\n    }\n\n    return CommonItemsValidator::modeReferenceValueIsValid(modeRefValuesInUse, modeRefToCheck.second, availableModeNames);\n}\n\n//-----------------------------------------------------------------------------\n// Function: ModeReferenceInterface::modeReferencePriorityIsValid()\n//-----------------------------------------------------------------------------\nbool ModeReferenceInterface::modeReferencePriorityIsValid(int modeReferenceIndex) const\n{\n    if (!(modeReferenceIndex >= 0 && modeReferenceIndex < modeReferences_.size()))\n    {\n        return false;\n    }\n\n    // Get the mode reference to check from the remap/access policy mode references. Check against mode references\n    // in all remaps/access policies.\n    auto modeRefToCheck = modeReferences_.at(modeReferenceIndex).first;\n\n    auto allModeRefs = getModeReferencesInUse(modeReferenceIndex);\n\n    QList<unsigned int> modeRefPrioritiesInUse;\n    modeRefPrioritiesInUse.reserve(allModeRefs.size());\n\n    std::transform(allModeRefs.cbegin(), allModeRefs.cend(), std::back_inserter(modeRefPrioritiesInUse),\n        [](auto const& tuple)\n        {\n            return tuple.first;\n        });\n\n    return CommonItemsValidator::modeReferencePriorityIsValid(modeRefPrioritiesInUse, modeRefToCheck, containingElementIsRemap_);\n}\n\n//-----------------------------------------------------------------------------\n// Function: ModeReferenceInterface::getModeReferencesString()\n//-----------------------------------------------------------------------------\nstd::vector<std::string> ModeReferenceInterface::getModeReferencesString() const\n{\n    std::vector<std::string> referencesAsStrings;\n    std::transform(modeReferences_.cbegin(), modeReferences_.cend(), std::back_inserter(referencesAsStrings),\n        [](auto const& modeRef)\n        {\n            return modeRef.second;\n        });\n\n    return referencesAsStrings;\n}\n\n//-----------------------------------------------------------------------------\n// Function: ModeReferenceInterface::setContainingElementIsRemap()\n//-----------------------------------------------------------------------------\nvoid ModeReferenceInterface::setContainingElementIsRemap(bool isRemap)\n{\n    containingElementIsRemap_ = isRemap;\n}\n\n//-----------------------------------------------------------------------------\n// Function: ModeReferenceInterface::setContainingElementModeReferences()\n//-----------------------------------------------------------------------------\nvoid ModeReferenceInterface::setContainingElementModeReferences(\n    std::vector<std::pair<unsigned int, std::string> > const& modeReferences)\n{\n    containingElementModeReferences_ = modeReferences;\n}\n\n//-----------------------------------------------------------------------------\n// Function: ModeReferenceInterface::getComponentModes()\n//-----------------------------------------------------------------------------\nstd::vector<std::string> ModeReferenceInterface::getComponentModes() const\n{\n    std::vector<std::string> availableModes;\n    std::transform(componentModes_->cbegin(), componentModes_->cend(), std::back_inserter(availableModes),\n        [](auto mode)\n        {\n            return mode->name().toStdString();\n        });\n\n    return availableModes;\n}\n\n//-----------------------------------------------------------------------------\n// Function: ModeReferenceInterface::setComponentModes()\n//-----------------------------------------------------------------------------\nvoid ModeReferenceInterface::setComponentModes(QSharedPointer<QList<QSharedPointer<Mode> > > newModes)\n{\n    componentModes_ = newModes;\n}\n\n//-----------------------------------------------------------------------------\n// Function: ModeReferenceInterface::getModeReferences()\n//-----------------------------------------------------------------------------\nstd::vector<std::pair<unsigned int, std::string> > ModeReferenceInterface::getModeReferences() const\n{\n    return modeReferences_;\n}\n\n//-----------------------------------------------------------------------------\n// Function: ModeReferenceInterface::areAllModeReferencesValid()\n//-----------------------------------------------------------------------------\nbool ModeReferenceInterface::areAllModeReferencesValid()\n{\n    if (modeReferences_.empty())\n    {\n        return false;\n    }\n\n    for ( int i = 0; i < modeReferences_.size(); i++)\n    {\n        if (!modeReferenceValueIsValid(i) || !modeReferencePriorityIsValid(i))\n        {\n            return false;\n        }\n    }\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: ModeReferenceInterface::getModeReferencesInUse()\n//-----------------------------------------------------------------------------\nstd::vector<std::pair<unsigned int, std::string> > ModeReferenceInterface::getModeReferencesInUse(int modeReferenceIndex) const\n{\n    // List containing all other mode references in containing parent, than the one being validated (given by index).\n    std::vector<std::pair<unsigned int, std::string> > allModeRefs;\n\n    allModeRefs.insert(allModeRefs.end(), containingElementModeReferences_.begin(), \n        containingElementModeReferences_.end());\n\n    int currentIndex = 0;\n    for (auto const& modeRef : modeReferences_)\n    {\n        // Get all other mode references, excluding mode references given by index.\n        if (currentIndex != modeReferenceIndex)\n        {\n            allModeRefs.push_back(modeRef);\n        }\n        currentIndex++;\n    }\n\n    return allModeRefs;\n}\n"
  },
  {
    "path": "KactusAPI/interfaces/component/ModuleParameterInterface.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: ModuleParameterInterface.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 22.09.2020\n//\n// Description:\n// Interface for editing module parameters.\n//-----------------------------------------------------------------------------\n\n#include <ModuleParameterInterface.h>\n\n#include <IPXACTmodels/common/ModuleParameter.h>\n#include <IPXACTmodels/Component/ComponentInstantiation.h>\n\n#include \"ComponentInstantiationParameterFinder.h\"\n\n//-----------------------------------------------------------------------------\n// Function: ModuleParameterInterface::ModuleParameterInterface()\n//-----------------------------------------------------------------------------\nModuleParameterInterface::ModuleParameterInterface(QSharedPointer<ParameterValidator> validator,\n    QSharedPointer<ExpressionParser> expressionParser, QSharedPointer<ExpressionFormatter> expressionFormatter,\n    QSharedPointer<ComponentInstantiationParameterFinder> parameterFinder):\nAbstractParameterInterface(validator, expressionParser, expressionFormatter),\nmoduleParameters_(),\nparameterFinder_(parameterFinder)\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: ModuleParameterInterface::setModuleParameters()\n//-----------------------------------------------------------------------------\nvoid ModuleParameterInterface::setModuleParameters(QSharedPointer<ComponentInstantiation> instantiation)\n{\n    moduleParameters_ = instantiation->getModuleParameters();\n\n    parameterFinder_->setComponentInstantiation(instantiation);\n}\n\n//-----------------------------------------------------------------------------\n// Function: ModuleParameterInterface::getItemIndex()\n//-----------------------------------------------------------------------------\nint ModuleParameterInterface::getItemIndex(std::string const& itemName) const\n{\n    if (moduleParameters_)\n    {\n        for (int i = 0; i < moduleParameters_->size(); ++i)\n        {\n            if (moduleParameters_->at(i)->name().toStdString() == itemName)\n            {\n                return i;\n            }\n        }\n    }\n\n    return -1;\n}\n\n//-----------------------------------------------------------------------------\n// Function: ModuleParameterInterface::getIndexedItemName()\n//-----------------------------------------------------------------------------\nstd::string ModuleParameterInterface::getIndexedItemName(int itemIndex) const\n{\n    std::string parameterName = \"\";\n    if (moduleParameters_ && (itemIndex >= 0 && itemIndex < moduleParameters_->size()))\n    {\n        parameterName = moduleParameters_->at(itemIndex)->name().toStdString();\n    }\n\n    return parameterName;\n}\n\n//-----------------------------------------------------------------------------\n// Function: ModuleParameterInterface::itemCount()\n//-----------------------------------------------------------------------------\nint ModuleParameterInterface::itemCount() const\n{\n    if (moduleParameters_)\n    {\n        return moduleParameters_->count();\n    }\n\n    return 0;\n}\n\n//-----------------------------------------------------------------------------\n// Function: ModuleParameterInterface::getItemNames()\n//-----------------------------------------------------------------------------\nstd::vector<std::string> ModuleParameterInterface::getItemNames() const\n{\n    std::vector<std::string> names;\n    if (moduleParameters_)\n    {\n        for (auto parameter : *moduleParameters_)\n        {\n            names.push_back(parameter->name().toStdString());\n        }\n    }\n\n    return names;\n}\n\n//-----------------------------------------------------------------------------\n// Function: ModuleParameterInterface::addModuleParameter()\n//-----------------------------------------------------------------------------\nvoid ModuleParameterInterface::addModuleParameter(int const& row, std::string const& newParameterName)\n{\n    QString parameterName = getUniqueName(newParameterName, \"parameter\");\n\n    QSharedPointer<ModuleParameter> newParameter(new ModuleParameter());\n    newParameter->setName(parameterName);\n\n    moduleParameters_->insert(row, newParameter);\n}\n\n//-----------------------------------------------------------------------------\n// Function: ModuleParameterInterface::removeModuleParameter()\n//-----------------------------------------------------------------------------\nbool ModuleParameterInterface::removeModuleParameter(std::string const& parameterName)\n{\n    QSharedPointer<ModuleParameter> removedParameter = getModuleParameter(parameterName);\n    if (!removedParameter)\n    {\n        return false;\n    }\n\n    return moduleParameters_->removeOne(removedParameter);\n}\n\n//-----------------------------------------------------------------------------\n// Function: ModuleParameterInterface::getItem()\n//-----------------------------------------------------------------------------\nQSharedPointer<NameGroup> ModuleParameterInterface::getItem(std::string const& parameterName) const\n{\n    return getModuleParameter(parameterName);\n}\n\n//-----------------------------------------------------------------------------\n// Function: ModuleParameterInterface::getParameter()\n//-----------------------------------------------------------------------------\nQSharedPointer<Parameter> ModuleParameterInterface::getParameter(std::string const& parameterName) const\n{\n    return getModuleParameter(parameterName);\n}\n\n\n//-----------------------------------------------------------------------------\n// Function: ModuleParameterInterface::isModuleParameter()\n//-----------------------------------------------------------------------------\nQSharedPointer<ModuleParameter> ModuleParameterInterface::getModuleParameter(std::string const& parameterName)\nconst\n{\n    if (moduleParameters_)\n    {\n        for (auto parameter : *moduleParameters_)\n        {\n            if (parameter->name().toStdString() == parameterName)\n            {\n                return parameter;\n            }\n        }\n    }\n\n    return QSharedPointer<ModuleParameter>();\n}\n\n//-----------------------------------------------------------------------------\n// Function: ModuleParameterInterface::getDataType()\n//-----------------------------------------------------------------------------\nstd::string ModuleParameterInterface::getDataType(std::string const& parameterName) const\n{\n    QSharedPointer<ModuleParameter> moduleParameter = getModuleParameter(parameterName);\n    if (moduleParameter)\n    {\n        return moduleParameter->getDataType().toStdString();\n    }\n\n    return std::string(\"\");\n}\n\n//-----------------------------------------------------------------------------\n// Function: ModuleParameterInterface::setDataType()\n//-----------------------------------------------------------------------------\nbool ModuleParameterInterface::setDataType(std::string const& parameterName, std::string const& newDataType)\n{\n    QSharedPointer<ModuleParameter> moduleParameter = getModuleParameter(parameterName);\n    if (!moduleParameter)\n    {\n        return false;\n    }\n\n    moduleParameter->setDataType(QString::fromStdString(newDataType));\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: ModuleParameterInterface::getUsageType()\n//-----------------------------------------------------------------------------\nstd::string ModuleParameterInterface::getUsageType(std::string const& parameterName) const\n{\n    QSharedPointer<ModuleParameter> moduleParameter = getModuleParameter(parameterName);\n    if (moduleParameter)\n    {\n        return moduleParameter->getUsageType().toStdString();\n    }\n\n    return std::string(\"\");\n}\n\n//-----------------------------------------------------------------------------\n// Function: ModuleParameterInterface::setUsageType()\n//-----------------------------------------------------------------------------\nbool ModuleParameterInterface::setUsageType(std::string const& parameterName, std::string const& newUsageType)\n{\n    QSharedPointer<ModuleParameter> moduleParameter = getModuleParameter(parameterName);\n    if (!moduleParameter)\n    {\n        return false;\n    }\n\n    moduleParameter->setUsageType(QString::fromStdString(newUsageType));\n    return true;\n}\n"
  },
  {
    "path": "KactusAPI/interfaces/component/PortMapInterface.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: PortMapInterface.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 22.10.2020\n//\n// Description:\n// Interface for editing port maps.\n//-----------------------------------------------------------------------------\n\n#include <PortMapInterface.h>\n\n#include <IPXACTmodels/AbstractionDefinition/PortAbstraction.h>\n#include <IPXACTmodels/AbstractionDefinition/AbstractionDefinition.h>\n#include <IPXACTmodels/AbstractionDefinition/WireAbstraction.h>\n#include <IPXACTmodels/AbstractionDefinition/TransactionalAbstraction.h>\n#include <IPXACTmodels/common/PresenceTypes.h>\n#include <IPXACTmodels/common/ConfigurableVLNVReference.h>\n#include <IPXACTmodels/Component/validators/PortMapValidator.h>\n#include <IPXACTmodels/Component/AbstractionType.h>\n#include <IPXACTmodels/Component/Port.h>\n\n#include <PortsInterface.h>\n#include <PortAbstractionInterface.h>\n\n#include <QVector>\n#include <QString>\n\nnamespace\n{\n    std::string const PORTMAP_TYPE = \"portMap\";\n\n    QString const MULTIPLE_SELECTED = \"[multiple]\";\n    QString const UNKNOWN_PORT = \"Unknown\";\n};\n\n//-----------------------------------------------------------------------------\n// Function: ComponentInstantiationInterface::ComponentInstantiationInterface()\n//-----------------------------------------------------------------------------\nPortMapInterface::PortMapInterface(QSharedPointer<PortMapValidator> validator,\n    QSharedPointer<ExpressionParser> expressionParser, QSharedPointer<ExpressionFormatter> expressionFormatter,\n    PortsInterface* physicalPortInterface, PortAbstractionInterface* logicalPortInterface):\nParameterizableInterface(expressionParser, expressionFormatter),\nCommonInterface(),\nvalidator_(validator),\nphysicalPortInterface_(physicalPortInterface),\nlogicalPortInterface_(logicalPortInterface)\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortMapInterface::setupLogicalPorts()\n//-----------------------------------------------------------------------------\nvoid PortMapInterface::setupAbstractionDefinition(QSharedPointer<AbstractionDefinition const> absDef)\n{\n    abstractionDef_ = absDef;\n\n    logicalPortInterface_->setAbsDef(absDef);\n\n    validator_->abstractionDefinitionChanged(absDef, interfaceMode_);\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortMapInterface::setupPhysicalPorts()\n//-----------------------------------------------------------------------------\nvoid PortMapInterface::setupPhysicalPorts(Port::List ports)\n{\n    physicalPortInterface_->setPorts(ports);\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortMapInterface::setupPortMaps()\n//-----------------------------------------------------------------------------\nvoid PortMapInterface::setupPortMaps(QSharedPointer<AbstractionType> abstractionType)\n{\n    portMaps_ = abstractionType->getPortMaps();\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortMapInterface::setupBusMode()\n//-----------------------------------------------------------------------------\nvoid PortMapInterface::setupBusMode(General::InterfaceMode busMode)\n{\n    interfaceMode_ = busMode;\n\n    if (abstractionDef_)\n    {\n        validator_->abstractionDefinitionChanged(abstractionDef_, interfaceMode_);\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortMapInterface::setupSystemGroup()\n//-----------------------------------------------------------------------------\nvoid PortMapInterface::setupSystemGroup(QString const& systemGroup)\n{\n    systemGroup_ = systemGroup.toStdString();\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortMapInterface::getIndexedItemName()\n//-----------------------------------------------------------------------------\nstd::string PortMapInterface::getIndexedItemName(int const& itemIndex) const\n{\n    return getLogicalPortName(itemIndex);\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortMapInterface::itemCount()\n//-----------------------------------------------------------------------------\nint PortMapInterface::itemCount() const\n{\n    int mapCount = 0;\n    if (portMaps_)\n    {\n        mapCount = portMaps_->size();\n    }\n\n    return mapCount;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortMapInterface::getItemNames()\n//-----------------------------------------------------------------------------\nstd::vector<std::string> PortMapInterface::getItemNames() const\n{\n    std::vector<std::string> names;\n\n    for (int i = 0; i < itemCount(); ++i)\n    {\n        std::string currentPortName = getLogicalPortName(i);\n        if (std::find(names.cbegin(), names.cend(), currentPortName) == names.cend())\n        {\n            names.push_back(currentPortName);\n        }\n    }\n\n    return names;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortMapInterface::getLogicalPortName()\n//-----------------------------------------------------------------------------\nstd::string PortMapInterface::getLogicalPortName(int const& portMapIndex) const\n{\n    std::string logicalPortName(\"\");\n\n    QSharedPointer<PortMap> map = getPortMap(portMapIndex);\n    if (map && map->getLogicalPort())\n    {\n        logicalPortName = map->getLogicalPort()->name_.toStdString();\n    }\n\n    return logicalPortName;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortMapInterface::setLogicalPort()\n//-----------------------------------------------------------------------------\nbool PortMapInterface::setLogicalPort(int const& portMapIndex, std::string const& newName)\n{\n    std::string busModeString(General::interfaceMode2Str(interfaceMode_).toStdString());\n\n    QSharedPointer<PortMap> map = getPortMap(portMapIndex);\n    if (map && logicalPortInterface_->portHasMode(newName, busModeString, systemGroup_))\n    {\n        QSharedPointer<PortMap::LogicalPort> logicalPort = map->getLogicalPort();\n        if (!logicalPort && !newName.empty())\n        {\n            logicalPort = QSharedPointer<PortMap::LogicalPort>(new PortMap::LogicalPort());\n            map->setLogicalPort(logicalPort);\n        }\n\n        logicalPort->name_ = QString::fromStdString(newName);\n\n        if (newName.empty())\n        {\n            removeEmptyLogicalPort(map);\n        }\n\n        return true;\n    }\n\n    return false;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortMapInterface::removeEmptyLogicalPort()\n//-----------------------------------------------------------------------------\nbool PortMapInterface::removeEmptyLogicalPort(QSharedPointer<PortMap> editedPortMap)\n{\n    QSharedPointer<PortMap::LogicalPort> mappedLogical = editedPortMap->getLogicalPort();\n    if (mappedLogical->name_.isEmpty() && !mappedLogical->range_)\n    {\n        editedPortMap->setLogicalPort(QSharedPointer<PortMap::LogicalPort>());\n        return true;\n    }\n    else\n    {\n        return false;\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortMapInterface::hasPhysicalPort()\n//-----------------------------------------------------------------------------\nbool PortMapInterface::hasPhysicalPort(int const& portMapIndex) const\n{\n    return portMapIndex >= 0 && portMapIndex < itemCount() && portMaps_->at(portMapIndex)->getPhysicalPort();\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortMapInterface::getPhysicalPortName()\n//-----------------------------------------------------------------------------\nstd::string PortMapInterface::getPhysicalPortName(int const& portMapIndex) const\n{\n    std::string physicalName(\"\");\n\n    QSharedPointer<PortMap> portMap = getPortMap(portMapIndex);\n    if (portMap)\n    {\n        QSharedPointer<PortMap::PhysicalPort> physicalPort = portMap->getPhysicalPort();\n        if (physicalPort)\n        {\n            physicalName = physicalPort->name_.toStdString();\n        }\n    }\n\n    return physicalName;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortMapInterface::setPhysicalPort()\n//-----------------------------------------------------------------------------\nbool PortMapInterface::setPhysicalPort(int const& portMapIndex, std::string const& newPhysicalName)\n{\n    QSharedPointer<PortMap> editedPortMap = getPortMap(portMapIndex);\n    if (!editedPortMap)\n    {\n        return false;\n    }\n\n    QSharedPointer<PortMap::PhysicalPort> physicalPort = editedPortMap->getPhysicalPort();\n    if (!physicalPort)\n    {\n        physicalPort = QSharedPointer<PortMap::PhysicalPort>(\n            new PortMap::PhysicalPort(QString::fromStdString(newPhysicalName)));\n\n        editedPortMap->setPhysicalPort(physicalPort);\n    }\n    else\n    {\n        physicalPort->name_ = QString::fromStdString(newPhysicalName);\n    }\n\n    if (newPhysicalName.empty())\n    {\n        removeEmptyPhysicalPort(editedPortMap);\n    }\n\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortMapInterface::removeEmptyPhysicalPort()\n//-----------------------------------------------------------------------------\nbool PortMapInterface::removeEmptyPhysicalPort(QSharedPointer<PortMap> editedPortMap)\n{\n    QSharedPointer<PortMap::PhysicalPort> physicalPort = editedPortMap->getPhysicalPort();\n    if (physicalPort)\n    {\n        if (removeEmptyPhysicalPartSelect(physicalPort) && physicalPort->name_.isEmpty())\n        {\n            editedPortMap->getPhysicalPort().clear();\n            editedPortMap->setPhysicalPort(QSharedPointer<PortMap::PhysicalPort>());\n        }\n        else\n        {\n            return false;\n        }\n    }\n\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortMapInterface::removeEmptyPhysicalPartSelect()\n//-----------------------------------------------------------------------------\nbool PortMapInterface::removeEmptyPhysicalPartSelect(QSharedPointer<PortMap::PhysicalPort> physicalPort)\n{\n    if (physicalPort->partSelect_)\n    {\n        QSharedPointer<PartSelect> physicalPart = physicalPort->partSelect_;\n        if (physicalPart->getIndices()->isEmpty() &&\n            physicalPart->getLeftRange().isEmpty() && physicalPart->getRightRange().isEmpty())\n        {\n            physicalPort->partSelect_.clear();\n            physicalPort->partSelect_ = QSharedPointer<PartSelect>();\n        }\n        else\n        {\n            return false;\n        }\n    }\n\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortMapInterface::getLogicalPresence()\n//-----------------------------------------------------------------------------\nstd::string PortMapInterface::getLogicalPresence(int const& portMapIndex)\n{\n    std::string logicalPortName = getLogicalPortName(portMapIndex);\n    return getLogicalPresenceWithLogicalPort(logicalPortName);\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortMapInterface::getLogicalPresenceWithLogicalPort()\n//-----------------------------------------------------------------------------\nstd::string PortMapInterface::getLogicalPresenceWithLogicalPort(std::string const& logicalName)\n{\n    std::string busMode = General::interfaceMode2Str(interfaceMode_).toStdString();\n\n    PresenceTypes::Presence requirement =\n        logicalPortInterface_->getPresence(logicalName, busMode, systemGroup_);\n    if (requirement == PresenceTypes::UNKNOWN)\n    {\n        requirement = PresenceTypes::OPTIONAL;\n    }\n\n    return PresenceTypes::presence2Str(requirement).toStdString();\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortMapInterface::getInvertString()\n//-----------------------------------------------------------------------------\nstd::string PortMapInterface::getInvertString(int const& portMapIndex) const\n{\n    BooleanValue invertValue;\n    QSharedPointer<PortMap> map = getPortMap(portMapIndex);\n    if (map)\n    {\n        invertValue = map->getInvert();\n    }\n\n    return invertValue.toString().toStdString();\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortMapInterface::getInvertValue()\n//-----------------------------------------------------------------------------\nBooleanValue PortMapInterface::getInvertValue(int const& portMapIndex) const\n{\n    QSharedPointer<PortMap> map = getPortMap(portMapIndex);\n    if (map)\n    {\n        return map->getInvert();\n    }\n\n    return BooleanValue();\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortMapInterface::getInvertBool()\n//-----------------------------------------------------------------------------\nbool PortMapInterface::getInvertBool(int const& portMapIndex) const\n{\n    QSharedPointer<PortMap> map = getPortMap(portMapIndex);\n    if (map)\n    {\n        return map->getInvert().toBool();\n    }\n    \n    return false;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortMapInterface::setInvertValue()\n//-----------------------------------------------------------------------------\nbool PortMapInterface::setInvertValue(int const& portMapIndex, bool newInvertValue) const\n{\n    QSharedPointer<PortMap> map = getPortMap(portMapIndex);\n    if (!map)\n    {\n        return false;\n    }\n\n    map->setInvert(newInvertValue);\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortMapInterface::getIsInformativeString()\n//-----------------------------------------------------------------------------\nstd::string PortMapInterface::getIsInformativeString(int const& portMapIndex) const\n{\n    BooleanValue isInfo;\n    QSharedPointer<PortMap> map = getPortMap(portMapIndex);\n    if (map)\n    {\n        isInfo = map->getIsInformative();\n    }\n\n    return isInfo.toString().toStdString();\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortMapInterface::getIsInformativeValue()\n//-----------------------------------------------------------------------------\nbool PortMapInterface::getIsInformativeValue(int const& portMapIndex) const\n{\n    QSharedPointer<PortMap> map = getPortMap(portMapIndex);\n    if (map)\n    {\n        return map->getIsInformative().toBool();\n    }\n    \n    return false;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortMapInterface::setIsInformativeValue()\n//-----------------------------------------------------------------------------\nbool PortMapInterface::setIsInformativeValue(int const& portMapIndex, bool newIsInformativeValue) const\n{\n    QSharedPointer<PortMap> editedPortMap = getPortMap(portMapIndex);\n    if (!editedPortMap)\n    {\n        return false;\n    }\n\n    editedPortMap->setIsInformative(newIsInformativeValue);\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortMapInterface::getLogicalTieOffValue()\n//-----------------------------------------------------------------------------\nstd::string PortMapInterface::getLogicalTieOffValue(int const& portMapIndex, int const& baseNumber) const\n{\n    QString logicalTieOff(\"\");\n    QSharedPointer<PortMap> selectedPortMap = getPortMap(portMapIndex);\n    if (selectedPortMap)\n    {\n        logicalTieOff = selectedPortMap->getLogicalTieOff();\n    }\n\n    return parseExpressionToBaseNumber(logicalTieOff, baseNumber).toStdString();\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortMapInterface::getLogicalTieOffFormattedExpression()\n//-----------------------------------------------------------------------------\nstd::string PortMapInterface::getLogicalTieOffFormattedExpression(int const& portMapIndex) const\n{\n    QString logicalTieOff(\"\");\n    QSharedPointer<PortMap> selectedPortMap = getPortMap(portMapIndex);\n    if (selectedPortMap)\n    {\n        logicalTieOff = selectedPortMap->getLogicalTieOff();\n    }\n\n    return formattedValueFor(logicalTieOff).toStdString();\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortMapInterface::getLogicalTieOffExpression()\n//-----------------------------------------------------------------------------\nstd::string PortMapInterface::getLogicalTieOffExpression(int const& portMapIndex) const\n{\n    QSharedPointer<PortMap> selectedPortMap = getPortMap(portMapIndex);\n    if (selectedPortMap)\n    {\n        return selectedPortMap->getLogicalTieOff().toStdString();\n    }\n\n    return std::string(\"\");\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortMapInterface::setLogicalTieOff()\n//-----------------------------------------------------------------------------\nbool PortMapInterface::setLogicalTieOff(int const& portMapIndex, std::string const& newTieOff)\n{\n    QSharedPointer<PortMap> portMap = getPortMap(portMapIndex);\n    if (!portMap)\n    {\n        return false;\n    }\n\n    portMap->setLogicalTieOff(QString::fromStdString(newTieOff));\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortMapInterface::getLogicalLeftBoundValue()\n//-----------------------------------------------------------------------------\nstd::string PortMapInterface::getLogicalLeftBoundValue(int const& portMapIndex, int const& baseNumber) const\n{\n    QSharedPointer<PortMap> selectedPortMap = getPortMap(portMapIndex);\n    if (selectedPortMap && selectedPortMap->getLogicalPort() && selectedPortMap->getLogicalPort()->range_)\n    {\n        return parseExpressionToBaseNumber(selectedPortMap->getLogicalPort()->range_->getLeft(), baseNumber).\n            toStdString();\n    }\n\n    return std::string(\"\");\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortMapInterface::getLogicalLeftBoundFormattedExpression()\n//-----------------------------------------------------------------------------\nstd::string PortMapInterface::getLogicalLeftBoundFormattedExpression(int const& portMapIndex) const\n{\n    QSharedPointer<PortMap> selectedPortMap = getPortMap(portMapIndex);\n    if (selectedPortMap && selectedPortMap->getLogicalPort() && selectedPortMap->getLogicalPort()->range_)\n    {\n        return formattedValueFor(selectedPortMap->getLogicalPort()->range_->getLeft()).toStdString();\n    }\n\n    return std::string(\"\");\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortMapInterface::getLogicalLeftBoundExpression()\n//-----------------------------------------------------------------------------\nstd::string PortMapInterface::getLogicalLeftBoundExpression(int const& portMapIndex) const\n{\n    QSharedPointer<PortMap> selectedPortMap = getPortMap(portMapIndex);\n    if (selectedPortMap && selectedPortMap->getLogicalPort() && selectedPortMap->getLogicalPort()->range_)\n    {\n        return selectedPortMap->getLogicalPort()->range_->getLeft().toStdString();\n    }\n\n    return std::string(\"\");\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortMapInterface::setLogicalLeftBound()\n//-----------------------------------------------------------------------------\nbool PortMapInterface::setLogicalLeftBound(int const& portMapIndex, std::string const& newLogicalLeft)\n{\n    QSharedPointer<PortMap> selectedPortMap = getPortMap(portMapIndex);\n    if (!selectedPortMap || !selectedPortMap->getLogicalPort())\n    {\n        return false;\n    }\n\n    QSharedPointer<PortMap::LogicalPort> logicalPort = selectedPortMap->getLogicalPort();\n    if (!logicalPort->range_ && !newLogicalLeft.empty())\n    {\n        QSharedPointer<Range> newRange(new Range(QString::fromStdString(newLogicalLeft), \"\"));\n        logicalPort->range_ = newRange;\n    }\n    else if (logicalPort->range_)\n    {\n        logicalPort->range_->setLeft(QString::fromStdString(newLogicalLeft));\n    }\n\n    if (newLogicalLeft.empty())\n    {\n        if (removeEmptyRange(logicalPort))\n        {\n            removeEmptyLogicalPort(selectedPortMap);\n        }\n    }\n\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortMapInterface::removeEmptyRange()\n//-----------------------------------------------------------------------------\nbool PortMapInterface::removeEmptyRange(QSharedPointer<PortMap::LogicalPort> editedPortLogical)\n{\n    if (editedPortLogical->range_ && editedPortLogical->range_->getLeft().isEmpty() &&\n        editedPortLogical->range_->getRight().isEmpty())\n    {\n        editedPortLogical->range_.clear();\n        return true;\n    }\n\n    return false;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortMapInterface::getLogicalRightBoundValue()\n//-----------------------------------------------------------------------------\nstd::string PortMapInterface::getLogicalRightBoundValue(int const& portMapIndex, int const& baseNumber) const\n{\n    QSharedPointer<PortMap> selectedPortMap = getPortMap(portMapIndex);\n    if (selectedPortMap && selectedPortMap->getLogicalPort() && selectedPortMap->getLogicalPort()->range_)\n    {\n        return parseExpressionToBaseNumber(\n            selectedPortMap->getLogicalPort()->range_->getRight(), baseNumber).toStdString();\n    }\n\n    return std::string(\"\");\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortMapInterface::getLogicalRightBoundFormattedExpression()\n//-----------------------------------------------------------------------------\nstd::string PortMapInterface::getLogicalRightBoundFormattedExpression(int const& portMapIndex) const\n{\n    QSharedPointer<PortMap> selectedPortMap = getPortMap(portMapIndex);\n    if (selectedPortMap && selectedPortMap->getLogicalPort() && selectedPortMap->getLogicalPort()->range_)\n    {\n        QString logicalRightBound(selectedPortMap->getLogicalPort()->range_->getRight());\n        return formattedValueFor(logicalRightBound).toStdString();\n    }\n\n    return std::string(\"\");\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortMapInterface::getLogicalRightBoundExpression()\n//-----------------------------------------------------------------------------\nstd::string PortMapInterface::getLogicalRightBoundExpression(int const& portMapIndex) const\n{\n    QSharedPointer<PortMap> selectedPortMap = getPortMap(portMapIndex);\n    if (selectedPortMap && selectedPortMap->getLogicalPort() && selectedPortMap->getLogicalPort()->range_)\n    {\n        QString logicalRightBound(selectedPortMap->getLogicalPort()->range_->getRight());\n        return logicalRightBound.toStdString();\n    }\n\n    return std::string(\"\");\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortMapInterface::setLogicalRightBound()\n//-----------------------------------------------------------------------------\nbool PortMapInterface::setLogicalRightBound(int const& portMapIndex, std::string const& newLogicalRight)\n{\n    QSharedPointer<PortMap> selectedPortMap = getPortMap(portMapIndex);\n    if (!selectedPortMap || !selectedPortMap->getLogicalPort())\n    {\n        return false;\n    }\n\n    QSharedPointer<PortMap::LogicalPort> logicalPort = selectedPortMap->getLogicalPort();\n    if (!logicalPort->range_ && !newLogicalRight.empty())\n    {\n        QSharedPointer<Range> newRange(new Range(\"\", QString::fromStdString(newLogicalRight)));\n        logicalPort->range_ = newRange;\n    }\n    else if (logicalPort->range_)\n    {\n        logicalPort->range_->setRight(QString::fromStdString(newLogicalRight));\n    }\n\n    if (newLogicalRight.empty())\n    {\n        if (removeEmptyRange(logicalPort))\n        {\n            removeEmptyLogicalPort(selectedPortMap);\n        }\n    }\n\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortMapInterface::getPhysicalLeftBoundValue()\n//-----------------------------------------------------------------------------\nstd::string PortMapInterface::getPhysicalLeftBoundValue(int const& portMapIndex, int const& baseNumber) const\n{\n    QSharedPointer<PortMap> selectedPortMap = getPortMap(portMapIndex);\n    if (selectedPortMap && selectedPortMap->getPhysicalPort() && selectedPortMap->getPhysicalPort()->partSelect_)\n    {\n        QString physicalLeftBound(selectedPortMap->getPhysicalPort()->partSelect_->getLeftRange());\n        return parseExpressionToBaseNumber(physicalLeftBound, baseNumber).toStdString();\n    }\n\n    return std::string(\"\");\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortMapInterface::getPhysicalLeftBoundFormattedExpression()\n//-----------------------------------------------------------------------------\nstd::string PortMapInterface::getPhysicalLeftBoundFormattedExpression(int const& portMapIndex) const\n{\n    QSharedPointer<PortMap> selectedPortMap = getPortMap(portMapIndex);\n    if (selectedPortMap && selectedPortMap->getPhysicalPort() && selectedPortMap->getPhysicalPort()->partSelect_)\n    {\n        QString physicalLeftBound(selectedPortMap->getPhysicalPort()->partSelect_->getLeftRange());\n        return formattedValueFor(physicalLeftBound).toStdString();\n    }\n\n    return std::string(\"\");\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortMapInterface::getPhysicalLefttBoundExpression()\n//-----------------------------------------------------------------------------\nstd::string PortMapInterface::getPhysicalLeftBoundExpression(int const& portMapIndex) const\n{\n    QSharedPointer<PortMap> selectedPortMap = getPortMap(portMapIndex);\n    if (selectedPortMap && selectedPortMap->getPhysicalPort() && selectedPortMap->getPhysicalPort()->partSelect_)\n    {\n        QString physicalLeftBound(selectedPortMap->getPhysicalPort()->partSelect_->getLeftRange());\n        return physicalLeftBound.toStdString();\n    }\n\n    return std::string(\"\");\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortMapInterface::setPhysicalLeftBound()\n//-----------------------------------------------------------------------------\nbool PortMapInterface::setPhysicalLeftBound(int const& portMapIndex, std::string const& newPhysicalLeft)\n{\n    QSharedPointer<PartSelect> physicalPart = getPhysicalPartSelect(portMapIndex);\n    if (physicalPart)\n    {\n        physicalPart->setLeftRange(QString::fromStdString(newPhysicalLeft));\n    }\n\n    if (newPhysicalLeft.empty())\n    {\n        removeEmptyPhysicalPort(getPortMap(portMapIndex));\n    }\n\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortMapInterface::getPhysicalPartSelect()\n//-----------------------------------------------------------------------------\nQSharedPointer<PartSelect> PortMapInterface::getPhysicalPartSelect(int const& portMapIndex)\n{\n    QSharedPointer<PortMap> portMap = getPortMap(portMapIndex);\n    if (!portMap)\n    {\n        return QSharedPointer<PartSelect>();\n    }\n\n    QSharedPointer<PortMap::PhysicalPort> physicalPort = portMap->getPhysicalPort();\n    if (!physicalPort)\n    {\n        physicalPort = QSharedPointer<PortMap::PhysicalPort>(new PortMap::PhysicalPort());\n        portMap->setPhysicalPort(physicalPort);\n    }\n\n    if (!physicalPort->partSelect_)\n    {\n        QSharedPointer<PartSelect> newPartSelect(new PartSelect());\n        physicalPort->partSelect_ = newPartSelect;\n    }\n\n    return physicalPort->partSelect_;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortMapInterface::getPhysicalRightBoundValue()\n//-----------------------------------------------------------------------------\nstd::string PortMapInterface::getPhysicalRightBoundValue(int const& portMapIndex, int const& baseNumber) const\n{\n    QSharedPointer<PortMap> selectedPortMap = getPortMap(portMapIndex);\n    if (selectedPortMap && selectedPortMap->getPhysicalPort() && selectedPortMap->getPhysicalPort()->partSelect_)\n    {\n        QString physicalRightBound(selectedPortMap->getPhysicalPort()->partSelect_->getRightRange());\n        return parseExpressionToBaseNumber(physicalRightBound, baseNumber).toStdString();\n    }\n\n    return std::string(\"\");\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortMapInterface::getPhysicalRightBoundFormattedExpression()\n//-----------------------------------------------------------------------------\nstd::string PortMapInterface::getPhysicalRightBoundFormattedExpression(int const& portMapIndex) const\n{\n    QSharedPointer<PortMap> selectedPortMap = getPortMap(portMapIndex);\n    if (selectedPortMap && selectedPortMap->getPhysicalPort() && selectedPortMap->getPhysicalPort()->partSelect_)\n    {\n        QString physicalRightBound(selectedPortMap->getPhysicalPort()->partSelect_->getRightRange());\n        return formattedValueFor(physicalRightBound).toStdString();\n    }\n\n    return std::string(\"\");\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortMapInterface::getPhysicalRightBoundExpression()\n//-----------------------------------------------------------------------------\nstd::string PortMapInterface::getPhysicalRightBoundExpression(int const& portMapIndex) const\n{\n    QSharedPointer<PortMap> selectedPortMap = getPortMap(portMapIndex);\n    if (selectedPortMap && selectedPortMap->getPhysicalPort() && selectedPortMap->getPhysicalPort()->partSelect_)\n    {\n        QString physicalRightBound(selectedPortMap->getPhysicalPort()->partSelect_->getRightRange());\n        return physicalRightBound.toStdString();\n    }\n\n    return std::string(\"\");\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortMapInterface::setPhysicalRightBound()\n//-----------------------------------------------------------------------------\nbool PortMapInterface::setPhysicalRightBound(int const& portMapIndex, std::string const& newPhysicalRight)\n{\n    QSharedPointer<PartSelect> physicalPart = getPhysicalPartSelect(portMapIndex);\n    if (physicalPart)\n    {\n        physicalPart->setRightRange(QString::fromStdString(newPhysicalRight));\n    }\n\n    if (newPhysicalRight.empty())\n    {\n        removeEmptyPhysicalPort(getPortMap(portMapIndex));\n    }\n\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortMapInterface::getLogicalPortIconPath()\n//-----------------------------------------------------------------------------\nstd::string PortMapInterface::getLogicalPortIconPath(int const& portMapIndex) const\n{\n    std::string mappingPath(\":icons/common/graphics/cross.png\");\n    std::string busMode(General::interfaceMode2Str(interfaceMode_).toStdString());\n\n    QSharedPointer<PortMap> map = getPortMap(portMapIndex);\n    if (map)\n    {\n        std::string logicalPortName(getLogicalPortName(portMapIndex));\n        if (logicalPortInterface_->portHasMode(logicalPortName, busMode, systemGroup_))\n        {\n            mappingPath = logicalPortInterface_->getIconPathForSignal(logicalPortName, busMode, systemGroup_);\n        }\n    }\n\n    return mappingPath;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortMapInterface::getPhysicalPortIconPath()\n//-----------------------------------------------------------------------------\nstd::string PortMapInterface::getPhysicalPortIconPath(int const& portMapIndex) const\n{\n    std::string iconPath(\"\");\n\n    QSharedPointer<PortMap> portMap = getPortMap(portMapIndex);\n    if (portMap && portMap->getPhysicalPort())\n    {\n        std::string portName(getPhysicalPortName(portMapIndex));\n        iconPath = physicalPortInterface_->getIconPathForPort(portName);\n    }\n\n    return iconPath;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortMapInterface::logicalPortExists()\n//-----------------------------------------------------------------------------\nbool PortMapInterface::logicalPortExists(int const& portMapIndex) const\n{\n    std::string interfaceMode = General::interfaceMode2Str(interfaceMode_).toStdString();\n    std::string logicalPortName = getLogicalPortName(portMapIndex);\n    return logicalPortInterface_->portHasMode(logicalPortName, interfaceMode, systemGroup_);\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortMapInterface::getAllReferencesToIdInItem()\n//-----------------------------------------------------------------------------\nint PortMapInterface::getAllReferencesToIdInItem(const std::string& itemName, std::string const&  valueID) const\n{\n    int totalReferencesToParameter = 0;\n\n    QList<QSharedPointer<PortMap> > logicalMaps;\n    for (int i = 0; i < itemCount(); ++i)\n    {\n        if (getLogicalPortName(i) == itemName)\n        {\n            logicalMaps.append(portMaps_->at(i));\n        }\n    }\n\n    for (auto portMap : logicalMaps)\n    {\n        QString idString(QString::fromStdString(valueID));\n\n        int referencesInLogicalPort = 0;\n        QSharedPointer<PortMap::LogicalPort> logicalPort = portMap->getLogicalPort();\n        if (logicalPort && logicalPort->range_)\n        {\n            referencesInLogicalPort += logicalPort->range_->getLeft().count(idString);\n            referencesInLogicalPort += logicalPort->range_->getRight().count(idString);\n        }\n\n        int referencesInPhysicalPort = 0;\n        QSharedPointer<PortMap::PhysicalPort> physicalPort = portMap->getPhysicalPort();\n        if (physicalPort && physicalPort->partSelect_)\n        {\n            QSharedPointer<PartSelect> physicalPart = physicalPort->partSelect_;\n\n            referencesInPhysicalPort += physicalPart->getLeftRange().count(idString);\n            referencesInPhysicalPort += physicalPart->getRightRange().count(idString);\n\n            if (physicalPart->getIndices())\n            {\n                for (auto index : *physicalPart->getIndices())\n                {\n                    referencesInPhysicalPort += index.count(idString);\n                }\n            }\n        }\n\n        int referencesInTieOff = portMap->getLogicalTieOff().count(idString);\n\n        totalReferencesToParameter = referencesInLogicalPort + referencesInPhysicalPort + referencesInTieOff;\n    }\n\n    return totalReferencesToParameter;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortMapInterface::getExpressionsInSelectedPortMap()\n//-----------------------------------------------------------------------------\nstd::vector<std::string> PortMapInterface::getExpressionsInSelectedPortMap(int const& portMapIndex) const\n{\n    std::vector<std::string> expressionList;\n\n    QSharedPointer<PortMap> portMap = getPortMap(portMapIndex);\n    if (portMap)\n    {\n        QSharedPointer<PortMap::LogicalPort> logicalPort = portMap->getLogicalPort();\n        if (logicalPort && logicalPort->range_)\n        {\n            expressionList.push_back(logicalPort->range_->getLeft().toStdString());\n            expressionList.push_back(logicalPort->range_->getRight().toStdString());\n        }\n\n        QSharedPointer<PortMap::PhysicalPort> physicalPort = portMap->getPhysicalPort();\n        if (physicalPort && physicalPort->partSelect_)\n        {\n            QSharedPointer<PartSelect> physicalPart = physicalPort->partSelect_;\n\n            expressionList.push_back(physicalPart->getLeftRange().toStdString());\n            expressionList.push_back(physicalPart->getRightRange().toStdString());\n\n            if (physicalPart->getIndices())\n            {\n                for (auto index : *physicalPart->getIndices())\n                {\n                    expressionList.push_back(index.toStdString());\n                }\n            }\n        }\n\n        expressionList.push_back(portMap->getLogicalTieOff().toStdString());\n    }\n\n    return expressionList;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortMapInterface::validateItems()\n//-----------------------------------------------------------------------------\nbool PortMapInterface::validateItems() const\n{\n    return std::all_of(portMaps_->cbegin(), portMaps_->cend(),\n        [this](auto const& portMap) { return validator_->validate(portMap); });\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortMapInterface::logicalPortIsValid()\n//-----------------------------------------------------------------------------\nbool PortMapInterface::logicalPortIsValid(int const& portMapIndex) const\n{\n    QSharedPointer<PortMap> validatedPortMap = getPortMap(portMapIndex);\n    if (validatedPortMap)\n    {\n        return validator_->hasValidLogicalPort(validatedPortMap->getLogicalPort());\n    }\n\n    return false;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortMapInterface::physicalPortIsValid()\n//-----------------------------------------------------------------------------\nbool PortMapInterface::physicalPortIsValid(int const& portMapIndex) const\n{\n    QSharedPointer<PortMap> validatedPortMap = getPortMap(portMapIndex);\n    if (validatedPortMap)\n    {\n        return validator_->hasValidPhysicalPort(validatedPortMap->getPhysicalPort());\n    }\n\n    return false;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortMapInterface::physicalPortIsValid()\n//-----------------------------------------------------------------------------\nbool PortMapInterface::physicalMappingIsValid(int const& portMapIndex) const\n{\n    QSharedPointer<PortMap> validatedPortMap = getPortMap(portMapIndex);\n    if (validatedPortMap)\n    {\n        return validator_->hasValidPhysicalMapping(validatedPortMap);\n    }\n\n    return false;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortMapInterface::connectedPortsHaveValidPortTypes()\n//-----------------------------------------------------------------------------\nbool PortMapInterface::connectedPortsHaveValidPortTypes(int const& portMapIndex) const\n{\n    QSharedPointer<PortMap> validatedPortMap = getPortMap(portMapIndex);\n    if (validatedPortMap)\n    {\n        std::string physicalPortName(getPhysicalPortName(portMapIndex));\n        std::string logicalPortName(getLogicalPortName(portMapIndex));\n\n        QSharedPointer<Port> physicalPortPointer = physicalPortInterface_->getPort(physicalPortName);\n        QSharedPointer<PortAbstraction> logicalPortPointer = logicalPortInterface_->getPort(logicalPortName);\n\n        return validator_->connectedPortsHaveValidPortTypes(logicalPortPointer, physicalPortPointer);\n    }\n\n    return false;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortMapInterface::connectedPortsHaveValidDirections()\n//-----------------------------------------------------------------------------\nbool PortMapInterface::connectedPortsHaveValidDirections(int const& portMapIndex) const\n{\n    QSharedPointer<PortMap> validatedPortMap = getPortMap(portMapIndex);\n    if (validatedPortMap)\n    {\n        std::string physicalPortName(getPhysicalPortName(portMapIndex));\n        std::string logicalPortName(getLogicalPortName(portMapIndex));\n\n        QSharedPointer<Port> physicalPortPointer = physicalPortInterface_->getPort(physicalPortName);\n        QSharedPointer<PortAbstraction> logicalPortPointer = logicalPortInterface_->getPort(logicalPortName);\n\n        return validator_->connectedPortsHaveValidDirections(logicalPortPointer, physicalPortPointer);\n    }\n\n    return false;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortMapInterface::connectedPortsHaveValidInitiatives()\n//-----------------------------------------------------------------------------\nbool PortMapInterface::connectedPortsHaveValidInitiatives(int const& portMapIndex) const\n{\n    QSharedPointer<PortMap> validatedPortMap = getPortMap(portMapIndex);\n    if (validatedPortMap)\n    {\n        std::string physicalPortName(getPhysicalPortName(portMapIndex));\n        std::string logicalPortName(getLogicalPortName(portMapIndex));\n\n        QSharedPointer<Port> physicalPortPointer = physicalPortInterface_->getPort(physicalPortName);\n        QSharedPointer<PortAbstraction> logicalPortPointer = logicalPortInterface_->getPort(logicalPortName);\n\n        return validator_->connectedPortsHaveValidInitiatives(logicalPortPointer, physicalPortPointer);\n    }\n\n    return false;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortMapInterface::connectedPortsHaveSameRange()\n//-----------------------------------------------------------------------------\nbool PortMapInterface::connectedPortsHaveSameRange(int const& portMapIndex) const\n{\n    QSharedPointer<PortMap> validatedPortMap = getPortMap(portMapIndex);\n    if (validatedPortMap)\n    {\n        return validator_->connectedPortsHaveSameRange(\n            validatedPortMap->getLogicalPort()->range_, validatedPortMap->getPhysicalPort()->partSelect_);\n    }\n\n    return false;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortMapInterface::tieOffIsValid()\n//-----------------------------------------------------------------------------\nbool PortMapInterface::tieOffIsValid(int const& portMapIndex) const\n{\n    QSharedPointer<PortMap> validatedPortMap = getPortMap(portMapIndex);\n    if (validatedPortMap)\n    {\n        return validator_->hasValidTieOff(validatedPortMap->getLogicalTieOff());\n    }\n\n    return false;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortMapInterface::logicalPortHasValidRange()\n//-----------------------------------------------------------------------------\nbool PortMapInterface::logicalPortHasValidRange(int const& portMapIndex) const\n{\n    QSharedPointer<PortMap> validatedPortMap = getPortMap(portMapIndex);\n    if (validatedPortMap && validatedPortMap->getLogicalPort())\n    {\n        std::string logicalPortName(getLogicalPortName(portMapIndex));\n\n        QSharedPointer<PortAbstraction> logicalPortPointer = logicalPortInterface_->getPort(logicalPortName);\n        validator_->logicalPortHasValidRange(validatedPortMap->getLogicalPort()->range_, logicalPortPointer);\n    }\n\n    return false;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortMapInterface::getComponentInstantiation()\n//-----------------------------------------------------------------------------\nQSharedPointer<PortMap> PortMapInterface::getPortMap(int const& portMapIndex) const\n{\n    if (portMaps_ && portMapIndex >= 0 && portMapIndex < portMaps_->size())\n    {\n        return portMaps_->at(portMapIndex);\n    }\n\n    return QSharedPointer<PortMap>();\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortMapInterface::mapPorts()\n//-----------------------------------------------------------------------------\nbool PortMapInterface::connectPorts(std::string const& logicalPortName, std::string const& physicalPortName)\n{\n    std::string interfaceMode(General::interfaceMode2Str(interfaceMode_).toStdString());\n    std::string systemGroup(systemGroup_);\n\n    if (logicalPortName.empty() || physicalPortName.empty() ||\n        !logicalPortInterface_->portHasMode(logicalPortName, interfaceMode, systemGroup) ||\n        !physicalPortInterface_->portExists(physicalPortName))\n    {\n        return false;\n    }\n\n    QSharedPointer<PortMap> newPortMap = getUnconnectedPortMap(logicalPortName);\n    if (!newPortMap)\n    {\n        return false;\n    }\n\n    QSharedPointer<PortMap::PhysicalPort> newMappedPhysical(\n        new PortMap::PhysicalPort(QString::fromStdString(physicalPortName)));\n    \n    QSharedPointer<PortMap::LogicalPort> newMappedLogical = newPortMap->getLogicalPort();\n\n    QString logicalWireWidth(QString::fromStdString(\n        logicalPortInterface_->getWidthValue(logicalPortName, General::str2Interfacemode(QString::fromStdString(interfaceMode), \n            General::InterfaceMode::INTERFACE_MODE_COUNT), systemGroup)));\n    if (!logicalWireWidth.isEmpty())\n    {\n        qint64 logicalSize = parseExpressionToDecimal(logicalWireWidth).toInt();\n        qint64 logicalLeft = logicalSize - 1;\n        qint64 logicalRight = 0;\n\n        qint64 physicalLeft = 0;\n        std::string leftValue(physicalPortInterface_->getLeftBoundValue(physicalPortName));\n        if (!leftValue.empty())\n        {\n            physicalLeft = std::stoll(leftValue);\n        }\n\n        qint64 physicalRight = 0;\n        std::string rightValue(physicalPortInterface_->getRightBoundValue(physicalPortName));\n        if (!rightValue.empty())\n        {\n            physicalRight = std::stoi(rightValue);\n        }\n\n        qint64 physicalSize = abs(physicalLeft - physicalRight) + 1;\n        \n        if (logicalSize != physicalSize)\n        {\n            if (physicalSize < logicalSize)\n            {\n                logicalLeft = logicalRight + physicalSize - 1;\n            }\n            else\n            {\n                if (physicalLeft < physicalRight)\n                {\n                    physicalRight = physicalLeft + logicalSize - 1;\n                }\n                else\n                {\n                    physicalLeft = physicalRight + logicalSize - 1;\n                }\n            }\n        }\n        \n        newMappedLogical->range_ = QSharedPointer<Range>(\n            new Range(QString::number(logicalLeft), QString::number(logicalRight)));\n        \n        newMappedPhysical->partSelect_ = QSharedPointer<PartSelect>(\n            new PartSelect(QString::number(physicalLeft), QString::number(physicalRight)));\n    }\n    \n    newPortMap->setPhysicalPort(newMappedPhysical);\n\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortMapInterface::getUnconnectedPortMap()\n//-----------------------------------------------------------------------------\nQSharedPointer<PortMap> PortMapInterface::getUnconnectedPortMap(std::string const& logicalPortName) const\n{\n    for (int i = 0; i < itemCount(); ++i)\n    {\n        if (getLogicalPortName(i) == logicalPortName && getPhysicalPortName(i).empty() &&\n            getLogicalTieOffValue(i).empty())\n        {\n            return getPortMap(i);\n        }\n    }\n\n    return QSharedPointer<PortMap>();\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortMapInterface::addPortMap()\n//-----------------------------------------------------------------------------\nvoid PortMapInterface::addPortMap(int const& row)\n{\n    QSharedPointer<PortMap> newPortMap(new PortMap());\n    portMaps_->insert(row, newPortMap);\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortMapInterface::removePortMap()\n//-----------------------------------------------------------------------------\nbool PortMapInterface::removePortMap(int const& portMapIndex)\n{\n    QSharedPointer<PortMap> removedPortMap = getPortMap(portMapIndex);\n    if (removedPortMap)\n    {\n        portMaps_->removeAll(removedPortMap);\n        return true;\n    }\n\n    return false;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortMapInterface::removeAllPortMapsFromLogicalPort()\n//-----------------------------------------------------------------------------\nstd::vector<std::string> PortMapInterface::removeAllPortMapsFromLogicalPort(std::string const& logicalPortName)\n{\n    std::vector<std::string> removedPhysicals;\n    for (int i = itemCount() - 1; i >= 0; --i)\n    {\n        if (logicalPortName == getLogicalPortName(i))\n        {\n            std::string connectedPhysical(getPhysicalPortName(i));\n            if (std::find(removedPhysicals.cbegin(), removedPhysicals.cend(), connectedPhysical) == removedPhysicals.cend())\n            {\n                removedPhysicals.push_back(connectedPhysical);\n            }\n\n            removePortMap(i);\n        }\n    }\n\n    return removedPhysicals;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortMapInterface::getPortMapPointer()\n//-----------------------------------------------------------------------------\nPortMap* PortMapInterface::getPortMapPointer(int const& portMapIndex) const\n{\n    PortMap* portMapPointer = nullptr;\n    if (portMapIndex >= 0 && portMapIndex < itemCount())\n    {\n        portMapPointer = portMaps_->at(portMapIndex).data();\n    }\n\n    return portMapPointer;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortMapInterface::getPhysicalPortInterface()\n//-----------------------------------------------------------------------------\nPortsInterface* PortMapInterface::getPhysicalPortInterface() const\n{\n    return physicalPortInterface_;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortMapInterface::getLogicalPortInterface()\n//-----------------------------------------------------------------------------\nPortAbstractionInterface* PortMapInterface::getLogicalPortInterface() const\n{\n    return logicalPortInterface_;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortMapInterface::createRequiredSignals()\n//-----------------------------------------------------------------------------\nvoid PortMapInterface::createRequiredSignals()\n{\n    createPortMapsWithPresence(PresenceTypes::REQUIRED);\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortMapInterface::createOptionalSignals()\n//-----------------------------------------------------------------------------\nvoid PortMapInterface::createOptionalSignals()\n{\n    createPortMapsWithPresence(PresenceTypes::OPTIONAL | PresenceTypes::UNKNOWN);\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortMapInterface::createAllSignals()\n//-----------------------------------------------------------------------------\nvoid PortMapInterface::createAllSignals()\n{\n    createPortMapsWithPresence(PresenceTypes::ALL);\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortMapInterface::createPortMapsWithPresence()\n//-----------------------------------------------------------------------------\nvoid PortMapInterface::createPortMapsWithPresence(int presence)\n{\n    std::string busMode = General::interfaceMode2Str(interfaceMode_).toStdString();\n    \n    std::vector<std::string> logicalSignals;\n\n    for (auto const& signalName : logicalPortInterface_->getItemNamesWithModeAndGroup(busMode, systemGroup_))\n    {\n        bool notFound = std::find(logicalSignals.cbegin(), logicalSignals.cend(), signalName) == logicalSignals.cend();\n        bool protMapDoesNotExist = !portMapExistsForLogicalSignal(signalName);\n        PresenceTypes::Presence portPresence = logicalPortInterface_->getPresence(signalName, busMode, systemGroup_);\n\n        if (notFound && protMapDoesNotExist &&\n            (presence == PresenceTypes::ALL || ((presence & portPresence) != 0) )) // AND for checking combined presence\n        {\n            logicalSignals.push_back(signalName);\n        }\n    }\n\n    int newPortMapIndex = itemCount();\n    for (auto const& signalName : logicalSignals)\n    {\n        addPortMap(newPortMapIndex);\n        setLogicalPort(newPortMapIndex, signalName);\n\n        newPortMapIndex++;\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortMapInterface::portMapExistsForLogicalSignal()\n//-----------------------------------------------------------------------------\nbool PortMapInterface::portMapExistsForLogicalSignal(std::string const& signalName) const\n{\n    for (int i = 0; i < itemCount(); ++i)\n    {\n        if (getLogicalPortName(i) == signalName)\n        {\n            return true;\n        }\n    }\n\n    return false;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortMapInterface::getInterfaceMode()\n//-----------------------------------------------------------------------------\nGeneral::InterfaceMode PortMapInterface::getInterfaceMode() const\n{\n    return interfaceMode_;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortMapInterface::getSystemGroup()\n//-----------------------------------------------------------------------------\nstd::string PortMapInterface::getSystemGroup() const\n{\n    return systemGroup_;\n}\n"
  },
  {
    "path": "KactusAPI/interfaces/component/PortsInterface.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: PortsInterface.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 25.02.2020\n//\n// Description:\n// Interface for editing component ports.\n//-----------------------------------------------------------------------------\n\n#include <PortsInterface.h>\n\n#include <IPXACTmodels/common/TransactionalTypes.h>\n#include <IPXACTmodels/common/Vector.h>\n\n#include <IPXACTmodels/Component/Port.h>\n#include <IPXACTmodels/Component/validators/PortValidator.h>\n\n#include <IPXACTmodels/utilities/Search.h>\n\n#include <KactusAPI/include/ListHelper.h>\n\n//-----------------------------------------------------------------------------\n// Function: PortsInterface::PortsInterface()\n//-----------------------------------------------------------------------------\nPortsInterface::PortsInterface(QSharedPointer<PortValidator> validator,\n    QSharedPointer<ExpressionParser> expressionParser, QSharedPointer<ExpressionFormatter> expressionFormatter):\nParameterizableInterface(expressionParser, expressionFormatter),\nMasterPortInterface(),\nportValidator_(validator)\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortsInterface::setPorts()\n//-----------------------------------------------------------------------------\nvoid PortsInterface::setPorts(Port::List ports)\n{\n    ports_ = ports;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortsInterface::hasPorts()\n//-----------------------------------------------------------------------------\nbool PortsInterface::hasPorts() const\n{\n    return ports_ && itemCount() > 0;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortsInterface::getPortIndex()\n//-----------------------------------------------------------------------------\nint PortsInterface::getItemIndex(std::string const& itemName) const\n{\n    return ListHelper::itemIndex(itemName, ports_);\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortsInterface::getIndexedPortName()\n//-----------------------------------------------------------------------------\nstd::string PortsInterface::getIndexedItemName(int itemIndex) const\n{\n    if (itemIndex >= 0 && itemIndex < ports_->size())\n    {\n        return ports_->at(itemIndex)->name().toStdString();\n    }\n\n    return std::string();\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortsInterface::itemCount()\n//-----------------------------------------------------------------------------\nint PortsInterface::itemCount() const\n{\n    return ports_->count();\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortsInterface::getItemNames()\n//-----------------------------------------------------------------------------\nstd::vector<std::string> PortsInterface::getItemNames() const\n{\n    return ListHelper::listNames(ports_);\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortsInterface::getPort()\n//-----------------------------------------------------------------------------\nQSharedPointer<Port> PortsInterface::getPort(std::string const& portName) const\n{\n    return Search::findByName(QString::fromStdString(portName), ports_);\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortsInterface::getItem()\n//-----------------------------------------------------------------------------\nQSharedPointer<NameGroup> PortsInterface::getItem(std::string const& portName) const\n{\n    return getPort(portName);\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortsInterface::setName()\n//-----------------------------------------------------------------------------\nbool PortsInterface::setName(std::string const& currentPortName, std::string const& newPortName)\n{\n    QSharedPointer<Port> editedPort = getPort(currentPortName);\n    if (editedPort && nameHasChanged(newPortName, currentPortName))\n    {\n        QString uniqueNewName(getUniqueName(newPortName, \"port\"));\n\n        editedPort->setName(uniqueNewName);\n        return true;\n    }\n    else\n    {\n        return false;\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortsInterface::getTypeName()\n//-----------------------------------------------------------------------------\nstd::string PortsInterface::getTypeName(std::string const& portName) const\n{\n    QSharedPointer<Port> port = getPort(portName);\n\n    QSharedPointer<QList<QSharedPointer<WireTypeDef> > > definitionList;\n    if (port->getWire())\n    {\n        definitionList = port->getWire()->getWireTypeDefs();\n    }\n    else if (port->getTransactional())\n    {\n        definitionList = port->getTransactional()->getTransTypeDef();\n    }\n\n    if (!definitionList)\n    {\n        return std::string();\n    }\n\n    if (definitionList->count() == 1)\n    {\n        return definitionList->first()->getTypeName().toStdString();\n    }\n    else\n    {\n        std::string combinedType;\n        for (auto const& typeDefinition : *definitionList)\n        {\n            combinedType.append(typeDefinition->getTypeName().toStdString());\n            if (typeDefinition != definitionList->last())\n            {\n                combinedType.append(\", \");\n            }\n        }\n\n        return combinedType;\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortsInterface::getTypeNameViews()\n//-----------------------------------------------------------------------------\nstd::vector<std::pair<std::string, std::vector<std::string> > > PortsInterface::getTypeNameViews(std::string const& portName) const\n{\n    using namespace std;\n    vector<pair<string, vector<string> > > typeNameViews;\n\n    QSharedPointer<Port> port = getPort(portName);\n    if (!port)\n    {\n        return typeNameViews;\n    }\n\n    QSharedPointer<QList<QSharedPointer<WireTypeDef> > > portTypeDefs;\n\n    if (auto wire = port->getWire())\n    {\n        portTypeDefs = wire->getWireTypeDefs();\n    }\n    else if (auto transactional = port->getTransactional())\n    {\n        portTypeDefs = transactional->getTransTypeDef();\n    }\n    else\n    {\n        return typeNameViews;\n    }\n\n    for (auto const& wireTypeDef : *portTypeDefs)\n    {\n        pair<string, vector<string> > singleType;\n        singleType.first = wireTypeDef->getTypeName().toStdString();\n\n        for (auto const& view : *wireTypeDef->getViewRefs())\n        {\n            singleType.second.push_back(view.toStdString());\n        }\n        typeNameViews.push_back(singleType);\n    }\n\n    return typeNameViews;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortsInterface::getTypeDefinitions()\n//-----------------------------------------------------------------------------\nstd::vector<std::pair<std::string, std::vector<std::string> > > PortsInterface::getTypeDefinitions(std::string const& portName) const\n{\n    using namespace std;\n    vector<pair<string, vector<string> > > typeNameDefinitions;\n\n    QSharedPointer<Port> port = getPort(portName);\n    if (!port)\n    {\n        return typeNameDefinitions;\n    }\n\n    QSharedPointer<QList<QSharedPointer<WireTypeDef> > > portTypeDefs;\n\n    if (auto wire = port->getWire())\n    {\n        portTypeDefs = wire->getWireTypeDefs();\n    }\n    else if (auto transactional = port->getTransactional())\n    {\n        portTypeDefs = transactional->getTransTypeDef();\n    }\n    else\n    {\n        return typeNameDefinitions;\n    }\n\n    for (auto const& wireTypeDef : *portTypeDefs)\n    {\n        pair<string, vector<string> > singleType;\n        singleType.first = wireTypeDef->getTypeName().toStdString();\n\n        for (auto const& typeDef : *wireTypeDef->getTypeDefinitions())\n        {\n            singleType.second.push_back(typeDef.toStdString());\n        }\n\n        typeNameDefinitions.push_back(singleType);\n    }\n\n    return typeNameDefinitions;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortsInterface::setTypeNameViews()\n//-----------------------------------------------------------------------------\nbool PortsInterface::setTypeDefViewRefs(std::string const& portName, std::vector<std::pair<std::string, std::vector<std::string> > > const& typeNameViews)\n{\n    QSharedPointer<Port> port = getPort(portName);\n    if (!port)\n    {\n        return false;\n    }\n\n    QSharedPointer<QList<QSharedPointer<WireTypeDef> > > portTypeDefs;\n\n    if (auto wire = port->getWire())\n    {\n        portTypeDefs = wire->getWireTypeDefs();\n    }\n    else if (auto transactional = port->getTransactional())\n    {\n        portTypeDefs = transactional->getTransTypeDef();\n    }\n    else\n    {\n        return false;\n    }\n\n    if (typeNameViews.empty())\n    {\n        portTypeDefs->clear();\n        return true;\n    }\n\n    for (auto const& [typeName, views] : typeNameViews)\n    {\n        auto typeNameQ = QString::fromStdString(typeName);\n\n        auto found_it = std::find_if(portTypeDefs->begin(), portTypeDefs->end(), \n            [&typeNameQ](QSharedPointer<WireTypeDef> wireTypeDef)\n            {\n                return wireTypeDef->getTypeName() == typeNameQ;\n            });\n\n        // Create new type def if not existing.\n        if (found_it == portTypeDefs->end())\n        {\n            QSharedPointer<WireTypeDef> newTypeDef(new WireTypeDef);\n            newTypeDef->setTypeName(typeNameQ);\n            portTypeDefs->append(newTypeDef);\n            found_it = portTypeDefs->end();\n            --found_it;\n        }\n        \n        for (auto const& view : views)\n        {\n            (*found_it)->getViewRefs()->append(QString::fromStdString(view));\n        }\n    }\n\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortsInterface::setTypeDefinitions()\n//-----------------------------------------------------------------------------\nbool PortsInterface::setTypeDefDefinitions(std::string const& portName, std::vector<std::pair<std::string, std::vector<std::string> > > const& typeDefinitions)\n{\n    QSharedPointer<Port> port = getPort(portName);\n    if (!port)\n    {\n        return false;\n    }\n\n    QSharedPointer<QList<QSharedPointer<WireTypeDef> > > portTypeDefs;\n\n    if (auto wire = port->getWire())\n    {\n        portTypeDefs = wire->getWireTypeDefs();\n    }\n    else if (auto transactional = port->getTransactional())\n    {\n        portTypeDefs = transactional->getTransTypeDef();\n    }\n    else\n    {\n        return false;\n    }\n\n    if (typeDefinitions.empty())\n    {\n        portTypeDefs->clear();\n        return true;\n    }\n\n    for (auto const& [typeName, typeDefs] : typeDefinitions)\n    {\n        auto typeNameQ = QString::fromStdString(typeName);\n\n        auto found_it = std::find_if(portTypeDefs->begin(), portTypeDefs->end(),\n            [&typeNameQ](QSharedPointer<WireTypeDef> wireTypeDef)\n            {\n                return wireTypeDef->getTypeName() == typeNameQ;\n            });\n\n        // Create new type def if not existing.\n        if (found_it == portTypeDefs->end())\n        {\n            QSharedPointer<WireTypeDef> newTypeDef(new WireTypeDef);\n            newTypeDef->setTypeName(typeNameQ);\n            portTypeDefs->append(newTypeDef);\n            found_it = portTypeDefs->end();\n            --found_it;\n        }\n\n        for (auto const& typeDef : typeDefs)\n        {\n            (*found_it)->getTypeDefinitions()->append(QString::fromStdString(typeDef));\n        }\n    }\n\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortsInterface::clearTypeDefinitions()\n//-----------------------------------------------------------------------------\nbool PortsInterface::clearTypeDefinitions(std::string const& portName)\n{\n    QSharedPointer<Port> port = getPort(portName);\n    if (!port)\n    {\n        return false;\n    }\n\n    if (auto wire = port->getWire())\n    {\n        wire->getWireTypeDefs()->clear();\n        return true;\n    }\n    else if (auto transactional = port->getTransactional())\n    {\n        transactional->getTransTypeDef()->clear();\n        return true;\n    }\n    \n    return false;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortsInterface::setTypeName()\n//-----------------------------------------------------------------------------\nbool PortsInterface::setTypeName(std::string const& portName, std::string const& newType) const\n{\n    QSharedPointer<Port> port = getPort(portName);\n    if (newType.empty())\n    {\n        if (port->getWire())\n        {\n            port->getWireTypes()->clear();\n        }\n        else\n        {\n            port->getTransactionalTypes()->clear();\n        }\n    }\n    else\n    {\n        port->setTypeName(QString::fromStdString(newType));\n\n        // update the type definition for the new type name.\n        port->setTypeDefinition(QString::fromStdString(newType), QString());\n    }\n\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortsInterface::getArrayLeftValue()\n//-----------------------------------------------------------------------------\nstd::string PortsInterface::getArrayLeftValue(std::string const& portName, unsigned int baseNumber) const\n{\n    if (QSharedPointer<Port> editedPort = getPort(portName); \n        editedPort)\n    {\n        return parseExpressionToBaseNumber(editedPort->getArrayLeft(), baseNumber).toStdString();\n    }\n\n    return std::string();\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortsInterface::getArrayLeftFormattedExpression()\n//-----------------------------------------------------------------------------\nstd::string PortsInterface::getArrayLeftFormattedExpression(std::string const& portName) const\n{\n    if (QSharedPointer<Port> editedPort = getPort(portName); \n        editedPort)\n    {\n        return formattedValueFor(editedPort->getArrayLeft()).toStdString();\n    }\n\n    return std::string();\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortsInterface::getArrayLeftExpression()\n//-----------------------------------------------------------------------------\nstd::string PortsInterface::getArrayLeftExpression(std::string const& portName) const\n{\n    if (QSharedPointer<Port> editedPort = getPort(portName); \n        editedPort)\n    {\n        return editedPort->getArrayLeft().toStdString();\n    }\n\n    return std::string();\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortsInterface::setArrayLeft()\n//-----------------------------------------------------------------------------\nbool PortsInterface::setArrayLeft(std::string const& portName, std::string const& newArrayLeft) const\n{\n    QSharedPointer<Port> editedPort = getPort(portName);\n    if (!editedPort)\n    {\n        return false;\n    }\n\n    editedPort->setArrayLeft(QString::fromStdString(newArrayLeft));\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortsInterface::getArrayRightValue()\n//-----------------------------------------------------------------------------\nstd::string PortsInterface::getArrayRightValue(std::string const& portName, unsigned int baseNumber) const\n{\n    if (QSharedPointer<Port> editedPort = getPort(portName);\n        editedPort)\n    {\n        return parseExpressionToBaseNumber(editedPort->getArrayRight(), baseNumber).toStdString();\n    }\n\n    return std::string();\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortsInterface::getArrayRight()\n//-----------------------------------------------------------------------------\nstd::string PortsInterface::getArrayRightFormattedExpression(std::string const& portName) const\n{\n    if (QSharedPointer<Port> editedPort = getPort(portName); \n        editedPort)\n    {\n        return formattedValueFor(editedPort->getArrayRight()).toStdString();\n    }\n\n    return std::string();\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortsInterface::getArrayRightExpression()\n//-----------------------------------------------------------------------------\nstd::string PortsInterface::getArrayRightExpression(std::string const& portName) const\n{\n    if (QSharedPointer<Port> editedPort = getPort(portName); \n        editedPort)\n    {\n        return editedPort->getArrayRight().toStdString();\n    }\n\n    return std::string();\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortsInterface::setArrayRight()\n//-----------------------------------------------------------------------------\nbool PortsInterface::setArrayRight(std::string const& portName, std::string const& newArrayRight) const\n{\n    QSharedPointer<Port> editedPort = getPort(portName);\n    if (!editedPort)\n    {\n        return false;\n    }\n\n    editedPort->setArrayRight(QString::fromStdString(newArrayRight));\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortsInterface::getTags()\n//-----------------------------------------------------------------------------\nstd::string PortsInterface::getTags(std::string const& portName) const\n{\n    if (QSharedPointer<Port> editedPort = getPort(portName); \n        editedPort)\n    {\n        return editedPort->getPortTags().toStdString();\n    }\n\n    return std::string();\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortsInterface::setTags()\n//-----------------------------------------------------------------------------\nbool PortsInterface::setTags(std::string const& portName, std::string const& tagList) const\n{\n    QSharedPointer<Port> editedPort = getPort(portName);\n    if (!editedPort)\n    {\n        return false;\n    }\n\n    editedPort->setPortTags(QString::fromStdString(tagList));\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortsInterface::isAdHoc()\n//-----------------------------------------------------------------------------\nbool PortsInterface::isAdHoc(std::string const& portName) const\n{\n    if (QSharedPointer<Port> editedPort = getPort(portName); \n        editedPort)\n    {\n        return editedPort->isAdHocVisible();\n    }\n\n    return false;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortsInterface::setAdHoc()\n//-----------------------------------------------------------------------------\nbool PortsInterface::setAdHoc(std::string const& portName, bool newAdHocVisibility) const\n{\n    QSharedPointer<Port> editedPort = getPort(portName);\n    if (!editedPort)\n    {\n        return false;\n    }\n\n    editedPort->setAdHocVisible(newAdHocVisibility);\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortsInterface::portIsWire()\n//-----------------------------------------------------------------------------\nbool PortsInterface::portIsWire(std::string const& portName) const\n{\n    return portIsWire(getPort(portName));\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortsInterface::portIsWire()\n//-----------------------------------------------------------------------------\nbool PortsInterface::portIsWire(QSharedPointer<Port> port) const\n{\n    return port.isNull() == false && port->getWire().isNull() == false;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortsInterface::getDirection()\n//-----------------------------------------------------------------------------\nstd::string PortsInterface::getDirection(std::string const& portName) const\n{\n    if (QSharedPointer<Port> selectedPort = getPort(portName); \n        portIsWire(selectedPort))\n    {\n        return DirectionTypes::direction2Str(selectedPort->getDirection()).toStdString();\n    }\n\n    return std::string();\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortsInterface::getDirectionType()\n//-----------------------------------------------------------------------------\nDirectionTypes::Direction PortsInterface::getDirectionType(std::string const& portName) const\n{\n    if (QSharedPointer<Port> selectedPort = getPort(portName); \n        portIsWire(selectedPort))\n    {\n        return selectedPort->getDirection();\n    }\n\n    return DirectionTypes::DIRECTION_INVALID;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortsInterface::setDirection()\n//-----------------------------------------------------------------------------\nbool PortsInterface::setDirection(std::string const& portName, std::string const& newDirection) const\n{\n    if (QSharedPointer<Port> editedPort = getPort(portName); \n        portIsWire(editedPort))\n    {\n        editedPort->setDirection(DirectionTypes::str2Direction(\n            QString::fromStdString(newDirection), DirectionTypes::DIRECTION_INVALID));\n        return true;\n    }\n    \n    return false;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortsInterface::getLeftBoundValue()\n//-----------------------------------------------------------------------------\nstd::string PortsInterface::getLeftBoundValue(std::string const& portName, unsigned int baseNumber) const\n{\n    if (QSharedPointer<Port> editedPort = getPort(portName); \n        portIsWire(editedPort))\n    {\n        if (editedPort->getWire()->getVectors()->isEmpty() == false)\n        {\n            return parseExpressionToBaseNumber(editedPort->getWire()->getVectorLeftBound(), baseNumber).toStdString();\n        }\n    }\n\n    return std::string();\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortsInterface::getLeftBoundFormattedExpression()\n//-----------------------------------------------------------------------------\nstd::string PortsInterface::getLeftBoundFormattedExpression(std::string const& portName) const\n{\n    if (QSharedPointer<Port> editedPort = getPort(portName); \n        portIsWire(editedPort))\n    {\n        if (editedPort->getWire()->getVectors()->isEmpty() == false)\n        {\n            return formattedValueFor(editedPort->getWire()->getVectorLeftBound()).toStdString();\n        }\n    }\n\n    return std::string();\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortsInterface::getLeftBoundExpression()\n//-----------------------------------------------------------------------------\nstd::string PortsInterface::getLeftBoundExpression(std::string const& portName) const\n{\n    if (QSharedPointer<Port> editedPort = getPort(portName); \n        portIsWire(editedPort))\n    {\n        if (editedPort->getWire()->getVectors()->isEmpty() == false)\n        {\n            return editedPort->getWire()->getVectorLeftBound().toStdString();\n        }\n    }\n\n    return std::string();\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortsInterface::setLeftBound()\n//-----------------------------------------------------------------------------\nbool PortsInterface::setLeftBound(std::string const& portName, std::string const& newLeftBound) const\n{\n    if (QSharedPointer<Port> editedPort = getPort(portName); \n        portIsWire(editedPort))\n    {\n        editedPort->setLeftBound(QString::fromStdString(newLeftBound));\n        setTypeNameAndDefinition(editedPort);\n        \n        return true;\n    }\n\n    return false;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortsInterface::getRightBoundValue()\n//-----------------------------------------------------------------------------\nstd::string PortsInterface::getRightBoundValue(std::string const& portName, unsigned int baseNumber) const\n{\n    if (QSharedPointer<Port> editedPort = getPort(portName); \n        portIsWire(editedPort))\n    {\n        if (editedPort->getWire()->getVectors()->isEmpty() == false)\n        {\n            return parseExpressionToBaseNumber(editedPort->getWire()->getVectorRightBound(), baseNumber).toStdString();\n        }\n    }\n\n    return std::string();\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortsInterface::getRightBoundFormattedExpression()\n//-----------------------------------------------------------------------------\nstd::string PortsInterface::getRightBoundFormattedExpression(std::string const& portName) const\n{\n    if (QSharedPointer<Port> editedPort = getPort(portName); \n        portIsWire(editedPort))\n    {\n        if (editedPort->getWire()->getVectors()->isEmpty() == false)\n        {\n            return formattedValueFor(editedPort->getWire()->getVectorRightBound()).toStdString();\n        }\n    }\n\n    return std::string();\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortsInterface::getRightBoundExpression()\n//-----------------------------------------------------------------------------\nstd::string PortsInterface::getRightBoundExpression(std::string const& portName) const\n{\n    if (QSharedPointer<Port> editedPort = getPort(portName); \n        portIsWire(editedPort))\n    {\n        if (editedPort->getWire()->getVectors()->isEmpty() == false)\n        {\n            return editedPort->getWire()->getVectorRightBound().toStdString();\n        }\n    }\n\n    return std::string();\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortsInterface::setRightBound()\n//-----------------------------------------------------------------------------\nbool PortsInterface::setRightBound(std::string const& portName, std::string const& newRightBound) const\n{\n    if (QSharedPointer<Port> editedPort = getPort(portName); \n        portIsWire(editedPort))\n    {\n        editedPort->setRightBound(QString::fromStdString(newRightBound));\n        setTypeNameAndDefinition(editedPort);\n\n        return true;\n    }\n\n    return false;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortsInterface::getWidth()\n//-----------------------------------------------------------------------------\nstd::string PortsInterface::getWidth(std::string const& portName) const\n{\n    QSharedPointer<Port> port = getPort(portName);\n\n    qint64 calculatedLeftBound = parseExpressionToDecimal(port->getLeftBound()).toULongLong();\n    qint64 calculatedRightBound = parseExpressionToDecimal(port->getRightBound()).toULongLong();\n\n    qint64 portWidth = abs(calculatedLeftBound - calculatedRightBound) + 1;\n    return QString::number(portWidth).toStdString();\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortsInterface::setWidth()\n//-----------------------------------------------------------------------------\nbool PortsInterface::setWidth(std::string const& portName, std::string const& newWidth) const\n{\n    if (hasExpressionInLeftOrRightBound(portName))\n    {\n        return false;\n    }\n\n    int size = parseExpressionToDecimal(QString::fromStdString(newWidth)).toInt();\n\n    QSharedPointer<Port> port = getPort(portName);\n    port->setPortSize(size);\n\n    setTypeNameAndDefinition(port);\n\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortsInterface::hasExpressionInLeftOrRightBound()\n//-----------------------------------------------------------------------------\nbool PortsInterface::hasExpressionInLeftOrRightBound(std::string const& portName) const\n{\n    QString left(QString::fromStdString(getLeftBoundValue(portName)));\n    QString right(QString::fromStdString(getRightBoundValue(portName)));\n\n    if (left.isEmpty() && right.isEmpty())\n    {\n        return false;\n    }\n\n    bool leftNumber = false;\n    bool rightNumber = false;\n\n    left.toLongLong(&leftNumber);\n    right.toLongLong(&rightNumber);\n\n    return leftNumber || rightNumber;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortsInterface::setTypeNameAndDefinition()\n//-----------------------------------------------------------------------------\nvoid PortsInterface::setTypeNameAndDefinition(QSharedPointer<Port> port) const\n{\n    qint64 calculatedLeftBound = parseExpressionToDecimal(port->getLeftBound()).toLongLong();\n    qint64 calculatedRightBound = parseExpressionToDecimal(port->getRightBound()).toLongLong();\n\n    auto portWidth = abs(calculatedLeftBound - calculatedRightBound) + 1;\n    // if port is vectored and previous type was std_logic\n    if (portWidth > 1 && port->getTypeName() == QString(\"std_logic\"))\n    {\n        // change the type to vectored\n        port->setTypeName(\"std_logic_vector\");\n        port->setTypeDefinition(\"std_logic_vector\", \"IEEE.std_logic_1164.all\");\n    }\n    // if port is not vectored but previous type was std_logic_vector\n    else if (portWidth < 2 && port->getTypeName() == QString(\"std_logic_vector\"))\n    {\n        port->setTypeName(QStringLiteral(\"std_logic\"));\n        port->setTypeDefinition(QStringLiteral(\"std_logic\"), \"IEEE.std_logic_1164.all\");\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortsInterface::getDefaultValue()\n//-----------------------------------------------------------------------------\nstd::string PortsInterface::getDefaultValue(std::string const& portName, unsigned int baseNumber) const\n{\n    if (QSharedPointer<Port> editedPort = getPort(portName); \n        portIsWire(editedPort))\n    {\n        return parseExpressionToBaseNumber(\n            editedPort->getWire()->getDefaultDriverValue(), baseNumber).toStdString();\n    }\n\n    return std::string();\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortsInterface::getDefaultValueFormattedExpression()\n//-----------------------------------------------------------------------------\nstd::string PortsInterface::getDefaultValueFormattedExpression(std::string const& portName) const\n{\n    if (QSharedPointer<Port> editedPort = getPort(portName); \n        portIsWire(editedPort))\n    {\n        return formattedValueFor(editedPort->getWire()->getDefaultDriverValue()).toStdString();\n    }\n\n    return std::string();\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortsInterface::getDefaultValueExpression()\n//-----------------------------------------------------------------------------\nstd::string PortsInterface::getDefaultValueExpression(std::string const& portName) const\n{\n    if (QSharedPointer<Port> editedPort = getPort(portName); \n        portIsWire(editedPort))\n    {\n        return editedPort->getWire()->getDefaultDriverValue().toStdString();\n    }\n\n    return std::string();\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortsInterface::setDefaultValue()\n//-----------------------------------------------------------------------------\nbool PortsInterface::setDefaultValue(std::string const& portName, std::string const& newDefaultValue) const\n{\n    if (QSharedPointer<Port> editedPort = getPort(portName); \n        portIsWire(editedPort))\n    {\n        editedPort->getWire()->setDefaultDriverValue(QString::fromStdString(newDefaultValue));\n        return true;\n    }\n\n    return false;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortsInterface::portIsTransactional()\n//-----------------------------------------------------------------------------\nbool PortsInterface::portIsTransactional(std::string const& portName) const\n{\n    return portIsTransactional(getPort(portName));\n}\n//-----------------------------------------------------------------------------\n// Function: PortsInterface::portIsTransactional()\n//-----------------------------------------------------------------------------\nbool PortsInterface::portIsTransactional(QSharedPointer<Port> port) const\n{\n    return port.isNull() == false && port->getTransactional().isNull() == false;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortsInterface::getBusWidthValue()\n//-----------------------------------------------------------------------------\nstd::string PortsInterface::getBusWidthValue(std::string const& portName, unsigned int baseNumber) const\n{\n    QSharedPointer<Port> editedPort = getPort(portName);\n    if (portIsTransactional(editedPort))\n    {\n        return\n            parseExpressionToBaseNumber(editedPort->getTransactional()->getBusWidth(), baseNumber).toStdString();\n    }\n\n    return std::string();\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortsInterface::getBusWidth()\n//-----------------------------------------------------------------------------\nstd::string PortsInterface::getBusWidthFormattedExpression(std::string const& portName) const\n{\n    if (QSharedPointer<Port> editedPort = getPort(portName); \n        portIsTransactional(editedPort))\n    {\n        return formattedValueFor(editedPort->getTransactional()->getBusWidth()).toStdString();\n    }\n\n    return std::string();\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortsInterface::getBusWidthExpression()\n//-----------------------------------------------------------------------------\nstd::string PortsInterface::getBusWidthExpression(std::string const& portName) const\n{\n    if (QSharedPointer<Port> editedPort = getPort(portName); \n        portIsTransactional(editedPort))\n    {\n        return editedPort->getTransactional()->getBusWidth().toStdString();\n    }\n\n    return std::string();\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortsInterface::setBusWidth()\n//-----------------------------------------------------------------------------\nbool PortsInterface::setBusWidth(std::string const& portName, std::string const& newBusWidth) const\n{\n    if (QSharedPointer<Port> editedPort = getPort(portName); \n        portIsTransactional(editedPort))\n    {\n        editedPort->getTransactional()->setBusWidth(QString::fromStdString(newBusWidth));\n        return true;\n    }\n\n    return false;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortsInterface::getInitiative()\n//-----------------------------------------------------------------------------\nstd::string PortsInterface::getInitiative(std::string const& portName) const\n{\n    if (QSharedPointer<Port> editedPort = getPort(portName); \n        portIsTransactional(editedPort))\n    {\n        return editedPort->getTransactional()->getInitiative().toStdString();\n    }\n\n    return std::string();\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortsInterface::setInitiative()\n//-----------------------------------------------------------------------------\nbool PortsInterface::setInitiative(std::string const& portName, std::string const& newInitiative) const\n{\n    if (QSharedPointer<Port> editedPort = getPort(portName); \n        portIsTransactional(editedPort))\n    {\n        editedPort->getTransactional()->setInitiative(QString::fromStdString(newInitiative));\n        return true;\n    }\n\n    return false;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortsInterface::getKind()\n//-----------------------------------------------------------------------------\nstd::string PortsInterface::getKind(std::string const& portName) const\n{\n    if (QSharedPointer<Port> editedPort = getPort(portName); \n        portIsTransactional(editedPort))\n    {\n        return editedPort->getTransactional()->getKind().toStdString();\n    }\n\n    return std::string();\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortsInterface::setKind()\n//-----------------------------------------------------------------------------\nbool PortsInterface::setKind(std::string const& portName, std::string const& newKind) const\n{\n    if (QSharedPointer<Port> editedPort = getPort(portName); \n        portIsTransactional(editedPort))\n    {\n        editedPort->getTransactional()->setKind(QString::fromStdString(newKind));\n        return true;\n    }\n\n    return false;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortsInterface::getProtocolType()\n//-----------------------------------------------------------------------------\nstd::string PortsInterface::getProtocolType(std::string const& portName) const\n{\n    if (QSharedPointer<Port> editedPort = getPort(portName); \n        portIsTransactional(editedPort))\n    {\n        QSharedPointer<Protocol> portProtocol = editedPort->getTransactional()->getProtocol();\n        if (portProtocol)\n        {\n            return portProtocol->getProtocolType().toStdString();\n        }\n    }\n\n    return std::string();\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortsInterface::setProtocolType()\n//-----------------------------------------------------------------------------\nbool PortsInterface::setProtocolType(std::string const& portName, std::string const& newProtocolType) const\n{\n    if (QSharedPointer<Port> editedPort = getPort(portName); \n        portIsTransactional(editedPort))\n    {\n        QSharedPointer<Protocol> portProtocol = editedPort->getTransactional()->getProtocol();\n        if (!portProtocol)\n        {\n            portProtocol = QSharedPointer<Protocol>(new Protocol());\n            editedPort->getTransactional()->setProtocol(portProtocol);\n        }\n\n        portProtocol->setProtocolType(QString::fromStdString(newProtocolType));\n        return true;\n    }\n\n    return false;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortsInterface::getMaxConnectionsValue()\n//-----------------------------------------------------------------------------\nstd::string PortsInterface::getMaxConnectionsValue(std::string const& portName, unsigned int baseNumber) const\n{\n    QSharedPointer<Port> editedPort = getPort(portName);\n    if (portIsTransactional(editedPort))\n    {\n        return parseExpressionToBaseNumber(\n            editedPort->getTransactional()->getMaxConnections(), baseNumber).toStdString();\n    }\n\n    return std::string();\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortsInterface::getMaxConnections()\n//-----------------------------------------------------------------------------\nstd::string PortsInterface::getMaxConnectionsFormattedExpression(std::string const& portName) const\n{\n    if (QSharedPointer<Port> editedPort = getPort(portName); \n        portIsTransactional(editedPort))\n    {\n        return formattedValueFor(editedPort->getTransactional()->getMaxConnections()).toStdString();\n    }\n\n    return std::string();\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortsInterface::getMaxConnectionsExpression()\n//-----------------------------------------------------------------------------\nstd::string PortsInterface::getMaxConnectionsExpression(std::string const& portName) const\n{\n    if (QSharedPointer<Port> editedPort = getPort(portName); \n        portIsTransactional(editedPort))\n    {\n        return editedPort->getTransactional()->getMaxConnections().toStdString();\n    }\n\n    return std::string();\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortsInterface::setMaxConnections()\n//-----------------------------------------------------------------------------\nbool PortsInterface::setMaxConnections(std::string const& portName, std::string const& newMaxConnections) const\n{\n    if (QSharedPointer<Port> editedPort = getPort(portName); \n        portIsTransactional(editedPort))\n    {\n        editedPort->getTransactional()->setMaxConnections(QString::fromStdString(newMaxConnections));\n        return true;\n    }\n\n    return false;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortsInterface::getMinConnectionsValue()\n//-----------------------------------------------------------------------------\nstd::string PortsInterface::getMinConnectionsValue(std::string const& portName, unsigned int baseNumber) const\n{\n    if (QSharedPointer<Port> editedPort = getPort(portName); \n        portIsTransactional(editedPort))\n    {\n        return parseExpressionToBaseNumber(\n            editedPort->getTransactional()->getMinConnections(), baseNumber).toStdString();\n    }\n\n    return std::string();\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortsInterface::getMinConnections()\n//-----------------------------------------------------------------------------\nstd::string PortsInterface::getMinConnectionsFormattedExpression(std::string const& portName) const\n{\n    if (QSharedPointer<Port> editedPort = getPort(portName); \n        portIsTransactional(editedPort))\n    {\n        return formattedValueFor(editedPort->getTransactional()->getMinConnections()).toStdString();\n    }\n\n    return std::string();\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortsInterface::getMinConnectionsExpression()\n//-----------------------------------------------------------------------------\nstd::string PortsInterface::getMinConnectionsExpression(std::string const& portName) const\n{\n   if (QSharedPointer<Port> editedPort = getPort(portName); \n       portIsTransactional(editedPort))\n    {\n        return editedPort->getTransactional()->getMinConnections().toStdString();\n    }\n\n    return std::string();\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortsInterface::setMinConnections()\n//-----------------------------------------------------------------------------\nbool PortsInterface::setMinConnections(std::string const& portName, std::string const& newMinConnections) const\n{\n    if (QSharedPointer<Port> editedPort = getPort(portName);\n        portIsTransactional(editedPort))\n    {\n        editedPort->getTransactional()->setMinConnections(QString::fromStdString(newMinConnections));\n        return true;\n    }\n\n    return false;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortsInterface::getAllReferencesToIdInPort()\n//-----------------------------------------------------------------------------\nint PortsInterface::getAllReferencesToIdInItem(const std::string& itemName, std::string const& valueID) const\n{\n    QSharedPointer<Port> port = getPort(itemName);\n    if (!port)\n    {\n        return 0;\n    }\n\n    QString idString(QString::fromStdString(valueID));\n\n    int referencesInArrayLeft = port->getArrayLeft().count(idString);\n    int referencesInArrayRight = port->getArrayRight().count(idString);\n\n    int totalReferences = referencesInArrayLeft + referencesInArrayRight;\n\n    if (portIsWire(port))\n    {\n        QSharedPointer<Wire> portWire = port->getWire();\n\n        totalReferences += port->getWire()->getVectorLeftBound().count(idString);\n        totalReferences += port->getWire()->getVectorRightBound().count(idString);\n        totalReferences += port->getWire()->getDefaultDriverValue().count(idString);\n    }\n    else if (portIsTransactional(port))\n    {\n        QSharedPointer<Transactional> portTransactional = port->getTransactional();\n\n        totalReferences += portTransactional->getBusWidth().count(idString);\n        totalReferences += portTransactional->getMaxConnections().count(idString);\n        totalReferences += portTransactional->getMinConnections().count(idString);\n    }\n\n    return totalReferences;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortsInterface::addWirePort()\n//-----------------------------------------------------------------------------\nvoid PortsInterface::addWirePort(std::string const& newPortName)\n{\n    QString portName(getUniqueName(newPortName, \"port\"));\n\n    QSharedPointer<Port> newPort(new Port(portName));\n    newPort->setWire(QSharedPointer<Wire>(new Wire()));\n\n    ports_->append(newPort);\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortsInterface::addTransactionalPort()\n//-----------------------------------------------------------------------------\nvoid PortsInterface::addTransactionalPort(std::string const& newPortName)\n{\n    QString portName(getUniqueName(newPortName, \"port\"));\n\n    QSharedPointer<Port> newPort(new Port(portName));\n    newPort->setTransactional(QSharedPointer<Transactional>(new Transactional()));\n\n    ports_->append(newPort);\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortsInterface::removePort()\n//-----------------------------------------------------------------------------\nbool PortsInterface::removePort(std::string const& portName) const\n{\n    QSharedPointer<Port> removedPort = getPort(portName);\n    if (!removedPort)\n    {\n        return false;\n    }\n\n    return ports_->removeOne(removedPort);\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortsInterface::portExists()\n//-----------------------------------------------------------------------------\nbool PortsInterface::portExists(std::string const& portName) const\n{\n    return Search::findByName(QString::fromStdString(portName), ports_) != nullptr;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortsInterface::validateItems()\n//-----------------------------------------------------------------------------\nbool PortsInterface::validateItems() const\n{\n    return std::all_of(ports_->cbegin(), ports_->cend(),\n        [this](auto const& port) { return portValidator_->validate(port); });\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortsInterface::itemHasValidName()\n//-----------------------------------------------------------------------------\nbool PortsInterface::itemHasValidName(std::string const& portName) const\n{\n    return portValidator_->hasValidName(QString::fromStdString(portName));\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortsInterface::portLeftArrayValueIsValid()\n//-----------------------------------------------------------------------------\nbool PortsInterface::portLeftArrayValueIsValid(std::string const& portName) const\n{\n    return portValidator_->arrayValueIsValid(getPort(portName)->getArrayLeft());\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortsInterface::portRightArrayValueIsValid()\n//-----------------------------------------------------------------------------\nbool PortsInterface::portRightArrayValueIsValid(std::string const& portName) const\n{\n    return portValidator_->arrayValueIsValid(getPort(portName)->getArrayRight());\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortsInterface::portHasValidTypes()\n//-----------------------------------------------------------------------------\nbool PortsInterface::portHasValidTypes(std::string const& portName) const\n{\n    return portValidator_->hasValidTypes(getPort(portName));\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortsInterface::portHasValidLeftBound()\n//-----------------------------------------------------------------------------\nbool PortsInterface::portHasValidLeftBound(std::string const& portName) const\n{\n    QSharedPointer<Port> port = getPort(portName);\n    if (port->getLeftBound().isEmpty() && port->getRightBound().isEmpty())\n    {\n        return true;\n    }\n\n    return portValidator_->portBoundIsValid(port->getLeftBound());\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortsInterface::portHasValidRightBound()\n//-----------------------------------------------------------------------------\nbool PortsInterface::portHasValidRightBound(std::string const& portName) const\n{\n    QSharedPointer<Port> port = getPort(portName);\n    if (port->getLeftBound().isEmpty() && port->getRightBound().isEmpty())\n    {\n        return true;\n    }\n\n    return portValidator_->portBoundIsValid(port->getRightBound());\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortsInterface::portHasValidDefaultValue()\n//-----------------------------------------------------------------------------\nbool PortsInterface::portHasValidDefaultValue(std::string const& portName) const\n{\n    return portValidator_->hasValidDefaultValue(getPort(portName));\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortsInterface::portHasValidBusWidth()\n//-----------------------------------------------------------------------------\nbool PortsInterface::portHasValidBusWidth(std::string const& portName) const\n{\n    QSharedPointer<Port> port = getPort(portName);\n    if (!port->getTransactional())\n    {\n        return false;\n    }\n\n    return portValidator_->hasValidTransactionalWidth(port->getTransactional());\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortsInterface::portHasValidInitiative()\n//-----------------------------------------------------------------------------\nbool PortsInterface::portHasValidInitiative(std::string const& portName) const\n{\n    QSharedPointer<Port> port = getPort(portName);\n    if (!port->getTransactional())\n    {\n        return false;\n    }\n\n    return portValidator_->hasValidTransactionalInitiative(port->getTransactional());\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortsInterface::portHasValidKind()\n//-----------------------------------------------------------------------------\nbool PortsInterface::portHasValidKind(std::string const& portName) const\n{\n    QSharedPointer<Port> port = getPort(portName);\n    if (!port->getTransactional())\n    {\n        return false;\n    }\n\n    return portValidator_->hasValidTransactionalKind(port->getTransactional());\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortsInterface::portHasValidProtocol()\n//-----------------------------------------------------------------------------\nbool PortsInterface::portHasValidProtocol(std::string const& portName) const\n{\n    QSharedPointer<Port> port = getPort(portName);\n    if (!port->getTransactional())\n    {\n        return false;\n    }\n\n    return portValidator_->hasValidTransactionalProtocol(port->getTransactional());\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortsInterface::portHasValidMaxConnections()\n//-----------------------------------------------------------------------------\nbool PortsInterface::portHasValidMaxConnections(std::string const& portName) const\n{\n    QSharedPointer<Port> port = getPort(portName);\n    if (!port->getTransactional())\n    {\n        return false;\n    }\n\n    return portValidator_->hasValidTransactionalMaxConnections(port->getTransactional());\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortsInterface::portHasValidMinConnections()\n//-----------------------------------------------------------------------------\nbool PortsInterface::portHasValidMinConnections(std::string const& portName) const\n{\n    QSharedPointer<Port> port = getPort(portName);\n    if (!port->getTransactional())\n    {\n        return false;\n    }\n\n    return portValidator_->hasValidTransactionalMinConnections(port->getTransactional());\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortsInterface::getPathForIcon()\n//-----------------------------------------------------------------------------\nstd::string PortsInterface::getIconPathForPort(std::string const& portName) const\n{\n    std::string path;\n    if (QSharedPointer<Port> selectedPort = getPort(portName); \n        !selectedPort)\n    {\n        path = getIconPathForMissingPort();\n    }\n    else\n    {\n        if (selectedPort->getWire())\n        {\n            DirectionTypes::Direction direction = DirectionTypes::DIRECTION_INVALID;\n            direction = selectedPort->getDirection();\n            \n            path = getIconPathForDirection(direction);\n        }\n        else if (selectedPort->getTransactional())\n        {\n            QString initiative = selectedPort->getTransactional()->getInitiative();\n            path = getIconPathForInitiative(initiative);\n        }\n    }\n\n    return path;\n}\n"
  },
  {
    "path": "KactusAPI/interfaces/component/RegisterInterface.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: RegisterInterface.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 27.04.2020\n//\n// Description:\n// Interface for editing registers.\n//-----------------------------------------------------------------------------\n\n#include <RegisterInterface.h>\n\n#include <IPXACTmodels/common/AccessTypes.h>\n\n#include <IPXACTmodels/Component/Register.h>\n#include <IPXACTmodels/Component/RegisterFile.h>\n#include <IPXACTmodels/Component/validators/RegisterValidator.h>\n\n#include <FieldInterface.h>\n#include <AccessPolicyInterface.h>\n#include <RegisterExpressionsGatherer.h>\n\n#include <QMimeData>\n#include <QApplication>\n#include <QClipboard>\n\nusing namespace std;\n\nnamespace\n{\n    QString const TRUE_STRING = QLatin1String(\"true\");\n    QString const FALSE_STRING = QLatin1String(\"false\");\n\n    std::string const REGISTER_TYPE = \"register\";\n};\n\n//-----------------------------------------------------------------------------\n// Function: RegisterInterface::RegisterInterface()\n//-----------------------------------------------------------------------------\nRegisterInterface::RegisterInterface(QSharedPointer<RegisterValidator> validator,\n    QSharedPointer<ExpressionParser> expressionParser, QSharedPointer<ExpressionFormatter> expressionFormatter,\n    FieldInterface* subInterface, AccessPolicyInterface* accessPolicyInterface) :\nParameterizableInterface(expressionParser, expressionFormatter),\nregisters_(),\nvalidator_(validator),\nsubInterface_(subInterface),\naccessPolicyInterface_(accessPolicyInterface),\naddressUnitBits_(0)\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: RegisterInterface::setRegisters()\n//-----------------------------------------------------------------------------\nvoid RegisterInterface::setRegisters(QSharedPointer<QList<QSharedPointer<RegisterBase>>> newRegisterData)\n{\n    registerData_ = newRegisterData;\n\n    registers_.clear();\n    for (auto item : *registerData_)\n    {\n        QSharedPointer<Register> registerItem = item.dynamicCast<Register>();\n        if (registerItem)\n        {\n            registers_.append(registerItem);\n        }\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: RegisterInterface::getItemIndex()\n//-----------------------------------------------------------------------------\nint RegisterInterface::getItemIndex(string const& itemName) const\n{\n    for (int i = 0; i < registers_.size(); ++i)\n    {\n        if (registers_.at(i)->name().toStdString() == itemName)\n        {\n            return i;\n        }\n    }\n\n    return -1;\n}\n\n//-----------------------------------------------------------------------------\n// Function: RegisterInterface::getIndexedItemName()\n//-----------------------------------------------------------------------------\nstring RegisterInterface::getIndexedItemName(int itemIndex) const\n{\n    string fieldName = \"\";\n    if (itemIndex >= 0 && itemIndex < registers_.size())\n    {\n        fieldName = registers_.at(itemIndex)->name().toStdString();\n    }\n\n    return fieldName;\n}\n\n//-----------------------------------------------------------------------------\n// Function: RegisterInterface::itemCount()\n//-----------------------------------------------------------------------------\nint RegisterInterface::itemCount() const\n{\n    return registers_.count();\n}\n\n//-----------------------------------------------------------------------------\n// Function: RegisterInterface::registerDataCount()\n//-----------------------------------------------------------------------------\nint RegisterInterface::registerDataCount() const\n{\n    return registerData_->count();\n}\n\n//-----------------------------------------------------------------------------\n// Function: RegisterInterface::indexInRegisterData()\n//-----------------------------------------------------------------------------\nint RegisterInterface::indexInRegisterData(int const& index) const\n{\n    QSharedPointer<Register> indexedRegister = getRegister(getIndexedItemName(index));\n    if (indexedRegister)\n    {\n        return registerData_->indexOf(indexedRegister);\n    }\n\n    return registerDataCount();\n}\n\n//-----------------------------------------------------------------------------\n// Function: RegisterInterface::getItemNames()\n//-----------------------------------------------------------------------------\nvector<string> RegisterInterface::getItemNames() const\n{\n    vector<string> names;\n    for (auto baseRegister : *registerData_)\n    {\n        names.push_back(baseRegister->name().toStdString());\n    }\n\n    return names;\n}\n\n//-----------------------------------------------------------------------------\n// Function: RegisterInterface::setName()\n//-----------------------------------------------------------------------------\nbool RegisterInterface::setName(string const& currentName, string const& newName)\n{\n    QSharedPointer<Register> editedRegister = getRegister(currentName);\n    if (editedRegister && nameHasChanged(newName, currentName))\n    {\n        QString uniqueNewName = getUniqueName(newName, REGISTER_TYPE);\n\n        editedRegister->setName(uniqueNewName);\n        return true;\n    }\n    else\n    {\n        return false;\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: RegisterInterface::getOffsetValue()\n//-----------------------------------------------------------------------------\nstring RegisterInterface::getOffsetValue(std::string const& registerName, int const& baseNumber) const\n{\n    QSharedPointer<Register> selectedRegister = getRegister(registerName);\n    if (selectedRegister)\n    {\n        return parseExpressionToBaseNumber(selectedRegister->getAddressOffset(), baseNumber).toStdString();\n    }\n\n    return string(\"\");\n}\n\n//-----------------------------------------------------------------------------\n// Function: RegisterInterface::getOffsetFormattedExpression()\n//-----------------------------------------------------------------------------\nstring RegisterInterface::getOffsetFormattedExpression(std::string const& registerName) const\n{\n    QSharedPointer<Register> selectedRegister = getRegister(registerName);\n    if (selectedRegister)\n    {\n        return formattedValueFor(selectedRegister->getAddressOffset()).toStdString();\n    }\n\n    return string(\"\");\n}\n\n//-----------------------------------------------------------------------------\n// Function: RegisterInterface::getOffsetExpression()\n//-----------------------------------------------------------------------------\nstring RegisterInterface::getOffsetExpression(std::string const& registerName) const\n{\n    QSharedPointer<Register> selectedRegister = getRegister(registerName);\n    if (selectedRegister)\n    {\n        return selectedRegister->getAddressOffset().toStdString();\n    }\n\n    return string(\"\");\n}\n\n//-----------------------------------------------------------------------------\n// Function: RegisterInterface::setOffset()\n//-----------------------------------------------------------------------------\nbool RegisterInterface::setOffset(std::string const& registerName, std::string const& newOffset)\n{   \n    QSharedPointer<Register> selectedRegister = getRegister(registerName);\n    if (!selectedRegister)\n    {\n        return false;\n    }\n\n    selectedRegister->setAddressOffset(QString::fromStdString(newOffset));\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: RegisterInterface::getDimensionValue()\n//-----------------------------------------------------------------------------\nstring RegisterInterface::getDimensionValue(std::string const& registerName, int const& baseNumber) const\n{\n    QSharedPointer<Register> selectedRegister = getRegister(registerName);\n    if (selectedRegister)\n    {\n        return parseExpressionToBaseNumber(selectedRegister->getDimension(), baseNumber).toStdString();\n    }\n\n    return string(\"\");\n}\n\n//-----------------------------------------------------------------------------\n// Function: RegisterInterface::getDimensionFormattedExpression()\n//-----------------------------------------------------------------------------\nstring RegisterInterface::getDimensionFormattedExpression(std::string const& registerName) const\n{\n    QSharedPointer<Register> selectedRegister = getRegister(registerName);\n    if (selectedRegister)\n    {\n        return formattedValueFor(selectedRegister->getDimension()).toStdString();\n    }\n\n    return string(\"\");\n}\n\n//-----------------------------------------------------------------------------\n// Function: RegisterInterface::getDimensionExpression()\n//-----------------------------------------------------------------------------\nstring RegisterInterface::getDimensionExpression(std::string const& registerName) const\n{\n    QSharedPointer<Register> selectedRegister = getRegister(registerName);\n    if (selectedRegister)\n    {\n        return selectedRegister->getDimension().toStdString();\n    }\n\n    return string(\"\");\n}\n\n//-----------------------------------------------------------------------------\n// Function: RegisterInterface::setDimension()\n//-----------------------------------------------------------------------------\nbool RegisterInterface::setDimension(std::string const& registerName, std::string const& newDimension)\n{\n    QSharedPointer<Register> selectedRegister = getRegister(registerName);\n    if (!selectedRegister)\n    {\n        return false;\n    }\n\n    selectedRegister->setDimension(QString::fromStdString(newDimension));\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: RegisterInterface::getIsPresentValue()\n//-----------------------------------------------------------------------------\nstring RegisterInterface::getIsPresentValue(std::string const& registerName, int const& baseNumber) const\n{\n    QSharedPointer<Register> selectedRegister = getRegister(registerName);\n    if (selectedRegister)\n    {\n        return parseExpressionToBaseNumber(selectedRegister->getIsPresent(), baseNumber).toStdString();\n    }\n\n    return string(\"\");\n}\n\n//-----------------------------------------------------------------------------\n// Function: RegisterInterface::getIsPresentFormattedExpression()\n//-----------------------------------------------------------------------------\nstring RegisterInterface::getIsPresentFormattedExpression(std::string const& registerName) const\n{\n    QSharedPointer<Register> selectedRegister = getRegister(registerName);\n    if (selectedRegister)\n    {\n        return formattedValueFor(selectedRegister->getIsPresent()).toStdString();\n    }\n\n    return string(\"\");\n}\n\n//-----------------------------------------------------------------------------\n// Function: RegisterInterface::getIsPresentExpression()\n//-----------------------------------------------------------------------------\nstring RegisterInterface::getIsPresentExpression(std::string const& registerName) const\n{\n    QSharedPointer<Register> selectedRegister = getRegister(registerName);\n    if (selectedRegister)\n    {\n        return selectedRegister->getIsPresent().toStdString();\n    }\n\n    return string(\"\");\n}\n\n//-----------------------------------------------------------------------------\n// Function: RegisterInterface::setIsPresent()\n//-----------------------------------------------------------------------------\nbool RegisterInterface::setIsPresent(std::string const& registerName, std::string const& newIsPresent)\n{\n    QSharedPointer<Register> selectedRegister = getRegister(registerName);\n    if (!selectedRegister)\n    {\n        return false;\n    }\n\n    selectedRegister->setIsPresent(QString::fromStdString(newIsPresent));\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: RegisterInterface::getSizeValue()\n//-----------------------------------------------------------------------------\nstring RegisterInterface::getSizeValue(std::string const& registerName, int const& baseNumber) const\n{\n    QSharedPointer<Register> selectedRegister = getRegister(registerName);\n    if (selectedRegister)\n    {\n        return parseExpressionToBaseNumber(selectedRegister->getSize(), baseNumber).toStdString();\n    }\n\n    return string(\"\");\n}\n\n//-----------------------------------------------------------------------------\n// Function: RegisterInterface::getSizeFormattedExpression()\n//-----------------------------------------------------------------------------\nstring RegisterInterface::getSizeFormattedExpression(std::string const& registerName) const\n{\n    QSharedPointer<Register> selectedRegister = getRegister(registerName);\n    if (selectedRegister)\n    {\n        return formattedValueFor(selectedRegister->getSize()).toStdString();\n    }\n\n    return string(\"\");\n}\n\n//-----------------------------------------------------------------------------\n// Function: RegisterInterface::getSizeExpression()\n//-----------------------------------------------------------------------------\nstring RegisterInterface::getSizeExpression(std::string const& registerName) const\n{\n    QSharedPointer<Register> selectedRegister = getRegister(registerName);\n    if (selectedRegister)\n    {\n        return selectedRegister->getSize().toStdString();\n    }\n\n    return string(\"\");\n}\n\n//-----------------------------------------------------------------------------\n// Function: RegisterInterface::setSize()\n//-----------------------------------------------------------------------------\nbool RegisterInterface::setSize(std::string const& registerName, std::string const& newSize)\n{\n    QSharedPointer<Register> selectedRegister = getRegister(registerName);\n    if (!selectedRegister)\n    {\n        return false;\n    }\n\n    selectedRegister->setSize(QString::fromStdString(newSize));\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: RegisterInterface::getVolatile()\n//-----------------------------------------------------------------------------\nstring RegisterInterface::getVolatile(std::string const& registerName) const\n{\n    QSharedPointer<Register> selectedRegister = getRegister(registerName);\n    if (selectedRegister)\n    {\n        return selectedRegister->getVolatile().toStdString();\n    }\n\n    return string(\"\");\n}\n\n//-----------------------------------------------------------------------------\n// Function: RegisterInterface::setVolatile()\n//-----------------------------------------------------------------------------\nbool RegisterInterface::setVolatile(std::string const& registerName, std::string const& newVolatile)\n{\n    QSharedPointer<Register> selectedRegister = getRegister(registerName);\n    if (!selectedRegister)\n    {\n        return false;\n    }\n\n    if (QString::fromStdString(newVolatile) == TRUE_STRING)\n    {\n        selectedRegister->setVolatile(true);\n    }\n    else if (QString::fromStdString(newVolatile) == FALSE_STRING)\n    {\n        selectedRegister->setVolatile(false);\n    }\n    else\n    {\n        selectedRegister->clearVolatile();\n    }\n\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: RegisterInterface::getAccessString()\n//-----------------------------------------------------------------------------\nstd::string RegisterInterface::getAccessString(std::string const& registerName, bool getAccessPolicyAccess /*= false*/) const\n{\n    if (auto selectedRegister = getRegister(registerName))\n    {\n        if (!getAccessPolicyAccess)\n        {\n            return AccessTypes::access2Str(selectedRegister->getAccess()).toStdString();\n        }\n        else\n        {\n            if (auto accessPolicies = selectedRegister->getAccessPolicies(); !accessPolicies->isEmpty())\n            {\n                return AccessTypes::access2Str(accessPolicies->first()->getAccess()).toStdString();\n            }\n        }\n    }\n\n    return string(\"\");\n}\n\n//-----------------------------------------------------------------------------\n// Function: RegisterInterface::getAccess()\n//-----------------------------------------------------------------------------\nAccessTypes::Access RegisterInterface::getAccess(std::string const& registerName) const\n{\n    if (auto selectedRegister = getRegister(registerName))\n    {\n        return selectedRegister->getAccess();\n    }\n\n    return AccessTypes::ACCESS_COUNT;\n}\n\n//-----------------------------------------------------------------------------\n// Function: RegisterInterface::setAccess()\n//-----------------------------------------------------------------------------\nbool RegisterInterface::setAccess(std::string const& registerName, std::string const& newAccess, bool setAccessPolicyAccess /*= false*/)\n{\n    auto selectedRegister = getRegister(registerName);\n    if (!selectedRegister)\n    {\n        return false;\n    }\n\n    if (!setAccessPolicyAccess)\n    {\n        auto newAccessType = AccessTypes::str2Access(QString::fromStdString(newAccess), AccessTypes::ACCESS_COUNT);\n        selectedRegister->setAccess(newAccessType);\n        return true;\n    }\n    else\n    {\n        if (auto accessPolicies = selectedRegister->getAccessPolicies(); accessPolicies->isEmpty() == false)\n        {\n            auto accessPolicy = selectedRegister->getAccessPolicies()->first();\n\n            // Remove access policy, if new access is empty.\n            if (accessPolicy && newAccess.empty())\n            {\n                selectedRegister->getAccessPolicies()->removeFirst();\n                return true;\n            }\n\n            accessPolicy->setAccess(AccessTypes::str2Access(QString::fromStdString(newAccess),\n                AccessTypes::ACCESS_COUNT));\n            return true;\n        }\n    }\n\n    return false;\n}\n\n//-----------------------------------------------------------------------------\n// Function: RegisterInterface::getAccessPolicyCount()\n//-----------------------------------------------------------------------------\nint RegisterInterface::getAccessPolicyCount(std::string const& registerName) const\n{\n    if (auto selectedRegister = getRegister(registerName))\n    {\n        return selectedRegister->getAccessPolicies()->size();\n    }\n\n    return 0;\n}\n\n//-----------------------------------------------------------------------------\n// Function: RegisterInterface::addAccessPolicy()\n//-----------------------------------------------------------------------------\nbool RegisterInterface::addAccessPolicy(std::string const& registerName)\n{\n    if (auto selectedRegister = getRegister(registerName))\n    {\n        QSharedPointer<AccessPolicy> newAccessPolicy(new AccessPolicy());\n        selectedRegister->getAccessPolicies()->append(newAccessPolicy);\n        return true;\n    }\n\n    return false;\n}\n\n//-----------------------------------------------------------------------------\n// Function: RegisterInterface::getAllReferencesToIdInItem()\n//-----------------------------------------------------------------------------\nint RegisterInterface::getAllReferencesToIdInItem(const string& itemName, string const&  valueID) const\n{\n    QSharedPointer<Register> selectedRegister = getRegister(itemName);\n\n    QString idString = QString::fromStdString(valueID);\n\n    int referencesInOffset = selectedRegister->getAddressOffset().count(idString);\n    int referencesInDimension = selectedRegister->getDimension().count(idString);\n    int referencesInIsPresent = selectedRegister->getIsPresent().count(idString);\n    int referencesInSize = selectedRegister->getSize().count(idString);\n\n    int totalReferencesToParameter =\n        referencesInOffset + referencesInDimension + referencesInIsPresent + referencesInSize;\n\n    return totalReferencesToParameter;\n}\n\n//-----------------------------------------------------------------------------\n// Function: RegisterInterface::validateItems()\n//-----------------------------------------------------------------------------\nbool RegisterInterface::validateItems() const\n{\n    for (auto currentRegister : registers_)\n    {\n        if (!validator_->validate(currentRegister))\n        {\n            return false;\n        }\n    }\n\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: RegisterInterface::itemHasValidName()\n//-----------------------------------------------------------------------------\nbool RegisterInterface::itemHasValidName(string const& itemName) const\n{\n    QStringList registerNames;\n    for (QSharedPointer<RegisterBase> registerItem : *registerData_)\n    {\n        registerNames.append(registerItem->name());\n    }\n\n    return registerNames.count(QString::fromStdString(itemName)) == 1 &&\n        validator_->hasValidName(getRegister(itemName));\n}\n\n//-----------------------------------------------------------------------------\n// Function: RegisterInterface::hasValidDimension()\n//-----------------------------------------------------------------------------\nbool RegisterInterface::hasValidDimension(std::string const& registerName) const\n{\n    QSharedPointer<Register> selectedRegister = getRegister(registerName);\n    if (!selectedRegister)\n    {\n        return false;\n    }\n\n    return validator_->hasValidDimensions(selectedRegister);\n}\n\n//-----------------------------------------------------------------------------\n// Function: RegisterInterface::hasValidOffset()\n//-----------------------------------------------------------------------------\nbool RegisterInterface::hasValidOffset(std::string const& registerName) const\n{\n    QSharedPointer<Register> selectedRegister = getRegister(registerName);\n    if (!selectedRegister)\n    {\n        return false;\n    }\n\n    return validator_->hasValidAddressOffset(selectedRegister);\n}\n\n//-----------------------------------------------------------------------------\n// Function: RegisterInterface::hasValidIsPresent()\n//-----------------------------------------------------------------------------\nbool RegisterInterface::hasValidIsPresent(std::string const& registerName) const\n{\n    QSharedPointer<Register> selectedRegister = getRegister(registerName);\n    if (!selectedRegister)\n    {\n        return false;\n    }\n\n    return validator_->hasValidIsPresent(selectedRegister);\n}\n\n//-----------------------------------------------------------------------------\n// Function: RegisterInterface::hasValidSize()\n//-----------------------------------------------------------------------------\nbool RegisterInterface::hasValidSize(std::string const& registerName) const\n{\n    QSharedPointer<Register> selectedRegister = getRegister(registerName);\n    if (!selectedRegister)\n    {\n        return false;\n    }\n\n    return validator_->hasValidSize(selectedRegister);\n}\n\n//-----------------------------------------------------------------------------\n// Function: RegisterInterface::getRegister()\n//-----------------------------------------------------------------------------\nQSharedPointer<Register> RegisterInterface::getRegister(std::string const& registerName) const\n{\n    for (auto currentRegister : registers_)\n    {\n        if (currentRegister->name().toStdString() == registerName)\n        {\n            return currentRegister;\n        }\n    }\n\n    return QSharedPointer<Register>();\n}\n\n//-----------------------------------------------------------------------------\n// Function: RegisterInterface::setAddressUnitBits()\n//-----------------------------------------------------------------------------\nvoid RegisterInterface::setAddressUnitBits(int const& newAddressUnitbits)\n{\n    addressUnitBits_ = newAddressUnitbits;\n}\n\n//-----------------------------------------------------------------------------\n// Function: FieldInterface::addRegister()\n//-----------------------------------------------------------------------------\nvoid RegisterInterface::addRegister(int const& row, int const& dataIndex, std::string const& newRegisterName /*= std::string(\"\")*/)\n{\n    QString registerName = getUniqueName(newRegisterName, REGISTER_TYPE);\n\n    QSharedPointer<Register> regItem(new Register());\n    regItem->setAddressOffset(getNextRegisterOffset());\n    regItem->setName(registerName);\n    registers_.insert(row, regItem);\n    registerData_->insert(dataIndex, regItem);\n}\n\n//-----------------------------------------------------------------------------\n// Function: RegisterInterface::addRegister()\n//-----------------------------------------------------------------------------\nvoid RegisterInterface::addRegister(std::string const& newRegisterName /*= std::string(\"\")*/)\n{\n    addRegister(registers_.size(), registerData_->size(), newRegisterName);\n}\n\n//-----------------------------------------------------------------------------\n// Function: RegisterInterface::removeRegister()\n//-----------------------------------------------------------------------------\nbool RegisterInterface::removeRegister(std::string const& registerName, int const& dataIndex)\n{\n    QSharedPointer<Register> removedRegister = getRegister(registerName);\n    if (!removedRegister || dataIndex < 0 || dataIndex >= registerDataCount())\n    {\n        return false;\n    }\n\n    registerData_->removeAt(dataIndex);\n    return registers_.removeOne(removedRegister);\n}\n\n//-----------------------------------------------------------------------------\n// Function: RegisterInterface::copyRows()\n//-----------------------------------------------------------------------------\nvoid RegisterInterface::copyRows(std::vector<int> const& selectedRows)\n{\n    QList<QSharedPointer<Register> > copiedRegisters;\n    for (auto index : selectedRows)\n    {\n        QSharedPointer<Register> currentRegister = registers_.at(index);\n        copiedRegisters.append(currentRegister);\n    }\n\n    QVariant registerVariant;\n    registerVariant.setValue(copiedRegisters);\n\n    QMimeData* newMimeData = new QMimeData();\n    newMimeData->setData(\"text/xml/ipxact:register\", QByteArray());\n    newMimeData->setImageData(registerVariant);\n\n    QApplication::clipboard()->setMimeData(newMimeData);\n}\n\n//-----------------------------------------------------------------------------\n// Function: RegisterInterface::pasteRows()\n//-----------------------------------------------------------------------------\nstd::vector<std::string> RegisterInterface::pasteRows()\n{\n    std::vector<std::string> pastedRegisterNames;\n\n    const QMimeData* pasteData = QApplication::clipboard()->mimeData();\n\n    if (pasteData->hasImage())\n    {\n        QVariant pasteVariant = pasteData->imageData();\n        if (pasteVariant.canConvert<QList<QSharedPointer<Register> > >())\n        {\n            QList<QSharedPointer<Register> > copiedRegisterList = pasteVariant.value<QList<QSharedPointer<Register>>>();\n\n            for (auto const& copiedRegister : copiedRegisterList)\n            {\n                QSharedPointer<Register> newRegister(new Register(*copiedRegister.data()));\n                newRegister->setName(getUniqueName(newRegister->name().toStdString(), REGISTER_TYPE));\n                registers_.append(newRegister);\n                registerData_->append(newRegister);\n\n                pastedRegisterNames.push_back(newRegister->name().toStdString());\n            }\n        }\n    }\n\n    return pastedRegisterNames;\n}\n\n//-----------------------------------------------------------------------------\n// Function: RegisterInterface::getPasteRowCount()\n//-----------------------------------------------------------------------------\nint RegisterInterface::getPasteRowCount() const\n{\n    const QMimeData* pasteData = QApplication::clipboard()->mimeData();\n    if (pasteData->hasImage())\n    {\n        QVariant pasteVariant = pasteData->imageData();\n        if (pasteVariant.canConvert<QList<QSharedPointer<Register> > >())\n        {\n            QList<QSharedPointer<Register> > newRegisters =\n                pasteVariant.value<QList<QSharedPointer<Register> > >();\n            return newRegisters.count();\n        }\n    }\n    \n    return 0;\n}\n\n//-----------------------------------------------------------------------------\n// Function: RegisterInterface::getExpressionsInSelectedFields()\n//-----------------------------------------------------------------------------\nstd::vector<std::string> RegisterInterface::\n    getExpressionsInSelectedRegisters(std::vector<std::string> const& registerNames) const\n{\n    std::vector<std::string> expressionList;\n\n    RegisterExpressionsGatherer gatherer;\n\n    for (auto const& name : registerNames)\n    {\n        QSharedPointer<Register> currentRegister = getRegister(name);\n        QStringList registerExpressions = gatherer.getExpressions(currentRegister);\n        for (auto const& expression : registerExpressions)\n        {\n            expressionList.push_back(expression.toStdString());\n        }\n    }\n\n    return expressionList;\n}\n\n//-----------------------------------------------------------------------------\n// Function: RegisterInterface::getSubInterface()\n//-----------------------------------------------------------------------------\nFieldInterface* RegisterInterface::getSubInterface() const\n{\n    return subInterface_;\n}\n\n//-----------------------------------------------------------------------------\n// Function: RegisterInterface::getAccessPolicyInterface()\n//-----------------------------------------------------------------------------\nAccessPolicyInterface* RegisterInterface::getAccessPolicyInterface() const\n{\n    return accessPolicyInterface_;\n}\n\n//-----------------------------------------------------------------------------\n// Function: RegisterInterface::getItem()\n//-----------------------------------------------------------------------------\nQSharedPointer<NameGroup> RegisterInterface::getItem(std::string const& registerName) const\n{\n    return getRegister(registerName);\n}\n\n//-----------------------------------------------------------------------------\n// Function: RegisterInterface::getNextRegisterOffset()\n//-----------------------------------------------------------------------------\nQString RegisterInterface::getNextRegisterOffset() const\n{\n    auto lastRegister = std::max_element(registerData_->cbegin(), registerData_->cend(),\n        [this](QSharedPointer<RegisterBase> const& a, QSharedPointer<RegisterBase> const& b)\n        {\n            return parseExpressionToDecimal(a->getAddressOffset()).toInt() <\n                parseExpressionToDecimal(b->getAddressOffset()).toInt();\n        });\n\n    quint64 lastRegAddress = 0;\n    quint64 lastRegDimension = 0;\n    quint64 lastRegRange = 0;\n\n    if (lastRegister != registerData_->cend())\n    {\n        lastRegAddress = parseExpressionToDecimal((*lastRegister)->getAddressOffset()).toInt();\n        lastRegDimension = parseExpressionToDecimal((*lastRegister)->getDimension()).toInt();\n\n        QSharedPointer<Register> reg = lastRegister->dynamicCast<Register>();\n        QSharedPointer<RegisterFile> regFile = lastRegister->dynamicCast<RegisterFile>();\n        if (reg)\n        {\n            lastRegRange = parseExpressionToDecimal(reg->getSize()).toInt() / qMax(addressUnitBits_, 1u);\n        }\n        else if (regFile)\n        {\n            lastRegRange = parseExpressionToDecimal(regFile->getRange()).toInt();\n        }\n    }\n\n    qreal offsetIncrease = qMax(quint64(0), lastRegRange * qMax(quint64(1), lastRegDimension));\n\n    quint64 itemAddress = lastRegAddress + offsetIncrease;\n    return QStringLiteral(\"'h\") + QString::number(itemAddress, 16);\n}\n"
  },
  {
    "path": "KactusAPI/interfaces/component/ResetInterface.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: ResetInterface.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 20.04.2020\n//\n// Description:\n// Interface for editing resets.\n//-----------------------------------------------------------------------------\n\n#include \"ResetInterface.h\"\n\n#include <IPXACTmodels/Component/Field.h>\n#include <IPXACTmodels/Component/FieldReset.h>\n\n#include <IPXACTmodels/Component/validators/FieldValidator.h>\n\nusing namespace std;\n\nnamespace\n{\n    string const DEFAULT_TYPE = \"\";\n};\n\n//-----------------------------------------------------------------------------\n// Function: ResetInterface::ResetInterface()\n//-----------------------------------------------------------------------------\nResetInterface::ResetInterface(QSharedPointer<FieldValidator> validator,\n    QSharedPointer<ExpressionParser> expressionParser, QSharedPointer<ExpressionFormatter> expressionFormatter):\nParameterizableInterface(expressionParser, expressionFormatter),\nCommonInterface(),\ncontainingField_(),\nresets_(),\nvalidator_(validator)\n{\n}\n\n//-----------------------------------------------------------------------------\n// Function: ResetInterface::setResets()\n//-----------------------------------------------------------------------------\nvoid ResetInterface::setResets(QSharedPointer<Field> containingField)\n{\n    containingField_ = containingField;\n    resets_ = containingField->getResets();\n}\n\n//-----------------------------------------------------------------------------\n// Function: ResetInterface::getReset()\n//-----------------------------------------------------------------------------\nQSharedPointer<FieldReset> ResetInterface::getReset(int const& resetIndex) const\n{\n    if (resetIndex >= 0 && resetIndex < resets_->size())\n    {\n        return resets_->at(resetIndex);\n    }\n\n    return QSharedPointer<FieldReset>();\n}\n\n//-----------------------------------------------------------------------------\n// Function: ResetInterface::getItemNames()\n//-----------------------------------------------------------------------------\nvector<string> ResetInterface::getItemNames() const\n{\n    vector<string> resetNames;\n    for (auto reset : *resets_)\n    {\n        resetNames.push_back(reset->getResetTypeReference().toStdString());\n    }\n\n    return resetNames;\n}\n\n//-----------------------------------------------------------------------------\n// Function: ResetInterface::itemCount()\n//-----------------------------------------------------------------------------\nint ResetInterface::itemCount() const\n{\n    if (resets_)\n    {\n        return resets_->count();\n    }\n\n    return 0;\n}\n\n//-----------------------------------------------------------------------------\n// Function: ResetInterface::getResetTypeReference()\n//-----------------------------------------------------------------------------\nstring ResetInterface::getResetTypeReference(int const& itemIndex) const\n{\n    string resetType = \"\";\n    if (itemIndex >= 0 && itemIndex < resets_->size())\n    {\n        resetType = resets_->at(itemIndex)->getResetTypeReference().toStdString();\n    }\n\n    return resetType;\n}\n\n//-----------------------------------------------------------------------------\n// Function: ResetInterface::setResetTypeReference()\n//-----------------------------------------------------------------------------\nbool ResetInterface::setResetTypeReference(int const& resetIndex, std::string const& newResetType)\n{\n    QSharedPointer<FieldReset> editedReset = getReset(resetIndex);\n    if (!editedReset)\n    {\n        return false;\n    }\n\n    editedReset->setResetTypeReference(QString::fromStdString(newResetType));\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: ResetInterface::getResetValue()\n//-----------------------------------------------------------------------------\nstd::string ResetInterface::getResetValue(int const& resetIndex, int const& baseNumber) const\n{\n    QSharedPointer<FieldReset> reset = getReset(resetIndex);\n    if (reset)\n    {\n        return parseExpressionToBaseNumber(reset->getResetValue(), baseNumber).toStdString();\n    }\n\n    return string(\"\");\n}\n\n//-----------------------------------------------------------------------------\n// Function: ResetInterface::getResetValueFormattedExpression()\n//-----------------------------------------------------------------------------\nstd::string ResetInterface::getResetValueFormattedExpression(int const& resetIndex) const\n{\n    QSharedPointer<FieldReset> reset = getReset(resetIndex);\n    if (reset)\n    {\n        return formattedValueFor(reset->getResetValue()).toStdString();\n    }\n\n    return string(\"\");\n}\n\n//-----------------------------------------------------------------------------\n// Function: ResetInterface::getResetValueExpression()\n//-----------------------------------------------------------------------------\nstd::string ResetInterface::getResetValueExpression(int const& resetIndex) const\n{\n    QSharedPointer<FieldReset> reset = getReset(resetIndex);\n    if (reset)\n    {\n        return reset->getResetValue().toStdString();\n    }\n\n    return string(\"\");\n}\n\n//-----------------------------------------------------------------------------\n// Function: ResetInterface::setResetValue()\n//-----------------------------------------------------------------------------\nbool ResetInterface::setResetValue(int const& resetIndex, std::string const& newResetValue)\n{\n    QSharedPointer<FieldReset> reset = getReset(resetIndex);\n    if (!reset)\n    {\n        return false;\n    }\n\n    reset->setResetValue(QString::fromStdString(newResetValue));\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: ResetInterface::getResetMaskValue()\n//-----------------------------------------------------------------------------\nstd::string ResetInterface::getResetMaskValue(int const& resetIndex, int const& baseNumber /* = 0 */) const\n{\n    QSharedPointer<FieldReset> reset = getReset(resetIndex);\n    if (reset)\n    {\n        return parseExpressionToBaseNumber(reset->getResetMask(), baseNumber).toStdString();\n    }\n\n    return string(\"\");\n}\n\n//-----------------------------------------------------------------------------\n// Function: ResetInterface::getResetMaskFormattedExpression()\n//-----------------------------------------------------------------------------\nstd::string ResetInterface::getResetMaskFormattedExpression(int const& resetIndex) const\n{\n    QSharedPointer<FieldReset> reset = getReset(resetIndex);\n    if (reset)\n    {\n        return formattedValueFor(reset->getResetMask()).toStdString();\n    }\n\n    return string(\"\");\n}\n\n//-----------------------------------------------------------------------------\n// Function: ResetInterface::getResetMaskExpression()\n//-----------------------------------------------------------------------------\nstd::string ResetInterface::getResetMaskExpression(int const& resetIndex) const\n{\n    QSharedPointer<FieldReset> reset = getReset(resetIndex);\n    if (reset)\n    {\n        return reset->getResetMask().toStdString();\n    }\n\n    return string(\"\");\n}\n\n//-----------------------------------------------------------------------------\n// Function: ResetInterface::setResetMask()\n//-----------------------------------------------------------------------------\nbool ResetInterface::setResetMask(int const& resetIndex, std::string const& newResetMask)\n{\n    QSharedPointer<FieldReset> reset = getReset(resetIndex);\n    if (!reset)\n    {\n        return false;\n    }\n\n    reset->setResetMask(QString::fromStdString(newResetMask));\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: ResetInterface::validateItems()\n//-----------------------------------------------------------------------------\nbool ResetInterface::validateItems() const\n{\n    return validator_->hasValidResets(containingField_);\n}\n\n//-----------------------------------------------------------------------------\n// Function: ResetInterface::hasValidResetType()\n//-----------------------------------------------------------------------------\nbool ResetInterface::hasValidResetType(int const& resetIndex) const\n{\n    QSharedPointer<FieldReset> reset = getReset(resetIndex);\n    if (reset)\n    {\n        return validator_->hasValidResetTypeReference(reset);\n    }\n\n    return false;\n}\n\n//-----------------------------------------------------------------------------\n// Function: ResetInterface::hasValidResetValue()\n//-----------------------------------------------------------------------------\nbool ResetInterface::hasValidResetValue(int const& resetIndex) const\n{\n    QSharedPointer<FieldReset> reset = getReset(resetIndex);\n    if (reset)\n    {\n        return validator_->hasValidResetValue(reset);\n    }\n\n    return false;\n}\n\n//-----------------------------------------------------------------------------\n// Function: ResetInterface::hasValidResetMask()\n//-----------------------------------------------------------------------------\nbool ResetInterface::hasValidResetMask(int const& resetIndex) const\n{\n    QSharedPointer<FieldReset> reset = getReset(resetIndex);\n    if (reset)\n    {\n        return validator_->hasValidResetMask(reset);\n    }\n\n    return false;\n}\n\n//-----------------------------------------------------------------------------\n// Function: ResetInterface::addReset()\n//-----------------------------------------------------------------------------\nvoid ResetInterface::addReset(int const& row)\n{\n    QSharedPointer<FieldReset> newReset(new FieldReset());\n    resets_->insert(row, newReset);\n}\n\n//-----------------------------------------------------------------------------\n// Function: ResetInterface::removeReset()\n//-----------------------------------------------------------------------------\nbool ResetInterface::removeReset(int const& resetIndex)\n{\n    QSharedPointer<FieldReset> removedReset = getReset(resetIndex);\n    if (!removedReset)\n    {\n        return false;\n    }\n\n    return resets_->removeOne(removedReset);\n}\n\n//-----------------------------------------------------------------------------\n// Function: ResetInterface::getAllReferencesToIdInItem()\n//-----------------------------------------------------------------------------\nint ResetInterface::getAllReferencesToIdInItem(const std::string& itemName, std::string const&  valueID) const\n{\n    for (int i = 0; i < itemCount(); ++i)\n    {\n        if (getResetTypeReference(i) == itemName)\n        {\n            return getAllReferencesToIdInIndex(i, valueID);\n        }\n    }\n\n    return 0;\n}\n\n//-----------------------------------------------------------------------------\n// Function: ResetInterface::getAllReferencesToIdInIndex()\n//-----------------------------------------------------------------------------\nint ResetInterface::getAllReferencesToIdInIndex(int const& itemIndex, std::string const& valueID) const\n{\n    int totalReferencesToParameter = 0;\n    QSharedPointer<FieldReset> reset = getReset(itemIndex);\n    if (reset)\n    {\n        QString idString = QString::fromStdString(valueID);\n\n        int referencesInResetValue = reset->getResetValue().count(idString);\n        int referencesInResetMask = reset->getResetMask().count(idString);\n\n        totalReferencesToParameter = referencesInResetValue + referencesInResetMask;\n    }\n\n    return totalReferencesToParameter;\n}\n"
  },
  {
    "path": "KactusAPI/interfaces/component/SubspaceMapInterface.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: SubspaceMapInterface.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 25.01.2022\n//\n// Description:\n// Interface for editing subspace maps.\n//-----------------------------------------------------------------------------\n\n#include \"SubspaceMapInterface.h\"\n\n#include <IPXACTmodels/Component/SubSpaceMap.h>\n#include <IPXACTmodels/Component/AddressSpace.h>\n#include <IPXACTmodels/Component/Segment.h>\n#include <IPXACTmodels/Component/Component.h>\n#include <IPXACTmodels/Component/validators/SubspaceMapValidator.h>\n\n#include <BusInterfaceInterface.h>\n\nusing namespace std;\n\nnamespace\n{\n    std::string const SUBSPACEMAP_TYPE = \"subspaceMap\";\n};\n\n//-----------------------------------------------------------------------------\n// Function: SubspaceMapInterface::SubspaceMapInterface()\n//-----------------------------------------------------------------------------\nSubspaceMapInterface::SubspaceMapInterface(QSharedPointer<SubspaceMapValidator> subspaceValidator,\n    QSharedPointer<ExpressionParser> expressionParser, QSharedPointer<ExpressionFormatter> expressionFormatter,\n    BusInterfaceInterface* busInterface, ParametersInterface* parameterInterface):\nMemoryBlockInterface(expressionParser, expressionFormatter, busInterface, parameterInterface),\nvalidator_(subspaceValidator)\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: SubspaceMapInterface::getItem()\n//-----------------------------------------------------------------------------\nQSharedPointer<NameGroup> SubspaceMapInterface::getItem(std::string const& itemName) const\n{\n    return getSubspaceMap(itemName);\n}\n\n//-----------------------------------------------------------------------------\n// Function: SubspaceMapInterface::getValidator()\n//-----------------------------------------------------------------------------\nQSharedPointer<MemoryBlockValidator> SubspaceMapInterface::getValidator() const\n{\n    return validator_;\n}\n\n//-----------------------------------------------------------------------------\n// Function: SubspaceMapInterface::getDefaultName()\n//-----------------------------------------------------------------------------\nstd::string SubspaceMapInterface::getDefaultName() const\n{\n    return SUBSPACEMAP_TYPE;\n}\n\n//-----------------------------------------------------------------------------\n// Function: SubspaceMapInterface::acceptBlock()\n//-----------------------------------------------------------------------------\nbool SubspaceMapInterface::acceptBlock(std::string const& blockName) const\n{\n    QSharedPointer<SubSpaceMap> block = getSubspaceMap(blockName);\n    if (block)\n    {\n        return true;\n    }\n\n    return false;\n}\n\n//-----------------------------------------------------------------------------\n// Function: SubspaceMapInterface::getSubspaceMap()\n//-----------------------------------------------------------------------------\nQSharedPointer<SubSpaceMap> SubspaceMapInterface::getSubspaceMap(std::string const& itemName) const\n{\n    QSharedPointer<MemoryBlockBase> memoryBlock = getBlock(itemName);\n    if (memoryBlock)\n    {\n        QSharedPointer<SubSpaceMap> subspaceBlock = memoryBlock.dynamicCast<SubSpaceMap>();\n        if (subspaceBlock)\n        {\n            return subspaceBlock;\n        }\n    }\n\n    return QSharedPointer<SubSpaceMap>();\n}\n\n//-----------------------------------------------------------------------------\n// Function: SubspaceMapInterface::getMasterReference()\n//-----------------------------------------------------------------------------\nstd::string SubspaceMapInterface::getInitiatorReference(std::string const& itemName) const\n{\n    QSharedPointer<SubSpaceMap> editedItem = getSubspaceMap(itemName);\n    if (editedItem)\n    {\n        return editedItem->getInitiatorReference().toStdString();\n    }\n\n    return string(\"\");\n}\n\n//-----------------------------------------------------------------------------\n// Function: SubspaceMapInterface::setMasterReference()\n//-----------------------------------------------------------------------------\nbool SubspaceMapInterface::setMasterReference(std::string const& itemName, std::string const& newMasterReference)\n{\n    QSharedPointer<SubSpaceMap> editedItem = getSubspaceMap(itemName);\n    if (!editedItem)\n    {\n        return false;\n    }\n\n    editedItem->setInitiatorReference(QString::fromStdString(newMasterReference));\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: SubspaceMapInterface::getSegmentReference()\n//-----------------------------------------------------------------------------\nstd::string SubspaceMapInterface::getSegmentReference(std::string const& itemName) const\n{\n    QSharedPointer<SubSpaceMap> editedItem = getSubspaceMap(itemName);\n    if (editedItem)\n    {\n        return editedItem->getSegmentReference().toStdString();\n    }\n\n    return string(\"\");\n}\n\n//-----------------------------------------------------------------------------\n// Function: SubspaceMapInterface::setSegmentReference()\n//-----------------------------------------------------------------------------\nbool SubspaceMapInterface::setSegmentReference(std::string const& itemName, std::string const& newSegmentReference)\n{\n    QSharedPointer<SubSpaceMap> editedItem = getSubspaceMap(itemName);\n    if (!editedItem)\n    {\n        return false;\n    }\n\n    editedItem->setSegmentReference(QString::fromStdString(newSegmentReference));\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: SubspaceMapInterface::getWidthValue()\n//-----------------------------------------------------------------------------\nstd::string SubspaceMapInterface::getWidthValue(std::string const& subspaceName, int const& baseNumber) const\n{\n    QSharedPointer<AddressSpace> space =\n        getReferencedAddressSpace(QString::fromStdString(getInitiatorReference(subspaceName)));\n    if (space)\n    {\n        return parseExpressionToBaseNumber(space->getWidth(), baseNumber).toStdString();\n    }\n\n    return std::string(\"\");\n}\n\n//-----------------------------------------------------------------------------\n// Function: SubspaceMapInterface::validateItems()\n//-----------------------------------------------------------------------------\nbool SubspaceMapInterface::validateItems() const\n{\n    for (auto const& currentItemName : getItemNames())\n    {\n        QSharedPointer<SubSpaceMap> block = getSubspaceMap(currentItemName);\n        if (block)\n        {\n            if (!validator_->validate(block))\n            {\n                return false;\n            }\n        }\n    }\n\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: SubspaceMapInterface::hasValidMasterReference()\n//-----------------------------------------------------------------------------\nbool SubspaceMapInterface::hasValidMasterReference(std::string const& itemName) const\n{\n    QSharedPointer<SubSpaceMap> subMap = getSubspaceMap(itemName);\n    if (subMap)\n    {\n        return validator_->hasValidMasterReference(subMap);\n    }\n\n    return false;\n}\n\n//-----------------------------------------------------------------------------\n// Function: SubspaceMapInterface::hasValidSegmentReference()\n//-----------------------------------------------------------------------------\nbool SubspaceMapInterface::hasValidSegmentReference(std::string const& itemName) const\n{\n    QSharedPointer<SubSpaceMap> subMap = getSubspaceMap(itemName);\n    if (subMap)\n    {\n        return validator_->hasValidSegmentReference(subMap);\n    }\n\n    return false;\n}\n\n//-----------------------------------------------------------------------------\n// Function: SubspaceMapInterface::addBlock()\n//-----------------------------------------------------------------------------\nvoid SubspaceMapInterface::addBlock(int const& row, std::string const& newBlockName)\n{\n    QString newBase = getNewBlockBaseAddress();\n\n    QSharedPointer<SubSpaceMap> newSubMap(new SubSpaceMap());\n    newSubMap->setBaseAddress(newBase);\n    newSubMap->setName(getUniqueName(newBlockName, SUBSPACEMAP_TYPE));\n\n    getBlocksData()->insert(row, newSubMap);\n}\n\n//-----------------------------------------------------------------------------\n// Function: SubspaceMapInterface::getExpressionsInSelectedItems()\n//-----------------------------------------------------------------------------\nstd::vector<std::string> SubspaceMapInterface::getExpressionsInSelectedItems(std::vector<std::string> const& itemNames) const\n{\n    std::vector<std::string> expressionList;\n\n    for (auto const& name : itemNames)\n    {\n        QSharedPointer<SubSpaceMap> currentSubMap = getSubspaceMap(name);\n        if (currentSubMap)\n        {\n            expressionList.push_back(currentSubMap->getBaseAddress().toStdString());\n            expressionList.push_back(currentSubMap->getIsPresent().toStdString());\n        }\n    }\n\n    return expressionList;\n}\n\n//-----------------------------------------------------------------------------\n// Function: SubspaceMapInterface::getCopiedBlocks()\n//-----------------------------------------------------------------------------\nQList<QSharedPointer<MemoryBlockBase> > SubspaceMapInterface::getCopiedBlocks(std::vector<int> const& selectedRows) const\n{\n    QList<QSharedPointer<MemoryBlockBase> > copiedBlocks;\n    for (auto index : selectedRows)\n    {\n        QSharedPointer<SubSpaceMap> block = getSubspaceMap(getIndexedItemName(index));\n        if (block)\n        {\n            copiedBlocks.append(block);\n        }\n    }\n\n    return copiedBlocks;\n}\n\n//-----------------------------------------------------------------------------\n// Function: SubspaceMapInterface::getMimeType()\n//-----------------------------------------------------------------------------\nQString SubspaceMapInterface::getMimeType() const\n{\n    return QString(\"text/xml/ipxact:subspaceMap\");\n}\n\n//-----------------------------------------------------------------------------\n// Function: SubspaceMapInterface::createCopyBlock()\n//-----------------------------------------------------------------------------\nQSharedPointer<MemoryBlockBase> SubspaceMapInterface::createCopyBlock(QSharedPointer<MemoryBlockBase> copiedItem)\nconst\n{\n    QSharedPointer<SubSpaceMap> copiedBlock = copiedItem.dynamicCast<SubSpaceMap>();\n    if (copiedBlock)\n    {\n        QSharedPointer<SubSpaceMap> newBlock(new SubSpaceMap(*copiedBlock.data()));\n        newBlock->setName(getUniqueName(newBlock->name().toStdString(), SUBSPACEMAP_TYPE));\n\n        return newBlock;\n    }\n\n    return QSharedPointer<MemoryBlockBase>();\n}\n\n//-----------------------------------------------------------------------------\n// Function: SubspaceMapInterface::()\n//-----------------------------------------------------------------------------\nint SubspaceMapInterface::countItems(QList<QSharedPointer<MemoryBlockBase> > itemList) const\n{\n    int itemCount = 0;\n    for (auto blockItem : itemList)\n    {\n        QSharedPointer<SubSpaceMap> subspaceMapItem = blockItem.dynamicCast<SubSpaceMap>();\n        if (subspaceMapItem)\n        {\n            itemCount++;\n        }\n    }\n\n    return itemCount;\n}\n"
  },
  {
    "path": "KactusAPI/interfaces/component/TransparentBridgeInterface.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: TransparentBridgeInterface.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 24.02.2021\n//\n// Description:\n// Interface for accessing transparent bridges.\n//-----------------------------------------------------------------------------\n\n#include <TransparentBridgeInterface.h>\n\n#include <IPXACTmodels/Component/TransparentBridge.h>\n#include <IPXACTmodels/Component/TargetInterface.h>\n#include <IPXACTmodels/Component/IndirectInterface.h>\n#include <IPXACTmodels/Component/validators/BusInterfaceValidator.h>\n#include <IPXACTmodels/Component/validators/IndirectInterfaceValidator.h>\n\nnamespace\n{\n    QString const DEFAULT_NAME = QString();\n};\n\n//-----------------------------------------------------------------------------\n// Function: TransparentBridgeInterface::TransparentBridgeInterface()\n//-----------------------------------------------------------------------------\nTransparentBridgeInterface::TransparentBridgeInterface(QSharedPointer<ExpressionParser> expressionParser,\n    QSharedPointer<ExpressionFormatter> expressionFormatter):\nParameterizableInterface(expressionParser, expressionFormatter),\nbridges_(),\nbusValidator_(),\nindirectValidator_()\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: TransparentBridgeInterface::setBridges()\n//-----------------------------------------------------------------------------\nvoid TransparentBridgeInterface::setBridges(QSharedPointer<QList<QSharedPointer<TransparentBridge> > > newBridges)\n{\n    bridges_ = newBridges;\n}\n\n//-----------------------------------------------------------------------------\n// Function: TransparentBridgeInterface::getTransparentBridge()\n//-----------------------------------------------------------------------------\nQSharedPointer<TransparentBridge> TransparentBridgeInterface::getTransparentBridge(\n    std::string const& masterReference) const\n{\n    QString masterQ = QString::fromStdString(masterReference);\n    for (auto bridge : *bridges_)\n    {\n        if (bridge->getMasterRef() == masterQ)\n        {\n            return bridge;\n        }\n    }\n\n    return QSharedPointer<TransparentBridge>();\n}\n\n//-----------------------------------------------------------------------------\n// Function: TransparentBridgeInterface::getItemIndex()\n//-----------------------------------------------------------------------------\nint TransparentBridgeInterface::getItemIndex(std::string const& masterReference) const\n{\n    QString master = QString::fromStdString(masterReference);\n\n    if (bridges_)\n    {\n        for (int i = 0; i < bridges_->count(); ++i)\n        {\n            auto bridge = bridges_->at(i);\n            if (bridge && bridge->getMasterRef() == master)\n            {\n                return i;\n            }\n        }\n    }\n    return -1;\n}\n\n//-----------------------------------------------------------------------------\n// Function: TransparentBridgeInterface::getIndexedMasterReference()\n//-----------------------------------------------------------------------------\nstd::string TransparentBridgeInterface::getIndexedMasterReference(int const& itemIndex) const\n{\n    std::string masterReference = \"\";\n    if (bridges_ && itemIndex >= 0 && itemIndex < bridges_->count())\n    {\n        masterReference = bridges_->at(itemIndex)->getMasterRef().toStdString();\n    }\n\n    return masterReference;\n}\n\n//-----------------------------------------------------------------------------\n// Function: TransparentBridgeInterface::itemCount()\n//-----------------------------------------------------------------------------\nint TransparentBridgeInterface::itemCount() const\n{\n    if (bridges_)\n    {\n        return bridges_->count();\n    }\n    else\n    {\n        return 0;\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: TransparentBridgeInterface::getItemNames()\n//-----------------------------------------------------------------------------\nstd::vector<std::string> TransparentBridgeInterface::getItemNames() const\n{\n    QVector<QString> bridgeMastersQ;\n    if (bridges_)\n    {\n        for (auto bridge : *bridges_)\n        {\n            QString bridgeMaster = bridge->getMasterRef();\n            if (!bridgeMastersQ.contains(bridgeMaster))\n            {\n                bridgeMastersQ.append(bridgeMaster);\n            }\n        }\n    }\n\n    std::vector<std::string> bridgeMasters;\n    for (auto master : bridgeMastersQ)\n    {\n        bridgeMasters.push_back(master.toStdString());\n    }\n\n    return bridgeMasters;\n}\n\n//-----------------------------------------------------------------------------\n// Function: TransparentBridgeInterface::setMasterReference()\n//-----------------------------------------------------------------------------\nbool TransparentBridgeInterface::setMasterReference(std::string const& currentMaster, std::string const& newMaster)\n{\n    QSharedPointer<TransparentBridge> selectedBridge = getTransparentBridge(currentMaster);\n    if (!selectedBridge)\n    {\n        return false;\n    }\n\n    selectedBridge->setMasterRef(QString::fromStdString(newMaster));\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: TransparentBridgeInterface::validateItems()\n//-----------------------------------------------------------------------------\nbool TransparentBridgeInterface::validateItems() const\n{\n    if (busValidator_)\n    {\n        return busValidator_->hasValidBridges(bridges_);\n    }\n    else if (indirectValidator_)\n    {\n        return indirectValidator_->hasValidTransparentBridges(bridges_);\n    }\n    else\n    {\n        return false;\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: TransparentBridgeInterface::getIsPresentValue()\n//-----------------------------------------------------------------------------\nstd::string TransparentBridgeInterface::getIsPresentValue(std::string const& masterReference,\n    int const& baseNumber) const\n{\n    QSharedPointer<TransparentBridge> selectedBridge = getTransparentBridge(masterReference);\n    if (selectedBridge)\n    {\n        return parseExpressionToBaseNumber(selectedBridge->getIsPresent(), baseNumber).toStdString();\n    }\n\n    return std::string(\"\");\n}\n\n//-----------------------------------------------------------------------------\n// Function: TransparentBridgeInterface::getIsPresentFormattedExpression()\n//-----------------------------------------------------------------------------\nstd::string TransparentBridgeInterface::getIsPresentFormattedExpression(std::string const& masterReference) const\n{\n    QSharedPointer<TransparentBridge> selectedBridge = getTransparentBridge(masterReference);\n    if (selectedBridge)\n    {\n        return formattedValueFor(selectedBridge->getIsPresent()).toStdString();\n    }\n\n    return std::string(\"\");\n}\n\n//-----------------------------------------------------------------------------\n// Function: TransparentBridgeInterface::getIsPresentExpression()\n//-----------------------------------------------------------------------------\nstd::string TransparentBridgeInterface::getIsPresentExpression(std::string const& masterReference) const\n{\n    QSharedPointer<TransparentBridge> selectedBridge = getTransparentBridge(masterReference);\n    if (selectedBridge)\n    {\n        return selectedBridge->getIsPresent().toStdString();\n    }\n\n    return std::string(\"\");\n}\n\n//-----------------------------------------------------------------------------\n// Function: TransparentBridgeInterface::setIsPresent()\n//-----------------------------------------------------------------------------\nbool TransparentBridgeInterface::setIsPresent(std::string const& masterReference, std::string const& newIsPresent)\n{\n    QSharedPointer<TransparentBridge> selectedBridge = getTransparentBridge(masterReference);\n    if (!selectedBridge)\n    {\n        return false;\n    }\n\n    selectedBridge->setIsPresent(QString::fromStdString(newIsPresent));\n    return true;\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: TransparentBridgeInterface::addBridge()\n//-----------------------------------------------------------------------------\nbool TransparentBridgeInterface::addBridge(int const& bridgeIndex, std::string const& bridgeName) const\n{\n    if (bridgeIndex < 0)\n    {\n        return false;\n    }\n\n    QSharedPointer<TransparentBridge> newBridge(new TransparentBridge());\n    newBridge->setMasterRef(getUniqueName(bridgeName, DEFAULT_NAME.toStdString()));\n\n    bridges_->insert(bridgeIndex, newBridge);\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: TransparentBridgeInterface::removeTransparentBridge()\n//-----------------------------------------------------------------------------\nbool TransparentBridgeInterface::removeTransparentBridge(std::string const& masterReference)\n{\n    QSharedPointer<TransparentBridge> bridge = getTransparentBridge(masterReference);\n    if (!bridge)\n    {\n        return false;\n    }\n\n    bridges_->removeOne(bridge);\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: TransparentBridgeInterface::getAllReferencesToIdInItem()\n//-----------------------------------------------------------------------------\nint TransparentBridgeInterface::getAllReferencesToIdInItem(const std::string& itemName,\n    std::string const&  valueID) const\n{\n    int totalReferencesToParameter = 0;\n    QSharedPointer<TransparentBridge> selectedItem = getTransparentBridge(itemName);\n    if (selectedItem)\n    {\n        QString idString = QString::fromStdString(valueID);\n\n        int referencesInIsPresent = selectedItem->getIsPresent().count(idString);\n        totalReferencesToParameter = referencesInIsPresent;\n    }\n\n\n    return totalReferencesToParameter;\n}\n\n//-----------------------------------------------------------------------------\n// Function: TransparentBridgeInterface::getAllExpressions()\n//-----------------------------------------------------------------------------\nstd::vector<std::string> TransparentBridgeInterface::getAllExpressions(std::string const& masterReference) const\n{\n    std::vector<std::string> expressions;\n\n    QString isPresentExpression = QString::fromStdString(getIsPresentExpression(masterReference));\n    if (!isPresentExpression.isEmpty())\n    {\n        expressions.push_back(isPresentExpression.toStdString());\n    }\n\n    return expressions;\n}\n"
  },
  {
    "path": "KactusAPI/interfaces/design/AdHocConnectionInterface.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: AdHocconnectionInterface.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 10.09.2021\n//\n// Description:\n// Interface for accessing design ad hoc connections.\n//-----------------------------------------------------------------------------\n\n#include <AdHocConnectionInterface.h>\n\n#include <IPXACTmodels/Design/Design.h>\n#include <IPXACTmodels/Design/AdHocConnection.h>\n#include <IPXACTmodels/Design/PortReference.h>\n\n#include <IPXACTmodels/utilities/Search.h>\n\nnamespace\n{\n    QString const DEFAULT_NAME = QLatin1String(\"adhocconnection\");\n};\n\n//-----------------------------------------------------------------------------\n// Function: AdHocConnectionInterface::AdHocConnectionInterface()\n//-----------------------------------------------------------------------------\nAdHocConnectionInterface::AdHocConnectionInterface():\nNameGroupInterface()\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: AdHocConnectionInterface::setConnections()\n//-----------------------------------------------------------------------------\nvoid AdHocConnectionInterface::setConnections(QSharedPointer<Design> newDesign)\n{\n    connections_= newDesign->getAdHocConnections();\n}\n\n//-----------------------------------------------------------------------------\n// Function: AdHocConnectionInterface::getAdHocConnection()\n//-----------------------------------------------------------------------------\nQSharedPointer<AdHocConnection> AdHocConnectionInterface::getAdHocConnection(std::string const& connectionName)\nconst\n{\n    return Search::findByName(QString::fromStdString(connectionName), connections_);\n}\n\n//-----------------------------------------------------------------------------\n// Function: AdHocConnectionInterface::getItem()\n//-----------------------------------------------------------------------------\nQSharedPointer<NameGroup> AdHocConnectionInterface::getItem(std::string const& connectionName) const\n{\n    return getAdHocConnection(connectionName);\n}\n\n//-----------------------------------------------------------------------------\n// Function: AdHocConnectionInterface::getItemIndex()\n//-----------------------------------------------------------------------------\nint AdHocConnectionInterface::getItemIndex(std::string const& itemName) const\n{\n    QString itemNameQ = QString::fromStdString(itemName);\n\n    const auto COUNT = connections_->size();\n    for (int i = 0; i < COUNT; ++i)\n    {\n        if (connections_->at(i)->name() == itemNameQ)\n        {\n            return i;\n        }\n    }\n\n    return -1;\n}\n\n//-----------------------------------------------------------------------------\n// Function: AdHocConnectionInterface::getIndexedItemName()\n//-----------------------------------------------------------------------------\nstd::string AdHocConnectionInterface::getIndexedItemName(int itemIndex) const\n{\n    std::string connectionName = \"\";\n    if (itemIndex >= 0 && itemIndex < itemCount())\n    {\n        connectionName = connections_->at(itemIndex)->name().toStdString();\n    }\n\n    return connectionName;\n}\n\n//-----------------------------------------------------------------------------\n// Function: AdHocConnectionInterface::getConnectionName()\n//-----------------------------------------------------------------------------\nstd::string AdHocConnectionInterface::getConnectionName(std::string const& startInstanceName,\n    std::string const& startPortName, std::string const& endInstanceName, std::string const& endPortName) const\n{\n    QString firstInstance = QString::fromStdString(startInstanceName);\n    QString firstPort = QString::fromStdString(startPortName);\n    QString secondInstance = QString::fromStdString(endInstanceName);\n    QString secondPort = QString::fromStdString(endPortName);\n\n    for (auto const& connection : *connections_)\n    {\n        bool foundFirst = false;\n        bool foundSecond = false;\n\n        for (auto const& portReference : *connection->getInternalPortReferences())\n        {\n            if (portReference->getComponentRef() == firstInstance && portReference->getPortRef() == firstPort)\n            {\n                foundFirst = true;\n            }\n            else if (portReference->getComponentRef() == secondInstance &&\n                portReference->getPortRef() == secondPort)\n            {\n                foundSecond = true;\n            }\n\n            if (foundFirst && foundSecond)\n            {\n                break;\n            }\n        }\n\n        if (foundFirst && foundSecond)\n        {\n            return connection->name().toStdString();\n        }\n    }\n\n    return std::string();\n}\n\n//-----------------------------------------------------------------------------\n// Function: AdHocConnectionInterface::getHierarchicalConnectionName()\n//-----------------------------------------------------------------------------\nstd::string AdHocConnectionInterface::getHierarchicalConnectionName(std::string const& instanceName,\n    std::string const& instancePort, std::string const& topPort) const\n{\n    QString instanceNameQ = QString::fromStdString(instanceName);\n    QString instancePortQ = QString::fromStdString(instancePort);\n    QString topPortQ = QString::fromStdString(topPort);\n\n    for (auto const& connection : *connections_)\n    {\n        bool foundInstance = false;\n        bool foundTop = false;\n\n        for (auto const& portReference : *connection->getInternalPortReferences())\n        {\n            if (portReference->getComponentRef() == instanceNameQ && portReference->getPortRef() == instancePortQ)\n            {\n                foundInstance = true;\n                break;\n            }\n        }\n        for (auto const& portReference : *connection->getExternalPortReferences())\n        {\n            if (portReference->getPortRef() == topPortQ)\n            {\n                foundTop = true;\n                break;\n            }\n        }\n\n        if (foundInstance && foundTop)\n        {\n            return connection->name().toStdString();\n        }\n    }\n\n    return std::string();\n}\n\n//-----------------------------------------------------------------------------\n// Function: AdHocConnectionInterface::itemCount()\n//-----------------------------------------------------------------------------\nint AdHocConnectionInterface::itemCount() const\n{\n    return connections_->count();\n}\n\n//-----------------------------------------------------------------------------\n// Function: AdHocConnectionInterface::getItemNames()\n//-----------------------------------------------------------------------------\nstd::vector<std::string> AdHocConnectionInterface::getItemNames() const\n{\n    std::vector<std::string> connectionNames;\n    for (auto const& connection : *connections_)\n    {\n        connectionNames.push_back(connection->name().toStdString());\n    }\n\n    return connectionNames;\n}\n\n//-----------------------------------------------------------------------------\n// Function: AdHocConnectionInterface::setName()\n//-----------------------------------------------------------------------------\nbool AdHocConnectionInterface::setName(std::string const& currentName, std::string const& newName)\n{\n    QSharedPointer<AdHocConnection> editedConnection = getAdHocConnection(currentName);\n    if (editedConnection && nameHasChanged(newName, currentName))\n    {\n        QString uniqueNewName = getUniqueName(newName, DEFAULT_NAME.toStdString());\n        editedConnection->setName(uniqueNewName);\n\n        return true;\n    }\n    else\n    {\n        return false;\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: AdHocConnectionInterface::getDescription()\n//-----------------------------------------------------------------------------\nstd::string AdHocConnectionInterface::getDescription(std::string const& itemName) const\n{\n    if (QSharedPointer<AdHocConnection> editedConnection = getAdHocConnection(itemName); \n        editedConnection)\n    {\n        return editedConnection->description().toStdString();\n    }\n\n    return std::string();\n}\n\n//-----------------------------------------------------------------------------\n// Function: AdHocConnectionInterface::setDescription()\n//-----------------------------------------------------------------------------\nbool AdHocConnectionInterface::setDescription(std::string const& itemName, std::string const& newDescription)\n{\n    QSharedPointer<AdHocConnection> editedConnection = getAdHocConnection(itemName);\n    if (!editedConnection)\n    {\n        return false;\n    }\n\n    editedConnection->setDescription(QString::fromStdString(newDescription));\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: AdHocConnectionInterface::validateItems()\n//-----------------------------------------------------------------------------\nbool AdHocConnectionInterface::validateItems() const\n{\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: AdHocConnectionInterface::itemHasValidName()\n//-----------------------------------------------------------------------------\nbool AdHocConnectionInterface::itemHasValidName(std::string const& /*itemName*/) const\n{\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: AdHocConnectionInterface::addAdHocConnection()\n//-----------------------------------------------------------------------------\nvoid AdHocConnectionInterface::addAdHocConnection(std::string const& startComponentInstance,\n    std::string const& startPort, std::string const& endComponentInstance, std::string const& endPort,\n    std::string const& connectionName)\n{\n    QString newConnectionName = QString::fromStdString(connectionName);\n\n    QString startInstanceQ = QString::fromStdString(startComponentInstance);\n    QString startPortQ = QString::fromStdString(startPort);\n    QString endInstanceQ = QString::fromStdString(endComponentInstance);\n    QString endPortQ = QString::fromStdString(endPort);\n\n    if (newConnectionName.isEmpty())\n    {\n        newConnectionName = startInstanceQ + QStringLiteral(\"_\") + startPortQ + QStringLiteral(\"_to_\") +\n            endInstanceQ + QStringLiteral(\"_\") + endPortQ;\n    }\n\n    QSharedPointer<PortReference> startReference(new PortReference(startPortQ, startInstanceQ));\n    QSharedPointer<PortReference> endReference(new PortReference(endPortQ, endInstanceQ));\n\n    QSharedPointer<AdHocConnection> newConnection(new AdHocConnection(newConnectionName));\n    newConnection->getInternalPortReferences()->append(startReference);\n    newConnection->getInternalPortReferences()->append(endReference);\n\n    connections_->append(newConnection);\n}\n\n//-----------------------------------------------------------------------------\n// Function: AdHocConnectionInterface::addHierarchicalAdHocConnection()\n//-----------------------------------------------------------------------------\nvoid AdHocConnectionInterface::addHierarchicalAdHocConnection(std::string const& instanceName,\n    std::string const& instancePort, std::string const& topPort, std::string const& connectionName /* = \"\" */)\n{\n    QString instanceQ = QString::fromStdString(instanceName);\n    QString instancePortQ = QString::fromStdString(instancePort);\n    QString topPortQ = QString::fromStdString(topPort);\n\n    QString newConnectionName = QString::fromStdString(connectionName);\n    if (newConnectionName.isEmpty())\n    {\n        newConnectionName = instanceQ + QStringLiteral(\"_\") + instancePortQ + QStringLiteral(\"_to_\") + topPortQ;\n    }\n\n    QSharedPointer<PortReference> instanceReference(new PortReference(instancePortQ, instanceQ));\n    QSharedPointer<PortReference> topReference(new PortReference(topPortQ));\n\n    QSharedPointer<AdHocConnection> newConnection(new AdHocConnection(newConnectionName));\n    newConnection->getInternalPortReferences()->append(instanceReference);\n    newConnection->getExternalPortReferences()->append(topReference);\n\n    connections_->append(newConnection);\n}\n\n//-----------------------------------------------------------------------------\n// Function: AdHocConnectionInterface::removeAdHocConnection()\n//-----------------------------------------------------------------------------\nbool AdHocConnectionInterface::removeAdHocConnection(std::string const& connectionName)\n{\n    QSharedPointer<AdHocConnection> removedItem = getAdHocConnection(connectionName);\n    if (!removedItem)\n    {\n        return false;\n    }\n\n    return connections_->removeOne(removedItem);\n}\n\n//-----------------------------------------------------------------------------\n// Function: AdHocConnectionInterface::removeInstanceAdHocConnections()\n//-----------------------------------------------------------------------------\nbool AdHocConnectionInterface::removeInstanceAdHocConnections(std::string const& instanceName)\n{\n    QString instanceNameQ = QString::fromStdString(instanceName);\n\n    QVector<QSharedPointer<AdHocConnection> > removedConnections;\n\n    for (auto const& connection : *connections_)\n    {\n        const auto connectionSize = connection->getInternalPortReferences()->size();\n        for (int connectionIndex = connectionSize - 1; connectionIndex >= 0; --connectionIndex)\n        {\n            auto portReference = connection->getInternalPortReferences()->at(connectionIndex);\n            if (portReference->getComponentRef() == instanceNameQ)\n            {\n                connection->getInternalPortReferences()->removeOne(portReference);\n            }\n        }\n\n        if (connection->getInternalPortReferences()->isEmpty())\n        {\n            removedConnections.append(connection);\n        }\n    }\n\n    if (removedConnections.isEmpty())\n    {\n        return false;\n    }\n\n    for (auto const& connection : removedConnections)\n    {\n        connections_->removeOne(connection);\n    }\n\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: AdHocConnectionInterface::adHocConnectionExists()\n//-----------------------------------------------------------------------------\nbool AdHocConnectionInterface::adHocConnectionExists(std::string const& connectionName) const\n{\n    return getAdHocConnection(connectionName) != nullptr;\n}\n\n//-----------------------------------------------------------------------------\n// Function: AdHocConnectionInterface::renameComponentReferences()\n//-----------------------------------------------------------------------------\nvoid AdHocConnectionInterface::renameComponentReferences(std::string const& currentName,\n    std::string const& newName)\n{\n    QString oldInstanceName = QString::fromStdString(currentName);\n    QString newInstanceName = QString::fromStdString(newName);\n\n    for (auto const& connection : *connections_)\n    {\n        for (auto& portReference : *connection->getInternalPortReferences())\n        {\n            if (portReference->getComponentRef() == oldInstanceName)\n            {\n                portReference->setComponentRef(newInstanceName);\n            }\n        }\n    }\n}\n"
  },
  {
    "path": "KactusAPI/interfaces/design/ComponentInstanceInterface.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: ComponentInstanceInterface.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 09.09.2021\n//\n// Description:\n// Interface for accessing component instances.\n//-----------------------------------------------------------------------------\n\n#include <ComponentInstanceInterface.h>\n\n#include <IPXACTmodels/common/ConfigurableVLNVReference.h>\n\n#include <IPXACTmodels/Design/Design.h>\n#include <IPXACTmodels/Design/ComponentInstance.h>\n\n#include <IPXACTmodels/utilities/Search.h>\n\n#include <InterconnectionInterface.h>\n#include <AdHocConnectionInterface.h>\n\nnamespace\n{\n    QString const DEFAULT_NAME = QLatin1String(\"component_instance\");\n};\n\n//-----------------------------------------------------------------------------\n// Function: ComponentInstanceInterface::ComponentInstanceInterface()\n//-----------------------------------------------------------------------------\nComponentInstanceInterface::ComponentInstanceInterface(InterconnectionInterface* connectionInterface,\n    AdHocConnectionInterface* adHocInterface):\nNameGroupInterface(),\nconnectionInterface_(connectionInterface),\nadHocConnectionInterface_(adHocInterface)\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: ComponentInstanceInterface::setComponentInstances()\n//-----------------------------------------------------------------------------\nvoid ComponentInstanceInterface::setComponentInstances(QSharedPointer<Design> newDesign)\n{\n    componentInstances_ = newDesign->getComponentInstances();\n\n    connectionInterface_->setInterconnections(newDesign);\n    adHocConnectionInterface_->setConnections(newDesign);\n}\n\n//-----------------------------------------------------------------------------\n// Function: ComponentInstanceInterface::getComponentInstance()\n//-----------------------------------------------------------------------------\nQSharedPointer<ComponentInstance> ComponentInstanceInterface::getComponentInstance(std::string const& instanceName)\nconst\n{\n    return Search::findByName(QString::fromStdString(instanceName), componentInstances_);\n}\n\n//-----------------------------------------------------------------------------\n// Function: ComponentInstanceInterface::getItem()\n//-----------------------------------------------------------------------------\nQSharedPointer<NameGroup> ComponentInstanceInterface::getItem(std::string const& instanceName) const\n{\n    return getComponentInstance(instanceName);\n}\n\n//-----------------------------------------------------------------------------\n// Function: ComponentInstanceInterface::getItemIndex()\n//-----------------------------------------------------------------------------\nint ComponentInstanceInterface::getItemIndex(std::string const& itemName) const\n{\n    QString itemNameQ = QString::fromStdString(itemName);\n    for (int i = 0; i < componentInstances_->size(); ++i)\n    {\n        if (componentInstances_->at(i)->getInstanceName() == itemNameQ)\n        {\n            return i;\n        }\n    }\n\n    return -1;\n}\n\n//-----------------------------------------------------------------------------\n// Function: ComponentInstanceInterface::getIndexedItemName()\n//-----------------------------------------------------------------------------\nstd::string ComponentInstanceInterface::getIndexedItemName(int itemIndex) const\n{\n    std::string instanceName = \"\";\n    if (itemIndex >= 0 && itemIndex < itemCount())\n    {\n        instanceName = componentInstances_->at(itemIndex)->getInstanceName().toStdString();\n    }\n\n    return instanceName;\n}\n\n//-----------------------------------------------------------------------------\n// Function: ComponentInstanceInterface::itemCount()\n//-----------------------------------------------------------------------------\nint ComponentInstanceInterface::itemCount() const\n{\n    return componentInstances_->count();\n}\n\n//-----------------------------------------------------------------------------\n// Function: ComponentInstanceInterface::getItemNames()\n//-----------------------------------------------------------------------------\nstd::vector<std::string> ComponentInstanceInterface::getItemNames() const\n{\n    std::vector<std::string> instanceNames;\n    for (auto const& instance : *componentInstances_)\n    {\n        instanceNames.push_back(instance->getInstanceName().toStdString());\n    }\n\n    return instanceNames;\n}\n\n//-----------------------------------------------------------------------------\n// Function: ComponentInstanceInterface::setName()\n//-----------------------------------------------------------------------------\nbool ComponentInstanceInterface::setName(std::string const& currentName, std::string const& newName)\n{\n    QSharedPointer<ComponentInstance> editedInstance = getComponentInstance(currentName);\n    if (editedInstance && nameHasChanged(newName, currentName))\n    {\n        QString uniqueNewName = getUniqueName(newName, DEFAULT_NAME.toStdString());\n\n        editedInstance->setInstanceName(uniqueNewName);\n\n        connectionInterface_->renameComponentReferences(currentName, newName);\n        adHocConnectionInterface_->renameComponentReferences(currentName, newName);\n\n        return true;\n    }\n    else\n    {\n        return false;\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: ComponentInstanceInterface::getDescription()\n//-----------------------------------------------------------------------------\nstd::string ComponentInstanceInterface::getDescription(std::string const& itemName) const\n{\n    if (QSharedPointer<ComponentInstance> editedInstance = getComponentInstance(itemName); \n        editedInstance)\n    {\n        return editedInstance->description().toStdString();\n    }\n\n    return std::string();\n}\n\n//-----------------------------------------------------------------------------\n// Function: ComponentInstanceInterface::setDescription()\n//-----------------------------------------------------------------------------\nbool ComponentInstanceInterface::setDescription(std::string const& itemName, std::string const& newDescription)\n{\n    QSharedPointer<ComponentInstance> editedInstance = getComponentInstance(itemName);\n    if (!editedInstance)\n    {\n        return false;\n    }\n\n    editedInstance->setDescription(QString::fromStdString(newDescription));\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: ComponentInstanceInterface::validateItems()\n//-----------------------------------------------------------------------------\nbool ComponentInstanceInterface::validateItems() const\n{\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: ComponentInstanceInterface::itemHasValidName()\n//-----------------------------------------------------------------------------\nbool ComponentInstanceInterface::itemHasValidName(std::string const& /*itemName*/) const\n{\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: ComponentInstanceInterface::getComponentReference()\n//-----------------------------------------------------------------------------\nQSharedPointer<ConfigurableVLNVReference> ComponentInstanceInterface::getComponentReference(\n    std::string const& instanceName) const\n{\n    if (QSharedPointer<ComponentInstance> selectedInstance = getComponentInstance(instanceName); \n        selectedInstance)\n    {\n        return selectedInstance->getComponentRef();\n    }\n\n    return QSharedPointer<ConfigurableVLNVReference>();\n}\n\n//-----------------------------------------------------------------------------\n// Function: ComponentInstanceInterface::setComponentReference()\n//-----------------------------------------------------------------------------\nbool ComponentInstanceInterface::setComponentReference(std::string const& instanceName,\n    std::string const& newVendor, std::string const& newLibrary, std::string const& newName,\n    std::string const& newVersion)\n{\n    QSharedPointer<ComponentInstance> editedInstance = getComponentInstance(instanceName);\n    if (!editedInstance)\n    {\n        return false;\n    }\n\n    QSharedPointer<ConfigurableVLNVReference> newComponentVLNV(new ConfigurableVLNVReference());\n    newComponentVLNV->setVendor(QString::fromStdString(newVendor));\n    newComponentVLNV->setLibrary(QString::fromStdString(newLibrary));\n    newComponentVLNV->setName(QString::fromStdString(newName));\n    newComponentVLNV->setVersion(QString::fromStdString(newVersion));\n\n    editedInstance->setComponentRef(newComponentVLNV);\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: ComponentInstanceInterface::addComponentInstance()\n//-----------------------------------------------------------------------------\nvoid ComponentInstanceInterface::addComponentInstance(std::string const& instanceName)\n{\n    QSharedPointer<ComponentInstance> newInstance(new ComponentInstance());\n    newInstance->setInstanceName(getUniqueName(instanceName, DEFAULT_NAME.toStdString()));\n\n    componentInstances_->append(newInstance);\n}\n\n//-----------------------------------------------------------------------------\n// Function: BusInterfaceInterface::removeComponentInstance()\n//-----------------------------------------------------------------------------\nbool ComponentInstanceInterface::removeComponentInstance(std::string const& instanceName)\n{\n    QSharedPointer<ComponentInstance> removedItem = getComponentInstance(instanceName);\n    if (!removedItem)\n    {\n        return false;\n    }\n\n    connectionInterface_->removeInstanceInterconnections(instanceName);\n    adHocConnectionInterface_->removeInstanceAdHocConnections(instanceName);\n\n    return componentInstances_->removeOne(removedItem);\n}\n\n//-----------------------------------------------------------------------------\n// Function: ComponentInstanceInterface::instanceExists()\n//-----------------------------------------------------------------------------\nbool ComponentInstanceInterface::instanceExists(std::string const& instanceName) const\n{\n    return getComponentInstance(instanceName) != nullptr;\n}\n"
  },
  {
    "path": "KactusAPI/interfaces/design/InterconnectionInterface.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: InterconnectionInterface.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 09.09.2021\n//\n// Description:\n// Interface for accessing design interconnections.\n//-----------------------------------------------------------------------------\n\n#include <InterconnectionInterface.h>\n\n#include <IPXACTmodels/Design/Design.h>\n#include <IPXACTmodels/Design/ActiveInterface.h>\n#include <IPXACTmodels/Design/Interconnection.h>\n#include <IPXACTmodels/Design/HierInterface.h>\n\n#include <IPXACTmodels/utilities/Search.h>\n\nnamespace\n{\n    QString const DEFAULT_NAME = QLatin1String(\"interconnection\");\n};\n\n//-----------------------------------------------------------------------------\n// Function: InterconnectionInterface::InterconnectionInterface()\n//-----------------------------------------------------------------------------\nInterconnectionInterface::InterconnectionInterface():\nNameGroupInterface()\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: InterconnectionInterface::setInterconnections()\n//-----------------------------------------------------------------------------\nvoid InterconnectionInterface::setInterconnections(QSharedPointer<Design> newDesign)\n{\n    interconnections_ = newDesign->getInterconnections();\n}\n\n//-----------------------------------------------------------------------------\n// Function: InterconnectionInterface::getInterconnection()\n//-----------------------------------------------------------------------------\nQSharedPointer<Interconnection> InterconnectionInterface::getInterconnection(std::string const& connectionName)\nconst\n{\n    return Search::findByName(QString::fromStdString(connectionName), interconnections_);\n}\n\n//-----------------------------------------------------------------------------\n// Function: InterconnectionInterface::getItem()\n//-----------------------------------------------------------------------------\nQSharedPointer<NameGroup> InterconnectionInterface::getItem(std::string const& connectionName) const\n{\n    return getInterconnection(connectionName);\n}\n\n//-----------------------------------------------------------------------------\n// Function: InterconnectionInterface::getItemIndex()\n//-----------------------------------------------------------------------------\nint InterconnectionInterface::getItemIndex(std::string const& itemName) const\n{\n    QString itemNameQ = QString::fromStdString(itemName);\n    for (int i = 0; i < interconnections_->size(); ++i)\n    {\n        if (interconnections_->at(i)->name() == itemNameQ)\n        {\n            return i;\n        }\n    }\n\n    return -1;\n}\n\n//-----------------------------------------------------------------------------\n// Function: InterconnectionInterface::getIndexedItemName()\n//-----------------------------------------------------------------------------\nstd::string InterconnectionInterface::getIndexedItemName(int itemIndex) const\n{\n    std::string connectionName = \"\";\n    if (itemIndex >= 0 && itemIndex < itemCount())\n    {\n        connectionName = interconnections_->at(itemIndex)->name().toStdString();\n    }\n\n    return connectionName;\n}\n\n//-----------------------------------------------------------------------------\n// Function: InterconnectionInterface::getConnectionName()\n//-----------------------------------------------------------------------------\nstd::string InterconnectionInterface::getConnectionName(std::string const& startInstanceName,\n    std::string const& startBusName, std::string const& endInstanceName, std::string const& endBusName) const\n{\n    QString firstInstance = QString::fromStdString(startInstanceName);\n    QString firstBus = QString::fromStdString(startBusName);\n    QString secondInstance = QString::fromStdString(endInstanceName);\n    QString secondBus = QString::fromStdString(endBusName);\n\n    for (auto connection : *interconnections_)\n    {\n        QString endInstance;\n        QString endBus;\n\n        QSharedPointer<ActiveInterface> startInterface = connection->getStartInterface();\n        if (startInterface)\n        {\n            if (startInterface->getComponentReference() == firstInstance &&\n                startInterface->getBusReference() == firstBus)\n            {\n                endInstance = secondInstance;\n                endBus = secondBus;\n            }\n            else if (startInterface->getComponentReference() == secondInstance &&\n                startInterface->getBusReference() == secondBus)\n            {\n                endInstance = firstInstance;\n                endBus = firstBus;\n            }\n        }\n\n        if (!endInstance.isEmpty() && !endBus.isEmpty())\n        {\n            for (auto connectionInterface : *connection->getActiveInterfaces())\n            {\n                if (connectionInterface->getComponentReference() == endInstance &&\n                    connectionInterface->getBusReference() == endBus)\n                {\n                    return connection->name().toStdString();\n                }\n            }\n        }\n    }\n\n    return std::string();\n}\n\n//-----------------------------------------------------------------------------\n// Function: InterconnectionInterface::getHierarchicalConnectionName()\n//-----------------------------------------------------------------------------\nstd::string InterconnectionInterface::getHierarchicalConnectionName(std::string const& instanceName,\n    std::string const& instanceBus, std::string const& topBus) const\n{\n    QString instanceQ = QString::fromStdString(instanceName);\n    QString instanceBusQ = QString::fromStdString(instanceBus);\n    QString topBusQ = QString::fromStdString(topBus);\n\n    for (auto connection : *interconnections_)\n    {\n        QSharedPointer<ActiveInterface> startInterface = connection->getStartInterface();\n        if (startInterface && startInterface->getComponentReference() == instanceQ &&\n            startInterface->getBusReference() == instanceBusQ)\n        {\n            for (auto connectionInterface : *connection->getHierInterfaces())\n            {\n                if (connectionInterface->getBusReference() == topBusQ)\n                {\n                    return connection->name().toStdString();\n                }\n            }\n        }\n    }\n\n    return std::string();\n}\n\n//-----------------------------------------------------------------------------\n// Function: InterconnectionInterface::itemCount()\n//-----------------------------------------------------------------------------\nint InterconnectionInterface::itemCount() const\n{\n    return interconnections_->count();\n}\n\n//-----------------------------------------------------------------------------\n// Function: InterconnectionInterface::getItemNames()\n//-----------------------------------------------------------------------------\nstd::vector<std::string> InterconnectionInterface::getItemNames() const\n{\n    std::vector<std::string> connectionNames;\n    for (auto const& connection : *interconnections_)\n    {\n        connectionNames.push_back(connection->name().toStdString());\n    }\n\n    return connectionNames;\n}\n\n//-----------------------------------------------------------------------------\n// Function: InterconnectionInterface::setName()\n//-----------------------------------------------------------------------------\nbool InterconnectionInterface::setName(std::string const& currentName, std::string const& newName)\n{\n    QSharedPointer<Interconnection> editedConnection = getInterconnection(currentName);\n    if (editedConnection && nameHasChanged(newName, currentName))\n    {\n        QString uniqueNewName = getUniqueName(newName, DEFAULT_NAME.toStdString());\n        editedConnection->setName(uniqueNewName);\n\n        return true;\n    }\n    else\n    {\n        return false;\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: InterconnectionInterface::getDescription()\n//-----------------------------------------------------------------------------\nstd::string InterconnectionInterface::getDescription(std::string const& itemName) const\n{\n    if (QSharedPointer<Interconnection> editedConnection = getInterconnection(itemName); \n        editedConnection)\n    {\n        return editedConnection->description().toStdString();\n    }\n\n    return std::string();\n}\n\n//-----------------------------------------------------------------------------\n// Function: InterconnectionInterface::setDescription()\n//-----------------------------------------------------------------------------\nbool InterconnectionInterface::setDescription(std::string const& itemName, std::string const& newDescription)\n{\n    QSharedPointer<Interconnection> editedConnection = getInterconnection(itemName);\n    if (!editedConnection)\n    {\n        return false;\n    }\n\n    editedConnection->setDescription(QString::fromStdString(newDescription));\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: InterconnectionInterface::validateItems()\n//-----------------------------------------------------------------------------\nbool InterconnectionInterface::validateItems() const\n{\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: InterconnectionInterface::itemHasValidName()\n//-----------------------------------------------------------------------------\nbool InterconnectionInterface::itemHasValidName(std::string const& /*itemName*/) const\n{\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: InterconnectionInterface::addInterconnection()\n//-----------------------------------------------------------------------------\nvoid InterconnectionInterface::addInterconnection(std::string const& startComponentInstance,\n    std::string const& startBus, std::string const& endComponentInstance, std::string const& endBus,\n    std::string const& connectionName)\n{\n    QString startComponentQ = QString::fromStdString(startComponentInstance);\n    QString startBusQ = QString::fromStdString(startBus);\n    QString endComponentQ = QString::fromStdString(endComponentInstance);\n    QString endBusQ = QString::fromStdString(endBus);\n\n    QSharedPointer<Interconnection> newConnection(new Interconnection());\n\n    QSharedPointer<ActiveInterface> startInterface(new ActiveInterface());\n    startInterface->setComponentReference(QString::fromStdString(startComponentInstance));\n    startInterface->setBusReference(QString::fromStdString(startBus));\n\n    QSharedPointer<ActiveInterface> endInterface(new ActiveInterface());\n    endInterface->setComponentReference(QString::fromStdString(endComponentInstance));\n    endInterface->setBusReference(QString::fromStdString(endBus));\n\n    newConnection->setStartInterface(startInterface);\n    newConnection->getActiveInterfaces()->append(endInterface);\n\n    QString newConnectionName = QString::fromStdString(connectionName);\n    if (newConnectionName.isEmpty())\n    {\n        newConnectionName = startComponentQ + QLatin1String(\"_\") + startBusQ + QLatin1String(\"_to_\") +\n            endComponentQ + QLatin1String(\"_\") + endBusQ;\n    }\n\n    newConnectionName = getUniqueName(newConnectionName.toStdString(), DEFAULT_NAME.toStdString());\n    newConnection->setName(newConnectionName);\n\n    interconnections_->append(newConnection);\n}\n\n//-----------------------------------------------------------------------------\n// Function: InterconnectionInterface::addHierarchicalInterconnection()\n//-----------------------------------------------------------------------------\nvoid InterconnectionInterface::addHierarchicalInterconnection(std::string const& instanceName,\n    std::string const& instanceBus, std::string const& topBus, std::string const& connectionName /* = \"\" */)\n{\n    QString instanceNameQ = QString::fromStdString(instanceName);\n    QString instanceBusQ = QString::fromStdString(instanceBus);\n    QString topBusQ = QString::fromStdString(topBus);\n\n    QSharedPointer<ActiveInterface> instanceInterface(new ActiveInterface(instanceNameQ, instanceBusQ));\n\n    QSharedPointer<HierInterface> topInterface(new HierInterface(topBusQ));\n\n    QString newConnectionName = QString::fromStdString(connectionName);\n    if (newConnectionName.isEmpty())\n    {\n        newConnectionName = instanceNameQ + QLatin1String(\"_\") + instanceBusQ + QLatin1String(\"_to_\") + topBusQ;\n    }\n    \n    QSharedPointer<Interconnection> newConnection(new Interconnection(newConnectionName, instanceInterface));\n    newConnection->getHierInterfaces()->append(topInterface);\n\n    interconnections_->append(newConnection);\n}\n\n//-----------------------------------------------------------------------------\n// Function: InterconnectionInterface::removeInterconnection()\n//-----------------------------------------------------------------------------\nbool InterconnectionInterface::removeInterconnection(std::string const& connectionName)\n{\n    QSharedPointer<Interconnection> removedItem = getInterconnection(connectionName);\n    if (!removedItem)\n    {\n        return false;\n    }\n\n    return interconnections_->removeOne(removedItem);\n}\n\n//-----------------------------------------------------------------------------\n// Function: InterconnectionInterface::removeInstanceInterconnections()\n//-----------------------------------------------------------------------------\nbool InterconnectionInterface::removeInstanceInterconnections(std::string const& instanceName)\n{\n    QString instanceNameQ = QString::fromStdString(instanceName);\n\n    QVector<QSharedPointer<Interconnection> > removedConnections;\n\n    for (auto const& connection : *interconnections_)\n    {\n        if (connection->getStartInterface()->getComponentReference() == instanceNameQ)\n        {\n            removedConnections.append(connection);\n        }\n        else\n        {\n            int interfaceCounter = connection->getActiveInterfaces()->size() - 1;\n            while (interfaceCounter >= 0)\n            {\n                QSharedPointer<ActiveInterface> currentInterface =\n                    connection->getActiveInterfaces()->at(interfaceCounter);\n                if (currentInterface->getComponentReference() == instanceNameQ)\n                {\n                    connection->getActiveInterfaces()->removeOne(currentInterface);\n                }\n\n                interfaceCounter--;\n            }\n\n            if (connection->getActiveInterfaces()->size() == 0)\n            {\n                removedConnections.append(connection);\n            }\n        }\n    }\n\n    if (removedConnections.isEmpty())\n    {\n        return false;\n    }\n\n    for (auto const& connection : removedConnections)\n    {\n        interconnections_->removeOne(connection);\n    }\n\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: InterconnectionInterface::interconnectionExists()\n//-----------------------------------------------------------------------------\nbool InterconnectionInterface::interconnectionExists(std::string const& connectionName) const\n{\n    return getInterconnection(connectionName) != nullptr;\n}\n\n//-----------------------------------------------------------------------------\n// Function: InterconnectionInterface::renameComponentReferences()\n//-----------------------------------------------------------------------------\nvoid InterconnectionInterface::renameComponentReferences(std::string const& currentName,\n    std::string const& newName)\n{\n    QString oldInstanceName = QString::fromStdString(currentName);\n    QString newInstanceName = QString::fromStdString(newName);\n\n    for (auto const& connection : *interconnections_)\n    {\n        if (connection->getStartInterface()->getComponentReference() == oldInstanceName)\n        {\n            connection->getStartInterface()->setComponentReference(newInstanceName);\n        }\n\n        for (auto const& connectionInterface : *connection->getActiveInterfaces())\n        {\n            if (connectionInterface->getComponentReference() == oldInstanceName)\n            {\n                connectionInterface->setComponentReference(newInstanceName);\n            }\n        }\n    }\n}\n"
  },
  {
    "path": "KactusAPI/library/DocumentFileAccess.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: DocumentFileAccess.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Esko Pekkarinen\n// Date: 09.02.2018\n//\n// Description:\n// Reading and writing of IP-XACT documents using a standard file system.\n//-----------------------------------------------------------------------------\n\n#include \"DocumentFileAccess.h\"\n\n#include <IPXACTmodels/common/VLNV.h>\n\n#include <IPXACTmodels/AbstractionDefinition/AbstractionDefinition.h>\n#include <IPXACTmodels/BusDefinition/BusDefinition.h>\n#include <IPXACTmodels/Catalog/Catalog.h>\n#include <IPXACTmodels/Component/Component.h>\n#include <IPXACTmodels/Design/Design.h>\n#include <IPXACTmodels/DesignConfiguration/DesignConfiguration.h>\n\n#include <IPXACTmodels/kactusExtensions/ComDefinition.h>\n#include <IPXACTmodels/kactusExtensions/ApiDefinition.h>\n\n#include <IPXACTmodels/AbstractionDefinition/AbstractionDefinitionReader.h>\n#include <IPXACTmodels/BusDefinition/BusDefinitionReader.h>\n#include <IPXACTmodels/Catalog/CatalogReader.h>\n#include <IPXACTmodels/Component/ComponentReader.h>\n#include <IPXACTmodels/Design/DesignReader.h>\n#include <IPXACTmodels/DesignConfiguration/DesignConfigurationReader.h>\n\n#include <IPXACTmodels/kactusExtensions/ComDefinitionReader.h>\n#include <IPXACTmodels/kactusExtensions/ApiDefinitionReader.h>\n\n#include <IPXACTmodels/AbstractionDefinition/AbstractionDefinitionWriter.h>\n#include <IPXACTmodels/BusDefinition/BusDefinitionWriter.h>\n#include <IPXACTmodels/Catalog/CatalogWriter.h>\n#include <IPXACTmodels/Component/ComponentWriter.h>\n#include <IPXACTmodels/Design/DesignWriter.h>\n#include <IPXACTmodels/DesignConfiguration/DesignConfigurationWriter.h>\n\n#include <IPXACTmodels/kactusExtensions/ComDefinitionWriter.h>\n#include <IPXACTmodels/kactusExtensions/ApiDefinitionWriter.h>\n\n#include <KactusAPI/include/MessageMediator.h>\n\n#include <QObject>\n#include <QDomElement>\n#include <QXmlStreamWriter>\n\n//-----------------------------------------------------------------------------\n// Function: DocumentFileAccess::readDocument()\n//-----------------------------------------------------------------------------\nQSharedPointer<Document> DocumentFileAccess::readDocument(QString const& path)\n{\n    // Create file handle and use it to read the IP-XACT document into memory.\n    QFile file(path);\n    file.open(QIODevice::ReadOnly);\n\n    QDomDocument doc;\n    if (!doc.setContent(&file))\n    {\n        file.close();        \n        return QSharedPointer<Document>();\n    }\n    file.close();\n\n    VLNV::IPXactType toCreate = VLNV::string2Type(doc.documentElement().nodeName());\n\n    // Create correct type of object.\n    if (toCreate == VLNV::ABSTRACTIONDEFINITION)\n    {\n        return AbstractionDefinitionReader::createAbstractionDefinitionFrom(doc);\n    }\n    else if (toCreate == VLNV::BUSDEFINITION)\n    {\n        return BusDefinitionReader::createBusDefinitionFrom(doc);\n    }\n    else if (toCreate == VLNV::CATALOG)\n    {   \n        return CatalogReader::createCatalogFrom(doc);\n    }\n    else if (toCreate == VLNV::COMPONENT)\n    {\n        ComponentReader reader;\n        return reader.createComponentFrom(doc);\n    }\n    else if (toCreate == VLNV::DESIGN)\n    {\n        return DesignReader::createDesignFrom(doc);\n    }\n    else if (toCreate == VLNV::DESIGNCONFIGURATION)\n    {\n        return DesignConfigurationReader::createDesignConfigurationFrom(doc);\n    }\n\n    else if (toCreate == VLNV::APIDEFINITION)\n    {\n        return ApiDefinitionReader::createApiDefinitionFrom(doc);\n    }\n    else if (toCreate == VLNV::COMDEFINITION)\n    {\n        return ComDefinitionReader::createComDefinitionFrom(doc);\n    }\n    else\n    {\n        return QSharedPointer<Document>();\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: DocumentFileAccess::writeDocument()\n//-----------------------------------------------------------------------------\nbool DocumentFileAccess::writeDocument(QSharedPointer<Document> model, QString const& path)\n{\n    QFile targetFile(path);\n    if (!targetFile.open(QFile::WriteOnly | QFile::Truncate))\n    {      \n        return false;\n    }\n\n    // write the parsed model\n    QXmlStreamWriter xmlWriter(&targetFile);\n    xmlWriter.setAutoFormatting(true);\n    xmlWriter.setAutoFormattingIndent(-1);\n\n    VLNV::IPXactType documentType = model->getVlnv().getType();\n    if (documentType == VLNV::ABSTRACTIONDEFINITION)\n    {\n        QSharedPointer<AbstractionDefinition> absDef = model.dynamicCast<AbstractionDefinition>();\n        AbstractionDefinitionWriter::writeAbstractionDefinition(xmlWriter, absDef);\n    }\n\n    else if (documentType == VLNV::BUSDEFINITION)\n    {\n        QSharedPointer<BusDefinition> busDef = model.dynamicCast<BusDefinition>();\n        BusDefinitionWriter::writeBusDefinition(xmlWriter, busDef);\n    }\n    else if (documentType == VLNV::CATALOG)\n    {\n        QSharedPointer<Catalog> catalog = model.dynamicCast<Catalog>();\n        CatalogWriter::writeCatalog(xmlWriter, catalog);\n    }\n    else if (documentType == VLNV::COMPONENT)\n    {\n        ComponentWriter writer;\n        QSharedPointer<Component> component = model.dynamicCast<Component>();\n        writer.writeComponent(xmlWriter, component);\n    }\n    else if (documentType == VLNV::DESIGN)\n    {\n        QSharedPointer<Design> design = model.dynamicCast<Design>();\n        DesignWriter::writeDesign(xmlWriter, design);\n    }\n\n    else if (documentType == VLNV::DESIGNCONFIGURATION)\n    {\n        QSharedPointer<DesignConfiguration> designConfiguration = model.dynamicCast<DesignConfiguration>();\n        DesignConfigurationWriter::writeDesignConfiguration(xmlWriter, designConfiguration);\n    }\n\n    else if (documentType == VLNV::APIDEFINITION)\n    {\n        QSharedPointer<ApiDefinition> apiDefinition = model.dynamicCast<ApiDefinition>();\n        ApiDefinitionWriter::writeApiDefinition(xmlWriter, apiDefinition);\n    }\n\n    else if (documentType == VLNV::COMDEFINITION)\n    {\n        QSharedPointer<ComDefinition> comDefinition = model.dynamicCast<ComDefinition>();\n        ComDefinitionWriter::writeComDefinition(xmlWriter, comDefinition);\n    }\n    else\n    {\n        Q_ASSERT_X(false, \"DocumentFileAccess::writeDocument().\", \"Trying to write unknown document type to file.\");\n        targetFile.close();\n        return false;\n    }\n\n    targetFile.close();\n    return true;\n}\n"
  },
  {
    "path": "KactusAPI/library/DocumentValidator.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: DocumentValidator.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Esko Pekkarinen\n// Date: 09.02.2018\n//\n// Description:\n// <Short description of the class/file contents>\n//-----------------------------------------------------------------------------\n\n#include \"DocumentValidator.h\"\n\n#include <KactusAPI/include/ComponentParameterFinder.h>\n#include <KactusAPI/include/IPXactSystemVerilogParser.h>\n#include <KactusAPI/include/ListParameterFinder.h>\n#include <KactusAPI/include/ParameterCache.h>\n#include <KactusAPI/include/SystemVerilogExpressionParser.h>\n#include <KactusAPI/include/ModeConditionParserInterface.h>\n\n#include <IPXACTmodels/AbstractionDefinition/AbstractionDefinition.h>\n#include <IPXACTmodels/BusDefinition/BusDefinition.h>\n#include <IPXACTmodels/Catalog/Catalog.h>\n#include <IPXACTmodels/Component/Component.h>\n#include <IPXACTmodels/Design/Design.h>\n#include <IPXACTmodels/DesignConfiguration/DesignConfiguration.h>\n\n//-----------------------------------------------------------------------------\n// Function: DocumentValidator::DocumentValidator()\n//-----------------------------------------------------------------------------\nDocumentValidator::DocumentValidator(LibraryInterface* library) :\n    library_(library),\n    abstractionValidator_(library_, QSharedPointer<ExpressionParser>(new IPXactSystemVerilogParser(absDefParameterFinder_))),\n    busValidator_(library_, QSharedPointer<ExpressionParser>(new SystemVerilogExpressionParser())),\n    designValidator_(QSharedPointer<ExpressionParser>(new IPXactSystemVerilogParser(designValidatorFinder_)), library_),\n    designConfigurationValidator_(QSharedPointer<ExpressionParser>(new SystemVerilogExpressionParser()), library_),\n    systemDesignConfigurationValidator_(QSharedPointer<ExpressionParser>(new SystemVerilogExpressionParser()), library_)\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: DocumentValidator::validate()\n//-----------------------------------------------------------------------------\nbool DocumentValidator::validate(QSharedPointer<Document> document)\n{\n    VLNV::IPXactType documentType = document->getVlnv().getType();\n    if (documentType == VLNV::ABSTRACTIONDEFINITION)\n    {\n        absDefParameterFinder_->setParameterList(document->getParameters());\n        return abstractionValidator_.validate(document.dynamicCast<AbstractionDefinition>());\n    }\n    else if (documentType == VLNV::BUSDEFINITION)\n    {\n        return busValidator_.validate(document.dynamicCast<BusDefinition>());\n    } \n    else if (documentType == VLNV::CATALOG)\n    {\n        return catalogValidator_.validate(document.dynamicCast<Catalog>());\n    }\n    else if (documentType == VLNV::COMPONENT)\n    {\n        QSharedPointer<Component> currentComponent = document.dynamicCast<Component>();\n        changeComponentValidatorParameterFinder(currentComponent);\n\n        QSharedPointer<ModeConditionParserInterface> modeConditionParserInterface(new ModeConditionParserInterface(componentValidatorFinder_));\n\n        ComponentValidator componentValidator(QSharedPointer<ExpressionParser>(\n            new IPXactSystemVerilogParser(componentValidatorFinder_)), modeConditionParserInterface, library_, currentComponent->getRevision());\n\n        return componentValidator.validate(currentComponent);\n    }\n    else if (documentType == VLNV::DESIGN)\n    {\n        QSharedPointer<Design> currentDesign = document.dynamicCast<Design>();\n        designValidatorFinder_->setParameterList(currentDesign->getParameters());\n\n        return designValidator_.validate(currentDesign);\n    }\n    else if (documentType == VLNV::DESIGNCONFIGURATION)\n    {\n        QSharedPointer<DesignConfiguration> configuration = document.dynamicCast<DesignConfiguration>();\n\n        if (configuration->getImplementation() == KactusAttribute::SYSTEM)\n        {\n            return systemDesignConfigurationValidator_.validate(configuration);\n        }\n        else\n        {\n            return designConfigurationValidator_.validate(configuration);\n        }\n    }\n    else if (documentType == VLNV::APIDEFINITION || documentType == VLNV::COMDEFINITION)\n    {\n        return true;\n    }\n    \n    return false;\n}\n\n//-----------------------------------------------------------------------------\n// Function: DocumentValidator::findErrorsInDocument()\n//-----------------------------------------------------------------------------\nvoid DocumentValidator::findErrorsIn(QSharedPointer<Document> document, QVector<QString>& errorList)\n{\n    // Check if the document XML is valid and if not then print errors of the document..\n    VLNV::IPXactType documentType = document->getVlnv().getType();\n    if (documentType == VLNV::BUSDEFINITION)\n    {\n        findErrorsInBusDefinition(document.dynamicCast<BusDefinition>(), errorList);\n    }\n    else if (documentType == VLNV::ABSTRACTIONDEFINITION)\n    {\n        findErrorsInAbstractionDefinition(document.dynamicCast<AbstractionDefinition>(), errorList);\n    }\n    else if (documentType == VLNV::COMPONENT)\n    {\n        findErrorsInComponent(document.dynamicCast<Component>(), errorList);\n    }\n    else if (documentType == VLNV::DESIGN)\n    {\n        findErrorsInDesign(document.dynamicCast<Design>(), errorList);\n    }\n    else if (documentType == VLNV::DESIGNCONFIGURATION)\n    {\n        findErrorsInDesignConfiguration(document.dynamicCast<DesignConfiguration>(), errorList);\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: DocumentValidator::changeComponentValidatorParameterFinder()\n//-----------------------------------------------------------------------------\nvoid DocumentValidator::changeComponentValidatorParameterFinder(QSharedPointer<Component> targetComponent)\n{\n    componentValidatorFinder_->setComponent(targetComponent);\n}\n\n//-----------------------------------------------------------------------------\n// Function: DocumentValidator::findErrorsInBusDefinition()\n//-----------------------------------------------------------------------------\nvoid DocumentValidator::findErrorsInBusDefinition(QSharedPointer<BusDefinition> busDefinition,\n    QVector<QString>& errorList)\n{\n    BusDefinitionValidator validator(\n        library_, QSharedPointer<ExpressionParser>(new SystemVerilogExpressionParser()));\n    validator.findErrorsIn(errorList, busDefinition);\n}\n\n//-----------------------------------------------------------------------------\n// Function: DocumentValidator::findErrorsInAbstractionDefinition()\n//-----------------------------------------------------------------------------\nvoid DocumentValidator::findErrorsInAbstractionDefinition(QSharedPointer<AbstractionDefinition> abstraction,\n    QVector<QString>& errorList)\n{\n    AbstractionDefinitionValidator validator(library_, \n        QSharedPointer<ExpressionParser>(new SystemVerilogExpressionParser()));\n    validator.findErrorsIn(errorList, abstraction);\n}\n\n//-----------------------------------------------------------------------------\n// Function: DocumentValidator::findErrorsInComponent()\n//-----------------------------------------------------------------------------\nvoid DocumentValidator::findErrorsInComponent(QSharedPointer<Component> component, QVector<QString>& errorList)\n{\n    changeComponentValidatorParameterFinder(component);\n    QSharedPointer<ModeConditionParserInterface> parserFactory(new ModeConditionParserInterface(componentValidatorFinder_));\n    ComponentValidator componentValidator(QSharedPointer<ExpressionParser>(\n        new IPXactSystemVerilogParser(componentValidatorFinder_)), parserFactory, library_, component->getRevision());\n    componentValidator.findErrorsIn(errorList, component);\n}\n\n//-----------------------------------------------------------------------------\n// Function: DocumentValidator::findErrorsInDesign()\n//-----------------------------------------------------------------------------\nvoid DocumentValidator::findErrorsInDesign(QSharedPointer<Design> design, QVector<QString>& errorList)\n{\n    designValidatorFinder_->setParameterList(design->getParameters());\n    designValidator_.findErrorsIn(errorList, design);\n}\n\n//-----------------------------------------------------------------------------\n// Function: DocumentValidator::findErrorsInDesignConfiguration()\n//-----------------------------------------------------------------------------\nvoid DocumentValidator::findErrorsInDesignConfiguration(QSharedPointer<DesignConfiguration> configuration,\n    QVector<QString>& errorList)\n{\n    if (configuration->getImplementation() == KactusAttribute::SYSTEM)\n    {\n        systemDesignConfigurationValidator_.findErrorsIn(errorList, configuration);\n    }\n    else\n    {\n        designConfigurationValidator_.findErrorsIn(errorList, configuration);\n    }\n}\n"
  },
  {
    "path": "KactusAPI/library/LibraryHandler.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: libraryhandler.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Antti Kamppi\r\n// Date: 20.12.2010\r\n//\r\n// Description:\r\n// LibraryHandler is the class that implements the services to manage the IP-XACT library.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"LibraryHandler.h\"\r\n\r\n#include \"MessageMediator.h\"\r\n\r\n#include \"FileHandler.h\"\r\n\r\n#include \"ConsoleMediator.h\"\r\n\r\n#include \"TagManager.h\"\r\n\r\n#include <IPXACTmodels/common/Document.h>\r\n\r\n#include <IPXACTmodels/AbstractionDefinition/AbstractionDefinition.h>\r\n\r\n#include <IPXACTmodels/BusDefinition/BusDefinition.h>\r\n\r\n#include <IPXACTmodels/Component/Component.h>\r\n#include <IPXACTmodels/Component/FileSet.h>\r\n\r\n#include <IPXACTmodels/Design/Design.h>\r\n\r\n#include <IPXACTmodels/DesignConfiguration/DesignConfiguration.h>\r\n\r\n#include <IPXACTmodels/common/VLNV.h>\r\n\r\n#include <QDir>\r\n#include <QFile>\r\n#include <QFileInfo>\r\n#include <QSharedPointer>\r\n#include <QList>\r\n#include <QMap>\r\n#include <QString>\r\n#include <QStringList>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LibraryHandler::getInstance()\r\n//-----------------------------------------------------------------------------\r\nLibraryHandler& LibraryHandler::getInstance()\r\n{\r\n    static LibraryHandler instance;\r\n\r\n    return instance;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LibraryHandler::LibraryHandler()\r\n//-----------------------------------------------------------------------------\r\nLibraryHandler::LibraryHandler():\r\nQObject(nullptr),\r\nLibraryInterface()\r\n{\r\n    // create the connections between models and library handler\r\n    syncronizeModels();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LibraryHandler::setOutputChannel()\r\n//-----------------------------------------------------------------------------\r\nvoid LibraryHandler::setOutputChannel(MessageMediator* messageChannel)\r\n{\r\n    messageChannel_ = messageChannel;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LibraryHandler::getModel()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<Document> LibraryHandler::getModel(VLNV const& vlnv)\r\n{\r\n    auto info = documentCache_.find(vlnv);\r\n    if (info == documentCache_.end())\r\n    {\r\n        showNotFoundError(vlnv);\r\n        return QSharedPointer<Document>();\r\n    }\r\n\r\n    // If object has not already been parsed, read it from the disk.\r\n    if (info->document.isNull())\r\n    {\r\n        info->document = DocumentFileAccess::readDocument(info->path);\r\n    }\r\n\r\n    QSharedPointer<Document> copy;\r\n    if (info->document.isNull() == false)\r\n    {\r\n        copy = info->document->clone();\r\n    }\r\n\r\n    return copy;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LibraryHandler::getModelReadOnly()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<Document const> LibraryHandler::getModelReadOnly(VLNV const& vlnv)\r\n{\r\n    auto info = documentCache_.find(vlnv);\r\n    if (info == documentCache_.end())\r\n    {\r\n        return QSharedPointer<Document const>();\r\n    }\r\n\r\n    if (info->document.isNull())\r\n    {\r\n        info->document = DocumentFileAccess::readDocument(info->path);\r\n    }\r\n\r\n    return info->document;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LibraryHandler::getAllVLNVs()\r\n//-----------------------------------------------------------------------------\r\nQList<VLNV> LibraryHandler::getAllVLNVs() const\r\n{\r\n    return documentCache_.keys();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LibraryHandler::contains()\r\n//-----------------------------------------------------------------------------\r\nbool LibraryHandler::contains(const VLNV& vlnv) const\r\n{\r\n    return documentCache_.contains(vlnv);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LibraryHandler::getPath()\r\n//-----------------------------------------------------------------------------\r\nconst QString LibraryHandler::getPath(VLNV const& vlnv) const\r\n{\r\n    return documentCache_.value(vlnv).path;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LibraryHandler::getDirectoryPath()\r\n//-----------------------------------------------------------------------------\r\nQString LibraryHandler::getDirectoryPath(VLNV const& vlnv) const\r\n{\r\n    QFileInfo pathInfo(getPath(vlnv));\r\n    return pathInfo.absolutePath();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LibraryHandler::writeModelToFile()\r\n//-----------------------------------------------------------------------------\r\nbool LibraryHandler::writeModelToFile(QString const& path, QSharedPointer<Document> model)\r\n{\r\n    VLNV vlnv = model->getVlnv();\r\n    Q_ASSERT(contains(vlnv) == false);\r\n    \r\n    // Create the path if it does not exist.\r\n    if (QDir(path).exists() == false && QDir().mkpath(path) == false)\r\n    {\r\n        messageChannel_->showFailure(tr(\"Could not create directory \\\"%1\\\".\").arg(path));        \r\n        return false;\r\n    }\r\n\r\n    QString filePath = path + \"/\" + vlnv.getName() + \".\" + vlnv.getVersion() + \".xml\";\r\n    if (addObject(model, filePath) == false)\r\n    {\r\n        return false;\r\n    }\r\n\r\n    // the hierarchy model must be re-built\r\n    hierarchyModel_.onResetModel();\r\n    treeModel_.onAddVLNV(vlnv);\r\n    \r\n    return true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LibraryHandler::writeModelToFile()\r\n//-----------------------------------------------------------------------------\r\nbool LibraryHandler::writeModelToFile(QSharedPointer<Document> model)\r\n{\r\n    return addObject(model, getPath(model->getVlnv()));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LibraryHandler::searchForIPXactFiles()\r\n//-----------------------------------------------------------------------------\r\nvoid LibraryHandler::searchForIPXactFiles()\r\n{\r\n    clearCache();\r\n\r\n    loadAvailableVLNVs();\r\n\r\n    onCheckLibraryIntegrity();\r\n    \r\n    resetModels();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LibraryHandler::getNeededVLNVs()\r\n//-----------------------------------------------------------------------------\r\nvoid LibraryHandler::getNeededVLNVs(VLNV const& vlnv, QList<VLNV>& list)\r\n{\r\n    if (contains(vlnv) == false)\r\n    {\r\n        messageChannel_->showError(tr(\"No item with following info was found in library: \\n\"\r\n            \"Vendor: %1\\n\"\r\n            \"Library: %2\\n\"\r\n            \"Name: %3\\n\"\r\n            \"Version: %4\").arg(vlnv.getVendor(), vlnv.getLibrary(), vlnv.getName(), vlnv.getVersion()));\r\n        return;\r\n    }\r\n\r\n    // This document is searched so add it to the list.\r\n    list.append(vlnv);\r\n\r\n    for (VLNV const& dependentVLNV : getModelReadOnly(vlnv)->getDependentVLNVs())\r\n    {\r\n        if (list.contains(dependentVLNV) == false)\r\n        {\r\n            getNeededVLNVs(dependentVLNV, list);\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LibraryHandler::getDependencyFiles()\r\n//-----------------------------------------------------------------------------\r\nvoid LibraryHandler::getDependencyFiles(VLNV const& vlnv, QStringList& list)\r\n{\r\n    QSharedPointer<const Document> document = getModelReadOnly(vlnv);\r\n\r\n    // Get path to the IP-Xact document that is used as base for relative file paths.\r\n    QFileInfo documentFile(getPath(vlnv));\r\n    QDir documentDirectory(documentFile.absolutePath());\r\n\r\n    // Convert all relative file path to an absolute to make the file accessible in the caller function.\r\n    for (QString const& relativePath : document->getDependentFiles())\r\n    {\r\n        QFileInfo dependentFile(documentDirectory.absoluteFilePath(relativePath));\r\n        \r\n        QString path = dependentFile.canonicalFilePath();\r\n        if (dependentFile.exists() && list.contains(path) == false)\r\n        {\r\n            list.append(path);\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LibraryHandler::getTreeRoot()\r\n//-----------------------------------------------------------------------------\r\nLibraryItem const* LibraryHandler::getTreeRoot() const\r\n{\r\n    return treeModel_.getRoot();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LibraryHandler::getDocumentType()\r\n//-----------------------------------------------------------------------------\r\nVLNV::IPXactType LibraryHandler::getDocumentType(VLNV const& vlnv)\r\n{\r\n    auto it = documentCache_.constFind(vlnv);\r\n    if (it == documentCache_.constEnd())\r\n    {\r\n        return VLNV::INVALID;\r\n    }\r\n\r\n    return it.key().getType();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LibraryHandler::referenceCount()\r\n//-----------------------------------------------------------------------------\r\nint LibraryHandler::referenceCount(VLNV const& vlnv) const\r\n{\r\n    QList<VLNV> list;\r\n    return hierarchyModel_.getOwners(list, vlnv);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LibraryHandler::getOwners()\r\n//-----------------------------------------------------------------------------\r\nint LibraryHandler::getOwners(QList<VLNV>& list, VLNV const& vlnvToSearch) const\r\n{\r\n    return hierarchyModel_.getOwners(list, vlnvToSearch);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LibraryHandler::getChildren()\r\n//-----------------------------------------------------------------------------\r\nint LibraryHandler::getChildren(QList<VLNV>& list, VLNV const& vlnvToSearch) const\r\n{\r\n    if (vlnvToSearch.isValid() == false)\r\n    {\r\n        return 0;\r\n    }\r\n\r\n    hierarchyModel_.getChildren(list, vlnvToSearch);\r\n    return list.size();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LibraryHandler::getDesignVLNV()\r\n//-----------------------------------------------------------------------------\r\nVLNV LibraryHandler::getDesignVLNV(VLNV const& hierarchyRef)\r\n{\r\n    if (getDocumentType(hierarchyRef) == VLNV::DESIGNCONFIGURATION)\r\n    {\r\n        QSharedPointer<const DesignConfiguration> desConf = \r\n            getModelReadOnly(hierarchyRef).staticCast<const DesignConfiguration>();\r\n\r\n        VLNV designVLNV = desConf->getDesignRef();\r\n        if (!contains(designVLNV) || getDocumentType(designVLNV) != VLNV::DESIGN)\r\n        {\r\n            showNotFoundError(designVLNV);\r\n            return VLNV();\r\n        }\r\n\r\n        designVLNV.setType(VLNV::DESIGN);\r\n        return designVLNV;\r\n    }\r\n    else if (getDocumentType(hierarchyRef) == VLNV::DESIGN)\r\n    {\r\n        return hierarchyRef;\r\n    }\r\n    else if (contains(hierarchyRef) == false)\r\n    {\r\n        showNotFoundError(hierarchyRef);\r\n        return VLNV();\r\n    }\r\n    else\r\n    {\r\n        messageChannel_->showError(tr(\"VLNV: %1 was not valid hierarchical reference.\").arg(hierarchyRef.toString()));\r\n        return VLNV();\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LibraryHandler::getDesign()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<Design> LibraryHandler::getDesign(VLNV const& hierarchyRef)\r\n{\r\n    VLNV designVlnv = getDesignVLNV(hierarchyRef);\r\n    if (designVlnv.isValid() == false)\r\n    {\r\n        showNotFoundError(hierarchyRef);\r\n        return QSharedPointer<Design>();\r\n    }   \r\n\r\n    return getModel(designVlnv).staticCast<Design>();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LibraryHandler::isValid()\r\n//-----------------------------------------------------------------------------\r\nbool LibraryHandler::isValid(VLNV const& vlnv)\r\n{    \r\n    auto it = documentCache_.constFind(vlnv);\r\n    if (it != documentCache_.cend())\r\n    {\r\n        return documentCache_.value(vlnv).isValid;\r\n    }\r\n\r\n    return false;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LibraryHandler::getHierarchyModel()\r\n//-----------------------------------------------------------------------------\r\nHierarchyModel* LibraryHandler::getHierarchyModel()\r\n{\r\n    return &hierarchyModel_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LibraryHandler::getTreeModel()\r\n//-----------------------------------------------------------------------------\r\nLibraryTreeModel* LibraryHandler::getTreeModel()\r\n{\r\n    return &treeModel_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LibraryHandler::onCheckLibraryIntegrity()\r\n//-----------------------------------------------------------------------------\r\nvoid LibraryHandler::onCheckLibraryIntegrity()\r\n{\r\n    messageChannel_->showStatusMessage(tr(\"Validating items. Please wait...\"));\r\n\r\n    checkResults_.documentCount = 0;\r\n    checkResults_.fileCount = 0;\r\n\r\n    QVector<TagData> documentTags;\r\n    for (auto it = documentCache_.begin(); it != documentCache_.end(); ++it)\r\n    {\r\n        // TODO: Add model to cache only, if it is already previously cached.\r\n        // Current hierarchy model forces all models to be loaded, but this should be changed.\r\n        QSharedPointer<Document> model = it->document;\r\n        if (model.isNull())\r\n        {\r\n            model = DocumentFileAccess::readDocument(it->path);\r\n            it->document = model;\r\n        }           \r\n\r\n        if (model.isNull() == false)\r\n        {\r\n            documentTags += (model->getTags());\r\n        }\r\n\r\n        it->isValid = validateDocument(model, it->path);\r\n        if (it->isValid == false)\r\n        {\r\n            checkResults_.documentCount++;\r\n        }\r\n    }\r\n\r\n    TagManager& manager = TagManager::getInstance();\r\n    manager.setTags(documentTags);\r\n\r\n    showIntegrityResults();\r\n\r\n    messageChannel_->showStatusMessage(tr(\"Ready.\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LibraryHandler::onEditItem()\r\n//-----------------------------------------------------------------------------\r\nvoid LibraryHandler::onEditItem(VLNV const& vlnv)\r\n{\r\n    if (vlnv.isValid() == false)\r\n    {\r\n        return;\r\n    }\r\n\r\n    VLNV::IPXactType documentType = getDocumentType(vlnv);\r\n    if (documentType == VLNV::COMPONENT)\r\n    {\r\n        emit openComponent(vlnv);\r\n    }\r\n\r\n    else if (documentType == VLNV::CATALOG)\r\n    {\r\n        emit openCatalog(vlnv);\r\n    }\r\n\r\n    else if (documentType == VLNV::COMDEFINITION)\r\n    {\r\n        emit openComDefinition(vlnv);\r\n    }\r\n\r\n    else if (documentType == VLNV::APIDEFINITION)\r\n    {\r\n        emit openApiDefinition(vlnv);\r\n    }\r\n\r\n    else if (documentType == VLNV::BUSDEFINITION)\r\n    {\r\n        emit openBus(vlnv);\r\n    }\r\n\r\n    else if (documentType == VLNV::ABSTRACTIONDEFINITION)\r\n    {\r\n        emit openAbsDef(vlnv);\r\n    }\r\n\r\n    else\r\n    {\r\n        messageChannel_->showMessage(tr(\"Item can not be edited.\"));\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LibraryHandler::onOpenDesign()\r\n//-----------------------------------------------------------------------------\r\nvoid LibraryHandler::onOpenDesign(VLNV const& vlnv, QString const& viewName)\r\n{\r\n    if (contains(vlnv) == false)\r\n    {\r\n        messageChannel_->showError(tr(\"Component was not found\"));\r\n        return;\r\n    }\r\n\r\n    if (getDocumentType(vlnv) == VLNV::COMPONENT)\r\n    {\r\n         emit openDesign(vlnv, viewName);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LibraryHandler::onOpenMemoryDesign()\r\n//-----------------------------------------------------------------------------\r\nvoid LibraryHandler::onOpenMemoryDesign(VLNV const& vlnv, QString const& activeView)\r\n{\r\n    QSharedPointer<const Component> component = getModelReadOnly(vlnv).dynamicCast<const Component>();\r\n    if (component.isNull())\r\n    {\r\n        messageChannel_->showError(tr(\"Component was not found\"));\r\n        return;\r\n    }\r\n       \r\n    if (component->getHierViews().contains(activeView))\r\n    {\r\n        emit openMemoryDesign(vlnv, activeView);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LibraryHandler::onOpenSWDesign()\r\n//-----------------------------------------------------------------------------\r\nvoid LibraryHandler::onOpenSWDesign(VLNV const& vlnv)\r\n{\r\n    QSharedPointer<const Component> component = getModelReadOnly(vlnv).dynamicCast<const Component>();\r\n    if (component.isNull())\r\n    {\r\n        messageChannel_->showError(tr(\"Component was not found\"));\r\n        return;\r\n    }\r\n\r\n    for (QSharedPointer<View> view : *component->getViews())\r\n    {\r\n        VLNV reference = component->getModel()->getHierRef(view->name());\r\n\r\n        QSharedPointer<const Document> document = getModelReadOnly(reference);\r\n\r\n        if (document && document->getImplementation() == KactusAttribute::SW)\r\n        {\r\n            emit openSWDesign(vlnv, view->name());\r\n            return;\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LibraryHandler::onOpenSystemDesign()\r\n//-----------------------------------------------------------------------------\r\nvoid LibraryHandler::onOpenSystemDesign(VLNV const& vlnv, QString const& activeView)\r\n{\r\n    QSharedPointer<const Component> component = getModelReadOnly(vlnv).dynamicCast<const Component>();\r\n    if (component.isNull())\r\n    {\r\n        messageChannel_->showError(tr(\"Component was not found\"));\r\n        return;\r\n    }\r\n\r\n\tif (component->getSystemViewNames().contains(activeView))\r\n\t{\r\n\t\temit openSystemDesign(vlnv, activeView);\r\n\t}\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LibraryHandler::removeObject()\r\n//-----------------------------------------------------------------------------\r\nvoid LibraryHandler::removeObject(VLNV const& vlnv)\r\n{\r\n    if (vlnv.isValid() == false || contains(vlnv) == false)\r\n    {\r\n        return;\r\n    }\r\n\r\n    QString path = documentCache_.find(vlnv)->path;\r\n\r\n    documentCache_.remove(vlnv);\r\n\r\n    treeModel_.onRemoveVLNV(vlnv);\r\n    hierarchyModel_.onRemoveVLNV(vlnv);\r\n\r\n    removeFile(path);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LibraryHandler::removeObjects()\r\n//-----------------------------------------------------------------------------\r\nvoid LibraryHandler::removeObjects(QList<VLNV> const& vlnvList)\r\n{\r\n    QStringList changedDirectories;\r\n    for (auto const& removedItem : vlnvList)\r\n    {\r\n        changedDirectories.append(QFileInfo(getPath(removedItem)).absolutePath());\r\n        removeObject(removedItem);\r\n    }\r\n\r\n    changedDirectories.removeDuplicates();\r\n    loader_.clean(changedDirectories);\r\n\r\n    QString removeMessage = QString(\"Deleted %1 VLNV item(s).\").arg(QString::number(vlnvList.count()));\r\n\r\n    messageChannel_->showMessage(removeMessage);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LibraryHandler::beginSave()\r\n//-----------------------------------------------------------------------------\r\nvoid LibraryHandler::beginSave()\r\n{\r\n    saveInProgress_ = true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LibraryHandler::endSave()\r\n//-----------------------------------------------------------------------------\r\nvoid LibraryHandler::endSave()\r\n{\r\n    saveInProgress_ = false;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LibraryHandler::onItemSaved()\r\n//-----------------------------------------------------------------------------\r\nvoid LibraryHandler::onItemSaved(VLNV const& vlnv) \r\n{\r\n    if (vlnv.isValid() == false)\r\n    {\r\n        return;\r\n    }\r\n\r\n    VLNV savedItem = vlnv;\r\n    savedItem.setType(getDocumentType(vlnv));\r\n\r\n    // Replace overwritten item with new and check validity.\r\n    QSharedPointer<Document> model = getModel(vlnv);\r\n    documentCache_.insert(vlnv, DocumentInfo(getPath(vlnv), model, validateDocument(model, getPath(vlnv))));\r\n    \r\n    treeModel_.onDocumentUpdated(vlnv);\r\n    hierarchyModel_.onDocumentUpdated(vlnv);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LibraryHandler::syncronizeModels()\r\n//-----------------------------------------------------------------------------\r\nvoid LibraryHandler::syncronizeModels()\r\n{\r\n    // signals from tree model to library handler\r\n \r\n    connect(&treeModel_, SIGNAL(openDesign(const VLNV&, QString const&)), this, SLOT(onOpenDesign(const VLNV&, QString const&)), Qt::UniqueConnection);\r\n    connect(&treeModel_, SIGNAL(openMemoryDesign(const VLNV&, QString const&)), this, SLOT(onOpenMemoryDesign(const VLNV&, QString const&)), Qt::UniqueConnection);\r\n    connect(&treeModel_, SIGNAL(openSWDesign(const VLNV&)), this, SLOT(onOpenSWDesign(const VLNV&)), Qt::UniqueConnection);\r\n    connect(&treeModel_, SIGNAL(openSystemDesign(const VLNV&, QString const&)), this, SLOT(onOpenSystemDesign(const VLNV&, QString const&)), Qt::UniqueConnection);\r\n    connect(&treeModel_, SIGNAL(editItem(const VLNV&)), this, SLOT(onEditItem(const VLNV&)), Qt::UniqueConnection);\r\n\r\n    connect(this, SIGNAL(resetModel()),\r\n        &treeModel_, SLOT(onResetModel()), Qt::UniqueConnection);\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // connect the signals from the hierarchy model\r\n    //-----------------------------------------------------------------------------\r\n\r\n    connect(&hierarchyModel_, SIGNAL(openDesign(const VLNV&, const QString&)),\r\n        this, SIGNAL(openDesign(const VLNV&, const QString&)), Qt::UniqueConnection);\r\n\r\n    connect(&hierarchyModel_, SIGNAL(openMemoryDesign(const VLNV&, const QString&)),\r\n        this, SLOT(onOpenMemoryDesign(const VLNV&, const QString&)), Qt::UniqueConnection);\r\n\r\n    connect(&hierarchyModel_, SIGNAL(openSWDesign(const VLNV&, const QString&)),\r\n        this, SIGNAL(openSWDesign(const VLNV&, const QString&)), Qt::UniqueConnection);\r\n    connect(&hierarchyModel_, SIGNAL(openSystemDesign(const VLNV&, const QString&)),\r\n        this, SIGNAL(openSystemDesign(const VLNV&, const QString&)), Qt::UniqueConnection);\r\n\r\n    connect(&hierarchyModel_, SIGNAL(editItem(const VLNV&)),\r\n        this, SLOT(onEditItem(const VLNV&)), Qt::UniqueConnection);\r\n\r\n\r\n    connect(this, SIGNAL(resetModel()),\r\n        &hierarchyModel_, SLOT(onResetModel()), Qt::UniqueConnection);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LibraryHandler::showNotFoundError()\r\n//-----------------------------------------------------------------------------\r\nvoid LibraryHandler::showNotFoundError(VLNV const& vlnv) const\r\n{\r\n    messageChannel_->showError(tr(\"VLNV: %1 was not found in library.\").arg(vlnv.toString()));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LibraryHandler::addObject()\r\n//-----------------------------------------------------------------------------\r\nbool LibraryHandler::addObject(QSharedPointer<Document> model, QString const& filePath)\r\n{\r\n    QString targetPath = filePath;\r\n\r\n    QFileInfo pathInfo(filePath);\r\n    if (pathInfo.isSymLink() && pathInfo.exists())\r\n    {\r\n        targetPath = pathInfo.symLinkTarget();\r\n    }\r\n\r\n    DocumentFileAccess::writeDocument(model, targetPath);\r\n\r\n    TagManager::getInstance().addNewTags(model->getTags());\r\n\r\n    documentCache_.insert(model->getVlnv(), DocumentInfo(targetPath, model->clone(), validateDocument(model, targetPath)));\r\n\r\n    return true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LibraryHandler::clearCache()\r\n//-----------------------------------------------------------------------------\r\nvoid LibraryHandler::clearCache()\r\n{\r\n    documentCache_.clear();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LibraryHandler::loadAvailableVLNVs()\r\n//-----------------------------------------------------------------------------\r\nvoid LibraryHandler::loadAvailableVLNVs()\r\n{\r\n    messageChannel_->showStatusMessage(tr(\"Scanning library. Please wait...\"));\r\n\r\n    // Read all items before validation.\r\n    // Validation will check for VLNVs in the library, so they must be available before validation.    \r\n    for (auto const& target: loader_.parseLibrary(messageChannel_))\r\n    {\r\n        if (contains(target.vlnv))\r\n        {\r\n            messageChannel_->showMessage(tr(\"VLNV %1 was already found in the library\").arg(\r\n                target.vlnv.toString()));\r\n        }\r\n        else\r\n        {\r\n            documentCache_.insert(target.vlnv, DocumentInfo(target.path));\r\n        }\r\n    }\r\n    messageChannel_->showStatusMessage(tr(\"Ready.\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LibraryHandler::resetModels()\r\n//-----------------------------------------------------------------------------\r\nvoid LibraryHandler::resetModels()\r\n{\r\n    messageChannel_->showStatusMessage(tr(\"Updating library view. Please wait...\"));\r\n\r\n    emit resetModel();\r\n\r\n    messageChannel_->showStatusMessage(tr(\"Ready.\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LibraryHandler::showIntegrityResults()\r\n//-----------------------------------------------------------------------------\r\nvoid LibraryHandler::showIntegrityResults() const\r\n{\r\n    messageChannel_->showMessage(tr(\"========== Library integrity check complete ==========\"));\r\n    messageChannel_->showMessage(tr(\"Total library object count: %1\").arg(documentCache_.size()));\r\n    messageChannel_->showMessage(tr(\"Total file count in the library: %1\").arg(checkResults_.fileCount));\r\n\r\n    // if errors were found then print the summary of error types\r\n    if (checkResults_.documentCount > 0)\r\n    {\r\n        messageChannel_->showError(tr(\"Total items containing errors: %1\").arg(checkResults_.documentCount));\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LibraryData::removeFile()\r\n//-----------------------------------------------------------------------------\r\nbool LibraryHandler::removeFile(QString const& filePath) const\r\n{\r\n    QFile file(filePath);\r\n    if (file.remove() == false)\r\n    {\r\n        messageChannel_->showError(tr(\"File %1 could not be removed from the file system.\").arg(filePath));\r\n        return false;\r\n    }\r\n\r\n    return true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LibraryHandler::validateDocument()\r\n//-----------------------------------------------------------------------------\r\nbool LibraryHandler::validateDocument(QSharedPointer<Document> document, QString const& documentPath)\r\n{\r\n    if (document.isNull() || QFileInfo(documentPath).exists() == false)\r\n    {\r\n        return false;\r\n    }\r\n\r\n    bool documentValid = validator_.validate(document);\r\n\r\n    return documentValid && validateDependentVLNVReferencences(document) &&\r\n        validateDependentDirectories(document, documentPath) &&\r\n        validateDependentFiles(document, documentPath);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LibraryHandler::findErrorsInDocument()\r\n//-----------------------------------------------------------------------------\r\nQVector<QString> LibraryHandler::findErrorsInDocument(QSharedPointer<Document> document, QString const& path)\r\n{\r\n    QVector<QString> errorList;\r\n    if (document.isNull())\r\n    {\r\n        if (path.isEmpty() == false)\r\n        {\r\n            auto it = std::find_if(documentCache_.cbegin(), documentCache_.cend(),\r\n                [path](DocumentInfo const& info) { return info.path == path;  });\r\n            \r\n            if (it != documentCache_.cend())\r\n            {\r\n                errorList.append(tr(\"File %1 could not be read.\").arg(path));\r\n            }\r\n        }\r\n\r\n        return errorList;\r\n    }\r\n\r\n    if (QFileInfo(path).exists() == false)\r\n    {\r\n        errorList.append(tr(\"File %1 for the document was not found.\").arg(path));\r\n    }\r\n\r\n    validator_.findErrorsIn(document, errorList);\r\n\r\n    findErrorsInDependentVLNVReferencences(document, errorList);\r\n\r\n    findErrorsInDependentDirectories(document, path, errorList);\r\n\r\n    findErrorsInDependentFiles(document, path, errorList);\r\n\r\n    return errorList;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LibraryHandler::validateDependentVLNVReferencences()\r\n//-----------------------------------------------------------------------------\r\nbool LibraryHandler::validateDependentVLNVReferencences(QSharedPointer<Document> document)\r\n{\r\n    for (VLNV const& vlnv : document->getDependentVLNVs())\r\n    {\r\n        if (contains(vlnv) == false)\r\n        {\r\n           return false;\r\n        }\r\n    }\r\n\r\n    return true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LibraryHandler::findErrorsInDependentVLNVReferencences()\r\n//-----------------------------------------------------------------------------\r\nvoid LibraryHandler::findErrorsInDependentVLNVReferencences(QSharedPointer<const Document> document,\r\n    QVector<QString>& errorList)\r\n{\r\n    for (VLNV const& vlnv : document->getDependentVLNVs())\r\n    {\r\n        if (contains(vlnv) == false)\r\n        {\r\n            errorList.append(tr(\"The referenced VLNV was not found in the library: %1\").arg(vlnv.toString()));\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LibraryHandler::validateDependentDirectories()\r\n//-----------------------------------------------------------------------------\r\nbool LibraryHandler::validateDependentDirectories(QSharedPointer<Document> document, QString const& documentPath)\r\n{\r\n    for (QString const& directoryPath : document->getDependentDirs())\r\n    {\r\n        if (FileHandler::isValidURI(documentPath, directoryPath) == false)\r\n        {\r\n            return false;\r\n        }\r\n    }\r\n\r\n    return true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LibraryHandler::findErrorsInDependentDirectories()\r\n//-----------------------------------------------------------------------------\r\nvoid LibraryHandler::findErrorsInDependentDirectories(QSharedPointer<const Document> document,\r\n    QString const& documentPath, QVector<QString>& errorList)\r\n{\r\n    for (QString const& directoryPath : document->getDependentDirs())\r\n    {\r\n        if (FileHandler::isValidURI(documentPath, directoryPath) == false)\r\n        {\r\n            errorList.append(tr(\"Directory %1 was not found in the file system.\").arg(directoryPath));\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LibraryHandler::validateDependentFiles()\r\n//-----------------------------------------------------------------------------\r\nbool LibraryHandler::validateDependentFiles(QSharedPointer<Document> document, QString const& documentPath)\r\n{\r\n    for (QString const& filePath : document->getDependentFiles())\r\n    {\r\n        if (FileHandler::isValidURI(documentPath, filePath) == false)\r\n        {\r\n            return false;\r\n        }\r\n        else\r\n        {\r\n            checkResults_.fileCount++;\r\n        }\r\n    }\r\n\r\n    return true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LibraryData::findErrorsInDependentFiles()\r\n//-----------------------------------------------------------------------------\r\nvoid LibraryHandler::findErrorsInDependentFiles(QSharedPointer<const Document> document,\r\n    QString const& documentPath, QVector<QString>& errorList)\r\n{\r\n    for (QString const& filePath : document->getDependentFiles())\r\n    {\r\n        QString resolvedURI = FileHandler::resolveURI(filePath);\r\n\r\n        if (FileHandler::isValidURI(documentPath, resolvedURI) == false)\r\n        {\r\n            errorList.append(tr(\"File %1 was not found in the file system.\").arg(filePath));\r\n        }\r\n        else \r\n        {\r\n            checkResults_.fileCount++;\r\n        }\r\n    }\r\n}\r\n"
  },
  {
    "path": "KactusAPI/library/LibraryItem.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: libraryitem.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Antti Kamppi\r\n// Date: 24.06.2010\r\n//\r\n// Description:\r\n// LibraryItem class is used to create the hierarchical structure of IP library.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"LibraryItem.h\"\r\n\r\n#include <IPXACTmodels/common/VLNV.h>\r\n\r\n#include <QString>\r\n#include <QVector>\r\n#include <QObject>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LibraryItem::LibraryItem()\r\n//-----------------------------------------------------------------------------\r\nLibraryItem::LibraryItem(QObject* parent): QObject(parent),\r\n    name_(tr(\"root\")), \r\n    level_(Level::ROOT),\r\n    childItems_(),\r\n    parentItem_(0),\r\n    vlnv_(),\r\n    valid_(true)\r\n{\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LibraryItem::LibraryItem()\r\n//-----------------------------------------------------------------------------\r\nLibraryItem::LibraryItem(VLNV const& vlnv, Level level, LibraryItem* parent): \r\nQObject(parent), \r\n    name_(), \r\n    level_(level),\r\n    childItems_(), \r\n    parentItem_(parent),\r\n    vlnv_(),\r\n    valid_(true)\r\n{\r\n\t// Choose name for the item in the tree.\r\n\tif (level == Level::VENDOR)\r\n    {\r\n\t\tname_ = vlnv.getVendor();\r\n    }\r\n    else if (level == Level::LIBRARY)\r\n    {\r\n\t\tname_ = vlnv.getLibrary();\r\n    }\r\n\telse if (level == Level::NAME)\r\n    {\r\n\t\tname_ = vlnv.getName();\r\n    }\r\n\telse if (level == Level::VERSION)\r\n    {\r\n\t\tname_ = vlnv.getVersion();\r\n\t\tvlnv_ = vlnv;\r\n    }\r\n\r\n\t// If the vlnv_ is null then the item has child items.\r\n\tif (!vlnv_.isValid())\r\n    {\r\n\t\t// a new item can't yet have children so no need to search for one with a same name\r\n\t\tchildItems_.push_back(new LibraryItem(vlnv, static_cast<Level>(static_cast<int>(level) + 1), this));\r\n\t}\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LibraryItem::~LibraryItem()\r\n//-----------------------------------------------------------------------------\r\nLibraryItem::~LibraryItem()\r\n{\r\n\tchildItems_.clear();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LibraryItem::createChild()\r\n//-----------------------------------------------------------------------------\r\nvoid LibraryItem::createChild(VLNV const& vlnv, Level level)\r\n{\r\n    LibraryItem* existingChild = findChildForLevel(level, vlnv);\r\n    if (existingChild)\r\n    {\r\n        existingChild->createChild(vlnv, static_cast<Level>(static_cast<int>(level) + 1));\r\n        return;\r\n    }\r\n\r\n\t// no child with same name was found so create a new child\r\n\tLibraryItem* newItem = new LibraryItem(vlnv, static_cast<Level>(static_cast<int>(level) + 1), this);\r\n\tchildItems_.push_back(newItem);\r\n\t\r\n\treturn;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LibraryItem::name()\r\n//-----------------------------------------------------------------------------\r\nQString LibraryItem::name() const\r\n{\r\n\treturn name_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LibraryItem::parent()\r\n//-----------------------------------------------------------------------------\r\nLibraryItem *LibraryItem::parent() const\r\n{\r\n\treturn parentItem_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LibraryItem::getLevel()\r\n//-----------------------------------------------------------------------------\r\nLibraryItem::Level LibraryItem::getLevel() const\r\n{\r\n\treturn level_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LibraryItem::child()\r\n//-----------------------------------------------------------------------------\r\nLibraryItem *LibraryItem::child(int index) const\r\n{\r\n\treturn childItems_[index];\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LibraryItem::row()\r\n//-----------------------------------------------------------------------------\r\nint LibraryItem::row()\r\n{\r\n\tif (parentItem_)\r\n    {\r\n\t\treturn parentItem_->getIndexOf(this);\r\n\t}\r\n\r\n\t// If parent does not exist then invalid index is returned.\r\n\treturn -1;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LibraryItem::getNumberOfChildren()\r\n//-----------------------------------------------------------------------------\r\nint LibraryItem::getNumberOfChildren() const\r\n{\r\n\treturn childItems_.size();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LibraryItem::getVLNV()\r\n//-----------------------------------------------------------------------------\r\nVLNV LibraryItem::getVLNV() const\r\n{\r\n\treturn vlnv_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LibraryItem::getIndexOf()\r\n//-----------------------------------------------------------------------------\r\nint LibraryItem::getIndexOf(LibraryItem* item)\r\n{\r\n\treturn childItems_.indexOf(item);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LibraryItem::hasChildren()\r\n//-----------------------------------------------------------------------------\r\nbool LibraryItem::hasChildren() const\r\n{\r\n\treturn !childItems_.isEmpty();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LibraryItem::getVLNVs()\r\n//-----------------------------------------------------------------------------\r\nQVector<VLNV> LibraryItem::getVLNVs() const\r\n{\t\r\n    QVector<VLNV> vlnvList;\r\n\r\n\t// if this is a leaf-object\r\n\tif (vlnv_.isValid())\r\n    {\r\n\t\tvlnvList.append(vlnv_);\r\n\t}\r\n\telse \r\n    {\r\n\t\tfor (LibraryItem const* child : childItems_)\r\n        {\r\n\t\t\tvlnvList += child->getVLNVs();\r\n\t\t}\r\n\t}\r\n\r\n    return vlnvList;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LibraryItem::removeChild()\r\n//-----------------------------------------------------------------------------\r\nvoid LibraryItem::removeChild(LibraryItem* childItem )\r\n{\r\n\tQ_ASSERT_X(childItem, \"LibraryItem::removeChild()\",\t\"Null LibraryItem-pointer\");\r\n\r\n    int index = childItems_.indexOf(childItem);\r\n\r\n\tif (index != -1)\r\n    {\r\n\t\tdelete childItems_.value(index);\r\n\t\tchildItems_.removeAt(index);\r\n\t}\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LibraryItem::findHighestUnique()\r\n//-----------------------------------------------------------------------------\r\nLibraryItem* LibraryItem::findHighestUnique(LibraryItem* childItem)\r\n{\r\n\t// if this is the root item\r\n\tif (!parentItem_)\r\n    {\r\n\t\treturn childItem;\r\n    }\r\n\telse if (!childItem)\r\n    {\r\n\t\treturn parentItem_->findHighestUnique(this);\r\n    }\r\n\telse if (childItems_.contains(childItem) && childItems_.size() == 1)\r\n    {\r\n\t\t// this is the highest to remove unless parent item is also removed.\r\n\t\treturn parentItem_->findHighestUnique(this);\r\n\t}\r\n\r\n\treturn childItem;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LibraryItem::findHighestUnique()\r\n//-----------------------------------------------------------------------------\r\nLibraryItem* LibraryItem::findHighestUnique(VLNV const& vlnv)\r\n{\r\n    if (level_ == Level::VERSION)\r\n    {\r\n        return parentItem_->findHighestUnique(this);\r\n    }\r\n\r\n    LibraryItem* existingChild = findChildForLevel(level_, vlnv);\r\n    if (existingChild)\r\n    {\r\n        return existingChild->findHighestUnique(vlnv);\r\n    }\r\n\r\n\t// if there was no child that matched the vlnv then this must be the highest unique that can be used.\r\n\treturn this;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LibraryItem::findItem()\r\n//-----------------------------------------------------------------------------\r\nLibraryItem* LibraryItem::findItem(VLNV const& vlnv)\r\n{\r\n    if (level_ == Level::VERSION)\r\n    {\r\n        if (vlnv_ == vlnv)\r\n        {\r\n            return this;\r\n        }\r\n        else\r\n        {\r\n            return 0;\r\n        }\r\n    }\r\n\r\n    LibraryItem* existingChild = findChildForLevel(level_, vlnv);\r\n    if (existingChild)\r\n    {\r\n        return existingChild->findItem(vlnv);\r\n    }\r\n\r\n\t// If no match was found.\r\n\treturn 0;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LibraryItem::setVlnv()\r\n//-----------------------------------------------------------------------------\r\nvoid LibraryItem::setVlnv(VLNV& vlnv)\r\n{\r\n    if (level_ == Level::ROOT)\r\n    {\r\n        return;\r\n    }\r\n    \r\n    \r\n    if (level_ == Level::VENDOR)\r\n    {\r\n        vlnv.setVendor(name_);        \r\n    }\r\n    else if (level_ == Level::LIBRARY)\r\n    {\r\n        vlnv.setLibrary(name_);        \r\n    }\r\n    else if (level_ == Level::NAME)\r\n    {\r\n        vlnv.setName(name_);        \r\n    }\r\n    else if (level_ == Level::VERSION) \r\n    {\r\n        vlnv.setVersion(name_);\r\n        vlnv.setType(vlnv_.getType());    \r\n    }\r\n\r\n    parentItem_->setVlnv(vlnv);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LibraryItem::clear()\r\n//-----------------------------------------------------------------------------\r\nvoid LibraryItem::clear()\r\n{\r\n\tqDeleteAll(childItems_);\r\n\tchildItems_.clear();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LibraryItem::getVendors()\r\n//-----------------------------------------------------------------------------\r\nQVector<LibraryItem*> LibraryItem::getVendors() const\r\n{\r\n    if (level_ == Level::ROOT)\r\n    {\r\n        return childItems_;\r\n    }\r\n    else\r\n    {\r\n        Q_ASSERT_X(false, \"LibraryItem::getVendors\", \"If came to code that should never be executed\");\r\n        return QVector<LibraryItem*>();\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LibraryItem::getLibraries()\r\n//-----------------------------------------------------------------------------\r\nQVector<LibraryItem*> LibraryItem::getLibraries() const\r\n{\r\n    if (level_ == Level::VENDOR)\r\n    {\r\n        return childItems_;\r\n    }\r\n\r\n    QVector<LibraryItem*> list;\r\n    if (level_ == Level::ROOT)\r\n    {\r\n        for (LibraryItem const* item : childItems_)\r\n        {\r\n            list += item->getLibraries();\r\n        }\r\n    }\r\n    else\r\n    {\r\n        Q_ASSERT_X(false, \"LibraryItem::getVendors\", \"Switch came to code that should never be executed\");\r\n    }\r\n\r\n    return list;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LibraryItem::getNames()\r\n//-----------------------------------------------------------------------------\r\nQVector<LibraryItem*> LibraryItem::getNames() const\r\n{\r\n    if (level_ == Level::LIBRARY)\r\n    {\r\n        return childItems_;\r\n    }\r\n\r\n    QVector<LibraryItem*> list;\r\n\r\n    if (level_ == Level::ROOT || level_ == Level::VENDOR)\r\n    {\r\n        for (LibraryItem const* item : childItems_)\r\n        {\r\n            list += item->getNames();\r\n        }\r\n    }\r\n    else\r\n    {\r\n        Q_ASSERT_X(false, \"LibraryItem::getVendors\", \"Switch came to code that should never be executed\");\t\r\n    }\r\n\r\n    return list;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LibraryItem::getVersions()\r\n//-----------------------------------------------------------------------------\r\nQVector<LibraryItem*> LibraryItem::getVersions() const\r\n{\r\n    if (level_ == Level::NAME)\r\n    {\r\n        return childItems_;\r\n    }\r\n\r\n\tQVector<LibraryItem*> list;\r\n    for (LibraryItem const* item : childItems_)\r\n    {\r\n        list += item->getNames();\r\n    }\r\n    return list;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LibraryItem::isValid()\r\n//-----------------------------------------------------------------------------\r\nbool LibraryItem::isValid() const\r\n{\r\n    return valid_;         \r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LibraryItem::setValid()\r\n//-----------------------------------------------------------------------------\r\nvoid LibraryItem::setValid(bool valid)\r\n{\r\n    valid_ = valid;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LibraryItem::findChildForLevel()\r\n//-----------------------------------------------------------------------------\r\nLibraryItem* LibraryItem::findChildForLevel(Level level, VLNV const& vlnv)\r\n{\r\n    QString childNameToMatch;\r\n\r\n    if (level == Level::ROOT)\r\n    {\r\n        childNameToMatch = vlnv.getVendor();\r\n    }\r\n    else if (level == Level::VENDOR)\r\n    {\r\n        childNameToMatch = vlnv.getLibrary();\r\n    }\r\n    else if (level == Level::LIBRARY)\r\n    {\r\n        childNameToMatch = vlnv.getName();\r\n    }\r\n    else if (level == Level::NAME)\r\n    {\r\n        childNameToMatch = vlnv.getVersion();\r\n    }\t\r\n\r\n    for (LibraryItem* child : childItems_)\r\n    {\r\n        if (child->name() == childNameToMatch)\r\n        {\r\n            return child;\r\n        }\r\n    }\r\n\r\n    return 0;\r\n}\r\n"
  },
  {
    "path": "KactusAPI/library/LibraryLoader.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: LibraryLoader.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Esko Pekkarinen\n// Date: 07.04.2018\n//\n// Description:\n// Class for IP-XACT file search and type parsing.\n//-----------------------------------------------------------------------------\n\n#include \"LibraryLoader.h\"\n\n#include <QDir>\n#include <QDirIterator>\n#include <QFileInfo>\n#include <QSettings>\n#include <QXmlStreamReader>\n\n//-----------------------------------------------------------------------------\n// Function: LibraryLoader::parseLibrary()\n//-----------------------------------------------------------------------------\nQVector<LibraryLoader::LoadTarget> LibraryLoader::parseLibrary(MessageMediator const* messageChannel) const\n{\n    QVector<LoadTarget> vlnvPaths;\n    QStringList xmlFilter{ QStringLiteral(\"*.xml\") };\n\n    for (QString const& location : QSettings().value(QStringLiteral(\"Library/ActiveLocations\")).toStringList())\n    {        \n        QDirIterator fileIterator(location, xmlFilter, QDir::Files,\n            QDirIterator::Subdirectories | QDirIterator::FollowSymlinks);\n\n        while (fileIterator.hasNext())\n        {\n            QString filePath(fileIterator.next());\n\n            VLNV vlnv = getDocumentVLNV(filePath, messageChannel);\n            if (vlnv.isValid())\n            {\n                vlnvPaths.append(LoadTarget(vlnv, filePath));\n            }\n        }\n    }\n\n    return vlnvPaths;\n}\n\n//-----------------------------------------------------------------------------\n// Function: LibraryLoader::clean()\n//-----------------------------------------------------------------------------\nvoid LibraryLoader::clean(QStringList const& changedDirectories) const\n{\n    QStringList libraryLocations = QSettings().value(QStringLiteral(\"Library/Locations\")).toStringList();\n\n    for (QString const& changedDirectory : changedDirectories)\n    {\n        clearDirectoryStructure(changedDirectory, libraryLocations);\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: LibraryLoader::getDocumentVLNV()\n//-----------------------------------------------------------------------------\nVLNV LibraryLoader::getDocumentVLNV(QString const& path, MessageMediator const* messageChannel) const\n{\n    QFile documentFile(path);\n    if (!documentFile.open(QFile::ReadOnly))\n    {\n        messageChannel->showError(QObject::tr(\"File %1 could not be read.\").arg(path));\n        return VLNV();\n    }\n\n    QXmlStreamReader documentReader(&documentFile);\n    documentReader.readNextStartElement();\n\n    QString type = documentReader.qualifiedName().toString();\n    if (type.startsWith(QStringLiteral(\"spirit:\")))\n    {\n        messageChannel->showMessage(QObject::tr(\"File %1 contains an IP-XACT description not compatible \"\n            \"with the supported standards and could not be read.\").arg(path));\n        documentFile.close();\n        return VLNV();\n    }\n\n    if (!type.startsWith(QStringLiteral(\"ipxact:\")) && !type.startsWith(QStringLiteral(\"kactus2:\")))\n    {\n        return VLNV();\n    }\n\n    // Find the first element of the VLVN.\n    while (documentReader.readNextStartElement() &&\n        documentReader.qualifiedName().compare(QStringLiteral(\"ipxact:vendor\")) != 0)\n    {\n        // Empty loop on purpose.\n    }\n\n    QString vlnvString = documentReader.readElementText();\n    for (int i = 0; i < 3; ++i)\n    {\n        documentReader.readNextStartElement();\n        vlnvString.append(':');\n        vlnvString.append(documentReader.readElementText());\n    }\n\n    documentFile.close();\n\n    VLNV documentVLNV(VLNV::string2Type(type), vlnvString);\n    if (!documentVLNV.isValid())\n    {\n        messageChannel->showError(QObject::tr(\"File %1 contains an invalid IP-XACT identifier %2.\").arg(path,\n            vlnvString));\n    }\n\n    return documentVLNV;\n}\n\n//-----------------------------------------------------------------------------\n// Function: LibraryLoader::clearDirectoryStructure()\n//-----------------------------------------------------------------------------\nvoid LibraryLoader::clearDirectoryStructure(QString const& dirPath, QStringList const& libraryLocations) const\n{\n    QDir dir(dirPath);\n\n    while (containsPath(QDir::cleanPath(dir.absolutePath()), libraryLocations))\n    {\n        QString directoryName = dir.dirName();\n\n        // if not possible to move up anymore (the dir could possibly have been destroyed already).\n        if (!dir.cdUp())\n        {\n            return;\n        }\n\n        // if the directory is not empty then it can't be removed and we can stop.\n        if (!dir.rmdir(directoryName))\n        {\n            return;\n        }\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: LibraryLoader::containsPath()\n//-----------------------------------------------------------------------------\nbool LibraryLoader::containsPath(QString const& path, QStringList const& pathsToSearch) const\n{\n    // As long as the path is not the same as search path but still contains the search path,\n    // it is a parent directory of the path.\n    return std::any_of(pathsToSearch.cbegin(), pathsToSearch.cend(), [&path](auto const& searchPath)\n        {\n            return path.contains(searchPath) && path.compare(searchPath) != 0;\n        });\n}\n"
  },
  {
    "path": "KactusAPI/library/LibraryTreeModel.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: librarytreemodel.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 20.12.2010\r\n//\r\n// Description:\r\n// The model that contains the LibraryItems to display library hierarchically.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"LibraryTreeModel.h\"\r\n#include \"LibraryItem.h\"\r\n#include \"LibraryInterface.h\"\r\n\r\n#include <IPXACTmodels/common/Document.h>\r\n\r\n#include <IPXACTmodels/Component/Component.h>\r\n#include <IPXACTmodels/Design/Design.h>\r\n\r\n#include <IPXACTmodels/kactusExtensions/KactusAttribute.h>\r\n\r\n#include <common/KactusColors.h>\r\n\r\n#include <QSharedPointer>\r\n#include <QBrush>\r\n\r\n#include <QIcon>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LibraryTreeModel::LibraryTreeModel()\r\n//-----------------------------------------------------------------------------\r\nLibraryTreeModel::LibraryTreeModel(LibraryInterface* handler, QObject* parent):\r\nQAbstractItemModel(parent),\r\n    rootItem_(),\r\n    handler_(handler)\r\n{\r\n    onResetModel();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LibraryTreeModel::~LibraryTreeModel()\r\n//-----------------------------------------------------------------------------\r\nLibraryTreeModel::~LibraryTreeModel()\r\n{\r\n    delete rootItem_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LibraryTreeModel::headerData()\r\n//-----------------------------------------------------------------------------\r\nQVariant LibraryTreeModel::headerData(int section, Qt::Orientation orientation, int role) const\r\n{\r\n    if (section == 0 && orientation == Qt::Horizontal && role == Qt::DisplayRole)\r\n    {\r\n        return tr(\"Library items\");\r\n    }\r\n    \r\n    return QVariant();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LibraryTreeModel::columnCount()\r\n//-----------------------------------------------------------------------------\r\nint LibraryTreeModel::columnCount(QModelIndex const&) const \r\n{\r\n    return 1;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LibraryTreeModel::rowCount()\r\n//-----------------------------------------------------------------------------\r\nint LibraryTreeModel::rowCount(QModelIndex const& parent) const\r\n{\r\n    // only one column exists\r\n    if (parent.column() > 0)\r\n    {\r\n        return 0;\r\n    }\r\n\r\n    LibraryItem *parentItem = 0;\r\n\r\n    // if the given item is invalid, it is interpreted as root item\r\n    if (!parent.isValid()) \r\n    {\r\n        parentItem = rootItem_;\r\n    }\r\n    else\r\n    {\r\n        parentItem = static_cast<LibraryItem*>(parent.internalPointer());\r\n    }\r\n\r\n    // return how many children the parent has\r\n    return parentItem->getNumberOfChildren();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LibraryTreeModel::index()\r\n//-----------------------------------------------------------------------------\r\nQModelIndex LibraryTreeModel::index(int row, int column, QModelIndex const& parent) const\r\n{\r\n    if (!hasIndex(row, column, parent))\r\n    {\r\n        return QModelIndex();\r\n    }\r\n\r\n    LibraryItem* parentItem = 0;\r\n\r\n    // if the index of the parent is invalid then it is the root item\r\n    if (!parent.isValid()) \r\n    {\r\n        parentItem = rootItem_;\r\n    }\r\n    else\r\n    {\r\n        parentItem = static_cast<LibraryItem*>(parent.internalPointer());\r\n    }\r\n\r\n    if (!parentItem)\r\n    {\r\n        return QModelIndex();\r\n    }\r\n\r\n    // find the child item of the parent\r\n    LibraryItem *child = parentItem->child(row);\r\n\r\n    // if the child is found\r\n    if (child)\r\n    {\r\n        return createIndex(row, column, child);\r\n    }\r\n    else\r\n    {\r\n        return QModelIndex();\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LibraryTreeModel::index()\r\n//-----------------------------------------------------------------------------\r\nQModelIndex LibraryTreeModel::index(LibraryItem* item) \r\n{\r\n    // if pointer is null\r\n    if (!item)\r\n    {\r\n        return QModelIndex();\r\n    }\r\n\r\n    // if this item has no parent then it is the root item\r\n    LibraryItem* parent = item->parent();\r\n    if (!parent)\r\n    {\r\n        return QModelIndex();\r\n    }\r\n\r\n    // create the index for the child\r\n    return createIndex(item->row(), 0, item);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LibraryTreeModel::parent()\r\n//-----------------------------------------------------------------------------\r\nQModelIndex LibraryTreeModel::parent(QModelIndex const& child) const\r\n{\r\n    if(!child.isValid())\r\n    {\r\n        return QModelIndex();\r\n    }\r\n\r\n    LibraryItem *childItem = static_cast<LibraryItem*>(child.internalPointer());\r\n    LibraryItem *parent = childItem->parent();\r\n\r\n    // If the parent does not exist then this item is the root item.\r\n    if (!parent)\r\n    {\r\n        return QModelIndex();\r\n    }\r\n\r\n    // If row is invalid then the grandparent does not exist and parent is the root.\r\n    int row = parent->row();\r\n    if (row == -1)\r\n    {\r\n        return QModelIndex();\r\n    }\r\n\r\n    return createIndex(row, 0, parent);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LibraryTreeModel::data()\r\n//-----------------------------------------------------------------------------\r\nQVariant LibraryTreeModel::data(QModelIndex const& index, int role) const\r\n{\r\n    if (!index.isValid())\r\n    {\r\n        return QVariant();\r\n    }\r\n\r\n    LibraryItem* item = static_cast<LibraryItem*>(index.internalPointer());\r\n\r\n    if (role == Qt::DisplayRole)\r\n    {\r\n        return item->name();\r\n    }\r\n\r\n    else if (role == Qt::ForegroundRole)\r\n    {\r\n        if (item->isValid())\r\n        {\r\n            return KactusColors::REGULAR_TEXT;\r\n        }\r\n        else\r\n        {\r\n            return KactusColors::ERROR;\r\n        }\r\n    }\r\n\r\n    else if (role == Qt::ToolTipRole)\r\n    {\r\n        VLNV vlnv = item->getVLNV();\r\n\r\n        // if item can identify a single library object\r\n        if (vlnv.isValid())\r\n        {\r\n            QString text = \"<b>Vendor:</b> \" + vlnv.getVendor() + \"<br>\" +\r\n                \"<b>Library:</b> \" + vlnv.getLibrary() + \"<br>\" + \r\n                \"<b>Name:</b> \" + vlnv.getName() + \"<br>\" +\r\n                \"<b>Version:</b> \" + vlnv.getVersion() + \"<br>\";\r\n\r\n            QSharedPointer<Document const> document = handler_->getModelReadOnly(vlnv);\r\n\r\n            text += \"<br><b>Compatibility:</b> \" + Document::toString(document->getRevision());\r\n\r\n            if (document != 0 && !document->getDescription().isEmpty())\r\n            {\r\n                text += \"<br><b>Description:</b><br>\" + document->getDescription();\r\n            }\r\n\r\n            text += \"<br><b>File Path:</b><br>\" + handler_->getPath(vlnv);\r\n            return text;\r\n        }\r\n\r\n        // if item did not represent a single vlnv item\r\n        return QVariant();\r\n    }\r\n    \r\n    else if (role == Qt::DecorationRole)\r\n    {        \r\n        VLNV vlnv = item->getVLNV();\r\n        \r\n        // if item represents a single vlnv object\r\n        if (vlnv.isValid())\r\n        {\r\n            VLNV::IPXactType documentType = vlnv.getType();\r\n            if (documentType == VLNV::COMPONENT)\r\n            {\r\n                QSharedPointer<Component const> component = \r\n                    handler_->getModelReadOnly(vlnv).staticCast<Component const>();\r\n\r\n                if (component != 0)\r\n                {\r\n                    if (component->getImplementation() == KactusAttribute::SYSTEM)\r\n                    {\r\n                        return QIcon(\":/icons/common/graphics/system-component.png\");\r\n                    }\r\n                    else if (component->getImplementation() == KactusAttribute::SW)\r\n                    {\r\n                        if (component->isHierarchical())\r\n                        {\r\n                            return QIcon(\":/icons/common/graphics/hier-sw-component.png\");\r\n                        }\r\n                        else\r\n                        {\r\n                            return QIcon(\":/icons/common/graphics/sw-component48x48.png\");\r\n                        }\r\n                    }\r\n                    else\r\n                    {\r\n                        if (component->isHierarchical())\r\n                        {\r\n                            return QIcon(\":/icons/common/graphics/hier-hw-component.png\");\r\n                        }\r\n                        else\r\n                        {\r\n                            return QIcon(\":/icons/common/graphics/hw-component.png\");\r\n                        }\r\n                    }\r\n                }\r\n\r\n                return QIcon(\":/icons/common/graphics/hw-component.png\");\r\n            }\r\n\r\n            else if (documentType == VLNV::ABSTRACTIONDEFINITION)\r\n            {\r\n                return QIcon(\":/icons/common/graphics/abs-def.png\");\r\n            }\r\n\r\n            else if (documentType == VLNV::BUSDEFINITION)\r\n            {\r\n                return QIcon(\":/icons/common/graphics/bus-def.png\");\r\n            }\r\n\r\n            else if (documentType == VLNV::CATALOG)\r\n            {\r\n                return QIcon(\":/icons/common/graphics/catalog.png\");\r\n            }\r\n\r\n            else if (documentType == VLNV::COMDEFINITION)\r\n            {\r\n                return QIcon(\":/icons/common/graphics/new-com_definition.png\");\r\n            }\r\n\r\n            else if (documentType == VLNV::APIDEFINITION)\r\n            {\r\n                return QIcon(\":/icons/common/graphics/new-api_definition.png\");\r\n            }\r\n\r\n            else if (documentType == VLNV::DESIGN)\r\n            {\r\n                // Determine the design type.\r\n                QSharedPointer<const Design> design = handler_->getModelReadOnly<Design>(vlnv);\r\n                if (design && (design->getImplementation() == KactusAttribute::SW ||\r\n                    design->getImplementation() == KactusAttribute::SYSTEM))\r\n                {\r\n                    return QIcon(\":/icons/common/graphics/sw-design48x48.png\");\r\n                }\r\n                else\r\n                {               \r\n                    return QIcon(\":/icons/common/graphics/hw-design.png\");\r\n                }\r\n            }\r\n\r\n            else if (documentType == VLNV::DESIGNCONFIGURATION)\r\n            {\r\n                return QIcon(\":/icons/common/graphics/configuration.png\");\r\n            }\r\n        }\r\n    }\r\n    \r\n    return QVariant();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LibraryTreeModel::flags()\r\n//-----------------------------------------------------------------------------\r\nQt::ItemFlags LibraryTreeModel::flags(QModelIndex const& index) const\r\n{\r\n    if (!index.isValid())\r\n    {\r\n        return Qt::ItemIsEnabled;\r\n    }\r\n\r\n    return (Qt::ItemIsEnabled | Qt::ItemIsSelectable);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LibraryTreeModel::hasChildren()\r\n//-----------------------------------------------------------------------------\r\nbool LibraryTreeModel::hasChildren(QModelIndex const& parent) const\r\n{\r\n    // only one column exists\r\n    if (parent.column() > 0)\r\n    {\r\n        return false;\r\n    }\r\n\r\n    LibraryItem *parentItem = 0;\r\n\r\n    // if the given item is invalid, it is interpreted as root item\r\n    if (!parent.isValid())\r\n    {\r\n        parentItem = rootItem_;\r\n    }\r\n    else\r\n    {\r\n        parentItem = static_cast<LibraryItem*>(parent.internalPointer());\r\n    }\r\n\r\n    // return how many children the parent has\r\n    return parentItem->hasChildren();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LibraryTreeModel::onExportItem()\r\n//-----------------------------------------------------------------------------\r\nvoid LibraryTreeModel::onExportItem(QModelIndex const& index)\r\n{\r\n    if (!index.isValid())\r\n    {\r\n        return;\r\n    }\r\n\r\n    LibraryItem* item = static_cast<LibraryItem*>(index.internalPointer());\r\n\r\n    emit exportItems(item->getVLNVs().toList());\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LibraryTreeModel::onDeleteItem()\r\n//-----------------------------------------------------------------------------\r\nvoid LibraryTreeModel::onDeleteItem(QModelIndex const& index)\r\n{\r\n    if (!index.isValid())\r\n    {\r\n        return;\r\n    }\r\n\r\n    LibraryItem* child = static_cast<LibraryItem*>(index.internalPointer());\r\n    LibraryItem* toRemove = child->findHighestUnique();\r\n\r\n    // inform the library handler that these VLNVs should be removed\r\n    emit removeVLNV(toRemove->getVLNVs().toList());\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LibraryTreeModel::onRemoveVLNV()\r\n//-----------------------------------------------------------------------------\r\nvoid LibraryTreeModel::onRemoveVLNV(VLNV const& vlnv)\r\n{\r\n    if (!vlnv.isValid())\r\n    {\r\n        return;\r\n    }\r\n\r\n    LibraryItem* toRemove = rootItem_->findHighestUnique(vlnv);\r\n    \r\n    // Remove the item and it's sub-items.\r\n    if (toRemove)\r\n    {\r\n        removeLibraryItem(toRemove);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LibraryTreeModel::onAddVLNV()\r\n//-----------------------------------------------------------------------------\r\nvoid LibraryTreeModel::onAddVLNV(VLNV const& vlnv)\r\n{\r\n    if (!vlnv.isValid())\r\n    {\r\n        return;\r\n    }\r\n\r\n    LibraryItem* parentItem = rootItem_->findHighestUnique(vlnv);\r\n\r\n    QModelIndex parentIndex;\r\n\r\n    // if the highest unique is not the root\r\n    if (parentItem != rootItem_)\r\n    {\r\n        int row = parentItem->row();\r\n        Q_ASSERT(row >= 0);\r\n\r\n        parentIndex = createIndex(row, 0, parentItem);\r\n    }\r\n    \r\n    int rowToAdd = parentItem->getNumberOfChildren();\r\n\r\n    beginInsertRows(parentIndex, rowToAdd, rowToAdd);\r\n    rootItem_->createChild(vlnv, static_cast<LibraryItem::Level>(0));\r\n    endInsertRows();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LibraryTreeModel::removeLibraryItem()\r\n//-----------------------------------------------------------------------------\r\nvoid LibraryTreeModel::removeLibraryItem(LibraryItem* toRemove)\r\n{\r\n    int row = toRemove->parent()->getIndexOf(toRemove);\r\n\r\n    QModelIndex removeIndex = createIndex(row, 0, toRemove);\r\n\r\n    // get the model index of the parent\r\n    QModelIndex parentIndex = parent(removeIndex);\r\n\r\n     beginRemoveRows(parentIndex, row, row);\r\n     toRemove->parent()->removeChild(toRemove);\r\n     endRemoveRows();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LibraryTreeModel::onResetModel()\r\n//-----------------------------------------------------------------------------\r\nvoid LibraryTreeModel::onResetModel()\r\n{    \r\n    beginResetModel();\r\n\r\n    if (!rootItem_)\r\n    {\r\n        rootItem_ = new LibraryItem(this);\r\n    }\r\n    else\r\n    {\r\n        rootItem_->clear();\r\n    }\r\n\r\n    // get the items to be displayed from the data source\r\n    for (VLNV const& item : handler_->getAllVLNVs())\r\n    {\r\n        VLNV::IPXactType documentType = item.getType();\r\n        if (documentType == VLNV::ABSTRACTIONDEFINITION || documentType == VLNV::BUSDEFINITION ||\r\n            documentType == VLNV::CATALOG || documentType == VLNV::COMPONENT ||\r\n            documentType == VLNV::DESIGN || documentType == VLNV::DESIGNCONFIGURATION ||\r\n            documentType == VLNV::APIDEFINITION || documentType == VLNV::COMDEFINITION)\r\n        {\r\n            rootItem_->createChild(item, LibraryItem::Level::ROOT);\r\n        }\r\n    }\r\n\r\n    validate(rootItem_);\r\n\r\n    endResetModel();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LibraryTreeModel::onDocumentUpdated()\r\n//-----------------------------------------------------------------------------\r\nvoid LibraryTreeModel::onDocumentUpdated(VLNV const& vlnv)\r\n{\r\n    LibraryItem* item = rootItem_->findHighestUnique(vlnv);\r\n    if (item)\r\n    {\r\n        validate(item);\r\n\r\n        QModelIndex itemIndex = index(item);\r\n        emit dataChanged(itemIndex, itemIndex);\r\n    }    \r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LibraryTreeModel::getRoot()\r\n//-----------------------------------------------------------------------------\r\nLibraryItem* LibraryTreeModel::getRoot() const\r\n{\r\n    return rootItem_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LibraryTreeModel::onCreateAbsDef()\r\n//-----------------------------------------------------------------------------\r\nvoid LibraryTreeModel::onCreateAbsDef(QModelIndex const& index)\r\n{\r\n    if (!index.isValid())\r\n    {\r\n        return;\r\n    }\r\n\r\n    LibraryItem* item = static_cast<LibraryItem*>(index.internalPointer());\r\n\r\n    VLNV vlnv;\r\n    vlnv.setType(VLNV::BUSDEFINITION);\r\n    item->setVlnv(vlnv);\r\n\r\n    emit createAbsDef(vlnv);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LibraryTreeModel::onOpenDocument()\r\n//-----------------------------------------------------------------------------\r\nvoid LibraryTreeModel::onOpenDocument(QModelIndex const& index)\r\n{\r\n    if (!index.isValid())\r\n    {\r\n        return;\r\n    }\r\n\r\n    LibraryItem* item = static_cast<LibraryItem*>(index.internalPointer());\r\n    VLNV vlnv = item->getVLNV();\r\n\r\n    if (vlnv.isValid())\r\n    {\r\n        emit editItem(vlnv);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LibraryTreeModel::onOpenDesign()\r\n//-----------------------------------------------------------------------------\r\nvoid LibraryTreeModel::onOpenDesign(QModelIndex const& index, QString const& viewName)\r\n{\r\n    if (!index.isValid())\r\n    {\r\n        return;\r\n    }\r\n\r\n    LibraryItem* item = static_cast<LibraryItem*>(index.internalPointer());\r\n    VLNV vlnv = item->getVLNV();\r\n\r\n    if (vlnv.isValid())\r\n    {\r\n        emit openDesign(vlnv, viewName);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: librarytreemodel::onOpenMemoryDesign()\r\n//-----------------------------------------------------------------------------\r\nvoid LibraryTreeModel::onOpenMemoryDesign(QModelIndex const& index, QString const& viewName)\r\n{\r\n    if (!index.isValid())\r\n    {\r\n        return;\r\n    }\r\n\r\n    LibraryItem* item = static_cast<LibraryItem*>(index.internalPointer());\r\n    if (item)\r\n    {\r\n        VLNV vlnv = item->getVLNV();\r\n\r\n        if (vlnv.isValid())\r\n        {\r\n            emit openMemoryDesign(vlnv, viewName);\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LibraryTreeModel::onOpenSWDesign()\r\n//-----------------------------------------------------------------------------\r\nvoid LibraryTreeModel::onOpenSWDesign(QModelIndex const& index)\r\n{\r\n    if (!index.isValid())\r\n    {\r\n        return;\r\n    }\r\n\r\n    LibraryItem* item = static_cast<LibraryItem*>(index.internalPointer());\r\n    VLNV vlnv = item->getVLNV();\r\n\r\n    if (vlnv.isValid())\r\n    {\r\n        emit openSWDesign(vlnv);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LibraryTreeModel::onOpenSystemDesign()\r\n//-----------------------------------------------------------------------------\r\nvoid LibraryTreeModel::onOpenSystemDesign(QModelIndex const& index, QString const& viewName)\r\n{\r\n    if (!index.isValid())\r\n    {\r\n        return;\r\n    }\r\n\r\n    LibraryItem* item = static_cast<LibraryItem*>(index.internalPointer());\r\n    VLNV vlnv = item->getVLNV();\r\n\r\n    if (vlnv.isValid())\r\n    {\r\n        emit openSystemDesign(vlnv, viewName);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LibraryTreeModel::onCreateNewDesign()\r\n//-----------------------------------------------------------------------------\r\nvoid LibraryTreeModel::onCreateNewDesign(QModelIndex const& index)\r\n{\r\n    if (!index.isValid())\r\n    {\r\n        return;\r\n    }\r\n\r\n    LibraryItem* item = static_cast<LibraryItem*>(index.internalPointer());\r\n\r\n    VLNV vlnv;\r\n    vlnv.setType(VLNV::COMPONENT);\r\n    item->setVlnv(vlnv);\r\n\r\n    emit createDesign(vlnv);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LibraryTreeModel::onCreateNewSWDesign()\r\n//-----------------------------------------------------------------------------\r\nvoid LibraryTreeModel::onCreateNewSWDesign(QModelIndex const& index)\r\n{\r\n    if (!index.isValid())\r\n    {\r\n        return;\r\n    }\r\n\r\n    LibraryItem* item = static_cast<LibraryItem*>(index.internalPointer());\r\n\r\n    VLNV vlnv;\r\n    vlnv.setType(VLNV::COMPONENT);\r\n    item->setVlnv(vlnv);\r\n\r\n    emit createSWDesign(vlnv);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LibraryTreeModel::onCreateNewSystemDesign()\r\n//-----------------------------------------------------------------------------\r\nvoid LibraryTreeModel::onCreateNewSystemDesign(QModelIndex const& index)\r\n{\r\n    if (!index.isValid())\r\n    {\r\n        return;\r\n    }\r\n\r\n    LibraryItem* item = static_cast<LibraryItem*>(index.internalPointer());\r\n\r\n    VLNV vlnv;\r\n    vlnv.setType(VLNV::COMPONENT);\r\n    item->setVlnv(vlnv);\r\n\r\n    emit createSystemDesign(vlnv);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HierarchyModel::onShowErrors()\r\n//-----------------------------------------------------------------------------\r\nvoid LibraryTreeModel::onShowErrors(QModelIndex const& index)\r\n{\r\n    if (!index.isValid())\r\n    {\r\n        return;\r\n    }\r\n\r\n    LibraryItem* item = static_cast<LibraryItem*>(index.internalPointer());\r\n    emit showErrors(item->getVLNV());\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LibraryTreeModel::validate()\r\n//-----------------------------------------------------------------------------\r\nbool LibraryTreeModel::validate(LibraryItem* item)\r\n{\r\n    bool isValid = false;\r\n    if (item->getLevel() == LibraryItem::Level::VERSION)\r\n    {\r\n        isValid = handler_->isValid(item->getVLNV());\r\n    }\r\n    else\r\n    {\r\n        bool hasOneValidChild = false;\r\n\r\n        int childCount = item->getNumberOfChildren();        \r\n        for (int i = 0; i < childCount; i++)\r\n        {\r\n            bool childIsValid = validate(item->child(i));\r\n            hasOneValidChild |= childIsValid;\r\n        }\r\n\r\n        isValid = hasOneValidChild;\r\n    }\r\n\r\n    item->setValid(isValid);\r\n    return isValid;\r\n}\r\n"
  },
  {
    "path": "KactusAPI/library/TagManager.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: TagManager.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Mikko Teuho\n// Date: 27.08.2019\n//\n// Description:\n// Manager for loaded tags.\n//-----------------------------------------------------------------------------\n\n#include \"TagManager.h\"\n\n//-----------------------------------------------------------------------------\n// Function: TagManager::addNewTags()\n//-----------------------------------------------------------------------------\nvoid TagManager::addNewTags(QVector<TagData> newTags)\n{\n    for (auto tag : newTags)\n    {\n        if (!tagExists(tag))\n        {\n            tags_.append(tag);\n        }\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: TagManager::tagExists()\n//-----------------------------------------------------------------------------\nbool TagManager::tagExists(TagData const& tag) const\n{\n    for (auto existingTag : tags_)\n    {\n        if (tag.name_.compare(existingTag.name_) == 0 && tag.color_.compare(existingTag.color_) == 0)\n        {\n            return true;\n        }\n    }\n\n    return false;\n}\n\n//-----------------------------------------------------------------------------\n// Function: TagManager::setTags()\n//-----------------------------------------------------------------------------\nvoid TagManager::setTags(QVector<TagData> newTags)\n{\n    clearTags();\n\n    for (auto tag : newTags)\n    {\n        if (!tagExists(tag))\n        {\n            tags_.append(tag);\n        }\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: TagManager::getTags()\n//-----------------------------------------------------------------------------\nQVector<TagData> TagManager::getTags() const\n{\n    return tags_;\n}\n\n//-----------------------------------------------------------------------------\n// Function: TagManager::clearTags()\n//-----------------------------------------------------------------------------\nvoid TagManager::clearTags()\n{\n    tags_.clear();\n}\n\n//-----------------------------------------------------------------------------\n// Function: TagManager::getInstance()\n//-----------------------------------------------------------------------------\nTagManager& TagManager::getInstance()\n{\n    static TagManager instance;\n    return instance;\n}\n\n//-----------------------------------------------------------------------------\n// Function: TagManager::TagManager()\n//-----------------------------------------------------------------------------\nTagManager::TagManager():\ntags_()\n{\n    \n}\n"
  },
  {
    "path": "KactusAPI/library/hierarchyitem.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: hierarchyitem.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Antti Kamppi\r\n// Date: 01.07.2011\r\n//\r\n// Description:\r\n// Represents a single component in the library in hierarchy view.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"hierarchyitem.h\"\r\n\r\n#include <algorithm>\r\n\r\n#include <KactusAPI/include/LibraryInterface.h>\r\n\r\n#include <IPXACTmodels/common/VLNV.h>\r\n\r\n#include <IPXACTmodels/Catalog/IpxactFile.h>\r\n\r\n#include <IPXACTmodels/DesignConfiguration/DesignConfiguration.h>\r\n\r\n#include <IPXACTmodels/kactusExtensions/SystemView.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HierarchyItem::HierarchyItem()\r\n//-----------------------------------------------------------------------------\r\nHierarchyItem::HierarchyItem(LibraryInterface* handler, HierarchyItem* parent, \r\n    VLNV const& vlnv, KactusAttribute::Implementation implementation, QString const& viewName):\r\nQObject(parent),\r\n    vlnv_(vlnv),\r\n    component_(),    \r\n    library_(handler),\r\n    childItems_(),\r\n    parentItem_(parent),\r\n    isValid_(true),\r\n    isDuplicate_(false),\r\n    type_(HierarchyItem::ROOT),\r\n    instanceCount_(),\r\n    viewName_()\r\n{\r\n    Q_ASSERT_X(handler, \"HierarchyItem constructor\", \"Null LibraryInterface pointer given as parameter\");\r\n    Q_ASSERT_X(parent, \"HierarchyItem constructor\", \"Null parent pointer given as parameter\");\r\n\r\n    connect(this, SIGNAL(errorMessage(QString const&)),\r\n        parent, SIGNAL(errorMessage(QString const&)), Qt::UniqueConnection);\r\n    connect(this, SIGNAL(noticeMessage(QString const&)),\r\n        parent, SIGNAL(noticeMessage(QString const&)), Qt::UniqueConnection);\r\n\r\n    // The line of code below prevents the project form loading if there are any files\r\n    // that are not presented in the library. However, all the conditions should be \r\n    // tested (including, for example, opening of deleted files) and thats why it is\r\n    // better to stay commented.\r\n    //Q_ASSERT(handler->contains(vlnv));\r\n\r\n    VLNV::IPXactType documentType = library_->getDocumentType(vlnv);\r\n    if (documentType == VLNV::COMPONENT)\r\n    {\r\n        parseComponent(vlnv);\r\n    }\r\n    else if (documentType == VLNV::CATALOG)\r\n    {\r\n        parseCatalog(vlnv);\r\n    }\r\n    else if (documentType == VLNV::BUSDEFINITION)\r\n    {\r\n        parseBusDefinition(vlnv);\r\n    }\r\n    else if (documentType == VLNV::ABSTRACTIONDEFINITION)\r\n    {\r\n        parseAbsDefinition(vlnv);\r\n    }\r\n    else if (documentType == VLNV::COMDEFINITION)\r\n    {\r\n        parseComDefinition(vlnv);\r\n    }\r\n    else if (documentType == VLNV::APIDEFINITION)\r\n    {\r\n        parseApiDefinition(vlnv);\r\n    }\r\n    else if (documentType == VLNV::DESIGN)\r\n    {\r\n        parseDesign(vlnv, implementation, viewName);\r\n    }\r\n    else\r\n    {\r\n        //emit errorMessage(tr(\"VLNV %1 was not for supported item\").arg(vlnv.toString()));\r\n        isValid_ = false;\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HierarchyItem::HierarchyItem()\r\n//-----------------------------------------------------------------------------\r\nHierarchyItem::HierarchyItem(LibraryInterface* handler, QObject* parent ):\r\nQObject(parent),\r\n    vlnv_(),\r\n    component_(),\r\n    library_(handler),\r\n    childItems_(),\r\n    parentItem_(NULL),\r\n    isValid_(true),\r\n    isDuplicate_(false),\r\n    type_(HierarchyItem::ROOT),\r\n    instanceCount_(),\r\n    viewName_()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HierarchyItem::createChild()\r\n//-----------------------------------------------------------------------------\r\nvoid HierarchyItem::createChild(VLNV const& vlnv)\r\n{\r\n\tif (hasChild(vlnv))// || !library_->contains(vlnv))\r\n    {\r\n\t\treturn;\r\n\t}\r\n\r\n\tchildItems_.append(new HierarchyItem(library_, this, vlnv));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HierarchyItem::parent()\r\n//-----------------------------------------------------------------------------\r\nHierarchyItem* HierarchyItem::parent() const\r\n{\r\n    return parentItem_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HierarchyItem::getVLNV()\r\n//-----------------------------------------------------------------------------\r\nVLNV const& HierarchyItem::getVLNV() const\r\n{\r\n    return vlnv_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HierarchyItem::child()\r\n//-----------------------------------------------------------------------------\r\nHierarchyItem* HierarchyItem::child(int index) const\r\n{\r\n\tif (0 <= index && index < childItems_.size())\r\n    {\r\n\t\treturn childItems_[index];\r\n    }\r\n\r\n\treturn 0;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HierarchyItem::row()\r\n//-----------------------------------------------------------------------------\r\nint HierarchyItem::row()\r\n{\r\n\tif (parentItem_)\r\n    {\r\n\t\treturn parentItem_->getIndexOf(this);\r\n    }\r\n\r\n\treturn -1;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HierarchyItem::getNumberOfChildren()\r\n//-----------------------------------------------------------------------------\r\nint HierarchyItem::getNumberOfChildren() const\r\n{\r\n\treturn childItems_.size();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HierarchyItem::getIndexOf()\r\n//-----------------------------------------------------------------------------\r\nint HierarchyItem::getIndexOf(HierarchyItem* item)\r\n{\r\n\treturn childItems_.indexOf(item);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HierarchyItem::hasChildren()\r\n//-----------------------------------------------------------------------------\r\nbool HierarchyItem::hasChildren() const\r\n{\r\n\treturn !childItems_.isEmpty();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HierarchyItem::isValid()\r\n//-----------------------------------------------------------------------------\r\nbool HierarchyItem::isValid() const\r\n{\r\n\treturn isValid_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HierarchyItem::setValidity()\r\n//-----------------------------------------------------------------------------\r\nvoid HierarchyItem::setValidity(bool valid)\r\n{\r\n\tisValid_ = valid;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HierarchyItem::contains()\r\n//-----------------------------------------------------------------------------\r\nbool HierarchyItem::contains(VLNV const& vlnv) const\r\n{\r\n    if (vlnv_ == vlnv)\r\n    {\r\n        return true;\r\n    }\r\n\r\n\tfor (HierarchyItem const* item : childItems_)\r\n    {\r\n\t\tif (item->contains(vlnv))\r\n        {\r\n\t\t\treturn true;\r\n        }\r\n\t}\r\n\r\n\treturn false;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HierarchyItem::cleanUp()\r\n//-----------------------------------------------------------------------------\r\nvoid HierarchyItem::cleanUp()\r\n{\r\n\t// make sure this is called only for root item\r\n\tQ_ASSERT_X(!component_, \"HierarchyItem::cleanUp\", \"Function was called for non-root item\");\r\n\r\n\tfor (auto item = childItems_.begin(); item != childItems_.end(); ++item)\r\n    {\r\n\t\tVLNV const& vlnv = (*item)->getVLNV();\r\n\r\n        // Check every pair exactly once: Children before item are already checked.\r\n\t\tfor (auto item2 = item + 1 ; item2 != childItems_.end(); ++item2)\r\n        {\t\t\t\r\n\t\t\t// if item is not the same but contains the other one and the other is not yet on the list to be removed\r\n\t\t\tif ((*item2)->contains(vlnv))\r\n            {\t\t\t\t\r\n\t\t\t\t(*item)->setDuplicate(true);\r\n\t\t\t\tbreak;\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HierarchyItem::component()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<Component const> HierarchyItem::component() const\r\n{\r\n\treturn component_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HierarchyItem::referenceCount()\r\n//-----------------------------------------------------------------------------\r\nint HierarchyItem::referenceCount(VLNV const& vlnv) const\r\n{\r\n\tint count = 0;\r\n\r\n\t// add the reference count of all child items.\r\n\tfor (HierarchyItem const* item : childItems_)\r\n    {\t\t\r\n\t\t// if item itself matches the vlnv and this item is not the root.\r\n\t\t// root must be excluded because it has all items as it's children so \r\n\t\t// the real count does not include direct children of root\r\n\t\tif (parentItem_ && item->getVLNV() == vlnv)\r\n        {\r\n\t\t\tcount++;\r\n        }\r\n\t\telse\r\n        {\r\n\t\t\tcount += item->referenceCount(vlnv);\r\n        }\r\n\t}\r\n\r\n\treturn count;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HierarchyItem::getOwners()\r\n//-----------------------------------------------------------------------------\r\nint HierarchyItem::getOwners(QList<VLNV>& list, VLNV const& vlnvToSearch) const\r\n{\r\n\tfor (HierarchyItem const* item : childItems_)\r\n    {\t\r\n\t\t// if item itself matches the vlnv and this item is not the root.\r\n\t\t// root must be excluded because it has all items as it's children so \r\n\t\t// the real count does not include direct children of root\r\n\t\t// also make sure the vlnvs are appended only once\r\n\t\tif (parentItem_ && item->getVLNV() == vlnvToSearch && !list.contains(getVLNV()))\r\n        {\r\n\t\t\tlist.append(getVLNV());\r\n        }\r\n\t\t// tell item to search it's children\r\n\t\telse\r\n        {\r\n\t\t\titem->getOwners(list, vlnvToSearch);\r\n        }\r\n\t}\r\n\r\n\treturn list.size();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HierarchyItem::removeItems()\r\n//-----------------------------------------------------------------------------\r\nint HierarchyItem::removeItems(VLNV const& vlnv)\r\n{\r\n    QVector<HierarchyItem*> childrenToRemove;\r\n\r\n\tfor (HierarchyItem* item : childItems_)\r\n    {\r\n\t\t// if item has the vlnv then it should be removed\r\n\t\tif (item->getVLNV() == vlnv) \r\n        {\r\n\t\t\tchildrenToRemove.append(item);\r\n        }\r\n\t\t// otherwise tell item to check it's own children\r\n\t\telse\r\n        {\r\n\t\t\titem->removeItems(vlnv);\r\n        }\r\n\t}\r\n\r\n\tfor (HierarchyItem* item : childrenToRemove)\r\n    {\r\n\t\tchildItems_.removeAt(childItems_.indexOf(item));\r\n        delete item;\r\n\r\n\t\t// If at least one item is removed then item is no longer valid because the design contains references \r\n        // to item that are not in the library. If type is not component then this of course remains valid.\r\n\t\tif (type_ == HierarchyItem::COMPONENT)\r\n        {\r\n\t\t\tisValid_ = false;\r\n        }\r\n\t}\r\n\r\n\treturn childrenToRemove.size();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HierarchyItem::findItems()\r\n//-----------------------------------------------------------------------------\r\nQVector<HierarchyItem*> HierarchyItem::findItems(const VLNV& vlnv)\r\n{\r\n\tQVector<HierarchyItem*> items;\r\n\r\n\tif (vlnv_ == vlnv)\r\n    {\r\n\t\titems.append(this);\r\n    }\r\n\r\n\tfor (HierarchyItem* item : childItems_)\r\n    {\r\n\t\titems += item->findItems(vlnv);\r\n\t}\r\n\r\n\treturn items;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HierarchyItem::updateItems()\r\n//-----------------------------------------------------------------------------\r\nvoid HierarchyItem::updateItems(VLNV const& vlnv)\r\n{\r\n\t// remove direct children with given vlnv\r\n\tint count = removeItems(vlnv);\r\n\r\n\t// tell remaining children to update their children if needed\r\n\tfor (HierarchyItem* item : childItems_)\r\n    {\r\n\t\titem->updateItems(vlnv);\r\n\t}\r\n\r\n\t// if at least one child item was removed then create it again.\r\n\tif (count > 0)\r\n    {\r\n\t\tHierarchyItem* item = new HierarchyItem(library_, this, vlnv, KactusAttribute::HW);\r\n\t\tchildItems_.append(item);\r\n\t}\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HierarchyItem::hasParent()\r\n//-----------------------------------------------------------------------------\r\nbool HierarchyItem::hasParent(VLNV const& vlnv)\r\n{\r\n\t// if this is not root\r\n\tif (parentItem_)\r\n    {\r\n\t\tif (parentItem_->getVLNV() == vlnv)\r\n        {\r\n\t\t\treturn true;\r\n        }\r\n\r\n\t\treturn parentItem_->hasParent(vlnv);\r\n\t}\r\n\t// if root item and match was not found.\r\n\telse\r\n    {\r\n\t\treturn false;\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HierarchyItem::parentIsRoot()\r\n//-----------------------------------------------------------------------------\r\nbool HierarchyItem::parentIsRoot() const \r\n{\r\n    if (!parentItem_)\r\n    {\r\n        return false;\r\n    }\r\n\r\n    return parentItem_->isRoot();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HierarchyItem::isRoot()\r\n//-----------------------------------------------------------------------------\r\nbool HierarchyItem::isRoot() const\r\n{\r\n    return !parentItem_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HierarchyItem::isDuplicate()\r\n//-----------------------------------------------------------------------------\r\nbool HierarchyItem::isDuplicate() const\r\n{\r\n    return isDuplicate_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HierarchyItem::setDuplicate()\r\n//-----------------------------------------------------------------------------\r\nvoid HierarchyItem::setDuplicate(bool isDuplicate)\r\n{\r\n    isDuplicate_ = isDuplicate;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HierarchyItem::getVLNVs()\r\n//-----------------------------------------------------------------------------\r\nQVector<VLNV> HierarchyItem::getVLNVs() const\r\n{\r\n    QVector<VLNV> list;\r\n\r\n\t// If this is not root item.\r\n\tif (parentItem_)\r\n    {\r\n\t\tlist.append(vlnv_);\r\n\t\tlist += parentItem_->getVLNVs();\r\n\t}\r\n\r\n\treturn list;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HierarchyItem::clear()\r\n//-----------------------------------------------------------------------------\r\nvoid HierarchyItem::clear()\r\n{\r\n\tqDeleteAll(childItems_);\r\n\r\n/*\r\n    for (int i = childItems_.size() - 1; i >= 0; --i)\r\n    {\r\n        childItems_.at(i)->deleteLater();\r\n    }\r\n*/\r\n\r\n\tchildItems_.clear();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HierarchyItem::isHierarchical()\r\n//-----------------------------------------------------------------------------\r\nbool HierarchyItem::isHierarchical() const\r\n{\r\n\tQ_ASSERT(component_);\r\n    if (component_.isNull())\r\n    {\r\n        return false;\r\n    }\r\n\r\n    if (component_->getImplementation() == KactusAttribute::SW)\r\n    {\r\n        return component_->hasViews();\r\n    }\r\n    else\r\n    {\r\n\t    return component_->isHierarchical();\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HierarchyItem::getImplementation()\r\n//-----------------------------------------------------------------------------\r\nKactusAttribute::Implementation HierarchyItem::getImplementation() const\r\n{\r\n    Q_ASSERT(component_);\r\n    if (component_)\r\n    {\r\n        return component_->getImplementation();\r\n    }\r\n    else\r\n    {\r\n        return KactusAttribute::KTS_IMPLEMENTATION_COUNT;\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HierarchyItem::type()\r\n//-----------------------------------------------------------------------------\r\nHierarchyItem::ObjectType HierarchyItem::type() const\r\n{\r\n\treturn type_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HierarchyItem::getChildren()\r\n//-----------------------------------------------------------------------------\r\nvoid HierarchyItem::getChildren(QList<VLNV>& childList, VLNV const& owner) const\r\n{\r\n\t// make sure this is called only for root item\r\n\tQ_ASSERT_X(!component_, \"HierarchyItem::getChildren\", \"Function was called for non-root item\");\r\n\r\n\t// search each child item\r\n\tfor (HierarchyItem const* item : childItems_)\r\n    {\r\n\t\t// if child matches the owner\r\n\t\tif (item->getVLNV() == owner)\r\n        {\r\n\t\t\t// ask child to append it's children\r\n\t\t\titem->getChildItems(childList);\r\n\t\t\tbreak;\r\n\t\t}\r\n\t}\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HierarchyItem::getChildItems()\r\n//-----------------------------------------------------------------------------\r\nvoid HierarchyItem::getChildItems(QList<VLNV>& itemList) const\r\n{\r\n\t// go through each child item\r\n\tfor (HierarchyItem const* item : childItems_)\r\n    {\r\n\t\t// if child's vlnv is not yet on the list\r\n\t\tif (!itemList.contains(item->getVLNV()))\r\n        {\r\n\t\t\titemList.append(item->getVLNV());\r\n        }\r\n\r\n\t\t// ask child to add its' children\r\n\t\titem->getChildItems(itemList);\r\n\t}\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HierarchyItem::instanceCount()\r\n//-----------------------------------------------------------------------------\r\nint HierarchyItem::instanceCount() const\r\n{\r\n\tif (type_ == HierarchyItem::COMPONENT)\r\n    {\r\n\t\treturn parentItem_->countInstances(getVLNV());\r\n\t}\r\n\telse\r\n    {\r\n\t\treturn -1;\r\n\t}\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HierarchyItem::getViewName()\r\n//-----------------------------------------------------------------------------\r\nQString HierarchyItem::getViewName() const\r\n{\r\n    return viewName_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HierarchyItem::countInstances()\r\n//-----------------------------------------------------------------------------\r\nint HierarchyItem::countInstances(VLNV const& componentVLNV)\r\n{\r\n    return instanceCount_.value(componentVLNV, -1);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HierarchyItem::hasChild()\r\n//-----------------------------------------------------------------------------\r\nbool HierarchyItem::hasChild(VLNV const& vlnv)\r\n{\r\n    return std::find_if(childItems_.cbegin(), childItems_.cend(),\r\n        [&vlnv](HierarchyItem const* child) { return child->getVLNV() == vlnv; }) != childItems_.cend();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HierarchyItem::parseComponent()\r\n//-----------------------------------------------------------------------------\r\nvoid HierarchyItem::parseComponent(VLNV const& vlnv)\r\n{\r\n    type_ = HierarchyItem::COMPONENT;\r\n    component_ = library_->getModelReadOnly<Component>(vlnv);\r\n    isValid_ = library_->isValid(vlnv);\r\n    \r\n    Q_ASSERT(component_);\r\n    if (component_.isNull())\r\n    {\r\n        return;\r\n    }\r\n\r\n    for (QSharedPointer<View> view : *component_->getViews())\r\n    {\r\n        if (view->isHierarchical())\r\n        {\r\n            VLNV designVLNV = findDesignReference(view);\r\n            createChildItemForDesign(designVLNV, view->name());\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HierarchyItem::parseCatalog()\r\n//-----------------------------------------------------------------------------\r\nvoid HierarchyItem::parseCatalog(VLNV const& vlnv)\r\n{\r\n    type_ = HierarchyItem::CATALOG;\r\n    QSharedPointer<Catalog const> catalog = library_->getModelReadOnly<Catalog>(vlnv);\r\n    Q_ASSERT(catalog);\r\n\r\n    isValid_ = library_->isValid(vlnv);\r\n\r\n    for (QSharedPointer<IpxactFile> catalogFile : *catalog->getCatalogs())\r\n    {\r\n        if (!hasParent(catalogFile->getVlnv())) //<! Avoid cyclic instantiations.\r\n        {\r\n             createChild(catalogFile->getVlnv());\r\n        }       \r\n    }\r\n\r\n    for (QSharedPointer<IpxactFile> const& busFile : *catalog->getBusDefinitions())\r\n    {\r\n        createChild(busFile->getVlnv());   \r\n    }\r\n\r\n    for (QSharedPointer<IpxactFile> const& abstractionFile : *catalog->getAbstractionDefinitions())\r\n    {\r\n        createChild(abstractionFile->getVlnv()); \r\n    }\r\n\r\n    for (QSharedPointer<IpxactFile> const& componentFile : *catalog->getComponents())\r\n    {\r\n        createChild(componentFile->getVlnv());\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HierarchyItem::findDesignReference()\r\n//-----------------------------------------------------------------------------\r\nVLNV HierarchyItem::findDesignReference(QSharedPointer<View> view)\r\n{\r\n    if (!view->getDesignInstantiationRef().isEmpty())\r\n    {\r\n        QString viewDesign = view->getDesignInstantiationRef();\r\n\r\n        for (QSharedPointer<DesignInstantiation> instantiation : *component_->getDesignInstantiations())\r\n        {\r\n            if (instantiation->name() == viewDesign)\r\n            {\r\n                return *instantiation->getDesignReference();\r\n            }\r\n        }\r\n    }\r\n    else\r\n    {\r\n        QString viewConfiguration = view->getDesignConfigurationInstantiationRef();\r\n\r\n        for (QSharedPointer<DesignConfigurationInstantiation> instantiation : \r\n            *component_->getDesignConfigurationInstantiations())\r\n        {\r\n            if (instantiation->name() == viewConfiguration)\r\n            {\r\n                VLNV configurationVLNV = *instantiation->getDesignConfigurationReference();\r\n\r\n                if (!library_->contains(configurationVLNV))\r\n                {\r\n                    isValid_ = false;\r\n                    return configurationVLNV;\r\n                }\r\n                else if (library_->getDocumentType(configurationVLNV) != VLNV::DESIGNCONFIGURATION)\r\n                {\r\n                    //emit errorMessage(tr(\"Design Configuration reference %1 was for wrong type of object.\").arg(\r\n                    //    configurationVLNV.toString()));\r\n                    isValid_ = false;\r\n                    return VLNV();\r\n                }\r\n                else\r\n                {\r\n                    return library_->getModelReadOnly<DesignConfiguration>(configurationVLNV)->getDesignRef();                   \r\n                }\r\n            }\r\n        }\r\n    }\r\n\r\n    return VLNV();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HierarchyItem::createChildItemForDesign()\r\n//-----------------------------------------------------------------------------\r\nvoid HierarchyItem::createChildItemForDesign(VLNV const& designVLNV, QString const& viewName)\r\n{\r\n    if (!designVLNV.isEmpty())\r\n    {\r\n        if (library_->getDocumentType(designVLNV) != VLNV::DESIGN)\r\n        {\r\n            //emit errorMessage(tr(\"VLNV %1 was not valid hierarchy reference.\").arg(designVLNV.toString()));\r\n            isValid_ = false;\r\n        }\r\n        else if (!hasChild(designVLNV)) \r\n        {\r\n            KactusAttribute::Implementation implementation = library_->getModelReadOnly(designVLNV)->getImplementation();\r\n            HierarchyItem* designItem = new HierarchyItem(library_, this, designVLNV, implementation, viewName);\r\n\r\n            connect(designItem, SIGNAL(errorMessage(QString const&)),\r\n                this, SIGNAL(errorMessage(QString const&)), Qt::UniqueConnection);\r\n            connect(designItem, SIGNAL(noticeMessage(QString const&)),\r\n                this, SIGNAL(noticeMessage(QString const&)), Qt::UniqueConnection);\r\n\r\n            childItems_.append(designItem);\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HierarchyItem::parseBusDefinition()\r\n//-----------------------------------------------------------------------------\r\nvoid HierarchyItem::parseBusDefinition(VLNV const& vlnv)\r\n{\r\n    type_ = HierarchyItem::BUSDEFINITION;    \r\n    isValid_ = library_->isValid(vlnv);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HierarchyItem::parseAbsDefinition()\r\n//-----------------------------------------------------------------------------\r\nvoid HierarchyItem::parseAbsDefinition(VLNV const& vlnv)\r\n{\r\n    type_ = HierarchyItem::ABSDEFINITION;\r\n    isValid_ = library_->isValid(vlnv);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HierarchyItem::parseComDefinition()\r\n//-----------------------------------------------------------------------------\r\nvoid HierarchyItem::parseComDefinition(VLNV const& vlnv)\r\n{\r\n    type_ = HierarchyItem::COMDEFINITION;\r\n    isValid_ = library_->isValid(vlnv);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HierarchyItem::parseApiDefinition()\r\n//-----------------------------------------------------------------------------\r\nvoid HierarchyItem::parseApiDefinition(VLNV const& vlnv)\r\n{\r\n    type_ = HierarchyItem::APIDEFINITION;    \r\n    isValid_ = library_->isValid(vlnv);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HierarchyItem::parseDesign()\r\n//-----------------------------------------------------------------------------\r\nvoid HierarchyItem::parseDesign(VLNV const& vlnv, KactusAttribute::Implementation implementation,\r\n    QString const& viewName)\r\n{\r\n    instanceCount_.clear();\r\n\r\n    viewName_ = viewName;\r\n    QSharedPointer<Design const> design = library_->getModelReadOnly<Design>(vlnv);\r\n    isValid_ = library_->isValid(vlnv);\r\n\r\n    if (implementation == KactusAttribute::HW)\r\n    {\r\n        type_ = HierarchyItem::HW_DESIGN;\r\n    }\r\n    else if (implementation == KactusAttribute::SW)\r\n    {\r\n        type_ = HierarchyItem::SW_DESIGN;\r\n    }\r\n    else if (implementation == KactusAttribute::SYSTEM)\r\n    {\r\n        type_ = HierarchyItem::SYS_DESIGN;\r\n    }\r\n    else\r\n    {\r\n        Q_ASSERT(false);\r\n    }\r\n\r\n    // Take all valid components referenced by the design.\r\n    const QVector<VLNV> componentReferences = getValidComponentsInDesign(design);\r\n\r\n    for (VLNV const& componentVLNV : componentReferences)\r\n    {\r\n        // If item already has a child with given VLNV then don't create duplicate.\r\n        if (!hasChild(componentVLNV))\r\n        {\r\n            HierarchyItem* item = new HierarchyItem(library_, this, componentVLNV);\r\n\r\n            connect(item, SIGNAL(errorMessage(QString const&)),\r\n                this, SIGNAL(errorMessage(QString const&)), Qt::UniqueConnection);\r\n            connect(item, SIGNAL(noticeMessage(QString const&)),\r\n                this, SIGNAL(noticeMessage(QString const&)), Qt::UniqueConnection);\r\n\r\n            childItems_.append(item);\r\n            instanceCount_[componentVLNV] = componentReferences.count(componentVLNV);\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HierarchyItem::getValidComponentsInDesign()\r\n//-----------------------------------------------------------------------------\r\nQVector<VLNV> HierarchyItem::getValidComponentsInDesign(QSharedPointer<Design const> design)\r\n{\r\n    QVector<VLNV> componentReferences;\r\n\r\n    for (QSharedPointer<ComponentInstance> instance : *design->getComponentInstances())\r\n    {\r\n        if (!instance->isDraft())\r\n        {\r\n            VLNV componentVLNV = *instance->getComponentRef();\r\n\r\n            if (isValidComponentInstanceVLNV(componentVLNV))\r\n            {\r\n                componentReferences.append(componentVLNV);\r\n            }\r\n            else\r\n            {\r\n                // Mark this object as invalid because not all items were valid.\r\n                isValid_ = false;\r\n            }\r\n        }\r\n    }\r\n\r\n    return componentReferences;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HierarchyItem::isValidComponentInstanceVLNV()\r\n//-----------------------------------------------------------------------------\r\nbool HierarchyItem::isValidComponentInstanceVLNV(VLNV const& componentVLNV)\r\n{\r\n    if (library_->getDocumentType(componentVLNV) != VLNV::COMPONENT)\r\n    {\r\n        //emit errorMessage(tr(\"VLNV %1 was not for component\").arg(componentVLNV.toString()));\r\n        return false;\r\n    }\r\n\r\n    else if (vlnv_ == componentVLNV || hasParent(componentVLNV))\r\n    {\r\n        emit errorMessage(tr(\"Cyclic instantiation for vlnv %1 was found\").arg(componentVLNV.toString()));\r\n        return false;\r\n    }\r\n\r\n    return true;\r\n}\r\n"
  },
  {
    "path": "KactusAPI/library/hierarchymodel.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: hierarchymodel.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 01.07.2011\r\n//\r\n// Description:\r\n// Contains the items to display the library component hierarchy to user.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"hierarchymodel.h\"\r\n\r\n#include <KactusAPI/include/LibraryInterface.h>\r\n\r\n#include <IPXACTmodels/Component/Component.h>\r\n#include <IPXACTmodels/kactusExtensions/KactusAttribute.h>\r\n\r\n#include <common/KactusColors.h>\r\n\r\n#include <QStringBuilder>\r\n#include <QIcon>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HierarchyModel::HierarchyModel()\r\n//-----------------------------------------------------------------------------\r\nHierarchyModel::HierarchyModel(LibraryInterface* handler, QObject* parent):\r\nQAbstractItemModel(parent),\r\n    rootItem_(new HierarchyItem(handler, this)),\r\n    handler_(handler)\r\n{\r\n    connect(rootItem_, SIGNAL(errorMessage(const QString&)),\r\n        this, SIGNAL(errorMessage(const QString&)), Qt::UniqueConnection);\r\n    connect(rootItem_, SIGNAL(noticeMessage(const QString&)),\r\n        this, SIGNAL(noticeMessage(const QString&)), Qt::UniqueConnection);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HierarchyModel::onResetModel()\r\n//-----------------------------------------------------------------------------\r\nvoid HierarchyModel::onResetModel()\r\n{\r\n    beginResetModel();\r\n\r\n    rootItem_->clear();\r\n\r\n    QVector<VLNV> absDefs;\r\n\r\n    // add all items to this model\r\n    for (VLNV const& itemVlnv : handler_->getAllVLNVs())\r\n    {\r\n        VLNV::IPXactType documentType = itemVlnv.getType();\r\n\r\n        //! Add supported item types only. Designs and configurations will be created by their top-components.\r\n        if (documentType == VLNV::ABSTRACTIONDEFINITION || documentType == VLNV::BUSDEFINITION ||\r\n            documentType == VLNV::CATALOG || documentType == VLNV::COMPONENT ||\r\n            documentType == VLNV::APIDEFINITION || documentType == VLNV::COMDEFINITION)\r\n        {\r\n            rootItem_->createChild(itemVlnv);\r\n\r\n            if (documentType == VLNV::ABSTRACTIONDEFINITION)\r\n            {\r\n                absDefs.append(itemVlnv);\r\n            }\r\n        }\r\n    }\r\n\r\n    // create the abstraction definitions\r\n    for (VLNV const& absDefVlnv : absDefs) \r\n    {\r\n    \tQSharedPointer<AbstractionDefinition const> absDef = \r\n            handler_->getModelReadOnly(absDefVlnv).staticCast<AbstractionDefinition const>();\r\n\r\n        for (HierarchyItem* busDefItem : rootItem_->findItems(absDef->getBusType()))\r\n        {\r\n    \t\tbusDefItem->createChild(absDefVlnv);\r\n        }\r\n    }\r\n\r\n    // Remove the duplicates.\r\n    rootItem_->cleanUp();\r\n\r\n    endResetModel();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HierarchyModel::headerData()\r\n//-----------------------------------------------------------------------------\r\nQVariant HierarchyModel::headerData(int section, Qt::Orientation orientation, int role) const\r\n{\r\n    if (orientation == Qt::Horizontal && role == Qt::DisplayRole)\r\n    {\r\n        if (section == HierarchyModel::OBJECT_COLUMN)\r\n        {\r\n            return tr(\"Library items\");\r\n        }\r\n        else if (section == HierarchyModel::INSTANCE_COLUMN)\r\n        {\r\n            return tr(\"Instances\");\r\n        }\r\n    }\r\n\r\n    return QVariant();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HierarchyModel::columnCount()\r\n//-----------------------------------------------------------------------------\r\nint HierarchyModel::columnCount(QModelIndex const&) const\r\n{\r\n    return HierarchyModel::COLUMN_COUNT;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HierarchyModel::rowCount()\r\n//-----------------------------------------------------------------------------\r\nint HierarchyModel::rowCount(QModelIndex const& parent) const\r\n{\r\n    // only one column exists\r\n    if (parent.column() > 0)\r\n    {\r\n    \treturn 0;\r\n    }\r\n\r\n    HierarchyItem* parentItem = 0;\r\n\r\n    // if the given item is invalid then it is the root\r\n    if (!parent.isValid())\r\n    {\r\n    \tparentItem = rootItem_;\r\n    }\r\n    else\r\n    {\r\n    \tparentItem = static_cast<HierarchyItem*>(parent.internalPointer());\r\n    }\r\n\r\n    return parentItem->getNumberOfChildren();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HierarchyModel::index()\r\n//-----------------------------------------------------------------------------\r\nQModelIndex HierarchyModel::index(int row, int column, QModelIndex const& parent) const\r\n{\r\n    if (!hasIndex(row, column, parent))\r\n    {\r\n    \treturn QModelIndex();\r\n    }\r\n\r\n    HierarchyItem* parentItem = 0;\r\n\r\n    // if the index of the parent is invalid then it is the root\r\n    if (!parent.isValid())\r\n    {\r\n    \tparentItem = rootItem_;\r\n    }\r\n    else\r\n    {\r\n    \tparentItem = static_cast<HierarchyItem*>(parent.internalPointer());\r\n    }\r\n\r\n    HierarchyItem* child = parentItem->child(row);\r\n    if (child)\r\n    {\r\n    \treturn createIndex(row, column, child);\r\n    }\r\n    else\r\n    {\r\n    \treturn QModelIndex();\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HierarchyModel::index()\r\n//-----------------------------------------------------------------------------\r\nQModelIndex HierarchyModel::index(HierarchyItem* item) const\r\n{\r\n    if (!item)\r\n    {\r\n    \treturn QModelIndex();\r\n    }\r\n\r\n    // if this item has no parent then it is the root item\r\n    HierarchyItem* parent = item->parent();\r\n    if (!parent)\r\n    {\r\n    \treturn QModelIndex();\r\n    }\r\n\r\n    return createIndex(item->row(), 0, item);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HierarchyModel::findIndexes()\r\n//-----------------------------------------------------------------------------\r\nQModelIndexList HierarchyModel::findIndexes(VLNV const& vlnv)\r\n{\r\n    QModelIndexList list;\r\n\r\n    for (HierarchyItem* item : rootItem_->findItems(vlnv))\r\n    {\r\n    \tlist.append(index(item));\r\n    }\r\n\r\n    return list;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HierarchyModel::parent()\r\n//-----------------------------------------------------------------------------\r\nQModelIndex HierarchyModel::parent(QModelIndex const& child) const\r\n{\r\n    if (!child.isValid())\r\n    {\r\n    \treturn QModelIndex();\r\n    }\r\n\r\n    HierarchyItem* childItem = static_cast<HierarchyItem*>(child.internalPointer());\r\n    HierarchyItem* parent = childItem->parent();\r\n\r\n    // if the parent does not exist then this item is root item\r\n    if (!parent)\r\n    {\r\n    \treturn QModelIndex();\r\n    }\r\n\r\n    // If row is invalid then the grandparent does not exist and the parent is the root.\r\n    int row = parent->row();\r\n    if (row == -1)\r\n    {\r\n    \treturn QModelIndex();\r\n    }\r\n\r\n    // create new index and return it\r\n    return createIndex(row, 0, parent);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HierarchyModel::data()\r\n//-----------------------------------------------------------------------------\r\nQVariant HierarchyModel::data(QModelIndex const& index, int role) const\r\n{\r\n    if (!index.isValid())\r\n    {\r\n    \treturn QVariant();\r\n    }\r\n\r\n    HierarchyItem* item = static_cast<HierarchyItem*>(index.internalPointer());\r\n\r\n    if (role == Qt::DisplayRole) \r\n    {\r\n        if (index.column() == HierarchyModel::OBJECT_COLUMN)\r\n        {\r\n            VLNV const& vlnv = item->getVLNV();\r\n            if (vlnv.isValid())\r\n            {\r\n                return vlnv.toString();\r\n            }\r\n        }\r\n        else if (index.column() == HierarchyModel::INSTANCE_COLUMN)\r\n        {\r\n            int count = item->instanceCount();\r\n            if (count > 0)\r\n            {\r\n                return count;\r\n            }\r\n        }        \r\n        \r\n        return QVariant();\r\n    }\r\n    else if (role == Qt::ForegroundRole)\r\n    {\r\n    \tif (item->isValid()) \r\n        {\r\n    \t\treturn KactusColors::REGULAR_TEXT;\r\n        }\r\n    \telse\r\n        {\r\n    \t\treturn KactusColors::ERROR;\r\n        }\r\n    }\r\n    else if (role == Qt::ToolTipRole)\r\n    {\r\n        VLNV vlnv = item->getVLNV();\r\n\r\n        QString text = \"<b>Vendor:</b> \" % vlnv.getVendor() % \"<br>\" %\r\n                       \"<b>Library:</b> \" % vlnv.getLibrary() % \"<br>\" %\r\n                       \"<b>Name:</b> \" % vlnv.getName() % \"<br>\" %\r\n                       \"<b>Version:</b> \" % vlnv.getVersion() % \"<br>\";\r\n\r\n        QSharedPointer<Document const> document = handler_->getModelReadOnly(vlnv);\r\n        \r\n        text += \"<br><b>Compatibility:</b> \" + Document::toString(document->getRevision());\r\n\r\n        if (document != 0 && !document->getDescription().isEmpty())\r\n        {\r\n            text += \"<br><b>Description:</b><br>\" % document->getDescription();\r\n        }\r\n\r\n        text += QString(\"<br><b>File Path:</b><br>%1\").arg(handler_->getPath(vlnv));\r\n        return text;\r\n    }\r\n    else if (role == Qt::DecorationRole && index.column() == HierarchyModel::OBJECT_COLUMN)\r\n    {\r\n        if (item->type() == HierarchyItem::COMPONENT)\r\n        {\r\n            if (item->getImplementation() == KactusAttribute::SYSTEM)\r\n            {\r\n                return QIcon(QStringLiteral(\":/icons/common/graphics/system-component.png\"));\r\n            }\r\n            else if (item->getImplementation() == KactusAttribute::SW)\r\n            {\r\n                if (item->isHierarchical())\r\n                {\r\n                    return QIcon(QStringLiteral(\":/icons/common/graphics/hier-sw-component.png\"));\r\n                }\r\n                else\r\n                {\r\n                    return QIcon(QStringLiteral(\":/icons/common/graphics/sw-component48x48.png\"));\r\n                }\r\n            }\r\n            else\r\n            {\r\n                if (item->isHierarchical()) \r\n                {\r\n                    return QIcon(QStringLiteral(\":/icons/common/graphics/hier-hw-component.png\"));\r\n                }\r\n                else\r\n                {\r\n                    return QIcon(QStringLiteral(\":/icons/common/graphics/hw-component.png\"));\r\n                }\t\t\r\n            }\r\n        }\r\n        else if (item->type() == HierarchyItem::CATALOG)\r\n        {\r\n            return QIcon(QStringLiteral(\":/icons/common/graphics/catalog.png\"));\r\n        }\r\n        else if (item->type() == HierarchyItem::COMDEFINITION)\r\n        {\r\n            return QIcon(QStringLiteral(\":/icons/common/graphics/new-com_definition.png\"));\r\n        }\r\n        else if (item->type() == HierarchyItem::APIDEFINITION)\r\n        {\r\n            return QIcon(QStringLiteral(\":/icons/common/graphics/new-api_definition.png\"));\r\n        }\r\n    \telse if (item->type() == HierarchyItem::HW_DESIGN)\r\n        {\r\n    \t\treturn QIcon(QStringLiteral(\":/icons/common/graphics/hw-design.png\"));\r\n    \t}\r\n    \telse if (item->type() == HierarchyItem::SW_DESIGN || item->type() == HierarchyItem::SYS_DESIGN)\r\n        {\r\n            return QIcon(QStringLiteral(\":/icons/common/graphics/sw-design48x48.png\"));\r\n    \t}\r\n        else if (item->type() == HierarchyItem::ABSDEFINITION)\r\n        {\r\n            return QIcon(QStringLiteral(\":/icons/common/graphics/abs-def.png\"));\r\n        }\r\n        else if (item->type() == HierarchyItem::BUSDEFINITION)\r\n        {\r\n            return QIcon(QStringLiteral(\":/icons/common/graphics/bus-def.png\"));\r\n        }\r\n        else\r\n        {\r\n            return QIcon(QStringLiteral(\":/icons/common/graphics/cross.png\"));\r\n        }\r\n    }\r\n\r\n    return QVariant();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HierarchyModel::hasChildren()\r\n//-----------------------------------------------------------------------------\r\nbool HierarchyModel::hasChildren(QModelIndex const& parent) const\r\n{\r\n    // only one column exists\r\n    if (parent.column() > 0)\r\n    {\r\n    \treturn false;\r\n    }\r\n\r\n    HierarchyItem* parentItem = 0;\r\n\r\n    // if given item is invalid then it is root item\r\n    if (!parent.isValid())\r\n    {\r\n    \tparentItem = rootItem_;\r\n    }\r\n    else\r\n    {\r\n    \tparentItem = static_cast<HierarchyItem*>(parent.internalPointer());\r\n    }\r\n\r\n    return parentItem->hasChildren();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HierarchyModel::flags()\r\n//-----------------------------------------------------------------------------\r\nQt::ItemFlags HierarchyModel::flags(QModelIndex const& index) const\r\n{\r\n    if (!index.isValid() || index.column() == HierarchyModel::INSTANCE_COLUMN)\r\n    {\r\n    \treturn Qt::NoItemFlags;\r\n    }\r\n\r\n    return Qt::ItemIsEnabled | Qt::ItemIsSelectable;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HierarchyModel::onOpenDesign()\r\n//-----------------------------------------------------------------------------\r\nvoid HierarchyModel::onOpenDesign(QModelIndex const& index)\r\n{\r\n    if (!index.isValid())\r\n    {\r\n    \treturn;\r\n    }\r\n\r\n    HierarchyItem* item = static_cast<HierarchyItem*>(index.internalPointer());\r\n    if (!item)\r\n    {\r\n    \treturn;\r\n    }\r\n\r\n    // item must always be design\r\n    Q_ASSERT(item->type() == HierarchyItem::HW_DESIGN || item->type() == HierarchyItem::SW_DESIGN);\t\r\n\r\n    // find the containing component\r\n    HierarchyItem* parent = item->parent();\r\n    // if the design has no parent or the parent is the root item (which is not component)\r\n    if (!parent || parent == rootItem_)\r\n    {\r\n    \temit errorMessage(tr(\"Design did not have containing component and could not be opened.\"));\r\n    \treturn;\r\n    }\r\n\r\n    Q_ASSERT(parent->type() == HierarchyItem::COMPONENT);\r\n\r\n    // find the vlnv of the component\r\n    VLNV componentVLNV = parent->getVLNV();\r\n    Q_ASSERT(componentVLNV.getType() == handler_->getDocumentType(componentVLNV));\r\n\r\n    if (item->type() == HierarchyItem::HW_DESIGN)\r\n    {\r\n        emit openDesign(componentVLNV, item->getViewName());\r\n    }\r\n\r\n    else if (item->type() == HierarchyItem::SW_DESIGN)\r\n    {\r\n        emit openSWDesign(componentVLNV, item->getViewName());\r\n    }\r\n\r\n    else if (item->type() == HierarchyItem::SYS_DESIGN)\r\n    {\r\n        emit openSystemDesign(componentVLNV, item->getViewName());\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HierarchyModel::onOpenMemoryDesign()\r\n//-----------------------------------------------------------------------------\r\nvoid HierarchyModel::onOpenMemoryDesign(QModelIndex const& index)\r\n{\r\n    if (!index.isValid())\r\n    {\r\n        return;\r\n    }\r\n\r\n    HierarchyItem* item = static_cast<HierarchyItem*>(index.internalPointer());\r\n    if (!item)\r\n    {\r\n        return;\r\n    }\r\n\r\n    // item must always be design\r\n    Q_ASSERT(item->type() == HierarchyItem::HW_DESIGN);\r\n\r\n    // find the containing component\r\n    HierarchyItem* parent = item->parent();\r\n    // if the design has no parent or the parent is the root item (which is not component)\r\n    if (!parent || parent == rootItem_)\r\n    {\r\n        emit errorMessage(tr(\"Design did not have containing component and could not be opened.\"));\r\n        return;\r\n    }\r\n    Q_ASSERT(parent->type() == HierarchyItem::COMPONENT);\r\n\r\n    // find the vlnv of the component\r\n    VLNV componentVLNV = parent->getVLNV();\r\n    Q_ASSERT(componentVLNV.getType() == handler_->getDocumentType(componentVLNV));\r\n\r\n    emit openMemoryDesign(componentVLNV, item->getViewName());\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HierarchyModel::onOpenItem()\r\n//-----------------------------------------------------------------------------\r\nvoid HierarchyModel::onOpenItem(QModelIndex const& index)\r\n{\r\n    if (!index.isValid())\r\n    {\r\n    \treturn;\r\n    }\r\n\r\n    HierarchyItem* item = static_cast<HierarchyItem*>(index.internalPointer());\r\n\r\n    VLNV vlnv = item->getVLNV();\r\n    if (vlnv.isValid())\r\n    {\r\n    \temit editItem(vlnv);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HierarchyModel::onCreateNewDesign()\r\n//-----------------------------------------------------------------------------\r\nvoid HierarchyModel::onCreateNewDesign(QModelIndex const& index)\r\n{\r\n    if (!index.isValid())\r\n    {\r\n    \treturn;\r\n    }\r\n\r\n    HierarchyItem* item = static_cast<HierarchyItem*>(index.internalPointer());\r\n\r\n    VLNV designVLNV = item->getVLNV();\r\n    designVLNV.setType(VLNV::COMPONENT);\r\n\r\n    emit createDesign(designVLNV);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HierarchyModel::onCreateNewSWDesign()\r\n//-----------------------------------------------------------------------------\r\nvoid HierarchyModel::onCreateNewSWDesign(QModelIndex const& index)\r\n{\r\n    if (!index.isValid())\r\n    {\r\n        return;\r\n    }\r\n\r\n    HierarchyItem* item = static_cast<HierarchyItem*>(index.internalPointer());\r\n\r\n    VLNV swDesignVLNV = item->getVLNV();\r\n    swDesignVLNV.setType(VLNV::COMPONENT);\r\n\r\n    emit createSWDesign(swDesignVLNV);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HierarchyModel::onCreateNewSystemDesign()\r\n//-----------------------------------------------------------------------------\r\nvoid HierarchyModel::onCreateNewSystemDesign(QModelIndex const& index)\r\n{\r\n    if (!index.isValid())\r\n    {\r\n        return;\r\n    }\r\n\r\n    HierarchyItem* item = static_cast<HierarchyItem*>(index.internalPointer());\r\n\r\n    VLNV systemDesignVLNV = item->getVLNV();\r\n    systemDesignVLNV.setType(VLNV::COMPONENT);\r\n\r\n    emit createSystemDesign(systemDesignVLNV);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HierarchyModel::onCreateNewAbsDef()\r\n//-----------------------------------------------------------------------------\r\nvoid HierarchyModel::onCreateNewAbsDef(QModelIndex const& index)\r\n{\r\n    if (!index.isValid())\r\n    {\r\n    \treturn;\r\n    }\r\n\r\n    HierarchyItem* item = static_cast<HierarchyItem*>(index.internalPointer());\r\n\r\n    VLNV abstractionVNLV = item->getVLNV();\r\n    abstractionVNLV.setType(VLNV::BUSDEFINITION);\r\n\r\n    emit createAbsDef(abstractionVNLV);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HierarchyModel::onExportItem()\r\n//-----------------------------------------------------------------------------\r\nvoid HierarchyModel::onExportItem(QModelIndex const& index)\r\n{\r\n    if (!index.isValid())\r\n    {\r\n    \treturn;\r\n    }\r\n\r\n    HierarchyItem* item = static_cast<HierarchyItem*>(index.internalPointer());\r\n\r\n    emit exportItem(item->getVLNV());\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LibraryTreeModel::onDeleteItem()\r\n//-----------------------------------------------------------------------------\r\nvoid HierarchyModel::onDeleteItem(QModelIndex const& index)\r\n{\r\n    if (!index.isValid())\r\n    {\r\n        return;\r\n    }\r\n\r\n    HierarchyItem* item = static_cast<HierarchyItem*>(index.internalPointer());\r\n   \r\n    QList<VLNV> removedVLNVs;\r\n    removedVLNVs.append(item->getVLNV());\r\n    \r\n    emit removeVLNV(removedVLNVs);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HierarchyModel::onRemoveVLNV()\r\n//-----------------------------------------------------------------------------\r\nvoid HierarchyModel::onRemoveVLNV(VLNV const& vlnv)\r\n{\r\n    if (!vlnv.isValid())\r\n    {\r\n    \treturn;\r\n    }\r\n\r\n    beginResetModel();\r\n    rootItem_->removeItems(vlnv);\r\n    endResetModel();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HierarchyModel::referenceCount()\r\n//-----------------------------------------------------------------------------\r\nint HierarchyModel::referenceCount(VLNV const& vlnv) const\r\n{\r\n    return rootItem_->referenceCount(vlnv);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HierarchyModel::onDocumentUpdated()\r\n//-----------------------------------------------------------------------------\r\nvoid HierarchyModel::onDocumentUpdated(VLNV const& vlnv)\r\n{\r\n    bool isValid = handler_->isValid(vlnv);\r\n    for (HierarchyItem* updatedItem : rootItem_->findItems(vlnv))\r\n    {\r\n        updatedItem->setValidity(isValid);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HierarchyModel::getOwners()\r\n//-----------------------------------------------------------------------------\r\nint HierarchyModel::getOwners(QList<VLNV>& list, VLNV const& vlnvToSearch) const\r\n{\r\n    rootItem_->getOwners(list, vlnvToSearch);\r\n    return list.size();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HierarchyModel::getChildren()\r\n//-----------------------------------------------------------------------------\r\nvoid HierarchyModel::getChildren(QList<VLNV>& childList, VLNV const& owner) const\r\n{\r\n    rootItem_->getChildren(childList, owner);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HierarchyModel::onShowErrors()\r\n//-----------------------------------------------------------------------------\r\nvoid HierarchyModel::onShowErrors(QModelIndex const& index)\r\n{\r\n    if (!index.isValid())\r\n    {\r\n        return;\r\n    }\r\n\r\n    HierarchyItem* item = static_cast<HierarchyItem*>(index.internalPointer());\r\n    VLNV vlnv = item->getVLNV();\r\n\r\n    emit showErrors(vlnv);\r\n}\r\n"
  },
  {
    "path": "KactusAPI/plugins/ImportHighlighter.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ImportHighlighter.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Esko Pekkarinen\r\n// Date: 11.09.2014\r\n//\r\n// Description:\r\n// Source file highlighter for import files.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"ImportHighlighter.h\"\r\n\r\n#include <KactusAPI/include/HighlightSource.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VHDLHighlighter::VHDLHighlighter()\r\n//-----------------------------------------------------------------------------\r\nImportHighlighter::ImportHighlighter(QPlainTextEdit* display, QObject *parent)\r\n    : QObject(parent),\r\n    display_(display)\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VHDLHighlighter::~VHDLHighlighter()\r\n//-----------------------------------------------------------------------------\r\nImportHighlighter::~ImportHighlighter()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VHDLHighlighter::highlight()\r\n//-----------------------------------------------------------------------------\r\nvoid ImportHighlighter::applyHighlight(QString const& text, QColor const& highlightColor,\r\n    QString const& subSection /* = \"\" */)\r\n{\r\n    QString displayText = display_->toPlainText();\r\n\r\n    int beginIndex = 0;\r\n    if (!subSection.isEmpty())\r\n    {\r\n        int subSectionIndex = displayText.indexOf(subSection);\r\n        int textIndex = subSection.indexOf(text);\r\n        beginIndex = subSectionIndex + textIndex;\r\n    }\r\n    else\r\n    {\r\n        beginIndex = displayText.indexOf(text);\r\n    }\r\n\r\n    int endIndex = beginIndex + text.length();\r\n\r\n    applyHighlight(beginIndex, endIndex, highlightColor);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ImportHighlighter::applyHighlight()\r\n//-----------------------------------------------------------------------------\r\nvoid ImportHighlighter::applyHighlight(int beginPosition, int endPosition, QColor const& highlightColor)\r\n{\r\n    if (beginPosition != -1 && endPosition != -1 && endPosition <= display_->toPlainText().length())\r\n    {\r\n        QTextCursor cursor = display_->textCursor();\r\n        cursor.setPosition(beginPosition);\r\n\r\n        QTextCharFormat highlighFormat = cursor.charFormat();        \r\n        highlighFormat.setBackground(QBrush(highlightColor));\r\n\r\n        cursor.setPosition(endPosition, QTextCursor::KeepAnchor);        \r\n        cursor.setCharFormat(highlighFormat);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VHDLHighlighter::setFontColor()\r\n//-----------------------------------------------------------------------------\r\nvoid ImportHighlighter::applyFontColor(QString const& text, QColor const& color)\r\n{\r\n    int beginIndex = display_->toPlainText().indexOf(text);\r\n    if (beginIndex != -1)\r\n    {\r\n        QTextCursor cursor = display_->textCursor();\r\n        cursor.setPosition(beginIndex);\r\n        cursor.setPosition(beginIndex + text.length(), QTextCursor::KeepAnchor);\r\n\r\n        QTextCharFormat highlighFormat;\r\n        highlighFormat.setForeground(QBrush(color));\r\n        cursor.setCharFormat(highlighFormat);\r\n    }\r\n}"
  },
  {
    "path": "KactusAPI/plugins/ImportRunner.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ImportRunner.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Esko Pekkarinen\r\n// Date: 18.09.2014\r\n//\r\n// Description:\r\n// Runs import plugins for a given file and component.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"ImportRunner.h\"\r\n\r\n#include <IPlugin.h>\r\n#include <ISourceAnalyzerPlugin.h>\r\n#include <ImportPlugin.h>\r\n#include <IncludeImportPlugin.h>\r\n\r\n#include <KactusAPI/include/HighlightSource.h>\r\n#include <KactusAPI/include/ExpressionSupport.h>\r\n\r\n#include <FileHandler.h>\r\n#include <KactusAPI/include/NullParser.h>\r\n\r\n#include <KactusAPI/include/ImportHighlighter.h>\r\n\r\n#include <IPXACTmodels/Component/Component.h>\r\n#include <IPXACTmodels/Component/FileSet.h>\r\n#include <IPXACTmodels/Component/File.h>\r\n\r\n#include <QApplication>\r\n#include <QRegularExpression>\r\n#include <QScrollBar>\r\n#include <QTextStream>\r\n#include <QTextBlock>\r\n#include <QFileInfo>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ImportRunner::ImportRunner()\r\n//-----------------------------------------------------------------------------\r\nImportRunner::ImportRunner(QSharedPointer<ComponentParameterFinder> parameterFinder, QTabWidget* displayTabs,\r\n    QObject* parent):\r\nQObject(parent),\r\nexpressionParser_(new NullParser()),\r\nImportPlugins_(),\r\nanalyzerPlugins_(),\r\nparameterFinder_(parameterFinder),\r\ndisplayTabs_(displayTabs),\r\nfileSuffixTable_(FileHandler::constructFileSuffixTable()),\r\ncomponentsInFile_()\r\n{\r\n    \r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ImportRunner::gatherComponentsFromFile()\r\n//-----------------------------------------------------------------------------\r\nQStringList ImportRunner::constructComponentDataFromFile(QString const& filePath, QString const& componentXMLPath,\r\n    QSharedPointer<const Component> targetComponent)\r\n{\r\n    componentsInFile_.clear();\r\n\r\n    QStringList filetypes = filetypesOf(filePath, *targetComponent->getFileSets().data());\r\n    QString const& fileContent = readInputFile(filePath, componentXMLPath);\r\n\r\n    QStringList availableComponentNames;\r\n\r\n    for (ImportPlugin const* parser : importPluginsForFileTypes(filetypes))\r\n    {\r\n        QStringList possibleComponents = parser->getFileComponents(fileContent);\r\n        for (auto component : possibleComponents)\r\n        {\r\n            QString componentName = parser->getComponentName(component);\r\n            availableComponentNames.append(componentName);\r\n\r\n            ImportRunner::AvailableComponent newComponent{ componentName, component };\r\n            componentsInFile_.append(newComponent);\r\n        }\r\n    }\r\n\r\n    return availableComponentNames;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ImportRunner::run()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<Component> ImportRunner::run(QString const& componentName, QString const& filePath,\r\n    QString const& componentXmlPath, QSharedPointer<const Component> targetComponent)\r\n{\r\n    if (displayTabs_ != nullptr)\r\n    {\r\n        QApplication::setOverrideCursor(Qt::WaitCursor);\r\n        displayTabs_->clear();\r\n    }\r\n\r\n    QSharedPointer<Component> importComponent(new Component(*targetComponent.data()));\r\n    parameterFinder_->setComponent(importComponent);\r\n\r\n    importIncludes(filePath, componentXmlPath, importComponent);\r\n\r\n    QStringList filetypes = filetypesOf(filePath, *importComponent->getFileSets().data());\r\n   \r\n    importFile(componentName, filePath, componentXmlPath, importPluginsForFileTypes(filetypes), importComponent);\r\n\r\n    if (displayTabs_ != nullptr)\r\n    {\r\n        QApplication::restoreOverrideCursor();\r\n    }\r\n\r\n    return importComponent;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ImportRunner::importFileTypes()\r\n//-----------------------------------------------------------------------------\r\nQStringList ImportRunner::importFileTypes() const\r\n{\r\n    QStringList fileTypes;\r\n\r\n    for (ImportPlugin const* parser : ImportPlugins_)\r\n    {\r\n        fileTypes.append(parser->getSupportedFileTypes());\r\n    }\r\n    fileTypes.removeDuplicates();\r\n\r\n    return fileTypes;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ImportRunner::loadPlugins()\r\n//-----------------------------------------------------------------------------\r\nvoid ImportRunner::loadPlugins(PluginManager const& pluginManager)\r\n{\r\n    for (IPlugin* plugin : pluginManager.getActivePlugins())\r\n    {\r\n        ImportPlugin* importPlugin = dynamic_cast<ImportPlugin*>(plugin);\r\n        ISourceAnalyzerPlugin* analyzerPlugin = dynamic_cast<ISourceAnalyzerPlugin*>(plugin);\r\n        if (importPlugin)\r\n        {            \r\n            ImportPlugins_.append(importPlugin);\r\n            addExpressionParserIfPossible(importPlugin);\r\n        }\r\n\r\n        if (analyzerPlugin)\r\n        {\r\n            analyzerPlugins_.append(analyzerPlugin);\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ImportRunner::setVerilogExpressionParser()\r\n//-----------------------------------------------------------------------------\r\nvoid ImportRunner::setExpressionParser(QSharedPointer<ExpressionParser> parser)\r\n{\r\n    expressionParser_ = parser;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ImportRunner::addExpressionParserIfPossible()\r\n//-----------------------------------------------------------------------------\r\nvoid ImportRunner::addExpressionParserIfPossible(ImportPlugin* importPlugin) const\r\n{\r\n    ExpressionSupport* pluginRequiringParser = dynamic_cast<ExpressionSupport*>(importPlugin);\r\n    if (pluginRequiringParser)\r\n    {\r\n        pluginRequiringParser->setExpressionParser(expressionParser_);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ImportRunner::scrollToFirstHighlight()\r\n//-----------------------------------------------------------------------------\r\nvoid ImportRunner::scrollSourceDisplayToFirstHighlight(QPlainTextEdit* sourceDisplay) const\r\n{\r\n    QTextCursor cursor = sourceDisplay->textCursor();\r\n    cursor.movePosition(QTextCursor::Start);\r\n    QTextCharFormat initialFormat = cursor.charFormat();\r\n\r\n    while (cursor.movePosition(QTextCursor::NextBlock) && cursor.charFormat() == initialFormat)\r\n    {\r\n        // Loop until first formatted block is found.\r\n    }\r\n\r\n    if (!cursor.atEnd())\r\n    {\r\n        int row = cursor.block().firstLineNumber();\r\n        sourceDisplay->verticalScrollBar()->setValue(row);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ImportRunner::importIncludes()\r\n//-----------------------------------------------------------------------------\r\nvoid ImportRunner::importIncludes(QString const& filePath, QString const& componentXmlPath, \r\n    QSharedPointer<Component> importComponent)\r\n{\r\n    if (filePath.isEmpty())\r\n    {\r\n        return;\r\n    }\r\n\r\n    QList<FileDependencyDesc> dependencies;\r\n    QString componentPath = QFileInfo(componentXmlPath).absolutePath() + QStringLiteral(\"/\");\r\n    QStringList filetypes = filetypesOf(filePath, *importComponent->getFileSets().data());\r\n\r\n    for (ISourceAnalyzerPlugin* analyzer : analyzerPluginsForFileTypes(filetypes))\r\n    {\r\n        analyzer->beginAnalysis(importComponent.data(), componentPath);\r\n        dependencies.append(analyzer->getFileDependencies(importComponent.data(), componentPath, \r\n            General::getAbsolutePath(componentXmlPath, filePath)));\r\n        analyzer->endAnalysis(importComponent.data(), componentPath);\r\n    }\r\n\r\n    QList<ImportPlugin*> importPlugins = includeImportPluginsForFileTypes(filetypes);\r\n    QString basePath = QFileInfo(General::getAbsolutePath(componentXmlPath, filePath)).absolutePath() + \r\n        QStringLiteral(\"/\");\r\n\r\n    for (FileDependencyDesc const& dependency : dependencies)\r\n    {        \r\n        importFile(QString(), dependency.filename, basePath, importPlugins, importComponent);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ImportRunner::filetypesOf()\r\n//-----------------------------------------------------------------------------\r\nQStringList ImportRunner::filetypesOf(QString const& fileName, QList<QSharedPointer<FileSet> > const& fileSets)\r\n    const\r\n{\r\n    QStringList fileTypes;\r\n\r\n    for (auto const& fileSet : fileSets)\r\n    {\r\n        for (auto const& file : *fileSet->getFiles())\r\n        {\r\n            if (fileName == file->name())\r\n            {\r\n                for (auto const& fileType : *file->getFileTypes())\r\n                {\r\n                    fileTypes.append(fileType.type_);\r\n                }\r\n            }\r\n        }\r\n    }\r\n\r\n    fileTypes.removeDuplicates();\r\n\r\n    if (fileTypes.isEmpty() && !fileName.isEmpty())\r\n    {\r\n        QString fileSuffix = QFileInfo(fileName).suffix();\r\n        fileTypes.append(FileHandler::getFileTypeForSuffix(fileSuffixTable_, fileSuffix));\r\n    }\r\n\r\n    return fileTypes;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ImportRunner::analyzerPluginsForFileTypes()\r\n//-----------------------------------------------------------------------------\r\nQList<ISourceAnalyzerPlugin*> ImportRunner::analyzerPluginsForFileTypes(QStringList filetypes) const\r\n{\r\n    QList<ISourceAnalyzerPlugin*> analysersForFiletype;\r\n    for (ISourceAnalyzerPlugin* analyzer : analyzerPlugins_)\r\n    {\r\n        QStringList supportedTypes = analyzer->getSupportedFileTypes();\r\n        for (QString const& filetype : filetypes)\r\n        {\r\n            if (supportedTypes.contains(filetype) && !analysersForFiletype.contains(analyzer))\r\n            {\r\n                analysersForFiletype.append(analyzer);\r\n            }\r\n        }\r\n    }\r\n\r\n    return analysersForFiletype;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ImportRunner::importFile()\r\n//-----------------------------------------------------------------------------\r\nvoid ImportRunner::importFile(QString const& componentName, QString const& filePath,\r\n    QString const& absoluteBasePath, QList<ImportPlugin *> importPluginsForFile,\r\n    QSharedPointer<Component> importComponent)\r\n{\r\n\r\n    QString componentDeclaration = getComponentFromFile(componentName);\r\n    if (filePath.isEmpty() || (componentDeclaration.isEmpty() && !componentName.isEmpty()))\r\n    {\r\n        return;\r\n    }\r\n\r\n    QString const& fileContent = readInputFile(filePath, absoluteBasePath);\r\n\r\n    QPlainTextEdit* sourceDisplayer = nullptr;\r\n    Highlighter* highlighter = nullptr;\r\n\r\n    if (displayTabs_ != nullptr)\r\n    {\r\n        sourceDisplayer = createSourceDisplayForFile(filePath);\r\n        sourceDisplayer->setPlainText(fileContent);\r\n\r\n        highlighter = new ImportHighlighter(sourceDisplayer, this);\r\n        highlighter->applyFontColor(fileContent, Qt::gray);\r\n    }\r\n\r\n    QStringList compatibilityWarnings;\r\n    for (ImportPlugin* parser : importPluginsForFile)\r\n    {\r\n        compatibilityWarnings.append(parser->getCompatibilityWarnings());\r\n        \r\n        HighlightSource* highlightSource = dynamic_cast<HighlightSource*>(parser);\r\n        if (highlightSource)\r\n        {\r\n            highlightSource->setHighlighter(highlighter);\r\n            parser->import(fileContent, componentDeclaration, importComponent);\r\n            highlightSource->setHighlighter(nullptr);\r\n        }\r\n        else\r\n        {\r\n            parser->import(fileContent, componentDeclaration, importComponent);\r\n        }\r\n    }\r\n    compatibilityWarnings.removeAll(QString());\r\n    emit noticeMessage(compatibilityWarnings.join(QStringLiteral(\"\\n\")));\r\n\r\n\r\n    if (displayTabs_ != nullptr)\r\n    {\r\n        displayTabs_->setCurrentIndex(displayTabs_->indexOf(sourceDisplayer));\r\n        scrollSourceDisplayToFirstHighlight(sourceDisplayer);\r\n\r\n        delete highlighter;\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ImportRunner::getComponentFromFile()\r\n//-----------------------------------------------------------------------------\r\nQString ImportRunner::getComponentFromFile(QString const& componentName) const\r\n{\r\n    if (!componentName.isEmpty())\r\n    {\r\n        for (auto component : componentsInFile_)\r\n        {\r\n            if (component.componentName_.compare(componentName) == 0)\r\n            {\r\n                return component.componentFile_;\r\n            }\r\n        }\r\n    }\r\n\r\n    return QString();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ImportRunner::createSourceDisplayForFile()\r\n//-----------------------------------------------------------------------------\r\nQPlainTextEdit* ImportRunner::createSourceDisplayForFile(QString const& filePath) const\r\n{\r\n    QPlainTextEdit* sourceDisplay = new QPlainTextEdit(displayTabs_);\r\n\r\n    QFont font(QStringLiteral(\"Courier\"));\r\n    font.setStyleHint(QFont::Monospace);\r\n    font.setFixedPitch(true);\r\n    font.setPointSize(9);\r\n\r\n    sourceDisplay->setFont(font);\r\n    sourceDisplay->setTabStopDistance(4 * sourceDisplay->fontMetrics().horizontalAdvance(QLatin1Char(' ')));\r\n    sourceDisplay->setReadOnly(true);\r\n    sourceDisplay->setCursorWidth(0);\r\n\r\n    displayTabs_->insertTab(0, sourceDisplay, QFileInfo(filePath).fileName());\r\n\r\n    return sourceDisplay;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ImportRunner::readInputFile()\r\n//-----------------------------------------------------------------------------\r\nQString ImportRunner::readInputFile(QString const& relativePath, QString const& basePath) const\r\n{\r\n    QString fileContent = QString();\r\n\r\n    QString absoluteFilePath = General::getAbsolutePath(basePath, relativePath);\r\n    QFile importedFile(absoluteFilePath);\r\n    if (QFileInfo(absoluteFilePath).exists() && importedFile.open(QIODevice::ReadOnly))\r\n    {\r\n        QTextStream stream(&importedFile);\r\n        fileContent = stream.readAll();\r\n        fileContent.replace(QStringLiteral(\"\\r\\n\"), QStringLiteral(\"\\n\"));\r\n\r\n        importedFile.close();\r\n    }\r\n    else\r\n    {\r\n        fileContent = tr(\"<File %1 not found in the file sets.>\").arg(relativePath);\r\n    }\r\n\r\n    return fileContent;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ImportRunner::importPluginsForFileTypes()\r\n//-----------------------------------------------------------------------------\r\nQList<ImportPlugin*> ImportRunner::importPluginsForFileTypes(QStringList const& filetypes) const\r\n{\r\n    QList<ImportPlugin*> compatiblePlugins;\r\n    for (ImportPlugin* importer : ImportPlugins_)\r\n    {\r\n        if (dynamic_cast<IncludeImportPlugin*>(importer) == 0)\r\n        {\r\n            QStringList parserAcceptedFiletypes = importer->getSupportedFileTypes();\r\n            for (QString const& filetype : filetypes)\r\n            {\r\n                if (parserAcceptedFiletypes.contains(filetype) && !compatiblePlugins.contains(importer))\r\n                {\r\n                    compatiblePlugins.prepend(importer);\r\n                }\r\n            }\r\n        }\r\n    }\r\n\r\n    return compatiblePlugins;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ImportRunner::includeImportPluginsForFileTypes()\r\n//-----------------------------------------------------------------------------\r\nQList<ImportPlugin*> ImportRunner::includeImportPluginsForFileTypes(QStringList const& filetypes) const\r\n{\r\n    QList<ImportPlugin*> compatiblePlugins;\r\n    for (ImportPlugin* importer : ImportPlugins_)\r\n    {\r\n        if (dynamic_cast<IncludeImportPlugin*>(importer) != 0)\r\n        {\r\n            QStringList parserAcceptedFiletypes = importer->getSupportedFileTypes();\r\n            for (QString const& filetype : filetypes)\r\n            {\r\n                if (parserAcceptedFiletypes.contains(filetype) && !compatiblePlugins.contains(importer))\r\n                {\r\n                    compatiblePlugins.prepend(importer);\r\n                }\r\n            }\r\n        }\r\n    }\r\n\r\n    return compatiblePlugins;\r\n}\r\n"
  },
  {
    "path": "KactusAPI/plugins/InterconnectGenerator/ConfigJsonParser.cpp",
    "content": "#include \"ConfigJsonParser.h\"\n#include <QtXml>\n\nusing namespace InterconnectGeneration;\n\nConfigJsonParser::ConfigJsonParser(){}\n\nConfigStruct* ConfigJsonParser::readFile() {\n\n    QFile configFile(path_);\n\n    if(configFile.open(QIODevice::ReadOnly)){\n\n        QByteArray configBytes = configFile.readAll();\n        configFile.close();\n\n        QJsonParseError jsonError;\n        QJsonDocument document = QJsonDocument::fromJson( configBytes, &jsonError );\n\n        if(jsonError.error == QJsonParseError::NoError) {\n\n            if(document.isObject()) {\n                QJsonObject jsonObj = document.object();\n\n                config_.interconVLNV = jsonObj.value(\"intercon\").toString();\n                config_.designVLNV = jsonObj.value(\"top\").toString();\n                config_.busVLNV = jsonObj.value(\"bus\").toString();\n                config_.clkVLNV = jsonObj.value(\"clk\").toString();\n                config_.rstVLNV = jsonObj.value(\"rst\").toString();\n                config_.filesetToGenerate = jsonObj.value(\"filesetToGenerate\").toString();\n\n                config_.busType = strToBusType(jsonObj.value(\"busType\").toString());\n                config_.addressWidth = jsonObj.value(\"addressWidth\").toString(); // corresponds to parsedAddressWidth in config struct\n                config_.dataWidth = jsonObj.value(\"dataWidth\").toString();\n                config_.idWidth = jsonObj.value(\"idWidth\").toInt();\n                config_.userWidth = jsonObj.value(\"userWidth\").toInt();\n\n                QJsonArray initListArr = jsonObj.value(\"initiators\").toArray();\n                config_.initList.resize(initListArr.size());\n\n                for(int n=0; n<initListArr.size(); n++){\n                    QJsonObject initObj = initListArr.at(n).toObject();\n                    InitStruct init;\n\n                    init.index = initObj.value(\"index\").toInt();\n                    init.name = initObj.value(\"name\").toString();\n                    //init.dataWidth = initObj.value(\"Data width\").toInt();\n\n                    config_.initList[init.index] = init;\n               }\n\n                QJsonArray targetListArr = jsonObj.value(\"targets\").toArray();\n                config_.targetList.resize(targetListArr.size());\n\n                for(int i=0; i<targetListArr.size(); i++){\n                    QJsonObject targetObj = targetListArr.at(i).toObject();\n                    TargetStruct target;\n\n                    target.index = targetObj.value(\"index\").toInt();\n                    target.name = targetObj.value(\"name\").toString();\n                    //target.dataWidth = targetObj.value(\"Data width\").toInt();\n\n                    QJsonArray addrRegionArr = targetObj.value(\"addressRegions\").toArray();\n\n                    for(int k=0; k<addrRegionArr.size(); ++k){\n                        QJsonObject addrObj = addrRegionArr.at(k).toObject();\n                        AddressPair addrPair;\n                        addrPair.start = addrObj.value(\"start\").toString();\n                        addrPair.end = addrObj.value(\"end\").toString();\n                        target.addressRegions.append(addrPair);\n                    }\n                    config_.targetList[target.index] = target;\n                }\n            }\n        }\n    }\n    return &config_;\n}\n\n//-----------------------------------------------------------------------------\n// Function: ConfigJsonParser::strToBusType()\n//-----------------------------------------------------------------------------\nInterconnectGeneration::BusType InterconnectGeneration::ConfigJsonParser::strToBusType(QString const& busTypeStr)\n{\n    auto busTypeStrUpper = busTypeStr.toUpper();\n    if (busTypeStrUpper.compare(\"AXI4\") == 0)\n    {\n        return BusType::AXI4;\n    }\n    else if (busTypeStrUpper.compare(\"AXI4LITE\") == 0)\n    {\n        return BusType::AXI4LITE;\n    }\n    else if (busTypeStrUpper.compare(\"OBI\") == 0)\n    {\n        return BusType::OBI;\n    }\n\n    return BusType::UNKNOWN;\n}\n\n//-----------------------------------------------------------------------------\n// Function: ConfigJsonParser::busTypeToStr()\n//-----------------------------------------------------------------------------\nQString ConfigJsonParser::busTypeToStr(BusType busType)\n{\n    switch (busType)\n    {\n    case BusType::AXI4:\n        return QString(\"AXI4\");\n    case BusType::AXI4LITE:\n        return QString(\"AXI4LITE\");\n    case BusType::OBI:\n        return QString(\"OBI\");\n    default:\n        return QString(\"Unknown\");\n    }\n}\n"
  },
  {
    "path": "KactusAPI/plugins/InterconnectGenerator/InterconnectGenerator.cpp",
    "content": "#include \"InterconnectGenerator.h\"\n\n#include <IPXACTmodels/Component/Channel.h>\n#include <IPXACTmodels/Component/FileSet.h>\n#include <IPXACTmodels/Component/File.h>\n\n#include <KactusAPI/KactusAPI.h>\n#include <KactusAPI/include/InterconnectRTLWriter.h>\n#include <KactusAPI/include/BusInterfaceInterfaceFactory.h>\n#include <KactusAPI/include/PortMapInterface.h>\n#include <KactusAPI/include/PortAbstractionInterface.h>\n\nusing namespace InterconnectGeneration;\n\n//-----------------------------------------------------------------------------\n// Function: InterconnectGenerator::InterconnectGenerator()\n//-----------------------------------------------------------------------------\nGenerator::Generator(LibraryInterface* library, MessageMediator* messager)\n    : library_(library),\n    messager_(messager),\n    config_(0)\n{\n}\n\n//-----------------------------------------------------------------------------\n// Function: InterconnectGenerator::generate()\n//-----------------------------------------------------------------------------\nVLNV Generator::generate()\n{\n    ConfigJsonParser parser;\n    config_ = parser.readFile();\n    VLNV designVLNV(VLNV::COMPONENT, config_->designVLNV);\n    VLNV interconVLNV(VLNV::COMPONENT, config_->interconVLNV);\n\n    busDefVLNV_ = VLNV(VLNV::BUSDEFINITION, config_->busVLNV);\n    rstVLNV_ = VLNV(VLNV::BUSDEFINITION, config_->rstVLNV);\n    clkVLNV_ = VLNV(VLNV::BUSDEFINITION, config_->clkVLNV);\n    openDesign(designVLNV);\n    createInterconComponent(interconVLNV);\n    findUnconnectedInterfaces();\n\n    directory_ = KactusAPI::getDefaultLibraryPath();\n    QString vlnvDir = \"/\" + interconComponent_->getVlnv().getVendor() + \"/\" + interconComponent_->getVlnv().getLibrary() + \"/\" +\n        interconComponent_->getVlnv().getName() + \"/\" + interconComponent_->getVlnv().getVersion();\n\n    directory_ += vlnvDir;\n    messager_->showMessage(QString(\"Writing component %1 to file\").arg(interconComponent_->getVlnv().toString()));\n    library_->writeModelToFile(directory_, interconComponent_);\n\n    InterconnectRTLWriter writer(interconComponent_, library_, messager_, directory_,\n        config_, clkPort_, rstPort_);\n    writer.generateRTL();\n    return interconVLNV;\n}\n\n//-----------------------------------------------------------------------------\n// Function: InterconnectGenerator::generate()\n//-----------------------------------------------------------------------------\nvoid Generator::generate(ConfigStruct* config, const QHash<QString, QList<QSharedPointer<BusInterface>>>& startingPoints,\n    const QHash<QString, QList<QSharedPointer<EndpointData>>>& endpoints, bool generateRtl)\n{\n    config_ = config;\n\n    VLNV designVLNV(VLNV::COMPONENT, config_->designVLNV);\n    VLNV interconVLNV(VLNV::COMPONENT, config_->interconVLNV);\n\n    busDefVLNV_ = VLNV(VLNV::BUSDEFINITION, config_->busVLNV);\n    rstVLNV_ = VLNV(VLNV::BUSDEFINITION, config_->rstVLNV);\n    clkVLNV_ = VLNV(VLNV::BUSDEFINITION, config_->clkVLNV);\n    openDesign(designVLNV);\n    createInterconComponent(interconVLNV);\n    processStartingPointsAndEndpoints(startingPoints, endpoints);\n\n    if (config_->isChannel)\n    {\n        createChannel();\n    }\n\n    directory_ = KactusAPI::getDefaultLibraryPath();\n    QString vlnvDir = \"/\" + interconComponent_->getVlnv().getVendor() + \"/\" + interconComponent_->getVlnv().getLibrary() + \"/\" +\n        interconComponent_->getVlnv().getName() + \"/\" + interconComponent_->getVlnv().getVersion();\n\n    directory_ += vlnvDir;\n    \n    if (generateRtl && config_->filesetToGenerate.isEmpty() == false)\n    {\n        createFileAndFileset();\n    }\n    \n    messager_->showMessage(QString(\"Writing component %1 to file\").arg(interconComponent_->getVlnv().toString()));\n\n    bool writeSucceeded = true;\n    if (!library_->writeModelToFile(directory_, interconComponent_))\n    {\n        writeSucceeded = false;\n    }\n\n    if (!library_->writeModelToFile(design_))\n    {\n        writeSucceeded = false;\n    }\n\n    if (!writeSucceeded) {\n        messager_->showError(\"Error saving design to disk.\");\n    }\n\n    if (generateRtl)\n    {\n        InterconnectRTLWriter writer(interconComponent_, library_, messager_, directory_, config_, clkPort_, rstPort_);\n        writer.generateRTL();\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: InterconnectGenerator::openDesign()\n//-----------------------------------------------------------------------------\nvoid Generator::openDesign(VLNV designVLNV)\n{\n    QSharedPointer<Document> designCompDocument = library_->getModel(designVLNV);\n\n    QSharedPointer<Component> designComp = designCompDocument.dynamicCast<Component>();\n    QSharedPointer<QList<QSharedPointer<DesignConfigurationInstantiation> > > list = designComp->getDesignConfigurationInstantiations();\n    QSharedPointer<DesignConfigurationInstantiation> inst = list->at(0);\n    QSharedPointer<ConfigurableVLNVReference> vlnv = inst->getDesignConfigurationReference();\n\n    QSharedPointer<Document> designConfDocument = library_->getModel(*vlnv);\n    QSharedPointer<DesignConfiguration> designConfig = designConfDocument.dynamicCast<DesignConfiguration>();\n\n    QSharedPointer<Document> designDocument = library_->getModel(designConfig->getDesignRef());\n    design_ = designDocument.dynamicCast<Design>();\n\n    instanceInterface_->setComponentInstances(design_);\n    connectionInterface_->setInterconnections(design_);\n    adhocConnectionInterface_->setConnections(design_);\n}\n\n//-----------------------------------------------------------------------------\n// Function: InterconnectGenerator::createInterconComponent()\n//-----------------------------------------------------------------------------\nvoid Generator::createInterconComponent(VLNV VLNV)\n{\n    if (library_->contains(VLNV)) {\n        library_->removeObject(VLNV);\n    }\n    messager_->showMessage(\"Creating new component\");\n    QSharedPointer<Component> component = QSharedPointer<Component>(new Component(VLNV, design_->getRevision()));\n\n    component->setHierarchy(KactusAttribute::FLAT);\n    component->setFirmness(KactusAttribute::MUTABLE);\n    component->setImplementation(KactusAttribute::HW);\n    component->setVersion(VLNV.getVersion());\n    interconComponent_ = component;\n\n    parameterFinder_->setComponent(interconComponent_);\n\n    interconComponent_->getParameters()->append(config_->interconnectParams);\n\n    busInfInterface_ = BusInterfaceInterfaceFactory::createBusInterface(parameterFinder_,\n        expressionFormatter_, expressionParser_, interconComponent_, library_);\n\n    busInfInterface_->setBusInterfaces(interconComponent_);\n    absTypeInf_ = busInfInterface_->getAbstractionTypeInterface();\n\n    instanceInterface_->addComponentInstance(VLNV.getName().toStdString());\n    instanceInterface_->setComponentReference(VLNV.getName().toStdString(), VLNV.getVendor().toStdString(), VLNV.getLibrary().toStdString(),\n        VLNV.getName().toStdString(), VLNV.getVersion().toStdString());\n\n    messager_->showMessage(\"Component created and linked\");\n}\n\n//-----------------------------------------------------------------------------\n// Function: InterconnectGenerator::findUnconnectedInterfaces()\n//-----------------------------------------------------------------------------\nvoid Generator::findUnconnectedInterfaces()\n{\n    messager_->showMessage(\"Seaching for interfaces..\");\n    int index = 0;\n    std::vector<std::string> compNames = instanceInterface_->getItemNames();\n\n    for (std::string compName : compNames)\n    {\n        messager_->showMessage(QString(\"Comp name %1\").arg(QString::fromStdString(compName)));\n        if (compName != \"interconnect\") {\n            auto compVLNV = instanceInterface_->getComponentReference(compName);\n            QSharedPointer<Document> compDocument = library_->getModel(*compVLNV.dynamicCast<VLNV>());\n            QSharedPointer<Component> comp = compDocument.dynamicCast<Component>();\n            QStringList busNames = comp->getBusInterfaceNames();\n            for (QString busName : busNames)\n            {\n                QSharedPointer<BusInterface> busInf = comp->getBusInterface(busName);\n                VLNV busVLNV = busInf->getBusType();\n                if (busVLNV == busDefVLNV_)\n                {\n                    if (!design_->hasInterconnection(QString::fromStdString(compName), busName))\n                    {\n                        messager_->showMessage(\"Unconnected interface found\");\n                        prefix_ = compName + \"_\";\n                        General::InterfaceMode newMode = General::getCompatibleInterfaceMode(busInf->getInterfaceMode());\n                        std::string modeString = General::interfaceMode2Str(newMode).toStdString();\n\n                        createBusInterface(busName.toUpper().toStdString(), modeString, index);\n\n                        createPortMaps(modeString, busInf);\n\n                        createPhysPorts(comp, busName);\n\n                        //connectionInterface_->addInterconnection(compName, busName.toStdString(), interconComponent_->getVlnv().getName().toStdString(), newBusName);\n\n                        index++;\n                        break;\n                    }\n                }\n            }\n        }\n    }\n    createRstorClkInterface(\"rst\", index);\n    createRstorClkInterface(\"clk\", index + 1);\n}\n\n//-----------------------------------------------------------------------------\n// Function: InterconnectGenerator::processStartingPointsAndEndpoints()\n//-----------------------------------------------------------------------------\nvoid Generator::processStartingPointsAndEndpoints(\n    const QHash<QString, QList<QSharedPointer<BusInterface>>>& startingPoints,\n    const QHash<QString, QList<QSharedPointer<EndpointData>>>& endpoints)\n{\n    messager_->showMessage(\"Processing starting points and endpoints...\");\n    int index = 0;\n\n    if (!config_->isChannel) {\n        createGlobalAddressSpaceFromEndpoints(endpoints);\n    }\n\n    std::vector<BusInterfaceInfo> createdBuses;\n\n    auto busesFromEndpoints = processEndpointSide(endpoints, index);\n    auto busesFromStarting = processStartingSide(startingPoints, index);\n\n    createdBuses.insert(createdBuses.end(), busesFromEndpoints.begin(), busesFromEndpoints.end());\n    createdBuses.insert(createdBuses.end(), busesFromStarting.begin(), busesFromStarting.end());\n\n    finalizeBusInterfaceCustomization(createdBuses);\n\n    if (!config_->rstVLNV.isEmpty()) createRstorClkInterface(\"rst\", index++);\n    if (!config_->clkVLNV.isEmpty()) createRstorClkInterface(\"clk\", index++);\n}\n\n//-----------------------------------------------------------------------------\n// Function: InterconnectGenerator::processEndpointSide()\n//-----------------------------------------------------------------------------\nstd::vector<BusInterfaceInfo> Generator::processEndpointSide(\n    const QHash<QString, QList<QSharedPointer<EndpointData>>>& endpoints, int& index)\n{\n    std::vector<BusInterfaceInfo> results;\n    VLNV designVLNV(VLNV::COMPONENT, config_->designVLNV);\n\n    for (auto it = endpoints.constBegin(); it != endpoints.constEnd(); ++it) {\n        QString instanceName = it.key();\n        bool isTop = (instanceName == designVLNV.getName());\n\n        auto compVLNV = resolveComponentVLNV(instanceName, isTop);\n        if (!compVLNV) continue;\n\n        QSharedPointer<Document> compDocument = library_->getModel(*compVLNV.dynamicCast<VLNV>());\n        QSharedPointer<Component> comp = compDocument.dynamicCast<Component>();\n\n        for (const QSharedPointer<EndpointData>& data : it.value()) {\n            QSharedPointer<BusInterface> bus = data->endpointBus;\n\n            BusInterfaceInfo info = createInterfaceForBus(instanceName, bus, isTop, true, index);\n            info.start = data->start;\n            info.range = data->range;\n            results.push_back(info);\n\n            createPortMaps(info.mode, bus);\n            createPhysPorts(comp, bus->name(), isTop);\n\n            index++;\n        }\n    }\n\n    return results;\n}\n\n//-----------------------------------------------------------------------------\n// Function: InterconnectGenerator::processStartingSide()\n//-----------------------------------------------------------------------------\nstd::vector<BusInterfaceInfo> Generator::processStartingSide(\n    const QHash<QString, QList<QSharedPointer<BusInterface>>>& startingPoints, int& index)\n{\n    std::vector<BusInterfaceInfo> results;\n    VLNV designVLNV(VLNV::COMPONENT, config_->designVLNV);\n\n    for (auto it = startingPoints.constBegin(); it != startingPoints.constEnd(); ++it) {\n        QString instanceName = it.key();\n        bool isTop = (instanceName == designVLNV.getName());\n\n        auto compVLNV = resolveComponentVLNV(instanceName, isTop);\n        if (!compVLNV) continue;\n\n        QSharedPointer<Document> compDocument = library_->getModel(*compVLNV.dynamicCast<VLNV>());\n        QSharedPointer<Component> comp = compDocument.dynamicCast<Component>();\n\n        for (const QSharedPointer<BusInterface>& bus : it.value()) {\n            BusInterfaceInfo info = createInterfaceForBus(instanceName, bus, isTop, false, index);\n            results.push_back(info);\n            \n            createPortMaps(info.mode, bus);\n            createPhysPorts(comp, bus->name(), isTop);\n\n            index++;\n        }\n    }\n    return results;\n}\n\n//-----------------------------------------------------------------------------\n// Function: InterconnectGenerator::createInterfaceForBus()\n//-----------------------------------------------------------------------------\nBusInterfaceInfo Generator::createInterfaceForBus(\n    const QString& instanceName, const QSharedPointer<BusInterface>& bus,\n    bool isTop, bool isEndpoint, int& index)\n{\n    QString busName = bus->name();\n    VLNV busVLNV = bus->getBusType();\n    prefix_ = instanceName.toStdString() + \"_\" + busName.toStdString() + \"_\";\n\n    bool isTarget = isTargetInterface(bus);\n    // Get the mode the new interconnect bus interface should use (e.g. endpoint = target and channel is used => mode should be mirroredTarget)\n    std::string mode = getInterfaceMode(bus, isTarget, config_->isChannel, isTop); \n    std::string newName = createBusInterface(busVLNV, busName.toUpper().toStdString(), mode, index);\n    \n    if (!globalAddressSpaceName_.empty() && isEndpoint && isTarget) \n    {\n        busInfInterface_->setAddressSpaceReference(newName, globalAddressSpaceName_);\n    }\n\n    if (isTop) \n    {\n        connectionInterface_->addHierarchicalInterconnection(\n            interconComponent_->getVlnv().getName().toStdString(), newName, busName.toStdString());\n    }\n    else \n    {\n        connectionInterface_->addInterconnection(\n            instanceName.toStdString(), busName.toStdString(),\n            interconComponent_->getVlnv().getName().toStdString(), newName);\n    }\n\n    return { newName, mode };\n}\n\n//-----------------------------------------------------------------------------\n// Function: InterconnectGenerator::resolveComponentVLNV()\n//-----------------------------------------------------------------------------\nQSharedPointer<ConfigurableVLNVReference> Generator::resolveComponentVLNV(\n    const QString& instanceName, bool isTop) const\n{\n    VLNV designVLNV(VLNV::COMPONENT, config_->designVLNV);\n\n    auto compVLNV = instanceInterface_->getComponentReference(instanceName.toStdString());\n\n    if (!compVLNV && isTop) {\n        return QSharedPointer<ConfigurableVLNVReference>::create(designVLNV);\n    }\n\n    return compVLNV;\n}\n\n//-----------------------------------------------------------------------------\n// Function: InterconnectGenerator::isTargetInterface()\n//-----------------------------------------------------------------------------\nbool Generator::isTargetInterface(const QSharedPointer<BusInterface>& bus) const\n{\n    auto mode = bus->getInterfaceMode();\n\n    return mode == General::TARGET ||\n        mode == General::MIRRORED_INITIATOR ||\n        mode == General::SLAVE ||\n        mode == General::MIRRORED_MASTER;\n}\n\n//-----------------------------------------------------------------------------\n// Function: InterconnectGenerator::getInterfaceMode()\n//-----------------------------------------------------------------------------\nstd::string Generator::getInterfaceMode(QSharedPointer<BusInterface> bus, bool isTarget, bool isChannel, bool isTop)\n{\n    if (isTop) \n    {\n        return General::interfaceMode2Str(bus->getInterfaceMode()).toStdString();\n    }\n    Document::Revision rev = design_->getRevision();\n\n    if (rev == Document::Revision::Std14)\n    {\n        if (!isTarget)\n            return isChannel ? \"mirroredMaster\" : \"slave\";\n        else\n            return isChannel ? \"mirroredSlave\" : \"master\";\n    }\n    else if (rev == Document::Revision::Std22)\n    {\n        if (!isTarget)\n            return isChannel ? \"mirroredInitiator\" : \"target\";\n        else\n            return isChannel ? \"mirroredTarget\" : \"initiator\";\n    }\n    return !isTarget ? \"target\" : \"initiator\";\n}\n\n//-----------------------------------------------------------------------------\n// Function: InterconnectGenerator::createBusInterface()\n//-----------------------------------------------------------------------------\nvoid Generator::createBusInterface(std::string busName, std::string modeString, int index)\n{\n    VLNV busDef = busDefVLNV_;\n    std::string newBusName = prefix_ + ConfigJsonParser::busTypeToStr(config_->busType).toStdString();\n\n    if (busName == \"rst\")\n    {\n        busDef = rstVLNV_;\n        QString name = rstVLNV_.getName().split(\".abs\")[0];\n        busDef.setName(name);\n        newBusName = prefix_ + name.toStdString();\n        rstName_ = newBusName;\n    }\n    else if (busName == \"clk\")\n    {\n        busDef = clkVLNV_;\n        QString name = clkVLNV_.getName().split(\".abs\")[0];\n        busDef.setName(name);\n        newBusName = prefix_ + name.toStdString();\n        clockName_ = newBusName;\n    }\n\n    messager_->showMessage(QString(\"Creating %1 interface\").arg(QString::fromStdString(newBusName)));\n    busInfInterface_->addBusInterface(index, newBusName);\n    busInfInterface_->setMode(newBusName, modeString);\n\n    busInfInterface_->setBustype(newBusName, busDef.getVendor().toStdString(), busDef.getLibrary().toStdString(),\n        busDef.getName().toStdString(), busDef.getVersion().toStdString());\n\n    busInfInterface_->addAbstractionType(newBusName, busDef.getVendor().toStdString(), busDef.getLibrary().toStdString(),\n        busDef.getName().toStdString() + \".absDef\", busDef.getVersion().toStdString());\n\n    messager_->showMessage(QString(\"%1 interface created\").arg(QString::fromStdString(newBusName)));\n}\n\n//-----------------------------------------------------------------------------\n// Function: InterconnectGenerator::createBusInterface()\n//-----------------------------------------------------------------------------\nstd::string Generator::createBusInterface(VLNV busVLNV, std::string busName,\n    std::string modeString, int index\n)\n{\n    VLNV busDef = busDefVLNV_;\n\n    std::string newBusName = prefix_;\n    newBusName.pop_back();\n\n    busInfInterface_->addBusInterface(index, newBusName);\n    busInfInterface_->setMode(newBusName, modeString);\n\n    busInfInterface_->setBustype(newBusName, busVLNV.getVendor().toStdString(), busVLNV.getLibrary().toStdString(),\n        busVLNV.getName().toStdString(), busVLNV.getVersion().toStdString());\n\n    busInfInterface_->addAbstractionType(newBusName, busDef.getVendor().toStdString(), busDef.getLibrary().toStdString(),\n        busDef.getName().toStdString(), busDef.getVersion().toStdString());\n\n    messager_->showMessage(QString(\"%1 interface created\").arg(QString::fromStdString(newBusName)));\n\n    return newBusName;\n}\n\n//-----------------------------------------------------------------------------\n// Function: InterconnectGenerator::finalizeBusInterfaceCustomization()\n//-----------------------------------------------------------------------------\nvoid Generator::finalizeBusInterfaceCustomization(const std::vector<BusInterfaceInfo>& createdBuses)\n{\n    for (const auto& busInfo : createdBuses) {\n        const std::string& name = busInfo.name;\n        const std::string& mode = busInfo.mode;\n\n        if (mode == \"slave\" || mode == \"target\") {\n            busInfInterface_->setupSubInterfaces(name);\n            TransparentBridgeInterface* bridgeInterface = busInfInterface_->getBridgeInterface();\n            if (!bridgeInterface) {\n                continue;\n            }\n\n            int index = bridgeInterface->itemCount();\n\n            for (const std::string& candidate : busInfInterface_->getItemNames()) {\n                std::string candidateMode = busInfInterface_->getModeString(candidate);\n\n                if (candidateMode != \"master\" && candidateMode != \"initiator\") {\n                    continue;\n                }\n                bridgeInterface->addBridge(index, candidate);\n                index++;\n            }\n        }\n        else if (mode == \"master\" || mode == \"initiator\") {\n            if (!busInfo.start.isEmpty()) {\n                busInfInterface_->setBaseAddress(name, busInfo.start.toStdString());\n            }\n        }\n        else if (mode == \"mirroredSlave\" || mode == \"mirroredTarget\") {\n            if (!busInfo.start.isEmpty()) {\n                busInfInterface_->setRemapAddress(name, busInfo.start.toStdString());\n            }\n            if (!busInfo.range.isEmpty()) {\n                busInfInterface_->setRange(name, busInfo.range.toStdString());\n            }\n        }\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: InterconnectGenerator::createPortMaps()\n//-----------------------------------------------------------------------------\nvoid Generator::createPortMaps(std::string modeString, QSharedPointer<BusInterface> busInf)\n{\n    messager_->showMessage(\"Creating port maps\");\n\n    if (absTypeInf_->setupAbstractionTypeForPortMapInterface(0)) {\n\n        PortMapInterface* portMapInf = absTypeInf_->getPortMapInterface();\n        \n        std::vector<std::string> logicalPortNames = portMapInf->\n            getLogicalPortInterface()->getItemNamesWithModeAndGroup(modeString, \"\");\n        \n        QList<QSharedPointer<PortMap> > portMaps = busInf->getPortMapsForView(\"\");\n        \n        for (int i = 0; i < portMaps.size(); i++)\n        {\n            QSharedPointer<PortMap> portMap = portMaps.at(i);\n\n            if (!portMap || !portMap->getLogicalPort() || !portMap->getPhysicalPort())\n            {\n                continue;\n            }\n\n            for (std::string const& logicalName : logicalPortNames)\n            {\n                std::string portMapName = portMap->getLogicalPort()->name_.toStdString();\n                    \n                if (logicalName == portMapName)\n                {\n                    std::string newName = prefix_ + portMap->getPhysicalPort()->name_.toStdString();\n\n                    QSharedPointer<PartSelect> partSelect = portMap->getPhysicalPort()->partSelect_;\n                    QSharedPointer<Range> range = portMap->getLogicalPort()->range_;\n                    int portMapIndex = portMapInf->itemCount();\n                        \n                    portMapInf->addPortMap(portMapIndex);\n\n                    portMapInf->setPhysicalPort(portMapIndex, newName);\n\n                    if (partSelect != nullptr)\n                    {\n                        portMapInf->setPhysicalLeftBound(portMapIndex, partSelect->getLeftRange().toStdString());\n                        portMapInf->setPhysicalRightBound(portMapIndex, partSelect->getRightRange().toStdString());\n                    }\n\n                    portMapInf->setLogicalPort(portMapIndex, logicalName);\n\n                    if (range != nullptr)\n                    {\n                        portMapInf->setLogicalLeftBound(portMapIndex, range->getLeft().toStdString());\n                        portMapInf->setLogicalRightBound(portMapIndex, range->getRight().toStdString());\n                    }\n                        \n                    break;\n                }\n            }\n        }\n    }\n    messager_->showMessage(\"All port maps created\");\n}\n\n//-----------------------------------------------------------------------------\n// Function: InterconnectGenerator::createPhysPorts()\n//-----------------------------------------------------------------------------\nvoid Generator::createPhysPorts(QSharedPointer<Component> comp, QString busName, bool isTop)\n{\n    messager_->showMessage(\"Populating model with ports\");\n\n    parameterFinder_->setComponent(comp);\n    portValidator_->componentChange(comp->getViews());\n    portsInterface_->setPorts(comp->getPorts());\n\n    QSharedPointer<Document> libComp = library_->getModel(busDefVLNV_);\n    QSharedPointer<AbstractionDefinition> absDef = libComp.staticCast<AbstractionDefinition>();\n    portAbsInterface_->setAbsDef(absDef);\n\n    for (QSharedPointer<Port> port : comp->getPortsMappedInInterface(busName))\n    {\n        QString physicalName = port->name();\n        std::string logicalName = getLogicalPortName(comp, busName, physicalName);\n\n        QString leftBound, rightBound;\n\n        if (!logicalName.empty())\n        {\n            std::tie(leftBound, rightBound) = getWidthBoundsFromAbstraction(logicalName);\n        }\n\n        if (leftBound.isEmpty() || rightBound.isEmpty())\n        {\n            std::tie(leftBound, rightBound) = getMirroredWidthBounds(physicalName);\n        }\n\n        QSharedPointer<Port> newPort(new Port(*port));\n        newPort->setName(QString::fromStdString(prefix_) + newPort->name());\n        \n        // ICN component ports shouldn't have default values\n        newPort->setDefaultValue(QString());\n\n        DirectionTypes::Direction newDir;\n        if (isTop) \n        {\n            newDir = newPort->getDirection();\n        }\n        else \n        {\n            newDir = DirectionTypes::convert2Mirrored(newPort->getDirection());\n        }\n        newPort->setDirection(newDir);\n        newPort->setLeftBound(leftBound);\n        newPort->setRightBound(rightBound);\n\n        interconComponent_->getPorts()->append(newPort);\n    }\n\n    parameterFinder_->setComponent(interconComponent_);\n}\n\n//-----------------------------------------------------------------------------\n// Function: InterconnectGenerator::getLogicalPortName()\n//-----------------------------------------------------------------------------\nstd::string Generator::getLogicalPortName(\n    QSharedPointer<Component> comp, QString busName, QString physicalName) const\n{\n    auto portMaps = comp->getBusInterface(busName)->getPortMapsForView(\"\");\n    for (const auto& map : portMaps)\n    {\n        if (map->getPhysicalPort() && map->getPhysicalPort()->name_ == physicalName)\n        {\n            return map->getLogicalPort()->name_.toStdString();\n        }\n    }\n    return \"\";\n}\n\n//-----------------------------------------------------------------------------\n// Function: InterconnectGenerator::getWidthBoundsFromAbstraction()\n//-----------------------------------------------------------------------------\nstd::pair<QString, QString> Generator::getWidthBoundsFromAbstraction(\n    const std::string& logicalName) const\n{\n    int index = portAbsInterface_->getItemIndex(logicalName);\n    if (index == -1) {\n        return { \"\", \"\" };\n    }\n\n    std::string absWidth = portAbsInterface_->getWidthExpression(index);\n    if (absWidth.empty()) {\n        return { \"\", \"\" };\n    }\n\n    QString widthExpr = QString::fromStdString(absWidth).trimmed();\n    QString left = widthExpr == \"1\" ? \"0\" : QString(\"%1 - 1\").arg(widthExpr);\n    QString right = \"0\";\n\n    return { left, right };\n}\n\n//-----------------------------------------------------------------------------\n// Function: InterconnectGenerator::getMirroredWidthBounds()\n//-----------------------------------------------------------------------------\nstd::pair<QString, QString> Generator::getMirroredWidthBounds(const QString& physicalName) const\n{\n    std::string left = portsInterface_->getLeftBoundValue(physicalName.toStdString());\n    std::string right = portsInterface_->getRightBoundValue(physicalName.toStdString());\n\n    QString leftBound = left.empty() ? \"0\" : QString::fromStdString(left);\n    QString rightBound = right.empty() ? \"0\" : QString::fromStdString(right);\n\n    return { leftBound, rightBound };\n}\n\n//-----------------------------------------------------------------------------\n// Function: InterconnectGenerator::createRstorClkInterface()\n//-----------------------------------------------------------------------------\nvoid Generator::createRstorClkInterface(std::string busName, int index)\n{\n    General::InterfaceMode mode = General::TARGET;\n\n    if (interconComponent_->getRevision() == Document::Revision::Std14)\n    {\n        mode = General::SLAVE;\n    }\n\n    std::string modeString = General::interfaceMode2Str(mode).toStdString();\n\n    prefix_ = busName + \"_\";\n\n    createBusInterface(busName, modeString, index);\n\n    absTypeInf_->setupAbstractionTypeForPortMapInterface(0);\n\n    PortMapInterface* portMapInf = absTypeInf_->getPortMapInterface();\n    PortsInterface* portInf = portMapInf->getPhysicalPortInterface();\n    PortAbstractionInterface* portAbsInf = portMapInf->getLogicalPortInterface();\n\n    portMapInf->setupPhysicalPorts(interconComponent_->getPorts());\n\n    for (std::string portName : portAbsInf->getItemNamesWithModeAndGroup(modeString, \"\"))\n    {\n        if (busName == \"clk\") {\n            clkPort_ = QString::fromStdString(portName);\n        }\n        else if (busName == \"rst\") {\n            rstPort_ = QString::fromStdString(portName);\n        }\n        int portIndex = portAbsInf->getItemIndex(portName);\n\n        if (!portInf->getPort(portName)) {\n            portInf->addWirePort(portName);\n        }\n\n        portInf->setDirection(portName, DirectionTypes::direction2Str(\n            portAbsInf->getDirection(portName, mode, \"\")).toStdString());\n\n        uint leftBound = 0;\n        bool signalIntegerOk = false;\n        uint signalWidth = QString::fromStdString(\n            portAbsInf->getWidthFormattedExpression(portIndex)).toUInt(&signalIntegerOk);\n\n        if (signalIntegerOk == true && signalWidth > 0)\n        {\n            leftBound = signalWidth - 1;\n        }\n\n        portInf->setLeftBound(portName, QString::number(leftBound).toStdString());\n        portInf->setRightBound(portName, \"0\");\n\n        portInf->setDefaultValue(portName, portAbsInf->getDefaultValueExpression(portIndex));\n        portInf->setDescription(portName, portAbsInf->getDescription(portName));\n\n        int mapIndex = portMapInf->itemCount();\n\n        portMapInf->addPortMap(mapIndex);\n        portMapInf->setLogicalPort(mapIndex, portName);\n\n        portMapInf->connectPorts(portName, portName);\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: InterconnectGenerator::createChannel()\n//-----------------------------------------------------------------------------\nvoid Generator::createChannel()\n{\n    std::vector<std::string> busNames = busInfInterface_->getItemNames();\n    QList<QString> interfaceList;\n\n    for (const std::string& name : busNames) {\n        if (name == clockName_ || name == rstName_)\n        {\n            continue;\n        }\n        interfaceList.append(QString::fromStdString(name));\n    }\n\n    QSharedPointer<Channel> channel(new Channel());\n    channel->setInterfaces(interfaceList);\n    channel->setName(\"channel\");\n\n    interconComponent_->getChannels()->append(channel);\n}\n\n//-----------------------------------------------------------------------------\n// Function: InterconnectGenerator::createGlobalAddressSpaceFromEndpoints()\n//-----------------------------------------------------------------------------\nvoid Generator::createGlobalAddressSpaceFromEndpoints(\n    const QHash<QString, QList<QSharedPointer<EndpointData>>>& endpoints)\n{\n    quint64 lowestStart = UINT64_MAX;\n    quint64 highestEnd = 0;\n\n    for (const auto& endpointList : endpoints) {\n        for (const QSharedPointer<EndpointData>& endpointData : endpointList) {\n            bool okStart = false, okRange = false;\n\n            quint64 start = parseIpxactHex(endpointData->start, &okStart);\n            quint64 range = parseIpxactHex(endpointData->range, &okRange);\n\n            if (okStart && okRange) {\n                lowestStart = std::min(lowestStart, start);\n                highestEnd = std::max(highestEnd, start + range);\n            }\n        }\n    }\n\n    if (lowestStart == UINT64_MAX || highestEnd == 0) {\n        return;\n    }\n\n    quint64 addrSpaceSize = (highestEnd > lowestStart) ? (highestEnd - lowestStart) : 0;\n\n    QString hexRange = QString::number(addrSpaceSize, 16).rightJustified(4, '0').toUpper();\n    QString ipxactRange = \"'h\" + hexRange;\n\n    QString addrWidth = config_->addressWidth;\n    globalAddressSpaceName_ = ConfigJsonParser::busTypeToStr(config_->busType).toStdString() + \"_global_space\";\n    createAddressSpace(globalAddressSpaceName_, ipxactRange, addrWidth);\n}\n\n//-----------------------------------------------------------------------------\n// Function: InterconnectGenerator::parseIpxactHex()\n//-----------------------------------------------------------------------------\nquint64 Generator::parseIpxactHex(const QString& str, bool* ok)\n{\n    QString clean = str.trimmed().toUpper();\n\n    if (clean.startsWith(\"'H\")) {\n        clean.remove(0, 2);\n    }\n    else if (clean.startsWith(\"0X\")) {\n        clean.remove(0, 2);\n    }\n\n    return clean.toULongLong(ok, 16);\n}\n\n//-----------------------------------------------------------------------------\n// Function: InterconnectGenerator::createAddressSpace()\n//-----------------------------------------------------------------------------\nvoid Generator::createAddressSpace(std::string spaceName, QString range, QString width)\n{\n    QSharedPointer<AddressSpace> addrSpace = QSharedPointer<AddressSpace>(\n        new AddressSpace(QString::fromStdString(spaceName), range, width));\n\n    interconComponent_->getAddressSpaces()->append(addrSpace);\n}\n\n//-----------------------------------------------------------------------------\n// Function: Generator::createFileAndFileset()\n//-----------------------------------------------------------------------------\nvoid Generator::createFileAndFileset()\n{\n    QSharedPointer<FileSet> newFileSet(new FileSet(config_->filesetToGenerate));\n    auto filePath = directory_ + \"/\" + interconComponent_->getVlnv().getName() + \".v\";\n\n    QSharedPointer<File> rtlFile(new File(filePath, \"verilog\"));\n    rtlFile->setDescription(\"Generated interconnect RTL\");\n\n    newFileSet->addFile(rtlFile);\n    interconComponent_->getFileSets()->append(newFileSet);\n}\n"
  },
  {
    "path": "KactusAPI/plugins/InterconnectGenerator/InterconnectRTLWriter.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: InterconnectRTLWriter.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Teemu Hanhisuanto, Linda Virtanen\n// Date: 07.2025\n//\n// Description:\n// Generates top-level Verilog interconnects for supported bus types utilizing\n// Pulp Platform libraries (https://github.com/pulp-platform).\n//-----------------------------------------------------------------------------\n\n#include \"InterconnectRTLWriter.h\"\n\n#include <IPXACTmodels/DesignConfiguration/DesignConfiguration.h>\n#include <IPXACTmodels/Design/Design.h>\n\nusing namespace InterconnectGeneration;\n\n//-----------------------------------------------------------------------------\n// Function: InterconnectRTLWriter::InterconnectRTLWriter\n//-----------------------------------------------------------------------------\nInterconnectRTLWriter::InterconnectRTLWriter(QSharedPointer<Component> component,\n    LibraryInterface* library, MessageMediator* messager, QString directory,\n    ConfigStruct* config, QString clk, QString rst)\n{\n    component_ = component;\n    library_ = library;\n    messager_ = messager;\n    directory_ = directory;\n    config_ = config;\n    clkPort_ = clk;\n    rstPort_ = rst;\n}\n\n//-----------------------------------------------------------------------------\n// Function: InterconnectRTLWriter::generateRTL\n//-----------------------------------------------------------------------------\nvoid InterconnectRTLWriter::generateRTL()\n{\n\n    QSharedPointer<Design> design;\n    QSharedPointer<DesignConfiguration> designConfig;\n    for (IPlugin* plugin : PluginManager::getInstance().getActivePlugins()) {\n        CLIGenerator* runnable = dynamic_cast<CLIGenerator*>(plugin);\n        if (runnable != 0)\n        {\n            if (runnable->getOutputFormat().toLower() == \"verilog\") {\n                PluginUtilityAdapter adapter(library_, messager_, VersionHelper::createVersionString(), nullptr);\n                runnable->runGenerator(&adapter, component_, design, designConfig, \"\", directory_);\n            }\n        }\n    }\n\n    QString verilogDirectory = directory_ + \"/\" + component_->getVlnv().getName() + \".v\";\n    messager_->showMessage(QString(\"Opening file %1\").arg(verilogDirectory));\n    QFile verilogFile(verilogDirectory);\n\n    QString verilogTxt;\n    QTextStream verilogRTL(&verilogFile);\n    \n    if (verilogFile.open(QIODevice::ReadOnly | QIODevice::Text)) {\n        while (!verilogRTL.atEnd()) {\n            QString line = verilogRTL.readLine();\n            verilogTxt.append(line + \"\\n\");\n            if (line.startsWith(\");\")) {\n                break;\n            }\n        }\n    }\n    verilogFile.close();\n\n    if (verilogFile.open(QIODevice::WriteOnly)) {\n        verilogRTL << verilogTxt << Qt::endl;\n    }\n    verilogFile.close();\n\n    auto usedInterface = config_->busType;\n\n    if (verilogFile.open(QIODevice::WriteOnly | QIODevice::Append)) {\n\n        switch (usedInterface)\n        {\n        case BusType::AXI4:\n            writeAXI4(verilogRTL);\n            writeAxiAddrMap(verilogRTL);\n            writeAxiXbarCfg(verilogRTL);\n            writeAxiXbar(verilogRTL);\n            break;\n        case BusType::AXI4LITE:\n            writeAXI4LITE(verilogRTL);\n            writeAxiAddrMap(verilogRTL);\n            writeAxiXbarCfg(verilogRTL);\n            writeAxiXbar(verilogRTL);\n            break;\n        case BusType::OBI:\n            writeObiParams(verilogRTL);\n            writeObiInterfaces(verilogRTL);\n            writeObiAddrMap(verilogRTL);\n            writeObiXbar(verilogRTL);\n            break;\n        default:\n            messager_->showMessage(QString(\n                \"*** No RTL generated: Interface type is not supported.\"));\n\n            verilogRTL << Qt::endl;\n            verilogRTL << \"// Could not implement the interconnect: unknown interface type\" << Qt::endl;\n\n            return;\n        }\n\n        verilogRTL << commentWriter(\"Signal assignments\") << \"\\n\";\n        writeTargetAssign(verilogRTL);\n        writeInitAssign(verilogRTL);\n        removeEndmodule(verilogFile);\n        verilogRTL << \"endmodule\" << Qt::endl;\n    }\n    \n    verilogFile.close();\n    messager_->showMessage(QString(\"Closed file %1\").arg(verilogDirectory));\n    return;\n}\n\n//-----------------------------------------------------------------------------\n// Function: InterconnectRTLWriter::writeAXI4\n//-----------------------------------------------------------------------------\nvoid InterconnectRTLWriter::writeAXI4(QTextStream& stream) {\n\n    writeAxiParams(stream);\n\n    stream << commentWriter(\"Initiator and target interface(s)\") << \"\\n\";\n\n    auto busTypeStr = ConfigJsonParser::busTypeToStr(config_->busType).toLower();\n\n    if (!config_->targetList.isEmpty()) {\n        stream << indent()  << \"AXI_BUS #(\" << Qt::endl;\n        stream << indent(2) << \".AXI_ID_WIDTH(\" << IdWidthInits_ << \"),\" << Qt::endl;\n        stream << indent(2) << \".AXI_USER_WIDTH(\" << config_->userWidth << \"),      // Adjustable\" << Qt::endl;\n        stream << indent(2) << \".AXI_ADDR_WIDTH(\" << config_->addressWidthParamName << \"),\" << Qt::endl;\n        stream << indent(2) << \".AXI_DATA_WIDTH(\" << config_->dataWidthParamName << \")\" << Qt::endl;\n\n        axiTargetBus_ = busTypeStr + axiTargetBus_;\n        stream << indent() << \") \" << axiTargetBus_;\n        stream << \"[\" << axiTargetParam_ << \"-1:0]();\\n\" << Qt::endl;\n    }\n\n    if (!config_->initList.isEmpty()) {\n        stream << indent()  << \"AXI_BUS #(\" << Qt::endl;\n        stream << indent(2) << \".AXI_ID_WIDTH(\" << IdWidthInits_ << \"),\" << Qt::endl;\n        stream << indent(2) << \".AXI_USER_WIDTH(\" << config_->userWidth << \"),      // Adjustable\" << Qt::endl;\n        stream << indent(2) << \".AXI_ADDR_WIDTH(\" << config_->addressWidthParamName << \"),\" << Qt::endl;\n        stream << indent(2) << \".AXI_DATA_WIDTH(\" << config_->dataWidthParamName << \")\" << Qt::endl;\n\n        axiInitBus_ = busTypeStr + axiInitBus_;\n        stream << indent() << \") \" << axiInitBus_;\n        stream << \"[\" << axiInitParam_ << \"-1:0]();\\n\" << Qt::endl;\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: InterconnectRTLWriter::writeAXI4LITE\n//-----------------------------------------------------------------------------\nvoid InterconnectRTLWriter::writeAXI4LITE(QTextStream& stream) {\n\n    writeAxiParams(stream);\n\n    stream << commentWriter(\"Initiator and target interface(s)\") << \"\\n\";\n    auto busTypeStr = ConfigJsonParser::busTypeToStr(config_->busType).toLower();\n\n    if (!config_->targetList.isEmpty()) {\n        stream << indent()  << \"AXI_LITE #(\"      << Qt::endl;\n        stream << indent(2) << \".AXI_ADDR_WIDTH(\" << config_->addressWidthParamName << \"),\" << Qt::endl;\n        stream << indent(2) << \".AXI_DATA_WIDTH(\" << config_->dataWidthParamName << \")\" << Qt::endl;\n\n        axiTargetBus_ = busTypeStr + axiTargetBus_;\n        stream << \"    ) \" << axiTargetBus_;\n        stream << \" [\" << axiTargetParam_ << \"-1:0]();\\n\" << Qt::endl;\n    }\n\n    if (!config_->initList.isEmpty()) {\n        stream << indent()  << \"AXI_LITE #(\"      << Qt::endl;\n        stream << indent(2) << \".AXI_ADDR_WIDTH(\" << config_->addressWidthParamName << \"),\" << Qt::endl;\n        stream << indent(2) << \".AXI_DATA_WIDTH(\" << config_->dataWidthParamName << \")\" << Qt::endl;\n\n        axiInitBus_ = busTypeStr + axiInitBus_;\n        stream << indent() << \") \" << axiInitBus_;\n        stream << \" [\" << axiInitParam_ << \"-1:0]();\\n\" << Qt::endl;\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: InterconnectRTLWriter::writeAxiParams\n//-----------------------------------------------------------------------------\nvoid InterconnectRTLWriter::writeAxiParams(QTextStream& stream) {\n\n    stream << commentWriter(\"Local parameters\") << \"\\n\";\n\n    stream << indent() << \"localparam \" << axiTargetParam_\n        << \" = \" << config_->targetList.size() << \";\\n\";\n\n    stream << indent() << \"localparam \" << axiInitParam_\n        << \" = \" << config_->initList.size() << \";\\n\";\n    \n    stream << indent() << \"localparam \" << IdWidthInits_ << \" = \";\n        stream << config_->idWidth << \" + \" << \"$clog2(\" << axiTargetParam_ << \");\\n\";\n\n    stream << Qt::endl;\n}\n\n//-----------------------------------------------------------------------------\n// Function: InterconnectRTLWriter::writeAxiAddrMap\n//-----------------------------------------------------------------------------\nvoid InterconnectRTLWriter::writeAxiAddrMap(QTextStream& stream)\n{\n    int targetRegions = 0;\n    for (TargetStruct const& target : config_->targetList) {\n        if (target.addressRegions.length() > 1) {\n            targetRegions += target.addressRegions.length() - 1;\n        }\n    }\n    stream << commentWriter(\"Address mapping\") << \"\\n\";\n\n    stream << indent() << \"localparam \" << addrRulesParam_ << \" = \"\n        << axiTargetParam_ << \" + \" << targetRegions << \";\\n\";\n\n    // parsedAddressWidth should be set to either 32 or 64. Invalid, if neither (i.e. invalid width for AXI)\n    if (config_->parsedAddressWidth == 32 || config_->parsedAddressWidth == 64)\n    {\n        stream << indent() << \"typedef axi_pkg::xbar_rule_\" << config_->parsedAddressWidth\n            << \"_t \" << ruleType_ << \";\\n\" << Qt::endl;\n    }\n    else\n    {\n        // Invalid width marked as X\n        stream << indent() << \"typedef axi_pkg::xbar_rule_X_t \" << ruleType_ << \";\\n\" << Qt::endl;\n    }\n\n    stream << indent() << ruleType_ << \" [\" << addrRulesParam_ << \"-1:0] \"\n        << addrMapXBAR_ << \";\\n\" << Qt::endl;\n    stream << indent() << \"assign \" << addrMapXBAR_ << \" = '{\" << Qt::endl;\n\n    int regionCounter = 0;\n\n    for (TargetStruct const& target : config_->targetList) {\n        for (AddressPair const& addrPair : target.addressRegions) {\n            regionCounter += 1;\n\n            QString startStr = parseAddress(addrPair.start);\n            QString rangeStr = parseAddress(addrPair.end);\n\n            // Add range to target address to get the end address\n            bool startOk, rangeOk;\n\n            uint64_t startValue = startStr.mid(startStr.indexOf('h') + 1).toULongLong(&startOk, 16);\n            uint64_t endValue = rangeStr.mid(startStr.indexOf('h') + 1).toULongLong(&rangeOk, 16);\n\n            // If value can be converted to numeric value, display it\n            if (startOk && rangeOk) {\n                uint64_t sum = startValue + endValue + 1; // start >=, end <\n                rangeStr = /*QString::number(config_->AddressWidth)*/ + \"'h\" + QString::number(sum, 16).toUpper();\n            }\n            else\n            {\n                // If start or range are parameterized, create new expression for end andress using parameterized expression.\n                // Otherwise, if empty, leave it as default (##null## = no value set)\n                if (rangeStr.compare(\"##null##\") != 0 && startStr.compare(\"##null##\") != 0)\n                {\n                    rangeStr = startStr + \"+\" + rangeStr;\n                }\n            }\n            \n            stream << indent(2)\n                << \"'{idx: \" << IdWidthInits_ << \"'('d\" << target.index\n                << \"), start_addr: \" << config_->addressWidthParamName << \"'(\" << startStr\n                << \"), end_addr: \" << config_->addressWidthParamName << \"'(\" << rangeStr << \")\"\n                << ((regionCounter == targetRegions + config_->targetList.size()) ? \"} \" : \"},\")\n                << \" // Target: \" << target.name << \"\\n\";\n        }\n    }\n    stream << indent() << \"};\\n\" << Qt::endl;\n}\n\n//-----------------------------------------------------------------------------\n// Function: InterconnectRTLWriter::writeAxiXbarCfg\n//-----------------------------------------------------------------------------\nvoid InterconnectRTLWriter::writeAxiXbarCfg(QTextStream& stream)\n{\n    stream << commentWriter(\"Crossbar configuration\", \"See definitions in 'axi_pkg.sv'\") << \"\\n\";\n\n    stream << indent()  << \"localparam axi_pkg::xbar_cfg_t \" << axiCfg_ << \" = '{\" << Qt::endl;\n    stream << indent(2) << \"NoSlvPorts:         \" << axiTargetParam_ << \",\" << Qt::endl;\n    stream << indent(2) << \"NoMstPorts:         \" << axiInitParam_ << \",\" << Qt::endl;\n    stream << indent(2) << \"MaxMstTrans:        1,    // Adjustable\" << Qt::endl;\n    stream << indent(2) << \"MaxSlvTrans:        1,    // Adjustable\" << Qt::endl;\n    stream << indent(2) << \"FallThrough:        1'b0, // Adjustable\" << Qt::endl;\n    stream << indent(2) << \"PipelineStages:     0,    // Adjustable\" << Qt::endl;\n    stream << indent(2) << \"LatencyMode:        axi_pkg::CUT_ALL_AX, // Options:\"\n        << \" NO_LATENCY, CUT_SLV_AX, CUT_MST_AX, CUT_ALL_AX, CUT_SLV_PORTS,\"\n        << \" CUT_MST_PORTS, CUT_ALL_PORTS\" << Qt::endl;\n    stream << indent(2) << \"AxiIdWidthSlvPorts: \" << IdWidthInits_ << \",\" << Qt::endl;\n    stream << indent(2) << \"AxiIdUsedSlvPorts:  0,    // Adjustable\" << Qt::endl;\n    stream << indent(2) << \"UniqueIds:          1'b1, // Adjustable\" << Qt::endl;\n    stream << indent(2) << \"AxiAddrWidth:       \" << config_->addressWidthParamName << \",\" << Qt::endl;\n    stream << indent(2) << \"AxiDataWidth:       \" << config_->dataWidthParamName << \",\" << Qt::endl;\n    stream << indent(2) << \"NoAddrRules:        \" << addrRulesParam_ << Qt::endl;\n    stream << indent() << \"};\\n\" << Qt::endl;\n}\n\n//-----------------------------------------------------------------------------\n// Function: InterconnectRTLWriter::witeAxiXbar\n//-----------------------------------------------------------------------------\nvoid InterconnectRTLWriter::writeAxiXbar(QTextStream& stream) {\n\n    if (config_->initList.isEmpty() || config_->targetList.isEmpty()) {\n        return;\n    }\n\n    if (config_->busType == BusType::AXI4) {\n\n        stream << commentWriter(\"Crossbar initialization\", \"See parameter definitions in 'axi_xbar.sv'\") << \"\\n\";\n        axiXbar_ = \"i_axi_xbar\";\n        stream << indent() << \"axi_xbar_intf #(\\n\";\n        stream << indent(2) << \".AXI_USER_WIDTH(\" << config_->userWidth << \"),\\n\";\n\n    }\n    else if (config_->busType == BusType::AXI4LITE) {\n\n        stream << commentWriter(\"Crossbar initialization\", \"See parameter definitions in 'axi_lite_xbar.sv'\") << \"\\n\";\n        axiXbar_ = \"i_axi_lite_xbar\";\n        stream << indent() << \"axi_lite_xbar_intf #(\\n\";\n\n    } else {\n        return;\n    }\n    \n    stream << indent(2) << \".Cfg(\" << axiCfg_ << \"),\\n\";\n    stream << indent(2) << \".rule_t(\" << ruleType_ << \")\\n\";\n    \n    stream << indent() << \") \" << axiXbar_ << \"(\\n\";\n\n    stream << indent(2) << \".clk_i(\" << clkPort_ << \"),\\n\";\n    stream << indent(2) << \".rst_ni(\" << rstPort_ << \"),\\n\";\n    stream << indent(2) << \".test_i(1'b0),               // Adjustable\\n\";\n    stream << indent(2) << \".slv_ports(\" << axiInitBus_ << \"),\\n\";\n    stream << indent(2) << \".mst_ports(\" << axiTargetBus_ << \"),\\n\";\n    stream << indent(2) << \".addr_map_i(\" << addrMapXBAR_ << \"),\\n\";\n    stream << indent(2) << \".en_default_mst_port_i('0),  // Adjustable\\n\";\n    stream << indent(2) << \".default_mst_port_i('0)      // Adjustable\\n\";\n    stream << indent() << \");\\n\" << Qt::endl;\n}\n\n//-----------------------------------------------------------------------------\n// Function: InterconnectRTLWriter::writeSignalAssignments\n//-----------------------------------------------------------------------------\nvoid InterconnectRTLWriter::writeSignalAssignments(QTextStream& stream, QString busName, int index, bool isInit) {\n\n    if (!component_) {\n        return;\n    }\n\n    stream << indent() << \"// Interface: \" << busName << '\\n' << Qt::endl;\n\n    QString targetBus;\n    QString initBus;\n\n    auto busType = config_->busType;\n\n    // Check which bus type is used and set the correct port list and bus names\n    QStringList ports = (busType == BusType::AXI4) ? axiPorts_ : axiLitePorts_;\n    if (busType == BusType::OBI) {\n        ports = obiPorts_;\n        targetBus = obiTargetInterface_;\n        initBus = obiInitInterface_;\n    } else {\n        targetBus = axiTargetBus_;\n        initBus = axiInitBus_;\n    }\n\n    // Assign input ports first\n    for (QSharedPointer<Port> compPort : component_->getPortsMappedInInterface(busName)) {\n\n        if (!compPort) {\n            continue;\n        }\n\n        for (QString const& port : ports) {\n            if (compPort->getDirection() != DirectionTypes::IN &&\n                (compPort->name().endsWith(\"_\" + port) ||\n                 compPort->name().endsWith(\"_\" + port + \"_in\")  ||\n                 compPort->name().endsWith(\"_\" + port + \"_out\") ||\n                 compPort->name().endsWith(\"_\" + port + \"_i\")   ||\n                 compPort->name().endsWith(\"_\" + port + \"_o\"))) {\n\n                if (isInit) {\n                    stream << indent() << \"assign \" << initBus << \"[\" << index << \"].\" << port;\n                    stream << \" = \" << compPort->name() << \";\" << Qt::endl;\n                } else {\n                    stream << indent() << \"assign \" << compPort->name();\n                    stream << \" = \" << targetBus << \"[\" << index << \"].\" << port << \";\" << Qt::endl;\n                }\n            }\n        }\n    }\n\n    // Then assign other ports\n    for (QSharedPointer<Port> compPort : component_->getPortsMappedInInterface(busName)) {\n\n        if (!compPort) {\n            return;\n        }\n\n        for (QString port : ports) {\n            if (compPort->getDirection() == DirectionTypes::IN &&\n                (compPort->name().endsWith(\"_\" + port) ||\n                 compPort->name().endsWith(\"_\" + port + \"_in\")  ||\n                 compPort->name().endsWith(\"_\" + port + \"_out\") ||\n                 compPort->name().endsWith(\"_\" + port + \"_i\")   ||\n                 compPort->name().endsWith(\"_\" + port + \"_o\"))) {\n\n                if (isInit) {\n                    stream << indent() << \"assign \" << compPort->name();\n                    stream << \" = \" << initBus << \"[\" << index << \"].\" << port << \";\\n\";\n                } else {\n                    stream << indent() << \"assign \" << targetBus << \"[\" << index << \"].\" << port;\n                    stream << \" = \" << compPort->name() << \";\\n\";\n                }\n            }\n        }\n    }\n    stream << Qt::endl;\n}\n\n//-----------------------------------------------------------------------------\n// Function: InterconnectRTLWriter::writeTargetAssign\n//-----------------------------------------------------------------------------\nvoid InterconnectRTLWriter::writeTargetAssign(QTextStream& stream) {\n\n    if (config_->targetList.isEmpty()) return;\n\n    for (const TargetStruct& target : config_->targetList) {\n        writeSignalAssignments(stream, target.name, target.index, false);\n        //stream << Qt::endl;\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: InterconnectRTLWriter::writeInitAssign\n//-----------------------------------------------------------------------------\nvoid InterconnectRTLWriter::writeInitAssign(QTextStream& stream) {\n\n    if (config_->initList.isEmpty()) return;\n\n    for (const InitStruct& init : config_->initList) {\n        writeSignalAssignments(stream, init.name, init.index, true);\n        //stream << Qt::endl;\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: InterconnectRTLWriter::writeObiParams\n//-----------------------------------------------------------------------------\nvoid InterconnectRTLWriter::writeObiParams(QTextStream& stream) {\n    \n    stream << commentWriter(\"Local parameters\") << \"\\n\";\n\n    stream << indent() << \"localparam \" << obiInitParam_\n        << \" = \" << config_->initList.size() << \";\\n\";\n\n    stream << indent() << \"localparam \" << obiTargetParam_\n        << \" = \" << config_->targetList.size() << \";\\n\";\n\n    stream << \"\\n\";\n    \n    stream << indent() << \"localparam \" << IdWidthInits_ << \" = \";\n        stream << config_->idWidth << \" + \" << \"$clog2(\" << obiTargetParam_ << \");\\n\";\n\n    stream << indent() << \"localparam \" << addrRulesParam_\n        << \" = \" << obiTargetParam_ << \";\\n\";\n\n    stream << \"\\n\";\n\n    //stream << indent()  << \"localparam obi_pkg::obi_optional_cfg_t obi_cfg = obi_pkg::obi_all_optional_config(\\n\";\n    stream << indent()  << \"localparam obi_pkg::obi_cfg_t obi_cfg = obi_pkg::obi_default_cfg(\\n\";\n    \n    // Print parameters of the configure struct\n    for (int i = 0; i < obiXbarCfgParams_.size(); ++i) {\n        const QString& param = obiXbarCfgParams_[i];\n        bool isLast = (i == obiXbarCfgParams_.size() - 1);\n        stream << indent(2) << param;\n        if (!isLast)\n            stream << \",\";\n        stream << \"\\n\";\n    }\n    stream << indent() << \");\\n\" << Qt::endl;\n}\n\n//-----------------------------------------------------------------------------\n// Function: InterconnectRTLWriter::writeObiInterfaces\n//-----------------------------------------------------------------------------\nvoid InterconnectRTLWriter::writeObiInterfaces(QTextStream& stream) {\n\n    stream << commentWriter(\"Initiator and target interface(s)\") << \"\\n\";\n\n    if (!config_->initList.isEmpty()) {\n        stream << indent()  << \"OBI_BUS #(\\n\";\n        stream << indent(2) << \".OBI_CFG(obi_cfg)\\n\";\n\n        if (config_->initList.size() == 1) {\n            stream << indent()  << \") \" << obiInitInterface_ << \" [(\" << obiInitParam_\n                << \"+1)-1:0](); // NOTE: Extra interface due to known single initiator issue\\n\" << Qt::endl;\n        } else {\n            stream << indent()  << \") \" << obiInitInterface_ << \" [\" << obiInitParam_ << \"-1:0]();\\n\" << Qt::endl;\n        }\n    }\n\n    if (!config_->targetList.isEmpty()) {\n        stream << indent()  << \"OBI_BUS #(\\n\";\n        stream << indent(2) << \".OBI_CFG(obi_cfg)\\n\";\n        stream << indent()  << \") \" << obiTargetInterface_ << \" [\" << obiTargetParam_ << \"-1:0]();\\n\" << Qt::endl;\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: InterconnectRTLWriter::writeObiAddrMap\n//-----------------------------------------------------------------------------\nvoid InterconnectRTLWriter::writeObiAddrMap(QTextStream& stream) {\n\n    stream << commentWriter(\"Address mapping\") << \"\\n\";\n\n    int targetRegions = 0;\n    for (TargetStruct const& target : config_->targetList) {\n        if (target.addressRegions.length() > 1) {\n            targetRegions += target.addressRegions.length() - 1;\n        }\n    }\n\n    stream << indent() << \"typedef struct packed {\\n\";\n    stream << indent(2) << \"int unsigned idx;\\n\";\n    stream << indent(2) << \"logic [\" << config_->addressWidthParamName << \"-1:0] start_addr;\\n\";\n    stream << indent(2) << \"logic [\" << config_->addressWidthParamName << \"-1:0] end_addr;\\n\";\n    stream << indent() << \"} \" << obiAddrRule_ << \" ;\\n\" << Qt::endl;\n\n    stream << indent() << obiAddrRule_ << \" \" << addrMapXBAR_ << \" [\" << addrRulesParam_ << \"] = '{\\n\";\n\n    int regionCounter = 0;\n\n    for (TargetStruct const& target : config_->targetList) {\n        for (AddressPair const& addrPair : target.addressRegions) {\n            regionCounter += 1;\n\n            QString startStr = parseAddress(addrPair.start);\n            QString rangeStr = parseAddress(addrPair.end);\n\n            // Add range to target address to get the end address\n            bool startOk, rangeOk;\n\n            uint64_t startValue = startStr.mid(startStr.indexOf('h') + 1).toULongLong(&startOk, 16);\n            uint64_t endValue = rangeStr.mid(startStr.indexOf('h') + 1).toULongLong(&rangeOk, 16);\n\n            if (startOk && rangeOk) {\n                uint64_t sum = startValue + endValue + 1; // start >=, end <\n                rangeStr = \"'h\" + QString::number(sum, 16).toUpper();\n            }\n\n            stream << indent(2)\n                << \"'{idx: \" << IdWidthInits_ << \"'('d\" << target.index << \"),\"\n                //<< \"start_addr: \" << config_->addressWidthParamName << \"'(\" << startStr << \"), \"  // No need to state width explicitly\n                //<< \"end_addr: \" << config_->addressWidthParamName << \"'(\" << rangeStr << \")\"\n                << \"start_addr: \" << startStr << \"), \"\n                << \"end_addr: \" << rangeStr << \")\"\n                << ((regionCounter == targetRegions + config_->targetList.size()) ? \"} \" : \"},\")\n                << \" // Target: \" << target.name << \"\\n\";\n        }\n    }\n    stream << indent() << \"};\\n\" << Qt::endl;\n}\n\n//-----------------------------------------------------------------------------\n// Function: InterconnectRTLWriter::writeObiXbar\n//-----------------------------------------------------------------------------\nvoid InterconnectRTLWriter::writeObiXbar(QTextStream& stream) {\n\n    stream << commentWriter(\"Crossbar initialization\", \"See parameter definitions in 'obi_xbar.sv'\") << \"\\n\";\n\n    stream << indent() << \"obi_xbar_intf #(\\n\";\n    stream << indent(2) << \".NumSbrPorts       (\" << obiInitParam_ << \"),\\n\";\n    stream << indent(2) << \".NumMgrPorts       (\" << obiTargetParam_ << \"),\\n\";\n    stream << indent(2) << \".NumMaxTrans       (1),          // Adjustable\\n\";\n    stream << indent(2) << \".NumAddrRules      (\" << addrRulesParam_ << \"),\\n\";\n    stream << indent(2) << \".addr_map_rule_t   (\" << obiAddrRule_ << \"),\\n\";\n    stream << indent(2) << \".UseIdForRouting   (0)           // Adjustable\\n\";\n    stream << indent() << \") i_obi_xbar (\\n\";\n    stream << indent(2) << \".clk_i             (\" << clkPort_ << \"),\\n\";\n    stream << indent(2) << \".rst_ni            (\" << rstPort_ << \"),\\n\";\n    stream << indent(2) << \".testmode_i        (1'b0),       // Adjustable\\n\";\n    stream << indent(2) << \".sbr_ports         (\" << obiInitInterface_ << \"),\\n\";\n    stream << indent(2) << \".mgr_ports         (\" << obiTargetInterface_ << \"),\\n\";\n    stream << indent(2) << \".addr_map_i        (\" << addrMapXBAR_ << \"),\\n\";\n    stream << indent(2) << \".en_default_idx_i  ('0),         // Adjustable\\n\";\n    stream << indent(2) << \".default_idx_i     ('0)          // Adjustable\\n\";\n    stream << indent() << \");\\n\" << Qt::endl;\n}\n\n//-----------------------------------------------------------------------------\n// Function: InterconnectRTLWriter::writeEndmodule\n//-----------------------------------------------------------------------------\nvoid InterconnectRTLWriter::removeEndmodule(QFile& file) {\n\n    if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) {\n        return;\n    }\n\n    QString newContent;\n    QTextStream in(&file);\n\n    while (!in.atEnd()) {\n        QString line = in.readLine();\n        if (line.trimmed() != \"endmodule\") {\n            newContent.append(line + '\\n');\n        }\n    }\n    file.close();\n\n    if (!file.open(QIODevice::WriteOnly | QIODevice::Truncate | QIODevice::Text)) {\n        return;\n    }\n\n    QTextStream out(&file);\n    out << newContent;\n\n    file.close();\n}\n\n//-----------------------------------------------------------------------------\n// Function: InterconnectRTLWriter::indent\n//-----------------------------------------------------------------------------\nQString InterconnectRTLWriter::indent(int n) {\n\n    return QString(n * 4, ' ');\n}\n\n//-----------------------------------------------------------------------------\n// Function: InterconnectRTLWriter::parseAddress\n//-----------------------------------------------------------------------------\nQString InterconnectRTLWriter::parseAddress(QString original) {\n\n    QString parsed = original.trimmed();\n\n    if (parsed.isEmpty()) {\n        return parsed;\n    }\n\n    // Checks if the given address is in hexadecimal, binary, or decimal format.\n    // Attempts to convert it to hexadecimal before returning.\n    // Otherwise, returns the trimmed original QString\n    if (parsed.contains(\"'h\", Qt::CaseInsensitive)) {\n\n        int index = parsed.indexOf(\"'h\", Qt::CaseInsensitive);\n        parsed = parsed.mid(index + 2).trimmed();\n        return /*QString::number(config_->AddressWidth)*/ + \"'h\" + parsed.toUpper();\n    }\n\n    else if (parsed.startsWith(\"0x\", Qt::CaseInsensitive)) {\n\n        parsed = parsed.mid(2);\n        return /*QString::number(config_->AddressWidth)*/ + \"'h\" + parsed.toUpper();\n    }\n    \n    else if (parsed.contains(\"'b\", Qt::CaseInsensitive)) {\n\n        int index = parsed.indexOf(\"'b\", Qt::CaseInsensitive);\n        parsed = parsed.mid(index + 2).trimmed();\n\n        bool ok;\n        uint64_t temp = parsed.toULongLong(&ok, 2);\n        \n        if (ok) {\n            parsed = /*QString::number(config_->AddressWidth) +*/ \"'h\" + QString::number(temp, 16).toUpper();\n            return parsed;\n        } else {\n            return parsed;\n        }\n    }\n\n    else if (parsed.startsWith(\"0b\", Qt::CaseInsensitive)) {\n\n        parsed = parsed.mid(2);\n\n        bool ok;\n        uint64_t temp = parsed.toULongLong(&ok, 2);\n        \n        if (ok) {\n            parsed = /*QString::number(config_->AddressWidth) +*/ \"'h\" + QString::number(temp, 16).toUpper();\n            return parsed;\n        } else {\n            return parsed;\n        }\n    }\n\n    bool isDecimal;\n    uint64_t dec = parsed.toULongLong(&isDecimal, 10);\n    if (isDecimal) {\n        parsed = /*QString::number(config_->AddressWidth) +*/ \"'h\" + QString::number(dec, 16).toUpper();\n        return parsed;\n    }\n    \n    return parsed;\n}\n\n//-----------------------------------------------------------------------------\n// Function: InterconnectRTLWriter::commentWriter\n//-----------------------------------------------------------------------------\nQString InterconnectRTLWriter::commentWriter(QString title, QString subtitle) {\n\n    QString comment = \"\\n//---------------------------------------------------\\n\"\n                        \"// \" + title + \"\\n\";\n\n    if (!subtitle.isEmpty()) {\n        comment +=      \"// \\n// \" + indent() + \"- \" + subtitle + \"\\n\";\n    }\n\n    comment +=          \"//---------------------------------------------------\\n\";\n    return comment;\n}"
  },
  {
    "path": "KactusAPI/plugins/PluginManager.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: PluginManager.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Joni-Matti Maatta\r\n// Date: 27.6.2012\r\n//\r\n// Description:\r\n// Plugin manager which manages loaded plugins.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"PluginManager.h\"\r\n\r\n#include \"IPlugin.h\"\r\n\r\n#include <IPXACTmodels/utilities/XmlUtils.h>\r\n\r\n#include <QCoreApplication>\r\n#include <QDir>\r\n#include <QPluginLoader>\r\n\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PluginManager::addPlugin()\r\n//-----------------------------------------------------------------------------\r\nvoid PluginManager::addPlugin(IPlugin* plugin)\r\n{\r\n    plugins_.append(plugin);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PluginManager::getPlugins()\r\n//-----------------------------------------------------------------------------\r\nQList<IPlugin*> PluginManager::getAllPlugins() const\r\n{\r\n    return plugins_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PluginManager::getActivePlugins()\r\n//-----------------------------------------------------------------------------\r\nQList<IPlugin*> PluginManager::getActivePlugins() const\r\n{\r\n    QSettings settings;\r\n    QList<IPlugin*> activePlugins;\r\n\r\n    for (IPlugin* plugin : plugins_)\r\n    {\r\n        if (settings.value(QStringLiteral(\"PluginSettings/\") + XmlUtils::removeWhiteSpace(plugin->getName()) + \r\n            QStringLiteral(\"/Active\"), true).toBool())\r\n        {\r\n            activePlugins.append(plugin);\r\n        }\r\n    }\r\n\r\n    return activePlugins;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PluginManager::setPluginPaths()\r\n//-----------------------------------------------------------------------------\r\nvoid PluginManager::setPluginPaths(QStringList const& pluginPaths)\r\n{\r\n    plugins_.clear();\r\n    plugins_ = findPluginsInPaths(pluginPaths);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PluginManager::findPluginsInPaths()\r\n//-----------------------------------------------------------------------------\r\nQList<IPlugin*> PluginManager::findPluginsInPaths(QStringList const& pluginPaths)\r\n{\r\n    QList<IPlugin*> plugins;\r\n\r\n    QSettings settings;\r\n    settings.beginGroup(QStringLiteral(\"PluginSettings\"));\r\n\r\n    for (QString const& dirName : pluginPaths)\r\n    {\r\n        QDir pluginDirectory(dirName);\r\n        if (pluginDirectory.isRelative())\r\n        {\r\n            pluginDirectory.setPath(QCoreApplication::applicationDirPath() + QLatin1Char('/') + dirName);\r\n        }        \r\n\r\n        for (QFileInfo const& fileInfo : pluginDirectory.entryInfoList(QDir::Files))\r\n        {\r\n            QPluginLoader loader(fileInfo.absoluteFilePath());\r\n            IPlugin* plugin = qobject_cast<IPlugin*>(loader.instance());\r\n\r\n            if (plugin != 0 && isUnique(plugin, plugins))\r\n            {\r\n                plugins.append(plugin);\r\n\r\n                settings.beginGroup(XmlUtils::removeWhiteSpace(plugin->getName()));\r\n                if (plugin->getSettingsModel())\r\n                {\r\n                    plugin->getSettingsModel()->loadSettings(settings);\r\n                }\r\n                settings.endGroup();\r\n            }\r\n        }\r\n    }\r\n\r\n    settings.endGroup();\r\n\r\n    return plugins;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PluginManager::isUnique()\r\n//-----------------------------------------------------------------------------\r\nbool PluginManager::isUnique(IPlugin* plugin, QList<IPlugin*> const& plugins)\r\n{\r\n    for (IPlugin* knownPlugin : plugins)\r\n    {\r\n        if (QString::compare(knownPlugin->getName(), plugin->getName()) == 0 && \r\n            QString::compare(knownPlugin->getVersion(), plugin->getVersion()) == 0)\r\n        {\r\n            return false;            \r\n        }\r\n    }\r\n\r\n    return true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PluginManager::getInstance()\r\n//-----------------------------------------------------------------------------\r\nPluginManager& PluginManager::getInstance()\r\n{\r\n    static PluginManager instance;\r\n    return instance;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PluginManager::PluginManager()\r\n//-----------------------------------------------------------------------------\r\nPluginManager::PluginManager(): plugins_()\r\n{\r\n    \r\n}\r\n"
  },
  {
    "path": "KactusAPI/plugins/PluginUtilityAdapter.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: PluginUtilityAdapter.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Esko Pekkarinen\r\n// Date: 7.7.2014\r\n//\r\n// Description:\r\n// Generic utility for passing parent window and library interface for generator plugins.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"PluginUtilityAdapter.h\"\r\n\r\n#include <KactusAPI/include/MessageMediator.h>\r\n\r\n#include <KactusAPI/include/LibraryInterface.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PluginUtilityAdapter::PluginUtilityAdapter()\r\n//-----------------------------------------------------------------------------\r\nPluginUtilityAdapter::PluginUtilityAdapter(LibraryInterface* libraryInterface, MessageMediator* messageChannel,\r\n    QString const& versionString, QWidget* parentWidget) :\r\nlibraryInterface_(libraryInterface),\r\n    messageChannel_(messageChannel),\r\n    parentWidget_(parentWidget),\r\n    versionString_(versionString)\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PluginUtilityAdapter::printError()\r\n//-----------------------------------------------------------------------------\r\nvoid PluginUtilityAdapter::printError(QString const& message)\r\n{\r\n    messageChannel_->showError(message);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PluginUtilityAdapter::printInfo()\r\n//-----------------------------------------------------------------------------\r\nvoid PluginUtilityAdapter::printInfo(QString const& message)\r\n{\r\n    messageChannel_->showMessage(message);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PluginUtilityAdapter::getLibraryInterface()\r\n//-----------------------------------------------------------------------------\r\nLibraryInterface* PluginUtilityAdapter::getLibraryInterface()\r\n{\r\n    return libraryInterface_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PluginUtilityAdapter::getParentWidget()\r\n//-----------------------------------------------------------------------------\r\nQWidget* PluginUtilityAdapter::getParentWidget()\r\n{\r\n    return parentWidget_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PluginUtilityAdapter::getKactusVersion()\r\n//-----------------------------------------------------------------------------\r\nQString PluginUtilityAdapter::getKactusVersion() const\r\n{\r\n\treturn versionString_;\r\n}"
  },
  {
    "path": "KactusAPI/utilities/ConsoleMediator.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: ConsoleMediator.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Esko Pekkarinen\n// Date: 13.02.2018\n//\n// Description:\n// Console output for user messages.\n//-----------------------------------------------------------------------------\n\n#include <KactusAPI/include/ConsoleMediator.h>\n\n#include <iostream>\n\n#include <QTextStream>\n\n\n//-----------------------------------------------------------------------------\n// Function: ConsoleMediator::showMessage()\n//-----------------------------------------------------------------------------\nvoid ConsoleMediator::showMessage(QString const& message) const\n{\n    static QTextStream out(stdout); \n    out << message << Qt::endl;\n}\n\n//-----------------------------------------------------------------------------\n// Function: ConsoleMediator::showError()\n//-----------------------------------------------------------------------------\nvoid ConsoleMediator::showError(QString const& error) const\n{\n    static QTextStream err(stderr);\n    err << error << Qt::endl;\n}\n\n//-----------------------------------------------------------------------------\n// Function: ConsoleMediator::showFailure()\n//-----------------------------------------------------------------------------\nvoid ConsoleMediator::showFailure(QString const& error) const\n{\n    showError(error);\n}\n\n//-----------------------------------------------------------------------------\n// Function: ConsoleMediator::showStatusMessage()\n//-----------------------------------------------------------------------------\nvoid ConsoleMediator::showStatusMessage(QString const& status) const\n{\n    showMessage(status);\n}\n"
  },
  {
    "path": "KactusAPI/utilities/FileHandler.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: FileHandler.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 08.10.2019\n//\n// Description:\n// Handles data regarding files.\n//-----------------------------------------------------------------------------\n\n#include \"FileHandler.h\"\n\n#include <IPXACTmodels/generaldeclarations.h>\n\n#include <QFileInfo>\n#include <QProcessEnvironment>\n#include <QRegularExpression>\n#include <QSettings>\n#include <QDir>\n\n//-----------------------------------------------------------------------------\n// Function: FileHandler::constructFileSuffixTable()\n//-----------------------------------------------------------------------------\nQMultiMap<QString, QString> FileHandler::constructFileSuffixTable()\n{\n    QMultiMap<QString, QString> fileSuffixTable;\n\n    QSettings settings;\n    settings.beginGroup(QStringLiteral(\"FileTypes\"));\n    for (QString const& fileType : settings.childGroups())\n    {\n        settings.beginGroup(fileType);\n\n        QStringList fileTypeExtensions = settings.value(QStringLiteral(\"Extensions\")).toString().split(QLatin1Char(';'));\n        for (QString const& extension : fileTypeExtensions)\n        {\n            fileSuffixTable.insert(extension, fileType);\n        }\n        settings.endGroup();\n    }\n\n    settings.endGroup();\n\n    return fileSuffixTable;\n}\n\n//-----------------------------------------------------------------------------\n// Function: FileHandler::getFileTypeForSuffix()\n//-----------------------------------------------------------------------------\nQString FileHandler::getFileTypeForSuffix(QMultiMap<QString, QString> const& fileSuffixTable, QString const& suffix)\n{\n    QMultiMapIterator<QString, QString> tableIterator(fileSuffixTable);\n    while (tableIterator.hasNext())\n    {\n        tableIterator.next();\n\n        if (tableIterator.key() == suffix)\n        {\n            return tableIterator.value();\n        }\n    }\n\n    return QString();\n}\n\n\n//-----------------------------------------------------------------------------\n// Function: FilesModel::resolvePath()\n//-----------------------------------------------------------------------------\nQString FileHandler::resolvePath(QString const& ipxactURI)\n{\n    auto resolvedURI = resolveURI(ipxactURI);\n\n    QFileInfo fileInfo(resolvedURI);\n    return fileInfo.filePath();\n}\n\n//-----------------------------------------------------------------------------\n// Function: FilesModel::resolveURI()\n//-----------------------------------------------------------------------------\nQString FileHandler::resolveURI(QString const& ipxactURI)\n{\n    auto resolvedURI = ipxactURI;\n\n    QRegularExpression envVariable(\"[$]{([^}]*)}\");\n\n    auto matchIterator = envVariable.globalMatch(resolvedURI);\n    while (matchIterator.hasNext())\n    {\n        auto match = matchIterator.next();\n        auto variableName = match.captured(1);\n        auto value = QProcessEnvironment::systemEnvironment().value(variableName);\n\n        resolvedURI.replace(match.captured(0), value);\n    }\n\n    return resolvedURI;\n}\n\n//-----------------------------------------------------------------------------\n// Function: FilesModel::isValidURI()\n//-----------------------------------------------------------------------------\nbool FileHandler::isValidURI(QString const& relativeTo, QString const& ipxactURI)\n{\n    auto resolvedURI = resolveURI(ipxactURI);\n\n    return filePathExists(relativeTo, resolvedURI) || isURI(resolvedURI);\n}\n\n//-----------------------------------------------------------------------------\n// Function: FileHandler::filePathExists()\n//-----------------------------------------------------------------------------\nbool FileHandler::filePathExists(QString const& relativeTo, QString const& filePath)\n{\n    if (filePath.isEmpty())\n    {\n        return false;\n    }\n\n    QString absFilePath = General::getAbsolutePath(relativeTo, filePath);\n\n    QFileInfo fileInfo(absFilePath);\n\n    return fileInfo.exists();\n}\n\n//-----------------------------------------------------------------------------\n// Function: FileHandler::isURI()\n//-----------------------------------------------------------------------------\nbool FileHandler::isURI(QString const& uri)\n{\n    return URL_VALIDITY_REG_EXP.match(uri).hasMatch();\n}\n\n//-----------------------------------------------------------------------------\n// Function: FileHandler::getModifiedPathWithExtension()\n//-----------------------------------------------------------------------------\nKACTUS2_API QString FileHandler::getModifiedPathWithExtension(QString const& filePath, QString const& extension)\n{\n\tauto nativeFilePath = QDir::toNativeSeparators(filePath);\n\tauto nativeSeparator = QDir::separator();\n\n\tif (auto lastSeparatorIndex = nativeFilePath.lastIndexOf(nativeSeparator); lastSeparatorIndex > 0)\n\t{\n\t\tauto fileName = nativeFilePath.last(nativeFilePath.size() - (lastSeparatorIndex + 1));\n        fileName.append(\".\" + extension);\n\n\t\tnativeFilePath = nativeFilePath.left(lastSeparatorIndex + 1);\n\t\tnativeFilePath.append(fileName);\n\t}\n\n    return nativeFilePath;\n}\n"
  },
  {
    "path": "KactusAPI/utilities/NullChannel.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: NullChannel.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Esko Pekkarinen\n// Date: 09.11.2023\n//\n// Description:\n// Null output for user messages.\n//-----------------------------------------------------------------------------\n\n#include <KactusAPI/include/NullChannel.h>\n\n//-----------------------------------------------------------------------------\n// Function: NullChannel::showMessage()\n//-----------------------------------------------------------------------------\nvoid NullChannel::showMessage(QString const& /*message*/) const\n{\n    // Do nothing.\n}\n\n//-----------------------------------------------------------------------------\n// Function: NullChannel::showError()\n//-----------------------------------------------------------------------------\nvoid NullChannel::showError(QString const& /*error*/) const\n{\n    // Do nothing.\n}\n\n//-----------------------------------------------------------------------------\n// Function: NullChannel::showFailure()\n//-----------------------------------------------------------------------------\nvoid NullChannel::showFailure(QString const& /*error*/) const\n{\n    // Do nothing.\n}\n\n//-----------------------------------------------------------------------------\n// Function: NullChannel::showStatusMessage()\n//-----------------------------------------------------------------------------\nvoid NullChannel::showStatusMessage(QString const& /*status*/) const\n{\n    // Do nothing.\n}\n"
  },
  {
    "path": "KactusAPI/utilities/VersionHelper.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: VersionHelper.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Janne Virtanen\r\n// Date: 31.8.2016\r\n//\r\n// Description:\r\n// A module that returns variations of version number as QStrings.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include <version.h>\r\n#include <KactusAPI/include/VersionHelper.h>\r\n\r\n// Used to convert defined values to string.\r\n// Double stringize is required to expand possible macros in str.\r\n#define DOUBLE_STR(x) #x\r\n#define TOSTRING(str) DOUBLE_STR(str)\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VersionHelper::createVersionString()\r\n//-----------------------------------------------------------------------------\r\nQString VersionHelper::createVersionString()\r\n{\r\n#if defined (_WIN64) || (__LP64__) || (_LP64)\r\n    int bits = 64;\r\n#else\r\n    int bits = 32;\r\n#endif\r\n\r\n    return QStringLiteral(\"%1.%2.%3 %4-bit\").arg(QString::number(VERSION_MAJOR),\r\n        QString::number(VERSION_MINOR),\r\n        QString::number(VERSION_BUILDNO),\r\n        QString::number(bits));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VersionHelper::versionFull()\r\n//-----------------------------------------------------------------------------\r\nQString VersionHelper::versionFull()\r\n{\r\n    return QStringLiteral(TOSTRING(VERSION_FULL));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VersionHelper::versionFileStr()\r\n//-----------------------------------------------------------------------------\r\nQString VersionHelper::versionFileStr()\r\n{\r\n    return QStringLiteral(VERSION_FILESTR);\r\n}\r\n"
  },
  {
    "path": "KactusAPI/utilities/utils.cpp",
    "content": "/* \r\n *\r\n *  Created on: 7.2.2011\r\n *      Author: Antti Kamppi\r\n *         filename: utils.cpp\r\n *         \r\n *         Description: This file contains definitions for general purpose \r\n *         functions that can be used in the whole software.\r\n */\r\n\r\n#include \"utils.h\"\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Utils::getCurrentUser()\r\n//-----------------------------------------------------------------------------\r\nQString Utils::getCurrentUser()\r\n{\r\n#ifdef Q_OS_WIN\r\n#pragma warning (disable: 4996)\r\n    return getenv(\"USERNAME\");\r\n#pragma warning (default: 4996)\r\n#else\r\n    return getenv(\"USER\");\r\n#endif\r\n}\r\n"
  },
  {
    "path": "LICENSE",
    "content": "                   GNU GENERAL PUBLIC LICENSE\r\n                       Version 2, June 1991\r\n\r\n Copyright (C) 1989, 1991 Free Software Foundation, Inc.,\r\n 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA\r\n Everyone is permitted to copy and distribute verbatim copies\r\n of this license document, but changing it is not allowed.\r\n\r\n                            Preamble\r\n\r\n  The licenses for most software are designed to take away your\r\nfreedom to share and change it.  By contrast, the GNU General Public\r\nLicense is intended to guarantee your freedom to share and change free\r\nsoftware--to make sure the software is free for all its users.  This\r\nGeneral Public License applies to most of the Free Software\r\nFoundation's software and to any other program whose authors commit to\r\nusing it.  (Some other Free Software Foundation software is covered by\r\nthe GNU Lesser General Public License instead.)  You can apply it to\r\nyour programs, too.\r\n\r\n  When we speak of free software, we are referring to freedom, not\r\nprice.  Our General Public Licenses are designed to make sure that you\r\nhave the freedom to distribute copies of free software (and charge for\r\nthis service if you wish), that you receive source code or can get it\r\nif you want it, that you can change the software or use pieces of it\r\nin new free programs; and that you know you can do these things.\r\n\r\n  To protect your rights, we need to make restrictions that forbid\r\nanyone to deny you these rights or to ask you to surrender the rights.\r\nThese restrictions translate to certain responsibilities for you if you\r\ndistribute copies of the software, or if you modify it.\r\n\r\n  For example, if you distribute copies of such a program, whether\r\ngratis or for a fee, you must give the recipients all the rights that\r\nyou have.  You must make sure that they, too, receive or can get the\r\nsource code.  And you must show them these terms so they know their\r\nrights.\r\n\r\n  We protect your rights with two steps: (1) copyright the software, and\r\n(2) offer you this license which gives you legal permission to copy,\r\ndistribute and/or modify the software.\r\n\r\n  Also, for each author's protection and ours, we want to make certain\r\nthat everyone understands that there is no warranty for this free\r\nsoftware.  If the software is modified by someone else and passed on, we\r\nwant its recipients to know that what they have is not the original, so\r\nthat any problems introduced by others will not reflect on the original\r\nauthors' reputations.\r\n\r\n  Finally, any free program is threatened constantly by software\r\npatents.  We wish to avoid the danger that redistributors of a free\r\nprogram will individually obtain patent licenses, in effect making the\r\nprogram proprietary.  To prevent this, we have made it clear that any\r\npatent must be licensed for everyone's free use or not licensed at all.\r\n\r\n  The precise terms and conditions for copying, distribution and\r\nmodification follow.\r\n\r\n                    GNU GENERAL PUBLIC LICENSE\r\n   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION\r\n\r\n  0. This License applies to any program or other work which contains\r\na notice placed by the copyright holder saying it may be distributed\r\nunder the terms of this General Public License.  The \"Program\", below,\r\nrefers to any such program or work, and a \"work based on the Program\"\r\nmeans either the Program or any derivative work under copyright law:\r\nthat is to say, a work containing the Program or a portion of it,\r\neither verbatim or with modifications and/or translated into another\r\nlanguage.  (Hereinafter, translation is included without limitation in\r\nthe term \"modification\".)  Each licensee is addressed as \"you\".\r\n\r\nActivities other than copying, distribution and modification are not\r\ncovered by this License; they are outside its scope.  The act of\r\nrunning the Program is not restricted, and the output from the Program\r\nis covered only if its contents constitute a work based on the\r\nProgram (independent of having been made by running the Program).\r\nWhether that is true depends on what the Program does.\r\n\r\n  1. You may copy and distribute verbatim copies of the Program's\r\nsource code as you receive it, in any medium, provided that you\r\nconspicuously and appropriately publish on each copy an appropriate\r\ncopyright notice and disclaimer of warranty; keep intact all the\r\nnotices that refer to this License and to the absence of any warranty;\r\nand give any other recipients of the Program a copy of this License\r\nalong with the Program.\r\n\r\nYou may charge a fee for the physical act of transferring a copy, and\r\nyou may at your option offer warranty protection in exchange for a fee.\r\n\r\n  2. You may modify your copy or copies of the Program or any portion\r\nof it, thus forming a work based on the Program, and copy and\r\ndistribute such modifications or work under the terms of Section 1\r\nabove, provided that you also meet all of these conditions:\r\n\r\n    a) You must cause the modified files to carry prominent notices\r\n    stating that you changed the files and the date of any change.\r\n\r\n    b) You must cause any work that you distribute or publish, that in\r\n    whole or in part contains or is derived from the Program or any\r\n    part thereof, to be licensed as a whole at no charge to all third\r\n    parties under the terms of this License.\r\n\r\n    c) If the modified program normally reads commands interactively\r\n    when run, you must cause it, when started running for such\r\n    interactive use in the most ordinary way, to print or display an\r\n    announcement including an appropriate copyright notice and a\r\n    notice that there is no warranty (or else, saying that you provide\r\n    a warranty) and that users may redistribute the program under\r\n    these conditions, and telling the user how to view a copy of this\r\n    License.  (Exception: if the Program itself is interactive but\r\n    does not normally print such an announcement, your work based on\r\n    the Program is not required to print an announcement.)\r\n\r\nThese requirements apply to the modified work as a whole.  If\r\nidentifiable sections of that work are not derived from the Program,\r\nand can be reasonably considered independent and separate works in\r\nthemselves, then this License, and its terms, do not apply to those\r\nsections when you distribute them as separate works.  But when you\r\ndistribute the same sections as part of a whole which is a work based\r\non the Program, the distribution of the whole must be on the terms of\r\nthis License, whose permissions for other licensees extend to the\r\nentire whole, and thus to each and every part regardless of who wrote it.\r\n\r\nThus, it is not the intent of this section to claim rights or contest\r\nyour rights to work written entirely by you; rather, the intent is to\r\nexercise the right to control the distribution of derivative or\r\ncollective works based on the Program.\r\n\r\nIn addition, mere aggregation of another work not based on the Program\r\nwith the Program (or with a work based on the Program) on a volume of\r\na storage or distribution medium does not bring the other work under\r\nthe scope of this License.\r\n\r\n  3. You may copy and distribute the Program (or a work based on it,\r\nunder Section 2) in object code or executable form under the terms of\r\nSections 1 and 2 above provided that you also do one of the following:\r\n\r\n    a) Accompany it with the complete corresponding machine-readable\r\n    source code, which must be distributed under the terms of Sections\r\n    1 and 2 above on a medium customarily used for software interchange; or,\r\n\r\n    b) Accompany it with a written offer, valid for at least three\r\n    years, to give any third party, for a charge no more than your\r\n    cost of physically performing source distribution, a complete\r\n    machine-readable copy of the corresponding source code, to be\r\n    distributed under the terms of Sections 1 and 2 above on a medium\r\n    customarily used for software interchange; or,\r\n\r\n    c) Accompany it with the information you received as to the offer\r\n    to distribute corresponding source code.  (This alternative is\r\n    allowed only for noncommercial distribution and only if you\r\n    received the program in object code or executable form with such\r\n    an offer, in accord with Subsection b above.)\r\n\r\nThe source code for a work means the preferred form of the work for\r\nmaking modifications to it.  For an executable work, complete source\r\ncode means all the source code for all modules it contains, plus any\r\nassociated interface definition files, plus the scripts used to\r\ncontrol compilation and installation of the executable.  However, as a\r\nspecial exception, the source code distributed need not include\r\nanything that is normally distributed (in either source or binary\r\nform) with the major components (compiler, kernel, and so on) of the\r\noperating system on which the executable runs, unless that component\r\nitself accompanies the executable.\r\n\r\nIf distribution of executable or object code is made by offering\r\naccess to copy from a designated place, then offering equivalent\r\naccess to copy the source code from the same place counts as\r\ndistribution of the source code, even though third parties are not\r\ncompelled to copy the source along with the object code.\r\n\r\n  4. You may not copy, modify, sublicense, or distribute the Program\r\nexcept as expressly provided under this License.  Any attempt\r\notherwise to copy, modify, sublicense or distribute the Program is\r\nvoid, and will automatically terminate your rights under this License.\r\nHowever, parties who have received copies, or rights, from you under\r\nthis License will not have their licenses terminated so long as such\r\nparties remain in full compliance.\r\n\r\n  5. You are not required to accept this License, since you have not\r\nsigned it.  However, nothing else grants you permission to modify or\r\ndistribute the Program or its derivative works.  These actions are\r\nprohibited by law if you do not accept this License.  Therefore, by\r\nmodifying or distributing the Program (or any work based on the\r\nProgram), you indicate your acceptance of this License to do so, and\r\nall its terms and conditions for copying, distributing or modifying\r\nthe Program or works based on it.\r\n\r\n  6. Each time you redistribute the Program (or any work based on the\r\nProgram), the recipient automatically receives a license from the\r\noriginal licensor to copy, distribute or modify the Program subject to\r\nthese terms and conditions.  You may not impose any further\r\nrestrictions on the recipients' exercise of the rights granted herein.\r\nYou are not responsible for enforcing compliance by third parties to\r\nthis License.\r\n\r\n  7. If, as a consequence of a court judgment or allegation of patent\r\ninfringement or for any other reason (not limited to patent issues),\r\nconditions are imposed on you (whether by court order, agreement or\r\notherwise) that contradict the conditions of this License, they do not\r\nexcuse you from the conditions of this License.  If you cannot\r\ndistribute so as to satisfy simultaneously your obligations under this\r\nLicense and any other pertinent obligations, then as a consequence you\r\nmay not distribute the Program at all.  For example, if a patent\r\nlicense would not permit royalty-free redistribution of the Program by\r\nall those who receive copies directly or indirectly through you, then\r\nthe only way you could satisfy both it and this License would be to\r\nrefrain entirely from distribution of the Program.\r\n\r\nIf any portion of this section is held invalid or unenforceable under\r\nany particular circumstance, the balance of the section is intended to\r\napply and the section as a whole is intended to apply in other\r\ncircumstances.\r\n\r\nIt is not the purpose of this section to induce you to infringe any\r\npatents or other property right claims or to contest validity of any\r\nsuch claims; this section has the sole purpose of protecting the\r\nintegrity of the free software distribution system, which is\r\nimplemented by public license practices.  Many people have made\r\ngenerous contributions to the wide range of software distributed\r\nthrough that system in reliance on consistent application of that\r\nsystem; it is up to the author/donor to decide if he or she is willing\r\nto distribute software through any other system and a licensee cannot\r\nimpose that choice.\r\n\r\nThis section is intended to make thoroughly clear what is believed to\r\nbe a consequence of the rest of this License.\r\n\r\n  8. If the distribution and/or use of the Program is restricted in\r\ncertain countries either by patents or by copyrighted interfaces, the\r\noriginal copyright holder who places the Program under this License\r\nmay add an explicit geographical distribution limitation excluding\r\nthose countries, so that distribution is permitted only in or among\r\ncountries not thus excluded.  In such case, this License incorporates\r\nthe limitation as if written in the body of this License.\r\n\r\n  9. The Free Software Foundation may publish revised and/or new versions\r\nof the General Public License from time to time.  Such new versions will\r\nbe similar in spirit to the present version, but may differ in detail to\r\naddress new problems or concerns.\r\n\r\nEach version is given a distinguishing version number.  If the Program\r\nspecifies a version number of this License which applies to it and \"any\r\nlater version\", you have the option of following the terms and conditions\r\neither of that version or of any later version published by the Free\r\nSoftware Foundation.  If the Program does not specify a version number of\r\nthis License, you may choose any version ever published by the Free Software\r\nFoundation.\r\n\r\n  10. If you wish to incorporate parts of the Program into other free\r\nprograms whose distribution conditions are different, write to the author\r\nto ask for permission.  For software which is copyrighted by the Free\r\nSoftware Foundation, write to the Free Software Foundation; we sometimes\r\nmake exceptions for this.  Our decision will be guided by the two goals\r\nof preserving the free status of all derivatives of our free software and\r\nof promoting the sharing and reuse of software generally.\r\n\r\n                            NO WARRANTY\r\n\r\n  11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY\r\nFOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW.  EXCEPT WHEN\r\nOTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES\r\nPROVIDE THE PROGRAM \"AS IS\" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED\r\nOR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\r\nMERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.  THE ENTIRE RISK AS\r\nTO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU.  SHOULD THE\r\nPROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,\r\nREPAIR OR CORRECTION.\r\n\r\n  12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING\r\nWILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR\r\nREDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,\r\nINCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING\r\nOUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED\r\nTO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY\r\nYOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER\r\nPROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE\r\nPOSSIBILITY OF SUCH DAMAGES.\r\n\r\n                     END OF TERMS AND CONDITIONS\r\n\r\n            How to Apply These Terms to Your New Programs\r\n\r\n  If you develop a new program, and you want it to be of the greatest\r\npossible use to the public, the best way to achieve this is to make it\r\nfree software which everyone can redistribute and change under these terms.\r\n\r\n  To do so, attach the following notices to the program.  It is safest\r\nto attach them to the start of each source file to most effectively\r\nconvey the exclusion of warranty; and each file should have at least\r\nthe \"copyright\" line and a pointer to where the full notice is found.\r\n\r\n    <one line to give the program's name and a brief idea of what it does.>\r\n    Copyright (C) <year>  <name of author>\r\n\r\n    This program is free software; you can redistribute it and/or modify\r\n    it under the terms of the GNU General Public License as published by\r\n    the Free Software Foundation; either version 2 of the License, or\r\n    (at your option) any later version.\r\n\r\n    This program is distributed in the hope that it will be useful,\r\n    but WITHOUT ANY WARRANTY; without even the implied warranty of\r\n    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r\n    GNU General Public License for more details.\r\n\r\n    You should have received a copy of the GNU General Public License along\r\n    with this program; if not, write to the Free Software Foundation, Inc.,\r\n    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.\r\n\r\nAlso add information on how to contact you by electronic and paper mail.\r\n\r\nIf the program is interactive, make it output a short notice like this\r\nwhen it starts in an interactive mode:\r\n\r\n    Gnomovision version 69, Copyright (C) year name of author\r\n    Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.\r\n    This is free software, and you are welcome to redistribute it\r\n    under certain conditions; type `show c' for details.\r\n\r\nThe hypothetical commands `show w' and `show c' should show the appropriate\r\nparts of the General Public License.  Of course, the commands you use may\r\nbe called something other than `show w' and `show c'; they could even be\r\nmouse-clicks or menu items--whatever suits your program.\r\n\r\nYou should also get your employer (if you work as a programmer) or your\r\nschool, if any, to sign a \"copyright disclaimer\" for the program, if\r\nnecessary.  Here is a sample; alter the names:\r\n\r\n  Yoyodyne, Inc., hereby disclaims all copyright interest in the program\r\n  `Gnomovision' (which makes passes at compilers) written by James Hacker.\r\n\r\n  <signature of Ty Coon>, 1 April 1989\r\n  Ty Coon, President of Vice\r\n\r\nThis General Public License does not permit incorporating your program into\r\nproprietary programs.  If your program is a subroutine library, you may\r\nconsider it more useful to permit linking proprietary applications with the\r\nlibrary.  If this is what you want to do, use the GNU Lesser General\r\nPublic License instead of this License."
  },
  {
    "path": "PSF_LICENSE.txt",
    "content": "A. HISTORY OF THE SOFTWARE\n==========================\n\nPython was created in the early 1990s by Guido van Rossum at Stichting\nMathematisch Centrum (CWI, see http://www.cwi.nl) in the Netherlands\nas a successor of a language called ABC.  Guido remains Python's\nprincipal author, although it includes many contributions from others.\n\nIn 1995, Guido continued his work on Python at the Corporation for\nNational Research Initiatives (CNRI, see http://www.cnri.reston.va.us)\nin Reston, Virginia where he released several versions of the\nsoftware.\n\nIn May 2000, Guido and the Python core development team moved to\nBeOpen.com to form the BeOpen PythonLabs team.  In October of the same\nyear, the PythonLabs team moved to Digital Creations, which became\nZope Corporation.  In 2001, the Python Software Foundation (PSF, see\nhttps://www.python.org/psf/) was formed, a non-profit organization\ncreated specifically to own Python-related Intellectual Property.\nZope Corporation was a sponsoring member of the PSF.\n\nAll Python releases are Open Source (see http://www.opensource.org for\nthe Open Source Definition).  Historically, most, but not all, Python\nreleases have also been GPL-compatible; the table below summarizes\nthe various releases.\n\n    Release         Derived     Year        Owner       GPL-\n                    from                                compatible? (1)\n\n    0.9.0 thru 1.2              1991-1995   CWI         yes\n    1.3 thru 1.5.2  1.2         1995-1999   CNRI        yes\n    1.6             1.5.2       2000        CNRI        no\n    2.0             1.6         2000        BeOpen.com  no\n    1.6.1           1.6         2001        CNRI        yes (2)\n    2.1             2.0+1.6.1   2001        PSF         no\n    2.0.1           2.0+1.6.1   2001        PSF         yes\n    2.1.1           2.1+2.0.1   2001        PSF         yes\n    2.1.2           2.1.1       2002        PSF         yes\n    2.1.3           2.1.2       2002        PSF         yes\n    2.2 and above   2.1.1       2001-now    PSF         yes\n\nFootnotes:\n\n(1) GPL-compatible doesn't mean that we're distributing Python under\n    the GPL.  All Python licenses, unlike the GPL, let you distribute\n    a modified version without making your changes open source.  The\n    GPL-compatible licenses make it possible to combine Python with\n    other software that is released under the GPL; the others don't.\n\n(2) According to Richard Stallman, 1.6.1 is not GPL-compatible,\n    because its license has a choice of law clause.  According to\n    CNRI, however, Stallman's lawyer has told CNRI's lawyer that 1.6.1\n    is \"not incompatible\" with the GPL.\n\nThanks to the many outside volunteers who have worked under Guido's\ndirection to make these releases possible.\n\n\nB. TERMS AND CONDITIONS FOR ACCESSING OR OTHERWISE USING PYTHON\n===============================================================\n\nPython software and documentation are licensed under the\nPython Software Foundation License Version 2.\n\nStarting with Python 3.8.6, examples, recipes, and other code in\nthe documentation are dual licensed under the PSF License Version 2\nand the Zero-Clause BSD license.\n\nSome software incorporated into Python is under different licenses.\nThe licenses are listed with code falling under that license.\n\n\nPYTHON SOFTWARE FOUNDATION LICENSE VERSION 2\n--------------------------------------------\n\n1. This LICENSE AGREEMENT is between the Python Software Foundation\n(\"PSF\"), and the Individual or Organization (\"Licensee\") accessing and\notherwise using this software (\"Python\") in source or binary form and\nits associated documentation.\n\n2. Subject to the terms and conditions of this License Agreement, PSF hereby\ngrants Licensee a nonexclusive, royalty-free, world-wide license to reproduce,\nanalyze, test, perform and/or display publicly, prepare derivative works,\ndistribute, and otherwise use Python alone or in any derivative version,\nprovided, however, that PSF's License Agreement and PSF's notice of copyright,\ni.e., \"Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,\n2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020, 2021 Python Software Foundation;\nAll Rights Reserved\" are retained in Python alone or in any derivative version\nprepared by Licensee.\n\n3. In the event Licensee prepares a derivative work that is based on\nor incorporates Python or any part thereof, and wants to make\nthe derivative work available to others as provided herein, then\nLicensee hereby agrees to include in any such work a brief summary of\nthe changes made to Python.\n\n4. PSF is making Python available to Licensee on an \"AS IS\"\nbasis.  PSF MAKES NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR\nIMPLIED.  BY WAY OF EXAMPLE, BUT NOT LIMITATION, PSF MAKES NO AND\nDISCLAIMS ANY REPRESENTATION OR WARRANTY OF MERCHANTABILITY OR FITNESS\nFOR ANY PARTICULAR PURPOSE OR THAT THE USE OF PYTHON WILL NOT\nINFRINGE ANY THIRD PARTY RIGHTS.\n\n5. PSF SHALL NOT BE LIABLE TO LICENSEE OR ANY OTHER USERS OF PYTHON\nFOR ANY INCIDENTAL, SPECIAL, OR CONSEQUENTIAL DAMAGES OR LOSS AS\nA RESULT OF MODIFYING, DISTRIBUTING, OR OTHERWISE USING PYTHON,\nOR ANY DERIVATIVE THEREOF, EVEN IF ADVISED OF THE POSSIBILITY THEREOF.\n\n6. This License Agreement will automatically terminate upon a material\nbreach of its terms and conditions.\n\n7. Nothing in this License Agreement shall be deemed to create any\nrelationship of agency, partnership, or joint venture between PSF and\nLicensee.  This License Agreement does not grant permission to use PSF\ntrademarks or trade name in a trademark sense to endorse or promote\nproducts or services of Licensee, or any third party.\n\n8. By copying, installing or otherwise using Python, Licensee\nagrees to be bound by the terms and conditions of this License\nAgreement.\n\n\nBEOPEN.COM LICENSE AGREEMENT FOR PYTHON 2.0\n-------------------------------------------\n\nBEOPEN PYTHON OPEN SOURCE LICENSE AGREEMENT VERSION 1\n\n1. This LICENSE AGREEMENT is between BeOpen.com (\"BeOpen\"), having an\noffice at 160 Saratoga Avenue, Santa Clara, CA 95051, and the\nIndividual or Organization (\"Licensee\") accessing and otherwise using\nthis software in source or binary form and its associated\ndocumentation (\"the Software\").\n\n2. Subject to the terms and conditions of this BeOpen Python License\nAgreement, BeOpen hereby grants Licensee a non-exclusive,\nroyalty-free, world-wide license to reproduce, analyze, test, perform\nand/or display publicly, prepare derivative works, distribute, and\notherwise use the Software alone or in any derivative version,\nprovided, however, that the BeOpen Python License is retained in the\nSoftware, alone or in any derivative version prepared by Licensee.\n\n3. BeOpen is making the Software available to Licensee on an \"AS IS\"\nbasis.  BEOPEN MAKES NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR\nIMPLIED.  BY WAY OF EXAMPLE, BUT NOT LIMITATION, BEOPEN MAKES NO AND\nDISCLAIMS ANY REPRESENTATION OR WARRANTY OF MERCHANTABILITY OR FITNESS\nFOR ANY PARTICULAR PURPOSE OR THAT THE USE OF THE SOFTWARE WILL NOT\nINFRINGE ANY THIRD PARTY RIGHTS.\n\n4. BEOPEN SHALL NOT BE LIABLE TO LICENSEE OR ANY OTHER USERS OF THE\nSOFTWARE FOR ANY INCIDENTAL, SPECIAL, OR CONSEQUENTIAL DAMAGES OR LOSS\nAS A RESULT OF USING, MODIFYING OR DISTRIBUTING THE SOFTWARE, OR ANY\nDERIVATIVE THEREOF, EVEN IF ADVISED OF THE POSSIBILITY THEREOF.\n\n5. This License Agreement will automatically terminate upon a material\nbreach of its terms and conditions.\n\n6. This License Agreement shall be governed by and interpreted in all\nrespects by the law of the State of California, excluding conflict of\nlaw provisions.  Nothing in this License Agreement shall be deemed to\ncreate any relationship of agency, partnership, or joint venture\nbetween BeOpen and Licensee.  This License Agreement does not grant\npermission to use BeOpen trademarks or trade names in a trademark\nsense to endorse or promote products or services of Licensee, or any\nthird party.  As an exception, the \"BeOpen Python\" logos available at\nhttp://www.pythonlabs.com/logos.html may be used according to the\npermissions granted on that web page.\n\n7. By copying, installing or otherwise using the software, Licensee\nagrees to be bound by the terms and conditions of this License\nAgreement.\n\n\nCNRI LICENSE AGREEMENT FOR PYTHON 1.6.1\n---------------------------------------\n\n1. This LICENSE AGREEMENT is between the Corporation for National\nResearch Initiatives, having an office at 1895 Preston White Drive,\nReston, VA 20191 (\"CNRI\"), and the Individual or Organization\n(\"Licensee\") accessing and otherwise using Python 1.6.1 software in\nsource or binary form and its associated documentation.\n\n2. Subject to the terms and conditions of this License Agreement, CNRI\nhereby grants Licensee a nonexclusive, royalty-free, world-wide\nlicense to reproduce, analyze, test, perform and/or display publicly,\nprepare derivative works, distribute, and otherwise use Python 1.6.1\nalone or in any derivative version, provided, however, that CNRI's\nLicense Agreement and CNRI's notice of copyright, i.e., \"Copyright (c)\n1995-2001 Corporation for National Research Initiatives; All Rights\nReserved\" are retained in Python 1.6.1 alone or in any derivative\nversion prepared by Licensee.  Alternately, in lieu of CNRI's License\nAgreement, Licensee may substitute the following text (omitting the\nquotes): \"Python 1.6.1 is made available subject to the terms and\nconditions in CNRI's License Agreement.  This Agreement together with\nPython 1.6.1 may be located on the Internet using the following\nunique, persistent identifier (known as a handle): 1895.22/1013.  This\nAgreement may also be obtained from a proxy server on the Internet\nusing the following URL: http://hdl.handle.net/1895.22/1013\".\n\n3. In the event Licensee prepares a derivative work that is based on\nor incorporates Python 1.6.1 or any part thereof, and wants to make\nthe derivative work available to others as provided herein, then\nLicensee hereby agrees to include in any such work a brief summary of\nthe changes made to Python 1.6.1.\n\n4. CNRI is making Python 1.6.1 available to Licensee on an \"AS IS\"\nbasis.  CNRI MAKES NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR\nIMPLIED.  BY WAY OF EXAMPLE, BUT NOT LIMITATION, CNRI MAKES NO AND\nDISCLAIMS ANY REPRESENTATION OR WARRANTY OF MERCHANTABILITY OR FITNESS\nFOR ANY PARTICULAR PURPOSE OR THAT THE USE OF PYTHON 1.6.1 WILL NOT\nINFRINGE ANY THIRD PARTY RIGHTS.\n\n5. CNRI SHALL NOT BE LIABLE TO LICENSEE OR ANY OTHER USERS OF PYTHON\n1.6.1 FOR ANY INCIDENTAL, SPECIAL, OR CONSEQUENTIAL DAMAGES OR LOSS AS\nA RESULT OF MODIFYING, DISTRIBUTING, OR OTHERWISE USING PYTHON 1.6.1,\nOR ANY DERIVATIVE THEREOF, EVEN IF ADVISED OF THE POSSIBILITY THEREOF.\n\n6. This License Agreement will automatically terminate upon a material\nbreach of its terms and conditions.\n\n7. This License Agreement shall be governed by the federal\nintellectual property law of the United States, including without\nlimitation the federal copyright law, and, to the extent such\nU.S. federal law does not apply, by the law of the Commonwealth of\nVirginia, excluding Virginia's conflict of law provisions.\nNotwithstanding the foregoing, with regard to derivative works based\non Python 1.6.1 that incorporate non-separable material that was\npreviously distributed under the GNU General Public License (GPL), the\nlaw of the Commonwealth of Virginia shall govern this License\nAgreement only as to issues arising under or with respect to\nParagraphs 4, 5, and 7 of this License Agreement.  Nothing in this\nLicense Agreement shall be deemed to create any relationship of\nagency, partnership, or joint venture between CNRI and Licensee.  This\nLicense Agreement does not grant permission to use CNRI trademarks or\ntrade name in a trademark sense to endorse or promote products or\nservices of Licensee, or any third party.\n\n8. By clicking on the \"ACCEPT\" button where indicated, or by copying,\ninstalling or otherwise using Python 1.6.1, Licensee agrees to be\nbound by the terms and conditions of this License Agreement.\n\n        ACCEPT\n\n\nCWI LICENSE AGREEMENT FOR PYTHON 0.9.0 THROUGH 1.2\n--------------------------------------------------\n\nCopyright (c) 1991 - 1995, Stichting Mathematisch Centrum Amsterdam,\nThe Netherlands.  All rights reserved.\n\nPermission to use, copy, modify, and distribute this software and its\ndocumentation for any purpose and without fee is hereby granted,\nprovided that the above copyright notice appear in all copies and that\nboth that copyright notice and this permission notice appear in\nsupporting documentation, and that the name of Stichting Mathematisch\nCentrum or CWI not be used in advertising or publicity pertaining to\ndistribution of the software without specific, written prior\npermission.\n\nSTICHTING MATHEMATISCH CENTRUM DISCLAIMS ALL WARRANTIES WITH REGARD TO\nTHIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND\nFITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH CENTRUM BE LIABLE\nFOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES\nWHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN\nACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT\nOF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.\n\nZERO-CLAUSE BSD LICENSE FOR CODE IN THE PYTHON DOCUMENTATION\n----------------------------------------------------------------------\n\nPermission to use, copy, modify, and/or distribute this software for any\npurpose with or without fee is hereby granted.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\nREGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY\nAND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\nINDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM\nLOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR\nOTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR\nPERFORMANCE OF THIS SOFTWARE.\n\n\n\nAdditional Conditions for this Windows binary build\n---------------------------------------------------\n\nThis program is linked with and uses Microsoft Distributable Code,\ncopyrighted by Microsoft Corporation. The Microsoft Distributable Code\nis embedded in each .exe, .dll and .pyd file as a result of running\nthe code through a linker.\n\nIf you further distribute programs that include the Microsoft\nDistributable Code, you must comply with the restrictions on\ndistribution specified by Microsoft. In particular, you must require\ndistributors and external end users to agree to terms that protect the\nMicrosoft Distributable Code at least as much as Microsoft's own\nrequirements for the Distributable Code. See Microsoft's documentation\n(included in its developer tools and on its website at microsoft.com)\nfor specific details.\n\nRedistribution of the Windows binary build of the Python interpreter\ncomplies with this agreement, provided that you do not:\n\n- alter any copyright, trademark or patent notice in Microsoft's\nDistributable Code;\n\n- use Microsoft's trademarks in your programs' names or in a way that\nsuggests your programs come from or are endorsed by Microsoft;\n\n- distribute Microsoft's Distributable Code to run on a platform other\nthan Microsoft operating systems, run-time technologies or application\nplatforms; or\n\n- include Microsoft Distributable Code in malicious, deceptive or\nunlawful programs.\n\nThese restrictions apply only to the Microsoft Distributable Code as\ndefined above, not to Python itself or any programs running on the\nPython interpreter. The redistribution of the Python interpreter and\nlibraries is governed by the Python Software License included with this\nfile, or by other licenses as marked.\n\n\n\n--------------------------------------------------------------------------\n\nThis program, \"bzip2\", the associated library \"libbzip2\", and all\ndocumentation, are copyright (C) 1996-2010 Julian R Seward.  All\nrights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions\nare met:\n\n1. Redistributions of source code must retain the above copyright\n   notice, this list of conditions and the following disclaimer.\n\n2. The origin of this software must not be misrepresented; you must \n   not claim that you wrote the original software.  If you use this \n   software in a product, an acknowledgment in the product \n   documentation would be appreciated but is not required.\n\n3. Altered source versions must be plainly marked as such, and must\n   not be misrepresented as being the original software.\n\n4. The name of the author may not be used to endorse or promote \n   products derived from this software without specific prior written \n   permission.\n\nTHIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS\nOR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\nWARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\nARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY\nDIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\nDAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE\nGOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS\nINTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\nWHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING\nNEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\nSOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\nJulian Seward, jseward@bzip.org\nbzip2/libbzip2 version 1.0.6 of 6 September 2010\n\n--------------------------------------------------------------------------\n\n\n  LICENSE ISSUES\n  ==============\n\n  The OpenSSL toolkit stays under a double license, i.e. both the conditions of\n  the OpenSSL License and the original SSLeay license apply to the toolkit.\n  See below for the actual license texts.\n\n  OpenSSL License\n  ---------------\n\n/* ====================================================================\n * Copyright (c) 1998-2019 The OpenSSL Project.  All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n *\n * 1. Redistributions of source code must retain the above copyright\n *    notice, this list of conditions and the following disclaimer.\n *\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in\n *    the documentation and/or other materials provided with the\n *    distribution.\n *\n * 3. All advertising materials mentioning features or use of this\n *    software must display the following acknowledgment:\n *    \"This product includes software developed by the OpenSSL Project\n *    for use in the OpenSSL Toolkit. (http://www.openssl.org/)\"\n *\n * 4. The names \"OpenSSL Toolkit\" and \"OpenSSL Project\" must not be used to\n *    endorse or promote products derived from this software without\n *    prior written permission. For written permission, please contact\n *    openssl-core@openssl.org.\n *\n * 5. Products derived from this software may not be called \"OpenSSL\"\n *    nor may \"OpenSSL\" appear in their names without prior written\n *    permission of the OpenSSL Project.\n *\n * 6. Redistributions of any form whatsoever must retain the following\n *    acknowledgment:\n *    \"This product includes software developed by the OpenSSL Project\n *    for use in the OpenSSL Toolkit (http://www.openssl.org/)\"\n *\n * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY\n * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\n * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE OpenSSL PROJECT OR\n * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT\n * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,\n * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\n * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED\n * OF THE POSSIBILITY OF SUCH DAMAGE.\n * ====================================================================\n *\n * This product includes cryptographic software written by Eric Young\n * (eay@cryptsoft.com).  This product includes software written by Tim\n * Hudson (tjh@cryptsoft.com).\n *\n */\n\n Original SSLeay License\n -----------------------\n\n/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)\n * All rights reserved.\n *\n * This package is an SSL implementation written\n * by Eric Young (eay@cryptsoft.com).\n * The implementation was written so as to conform with Netscapes SSL.\n *\n * This library is free for commercial and non-commercial use as long as\n * the following conditions are aheared to.  The following conditions\n * apply to all code found in this distribution, be it the RC4, RSA,\n * lhash, DES, etc., code; not just the SSL code.  The SSL documentation\n * included with this distribution is covered by the same copyright terms\n * except that the holder is Tim Hudson (tjh@cryptsoft.com).\n *\n * Copyright remains Eric Young's, and as such any Copyright notices in\n * the code are not to be removed.\n * If this package is used in a product, Eric Young should be given attribution\n * as the author of the parts of the library used.\n * This can be in the form of a textual message at program startup or\n * in documentation (online or textual) provided with the package.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n * 1. Redistributions of source code must retain the copyright\n *    notice, this list of conditions and the following disclaimer.\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in the\n *    documentation and/or other materials provided with the distribution.\n * 3. All advertising materials mentioning features or use of this software\n *    must display the following acknowledgement:\n *    \"This product includes cryptographic software written by\n *     Eric Young (eay@cryptsoft.com)\"\n *    The word 'cryptographic' can be left out if the rouines from the library\n *    being used are not cryptographic related :-).\n * 4. If you include any Windows specific code (or a derivative thereof) from\n *    the apps directory (application code) you must include an acknowledgement:\n *    \"This product includes software written by Tim Hudson (tjh@cryptsoft.com)\"\n *\n * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND\n * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE\n * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\n * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\n * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\n * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\n * SUCH DAMAGE.\n *\n * The licence and distribution terms for any publically available version or\n * derivative of this code cannot be changed.  i.e. this code cannot simply be\n * copied and put under another distribution licence\n * [including the GNU Public Licence.]\n */\n\n\nlibffi - Copyright (c) 1996-2014  Anthony Green, Red Hat, Inc and others.\nSee source files for details.\n\nPermission is hereby granted, free of charge, to any person obtaining\na copy of this software and associated documentation files (the\n``Software''), to deal in the Software without restriction, including\nwithout limitation the rights to use, copy, modify, merge, publish,\ndistribute, sublicense, and/or sell copies of the Software, and to\npermit persons to whom the Software is furnished to do so, subject to\nthe following conditions:\n\nThe above copyright notice and this permission notice shall be\nincluded in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND,\nEXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.\nIN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY\nCLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,\nTORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\nSOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n\nThis software is copyrighted by the Regents of the University of\nCalifornia, Sun Microsystems, Inc., Scriptics Corporation, ActiveState\nCorporation and other parties.  The following terms apply to all files\nassociated with the software unless explicitly disclaimed in\nindividual files.\n\nThe authors hereby grant permission to use, copy, modify, distribute,\nand license this software and its documentation for any purpose, provided\nthat existing copyright notices are retained in all copies and that this\nnotice is included verbatim in any distributions. No written agreement,\nlicense, or royalty fee is required for any of the authorized uses.\nModifications to this software may be copyrighted by their authors\nand need not follow the licensing terms described here, provided that\nthe new terms are clearly indicated on the first page of each file where\nthey apply.\n\nIN NO EVENT SHALL THE AUTHORS OR DISTRIBUTORS BE LIABLE TO ANY PARTY\nFOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES\nARISING OUT OF THE USE OF THIS SOFTWARE, ITS DOCUMENTATION, OR ANY\nDERIVATIVES THEREOF, EVEN IF THE AUTHORS HAVE BEEN ADVISED OF THE\nPOSSIBILITY OF SUCH DAMAGE.\n\nTHE AUTHORS AND DISTRIBUTORS SPECIFICALLY DISCLAIM ANY WARRANTIES,\nINCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT.  THIS SOFTWARE\nIS PROVIDED ON AN \"AS IS\" BASIS, AND THE AUTHORS AND DISTRIBUTORS HAVE\nNO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR\nMODIFICATIONS.\n\nGOVERNMENT USE: If you are acquiring this software on behalf of the\nU.S. government, the Government shall have only \"Restricted Rights\"\nin the software and related documentation as defined in the Federal\nAcquisition Regulations (FARs) in Clause 52.227.19 (c) (2).  If you\nare acquiring the software on behalf of the Department of Defense, the\nsoftware shall be classified as \"Commercial Computer Software\" and the\nGovernment shall have only \"Restricted Rights\" as defined in Clause\n252.227-7014 (b) (3) of DFARs.  Notwithstanding the foregoing, the\nauthors grant the U.S. Government and others acting in its behalf\npermission to use and distribute the software in accordance with the\nterms specified in this license.\n\nThis software is copyrighted by the Regents of the University of\nCalifornia, Sun Microsystems, Inc., Scriptics Corporation, ActiveState\nCorporation, Apple Inc. and other parties.  The following terms apply to\nall files associated with the software unless explicitly disclaimed in\nindividual files.\n\nThe authors hereby grant permission to use, copy, modify, distribute,\nand license this software and its documentation for any purpose, provided\nthat existing copyright notices are retained in all copies and that this\nnotice is included verbatim in any distributions. No written agreement,\nlicense, or royalty fee is required for any of the authorized uses.\nModifications to this software may be copyrighted by their authors\nand need not follow the licensing terms described here, provided that\nthe new terms are clearly indicated on the first page of each file where\nthey apply.\n\nIN NO EVENT SHALL THE AUTHORS OR DISTRIBUTORS BE LIABLE TO ANY PARTY\nFOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES\nARISING OUT OF THE USE OF THIS SOFTWARE, ITS DOCUMENTATION, OR ANY\nDERIVATIVES THEREOF, EVEN IF THE AUTHORS HAVE BEEN ADVISED OF THE\nPOSSIBILITY OF SUCH DAMAGE.\n\nTHE AUTHORS AND DISTRIBUTORS SPECIFICALLY DISCLAIM ANY WARRANTIES,\nINCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT.  THIS SOFTWARE\nIS PROVIDED ON AN \"AS IS\" BASIS, AND THE AUTHORS AND DISTRIBUTORS HAVE\nNO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR\nMODIFICATIONS.\n\nGOVERNMENT USE: If you are acquiring this software on behalf of the\nU.S. government, the Government shall have only \"Restricted Rights\"\nin the software and related documentation as defined in the Federal\nAcquisition Regulations (FARs) in Clause 52.227.19 (c) (2).  If you\nare acquiring the software on behalf of the Department of Defense, the\nsoftware shall be classified as \"Commercial Computer Software\" and the\nGovernment shall have only \"Restricted Rights\" as defined in Clause\n252.227-7013 (b) (3) of DFARs.  Notwithstanding the foregoing, the\nauthors grant the U.S. Government and others acting in its behalf\npermission to use and distribute the software in accordance with the\nterms specified in this license.\n\nCopyright (c) 1993-1999 Ioi Kim Lam.\nCopyright (c) 2000-2001 Tix Project Group.\nCopyright (c) 2004 ActiveState\n\nThis software is copyrighted by the above entities\nand other parties.  The following terms apply to all files associated\nwith the software unless explicitly disclaimed in individual files.\n\nThe authors hereby grant permission to use, copy, modify, distribute,\nand license this software and its documentation for any purpose, provided\nthat existing copyright notices are retained in all copies and that this\nnotice is included verbatim in any distributions. No written agreement,\nlicense, or royalty fee is required for any of the authorized uses.\nModifications to this software may be copyrighted by their authors\nand need not follow the licensing terms described here, provided that\nthe new terms are clearly indicated on the first page of each file where\nthey apply.\n\nIN NO EVENT SHALL THE AUTHORS OR DISTRIBUTORS BE LIABLE TO ANY PARTY\nFOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES\nARISING OUT OF THE USE OF THIS SOFTWARE, ITS DOCUMENTATION, OR ANY\nDERIVATIVES THEREOF, EVEN IF THE AUTHORS HAVE BEEN ADVISED OF THE\nPOSSIBILITY OF SUCH DAMAGE.\n\nTHE AUTHORS AND DISTRIBUTORS SPECIFICALLY DISCLAIM ANY WARRANTIES,\nINCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT.  THIS SOFTWARE\nIS PROVIDED ON AN \"AS IS\" BASIS, AND THE AUTHORS AND DISTRIBUTORS HAVE\nNO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR\nMODIFICATIONS.\n\nGOVERNMENT USE: If you are acquiring this software on behalf of the\nU.S. government, the Government shall have only \"Restricted Rights\"\nin the software and related documentation as defined in the Federal \nAcquisition Regulations (FARs) in Clause 52.227.19 (c) (2).  If you\nare acquiring the software on behalf of the Department of Defense, the\nsoftware shall be classified as \"Commercial Computer Software\" and the\nGovernment shall have only \"Restricted Rights\" as defined in Clause\n252.227-7013 (c) (1) of DFARs.  Notwithstanding the foregoing, the\nauthors grant the U.S. Government and others acting in its behalf\npermission to use and distribute the software in accordance with the\nterms specified in this license. \n\n----------------------------------------------------------------------\n\nParts of this software are based on the Tcl/Tk software copyrighted by\nthe Regents of the University of California, Sun Microsystems, Inc.,\nand other parties. The original license terms of the Tcl/Tk software\ndistribution is included in the file docs/license.tcltk.\n\nParts of this software are based on the HTML Library software\ncopyrighted by Sun Microsystems, Inc. The original license terms of\nthe HTML Library software distribution is included in the file\ndocs/license.html_lib.\n\n"
  },
  {
    "path": "Plugins/AlteraBSPGenerator/AlteraBSPGenerator.pri",
    "content": "# ----------------------------------------------------\r\n# This file is generated by the Qt Visual Studio Tools.\r\n# ------------------------------------------------------\r\n\r\nHEADERS += ./alterabspgenerator_global.h \\\r\n    ./commandlinegeneratordialog.h \\\r\n    ./commandlineconsole.h \\\r\n    ./alterabspgenerator.h \\\r\n    ./alterabspgeneratordialog.h \\\r\n    ../../common/widgets/viewSelector/viewselector.h\r\nSOURCES += ../../common/widgets/viewSelector/viewselector.cpp \\\r\n    ./alterabspgeneratordialog.cpp \\\r\n    ./commandlineconsole.cpp \\\r\n    ./commandlinegeneratordialog.cpp \\\r\n    ./alterabspgenerator.cpp\r\nRESOURCES += AlteraBSPGenerator.qrc\r\n"
  },
  {
    "path": "Plugins/AlteraBSPGenerator/AlteraBSPGenerator.pro",
    "content": "# ----------------------------------------------------\r\n# This file is generated by the Qt Visual Studio Add-in.\r\n# ------------------------------------------------------\r\n\r\nTEMPLATE = lib\r\n\r\nQT += core xml widgets gui printsupport\r\nCONFIG += c++11 plugin\r\n\r\nDEFINES += ALTERABSPGENERATOR_LIB\r\n\r\nINCLUDEPATH += ./GeneratedFiles \\\r\n    . \\\r\n    ./../.. \\\r\n\r\nDESTDIR = ../../executable/Plugins\r\n\r\nCONFIG(debug, debug|release) {\r\n    # debug mode\r\n    LIBS += \\\r\n        -L../../executable -lIPXACTmodelsd\r\n\r\n    MOC_DIR += ./GeneratedFiles/Debug\r\n    OBJECTS_DIR += Debug\r\n    TARGET = AlteraBSPGeneratord\r\n\r\n} else {\r\n    # release mode \r\n    LIBS += \\\r\n        -L../../executable -lIPXACTmodels\r\n    \r\n    MOC_DIR += ./GeneratedFiles/Release\r\n    OBJECTS_DIR += Release\r\n    TARGET = AlteraBSPGenerator\r\n}\r\n\r\n\r\nDEPENDPATH += .\r\nUI_DIR += ./GeneratedFiles\r\nRCC_DIR += ./GeneratedFiles\r\ninclude(AlteraBSPGenerator.pri)\r\n\r\ntarget.path = $$plugin_path\r\nINSTALLS += target\r\n"
  },
  {
    "path": "Plugins/AlteraBSPGenerator/AlteraBSPGenerator.qrc",
    "content": "<RCC>\n    <qresource prefix=\"/icons\">\n        <file>BSPicon24.png</file>\n    </qresource>\n</RCC>\n"
  },
  {
    "path": "Plugins/AlteraBSPGenerator/AlteraBSPGenerator.vcxproj",
    "content": "﻿<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n<Project DefaultTargets=\"Build\" ToolsVersion=\"15.0\" xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">\r\n  <ItemGroup Label=\"ProjectConfigurations\">\r\n    <ProjectConfiguration Include=\"Debug|x64\">\r\n      <Configuration>Debug</Configuration>\r\n      <Platform>x64</Platform>\r\n    </ProjectConfiguration>\r\n    <ProjectConfiguration Include=\"Release|x64\">\r\n      <Configuration>Release</Configuration>\r\n      <Platform>x64</Platform>\r\n    </ProjectConfiguration>\r\n  </ItemGroup>\r\n  <PropertyGroup Label=\"Globals\">\r\n    <ProjectGuid>{16C73FC5-A179-4B2C-983C-59B9D1431703}</ProjectGuid>\r\n    <Keyword>QtVS_v304</Keyword>\r\n    <WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>\r\n    <QtMsBuild Condition=\"'$(QtMsBuild)'=='' or !Exists('$(QtMsBuild)\\qt.targets')\">$(MSBuildProjectDirectory)\\QtMsBuild</QtMsBuild>\r\n  </PropertyGroup>\r\n  <Import Project=\"$(VCTargetsPath)\\Microsoft.Cpp.Default.props\" />\r\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\" Label=\"Configuration\">\r\n    <ConfigurationType>DynamicLibrary</ConfigurationType>\r\n    <PlatformToolset>v143</PlatformToolset>\r\n  </PropertyGroup>\r\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\" Label=\"Configuration\">\r\n    <ConfigurationType>DynamicLibrary</ConfigurationType>\r\n    <PlatformToolset>v143</PlatformToolset>\r\n  </PropertyGroup>\r\n  <Import Project=\"$(VCTargetsPath)\\Microsoft.Cpp.props\" />\r\n  <Target Name=\"QtMsBuildNotFound\" BeforeTargets=\"CustomBuild;ClCompile\" Condition=\"!Exists('$(QtMsBuild)\\qt.targets') or !Exists('$(QtMsBuild)\\qt.props')\">\r\n    <Message Importance=\"High\" Text=\"QtMsBuild: could not locate qt.targets, qt.props; project may not build correctly.\" />\r\n  </Target>\r\n  <ImportGroup Label=\"ExtensionSettings\">\r\n  </ImportGroup>\r\n  <ImportGroup Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\" Label=\"PropertySheets\">\r\n    <Import Project=\"$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props\" Condition=\"exists('$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props')\" Label=\"LocalAppDataPlatform\" />\r\n  </ImportGroup>\r\n  <ImportGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\" Label=\"PropertySheets\">\r\n    <Import Project=\"$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props\" Condition=\"exists('$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props')\" Label=\"LocalAppDataPlatform\" />\r\n  </ImportGroup>\r\n  <PropertyGroup Label=\"UserMacros\" />\r\n  <ImportGroup Condition=\"Exists('$(QtMsBuild)\\qt_defaults.props')\">\r\n    <Import Project=\"$(QtMsBuild)\\qt_defaults.props\" />\r\n  </ImportGroup>\r\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n    <OutDir>$(SolutionDir)executable\\Plugins\\</OutDir>\r\n    <IntDir>$(ProjectDir)\\$(Configuration)\\</IntDir>\r\n  </PropertyGroup>\r\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n    <OutDir>$(SolutionDir)executable\\Plugins\\</OutDir>\r\n    <IntDir>$(ProjectDir)\\$(Configuration)\\</IntDir>\r\n  </PropertyGroup>\r\n  <PropertyGroup Label=\"QtSettings\" Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n    <QtInstall>6.2.4</QtInstall>\r\n    <QtModules>core;gui;widgets;help;printsupport;xml</QtModules>\r\n  </PropertyGroup>\r\n  <PropertyGroup Label=\"QtSettings\" Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n    <QtInstall>6.2.4</QtInstall>\r\n    <QtModules>core;gui;widgets;help;printsupport;xml</QtModules>\r\n  </PropertyGroup>\r\n  <ImportGroup Condition=\"Exists('$(QtMsBuild)\\qt.props')\">\r\n    <Import Project=\"$(QtMsBuild)\\qt.props\" />\r\n  </ImportGroup>\r\n  <PropertyGroup>\r\n    <_ProjectFileVersion>10.0.40219.1</_ProjectFileVersion>\r\n  </PropertyGroup>\r\n  <ItemDefinitionGroup Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n    <ClCompile>\r\n      <PreprocessorDefinitions>ALTERABSPGENERATOR_LIB;QT_XMLPATTERNS_LIB;UNICODE;WIN32;%(PreprocessorDefinitions)</PreprocessorDefinitions>\r\n      <AdditionalIncludeDirectories>.\\GeneratedFiles\\$(ConfigurationName);.\\GeneratedFiles;.\\GeneratedFiles\\$(Configuration);.;.\\..\\..;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\r\n      <Optimization>Disabled</Optimization>\r\n      <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>\r\n      <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>\r\n      <TreatWChar_tAsBuiltInType>true</TreatWChar_tAsBuiltInType>\r\n      <LanguageStandard>stdcpp17</LanguageStandard>\r\n      <AdditionalOptions>/Zc:__cplusplus %(AdditionalOptions)</AdditionalOptions>\r\n      <MultiProcessorCompilation>true</MultiProcessorCompilation>\r\n    </ClCompile>\r\n    <Link>\r\n      <SubSystem>Windows</SubSystem>\r\n      <OutputFile>$(OutDir)$(ProjectName).dll</OutputFile>\r\n      <AdditionalLibraryDirectories>..\\..\\executable;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>\r\n      <GenerateDebugInformation>true</GenerateDebugInformation>\r\n      <AdditionalDependencies>IPXACTmodelsd.lib;%(AdditionalDependencies)</AdditionalDependencies>\r\n      <TargetMachine>MachineX64</TargetMachine>\r\n      <AdditionalOptions> /SUBSYSTEM:WINDOWS</AdditionalOptions>\r\n    </Link>\r\n    <QtMoc>\r\n      <ExecutionDescription>Moc'ing %(Identity)...</ExecutionDescription>\r\n      <DynamicSource>output</DynamicSource>\r\n      <QtMocDir>.\\GeneratedFiles\\$(ConfigurationName)</QtMocDir>\r\n      <QtMocFileName>moc_%(Filename).cpp</QtMocFileName>\r\n    </QtMoc>\r\n    <QtRcc>\r\n      <InitFuncName>%(Filename)</InitFuncName>\r\n      <Compression>default</Compression>\r\n      <NoCompression>true</NoCompression>\r\n      <ExecutionDescription>Rcc'ing %(Identity)...</ExecutionDescription>\r\n      <QtRccDir>.\\GeneratedFiles</QtRccDir>\r\n      <QtRccFileName>qrc_%(Filename).cpp</QtRccFileName>\r\n    </QtRcc>\r\n  </ItemDefinitionGroup>\r\n  <ItemDefinitionGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n    <ClCompile>\r\n      <PreprocessorDefinitions>ALTERABSPGENERATOR_LIB;NDEBUG;QT_NO_DEBUG;QT_XMLPATTERNS_LIB;UNICODE;WIN32;%(PreprocessorDefinitions)</PreprocessorDefinitions>\r\n      <AdditionalIncludeDirectories>.\\GeneratedFiles\\$(ConfigurationName);.\\GeneratedFiles;.\\GeneratedFiles\\$(Configuration);.;.\\..\\..;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\r\n      <DebugInformationFormat>\r\n      </DebugInformationFormat>\r\n      <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>\r\n      <TreatWChar_tAsBuiltInType>true</TreatWChar_tAsBuiltInType>\r\n      <LanguageStandard>stdcpp17</LanguageStandard>\r\n      <AdditionalOptions>/Zc:__cplusplus %(AdditionalOptions)</AdditionalOptions>\r\n      <MultiProcessorCompilation>true</MultiProcessorCompilation>\r\n    </ClCompile>\r\n    <Link>\r\n      <SubSystem>Windows</SubSystem>\r\n      <OutputFile>$(OutDir)$(ProjectName).dll</OutputFile>\r\n      <AdditionalLibraryDirectories>..\\..\\executable;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>\r\n      <GenerateDebugInformation>false</GenerateDebugInformation>\r\n      <AdditionalDependencies>IPXACTmodels.lib;%(AdditionalDependencies)</AdditionalDependencies>\r\n      <TargetMachine>MachineX64</TargetMachine>\r\n      <AdditionalOptions> /SUBSYSTEM:WINDOWS</AdditionalOptions>\r\n    </Link>\r\n    <QtMoc>\r\n      <ExecutionDescription>Moc'ing %(Identity)...</ExecutionDescription>\r\n      <DynamicSource>output</DynamicSource>\r\n      <QtMocDir>.\\GeneratedFiles\\$(ConfigurationName)</QtMocDir>\r\n      <QtMocFileName>moc_%(Filename).cpp</QtMocFileName>\r\n    </QtMoc>\r\n    <QtRcc>\r\n      <InitFuncName>%(Filename)</InitFuncName>\r\n      <Compression>default</Compression>\r\n      <NoCompression>true</NoCompression>\r\n      <ExecutionDescription>Rcc'ing %(Identity)...</ExecutionDescription>\r\n      <QtRccDir>.\\GeneratedFiles</QtRccDir>\r\n      <QtRccFileName>qrc_%(Filename).cpp</QtRccFileName>\r\n    </QtRcc>\r\n  </ItemDefinitionGroup>\r\n  <ItemGroup>\r\n    <ClCompile Include=\"..\\..\\common\\widgets\\viewSelector\\viewselector.cpp\" />\r\n    <ClCompile Include=\"alterabspgeneratordialog.cpp\" />\r\n    <ClCompile Include=\"commandlineconsole.cpp\" />\r\n    <ClCompile Include=\"commandlinegeneratordialog.cpp\" />\r\n    <ClCompile Include=\"alterabspgenerator.cpp\" />\r\n  </ItemGroup>\r\n  <ItemGroup>\r\n    <QtMoc Include=\"commandlinegeneratordialog.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"commandlineconsole.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"alterabspgenerator.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"alterabspgeneratordialog.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"..\\..\\common\\widgets\\viewSelector\\viewselector.h\">\r\n    </QtMoc>\r\n    <ClInclude Include=\"alterabspgenerator_global.h\" />\r\n  </ItemGroup>\r\n  <ItemGroup>\r\n    <None Include=\"alteraBSPGenerator.json\" />\r\n    <None Include=\"BSPicon24.png\">\r\n      <ExcludedFromBuild Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">true</ExcludedFromBuild>\r\n      <ExcludedFromBuild Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">true</ExcludedFromBuild>\r\n    </None>\r\n    <QtRcc Include=\"AlteraBSPGenerator.qrc\">\r\n    </QtRcc>\r\n  </ItemGroup>\r\n  <Import Project=\"$(VCTargetsPath)\\Microsoft.Cpp.targets\" />\r\n  <ImportGroup Condition=\"Exists('$(QtMsBuild)\\qt.targets')\">\r\n    <Import Project=\"$(QtMsBuild)\\qt.targets\" />\r\n  </ImportGroup>\r\n  <ImportGroup Label=\"ExtensionTargets\">\r\n  </ImportGroup>\r\n  <ProjectExtensions>\r\n    <VisualStudio>\r\n      <UserProperties />\r\n    </VisualStudio>\r\n  </ProjectExtensions>\r\n</Project>"
  },
  {
    "path": "Plugins/AlteraBSPGenerator/AlteraBSPGenerator.vcxproj.filters",
    "content": "﻿<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n<Project ToolsVersion=\"4.0\" xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">\r\n  <ItemGroup>\r\n    <Filter Include=\"Source Files\">\r\n      <UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>\r\n      <Extensions>cpp;cxx;c;def</Extensions>\r\n    </Filter>\r\n    <Filter Include=\"Header Files\">\r\n      <UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>\r\n      <Extensions>h</Extensions>\r\n    </Filter>\r\n    <Filter Include=\"Resource Files\">\r\n      <UniqueIdentifier>{D9D6E242-F8AF-46E4-B9FD-80ECBC20BA3E}</UniqueIdentifier>\r\n      <Extensions>qrc;*</Extensions>\r\n      <ParseFiles>false</ParseFiles>\r\n    </Filter>\r\n    <Filter Include=\"Generated Files\">\r\n      <UniqueIdentifier>{71ED8ED8-ACB9-4CE9-BBE1-E00B30144E11}</UniqueIdentifier>\r\n      <Extensions>moc;h;cpp</Extensions>\r\n      <SourceControlFiles>False</SourceControlFiles>\r\n    </Filter>\r\n    <Filter Include=\"Generated Files\\Debug\">\r\n      <UniqueIdentifier>{aadf1134-eca1-4c7e-afc5-1e558bce1cca}</UniqueIdentifier>\r\n      <Extensions>cpp;moc</Extensions>\r\n      <SourceControlFiles>False</SourceControlFiles>\r\n    </Filter>\r\n    <Filter Include=\"Generated Files\\Release\">\r\n      <UniqueIdentifier>{8d5952d1-aa69-48bb-8569-a9f6e60c9c17}</UniqueIdentifier>\r\n      <Extensions>cpp;moc</Extensions>\r\n      <SourceControlFiles>False</SourceControlFiles>\r\n    </Filter>\r\n  </ItemGroup>\r\n  <ItemGroup>\r\n    \r\n    \r\n    \r\n    <ClCompile Include=\"alterabspgenerator.cpp\">\r\n      <Filter>Source Files</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"alterabspgeneratordialog.cpp\">\r\n      <Filter>Source Files</Filter>\r\n    </ClCompile>\r\n    \r\n    \r\n    <ClCompile Include=\"..\\..\\common\\widgets\\viewSelector\\viewselector.cpp\">\r\n      <Filter>Source Files</Filter>\r\n    </ClCompile>\r\n    \r\n    \r\n    \r\n    \r\n    \r\n    \r\n    <ClCompile Include=\"commandlineconsole.cpp\">\r\n      <Filter>Source Files</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"commandlinegeneratordialog.cpp\">\r\n      <Filter>Source Files</Filter>\r\n    </ClCompile>\r\n  </ItemGroup>\r\n  <ItemGroup>\r\n    <QtRcc Include=\"AlteraBSPGenerator.qrc\">\r\n      <Filter>Resource Files</Filter>\r\n    </QtRcc>\r\n    <QtMoc Include=\"alterabspgenerator.h\">\r\n      <Filter>Header Files</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"alterabspgeneratordialog.h\">\r\n      <Filter>Header Files</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"..\\..\\common\\widgets\\viewSelector\\viewselector.h\">\r\n      <Filter>Header Files</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"commandlineconsole.h\">\r\n      <Filter>Header Files</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"commandlinegeneratordialog.h\">\r\n      <Filter>Header Files</Filter>\r\n    </QtMoc>\r\n  </ItemGroup>\r\n  <ItemGroup>\r\n    <None Include=\"BSPicon24.png\">\r\n      <Filter>Resource Files</Filter>\r\n    </None>\r\n    <None Include=\"alteraBSPGenerator.json\" />\r\n  </ItemGroup>\r\n  <ItemGroup>\r\n    <ClInclude Include=\"alterabspgenerator_global.h\">\r\n      <Filter>Header Files</Filter>\r\n    </ClInclude>\r\n  </ItemGroup>\r\n</Project>"
  },
  {
    "path": "Plugins/AlteraBSPGenerator/alteraBSPGenerator.json",
    "content": "{\r\n\t\"Keys\": [ \"Altera BSP generator\" ]\r\n}"
  },
  {
    "path": "Plugins/AlteraBSPGenerator/alterabspgenerator.cpp",
    "content": "/* \r\n *\tCreated on: 15.2.2013\r\n *\tAuthor:\t\tAntti Kamppi\r\n * \tFile name:\talterabspgenerator.cpp\r\n * \tProject:\tKactus 2\r\n*/\r\n\r\n#include \"alterabspgenerator.h\"\r\n\r\n#include <KactusAPI/include/LibraryInterface.h>\r\n\r\n#include <KactusAPI/include/IPluginUtility.h>\r\n\r\n#include <IPXACTmodels/Component/Component.h>\r\n\r\n#include \"alterabspgeneratordialog.h\"\r\n\r\n#include <QDir>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryMapHeaderGenerator::getSettingsWidget()\r\n//-----------------------------------------------------------------------------\r\nAlteraBSPGenerator::AlteraBSPGenerator():\r\nutility_(nullptr)\r\n{\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryMapHeaderGenerator::getName()\r\n//-----------------------------------------------------------------------------\r\nQString AlteraBSPGenerator::getName() const\r\n{\r\n\tstatic QString name(tr(\"Altera BSP Generator\"));\r\n\treturn name;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryMapHeaderGenerator::getVersion()\r\n//-----------------------------------------------------------------------------\r\nQString AlteraBSPGenerator::getVersion() const\r\n{\r\n\tstatic QString version(tr(\"1.0\"));\r\n\treturn version;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryMapHeaderGenerator::getDescription()\r\n//-----------------------------------------------------------------------------\r\nQString AlteraBSPGenerator::getDescription() const\r\n{\r\n    static QString description(tr(\"Generates board support package for CPU component.\"));\r\n    return description;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryMapHeaderGenerator::getVendor()\r\n//-----------------------------------------------------------------------------\r\nQString AlteraBSPGenerator::getVendor() const\r\n{\r\n    static QString vendor(tr(\"Tampere University (tuni.fi)\"));\r\n    return vendor;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryMapHeaderGenerator::getLicense()\r\n//-----------------------------------------------------------------------------\r\nQString AlteraBSPGenerator::getLicense() const\r\n{\r\n    static QString license(tr(\"GPL2\"));\r\n    return license;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryMapHeaderGenerator::getLicenseHolder()\r\n//-----------------------------------------------------------------------------\r\nQString AlteraBSPGenerator::getLicenseHolder() const\r\n{\r\n    static QString holder(tr(\"Public\"));\r\n    return holder;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryMapHeaderGenerator::getSettingsWidget()\r\n//-----------------------------------------------------------------------------\r\nQWidget* AlteraBSPGenerator::getSettingsWidget()\r\n{\r\n    return nullptr;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryMapHeaderGenerator::getIcon()\r\n//-----------------------------------------------------------------------------\r\nQIcon AlteraBSPGenerator::getIcon() const\r\n{\r\n    return QIcon(\":icons/BSPicon24.png\");\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryMapHeaderGenerator::checkGeneratorSupport()\r\n//-----------------------------------------------------------------------------\r\nbool AlteraBSPGenerator::checkGeneratorSupport(QSharedPointer<Component const> component,\r\n    QSharedPointer<Design const> design,\r\n    QSharedPointer<DesignConfiguration const> designConfiguration) const\r\n{\r\n\t// BSP package can only be run on component editor \r\n\tif (design || designConfiguration)\r\n    {\r\n\t\treturn false;\r\n\t}\r\n\r\n    // Must have a component.\r\n    if (!component)\r\n    {\r\n        return false;\r\n    }\r\n\t\r\n\t// HW component must be CPU and contain at least one view.\r\n\tif (component->getImplementation() == KactusAttribute::HW)\r\n    {\r\n\t\treturn component->isCpu() && component->getViews()->size() > 0;\r\n    }\r\n\r\n\t// By default, always return false.\r\n\treturn false;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryMapHeaderGenerator::runGenerator()\r\n//-----------------------------------------------------------------------------\r\nvoid AlteraBSPGenerator::runGenerator(IPluginUtility* utility, \r\n    QSharedPointer<Component> component,\r\n    QSharedPointer<Design> /*design*/,\r\n    QSharedPointer<DesignConfiguration> /*designConfiguration*/)\r\n{\r\n\tutility_ = utility;\r\n\tQ_ASSERT(utility_);\r\n\r\n\tQ_ASSERT(component);\r\n\r\n\t\r\n\tAlteraBSPGeneratorDialog dialog(utility_->getLibraryInterface(), component, utility_->getParentWidget());\r\n\r\n\tint result = dialog.exec();\r\n\r\n\t// if user did not want to add the generated files to the component metadata.\r\n\tif (result == QDialog::Rejected)\r\n    {\r\n\t\treturn;\r\n\t}\r\n\r\n\t// the path to the component's xml file for creating the relative paths.\r\n\tQString xmlPath = utility_->getLibraryInterface()->getPath(component->getVlnv());\r\n\r\n\t// contains the file type settings for adding files\r\n\tQSettings settings;\r\n\r\n\t// if nothing is changed then no saving is necessary\r\n\tbool modified = false;\r\n\r\n\t// package the generated files to component metadata\r\n\tconst QList<AlteraBSPGeneratorDialog::GenerationOptions>& genOptions = dialog.getCreatedDirs();\r\n\tforeach (const AlteraBSPGeneratorDialog::GenerationOptions& opt, genOptions) {\r\n\r\n\t\tmodified = true;\r\n\r\n\t\tQString fileSetName = QString(\"%1_bsp\").arg(opt.swViewName_);\r\n\r\n\t\t// find the file set and if none exists then create one\r\n\t\tQSharedPointer<FileSet> fileSet = component->getFileSet(fileSetName);\r\n\t\tfileSet->setGroups(\"generatedFiles\");\r\n\t\tfileSet->setDescription(tr(\"Contains the BSP files generated by Altera tools for SW view %1\").arg(opt.swViewName_));\r\n\r\n\t\t// find the contents of the directory\r\n\t\tQDir genDir(opt.dirPath_);\r\n\r\n\t\t// search the file system for generated files\r\n\t\tforeach (QFileInfo const& entry,\r\n            genDir.entryInfoList(QDir::NoDotAndDotDot | QDir::NoSymLinks | QDir::Files | QDir::Dirs))\r\n        {\r\n\t\t\taddEntry(entry, xmlPath, fileSet, settings);\r\n\t\t}\r\n\r\n        QSharedPointer<View> swView = component->getModel()->findView(opt.swViewName_);\r\n        Q_ASSERT(swView);\r\n\r\n        QSharedPointer<ComponentInstantiation> insta =\r\n            component->getModel()->findComponentInstantiation(swView->getComponentInstantiationRef());\r\n\r\n        if (insta)\r\n        {\r\n\t\t\tQSharedPointer<FileSetRef> newFileSetRef(new FileSetRef());\r\n\t\t\tnewFileSetRef->setReference(fileSetName);\r\n            insta->getFileSetReferences()->append(newFileSetRef);\r\n        }\r\n\t}\r\n\r\n\tif (modified)\r\n    {\r\n\t\t// save the changes to the file sets and SW views\r\n\t\tutility_->getLibraryInterface()->writeModelToFile(component);\r\n\t}\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryMapHeaderGenerator::addEntry()\r\n//-----------------------------------------------------------------------------\r\nvoid AlteraBSPGenerator::addEntry(const QFileInfo &entry,\r\n\tconst QString& xmlPath,\r\n\tQSharedPointer<FileSet> fileSet,\r\n\tQSettings& settings) {\r\n\r\n\t// Non-existing entries are not packaged\r\n\tif (!entry.exists()) {\r\n\t\treturn;\r\n\t}\r\n\r\n\tQString relPath = General::getRelativePath(xmlPath, entry.absoluteFilePath());\r\n\tQ_ASSERT(!relPath.isEmpty());\r\n\r\n\tif (entry.isFile()) {\r\n\t\tfileSet->addFile(relPath, settings);\r\n\t}\r\n\telse if (entry.isDir()) {\r\n\t\tfileSet->addDependency(relPath);\r\n\t}\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryMapHeaderGenerator::getProgramRequirements()\r\n//-----------------------------------------------------------------------------\r\nQList<IPlugin::ExternalProgramRequirement> AlteraBSPGenerator::getProgramRequirements() {\r\n\tQList<IPlugin::ExternalProgramRequirement> list;\r\n\r\n\t// windows uses the batch file to run cygwin\r\n#ifdef Q_OS_WIN32\r\n\tIPlugin::ExternalProgramRequirement batchFile;\r\n\tbatchFile.name_ = AlteraBSPGeneratorDialog::VARIABLE_NAMES[AlteraBSPGeneratorDialog::WIN_PATH];\r\n\tbatchFile.filters_ = tr(\"Batch files (*.bat)\");\r\n\tbatchFile.description_ = tr(\"The batch file which starts the Nios II command shell for windows. \"\r\n\t\t\"Usually named as \\\"Nios II Command Shell.bat\\\".\");\r\n\tlist.append(batchFile);\r\n\r\n\t// others run the shell script\r\n#else\r\n\tIPlugin::ExternalProgramRequirement shellFile;\r\n\tshellFile.name_ = AlteraBSPGeneratorDialog::VARIABLE_NAMES[AlteraBSPGeneratorDialog::LINUX_PATH];\r\n\tshellFile.filters_ = tr(\"Shell scripts (*.sh)\");\r\n\tshellFile.description_ = tr(\"The shell script which sets the environment variables for \"\r\n\t\t\"Nios II Command shell. Usually named as \\\"nios2_command_shell.sh\\\"\");\r\n\tlist.append(shellFile);\r\n#endif\r\n\r\n\treturn list;\r\n}\r\n"
  },
  {
    "path": "Plugins/AlteraBSPGenerator/alterabspgenerator.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: alterabspgenerator.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 15.2.2013\r\n//\r\n// Description:\r\n// Generator plugin for Altera Board Support Package (BSP) files.\r\n//-----------------------------------------------------------------------------\r\n\r\n\r\n#ifndef ALTERABSPGENERATOR_H\r\n#define ALTERABSPGENERATOR_H\r\n\r\n#include \"alterabspgenerator_global.h\"\r\n\r\n#include <KactusAPI/include/IGeneratorPlugin.h>\r\n\r\n#include <IPXACTmodels/common/Document.h>\r\n#include <IPXACTmodels/Component/FileSet.h>\r\n\r\n#include <QFileInfo>\r\n\r\nclass IPluginUtility;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Generator plugin for Altera Board Support Package (BSP) files.\r\n//-----------------------------------------------------------------------------\r\nclass ALTERABSPGENERATOR_EXPORT AlteraBSPGenerator : public QObject, public IGeneratorPlugin\r\n{\r\n\tQ_OBJECT\r\n\tQ_PLUGIN_METADATA(IID \"kactus2.plugins.AlteraBSPGenerator\" FILE \"alteraBSPGenerator.json\")\r\n\r\n\tQ_INTERFACES(IPlugin)\r\n\tQ_INTERFACES(IGeneratorPlugin)\r\n\r\npublic:\r\n\r\n\t/*!  The constructor\r\n\t *\r\n\t * Method: \t\tAlteraBSPGenerator\r\n\t * Full name:\tAlteraBSPGenerator::AlteraBSPGenerator\r\n\t * Access:\t\tpublic \r\n\t *\r\n\t*/\r\n\tAlteraBSPGenerator();\r\n\r\n    //!  No copying\r\n    AlteraBSPGenerator(const AlteraBSPGenerator& other) = delete;\r\n\r\n    //!  No assignment\r\n    AlteraBSPGenerator& operator=(const AlteraBSPGenerator& other) = delete;\r\n\r\n\t//!  The destructor\r\n\tvirtual ~AlteraBSPGenerator() = default;\r\n\r\n\t//!  Returns the name of the plugin.\r\n    virtual QString getName() const override final;\r\n\r\n\t//!  Returns the version of the plugin.\r\n    virtual QString getVersion() const override final;\r\n\r\n\t//!  Returns the description of the plugin.\r\n    virtual QString getDescription() const override final;\r\n\r\n    /*!\r\n     *  Returns the vendor of the plugin.\r\n     */\r\n    virtual QString getVendor() const override final;\r\n\r\n    /*!\r\n     *  Returns the license of the plugin.\r\n     */\r\n    virtual QString getLicense() const override final;\r\n\r\n    /*!\r\n     *  Returns the holder of the license of the plugin.\r\n     */\r\n    virtual QString getLicenseHolder() const override final;\r\n\r\n\t//!  Returns the icon for the generator.\r\n    /*!\r\n     *  Returns the settings widget.\r\n     */\r\n    virtual QWidget* getSettingsWidget() override final;\r\n\r\n    /*!\r\n     *  This is used to access the settings modified by function getSettingsWidget().\r\n     */\r\n    virtual PluginSettingsModel* getSettingsModel() override final {return nullptr;}\r\n\r\n    /*!\r\n     *  Returns the icon for the generator.\r\n     */\r\n    virtual QIcon getIcon() const override final;\r\n\r\n    /*!\r\n     *  Checks whether the generator may run for the given component or design. \r\n     *\r\n     *    @param [in] component\t        The component for which to check support. If design is not null, component\r\n\t *                                      will refer to design or designConfiguration.\r\n     *    @param [in] design\t            The design, if the generator is ran for a design.\r\n     *    @param [in] designConfiguration The design configuration for design, if it is not null.\r\n     *\r\n     *    @return True, if the generator may run the given component. Otherwise false.\r\n     */\r\n    virtual bool checkGeneratorSupport(QSharedPointer<Component const> component,\r\n        QSharedPointer<Design const> design,\r\n        QSharedPointer<DesignConfiguration const> designConfiguration) const override final;\r\n\r\n    /*!\r\n     *  Runs the generation, creating new files and/or modifying the IP-XACT metadata. The function has\r\n\t *  also access to the parent window widget, so that it can show dialogs for the user to aid the generation.\r\n     *\r\n     *    @param [in] utility\t\t\t    The plugin utility interface.\r\n     *    @param [in] component\t        The component for which to check support. If design is not null, component\r\n     *                                      will refer to design or designConfiguration.\r\n     *    @param [in] design\t            The design, if the generator is ran for a design.\r\n     *    @param [in] designConfiguration The design configuration for design, if it is not null.\r\n     */\r\n    virtual void runGenerator(IPluginUtility* utility, \r\n        QSharedPointer<Component> component,\r\n        QSharedPointer<Design> design,\r\n        QSharedPointer<DesignConfiguration> designConfiguration) override final;\r\n\r\n\t //!  Returns the external program requirements of the plugin.\r\n\t virtual QList<IPlugin::ExternalProgramRequirement> getProgramRequirements() override final;\r\n\r\nprivate:\r\n\r\n\t/*!\r\n\t * Parse the entries in the file system and add them to specified file set.\r\n\t *\r\n\t *    @param [in] entry    The entry to add.\r\n\t *    @param [in] xmlPath  Path to the top component xml file.\r\n\t *    @param [in] fileSet  The file set to add the entries to.\r\n\t *    @param [in] settings  Contains the file type settings.\r\n\t */\r\n\t void addEntry(const QFileInfo &entry, const QString& xmlPath, QSharedPointer<FileSet> fileSet,\r\n\t\tQSettings& settings);\r\n\r\n\t//! The plugin utility.\r\n\tIPluginUtility* utility_;\r\n};\r\n\r\n#endif // ALTERABSPGENERATOR_H\r\n"
  },
  {
    "path": "Plugins/AlteraBSPGenerator/alterabspgenerator_global.h",
    "content": "/* \r\n *\tCreated on:\t18.4.2013\r\n *\tAuthor:\t\tAntti Kamppi\r\n *\tFile name:\talterabspgenerator_global.h\r\n *\tProject:\t\tKactus 2\r\n*/\r\n\r\n#ifndef ALTERABSPGENERATOR_GLOBAL_H\r\n#define ALTERABSPGENERATOR_GLOBAL_H\r\n\r\n#include <QtCore/qglobal.h>\r\n\r\n#ifdef ALTERABSPGENERATOR_LIB\r\n# define ALTERABSPGENERATOR_EXPORT Q_DECL_EXPORT\r\n#else\r\n# define ALTERABSPGENERATOR_EXPORT Q_DECL_IMPORT\r\n#endif\r\n\r\n#endif // ALTERABSPGENERATOR_GLOBAL_H\r\n"
  },
  {
    "path": "Plugins/AlteraBSPGenerator/alterabspgeneratordialog.cpp",
    "content": "/* \r\n *\tCreated on:\t19.4.2013\r\n *\tAuthor:\t\tAntti Kamppi\r\n *\tFile name:\talterabspgeneratordialog.cpp\r\n *\tProject:\t\tKactus 2\r\n*/\r\n\r\n#include \"alterabspgeneratordialog.h\"\r\n#include <KactusAPI/include/LibraryInterface.h>\r\n#include <IPXACTmodels/Component/Component.h>\r\n\r\n#include <QFormLayout>\r\n#include <QFileDialog>\r\n#include <QGuiApplication>\r\n#include <QCursor>\r\n\r\nconst QString AlteraBSPGeneratorDialog::VARIABLE_NAMES[AlteraBSPGeneratorDialog::VARIABLE_COUNT] = {\r\n\t\"NIOS_COMMAND_SHELL_WIN\",\r\n\t\"NIOS_COMMAND_SHELL_LINUX\"\r\n};\r\n\r\nAlteraBSPGeneratorDialog::AlteraBSPGeneratorDialog(LibraryInterface* handler, \r\n\tQSharedPointer<Component> component, \r\n\tQWidget *parent):\r\nCommandLineGeneratorDialog(parent),\r\n\thandler_(handler),\r\n\tcomponent_(component),\r\nviewSelector_(NULL),\r\ndirButton_(NULL),\r\ncommandLabel_(NULL), \r\noutPutDirLabel_(NULL),\r\nsourceLabel_(NULL),\r\nargLabel_(NULL),\r\ntargetDir_(),\r\ncurrentView_(),\r\ngeneratedPaths_() {\r\n\r\n\tQ_ASSERT(handler_);\r\n\tQ_ASSERT(component_);\r\n\r\n\tsetMinimumWidth(600);\r\n\tsetMinimumHeight(400);\r\n\r\n\tviewSelector_ = new ViewSelector(ViewSelector::BOTH_HW_VIEWS, component, this, false);\r\n\tviewSelector_->refresh();\r\n\tconnect(viewSelector_, SIGNAL(viewSelected(const QString&)),\r\n\t\tthis, SLOT(onViewChange(const QString&)), Qt::UniqueConnection);\r\n\tdirButton_ = new QPushButton(tr(\"Select...\"), this);\r\n\tconnect(dirButton_, SIGNAL(clicked(bool)),\r\n\t\tthis, SLOT(onSelectOutput()), Qt::UniqueConnection);\r\n\tQFormLayout* settingsLayout = new QFormLayout();\r\n\tsettingsLayout->setFieldGrowthPolicy(QFormLayout::FieldsStayAtSizeHint);\r\n\tsettingsLayout->addRow(tr(\"1. Select SW view\"), viewSelector_);\r\n\tsettingsLayout->addRow(tr(\"2. Select output BSP directory\"), dirButton_);\r\n\r\n\tQLabel* commandName = new QLabel(tr(\"Command:\"), this);\r\n\tcommandLabel_ = new QLabel(this);\r\n\toutPutDirLabel_ = new QLabel(this);\r\n\tsourceLabel_ = new QLabel(this);\r\n\targLabel_ = new QLabel(this);\r\n\r\n\tQVBoxLayout* topLayout = new QVBoxLayout(this);\r\n\ttopLayout->addLayout(settingsLayout);\r\n\ttopLayout->addWidget(commandName, 0, Qt::AlignLeft);\r\n\ttopLayout->addWidget(commandLabel_, 0, Qt::AlignLeft);\r\n\ttopLayout->addWidget(outPutDirLabel_, 0, Qt::AlignLeft);\r\n\ttopLayout->addWidget(sourceLabel_, 0, Qt::AlignLeft);\r\n\ttopLayout->addWidget(argLabel_, 0, Qt::AlignLeft);\r\n\ttopLayout->addWidget(outputBox_, 1);\r\n\ttopLayout->addLayout(statusLayout_);\r\n\ttopLayout->addLayout(buttonLayout_);\r\n\r\n\tprocess_ = new QProcess(this);\r\n\tQStringList environment = QProcess::systemEnvironment();\r\n\tprocess_->setEnvironment(environment);\r\n\tconnectProcessToOutput();\r\n\r\n\t// by default the target directory is on the root of the component\r\n\ttargetDir_ = handler_->getDirectoryPath(component_->getVlnv());\r\n\ttargetDir_.append(\"/BSP\");\r\n\r\n\tonViewChange(viewSelector_->currentText());\r\n}\r\n\r\nAlteraBSPGeneratorDialog::~AlteraBSPGeneratorDialog() {\r\n}\r\n\r\nvoid AlteraBSPGeneratorDialog::onViewChange( const QString& viewName ) {\r\n\r\n    currentView_ = component_->getModel()->findView(viewName);\r\n\r\n\tQ_ASSERT(currentView_);\r\n\r\n\tupdateCommand();\r\n}\r\n\r\nvoid AlteraBSPGeneratorDialog::onSelectOutput() {\r\n\tQString newTarget = QFileDialog::getExistingDirectory(this, tr(\"Select directory to generate BSP to.\"),\r\n\t\ttargetDir_);\r\n\r\n\t// if user selected a directory\r\n\tif (!newTarget.isEmpty()) {\r\n\t\ttargetDir_ = newTarget;\r\n\t\tupdateCommand();\r\n\t}\r\n}\r\n\r\nvoid AlteraBSPGeneratorDialog::updateCommand() {\r\n\tQString command(\"[COMMAND MISSING]\");\r\n\tQString sourceFile(\"[SOURCE_FILE MISSING]\");\r\n\tQString args(\"[ARGUMENTS MISSING]\");\r\n\tQString cpuName(\"[CPU_NAME MISSING]\");\r\n\r\n\tQ_ASSERT(currentView_);\r\n\r\n    QString instaRef = currentView_->getComponentInstantiationRef();\r\n\r\n    QSharedPointer<ComponentInstantiation> insta = component_->getModel()->findComponentInstantiation(instaRef);\r\n    QSharedPointer<FileBuilder> com;\r\n\r\n    if (insta && insta->getDefaultFileBuilders()->size() > 0)\r\n    {\r\n\t    com = insta->getDefaultFileBuilders()->first();\r\n    }\r\n\r\n\tif (com)\r\n    {\r\n\t\t// only the defined elements are set\r\n\t\tif (!com->getCommand().isEmpty())\r\n        {\r\n\t\t\tcommand = com->getCommand();\r\n\t\t}\r\n\r\n\t\t// search the for the source file\r\n\t\tQString sourceFileType = com->getFileType().type_;\r\n\t\tQStringList sourceFiles = component_->findFilesByFileType(sourceFileType);\r\n\t\t\r\n\t\t// if theres exactly one file that matches\r\n\t\tif (sourceFiles.size() == 1)\r\n        {\r\n\t\t\tQString xmlPath = handler_->getPath(component_->getVlnv());\r\n\t\t\tsourceFile = General::getAbsolutePath(xmlPath, sourceFiles.first());\r\n\t\t}\r\n\t\t// if there are several source files.\r\n\t\telse if (sourceFiles.size() > 1)\r\n        {\r\n\t\t\tsourceFile = tr(\"[SEVERAL SOURCE FILES FOUND]\");\r\n\t\t}\r\n\r\n\t\t// arguments may not be necessary\r\n\t\targs = com->getFlags();\r\n\t}\r\n\r\n// \tQString wholeCommand = QString(\"%1 %2 %3 %4 --cpu-name %5\").arg(command).arg(targetDir_).arg(\r\n// \t\tsourceFile).arg(args).arg(cpuName);\r\n\r\n\tcommandLabel_->setText(command);\r\n\toutPutDirLabel_->setText(targetDir_);\r\n\tsourceLabel_->setText(sourceFile);\r\n\targLabel_->setText(args);\r\n}\r\n\r\nvoid AlteraBSPGeneratorDialog::onRunClicked() {\r\n\t// clear previous prints\r\n\toutput_->clear();\r\n\r\n\tQGuiApplication::setOverrideCursor(QCursor(Qt::WaitCursor));\r\n\r\n\t// make sure the output path exists\r\n\tQDir targetDirPath(targetDir_);\r\n\tQString dirName = targetDirPath.dirName();\r\n\ttargetDirPath.cdUp();\r\n\ttargetDirPath.mkpath(dirName);\r\n\r\n\t// on windows the command prompt is run and commands written to it\r\n#ifdef Q_OS_WIN32\r\n\r\n\trunWindowsCommands();\r\n\r\n\t// others run the shell script\r\n#else\r\n\trunOtherCommands();\r\n#endif\r\n\r\n\t// add the target dir to the list to remember where the generator is run.\r\n\tQ_ASSERT(currentView_);\r\n\r\n\tgeneratedPaths_.append(AlteraBSPGeneratorDialog::GenerationOptions(targetDir_ + \"/\", currentView_->name()));\r\n\r\n\tQGuiApplication::restoreOverrideCursor();\r\n}\r\n\r\nvoid AlteraBSPGeneratorDialog::runWindowsCommands() {\r\n\tprocess_->start(\"cmd\");\r\n\r\n\t// if process can not be started successfully\r\n\tif (!process_->waitForStarted()) {\r\n\t\toutput_->printError(tr(\"Process could not be started successfully.\"));\r\n\t\tstatusLabel_->setText(tr(\"Could not start.\"));\r\n\t\tprocess_->close();\r\n\t\treturn;\r\n\t}\r\n\r\n\t// inform user that batch file is run\r\n\tprocess_->write(\"echo Running the batch file to start the Nios II command shell.\\n\");\r\n\r\n\t// find the saved path\r\n\tQSettings settings;\r\n\tQString batchPath = settings.value(\"K2Variables/\" +\r\n\t\tAlteraBSPGeneratorDialog::VARIABLE_NAMES[AlteraBSPGeneratorDialog::WIN_PATH] +\r\n\t\t\"/value\").toString();\r\n\r\n\t// run the batch file\r\n\tQString batchCom = \"\\\"\" + batchPath + \"\\\"\\n\";\r\n\tprocess_->write(batchCom.toLatin1());\r\n\r\n\trunCygwinCommands();\r\n}\r\n\r\nvoid AlteraBSPGeneratorDialog::runOtherCommands() {\r\n\tprocess_->start(\"/bin/bash\");\r\n\r\n\t// if process can not be started successfully\r\n\tif (!process_->waitForStarted()) {\r\n\t\toutput_->printError(tr(\"Process could not be started successfully.\"));\r\n\t\tstatusLabel_->setText(tr(\"Could not start.\"));\r\n\t\tprocess_->close();\r\n\t\treturn;\r\n\t}\r\n\r\n\t// inform user that batch file is run\r\n\tprocess_->write(\"echo Running the shell script to set the environment variables for Nios II tools.\\n\");\r\n\r\n\t// find the saved path\r\n\tQSettings settings;\r\n\tQString batchPath = settings.value(\"K2Variables/\" +\r\n\t\tAlteraBSPGeneratorDialog::VARIABLE_NAMES[AlteraBSPGeneratorDialog::LINUX_PATH] +\r\n\t\t\"/value\").toString();\r\n\r\n\t// run the batch file\r\n\tQString batchCom = \"\\\"\" + batchPath + \"\\\"\\n\";\r\n\tprocess_->write(batchCom.toLatin1());\r\n\r\n\trunCygwinCommands();\r\n}\r\n\r\nconst QList<AlteraBSPGeneratorDialog::GenerationOptions>& AlteraBSPGeneratorDialog::getCreatedDirs() const {\r\n\treturn generatedPaths_;\r\n}\r\n\r\nvoid AlteraBSPGeneratorDialog::runCygwinCommands() {\r\n\t// convert the output dir path\r\n\tQString outputComPath = QString(\"export kactus2Target=\\\"$(cygpath -u '%1')\\\"\\n\").arg(outPutDirLabel_->text());\r\n\tprocess_->write(outputComPath.toLatin1());\r\n\r\n\tQString sourceFilePath = QString(\"export kactus2Source=\\\"$(cygpath -u '%1')\\\"\\n\").arg(sourceLabel_->text());\r\n\tprocess_->write(sourceFilePath.toLatin1());\r\n\r\n\t// print the saved paths\r\n\tprocess_->write(\"echo The converted output directory path:\\n\");\r\n\tprocess_->write(\"echo $kactus2Target\\n\");\r\n\tprocess_->write(\"echo \\n\");\r\n\tprocess_->write(\"echo The converted source file path:\\n\");\r\n\tprocess_->write(\"echo $kactus2Source\\n\");\r\n\r\n\tprocess_->write(\"echo \\n\");\r\n\tprocess_->write(\"echo Path variables set, running the generation command...\\n\");\r\n\tprocess_->write(\"echo \\n\");\r\n\r\n\tQString bspCommand = QString(\"%1 $kactus2Target $kactus2Source %3\\n\").arg(\r\n\t\tcommandLabel_->text()).arg(argLabel_->text());\r\n\r\n\tprocess_->write(bspCommand.toLatin1());\r\n\r\n\tprocess_->write(\"exit\\n\");\r\n\r\n\tprocess_->write(\"exit\\n\");\r\n\tprocess_->waitForBytesWritten();\r\n\tif (!process_->waitForFinished()) {\r\n\t\toutput_->printError(tr(\"Process could not be finished successfully.\"));\r\n\t\tstatusLabel_->setText(tr(\"Could not finish.\"));\r\n\t\tprocess_->close();\r\n\t\treturn;\r\n\t}\r\n\r\n\tprocess_->close();\r\n}\r\n\r\nAlteraBSPGeneratorDialog::GenerationOptions::GenerationOptions( const QString& path, const QString& view ):\r\ndirPath_(path), \r\nswViewName_(view) {\r\n}\r\n"
  },
  {
    "path": "Plugins/AlteraBSPGenerator/alterabspgeneratordialog.h",
    "content": "/* \r\n *\tCreated on:\t19.4.2013\r\n *\tAuthor:\t\tAntti Kamppi\r\n *\tFile name:\talterabspgeneratordialog.h\r\n *\tProject:\t\tKactus 2\r\n*/\r\n\r\n#ifndef ALTERABSPGENERATORDIALOG_H\r\n#define ALTERABSPGENERATORDIALOG_H\r\n\r\n#include \"commandlinegeneratordialog.h\"\r\n\r\n#include <common/widgets/viewSelector/viewselector.h>\r\n\r\n#include <IPXACTmodels/Component/Component.h>\r\n\r\nclass LibraryInterface;\r\n\r\n/*! \\brief The dialog to generate the BSP for a CPU component.\r\n *\r\n */\r\nclass AlteraBSPGeneratorDialog : public CommandLineGeneratorDialog {\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\r\n\t//! \\brief The indexes for variables\r\n\tenum VariableIndex {\r\n\t\tWIN_PATH = 0,\r\n\t\tLINUX_PATH,\r\n\t\tVARIABLE_COUNT\r\n\t};\r\n\r\n\t//! \\brief Defines the names for the required variables.\r\n\tstatic const QString VARIABLE_NAMES[VARIABLE_COUNT];\r\n\r\n\t//! \\brief Used to remember where and to which sw view the generator is run.\r\n\tstruct GenerationOptions {\r\n\r\n\t\t//! \\brief The path to the directory used as base for the generator.\r\n\t\tQString dirPath_;\r\n\r\n\t\t//! \\brief The name of the SW view the generator is run for.\r\n\t\tQString swViewName_;\r\n\r\n\t\t//! \\brief The constructor.\r\n\t\tGenerationOptions(const QString& path, const QString& view);\r\n\t};\r\n\r\n\t//! \\brief The name of the script to run when running the generator.\r\n\tstatic const QString PROCESS_START_COMMAND;\r\n\r\n\t/*! \\brief The constructor.\r\n\t *\r\n\t * Method: \t\tAlteraBSPGeneratorDialog\r\n\t * Full name:\tAlteraBSPGeneratorDialog::AlteraBSPGeneratorDialog\r\n\t * Access:\t\tprivate \r\n\t *\r\n\t * \\param component Pointer to the component to generate BSP for.\r\n\t * \\param parent Pointer to the owner of the dialog.\r\n\t *\r\n\t*/\r\n\tAlteraBSPGeneratorDialog(LibraryInterface* handler, \r\n\t\tQSharedPointer<Component> component,\r\n\t\tQWidget *parent);\r\n\t\r\n\t//! \\brief The destructor.\r\n\tvirtual ~AlteraBSPGeneratorDialog();\r\n\r\n\t/*! \\brief Get list of the directories where the generator was run.\r\n\t *\r\n\t * Method: \t\tgetCreatedDirs\r\n\t * Full name:\tAlteraBSPGeneratorDialog::getCreatedDirs\r\n\t * Access:\t\tpublic \r\n\t *\r\n\t *\r\n\t * \\return QStringList containing the absolute paths to the directories.\r\n\t*/\r\n\tconst QList<GenerationOptions>& getCreatedDirs() const;\r\n\r\nprotected slots:\r\n\r\n\t\t//! \\brief Handler for clicks on run button.\r\n\t\tvirtual void onRunClicked();\r\n\r\nprivate slots:\r\n\r\n\t//! \\brief Handler for changes in SW view selector.\r\n\tvoid onViewChange(const QString& viewName);\r\n\r\n\t//! \\brief Handler for clicks on output dir button.\r\n\tvoid onSelectOutput();\r\n\r\nprivate:\r\n\t\r\n\t//! \\brief No copying\r\n\tAlteraBSPGeneratorDialog(const AlteraBSPGeneratorDialog& other);\r\n\r\n\t//! \\brief No assignment\r\n\tAlteraBSPGeneratorDialog& operator=(const AlteraBSPGeneratorDialog& other);\r\n\r\n\t//! \\brief Update the command to generate the BSP.\r\n\tvoid updateCommand();\r\n\r\n\t//! \\brief Run the generator for windows.\r\n\tvoid runWindowsCommands();\r\n\r\n\t//! \\brief Run the generator for Linux-based systems.\r\n\tvoid runOtherCommands();\r\n\r\n\t//! \\brief Runs the cygwin-commands which are common for all systems.\r\n\tvoid runCygwinCommands();\r\n\r\n\t//! \\brief The instance which manages the library.\r\n\tLibraryInterface* handler_;\r\n\r\n\t//! \\brief Pointer to the component to generate the BSP for.\r\n\tQSharedPointer<Component> component_;\r\n\r\n\t//! \\brief Combo box to select a SW view of the component.\r\n\tViewSelector* viewSelector_;\r\n\r\n\t//! \\brief The button for user to select the output directory.\r\n\tQPushButton* dirButton_;\r\n\r\n\t//! \\brief Displays the command to be run.\r\n\tQLabel* commandLabel_;\r\n\r\n\t//! \\brief Displays the output directory\r\n\tQLabel* outPutDirLabel_;\r\n\r\n\t//! \\brief Displays the source file path\r\n\tQLabel* sourceLabel_;\r\n\r\n\t//! \\brief Displays the arguments for the command.\r\n\tQLabel* argLabel_;\r\n\r\n\t//! \\brief The path to the directory to generate the BSP to.\r\n\tQString targetDir_;\r\n\r\n\t//! \\brief The currently selected SW view.\r\n\tQSharedPointer<View> currentView_;\r\n\r\n\t//! \\brief Contains the paths to directories where the generator is run.\r\n\tQList<GenerationOptions> generatedPaths_;\r\n};\r\n\r\n#endif // ALTERABSPGENERATORDIALOG_H\r\n"
  },
  {
    "path": "Plugins/AlteraBSPGenerator/commandlineconsole.cpp",
    "content": "/* \r\n *\tCreated on:\t23.4.2013\r\n *\tAuthor:\t\tAntti Kamppi\r\n *\tFile name:\tcommandlineconsole.cpp\r\n *\tProject:\t\tKactus2\r\n*/\r\n\r\n#include \"commandlineconsole.h\"\r\n#include <common/KactusColors.h>\r\n\r\nCommandLineConsole::CommandLineConsole(QWidget *parent):\r\nQTextEdit(parent) {\r\n\r\n\tsetReadOnly(true);\r\n}\r\n\r\nCommandLineConsole::~CommandLineConsole() {\r\n}\r\n\r\nvoid CommandLineConsole::printStandard( const QString& text ) {\r\n\tif (text.isEmpty()) {\r\n\t\treturn;\r\n\t}\r\n\r\n\tmoveCursor(QTextCursor::End);\r\n\r\n\t// notices are printed in blue\r\n\tsetTextColor(KactusColors::REGULAR_MESSAGE);\r\n\tinsertPlainText(text);\r\n\r\n\t// set cursor to the end of the text\r\n\tmoveCursor(QTextCursor::End);\r\n}\r\n\r\nvoid CommandLineConsole::printError( const QString& text ) {\r\n\tif (text.isEmpty()) {\r\n\t\treturn;\r\n\t}\r\n\r\n\tmoveCursor(QTextCursor::End);\r\n\r\n\t// errors are printed in red color\r\n\tsetTextColor(KactusColors::ERROR);\r\n\tinsertPlainText(text);\r\n\r\n\t// set cursor to the end of the text\r\n\tmoveCursor(QTextCursor::End);\r\n}\r\n"
  },
  {
    "path": "Plugins/AlteraBSPGenerator/commandlineconsole.h",
    "content": "/* \r\n *\tCreated on:\t23.4.2013\r\n *\tAuthor:\t\tAntti Kamppi\r\n *\tFile name:\tcommandlineconsole.h\r\n *\tProject:\t\tKactus2\r\n*/\r\n\r\n#ifndef COMMANDLINECONSOLE_H\r\n#define COMMANDLINECONSOLE_H\r\n\r\n#include <QTextEdit>\r\n\r\n/*! \\brief Used to print standard and error output from other processes run through Kactus2.\r\n * \r\n */\r\nclass CommandLineConsole : public QTextEdit {\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\r\n\t/*! \\brief The constructor.\r\n\t *\r\n\t * Method: \t\tCommandLineConsole\r\n\t * Full name:\tCommandLineConsole::CommandLineConsole\r\n\t * Access:\t\tprivate \r\n\t *\r\n\t * \\param parent Pointer to the owner of the console.\r\n\t *\r\n\t*/\r\n\tCommandLineConsole(QWidget *parent);\r\n\t\r\n\t//! \\brief The destructor.\r\n\tvirtual ~CommandLineConsole();\r\n\r\npublic slots:\r\n\r\n\t//! \\brief Print the text as normal.\r\n\tvoid printStandard(const QString& text);\r\n\r\n\t//! \\brief Print the text as error.\r\n\tvoid printError(const QString& text);\r\n\r\nprivate:\r\n\t\r\n\t//! \\brief No copying\r\n\tCommandLineConsole(const CommandLineConsole& other);\r\n\r\n\t//! \\brief No assignment\r\n\tCommandLineConsole& operator=(const CommandLineConsole& other);\r\n};\r\n\r\n#endif // COMMANDLINECONSOLE_H\r\n"
  },
  {
    "path": "Plugins/AlteraBSPGenerator/commandlinegeneratordialog.cpp",
    "content": "/* \r\n *\tCreated on:\t19.4.2013\r\n *\tAuthor:\t\tAntti Kamppi\r\n *\tFile name:\tcommandlinegeneratordialog.cpp\r\n *\tProject:\t\tKactus 2\r\n*/\r\n\r\n#include \"commandlinegeneratordialog.h\"\r\n\r\n#include <QString>\r\n#include <QByteArray>\r\n\r\nCommandLineGeneratorDialog::CommandLineGeneratorDialog(QWidget *parent):\r\nQDialog(parent),\r\noutput_(NULL),\r\noutputBox_(NULL),\r\nprocess_(NULL),\r\nbuttonLayout_(NULL),\r\nstatusLayout_(NULL),\r\nstatusLabel_(NULL),\r\nrunButton_(NULL),\r\nokButton_(NULL),\r\ncancelButton_(NULL)\r\n{\r\n\tQLabel* statusName = new QLabel(tr(\"Status: \"), this);\r\n\tstatusLabel_ = new QLabel(tr(\"Waiting\"), this);\r\n\tstatusLayout_ = new QHBoxLayout();\r\n\tstatusLayout_->addWidget(statusName);\r\n\tstatusLayout_->addWidget(statusLabel_);\r\n\tstatusLayout_->addStretch();\r\n\r\n\toutputBox_ = new QGroupBox(tr(\"Output\"), this);\r\n\tQHBoxLayout* boxLayout = new QHBoxLayout(outputBox_);\r\n\toutput_ = new CommandLineConsole(outputBox_);\r\n\tboxLayout->addWidget(output_);\r\n\r\n\t// set up the buttons\r\n\trunButton_ = new QPushButton(tr(\"Run\"), this);\r\n\tokButton_ = new QPushButton(tr(\"Ok\"), this);\r\n\tcancelButton_ = new QPushButton(tr(\"Cancel\"), this);\r\n\tbuttonLayout_ = new QHBoxLayout();\r\n\tbuttonLayout_->addStretch();\r\n\tbuttonLayout_->addWidget(runButton_, 0, Qt::AlignRight);\r\n\tbuttonLayout_->addWidget(okButton_, 0, Qt::AlignRight);\r\n\tbuttonLayout_->addWidget(cancelButton_, 0, Qt::AlignRight);\r\n\tconnect(runButton_, SIGNAL(clicked(bool)),\r\n\t\tthis, SLOT(onRunClicked()), Qt::UniqueConnection);\r\n\tconnect(okButton_, SIGNAL(clicked(bool)),\r\n\t\tthis, SLOT(accept()), Qt::UniqueConnection);\r\n\tconnect(cancelButton_, SIGNAL(clicked(bool)),\r\n\t\tthis, SLOT(reject()), Qt::UniqueConnection);\r\n}\r\n\r\nCommandLineGeneratorDialog::~CommandLineGeneratorDialog()\r\n{\r\n}\r\n\r\nvoid CommandLineGeneratorDialog::connectProcessToOutput()\r\n{\r\n\t// the process is set up in sub-class but it has to be done before calling this function.\r\n\tQ_ASSERT(process_);\r\n\r\n\tconnect(process_, SIGNAL(readyReadStandardOutput()),\r\n\t\tthis, SLOT(onStandardOutputRead()), Qt::UniqueConnection);\r\n\tconnect(process_, SIGNAL(readyReadStandardError()),\r\n\t\tthis, SLOT(onStandardErrorRead()), Qt::UniqueConnection);\r\n\tconnect(process_, SIGNAL(started()),\r\n\t\tthis, SLOT(onProcessStarted()), Qt::UniqueConnection);\r\n\tconnect(process_, SIGNAL(finished(int, QProcess::ExitStatus)),\r\n\t\tthis, SLOT(onProcessFinished(int, QProcess::ExitStatus)), Qt::UniqueConnection);\r\n}\r\n\r\nvoid CommandLineGeneratorDialog::onStandardOutputRead()\r\n{\r\n\tQString output(process_->readAllStandardOutput());\r\n\toutput_->printStandard(output);\r\n}\r\n\r\nvoid CommandLineGeneratorDialog::onStandardErrorRead()\r\n{\r\n\tQString output(process_->readAllStandardError());\r\n\toutput_->printError(output);\r\n}\r\n\r\nvoid CommandLineGeneratorDialog::onProcessStarted()\r\n{\r\n\tstatusLabel_->setText(tr(\"Running...\"));\r\n}\r\n\r\nvoid CommandLineGeneratorDialog::onProcessFinished(int exitCode, QProcess::ExitStatus exitStatus)\r\n{\r\n\tQString text;\r\n\r\n\tswitch (exitStatus) {\r\n\tcase QProcess::NormalExit: {\r\n\t\ttext.append(tr(\"Finished normally \"));\r\n\t\tbreak;\r\n\t\t\t\t\t\t\t\t\t\t}\r\n\tdefault: {\r\n\t\ttext.append(tr(\"Crashed \"));\r\n\t\tbreak;\r\n\t\t\t\t}\r\n\t}\r\n\r\n\ttext.append(tr(\"with exit code %1.\").arg(exitCode));\r\n\tstatusLabel_->setText(text);\r\n}\r\n"
  },
  {
    "path": "Plugins/AlteraBSPGenerator/commandlinegeneratordialog.h",
    "content": "/* \r\n *\tCreated on:\t19.4.2013\r\n *\tAuthor:\t\tAntti Kamppi\r\n *\tFile name:\tcommandlinegeneratordialog.h\r\n *\tProject:\t\tKactus 2\r\n*/\r\n\r\n#ifndef COMMANDLINEGENERATORDIALOG_H\r\n#define COMMANDLINEGENERATORDIALOG_H\r\n\r\n#include \"commandlineconsole.h\"\r\n\r\n#include <QDialog>\r\n#include <QProcess>\r\n#include <QPushButton>\r\n#include <QHBoxLayout>\r\n#include <QGroupBox>\r\n#include <QLabel>\r\n\r\n/*! \\brief Dialog which can be used as base class for generators which run other programs in separate process.\r\n * \r\n * This class must be sub-classed and can not be used as such.\r\n * Sub-classes must set up the top layout for the dialog.\r\n */\r\nclass CommandLineGeneratorDialog : public QDialog {\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\r\n\t/*! \\brief The constructor.\r\n\t *\r\n\t * Method: \t\tCommandLineGeneratorDialog\r\n\t * Full name:\tCommandLineGeneratorDialog::CommandLineGeneratorDialog\r\n\t * Access:\t\tprivate \r\n\t *\r\n\t * \\param parent Pointer to the owner of the dialog.\r\n\t *\r\n\t*/\r\n\tCommandLineGeneratorDialog(QWidget *parent);\r\n\t\r\n\t//! \\brief The destructor.\r\n\tvirtual ~CommandLineGeneratorDialog();\r\n\r\nprotected slots:\r\n\r\n\t//! \\brief Handler for clicks on run button, this must be implemented in sub-classes.\r\n\tvirtual void onRunClicked() = 0;\r\n\r\nprotected:\r\n\r\n\t//! \\brief Connects the signals from process to the output message console. Create the process before calling this.\r\n\tvoid connectProcessToOutput();\r\n\r\n\t//! \\brief The message box displaying the output from the process.\r\n\tCommandLineConsole* output_;\r\n\r\n\t//! \\brief The group box which contains the output message console.\r\n\tQGroupBox* outputBox_;\r\n\r\n\t//! \\brief The process which is run. This must be set in the sub-class.\r\n\tQProcess* process_;\r\n\r\n\t//! \\brief Layout for the buttons on the lower right corner.\r\n\tQHBoxLayout* buttonLayout_;\r\n\r\n\t//! \\brief The layout for the status name and label.\r\n\tQHBoxLayout* statusLayout_;\r\n\r\n\t//! \\brief The label displaying the status of the process.\r\n\tQLabel* statusLabel_;\r\n\r\nprivate slots:\r\n\r\n\t//! \\brief When process has data to read from standard output (stdout) this prints it to output console.\r\n\tvoid onStandardOutputRead();\r\n\r\n\t//! \\brief When process has data to read from standard error (stderr) this prints it to output console.\r\n\tvoid onStandardErrorRead();\r\n\r\n\t//! \\brief Handler for process' started()-signal.\r\n\tvoid onProcessStarted();\r\n\r\n\t//! \\brief Handler for process' finished()-signal.\r\n\tvoid onProcessFinished(int exitCode, QProcess::ExitStatus exitStatus);\r\n\r\nprivate:\r\n\t\r\n\t//! \\brief No copying\r\n\tCommandLineGeneratorDialog(const CommandLineGeneratorDialog& other);\r\n\r\n\t//! \\brief No assignment\r\n\tCommandLineGeneratorDialog& operator=(const CommandLineGeneratorDialog& other);\r\n\r\n\t//! \\brief Button to run the generator.\r\n\tQPushButton* runButton_;\r\n\r\n\t//! \\brief Button to accept changes.\r\n\tQPushButton* okButton_;\r\n\r\n\t//! \\brief Button to cancel changes.\r\n\tQPushButton* cancelButton_;\r\n};\r\n\r\n#endif // COMMANDLINEGENERATORDIALOG_H\r\n"
  },
  {
    "path": "Plugins/CppSourceAnalyzer/CppSourceAnalyzer.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: CppSourceAnalyzer.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Honkonen, Joni-Matti Maatta\r\n// Date: 18.1.2013\r\n//\r\n// Description:\r\n// C/C++ source analyzer plugin.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"CppSourceAnalyzer.h\"\r\n\r\n#include <QCryptographicHash>\r\n#include <QTextStream>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: CppSourceAnalyzer::CppSourceAnalyzer()\r\n//-----------------------------------------------------------------------------\r\nCppSourceAnalyzer::CppSourceAnalyzer(): fileTypes_()\r\n{\r\n    fileTypes_.append(\"cSource\");\r\n    fileTypes_.append(\"cppSource\");\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: CppSourceAnalyzer::getName()\r\n//----------------------------------------------------------------------------\r\nQString CppSourceAnalyzer::getName() const\r\n{\r\n    return \"C/C++ Source Analyzer\";\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: CppSourceAnalyzer::getVersion()\r\n//-----------------------------------------------------------------------------\r\nQString CppSourceAnalyzer::getVersion() const\r\n{\r\n    return \"1.1\";\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: CppSourceAnalyzer::getDescription()\r\n//-----------------------------------------------------------------------------\r\nQString CppSourceAnalyzer::getDescription() const\r\n{\r\n    return \"Analyzes file dependencies from C/C++ files.\";\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: CppSourceAnalyzer::getVendor()\r\n//-----------------------------------------------------------------------------\r\nQString CppSourceAnalyzer::getVendor() const\r\n{\r\n    return tr(\"Tampere University (tuni.fi)\");\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: CppSourceAnalyzer::getLicense()\r\n//-----------------------------------------------------------------------------\r\nQString CppSourceAnalyzer::getLicense() const\r\n{\r\n    return tr(\"GPL2\");\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: CppSourceAnalyzer::getLicenseHolder()\r\n//-----------------------------------------------------------------------------\r\nQString CppSourceAnalyzer::getLicenseHolder() const\r\n{\r\n    return tr(\"Public\");\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: CppSourceAnalyzer::getSettingsWidget()\r\n//-----------------------------------------------------------------------------\r\nQWidget* CppSourceAnalyzer::getSettingsWidget()\r\n{\r\n    return nullptr;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: CppSourceAnalyzer::getSupportedFileTypes()\r\n//-----------------------------------------------------------------------------\r\nQStringList CppSourceAnalyzer::getSupportedFileTypes() const\r\n{\r\n    return fileTypes_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: CppSourceAnalyzer::calculateHash()\r\n//-----------------------------------------------------------------------------\r\nQString CppSourceAnalyzer::calculateHash(QString const& filename)\r\n{\r\n    // Try to open the file\r\n    QFile file(filename);\r\n    if (!file.open(QIODevice::ReadOnly | QIODevice::Text) )\r\n    {\r\n        // File could not be opened, show error\r\n        return 0;\r\n    }\r\n\r\n    QString source = getSourceData(file);\r\n\r\n    // Calculate the hash\r\n    QCryptographicHash hash(QCryptographicHash::Sha1);\r\n    hash.addData(source.toLatin1());\r\n\r\n    QString result = hash.result().toHex();\r\n    return result;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: CppSourceAnalyzer::getFileDependencies()\r\n//-----------------------------------------------------------------------------\r\nQList<FileDependencyDesc> CppSourceAnalyzer::getFileDependencies(Component const* /*component*/,\r\n                                            QString const& /*componentPath*/,\r\n                                            QString const& filename)\r\n{\r\n    QList<FileDependencyDesc> dependencies;\r\n\r\n    QFile file(filename);\r\n    if (file.open(QIODevice::ReadOnly | QIODevice::Text) )\r\n    {\r\n        QString source = getSourceData(file);\r\n\r\n        // Find #includes\r\n        QTextStream sourceStream(&source);\r\n        while(!sourceStream.atEnd())\r\n        {\r\n            const QString currentLine = sourceStream.readLine();\r\n            int includePosition = currentLine.indexOf(\"#include\");\r\n            // include found (can they be somewhere else than start of line?)\r\n            if (includePosition == 0)\r\n            {\r\n                FileDependencyDesc dependency;\r\n\r\n                int includeStart = 0;\r\n                int includeEnd = 0;\r\n                // includes with < >\r\n                if (currentLine.indexOf(\"<\") != -1)\r\n                {\r\n                    includeStart = currentLine.indexOf(\"<\") + 1;\r\n                    includeEnd = currentLine.indexOf(\">\");\r\n                }\r\n                // includes with \" \"\r\n                else\r\n                {\r\n                    includeStart = currentLine.indexOf(\"\\\"\") + 1;\r\n                    includeEnd = currentLine.indexOf(\"\\\"\", includeStart+1);\r\n                }\r\n                // Include found, TODO: store it\r\n                QString includeName = currentLine.mid(includeStart, includeEnd-includeStart);\r\n                dependency.filename = includeName;\r\n                dependencies.append(dependency);\r\n            }\r\n        }\r\n    }\r\n\r\n    return dependencies;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: CppSourceAnalyzer::getSourceData()\r\n//-----------------------------------------------------------------------------\r\nQString CppSourceAnalyzer::getSourceData(QFile& file)\r\n{\r\n    // Read the file data\r\n    QString fileData;\r\n    while (!file.atEnd())\r\n    {\r\n        QString line = file.readLine();\r\n        line = line.simplified();\r\n\r\n        if (line == \"\")\r\n        {\r\n            // Skip empty lines\r\n            continue;\r\n        }\r\n\r\n        // check if the line ends in backslash (split line) \r\n        while (line.length() > 0 && line.at(line.length()-1) == '\\\\')\r\n        {\r\n            line = line.left(line.length()-1);\r\n            QString nextLine = file.readLine();\r\n            line.append(nextLine.simplified());\r\n        }\r\n\r\n        fileData.append(line.append(\"\\n\"));\r\n    }\r\n    \r\n    // Remove comments from the source\r\n    QString finalData = removeComments(fileData);\r\n\r\n    return finalData;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: CppSourceAnalyzer::removeComments()\r\n//-----------------------------------------------------------------------------\r\nQString CppSourceAnalyzer::removeComments(QString const& source)\r\n{\r\n    QString finalData = source;\r\n    QStringList includes;\r\n\r\n    QRegularExpression tokenExp(\"(/\\\\*|//|\\\"|#include)\");\r\n    QRegularExpression stringEndExp(\"(\\\\\\\\\\\"|\\\"|\\n)\");\r\n\r\n    int index = finalData.indexOf(tokenExp);\r\n    auto tokenMatch = tokenExp.match(finalData);\r\n\r\n    while (tokenMatch.hasMatch())\r\n    {\r\n        auto token = tokenMatch.captured(1);\r\n        \r\n        if (token == \"#include\")\r\n        {\r\n            // Extract include\r\n            int endIndex = finalData.indexOf('\\n', index + tokenMatch.capturedLength());\r\n\r\n            if (endIndex == -1)\r\n            {\r\n                endIndex = finalData.length();\r\n            }\r\n\r\n            includes.append(finalData.sliced(index, endIndex - index));\r\n            finalData.remove(index, endIndex - index);\r\n            index = index + 1;\r\n        }\r\n        else if (token == \"//\")\r\n        {\r\n            // Single-line comment. Strip to the end of the line.\r\n            int endIndex = finalData.indexOf('\\n', index + tokenMatch.capturedLength());\r\n\r\n            if (endIndex == -1)\r\n            {\r\n                endIndex = finalData.length();\r\n            }\r\n\r\n            finalData.remove(index, endIndex - index);\r\n            index = index + 1;\r\n        }\r\n        else if (token == \"/*\")\r\n        {\r\n            // Multi-line string begins. Strip to the end marker.\r\n            int endIndex = finalData.indexOf(\"*/\", index + tokenMatch.capturedLength());\r\n\r\n            if (endIndex == -1)\r\n            {\r\n                endIndex = finalData.length();\r\n            }\r\n            else\r\n            {\r\n                endIndex += 2;\r\n            }\r\n            \r\n            finalData.remove(index, endIndex - index);\r\n            index = index + 1;\r\n        }\r\n        else if (token == \"\\\"\")\r\n        {\r\n            // Strip entire string\r\n            int endIndex = finalData.indexOf(\"\\\"\", index + tokenMatch.capturedLength());\r\n\r\n            if (endIndex == -1)\r\n            {\r\n                endIndex = finalData.length();\r\n            }\r\n            else\r\n            {\r\n                endIndex += 1;\r\n            }\r\n\r\n            finalData.remove(index, endIndex - index);\r\n            index = endIndex;\r\n        }\r\n\r\n        index = finalData.indexOf(tokenExp, index);\r\n        tokenMatch = tokenExp.match(finalData);\r\n    }\r\n\r\n    for (auto it = includes.crbegin(); it != includes.crend(); ++it)\r\n    {\r\n        finalData.prepend(*it + \"\\n\");\r\n    }\r\n\r\n    return finalData;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: CppSourceAnalyzer::beginAnalysis()\r\n//-----------------------------------------------------------------------------\r\nvoid CppSourceAnalyzer::beginAnalysis(Component const* /*component*/, QString const& /*componentPath*/)\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: CppSourceAnalyzer::endAnalysis()\r\n//-----------------------------------------------------------------------------\r\nvoid CppSourceAnalyzer::endAnalysis(Component const* /*component*/, QString const& /*componentPath*/)\r\n{\r\n\r\n}\r\n\r\nQList<IPlugin::ExternalProgramRequirement> CppSourceAnalyzer::getProgramRequirements()\r\n{\r\n\treturn QList<IPlugin::ExternalProgramRequirement>();\r\n}\r\n"
  },
  {
    "path": "Plugins/CppSourceAnalyzer/CppSourceAnalyzer.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: CppSourceAnalyzer.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Honkonen, Joni-Matti Maatta\r\n// Date: 18.1.2013\r\n//\r\n// Description:\r\n// C/C++ source analyzer plugin.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef CPPSOURCEANALYZER_H\r\n#define CPPSOURCEANALYZER_H\r\n\r\n#include <KactusAPI/include/ISourceAnalyzerPlugin.h>\r\n\r\n#include <QFile>\r\n#include <QString>\r\n\r\n//-----------------------------------------------------------------------------\r\n// C/C++ source analyzer plugin.\r\n//-----------------------------------------------------------------------------\r\nclass CppSourceAnalyzer : public QObject, public ISourceAnalyzerPlugin\r\n{\r\n    Q_OBJECT\r\n    Q_PLUGIN_METADATA(IID \"kactus2.plugins.CppSourceAnalyzer\" FILE \"CppSourceAnalyzer.json\")\r\n\r\n    Q_INTERFACES(IPlugin)\r\n    Q_INTERFACES(ISourceAnalyzerPlugin)\r\n\r\npublic:\r\n\r\n    //! The constructor.\r\n    CppSourceAnalyzer();\r\n\r\n    // Disable copying.\r\n    CppSourceAnalyzer(CppSourceAnalyzer const& rhs) = delete;\r\n    CppSourceAnalyzer& operator=(CppSourceAnalyzer const& rhs) = delete;\r\n\r\n    //! The destructor.\r\n    virtual ~CppSourceAnalyzer() = default;\r\n\r\n    /*!\r\n     *  Returns the name of the plugin.\r\n     */\r\n    virtual QString getName() const override final;\r\n\r\n    /*!\r\n     *  Returns the version of the plugin.\r\n     */\r\n    virtual QString getVersion() const override final;\r\n\r\n    /*!\r\n     *  Returns the description of the plugin.\r\n     */\r\n    virtual QString getDescription() const override final;\r\n\r\n    /*!\r\n     *  Returns the vendor of the plugin.\r\n     */\r\n    virtual QString getVendor() const override final;\r\n\r\n    /*!\r\n     *  Returns the license of the plugin.\r\n     */\r\n    virtual QString getLicense() const override final;\r\n\r\n    /*!\r\n     *  Returns the holder of the license of the plugin.\r\n     */\r\n    virtual QString getLicenseHolder() const override final;\r\n\r\n    /*!\r\n     *  Returns the settings widget.\r\n     */\r\n    virtual QWidget* getSettingsWidget() override final;\r\n\r\n    /*!\r\n     *  This is used to access the settings modified by function getSettingsWidget().\r\n     */\r\n    virtual PluginSettingsModel* getSettingsModel() override final  {return nullptr;}\r\n\r\n    /*!\r\n     *  Returns the list of file types this plugin can run analysis for.\r\n     */\r\n    virtual QStringList getSupportedFileTypes() const override final;\r\n\r\n    /*!\r\n     *  Calculates a language-dependent hash for the given file.\r\n     *\r\n     *    @param [in] filename  The name of the file.\r\n     *\r\n     *    @return The hash value for the file.\r\n     *\r\n     *      @remarks Comments and whitespace are ignored and do not affect the hash value.\r\n     */\r\n    virtual QString calculateHash(QString const& filename) override final;\r\n\r\n    /*!\r\n     *  Begins the analysis for the given component.\r\n     *\r\n     *    @param [in] component       The component to which the dependency scan is being run.\r\n     *    @param [in] componentPath  The path to the directory where the component is located.\r\n     *\r\n     *      @remarks Any preparations needed for the file dependency analysis should be made here.\r\n     */\r\n    virtual void beginAnalysis(Component const* component, QString const& componentPath) override final;\r\n\r\n    /*!\r\n     *  Ends the analysis for the given component.\r\n     *\r\n     *    @param [in] component       The component to which the dependency scan is being run.\r\n     *    @param [in] componentPath  The path to the directory where the component is located.\r\n     *\r\n     *      @remarks Any cleanups needed should be made here.\r\n     */\r\n    virtual void endAnalysis(Component const* component, QString const& componentPath) override final;\r\n\r\n    /*!\r\n     *  Retrieves all file dependencies the given file has.\r\n     *\r\n     *    @param [in]  component      The component to which the dependency scan is being run.\r\n     *    @param [in]  componentPath  The path to the directory where the component is located.\r\n     *    @param [in]  filename       The name of the file to which the analysis is run.\r\n     *    @param [out] dependencies   The list of found dependencies.\r\n     */\r\n    virtual QList<FileDependencyDesc> getFileDependencies(Component const* component,\r\n                                     QString const& componentPath,\r\n                                     QString const& filename) override final;\r\n\r\n\t //! Returns the external program requirements of the plugin.\r\n\t virtual QList<IPlugin::ExternalProgramRequirement> getProgramRequirements() override final;\r\n\r\n    /*!\r\n     *\r\n     * Reads source file data from given file. Used by calulateHash and getFileDependencies.\r\n     *\r\n     *    @param [in] file    The file that is read.\r\n     *\r\n     *    @return The meaningful source data of the file, with comments and empty lines removed.\r\n     */\r\n    QString getSourceData(QFile& file);\r\n\r\nprivate:\r\n\r\n\r\n    /*!\r\n     *\r\n     * Removes comments from a string that consists of a C/C++ source code\r\n     *\r\n     *    @param [inout] data    The input source code with comments.\r\n     *\r\n     *    @return The meaningful source data of the file, with comments removed.\r\n     */\r\n    QString removeComments(QString const& source);\r\n    \r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! The supported file types.\r\n    QStringList fileTypes_;\r\n};\r\n\r\n#endif // CPPSOURCEANALYZER_H\r\n"
  },
  {
    "path": "Plugins/CppSourceAnalyzer/CppSourceAnalyzer.json",
    "content": "{\r\n\t\"Keys\": [ \"C++\" ]\r\n}"
  },
  {
    "path": "Plugins/CppSourceAnalyzer/CppSourceAnalyzer.pri",
    "content": "# ----------------------------------------------------\r\n# This file is generated by the Qt Visual Studio Add-in.\r\n# ------------------------------------------------------\r\n\r\nHEADERS += ./CppSourceAnalyzer.h\r\n\r\nSOURCES += ./CppSourceAnalyzer.cpp\r\n"
  },
  {
    "path": "Plugins/CppSourceAnalyzer/CppSourceAnalyzer.pro",
    "content": "# ----------------------------------------------------\r\n# This file is generated by the Qt Visual Studio Add-in.\r\n# ------------------------------------------------------\r\n\r\nTEMPLATE = lib\r\n\r\nQT += core xml widgets gui\r\n\r\nCONFIG += c++11 plugin\r\nDEFINES += CPPSOURCEANALYZER_LIB\r\n\r\nINCLUDEPATH += ./GeneratedFiles \\\r\n    . \\\r\n    ./../.. \r\n\r\nDESTDIR = ../../executable/Plugins\r\n\r\nCONFIG(debug, debug|release) {\r\n    # debug mode\r\n    MOC_DIR += ./GeneratedFiles/Debug\r\n    OBJECTS_DIR += Debug\r\n    TARGET = CppSourceAnalyzerd\r\n\r\n} else {\r\n    # release mode     \r\n    MOC_DIR += ./GeneratedFiles/Release\r\n    OBJECTS_DIR += Release\r\n    TARGET = CppSourceAnalyzer\r\n}\r\n\r\nDEPENDPATH += .\r\nUI_DIR += ./GeneratedFiles\r\nRCC_DIR += ./GeneratedFiles\r\n\r\ninclude(CppSourceAnalyzer.pri)\r\n\r\ntarget.path = $$plugin_path\r\nINSTALLS += target\r\n"
  },
  {
    "path": "Plugins/CppSourceAnalyzer/CppSourceAnalyzer.vcproj",
    "content": "<?xml version=\"1.0\" encoding=\"Windows-1252\"?>\r\n<VisualStudioProject\r\n\tProjectType=\"Visual C++\"\r\n\tVersion=\"9,00\"\r\n\tName=\"CppSourceAnalyzer\"\r\n\tProjectGUID=\"{D47FBAF4-1642-4F73-837C-F289DCB9E8FE}\"\r\n\tKeyword=\"Qt4VSv1.0\"\r\n\tTargetFrameworkVersion=\"0\"\r\n\t>\r\n\t<Platforms>\r\n\t\t<Platform\r\n\t\t\tName=\"Win32\"\r\n\t\t/>\r\n\t\t<Platform\r\n\t\t\tName=\"x64\"\r\n\t\t/>\r\n\t</Platforms>\r\n\t<ToolFiles>\r\n\t</ToolFiles>\r\n\t<Configurations>\r\n\t\t<Configuration\r\n\t\t\tName=\"Release|Win32\"\r\n\t\t\tOutputDirectory=\"$(SolutionDir)\\executable\\Plugins\"\r\n\t\t\tIntermediateDirectory=\"$(SolutionDir)$(ConfigurationName)\"\r\n\t\t\tConfigurationType=\"2\"\r\n\t\t\t>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCPreBuildEventTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCCustomBuildTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCXMLDataGeneratorTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCWebServiceProxyGeneratorTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCMIDLTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCCLCompilerTool\"\r\n\t\t\t\tAdditionalIncludeDirectories=\"&quot;.\\GeneratedFiles&quot;;&quot;$(QTDIR)\\include&quot;;&quot;.\\GeneratedFiles\\$(ConfigurationName)&quot;;&quot;$(QTDIR)\\include\\qtmain&quot;;&quot;$(QTDIR)\\include\\QtCore&quot;;&quot;.\\&quot;;&quot;..\\..\\&quot;;&quot;$(QTDIR)\\include\\QtXml&quot;;&quot;$(QTDIR)\\include\\QtXmlPatterns&quot;;&quot;$(QTDIR)\\include\\QtGui&quot;\"\r\n\t\t\t\tPreprocessorDefinitions=\",UNICODE,WIN32,QT_NO_DEBUG,NDEBUG;QT_CORE_LIB;CPPSOURCEANALYZER_LIB;QT_XML_LIB;QT_XMLPATTERNS_LIB;QT_GUI_LIB;QT_DLL\"\r\n\t\t\t\tRuntimeLibrary=\"2\"\r\n\t\t\t\tTreatWChar_tAsBuiltInType=\"false\"\r\n\t\t\t\tDebugInformationFormat=\"0\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCManagedResourceCompilerTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCResourceCompilerTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCPreLinkEventTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCLinkerTool\"\r\n\t\t\t\tAdditionalDependencies=\"qtmain.lib QtCore4.lib QtXml4.lib QtXmlPatterns4.lib QtGui4.lib Kactus2.lib\"\r\n\t\t\t\tOutputFile=\"$(OutDir)\\$(ProjectName).dll\"\r\n\t\t\t\tAdditionalLibraryDirectories=\"&quot;..\\..\\executable&quot;;&quot;$(QTDIR)\\lib&quot;\"\r\n\t\t\t\tGenerateDebugInformation=\"false\"\r\n\t\t\t\tSubSystem=\"2\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCALinkTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCManifestTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCXDCMakeTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCBscMakeTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCFxCopTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCAppVerifierTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCPostBuildEventTool\"\r\n\t\t\t\tCommandLine=\"\"\r\n\t\t\t/>\r\n\t\t</Configuration>\r\n\t\t<Configuration\r\n\t\t\tName=\"Release|x64\"\r\n\t\t\tOutputDirectory=\"$(SolutionDir)\\x64\\executable\\Plugins\"\r\n\t\t\tIntermediateDirectory=\"$(PlatformName)\\$(ConfigurationName)\"\r\n\t\t\tConfigurationType=\"2\"\r\n\t\t\t>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCPreBuildEventTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCCustomBuildTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCXMLDataGeneratorTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCWebServiceProxyGeneratorTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCMIDLTool\"\r\n\t\t\t\tTargetEnvironment=\"3\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCCLCompilerTool\"\r\n\t\t\t\tAdditionalIncludeDirectories=\"&quot;.\\GeneratedFiles&quot;;&quot;$(QTDIR)\\include&quot;;&quot;.\\GeneratedFiles\\$(ConfigurationName)&quot;;&quot;$(QTDIR)\\include\\qtmain&quot;;&quot;$(QTDIR)\\include\\QtCore&quot;;&quot;.\\&quot;;&quot;..\\..\\&quot;;&quot;$(QTDIR)\\include\\QtXml&quot;;&quot;$(QTDIR)\\include\\QtXmlPatterns&quot;;&quot;$(QTDIR)\\include\\QtGui&quot;\"\r\n\t\t\t\tPreprocessorDefinitions=\",UNICODE,WIN32,QT_NO_DEBUG,NDEBUG;QT_CORE_LIB;CPPSOURCEANALYZER_LIB;QT_XML_LIB;QT_XMLPATTERNS_LIB;QT_GUI_LIB;QT_DLL\"\r\n\t\t\t\tRuntimeLibrary=\"2\"\r\n\t\t\t\tTreatWChar_tAsBuiltInType=\"false\"\r\n\t\t\t\tDebugInformationFormat=\"0\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCManagedResourceCompilerTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCResourceCompilerTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCPreLinkEventTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCLinkerTool\"\r\n\t\t\t\tAdditionalDependencies=\"qtmain.lib QtCore4.lib QtXml4.lib QtXmlPatterns4.lib QtGui4.lib Kactus2.lib\"\r\n\t\t\t\tOutputFile=\"$(OutDir)\\$(ProjectName).dll\"\r\n\t\t\t\tAdditionalLibraryDirectories=\"&quot;..\\..\\x64\\executable&quot;;&quot;$(QTDIR)\\lib&quot;\"\r\n\t\t\t\tGenerateDebugInformation=\"false\"\r\n\t\t\t\tSubSystem=\"2\"\r\n\t\t\t\tTargetMachine=\"17\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCALinkTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCManifestTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCXDCMakeTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCBscMakeTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCFxCopTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCAppVerifierTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCPostBuildEventTool\"\r\n\t\t\t\tCommandLine=\"\"\r\n\t\t\t/>\r\n\t\t</Configuration>\r\n\t\t<Configuration\r\n\t\t\tName=\"Debug|Win32\"\r\n\t\t\tOutputDirectory=\"$(SolutionDir)\\executable\\Plugins\"\r\n\t\t\tIntermediateDirectory=\"$(SolutionDir)$(ConfigurationName)\"\r\n\t\t\tConfigurationType=\"2\"\r\n\t\t\t>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCPreBuildEventTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCCustomBuildTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCXMLDataGeneratorTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCWebServiceProxyGeneratorTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCMIDLTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCCLCompilerTool\"\r\n\t\t\t\tOptimization=\"0\"\r\n\t\t\t\tAdditionalIncludeDirectories=\"&quot;.\\GeneratedFiles&quot;;&quot;$(QTDIR)\\include&quot;;&quot;.\\GeneratedFiles\\$(ConfigurationName)&quot;;&quot;$(QTDIR)\\include\\qtmain&quot;;&quot;$(QTDIR)\\include\\QtCore&quot;;&quot;.\\&quot;;&quot;..\\..\\&quot;;&quot;$(QTDIR)\\include\\QtXml&quot;;&quot;$(QTDIR)\\include\\QtXmlPatterns&quot;;&quot;$(QTDIR)\\include\\QtGui&quot;\"\r\n\t\t\t\tPreprocessorDefinitions=\",UNICODE,WIN32,QT_CORE_LIB;CPPSOURCEANALYZER_LIB;QT_XML_LIB;QT_XMLPATTERNS_LIB;QT_GUI_LIB;QT_DLL\"\r\n\t\t\t\tRuntimeLibrary=\"3\"\r\n\t\t\t\tTreatWChar_tAsBuiltInType=\"false\"\r\n\t\t\t\tDebugInformationFormat=\"3\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCManagedResourceCompilerTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCResourceCompilerTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCPreLinkEventTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCLinkerTool\"\r\n\t\t\t\tAdditionalDependencies=\"qtmaind.lib QtCored4.lib QtXmld4.lib QtXmlPatternsd4.lib QtGuid4.lib Kactus2_d.lib\"\r\n\t\t\t\tOutputFile=\"$(OutDir)\\$(ProjectName).dll\"\r\n\t\t\t\tAdditionalLibraryDirectories=\"&quot;..\\..\\executable&quot;;&quot;$(QTDIR)\\lib&quot;\"\r\n\t\t\t\tGenerateDebugInformation=\"true\"\r\n\t\t\t\tSubSystem=\"2\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCALinkTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCManifestTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCXDCMakeTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCBscMakeTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCFxCopTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCAppVerifierTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCPostBuildEventTool\"\r\n\t\t\t\tCommandLine=\"\"\r\n\t\t\t/>\r\n\t\t</Configuration>\r\n\t\t<Configuration\r\n\t\t\tName=\"Debug|x64\"\r\n\t\t\tOutputDirectory=\"$(SolutionDir)\\x64\\executable\\Plugins\"\r\n\t\t\tIntermediateDirectory=\"$(PlatformName)\\$(ConfigurationName)\"\r\n\t\t\tConfigurationType=\"2\"\r\n\t\t\t>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCPreBuildEventTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCCustomBuildTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCXMLDataGeneratorTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCWebServiceProxyGeneratorTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCMIDLTool\"\r\n\t\t\t\tTargetEnvironment=\"3\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCCLCompilerTool\"\r\n\t\t\t\tOptimization=\"0\"\r\n\t\t\t\tAdditionalIncludeDirectories=\"&quot;.\\GeneratedFiles&quot;;&quot;$(QTDIR)\\include&quot;;&quot;.\\GeneratedFiles\\$(ConfigurationName)&quot;;&quot;$(QTDIR)\\include\\qtmain&quot;;&quot;$(QTDIR)\\include\\QtCore&quot;;&quot;.\\&quot;;&quot;..\\..\\&quot;;&quot;$(QTDIR)\\include\\QtXml&quot;;&quot;$(QTDIR)\\include\\QtXmlPatterns&quot;;&quot;$(QTDIR)\\include\\QtGui&quot;\"\r\n\t\t\t\tPreprocessorDefinitions=\",UNICODE,WIN32,QT_CORE_LIB;CPPSOURCEANALYZER_LIB;QT_XML_LIB;QT_XMLPATTERNS_LIB;QT_GUI_LIB;QT_DLL\"\r\n\t\t\t\tRuntimeLibrary=\"3\"\r\n\t\t\t\tTreatWChar_tAsBuiltInType=\"false\"\r\n\t\t\t\tDebugInformationFormat=\"3\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCManagedResourceCompilerTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCResourceCompilerTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCPreLinkEventTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCLinkerTool\"\r\n\t\t\t\tAdditionalDependencies=\"qtmaind.lib QtCored4.lib QtXmld4.lib QtXmlPatternsd4.lib QtGuid4.lib Kactus2_d.lib\"\r\n\t\t\t\tOutputFile=\"$(OutDir)\\$(ProjectName).dll\"\r\n\t\t\t\tAdditionalLibraryDirectories=\"&quot;..\\..\\x64\\executable&quot;;&quot;$(QTDIR)\\lib&quot;\"\r\n\t\t\t\tGenerateDebugInformation=\"true\"\r\n\t\t\t\tSubSystem=\"2\"\r\n\t\t\t\tTargetMachine=\"17\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCALinkTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCManifestTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCXDCMakeTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCBscMakeTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCFxCopTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCAppVerifierTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCPostBuildEventTool\"\r\n\t\t\t\tCommandLine=\"\"\r\n\t\t\t/>\r\n\t\t</Configuration>\r\n\t</Configurations>\r\n\t<References>\r\n\t</References>\r\n\t<Files>\r\n\t\t<Filter\r\n\t\t\tName=\"Source Files\"\r\n\t\t\tFilter=\"cpp;cxx;c;def\"\r\n\t\t\tUniqueIdentifier=\"{4FC737F1-C7A5-4376-A066-2A32D752A2FF}\"\r\n\t\t\t>\r\n\t\t\t<File\r\n\t\t\t\tRelativePath=\".\\CppSourceAnalyzer.cpp\"\r\n\t\t\t\t>\r\n\t\t\t</File>\r\n\t\t</Filter>\r\n\t\t<Filter\r\n\t\t\tName=\"Header Files\"\r\n\t\t\tFilter=\"h\"\r\n\t\t\tUniqueIdentifier=\"{93995380-89BD-4b04-88EB-625FBE52EBFB}\"\r\n\t\t\t>\r\n\t\t\t<File\r\n\t\t\t\tRelativePath=\".\\CppSourceAnalyzer.h\"\r\n\t\t\t\t>\r\n\t\t\t\t<FileConfiguration\r\n\t\t\t\t\tName=\"Release|Win32\"\r\n\t\t\t\t\t>\r\n\t\t\t\t\t<Tool\r\n\t\t\t\t\t\tName=\"VCCustomBuildTool\"\r\n\t\t\t\t\t\tDescription=\"Moc&apos;ing $(InputFileName)...\"\r\n\t\t\t\t\t\tCommandLine=\"&quot;$(QTDIR)\\bin\\moc.exe&quot;   -DUNICODE -DWIN32 -DQT_NO_DEBUG -DNDEBUG -DQT_CORE_LIB -DCPPSOURCEANALYZER_LIB -DQT_XML_LIB -DQT_XMLPATTERNS_LIB -DQT_GUI_LIB -DQT_DLL -D_WINDLL  &quot;-I.\\GeneratedFiles&quot; &quot;-I$(QTDIR)\\include&quot; &quot;-I.\\GeneratedFiles\\$(ConfigurationName)\\.&quot; &quot;-I$(QTDIR)\\include\\qtmain&quot; &quot;-I$(QTDIR)\\include\\QtCore&quot; &quot;-I.&quot; &quot;-I.\\..\\..&quot; &quot;-I$(QTDIR)\\include\\QtXml&quot; &quot;-I$(QTDIR)\\include\\QtXmlPatterns&quot; &quot;-I$(QTDIR)\\include\\QtGui&quot; &quot;.\\CppSourceAnalyzer.h&quot; -o &quot;.\\GeneratedFiles\\$(ConfigurationName)\\moc_$(InputName).cpp&quot;&#x0D;&#x0A;\"\r\n\t\t\t\t\t\tAdditionalDependencies=\"&quot;$(QTDIR)\\bin\\moc.exe&quot;;$(InputPath)\"\r\n\t\t\t\t\t\tOutputs=\"&quot;.\\GeneratedFiles\\$(ConfigurationName)\\moc_CppSourceAnalyzer.cpp&quot;\"\r\n\t\t\t\t\t/>\r\n\t\t\t\t</FileConfiguration>\r\n\t\t\t\t<FileConfiguration\r\n\t\t\t\t\tName=\"Release|x64\"\r\n\t\t\t\t\t>\r\n\t\t\t\t\t<Tool\r\n\t\t\t\t\t\tName=\"VCCustomBuildTool\"\r\n\t\t\t\t\t\tDescription=\"Moc&apos;ing $(InputFileName)...\"\r\n\t\t\t\t\t\tCommandLine=\"&quot;$(QTDIR)\\bin\\moc.exe&quot;   -DUNICODE -DWIN32 -DQT_NO_DEBUG -DNDEBUG -DQT_CORE_LIB -DCPPSOURCEANALYZER_LIB -DQT_XML_LIB -DQT_XMLPATTERNS_LIB -DQT_GUI_LIB -DQT_DLL -D_WINDLL  &quot;-I.\\GeneratedFiles&quot; &quot;-I$(QTDIR)\\include&quot; &quot;-I.\\GeneratedFiles\\$(ConfigurationName)\\.&quot; &quot;-I$(QTDIR)\\include\\qtmain&quot; &quot;-I$(QTDIR)\\include\\QtCore&quot; &quot;-I.&quot; &quot;-I.\\..\\..&quot; &quot;-I$(QTDIR)\\include\\QtXml&quot; &quot;-I$(QTDIR)\\include\\QtXmlPatterns&quot; &quot;-I$(QTDIR)\\include\\QtGui&quot; &quot;.\\CppSourceAnalyzer.h&quot; -o &quot;.\\GeneratedFiles\\$(ConfigurationName)\\moc_$(InputName).cpp&quot;&#x0D;&#x0A;\"\r\n\t\t\t\t\t\tAdditionalDependencies=\"&quot;$(QTDIR)\\bin\\moc.exe&quot;;$(InputPath)\"\r\n\t\t\t\t\t\tOutputs=\"&quot;.\\GeneratedFiles\\$(ConfigurationName)\\moc_CppSourceAnalyzer.cpp&quot;\"\r\n\t\t\t\t\t/>\r\n\t\t\t\t</FileConfiguration>\r\n\t\t\t\t<FileConfiguration\r\n\t\t\t\t\tName=\"Debug|Win32\"\r\n\t\t\t\t\t>\r\n\t\t\t\t\t<Tool\r\n\t\t\t\t\t\tName=\"VCCustomBuildTool\"\r\n\t\t\t\t\t\tDescription=\"Moc&apos;ing $(InputFileName)...\"\r\n\t\t\t\t\t\tCommandLine=\"&quot;$(QTDIR)\\bin\\moc.exe&quot;   -DUNICODE -DWIN32 -DQT_CORE_LIB -DCPPSOURCEANALYZER_LIB -DQT_XML_LIB -DQT_XMLPATTERNS_LIB -DQT_GUI_LIB -DQT_DLL -D_WINDLL  &quot;-I.\\GeneratedFiles&quot; &quot;-I$(QTDIR)\\include&quot; &quot;-I.\\GeneratedFiles\\$(ConfigurationName)\\.&quot; &quot;-I$(QTDIR)\\include\\qtmain&quot; &quot;-I$(QTDIR)\\include\\QtCore&quot; &quot;-I.&quot; &quot;-I.\\..\\..&quot; &quot;-I$(QTDIR)\\include\\QtXml&quot; &quot;-I$(QTDIR)\\include\\QtXmlPatterns&quot; &quot;-I$(QTDIR)\\include\\QtGui&quot; &quot;.\\CppSourceAnalyzer.h&quot; -o &quot;.\\GeneratedFiles\\$(ConfigurationName)\\moc_$(InputName).cpp&quot;&#x0D;&#x0A;\"\r\n\t\t\t\t\t\tAdditionalDependencies=\"&quot;$(QTDIR)\\bin\\moc.exe&quot;;$(InputPath)\"\r\n\t\t\t\t\t\tOutputs=\"&quot;.\\GeneratedFiles\\$(ConfigurationName)\\moc_CppSourceAnalyzer.cpp&quot;\"\r\n\t\t\t\t\t/>\r\n\t\t\t\t</FileConfiguration>\r\n\t\t\t\t<FileConfiguration\r\n\t\t\t\t\tName=\"Debug|x64\"\r\n\t\t\t\t\t>\r\n\t\t\t\t\t<Tool\r\n\t\t\t\t\t\tName=\"VCCustomBuildTool\"\r\n\t\t\t\t\t\tDescription=\"Moc&apos;ing $(InputFileName)...\"\r\n\t\t\t\t\t\tCommandLine=\"&quot;$(QTDIR)\\bin\\moc.exe&quot;   -DUNICODE -DWIN32 -DQT_CORE_LIB -DCPPSOURCEANALYZER_LIB -DQT_XML_LIB -DQT_XMLPATTERNS_LIB -DQT_GUI_LIB -DQT_DLL -D_WINDLL  &quot;-I.\\GeneratedFiles&quot; &quot;-I$(QTDIR)\\include&quot; &quot;-I.\\GeneratedFiles\\$(ConfigurationName)\\.&quot; &quot;-I$(QTDIR)\\include\\qtmain&quot; &quot;-I$(QTDIR)\\include\\QtCore&quot; &quot;-I.&quot; &quot;-I.\\..\\..&quot; &quot;-I$(QTDIR)\\include\\QtXml&quot; &quot;-I$(QTDIR)\\include\\QtXmlPatterns&quot; &quot;-I$(QTDIR)\\include\\QtGui&quot; &quot;.\\CppSourceAnalyzer.h&quot; -o &quot;.\\GeneratedFiles\\$(ConfigurationName)\\moc_$(InputName).cpp&quot;&#x0D;&#x0A;\"\r\n\t\t\t\t\t\tAdditionalDependencies=\"&quot;$(QTDIR)\\bin\\moc.exe&quot;;$(InputPath)\"\r\n\t\t\t\t\t\tOutputs=\"&quot;.\\GeneratedFiles\\$(ConfigurationName)\\moc_CppSourceAnalyzer.cpp&quot;\"\r\n\t\t\t\t\t/>\r\n\t\t\t\t</FileConfiguration>\r\n\t\t\t</File>\r\n\t\t</Filter>\r\n\t\t<Filter\r\n\t\t\tName=\"Form Files\"\r\n\t\t\tFilter=\"ui\"\r\n\t\t\tUniqueIdentifier=\"{99349809-55BA-4b9d-BF79-8FDBB0286EB3}\"\r\n\t\t\t>\r\n\t\t</Filter>\r\n\t\t<Filter\r\n\t\t\tName=\"Resource Files\"\r\n\t\t\tFilter=\"qrc;*\"\r\n\t\t\tUniqueIdentifier=\"{D9D6E242-F8AF-46E4-B9FD-80ECBC20BA3E}\"\r\n\t\t\tParseFiles=\"false\"\r\n\t\t\t>\r\n\t\t</Filter>\r\n\t\t<Filter\r\n\t\t\tName=\"Generated Files\"\r\n\t\t\tFilter=\"moc;h;cpp\"\r\n\t\t\tUniqueIdentifier=\"{71ED8ED8-ACB9-4CE9-BBE1-E00B30144E11}\"\r\n\t\t\tSourceControlFiles=\"false\"\r\n\t\t\t>\r\n\t\t\t<Filter\r\n\t\t\t\tName=\"Release\"\r\n\t\t\t\tFilter=\"cpp;moc\"\r\n\t\t\t\tSourceControlFiles=\"false\"\r\n\t\t\t\t>\r\n\t\t\t\t<File\r\n\t\t\t\t\tRelativePath=\".\\GeneratedFiles\\Release\\moc_CppSourceAnalyzer.cpp\"\r\n\t\t\t\t\t>\r\n\t\t\t\t\t<FileConfiguration\r\n\t\t\t\t\t\tName=\"Debug|Win32\"\r\n\t\t\t\t\t\tExcludedFromBuild=\"true\"\r\n\t\t\t\t\t\t>\r\n\t\t\t\t\t\t<Tool\r\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\r\n\t\t\t\t\t\t/>\r\n\t\t\t\t\t</FileConfiguration>\r\n\t\t\t\t\t<FileConfiguration\r\n\t\t\t\t\t\tName=\"Debug|x64\"\r\n\t\t\t\t\t\tExcludedFromBuild=\"true\"\r\n\t\t\t\t\t\t>\r\n\t\t\t\t\t\t<Tool\r\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\r\n\t\t\t\t\t\t/>\r\n\t\t\t\t\t</FileConfiguration>\r\n\t\t\t\t</File>\r\n\t\t\t</Filter>\r\n\t\t\t<Filter\r\n\t\t\t\tName=\"Debug\"\r\n\t\t\t\tFilter=\"cpp;moc\"\r\n\t\t\t\tSourceControlFiles=\"false\"\r\n\t\t\t\t>\r\n\t\t\t\t<File\r\n\t\t\t\t\tRelativePath=\".\\GeneratedFiles\\Debug\\moc_CppSourceAnalyzer.cpp\"\r\n\t\t\t\t\t>\r\n\t\t\t\t\t<FileConfiguration\r\n\t\t\t\t\t\tName=\"Release|Win32\"\r\n\t\t\t\t\t\tExcludedFromBuild=\"true\"\r\n\t\t\t\t\t\t>\r\n\t\t\t\t\t\t<Tool\r\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\r\n\t\t\t\t\t\t/>\r\n\t\t\t\t\t</FileConfiguration>\r\n\t\t\t\t\t<FileConfiguration\r\n\t\t\t\t\t\tName=\"Release|x64\"\r\n\t\t\t\t\t\tExcludedFromBuild=\"true\"\r\n\t\t\t\t\t\t>\r\n\t\t\t\t\t\t<Tool\r\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\r\n\t\t\t\t\t\t/>\r\n\t\t\t\t\t</FileConfiguration>\r\n\t\t\t\t</File>\r\n\t\t\t</Filter>\r\n\t\t</Filter>\r\n\t</Files>\r\n\t<Globals>\r\n\t\t<Global\r\n\t\t\tName=\"lreleaseOptions\"\r\n\t\t\tValue=\"\"\r\n\t\t/>\r\n\t\t<Global\r\n\t\t\tName=\"lupdateOnBuild\"\r\n\t\t\tValue=\"0\"\r\n\t\t/>\r\n\t\t<Global\r\n\t\t\tName=\"lupdateOptions\"\r\n\t\t\tValue=\"\"\r\n\t\t/>\r\n\t\t<Global\r\n\t\t\tName=\"MocDir\"\r\n\t\t\tValue=\".\\GeneratedFiles\\$(ConfigurationName)\"\r\n\t\t/>\r\n\t\t<Global\r\n\t\t\tName=\"MocOptions\"\r\n\t\t\tValue=\"\"\r\n\t\t/>\r\n\t\t<Global\r\n\t\t\tName=\"Qt5Version Win32\"\r\n\t\t\tValue=\"4.8.3\"\r\n\t\t/>\r\n\t\t<Global\r\n\t\t\tName=\"QtVersion Win32\"\r\n\t\t\tValue=\"4.8.3\"\r\n\t\t/>\r\n\t\t<Global\r\n\t\t\tName=\"QtVersion x64\"\r\n\t\t\tValue=\"4.8.3 x64\"\r\n\t\t/>\r\n\t\t<Global\r\n\t\t\tName=\"RccDir\"\r\n\t\t\tValue=\".\\GeneratedFiles\"\r\n\t\t/>\r\n\t\t<Global\r\n\t\t\tName=\"UicDir\"\r\n\t\t\tValue=\".\\GeneratedFiles\"\r\n\t\t/>\r\n\t</Globals>\r\n</VisualStudioProject>\r\n"
  },
  {
    "path": "Plugins/CppSourceAnalyzer/CppSourceAnalyzer.vcxproj",
    "content": "﻿<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n<Project DefaultTargets=\"Build\" ToolsVersion=\"15.0\" xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">\r\n  <ItemGroup Label=\"ProjectConfigurations\">\r\n    <ProjectConfiguration Include=\"Debug|x64\">\r\n      <Configuration>Debug</Configuration>\r\n      <Platform>x64</Platform>\r\n    </ProjectConfiguration>\r\n    <ProjectConfiguration Include=\"Release|x64\">\r\n      <Configuration>Release</Configuration>\r\n      <Platform>x64</Platform>\r\n    </ProjectConfiguration>\r\n    <ProjectConfiguration Include=\"Template|x64\">\r\n      <Configuration>Template</Configuration>\r\n      <Platform>x64</Platform>\r\n    </ProjectConfiguration>\r\n  </ItemGroup>\r\n  <PropertyGroup Label=\"Globals\">\r\n    <ProjectGuid>{D47FBAF4-1642-4F73-837C-F289DCB9E8FE}</ProjectGuid>\r\n    <Keyword>QtVS_v304</Keyword>\r\n    <WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>\r\n    <QtMsBuild Condition=\"'$(QtMsBuild)'=='' or !Exists('$(QtMsBuild)\\qt.targets')\">$(MSBuildProjectDirectory)\\QtMsBuild</QtMsBuild>\r\n  </PropertyGroup>\r\n  <Import Project=\"$(VCTargetsPath)\\Microsoft.Cpp.Default.props\" />\r\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Template|x64'\" Label=\"Configuration\">\r\n    <ConfigurationType>Application</ConfigurationType>\r\n    <PlatformToolset>v143</PlatformToolset>\r\n  </PropertyGroup>\r\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\" Label=\"Configuration\">\r\n    <ConfigurationType>DynamicLibrary</ConfigurationType>\r\n    <PlatformToolset>v143</PlatformToolset>\r\n  </PropertyGroup>\r\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\" Label=\"Configuration\">\r\n    <ConfigurationType>DynamicLibrary</ConfigurationType>\r\n    <PlatformToolset>v143</PlatformToolset>\r\n  </PropertyGroup>\r\n  <Import Project=\"$(VCTargetsPath)\\Microsoft.Cpp.props\" />\r\n  <Target Name=\"QtMsBuildNotFound\" BeforeTargets=\"CustomBuild;ClCompile\" Condition=\"!Exists('$(QtMsBuild)\\qt.targets') or !Exists('$(QtMsBuild)\\qt.props')\">\r\n    <Message Importance=\"High\" Text=\"QtMsBuild: could not locate qt.targets, qt.props; project may not build correctly.\" />\r\n  </Target>\r\n  <ImportGroup Label=\"ExtensionSettings\">\r\n  </ImportGroup>\r\n  <ImportGroup Condition=\"'$(Configuration)|$(Platform)'=='Template|x64'\" Label=\"PropertySheets\">\r\n    <Import Project=\"$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props\" Condition=\"exists('$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props')\" Label=\"LocalAppDataPlatform\" />\r\n  </ImportGroup>\r\n  <ImportGroup Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\" Label=\"PropertySheets\">\r\n    <Import Project=\"$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props\" Condition=\"exists('$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props')\" Label=\"LocalAppDataPlatform\" />\r\n  </ImportGroup>\r\n  <ImportGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\" Label=\"PropertySheets\">\r\n    <Import Project=\"$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props\" Condition=\"exists('$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props')\" Label=\"LocalAppDataPlatform\" />\r\n  </ImportGroup>\r\n  <PropertyGroup Label=\"UserMacros\" />\r\n  <ImportGroup Condition=\"Exists('$(QtMsBuild)\\qt_defaults.props')\">\r\n    <Import Project=\"$(QtMsBuild)\\qt_defaults.props\" />\r\n  </ImportGroup>\r\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Template|x64'\">\r\n    <OutDir>$(SolutionDir)executable\\Plugins\\</OutDir>\r\n    <IntDir>$(ProjectDir)\\$(Configuration)\\</IntDir>\r\n  </PropertyGroup>\r\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n    <OutDir>$(SolutionDir)executable\\Plugins\\</OutDir>\r\n    <IntDir>$(ProjectDir)\\$(Configuration)\\</IntDir>\r\n  </PropertyGroup>\r\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n    <OutDir>$(SolutionDir)executable\\Plugins\\</OutDir>\r\n    <IntDir>$(ProjectDir)\\$(Configuration)\\</IntDir>\r\n  </PropertyGroup>\r\n  <PropertyGroup Label=\"QtSettings\" Condition=\"'$(Configuration)|$(Platform)'=='Template|x64'\">\r\n    <QtInstall>6.2.4</QtInstall>\r\n    <QtModules>core;gui;widgets;help;xml</QtModules>\r\n  </PropertyGroup>\r\n  <PropertyGroup Label=\"QtSettings\" Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n    <QtInstall>6.2.4</QtInstall>\r\n    <QtModules>core;gui;widgets;help;xml</QtModules>\r\n  </PropertyGroup>\r\n  <PropertyGroup Label=\"QtSettings\" Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n    <QtInstall>6.2.4</QtInstall>\r\n    <QtModules>core;gui;widgets;help;xml</QtModules>\r\n  </PropertyGroup>\r\n  <ImportGroup Condition=\"Exists('$(QtMsBuild)\\qt.props')\">\r\n    <Import Project=\"$(QtMsBuild)\\qt.props\" />\r\n  </ImportGroup>\r\n  <PropertyGroup>\r\n    <_ProjectFileVersion>10.0.40219.1</_ProjectFileVersion>\r\n  </PropertyGroup>\r\n  <ItemDefinitionGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n    <Midl>\r\n      <TargetEnvironment>X64</TargetEnvironment>\r\n    </Midl>\r\n    <ClCompile>\r\n      <AdditionalIncludeDirectories>.\\GeneratedFiles\\$(ConfigurationName);.\\GeneratedFiles;.\\GeneratedFiles\\$(Configuration);.\\;..\\..\\;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\r\n      <PreprocessorDefinitions>UNICODE;WIN32;QT_NO_DEBUG;NDEBUG;CPPSOURCEANALYZER_LIB;QT_XMLPATTERNS_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>\r\n      <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>\r\n      <TreatWChar_tAsBuiltInType>true</TreatWChar_tAsBuiltInType>\r\n      <DebugInformationFormat>\r\n      </DebugInformationFormat>\r\n      <LanguageStandard>stdcpp17</LanguageStandard>\r\n      <AdditionalOptions>/Zc:__cplusplus %(AdditionalOptions)</AdditionalOptions>\r\n      <MultiProcessorCompilation>true</MultiProcessorCompilation>\r\n    </ClCompile>\r\n    <Link>\r\n      <AdditionalDependencies>IPXACTmodels.lib;KactusAPI.lib;%(AdditionalDependencies)</AdditionalDependencies>\r\n      <OutputFile>$(OutDir)$(ProjectName).dll</OutputFile>\r\n      <AdditionalLibraryDirectories>..\\..\\executable;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>\r\n      <GenerateDebugInformation>false</GenerateDebugInformation>\r\n      <SubSystem>Windows</SubSystem>\r\n      <TargetMachine>MachineX64</TargetMachine>\r\n    </Link>\r\n    <PostBuildEvent>\r\n      <Command>\r\n      </Command>\r\n    </PostBuildEvent>\r\n    <QtMoc>\r\n      <ExecutionDescription>Moc'ing %(Identity)...</ExecutionDescription>\r\n      <DynamicSource>output</DynamicSource>\r\n      <QtMocDir>.\\GeneratedFiles\\$(ConfigurationName)</QtMocDir>\r\n      <QtMocFileName>moc_%(Filename).cpp</QtMocFileName>\r\n    </QtMoc>\r\n  </ItemDefinitionGroup>\r\n  <ItemDefinitionGroup Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n    <Midl>\r\n      <TargetEnvironment>X64</TargetEnvironment>\r\n    </Midl>\r\n    <ClCompile>\r\n      <Optimization>Disabled</Optimization>\r\n      <AdditionalIncludeDirectories>.\\GeneratedFiles\\$(ConfigurationName);.\\GeneratedFiles;.\\GeneratedFiles\\$(Configuration);.\\;..\\..\\;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\r\n      <PreprocessorDefinitions>UNICODE;WIN32;CPPSOURCEANALYZER_LIB;QT_XMLPATTERNS_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>\r\n      <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>\r\n      <TreatWChar_tAsBuiltInType>true</TreatWChar_tAsBuiltInType>\r\n      <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>\r\n      <LanguageStandard>stdcpp17</LanguageStandard>\r\n      <AdditionalOptions>/Zc:__cplusplus %(AdditionalOptions)</AdditionalOptions>\r\n      <MultiProcessorCompilation>true</MultiProcessorCompilation>\r\n    </ClCompile>\r\n    <Link>\r\n      <AdditionalDependencies>IPXACTmodelsd.lib;KactusAPId.lib;%(AdditionalDependencies)</AdditionalDependencies>\r\n      <OutputFile>$(OutDir)$(ProjectName).dll</OutputFile>\r\n      <AdditionalLibraryDirectories>..\\..\\executable;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>\r\n      <GenerateDebugInformation>true</GenerateDebugInformation>\r\n      <SubSystem>Windows</SubSystem>\r\n      <TargetMachine>MachineX64</TargetMachine>\r\n    </Link>\r\n    <PostBuildEvent>\r\n      <Command>\r\n      </Command>\r\n    </PostBuildEvent>\r\n    <QtMoc>\r\n      <ExecutionDescription>Moc'ing %(Identity)...</ExecutionDescription>\r\n      <DynamicSource>output</DynamicSource>\r\n      <QtMocDir>.\\GeneratedFiles\\$(ConfigurationName)</QtMocDir>\r\n      <QtMocFileName>moc_%(Filename).cpp</QtMocFileName>\r\n    </QtMoc>\r\n  </ItemDefinitionGroup>\r\n  <ItemDefinitionGroup Condition=\"'$(Configuration)|$(Platform)'=='Template|x64'\">\r\n    <ClCompile>\r\n      <PreprocessorDefinitions>%(PreprocessorDefinitions)</PreprocessorDefinitions>\r\n      <AdditionalIncludeDirectories>.\\GeneratedFiles\\$(ConfigurationName);.\\GeneratedFiles;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\r\n      <MultiProcessorCompilation>true</MultiProcessorCompilation>\r\n    </ClCompile>\r\n    <Link>\r\n      <AdditionalDependencies>%(AdditionalDependencies)</AdditionalDependencies>\r\n      <AdditionalLibraryDirectories>..\\..\\executable;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>\r\n    </Link>\r\n  </ItemDefinitionGroup>\r\n  <ItemGroup>\r\n    <ClCompile Include=\"CppSourceAnalyzer.cpp\" />\r\n  </ItemGroup>\r\n  <ItemGroup>\r\n    <QtMoc Include=\"CppSourceAnalyzer.h\">\r\n    </QtMoc>\r\n  </ItemGroup>\r\n  <ItemGroup>\r\n    <None Include=\"CppSourceAnalyzer.json\" />\r\n  </ItemGroup>\r\n  <Import Project=\"$(VCTargetsPath)\\Microsoft.Cpp.targets\" />\r\n  <ImportGroup Condition=\"Exists('$(QtMsBuild)\\qt.targets')\">\r\n    <Import Project=\"$(QtMsBuild)\\qt.targets\" />\r\n  </ImportGroup>\r\n  <ImportGroup Label=\"ExtensionTargets\">\r\n  </ImportGroup>\r\n  <ProjectExtensions>\r\n    <VisualStudio>\r\n      <UserProperties QtVersion_x0020_Win32=\"4.8.3\" QtVersion_x0020_x64=\"4.8.3 x64\" />\r\n    </VisualStudio>\r\n  </ProjectExtensions>\r\n</Project>"
  },
  {
    "path": "Plugins/CppSourceAnalyzer/CppSourceAnalyzer.vcxproj.filters",
    "content": "﻿<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n<Project ToolsVersion=\"4.0\" xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">\r\n  <ItemGroup>\r\n    <Filter Include=\"Source Files\">\r\n      <UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>\r\n      <Extensions>cpp;cxx;c;def</Extensions>\r\n    </Filter>\r\n    <Filter Include=\"Header Files\">\r\n      <UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>\r\n      <Extensions>h</Extensions>\r\n    </Filter>\r\n    <Filter Include=\"Resource Files\">\r\n      <UniqueIdentifier>{D9D6E242-F8AF-46E4-B9FD-80ECBC20BA3E}</UniqueIdentifier>\r\n      <Extensions>qrc;*</Extensions>\r\n      <ParseFiles>false</ParseFiles>\r\n    </Filter>\r\n    <Filter Include=\"Generated Files\">\r\n      <UniqueIdentifier>{71ED8ED8-ACB9-4CE9-BBE1-E00B30144E11}</UniqueIdentifier>\r\n      <Extensions>moc;h;cpp</Extensions>\r\n      <SourceControlFiles>False</SourceControlFiles>\r\n    </Filter>\r\n    <Filter Include=\"Generated Files\\Release\">\r\n      <UniqueIdentifier>{e3dde204-e11b-4458-bdeb-652f6ac65a6f}</UniqueIdentifier>\r\n      <Extensions>cpp;moc</Extensions>\r\n      <SourceControlFiles>False</SourceControlFiles>\r\n    </Filter>\r\n    <Filter Include=\"Generated Files\\Debug\">\r\n      <UniqueIdentifier>{3dbdbcb3-43d2-45b2-840e-c8f065fc0cd1}</UniqueIdentifier>\r\n      <Extensions>cpp;moc</Extensions>\r\n      <SourceControlFiles>False</SourceControlFiles>\r\n    </Filter>\r\n  </ItemGroup>\r\n  <ItemGroup>\r\n    <ClCompile Include=\"CppSourceAnalyzer.cpp\">\r\n      <Filter>Source Files</Filter>\r\n    </ClCompile>\r\n    \r\n    \r\n  </ItemGroup>\r\n  <ItemGroup>\r\n    <QtMoc Include=\"CppSourceAnalyzer.h\">\r\n      <Filter>Header Files</Filter>\r\n    </QtMoc>\r\n  </ItemGroup>\r\n  <ItemGroup>\r\n    <None Include=\"CppSourceAnalyzer.json\" />\r\n  </ItemGroup>\r\n</Project>"
  },
  {
    "path": "Plugins/LinuxDeviceTree/CPUSelection/LinuxDeviceTreeCPUColumns.h",
    "content": "//-----------------------------------------------------------------------------\n// File: LinuxDeviceTreeCPUClumns.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 15.10.2021\n//\n// Description:\n// Linux device tree declarations for editing CPU details.\n//-----------------------------------------------------------------------------\n\n#ifndef LINUXDEVICETREECPUCOLUMNS_H\n#define LINUXDEVICETREECPUCOLUMNS_H\n\nnamespace LinuxDeviceTreeCPUColumns\n{\n    //! Defines the columns for the Linux device tree CPU table.\n    enum Column\n    {\n        CREATEDEVICETREE = 0,\n        FILE_NAME,\n        CPUS,\n        CONTAINING_COMPONENT,\n        COLUMN_COUNT\n    };\n}\n\n#endif // LINUXDEVICETREECPUCOLUMNS_H\n"
  },
  {
    "path": "Plugins/LinuxDeviceTree/CPUSelection/LinuxDeviceTreeCPUDelegate.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: SVDCPUDelegate.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 20.05.2021\n//\n// Description:\n// The delegate that provides editors to edit SVD CPU details.\n//-----------------------------------------------------------------------------\n\n#include \"LinuxDeviceTreeCPUDelegate.h\"\n\n#include <Plugins/LinuxDeviceTree/CPUSelection/LinuxDeviceTreeCPUColumns.h>\n\n#include <QApplication>\n#include <QMouseEvent>\n#include <QPainter>\n\n//-----------------------------------------------------------------------------\n// Function: SVDCPUDelegate::LinuxDeviceTreeCPUDelegate()\n//-----------------------------------------------------------------------------\nLinuxDeviceTreeCPUDelegate::LinuxDeviceTreeCPUDelegate(QObject* parent):\nQStyledItemDelegate(parent),\nbooleanModify_(false),\nbooleanState_(Qt::Unchecked)\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: LinuxDeviceTreeCPUDelegate::editorEvent()\n//-----------------------------------------------------------------------------\nbool LinuxDeviceTreeCPUDelegate::editorEvent(QEvent *event, QAbstractItemModel* model,\n    QStyleOptionViewItem const& option, QModelIndex const& index)\n{\n    Q_ASSERT(event);\n    Q_ASSERT(model);\n\n    // Always reset the ad-hoc group modify flag.\n    if (event->type() == QEvent::MouseButtonRelease)\n    {\n        booleanModify_ = false;\n    }\n\n    // Make sure that the item is checkable.\n    Qt::ItemFlags flags = model->flags(index);\n\n    if (!(flags & Qt::ItemIsUserCheckable) || !(flags & Qt::ItemIsEnabled))\n    {\n        return false;\n    }\n\n    // Make sure that we have a check state.\n    QVariant value = index.data(Qt::CheckStateRole);\n\n    if (!value.isValid())\n    {\n        return false;\n    }\n\n    Qt::CheckState newState = static_cast<Qt::CheckState>(value.toInt());\n\n    // Handle the mouse button events.\n    if (event->type() == QEvent::MouseButtonPress)\n    {\n        const int textMargin = QApplication::style()->pixelMetric(QStyle::PM_FocusFrameHMargin) + 1;\n\n        QRect checkRect = QStyle::alignedRect(option.direction, Qt::AlignCenter,\n            option.decorationSize,\n            QRect(option.rect.x() + (2 * textMargin), option.rect.y(),\n            option.rect.width() - (2 * textMargin),\n            option.rect.height()));\n\n        if (!checkRect.contains(static_cast<QMouseEvent*>(event)->pos()))\n        {\n            return false;\n        }\n\n        newState = (static_cast<Qt::CheckState>(value.toInt()) == Qt::Checked ? Qt::Unchecked : Qt::Checked);\n        booleanModify_ = true;\n        booleanState_ = newState;\n    }\n    else if (event->type() == QEvent::MouseMove)\n    {\n        if (!booleanModify_ || static_cast<Qt::CheckState>(value.toInt()) == booleanState_)\n        {\n            return false;\n        }\n\n        const int textMargin = QApplication::style()->pixelMetric(QStyle::PM_FocusFrameHMargin) + 1;\n\n        QRect checkRect = QStyle::alignedRect(option.direction, Qt::AlignCenter,\n            option.decorationSize,\n            QRect(option.rect.x() + (2 * textMargin), option.rect.y(),\n            option.rect.width() - (2 * textMargin),\n            option.rect.height()));\n\n        if (!checkRect.contains(static_cast<QMouseEvent*>(event)->pos()))\n        {\n            return false;\n        }\n        \n        newState = booleanState_;\n    }\n    else if (event->type() == QEvent::KeyPress)\n    {\n        if (static_cast<QKeyEvent*>(event)->key() != Qt::Key_Space &&\n            static_cast<QKeyEvent*>(event)->key() != Qt::Key_Select)\n        {\n            return false;\n        }\n    }\n    else\n    {\n        return false;\n    }\n\n    return model->setData(index, newState, Qt::CheckStateRole);\n}\n\n//-----------------------------------------------------------------------------\n// Function: LinuxDeviceTreeCPUDelegate::paint()\n//-----------------------------------------------------------------------------\nvoid LinuxDeviceTreeCPUDelegate::paint(QPainter* painter, QStyleOptionViewItem const& option,\n    QModelIndex const& index) const\n{\n\tQStyleOptionViewItem viewItemOption(option);\n\n    if (index.column() == LinuxDeviceTreeCPUColumns::CREATEDEVICETREE)\n    {\n        painter->fillRect(option.rect, Qt::white);\n\n        const int textMargin = QApplication::style()->pixelMetric(QStyle::PM_FocusFrameHMargin) + 1;\n\n        QRect newRect = QStyle::alignedRect(option.direction, Qt::AlignCenter,\n                                            QSize(option.decorationSize.width() + 5, option.decorationSize.height()),\n                                            QRect(option.rect.x() + textMargin, option.rect.y(),\n                                                  option.rect.width() - (2 * textMargin), option.rect.height()));\n        viewItemOption.rect = newRect;\n    }\n\n    QStyledItemDelegate::paint(painter, viewItemOption, index);\n}\n"
  },
  {
    "path": "Plugins/LinuxDeviceTree/CPUSelection/LinuxDeviceTreeCPUDelegate.h",
    "content": "//-----------------------------------------------------------------------------\n// File: LinuxDeviceTreeCPUDelegate.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 15.10.2021\n//\n// Description:\n// The delegate that provides editors to edit Linux Device Tree CPU details.\n//-----------------------------------------------------------------------------\n\n#ifndef LINUXDEVICETREECPUDELEGATE_H\n#define LINUXDEVICETREECPUDELEGATE_H\n\n#include <QStyledItemDelegate>\n\n//-----------------------------------------------------------------------------\n//! The delegate that provides editors to edit Linux Device Tree CPU details.\n//-----------------------------------------------------------------------------\nclass LinuxDeviceTreeCPUDelegate : public QStyledItemDelegate\n{\n\tQ_OBJECT\n\npublic:\n\n    /*!\n     *  The constructor.\n     */\n    LinuxDeviceTreeCPUDelegate(QObject* parent = 0);\n\t\n\t/*!\n     *  The destructor.\n     */\n    virtual ~LinuxDeviceTreeCPUDelegate() = default;\n\n\t/*!\n\t *  Renders an item in the given index.\n\t *\n\t *    @param [in] painter     The painter to use for rendering.\n\t *    @param [in] option      The style options for the rendering.\n\t *    @param [in] index       The index to the data being rendered.\n\t */\n\tvirtual void paint(QPainter* painter, QStyleOptionViewItem const& option, QModelIndex const& index) const;\n\n    // Disable copying.\n    LinuxDeviceTreeCPUDelegate(LinuxDeviceTreeCPUDelegate const& rhs) = delete;\n    LinuxDeviceTreeCPUDelegate& operator=(LinuxDeviceTreeCPUDelegate const& rhs) = delete;\n\nprotected:\n    \n    /*!\n     *  Handler for preprocessing events that starts editing.\n     *\n     *    @param [in] event   The event that triggered the editing.\n     *    @param [in] model   The underlying model to edit.\n     *    @param [in] option  Style options for rendering the item.\n     *    @param [in] index   The index being edited.\n     *\n     *    @return True, if the delegate handles the event, otherwise false.\n     */\n    virtual bool editorEvent(QEvent* event, QAbstractItemModel* model, QStyleOptionViewItem const& option, \n        QModelIndex const& index);\n\nprivate:\n\n    //-----------------------------------------------------------------------------\n    // Data.\n    //-----------------------------------------------------------------------------\n\n    //! Boolean for boolean group modify.\n    bool booleanModify_;\n\n    //! The new state for the boolean modify.\n    Qt::CheckState booleanState_;\n};\n\n#endif // LINUXDEVICETREECPUDELEGATE_H\n"
  },
  {
    "path": "Plugins/LinuxDeviceTree/CPUSelection/LinuxDeviceTreeCPUDetails.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: LinuxDeviceTreeCPUDetails.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 15.10.2021\n//\n// Description:\n// Details for Linux device tree CPU declarations.\n//-----------------------------------------------------------------------------\n\n#include \"LinuxDeviceTreeCPUDetails.h\"\n\n#include <IPXACTmodels/common/VLNV.h>\n#include <IPXACTmodels/Component/Component.h>\n#include <IPXACTmodels/Component/Cpu.h>\n\n#include <editors/MemoryDesigner/MemoryItem.h>\n#include <editors/MemoryDesigner/ConnectivityComponent.h>\n#include <editors/MemoryDesigner/ConnectivityInterface.h>\n#include <editors/MemoryDesigner/MemoryConnectionAddressCalculator.h>\n\n#include <Plugins/common/SingleCpuRoutesContainer.h>\n#include <Plugins/common/ConnectivityGraphUtilities.h>\n\n#include <KactusAPI/include/LibraryInterface.h>\n\nnamespace\n{\n    //-----------------------------------------------------------------------------\n    // Function: routeExistsInList()\n    //-----------------------------------------------------------------------------\n    bool routeExistsInList(QSharedPointer<CpuRouteStructs::CpuRoute> route,\n        QVector<QSharedPointer<CpuRouteStructs::CpuRoute> > routeData)\n    {\n        for (auto comparisonRoute : routeData)\n        {\n            if (comparisonRoute->cpuInterface_ == route->cpuInterface_)\n            {\n                return true;\n            }\n        }\n\n        return false;\n    }\n\n    //-----------------------------------------------------------------------------\n    // Function: containerContainsSameRoutes()\n    //-----------------------------------------------------------------------------\n    bool containerContainsSameRoutes(QSharedPointer<LinuxDeviceTreeCpuRoutesContainer> container,\n        QVector<QSharedPointer<CpuRouteStructs::CpuRoute> > routeData)\n    {\n        if (routeData.size() == container->getRoutes().size())\n        {\n            for (auto comparisonRoute : container->getRoutes())\n            {\n                if (!routeExistsInList(comparisonRoute, routeData))\n                {\n                    return false;\n                }\n            }\n\n            return true;\n        }\n\n        return false;\n    }\n\n    //-----------------------------------------------------------------------------\n    // Function: getContainerForRouteData()\n    //-----------------------------------------------------------------------------\n    QSharedPointer<LinuxDeviceTreeCpuRoutesContainer> getContainerForRouteData(\n        QVector<QSharedPointer<CpuRouteStructs::CpuRoute> > routeData,\n        QVector<QSharedPointer<LinuxDeviceTreeCpuRoutesContainer> > containers)\n    {\n        for (auto singleCpuContainer : containers)\n        {\n            if (containerContainsSameRoutes(singleCpuContainer, routeData))\n            {\n                return singleCpuContainer;\n            }\n        }\n\n        return QSharedPointer<LinuxDeviceTreeCpuRoutesContainer>();\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: LinuxDeviceTreeCPUDetails::getCPUContainers()\n//-----------------------------------------------------------------------------\nQVector<QSharedPointer<LinuxDeviceTreeCpuRoutesContainer> > LinuxDeviceTreeCPUDetails::getCPUContainers(\n    QString const& fileName, QSharedPointer<Component> topComponent, QString const& viewName, LibraryInterface* library)\n{\n    QVector<QSharedPointer<LinuxDeviceTreeCpuRoutesContainer> > dtsCpuContainers;\n\n    for (auto container : ConnectivityGraphUtilities::getDefaultCPUs(library, topComponent, viewName))\n    {\n        QSharedPointer<LinuxDeviceTreeCpuRoutesContainer> singleDtsContainer =\n            getContainerForRouteData(container->getRoutes(), dtsCpuContainers);\n        if (!singleDtsContainer)\n        {\n            singleDtsContainer = QSharedPointer<LinuxDeviceTreeCpuRoutesContainer>(new LinuxDeviceTreeCpuRoutesContainer(*container.data()));\n\n            dtsCpuContainers.append(singleDtsContainer);\n        }\n\n        singleDtsContainer->addCpu(container->getCpu());\n    }\n\n    for (int i = 0; i < dtsCpuContainers.size(); ++i)\n    {\n        QSharedPointer<LinuxDeviceTreeCpuRoutesContainer> singleContainer = dtsCpuContainers.at(i);\n        singleContainer->setFileName(fileName + \"_\" + QString::number(i));\n    }\n\n    return dtsCpuContainers;\n}\n\n//-----------------------------------------------------------------------------\n// Function: LinuxDeviceTreeCPUDetails::getComponentContainingInterface()\n//-----------------------------------------------------------------------------\nQSharedPointer<Component const> LinuxDeviceTreeCPUDetails::getComponentContainingInterface(\n    QSharedPointer<const ConnectivityInterface> interfaceNode, LibraryInterface* library)\n{\n    VLNV componentVLNV(VLNV::COMPONENT, interfaceNode->getInstance()->getVlnv());\n\n    QSharedPointer<Document const> componentDocument = library->getModelReadOnly(componentVLNV);\n    if (componentDocument)\n    {\n        QSharedPointer<Component const> component = componentDocument.dynamicCast<Component const>();\n        if (component)\n        {\n            return component;\n        }\n    }\n\n    return QSharedPointer<const Component>();\n}\n\n//-----------------------------------------------------------------------------\n// Function: LinuxDeviceTreeCPUDetails::getMemories()\n//-----------------------------------------------------------------------------\nQVector<LinuxDeviceTreeCPUDetails::CpuMemory> LinuxDeviceTreeCPUDetails::getMemories(\n    QSharedPointer<DeviceTreeUtilities::CpuDeviceTree> deviceTreeContainer, quint64 baseAddress, quint64 const& memoryItemRange)\n{\n    QVector<LinuxDeviceTreeCPUDetails::CpuMemory> newCpuMemories;\n    quint64 newBaseAddress = baseAddress;\n    quint64 newMemoryRange = memoryItemRange;\n\n    QSharedPointer<const ConnectivityInterface> containerInterface = deviceTreeContainer->interface_;\n    if (General::InterfaceMode containerMode = containerInterface->getMode();\n        containerMode == General::MASTER || containerMode == General::INITIATOR)\n    {\n        newBaseAddress += containerInterface->getBaseAddress().toULongLong();\n    }\n    else if (containerMode == General::MIRRORED_SLAVE || containerMode == General::MIRRORED_TARGET)\n    {\n        newBaseAddress += containerInterface->getRemapAddress().toULongLong();\n        newMemoryRange = containerInterface->getRemapRange().toULongLong();\n    }\n    else if (containerMode == General::SLAVE || containerMode == General::TARGET)\n    {\n        if (interfacedItemIsMemory(containerInterface))\n        {\n            QPair<quint64, quint64> memoryAddress =\n                MemoryConnectionAddressCalculator::getMemoryMapAddressRanges(containerInterface->getConnectedMemory());\n\n            quint64 memoryBase = newBaseAddress;\n            newBaseAddress += memoryAddress.first;\n            if (newMemoryRange == 0)\n            {\n                newMemoryRange = memoryAddress.second + 1;\n            }\n\n            LinuxDeviceTreeCPUDetails::CpuMemory newMemory{containerInterface, memoryBase, newBaseAddress, newMemoryRange };\n            newCpuMemories.append(newMemory);\n            return newCpuMemories;\n        }\n    }\n\n    for (auto leafContainer : deviceTreeContainer->childContainers_)\n    {\n        QVector<LinuxDeviceTreeCPUDetails::CpuMemory> nodeMemories = getMemories(leafContainer, newBaseAddress, newMemoryRange);\n        if (!nodeMemories.isEmpty())\n        {\n            newCpuMemories.append(nodeMemories);\n        }\n    }\n\n    return newCpuMemories;\n}\n\n//-----------------------------------------------------------------------------\n// Function: LinuxDeviceTreeCPUDetails::interfacedItemIsMemory()\n//-----------------------------------------------------------------------------\nbool LinuxDeviceTreeCPUDetails::interfacedItemIsMemory(QSharedPointer<const ConnectivityInterface> memoryInterface)\n{\n    QSharedPointer<MemoryItem> interfacedMemoryItem = memoryInterface->getConnectedMemory();\n    if (interfacedMemoryItem && interfacedMemoryItem->getUsage() == General::MEMORY)\n    {\n        return true;\n    }\n\n    return false;\n}\n"
  },
  {
    "path": "Plugins/LinuxDeviceTree/CPUSelection/LinuxDeviceTreeCPUDetails.h",
    "content": "//-----------------------------------------------------------------------------\n// File: LinuxDeviceTreeCPUDetails.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 15.10.2021\n//\n// Description:\n// Details for Linux device tree CPU declarations.\n//-----------------------------------------------------------------------------\n\n#ifndef LINUXDEVICETREECPUDETAILS_H\n#define LINUXDEVICETREECPUDETAILS_H\n\n#include <QVector>\n#include <QSharedPointer>\n#include <QMultiMap>\n\n#include <Plugins/LinuxDeviceTree/CPUSelection/LinuxDeviceTreeCpuRoutesContainer.h>\n\nclass Cpu;\nclass ConnectivityInterface;\nclass Component;\nclass LibraryInterface;\n\nnamespace LinuxDeviceTreeCPUDetails\n{\n    //! Container for memory data.\n    struct CpuMemory\n    {\n        //! Interface containing the memory item.\n        QSharedPointer<ConnectivityInterface const> memoryInterface_;\n\n        //! Base address of the memory location.\n        quint64 itemBaseAddress_;\n\n        //! Base address of the memory.\n        quint64 mapBaseAddress_;\n\n        //! Range of the memory.\n        quint64 range_;\n    };\n\n    /*!\n     *  Get containers for combined CPUs and interfaces.\n     *\n     *    @param [in] fileName        Default file name for the containers.\n     *    @param [in] topComponent    The top level component.\n     *    @param [in] viewName        Name of the top level view.\n     *    @param [in] library         The library interface.\n     *\n     *    @return Containers containing combined CPUs and interfaces.\n     */\n    QVector<QSharedPointer<LinuxDeviceTreeCpuRoutesContainer> > getCPUContainers(QString const& fileName,\n        QSharedPointer<Component> topComponent,\n        QString const& viewName,\n        LibraryInterface* library);\n\n    /*!\n     *  Get the component containing the selected interface.\n     *\n     *    @param [in] interfaceNode   The selected interface.\n     *    @param [in] library         The library interface.\n     *\n     *    @return Component containing the selected interface.\n     */\n    QSharedPointer<Component const> getComponentContainingInterface(\n        QSharedPointer<const ConnectivityInterface> interfaceNode, LibraryInterface* library);\n\n\n    /*!\n     *  Get the memory data of the selected interface.\n     *\n     *    @param [in] deviceTreeContainer     Container for the tree structure of a device tree interface.\n     *    @param [in] baseAddress             Currently active base address.\n     *    @param [in] memoryItemRange         Currently active range.\n     *\n     *    @return List of memory data connected to the selected interface.\n     */\n    QVector<CpuMemory> getMemories(QSharedPointer<DeviceTreeUtilities::CpuDeviceTree> deviceTreeContainer,\n        quint64 baseAddress,\n        quint64 const& memoryItemRange);\n\n    /*!\n     *  Check if the selected interface contains memory data.\n     *\n     *    @param [in] memoryInterface     The selected interface.\n     *\n     *    @return True, if the selected interface contains memory data, false otherwise.\n     */\n    bool interfacedItemIsMemory(QSharedPointer<const ConnectivityInterface> memoryInterface);\n}\n\n#endif // LINUXDEVICETREECPUDETAILS_H\n"
  },
  {
    "path": "Plugins/LinuxDeviceTree/CPUSelection/LinuxDeviceTreeCPUEditor.cpp",
    "content": "﻿//-----------------------------------------------------------------------------\n// File: LinuxDeviceTreeCPUEditor.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 14.10.2021\n//\n// Description:\n// Editor for CPU details in Linux Device Tree generation.\n//-----------------------------------------------------------------------------\n\n#include \"LinuxDeviceTreeCPUEditor.h\"\n\n#include <Plugins/LinuxDeviceTree/CPUSelection/LinuxDeviceTreeCPUModel.h>\n#include <Plugins/LinuxDeviceTree/CPUSelection/LinuxDeviceTreeCPUDelegate.h>\n\n#include <QSortFilterProxyModel>\n#include <QVBoxLayout>\n#include <QHeaderView>\n\n//-----------------------------------------------------------------------------\n// Function: LinuxDeviceTreeCPUEditor::LinuxDeviceTreeCPUEditor()\n//-----------------------------------------------------------------------------\nLinuxDeviceTreeCPUEditor::LinuxDeviceTreeCPUEditor(QWidget *parent):\nQWidget(parent),\nview_(new QTableView(this)),\nmodel_(new LinuxDeviceTreeCPUModel(this))\n{\n    LinuxDeviceTreeCPUDelegate* cpuDelegate(new LinuxDeviceTreeCPUDelegate(parent));\n\n    QSortFilterProxyModel* proxy(new QSortFilterProxyModel(this));\n    proxy->setSourceModel(model_);\n\n    view_->setModel(proxy);\n    view_->setItemDelegate(cpuDelegate),\n\n    view_->horizontalHeader()->setSectionResizeMode(QHeaderView::Interactive);\n    view_->horizontalHeader()->setStretchLastSection(true);\n    view_->verticalHeader()->hide();\n    view_->verticalHeader()->setDefaultSectionSize(fontMetrics().height() + 8);\n\n    QVBoxLayout* layout = new QVBoxLayout(this);\n    layout->addWidget(view_, 1);\n    layout->setContentsMargins(0, 0, 0, 0);\n}\n\n//-----------------------------------------------------------------------------\n// Function: LinuxDeviceTreeCPUEditor::setCPUDetails()\n//-----------------------------------------------------------------------------\nvoid LinuxDeviceTreeCPUEditor::setupCPUDetails(\n    QVector<QSharedPointer<LinuxDeviceTreeCpuRoutesContainer> > cpuDetails)\n{\n    model_->setupCPUDetails(cpuDetails);\n    view_->resizeColumnsToContents();\n}\n\n//-----------------------------------------------------------------------------\n// Function: LinuxDeviceTreeCPUEditor::getAcceptedContainers()\n//-----------------------------------------------------------------------------\nQVector<QSharedPointer<LinuxDeviceTreeCpuRoutesContainer> > LinuxDeviceTreeCPUEditor::getAcceptedContainers()\nconst\n{\n    return model_->getCPUDetails();\n}\n"
  },
  {
    "path": "Plugins/LinuxDeviceTree/CPUSelection/LinuxDeviceTreeCPUEditor.h",
    "content": "//-----------------------------------------------------------------------------\n// File: LinuxDeviceTreeCPUEditor.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 14.10.2021\n//\n// Description:\n// Editor for CPU details in Linux Device Tree generation.\n//-----------------------------------------------------------------------------\n\n#ifndef LINUXDEVICETREECPUEDITOR_H\n#define LINUXDEVICETREECPUEDITOR_H\n\n#include <QWidget>\n#include <QObject>\n#include <QTableView>\n\n#include <Plugins/LinuxDeviceTree/CPUSelection/LinuxDeviceTreeCPUDetails.h>\n\nclass LinuxDeviceTreeCPUModel;\n\n//-----------------------------------------------------------------------------\n//! Editor for CPU details in Linux Device Tree generation.\n//-----------------------------------------------------------------------------\nclass LinuxDeviceTreeCPUEditor : public QWidget\n{\n    Q_OBJECT\n\npublic:\n\n    /*!\n     *  The constructor.\n     *\n     *    @param [in] parent  Pointer to the owner of this widget.\n     */\n    LinuxDeviceTreeCPUEditor(QWidget *parent = 0);\n\n    /*!\n     *  The destructor.\n     */\n    virtual ~LinuxDeviceTreeCPUEditor() = default;\n\n    /*!\n     *  Setup the selected CPU containers.\n     *\n     *    @param [in] cpuDetails  The selected CPU containers.\n     */\n    void setupCPUDetails(QVector<QSharedPointer<LinuxDeviceTreeCpuRoutesContainer> > cpuDetails);\n\n    /*!\n     *  Get the selected CPU containers.\n     *\n     *    @return The selected CPU containers.\n     */\n    QVector<QSharedPointer<LinuxDeviceTreeCpuRoutesContainer> > getAcceptedContainers() const;\n\n    //! No copying. No assignment.\n    LinuxDeviceTreeCPUEditor(const LinuxDeviceTreeCPUEditor& other) = delete;\n    LinuxDeviceTreeCPUEditor& operator=(const LinuxDeviceTreeCPUEditor& other) = delete;\n\nprivate:\n\n    //! The view for the table.\n    QTableView* view_;\n\n    //! The containing model.\n    LinuxDeviceTreeCPUModel* model_;\n};\n\n#endif // LINUXDEVICETREECPUEDITOR_H\n"
  },
  {
    "path": "Plugins/LinuxDeviceTree/CPUSelection/LinuxDeviceTreeCPUModel.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: LinuxDeviceTreeCPUModel.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 15.10.2021\n//\n// Description:\n// The model to manage the Linux Device Tree CPU details.\n//-----------------------------------------------------------------------------\n\n#include \"LinuxDeviceTreeCPUModel.h\"\n#include \"LinuxDeviceTreeCPUColumns.h\"\n\n#include <IPXACTmodels/Component/Cpu.h>\n#include <IPXACTmodels/Component/Component.h>\n\n#include <common/KactusColors.h>\n\n#include <editors/MemoryDesigner/ConnectivityInterface.h>\n#include <editors/MemoryDesigner/ConnectivityComponent.h>\n\n#include <Plugins/LinuxDeviceTree/CPUSelection/LinuxDeviceTreeCpuRoutesContainer.h>\n\n//-----------------------------------------------------------------------------\n// Function: LinuxDeviceTreeCPUModel::LinuxDeviceTreeCPUModel()\n//-----------------------------------------------------------------------------\nLinuxDeviceTreeCPUModel::LinuxDeviceTreeCPUModel(QObject *parent):\nQAbstractTableModel(parent),\ncpus_()\n{\n}\n\n//-----------------------------------------------------------------------------\n// Function: LinuxDeviceTreeCPUModel::setupCPUDetails()\n//-----------------------------------------------------------------------------\nvoid LinuxDeviceTreeCPUModel::setupCPUDetails(QVector<QSharedPointer<LinuxDeviceTreeCpuRoutesContainer>> cpuDetails)\n{\n    beginResetModel();\n\n    cpus_.clear();\n    cpus_ = cpuDetails;\n\n    endResetModel();\n}\n\n//-----------------------------------------------------------------------------\n// Function: LinuxDeviceTreeCPUModel::getCPUDetails()\n//-----------------------------------------------------------------------------\nQVector<QSharedPointer<LinuxDeviceTreeCpuRoutesContainer> > LinuxDeviceTreeCPUModel::getCPUDetails() const\n{\n    QVector<QSharedPointer<LinuxDeviceTreeCpuRoutesContainer> > acceptedContainers;\n    for (auto cpuContainer : cpus_)\n    {\n        if (cpuContainer->shouldCreateFile())\n        {\n            acceptedContainers.append(cpuContainer);\n        }\n    }\n\n    return acceptedContainers;\n}\n\n//-----------------------------------------------------------------------------\n// Function: LinuxDeviceTreeCPUModel::rowCount()\n//-----------------------------------------------------------------------------\nint LinuxDeviceTreeCPUModel::rowCount(QModelIndex const& parent) const\n{\n\tif (parent.isValid())\n    {\n\t\treturn 0;\n\t}\n\n\treturn cpus_.count();\n}\n\n//-----------------------------------------------------------------------------\n// Function: LinuxDeviceTreeCPUModel::columnCount()\n//-----------------------------------------------------------------------------\nint LinuxDeviceTreeCPUModel::columnCount(QModelIndex const& parent) const\n{\n\tif (parent.isValid())\n    {\n\t\treturn 0;\n\t}\n\n    return LinuxDeviceTreeCPUColumns::COLUMN_COUNT;\n}\n\n//-----------------------------------------------------------------------------\n// Function: LinuxDeviceTreeCPUModel::flags()\n//-----------------------------------------------------------------------------\nQt::ItemFlags LinuxDeviceTreeCPUModel::flags(QModelIndex const& index) const\n{\n\tif (!index.isValid() || index.column() == LinuxDeviceTreeCPUColumns::CPUS ||\n        index.column() == LinuxDeviceTreeCPUColumns::CONTAINING_COMPONENT)\n    {\n\t\treturn Qt::NoItemFlags;\n\t}\n\n    Qt::ItemFlags flags = Qt::ItemIsEnabled | Qt::ItemIsSelectable;\n\n    if (index.column() == LinuxDeviceTreeCPUColumns::CREATEDEVICETREE)\n    {\n        flags |= Qt::ItemIsUserCheckable;\n    }\n    else\n    {\n        flags |= Qt::ItemIsEditable;\n    }\n\n    return flags;\n}\n\n//-----------------------------------------------------------------------------\n// Function: LinuxDeviceTreeCPUModel::headerData()\n//-----------------------------------------------------------------------------\nQVariant LinuxDeviceTreeCPUModel::headerData(int section, Qt::Orientation orientation, int role) const\n{\n\tif (orientation != Qt::Horizontal)\n    {\n\t\treturn QVariant();\n\t}\n\n\tif (role == Qt::DisplayRole)\n    {\n        if (section == LinuxDeviceTreeCPUColumns::CREATEDEVICETREE)\n        {\n            return \"Create\\nDTS\";\n        }\n        else if (section == LinuxDeviceTreeCPUColumns::FILE_NAME)\n        {\n            return \"File name\";\n        }\n        else if (section == LinuxDeviceTreeCPUColumns::CPUS)\n        {\n            return \"CPUs\";\n        }\n        else if (section == LinuxDeviceTreeCPUColumns::CONTAINING_COMPONENT)\n        {\n            return \"Component\";\n        }\n\t}\n    \n    return QVariant();\n}\n\n//-----------------------------------------------------------------------------\n// Function: LinuxDeviceTreeCPUModel::data()\n//-----------------------------------------------------------------------------\nQVariant LinuxDeviceTreeCPUModel::data(QModelIndex const& index, int role) const\n{\n\tif (!index.isValid() || index.row() < 0 || index.row() >= cpus_.size())\n    {\n\t\treturn QVariant();\n\t}\n\n    if (role == Qt::DisplayRole || role == Qt::EditRole)\n    {\n        return valueForIndex(index);\n    }\n    else if (role == Qt::ToolTipRole)\n    {\n        return tooltipForIndex(index);\n    }\n\telse if (role == Qt::ForegroundRole)\n    {\n        if (index.column() == LinuxDeviceTreeCPUColumns::CPUS ||\n            index.column() == LinuxDeviceTreeCPUColumns::CONTAINING_COMPONENT)\n        {\n            return KactusColors::DISABLED_TEXT;\n        }\n        else\n        {\n            return KactusColors::REGULAR_TEXT;\n        }\n    }\n    else if (Qt::CheckStateRole == role)\n    {\n        if (index.column() == LinuxDeviceTreeCPUColumns::CREATEDEVICETREE)\n        {\n            QSharedPointer<LinuxDeviceTreeCpuRoutesContainer> indexedCPU = cpus_.at(index.row());\n            if (indexedCPU->shouldCreateFile())\n            {\n                return Qt::Checked;\n            }\n            else\n            {\n                return Qt::Unchecked;\n            }\n        }\n        else\n        {\n            return QVariant();\n        }\n    }\n\n    return QVariant();\n}\n\n//-----------------------------------------------------------------------------\n// Function: LinuxDeviceTreeCPUModel::setData()\n//-----------------------------------------------------------------------------\nbool LinuxDeviceTreeCPUModel::setData(QModelIndex const& index, QVariant const& value, int role)\n{\n\tif (!index.isValid() || index.row() < 0 || index.row() >= cpus_.size())\n    {\n\t\treturn false;\n\t}\n\n    QSharedPointer<LinuxDeviceTreeCpuRoutesContainer> indexedCPU = cpus_.at(index.row());\n    if (Qt::EditRole == role)\n    {\n        if (index.column() == LinuxDeviceTreeCPUColumns::FILE_NAME)\n        {\n            indexedCPU->setFileName(value.toString());\n        }\n\n        emit dataChanged(index, index);\n        return true;\n    }\n    else if (role == Qt::CheckStateRole)\n    {\n        if (index.column() == LinuxDeviceTreeCPUColumns::CREATEDEVICETREE)\n        {\n            indexedCPU->setCreateFileFlag(value.toBool());\n        }\n\n        emit dataChanged(index, index);\n        return true;\n    }\n\n    return false;\n}\n\n//-----------------------------------------------------------------------------\n// Function: LinuxDeviceTreeCPUModel::valueForIndex()\n//-----------------------------------------------------------------------------\nQVariant LinuxDeviceTreeCPUModel::valueForIndex(QModelIndex const& index) const\n{\n    QSharedPointer<LinuxDeviceTreeCpuRoutesContainer> indexedContainer = cpus_.at(index.row());\n\n    if (index.column() == LinuxDeviceTreeCPUColumns::FILE_NAME)\n    {\n        return indexedContainer->getFileName();\n    }\n    else if (index.column() == LinuxDeviceTreeCPUColumns::CPUS)\n    {\n        QString cpuText = \"\";\n        for (auto currentCPU : indexedContainer->getCpus())\n        {\n            cpuText += currentCPU->name();\n\n            if (currentCPU != indexedContainer->getCpus().last())\n            {\n                cpuText += \", \";\n            }\n        }\n\n        return cpuText;\n    }\n    else if (index.column() == LinuxDeviceTreeCPUColumns::CONTAINING_COMPONENT)\n    {\n        if (indexedContainer->getRoutes().isEmpty() == false && indexedContainer->getRoutes().first()->cpuInterface_)\n        {\n            return indexedContainer->getRoutes().first()->cpuInterface_->getInstance()->getVlnv();\n        }\n        else\n        {\n            return \"\";\n        }\n    }\n   \n    return QVariant();\n}\n\n//-----------------------------------------------------------------------------\n// Function: LinuxDeviceTreeCPUModel::tooltipForIndex()\n//-----------------------------------------------------------------------------\nQVariant LinuxDeviceTreeCPUModel::tooltipForIndex(QModelIndex const& index) const\n{\n    if (index.column() == LinuxDeviceTreeCPUColumns::CPUS)\n    {\n        QString cpuTooltip = \"CPUs:\\n\";\n\n        QSharedPointer<LinuxDeviceTreeCpuRoutesContainer> indexedContainer = cpus_.at(index.row());\n        for (auto currentCPU : indexedContainer->getCpus())\n        {\n            cpuTooltip += currentCPU->name();\n\n            if (currentCPU != indexedContainer->getCpus().last())\n            {\n                cpuTooltip += \"\\n\";\n            }\n        }\n\n        return cpuTooltip;\n    }\n    else\n    {\n        return valueForIndex(index);\n    }\n\n    return QVariant();\n}\n"
  },
  {
    "path": "Plugins/LinuxDeviceTree/CPUSelection/LinuxDeviceTreeCPUModel.h",
    "content": "//-----------------------------------------------------------------------------\n// File: LinuxDeviceTreeCPUModel.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 15.10.2021\n//\n// Description:\n// The model to manage the Linux Device Tree CPU details.\n//-----------------------------------------------------------------------------\n\n#ifndef LINUXDEVICETREECPUMODEL_H\n#define LINUXDEVICETREECPUMODEL_H\n\n#include <Plugins/LinuxDeviceTree/CPUSelection/LinuxDeviceTreeCPUDetails.h>\n\n#include <QAbstractTableModel>\n#include <QSharedPointer>\n\nclass LinuxDeviceTreeCpuRoutesContainer;\n\n//-----------------------------------------------------------------------------\n//! The model to manage the Linux Device Tree CPU details.\n//-----------------------------------------------------------------------------\nclass LinuxDeviceTreeCPUModel : public QAbstractTableModel\n{\n\tQ_OBJECT\n\npublic:\n\n\t/*!\n\t *  The constructor.\n\t *\n\t *    @param [in] parent  Pointer to the owner of this model.\n\t */\n    LinuxDeviceTreeCPUModel(QObject *parent);\n\t\n\t/*!\n     *  The destructor.\n     */\n    virtual ~LinuxDeviceTreeCPUModel() = default;\n\n    /*!\n     *  Setup the selected CPU containers.\n     *\n     *    @param [in] cpuDetails  The selected CPU containers.\n     */\n    void setupCPUDetails(QVector<QSharedPointer<LinuxDeviceTreeCpuRoutesContainer> > cpuDetails);\n\n    /*!\n     *  Get the selected CPU containers.\n     *\n     *    @return List of CPU containers that should be written into files.\n     */\n    QVector<QSharedPointer<LinuxDeviceTreeCpuRoutesContainer> > getCPUDetails() const;\n\n\t/*!\n     *  Get the number of rows an item contains.\n\t *\n\t *    @param [in] parent  Identifies the parent that's row count is requested.\n\t *\n\t *    @return Number of rows the item has.\n\t */\n\tvirtual int rowCount(QModelIndex const& parent = QModelIndex()) const;\n\n\t/*!\n     *  Get the number of columns the item has to be displayed.\n\t *\n\t *    @param [in] parent  Identifies the parent that's column count is requested.\n\t *\n\t *    @return The number of columns to be displayed.\n\t */\n\tvirtual int columnCount(QModelIndex const& parent = QModelIndex()) const;\n\n\t/*!\n     *  Get the item flags that defines the possible operations for the item.\n\t *\n\t *    @param [in] index   Model index that identifies the item.\n\t *\n\t *    @return Qt::ItemFlags specify the possible operations for the item.\n\t */\n\tQt::ItemFlags flags(QModelIndex const& index) const;\n\n\t/*!\n     *  Get the header data for specified header.\n\t *\n\t *    @param [in] section         The section specifies the row/column number for the header.\n\t *    @param [in] orientation     Specified if horizontal or vertical header is wanted.\n\t *    @param [in] role            Specifies the type of the requested data.\n\t *\n\t *    @return QVariant Contains the requested data.\n\t */\n\tvirtual QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;\n\n\t/*!\n     *  Get the data for specified item.\n\t *\n\t *    @param [in] index   Specifies the item that's data is requested.\n\t *    @param [in] role    The role that defines what kind of data is requested.\n\t *\n\t *    @return QVariant Contains the data for the item.\n\t */\n\tvirtual QVariant data(QModelIndex const& index, int role = Qt::DisplayRole) const;\n\n\t/*!\n     *  Save the data to the model for specified item.\n\t *\n\t *    @param [in] index   The model index of the item that's data is to be saved.\n\t *    @param [in] value   The data that is to be saved.\n\t *    @param [in] role    The role specifies what kind of data should be saved.\n\t *\n\t *    @return True if saving happened successfully.\n\t */\n\tbool setData(QModelIndex const& index, const QVariant& value, int role = Qt::EditRole);\n    \n    //! No copying. No assignment.\n    LinuxDeviceTreeCPUModel(const LinuxDeviceTreeCPUModel& other) = delete;\n    LinuxDeviceTreeCPUModel& operator=(const LinuxDeviceTreeCPUModel& other) = delete;\n\nprivate:\n\t\n    /*!\n     *  Gets the value for the given index.\n     *\n     *    @param [in] index   The index of the target data.\n     *\n     *    @return The data in the given index.\n     */\n    QVariant valueForIndex(QModelIndex const& index) const;\n\n    /*!\n     *  Gets the tooltip value for the given index.\n     *\n     *    @param [in] index   The index of the target data.\n     *\n     *    @return The tooltip data in the given index.\n     */\n    QVariant tooltipForIndex(QModelIndex const& index) const;\n\n    //-----------------------------------------------------------------------------\n    // Data.\n    //-----------------------------------------------------------------------------\n\n    //! The CPU containers being edited.\n    QVector<QSharedPointer<LinuxDeviceTreeCpuRoutesContainer> > cpus_;\n};\n\n#endif // LINUXDEVICETREECPUMODEL_H\n"
  },
  {
    "path": "Plugins/LinuxDeviceTree/CPUSelection/LinuxDeviceTreeCpuRoutesContainer.cpp",
    "content": "﻿//-----------------------------------------------------------------------------\n// File: LinuxDeviceTreeCpuRoutesContainer.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 09.05.2023\n//\n// Description:\n// Container for routes connected to CPUs in Linux Device Tree.\n//-----------------------------------------------------------------------------\n\n#include \"LinuxDeviceTreeCpuRoutesContainer.h\"\n\n//-----------------------------------------------------------------------------\n// Function: LinuxDeviceTreeCpuRoutesContainer::LinuxDeviceTreeCpuRoutesContainer()\n//-----------------------------------------------------------------------------\nLinuxDeviceTreeCpuRoutesContainer::LinuxDeviceTreeCpuRoutesContainer() :\nCpuRoutesContainer(),\ncpus_(),\nfilePath_(\"\"),\ndeviceTreeRoutes_()\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: LinuxDeviceTreeCpuRoutesContainer::LinuxDeviceTreeCpuRoutesContainer()\n//-----------------------------------------------------------------------------\nLinuxDeviceTreeCpuRoutesContainer::LinuxDeviceTreeCpuRoutesContainer(const CpuRoutesContainer& other) :\nCpuRoutesContainer(other),\ncpus_(),\nfilePath_(\"\"),\ndeviceTreeRoutes_()\n{\n    setupDeviceTreeRoutes(other.getRoutes());\n}\n\n//-----------------------------------------------------------------------------\n// Function: LinuxDeviceTreeCpuRoutesContainer::getCpus()\n//-----------------------------------------------------------------------------\nQVector<QSharedPointer<const Cpu> > LinuxDeviceTreeCpuRoutesContainer::getCpus() const\n{\n    return cpus_;\n}\n\n//-----------------------------------------------------------------------------\n// Function: LinuxDeviceTreeCpuRoutesContainer::setCpus()\n//-----------------------------------------------------------------------------\nvoid LinuxDeviceTreeCpuRoutesContainer::setCpus(QVector<QSharedPointer<Cpu> > newCpus)\n{\n    cpus_.clear();\n\n    for (auto singleCpu : newCpus)\n    {\n        cpus_.append(singleCpu);\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: LinuxDeviceTreeCpuRoutesContainer::addCpu()\n//-----------------------------------------------------------------------------\nvoid LinuxDeviceTreeCpuRoutesContainer::addCpu(QSharedPointer<Cpu> newCpu)\n{\n    cpus_.append(newCpu);\n}\n\n//-----------------------------------------------------------------------------\n// Function: LinuxDeviceTreeCpuRoutesContainer::getFilePath()\n//-----------------------------------------------------------------------------\nQString LinuxDeviceTreeCpuRoutesContainer::getFilePath() const\n{\n    return filePath_;\n}\n\n//-----------------------------------------------------------------------------\n// Function: LinuxDeviceTreeCpuRoutesContainer::setFilePath()\n//-----------------------------------------------------------------------------\nvoid LinuxDeviceTreeCpuRoutesContainer::setFilePath(QString const& newFilePath)\n{\n    filePath_ = newFilePath;\n}\n\n//-----------------------------------------------------------------------------\n// Function: LinuxDeviceTreeCpuRoutesContainer::getDeviceTreeRoutes()\n//-----------------------------------------------------------------------------\nQVector<QSharedPointer<DeviceTreeUtilities::CpuDeviceTree> > LinuxDeviceTreeCpuRoutesContainer::getDeviceTreeRoutes() const\n{\n    return deviceTreeRoutes_;\n}\n\n//-----------------------------------------------------------------------------\n// Function: LinuxDeviceTreeCpuRoutesContainer::setRoutes()\n//-----------------------------------------------------------------------------\nvoid LinuxDeviceTreeCpuRoutesContainer::setRoutes(QVector <QSharedPointer<CpuRouteStructs::CpuRoute> > newContainers)\n{\n    CpuRoutesContainer::setRoutes(newContainers);\n    setupDeviceTreeRoutes(newContainers);\n}\n\n//-----------------------------------------------------------------------------\n// Function: LinuxDeviceTreeCpuRoutesContainer::setupDeviceTreeRoutes()\n//-----------------------------------------------------------------------------\nvoid LinuxDeviceTreeCpuRoutesContainer::setupDeviceTreeRoutes(QVector<QSharedPointer<CpuRouteStructs::CpuRoute>> newRouteContainers)\n{\n    for (auto routeContainer : newRouteContainers)\n    {\n        setupSingleDeviceTreeRoute(routeContainer);\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: LinuxDeviceTreeCpuRoutesContainer::setupSingleDeviceTreeRoute()\n//-----------------------------------------------------------------------------\nvoid LinuxDeviceTreeCpuRoutesContainer::setupSingleDeviceTreeRoute(QSharedPointer<CpuRouteStructs::CpuRoute> routeContainer)\n{\n    for (auto route : routeContainer->routes_)\n    {\n        QSharedPointer<DeviceTreeUtilities::CpuDeviceTree> cpuDeviceTree = getDeviceTreeForRoute(route, deviceTreeRoutes_);\n        if (cpuDeviceTree && !deviceTreeRoutes_.contains(cpuDeviceTree))\n        {\n            deviceTreeRoutes_.append(cpuDeviceTree);\n        }\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: LinuxDeviceTreeCpuRoutesContainer::getDeviceTreeForRoute()\n//-----------------------------------------------------------------------------\nQSharedPointer<DeviceTreeUtilities::CpuDeviceTree> LinuxDeviceTreeCpuRoutesContainer::getDeviceTreeForRoute(\n    QVector<QSharedPointer<const ConnectivityInterface> > route,\n    QVector<QSharedPointer<DeviceTreeUtilities::CpuDeviceTree> > treeRoutes)\n{\n    if (route.isEmpty())\n    {\n        return QSharedPointer<DeviceTreeUtilities::CpuDeviceTree>();\n    }\n\n    QVector<QSharedPointer<const ConnectivityInterface> > shortenedRoute = route;\n    QSharedPointer<const ConnectivityInterface> startingInterface = shortenedRoute.takeFirst();\n\n    QSharedPointer<DeviceTreeUtilities::CpuDeviceTree> treeContainer = getDeviceTreeContainerForInterface(startingInterface, treeRoutes);\n    if (!treeContainer)\n    {\n        treeContainer = QSharedPointer<DeviceTreeUtilities::CpuDeviceTree>(new DeviceTreeUtilities::CpuDeviceTree());\n        treeContainer->interface_ = startingInterface;\n    }\n\n    QSharedPointer<DeviceTreeUtilities::CpuDeviceTree> childContainer = getDeviceTreeForRoute(shortenedRoute, treeContainer->childContainers_);\n    if (childContainer && !treeContainer->childContainers_.contains(childContainer))\n    {\n        treeContainer->childContainers_.append(childContainer);\n    }\n\n    return treeContainer;\n}\n\n//-----------------------------------------------------------------------------\n// Function: LinuxDeviceTreeCpuRoutesContainer::getDeviceTreeContainerForInterface()\n//-----------------------------------------------------------------------------\nQSharedPointer<DeviceTreeUtilities::CpuDeviceTree> LinuxDeviceTreeCpuRoutesContainer::getDeviceTreeContainerForInterface(\n    QSharedPointer<const ConnectivityInterface> interfaceNode,\n    QVector<QSharedPointer<DeviceTreeUtilities::CpuDeviceTree> > treeContainers) const\n{\n    for (auto container : treeContainers)\n    {\n        if (container->interface_ == interfaceNode)\n        {\n            return container;\n        }\n    }\n\n    return QSharedPointer<DeviceTreeUtilities::CpuDeviceTree>();\n}\n\n//-----------------------------------------------------------------------------\n// Function: LinuxDeviceTreeCpuRoutesContainer::addRoute()\n//-----------------------------------------------------------------------------\nvoid LinuxDeviceTreeCpuRoutesContainer::addRoute(QSharedPointer<CpuRouteStructs::CpuRoute> newContainer)\n{\n    CpuRoutesContainer::addRoute(newContainer);\n\n    for (auto route : newContainer->routes_)\n    {\n        QSharedPointer<DeviceTreeUtilities::CpuDeviceTree> cpuDeviceTree = getDeviceTreeForRoute(route, deviceTreeRoutes_);\n        if (cpuDeviceTree && !deviceTreeRoutes_.contains(cpuDeviceTree))\n        {\n            deviceTreeRoutes_.append(cpuDeviceTree);\n        }\n    }\n}"
  },
  {
    "path": "Plugins/LinuxDeviceTree/CPUSelection/LinuxDeviceTreeCpuRoutesContainer.h",
    "content": "//-----------------------------------------------------------------------------\n// File: LinuxDeviceTreeCpuRoutesContainer.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 09.05.2023\n//\n// Description:\n// Container for routes connected to CPUs in Linux Device Tree.\n//-----------------------------------------------------------------------------\n\n#ifndef LINUXDEVICETREECPUROUTESCONTAINER_H\n#define LINUXDEVICETREECPUROUTESCONTAINER_H\n\n#include <Plugins/common/CpuRoutesContainer.h>\n\n//! Utilities for Linux Device Tree CPU route container\nnamespace DeviceTreeUtilities\n{\n    //! Container for interface and the containers connected to it.\n    struct CpuDeviceTree\n    {\n        //! Interface of the container.\n        QSharedPointer<const ConnectivityInterface> interface_;\n\n        //! Containers connected to this interface.\n        QVector<QSharedPointer<CpuDeviceTree> > childContainers_;\n    };\n};\n\n//-----------------------------------------------------------------------------\n//! Container for routes connected to a single CPU.\n//-----------------------------------------------------------------------------\nclass LinuxDeviceTreeCpuRoutesContainer : public CpuRoutesContainer\n{\n\npublic:\n\n    /*!\n     *  The constructor.\n     * \n     *    @param [in] CPU     The CPU.\n     */\n    LinuxDeviceTreeCpuRoutesContainer();\n\n    /*!\n     *  The destructor.\n     */\n    virtual ~LinuxDeviceTreeCpuRoutesContainer() = default;\n\n    /*!\n     *  Copy constructor.\n     * \n     *    @param [in] other   The original to be copied.\n     */\n    LinuxDeviceTreeCpuRoutesContainer(const CpuRoutesContainer& other);\n\n    /*!\n     *  Get the contained CPUs.\n     *\n     *    @return The contained CPUs.\n     */\n    QVector<QSharedPointer<const Cpu> > getCpus() const;\n\n    /*!\n     *  Set the contained CPUs.\n     *\n     *    @param [in] newCpu  The new CPUs.\n     */\n    void setCpus(QVector<QSharedPointer<Cpu> > newCpus);\n\n    /*!\n     *  Add a new connected CPU.\n     *\n     *    @param [in] newCpu  The new CPU.\n     */\n    void addCpu(QSharedPointer<Cpu> newCpu);\n\n    /*!\n     *  Get the file path.\n     *\n     *    @return The file path.\n     */\n    QString getFilePath() const;\n\n    /*!\n     *  Set the file path.\n     *\n     *    @param [in] newFilePath     The new file path.\n     */\n    void setFilePath(QString const& newFilePath);\n\n    /*!\n     *  Get a list of the interface trees connected to this container.\n     *\n     *    @return List of interface trees connected to this container.\n     */\n    QVector<QSharedPointer<DeviceTreeUtilities::CpuDeviceTree> > getDeviceTreeRoutes() const;\n\n    /*!\n     *  Set the connected interface trees for this container.\n     *\n     *    @param [in] newContainers   The new connected interface trees.\n     */\n    virtual void setRoutes(QVector <QSharedPointer<CpuRouteStructs::CpuRoute> > newContainers) override final;\n\n    /*!\n     *  Add a new connected interface tree for this container.\n     *\n     *    @param [in] newContainer    The new connected interface tree.\n     */\n    virtual void addRoute(QSharedPointer<CpuRouteStructs::CpuRoute> newContainer) override final;\n\n    //! No copying. No assignment.\n    LinuxDeviceTreeCpuRoutesContainer(const LinuxDeviceTreeCpuRoutesContainer& other) = delete;\n    LinuxDeviceTreeCpuRoutesContainer& operator=(const LinuxDeviceTreeCpuRoutesContainer& other) = delete;\n\nprivate:\n\n    /*!\n     *  Set up the device tree route containers.\n     *\n     *    @param [in] newRouteContainers  List of the CPU route containers.\n     */\n    void setupDeviceTreeRoutes(QVector<QSharedPointer<CpuRouteStructs::CpuRoute> > newRouteContainers);\n\n    /*!\n     *  Set up a single device tree route container.\n     *\n     *    @param [in] routeContainers     The CPU route container.\n     */\n    void setupSingleDeviceTreeRoute(QSharedPointer<CpuRouteStructs::CpuRoute> routeContainer);\n\n    /*!\n     *  Get the device tree route container for the selected interface route.\n     *\n     *    @param [in] route       The selected route.\n     *    @param [in] treeRoutes  List of the available device tree route containers.\n     *\n     *    @return The device tree route container containing the selected interface route.\n     */\n    QSharedPointer<DeviceTreeUtilities::CpuDeviceTree> getDeviceTreeForRoute(\n        QVector<QSharedPointer<const ConnectivityInterface> > route,\n        QVector<QSharedPointer<DeviceTreeUtilities::CpuDeviceTree> > treeRoutes);\n\n    /*!\n     *  Get the device tree route container for the selected interface.\n     *\n     *    @param [in] interfaceNode   The selected interface.\n     *    @param [in] treeContainers  List of available device tree route containers.\n     *\n     *    @return The device tree route container containing the selected interface.\n     */\n    QSharedPointer<DeviceTreeUtilities::CpuDeviceTree> getDeviceTreeContainerForInterface(\n        QSharedPointer<const ConnectivityInterface> interfaceNode,\n        QVector<QSharedPointer<DeviceTreeUtilities::CpuDeviceTree> > treeContainers) const;\n\n    //-----------------------------------------------------------------------------\n    // Data.\n    //-----------------------------------------------------------------------------\n\n    //! List of connected CPUs.\n    QVector<QSharedPointer<const Cpu> > cpus_;\n\n    //! List of root interface containers.\n    QVector<QSharedPointer<DeviceTreeUtilities::CpuDeviceTree> > deviceTreeRoutes_;\n\n    //! The file path.\n    QString filePath_;\n};\n\n#endif // LINUXDEVICETREECPUROUTESCONTAINER_H"
  },
  {
    "path": "Plugins/LinuxDeviceTree/LinuxDeviceTree.qrc",
    "content": "<RCC>\n    <qresource prefix=\"/icons\">\n        <file>LinuxDeviceTreeGenerator.png</file>\n    </qresource>\n</RCC>\n"
  },
  {
    "path": "Plugins/LinuxDeviceTree/LinuxDeviceTreeDialog.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: LinuxDeviceTreeDialog.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Mikko Teuho\n// Date: 25.05.2018\n//\n// Description:\n// Dialog for setting linux device tree generation options.\n//-----------------------------------------------------------------------------\n\n#include \"LinuxDeviceTreeDialog.h\"\n\n#include <IPXACTmodels/common/ConfigurableVLNVReference.h>\n#include <IPXACTmodels/Component/View.h>\n#include <IPXACTmodels/Component/FileSet.h>\n#include <IPXACTmodels/Component/Component.h>\n#include <IPXACTmodels/Component/DesignInstantiation.h>\n#include <IPXACTmodels/Component/DesignConfigurationInstantiation.h>\n#include <IPXACTmodels/Design/Design.h>\n#include <IPXACTmodels/DesignConfiguration/DesignConfiguration.h>\n\n#include <KactusAPI/include/LibraryInterface.h>\n\n#include <Plugins/common/ConnectivityGraphUtilities.h>\n#include <Plugins/LinuxDeviceTree/CPUSelection/LinuxDeviceTreeCPUEditor.h>\n\n#include <QFileDialog>\n#include <QPushButton>\n#include <QHBoxLayout>\n#include <QVBoxLayout>\n#include <QDialogButtonBox>\n#include <QFormLayout>\n\n//-----------------------------------------------------------------------------\n// Function: LinuxDeviceTreeDialog::LinuxDeviceTreeDialog()\n//-----------------------------------------------------------------------------\nLinuxDeviceTreeDialog::LinuxDeviceTreeDialog(QString const& defaultPath, QSharedPointer<Component> component,\n    QSharedPointer<Design> design, LibraryInterface* library, QWidget* parent):\nQDialog(parent),\nlibrary_(library),\ntopComponent_(component),\nviewSelector_(new QComboBox(this)),\nfileSetGroup_(new QGroupBox(tr(\"Add file to fileset\"))),\nfileSetSelector_(new QComboBox(this)),\nfileEditor_(new QLineEdit(this)),\nwriteBlocks_(new QCheckBox(\"Write address blocks\")),\ncpuEditor_(new LinuxDeviceTreeCPUEditor(this)),\ngraphFactory_(library),\nsearchAlgorithm_()\n{\n    setMinimumWidth(800);\n\n    setWindowTitle(\"Linux Device Tree generator\");\n    setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);\n\n    fileEditor_->setText(defaultPath);\n    fileEditor_->setToolTip(defaultPath);\n\n    fileSetGroup_->setCheckable(true);\n    fileSetGroup_->setChecked(true);\n    fileSetSelector_->setEditable(true);\n\n    setupViewSelector(component, design);\n    setupFileSetSelector(component->getFileSets());\n\n    setupCPUEditor(viewSelector_->currentText());\n\n    connect(viewSelector_, SIGNAL(currentTextChanged(QString const&)),\n        this, SLOT(setupCPUEditor(QString const&)), Qt::UniqueConnection);\n\n    setupLayout();\n}\n\n//-----------------------------------------------------------------------------\n// Function: LinuxDeviceTreeDialog::~LinuxDeviceTreeDialog()\n//-----------------------------------------------------------------------------\nLinuxDeviceTreeDialog::~LinuxDeviceTreeDialog()\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: LinuxDeviceTreeDialog::getOutputPath()\n//-----------------------------------------------------------------------------\nQString LinuxDeviceTreeDialog::getOutputPath() const\n{\n    return fileEditor_->text();\n}\n\n//-----------------------------------------------------------------------------\n// Function: LinuxDeviceTreeDialog::getSelectedView()\n//-----------------------------------------------------------------------------\nQString LinuxDeviceTreeDialog::getSelectedView() const\n{\n    return viewSelector_->currentText();\n}\n\n//-----------------------------------------------------------------------------\n// Function: LinuxDeviceTreeDialog::saveFileToFileSet()\n//-----------------------------------------------------------------------------\nbool LinuxDeviceTreeDialog::saveFileToFileSet() const\n{\n    return fileSetGroup_->isChecked();\n}\n\n//-----------------------------------------------------------------------------\n// Function: LinuxDeviceTreeDialog::getTargetFileSet()\n//-----------------------------------------------------------------------------\nQString LinuxDeviceTreeDialog::getTargetFileSet() const\n{\n    return fileSetSelector_->currentText();\n}\n\n//-----------------------------------------------------------------------------\n// Function: LinuxDeviceTreeDialog::allowAddressBlocks()\n//-----------------------------------------------------------------------------\nbool LinuxDeviceTreeDialog::allowAddressBlocks() const\n{\n    return writeBlocks_->isChecked();\n}\n\n//-----------------------------------------------------------------------------\n// Function: LinuxDeviceTreeDialog::accept()\n//-----------------------------------------------------------------------------\nvoid LinuxDeviceTreeDialog::accept()\n{\n    if (fileEditor_->text().isEmpty())\n    {\n        return;\n    }\n\n    QDialog::accept();\n}\n\n//-----------------------------------------------------------------------------\n// Function: LinuxDeviceTreeDialog::onBrowse()\n//-----------------------------------------------------------------------------\nvoid LinuxDeviceTreeDialog::onBrowse()\n{\n    QString newDir = QFileDialog::getExistingDirectory(this, tr(\"Open Directory\"), fileEditor_->text(),\n        QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks);\n\n    if (!newDir.isEmpty())\n    {\n        fileEditor_->setText(newDir);\n        fileEditor_->setToolTip(newDir);\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: LinuxDeviceTreeDialog::setupViewSelector()\n//-----------------------------------------------------------------------------\nvoid LinuxDeviceTreeDialog::setupViewSelector(QSharedPointer<Component> component, QSharedPointer<Design> design)\n{\n    int currentViewIndex = 0;\n    bool currentViewFound = false;\n    for (int i = 0; i < component->getViews()->size(); ++i)\n    {\n        QSharedPointer<View> view = component->getViews()->at(i);\n        viewSelector_->addItem(view->name());\n\n        if (design)\n        {\n            QString instantiationReference = view->getDesignInstantiationRef();\n            if (!currentViewFound && !instantiationReference.isEmpty())\n            {\n                foreach(QSharedPointer<DesignInstantiation> instantiation, *component->getDesignInstantiations())\n                {\n                    VLNV instantiationVLNVReference(*instantiation->getDesignReference());\n                    if (instantiationVLNVReference.isValid() && instantiation->name() == instantiationReference &&\n                        instantiationVLNVReference == design->getVlnv())\n                    {\n                        currentViewIndex = i;\n                        currentViewFound = true;\n                    }\n                }\n            }\n        }\n    }\n\n    if (currentViewFound)\n    {\n        viewSelector_->setCurrentIndex(currentViewIndex);\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: LinuxDeviceTreeDialog::setupFileSetSelector()\n//-----------------------------------------------------------------------------\nvoid LinuxDeviceTreeDialog::setupFileSetSelector(\n    QSharedPointer<QList<QSharedPointer<FileSet> > > componentFileSets)\n{\n    bool deviceTreeFileSetFound = false;\n    QString deviceTreeSetName(\"deviceTree\");\n\n    for (int i = 0; i < componentFileSets->size(); ++i)\n    {\n        QSharedPointer<FileSet> fileSet = componentFileSets->at(i);\n        fileSetSelector_->addItem(fileSet->name());\n\n        if (!deviceTreeFileSetFound && fileSet->name() == deviceTreeSetName)\n        {\n            deviceTreeFileSetFound = true;\n            fileSetSelector_->setCurrentIndex(i);\n        }\n    }\n\n    if (!deviceTreeFileSetFound)\n    {\n        fileSetSelector_->addItem(deviceTreeSetName);\n        fileSetSelector_->setCurrentIndex(componentFileSets->size());\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: LinuxDeviceTreeDialog::setupCPUEditor()\n//-----------------------------------------------------------------------------\nvoid LinuxDeviceTreeDialog::setupCPUEditor(QString const& view)\n{\n    QVector<QSharedPointer<LinuxDeviceTreeCpuRoutesContainer> > cpuContainers =\n        LinuxDeviceTreeCPUDetails::getCPUContainers(topComponent_->getVlnv().getName(), topComponent_, view, library_);\n\n    cpuEditor_->setupCPUDetails(cpuContainers);\n}\n\n//-----------------------------------------------------------------------------\n// Function: LinuxDeviceTreeDialog::getDesignName()\n//-----------------------------------------------------------------------------\nQString LinuxDeviceTreeDialog::getDesignName()\n{\n    QString viewName = viewSelector_->currentText();\n    for (auto designView : *topComponent_->getViews())\n    {\n        if (designView->name() == viewName)\n        {\n            QString instantiationReference = designView->getDesignInstantiationRef();\n            if (!instantiationReference.isEmpty())\n            {\n                for (auto instantiation : *topComponent_->getDesignInstantiations())\n                {\n                    if (instantiation->name() == instantiationReference)\n                    {\n                        QSharedPointer<ConfigurableVLNVReference> designVLNV =\n                            instantiation->getDesignReference();\n                        if (designVLNV)\n                        {\n                            return designVLNV->getName();\n                        }\n\n                        break;\n                    }\n                }\n            }\n            else\n            {\n                instantiationReference = designView->getDesignConfigurationInstantiationRef();\n                if (!instantiationReference.isEmpty())\n                {\n                    for (auto instantiation : *topComponent_->getDesignConfigurationInstantiations())\n                    {\n                        if (instantiation->name() == instantiationReference)\n                        {\n                            QSharedPointer<ConfigurableVLNVReference> designConfigurationVLNV =\n                                instantiation->getDesignConfigurationReference();\n\n                            QSharedPointer<const Document> designDocument =\n                                library_->getModelReadOnly(*designConfigurationVLNV.data());\n                            if (designDocument)\n                            {\n                                QSharedPointer<const DesignConfiguration> designConfiguration =\n                                    designDocument.dynamicCast<const DesignConfiguration>();\n                                if (designConfiguration)\n                                {\n                                    return designConfiguration->getDesignRef().getName();\n                                }\n                            }\n\n                            break;\n                        }\n                    }\n                }\n            }\n        }\n    }\n\n    return \"\";\n}\n\n//-----------------------------------------------------------------------------\n// Function: LinuxDeviceTreeDialog::setupLayout()\n//-----------------------------------------------------------------------------\nvoid LinuxDeviceTreeDialog::setupLayout()\n{\n    QFormLayout* viewLayout = new QFormLayout();\n    viewLayout->addRow(tr(\"Select view:\"), viewSelector_);\n\n    viewLayout->addRow(writeBlocks_);\n\n    QFormLayout* fileSetLayout = new QFormLayout();\n    fileSetLayout->addRow(tr(\"Select file set:\"), fileSetSelector_);\n    fileSetGroup_->setLayout(fileSetLayout);\n\n    QPushButton* openFolderButton(\n        new QPushButton(QIcon(\":icons/common/graphics/opened-folder.png\"), QString(), this));\n\n    QHBoxLayout* fileLayout = new QHBoxLayout();\n    fileLayout->addWidget(new QLabel(tr(\"Output file:\"), this));\n    fileLayout->addWidget(fileEditor_);\n    fileLayout->addWidget(openFolderButton);\n\n    QGroupBox* settingsGroup = new QGroupBox(tr(\"Settings\"), this);\n    QVBoxLayout* settingsLayout = new QVBoxLayout(settingsGroup);\n\n    settingsLayout->addLayout(viewLayout);\n    settingsLayout->addLayout(fileLayout);\n    settingsLayout->addWidget(fileSetGroup_);\n\n    QDialogButtonBox* buttons = new QDialogButtonBox(Qt::Horizontal, this);\n    buttons->addButton(tr(\"Write file\"), QDialogButtonBox::AcceptRole);\n    buttons->addButton(QDialogButtonBox::Cancel);\n\n    QHBoxLayout* editorLayout = new QHBoxLayout();\n    editorLayout->addWidget(settingsGroup);\n    editorLayout->addWidget(cpuEditor_, 3);\n\n    QVBoxLayout* topLayout = new QVBoxLayout(this);\n    topLayout->addLayout(editorLayout);\n    topLayout->addWidget(buttons);\n\n    connect(openFolderButton, SIGNAL(clicked()), this, SLOT(onBrowse()), Qt::UniqueConnection);\n    connect(buttons, SIGNAL(accepted()), this, SLOT(accept()), Qt::UniqueConnection);\n    connect(buttons, SIGNAL(rejected()), this, SLOT(reject()), Qt::UniqueConnection);\n}\n\n//-----------------------------------------------------------------------------\n// Function: LinuxDeviceTreeDialog::getAcceptedContainers()\n//-----------------------------------------------------------------------------\nQVector<QSharedPointer<LinuxDeviceTreeCpuRoutesContainer> > LinuxDeviceTreeDialog::getAcceptedContainers() const\n{\n    return cpuEditor_->getAcceptedContainers();\n}\n"
  },
  {
    "path": "Plugins/LinuxDeviceTree/LinuxDeviceTreeDialog.h",
    "content": "//-----------------------------------------------------------------------------\n// File: LinuxDeviceTreeDialog.h\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Mikko Teuho\n// Date: 25.05.2018\n//\n// Description:\n// Dialog for setting linux device tree generation options.\n//-----------------------------------------------------------------------------\n\n#ifndef LINUXDEVICETREEDIALOG_H\n#define LINUXDEVICETREEDIALOG_H\n\nclass FileSet;\nclass View;\nclass VLNV;\nclass Component;\nclass Design;\nclass LinuxDeviceTreeCPUEditor;\n\n#include <editors/MemoryDesigner/ConnectivityGraphFactory.h>\n#include <editors/MemoryDesigner/MasterSlavePathSearch.h>\n\n#include <Plugins/LinuxDeviceTree/CPUSelection/LinuxDeviceTreeCPUDetails.h>\n\n#include <QDialog>\n#include <QComboBox>\n#include <QGroupBox>\n#include <QLineEdit>\n#include <QLabel>\n#include <QSharedPointer>\n#include <QCheckBox>\n\nclass LinuxDeviceTreeCpuRoutesContainer;\n\n//-----------------------------------------------------------------------------\n//! Dialog for setting linux device tree generation options.\n//-----------------------------------------------------------------------------\nclass LinuxDeviceTreeDialog: public QDialog\n{\n    Q_OBJECT\npublic:\n    \n    /*!\n     *\tThe constructor.\n     *\n     *\t\t@param [in]\tdefaultPath     The default path for the Linux Device Tree file.\n     *\t\t@param [in]\tcomponent       The top component of the selected design.\n     *\t\t@param [in]\tdesign          The selected design.\n     *    @param [in] library         The library interface.\n     *\t\t@param [in]\tparent          Parent item for the dialog.\n     */\n    LinuxDeviceTreeDialog(QString const& defaultPath, QSharedPointer<Component> component,\n        QSharedPointer<Design> design, LibraryInterface* library, QWidget* parent);\n\n\t/*!\n     *  The destructor.\n     */\n    virtual ~LinuxDeviceTreeDialog();\n\n    /*!\n     *\tGet the output path for the device tree file.\n     *\n     *\t\t@return\tThe output path of the device tree file.\n     */\n    QString getOutputPath() const;\n\n    /*!\n     *  Get the top component view from which the device tree file is constructed from.\n     *\n     *    @return\tThe name of the selected view.\n     */\n    QString getSelectedView() const;\n\n    /*!\n     *  Check if the file should be saved to a file set.\n     *\n     *    @return\tTrue, if the file should be saved to a file set, false otherwise.\n     */\n    bool saveFileToFileSet() const;\n\n    /*!\n     *  Get the name of the file set where to save the file to.\n     *\n     *    @return\tThe name of the selected file set.\n     */\n    QString getTargetFileSet() const;\n\n    /*!\n     *  Check if address blocks should be written.\n     *\n     *    @return True, if address blocks should be written, false otherwise.\n     */\n    bool allowAddressBlocks() const;\n\n    /*!\n     *  Get the list of the selected CPU containers.\n     *\n     *    @return List of the selected CPU containers.\n     */\n    QVector<QSharedPointer<LinuxDeviceTreeCpuRoutesContainer> > getAcceptedContainers() const;\n\npublic slots:\n\n    /*!\n     *\tHandles the accepting of the dialog.\n     */\n    void accept();\n\nprivate slots:\n\n    /*!\n     *\tHandles the target file browsing.\n     */\n    void onBrowse();\n\n    /*!\n     *  Setup the CPU editor.\n     *\n     *    @param [in] view    Name of the active view.\n     */\n    void setupCPUEditor(QString const& view);\n\nprivate:\n\n\t// Disable copying. Disable assignment.\n    LinuxDeviceTreeDialog(LinuxDeviceTreeDialog const& rhs);\n    LinuxDeviceTreeDialog& operator=(LinuxDeviceTreeDialog const& rhs);\n\n    /*!\n     *\tSetup the view selector for the selected component. Set the current view according to the selected design.\n     *\n     *\t\t@param [in]\tcomponent   The selected component.\n     *\t\t@param [in]\tdesign      The selected design.\n     */\n    void setupViewSelector(QSharedPointer<Component> component, QSharedPointer<Design> design);\n\n    /*!\n     *\tSetup the file set selector for the selected component.\n     *\n     *\t\t@param [in]\tcomponentFileSets   File sets of the selected component.\n     */\n    void setupFileSetSelector(QSharedPointer<QList<QSharedPointer<FileSet> > > componentFileSets);\n\n    /*!\n     *  Get the name of the design referenced by the currently active view.\n     *\n     *\n     *    @return \n     */\n    QString getDesignName();\n\n    /*!\n     *\tSetup the dialog layout.\n     */\n    void setupLayout();\n\n    //-----------------------------------------------------------------------------\n    // Data.\n    //-----------------------------------------------------------------------------\n\n    //! The library interface.\n    LibraryInterface* library_;\n\n    //! The component from which the linux device tree is created from.\n    QSharedPointer<Component> topComponent_;\n\n    //! Selects the target view.\n    QComboBox* viewSelector_;\n\n    //! Groups the desired items for file set selection.\n    QGroupBox* fileSetGroup_;\n\n    //! Selects the target file set.\n    QComboBox* fileSetSelector_;\n\n    //! Editor for selecting the path for the device tree file.\n    QLineEdit* fileEditor_;\n\n    //! Check box for writing address blocks.\n    QCheckBox* writeBlocks_;\n\n    //! Editor for CPU details.\n    LinuxDeviceTreeCPUEditor* cpuEditor_;\n\n    //! Factory for creating connectivity graphs.\n    ConnectivityGraphFactory graphFactory_;\n\n    //! Master slave search algorithm for connectivity graphs.\n    MasterSlavePathSearch searchAlgorithm_;\n};\n\n#endif // LINUXDEVICETREEDIALOG_H\n"
  },
  {
    "path": "Plugins/LinuxDeviceTree/LinuxDeviceTreeGenerator.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: LinuxDeviceTreePlugin.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Copyright: Tampere University of Technology\n// Author: Mikko Teuho\n// Date: 08.05.2018\n//\n// Description:\n// Creates a Linux Device Tree from the selected document.\n//-----------------------------------------------------------------------------\n\n#include \"LinuxDeviceTreeGenerator.h\"\n\n#include <IPXACTmodels/common/Document.h>\n#include <IPXACTmodels/Component/Component.h>\n#include <IPXACTmodels/Component/Cpu.h>\n#include <IPXACTmodels/Component/AddressSpace.h>\n#include <IPXACTmodels/Component/MemoryMap.h>\n#include <IPXACTmodels/Component/AddressBlock.h>\n#include <IPXACTmodels/Design/Design.h>\n#include <IPXACTmodels/DesignConfiguration/DesignConfiguration.h>\n\n#include <KactusAPI/include/LibraryInterface.h>\n\n#include <editors/MemoryDesigner/MemoryItem.h>\n#include <editors/MemoryDesigner/ConnectivityGraph.h>\n#include <editors/MemoryDesigner/MasterSlavePathSearch.h>\n#include <editors/MemoryDesigner/ConnectivityInterface.h>\n#include <editors/MemoryDesigner/ConnectivityComponent.h>\n#include <editors/MemoryDesigner/MemoryDesignerConstants.h>\n\n#include <Plugins/LinuxDeviceTree/CPUSelection/LinuxDeviceTreeCpuRoutesContainer.h>\n\n#include <QTextStream>\n\nnamespace\n{\n    QString const TABPREFIX = QLatin1String(\"\\t\");\n};\n\n//-----------------------------------------------------------------------------\n// Function: LinuxDeviceTreeGenerator::LinuxDeviceTreeGenerator()\n//-----------------------------------------------------------------------------\nLinuxDeviceTreeGenerator::LinuxDeviceTreeGenerator(LibraryInterface* library):\nlibrary_(library),\ngraphFactory_(library)\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: LinuxDeviceTreeGenerator::generate()\n//-----------------------------------------------------------------------------\nbool LinuxDeviceTreeGenerator::generate(QSharedPointer<Component> topComponent, QString const& activeView,\n    bool writeAddressBlocks, QVector<QSharedPointer<LinuxDeviceTreeCpuRoutesContainer> > cpuContainers,\n    QString const& outputFolder)\n{\n    QSharedPointer<const Design> hierarchicalDesign;\n    QSharedPointer<View> designView = getView(topComponent, activeView);\n    if (designView)\n    {\n        QSharedPointer<const DesignConfiguration> hierarchicalConfiguration =\n            getDesignConfiguration(topComponent, designView);\n        hierarchicalDesign = getHierarchicalDesign(topComponent, designView, hierarchicalConfiguration);\n    }\n\n    if (!hierarchicalDesign)\n    {\n        return false;\n    }\n\n    QString designVendor = hierarchicalDesign->getVlnv().getVendor();\n    QString designName = hierarchicalDesign->getVlnv().getName();\n\n    for (auto cpuContainer : cpuContainers)\n    {\n        writeFile(designVendor, designName, cpuContainer, writeAddressBlocks, outputFolder);\n    }\n\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: LinuxDeviceTreeGenerator::getDesignConfiguration()\n//-----------------------------------------------------------------------------\nQSharedPointer<const DesignConfiguration> LinuxDeviceTreeGenerator::getDesignConfiguration(\n    QSharedPointer<Component const> containingComponent, QSharedPointer<View> referencingView) const\n{\n    QString configurationReference = referencingView->getDesignConfigurationInstantiationRef();\n    if (!configurationReference.isEmpty())\n    {\n        for (auto instantiation : *containingComponent->getDesignConfigurationInstantiations())\n        {\n            if (instantiation->name().compare(configurationReference) == 0)\n            {\n               auto configurationVLNV = instantiation->getDesignConfigurationReference();\n\n                return library_->getModelReadOnly<const DesignConfiguration>(*configurationVLNV);\n            }\n        }\n    }\n\n    return QSharedPointer<const DesignConfiguration>();\n}\n\n//-----------------------------------------------------------------------------\n// Function: LinuxDeviceTreeGenerator::getDesignInstantiation()\n//-----------------------------------------------------------------------------\nQSharedPointer<const Design> LinuxDeviceTreeGenerator::getHierarchicalDesign(\n    QSharedPointer<Component const> containingComponent, QSharedPointer<View> referencingView,\n    QSharedPointer<const DesignConfiguration> designConfiguration) const\n{\n    VLNV designVLNV = getHierarchicalDesignVLNV(containingComponent, referencingView);\n\n    if (!designVLNV.isValid() && !designConfiguration.isNull())\n    {\n        designVLNV = designConfiguration->getDesignRef();\n    }\n\n    if (designVLNV.isValid())\n    {\n        return library_->getModelReadOnly<const Design>(designVLNV);\n    }\n\n    return QSharedPointer<const Design>();\n}\n\n//-----------------------------------------------------------------------------\n// Function: LinuxDeviceTreeGenerator::getHierarchicalDesignVLNV()\n//-----------------------------------------------------------------------------\nVLNV LinuxDeviceTreeGenerator::getHierarchicalDesignVLNV(QSharedPointer<Component const> containingComponent,\n    QSharedPointer<View> referencingView) const\n{\n    QString referencedInstantiation = referencingView->getDesignInstantiationRef();\n\n    if (!referencedInstantiation.isEmpty())\n    {\n        for (QSharedPointer<DesignInstantiation> instantiation : *containingComponent->getDesignInstantiations())\n        {\n            if (instantiation->name().compare(referencedInstantiation) == 0)\n            {\n                return VLNV(*instantiation->getDesignReference());\n            }\n        }\n    }\n\n    return VLNV();\n}\n\n//-----------------------------------------------------------------------------\n// Function: LinuxDeviceTreeGenerator::writeFile()\n//-----------------------------------------------------------------------------\nvoid LinuxDeviceTreeGenerator::writeFile(QString const& designVendor, QString const& designName,\n    QSharedPointer<LinuxDeviceTreeCpuRoutesContainer> cpuContainer, bool writeAddressBlocks,\n    QString const& outputFolder)\n{\n    QString outputPath = outputFolder + \"/\" + cpuContainer->getFileName() + \".dts\";\n    cpuContainer->setFilePath(outputPath);\n\n    QFile outputFile(outputPath);\n    if (!outputFile.open(QIODevice::WriteOnly))\n    {\n        return;\n    }\n\n    QString prefix = TABPREFIX;\n    QTextStream outputStream(&outputFile);\n\n    QSharedPointer<DeviceTreeUtilities::CpuDeviceTree> rootContainer(new DeviceTreeUtilities::CpuDeviceTree());\n    rootContainer->interface_ = QSharedPointer<const ConnectivityInterface>(new ConnectivityInterface(\"Root\"));\n    rootContainer->childContainers_ = cpuContainer->getDeviceTreeRoutes();\n\n    QPair<quint64, quint64> addressSizeRequirements =\n        getAddressAndSizeRequirements(rootContainer, QSharedPointer<ConnectivityInterface const>(), 0, 0, false);\n\n    auto addressWordSize = calculateWordSize(addressSizeRequirements.first);\n    auto rangeWordSize = calculateWordSize(addressSizeRequirements.second);\n\n    writeTreeStart(outputStream, designVendor, designName, prefix, addressWordSize, rangeWordSize);\n    writeContainer(outputStream, cpuContainer, writeAddressBlocks, prefix, addressWordSize, rangeWordSize);\n\n    prefix.remove(0, 1);\n    writeLineEnding(outputStream, prefix);\n    outputStream << Qt::endl;\n\n    outputFile.close();\n}\n\n//-----------------------------------------------------------------------------\n// Function: LinuxDeviceTreeGenerator::writeTreeStart()\n//-----------------------------------------------------------------------------\nvoid LinuxDeviceTreeGenerator::writeTreeStart(QTextStream& outputStream, QString const& designVendor,\n    QString const& designName, QString const& prefix, int addressSize, int rangeSize) const\n{\n    outputStream << \"/dts-v1/;\" << Qt::endl << Qt::endl << \"/ {\" << Qt::endl;\n\n    outputStream << prefix << \"#address-cells = <\" << QString::number(addressSize) << \">;\" <<\n        Qt::endl;\n    outputStream << prefix << \"#size-cells = <\" << QString::number(rangeSize) << \">;\" << Qt::endl;\n\n    QString compatibaleText = \"\\\"\" + designVendor + \",\" + designName + \"\\\";\";\n    outputStream << prefix << \"model = \" << compatibaleText << Qt::endl;\n    outputStream << prefix << \"compatible = \" << compatibaleText << Qt::endl << Qt::endl;\n}\n\n//-----------------------------------------------------------------------------\n// Function: LinuxDeviceTreeGenerator::writePaths()\n//-----------------------------------------------------------------------------\nvoid LinuxDeviceTreeGenerator::writeContainer(QTextStream& outputStream,\n    QSharedPointer<LinuxDeviceTreeCpuRoutesContainer> cpuContainer, bool writeAddressBlocks, QString& prefix,\n    int addressSize, int rangeSize)\n{\n    if (cpuContainer->getDeviceTreeRoutes().isEmpty() || !cpuContainer->getDeviceTreeRoutes().first()->interface_)\n    {\n        return;\n    }\n\n    QSharedPointer<const ConnectivityInterface> firstInterface = cpuContainer->getDeviceTreeRoutes().first()->interface_;\n    QString componentVLNV = firstInterface->getInstance()->getVlnv();\n\n    writeIntroductionToCPUs(outputStream, cpuContainer->getCpus(), componentVLNV, prefix);\n\n    prefix.remove(0, 1);\n    writeLineEnding(outputStream, prefix);\n    outputStream << Qt::endl;\n\n    for (auto deviceTreeContainer : cpuContainer->getDeviceTreeRoutes())\n    {\n        startPathWriting(outputStream, deviceTreeContainer, writeAddressBlocks, prefix, addressSize, rangeSize);\n    }\n\n    writeMemories(outputStream, cpuContainer, prefix, writeAddressBlocks, addressSize, rangeSize);\n}\n\n//-----------------------------------------------------------------------------\n// Function: LinuxDeviceTreeGenerator::writeIntroductionCPUs()\n//-----------------------------------------------------------------------------\nvoid LinuxDeviceTreeGenerator::writeIntroductionToCPUs(QTextStream& outputStream,\n    QVector<QSharedPointer<const Cpu>> cpus, QString const& componentVLNV, QString& prefix)\n{\n    outputStream << prefix << \"cpus {\" << Qt::endl;\n\n    prefix.append(TABPREFIX);\n\n    outputStream << prefix << \"#address-cells = <1>;\" << Qt::endl;\n    outputStream << prefix << \"#size-cells = <0>;\" << Qt::endl << Qt::endl;\n\n    for (int i = 0; i < cpus.size(); ++i)\n    {\n        QSharedPointer<Cpu const> currentCPU = cpus.at(i);\n        writeCPU(outputStream, currentCPU->name(), componentVLNV, i, prefix);\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: LinuxDeviceTreeGenerator::writeCPU()\n//-----------------------------------------------------------------------------\nvoid LinuxDeviceTreeGenerator::writeCPU(QTextStream& outputStream, QString const& CPUName,\n    QString const& componentVLNV, int cpuNumber, QString& prefix)\n{\n    outputStream << prefix << \"// '\" << CPUName << \"' in component \" << componentVLNV << Qt::endl;\n    outputStream << prefix << \"cpu@\" << QString::number(cpuNumber) << \" {\" << Qt::endl;\n    prefix.append(TABPREFIX);\n\n    outputStream << prefix << \"reg = <\" << QString::number(cpuNumber) << \">;\" << Qt::endl;\n\n    prefix.remove(0, 1);\n    writeLineEnding(outputStream, prefix);\n}\n\n//-----------------------------------------------------------------------------\n// Function: LinuxDeviceTreeGenerator::startPathWriting()\n//-----------------------------------------------------------------------------\nvoid LinuxDeviceTreeGenerator::startPathWriting(QTextStream& outputStream,\n    QSharedPointer<DeviceTreeUtilities::CpuDeviceTree> nodeContainer,\n    bool writeAddressBlocks, QString& prefix, int addressSize, int rangeSize)\n{\n    quint64 memoryItemBaseAddress = 0;\n    quint64 memoryItemRange = 0;\n    writePathNode(outputStream, QSharedPointer<ConnectivityInterface>(), nodeContainer, memoryItemBaseAddress,\n        memoryItemRange, prefix, writeAddressBlocks, addressSize, rangeSize);\n}\n\n//-----------------------------------------------------------------------------\n// Function: LinuxDeviceTreeGenerator::writePathNode()\n//-----------------------------------------------------------------------------\nvoid LinuxDeviceTreeGenerator::writePathNode(QTextStream& outputStream, QSharedPointer<const ConnectivityInterface> previousInterface,\n    QSharedPointer<DeviceTreeUtilities::CpuDeviceTree> nodeContainer, quint64 const& baseAddress, quint64 const& memoryItemRange,\n    QString& prefix, bool writeAddressBlocks, int addressSize, int rangeSize)\n{\n    QSharedPointer<const ConnectivityInterface> containerInterface = nodeContainer->interface_;\n    if (!canWriteNode(containerInterface, previousInterface))\n    {\n        return;\n    }\n\n    General::InterfaceMode containerMode = containerInterface->getMode();\n\n    quint64 newBaseAddress = baseAddress;\n    quint64 newMemoryRange = memoryItemRange;\n\n    if (containerInterface->getInstance()->isChanneled() &&\n        (!previousInterface || containerInterface->getInstance() != previousInterface->getInstance()))\n    {\n        writeBridge(outputStream, containerInterface, \"channel\", addressSize, rangeSize, prefix);\n    }\n\n    if (containerMode == General::MASTER || containerMode == General::INITIATOR)\n    {\n        newBaseAddress += containerInterface->getBaseAddress().toULongLong();\n    }\n    else if (containerMode == General::MIRRORED_SLAVE || containerMode == General::MIRRORED_TARGET)\n    {\n        newBaseAddress += containerInterface->getRemapAddress().toULongLong();\n        newMemoryRange = containerInterface->getRemapRange().toULongLong();\n    }\n    else if (containerMode == General::SLAVE || containerMode == General::TARGET)\n    {\n        if (containerInterface->isBridged())\n        {\n            //! Override current address-cells and size-cells.\n            QPair<quint64, quint64> addressSizeRequirements = getAddressAndSizeRequirements(\n                nodeContainer, QSharedPointer<const ConnectivityInterface>(), newBaseAddress, newMemoryRange, true);\n\n            addressSize = calculateWordSize(addressSizeRequirements.first);\n            rangeSize = calculateWordSize(addressSizeRequirements.second);\n\n            writeBridge(outputStream, containerInterface, \"bridge\", addressSize, rangeSize, prefix);\n        }\n        else if (containerInterface->getConnectedMemory())\n        {\n            QPair<quint64, quint64> memoryAddress =\n                MemoryConnectionAddressCalculator::getMemoryMapAddressRanges(containerInterface->getConnectedMemory());\n\n            quint64 mapBaseAddress = newBaseAddress + memoryAddress.first;\n            if (newMemoryRange == 0)\n            {\n                newMemoryRange = memoryAddress.second + 1;\n            }\n\n            writeMemoryData(outputStream, newBaseAddress, mapBaseAddress,\n                newMemoryRange, addressSize, rangeSize, false, prefix, containerInterface, writeAddressBlocks);\n\n            outputStream << Qt::endl;\n            return;\n        }\n    }\n\n    for (auto leafContainer : nodeContainer->childContainers_)\n    {\n        writePathNode(outputStream, containerInterface, leafContainer, newBaseAddress,\n            newMemoryRange, prefix, writeAddressBlocks, addressSize, rangeSize);\n    }\n\n    if (((containerMode == General::SLAVE || containerMode == General::TARGET) &&\n        containerInterface->isBridged()) ||\n        (containerInterface->getInstance()->isChanneled() &&\n            (!previousInterface || containerInterface->getInstance() != previousInterface->getInstance())))\n    {\n        prefix.remove(0, 1);\n        writeLineEnding(outputStream, prefix);\n        outputStream << Qt::endl;\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: LinuxDeviceTreeGenerator::canWriteNode()\n//-----------------------------------------------------------------------------\nbool LinuxDeviceTreeGenerator::canWriteNode(QSharedPointer<const ConnectivityInterface> interfaceNode,\n    QSharedPointer<const ConnectivityInterface> previousNode) const\n{\n    if (LinuxDeviceTreeCPUDetails::interfacedItemIsMemory(interfaceNode))\n    {\n        return false;\n    }\n    else if (interfaceNode->getChildInterfaceNodes().isEmpty())\n    {\n        return true;\n    }\n\n    for (auto childNode : interfaceNode->getChildInterfaceNodes())\n    {\n        if (childNode != previousNode && canWriteNode(childNode, interfaceNode))\n        {\n            return true;\n        }\n    }\n\n    return false;\n}\n\n//-----------------------------------------------------------------------------\n// Function: LinuxDeviceTreeGenerator::writeLineEnding()\n//-----------------------------------------------------------------------------\nvoid LinuxDeviceTreeGenerator::writeLineEnding(QTextStream& outputStream, QString const& prefix) const\n{\n    outputStream << prefix << \"};\" << Qt::endl;\n}\n\n//-----------------------------------------------------------------------------\n// Function: LinuxDeviceTreeGenerator::writeBridge()\n//-----------------------------------------------------------------------------\nvoid LinuxDeviceTreeGenerator::writeBridge(QTextStream& outputStream,\n    QSharedPointer<ConnectivityInterface const> interfaceNode, QString const& bridgeType,\n    int addressSize, int rangeSize, QString& prefix)\n{\n    QString instanceName = interfaceNode->getInstance()->getName();\n    QString componentVLNV = interfaceNode->getInstance()->getVlnv();\n    QSharedPointer<const Component> interfacedComponent =\n        LinuxDeviceTreeCPUDetails::getComponentContainingInterface(interfaceNode, library_);\n\n    outputStream << prefix << \"// Instance '\" << instanceName << \"' of \" << bridgeType << \" component \" <<\n        componentVLNV << Qt::endl;\n    outputStream << prefix << interfacedComponent->getVlnv().getName() << \" {\" << Qt::endl;\n\n    prefix.append(TABPREFIX);\n\n    outputStream << prefix << \"compatible = \\\"simple-bus\\\";\" << Qt::endl;\n    outputStream << prefix << \"#address-cells = <\" << QString::number(addressSize) << \">;\" << Qt::endl;\n    outputStream << prefix << \"#size-cells = <\" << QString::number(rangeSize) << \">;\" << Qt::endl << Qt::endl;\n}\n\n//-----------------------------------------------------------------------------\n// Function: LinuxDeviceTreeGenerator::getAddressAndSizeRequirements()\n//-----------------------------------------------------------------------------\nQPair<quint64, quint64> LinuxDeviceTreeGenerator::getAddressAndSizeRequirements(\n    QSharedPointer<DeviceTreeUtilities::CpuDeviceTree> rootContainer,\n    QSharedPointer<ConnectivityInterface const> previousNode, quint64 baseAddress, quint64 memoryRange, bool stopAtBridges)\n{\n    QPair<quint64, quint64> addressSizeRequirements;\n    addressSizeRequirements.first = baseAddress;\n    addressSizeRequirements.second = memoryRange;\n\n    QSharedPointer<const ConnectivityInterface> containerInterface = rootContainer->interface_;\n\n    if (!canWriteNode(containerInterface, previousNode))\n    {\n        return addressSizeRequirements;\n    }\n\n    if (stopAtBridges && (containerInterface->getInstance()->isChanneled() && previousNode &&\n        containerInterface->getInstance() != previousNode->getInstance()))\n    {\n        return addressSizeRequirements;\n    }\n\n    quint64 newBaseAddress = baseAddress;\n    quint64 newRange = memoryRange;\n\n    if (containerInterface->getMode() == General::MASTER || containerInterface->getMode() == General::INITIATOR)\n    {\n        newBaseAddress += containerInterface->getBaseAddress().toULongLong();\n    }\n    else if (containerInterface->getMode() == General::MIRRORED_SLAVE || containerInterface->getMode() == General::MIRRORED_TARGET)\n    {\n        newBaseAddress += containerInterface->getRemapAddress().toULongLong();\n        newRange = containerInterface->getRemapRange().toULongLong();\n    }\n    else if (containerInterface->getMode() == General::SLAVE || containerInterface->getMode() == General::TARGET)\n    {\n        if (containerInterface->isBridged())\n        {\n            return addressSizeRequirements;\n        }\n        else if (containerInterface->getConnectedMemory())\n        {\n            QPair<quint64, quint64> memoryAddress =\n                MemoryConnectionAddressCalculator::getMemoryMapAddressRanges(containerInterface->getConnectedMemory());\n\n            if (newRange == 0)\n            {\n                newRange = memoryAddress.second + 1;\n            }\n\n            addressSizeRequirements.first += memoryAddress.first;\n            addressSizeRequirements.second = newRange;\n\n            return addressSizeRequirements;\n        }\n    }\n\n    for (auto pathContainer : rootContainer->childContainers_)\n    {\n        QPair<quint64, quint64> newAddressSize =\n            getAddressAndSizeRequirements(pathContainer, containerInterface, newBaseAddress, newRange, stopAtBridges);\n\n        if (newAddressSize.first > addressSizeRequirements.first)\n        {\n            addressSizeRequirements.first = newAddressSize.first;\n        }\n        if (newAddressSize.second > addressSizeRequirements.second)\n        {\n            addressSizeRequirements.second = newAddressSize.second;\n        }\n    }\n\n    return addressSizeRequirements;\n}\n\n//-----------------------------------------------------------------------------\n// Function: LinuxDeviceTreeGenerator::calculateWordSize()\n//-----------------------------------------------------------------------------\nunsigned int LinuxDeviceTreeGenerator::calculateWordSize(quint64 const& requirementValue) const\n{\n    QString requirement = QString::number(requirementValue, 2);\n    int wordSize = requirement.size() / 32;\n\n    if (requirement.size() > wordSize * 32)\n    {\n        wordSize += 1;\n    }\n\n    return wordSize;\n}\n\n//-----------------------------------------------------------------------------\n// Function: LinuxDeviceTreeGenerator::writeMemoryData()\n//-----------------------------------------------------------------------------\nvoid LinuxDeviceTreeGenerator::writeMemoryData(QTextStream& outputStream, \n    quint64 const& itemBaseAddress,\n    quint64 const& mapBaseAddress, quint64 const& range,\n    int addressSize, int rangeSize, bool isMemory, QString& prefix,\n    QSharedPointer<ConnectivityInterface const> memoryNode, bool writeAddressBlocks) const\n{\n    QString instanceName = memoryNode->getInstance()->getName();\n    QString componentVLNV = memoryNode->getInstance()->getVlnv();\n    QString mapName = memoryNode->getConnectedMemory()->getName();\n\n    QString writtenName = mapName;\n\n    if (isMemory)\n    {\n        writtenName = QLatin1String(\"memory\");\n    }\n\n    outputStream << prefix << \"// Memory map '\" << mapName << \"' in instance '\" << instanceName <<\n        \"' of component \" << componentVLNV << Qt::endl;\n    outputStream << prefix << writtenName << \"@\" << QString::number(mapBaseAddress, 16) << \" {\" << Qt::endl;\n    prefix.append(TABPREFIX);\n\n    if (isMemory)\n    {\n        outputStream << prefix << QLatin1String(\"device_type = \\\"memory\\\";\") << Qt::endl;\n    }\n\n    outputStream << prefix << \"#address-cells = <\" << QString::number(addressSize) << \">;\" <<\n        Qt::endl;\n    outputStream << prefix << \"#size-cells = <\" << QString::number(rangeSize) << \">;\" << Qt::endl;\n\n    writeRegister(outputStream, mapBaseAddress, range, addressSize, rangeSize, prefix);\n\n    if (writeAddressBlocks && !isMemory)\n    {\n        writeAddressBlocksData(outputStream, memoryNode, itemBaseAddress, addressSize, rangeSize, prefix);\n    }\n\n    prefix.remove(0, 1);\n    writeLineEnding(outputStream, prefix);\n}\n\n//-----------------------------------------------------------------------------\n// Function: LinuxDeviceTreeGenerator::writeAddressBlocksData()\n//-----------------------------------------------------------------------------\nvoid LinuxDeviceTreeGenerator::writeAddressBlocksData(QTextStream& outputStream,\n    QSharedPointer<ConnectivityInterface const> memoryNode, quint64 const& itemBaseAddress, \n    int addressSize, int rangeSize, QString& prefix) const\n{\n    for (auto childItem : memoryNode->getConnectedMemory()->getChildItems())\n    {\n        if (childItem->getType() == MemoryDesignerConstants::ADDRESSBLOCK_TYPE)\n        {\n            QString vendor;\n            if (QStringList vlnvList = memoryNode->getInstance()->getVlnv().split(\":\"); vlnvList.isEmpty() == false)\n            {\n                vendor = vlnvList.first();\n            }\n\n            writeSingleAddressBlock(outputStream, vendor, childItem, itemBaseAddress, addressSize, rangeSize, \n                prefix);\n        }\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: LinuxDeviceTreeGenerator::writeSingleAddressBlock()\n//-----------------------------------------------------------------------------\nvoid LinuxDeviceTreeGenerator::writeSingleAddressBlock(QTextStream& outputStream,\n    QString const& vendorName, QSharedPointer<MemoryItem> blockItem,\n    quint64 const& itemBaseAddress, int addressSize, int rangeSize, QString& prefix) const\n{\n    QString blockName = blockItem->getName();\n    quint64 address = blockItem->getAddress().toULongLong() + itemBaseAddress;\n    QString addressString = QString::number(address, 16);\n\n    QString status = getStatus(blockItem);\n\n    outputStream << Qt::endl;\n    outputStream << prefix << \"// Address block '\" << blockName << \"'\" << Qt::endl;\n    outputStream << prefix << blockItem->getName() << \"@\" << addressString << \" {\" <<  Qt::endl;\n    prefix.append(TABPREFIX);\n\n    outputStream << prefix << \"compatible = \\\"\" << vendorName << \",\" << blockName << \"\\\";\" << Qt::endl;\n    outputStream << prefix << \"status = \\\"\" << status << \"\\\";\" << Qt::endl;\n\n    General::Usage blockUsage = blockItem->getUsage();\n    if (blockUsage == General::REGISTER)\n    {\n        writeRegister(outputStream, address, blockItem->getRange().toULongLong(), addressSize, rangeSize, prefix);\n    }\n    else if (blockUsage == General::MEMORY)\n    {\n        outputStream << prefix << \"device_type = \\\"memory\\\";\" << Qt::endl;\n    }\n\n    prefix.remove(0, 1);\n    writeLineEnding(outputStream, prefix);\n}\n\n//-----------------------------------------------------------------------------\n// Function: LinuxDeviceTreeGenerator::getStatus()\n//-----------------------------------------------------------------------------\nQString LinuxDeviceTreeGenerator::getStatus(QSharedPointer<MemoryItem> blockItem) const\n{\n    QString blockStatus = \"disabled\";\n    bool canConvertPresence = false;\n    int blockPresence = blockItem->getIsPresent().toInt(&canConvertPresence);\n    if (canConvertPresence && blockPresence != 0)\n    {\n        blockStatus = \"okay\";\n    }\n\n    return blockStatus;\n}\n\n//-----------------------------------------------------------------------------\n// Function: LinuxDeviceTreeGenerator::writeRegister()\n//-----------------------------------------------------------------------------\nvoid LinuxDeviceTreeGenerator::writeRegister(QTextStream& output, quint64 const& address, quint64 const& range,\n    int addressSize, int rangeSize, QString const& prefix) const\n{\n    QString formattedAddress = formatValue(address, addressSize);\n    QString formattedRange = formatValue(range, rangeSize);\n\n    output << prefix << \"reg = <\" << formattedAddress << \" \" << formattedRange << \">;\" << Qt::endl;\n}\n\n//-----------------------------------------------------------------------------\n// Function: LinuxDeviceTreeGenerator::formatValue()\n//-----------------------------------------------------------------------------\nQString LinuxDeviceTreeGenerator::formatValue(quint64 const& value, int wordSize) const\n{\n    if (wordSize == 0)\n    {\n        return QString();\n    }\n\n    QString hexValue = QString::number(value, 16);\n    auto length = hexValue.length();\n\n    auto leftmostHexCount = length % 8;\n\n    QStringList hexWords;\n    if (leftmostHexCount != 0)\n    {\n        hexWords.append(hexValue.left(leftmostHexCount));\n    }\n\n    for (auto i = leftmostHexCount; i < length; i = i + 8)\n    {\n        hexWords.append(hexValue.mid(i, 8));\n    }\n\n    while (hexWords.size() < wordSize)\n    {\n        hexWords.prepend(\"0\");\n    }\n\n    Q_ASSERT(hexWords.size() <= wordSize);\n\n    return hexWords.join(\" 0x\").prepend(\"0x\");\n}\n\n//-----------------------------------------------------------------------------\n// Function: LinuxDeviceTreeGenerator::writeMemories()\n//-----------------------------------------------------------------------------\nvoid LinuxDeviceTreeGenerator::writeMemories(QTextStream& outputStream,\n    QSharedPointer<LinuxDeviceTreeCpuRoutesContainer> cpuContainer, QString& prefix,\n    bool writeAddressBlocks,int addressSize, int rangeSize)\n    const\n{\n    for (auto rootContainer : cpuContainer->getDeviceTreeRoutes())\n    {\n        QVector<LinuxDeviceTreeCPUDetails::CpuMemory> containerMemories = LinuxDeviceTreeCPUDetails::getMemories(rootContainer, 0, 0);\n        for (auto const& memory : containerMemories)\n        {\n            QString mapName = memory.memoryInterface_->getConnectedMemory()->getName();\n            QString instanceName = memory.memoryInterface_->getInstance()->getName();\n            QString componentVLNV = memory.memoryInterface_->getInstance()->getVlnv();\n\n            writeMemoryData(outputStream, memory.itemBaseAddress_,\n                memory.mapBaseAddress_, memory.range_,\n                addressSize, rangeSize, true, prefix, memory.memoryInterface_, writeAddressBlocks);\n\n            outputStream << Qt::endl;\n        }\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: LinuxDeviceTreeGenerator::getView()\n//-----------------------------------------------------------------------------\nQSharedPointer<View> LinuxDeviceTreeGenerator::getView(QSharedPointer<Component const> containingComponent,\n    QString const& viewName) const\n{\n    for (QSharedPointer<View> view : *containingComponent->getViews())\n    {\n        if (view->name() == viewName)\n        {\n            return view;\n        }\n    }\n\n    return QSharedPointer<View>();\n}\n"
  },
  {
    "path": "Plugins/LinuxDeviceTree/LinuxDeviceTreeGenerator.h",
    "content": "//-----------------------------------------------------------------------------\n// File: LinuxDeviceTreePlugin.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Copyright: Tampere University of Technology\n// Author: Mikko Teuho\n// Date: 08.05.2018\n//\n// Description:\n// Creates a Linux Device Tree from the selected document.\n//-----------------------------------------------------------------------------\n\n#ifndef LINUXDEVICETREEGENERATOR_H\n#define LINUXDEVICETREEGENERATOR_H\n\n#include \"LinuxDeviceTreeGenerator_global.h\"\n\n#include <editors/MemoryDesigner/ConnectivityGraphFactory.h>\n#include <editors/MemoryDesigner/MemoryConnectionAddressCalculator.h>\n\n#include <Plugins/LinuxDeviceTree/CPUSelection/LinuxDeviceTreeCPUDetails.h>\n\n#include <QSharedPointer>\n#include <QTextStream>\n\nclass LibraryInterface;\nclass Component;\nclass Cpu;\nclass AddressSpace;\nclass Design;\nclass DesignConfiguration;\nclass LinuxDeviceTreeCpuRoutesContainer;\n\n//-----------------------------------------------------------------------------\n//! Creates a Linux Device Tree from the selected document.\n//-----------------------------------------------------------------------------\nclass LINUXDEVICETREEGENERATOR_EXPORT LinuxDeviceTreeGenerator\n{\n\npublic:\n    \n    /*!\n     *  The Constructor.\n     *\n     *    @param [in] library     Interface to the library.\n     */\n    LinuxDeviceTreeGenerator(LibraryInterface* library);\n\n    /*!\n     *  The destructor.\n     */\n    ~LinuxDeviceTreeGenerator() = default;\n\n    /*!\n     *  Generates the linux device tree.\n     *\n     *    @param [in] topComponent        The top component in the hierarchy to generate listing for.\n     *    @param [in] activeView          The active view for the generation.\n     *    @param [in] writeAddressBlocks  Flag for writing address block data.\n     *    @param [in] cpuContainers       List of CPU containers.\n     *    @param [in] outputFolder        Path to the output folder.\n     */\n    bool generate(QSharedPointer<Component> topComponent,\n        QString const& activeView,\n        bool writeAddressBlocks,\n        QVector<QSharedPointer<LinuxDeviceTreeCpuRoutesContainer> > cpuContainers,\n        QString const& outputFolder);\n\nprivate:\n\n    // Disable copying.\n    LinuxDeviceTreeGenerator(LinuxDeviceTreeGenerator const& rhs);\n    LinuxDeviceTreeGenerator& operator=(LinuxDeviceTreeGenerator const& rhs);\n\n    /*!\n     *  Write the device tree file.\n     *\n     *    @param [in] designVendor        Vendor of the selected design.\n     *    @param [in] designName          Name of the selected design.\n     *    @param [in] cpuContainer        Container for CPUs.\n     *    @param [in] writeAddressBlocks  Flag for writing address block data.\n     *    @param [in] outputFolder        Path for the folder.\n     */\n    void writeFile(QString const& designVendor,\n        QString const& designName,\n        QSharedPointer<LinuxDeviceTreeCpuRoutesContainer> cpuContainer,\n        bool writeAddressBlocks,\n        QString const& outputFolder);\n\n    /*!\n     *\tWrite the start of the device tree.\n     *\n     *\t\t@param [in]\toutputStream    The stream to write into.\n     *    @param [in] designVendor    Vendor of the selected design.\n     *    @param [in] designName      Name of the selected design.\n     *    @param [in] masterRoots     Roots of the connectivity graph.\n     *    @param [in] prefix          Current tab prefix of the items.\n     */\n    void writeTreeStart(QTextStream& outputStream, QString const& designVendor, QString const& designName, QString const& prefix, int addressSize, int rangeSize) const;\n\n\t/*!\n\t *  Write the found memory paths of the selected CPU container.\n\t *\n\t *    @param [in]\toutputStream        The stream to write into.\n     *    @param [in] cpuContainer        The selected CPU container.\n     *    @param [in] writeAddressBlocks  Flag for writing address block data.\n     *    @param [in] prefix              Current tab prefix of the items.\n     */\n    void writeContainer(QTextStream& outputStream,\n        QSharedPointer<LinuxDeviceTreeCpuRoutesContainer> cpuContainer, bool writeAddressBlocks,\n        QString& prefix, int addressSize, int rangeSize);\n\n    /*!\n     *  Write the selected interface path.\n     *\n     *    @param [in] outputStream        The stream to write into.\n     *    @param [in] pathRootNode        Root interface of the path.\n     *    @param [in] cpuContainer        CPU container containing the path.\n     *    @param [in] writeAddressBlocks  Flag for writing address block data.\n     *    @param [in] prefix              Current tab prefix of the items.\n     */\n    void startPathWriting(QTextStream& outputStream,\n        QSharedPointer<DeviceTreeUtilities::CpuDeviceTree> nodeContainer,\n        bool writeAddressBlocks,\n        QString& prefix,\n        int addressSize,\n        int rangeSize);\n\n    /*!\n     *\tWrite an introduction to the CPUs.\n     *\n     *\t\t@param [in]\toutputStream    The stream to write into.\n     *    @param [in] cpus            The selected CPUs.\n     *    @param [in] componentVLNV   VLNV of the component containing the CPUs.\n     *    @param [in] prefix          The prefix for CPUs.\n     */\n    void writeIntroductionToCPUs(QTextStream& outputStream, QVector<QSharedPointer<const Cpu> > cpus,\n        QString const& componentVLNV, QString& prefix);\n\n    /*!\n     *  Write a single CPU.\n     *\n     *\t\t@param [in]\toutputStream    The stream to write into.\n     *    @param [in] CPUName         Name of the selected CPU.\n     *    @param [in] componentVLNV   VLNV of the component containing the selected CPU.\n     *\t\t@param [in]\tcpuNumber       Number of the CPU.\n     *    @param [in] prefix          The prefix for a single CPU.\n     */\n    void writeCPU(QTextStream& outputStream, QString const& CPUName, QString const& componentVLNV, int cpuNumber,\n        QString& prefix);\n\n    /*!\n     *  Write the selected interface node.\n     *\n     *    @param [in] outputStream        The stream to write into.\n     *    @param [in] previousInterface   The previously written interface.\n     *    @param [in] nodeContainer       Container for the interface node.\n     *    @param [in] baseAddress         Currently effective base address.\n     *    @param [in] memoryItemRange     Currently effective range of the memory item.\n     *    @param [in] prefix              Current tab prefix of the items.\n     *    @param [in] writeAddressBlocks  Flag for writing address block data.\n     *    @param [in] addressSize         Current address size.\n     *    @param [in] rangeSize           Current range size.\n     */\n    void writePathNode(QTextStream& outputStream,\n        QSharedPointer<const ConnectivityInterface> previousInterface,\n        QSharedPointer<DeviceTreeUtilities::CpuDeviceTree> nodeContainer,\n        quint64 const& baseAddress,\n        quint64 const& memoryItemRange,\n        QString& prefix,\n        bool writeAddressBlocks,\n        int addressSize,\n        int rangeSize);\n\n    /*!\n     *  Check if an interface node has access to memory interface nodes.\n     *\n     *    @param [in] interfaceNode   The selected interface node.\n     *    @param [in] previousNode    Previous interface node on the tree.\n     *\n     *    @return True, if an interface has access to memory interface nodes, false otherwise.\n     */\n    bool canWriteNode(QSharedPointer<const ConnectivityInterface> interfaceNode,\n        QSharedPointer<const ConnectivityInterface> previousNode) const;\n\n    /*!\n     *\tWrite a line ending.\n     *\n     *\t\t@param [in]\toutputStream    The stream to write into.\n     *\t\t@param [in]\tprefix          The prefix for the line ending.\n     */\n    void writeLineEnding(QTextStream& outputStream, QString const& prefix) const;\n\n    /*!\n     *  Write a single bridge.\n     *\n     *    @param [in] outputStream    The stream to write into.\n     *    @param [in] interfaceNode   Interface containing the bridge.\n     *    @param [in] bridgeType      The bridge type.\n     *    @param [in] baseAddress     The current base address of the connection chain.\n     *    @param [in] memoryRange     Range given for memory items.\n     *    @param [in] prefix          The prefix for the bridge.\n     */\n    void writeBridge(QTextStream& outputStream, QSharedPointer<ConnectivityInterface const> interfaceNode,\n        QString const& bridgeType, int addressSize, int rangeSize, QString& prefix);\n\n    /*!\n     *  Get address and size requirements of the selected interface node.\n     *\n     *    @param [in] rootContainer   Container containing the selected interface node.\n     *    @param [in] previousNode    Previous node in the connectivity graph.\n     *    @param [in] baseAddress     The current base address of the connection chain.\n     *    @param [in] memoryRange     Current range for the memory items.\n     *    @param [in] stopAtBridges   Flag for stopping the requirement check at bridge components.\n     *\n     *    @return Addres / size requirement pair.\n     */\n    QPair<quint64, quint64> getAddressAndSizeRequirements(QSharedPointer<DeviceTreeUtilities::CpuDeviceTree> rootContainer,\n        QSharedPointer<ConnectivityInterface const> previousNode,\n        quint64 baseAddress,\n        quint64 memoryRange,\n        bool stopAtBridges);\n\n    /*!\n     *  Calculate the amount of 32 bit sizes of the selected value.\n     *\n     *    @param [in] requirementValue    The selected value.\n     *\n     *    @return The amount of 32 bit sizes of the selected value.\n     */\n    unsigned int calculateWordSize(quint64 const& requirementValue) const;\n\n    /*!\n     *  Write memory item.\n     *\n     *    @param [in] outputStream        Stream to write into.\n     *    @param [in] itemName            Name of the memory item.\n     *    @param [in] instanceName        Name of the instance containing the memory item.\n     *    @param [in] componentVLNV       VLNV of the component instance.\n     *    @param [in] baseAddress         Base address of the memory item.\n     *    @param [in] range               Range of the memory item.\n     *    @param [in] isMemory            Item memory usage.\n     *    @param [in] prefix              Prefix of the memory item.\n     *    @param [in] memoryNode          Interface containing the memory item.\n     *    @param [in] writeAddressBlocks  Flag for writing address block data.\n     */\n    void writeMemoryData(QTextStream& outputStream, quint64 const& itemBaseAddress, quint64 const& mapBaseAddress,\n        quint64 const& range,\n        int addressSize, int rangeSize, bool isMemory, QString& prefix,\n        QSharedPointer<ConnectivityInterface const> memoryNode, bool writeAddressBlocks) const;\n\n    /*!\n     *  Write address blocks.\n     *\n     *    @param [in] outputStream        Stream to write into.\n     *    @param [in] memoryNode          Interface containing the memory item.\n     *    @param [in] itemBaseAddress     Base address of the memory location.\n     *    @param [in] prefix              Prefix of the address blocks.\n     */\n    void writeAddressBlocksData(QTextStream& outputStream, QSharedPointer<ConnectivityInterface const> memoryNode,\n        quint64 const& itemBaseAddress, int addressSize, int rangeSize, QString& prefix) const;\n\n    /*!\n     *  Write the selected address block.\n     *\n     *    @param [in] outputStream        Stream to write into.\n     *    @param [in] memoryNode          Interface containing the memory item.\n     *    @param [in] blockItem           The selected address block memory item.\n     *    @param [in] itemBaseAddress     Base address of the memory location.\n     *    @param [in] prefix              Prefix of the address blocks.\n     */\n    void writeSingleAddressBlock(QTextStream& outputStream,\n        QString const& vendorName, QSharedPointer<MemoryItem> blockItem,\n        quint64 const& itemBaseAddress, int addressSize, int rangeSize, QString& prefix) const;\n\n    QString getStatus(QSharedPointer<MemoryItem> blockItem) const;\n\n    void writeRegister(QTextStream& output, quint64 const& address, quint64 const& range, \n        int addressSize, int rangeSize,\n        QString const& prefix) const;\n\n    QString formatValue(quint64 const& address, int addressSize) const;\n\n    /*!\n     *  Write the memory items with usage memory.\n     *\n     *    @param [in] outputStream        Stream to write into.\n     *    @param [in] cpuContainer        CPU containing the memories.\n     *    @param [in] prefix              Prefix of the memories.\n     *    @param [in] writeAddressBlocks  Flag for writing address block data.\n     */\n    void writeMemories(QTextStream& outputStream,\n        QSharedPointer<LinuxDeviceTreeCpuRoutesContainer> cpuContainer, QString& prefix,\n        bool writeAddressBlocks,int addressSize, int rangeSize) const;\n\n    /*!\n     *\tGet the active view matching the selected view name.\n     *\n     *\t\t@param [in]\tcontainingComponent     Component containing the views.\n     *\t\t@param [in]\tviewName                Name of the currently active view.\n     *\n     *    @return The currently active view.\n     */\n    QSharedPointer<View> getView(QSharedPointer<Component const> containingComponent, QString const& viewName)\n        const;\n\n    /*!\n     *\tGet the design configuration referenced by the selected view.\n     *\n     *\t\t@param [in]\tcontainingComponent     Component containing the required items.\n     *\t\t@param [in]\treferencingView         The selected view.\n     *\n     *    @return Design configuration referenced by the selected view.\n     */\n    QSharedPointer<const DesignConfiguration> getDesignConfiguration(\n        QSharedPointer<Component const> containingComponent, QSharedPointer<View> referencingView) const;\n\n    /*!\n     *\tGet the design referenced by the selected view.\n     *\n     *\t\t@param [in]\tcontainingComponent     Component containing the required items.\n     *\t\t@param [in]\treferencingView         The selected view.\n     *\t\t@param [in]\tdesignConfiguration     Design configuration referenced by the selected view.\n     *\n     *\t\t@return\tDesign referenced by the selected view.\n     */\n    QSharedPointer<const Design> getHierarchicalDesign(QSharedPointer<Component const> containingComponent,\n        QSharedPointer<View> referencingView, QSharedPointer<const DesignConfiguration> designConfiguration) const;\n\n    /*!\n     *\tGet the VLNV of the hierarchical design referenced by the selected view.\n     *\n     *\t\t@param [in]\tcontainingComponent     Component containing the selected view.\n     *\t\t@param [in]\treferencingView         The selected view.\n     *\n     *\t\t@return\tVLNV of the hierarchical design referenced by the selected view.\n     */\n    VLNV getHierarchicalDesignVLNV(QSharedPointer<Component const> containingComponent,\n        QSharedPointer<View> referencingView) const;\n\n    //-----------------------------------------------------------------------------\n    // Data.\n    //-----------------------------------------------------------------------------\n\n    //! The library interface.\n    LibraryInterface* library_;\n\n    //! The connectivity graph factory.\n    ConnectivityGraphFactory graphFactory_;\n};\n\n#endif // LINUXDEVICETREEGENERATOR_H\n"
  },
  {
    "path": "Plugins/LinuxDeviceTree/LinuxDeviceTreeGenerator.pri",
    "content": "# ----------------------------------------------------\n# This file is generated by the Qt Visual Studio Tools.\n# ------------------------------------------------------\n\n# This is a reminder that you are using a generated .pro file.\n# Remove it when you are finished editing this file.\nmessage(\"You are running qmake on a generated .pro file. This may not work!\")\n\n\nHEADERS += ../../editors/MemoryDesigner/ConnectivityComponent.h \\\n    ../../editors/MemoryDesigner/ConnectivityConnection.h \\\n    ../../editors/MemoryDesigner/ConnectivityGraph.h \\\n    ../../editors/MemoryDesigner/ConnectivityGraphFactory.h \\\n    ../../editors/MemoryDesigner/ConnectivityInterface.h \\\n    ../../editors/MemoryDesigner/MasterSlavePathSearch.h \\\n    ../../editors/MemoryDesigner/MemoryConnectionAddressCalculator.h \\\n    ../../editors/MemoryDesigner/MemoryDesignerConstants.h \\\n    ../../editors/MemoryDesigner/MemoryItem.h \\\n    ../PluginSystem/GeneratorPlugin/ViewSelection.h \\\n    ./LinuxDeviceTreeGenerator.h \\\n    ./LinuxDeviceTreeGenerator_global.h \\\n    ./LinuxDeviceTreeDialog.h \\\n    ./LinuxDeviceTreePlugin.h \\\n    ../common/CpuRoutesContainer.h \\\n    ./CPUSelection/LinuxDeviceTreeCPUColumns.h \\\n    ./CPUSelection/LinuxDeviceTreeCPUDetails.h \\\n    ./CPUSelection/LinuxDeviceTreeCpuRoutesContainer.h \\\n    ./CPUSelection/LinuxDeviceTreeCPUModel.h \\\n    ./CPUSelection/LinuxDeviceTreeCPUDelegate.h \\\n    ./CPUSelection/LinuxDeviceTreeCPUEditor.h \\\n    ../common/SingleCpuRoutesContainer.h \\\n    ../common/ConnectivityGraphUtilities.h\nSOURCES += ../../editors/MemoryDesigner/ConnectivityComponent.cpp \\\n    ../../editors/MemoryDesigner/ConnectivityConnection.cpp \\\n    ../../editors/MemoryDesigner/ConnectivityGraph.cpp \\\n    ../../editors/MemoryDesigner/ConnectivityGraphFactory.cpp \\\n    ../../editors/MemoryDesigner/ConnectivityInterface.cpp \\\n    ../../editors/MemoryDesigner/MasterSlavePathSearch.cpp \\\n    ../../editors/MemoryDesigner/MemoryConnectionAddressCalculator.cpp \\\n    ../../editors/MemoryDesigner/MemoryDesignerConstants.cpp \\\n    ../../editors/MemoryDesigner/MemoryItem.cpp \\\n    ../PluginSystem/GeneratorPlugin/ViewSelection.cpp \\\n    ./LinuxDeviceTreeDialog.cpp \\\n    ./LinuxDeviceTreeGenerator.cpp \\\n    ./LinuxDeviceTreePlugin.cpp \\\n    ../common/CpuRoutesContainer.cpp \\\n    ./CPUSelection/LinuxDeviceTreeCPUDelegate.cpp \\\n    ./CPUSelection/LinuxDeviceTreeCPUDetails.cpp \\\n    ./CPUSelection/LinuxDeviceTreeCPUEditor.cpp \\\n    ./CPUSelection/LinuxDeviceTreeCPUModel.cpp \\\n    ./CPUSelection/LinuxDeviceTreeCpuRoutesContainer.cpp \\\n    ../common/SingleCpuRoutesContainer.cpp \\\n    ../common/ConnectivityGraphUtilities.cpp\nRESOURCES += LinuxDeviceTree.qrc\n"
  },
  {
    "path": "Plugins/LinuxDeviceTree/LinuxDeviceTreeGenerator.pro",
    "content": "# ----------------------------------------------------\n# This file is generated by the Qt Visual Studio Add-in.\n# ------------------------------------------------------\n\nTEMPLATE = lib\nDESTDIR = ../../executable/Plugins\nQT += core widgets gui xml\nCONFIG += c++11 plugin\nDEFINES += QT_DLL LINUXDEVICETREEGENERATOR_LIB\n\nINCLUDEPATH += ./../..\n\nCONFIG(debug, debug|release) {\n    # debug mode\n    LIBS += \\\n        -L../../executable -lIPXACTmodelsd \\\n        -L../../executable -lKactusAPId\n\n    MOC_DIR += ./GeneratedFiles/Debug\n    OBJECTS_DIR += Debug\n    TARGET = LinuxDeviceTreeGeneratord\n\n} else {\n    # release mode \n    LIBS += \\\n        -L../../executable -lIPXACTmodels \\\n        -L../../executable -lKactusAPI\n    \n    MOC_DIR += ./GeneratedFiles/Release\n    OBJECTS_DIR += Release\n    TARGET = LinuxDeviceTreeGenerator\n}\n\nDEPENDPATH += .\n\nUI_DIR += ./GeneratedFiles\nRCC_DIR += ./GeneratedFiles\ninclude(LinuxDeviceTreeGenerator.pri)\n\ntarget.path = $$plugin_path\nINSTALLS += target\n"
  },
  {
    "path": "Plugins/LinuxDeviceTree/LinuxDeviceTreeGenerator.vcxproj",
    "content": "﻿<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<Project DefaultTargets=\"Build\" ToolsVersion=\"4.0\" xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">\n  <ItemGroup Label=\"ProjectConfigurations\">\n    <ProjectConfiguration Include=\"Debug|x64\">\n      <Configuration>Debug</Configuration>\n      <Platform>x64</Platform>\n    </ProjectConfiguration>\n    <ProjectConfiguration Include=\"Release|x64\">\n      <Configuration>Release</Configuration>\n      <Platform>x64</Platform>\n    </ProjectConfiguration>\n  </ItemGroup>\n  <PropertyGroup Label=\"Globals\">\n    <ProjectGuid>{E5EC0C47-17DE-4E2F-8F13-731D5EECB70B}</ProjectGuid>\n    <Keyword>QtVS_v304</Keyword>\n    <WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>\n    <QtMsBuild Condition=\"'$(QtMsBuild)'=='' or !Exists('$(QtMsBuild)\\qt.targets')\">$(MSBuildProjectDirectory)\\QtMsBuild</QtMsBuild>\n  </PropertyGroup>\n  <Import Project=\"$(VCTargetsPath)\\Microsoft.Cpp.Default.props\" />\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\" Label=\"Configuration\">\n    <ConfigurationType>DynamicLibrary</ConfigurationType>\n    <PlatformToolset>v143</PlatformToolset>\n  </PropertyGroup>\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\" Label=\"Configuration\">\n    <ConfigurationType>DynamicLibrary</ConfigurationType>\n    <PlatformToolset>v143</PlatformToolset>\n  </PropertyGroup>\n  <Import Project=\"$(VCTargetsPath)\\Microsoft.Cpp.props\" />\n  <Target Name=\"QtMsBuildNotFound\" BeforeTargets=\"CustomBuild;ClCompile\" Condition=\"!Exists('$(QtMsBuild)\\qt.targets') or !Exists('$(QtMsBuild)\\qt.props')\">\n    <Message Importance=\"High\" Text=\"QtMsBuild: could not locate qt.targets, qt.props; project may not build correctly.\" />\n  </Target>\n  <ImportGroup Label=\"ExtensionSettings\">\n  </ImportGroup>\n  <ImportGroup Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\" Label=\"PropertySheets\">\n    <Import Project=\"$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props\" Condition=\"exists('$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props')\" Label=\"LocalAppDataPlatform\" />\n  </ImportGroup>\n  <ImportGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\" Label=\"PropertySheets\">\n    <Import Project=\"$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props\" Condition=\"exists('$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props')\" Label=\"LocalAppDataPlatform\" />\n  </ImportGroup>\n  <PropertyGroup Label=\"UserMacros\" />\n  <ImportGroup Condition=\"Exists('$(QtMsBuild)\\qt_defaults.props')\">\n    <Import Project=\"$(QtMsBuild)\\qt_defaults.props\" />\n  </ImportGroup>\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\n    <IntDir>$(ProjectDir)\\$(Configuration)\\</IntDir>\n    <OutDir>$(SolutionDir)executable\\Plugins\\</OutDir>\n  </PropertyGroup>\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\n    <IntDir>$(ProjectDir)\\$(Configuration)\\</IntDir>\n    <OutDir>$(SolutionDir)executable\\Plugins\\</OutDir>\n  </PropertyGroup>\n  <PropertyGroup Label=\"QtSettings\" Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\n    <QtInstall>6.2.4</QtInstall>\n    <QtModules>core;gui;widgets;xml</QtModules>\n  </PropertyGroup>\n  <PropertyGroup Label=\"QtSettings\" Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\n    <QtInstall>6.2.4</QtInstall>\n    <QtModules>core;gui;widgets;xml</QtModules>\n  </PropertyGroup>\n  <ImportGroup Condition=\"Exists('$(QtMsBuild)\\qt.props')\">\n    <Import Project=\"$(QtMsBuild)\\qt.props\" />\n  </ImportGroup>\n  <PropertyGroup>\n    <_ProjectFileVersion>10.0.40219.1</_ProjectFileVersion>\n  </PropertyGroup>\n  <ItemDefinitionGroup Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\n    <ClCompile>\n      <PreprocessorDefinitions>LINUXDEVICETREEGENERATOR_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>\n      <AdditionalIncludeDirectories>.\\GeneratedFiles\\$(ConfigurationName);.\\GeneratedFiles;..\\..\\;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\n      <ObjectFileName>$(IntDir)</ObjectFileName>\n      <ProgramDataBaseFileName>$(IntDir)vc$(PlatformToolsetVersion).pdb</ProgramDataBaseFileName>\n      <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>\n      <LanguageStandard>stdcpp17</LanguageStandard>\n      <AdditionalOptions>/Zc:__cplusplus %(AdditionalOptions)</AdditionalOptions>\n      <MultiProcessorCompilation>true</MultiProcessorCompilation>\n    </ClCompile>\n    <Link>\n      <AdditionalDependencies>IPXACTmodelsd.lib;KactusAPId.lib;%(AdditionalDependencies)</AdditionalDependencies>\n      <AdditionalLibraryDirectories>..\\..\\executable;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>\n    </Link>\n    <QtMoc>\n      <ExecutionDescription>Moc'ing %(Identity)...</ExecutionDescription>\n      <DynamicSource>output</DynamicSource>\n      <QtMocDir>.\\GeneratedFiles</QtMocDir>\n      <QtMocFileName>moc_%(Filename).cpp</QtMocFileName>\n    </QtMoc>\n    <QtRcc>\n      <InitFuncName>%(Filename)</InitFuncName>\n      <Compression>default</Compression>\n      <NoCompression>true</NoCompression>\n      <ExecutionDescription>Rcc'ing %(Identity)...</ExecutionDescription>\n      <QtRccDir>.\\GeneratedFiles</QtRccDir>\n      <QtRccFileName>qrc_%(Filename).cpp</QtRccFileName>\n    </QtRcc>\n  </ItemDefinitionGroup>\n  <ItemDefinitionGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\n    <ClCompile>\n      <PreprocessorDefinitions>LINUXDEVICETREEGENERATOR_LIB;NDEBUG;QT_NO_DEBUG;UNICODE;WIN32;WIN64;%(PreprocessorDefinitions)</PreprocessorDefinitions>\n      <AdditionalIncludeDirectories>.\\GeneratedFiles\\$(ConfigurationName);.\\GeneratedFiles;.\\GeneratedFiles\\$(Configuration);.;.\\..\\..;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\n      <ObjectFileName>$(IntDir)</ObjectFileName>\n      <ProgramDataBaseFileName>$(IntDir)vc$(PlatformToolsetVersion).pdb</ProgramDataBaseFileName>\n      <LanguageStandard>stdcpp17</LanguageStandard>\n      <AdditionalOptions>/Zc:__cplusplus %(AdditionalOptions)</AdditionalOptions>\n      <MultiProcessorCompilation>true</MultiProcessorCompilation>\n    </ClCompile>\n    <Link>\n      <AdditionalDependencies>IPXACTmodels.lib;KactusAPI.lib;%(AdditionalDependencies)</AdditionalDependencies>\n      <AdditionalLibraryDirectories>..\\..\\executable;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>\n    </Link>\n    <QtMoc>\n      <ExecutionDescription>Moc'ing %(Identity)...</ExecutionDescription>\n      <DynamicSource>output</DynamicSource>\n      <QtMocDir>.\\GeneratedFiles</QtMocDir>\n      <QtMocFileName>moc_%(Filename).cpp</QtMocFileName>\n    </QtMoc>\n    <QtRcc>\n      <InitFuncName>%(Filename)</InitFuncName>\n      <Compression>default</Compression>\n      <NoCompression>true</NoCompression>\n      <ExecutionDescription>Rcc'ing %(Identity)...</ExecutionDescription>\n      <QtRccDir>.\\GeneratedFiles</QtRccDir>\n      <QtRccFileName>qrc_%(Filename).cpp</QtRccFileName>\n    </QtRcc>\n  </ItemDefinitionGroup>\n  <ItemGroup>\n    <ProjectReference Include=\"..\\..\\IPXACTmodels\\IPXACTmodels.vcxproj\">\n      <Project>{5c0ca59d-cfce-49c6-b62a-9e3065ca34dd}</Project>\n    </ProjectReference>\n  </ItemGroup>\n  <ItemGroup>\n    <ClCompile Include=\"..\\..\\editors\\MemoryDesigner\\ConnectivityComponent.cpp\" />\n    <ClCompile Include=\"..\\..\\editors\\MemoryDesigner\\ConnectivityConnection.cpp\" />\n    <ClCompile Include=\"..\\..\\editors\\MemoryDesigner\\ConnectivityGraph.cpp\" />\n    <ClCompile Include=\"..\\..\\editors\\MemoryDesigner\\ConnectivityGraphFactory.cpp\" />\n    <ClCompile Include=\"..\\..\\editors\\MemoryDesigner\\ConnectivityInterface.cpp\" />\n    <ClCompile Include=\"..\\..\\editors\\MemoryDesigner\\MasterSlavePathSearch.cpp\" />\n    <ClCompile Include=\"..\\..\\editors\\MemoryDesigner\\MemoryConnectionAddressCalculator.cpp\" />\n    <ClCompile Include=\"..\\..\\editors\\MemoryDesigner\\MemoryDesignerConstants.cpp\" />\n    <ClCompile Include=\"..\\..\\editors\\MemoryDesigner\\MemoryItem.cpp\" />\n    <ClCompile Include=\"..\\common\\ConnectivityGraphUtilities.cpp\" />\n    <ClCompile Include=\"..\\common\\CpuRoutesContainer.cpp\" />\n    <ClCompile Include=\"..\\common\\SingleCpuRoutesContainer.cpp\" />\n    <ClCompile Include=\"..\\PluginSystem\\GeneratorPlugin\\ViewSelection.cpp\" />\n    <ClCompile Include=\"CPUSelection\\LinuxDeviceTreeCPUDelegate.cpp\" />\n    <ClCompile Include=\"CPUSelection\\LinuxDeviceTreeCPUDetails.cpp\" />\n    <ClCompile Include=\"CPUSelection\\LinuxDeviceTreeCPUEditor.cpp\" />\n    <ClCompile Include=\"CPUSelection\\LinuxDeviceTreeCPUModel.cpp\" />\n    <ClCompile Include=\"CPUSelection\\LinuxDeviceTreeCpuRoutesContainer.cpp\" />\n    <ClCompile Include=\"LinuxDeviceTreeDialog.cpp\" />\n    <ClCompile Include=\"LinuxDeviceTreeGenerator.cpp\" />\n    <ClCompile Include=\"LinuxDeviceTreePlugin.cpp\" />\n  </ItemGroup>\n  <ItemGroup>\n    <ClInclude Include=\"..\\..\\editors\\MemoryDesigner\\ConnectivityComponent.h\" />\n    <ClInclude Include=\"..\\..\\editors\\MemoryDesigner\\ConnectivityConnection.h\" />\n    <ClInclude Include=\"..\\..\\editors\\MemoryDesigner\\ConnectivityGraph.h\" />\n    <ClInclude Include=\"..\\..\\editors\\MemoryDesigner\\ConnectivityGraphFactory.h\" />\n    <ClInclude Include=\"..\\..\\editors\\MemoryDesigner\\ConnectivityInterface.h\" />\n    <ClInclude Include=\"..\\..\\editors\\MemoryDesigner\\MasterSlavePathSearch.h\" />\n    <ClInclude Include=\"..\\..\\editors\\MemoryDesigner\\MemoryConnectionAddressCalculator.h\" />\n    <ClInclude Include=\"..\\..\\editors\\MemoryDesigner\\MemoryDesignerConstants.h\" />\n    <ClInclude Include=\"..\\..\\editors\\MemoryDesigner\\MemoryItem.h\" />\n    <QtMoc Include=\"LinuxDeviceTreeDialog.h\">\n    </QtMoc>\n    <ClInclude Include=\"..\\common\\ConnectivityGraphUtilities.h\" />\n    <ClInclude Include=\"..\\common\\CpuRoutesContainer.h\" />\n    <ClInclude Include=\"..\\common\\SingleCpuRoutesContainer.h\" />\n    <ClInclude Include=\"..\\PluginSystem\\GeneratorPlugin\\ViewSelection.h\" />\n    <QtMoc Include=\"CPUSelection\\LinuxDeviceTreeCPUModel.h\">\n    </QtMoc>\n    <ClInclude Include=\"CPUSelection\\LinuxDeviceTreeCPUColumns.h\" />\n    <QtMoc Include=\"CPUSelection\\LinuxDeviceTreeCPUDelegate.h\">\n    </QtMoc>\n    <QtMoc Include=\"CPUSelection\\LinuxDeviceTreeCPUEditor.h\">\n    </QtMoc>\n    <ClInclude Include=\"CPUSelection\\LinuxDeviceTreeCPUDetails.h\" />\n    <ClInclude Include=\"CPUSelection\\LinuxDeviceTreeCpuRoutesContainer.h\" />\n    <ClInclude Include=\"LinuxDeviceTreeGenerator.h\" />\n    <ClInclude Include=\"LinuxDeviceTreeGenerator_global.h\" />\n    <QtMoc Include=\"LinuxDeviceTreePlugin.h\">\n    </QtMoc>\n  </ItemGroup>\n  <ItemGroup>\n    <Image Include=\"LinuxDeviceTreeGenerator.png\">\n      <ExcludedFromBuild Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">true</ExcludedFromBuild>\n      <ExcludedFromBuild Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">true</ExcludedFromBuild>\n    </Image>\n  </ItemGroup>\n  <ItemGroup>\n    <QtRcc Include=\"LinuxDeviceTree.qrc\">\n    </QtRcc>\n  </ItemGroup>\n  <Import Project=\"$(VCTargetsPath)\\Microsoft.Cpp.targets\" />\n  <ImportGroup Condition=\"Exists('$(QtMsBuild)\\qt.targets')\">\n    <Import Project=\"$(QtMsBuild)\\qt.targets\" />\n  </ImportGroup>\n  <ImportGroup Label=\"ExtensionTargets\">\n  </ImportGroup>\n  <ProjectExtensions>\n    <VisualStudio>\n      <UserProperties />\n    </VisualStudio>\n  </ProjectExtensions>\n</Project>"
  },
  {
    "path": "Plugins/LinuxDeviceTree/LinuxDeviceTreeGenerator.vcxproj.filters",
    "content": "﻿<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<Project ToolsVersion=\"4.0\" xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">\n  <ItemGroup>\n    <Filter Include=\"Source Files\">\n      <UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>\n      <Extensions>cpp;cxx;c;def</Extensions>\n    </Filter>\n    <Filter Include=\"Header Files\">\n      <UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>\n      <Extensions>h</Extensions>\n    </Filter>\n    <Filter Include=\"Form Files\">\n      <UniqueIdentifier>{99349809-55BA-4b9d-BF79-8FDBB0286EB3}</UniqueIdentifier>\n      <Extensions>ui</Extensions>\n    </Filter>\n    <Filter Include=\"Resource Files\">\n      <UniqueIdentifier>{D9D6E242-F8AF-46E4-B9FD-80ECBC20BA3E}</UniqueIdentifier>\n      <Extensions>qrc;*</Extensions>\n      <ParseFiles>false</ParseFiles>\n    </Filter>\n    <Filter Include=\"Generated Files\">\n      <UniqueIdentifier>{71ED8ED8-ACB9-4CE9-BBE1-E00B30144E11}</UniqueIdentifier>\n      <Extensions>moc;h;cpp</Extensions>\n      <SourceControlFiles>False</SourceControlFiles>\n    </Filter>\n    <Filter Include=\"Source Files\\CPUSelection\">\n      <UniqueIdentifier>{be4c3c8f-dc25-4101-9b7d-b43b96c652ff}</UniqueIdentifier>\n    </Filter>\n    <Filter Include=\"Header Files\\CPUSelection\">\n      <UniqueIdentifier>{a930d07a-9747-4365-b0bb-92a27fa37e68}</UniqueIdentifier>\n    </Filter>\n    <Filter Include=\"Header Files\\common\">\n      <UniqueIdentifier>{84b9bd44-af87-4e2f-b917-3d961b8dacfc}</UniqueIdentifier>\n    </Filter>\n    <Filter Include=\"Header Files\\MemoryDesigner\">\n      <UniqueIdentifier>{7d92c563-ff5c-43cd-83b1-8ec7b22f4f86}</UniqueIdentifier>\n    </Filter>\n    <Filter Include=\"Source Files\\common\">\n      <UniqueIdentifier>{948137d2-3be7-4849-9559-f86838773504}</UniqueIdentifier>\n    </Filter>\n    <Filter Include=\"Source Files\\MemoryDesigner\">\n      <UniqueIdentifier>{2e1b6bae-757c-42b4-b456-b7304d129396}</UniqueIdentifier>\n    </Filter>\n  </ItemGroup>\n  <ItemGroup>\n    <ClCompile Include=\"LinuxDeviceTreePlugin.cpp\">\n      <Filter>Source Files</Filter>\n    </ClCompile>\n    <ClCompile Include=\"LinuxDeviceTreeGenerator.cpp\">\n      <Filter>Source Files</Filter>\n    </ClCompile>\n    <ClCompile Include=\"LinuxDeviceTreeDialog.cpp\">\n      <Filter>Source Files</Filter>\n    </ClCompile>\n    <ClCompile Include=\"CPUSelection\\LinuxDeviceTreeCPUDelegate.cpp\">\n      <Filter>Source Files\\CPUSelection</Filter>\n    </ClCompile>\n    <ClCompile Include=\"CPUSelection\\LinuxDeviceTreeCPUEditor.cpp\">\n      <Filter>Source Files\\CPUSelection</Filter>\n    </ClCompile>\n    <ClCompile Include=\"CPUSelection\\LinuxDeviceTreeCPUModel.cpp\">\n      <Filter>Source Files\\CPUSelection</Filter>\n    </ClCompile>\n    <ClCompile Include=\"CPUSelection\\LinuxDeviceTreeCPUDetails.cpp\">\n      <Filter>Source Files\\CPUSelection</Filter>\n    </ClCompile>\n    <ClCompile Include=\"CPUSelection\\LinuxDeviceTreeCpuRoutesContainer.cpp\">\n      <Filter>Source Files\\CPUSelection</Filter>\n    </ClCompile>\n    <ClCompile Include=\"..\\common\\ConnectivityGraphUtilities.cpp\">\n      <Filter>Source Files\\common</Filter>\n    </ClCompile>\n    <ClCompile Include=\"..\\common\\CpuRoutesContainer.cpp\">\n      <Filter>Source Files\\common</Filter>\n    </ClCompile>\n    <ClCompile Include=\"..\\common\\SingleCpuRoutesContainer.cpp\">\n      <Filter>Source Files\\common</Filter>\n    </ClCompile>\n    <ClCompile Include=\"..\\PluginSystem\\GeneratorPlugin\\ViewSelection.cpp\">\n      <Filter>Source Files\\common</Filter>\n    </ClCompile>\n    <ClCompile Include=\"..\\..\\editors\\MemoryDesigner\\ConnectivityComponent.cpp\">\n      <Filter>Source Files\\MemoryDesigner</Filter>\n    </ClCompile>\n    <ClCompile Include=\"..\\..\\editors\\MemoryDesigner\\ConnectivityConnection.cpp\">\n      <Filter>Source Files\\MemoryDesigner</Filter>\n    </ClCompile>\n    <ClCompile Include=\"..\\..\\editors\\MemoryDesigner\\ConnectivityGraph.cpp\">\n      <Filter>Source Files\\MemoryDesigner</Filter>\n    </ClCompile>\n    <ClCompile Include=\"..\\..\\editors\\MemoryDesigner\\ConnectivityGraphFactory.cpp\">\n      <Filter>Source Files\\MemoryDesigner</Filter>\n    </ClCompile>\n    <ClCompile Include=\"..\\..\\editors\\MemoryDesigner\\ConnectivityInterface.cpp\">\n      <Filter>Source Files\\MemoryDesigner</Filter>\n    </ClCompile>\n    <ClCompile Include=\"..\\..\\editors\\MemoryDesigner\\MasterSlavePathSearch.cpp\">\n      <Filter>Source Files\\MemoryDesigner</Filter>\n    </ClCompile>\n    <ClCompile Include=\"..\\..\\editors\\MemoryDesigner\\MemoryConnectionAddressCalculator.cpp\">\n      <Filter>Source Files\\MemoryDesigner</Filter>\n    </ClCompile>\n    <ClCompile Include=\"..\\..\\editors\\MemoryDesigner\\MemoryDesignerConstants.cpp\">\n      <Filter>Source Files\\MemoryDesigner</Filter>\n    </ClCompile>\n    <ClCompile Include=\"..\\..\\editors\\MemoryDesigner\\MemoryItem.cpp\">\n      <Filter>Source Files\\MemoryDesigner</Filter>\n    </ClCompile>\n  </ItemGroup>\n  <ItemGroup>\n    <ClInclude Include=\"LinuxDeviceTreeGenerator_global.h\">\n      <Filter>Header Files</Filter>\n    </ClInclude>\n    <ClInclude Include=\"LinuxDeviceTreeGenerator.h\">\n      <Filter>Header Files</Filter>\n    </ClInclude>\n    <ClInclude Include=\"CPUSelection\\LinuxDeviceTreeCPUColumns.h\">\n      <Filter>Header Files\\CPUSelection</Filter>\n    </ClInclude>\n    <ClInclude Include=\"CPUSelection\\LinuxDeviceTreeCPUDetails.h\">\n      <Filter>Header Files\\CPUSelection</Filter>\n    </ClInclude>\n    <ClInclude Include=\"CPUSelection\\LinuxDeviceTreeCpuRoutesContainer.h\">\n      <Filter>Header Files\\CPUSelection</Filter>\n    </ClInclude>\n    <ClInclude Include=\"..\\common\\ConnectivityGraphUtilities.h\">\n      <Filter>Header Files\\common</Filter>\n    </ClInclude>\n    <ClInclude Include=\"..\\common\\CpuRoutesContainer.h\">\n      <Filter>Header Files\\common</Filter>\n    </ClInclude>\n    <ClInclude Include=\"..\\common\\SingleCpuRoutesContainer.h\">\n      <Filter>Header Files\\common</Filter>\n    </ClInclude>\n    <ClInclude Include=\"..\\..\\editors\\MemoryDesigner\\ConnectivityComponent.h\">\n      <Filter>Header Files\\MemoryDesigner</Filter>\n    </ClInclude>\n    <ClInclude Include=\"..\\..\\editors\\MemoryDesigner\\ConnectivityConnection.h\">\n      <Filter>Header Files\\MemoryDesigner</Filter>\n    </ClInclude>\n    <ClInclude Include=\"..\\..\\editors\\MemoryDesigner\\ConnectivityGraph.h\">\n      <Filter>Header Files\\MemoryDesigner</Filter>\n    </ClInclude>\n    <ClInclude Include=\"..\\..\\editors\\MemoryDesigner\\ConnectivityGraphFactory.h\">\n      <Filter>Header Files\\MemoryDesigner</Filter>\n    </ClInclude>\n    <ClInclude Include=\"..\\..\\editors\\MemoryDesigner\\ConnectivityInterface.h\">\n      <Filter>Header Files\\MemoryDesigner</Filter>\n    </ClInclude>\n    <ClInclude Include=\"..\\..\\editors\\MemoryDesigner\\MasterSlavePathSearch.h\">\n      <Filter>Header Files\\MemoryDesigner</Filter>\n    </ClInclude>\n    <ClInclude Include=\"..\\..\\editors\\MemoryDesigner\\MemoryConnectionAddressCalculator.h\">\n      <Filter>Header Files\\MemoryDesigner</Filter>\n    </ClInclude>\n    <ClInclude Include=\"..\\..\\editors\\MemoryDesigner\\MemoryDesignerConstants.h\">\n      <Filter>Header Files\\MemoryDesigner</Filter>\n    </ClInclude>\n    <ClInclude Include=\"..\\..\\editors\\MemoryDesigner\\MemoryItem.h\">\n      <Filter>Header Files\\MemoryDesigner</Filter>\n    </ClInclude>\n    <ClInclude Include=\"..\\PluginSystem\\GeneratorPlugin\\ViewSelection.h\">\n      <Filter>Header Files\\common</Filter>\n    </ClInclude>\n  </ItemGroup>\n  <ItemGroup>\n    <QtMoc Include=\"LinuxDeviceTreeDialog.h\">\n      <Filter>Header Files</Filter>\n    </QtMoc>\n    <QtMoc Include=\"LinuxDeviceTreePlugin.h\">\n      <Filter>Header Files</Filter>\n    </QtMoc>\n    <QtMoc Include=\"CPUSelection\\LinuxDeviceTreeCPUModel.h\">\n      <Filter>Header Files\\CPUSelection</Filter>\n    </QtMoc>\n    <QtMoc Include=\"CPUSelection\\LinuxDeviceTreeCPUDelegate.h\">\n      <Filter>Header Files\\CPUSelection</Filter>\n    </QtMoc>\n    <QtMoc Include=\"CPUSelection\\LinuxDeviceTreeCPUEditor.h\">\n      <Filter>Header Files\\CPUSelection</Filter>\n    </QtMoc>\n    <QtRcc Include=\"LinuxDeviceTree.qrc\">\n      <Filter>Resource Files</Filter>\n    </QtRcc>\n  </ItemGroup>\n  <ItemGroup>\n    <Image Include=\"LinuxDeviceTreeGenerator.png\">\n      <Filter>Resource Files</Filter>\n    </Image>\n  </ItemGroup>\n</Project>"
  },
  {
    "path": "Plugins/LinuxDeviceTree/LinuxDeviceTreeGenerator_global.h",
    "content": "#ifndef LINUXDEVICETREEGENERATOR_GLOBAL_H\n#define LINUXDEVICETREEGENERATOR_GLOBAL_H\n\n#include <QtCore/qglobal.h>\n\n#ifdef LINUXDEVICETREEGENERATOR_LIB\n# define LINUXDEVICETREEGENERATOR_EXPORT Q_DECL_EXPORT\n#else\n# define LINUXDEVICETREEGENERATOR_EXPORT Q_DECL_IMPORT\n#endif\n\n#endif // LINUXDEVICETREEGENERATOR_GLOBAL_H\n"
  },
  {
    "path": "Plugins/LinuxDeviceTree/LinuxDeviceTreePlugin.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: LinuxDeviceTreePlugin.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Copyright: Tampere University of Technology\n// Author: Mikko Teuho\n// Date: 08.05.2018\n//\n// Description:\n// Generator plugin for Linux Device Tree.\n//-----------------------------------------------------------------------------\n\n#include \"LinuxDeviceTreePlugin.h\"\n\n#include <IPXACTmodels/Component/Component.h>\n#include <IPXACTmodels/Component/FileSet.h>\n#include <IPXACTmodels/Design/Design.h>\n\n#include <editors/MemoryDesigner/ConnectivityGraphFactory.h>\n#include <editors/MemoryDesigner/MasterSlavePathSearch.h>\n#include <editors/MemoryDesigner/ConnectivityGraphFactory.h>\n\n#include <KactusAPI/include/IPluginUtility.h>\n#include <KactusAPI/include/LibraryInterface.h>\n\n#include <Plugins/common/HDLParser/HDLCommandLineParser.h>\n#include <Plugins/LinuxDeviceTree/LinuxDeviceTreeDialog.h>\n#include <Plugins/LinuxDeviceTree/LinuxDeviceTreeGenerator.h>\n#include <Plugins/LinuxDeviceTree/CPUSelection/LinuxDeviceTreeCpuRoutesContainer.h>\n\n#include <QCoreApplication>\n#include <QFileInfo>\n#include <QMessageBox>\n#include <QDir>\n\n//-----------------------------------------------------------------------------\n// Function: LinuxDeviceTreePlugin::LinuxDeviceTreePlugin()\n//-----------------------------------------------------------------------------\nLinuxDeviceTreePlugin::LinuxDeviceTreePlugin()\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: LinuxDeviceTreePlugin::getName()\n//----------------------------------------------------------------------------\nQString LinuxDeviceTreePlugin::getName() const\n{\n    return tr(\"Linux Device Tree Generator\");\n}\n\n//-----------------------------------------------------------------------------\n// Function: LinuxDeviceTreePlugin::getVersion()\n//-----------------------------------------------------------------------------\nQString LinuxDeviceTreePlugin::getVersion() const\n{\n    return \"0.3\";\n}\n\n//-----------------------------------------------------------------------------\n// Function: LinuxDeviceTreePlugin::getDescription()\n//-----------------------------------------------------------------------------\nQString LinuxDeviceTreePlugin::getDescription() const\n{\n    return QString(\"Creates a Linux Device Tree from the selected document\");\n}\n\n//-----------------------------------------------------------------------------\n// Function: LinuxDeviceTreePlugin::getVendor()\n//-----------------------------------------------------------------------------\nQString LinuxDeviceTreePlugin::getVendor() const\n{\n    return tr(\"tuni.fi\");\n}\n\n//-----------------------------------------------------------------------------\n// Function: LinuxDeviceTreePlugin::getLicense()\n//-----------------------------------------------------------------------------\nQString LinuxDeviceTreePlugin::getLicense() const\n{\n    return tr(\"GPL2\");\n}\n\n//-----------------------------------------------------------------------------\n// Function: LinuxDeviceTreePlugin::getLicenseHolder()\n//-----------------------------------------------------------------------------\nQString LinuxDeviceTreePlugin::getLicenseHolder() const\n{\n    return tr(\"Public\");\n}\n\n//-----------------------------------------------------------------------------\n// Function: LinuxDeviceTreePlugin::getSettingsWidget()\n//-----------------------------------------------------------------------------\nQWidget* LinuxDeviceTreePlugin::getSettingsWidget()\n{\n    return nullptr;\n}\n\n//-----------------------------------------------------------------------------\n// Function: LinuxDeviceTreePlugin::getSettingsModel()\n//-----------------------------------------------------------------------------\nPluginSettingsModel* LinuxDeviceTreePlugin::getSettingsModel()\n{\n    return nullptr;\n}\n\n//-----------------------------------------------------------------------------\n// Function: LinuxDeviceTreePlugin::getIcon()\n//-----------------------------------------------------------------------------\nQIcon LinuxDeviceTreePlugin::getIcon() const\n{\n    return QIcon(\":icons/LinuxDeviceTreeGenerator.png\");\n}\n\n//-----------------------------------------------------------------------------\n// Function: LinuxDeviceTreePlugin::checkGeneratorSupport()\n//-----------------------------------------------------------------------------\nbool LinuxDeviceTreePlugin::checkGeneratorSupport(QSharedPointer<Component const> component,\n    QSharedPointer<Design const> /*design*/, QSharedPointer<DesignConfiguration const> /*designConfiguration*/) const\n{\n    return component != 0;\n}\n\n//-----------------------------------------------------------------------------\n// Function: LinuxDeviceTreePlugin::runGenerator()\n//-----------------------------------------------------------------------------\nvoid LinuxDeviceTreePlugin::runGenerator(IPluginUtility* utility, QSharedPointer<Component> component,\n    QSharedPointer<Design> design, QSharedPointer<DesignConfiguration> /*designConfiguration*/)\n{\n    utility_ = utility;\n    LibraryInterface* library = utility_->getLibraryInterface();\n    utility->printInfo(\"Running Linux Device Tree Generator \" + getVersion());\n\n    QFileInfo targetInfo(library->getPath(component->getVlnv()));\n    QString suggestedPath = library->getDirectoryPath(component->getVlnv());\n\n    LinuxDeviceTreeDialog dialog(suggestedPath, component, design, library, utility_->getParentWidget());\n\n    if (dialog.exec() == QDialog::Accepted)\n    {\n        QVector<QSharedPointer<LinuxDeviceTreeCpuRoutesContainer> > acceptedContainers = dialog.getAcceptedContainers();\n\n        if (!acceptedContainers.isEmpty())\n        {\n            generateDeviceTree(\n                component, dialog.getSelectedView(), dialog.getOutputPath(), dialog.allowAddressBlocks(),\n                dialog.getAcceptedContainers());\n\n            if (dialog.saveFileToFileSet())\n            {\n                QString targetFileSet = dialog.getTargetFileSet();\n\n                for (auto cpuContainer : acceptedContainers)\n                {\n                    QString relativePath =\n                        General::getRelativePath(targetInfo.absoluteFilePath(), cpuContainer->getFilePath());\n\n                    saveFileToFileSet(component, targetFileSet, relativePath);\n\n                    utility->getLibraryInterface()->writeModelToFile(component);\n                    utility->printInfo(\"File \" + relativePath + \" stored in fileset \" + targetFileSet +\n                        \" within component \" + component->getVlnv().toString() + \".\");\n                }\n            }\n        }\n    }\n    else\n    {\n        utility->printInfo(\"Generation aborted.\");\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: LinuxDeviceTreePlugin::runGenerator()\n//-----------------------------------------------------------------------------\nvoid LinuxDeviceTreePlugin::runGenerator(IPluginUtility* utility, QSharedPointer<Component> component,\n    QSharedPointer<Design> /*design*/, QSharedPointer<DesignConfiguration> /*designConfiguration*/,\n    QString const& viewName, QString const& outputDirectory)\n{\n    utility_ = utility;\n    utility_->printInfo(tr(\"Running %1 %2.\").arg(getName(), getVersion()));\n\n    if (!component)\n    {\n        utility_->printError(tr(\"Invalid component given as a parameter.\"));\n        return;\n    }\n\n    utility_->printInfo(tr(\"Running generation for %1 and view '%2'.\").arg(component->getVlnv().toString(),\n        viewName));\n\n    QDir targetDirectory;\n    if (!targetDirectory.mkpath(outputDirectory))\n    {\n        utility_->printError(tr(\"Could not create target directory: %1\").arg(outputDirectory));\n        return;\n    }\n\n    utility_->printInfo(tr(\"Target directory: %1\").arg(outputDirectory));\n\n    LibraryInterface* library = utility_->getLibraryInterface();\n    ConnectivityGraphFactory graphFactory(library);\n    MasterSlavePathSearch searchAlgorithm;\n\n    QVector<QSharedPointer<LinuxDeviceTreeCpuRoutesContainer> > cpuContainers =\n        LinuxDeviceTreeCPUDetails::getCPUContainers(component->getVlnv().getName(), component, viewName, library);\n\n    generateDeviceTree(component, viewName, outputDirectory, false, cpuContainers);\n}\n\n//-----------------------------------------------------------------------------\n// Function: LinuxDeviceTreePlugin::getOutputFormat()\n//-----------------------------------------------------------------------------\nQString LinuxDeviceTreePlugin::getOutputFormat() const\n{\n    return QStringLiteral(\"dts\");\n}\n\n//-----------------------------------------------------------------------------\n// Function: LinuxDeviceTreePlugin::getProgramRequirements()\n//-----------------------------------------------------------------------------\nQList<IPlugin::ExternalProgramRequirement> LinuxDeviceTreePlugin::getProgramRequirements()\n{\n    return QList<IPlugin::ExternalProgramRequirement>();\n}\n\n//-----------------------------------------------------------------------------\n// Function: LinuxDeviceTreePlugin::createFileNamePath()\n//-----------------------------------------------------------------------------\nQString LinuxDeviceTreePlugin::createFileNamePath(QString const& suggestedPath, QString const& componentName) const\n{\n    QString fileNamePath = suggestedPath;\n    if (fileNamePath.endsWith(QLatin1Char('/')) == false)\n    {\n        fileNamePath.append(QLatin1Char('/'));\n    }\n\n    fileNamePath.append(componentName);\n    fileNamePath.append(QStringLiteral(\".dts\"));\n\n    return fileNamePath;\n}\n\n//-----------------------------------------------------------------------------\n// Function: LinuxDeviceTreePlugin::generateDeviceTree()\n//-----------------------------------------------------------------------------\nvoid LinuxDeviceTreePlugin::generateDeviceTree(QSharedPointer<Component> component, QString const& activeView,\n    QString const& folderPath, bool writeBlocks,\n    QVector<QSharedPointer<LinuxDeviceTreeCpuRoutesContainer>> acceptedContainers)\n{\n    LinuxDeviceTreeGenerator generator(utility_->getLibraryInterface());\n    if (generator.generate(component, activeView, writeBlocks, acceptedContainers, folderPath) == true)\n    {\n        utility_->printInfo(\"Generation successful.\");\n    }\n    else\n    {\n        utility_->printError(\"Generation failed.\");\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: LinuxDeviceTreePlugin:::onErrorReport()\n//-----------------------------------------------------------------------------\nvoid LinuxDeviceTreePlugin::onErrorReport(const QString& report)\n{\n    utility_->printError(report);\n}\n\n//-----------------------------------------------------------------------------\n// Function: LinuxDeviceTreePlugin::saveFileToFileSet()\n//-----------------------------------------------------------------------------\nvoid LinuxDeviceTreePlugin::saveFileToFileSet(QSharedPointer<Component> component, QString const& fileSetName,\n    QString const& filePath)\n{\n    QSharedPointer<FileSet> targetFileSet = getFileSet(component, fileSetName);\n    if (targetFileSet)\n    {\n        QSettings settings;\n\n        QSharedPointer<File> deviceTreeFile = targetFileSet->addFile(filePath, settings);\n        deviceTreeFile->addFileType(QString(\"linuxDeviceTree\"));\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: LinuxDeviceTreePlugin::getFileSet()\n//-----------------------------------------------------------------------------\nQSharedPointer<FileSet> LinuxDeviceTreePlugin::getFileSet(QSharedPointer<Component> component,\n    QString const& fileSetName)\n{\n    foreach(QSharedPointer<FileSet> fileSet, *component->getFileSets())\n    {\n        if (fileSet->name().compare(fileSetName) == 0)\n        {\n            return fileSet;\n        }\n    }\n\n    QSharedPointer<FileSet> newFileSet(new FileSet(fileSetName, QStringLiteral(\"generatedFiles\")));\n    component->getFileSets()->append(newFileSet);\n\n    return newFileSet;\n}\n"
  },
  {
    "path": "Plugins/LinuxDeviceTree/LinuxDeviceTreePlugin.h",
    "content": "//-----------------------------------------------------------------------------\n// File: LinuxDeviceTreePlugin.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Copyright: Tampere University of Technology\n// Author: Mikko Teuho\n// Date: 08.05.2018\n//\n// Description:\n// Generator plugin for Linux Device Tree.\n//-----------------------------------------------------------------------------\n\n#ifndef LINUXDEVICETREEPLUGIN_H\n#define LINUXDEVICETREEPLUGIN_H\n\n#include \"LinuxDeviceTreeGenerator_global.h\"\n\n#include <KactusAPI/include/IGeneratorPlugin.h>\n#include <KactusAPI/include/IPluginUtility.h>\n#include <KactusAPI/include/IPlugin.h>\n#include <KactusAPI/include/CLIGenerator.h>\n\n#include <Plugins/LinuxDeviceTree/CPUSelection/LinuxDeviceTreeCPUDetails.h>\n\n#include <QObject>\n\nclass FileSet;\nclass LinuxDeviceTreeCpuRoutesContainer;\n\n//-----------------------------------------------------------------------------\n//! Generator plugin for Linux Device Tree.\n//-----------------------------------------------------------------------------\nclass LINUXDEVICETREEGENERATOR_EXPORT LinuxDeviceTreePlugin : public QObject, public IGeneratorPlugin,\n    public CLIGenerator\n{\n    Q_OBJECT\n        Q_PLUGIN_METADATA(IID \"kactus2.plugins.LinuxDeviceTreePlugin\" FILE \"LinuxDeviceTreePlugin.json\")\n\n        Q_INTERFACES(IPlugin)\n        Q_INTERFACES(IGeneratorPlugin)\n\npublic:\n\n    /*!\n     *  The constructor.\n     */\n    LinuxDeviceTreePlugin();\n\n    /*!\n     *  The destructor.\n     */\n    virtual ~LinuxDeviceTreePlugin() = default;\n\n    /*!\n     *  Returns the name of the plugin.\n     */\n    virtual QString getName() const;\n\n    /*!\n     *  Returns the version of the plugin.\n     */\n    virtual QString getVersion() const;\n\n    /*!\n     *  Returns the description of the plugin.\n     */\n    virtual QString getDescription() const;\n\n    /*!\n     *  Returns the vendor of the plugin.\n     */\n    virtual QString getVendor() const;\n\n    /*!\n     *  Returns the license of the plugin.\n     */\n    virtual QString getLicense() const;\n\n    /*!\n     *  Returns the holder of the license of the plugin.\n     */\n    virtual QString getLicenseHolder() const;\n\n    /*!\n     *  Returns the settings widget.\n     */\n    virtual QWidget* getSettingsWidget();\n\n    /*!\n     *  This is used to access the settings modified by function getSettingsWidget().\n     */\n    virtual PluginSettingsModel* getSettingsModel();\n\n    /*!\n     *  Returns the icon for the generator.\n     */\n    virtual QIcon getIcon() const;\n\n    /*!\n     *  Checks whether the generator may run for the given component or design.\n     *\n     *    @param [in] component\t        The component for which to check support. If design is not null, component\n\t *                                      will refer to design or designConfiguration.\n     *    @param [in] design\t            The design, if the generator is ran for a design.\n     *    @param [in] designConfiguration The design configuration for design, if it is not null.\n     *\n     *    @return True, if the generator may run the given component. Otherwise false.\n     */\n    virtual bool checkGeneratorSupport(QSharedPointer<Component const> component,\n        QSharedPointer<Design const> design, QSharedPointer<DesignConfiguration const> designConfiguration) const;\n\n    /*!\n     *  Runs the generation, creating new files and/or modifying the IP-XACT metadata. The function has\n\t *  also access to the parent window widget, so that it can show dialogs for the user to aid the generation.\n     *\n     *    @param [in] utility\t\t\t    The plugin utility interface.\n     *    @param [in] component\t        The component for which to check support. If design is not null, component\n     *                                      will refer to design or designConfiguration.\n     *    @param [in] design\t            The design, if the generator is ran for a design.\n     *    @param [in] designConfiguration The design configuration for design, if it is not null.\n     */\n    virtual void runGenerator(IPluginUtility* utility, QSharedPointer<Component> component,\n        QSharedPointer<Design> design, QSharedPointer<DesignConfiguration> designConfiguration);\n\n    virtual void runGenerator(IPluginUtility* utility, QSharedPointer<Component> component,\n        QSharedPointer<Design> design, QSharedPointer<DesignConfiguration> designConfiguration,\n        QString const& viewName, QString const& outputDirectory) override final;\n\n    virtual QString getOutputFormat() const override final;\n\n\n     /*!\n      * Returns the external program requirements of the plugin.\n      */\n     virtual QList<IPlugin::ExternalProgramRequirement> getProgramRequirements();\n\n\npublic slots:\n\n    /*!\n     *  Called when an error is reported to us.\n     *\n\t *    @param [in] report\t\t\tThe error message.\n\t */\n    void onErrorReport(const QString& report);\n\nprivate:\n\n    /*!\n     *\tSave the created device tree file to the selected file set.\n     *\n     *\t\t@param [in]\tcomponent       Component containing the selected file set.\n     *\t\t@param [in]\tfileSetName     Name of the selected file set.\n     *\t\t@param [in]\tfilePath        Path of the created device tree file.\n     */\n    void saveFileToFileSet(QSharedPointer<Component> component, QString const& fileSetName,\n        QString const& filePath);\n\n    /*!\n     *\tGet the selected file set.\n     *\n     *\t\t@param [in]\tcomponent       Component containing the selected file set.\n     *\t\t@param [in]\tfileSetName     Name of the selected file set.\n     *\n     *\t\t@return\tThe selected file set.\n     */\n    QSharedPointer<FileSet> getFileSet(QSharedPointer<Component> component, QString const& fileSetName);\n\n    /*!\n     *  Create a path containing the default file name.\n     *\n     *    @param [in] suggestedPath   The suggested path for the device tree file.\n     *    @param [in] componentName   Name of the component.\n     */\n    QString createFileNamePath(QString const& suggestedPath, QString const& componentName) const;\n\n    /*!\n     *  Generate the device tree.\n     *\n     *    @param [in] component           The selected top component.\n     *    @param [in] activeView          View of the selected top component.\n     *    @param [in] folderPath          Folder path for the device tree files.\n     *    @param [in] writeBlocks         Flag for writing address block data.\n     *    @param [in] acceptedContainers  List of CPU containers to be written.\n     */\n    void generateDeviceTree(QSharedPointer<Component> component, QString const& activeView,\n        QString const& folderPath, bool writeBlocks,\n        QVector<QSharedPointer<LinuxDeviceTreeCpuRoutesContainer> > acceptedContainers);\n\n    //-----------------------------------------------------------------------------\n    // Data.\n    //-----------------------------------------------------------------------------\n\n    //! The plugin utility provided by call runGenerator.\n    IPluginUtility* utility_;\n};\n\n#endif // LINUXDEVICETREEPLUGIN_H\n"
  },
  {
    "path": "Plugins/LinuxDeviceTree/LinuxDeviceTreePlugin.json",
    "content": "{\n\t\"Keys\": [ \"sampleGenerator\" ]\n}"
  },
  {
    "path": "Plugins/MCAPICodeGenerator/MCAPICodeGenerator.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: MCAPICodeGenerator.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Joni-Matti Maatta\r\n// Date: 27.6.2012\r\n//\r\n// Description:\r\n// MCAPI code generator.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"MCAPICodeGenerator.h\"\r\n\r\n#include <QMessageBox>\r\n#include <QCoreApplication>\r\n\r\n#include <Plugins/common/CSourceWriter.h>\r\n#include <editors/CSourceEditor/CSourceTextEdit.h>\r\n\r\n#include <IPXACTmodels/Component/FileSet.h>\r\n\r\n#include \"common/dialogs/comboSelector/comboselector.h\"\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MCAPICodeGenerator::MCAPICodeGenerator()\r\n//-----------------------------------------------------------------------------\r\nMCAPICodeGenerator::MCAPICodeGenerator( MCAPIParser& parser, IPluginUtility* utility ) : \r\ncomponentEndpoints_( parser.getComponentEndpoints() ), designNodes_( parser.getDesignNodes() ), utility_( utility )\r\n{\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MCAPICodeGenerator::~MCAPICodeGenerator()\r\n//-----------------------------------------------------------------------------\r\nMCAPICodeGenerator::~MCAPICodeGenerator()\r\n{\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MCAPICodeGenerator::generateMCAPIForComponent()\r\n//-----------------------------------------------------------------------------\r\nvoid MCAPICodeGenerator::generateMCAPIForComponent(QString dir, QSharedPointer<Component> component)\r\n{\r\n    QStringList replacedFiles;\r\n\r\n    QString mainDir = dir + \"/main.c\";\r\n    QString sourceDir = dir + \"/ktsmcapicode.c\";\r\n    QString headerDir = dir + \"/ktsmcapicode.h\";\r\n\r\n    // We also need to know if the files exists\r\n    QFile file1(mainDir);\r\n    QFile file2(sourceDir);\r\n    QFile file3(headerDir);\r\n\r\n    // If does, put in the list.\r\n    if ( file1.exists() )\r\n    {\r\n        replacedFiles.append(mainDir);\r\n    }\r\n\r\n    if ( file2.exists() )\r\n    {\r\n        replacedFiles.append(sourceDir);\r\n    }\r\n\r\n    if ( file2.exists() )\r\n    {\r\n        replacedFiles.append(headerDir);\r\n    }\r\n\r\n    // Ask verification from the user, if any file is being replaced,\r\n    if ( replacedFiles.size() > 0 )\r\n    {\r\n        // Details will be the list of files being replaced.\r\n        QString detailMsg;\r\n\r\n        foreach ( QString file, replacedFiles )\r\n        {\r\n            detailMsg += file + \"\\n\";\r\n        }\r\n\r\n        QMessageBox msgBox( QMessageBox::Warning, QCoreApplication::applicationName(),\r\n            \"Some files will be WRITTEN OVER in the generation. Proceed?\",\r\n            QMessageBox::Yes | QMessageBox::No, utility_->getParentWidget());\r\n        msgBox.setDetailedText(detailMsg);\r\n\r\n        // If user did not want to replace the files.\r\n        if (msgBox.exec() == QMessageBox::No) {\r\n            return;\r\n        }\r\n    }\r\n\r\n    // Update the ktsmcapicode module.\r\n    generateMainTemplate(mainDir);\r\n    generateHeader(headerDir);\r\n    generateSource(sourceDir);\r\n\r\n    // Add the files to the component metadata.\r\n    QSharedPointer<FileSet> fileSet = component->getFileSet(\"generatedMCAPI\");\r\n\r\n    if (fileSet.isNull())\r\n    {\r\n        fileSet = QSharedPointer<FileSet>(new FileSet(\"generatedMCAPI\"));\r\n        component->getFileSets()->append(fileSet);\r\n    }\r\n\r\n    fileSet->setGroups(\"sourceFiles\");\r\n\r\n    QSharedPointer<QList<QSharedPointer<FileBuilder> > > fblist = fileSet->getDefaultFileBuilders();\r\n\r\n    bool hasCBuild = false;\r\n\r\n    // Check if there is already a builder for c sources specified.\r\n    foreach ( QSharedPointer<FileBuilder> builder, *fblist )\r\n    {\r\n        if ( builder->getFileType().type_ == \"cSource\" )\r\n        {\r\n            hasCBuild = true;\r\n            break;\r\n        }\r\n    }\r\n\r\n    // If there is no pre-existing builder for c sources, make a new one.\r\n    if ( !hasCBuild )\r\n    {\r\n        QSharedPointer<FileBuilder> newBuilder = QSharedPointer<FileBuilder>(new FileBuilder);\r\n        newBuilder->setCommand( \"gcc -c -o\" );\r\n        newBuilder->setFileType(\"cSource\");\r\n        fblist->append(newBuilder);\r\n    }\r\n\r\n    QSettings settings;\r\n\r\n    QSharedPointer<File> file;\r\n\r\n    if (!fileSet->contains(\"ktsmcapicode.h\"))\r\n    {\r\n        file = fileSet->addFile(\"ktsmcapicode.h\", settings);\r\n        file->addFileType( \"cSource\" );\r\n        file->setIncludeFile( true );\r\n    }\r\n    if (!fileSet->contains(\"ktsmcapicode.c\"))\r\n    {\r\n\t\tfile = fileSet->addFile(\"ktsmcapicode.c\", settings);\r\n\t\tfile->addFileType( \"cSource\" );\r\n\r\n        //The build flags of this file must contain tool integration to avoid redefinition.\r\n        file->setBuildFlags( \"-DTOOL_INTEGRATION\", \"false\" );\r\n    }\r\n    if (!fileSet->contains(\"main.c\"))\r\n    {\r\n\t\tfile = fileSet->addFile(\"main.c\", settings);\r\n\t\tfile->addFileType( \"cSource\" );\r\n    }\r\n\r\n    int viewCount = component->getViews()->size();\r\n    QSharedPointer<View> view;\r\n\r\n    if ( viewCount > 1 )\r\n    {\r\n        // Add fileSet to selected software view\r\n        ComboSelector cs(utility_->getParentWidget());\r\n        cs.setComboBoxItems( component->getViewNames() );\r\n        cs.setLabelText( QObject::tr(\"Select a view which shall include reference to the generated MCAPI\") );\r\n\r\n        QString viewName = cs.execDialog();\r\n\r\n        if ( !viewName.isEmpty() )\r\n        {\r\n            view = component->getModel()->findView(viewName);\r\n        }\r\n    }\r\n    else if ( viewCount > 0 )\r\n    {\r\n        component->getModel()->getViews()->first();\r\n    }\r\n\r\n    // Add fileSet to the component instantiation.\r\n    if (view)\r\n    {\r\n        QSharedPointer<ComponentInstantiation> insta = component->getModel()->\r\n            findComponentInstantiation(view->getComponentInstantiationRef());\r\n\r\n        if(insta)\r\n        {\r\n            QSharedPointer<FileSetRef> newFileSetRef(new FileSetRef());\r\n            newFileSetRef->setReference(fileSet->name());\r\n            insta->getFileSetReferences()->append(newFileSetRef);\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MCAPICodeGenerator::createIndentString()\r\n//-----------------------------------------------------------------------------\r\nQString MCAPICodeGenerator::createIndentString()\r\n{\r\n    QSettings settings;\r\n\r\n    // Read indentation settings.\r\n    IndentStyle style = static_cast<IndentStyle>(settings.value(\"Editor/IndentStyle\",\r\n        INDENT_STYLE_SPACES).toInt());\r\n    unsigned int width = settings.value(\"Editor/IndentWidth\", 4).toInt();\r\n\r\n    QString indent;\r\n\r\n    if (style == INDENT_STYLE_SPACES)\r\n    {\r\n        indent.fill(' ', width);\r\n    }\r\n    else\r\n    {\r\n        indent = \"\\t\";\r\n    }\r\n\r\n    return indent;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MCAPICodeGenerator::generateHeader()\r\n//-----------------------------------------------------------------------------\r\nvoid MCAPICodeGenerator::generateHeader(QString const& filename)\r\n{\r\n    CSourceWriter writer(filename, createIndentString());\r\n\r\n    if (!writer.open())\r\n    {\r\n        return;\r\n    }\r\n\r\n    writer.writeFileHeader();\r\n\r\n    writer.writeLine(\"// DO NOT MODIFY THIS FILE. ALL CHANGES WILL BE OVERWRITTEN BY KACTUS2.\");\r\n    writer.writeEmptyLine();\r\n\r\n    writer.writeLine(\"#ifndef KTSMCAPICODE_H\");\r\n    writer.writeLine(\"#define KTSMCAPICODE_H\");\r\n    writer.writeEmptyLine();\r\n\r\n    // Write the Kactus 2 generated code.\r\n\r\n    writer.writeInclude(\"mcapi.h\");\r\n    writer.writeEmptyLine();\r\n\r\n    writer.writeHeaderComment(\"Node data.\");\r\n    writer.writeEmptyLine();\r\n\r\n    writeLocalEndpoints(writer, true);\r\n    writeRemoteEndpoints(writer, true);\r\n\r\n    writer.writeEmptyLine();\r\n\r\n    // Write the other variables.\r\n    writer.writeLine(\"// Other variables.\");\r\n    writer.writeLine(\"extern mcapi_status_t status;\");\r\n    writer.writeEmptyLine();\r\n\r\n    writeFunctionDeclarations(writer);\r\n\r\n    writer.writeLine(\"#endif // KTSMCAPICODE_H\");\r\n    writer.writeEmptyLine();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MCAPICodeGenerator::writeFunctionDeclarations(()\r\n//-----------------------------------------------------------------------------\r\nvoid MCAPICodeGenerator::writeFunctionDeclarations(CSourceWriter &writer)\r\n{\r\n    writer.writeHeaderComment(\"Functions.\");\r\n    writer.writeEmptyLine();\r\n\r\n\r\n    writer.writeLine(\"/*\");\r\n    writer.writeLine(\" *  Main program implemented by the application.\" );\r\n    writer.writeLine(\" *  Has the same parameters as the main.\");\r\n    writer.writeLine(\" *\");\r\n    writer.writeLine(\" *        @param [in] argc    The number of arguments in the array of arguments.\");\r\n    writer.writeLine(\" *        @param [in] char* argv[]    The array of arguments to main.\");\r\n    writer.writeLine(\" */\");\r\n    writer.writeLine(\"int appmain(int argc, char* argv[]);\");\r\n    writer.writeEmptyLine();\r\n\r\n    writer.writeLine(\"/*\");\r\n    writer.writeLine(\" *  Initializes the MCAPI system and endpoints.\");\r\n    writer.writeLine(\" *\");\r\n    writer.writeLine(\" *        @return 0 if successful. -1 in case of an error.\");\r\n    writer.writeLine(\" */\");\r\n    writer.writeLine(\"int initializeMCAPI();\");\r\n    writer.writeEmptyLine();\r\n\r\n    writer.writeLine(\"/*\");\r\n    writer.writeLine(\" *  Connects all channels.\");\r\n    writer.writeLine(\" *\");\r\n    writer.writeLine(\" *        @return 0 if successful. -1 in case of an error.\");\r\n    writer.writeLine(\" */\");\r\n    writer.writeLine(\"int connectChannels();\");\r\n    writer.writeEmptyLine();\r\n\r\n    writer.writeLine(\"/*\");\r\n    writer.writeLine(\" *  Opens all connections.\");\r\n    writer.writeLine(\" *\");\r\n    writer.writeLine(\" *        @return 0 if successful. -1 in case of an error.\");\r\n    writer.writeLine(\" */\");\r\n    writer.writeLine(\"int openConnections();\");\r\n    writer.writeEmptyLine();\r\n\r\n    writer.writeLine(\"/*\");\r\n    writer.writeLine(\" *  Closes all connections.\");\r\n    writer.writeLine(\" *\");\r\n    writer.writeLine(\" *        @return 0 if successful. -1 in case of an error.\");\r\n    writer.writeLine(\" */\");\r\n    writer.writeLine(\"int closeConnections();\");\r\n    writer.writeEmptyLine();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MCAPICodeGenerator::generateSource()\r\n//-----------------------------------------------------------------------------\r\nvoid MCAPICodeGenerator::generateSource(QString const& filename)\r\n{\r\n    CSourceWriter writer(filename, createIndentString());\r\n\r\n    if (!writer.open())\r\n    {\r\n        return;\r\n    }\r\n\r\n    writer.writeFileHeader();\r\n\r\n    // Write the Kactus 2 generated code.\r\n    writer.writeLine(\"// DO NOT MODIFY THIS FILE. ALL CHANGES WILL BE OVERWRITTEN BY KACTUS2.\");\r\n    writer.writeEmptyLine();\r\n\r\n    writer.writeInclude(\"ktsmcapicode.h\", true);\r\n    writer.writeInclude(\"instanceheader.h\", true);\r\n    writer.writeInclude(\"stdio.h\");\r\n    writer.writeInclude(\"errno.h\");\r\n    writer.writeEmptyLine();\r\n    writer.writeHeaderComment(\"Constants.\");\r\n    writer.writeEmptyLine();\r\n    writer.writeLine(\"const mcapi_timeout_t TIMEOUT = 1000;\");\r\n    writer.writeEmptyLine();\r\n\r\n    // Write local port IDs.\r\n    writeLocalPorts(writer);\r\n\r\n    writer.writeEmptyLine();\r\n\r\n    writeLocalEndpoints(writer, false);\r\n    writeRemoteEndpoints(writer, false);\r\n\r\n    writer.writeEmptyLine();\r\n\r\n    // Write the other variables.\r\n    writer.writeLine(\"// Other variables.\");\r\n    writer.writeLine(\"mcapi_status_t status;\");\r\n    writer.writeLine(\"char status_msg[MCAPI_MAX_STATUS_MSG_LEN];\");\r\n    writer.writeEmptyLine();\r\n\r\n    // Generate functions.\r\n    generateInitializeMCAPIFunc(writer);\r\n    generateConnectChannelsFunc(writer);\r\n    generateOpenConnectionsFunc(writer);\r\n    generateCloseConnectionsFunc(writer);\r\n\r\n    writer.writeEmptyLine();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MCAPICodeGenerator::writeLocalPorts()\r\n//-----------------------------------------------------------------------------\r\nvoid MCAPICodeGenerator::writeLocalPorts(CSourceWriter &writer)\r\n{\r\n    writer.writeLine(\"// Local port IDs.\");\r\n\r\n    foreach (MCAPIParser::EndPointData epd, componentEndpoints_)\r\n    {\r\n        writer.writeLine(\"const mcapi_port_t \" + epd.name.toUpper() + \"_PORT = \" + epd.portID + \";\");\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MCAPICodeGenerator::writeLocalEndpoints()\r\n//-----------------------------------------------------------------------------\r\nvoid MCAPICodeGenerator::writeLocalEndpoints(CSourceWriter &writer, bool isExtern)\r\n{\r\n    writer.writeLine(\"// Local endpoints.\");\r\n\r\n    QString externString;\r\n\r\n    if ( isExtern )\r\n    {\r\n        externString = \"extern \";\r\n    }\r\n\r\n    foreach (MCAPIParser::EndPointData epd, componentEndpoints_)\r\n    {\r\n        writer.writeLine(externString + \"mcapi_endpoint_t \" + epd.name + \";\");\r\n\r\n        QString handleName = epd.handleName;\r\n\r\n        if (epd.transferType == \"packet\")\r\n        {\r\n            if (epd.direction == DirectionTypes::OUT)\r\n            {\r\n                writer.writeLine(externString + \"mcapi_pktchan_send_hndl_t \" + handleName + \";\");\r\n            }\r\n            else\r\n            {\r\n                writer.writeLine(externString + \"mcapi_pktchan_recv_hndl_t \" + handleName + \";\");\r\n            }\r\n        }\r\n        else if (epd.transferType == \"scalar\")\r\n        {\r\n            if (epd.direction == DirectionTypes::OUT)\r\n            {\r\n                writer.writeLine(externString + \"mcapi_sclchan_send_hndl_t \" + handleName + \";\");\r\n            }\r\n            else\r\n            {\r\n                writer.writeLine(externString + \"mcapi_sclchan_recv_hndl_t \" + handleName + \";\");\r\n            }\r\n        }\r\n\r\n        writer.writeEmptyLine();\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MCAPICodeGenerator::writeRemoteEndpoints()\r\n//-----------------------------------------------------------------------------\r\nvoid MCAPICodeGenerator::writeRemoteEndpoints(CSourceWriter &writer, bool isExtern)\r\n{\r\n    writer.writeLine(\"// Remote endpoints.\");\r\n\r\n    QString externString;\r\n\r\n    if ( isExtern )\r\n    {\r\n        externString = \"extern \";\r\n    }\r\n\r\n    foreach (MCAPIParser::EndPointData epd, componentEndpoints_)\r\n    {\r\n        QString remoteEndpointName = epd.remoteName;\r\n        writer.writeLine(externString + \"mcapi_endpoint_t \" + remoteEndpointName + \";\");\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MCAPICodeGenerator::generateMainTemplate()\r\n//-----------------------------------------------------------------------------\r\nvoid MCAPICodeGenerator::generateMainTemplate(QString const& filename)\r\n{\r\n    CSourceWriter writer(filename, createIndentString());\r\n\r\n    if (!writer.open())\r\n    {\r\n        return;\r\n    }\r\n\r\n    writer.writeFileHeader();\r\n\r\n    writer.writeLine(\"// DO NOT MODIFY THIS FILE. ALL CHANGES WILL BE OVERWRITTEN BY KACTUS2.\");\r\n    writer.writeEmptyLine();\r\n\r\n    // Write includes.\r\n    writer.writeInclude(\"stdlib.h\");\r\n    writer.writeInclude(\"stdio.h\");\r\n    writer.writeInclude(\"errno.h\");\r\n    writer.writeEmptyLine();\r\n\r\n    writer.writeLine(\"// This header includes the Kactus2 generated MCAPI code.\");\r\n    writer.writeInclude(\"ktsmcapicode.h\");\r\n    writer.writeEmptyLine();\r\n\r\n    writer.writeLine(\"int main(int argc, char* argv[])\");\r\n    writer.beginBlock();\r\n    writer.writeLine(\"// Return value from application main.\");\r\n    writer.writeLine(\"int appReturn = 0;\");\r\n    writer.writeLine(\"// Initialize MCAPI.\");\r\n\r\n    writer.writeLine(\"if (initializeMCAPI() != 0)\");\r\n    writer.beginBlock();\r\n    writer.writeLine(\"fprintf(stderr, \\\"MCAPI INITIALIZATION FAILED!!!\\\\n\\\" );\");\r\n    writer.writeLine(\"return EXIT_FAILURE;\");\r\n    writer.endBlock();\r\n    writer.writeEmptyLine();\r\n\r\n    writer.writeLine(\"if (connectChannels() != 0)\");\r\n    writer.beginBlock();\r\n    writer.writeLine(\"fprintf(stderr, \\\"CONNECTING CHANNELS FAILED!!!\\\\n\\\" );\");\r\n    writer.writeLine(\"return EXIT_FAILURE;\");\r\n    writer.endBlock();\r\n    writer.writeEmptyLine();\r\n\r\n    writer.writeLine(\"if (openConnections() != 0)\");\r\n    writer.beginBlock();\r\n    writer.writeLine(\"fprintf(stderr, \\\"OPENING CHANNELS FAILED!!!\\\\n\\\" );\");\r\n    writer.writeLine(\"return EXIT_FAILURE;\");\r\n    writer.endBlock();\r\n    writer.writeEmptyLine();\r\n\r\n    writer.writeLine(\"// Branching to the application execution.\");\r\n    writer.writeLine(\"// NOTICE: This function must be implemented by application!\");\r\n    writer.writeLine(\"appReturn = appmain(argc, argv);\");\r\n    writer.writeEmptyLine();\r\n    writer.writeLine(\"// Close connections and finalize MCAPI before exiting.\");\r\n    writer.writeLine(\"if (closeConnections() != 0)\");\r\n    writer.beginBlock();\r\n    writer.writeLine(\"fprintf(stderr, \\\"CLOSING CHANNELS FAILED!!!\\\\n\\\" );\");\r\n    writer.writeLine(\"return EXIT_FAILURE;\");\r\n    writer.endBlock();\r\n    writer.writeEmptyLine();\r\n    writer.writeLine(\"mcapi_finalize(&status);\");\r\n    writer.writeEmptyLine();\r\n    writer.writeLine(\"return appReturn;\");\r\n\r\n    writer.endBlock();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MCAPICodeGenerator::generateInitializeMCAPIFunc()\r\n//-----------------------------------------------------------------------------\r\nvoid MCAPICodeGenerator::generateInitializeMCAPIFunc(CSourceWriter& writer)\r\n{\r\n    // Write the initialization function.\r\n    writer.writeHeaderComment(\"Function: initializeMCAPI()\");\r\n    writer.writeLine(\"int initializeMCAPI()\");\r\n\r\n    writer.beginBlock();\r\n    writer.writeLine(\"mcapi_status_t status;\");\r\n    writer.writeLine(\"mcapi_info_t info;\");\r\n    writer.writeEmptyLine();\r\n\r\n    createInitialization(writer);\r\n    writer.writeEmptyLine();\r\n\r\n    createLocalEndpoints(writer);\r\n\r\n    getRemoteEndpoints(writer);\r\n\r\n    writer.writeLine(\"return 0;\");\r\n    writer.endBlock();\r\n    writer.writeEmptyLine();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MCAPICodeGenerator::createInitialization()\r\n//-----------------------------------------------------------------------------\r\nvoid MCAPICodeGenerator::createInitialization(CSourceWriter &writer)\r\n{\r\n    writer.writeLine(\"// Initialize MCAPI implementation.\");\r\n    writer.writeLine(\"mcapi_initialize(LOCAL_DOMAIN_ID, LOCAL_NODE_ID, 0, 0, &info, &status);\");\r\n    writer.writeEmptyLine();\r\n\r\n    writer.writeLine(\"if (status != MCAPI_SUCCESS)\");\r\n    writer.beginBlock();\r\n    writer.writeLine(\"mcapi_display_status( status, status_msg, MCAPI_MAX_STATUS_MSG_LEN );\");\r\n    writer.writeLine(\"fprintf(stderr, \\\"ERROR: %s Failed to initialized node %u at domain %u\\\"\" );\r\n    writer.writeLine( \"\\\" at line %u.\\\\n\\\", status_msg, LOCAL_NODE_ID, LOCAL_DOMAIN_ID, __LINE__ );\");\r\n    writer.writeLine(\"return -1;\");\r\n    writer.endBlock();\r\n}\r\n\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MCAPICodeGenerator::createLocalEndpoints()\r\n//-----------------------------------------------------------------------------\r\nvoid MCAPICodeGenerator::createLocalEndpoints(CSourceWriter &writer)\r\n{\r\n    writer.writeLine(\"// Create local endpoints.\");\r\n\r\n    foreach (MCAPIParser::EndPointData epd, componentEndpoints_)\r\n    {\r\n        writer.writeLine(epd.name + \" = mcapi_endpoint_create(\" + epd.name.toUpper() + \"_PORT, &status);\");\r\n        writer.writeEmptyLine();\r\n\r\n        writer.writeLine(\"if (status != MCAPI_SUCCESS)\");\r\n        writer.beginBlock();\r\n\r\n        writer.writeLine(\"mcapi_display_status( status, status_msg, MCAPI_MAX_STATUS_MSG_LEN );\");\r\n        writer.writeLine(\"fprintf(stderr, \\\"ERROR: %s Failed to create endpoint \" + epd.name + \"\\\"\" );\r\n        writer.writeLine( \"\\\" at line %u.\\\\n\\\", status_msg, __LINE__ );\");\r\n        writer.writeLine(\"return -1;\");\r\n        writer.endBlock();\r\n        writer.writeEmptyLine();\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MCAPICodeGenerator::getRemoteEndpoints()\r\n//-----------------------------------------------------------------------------\r\nvoid MCAPICodeGenerator::getRemoteEndpoints(CSourceWriter &writer)\r\n{\r\n    writer.writeLine(\"// Retrieve remote endpoints.\");\r\n\r\n    foreach (MCAPIParser::EndPointData epd, componentEndpoints_)\r\n    {\r\n        writer.writeLine(epd.remoteName + \" = mcapi_endpoint_get(\" + epd.remoteName.toUpper() +\r\n            \"_DOMAIN\" + \", \" +  epd.remoteName.toUpper() + \"_NODE,\" );\r\n        writer.writeLine( epd.remoteName.toUpper() + \"_PORT, TIMEOUT, &status);\");\r\n        writer.writeEmptyLine();\r\n\r\n        writer.writeLine(\"if (status != MCAPI_SUCCESS)\");\r\n        writer.beginBlock();\r\n        writer.writeLine(\"mcapi_display_status( status, status_msg, MCAPI_MAX_STATUS_MSG_LEN );\");\r\n        writer.writeLine(\"fprintf(stderr, \\\"ERROR: %s Failed to get remote endpoint \" + epd.name + \"\\\"\" );\r\n        writer.writeLine(\"\\\" at line %u.\\\\n\\\", status_msg, __LINE__ );\");\r\n        writer.writeLine(\"return -1;\");\r\n        writer.endBlock();\r\n        writer.writeEmptyLine();\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MCAPICodeGenerator::generateConnectChannelsFunc()\r\n//-----------------------------------------------------------------------------\r\nvoid MCAPICodeGenerator::generateConnectChannelsFunc(CSourceWriter& writer)\r\n{\r\n    // Write the connectChannels() function.\r\n    writer.writeHeaderComment(\"Function: connectChannels()\");\r\n    writer.writeLine(\"int connectChannels()\");\r\n\r\n    // Must have request for each interface, and a value used to check if it opened already.\r\n    QString interfaceCount = QString::number( componentEndpoints_.size() ) ;\r\n\r\n    writer.beginBlock();\r\n    writeConnectionVariables(writer, interfaceCount, \"connect\");\r\n    writer.writeEmptyLine();\r\n\r\n    foreach (MCAPIParser::EndPointData epd, componentEndpoints_ )\r\n    {\r\n        // Sender is responsible of calling the connect function.\r\n        if ( epd.direction == DirectionTypes::OUT )\r\n        {\r\n            if (epd.transferType == \"packet\")\r\n            {\r\n                writeCon(epd, writer, \"pkt\");\r\n            }\r\n            else if (epd.transferType == \"scalar\")\r\n            {\r\n                writeCon(epd, writer, \"scl\");\r\n            }\r\n        }\r\n        else\r\n        {\r\n            writer.writeLine(\"connect_complete[ifIter] = 1;\");\r\n        }\r\n\r\n        writer.writeLine(\"++ifIter;\");\r\n        writer.writeEmptyLine();\r\n    }\r\n    \r\n    writeRetryLoop(writer, \"connect\");\r\n\r\n    writer.writeEmptyLine();\r\n    writer.writeLine(\"return 0;\");\r\n    writer.endBlock();\r\n    writer.writeEmptyLine();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MCAPICodeGenerator::generateOpenConnectionsFunc()\r\n//-----------------------------------------------------------------------------\r\nvoid MCAPICodeGenerator::generateOpenConnectionsFunc(CSourceWriter& writer)\r\n{\r\n    // Write the openConnections() function.\r\n    writer.writeHeaderComment(\"Function: openConnections()\");\r\n    writer.writeLine(\"int openConnections()\");\r\n\r\n    // Must have request for each interface, and a value used to check if it opened already.\r\n    QString interfaceCount = QString::number( componentEndpoints_.size() ) ;\r\n\r\n    writer.beginBlock();\r\n    writeConnectionVariables(writer, interfaceCount, \"open\");\r\n    writer.writeEmptyLine();\r\n\r\n    foreach (MCAPIParser::EndPointData epd, componentEndpoints_)\r\n    {\r\n        if (epd.transferType == \"packet\")\r\n        {\r\n            writeOpen(epd, writer, \"pkt\");\r\n        }\r\n        else if (epd.transferType == \"scalar\")\r\n        {\r\n            writeOpen(epd, writer, \"scl\");\r\n        }\r\n\r\n        writer.writeLine(\"++ifIter;\");\r\n        writer.writeEmptyLine();\r\n    }\r\n\r\n    writeRetryLoop(writer, \"open\");\r\n\r\n    writer.writeEmptyLine();\r\n    writer.writeLine(\"return 0;\");\r\n    writer.endBlock();\r\n    writer.writeEmptyLine();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MCAPICodeGenerator::generateCloseConnectionsFunc()\r\n//-----------------------------------------------------------------------------\r\nvoid MCAPICodeGenerator::generateCloseConnectionsFunc(CSourceWriter& writer)\r\n{\r\n    // Write the closeConnections() function.\r\n    writer.writeHeaderComment(\"Function: closeConnections()\");\r\n    writer.writeLine(\"int closeConnections()\");\r\n\r\n    // Must have request for each interface, and a value used to check if it opened already.\r\n    QString interfaceCount = QString::number( componentEndpoints_.size() ) ;\r\n\r\n    writer.beginBlock();\r\n    writeConnectionVariables(writer, interfaceCount, \"close\");\r\n\r\n    writer.writeEmptyLine();\r\n\r\n    foreach (MCAPIParser::EndPointData epd, componentEndpoints_)\r\n    {\r\n        if (epd.transferType == \"packet\")\r\n        {\r\n            writeClose(epd, writer, \"pkt\");\r\n        }\r\n        else if (epd.transferType == \"scalar\")\r\n        {\r\n            writeClose(epd, writer, \"scl\");\r\n        }\r\n\r\n        writer.writeLine(\"++ifIter;\");\r\n        writer.writeEmptyLine();\r\n    }\r\n\r\n    writeRetryLoop(writer, \"close\");\r\n    writer.writeEmptyLine();\r\n\r\n    writer.writeEmptyLine();\r\n    writer.writeLine(\"return 0;\");\r\n    writer.endBlock();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MCAPICodeGenerator::writeConnectionParameters()\r\n//-----------------------------------------------------------------------------\r\nvoid MCAPICodeGenerator::writeConnectionVariables(CSourceWriter &writer, QString interfaceCount, QString name)\r\n{\r\n    writer.writeLine(\"size_t interfaceCount = \" + interfaceCount + \";\");\r\n    writer.writeLine(\"int tryMaximum = 5;\");\r\n    writer.writeLine(\"mcapi_request_t request;\");\r\n    writer.writeLine(\"mcapi_request_t \" + name + \"_request[interfaceCount];\");\r\n    writer.writeLine(\"char \" + name + \"_complete[interfaceCount];\");\r\n    writer.writeLine(\"size_t size = 0;\");\r\n    writer.writeLine(\"int ifIter = 0;\");\r\n    writer.writeLine(\"int retry = 0;\");\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MCAPICodeGenerator::writeConOpen()\r\n//-----------------------------------------------------------------------------\r\nvoid MCAPICodeGenerator::writeCon(MCAPIParser::EndPointData epd, CSourceWriter &writer, QString name)\r\n{\r\n    writer.writeLine(\"mcapi_\" + name + \"chan_connect_i(\" + epd.name + \", \" +\r\n        epd.remoteName + \", &request, &status);\");\r\n\r\n    writer.writeEmptyLine();\r\n    writePendStatusCheck(writer, \"connect\");\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MCAPICodeGenerator::writeConOpen()\r\n//-----------------------------------------------------------------------------\r\nvoid MCAPICodeGenerator::writeOpen(MCAPIParser::EndPointData epd, CSourceWriter &writer, QString name)\r\n{\r\n    if (epd.direction == DirectionTypes::OUT)\r\n    {\r\n        writer.writeLine(\"mcapi_\" + name + \"chan_send_open_i(&\" + epd.handleName +\r\n            \", \" + epd.name + \", &request, &status);\");\r\n    }\r\n    else if (epd.direction == DirectionTypes::IN)\r\n    {\r\n        writer.writeLine(\"mcapi_\" + name + \"chan_recv_open_i(&\" + epd.handleName +\r\n            \", \" + epd.name + \", &request, &status);\");\r\n    }\r\n\r\n    writer.writeEmptyLine();\r\n    writePendStatusCheck(writer, \"open\");\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MCAPICodeGenerator::writeClose()\r\n//-----------------------------------------------------------------------------\r\nvoid MCAPICodeGenerator::writeClose(MCAPIParser::EndPointData epd, CSourceWriter &writer, QString name)\r\n{\r\n    if (epd.direction == DirectionTypes::OUT)\r\n    {\r\n        writer.writeLine(\"mcapi_\" + name + \"chan_send_close_i(\" + epd.handleName + \", &request, &status);\");\r\n    }\r\n    else if (epd.direction == DirectionTypes::IN)\r\n    {\r\n        writer.writeLine(\"mcapi_\" + name + \"chan_recv_close_i(\" + epd.handleName + \", &request, &status);\");\r\n    }\r\n\r\n    writer.writeEmptyLine();\r\n    writePendStatusCheck(writer, \"close\");\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MCAPICodeGenerator::writeRetryLoop()\r\n//-----------------------------------------------------------------------------\r\nvoid MCAPICodeGenerator::writeRetryLoop(CSourceWriter &writer, QString name)\r\n{\r\n    writer.writeLine(\"for ( retry = 0; retry < tryMaximum; ++retry )\");\r\n    writer.beginBlock();\r\n    writer.writeLine(\"for ( ifIter = 0; ifIter < interfaceCount; ++ifIter )\");\r\n    writer.beginBlock();\r\n\r\n    writeIterationWait(writer, name);\r\n\r\n    writer.endBlock();\r\n    writer.endBlock();\r\n\r\n    writer.writeEmptyLine();\r\n    writeCompleteCheck(writer, name);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MCAPICodeGenerator::writeIterationWait()\r\n//-----------------------------------------------------------------------------\r\nvoid MCAPICodeGenerator::writeIterationWait(CSourceWriter &writer, QString name)\r\n{\r\n    writer.writeLine(\"if ( \" + name + \"_complete[ifIter] != 1 )\");\r\n    writer.beginBlock();\r\n    writer.writeLine(\"if (mcapi_wait(&\" + name + \"_request[ifIter], &size, TIMEOUT, &status)\");\r\n    writer.writeLine(\"== MCAPI_TRUE && status == MCAPI_SUCCESS)\");\r\n    writer.beginBlock();\r\n    writer.writeLine(name + \"_complete[ifIter] = 1;\");\r\n    writer.endBlock();\r\n    writer.endBlock();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MCAPICodeGenerator::writeCompleteCheck()\r\n//-----------------------------------------------------------------------------\r\nvoid MCAPICodeGenerator::writeCompleteCheck(CSourceWriter &writer, QString name)\r\n{\r\n    writer.writeLine(\"for ( ifIter = 0; ifIter < interfaceCount; ++ifIter )\");\r\n    writer.beginBlock();\r\n    writer.writeLine(\"if ( \" + name + \"_complete[ifIter] != 1 )\");\r\n    writer.beginBlock();\r\n    writer.writeLine(\"mcapi_display_status( status, status_msg, MCAPI_MAX_STATUS_MSG_LEN );\");\r\n    writer.writeLine(\"fprintf(stderr, \\\"ERROR: %s Failed to \" + name + \" channel \\\"\" );\r\n    writer.writeLine(\"\\\"at line %u.\\\\n\\\", status_msg, __LINE__ );\");\r\n    writer.writeLine(\"return -1;\");\r\n    writer.endBlock();\r\n    writer.endBlock();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MCAPICodeGenerator::writePendStatusCheck()\r\n//-----------------------------------------------------------------------------\r\nvoid MCAPICodeGenerator::writePendStatusCheck(CSourceWriter &writer, QString name)\r\n{\r\n    writer.writeLine(\"if (status == MCAPI_PENDING)\");\r\n    writer.beginBlock();\r\n    writer.writeLine(name + \"_request[ifIter] = request;\");\r\n    writer.writeLine(name + \"_complete[ifIter] = 0;\");\r\n    writer.endBlock();\r\n\r\n    writer.writeLine(\"else if (status != MCAPI_SUCCESS)\");\r\n    writer.beginBlock();\r\n    writer.writeLine(\"mcapi_display_status( status, status_msg, MCAPI_MAX_STATUS_MSG_LEN );\");\r\n    writer.writeLine(\"fprintf(stderr, \\\"ERROR: %s Failed to \" + name + \" channel \\\"\" );\r\n    writer.writeLine(\"\\\"at line %u.\\\\n\\\", status_msg, __LINE__ );\");\r\n    writer.writeLine(\"return -1;\");\r\n    writer.endBlock();\r\n\r\n    writer.writeLine(\"else\");\r\n    writer.beginBlock();\r\n        writer.writeLine(name + \"_complete[ifIter] = 1;\");\r\n    writer.endBlock();\r\n\r\n    writer.writeEmptyLine();\r\n}\r\n"
  },
  {
    "path": "Plugins/MCAPICodeGenerator/MCAPICodeGenerator.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: MCAPICodeGenerator.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Joni-Matti Maatta\r\n// Date: 27.6.2012\r\n//\r\n// Description:\r\n// MCAPI code generator.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef MCAPICODEGENERATOR_H\r\n#define MCAPICODEGENERATOR_H\r\n\r\n#include <IPXACTmodels/kactusExtensions/ComDefinition.h>\r\n#include <IPXACTmodels/kactusExtensions/ComInterface.h>\r\n\r\n#include <KactusAPI/include/IPluginUtility.h>\r\n\r\n#include <MCAPIParser.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n//! MCAPI code generator.\r\n//-----------------------------------------------------------------------------\r\nclass MCAPICodeGenerator\r\n{\r\npublic:\r\n    MCAPICodeGenerator( MCAPIParser& parser, IPluginUtility* utility );\r\n    ~MCAPICodeGenerator();\r\n\r\n    /*!\r\n     *  Generates MCAPI code for the given component.\r\n     *\r\n     *    @param [in] QString dir   The directory for the generated code.\r\n     *    @param [in] QSharedPointer<Component> component   The component which MCAPI code will be generated.\r\n     */\r\n    void generateMCAPIForComponent(QString dir, QSharedPointer<Component> component);\r\n\r\nprivate:\r\n\r\n    /*!\r\n     *  Creates the indent string based on the application settings.\r\n     */\r\n    QString createIndentString();\r\n\r\n    /*!\r\n     *  Checks if MCAPI code may be generated for the given component.\r\n     *\r\n     *    @param [in] component   The component, which is checked.\r\n     *    @return   True, if MCAPI code can be generated for the component.\r\n     */\r\n    bool canGenerateMCAPIComponent(QSharedPointer<Component> component);\r\n\r\n    /*!\r\n     *  Checks if all properties required in given ComDefintion are set in the given ComInterface.\r\n     *\r\n     *    @param [in] comDef   The ComDefinition under inspection.\r\n     *    @param [in] comIf   The ComInterface under inspection.\r\n     *    @param [in] errorList   Missing properties will be reported in this list.\r\n     */\r\n     void checkRequiredPropertiesSet(QString componentVLNV, QSharedPointer<ComDefinition> comDef,\r\n         QSharedPointer<ComInterface> comIf,  QStringList &errorList);\r\n\r\n    /*!\r\n     *  Generates the MCAPI code header file.\r\n     *\r\n     *    @param [in] filename   The name of the header file to write.\r\n     */\r\n     void generateHeader(QString const& filename);\r\n\r\n    /*!\r\n     *  Writes function declarations for the generated code.\r\n     *\r\n     *    @param [in] writer   The source writer.\r\n     */\r\n     void writeFunctionDeclarations(CSourceWriter &writer);\r\n\r\n    /*!\r\n     *  Generates the MCAPI code source file.\r\n     *\r\n     *    @param [in] filename   The name of the source file to write.\r\n     */\r\n     void generateSource(QString const& filename);\r\n\r\n    /*!\r\n     *   Generates port identifiers for the local endpoints.\r\n     *\r\n     *    @param [in] writer   The source writer.\r\n     */\r\n     void writeLocalPorts(CSourceWriter &writer);\r\n\r\n    /*!\r\n     *  Writes declarations for remote endpoint variables and handles.\r\n     *\r\n     *    @param [in] writer   The source writer.\r\n     *    @param [in] isExtern   True, if extern is added to variable declaration.\r\n     */\r\n     void writeRemoteEndpoints(CSourceWriter &writer, bool isExtern);\r\n\r\n    /*!\r\n     *  Writes declarations for local endpoint variables.\r\n     *\r\n     *    @param [in] writer   The source writer.\r\n     *    @param [in] isExtern   True, if extern is added to variable declaration.\r\n     */\r\n     void writeLocalEndpoints(CSourceWriter &writer, bool isExtern);\r\n\r\n    /*!\r\n     *  Generates the template source containing the program main().\r\n     *\r\n     *    @param [in] filename   The name of the file to write.\r\n     */\r\n     void generateMainTemplate(QString const& filename);\r\n\r\n    /*!\r\n     *  Generates the initializeMCAPI() function based on the component.\r\n     *\r\n     *    @param [in] writer     The source writer.\r\n     */\r\n     void generateInitializeMCAPIFunc(CSourceWriter& writer);\r\n\r\n    /*!\r\n     *  Generates the node initialization code.\r\n     *\r\n     *    @param [in] writer   The source writer.\r\n     */\r\n     void createInitialization(CSourceWriter &writer);\r\n\r\n    /*!\r\n     *   Generates code to get remote endpoints for the given component.\r\n     *\r\n     *    @param [in] writer   The source writer.\r\n     */\r\n     void getRemoteEndpoints(CSourceWriter &writer);\r\n\r\n    /*!\r\n     *  Generates code to create local endpoints for the given component.\r\n     *\r\n     *    @param [in] writer   The source writer.\r\n     */\r\n     void createLocalEndpoints(CSourceWriter &writer);\r\n\r\n    /*!\r\n     *  Generates the connectChannels() function based on the component.\r\n     *\r\n     *    @param [in] writer     The source writer.\r\n     */\r\n     void generateConnectChannelsFunc(CSourceWriter& writer);\r\n\r\n    /*!\r\n     *  Generates the openConnections() function based on the component.\r\n     *\r\n     *    @param [in] writer     The source writer.\r\n     */\r\n     void generateOpenConnectionsFunc(CSourceWriter& writer);\r\n\r\n    /*!\r\n     *  Generates the closeConnections() function based on the component.\r\n     *\r\n     *    @param [in] writer     The source writer.\r\n     */\r\n     void generateCloseConnectionsFunc(CSourceWriter& writer);\r\n\r\n    /*!\r\n     *  Generates variables used in connection, open, or close function.\r\n     *\r\n     *    @param [in] writer   The source writer.\r\n     *    @param [in] interfaceCount   Number of interfaces in the component.\r\n     *    @param [in] name   Name of the operation, ideally 'connect', 'open', or 'close'.\r\n     */\r\n     void writeConnectionVariables(CSourceWriter &writer, QString interfaceCount, QString name);\r\n\r\n    /*!\r\n     *  Writes connection call for the given interface.\r\n     *\r\n     *    @param [in] comIf   Interface, which connection call is written.\r\n     *    @param [in] writer   The source writer.\r\n     *    @param [in] name   Name of transfer type, ideally 'pkt' or 'scl'.\r\n     */\r\n     void writeCon(MCAPIParser::EndPointData epd, CSourceWriter &writer, QString name);\r\n\r\n    /*!\r\n     *  Writes open call for the given interface.\r\n     *\r\n     *    @param [in] comIf   Interface, which open call is written.\r\n     *    @param [in] writer   The source writer.\r\n     *    @param [in] name   Name of transfer type, ideally 'pkt' or 'scl'.\r\n     */\r\n     void writeOpen(MCAPIParser::EndPointData epd, CSourceWriter &writer, QString name);\r\n\r\n    /*!\r\n     *  Writes close call for the given interface.\r\n     *\r\n     *    @param [in] comIf   Interface, which close call is written.\r\n     *    @param [in] writer   The source writer.\r\n     *    @param [in] name   Name of transfer type, ideally 'pkt' or 'scl'.\r\n     */\r\n     void writeClose(MCAPIParser::EndPointData epd, CSourceWriter &writer, QString name);\r\n\r\n    /*!\r\n     *  Writes loop which tries to connect, open or close for preset times.\r\n     *\r\n     *    @param [in] writer   The source writer.\r\n     *    @param [in] name   Name of the operation, ideally 'connect', 'open', or 'close'.\r\n     */\r\n     void writeRetryLoop(CSourceWriter &writer, QString name);\r\n\r\n    /*!\r\n     *  Call which waits for request for givent time.\r\n     *\r\n     *    @param [in] writer   The source writer.\r\n     *    @param [in] name   Name of the operation, ideally 'connect', 'open', or 'close'.\r\n     */\r\n     void writeIterationWait(CSourceWriter &writer, QString name);\r\n\r\n    /*!\r\n     *  Checks if all connect, open or close calls are complete.\r\n     *\r\n     *    @param [in] writer   The source writer.\r\n     *    @param [in] name   Name of the operation, ideally 'connect', 'open', or 'close'.\r\n     */\r\n     void writeCompleteCheck(CSourceWriter &writer, QString name);\r\n\r\n    /*!\r\n     *  Writes an MCAPI status check, which waits in case of pending.\r\n     *\r\n     *    @param [in] writer         The source writer.\r\n     *    @param [in] name Name of the operation, ideally 'connect', 'open', or 'close'.\r\n     */\r\n    void writePendStatusCheck(CSourceWriter &writer, QString name);\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! Endpoints parsed from component\r\n    QList<MCAPIParser::EndPointData> componentEndpoints_;\r\n    //! Nodes parsed from design.\r\n    QList<MCAPIParser::NodeData> designNodes_;\r\n    //! The plugin utility.\r\n    IPluginUtility* utility_;\r\n};\r\n\r\n#endif // MCAPICODEGENERATOR_H\r\n"
  },
  {
    "path": "Plugins/MCAPICodeGenerator/MCAPICodeGenerator.pri",
    "content": "# ----------------------------------------------------\r\n# This file is generated by the Qt Visual Studio Tools.\r\n# ------------------------------------------------------\r\n\r\nHEADERS += ../../common/NameGenerationPolicy.h \\\r\n    ../common/CSourceWriter.h \\\r\n    ./MCAPIHeaderGenerator.h \\\r\n    ./MCAPIParser.h \\\r\n    ./MCAPICodeGenerator.h \\\r\n    ../../common/dialogs/comboSelector/comboselector.h \\\r\n    ./MCAPICodeGeneratorPlugin.h\r\nSOURCES += ../../common/dialogs/comboSelector/comboselector.cpp \\\r\n    ../../common/NameGenerationPolicy.cpp \\\r\n    ../common/CSourceWriter.cpp \\\r\n    ./MCAPICodeGenerator.cpp \\\r\n    ./MCAPICodeGeneratorPlugin.cpp \\\r\n    ./MCAPIHeaderGenerator.cpp \\\r\n    ./MCAPIParser.cpp\r\nRESOURCES += MCAPICodeGenerator.qrc\r\n"
  },
  {
    "path": "Plugins/MCAPICodeGenerator/MCAPICodeGenerator.pro",
    "content": "# ----------------------------------------------------\r\n# This file is generated by the Qt Visual Studio Add-in.\r\n# ------------------------------------------------------\r\n\r\nTEMPLATE = lib\r\n\r\nQT += core xml widgets gui\r\nDEFINES += MCAPICODEGENERATOR_LIB\r\nCONFIG += c++11 plugin\r\n\r\nDEFINES += MCAPICODEGENERATOR_LIB\r\n\r\nINCLUDEPATH += ./../.. \\\r\n    ./GeneratedFiles \\\r\n    .\r\n\r\nCONFIG(debug, debug|release) {\r\n    # debug mode\r\n    LIBS += \\\r\n        -L../../executable -lIPXACTmodelsd \\\r\n        -L../../executable -lKactusAPId\r\n\r\n    MOC_DIR += ./GeneratedFiles/Debug\r\n    OBJECTS_DIR += Debug\r\n    TARGET = MCAPICodeGeneratord\r\n\r\n} else {\r\n    # release mode \r\n    LIBS += \\\r\n        -L../../executable -lIPXACTmodels \\\r\n        -L../../executable -lKactusAPI\r\n    \r\n    MOC_DIR += ./GeneratedFiles/Release\r\n    OBJECTS_DIR += Release\r\n    TARGET = MCAPICodeGenerator\r\n}\r\nDESTDIR = ../../executable/Plugins\r\n\r\nDEPENDPATH += .\r\nUI_DIR += ./GeneratedFiles\r\nRCC_DIR += ./GeneratedFiles\r\n\r\ninclude(MCAPICodeGenerator.pri)\r\n\r\ntarget.path = $$plugin_path\r\nINSTALLS += target\r\n"
  },
  {
    "path": "Plugins/MCAPICodeGenerator/MCAPICodeGenerator.qrc",
    "content": "<RCC>\r\n    <qresource prefix=\"/icons\">\r\n        <file>McapiGenerator.png</file>\r\n    </qresource>\r\n</RCC>\r\n"
  },
  {
    "path": "Plugins/MCAPICodeGenerator/MCAPICodeGenerator.vcproj",
    "content": "<?xml version=\"1.0\" encoding=\"Windows-1252\"?>\r\n<VisualStudioProject\r\n\tProjectType=\"Visual C++\"\r\n\tVersion=\"9,00\"\r\n\tName=\"MCAPICodeGenerator\"\r\n\tProjectGUID=\"{AA63BE2D-A701-4C68-9760-C71655FFE66D}\"\r\n\tKeyword=\"Qt4VSv1.0\"\r\n\tTargetFrameworkVersion=\"0\"\r\n\t>\r\n\t<Platforms>\r\n\t\t<Platform\r\n\t\t\tName=\"Win32\"\r\n\t\t/>\r\n\t\t<Platform\r\n\t\t\tName=\"x64\"\r\n\t\t/>\r\n\t</Platforms>\r\n\t<ToolFiles>\r\n\t</ToolFiles>\r\n\t<Configurations>\r\n\t\t<Configuration\r\n\t\t\tName=\"Release|Win32\"\r\n\t\t\tOutputDirectory=\"$(SolutionDir)\\executable\\Plugins\"\r\n\t\t\tIntermediateDirectory=\"$(SolutionDir)$(ConfigurationName)\"\r\n\t\t\tConfigurationType=\"2\"\r\n\t\t\t>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCPreBuildEventTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCCustomBuildTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCXMLDataGeneratorTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCWebServiceProxyGeneratorTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCMIDLTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCCLCompilerTool\"\r\n\t\t\t\tAdditionalIncludeDirectories=\"&quot;.\\GeneratedFiles&quot;;&quot;$(QTDIR)\\include&quot;;&quot;.\\GeneratedFiles\\$(ConfigurationName)&quot;;&quot;$(QTDIR)\\include\\qtmain&quot;;&quot;$(QTDIR)\\include\\QtCore&quot;;&quot;.\\&quot;;&quot;..\\..\\&quot;;&quot;$(QTDIR)\\include\\QtXml&quot;;&quot;$(QTDIR)\\include\\QtXmlPatterns&quot;;&quot;$(QTDIR)\\include\\QtGui&quot;;&quot;$(QTDIR)\\..\\qttools\\include&quot;;&quot;$(QTDIR)\\..\\qttools\\include\\QtHelp&quot;;&quot;$(QTDIR)\\include\\QtPrintSupport&quot;;&quot;$(QTDIR)\\include\\QtWidgets&quot;;&quot;$(QTDIR)\\..\\qtxmlpatterns\\include\\QtXmlPatterns&quot;;&quot;$(QTDIR)\\..\\qtxmlpatterns\\include&quot;\"\r\n\t\t\t\tPreprocessorDefinitions=\",UNICODE,WIN32,QT_NO_DEBUG,NDEBUG;QT_CORE_LIB;MCAPICODEGENERATOR_LIB;QT_XML_LIB;QT_XMLPATTERNS_LIB;QT_GUI_LIB;QT_DLL;QT_HELP_LIB;QT_PRINTSUPPORT_LIB;QT_WIDGETS_LIB\"\r\n\t\t\t\tRuntimeLibrary=\"2\"\r\n\t\t\t\tTreatWChar_tAsBuiltInType=\"false\"\r\n\t\t\t\tDebugInformationFormat=\"0\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCManagedResourceCompilerTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCResourceCompilerTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCPreLinkEventTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCLinkerTool\"\r\n\t\t\t\tAdditionalDependencies=\"qtmain.lib QtCore4.lib QtXml4.lib QtXmlPatterns4.lib QtGui4.lib Kactus2.lib Qt5Help.lib Qt5PrintSupport.lib Qt5Widgets.lib Qt5XmlPatterns.lib\"\r\n\t\t\t\tOutputFile=\"$(OutDir)\\$(ProjectName).dll\"\r\n\t\t\t\tAdditionalLibraryDirectories=\"&quot;..\\..\\executable&quot;;&quot;$(QTDIR)\\lib&quot;\"\r\n\t\t\t\tGenerateDebugInformation=\"false\"\r\n\t\t\t\tSubSystem=\"2\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCALinkTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCManifestTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCXDCMakeTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCBscMakeTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCFxCopTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCAppVerifierTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCPostBuildEventTool\"\r\n\t\t\t\tCommandLine=\"\"\r\n\t\t\t/>\r\n\t\t</Configuration>\r\n\t\t<Configuration\r\n\t\t\tName=\"Release|x64\"\r\n\t\t\tOutputDirectory=\"$(SolutionDir)\\x64\\executable\\Plugins\"\r\n\t\t\tIntermediateDirectory=\"$(PlatformName)\\$(ConfigurationName)\"\r\n\t\t\tConfigurationType=\"2\"\r\n\t\t\t>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCPreBuildEventTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCCustomBuildTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCXMLDataGeneratorTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCWebServiceProxyGeneratorTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCMIDLTool\"\r\n\t\t\t\tTargetEnvironment=\"3\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCCLCompilerTool\"\r\n\t\t\t\tAdditionalIncludeDirectories=\"&quot;.\\GeneratedFiles&quot;;&quot;$(QTDIR)\\include&quot;;&quot;.\\GeneratedFiles\\$(ConfigurationName)&quot;;&quot;$(QTDIR)\\include\\qtmain&quot;;&quot;$(QTDIR)\\include\\QtCore&quot;;&quot;.\\&quot;;&quot;..\\..\\&quot;;&quot;$(QTDIR)\\include\\QtXml&quot;;&quot;$(QTDIR)\\include\\QtXmlPatterns&quot;;&quot;$(QTDIR)\\include\\QtGui&quot;;&quot;$(QTDIR)\\..\\qttools\\include&quot;;&quot;$(QTDIR)\\..\\qttools\\include\\QtHelp&quot;;&quot;$(QTDIR)\\include\\QtPrintSupport&quot;;&quot;$(QTDIR)\\include\\QtWidgets&quot;;&quot;$(QTDIR)\\..\\qtxmlpatterns\\include\\QtXmlPatterns&quot;;&quot;$(QTDIR)\\..\\qtxmlpatterns\\include&quot;\"\r\n\t\t\t\tPreprocessorDefinitions=\",UNICODE,WIN32,QT_NO_DEBUG,NDEBUG;QT_CORE_LIB;MCAPICODEGENERATOR_LIB;QT_XML_LIB;QT_XMLPATTERNS_LIB;QT_GUI_LIB;QT_DLL;QT_HELP_LIB;QT_PRINTSUPPORT_LIB;QT_WIDGETS_LIB\"\r\n\t\t\t\tRuntimeLibrary=\"2\"\r\n\t\t\t\tTreatWChar_tAsBuiltInType=\"false\"\r\n\t\t\t\tDebugInformationFormat=\"0\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCManagedResourceCompilerTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCResourceCompilerTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCPreLinkEventTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCLinkerTool\"\r\n\t\t\t\tAdditionalDependencies=\"qtmain.lib QtCore4.lib QtXml4.lib QtXmlPatterns4.lib QtGui4.lib Kactus2.lib Qt5Help.lib Qt5PrintSupport.lib Qt5Widgets.lib Qt5XmlPatterns.lib\"\r\n\t\t\t\tOutputFile=\"$(OutDir)\\$(ProjectName).dll\"\r\n\t\t\t\tAdditionalLibraryDirectories=\"&quot;..\\..\\x64\\executable&quot;;&quot;$(QTDIR)\\lib&quot;\"\r\n\t\t\t\tGenerateDebugInformation=\"false\"\r\n\t\t\t\tSubSystem=\"2\"\r\n\t\t\t\tTargetMachine=\"17\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCALinkTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCManifestTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCXDCMakeTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCBscMakeTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCFxCopTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCAppVerifierTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCPostBuildEventTool\"\r\n\t\t\t\tCommandLine=\"\"\r\n\t\t\t/>\r\n\t\t</Configuration>\r\n\t\t<Configuration\r\n\t\t\tName=\"Debug|Win32\"\r\n\t\t\tOutputDirectory=\"$(SolutionDir)\\executable\\Plugins\"\r\n\t\t\tIntermediateDirectory=\"$(SolutionDir)$(ConfigurationName)\"\r\n\t\t\tConfigurationType=\"2\"\r\n\t\t\t>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCPreBuildEventTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCCustomBuildTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCXMLDataGeneratorTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCWebServiceProxyGeneratorTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCMIDLTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCCLCompilerTool\"\r\n\t\t\t\tOptimization=\"0\"\r\n\t\t\t\tAdditionalIncludeDirectories=\"&quot;.\\GeneratedFiles&quot;;&quot;$(QTDIR)\\include&quot;;&quot;.\\GeneratedFiles\\$(ConfigurationName)&quot;;&quot;$(QTDIR)\\include\\qtmain&quot;;&quot;$(QTDIR)\\include\\QtCore&quot;;&quot;.\\&quot;;&quot;..\\..\\&quot;;&quot;$(QTDIR)\\include\\QtXml&quot;;&quot;$(QTDIR)\\include\\QtXmlPatterns&quot;;&quot;$(QTDIR)\\include\\QtGui&quot;;&quot;$(QTDIR)\\..\\qttools\\include&quot;;&quot;$(QTDIR)\\..\\qttools\\include\\QtHelp&quot;;&quot;$(QTDIR)\\include\\QtPrintSupport&quot;;&quot;$(QTDIR)\\include\\QtWidgets&quot;;&quot;$(QTDIR)\\..\\qtxmlpatterns\\include\\QtXmlPatterns&quot;;&quot;$(QTDIR)\\..\\qtxmlpatterns\\include&quot;\"\r\n\t\t\t\tPreprocessorDefinitions=\",UNICODE,WIN32,QT_CORE_LIB;MCAPICODEGENERATOR_LIB;QT_XML_LIB;QT_XMLPATTERNS_LIB;QT_GUI_LIB;QT_DLL;QT_HELP_LIB;QT_PRINTSUPPORT_LIB;QT_WIDGETS_LIB\"\r\n\t\t\t\tRuntimeLibrary=\"3\"\r\n\t\t\t\tTreatWChar_tAsBuiltInType=\"false\"\r\n\t\t\t\tDebugInformationFormat=\"3\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCManagedResourceCompilerTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCResourceCompilerTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCPreLinkEventTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCLinkerTool\"\r\n\t\t\t\tAdditionalDependencies=\"qtmaind.lib QtCored4.lib QtXmld4.lib QtXmlPatternsd4.lib QtGuid4.lib Kactus2_d.lib Qt5Helpd.lib Qt5PrintSupportd.lib Qt5Widgetsd.lib Qt5XmlPatternsd.lib\"\r\n\t\t\t\tOutputFile=\"$(OutDir)\\$(ProjectName).dll\"\r\n\t\t\t\tAdditionalLibraryDirectories=\"&quot;..\\..\\executable&quot;;&quot;$(QTDIR)\\lib&quot;\"\r\n\t\t\t\tGenerateDebugInformation=\"true\"\r\n\t\t\t\tSubSystem=\"2\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCALinkTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCManifestTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCXDCMakeTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCBscMakeTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCFxCopTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCAppVerifierTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCPostBuildEventTool\"\r\n\t\t\t\tCommandLine=\"\"\r\n\t\t\t/>\r\n\t\t</Configuration>\r\n\t\t<Configuration\r\n\t\t\tName=\"Debug|x64\"\r\n\t\t\tOutputDirectory=\"$(SolutionDir)\\x64\\executable\\Plugins\"\r\n\t\t\tIntermediateDirectory=\"$(PlatformName)\\$(ConfigurationName)\"\r\n\t\t\tConfigurationType=\"2\"\r\n\t\t\t>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCPreBuildEventTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCCustomBuildTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCXMLDataGeneratorTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCWebServiceProxyGeneratorTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCMIDLTool\"\r\n\t\t\t\tTargetEnvironment=\"3\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCCLCompilerTool\"\r\n\t\t\t\tOptimization=\"0\"\r\n\t\t\t\tAdditionalIncludeDirectories=\"&quot;.\\GeneratedFiles&quot;;&quot;$(QTDIR)\\include&quot;;&quot;.\\GeneratedFiles\\$(ConfigurationName)&quot;;&quot;$(QTDIR)\\include\\qtmain&quot;;&quot;$(QTDIR)\\include\\QtCore&quot;;&quot;.\\&quot;;&quot;..\\..\\&quot;;&quot;$(QTDIR)\\include\\QtXml&quot;;&quot;$(QTDIR)\\include\\QtXmlPatterns&quot;;&quot;$(QTDIR)\\include\\QtGui&quot;;&quot;$(QTDIR)\\..\\qttools\\include&quot;;&quot;$(QTDIR)\\..\\qttools\\include\\QtHelp&quot;;&quot;$(QTDIR)\\include\\QtPrintSupport&quot;;&quot;$(QTDIR)\\include\\QtWidgets&quot;;&quot;$(QTDIR)\\..\\qtxmlpatterns\\include\\QtXmlPatterns&quot;;&quot;$(QTDIR)\\..\\qtxmlpatterns\\include&quot;\"\r\n\t\t\t\tPreprocessorDefinitions=\",UNICODE,WIN32,QT_CORE_LIB;MCAPICODEGENERATOR_LIB;QT_XML_LIB;QT_XMLPATTERNS_LIB;QT_GUI_LIB;QT_DLL;QT_HELP_LIB;QT_PRINTSUPPORT_LIB;QT_WIDGETS_LIB\"\r\n\t\t\t\tRuntimeLibrary=\"3\"\r\n\t\t\t\tTreatWChar_tAsBuiltInType=\"false\"\r\n\t\t\t\tDebugInformationFormat=\"3\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCManagedResourceCompilerTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCResourceCompilerTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCPreLinkEventTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCLinkerTool\"\r\n\t\t\t\tAdditionalDependencies=\"qtmaind.lib QtCored4.lib QtXmld4.lib QtXmlPatternsd4.lib QtGuid4.lib Kactus2_d.lib Qt5Helpd.lib Qt5PrintSupportd.lib Qt5Widgetsd.lib Qt5XmlPatternsd.lib\"\r\n\t\t\t\tOutputFile=\"$(OutDir)\\$(ProjectName).dll\"\r\n\t\t\t\tAdditionalLibraryDirectories=\"&quot;..\\..\\x64\\executable&quot;;&quot;$(QTDIR)\\lib&quot;\"\r\n\t\t\t\tGenerateDebugInformation=\"true\"\r\n\t\t\t\tSubSystem=\"2\"\r\n\t\t\t\tTargetMachine=\"17\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCALinkTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCManifestTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCXDCMakeTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCBscMakeTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCFxCopTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCAppVerifierTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCPostBuildEventTool\"\r\n\t\t\t\tCommandLine=\"\"\r\n\t\t\t/>\r\n\t\t</Configuration>\r\n\t</Configurations>\r\n\t<References>\r\n\t</References>\r\n\t<Files>\r\n\t\t<Filter\r\n\t\t\tName=\"Source Files\"\r\n\t\t\tFilter=\"cpp;cxx;c;def\"\r\n\t\t\tUniqueIdentifier=\"{4FC737F1-C7A5-4376-A066-2A32D752A2FF}\"\r\n\t\t\t>\r\n\t\t\t<File\r\n\t\t\t\tRelativePath=\".\\MCAPICodeGenerator.cpp\"\r\n\t\t\t\t>\r\n\t\t\t</File>\r\n\t\t</Filter>\r\n\t\t<Filter\r\n\t\t\tName=\"Header Files\"\r\n\t\t\tFilter=\"h\"\r\n\t\t\tUniqueIdentifier=\"{93995380-89BD-4b04-88EB-625FBE52EBFB}\"\r\n\t\t\t>\r\n\t\t\t<File\r\n\t\t\t\tRelativePath=\".\\MCAPICodeGenerator.h\"\r\n\t\t\t\t>\r\n\t\t\t\t<FileConfiguration\r\n\t\t\t\t\tName=\"Release|Win32\"\r\n\t\t\t\t\t>\r\n\t\t\t\t\t<Tool\r\n\t\t\t\t\t\tName=\"VCCustomBuildTool\"\r\n\t\t\t\t\t\tDescription=\"Moc&apos;ing $(InputFileName)...\"\r\n\t\t\t\t\t\tCommandLine=\"&quot;$(QTDIR)\\bin\\moc.exe&quot;  &quot;$(InputPath)&quot; -o &quot;.\\GeneratedFiles\\$(ConfigurationName)\\moc_$(InputName).cpp&quot;  -DUNICODE -DWIN32 -DQT_NO_DEBUG -DNDEBUG -DQT_CORE_LIB -DMCAPICODEGENERATOR_LIB -DQT_XML_LIB -DQT_XMLPATTERNS_LIB -DQT_GUI_LIB -DQT_DLL -DQT_HELP_LIB -DQT_PRINTSUPPORT_LIB -DQT_WIDGETS_LIB -D_WINDLL  &quot;-I.\\GeneratedFiles&quot; &quot;-I$(QTDIR)\\include&quot; &quot;-I.\\GeneratedFiles\\$(ConfigurationName)\\.&quot; &quot;-I$(QTDIR)\\include\\qtmain&quot; &quot;-I$(QTDIR)\\include\\QtCore&quot; &quot;-I.&quot; &quot;-I.\\..\\..&quot; &quot;-I$(QTDIR)\\include\\QtXml&quot; &quot;-I$(QTDIR)\\include\\QtXmlPatterns&quot; &quot;-I$(QTDIR)\\include\\QtGui&quot; &quot;-I$(QTDIR)\\..\\qttools\\include&quot; &quot;-I$(QTDIR)\\..\\qttools\\include\\QtHelp&quot; &quot;-I$(QTDIR)\\include\\QtPrintSupport&quot; &quot;-I$(QTDIR)\\include\\QtWidgets&quot; &quot;-I$(QTDIR)\\..\\qtxmlpatterns\\include\\QtXmlPatterns&quot; &quot;-I$(QTDIR)\\..\\qtxmlpatterns\\include&quot;&#x0D;&#x0A;\"\r\n\t\t\t\t\t\tAdditionalDependencies=\"&quot;$(QTDIR)\\bin\\moc.exe&quot;;$(InputPath)\"\r\n\t\t\t\t\t\tOutputs=\"&quot;.\\GeneratedFiles\\$(ConfigurationName)\\moc_McapiCodeGenerator.cpp&quot;\"\r\n\t\t\t\t\t/>\r\n\t\t\t\t</FileConfiguration>\r\n\t\t\t\t<FileConfiguration\r\n\t\t\t\t\tName=\"Release|x64\"\r\n\t\t\t\t\t>\r\n\t\t\t\t\t<Tool\r\n\t\t\t\t\t\tName=\"VCCustomBuildTool\"\r\n\t\t\t\t\t\tDescription=\"Moc&apos;ing $(InputFileName)...\"\r\n\t\t\t\t\t\tCommandLine=\"&quot;$(QTDIR)\\bin\\moc.exe&quot;  &quot;$(InputPath)&quot; -o &quot;.\\GeneratedFiles\\$(ConfigurationName)\\moc_$(InputName).cpp&quot;  -DUNICODE -DWIN32 -DQT_NO_DEBUG -DNDEBUG -DQT_CORE_LIB -DMCAPICODEGENERATOR_LIB -DQT_XML_LIB -DQT_XMLPATTERNS_LIB -DQT_GUI_LIB -DQT_DLL -DQT_HELP_LIB -DQT_PRINTSUPPORT_LIB -DQT_WIDGETS_LIB -D_WINDLL  &quot;-I.\\GeneratedFiles&quot; &quot;-I$(QTDIR)\\include&quot; &quot;-I.\\GeneratedFiles\\$(ConfigurationName)\\.&quot; &quot;-I$(QTDIR)\\include\\qtmain&quot; &quot;-I$(QTDIR)\\include\\QtCore&quot; &quot;-I.&quot; &quot;-I.\\..\\..&quot; &quot;-I$(QTDIR)\\include\\QtXml&quot; &quot;-I$(QTDIR)\\include\\QtXmlPatterns&quot; &quot;-I$(QTDIR)\\include\\QtGui&quot; &quot;-I$(QTDIR)\\..\\qttools\\include&quot; &quot;-I$(QTDIR)\\..\\qttools\\include\\QtHelp&quot; &quot;-I$(QTDIR)\\include\\QtPrintSupport&quot; &quot;-I$(QTDIR)\\include\\QtWidgets&quot; &quot;-I$(QTDIR)\\..\\qtxmlpatterns\\include\\QtXmlPatterns&quot; &quot;-I$(QTDIR)\\..\\qtxmlpatterns\\include&quot;&#x0D;&#x0A;\"\r\n\t\t\t\t\t\tAdditionalDependencies=\"&quot;$(QTDIR)\\bin\\moc.exe&quot;;$(InputPath)\"\r\n\t\t\t\t\t\tOutputs=\"&quot;.\\GeneratedFiles\\$(ConfigurationName)\\moc_McapiCodeGenerator.cpp&quot;\"\r\n\t\t\t\t\t/>\r\n\t\t\t\t</FileConfiguration>\r\n\t\t\t\t<FileConfiguration\r\n\t\t\t\t\tName=\"Debug|Win32\"\r\n\t\t\t\t\t>\r\n\t\t\t\t\t<Tool\r\n\t\t\t\t\t\tName=\"VCCustomBuildTool\"\r\n\t\t\t\t\t\tDescription=\"Moc&apos;ing $(InputFileName)...\"\r\n\t\t\t\t\t\tCommandLine=\"&quot;$(QTDIR)\\bin\\moc.exe&quot;  &quot;$(InputPath)&quot; -o &quot;.\\GeneratedFiles\\$(ConfigurationName)\\moc_$(InputName).cpp&quot;  -DUNICODE -DWIN32 -DQT_CORE_LIB -DMCAPICODEGENERATOR_LIB -DQT_XML_LIB -DQT_XMLPATTERNS_LIB -DQT_GUI_LIB -DQT_DLL -DQT_HELP_LIB -DQT_PRINTSUPPORT_LIB -DQT_WIDGETS_LIB -D_WINDLL  &quot;-I.\\GeneratedFiles&quot; &quot;-I$(QTDIR)\\include&quot; &quot;-I.\\GeneratedFiles\\$(ConfigurationName)\\.&quot; &quot;-I$(QTDIR)\\include\\qtmain&quot; &quot;-I$(QTDIR)\\include\\QtCore&quot; &quot;-I.&quot; &quot;-I.\\..\\..&quot; &quot;-I$(QTDIR)\\include\\QtXml&quot; &quot;-I$(QTDIR)\\include\\QtXmlPatterns&quot; &quot;-I$(QTDIR)\\include\\QtGui&quot; &quot;-I$(QTDIR)\\..\\qttools\\include&quot; &quot;-I$(QTDIR)\\..\\qttools\\include\\QtHelp&quot; &quot;-I$(QTDIR)\\include\\QtPrintSupport&quot; &quot;-I$(QTDIR)\\include\\QtWidgets&quot; &quot;-I$(QTDIR)\\..\\qtxmlpatterns\\include\\QtXmlPatterns&quot; &quot;-I$(QTDIR)\\..\\qtxmlpatterns\\include&quot;&#x0D;&#x0A;\"\r\n\t\t\t\t\t\tAdditionalDependencies=\"&quot;$(QTDIR)\\bin\\moc.exe&quot;;$(InputPath)\"\r\n\t\t\t\t\t\tOutputs=\"&quot;.\\GeneratedFiles\\$(ConfigurationName)\\moc_McapiCodeGenerator.cpp&quot;\"\r\n\t\t\t\t\t/>\r\n\t\t\t\t</FileConfiguration>\r\n\t\t\t\t<FileConfiguration\r\n\t\t\t\t\tName=\"Debug|x64\"\r\n\t\t\t\t\t>\r\n\t\t\t\t\t<Tool\r\n\t\t\t\t\t\tName=\"VCCustomBuildTool\"\r\n\t\t\t\t\t\tDescription=\"Moc&apos;ing $(InputFileName)...\"\r\n\t\t\t\t\t\tCommandLine=\"&quot;$(QTDIR)\\bin\\moc.exe&quot;  &quot;$(InputPath)&quot; -o &quot;.\\GeneratedFiles\\$(ConfigurationName)\\moc_$(InputName).cpp&quot;  -DUNICODE -DWIN32 -DQT_CORE_LIB -DMCAPICODEGENERATOR_LIB -DQT_XML_LIB -DQT_XMLPATTERNS_LIB -DQT_GUI_LIB -DQT_DLL -DQT_HELP_LIB -DQT_PRINTSUPPORT_LIB -DQT_WIDGETS_LIB -D_WINDLL  &quot;-I.\\GeneratedFiles&quot; &quot;-I$(QTDIR)\\include&quot; &quot;-I.\\GeneratedFiles\\$(ConfigurationName)\\.&quot; &quot;-I$(QTDIR)\\include\\qtmain&quot; &quot;-I$(QTDIR)\\include\\QtCore&quot; &quot;-I.&quot; &quot;-I.\\..\\..&quot; &quot;-I$(QTDIR)\\include\\QtXml&quot; &quot;-I$(QTDIR)\\include\\QtXmlPatterns&quot; &quot;-I$(QTDIR)\\include\\QtGui&quot; &quot;-I$(QTDIR)\\..\\qttools\\include&quot; &quot;-I$(QTDIR)\\..\\qttools\\include\\QtHelp&quot; &quot;-I$(QTDIR)\\include\\QtPrintSupport&quot; &quot;-I$(QTDIR)\\include\\QtWidgets&quot; &quot;-I$(QTDIR)\\..\\qtxmlpatterns\\include\\QtXmlPatterns&quot; &quot;-I$(QTDIR)\\..\\qtxmlpatterns\\include&quot;&#x0D;&#x0A;\"\r\n\t\t\t\t\t\tAdditionalDependencies=\"&quot;$(QTDIR)\\bin\\moc.exe&quot;;$(InputPath)\"\r\n\t\t\t\t\t\tOutputs=\"&quot;.\\GeneratedFiles\\$(ConfigurationName)\\moc_McapiCodeGenerator.cpp&quot;\"\r\n\t\t\t\t\t/>\r\n\t\t\t\t</FileConfiguration>\r\n\t\t\t</File>\r\n\t\t</Filter>\r\n\t\t<Filter\r\n\t\t\tName=\"Form Files\"\r\n\t\t\tFilter=\"ui\"\r\n\t\t\tUniqueIdentifier=\"{99349809-55BA-4b9d-BF79-8FDBB0286EB3}\"\r\n\t\t\t>\r\n\t\t</Filter>\r\n\t\t<Filter\r\n\t\t\tName=\"Resource Files\"\r\n\t\t\tFilter=\"qrc;*\"\r\n\t\t\tUniqueIdentifier=\"{D9D6E242-F8AF-46E4-B9FD-80ECBC20BA3E}\"\r\n\t\t\tParseFiles=\"false\"\r\n\t\t\t>\r\n\t\t</Filter>\r\n\t\t<Filter\r\n\t\t\tName=\"Generated Files\"\r\n\t\t\tFilter=\"moc;h;cpp\"\r\n\t\t\tUniqueIdentifier=\"{71ED8ED8-ACB9-4CE9-BBE1-E00B30144E11}\"\r\n\t\t\tSourceControlFiles=\"false\"\r\n\t\t\t>\r\n\t\t\t<Filter\r\n\t\t\t\tName=\"Release\"\r\n\t\t\t\tFilter=\"cpp;moc\"\r\n\t\t\t\tSourceControlFiles=\"false\"\r\n\t\t\t\t>\r\n\t\t\t\t<File\r\n\t\t\t\t\tRelativePath=\".\\GeneratedFiles\\Release\\moc_McapiCodeGenerator.cpp\"\r\n\t\t\t\t\t>\r\n\t\t\t\t\t<FileConfiguration\r\n\t\t\t\t\t\tName=\"Debug|Win32\"\r\n\t\t\t\t\t\tExcludedFromBuild=\"true\"\r\n\t\t\t\t\t\t>\r\n\t\t\t\t\t\t<Tool\r\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\r\n\t\t\t\t\t\t/>\r\n\t\t\t\t\t</FileConfiguration>\r\n\t\t\t\t\t<FileConfiguration\r\n\t\t\t\t\t\tName=\"Debug|x64\"\r\n\t\t\t\t\t\tExcludedFromBuild=\"true\"\r\n\t\t\t\t\t\t>\r\n\t\t\t\t\t\t<Tool\r\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\r\n\t\t\t\t\t\t/>\r\n\t\t\t\t\t</FileConfiguration>\r\n\t\t\t\t</File>\r\n\t\t\t</Filter>\r\n\t\t\t<Filter\r\n\t\t\t\tName=\"Debug\"\r\n\t\t\t\tFilter=\"cpp;moc\"\r\n\t\t\t\tSourceControlFiles=\"false\"\r\n\t\t\t\t>\r\n\t\t\t\t<File\r\n\t\t\t\t\tRelativePath=\".\\GeneratedFiles\\Debug\\moc_McapiCodeGenerator.cpp\"\r\n\t\t\t\t\t>\r\n\t\t\t\t\t<FileConfiguration\r\n\t\t\t\t\t\tName=\"Release|Win32\"\r\n\t\t\t\t\t\tExcludedFromBuild=\"true\"\r\n\t\t\t\t\t\t>\r\n\t\t\t\t\t\t<Tool\r\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\r\n\t\t\t\t\t\t/>\r\n\t\t\t\t\t</FileConfiguration>\r\n\t\t\t\t\t<FileConfiguration\r\n\t\t\t\t\t\tName=\"Release|x64\"\r\n\t\t\t\t\t\tExcludedFromBuild=\"true\"\r\n\t\t\t\t\t\t>\r\n\t\t\t\t\t\t<Tool\r\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\r\n\t\t\t\t\t\t/>\r\n\t\t\t\t\t</FileConfiguration>\r\n\t\t\t\t</File>\r\n\t\t\t</Filter>\r\n\t\t</Filter>\r\n\t</Files>\r\n\t<Globals>\r\n\t\t<Global\r\n\t\t\tName=\"lreleaseOptions\"\r\n\t\t\tValue=\"\"\r\n\t\t/>\r\n\t\t<Global\r\n\t\t\tName=\"lupdateOnBuild\"\r\n\t\t\tValue=\"0\"\r\n\t\t/>\r\n\t\t<Global\r\n\t\t\tName=\"lupdateOptions\"\r\n\t\t\tValue=\"\"\r\n\t\t/>\r\n\t\t<Global\r\n\t\t\tName=\"MocDir\"\r\n\t\t\tValue=\".\\GeneratedFiles\\$(ConfigurationName)\"\r\n\t\t/>\r\n\t\t<Global\r\n\t\t\tName=\"MocOptions\"\r\n\t\t\tValue=\"\"\r\n\t\t/>\r\n\t\t<Global\r\n\t\t\tName=\"Qt5Version Win32\"\r\n\t\t\tValue=\"5.0.0 VS2010\"\r\n\t\t/>\r\n\t\t<Global\r\n\t\t\tName=\"QtVersion Win32\"\r\n\t\t\tValue=\"4.8.3\"\r\n\t\t/>\r\n\t\t<Global\r\n\t\t\tName=\"QtVersion x64\"\r\n\t\t\tValue=\"4.8.3 x64\"\r\n\t\t/>\r\n\t\t<Global\r\n\t\t\tName=\"RccDir\"\r\n\t\t\tValue=\".\\GeneratedFiles\"\r\n\t\t/>\r\n\t\t<Global\r\n\t\t\tName=\"UicDir\"\r\n\t\t\tValue=\".\\GeneratedFiles\"\r\n\t\t/>\r\n\t</Globals>\r\n</VisualStudioProject>\r\n"
  },
  {
    "path": "Plugins/MCAPICodeGenerator/MCAPICodeGenerator.vcxproj",
    "content": "﻿<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n<Project DefaultTargets=\"Build\" ToolsVersion=\"15.0\" xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">\r\n  <ItemGroup Label=\"ProjectConfigurations\">\r\n    <ProjectConfiguration Include=\"Debug|x64\">\r\n      <Configuration>Debug</Configuration>\r\n      <Platform>x64</Platform>\r\n    </ProjectConfiguration>\r\n    <ProjectConfiguration Include=\"Release|x64\">\r\n      <Configuration>Release</Configuration>\r\n      <Platform>x64</Platform>\r\n    </ProjectConfiguration>\r\n    <ProjectConfiguration Include=\"Template|x64\">\r\n      <Configuration>Template</Configuration>\r\n      <Platform>x64</Platform>\r\n    </ProjectConfiguration>\r\n  </ItemGroup>\r\n  <PropertyGroup Label=\"Globals\">\r\n    <ProjectGuid>{AA63BE2D-A701-4C68-9760-C71655FFE66D}</ProjectGuid>\r\n    <Keyword>QtVS_v304</Keyword>\r\n    <WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>\r\n    <QtMsBuild Condition=\"'$(QtMsBuild)'=='' or !Exists('$(QtMsBuild)\\qt.targets')\">$(MSBuildProjectDirectory)\\QtMsBuild</QtMsBuild>\r\n  </PropertyGroup>\r\n  <Import Project=\"$(VCTargetsPath)\\Microsoft.Cpp.Default.props\" />\r\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Template|x64'\" Label=\"Configuration\">\r\n    <ConfigurationType>Application</ConfigurationType>\r\n    <PlatformToolset>v143</PlatformToolset>\r\n  </PropertyGroup>\r\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\" Label=\"Configuration\">\r\n    <ConfigurationType>DynamicLibrary</ConfigurationType>\r\n    <PlatformToolset>v143</PlatformToolset>\r\n  </PropertyGroup>\r\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\" Label=\"Configuration\">\r\n    <ConfigurationType>DynamicLibrary</ConfigurationType>\r\n    <PlatformToolset>v143</PlatformToolset>\r\n  </PropertyGroup>\r\n  <Import Project=\"$(VCTargetsPath)\\Microsoft.Cpp.props\" />\r\n  <Target Name=\"QtMsBuildNotFound\" BeforeTargets=\"CustomBuild;ClCompile\" Condition=\"!Exists('$(QtMsBuild)\\qt.targets') or !Exists('$(QtMsBuild)\\qt.props')\">\r\n    <Message Importance=\"High\" Text=\"QtMsBuild: could not locate qt.targets, qt.props; project may not build correctly.\" />\r\n  </Target>\r\n  <ImportGroup Label=\"ExtensionSettings\">\r\n  </ImportGroup>\r\n  <ImportGroup Condition=\"'$(Configuration)|$(Platform)'=='Template|x64'\" Label=\"PropertySheets\">\r\n    <Import Project=\"$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props\" Condition=\"exists('$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props')\" Label=\"LocalAppDataPlatform\" />\r\n  </ImportGroup>\r\n  <ImportGroup Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\" Label=\"PropertySheets\">\r\n    <Import Project=\"$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props\" Condition=\"exists('$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props')\" Label=\"LocalAppDataPlatform\" />\r\n  </ImportGroup>\r\n  <ImportGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\" Label=\"PropertySheets\">\r\n    <Import Project=\"$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props\" Condition=\"exists('$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props')\" Label=\"LocalAppDataPlatform\" />\r\n  </ImportGroup>\r\n  <PropertyGroup Label=\"UserMacros\" />\r\n  <ImportGroup Condition=\"Exists('$(QtMsBuild)\\qt_defaults.props')\">\r\n    <Import Project=\"$(QtMsBuild)\\qt_defaults.props\" />\r\n  </ImportGroup>\r\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Template|x64'\">\r\n    <OutDir>$(SolutionDir)executable\\Plugins\\</OutDir>\r\n  </PropertyGroup>\r\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n    <OutDir>$(SolutionDir)executable\\Plugins\\</OutDir>\r\n    <IntDir>$(ProjectDir)\\$(Configuration)\\</IntDir>\r\n  </PropertyGroup>\r\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n    <OutDir>$(SolutionDir)executable\\Plugins\\</OutDir>\r\n    <IntDir>$(ProjectDir)\\$(Configuration)\\</IntDir>\r\n  </PropertyGroup>\r\n  <PropertyGroup Label=\"QtSettings\" Condition=\"'$(Configuration)|$(Platform)'=='Template|x64'\">\r\n    <QtInstall>6.2.4</QtInstall>\r\n    <QtModules>core;gui;widgets;help;printsupport;xml</QtModules>\r\n  </PropertyGroup>\r\n  <PropertyGroup Label=\"QtSettings\" Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n    <QtInstall>6.2.4</QtInstall>\r\n    <QtModules>core;gui;widgets;help;printsupport;xml</QtModules>\r\n  </PropertyGroup>\r\n  <PropertyGroup Label=\"QtSettings\" Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n    <QtInstall>6.2.4</QtInstall>\r\n    <QtModules>core;gui;widgets;help;printsupport;xml</QtModules>\r\n  </PropertyGroup>\r\n  <ImportGroup Condition=\"Exists('$(QtMsBuild)\\qt.props')\">\r\n    <Import Project=\"$(QtMsBuild)\\qt.props\" />\r\n  </ImportGroup>\r\n  <PropertyGroup>\r\n    <_ProjectFileVersion>10.0.40219.1</_ProjectFileVersion>\r\n  </PropertyGroup>\r\n  <ItemDefinitionGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n    <Midl>\r\n      <TargetEnvironment>X64</TargetEnvironment>\r\n    </Midl>\r\n    <ClCompile>\r\n      <AdditionalIncludeDirectories>.\\GeneratedFiles\\$(ConfigurationName);.\\GeneratedFiles;.\\GeneratedFiles\\$(Configuration);.\\;..\\..\\;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\r\n      <PreprocessorDefinitions>UNICODE;WIN32;QT_NO_DEBUG;NDEBUG;MCAPICODEGENERATOR_LIB;QT_XMLPATTERNS_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>\r\n      <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>\r\n      <TreatWChar_tAsBuiltInType>true</TreatWChar_tAsBuiltInType>\r\n      <DebugInformationFormat>\r\n      </DebugInformationFormat>\r\n      <MultiProcessorCompilation>true</MultiProcessorCompilation>\r\n      <AdditionalOptions>/Zc:__cplusplus %(AdditionalOptions)</AdditionalOptions>\r\n      <LanguageStandard>stdcpp17</LanguageStandard>\r\n    </ClCompile>\r\n    <Link>\r\n      <AdditionalDependencies>IPXACTmodels.lib;%(AdditionalDependencies)</AdditionalDependencies>\r\n      <OutputFile>$(OutDir)$(ProjectName).dll</OutputFile>\r\n      <AdditionalLibraryDirectories>..\\..\\executable;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>\r\n      <GenerateDebugInformation>false</GenerateDebugInformation>\r\n      <SubSystem>Windows</SubSystem>\r\n      <TargetMachine>MachineX64</TargetMachine>\r\n    </Link>\r\n    <PostBuildEvent>\r\n      <Command>\r\n      </Command>\r\n    </PostBuildEvent>\r\n    <QtMoc>\r\n      <ExecutionDescription>Moc'ing %(Identity)...</ExecutionDescription>\r\n      <DynamicSource>output</DynamicSource>\r\n      <QtMocDir>.\\GeneratedFiles\\$(ConfigurationName)</QtMocDir>\r\n      <QtMocFileName>moc_%(Filename).cpp</QtMocFileName>\r\n    </QtMoc>\r\n    <QtRcc>\r\n      <InitFuncName>%(Filename)</InitFuncName>\r\n      <Compression>default</Compression>\r\n      <NoCompression>true</NoCompression>\r\n      <ExecutionDescription>Rcc'ing %(Identity)...</ExecutionDescription>\r\n      <QtRccDir>.\\GeneratedFiles</QtRccDir>\r\n      <QtRccFileName>qrc_%(Filename).cpp</QtRccFileName>\r\n    </QtRcc>\r\n  </ItemDefinitionGroup>\r\n  <ItemDefinitionGroup Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n    <Midl>\r\n      <TargetEnvironment>X64</TargetEnvironment>\r\n    </Midl>\r\n    <ClCompile>\r\n      <Optimization>Disabled</Optimization>\r\n      <AdditionalIncludeDirectories>.\\GeneratedFiles\\$(ConfigurationName);.\\GeneratedFiles;.\\GeneratedFiles\\$(Configuration);.\\;..\\..\\;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\r\n      <PreprocessorDefinitions>UNICODE;WIN32;MCAPICODEGENERATOR_LIB;QT_XMLPATTERNS_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>\r\n      <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>\r\n      <TreatWChar_tAsBuiltInType>true</TreatWChar_tAsBuiltInType>\r\n      <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>\r\n      <LanguageStandard>stdcpp17</LanguageStandard>\r\n      <AdditionalOptions>/Zc:__cplusplus %(AdditionalOptions)</AdditionalOptions>\r\n      <MultiProcessorCompilation>true</MultiProcessorCompilation>\r\n    </ClCompile>\r\n    <Link>\r\n      <AdditionalDependencies>IPXACTmodelsd.lib;%(AdditionalDependencies)</AdditionalDependencies>\r\n      <OutputFile>$(OutDir)$(ProjectName).dll</OutputFile>\r\n      <AdditionalLibraryDirectories>..\\..\\executable;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>\r\n      <GenerateDebugInformation>true</GenerateDebugInformation>\r\n      <SubSystem>Windows</SubSystem>\r\n      <TargetMachine>MachineX64</TargetMachine>\r\n    </Link>\r\n    <PostBuildEvent>\r\n      <Command>\r\n      </Command>\r\n    </PostBuildEvent>\r\n    <QtMoc>\r\n      <ExecutionDescription>Moc'ing %(Identity)...</ExecutionDescription>\r\n      <DynamicSource>output</DynamicSource>\r\n      <QtMocDir>.\\GeneratedFiles\\$(ConfigurationName)</QtMocDir>\r\n      <QtMocFileName>moc_%(Filename).cpp</QtMocFileName>\r\n    </QtMoc>\r\n    <QtRcc>\r\n      <InitFuncName>%(Filename)</InitFuncName>\r\n      <Compression>default</Compression>\r\n      <NoCompression>true</NoCompression>\r\n      <ExecutionDescription>Rcc'ing %(Identity)...</ExecutionDescription>\r\n      <QtRccDir>.\\GeneratedFiles</QtRccDir>\r\n      <QtRccFileName>qrc_%(Filename).cpp</QtRccFileName>\r\n    </QtRcc>\r\n  </ItemDefinitionGroup>\r\n  <ItemDefinitionGroup Condition=\"'$(Configuration)|$(Platform)'=='Template|x64'\">\r\n    <Link>\r\n      <AdditionalDependencies>Qt5XmlPatterns.lib;%(AdditionalDependencies)</AdditionalDependencies>\r\n      <AdditionalLibraryDirectories>..\\..\\executable;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>\r\n    </Link>\r\n    <ClCompile>\r\n      <PreprocessorDefinitions>QT_XMLPATTERNS_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>\r\n      <AdditionalIncludeDirectories>.\\GeneratedFiles\\$(ConfigurationName);.\\GeneratedFiles;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\r\n      <MultiProcessorCompilation>true</MultiProcessorCompilation>\r\n    </ClCompile>\r\n    <QtMoc>\r\n      <ExecutionDescription>Moc'ing %(Identity)...</ExecutionDescription>\r\n      <DynamicSource>output</DynamicSource>\r\n      <QtMocDir>.\\GeneratedFiles\\$(ConfigurationName)</QtMocDir>\r\n      <QtMocFileName>moc_%(Filename).cpp</QtMocFileName>\r\n    </QtMoc>\r\n    <QtRcc>\r\n      <InitFuncName>%(Filename)</InitFuncName>\r\n      <Compression>default</Compression>\r\n      <NoCompression>true</NoCompression>\r\n      <ExecutionDescription>Rcc'ing %(Identity)...</ExecutionDescription>\r\n      <QtRccDir>.\\GeneratedFiles</QtRccDir>\r\n      <QtRccFileName>qrc_%(Filename).cpp</QtRccFileName>\r\n    </QtRcc>\r\n  </ItemDefinitionGroup>\r\n  <ItemGroup>\r\n    <ClCompile Include=\"..\\..\\common\\dialogs\\comboSelector\\comboselector.cpp\" />\r\n    <ClCompile Include=\"..\\..\\common\\NameGenerationPolicy.cpp\" />\r\n    <ClCompile Include=\"..\\common\\CSourceWriter.cpp\" />\r\n    <ClCompile Include=\"MCAPICodeGenerator.cpp\" />\r\n    <ClCompile Include=\"MCAPICodeGeneratorPlugin.cpp\" />\r\n    <ClCompile Include=\"MCAPIHeaderGenerator.cpp\" />\r\n    <ClCompile Include=\"MCAPIParser.cpp\" />\r\n  </ItemGroup>\r\n  <ItemGroup>\r\n    <CustomBuild Include=\"MCAPICodeGenerator.h\">\r\n      <Message Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n      </Message>\r\n      <Command Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n      </Command>\r\n      <AdditionalInputs Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">%(AdditionalInputs)</AdditionalInputs>\r\n      <Outputs Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">%(Outputs)</Outputs>\r\n      <Message Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n      </Message>\r\n      <Command Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n      </Command>\r\n      <AdditionalInputs Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">%(AdditionalInputs)</AdditionalInputs>\r\n      <Outputs Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">%(Outputs)</Outputs>\r\n      <AdditionalInputs Condition=\"'$(Configuration)|$(Platform)'=='Template|x64'\">%(AdditionalInputs)</AdditionalInputs>\r\n      <Message Condition=\"'$(Configuration)|$(Platform)'=='Template|x64'\">Performing Custom Build Tools</Message>\r\n      <Outputs Condition=\"'$(Configuration)|$(Platform)'=='Template|x64'\">\r\n      </Outputs>\r\n    </CustomBuild>\r\n  </ItemGroup>\r\n  <ItemGroup>\r\n    <None Include=\"mcapi.json\" />\r\n    <QtRcc Include=\"MCAPICodeGenerator.qrc\">\r\n    </QtRcc>\r\n    <None Include=\"McapiGenerator.png\">\r\n      <ExcludedFromBuild Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">true</ExcludedFromBuild>\r\n      <ExcludedFromBuild Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">true</ExcludedFromBuild>\r\n      <ExcludedFromBuild Condition=\"'$(Configuration)|$(Platform)'=='Template|x64'\">true</ExcludedFromBuild>\r\n    </None>\r\n  </ItemGroup>\r\n  <ItemGroup>\r\n    <QtMoc Include=\"..\\..\\common\\dialogs\\comboSelector\\comboselector.h\">\r\n    </QtMoc>\r\n    <ClInclude Include=\"..\\..\\common\\NameGenerationPolicy.h\" />\r\n    <ClInclude Include=\"..\\common\\CSourceWriter.h\" />\r\n    <ClInclude Include=\"MCAPIHeaderGenerator.h\" />\r\n    <ClInclude Include=\"MCAPIParser.h\" />\r\n    <QtMoc Include=\"MCAPICodeGeneratorPlugin.h\">\r\n    </QtMoc>\r\n  </ItemGroup>\r\n  <Import Project=\"$(VCTargetsPath)\\Microsoft.Cpp.targets\" />\r\n  <ImportGroup Condition=\"Exists('$(QtMsBuild)\\qt.targets')\">\r\n    <Import Project=\"$(QtMsBuild)\\qt.targets\" />\r\n  </ImportGroup>\r\n  <ImportGroup Label=\"ExtensionTargets\">\r\n  </ImportGroup>\r\n  <ProjectExtensions>\r\n    <VisualStudio>\r\n      <UserProperties QtVersion_x0020_Win32=\"4.8.3\" QtVersion_x0020_x64=\"4.8.3 x64\" />\r\n    </VisualStudio>\r\n  </ProjectExtensions>\r\n</Project>"
  },
  {
    "path": "Plugins/MCAPICodeGenerator/MCAPICodeGenerator.vcxproj.filters",
    "content": "﻿<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n<Project ToolsVersion=\"4.0\" xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">\r\n  <ItemGroup>\r\n    <Filter Include=\"Source Files\">\r\n      <UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>\r\n      <Extensions>cpp;cxx;c;def</Extensions>\r\n    </Filter>\r\n    <Filter Include=\"Header Files\">\r\n      <UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>\r\n      <Extensions>h</Extensions>\r\n    </Filter>\r\n    <Filter Include=\"Resource Files\">\r\n      <UniqueIdentifier>{D9D6E242-F8AF-46E4-B9FD-80ECBC20BA3E}</UniqueIdentifier>\r\n      <Extensions>qrc;*</Extensions>\r\n      <ParseFiles>false</ParseFiles>\r\n    </Filter>\r\n    <Filter Include=\"Generated Files\">\r\n      <UniqueIdentifier>{71ED8ED8-ACB9-4CE9-BBE1-E00B30144E11}</UniqueIdentifier>\r\n      <Extensions>moc;h;cpp</Extensions>\r\n      <SourceControlFiles>False</SourceControlFiles>\r\n    </Filter>\r\n    <Filter Include=\"Generated Files\\Release\">\r\n      <UniqueIdentifier>{31125f37-277c-4b96-85de-0827af96c4f8}</UniqueIdentifier>\r\n      <Extensions>cpp;moc</Extensions>\r\n      <SourceControlFiles>False</SourceControlFiles>\r\n    </Filter>\r\n    <Filter Include=\"Generated Files\\Debug\">\r\n      <UniqueIdentifier>{471fac65-b7ff-414d-b828-22d7444fee4b}</UniqueIdentifier>\r\n      <Extensions>cpp;moc</Extensions>\r\n      <SourceControlFiles>False</SourceControlFiles>\r\n    </Filter>\r\n    <Filter Include=\"Generated Files\\Template\">\r\n      <UniqueIdentifier>{4b3ed3c7-312a-468c-9438-e86eafb40c9d}</UniqueIdentifier>\r\n      <Extensions>cpp;moc</Extensions>\r\n      <SourceControlFiles>False</SourceControlFiles>\r\n    </Filter>\r\n  </ItemGroup>\r\n  <ItemGroup>\r\n    <ClCompile Include=\"MCAPICodeGenerator.cpp\">\r\n      <Filter>Source Files</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"MCAPICodeGeneratorPlugin.cpp\">\r\n      <Filter>Source Files</Filter>\r\n    </ClCompile>\r\n    \r\n    \r\n    \r\n    <ClCompile Include=\"MCAPIParser.cpp\">\r\n      <Filter>Source Files</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"MCAPIHeaderGenerator.cpp\">\r\n      <Filter>Source Files</Filter>\r\n    </ClCompile>\r\n    \r\n    <ClCompile Include=\"..\\common\\CSourceWriter.cpp\">\r\n      <Filter>Source Files</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\common\\NameGenerationPolicy.cpp\">\r\n      <Filter>Source Files</Filter>\r\n    </ClCompile>\r\n    \r\n    \r\n    \r\n    <ClCompile Include=\"..\\..\\common\\dialogs\\comboSelector\\comboselector.cpp\">\r\n      <Filter>Source Files</Filter>\r\n    </ClCompile>\r\n  </ItemGroup>\r\n  <ItemGroup>\r\n    <CustomBuild Include=\"MCAPICodeGenerator.h\">\r\n      <Filter>Header Files</Filter>\r\n    </CustomBuild>\r\n    <QtMoc Include=\"MCAPICodeGeneratorPlugin.h\">\r\n      <Filter>Header Files</Filter>\r\n    </QtMoc>\r\n    <QtRcc Include=\"MCAPICodeGenerator.qrc\">\r\n      <Filter>Resource Files</Filter>\r\n    </QtRcc>\r\n    <QtMoc Include=\"..\\..\\common\\dialogs\\comboSelector\\comboselector.h\">\r\n      <Filter>Header Files</Filter>\r\n    </QtMoc>\r\n  </ItemGroup>\r\n  <ItemGroup>\r\n    <None Include=\"mcapi.json\" />\r\n    <None Include=\"McapiGenerator.png\">\r\n      <Filter>Resource Files</Filter>\r\n    </None>\r\n  </ItemGroup>\r\n  <ItemGroup>\r\n    <ClInclude Include=\"MCAPIParser.h\">\r\n      <Filter>Header Files</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"MCAPIHeaderGenerator.h\">\r\n      <Filter>Header Files</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\common\\CSourceWriter.h\">\r\n      <Filter>Header Files</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\common\\NameGenerationPolicy.h\">\r\n      <Filter>Header Files</Filter>\r\n    </ClInclude>\r\n  </ItemGroup>\r\n</Project>"
  },
  {
    "path": "Plugins/MCAPICodeGenerator/MCAPICodeGeneratorPlugin.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: MCAPICodeGeneratorPlugin.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Janne Virtanen\r\n// Date: 13.10.2014\r\n//\r\n// Description:\r\n// MCAPI code generator plugin.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"MCAPICodeGeneratorPlugin.h\"\r\n#include \"MCAPICodeGenerator.h\"\r\n#include \"MCAPIHeaderGenerator.h\"\r\n\r\n#include <QCoreApplication>\r\n#include <QFileInfo>\r\n#include <QMessageBox>\r\n\r\n#include <KactusAPI/include/LibraryInterface.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MCAPICodeGeneratorPlugin::MCAPICodeGeneratorPlugin()\r\n//-----------------------------------------------------------------------------\r\nMCAPICodeGeneratorPlugin::MCAPICodeGeneratorPlugin()\r\n{\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MCAPICodeGeneratorPlugin::~MCAPICodeGeneratorPlugin()\r\n//-----------------------------------------------------------------------------\r\nMCAPICodeGeneratorPlugin::~MCAPICodeGeneratorPlugin()\r\n{\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MCAPICodeGeneratorPlugin::getName()\r\n//----------------------------------------------------------------------------\r\nQString MCAPICodeGeneratorPlugin::getName() const\r\n{\r\n    return \"MCAPI Code Generator\";\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MCAPICodeGeneratorPlugin::getVersion()\r\n//-----------------------------------------------------------------------------\r\nQString MCAPICodeGeneratorPlugin::getVersion() const\r\n{\r\n    return \"1.1\";\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MCAPICodeGeneratorPlugin::getDescription()\r\n//-----------------------------------------------------------------------------\r\nQString MCAPICodeGeneratorPlugin::getDescription() const\r\n{\r\n    return \"Generates MCAPI code templates based on the metadata.\";\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MCAPICodeGeneratorPlugin::getVendor()\r\n//-----------------------------------------------------------------------------\r\nQString MCAPICodeGeneratorPlugin::getVendor() const\r\n{\r\n    return tr(\"TUT\");\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MCAPICodeGeneratorPlugin::getLicense()\r\n//-----------------------------------------------------------------------------\r\nQString MCAPICodeGeneratorPlugin::getLicense() const\r\n{\r\n    return tr(\"GPL2\");\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MCAPICodeGeneratorPlugin::getLicenseHolder()\r\n//-----------------------------------------------------------------------------\r\nQString MCAPICodeGeneratorPlugin::getLicenseHolder() const\r\n{\r\n    return tr(\"Public\");\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MCAPICodeGeneratorPlugin::getSettingsWidget()\r\n//-----------------------------------------------------------------------------\r\nQWidget* MCAPICodeGeneratorPlugin::getSettingsWidget()\r\n{\r\n    return nullptr;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MCAPICodeGeneratorPlugin::getIcon()\r\n//-----------------------------------------------------------------------------\r\nQIcon MCAPICodeGeneratorPlugin::getIcon() const\r\n{\r\n    return QIcon(\":icons/McapiGenerator.png\");\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MCAPICodeGeneratorPlugin::checkGeneratorSupport()\r\n//-----------------------------------------------------------------------------\r\nbool MCAPICodeGeneratorPlugin::checkGeneratorSupport(QSharedPointer<Component const> component,\r\n    QSharedPointer<Design const> design,\r\n    QSharedPointer<DesignConfiguration const> designConfiguration) const\r\n{\r\n    return (component != 0 && component->getImplementation() == KactusAttribute::SW) ||\r\n        ( design != 0 && designConfiguration != 0 && designConfiguration->getImplementation() == KactusAttribute::SYSTEM );\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MCAPICodeGeneratorPlugin::runGenerator()\r\n//-----------------------------------------------------------------------------\r\nvoid MCAPICodeGeneratorPlugin::runGenerator(IPluginUtility* utility, \r\n    QSharedPointer<Component> component,\r\n    QSharedPointer<Design> design,\r\n    QSharedPointer<DesignConfiguration> designConfiguration)\r\n{\r\n    if (component != 0 && component->getImplementation() == KactusAttribute::SW)\r\n    {\r\n        MCAPIParser parser( utility );\r\n        parser.parseMCAPIForComponent(component);\r\n        MCAPICodeGenerator generator( parser, utility );\r\n        QString dir = QFileInfo(utility->getLibraryInterface()->getPath(component->getVlnv())).absolutePath(); \r\n        generator.generateMCAPIForComponent(dir, component);\r\n    }\r\n    else if (design != 0 && designConfiguration != 0 &&\r\n        designConfiguration->getImplementation() == KactusAttribute::SYSTEM )\r\n    {\r\n        MCAPIParser parser( utility );\r\n        parser.parseTopLevel(design, component, designConfiguration);\r\n\r\n        QStringList replacedFiles = parser.getReplacedFiles();\r\n\r\n        // Ask verification from the user, if any file is being replaced,\r\n        if ( replacedFiles.size() > 0 )\r\n        {\r\n            // Details will be the list of files being replaced.\r\n            QString detailMsg;\r\n\r\n            foreach ( QString file, replacedFiles )\r\n            {\r\n                detailMsg += file + \"\\n\";\r\n            }\r\n\r\n            QMessageBox msgBox( QMessageBox::Warning, QCoreApplication::applicationName(),\r\n                \"Some files will be WRITTEN OVER in the generation. Proceed?\",\r\n                QMessageBox::Yes | QMessageBox::No, utility->getParentWidget());\r\n            msgBox.setDetailedText(detailMsg);\r\n\r\n            // If user did not want to replace the files.\r\n            if (msgBox.exec() == QMessageBox::No) {\r\n                return;\r\n            }\r\n        }\r\n\r\n        MCAPIHeaderGenerator generator( parser, utility );\r\n        VLNV topVLNV = component->getVlnv();\r\n        QString topDir = QFileInfo(utility->getLibraryInterface()->getPath(topVLNV)).absolutePath();\r\n        generator.generateTopLevel(component, designConfiguration, topDir);\r\n        utility->getLibraryInterface()->writeModelToFile(design);\r\n    }\r\n\r\n    utility->getLibraryInterface()->writeModelToFile(component);\r\n\r\n    utility->printInfo( \"MCAPI generation complete.\");\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MCAPICodeGeneratorPlugin::getProgramRequirements()\r\n//-----------------------------------------------------------------------------\r\nQList<IPlugin::ExternalProgramRequirement> MCAPICodeGeneratorPlugin::getProgramRequirements() {\r\n    return QList<IPlugin::ExternalProgramRequirement>();\r\n}"
  },
  {
    "path": "Plugins/MCAPICodeGenerator/MCAPICodeGeneratorPlugin.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: MCAPICodeGeneratorPlugin.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Janne Virtanen\r\n// Date: 13.10.2014\r\n//\r\n// Description:\r\n// MCAPI code generator plugin.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef MCAPICodeGeneratorPlugin_H\r\n#define MCAPICodeGeneratorPlugin_H\r\n\r\n#include <KactusAPI/include/IGeneratorPlugin.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n//! MCAPI code generator.\r\n//-----------------------------------------------------------------------------\r\nclass MCAPICodeGeneratorPlugin : public QObject, public IGeneratorPlugin\r\n{\r\n    Q_OBJECT\r\n    Q_PLUGIN_METADATA(IID \"kactus2.plugins.MCAPICodeGenerator\" FILE \"mcapi.json\")\r\n\r\n    Q_INTERFACES(IPlugin)\r\n    Q_INTERFACES(IGeneratorPlugin)\r\n\r\npublic:\r\n    MCAPICodeGeneratorPlugin();\r\n    ~MCAPICodeGeneratorPlugin();\r\n\r\n    /*!\r\n     *  Returns the name of the plugin.\r\n     */\r\n    virtual QString getName() const;\r\n\r\n    /*!\r\n     *  Returns the version of the plugin.\r\n     */\r\n    virtual QString getVersion() const;\r\n\r\n    /*!\r\n     *  Returns the description of the plugin.\r\n     */\r\n    virtual QString getDescription() const;\r\n\r\n    /*!\r\n     *  Returns the vendor of the plugin.\r\n     */\r\n    virtual QString getVendor() const;\r\n\r\n    /*!\r\n     *  Returns the license of the plugin.\r\n     */\r\n    virtual QString getLicense() const;\r\n\r\n    /*!\r\n     *  Returns the holder of the license of the plugin.\r\n     */\r\n    virtual QString getLicenseHolder() const;\r\n\r\n    /*!\r\n     *  Returns the settings widget.\r\n     */\r\n    virtual QWidget* getSettingsWidget();\r\n\r\n    /*!\r\n     *  This is used to access the settings modified by function getSettingsWidget().\r\n     */\r\n    virtual PluginSettingsModel* getSettingsModel(){return NULL;}\r\n\r\n    /*!\r\n     *  Returns the icon for the generator.\r\n     */\r\n    virtual QIcon getIcon() const;\r\n    /*!\r\n     *  Checks whether the generator may run for the given component or design. \r\n     *\r\n     *    @param [in] component\t        The component for which to check support. If design is not null, component\r\n\t *                                      will refer to design or designConfiguration.\r\n     *    @param [in] design\t            The design, if the generator is ran for a design.\r\n     *    @param [in] designConfiguration The design configuration for design, if it is not null.\r\n     *\r\n     *    @return True, if the generator may run the given component. Otherwise false.\r\n     */\r\n    virtual bool checkGeneratorSupport(QSharedPointer<Component const> component,\r\n        QSharedPointer<Design const> design,\r\n        QSharedPointer<DesignConfiguration const> designConfiguration) const;\r\n\r\n    /*!\r\n     *  Runs the generation, creating new files and/or modifying the IP-XACT metadata. The function has\r\n\t *  also access to the parent window widget, so that it can show dialogs for the user to aid the generation.\r\n     *\r\n     *    @param [in] utility\t\t\t    The plugin utility interface.\r\n     *    @param [in] component\t        The component for which to check support. If design is not null, component\r\n     *                                      will refer to design or designConfiguration.\r\n     *    @param [in] design\t            The design, if the generator is ran for a design.\r\n     *    @param [in] designConfiguration The design configuration for design, if it is not null.\r\n     */\r\n    virtual void runGenerator(IPluginUtility* utility, \r\n        QSharedPointer<Component> component,\r\n        QSharedPointer<Design> design,\r\n        QSharedPointer<DesignConfiguration> designConfiguration);\r\n\r\n     //! \\brief Returns the external program requirements of the plugin.\r\n     virtual QList<IPlugin::ExternalProgramRequirement> getProgramRequirements();\r\n};\r\n\r\n#endif // MCAPICodeGeneratorPlugin_H\r\n"
  },
  {
    "path": "Plugins/MCAPICodeGenerator/MCAPIHeaderGenerator.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: MCAPIHeaderGenerator.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Janne Virtanen\r\n// Date: 13.10.2014\r\n//\r\n// Description:\r\n// MCAPI generator for instance specific headers.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"MCAPIHeaderGenerator.h\"\r\n\r\n#include <QDir>\r\n\r\n#include <Plugins/common/CSourceWriter.h>\r\n#include <editors/CSourceEditor/CSourceTextEdit.h>\r\n\r\n#include <IPXACTmodels/Component/FileSet.h>\r\n\r\n#include <IPXACTmodels/kactusExtensions/SystemView.h>\r\n\r\n#include <common/NameGenerationPolicy.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MCAPIHeaderGenerator::MCAPIHeaderGenerator()\r\n//-----------------------------------------------------------------------------\r\nMCAPIHeaderGenerator::MCAPIHeaderGenerator( MCAPIParser& parser, IPluginUtility* utility ) : \r\ncomponentEndpoints_( parser.getComponentEndpoints() ), designNodes_( parser.getDesignNodes() ), utility_( utility )\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MCAPIHeaderGenerator::generateTopLevel()\r\n//-----------------------------------------------------------------------------\r\nvoid MCAPIHeaderGenerator::generateTopLevel(QSharedPointer<Component> topComponent,\r\n    QSharedPointer<DesignConfiguration const> desgConf, QString topDir)\r\n{\r\n    foreach ( MCAPIParser::NodeData nd, designNodes_ )\r\n    {\r\n        generateInstanceHeader(nd.directory, nd);\r\n\r\n        addGeneratedMCAPIToFileset(General::getRelativePath(topDir,nd.directory), topComponent,\r\n            nd.instance, desgConf);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MCAPIHeaderGenerator::createIndentString()\r\n//-----------------------------------------------------------------------------\r\nQString MCAPIHeaderGenerator::createIndentString()\r\n{\r\n    QSettings settings;\r\n\r\n    // Read indentation settings.\r\n    IndentStyle style = static_cast<IndentStyle>(settings.value(\"Editor/IndentStyle\",\r\n        INDENT_STYLE_SPACES).toInt());\r\n    unsigned int width = settings.value(\"Editor/IndentWidth\", 4).toInt();\r\n\r\n    QString indent;\r\n\r\n    if (style == INDENT_STYLE_SPACES)\r\n    {\r\n        indent.fill(' ', width);\r\n    }\r\n    else\r\n    {\r\n        indent = \"\\t\";\r\n    }\r\n\r\n    return indent;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: generateInstanceHeader()\r\n//-----------------------------------------------------------------------------\r\nvoid MCAPIHeaderGenerator::generateInstanceHeader(QString const& directory, MCAPIParser::NodeData const& nodeData)\r\n{\r\n    // Create folder for the instance.\r\n    QDir path;\r\n    path.mkpath( directory );\r\n\r\n    // Open the file for writing.\r\n    QString const filename = directory + \"/instanceheader.h\";\r\n    CSourceWriter writer(filename, createIndentString());\r\n\r\n    if (!writer.open())\r\n    {\r\n        return;\r\n    }\r\n\r\n    writer.writeFileHeader();\r\n\r\n    writer.writeLine(\"// DO NOT MODIFY THIS FILE. ALL CHANGES WILL BE OVERWRITTEN BY KACTUS2.\");\r\n    writer.writeEmptyLine();\r\n\r\n    writer.writeLine(\"#ifndef INSTANCEHEADER_H\");\r\n    writer.writeLine(\"#define INSTANCEHEADER_H\");\r\n    writer.writeEmptyLine();\r\n\r\n    // List of items going to array definition.\r\n    QStringList endpointDefs;\r\n\r\n    writer.writeLine(\"//Local instance specific data:\");\r\n    writer.writeLine(\"#define LOCAL_NODE_ID \" + nodeData.nodeID);\r\n    writer.writeLine(\"#define LOCAL_DOMAIN_ID \" + nodeData.domainID);\r\n\r\n    writer.writeEmptyLine();\r\n\r\n    QPair<MCAPIParser::EndPointData, MCAPIParser::EndPointData> conPair;\r\n    foreach( conPair, nodeData.connections )\r\n    {\r\n        writeRemoteEndpoint(writer, conPair.first, conPair.second, endpointDefs);\r\n    }\r\n\r\n    writeEndpointDefList(writer, endpointDefs);\r\n\r\n    writer.writeLine(\"#endif\");\r\n\r\n    writer.writeEmptyLine();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MCAPIHeaderGenerator::addGeneratedMCAPIToFileset()\r\n//-----------------------------------------------------------------------------\r\nvoid MCAPIHeaderGenerator::addGeneratedMCAPIToFileset(QString directory, QSharedPointer<Component> topComponent,\r\n    QSharedPointer<ComponentInstance> instance, QSharedPointer<DesignConfiguration const> desgConf)\r\n{\r\n    QString sysViewName;\r\n\r\n    foreach( QSharedPointer<SystemView> view, topComponent->getSystemViews() )\r\n    {\r\n        if ( view->getHierarchyRef() == desgConf->getVlnv() )\r\n        {\r\n           sysViewName = view->name();\r\n           break;\r\n        }\r\n    }\r\n\r\n    // Add the files to the component metadata.\r\n    QString fileSetName;\r\n\r\n    // Check if the software instance has and existing fileSet reference. \r\n    if ( instance->getFileSetRef().isEmpty() )\r\n    {\r\n        // If not, make a new one.\r\n        fileSetName = NameGenerationPolicy::instanceFilesetName( sysViewName, instance->getInstanceName() );\r\n        instance->setFileSetRef( fileSetName );\r\n    }\r\n    else\r\n    {\r\n        // If there is pre-existing reference, use it.\r\n        fileSetName = instance->getFileSetRef();\r\n    }\r\n\r\n    // Obtain the the fileSet by name and set it as a source file group.\r\n    QSharedPointer<FileSet> fileSet = topComponent->getFileSet(fileSetName);\r\n    fileSet->setGroups(\"sourceFiles\");\r\n\r\n    // Path of the file, including file name.\r\n    QString filePath = directory + \"/instanceheader.h\";\r\n\r\n    // Create file if does not already exist.\r\n    if ( !fileSet->contains(filePath) )\r\n    {\r\n        QSharedPointer<File> file;\r\n        QSettings settings;\r\n        file = fileSet->addFile(filePath, settings);\r\n        file->addFileType(\"cSource\");\r\n        file->setIncludeFile( true );\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MCAPIHeaderGenerator::writeRemoteEndpoint()\r\n//-----------------------------------------------------------------------------\r\nvoid MCAPIHeaderGenerator::writeRemoteEndpoint(CSourceWriter &writer, MCAPIParser::EndPointData ourEnd,\r\n    MCAPIParser::EndPointData theirEnd, QStringList& endpointDefs)\r\n{\r\n    QString remoteName = ourEnd.remoteName;\r\n\r\n    // Direction and transfer type must convert to correct format.\r\n    QString ourTransferString = transferTypeToEString(ourEnd.transferType);\r\n    QString ourDirectionString = transferDirectionToEString(ourEnd.direction);\r\n    QString theirTransferString = transferTypeToEString(theirEnd.transferType);\r\n    QString theirDirectionString = transferDirectionToEString(theirEnd.direction);\r\n\r\n    // Read the sizes of scalars.\r\n    QString ourScalarSize = ourEnd.scalarSize;\r\n    QString theirScalarSize = theirEnd.scalarSize;\r\n\r\n    // Generate the endpoint identifier for the remote endpoint.\r\n    writer.writeLine(\" //\" + remoteName + \" endpoint identifier:\");\r\n    writer.writeLine(\"#define \" + remoteName.toUpper() + \"_DOMAIN \"+ theirEnd.domainID);\r\n    writer.writeLine(\"#define \" + remoteName.toUpper() + \"_NODE \"+ theirEnd.nodeID);\r\n    writer.writeLine(\"#define \" + remoteName.toUpper() + \"_PORT \"+ theirEnd.portID);\r\n\r\n    writer.writeEmptyLine();\r\n\r\n    // Generate identifier strings corresponding the endpoint identifiers.\r\n    QString theirIdString = makeIdString(theirEnd.domainID, theirEnd.nodeID, theirEnd.portID);\r\n    QString ourIdString = makeIdString(ourEnd.domainID, ourEnd.nodeID, ourEnd.portID);\r\n\r\n    // Create endpoint definitions.\r\n    QString ourEndpointDef = ourEnd.name.toUpper() + \"_DEF\";\r\n    QString theirEndpointDef = remoteName.toUpper() + \"_DEF\";\r\n\r\n    writer.writeLine(\"#define \" + ourEndpointDef + \" {\" + ourIdString + \", \" + ourTransferString  +\r\n        \", \" + ourDirectionString + \", \" + theirIdString + \", \" + ourScalarSize + \"}\" );\r\n    writer.writeLine(\"#define \" + theirEndpointDef + \" {\" + theirIdString + \", \" + ourTransferString +\r\n        \", \" + theirDirectionString + \", \" + ourIdString + \", \" + theirScalarSize + \"}\" );\r\n\r\n    writer.writeEmptyLine();\r\n\r\n    // Append the definitions to list, to be placed to an array.\r\n    endpointDefs.append(ourEndpointDef);\r\n    endpointDefs.append(theirEndpointDef);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MCAPIHeaderGenerator::writeEndpointDefList()\r\n//-----------------------------------------------------------------------------\r\nvoid MCAPIHeaderGenerator::writeEndpointDefList(CSourceWriter& writer, QStringList& endpointDefs)\r\n{\r\n    writer.writeLine(\"//List of endpoint definitions used by the implementation.\" );\r\n    writer.writeLine(\"#define DEF_LIST { \\\\\" );\r\n    QString line;\r\n\r\n    for ( int i = 0; i < endpointDefs.size(); ++i )\r\n    {\r\n        QString edpDef = endpointDefs[i];\r\n\r\n        line.append(edpDef + \", \");\r\n\r\n        if ( (i+1)%5 == 0 )\r\n        {\r\n            writer.writeLine(line + \" \\\\\");\r\n            line.clear();\r\n        }\r\n    }\r\n\r\n    if ( !line.isEmpty() )\r\n    {\r\n        writer.writeLine(line + \" \\\\\");\r\n    }\r\n\r\n    writer.writeLine(\"}\" );\r\n    writer.writeEmptyLine();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MCAPIHeaderGenerator::transferDirectionToEString()\r\n//-----------------------------------------------------------------------------\r\nQString MCAPIHeaderGenerator::transferDirectionToEString(DirectionTypes::Direction direction)\r\n{\r\n    if ( direction == DirectionTypes::IN )\r\n    {\r\n        return \"CHAN_DIR_RECV\";\r\n    }\r\n    else if ( direction == DirectionTypes::OUT )\r\n    {\r\n        return \"CHAN_DIR_SEND\";\r\n    }\r\n    else if ( direction == DirectionTypes::INOUT )\r\n    {\r\n        return \"CHAN_NO_DIR\";\r\n    }\r\n\r\n    return QString();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MCAPIHeaderGenerator::transferTypeToEString()\r\n//-----------------------------------------------------------------------------\r\nQString MCAPIHeaderGenerator::transferTypeToEString(QString transferType)\r\n{\r\n    if ( transferType == \"message\" )\r\n    {\r\n        return \"MCAPI_NO_CHAN\";\r\n    }\r\n    else if ( transferType == \"scalar\" )\r\n    {\r\n        return\"MCAPI_SCL_CHAN\";\r\n    }\r\n    else if ( transferType == \"packet\" )\r\n    {\r\n        return \"MCAPI_PKT_CHAN\";\r\n    }\r\n\r\n    return QString();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MCAPIHeaderGenerator::makeIdString()\r\n//-----------------------------------------------------------------------------\r\nQString MCAPIHeaderGenerator::makeIdString(QString domainID, QString nodeID, QString portID)\r\n{\r\n    return \"{\" + domainID + \", \" + nodeID + \", \" + portID + \"}\";\r\n}\r\n"
  },
  {
    "path": "Plugins/MCAPICodeGenerator/MCAPIHeaderGenerator.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: MCAPIHeaderGenerator.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Janne Virtanen\r\n// Date: 13.10.2014\r\n//\r\n// Description:\r\n// MCAPI generator for instance specific headers.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef MCAPIHeaderGenerator_H\r\n#define MCAPIHeaderGenerator_H\r\n\r\n#include <MCAPIParser.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n//! MCAPI code generator.\r\n//-----------------------------------------------------------------------------\r\nclass MCAPIHeaderGenerator\r\n{\r\npublic:\r\n    /*!\r\n     *  The constructor.\r\n     *\r\n     *    @param [in] parser   A parser that has already parsed the design for MCAPI generation.\r\n     *    @param [in] utility   The same IPluginUtility, which is fed to the plugin class as parameter.\r\n     */\r\n     MCAPIHeaderGenerator( MCAPIParser& parser, IPluginUtility* utility );\r\n    \r\n     //! Disable copying.\r\n     MCAPIHeaderGenerator(MCAPIHeaderGenerator const& other) = delete;\r\n     MCAPIHeaderGenerator& operator=(MCAPIHeaderGenerator const& other) = delete;\r\n\r\n     virtual ~MCAPIHeaderGenerator() = default;\r\n\r\n    /*!\r\n     *  Generates source files associated with the top level component of the design.\r\n     *\r\n     *    @param [in] topComponent   The top level component associated with the design.\r\n     *    @param [in] desgConf   The design configuration associated with the design.\r\n     *    @param [in] topDir   The location of the top level component in the file system.\r\n     */\r\n     void generateTopLevel(QSharedPointer<Component> topComponent,\r\n        QSharedPointer<DesignConfiguration const> desgConf, QString topDir);\r\n\r\nprivate:\r\n\r\n    /*!\r\n     *  Creates the indent string based on the application settings.\r\n     */\r\n    QString createIndentString();\r\n\r\n    /*!\r\n     *  Generates a header file containing data specific to a software instance.\r\n     *\r\n     *    @param [in] filename   The name of the source file to write.\r\n     *    @param [in] nodeData   MCAPI node data associated with the instance.\r\n     */\r\n    void generateInstanceHeader(QString const& directory, MCAPIParser::NodeData const& nodeData);\r\n\r\n    /*!\r\n     *  Add generated MCAPI code files to the fileSet of the associated component.\r\n     *\r\n     *    @param [in] directory   The directory, where the files are inserted on the file system.\r\n     *    @param [in] topComponent   The top level component associated with the design.\r\n     *    @param [in] instance   The software instance, which instance header was generated.\r\n     *    @param [in] desgConf   The design configuration associated with the design.\r\n     */\r\n     void addGeneratedMCAPIToFileset(QString directory, QSharedPointer<Component> topComponent,\r\n        QSharedPointer<ComponentInstance> instance, QSharedPointer<DesignConfiguration const> desgConf);\r\n\r\n    /*!\r\n     *  Find connections of given software instance and returns a list of pairs, where the first is from the\r\n     *  end of the given instance, and second the other end.\r\n     *\r\n     *    @param [in] design   The design where the software instance belongs to.\r\n     *    @param [in] ourInstance   The software instance, which connections are listed.\r\n     *    @param [in] component   The software component of ourInstance.\r\n     *    @return List of \"our\" interfaces paired with their connected interfaces.\r\n     */\r\n     QList<QPair<QSharedPointer<ComInterface>, PortReference> > findConnectedComInterfaces(\r\n        QSharedPointer<const Design> design, QSharedPointer<ComponentInstance> ourInstance,\r\n        QSharedPointer<Component> component );\r\n\r\n     /*!\r\n     *  Writes remote endpoint of 'ourInterface' and endpoint definitions of both given interfaces.\r\n     *  The definitions are appended to the list 'endpointDefs'.\r\n      *\r\n      *    @param [in] writer   The source writer.\r\n      *    @param [in] ourEnd   Data associated with end point in \"our\" end of connection.\r\n      *    @param [in] theirEnd   Data associated with end point in \"their\" end of connection.\r\n      *    @param [in] endpointDefs   The list of endpoint definition names.\r\n      */\r\n      void writeRemoteEndpoint(CSourceWriter &writer, MCAPIParser::EndPointData ourEnd,\r\n          MCAPIParser::EndPointData theirEnd, QStringList& endpointDefs);\r\n\r\n    /*!\r\n     *  Writes the given endpoint definition names to array.\r\n     *\r\n     *    @param [in] writer   The source writer.\r\n     *    @param [in] endpointDefs   The list of endpoint definition names.\r\n     */\r\n     void writeEndpointDefList(CSourceWriter &writer, QStringList &endpointDefs);\r\n\r\n    /*!\r\n     *  Converts direction string of Kactus2 to enum used by PMQ-MCAPI.\r\n     *\r\n     *    @param [in] direction   Direction string to be converted.\r\n     *    @return The created enum.\r\n     */\r\n     QString transferDirectionToEString(DirectionTypes::Direction direction);\r\n\r\n    /*!\r\n     *  Converts transfer type string of Kactus2 to enum used by PMQ-MCAPI.\r\n     *\r\n     *    @param [in] transferType   Transfer type string to be converted.\r\n     *    @return The created enum.\r\n     */\r\n     QString transferTypeToEString(QString transferType);\r\n\r\n    /*!\r\n     *  Makes an endpoint identifier understood by PMQ-MCAPI.\r\n     *\r\n     *    @param [in] domainID   The domain of the endpoint.\r\n     *    @param [in] nodeID   The node of the endpoint.\r\n     *    @param [in] portID   The port of the endpoint.\r\n     *    @return The created string.\r\n     */\r\n     QString makeIdString(QString domainID, QString nodeID, QString portID);\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! Endpoints parsed from component\r\n    QList<MCAPIParser::EndPointData> componentEndpoints_;\r\n\r\n    //! Nodes parsed from design.\r\n    QList<MCAPIParser::NodeData> designNodes_;\r\n\r\n    //! The plugin utility.\r\n    IPluginUtility* utility_;\r\n};\r\n\r\n#endif // MCAPIHeaderGenerator_H\r\n"
  },
  {
    "path": "Plugins/MCAPICodeGenerator/MCAPIParser.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: MCAPIParser.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Janne Virtanen\r\n// Date: 13.10.2014\r\n//\r\n// Description:\r\n// MCAPI parser.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"MCAPIParser.h\"\r\n\r\n#include <QCoreApplication>\r\n#include <QFileInfo>\r\n#include <QMessageBox>\r\n\r\n#include <editors/CSourceEditor/CSourceTextEdit.h>\r\n\r\n#include \"common/dialogs/comboSelector/comboselector.h\"\r\n\r\n#include <IPXACTmodels/kactusExtensions/SystemView.h>\r\n#include <IPXACTmodels/kactusExtensions/ComInterface.h>\r\n\r\n#include <IPXACTmodels/Design/PortReference.h>\r\n\r\n#include <KactusAPI/include/LibraryInterface.h>\r\n\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MCAPIParser::MCAPIParser()\r\n//-----------------------------------------------------------------------------\r\nMCAPIParser::MCAPIParser( IPluginUtility* utility ) : utility_( utility )\r\n{\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MCAPIParser::~MCAPIParser()\r\n//-----------------------------------------------------------------------------\r\nMCAPIParser::~MCAPIParser()\r\n{\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MCAPIParser::getComponentEndpoints()\r\n//-----------------------------------------------------------------------------\r\nQList<MCAPIParser::EndPointData> MCAPIParser::getComponentEndpoints()\r\n{\r\n    return componentEndpoints_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MCAPIParser::getDesignNodes()\r\n//-----------------------------------------------------------------------------\r\nQList<MCAPIParser::NodeData> MCAPIParser::getDesignNodes()\r\n{\r\n    return designNodes_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MCAPIParser::getReplacedFiles()\r\n//-----------------------------------------------------------------------------\r\nQStringList MCAPIParser::getReplacedFiles()\r\n{\r\n    return replacedFiles_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MCAPIParser::parseMCAPIForComponent()\r\n//-----------------------------------------------------------------------------\r\nvoid MCAPIParser::parseMCAPIForComponent(QSharedPointer<Component> component)\r\n{\r\n    foreach (QSharedPointer<ComInterface> comIf, component->getComInterfaces())\r\n    {\r\n        if (comIf->getComType().getName().toLower() == \"mcapi\")\r\n        {\r\n            componentEndpoints_.append(parseEndpoint(comIf));\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MCAPIParser::parseTopLevel()\r\n//-----------------------------------------------------------------------------\r\nvoid MCAPIParser::parseTopLevel(QSharedPointer<Design> design, QSharedPointer<Component> topComponent,\r\n    QSharedPointer<DesignConfiguration const> desgConf)\r\n{\r\n    foreach (QSharedPointer<ComponentInstance> instance, *design->getComponentInstances())\r\n    {\r\n        VLNV instanceVLNV = *instance->getComponentRef();\r\n        VLNV designVLNV = design->getVlnv();\r\n\r\n        QSharedPointer<Document> instanceLibComp = utility_->getLibraryInterface()->getModel(instanceVLNV);\r\n        QSharedPointer<Component> instanceComp = instanceLibComp.dynamicCast<Component>();\r\n\r\n        if (instanceComp->getImplementation() != KactusAttribute::SW)\r\n        {\r\n            continue;\r\n        }\r\n\r\n        // Check if can generate the component, return if cannot\r\n        if (canGenerateMCAPIComponent(instanceComp))\r\n        {\r\n            NodeData nd; \r\n            nd.instance = instance;\r\n\r\n\t\t\t// Find the name of the system view pointing to the design configuration.\r\n\t\t\tQString sysViewName;\r\n\t\t\tforeach ( QSharedPointer<SystemView> view, topComponent->getSystemViews() )\r\n\t\t\t{\r\n                if ( view->getHierarchyRef() == desgConf->getVlnv() )\r\n\t\t\t\t{\r\n\t\t\t\t\tsysViewName = view->name();\r\n\t\t\t\t\tbreak;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\r\n            // Parse its directory as well.\r\n            QString subDir = \"/sw_\" + sysViewName + \"/\" + instance->getInstanceName();\r\n            QString dir = QFileInfo(utility_->getLibraryInterface()->getPath(designVLNV)).absolutePath() + subDir;\r\n            nd.directory = dir;\r\n\r\n            QFile file(dir + \"/instanceheader.h\");\r\n\r\n            // If does, put in the list.\r\n            if ( file.exists() )\r\n            {\r\n                replacedFiles_.append(dir + \"/instanceheader.h\");\r\n            }\r\n\r\n            // Mark up the node identifier, as well as the associated domain identifier.\r\n            nd.nodeID = instance->getPropertyValues().value(\"Node ID\");\r\n            nd.domainID = instance->getPropertyValues().value(\"Domain ID\");\r\n\r\n            findEndpointDefinitions(design, instance, instanceComp, nd);\r\n                        \r\n            designNodes_.append(nd);\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MCAPIParser::canGenerateMCAPIComponent()\r\n//-----------------------------------------------------------------------------\r\nbool MCAPIParser::canGenerateMCAPIComponent(QSharedPointer<Component> component)\r\n{\r\n    // Will not generate a null component.\r\n    if ( component == 0 )\r\n    {\r\n        return false;\r\n    }\r\n\r\n    // Errors found in interfaces.\r\n    QStringList errorList;\r\n    // Must have at least one MCAPI interface to generate.\r\n    bool hasMcapi = false;\r\n\r\n    // Go over each com interface and check for that each required property is set.\r\n    foreach (QSharedPointer<ComInterface> comIf, component->getComInterfaces())\r\n    {\r\n        // Check API support for generated interface\r\n        if (comIf->getComType().getName().toLower() == \"mcapi\" )\r\n        {\r\n            hasMcapi = true;\r\n        }\r\n\r\n        QSharedPointer<Document> libCom = utility_->getLibraryInterface()->getModel(comIf->getComType());\r\n        QSharedPointer<ComDefinition> comDef = libCom.dynamicCast<ComDefinition>();\r\n\r\n        if (comDef)\r\n        {\r\n            checkRequiredPropertiesSet(component->getVlnv().toString(), comDef, comIf, errorList);\r\n        }\r\n    }\r\n\r\n    // If errors exist, print about it and return false.\r\n    if ( hasMcapi && !errorList.isEmpty())\r\n    {\r\n        foreach (QString const& msg, errorList)\r\n        {\r\n            utility_->printError(msg);\r\n        }\r\n\r\n        QMessageBox msgBox(QMessageBox::Critical, QCoreApplication::applicationName(),\r\n            QObject::tr(\"The component contained %1 error(s). MCAPI code was not generated.\").arg(errorList.size()),\r\n            QMessageBox::Ok, utility_->getParentWidget());\r\n        msgBox.setDetailedText(QObject::tr(\"The following error(s) were found: \\n* \") + errorList.join(\"\\n* \"));\r\n\r\n        msgBox.exec();\r\n    }\r\n\r\n    // If no errors, we can generate the component.\r\n    return errorList.isEmpty() && hasMcapi;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MCAPIParser::checkRequiredPropertiesSet()\r\n//-----------------------------------------------------------------------------\r\nvoid MCAPIParser::checkRequiredPropertiesSet(QString componentVLNV, QSharedPointer<ComDefinition> comDef,\r\n    QSharedPointer<ComInterface> comIf, QStringList &errorList)\r\n{\r\n    for ( QSharedPointer<ComProperty> property : comDef->getProperties() )\r\n    {\r\n        if ( property->isRequired() && comIf->getPropertyValues().value(property->name()).isEmpty() )\r\n        {\r\n            errorList.append(QObject::tr(\"Property %1 of COM interface '%2' is not set in component '%3'\").\r\n                arg(property->name(),\r\n                comIf->name(),componentVLNV));\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MCAPIParser::findEndpointDefinitions()\r\n//-----------------------------------------------------------------------------\r\nvoid MCAPIParser::findEndpointDefinitions(QSharedPointer<const Design> design, QSharedPointer<ComponentInstance> ourInstance, \r\n    QSharedPointer<Component> component, NodeData& nodeData)\r\n{\r\n    QPair<QSharedPointer<ComInterface>, PortReference> conPair(QSharedPointer<ComInterface>(), PortReference(\"\"));\r\n    foreach(conPair, findConnectedComInterfaces(design, ourInstance, component))\r\n    {\r\n        // Search for software instance corresponding theirs.\r\n        QSharedPointer<ComponentInstance> targetInstance = design->findComponentInstance(conPair.second.getComponentRef());\r\n\r\n        // Obtain the component object corresponding the software instance.\r\n        VLNV instanceVLNV = *targetInstance->getComponentRef();\r\n        QSharedPointer<Document> instanceLibComp = utility_->getLibraryInterface()->getModel(instanceVLNV);\r\n        QSharedPointer<Component> instanceComp = instanceLibComp.dynamicCast<Component>();\r\n\r\n        if (instanceComp != 0)\r\n        {\r\n            // Get the interfaces.\r\n            QSharedPointer<ComInterface> targetInterface = instanceComp->getComInterface(conPair.second.getPortRef());\r\n            QSharedPointer<ComInterface> ourInterface = conPair.first;\r\n\r\n            // Must find it to generate.\r\n            if (targetInterface != 0)\r\n            {\r\n                // Check for sanity.\r\n                checkEndpointIdentifier(targetInterface, targetInstance);\r\n                checkTransferType(ourInstance, ourInterface, targetInstance, targetInterface);\r\n                checkScalarSize(ourInstance, ourInterface, targetInstance, targetInterface);\r\n\r\n                // The data needed for \"our\" endpoint.\r\n                EndPointData ourEnd = parseEndpoint(ourInterface);\r\n                ourEnd.nodeID = ourInstance->getPropertyValues().value(\"Node ID\");\r\n                ourEnd.domainID = ourInstance->getPropertyValues().value(\"Domain ID\");\r\n\r\n                // The data needed for \"their\" endpoint.\r\n                EndPointData theirEnd = parseEndpoint(ourInterface);\r\n                theirEnd.nodeID = targetInstance->getPropertyValues().value(\"Node ID\");\r\n                theirEnd.domainID = targetInstance->getPropertyValues().value(\"Domain ID\");\r\n\r\n                // Create the pair endpoints and append to the list\r\n                QPair<EndPointData, EndPointData> pair(ourEnd,theirEnd);\r\n                nodeData.connections.append(pair);\r\n            }\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MCAPIParser::findConnectedComInterfaces()\r\n//-----------------------------------------------------------------------------\r\nQList<QPair<QSharedPointer<ComInterface>, PortReference> > MCAPIParser::findConnectedComInterfaces(\r\n    QSharedPointer<const Design> design, QSharedPointer<ComponentInstance> ourInstance, QSharedPointer<Component> component )\r\n{\r\n    QList<QPair<QSharedPointer<ComInterface>, PortReference> > connectedInterfaces;\r\n\r\n    // Go through the list of connections in the design to retrieve remote endpoint identifiers.\r\n    /*foreach ( QSharedPointer<ComInterconnection> connection, design->getComConnections() )\r\n    {\r\n        // See which end on the connection is NOT ours.\r\n        if ( ourInstance->getInstanceName() == connection->getStartInterface()->getComponentReference())\r\n        {\r\n            QSharedPointer<ComInterface> ourInterface = component->getComInterface(connection->getStartInterface()->getBusReference());\r\n\r\n            // If our interface was not found we should not generate remote endpoint identifier for it.\r\n            if (!ourInterface.isNull())\r\n            {\r\n                QSharedPointer<ActiveInterface> targetInterface = connection->getEndInterface();\r\n\r\n                QPair<QSharedPointer<ComInterface>, PortReference> pair(ourInterface,\r\n                    PortReference(targetInterface->getBusReference(), targetInterface->getComponentReference()));\r\n                connectedInterfaces.append(pair);\r\n            }\r\n        }\r\n\r\n        else\r\n        {\r\n            QSharedPointer<ComInterface> ourInterface = component->\r\n                getComInterface(connection->getEndInterface()->getBusReference());\r\n\r\n            // If our interface was not found we should not generate remote endpoint identifier for it.\r\n            if (!ourInterface.isNull())\r\n            {\r\n                QSharedPointer<ActiveInterface> targetInterface = connection->getStartInterface();\r\n\r\n                QPair<QSharedPointer<ComInterface>, PortReference> pair( ourInterface,\r\n                    PortReference(targetInterface->getBusReference(), targetInterface->getComponentReference()));\r\n                connectedInterfaces.append(pair);\r\n            }\r\n        }\r\n    }*/\r\n\r\n    return connectedInterfaces;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MCAPIParser::parseEndpoint()\r\n//-----------------------------------------------------------------------------\r\nMCAPIParser::EndPointData MCAPIParser::parseEndpoint(QSharedPointer<ComInterface> comIf)\r\n{\r\n    EndPointData epd;\r\n    epd.name = comIf->name();\r\n    epd.remoteName = comIf->getPropertyValues().value(\"remote_endpoint_name\");\r\n    epd.portID = comIf->getPropertyValues().value(\"port_id\");\r\n    epd.handleName = comIf->getPropertyValues().value(\"handle_name\");\r\n    epd.scalarSize = comIf->getPropertyValues().value(\"scalar_size\");\r\n    epd.transferType = comIf->getTransferType();\r\n    epd.direction = comIf->getDirection();\r\n    return epd;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MCAPIParser::checkEndpointIdentifier()\r\n//-----------------------------------------------------------------------------\r\nvoid MCAPIParser::checkEndpointIdentifier(QSharedPointer<ComInterface> targetInterface,\r\n    QSharedPointer<ComponentInstance> targetInstance)\r\n{\r\n    QString theirPortID = targetInterface->getPropertyValues().value(\"port_id\").toUpper();\r\n    QString theirDomainID = targetInstance->getPropertyValues().value(\"Domain ID\");\r\n    QString theirNodeID = targetInstance->getPropertyValues().value(\"Node ID\");\r\n\r\n    if ( theirPortID.isEmpty() || theirDomainID.isEmpty() || theirNodeID.isEmpty() )\r\n    {\r\n        utility_->printError(\"Could not find whole endpoint identifier for instance \"\r\n            + targetInstance->getInstanceName() + \" interface \" + targetInterface->name()\r\n            + \" Found domain: \" + theirDomainID + \" node: \" + theirNodeID + \" port: \" + theirPortID);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MCAPIParser::checkTransferType()\r\n//-----------------------------------------------------------------------------\r\nvoid MCAPIParser::checkTransferType(QSharedPointer<ComponentInstance> ourInstance, \r\n    QSharedPointer<ComInterface> ourInterface, \r\n    QSharedPointer<ComponentInstance> targetInstance, QSharedPointer<ComInterface> targetInterface)\r\n{\r\n    if ( ourInterface->getTransferType() != targetInterface->getTransferType() )\r\n    {\r\n        utility_->printError(\"Transfer types of connected endpoints did not match! \"\r\n            \"First instance: \" + ourInstance->getInstanceName() + \" first interface: \"\r\n            + ourInterface->name() + \" Second instance: \" + targetInstance->getInstanceName() + \r\n            \" second interface \" + targetInterface->name());\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MCAPIParser::checkScalarSize()\r\n//-----------------------------------------------------------------------------\r\nvoid MCAPIParser::checkScalarSize(QSharedPointer<ComponentInstance> ourInstance,\r\n    QSharedPointer<ComInterface> ourInterface, \r\n    QSharedPointer<ComponentInstance> targetInstance, QSharedPointer<ComInterface> targetInterface)\r\n{\r\n    QString ourScalarSize = ourInterface->getPropertyValues().value(\"scalar_size\");\r\n    QString theirScalarSize = targetInterface->getPropertyValues().value(\"scalar_size\");\r\n\r\n    if ( ourScalarSize != theirScalarSize )\r\n    {\r\n        utility_->printError(\"Scalar sizes of connected endpoints did not match! \"\r\n            \"First instance: \" + ourInstance->getInstanceName() + \" first interface: \"\r\n            + ourInterface->name() + \" Second instance: \" + targetInstance->getInstanceName() + \r\n            \" second interface \" + targetInterface->name());\r\n    }\r\n}\r\n"
  },
  {
    "path": "Plugins/MCAPICodeGenerator/MCAPIParser.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: MCAPIParser.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Janne Virtanen\r\n// Date: 13.10.2014\r\n//\r\n// Description:\r\n// MCAPI parser.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef MCAPIParser_H\r\n#define MCAPIParser_H\r\n\r\n#include <IPXACTmodels/kactusExtensions/ComDefinition.h>\r\n#include <IPXACTmodels/Component/Component.h>\r\n\r\n#include <IPXACTmodels/Design/Design.h>\r\n\r\n#include <IPXACTmodels/DesignConfiguration/DesignConfiguration.h>\r\n\r\n#include <KactusAPI/include/IPluginUtility.h>\r\n\r\nclass CSourceWriter;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! MCAPI code generator.\r\n//-----------------------------------------------------------------------------\r\nclass MCAPIParser\r\n{\r\npublic:\r\n    struct EndPointData\r\n    {\r\n        QString name;\r\n        QString remoteName;\r\n        QString portID;\r\n        QString nodeID;\r\n        QString domainID;\r\n        QString handleName;\r\n        QString scalarSize;\r\n        QString transferType;\r\n        DirectionTypes::Direction direction;\r\n    };\r\n\r\n    struct NodeData\r\n    {\r\n        QSharedPointer<ComponentInstance> instance;\r\n        QString name;\r\n        QString nodeID;\r\n        QString domainID;\r\n        QString directory;\r\n        QList<QPair<EndPointData,EndPointData> > connections;\r\n    };\r\n\r\n    MCAPIParser( IPluginUtility* utility );\r\n    ~MCAPIParser();\r\n\r\n    /*!\r\n     *  Returns list MCAPI endpoints within a single software component.\r\n     */\r\n     QList<EndPointData> getComponentEndpoints();\r\n\r\n    /*!\r\n     *  Returns list nodes within a single system design, along with their connections to other nodes.\r\n     */\r\n     QList<NodeData> getDesignNodes();\r\n\r\n    /*!\r\n     *  Returns list of files replaced on the instance header generation.\r\n     */\r\n     QStringList getReplacedFiles();\r\n\r\n    /*!\r\n     *  Generates MCAPI code for the given component.\r\n     *\r\n     *    @param [in] component   The component, which is being parsed.\r\n     */\r\n    void parseMCAPIForComponent(QSharedPointer<Component> component);\r\n\r\n    /*!\r\n     *  Generates source files associated with the top level component of the design.\r\n     *\r\n     *    @param [in] design   The design subject to generation.\r\n     *    @param [in] topComponent   The top level component associated with the design.\r\n     *    @param [in] desgConf   The design configuration associated with the design.\r\n     */\r\n     void parseTopLevel(QSharedPointer<Design> design, QSharedPointer<Component> topComponent,\r\n         QSharedPointer<DesignConfiguration const> desgConf);\r\n\r\nprivate:\r\n\r\n    /*!\r\n     *  Checks if MCAPI code may be generated for the given component.\r\n     *\r\n     *    @param [in] component   The component, which is checked.\r\n     *    @return   True, if MCAPI code can be generated for the component.\r\n     */\r\n    bool canGenerateMCAPIComponent(QSharedPointer<Component> component);\r\n\r\n     /*!\r\n      *  Checks if all properties required in given ComDefintion are set in the given ComInterface.\r\n      *\r\n      *    @param [in] componentVLNV   VLNV associated with component where the interface belongs to.\r\n      *    @param [in] comDef    The ComDefinition under inspection.\r\n      *    @param [in] comIf   The ComInterface under inspection.\r\n      *    @param [in] errorList    Missing properties will be reported in this list.\r\n      */\r\n      void checkRequiredPropertiesSet(QString componentVLNV, QSharedPointer<ComDefinition> comDef,\r\n         QSharedPointer<ComInterface> comIf,  QStringList &errorList);\r\n\r\n    /*!\r\n     *  Parses all endpoint definitions of given software instance.\r\n     *\r\n     *    @param [in] design   The design where the software instance belongs to.\r\n     *    @param [in] ourInstance   The software instance, which endpoint definitions are written.\r\n     *    @param [in] component   The software component of ourInstance.\r\n     *    @param [in] nodeData    Node associated with the instance.\r\n     */\r\n     void findEndpointDefinitions(QSharedPointer<const Design> design, QSharedPointer<ComponentInstance> ourInstance,\r\n         QSharedPointer<Component> component, NodeData& nodeData);\r\n\r\n    /*!\r\n     *  Find connections of given software instance and returns a list of pairs, where the first is from the\r\n     *  end of the given instance, and second the other end.\r\n     *\r\n     *    @param [in] design   The design where the software instance belongs to.\r\n     *    @param [in] ourInstance   The software instance, which connections are listed.\r\n     *    @param [in] component   The software component of ourInstance.\r\n     *\r\n     *    @return List of \"our\" interfaces paired with their connected interfaces.\r\n     */\r\n     QList<QPair<QSharedPointer<ComInterface>, PortReference> > findConnectedComInterfaces(\r\n        QSharedPointer<const Design> design, QSharedPointer<ComponentInstance> ourInstance, \r\n        QSharedPointer<Component> component );\r\n\r\n     /*!\r\n      *  Parses data associated with an endpoint from given ComInterface and assigns it to the given endpoint.\r\n      *\r\n      *    @param [in] comIf   Source of the parsed data.\r\n      *\r\n      *    @return The parsed data.\r\n      */\r\n      EndPointData parseEndpoint(QSharedPointer<ComInterface> comIf);\r\n\r\n    /*!\r\n     *  Warns if all fields of endpoint identifier may be not found in given interface and its instance.\r\n     *\r\n     *    @param [in] targetInterface   Interface, which port ID is to be checked.\r\n     *    @param [in] targetInstance   Instance, which node ID and domain ID are to be checked.\r\n     */\r\n     void checkEndpointIdentifier(QSharedPointer<ComInterface> targetInterface,\r\n         QSharedPointer<ComponentInstance> targetInstance);\r\n\r\n    /*!\r\n     *  Warns if the transfer types of given interfaces are not compatible.\r\n     *\r\n     *    @param [in] ourInterface   Interface of connection in \"our\" end.\r\n     *    @param [in] targetInterface   Interface of connection in \"their\" end.\r\n     *    @param [in] ourInstance  Instance of connection in \"our\" end.\r\n     *    @param [in] targetInstance   Instance of connection in \"their\" end.\r\n     */\r\n     void checkTransferType(QSharedPointer<ComponentInstance> ourInstance, QSharedPointer<ComInterface> ourInterface, \r\n         QSharedPointer<ComponentInstance> targetInstance, QSharedPointer<ComInterface> targetInterface);\r\n\r\n    /*!\r\n     *   Warns if the scalar sizes of given interfaces are not compatible.\r\n     *\r\n     *    @param [in] ourInterface   Interface of connection in \"our\" end.\r\n     *    @param [in] targetInterface   Interface of connection in \"their\" end.\r\n     *    @param [in] ourInstance   Instance of connection in \"our\" end.\r\n     *    @param [in] targetInstance   Instance of connection in \"their\" end.\r\n     */\r\n     void checkScalarSize(QSharedPointer<ComponentInstance> ourInstance, QSharedPointer<ComInterface> ourInterface, \r\n         QSharedPointer<ComponentInstance> targetInstance, QSharedPointer<ComInterface> targetInterface);\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! Endpoints parsed from component.\r\n    QList<EndPointData> componentEndpoints_;\r\n\r\n    //! Nodes parsed from design.\r\n    QList<NodeData> designNodes_;\r\n\r\n    //! List of files that may be replaced\r\n    QStringList replacedFiles_;\r\n\r\n    //! The plugin utility.\r\n    IPluginUtility* utility_;\r\n};\r\n\r\n#endif // MCAPIParser_H\r\n"
  },
  {
    "path": "Plugins/MCAPICodeGenerator/mcapi.json",
    "content": "{\r\n\t\"Keys\": [ \"mcapi\" ]\r\n}"
  },
  {
    "path": "Plugins/MakefileGenerator/MakeCommon.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: MakeCommon.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Janne Virtanen\r\n// Date: 19.05.2016\r\n//\r\n// Description:\r\n// Contains the data types and constants commonly used in the makefile generation.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef MAKECOMMON_H\r\n#define MAKECOMMON_H\r\n\r\n#include <QString>\r\n#include <QSharedPointer>\r\n\r\n#include <IPXACTmodels/Component/File.h>\r\n#include <IPXACTmodels/Component/FileSet.h>\r\n#include <IPXACTmodels/Component/Component.h>\r\n#include <IPXACTmodels/Component/BuildCommand.h>\r\n#include <IPXACTmodels/Component/View.h>\r\n\r\nnamespace MakeCommon\r\n{\r\n    // The names of a generated makefiles.\r\n    const QString MAKEFILE_MASTER_NAME = \"Makefile\";\r\n    const QString MAKEFILE_FRAGMENT_SUFFIX = \".mak\";\r\n\r\n    // Flags appended by default to each object file build rule. Currently, the effects are:\r\n    // 1. To make use of the automatic dependency analysis.\r\n    // 2. To create an object file with specific name rather than executable with the default name.\r\n    const QString DEFAULT_OBJECT_FLAGS = \"-MMD -MP -c -o\";\r\n\r\n    // A struct containing parsed data of software instance in a stack.\r\n    struct StackPart\r\n    {\r\n        // The name of the associated component instance.\r\n        QString instanceName;\r\n        // The instantiated component.\r\n        QSharedPointer<Component> component;\r\n        // The active view in the current design configuration.\r\n        QSharedPointer<View> view;\r\n        // The component instantiation associated with the view.\r\n        QSharedPointer<ComponentInstantiation> instantiation;\r\n        // The selected build command of the active software view.\r\n        QSharedPointer<FileBuilder> buildCmd;\r\n        // Header files associated with the component instance.\r\n        QSharedPointer<FileSet> instanceHeaders;\r\n    };\r\n\r\n    // A struct containing needed data of a single file parsed to be used in a makefile.\r\n    // Provided that it is not a header file, it likely yields an object file.\r\n    struct MakeObjectData\r\n    {\r\n        // The file which data is parsed here.\r\n        QSharedPointer<File> file;\r\n        // The build command directly associated with the file.\r\n        QSharedPointer<BuildCommand> fileBuildCmd;\r\n        // The build command of the file set where file belongs to.\r\n        QSharedPointer<FileBuilder> fileSetBuildCmd;\r\n        // The build command of the active software view of the software instance.\r\n        QSharedPointer<FileBuilder> swBuildCmd;\r\n        // The resolved compiler for the object file.\r\n        QString compiler;\r\n        // The resolved flags for the object file.\r\n        QString flags;\r\n        // The absolute path of the file.\r\n        QString path;\r\n        // The name of the file.\r\n        QString fileName;\r\n        // File set where the file is included.\r\n        QSharedPointer<FileSet> fileSet;\r\n        // The part of the stack where this is based to.\r\n        QSharedPointer<StackPart> stackPart;\r\n        // True, if this object will be generated to the makefile.\r\n        bool isChosen = true;\r\n    };\r\n\r\n    // A struct containing needed data of a single makefile.\r\n    struct MakeFileData\r\n    {\r\n        // The parsed software stack.\r\n        QList<QSharedPointer<StackPart> > parts;\r\n\r\n        // The hardware instance, where the top component of the stack is mapped to.\r\n        QSharedPointer<StackPart> hardPart;\r\n\r\n        // Parsed files found in software views of software components.\r\n        QList<QSharedPointer<MakeObjectData> > swObjects;\r\n        // Flags passed down from component instantiations.\r\n        QStringList componentInstantiationFlags;\r\n        // The name of the instance.\r\n        QString name;\r\n        // The list of all included directories.\r\n        QStringList includeDirectories;\r\n        // The list of parsed software instances. Tracked to avoid re-parsing a dependency.\r\n        QList<QSharedPointer<ComponentInstance> > parsedInstances;\r\n        // Header files associated with the topmost component instance.\r\n        // This is to contain the makefile generated for the instance.\r\n        QSharedPointer<FileSet> instanceFileSet;\r\n        // The path where the makefile is generated to.\r\n        QString makeName;\r\n        // Sets of conflicting parts.\r\n        QVector<QSet<QSharedPointer<MakeObjectData> > > conflicts;\r\n    };\r\n\r\n}\r\n#endif // MAKECOMMON_H"
  },
  {
    "path": "Plugins/MakefileGenerator/MakeConfiguration.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: MakeConfiguration.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Janne Virtanen\r\n// Date: 17.11.2016\r\n//\r\n// Description:\r\n// Container class for make configuration.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"MakeConfiguration.h\"\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MakeConfiguration::MakeConfiguration()\r\n//-----------------------------------------------------------------------------\r\nMakeConfiguration::MakeConfiguration(SWStackParser* parser) : outputControl_(new OutputControl)\r\n{\r\n    // Must have the parser for the data.\r\n    if (!parser)\r\n    {\r\n        return;\r\n    }\r\n\r\n    // Clear the old ones.\r\n    outputControl_->getOutputs()->clear();\r\n\r\n    // Append to the master make file to the list, no VLNV is directly associated with it.\r\n    QSharedPointer<MakeDocument> masterFile(new MakeDocument);\r\n    masterFile->fileName_ = MAKEFILE_MASTER_NAME;\r\n    outputControl_->getOutputs()->append(masterFile);\r\n\r\n    foreach (QSharedPointer<MakeFileData> mfd, *parser->getParsedData())\r\n    {\r\n        // Append reference to the each proposed name of a makefile.\r\n        QSharedPointer<MakeDocument> file(new MakeDocument);\r\n        file->fileName_ = mfd->makeName;\r\n        outputControl_->getOutputs()->append(file);\r\n\r\n        // Pick the VLNV from the first stack component if exists.\r\n        if (mfd->parts.size() > 0)\r\n        {\r\n            file->vlnv_ = mfd->parts.first()->component->getVlnv().toString();\r\n        }\r\n        else\r\n        {\r\n            file->vlnv_ = \":::\";\r\n        }\r\n    }\r\n}\r\n\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MakeConfiguration::validSelections()\r\n//-----------------------------------------------------------------------------\r\nbool MakeConfiguration::validSelections(QString &warning)\r\n{\r\n    // Must have valid file output.\r\n    if (!outputControl_->validSelections(warning))\r\n    {\r\n        return false;\r\n    }\r\n\r\n   return true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MakeConfiguration::getFileOuput()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<OutputControl> MakeConfiguration::getFileOuput() const\r\n{\r\n    return outputControl_;\r\n}\r\n"
  },
  {
    "path": "Plugins/MakefileGenerator/MakeConfiguration.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: MakeConfiguration.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Janne Virtanen\r\n// Date: 17.11.2016\r\n//\r\n// Description:\r\n// Container class for make configuration.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef MAKECONFIGURATION_H\r\n#define MAKECONFIGURATION_H\r\n\r\n#include <QString>\r\n#include <QMap>\r\n#include <QSharedPointer>\r\n\r\n#include <Plugins/PluginSystem/GeneratorPlugin/OutputControl.h>\r\n\r\n#include \"SWStackParser.h\"\r\n\r\nstruct MakeDocument : public GenerationOutput\r\n{\r\n    /*!\r\n     *  Writes the content. \r\n     *\r\n     *    @param [in] outputDirectory         The possible output directory.\r\n     */\r\n\tvirtual void write(QString const& /*outputDirectory*/) override final {}\r\n    \r\n    /*!\r\n     *  Finds position for body text highlight in document, if any exists.\r\n     *\r\n\t *    @param [out] begin                  The position where the highlight begins, if successful.\r\n     *    @param [out] end                    The position where the highlight ends, if successful.\r\n     */\r\n    virtual void getBodyHighlight(int& /*begin*/, int& /*end*/) const override final {}\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Container class for make configuration.\r\n//-----------------------------------------------------------------------------\r\nclass MakeConfiguration : public QObject\r\n{\r\n    Q_OBJECT\r\n\r\npublic:\r\n\r\n\t//! The constructor.\r\n    MakeConfiguration(SWStackParser* parser);\r\n\r\n    // Disable copying.\r\n    MakeConfiguration(MakeConfiguration const& rhs) = delete;\r\n    MakeConfiguration& operator=(MakeConfiguration const& rhs) = delete;\r\n\r\n\t//! The destructor.\r\n    virtual ~MakeConfiguration() = default;\r\n    \r\n    /*!\r\n     *  Checks if the generation configuration is valid.\r\n     *\r\n     *    @param [out] warning   The stated reason for not accepting.\r\n     */\r\n    bool validSelections(QString &warning);\r\n\t\r\n    /*!\r\n     *  Gets the file output data.\r\n     */\r\n\tQSharedPointer<OutputControl> getFileOuput() const;\r\n\r\nsignals:\r\n\t\r\n    /*!\r\n     *  Emitted when output files have changed.\r\n     */\r\n\tvoid outputFilesChanged(QStringList) const;\r\n\r\nprivate:\r\n\r\n    //! The file output configuration.\r\n    QSharedPointer<OutputControl> outputControl_;\r\n};\r\n\r\n#endif // MAKECONFIGURATION_H\r\n"
  },
  {
    "path": "Plugins/MakefileGenerator/MakeParametersDialog.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: MakeParametersDialog.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Janne Virtanen\r\n// Date: 15.10.2015\r\n//\r\n// Description:\r\n// Dialog for presenting parameters, which may be chosen for makefile generation.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"MakeParametersDialog.h\"\r\n#include \"MakeConfiguration.h\"\r\n\r\n#include <QFormLayout>\r\n#include <QCheckBox>\r\n#include <QHeaderView>\r\n#include <QDialogButtonBox>\r\n#include <QGroupBox>\r\n\r\nnamespace\r\n{\r\n    //! The columns in the conflict tree view.\r\n    enum Columns\r\n    {\r\n        COLUMN_CHOOSE = 0,\r\n        COLUMN_INSTANCE,\r\n        COLUMN_FILESET,\r\n        COLUMN_COMPILER,\r\n        COLUMN_FLAGS,\r\n    };\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MakeParametersDialog()\r\n//-----------------------------------------------------------------------------\r\nMakeParametersDialog::MakeParametersDialog(QSharedPointer<MakeConfiguration> configuration,\r\n\tQSharedPointer<QList<QSharedPointer<MakeFileData> > > parsedData, QWidget* parent) : QDialog(parent),\r\n    configuration_(configuration),\r\n    fileOutput_(new FileOutputWidget(configuration->getFileOuput())),\r\n    generalWarningLabel_(new QLabel),\r\n    objectMapping_()\r\n{\r\n    // Create tree widget to display conflicts.\r\n    QTreeWidget* conflictTree = createConflictTree(parsedData);\r\n\r\n    // Expand it right away.\r\n    conflictTree->expandAll();\r\n\r\n    // Layout for things coming to the bottom part of the dialog.\r\n    QHBoxLayout* bottomLayout = new QHBoxLayout();\r\n\r\n    // Add Ok and cancel give the dialog results.\r\n    QDialogButtonBox* dialogButtons = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, \r\n        Qt::Horizontal);\r\n\r\n    // Add things in order.\r\n    bottomLayout->addWidget(generalWarningLabel_);\r\n    bottomLayout->addWidget(dialogButtons);\r\n\r\n    // Connect the buttons to correct slots.\r\n    connect(dialogButtons, SIGNAL(accepted()), this, SLOT(accept()), Qt::UniqueConnection);\r\n    connect(dialogButtons, SIGNAL(rejected()), this, SLOT(reject()), Qt::UniqueConnection);\r\n\r\n    // Signal the file output to react to the files.\r\n    fileOutput_->onOutputFilesChanged();\r\n\r\n    // Add things in order.\r\n    QVBoxLayout* mainLayout = new QVBoxLayout(this);\r\n\r\n    mainLayout->addWidget(new QLabel(\"Detected stacks with redundant source files:\"));\r\n    mainLayout->addWidget(conflictTree);\r\n    mainLayout->addWidget(fileOutput_);\r\n    mainLayout->addLayout(bottomLayout);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MakeParametersDialog::accept()\r\n//-----------------------------------------------------------------------------\r\nvoid MakeParametersDialog::accept()\r\n{\r\n    // Check it is sane.\r\n    QString warning;\r\n    if (!configuration_->validSelections(warning))\r\n    {\r\n        generalWarningLabel_->setText(warning);\r\n        return;\r\n    }\r\n\r\n    QDialog::accept();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MakeParametersDialog::onItemChanged()\r\n//-----------------------------------------------------------------------------\r\nvoid MakeParametersDialog::onItemChanged(QTreeWidgetItem *item, int column)\r\n{\r\n    // Must belong to the correct column.\r\n    if (column != COLUMN_CHOOSE)\r\n    {\r\n        return;\r\n    }\r\n\r\n    // Must be able to obtain the corresponding data.\r\n    QMap<QTreeWidgetItem*,QSharedPointer<MakeObjectData> >::iterator iter = objectMapping_.find(item);\r\n\r\n    if (iter == objectMapping_.end())\r\n    {\r\n        return;\r\n    }\r\n\r\n    QSharedPointer<MakeObjectData> object = *iter;\r\n\r\n    if (object)\r\n    {\r\n        // If found, set the corresponding state.\r\n        object->isChosen = item->checkState(COLUMN_CHOOSE) == Qt::Checked;\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MakeParametersDialog::createConflictTree()\r\n//-----------------------------------------------------------------------------\r\nQTreeWidget* MakeParametersDialog::createConflictTree(QSharedPointer<QList<QSharedPointer<MakeFileData> > > parsedData)\r\n{\r\n    QTreeWidget* conflictTree = new QTreeWidget(this);\r\n\r\n    // Conflict tree has 5 columns.\r\n    conflictTree->setColumnCount(5);\r\n\r\n    // The headers for each of the columns.\r\n    QStringList headers;\r\n    headers.append(tr(\"Choose\"));\r\n    headers.append(tr(\"Instance\"));\r\n    headers.append(tr(\"File set\"));\r\n    headers.append(tr(\"Compiler\"));\r\n    headers.append(tr(\"Flags\"));\r\n\r\n    // Put the headers in to effect.\r\n    conflictTree->setHeaderLabels(headers);\r\n\r\n    // Easier to see the different rows from one another.\r\n    conflictTree->setAlternatingRowColors(true);\r\n\r\n    // Connect the conflict tree, so that we may react to changes in it.\r\n    connect(conflictTree, SIGNAL(itemChanged(QTreeWidgetItem*, int)),\r\n        this, SLOT(onItemChanged(QTreeWidgetItem*, int)), Qt::UniqueConnection);\r\n\r\n    // Add eligible makefiles to the tree.\r\n    foreach (QSharedPointer<MakeFileData> makeData, *parsedData)\r\n    {\r\n        // Must have at least one conflict. Else it takes needlessly space from tree.\r\n        if (makeData->conflicts.size() < 1)\r\n        {\r\n            continue;\r\n        }\r\n\r\n        // The upmost level shall have the topmost instance of stack.\r\n        QString topInstance = makeData->name;\r\n        QTreeWidgetItem* instanceItem = new QTreeWidgetItem;\r\n        // Set the name as the text, append to the tree structure.\r\n        instanceItem->setText(0,topInstance);\r\n        conflictTree->addTopLevelItem(instanceItem);\r\n        // There shall be no other columns, so lets use the whole row.\r\n        instanceItem->setFirstColumnSpanned(true);\r\n\r\n        foreach (QSet<QSharedPointer<MakeObjectData> > conflictSet, makeData->conflicts)\r\n        {\r\n            // Sanity check: Must have at least two items in conflict.\r\n            if (conflictSet.size() < 2)\r\n            {\r\n                continue;\r\n            }\r\n\r\n            // Individual fiels shall be the next level.\r\n            QTreeWidgetItem* conflictItem = new QTreeWidgetItem;\r\n            // Set the path as the text, append to the tree structure.\r\n            conflictItem->setText(0, (*conflictSet.begin())->path + \"/\" + (*conflictSet.begin())->fileName);\r\n            instanceItem->addChild(conflictItem);\r\n            // There shall be no other columns, so lets use the whole row.\r\n            conflictItem->setFirstColumnSpanned(true);\r\n\r\n            // Append all interpretations of the file.\r\n            foreach (QSharedPointer<MakeObjectData> participant, conflictSet)\r\n            {\r\n                // Append to the tree structure.\r\n                QTreeWidgetItem* participantItem = new QTreeWidgetItem;\r\n                conflictItem->addChild(participantItem);\r\n                // Must map the object file data to the item.\r\n                objectMapping_[participantItem] = participant;\r\n\r\n                // Column about letting user to choose this specific object file for generation.\r\n                if (participant->isChosen)\r\n                {\r\n                    participantItem->setCheckState(COLUMN_CHOOSE, Qt::Checked);\r\n                }\r\n                else\r\n                {\r\n                    participantItem->setCheckState(COLUMN_CHOOSE, Qt::Unchecked);\r\n                }\r\n\r\n                // Column telling the instance where the object file comes from.\r\n                participantItem->setText(COLUMN_INSTANCE, participant->stackPart->instanceName);\r\n                participantItem->setToolTip(COLUMN_INSTANCE, participant->stackPart->instanceName);\r\n\r\n                // Column telling the file set where the object file comes from.\r\n                participantItem->setText(COLUMN_FILESET, participant->fileSet->name());\r\n                participantItem->setToolTip(COLUMN_FILESET, participant->fileSet->name());\r\n\r\n                // Column telling the deducted compiler for the object file.\r\n                participantItem->setText(COLUMN_COMPILER, participant->compiler);\r\n                participantItem->setToolTip(COLUMN_COMPILER, participant->compiler);\r\n\r\n                // Column telling the deducted compilation flags for the object file.\r\n                participantItem->setText(COLUMN_FLAGS, participant->flags);\r\n                participantItem->setToolTip(COLUMN_FLAGS, participant->flags);\r\n            }\r\n        }\r\n    }\r\n\r\n    // Refit the columns.\r\n    conflictTree->resizeColumnToContents(COLUMN_CHOOSE);\r\n    conflictTree->resizeColumnToContents(COLUMN_INSTANCE);\r\n    conflictTree->resizeColumnToContents(COLUMN_FILESET);\r\n    conflictTree->resizeColumnToContents(COLUMN_COMPILER);\r\n    conflictTree->resizeColumnToContents(COLUMN_FLAGS);\r\n\r\n    return conflictTree;\r\n}\r\n"
  },
  {
    "path": "Plugins/MakefileGenerator/MakeParametersDialog.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: MakeParametersDialog.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Janne Virtanen\r\n// Date: 15.10.2015\r\n//\r\n// Description:\r\n// Dialog for presenting parameters, which may be chosen for makefile generation.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef MAKEPARAMETERSDIALOG_H\r\n#define MAKEPARAMETERSDIALOG_H\r\n\r\n#include <QDialog>\r\n#include <QVBoxLayout>\r\n#include <QTreeWidget>\r\n\r\n#include \"MakefileParser.h\"\r\n#include <Plugins/PluginSystem/GeneratorPlugin/FileOutputWidget.h>\r\n\r\nclass MakeConfiguration;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! MakeParametersDialog class.\r\n//-----------------------------------------------------------------------------\r\nclass MakeParametersDialog : public QDialog\r\n{\r\n    Q_OBJECT\r\n\r\npublic:\r\n    /*!\r\n     *  Constructor.\r\n     */\r\n    MakeParametersDialog(QSharedPointer<MakeConfiguration> configuration,\r\n        QSharedPointer<QList<QSharedPointer<MakeFileData> > > parsedData, QWidget* parent);\r\n\r\n    // Disable copying.\r\n    MakeParametersDialog(MakeParametersDialog const& rhs) = delete;\r\n    MakeParametersDialog& operator=(MakeParametersDialog const& rhs) = delete;\r\n\r\n    /*!\r\n     *  Destructor.\r\n     */\r\n    virtual ~MakeParametersDialog() = default;\r\n\r\npublic slots:\r\n\r\n    virtual void accept() override;\r\n\r\nprivate slots:\r\n\r\n    void onItemChanged(QTreeWidgetItem *item, int column);\r\n\r\nprivate:\r\n\r\n    QTreeWidget* createConflictTree(QSharedPointer<QList<QSharedPointer<MakeFileData> > > parsedData);\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! The configuration for the generation.\r\n    QSharedPointer<MakeConfiguration> configuration_;\r\n\r\n    //! Widget for output file information.\r\n    FileOutputWidget* fileOutput_;\r\n\r\n    //! General warnings are displayed here.\r\n    QLabel* generalWarningLabel_;\r\n\r\n    //! Make objects mapped to table items.\r\n    QMap<QTreeWidgetItem*, QSharedPointer<MakeObjectData> > objectMapping_;\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n\r\n#endif // MAKEPARAMETERSDIALOG_H\r\n"
  },
  {
    "path": "Plugins/MakefileGenerator/MakefileGenerator.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: MakefileGenerator.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Janne Virtanen\r\n// Date: 02.09.2014\r\n//\r\n// Description:\r\n// Makefile generator.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"MakefileGenerator.h\"\r\n\r\n#include <QFile>\r\n#include <QTextStream>\r\n#include <QIODevice> \r\n#include <QFileInfo>\r\n#include <QDir>\r\n\r\n#include <IPXACTmodels/Component/FileSet.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MakefileGenerator::MakefileGenerator()\r\n//-----------------------------------------------------------------------------\r\nMakefileGenerator::MakefileGenerator(MakefileParser& parser, IPluginUtility* utility,\r\n\tQSharedPointer<FileSet> generalFileSet) :\r\n\tparsedData_(parser.getParsedData()),\r\n    utility_(utility),\r\n    generalFileSet_(generalFileSet)\r\n{\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MakefileGenerator::generate()\r\n//-----------------------------------------------------------------------------\r\nint MakefileGenerator::generate(QString const& targetPath, QString const& topPath)\r\n{\r\n    // Names of the created directories to be referenced by the master makefile.\r\n    QStringList makeNames;\r\n\r\n    // Try to create a make file out of each parsed makefile data.\r\n    for (QSharedPointer<MakeFileData> mfd : *parsedData_)\r\n    {\r\n        generateInstanceMakefile(targetPath, topPath, mfd, makeNames);\r\n    }\r\n\r\n    // Generate the main makefile only if there was any other created makefiles.\r\n\tif (makeNames.count() > 0)\r\n\t{\r\n\t\tgenerateMainMakefile(targetPath, topPath, makeNames);\r\n\t}\r\n\r\n\treturn makeNames.count();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MakefileGenerator::generateInstanceMakefile()\r\n//-----------------------------------------------------------------------------\r\nvoid MakefileGenerator::generateInstanceMakefile(QString const& targetPath, QString const& componentPath,\r\n    QSharedPointer<MakeFileData> makeData, QStringList& makeNames)\r\n{\r\n\t// Nothing to make -> no action.\r\n\tif (makeData->swObjects.count() < 1)\r\n\t{\r\n\t\tutility_->printError(\"No objects for makefile. Top instance: \" + makeData->name);\r\n\t\treturn;\r\n\t}\r\n\r\n\t// No path -> no action.\r\n\tif (makeData->makeName.isEmpty())\r\n\t{\r\n\t\tutility_->printError(\"Empty path for a makefile. Top instance: \" + makeData->name);\r\n\t\treturn;\r\n\t}\r\n\r\n    // Form the absolute bath for the makefile.\r\n    QString pathString = targetPath + \"/\" + makeData->makeName;\r\n    QFileInfo qfi(pathString);\r\n    QString absolutePathString = qfi.absolutePath() + \"/\";\r\n    // Create path as needed.\r\n    QDir makeDir(qfi.absolutePath());\r\n\r\n    if (!makeDir.exists() && !makeDir.mkdir(absolutePathString))\r\n    {\r\n        utility_->printError(\"Could not create path for the makefile: \" + absolutePathString);\r\n        return;\r\n    }\r\n\r\n    // Create the makefile.\r\n    QFile makeFile(pathString);\r\n    \r\n\t// If it cannot be written, then it is too bad.\r\n    if (!makeFile.open(QIODevice::WriteOnly))\r\n    {\r\n        utility_->printError(\"Could not open the makefile at location \" + pathString);\r\n\t\tutility_->printError(\"Reason: \" + makeFile.errorString());\r\n\t\tutility_->printError(\"Top instance: \" + makeData->name);\r\n\t\treturn;\r\n    }\r\n\r\n\t// Nicer to handle as a stream.\r\n    QTextStream outStream(&makeFile);\r\n\r\n    // Write the paths of directories containing includes.\r\n    outStream << \"_INCLUDES=\";\r\n\r\n    for (auto const& includePath : makeData->includeDirectories)\r\n    {\r\n        outStream << \" \" << General::getRelativePath(absolutePathString, includePath);\r\n    }\r\n\r\n    outStream << Qt::endl;\r\n\t// Will make the -I option out of every included directory.\r\n    outStream << \"INCLUDES=$(patsubst %, -I%, $(_INCLUDES))\" << Qt::endl << Qt::endl;\r\n\r\n    // The common dependency list.\r\n\t// Currently features only Makefile, in case a new one is generated.\r\n    outStream << \"DEPS= \" << qfi.fileName() << Qt::endl << Qt::endl;\r\n\r\n    // Other stuff is in their own functions.\r\n    writeFinalFlagsAndBuilder(makeData, outStream);\r\n    writeObjectList(makeData, outStream);\r\n\twriteExeBuild(outStream);\r\n\twriteCleanRules(outStream);\r\n\r\n\t// Create rule for using debugging and profiling options\r\n\toutStream << \"DEBUG_FLAGS +=\" << Qt::endl;\r\n\toutStream << \"debug: DEBUG_FLAGS += -ggdb -fno-omit-frame-pointer -fno-inline-functions \"\r\n\t\t\"-fno-inline-functions-called-once -fno-optimize-sibling-calls\" << Qt::endl;\r\n\toutStream << \"debug: $(ENAME)\" << Qt::endl << Qt::endl;\r\n\r\n\toutStream << \"PROFILE_FLAGS +=\" << Qt::endl;\r\n\toutStream << \"profile: PROFILE_FLAGS += -pg -fno-omit-frame-pointer -fno-inline-functions \"\r\n\t\t\"-fno-inline-functions-called-once -fno-optimize-sibling-calls\" << Qt::endl;\r\n\toutStream << \"profile: $(ENAME)\" << Qt::endl << Qt::endl;\r\n\r\n\t// Rule to include generated dependency files to the compilation.\r\n\toutStream << \"-include $(OBJ:%.o=%.d)\";\r\n\r\n\t// Write the compilation rules for the object files.\r\n    writeMakeObjects(outStream, makeData->swObjects, absolutePathString);\r\n\r\n    // Close after it is done.\r\n    makeFile.close();\r\n\r\n    // The file set is the instance file set earlier defined for the make file.\r\n    QSharedPointer<FileSet> fileSet = makeData->instanceFileSet;\r\n\r\n    // Must create a new file with path relative to the component path.\r\n    QString relPath = General::getRelativePath(componentPath, absolutePathString);\r\n\r\n    // Add the file to instance file set, if it does not exist there.\r\n    if (fileSet && !fileSet->contains(relPath))\r\n    {\r\n        QSharedPointer<File> file;\r\n        QSettings settings;\r\n        file = fileSet->addFile(relPath, settings);\r\n        file->addFileType(\"makefile\");\r\n    }\r\n\r\n    // Add to the list of created makefiles for later reference.\r\n    makeNames.append(makeData->makeName);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MakefileGenerator::generateMainMakefile()\r\n//-----------------------------------------------------------------------------\r\nvoid MakefileGenerator::generateMainMakefile(QString const& targetPath, QString const& componentPath, \r\n    QStringList& makeNames) const\r\n{\r\n    QString pathString = targetPath + \"/\" + MakeCommon::MAKEFILE_MASTER_NAME;\r\n    // Create the master makefile.\r\n    QFile makeFile(pathString);\r\n\r\n    // If it cannot be written, then it is too bad.\r\n    if (!makeFile.open(QIODevice::WriteOnly))\r\n    {\r\n        utility_->printError(\"Could not open the makefile at location \" + pathString);\r\n        utility_->printError(\"Reason: \" + makeFile.errorString());\r\n        return;\r\n    }\r\n\r\n    // Nicer to handle as a stream.\r\n    QTextStream outStream(&makeFile);\r\n\r\n    // Default target for each directory.\r\n    outStream << \"make:\";\r\n\r\n    for (auto const& directory : makeNames)\r\n    {\r\n        QFileInfo qfi(targetPath + \"/\" + directory);\r\n        outStream << Qt::endl << \"\\t(cd \" << General::getRelativePath(targetPath, qfi.absolutePath()) << \"; make -f \" << qfi.fileName() << \")\";\r\n    }\r\n\r\n    // Needs also cleaner for each directory.\r\n    outStream << Qt::endl << Qt::endl << \"clean:\";\r\n\r\n    for (auto const& directory : makeNames)\r\n    {\r\n        QFileInfo qfi(targetPath + \"/\" + directory);\r\n        outStream << Qt::endl << \"\\t(cd \" << General::getRelativePath(targetPath, qfi.absolutePath()) << \"; make clean -f \" << qfi.fileName() << \")\";\r\n\t}\r\n\r\n\t// Debug target for each directory.\r\n\toutStream << Qt::endl << Qt::endl << \"debug:\";\r\n\r\n\tfor (auto const& directory : makeNames)\r\n    {\r\n        QFileInfo qfi(targetPath + \"/\" + directory);\r\n        outStream << Qt::endl << \"\\t(cd \" << General::getRelativePath(targetPath, qfi.absolutePath()) << \"; make debug -f \" << qfi.fileName() << \")\";\r\n\t}\r\n\r\n\t// Profiling target for each directory.\r\n\toutStream << Qt::endl << Qt::endl << \"profile:\";\r\n\r\n\tfor (auto const& directory : makeNames)\r\n    {\r\n        QFileInfo qfi(targetPath + \"/\" + directory);\r\n\t\toutStream << Qt::endl << \"\\t(cd \" << General::getRelativePath(targetPath, qfi.absolutePath()) << \"; make profile -f \" << qfi.fileName() << \")\";\r\n\t}\r\n\r\n    // Close after it is done.\r\n    makeFile.close();\r\n\r\n    // The path in the fileSet must be relative to the basePath.\r\n    QString relDir = General::getRelativePath(componentPath, pathString);\r\n\r\n    // Add the file to instance fileSet\r\n    if (generalFileSet_ && !generalFileSet_->contains(relDir))\r\n    {\r\n        QSharedPointer<File> file;\r\n        QSettings settings;\r\n        file = generalFileSet_->addFile(relDir, settings);\r\n        file->addFileType(\"makefile\");\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MakefileGenerator::writeFinalFlagsAndBuilder()\r\n//-----------------------------------------------------------------------------\r\nvoid MakefileGenerator::writeFinalFlagsAndBuilder(QSharedPointer<MakeFileData> mfd, QTextStream& outStream) const\r\n{\r\n    QString finalFlags = \"$(INCLUDES) $(DEBUG_FLAGS) $(PROFILE_FLAGS)\";\r\n    QString finalBuilder;\r\n\r\n    // If build command of software view of the hardware instance exist, its properties are used.\r\n    if (mfd->hardPart->buildCmd != 0)\r\n    {\r\n        finalBuilder = mfd->hardPart->buildCmd->getCommand();\r\n\r\n        finalFlags += \" \" + mfd->hardPart->buildCmd->getFlags();\r\n    }\r\n\r\n    // All flags of all software views must be appended to the flags.\r\n    for (auto const& flag : mfd->componentInstantiationFlags)\r\n    {\r\n        finalFlags += \" \" + flag;\r\n    }\r\n\r\n    // Finally, write down what we learned.\r\n    outStream << \"ENAME= \" << mfd->name << Qt::endl;\r\n    outStream << \"EFLAGS= \" << finalFlags << Qt::endl;\r\n    outStream << \"EBUILDER= \" << finalBuilder << Qt::endl;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MakefileGenerator::writeObjectList()\r\n//-----------------------------------------------------------------------------\r\nvoid MakefileGenerator::writeObjectList(QSharedPointer<MakeFileData> mfd, QTextStream& outStream) const\r\n{\r\n    // Include files are skipped and the object file is simply original filename + \".o\".\r\n    outStream << \"_OBJ=\";\r\n\r\n    for (QSharedPointer<MakeObjectData> mod : mfd->swObjects)\r\n    {\r\n        if (!mod->compiler.isEmpty())\r\n        {\r\n            outStream << \" \" << mod->fileName << \".o\";\r\n        }\r\n    }\r\n\r\n    // Finally, write down what we learned.\r\n    outStream << Qt::endl;\r\n    outStream << \"ODIR= obj\" << Qt::endl;\r\n    outStream << \"OBJ= $(patsubst %,$(ODIR)/%,$(_OBJ))\" << Qt::endl << Qt::endl;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MakefileGenerator::writeExeBuild()\r\n//-----------------------------------------------------------------------------\r\nvoid MakefileGenerator::writeExeBuild(QTextStream& outStream) const\r\n{\r\n    // Rather straight forward: write constant build rule and a cleaner rule.\r\n    outStream << \"$(ENAME): $(OBJ)\" << Qt::endl;\r\n    outStream << \"\\t$(EBUILDER) -o $(ENAME) $(OBJ) $(EFLAGS)\"\r\n        << Qt::endl << Qt::endl;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MakefileGenerator::writeCleanRules()\r\n//-----------------------------------------------------------------------------\r\nvoid MakefileGenerator::writeCleanRules(QTextStream& outStream) const\r\n{\r\n\t// Delete all known object files. May leave renamed files undeleted, but is more secure than deleting all\r\n\t// content of the object directory.\r\n\toutStream << \"clean:\" << Qt::endl;\r\n\toutStream << \"\\trm -f $(OBJ:%.o=%.d);\" << Qt::endl;\r\n\toutStream << \"\\trm -f $(OBJ);\" << Qt::endl << Qt::endl;\r\n\r\n\t// Make a directory for the object files.\r\n\toutStream << \"all: $(OBJ)\" << Qt::endl << Qt::endl;\r\n\toutStream << \"$(OBJ): | $(ODIR)\" << Qt::endl << Qt::endl;\r\n\toutStream << \"$(ODIR):\" << Qt::endl << \"\\tmkdir -p $(ODIR)\" << Qt::endl << Qt::endl;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MakefileGenerator::writeMakeObjects()\r\n//-----------------------------------------------------------------------------\r\nvoid MakefileGenerator::writeMakeObjects(QTextStream& outStream, \r\n    QList<QSharedPointer<MakeObjectData> > const& objects, QString instancePath) const\r\n{\r\n    for (QSharedPointer<MakeObjectData> mod : objects)\r\n    {\r\n        // Compilerless files are skipped. Moreover, use may have opted for exclusion.\r\n        if (!mod->isChosen || mod->compiler.isEmpty())\r\n        {\r\n            continue;\r\n        }\r\n\r\n        // Flags will always include at least the includes, and possibility for debug and profiling flags.\r\n        QString cFlags = \"$(INCLUDES) $(DEBUG_FLAGS) $(PROFILE_FLAGS) \";\r\n\r\n        // More flags may come from the parsed data.\r\n        cFlags += mod->flags;\r\n\r\n        // The relative path is needed by the make and the builder to access the source file.\r\n        QString relPath = General::getRelativePath(instancePath,mod->path);\r\n        QString fileName = mod->fileName;\r\n\r\n        // Write the rule for building the individual object file, including dependencies.\r\n        outStream << Qt::endl << Qt::endl;\r\n        outStream << \"$(ODIR)/\" << fileName << \".o: $(DEPS) \" << relPath << \"/\" << fileName << Qt::endl;\r\n        outStream << \"\\t\" << mod->compiler << \" \" << DEFAULT_OBJECT_FLAGS << \" $(ODIR)/\" << fileName << \".o \" <<\r\n            relPath << \"/\" << fileName << \" \" << cFlags;\r\n    }\r\n}\r\n"
  },
  {
    "path": "Plugins/MakefileGenerator/MakefileGenerator.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: MakefileGenerator.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Janne Virtanen\r\n// Date: 02.09.2014\r\n//\r\n// Description:\r\n// Makefile generator.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef MAKEFILEGENERATOR_H\r\n#define MAKEFILEGENERATOR_H\r\n\r\n#include \"MakefileParser.h\"\r\n#include \"MakeCommon.h\"\r\n\r\n#include <KactusAPI/include/IPluginUtility.h>\r\n\r\nclass MakefileGenerator\r\n{\r\npublic:\r\n    /*!\r\n     *  The constructor.\r\n     *\r\n     *    @param [in] parser          The parser which parsed the meta data to data structures directly usable by the generator.\r\n     *    @param [in] utility         The provided plugin utility.\r\n     *    @param [in] generalFileSet  The file set, where design configuration specific things belong to.\r\n     */\r\n    MakefileGenerator( MakefileParser& parser, IPluginUtility* utility, \r\n        QSharedPointer<FileSet> generalFileSet );\r\n    \r\n    //! Disable copying.\r\n    MakefileGenerator(MakefileGenerator const& other) = delete;\r\n    MakefileGenerator& operator=(MakefileGenerator const& other) = delete;\r\n\r\n    /*!\r\n     *  The destructor.\r\n     */\r\n    ~MakefileGenerator() = default;\r\n\r\n    /*!\r\n     *  Generates all makefiles based on the parsed data.\r\n     *\r\n     *    @param [in] targetPath\t\tThe path, where the makefiles are created.\r\n\t *    @param [in] topPath\t\t\tThe path, where the top component is.\r\n\t *    @param [in] sysViewName\t\tName of the system view pointing to used design configuration.\r\n\t *\r\n\t *    @return How many executables got a makefile.\r\n\t */\r\n\tint generate(QString const& targetPath, QString const& topPath);\r\n\r\n\r\nprivate:\r\n\r\n    /*!\r\n     *  Creates a makefile for a single software instance, and thus for a single executable.\r\n     *  The makefile is also placed to the instance headers. Will add the name to makeNames.\r\n     *\r\n     *    @param [in] targetPath  The path, where the makefiles are created.\r\n     *    @param [in] componentPath     The path of the component which will be associated with the created make file.\r\n     *    @param [in] makeData    The make data associated with the makefile as whole.\r\n     *    @param [in/out] makeNames   The directory of the created makefile must be added here.\r\n     */\r\n    void generateInstanceMakefile(QString const& targetPath, QString const& componentPath,\r\n\t\tQSharedPointer<MakeFileData> makeData, QStringList& makeNames);\r\n\r\n    /*!\r\n     *  Creates a makefile calling all the other makefiles associated with the design.\r\n     *  The makefile is also placed to the instance headers.\r\n     *\r\n     *    @param [in] basePath        The path, where the makefile is created.\r\n     *    @param [in] componentPath   The path of the component which will be associated with the created make file.\r\n     *    @param [in] makeNames   The names of all created make files so far.\r\n     */\r\n    void generateMainMakefile(QString const& targetPath, QString const& componentPath, QStringList& makeNames) const;\r\n\r\n    /*!\r\n     *  Writes data used in building the executable to the stream.\r\n     *\r\n     *    @param [in] mfd   The make data associated with the makefile as whole.\r\n     *    @param [in] outStream   The stream where the makefile is written.\r\n     */\r\n     void writeFinalFlagsAndBuilder(QSharedPointer<MakeFileData> mfd, QTextStream& outStream) const;\r\n\r\n    /*!\r\n     *  Writes the list of the built and used objects to the stream.\r\n     *\r\n     *    @param [in] mfd   The make data associated with the makefile as whole.\r\n     *    @param [in] outStream   The stream where the makefile is written.\r\n     */\r\n     void writeObjectList(QSharedPointer<MakeFileData> mfd, QTextStream& outStream) const;\r\n\r\n    /*!\r\n     *  Writes the build command of the executable to the stream.\r\n     *\r\n     *    @param [in] outStream   The stream where the makefile is written.\r\n     */\r\n     void writeExeBuild(QTextStream& outStream) const;\r\n\t \r\n    /*!\r\n     *  Writes the cleaning rules for makefile, which removes both object and dependency files.\r\n     *\r\n     *    @param [in] outStream   The stream where the makefile is written.\r\n     */\r\n\t void writeCleanRules(QTextStream& outStream) const;\r\n\r\n    /*!\r\n     *  Writes the build rules for the object files of the makefile.\r\n     *\r\n     *    @param [in] outStream   The stream where the makefile is written.\r\n     *    @param [in] objects   The list of the objects written.\r\n     *    @param [in] instancePath   Path of the makefile and thus the path where it is called from.\r\n     */\r\n     void writeMakeObjects(QTextStream& outStream,\r\n\t\t QList<QSharedPointer<MakeObjectData> > const& objects, QString instancePath) const;\r\n\r\n     //-----------------------------------------------------------------------------\r\n     // Data.\r\n     //-----------------------------------------------------------------------------\r\n\r\n      //! Collection of data sets, one for each makefile.\r\n      QSharedPointer<QList<QSharedPointer<MakeFileData> > > parsedData_;\r\n\r\n      //! The utility used to print message and etc.\r\n      IPluginUtility* utility_;\r\n\r\n      //! The fileSet for the main makefile and the launcher.\r\n      QSharedPointer<FileSet> generalFileSet_;\r\n\r\n      QString mainMakeName_;\r\n\r\n};\r\n\r\n#endif // MAKEFILEGENERATOR_H\r\n"
  },
  {
    "path": "Plugins/MakefileGenerator/MakefileGenerator.pri",
    "content": "# ----------------------------------------------------\r\n# This file is generated by the Qt Visual Studio Tools.\r\n# ------------------------------------------------------\r\n\r\nHEADERS += ../../common/NameGenerationPolicy.h \\\r\n    ../PluginSystem/GeneratorPlugin/OutputControl.h \\\r\n    ./MakeCommon.h \\\r\n    ./MakefileGenerator.h \\\r\n    ./MakefileParser.h \\\r\n    ./SWStackParser.h \\\r\n    ./makefilegenerator_global.h \\\r\n    ../PluginSystem/GeneratorPlugin/FileOutputWidget.h \\\r\n    ./MakeConfiguration.h \\\r\n    ./MakeParametersDialog.h \\\r\n    ./MakefileGeneratorPlugin.h\r\nSOURCES += ../../common/NameGenerationPolicy.cpp \\\r\n    ../PluginSystem/GeneratorPlugin/FileOutputWidget.cpp \\\r\n    ../PluginSystem/GeneratorPlugin/OutputControl.cpp \\\r\n    ./MakeConfiguration.cpp \\\r\n    ./MakefileGenerator.cpp \\\r\n    ./MakefileGeneratorPlugin.cpp \\\r\n    ./MakefileParser.cpp \\\r\n    ./MakeParametersDialog.cpp \\\r\n    ./SWStackParser.cpp\r\nRESOURCES += MakefileGenerator.qrc\r\n"
  },
  {
    "path": "Plugins/MakefileGenerator/MakefileGenerator.pro",
    "content": "# ----------------------------------------------------\r\n# This file is generated by the Qt Visual Studio Add-in.\r\n# ------------------------------------------------------\r\n\r\nTEMPLATE = lib\r\nTARGET = MakefileGenerator\r\n\r\nQT += core xml widgets gui\r\n\r\nCONFIG += c++11 plugin\r\nDEFINES += MAKEFILEGENERATOR_LIB\r\n\r\nINCLUDEPATH += ./../.. \\\r\n    ./GeneratedFiles \\\r\n    .\r\n\r\nCONFIG(debug, debug|release) {\r\n    # debug mode\r\n    LIBS += \\\r\n        -L../../executable -lIPXACTmodelsd \\\r\n        -L../../executable -lKactusAPId\r\n\r\n    MOC_DIR += ./GeneratedFiles/Debug\r\n    OBJECTS_DIR += Debug\r\n    TARGET = MakefileGeneratord\r\n\r\n} else {\r\n    # release mode \r\n    LIBS += \\\r\n        -L../../executable -lIPXACTmodels \\\r\n        -L../../executable -lKactusAPI\r\n    \r\n    MOC_DIR += ./GeneratedFiles/Release\r\n    OBJECTS_DIR += Release\r\n    TARGET = MakefileGenerator\r\n}\r\n\r\nDESTDIR = ../../executable/Plugins\r\n\r\nDEPENDPATH += .\r\nUI_DIR += ./GeneratedFiles\r\nRCC_DIR += ./GeneratedFiles\r\ninclude(MakefileGenerator.pri)\r\n\r\ntarget.path = $$plugin_path\r\nINSTALLS += target\r\n"
  },
  {
    "path": "Plugins/MakefileGenerator/MakefileGenerator.qrc",
    "content": "<RCC>\r\n    <qresource prefix=\"/icons\">\r\n        <file>MakefileGenerator.png</file>\r\n    </qresource>\r\n</RCC>\r\n"
  },
  {
    "path": "Plugins/MakefileGenerator/MakefileGenerator.vcxproj",
    "content": "﻿<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n<Project DefaultTargets=\"Build\" ToolsVersion=\"15.0\" xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">\r\n  <ItemGroup Label=\"ProjectConfigurations\">\r\n    <ProjectConfiguration Include=\"Debug|x64\">\r\n      <Configuration>Debug</Configuration>\r\n      <Platform>x64</Platform>\r\n    </ProjectConfiguration>\r\n    <ProjectConfiguration Include=\"Release|x64\">\r\n      <Configuration>Release</Configuration>\r\n      <Platform>x64</Platform>\r\n    </ProjectConfiguration>\r\n  </ItemGroup>\r\n  <PropertyGroup Label=\"Globals\">\r\n    <ProjectGuid>{7ED945F7-9538-4306-A770-4A186327F8BF}</ProjectGuid>\r\n    <Keyword>QtVS_v304</Keyword>\r\n    <WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>\r\n    <QtMsBuild Condition=\"'$(QtMsBuild)'=='' or !Exists('$(QtMsBuild)\\qt.targets')\">$(MSBuildProjectDirectory)\\QtMsBuild</QtMsBuild>\r\n  </PropertyGroup>\r\n  <Import Project=\"$(VCTargetsPath)\\Microsoft.Cpp.Default.props\" />\r\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\" Label=\"Configuration\">\r\n    <ConfigurationType>DynamicLibrary</ConfigurationType>\r\n    <PlatformToolset>v143</PlatformToolset>\r\n  </PropertyGroup>\r\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\" Label=\"Configuration\">\r\n    <ConfigurationType>DynamicLibrary</ConfigurationType>\r\n    <PlatformToolset>v143</PlatformToolset>\r\n  </PropertyGroup>\r\n  <Import Project=\"$(VCTargetsPath)\\Microsoft.Cpp.props\" />\r\n  <Target Name=\"QtMsBuildNotFound\" BeforeTargets=\"CustomBuild;ClCompile\" Condition=\"!Exists('$(QtMsBuild)\\qt.targets') or !Exists('$(QtMsBuild)\\qt.props')\">\r\n    <Message Importance=\"High\" Text=\"QtMsBuild: could not locate qt.targets, qt.props; project may not build correctly.\" />\r\n  </Target>\r\n  <ImportGroup Label=\"ExtensionSettings\">\r\n  </ImportGroup>\r\n  <ImportGroup Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\" Label=\"PropertySheets\">\r\n    <Import Project=\"$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props\" Condition=\"exists('$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props')\" Label=\"LocalAppDataPlatform\" />\r\n  </ImportGroup>\r\n  <ImportGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\" Label=\"PropertySheets\">\r\n    <Import Project=\"$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props\" Condition=\"exists('$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props')\" Label=\"LocalAppDataPlatform\" />\r\n  </ImportGroup>\r\n  <PropertyGroup Label=\"UserMacros\" />\r\n  <ImportGroup Condition=\"Exists('$(QtMsBuild)\\qt_defaults.props')\">\r\n    <Import Project=\"$(QtMsBuild)\\qt_defaults.props\" />\r\n  </ImportGroup>\r\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n    <OutDir>$(SolutionDir)executable\\Plugins\\</OutDir>\r\n  </PropertyGroup>\r\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n    <OutDir>$(SolutionDir)executable\\Plugins\\</OutDir>\r\n  </PropertyGroup>\r\n  <PropertyGroup Label=\"QtSettings\" Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n    <QtInstall>6.2.4</QtInstall>\r\n    <QtModules>core;gui;widgets;xml</QtModules>\r\n  </PropertyGroup>\r\n  <PropertyGroup Label=\"QtSettings\" Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n    <QtInstall>6.2.4</QtInstall>\r\n    <QtModules>core;gui;widgets;xml</QtModules>\r\n  </PropertyGroup>\r\n  <ImportGroup Condition=\"Exists('$(QtMsBuild)\\qt.props')\">\r\n    <Import Project=\"$(QtMsBuild)\\qt.props\" />\r\n  </ImportGroup>\r\n  <PropertyGroup>\r\n    <_ProjectFileVersion>10.0.40219.1</_ProjectFileVersion>\r\n  </PropertyGroup>\r\n  <ItemDefinitionGroup Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n    <ClCompile>\r\n      <PreprocessorDefinitions>MAKEFILEGENERATOR_LIB;UNICODE;WIN32;WIN64;%(PreprocessorDefinitions)</PreprocessorDefinitions>\r\n      <AdditionalIncludeDirectories>.\\GeneratedFiles\\$(ConfigurationName);.\\GeneratedFiles;.\\..\\..;.;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\r\n      <Optimization>Disabled</Optimization>\r\n      <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>\r\n      <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>\r\n      <TreatWChar_tAsBuiltInType>true</TreatWChar_tAsBuiltInType>\r\n      <LanguageStandard>stdcpp17</LanguageStandard>\r\n      <AdditionalOptions>/Zc:__cplusplus %(AdditionalOptions)</AdditionalOptions>\r\n      <MultiProcessorCompilation>true</MultiProcessorCompilation>\r\n    </ClCompile>\r\n    <Link>\r\n      <SubSystem>Windows</SubSystem>\r\n      <OutputFile>$(OutDir)\\$(ProjectName).dll</OutputFile>\r\n      <AdditionalLibraryDirectories>..\\..\\executable;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>\r\n      <GenerateDebugInformation>true</GenerateDebugInformation>\r\n      <AdditionalDependencies>IPXACTmodelsd.lib;KactusAPId.lib;%(AdditionalDependencies)</AdditionalDependencies>\r\n      <TargetMachine>MachineX64</TargetMachine>\r\n      <AdditionalOptions> /SUBSYSTEM:WINDOWS</AdditionalOptions>\r\n    </Link>\r\n    <QtMoc>\r\n      <ExecutionDescription>Moc'ing %(Identity)...</ExecutionDescription>\r\n      <DynamicSource>output</DynamicSource>\r\n      <QtMocDir>.\\GeneratedFiles\\$(ConfigurationName)</QtMocDir>\r\n      <QtMocFileName>moc_%(Filename).cpp</QtMocFileName>\r\n    </QtMoc>\r\n    <QtRcc>\r\n      <InitFuncName>%(Filename)</InitFuncName>\r\n      <Compression>default</Compression>\r\n      <NoCompression>true</NoCompression>\r\n      <ExecutionDescription>Rcc'ing %(Identity)...</ExecutionDescription>\r\n      <QtRccDir>.\\GeneratedFiles</QtRccDir>\r\n      <QtRccFileName>qrc_%(Filename).cpp</QtRccFileName>\r\n    </QtRcc>\r\n  </ItemDefinitionGroup>\r\n  <ItemDefinitionGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n    <ClCompile>\r\n      <PreprocessorDefinitions>MAKEFILEGENERATOR_LIB;NDEBUG;QT_NO_DEBUG;UNICODE;WIN32;WIN64;%(PreprocessorDefinitions)</PreprocessorDefinitions>\r\n      <AdditionalIncludeDirectories>.\\GeneratedFiles\\$(ConfigurationName);.\\GeneratedFiles;.\\..\\..;.;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\r\n      <DebugInformationFormat>\r\n      </DebugInformationFormat>\r\n      <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>\r\n      <TreatWChar_tAsBuiltInType>true</TreatWChar_tAsBuiltInType>\r\n      <MultiProcessorCompilation>true</MultiProcessorCompilation>\r\n      <AdditionalOptions>/Zc:__cplusplus %(AdditionalOptions)</AdditionalOptions>\r\n      <LanguageStandard>stdcpp17</LanguageStandard>\r\n    </ClCompile>\r\n    <Link>\r\n      <SubSystem>Windows</SubSystem>\r\n      <OutputFile>$(OutDir)\\$(ProjectName).dll</OutputFile>\r\n      <AdditionalLibraryDirectories>..\\..\\executable;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>\r\n      <GenerateDebugInformation>false</GenerateDebugInformation>\r\n      <AdditionalDependencies>IPXACTmodels.lib;KactusAPI.lib;%(AdditionalDependencies)</AdditionalDependencies>\r\n      <TargetMachine>MachineX64</TargetMachine>\r\n      <AdditionalOptions> /SUBSYSTEM:WINDOWS</AdditionalOptions>\r\n    </Link>\r\n    <QtMoc>\r\n      <ExecutionDescription>Moc'ing %(Identity)...</ExecutionDescription>\r\n      <DynamicSource>output</DynamicSource>\r\n      <QtMocDir>.\\GeneratedFiles\\$(ConfigurationName)</QtMocDir>\r\n      <QtMocFileName>moc_%(Filename).cpp</QtMocFileName>\r\n    </QtMoc>\r\n    <QtRcc>\r\n      <InitFuncName>%(Filename)</InitFuncName>\r\n      <Compression>default</Compression>\r\n      <NoCompression>true</NoCompression>\r\n      <ExecutionDescription>Rcc'ing %(Identity)...</ExecutionDescription>\r\n      <QtRccDir>.\\GeneratedFiles</QtRccDir>\r\n      <QtRccFileName>qrc_%(Filename).cpp</QtRccFileName>\r\n    </QtRcc>\r\n  </ItemDefinitionGroup>\r\n  <ItemGroup>\r\n    <ClCompile Include=\"..\\..\\common\\NameGenerationPolicy.cpp\" />\r\n    <ClCompile Include=\"..\\PluginSystem\\GeneratorPlugin\\FileOutputWidget.cpp\" />\r\n    <ClCompile Include=\"..\\PluginSystem\\GeneratorPlugin\\OutputControl.cpp\" />\r\n    <ClCompile Include=\"MakeConfiguration.cpp\" />\r\n    <ClCompile Include=\"MakefileGenerator.cpp\" />\r\n    <ClCompile Include=\"MakefileGeneratorPlugin.cpp\" />\r\n    <ClCompile Include=\"MakefileParser.cpp\" />\r\n    <ClCompile Include=\"MakeParametersDialog.cpp\" />\r\n    <ClCompile Include=\"SWStackParser.cpp\" />\r\n  </ItemGroup>\r\n  <ItemGroup>\r\n    <ClInclude Include=\"..\\..\\common\\NameGenerationPolicy.h\" />\r\n    <ClInclude Include=\"..\\..\\editors\\ComponentEditor\\common\\SystemVerilogSyntax.h\" />\r\n    <QtMoc Include=\"..\\PluginSystem\\GeneratorPlugin\\FileOutputWidget.h\">\r\n    </QtMoc>\r\n    <ClInclude Include=\"..\\PluginSystem\\GeneratorPlugin\\OutputControl.h\" />\r\n    <ClInclude Include=\"MakeCommon.h\" />\r\n    <QtMoc Include=\"MakeConfiguration.h\">\r\n    </QtMoc>\r\n    <ClInclude Include=\"MakefileGenerator.h\" />\r\n    <ClInclude Include=\"MakefileParser.h\" />\r\n    <QtMoc Include=\"MakeParametersDialog.h\">\r\n    </QtMoc>\r\n    <ClInclude Include=\"SWStackParser.h\" />\r\n    <QtMoc Include=\"MakefileGeneratorPlugin.h\">\r\n    </QtMoc>\r\n    <ClInclude Include=\"makefilegenerator_global.h\" />\r\n  </ItemGroup>\r\n  <ItemGroup>\r\n    <None Include=\"makefile.json\" />\r\n    <None Include=\"MakefileGenerator.png\">\r\n      <ExcludedFromBuild Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">true</ExcludedFromBuild>\r\n      <ExcludedFromBuild Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">true</ExcludedFromBuild>\r\n    </None>\r\n    <QtRcc Include=\"MakefileGenerator.qrc\">\r\n    </QtRcc>\r\n  </ItemGroup>\r\n  <Import Project=\"$(VCTargetsPath)\\Microsoft.Cpp.targets\" />\r\n  <ImportGroup Condition=\"Exists('$(QtMsBuild)\\qt.targets')\">\r\n    <Import Project=\"$(QtMsBuild)\\qt.targets\" />\r\n  </ImportGroup>\r\n  <ImportGroup Label=\"ExtensionTargets\">\r\n  </ImportGroup>\r\n  <ProjectExtensions>\r\n    <VisualStudio>\r\n      <UserProperties />\r\n    </VisualStudio>\r\n  </ProjectExtensions>\r\n</Project>"
  },
  {
    "path": "Plugins/MakefileGenerator/MakefileGenerator.vcxproj.filters",
    "content": "﻿<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n<Project ToolsVersion=\"4.0\" xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">\r\n  <ItemGroup>\r\n    <Filter Include=\"Source Files\">\r\n      <UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>\r\n      <Extensions>cpp;cxx;c;def</Extensions>\r\n    </Filter>\r\n    <Filter Include=\"Header Files\">\r\n      <UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>\r\n      <Extensions>h</Extensions>\r\n    </Filter>\r\n    <Filter Include=\"Generated Files\">\r\n      <UniqueIdentifier>{71ED8ED8-ACB9-4CE9-BBE1-E00B30144E11}</UniqueIdentifier>\r\n      <Extensions>moc;h;cpp</Extensions>\r\n      <SourceControlFiles>False</SourceControlFiles>\r\n    </Filter>\r\n    <Filter Include=\"Generated Files\\Debug\">\r\n      <UniqueIdentifier>{1cab6335-8bf0-428b-b527-f4a97b93cf03}</UniqueIdentifier>\r\n      <Extensions>cpp;moc</Extensions>\r\n      <SourceControlFiles>False</SourceControlFiles>\r\n    </Filter>\r\n    <Filter Include=\"Generated Files\\Release\">\r\n      <UniqueIdentifier>{bcbe60b9-a5b8-4d37-b79f-8c561fe0c86a}</UniqueIdentifier>\r\n      <Extensions>cpp;moc</Extensions>\r\n      <SourceControlFiles>False</SourceControlFiles>\r\n    </Filter>\r\n    <Filter Include=\"Resource Files\">\r\n      <UniqueIdentifier>{D9D6E242-F8AF-46E4-B9FD-80ECBC20BA3E}</UniqueIdentifier>\r\n      <Extensions>qrc;*</Extensions>\r\n      <ParseFiles>false</ParseFiles>\r\n    </Filter>\r\n  </ItemGroup>\r\n  <ItemGroup>\r\n    <ClCompile Include=\"MakefileGenerator.cpp\">\r\n      <Filter>Source Files</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"MakefileGeneratorPlugin.cpp\">\r\n      <Filter>Source Files</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"MakefileParser.cpp\">\r\n      <Filter>Source Files</Filter>\r\n    </ClCompile>\r\n    \r\n    \r\n    \r\n    <ClCompile Include=\"SWStackParser.cpp\">\r\n      <Filter>Source Files</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"MakeParametersDialog.cpp\">\r\n      <Filter>Source Files</Filter>\r\n    </ClCompile>\r\n    \r\n    \r\n    \r\n    \r\n    <ClCompile Include=\"..\\PluginSystem\\GeneratorPlugin\\FileOutputWidget.cpp\">\r\n      <Filter>Source Files</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"MakeConfiguration.cpp\">\r\n      <Filter>Source Files</Filter>\r\n    </ClCompile>\r\n    \r\n    \r\n    <ClCompile Include=\"..\\PluginSystem\\GeneratorPlugin\\OutputControl.cpp\">\r\n      <Filter>Source Files</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\common\\NameGenerationPolicy.cpp\">\r\n      <Filter>Source Files</Filter>\r\n    </ClCompile>\r\n  </ItemGroup>\r\n  <ItemGroup>\r\n    <ClInclude Include=\"MakefileGenerator.h\">\r\n      <Filter>Header Files</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"makefilegenerator_global.h\">\r\n      <Filter>Header Files</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"MakefileParser.h\">\r\n      <Filter>Header Files</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\editors\\ComponentEditor\\common\\SystemVerilogSyntax.h\">\r\n      <Filter>Header Files</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"MakeCommon.h\">\r\n      <Filter>Header Files</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"SWStackParser.h\">\r\n      <Filter>Header Files</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\PluginSystem\\GeneratorPlugin\\OutputControl.h\">\r\n      <Filter>Header Files</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\common\\NameGenerationPolicy.h\">\r\n      <Filter>Header Files</Filter>\r\n    </ClInclude>\r\n  </ItemGroup>\r\n  <ItemGroup>\r\n    <QtMoc Include=\"MakefileGeneratorPlugin.h\">\r\n      <Filter>Header Files</Filter>\r\n    </QtMoc>\r\n    <QtRcc Include=\"MakefileGenerator.qrc\">\r\n      <Filter>Resource Files</Filter>\r\n    </QtRcc>\r\n    <QtMoc Include=\"MakeParametersDialog.h\">\r\n      <Filter>Header Files</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"..\\PluginSystem\\GeneratorPlugin\\FileOutputWidget.h\">\r\n      <Filter>Header Files</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"MakeConfiguration.h\">\r\n      <Filter>Header Files</Filter>\r\n    </QtMoc>\r\n  </ItemGroup>\r\n  <ItemGroup>\r\n    <None Include=\"MakefileGenerator.png\">\r\n      <Filter>Resource Files</Filter>\r\n    </None>\r\n    <None Include=\"makefile.json\" />\r\n  </ItemGroup>\r\n</Project>"
  },
  {
    "path": "Plugins/MakefileGenerator/MakefileGeneratorPlugin.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: MakefileGeneratorPlugin.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Janne Virtanen\r\n// Date: 15.9.2014\r\n//\r\n// Description:\r\n// Makefile generator plugin.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"MakefileGenerator.h\"\r\n#include \"MakefileGeneratorPlugin.h\"\r\n#include \"MakeParametersDialog.h\"\r\n#include \"MakeConfiguration.h\"\r\n\r\n#include <QCoreApplication>\r\n#include <QFileInfo>\r\n#include <QMessageBox>\r\n#include <QDir>\r\n\r\n#include <IPXACTmodels/kactusExtensions/SystemView.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MakefileGeneratorPlugin::MakefileGeneratorPlugin()\r\n//-----------------------------------------------------------------------------\r\nMakefileGeneratorPlugin::MakefileGeneratorPlugin() : QObject(nullptr)\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MakefileGeneratorPlugin::getName()\r\n//----------------------------------------------------------------------------\r\nQString MakefileGeneratorPlugin::getName() const\r\n{\r\n    return \"Makefile Generator\";\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MakefileGeneratorPlugin::getVersion()\r\n//-----------------------------------------------------------------------------\r\nQString MakefileGeneratorPlugin::getVersion() const\r\n{\r\n    return \"1.4\";\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MakefileGeneratorPlugin::getDescription()\r\n//-----------------------------------------------------------------------------\r\nQString MakefileGeneratorPlugin::getDescription() const\r\n{\r\n    return \"Generates C/C++ makefiles for a system design.\";\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MakefileGeneratorPlugin::getVendor()\r\n//-----------------------------------------------------------------------------\r\nQString MakefileGeneratorPlugin::getVendor() const\r\n{\r\n    return tr(\"Tampere University (tuni.fi)\");\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MakefileGeneratorPlugin::getLicense()\r\n//-----------------------------------------------------------------------------\r\nQString MakefileGeneratorPlugin::getLicense() const\r\n{\r\n    return tr(\"GPL2\");\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MakefileGeneratorPlugin::getLicenseHolder()\r\n//-----------------------------------------------------------------------------\r\nQString MakefileGeneratorPlugin::getLicenseHolder() const\r\n{\r\n    return tr(\"Public\");\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MakefileGeneratorPlugin::getSettingsWidget()\r\n//-----------------------------------------------------------------------------\r\nQWidget* MakefileGeneratorPlugin::getSettingsWidget()\r\n{\r\n    return nullptr;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MakefileGeneratorPlugin::getIcon()\r\n//-----------------------------------------------------------------------------\r\nQIcon MakefileGeneratorPlugin::getIcon() const\r\n{\r\n    return QIcon(\":icons/MakefileGenerator.png\");\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MakefileGeneratorPlugin::checkGeneratorSupport()\r\n//-----------------------------------------------------------------------------\r\nbool MakefileGeneratorPlugin::checkGeneratorSupport(\r\n    QSharedPointer<Component const> /*component*/,\r\n    QSharedPointer<Design const> design,\r\n    QSharedPointer<DesignConfiguration const> designConfiguration) const\r\n{\r\n    return (design != nullptr && \r\n        designConfiguration != nullptr && \r\n        designConfiguration->getDesignConfigImplementation() == KactusAttribute::SYSTEM);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MakefileGeneratorPlugin::runGenerator()\r\n//-----------------------------------------------------------------------------\r\nvoid MakefileGeneratorPlugin::runGenerator(IPluginUtility* utility, \r\n    QSharedPointer<Component> component,\r\n    QSharedPointer<Design> design,\r\n    QSharedPointer<DesignConfiguration> designConfiguration)\r\n{\r\n    utility->printInfo(tr(\"Running %1 %2.\").arg(getName(), getVersion()));\r\n\r\n    LibraryInterface* library = utility->getLibraryInterface();\r\n\r\n\t// Find the name of the system view pointing to the design configuration.\r\n\tQString sysViewName;\r\n\r\n\tforeach (QSharedPointer<SystemView> view, component->getSystemViews())\r\n\t{\r\n\t\tif (view->getHierarchyRef() == designConfiguration->getVlnv())\r\n\t\t{\r\n\t\t\tsysViewName = view->name();\r\n\t\t\tbreak;\r\n\t\t}\r\n    }\r\n\r\n    // System view must exist.\r\n    if (sysViewName.isEmpty())\r\n    {\r\n        utility->printError(\"The design configuration did not match any system view. VLNV: \" + \r\n            designConfiguration->getVlnv().toString());\r\n        return;\r\n    }\r\n\r\n\t// Parse the design for buildable software stacks.\r\n    SWStackParser stackParser(library, component, design, designConfiguration);\r\n    stackParser.parse(sysViewName);\r\n\r\n    // Parse the stacks for buildable objects.\r\n    MakefileParser makeParser(library, stackParser);\r\n    makeParser.parse(component);\r\n\r\n    QString targetPath = QFileInfo(library->getPath(design->getVlnv())).absolutePath() + \"/sw_\" + sysViewName;\r\n\r\n    QDir path;\r\n    if (!path.mkpath(targetPath))\r\n    {\r\n        utility->printError(\"Could not create path for the makefiles: \" + targetPath);\r\n        return;\r\n    }\r\n\r\n\t// Show the dialog.\r\n    QSharedPointer<MakeConfiguration> configuration(new MakeConfiguration(&stackParser));\r\n    configuration->getFileOuput()->setOutputPath(targetPath);\r\n\tMakeParametersDialog dialog(configuration, makeParser.getParsedData(), utility->getParentWidget());\r\n\r\n\t// Return, if user did not want to proceed after seeing it.\r\n\tif (dialog.exec() == QDialog::Rejected)\r\n\t{\r\n\t\tutility->printError(\"Makefile generation rejected by user.\");\r\n\t\treturn;\r\n    }\r\n\r\n\t// Generate files from parsed data.\r\n    MakefileGenerator generator(makeParser, utility, stackParser.getGeneralFileSet());\r\n\r\n\t// Also the directory of the top component is needed for the generated files.\r\n\tQString topDir = QFileInfo(library->getPath(component->getVlnv())).absolutePath(); \r\n    int exe_count = generator.generate(configuration->getFileOuput()->getOutputPath(), topDir);\r\n\r\n\t// Did we actually generate anything?\r\n\tif (exe_count > 0)\r\n\t{\r\n\t\t// Top component and the design may have been affected by changes -> save.\r\n\t\tlibrary->writeModelToFile(component);\r\n\t\tlibrary->writeModelToFile(design);\r\n\r\n\t\t// Inform that the generation is complete.\r\n\t\tutility->printInfo( tr(\"Makefile generation complete. Created a makefile for %1 executables.\").arg(exe_count) );\r\n\t}\r\n\telse\r\n\t{\r\n\t\t// Inform that there was nothing to generate.\r\n\t\tutility->printError( \"No makefiles generated.\");\r\n\t}\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MakefileGeneratorPlugin::runGenerator()\r\n//-----------------------------------------------------------------------------\r\nvoid MakefileGeneratorPlugin::runGenerator(IPluginUtility* utility, QSharedPointer<Component> component,\r\n    QSharedPointer<Design> design, QSharedPointer<DesignConfiguration> designConfiguration,\r\n    QString const& viewName, QString const& outputDirectory)\r\n{\r\n    utility->printInfo(tr(\"Running %1 %2.\").arg(getName(), getVersion()));\r\n\r\n    LibraryInterface* library = utility->getLibraryInterface();\r\n\r\n    // System view must be valid.\r\n    if (designConfiguration == nullptr || designConfiguration->getDesignConfigImplementation() != KactusAttribute::SYSTEM)\r\n    {\r\n        utility->printError(\"Valid design configuration could not be found for view '\" + viewName + \"'\" );\r\n        return;\r\n    }\r\n\r\n    if (component->getHierRef(viewName) != designConfiguration->getVlnv())\r\n    {\r\n        utility->printError(\"The design configuration did not match any system view. VLNV: \" +\r\n            designConfiguration->getVlnv().toString());\r\n        return;\r\n    }\r\n\r\n    // Parse the design for buildable software stacks.\r\n    SWStackParser stackParser(library, component, design, designConfiguration);\r\n    stackParser.parse(viewName);\r\n\r\n    // Parse the stacks for buildable objects.\r\n    MakefileParser makeParser(library, stackParser);\r\n    makeParser.parse(component);\r\n\r\n    QString targetPath = QFileInfo(outputDirectory).absolutePath() + \"/sw_\" + viewName;\r\n\r\n    QDir path;\r\n    if (!path.mkpath(targetPath))\r\n    {\r\n        utility->printError(\"Could not create path for the makefiles: \" + targetPath);\r\n        return;\r\n    }\r\n\r\n    // Show the dialog.\r\n    QSharedPointer<MakeConfiguration> configuration(new MakeConfiguration(&stackParser));\r\n    configuration->getFileOuput()->setOutputPath(targetPath);\r\n\r\n    // Generate files from parsed data.\r\n    MakefileGenerator generator(makeParser, utility, stackParser.getGeneralFileSet());\r\n\r\n    // Also the directory of the top component is needed for the generated files.\r\n    QString topDir = QFileInfo(library->getPath(component->getVlnv())).absolutePath();\r\n    int exe_count = generator.generate(configuration->getFileOuput()->getOutputPath(), topDir);\r\n\r\n    // Did we actually generate anything?\r\n    if (exe_count > 0)\r\n    {\r\n        // Top component and the design may have been affected by changes -> save.\r\n        library->writeModelToFile(component);\r\n        library->writeModelToFile(design);\r\n\r\n        // Inform that the generation is complete.\r\n        utility->printInfo(tr(\"Makefile generation complete. Created a makefile for %1 executables.\").arg(exe_count));\r\n    }\r\n    else\r\n    {\r\n        // Inform that there was nothing to generate.\r\n        utility->printError(\"No makefiles generated.\");\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MakefileGeneratorPlugin::getOutputFormat()\r\n//-----------------------------------------------------------------------------\r\nQString MakefileGeneratorPlugin::getOutputFormat() const\r\n{\r\n    return QStringLiteral(\"Makefile\");\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MakefileGeneratorPlugin::getProgramRequirements()\r\n//-----------------------------------------------------------------------------\r\nQList<IPlugin::ExternalProgramRequirement> MakefileGeneratorPlugin::getProgramRequirements()\r\n{\r\n    return QList<IPlugin::ExternalProgramRequirement>();\r\n}\r\n"
  },
  {
    "path": "Plugins/MakefileGenerator/MakefileGeneratorPlugin.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: MakefileGeneratorPlugin.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Janne Virtanen\r\n// Date: 15.9.2014\r\n//\r\n// Description:\r\n// Makefile generator plugin.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef MAKEFILEGENERATORPLUGIN_H\r\n#define MAKEFILEGENERATORPLUGIN_H\r\n\r\n#include \"makefilegenerator_global.h\"\r\n\r\n#include <KactusAPI/include/IGeneratorPlugin.h>\r\n#include <KactusAPI/include/IPluginUtility.h>\r\n#include <KactusAPI/include/CLIGenerator.h>\r\n\r\nclass MAKEFILEGENERATOR_EXPORT MakefileGeneratorPlugin : public QObject, public IGeneratorPlugin,\r\n    public CLIGenerator\r\n{\r\n    Q_OBJECT\r\n    Q_PLUGIN_METADATA(IID \"kactus2.plugins.MakefileGenerator\" FILE \"makefile.json\")\r\n\r\n    Q_INTERFACES(IPlugin)\r\n    Q_INTERFACES(IGeneratorPlugin)\r\n\r\npublic:\r\n    MakefileGeneratorPlugin();\r\n    ~MakefileGeneratorPlugin() = default;\r\n\r\n    // Disable copying.\r\n    MakefileGeneratorPlugin(MakefileGeneratorPlugin const& rhs) = delete;\r\n    MakefileGeneratorPlugin& operator=(MakefileGeneratorPlugin const& rhs) = delete;\r\n\r\n    /*!\r\n     *  Returns the name of the plugin.\r\n     */\r\n    virtual QString getName() const;\r\n\r\n    /*!\r\n     *  Returns the version of the plugin.\r\n     */\r\n    virtual QString getVersion() const;\r\n\r\n    /*!\r\n     *  Returns the description of the plugin.\r\n     */\r\n    virtual QString getDescription() const;\r\n\r\n    /*!\r\n     *  Returns the vendor of the plugin.\r\n     */\r\n    virtual QString getVendor() const;\r\n\r\n    /*!\r\n     *  Returns the license of the plugin.\r\n     */\r\n    virtual QString getLicense() const;\r\n\r\n    /*!\r\n     *  Returns the holder of the license of the plugin.\r\n     */\r\n    virtual QString getLicenseHolder() const;\r\n\r\n    /*!\r\n     *  Returns the settings widget.\r\n     */\r\n    virtual QWidget* getSettingsWidget();\r\n\r\n    /*!\r\n     *  This is used to access the settings modified by function getSettingsWidget().\r\n     */\r\n    virtual PluginSettingsModel* getSettingsModel(){return NULL;}\r\n\r\n    /*!\r\n     *  Returns the icon for the generator.\r\n     */\r\n    virtual QIcon getIcon() const;\r\n\r\n    /*!\r\n     *  Checks whether the generator may run for the given component or design. \r\n     *\r\n     *    @param [in] component\t        The component for which to check support. If design is not null, component\r\n\t *                                      will refer to design or designConfiguration.\r\n     *    @param [in] design\t            The design, if the generator is ran for a design.\r\n     *    @param [in] designConfiguration The design configuration for design, if it is not null.\r\n     *\r\n     *    @return True, if the generator may run the given component. Otherwise false.\r\n     */\r\n    virtual bool checkGeneratorSupport(\r\n        QSharedPointer<Component const> component,\r\n        QSharedPointer<Design const> design,\r\n        QSharedPointer<DesignConfiguration const> designConfiguration) const;\r\n\r\n    /*!\r\n     *  Runs the generation, creating new files and/or modifying the IP-XACT metadata. The function has\r\n\t *  also access to the parent window widget, so that it can show dialogs for the user to aid the generation.\r\n     *\r\n     *    @param [in] utility\t\t\t    The plugin utility interface.\r\n     *    @param [in] component\t        The component for which to check support. If design is not null, component\r\n     *                                      will refer to design or designConfiguration.\r\n     *    @param [in] design\t            The design, if the generator is ran for a design.\r\n     *    @param [in] designConfiguration The design configuration for design, if it is not null.\r\n     */\r\n    virtual void runGenerator(IPluginUtility* utility, \r\n        QSharedPointer<Component> component,\r\n        QSharedPointer<Design> design,\r\n        QSharedPointer<DesignConfiguration> designConfiguration);\r\n\r\n    /*!\r\n      * Runs the generation.\r\n      *\r\n      *    @param [in] utility              Utilities for enabling plugin execution.\r\n      *    @param [in] component            The component to run the generation for.\r\n      *    @param [in] design               The design to run the generation for.\r\n      *    @param [in] designConfiguration  The design configuration to run the generation for.\r\n      *    @param [in] viewName             The component view name to run the generation for.\r\n      *    @param [in] outputDirectory      The output directory for the generation results.\r\n      */\r\n    virtual void runGenerator(IPluginUtility* utility, QSharedPointer<Component> component,\r\n        QSharedPointer<Design> design, QSharedPointer<DesignConfiguration> designConfiguration,\r\n        QString const& viewName, QString const& outputDirectory) override;\r\n\r\n    /*!\r\n     *  Gets the output format generated by the plugin.\r\n     *\r\n     *    @return The output file format generated by the plugin.\r\n     */\r\n    virtual QString getOutputFormat() const override;\r\n\r\n    //! Returns the external program requirements of the plugin.\r\n    virtual QList<IPlugin::ExternalProgramRequirement> getProgramRequirements();\r\n\r\n};\r\n\r\n#endif // MAKEFILEGENERATORPLUGIN_H\r\n"
  },
  {
    "path": "Plugins/MakefileGenerator/MakefileParser.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: MakefileParser.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Janne Virtanen\r\n// Date: 22.09.2014\r\n//\r\n// Description:\r\n// Parses makefile data from SW stack.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"MakefileParser.h\"\r\n\r\n#include <QFileInfo>\r\n#include <QSet>\r\n\r\n#include <IPXACTmodels/kactusExtensions/ApiInterface.h>\r\n#include <common/NameGenerationPolicy.h>\r\n\r\n#include <KactusAPI/include/ListParameterFinder.h>\r\n#include <KactusAPI/include/IPXactSystemVerilogParser.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MakefileParser::MakefileParser()\r\n//-----------------------------------------------------------------------------\r\nMakefileParser::MakefileParser( LibraryInterface* library, SWStackParser& swStackParser ) :\r\nlibrary_( library ), swStackParser_(swStackParser), parsedData_( QSharedPointer<QList<QSharedPointer<MakeFileData> > >\r\n\t( new QList<QSharedPointer<MakeFileData> > ) )\r\n{\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MakefileParser::~MakefileParser()\r\n//-----------------------------------------------------------------------------\r\nMakefileParser::~MakefileParser()\r\n{\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MakefileParser::getParsedData()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<QList<QSharedPointer<MakeFileData> > > MakefileParser::getParsedData()\r\n{\r\n    return parsedData_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MakefileParser::searchSWComponent()\r\n//-----------------------------------------------------------------------------\r\nvoid MakefileParser::parse(QSharedPointer<Component> topComponent)\r\n{\r\n\tforeach (QSharedPointer<MakeFileData> makeData, *swStackParser_.getParsedData())\r\n\t{\r\n\t\t// Path to the top component is needed to construct the absolute path.\r\n\t\tQFileInfo componentQfi = QFileInfo(library_->getPath(topComponent->getVlnv()));\r\n\t\tQString componentPath = componentQfi.absolutePath() + \"/\";\r\n\r\n\t\tforeach (QSharedPointer<StackPart> stackPart, makeData->parts)\r\n\t\t{\r\n\t\t\t// Also parse the associated instance headers, if any exist.\r\n\t\t\tif (stackPart->instanceHeaders)\r\n\t\t\t{\r\n\t\t\t\tparseFileSet(stackPart->instanceHeaders, makeData, stackPart, componentPath);\r\n\t\t\t}\r\n\r\n\t\t\t// Parse the files of the given software view.\r\n\t\t\tparseMakeObjects(makeData, stackPart);\r\n\t\t}\r\n\r\n\t\t// Now we may check the compiler and flags of individual files...\r\n\t\tforeach (QSharedPointer<MakeObjectData> mod, makeData->swObjects)\r\n\t\t{\r\n\t\t\tmod->compiler = getFileCompiler(mod, makeData->hardPart->buildCmd);\r\n\t\t\tmod->flags = getFileFlags(makeData->parts.first()->component, mod, makeData );\r\n\t\t}\r\n\r\n\t\t// Check if software objects found: If none, no need for a makefile.\r\n\t\tif (makeData->swObjects.isEmpty())\r\n\t\t{\r\n\t\t\tcontinue;\r\n\t\t}\r\n\r\n\t\t// Remove duplicates: They are not needed.\r\n\t\tmakeData->includeDirectories.removeDuplicates();\r\n\t\tmakeData->componentInstantiationFlags.removeDuplicates();\r\n\r\n\t\t// Finally, see if there are any conflicts within the potential object files.\r\n\t\tfindConflicts(makeData);\r\n\r\n\t\t// Append to the list.\r\n\t\tparsedData_->append(makeData);\r\n\t}\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MakefileParser::parseMakeObjects()\r\n//-----------------------------------------------------------------------------\r\nvoid MakefileParser::parseMakeObjects( QSharedPointer<MakeFileData> makeData, \r\n\tQSharedPointer<StackPart> stackPart )\r\n{\r\n\t// Path to the component is needed to construct the absolute path.\r\n\tQFileInfo componentQfi = QFileInfo(library_->getPath(stackPart->component->getVlnv()));\r\n\tQString componentPath = componentQfi.absolutePath() + \"/\";\r\n\r\n    // Go through the fileSets referenced in the software view.\r\n    for (auto fileSetRef : *stackPart->instantiation->getFileSetReferences())\r\n    {\r\n        QSharedPointer<FileSet> fset = stackPart->component->getFileSet(fileSetRef->getReference());\r\n\r\n\t\t// Skip, if no such file set exist!\r\n\t\tif (fset)\r\n\t\t{\r\n\t\t\tparseFileSet(fset, makeData, stackPart, componentPath );\r\n\t\t}\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MakefileParser::parseFileSet()\r\n//-----------------------------------------------------------------------------\r\nvoid MakefileParser::parseFileSet(QSharedPointer<FileSet> fset, QSharedPointer<MakeFileData> makeData, \r\n\tQSharedPointer<StackPart> stackPart, QString& componentPath)\r\n{\r\n\t// Go through the files in the fileSet.\r\n\tforeach( QSharedPointer<File> file, *fset->getFiles())\r\n\t{\r\n\t\t// First of all, the selected build commands must support the file type.\r\n\t\tif (!file->getFileTypes()->contains(stackPart->buildCmd->getFileType()))\r\n\t\t{\r\n\t\t\tcontinue;\r\n\t\t}\r\n\r\n\t\t// Get info about the file path.\r\n        QFileInfo fileQfi = QFileInfo(componentPath + file->name());\r\n\r\n        // In case of an include file:\r\n        if (file->isIncludeFile())\r\n        {\r\n            // Path is added to the collection of the include paths.\r\n            makeData->includeDirectories.append(fileQfi.absolutePath());\r\n            // They do not yield anything else.\r\n            continue;\r\n        }\r\n\r\n        // Initialize the data to the collection associated with the makefile data.\r\n        QSharedPointer<MakeObjectData> objectData( new MakeObjectData );\r\n        makeData->swObjects.append(objectData);\r\n\r\n\t\t// Set the needed fields.\r\n\t\tobjectData->file = file;\r\n\t\tobjectData->fileBuildCmd = file->getBuildCommand();\r\n\t\tobjectData->fileName = fileQfi.fileName();\r\n\t\tobjectData->path = fileQfi.absolutePath();\r\n\t\tobjectData->fileSet = fset;\r\n\t\tobjectData->swBuildCmd = stackPart->buildCmd;\r\n\t\tobjectData->stackPart = stackPart;\r\n        objectData->isChosen = true;\r\n\r\n\t\t// A fileSet builder associated with the file type is also a possible field.\r\n\t\tforeach(QSharedPointer<FileBuilder> builder, *fset->getDefaultFileBuilders())\r\n\t\t{\r\n\t\t\tif (file->getFileTypes()->contains(builder->getFileType()))\r\n\t\t\t{\r\n\t\t\t\tobjectData->fileSetBuildCmd = builder;\r\n\t\t\t\tbreak;\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MakefileParser::getFileCompiler()\r\n//-----------------------------------------------------------------------------\r\nQString MakefileParser::getFileCompiler(QSharedPointer<MakeObjectData> mod,\r\n\tQSharedPointer<FileBuilder> hardBuilder) const\r\n{\r\n\tQString compiler;\r\n\tQSharedPointer<FileBuilder> swbc;\r\n\r\n\t// This mesh does following:\r\n\t// 1. No file builder -> use fileSet builder\r\n\t// 2. No fileSet builder -> use builder of the software instance\r\n\t// 3. If nothing else, use the builder of the hardware instance\r\n\tif (mod->fileBuildCmd == 0 || mod->fileBuildCmd->getCommand().isEmpty())\r\n\t{\r\n\t\tif (mod->fileSetBuildCmd == 0 || mod->fileSetBuildCmd->getCommand().isEmpty())\r\n\t\t{\r\n\t\t\tif (mod->swBuildCmd == 0 || mod->swBuildCmd->getCommand().isEmpty())\r\n\t\t\t{\r\n\t\t\t\tswbc = hardBuilder;\r\n\t\t\t}\r\n\t\t\telse\r\n\t\t\t{\r\n\t\t\t\tswbc = mod->swBuildCmd;\r\n\t\t\t}\r\n\t\t}\r\n\t\telse if (mod->fileSetBuildCmd != 0)\r\n\t\t{\r\n\t\t\tcompiler = mod->fileSetBuildCmd->getCommand();\r\n\t\t}\r\n\t}\r\n\telse\r\n\t{\r\n\t\tcompiler = mod->fileBuildCmd->getCommand();\r\n\t}\r\n\r\n\t// Verify that file has a type matching the build command.\r\n\tif (swbc != 0 && mod->file->getFileTypes()->contains(swbc->getFileType()))\r\n\t{\r\n\t\tcompiler = swbc->getCommand();\r\n\t}\r\n\r\n\treturn compiler;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MakefileGenerator::getFileFlags()\r\n//-----------------------------------------------------------------------------\r\nQString MakefileParser::getFileFlags(QSharedPointer<Component> component,\r\n\tQSharedPointer<MakeObjectData> &mod, QSharedPointer<MakeFileData> makeData) const\r\n{\r\n\tQString cFlags;\r\n\tint fileReplaceFlags = 0;\r\n\tint fileSetReplaceFlags = 0;\r\n\r\n\tQSharedPointer<ListParameterFinder> finder (new ListParameterFinder());\r\n\tfinder->setParameterList(component->getParameters());\r\n\tQSharedPointer<IPXactSystemVerilogParser> expressionParser (new IPXactSystemVerilogParser(finder));\r\n\t\r\n\t// At any rate, the file may have its own flags.\r\n\tif (mod->fileBuildCmd != 0)\r\n\t{\r\n\t\tcFlags += mod->fileBuildCmd->getFlags();\r\n\t\tfileReplaceFlags =\r\n\t\t\texpressionParser->parseExpression(mod->fileBuildCmd->getReplaceDefaultFlags()).toInt();\r\n\t}\r\n\r\n\t// See if file set flags replace anything.\r\n\tif (mod->fileSetBuildCmd != 0)\r\n\t{\r\n\t\tfileSetReplaceFlags =\r\n\t\t\texpressionParser->parseExpression(mod->fileSetBuildCmd->getReplaceDefaultFlags()).toInt();\r\n\t}\r\n\r\n\t// This mesh does following:\r\n\t// 1. If file does not override flags, may use fileSet flags\r\n\t// 2. If fileSet does not override flags, may use software flags\r\n\t// 2. If software does not override flags, may use hardware flags\r\n\tif (mod->fileBuildCmd == 0 || fileReplaceFlags != 1)\r\n\t{\r\n\t\tif (mod->fileSetBuildCmd != 0 )\r\n\t\t{\r\n\t\t\tcFlags += \" \" + mod->fileSetBuildCmd->getFlags();\r\n\t\t}\r\n\r\n\t\tif (mod->fileSetBuildCmd == 0 || fileSetReplaceFlags != 1)\r\n\t\t{\r\n\t\t\tif (mod->swBuildCmd != 0)\r\n\t\t\t{\r\n\t\t\t\tcFlags += \" \" + mod->swBuildCmd->getFlags();\r\n\t\t\t}   \r\n\r\n\t\t\tif ((mod->swBuildCmd == 0 || mod->swBuildCmd->getReplaceDefaultFlags().toInt() != 1)\r\n                && makeData->hardPart->buildCmd != 0 && makeData->hardPart->buildCmd != mod->swBuildCmd)\r\n\t\t\t{\r\n\t\t\t\tcFlags += \" \" + makeData->hardPart->buildCmd->getFlags();\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\treturn cFlags;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MakefileGenerator::findConflicts()\r\n//-----------------------------------------------------------------------------\r\nvoid MakefileParser::findConflicts(QSharedPointer<MakeFileData> makeData)\r\n{\r\n\t// Take a copy of the list, so that they may be removed while evaluating.\r\n\tQList<QSharedPointer<MakeObjectData> > objects = makeData->swObjects;\r\n\r\n\t// Go on until the list is empty.\r\n\twhile (!objects.empty())\r\n\t{\r\n\t\t// Remove the object, so that there will not be a double entry nor self-evaluation.\r\n\t\tQSharedPointer<MakeObjectData> mod = objects.first();\r\n\t\tobjects.removeFirst();\r\n\r\n\t\t// List of the entires that conflict each other.\r\n\t\tQSet<QSharedPointer<MakeObjectData> > conflictingFiles;\r\n\r\n\t\t// The object itself must be one of the sides of the conflict.\r\n\t\tconflictingFiles.insert(mod);\r\n\r\n\t\t// Compare it to the others\r\n\t\tforeach (QSharedPointer<MakeObjectData> modCompare, objects)\r\n\t\t{\r\n\t\t\t// Absolute path is same means that the file is definitely same.\r\n\t\t\t// Must also consider the filename, as it is omitted from the path.\r\n\t\t\tif (modCompare->path == mod->path && modCompare->fileName == mod->fileName)\r\n\t\t\t{\r\n                conflictingFiles.insert(modCompare);\r\n                objects.removeOne(modCompare);\r\n            }\r\n\t\t}\r\n\r\n\t\t// One side of the conflict is the file compared to others, there has to be two conflicting files.\r\n\t\tif (conflictingFiles.size() > 1)\r\n\t\t{\r\n\t\t\tmakeData->conflicts.append(conflictingFiles);\r\n\t\t}\r\n\t}\r\n}"
  },
  {
    "path": "Plugins/MakefileGenerator/MakefileParser.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: MakefileParser.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Janne Virtanen\r\n// Date: 22.09.2014\r\n//\r\n// Description:\r\n// Parses makefile data from SW stack.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef MakefileParser_H\r\n#define MakefileParser_H\r\n\r\n#include <QString>\r\n\r\n#include \"SWStackParser.h\"\r\n#include \"MakeCommon.h\"\r\n\r\n#include <IPXACTmodels/Component/File.h>\r\n#include <IPXACTmodels/Component/FileSet.h>\r\n#include <IPXACTmodels/Component/Component.h>\r\n#include <IPXACTmodels/Component/BuildCommand.h>\r\n\r\n#include <KactusAPI/include/LibraryInterface.h>\r\n\r\nclass MakefileParser\r\n{\r\npublic:\r\n    /*!\r\n     *  The constructor.\r\n     *\r\n\t *    @param [in] library   The library containing all components in the design.\r\n\t *    @param [in] parser   The parsed software stack containing needed references.\r\n\t */\r\n    MakefileParser( LibraryInterface* library, SWStackParser& swStackParser );\r\n\r\n    ~MakefileParser();\r\n\r\n    // Returns reference to all parsed MakeFileData.\r\n    QSharedPointer<QList<QSharedPointer<MakeFileData> > > getParsedData();\r\n\r\n    /*!\r\n     *  Parses all software components from the design for the data needed in makefiles.\r\n     */\r\n    void parse(QSharedPointer<Component> topComponent);\r\n\r\nprivate:\r\n\r\n    /*!\r\n     *  Parses all source files in all file sets in the given part of a stack.\r\n\t *\r\n\t *    @param [in] makeData   The make data associated with the makefile as whole.\r\n\t *    @param [in] view       The software view, where the files belong to.\r\n     *    @param [in] buildCmd   The build command of the associated software view.\r\n\t *    @param [in] component  The component of softInstance.\r\n     */\r\n\tvoid parseMakeObjects( QSharedPointer<MakeFileData> makeData, \r\n\t\tQSharedPointer<StackPart> stackPart );\r\n\r\n\t/*!\r\n\t *  Parses all files of parameters fset, adding the to parameters objects.\r\n\t *  Parsing involves defining the file as header, and determining its relevant build commands and path.\r\n\t *\r\n\t *    @param [in] fset\t\t\t\tThe inspected file set\r\n\t *    @param [in] objects\t\t\tThe list of parsed objects, where the file data will be appended.\r\n\t *    @param [in] makeData\t\t\tThe make data associated with the makefile as whole.\r\n\t *    @param [in] buildCmd\t\t\tThe build command \r\n\t *    @param [in] componentPath\tPath to the component where the file sets belong to.\r\n\t */\r\n\t void parseFileSet(QSharedPointer<FileSet> fset, QSharedPointer<MakeFileData> makeData, \r\n\t QSharedPointer<StackPart> stackPart, QString& componentPath);\r\n\r\n    /*!\r\n     *  Gets the compiler used for the file.\r\n     *\r\n     *    @param [in] mod   The make data associated with the object file.\r\n\t *    @param [in] hardView   Software view of the associated hardware component.\r\n\t *\r\n\t *    @return The resolved compiler for the file.\r\n\t */\r\n\t QString getFileCompiler(QSharedPointer<MakeObjectData> mod, QSharedPointer<FileBuilder> hardBuilder) const;\r\n\r\n    /*!\r\n     *  Gets concatenated the build flags of the file with those fileSet and software views.\r\n     *\r\n     *    @param [in] mod   The make data associated with the object file.\r\n\t *    @param [in] mfd   The make data associated with the makefile as whole.\r\n\t *\r\n\t *    @return The resolved flags for the file.\r\n     */\r\n     QString getFileFlags(QSharedPointer<Component> component, QSharedPointer<MakeObjectData> &mod,\r\n\t\t QSharedPointer<MakeFileData> makeData) const;\r\n\t \r\n    /*!\r\n\t *  Finds conflicting files within the stack: The same file with different meta data.\r\n     *\r\n     *    @param [in] makeData\t\t\tThe make data associated with the makefile as whole.\r\n     */\r\n\t void findConflicts(QSharedPointer<MakeFileData> makeData);\r\n\r\n\t //! The library containing all components in the design.\r\n     LibraryInterface* library_;\r\n     //! The parser containing parsed stack data.\r\n     SWStackParser& swStackParser_;\r\n     //! Collection of data sets, one for each makefile.\r\n\t QSharedPointer<QList<QSharedPointer<MakeFileData> > > parsedData_;\r\n};\r\n\r\n#endif // MakefileParser_H\r\n"
  },
  {
    "path": "Plugins/MakefileGenerator/SWStackParser.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: SWStackParser.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Janne Virtanen\r\n// Date: 18.05.2016\r\n//\r\n// Description:\r\n// Parses design and its configuration for makefile generation data.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"SWStackParser.h\"\r\n\r\n#include <QFileInfo>\r\n#include <QSet>\r\n\r\n#include <IPXACTmodels/kactusExtensions/ApiInterface.h>\r\n\r\n#include <common/NameGenerationPolicy.h>\r\n\r\n#include <KactusAPI/include/ListParameterFinder.h>\r\n#include <KactusAPI/include/IPXactSystemVerilogParser.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SWStackParser::MakefileParser()\r\n//-----------------------------------------------------------------------------\r\nSWStackParser::SWStackParser(LibraryInterface* library, QSharedPointer<Component> topComponent,\r\n    QSharedPointer<Design> design, QSharedPointer<DesignConfiguration> designConf) :\r\n    library_(library),\r\n    topComponent_(topComponent),\r\n    design_(design),\r\n    designConf_(designConf),\r\n    parsedData_(QSharedPointer<QList<QSharedPointer<MakeFileData> > >(new QList<QSharedPointer<MakeFileData> >)),\r\n    generalFileSet_()\r\n{\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SWStackParser::getParsedData()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<QList<QSharedPointer<MakeFileData> > > SWStackParser::getParsedData()\r\n{\r\n    return parsedData_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SWStackParser::getGeneralFileSet()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<FileSet> SWStackParser::getGeneralFileSet()\r\n{\r\n    return generalFileSet_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SWStackParser::parse()\r\n//-----------------------------------------------------------------------------\r\nvoid SWStackParser::parse(QString const& sysViewName)\r\n{\r\n    // Fabricate name for the fileSet of design configuration specific files.\r\n    QString generalFileSetName = NameGenerationPolicy::systemViewFilesetName(sysViewName);\r\n\r\n\t// Obtain the the fileSet by name and set it as a source file group.\r\n\tQSharedPointer<FileSet> fileSet = topComponent_->getFileSet(generalFileSetName);\r\n\r\n\tif (!fileSet)\r\n\t{\r\n\t\tQSharedPointer<QList<QSharedPointer<FileSet> > > fileSets = topComponent_->getFileSets();\r\n\t\tfileSet = QSharedPointer<FileSet>(new FileSet(generalFileSetName, \"sourceFiles\"));\r\n\t\tfileSets->append(fileSet);\r\n\t}\r\n\r\n    fileSet->setGroups(\"sourceFiles\");\r\n\r\n    // This is also a fileSet referenced by the makefile generation\r\n    generalFileSet_ = fileSet;\r\n\r\n    // The base directory for the software.\r\n    QString basePath = sysViewName + \"/\";\r\n\r\n    // Check if the main makefile and the launcher files already exits.\r\n    QString mainMakeDir = basePath + \"Makefile\";\r\n\r\n    // We also need to know if the file exists\r\n    QString launcherDir = basePath + \"launcher.sh\";\r\n\r\n    foreach (QSharedPointer<ComponentInstance> softInstance, *design_->getComponentInstances())\r\n    {\r\n        // The VLNV and the component of the instance are needed.\r\n        QSharedPointer<VLNV> softwareVLNV = softInstance->getComponentRef();\r\n        QSharedPointer<Component> softComponent = library_->getModel(*softwareVLNV).dynamicCast<Component>();\r\n\r\n        // Lower levels of a stack do not get their own makefiles.\r\n        if (!isTopOfStack(softInstance, softComponent))\r\n        {\r\n\t\t\tcontinue;\r\n\t\t}\r\n\r\n        // Initialize the data of makefile to collection of parsed entities.\r\n        QSharedPointer<MakeFileData> makeData(new MakeFileData);\r\n\r\n\t\t// Parse files of the underlying hardware.\r\n\t\tQSharedPointer<ComponentInstance> hardInstance;\r\n\r\n\t\t// See if the design contains a hardware instance corresponding the mapped hardware instance.\r\n\t\tforeach (QSharedPointer<ComponentInstance> instance, *design_->getComponentInstances())\r\n\t\t{\r\n\t\t\tif (instance->getUuid() == softInstance->getMapping())\r\n\t\t\t{\r\n\t\t\t\thardInstance = instance;\r\n\t\t\t\tbreak;\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\t// If not found, skip.\r\n\t\tif (!hardInstance)\r\n\t\t{\r\n\t\t\tcontinue;\r\n\t\t}\r\n\r\n\t\t// Get the component of the hardware instance.\r\n\t\tQSharedPointer<VLNV> hardwareVLNV = hardInstance->getComponentRef();\r\n\t\tQSharedPointer<Component> hardComponent = library_->getModel(*hardwareVLNV).dynamicCast<Component>();\r\n\r\n\t\t// Find the view corresponding the active view name\r\n\t\tQString hardViewName = designConf_->getActiveView(hardInstance->getInstanceName());\r\n\t\tQSharedPointer<View> hardView = hardComponent->getModel()->findView(hardViewName);\r\n\r\n\t\t// If not found, skip.\r\n\t\tif (!hardView)\r\n\t\t{\r\n\t\t\tcontinue;\r\n        }\r\n\r\n        // Must have a component instantiation.\r\n        QSharedPointer<ComponentInstantiation> hardInstantiation = hardComponent->getModel()->\r\n            findComponentInstantiation(hardView->getComponentInstantiationRef());\r\n\r\n        if (!hardInstantiation)\r\n        {\r\n            return;\r\n        }\r\n\r\n\t\t// Get the hardware data.\r\n\t\tmakeData->hardPart = QSharedPointer<StackPart>(new StackPart);\r\n\t\tmakeData->hardPart->component = hardComponent;\r\n\t\tmakeData->hardPart->instanceName = hardInstance->getInstanceName();\r\n\t\tmakeData->hardPart->view = hardView;\r\n        makeData->hardPart->instantiation = hardInstantiation;\r\n\r\n\t\t// This is also the point where hardware build command is decided.\r\n\t\t// TODO: Ask from user which one.\r\n\t\tif (hardInstantiation->getDefaultFileBuilders()->count() > 0)\r\n\t\t{\r\n\t\t\tmakeData->hardPart->buildCmd = hardInstantiation->getDefaultFileBuilders()->first();\r\n\t\t}\r\n\r\n\t\t// No hardware build command means no makefile.\r\n\t\tif (!makeData->hardPart->buildCmd)\r\n\t\t{\r\n\t\t\tcontinue;\r\n\t\t}\r\n\r\n\t\t// Parse its files, as well as files of any instance in the underlying stack.\r\n\t\tparseStackObjects(softComponent, softInstance, makeData, sysViewName);\r\n\r\n\t\t// Empty stack means no makefile.\r\n\t\tif (makeData->parts.count() < 1)\r\n\t\t{\r\n\t\t\tcontinue;\r\n\t\t}\r\n\r\n\t\t// Now add the hardware to the list of parts as well.\r\n\t\tmakeData->parts.append(makeData->hardPart);\r\n\r\n\t\t// We need a file set for makefile. It shall be the header set of the topmost instance.\r\n\t\tmakeData->instanceFileSet = makeData->parts.first()->instanceHeaders;\r\n\r\n\t\t// Since every software stack gets its own makefile, naming is after the instance name.\r\n\t\tmakeData->name = makeData->parts.first()->instanceName;\r\n\r\n\t\t// We a name for the file, possibly via subfolder,\r\n\t\tmakeData->makeName = makeData->name + \"/\" + makeData->name + \".mak\";\r\n\r\n\t\t// Finally, append to the list of parsed stuff.\r\n\t\tparsedData_->append(makeData);\r\n\t}\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SWStackParser::isTopOfStack()\r\n//-----------------------------------------------------------------------------\r\nbool SWStackParser::isTopOfStack(QSharedPointer<ComponentInstance> softInstance, QSharedPointer<Component> softComponent)\r\n{\r\n    for (QSharedPointer<ApiInterconnection> connection : design_->getApiConnections())\r\n    {\r\n        QSharedPointer<ApiInterface> ourInterface;\r\n\r\n        if (softInstance->getInstanceName() == connection->getStartInterface()->getComponentReference())\r\n        {\r\n            ourInterface = softComponent->getApiInterface(connection->getStartInterface()->getBusReference());\r\n        }\r\n        else\r\n        {\r\n            // See if one of the ends is ours.\r\n            for (QSharedPointer<ActiveInterface> activeInterface : *connection->getActiveInterfaces())\r\n            {\r\n                if (softInstance->getInstanceName() == activeInterface->getComponentReference())\r\n                {\r\n                    ourInterface = softComponent->getApiInterface(activeInterface->getBusReference());\r\n                    break;\r\n                }\r\n            }\r\n        }\r\n\r\n        // If found and it turns out that we are an active provider, we are not on the top of a stack.\r\n        if (!ourInterface.isNull() && ourInterface->getDependencyDirection() == DEPENDENCY_PROVIDER)\r\n        {\r\n            return false;\r\n        }\r\n    }\r\n\r\n    return true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SWStackParser::parseStackObjects()\r\n//-----------------------------------------------------------------------------\r\nvoid SWStackParser::parseStackObjects(QSharedPointer<Component> softComponent,\r\n    QSharedPointer<ComponentInstance> softInstance, QSharedPointer<MakeCommon::MakeFileData> makeData, \r\n    QString const& systemViewName)\r\n{\r\n    // Skip if already parsed\r\n    if (makeData->parsedInstances.contains( softInstance ))\r\n    {\r\n        return;\r\n\t}\r\n\r\n\t// There may be only one active software view.\r\n\tQString softViewName = designConf_->getActiveView(softInstance->getInstanceName());\r\n\r\n    // It must correspond an actual view in the component.\r\n\tQSharedPointer<View> softView = softComponent->getModel()->findView(softViewName);\r\n\r\n\tif (!softView)\r\n\t{\r\n\t\treturn;\r\n\t}\r\n\r\n    // Must have a component instantiation.\r\n    QSharedPointer<ComponentInstantiation> softInstantiation = softComponent->getModel()->\r\n        findComponentInstantiation(softView->getComponentInstantiationRef());\r\n\r\n    if (!softInstantiation)\r\n    {\r\n        return;\r\n    }\r\n\r\n\t// Find build command of matching file type from the software view.\r\n\tQSharedPointer<FileBuilder> softViewBuildCmd;\r\n\r\n\tfor (QSharedPointer<FileBuilder> buildCmd : *softInstantiation->getDefaultFileBuilders())\r\n\t{\r\n\t\tif (buildCmd->getFileType() == makeData->hardPart->buildCmd->getFileType())\r\n\t\t{\r\n\t\t\tsoftViewBuildCmd = buildCmd;\r\n\r\n\t\t\tbreak;\r\n\t\t}\r\n\t}\r\n\r\n\t// If no suitable command exists, the software view is unusable for us.\r\n\tif (!softViewBuildCmd)\r\n\t{\r\n\t\treturn;\r\n\t}\r\n\r\n\t// Add the instance as a new part of the stack.\r\n\tQSharedPointer<StackPart> stackPart = QSharedPointer<StackPart>( new StackPart );\r\n\tstackPart->instanceName = softInstance->getInstanceName();\r\n\tstackPart->component = softComponent;\r\n\tstackPart->view = softView;\r\n    stackPart->instantiation = softInstantiation;\r\n\tstackPart->buildCmd = softViewBuildCmd;\r\n\r\n\t// Add to the lists.\r\n\tmakeData->parts.append(stackPart);\r\n\tmakeData->parsedInstances.append(softInstance);\r\n\r\n\t// Its flags are to be used.\r\n\tmakeData->componentInstantiationFlags.append(softViewBuildCmd->getFlags());\r\n\r\n\t// The top component of the design may contain header files specific to the instance.\r\n\t// The path leading to the design.\r\n\tQString fileSetName = softInstance->getFileSetRef();\r\n\r\n\t// Create a new fileSet, if no reference exist.\r\n\tif (fileSetName.isEmpty())\r\n\t{\r\n\t\t// If not, make a new one.\r\n\t\tfileSetName = NameGenerationPolicy::instanceFilesetName(systemViewName, softInstance->getInstanceName());\r\n\t\tsoftInstance->setFileSetRef(fileSetName);\r\n\t}\r\n\r\n\t// Obtain the the fileSet by name.\r\n\tQSharedPointer<FileSet> fileSet = topComponent_->getFileSet(fileSetName);\r\n\r\n\t// Create and add to the top component if needed.\r\n\tif (!fileSet)\r\n\t{\r\n\t\tfileSet = QSharedPointer<FileSet>(new FileSet(fileSetName, \"sourceFiles\"));\r\n\t\ttopComponent_->getFileSets()->append(fileSet);\r\n\t}\r\n\r\n\t// Save for later use.\r\n\tstackPart->instanceHeaders = fileSet;\r\n\r\n    // Go through the list of connections in the design to retrieve remote endpoint identifiers.\r\n    for (QSharedPointer<ApiInterconnection> connection : design_->getApiConnections())\r\n    {\r\n        QSharedPointer<ApiInterface> ourInterface;\r\n        QSharedPointer<ApiInterface> theirInterface;\r\n        QSharedPointer<ComponentInstance> theirInstance;\r\n        QSharedPointer<Component> theirComponent;\r\n\r\n        // We must find the API interfaces of the both ends, and the software instance and component of the\r\n        // end that is NOT us.\r\n        if (softInstance->getInstanceName() == connection->getStartInterface()->getComponentReference())\r\n        {\r\n            ourInterface = softComponent->getApiInterface(connection->getStartInterface()->getBusReference());\r\n        }\r\n        else\r\n        {\r\n            theirComponent = searchSWComponent(connection->getStartInterface()->getComponentReference(), theirInstance);\r\n            theirInterface = theirComponent->getApiInterface(connection->getStartInterface()->getBusReference());\r\n        }\r\n\r\n        for (QSharedPointer<ActiveInterface> activeInterface : *connection->getActiveInterfaces())\r\n        {\r\n            if (softInstance->getInstanceName() == activeInterface->getComponentReference())\r\n            {\r\n                ourInterface = softComponent->getApiInterface(activeInterface->getBusReference());\r\n            }\r\n            else\r\n            {\r\n                theirComponent = searchSWComponent(activeInterface->getComponentReference(), theirInstance);\r\n                theirInterface = theirComponent->getApiInterface(activeInterface->getBusReference());\r\n            }\r\n        }\r\n\r\n        // If both ends are found and are pointing the right way, we may include it to the stack.\r\n        if (!ourInterface.isNull() && ourInterface->getDependencyDirection() == DEPENDENCY_REQUESTER && \r\n            !theirInterface.isNull() && theirInterface->getDependencyDirection() == DEPENDENCY_PROVIDER &&\r\n\t\t\t!theirInstance.isNull())\r\n        {\r\n\t\t\tparseStackObjects(theirComponent, theirInstance, makeData, systemViewName);\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SWStackParser::searchSWComponent()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<Component> SWStackParser::searchSWComponent(QString instanceName,\r\n    QSharedPointer<ComponentInstance>& targetInstance)\r\n{\r\n    // Go through the software instances of the design, finding the right one.\r\n    for (QSharedPointer<ComponentInstance> instance : *design_->getComponentInstances())\r\n    {\r\n        // If the found instance name is same as target, it is what we seek.\r\n        if (instance->getInstanceName() == instanceName)\r\n        {\r\n            targetInstance = instance;\r\n            break;\r\n        }\r\n    }\r\n\r\n    // Obtain the component of the instance.\r\n    QSharedPointer<VLNV> instanceVLNV = targetInstance->getComponentRef();\r\n    QSharedPointer<Document> instanceLibComp = library_->getModel(*instanceVLNV);\r\n    QSharedPointer<Component> instanceComp = instanceLibComp.dynamicCast<Component>();\r\n\r\n    return instanceComp;\r\n}"
  },
  {
    "path": "Plugins/MakefileGenerator/SWStackParser.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: SWStackParser.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Janne Virtanen\r\n// Date: 18.05.2016\r\n//\r\n// Description:\r\n// Parses design and its configuration for makefile generation data.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef SWSTACKPARSER_H\r\n#define SWSTACKPARSER_H\r\n\r\n#include <QString>\r\n\r\n#include <IPXACTmodels/Design/Design.h>\r\n\r\n#include <IPXACTmodels/DesignConfiguration/DesignConfiguration.h>\r\n\r\n#include <IPXACTmodels/Component/File.h>\r\n#include <IPXACTmodels/Component/FileSet.h>\r\n#include <IPXACTmodels/Component/Component.h>\r\n#include <IPXACTmodels/Component/BuildCommand.h>\r\n#include <IPXACTmodels/Component/View.h>\r\n\r\n#include <KactusAPI/include/LibraryInterface.h>\r\n\r\n#include <KactusAPI/include/IGeneratorPlugin.h>\r\n\r\n#include \"MakeCommon.h\"\r\n\r\nusing namespace MakeCommon;\r\n\r\nclass SWStackParser\r\n{\r\npublic:\r\n    //! The constructor.\r\n    SWStackParser(LibraryInterface* library, QSharedPointer<Component> topComponent,\r\n        QSharedPointer<Design> design, QSharedPointer<DesignConfiguration> designConf);\r\n\r\n    //! The destructor.\r\n    ~SWStackParser() = default;\r\n\r\n    // Returns reference to all parsed MakeFileData.\r\n    QSharedPointer<QList<QSharedPointer<MakeFileData> > > getParsedData();\r\n\r\n    // Return the general file set.\r\n    QSharedPointer<FileSet> getGeneralFileSet();\r\n\r\n    /*!\r\n     *  Parses all software components from the design for the data needed in makefiles.\r\n     *\r\n\t *    @param [in] sysViewName  Name of the system view pointing to used design configuration.\r\n     */\r\n    void parse(QString const& sysViewName);\r\n\r\nprivate:\r\n\r\n    /*!\r\n     *  Checks if softInstance is the topmost instance in its stack.\r\n     *\r\n     *    @param [in] softInstance   The software instance to be checked.\r\n     *    @param [in] softComponent   The software component of the instance.\r\n     *\r\n     *    @return True, if the softInstance is the topmost instance in its stack. Otherwise false.\r\n     */\r\n     bool isTopOfStack(QSharedPointer<ComponentInstance> softInstance, QSharedPointer<Component> softComponent);\r\n\r\n    /*!\r\n     *  Recursively parses source files for the whole stack for the given software instance.\r\n\t *\r\n     *    @param [in] softComponent   The component of softInstance.\r\n     *    @param [in] softInstance   The software instance which active view is to be parsed.\r\n\t *    @param [in] makeData   The make data associated with the makefile as whole.\r\n\t *    @param [in] sysViewName  Name of the system view pointing to used design configuration.\r\n     */\r\n     void parseStackObjects(QSharedPointer<Component> softComponent, QSharedPointer<ComponentInstance> softInstance,\r\n         QSharedPointer<MakeFileData> makeData, QString const& systemViewName);\r\n\r\n    /*!\r\n     *  Tries to find a software instance by name and the component associated with it.\r\n     *\r\n     *    @param [in] instanceName   Name of the searched software instance.\r\n     *    @param [out] targetInstance   The found software instance.\r\n     *\r\n     *    @return The component of the found instance.\r\n     */\r\n     QSharedPointer<Component> searchSWComponent(QString instanceName, QSharedPointer<ComponentInstance>& targetInstance);\r\n\r\n\t //! The library containing all components in the design.\r\n     LibraryInterface* library_;\r\n\r\n     //! The top component of the design_.\r\n     QSharedPointer<Component> topComponent_;\r\n\r\n     //! The design to parse.\r\n     QSharedPointer<Design> design_;\r\n\r\n     //! The design configuration to parse.\r\n     QSharedPointer<DesignConfiguration> designConf_;\r\n\r\n     //! Collection of data sets, one for each makefile.\r\n\t QSharedPointer<QList<QSharedPointer<MakeFileData> > > parsedData_;\r\n\r\n     //! The fileSet for the main makefile and the launcher.\r\n     QSharedPointer<FileSet> generalFileSet_;\r\n};\r\n\r\n#endif // SWSTACKPARSER_H\r\n"
  },
  {
    "path": "Plugins/MakefileGenerator/makefile.json",
    "content": "{\r\n\t\"Keys\": [ \"makefile\" ]\r\n}"
  },
  {
    "path": "Plugins/MakefileGenerator/makefilegenerator_global.h",
    "content": "#ifndef MAKEFILEGENERATOR_GLOBAL_H\r\n#define MAKEFILEGENERATOR_GLOBAL_H\r\n\r\n#include <QtCore/qglobal.h>\r\n\r\n#ifdef MAKEFILEGENERATOR_LIB\r\n# define MAKEFILEGENERATOR_EXPORT Q_DECL_EXPORT\r\n#else\r\n# define MAKEFILEGENERATOR_EXPORT Q_DECL_IMPORT\r\n#endif\r\n\r\n#endif // MAKEFILEGENERATOR_GLOBAL_H\r\n"
  },
  {
    "path": "Plugins/MemoryMapHeaderGenerator/BaseMemoryMapHeaderWriter.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: BaseMemoryMapHeaderWriter.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 07.05.2015\r\n//\r\n// Description:\r\n// The base implementation for memory map header writer.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"BaseMemoryMapHeaderWriter.h\"\r\n\r\n#include <KactusAPI/include/LibraryInterface.h>\r\n\r\n#include <KactusAPI/include/IPluginUtility.h>\r\n\r\n#include <KactusAPI/include/ComponentParameterFinder.h>\r\n#include <KactusAPI/include/ParameterFinder.h>\r\n#include <KactusAPI/include/IPXactSystemVerilogParser.h>\r\n#include <KactusAPI/include/ExpressionFormatter.h>\r\n\r\n#include <editors/MemoryDesigner/MemoryItem.h>\r\n#include <editors/MemoryDesigner/MemoryDesignerConstants.h>\r\n\r\n#include <IPXACTmodels/common/AccessTypes.h>\r\n#include <IPXACTmodels/Component/FileSet.h>\r\n#include <IPXACTmodels/Component/File.h>\r\n#include <IPXACTmodels/Component/MemoryMapBase.h>\r\n\r\n#include <QCoreApplication>\r\n#include <QDate>\r\n#include <QSettings>\r\n#include <QDir>\r\n#include <QDesktopServices>\r\n#include <QUrl>\r\n#include <QLocale>\r\n#include <QMessageBox>\r\n#include <QTime>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BaseMemoryMapHeaderWriter::BaseMemoryMapHeaderWriter()\r\n//-----------------------------------------------------------------------------\r\nBaseMemoryMapHeaderWriter::BaseMemoryMapHeaderWriter(IPluginUtility* utility):\r\nutility_(utility)\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BaseMemoryMapHeaderWriter::BaseMemoryMapHeaderWriter()\r\n//-----------------------------------------------------------------------------\r\nBaseMemoryMapHeaderWriter::~BaseMemoryMapHeaderWriter()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BaseMemoryMapHeaderWriter::checkDirectoryStructure()\r\n//-----------------------------------------------------------------------------\r\nvoid BaseMemoryMapHeaderWriter::checkDirectoryStructure(QDir dir)\r\n{\r\n    if (!dir.exists())\r\n    {\r\n        QString dirName(dir.dirName());\r\n        dir.cdUp();\r\n        dir.mkpath(dirName);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BaseMemoryMapHeaderWriter::openFileErrorMessage()\r\n//-----------------------------------------------------------------------------\r\nvoid BaseMemoryMapHeaderWriter::openFileErrorMessage(QString const& absoluteFilePath)\r\n{\r\n    QString message(QObject::tr(\"File: %1 could not be opened for writing.\").arg(absoluteFilePath));\r\n    QMessageBox::critical(utility_->getParentWidget(), QCoreApplication::applicationName(), message);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BaseMemoryMapHeaderWriter::writeTopOfHeaderFile()\r\n//-----------------------------------------------------------------------------\r\nvoid BaseMemoryMapHeaderWriter::writeTopOfHeaderFile(QTextStream& stream, QString const& fileName,\r\n    QString const& header, QString const& description)\r\n{\r\n    stream << \"/*\" << Qt::endl;\r\n    stream << \" * File: \" << fileName << Qt::endl;\r\n    stream << \" * Created on: \" << QDate::currentDate().toString(\"dd.MM.yyyy\") << Qt::endl;\r\n\r\n    QSettings settings;\r\n    QString userName = settings.value(\"General/Username\").toString();\r\n\r\n    stream << \" * Generated by: \" << userName << Qt::endl;\r\n    stream << \" *\" << Qt::endl;\r\n    stream << \" * Description:\" << Qt::endl;\r\n    stream << description << Qt::endl;\r\n\r\n    stream << \"#ifndef \" << header << Qt::endl;\r\n    stream << \"#define \" << header << Qt::endl << Qt::endl;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BaseMemoryMapHeaderWriter::addHeaderFile()\r\n//-----------------------------------------------------------------------------\r\nvoid BaseMemoryMapHeaderWriter::addHeaderFile(QSharedPointer<Component> component, const QFileInfo& fileInfo,\r\n    QString const& filesetName, QStringList const& swViewNames, QString const& instanceId) const\r\n{\r\n    QString xmlDir = utility_->getLibraryInterface()->getDirectoryPath(component->getVlnv());\r\n\r\n    // if the directory does not exist\r\n    QDir ipXactDir(xmlDir);\r\n    Q_ASSERT(ipXactDir.exists());\r\n    Q_ASSERT(fileInfo.exists());\r\n\r\n    // calculate the relative path \r\n    QString relPath =  ipXactDir.relativeFilePath(fileInfo.absoluteFilePath());\r\n\r\n    // file set where the file is added to\r\n    QSharedPointer<FileSet> fileSet = component->getFileSet(filesetName);\r\n    if (fileSet.isNull())\r\n    {\r\n        fileSet = QSharedPointer<FileSet>(new FileSet(filesetName));\r\n        component->getFileSets()->append(fileSet);\r\n    }\r\n\r\n    fileSet->setGroups(\"generatedFiles\");\r\n    fileSet->setDescription(QObject::tr(\"Contains header files generated for the component.\\n\"\r\n        \"Do not rename this file set, name is used to find the generated headers.\"));\r\n\r\n    // if instance id was specified\r\n    if (!instanceId.isEmpty())\r\n    {\r\n        // use the same id as the instance the file set is created for.\r\n        fileSet->setFileSetId(instanceId);\r\n    }\r\n\r\n    QSettings settings;\r\n    QSharedPointer<File> file = fileSet->addFile(relPath, settings);\r\n    Q_ASSERT(file);\r\n\r\n    file->setDescription(QObject::tr(\"A header file generated by Kactus2.\\n\"\r\n        \"This file contains the register and memory addresses defined in the memory map(s)\"));\r\n    file->setIncludeFile(true);\r\n\r\n    foreach (QSharedPointer<View> swView, *component->getViews())\r\n    {\r\n        if (swViewNames.contains(swView->name()))\r\n        {\r\n            QSharedPointer<ComponentInstantiation> insta = component->getModel()->findComponentInstantiation(swView->getComponentInstantiationRef());\r\n\r\n            if (insta)\r\n            {\r\n                QSharedPointer<FileSetRef> newFileSetRef(new FileSetRef());\r\n                newFileSetRef->setReference(filesetName);\r\n\r\n                insta->getFileSetReferences()->append(newFileSetRef);\r\n            }\r\n        }\r\n    }\r\n\r\n    displayMemoryMapHeader(fileInfo.absoluteFilePath());\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BaseMemoryMapHeaderWriter::displayMemoryMapHeader()\r\n//-----------------------------------------------------------------------------\r\nvoid BaseMemoryMapHeaderWriter::displayMemoryMapHeader(QString const& filePath) const\r\n{\r\n    QDesktopServices::openUrl(QUrl::fromLocalFile(filePath));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BaseMemoryMapHeaderWriter::writeRegistersFromMemoryMap()\r\n//-----------------------------------------------------------------------------\r\nvoid BaseMemoryMapHeaderWriter::writeRegisterFromMemoryMap(QSharedPointer<ParameterFinder> finder,\r\n    QSharedPointer<MemoryMapBase> containingMemoryMap, QTextStream& stream, bool useAddressBlockID, quint64 offset,\r\n    QString const& idString)\r\n{\r\n    QSharedPointer<IPXactSystemVerilogParser> expressionParser (new IPXactSystemVerilogParser(finder));\r\n    QSharedPointer<ExpressionFormatter> formatter (new ExpressionFormatter(finder));\r\n\r\n    foreach (QSharedPointer<MemoryBlockBase> memoryItem, *containingMemoryMap->getMemoryBlocks())\r\n    {\r\n        QSharedPointer<AddressBlock> addressBlock = memoryItem.dynamicCast<AddressBlock>();\r\n\r\n        if (addressBlock && (addressBlock->getUsage() == General::REGISTER || (General::usage2Str(\r\n            addressBlock->getUsage()).isEmpty() && !addressBlock->getRegisterData()->isEmpty())))\r\n        {\r\n            writeRegistersFromAddressBlock(expressionParser, formatter, addressBlock, stream, useAddressBlockID,\r\n                offset, idString);\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BaseMemoryMapHeaderWriter::writeRegisterFromMemoryMap()\r\n//-----------------------------------------------------------------------------\r\nvoid BaseMemoryMapHeaderWriter::writeRegisterFromMemoryMap(AddressContainer const& addressContainer,\r\n    QTextStream& stream,\r\n    QSharedPointer<MemoryItem> memoryItem,\r\n    bool useAddressBlockID,\r\n    QString const& idString /* = QString() */) const\r\n{\r\n    for (auto blockItem : memoryItem->getChildItems())\r\n\t{\r\n        if (blockItem && blockItem->getType() == MemoryDesignerConstants::ADDRESSBLOCK_TYPE &&\r\n            (blockItem->getUsage() == General::REGISTER ||\r\n                (blockItem->getUsage() == General::USAGE_COUNT && blockItem->getChildItems().isEmpty() == false )))\r\n\t\t{\r\n            writeRegistersFromAddressBlock(addressContainer, stream, blockItem, useAddressBlockID, idString);\r\n\t\t}\r\n\t}\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BaseMemoryMapHeaderWriter::writeRegistersFromAddressBlock()\r\n//-----------------------------------------------------------------------------\r\nvoid BaseMemoryMapHeaderWriter::writeRegistersFromAddressBlock(QSharedPointer<ExpressionParser> expressionParser,\r\n    QSharedPointer<ExpressionFormatter> formatter, QSharedPointer<AddressBlock> currentAddressBlock,\r\n    QTextStream& stream, bool useAddressBlockID, quint64 offset, QString const& idString)\r\n{\r\n    QString addressBlockOffsetInt = expressionParser->parseExpression(currentAddressBlock->getBaseAddress());\r\n    quint64 addressBlockOffset = addressBlockOffsetInt.toUInt() + offset;\r\n    \r\n    QString id;\r\n    if (!idString.isEmpty())\r\n    {\r\n        id = idString;\r\n        if (useAddressBlockID)\r\n        {\r\n            id.append(currentAddressBlock->name().toUpper());\r\n        }\r\n    }\r\n    \r\n    if (useAddressBlockID)\r\n    {\r\n        id.append(currentAddressBlock->name().toUpper());\r\n    }\r\n\r\n    stream << \"/*\" << Qt::endl;\r\n    stream << \" * Address block: \" << currentAddressBlock->name() << Qt::endl;\r\n    if (!currentAddressBlock->description().isEmpty())\r\n    {\r\n        stream << \" * Description:\" << Qt::endl;\r\n        stream << \" * \" << currentAddressBlock->description() << Qt::endl;\r\n    }\r\n    stream << \"*/\" << Qt::endl;\r\n\r\n    foreach (QSharedPointer<RegisterBase> registerModelItem, *currentAddressBlock->getRegisterData())\r\n    {\r\n        QSharedPointer<Register> registerItem = registerModelItem.dynamicCast<Register>();\r\n        if (registerItem)\r\n        {\r\n            writeRegister(expressionParser, formatter, registerItem, stream, addressBlockOffset, id);\r\n        }\r\n    }\r\n    stream << Qt::endl;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BaseMemoryMapHeaderWriter::writeRegistersFromAddressBlock()\r\n//-----------------------------------------------------------------------------\r\nvoid BaseMemoryMapHeaderWriter::writeRegistersFromAddressBlock(AddressContainer const& addressContainer,\r\n    QTextStream& stream,\r\n    QSharedPointer<MemoryItem> blockItem,\r\n    bool useAddressBlockID,\r\n    QString const& idString /* = QString() */) const\r\n{\r\n    auto addressBlockOffset = blockItem->getAddress().toULongLong() + addressContainer.baseAddress_;\r\n\r\n    QString id;\r\n    if (!idString.isEmpty())\r\n    {\r\n        id = idString;\r\n        if (useAddressBlockID)\r\n        {\r\n            id.append(blockItem->getName().toUpper());\r\n        }\r\n    }\r\n\r\n    if (useAddressBlockID)\r\n    {\r\n        id.append(blockItem->getName().toUpper());\r\n    }\r\n\r\n    if (addressContainer.hasRemapRange_ && addressBlockOffset > addressContainer.lastAddress_)\r\n    {\r\n        return;\r\n    }\r\n\r\n    stream << \"/*\" << Qt::endl;\r\n\tstream << \" * Address block: \" << blockItem->getName() << Qt::endl;\r\n    if (blockItem->getDescription().isEmpty() == false)\r\n    {\r\n        stream << \" * Description:\" << Qt::endl;\r\n\t\tstream << \" * \" << blockItem->getDescription() << Qt::endl;\r\n    }\r\n    stream << \"*/\" << Qt::endl;\r\n\r\n    for (auto registerItem : blockItem->getChildItems())\r\n    {\r\n        if (registerItem && registerItem->getType() == MemoryDesignerConstants::REGISTER_TYPE)\r\n        {\r\n            writeRegister(addressBlockOffset, addressContainer, stream, registerItem, id);\r\n        }\r\n    }\r\n    stream << Qt::endl;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BaseMemoryMapHeaderWriter::writeRegister()\r\n//-----------------------------------------------------------------------------\r\nvoid BaseMemoryMapHeaderWriter::writeRegister(QSharedPointer<ExpressionParser> expressionParser,\r\n    QSharedPointer<ExpressionFormatter> formatter, QSharedPointer<Register> currentRegister, QTextStream& stream,\r\n    quint64 addressBlockOffset, QString const& idString /* = QString() */)\r\n{\r\n    QString parsedOffset = expressionParser->parseExpression(currentRegister->getAddressOffset());\r\n    quint64 registerOffsetInt = parsedOffset.toUInt() + addressBlockOffset;\r\n    QString registerOffsetString = QString::number(registerOffsetInt, 16);\r\n    registerOffsetString.prepend(\"0x\");\r\n\r\n    stream << \"/*\" << Qt::endl;\r\n    stream << \" * Register name: \" << currentRegister->name() << Qt::endl;\r\n\r\n    if (!currentRegister->description().isEmpty())\r\n    {\r\n        stream << \" * Description:\" << Qt::endl;\r\n        stream << \" * \" << currentRegister->description() << Qt::endl;\r\n    }\r\n\r\n    stream << \" * Offset: \" << formatter->formatReferringExpression(currentRegister->getAddressOffset());\r\n    if (!expressionParser->isPlainValue(currentRegister->getAddressOffset()))\r\n    {\r\n        quint64 parsedOffsetInt = parsedOffset.toUInt();\r\n        QString parsedOffsetString = QString::number(parsedOffsetInt, 16);\r\n        stream << \" = 0x\" << parsedOffsetString;\r\n    }\r\n\r\n    stream << Qt::endl << \"*/\" << Qt::endl;\r\n    stream << \"#define \";\r\n\r\n    if (idString.isEmpty())\r\n    {\r\n        stream << currentRegister->name().toUpper() << \" \" << registerOffsetString;\r\n    }\r\n    else\r\n    {\r\n        stream << idString.toUpper() << \"_\" << currentRegister->name().toUpper() << \" \" <<\r\n            registerOffsetString;\r\n    }\r\n\r\n    stream << Qt::endl;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BaseMemoryMapHeaderWriter::writeRegister()\r\n//-----------------------------------------------------------------------------\r\nvoid BaseMemoryMapHeaderWriter::writeRegister(quint64 const& addressBlockOffset,\r\n    AddressContainer const& addressContainer,\r\n    QTextStream& stream,\r\n    QSharedPointer<MemoryItem> registerItem,\r\n    QString const& idString /* = QString() */) const\r\n{\r\n    auto registerOffsetInt = registerItem->getOffset().toULongLong() + addressBlockOffset;\r\n    QString registerOffsetString = QString::number(registerOffsetInt, 16);\r\n    registerOffsetString.prepend(\"0x\");\r\n\r\n    if (addressContainer.hasRemapRange_ && registerOffsetInt > addressContainer.lastAddress_)\r\n    {\r\n        return;\r\n    }\r\n\r\n    stream << \"/*\" << Qt::endl;\r\n\tstream << \" * Register name: \" << registerItem->getName() << Qt::endl;\r\n\r\n\tif (!registerItem->getDescription().isEmpty())\r\n    {\r\n        stream << \" * Description:\" << Qt::endl;\r\n\t\tstream << \" * \" << registerItem->getDescription() << Qt::endl;\r\n    }\r\n\r\n    QString offsetString = registerItem->getOffset();\r\n\tauto offsetInteger = offsetString.toULongLong();\r\n    auto finalOffsetString = \"0x\" + QString::number(offsetInteger, 16);\r\n\r\n    if (registerItem->getFormattedOffsetExpression().isEmpty() == false)\r\n    {\r\n        finalOffsetString = registerItem->getFormattedOffsetExpression() + \" = \" + finalOffsetString;\r\n    }\r\n\r\n    stream << \" * Offset: \" << finalOffsetString;\r\n    stream << Qt::endl << \"*/\" << Qt::endl;\r\n    stream << \"#define \";\r\n\r\n    if (idString.isEmpty())\r\n    {\r\n\t\tstream << registerItem->getName().toUpper() << \" \" << registerOffsetString;\r\n    }\r\n    else\r\n    {\r\n\t\tstream << idString.toUpper() << \"_\" << registerItem->getName().toUpper() << \" \" << registerOffsetString;\r\n    }\r\n\r\n    stream << Qt::endl;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BaseMemoryMapHeaderWriter::writeMemoryAddresses()\r\n//-----------------------------------------------------------------------------\r\nvoid BaseMemoryMapHeaderWriter::writeMemoryAddresses(QSharedPointer<ParameterFinder> finder,\r\n    QSharedPointer<MemoryMapBase> targetMemoryMap, QTextStream& stream, quint64 offset,\r\n    QString const& idString) const\r\n{\r\n    QSharedPointer<IPXactSystemVerilogParser> expressionParser (new IPXactSystemVerilogParser(finder));\r\n    QSharedPointer<ExpressionFormatter> formatter (new ExpressionFormatter(finder));\r\n\r\n    foreach (QSharedPointer<MemoryBlockBase> memoryItem, *targetMemoryMap->getMemoryBlocks())\r\n    {\r\n        QSharedPointer<AddressBlock> currentAddressBlock = memoryItem.dynamicCast<AddressBlock>();\r\n        if (currentAddressBlock && (currentAddressBlock->getUsage() == General::MEMORY ||\r\n            currentAddressBlock->getUsage() == General::RESERVED))\r\n        {\r\n            QString addressOffsetString = expressionParser->parseExpression(currentAddressBlock->getBaseAddress());\r\n            quint64 addressOffset = addressOffsetString.toUInt() + offset;\r\n            QString addressStart = QString::number(addressOffset, 16);\r\n            addressStart.prepend(\"0x\");\r\n\r\n            QString endAddress = getAddressBlockLastAddress(offset, currentAddressBlock, expressionParser);\r\n            \r\n            stream << \"/*\" << Qt::endl;\r\n            if (currentAddressBlock->getUsage() == General::MEMORY)\r\n            {\r\n                stream << \" * Memory block name: \" << currentAddressBlock->name() << Qt::endl;\r\n            }\r\n            else\r\n            {\r\n                stream << \" * Reserved block name: \" << currentAddressBlock->name() << Qt::endl;\r\n            }\r\n\r\n            stream << \" * Width: \" << expressionParser->parseExpression(currentAddressBlock->getWidth());\r\n            if (!expressionParser->isPlainValue(currentAddressBlock->getWidth()))\r\n            {\r\n                stream << \" = \" << formatter->formatReferringExpression(currentAddressBlock->getWidth());\r\n            }\r\n            stream << Qt::endl;\r\n\r\n            QString parseRange = expressionParser->parseExpression(currentAddressBlock->getRange());\r\n\r\n            stream << \" * Range: \" << expressionParser->parseExpression(currentAddressBlock->getRange());\r\n            if (!expressionParser->isPlainValue(currentAddressBlock->getRange()))\r\n            {\r\n                stream << \" = \" << formatter->formatReferringExpression(currentAddressBlock->getRange());\r\n            }\r\n            stream << Qt::endl;\r\n\r\n            QString accessString = AccessTypes::access2Str(currentAddressBlock->getAccess());\r\n            if (!accessString.isEmpty())\r\n            {\r\n                stream << \" * Access: \" << accessString << Qt::endl;\r\n            }\r\n            stream << \"*/\" << Qt::endl;\r\n\r\n            QString blockName = currentAddressBlock->name().toUpper();\r\n            if (!idString.isEmpty())\r\n            {\r\n                blockName = idString.toUpper() + \"_\" + blockName;\r\n            }\r\n            stream << \"#define \" << blockName << \"_START \" << addressStart;\r\n            if (!expressionParser->isPlainValue(currentAddressBlock->getBaseAddress()))\r\n            {\r\n                stream << \" // \" << formatter->formatReferringExpression(currentAddressBlock->getBaseAddress());\r\n            }\r\n            stream << Qt::endl;\r\n            stream << \"#define \" << blockName << \"_END \" << endAddress << Qt::endl;\r\n            stream << Qt::endl;\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BaseMemoryMapHeaderWriter::writeMemoryAddresses()\r\n//-----------------------------------------------------------------------------\r\nvoid BaseMemoryMapHeaderWriter::writeMemoryAddresses(AddressContainer const& addressContainer,\r\n    QTextStream& stream,\r\n    QSharedPointer<MemoryItem> memoryItem,\r\n    QString const& idString) const\r\n{\r\n    for (auto blockItem : memoryItem->getChildItems())\r\n    {\r\n        if (blockItem->getType() != MemoryDesignerConstants::ADDRESSBLOCK_TYPE)\r\n        {\r\n            continue;\r\n        }\r\n\r\n\t\tif (blockItem->getUsage() == General::MEMORY || blockItem->getUsage() == General::RESERVED)\r\n        {\r\n            quint64 addressOffset = blockItem->getAddress().toULongLong() + addressContainer.baseAddress_;\r\n            QString addressStart = QString::number(addressOffset, 16);\r\n            addressStart.prepend(\"0x\");\r\n\r\n            quint64 endAddressInt = addressOffset + blockItem->getRange().toULongLong();\r\n\t\t\tif (endAddressInt > 0)\r\n\t\t\t{\r\n\t\t\t\tendAddressInt -= 1;\r\n\t\t\t}\r\n\r\n            if (addressContainer.hasRemapRange_)\r\n            {\r\n                if (addressOffset > addressContainer.lastAddress_)\r\n                {\r\n                    //! Do not write when the address block starts beyond the address range.\r\n                    return;\r\n                }\r\n                else if (endAddressInt > addressContainer.lastAddress_)\r\n                {\r\n                    endAddressInt = addressContainer.lastAddress_;\r\n                }\r\n            }\r\n\r\n            QString endAddress = \"0x\" + QString::number(endAddressInt, 16);\r\n\r\n            stream << \"/*\" << Qt::endl;\r\n\t\t\tif (blockItem->getUsage() == General::MEMORY)\r\n            {\r\n                stream << \" * Memory block name: \" << blockItem->getName() << Qt::endl;\r\n            }\r\n            else\r\n            {\r\n\t\t\t\tstream << \" * Reserved block name: \" << blockItem->getName() << Qt::endl;\r\n            }\r\n\r\n\t\t\tstream << \" * Width: \" << blockItem->getWidth();\r\n\t\t\tif (blockItem->getFormattedWidthExpression().isEmpty() == false)\r\n\t\t\t{\r\n\t\t\t\tstream << \" = \" << blockItem->getFormattedWidthExpression();\r\n\t\t\t}\r\n            stream << Qt::endl;\r\n\r\n\t\t\tstream << \" * Range: \" << blockItem->getRange();\r\n\t\t\tif (blockItem->getFormattedRangeExpression().isEmpty() == false)\r\n\t\t\t{\r\n\t\t\t\tstream << \" = \" << blockItem->getFormattedRangeExpression();\r\n\t\t\t}\r\n            stream << Qt::endl;\r\n\r\n\t\t\tif (auto accessString = AccessTypes::access2Str(blockItem->getAccess()); !accessString.isEmpty())\r\n            {\r\n                stream << \" * Access: \" << accessString << Qt::endl;\r\n            }\r\n            stream << \"*/\" << Qt::endl;\r\n\r\n\t\t\tQString blockName = blockItem->getName().toUpper();\r\n            if (!idString.isEmpty())\r\n            {\r\n                blockName = idString.toUpper() + \"_\" + blockName;\r\n            }\r\n            \r\n            stream << \"#define \" << blockName << \"_START \" << addressStart;\r\n\r\n            if (blockItem->getFormattedAddressExpression().isEmpty() == false)\r\n            {\r\n\t\t\t\tstream << \" // \" << blockItem->getFormattedAddressExpression();\r\n            }\r\n            stream << Qt::endl;\r\n            stream << \"#define \" << blockName << \"_END \" << endAddress << Qt::endl;\r\n            stream << Qt::endl;\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BaseMemoryMapHeaderWriter::getAddressBlockLastAddress()\r\n//-----------------------------------------------------------------------------\r\nQString BaseMemoryMapHeaderWriter::getAddressBlockLastAddress(\r\n    quint64 const& offset,\r\n    QSharedPointer<AddressBlock> targetAddressBlock,\r\n    QSharedPointer<ExpressionParser> expressionParser) const\r\n{\r\n    QString parsedBaseAddress = expressionParser->parseExpression(targetAddressBlock->getBaseAddress());\r\n    QString parsedRange = expressionParser->parseExpression(targetAddressBlock->getRange());\r\n\r\n    quint64 lastAddress = offset + parsedBaseAddress.toUInt() + parsedRange.toUInt();\r\n    QString lastAddressString = \"0x\";\r\n    if (lastAddress != 0)\r\n    {\r\n        lastAddress -= 1;\r\n    }\r\n\r\n    lastAddressString.append(QString::number(lastAddress, 16));\r\n    return lastAddressString;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BaseMemoryMapHeaderWriter::formattedValueFor()\r\n//-----------------------------------------------------------------------------\r\nQString BaseMemoryMapHeaderWriter::parsedValueFor(QString const& expression,\r\n    QSharedPointer<ParameterFinder> finder) const\r\n{\r\n    QSharedPointer<IPXactSystemVerilogParser> expressionParser (new IPXactSystemVerilogParser(finder));\r\n\r\n    return expressionParser->parseExpression(expression);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BaseMemoryMapHeaderWriter::informStartOfGeneration()\r\n//-----------------------------------------------------------------------------\r\nvoid BaseMemoryMapHeaderWriter::informStartOfGeneration() const\r\n{\r\n    auto locale = QLocale::system();\r\n    utility_->printInfo(QObject::tr(\"Generation started %1 %2\").arg(locale.toString(QDate::currentDate(),\r\n        locale.dateFormat(QLocale::ShortFormat)), locale.toString(QTime::currentTime(), locale.timeFormat(QLocale::ShortFormat))));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BaseMemoryMapHeaderWriter::informWritingFinished()\r\n//-----------------------------------------------------------------------------\r\nvoid BaseMemoryMapHeaderWriter::informWritingFinished(QString const& outputFile) const\r\n{\r\n    utility_->printInfo(QObject::tr(\"Finished writing file %1.\").arg(outputFile));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BaseMemoryMapHeaderWriter::informGenerationComplete()\r\n//-----------------------------------------------------------------------------\r\nvoid BaseMemoryMapHeaderWriter::informGenerationComplete() const\r\n{\r\n    utility_->printInfo(QObject::tr(\"Generation complete.\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BaseMemoryMapHeaderWriter::informGenerationAbort()\r\n//-----------------------------------------------------------------------------\r\nvoid BaseMemoryMapHeaderWriter::informGenerationAbort() const\r\n{\r\n    utility_->printInfo(QObject::tr(\"Generation aborted.\"));\r\n}\r\n"
  },
  {
    "path": "Plugins/MemoryMapHeaderGenerator/BaseMemoryMapHeaderWriter.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: BaseMemoryMapHeaderWriter.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 07.05.2015\r\n//\r\n// Description:\r\n// The base implementation for memory map header writer.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef BASEMEMORYMAPHEADERWRITER_H\r\n#define BASEMEMORYMAPHEADERWRITER_H\r\n\r\n#include <IPXACTmodels/Component/Component.h>\r\n#include <IPXACTmodels/Component/AddressBlock.h>\r\n#include <IPXACTmodels/Component/Register.h>\r\n#include <IPXACTmodels/Component/MemoryMap.h>\r\n\r\n#include <QFileInfo>\r\n#include <QObject>\r\n#include <QSharedPointer>\r\n#include <QString>\r\n#include <QFileInfo>\r\n#include <QList>\r\n#include <QTextStream>\r\n#include <QDir>\r\n\r\nclass IPluginUtility;\r\nclass PluginUtilityAdapter;\r\nclass ExpressionParser;\r\nclass ExpressionFormatter;\r\nclass ParameterFinder;\r\nclass MemoryMapBase;\r\nclass MemoryItem;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! The base implementation for memory map header writer.\r\n//-----------------------------------------------------------------------------\r\nclass BaseMemoryMapHeaderWriter\r\n{\r\n\r\npublic:\r\n\r\n\t/*!\r\n\t *  The constructor.\r\n\t *\r\n\t *    @param [in] utility     Interface which offers core utilities for plugins.\r\n\t */\r\n\tBaseMemoryMapHeaderWriter(IPluginUtility* utility);\r\n\r\n    /*!\r\n     *  The destructor.\r\n     */\r\n    virtual ~BaseMemoryMapHeaderWriter();\r\n\r\nprotected:\r\n\r\n    //! The container for address data.\r\n    struct AddressContainer\r\n    {\r\n        //! Base address\r\n        quint64 baseAddress_ = 0;\r\n\r\n        //! Last address\r\n        quint64 lastAddress_ = 0;\r\n\r\n        //! Flag for contained remap range.\r\n        bool hasRemapRange_ = false;\r\n    };\r\n\r\n    /*!\r\n     *  Check that the directory structure exists for the file.\r\n     *\r\n     *    @param [in] dir     The directory for the file.\r\n     */\r\n    void checkDirectoryStructure(QDir dir);\r\n\r\n    /*!\r\n     *  Display an error message when opening a file.\r\n     *\r\n     *    @param [in] absoluteFilePath    The file path of the file that couldn't be opened.\r\n     */\r\n    void openFileErrorMessage(QString const& absoluteFilePath);\r\n\r\n    /*!\r\n     *  Write the top part of the header file.\r\n     *\r\n     *    @param [in] stream          The text stream used for writing.\r\n     *    @param [in] fileName        The name of the file being written.\r\n     *    @param [in] header          The header guard of the file.\r\n     *    @param [in] description     The description of the file.\r\n     */\r\n    void writeTopOfHeaderFile(QTextStream& stream, QString const& fileName, QString const& header,\r\n        QString const& description);\r\n\r\n\t/*!\r\n\t *  Add a generated file to the file sets of a component.\r\n\t *\r\n\t *    @param [in] component       Pointer to the component where the file is added to.\r\n\t *    @param [in] fileInfo        Contains the info on the generated file.\r\n\t *    @param [in] filesetName     The name of the file set to add the header file to.\r\n\t *    @param [in] swViewNames     Contains the names of the sw views to add the file set reference to.\r\n\t *    @param [in] instanceId      The id of the instance which is used when generating global headers.\r\n\t */\r\n\tvoid addHeaderFile(QSharedPointer<Component> component, const QFileInfo& fileInfo, const QString& filesetName,\r\n\t\tconst QStringList& swViewNames = QStringList(), const QString& instanceId = QString()) const;\r\n\r\n    /*!\r\n     *  Display the created memory map header file for the user.\r\n     *\r\n     *    @param [in] filePath    The path to the created file.\r\n     */\r\n    virtual void displayMemoryMapHeader(QString const& filePath) const;\r\n\r\n    /*!\r\n     *  Write the registers contained in a memory map.\r\n     *\r\n     *    @param [in] finder                  The parameter finder containing the referenced parameters.\r\n     *    @param [in] containingMemoryMap     The base memory map containing the registers.\r\n     *    @param [in] stream                  The text stream to write into.\r\n     *    @param [in] useAddressBlockID       Tells if an address block id is needed for the register name.\r\n     *    @param [in] offset                  The current offset.\r\n     *    @param [in] idString                Helps to identify non-unique registers.\r\n     */\r\n    void writeRegisterFromMemoryMap(QSharedPointer<ParameterFinder> finder,\r\n        QSharedPointer<MemoryMapBase> containingMemoryMap, QTextStream& stream, bool useAddressBlockID,\r\n        quint64 offset, QString const& idString = QString());\r\n\r\n    /*!\r\n     *  Write the registers contained in a memory map.\r\n     *\r\n     *    @param [in] addressContainer      Container for the address values changed during the route inspection.\r\n     *    @param [in] stream                The text stream to write into.\r\n     *    @param [in] memoryItem            Memory item containing the registers.\r\n     *    @param [in] useAddressBlockID     Flag for using an address block ID.\r\n     *    @param [in] idString              Helps to identify non-unique registers.\r\n     */\r\n    void writeRegisterFromMemoryMap(AddressContainer const& addressContainer,\r\n\t\tQTextStream& stream,\r\n\t\tQSharedPointer<MemoryItem> memoryItem,\r\n        bool useAddressBlockID,\r\n\t\tQString const& idString = QString()) const;\r\n\r\n    /*!\r\n     *  Write registers contained in an address block.\r\n     *\r\n     *    @param [in] expressionParser        The expression parser.\r\n     *    @param [in] formatter               The expression formatter, for changing parameter ids into names.\r\n     *    @param [in] currentAddressBlock     Pointer to the address block.\r\n     *    @param [in] stream                  The text stream to write into.\r\n     *    @param [in] useAddressBlockID       Tells if an address block id is needed for the register name.\r\n     *    @param [in] offset                  The current offset.\r\n     *    @param [in] idString                Helps to identify non-unique registers.\r\n     */\r\n    void writeRegistersFromAddressBlock(QSharedPointer<ExpressionParser> expressionParser,\r\n        QSharedPointer<ExpressionFormatter> formatter, QSharedPointer<AddressBlock> currentAddressBlock,\r\n        QTextStream& stream, bool useAddressBlockID, quint64 offset, QString const& idString = QString());\r\n\r\n    /*!\r\n     *  Write registers contained in an address block.\r\n     *\r\n\t *    @param [in] addressContainer      Container for the address values changed during the route inspection.\r\n\t *    @param [in] stream                The text stream to write into.\r\n\t *    @param [in] blockItem             Address block item containing the registers.\r\n\t *    @param [in] useAddressBlockID     Flag for using an address block ID.\r\n\t *    @param [in] idString              Helps to identify non-unique registers.\r\n     */\r\n    void writeRegistersFromAddressBlock(AddressContainer const& addressContainer,\r\n        QTextStream& stream,\r\n        QSharedPointer<MemoryItem> blockItem,\r\n        bool useAddressBlockID,\r\n        QString const& idString = QString()) const;\r\n\r\n    /*!\r\n     *  Write the register information to a text stream.\r\n     *\r\n     *    @param [in] expressionParser    The expression parser.\r\n     *    @param [in] formatter           The expression formatter, used to change parameter ids into names.\r\n     *    @param [in] currentRegister     The current register.\r\n     *    @param [in] stream              The text stream to write into.\r\n     *    @param [in] addressBlockOffset  The current offset.\r\n     *    @param [in] idString            Helps to identify non-unique registers.\r\n     */\r\n    void writeRegister(QSharedPointer<ExpressionParser> expressionParser,\r\n        QSharedPointer<ExpressionFormatter> formatter, QSharedPointer<Register> currentRegister, QTextStream& stream,\r\n        quint64 addressBlockOffset, QString const& idString = QString());\r\n\r\n    /*!\r\n     *  Write the register information to a text stream.\r\n     *\r\n     *    @param [in] addressBlockOffset    Offset of the containing address block.\r\n     *    @param [in] addressContainer      Container for the address values changed during the route inspection.\r\n     *    @param [in] stream                The text stream to write into.\r\n     *    @param [in] registerItem          Register item to be written.\r\n     *    @param [in] idString              Helps to identify non-unique registers.\r\n     */\r\n    void writeRegister(quint64 const& addressBlockOffset,\r\n        AddressContainer const& addressContainer,\r\n        QTextStream& stream,\r\n        QSharedPointer<MemoryItem> registerItem,\r\n\t\tQString const& idString = QString()) const;\r\n\r\n    /*!\r\n     *  Write the memory names and given addresses.\r\n     *\r\n     *    @param [in] finder              The parameter finder containing the referenced parameters.\r\n     *    @param [in] targetMemoryMap     The used base memory map.\r\n     *    @param [in] stream              The text stream to write into.\r\n     *    @param [in] offset              The current offset.\r\n     *    @param [in] idString            Helps to identify non-unique elements.\r\n     */\r\n    void writeMemoryAddresses(QSharedPointer<ParameterFinder> finder,\r\n        QSharedPointer<MemoryMapBase> targetMemoryMap, QTextStream& stream, quint64 offset,\r\n        QString const& idString = QString()) const;\r\n\r\n    /*!\r\n     *  Write the memory names and given addresses.\r\n     *\r\n     *    @param [in] addressContainer  Container for the address values changed during the route inspection.\r\n     *    @param [in] stream            The text stream to write into.\r\n     *    @param [in] memoryItem        The selected memory item.\r\n     *    @param [in] idString          Helps to identify non-unique elements.\r\n     */\r\n    void writeMemoryAddresses(AddressContainer const& addressContainer,\r\n        QTextStream& stream,\r\n        QSharedPointer<MemoryItem> memoryItem,\r\n        QString const& idString = QString()) const;\r\n\r\n    /*!\r\n     *  Gets the ending address of an address block.\r\n     *\r\n     *      @param [in] offset              The current offset\r\n     *      @param [in] targetAddressBlock  The address block being examined.\r\n     *      @param [in] expressionParser    The expression parser.\r\n     *\r\n     *      @return The ending address of the address block.\r\n     */\r\n\tQString getAddressBlockLastAddress(quint64 const& offset,\r\n        QSharedPointer<AddressBlock> targetAddressBlock,\r\n\t\tQSharedPointer<ExpressionParser> expressionParser) const;\r\n\r\n    /*!\r\n     *  Get the parsed value for a given expression.\r\n     *\r\n     *    @param [in] expression  The expression to be parsed.\r\n     *    @param [in] finder      The parameter finder used in the parser.\r\n     *\r\n     *    @return The parsed value for the given expression.\r\n     */\r\n    QString parsedValueFor(QString const& expression, QSharedPointer<ParameterFinder> finder) const;\r\n\r\n    /*!\r\n     *  Inform of the start of the generator.\r\n     */\r\n    void informStartOfGeneration() const;\r\n\r\n    /*!\r\n     *  Inform when the writing has been finished.\r\n     *\r\n     *    @param [in] outputFile  The name of the output file.\r\n     */\r\n    void informWritingFinished(QString const& outputFile) const;\r\n\r\n    /*!\r\n     *  Inform of the generation finish.\r\n     */\r\n    void informGenerationComplete() const;\r\n\r\n    /*!\r\n     *  Inform of the generation abort.\r\n     */\r\n    void informGenerationAbort() const;\r\n\r\n    //! The interface which offers core utilities for plugins.\r\n    IPluginUtility* utility_;\r\n\r\nprivate:\r\n\r\n\t//! No copying\r\n    BaseMemoryMapHeaderWriter(const BaseMemoryMapHeaderWriter& other);\r\n\r\n\t//! No assignment\r\n    BaseMemoryMapHeaderWriter& operator=(const BaseMemoryMapHeaderWriter& other);\r\n\r\n};\r\n\r\n#endif // BASEMEMORYMAPHEADERWRITER_H\r\n"
  },
  {
    "path": "Plugins/MemoryMapHeaderGenerator/GlobalMemoryMapHeaderWriter.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: GlobalMemoryMapHeaderWriter.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 08.05.2015\r\n//\r\n// Description:\r\n// The implementation for creating c-headers of global memory maps.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"GlobalMemoryMapHeaderWriter.h\"\r\n\r\n#include <KactusAPI/include/LibraryInterface.h>\r\n#include <KactusAPI/include/IPluginUtility.h>\r\n#include <KactusAPI/include/ListParameterFinder.h>\r\n\r\n#include <editors/MemoryDesigner/MemoryItem.h>\r\n#include <editors/MemoryDesigner/MemoryDesignerConstants.h>\r\n\r\n#include <Plugins/common/ConnectivityGraphUtilities.h>\r\n#include <Plugins/MemoryMapHeaderGenerator/fileSaveDialog/filesavedialog.h>\r\n\r\n#include <IPXACTmodels/Component/BusInterface.h>\r\n#include <IPXACTmodels/Component/Channel.h>\r\n#include <IPXACTmodels/Component/InitiatorInterface.h>\r\n#include <IPXACTmodels/Component/MirroredTargetInterface.h>\r\n#include <IPXACTmodels/Component/TargetInterface.h>\r\n\r\n#include <QDate>\r\n#include <QDir>\r\n#include <QDesktopServices>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: GlobalMemoryMapHeaderWriter::GlobalMemoryMapHeaderWriter()\r\n//-----------------------------------------------------------------------------\r\nGlobalMemoryMapHeaderWriter::GlobalMemoryMapHeaderWriter(IPluginUtility* utility,\r\n    QSharedPointer<Design> componentDesign, QSharedPointer<DesignConfiguration> componentDesignConfig,\r\n    QObject* parentObject):\r\nBaseMemoryMapHeaderWriter(utility),\r\nparentObject_(parentObject),\r\ncomponentDesign_(componentDesign),\r\ncomponentDesignConfig_(componentDesignConfig),\r\noperatedInterfaces_(),\r\nsaveOptions_()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: GlobalMemoryMapHeaderWriter::GlobalMemoryMapHeaderWriter()\r\n//-----------------------------------------------------------------------------\r\nGlobalMemoryMapHeaderWriter::~GlobalMemoryMapHeaderWriter()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: GlobalMemoryMapHeaderWriter::writeMemoryMapHeader()\r\n//-----------------------------------------------------------------------------\r\nvoid GlobalMemoryMapHeaderWriter::writeMemoryMapHeader(QSharedPointer<Component> globalComponent,\r\n    QList<QSharedPointer<GlobalHeaderSaveModel::SaveFileOptions> > saveOptions)\r\n{\r\n    auto viewName = ConnectivityGraphUtilities::getDesignViewName(globalComponent, componentDesign_, componentDesignConfig_);\r\n    auto defaultCPUs = ConnectivityGraphUtilities::getDefaultCPUs(utility_->getLibraryInterface(), globalComponent, viewName);\r\n\r\n    saveOptions_ = saveOptions;\r\n    QList<QSharedPointer<GlobalHeaderSaveModel::SaveFileOptions> > options = saveOptions_;\r\n\r\n    bool changed = false;\r\n\r\n    GlobalHeaderSaveModel model(utility_->getLibraryInterface(), parentObject_);\r\n    model.setCPUData(globalComponent, defaultCPUs);\r\n\r\n    if (options.isEmpty())\r\n    {\r\n        // create the dialog to display the headers to be generated\r\n        FileSaveDialog dialog(utility_->getParentWidget());\r\n        dialog.setModel(&model);\r\n\r\n        // if user clicked cancel\r\n\t\tif (dialog.exec() == QDialog::Rejected)\r\n        {\r\n            informGenerationAbort();\r\n            return;\r\n        }\r\n\r\n        options = model.getHeaderOptions();\r\n    }\r\n    else\r\n    {\r\n        setupRoutesForExistingOptions(options, defaultCPUs);\r\n    }\r\n\r\n    informStartOfGeneration();\r\n\r\n\tfor(auto headerOpt : options)\r\n    {\r\n\t\tQFile file(headerOpt->fileInfo_.absoluteFilePath());\r\n\r\n        checkDirectoryStructure(headerOpt->fileInfo_.dir());\r\n\r\n\t\tif (!file.open(QFile::Truncate | QFile::WriteOnly))\r\n        {\r\n            openFileErrorMessage(headerOpt->fileInfo_.absoluteFilePath());\r\n\t\t\tbreak;\r\n\t\t}\r\n\r\n\t\tQTextStream stream(&file);\r\n\r\n        QString description (\" * Header file generated by Kactus2 for instance \\\"\" + headerOpt->instance_ +\r\n            \"\\\" interface \\\"\" + headerOpt->interface_ + \"\\\".\\n\"+\r\n            \" * This file contains addresses of the memories and registers defined in the memory maps \" +\r\n            \"of connected components.\\n\" +\r\n            \" * Source component: \" + headerOpt->comp_.toString() + \".\\n\" +\r\n        \t\"*/\\n\");\r\n\r\n        QString headerGuard (\"__\" + headerOpt->instance_.toUpper() + \"_\" + headerOpt->interface_.toUpper() + \"_H\");\r\n\r\n        writeTopOfHeaderFile(stream, headerOpt->fileInfo_.fileName(), headerGuard, description);\r\n\r\n        parseRoutes(stream, headerOpt->cpuContainer_);\r\n\r\n\t\tstream << \"#endif /* \" << headerGuard << \" */\" << Qt::endl << Qt::endl;\r\n\r\n        file.close();\r\n\r\n        informWritingFinished(headerOpt->fileInfo_.fileName());\r\n\r\n\t\taddHeaderFile(globalComponent, headerOpt->fileInfo_, headerOpt->instance_, QStringList(),\r\n            headerOpt->instanceId_);\r\n\r\n\t\t// a header file was added\r\n\t\tchanged = true;\r\n\r\n\t\t// the list must be cleared when moving to completely new master interface so each header generation\r\n        // starts from scratch.\r\n\t\toperatedInterfaces_.clear();\r\n\t}\r\n\r\n\tif (changed)\r\n    {\r\n\t\t// save the changes to the file sets\r\n\t\tutility_->getLibraryInterface()->writeModelToFile(globalComponent);\r\n\t}\r\n\r\n\t// clear the members for next generation run\r\n    componentDesign_.clear();\r\n\toperatedInterfaces_.clear();\r\n\r\n\r\n    informGenerationComplete();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: GlobalMemoryMapHeaderWriter::setupRoutesForExistingOptions()\r\n//-----------------------------------------------------------------------------\r\nvoid GlobalMemoryMapHeaderWriter::setupRoutesForExistingOptions(\r\n    QList<QSharedPointer<GlobalHeaderSaveModel::SaveFileOptions> > options,\r\n    QVector<QSharedPointer<SingleCpuRoutesContainer> > cpuRoutes)\r\n{\r\n    for (auto singleCPU : cpuRoutes)\r\n    {\r\n        if (auto matchingOption = getSaveOptionForCPU(options, singleCPU); matchingOption)\r\n        {\r\n\t\t\tmatchingOption->cpuContainer_ = singleCPU;\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: GlobalMemoryMapHeaderWriter::getSaveOptionForCPU()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<GlobalHeaderSaveModel::SaveFileOptions> GlobalMemoryMapHeaderWriter::getSaveOptionForCPU(\r\n    QList<QSharedPointer<GlobalHeaderSaveModel::SaveFileOptions> > options,\r\n    QSharedPointer<SingleCpuRoutesContainer> singleCPU)\r\n{\r\n    auto cpuInterface = singleCPU->getRoutes().first()->cpuInterface_;\r\n    auto cpuInstance = cpuInterface->getInstance();\r\n    \r\n    auto interfaceName = cpuInterface->getName();\r\n    auto instanceName = cpuInstance->getName();\r\n    \r\n    VLNV cpuComponentVLNV(VLNV::COMPONENT, cpuInstance->getVlnv());\r\n\r\n    for (auto saveOption : options)\r\n    {\r\n        if (saveOption->instance_ == instanceName &&\r\n            saveOption->interface_ == interfaceName &&\r\n            saveOption->comp_ == cpuComponentVLNV &&\r\n            saveOption->instanceId_ == cpuInstance->getInstanceUuid())\r\n        {\r\n            return saveOption;\r\n        }\r\n    }\r\n\r\n    return QSharedPointer<GlobalHeaderSaveModel::SaveFileOptions>();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: GlobalMemoryMapHeaderWriter::parseRoutes()\r\n//-----------------------------------------------------------------------------\r\nvoid GlobalMemoryMapHeaderWriter::parseRoutes(QTextStream& stream, QSharedPointer<SingleCpuRoutesContainer> container)\r\n{\r\n    if (!container)\r\n    {\r\n        return;\r\n    }\r\n\r\n    for (auto const& startingInterfaceRoutes : container->getRoutes())\r\n    {\r\n        for (auto const& interfaceRoutes : startingInterfaceRoutes->routes_)\r\n        {\r\n            AddressContainer addressContainer;\r\n\r\n            //! A single route starts in here\r\n            for (auto currentInterface : interfaceRoutes)\r\n            {\r\n                auto interfaceMode = currentInterface->getMode();\r\n\t\t\t\tif (interfaceMode == General::MASTER || interfaceMode == General::INITIATOR)\r\n\t\t\t\t{\r\n\t\t\t\t\tparseMasterInterface(addressContainer, currentInterface);\r\n\t\t\t\t}\r\n\t\t\t\telse if (interfaceMode == General::SLAVE || interfaceMode == General::TARGET)\r\n\t\t\t\t{\r\n\t\t\t\t\tparseTargetInterface(addressContainer, stream, currentInterface);\r\n\t\t\t\t}\r\n\t\t\t\telse if (interfaceMode == General::MIRRORED_SLAVE || interfaceMode == General::MIRRORED_TARGET)\r\n\t\t\t\t{\r\n\t\t\t\t\tparseMirroredTargetInterface(addressContainer, currentInterface);\r\n\t\t\t\t}\r\n            }\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: GlobalMemoryMapHeaderWriter::parseMasterInterface()\r\n//-----------------------------------------------------------------------------\r\nvoid GlobalMemoryMapHeaderWriter::parseMasterInterface(AddressContainer& addressContainer, QSharedPointer<const ConnectivityInterface> masterInterface) const\r\n{\r\n    addressContainer.baseAddress_ += masterInterface->getBaseAddress().toULongLong();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: GlobalMemoryMapHeaderWriter::parseTargetInterface()\r\n//-----------------------------------------------------------------------------\r\nvoid GlobalMemoryMapHeaderWriter::parseTargetInterface(AddressContainer addressContainer,\r\n    QTextStream& stream,\r\n    QSharedPointer<const ConnectivityInterface> targetInterface)\r\n{\r\n\tauto memoryItem = targetInterface->getConnectedMemory();\r\n    if (targetInterface->isBridged() || !memoryItem)\r\n    {\r\n        return;\r\n    }\r\n\r\n\tif (memoryItem->getType() == MemoryDesignerConstants::MEMORYMAP_TYPE && memoryItemContainsAddressBlocks(memoryItem))\r\n    {\r\n        auto targetInstance = targetInterface->getInstance();\r\n\r\n        stream << \"/*\" << Qt::endl;\r\n\t\tstream << \" * Instance: \" << targetInstance->getName() << \" Interface: \" << targetInterface->getName() << Qt::endl;\r\n\t\tstream << \" * Instance base address: 0x\" << QString::number(addressContainer.baseAddress_, 16) << Qt::endl;\r\n\t\tstream << \" * Source component: \" << targetInstance->getVlnv() << Qt::endl;\r\n\r\n        // if there is a description for the component instance\r\n        auto instanceDescription = targetInstance->getDescription();\r\n        if (!instanceDescription.isEmpty())\r\n        {\r\n            stream << \" * Description:\" << Qt::endl;\r\n            stream << \" * \" << instanceDescription << Qt::endl;\r\n        }\r\n\r\n\t\tstream << \" * The defines for the memory map \\\"\" << memoryItem->getName() << \"\\\":\" << Qt::endl;\r\n        stream << \"*/\" << Qt::endl << Qt::endl;\r\n\r\n        writeMemoryAddresses(addressContainer, stream, memoryItem, targetInstance->getName());\r\n\r\n        // if the registers within the instance are unique then do not concatenate with address block name\r\n        /*QStringList regNames;\r\n        if (memMap->uniqueRegisterNames(regNames))\r\n        {*/\r\n\r\n        writeRegisterFromMemoryMap(addressContainer, stream, memoryItem, false, targetInstance->getName());\r\n\r\n        /*}\r\n        else\r\n        {\r\n            writeRegisterFromMemoryMap(finder, memMap, stream, true, offset, interface->getComponentReference());\r\n        }*/\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: GlobalMemoryMapHeaderWriter::memoryItemContainsAddressBlocks()\r\n//-----------------------------------------------------------------------------\r\nbool GlobalMemoryMapHeaderWriter::memoryItemContainsAddressBlocks(QSharedPointer<MemoryItem> memoryItem) const\r\n{\r\n    if (memoryItem->getChildItems().isEmpty() == false)\r\n    {\r\n        for (auto childItem : memoryItem->getChildItems())\r\n        {\r\n            if (childItem->getType() != MemoryDesignerConstants::ADDRESSBLOCK_TYPE)\r\n            {\r\n                return false;\r\n            }\r\n        }\r\n\r\n        return true;\r\n    }\r\n\r\n    return false;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: GlobalMemoryMapHeaderWriter::parseMirroredTargetInterface()\r\n//-----------------------------------------------------------------------------\r\nvoid GlobalMemoryMapHeaderWriter::parseMirroredTargetInterface(AddressContainer& addressContainer,\r\n    QSharedPointer<const ConnectivityInterface> mirroredTargetInterface) const\r\n{\r\n    addressContainer.baseAddress_ += mirroredTargetInterface->getRemapAddress().toULongLong();\r\n\r\n    auto newLastAddress = addressContainer.baseAddress_ + mirroredTargetInterface->getRemapRange().toULongLong();\r\n    if (newLastAddress > 0)\r\n    {\r\n        newLastAddress = newLastAddress - 1;\r\n    }\r\n\r\n    if (addressContainer.hasRemapRange_ == false ||\r\n        (addressContainer.hasRemapRange_ && newLastAddress < addressContainer.lastAddress_))\r\n    {\r\n        addressContainer.lastAddress_ = newLastAddress;\r\n    }\r\n\r\n    addressContainer.hasRemapRange_ = true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: GlobalMemoryMapHeaderWriter::displayMemoryMapHeader()\r\n//-----------------------------------------------------------------------------\r\nvoid GlobalMemoryMapHeaderWriter::displayMemoryMapHeader(QString const& filePath) const\r\n{\r\n    if (saveOptions_.isEmpty())\r\n    {\r\n        QDesktopServices::openUrl(QUrl::fromLocalFile(filePath));\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: GlobalMemoryMapHeaderWriter::checkConfigurableElementValues()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<ListParameterFinder> GlobalMemoryMapHeaderWriter::createParameterFinder(QString const& instanceID,\r\n    QSharedPointer<Component> component)\r\n{\r\n    QSharedPointer<QList<QSharedPointer<Parameter> > > configurableElementValues\r\n        (new QList<QSharedPointer<Parameter> > ());\r\n\r\n    QMap<QString, QString> configurableElementsInInstance;\r\n\r\n    if (componentDesign_)\r\n    {\r\n        configurableElementsInInstance = getConfigurableElementsFromInstance(instanceID);\r\n    }\r\n\r\n    foreach (QSharedPointer<Parameter> parameterPointer, *component->getParameters())\r\n    {\r\n        QSharedPointer<Parameter> newConfigurableElement (new Parameter(*(parameterPointer)));\r\n\r\n        if (configurableElementsInInstance.contains(newConfigurableElement->getValueId()))\r\n        {\r\n            newConfigurableElement->setValue(configurableElementsInInstance.value(\r\n                newConfigurableElement->getValueId()));\r\n        }\r\n\r\n        configurableElementValues->append(newConfigurableElement);\r\n    }\r\n\r\n    QSharedPointer<ListParameterFinder> listFinder (new ListParameterFinder());\r\n    listFinder->setParameterList(configurableElementValues);\r\n\r\n    return listFinder;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: GlobalMemoryMapHeaderWriter::getConfigurableElementsFromInstance()\r\n//-----------------------------------------------------------------------------\r\nQMap<QString, QString> GlobalMemoryMapHeaderWriter::getConfigurableElementsFromInstance(QString const& instanceId)\r\n    const\r\n{\r\n    QMap<QString, QString> configurableElements;\r\n\r\n    foreach (QSharedPointer<ComponentInstance> instance, *componentDesign_->getComponentInstances())\r\n    {\r\n        if (instance->getUuid() == instanceId)\r\n        {\r\n            foreach (QSharedPointer<ConfigurableElementValue> configurable,\r\n                *instance->getConfigurableElementValues())\r\n            {\r\n                configurableElements.insert(configurable->getReferenceId(), configurable->getConfigurableValue());\r\n            }\r\n\r\n            break;\r\n        }\r\n    }\r\n\r\n    return configurableElements;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: GlobalMemoryMapHeaderWriter::getInstanceID()\r\n//-----------------------------------------------------------------------------\r\nQString GlobalMemoryMapHeaderWriter::getInstanceID(QString const& interfaceReference) const\r\n{\r\n    foreach (QSharedPointer<ComponentInstance> instance, *componentDesign_->getComponentInstances())\r\n    {\r\n        if (instance->getInstanceName() == interfaceReference)\r\n        {\r\n            return instance->getUuid();\r\n        }\r\n    }\r\n\r\n    // This should not be reached.\r\n    return QString();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: GlobalMemoryMapHeaderWriter::getConnectedInterfaces()\r\n//-----------------------------------------------------------------------------\r\nQList<QSharedPointer<ActiveInterface> > GlobalMemoryMapHeaderWriter::getConnectedInterfaces(\r\n    QSharedPointer<ActiveInterface> interface)\r\n{\r\n    QList<QSharedPointer<ActiveInterface> > connectedInterfaces;\r\n\r\n    foreach (QSharedPointer<Interconnection> connection, *componentDesign_->getInterconnections())\r\n    {\r\n        if (connection->getStartInterface()->getComponentReference() == interface->getComponentReference() &&\r\n            connection->getStartInterface()->getBusReference() == interface->getBusReference())\r\n        {\r\n            connectedInterfaces.append(*connection->getActiveInterfaces());\r\n        }\r\n        else\r\n        {\r\n            foreach (QSharedPointer<ActiveInterface> active, *connection->getActiveInterfaces())\r\n            {\r\n                if (active->getComponentReference() == interface->getComponentReference() &&\r\n                    active->getBusReference() == interface->getBusReference())\r\n                {\r\n                    connectedInterfaces.append(connection->getStartInterface());\r\n                }\r\n            }\r\n        }\r\n    }\r\n\r\n    return connectedInterfaces;\r\n}\r\n"
  },
  {
    "path": "Plugins/MemoryMapHeaderGenerator/GlobalMemoryMapHeaderWriter.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: GlobalMemoryMapHeaderWriter.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 08.05.2015\r\n//\r\n// Description:\r\n// The implementation for creating c-headers of global memory maps.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef GLOBALMEMORYMAPHEADERWRITER_H\r\n#define GLOBALMEMORYMAPHEADERWRITER_H\r\n\r\n#include \"BaseMemoryMapHeaderWriter.h\"\r\n\r\n#include \"globalheadersavemodel.h\"\r\n\r\n#include <IPXACTmodels/common/Parameter.h>\r\n\r\n#include <IPXACTmodels/Component/Component.h>\r\n\r\n#include <IPXACTmodels/Design/Design.h>\r\n\r\n#include <IPXACTmodels/DesignConfiguration/DesignConfiguration.h>\r\n\r\n#include <QObject>\r\n#include <QSharedPointer>\r\n#include <QString>\r\n#include <QFileInfo>\r\n#include <QList>\r\n#include <QTextStream>\r\n\r\nclass IPluginUtility;\r\nclass ListParameterFinder;\r\nclass ConnectivityInterface;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! The implementation for creating c-headers of global memory maps.\r\n//-----------------------------------------------------------------------------\r\nclass GlobalMemoryMapHeaderWriter : public BaseMemoryMapHeaderWriter\r\n{\r\n\r\npublic:\r\n\r\n    /*!\r\n     *  The constructor.\r\n     *\r\n     *    @param [in] utility                 The interface which offers core utilities for plugins.\r\n     *    @param [in] componentDesign         The design currently in use.\r\n     *    @param [in] componentDesignConfig   The design configuration currently in use.\r\n     *    @param [in] parentObject            The parent object of this writer.\r\n     */\r\n    GlobalMemoryMapHeaderWriter(IPluginUtility* utility, QSharedPointer<Design> componentDesign,\r\n        QSharedPointer<DesignConfiguration> componentDesignConfig, QObject* parentObject);\r\n\r\n    /*!\r\n     *  The destructor.\r\n     */\r\n    virtual ~GlobalMemoryMapHeaderWriter();\r\n\r\n    /*!\r\n     *  Write the memory map header into a file.\r\n     *\r\n     *    @param [in] globalComponent     The top component of the design.\r\n     *    @param [in] saveOptions         The save options for the memory map header.\r\n     */\r\n    virtual void writeMemoryMapHeader(QSharedPointer<Component> globalComponent,\r\n        QList<QSharedPointer<GlobalHeaderSaveModel::SaveFileOptions> > saveOptions);\r\n\r\nprotected:\r\n    \r\n    /*!\r\n     *  Display the created memory map header.\r\n     *\r\n     *    @param [in] filePath    The file path.\r\n     */\r\n    virtual void displayMemoryMapHeader(QString const& filePath) const;\r\n\r\nprivate:\r\n\r\n\t//! No copying\r\n\t//! No assignment\r\n    GlobalMemoryMapHeaderWriter(const GlobalMemoryMapHeaderWriter& other);\r\n    GlobalMemoryMapHeaderWriter& operator=(const GlobalMemoryMapHeaderWriter& other);\r\n\r\n    /*!\r\n     *  Setup the CPU route containers for existing save file options.\r\n     *\r\n     *    @param [in] options       The existing save file options.\r\n     *    @param [in] cpuRoutes     The located CPU route containers.\r\n     */\r\n    void setupRoutesForExistingOptions(\r\n        QList<QSharedPointer<GlobalHeaderSaveModel::SaveFileOptions> > options,\r\n        QVector<QSharedPointer<SingleCpuRoutesContainer> > cpuRoutes);\r\n\r\n    /*!\r\n     *  Get the matching save file option for the selected CPU container.\r\n     *\r\n     *    @param [in] options       List of available save file options.\r\n     *    @param [in] singleCPU     The selected CPU container.\r\n     *\r\n     *    @return The matching save file option.\r\n     */\r\n    QSharedPointer<GlobalHeaderSaveModel::SaveFileOptions> getSaveOptionForCPU(\r\n        QList<QSharedPointer<GlobalHeaderSaveModel::SaveFileOptions> > options,\r\n        QSharedPointer<SingleCpuRoutesContainer> singleCPU);\r\n\r\n    /*!\r\n     *  Parse the CPU route.\r\n     *\r\n     *    @param [in] stream        Text stream to write into.\r\n     *    @param [in] container     Container for address calculations.\r\n     */\r\n    void parseRoutes(QTextStream& stream, QSharedPointer<SingleCpuRoutesContainer> container);\r\n\r\n    /*!\r\n     *  Parse the master interface.\r\n     *\r\n     *    @param [in] addressContainer  Container for address calculations.\r\n     *    @param [in] masterInterface   The selected master interface.\r\n     */\r\n\tvoid parseMasterInterface(AddressContainer& addressContainer, QSharedPointer<const ConnectivityInterface> masterInterface) const;\r\n\r\n    /*!\r\n     *  Parse the slave interface.\r\n     *\r\n     *    @param [in] addressContainer  Container for address calculations.\r\n     *    @param [in] stream            The text stream to write into.\r\n     *    @param [in] targetInterFace   The selected target interface.\r\n     */\r\n\tvoid parseTargetInterface(AddressContainer addressContainer, QTextStream& stream,\r\n\t\tQSharedPointer<const ConnectivityInterface> targetInterface);\r\n\r\n    /*!\r\n     *  Check if the selected memory item contains address blocks.\r\n     *\r\n     *    @param [in] memoryItem    The selected memory item.\r\n     *\r\n     *    @return True, if the memory item contains address blocks, false otherwise.\r\n     */\r\n    bool memoryItemContainsAddressBlocks(QSharedPointer<MemoryItem> memoryItem) const;\r\n\r\n    /*!\r\n     *  Parse the mirrored slave interface.\r\n     *\r\n     *    @param [in] addressContainer          Container for address calculations.\r\n     *    @param [in] mirroredTargetInterFace   The selected mirrored target interface.\r\n     */\r\n\tvoid parseMirroredTargetInterface(AddressContainer& addressContainer,\r\n\t\tQSharedPointer<const ConnectivityInterface> mirroredTargetInterface) const;\r\n\r\n    /*!\r\n     *  Creates the parameter finder using configurable element values of the instance.\r\n     *\r\n     *    @param [in] instanceID  The uuid of the instance of the configurable element values.\r\n     *    @param [in] component   The component of the instance.\r\n     *\r\n     *    @return A list parameter finder containing the configurable element values of the instance.\r\n     */\r\n    QSharedPointer<ListParameterFinder> createParameterFinder(QString const& instanceID,\r\n        QSharedPointer<Component> component);\r\n\r\n    /*!\r\n     *  Gets the uuid of an instance.\r\n     *\r\n     *    @param [in] interfaceReference  The name of the component instance.\r\n     *\r\n     *    @return Uuid of the instance.\r\n     */\r\n    QString getInstanceID(QString const& interfaceReference) const;\r\n\r\n    /*!\r\n     *  Get configurable elements from the selected instance.\r\n     *\r\n     *    @param [in] instanceId  The id of the selected instance.\r\n     *\r\n     *    @return Map containing the configurable elements from the selected instance as ID / value pairs.\r\n     */\r\n    QMap<QString, QString> getConfigurableElementsFromInstance(QString const& instanceId) const;\r\n\r\n    /*!\r\n     *  Get the connected interfaces.\r\n     *\r\n     *    @param [in] interface   The start point interface of the connection.\r\n     *\r\n     *    @return A list of interfaces connected to the selected interface.\r\n     */\r\n    QList<QSharedPointer<ActiveInterface> > getConnectedInterfaces(QSharedPointer<ActiveInterface> interface);\r\n    \r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! The parent object of this writer.\r\n    QObject* parentObject_;\r\n\r\n    //! The hw design of the component.\r\n    QSharedPointer<Design> componentDesign_;\r\n\r\n    //! The hw design configuration of the component.\r\n    QSharedPointer<DesignConfiguration> componentDesignConfig_;\r\n\r\n    //! A list of interfaces that have been checked.\r\n    QList<QSharedPointer<ActiveInterface> > operatedInterfaces_;\r\n\r\n    //! A list of save options for the writer.\r\n    QList<QSharedPointer<GlobalHeaderSaveModel::SaveFileOptions> > saveOptions_;\r\n};\r\n\r\n#endif // GLOBALMEMORYMAPHEADERWRITER_H\r\n"
  },
  {
    "path": "Plugins/MemoryMapHeaderGenerator/LocalMemoryMapHeaderWriter.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: LocalMemoryMapHeaderWriter.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 07.05.2015\r\n//\r\n// Description:\r\n// The implementation for creating c-headers of local memory maps.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"LocalMemoryMapHeaderWriter.h\"\r\n\r\n#include \"localheadersavedelegate.h\"\r\n\r\n#include <KactusAPI/include/LibraryInterface.h>\r\n\r\n#include <KactusAPI/include/IPluginUtility.h>\r\n#include <Plugins/MemoryMapHeaderGenerator/fileSaveDialog/filesavedialog.h>\r\n\r\n#include <KactusAPI/include/ComponentParameterFinder.h>\r\n\r\n#include <IPXACTmodels/Component/MemoryMap.h>\r\n\r\n#include <QDate>\r\n#include <QDir>\r\n#include <QDesktopServices>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LocalMemoryMapHeaderWriter::LocalMemoryMapHeaderWriter()\r\n//-----------------------------------------------------------------------------\r\nLocalMemoryMapHeaderWriter::LocalMemoryMapHeaderWriter(IPluginUtility* utility,\r\n    QSharedPointer<Component> localComponent, QObject* parentObject):\r\nBaseMemoryMapHeaderWriter(utility),\r\ncomponent_(localComponent),\r\nparentObject_(parentObject),\r\nsaveOptions_()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LocalMemoryMapHeaderWriter::~LocalMemoryMapHeaderWriter()\r\n//-----------------------------------------------------------------------------\r\nLocalMemoryMapHeaderWriter::~LocalMemoryMapHeaderWriter()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LocalMemoryMapHeaderWriter::writeMemoryMapHeader()\r\n//-----------------------------------------------------------------------------\r\nvoid LocalMemoryMapHeaderWriter::writeMemoryMapHeader(QList<LocalHeaderSaveModel::SaveFileOptions*> saveOptions)\r\n{\r\n    saveOptions_ = saveOptions;\r\n    QList<LocalHeaderSaveModel::SaveFileOptions*> options = saveOptions_;\r\n    bool changed = false;\r\n\r\n    LocalHeaderSaveModel model(utility_->getLibraryInterface(), parentObject_);\r\n    model.setComponent(component_);\r\n\r\n    if (options.isEmpty())\r\n    {\r\n        FileSaveDialog dialog(utility_->getParentWidget());\r\n        dialog.setModel(&model);\r\n        dialog.setItemDelegate(new LocalHeaderSaveDelegate(component_, parentObject_));\r\n\r\n        int result = dialog.exec();\r\n\r\n        // if user clicked cancel\r\n        if (result == QDialog::Rejected)\r\n        {\r\n            informGenerationAbort();\r\n            return;\r\n        }\r\n\r\n        options = model.getHeaderOptions();\r\n    }\r\n\r\n    informStartOfGeneration();\r\n\r\n\tforeach (LocalHeaderSaveModel::SaveFileOptions* headerOpt, options)\r\n    {\r\n\t\tQFile file(headerOpt->fileInfo_.absoluteFilePath());\r\n\r\n        checkDirectoryStructure(headerOpt->fileInfo_.dir());\r\n\r\n\t\tif (!file.open(QFile::Truncate | QFile::WriteOnly))\r\n        {\r\n            openFileErrorMessage(headerOpt->fileInfo_.absoluteFilePath());\r\n\t\t\tbreak;\r\n\t\t}\r\n\r\n        QTextStream stream(&file);\r\n\r\n        QString description (\" * Header file generated by Kactus2 from local memory map \\\"\" +\r\n            headerOpt->localMemMap_->name() + \"\\\".\\n\" +\r\n            \" * This file contains addresses of the memories and registers defined in the local memory map.\\n\" +\r\n            \" * Source component: \" + component_->getVlnv().toString() + \".\\n\" +\r\n            \"*/\\n\");\r\n\r\n        QString headerGuard (\"__\" + component_->getVlnv().toString(\"_\") + \"_\" + headerOpt->localMemMap_->name()\r\n            + \"_H\");\r\n        headerGuard = headerGuard.toUpper();\r\n\r\n        writeTopOfHeaderFile(stream, headerOpt->fileInfo_.fileName(), headerGuard, description);\r\n\r\n        QSharedPointer<ComponentParameterFinder> finder (new ComponentParameterFinder(component_));\r\n\r\n        writeMemoryAddresses(finder, headerOpt->localMemMap_, stream, 0);\r\n\r\n\t\t// if the register names are unique then there is no need to add address block name\r\n\t\t/*QStringList regNames;\r\n\t\tif (headerOpt->localMemMap_->uniqueRegisterNames(regNames))\r\n        {*/\r\n        \r\n        writeRegisterFromMemoryMap(finder, headerOpt->localMemMap_, stream, false, 0);\r\n\t\t\r\n        /*}\r\n\t\telse\r\n        {\r\n            writeRegisterFromMemoryMap(finder, headerOpt->localMemMap_, stream, true, 0);\r\n\t\t}*/\r\n\r\n\t\tstream << \"#endif /* \" << headerGuard << \" */\" << Qt::endl << Qt::endl;\r\n\r\n        informWritingFinished(headerOpt->fileInfo_.fileName());\r\n\r\n\t\tfile.close();\r\n\r\n\t\tQStringList swViewRefs;\r\n\r\n\t\t// where user selected to add a reference to the generated file set\r\n\t\tQString swViewRef = headerOpt->swView_;\r\n\t\tQ_ASSERT(!swViewRef.isEmpty());\r\n\r\n\t\t// if user selected to add the reference to all SW views.\r\n\t\tif (swViewRef == QObject::tr(\"all\"))\r\n        {\r\n\t\t\tswViewRefs = component_->getViewNames();\r\n\t\t}\r\n\t\t// if user selected only a single view\r\n\t\telse\r\n        {\r\n\t\t\tswViewRefs.append(swViewRef);\r\n\t\t}\r\n\r\n\t\t// add the file to the component's file sets\r\n\t\taddHeaderFile(component_, headerOpt->fileInfo_,\r\n            QString(\"%1_header\").arg(headerOpt->localMemMap_->name()), swViewRefs);\r\n\r\n\t\t// a header file was added\r\n\t\tchanged = true;\r\n\t}\r\n\r\n\tif (changed)\r\n    {\r\n\t\t// save the changes to the file sets\r\n\t\tutility_->getLibraryInterface()->writeModelToFile(component_);\r\n\t}\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LocalMemoryMapHeaderWriter::displayMemoryMapHeader()\r\n//-----------------------------------------------------------------------------\r\nvoid LocalMemoryMapHeaderWriter::displayMemoryMapHeader(QString const& filePath) const\r\n{\r\n    if (saveOptions_.isEmpty())\r\n    {\r\n        QDesktopServices::openUrl(QUrl::fromLocalFile(filePath));\r\n    }\r\n\r\n    informGenerationComplete();\r\n}"
  },
  {
    "path": "Plugins/MemoryMapHeaderGenerator/LocalMemoryMapHeaderWriter.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: LocalMemoryMapHeaderWriter.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 07.05.2015\r\n//\r\n// Description:\r\n// The implementation for creating c-headers of local memory maps.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef LOCALMEMORYMAPHEADERWRITER_H\r\n#define LOCALMEMORYMAPHEADERWRITER_H\r\n\r\n#include \"BaseMemoryMapHeaderWriter.h\"\r\n\r\n#include \"localheadersavemodel.h\"\r\n\r\n#include <QObject>\r\n#include <QSharedPointer>\r\n#include <QString>\r\n#include <QFileInfo>\r\n#include <QList>\r\n#include <QTextStream>\r\n\r\nclass IPluginUtility;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! The implementation for creating c-headers of local memory maps.\r\n//-----------------------------------------------------------------------------\r\nclass LocalMemoryMapHeaderWriter : public BaseMemoryMapHeaderWriter\r\n{\r\n\r\npublic:\r\n\r\n    /*!\r\n     *  The constructor.\r\n     *\r\n     *    @param [in] utility         The interface which offers core utilities for plugins.\r\n     *    @param [in] localComponent  The selected component.\r\n     *    @param [in] parentObject    The parent object of this writer.\r\n     */\r\n    LocalMemoryMapHeaderWriter(IPluginUtility* utility, QSharedPointer<Component> localComponent,\r\n        QObject* parentObject);\r\n\r\n    /*!\r\n     *  The destructor.\r\n     */\r\n    virtual ~LocalMemoryMapHeaderWriter();\r\n\r\n    /*!\r\n     *  Write the memory map header file.\r\n     *\r\n     *    @param [in] saveOptions     The save options for the memory map header.\r\n     */\r\n    virtual void writeMemoryMapHeader(QList<LocalHeaderSaveModel::SaveFileOptions*> saveOptions);\r\n\r\nprotected:\r\n\r\n    /*!\r\n     *  Display the created memory map header.\r\n     *\r\n     *    @param [in] filePath    The file path to the memory map header.\r\n     */\r\n    virtual void displayMemoryMapHeader(QString const& filePath) const;\r\n\r\nprivate:\r\n\r\n\t//! No copying\r\n    LocalMemoryMapHeaderWriter(const LocalMemoryMapHeaderWriter& other);\r\n\r\n\t//! No assignment\r\n    LocalMemoryMapHeaderWriter& operator=(const LocalMemoryMapHeaderWriter& other);\r\n\r\n    //! The selected component.\r\n    QSharedPointer<Component> component_;\r\n\r\n    //! The parent object of this writer.\r\n    QObject* parentObject_;\r\n\r\n    //! The save options for the memory map header.\r\n    QList<LocalHeaderSaveModel::SaveFileOptions*> saveOptions_;\r\n};\r\n\r\n#endif // LOCALMEMORYMAPHEADERWRITER_H\r\n"
  },
  {
    "path": "Plugins/MemoryMapHeaderGenerator/MemoryMapHeaderGenerator.pri",
    "content": "# ----------------------------------------------------\r\n# This file is generated by the Qt Visual Studio Tools.\r\n# ------------------------------------------------------\r\n\r\n# This is a reminder that you are using a generated .pro file.\r\n# Remove it when you are finished editing this file.\r\nmessage(\"You are running qmake on a generated .pro file. This may not work!\")\r\n\r\n\r\nHEADERS += ./BaseMemoryMapHeaderWriter.h \\\r\n    ./GlobalMemoryMapHeaderWriter.h \\\r\n    ./LocalMemoryMapHeaderWriter.h \\\r\n    ./SystemMemoryMapHeaderWriter.h \\\r\n    ./memorymapheadergenerator_global.h \\\r\n    ../../common/widgets/viewSelector/viewselector.h \\\r\n    ./systemheadersavemodel.h \\\r\n    ./memorymapheadergenerator.h \\\r\n    ./globalheadersavemodel.h \\\r\n    ./localheadersavedelegate.h \\\r\n    ./localheadersavemodel.h \\\r\n    ./fileSaveDialog/filesavedialog.h \\\r\n    ./fileSaveDialog/filesavedialogview.h \\\r\n    ../common/ConnectivityGraphUtilities.h \\\r\n    ../../editors/MemoryDesigner/ConnectivityInterface.h \\\r\n    ../../editors/MemoryDesigner/ConnectivityComponent.h \\\r\n    ../common/CpuRoutesContainer.h \\\r\n    ../common/SingleCpuRoutesContainer.h \\\r\n    ../../editors/MemoryDesigner/ConnectivityGraphFactory.h \\\r\n    ../../editors/MemoryDesigner/ConnectivityConnection.h \\\r\n    ../../editors/MemoryDesigner/MemoryItem.h \\\r\n    ../../editors/MemoryDesigner/ConnectivityGraph.h \\\r\n    ../../editors/MemoryDesigner/MasterSlavePathSearch.h\r\nSOURCES += ../../common/widgets/viewSelector/viewselector.cpp \\\r\n    ./BaseMemoryMapHeaderWriter.cpp \\\r\n    ./globalheadersavemodel.cpp \\\r\n    ./GlobalMemoryMapHeaderWriter.cpp \\\r\n    ./localheadersavedelegate.cpp \\\r\n    ./localheadersavemodel.cpp \\\r\n    ./LocalMemoryMapHeaderWriter.cpp \\\r\n    ./memorymapheadergenerator.cpp \\\r\n    ./systemheadersavemodel.cpp \\\r\n    ./SystemMemoryMapHeaderWriter.cpp \\\r\n    ./fileSaveDialog/filesavedialog.cpp \\\r\n    ./fileSaveDialog/filesavedialogview.cpp \\\r\n    ../common/ConnectivityGraphUtilities.cpp \\\r\n    ../../editors/MemoryDesigner/ConnectivityInterface.cpp \\\r\n    ../../editors/MemoryDesigner/ConnectivityComponent.cpp \\\r\n    ../common/CpuRoutesContainer.cpp \\\r\n    ../common/SingleCpuRoutesContainer.cpp \\\r\n    ../../editors/MemoryDesigner/ConnectivityGraphFactory.cpp \\\r\n    ../../editors/MemoryDesigner/ConnectivityConnection.cpp \\\r\n    ../../editors/MemoryDesigner/MemoryItem.cpp \\\r\n    ../../editors/MemoryDesigner/ConnectivityGraph.cpp \\\r\n    ../../editors/MemoryDesigner/MasterSlavePathSearch.cpp\r\nRESOURCES += memorymapheadergenerator.qrc\r\n"
  },
  {
    "path": "Plugins/MemoryMapHeaderGenerator/MemoryMapHeaderGenerator.pro",
    "content": "# ----------------------------------------------------\r\n# This file is generated by the Qt Visual Studio Add-in.\r\n# ------------------------------------------------------\r\n\r\nTEMPLATE = lib\r\n\r\nQT += core xml widgets gui printsupport\r\nCONFIG += c++11 plugin\r\n\r\nDEFINES += MEMORYMAPHEADERGENERATOR_LIB\r\n\r\nINCLUDEPATH += ./GeneratedFiles \\\r\n    . \\\r\n    ./../.. \\\r\n\r\nCONFIG(debug, debug|release) {\r\n    # debug mode\r\n    LIBS += \\\r\n        -L../../executable -lIPXACTmodelsd \\\r\n        -L../../executable -lKactusAPId\r\n\r\n    MOC_DIR += ./GeneratedFiles/Debug\r\n    OBJECTS_DIR += Debug\r\n    TARGET = MemoryMapHeaderGeneratord\r\n\r\n} else {\r\n    # release mode \r\n    LIBS += \\\r\n        -L../../executable -lIPXACTmodels \\\r\n        -L../../executable -lKactusAPI\r\n    \r\n    MOC_DIR += ./GeneratedFiles/Release\r\n    OBJECTS_DIR += Release\r\n    TARGET = MemoryMapHeaderGenerator\r\n}\r\n\r\nDESTDIR = ../../executable/Plugins\r\n\r\nDEPENDPATH += .\r\nUI_DIR += ./GeneratedFiles\r\nRCC_DIR += ./GeneratedFiles\r\n\r\ninclude(MemoryMapHeaderGenerator.pri)\r\n\r\ntarget.path = $$plugin_path\r\nINSTALLS += target\r\n"
  },
  {
    "path": "Plugins/MemoryMapHeaderGenerator/MemoryMapHeaderGenerator.vcxproj",
    "content": "﻿<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n<Project DefaultTargets=\"Build\" ToolsVersion=\"15.0\" xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">\r\n  <ItemGroup Label=\"ProjectConfigurations\">\r\n    <ProjectConfiguration Include=\"Debug|x64\">\r\n      <Configuration>Debug</Configuration>\r\n      <Platform>x64</Platform>\r\n    </ProjectConfiguration>\r\n    <ProjectConfiguration Include=\"Release|x64\">\r\n      <Configuration>Release</Configuration>\r\n      <Platform>x64</Platform>\r\n    </ProjectConfiguration>\r\n  </ItemGroup>\r\n  <PropertyGroup Label=\"Globals\">\r\n    <ProjectGuid>{C846486D-4A9D-4212-89A8-D25BEFED7FC5}</ProjectGuid>\r\n    <Keyword>QtVS_v304</Keyword>\r\n    <WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>\r\n    <QtMsBuild Condition=\"'$(QtMsBuild)'=='' or !Exists('$(QtMsBuild)\\qt.targets')\">$(MSBuildProjectDirectory)\\QtMsBuild</QtMsBuild>\r\n  </PropertyGroup>\r\n  <Import Project=\"$(VCTargetsPath)\\Microsoft.Cpp.Default.props\" />\r\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\" Label=\"Configuration\">\r\n    <ConfigurationType>DynamicLibrary</ConfigurationType>\r\n    <PlatformToolset>v143</PlatformToolset>\r\n  </PropertyGroup>\r\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\" Label=\"Configuration\">\r\n    <ConfigurationType>DynamicLibrary</ConfigurationType>\r\n    <PlatformToolset>v143</PlatformToolset>\r\n  </PropertyGroup>\r\n  <Import Project=\"$(VCTargetsPath)\\Microsoft.Cpp.props\" />\r\n  <Target Name=\"QtMsBuildNotFound\" BeforeTargets=\"CustomBuild;ClCompile\" Condition=\"!Exists('$(QtMsBuild)\\qt.targets') or !Exists('$(QtMsBuild)\\qt.props')\">\r\n    <Message Importance=\"High\" Text=\"QtMsBuild: could not locate qt.targets, qt.props; project may not build correctly.\" />\r\n  </Target>\r\n  <ImportGroup Label=\"ExtensionSettings\">\r\n  </ImportGroup>\r\n  <ImportGroup Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\" Label=\"PropertySheets\">\r\n    <Import Project=\"$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props\" Condition=\"exists('$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props')\" Label=\"LocalAppDataPlatform\" />\r\n  </ImportGroup>\r\n  <ImportGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\" Label=\"PropertySheets\">\r\n    <Import Project=\"$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props\" Condition=\"exists('$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props')\" Label=\"LocalAppDataPlatform\" />\r\n  </ImportGroup>\r\n  <PropertyGroup Label=\"UserMacros\" />\r\n  <ImportGroup Condition=\"Exists('$(QtMsBuild)\\qt_defaults.props')\">\r\n    <Import Project=\"$(QtMsBuild)\\qt_defaults.props\" />\r\n  </ImportGroup>\r\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n    <OutDir>$(SolutionDir)executable\\Plugins\\</OutDir>\r\n    <IntDir>$(ProjectDir)\\$(Configuration)\\</IntDir>\r\n  </PropertyGroup>\r\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n    <OutDir>$(SolutionDir)executable\\Plugins\\</OutDir>\r\n    <IntDir>$(ProjectDir)\\$(Configuration)\\</IntDir>\r\n  </PropertyGroup>\r\n  <PropertyGroup Label=\"QtSettings\" Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n    <QtInstall>6.2.4</QtInstall>\r\n    <QtModules>core;gui;widgets;help;printsupport;xml</QtModules>\r\n  </PropertyGroup>\r\n  <PropertyGroup Label=\"QtSettings\" Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n    <QtInstall>6.2.4</QtInstall>\r\n    <QtModules>core;gui;widgets;help;printsupport;xml</QtModules>\r\n  </PropertyGroup>\r\n  <ImportGroup Condition=\"Exists('$(QtMsBuild)\\qt.props')\">\r\n    <Import Project=\"$(QtMsBuild)\\qt.props\" />\r\n  </ImportGroup>\r\n  <PropertyGroup>\r\n    <_ProjectFileVersion>10.0.40219.1</_ProjectFileVersion>\r\n  </PropertyGroup>\r\n  <ItemDefinitionGroup Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n    <ClCompile>\r\n      <PreprocessorDefinitions>MEMORYMAPHEADERGENERATOR_LIB;QT_XMLPATTERNS_LIB;UNICODE;WIN32;%(PreprocessorDefinitions)</PreprocessorDefinitions>\r\n      <AdditionalIncludeDirectories>.\\GeneratedFiles\\$(ConfigurationName);.\\GeneratedFiles;.\\GeneratedFiles\\$(Configuration);.;.\\..\\..;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\r\n      <Optimization>Disabled</Optimization>\r\n      <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>\r\n      <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>\r\n      <TreatWChar_tAsBuiltInType>true</TreatWChar_tAsBuiltInType>\r\n      <LanguageStandard>stdcpp17</LanguageStandard>\r\n      <AdditionalOptions>/Zc:__cplusplus %(AdditionalOptions)</AdditionalOptions>\r\n      <MultiProcessorCompilation>true</MultiProcessorCompilation>\r\n    </ClCompile>\r\n    <Link>\r\n      <SubSystem>Windows</SubSystem>\r\n      <OutputFile>$(OutDir)$(ProjectName).dll</OutputFile>\r\n      <AdditionalLibraryDirectories>..\\..\\executable;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>\r\n      <GenerateDebugInformation>true</GenerateDebugInformation>\r\n      <AdditionalDependencies>IPXACTmodelsd.lib;KactusAPId.lib;%(AdditionalDependencies)</AdditionalDependencies>\r\n      <TargetMachine>MachineX64</TargetMachine>\r\n      <AdditionalOptions> /SUBSYSTEM:WINDOWS</AdditionalOptions>\r\n    </Link>\r\n    <QtMoc>\r\n      <ExecutionDescription>Moc'ing %(Identity)...</ExecutionDescription>\r\n      <DynamicSource>output</DynamicSource>\r\n      <QtMocDir>.\\GeneratedFiles\\$(ConfigurationName)</QtMocDir>\r\n      <QtMocFileName>moc_%(Filename).cpp</QtMocFileName>\r\n    </QtMoc>\r\n    <QtRcc>\r\n      <InitFuncName>%(Filename)</InitFuncName>\r\n      <Compression>default</Compression>\r\n      <NoCompression>true</NoCompression>\r\n      <ExecutionDescription>Rcc'ing %(Identity)...</ExecutionDescription>\r\n      <QtRccDir>.\\GeneratedFiles</QtRccDir>\r\n      <QtRccFileName>qrc_%(Filename).cpp</QtRccFileName>\r\n    </QtRcc>\r\n  </ItemDefinitionGroup>\r\n  <ItemDefinitionGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n    <ClCompile>\r\n      <PreprocessorDefinitions>MEMORYMAPHEADERGENERATOR_LIB;NDEBUG;QT_NO_DEBUG;QT_XMLPATTERNS_LIB;UNICODE;WIN32;%(PreprocessorDefinitions)</PreprocessorDefinitions>\r\n      <AdditionalIncludeDirectories>.\\GeneratedFiles\\$(ConfigurationName);.\\GeneratedFiles;.\\GeneratedFiles\\$(Configuration);.;.\\..\\..;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\r\n      <DebugInformationFormat>\r\n      </DebugInformationFormat>\r\n      <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>\r\n      <TreatWChar_tAsBuiltInType>true</TreatWChar_tAsBuiltInType>\r\n      <MultiProcessorCompilation>true</MultiProcessorCompilation>\r\n      <AdditionalOptions>/Zc:__cplusplus %(AdditionalOptions)</AdditionalOptions>\r\n      <LanguageStandard>stdcpp17</LanguageStandard>\r\n    </ClCompile>\r\n    <Link>\r\n      <SubSystem>Windows</SubSystem>\r\n      <OutputFile>$(OutDir)$(ProjectName).dll</OutputFile>\r\n      <AdditionalLibraryDirectories>..\\..\\executable;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>\r\n      <GenerateDebugInformation>false</GenerateDebugInformation>\r\n      <AdditionalDependencies>IPXACTmodels.lib;KactusAPI.lib;%(AdditionalDependencies)</AdditionalDependencies>\r\n      <TargetMachine>MachineX64</TargetMachine>\r\n      <AdditionalOptions> /SUBSYSTEM:WINDOWS</AdditionalOptions>\r\n    </Link>\r\n    <QtMoc>\r\n      <ExecutionDescription>Moc'ing %(Identity)...</ExecutionDescription>\r\n      <DynamicSource>output</DynamicSource>\r\n      <QtMocDir>.\\GeneratedFiles\\$(ConfigurationName)</QtMocDir>\r\n      <QtMocFileName>moc_%(Filename).cpp</QtMocFileName>\r\n    </QtMoc>\r\n    <QtRcc>\r\n      <InitFuncName>%(Filename)</InitFuncName>\r\n      <Compression>default</Compression>\r\n      <NoCompression>true</NoCompression>\r\n      <ExecutionDescription>Rcc'ing %(Identity)...</ExecutionDescription>\r\n      <QtRccDir>.\\GeneratedFiles</QtRccDir>\r\n      <QtRccFileName>qrc_%(Filename).cpp</QtRccFileName>\r\n    </QtRcc>\r\n  </ItemDefinitionGroup>\r\n  <ItemGroup>\r\n    <ClCompile Include=\"..\\..\\common\\widgets\\viewSelector\\viewselector.cpp\" />\r\n    <ClCompile Include=\"..\\..\\editors\\MemoryDesigner\\ConnectivityComponent.cpp\" />\r\n    <ClCompile Include=\"..\\..\\editors\\MemoryDesigner\\ConnectivityConnection.cpp\" />\r\n    <ClCompile Include=\"..\\..\\editors\\MemoryDesigner\\ConnectivityGraph.cpp\" />\r\n    <ClCompile Include=\"..\\..\\editors\\MemoryDesigner\\ConnectivityGraphFactory.cpp\" />\r\n    <ClCompile Include=\"..\\..\\editors\\MemoryDesigner\\ConnectivityInterface.cpp\" />\r\n    <ClCompile Include=\"..\\..\\editors\\MemoryDesigner\\MasterSlavePathSearch.cpp\" />\r\n    <ClCompile Include=\"..\\..\\editors\\MemoryDesigner\\MemoryItem.cpp\" />\r\n    <ClCompile Include=\"..\\common\\ConnectivityGraphUtilities.cpp\" />\r\n    <ClCompile Include=\"..\\common\\CpuRoutesContainer.cpp\" />\r\n    <ClCompile Include=\"..\\common\\SingleCpuRoutesContainer.cpp\" />\r\n    <ClCompile Include=\"BaseMemoryMapHeaderWriter.cpp\" />\r\n    <ClCompile Include=\"fileSaveDialog\\filesavedialog.cpp\" />\r\n    <ClCompile Include=\"fileSaveDialog\\filesavedialogview.cpp\" />\r\n    <ClCompile Include=\"globalheadersavemodel.cpp\" />\r\n    <ClCompile Include=\"GlobalMemoryMapHeaderWriter.cpp\" />\r\n    <ClCompile Include=\"localheadersavedelegate.cpp\" />\r\n    <ClCompile Include=\"localheadersavemodel.cpp\" />\r\n    <ClCompile Include=\"LocalMemoryMapHeaderWriter.cpp\" />\r\n    <ClCompile Include=\"memorymapheadergenerator.cpp\" />\r\n    <ClCompile Include=\"systemheadersavemodel.cpp\" />\r\n    <ClCompile Include=\"SystemMemoryMapHeaderWriter.cpp\" />\r\n  </ItemGroup>\r\n  <ItemGroup>\r\n    <QtMoc Include=\"..\\..\\common\\widgets\\viewSelector\\viewselector.h\">\r\n    </QtMoc>\r\n    <ClInclude Include=\"..\\..\\editors\\MemoryDesigner\\ConnectivityComponent.h\" />\r\n    <ClInclude Include=\"..\\..\\editors\\MemoryDesigner\\ConnectivityConnection.h\" />\r\n    <ClInclude Include=\"..\\..\\editors\\MemoryDesigner\\ConnectivityGraph.h\" />\r\n    <ClInclude Include=\"..\\..\\editors\\MemoryDesigner\\ConnectivityGraphFactory.h\" />\r\n    <ClInclude Include=\"..\\..\\editors\\MemoryDesigner\\ConnectivityInterface.h\" />\r\n    <ClInclude Include=\"..\\..\\editors\\MemoryDesigner\\MasterSlavePathSearch.h\" />\r\n    <ClInclude Include=\"..\\..\\editors\\MemoryDesigner\\MemoryItem.h\" />\r\n    <ClInclude Include=\"..\\common\\ConnectivityGraphUtilities.h\" />\r\n    <ClInclude Include=\"..\\common\\CpuRoutesContainer.h\" />\r\n    <ClInclude Include=\"..\\common\\SingleCpuRoutesContainer.h\" />\r\n    <ClInclude Include=\"BaseMemoryMapHeaderWriter.h\" />\r\n    <ClInclude Include=\"GlobalMemoryMapHeaderWriter.h\" />\r\n    <ClInclude Include=\"LocalMemoryMapHeaderWriter.h\" />\r\n    <ClInclude Include=\"SystemMemoryMapHeaderWriter.h\" />\r\n    <QtMoc Include=\"systemheadersavemodel.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"memorymapheadergenerator.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"globalheadersavemodel.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"localheadersavedelegate.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"localheadersavemodel.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"fileSaveDialog\\filesavedialog.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"fileSaveDialog\\filesavedialogview.h\">\r\n    </QtMoc>\r\n    <ClInclude Include=\"memorymapheadergenerator_global.h\" />\r\n  </ItemGroup>\r\n  <ItemGroup>\r\n    <None Include=\"headerGenerator.json\" />\r\n    <QtRcc Include=\"memorymapheadergenerator.qrc\">\r\n    </QtRcc>\r\n  </ItemGroup>\r\n  <Import Project=\"$(VCTargetsPath)\\Microsoft.Cpp.targets\" />\r\n  <ImportGroup Condition=\"Exists('$(QtMsBuild)\\qt.targets')\">\r\n    <Import Project=\"$(QtMsBuild)\\qt.targets\" />\r\n  </ImportGroup>\r\n  <ImportGroup Label=\"ExtensionTargets\">\r\n  </ImportGroup>\r\n  <ProjectExtensions>\r\n    <VisualStudio>\r\n      <UserProperties />\r\n    </VisualStudio>\r\n  </ProjectExtensions>\r\n</Project>"
  },
  {
    "path": "Plugins/MemoryMapHeaderGenerator/MemoryMapHeaderGenerator.vcxproj.filters",
    "content": "﻿<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n<Project ToolsVersion=\"4.0\" xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">\r\n  <ItemGroup>\r\n    <Filter Include=\"Source Files\">\r\n      <UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>\r\n      <Extensions>cpp;cxx;c;def</Extensions>\r\n    </Filter>\r\n    <Filter Include=\"Header Files\">\r\n      <UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>\r\n      <Extensions>h</Extensions>\r\n    </Filter>\r\n    <Filter Include=\"Resource Files\">\r\n      <UniqueIdentifier>{D9D6E242-F8AF-46E4-B9FD-80ECBC20BA3E}</UniqueIdentifier>\r\n      <Extensions>qrc;*</Extensions>\r\n      <ParseFiles>false</ParseFiles>\r\n    </Filter>\r\n    <Filter Include=\"Generated Files\">\r\n      <UniqueIdentifier>{71ED8ED8-ACB9-4CE9-BBE1-E00B30144E11}</UniqueIdentifier>\r\n      <Extensions>moc;h;cpp</Extensions>\r\n      <SourceControlFiles>False</SourceControlFiles>\r\n    </Filter>\r\n    <Filter Include=\"Generated Files\\Debug\">\r\n      <UniqueIdentifier>{aadf1134-eca1-4c7e-afc5-1e558bce1cca}</UniqueIdentifier>\r\n      <Extensions>cpp;moc</Extensions>\r\n      <SourceControlFiles>False</SourceControlFiles>\r\n    </Filter>\r\n    <Filter Include=\"Generated Files\\Release\">\r\n      <UniqueIdentifier>{8d5952d1-aa69-48bb-8569-a9f6e60c9c17}</UniqueIdentifier>\r\n      <Extensions>cpp;moc</Extensions>\r\n      <SourceControlFiles>False</SourceControlFiles>\r\n    </Filter>\r\n    <Filter Include=\"Header Files\\fileSaveDialog\">\r\n      <UniqueIdentifier>{b83ec61f-c442-4d4e-837d-d2a15546f1d2}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Source Files\\fileSaveDialog\">\r\n      <UniqueIdentifier>{96791d0b-4242-4c48-8995-dc759e173938}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Header Files\\common\">\r\n      <UniqueIdentifier>{2b182065-7909-4047-b5ba-0b631bfcc244}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Source Files\\common\">\r\n      <UniqueIdentifier>{01471689-4fe1-4eb1-aff5-66fae41f2c1b}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Header Files\\memoryDesigner\">\r\n      <UniqueIdentifier>{01e40c77-7557-4568-b84c-3db5dd57cb6b}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Source Files\\memoryDesigner\">\r\n      <UniqueIdentifier>{e45a822a-90b3-4a17-8e9a-deb3f69414ba}</UniqueIdentifier>\r\n    </Filter>\r\n  </ItemGroup>\r\n  <ItemGroup>\r\n    <ClCompile Include=\"memorymapheadergenerator.cpp\">\r\n      <Filter>Source Files</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"localheadersavemodel.cpp\">\r\n      <Filter>Source Files</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"globalheadersavemodel.cpp\">\r\n      <Filter>Source Files</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"localheadersavedelegate.cpp\">\r\n      <Filter>Source Files</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"systemheadersavemodel.cpp\">\r\n      <Filter>Source Files</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"fileSaveDialog\\filesavedialogview.cpp\">\r\n      <Filter>Source Files\\fileSaveDialog</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"fileSaveDialog\\filesavedialog.cpp\">\r\n      <Filter>Source Files\\fileSaveDialog</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"SystemMemoryMapHeaderWriter.cpp\">\r\n      <Filter>Source Files</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"LocalMemoryMapHeaderWriter.cpp\">\r\n      <Filter>Source Files</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"GlobalMemoryMapHeaderWriter.cpp\">\r\n      <Filter>Source Files</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"BaseMemoryMapHeaderWriter.cpp\">\r\n      <Filter>Source Files</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\common\\widgets\\viewSelector\\viewselector.cpp\">\r\n      <Filter>Source Files</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\common\\ConnectivityGraphUtilities.cpp\">\r\n      <Filter>Source Files\\common</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\editors\\MemoryDesigner\\ConnectivityInterface.cpp\">\r\n      <Filter>Source Files\\memoryDesigner</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\editors\\MemoryDesigner\\ConnectivityComponent.cpp\">\r\n      <Filter>Source Files\\memoryDesigner</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\common\\CpuRoutesContainer.cpp\">\r\n      <Filter>Source Files\\common</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\common\\SingleCpuRoutesContainer.cpp\">\r\n      <Filter>Source Files\\common</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\editors\\MemoryDesigner\\ConnectivityGraphFactory.cpp\">\r\n      <Filter>Source Files\\memoryDesigner</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\editors\\MemoryDesigner\\ConnectivityConnection.cpp\">\r\n      <Filter>Source Files\\memoryDesigner</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\editors\\MemoryDesigner\\MemoryItem.cpp\">\r\n      <Filter>Source Files\\memoryDesigner</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\editors\\MemoryDesigner\\ConnectivityGraph.cpp\">\r\n      <Filter>Source Files\\memoryDesigner</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\editors\\MemoryDesigner\\MasterSlavePathSearch.cpp\">\r\n      <Filter>Source Files\\memoryDesigner</Filter>\r\n    </ClCompile>\r\n  </ItemGroup>\r\n  <ItemGroup>\r\n    <ClInclude Include=\"memorymapheadergenerator_global.h\">\r\n      <Filter>Header Files</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"SystemMemoryMapHeaderWriter.h\">\r\n      <Filter>Header Files</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"LocalMemoryMapHeaderWriter.h\">\r\n      <Filter>Header Files</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"GlobalMemoryMapHeaderWriter.h\">\r\n      <Filter>Header Files</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"BaseMemoryMapHeaderWriter.h\">\r\n      <Filter>Header Files</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\common\\ConnectivityGraphUtilities.h\">\r\n      <Filter>Header Files\\common</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\editors\\MemoryDesigner\\ConnectivityInterface.h\">\r\n      <Filter>Header Files\\memoryDesigner</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\editors\\MemoryDesigner\\ConnectivityComponent.h\">\r\n      <Filter>Header Files\\memoryDesigner</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\common\\CpuRoutesContainer.h\">\r\n      <Filter>Header Files\\common</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\common\\SingleCpuRoutesContainer.h\">\r\n      <Filter>Header Files\\common</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\editors\\MemoryDesigner\\ConnectivityGraphFactory.h\">\r\n      <Filter>Header Files\\memoryDesigner</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\editors\\MemoryDesigner\\ConnectivityConnection.h\">\r\n      <Filter>Header Files\\memoryDesigner</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\editors\\MemoryDesigner\\MemoryItem.h\">\r\n      <Filter>Header Files\\memoryDesigner</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\editors\\MemoryDesigner\\ConnectivityGraph.h\">\r\n      <Filter>Header Files\\memoryDesigner</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\editors\\MemoryDesigner\\MasterSlavePathSearch.h\">\r\n      <Filter>Header Files\\memoryDesigner</Filter>\r\n    </ClInclude>\r\n  </ItemGroup>\r\n  <ItemGroup>\r\n    <QtMoc Include=\"memorymapheadergenerator.h\">\r\n      <Filter>Header Files</Filter>\r\n    </QtMoc>\r\n    <QtRcc Include=\"memorymapheadergenerator.qrc\">\r\n      <Filter>Resource Files</Filter>\r\n    </QtRcc>\r\n    <QtMoc Include=\"globalheadersavemodel.h\">\r\n      <Filter>Header Files</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"localheadersavedelegate.h\">\r\n      <Filter>Header Files</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"localheadersavemodel.h\">\r\n      <Filter>Header Files</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"systemheadersavemodel.h\">\r\n      <Filter>Header Files</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"fileSaveDialog\\filesavedialog.h\">\r\n      <Filter>Header Files\\fileSaveDialog</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"fileSaveDialog\\filesavedialogview.h\">\r\n      <Filter>Header Files\\fileSaveDialog</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"..\\..\\common\\widgets\\viewSelector\\viewselector.h\">\r\n      <Filter>Header Files</Filter>\r\n    </QtMoc>\r\n  </ItemGroup>\r\n  <ItemGroup>\r\n    <None Include=\"headerGenerator.json\" />\r\n  </ItemGroup>\r\n</Project>"
  },
  {
    "path": "Plugins/MemoryMapHeaderGenerator/SystemMemoryMapHeaderWriter.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: SystemMemoryMapHeaderWriter.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 08.05.2015\r\n//\r\n// Description:\r\n// The implementation for creating c-headers of a system, including other generated code for the HW platform.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"SystemMemoryMapHeaderWriter.h\"\r\n\r\n#include <KactusAPI/include/LibraryInterface.h>\r\n\r\n#include <KactusAPI/include/IPluginUtility.h>\r\n#include <Plugins/MemoryMapHeaderGenerator/fileSaveDialog/filesavedialog.h>\r\n\r\n#include <IPXACTmodels/kactusExtensions/SystemView.h>\r\n\r\n#include <IPXACTmodels/Component/FileSet.h>\r\n\r\n#include <QDate>\r\n#include <QDir>\r\n#include <QStringList>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SystemMemoryMapHeaderWriter::SystemMemoryMapHeaderWriter()\r\n//-----------------------------------------------------------------------------\r\nSystemMemoryMapHeaderWriter::SystemMemoryMapHeaderWriter(IPluginUtility* utility, QObject* parentObject):\r\nBaseMemoryMapHeaderWriter(utility),\r\nparentObject_(parentObject),\r\nsystemGeneratorSettings_()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SystemMemoryMapHeaderWriter::SystemMemoryMapHeaderWriter()\r\n//-----------------------------------------------------------------------------\r\nSystemMemoryMapHeaderWriter::~SystemMemoryMapHeaderWriter()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SystemMemoryMapHeaderWriter::writeMemoryMapHeader()\r\n//-----------------------------------------------------------------------------\r\nvoid SystemMemoryMapHeaderWriter::writeMemoryMapHeader(QSharedPointer<Component> component,\r\n    QSharedPointer<DesignConfiguration> designConfiguration, QSharedPointer<Design> design)\r\n{\r\n    Q_ASSERT(component);\r\n    Q_ASSERT(designConfiguration);\r\n    Q_ASSERT(design);\r\n    Q_ASSERT(utility_);\r\n\r\n    QSharedPointer<SystemView> systemView = findSystemView(component, designConfiguration);\r\n\r\n    VLNV designVLNV = component->getModel()->getHierRef(systemView->getHWViewRef());\r\n\r\n    QSharedPointer<Design> hwDesign = utility_->getLibraryInterface()->getDesign(designVLNV);\r\n\r\n    systemGeneratorSettings_.clear();\r\n\r\n    QSharedPointer<SystemView> sysView = component->findSystemView(designConfiguration->getVlnv());\r\n\tQ_ASSERT(sysView);\r\n\r\n\tQStringList usedFileTypes;\r\n\tusedFileTypes.append(\"cSource\");\r\n\tusedFileTypes.append(\"cppSource\");\r\n\r\n\t// find all CPU instances\r\n\tforeach (QSharedPointer<const ComponentInstance> instance, *design->getComponentInstances())\r\n    {\r\n\t\tVLNV instanceVLNV = *instance->getComponentRef();\r\n\t\tQSharedPointer<const Document> libComp = utility_->getLibraryInterface()->getModelReadOnly(instanceVLNV);\r\n\t\tQSharedPointer<const Component> instComponent = libComp.dynamicCast<const Component>();\r\n\t\tQ_ASSERT(instComponent);\r\n\r\n\t\tif (!instComponent->isCpu())\r\n        {\r\n\t\t\tcontinue;\r\n\t\t}\r\n\r\n\t\t// create header settings object for the CPU instance\r\n\t\tSystemHeaderSaveModel::SysHeaderOptions systemHeaderOption(instance->getInstanceName(), instanceVLNV);\r\n\r\n\t\tsystemHeaderOption.instanceId_ = instance->getUuid();\r\n\r\n        QString activeView = designConfiguration->getActiveView(instance->getInstanceName());\r\n\t\tif (!activeView.isEmpty())\r\n        {\r\n\t\t\tQSharedPointer<View> swView = component->getModel()->findView(activeView);\r\n            QSharedPointer<ComponentInstantiation> insta;\r\n\r\n            if (swView)\r\n            {\r\n                insta = component->getModel()->findComponentInstantiation(swView->getComponentInstantiationRef());\r\n            }\r\n\r\n            if (insta)\r\n            {\r\n                QStringList fileSets = insta->getFileSetReferenceStrings();\r\n\r\n                // the files that are included in the active view\r\n                QStringList files = instComponent->getFilesFromFileSets(fileSets, usedFileTypes);\r\n\r\n                QString sourcePath = utility_->getLibraryInterface()->getPath(instanceVLNV);\r\n\r\n                // convert all relative paths from component to absolute path\r\n                foreach (QString relPath, files)\r\n                {\r\n                    QString absolutePath = General::getAbsolutePath(sourcePath, relPath);\r\n\r\n                    QFileInfo info(absolutePath);\r\n                    systemHeaderOption.includeFiles_.append(info);\r\n                }\r\n            }\r\n\t\t}\r\n        systemGeneratorSettings_.append(systemHeaderOption);\r\n\t}\r\n\r\n\tSystemHeaderSaveModel model(utility_->getLibraryInterface(), parentObject_);\r\n    model.setObjects(component, systemGeneratorSettings_);\r\n\r\n\tFileSaveDialog dialog(utility_->getParentWidget());\r\n\tdialog.setModel(&model);\r\n\r\n\tint result = dialog.exec();\r\n\r\n\tif (result == QDialog::Rejected)\r\n    {\r\n        informGenerationAbort();\r\n\t\treturn;\r\n\t}\r\n\r\n    systemGeneratorSettings_ = model.getObjects();\r\n\r\n    searchInstanceFiles(component, sysView->getHWViewRef());\r\n\r\n\tbool changed = false;\r\n\r\n    informStartOfGeneration();\r\n\r\n\t// write the system headers for CPU instances\r\n    foreach (const SystemHeaderSaveModel::SysHeaderOptions& systemHeaderOption, systemGeneratorSettings_)\r\n    {\r\n\t\tQFile file(systemHeaderOption.sysHeaderInfo_.absoluteFilePath());\r\n\r\n        checkDirectoryStructure(systemHeaderOption.sysHeaderInfo_.dir());\r\n\r\n\t\tif (!file.open(QFile::Truncate | QFile::WriteOnly))\r\n        {\r\n            openFileErrorMessage(systemHeaderOption.sysHeaderInfo_.absoluteFilePath());\r\n\t\t\tbreak;\r\n\t\t}\r\n\r\n        QTextStream stream(&file);\r\n\r\n        QString description(\" * This file includes the header files which are automatically generated by Kactus2.\\n\"\r\n            \" * This file allows indirect includes for generated files, thus allowing more flexible SW \"\r\n            \"development.\\n\"\r\n            \" * Generated for system design: \" + design->getVlnv().toString() + \"\\n\"\r\n            \" * Target instance: \" + systemHeaderOption.instanceName_ + \"\\n\"\r\n            \"*/\");\r\n\r\n        QString headerGuard(component->getVlnv().toString(\"_\").toUpper() + \"_\" +\r\n            systemHeaderOption.instanceName_.toUpper() + \"_H\");\r\n\r\n        writeTopOfHeaderFile(stream, systemHeaderOption.sysHeaderInfo_.fileName(), headerGuard, description);\r\n\r\n\t\tforeach (const QFileInfo& includeFile, systemHeaderOption.includeFiles_)\r\n        {\r\n\t\t\tstream << \"#include \\\"\" << includeFile.absoluteFilePath() << \"\\\"\" << Qt::endl;\r\n\t\t}\r\n\r\n\t\tstream << Qt::endl << \"#endif /* \" << headerGuard << \" */\" << Qt::endl;\r\n\r\n        informWritingFinished(systemHeaderOption.sysHeaderInfo_.fileName());\r\n\r\n\t\tfile.close();\r\n\r\n\t\tchanged = true;\r\n\r\n        addHeaderFile(component, systemHeaderOption.sysHeaderInfo_, systemHeaderOption.instanceName_,\r\n            QStringList(), systemHeaderOption.instanceId_);\r\n\t}\r\n\r\n\tif (changed)\r\n    {\r\n\t\t// save the changes to the file sets\r\n        utility_->getLibraryInterface()->writeModelToFile(component);\r\n\t}\r\n\r\n\t// clear the settings after generation\r\n    systemGeneratorSettings_.clear();\r\n\r\n    informGenerationComplete();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SystemMemoryMapHeaderWriter::searchInstanceFiles()\r\n//-----------------------------------------------------------------------------\r\nvoid SystemMemoryMapHeaderWriter::searchInstanceFiles(QSharedPointer<const Component> component,\r\n    const QString& hwViewName)\r\n{\r\n    if (!component->hasView(hwViewName))\r\n    {\r\n        return;\r\n    }\r\n\r\n    VLNV hierRef = component->getHierRef(hwViewName);\r\n\r\n    if (!hierRef.isValid())\r\n    {\r\n        return;\r\n    }\r\n\r\n    QSharedPointer<const Document> libDesConf = utility_->getLibraryInterface()->getModelReadOnly(hierRef);\r\n    QSharedPointer<const DesignConfiguration> desConf = libDesConf.dynamicCast<const DesignConfiguration>();\r\n\r\n    QSharedPointer<const Design> design;\r\n\r\n    if (!desConf)\r\n    {\r\n        design = libDesConf.dynamicCast<const Design>();\r\n    }\r\n    else\r\n    {\r\n        VLNV designVLNV = desConf->getDesignRef();\r\n        QSharedPointer<const Document> libDes =\r\n            utility_->getLibraryInterface()->getModelReadOnly(designVLNV);\r\n        design = libDes.dynamicCast<const Design>();\r\n    }\r\n\r\n    if (!design)\r\n    {\r\n        return;\r\n    }\r\n\r\n    QList<SystemMemoryMapHeaderWriter::HierParsingInfo> instancesToParse;\r\n\r\n    QStringList usedFileTypes;\r\n    usedFileTypes.append(\"cSource\");\r\n    usedFileTypes.append(\"cppSource\");\r\n\r\n    foreach (QSharedPointer<const ComponentInstance> instance, *design->getComponentInstances())\r\n    {\r\n        bool matched = false;\r\n\r\n        // check if the instance matches one of the searched CPUs\r\n        for (int i = 0; i < systemGeneratorSettings_.size(); ++i)\r\n        {\r\n            SystemHeaderSaveModel::SysHeaderOptions& systemHeaderOption = systemGeneratorSettings_[i];\r\n\r\n            // if the CPU was already found before\r\n            if (systemHeaderOption.found_)\r\n            {\r\n                continue;\r\n            }\r\n\r\n            else if (instance->getUuid() == systemHeaderOption.instanceId_)\r\n            {\r\n                systemHeaderOption.found_ = true;\r\n                matched = true;\r\n\r\n                QSharedPointer<const FileSet> instanceFileSet =\r\n                    component->findFileSetById(systemHeaderOption.instanceId_);\r\n\r\n                if (!instanceFileSet)\r\n                {\r\n                    break;\r\n                }\r\n\r\n                QString sourcePath = utility_->getLibraryInterface()->getPath(component->getVlnv());\r\n                foreach (QString const& fileType, usedFileTypes)\r\n                {\r\n                    foreach (QString const& relativePath, instanceFileSet->findFilesByFileType(fileType))\r\n                    {\r\n                        QString absolutePath = General::getAbsolutePath(sourcePath, relativePath);\r\n\r\n                        QFileInfo info(absolutePath);\r\n                        systemHeaderOption.includeFiles_.append(info);\r\n                    }\r\n                }\r\n\r\n                break;\r\n            }\r\n        }\r\n\r\n        if (!matched)\r\n        {\r\n            VLNV instanceVLNV = *instance->getComponentRef();\r\n            QSharedPointer<const Document> libComp = utility_->getLibraryInterface()->getModelReadOnly(instanceVLNV);\r\n            QSharedPointer<const Component> instanceComponent = libComp.dynamicCast<const Component>();\r\n            Q_ASSERT(instanceComponent);\r\n\r\n            QString activeView = desConf->getActiveView(instance->getInstanceName());\r\n            if (activeView.isEmpty())\r\n            {\r\n                QStringList hierViewNames = instanceComponent->getHierViews();\r\n\r\n                if (hierViewNames.size() == 1)\r\n                {\r\n                    activeView = hierViewNames.first();\r\n                }\r\n                else\r\n                {\r\n                    continue;\r\n                }\r\n            }\r\n\r\n            Q_ASSERT(!activeView.isEmpty());\r\n\r\n            SystemMemoryMapHeaderWriter::HierParsingInfo info(instanceComponent, activeView);\r\n            instancesToParse.append(info);\r\n        }\r\n    }\r\n\r\n    bool allFound = true;\r\n    foreach (const SystemHeaderSaveModel::SysHeaderOptions& systemHeaderOption, systemGeneratorSettings_)\r\n    {\r\n        if (!systemHeaderOption.found_)\r\n        {\r\n            allFound = false;\r\n        }\r\n    }\r\n\r\n    // if there is at least one more CPU instance to find\r\n    if (!allFound)\r\n    {\r\n        foreach (SystemMemoryMapHeaderWriter::HierParsingInfo info, instancesToParse)\r\n        {\r\n            searchInstanceFiles(info.comp_, info.activeView_);\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SystemMemoryMapHeaderWriter::HierParsingInfo::HierParsingInfo()\r\n//-----------------------------------------------------------------------------\r\nSystemMemoryMapHeaderWriter::HierParsingInfo::HierParsingInfo(QSharedPointer<const Component> comp,\r\n    const QString& viewName):\r\ncomp_(comp),\r\nactiveView_(viewName)\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SystemMemoryMapHeaderWriter::HierParsingInfo::HierParsingInfo()\r\n//-----------------------------------------------------------------------------\r\nSystemMemoryMapHeaderWriter::HierParsingInfo::HierParsingInfo(const HierParsingInfo& other):\r\ncomp_(other.comp_),\r\nactiveView_(other.activeView_)\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SystemMemoryMapHeaderWriter::HierParsingInfo::operator=()\r\n//-----------------------------------------------------------------------------\r\nSystemMemoryMapHeaderWriter::HierParsingInfo& SystemMemoryMapHeaderWriter::HierParsingInfo::operator=(\r\n    const HierParsingInfo& other)\r\n{\r\n    if (&other != this)\r\n    {\r\n        comp_ = other.comp_;\r\n        activeView_ = other.activeView_;\r\n    }\r\n    return *this;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SystemMemoryMapHeaderWriter::findSystemView()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<SystemView> SystemMemoryMapHeaderWriter::findSystemView(QSharedPointer<Component> component,\r\n    QSharedPointer<DesignConfiguration> designConfiguration) const\r\n{\r\n    foreach (QSharedPointer<SystemView> systemDesignView, component->getSystemViews())\r\n    {\r\n        if (systemDesignView->getHierarchyRef() == designConfiguration->getVlnv())\r\n        {\r\n            return systemDesignView;\r\n        }\r\n    }\r\n\r\n    // This should not be reached.\r\n    return QSharedPointer<SystemView> ();\r\n}\r\n"
  },
  {
    "path": "Plugins/MemoryMapHeaderGenerator/SystemMemoryMapHeaderWriter.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: SystemMemoryMapHeaderWriter.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 08.05.2015\r\n//\r\n// Description:\r\n// The implementation for creating c-headers of a system, including other generated code for the HW platform.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef SYSTEMMEMORYMAPHEADERWRITER_H\r\n#define SYSTEMMEMORYMAPHEADERWRITER_H\r\n\r\n#include \"BaseMemoryMapHeaderWriter.h\"\r\n\r\n#include \"systemheadersavemodel.h\"\r\n\r\n#include <IPXACTmodels/Component/Component.h>\r\n\r\n#include <IPXACTmodels/kactusExtensions/SystemView.h>\r\n\r\n#include <IPXACTmodels/Design/Design.h>\r\n\r\n#include <IPXACTmodels/DesignConfiguration/DesignConfiguration.h>\r\n\r\n\r\n#include <QObject>\r\n#include <QSharedPointer>\r\n#include <QString>\r\n#include <QFileInfo>\r\n#include <QList>\r\n#include <QTextStream>\r\n\r\nclass IPluginUtility;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! The base implementation for memory map header writer.\r\n//-----------------------------------------------------------------------------\r\nclass SystemMemoryMapHeaderWriter : public BaseMemoryMapHeaderWriter\r\n{\r\n\r\npublic:\r\n\r\n    /*!\r\n     *  The constructor.\r\n     *\r\n     *    @param [in] utility         The interface which offers core utilites for plugins.\r\n     *    @param [in] parentObject    The parent object of this writer.\r\n     */\r\n    SystemMemoryMapHeaderWriter(IPluginUtility* utility, QObject* parentObject);\r\n\r\n    /*!\r\n     *  The destructor.\r\n     */\r\n    virtual ~SystemMemoryMapHeaderWriter();\r\n\r\n    /*!\r\n     *  Write the memory map header file.\r\n     *\r\n     *    @param [in] component               The component whose header file is being written.\r\n     *    @param [in] designConfiguration     The design configuration for the component.\r\n     *    @param [in] design                  The designg for the component.\r\n     */\r\n    virtual void writeMemoryMapHeader(QSharedPointer<Component> component,\r\n        QSharedPointer<DesignConfiguration> designConfiguration, QSharedPointer<Design> design);\r\n\r\nprotected:\r\n\r\nprivate:\r\n\r\n\t//! No copying\r\n    SystemMemoryMapHeaderWriter(const SystemMemoryMapHeaderWriter& other);\r\n\r\n\t//! No assignment\r\n    SystemMemoryMapHeaderWriter& operator=(const SystemMemoryMapHeaderWriter& other);\r\n\r\n\t/*!\r\n\t *  Search the CPU instances and their containing component to find the generated global headers.\r\n\t *\r\n\t *    @param [in] component   Pointer to the hierarchical component to search.\r\n\t *    @param [in] hwViewName  The name of the hierarchical view on the component.\r\n\t */\r\n\tvoid searchInstanceFiles(QSharedPointer<const Component> component, const QString& hwViewName);\r\n\r\n    /*!\r\n     *  Find the system view currently used in the system design.\r\n     *\r\n     *    @param [in] component               The component whose system view is in use.\r\n     *    @param [in] designConfiguration     The design configuration of the component.\r\n     */\r\n    QSharedPointer<SystemView> findSystemView(QSharedPointer<Component> component,\r\n        QSharedPointer<DesignConfiguration> designConfiguration) const;\r\n\r\n    //! Used to save info on instances and their active views to be parsed.\r\n    struct HierParsingInfo {\r\n\r\n        //! Identifies the component.\r\n        QSharedPointer<const Component> comp_;\r\n\r\n        //! The view which is set for the component.\r\n        QString activeView_;\r\n\r\n        //! The constructor.\r\n        HierParsingInfo(QSharedPointer<const Component> comp, const QString& viewName);\r\n\r\n        //! Copy constructor. No deep copy needed for the pointer.\r\n        HierParsingInfo(const HierParsingInfo& other);\r\n\r\n        //! Assignment operator. No deep copy needed for the pointer.\r\n        HierParsingInfo& operator=(const HierParsingInfo& other);\r\n    };\r\n\r\n    //! The parent object of this writer.\r\n    QObject* parentObject_;\r\n\r\n    //! The system header options.\r\n    QList<SystemHeaderSaveModel::SysHeaderOptions> systemGeneratorSettings_;\r\n};\r\n\r\n#endif // SYSTEMMEMORYMAPHEADERWRITER_H\r\n"
  },
  {
    "path": "Plugins/MemoryMapHeaderGenerator/fileSaveDialog/filesavedialog.cpp",
    "content": "/* \r\n *\tCreated on: 18.2.2013\r\n *\tAuthor:\t\tAntti Kamppi\r\n * \tFile name:\tfilesavedialog.cpp\r\n * \tProject:\tKactus 2\r\n*/\r\n\r\n#include \"filesavedialog.h\"\r\n\r\n#include <QLabel>\r\n#include <QVBoxLayout>\r\n#include <QDialogButtonBox>\r\n\r\nFileSaveDialog::FileSaveDialog(QWidget *parent):\r\nQDialog(parent),\r\nview_(new FileSaveDialogView(this))\r\n{\r\n\tQLabel* infoText = new QLabel(tr(\"Select names for the output files\"), this);\r\n\r\n\tQDialogButtonBox* buttons = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel,\r\n\t\tQt::Horizontal, this);\r\n\r\n\tconnect(buttons, SIGNAL(accepted()), this, SLOT(accept()), Qt::UniqueConnection);\r\n\tconnect(buttons, SIGNAL(rejected()), this, SLOT(reject()), Qt::UniqueConnection);\r\n\r\n\tQVBoxLayout* layout = new QVBoxLayout(this);\r\n\tlayout->addWidget(infoText);\r\n\tlayout->addWidget(view_);\r\n\tlayout->addWidget(buttons);\r\n}\r\n\r\nFileSaveDialog::~FileSaveDialog() {\r\n}\r\n\r\nvoid FileSaveDialog::setModel( QAbstractTableModel* model ) {\r\n\tview_->setModel(model);\r\n}\r\n\r\nQSize FileSaveDialog::sizeHint() const {\r\n\treturn minimumSizeHint();\r\n}\r\n\r\nQSize FileSaveDialog::minimumSizeHint() const {\r\n\treturn QSize(FileSaveDialog::WIDTH, FileSaveDialog::HEIGHT);\r\n}\r\n\r\nvoid FileSaveDialog::setItemDelegate( QStyledItemDelegate* delegate ) {\r\n\tview_->setItemDelegate(delegate);\r\n}\r\n"
  },
  {
    "path": "Plugins/MemoryMapHeaderGenerator/fileSaveDialog/filesavedialog.h",
    "content": "/* \r\n *\tCreated on: 18.2.2013\r\n *\tAuthor:\t\tAntti Kamppi\r\n * \tFile name:\tfilesavedialog.h\r\n * \tProject:\tKactus 2\r\n*/\r\n#ifndef FILESAVEDIALOG_H\r\n#define FILESAVEDIALOG_H\r\n\r\n#include \"filesavedialogview.h\"\r\n\r\n#include <QDialog>\r\n#include <QAbstractTableModel>\r\n#include <QSize>\r\n#include <QStyledItemDelegate>\r\n\r\n/*! \\brief The dialog can be used for user to select multiple files to be created.\r\n * \r\n * The dialog needs a model which is used to display the files to be created. \r\n * User can change the file names and paths.\r\n */\r\nclass FileSaveDialog : public QDialog\r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\r\n\t//! \\brief Contains the height and width of the dialog.\r\n\tenum Sizes {\r\n\t\tWIDTH = 600,\r\n\t\tHEIGHT = 300\r\n\t};\r\n\r\n\t/*! \\brief The constructor\r\n\t *\r\n\t * Method: \t\tFileSaveDialog\r\n\t * Full name:\tFileSaveDialog::FileSaveDialog\r\n\t * Access:\t\tpublic \r\n\t *\r\n\t * \\param parent Pointer to the owner of the dialog.\r\n\t *\r\n\t*/\r\n\tFileSaveDialog(QWidget *parent);\r\n\r\n\t//! \\brief The destructor\r\n\tvirtual ~FileSaveDialog();\r\n\r\n\t/*! \\brief Set the model for the table view.\r\n\t *\r\n\t * Method: \t\tsetModel\r\n\t * Full name:\tFileSaveDialog::setModel\r\n\t * Access:\t\tpublic \r\n\t *\r\n\t * \\param model Pointer to the model class, which contains the data to modify.\r\n\t *\r\n\t*/\r\n\tvoid setModel(QAbstractTableModel* model);\r\n\r\n\t/*! \\brief Get the size hint for the dialog.\r\n\t *\r\n\t * Method: \t\tsizeHint\r\n\t * Full name:\tFileSaveDialog::sizeHint\r\n\t * Access:\t\tvirtual public \r\n\t *\r\n\t * \r\n\t * \\return QSize contains the preferred size of the dialog.\r\n\t*/\r\n\tvirtual QSize sizeHint() const;\r\n\r\n\t/*! \\brief Get the minimum size hint for the dialog.\r\n\t *\r\n\t * Method: \t\tminimumSizeHint\r\n\t * Full name:\tFileSaveDialog::minimumSizeHint\r\n\t * Access:\t\tvirtual public \r\n\t *\r\n\t *\r\n\t * \\return QSize contains the minimum size of the dialog.\r\n\t*/\r\n\tvirtual QSize minimumSizeHint() const;\r\n\r\n\t//! \\brief Set the delegate class for the view.\r\n\tvoid setItemDelegate(QStyledItemDelegate* delegate);\r\n\r\nprivate:\r\n\t\r\n\t//! \\brief No copying\r\n\tFileSaveDialog(const FileSaveDialog& other);\r\n\r\n\t//! \\brief No assignment\r\n\tFileSaveDialog& operator=(const FileSaveDialog& other);\r\n\r\n\t//! \\brief The view displaying the files to be created.\r\n\tFileSaveDialogView* view_;\r\n};\r\n\r\n#endif // FILESAVEDIALOG_H\r\n"
  },
  {
    "path": "Plugins/MemoryMapHeaderGenerator/fileSaveDialog/filesavedialogview.cpp",
    "content": "/* \r\n *\tCreated on: 19.2.2013\r\n *\tAuthor:\t\tAntti Kamppi\r\n * \tFile name:\tfilesavedialogview.cpp\r\n * \tProject:\tKactus 2\r\n*/\r\n\r\n#include \"filesavedialogview.h\"\r\n\r\n#include <QMenu>\r\n#include <QHeaderView>\r\n#include <QFontMetrics>\r\n#include <QFileDialog>\r\n\r\n#include <QDebug>\r\n\r\nFileSaveDialogView::FileSaveDialogView(QWidget *parent):\r\nQTableView(parent),\r\nchangeAction_(new QAction(tr(\"Change\"), this)) {\r\n\r\n\tchangeAction_->setToolTip(tr(\"Change the file name and path\"));\r\n\tchangeAction_->setStatusTip(tr(\"Change the file name and path\"));\r\n\tconnect(changeAction_, SIGNAL(triggered()),\r\n\t\tthis, SLOT(onChange()), Qt::UniqueConnection);\r\n\r\n\t// cells are resized to match contents \r\n\thorizontalHeader()->setSectionResizeMode(QHeaderView::Interactive);\r\n\r\n\t//last column is stretched take the available space in the widget\r\n\thorizontalHeader()->setStretchLastSection(true);\r\n\r\n\t// vertical headers are not visible\r\n\tverticalHeader()->hide();\r\n\r\n\t// set the height of a row to be smaller than default\r\n\tverticalHeader()->setDefaultSectionSize(fontMetrics().height() + 8);\r\n\r\n\t// words are wrapped in the cells to minimize space usage\r\n\tsetWordWrap(true);\r\n\r\n\t// easies to see the different rows from one another\r\n\tsetAlternatingRowColors(true);\r\n}\r\n\r\nFileSaveDialogView::~FileSaveDialogView() {\r\n}\r\n\r\nvoid FileSaveDialogView::mouseDoubleClickEvent( QMouseEvent* event ) {\r\n\tpressedPoint_ = event->pos();\r\n\tQTableView::mouseDoubleClickEvent(event);\r\n\r\n\t// if the item is valid but not editable then double click works\r\n\tQModelIndex selectedIndex = indexAt(pressedPoint_);\r\n\tif (selectedIndex.isValid() && (selectedIndex.model()->flags(selectedIndex) & Qt::ItemIsEditable) == 0) {\r\n\t\tonChange();\r\n\t}\r\n\r\n}\r\n\r\nvoid FileSaveDialogView::contextMenuEvent( QContextMenuEvent* event ) {\r\n\tpressedPoint_ = event->pos();\r\n\r\n\tQModelIndex index = indexAt(pressedPoint_);\r\n\r\n\t// only valid items can be changed\r\n\tif (!index.isValid()) {\r\n\t\treturn;\r\n\t}\r\n\r\n\t// display the menu\r\n\tQMenu menu(this);\r\n\tmenu.addAction(changeAction_);\r\n\tmenu.exec(event->globalPos());\r\n\r\n\tevent->accept();\r\n}\r\n\r\nvoid FileSaveDialogView::onChange() {\r\n\t\r\n\t// find out which item was selected\r\n\tQModelIndex selectedIndex = indexAt(pressedPoint_);\r\n\tif (!selectedIndex.isValid()) {\r\n\t\treturn;\r\n\t}\r\n\r\n\t// the previous path to the file\r\n\tQString previousPath = model()->data(selectedIndex, Qt::UserRole).toString();\r\n\r\n\t// ask user to select the file to save\r\n\tQString targetName = QFileDialog::getSaveFileName(this, tr(\"Select file to save\"), previousPath, tr(\"header files (*.h)\"));\r\n\t\r\n\t// is user clicked cancel\r\n\tif (targetName.isEmpty()) {\r\n\t\treturn;\r\n\t}\r\n\r\n\t// save the new path to the model\r\n\tmodel()->setData(selectedIndex, targetName, Qt::UserRole);\r\n}\r\n\r\nvoid FileSaveDialogView::setModel( QAbstractItemModel* model ) {\r\n\t// the base class implementation does most of the work\r\n\tQTableView::setModel(model);\r\n\r\n\t// contains info on the used font\r\n\tQFontMetrics fMetrics = fontMetrics();\r\n\r\n\t// set the widths for the columns\r\n\tint columnCount = model->columnCount(QModelIndex());\r\n\tfor (int i = 0; i < columnCount; ++i) {\r\n\r\n\t\t// the width required by the contents of the model\r\n\t\tint contentSize = sizeHintForColumn(i);\r\n\r\n\t\t// get the header for the section\r\n\t\tQString headerText = model->headerData(i, Qt::Horizontal, Qt::DisplayRole).toString();\r\n\t\t// if the header contains several lines\r\n\t\tQStringList headerLines = headerText.split(\"\\n\", Qt::SkipEmptyParts);\r\n\t\tint headerSize = 0;\r\n\r\n\t\t// find the line that needs most space\r\n\t\tforeach (QString headerLine, headerLines) {\r\n\t\t\theaderSize = qMax(headerSize, fMetrics.horizontalAdvance(headerLine));\r\n\t\t}\r\n\t\theaderSize += 45;\r\n\r\n\t\t// set the width for the column\r\n\t\tsetColumnWidth(i, qMax(contentSize, headerSize));\r\n\t}\r\n}\r\n"
  },
  {
    "path": "Plugins/MemoryMapHeaderGenerator/fileSaveDialog/filesavedialogview.h",
    "content": "/* \r\n *\tCreated on: 19.2.2013\r\n *\tAuthor:\t\tAntti Kamppi\r\n * \tFile name:\tfilesavedialogview.h\r\n * \tProject:\tKactus 2\r\n*/\r\n\r\n#ifndef FILESAVEDIALOGVIEW_H\r\n#define FILESAVEDIALOGVIEW_H\r\n\r\n#include <QTableView>\r\n#include <QMouseEvent>\r\n#include <QContextMenuEvent>\r\n#include <QAction>\r\n\r\nclass LibraryInterface;\r\n\r\n/*! \\brief The view used to display the files to be created in the FileSaveDialog.\r\n *\r\n */\r\nclass FileSaveDialogView : public QTableView {\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\r\n\t/*! \\brief The constructor.\r\n\t *\r\n\t * Method: \t\tFileSaveDialogView\r\n\t * Full name:\tFileSaveDialogView::FileSaveDialogView\r\n\t * Access:\t\tprivate \r\n\t *\r\n\t * \\param parent Pointer to the owner of the view.\r\n\t *\r\n\t*/\r\n\tFileSaveDialogView(QWidget *parent);\r\n\t\r\n\t//! \\brief The destructor\r\n\tvirtual ~FileSaveDialogView();\r\n\r\n\t/*! \\brief Set the model class for this view.\r\n\t *\r\n\t * Method: \t\tsetModel\r\n\t * Full name:\tEditableTableView::setModel\r\n\t * Access:\t\tvirtual public \r\n\t *\r\n\t * \\param model Pointer to the model class which is displayed by this view.\r\n\t *\r\n\t*/\r\n\tvirtual void setModel(QAbstractItemModel* model);\r\n\r\nprotected:\r\n\r\n\t//! \\brief Handler for mouse double click events\r\n\tvirtual void mouseDoubleClickEvent(QMouseEvent* event);\r\n\r\n\t//! \\brief Handler for context menu events\r\n\tvirtual void contextMenuEvent(QContextMenuEvent* event);\r\n\r\nprivate slots:\r\n\r\n\t//! \\brief Handler for path changes through context menu. \r\n\tvirtual void onChange();\r\n\r\nprivate:\r\n\t\r\n\t//! \\brief No copying\r\n\tFileSaveDialogView(const FileSaveDialogView& other);\r\n\r\n\t//! \\brief No assignment\r\n\tFileSaveDialogView& operator=(const FileSaveDialogView& other);\r\n\r\n\t//! \\brief The action in the context menu to change the path.\r\n\tQAction* changeAction_;\r\n\r\n\t//! \\brief The point where e.g. context menu was requested.\r\n\tQPoint pressedPoint_;\r\n};\r\n\r\n#endif // FILESAVEDIALOGVIEW_H\r\n"
  },
  {
    "path": "Plugins/MemoryMapHeaderGenerator/globalheadersavemodel.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: globalheadersavemodel.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Antti Kamppi\r\n// Date: 25.02.2013\r\n//\r\n// Description:\r\n// The model class to display the header files to be created for CPU instances within a design.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"globalheadersavemodel.h\"\r\n\r\n#include <KactusAPI/include/LibraryInterface.h>\r\n\r\n#include <editors/MemoryDesigner/ConnectivityComponent.h>\r\n\r\n#include <Plugins/common/SingleCpuRoutesContainer.h>\r\n\r\n#include <IPXACTmodels/Design/ComponentInstance.h>\r\n\r\n#include <QDir>\r\n#include <QStringList>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: globalheadersavemodel::GlobalHeaderSaveModel()\r\n//-----------------------------------------------------------------------------\r\nGlobalHeaderSaveModel::GlobalHeaderSaveModel( LibraryInterface* handler, QObject *parent ):\r\nQAbstractTableModel(parent),\r\nhandler_(handler),\r\ntable_(),\r\ncomp_()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: globalheadersavemodel::~GlobalHeaderSaveModel()\r\n//-----------------------------------------------------------------------------\r\nGlobalHeaderSaveModel::~GlobalHeaderSaveModel()\r\n{\r\n\ttable_.clear();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: globalheadersavemodel::rowCount()\r\n//-----------------------------------------------------------------------------\r\nint GlobalHeaderSaveModel::rowCount( const QModelIndex& parent /*= QModelIndex()*/ ) const\r\n{\r\n\tif (parent.isValid())\r\n    {\r\n\t\treturn 0;\r\n\t}\r\n\r\n\treturn table_.size();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: globalheadersavemodel::columnCount()\r\n//-----------------------------------------------------------------------------\r\nint GlobalHeaderSaveModel::columnCount( const QModelIndex& parent /*= QModelIndex()*/ ) const\r\n{\r\n\tif (parent.isValid())\r\n    {\r\n\t\treturn 0;\r\n\t}\r\n\r\n\treturn GlobalHeaderSaveModel::COLUMN_COUNT;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: globalheadersavemodel::flags()\r\n//-----------------------------------------------------------------------------\r\nQt::ItemFlags GlobalHeaderSaveModel::flags( const QModelIndex& index ) const\r\n{\r\n\tif (!index.isValid())\r\n    {\r\n\t\treturn Qt::NoItemFlags;\r\n\t}\r\n\r\n\treturn Qt::ItemIsEnabled | Qt::ItemIsSelectable;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: globalheadersavemodel::headerData()\r\n//-----------------------------------------------------------------------------\r\nQVariant GlobalHeaderSaveModel::headerData( int section, Qt::Orientation orientation, int role) const\r\n{\r\n\tif (orientation != Qt::Horizontal)\r\n    {\r\n\t\treturn QVariant();\r\n\t}\r\n\tif (Qt::DisplayRole == role)\r\n    {\r\n        if (section == GlobalHeaderSaveModel::INSTANCE_NAME)\r\n        {\r\n            return tr(\"Instance\\nname\");\r\n        }\r\n        else if (section == GlobalHeaderSaveModel::INTERFACE_NAME)\r\n        {\r\n            return tr(\"Interface\\nname\");\r\n        }\r\n        else if (section == GlobalHeaderSaveModel::FILE_NAME)\r\n        {\r\n            return tr(\"File name\");\r\n        }\r\n        else if (section == GlobalHeaderSaveModel::FILE_PATH)\r\n        {\r\n            return tr(\"File path\");\r\n        }\r\n\t}\r\n\r\n    return QVariant();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: globalheadersavemodel::data()\r\n//-----------------------------------------------------------------------------\r\nQVariant GlobalHeaderSaveModel::data( const QModelIndex& index, int role) const\r\n{\r\n\tif (!index.isValid())\r\n    {\r\n\t\treturn QVariant();\r\n\t}\r\n\telse if (index.row() < 0 || index.row() >= table_.size())\r\n    {\r\n\t\treturn QVariant();\r\n\t}\r\n\r\n\tif (Qt::DisplayRole == role)\r\n    {\r\n        if (index.column() == GlobalHeaderSaveModel::INSTANCE_NAME)\r\n        {\r\n            return table_.at(index.row())->instance_;\r\n        }\r\n        else if (index.column() == GlobalHeaderSaveModel::INTERFACE_NAME)\r\n        {\r\n            return table_.at(index.row())->interface_;\r\n        }\r\n        else if (index.column() == GlobalHeaderSaveModel::FILE_NAME)\r\n        {\r\n            return table_.at(index.row())->fileInfo_.fileName();\r\n        }\r\n        else if (index.column() == GlobalHeaderSaveModel::FILE_PATH)\r\n        {\r\n            VLNV identifier = table_.at(index.row())->comp_;\r\n\r\n            // display the relative path from xml directory to the header to be generated\r\n            QDir xmlDir(handler_->getDirectoryPath(comp_->getVlnv()));\r\n\t\t\tQString headerPath = table_.at(index.row())->fileInfo_.absoluteFilePath();\r\n            QString relPath = xmlDir.relativeFilePath(headerPath);\r\n\r\n            return relPath;\r\n\t\t}\r\n        else\r\n        {\r\n            return QVariant();\r\n        }\r\n\t}\r\n\t// user role always returns the absolute file path\r\n\telse if (Qt::UserRole == role)\r\n    {\r\n\t\t// if the header dir exists\r\n\t\tQFileInfo headerInfo(table_.at(index.row())->fileInfo_.absolutePath());\r\n\t\tif (headerInfo.exists())\r\n        {\r\n\t\t\t// return path to the directory for headers\r\n\t\t\treturn headerInfo.absoluteFilePath();\r\n\t\t}\r\n\r\n\t\t// if not then at least the xml directory exists\r\n\t\telse\r\n        {\r\n\t\t\treturn handler_->getDirectoryPath(comp_->getVlnv());\r\n\t\t}\r\n\t}\r\n\telse\r\n    {\r\n\t\treturn QVariant();\r\n\t}\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: globalheadersavemodel::setData()\r\n//-----------------------------------------------------------------------------\r\nbool GlobalHeaderSaveModel::setData( const QModelIndex& index, const QVariant& value, int role)\r\n{\r\n\tif (!index.isValid())\r\n    {\r\n\t\treturn false;\r\n\t}\r\n\telse if (index.row() < 0 || index.row() >= table_.size())\r\n    {\r\n\t\treturn false;\r\n\t}\r\n\r\n\tif (Qt::EditRole == role)\r\n    {\r\n        if (index.column() == GlobalHeaderSaveModel::INSTANCE_NAME ||\r\n            index.column() == GlobalHeaderSaveModel::INTERFACE_NAME)\r\n        {\r\n            return false;\r\n        }\r\n        else if (index.column() == GlobalHeaderSaveModel::FILE_NAME)\r\n        {\r\n            table_[index.row()]->fileInfo_.setFile(value.toString());\r\n\r\n            // both indexes change\r\n            QModelIndex pathIndex =\r\n                QAbstractTableModel::index(index.row(), GlobalHeaderSaveModel::FILE_PATH, QModelIndex());\r\n            emit dataChanged(index, pathIndex);\r\n            return true;\r\n        }\r\n        else if (index.column() == GlobalHeaderSaveModel::FILE_PATH)\r\n        {\r\n            table_[index.row()]->fileInfo_.setFile(value.toString());\r\n\r\n            // both columns change\r\n            QModelIndex nameIndex = QAbstractTableModel::index(index.row(), GlobalHeaderSaveModel::FILE_NAME, QModelIndex());\r\n            emit dataChanged(nameIndex, index);\r\n            return true;\r\n        }\r\n        else\r\n        {\r\n            return false;\r\n        }\r\n\t}\r\n\telse if (Qt::UserRole == role)\r\n    {\r\n\t\ttable_[index.row()]->fileInfo_.setFile(value.toString());\r\n\r\n\t\t// the change affects to both columns\r\n\t\tQModelIndex leftIndex = QAbstractTableModel::index(index.row(), GlobalHeaderSaveModel::FILE_NAME, QModelIndex());\r\n\t\tQModelIndex rightIndex = QAbstractTableModel::index(index.row(), GlobalHeaderSaveModel::FILE_PATH, QModelIndex());\r\n\r\n\t\t// inform of changes\r\n\t\temit dataChanged(leftIndex, rightIndex);\r\n\t\treturn true;\r\n\t}\r\n\telse\r\n    {\r\n\t\treturn false;\r\n\t}\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: globalheadersavemodel::getHeaderOptions()\r\n//-----------------------------------------------------------------------------\r\nconst QList<QSharedPointer<GlobalHeaderSaveModel::SaveFileOptions> >& GlobalHeaderSaveModel::getHeaderOptions() const\r\n{\r\n\treturn table_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: globalheadersavemodel::setCPUData()\r\n//-----------------------------------------------------------------------------\r\nvoid GlobalHeaderSaveModel::setCPUData(QSharedPointer<Component> topComponent, QVector<QSharedPointer<SingleCpuRoutesContainer>> const& cpuRoutes)\r\n{\r\n\tbeginResetModel();\r\n\r\n\t// update the component and design used\r\n\tcomp_ = topComponent;\r\n\r\n\t// remove previous items\r\n\ttable_.clear();\r\n\r\n\tfor (auto singleCPU : cpuRoutes)\r\n\t{\r\n\t\tauto cpuInterface = singleCPU->getRoutes().first()->cpuInterface_;\r\n\t\tauto cpuInstance = cpuInterface->getInstance();\r\n\r\n\t\tauto interfaceName = cpuInterface->getName();\r\n\t\tauto instanceName = cpuInstance->getName();\r\n\r\n\t\tVLNV cpuComponentVLNV(VLNV::COMPONENT, cpuInstance->getVlnv());\r\n\r\n\t\tauto options = QSharedPointer<SaveFileOptions>::create();\r\n\t\toptions->instance_ = instanceName;\r\n\t\toptions->interface_ = interfaceName;\r\n\t\toptions->comp_ = cpuComponentVLNV;\r\n\t\toptions->instanceId_ = cpuInstance->getInstanceUuid();\r\n\t\toptions->cpuContainer_ = singleCPU;\r\n\r\n\t\t// the path to the directory containing the xml metadata\r\n\t\tQString compPath(handler_->getDirectoryPath(topComponent->getVlnv()));\r\n\r\n\t\t// the relative path from the xml dir to the header to generate\r\n\t\tQString headerPath = QString(\"%1/%2/%3.h\").arg(tr(\"headers\"), instanceName, interfaceName);\r\n\r\n\t\t// the absolute path to the header file\r\n\t\tconst QString fullPath = QString(\"%1/%2\").arg(compPath, headerPath);\r\n\r\n\t\t// create the file info instance\r\n\t\toptions->fileInfo_ = QFileInfo(fullPath);\r\n\r\n\t\ttable_.append(options);\r\n\t}\r\n\r\n\tendResetModel();\r\n}\r\n"
  },
  {
    "path": "Plugins/MemoryMapHeaderGenerator/globalheadersavemodel.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: globalheadersavemodel.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Antti Kamppi\r\n// Date: 25.02.2013\r\n//\r\n// Description:\r\n// The model class to display the header files to be created for CPU instances within a design.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef GLOBALHEADERSAVEMODEL_H\r\n#define GLOBALHEADERSAVEMODEL_H\r\n\r\n#include <IPXACTmodels/common/VLNV.h>\r\n#include <IPXACTmodels/Component/Component.h>\r\n\r\n#include <IPXACTmodels/Design/Design.h>\r\n\r\n#include <QAbstractTableModel>\r\n#include <QString>\r\n#include <QList>\r\n#include <QFileInfo>\r\n\r\nclass LibraryInterface;\r\nclass SingleCpuRoutesContainer;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! The model class to display the header files to be created for CPU instances within a design.\r\n//-----------------------------------------------------------------------------\r\nclass GlobalHeaderSaveModel : public QAbstractTableModel\r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\r\n\t//! Contains the options to identify the local memory map and its save file path.\r\n\tstruct SaveFileOptions\r\n    {\r\n\t\t//! The VLNV identifier of the component.\r\n\t\tVLNV comp_;\r\n\r\n\t\t//! The name of the instance containing the interface.\r\n\t\tQString instance_;\r\n\r\n\t\t//! The id used to identify the instance through hierarchy levels.\r\n\t\tQString instanceId_;\r\n\r\n\t\t//! The name of the master interface to create the header for.\r\n\t\tQString interface_;\r\n\r\n\t\t//! Contains the path for the header file to be saved.\r\n\t\tQFileInfo fileInfo_;\r\n\r\n\t\t//! Container for routes from a single CPU interface.\r\n\t\tQSharedPointer<SingleCpuRoutesContainer> cpuContainer_;\r\n\t};\r\n\r\n\t//! The column numbers for the table.\r\n\tenum Columns\r\n    {\r\n\t\tINSTANCE_NAME = 0,\r\n\t\tINTERFACE_NAME,\r\n\t\tFILE_NAME,\r\n\t\tFILE_PATH,\r\n\t\tCOLUMN_COUNT\r\n\t};\r\n\r\n\t/*!\r\n     *  The constructor\r\n\t *\r\n\t *    @param [in] handler     Pointer to the instance that manages the library.\r\n\t *    @param [in] parent      Pointer to the owner of the model.\r\n\t */\r\n\tGlobalHeaderSaveModel(LibraryInterface* handler, QObject *parent);\r\n\t\r\n\t//! The destructor.\r\n\tvirtual ~GlobalHeaderSaveModel();\r\n\r\n\t/*!\r\n     *  Set the design for which the global headers are generated.\r\n\t *\r\n\t *    @param [in] topComp\t\tPointer to the component which contains the design.\r\n\t *    @param [in] cpuRoutes\t\tList of CPU interface routes.\r\n\t */\r\n\tvoid setCPUData(QSharedPointer<Component> topComponent,\r\n\t\tQVector<QSharedPointer<SingleCpuRoutesContainer> > const& cpuRoutes);\r\n\r\n\t/*!\r\n     *  Get the number of rows an item contains.\r\n\t *\r\n\t *    @param [in] parent  Identifies the parent that's row count is requested.\r\n\t *\r\n\t *    @return Number of rows the item has.\r\n\t */\r\n\tvirtual int rowCount(const QModelIndex& parent = QModelIndex()) const;\r\n\r\n\t/*!\r\n     *  Get the number of columns the item has to be displayed.\r\n\t *\r\n\t *    @param [in] parent  Identifies the parent that's column count is requested.\r\n\t *\r\n\t *    @return The number of columns to be displayed.\r\n\t */\r\n\tvirtual int columnCount(const QModelIndex& parent = QModelIndex()) const;\r\n\r\n\t/*!\r\n     *  Get the item flags that defines the possible operations for the item.\r\n\t *\r\n\t *    @param [in] index   Model index that identifies the item.\r\n\t *\r\n\t *    @return Qt::ItemFlags specify the possible operations for the item.\r\n\t */\r\n\tQt::ItemFlags flags(const QModelIndex& index) const;\r\n\r\n\t/*!\r\n     *  Get the header data for specified header.\r\n\t *\r\n\t *    @param [in] section         The section specifies the row/column number for the header.\r\n\t *    @param [in] orientation     Specified if horizontal or vertical header is wanted.\r\n\t *    @param [in] role            Specifies the type of the requested data.\r\n\t *\r\n\t *    @return QVariant Contains the requested data.\r\n\t */\r\n\tvirtual QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;\r\n\r\n\t/*!\r\n     *  Get the data for specified item.\r\n\t *\r\n\t *    @param [in] index   Specifies the item that's data is requested.\r\n\t *    @param [in] role    The role that defines what kind of data is requested.\r\n\t *\r\n\t *    @return QVariant Contains the data for the item.\r\n\t */\r\n\tvirtual QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const;\r\n\r\n\t/*!\r\n     *  Save the data to the model for specified item\r\n\t *\r\n\t *    @param [in] index   The model index of the item that's data is to be saved.\r\n\t *    @param [in] value   The data that is to be saved.\r\n\t *    @param [in] role    The role specifies what kind of data should be saved.\r\n\t *\r\n\t *    @return True if saving happened successfully.\r\n\t */\r\n\tbool setData(const QModelIndex& index, const QVariant& value, int role = Qt::EditRole);\r\n\r\n\t/*!\r\n     *  Get the options defining locations for headers to generate.\r\n\t *\r\n\t *    @return QList containing the save options.\r\n\t */\r\n\tconst QList<QSharedPointer<SaveFileOptions> >& getHeaderOptions() const;\r\n\r\nprivate:\r\n\t\r\n\t//! No copying.\r\n\tGlobalHeaderSaveModel(const GlobalHeaderSaveModel& other);\r\n\r\n\t//! No assignment.\r\n\tGlobalHeaderSaveModel& operator=(const GlobalHeaderSaveModel& other);\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n\t//! Pointer to the instance that manages the library.\r\n\tLibraryInterface* handler_;\r\n\r\n\t//! Contains the instance and interface names and the file paths.\r\n\tQList<QSharedPointer<SaveFileOptions> > table_;\r\n\r\n\t//! Pointer to the top component.\r\n\tQSharedPointer<Component> comp_;\r\n};\r\n\r\n#endif // GLOBALHEADERSAVEMODEL_H\r\n"
  },
  {
    "path": "Plugins/MemoryMapHeaderGenerator/headerGenerator.json",
    "content": "{\r\n\t\"Keys\": [ \"Memory map header generator\" ]\r\n}"
  },
  {
    "path": "Plugins/MemoryMapHeaderGenerator/localheadersavedelegate.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: localheadersavedelegate.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Antti Kamppi\r\n// Date: 09.04.2013\r\n//\r\n// Description:\r\n// The delegate class to select the local headers to be generated.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"localheadersavedelegate.h\"\r\n#include \"localheadersavemodel.h\"\r\n#include <common/widgets/viewSelector/viewselector.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: localheadersavedelegate::LocalHeaderSaveDelegate()\r\n//-----------------------------------------------------------------------------\r\nLocalHeaderSaveDelegate::LocalHeaderSaveDelegate(QSharedPointer<Component> component,\r\n\tQObject *parent):\r\nQStyledItemDelegate(parent),\r\ncomponent_(component)\r\n{\r\n\tQ_ASSERT(component_);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: localheadersavedelegate::~LocalHeaderSaveDelegate()\r\n//-----------------------------------------------------------------------------\r\nLocalHeaderSaveDelegate::~LocalHeaderSaveDelegate()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: localheadersavedelegate::createEditor()\r\n//-----------------------------------------------------------------------------\r\nQWidget* LocalHeaderSaveDelegate::createEditor( QWidget* parent, const QStyleOptionViewItem& option,\r\n                                                const QModelIndex& index ) const\r\n{\r\n    if (index.column() == LocalHeaderSaveModel::SW_VIEW_NAME)\r\n    {\r\n        ViewSelector* viewSelector = new ViewSelector(ViewSelector::BOTH_HW_VIEWS, component_, parent, false);\r\n        viewSelector->refresh();\r\n        viewSelector->addItem(tr(\"all\"));\r\n        viewSelector->setEditable(true);\r\n        return viewSelector;\r\n    }\r\n    else\r\n    {\r\n        return QStyledItemDelegate::createEditor(parent, option, index);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: localheadersavedelegate::setEditorData()\r\n//-----------------------------------------------------------------------------\r\nvoid LocalHeaderSaveDelegate::setEditorData( QWidget* editor, const QModelIndex& index ) const\r\n{\r\n    if (index.column() == LocalHeaderSaveModel::SW_VIEW_NAME)\r\n    {\r\n\t\tViewSelector* viewSelector = qobject_cast<ViewSelector*>(editor);\r\n\t\tQ_ASSERT(viewSelector);\r\n\r\n\t\t// fetch the view name from the model and set it as selected\r\n\t\tQString viewName = index.model()->data(index, Qt::DisplayRole).toString();\r\n\t\tviewSelector->selectView(viewName);\r\n    }\r\n    else\r\n    {\r\n        QStyledItemDelegate::setEditorData(editor, index);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: localheadersavedelegate::setModelData()\r\n//-----------------------------------------------------------------------------\r\nvoid LocalHeaderSaveDelegate::setModelData( QWidget* editor, QAbstractItemModel* model, const QModelIndex& index )\r\n    const\r\n{\r\n    if (index.column() == LocalHeaderSaveModel::SW_VIEW_NAME)\r\n    {\r\n\t\tViewSelector* viewSelector = qobject_cast<ViewSelector*>(editor);\r\n\t\tQ_ASSERT(viewSelector);\r\n\r\n\t\tQString selectedView = viewSelector->currentText();\r\n\t\tmodel->setData(index, selectedView, Qt::EditRole);\r\n    }\r\n    else\r\n    {\r\n        QStyledItemDelegate::setModelData(editor, model, index);\r\n    }\r\n}\r\n"
  },
  {
    "path": "Plugins/MemoryMapHeaderGenerator/localheadersavedelegate.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: localheadersavedelegate.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Antti Kamppi\r\n// Date: 09.04.2013\r\n//\r\n// Description:\r\n// The delegate class to select the local headers to be generated.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef LOCALHEADERSAVEDELEGATE_H\r\n#define LOCALHEADERSAVEDELEGATE_H\r\n\r\n#include <IPXACTmodels/Component/Component.h>\r\n\r\n#include <QStyledItemDelegate>\r\n#include <QSharedPointer>\r\n\r\n//-----------------------------------------------------------------------------\r\n//! The delegate class to select the local headers to be generated.\r\n//-----------------------------------------------------------------------------\r\nclass LocalHeaderSaveDelegate : public QStyledItemDelegate\r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\r\n\t/*!\r\n     *  The constructor.\r\n\t *\r\n\t *    @param [in] component   Pointer to the component to generate the headers for.\r\n\t *    @param [in] parent      Pointer to the owner of the delegate.\r\n\t */\r\n\tLocalHeaderSaveDelegate(QSharedPointer<Component> component, QObject *parent);\r\n\t\r\n\t//! The destructor.\r\n\tvirtual ~LocalHeaderSaveDelegate();\r\n\r\n\t/*!\r\n     *  Create a new editor for the given item.\r\n\t *\r\n\t *    @param [in] parent  Owner for the editor.\r\n\t *    @param [in] option  Contains options for the editor.\r\n\t *    @param [in] index   Model index identifying the item.\r\n\t *\r\n\t *    @return Pointer to the editor to be used to edit the item.\r\n\t */\r\n\tvirtual QWidget* createEditor(QWidget* parent, const QStyleOptionViewItem& option, const QModelIndex& index)\r\n        const;\r\n\r\n\t/*!\r\n     *  Set the data for the editor.\r\n\t *\r\n\t *    @param [in] editor  Pointer to the editor where the data is to be set.\r\n\t *    @param [in] index   Model index identifying the item that's data is to be set.\r\n\t */\r\n\tvirtual void setEditorData(QWidget* editor, const QModelIndex& index) const;\r\n\r\n\t/*!\r\n     *  Save the data from the editor to the model.\r\n\t *\r\n\t *    @param [in] editor  Pointer to the editor that contains the data to store.\r\n\t *    @param [in] model   Model that contains the data structure where data is to be saved to.\r\n\t *    @param [in] index   Model index identifying the item that's data is to be saved.\r\n\t */\r\n\tvirtual void setModelData(QWidget* editor, QAbstractItemModel* model, const QModelIndex& index) const;\r\n\r\nprivate:\r\n\t\r\n\t//! No copying.\r\n\tLocalHeaderSaveDelegate(const LocalHeaderSaveDelegate& other);\r\n\r\n\t//! No assignment.\r\n\tLocalHeaderSaveDelegate& operator=(const LocalHeaderSaveDelegate& other);\r\n\r\n\t//! Pointer to the component the headers are generated for.\r\n\tQSharedPointer<Component> component_;\r\n};\r\n\r\n#endif // LOCALHEADERSAVEDELEGATE_H\r\n"
  },
  {
    "path": "Plugins/MemoryMapHeaderGenerator/localheadersavemodel.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: localheadersavemodel.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Antti Kamppi\r\n// Date: 20.02.2013\r\n//\r\n// Description:\r\n// The model class to display the header files to be created from component's local memory maps.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"localheadersavemodel.h\"\r\n#include <KactusAPI/include/LibraryInterface.h>\r\n#include <IPXACTmodels/Component/AddressSpace.h>\r\n#include <IPXACTmodels/Component/MemoryMap.h>\r\n\r\n#include <QDir>\r\n#include <QStringList>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: localheadersavemodel::LocalHeaderSaveModel()\r\n//-----------------------------------------------------------------------------\r\nLocalHeaderSaveModel::LocalHeaderSaveModel(LibraryInterface* handler, QObject *parent ):\r\nQAbstractTableModel(parent),\r\ncomponent_(),\r\nhandler_(handler),\r\ntable_()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: localheadersavemodel::~LocalHeaderSaveModel()\r\n//-----------------------------------------------------------------------------\r\nLocalHeaderSaveModel::~LocalHeaderSaveModel()\r\n{\r\n\tqDeleteAll(table_);\r\n\ttable_.clear();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: localheadersavemodel::setComponent()\r\n//-----------------------------------------------------------------------------\r\nvoid LocalHeaderSaveModel::setComponent(QSharedPointer<Component> component)\r\n{\r\n\tbeginResetModel();\r\n\tcomponent_ = component;\r\n\r\n\tqDeleteAll(table_);\r\n\ttable_.clear();\r\n\r\n\tQString defSWView;\r\n\tQStringList swViewNames = component->getViewNames();\r\n\t\r\n\t// if there are no sw views then use default name to create one\r\n\tif (swViewNames.isEmpty())\r\n    {\r\n\t\tdefSWView = \"swView\";\r\n\t}\r\n\t// if there is at least one sw view then use it.\r\n\telse\r\n    {\r\n\t\tdefSWView = swViewNames.first();\r\n\t}\r\n\r\n\tforeach (QSharedPointer<AddressSpace> addrSpace, *component_->getAddressSpaces())\r\n    {\r\n        QSharedPointer<MemoryMapBase> localMemoryMap = addrSpace->getLocalMemoryMap();\r\n\r\n\t\t// if the address space contains a local memory map and contains at least one item\r\n        if (localMemoryMap && localMemoryMap->hasMemoryBlocks())\r\n        {\r\n\t\t\tLocalHeaderSaveModel::SaveFileOptions* options = new SaveFileOptions();\r\n            options->localMemMap_ = localMemoryMap;\r\n\r\n\t\t\t// the path to the directory containing the xml metadata\r\n\t\t\tQString compPath(handler_->getDirectoryPath(component_->getVlnv()));\r\n\r\n\t\t\t// the relative path from the xml dir to the header to generate\r\n            QString headerPath = QString(\"%1/%2.h\").arg(tr(\"headers\")).arg(localMemoryMap->name());\r\n\r\n\t\t\t// the absolute path to the header file\r\n\t\t\tconst QString fullPath = QString(\"%1/%2\").arg(compPath).arg(headerPath);\r\n\r\n\t\t\t// create the file info instance\r\n\t\t\toptions->fileInfo_ = QFileInfo(fullPath);\r\n\r\n\t\t\toptions->swView_ = defSWView;\r\n\r\n\t\t\t// append the options to the table\r\n\t\t\ttable_.append(options);\r\n\t\t}\r\n\t}\r\n\r\n\tendResetModel();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: localheadersavemodel::rowCount()\r\n//-----------------------------------------------------------------------------\r\nint LocalHeaderSaveModel::rowCount(QModelIndex const& parent) const\r\n{\r\n\tif (parent.isValid())\r\n    {\r\n\t\treturn 0;\r\n\t}\r\n\r\n\treturn table_.size();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: localheadersavemodel::columnCount()\r\n//-----------------------------------------------------------------------------\r\nint LocalHeaderSaveModel::columnCount(QModelIndex const& parent) const\r\n{\r\n\tif (parent.isValid())\r\n    {\r\n\t\treturn 0;\r\n\t}\r\n\r\n\treturn LocalHeaderSaveModel::COLUMN_COUNT;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: localheadersavemodel::flags()\r\n//-----------------------------------------------------------------------------\r\nQt::ItemFlags LocalHeaderSaveModel::flags(QModelIndex const& index) const\r\n{\r\n\tif (!index.isValid())\r\n    {\r\n\t\treturn Qt::NoItemFlags;\r\n\t}\r\n\r\n\tQt::ItemFlags flags = Qt::ItemIsEnabled | Qt::ItemIsSelectable;\r\n\r\n\tif (index.column() == LocalHeaderSaveModel::SW_VIEW_NAME)\r\n    {\r\n\t\tflags |= Qt::ItemIsEditable;\r\n\t}\r\n\r\n\treturn flags;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: localheadersavemodel::headerData()\r\n//-----------------------------------------------------------------------------\r\nQVariant LocalHeaderSaveModel::headerData(int section, Qt::Orientation orientation, int role) const\r\n{\r\n\tif (orientation != Qt::Horizontal)\r\n    {\r\n\t\treturn QVariant();\r\n\t}\r\n\tif (Qt::DisplayRole == role)\r\n    {\r\n        if (section == LocalHeaderSaveModel::SW_VIEW_NAME)\r\n        {\r\n            return tr(\"SW View\");\r\n        }\r\n        else if (section == LocalHeaderSaveModel::MEM_MAP_NAME)\r\n        {\r\n            return tr(\"Local memory\\nmap name\");\r\n        }\r\n        else if (section == LocalHeaderSaveModel::FILE_NAME)\r\n        {\r\n            return tr(\"File name\");\r\n        }\r\n        else if (section == LocalHeaderSaveModel::FILE_PATH)\r\n        {\r\n            return tr(\"File path\");\r\n        }\r\n\t}\r\n\r\n    return QVariant();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: localheadersavemodel::data()\r\n//-----------------------------------------------------------------------------\r\nQVariant LocalHeaderSaveModel::data(QModelIndex const& index, int role) const\r\n{\r\n\tif (!index.isValid() || index.row() < 0 || index.row() >= table_.size())\r\n    {\r\n\t\treturn QVariant();\r\n\t}\r\n\r\n\tif (Qt::DisplayRole == role)\r\n    {\r\n        if (index.column() == LocalHeaderSaveModel::SW_VIEW_NAME)\r\n        {\r\n            return table_.at(index.row())->swView_;\r\n        }\r\n        else if (index.column() == LocalHeaderSaveModel::MEM_MAP_NAME)\r\n        {\r\n            return table_.at(index.row())->localMemMap_->name();\r\n        }\r\n        else if (index.column() == LocalHeaderSaveModel::FILE_NAME)\r\n        {\r\n            return table_.at(index.row())->fileInfo_.fileName();\r\n        }\r\n        else if (index.column() == LocalHeaderSaveModel::FILE_PATH)\r\n        {\r\n            // display the relative path from xml directory to the header to be generated\r\n            QDir xmlDir(handler_->getDirectoryPath(component_->getVlnv()));\r\n            QString headerPath = table_.at(index.row())->fileInfo_.absoluteFilePath();\r\n            QString relPath = xmlDir.relativeFilePath(headerPath);\r\n            return relPath;\r\n        }\r\n        else\r\n        {\r\n            return QVariant();\r\n        }\r\n\t}\r\n\t// user role always returns the absolute file path\r\n\telse if (Qt::UserRole == role)\r\n    {\r\n\t\t// if the header dir exists\r\n\t\tQFileInfo headerInfo(table_.at(index.row())->fileInfo_.absolutePath());\r\n\t\tif (headerInfo.exists())\r\n        {\r\n\t\t\t// return path to the directory for headers\r\n\t\t\treturn headerInfo.absoluteFilePath();\r\n\t\t}\r\n\t\t// if not then at least the xml directory exists\r\n\t\telse\r\n        {\r\n\t\t\treturn handler_->getDirectoryPath(component_->getVlnv());\r\n\t\t}\t\t\r\n\t}\r\n\telse\r\n    {\r\n\t\treturn QVariant();\r\n\t}\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: localheadersavemodel::setData()\r\n//-----------------------------------------------------------------------------\r\nbool LocalHeaderSaveModel::setData(QModelIndex const& index, QVariant const& value, int role)\r\n{\r\n\tif (!index.isValid()|| index.row() < 0 || index.row() >= table_.size())\r\n    {\r\n\t\treturn false;\r\n\t}\r\n\r\n\tif (role == Qt::EditRole)\r\n    {\r\n        if (index.column() == LocalHeaderSaveModel::SW_VIEW_NAME)\r\n        {\r\n            table_[index.row()]->swView_ = value.toString();\r\n        }\r\n        else if (index.column() == LocalHeaderSaveModel::MEM_MAP_NAME)\r\n        {\r\n            // memory map name can not be modified\r\n            return false;\r\n        }\r\n        else if (index.column() == LocalHeaderSaveModel::FILE_NAME)\r\n        {\r\n            table_[index.row()]->fileInfo_.setFile(value.toString());\r\n\r\n            // both indexes change\r\n            QModelIndex pathIndex = QAbstractTableModel::index(index.row(), LocalHeaderSaveModel::FILE_PATH);\r\n            emit dataChanged(index, pathIndex);\r\n            return true;\r\n        }\r\n        else if (index.column() == LocalHeaderSaveModel::FILE_PATH)\r\n        {\r\n            table_[index.row()]->fileInfo_.setFile(value.toString());\r\n\r\n            // both columns change\r\n            QModelIndex nameIndex = QAbstractTableModel::index(index.row(), LocalHeaderSaveModel::FILE_NAME);\r\n            emit dataChanged(nameIndex, index);\r\n            return true;\r\n        }\r\n        else\r\n        {\r\n            return false;\r\n        }\r\n\r\n        emit dataChanged(index, index);\r\n        return true;\r\n    }\r\n\telse if (role == Qt::UserRole)\r\n    {\r\n\t\ttable_[index.row()]->fileInfo_.setFile(value.toString());\r\n\r\n\t\t// the change affects to both columns\r\n\t\tQModelIndex leftIndex = QAbstractTableModel::index(index.row(), LocalHeaderSaveModel::FILE_NAME);\r\n\t\tQModelIndex rightIndex = QAbstractTableModel::index(index.row(), LocalHeaderSaveModel::FILE_PATH);\r\n\r\n\t\t// inform of changes\r\n\t\temit dataChanged(leftIndex, rightIndex);\r\n\t\treturn true;\r\n\t}\r\n\telse\r\n    {\r\n\t\treturn false;\r\n\t}\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: localheadersavemodel::getHeaderOptions()\r\n//-----------------------------------------------------------------------------\r\nconst QList<LocalHeaderSaveModel::SaveFileOptions*>& LocalHeaderSaveModel::getHeaderOptions() const\r\n{\r\n\treturn table_;\r\n}\r\n"
  },
  {
    "path": "Plugins/MemoryMapHeaderGenerator/localheadersavemodel.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: localheadersavemodel.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Antti Kamppi\r\n// Date: 20.02.2013\r\n//\r\n// Description:\r\n// The model class to display the header files to be created from component's local memory maps.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef LOCALHEADERSAVEMODEL_H\r\n#define LOCALHEADERSAVEMODEL_H\r\n\r\n#include <IPXACTmodels/Component/Component.h>\r\n\r\n#include <QSharedPointer>\r\n#include <QAbstractTableModel>\r\n#include <QFileInfo>\r\n#include <QList>\r\n\r\nclass LibraryInterface;\r\nclass MemoryMapBase;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! The model class to display the header files to be created from component's local memory maps.\r\n//-----------------------------------------------------------------------------\r\nclass LocalHeaderSaveModel : public QAbstractTableModel\r\n{\r\n    Q_OBJECT\r\n\r\npublic:\r\n\r\n\t//! Contains the options to identify the local memory map and its save file path.\r\n\tstruct SaveFileOptions\r\n    {\r\n\t\t//! Pointer to the local memory map.\r\n        QSharedPointer<MemoryMapBase> localMemMap_;\r\n\r\n\t\t//! Contains the path for the header file to be saved.\r\n\t\tQFileInfo fileInfo_;\r\n\r\n\t\t//! The name of the sw view to create the header for.\r\n\t\tQString swView_;\r\n\t};\r\n\r\n\t//! The column numbers for the table.\r\n\tenum Columns\r\n    {\r\n\t\tSW_VIEW_NAME = 0,\r\n\t\tMEM_MAP_NAME,\r\n\t\tFILE_NAME,\r\n\t\tFILE_PATH,\r\n\t\tCOLUMN_COUNT\r\n\t};\r\n\r\n\t/*!\r\n     *  The constructor.\r\n\t *\r\n\t *    @param [in] handler     Pointer to the instance that manages the library.\r\n\t *    @param [in] parent      Pointer to the owner of the model.\r\n\t */\r\n\tLocalHeaderSaveModel(LibraryInterface* handler, QObject *parent);\r\n\t\r\n\t//! The destructor.\r\n\tvirtual ~LocalHeaderSaveModel();\r\n\r\n\t/*!\r\n     *  Set the component in which the local memory maps are displayed.\r\n\t *\r\n\t *    @param [in] component   The pointer to the component to create the local memory maps for.\r\n\t */\r\n\tvoid setComponent(QSharedPointer<Component> component);\r\n\r\n\t/*!\r\n     *  Get the number of rows an item contains.\r\n\t *\r\n\t *    @param [in] parent  Identifies the parent that's row count is requested.\r\n\t *\r\n\t *    @return Number of rows the item has.\r\n\t */\r\n\tvirtual int rowCount(const QModelIndex& parent = QModelIndex()) const;\r\n\r\n\t/*!\r\n     *  Get the number of columns the item has to be displayed.\r\n\t *\r\n\t *    @param [in] parent  Identifies the parent that's column count is requested.\r\n\t *\r\n\t *    @return The number of columns to be displayed.\r\n\t */\r\n\tvirtual int columnCount(const QModelIndex& parent = QModelIndex()) const;\r\n\r\n\t/*!\r\n     *  Get the item flags that defines the possible operations for the item.\r\n\t *\r\n\t *    @param [in] index   Model index that identifies the item.\r\n\t *\r\n\t *    @return Qt::ItemFlags specify the possible operations for the item.\r\n\t */\r\n\tQt::ItemFlags flags(const QModelIndex& index) const;\r\n\r\n\t/*!\r\n     *  Get the header data for specified header.\r\n\t *\r\n\t *    @param [in] section         The section specifies the row/column number for the header.\r\n\t *    @param [in] orientation     Specified if horizontal or vertical header is wanted.\r\n\t *    @param [in] role            Specifies the type of the requested data.\r\n\t *\r\n\t *    @return QVariant Contains the requested data.\r\n\t */\r\n\tvirtual QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;\r\n\r\n\t/*!\r\n     *  Get the data for specified item.\r\n\t *\r\n\t *    @param [in] index   Specifies the item that's data is requested.\r\n\t *    @param [in] role    The role that defines what kind of data is requested.\r\n\t *\r\n\t *    @return QVariant Contains the data for the item.\r\n\t */\r\n\tvirtual QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const;\r\n\r\n\t/*!\r\n     *  Save the data to the model for specified item\r\n\t *\r\n\t *    @param [in] index   The model index of the item that's data is to be saved.\r\n\t *    @param [in] value   The data that is to be saved.\r\n\t *    @param [in] role    The role specifies what kind of data should be saved.\r\n\t *\r\n\t *    @return True if saving happened successfully.\r\n\t */\r\n\tbool setData(const QModelIndex& index, const QVariant& value, int role = Qt::EditRole);\r\n\r\n\t/*!\r\n     *  Get the options defining locations for headers to generate.\r\n\t *\r\n\t *    @return QList containing the save options.\r\n\t */\r\n\tconst QList<SaveFileOptions*>& getHeaderOptions() const;\r\n\r\nprivate:\r\n\t\r\n\t//! No copying.\r\n\tLocalHeaderSaveModel(const LocalHeaderSaveModel& other);\r\n\r\n\t//! No assignment.\r\n\tLocalHeaderSaveModel& operator=(const LocalHeaderSaveModel& other);\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n\t//! Pointer to the component which contains the local memory maps.\r\n\tQSharedPointer<Component> component_;\r\n\r\n\t//! Pointer to the instance that manages the library.\r\n\tLibraryInterface* handler_;\r\n\r\n\t//! Contains the local memory maps and paths to save the headers.\r\n\tQList<SaveFileOptions*> table_;\r\n};\r\n\r\n#endif // LOCALHEADERSAVEMODEL_H\r\n"
  },
  {
    "path": "Plugins/MemoryMapHeaderGenerator/memorymapheadergenerator.cpp",
    "content": "/* \r\n *\tCreated on: 15.2.2013\r\n *\tAuthor:\t\tAntti Kamppi\r\n * \tFile name:\tmemorymapheadergenerator.cpp\r\n * \tProject:\tKactus 2\r\n*/\r\n\r\n#include \"memorymapheadergenerator.h\"\r\n\r\n#include <KactusAPI/include/IPluginUtility.h>\r\n\r\n#include <Plugins/MemoryMapHeaderGenerator/LocalMemoryMapHeaderWriter.h>\r\n#include <Plugins/MemoryMapHeaderGenerator/GlobalMemoryMapHeaderWriter.h>\r\n#include <Plugins/MemoryMapHeaderGenerator/SystemMemoryMapHeaderWriter.h>\r\n\r\n#include <QtPlugin>\r\n#include <QCoreApplication>\r\n#include <QMessageBox>\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryMapHeaderGenerator::MemoryMapHeaderGenerator()\r\n//-----------------------------------------------------------------------------\r\nMemoryMapHeaderGenerator::MemoryMapHeaderGenerator():\r\nutility_(NULL),\r\ndesign_(),\r\nlocalSaveOptions_(),\r\nglobalSaveOptions_()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryMapHeaderGenerator::~MemoryMapHeaderGenerator()\r\n//-----------------------------------------------------------------------------\r\nMemoryMapHeaderGenerator::~MemoryMapHeaderGenerator()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryMapHeaderGenerator::getName()\r\n//-----------------------------------------------------------------------------\r\nQString MemoryMapHeaderGenerator::getName() const\r\n{\r\n\treturn tr(\"Memory Map Header Generator\");\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryMapHeaderGenerator::getVersion()\r\n//-----------------------------------------------------------------------------\r\nQString MemoryMapHeaderGenerator::getVersion() const\r\n{\r\n\treturn tr(\"1.1\");\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryMapHeaderGenerator::getDescription()\r\n//-----------------------------------------------------------------------------\r\nQString MemoryMapHeaderGenerator::getDescription() const\r\n{\r\n\treturn tr(\"Generates C-headers for memory maps of a component\");\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryMapHeaderGenerator::getVendor()\r\n//-----------------------------------------------------------------------------\r\nQString MemoryMapHeaderGenerator::getVendor() const\r\n{\r\n    return tr(\"Tampere University (tuni.fi)\");\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryMapHeaderGenerator::getLicense()\r\n//-----------------------------------------------------------------------------\r\nQString MemoryMapHeaderGenerator::getLicense() const\r\n{\r\n    return tr(\"GPL2\");\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryMapHeaderGenerator::getLicenseHolder()\r\n//-----------------------------------------------------------------------------\r\nQString MemoryMapHeaderGenerator::getLicenseHolder() const\r\n{\r\n    return tr(\"Public\");\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryMapHeaderGenerator::getSettingsWidget()\r\n//-----------------------------------------------------------------------------\r\nQWidget* MemoryMapHeaderGenerator::getSettingsWidget()\r\n{\r\n    return nullptr;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryMapHeaderGenerator::getIcon()\r\n//-----------------------------------------------------------------------------\r\nQIcon MemoryMapHeaderGenerator::getIcon() const\r\n{\r\n    return QIcon(\":icons/headerGenerator24.png\");\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryMapHeaderGenerator::checkGeneratorSupport()\r\n//-----------------------------------------------------------------------------\r\nbool MemoryMapHeaderGenerator::checkGeneratorSupport(QSharedPointer<Component const> component,\r\n    QSharedPointer<Design const> /*design*/,\r\n    QSharedPointer<DesignConfiguration const> designConfiguration) const\r\n{\r\n\t// if there is no design then header is generated for local memory maps\r\n\tif (!designConfiguration)\r\n    {\r\n\t\treturn component->hasLocalMemoryMaps();\r\n\t}\r\n\r\n\t// the design configuration must be for HW or system\r\n\treturn designConfiguration->getImplementation() == KactusAttribute::HW;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryMapHeaderGenerator::runGenerator()\r\n//-----------------------------------------------------------------------------\r\nvoid MemoryMapHeaderGenerator::runGenerator(IPluginUtility* utility, \r\n    QSharedPointer<Component> component,\r\n    QSharedPointer<Design> design,\r\n    QSharedPointer<DesignConfiguration> designConfiguration)\r\n{\r\n\tutility_ = utility;\r\n\r\n    utility_->printInfo(tr(\"Running %1 %2.\").arg(getName(), getVersion()));\r\n\r\n\tQ_ASSERT(component);\r\n\r\n\t// if there is no design object then create headers for local memory maps\r\n\tif (!design)\r\n    {\r\n        LocalMemoryMapHeaderWriter localWriter(utility_, component, this);\r\n        localWriter.writeMemoryMapHeader(localSaveOptions_);\r\n\t}\r\n\t// if there is a design configuration\r\n\telse if (designConfiguration)\r\n    {\r\n\t\tQ_ASSERT(design);\r\n\r\n\t\t// the component knows the implementation of the view\r\n\t\tKactusAttribute::Implementation implementation = designConfiguration->getImplementation();\r\n\r\n\t\tQ_ASSERT(designConfiguration);\r\n\r\n\t\t// if the generator is run on a hierarchical HW component\r\n\t\tif (implementation == KactusAttribute::HW)\r\n        {\r\n            GlobalMemoryMapHeaderWriter globalWriter(utility_, design, designConfiguration, this);\r\n            globalWriter.writeMemoryMapHeader(component, globalSaveOptions_);\r\n\t\t}\r\n\r\n\t\t// the generator is run on a system component\r\n\t\telse\r\n        {\r\n            SystemMemoryMapHeaderWriter systemWriter(utility_, this);\r\n            systemWriter.writeMemoryMapHeader(component, designConfiguration, design);\r\n\t\t}\r\n\t}\r\n\r\n\t// if there is a design but no design configuration\r\n\telse\r\n    {\r\n\t\tQ_ASSERT(design);\r\n\r\n\t\tKactusAttribute::Implementation implementation = design->getImplementation();\r\n\r\n\t\t// if the generator is run on a hierarchical HW component\r\n\t\tif (implementation == KactusAttribute::HW)\r\n        {\r\n            GlobalMemoryMapHeaderWriter globalWriter(utility_, design, QSharedPointer<DesignConfiguration> (),\r\n                this);\r\n            globalWriter.writeMemoryMapHeader(component, globalSaveOptions_);\r\n\t\t}\r\n\r\n\t\t// the generator is run on a system component without the configuration\r\n\t\telse\r\n        {\r\n\t\t\tQMessageBox::warning(utility_->getParentWidget(), QCoreApplication::applicationName(),\r\n\t\t\t\ttr(\"A system design opened without configuration.\\n\"\r\n                \"System design must always have a configuration.\"));\r\n\t\t}\r\n\t}\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryMapHeaderGenerator::getProgramRequirements()\r\n//-----------------------------------------------------------------------------\r\nQList<IPlugin::ExternalProgramRequirement> MemoryMapHeaderGenerator::getProgramRequirements()\r\n{\r\n\treturn QList<IPlugin::ExternalProgramRequirement>();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: memorymapheadergenerator::setLocalSaveFileOptions()\r\n//-----------------------------------------------------------------------------\r\nvoid MemoryMapHeaderGenerator::setLocalSaveFileOptions(QSharedPointer<MemoryMap> localMemoryMap,\r\n    QFileInfo fileInfo, QString swViewName)\r\n{\r\n    LocalHeaderSaveModel::SaveFileOptions* newSaveOptions (new LocalHeaderSaveModel::SaveFileOptions);\r\n    newSaveOptions->localMemMap_ = localMemoryMap;\r\n    newSaveOptions->fileInfo_ = fileInfo;\r\n    newSaveOptions->swView_ = swViewName;\r\n\r\n    localSaveOptions_.clear();\r\n    localSaveOptions_.append(newSaveOptions);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: memorymapheadergenerator::setGlobalSaveFileOptions()\r\n//-----------------------------------------------------------------------------\r\nvoid MemoryMapHeaderGenerator::setGlobalSaveFileOptions(QSharedPointer<Component> component,\r\n    QString const& instanceName, QString const& instanceId, QString const& masterInterfaceName, QFileInfo fileInfo)\r\n{\r\n\tauto newSaveOptions = QSharedPointer<GlobalHeaderSaveModel::SaveFileOptions>::create();\r\n    newSaveOptions->comp_ = component->getVlnv();\r\n    newSaveOptions->instance_ = instanceName;\r\n    newSaveOptions->instanceId_ = instanceId;\r\n    newSaveOptions->interface_ = masterInterfaceName;\r\n    newSaveOptions->fileInfo_ = fileInfo;\r\n\r\n    globalSaveOptions_.clear();\r\n    globalSaveOptions_.append(newSaveOptions);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: memorymapheadergenerator::setSystemSaveFileOptions()\r\n//-----------------------------------------------------------------------------\r\nvoid MemoryMapHeaderGenerator::setSystemSaveFileOptions()\r\n{\r\n\r\n}\r\n"
  },
  {
    "path": "Plugins/MemoryMapHeaderGenerator/memorymapheadergenerator.h",
    "content": "/* \r\n *\tCreated on: 15.2.2013\r\n *\tAuthor:\t\tAntti Kamppi\r\n * \tFile name:\tmemorymapheadergenerator.h\r\n * \tProject:\tKactus 2\r\n*/\r\n\r\n#ifndef MEMORYMAPHEADERGENERATOR_H\r\n#define MEMORYMAPHEADERGENERATOR_H\r\n\r\n#include \"memorymapheadergenerator_global.h\"\r\n\r\n#include \"localheadersavemodel.h\"\r\n#include \"globalheadersavemodel.h\"\r\n#include \"systemheadersavemodel.h\"\r\n\r\n#include <KactusAPI/include/IGeneratorPlugin.h>\r\n\r\n#include <IPXACTmodels/Component/Component.h>\r\n\r\n#include <IPXACTmodels/Design/Design.h>\r\n\r\n#include <IPXACTmodels/DesignConfiguration/DesignConfiguration.h>\r\n\r\n#include <QObject>\r\n#include <QSharedPointer>\r\n\r\nclass IPluginUtility;\r\nclass ExpressionParser;\r\nclass ExpressionFormatter;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! The plugin to generate C-headers of component memory maps.\r\n//-----------------------------------------------------------------------------\r\nclass MEMORYMAPHEADERGENERATOR_EXPORT MemoryMapHeaderGenerator : public QObject, public IGeneratorPlugin {\r\n\r\n\tQ_OBJECT\r\n\tQ_PLUGIN_METADATA(IID \"kactus2.plugins.MemoryMapHeaderGenerator\" FILE \"headerGenerator.json\")\r\n\r\n\tQ_INTERFACES(IPlugin)\r\n\tQ_INTERFACES(IGeneratorPlugin)\r\n\r\npublic:\r\n\r\n    /*!\r\n\t *  The constructor.\r\n\t */\r\n\tMemoryMapHeaderGenerator();\r\n\t\r\n\t/*!\r\n\t *  The destructor.\r\n\t */\r\n\tvirtual ~MemoryMapHeaderGenerator();\r\n\r\n    /*!\r\n     *  Get the name of the plugin.\r\n     *\r\n     *    @return The name of the plugin.\r\n     */\r\n    virtual QString getName() const;\r\n\r\n    /*!\r\n     *  Get the version of the plugin.\r\n     *\r\n     *    @return The version of the plugin.\r\n     */\r\n    virtual QString getVersion() const;\r\n\r\n    /*!\r\n     *  Get the description of the plugin.\r\n     *\r\n     *    @return The description of the plugin.\r\n     */\r\n    virtual QString getDescription() const;\r\n\r\n    /*!\r\n     *  Get the vendor of the plugin.\r\n     *\r\n     *    @return The vendor of the plugin.\r\n     */\r\n    virtual QString getVendor() const;\r\n\r\n    /*!\r\n     *  Get the license of the plugin.\r\n     *\r\n     *    @return The license of the plugin.\r\n     */\r\n    virtual QString getLicense() const;\r\n\r\n    /*!\r\n     *  Get the holder of the license of the plugin.\r\n     *\r\n     *    @return The holder of the license of the plugin.\r\n     */\r\n    virtual QString getLicenseHolder() const;\r\n\r\n    /*!\r\n     *  Get the settings widget for the plugin.\r\n     *\r\n     *    @return The plugin settings widget.\r\n     */\r\n    virtual QWidget* getSettingsWidget();\r\n\r\n    /*!\r\n     *  This is used to access the settings modified by function getSettingsWidget().\r\n     */\r\n    virtual PluginSettingsModel* getSettingsModel(){return NULL;}\r\n\r\n    /*!\r\n     *  Get the icon for the generator.\r\n     *\r\n     *    @return The icon for the generator.\r\n     */\r\n    virtual QIcon getIcon() const;\r\n\r\n\t /*!\r\n     *  Checks whether the generator may run for the given component or design. \r\n     *\r\n     *    @param [in] component\t        The component for which to check support. If design is not null, component\r\n\t *                                      will refer to design or designConfiguration.\r\n     *    @param [in] design\t            The design, if the generator is ran for a design.\r\n     *    @param [in] designConfiguration The design configuration for design, if it is not null.\r\n     *\r\n     *    @return True, if the generator may run the given component. Otherwise false.\r\n     */\r\n    virtual bool checkGeneratorSupport(QSharedPointer<Component const> component,\r\n        QSharedPointer<Design const> design,\r\n        QSharedPointer<DesignConfiguration const> designConfiguration) const;\r\n\r\n\t /*!\r\n     *  Runs the generation, creating new files and/or modifying the IP-XACT metadata. The function has\r\n\t *  also access to the parent window widget, so that it can show dialogs for the user to aid the generation.\r\n     *\r\n     *    @param [in] utility\t\t\t    The plugin utility interface.\r\n     *    @param [in] component\t        The component for which to check support. If design is not null, component\r\n     *                                      will refer to design or designConfiguration.\r\n     *    @param [in] design\t            The design, if the generator is ran for a design.\r\n     *    @param [in] designConfiguration The design configuration for design, if it is not null.\r\n     */\r\n    virtual void runGenerator(IPluginUtility* utility, \r\n        QSharedPointer<Component> component,\r\n        QSharedPointer<Design> design,\r\n        QSharedPointer<DesignConfiguration> designConfiguration);\r\n\r\n\t /*!\r\n\t  *  Get the external program requirements of the plugin.\r\n\t  *\r\n      *    @return A list of external program requirements.\r\n\t  */\r\n\t virtual QList<IPlugin::ExternalProgramRequirement> getProgramRequirements();\r\n\r\n     /*!\r\n      *  Set the save options for a local writer.\r\n      *\r\n      *    @param [in] localMemoryMap     The local memory map of an address space.\r\n      *    @param [in] fileInfo           The file information for the header file.\r\n      *    @param [in] swViewName         The name of the sw view.\r\n      */\r\n     void setLocalSaveFileOptions(QSharedPointer<MemoryMap> localMemoryMap, QFileInfo fileInfo, QString swViewName);\r\n\r\n     /*!\r\n      *  Set the save options for a global writer.\r\n      *\r\n      *    @param [in] component              The top component of the design.\r\n      *    @param [in] instanceName           The name of the instance containing the interface.\r\n      *    @param [in] instanceId             The id of the instance.\r\n      *    @param [in] masterInterfaceName    The name of the master interface to create the header for.\r\n      *    @param [in] fileInfo               The file information for the header file.\r\n      */\r\n     void setGlobalSaveFileOptions(QSharedPointer<Component> component, QString const& instanceName,\r\n         QString const& instanceId, QString const& masterInterfaceName, QFileInfo fileInfo);\r\n\r\n     /*!\r\n      *  Set the save options for a system design writer.\r\n      */\r\n     void setSystemSaveFileOptions();\r\n\r\nprivate:\r\n\r\n\t//! No copying\r\n\tMemoryMapHeaderGenerator(const MemoryMapHeaderGenerator& other);\r\n\r\n\t//! No assignment\r\n\tMemoryMapHeaderGenerator& operator=(const MemoryMapHeaderGenerator& other);\r\n\r\n\t//! The plugin utility.\r\n\tIPluginUtility* utility_;\r\n\r\n\t//! Pointer to the design being operated when creating global headers.\r\n\tQSharedPointer<Design> design_;\r\n\r\n    //! Save file options for a local header writer.\r\n    QList<LocalHeaderSaveModel::SaveFileOptions*> localSaveOptions_;\r\n\r\n    //! Save file options for a global header writer\r\n    QList<QSharedPointer<GlobalHeaderSaveModel::SaveFileOptions> > globalSaveOptions_;\r\n\r\n};\r\n\r\n#endif // MEMORYMAPHEADERGENERATOR_H\r\n"
  },
  {
    "path": "Plugins/MemoryMapHeaderGenerator/memorymapheadergenerator.qrc",
    "content": "<RCC>\n    <qresource prefix=\"/icons\">\n        <file>headerGenerator24.png</file>\n    </qresource>\n</RCC>\n"
  },
  {
    "path": "Plugins/MemoryMapHeaderGenerator/memorymapheadergenerator_global.h",
    "content": "/* \r\n *\tCreated on: 15.2.2013\r\n *\tAuthor:\t\tAntti Kamppi\r\n * \tFile name:\tmemorymapheadergenerator_global.h\r\n * \tProject:\tKactus 2\r\n*/\r\n\r\n#ifndef MEMORYMAPHEADERGENERATOR_GLOBAL_H\r\n#define MEMORYMAPHEADERGENERATOR_GLOBAL_H\r\n\r\n#include <QtCore/qglobal.h>\r\n\r\n#ifdef MEMORYMAPHEADERGENERATOR_LIB\r\n# define MEMORYMAPHEADERGENERATOR_EXPORT Q_DECL_EXPORT\r\n#else\r\n# define MEMORYMAPHEADERGENERATOR_EXPORT Q_DECL_IMPORT\r\n#endif\r\n\r\n#endif // MEMORYMAPHEADERGENERATOR_GLOBAL_H\r\n"
  },
  {
    "path": "Plugins/MemoryMapHeaderGenerator/systemheadersavemodel.cpp",
    "content": "/* \r\n *\tCreated on:\t11.4.2013\r\n *\tAuthor:\t\tAntti Kamppi\r\n *\tFile name:\tsystemheadersavemodel.cpp\r\n *\tProject:\t\tKactus 2\r\n*/\r\n\r\n#include \"systemheadersavemodel.h\"\r\n\r\n#include <KactusAPI/include/LibraryInterface.h>\r\n\r\n#include <QDir>\r\n#include <QFileInfo>\r\n\r\nSystemHeaderSaveModel::SystemHeaderSaveModel( LibraryInterface* handler, QObject *parent ):\r\nQAbstractTableModel(parent),\r\nhandler_(handler),\r\ntable_(), \r\ntopComp_() {\r\n\r\n\tQ_ASSERT(handler_);\r\n}\r\n\r\nSystemHeaderSaveModel::~SystemHeaderSaveModel() {\r\n}\r\n\r\nvoid SystemHeaderSaveModel::setObjects(QSharedPointer<Component> topComponent,\r\n\tconst QList<SystemHeaderSaveModel::SysHeaderOptions>& options ) {\r\n\t\r\n\ttopComp_.clear();\r\n\ttopComp_ = topComponent;\r\n\tQ_ASSERT(topComp_);\r\n\r\n\tbeginResetModel();\r\n\r\n\ttable_ = options;\r\n\r\n\t// set default paths for system headers\r\n\tfor (int i = 0; i < table_.size(); ++i) {\r\n\r\n\t\tSystemHeaderSaveModel::SysHeaderOptions& opt = table_[i];\r\n\r\n\t\t// path to the directory containing the xml metadata for the system component\r\n\t\tQString compPath = handler_->getDirectoryPath(topComp_->getVlnv());\r\n\r\n\t\t// the relative path for the header\r\n\t\tQString headerPath = QString(\"%1/systemHeaders.h\").arg(opt.instanceName_);\r\n\r\n\t\t// the absolute path for the header file\r\n\t\tQString fullPath = QString(\"%1/%2\").arg(compPath).arg(headerPath);\r\n\r\n\t\topt.sysHeaderInfo_ = QFileInfo(fullPath);\r\n\t}\r\n\r\n\tendResetModel();\r\n}\r\n\r\nint SystemHeaderSaveModel::rowCount( const QModelIndex& parent /*= QModelIndex()*/ ) const {\r\n\tif (parent.isValid()) {\r\n\t\treturn 0;\r\n\t}\r\n\treturn table_.size();\r\n}\r\n\r\nint SystemHeaderSaveModel::columnCount( const QModelIndex& parent /*= QModelIndex()*/ ) const {\r\n\tif (parent.isValid()) {\r\n\t\treturn 0;\r\n\t}\r\n\treturn SystemHeaderSaveModel::COLUMN_COUNT;\r\n}\r\n\r\nQt::ItemFlags SystemHeaderSaveModel::flags( const QModelIndex& index ) const {\r\n\tif (!index.isValid()) {\r\n\t\treturn Qt::NoItemFlags;\r\n\t}\r\n\r\n\treturn Qt::ItemIsSelectable | Qt::ItemIsEnabled;\r\n}\r\n\r\nQVariant SystemHeaderSaveModel::headerData( int section, Qt::Orientation orientation, int role /*= Qt::DisplayRole*/ ) const {\r\n\tif (orientation != Qt::Horizontal) {\r\n\t\treturn QVariant();\r\n\t}\r\n\tif (Qt::DisplayRole == role) {\r\n\r\n\t\tswitch (section) {\r\n\t\tcase SystemHeaderSaveModel::INSTANCE_COLUMN: {\r\n\t\t\treturn tr(\"Instance\\nname\");\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t }\r\n\t\tcase SystemHeaderSaveModel::FILENAME_COLUMN: {\r\n\t\t\treturn tr(\"File name\");\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t  }\r\n\t\tcase SystemHeaderSaveModel::FILEPATH_COLUMN: {\r\n\t\t\treturn tr(\"File Path\");\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t}\r\n\t\tdefault: {\r\n\t\t\treturn QVariant();\r\n\t\t\t\t\t}\r\n\t\t}\r\n\t}\r\n\telse {\r\n\t\treturn QVariant();\r\n\t}\r\n}\r\n\r\nQVariant SystemHeaderSaveModel::data( const QModelIndex& index, int role /*= Qt::DisplayRole*/ ) const {\r\n\tif (!index.isValid()) {\r\n\t\treturn QVariant();\r\n\t}\r\n\telse if (index.row() < 0 || index.row() >= table_.size()) {\r\n\t\treturn QVariant();\r\n\t}\r\n\r\n\tif (Qt::DisplayRole == role) {\r\n\r\n\t\tswitch (index.column()) {\r\n\t\tcase SystemHeaderSaveModel::INSTANCE_COLUMN: {\r\n\t\t\treturn table_.at(index.row()).instanceName_;\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t }\r\n\t\tcase SystemHeaderSaveModel::FILENAME_COLUMN: {\r\n\t\t\treturn table_.at(index.row()).sysHeaderInfo_.fileName();\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t}\r\n\t\tcase SystemHeaderSaveModel::FILEPATH_COLUMN: {\r\n\r\n\t\t\t// display the relative path from xml directory to the header to be generated\r\n\t\t\tQDir xmlDir(handler_->getDirectoryPath(topComp_->getVlnv()));\r\n\t\t\tQString headerPath = table_.at(index.row()).sysHeaderInfo_.absoluteFilePath();\r\n\t\t\tQString relPath = xmlDir.relativeFilePath(headerPath);\r\n\r\n\t\t\treturn relPath;\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t}\r\n\t\tdefault: {\r\n\t\t\treturn QVariant();\r\n\t\t\t\t\t}\r\n\t\t}\r\n\t}\r\n\t// user role always returns the absolute file path\r\n\telse if (Qt::UserRole == role) {\r\n\r\n\t\t// if the header dir exists\r\n\t\tif (table_.at(index.row()).sysHeaderInfo_.exists()) {\r\n\r\n\t\t\t// return path to the directory for headers\r\n\t\t\treturn table_.at(index.row()).sysHeaderInfo_.absoluteFilePath();\r\n\t\t}\r\n\r\n\t\t// if not then at least the xml directory exists\r\n\t\telse {\r\n\t\t\treturn handler_->getDirectoryPath(topComp_->getVlnv());\r\n\t\t}\t\t\r\n\t}\r\n\telse {\r\n\t\treturn QVariant();\r\n\t}\r\n}\r\n\r\nbool SystemHeaderSaveModel::setData( const QModelIndex& index, const QVariant& value, int role /*= Qt::EditRole*/ ) {\r\n\tif (!index.isValid()) {\r\n\t\treturn false;\r\n\t}\r\n\telse if (index.row() < 0 || index.row() >= table_.size()) {\r\n\t\treturn false;\r\n\t}\r\n\r\n\tif (Qt::EditRole == role) {\r\n\r\n\t\tswitch (index.column()) {\r\n\t\tcase SystemHeaderSaveModel::INSTANCE_COLUMN: {\r\n\t\t\t// instance name can not be modified\r\n\t\t\treturn false;\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t }\r\n\t\tcase SystemHeaderSaveModel::FILENAME_COLUMN: {\r\n\t\t\ttable_[index.row()].sysHeaderInfo_.setFile(value.toString());\r\n\r\n\t\t\t// both indexes change\r\n\t\t\tQModelIndex pathIndex = QAbstractTableModel::index(index.row(), SystemHeaderSaveModel::FILEPATH_COLUMN, QModelIndex());\r\n\t\t\temit dataChanged(index, pathIndex);\r\n\t\t\treturn true;\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t}\r\n\t\tcase SystemHeaderSaveModel::FILEPATH_COLUMN: {\r\n\t\t\ttable_[index.row()].sysHeaderInfo_.setFile(value.toString());\r\n\r\n\t\t\t// both columns change\r\n\t\t\tQModelIndex nameIndex = QAbstractTableModel::index(index.row(), SystemHeaderSaveModel::FILENAME_COLUMN, QModelIndex());\r\n\t\t\temit dataChanged(nameIndex, index);\r\n\t\t\treturn true;\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t}\r\n\t\tdefault: {\r\n\t\t\treturn false;\r\n\t\t\t\t\t}\r\n\t\t}\r\n\t}\r\n\telse if (Qt::UserRole == role) {\r\n\t\ttable_[index.row()].sysHeaderInfo_.setFile(value.toString());\r\n\r\n\t\t// the change affects to both columns\r\n\t\tQModelIndex leftIndex = QAbstractTableModel::index(index.row(), SystemHeaderSaveModel::FILENAME_COLUMN, QModelIndex());\r\n\t\tQModelIndex rightIndex = QAbstractTableModel::index(index.row(), SystemHeaderSaveModel::FILEPATH_COLUMN, QModelIndex());\r\n\r\n\t\t// inform of changes\r\n\t\temit dataChanged(leftIndex, rightIndex);\r\n\t\treturn true;\r\n\t}\r\n\telse {\r\n\t\treturn false;\r\n\t}\r\n}\r\n\r\nconst QList<SystemHeaderSaveModel::SysHeaderOptions>& SystemHeaderSaveModel::getObjects() const {\r\n\treturn table_;\r\n}\r\n\r\nSystemHeaderSaveModel::SysHeaderOptions::SysHeaderOptions( const QString& instanceName /*= QString()*/,\r\n\tconst VLNV& compVLNV /*= VLNV()*/ ):\r\ninstanceName_(instanceName),\r\n\tcompVLNV_(compVLNV),\r\n\tinstanceId_(),\r\n\tsysHeaderInfo_(),\r\n\tincludeFiles_(),\r\n\tfound_(false) {\r\n}\r\n\r\nSystemHeaderSaveModel::SysHeaderOptions::SysHeaderOptions( const SysHeaderOptions& other ):\r\ninstanceName_(other.instanceName_),\r\n\tcompVLNV_(other.compVLNV_),\r\n\tinstanceId_(other.instanceId_),\r\n\tsysHeaderInfo_(other.sysHeaderInfo_),\r\n\tincludeFiles_(other.includeFiles_),\r\n\tfound_(other.found_) {\r\n}\r\n\r\nSystemHeaderSaveModel::SysHeaderOptions& SystemHeaderSaveModel::SysHeaderOptions::operator=( const SysHeaderOptions& other ) {\r\n\tif (this != &other) {\r\n\t\tinstanceName_ = other.instanceName_;\r\n\t\tcompVLNV_ = other.compVLNV_;\r\n\t\tinstanceId_ = other.instanceId_;\r\n\t\tsysHeaderInfo_ = other.sysHeaderInfo_;\r\n\t\tincludeFiles_ = other.includeFiles_;\r\n\t\tfound_ = other.found_;\r\n\t}\r\n\treturn *this;\r\n}\r\n\r\nbool SystemHeaderSaveModel::SysHeaderOptions::operator==( const SysHeaderOptions& other ) {\r\n\tif (compVLNV_ == other.compVLNV_ &&\r\n\t\tinstanceName_.compare(other.instanceName_, Qt::CaseInsensitive) == 0) {\r\n\t\t\treturn true;\r\n\t}\r\n\telse {\r\n\t\treturn false;\r\n\t}\r\n}\r\n\r\nbool SystemHeaderSaveModel::SysHeaderOptions::operator!=( const SysHeaderOptions& other ) {\r\n\tif (compVLNV_ != other.compVLNV_) {\r\n\t\treturn true;\r\n\t}\r\n\treturn instanceName_.compare(other.instanceName_, Qt::CaseInsensitive) != 0;\r\n}\r\n\r\nbool SystemHeaderSaveModel::SysHeaderOptions::operator<( const SysHeaderOptions& other ) {\r\n\tif (compVLNV_ == other.compVLNV_) {\r\n\t\treturn instanceName_.compare(other.instanceName_, Qt::CaseInsensitive) < 0;\r\n\t}\r\n\telse {\r\n\t\treturn compVLNV_ < other.compVLNV_;\r\n\t}\r\n}\r\n"
  },
  {
    "path": "Plugins/MemoryMapHeaderGenerator/systemheadersavemodel.h",
    "content": "/* \r\n *\tCreated on:\t11.4.2013\r\n *\tAuthor:\t\tAntti Kamppi\r\n *\tFile name:\tsystemheadersavemodel.h\r\n *\tProject:\t\tKactus 2\r\n*/\r\n\r\n#ifndef SYSTEMHEADERSAVEMODEL_H\r\n#define SYSTEMHEADERSAVEMODEL_H\r\n\r\n#include <IPXACTmodels/common/VLNV.h>\r\n#include <IPXACTmodels/Component/Component.h>\r\n\r\n#include <QAbstractTableModel>\r\n#include <QString>\r\n#include <QFileInfo>\r\n#include <QList>\r\n#include <QObject>\r\n#include <QSharedPointer>\r\n\r\nclass LibraryInterface;\r\n\r\n/*! \\brief The model class to display the header files to be generated for CPU instances of system design.\r\n *\r\n */\r\nclass SystemHeaderSaveModel : public QAbstractTableModel {\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\r\n\t//! \\brief Specifies the columns supported by the model.\r\n\tenum Columns {\r\n\t\tINSTANCE_COLUMN = 0,\r\n\t\tFILENAME_COLUMN,\r\n\t\tFILEPATH_COLUMN,\r\n\t\tCOLUMN_COUNT\r\n\t};\r\n\r\n\t/*! \\brief The constructor.\r\n\t *\r\n\t * Method: \t\tSystemHeaderSaveModel\r\n\t * Full name:\tSystemHeaderSaveModel::SystemHeaderSaveModel\r\n\t * Access:\t\tprivate \r\n\t *\r\n\t * \\param handler Pointer to the instance which manages the library.\r\n\t * \\param parent Pointer to the owner of the model.\r\n\t *\r\n\t*/\r\n\tSystemHeaderSaveModel(LibraryInterface* handler, QObject *parent);\r\n\t\r\n\t//! \\brief The destructor.\r\n\tvirtual ~SystemHeaderSaveModel();\r\n\r\n\t/*! \\brief Get the number of rows an item contains.\r\n\t *\r\n\t * \\param parent Identifies the parent that's row count is requested.\r\n\t *\r\n\t * \\return Number of rows the item has.\r\n\t*/\r\n\tvirtual int rowCount(const QModelIndex& parent = QModelIndex()) const;\r\n\r\n\t/*! \\brief Get the number of columns the item has to be displayed.\r\n\t *\r\n\t * \\param parent Identifies the parent that's column count is requested.\r\n\t *\r\n\t * \\return The number of columns to be displayed.\r\n\t*/\r\n\tvirtual int columnCount(const QModelIndex& parent = QModelIndex()) const;\r\n\r\n\t/*! \\brief Get the item flags that defines the possible operations for the item.\r\n\t *\r\n\t * \\param index Model index that identifies the item.\r\n\t *\r\n\t * \\return Qt::ItemFlags specify the possible operations for the item.\r\n\t*/\r\n\tQt::ItemFlags flags(const QModelIndex& index) const;\r\n\r\n\t/*! \\brief Get the header data for specified header.\r\n\t *\r\n\t * \\param section The section specifies the row/column number for the header.\r\n\t * \\param orientation Specified if horizontal or vertical header is wanted.\r\n\t * \\param role Specifies the type of the requested data.\r\n\t *\r\n\t * \\return QVariant Contains the requested data.\r\n\t*/\r\n\tvirtual QVariant headerData(int section, Qt::Orientation orientation, \r\n\t\tint role = Qt::DisplayRole) const;\r\n\r\n\t/*! \\brief Get the data for specified item.\r\n\t *\r\n\t * \\param index Specifies the item that's data is requested.\r\n\t * \\param role The role that defines what kind of data is requested.\r\n\t *\r\n\t * \\return QVariant Contains the data for the item.\r\n\t*/\r\n\tvirtual QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const;\r\n\r\n\t/*! \\brief Save the data to the model for specified item\r\n\t *\r\n\t * \\param index The model index of the item that's data is to be saved.\r\n\t * \\param value The data that is to be saved.\r\n\t * \\param role The role specifies what kind of data should be saved.\r\n\t *\r\n\t * \\return True if saving happened successfully.\r\n\t*/\r\n\tbool setData(const QModelIndex& index, const QVariant& value, \r\n\t\tint role = Qt::EditRole);\r\n\r\n\t//! \\brief Contains the settings needed to generate the system headers\r\n\tstruct SysHeaderOptions {\r\n\r\n\t\t//! \\brief Name of the CPU instance.\r\n\t\tQString instanceName_;\r\n\r\n\t\t//! \\brief Identifies the component.\r\n\t\tVLNV compVLNV_;\r\n\r\n\t\t//! \\brief Uuid identifying the instance.\r\n\t\tQString instanceId_;\r\n\r\n\t\t//! \\brief Refers to the system header to generate.\r\n\t\tQFileInfo sysHeaderInfo_;\r\n\r\n\t\t//! \\brief References to the files to include in the system header.\r\n\t\tQList<QFileInfo> includeFiles_;\r\n\r\n\t\t//! \\brief Indicates whether the instance has been found or not.\r\n\t\tbool found_;\r\n\r\n\t\t/*! \\brief The constructor.\r\n\t\t *\r\n\t\t * Method: \t\tSysHeaderOptions\r\n\t\t * Full name:\tMemoryMapHeaderGenerator::SysHeaderOptions::SysHeaderOptions\r\n\t\t * Access:\t\tpublic \r\n\t\t *\r\n\t\t * \\param instanceName The name of the CPU instance.\r\n\t\t * \\param compVLNV VLNV identifying the component.\r\n\t\t *\r\n\t\t*/\r\n\t\tSysHeaderOptions(const QString& instanceName = QString(), const VLNV& compVLNV = VLNV());\r\n\r\n\t\t//! \\brief Copy constructor.\r\n\t\tSysHeaderOptions(const SysHeaderOptions& other);\r\n\r\n\t\t//! \\brief Assignment operator.\r\n\t\tSysHeaderOptions& operator=(const SysHeaderOptions& other);\r\n\r\n\t\t//! \\brief The equality operator.\r\n\t\tbool operator==(const SysHeaderOptions& other);\r\n\r\n\t\t//! \\brief The inequality operator.\r\n\t\tbool operator!=(const SysHeaderOptions& other);\r\n\r\n\t\t//! \\brief Smaller than operator.\r\n\t\tbool operator<(const SysHeaderOptions& other);\r\n\t};\r\n\r\n\t/*! \\brief Set the objects to display in the model.\r\n\t *\r\n\t * Method: \t\tsetObjects\r\n\t * Full name:\tSystemHeaderSaveModel::setObjects\r\n\t * Access:\t\tpublic \r\n\t *\r\n\t * \\param options Contains the settings for the objects to create.\r\n\t *\r\n\t*/\r\n\tvoid setObjects(QSharedPointer<Component> topComponent, \r\n\t\tconst QList<SystemHeaderSaveModel::SysHeaderOptions>& options);\r\n\r\n\t/*! \\brief Get the objects displayed in the model.\r\n\t *\r\n\t * Method: \t\tgetObjects\r\n\t * Full name:\tSystemHeaderSaveModel::getObjects\r\n\t * Access:\t\tpublic \r\n\t *\r\n\t *\r\n\t * \\return QList containing the settings for the objects.\r\n\t*/\r\n\tconst QList<SystemHeaderSaveModel::SysHeaderOptions>& getObjects() const;\r\n\r\nprivate:\r\n\t\r\n\t//! \\brief No copying\r\n\tSystemHeaderSaveModel(const SystemHeaderSaveModel& other);\r\n\r\n\t//! \\brief No assignment\r\n\tSystemHeaderSaveModel& operator=(const SystemHeaderSaveModel& other);\r\n\r\n\t//! \\brief Pointer to the instance which manages the library.\r\n\tLibraryInterface* handler_;\r\n\r\n\t//! \\brief Contains the settings to display.\r\n\tQList<SysHeaderOptions> table_;\r\n\r\n\t//! \\brief Pointer to the system-level component.\r\n\tQSharedPointer<Component> topComp_;\r\n};\r\n\r\n#endif // SYSTEMHEADERSAVEMODEL_H\r\n"
  },
  {
    "path": "Plugins/MemoryViewGenerator/MemoryViewGenerator.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: MemoryViewGenerator.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Esko Pekkarinen\r\n// Date: 26.04.2016\r\n//\r\n// Description:\r\n// Creates a CSV listing of all slave memories within a design hierarchy.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"MemoryViewGenerator.h\"\r\n\r\n#include <KactusAPI/include/LibraryInterface.h>\r\n\r\n#include <KactusAPI/include/SystemVerilogExpressionParser.h>\r\n\r\n#include <editors/MemoryDesigner/ConnectivityConnection.h>\r\n#include <editors/MemoryDesigner/ConnectivityGraph.h>\r\n#include <editors/MemoryDesigner/ConnectivityGraphFactory.h>\r\n#include <editors/MemoryDesigner/ConnectivityInterface.h>\r\n#include <editors/MemoryDesigner/MasterSlavePathSearch.h>\r\n#include <editors/MemoryDesigner/MemoryItem.h>\r\n\r\n#include <IPXACTmodels/Component/Component.h>\r\n#include <IPXACTmodels/Design/Design.h>\r\n#include <IPXACTmodels/DesignConfiguration/DesignConfiguration.h>\r\n\r\n#include <QFileInfo>\r\n#include <QTextStream>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryViewGenerator::MemoryViewGenerator()\r\n//-----------------------------------------------------------------------------\r\nMemoryViewGenerator::MemoryViewGenerator(LibraryInterface* library): library_(library),\r\n    graphFactory_(library),\r\n    expressionParser_(new SystemVerilogExpressionParser())\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryViewGenerator::~MemoryViewGenerator()\r\n//-----------------------------------------------------------------------------\r\nMemoryViewGenerator::~MemoryViewGenerator()\r\n{\r\n    delete expressionParser_;\r\n    expressionParser_ = 0;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryViewGenerator::generate()\r\n//-----------------------------------------------------------------------------\r\nvoid MemoryViewGenerator::generate(QSharedPointer<Component> topComponent, QString const& activeView, \r\n    QString const& outputPath)\r\n{\r\n    QSharedPointer<ConnectivityGraph> graph = graphFactory_.createConnectivityGraph(topComponent, activeView);\r\n    MasterSlavePathSearch searchAlgorithm;\r\n\r\n    writeFile(outputPath, searchAlgorithm.findMasterSlavePaths(graph, true));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryViewGenerator::writeFile()\r\n//-----------------------------------------------------------------------------\r\nvoid MemoryViewGenerator::writeFile(QString const& outputPath, \r\n    QVector<QVector<QSharedPointer<const ConnectivityInterface> > > masterRoutes)\r\n{\r\n    QFile outputFile(outputPath); \r\n    if (!outputFile.open(QIODevice::WriteOnly))\r\n    {\r\n        return;\r\n    }\r\n\r\n    QTextStream outputStream(&outputFile);\r\n\r\n    outputStream << \"Identifier;Type;Address;Range (AUB);Width (bits);Size (bits);Offset (bits);\" << Qt::endl;\r\n\r\n    foreach (QVector<QSharedPointer<const ConnectivityInterface> > path, masterRoutes)\r\n    {        \r\n        int addressOffset = path.first()->getBaseAddress().toInt();\r\n        foreach (QSharedPointer<const ConnectivityInterface> inter, path)\r\n        {\r\n            if (inter->getMode() == General::MIRRORED_SLAVE)\r\n            {\r\n                addressOffset += inter->getRemapAddress().toInt();\r\n            }\r\n        }\r\n\r\n        writeItem(path.first()->getConnectedMemory(), addressOffset, outputStream);\r\n\r\n        if (path.first() != path.last())\r\n        {\r\n            writeItem(path.last()->getConnectedMemory(), addressOffset, outputStream);\r\n        }\r\n    }\r\n\r\n    outputFile.close();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryViewGenerator::writeItem()\r\n//-----------------------------------------------------------------------------\r\nvoid MemoryViewGenerator::writeItem(QSharedPointer<MemoryItem> item, int addressOffset, QTextStream& outputStream)\r\n{\r\n    if (item)\r\n    {\r\n        outputStream << item->getIdentifier() << \";\" << item->getType() << \";\" <<\r\n            \"0x\" + QString::number(addressOffset + item->getAddress().toInt(), 16) << \";\" << \r\n            item->getRange() << \";\" << item->getWidth() << \";\" << item->getSize() << \";\" <<\r\n            item->getOffset() << \";\" << Qt::endl;\r\n\r\n        foreach (QSharedPointer<MemoryItem> child, item->getChildItems())\r\n        {\r\n            writeItem(child, addressOffset, outputStream);\r\n        }\r\n    }\r\n}\r\n"
  },
  {
    "path": "Plugins/MemoryViewGenerator/MemoryViewGenerator.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: MemoryViewGenerator.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Esko Pekkarinen\r\n// Date: 26.04.2016\r\n//\r\n// Description:\r\n// Creates a CSV listing of all slave memories within a design hierarchy.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef MEMORYVIEWGENERATOR_H\r\n#define MEMORYVIEWGENERATOR_H\r\n\r\n#include <QList>\r\n#include <QString>\r\n#include <QSharedPointer>\r\n\r\n#include \"memoryviewgenerator_global.h\"\r\n\r\n#include <editors/MemoryDesigner/ConnectivityGraphFactory.h>\r\n\r\n#include <IPXACTmodels/Component/BusInterface.h>\r\n\r\n#include <IPXACTmodels/Design/ActiveInterface.h>\r\n#include <IPXACTmodels/Design/Design.h>\r\n\r\n#include <IPXACTmodels/generaldeclarations.h>\r\n\r\nclass AddressBlock;\r\nclass BusInterface;\r\nclass Component;\r\nclass ExpressionParser;\r\nclass Field;\r\nclass ConnectivityInterface;\r\nclass LibraryInterface;\r\nclass MemoryMap;\r\nclass MemoryItem;\r\nclass Register;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Creates a CSV listing of all slave memories within a design hierarchy.\r\n//-----------------------------------------------------------------------------\r\nclass MEMORYVIEWGENERATOR_EXPORT MemoryViewGenerator\r\n{\r\n\r\npublic:\r\n    \r\n    //! The constructor.\r\n    MemoryViewGenerator(LibraryInterface* library);\r\n\r\n    //! The destructor.\r\n    ~MemoryViewGenerator();\r\n\r\n    /*!\r\n     *  Generates slave memory listing for the given component.\r\n     *\r\n     *    @param [in] topComponent    The top component in the hierarchy to generate listing for.\r\n     *    @param [in] outputPath      Path to the output file.\r\n     */\r\n    void generate(QSharedPointer<Component> topComponent, QString const& activeView, QString const& outputPath);\r\n  \r\nprivate:\r\n\r\n    // Disable copying.\r\n    MemoryViewGenerator(MemoryViewGenerator const& rhs);\r\n    MemoryViewGenerator& operator=(MemoryViewGenerator const& rhs);\r\n\r\n    /*!\r\n     *  Writes the listing into a given file.\r\n     *\r\n     *    @param [in] outputPath   The path to the output file.\r\n     */\r\n    void writeFile(QString const& outputPath, QVector<QVector<QSharedPointer<const ConnectivityInterface> > >  masterRoutes);\r\n\r\n    /*!\r\n     *  Writes the given memory element into output.\r\n     *\r\n     *    @param [in] item            The memory element to write.\r\n     *    @param [in] addressOffset   Offset for the memory item.\r\n     *    @param [in] outputStream    The output to write the element into.\r\n     */\r\n    void writeItem(QSharedPointer<MemoryItem> item, int addressOffset, QTextStream& outputStream);\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! The available IP-XACT library.\r\n    LibraryInterface* library_;\r\n\r\n    //! Factory for creating connectivity graphs.\r\n    ConnectivityGraphFactory graphFactory_;\r\n\r\n    //! Parser for resolving expressions.\r\n    ExpressionParser* expressionParser_;\r\n};\r\n\r\n#endif // MEMORYVIEWGENERATOR_H\r\n"
  },
  {
    "path": "Plugins/MemoryViewGenerator/MemoryViewGenerator.json",
    "content": "{\r\n\t\"Keys\": [ \"Memory view generator\" ]\r\n}"
  },
  {
    "path": "Plugins/MemoryViewGenerator/MemoryViewGenerator.pri",
    "content": "# ----------------------------------------------------\r\n# This file is generated by the Qt Visual Studio Tools.\r\n# ------------------------------------------------------\r\n\r\nHEADERS += \\\r\n    ../../editors/MemoryDesigner/ConnectivityComponent.h \\\r\n    ../../editors/MemoryDesigner/ConnectivityConnection.h \\\r\n    ../../editors/MemoryDesigner/ConnectivityGraph.h \\\r\n    ../../editors/MemoryDesigner/ConnectivityGraphFactory.h \\\r\n    ../../editors/MemoryDesigner/ConnectivityInterface.h \\\r\n    ../../editors/MemoryDesigner/MasterSlavePathSearch.h \\\r\n    ../../editors/MemoryDesigner/MemoryItem.h \\\r\n    ./MemoryViewGenerator.h \\\r\n    ./memoryviewgenerator_global.h \\\r\n    ./MemoryViewGeneratorPlugin.h \\\r\n    ../PluginSystem/GeneratorPlugin/GenerationControl.h \\\r\n    ../PluginSystem/GeneratorPlugin/OutputControl.h \\\r\n    ../PluginSystem/GeneratorPlugin/ViewSelection.h \\\r\n    ../common/HDLParser/MetaComponent.h \\\r\n    ../common/HDLParser/MetaDesign.h \\\r\n    ../common/HDLParser/MetaInstance.h \\\r\n    ../../IPXACTmodels/utilities/ComponentSearch.h \\\r\n    ../../IPXACTmodels/utilities/Search.h\r\nSOURCES += \\\r\n    ../../editors/MemoryDesigner/ConnectivityComponent.cpp \\\r\n    ../../editors/MemoryDesigner/ConnectivityConnection.cpp \\\r\n    ../../editors/MemoryDesigner/ConnectivityGraph.cpp \\\r\n    ../../editors/MemoryDesigner/ConnectivityGraphFactory.cpp \\\r\n    ../../editors/MemoryDesigner/ConnectivityInterface.cpp \\\r\n    ../../editors/MemoryDesigner/MasterSlavePathSearch.cpp \\\r\n    ../../editors/MemoryDesigner/MemoryItem.cpp \\\r\n    ./MemoryViewGenerator.cpp \\\r\n    ./MemoryViewGeneratorPlugin.cpp \\\r\n    ../PluginSystem/GeneratorPlugin/GenerationControl.cpp \\\r\n    ../PluginSystem/GeneratorPlugin/OutputControl.cpp \\\r\n    ../PluginSystem/GeneratorPlugin/ViewSelection.cpp \\\r\n    ../common/HDLParser/MetaComponent.cpp \\\r\n    ../common/HDLParser/MetaDesign.cpp \\\r\n    ../common/HDLParser/MetaInstance.cpp \\\r\n    ../../IPXACTmodels/utilities/ComponentSearch.cpp\r\nRESOURCES += MemoryViewGenerator.qrc\r\n"
  },
  {
    "path": "Plugins/MemoryViewGenerator/MemoryViewGenerator.pro",
    "content": "# ----------------------------------------------------\r\n# This file is generated by the Qt Visual Studio Add-in.\r\n# ------------------------------------------------------\r\n\r\nTEMPLATE = lib\r\n\r\nQT += core xml widgets gui\r\nCONFIG += c++11 plugin\r\n\r\nDEFINES += MEMORYVIEWGENERATOR_LIB\r\n\r\nINCLUDEPATH += ./GeneratedFiles \\\r\n    . \\\r\n    ./../..\r\n\r\nCONFIG(debug, debug|release) {\r\n    # debug mode\r\n    LIBS += \\\r\n        -L../../executable -lIPXACTmodelsd \\\r\n        -L../../executable -lKactusAPId\r\n\r\n    MOC_DIR += ./GeneratedFiles/Debug\r\n    OBJECTS_DIR += Debug\r\n    TARGET = MemoryViewGeneratord\r\n\r\n} else {\r\n    # release mode \r\n    LIBS += \\\r\n        -L../../executable -lIPXACTmodels \\\r\n        -L../../executable -lKactusAPI\r\n    \r\n    MOC_DIR += ./GeneratedFiles/Release\r\n    OBJECTS_DIR += Release\r\n    TARGET = MemoryViewGenerator\r\n}\r\n\r\nDEPENDPATH += . \\\r\n    ./../../.. \\\r\n\r\nDESTDIR = ../../executable/Plugins\r\n\r\nUI_DIR += ./GeneratedFiles\r\nRCC_DIR += ./GeneratedFiles\r\n\r\ninclude(MemoryViewGenerator.pri)\r\n\r\ntarget.path = $$plugin_path\r\nINSTALLS += target\r\n"
  },
  {
    "path": "Plugins/MemoryViewGenerator/MemoryViewGenerator.qrc",
    "content": "<RCC>\n    <qresource prefix=\"/icons\">\n        <file>memory.png</file>\n    </qresource>\n</RCC>\n"
  },
  {
    "path": "Plugins/MemoryViewGenerator/MemoryViewGenerator.vcxproj",
    "content": "﻿<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n<Project DefaultTargets=\"Build\" ToolsVersion=\"15.0\" xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">\r\n  <ItemGroup Label=\"ProjectConfigurations\">\r\n    <ProjectConfiguration Include=\"Debug|x64\">\r\n      <Configuration>Debug</Configuration>\r\n      <Platform>x64</Platform>\r\n    </ProjectConfiguration>\r\n    <ProjectConfiguration Include=\"Release|x64\">\r\n      <Configuration>Release</Configuration>\r\n      <Platform>x64</Platform>\r\n    </ProjectConfiguration>\r\n  </ItemGroup>\r\n  <PropertyGroup Label=\"Globals\">\r\n    <ProjectGuid>{8FC8D073-3D03-4DE6-8605-D906431FF5E8}</ProjectGuid>\r\n    <Keyword>QtVS_v304</Keyword>\r\n    <WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>\r\n    <QtMsBuild Condition=\"'$(QtMsBuild)'=='' or !Exists('$(QtMsBuild)\\qt.targets')\">$(MSBuildProjectDirectory)\\QtMsBuild</QtMsBuild>\r\n  </PropertyGroup>\r\n  <Import Project=\"$(VCTargetsPath)\\Microsoft.Cpp.Default.props\" />\r\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\" Label=\"Configuration\">\r\n    <ConfigurationType>DynamicLibrary</ConfigurationType>\r\n    <PlatformToolset>v143</PlatformToolset>\r\n  </PropertyGroup>\r\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\" Label=\"Configuration\">\r\n    <ConfigurationType>DynamicLibrary</ConfigurationType>\r\n    <PlatformToolset>v143</PlatformToolset>\r\n  </PropertyGroup>\r\n  <Import Project=\"$(VCTargetsPath)\\Microsoft.Cpp.props\" />\r\n  <Target Name=\"QtMsBuildNotFound\" BeforeTargets=\"CustomBuild;ClCompile\" Condition=\"!Exists('$(QtMsBuild)\\qt.targets') or !Exists('$(QtMsBuild)\\qt.props')\">\r\n    <Message Importance=\"High\" Text=\"QtMsBuild: could not locate qt.targets, qt.props; project may not build correctly.\" />\r\n  </Target>\r\n  <ImportGroup Label=\"ExtensionSettings\">\r\n  </ImportGroup>\r\n  <ImportGroup Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\" Label=\"PropertySheets\">\r\n    <Import Project=\"$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props\" Condition=\"exists('$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props')\" Label=\"LocalAppDataPlatform\" />\r\n  </ImportGroup>\r\n  <ImportGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\" Label=\"PropertySheets\">\r\n    <Import Project=\"$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props\" Condition=\"exists('$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props')\" Label=\"LocalAppDataPlatform\" />\r\n  </ImportGroup>\r\n  <PropertyGroup Label=\"UserMacros\" />\r\n  <ImportGroup Condition=\"Exists('$(QtMsBuild)\\qt_defaults.props')\">\r\n    <Import Project=\"$(QtMsBuild)\\qt_defaults.props\" />\r\n  </ImportGroup>\r\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n    <IntDir>$(ProjectDir)\\$(Configuration)\\</IntDir>\r\n    <OutDir>$(SolutionDir)executable\\Plugins\\</OutDir>\r\n  </PropertyGroup>\r\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n    <IntDir>$(ProjectDir)\\$(Configuration)\\</IntDir>\r\n    <OutDir>$(SolutionDir)executable\\Plugins\\</OutDir>\r\n  </PropertyGroup>\r\n  <PropertyGroup Label=\"QtSettings\" Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n    <QtInstall>6.2.4</QtInstall>\r\n    <QtModules>core;gui;widgets;xml</QtModules>\r\n  </PropertyGroup>\r\n  <PropertyGroup Label=\"QtSettings\" Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n    <QtInstall>6.2.4</QtInstall>\r\n    <QtModules>core;gui;widgets;xml</QtModules>\r\n  </PropertyGroup>\r\n  <ImportGroup Condition=\"Exists('$(QtMsBuild)\\qt.props')\">\r\n    <Import Project=\"$(QtMsBuild)\\qt.props\" />\r\n  </ImportGroup>\r\n  <PropertyGroup>\r\n    <_ProjectFileVersion>10.0.40219.1</_ProjectFileVersion>\r\n  </PropertyGroup>\r\n  <ItemDefinitionGroup Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n    <ClCompile>\r\n      <PreprocessorDefinitions>MEMORYVIEWGENERATOR_LIB;UNICODE;WIN32;WIN64;%(PreprocessorDefinitions)</PreprocessorDefinitions>\r\n      <AdditionalIncludeDirectories>.\\GeneratedFiles\\$(ConfigurationName);.\\GeneratedFiles;.\\..\\..;.;$(SolutionDir)KactusAPI\\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\r\n      <ObjectFileName>$(IntDir)</ObjectFileName>\r\n      <ProgramDataBaseFileName>$(IntDir)vc$(PlatformToolsetVersion).pdb</ProgramDataBaseFileName>\r\n      <Optimization>Disabled</Optimization>\r\n      <LanguageStandard>stdcpp17</LanguageStandard>\r\n      <AdditionalOptions>/Zc:__cplusplus %(AdditionalOptions)</AdditionalOptions>\r\n      <MultiProcessorCompilation>true</MultiProcessorCompilation>\r\n    </ClCompile>\r\n    <Link>\r\n      <AdditionalDependencies>IPXACTmodelsd.lib;KactusAPId.lib;%(AdditionalDependencies)</AdditionalDependencies>\r\n      <AdditionalLibraryDirectories>..\\..\\executable;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>\r\n    </Link>\r\n    <QtMoc>\r\n      <ExecutionDescription>Moc'ing %(Identity)...</ExecutionDescription>\r\n      <DynamicSource>output</DynamicSource>\r\n      <QtMocDir>.\\GeneratedFiles\\$(ConfigurationName)</QtMocDir>\r\n      <QtMocFileName>moc_%(Filename).cpp</QtMocFileName>\r\n    </QtMoc>\r\n    <QtRcc>\r\n      <InitFuncName>%(Filename)</InitFuncName>\r\n      <Compression>default</Compression>\r\n      <NoCompression>true</NoCompression>\r\n      <ExecutionDescription>Rcc'ing %(Identity)...</ExecutionDescription>\r\n      <QtRccDir>.\\GeneratedFiles</QtRccDir>\r\n      <QtRccFileName>qrc_%(Filename).cpp</QtRccFileName>\r\n    </QtRcc>\r\n  </ItemDefinitionGroup>\r\n  <ItemDefinitionGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n    <ClCompile>\r\n      <PreprocessorDefinitions>MEMORYVIEWGENERATOR_LIB;NDEBUG;QT_NO_DEBUG;UNICODE;WIN32;WIN64;%(PreprocessorDefinitions)</PreprocessorDefinitions>\r\n      <AdditionalIncludeDirectories>.\\GeneratedFiles\\$(ConfigurationName);.\\GeneratedFiles;.\\GeneratedFiles\\$(Configuration);.;.\\..\\..;$(SolutionDir)KactusAPI\\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\r\n      <ObjectFileName>$(IntDir)</ObjectFileName>\r\n      <ProgramDataBaseFileName>$(IntDir)vc$(PlatformToolsetVersion).pdb</ProgramDataBaseFileName>\r\n      <MultiProcessorCompilation>true</MultiProcessorCompilation>\r\n      <AdditionalOptions>/Zc:__cplusplus %(AdditionalOptions)</AdditionalOptions>\r\n      <LanguageStandard>stdcpp17</LanguageStandard>\r\n    </ClCompile>\r\n    <Link>\r\n      <AdditionalDependencies>IPXACTmodels.lib;KactusAPI.lib;%(AdditionalDependencies)</AdditionalDependencies>\r\n      <AdditionalLibraryDirectories>..\\..\\executable;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>\r\n    </Link>\r\n    <QtMoc>\r\n      <ExecutionDescription>Moc'ing %(Identity)...</ExecutionDescription>\r\n      <DynamicSource>output</DynamicSource>\r\n      <QtMocDir>.\\GeneratedFiles\\$(ConfigurationName)</QtMocDir>\r\n      <QtMocFileName>moc_%(Filename).cpp</QtMocFileName>\r\n    </QtMoc>\r\n    <QtRcc>\r\n      <InitFuncName>%(Filename)</InitFuncName>\r\n      <Compression>default</Compression>\r\n      <NoCompression>true</NoCompression>\r\n      <ExecutionDescription>Rcc'ing %(Identity)...</ExecutionDescription>\r\n      <QtRccDir>.\\GeneratedFiles</QtRccDir>\r\n      <QtRccFileName>qrc_%(Filename).cpp</QtRccFileName>\r\n    </QtRcc>\r\n  </ItemDefinitionGroup>\r\n  <ItemGroup>\r\n    <ClCompile Include=\"..\\..\\editors\\MemoryDesigner\\ConnectivityComponent.cpp\" />\r\n    <ClCompile Include=\"..\\..\\editors\\MemoryDesigner\\ConnectivityConnection.cpp\" />\r\n    <ClCompile Include=\"..\\..\\editors\\MemoryDesigner\\ConnectivityGraph.cpp\" />\r\n    <ClCompile Include=\"..\\..\\editors\\MemoryDesigner\\ConnectivityGraphFactory.cpp\" />\r\n    <ClCompile Include=\"..\\..\\editors\\MemoryDesigner\\ConnectivityInterface.cpp\" />\r\n    <ClCompile Include=\"..\\..\\editors\\MemoryDesigner\\MasterSlavePathSearch.cpp\" />\r\n    <ClCompile Include=\"..\\..\\editors\\MemoryDesigner\\MemoryItem.cpp\" />\r\n    <ClCompile Include=\"..\\..\\IPXACTmodels\\utilities\\ComponentSearch.cpp\" />\r\n    <ClCompile Include=\"..\\common\\HDLParser\\MetaComponent.cpp\" />\r\n    <ClCompile Include=\"..\\common\\HDLParser\\MetaDesign.cpp\" />\r\n    <ClCompile Include=\"..\\common\\HDLParser\\MetaInstance.cpp\" />\r\n    <ClCompile Include=\"..\\PluginSystem\\GeneratorPlugin\\GenerationControl.cpp\" />\r\n    <ClCompile Include=\"..\\PluginSystem\\GeneratorPlugin\\OutputControl.cpp\" />\r\n    <ClCompile Include=\"..\\PluginSystem\\GeneratorPlugin\\ViewSelection.cpp\" />\r\n    <ClCompile Include=\"MemoryViewGenerator.cpp\" />\r\n    <ClCompile Include=\"MemoryViewGeneratorPlugin.cpp\" />\r\n  </ItemGroup>\r\n  <ItemGroup>\r\n    <ClInclude Include=\"..\\..\\editors\\MemoryDesigner\\ConnectivityComponent.h\" />\r\n    <ClInclude Include=\"..\\..\\editors\\MemoryDesigner\\ConnectivityConnection.h\" />\r\n    <ClInclude Include=\"..\\..\\editors\\MemoryDesigner\\ConnectivityGraph.h\" />\r\n    <ClInclude Include=\"..\\..\\editors\\MemoryDesigner\\ConnectivityGraphFactory.h\" />\r\n    <ClInclude Include=\"..\\..\\editors\\MemoryDesigner\\ConnectivityInterface.h\" />\r\n    <ClInclude Include=\"..\\..\\editors\\MemoryDesigner\\MasterSlavePathSearch.h\" />\r\n    <ClInclude Include=\"..\\..\\editors\\MemoryDesigner\\MemoryItem.h\" />\r\n    <ClInclude Include=\"..\\..\\IPXACTmodels\\utilities\\ComponentSearch.h\" />\r\n    <ClInclude Include=\"..\\..\\IPXACTmodels\\utilities\\Search.h\" />\r\n    <ClInclude Include=\"..\\common\\HDLParser\\MetaComponent.h\" />\r\n    <ClInclude Include=\"..\\common\\HDLParser\\MetaDesign.h\" />\r\n    <ClInclude Include=\"..\\common\\HDLParser\\MetaInstance.h\" />\r\n    <ClInclude Include=\"..\\PluginSystem\\GeneratorPlugin\\GenerationControl.h\" />\r\n    <ClInclude Include=\"..\\PluginSystem\\GeneratorPlugin\\OutputControl.h\" />\r\n    <ClInclude Include=\"..\\PluginSystem\\GeneratorPlugin\\ViewSelection.h\" />\r\n    <ClInclude Include=\"MemoryViewGenerator.h\" />\r\n    <QtMoc Include=\"MemoryViewGeneratorPlugin.h\">\r\n    </QtMoc>\r\n    <ClInclude Include=\"memoryviewgenerator_global.h\" />\r\n  </ItemGroup>\r\n  <ItemGroup>\r\n    <QtRcc Include=\"MemoryViewGenerator.qrc\">\r\n    </QtRcc>\r\n  </ItemGroup>\r\n  <ItemGroup>\r\n    <None Include=\"memory.png\">\r\n      <ExcludedFromBuild Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">true</ExcludedFromBuild>\r\n      <ExcludedFromBuild Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">true</ExcludedFromBuild>\r\n    </None>\r\n  </ItemGroup>\r\n  <Import Project=\"$(VCTargetsPath)\\Microsoft.Cpp.targets\" />\r\n  <ImportGroup Condition=\"Exists('$(QtMsBuild)\\qt.targets')\">\r\n    <Import Project=\"$(QtMsBuild)\\qt.targets\" />\r\n  </ImportGroup>\r\n  <ImportGroup Label=\"ExtensionTargets\">\r\n  </ImportGroup>\r\n  <ProjectExtensions>\r\n    <VisualStudio>\r\n      <UserProperties />\r\n    </VisualStudio>\r\n  </ProjectExtensions>\r\n</Project>"
  },
  {
    "path": "Plugins/MemoryViewGenerator/MemoryViewGenerator.vcxproj.filters",
    "content": "﻿<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n<Project ToolsVersion=\"4.0\" xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">\r\n  <ItemGroup>\r\n    <Filter Include=\"Source Files\">\r\n      <UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>\r\n      <Extensions>cpp;cxx;c;def</Extensions>\r\n    </Filter>\r\n    <Filter Include=\"Header Files\">\r\n      <UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>\r\n      <Extensions>h</Extensions>\r\n    </Filter>\r\n    <Filter Include=\"Resource Files\">\r\n      <UniqueIdentifier>{D9D6E242-F8AF-46E4-B9FD-80ECBC20BA3E}</UniqueIdentifier>\r\n      <Extensions>qrc;*</Extensions>\r\n      <ParseFiles>false</ParseFiles>\r\n    </Filter>\r\n    <Filter Include=\"Generated Files\">\r\n      <UniqueIdentifier>{71ED8ED8-ACB9-4CE9-BBE1-E00B30144E11}</UniqueIdentifier>\r\n      <Extensions>moc;h;cpp</Extensions>\r\n      <SourceControlFiles>False</SourceControlFiles>\r\n    </Filter>\r\n    <Filter Include=\"Generated Files\\Debug\">\r\n      <UniqueIdentifier>{76cb1c2b-9ae3-402c-8004-35a0d5e62175}</UniqueIdentifier>\r\n      <Extensions>cpp;moc</Extensions>\r\n      <SourceControlFiles>False</SourceControlFiles>\r\n    </Filter>\r\n    <Filter Include=\"Generated Files\\Release\">\r\n      <UniqueIdentifier>{fc46172b-c8bd-4b63-a194-9a7ce8caad4d}</UniqueIdentifier>\r\n      <Extensions>cpp;moc</Extensions>\r\n      <SourceControlFiles>False</SourceControlFiles>\r\n    </Filter>\r\n    <Filter Include=\"Source Files\\GenerationControl\">\r\n      <UniqueIdentifier>{b0614b26-63fd-4457-88b6-9e026485f1db}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Header Files\\GenerationControl\">\r\n      <UniqueIdentifier>{f5af8e81-6872-45d3-84ec-14cd2220c1a6}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Source Files\\Parsing\">\r\n      <UniqueIdentifier>{a8e8f746-ed26-4c27-8897-6b73bc0ea583}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Header Files\\Parsing\">\r\n      <UniqueIdentifier>{0ac476ff-d2d4-46f6-8081-d4d1cd560f7f}</UniqueIdentifier>\r\n    </Filter>\r\n  </ItemGroup>\r\n  <ItemGroup>\r\n    <ClCompile Include=\"MemoryViewGeneratorPlugin.cpp\">\r\n      <Filter>Source Files</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"MemoryViewGenerator.cpp\">\r\n      <Filter>Source Files</Filter>\r\n    </ClCompile>\r\n    \r\n    <ClCompile Include=\"..\\PluginSystem\\GeneratorPlugin\\GenerationControl.cpp\">\r\n      <Filter>Source Files\\GenerationControl</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\PluginSystem\\GeneratorPlugin\\OutputControl.cpp\">\r\n      <Filter>Source Files\\GenerationControl</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\PluginSystem\\GeneratorPlugin\\ViewSelection.cpp\">\r\n      <Filter>Source Files\\GenerationControl</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\common\\HDLParser\\MetaComponent.cpp\">\r\n      <Filter>Source Files\\Parsing</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\common\\HDLParser\\MetaDesign.cpp\">\r\n      <Filter>Source Files\\Parsing</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\common\\HDLParser\\MetaInstance.cpp\">\r\n      <Filter>Source Files\\Parsing</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\editors\\MemoryDesigner\\ConnectivityComponent.cpp\">\r\n      <Filter>Source Files</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\editors\\MemoryDesigner\\ConnectivityConnection.cpp\">\r\n      <Filter>Source Files</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\editors\\MemoryDesigner\\ConnectivityGraph.cpp\">\r\n      <Filter>Source Files</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\editors\\MemoryDesigner\\ConnectivityGraphFactory.cpp\">\r\n      <Filter>Source Files</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\editors\\MemoryDesigner\\ConnectivityInterface.cpp\">\r\n      <Filter>Source Files</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\editors\\MemoryDesigner\\MasterSlavePathSearch.cpp\">\r\n      <Filter>Source Files</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\editors\\MemoryDesigner\\MemoryItem.cpp\">\r\n      <Filter>Source Files</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\IPXACTmodels\\utilities\\ComponentSearch.cpp\">\r\n      <Filter>Source Files</Filter>\r\n    </ClCompile>\r\n    \r\n    \r\n  </ItemGroup>\r\n  <ItemGroup>\r\n    <ClInclude Include=\"MemoryViewGenerator.h\">\r\n      <Filter>Header Files</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"memoryviewgenerator_global.h\">\r\n      <Filter>Header Files</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\PluginSystem\\GeneratorPlugin\\GenerationControl.h\">\r\n      <Filter>Header Files\\GenerationControl</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\PluginSystem\\GeneratorPlugin\\OutputControl.h\">\r\n      <Filter>Header Files\\GenerationControl</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\PluginSystem\\GeneratorPlugin\\ViewSelection.h\">\r\n      <Filter>Header Files\\GenerationControl</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\common\\HDLParser\\MetaComponent.h\">\r\n      <Filter>Header Files\\Parsing</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\common\\HDLParser\\MetaDesign.h\">\r\n      <Filter>Header Files\\Parsing</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\common\\HDLParser\\MetaInstance.h\">\r\n      <Filter>Header Files\\Parsing</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\editors\\MemoryDesigner\\ConnectivityComponent.h\">\r\n      <Filter>Header Files</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\editors\\MemoryDesigner\\ConnectivityConnection.h\">\r\n      <Filter>Header Files</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\editors\\MemoryDesigner\\ConnectivityGraph.h\">\r\n      <Filter>Header Files</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\editors\\MemoryDesigner\\ConnectivityGraphFactory.h\">\r\n      <Filter>Header Files</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\editors\\MemoryDesigner\\ConnectivityInterface.h\">\r\n      <Filter>Header Files</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\editors\\MemoryDesigner\\MasterSlavePathSearch.h\">\r\n      <Filter>Header Files</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\editors\\MemoryDesigner\\MemoryItem.h\">\r\n      <Filter>Header Files</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\IPXACTmodels\\utilities\\ComponentSearch.h\">\r\n      <Filter>Header Files</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\IPXACTmodels\\utilities\\Search.h\">\r\n      <Filter>Header Files</Filter>\r\n    </ClInclude>\r\n  </ItemGroup>\r\n  <ItemGroup>\r\n    <QtRcc Include=\"MemoryViewGenerator.qrc\">\r\n      <Filter>Resource Files</Filter>\r\n    </QtRcc>\r\n    <QtMoc Include=\"MemoryViewGeneratorPlugin.h\">\r\n      <Filter>Header Files</Filter>\r\n    </QtMoc>\r\n  </ItemGroup>\r\n  <ItemGroup>\r\n    <None Include=\"memory.png\">\r\n      <Filter>Resource Files</Filter>\r\n    </None>\r\n  </ItemGroup>\r\n</Project>"
  },
  {
    "path": "Plugins/MemoryViewGenerator/MemoryViewGeneratorPlugin.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: MemoryViewGeneratorPlugin.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Esko Pekkarinen\r\n// Date: 25.04.2016\r\n//\r\n// Description:\r\n// Plugin for creating a CSV listing of all slave memories within a design hierarchy.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"MemoryViewGeneratorPlugin.h\"\r\n\r\n#include <Plugins/common/HDLParser/HDLParserCommon.h>\r\n#include <KactusAPI/include/IPluginUtility.h>\r\n#include <Plugins/PluginSystem/GeneratorPlugin/GenerationControl.h>\r\n\r\n#include <KactusAPI/include/LibraryInterface.h>\r\n\r\n#include <IPXACTmodels/Component/Component.h>\r\n#include <IPXACTmodels/Component/File.h>\r\n#include <IPXACTmodels/Component/FileSet.h>\r\n\r\n#include \"MemoryViewGenerator.h\"\r\n\r\n#include <QDateTime>\r\n#include <QFileDialog>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryViewGeneratorPlugin::MemoryViewGeneratorPlugin()\r\n//-----------------------------------------------------------------------------\r\nMemoryViewGeneratorPlugin::MemoryViewGeneratorPlugin()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryViewGeneratorPlugin::~MemoryViewGeneratorPlugin()\r\n//-----------------------------------------------------------------------------\r\nMemoryViewGeneratorPlugin::~MemoryViewGeneratorPlugin()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryViewGeneratorPlugin::getName()\r\n//-----------------------------------------------------------------------------\r\nQString MemoryViewGeneratorPlugin::getName() const\r\n{\r\n    return tr(\"Memory View Generator\");\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryViewGeneratorPlugin::getVersion()\r\n//-----------------------------------------------------------------------------\r\nQString MemoryViewGeneratorPlugin::getVersion() const\r\n{\r\n    return tr(\"0.2\");\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryViewGeneratorPlugin::getDescription()\r\n//-----------------------------------------------------------------------------\r\nQString MemoryViewGeneratorPlugin::getDescription() const\r\n{\r\n    return tr(\"Creates a CSV listing of all slave memories within a design hierarchy.\");\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryViewGeneratorPlugin::getVendor()\r\n//-----------------------------------------------------------------------------\r\nQString MemoryViewGeneratorPlugin::getVendor() const\r\n{\r\n    return tr(\"Tampere University (tuni.fi)\");\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryViewGeneratorPlugin::getLicense()\r\n//-----------------------------------------------------------------------------\r\nQString MemoryViewGeneratorPlugin::getLicense() const\r\n{\r\n    return tr(\"GPL2\");\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryViewGeneratorPlugin::getLicenseHolder()\r\n//-----------------------------------------------------------------------------\r\nQString MemoryViewGeneratorPlugin::getLicenseHolder() const\r\n{\r\n    return tr(\"Public\");\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryViewGeneratorPlugin::getSettingsWidget()\r\n//-----------------------------------------------------------------------------\r\nQWidget* MemoryViewGeneratorPlugin::getSettingsWidget()\r\n{\r\n    return nullptr;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryViewGeneratorPlugin::getProgramRequirements()\r\n//-----------------------------------------------------------------------------\r\nQList<IPlugin::ExternalProgramRequirement> MemoryViewGeneratorPlugin::getProgramRequirements()\r\n{\r\n    return QList<IPlugin::ExternalProgramRequirement>();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryViewGeneratorPlugin::getIcon()\r\n//-----------------------------------------------------------------------------\r\nQIcon MemoryViewGeneratorPlugin::getIcon() const\r\n{\r\n    return QIcon(\":icons/memory.png\");\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryViewGeneratorPlugin::checkGeneratorSupport()\r\n//-----------------------------------------------------------------------------\r\nbool MemoryViewGeneratorPlugin::checkGeneratorSupport(QSharedPointer<Component const> component,\r\n    QSharedPointer<Design const> design,\r\n    QSharedPointer<DesignConfiguration const> designConfiguration) const\r\n{\r\n    if (!component || component->getImplementation() != KactusAttribute::HW)\r\n    {\r\n        return false;\r\n    }\r\n\r\n    return design || designConfiguration;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryViewGeneratorPlugin::runGenerator()\r\n//-----------------------------------------------------------------------------\r\nvoid MemoryViewGeneratorPlugin::runGenerator(IPluginUtility* utility, \r\n    QSharedPointer<Component> component,\r\n    QSharedPointer<Design> design,\r\n    QSharedPointer<DesignConfiguration> designConfiguration)\r\n{\r\n    utility->printInfo(tr(\"Running %1 %2.\").arg(getName(), getVersion()));\r\n    \r\n    QString xmlFilePath = utility->getLibraryInterface()->getDirectoryPath(component->getVlnv());\r\n\r\n    QString targetFile = QFileDialog::getSaveFileName(utility->getParentWidget(), tr(\"Select target file\"), \r\n        xmlFilePath, tr(\"Comma separated values (*.csv)\"));\r\n\r\n    if (!targetFile.isEmpty())\r\n    {\r\n        GenerationTuple controlTuple;\r\n        controlTuple.component = component;\r\n        controlTuple.design = design;\r\n        controlTuple.designConfiguration = designConfiguration;\r\n\r\n        QSharedPointer<QList<QSharedPointer<View> > > views = GenerationControl::findPossibleViews(controlTuple);\r\n        QString activeView;\r\n        if (!views->isEmpty())\r\n        {\r\n            activeView = views->first()->name();\r\n        }\r\n\r\n        MemoryViewGenerator generator(utility->getLibraryInterface());\r\n        generator.generate(component, activeView, targetFile);\r\n\r\n        saveToFileset(targetFile, component, utility);\r\n\r\n        utility->printInfo(tr(\"Generation complete.\"));\r\n    }\r\n    else\r\n    {\r\n        utility->printInfo(tr(\"Generation aborted.\"));\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryViewGeneratorPlugin::saveToFileset()\r\n//-----------------------------------------------------------------------------\r\nvoid MemoryViewGeneratorPlugin::saveToFileset(QString const& targetFile, QSharedPointer<Component> component, \r\n    IPluginUtility* utility)\r\n{\r\n    QString xmlFilePath = utility->getLibraryInterface()->getDirectoryPath(component->getVlnv());\r\n\r\n    QSharedPointer<Component> topComponent = component.dynamicCast<Component>();\r\n\r\n    QString filesetName = \"memoryListings\";\r\n    QSharedPointer<FileSet> targetFileset = topComponent->getFileSet(filesetName);\r\n    if (!targetFileset)\r\n    {\r\n        targetFileset = QSharedPointer<FileSet>(new FileSet(filesetName));\r\n        topComponent->getFileSets()->append(targetFileset);\r\n    }\r\n\r\n    QString relativeFilePath = General::getRelativePath(xmlFilePath, targetFile);\r\n\r\n    QSharedPointer<File> file;\r\n    foreach (QSharedPointer<File> filesetFile, *targetFileset->getFiles())\r\n    {            \r\n        if (filesetFile->name().compare(relativeFilePath) == 0)\r\n        {\r\n            file = filesetFile;\r\n        }\r\n    }\r\n\r\n    if (!file)\r\n    {\r\n        file = QSharedPointer<File>(new File(relativeFilePath));\r\n        file->getFileTypes()->append(FileType(QStringLiteral(\"unknown\")));\r\n\r\n        targetFileset->addFile(file);\r\n        utility->printInfo(tr(\"Added file %1 to top component file set %2.\").arg(targetFile, filesetName));\r\n    }\r\n\r\n    file->setDescription(tr(\"Generated on %1 by Kactus2 %2 plugin version %3.\").arg(\r\n        QDateTime::currentDateTime().toString(\"dd.MM.yyyy hh:mm:ss\"), getName(), getVersion()));\r\n\r\n    utility->getLibraryInterface()->writeModelToFile(component);\r\n}\r\n"
  },
  {
    "path": "Plugins/MemoryViewGenerator/MemoryViewGeneratorPlugin.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: MemoryViewGeneratorPlugin.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Esko Pekkarinen\r\n// Date: 25.04.2016\r\n//\r\n// Description:\r\n// Plugin for creating a CSV listing of all slave memories within a design hierarchy.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef MEMORYVIEWGENERATORPLUGIN_H\r\n#define MEMORYVIEWGENERATORPLUGIN_H\r\n\r\n#include \"memoryviewgenerator_global.h\"\r\n\r\n#include <KactusAPI/include/IGeneratorPlugin.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Plugin for creating a CSV listing of all slave memories within a design hierarchy.\r\n//-----------------------------------------------------------------------------\r\nclass MEMORYVIEWGENERATOR_EXPORT MemoryViewGeneratorPlugin : public QObject, public IGeneratorPlugin\r\n{\r\n    Q_OBJECT\r\n    Q_PLUGIN_METADATA(IID \"kactus2.plugins.MemoryViewGeneratorPlugin\" FILE \"MemoryViewGenerator.json\")\r\n\r\n    Q_INTERFACES(IPlugin)\r\n    Q_INTERFACES(IGeneratorPlugin)\r\n\r\npublic:\r\n    \r\n    //! The constructor.\r\n    MemoryViewGeneratorPlugin();\r\n\r\n    //! The destructor.\r\n    ~MemoryViewGeneratorPlugin();\r\n\r\n    //! Returns the name of the plugin.\r\n    virtual QString getName() const;\r\n\r\n    //! Returns the version of the plugin.\r\n    virtual QString getVersion() const;\r\n\r\n    //! Returns the description of the plugin.\r\n    virtual QString getDescription() const;\r\n\r\n    //! Returns the vendor of the plugin.     \r\n    virtual QString getVendor() const;\r\n\r\n    //! Returns the license of the plugin.\r\n    virtual QString getLicense() const;\r\n\r\n    //! Returns the license holder i.e. who is the plugin licensed to.\r\n    virtual QString getLicenseHolder() const;\r\n\r\n    /*!\r\n     *  This can be used to show custom plugin-specific settings UI in the Kactus2 settings dialog.\r\n\t *  If the plugin has no custom settings, a null pointer should be returned.\r\n     */\r\n    virtual QWidget* getSettingsWidget();\r\n\r\n    /*!\r\n     *  This is used to access the settings modified by function getSettingsWidget().\r\n     */\r\n    virtual PluginSettingsModel* getSettingsModel(){return NULL;}\r\n\r\n    /*!\r\n     *  This can be used to indicate what external programs the plugin needs in order to operate correctly.\r\n\t *  This allows Kactus2 to show settings to set paths where those external program are located.\r\n     */\r\n\t virtual QList<ExternalProgramRequirement> getProgramRequirements();\r\n    \r\n    //! Returns the icon for the generator.\r\n    virtual QIcon getIcon() const;\r\n    \r\n    /*!\r\n     *  Checks whether the generator may run for the given component or design. \r\n     *\r\n     *    @param [in] component\t        The component for which to check support. If design is not null, component\r\n\t *                                      will refer to design or designConfiguration.\r\n     *    @param [in] design\t            The design, if the generator is ran for a design.\r\n     *    @param [in] designConfiguration The design configuration for design, if it is not null.\r\n     *\r\n     *    @return True, if the generator may run the given component. Otherwise false.\r\n     */\r\n    virtual bool checkGeneratorSupport(QSharedPointer<Component const> component,\r\n        QSharedPointer<Design const> design,\r\n        QSharedPointer<DesignConfiguration const> designConfiguration) const;\r\n   \r\n    /*!\r\n     *  Runs the generation, creating new files and/or modifying the IP-XACT metadata. The function has\r\n\t *  also access to the parent window widget, so that it can show dialogs for the user to aid the generation.\r\n     *\r\n     *    @param [in] utility\t\t\t    The plugin utility interface.\r\n     *    @param [in] component\t        The component for which to check support. If design is not null, component\r\n     *                                      will refer to design or designConfiguration.\r\n     *    @param [in] design\t            The design, if the generator is ran for a design.\r\n     *    @param [in] designConfiguration The design configuration for design, if it is not null.\r\n     */\r\n    virtual void runGenerator(IPluginUtility* utility, \r\n        QSharedPointer<Component> component,\r\n        QSharedPointer<Design> design,\r\n        QSharedPointer<DesignConfiguration> designConfiguration);\r\n\r\nprivate:\r\n    // Disable copying.\r\n    MemoryViewGeneratorPlugin(MemoryViewGeneratorPlugin const& rhs);\r\n    MemoryViewGeneratorPlugin& operator=(MemoryViewGeneratorPlugin const& rhs);\r\n\r\n    /*!\r\n     *  Saves the generated file to top component fileset.\r\n     *\r\n     *    @param [in] targetFile      The generated file path.\r\n     *    @param [in] component       The top level component.\r\n     *    @param [in] utility         The plugin utility interface.\r\n     *\r\n     *    @return <Description>.\r\n     */\r\n    void saveToFileset(QString const& targetFile, QSharedPointer<Component> component, IPluginUtility* utility);\r\n};\r\n\r\n#endif // MEMORYVIEWGENERATORPLUGIN_H\r\n"
  },
  {
    "path": "Plugins/MemoryViewGenerator/memoryviewgenerator_global.h",
    "content": "#ifndef MEMORYVIEWGENERATOR_GLOBAL_H\r\n#define MEMORYVIEWGENERATOR_GLOBAL_H\r\n\r\n#include <QtCore/qglobal.h>\r\n\r\n#ifdef MEMORYVIEWGENERATOR_LIB\r\n# define MEMORYVIEWGENERATOR_EXPORT Q_DECL_EXPORT\r\n#else\r\n# define MEMORYVIEWGENERATOR_EXPORT Q_DECL_IMPORT\r\n#endif\r\n\r\n#endif // MEMORYVIEWGENERATOR_GLOBAL_H\r\n"
  },
  {
    "path": "Plugins/ModelSimGenerator/ModelSimGenerator.pri",
    "content": "# ----------------------------------------------------\r\n# This file is generated by the Qt Visual Studio Tools.\r\n# ------------------------------------------------------\r\n\r\n\r\nHEADERS += ../../IPXACTmodels/utilities/ComponentSearch.h \\\r\n    ../../IPXACTmodels/utilities/Search.h \\\r\n    ./modelsimgenerator_global.h \\\r\n    ./ModelSimGeneratorPlugin.h \\\r\n    ../common/HDLParser/HDLParserCommon.h \\\r\n    ../common/HDLParser/MetaComponent.h \\\r\n    ../common/HDLParser/MetaDesign.h \\\r\n    ../common/HDLParser/MetaInstance.h \\\r\n    ../PluginSystem/GeneratorPlugin/GenerationControl.h \\\r\n    ../PluginSystem/GeneratorPlugin/OutputControl.h \\\r\n    ../PluginSystem/GeneratorPlugin/ViewSelection.h \\\r\n    ../PluginSystem/GeneratorPlugin/MessagePasser.h \\\r\n    ../../mainwindow/MessageConsole/messageconsole.h \\\r\n    ../PluginSystem/GeneratorPlugin/FileOutputWidget.h \\\r\n    ../PluginSystem/GeneratorPlugin/HDLGenerationDialog.h \\\r\n    ../PluginSystem/GeneratorPlugin/ViewSelectionWidget.h \\\r\n    ./ModelSimWriterFactory/ModelSimDocument.h \\\r\n    ./ModelSimWriterFactory/ModelSimWriter.h \\\r\n    ./ModelSimWriterFactory/ModelSimWriterFactory.h \\\r\n    ../PluginSystem/GeneratorPlugin/IWriterFactory.h\r\nSOURCES += ../../IPXACTmodels/utilities/ComponentSearch.cpp \\\r\n    ./ModelSimGeneratorPlugin.cpp \\\r\n    ../common/HDLParser/MetaComponent.cpp \\\r\n    ../common/HDLParser/MetaDesign.cpp \\\r\n    ../common/HDLParser/MetaInstance.cpp \\\r\n    ../PluginSystem/GeneratorPlugin/GenerationControl.cpp \\\r\n    ../PluginSystem/GeneratorPlugin/MessagePasser.cpp \\\r\n    ../PluginSystem/GeneratorPlugin/OutputControl.cpp \\\r\n    ../PluginSystem/GeneratorPlugin/ViewSelection.cpp \\\r\n    ../../mainwindow/MessageConsole/messageconsole.cpp \\\r\n    ../PluginSystem/GeneratorPlugin/FileOutputWidget.cpp \\\r\n    ../PluginSystem/GeneratorPlugin/HDLGenerationDialog.cpp \\\r\n    ../PluginSystem/GeneratorPlugin/ViewSelectionWidget.cpp \\\r\n    ./ModelSimWriterFactory/ModelSimDocument.cpp \\\r\n    ./ModelSimWriterFactory/ModelSimWriter.cpp \\\r\n    ./ModelSimWriterFactory/ModelSimWriterFactory.cpp\r\nRESOURCES += ModelSimGenerator.qrc\r\n"
  },
  {
    "path": "Plugins/ModelSimGenerator/ModelSimGenerator.pro",
    "content": "# ----------------------------------------------------\r\n# This file is generated by the Qt Visual Studio Add-in.\r\n# ------------------------------------------------------\r\n\r\nTEMPLATE = lib\r\n\r\nQT += core xml widgets gui\r\nCONFIG += c++11 plugin\r\n\r\nDEFINES += MODELSIMGENERATOR_LIB\r\n\r\nINCLUDEPATH += ./../.. \\\r\n    ./GeneratedFiles \\\r\n    .\r\n\r\nCONFIG(debug, debug|release) {\r\n    # debug mode\r\n    LIBS += \\\r\n        -L../../executable -lIPXACTmodelsd \\\r\n        -L../../executable -lKactusAPId\r\n\r\n    MOC_DIR += ./GeneratedFiles/Debug\r\n    OBJECTS_DIR += Debug\r\n    TARGET = ModelSimGeneratord\r\n\r\n} else {\r\n    # release mode \r\n    LIBS += \\\r\n        -L../../executable -lIPXACTmodels \\\r\n        -L../../executable -lKactusAPI\r\n    \r\n    MOC_DIR += ./GeneratedFiles/Release\r\n    OBJECTS_DIR += Release\r\n    TARGET = ModelSimGenerator\r\n}\r\n\r\nDESTDIR = ../../executable/Plugins\r\n\r\nDEPENDPATH += .\r\nUI_DIR += ./GeneratedFiles\r\nRCC_DIR += ./GeneratedFiles\r\n\r\ninclude(ModelSimGenerator.pri)\r\n\r\ntarget.path = $$plugin_path\r\nINSTALLS += target\r\n\r\n"
  },
  {
    "path": "Plugins/ModelSimGenerator/ModelSimGenerator.qrc",
    "content": "<RCC>\r\n    <qresource prefix=\"/icons\">\r\n        <file>ModelSimGenerator.png</file>\r\n    </qresource>\r\n</RCC>\r\n"
  },
  {
    "path": "Plugins/ModelSimGenerator/ModelSimGenerator.vcxproj",
    "content": "﻿<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n<Project DefaultTargets=\"Build\" ToolsVersion=\"15.0\" xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">\r\n  <ItemGroup Label=\"ProjectConfigurations\">\r\n    <ProjectConfiguration Include=\"Debug|x64\">\r\n      <Configuration>Debug</Configuration>\r\n      <Platform>x64</Platform>\r\n    </ProjectConfiguration>\r\n    <ProjectConfiguration Include=\"Release|x64\">\r\n      <Configuration>Release</Configuration>\r\n      <Platform>x64</Platform>\r\n    </ProjectConfiguration>\r\n  </ItemGroup>\r\n  <PropertyGroup Label=\"Globals\">\r\n    <ProjectGuid>{09C39723-AF6B-4F3B-81C7-3233E7F8A22E}</ProjectGuid>\r\n    <Keyword>QtVS_v304</Keyword>\r\n    <WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>\r\n    <QtMsBuild Condition=\"'$(QtMsBuild)'=='' or !Exists('$(QtMsBuild)\\qt.targets')\">$(MSBuildProjectDirectory)\\QtMsBuild</QtMsBuild>\r\n  </PropertyGroup>\r\n  <Import Project=\"$(VCTargetsPath)\\Microsoft.Cpp.Default.props\" />\r\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\" Label=\"Configuration\">\r\n    <ConfigurationType>DynamicLibrary</ConfigurationType>\r\n    <PlatformToolset>v143</PlatformToolset>\r\n  </PropertyGroup>\r\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\" Label=\"Configuration\">\r\n    <ConfigurationType>DynamicLibrary</ConfigurationType>\r\n    <PlatformToolset>v143</PlatformToolset>\r\n  </PropertyGroup>\r\n  <Import Project=\"$(VCTargetsPath)\\Microsoft.Cpp.props\" />\r\n  <Target Name=\"QtMsBuildNotFound\" BeforeTargets=\"CustomBuild;ClCompile\" Condition=\"!Exists('$(QtMsBuild)\\qt.targets') or !Exists('$(QtMsBuild)\\qt.props')\">\r\n    <Message Importance=\"High\" Text=\"QtMsBuild: could not locate qt.targets, qt.props; project may not build correctly.\" />\r\n  </Target>\r\n  <ImportGroup Label=\"ExtensionSettings\">\r\n  </ImportGroup>\r\n  <ImportGroup Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\" Label=\"PropertySheets\">\r\n    <Import Project=\"$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props\" Condition=\"exists('$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props')\" Label=\"LocalAppDataPlatform\" />\r\n  </ImportGroup>\r\n  <ImportGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\" Label=\"PropertySheets\">\r\n    <Import Project=\"$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props\" Condition=\"exists('$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props')\" Label=\"LocalAppDataPlatform\" />\r\n  </ImportGroup>\r\n  <PropertyGroup Label=\"UserMacros\" />\r\n  <ImportGroup Condition=\"Exists('$(QtMsBuild)\\qt_defaults.props')\">\r\n    <Import Project=\"$(QtMsBuild)\\qt_defaults.props\" />\r\n  </ImportGroup>\r\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n    <OutDir>$(SolutionDir)executable\\Plugins\\</OutDir>\r\n    <IntDir>$(ProjectDir)\\$(Configuration)\\</IntDir>\r\n  </PropertyGroup>\r\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n    <OutDir>$(SolutionDir)executable\\Plugins\\</OutDir>\r\n    <IntDir>$(ProjectDir)\\$(Configuration)\\</IntDir>\r\n  </PropertyGroup>\r\n  <PropertyGroup Label=\"QtSettings\" Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n    <QtInstall>6.2.4</QtInstall>\r\n    <QtModules>core;gui;widgets;xml</QtModules>\r\n  </PropertyGroup>\r\n  <PropertyGroup Label=\"QtSettings\" Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n    <QtInstall>6.2.4</QtInstall>\r\n    <QtModules>core;gui;widgets;xml</QtModules>\r\n  </PropertyGroup>\r\n  <ImportGroup Condition=\"Exists('$(QtMsBuild)\\qt.props')\">\r\n    <Import Project=\"$(QtMsBuild)\\qt.props\" />\r\n  </ImportGroup>\r\n  <PropertyGroup>\r\n    <_ProjectFileVersion>10.0.40219.1</_ProjectFileVersion>\r\n  </PropertyGroup>\r\n  <ItemDefinitionGroup Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n    <ClCompile>\r\n      <PreprocessorDefinitions>MODELSIMGENERATOR_LIB;UNICODE;WIN32;WIN64;%(PreprocessorDefinitions)</PreprocessorDefinitions>\r\n      <AdditionalIncludeDirectories>.\\GeneratedFiles\\$(ConfigurationName);.\\GeneratedFiles;.\\..\\..;.;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\r\n      <Optimization>Disabled</Optimization>\r\n      <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>\r\n      <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>\r\n      <TreatWChar_tAsBuiltInType>true</TreatWChar_tAsBuiltInType>\r\n      <MultiProcessorCompilation>true</MultiProcessorCompilation>\r\n      <LanguageStandard>stdcpp17</LanguageStandard>\r\n      <AdditionalOptions>/Zc:__cplusplus %(AdditionalOptions)</AdditionalOptions>\r\n    </ClCompile>\r\n    <Link>\r\n      <SubSystem>Windows</SubSystem>\r\n      <OutputFile>$(OutDir)\\$(ProjectName).dll</OutputFile>\r\n      <AdditionalLibraryDirectories>..\\..\\executable;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>\r\n      <GenerateDebugInformation>true</GenerateDebugInformation>\r\n      <AdditionalDependencies>IPXACTmodelsd.lib;KactusAPId.lib;%(AdditionalDependencies)</AdditionalDependencies>\r\n      <TargetMachine>MachineX64</TargetMachine>\r\n      <AdditionalOptions> /SUBSYSTEM:WINDOWS</AdditionalOptions>\r\n    </Link>\r\n    <QtMoc>\r\n      <ExecutionDescription>Moc'ing %(Identity)...</ExecutionDescription>\r\n      <DynamicSource>output</DynamicSource>\r\n      <QtMocDir>.\\GeneratedFiles\\$(ConfigurationName)</QtMocDir>\r\n      <QtMocFileName>moc_%(Filename).cpp</QtMocFileName>\r\n    </QtMoc>\r\n    <QtRcc>\r\n      <InitFuncName>%(Filename)</InitFuncName>\r\n      <Compression>default</Compression>\r\n      <NoCompression>true</NoCompression>\r\n      <ExecutionDescription>Rcc'ing %(Identity)...</ExecutionDescription>\r\n      <QtRccDir>.\\GeneratedFiles</QtRccDir>\r\n      <QtRccFileName>qrc_%(Filename).cpp</QtRccFileName>\r\n    </QtRcc>\r\n  </ItemDefinitionGroup>\r\n  <ItemDefinitionGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n    <ClCompile>\r\n      <PreprocessorDefinitions>MODELSIMGENERATOR_LIB;NDEBUG;QT_NO_DEBUG;UNICODE;WIN32;WIN64;%(PreprocessorDefinitions)</PreprocessorDefinitions>\r\n      <AdditionalIncludeDirectories>.\\GeneratedFiles\\$(ConfigurationName);.\\GeneratedFiles;.\\..\\..;.;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\r\n      <DebugInformationFormat>\r\n      </DebugInformationFormat>\r\n      <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>\r\n      <TreatWChar_tAsBuiltInType>true</TreatWChar_tAsBuiltInType>\r\n      <MultiProcessorCompilation>true</MultiProcessorCompilation>\r\n      <AdditionalOptions>/Zc:__cplusplus %(AdditionalOptions)</AdditionalOptions>\r\n      <LanguageStandard>stdcpp17</LanguageStandard>\r\n    </ClCompile>\r\n    <Link>\r\n      <SubSystem>Windows</SubSystem>\r\n      <OutputFile>$(OutDir)\\$(ProjectName).dll</OutputFile>\r\n      <AdditionalLibraryDirectories>..\\..\\executable;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>\r\n      <GenerateDebugInformation>false</GenerateDebugInformation>\r\n      <AdditionalDependencies>IPXACTmodels.lib;KactusAPI.lib;%(AdditionalDependencies)</AdditionalDependencies>\r\n      <TargetMachine>MachineX64</TargetMachine>\r\n      <AdditionalOptions> /SUBSYSTEM:WINDOWS</AdditionalOptions>\r\n    </Link>\r\n    <QtMoc>\r\n      <ExecutionDescription>Moc'ing %(Identity)...</ExecutionDescription>\r\n      <DynamicSource>output</DynamicSource>\r\n      <QtMocDir>.\\GeneratedFiles\\$(ConfigurationName)</QtMocDir>\r\n      <QtMocFileName>moc_%(Filename).cpp</QtMocFileName>\r\n    </QtMoc>\r\n    <QtRcc>\r\n      <InitFuncName>%(Filename)</InitFuncName>\r\n      <Compression>default</Compression>\r\n      <NoCompression>true</NoCompression>\r\n      <ExecutionDescription>Rcc'ing %(Identity)...</ExecutionDescription>\r\n      <QtRccDir>.\\GeneratedFiles</QtRccDir>\r\n      <QtRccFileName>qrc_%(Filename).cpp</QtRccFileName>\r\n    </QtRcc>\r\n  </ItemDefinitionGroup>\r\n  <ItemGroup>\r\n    <ClCompile Include=\"..\\..\\IPXACTmodels\\utilities\\ComponentSearch.cpp\" />\r\n    <ClCompile Include=\"..\\..\\mainwindow\\MessageConsole\\messageconsole.cpp\" />\r\n    <ClCompile Include=\"..\\common\\HDLParser\\MetaComponent.cpp\" />\r\n    <ClCompile Include=\"..\\common\\HDLParser\\MetaDesign.cpp\" />\r\n    <ClCompile Include=\"..\\common\\HDLParser\\MetaInstance.cpp\" />\r\n    <ClCompile Include=\"..\\PluginSystem\\GeneratorPlugin\\AddToFilesetWidget.cpp\" />\r\n    <ClCompile Include=\"..\\PluginSystem\\GeneratorPlugin\\FileOutputWidget.cpp\" />\r\n    <ClCompile Include=\"..\\PluginSystem\\GeneratorPlugin\\GenerationControl.cpp\" />\r\n    <ClCompile Include=\"..\\PluginSystem\\GeneratorPlugin\\HDLGenerationDialog.cpp\" />\r\n    <ClCompile Include=\"..\\PluginSystem\\GeneratorPlugin\\MessagePasser.cpp\" />\r\n    <ClCompile Include=\"..\\PluginSystem\\GeneratorPlugin\\OutputControl.cpp\" />\r\n    <ClCompile Include=\"..\\PluginSystem\\GeneratorPlugin\\ViewSelection.cpp\" />\r\n    <ClCompile Include=\"..\\PluginSystem\\GeneratorPlugin\\ViewSelectionWidget.cpp\" />\r\n    <ClCompile Include=\"ModelSimGeneratorPlugin.cpp\" />\r\n    <ClCompile Include=\"ModelSimWriterFactory\\ModelSimDocument.cpp\" />\r\n    <ClCompile Include=\"ModelSimWriterFactory\\ModelSimWriter.cpp\" />\r\n    <ClCompile Include=\"ModelSimWriterFactory\\ModelSimWriterFactory.cpp\" />\r\n  </ItemGroup>\r\n  <ItemGroup>\r\n    <None Include=\"modelSimGenerator.json\" />\r\n    <None Include=\"ModelSimGenerator.png\">\r\n      <ExcludedFromBuild Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">true</ExcludedFromBuild>\r\n      <ExcludedFromBuild Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">true</ExcludedFromBuild>\r\n    </None>\r\n    <QtRcc Include=\"ModelSimGenerator.qrc\">\r\n    </QtRcc>\r\n  </ItemGroup>\r\n  <ItemGroup>\r\n    <ClInclude Include=\"..\\..\\IPXACTmodels\\utilities\\ComponentSearch.h\" />\r\n    <ClInclude Include=\"..\\..\\IPXACTmodels\\utilities\\Search.h\" />\r\n    <QtMoc Include=\"..\\PluginSystem\\GeneratorPlugin\\AddToFilesetWidget.h\" />\r\n    <ClInclude Include=\"ModelSimWriterFactory\\ModelSimDocument.h\" />\r\n    <ClInclude Include=\"ModelSimWriterFactory\\ModelSimWriter.h\" />\r\n    <ClInclude Include=\"ModelSimWriterFactory\\ModelSimWriterFactory.h\" />\r\n    <QtMoc Include=\"ModelSimGeneratorPlugin.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"..\\..\\mainwindow\\MessageConsole\\messageconsole.h\">\r\n    </QtMoc>\r\n    <ClInclude Include=\"..\\common\\HDLParser\\HDLParserCommon.h\" />\r\n    <ClInclude Include=\"..\\common\\HDLParser\\MetaComponent.h\" />\r\n    <ClInclude Include=\"..\\common\\HDLParser\\MetaDesign.h\" />\r\n    <ClInclude Include=\"..\\common\\HDLParser\\MetaInstance.h\" />\r\n    <QtMoc Include=\"..\\PluginSystem\\GeneratorPlugin\\FileOutputWidget.h\">\r\n    </QtMoc>\r\n    <ClInclude Include=\"..\\PluginSystem\\GeneratorPlugin\\GenerationControl.h\" />\r\n    <QtMoc Include=\"..\\PluginSystem\\GeneratorPlugin\\HDLGenerationDialog.h\">\r\n    </QtMoc>\r\n    <ClInclude Include=\"..\\PluginSystem\\GeneratorPlugin\\IWriterFactory.h\" />\r\n    <QtMoc Include=\"..\\PluginSystem\\GeneratorPlugin\\MessagePasser.h\">\r\n    </QtMoc>\r\n    <ClInclude Include=\"..\\PluginSystem\\GeneratorPlugin\\OutputControl.h\" />\r\n    <ClInclude Include=\"..\\PluginSystem\\GeneratorPlugin\\ViewSelection.h\" />\r\n    <QtMoc Include=\"..\\PluginSystem\\GeneratorPlugin\\ViewSelectionWidget.h\">\r\n    </QtMoc>\r\n    <ClInclude Include=\"modelsimgenerator_global.h\" />\r\n  </ItemGroup>\r\n  <Import Project=\"$(VCTargetsPath)\\Microsoft.Cpp.targets\" />\r\n  <ImportGroup Condition=\"Exists('$(QtMsBuild)\\qt.targets')\">\r\n    <Import Project=\"$(QtMsBuild)\\qt.targets\" />\r\n  </ImportGroup>\r\n  <ImportGroup Label=\"ExtensionTargets\">\r\n  </ImportGroup>\r\n  <ProjectExtensions>\r\n    <VisualStudio>\r\n      <UserProperties />\r\n    </VisualStudio>\r\n  </ProjectExtensions>\r\n</Project>"
  },
  {
    "path": "Plugins/ModelSimGenerator/ModelSimGenerator.vcxproj.filters",
    "content": "﻿<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n<Project ToolsVersion=\"4.0\" xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">\r\n  <ItemGroup>\r\n    <Filter Include=\"Source Files\">\r\n      <UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>\r\n      <Extensions>cpp;cxx;c;def</Extensions>\r\n    </Filter>\r\n    <Filter Include=\"Header Files\">\r\n      <UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>\r\n      <Extensions>h</Extensions>\r\n    </Filter>\r\n    <Filter Include=\"Resource Files\">\r\n      <UniqueIdentifier>{D9D6E242-F8AF-46E4-B9FD-80ECBC20BA3E}</UniqueIdentifier>\r\n      <Extensions>qrc;*</Extensions>\r\n      <ParseFiles>false</ParseFiles>\r\n    </Filter>\r\n    <Filter Include=\"Generated Files\">\r\n      <UniqueIdentifier>{71ED8ED8-ACB9-4CE9-BBE1-E00B30144E11}</UniqueIdentifier>\r\n      <Extensions>moc;h;cpp</Extensions>\r\n      <SourceControlFiles>False</SourceControlFiles>\r\n    </Filter>\r\n    <Filter Include=\"Generated Files\\Debug\">\r\n      <UniqueIdentifier>{1cab6335-8bf0-428b-b527-f4a97b93cf03}</UniqueIdentifier>\r\n      <Extensions>cpp;moc</Extensions>\r\n      <SourceControlFiles>False</SourceControlFiles>\r\n    </Filter>\r\n    <Filter Include=\"Generated Files\\Release\">\r\n      <UniqueIdentifier>{bcbe60b9-a5b8-4d37-b79f-8c561fe0c86a}</UniqueIdentifier>\r\n      <Extensions>cpp;moc</Extensions>\r\n      <SourceControlFiles>False</SourceControlFiles>\r\n    </Filter>\r\n    <Filter Include=\"Header Files\\Parsing\">\r\n      <UniqueIdentifier>{d3bbdfb7-dff1-4897-b8d3-d49b89c8cb76}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Source Files\\Parsing\">\r\n      <UniqueIdentifier>{8bfc3890-9aa1-40f3-a4b4-55445b974b81}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Header Files\\GenerationControl\">\r\n      <UniqueIdentifier>{ebb899ad-7b28-44ae-92f5-a44282cb51fb}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Source Files\\GenerationControl\">\r\n      <UniqueIdentifier>{62f412f1-2d73-439f-a71f-dd47aa072532}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Header Files\\Widgets\">\r\n      <UniqueIdentifier>{041a6a83-8e20-472a-8812-690dc976d657}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Source Files\\Widgets\">\r\n      <UniqueIdentifier>{1bc67e41-2988-4b1c-b5cb-ef22743b4c8a}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Source Files\\ModelSimWriterFactory\">\r\n      <UniqueIdentifier>{22a40d0a-3a8e-4d5d-9e13-749a56b459cd}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Header Files\\ModelSimWriterFactory\">\r\n      <UniqueIdentifier>{d1f9c4db-5320-4116-92fb-6dd636905c94}</UniqueIdentifier>\r\n    </Filter>\r\n  </ItemGroup>\r\n  <ItemGroup>\r\n    <ClCompile Include=\"ModelSimGeneratorPlugin.cpp\">\r\n      <Filter>Source Files</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\common\\HDLParser\\MetaComponent.cpp\">\r\n      <Filter>Source Files\\Parsing</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\common\\HDLParser\\MetaDesign.cpp\">\r\n      <Filter>Source Files\\Parsing</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\common\\HDLParser\\MetaInstance.cpp\">\r\n      <Filter>Source Files\\Parsing</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\PluginSystem\\GeneratorPlugin\\MessagePasser.cpp\">\r\n      <Filter>Source Files\\GenerationControl</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\PluginSystem\\GeneratorPlugin\\OutputControl.cpp\">\r\n      <Filter>Source Files\\GenerationControl</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\PluginSystem\\GeneratorPlugin\\ViewSelection.cpp\">\r\n      <Filter>Source Files\\GenerationControl</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\PluginSystem\\GeneratorPlugin\\GenerationControl.cpp\">\r\n      <Filter>Source Files\\GenerationControl</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\PluginSystem\\GeneratorPlugin\\ViewSelectionWidget.cpp\">\r\n      <Filter>Source Files\\Widgets</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\PluginSystem\\GeneratorPlugin\\HDLGenerationDialog.cpp\">\r\n      <Filter>Source Files\\Widgets</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\PluginSystem\\GeneratorPlugin\\FileOutputWidget.cpp\">\r\n      <Filter>Source Files\\Widgets</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\mainwindow\\MessageConsole\\messageconsole.cpp\">\r\n      <Filter>Source Files\\Widgets</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"ModelSimWriterFactory\\ModelSimWriterFactory.cpp\">\r\n      <Filter>Source Files\\ModelSimWriterFactory</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"ModelSimWriterFactory\\ModelSimDocument.cpp\">\r\n      <Filter>Source Files\\ModelSimWriterFactory</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"ModelSimWriterFactory\\ModelSimWriter.cpp\">\r\n      <Filter>Source Files\\ModelSimWriterFactory</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\IPXACTmodels\\utilities\\ComponentSearch.cpp\">\r\n      <Filter>Source Files</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\PluginSystem\\GeneratorPlugin\\AddToFilesetWidget.cpp\">\r\n      <Filter>Source Files\\Widgets</Filter>\r\n    </ClCompile>\r\n  </ItemGroup>\r\n  <ItemGroup>\r\n    <QtRcc Include=\"ModelSimGenerator.qrc\">\r\n      <Filter>Resource Files</Filter>\r\n    </QtRcc>\r\n    <QtMoc Include=\"ModelSimGeneratorPlugin.h\">\r\n      <Filter>Header Files</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"..\\PluginSystem\\GeneratorPlugin\\MessagePasser.h\">\r\n      <Filter>Header Files\\GenerationControl</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"..\\PluginSystem\\GeneratorPlugin\\FileOutputWidget.h\">\r\n      <Filter>Header Files\\Widgets</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"..\\PluginSystem\\GeneratorPlugin\\ViewSelectionWidget.h\">\r\n      <Filter>Header Files\\Widgets</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"..\\PluginSystem\\GeneratorPlugin\\HDLGenerationDialog.h\">\r\n      <Filter>Header Files\\Widgets</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"..\\..\\mainwindow\\MessageConsole\\messageconsole.h\">\r\n      <Filter>Header Files\\Widgets</Filter>\r\n    </QtMoc>\r\n  </ItemGroup>\r\n  <ItemGroup>\r\n    <None Include=\"modelSimGenerator.json\" />\r\n    <None Include=\"ModelSimGenerator.png\">\r\n      <Filter>Resource Files</Filter>\r\n    </None>\r\n  </ItemGroup>\r\n  <ItemGroup>\r\n    <ClInclude Include=\"modelsimgenerator_global.h\">\r\n      <Filter>Header Files</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\common\\HDLParser\\HDLParserCommon.h\">\r\n      <Filter>Header Files\\Parsing</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\common\\HDLParser\\MetaComponent.h\">\r\n      <Filter>Header Files\\Parsing</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\common\\HDLParser\\MetaDesign.h\">\r\n      <Filter>Header Files\\Parsing</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\common\\HDLParser\\MetaInstance.h\">\r\n      <Filter>Header Files\\Parsing</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\PluginSystem\\GeneratorPlugin\\GenerationControl.h\">\r\n      <Filter>Header Files\\GenerationControl</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\PluginSystem\\GeneratorPlugin\\OutputControl.h\">\r\n      <Filter>Header Files\\GenerationControl</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\PluginSystem\\GeneratorPlugin\\ViewSelection.h\">\r\n      <Filter>Header Files\\GenerationControl</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"ModelSimWriterFactory\\ModelSimDocument.h\">\r\n      <Filter>Header Files\\ModelSimWriterFactory</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"ModelSimWriterFactory\\ModelSimWriterFactory.h\">\r\n      <Filter>Header Files\\ModelSimWriterFactory</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"ModelSimWriterFactory\\ModelSimWriter.h\">\r\n      <Filter>Header Files\\ModelSimWriterFactory</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\PluginSystem\\GeneratorPlugin\\IWriterFactory.h\">\r\n      <Filter>Header Files\\ModelSimWriterFactory</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\IPXACTmodels\\utilities\\ComponentSearch.h\">\r\n      <Filter>Header Files</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\IPXACTmodels\\utilities\\Search.h\">\r\n      <Filter>Header Files</Filter>\r\n    </ClInclude>\r\n  </ItemGroup>\r\n  <ItemGroup>\r\n    <QtMoc Include=\"..\\PluginSystem\\GeneratorPlugin\\AddToFilesetWidget.h\">\r\n      <Filter>Header Files\\Widgets</Filter>\r\n    </QtMoc>\r\n  </ItemGroup>\r\n</Project>"
  },
  {
    "path": "Plugins/ModelSimGenerator/ModelSimGeneratorPlugin.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ModelSimGeneratorPlugin.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Janne Virtanen\r\n// Date: 10.06.2016\r\n//\r\n// Description:\r\n// ModelSim generator plugin.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"ModelSimGeneratorPlugin.h\"\r\n\r\n#include \"ModelSimWriterFactory/ModelSimWriterFactory.h\"\r\n\r\n#include <Plugins/common/LanguageHighlighter.h>\r\n#include <KactusAPI/include/IPluginUtility.h>\r\n#include <Plugins/PluginSystem/GeneratorPlugin/MessagePasser.h>\r\n#include <Plugins/PluginSystem/GeneratorPlugin/HDLGenerationDialog.h>\r\n\r\n#include <IPXACTmodels/Design/Design.h>\r\n#include <IPXACTmodels/DesignConfiguration/DesignConfiguration.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ModelSimGeneratorPlugin::ModelSimGeneratorPlugin()\r\n//-----------------------------------------------------------------------------\r\nModelSimGeneratorPlugin::ModelSimGeneratorPlugin() : QObject(0)\r\n{\r\n    settings_.generateInterfaces_ = false;\r\n    settings_.lastFileSetName_ = \"\";\r\n    settings_.lastViewName_ = \"\";\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ModelSimGeneratorPlugin::getName()\r\n//----------------------------------------------------------------------------\r\nQString ModelSimGeneratorPlugin::getName() const\r\n{\r\n    return \"ModelSim Generator\";\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ModelSimGeneratorPlugin::getVersion()\r\n//-----------------------------------------------------------------------------\r\nQString ModelSimGeneratorPlugin::getVersion() const\r\n{\r\n    return \"2.2\";\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ModelSimGeneratorPlugin::getDescription()\r\n//-----------------------------------------------------------------------------\r\nQString ModelSimGeneratorPlugin::getDescription() const\r\n{\r\n\treturn \"Generates a ModelSim do file, which adds the files in design to the active ModelSim project.\";\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ModelSimGeneratorPlugin::getVendor()\r\n//-----------------------------------------------------------------------------\r\nQString ModelSimGeneratorPlugin::getVendor() const\r\n{\r\n    return tr(\"Tampere University (tuni.fi)\");\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ModelSimGeneratorPlugin::getLicense()\r\n//-----------------------------------------------------------------------------\r\nQString ModelSimGeneratorPlugin::getLicense() const\r\n{\r\n    return tr(\"GPL2\");\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ModelSimGeneratorPlugin::getLicenseHolder()\r\n//-----------------------------------------------------------------------------\r\nQString ModelSimGeneratorPlugin::getLicenseHolder() const\r\n{\r\n    return tr(\"Public\");\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ModelSimGeneratorPlugin::getSettingsWidget()\r\n//-----------------------------------------------------------------------------\r\nQWidget* ModelSimGeneratorPlugin::getSettingsWidget()\r\n{\r\n    return nullptr;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ModelSimGeneratorPlugin::getIcon()\r\n//-----------------------------------------------------------------------------\r\nQIcon ModelSimGeneratorPlugin::getIcon() const\r\n{\r\n    return QIcon(\":icons/ModelSimGenerator.png\");\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ModelSimGeneratorPlugin::checkGeneratorSupport()\r\n//-----------------------------------------------------------------------------\r\nbool ModelSimGeneratorPlugin::checkGeneratorSupport(QSharedPointer<Component const> component,\r\n    QSharedPointer<Design const> design,\r\n    QSharedPointer<DesignConfiguration const> designConfiguration) const\r\n{\r\n    // If design or design configuration exists, their implementation overrides the top component.\r\n    if (design)\r\n    {\r\n        return design->getImplementation() == KactusAttribute::HW;\r\n    }\r\n\r\n    if (designConfiguration)\r\n    {\r\n        return designConfiguration->getImplementation() == KactusAttribute::HW;\r\n    }\r\n\r\n    // Else the availability is determined based on the top component.\r\n    return component && component->getImplementation() == KactusAttribute::HW;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ModelSimGeneratorPlugin::runGenerator()\r\n//-----------------------------------------------------------------------------\r\nvoid ModelSimGeneratorPlugin::runGenerator(IPluginUtility* utility, \r\n    QSharedPointer<Component> component,\r\n    QSharedPointer<Design> design,\r\n    QSharedPointer<DesignConfiguration> designConfiguration)\r\n{\r\n    // First state we are running. Tell the version.\r\n    utility->printInfo(tr(\"Running %1 %2.\").arg(getName(), getVersion()));\r\n\r\n    // Must have a component under any condition.\r\n    if (!component)\r\n    {\r\n        utility->printError(tr(\"Null component given as a parameter.\"));\r\n        return;\r\n    }\r\n\r\n    MessagePasser messages;\r\n\r\n    GenerationTuple input;\r\n    input.component = component;\r\n    input.design = design;\r\n    input.designConfiguration = designConfiguration;\r\n    input.messages = &messages;\r\n\r\n    ModelSimWriterFactory factory(utility->getLibraryInterface(), &messages, &settings_,\r\n        utility->getKactusVersion(), getVersion());\r\n\r\n    // Create model for the configuration widget.\r\n    QSharedPointer<GenerationControl> configuration(new GenerationControl\r\n        (utility->getLibraryInterface(), &factory, input, &settings_));\r\n\r\n    // Create the dialog and execute: The user will ultimately accept the configuration.\r\n    HDLGenerationDialog dialog(configuration, \"ModelSim\", utility->getParentWidget());\r\n\r\n    connect(&messages, SIGNAL(errorMessage(const QString&)),\r\n        &dialog, SLOT(onErrorMessage(const QString&)), Qt::UniqueConnection);\r\n    connect(&messages, SIGNAL(noticeMessage(const QString&)),\r\n        & dialog, SLOT(onNoticeMessage(const QString&)), Qt::UniqueConnection);\r\n\r\n    dialog.onViewChanged();\r\n\r\n    if (dialog.exec() != QDialog::Accepted)\r\n    {\r\n        utility->printInfo(tr(\"Generation aborted.\"));\r\n        return;\r\n    }\r\n\r\n    // Finally, save the changes.\r\n    utility->printInfo(tr(\"Generation complete.\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ModelSimGeneratorPlugin::runGenerator()\r\n//-----------------------------------------------------------------------------\r\nvoid ModelSimGeneratorPlugin::runGenerator(IPluginUtility* utility, QSharedPointer<Component> component, \r\n    QSharedPointer<Design> design, QSharedPointer<DesignConfiguration> designConfiguration, \r\n    QString const& viewName, QString const& outputDirectory)\r\n{\r\n    utility->printInfo(tr(\"Running %1 %2.\").arg(getName(), getVersion()));\r\n\r\n    if (component == nullptr)\r\n    {\r\n        utility->printError(tr(\"Null component given as a parameter.\"));\r\n        return;\r\n    }\r\n\r\n    MessagePasser messages;\r\n\r\n    GenerationTuple input;\r\n    input.component = component;\r\n    input.design = design;\r\n    input.designConfiguration = designConfiguration;\r\n    input.messages = &messages;\r\n    \r\n    settings_.lastViewName_ = viewName;\r\n    \r\n    ModelSimWriterFactory factory(utility->getLibraryInterface(), &messages, &settings_,\r\n        utility->getKactusVersion(), getVersion());\r\n    \r\n    // Create model for the configuration widget.\r\n    QSharedPointer<GenerationControl> configuration(new GenerationControl\r\n    (utility->getLibraryInterface(), &factory, input, &settings_));\r\n\r\n    configuration->getOutputControl()->setOutputPath(outputDirectory);\r\n\r\n    configuration->parseDocuments();\r\n\r\n    QString warning;\r\n    if (!configuration->validSelections(warning))\r\n    {        \r\n        utility->printError(warning);\r\n        return;\r\n    }\r\n\r\n    if (configuration->writeDocuments())\r\n    {\r\n        // Finally, save the changes.\r\n        utility->printInfo(tr(\"Generation complete.\"));\r\n    }\r\n    else\r\n    {\r\n        utility->printError(tr(\"Generation failed.\"));\r\n\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ModelSimGeneratorPlugin::getOutputFormat()\r\n//-----------------------------------------------------------------------------\r\nQString ModelSimGeneratorPlugin::getOutputFormat() const\r\n{\r\n    return QStringLiteral(\"do\");\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ModelSimGeneratorPlugin::getProgramRequirements()\r\n//-----------------------------------------------------------------------------\r\nQList<IPlugin::ExternalProgramRequirement> ModelSimGeneratorPlugin::getProgramRequirements()\r\n{\r\n    return QList<IPlugin::ExternalProgramRequirement>();\r\n}\r\n"
  },
  {
    "path": "Plugins/ModelSimGenerator/ModelSimGeneratorPlugin.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ModelSimGeneratorPlugin.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Janne Virtanen\r\n// Date: 10.06.2016\r\n//\r\n// Description:\r\n// ModelSim generator plugin.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef MODELSIMGENERATORPLUGIN_H\r\n#define MODELSIMGENERATORPLUGIN_H\r\n\r\n#include \"modelsimgenerator_global.h\"\r\n\r\n#include <KactusAPI/include/IGeneratorPlugin.h>\r\n#include <Plugins/PluginSystem/GeneratorPlugin/GenerationControl.h>\r\n#include <KactusAPI/include/CLIGenerator.h>\r\n\r\nclass MODELSIMGENERATOR_EXPORT ModelSimGeneratorPlugin : public QObject, public IGeneratorPlugin,\r\n    public CLIGenerator\r\n{\r\n    Q_OBJECT\r\n    Q_PLUGIN_METADATA(IID \"kactus2.plugins.modelSimGenerator\" FILE \"modelSimGenerator.json\")\r\n\r\n    Q_INTERFACES(IPlugin)\r\n    Q_INTERFACES(IGeneratorPlugin)\r\n\r\npublic:\r\n    //! The default constructor.\r\n    ModelSimGeneratorPlugin();\r\n\r\n    //! The destructor.\r\n    ~ModelSimGeneratorPlugin() = default;\r\n\r\n    // Disable copying.\r\n    ModelSimGeneratorPlugin(ModelSimGeneratorPlugin const& rhs) = delete;\r\n    ModelSimGeneratorPlugin& operator=(ModelSimGeneratorPlugin const& rhs) = delete;\r\n\r\n    /*!\r\n     *  Returns the name of the plugin.\r\n     */\r\n    virtual QString getName() const;\r\n\r\n    /*!\r\n     *  Returns the version of the plugin.\r\n     */\r\n    virtual QString getVersion() const;\r\n\r\n    /*!\r\n     *  Returns the description of the plugin.\r\n     */\r\n    virtual QString getDescription() const;\r\n\r\n    /*!\r\n     *  Returns the vendor of the plugin.\r\n     */\r\n    virtual QString getVendor() const;\r\n\r\n    /*!\r\n     *  Returns the license of the plugin.\r\n     */\r\n    virtual QString getLicense() const;\r\n\r\n    /*!\r\n     *  Returns the holder of the license of the plugin.\r\n     */\r\n    virtual QString getLicenseHolder() const;\r\n\r\n    /*!\r\n     *  Returns the settings widget.\r\n     */\r\n    virtual QWidget* getSettingsWidget();\r\n\r\n    /*!\r\n     *  This is used to access the settings modified by function getSettingsWidget().\r\n     */\r\n    virtual PluginSettingsModel* getSettingsModel(){return NULL;}\r\n\r\n    /*!\r\n     *  Returns the icon for the generator.\r\n     */\r\n    virtual QIcon getIcon() const;\r\n\t\r\n    /*!\r\n     *  Checks whether the generator may run for the given component or design. \r\n     *\r\n     *    @param [in] component\t        The component for which to check support. If design is not null, component\r\n\t *                                      will refer to design or designConfiguration.\r\n     *    @param [in] design\t            The design, if the generator is ran for a design.\r\n     *    @param [in] designConfiguration The design configuration for design, if it is not null.\r\n     *\r\n     *    @return True, if the generator may run the given component. Otherwise false.\r\n     */\r\n    virtual bool checkGeneratorSupport(QSharedPointer<Component const> component,\r\n        QSharedPointer<Design const> design,\r\n        QSharedPointer<DesignConfiguration const> designConfiguration) const;\r\n\t \r\n    /*!\r\n     *  Runs the generation, creating new files and/or modifying the IP-XACT metadata. The function has\r\n\t *  also access to the parent window widget, so that it can show dialogs for the user to aid the generation.\r\n     *\r\n     *    @param [in] utility\t\t\t    The plugin utility interface.\r\n     *    @param [in] component\t        The component for which to check support. If design is not null, component\r\n     *                                      will refer to design or designConfiguration.\r\n     *    @param [in] design\t            The design, if the generator is ran for a design.\r\n     *    @param [in] designConfiguration The design configuration for design, if it is not null.\r\n     */\r\n    virtual void runGenerator(IPluginUtility* utility, \r\n        QSharedPointer<Component> component,\r\n        QSharedPointer<Design> design,\r\n        QSharedPointer<DesignConfiguration> designConfiguration);\r\n\r\n    /*!\r\n     * Runs the generation.\r\n     *\r\n     *    @param [in] utility              Utilities for enabling plugin execution.\r\n     *    @param [in] component            The component to run the generation for.\r\n     *    @param [in] design               The design to run the generation for.\r\n     *    @param [in] designConfiguration  The design configuration to run the generation for.\r\n     *    @param [in] viewName             The component view name to run the generation for.\r\n     *    @param [in] outputDirectory      The output directory for the generation results.\r\n     */\r\n    virtual void runGenerator(IPluginUtility* utility, QSharedPointer<Component> component, \r\n        QSharedPointer<Design> design, QSharedPointer<DesignConfiguration> designConfiguration,\r\n        QString const& viewName, QString const& outputDirectory) override;\r\n\r\n    /*!\r\n     *  Gets the output format generated by the plugin.\r\n     *\r\n     *    @return The output file format generated by the plugin.\r\n     */\r\n    virtual QString getOutputFormat() const override;\r\n\r\n    //! Returns the external program requirements of the plugin.\r\n    virtual QList<IPlugin::ExternalProgramRequirement> getProgramRequirements();\r\n\r\nprivate:\r\n\r\n     //-----------------------------------------------------------------------------\r\n     // Data.\r\n     //-----------------------------------------------------------------------------\r\n\r\n     //! The last values used by the generation.\r\n     GenerationSettings settings_;\r\n};\r\n\r\n#endif // MODELSIMGENERATORPLUGIN_H\r\n"
  },
  {
    "path": "Plugins/ModelSimGenerator/ModelSimWriterFactory/ModelSimDocument.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: ModelSimDocument.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Janne Virtanen\n// Date: 20.04.2017\n//\n// Description:\n// Storage for ModelSim writers.\n//-----------------------------------------------------------------------------\n\n#include \"ModelSimDocument.h\"\n\n#include <QTextStream>\n\n//-----------------------------------------------------------------------------\n// Function: ModelSimDocument::ModelSimDocument()\n//-----------------------------------------------------------------------------\nModelSimDocument::ModelSimDocument(QSharedPointer<ModelSimWriter> writer): writer_(writer)\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: ModelSimDocument::write()\n//-----------------------------------------------------------------------------\nvoid ModelSimDocument::write(QString const& outputDirectory)\n{\n    fileContent_.clear();\n    QTextStream outputStream(&fileContent_);\n\n    writer_->write(outputStream, outputDirectory);\n}\n\n//-----------------------------------------------------------------------------\n// Function: ModelSimDocument::getImplementation()\n//-----------------------------------------------------------------------------\nvoid ModelSimDocument::getBodyHighlight(int& begin, int& end) const\n{\n    begin = -1;\n    end = -1;\n}"
  },
  {
    "path": "Plugins/ModelSimGenerator/ModelSimWriterFactory/ModelSimDocument.h",
    "content": "//-----------------------------------------------------------------------------\n// File: ModelSimDocument.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Janne Virtanen\n// Date: 20.04.2017\n//\n// Description:\n// Storage for ModelSim writers.\n//-----------------------------------------------------------------------------\n\n#ifndef MODELSIMDOCUMENT_H\n#define MODELSIMDOCUMENT_H\n\n#include \"../modelsimgenerator_global.h\"\n\n#include <Plugins/PluginSystem/GeneratorPlugin/OutputControl.h>\n\n#include \"ModelSimWriter.h\"\n\n//-----------------------------------------------------------------------------\n// ModelSim document.\n//-----------------------------------------------------------------------------\nstruct ModelSimDocument : public GenerationOutput\n{\n    QSharedPointer<ModelSimWriter> writer_;\n\n    //! The constructor.\n    explicit ModelSimDocument(QSharedPointer<ModelSimWriter> writer);\n\n    //! The destructor.\n    virtual ~ModelSimDocument() = default;\n\n    /*!\n     *  Writes the content. \n     *\n     *    @param [in] outputDirectory         The possible output directory.\n     */\n\tvoid write(QString const& outputDirectory);\n    \n    /*!\n     *  Finds position for body text highlight in document, if any exists.\n     *\n\t *    @param [out] begin                  The position where the highlight begins, if successful.\n     *    @param [out] end                    The position where the highlight ends, if successful.\n     */\n    void getBodyHighlight(int& begin, int& end) const;\n    \nprivate:\n};\n\n#endif // MODELSIMDOCUMENT_H\n"
  },
  {
    "path": "Plugins/ModelSimGenerator/ModelSimWriterFactory/ModelSimWriter.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: ModelSimWriter.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Janne Virtanen\n// Date: 20.04.2017\n//\n// Description:\n// Executes writing a ModelSim do file.\n//-----------------------------------------------------------------------------\n\n#include \"ModelSimWriter.h\"\n\n#include <IPXACTmodels/generaldeclarations.h>\n\n//-----------------------------------------------------------------------------\n// Function: ModelSimWriter::ModelSimWriter()\n//-----------------------------------------------------------------------------\nModelSimWriter::ModelSimWriter()\n{\n}\n\n//-----------------------------------------------------------------------------\n// Function: ModelSimWriter::write()\n//-----------------------------------------------------------------------------\nvoid ModelSimWriter::write(QTextStream& output, QString const& outputDirectory) const\n{\n    // Inform user when executing the script.\n    output << \"echo \" << QObject::tr(\"\\\"Adding files to the project\\\"\") << Qt::endl;\n\n    output << Qt::endl;\n\n    // Each path gets a line: Create a relative path from output directory to the location.\n    foreach (QString absolutePath, paths_)\n    {\n        QString relativePath = General::getRelativePath(outputDirectory, absolutePath);\n\n        output << \"project addfile \" << relativePath << Qt::endl;\n    }\n\n    output << Qt::endl;\n\n    // Latsly, compile the project.\n    output << \"project compileall\" << Qt::endl;\n\n    output << Qt::endl;\n\n    // Inform user that script has been successfully executed.\n    output << \"echo \" << QObject::tr(\"\\\"Script has been executed\\\"\") << Qt::endl;\n}\n\n//-----------------------------------------------------------------------------\n// Function: ModelSimWriter::addPath()\n//-----------------------------------------------------------------------------\nvoid ModelSimWriter::addPath(QString const& path)\n{\n    if (!paths_.contains(path))\n    {\n        paths_.append(path);\n    }\n}"
  },
  {
    "path": "Plugins/ModelSimGenerator/ModelSimWriterFactory/ModelSimWriter.h",
    "content": "//-----------------------------------------------------------------------------\n// File: ModelSimWriter.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Janne Virtanen\n// Date: 20.04.2017\n//\n// Description:\n// Executes writing a ModelSim do file.\n//-----------------------------------------------------------------------------\n\n#ifndef MODELSIMWRITER_H\n#define MODELSIMWRITER_H\n\n#include <QList>\n#include <QString>\n#include <QTextStream>\n\n//-----------------------------------------------------------------------------\n// Executes writing a ModelSim do file.\n//-----------------------------------------------------------------------------\nstruct ModelSimWriter\n{\n    //! The constructor.\n    ModelSimWriter();\n\n    /*!\n     *  Writes the content to the given output.\n     *\n     *    @param [in] output   The output to write to.\n     */\n    void write(QTextStream& output, QString const& outputDirectory) const;\n    \n    /*!\n     *  Adds an absolute path to the list of paths that needs to be referred.\n     */\n    void addPath(QString const& path);\n    \nprivate:\n    QList<QString> paths_;\n};\n\n#endif // MODELSIMWRITER_H\n"
  },
  {
    "path": "Plugins/ModelSimGenerator/ModelSimWriterFactory/ModelSimWriterFactory.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: ModelSimWriterFactory.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Janne Virtanen\n// Date: 20.04.2017\n//\n// Description:\n// Creates writers for generating do files.\n//-----------------------------------------------------------------------------\n\n#include \"ModelSimWriterFactory.h\"\n#include \"ModelSimWriter.h\"\n\n#include <KactusAPI/include/LibraryInterface.h>\n\n#include <Plugins/PluginSystem/GeneratorPlugin/GenerationControl.h>\n\n#include <IPXACTmodels/Component/File.h>\n#include <IPXACTmodels/Component/FileSet.h>\n\n//-----------------------------------------------------------------------------\n// Function: ModelSimWriterFactory::ModelSimWriterFactory()\n//-----------------------------------------------------------------------------\nModelSimWriterFactory::ModelSimWriterFactory(LibraryInterface* library,\n    MessageMediator* messages, GenerationSettings* settings,\n    QString const& kactusVersion, QString const& generatorVersion) :\n    library_(library),\n    messages_(messages),\n    settings_(settings),    \n    generatorVersion_(generatorVersion),\n    kactusVersion_(kactusVersion)\n{\n}\n\n//-----------------------------------------------------------------------------\n// Function: ModelSimWriterFactory::prepareComponent()\n//-----------------------------------------------------------------------------\nQSharedPointer<GenerationOutput> ModelSimWriterFactory::prepareComponent(QString const& /*outputPath*/,\n    QSharedPointer<MetaComponent> /*component*/)\n{\n    return QSharedPointer<ModelSimDocument>();\n}\n\n//-----------------------------------------------------------------------------\n// Function: ModelSimWriterFactory::prepareDesign()\n//-----------------------------------------------------------------------------\nQList<QSharedPointer<GenerationOutput> > ModelSimWriterFactory::prepareDesign(QList<QSharedPointer<MetaDesign> >& designs)\n{\n    QSharedPointer<ModelSimDocument> document = \n        QSharedPointer<ModelSimDocument>(new ModelSimDocument(QSharedPointer<ModelSimWriter>(new ModelSimWriter)));\n\n    QList<QSharedPointer<MetaInstance> > components;\n\n    for (QSharedPointer<MetaDesign> mDesign : designs)\n    {\n        components.append(mDesign->getTopInstance());\n        components.append(mDesign->getInstances()->values());\n    }\n\n    QSharedPointer<ModelSimWriter> writer(new ModelSimWriter);\n\n    document->writer_ = writer;\n    document->fileName_ = designs.first()->getTopInstance()->getModuleName() + \".do\";\n    document->vlnv_ = designs.first()->getTopInstance()->getComponent()->getVlnv().toString();\n    document->metaDesign_ = designs.first();\n\n    for (QSharedPointer<MetaComponent> mComponent : components)\n    {\n        QString basePath = library_->getPath(mComponent->getComponent()->getVlnv());\n\n        for (QSharedPointer<FileSet> fileSet : *mComponent->getFileSets())\n        {\n            for (QSharedPointer<File> file : *fileSet->getFiles())\n            {\n                // Fetch the absolute path to the file\n                QString absolutePath = General::getAbsolutePath(basePath, file->name());\n\n                writer->addPath(absolutePath);\n            }\n        }\n    }\n\n    QList<QSharedPointer<GenerationOutput> > retval;\n    retval.append(document);\n\n    return retval;\n}\n\n//-----------------------------------------------------------------------------\n// Function: ModelSimWriterFactory::getLanguage()\n//-----------------------------------------------------------------------------\nQString ModelSimWriterFactory::getLanguage() const\n{\n    return QString();\n}\n\n//-----------------------------------------------------------------------------\n// Function: ModelSimWriterFactory::getSaveToFileset()\n//-----------------------------------------------------------------------------\nbool ModelSimWriterFactory::getSaveToFileset() const\n{\n    return false;\n}\n\n//-----------------------------------------------------------------------------\n// Function: ModelSimWriterFactory::getGroupIdentifier()\n//-----------------------------------------------------------------------------\nQString ModelSimWriterFactory::getGroupIdentifier() const\n{\n    return QStringLiteral(\"simulation\");\n}\n"
  },
  {
    "path": "Plugins/ModelSimGenerator/ModelSimWriterFactory/ModelSimWriterFactory.h",
    "content": "//-----------------------------------------------------------------------------\n// File: ModelSimWriterFactory.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Janne Virtanen\n// Date: 20.04.2017\n//\n// Description:\n// Creates writers for generating do files.\n//-----------------------------------------------------------------------------\n\n#ifndef MODELSIMFACTORY_H\n#define MODELSIMFACTORY_H\n\n#include \"ModelSimDocument.h\"\n\n#include <Plugins/PluginSystem/GeneratorPlugin/IWriterFactory.h>\n\nstruct GenerationSettings;\n\n//-----------------------------------------------------------------------------\n// Creates writers for generating do files.\n//-----------------------------------------------------------------------------\nclass ModelSimWriterFactory : public IWriterFactory\n{\npublic:\n\n\t/*!\n\t *  The constructor.\n\t *\n     *    @param [in] library                 The component library.\n     *    @param [in] messages                For message output.\n     *    @param [in] settings                Points to the settings to be used within the generation.\n\t *    @param [in] kactusVersion\t\t    The version of the current Kactus build.\n\t *    @param [in] generatorVersion\t    The current version of the generator.\n\t */\n    ModelSimWriterFactory(LibraryInterface* library, \n        MessageMediator* messages, GenerationSettings* settings,\n        QString const& kactusVersion, QString const& generatorVersion);\n\n    // Disable copying.\n    ModelSimWriterFactory(ModelSimWriterFactory const& rhs) = delete;\n    ModelSimWriterFactory& operator=(ModelSimWriterFactory const& rhs) = delete;\n\n    //! The destructor.\n    virtual ~ModelSimWriterFactory() = default;\n\n    /*!\n     *  Creates writers for the given formatted HDL component.\n     *\n     *    @param [in] outputPath\t\t\tThe path to the output file.\n     *    @param [in] component           The component which is needs writing.\n     *\n     *    @return The objects that bundles the writers. Will be null, if could not be created.\n     */\n    virtual QSharedPointer<GenerationOutput> prepareComponent(QString const& outputPath,\n        QSharedPointer<MetaComponent> component);\n\n    /*!\n     *  Creates writers for the given parsed meta design.\n     *\n     *    @param [in] design             The design which is needs writing.\n     *\n     *    @return The objects that bundles the writers. Will be null, if could not be created.\n     */\n    virtual QList<QSharedPointer<GenerationOutput> > prepareDesign(QList<QSharedPointer<MetaDesign> >& designs);\n    \n    /*!\n     *  Returns the language of the factory.\n     */\n    virtual QString getLanguage() const;\n    \n    /*!\n     *  Returns true, if it is desirable to save the output to file set by default.\n     */\n    virtual bool getSaveToFileset() const;\n    \n    /*!\n     *  Returns the group identifier suitable for the produced files.\n     */\n    virtual QString getGroupIdentifier() const;\n\nprivate:\n\n    //-----------------------------------------------------------------------------\n    // Data.\n    //-----------------------------------------------------------------------------\n\n    //! The component library.\n    LibraryInterface* library_;\n\n    //! The messages.\n    MessageMediator* messages_;\n\n    //! Points to the settings to be used within the generation.\n    GenerationSettings* settings_;\n\n    //! Version of the generator.\n    QString generatorVersion_;\n\n    //! Version of Kactus2.\n    QString kactusVersion_;\n};\n\n#endif // MODELSIMFACTORY_H\n"
  },
  {
    "path": "Plugins/ModelSimGenerator/modelSimGenerator.json",
    "content": "{\r\n\t\"Keys\": [ \"modelSimGenerator\" ]\r\n}"
  },
  {
    "path": "Plugins/ModelSimGenerator/modelsimgenerator_global.h",
    "content": "// Copyright Tampere University of Technology\r\n\r\n#ifndef MODELSIMGENERATOR_GLOBAL_H\r\n#define MODELSIMGENERATOR_GLOBAL_H\r\n\r\n#include <QtCore/qglobal.h>\r\n\r\n#ifdef MODELSIMGENERATOR_LIB\r\n# define MODELSIMGENERATOR_EXPORT Q_DECL_EXPORT\r\n#else\r\n# define MODELSIMGENERATOR_EXPORT Q_DECL_IMPORT\r\n#endif\r\n\r\n#endif // MODELSIMGENERATOR_GLOBAL_H\r\n"
  },
  {
    "path": "Plugins/PadsPartGenerator/PadsAsciiSyntax.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: PadsAsciiSyntax.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Esko Pekkarinen\r\n// Date: 6.11.2013\r\n//\r\n// Description:\r\n// Syntax description for PADS ascii files.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef PADSASCIISYNTAX_H\r\n#define PADSASCIISYNTAX_H\r\n\r\n#include <QRegularExpression>\r\n#include <QString>\r\n\r\nnamespace PadsAsciiSyntax {\r\n    \r\n    // All ascii files end with the following expression.\r\n    const QString PADS_FILE_END = \"*END*\";\r\n\r\n    // General separator in ascii files is a space.\r\n    const char SEPARATOR = ' ';\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // PADS Part file.\r\n    //-----------------------------------------------------------------------------\r\n    \r\n    // PADS Part file header.\r\n    const QString PART_FILE_BEGIN = \"*PADS-LIBRARY-PART-TYPES-V9*\";    \r\n    \r\n    // Supported units.\r\n    const QString IMPERIAL = \"I\";\r\n    const QString METRIC = \"M\";\r\n\r\n    // First header line in PADS part.    \r\n    const QString PART_HEADER_1ST_LINE = \"name pcbdecals u logfam attrs gates sigpins pinmap flag\";\r\n    const QRegularExpression PART_HEADER_1ST_EXP = \r\n        QRegularExpression(\"(\\\\w{1,40}) (\\\\w{1,40}(?:[:]\\\\w{1,40}){0,15}) (\\\\w) (\\\\w{3}) \\\\d+ \\\\d+ \\\\d+ \\\\d+ \\\\d{1,3}\");\r\n\r\n    // Positions of header fields.\r\n    enum partHeaderPos\r\n    {\r\n        NAME = 0,\r\n        DECALS,\r\n        UNITS,\r\n        LOGFAMILY,\r\n        NUM_ATTRS,\r\n        NUM_GATES,\r\n        NUM_SIGNPINS,\r\n        NUM_PINMAPS,\r\n        FLAG\r\n    };\r\n\r\n    // Second header line in PADS part.\r\n    const QString PART_HEADER_2ND_LINE = \"TIMESTAMP year.month.day.hour.minute.second\";\r\n    const QRegularExpression PART_HEADER_2ND_EXP(\"TIMESTAMP \\\\d{4}[.]\\\\d{1,2}[.]\\\\d{1,2}[.]\\\\d{1,2}[.]\\\\d{1,2}[.]\\\\d{1,2}\",\r\n            QRegularExpression::CaseInsensitiveOption);\r\n\r\n    // Part attribute line.\r\n    const QString ATTRIBUTE_DECLARATION = \"name value\";\r\n    const QRegularExpression ATTRIBUTE_EXP = QRegularExpression(\"\\\"[^\\\"]{1,255}\\\"(([^\\\\r\\\\n])*)\");\r\n\r\n    // Positions of fields in attributes.\r\n    enum attrPos\r\n    {\r\n        ATTRNAME = 0,\r\n        VALUE\r\n    };\r\n\r\n    // Gate declaration for normal parts.\r\n    const QString PART_GATE_DECLARATION = \"GATE decals pins gateswap\";\r\n    const QRegularExpression PART_GATE_EXP = QRegularExpression(\"GATE (\\\\d) (\\\\d+) (\\\\d)\", \r\n        QRegularExpression::CaseInsensitiveOption);\r\n    const QRegularExpression PART_GATE_NAME_EXP = QRegularExpression(\"(\\\\w{1,40}([:]\\\\w{1,40}){0,3})\", \r\n        QRegularExpression::CaseInsensitiveOption);\r\n\r\n    // Positions of gate fields in normal part.\r\n    enum gatePos\r\n    {        \r\n        NUM_DECALS = 1,\r\n        NUM_PINS,\r\n        GATESWAP        \r\n    };\r\n\r\n    // Pin declaration for normal part gates.\r\n    const QString PART_GATE_PIN = \"pinnumber pinswap pintype pinname\";\r\n    const QRegularExpression PART_GATE_PIN_EXP = QRegularExpression(\"(\\\\w{1,7}) (\\\\d) ([S|B|C|O|T|L|Z|P|G|U])( \\\\w{1,40})?\", \r\n        QRegularExpression::CaseInsensitiveOption);\r\n\r\n    // Positions of gate pin fields.\r\n    enum pinPos\r\n    {        \r\n        PINNUMBER = 0,        \r\n        PINSWAP,\r\n        PINTYPE,\r\n        PINNAME\r\n    };\r\n \r\n    //-----------------------------------------------------------------------------\r\n    // PADS CAE decal file.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    // PADS CAE decal header.\r\n    const QString CAE_FILE_BEGIN = \"*PADS-LIBRARY-SCH-DECALS-V9*\";\r\n\r\n    // First line of CAE header.\r\n    const QString CAE_HEADER_1ST_LINE = \"name x y pnhgt pnwid pnmhgt pnmwid labels pieces txt terminals vis\";\r\n\r\n    // Positions of CAE header fields.\r\n    enum caeHeaderPos\r\n    {        \r\n        CAENAME = 0,        \r\n        CAE_POS_X,\r\n        CAE_POS_Y,\r\n        PINNUMBER_HEIGHT,\r\n        PINNUMBER_WIDTH,\r\n        PINNAME_HEIGHT,\r\n        PINNAME_WIDTH,\r\n        NUM_LABELS,\r\n        NUM_PIECES,\r\n        NUM_TXT,\r\n        NUM_TERMINALS,\r\n        VISIBILITY\r\n    };\r\n\r\n    // Default font definition.\r\n    const QString DEFAULT_FONT = \"\\\"Default Font\\\"\";\r\n\r\n    // Drawing symbol for simple rectangle.\r\n    const QString CAE_RECT_PIECE = \"CLOSED 5 10 0 -1\";\r\n    \r\n    // Text label definition.\r\n    const QString CAE_LABEL = \"x y rotation justification height width fontinfo\";\r\n\r\n    // Position of text label fields.\r\n    enum caeLabelPos\r\n    {                \r\n        LABEL_POS_X = 0,\r\n        LABEL_POS_Y,\r\n        LABEL_ROTATION,\r\n        JUSTIFICATION,\r\n        LABEL_TEXT_HEIGHT,\r\n        LABEL_TEXT_WIDTH,\r\n        LABEL_FONTINFO\r\n    };\r\n\r\n    // Free text item defintion.\r\n    const QString TEXT_ITEM = \"x y rotation layer height width mirror just drwnum field fontinfo\";\r\n\r\n    // Positions of free text fields.\r\n    enum textItemPos\r\n    {                \r\n        TEXT_POS_X = 0,\r\n        TEXT_POS_Y,\r\n        TEXT_ROTATION,\r\n        LAYER,        \r\n        TEXT_HEIGHT,\r\n        TEXT_WIDTH,\r\n        TEXT_MIRRORING,\r\n        TEXT_JUSTIFICATION,\r\n        PCB_DRAW_NUMBER,\r\n        FIELD_FLAG,\r\n        TEXT_FONTINFO\r\n    };\r\n\r\n    // CAE terminal definition. Preceded by 'T' without space.\r\n    const QString CAE_TERMINAL = \"x y rtn xym pnx pny pnrtn pnjust pnmx pnmy pnmrtn pnmjust pindecal\";\r\n    \r\n    // Positions of CAE terminal fields.\r\n    enum terminalPos\r\n    {                \r\n        TERMINAL_POS_X = 0,\r\n        TERMINAL_POS_Y,\r\n        TERMINAL_ROTATION,\r\n        TERMINAL_MIRROR,\r\n        TERMINAL_PINNUM_X,\r\n        TERMINAL_PINNUM_Y,\r\n        TERMINAL_PINNUM_ROTATION,\r\n        TERMINAL_PINNUM_JUSTIFICATION,\r\n        TERMINAL_PINNAME_X,\r\n        TERMINAL_PINNAME_Y,\r\n        TERMINAL_PINNAME_ROTATION,\r\n        TERMINAL_PINNAME_JUSTIFICATION,\r\n        TERMINAL_PINNAME\r\n    };\r\n\r\n    // CAE terminal pin property label definition. Preceded by 'P' without space.\r\n    const QString CAE_PIN_PROPERTY = \"plx ply plrtn pljust nlx nly nlrtn nljust pflags\";\r\n\r\n    // Positions of pin property fields.\r\n    enum pinPropertyPos\r\n    {                \r\n        PINPROPERTY_POS_X = 0,\r\n        PINPROPERTY_POS_Y,\r\n        PINPROPERTY_ROTATION,\r\n        PINPROPERTY_JUSTIFICATION,\r\n        NETNAME_POS_X,\r\n        NETNAME_POS_Y,\r\n        NETNAME_ROTATION,\r\n        NETNAME_JUSTIFICATION,\r\n        PINPROPERTY_FLAGS\r\n    };\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // PADS PCB decal file.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    // PADS PCB decal header.\r\n    // const QString PCB_DECAL_HEADER = \"name u x y attrs labels pieces txt terminals stacks maxlayers\"\r\n    const QRegularExpression PCB_DECAL_HEADER_EXP = QRegularExpression(\"(\\\\w+) \\\\w -?\\\\d+ -?\\\\d+ \\\\d+ \\\\d+ \\\\d+ \\\\d+ \\\\d+ \\\\d+ \\\\d\");\r\n\r\n}\r\n\r\n#endif // PADSASCIISYNTAX_H"
  },
  {
    "path": "Plugins/PadsPartGenerator/PadsPartGenerator.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: PadsPartGenerator\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Esko Pekkarinen\r\n// Date: 5.11.2013\r\n//\r\n// Description:\r\n// Generator for PADS parts.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"PadsPartGenerator.h\"\r\n\r\n#include \"PadsAsciiSyntax.h\"\r\n#include \"PadsPartGeneratorDialog.h\"\r\n\r\n#include <KactusAPI/include/LibraryInterface.h>\r\n\r\n#include <IPXACTmodels/generaldeclarations.h>\r\n\r\n#include <IPXACTmodels/Component/Component.h>\r\n#include <IPXACTmodels/Component/File.h>\r\n#include <IPXACTmodels/Component/FileSet.h>\r\n\r\n#include <IPXACTmodels/kactusExtensions/KactusAttribute.h>\r\n\r\n#include <KactusAPI/include/IPlugin.h>\r\n#include <KactusAPI/include/IPluginUtility.h>\r\n\r\n#include <KactusAPI/include/ComponentParameterFinder.h>\r\n#include <KactusAPI/include/IPXactSystemVerilogParser.h>\r\n\r\n#include <QDate>\r\n#include <QDialog>\r\n#include <QDir>\r\n#include <QFile>\r\n#include <QRect>\r\n#include <QStringList>\r\n#include <QTextStream>\r\n#include <QTime>\r\n#include <QtPlugin>\r\n\r\nnamespace\r\n{\r\n    // Label options.\r\n    const int LABEL_DEFAULT_COUNT = 4;  //<! Part type, part reference and two free text labels are displayed.\r\n    const int LABEL_DEFAULT_WIDTH = 10;\r\n    const int LABEL_DEFAULT_HEIGHT = 97;\r\n    const int LABEL_JUSTIFICATION = 17;    \r\n\r\n    // Item rotation options.\r\n    const int NO_ROTATION = 0;\r\n    const int LEFT_MIRROR = 0;\r\n    const int RIGHT_MIRROR = 2;\r\n\r\n    // CAE item settings.\r\n    const int LAYER = 0;                //!< Use all layers.\r\n    const int DEFAULT_VISIBILITY = 2;   //!< Part type invisibility.\r\n\r\n    // General justification options of items.\r\n    const int JUST_BOTTOM_RIGHT = 1;\r\n    const int JUST_TOP_LEFT = 2;\r\n    const int JUST_TOP_CENTER = 6;\r\n    const int JUST_MIDDLE_CENTER = 12;\r\n    \r\n    // Pinname options.\r\n    const int PINNAME_X = 230;  //!< Distance in x-direction relative to terminal position.\r\n    const int PINNAME_Y = 0;    //!< Distance in y-direction relative to terminal position.\r\n\r\n    // Pin options.\r\n    const int PIN_SPAN = 100;               //!< Distance in y-direction between adjacent pins.    \r\n    const int PIN_WIDTH = 200;              //!< Width of PIN decal.    \r\n    const int PIN_JUSTIFICATION = 16;\r\n    const int NETNAME_DISTANCE = -80;       //!< Distance in x-direction relative to terminal position.\r\n    const int PINNUMBER_DISTANCE = 140;     //!< Distance in x-direction relative to terminal position.\r\n    const int PIN_PROPERTY_DISTANCE = -520; //!< Distance in x-direction relative to terminal position.        \r\n\r\n    // Default width for decal rectangle.\r\n    const int PART_DEFAULT_WIDTH = 1600;    \r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PadsPartGenerator::PadsPartGenerator()\r\n//-----------------------------------------------------------------------------\r\nPadsPartGenerator::PadsPartGenerator()\r\n{  \r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PadsPartGenerator::getName()\r\n//-----------------------------------------------------------------------------\r\nQString PadsPartGenerator::getName() const\r\n{\r\n    return tr(\"PADS Part Generator\");\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PadsPartGenerator::getVersion()\r\n//-----------------------------------------------------------------------------\r\nQString PadsPartGenerator::getVersion() const\r\n{\r\n    return tr(\"1.1\");\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PadsPartGenerator::getDescription()\r\n//-----------------------------------------------------------------------------\r\nQString PadsPartGenerator::getDescription() const\r\n{\r\n    return tr(\"Generates PADS part for component.\");\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PadsPartGenerator::getVendor()\r\n//-----------------------------------------------------------------------------\r\nQString PadsPartGenerator::getVendor() const\r\n{\r\n    return tr(\"Tampere University (tuni.fi)\");\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PadsPartGenerator::getLicense()\r\n//-----------------------------------------------------------------------------\r\nQString PadsPartGenerator::getLicense() const\r\n{\r\n    return tr(\"GPL2\");\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PadsPartGenerator::getLicenseHolder()\r\n//-----------------------------------------------------------------------------\r\nQString PadsPartGenerator::getLicenseHolder() const\r\n{\r\n    return tr(\"Public\");\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PadsPartGenerator::getSettingsWidget()\r\n//-----------------------------------------------------------------------------\r\nQWidget* PadsPartGenerator::getSettingsWidget()\r\n{\r\n    return nullptr;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PadsPartGenerator::getIcon()\r\n//-----------------------------------------------------------------------------\r\nQIcon PadsPartGenerator::getIcon() const\r\n{\r\n    return QIcon(\":icons/processor.png\");\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PadsPartGenerator::checkGeneratorSupport()\r\n//-----------------------------------------------------------------------------\r\nbool PadsPartGenerator::checkGeneratorSupport(QSharedPointer<Component const> component,\r\n    QSharedPointer<Design const> design,\r\n    QSharedPointer<DesignConfiguration const> designConfiguration) const\r\n{\r\n    // Pads part generation can only be run on component editor.\r\n    if (designConfiguration || design)\r\n    {\r\n        return false;\r\n    }\r\n\r\n    // Part generation can only run on HW chip components.\r\n    if (!component || component->getImplementation() != KactusAttribute::HW ||\r\n        component->getHierarchy() != KactusAttribute::CHIP)\r\n    {\r\n        return false;\r\n    }\r\n\r\n    return true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PadsPartGenerator::runGenerator()\r\n//-----------------------------------------------------------------------------\r\nvoid PadsPartGenerator::runGenerator(IPluginUtility* utility, \r\n    QSharedPointer<Component> component,\r\n    QSharedPointer<Design> /*design*/,\r\n    QSharedPointer<DesignConfiguration> /*designConfiguration*/)\r\n{\r\n    QSharedPointer<ParameterFinder> finder(new ComponentParameterFinder(component));\r\n    QSharedPointer<ExpressionParser> parser(new IPXactSystemVerilogParser(finder));\r\n\r\n    // Ask user for generation settings.\r\n    PadsPartGeneratorDialog dialog(utility->getLibraryInterface(), component, parser, getName(), getVersion(), \r\n        utility->getParentWidget());\r\n    if (dialog.exec() == QDialog::Rejected)\r\n    {\r\n        return;\r\n    }\r\n\r\n    utility->printInfo(QString(\"---------- Kactus2 \" + getName() + \" \" + getVersion() + \" ----------\"));    \r\n    utility->printInfo(QString(tr(\"Generation started \") + QDate::currentDate().toString(\"dd.MM.yyyy\") + \r\n        \" \" + QTime::currentTime().toString()));\r\n\r\n    QString partDescription(dialog.getPreviewText());\r\n    QString filesetName =  dialog.getFileSetName();    \r\n    QString basePath = utility->getLibraryInterface()->getPath(component->getVlnv());\r\n    QFileInfo fileInfo(basePath); \r\n    QString targetDirectoryPath = fileInfo.absolutePath() + \"/\" + filesetName;\r\n    QDir targetDirectory(targetDirectoryPath);\r\n    if (!targetDirectory.exists())\r\n    {\r\n        targetDirectory.mkpath(\".\");\r\n    }\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Generate part file.\r\n    //-----------------------------------------------------------------------------\r\n    QString partFileName = dialog.getPartName() + \".p\";      \r\n    QString partFilePath =  targetDirectoryPath + \"/\" + partFileName;\r\n    QFile* partFile = new QFile(partFilePath);\r\n\r\n    if (!generatePartFile(partFile, partDescription))\r\n    {\r\n        utility->printError(tr(\"Could not write file %1\").arg(partFilePath));    \r\n    }\r\n   \r\n    partFile->close();\r\n    utility->printInfo(tr(\"Finished writing %1\").arg(partFilePath));\r\n\r\n    // Add part file to fileset.\r\n    QSharedPointer<FileSet> targetFileset = component->getFileSet(filesetName);\r\n    if (!targetFileset)\r\n    {\r\n        targetFileset = QSharedPointer<FileSet>(new FileSet(filesetName));\r\n        component->getFileSets()->append(targetFileset);\r\n    }\r\n\r\n    if (addFileToFileset(targetFileset, partFilePath, basePath, QStringList(\"padsPart\")))\r\n    {\r\n        utility->printInfo(tr(\"Added %1 to fileset %2\").arg(partFileName).arg(filesetName)); \r\n    }\r\n    else\r\n    {        \r\n        utility->printError(tr(\"Could not add %1 to fileset %2\").arg(partFileName).arg(filesetName));         \r\n    }\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Generate cae decal file.\r\n    //-----------------------------------------------------------------------------\r\n    QString caeFileName = dialog.getPartName() + \".c\";   \r\n    QString caeFilePath = targetDirectoryPath + \"/\" + caeFileName;    \r\n    QFile* caeFile = new QFile(caeFilePath);\r\n\r\n    if (!generateCAEFile(caeFile, component->getVlnv().toString().toUpper(), partDescription))\r\n    {\r\n        utility->printError(tr(\"Could not write file %1\").arg(caeFilePath));    \r\n    }\r\n    \r\n    caeFile->close();\r\n    utility->printInfo(tr(\"Finished writing %1\").arg(caeFilePath));\r\n\r\n    // Add cae file to fileset.\r\n    if (!addFileToFileset(targetFileset, caeFilePath, basePath, QStringList(\"padsCAEDecal\")))\r\n    {\r\n        utility->printError(tr(\"Could not add %1 to fileset %2\").arg(caeFileName).arg(filesetName));\r\n    }\r\n    else\r\n    {\r\n        utility->printInfo(tr(\"Added %1 to fileset %2\").arg(caeFileName).arg(filesetName));          \r\n    }\r\n\r\n    // Write fileset changes to xml.\r\n    utility->printInfo(tr(\"========== Part generation complete ==========\"));\r\n    utility->getLibraryInterface()->writeModelToFile(component);         \r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PadsPartGenerator::getProgramRequirements()\r\n//-----------------------------------------------------------------------------\r\nQList<IPlugin::ExternalProgramRequirement> PadsPartGenerator::getProgramRequirements()\r\n{\r\n    return QList<IPlugin::ExternalProgramRequirement>();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PadsPartGenerator::generatePartFile()\r\n//-----------------------------------------------------------------------------                        \r\nbool PadsPartGenerator::generatePartFile(QFile* file, QString const& partDescription)\r\n{\r\n    // open the file and erase all old contents if any exists.\r\n    // if file could not be opened, cancel.\r\n    if (!file->isOpen() && !file->open(QFile::Truncate | QFile::WriteOnly)) {          \r\n        return false;\r\n    }\r\n\r\n    // open file stream to write to.\r\n    QTextStream fileStream(file);\r\n    fileStream << partDescription;   \r\n    return true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PadsPartGenerator::generateCAEFile()\r\n//-----------------------------------------------------------------------------\r\nbool PadsPartGenerator::generateCAEFile(QFile* file, QString const& partTitle, QString const& partDescription)\r\n{\r\n    // open the file and erase all old contents if any exists.\r\n    // if file could not be opened, cancel.\r\n    if (!file->isOpen() && !file->open(QFile::Truncate | QFile::WriteOnly)) {        \r\n        return false;\r\n    }\r\n\r\n    QTextStream caeFileStream(file);\r\n\r\n    // Write file header.\r\n    caeFileStream << PadsAsciiSyntax::CAE_FILE_BEGIN << Qt::endl;\r\n    caeFileStream << Qt::endl;\r\n    \r\n    // Get the timestamp from part.\r\n    auto timeMatch = PadsAsciiSyntax::PART_HEADER_2ND_EXP.match(partDescription);\r\n    QString timestamp = timeMatch.captured();\r\n\r\n    // Generate CAE decal for each gate.\r\n    auto gateMatch = PadsAsciiSyntax::PART_GATE_EXP.match(partDescription);\r\n    while(gateMatch.hasMatch())\r\n    {\r\n        QString gate = gateMatch.captured(0);\r\n\r\n        auto nameMatch = PadsAsciiSyntax::PART_GATE_NAME_EXP.match(partDescription, gateMatch.capturedEnd());\r\n\r\n        QString gateName = nameMatch.captured(0);\r\n        int pinCount = gateMatch.captured(PadsAsciiSyntax::NUM_PINS).toInt();\r\n\r\n        QRect caeRect(0,0, PART_DEFAULT_WIDTH, pinCount/2 * PIN_SPAN + 5*PIN_SPAN);\r\n\r\n        insertCAEHeader(caeFileStream, timestamp, gateName, pinCount);\r\n        insertCAEDecal(caeFileStream, caeRect, partTitle, gateName);\r\n        insertCAETerminals(caeFileStream, caeRect, pinCount);\r\n        caeFileStream << Qt::endl;\r\n\r\n        // Find the next gate.\r\n        gateMatch = PadsAsciiSyntax::PART_GATE_EXP.match(partDescription, gateMatch.capturedEnd());\r\n    }\r\n\r\n    // Write file end.\r\n    caeFileStream << PadsAsciiSyntax::PADS_FILE_END << Qt::endl;\r\n\r\n    caeFileStream.flush();\r\n    return true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PadsPartGenerator::generateCAEHeader()\r\n//-----------------------------------------------------------------------------\r\nvoid PadsPartGenerator::insertCAEHeader(QTextStream& output, QString const& timestamp, \r\n    QString const& gateName, int pinCount)\r\n{\r\n    // First line of CAE Header.\r\n    QStringList header = PadsAsciiSyntax::CAE_HEADER_1ST_LINE.split(PadsAsciiSyntax::SEPARATOR);\r\n    header.replace(PadsAsciiSyntax::CAENAME, gateName);    \r\n    header.replace(PadsAsciiSyntax::CAE_POS_X, \"0\");\r\n    header.replace(PadsAsciiSyntax::CAE_POS_Y, \"0\");\r\n    header.replace(PadsAsciiSyntax::PINNUMBER_HEIGHT, QString::number(LABEL_DEFAULT_HEIGHT));\r\n    header.replace(PadsAsciiSyntax::PINNUMBER_WIDTH, QString::number(LABEL_DEFAULT_WIDTH));\r\n    header.replace(PadsAsciiSyntax::PINNAME_HEIGHT,QString::number(LABEL_DEFAULT_HEIGHT));\r\n    header.replace(PadsAsciiSyntax::PINNAME_WIDTH, QString::number(LABEL_DEFAULT_WIDTH));\r\n    header.replace(PadsAsciiSyntax::NUM_LABELS, QString::number(LABEL_DEFAULT_COUNT));\r\n    header.replace(PadsAsciiSyntax::NUM_PIECES, \"1\");\r\n    header.replace(PadsAsciiSyntax::NUM_TXT, \"2\");\r\n    header.replace(PadsAsciiSyntax::NUM_TERMINALS, QString::number(pinCount));\r\n    header.replace(PadsAsciiSyntax::VISIBILITY, QString::number(DEFAULT_VISIBILITY));\r\n\r\n    output << header.join(PadsAsciiSyntax::SEPARATOR) << Qt::endl;\r\n\r\n    // 2. line has the timestamp.\r\n    output << timestamp << Qt::endl;\r\n\r\n    // Font info on the 3. and 4. lines.\r\n    output << PadsAsciiSyntax::DEFAULT_FONT << Qt::endl;\r\n    output << PadsAsciiSyntax::DEFAULT_FONT << Qt::endl;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PadsPartGenerator::generateCAEDecal()\r\n//-----------------------------------------------------------------------------\r\nvoid PadsPartGenerator::insertCAEDecal(QTextStream& output, QRect const& drawSymbol, \r\n    QString const& gateTitle, QString const& gateName)\r\n{   \r\n    int partWidth = drawSymbol.width();\r\n    int partHeight = drawSymbol.height();\r\n\r\n    QStringList text = PadsAsciiSyntax::CAE_LABEL.split(PadsAsciiSyntax::SEPARATOR);\r\n    text.replace(PadsAsciiSyntax::LABEL_POS_X, QString::number(partWidth/2));\r\n    text.replace(PadsAsciiSyntax::LABEL_POS_Y, QString::number(partHeight + 2*PIN_SPAN));\r\n    text.replace(PadsAsciiSyntax::LABEL_ROTATION,QString::number(NO_ROTATION));\r\n    text.replace(PadsAsciiSyntax::JUSTIFICATION,QString::number(JUST_TOP_CENTER));\r\n    text.replace(PadsAsciiSyntax::LABEL_TEXT_HEIGHT, QString::number(LABEL_DEFAULT_HEIGHT));\r\n    text.replace(PadsAsciiSyntax::LABEL_TEXT_WIDTH, QString::number(LABEL_DEFAULT_WIDTH));\r\n    text.replace(PadsAsciiSyntax::LABEL_FONTINFO, PadsAsciiSyntax::DEFAULT_FONT);\r\n\r\n    // Reference designator location definition.\r\n    output << text.join(PadsAsciiSyntax::SEPARATOR) << Qt::endl;\r\n    output << \"REF-DES\" << Qt::endl;\r\n\r\n    // Part type name definition.\r\n    text.replace(PadsAsciiSyntax::LABEL_POS_Y, QString::number(-2*PIN_SPAN));\r\n    text.replace(PadsAsciiSyntax::JUSTIFICATION,QString::number(JUST_TOP_CENTER));\r\n    output << text.join(PadsAsciiSyntax::SEPARATOR) << Qt::endl;\r\n    output << \"PART-TYPE\" << Qt::endl;\r\n\r\n    // First part attribute value definition.\r\n    text.replace(PadsAsciiSyntax::LABEL_POS_Y, QString::number(-PIN_SPAN));\r\n    output << text.join(PadsAsciiSyntax::SEPARATOR) << Qt::endl;\r\n    output << \"*\" << Qt::endl;\r\n\r\n    // Second part attribute value definition.\r\n    text.replace(PadsAsciiSyntax::LABEL_POS_Y, QString::number(partHeight + PIN_SPAN));\r\n    output << text.join(PadsAsciiSyntax::SEPARATOR) << Qt::endl;\r\n    output << \"*\" << Qt::endl;\r\n\r\n    // Drawing symbol, rectangle, corner points. First point twice.\r\n    output << PadsAsciiSyntax::CAE_RECT_PIECE << Qt::endl;\r\n    output << drawSymbol.topLeft().x() << \" \" << drawSymbol.topLeft().y() << Qt::endl;\r\n    output << drawSymbol.bottomLeft().x() << \" \" << drawSymbol.bottomLeft().y() << Qt::endl;        \r\n    output << drawSymbol.bottomRight().x() << \" \" << drawSymbol.bottomRight().y() << Qt::endl;\r\n    output << drawSymbol.topRight().x() << \" \" << drawSymbol.topRight().y() << Qt::endl;\r\n    output << drawSymbol.topLeft().x() << \" \" << drawSymbol.topLeft().y() << Qt::endl;\r\n\r\n    // First label for gate title.\r\n    QStringList overheadLabel = PadsAsciiSyntax::TEXT_ITEM.split(PadsAsciiSyntax::SEPARATOR);             \r\n    overheadLabel.replace(PadsAsciiSyntax::TEXT_POS_X, QString::number(drawSymbol.center().x()));\r\n    overheadLabel.replace(PadsAsciiSyntax::TEXT_POS_Y, QString::number(drawSymbol.bottom() - PIN_SPAN));\r\n    overheadLabel.replace(PadsAsciiSyntax::TEXT_ROTATION, QString::number(NO_ROTATION));\r\n    overheadLabel.replace(PadsAsciiSyntax::LAYER, QString::number(LAYER));\r\n    overheadLabel.replace(PadsAsciiSyntax::TEXT_WIDTH, QString::number(LABEL_DEFAULT_WIDTH));\r\n    overheadLabel.replace(PadsAsciiSyntax::TEXT_HEIGHT, QString::number(LABEL_DEFAULT_HEIGHT));\r\n    overheadLabel.replace(PadsAsciiSyntax::TEXT_MIRRORING, QString::number(LEFT_MIRROR));\r\n    overheadLabel.replace(PadsAsciiSyntax::TEXT_JUSTIFICATION, QString::number(LABEL_JUSTIFICATION));\r\n    overheadLabel.replace(PadsAsciiSyntax::PCB_DRAW_NUMBER, \"0\");\r\n    overheadLabel.replace(PadsAsciiSyntax::FIELD_FLAG, \"0\");\r\n    overheadLabel.replace(PadsAsciiSyntax::TEXT_FONTINFO, PadsAsciiSyntax::DEFAULT_FONT);\r\n    output << overheadLabel.join(PadsAsciiSyntax::SEPARATOR) << Qt::endl;                                        \r\n    output << gateTitle << Qt::endl;\r\n\r\n    // Second label for gate name.\r\n    overheadLabel.replace(PadsAsciiSyntax::TEXT_POS_Y, QString::number(drawSymbol.bottom() - 2*PIN_SPAN));\r\n    output << overheadLabel.join(PadsAsciiSyntax::SEPARATOR) << Qt::endl;         \r\n    output << gateName << Qt::endl;        \r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PadsPartGenerator::generateCAETerminals()\r\n//-----------------------------------------------------------------------------\r\nvoid PadsPartGenerator::insertCAETerminals(QTextStream& output, QRect const& drawSymbol, int pinCount)\r\n{\r\n    int halfPins = pinCount/2;\r\n    if (pinCount % 2 != 0)\r\n    {\r\n        halfPins++;\r\n    }\r\n\r\n    int x = -PIN_WIDTH;\r\n    int y = drawSymbol.bottom() - 4*PIN_SPAN;\r\n\r\n    QStringList terminal = PadsAsciiSyntax::CAE_TERMINAL.split(PadsAsciiSyntax::SEPARATOR);\r\n    terminal.replace(PadsAsciiSyntax::TERMINAL_POS_X, QString::number(x));\r\n    terminal.replace(PadsAsciiSyntax::TERMINAL_ROTATION, QString::number(NO_ROTATION));\r\n    terminal.replace(PadsAsciiSyntax::TERMINAL_MIRROR, QString::number(LEFT_MIRROR));\r\n    terminal.replace(PadsAsciiSyntax::TERMINAL_PINNUM_X, QString::number(PINNUMBER_DISTANCE));\r\n    terminal.replace(PadsAsciiSyntax::TERMINAL_PINNUM_Y, QString::number(20));\r\n    terminal.replace(PadsAsciiSyntax::TERMINAL_PINNUM_ROTATION, QString::number(NO_ROTATION));\r\n    terminal.replace(PadsAsciiSyntax::TERMINAL_PINNUM_JUSTIFICATION, QString::number(JUST_TOP_LEFT));\r\n    terminal.replace(PadsAsciiSyntax::TERMINAL_PINNAME_X, QString::number(PINNAME_X));\r\n    terminal.replace(PadsAsciiSyntax::TERMINAL_PINNAME_Y, QString::number(PINNAME_Y));\r\n    terminal.replace(PadsAsciiSyntax::TERMINAL_PINNAME_ROTATION, QString::number(NO_ROTATION));\r\n    terminal.replace(PadsAsciiSyntax::TERMINAL_PINNAME_JUSTIFICATION, QString::number(PIN_JUSTIFICATION));\r\n    terminal.replace(PadsAsciiSyntax::TERMINAL_PINNAME, \"PIN\");\r\n\r\n    QStringList pinProperty = PadsAsciiSyntax::CAE_PIN_PROPERTY.split(PadsAsciiSyntax::SEPARATOR);\r\n    pinProperty.replace(PadsAsciiSyntax::PINPROPERTY_POS_X, QString::number(PIN_PROPERTY_DISTANCE));\r\n    pinProperty.replace(PadsAsciiSyntax::PINPROPERTY_POS_Y, \"0\");\r\n    pinProperty.replace(PadsAsciiSyntax::PINPROPERTY_ROTATION, QString::number(NO_ROTATION));\r\n    pinProperty.replace(PadsAsciiSyntax::PINPROPERTY_JUSTIFICATION, QString::number(JUST_TOP_LEFT));\r\n    pinProperty.replace(PadsAsciiSyntax::NETNAME_POS_X, QString::number(NETNAME_DISTANCE));\r\n    pinProperty.replace(PadsAsciiSyntax::NETNAME_POS_Y, \"0\");\r\n    pinProperty.replace(PadsAsciiSyntax::NETNAME_ROTATION, QString::number(NO_ROTATION));\r\n    pinProperty.replace(PadsAsciiSyntax::NETNAME_JUSTIFICATION, QString::number(JUST_TOP_LEFT));\r\n    pinProperty.replace(PadsAsciiSyntax::PINPROPERTY_FLAGS, \"0\");\r\n\r\n\r\n    // Left side terminals.\r\n    for (int i = 0; i < halfPins; i++)\r\n    {\r\n        terminal.replace(PadsAsciiSyntax::TERMINAL_POS_Y,QString::number(y));\r\n\r\n        output << \"T\" << terminal.join(PadsAsciiSyntax::SEPARATOR) << Qt::endl;\r\n        output << \"P\" << pinProperty.join(PadsAsciiSyntax::SEPARATOR) << Qt::endl;\r\n\r\n        y -= PIN_SPAN;\r\n    }\r\n\r\n    // Right side terminals.\r\n    y = drawSymbol.bottom() - 4*PIN_SPAN;\r\n    x = drawSymbol.right() + PIN_WIDTH;\r\n \r\n    terminal.replace(PadsAsciiSyntax::TERMINAL_MIRROR, QString::number(RIGHT_MIRROR));\r\n    terminal.replace(PadsAsciiSyntax::TERMINAL_POS_X, QString::number(x));\r\n    for (int i = halfPins; i < pinCount; i++)\r\n    {\r\n        terminal.replace(PadsAsciiSyntax::TERMINAL_POS_Y,QString::number(y));\r\n\r\n        output << \"T\" << terminal.join(PadsAsciiSyntax::SEPARATOR) << Qt::endl;\r\n        output << \"P\" << pinProperty.join(PadsAsciiSyntax::SEPARATOR) << Qt::endl;\r\n\r\n        y -= PIN_SPAN;\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PadsPartGenerator::addFileToFileset()\r\n//-----------------------------------------------------------------------------\r\nbool PadsPartGenerator::addFileToFileset(QSharedPointer<FileSet> fileSet, \r\n    QString const& filePath, QString const& basePath, const QStringList& fileTypes)\r\n{\r\n    QString relativePath = General::getRelativePath(basePath, filePath);\r\n    if (relativePath.isEmpty())\r\n    {        \r\n        return false;\r\n    }\r\n\r\n    // Add a new file to fileset.\r\n    QSharedPointer<File> partFile(new File(relativePath, 0));    \r\n    partFile->setIncludeFile(false);   \r\n\r\n    for (auto const& fileType : fileTypes)\r\n    {\r\n        partFile->getFileTypes()->append(FileType(fileType));\r\n    }\r\n  \r\n    fileSet->addFile(partFile);\r\n    return true;\r\n}\r\n"
  },
  {
    "path": "Plugins/PadsPartGenerator/PadsPartGenerator.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: PadsPartGenerator.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Esko Pekkarinen\r\n// Date: 5.11.2013\r\n//\r\n// Description:\r\n// Generator for PADS parts.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef PADSPARTGENERATOR_H\r\n#define PADSPARTGENERATOR_H\r\n\r\n#include \"PadsPartGeneratorDialog.h\"\r\n#include <KactusAPI/include/IGeneratorPlugin.h>\r\n#include <KactusAPI/include/IPlugin.h>\r\n\r\n#include <QtPlugin>\r\n#include <QObject>\r\n#include <QSharedPointer>\r\n#include <QString>\r\n#include <QIcon>\r\n#include <QFileInfo>\r\n#include <QSettings>\r\n\r\nclass Component;\r\nclass Document;\r\nclass FileSet;\r\nclass IPluginUtility;\r\nclass PluginSettingsWidget;\r\n\r\n//-----------------------------------------------------------------------------\r\n// class PadsPartGenerator.\r\n//-----------------------------------------------------------------------------\r\nclass PadsPartGenerator : public QObject, public IGeneratorPlugin\r\n{\r\n    Q_OBJECT\r\n    Q_PLUGIN_METADATA(IID \"kactus2.plugins.PadsPartGenerator\" FILE \"padspartgenerator.json\")\r\n    Q_INTERFACES(IPlugin)\r\n    Q_INTERFACES(IGeneratorPlugin)\r\n\r\npublic:\r\n\r\n\t/*!\r\n\t *  The constructor.\r\n\t */\r\n\tPadsPartGenerator();\r\n\r\n    // Disable copying.\r\n    PadsPartGenerator(PadsPartGenerator const& rhs) = delete;\r\n\r\n    // Disable assignment.\r\n    PadsPartGenerator& operator=(PadsPartGenerator& rhs) = delete;\r\n\r\n\t/*!\r\n\t *  The destructor.\r\n\t*/\r\n\tvirtual ~PadsPartGenerator() = default;\r\n\r\n    //! Returns the name of the plugin.\r\n    virtual QString getName() const override final;\r\n\r\n\t//! Returns the version of the plugin.\r\n    virtual QString getVersion() const override final;\r\n\r\n\t//! Returns the description of the plugin.\r\n    virtual QString getDescription() const override final;\r\n\r\n    /*!\r\n     *  Returns the vendor of the plugin.\r\n     */\r\n    virtual QString getVendor() const override final;\r\n\r\n    /*!\r\n     *  Returns the license of the plugin.\r\n     */\r\n    virtual QString getLicense() const override final;\r\n\r\n    /*!\r\n     *  Returns the holder of the license of the plugin.\r\n     */\r\n    virtual QString getLicenseHolder() const override final;\r\n\r\n\t//! Returns the icon for the generator.\r\n    /*!\r\n     *  Returns the settings widget.\r\n     */\r\n    virtual QWidget* getSettingsWidget() override final;\r\n\r\n    /*!\r\n     *  This is used to access the settings modified by function getSettingsWidget().\r\n     */\r\n    virtual PluginSettingsModel* getSettingsModel() override final {return nullptr;}\r\n\r\n    /*!\r\n     *  Returns the icon for the generator.\r\n     */\r\n    virtual QIcon getIcon() const override final;\r\n\r\n    /*!\r\n    *  Checks whether the generator may run for the given component or design. \r\n    *\r\n    *    @param [in] component\t        The component for which to check support. If design is not null, component\r\n    *                                      will refer to design or designConfiguration.\r\n    *    @param [in] design\t            The design, if the generator is ran for a design.\r\n    *    @param [in] designConfiguration The design configuration for design, if it is not null.\r\n    *\r\n    *    @return True, if the generator may run the given component. Otherwise false.\r\n    */\r\n    virtual bool checkGeneratorSupport(QSharedPointer<Component const> component,\r\n        QSharedPointer<Design const> design,\r\n        QSharedPointer<DesignConfiguration const> designConfiguration) const override final;\r\n\r\n    /*!\r\n     *  Runs the generation, creating new files and/or modifying the IP-XACT metadata. The function has\r\n\t *  also access to the parent window widget, so that it can show dialogs for the user to aid the generation.\r\n     *\r\n     *    @param [in] utility\t\t\t    The plugin utility interface.\r\n     *    @param [in] component\t        The component for which to check support. If design is not null, component\r\n     *                                      will refer to design or designConfiguration.\r\n     *    @param [in] design\t            The design, if the generator is ran for a design.\r\n     *    @param [in] designConfiguration The design configuration for design, if it is not null.\r\n     */\r\n    virtual void runGenerator(IPluginUtility* utility, \r\n        QSharedPointer<Component> component,\r\n        QSharedPointer<Design> design,\r\n        QSharedPointer<DesignConfiguration> designConfiguration) override final;\r\n\r\n\t //! Returns the external program requirements of the plugin.\r\n\t virtual QList<IPlugin::ExternalProgramRequirement> getProgramRequirements() override final;\r\n\r\nprivate:\r\n\r\n    /*!\r\n     *  Writes the PADS part file.\r\n     *\r\n     *    @param [in] file            The file to write to.\r\n     *    @param [in] partDescription The part description to write.\r\n     *\r\n     *    @return True, if part file was successfully written, otherwise false.\r\n     */\r\n    bool generatePartFile(QFile* file, QString const& partDescription);\r\n\r\n    /*!\r\n     *  Writes the PADS CAE decal file.\r\n     *\r\n     *    @param [in] file            The file to write to.\r\n     *    @param [in] partTitle       The part title displayed on all gates.\r\n     *    @param [in] partDescription The PADS part description.\r\n     *\r\n     *    @return True, if CAE file was successfully written, otherwise false.\r\n     */\r\n    bool generateCAEFile(QFile* file, QString const& partTitle, QString const& partDescription);\r\n\r\n    /*!\r\n     *  Generates the CAE decal terminals and prints them into an output stream.\r\n     *\r\n     *    @param [in] output      The output stream for generation.\r\n     *    @param [in] drawSymbol  The rectangle used as a drawing symbol for decal.\r\n     *    @param [in] pinCount    The number of terminals in the decal.\r\n     */\r\n    void insertCAETerminals( QTextStream& output, QRect const& drawSymbol, int pinCount );  \r\n\r\n    /*!\r\n     *  Generates the CAE decal and prints it into an output stream.\r\n     *\r\n     *    @param [in] output          The output stream for generation.\r\n     *    @param [in] drawSymbol      The rectangle used as a drawing symbol for decal.\r\n     *    @param [in] gateTitle       The title of the gate.\r\n     *    @param [in] gateName        The name of the gate used as a decal name.      \r\n     */\r\n    void insertCAEDecal(QTextStream& output, QRect const& drawSymbol,\r\n        QString const& gateTitle, QString const& gateName); \r\n    \r\n\r\n    /*!\r\n     *  Generates the CAE header lines and prints them into an output stream.\r\n     *\r\n     *    @param [in] output      The output stream for generation.\r\n     *    @param [in] timestamp   Header line with timestamp to insert.\r\n     *    @param [in] gateName    The name of the gate used as a decal name.\r\n     *    @param [in] pinCount    The number of terminals in the decal.\r\n     */\r\n    void insertCAEHeader( QTextStream& output, QString const& timestamp, QString const& gateName, int pinCount );\r\n   \r\n\r\n    // void generateCAETerminals( QTextStream& output, gateGenerationType generationType );\r\n\r\n    /*!\r\n     *  Adds a file to a file set with defined file types.\r\n     *\r\n     *    @param [in] fileSet         The file set.\r\n     *    @param [in] filePath        The path to file which is added.\r\n     *    @param [in] basePath        The base path of the component xlm file.\r\n     *    @param [in] fileTypes       The filetypes of the added file.\r\n     *\r\n     *    @return True, if the file was successfully added to file set, otherwise false.\r\n     */\r\n    bool addFileToFileset(QSharedPointer<FileSet> fileSet, QString const& filePath, QString const& basePath,\r\n        const QStringList& fileTypes);\r\n\r\n};\r\n#endif // PADSPARTGENERATOR_H\r\n"
  },
  {
    "path": "Plugins/PadsPartGenerator/PadsPartGenerator.pri",
    "content": "# ----------------------------------------------------\r\n# This file is generated by the Qt Visual Studio Tools.\r\n# ------------------------------------------------------\r\n\r\nHEADERS += ./PadsAsciiSyntax.h \\\r\n    ./PadsPartGenerator.h \\\r\n    ./PadsPartGeneratorDialog.h\r\nSOURCES += ./PadsPartGenerator.cpp \\\r\n    ./PadsPartGeneratorDialog.cpp\r\nRESOURCES += PadsPartGenerator.qrc\r\n"
  },
  {
    "path": "Plugins/PadsPartGenerator/PadsPartGenerator.pro",
    "content": "# ----------------------------------------------------\r\n# This file is generated by the Qt Visual Studio Add-in.\r\n# ------------------------------------------------------\r\n\r\nTEMPLATE = lib\r\n\r\nQT += core xml widgets gui\r\nCONFIG += c++11\r\nDEFINES += QT_DLL QT_WIDGETS_LIB QT_XML_LIB\r\n\r\nINCLUDEPATH += ./GeneratedFiles \\\r\n    . \\\r\n    ./../..\r\n\r\nCONFIG(debug, debug|release) {\r\n    # debug mode\r\n    LIBS += \\\r\n        -L../../executable -lIPXACTmodelsd \\\r\n        -L../../executable -lKactusAPId\r\n\r\n    MOC_DIR += ./GeneratedFiles/Debug\r\n    OBJECTS_DIR += Debug\r\n    TARGET = PadsPartGeneratord\r\n\r\n} else {\r\n    # release mode \r\n    LIBS += \\\r\n        -L../../executable -lIPXACTmodels \\\r\n        -L../../executable -lKactusAPI\r\n    \r\n    MOC_DIR += ./GeneratedFiles/Release\r\n    OBJECTS_DIR += Release\r\n    TARGET = PadsPartGenerator\r\n}\r\n\r\nDESTDIR = ../../executable/Plugins\r\n\r\nDEPENDPATH += .\r\nUI_DIR += ./GeneratedFiles\r\nRCC_DIR += ./GeneratedFiles\r\ninclude(PadsPartGenerator.pri)\r\n\r\ntarget.path = $$plugin_path\r\nINSTALLS += target\r\n"
  },
  {
    "path": "Plugins/PadsPartGenerator/PadsPartGenerator.qrc",
    "content": "<RCC>\r\n    <qresource prefix=\"/icons\">\r\n        <file>processor.png</file>\r\n    </qresource>\r\n</RCC>\r\n"
  },
  {
    "path": "Plugins/PadsPartGenerator/PadsPartGenerator.vcxproj",
    "content": "﻿<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n<Project DefaultTargets=\"Build\" ToolsVersion=\"15.0\" xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">\r\n  <ItemGroup Label=\"ProjectConfigurations\">\r\n    <ProjectConfiguration Include=\"Debug|x64\">\r\n      <Configuration>Debug</Configuration>\r\n      <Platform>x64</Platform>\r\n    </ProjectConfiguration>\r\n    <ProjectConfiguration Include=\"Release|x64\">\r\n      <Configuration>Release</Configuration>\r\n      <Platform>x64</Platform>\r\n    </ProjectConfiguration>\r\n  </ItemGroup>\r\n  <PropertyGroup Label=\"Globals\">\r\n    <ProjectGuid>{A84E0600-2A1B-4593-9D89-25098A0150AA}</ProjectGuid>\r\n    <Keyword>QtVS_v304</Keyword>\r\n    <WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>\r\n    <QtMsBuild Condition=\"'$(QtMsBuild)'=='' or !Exists('$(QtMsBuild)\\qt.targets')\">$(MSBuildProjectDirectory)\\QtMsBuild</QtMsBuild>\r\n  </PropertyGroup>\r\n  <Import Project=\"$(VCTargetsPath)\\Microsoft.Cpp.Default.props\" />\r\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\" Label=\"Configuration\">\r\n    <ConfigurationType>DynamicLibrary</ConfigurationType>\r\n    <PlatformToolset>v143</PlatformToolset>\r\n  </PropertyGroup>\r\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\" Label=\"Configuration\">\r\n    <ConfigurationType>DynamicLibrary</ConfigurationType>\r\n    <PlatformToolset>v143</PlatformToolset>\r\n  </PropertyGroup>\r\n  <Import Project=\"$(VCTargetsPath)\\Microsoft.Cpp.props\" />\r\n  <Target Name=\"QtMsBuildNotFound\" BeforeTargets=\"CustomBuild;ClCompile\" Condition=\"!Exists('$(QtMsBuild)\\qt.targets') or !Exists('$(QtMsBuild)\\qt.props')\">\r\n    <Message Importance=\"High\" Text=\"QtMsBuild: could not locate qt.targets, qt.props; project may not build correctly.\" />\r\n  </Target>\r\n  <ImportGroup Label=\"ExtensionSettings\">\r\n  </ImportGroup>\r\n  <ImportGroup Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\" Label=\"PropertySheets\">\r\n    <Import Project=\"$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props\" Condition=\"exists('$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props')\" Label=\"LocalAppDataPlatform\" />\r\n  </ImportGroup>\r\n  <ImportGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\" Label=\"PropertySheets\">\r\n    <Import Project=\"$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props\" Condition=\"exists('$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props')\" Label=\"LocalAppDataPlatform\" />\r\n  </ImportGroup>\r\n  <PropertyGroup Label=\"UserMacros\" />\r\n  <ImportGroup Condition=\"Exists('$(QtMsBuild)\\qt_defaults.props')\">\r\n    <Import Project=\"$(QtMsBuild)\\qt_defaults.props\" />\r\n  </ImportGroup>\r\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n    <OutDir>$(SolutionDir)executable\\Plugins\\</OutDir>\r\n    <IntDir>$(ProjectDir)\\$(Configuration)\\</IntDir>\r\n  </PropertyGroup>\r\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n    <OutDir>$(SolutionDir)executable\\Plugins\\</OutDir>\r\n    <IntDir>$(ProjectDir)\\$(Configuration)\\</IntDir>\r\n  </PropertyGroup>\r\n  <PropertyGroup Label=\"QtSettings\" Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n    <QtInstall>6.2.4</QtInstall>\r\n    <QtModules>core;gui;widgets;printsupport;xml</QtModules>\r\n  </PropertyGroup>\r\n  <PropertyGroup Label=\"QtSettings\" Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n    <QtInstall>6.2.4</QtInstall>\r\n    <QtModules>core;gui;widgets;printsupport;xml</QtModules>\r\n  </PropertyGroup>\r\n  <ImportGroup Condition=\"Exists('$(QtMsBuild)\\qt.props')\">\r\n    <Import Project=\"$(QtMsBuild)\\qt.props\" />\r\n  </ImportGroup>\r\n  <PropertyGroup>\r\n    <_ProjectFileVersion>10.0.40219.1</_ProjectFileVersion>\r\n  </PropertyGroup>\r\n  <ItemDefinitionGroup Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n    <ClCompile>\r\n      <PreprocessorDefinitions>UNICODE;WIN32;WIN64;%(PreprocessorDefinitions)</PreprocessorDefinitions>\r\n      <AdditionalIncludeDirectories>.\\GeneratedFiles\\$(ConfigurationName);.\\GeneratedFiles;.;./../..;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\r\n      <Optimization>Disabled</Optimization>\r\n      <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>\r\n      <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>\r\n      <TreatWChar_tAsBuiltInType>true</TreatWChar_tAsBuiltInType>\r\n      <MultiProcessorCompilation>true</MultiProcessorCompilation>\r\n      <LanguageStandard>stdcpp17</LanguageStandard>\r\n      <AdditionalOptions>/Zc:__cplusplus %(AdditionalOptions)</AdditionalOptions>\r\n    </ClCompile>\r\n    <Link>\r\n      <SubSystem>Windows</SubSystem>\r\n      <OutputFile>$(OutDir)$(ProjectName).dll</OutputFile>\r\n      <GenerateDebugInformation>true</GenerateDebugInformation>\r\n      <AdditionalDependencies>IPXACTmodelsd.lib;KactusAPId.lib;%(AdditionalDependencies)</AdditionalDependencies>\r\n      <AdditionalLibraryDirectories>..\\..\\executable;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>\r\n    </Link>\r\n    <QtMoc>\r\n      <ExecutionDescription>Moc'ing %(Identity)...</ExecutionDescription>\r\n      <DynamicSource>output</DynamicSource>\r\n      <QtMocDir>.\\GeneratedFiles\\$(ConfigurationName)</QtMocDir>\r\n      <QtMocFileName>moc_%(Filename).cpp</QtMocFileName>\r\n    </QtMoc>\r\n    <QtRcc>\r\n      <InitFuncName>%(Filename)</InitFuncName>\r\n      <Compression>default</Compression>\r\n      <NoCompression>true</NoCompression>\r\n      <ExecutionDescription>Rcc'ing %(Identity)...</ExecutionDescription>\r\n      <QtRccDir>.\\GeneratedFiles</QtRccDir>\r\n      <QtRccFileName>qrc_%(Filename).cpp</QtRccFileName>\r\n    </QtRcc>\r\n  </ItemDefinitionGroup>\r\n  <ItemDefinitionGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n    <ClCompile>\r\n      <PreprocessorDefinitions>UNICODE;WIN32;WIN64;QT_NO_DEBUG;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>\r\n      <AdditionalIncludeDirectories>.\\GeneratedFiles\\$(ConfigurationName);.\\GeneratedFiles;.;.\\..\\..;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\r\n      <DebugInformationFormat>\r\n      </DebugInformationFormat>\r\n      <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>\r\n      <TreatWChar_tAsBuiltInType>true</TreatWChar_tAsBuiltInType>\r\n      <MultiProcessorCompilation>true</MultiProcessorCompilation>\r\n      <AdditionalOptions>/Zc:__cplusplus %(AdditionalOptions)</AdditionalOptions>\r\n      <LanguageStandard>stdcpp17</LanguageStandard>\r\n    </ClCompile>\r\n    <Link>\r\n      <SubSystem>Windows</SubSystem>\r\n      <OutputFile>$(OutDir)$(ProjectName).dll</OutputFile>\r\n      <AdditionalLibraryDirectories>..\\..\\executable;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>\r\n      <GenerateDebugInformation>false</GenerateDebugInformation>\r\n      <AdditionalDependencies>IPXACTmodels.lib;KactusAPI.lib;%(AdditionalDependencies)</AdditionalDependencies>\r\n    </Link>\r\n    <QtMoc>\r\n      <ExecutionDescription>Moc'ing %(Identity)...</ExecutionDescription>\r\n      <DynamicSource>output</DynamicSource>\r\n      <QtMocDir>.\\GeneratedFiles\\$(ConfigurationName)</QtMocDir>\r\n      <QtMocFileName>moc_%(Filename).cpp</QtMocFileName>\r\n    </QtMoc>\r\n    <QtRcc>\r\n      <InitFuncName>%(Filename)</InitFuncName>\r\n      <Compression>default</Compression>\r\n      <NoCompression>true</NoCompression>\r\n      <ExecutionDescription>Rcc'ing %(Identity)...</ExecutionDescription>\r\n      <QtRccDir>.\\GeneratedFiles</QtRccDir>\r\n      <QtRccFileName>qrc_%(Filename).cpp</QtRccFileName>\r\n    </QtRcc>\r\n  </ItemDefinitionGroup>\r\n  <ItemGroup>\r\n    <ClCompile Include=\"PadsPartGenerator.cpp\" />\r\n    <ClCompile Include=\"PadsPartGeneratorDialog.cpp\" />\r\n  </ItemGroup>\r\n  <ItemGroup>\r\n    <QtMoc Include=\"PadsPartGenerator.h\">\r\n    </QtMoc>\r\n  </ItemGroup>\r\n  <ItemGroup>\r\n    <QtRcc Include=\"PadsPartGenerator.qrc\">\r\n    </QtRcc>\r\n  </ItemGroup>\r\n  <ItemGroup>\r\n    <QtMoc Include=\"PadsPartGeneratorDialog.h\">\r\n    </QtMoc>\r\n  </ItemGroup>\r\n  <ItemGroup>\r\n    <ClInclude Include=\"PadsAsciiSyntax.h\" />\r\n  </ItemGroup>\r\n  <ItemGroup>\r\n    <None Include=\"padspartgenerator.json\" />\r\n    <None Include=\"processor.png\" />\r\n  </ItemGroup>\r\n  <Import Project=\"$(VCTargetsPath)\\Microsoft.Cpp.targets\" />\r\n  <ImportGroup Condition=\"Exists('$(QtMsBuild)\\qt.targets')\">\r\n    <Import Project=\"$(QtMsBuild)\\qt.targets\" />\r\n  </ImportGroup>\r\n  <ImportGroup Label=\"ExtensionTargets\">\r\n  </ImportGroup>\r\n  <ProjectExtensions>\r\n    <VisualStudio>\r\n      <UserProperties />\r\n    </VisualStudio>\r\n  </ProjectExtensions>\r\n</Project>"
  },
  {
    "path": "Plugins/PadsPartGenerator/PadsPartGenerator.vcxproj.filters",
    "content": "﻿<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n<Project ToolsVersion=\"4.0\" xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">\r\n  <ItemGroup>\r\n    <Filter Include=\"Source Files\">\r\n      <UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>\r\n      <Extensions>cpp;cxx;c;def</Extensions>\r\n    </Filter>\r\n    <Filter Include=\"Header Files\">\r\n      <UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>\r\n      <Extensions>h</Extensions>\r\n    </Filter>\r\n    <Filter Include=\"Resource Files\">\r\n      <UniqueIdentifier>{D9D6E242-F8AF-46E4-B9FD-80ECBC20BA3E}</UniqueIdentifier>\r\n      <Extensions>qrc;*</Extensions>\r\n      <ParseFiles>false</ParseFiles>\r\n    </Filter>\r\n    <Filter Include=\"Generated Files\">\r\n      <UniqueIdentifier>{71ED8ED8-ACB9-4CE9-BBE1-E00B30144E11}</UniqueIdentifier>\r\n      <Extensions>moc;h;cpp</Extensions>\r\n      <SourceControlFiles>False</SourceControlFiles>\r\n    </Filter>\r\n    <Filter Include=\"Generated Files\\Debug\">\r\n      <UniqueIdentifier>{5afe9391-6803-4c0a-9c33-affb8679b911}</UniqueIdentifier>\r\n      <Extensions>cpp;moc</Extensions>\r\n      <SourceControlFiles>False</SourceControlFiles>\r\n    </Filter>\r\n    <Filter Include=\"Generated Files\\Release\">\r\n      <UniqueIdentifier>{f8a31f96-9b72-47f6-b75a-82f02423e052}</UniqueIdentifier>\r\n      <Extensions>cpp;moc</Extensions>\r\n      <SourceControlFiles>False</SourceControlFiles>\r\n    </Filter>\r\n  </ItemGroup>\r\n  <ItemGroup>\r\n    <ClCompile Include=\"PadsPartGenerator.cpp\">\r\n      <Filter>Source Files</Filter>\r\n    </ClCompile>\r\n    \r\n    \r\n    \r\n    <ClCompile Include=\"PadsPartGeneratorDialog.cpp\">\r\n      <Filter>Source Files</Filter>\r\n    </ClCompile>\r\n    \r\n    \r\n  </ItemGroup>\r\n  <ItemGroup>\r\n    <QtMoc Include=\"PadsPartGenerator.h\">\r\n      <Filter>Header Files</Filter>\r\n    </QtMoc>\r\n    <QtRcc Include=\"PadsPartGenerator.qrc\">\r\n      <Filter>Resource Files</Filter>\r\n    </QtRcc>\r\n    <QtMoc Include=\"PadsPartGeneratorDialog.h\">\r\n      <Filter>Header Files</Filter>\r\n    </QtMoc>\r\n  </ItemGroup>\r\n  <ItemGroup>\r\n    <None Include=\"processor.png\">\r\n      <Filter>Resource Files</Filter>\r\n    </None>\r\n    <None Include=\"padspartgenerator.json\" />\r\n  </ItemGroup>\r\n  <ItemGroup>\r\n    <ClInclude Include=\"PadsAsciiSyntax.h\">\r\n      <Filter>Header Files</Filter>\r\n    </ClInclude>\r\n  </ItemGroup>\r\n</Project>"
  },
  {
    "path": "Plugins/PadsPartGenerator/PadsPartGeneratorDialog.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: PadsPartGeneratorDialog\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Esko Pekkarinen\r\n// Date: 5.11.2013\r\n//\r\n// Description:\r\n// Dialog for PADS part generation settings.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"PadsPartGeneratorDialog.h\"\r\n#include \"PadsPartGenerator.h\"\r\n#include \"PadsAsciiSyntax.h\"\r\n\r\n#include <KactusAPI/include/LibraryInterface.h>\r\n\r\n#include <KactusAPI/include/ExpressionParser.h>\r\n\r\n#include <IPXACTmodels/AbstractionDefinition/AbstractionDefinition.h>\r\n#include <IPXACTmodels/AbstractionDefinition/PortAbstraction.h>\r\n#include <IPXACTmodels/AbstractionDefinition/WireAbstraction.h>\r\n\r\n#include <IPXACTmodels/common/Vector.h>\r\n#include <IPXACTmodels/common/VLNV.h>\r\n\r\n#include <IPXACTmodels/Component/BusInterface.h>\r\n#include <IPXACTmodels/Component/Component.h>\r\n#include <IPXACTmodels/Component/File.h>\r\n#include <IPXACTmodels/Component/FileSet.h>\r\n#include <IPXACTmodels/Component/PortMap.h>\r\n\r\n#include <QApplication>\r\n#include <QTextCharFormat>\r\n#include <QComboBox>\r\n#include <QDateTime>\r\n#include <QFile>\r\n#include <QFormLayout>\r\n#include <QGroupBox>\r\n#include <QHBoxLayout>\r\n#include <QLineEdit>\r\n#include <QMessageBox>\r\n#include <QRadioButton>\r\n#include <QRegularExpression>\r\n#include <QRegularExpressionValidator>\r\n#include <QTextBlock>\r\n#include <QTextCursor>\r\n#include <QTextStream>\r\n#include <QMap>\r\n#include <QPlainTextEdit>\r\n#include <QPushButton>\r\n#include <QRadioButton>\r\n#include <QScrollBar>\r\n#include <QVBoxLayout>\r\n\r\nnamespace\r\n{\r\n    // Unit indexes in unitSelector_.\r\n    enum UNIT_INDEX\r\n    {\r\n        IMPERIAL = 0,\r\n        METRIC\r\n    };\r\n\r\n    // Author, VLNV and plugin version are added as default attributes.\r\n    const int PREGEN_ATTRS = 6;\r\n\r\n    // Default file set name.\r\n    const QString DEFAULT_FILESET = \"PadsFiles\";\r\n\r\n    // Default gate name.\r\n    const QString DEFAULT_GATENAME = \"Default_Gate\";\r\n\r\n    // Dialog settings.\r\n    const int MINIMUM_WIDTH = 600;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PadsPartGeneratorDialog::PadsPartGeneratorDialog()\r\n//-----------------------------------------------------------------------------\r\nPadsPartGeneratorDialog::PadsPartGeneratorDialog(LibraryInterface* libIf,\r\n    QSharedPointer<const Component> component, QSharedPointer<ExpressionParser> expressionParser, \r\n    QString const& generatorName,  QString const& generatorVersion, QWidget* parent):\r\nQDialog(parent),\r\nlibHandler_(libIf),\r\ncomponent_(component),\r\nexpressionParser_(expressionParser),\r\ngeneratorName_(generatorName),\r\ngeneratorVersion_(generatorVersion),\r\nfileSetSelector_(new QComboBox(this)),\r\nviewSelector_(new QComboBox(this)),\r\nnameEditor_(new QLineEdit(this)),\r\nunitSelector_(new QComboBox(this)),\r\nfamilyEditor_(new QLineEdit(this)),\r\nmultiGateButton_(new QRadioButton(tr(\"Create one gate per bus definition\"), this)),\r\nsingleGateButton_(new QRadioButton(tr(\"Create single gate\"), this)),\r\ngateNameEditor_(new QLineEdit(this)),\r\npreview_(new QPlainTextEdit(this)),\r\ngateGenerationType_(MULTIPLEGATES),\r\ngates_(),\r\nokFormat_(),\r\nerrorFormat_()\r\n{\r\n    setWindowTitle(generatorName_);\r\n\r\n    // Part name editor.\r\n    QRegularExpressionValidator* nameValidator = new QRegularExpressionValidator(\r\n        QRegularExpression(\"\\\\w{1,40}\", QRegularExpression::CaseInsensitiveOption), this);\r\n    nameEditor_->setValidator(nameValidator);    \r\n    nameEditor_->setText(component_->getVlnv().getName());    \r\n    connect(nameEditor_, SIGNAL(textChanged(QString const&)),\r\n        this, SLOT(onNameChanged()), Qt::UniqueConnection);\r\n\r\n    // File set selector.\r\n    fileSetSelector_->setEditable(false);\r\n    fileSetSelector_->addItem(tr(\"<Create new fileset>\"));\r\n    fileSetSelector_->setCurrentIndex(0);\r\n    \r\n    // Add file sets to selector.\r\n    foreach(QString fileSetName, component_->getFileSetNames())\r\n    {\r\n        fileSetSelector_->addItem(fileSetName);\r\n        // If default file set is found, set it as selection.\r\n        if (QString::compare(fileSetName, DEFAULT_FILESET) == 0)\r\n        {\r\n            fileSetSelector_->setCurrentIndex(fileSetSelector_->count() - 1);\r\n        }\r\n    }\r\n\r\n    foreach (QString viewName, component_->getViewNames())\r\n    {\r\n        viewSelector_->addItem(viewName);\r\n    }\r\n\r\n    if (viewSelector_->count() > 0)\r\n    {\r\n        viewSelector_->setCurrentIndex(0);\r\n    }\r\n\r\n    // Part measurement unit selection.\r\n    unitSelector_->setEditable(false);\r\n    unitSelector_->addItem(tr(\"Imperial (mils)\"));\r\n    unitSelector_->addItem(tr(\"Metric (mm)\"));\r\n    unitSelector_->setCurrentIndex(IMPERIAL);\r\n    connect(unitSelector_, SIGNAL(currentIndexChanged(int)),\r\n        this, SLOT(onUnitChanged()), Qt::UniqueConnection);\r\n\r\n    // Part logic family editor.\r\n    QRegularExpressionValidator* familyValidator = new QRegularExpressionValidator(\r\n        QRegularExpression(\"\\\\w{3}\", QRegularExpression::CaseInsensitiveOption), this);\r\n    familyEditor_->setValidator(familyValidator);\r\n    familyEditor_->setText(\"MOS\");\r\n    connect(familyEditor_, SIGNAL(textChanged(QString const&)),\r\n        this, SLOT(onFamilyChanged()), Qt::UniqueConnection);\r\n\r\n    // Gate generation type.\r\n    multiGateButton_->setChecked(true);\r\n    connect(multiGateButton_, SIGNAL(toggled(bool)),\r\n        this, SLOT(onGateSelectionChanged()), Qt::UniqueConnection);\r\n\r\n    // Gate name editor.\r\n    QRegularExpressionValidator* gateNameValidator = new QRegularExpressionValidator(\r\n        QRegularExpression(\"\\\\w{1,40}\", QRegularExpression::CaseInsensitiveOption), this);\r\n    gateNameEditor_->setValidator(gateNameValidator);  \r\n    gateNameEditor_->setText(DEFAULT_GATENAME);  \r\n    gateNameEditor_->setEnabled(false);\r\n    connect(gateNameEditor_, SIGNAL(textChanged(QString const&)),\r\n        this, SLOT(onGateNameChanged()), Qt::UniqueConnection);\r\n\r\n    // Part preview.\r\n    preview_->setReadOnly(true);\r\n    preview_->setLineWrapMode(QPlainTextEdit::NoWrap);\r\n\r\n    setupLayout();\r\n\r\n    // Formatting options.\r\n    okFormat_.setForeground(QBrush(\"black\"));\r\n    errorFormat_.setForeground(QBrush(\"red\"));\r\n    \r\n    refreshPreview();      \r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PadsPartGeneratorDialog::~PadsPartGeneratorDialog()\r\n//-----------------------------------------------------------------------------\r\nPadsPartGeneratorDialog::~PadsPartGeneratorDialog()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PadsPartGeneratorDialog::getPartName()\r\n//-----------------------------------------------------------------------------\r\nQString PadsPartGeneratorDialog::getPartName() const\r\n{\r\n    return nameEditor_->text();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PadsPartGeneratorDialog::getTargetFile()\r\n//-----------------------------------------------------------------------------\r\nQString PadsPartGeneratorDialog::getFileSetName() const\r\n{\r\n    if (fileSetSelector_->currentIndex() != 0)\r\n    {\r\n        return fileSetSelector_->currentText();\r\n    } \r\n    else\r\n    {\r\n        return DEFAULT_FILESET;\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PadsPartGeneratorDialog::getPreview()\r\n//-----------------------------------------------------------------------------\r\nQString PadsPartGeneratorDialog::getPreviewText()\r\n{\r\n    return preview_->toPlainText();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PadsPartGeneratorDialog::getGategenerationType()\r\n//-----------------------------------------------------------------------------\r\nPadsPartGeneratorDialog::gateGenerationType PadsPartGeneratorDialog::getGategenerationType() const\r\n{\r\n    return gateGenerationType_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PadsPartGeneratorDialog::updatePreview()\r\n//-----------------------------------------------------------------------------\r\nvoid PadsPartGeneratorDialog::refreshPreview()\r\n{\r\n    QApplication::setOverrideCursor(Qt::WaitCursor);\r\n    gates_.clear();    \r\n    preview_->clear();\r\n\r\n    insertLine(PadsAsciiSyntax::PART_FILE_BEGIN, preview_->textCursor());\r\n\r\n    generateHeader();\r\n    generateGates();\r\n\r\n    insertLine(PadsAsciiSyntax::PADS_FILE_END, preview_->textCursor());\r\n\r\n    QApplication::restoreOverrideCursor();     \r\n\r\n    // Scroll to beginning.\r\n    QTextCursor cursor = preview_->textCursor();\r\n    cursor.movePosition(QTextCursor::Start);\r\n    preview_->setTextCursor(cursor);\r\n    preview_->verticalScrollBar()->setSliderPosition(0);    \r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PadsPartGeneratorDialog::onRunClicked()\r\n//-----------------------------------------------------------------------------\r\nvoid PadsPartGeneratorDialog::onRunClicked()\r\n{\r\n    QStringList errorList;\r\n    \r\n    if (!nameEditor_->hasAcceptableInput())\r\n    {\r\n        errorList << tr(\"Part name is invalid.\");\r\n    }\r\n\r\n    if (!familyEditor_->hasAcceptableInput())\r\n    {\r\n        errorList << tr(\"Part logic family is invalid.\");\r\n    }\r\n\r\n    if (gateGenerationType_ == SINGLEGATE && !gateNameEditor_->hasAcceptableInput())\r\n    {\r\n        errorList << tr(\"Gate name is invalid.\");\r\n    }\r\n\r\n    if (!errorList.isEmpty())\r\n    {\r\n        QMessageBox msgBox(QMessageBox::Warning, generatorName_, \r\n            tr(\"The generator cannot run because of the following error(s):\\n\") + errorList.join('\\n'), \r\n            QMessageBox::Ok, this);\r\n        msgBox.exec();\r\n        return;\r\n    } \r\n    else\r\n    {\r\n        accept();\r\n    }    \r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PadsPartGeneratorDialog::onNameChanged()\r\n//-----------------------------------------------------------------------------\r\nvoid PadsPartGeneratorDialog::onNameChanged()\r\n{    \r\n    QTextCursor cursor = preview_->document()->find(PadsAsciiSyntax::PART_HEADER_1ST_EXP);\r\n    if (!cursor.isNull())\r\n    {\r\n        QString newName = nameEditor_->text().toUpper();\r\n        if (!newName.isEmpty())\r\n        {\r\n            // Replace old name with new name in the header.\r\n            QStringList line = cursor.block().text().split(PadsAsciiSyntax::SEPARATOR, Qt::SkipEmptyParts);\r\n            line.replace(PadsAsciiSyntax::NAME, newName);\r\n            cursor.movePosition(QTextCursor::EndOfBlock, QTextCursor::KeepAnchor);        \r\n            cursor.insertText(line.join(PadsAsciiSyntax::SEPARATOR));\r\n\r\n            // Replace old name with new name in gate names.\r\n            foreach(int row, gates_.keys())\r\n            {\r\n                QTextBlock gateBlock = preview_->document()->findBlockByLineNumber(row);\r\n                cursor.setPosition(gateBlock.position());    \r\n                //QString gate = gateBlock.text();\r\n                int index = gateBlock.text().indexOf(gates_.value(row), 0, Qt::CaseInsensitive);  \r\n                if (index != -1)\r\n                {\r\n                    cursor.setPosition(cursor.position() + index, QTextCursor::KeepAnchor);\r\n                    cursor.insertText(newName + \"_\");\r\n                }                                  \r\n            }      \r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PadsPartGeneratorDialog::onUnitChanged()\r\n//-----------------------------------------------------------------------------\r\nvoid PadsPartGeneratorDialog::onUnitChanged()\r\n{\r\n    QTextCursor cursor = preview_->document()->find(PadsAsciiSyntax::PART_HEADER_1ST_EXP);\r\n    if (!cursor.isNull())\r\n    {\r\n        // Replace old unit with new in the header.\r\n        QStringList line = cursor.block().text().split(PadsAsciiSyntax::SEPARATOR, Qt::SkipEmptyParts);\r\n        if (unitSelector_->currentIndex() == IMPERIAL)\r\n        {\r\n            line.replace(PadsAsciiSyntax::UNITS, PadsAsciiSyntax::IMPERIAL);\r\n        } \r\n        else //if (unitSelector_->currentIndex() == METRIC)\r\n        {\r\n            line.replace(PadsAsciiSyntax::UNITS, PadsAsciiSyntax::METRIC);\r\n        }                \r\n        cursor.movePosition(QTextCursor::EndOfBlock, QTextCursor::KeepAnchor);\r\n        cursor.insertText(line.join(PadsAsciiSyntax::SEPARATOR));\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PadsPartGeneratorDialog::onFamilyChanged()\r\n//-----------------------------------------------------------------------------\r\nvoid PadsPartGeneratorDialog::onFamilyChanged()\r\n{\r\n    if (familyEditor_->hasAcceptableInput())\r\n    {\r\n        // Replace old logic family with new in the header.\r\n        QTextCursor cursor = preview_->document()->find(PadsAsciiSyntax::PART_HEADER_1ST_EXP);\r\n        if (!cursor.isNull())\r\n        {\r\n            QStringList line = cursor.block().text().split(PadsAsciiSyntax::SEPARATOR, Qt::SkipEmptyParts);\r\n            line.replace(PadsAsciiSyntax::LOGFAMILY, familyEditor_->text());\r\n\r\n            cursor.movePosition(QTextCursor::EndOfBlock, QTextCursor::KeepAnchor);\r\n            cursor.insertText(line.join(PadsAsciiSyntax::SEPARATOR));\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PadsPartGeneratorDialog::onGateSelectionChanged()\r\n//-----------------------------------------------------------------------------\r\nvoid PadsPartGeneratorDialog::onGateSelectionChanged()\r\n{\r\n    gateGenerationType oldSelection = gateGenerationType_;\r\n\r\n    if (multiGateButton_->isChecked())\r\n    {\r\n        gateGenerationType_ = MULTIPLEGATES;\r\n    } \r\n    else\r\n    {\r\n        gateGenerationType_ = SINGLEGATE;\r\n    }\r\n\r\n    // Enable/disable gate name editing.\r\n    gateNameEditor_->setEnabled(singleGateButton_->isChecked());\r\n\r\n    // Regenerate gates.\r\n    if (gateGenerationType_ != oldSelection)\r\n    {\r\n        gates_.clear();\r\n        generateGates();\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PadsPartGeneratorDialog::onGateNameChanged()\r\n//-----------------------------------------------------------------------------\r\nvoid PadsPartGeneratorDialog::onGateNameChanged()\r\n{\r\n    Q_ASSERT(gateGenerationType_ == SINGLEGATE);\r\n\r\n    if (!gateNameEditor_->text().isEmpty() && gates_.size() > 0)\r\n    {\r\n        // Replace old gate name with new one.\r\n        int row = gates_.keys().first();\r\n        QString newName = gateNameEditor_->text();\r\n        QTextCursor cursor = preview_->textCursor();\r\n        QTextBlock gateBlock = preview_->document()->findBlockByLineNumber(row);\r\n        QString block = gateBlock.text();\r\n        QString gate = gates_.value(row);\r\n        int index = gateBlock.text().lastIndexOf(gates_.value(row), -1, Qt::CaseInsensitive);\r\n        if (index != -1)\r\n        {\r\n            cursor.setPosition(gateBlock.position() + index);        \r\n            cursor.movePosition(QTextCursor::NextWord, QTextCursor::KeepAnchor);\r\n            cursor.insertText(newName.toUpper());\r\n            gates_.insert(row, newName);\r\n        }        \r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PadsPartGeneratorDialog::generateHeader()\r\n//-----------------------------------------------------------------------------\r\nvoid PadsPartGeneratorDialog::generateHeader()\r\n{\r\n    QTextCursor cursor = preview_->document()->find(PadsAsciiSyntax::PART_HEADER_1ST_EXP);\r\n    \r\n    if (cursor.isNull())\r\n    {\r\n        cursor = preview_->textCursor();\r\n        cursor.insertBlock();\r\n\r\n        // Insert 1. header line.\r\n        QStringList headerLine1 = PadsAsciiSyntax::PART_HEADER_1ST_LINE.split(PadsAsciiSyntax::SEPARATOR, \r\n            Qt::SkipEmptyParts);    \r\n        \r\n        headerLine1.replace(PadsAsciiSyntax::NAME, nameEditor_->text().toUpper());        \r\n        headerLine1.replace(PadsAsciiSyntax::DECALS, tr(\"NO_DECAL\"));\r\n        if (unitSelector_->currentIndex() == IMPERIAL)\r\n        {\r\n            headerLine1.replace(PadsAsciiSyntax::UNITS, PadsAsciiSyntax::IMPERIAL);\r\n        } \r\n        else\r\n        {\r\n            headerLine1.replace(PadsAsciiSyntax::UNITS, PadsAsciiSyntax::METRIC);\r\n        }\r\n        headerLine1.replace(PadsAsciiSyntax::LOGFAMILY, familyEditor_->text());\r\n\r\n        int numAttr = PREGEN_ATTRS + component_->getParameters()->size();\r\n\r\n        headerLine1.replace(PadsAsciiSyntax::NUM_ATTRS, QString::number(numAttr));\r\n        int gateCount = 1;\r\n        if (gateGenerationType_ == MULTIPLEGATES)\r\n        {\r\n            gateCount = component_->getBusInterfaces()->size();\r\n        } \r\n        headerLine1.replace(PadsAsciiSyntax::NUM_GATES, QString::number(gateCount));\r\n        headerLine1.replace(PadsAsciiSyntax::NUM_SIGNPINS, \"0\");\r\n        headerLine1.replace(PadsAsciiSyntax::NUM_PINMAPS, \"0\");\r\n        headerLine1.replace(PadsAsciiSyntax::FLAG, \"0\");\r\n\r\n        insertLine(headerLine1.join(PadsAsciiSyntax::SEPARATOR), cursor, PadsAsciiSyntax::PART_HEADER_1ST_EXP);         \r\n\r\n        // Insert 2. header line.\r\n        QString headerLine2 = PadsAsciiSyntax::PART_HEADER_2ND_LINE;\r\n\r\n        QDateTime time = QDateTime::currentDateTime();\r\n        headerLine2.replace(\"year\", QString::number(time.date().year()));\r\n        headerLine2.replace(\"month\", QString::number(time.date().month()));\r\n        headerLine2.replace(\"day\", QString::number(time.date().day()));\r\n        headerLine2.replace(\"hour\", QString::number(time.time().hour()));\r\n        headerLine2.replace(\"minute\", QString::number(time.time().minute()));\r\n        headerLine2.replace(\"second\", QString::number(time.time().second()));\r\n\r\n        cursor.insertText(headerLine2);\r\n        cursor.insertBlock();        \r\n        preview_->setTextCursor(cursor);\r\n\r\n        // Insert attributes.\r\n        insertAttributes(cursor);\r\n        cursor.insertBlock();\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PadsPartGeneratorDialog::onGenerateGates()\r\n//-----------------------------------------------------------------------------\r\nvoid PadsPartGeneratorDialog::generateGates()\r\n{\r\n    QTextCursor cursor = preview_->document()->find(PadsAsciiSyntax::PART_GATE_EXP);\r\n\r\n    if (!cursor.isNull())\r\n    {\r\n        // Clear previous gate information.               \r\n        QTextCursor endCursor = preview_->document()->find(PadsAsciiSyntax::PADS_FILE_END);\r\n        cursor.setPosition(endCursor.position(), QTextCursor::KeepAnchor);\r\n        cursor.movePosition(QTextCursor::PreviousBlock, QTextCursor::KeepAnchor);\r\n        cursor.removeSelectedText();\r\n    }\r\n    else\r\n    {\r\n        cursor = preview_->textCursor();\r\n    }\r\n\r\n    int gateCount = 0;\r\n\r\n    if (gateGenerationType_ == MULTIPLEGATES)\r\n    {        \r\n        foreach(QSharedPointer<BusInterface> busInterface, *component_->getBusInterfaces())\r\n        {\r\n            int pinCount = countInterfacePins(busInterface);\r\n\r\n            insertGate(busInterface->name(), 1, pinCount, 0, cursor);\r\n            insertPins(busInterface, cursor);\r\n            cursor.insertBlock();\r\n        }\r\n        \r\n        gateCount = component_->getBusInterfaces()->size();\r\n    } \r\n\r\n    else //if (gateGenerationType_ == SINGLEGATE)\r\n    {\r\n        int pinCount = 0;\r\n        foreach(QSharedPointer<BusInterface> busInterface, *component_->getBusInterfaces())\r\n        {\r\n            pinCount += countInterfacePins(busInterface);\r\n        }\r\n\r\n        QString gateName = gateNameEditor_->text();\r\n        if (gateName.isEmpty())\r\n        {\r\n            gateName = DEFAULT_GATENAME;\r\n        }\r\n        insertGate(gateName, 1, pinCount, 0, cursor);\r\n\r\n        foreach(QSharedPointer<BusInterface> busInterface, *component_->getBusInterfaces())\r\n        {\r\n            insertPins(busInterface, cursor);\r\n        }        \r\n           \r\n        gateCount = 1;        \r\n    }\r\n\r\n    // Update 1. header line with correct amount of gates.\r\n    cursor = preview_->document()->find(PadsAsciiSyntax::PART_HEADER_1ST_EXP);\r\n    if (!cursor.isNull())\r\n    {\r\n        QStringList headerLine1 = cursor.block().text().split(PadsAsciiSyntax::SEPARATOR, \r\n            Qt::SkipEmptyParts);    \r\n        headerLine1.replace(PadsAsciiSyntax::NUM_GATES, QString::number(gateCount));\r\n        cursor.movePosition(QTextCursor::NextBlock, QTextCursor::KeepAnchor);\r\n\r\n        insertLine(headerLine1.join(PadsAsciiSyntax::SEPARATOR), \r\n            cursor, PadsAsciiSyntax::PART_HEADER_1ST_EXP);                \r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PadsPartGeneratorDialog::countInterfacePins()\r\n//-----------------------------------------------------------------------------\r\nint PadsPartGeneratorDialog::countInterfacePins(QSharedPointer<BusInterface> busInterface)\r\n{\r\n    int pinCount = 0;\r\n\r\n    QString activeView = viewSelector_->currentText();\r\n    QSharedPointer<AbstractionType> abstraction = busInterface->getAbstractionContainingView(activeView);\r\n    if (abstraction)\r\n    {\r\n        foreach (QSharedPointer<PortMap> portMap, *abstraction->getPortMaps())\r\n        {\r\n            pinCount += countPortMapPins(portMap);\r\n        }  \r\n    }\r\n\r\n    return pinCount;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PadsPartGeneratorDialog::countPortMapPins()\r\n//-----------------------------------------------------------------------------\r\nint PadsPartGeneratorDialog::countPortMapPins(QSharedPointer<PortMap> portMap)\r\n{\r\n    int pinCount = 0;\r\n\r\n    if (portMap->getPhysicalPort())\r\n    {\r\n        QString left = QString();\r\n        QString right = QString();\r\n\r\n        if (portMap->getPhysicalPort()->partSelect_)\r\n        {\r\n            left = portMap->getPhysicalPort()->partSelect_->getLeftRange();\r\n            right = portMap->getPhysicalPort()->partSelect_->getRightRange();\r\n        }\r\n        else if (component_->hasPort(portMap->getPhysicalPort()->name_))\r\n        {\r\n            QSharedPointer<Port> physicalPort = component_->getPort(portMap->getPhysicalPort()->name_);\r\n            left = physicalPort->getLeftBound();\r\n            right = physicalPort->getRightBound();\r\n        }\r\n\r\n        if (!left.isEmpty() && !right.isEmpty())\r\n        {\r\n            pinCount += abs(expressionParser_->parseExpression(left).toInt() - \r\n                expressionParser_->parseExpression(right).toInt()) + 1;\r\n        }\r\n    }    \r\n\r\n    return pinCount;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PadsPartGeneratorDialog::insertGate()\r\n//-----------------------------------------------------------------------------\r\nvoid PadsPartGeneratorDialog::insertGate(QString const& name, int decals, int pins, int gateswap, QTextCursor& cursor)\r\n{\r\n    QStringList gateLine = PadsAsciiSyntax::PART_GATE_DECLARATION.split(PadsAsciiSyntax::SEPARATOR);;\r\n    gateLine.replace(PadsAsciiSyntax::NUM_DECALS, QString::number(decals));\r\n    gateLine.replace(PadsAsciiSyntax::NUM_PINS, QString::number(pins));\r\n    gateLine.replace(PadsAsciiSyntax::GATESWAP, QString::number(gateswap));\r\n\r\n    // Add gate declaration.  \r\n    insertLine(gateLine.join(PadsAsciiSyntax::SEPARATOR), cursor, PadsAsciiSyntax::PART_GATE_EXP);    \r\n\r\n    // Add gate name declaration on 2nd line.\r\n    gates_.insert(cursor.blockNumber(), name);    \r\n    insertLine(nameEditor_->text().toUpper() + \"_\" + name.toUpper(), cursor, PadsAsciiSyntax::PART_GATE_NAME_EXP);        \r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PadsPartGeneratorDialog::insertPins()\r\n//-----------------------------------------------------------------------------\r\nvoid PadsPartGeneratorDialog::insertPins(QSharedPointer<BusInterface> busInterface, QTextCursor& cursor)\r\n{\r\n    // Get the abstract definition of the bus interface for resolving the logical signal size.\r\n    QSharedPointer<AbstractionType> abstraction =\r\n        busInterface->getAbstractionContainingView(viewSelector_->currentText());\r\n    if (abstraction && abstraction->getAbstractionRef() && abstraction->getAbstractionRef()->isValid())\r\n    {\r\n        foreach (QSharedPointer<PortMap> portMap, *abstraction->getPortMaps())\r\n        {\r\n            QString pin = portMap->getPhysicalPort()->name_;\r\n            QStringList line = PadsAsciiSyntax::PART_GATE_PIN.split(PadsAsciiSyntax::SEPARATOR);        \r\n\r\n            int logLower = 0;\r\n            int logHigher = countPortMapPins(portMap) - 1;\r\n\r\n            bool showLogicalIndex = logHigher > logLower;   \r\n\r\n            for (int logIndex = logLower; logIndex <= logHigher; logIndex++)\r\n            {                    \r\n                line.replace(PadsAsciiSyntax::PINNUMBER, pin);\r\n                line.replace(PadsAsciiSyntax::PINSWAP, \"0\");\r\n                line.replace(PadsAsciiSyntax::PINTYPE, \"U\");\r\n                if (showLogicalIndex)\r\n                {\r\n                    line.replace(PadsAsciiSyntax::PINNAME, \r\n                        portMap->getLogicalPort()->name_  + \"_\" + QString::number(logIndex));\r\n                } \r\n                else\r\n                {\r\n                    line.replace(PadsAsciiSyntax::PINNAME, portMap->getLogicalPort()->name_);\r\n                }  \r\n\r\n                insertLine(line.join(PadsAsciiSyntax::SEPARATOR), cursor, PadsAsciiSyntax::PART_GATE_PIN_EXP);                                        \r\n            }\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PadsPartGeneratorDialog::insertLine()\r\n//-----------------------------------------------------------------------------\r\nvoid PadsPartGeneratorDialog::insertLine(QString const& line, QTextCursor cursor, QRegularExpression const& validatingExp)\r\n{    \r\n    if (validatingExp.pattern().isEmpty() || validatingExp.match(line).hasMatch())\r\n    {\r\n        cursor.insertText(line, okFormat_);            \r\n    }\r\n    else\r\n    {                \r\n        cursor.insertText(line, errorFormat_);\r\n    } \r\n    cursor.insertBlock();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PadsPartGeneratorDialog::insertAttributes()\r\n//-----------------------------------------------------------------------------\r\nvoid PadsPartGeneratorDialog::insertAttributes(QTextCursor& cursor)\r\n{\r\n    // Insert default attributes.\r\n    QStringList attr = PadsAsciiSyntax::ATTRIBUTE_DECLARATION.split(PadsAsciiSyntax::SEPARATOR, \r\n        Qt::SkipEmptyParts);\r\n    attr.replace(PadsAsciiSyntax::ATTRNAME, tr(\"\\\"Generated by\\\"\"));\r\n    attr.replace(PadsAsciiSyntax::VALUE, \"Kactus2 \" + generatorName_ + tr(\" version \") + \r\n        generatorVersion_);\r\n    insertLine(attr.join(PadsAsciiSyntax::SEPARATOR), cursor, PadsAsciiSyntax::ATTRIBUTE_EXP);\r\n\r\n    attr.replace(PadsAsciiSyntax::ATTRNAME, tr(\"\\\"Author\\\"\"));\r\n    attr.replace(PadsAsciiSyntax::VALUE, component_->getAuthor());\r\n    insertLine(attr.join(PadsAsciiSyntax::SEPARATOR), cursor, PadsAsciiSyntax::ATTRIBUTE_EXP);\r\n\r\n    attr.replace(PadsAsciiSyntax::ATTRNAME, tr(\"\\\"Vendor\\\"\"));\r\n    attr.replace(PadsAsciiSyntax::VALUE, component_->getVlnv().getVendor());\r\n    insertLine(attr.join(PadsAsciiSyntax::SEPARATOR), cursor, PadsAsciiSyntax::ATTRIBUTE_EXP);\r\n\r\n    attr.replace(PadsAsciiSyntax::ATTRNAME, tr(\"\\\"Library\\\"\"));\r\n    attr.replace(PadsAsciiSyntax::VALUE, component_->getVlnv().getLibrary());\r\n    insertLine(attr.join(PadsAsciiSyntax::SEPARATOR), cursor, PadsAsciiSyntax::ATTRIBUTE_EXP);\r\n\r\n    attr.replace(PadsAsciiSyntax::ATTRNAME, tr(\"\\\"Name\\\"\"));\r\n    attr.replace(PadsAsciiSyntax::VALUE, component_->getVlnv().getName());\r\n    insertLine(attr.join(PadsAsciiSyntax::SEPARATOR), cursor, PadsAsciiSyntax::ATTRIBUTE_EXP);\r\n\r\n    attr.replace(PadsAsciiSyntax::ATTRNAME, tr(\"\\\"Version\\\"\"));\r\n    attr.replace(PadsAsciiSyntax::VALUE, component_->getVlnv().getVersion());\r\n    insertLine(attr.join(PadsAsciiSyntax::SEPARATOR), cursor, PadsAsciiSyntax::ATTRIBUTE_EXP);\r\n\r\n    // Insert all parameters as attributes.\r\n    foreach(QSharedPointer<Parameter> parameter, *component_->getParameters())\r\n    {\r\n        attr.replace(PadsAsciiSyntax::ATTRNAME, \"\\\"\" + parameter->name() + \"\\\"\");\r\n        attr.replace(PadsAsciiSyntax::VALUE, expressionParser_->parseExpression(parameter->getValue()));\r\n        insertLine(attr.join(PadsAsciiSyntax::SEPARATOR), cursor, PadsAsciiSyntax::ATTRIBUTE_EXP);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PadsPartGeneratorDialog::setupLayout()\r\n//-----------------------------------------------------------------------------\r\nvoid PadsPartGeneratorDialog::setupLayout()\r\n{\r\n    QGroupBox* kactusGroup = new QGroupBox(tr(\"Generation options\"), this);\r\n    QFormLayout* kactusLayout = new QFormLayout(kactusGroup);\r\n    kactusLayout->addRow(tr(\"Select target fileset\"), fileSetSelector_);\r\n    kactusLayout->addRow(tr(\"Select active view\"), viewSelector_);\r\n\r\n    QGroupBox* headerGenerationGroup = new QGroupBox(tr(\"Header generation options\"), this);\r\n    QFormLayout* headerLayout = new QFormLayout(headerGenerationGroup);\r\n\r\n    headerLayout->addRow(tr(\"Part name\"), nameEditor_);\r\n    headerLayout->addRow(tr(\"Coordinate units\"), unitSelector_);\r\n    headerLayout->addRow(tr(\"Logic family\"), familyEditor_);\r\n\r\n    QGroupBox* gateGenerationGroup = new QGroupBox(tr(\"Gate options\"), this);\r\n    QVBoxLayout* gateGenerationLayout = new QVBoxLayout(gateGenerationGroup);\r\n    gateGenerationLayout->addWidget(multiGateButton_);\r\n    gateGenerationLayout->addWidget(singleGateButton_);\r\n    QFormLayout* gateNameLayout = new QFormLayout();\r\n    gateNameLayout->addRow(tr(\"Gate name\"), gateNameEditor_);\r\n    gateGenerationLayout->addLayout(gateNameLayout);\r\n\r\n    QGroupBox* previewGroup = new QGroupBox(tr(\"Preview\"), this);\r\n    QVBoxLayout* previewLayout = new QVBoxLayout(previewGroup);\r\n    previewLayout->addWidget(preview_);\r\n\r\n    QHBoxLayout* buttonLayout = new QHBoxLayout();\r\n    QPushButton* runButton = new QPushButton(tr(\"Run\"));\r\n    QPushButton* cancelButton = new QPushButton(tr(\"Cancel\"));\r\n    buttonLayout->addStretch();\r\n    buttonLayout->addWidget(runButton, 0, Qt::AlignRight);\r\n    buttonLayout->addWidget(cancelButton, 0, Qt::AlignRight);\r\n\r\n    QGridLayout* topLayout = new QGridLayout(this);\r\n    topLayout->addWidget(kactusGroup, 0, 0, 1, 1);\r\n    topLayout->addWidget(headerGenerationGroup, 1, 0, 1, 1);\r\n    topLayout->addWidget(gateGenerationGroup, 2, 0, 1, 1);\r\n    topLayout->addWidget(previewGroup, 0, 1, 3, 1);\r\n    topLayout->addLayout(buttonLayout, 3, 0, 1, 2);\r\n    topLayout->setRowStretch(2, 1);\r\n\r\n    connect(runButton, SIGNAL(clicked(bool)), this, SLOT(onRunClicked()), Qt::UniqueConnection);    \r\n    connect(cancelButton, SIGNAL(clicked(bool)), this, SLOT(reject()), Qt::UniqueConnection);\r\n    connect(viewSelector_, SIGNAL(currentIndexChanged(int)), this, SLOT(refreshPreview()), Qt::UniqueConnection);\r\n\r\n    setMinimumWidth(MINIMUM_WIDTH);\r\n}\r\n"
  },
  {
    "path": "Plugins/PadsPartGenerator/PadsPartGeneratorDialog.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: PadsPartGeneratorDialog.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Esko Pekkarinen\r\n// Date: 5.11.2013\r\n//\r\n// Description:\r\n// Dialog for PADS part generation settings.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef PADSPARTGENERATORDIALOG_H\r\n#define PADSPARTGENERATORDIALOG_H\r\n\r\n#include <QComboBox>\r\n#include <QDialog>\r\n#include <QLabel>\r\n#include <QLineEdit>\r\n#include <QMap>\r\n#include <QPlainTextEdit>\r\n#include <QPushButton>\r\n#include <QRadioButton>\r\n\r\nclass BusInterface;\r\nclass Component;\r\nclass ExpressionParser;\r\nclass LibraryInterface;\r\nclass PadsPartGenerator;\r\nclass PortMap;\r\n\r\n//-----------------------------------------------------------------------------\r\n// class PadsPartGeneratorDialog.\r\n//-----------------------------------------------------------------------------\r\nclass PadsPartGeneratorDialog : public QDialog\r\n{\t\r\n    Q_OBJECT\r\n\r\npublic:\r\n\r\n    //! Selection type for gate generation.\r\n    enum gateGenerationType\r\n    {\r\n        MULTIPLEGATES = 0,  //!< Generate one gate per interface.\r\n        SINGLEGATE          //!< Generate exactly one gate.\r\n    };\r\n\r\n\t/*!\r\n\t *  The constructor.\r\n\t *\r\n\t *    @param [in] libIf               The library interface.\r\n\t *    @param [in] component           The component for which generation is done.\r\n     *    @param [in] expressionParser    The parser for expressions.\r\n\t *    @param [in] generatorName       The utilizing generator name.\r\n     *    @param [in] generatorVersion    The utilizing generator version.\r\n\t *    @param [in] parent              The parent widget.\r\n\t *\r\n\t *    @return \r\n\t */\r\n\tPadsPartGeneratorDialog(LibraryInterface* libIf, QSharedPointer<const Component> component, \r\n        QSharedPointer<ExpressionParser> expressionParser,\r\n        QString const& generatorName, QString const& generatorVersion, QWidget* parent);\r\n\r\n\t/*!\r\n    *  The destructor.\r\n    */\r\n    ~PadsPartGeneratorDialog();\r\n\r\n    /*!\r\n     *  Returns the name for the generated part.\r\n     *\r\n     *    @return The name of the part.\r\n     */\r\n    QString getPartName() const;\r\n\r\n    /*!\r\n     *  Returns the name of the target fileset.\r\n     *\r\n     *    @return Name of the selected fileset.\r\n     */\r\n    QString getFileSetName() const;\r\n\r\n    /*!\r\n     *  Returns the text in the preview.     \r\n     *\r\n     *    @return the preview text.\r\n     */\r\n    QString getPreviewText();\r\n\r\n    /*!\r\n     *  Returns the selected gate generation type (single/multiple).\r\n     *     \r\n     *    @return The selected type.\r\n     */\r\n    gateGenerationType getGategenerationType() const;\r\n\r\npublic slots:\r\n\r\n    /*!\r\n     *  Generates the two-line header for PADS part file.\r\n     */\r\n    virtual void generateHeader();\r\n\r\n    /*!\r\n     *  Generates the gates in PADS part file.\r\n     */\r\n    virtual void generateGates();\r\n\r\n    /*!\r\n     *  Count the number of physical pins in a bus interface.\r\n     *\r\n     *    @param [in] busInterface   The bus interface whose physical pins to count.\r\n     *\r\n     *    @return The number of physical pins in the interface.\r\n     */\r\n    int countInterfacePins(QSharedPointer<BusInterface> busInterface);\r\n\r\n    /*!\r\n     *  Count the number of physical pins in a port map.\r\n     *\r\n     *    @param [in] portMap     The port map whose physical pins to count.\r\n     *\r\n     *    @return The number of physical pins in the port map.\r\n     */\r\n    int countPortMapPins(QSharedPointer<PortMap> portMap);\r\n\r\n    /*!\r\n     *  Handler for events when user clicks run.\r\n     */\r\n    virtual void onRunClicked();\r\n\r\n    /*!\r\n     *  Handler for events when user edits the part name.\r\n     */\r\n    virtual void onNameChanged();\r\n\r\n    /*!\r\n     *  Handler for events when user changes the measurement unit.\r\n     */\r\n    virtual void onUnitChanged();\r\n\r\n    /*!\r\n     *  Handler for events when user changes the logical family.\r\n     */\r\n    virtual void onFamilyChanged();\r\n\r\n    /*!\r\n     *  Handler for events when user selects single/multiple gates.\r\n     */\r\n    virtual void onGateSelectionChanged();\r\n\r\n    /*!\r\n     *  Handler for events when user edits the gate name.\r\n     */\r\n    virtual void onGateNameChanged();\r\n\r\nprivate slots:\r\n\r\n    /*!\r\n     *  Re-generates the part preview.\r\n     */\r\n    virtual void refreshPreview();\r\n\r\nprivate:\r\n\t// Disable copying.\r\n\tPadsPartGeneratorDialog(PadsPartGeneratorDialog const& rhs);\r\n\r\n\t// Disable assignment.\r\n\tPadsPartGeneratorDialog& operator=(PadsPartGeneratorDialog const& rhs);\r\n\r\n    /*!\r\n     *  Adds pin declarations for interface ports.\r\n     *\r\n     *    @param [in] busInterface    The interface whose ports to add.\r\n     *    @param [in] cursor          Cursor to the correct position in preview.\r\n     */\r\n    void insertPins(QSharedPointer<BusInterface> busInterface, QTextCursor &cursor); \r\n\r\n    /*!\r\n     *  Adds a gate declaration.\r\n     *\r\n     *    @param [in] name        The name of the gate.\r\n     *    @param [in] decals      Number of decals for the gate.\r\n     *    @param [in] pins        Number of pins in the gate.\r\n     *    @param [in] gateswap    Gate swap type.\r\n     *    @param [in] cursor      Cursor to the correct position in preview.\r\n     */\r\n    void insertGate(QString const& name, int decals, int pins, int gateswap, QTextCursor &cursor); \r\n\r\n    /*!\r\n     *  Inserts a line of text to the preview.\r\n     *\r\n     *    @param [in] line            The line to insert.\r\n     *    @param [in] cursor          Cursor to the correct position in preview.\r\n     *    @param [in] validatingExp   RegExp for checking the line correctness.\r\n     */\r\n    void insertLine(QString const& line,  QTextCursor cursor, QRegularExpression const& validatingExp = QRegularExpression() );\r\n\r\n    /*!\r\n     *  Inserts part attributes to the preview.\r\n     *\r\n     *    @param [in] cursor   Cursor to the correct position in preview.\r\n     */\r\n    void insertAttributes( QTextCursor& cursor );\r\n    \r\n    /*!\r\n     *  Sets the dialog layout.\r\n     */\r\n    void setupLayout();\r\n\r\n\t//-----------------------------------------------------------------------------\r\n\t// Data.\r\n\t//-----------------------------------------------------------------------------\r\n\r\n    //! The library interface.\r\n    LibraryInterface* libHandler_;\r\n\r\n    //! The component for which the generator is run.\r\n    QSharedPointer<const Component> component_;\r\n\r\n    //! The parser for expressions.\r\n    QSharedPointer<ExpressionParser> expressionParser_;\r\n\r\n    //! The generator name.\r\n    QString generatorName_;\r\n\r\n    //! The generator version.\r\n    QString generatorVersion_;\r\n\r\n    //! Selector for fileset.\r\n    QComboBox* fileSetSelector_;\r\n\r\n    //! Selector for views.\r\n    QComboBox* viewSelector_;\r\n\r\n    //! Editor for part name.\r\n    QLineEdit* nameEditor_;\r\n\r\n    //! Selector for pcb decal.\r\n    QComboBox* decalSelector_;\r\n\r\n    //! Selector for measurement unit.\r\n    QComboBox* unitSelector_;\r\n\r\n    //! Editor for logical family of the part.\r\n    QLineEdit* familyEditor_;\r\n\r\n    //! Button for selecting multiple gate generation.\r\n    QRadioButton* multiGateButton_; \r\n\r\n    //! Button for selecting single gate generation.\r\n    QRadioButton* singleGateButton_;\r\n\r\n    //! Editor for gate name when single gate generation is selected.\r\n    QLineEdit* gateNameEditor_;\r\n\r\n    //! Editor for displaying preview of the generated part.\r\n    QPlainTextEdit* preview_;\r\n\r\n    //! Selected gate generation type.\r\n    gateGenerationType gateGenerationType_;    \r\n\r\n    //! Map of gate names and their line numbers in preview.\r\n    QMap<int, QString> gates_;\r\n\r\n    //! Formatting for valid lines.\r\n    QTextCharFormat okFormat_;\r\n\r\n    //! Formatting for invalid lines.\r\n    QTextCharFormat errorFormat_;\r\n};\r\n#endif // PADSPARTGENERATORDIALOG_H\r\n\r\n"
  },
  {
    "path": "Plugins/PadsPartGenerator/padspartgenerator.json",
    "content": "{\r\n\t\"Keys\": [ \"Pads part generator\" ]\r\n}"
  },
  {
    "path": "Plugins/PluginSystem/GeneratorPlugin/AddToFilesetWidget.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: AddToFilesetWidget.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Anton Hagqvist\n// Date: 27.11.2025\n//\n// Description:\n// Widget for selecting file set to add generated item into.\n//-----------------------------------------------------------------------------\n\n#include \"AddToFilesetWidget.h\"\n\n#include <common/KactusColors.h>\n\n#include <QFormLayout>\n\n//-----------------------------------------------------------------------------\n// Function: AddToFilesetWidget::AddToFilesetWidget()\n//-----------------------------------------------------------------------------\nAddToFilesetWidget::AddToFilesetWidget(QWidget* parent) : QGroupBox(tr(\"Add file to fileset\"), parent)\n{\n    setCheckable(true);\n    setChecked(false);\n\n    // Is editable, in case a new entry is desired.\n    fileSetSelection_.setEditable(true);\n\n    QFormLayout* filesetLayout = new QFormLayout();\n    setLayout(filesetLayout);\n    filesetLayout->addRow(tr(\"Select or create new file set:\"), &fileSetSelection_);\n    filesetLayout->addWidget(&fileSetWarningLabel_);\n\n    connect(&fileSetSelection_, SIGNAL(currentTextChanged(QString const&)),\n        this, SLOT(onFileSetChanged(QString const&)), Qt::UniqueConnection);\n    connect(&fileSetSelection_, SIGNAL(currentTextChanged(QString const&)),\n        this, SLOT(onFileSetChanged(QString const&)), Qt::UniqueConnection);\n}\n\n//-----------------------------------------------------------------------------\n// Function: AddToFilesetWidget::clear()\n//-----------------------------------------------------------------------------\nvoid AddToFilesetWidget::clear()\n{\n    setChecked(false);\n    fileSetSelection_.clear();\n}\n\n//-----------------------------------------------------------------------------\n// Function: AddToFilesetWidget::setExistingFileSets()\n//-----------------------------------------------------------------------------\nvoid AddToFilesetWidget::setExistingFileSets(QStringList const& fileSetNames)\n{\n    fileSetNames_ = fileSetNames;\n    fileSetSelection_.clear();\n    fileSetSelection_.addItems(fileSetNames);\n}\n\n//-----------------------------------------------------------------------------\n// Function: AddToFilesetWidget::selectDefaultFileSet()\n//-----------------------------------------------------------------------------\nvoid AddToFilesetWidget::selectDefaultFileSet(QString const& defaultName)\n{\n    int defaultFileSetIndex = fileSetSelection_.findText(defaultName);\n\n    if (defaultFileSetIndex == -1)\n    {\n        // If none, just pick the topmost.\n        fileSetSelection_.setCurrentIndex(0);\n    }\n    else\n    {\n        // Else set the selection accordingly.\n        fileSetSelection_.setCurrentIndex(defaultFileSetIndex);\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: AddToFilesetWidget::setChecked()\n//-----------------------------------------------------------------------------\nvoid AddToFilesetWidget::setChecked(bool checked)\n{\n    QGroupBox::setChecked(checked);\n}\n\n//-----------------------------------------------------------------------------\n// Function: AddToFilesetWidget::currentSelection()\n//-----------------------------------------------------------------------------\nQString AddToFilesetWidget::currentSelection() const\n{\n    return fileSetSelection_.currentText();\n}\n\n//-----------------------------------------------------------------------------\n// Function: AddToFilesetWidget::onFileSetChanged()\n//-----------------------------------------------------------------------------\nvoid AddToFilesetWidget::onFileSetChanged(QString const& fileSetName)\n{\n    if (!fileSetNames_.contains(fileSetName) && fileSetName.isEmpty() == false)\n    {\n        // Warn user that a new file set will be created.\n        fileSetWarningLabel_.setText(tr(\"New file set '%1' will be created.\").arg(fileSetName));\n    }\n    else\n    {\n        fileSetWarningLabel_.setText(\"\");\n    }\n\n    emit fileSetChanged(fileSetName);\n}\n"
  },
  {
    "path": "Plugins/PluginSystem/GeneratorPlugin/AddToFilesetWidget.h",
    "content": "//-----------------------------------------------------------------------------\n// File: AddToFilesetWidget.h\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Anton Hagqvist\n// Date: 27.11.2025\n//\n// Description:\n// Widget for selecting file set to add generated item into.\n//-----------------------------------------------------------------------------\n\n#ifndef ADDTOFILESETWIDGET_H\n#define ADDTOFILESETWIDGET_H\n\n#include <QGroupBox>\n#include <QComboBox>\n#include <QLabel>\n\nclass AddToFilesetWidget : public QGroupBox\n{\n    Q_OBJECT\npublic:\n\n    /*!\n     *\tThe constructor.\n     *  \n     *    @param [in] parent     The parent widget of this widget.\n     */\n    AddToFilesetWidget(QWidget* parent = nullptr);\n\n    //! Disable copying\n    AddToFilesetWidget(AddToFilesetWidget const& other) = delete;\n    AddToFilesetWidget& operator=(AddToFilesetWidget const& other) = delete;\n\t\n    virtual ~AddToFilesetWidget() = default;\n\n    /*!\n     *\tClear any file set selection and uncheck.\n     */\n    void clear();\n\n    /*!\n     *\tSet the available file sets.\n     *  \n     *    @param [in] fileSetNames     Available file set names.\n     */\n    void setExistingFileSets(QStringList const& fileSetNames);\n\n    /*!\n     *\tSelect default file set (e.g. based on view), if it exists. Otherwise select first item.\n     *  \n     *    @param [in] defaultName     The default file set to select.\n     */\n    void selectDefaultFileSet(QString const& defaultName);\n    \n    /*!\n     *\tSet checked state of groupbox.\n     *  \n     *    @param [in] checked     Flag if group box should be checked (enabled) or not.\n     */\n    void setChecked(bool checked);\n\n    /*!\n     *\tGet the currently selected file set.\n     *  \n     *    @return  The currently selected file set name.\n     */\n    QString currentSelection() const;\n\nsignals:\n\n    /*!\n     *\tInform parent that file set has been changed.\n     */\n    void fileSetChanged(QString const& fileSetName);\n\nprivate slots:\n\n    /*!\n     *\tHandle file set change.\n     *  \n     *    @param [in] fileSetName     \n     */\n    void onFileSetChanged(QString const& fileSetName);\n\nprivate:\n\n    //! The combobox to select the fileset.\n    QComboBox fileSetSelection_;\n\n    //! The label to give warnings about file set selection.\n    QLabel fileSetWarningLabel_;\n\n    //! Existing component file sets.\n    QStringList fileSetNames_;\n};\n\n#endif // ADDTOFILESETWIDGET_H\n\n"
  },
  {
    "path": "Plugins/PluginSystem/GeneratorPlugin/FileOutputWidget.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: FileOutputWidget.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Janne Virtanen\r\n// Date: 15.11.2016\r\n//\r\n// Description:\r\n// Widget for listing generated files and some details about them.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"FileOutputWidget.h\"\r\n\r\n#include <common/KactusColors.h>\r\n\r\n#include <QFileDialog>\r\n#include <QVBoxLayout>\r\n#include <QHeaderView>\r\n#include <QApplication>\r\n#include <QPushButton>\r\n\r\nnamespace\r\n{\r\n    const QString WARNING_FILE_EXISTS(\"<b>One or more of the output files already exists and will \"\r\n        \"be overwritten.</b>\");\r\n\r\n    enum Columns\r\n    {\r\n        COLUMN_VLNV = 0,\r\n        COLUMN_EXISTS,\r\n        COLUMN_FILENAME\r\n    };\r\n}\r\n\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileOutputWidget::FileOutputWidget()\r\n//-----------------------------------------------------------------------------\r\nFileOutputWidget::FileOutputWidget(QSharedPointer<OutputControl> configuration) : \r\nmodel_(configuration),\r\npathEditor_(new QLineEdit(this)),\r\ngeneralWarningLabel_(new QLabel),\r\nfileTable_(new QTableWidget)\r\n{\r\n    // Layout for path selection widgets.\r\n    QHBoxLayout* pathSelectionLayout = new QHBoxLayout();\r\n    pathSelectionLayout->addWidget(new QLabel(tr(\"Output directory:\")));\r\n    pathSelectionLayout->addWidget(pathEditor_);\r\n\r\n    QPalette p = pathEditor_->palette();\r\n    p.setColor(QPalette::Base, KactusColors::MANDATORY_FIELD);\r\n    pathEditor_->setPalette(p);\r\n\r\n    // Get the default output path from the generation configuration.\r\n    pathEditor_->setText(model_->getOutputPath());\r\n\r\n    // Add button for choosing the path via dialog.\r\n    QPushButton* browseButton = new QPushButton(tr(\"Browse\"), this);\r\n    pathSelectionLayout->addWidget(browseButton);\r\n\r\n    // Stuff that comes on top of the file table.\r\n    QHBoxLayout* headerLayout = new QHBoxLayout();\r\n    QLabel* tableHeader = new QLabel(\"Output files:\");\r\n    headerLayout->addWidget(tableHeader);\r\n\r\n    // Layout for thing coming to the bottom part of the dialog.\r\n    QHBoxLayout* bottomLayout = new QHBoxLayout();\r\n\r\n    bottomLayout->addWidget(generalWarningLabel_);\r\n\r\n    // The headers for each of the column.\r\n    QStringList headers;\r\n    headers.append(tr(\"Top component VLNV\"));\r\n    headers.append(tr(\"Exists\"));\r\n    headers.append(tr(\"File name\"));\r\n    // Set the number of columns correspond the number of headers.\r\n    fileTable_->setColumnCount(headers.size());\r\n\r\n    // Put the headers in to effect.\r\n    fileTable_->setHorizontalHeaderLabels(headers);\r\n\r\n    // Vertical headers are not used.\r\n    fileTable_->verticalHeader()->hide();\r\n\r\n    // Easier to see the different rows from one another.\r\n    fileTable_->setAlternatingRowColors(true);\r\n\r\n    // The last column is stretched take the available space in the widget.\r\n    fileTable_->horizontalHeader()->setStretchLastSection(true);\r\n\r\n    // Refit the columns.\r\n    fileTable_->resizeColumnsToContents();\r\n\r\n    // Add everything it their proper position in the final layout.\r\n    QVBoxLayout* topLayout = new QVBoxLayout(this);\r\n    topLayout->addLayout(pathSelectionLayout);\r\n    topLayout->addLayout(headerLayout);\r\n    topLayout->addWidget(fileTable_);\r\n    topLayout->addLayout(bottomLayout);\r\n\r\n    // Use red to make it more warny.\r\n    generalWarningLabel_->setStyleSheet(\"QLabel { color : \" + KactusColors::WARNING.name() + \"; }\");\r\n\r\n    connect(pathEditor_, SIGNAL(editingFinished()), this,\r\n        SLOT(onPathEdited()), Qt::UniqueConnection);\r\n    connect(browseButton, SIGNAL(clicked(bool)), this, SLOT(onBrowse()), Qt::UniqueConnection);\r\n    connect(fileTable_, SIGNAL(itemChanged(QTableWidgetItem*)),\r\n        this, SLOT(onItemChanged(QTableWidgetItem*)), Qt::UniqueConnection);\r\n    connect(fileTable_, SIGNAL(itemSelectionChanged()),\r\n        this, SLOT(onItemSelectionChanged()), Qt::UniqueConnection);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileOutputWidget::canAccept()\r\n//-----------------------------------------------------------------------------\r\nbool FileOutputWidget::canAccept() const\r\n{\r\n    return pathEditor_->hasFocus() == false;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileOutputWidget::onOutputFilesChanged()\r\n//-----------------------------------------------------------------------------\r\nvoid FileOutputWidget::onOutputFilesChanged()\r\n{\r\n    // Remove the old stuff, set number of rows as number of files.\r\n    fileTable_->clearContents();\r\n    fileTable_->setRowCount(model_->getOutputs()->size());\r\n\r\n    // Populate the table.\r\n    int row = 0;\r\n\r\n    foreach(QSharedPointer<GenerationOutput> output, *model_->getOutputs())\r\n    {\r\n        // Insert VLNV string to the row.\r\n        QString vlnv = output->vlnv_;\r\n        QTableWidgetItem* vlnvItem = new QTableWidgetItem(vlnv);\r\n        vlnvItem->setToolTip(vlnv);\r\n        fileTable_->setItem(row, COLUMN_VLNV, vlnvItem);\r\n\r\n        // Create existence check box and insert to the row.\r\n        QTableWidgetItem* fileExistsItem = new QTableWidgetItem(Qt::Checked);\r\n        fileTable_->setItem(row, COLUMN_EXISTS, fileExistsItem);\r\n\r\n        // Insert filename to the row.\r\n        QTableWidgetItem* fileNameItem = new QTableWidgetItem(output->fileName_);\r\n        fileNameItem->setToolTip(output->fileName_);\r\n        fileTable_->setItem(row, COLUMN_FILENAME, fileNameItem);\r\n\r\n        // Disable editing.\r\n        vlnvItem->setFlags(Qt::ItemIsSelectable);\r\n        fileExistsItem->setFlags(Qt::ItemIsSelectable);\r\n\r\n        // The next one goes to the next row.\r\n        ++row;\r\n    }\r\n\r\n    // File paths are potentially changed -> update existince status.\r\n    checkExistence();\r\n\r\n    if (fileTable_->rowCount() > 0 && fileTable_->columnCount() >= COLUMN_FILENAME)\r\n    {\r\n        fileTable_->setCurrentCell(0, COLUMN_FILENAME);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileOutputWidget::onPathEdited()\r\n//-----------------------------------------------------------------------------\r\nvoid FileOutputWidget::onPathEdited()\r\n{\r\n    // Tell the path to the configuration.\r\n    model_->setOutputPath(pathEditor_->text());\r\n\r\n    // Path of of all files changed -> update existence status.\r\n    checkExistence();\r\n\r\n    emit outputPathChanged();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileOutputWidget::onBrowse()\r\n//-----------------------------------------------------------------------------\r\nvoid FileOutputWidget::onBrowse()\r\n{\r\n    // Acquire the path to the file through a dialog.\r\n    QString selectedPath = QFileDialog::getExistingDirectory(this,\r\n        tr(\"Select output path for generation\"), pathEditor_->text(), QFileDialog::ShowDirsOnly);\r\n\r\n    // If any path chosen, set it as the selected path.\r\n    if (!selectedPath.isEmpty())\r\n    {\r\n        pathEditor_->setText(selectedPath);\r\n\r\n        // Tell the path to the configuration.\r\n        model_->setOutputPath(pathEditor_->text());\r\n\r\n        // Path of of all files changed -> update existence status.\r\n        checkExistence();\r\n\r\n        emit outputPathChanged();\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileOutputWidget::onItemChanged()\r\n//-----------------------------------------------------------------------------\r\nvoid FileOutputWidget::onItemChanged(QTableWidgetItem *item)\r\n{\r\n    // Must be in the filename column.\r\n    if (item->column() != COLUMN_FILENAME)\r\n    {\r\n        return;\r\n    }\r\n\r\n    // Inform the change to the model.\r\n    QString newName = item->text();\r\n    if (newName.isEmpty())\r\n    {\r\n        item->setText(model_->getOutputs()->at(item->row())->fileName_);\r\n        return;\r\n    }\r\n\r\n    QSharedPointer<GenerationOutput> affectedFile = model_->changeFileName(item->row(), newName);\r\n\r\n    if (affectedFile)\r\n    {\r\n        //! This is a change done for verilog generator.\r\n\r\n\t\temit fileNameChanged(item->row());\r\n\t\temit selectedFileChanged(model_->getOutputs()->at(item->row()));\r\n\r\n        // A name of a file changed -> emit signal and update existence status.\r\n        checkExistence();\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileOutputWidget::onItemSelectionChanged()\r\n//-----------------------------------------------------------------------------\r\nvoid FileOutputWidget::onItemSelectionChanged()\r\n{\r\n    if (fileTable_->selectedItems().size() < 1)\r\n    {\r\n        return;\r\n    }\r\n\r\n    QTableWidgetItem* item = fileTable_->selectedItems().last();\r\n\r\n    if (item->row() < model_->getOutputs()->size())\r\n    {\r\n        QSharedPointer<GenerationOutput> selection = model_->getOutputs()->at(item->row());\r\n        emit selectedFileChanged(selection);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileOutputWidget::checkExistence()\r\n//-----------------------------------------------------------------------------\r\nvoid FileOutputWidget::checkExistence()\r\n{\r\n    bool existingFiles = false;\r\n\r\n    for(int row = 0; row < fileTable_->rowCount(); ++row)\r\n    {\r\n        QTableWidgetItem* pathItem = fileTable_->item(row, COLUMN_FILENAME);\r\n        QTableWidgetItem* fileExistsItem = fileTable_->item(row, COLUMN_EXISTS);\r\n\r\n        // Both must exist\r\n        if (!fileExistsItem || !pathItem)\r\n        {\r\n            continue;\r\n        }\r\n\r\n\t\tauto selection = model_->getOutputs()->at(row);\r\n\r\n        // Select correct check state: Does it exist or not.\r\n\t\tQFile fileCandidate(model_->getOutputPath() + \"/\" + selection->fileName_);\r\n\r\n        if (fileCandidate.exists())\r\n        {\r\n            // Check and set a warning color.\r\n            fileExistsItem->setCheckState(Qt::Checked);\r\n            pathItem->setForeground(KactusColors::WARNING);\r\n            existingFiles = true;\r\n        }\r\n        else\r\n        {\r\n            // Uncheck and set regular color.\r\n            fileExistsItem->setCheckState(Qt::Unchecked);\r\n            pathItem->setForeground(QApplication::palette().brush(QPalette::Text).color());\r\n        }\r\n    }\r\n\r\n    if (existingFiles)\r\n    {\r\n        // Warn user if it already exists\r\n        generalWarningLabel_->setText(WARNING_FILE_EXISTS);\r\n    }\r\n    else\r\n    {\r\n        // Else clear any warning.\r\n        generalWarningLabel_->setText(\"\");\r\n    }\r\n}"
  },
  {
    "path": "Plugins/PluginSystem/GeneratorPlugin/FileOutputWidget.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: FileOutputWidget.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Janne Virtanen\r\n// Date: 15.11.2016\r\n//\r\n// Description:\r\n// Widget for listing generated files and some details about them.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef FILEOUTPUTWIDGET_H\r\n#define FILEOUTPUTWIDGET_H\r\n\r\n#include <QLineEdit>\r\n#include <QLabel>\r\n#include <QTableWidget>\r\n\r\n#include \"OutputControl.h\"\r\n\r\nclass FileOutputWidget : public QWidget\r\n{\r\n    Q_OBJECT\r\npublic:\r\n\r\n    //! The constructor.\r\n\tFileOutputWidget(QSharedPointer<OutputControl> model);\r\n\r\n\t//! The destructor.\r\n    virtual ~FileOutputWidget() = default;\r\n\r\n    /*!\r\n     * Checks if the output setting can be accepted.    \r\n     *\r\n     *    @return  True, if acceptable, otherwise false. \r\n     */\r\n    bool canAccept() const;\r\n\r\nsignals:\r\n\t\r\n    // Emitted when the selected file is changed.\r\n    void selectedFileChanged(QSharedPointer<GenerationOutput> newSelection) const;\r\n\r\n    // Emitted when the output path is changed.\r\n    void outputPathChanged() const;\r\n\r\n    /*!\r\n     *  Informs of filename change.\r\n     *\r\n     *    @param [in] fileIndex   Index of the changed file.\r\n     */\r\n    void fileNameChanged(int const& fileIndex);\r\n\r\npublic slots:\r\n\r\n    // Informs that the output files have changes. Will query new ones from the model and reconstruct the table.\r\n    void onOutputFilesChanged();\r\n\r\nprivate slots:\r\n\r\n    // Informs that the user chosen new output path.\r\n    // Will tell to model and call checkExistence().\r\n    void onPathEdited();\r\n\r\n    // Received when user click the browse button. Opens a dialog and updates the changes to the path editor.\r\n    void onBrowse();\r\n\r\n    // Received when user makes a change to the table.\r\n    void onItemChanged(QTableWidgetItem *item);\r\n\r\n    // Received when user selects an item on the table.\r\n    void onItemSelectionChanged();\r\n\r\nprivate:\r\n\r\n    // Disable copying.\r\n    FileOutputWidget(FileOutputWidget const& rhs);\r\n    FileOutputWidget& operator=(FileOutputWidget const& rhs);\r\n\r\n    // Goes through the fileTable_ and checks if there are files that already exists.\r\n    // Will set appropriate warnings.\r\n    void checkExistence();\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n\t// The \"model\" for the widget.\r\n    QSharedPointer<OutputControl> model_;\r\n\r\n    //! Editor for the path of the generated file.\r\n    QLineEdit* pathEditor_;\r\n\r\n    //! Warning is display here, namely for an existing file being overwritten.\r\n    QLabel* generalWarningLabel_;\r\n\r\n    //! Table used to display all needed files.\r\n    QTableWidget* fileTable_;\r\n};\r\n\r\n#endif //FILEOUTPUTWIDGET_H"
  },
  {
    "path": "Plugins/PluginSystem/GeneratorPlugin/GenerationControl.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: GenerationControl.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Janne Virtanen\r\n// Date: 26.01.2017\r\n//\r\n// Description:\r\n// Class to control the over structure of generation.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"GenerationControl.h\"\r\n\r\n#include <KactusAPI/include/MessageMediator.h>\r\n\r\n#include <KactusAPI/include/LibraryInterface.h>\r\n\r\n#include <IPXACTmodels/Component/FileSet.h>\r\n#include <IPXACTmodels/Component/FileSetRef.h>\r\n#include <IPXACTmodels/Design/Design.h>\r\n#include <IPXACTmodels/DesignConfiguration/DesignConfiguration.h>\r\n\r\n#include <QFileInfo>\r\n#include <QRegularExpression>\r\n#include <QDateTime>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: GenerationControl::GenerationControl()\r\n//-----------------------------------------------------------------------------\r\nGenerationControl::GenerationControl(LibraryInterface* library,\r\n    IWriterFactory* factory, GenerationTuple input, GenerationSettings* settings) :\r\n\tlibrary_(library), factory_(factory), input_(input), settings_(settings), isDesignGeneration_(input.design != 0),\r\n    outputControl_(new OutputControl)\r\n{\r\n    // Find views usable for the generation.\r\n    QSharedPointer<QList<QSharedPointer<View> > > possibleViews;\r\n\r\n    if (isDesignGeneration_)\r\n    {\r\n        possibleViews = findPossibleViews(input);\r\n    }\r\n    else\r\n    {\r\n        possibleViews = findPossibleViews(input.component);\r\n    }\r\n\r\n    // The usable instantiations and file sets are, in principle, the ones of the component.\r\n    QSharedPointer<QList<QSharedPointer<ComponentInstantiation> > > possibleInstantiations =\r\n        input.component->getComponentInstantiations();\r\n    QSharedPointer<QList<QSharedPointer<FileSet> > > possibleFileSets = input.component->getFileSets();\r\n\r\n    // Initialize model for view selection.\r\n    viewSelection_ = QSharedPointer<ViewSelection>(\r\n        new ViewSelection(factory->getLanguage(), factory_->getSaveToFileset(), factory_->getGroupIdentifier(), settings_,\r\n        possibleViews, possibleInstantiations, possibleFileSets));\r\n\r\n    // Set the defaults for convenience.\r\n    outputControl_->setOutputPath(defaultOutputPath());\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: GenerationControl::writeDocuments()\r\n//-----------------------------------------------------------------------------\r\nbool GenerationControl::writeDocuments()\r\n{\r\n    // Remember the values chosen by the user.\r\n    settings_->lastFileSetName_ = getViewSelection()->getFileSetName();\r\n\r\n    if (getViewSelection()->getView())\r\n    {\r\n        settings_->lastViewName_ = getViewSelection()->getView()->name();\r\n    }\r\n\r\n    QSharedPointer<ComponentInstantiation> instantiation = viewSelection_->getInstantiation();\r\n    QSharedPointer<FileSet> fileSet;\r\n\r\n    if (viewSelection_->getSaveToFileset())\r\n    {\r\n        fileSet = viewSelection_->getFileSet();\r\n\r\n        // If the file set does not exist, create a new one with the same name.\r\n        if (!fileSet)\r\n        {\r\n            fileSet = QSharedPointer<FileSet>(new FileSet(viewSelection_->getFileSetName(), factory_->getGroupIdentifier()));\r\n            input_.component->getFileSets()->append(fileSet);\r\n        }\r\n        else if (!factory_->getGroupIdentifier().isEmpty() &&\r\n            !fileSet->getGroups()->contains(factory_->getGroupIdentifier()))\r\n        {\r\n            fileSet->getGroups()->append(factory_->getGroupIdentifier());\r\n        }\r\n\r\n        // If instantiation exists, make sure that the instantiation refers to the file set.\r\n        if (instantiation && instantiation->getFileSetReferenceStrings().contains(fileSet->name()))\r\n        {\r\n            QSharedPointer<FileSetRef> newFileSetRef(new FileSetRef());\r\n            newFileSetRef->setReference(fileSet->name());\r\n            instantiation->getFileSetReferences()->append(newFileSetRef);\r\n        }\r\n    }\r\n\r\n    QString componentPath = library_->getPath(input_.component->getVlnv());\r\n\r\n    bool fails = false;\r\n\r\n    // Go through each potential file.\r\n    for (QSharedPointer<GenerationOutput> output : *outputControl_->getOutputs())\r\n    {\r\n        // Form the path from the determined output path plus determined file name.\r\n        QString absFilePath = outputControl_->getOutputPath() + \"/\" + output->fileName_;\r\n\r\n        // Try to open the file.\r\n        QFile outputFile(absFilePath); \r\n        if (!outputFile.open(QIODevice::WriteOnly))\r\n        {\r\n            input_.messages->showError(QObject::tr(\"Could not open output file for writing: %1\").arg(absFilePath));\r\n            fails = true;\r\n            continue;\r\n        }\r\n\r\n        // Put the content to the file and close it.\r\n        QTextStream outputStream(&outputFile);\r\n\r\n        outputStream << output->fileContent_;\r\n\r\n        outputFile.close();\r\n\r\n        if (viewSelection_->getSaveToFileset())\r\n        {\r\n            // Need a path for the IP-XACT file: It must be relative to the file path of the document.\r\n            QString ipFilePath = General::getRelativePath(componentPath, absFilePath);\r\n            // Add the new file to the file set.\r\n            QSettings settings;\r\n            QSharedPointer<File> ipFile = fileSet->addFile(ipFilePath, settings);\r\n\r\n            // Insert the proper description to the IP-XACT file.\r\n            insertFileDescription(ipFile);\r\n        }\r\n    }\r\n\r\n    // Return false if something fails.\r\n    return !fails && saveChanges();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: GenerationControl::saveChanges()\r\n//-----------------------------------------------------------------------------\r\nbool GenerationControl::saveChanges()\r\n{\r\n    // The component VLNV in string format.\r\n    QString component = input_.component->getVlnv().toString();\r\n\r\n    // Try to save.\r\n    bool saveSucceeded = library_->writeModelToFile(input_.component);\r\n\r\n    if (saveSucceeded)\r\n    {\r\n        return true;\r\n    }    \r\n\r\n    // Fail: Report the error, including the path.\r\n    QString savePath = library_->getPath(input_.component->getVlnv());\r\n    input_.messages->showError(QObject::tr(\"Could not write component %1 to file %2.\").arg(component, savePath));\r\n    return false;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: GenerationControl::validSelections()\r\n//-----------------------------------------------------------------------------\r\nbool GenerationControl::validSelections(QString &warning)\r\n{\r\n    // Must have a file set as well.\r\n    if (!viewSelection_->validSelections(warning))\r\n    {\r\n        return false;\r\n    }\r\n\r\n    // Must have valid file output.\r\n    if (!outputControl_->validSelections(warning))\r\n    {\r\n        return false;\r\n    }\r\n\r\n    return true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: GenerationControl::parseDocuments()\r\n//-----------------------------------------------------------------------------\r\nvoid GenerationControl::parseDocuments()\r\n{\r\n    QSharedPointer<QList<QSharedPointer<GenerationOutput> > > generatedOutputs = outputControl_->getOutputs();\r\n    if (generatedOutputs->isEmpty())\r\n    {\r\n        initializeDocuments();\r\n    }\r\n    else\r\n    {\r\n        reInitializeDocuments(generatedOutputs);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: GenerationControl::initializeDocuments()\r\n//-----------------------------------------------------------------------------\r\nvoid GenerationControl::initializeDocuments()\r\n{\r\n    // Clear the existing list of files.\r\n    outputControl_->getOutputs()->clear();\r\n    auto locale = QLocale::system();\r\n    if (isDesignGeneration_)\r\n    {\r\n        // Time to write the contents to files\r\n        input_.messages->showMessage(QObject::tr(\"Parsing hierarchy %1 %2.\").arg(locale.toString(QDate::currentDate(),\r\n            locale.dateFormat(QLocale::ShortFormat)), locale.toString(QTime::currentTime(), locale.timeFormat(QLocale::ShortFormat))));\r\n\r\n        // Parse the design hierarchy.\r\n        QList<QSharedPointer<MetaDesign> > designs =\r\n            MetaDesign::parseHierarchy(library_, input_, viewSelection_->getView());\r\n\r\n        // No results -> return.\r\n        if (designs.size() < 1)\r\n        {\r\n            input_.messages->showError(\"No parsed designs in the hierarchy!\");\r\n            return;\r\n        }\r\n\r\n        // Write outputs.\r\n        input_.messages->showMessage(QObject::tr(\"Writing content for preview %1 %2.\").arg(locale.toString(QDate::currentDate(),\r\n            locale.dateFormat(QLocale::ShortFormat)), locale.toString(QTime::currentTime(), locale.timeFormat(QLocale::ShortFormat))));\r\n\r\n        // Pass the topmost design.\r\n        QList<QSharedPointer<GenerationOutput> > documents = factory_->prepareDesign(designs);\r\n\r\n        // Go through the parsed designs.\r\n        for (QSharedPointer<GenerationOutput> output : documents)\r\n        {\r\n            if (!output)\r\n            {\r\n                continue;\r\n            }\r\n\r\n            // Write the contents to a file.\r\n            output->write(outputControl_->getOutputPath());\r\n\r\n            // Append to the list of proposed outputs.\r\n            outputControl_->getOutputs()->append(output);\r\n        }\r\n    }\r\n    else\r\n    {\r\n        // Parse component metadata.\r\n        input_.messages->showMessage(QObject::tr(\"Formatting component %1 %2.\").arg(locale.toString(QDate::currentDate(),\r\n            locale.dateFormat(QLocale::ShortFormat)), locale.toString(QTime::currentTime(), locale.timeFormat(QLocale::ShortFormat))));\r\n\r\n        QSharedPointer<MetaComponent> componentParser\r\n            (new MetaComponent(input_.messages, input_.component, viewSelection_->getView()));\r\n        componentParser->formatComponent();\r\n\r\n        // Form writers from parsed data.\r\n        QSharedPointer<GenerationOutput> output = factory_->\r\n            prepareComponent(outputControl_->getOutputPath(), componentParser);\r\n\r\n        if (!output)\r\n        {\r\n            return;\r\n        }\r\n\r\n        // Write outputs.\r\n        input_.messages->showMessage(QObject::tr(\"Writing content for preview %1 %2.\").arg(locale.toString(QDate::currentDate(),\r\n            locale.dateFormat(QLocale::ShortFormat)), locale.toString(QTime::currentTime(), locale.timeFormat(QLocale::ShortFormat))));\r\n        output->write(outputControl_->getOutputPath());\r\n\r\n        // Append to the list of proposed outputs.\r\n        outputControl_->getOutputs()->append(output);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: GenerationControl::reInitializeDocuments()\r\n//-----------------------------------------------------------------------------\r\nvoid GenerationControl::reInitializeDocuments(\r\n    QSharedPointer<QList<QSharedPointer<GenerationOutput> > > generationOutputs)\r\n{\r\n    QList<QSharedPointer<GenerationOutput> > newGenerations;\r\n\r\n    if (isDesignGeneration_)\r\n    {\r\n        //! Verilog generator does not work properly while switching folders. A custom name is not kept.\r\n        //! Component side works already, design configuration does not.\r\n\r\n        QList<QSharedPointer<MetaDesign> > designs =\r\n            MetaDesign::parseHierarchy(library_, input_, viewSelection_->getView());\r\n\r\n        QList<QSharedPointer<GenerationOutput> > documents = factory_->prepareDesign(designs);\r\n        for (auto output : documents)\r\n        {\r\n            if (!output)\r\n            {\r\n                continue;\r\n            }\r\n\r\n            QSharedPointer<GenerationOutput> matchingMetaOutput = getMatchingMetaDesignOutput(output);\r\n            if (matchingMetaOutput)\r\n            {\r\n                QSharedPointer<MetaDesign> matchingMeta = matchingMetaOutput->metaDesign_;\r\n                output->metaDesign_->getTopInstance()->setModuleName(\r\n                    matchingMeta->getTopInstance()->getModuleName());\r\n                output->fileName_ = matchingMetaOutput->fileName_;\r\n\r\n                output->write(outputControl_->getOutputPath());\r\n                newGenerations.append(output);\r\n            }\r\n        }\r\n    }\r\n    else\r\n    {\r\n        for (int outputIndex = 0; outputIndex < generationOutputs->size(); ++outputIndex)\r\n        {\r\n            QSharedPointer<GenerationOutput> selection = generationOutputs->at(outputIndex);\r\n            QSharedPointer<MetaComponent> componentParser = selection->metaComponent_;\r\n            if (componentParser)\r\n            {\r\n                QSharedPointer<MetaComponent> newComponentParser(\r\n                    new MetaComponent(input_.messages, input_.component, viewSelection_->getView()));\r\n                newComponentParser->formatComponent();\r\n                newComponentParser->setModuleName(componentParser->getModuleName());\r\n\r\n                QSharedPointer<GenerationOutput> output =\r\n                    factory_->prepareComponent(outputControl_->getOutputPath(), componentParser);\r\n                if (output)\r\n                {\r\n                    output->fileName_ = selection->fileName_;\r\n                    output->write(outputControl_->getOutputPath());\r\n                    newGenerations.append(output);\r\n                }\r\n            }\r\n        }\r\n    }\r\n\r\n    outputControl_->getOutputs()->clear();\r\n    for (auto generation : newGenerations)\r\n    {\r\n        outputControl_->getOutputs()->append(generation);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: GenerationControl::getMatchingMetaDesign()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<GenerationOutput> GenerationControl::getMatchingMetaDesignOutput(\r\n    QSharedPointer<GenerationOutput> output) const\r\n{\r\n    auto originalTopInstance = output->metaDesign_->getTopInstance();\r\n\r\n    for (auto designOutput : *outputControl_->getOutputs())\r\n    {\r\n        auto comparisonTopInstance = designOutput->metaDesign_->getTopInstance();\r\n\r\n\t\tif (originalTopInstance->getComponent()->getVlnv() == comparisonTopInstance->getComponent()->getVlnv() &&\r\n            (originalTopInstance->getComponentInstance() == nullptr || \r\n            (originalTopInstance->getComponentInstance() && comparisonTopInstance->getComponentInstance() && \r\n            originalTopInstance->getComponentInstance()->name() == comparisonTopInstance->getComponentInstance()->name())))\r\n        {\r\n            return designOutput;\r\n        }\r\n    }\r\n\r\n    return QSharedPointer<GenerationOutput>();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: GenerationControl::getViewSelection()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<ViewSelection> GenerationControl::getViewSelection() const\r\n{\r\n    return viewSelection_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: GenerationControl::getFileOutput()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<OutputControl> GenerationControl::getOutputControl() const\r\n{\r\n    return outputControl_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: GenerationControl::getSettings()\r\n//-----------------------------------------------------------------------------\r\nGenerationSettings* GenerationControl::getSettings() const\r\n{\r\n    return settings_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: GenerationControl::isDesignGeneration()\r\n//-----------------------------------------------------------------------------\r\nbool GenerationControl::isDesignGeneration() const\r\n{\r\n    return isDesignGeneration_;\r\n}\r\n\r\nbool GenerationControl::isUnder() const\r\n{\r\n    QString componentPath = library_->getPath(input_.component->getVlnv());\r\n    QFileInfo fileInfo = QFileInfo(componentPath);\r\n\r\n    return outputControl_->getOutputPath().contains(fileInfo.absolutePath());\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: GenerationControl::findPossibleViews()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<QList<QSharedPointer<View> > > GenerationControl::findPossibleViews(GenerationTuple input)\r\n{\r\n    // Create a new list object.\r\n    QSharedPointer<QList<QSharedPointer<View> > > views = QSharedPointer<QList<QSharedPointer<View> > >\r\n        (new QList<QSharedPointer<View> >);\r\n\r\n    // The input must have a design\r\n    if (!input.design)\r\n    {\r\n        return views;\r\n    }\r\n\r\n    // Go through each view of the containing component and pick the eligible ones.\r\n    for (QSharedPointer<View> view : *input.component->getViews())\r\n    {\r\n        // Find the design instantiation of the view.\r\n        QSharedPointer<DesignInstantiation> viewDesignInstantiation = input.component->getModel()->\r\n            findDesignInstantiation(view->getDesignInstantiationRef());\r\n\r\n        // If it exists it must refer to the input design.\r\n        if (viewDesignInstantiation && *viewDesignInstantiation->getDesignReference() != input.design->getVlnv())\r\n        {\r\n            continue;\r\n        }\r\n\r\n        // Find the design configuration instantiation of the view.\r\n        QSharedPointer<DesignConfigurationInstantiation> viewDesignConfigInstantiation = input.component->getModel()->\r\n            findDesignConfigurationInstantiation(view->getDesignConfigurationInstantiationRef());\r\n\r\n        // If input has no design configuration, the instantiation must not exist.\r\n        if (!input.designConfiguration && viewDesignConfigInstantiation)\r\n        {\r\n            continue;\r\n        }\r\n\r\n        // If it does, the instantiation must exist and VLNVs must match.\r\n        if ((input.designConfiguration && !viewDesignConfigInstantiation) ||\r\n            (viewDesignConfigInstantiation && *viewDesignConfigInstantiation->getDesignConfigurationReference() != input.designConfiguration->getVlnv()))\r\n        {\r\n            continue;\r\n        }\r\n\r\n        // If above conditions are satisfied, the view may be used for generation.\r\n        views->append(view);\r\n    }\r\n\r\n    // Finally, return the pickings.\r\n    return views;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: GenerationControl::findPossibleViews()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<QList<QSharedPointer<View> > > GenerationControl::findPossibleViews(\r\n    QSharedPointer<const Component> targetComponent) const\r\n{\r\n    // If the generation is targeted to a component, return the flat views of the component.\r\n    QSharedPointer<QList<QSharedPointer<View> > > views = QSharedPointer<QList<QSharedPointer<View> > >\r\n        (new QList<QSharedPointer<View> >);\r\n\r\n    // In practice, go through each view, and if it is not hierarchical, append to the list.\r\n    for (QSharedPointer<View> view : *targetComponent->getViews())\r\n    {\r\n        if (!view->isHierarchical())\r\n        {\r\n            views->append(view);\r\n        }\r\n    }\r\n\r\n    return views;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: GenerationControl::defaultOutputPath()\r\n//-----------------------------------------------------------------------------\r\nQString GenerationControl::defaultOutputPath() const\r\n{\r\n    QString suggestedDir = \"\";\r\n\r\n    QString topComponentPath = library_->getPath(input_.component->getVlnv());\r\n    QString xmlDir =  QFileInfo(topComponentPath).canonicalPath();\r\n    suggestedDir = xmlDir;\r\n\r\n    return suggestedDir;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: GenerationControl::relativePathForFile()\r\n//-----------------------------------------------------------------------------\r\nQString GenerationControl::relativePathFromXmlToFile(QString const& filePath) const\r\n{\r\n    QString xmlPath = library_->getPath(input_.component->getVlnv());\r\n    return General::getRelativePath(xmlPath, filePath);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: GenerationControl::insertFileDescription()\r\n//-----------------------------------------------------------------------------\r\nvoid GenerationControl::insertFileDescription(QSharedPointer<File> file)\r\n{\r\n    // Get the current description.\r\n    QString desc = file->getDescription();\r\n\r\n    // Find the existing generation time statement.\r\n    QRegularExpression regExp = QRegularExpression(\"(Generated at).+(by Kactus2. *)\");\r\n    // Rip it off.\r\n    QRegularExpressionMatch match = regExp.match(desc);\r\n    desc = desc.remove(match.capturedStart(), match.capturedLength());\r\n\r\n    // Form string time and date string.\r\n    QDateTime generationTime = QDateTime::currentDateTime();\r\n    QString date = generationTime.date().toString(\"dd.MM.yyyy\");\r\n    QString time = generationTime.time().toString(\"hh:mm:ss\");\r\n\r\n    // Append the generation time description to the description.\r\n    file->setDescription(\"Generated at \" + time + \" on \" + date + \" by Kactus2. \" + desc);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: GenerationControl::setupRenamedSelection()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<GenerationOutput> GenerationControl::setupRenamedSelection(int const& fileIndex)\r\n{\r\n    QSharedPointer < QList<QSharedPointer<GenerationOutput> > > generationOutputs = outputControl_->getOutputs();\r\n    QSharedPointer<GenerationOutput> selection = generationOutputs->at(fileIndex);\r\n    QString selectionFileName = selection->fileName_;\r\n    if (selectionFileName.right(2) == \".v\")\r\n    {\r\n        selectionFileName = selectionFileName.left(selectionFileName.size() - 2);\r\n    }\r\n\r\n    if (isDesignGeneration_)\r\n    {\r\n        selection->metaDesign_->getTopInstance()->setModuleName(selectionFileName);\r\n\r\n        if (auto correctedFileName = selection->fileName_; correctedFileName.right(2) != \".v\")\r\n        {\r\n            correctedFileName.append(\".v\");\r\n            selection->fileName_ = correctedFileName;\r\n        }\r\n\r\n        selection->write(outputControl_->getOutputPath());\r\n\r\n        generationOutputs->replace(fileIndex, selection);\r\n    }\r\n    else\r\n    {\r\n        auto locale = QLocale::system();\r\n\r\n        input_.messages->showMessage(QObject::tr(\"Formatting component %1 %2.\").arg(locale.toString(QDate::currentDate(),\r\n            locale.dateFormat(QLocale::ShortFormat)), locale.toString(QTime::currentTime(), locale.timeFormat(QLocale::ShortFormat))));\r\n\r\n        QSharedPointer<MetaComponent> componentParser = selection->metaComponent_;\r\n        componentParser->formatComponent();\r\n        componentParser->setModuleName(selectionFileName);\r\n\r\n        QSharedPointer<GenerationOutput> output =\r\n            factory_->prepareComponent(outputControl_->getOutputPath(), componentParser);\r\n        if (output)\r\n        {\r\n            input_.messages->showMessage(QObject::tr(\"Writing content for preview %1 %2.\").arg(locale.toString(QDate::currentDate(),\r\n                locale.dateFormat(QLocale::ShortFormat)), locale.toString(QTime::currentTime(), locale.timeFormat(QLocale::ShortFormat))));\r\n\r\n            output->write(outputControl_->getOutputPath());\r\n\r\n            selection = output;\r\n            generationOutputs->replace(fileIndex, selection);\r\n        }\r\n    }\r\n\r\n    return selection;\r\n}\r\n"
  },
  {
    "path": "Plugins/PluginSystem/GeneratorPlugin/GenerationControl.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: GenerationControl.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Janne Virtanen\r\n// Date: 26.01.2017\r\n//\r\n// Description:\r\n// Class to control the over structure of generation.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef GENERATIONCONTROL_H\r\n#define GENERATIONCONTROL_H\r\n\r\n#include \"ViewSelection.h\"\r\n#include \"OutputControl.h\"\r\n\r\n#include <Plugins/PluginSystem/GeneratorPlugin/IWriterFactory.h>\r\n\r\nclass LibraryInterface;\r\n\r\nstruct GenerationSettings\r\n{\r\n    //! If true, interfaces should be utilized in generation, else it is false.\r\n    bool generateInterfaces_;\r\n    //! The last values used by the generation.\r\n    QString lastViewName_;\r\n    QString lastFileSetName_;\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Container class for generator configuration.\r\n//-----------------------------------------------------------------------------\r\nclass GenerationControl\r\n{\r\npublic:\r\n\r\n\t//! The constructors.\r\n    GenerationControl(LibraryInterface* library,\r\n        IWriterFactory* factory,\r\n        GenerationTuple input,\r\n        GenerationSettings* settings);\r\n\r\n    // Disable copying.\r\n    GenerationControl(GenerationControl const& rhs) = delete;\r\n    GenerationControl& operator=(GenerationControl const& rhs) = delete;\r\n\r\n\t//! The destructor.\r\n    virtual ~GenerationControl() = default;\r\n\r\n    /*!\r\n     *  Tries to write documents to file system. Returns true if succeeds, else false.\r\n     */\r\n    bool writeDocuments();\r\n    \r\n    /*!\r\n     *  Tries to write changes of the top component to file system. Returns true if succeeds, else false.\r\n     */\r\n    bool saveChanges();\r\n   \r\n    /*!\r\n     *  Checks if the generation configuration is valid.\r\n     *\r\n     *    @param [out] warning   The stated reason for not accepting.\r\n     */\r\n    bool validSelections(QString &warning);\r\n    \r\n    /*!\r\n     *  Parses the documents so that we know what will be generated.\r\n     */\r\n    void parseDocuments();\r\n\t\r\n    /*!\r\n     *  Gets the view selection data.\r\n     */\r\n\tQSharedPointer<ViewSelection> getViewSelection() const;\r\n\t\r\n    /*!\r\n     *  Gets the output data.\r\n     */\r\n\tQSharedPointer<OutputControl> getOutputControl() const;\r\n\r\n    /*!\r\n     *  Returns settings.\r\n     */\r\n    GenerationSettings* getSettings() const;\r\n\r\n    /*!\r\n     *  Returns isDesignGeneration_;\r\n     */\r\n    bool isDesignGeneration() const;\r\n    \r\n    /*!\r\n     *  Returns true, if target path is a sub folder of the component path.\r\n     */\r\n    bool isUnder() const;\r\n\r\n    /*!\r\n     *  Finds the possible views for generation.\r\n     *\r\n     *    @param [in] input   The relevant IP-XACT documents.\r\n     *\r\n     *    @return List of possible view names for which to run the generation.\r\n     */\r\n    static QSharedPointer<QList<QSharedPointer<View> > > findPossibleViews(GenerationTuple input);\r\n\r\n    /*!\r\n     *  Reconfigure the selected file.\r\n     *\r\n     *    @param [in] fileIndex   Index of the selected file.\r\n     *\r\n     *    @return The reconfigured file output.\r\n     */\r\n    QSharedPointer<GenerationOutput> setupRenamedSelection(int const& fileIndex);\r\n\r\nprotected:\r\n\r\n    /*!\r\n     *  Finds the possible views for generation.\r\n     *\r\n     *    @param [in,out] targetComponent     The component for which the generator is run.\r\n     *\r\n     *    @return List of possible view names for which to run the generation.\r\n     */\r\n    QSharedPointer<QList<QSharedPointer<View> > > findPossibleViews(QSharedPointer<const Component> targetComponent) const;\r\n\r\nprivate:\r\n\r\n    /*!\r\n     *  Initialize the generation documents.\r\n     */\r\n    void initializeDocuments();\r\n\r\n    /*!\r\n     *  Re-initialize the generation documents.\r\n     *\r\n     *    @param [in] generationOutputs   Current documents.\r\n     */\r\n    void reInitializeDocuments(QSharedPointer<QList<QSharedPointer<GenerationOutput> > > generationOutputs);\r\n\r\n    /*!\r\n     *  Get the existing generation output matching the selected generation output.\r\n     *\r\n     *    @param [in] output  The selected generation output.\r\n     *\r\n     *    @return The matching generation output.\r\n     */\r\n    QSharedPointer<GenerationOutput> getMatchingMetaDesignOutput(QSharedPointer<GenerationOutput> output) const;\r\n\r\n    /*!\r\n     *  Returns the default output path.     \r\n     */\r\n    QString defaultOutputPath() const;\r\n    \r\n    /*!\r\n     *  Gets the relative path from the top component xml file to the given absolute path.\r\n     *\r\n     *    @param [in] filePath                The absolute path to the target file.\r\n     *\r\n     *    @return Relative path from the top component xml file to the target file.\r\n     */\r\n    QString relativePathFromXmlToFile(QString const& filePath) const;\r\n\r\n    /*!\r\n     *  Inserts description to a generated file.\r\n     *\r\n\t *    @param [in] file\t\t            The file which needs to be described.\r\n     */\r\n    void insertFileDescription(QSharedPointer<File> file);\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! The plugin utility to use.\r\n    LibraryInterface* library_;\r\n\r\n    //! The language dependent factory for this generation session.\r\n    IWriterFactory* factory_;\r\n    //! Has the input objects for the generation.\r\n    GenerationTuple input_;\r\n    //! Points to the memorized settings.\r\n    GenerationSettings* settings_;\r\n    //! True, if the generation target is deemed to be a design. False, if it is a component.\r\n    bool isDesignGeneration_;\r\n    //! The file output configuration.\r\n    QSharedPointer<OutputControl> outputControl_;\r\n    //! The view selection configuration.\r\n    QSharedPointer<ViewSelection> viewSelection_;\r\n};\r\n\r\n#endif // GENERATIONCONTROL_H\r\n"
  },
  {
    "path": "Plugins/PluginSystem/GeneratorPlugin/HDLGenerationDialog.cpp",
    "content": "﻿//-----------------------------------------------------------------------------\n// File: HDLGenerationDialog.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Janne Virtanen\n// Date: 26.01.2017\n//\n// Description:\n// Dialog for setting file generation options.\n//-----------------------------------------------------------------------------\n\n#include \"HDLGenerationDialog.h\"\n#include \"GenerationControl.h\"\n\n#include <common/KactusColors.h>\n#include <QDialogButtonBox>\n#include <QPushButton>\n#include <QFileDialog>\n#include <QVBoxLayout>\n#include <QCheckBox>\n#include <QGroupBox>\n#include <QTextCursor>\n#include <QGridLayout>\n\n//-----------------------------------------------------------------------------\n// Function: HDLGenerationDialog::HDLGenerationDialog()\n//-----------------------------------------------------------------------------\nHDLGenerationDialog::HDLGenerationDialog(QSharedPointer<GenerationControl> configuration,\n\tQString const& targetFileType, QWidget *parent) :\nQDialog(parent, Qt::WindowTitleHint | Qt::WindowCloseButtonHint), \nconfiguration_(configuration),\nviewSelection_(new ViewSelectionWidget(configuration->getViewSelection(), this)),\nfileOutput_(new FileOutputWidget(configuration->getOutputControl())),\ngeneralWarningLabel_(new QLabel), \npreviewer_(new QPlainTextEdit(this)),\nconsole_(new MessageConsole(this))\n{\n    setWindowTitle(tr(\"File generation for %1\").arg(targetFileType));\n\n    // Create font for previewing.\n    QFont font(\"Courier\");\n    font.setStyleHint(QFont::Monospace);\n    font.setFixedPitch(true);\n    font.setPointSize(9);\n\n    // Create the previewer.\n    previewer_->setFont(font);\n    previewer_->setTabStopDistance(4 * previewer_->fontMetrics().horizontalAdvance(' '));\n    previewer_->setReadOnly(true);\n    previewer_->setCursorWidth(0);\n    previewer_->setLineWrapMode(QPlainTextEdit::NoWrap);\n    previewer_->setMinimumWidth(850);\n\n    // Add everything it their proper position in the final layout.\n\tQVBoxLayout* leftLayout = new QVBoxLayout();\n    leftLayout->addWidget(viewSelection_);\n    leftLayout->addWidget(fileOutput_);\n\n    // Layout for things coming to the bottom part of the dialog.\n\n    // Add Ok and cancel give the dialog results.\n    QDialogButtonBox* dialogButtons = new QDialogButtonBox(QDialogButtonBox::Cancel, \n        Qt::Horizontal);\n    QPushButton* writeButton = dialogButtons->addButton(\"Write files\", QDialogButtonBox::AcceptRole);\n    writeButton->setDefault(false);\n    writeButton->setAutoDefault(false);\n\n    QGridLayout* grid = new QGridLayout(this);\n\n    QGroupBox* leftBox = new QGroupBox(\"Settings\");\n    leftBox->setLayout(leftLayout);\n\n    QGroupBox* logBox = new QGroupBox(\"Log\");\n    QVBoxLayout* botLayout = new QVBoxLayout();\n    logBox->setLayout(botLayout);\n\n    console_->setMinimumWidth(500);\n    botLayout->addWidget(console_);\n\n    grid->addWidget(leftBox, 0, 0, 2, 1);\n    grid->addWidget(logBox, 2, 0, 2, 1);\n\n    QGroupBox* rightBox = new QGroupBox(\"Preview\");\n    QVBoxLayout* rightLayout = new QVBoxLayout();\n    rightLayout->addWidget(previewer_);\n    rightBox->setLayout(rightLayout);\n\n    grid->addWidget(rightBox, 0, 1, 4, 2);\n    grid->addWidget(dialogButtons, 4, 2, 1, 1);\n    grid->addWidget(generalWarningLabel_, 4, 1, 1, 1);\n\n    // Finally, connect the relevant events to their handler functions.\n\n    // Connect the view selection.\n    connect(viewSelection_, SIGNAL(viewChanged()), \n        this, SLOT(onViewChanged()), Qt::UniqueConnection);\n\n    // Connect file output.\n    connect(fileOutput_, SIGNAL(selectedFileChanged(QSharedPointer<GenerationOutput>)), \n        this, SLOT(onSelectedFileChanged(QSharedPointer<GenerationOutput>)), Qt::UniqueConnection);\n    connect(fileOutput_, SIGNAL(fileNameChanged(int const&)),\n        this, SLOT(onFileNameChanged(int const&)), Qt::UniqueConnection);\n\n    connect(fileOutput_, SIGNAL(outputPathChanged()), this, SLOT(onOutputPathChanged()), Qt::UniqueConnection);\n\n    // Connect the dialog buttons to their respective functions.\n    connect(dialogButtons, SIGNAL(accepted()), this, SLOT(accept()), Qt::UniqueConnection);\n    connect(dialogButtons, SIGNAL(rejected()), this, SLOT(reject()), Qt::UniqueConnection);\n}\n\n//-----------------------------------------------------------------------------\n// Function: HDLGenerationDialog::~HDLGenerationDialog()\n//-----------------------------------------------------------------------------\nHDLGenerationDialog::~HDLGenerationDialog()\n{\n}\n\n//-----------------------------------------------------------------------------\n// Function: HDLGenerationDialog::setPreviewHighlighter()\n//-----------------------------------------------------------------------------\nvoid HDLGenerationDialog::setPreviewHighlighter(QSyntaxHighlighter* highlighter)\n{\n    highlighter->setDocument(previewer_->document());\n}\n\n//-----------------------------------------------------------------------------\n// Function: HDLGenerationDialog::accept()\n//-----------------------------------------------------------------------------\nvoid HDLGenerationDialog::accept()\n{\n    if (fileOutput_->canAccept() == false)\n    {\n        return;\n    }\n\n\t// Check it is sane.\n    QString warning;\n    if (!configuration_->validSelections(warning))\n\t{\n        // If not, tell user why not.\n\t\tgeneralWarningLabel_->setText(warning);\n\t\treturn;\n\t}\n\n    if (!configuration_->writeDocuments())\n    {\n        return;\n    }\n\n    QDialog::accept();\n}\n\n//-----------------------------------------------------------------------------\n// Function: HDLGenerationDialog::onViewChanged()\n//-----------------------------------------------------------------------------\nvoid HDLGenerationDialog::onViewChanged()\n{\n    configuration_->parseDocuments();\n    fileOutput_->onOutputFilesChanged();\n}\n\n//-----------------------------------------------------------------------------\n// Function: HDLGenerationDialog::onNoticeMessage()\n//-----------------------------------------------------------------------------\nvoid HDLGenerationDialog::onNoticeMessage(QString const& message)\n{\n    console_->onNoticeMessage(message);\n}\n\n//-----------------------------------------------------------------------------\n// Function: HDLGenerationDialog::onErrorMessage()\n//-----------------------------------------------------------------------------\nvoid HDLGenerationDialog::onErrorMessage(QString const& message)\n{\n    console_->onErrorMessage(message);\n}\n\n//-----------------------------------------------------------------------------\n// Function: HDLGenerationDialog::onFileNameChanged()\n//-----------------------------------------------------------------------------\nvoid HDLGenerationDialog::onFileNameChanged(int const& itemIndex)\n{\n    QSharedPointer<GenerationOutput> selection = configuration_->setupRenamedSelection(itemIndex);\n}\n\n//-----------------------------------------------------------------------------\n// Function: HDLGenerationDialog::onSelectedFileChanged()\n//-----------------------------------------------------------------------------\nvoid HDLGenerationDialog::onSelectedFileChanged(QSharedPointer<GenerationOutput> newSelection)\n{\n    previewer_->setPlainText(newSelection->fileContent_);\n\n    int higlightStart;\n    int highlightEnd;\n\n    newSelection->getBodyHighlight(higlightStart, highlightEnd);\n\n    if (higlightStart < 0 || highlightEnd < 0)\n    {\n        return;\n    }\n\n    QTextCursor cursor = previewer_->textCursor();\n    cursor.setPosition(higlightStart);\n\n    QTextCharFormat highlighFormat = cursor.charFormat();        \n    highlighFormat.setBackground(QBrush(KactusColors::TEXT_BODY_HIGHLIGHT));\n\n    cursor.setPosition(highlightEnd, QTextCursor::KeepAnchor);        \n    cursor.setCharFormat(highlighFormat);\n}\n\n//-----------------------------------------------------------------------------\n// Function: HDLGenerationDialog::onOutputPathChanged()\n//-----------------------------------------------------------------------------\nvoid HDLGenerationDialog::onOutputPathChanged()\n{\n    configuration_->parseDocuments();\n    fileOutput_->onOutputFilesChanged();\n}"
  },
  {
    "path": "Plugins/PluginSystem/GeneratorPlugin/HDLGenerationDialog.h",
    "content": "//-----------------------------------------------------------------------------\n// File: HDLGenerationDialog.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Janne Virtanen\n// Date: 26.01.2017\n//\n// Description:\n// Dialog for setting file generation options.\n//-----------------------------------------------------------------------------\n\n#ifndef HDLGENERATIONDIALOG_H\n#define HDLGENERATIONDIALOG_H\n\n#include <QDialog>\n#include <QLabel>\n#include <QPlainTextEdit>\n\n#include \"ViewSelectionWidget.h\"\n#include \"FileOutputWidget.h\"\n#include <mainwindow/MessageConsole/messageconsole.h>\n\n#include <QSyntaxHighlighter>\n\nclass GenerationControl;\n\n//-----------------------------------------------------------------------------\n//! Interface model for setting file generation options.\n//-----------------------------------------------------------------------------\nclass HDLGenerationDialog : public QDialog\n{\n    Q_OBJECT\n\npublic:\n\n\t//! The constructor.\n\tHDLGenerationDialog(QSharedPointer<GenerationControl> configuration, QString const& targetFileType, QWidget *parent);\n\n\t//! The destructor.\n    virtual ~HDLGenerationDialog();\n\n    /*!\n     *  Sets syntax highlighter for the generation preview.\n     *\n     *    @param [in] highlighter   The highlighter to use for preview.\n     */\n    void setPreviewHighlighter(QSyntaxHighlighter* highlighter);\n\npublic slots:\n\n    // Received when the OK button is pressed. NOTICE: Overrides slot accept() of the parent class.\n    virtual void accept();\n\n    void onViewChanged();\n\n    void onNoticeMessage(QString const& message);\n\n    void onErrorMessage(QString const& message);\n\nprivate slots:\n\n    /*!\n     *  Handle the file name change.\n     *\n     *    @param [in] itemIndex   Index of the changed file.\n     */\n    void onFileNameChanged(int const& itemIndex);\n\n    void onSelectedFileChanged(QSharedPointer<GenerationOutput> newSelection);\n\n    void onOutputPathChanged();\n\nprivate:\n\n    // Disable copying.\n    HDLGenerationDialog(HDLGenerationDialog const& rhs);\n    HDLGenerationDialog& operator=(HDLGenerationDialog const& rhs);\n\n\n    //-----------------------------------------------------------------------------\n    // Data.\n    //-----------------------------------------------------------------------------\n\n\t//! The \"model\" for the dialog.\n\tQSharedPointer<GenerationControl> configuration_;\n\n\t//! Widget for selecting view-component instantiation-file set -tuple.\n    ViewSelectionWidget* viewSelection_;\n\n    //! Widget for output file information.\n    FileOutputWidget* fileOutput_;\n\n    //! General warnings are displayed here.\n\tQLabel* generalWarningLabel_;\n\n    //! Preview for the generation output.\n    QPlainTextEdit* previewer_;\n\n    //! Output window for the messages.\n    MessageConsole* console_;\n};\n\n#endif //HDLGENERATIONDIALOG_H"
  },
  {
    "path": "Plugins/PluginSystem/GeneratorPlugin/IWriterFactory.h",
    "content": "//-----------------------------------------------------------------------------\n// File: IWriterFactory.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Janne Virtanen\n// Date: 30.01.2017\n//\n// Description:\n// Common interface for writer factories of generators.\n//-----------------------------------------------------------------------------\n\n#ifndef IWRITERFACTORY_H\n#define IWRITERFACTORY_H\n\n#include <Plugins/common/HDLParser/MetaDesign.h>\n\n//-----------------------------------------------------------------------------\n// Common interface for writer factories of generators.\n//-----------------------------------------------------------------------------\nclass IWriterFactory\n{\npublic:\n    /*!\n     *  Destructor.\n     */\n    virtual ~IWriterFactory() {}\n\n    /*!\n     *  Creates writers for the given formatted HDL component.\n     *\n     *    @param [in] outputPath\t\t\tThe path to the output file.\n     *    @param [in] component           The component which is needs writing.\n     *\n     *    @return The objects that bundles the writers. Will be null, if could not be created.\n     */\n    virtual QSharedPointer<GenerationOutput> prepareComponent(QString const& outputPath,\n        QSharedPointer<MetaComponent> component) = 0;\n\n    /*!\n     *  Creates writers for the given meta designs.\n     *\n     *    @param [in] designs             The designs that will yield documents.\n     *\n     *    @return The objects that bundles the writers. Will be null, if could not be created.\n     */\n    virtual QList<QSharedPointer<GenerationOutput> > prepareDesign(QList<QSharedPointer<MetaDesign> >& designs) = 0;\n    \n    /*!\n     *  Returns the language of the factory.\n     */\n    virtual QString getLanguage() const = 0;\n    \n    /*!\n     *  Returns true, if it is desirable to save the output to file set by default.\n     */\n    virtual bool getSaveToFileset() const = 0;\n    \n    /*!\n     *  Returns the group identifier suitable for the produced files.\n     */\n    virtual QString getGroupIdentifier() const = 0;\n};\n\n#endif // IWRITERFACTORY_H\n"
  },
  {
    "path": "Plugins/PluginSystem/GeneratorPlugin/MessagePasser.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: MessagePasser.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Janne Virtanen\n// Date: 02.02.2017\n//\n// Description:\n// Class for passing messages to UI.\n//-----------------------------------------------------------------------------\n\n#include \"MessagePasser.h\"\n\n//-----------------------------------------------------------------------------\n// Function: MessagePasser::MessagePasser()\n//-----------------------------------------------------------------------------\nMessagePasser::MessagePasser() : QObject(0)\n{\n}\n\n//-----------------------------------------------------------------------------\n// Function: MessagePasser::~MessagePasser()\n//-----------------------------------------------------------------------------\nMessagePasser::~MessagePasser()\n{\n}\n\n//-----------------------------------------------------------------------------\n// Function: MessagePasser::sendError()\n//-----------------------------------------------------------------------------\nvoid MessagePasser::showError(QString const& message) const\n{\n    emit errorMessage(message);\n}\n\n//-----------------------------------------------------------------------------\n// Function: MessagePasser::sendNotice()\n//-----------------------------------------------------------------------------\nvoid MessagePasser::showMessage(QString const& message) const\n{\n    emit noticeMessage(message);\n}\n\n//-----------------------------------------------------------------------------\n// Function: MessagePasser::showFailure()\n//-----------------------------------------------------------------------------\nvoid MessagePasser::showFailure(QString const& error) const\n{\n    emit errorMessage(error);\n}\n\n//-----------------------------------------------------------------------------\n// Function: MessagePasser::showStatusMessage()\n//-----------------------------------------------------------------------------\nvoid MessagePasser::showStatusMessage(QString const& /*status*/) const\n{\n\n}\n"
  },
  {
    "path": "Plugins/PluginSystem/GeneratorPlugin/MessagePasser.h",
    "content": "//-----------------------------------------------------------------------------\n// File: MessagePasser.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Janne Virtanen\n// Date: 02.02.2017\n//\n// Description:\n// Class for passing messages to UI.\n//-----------------------------------------------------------------------------\n\n#ifndef MESSAGEPASSER_H\n#define MESSAGEPASSER_H\n\n#include <KactusAPI/include/MessageMediator.h>\n\n#include <QString>\n#include <QObject>\n\n//-----------------------------------------------------------------------------\n// Class for passing messages to UI.\n//-----------------------------------------------------------------------------\nclass MessagePasser : public QObject, public MessageMediator\n{\n    Q_OBJECT\n\npublic:\n\n\t//! The constructor.\n    MessagePasser();\n\n\t//! The destructor.\n    virtual ~MessagePasser();\n\n    /*!\n     *  Signals the given notice message.\n     */\n    virtual void showMessage(QString const& message) const;\n\n    /*!\n     *  Signals the given error message.\n     */\n    virtual void showError(QString const& message) const;\n\n    virtual void showFailure(QString const& error) const;\n\n    virtual void showStatusMessage(QString const& status) const;\n\nsignals:\n\n    // Emitted when an error message is received\n    void errorMessage(QString const& message) const;\n\n    // Emitted when a notice message is received\n    void noticeMessage(QString const& message) const;\n\nprivate:\n\n\t// Disable copying.\n\tMessagePasser(MessagePasser const& rhs);\n\tMessagePasser& operator=(MessagePasser const& rhs);\n};\n\n#endif // MESSAGEPASSER_H\n"
  },
  {
    "path": "Plugins/PluginSystem/GeneratorPlugin/OutputControl.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: OutputControl.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Janne Virtanen\r\n// Date: 15.11.2016\r\n//\r\n// Description:\r\n// Container class for file output of generation.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"OutputControl.h\"\r\n\r\n#include <IPXACTmodels/Component/View.h>\r\n#include <IPXACTmodels/Component/ComponentInstantiation.h>\r\n#include <IPXACTmodels/Component/FileSet.h>\r\n\r\n#include <QDir>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: OutputControl::OutputControl()\r\n//-----------------------------------------------------------------------------\r\nOutputControl::OutputControl() : outputPath_(), outputs_(new QList<QSharedPointer<GenerationOutput> >)\r\n{\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: OutputControl::~OutputControl()\r\n//-----------------------------------------------------------------------------\r\nOutputControl::~OutputControl()\r\n{\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: OutputControl::validSelections()\r\n//-----------------------------------------------------------------------------\r\nbool OutputControl::validSelections(QString &warning)\r\n{\r\n    // Must have path for the files. \r\n    if (outputPath_.isEmpty() || !QDir(outputPath_).exists())\r\n    {\r\n        warning = QLatin1String(\"<b>The output directory must exist.</b>\");\r\n        return false;\r\n    }\r\n\r\n    // Must not have same file name more than once!\r\n    for(int i = 0; i < outputs_->size(); ++i)\r\n    {\r\n        QSharedPointer<GenerationOutput> file = outputs_->at(i);\r\n\r\n        for(int j = 0; j < outputs_->size(); ++j)\r\n        {\r\n            // Do not compare with itself\r\n            if (i==j)\r\n            {\r\n                continue;\r\n            }\r\n\r\n            QString name2compare = outputs_->at(j)->fileName_;\r\n\r\n            // Is the same -> fail.\r\n            if (file->fileName_ == name2compare)\r\n            {\r\n                warning = QLatin1String(\"<b>File name</b> \") + file->fileName_ + QLatin1String(\" <b>is listed more than once.</b>\");\r\n                return false;\r\n            }\r\n        }\r\n    }\r\n\r\n    return true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: OutputControl::setOutputPath()\r\n//-----------------------------------------------------------------------------\r\nvoid OutputControl::setOutputPath(QString const& path)\r\n{\r\n    outputPath_ = path;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: OutputControl::getOutputPath()\r\n//-----------------------------------------------------------------------------\r\nQString OutputControl::getOutputPath() const\r\n{\r\n    return outputPath_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: OutputControl::getFileNames()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<QList<QSharedPointer<GenerationOutput> > > OutputControl::getOutputs()\r\n{\r\n    return outputs_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: OutputControl::changeFileName()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<GenerationOutput> OutputControl::changeFileName(int index, QString const& newName)\r\n{\r\n    if (index >= outputs_->size() || index < 0)\r\n    {\r\n        return QSharedPointer<GenerationOutput>();\r\n    }\r\n\r\n    QSharedPointer<GenerationOutput> selection = outputs_->at(index);\r\n\r\n    if (selection->fileName_ == newName)\r\n    {\r\n        return QSharedPointer<GenerationOutput>();\r\n    }\r\n\r\n    selection->fileName_ = newName;\r\n\r\n    return selection;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: OutputControl::writeFileToCurrentPath()\r\n//-----------------------------------------------------------------------------\r\nvoid OutputControl::writeFileToCurrentPath(int const& index)\r\n{\r\n\tif (index >= outputs_->size() || index < 0)\r\n\t{\r\n        return;\r\n\t}\r\n\r\n\tQSharedPointer<GenerationOutput> selection = outputs_->at(index);\r\n    selection->write(outputPath_);\r\n}\r\n"
  },
  {
    "path": "Plugins/PluginSystem/GeneratorPlugin/OutputControl.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: OutputControl.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Janne Virtanen\r\n// Date: 15.11.2016\r\n//\r\n// Description:\r\n// Helps to control output of generation.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef OUTPUTCONTROL_H\r\n#define OUTPUTCONTROL_H\r\n\r\n#include <QString>\r\n#include <QMap>\r\n#include <QSharedPointer>\r\n\r\n#include \"ViewSelection.h\"\r\n\r\nclass MetaComponent;\r\nclass MetaDesign;\r\n\r\nstruct GenerationOutput\r\n{\r\n    //! The name for the file created from the output.\r\n    QString fileName_;\r\n\r\n    //! The VLNV of the component corresponding the output.\r\n    QString vlnv_;\r\n    //! The content of the output, ie. what will be written to the file.\r\n    QString fileContent_;\r\n    \r\n    //! The meta component of the output.\r\n    QSharedPointer<MetaComponent> metaComponent_;\r\n\r\n    //! The meta design of the output.\r\n    QSharedPointer<MetaDesign> metaDesign_;\r\n\r\n    GenerationOutput() = default;\r\n\r\n    virtual ~GenerationOutput() = default;\r\n\r\n    /*!\r\n     *  Writes the content.\r\n     */\r\n\tvirtual void write(QString const& outputDirectory) = 0;\r\n    \r\n    /*!\r\n     *  Finds position for body text highlight in document, if any exists.\r\n     *\r\n\t *    @param [out] begin                  The position where the highlight begins, if successful.\r\n     *    @param [out] end                    The position where the highlight ends, if successful.\r\n     */\r\n    virtual void getBodyHighlight(int& begin, int& end) const = 0;\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n// Container class for file output of generation.\r\n//-----------------------------------------------------------------------------\r\nclass OutputControl\r\n{\r\npublic:\r\n\r\n\t//! The constructor.\r\n    OutputControl();\r\n\r\n\t//! The destructor.\r\n\t~OutputControl();\r\n    \r\n    /*!\r\n     *  Checks if the file output configuration is valid.\r\n     *\r\n     *    @param [out] warning   The stated reason for not accepting.\r\n     */\r\n    bool validSelections(QString &warning);\r\n\r\n    /*!\r\n     *  Sets the path for the output file for the generation.\r\n     *\r\n     *    @param [in] path   The path to set.\r\n     */\r\n    void setOutputPath(QString const& path);\r\n\r\n    /*!\r\n     *  Gets the output path for generation.\r\n     *\r\n     *    @return The path to output file.\r\n     */\r\n    QString getOutputPath() const;\r\n    \r\n    /*!\r\n     *  Gets reference to the output file paths.\r\n     */\r\n    QSharedPointer<QList<QSharedPointer<GenerationOutput> > > getOutputs();\r\n    \r\n    /*!\r\n     *  Tries to change the file name of an output. Will rewrite the content.\r\n     *\r\n     *    @param [in] index           The position of the output within the list.\r\n     *    @param [in] newName         The would-be new name for the file.\r\n     *\r\n     *    @return The changed output if the change was successful.\r\n     */\r\n    QSharedPointer<GenerationOutput> changeFileName(int index, QString const& newName);\r\n\r\n    /*!\r\n     *  Write the contents of the selected file using the current base directory.\r\n     *\r\n     *    @param [in] index     The position of the output within the list.\r\n     */\r\n    void writeFileToCurrentPath(int const& index);\r\n\r\nprivate:\r\n\r\n\t// Disable copying.\r\n\tOutputControl(OutputControl const& rhs);\r\n\tOutputControl& operator=(OutputControl const& rhs);\r\n\r\n    //! The base directory for output paths.\r\n    QString outputPath_;\r\n    //! The directory of the component which may refer to the files.\r\n    QString componentPath_;\r\n    //! The potential new files.\r\n    QSharedPointer<QList<QSharedPointer<GenerationOutput> > > outputs_;\r\n};\r\n\r\n#endif // OUTPUTCONTROL_H\r\n"
  },
  {
    "path": "Plugins/PluginSystem/GeneratorPlugin/ViewSelection.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ViewSelection.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Janne Virtanen\r\n// Date: 13.09.2016\r\n//\r\n// Description:\r\n// Container class for view selection.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"ViewSelection.h\"\r\n#include \"GenerationControl.h\"\r\n\r\n#include <IPXACTmodels/Component/View.h>\r\n#include <IPXACTmodels/Component/ComponentInstantiation.h>\r\n#include <IPXACTmodels/Component/FileSet.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ViewSelection::ViewSelection()\r\n//-----------------------------------------------------------------------------\r\nViewSelection::ViewSelection(QString const& targetLanguage, \r\n    bool saveToFileset, \r\n    QString const& targetGroup, \r\n\tGenerationSettings* settings,\r\n\tQSharedPointer<QList<QSharedPointer<View> > > views, \r\n\tQSharedPointer<QList<QSharedPointer<ComponentInstantiation> > > instantiations, \r\n\tQSharedPointer<QList<QSharedPointer<FileSet> > > fileSets) :\r\n\ttargetLanguage_(targetLanguage), view_(), saveToFileset_(saveToFileset)\r\n{\r\n\t// Track the views by name.\r\n\tforeach (QSharedPointer<View> currentView, *views)\r\n\t{\r\n\t\tviews_[currentView->name()] = currentView;\r\n\t}\r\n\r\n\t// Track the instantiations by name.\r\n\tforeach (QSharedPointer<ComponentInstantiation> cimp, *instantiations)\r\n\t{\r\n\t\tinstantiations_[cimp->name()] = cimp;\r\n\t}\r\n\r\n\t// Track the file sets by name.\r\n\tforeach (QSharedPointer<FileSet> fileSet, *fileSets)\r\n\t{\r\n\t\tfileSets_[fileSet->name()] = fileSet;\r\n\t}\r\n\r\n    // Try to find the default view from the mapping.\r\n    view_ = views_.value(settings->lastViewName_);\r\n\r\n    if (!view_)\r\n    {\r\n        // If not found, try to find a view that has the target language in its instantiation.\r\n        foreach(QSharedPointer<View> view, views_)\r\n        {\r\n            QSharedPointer<ComponentInstantiation> cimp = instantiations_.value(view->getComponentInstantiationRef());\r\n\r\n            if (cimp && cimp->getLanguage().toLower() == targetLanguage_.toLower())\r\n            {\r\n                // If this is a match, pick both view and instantiation.\r\n                view_ = view;\r\n                instantiation_ = cimp;\r\n                break;\r\n            }\r\n        }\r\n    }\r\n\r\n    // If none found, just pick the first one.\r\n    if (!view_ && views_.size() > 0)\r\n    {\r\n        view_ = views_.first();\r\n    }\r\n\r\n    // If view is found, but not the instantiation, try to pick instantiation referenced by the view.\r\n    if (view_ && !instantiation_)\r\n    {\r\n        instantiation_ = instantiations_.value(view_->getComponentInstantiationRef());\r\n    }\r\n\r\n    // Also try find a default file set.\r\n    fileSet_ = fileSets_.value(settings->lastFileSetName_);\r\n\r\n    // If instantiation exists and it has file set references, it may affect the choice.\r\n    if (instantiation_ && instantiation_->getFileSetReferences()->isEmpty() == false)\r\n    {\r\n        // If the default file set exists and is referred by the instantiation, it is a valid choice.\r\n        if (!fileSet_ || !instantiation_->getFileSetReferenceStrings().contains(fileSet_->name()))\r\n        {\r\n            // If not, try to first find one with a matching group identifier.\r\n            for (auto const& fileSetRef : *instantiation_->getFileSetReferences())\r\n            {\r\n                QSharedPointer<FileSet> inspect =  fileSets_.value(fileSetRef->getReference());\r\n\r\n                if (inspect->getGroups()->contains(targetGroup))\r\n                {\r\n                    fileSet_ = inspect;\r\n                }\r\n            }\r\n\r\n            // If none found, pick the first one.\r\n            if (!fileSet_)\r\n            {\r\n                fileSet_ = fileSets_.value(instantiation_->getFileSetReferences()->first()->getReference());\r\n            }\r\n        }\r\n    }\r\n    \r\n    // If no other match, pick the first file set on the mapping.\r\n    if (!fileSet_ && fileSets_.size() > 0)\r\n    {\r\n        fileSet_ = fileSets_.first();\r\n    }\r\n\r\n    // If a file set was found, take its name as the reference.\r\n    if (fileSet_)\r\n    {\r\n        fileSetRef_ = fileSet_->name();\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ViewSelection::~ViewSelection()\r\n//-----------------------------------------------------------------------------\r\nViewSelection::~ViewSelection()\r\n{\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ViewSelection::validSelections()\r\n//-----------------------------------------------------------------------------\r\nbool ViewSelection::validSelections(QString &warning)\r\n{\r\n    // Must have a file set, if going to use it.\r\n    if (saveToFileset_ && fileSetRef_.isEmpty())\r\n    {\r\n        warning = QLatin1String(\"<b>Define the file set.</b>\");\r\n        return false;\r\n    }\r\n\r\n    return true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ViewSelection::viewNames()\r\n//-----------------------------------------------------------------------------\r\nQStringList ViewSelection::viewNames() const\r\n{\r\n\treturn QStringList(views_.keys());\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ViewSelection::instantiationNames()\r\n//-----------------------------------------------------------------------------\r\nQStringList ViewSelection::instantiationNames() const\r\n{\r\n\treturn QStringList(instantiations_.keys());\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ViewSelection::fileSetNames()\r\n//-----------------------------------------------------------------------------\r\nQStringList ViewSelection::fileSetNames() const\r\n{\r\n\treturn QStringList(fileSets_.keys());\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ViewSelection::setView()\r\n//-----------------------------------------------------------------------------\r\nvoid ViewSelection::setView(QString const& viewName)\r\n{\r\n    view_ = views_.value(viewName);\r\n\r\n    if (view_)\r\n    {\r\n        instantiation_ = instantiations_.value(view_->getComponentInstantiationRef());\r\n\r\n        if (instantiation_ && instantiation_->getFileSetReferences()->isEmpty() == false)\r\n        {\r\n            QSharedPointer<FileSet> newFileSet = fileSets_.value(\r\n                instantiation_->getFileSetReferences()->first()->getReference());\r\n\r\n            if (newFileSet)\r\n            {\r\n                fileSet_ = newFileSet;\r\n                fileSetRef_ = newFileSet->name();\r\n            }\r\n        }\r\n    }\r\n    else\r\n    {\r\n        instantiation_ = QSharedPointer<ComponentInstantiation>();\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ViewSelection::getActiveView()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<View> ViewSelection::getView() const\r\n{\r\n    return view_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ViewSelection::getActiveViewName()\r\n//-----------------------------------------------------------------------------\r\nQString ViewSelection::getViewName() const\r\n{\r\n    if (!view_)\r\n    {\r\n        return \"\";\r\n    }\r\n\r\n    return view_->name();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ViewSelection::getInstantiation()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<ComponentInstantiation> ViewSelection::getInstantiation() const\r\n{\r\n\treturn instantiation_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ViewSelection::getInstantiationName()\r\n//-----------------------------------------------------------------------------\r\nQString ViewSelection::getInstantiationName() const\r\n{\r\n    if (!view_)\r\n    {\r\n        return \"\";\r\n    }\r\n\r\n\treturn view_->getComponentInstantiationRef();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ViewSelection::setFileSetRef()\r\n//-----------------------------------------------------------------------------\r\nbool ViewSelection::setFileSet(QString const& fileSetRef)\r\n{\r\n\tfileSet_ = fileSets_.value(fileSetRef);\r\n\tfileSetRef_ = fileSetRef;\r\n\r\n\tif (fileSet_)\r\n\t{\r\n\t\treturn true;\r\n\t}\r\n\r\n\treturn false;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ViewSelection::getFileSet()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<FileSet> ViewSelection::getFileSet() const\r\n{\r\n\treturn fileSet_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ViewSelection::getFileSetRef()\r\n//-----------------------------------------------------------------------------\r\nQString ViewSelection::getFileSetName() const\r\n{\r\n\treturn fileSetRef_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ViewSelection::getAddToFileset()\r\n//-----------------------------------------------------------------------------\r\nbool ViewSelection::getSaveToFileset() const\r\n{\r\n    return saveToFileset_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ViewSelection::setAddToFileset()\r\n//-----------------------------------------------------------------------------\r\nvoid ViewSelection::setSaveToFileset(bool shouldSave)\r\n{\r\n   saveToFileset_ = shouldSave;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ViewSelection::targetLanguage()\r\n//-----------------------------------------------------------------------------\r\nQString ViewSelection::getTargetLanguage() const\r\n{\r\n    return targetLanguage_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ViewSelection::getCurrentLanguage()\r\n//-----------------------------------------------------------------------------\r\nQString ViewSelection::getCurrentLanguage() const\r\n{\r\n\tif (instantiation_)\r\n\t{\r\n\t\treturn instantiation_->getLanguage();\r\n\t}\r\n\r\n\treturn \"\";\r\n}"
  },
  {
    "path": "Plugins/PluginSystem/GeneratorPlugin/ViewSelection.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ViewSelection.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Janne Virtanen\r\n// Date: 13.09.2016\r\n//\r\n// Description:\r\n// Container class for view selection.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef VIEWSELECTION_H\r\n#define VIEWSELECTION_H\r\n\r\n#include <QString>\r\n#include <QMap>\r\n#include <QSharedPointer>\r\n\r\nclass View;\r\nclass ComponentInstantiation;\r\nclass FileSet;\r\nstruct GenerationSettings;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Container class for view selection.\r\n//-----------------------------------------------------------------------------\r\nclass ViewSelection\r\n{\r\npublic:\r\n\r\n\t//! The constructor.\r\n    ViewSelection(QString const& targetLanguage,\r\n        bool saveToFileset, QString const& targetGroup,\r\n        GenerationSettings* settings, QSharedPointer<QList<QSharedPointer<View> > > views,\r\n        QSharedPointer<QList<QSharedPointer<ComponentInstantiation> > > instantiations,\r\n        QSharedPointer<QList<QSharedPointer<FileSet> > > fileSets);\r\n\r\n\t//! The destructor.\r\n\t~ViewSelection();\r\n    \r\n    /*!\r\n     *  Checks if the view configuration is valid.\r\n     *\r\n     *    @param [out] warning   The stated reason for not accepting.\r\n     */\r\n    bool validSelections(QString &warning);\r\n\t\r\n    /*!\r\n     *  Gets the names of the possible views .\r\n     */\r\n\tQStringList viewNames() const;\r\n\t\r\n    /*!\r\n     *  Gets the names of the possible component instantiations.\r\n     */\r\n\tQStringList instantiationNames() const;\r\n\t\r\n    /*!\r\n     *  Gets the names of the file sets.\r\n     */\r\n\tQStringList fileSetNames() const;\r\n\r\n    /*!\r\n     *  Sets the view for the top component in generation, if it exists.\r\n     *\r\n\t *    @param [in] viewName   The name of the active view.\r\n\t */\r\n    void setView(QString const& viewName);\r\n\r\n    /*!\r\n     *  Gets the active view for the top component.\r\n     */\r\n\tQSharedPointer<View> getView() const;\r\n\r\n    /*!\r\n     *  Gets the name of the active view for the top component.\r\n     */\r\n\tQString getViewName() const;\r\n\t\r\n    /*!\r\n     *  Gets the selected component instantiation.\r\n     */\r\n\tQSharedPointer<ComponentInstantiation> getInstantiation() const;\r\n\r\n    /*!\r\n     *  Gets the name of the selected instantiation, even if it does not exist.\r\n     */\r\n\tQString getInstantiationName() const;\r\n\r\n    /*!\r\n     *  Sets the file set referred by the instantiation.\r\n     *\r\n     *    @param [in] fileSetRef   The fileSetRef to set.\r\n     */\r\n    bool setFileSet(QString const& fileSetRef);\r\n\t\r\n    /*!\r\n     *  Gets the file set referred by the instantiation.\r\n     *\r\n     *    @return The fileSetRef.\r\n     */\r\n\tQSharedPointer<FileSet> getFileSet() const;\r\n\t\r\n    /*!\r\n     *  Gets the name of the selected file set, even if it does not exist.\r\n     */\r\n    QString getFileSetName() const;\r\n\r\n    /*!\r\n     *  Sets whether the output file should be added to top component file sets or not.\r\n     *\r\n     *    @param [in] shouldSave   True for saving, false for not saving.\r\n     */\r\n    void setSaveToFileset(bool shouldSave);\r\n\r\n    /*!\r\n     *  Checks if the output file should be added to top component file sets.\r\n     *\r\n     *    @return True, if file should be saved, false otherwise.\r\n     */\r\n    bool getSaveToFileset() const;\r\n\t\r\n    /*!\r\n     *  Gets the target language of the generation.\r\n     */\r\n    QString getTargetLanguage() const;\r\n\t\r\n    /*!\r\n     *  Gets the language of the selected instantiation, or empty string if none exists.\r\n     */\r\n    QString getCurrentLanguage() const;\r\n\r\nprivate:\r\n\r\n\t// Disable copying.\r\n\tViewSelection(ViewSelection const& rhs);\r\n\tViewSelection& operator=(ViewSelection const& rhs);\r\n\r\n    //! The language for generation.\r\n    QString targetLanguage_;\r\n    //! The possible views, indexed by their names.\r\n    QMap<QString,QSharedPointer<View> > views_;\r\n    //! The possible component instantiations, indexed by their names.\r\n    QMap<QString,QSharedPointer<ComponentInstantiation> > instantiations_;\r\n    //! The possible file sets, indexed by their names.\r\n    QMap<QString,QSharedPointer<FileSet> > fileSets_;\r\n\r\n    //! The selected view.\r\n\tQSharedPointer<View> view_;\r\n\r\n\t//! The component instantiation of the current view.\r\n\tQSharedPointer<ComponentInstantiation> instantiation_;\r\n\r\n\t//! The selected file set and its name.\r\n\tQSharedPointer<FileSet> fileSet_;\r\n\tQString fileSetRef_;\r\n\r\n    //! Flag for indicating if the output file should be saved to top component file sets.\r\n    bool saveToFileset_;\r\n};\r\n\r\n#endif // VIEWSELECTION_H\r\n"
  },
  {
    "path": "Plugins/PluginSystem/GeneratorPlugin/ViewSelectionWidget.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ViewSelectionWidget.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Janne Virtanen\r\n// Date: 14.06.2016\r\n//\r\n// Description:\r\n// Widget for selecting a view, component instantiation and file set for generation.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"ViewSelectionWidget.h\"\r\n#include \"ViewSelection.h\"\r\n\r\n#include <common/KactusColors.h>\r\n\r\n#include <QFormLayout>\r\n#include <QVBoxLayout>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ViewSelectionWidget::ViewSelectionWidget()\r\n//-----------------------------------------------------------------------------\r\nViewSelectionWidget::ViewSelectionWidget(QSharedPointer<ViewSelection> model, QWidget* parent) :\r\nQWidget(parent),\r\n\tmodel_(model),\r\n    viewSelection_(new QComboBox(this)),\r\n    addToFileset_(new AddToFilesetWidget()),\r\n\tinstantiationSelection_(new QLabel),\r\n\tinstantiationLanguage_(new QLabel)\r\n{\r\n\t// Make view selection its own layout.\r\n\tQFormLayout* viewSelectionLayout = new QFormLayout();\r\n    viewSelectionLayout->addRow(tr(\"Select view:\"), viewSelection_);\r\n    // Select an instantiation and the file set in conjunction with view.\r\n    viewSelectionLayout->addRow(tr(\"The component instantiation:\"), instantiationSelection_);\r\n    viewSelectionLayout->addRow(tr(\"Language of the instantiation:\"), instantiationLanguage_);\r\n\r\n    // The names of available views are the view selection items.\r\n    viewSelection_->addItems(model_->viewNames());\r\n    // The names of available file sets are the file set selection items.\r\n    addToFileset_->setExistingFileSets(model_->fileSetNames());\r\n\r\n    // Checkable group box used to include generated file in the IP-XACT component.\r\n    addToFileset_->setChecked(model->getSaveToFileset() != 0);\r\n\r\n\t// Add everything it their proper position in the final layout.\r\n\tQVBoxLayout* topLayout = new QVBoxLayout(this);\r\n    topLayout->addLayout(viewSelectionLayout);\r\n    topLayout->addWidget(addToFileset_);\r\n    // Widget for warning messages.\r\n    //topLayout->addWidget(fileSetWarningLabel_);\r\n\r\n\t// Connect the relevant events to their handler functions.\r\n    connect(addToFileset_, SIGNAL(toggled(bool)), \r\n        this, SLOT(onFileSetStateChanged(bool)), Qt::UniqueConnection);\r\n    connect(viewSelection_, SIGNAL(currentTextChanged(QString const&)),\r\n\t\tthis, SLOT(onViewChanged(QString const&)), Qt::UniqueConnection);\r\n\tconnect(addToFileset_, SIGNAL(fileSetChanged(QString const&)),\r\n\t\tthis, SLOT(onFileSetChanged(QString const&)), Qt::UniqueConnection);\r\n\r\n\t// Get the selected view.\r\n    int defaultViewIndex = viewSelection_->findText(model_->getViewName());\r\n\r\n    if (defaultViewIndex == -1)\r\n    {\r\n        // If none, just pick the topmost.\r\n\t    viewSelection_->setCurrentIndex(0);\r\n    }\r\n    else\r\n    {\r\n        // Else set the selection accordingly.\r\n        viewSelection_->setCurrentIndex(defaultViewIndex);\r\n    }\r\n\r\n    // Affects the selected file set.\r\n    addToFileset_->selectDefaultFileSet(model_->getFileSetName());\r\n\r\n    // Set the instantiation and the language.\r\n    instantiationSelection_->setText(model_->getInstantiationName());\r\n    setLanguage(model_->getCurrentLanguage());\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ViewSelectionWidget::~ViewSelectionWidget()\r\n//-----------------------------------------------------------------------------\r\nViewSelectionWidget::~ViewSelectionWidget()\r\n{\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ViewSelectionWidget::onFileSetStateChanged()\r\n//-----------------------------------------------------------------------------\r\nvoid ViewSelectionWidget::onFileSetStateChanged(bool on)\r\n{\r\n    addToFileset_->setChecked(on);\r\n    model_->setSaveToFileset(on);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ViewSelectionWidget::onViewChanged()\r\n//-----------------------------------------------------------------------------\r\nvoid ViewSelectionWidget::onViewChanged(QString const& selectedViewName)\r\n{\r\n\t// Pass the selection to model, get the component instantiation reference.\r\n\tmodel_->setView(selectedViewName);\r\n\r\n    // Affects the instantiation.\r\n    instantiationSelection_->setText(model_->getInstantiationName());\r\n\r\n    // Update the language.\r\n    setLanguage(model_->getCurrentLanguage());\r\n\r\n    // Affects the selected file set.\r\n    addToFileset_->selectDefaultFileSet(model_->getFileSetName());\r\n\r\n    onFileSetChanged(addToFileset_->currentSelection());\r\n\r\n    emit viewChanged();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ViewSelectionWidget::setLanguage()\r\n//-----------------------------------------------------------------------------\r\nvoid ViewSelectionWidget::setLanguage(QString selectedLanguage)\r\n{\r\n    if (selectedLanguage.isEmpty())\r\n    {\r\n        // Make it more notable, if the selected language is empty\r\n        instantiationLanguage_->setText(\"Not specified\");\r\n    }\r\n    else\r\n    {\r\n        // Inform the language setting to user.\r\n        instantiationLanguage_->setText(selectedLanguage);\r\n    }\r\n\r\n    // No target language means no further reaction.\r\n    if (model_->getTargetLanguage().isEmpty())\r\n    {\r\n        return;\r\n    }\r\n\r\n\t// Select color depending on match.\r\n\tif (selectedLanguage.toLower() == model_->getTargetLanguage().toLower())\r\n\t{\r\n\t\tinstantiationLanguage_->setStyleSheet(\"QLabel { color : green; }\");\r\n\t}\r\n\telse\r\n\t{\r\n\t\tinstantiationLanguage_->setStyleSheet(\"QLabel { color : rgb(255, 102, 45); }\");\r\n\t}\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ViewSelectionWidget::onFileSetChanged()\r\n//-----------------------------------------------------------------------------\r\nvoid ViewSelectionWidget::onFileSetChanged(QString const& fileSetName)\r\n{\r\n\t// Set to the configuration.\r\n    model_->setFileSet(fileSetName);\r\n}\r\n"
  },
  {
    "path": "Plugins/PluginSystem/GeneratorPlugin/ViewSelectionWidget.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ViewSelectionWidget.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Janne Virtanen\r\n// Date: 14.06.2016\r\n//\r\n// Description:\r\n// Widget for selecting a view, component instantiation and file set for generation.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef VIEWSELECTIONWIDGET_H\r\n#define VIEWSELECTIONWIDGET_H\r\n\r\n#include \"AddToFilesetWidget.h\"\r\n\r\n#include <QComboBox>\r\n#include <QGroupBox>\r\n#include <QLabel>\r\n\r\nclass ViewSelection;\r\n\r\nclass ViewSelectionWidget : public QWidget\r\n{\r\n    Q_OBJECT\r\npublic:\r\n\r\n\t//! The constructor.\r\n\tViewSelectionWidget(QSharedPointer<ViewSelection> model, QWidget* parent);\r\n\r\n\t//! The destructor.\r\n\t~ViewSelectionWidget();\r\n\r\nsignals:\r\n\t\r\n    /*!\r\n    *  Emitted when the view is changed.\r\n     */\r\n    void viewChanged() const;\r\n\r\nprivate slots:\r\n    void onFileSetStateChanged(bool on);\r\n\r\n\tvoid onViewChanged(QString const& selectedViewName);\r\n\r\n\tvoid setLanguage(QString selectedLanguage);\r\n\r\n\tvoid onFileSetChanged(QString const& fileSetName);\r\n\r\nprivate:\r\n\r\n    // Disable copying.\r\n    ViewSelectionWidget(ViewSelectionWidget const& rhs);\r\n    ViewSelectionWidget& operator=(ViewSelectionWidget const& rhs);\r\n  \r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n\t// The \"model\" for the widget.\r\n\tQSharedPointer<ViewSelection> model_;\r\n\r\n\t// The combobox to select the desired view.\r\n\tQComboBox* viewSelection_;\r\n\r\n\t// The group box for file set selection\r\n\tAddToFilesetWidget* addToFileset_;\r\n\r\n\t// The combobox to select the desired component instantiation.\r\n\tQLabel* instantiationSelection_;\r\n\r\n\t// The label informing the known language of the currently select instantiation.\r\n\tQLabel* instantiationLanguage_;\r\n};\r\n\r\n#endif //VIEWSELECTIONWIDGET_H"
  },
  {
    "path": "Plugins/QuartusPinImportPlugin/QuartusPinImportPlugin.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: QuartusPinImportPlugin.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Esko Pekkarinen\r\n// Date: 19.11.2013\r\n//\r\n// Description:\r\n// Kactus2 plugin for Quartus II pin import.\r\n//-----------------------------------------------------------------------------\r\n\r\n\r\n#include \"QuartusPinImportPlugin.h\"\r\n#include \"QuartusPinSyntax.h\"\r\n\r\n#include <KactusAPI/include/ImportColors.h>\r\n\r\n#include <IPXACTmodels/Component/Component.h>\r\n#include <IPXACTmodels/Component/Port.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: QuartusPinImportPlugin::QuartusPinImportPlugin()\r\n//-----------------------------------------------------------------------------\r\nQuartusPinImportPlugin::QuartusPinImportPlugin(): highlighter_(0)\r\n{\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: QuartusPinImportPlugin::~QuartusPinImportPlugin()\r\n//-----------------------------------------------------------------------------\r\nQuartusPinImportPlugin::~QuartusPinImportPlugin()\r\n{\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: QuartusPinImportPlugin::getName()\r\n//-----------------------------------------------------------------------------\r\nQString QuartusPinImportPlugin::getName() const\r\n{\r\n    return tr(\"Quartus II Pin Import\");\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: QuartusPinImportPlugin::getVersion()\r\n//-----------------------------------------------------------------------------\r\nQString QuartusPinImportPlugin::getVersion() const\r\n{\r\n    return tr(\"1.1\");\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: QuartusPinImportPlugin::getDescription()\r\n//-----------------------------------------------------------------------------\r\nQString QuartusPinImportPlugin::getDescription() const\r\n{\r\n    return tr(\"Imports ports from Quartus pin file.\");\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: QuartusPinImportPlugin::getVendor()\r\n//-----------------------------------------------------------------------------\r\nQString QuartusPinImportPlugin::getVendor() const\r\n{\r\n    return tr(\"TUT\");\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: QuartusPinImportPlugin::getLicense()\r\n//-----------------------------------------------------------------------------\r\nQString QuartusPinImportPlugin::getLicense() const\r\n{\r\n    return tr(\"GPL2\");\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: QuartusPinImportPlugin::getLicenseHolder()\r\n//-----------------------------------------------------------------------------\r\nQString QuartusPinImportPlugin::getLicenseHolder() const\r\n{\r\n    return tr(\"Public\");\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: QuartusPinImportPlugin::getSettingsWidget()\r\n//-----------------------------------------------------------------------------\r\nQWidget* QuartusPinImportPlugin::getSettingsWidget()\r\n{\r\n    return nullptr;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: QuartusPinImportPlugin::getProgramRequirements()\r\n//-----------------------------------------------------------------------------\r\nQList<IPlugin::ExternalProgramRequirement> QuartusPinImportPlugin::getProgramRequirements()\r\n{\r\n    return QList<IPlugin::ExternalProgramRequirement>();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: QuartusPinImportPlugin::setHighlighter()\r\n//-----------------------------------------------------------------------------\r\nvoid QuartusPinImportPlugin::setHighlighter(Highlighter* highlighter)\r\n{\r\n    highlighter_ = highlighter;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: QuartusPinImportPlugin::getSupportedFileTypes()\r\n//-----------------------------------------------------------------------------\r\nQStringList QuartusPinImportPlugin::getSupportedFileTypes() const\r\n{\r\n    return QStringList(\"quartusPinFile\");\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: QuartusPinImportPlugin::getCompatibilityWarnings()\r\n//-----------------------------------------------------------------------------\r\nQString QuartusPinImportPlugin::getCompatibilityWarnings() const\r\n{\r\n    return QString();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: QuartusPinImportPlugin::getFileComponents()\r\n//-----------------------------------------------------------------------------\r\nQStringList QuartusPinImportPlugin::getFileComponents(QString const& /*input*/) const\r\n{\r\n    return QStringList();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: QuartusPinImportPlugin::getComponentName()\r\n//-----------------------------------------------------------------------------\r\n//     virtual QStringList getComponentNames(QStringList const& fileComponents) const = 0;\r\nQString QuartusPinImportPlugin::getComponentName(QString const& /*componentDeclaration*/) const\r\n{\r\n    return QString();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: QuartusPinImportPlugin::import()\r\n//-----------------------------------------------------------------------------\r\nvoid QuartusPinImportPlugin::import(QString const& input, QString const& /*componentDeclaration*/,\r\n    QSharedPointer<Component> targetComponent)\r\n{\r\n    if (highlighter_)\r\n    {\r\n        highlighter_->applyFontColor(input, QColor(\"gray\"));\r\n    }\r\n\r\n    //! The existing ports are changed to phantom in order to keep the component error-free.\r\n    //! These ports can then be deleted later.\r\n    foreach (QSharedPointer<Port> existingPort, *targetComponent->getPorts())\r\n    {\r\n        existingPort->setDirection(DirectionTypes::DIRECTION_PHANTOM);\r\n    }\r\n\r\n    foreach (QString line, input.split(QRegularExpression(\"(\\\\r\\\\n?|\\\\n\\\\r?)\")))\r\n    {\r\n        if (QuartusPinSyntax::pinDefinition.match(line).hasMatch())\r\n        {\r\n            createPort(line, targetComponent);\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: QuartusPinImportPlugin::createPort()\r\n//-----------------------------------------------------------------------------\r\nvoid QuartusPinImportPlugin::createPort(QString const& line, QSharedPointer<Component> targetComponent)\r\n{\r\n    if (highlighter_)\r\n    {\r\n        highlighter_->applyFontColor(line, Qt::black);\r\n        highlighter_->applyHighlight(line, ImportColors::PORT);\r\n    }\r\n\r\n    QRegularExpressionMatch lineMatch = QuartusPinSyntax::pinDefinition.match(line);\r\n    \r\n    QString portName = lineMatch.captured(QuartusPinSyntax::LOCATION);\r\n\r\n    QString direction = lineMatch.captured(QuartusPinSyntax::DIRECTION);\r\n    DirectionTypes::Direction portDirection = parseDirection(direction);\r\n\r\n    QString description = lineMatch.captured(QuartusPinSyntax::PINUSAGE);\r\n\r\n    QSharedPointer<Port> port = targetComponent->getPort(portName);\r\n    if (port.isNull())\r\n    {\r\n        QSharedPointer<Wire> portWire(new Wire());\r\n        portWire->setDirection(DirectionTypes::DIRECTION_PHANTOM);\r\n\r\n        port = QSharedPointer<Port>(new Port(portName));\r\n        port->setWire(portWire);\r\n\r\n        targetComponent->getPorts()->append(port);\r\n    }\r\n\r\n    port->setDirection(portDirection);\r\n    port->setDescription(description);\r\n    port->setPortSize(1);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: QuartusPinImportPlugin::parseDirection()\r\n//-----------------------------------------------------------------------------\r\nDirectionTypes::Direction QuartusPinImportPlugin::parseDirection(QString const& direction)\r\n{\r\n    if (QRegularExpression(\"input\", QRegularExpression::CaseInsensitiveOption).match(direction).hasMatch())\r\n    {\r\n        return DirectionTypes::IN;\r\n    }\r\n    else if (QRegularExpression(\"output\", QRegularExpression::CaseInsensitiveOption).match(direction).hasMatch())\r\n    {\r\n        return DirectionTypes::OUT;\r\n    }\r\n    else if (QRegularExpression(\"bidir|power|gnd\",\r\n        QRegularExpression::CaseInsensitiveOption).match(direction).hasMatch())\r\n    {\r\n        return DirectionTypes::INOUT;\r\n    }\r\n    else\r\n    {\r\n        return DirectionTypes::DIRECTION_PHANTOM;\r\n    }\r\n}\r\n"
  },
  {
    "path": "Plugins/QuartusPinImportPlugin/QuartusPinImportPlugin.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: QuartusPinImportPlugin.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Esko Pekkarinen\r\n// Date: 19.11.2013\r\n//\r\n// Description:\r\n// Kactus2 plugin for Quartus II pin import.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef QUARTUSPINIMPORTPLUGIN_H\r\n#define QUARTUSPINIMPORTPLUGIN_H\r\n\r\n#include \"QuartusPinImportPlugin_global.h\"\r\n\r\n#include <KactusAPI/include/IPlugin.h>\r\n#include <KactusAPI/include/ImportPlugin.h>\r\n#include <KactusAPI/include/HighlightSource.h>\r\n\r\n#include <IPXACTmodels/common/DirectionTypes.h>\r\n\r\nclass Component;\r\nclass Highlighter;\r\n//-----------------------------------------------------------------------------\r\n// Plugin for importing component ports from Quartus II pin file.\r\n//-----------------------------------------------------------------------------\r\nclass QUARTUSPINIMPORTPLUGIN_EXPORT QuartusPinImportPlugin : public QObject, \r\n    public ImportPlugin, public HighlightSource\r\n{\r\n\r\n    Q_OBJECT\r\n    Q_PLUGIN_METADATA(IID \"kactus2.plugins.quartuspinimportplugin\" FILE \"quartuspinimportplugin.json\")\r\n    Q_INTERFACES(IPlugin)\r\n    Q_INTERFACES(ImportPlugin)\r\n\r\npublic:\r\n    //! The constructor.\r\n    QuartusPinImportPlugin();\r\n\r\n    //! The destructor.\r\n    ~QuartusPinImportPlugin();\r\n\r\n    //! Returns the name of the plugin.\r\n    virtual QString getName() const;\r\n\r\n\t//! Returns the version of the plugin.\r\n    virtual QString getVersion() const;\r\n\r\n\t//! Returns the description of the plugin.\r\n    virtual QString getDescription() const;\r\n\r\n    /*!\r\n     *  Returns the vendor of the plugin.\r\n     */\r\n    virtual QString getVendor() const;\r\n\r\n    /*!\r\n     *  Returns the license of the plugin.\r\n     */\r\n    virtual QString getLicense() const;\r\n\r\n    /*!\r\n     *  Returns the holder of the license of the plugin.\r\n     */\r\n    virtual QString getLicenseHolder() const;\r\n\r\n\t//! Returns the icon for the generator.\r\n    /*!\r\n     *  Returns the settings widget.\r\n     */\r\n    virtual QWidget* getSettingsWidget();\r\n\r\n    /*!\r\n     *  This is used to access the settings modified by function getSettingsWidget().\r\n     */\r\n    virtual PluginSettingsModel* getSettingsModel(){return NULL;}\r\n\r\n    //! Returns the external program requirements of the plugin.\r\n    virtual QList<IPlugin::ExternalProgramRequirement> getProgramRequirements();\r\n        \r\n    /*!\r\n     *  Sets the given highlighter to be used by the plugin.\r\n     *\r\n     *    @param [in] highlighter   The highlighter to use.          \r\n     */\r\n    virtual void setHighlighter(Highlighter* highlighter);\r\n\r\n    /*!\r\n     *  Returns the supported import file types.\r\n     *\r\n     *    @return The file types the import plugin supports.\r\n     */\r\n    virtual QStringList getSupportedFileTypes() const;\r\n    \r\n    /*!\r\n     *  Gets any compatibility warnings for the plugin.\r\n     *\r\n     *    @return The warning text.\r\n     */\r\n    virtual QString getCompatibilityWarnings() const;\r\n    \r\n    /*!\r\n     *  Get component declarations from the selected input file.\r\n     *\r\n     *    @param [in] input   The selected input file.\r\n     *\r\n     *    @return List of component declarations found in the selected input.\r\n     */\r\n    virtual QStringList getFileComponents(QString const& input) const override final;\r\n\r\n    /*!\r\n     *  Get the name of the selected component declaration.\r\n     *\r\n     *    @param [in] componentDeclaration    The selected component declaration.\r\n     *\r\n     *    @return Name of the selected component declaration.\r\n     */\r\n    virtual QString getComponentName(QString const& componentDeclaration) const override final;\r\n\r\n    /*!\r\n     *  Runs the import by parsing the given input and applying the parsed elements to the given component.\r\n     *\r\n     *    @param [in] input                   The input text to parse.\r\n     *    @param [in] componentDeclaration    Declaration of the selected component.\r\n     *    @param [in] targetComponent         The component to apply all imported changes to.\r\n     */\r\n    virtual void import(QString const& input, QString const& componentDeclaration,\r\n        QSharedPointer<Component> targetComponent);\r\n\r\nprivate:\r\n\r\n    //! No copying\r\n    QuartusPinImportPlugin(const QuartusPinImportPlugin& other);\r\n\r\n    //! No assignment\r\n    QuartusPinImportPlugin& operator=(const QuartusPinImportPlugin& other);\r\n\r\n    /*!\r\n     *  Creates a port in the component from the given line in the pin file.\r\n     *\r\n     *    @param [in] line                The line to parse as port.\r\n     *    @param [in] targetComponent     The component to add the port into.\r\n     */\r\n    void createPort(QString const& line, QSharedPointer<Component> targetComponent);\r\n\r\n    /*!\r\n     *  Parses pin direction to IP-XACT port direction.\r\n     *\r\n     *    @param [in] direction   The direction to parse.\r\n     *\r\n     *    @return The port direction.\r\n     */\r\n    DirectionTypes::Direction parseDirection(QString const& direction);\r\n\r\n    //! The highlighter to use.\r\n    Highlighter* highlighter_;\r\n};\r\n\r\n#endif // QUARTUSPINIMPORTPLUGIN_H\r\n"
  },
  {
    "path": "Plugins/QuartusPinImportPlugin/QuartusPinImportPlugin.pri",
    "content": "# ----------------------------------------------------\r\n# This file is generated by the Qt Visual Studio Add-in.\r\n# ------------------------------------------------------\r\n\r\nHEADERS += ./QuartusPinImportPlugin_global.h \\\r\n    ./QuartusPinSyntax.h \\\r\n    ./QuartusPinImportPlugin.h\r\n\r\nSOURCES += ./QuartusPinImportPlugin.cpp\r\n"
  },
  {
    "path": "Plugins/QuartusPinImportPlugin/QuartusPinImportPlugin.pro",
    "content": "# ----------------------------------------------------\r\n# This file is generated by the Qt Visual Studio Add-in.\r\n# ------------------------------------------------------\r\n\r\nTEMPLATE = lib\r\n\r\nQT += core xml widgets gui\r\nCONFIG += c++11 plugin\r\nDEFINES += QUARTUSPINIMPORTPLUGIN_LIB\r\n\r\nINCLUDEPATH += ./GeneratedFiles \\\r\n    . \\\r\n    ./../..\r\n\r\nCONFIG(debug, debug|release) {\r\n    # debug mode\r\n    LIBS += \\\r\n        -L../../executable -lIPXACTmodelsd\r\n\r\n    MOC_DIR += ./GeneratedFiles/Debug\r\n    OBJECTS_DIR += Debug\r\n    TARGET = QuartusPinImportPlugind\r\n\r\n} else {\r\n    # release mode \r\n    LIBS += \\\r\n        -L../../executable -lIPXACTmodels\r\n    \r\n    MOC_DIR += ./GeneratedFiles/Release\r\n    OBJECTS_DIR += Release\r\n    TARGET = QuartusPinImportPlugin\r\n}\r\n\r\nDESTDIR = ../../executable/Plugins\r\n\r\nDEPENDPATH += .\r\nOBJECTS_DIR += release\r\nUI_DIR += ./GeneratedFiles\r\nRCC_DIR += ./GeneratedFiles\r\n\r\ninclude(QuartusPinImportPlugin.pri)\r\n\r\ntarget.path = $$plugin_path\r\nINSTALLS += target\r\nPadsPartGeneratorPadsPartGenerator\r\n"
  },
  {
    "path": "Plugins/QuartusPinImportPlugin/QuartusPinImportPlugin.vcxproj",
    "content": "﻿<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n<Project DefaultTargets=\"Build\" ToolsVersion=\"15.0\" xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">\r\n  <ItemGroup Label=\"ProjectConfigurations\">\r\n    <ProjectConfiguration Include=\"Debug|x64\">\r\n      <Configuration>Debug</Configuration>\r\n      <Platform>x64</Platform>\r\n    </ProjectConfiguration>\r\n    <ProjectConfiguration Include=\"Release|x64\">\r\n      <Configuration>Release</Configuration>\r\n      <Platform>x64</Platform>\r\n    </ProjectConfiguration>\r\n  </ItemGroup>\r\n  <ItemGroup>\r\n    <ClCompile Include=\"QuartusPinImportPlugin.cpp\" />\r\n  </ItemGroup>\r\n  <ItemGroup>\r\n    <QtMoc Include=\"QuartusPinImportPlugin.h\">\r\n    </QtMoc>\r\n    <ClInclude Include=\"QuartusPinImportPlugin_global.h\" />\r\n    <ClInclude Include=\"QuartusPinSyntax.h\" />\r\n  </ItemGroup>\r\n  <ItemGroup>\r\n    <None Include=\"quartuspinimportplugin.json\" />\r\n  </ItemGroup>\r\n  <PropertyGroup Label=\"Globals\">\r\n    <ProjectGuid>{C0DBF909-F12F-473F-8AC3-2248ABA68B92}</ProjectGuid>\r\n    <Keyword>QtVS_v304</Keyword>\r\n    <WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>\r\n    <QtMsBuild Condition=\"'$(QtMsBuild)'=='' or !Exists('$(QtMsBuild)\\qt.targets')\">$(MSBuildProjectDirectory)\\QtMsBuild</QtMsBuild>\r\n  </PropertyGroup>\r\n  <Import Project=\"$(VCTargetsPath)\\Microsoft.Cpp.Default.props\" />\r\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\" Label=\"Configuration\">\r\n    <ConfigurationType>DynamicLibrary</ConfigurationType>\r\n    <PlatformToolset>v143</PlatformToolset>\r\n  </PropertyGroup>\r\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\" Label=\"Configuration\">\r\n    <ConfigurationType>DynamicLibrary</ConfigurationType>\r\n    <PlatformToolset>v143</PlatformToolset>\r\n  </PropertyGroup>\r\n  <Import Project=\"$(VCTargetsPath)\\Microsoft.Cpp.props\" />\r\n  <Target Name=\"QtMsBuildNotFound\" BeforeTargets=\"CustomBuild;ClCompile\" Condition=\"!Exists('$(QtMsBuild)\\qt.targets') or !Exists('$(QtMsBuild)\\qt.props')\">\r\n    <Message Importance=\"High\" Text=\"QtMsBuild: could not locate qt.targets, qt.props; project may not build correctly.\" />\r\n  </Target>\r\n  <ImportGroup Label=\"ExtensionSettings\">\r\n  </ImportGroup>\r\n  <ImportGroup Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\" Label=\"PropertySheets\">\r\n    <Import Project=\"$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props\" Condition=\"exists('$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props')\" Label=\"LocalAppDataPlatform\" />\r\n  </ImportGroup>\r\n  <ImportGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\" Label=\"PropertySheets\">\r\n    <Import Project=\"$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props\" Condition=\"exists('$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props')\" Label=\"LocalAppDataPlatform\" />\r\n  </ImportGroup>\r\n  <PropertyGroup Label=\"UserMacros\" />\r\n  <ImportGroup Condition=\"Exists('$(QtMsBuild)\\qt_defaults.props')\">\r\n    <Import Project=\"$(QtMsBuild)\\qt_defaults.props\" />\r\n  </ImportGroup>\r\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n    <OutDir>$(SolutionDir)executable\\Plugins\\</OutDir>\r\n    <IntDir>$(ProjectDir)\\$(Configuration)\\</IntDir>\r\n  </PropertyGroup>\r\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n    <OutDir>$(SolutionDir)executable\\Plugins\\</OutDir>\r\n    <IntDir>$(ProjectDir)\\$(Configuration)\\</IntDir>\r\n  </PropertyGroup>\r\n  <PropertyGroup Label=\"QtSettings\" Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n    <QtInstall>6.2.4</QtInstall>\r\n    <QtModules>core;gui;widgets;printsupport;xml</QtModules>\r\n  </PropertyGroup>\r\n  <PropertyGroup Label=\"QtSettings\" Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n    <QtInstall>6.2.4</QtInstall>\r\n    <QtModules>core;gui;widgets;printsupport;xml</QtModules>\r\n  </PropertyGroup>\r\n  <ImportGroup Condition=\"Exists('$(QtMsBuild)\\qt.props')\">\r\n    <Import Project=\"$(QtMsBuild)\\qt.props\" />\r\n  </ImportGroup>\r\n  <PropertyGroup>\r\n    <_ProjectFileVersion>10.0.40219.1</_ProjectFileVersion>\r\n  </PropertyGroup>\r\n  <ItemDefinitionGroup Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n    <ClCompile>\r\n      <PreprocessorDefinitions>QUARTUSPINIMPORTPLUGIN_LIB;UNICODE;WIN32;WIN64;%(PreprocessorDefinitions)</PreprocessorDefinitions>\r\n      <AdditionalIncludeDirectories>.\\GeneratedFiles\\$(ConfigurationName);.\\GeneratedFiles;.\\..\\..;.;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\r\n      <Optimization>Disabled</Optimization>\r\n      <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>\r\n      <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>\r\n      <TreatWChar_tAsBuiltInType>true</TreatWChar_tAsBuiltInType>\r\n      <MultiProcessorCompilation>true</MultiProcessorCompilation>\r\n      <LanguageStandard>stdcpp17</LanguageStandard>\r\n      <AdditionalOptions>/Zc:__cplusplus %(AdditionalOptions)</AdditionalOptions>\r\n    </ClCompile>\r\n    <Link>\r\n      <SubSystem>Windows</SubSystem>\r\n      <OutputFile>$(OutDir)$(ProjectName).dll</OutputFile>\r\n      <AdditionalLibraryDirectories>..\\..\\executable;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>\r\n      <GenerateDebugInformation>true</GenerateDebugInformation>\r\n      <AdditionalDependencies>IPXACTmodelsd.lib;%(AdditionalDependencies)</AdditionalDependencies>\r\n      <ShowProgress>NotSet</ShowProgress>\r\n      <TargetMachine>MachineX64</TargetMachine>\r\n      <AdditionalOptions> /SUBSYSTEM:WINDOWS</AdditionalOptions>\r\n    </Link>\r\n    <QtMoc>\r\n      <ExecutionDescription>Moc'ing %(Identity)...</ExecutionDescription>\r\n      <DynamicSource>output</DynamicSource>\r\n      <QtMocDir>.\\GeneratedFiles\\$(ConfigurationName)</QtMocDir>\r\n      <QtMocFileName>moc_%(Filename).cpp</QtMocFileName>\r\n    </QtMoc>\r\n  </ItemDefinitionGroup>\r\n  <ItemDefinitionGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n    <ClCompile>\r\n      <PreprocessorDefinitions>NDEBUG;QT_NO_DEBUG;QUARTUSPINIMPORTPLUGIN_LIB;UNICODE;WIN32;WIN64;%(PreprocessorDefinitions)</PreprocessorDefinitions>\r\n      <AdditionalIncludeDirectories>.\\GeneratedFiles\\$(ConfigurationName);.\\GeneratedFiles;.;.\\..\\..;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\r\n      <DebugInformationFormat>\r\n      </DebugInformationFormat>\r\n      <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>\r\n      <TreatWChar_tAsBuiltInType>true</TreatWChar_tAsBuiltInType>\r\n      <MultiProcessorCompilation>true</MultiProcessorCompilation>\r\n      <AdditionalOptions>/Zc:__cplusplus %(AdditionalOptions)</AdditionalOptions>\r\n      <LanguageStandard>stdcpp17</LanguageStandard>\r\n    </ClCompile>\r\n    <Link>\r\n      <SubSystem>Windows</SubSystem>\r\n      <OutputFile>$(OutDir)$(ProjectName).dll</OutputFile>\r\n      <AdditionalLibraryDirectories>..\\..\\executable;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>\r\n      <GenerateDebugInformation>false</GenerateDebugInformation>\r\n      <AdditionalDependencies>IPXACTmodels.lib;%(AdditionalDependencies)</AdditionalDependencies>\r\n      <TargetMachine>MachineX64</TargetMachine>\r\n      <AdditionalOptions> /SUBSYSTEM:WINDOWS</AdditionalOptions>\r\n    </Link>\r\n    <QtMoc>\r\n      <ExecutionDescription>Moc'ing %(Identity)...</ExecutionDescription>\r\n      <DynamicSource>output</DynamicSource>\r\n      <QtMocDir>.\\GeneratedFiles\\$(ConfigurationName)</QtMocDir>\r\n      <QtMocFileName>moc_%(Filename).cpp</QtMocFileName>\r\n    </QtMoc>\r\n  </ItemDefinitionGroup>\r\n  <Import Project=\"$(VCTargetsPath)\\Microsoft.Cpp.targets\" />\r\n  <ImportGroup Condition=\"Exists('$(QtMsBuild)\\qt.targets')\">\r\n    <Import Project=\"$(QtMsBuild)\\qt.targets\" />\r\n  </ImportGroup>\r\n  <ImportGroup Label=\"ExtensionTargets\">\r\n  </ImportGroup>\r\n  <ProjectExtensions>\r\n    <VisualStudio>\r\n      <UserProperties />\r\n    </VisualStudio>\r\n  </ProjectExtensions>\r\n</Project>"
  },
  {
    "path": "Plugins/QuartusPinImportPlugin/QuartusPinImportPlugin.vcxproj.filters",
    "content": "﻿<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n<Project ToolsVersion=\"4.0\" xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">\r\n  <ItemGroup>\r\n    <Filter Include=\"Source Files\">\r\n      <UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>\r\n      <Extensions>cpp;cxx;c;def</Extensions>\r\n    </Filter>\r\n    <Filter Include=\"Header Files\">\r\n      <UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>\r\n      <Extensions>h</Extensions>\r\n    </Filter>\r\n    <Filter Include=\"Generated Files\">\r\n      <UniqueIdentifier>{71ED8ED8-ACB9-4CE9-BBE1-E00B30144E11}</UniqueIdentifier>\r\n      <Extensions>moc;h;cpp</Extensions>\r\n      <SourceControlFiles>False</SourceControlFiles>\r\n    </Filter>\r\n    <Filter Include=\"Generated Files\\Debug\">\r\n      <UniqueIdentifier>{ccd28c1b-dca6-494e-a1e7-1b2b42a84fff}</UniqueIdentifier>\r\n      <Extensions>cpp;moc</Extensions>\r\n      <SourceControlFiles>False</SourceControlFiles>\r\n    </Filter>\r\n    <Filter Include=\"Generated Files\\Release\">\r\n      <UniqueIdentifier>{7073ed79-7b5a-4169-a0b4-df3106505539}</UniqueIdentifier>\r\n      <Extensions>cpp;moc</Extensions>\r\n      <SourceControlFiles>False</SourceControlFiles>\r\n    </Filter>\r\n  </ItemGroup>\r\n  <ItemGroup>\r\n    \r\n    \r\n    <ClCompile Include=\"QuartusPinImportPlugin.cpp\">\r\n      <Filter>Source Files</Filter>\r\n    </ClCompile>\r\n  </ItemGroup>\r\n  <ItemGroup>\r\n    <QtMoc Include=\"QuartusPinImportPlugin.h\">\r\n      <Filter>Header Files</Filter>\r\n    </QtMoc>\r\n  </ItemGroup>\r\n  <ItemGroup>\r\n    <ClInclude Include=\"QuartusPinSyntax.h\">\r\n      <Filter>Header Files</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"QuartusPinImportPlugin_global.h\">\r\n      <Filter>Header Files</Filter>\r\n    </ClInclude>\r\n  </ItemGroup>\r\n  <ItemGroup>\r\n    <None Include=\"quartuspinimportplugin.json\" />\r\n  </ItemGroup>\r\n</Project>"
  },
  {
    "path": "Plugins/QuartusPinImportPlugin/QuartusPinImportPlugin_global.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: quartuspinimportplugin_global.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Esko Pekkarinen\r\n// Date: 21.11.2013\r\n//\r\n// Description:\r\n// <Short description of the class/file contents>\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef QUARTUSPINIMPORTPLUGIN_GLOBAL_H\r\n#define QUARTUSPINIMPORTPLUGIN_GLOBAL_H\r\n\r\n#include <QtCore/qglobal.h>\r\n\r\n#ifdef QUARTUSPINIMPORTPLUGIN_LIB\r\n# define QUARTUSPINIMPORTPLUGIN_EXPORT Q_DECL_EXPORT\r\n#else\r\n# define QUARTUSPINIMPORTPLUGIN_EXPORT Q_DECL_IMPORT\r\n#endif\r\n\r\n#endif // QUARTUSPINIMPORTPLUGIN_GLOBAL_H\r\n"
  },
  {
    "path": "Plugins/QuartusPinImportPlugin/QuartusPinSyntax.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: QuartusPinSyntax.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Esko Pekkarinen\r\n// Date: 19.11.2013\r\n//\r\n// Description:\r\n// Syntax description for Quartus .pin-files.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef QUARTUSPINSYNTAX_H\r\n#define QUARTUSPINSYNTAX_H\r\n\r\n#include <QRegularExpression>\r\n\r\nnamespace QuartusPinSyntax\r\n{\r\n    // Delimiter for properties.\r\n    const char DELIMITER = ':';\r\n\r\n    //! Whitespace without line end.\r\n    const QString SPACE = \"[ \\\\t]*\";    \r\n\r\n    // Each pin assignment is described on its own line using the following syntax:\r\n    // Pin Name/Usage : Location : Dir. : I/O Standard : Voltage : I/O Bank  : User Assignment    \r\n    const QString pinName = \"[^ :]+(?: / [^ :]+)*\";\r\n    const QString location = \"\\\\w+\";\r\n    const QString direction = \"input|output|bidir|power|gnd\";\r\n    const QString ioStandard = \"[^ :]+(?:\" + SPACE + \"[^ :]+)*\";\r\n    const QString voltage = \"\\\\d+\\\\.\\\\d+\" + SPACE +\"V\";\r\n    const QString ioBank = \"\\\\w+\";\r\n    const QString userAssignment = \"Y|N\";\r\n\r\n    // Pin definition line.\r\n    const QRegularExpression pinDefinition = QRegularExpression(\"\\\\b(\" + pinName + \")\" + SPACE + DELIMITER + SPACE +        \r\n                                   \"(\" + location + \")\" + SPACE + DELIMITER + SPACE +\r\n                                   \"(\" + direction + \")?\" + SPACE + DELIMITER + SPACE +\r\n                                   \"(\" + ioStandard + \")?\" + SPACE + DELIMITER + SPACE +\r\n                                   \"(\" + voltage + \")?\" + SPACE + DELIMITER + SPACE +\r\n                                   \"(\" + ioBank + \")?\" + SPACE + DELIMITER + SPACE +\r\n                                   \"(\" + userAssignment + \")?(?=\\\\s*$)\", \r\n                                   QRegularExpression::CaseInsensitiveOption);\r\n\r\n    // Property capture positions.\r\n    enum propertyPos\r\n    {\r\n        PINUSAGE = 1,\r\n        LOCATION,\r\n        DIRECTION,\r\n        IOSTANDARD,\r\n        VOLTAGE,\r\n        IOBANK,\r\n        USERASSIGNMENT,\r\n        PROPERTY_COUNT\r\n    };\r\n}\r\n\r\n#endif // QUARTUSPINSYNTAX_H"
  },
  {
    "path": "Plugins/QuartusPinImportPlugin/quartuspinimportplugin.json",
    "content": "{\r\n\t\"Keys\": [ \"Quartus pin import\" ]\r\n}\r\n"
  },
  {
    "path": "Plugins/QuartusProjectGenerator/QuartusGenerator.cpp",
    "content": "/* \r\n *\r\n *  Created on: 24.11.2010\r\n *      Author: Antti Kamppi\r\n */\r\n\r\n#include \"QuartusGenerator.h\"\r\n\r\n#include <IPXACTmodels/Design/Design.h>\r\n#include <IPXACTmodels/DesignConfiguration/DesignConfiguration.h>\r\n\r\n#include <IPXACTmodels/Component/Component.h>\r\n#include <IPXACTmodels/Component/FileSet.h>\r\n#include <IPXACTmodels/Component/View.h>\r\n#include <IPXACTmodels/Component/ComponentInstantiation.h>\r\n#include <IPXACTmodels/Component/DesignConfigurationInstantiation.h>\r\n#include <IPXACTmodels/Component/DesignInstantiation.h>\r\n\r\n#include <IPXACTmodels/utilities/Search.h>\r\n#include <IPXACTmodels/utilities/ComponentSearch.h>\r\n\r\n#include <KactusAPI/include/IPluginUtility.h>\r\n#include <KactusAPI/include/LibraryInterface.h>\r\n\r\n#include <QDateTime>\r\n#include <QDir>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: QuartusGenerator::QuartusGenerator()\r\n//-----------------------------------------------------------------------------\r\nQuartusGenerator::QuartusGenerator(IPluginUtility* utility) :\r\n    utility_(utility),\r\n    files_(),\r\n    assignments_(),\r\n    handler_(utility->getLibraryInterface()),\r\n    timeReplacement_()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: QuartusGenerator::readExistingPinMap()\r\n//-----------------------------------------------------------------------------\r\nvoid QuartusGenerator::readExistingPinMap(QSharedPointer<Component> component)\r\n{\r\n\tassignments_.clear();\r\n\r\n\t// find the file wrapper that holds the assignments\r\n    QSharedPointer<File> fileWrapper = getQuartusPinMap(component);\r\n    if (fileWrapper.isNull())\r\n    {\r\n\t\tutility_->printInfo(tr(\"No pin map found on the component\"));\r\n\t\treturn;\r\n\t}\r\n\r\n\tQString pinmapPath = General::getAbsolutePath(handler_->getPath(component->getVlnv()), fileWrapper->name());\t\r\n\tQFileInfo pinmapInfo(pinmapPath);\r\n\tif (!pinmapInfo.exists())\r\n    {\r\n\t\tutility_->printError(tr(\"The pin map file %1 was not found in file system.\").arg(pinmapPath));\r\n\t\treturn;\r\n\t}\r\n\r\n\tQFile mappingsFile(pinmapPath);\r\n\tif (!mappingsFile.open(QIODevice::ReadOnly))\r\n    {\r\n\t\tutility_->printError(tr(\"File %1 could not be opened for reading.\").arg(pinmapPath));\r\n\t\treturn;\r\n\t}\r\n\r\n\tQTextStream stream(&mappingsFile);\r\n    assignments_ = stream.readAll().split(QStringLiteral(\"\\n\"));\r\n\tmappingsFile.close();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: QuartusGenerator::parseFiles()\r\n//-----------------------------------------------------------------------------\r\nvoid QuartusGenerator::parseFiles(QSharedPointer<Component> component, QSharedPointer<View> view)\r\n{\r\n    Q_ASSERT_X(component, \"QuartusGenerator::parseFiles\", \"Null component-pointer given as parameter\");\r\n\r\n    if (!view)\r\n    {\r\n        utility_->printInfo(tr(\"Component %1 didn't contain an active view, adding all found RTL-files from \"\r\n            \"component file sets.\").arg(component->getVlnv().getName()));\r\n\r\n        parseAllFileSets(component);\r\n    }\r\n    else\r\n    {\r\n        utility_->printInfo(tr(\"Processing view %1 of component %2\").arg(view->name(), \r\n            component->getVlnv().toString()));\r\n\r\n        if (view->isHierarchical())\r\n        {\r\n            parseFilesFromHierarchicalView(view, component);\r\n        }\r\n        else\r\n        {\r\n            parseFilesFromFlatView(component, view);\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: QuartusGenerator::generateProject()\r\n//-----------------------------------------------------------------------------\r\nvoid QuartusGenerator::generateProject(QString const& outputPath, QString const& topEntity, \r\n    QString const& generatorInformation)\r\n{\r\n    // If the output dir doesn't exist then create it.\r\n    QDir outputDir(outputPath);\r\n    if (!outputDir.exists())\r\n    {\r\n        outputDir.mkpath(outputPath);\r\n    }\r\n\r\n    utility_->printInfo(tr(\"Writing Quartus project file.\"));\r\n    writeQuartusProjectFile(outputPath, topEntity, generatorInformation);\r\n\r\n    utility_->printInfo(tr(\"Writing Quartus settings file.\"));\r\n    writeQuartusSettingsFile(outputPath, topEntity, generatorInformation);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: QuartusGenerator::replaceTime()\r\n//-----------------------------------------------------------------------------\r\nvoid QuartusGenerator::replaceTime(QString const& newTime)\r\n{\r\n    timeReplacement_ = newTime;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: QuartusGenerator::getQuartusPinMap()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<File> QuartusGenerator::getQuartusPinMap(QSharedPointer<Component> component)\r\n{\r\n    QStringList pinTypes({ QStringLiteral(\"quartusPinmap\"), QStringLiteral(\"quartusPinFile\") });\r\n\r\n    for (QSharedPointer<FileSet> fileSet : *component->getFileSets())\r\n    {\r\n        for (QSharedPointer<File> currentFile : *fileSet->getFiles())\r\n        {\r\n            for (auto const& fileType : *currentFile->getFileTypes())\r\n            {\r\n                if (pinTypes.contains(fileType.type_))\r\n                {\r\n                    return currentFile;\r\n                }\r\n            }\r\n        }\r\n    }\r\n\r\n    return QSharedPointer<File>();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: QuartusGenerator::writeQuartusProjectFile()\r\n//-----------------------------------------------------------------------------\r\nvoid QuartusGenerator::writeQuartusProjectFile(QString const& outputPath, QString const& topEntity, \r\n    QString const& generatorInformation)\r\n{\r\n\t// Save previous working directory.\r\n\tQDir savedCurrentDir = QDir::current();\r\n\r\n    QFile* quartusProjectFile = createQuartusProjectFile(outputPath, topEntity, QStringLiteral(\".qpf\"));\r\n    if (quartusProjectFile->isOpen())\r\n    {\r\n        QTextStream stream(quartusProjectFile);\r\n\r\n        writeHeader(stream, generatorInformation);\r\n\r\n        // write project info.\r\n        stream << QStringLiteral(\"QUARTUS_VERSION = \\\"10.0\\\"\") << Qt::endl << Qt::endl;\r\n        stream << QStringLiteral(\"# Revisions\") << Qt::endl << Qt::endl;\r\n        stream << QStringLiteral(\"PROJECT_REVISION = \\\"\");\r\n        stream << topEntity;\r\n        stream << QStringLiteral(\"\\\"\") << Qt::endl;\r\n\r\n        quartusProjectFile->close();\r\n\r\n        utility_->printInfo(tr(\"Finished writing file %1.\").arg(quartusProjectFile->fileName()));\r\n    }\r\n\r\n    // Restore previous working directory.\r\n\tQDir::setCurrent(savedCurrentDir.path());\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: QuartusGenerator::createQuartusProjectFile()\r\n//-----------------------------------------------------------------------------\r\nQFile* QuartusGenerator::createQuartusProjectFile(QString const& outputPath, QString const& topEntity,\r\n    QString const& fileSuffix)\r\n{\r\n    QDir::setCurrent(outputPath);\r\n    \r\n    QString fileName = topEntity + fileSuffix;\r\n    QFile* quartusProjectFile = new QFile(fileName);\r\n\r\n    if (!quartusProjectFile->open(QIODevice::WriteOnly | QIODevice::Truncate))\r\n    {\r\n        QString message(tr(\"Can't open file %1 for writing\").arg(quartusProjectFile->fileName()));\r\n        utility_->printError(message);\r\n    }\r\n\r\n    return quartusProjectFile;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: QuartusGenerator::writeHeader()\r\n//-----------------------------------------------------------------------------\r\nvoid QuartusGenerator::writeHeader(QTextStream& stream, QString const& generatorInformation)\r\n{\r\n    QString currentTime = timeReplacement_;\r\n    if (currentTime.isEmpty())\r\n    {\r\n        currentTime = QDateTime::currentDateTime().toString(QStringLiteral(\"hh:mm:ss dd.MM.yyyy\"));\r\n    }\r\n\r\n    stream << \"# ----------------------------------------------------------- #\" << Qt::endl << Qt::endl;\r\n    stream << tr(\"# Quartus project generated by Kactus2\") << Qt::endl;\r\n    stream << tr(\"# Date created \") << currentTime << Qt::endl;\r\n    stream << tr(\"# This file was generated with \") << generatorInformation << Qt::endl << Qt::endl;\r\n    stream << \"# ----------------------------------------------------------- #\" << Qt::endl << Qt::endl;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: QuartusGenerator::writeQuartusSettingsFile()\r\n//-----------------------------------------------------------------------------\r\nvoid QuartusGenerator::writeQuartusSettingsFile(QString const& outputPath, QString const& topEntity,\r\n    QString const& generatorInformation)\r\n{\r\n    // Save previous working directory.\r\n\tQDir savedCurrentDir = QDir::current();\r\n\r\n    QFile* quartusSettingsFile = createQuartusProjectFile(outputPath, topEntity, QStringLiteral(\".qsf\"));\r\n    if (quartusSettingsFile->isOpen())\r\n    {\r\n        QTextStream stream(quartusSettingsFile);\r\n\r\n        writeHeader(stream, generatorInformation);\r\n\r\n        stream << \"set_global_assignment -name TOP_LEVEL_ENTITY \" << topEntity << Qt::endl;\r\n        stream << \"set_global_assignment -name ORIGINAL_QUARTUS_VERSION \\\"10.0 SP1\\\"\" << Qt::endl;\r\n\r\n        writeIncludedFiles(stream);\r\n        writePinAssignments(stream);\r\n\r\n        quartusSettingsFile->close();\r\n\r\n        utility_->printInfo(tr(\"Finished writing file %1\").arg(quartusSettingsFile->fileName()));\r\n    }\r\n\r\n    // Restore previous working directory.\r\n    QDir::setCurrent(savedCurrentDir.path());\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: QuartusGenerator::writeIncludedFiles()\r\n//-----------------------------------------------------------------------------\r\nvoid QuartusGenerator::writeIncludedFiles(QTextStream& stream)\r\n{\r\n    for (QString const& fileName : files_)\r\n    {\r\n        QString fileSuffix = QFileInfo(fileName).suffix();\r\n\r\n        if (fileSuffix.compare(QLatin1String(\"vhd\")) == 0 || fileSuffix.compare(QLatin1String(\"vhdl\")) == 0)\r\n        {\r\n            stream << \"set_global_assignment -name VHDL_FILE \" << fileName << Qt::endl;\r\n        }\r\n        else if (fileSuffix.compare(QLatin1String(\"v\")) == 0)\r\n        {\r\n            stream << \"set_global_assignment -name VERILOG_FILE \" << fileName << Qt::endl;\r\n        }\r\n        else if (fileSuffix.compare(QLatin1String(\"sv\")) == 0)\r\n        {\r\n            stream << \"set_global_assignment -name SYSTEMVERILOG_FILE \" << fileName << Qt::endl;\r\n        }\r\n        else if (fileSuffix.compare(QLatin1String(\"qip\")) == 0)\r\n        {\r\n            stream << \"set_global_assignment -name QIP_FILE \" << fileName << Qt::endl;\r\n        }\r\n        else if (fileSuffix.compare(QLatin1String(\"sdc\")) == 0)\r\n        {\r\n            stream << \"set_global_assignment -name SDC_FILE \" << fileName << Qt::endl;\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: QuartusGenerator::writePinAssignments()\r\n//-----------------------------------------------------------------------------\r\nvoid QuartusGenerator::writePinAssignments(QTextStream &stream)\r\n{\r\n    for (QString const& assignment : assignments_)\r\n    {\r\n        stream << assignment << Qt::endl;\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: QuartusGenerator::parseAllFileSets()\r\n//-----------------------------------------------------------------------------\r\nvoid QuartusGenerator::parseAllFileSets(QSharedPointer<Component> component)\r\n{\r\n    Q_ASSERT_X(component, \"ModelsimGenerator::parseAllFileSets\", \"Null component pointer given as parameter\");\r\n\r\n    QString basePath = handler_->getPath(component->getVlnv());\r\n    if (basePath.isEmpty())\r\n    {\r\n        utility_->printError(tr(\"Component %1was not found in library.\").arg(component->getVlnv().toString()));\r\n        return;\r\n    }\r\n\r\n    QString componentVLNV = component->getVlnv().toString();\r\n\r\n    // Parse all RTL files of the component.\r\n\tfor (QSharedPointer<FileSet> fileSet : *component->getFileSets())\r\n\t{\r\n\t\tfor (QSharedPointer<File> file : *fileSet->getFiles())\r\n\t\t{\r\n\t\t\tif (file->isRTLFile())\r\n\t\t\t{\r\n                parseSingleFile(file, basePath, componentVLNV);\r\n            }\r\n\t\t}\r\n\t}\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: QuartusGenerator::parseSingleFile()\r\n//-----------------------------------------------------------------------------\r\nvoid QuartusGenerator::parseSingleFile(QSharedPointer<File> targetFile, QString const& basePath,\r\n    QString const& componentVLNV)\r\n{\r\n    QString absolutePath = General::getAbsolutePath(basePath, targetFile->name());\r\n    if (absolutePath.isEmpty())\r\n    {\r\n        utility_->printError(tr(\"The file %1 was not found within %2\").arg(targetFile->getFileName(),\r\n            absolutePath));\r\n        return;\r\n    }\r\n\r\n    QFileInfo filePathInfo(absolutePath);\r\n    if (!filePathInfo.exists())\r\n    {\r\n        utility_->printError(tr(\"The file %1 needed by component %2 was not found in the file system.\").arg(\r\n            absolutePath, componentVLNV));\r\n        return;\r\n    }\r\n\r\n    if (files_.contains(absolutePath) == false)\r\n    {\r\n        files_.append(absolutePath);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: QuartusGenerator::parseFileSets()\r\n//-----------------------------------------------------------------------------\r\nvoid QuartusGenerator::parseFileSets(QSharedPointer<Component> component, QStringList const& fileSetNames)\r\n{\r\n    Q_ASSERT_X(component, \"ModelsimGenerator::parseFileSets\", \"Null component-pointer given as parameter\");\r\n\r\n    QString basePath = handler_->getPath(component->getVlnv());\r\n    if (basePath.isEmpty())\r\n    {\r\n        utility_->printError(tr(\"Component %1 was not found within library. Stopping generation.\").\r\n            arg(component->getVlnv().toString()));\r\n        return;\r\n    }\r\n\r\n    for (QString const& fileSetName : fileSetNames)\r\n    {\r\n        if (!component->hasFileSet(fileSetName))\r\n        {\r\n            utility_->printError(tr(\"Fileset %1 was not found within component %2.\").arg(fileSetName, \r\n                component->getVlnv().toString()));\r\n        }\r\n        else\r\n        {\r\n            for (QSharedPointer<File> file : *component->getFileSet(fileSetName)->getFiles())\r\n            {\r\n                parseSingleFile(file, basePath, component->getVlnv().toString());\r\n            }\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: QuartusGenerator::parseFilesFromHierarchicalView()\r\n//-----------------------------------------------------------------------------\r\nvoid QuartusGenerator::parseFilesFromHierarchicalView(QSharedPointer<View> view, QSharedPointer<Component> component)\r\n{\r\n    VLNV designVLNV = ComponentSearch::findDesignReference(component, handler_, view);\r\n    VLNV desConfVLNV = ComponentSearch::findDesignConfigurationReference(component, view);\r\n\r\n    QSharedPointer<const DesignConfiguration> designConf = handler_->getModelReadOnly<DesignConfiguration>(desConfVLNV);\r\n\r\n    if (!handler_->contains(designVLNV))\r\n    {\r\n        utility_->printError(tr(\"Design %1 was not found in library. Stopping generation.\")\r\n            .arg(designVLNV.toString()));\r\n        return;\r\n    }\r\n\r\n    QSharedPointer<const Design> design = handler_->getModelReadOnly<Design>(designVLNV);\r\n\r\n\treadDesign(design, designConf);\r\n\r\n    parseFilesFromFlatView(component, view);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: QuartusGenerator::readDesign()\r\n//-----------------------------------------------------------------------------\r\nvoid QuartusGenerator::readDesign(QSharedPointer<const Design> design, \r\n    QSharedPointer<const DesignConfiguration> desConf)\r\n{\r\n    Q_ASSERT_X(design, \"ModelsimGenerator::readDesign\", \"Null Design-pointer given as parameter\");\r\n\r\n    for (QSharedPointer<ComponentInstance> instance : *design->getComponentInstances())\r\n    {\r\n        VLNV vlnv = *instance->getComponentRef();\r\n\r\n        if (!handler_->contains(vlnv))\r\n        {\r\n            utility_->printError(tr(\"Component %1 was not found within library. Skipping.\").\r\n                arg(vlnv.toString()));\r\n            continue;\r\n        }\r\n\r\n        QSharedPointer<Component> component = handler_->getModel<Component>(vlnv);\r\n        if (component.isNull())\r\n        {\r\n            utility_->printError(tr(\"Referenced item %1 was not a component.\").arg(vlnv.toString()));\r\n            continue;\r\n        }\r\n\r\n        QSharedPointer<View> view;\r\n\r\n        if (desConf && desConf->hasActiveView(instance->getInstanceName()))\r\n        {\r\n            QMap<QString, QString> viewOverrides = desConf->getKactus2ViewOverrides();\r\n\r\n            QString viewName = viewOverrides.value(instance->getUuid(), \r\n                desConf->getActiveView(instance->getInstanceName()));\r\n\r\n            view = Search::findByName(viewName, *component->getViews());\r\n        }\r\n        // if design configuration is not used or view was not found\r\n        else\r\n        {\r\n            utility_->printInfo(tr(\"No active view selected for instance %1 of component %2.\").arg(\r\n                instance->getInstanceName(), vlnv.toString()));\r\n        }\r\n\r\n        parseFiles(component, view);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: QuartusGenerator::parseFilesFromFlatView()\r\n//-----------------------------------------------------------------------------\r\nvoid QuartusGenerator::parseFilesFromFlatView(QSharedPointer<Component> component, QSharedPointer<View> view)\r\n{\r\n    QStringList fileSets;\r\n\r\n    auto instance = Search::findByName(view->getComponentInstantiationRef(),\r\n        *component->getComponentInstantiations());\r\n\r\n    if (instance)\r\n    {\r\n        fileSets = instance->getFileSetReferenceStrings();\r\n    }\r\n\r\n    parseFileSets(component, fileSets);\r\n}\r\n"
  },
  {
    "path": "Plugins/QuartusProjectGenerator/QuartusGenerator.h",
    "content": "/* \r\n *\r\n *  Created on: 24.11.2010\r\n *      Author: Antti Kamppi\r\n */\r\n\r\n#ifndef QUARTUSGENERATOR_H\r\n#define QUARTUSGENERATOR_H\r\n\r\n#include <QTextStream>\r\n#include <QFile>\r\n\r\nclass Component;\r\nclass File;\r\nclass LibraryInterface;\r\nclass Design;\r\nclass DesignConfiguration;\r\nclass View;\r\nclass IPluginUtility;\r\n\r\n/*!  QuartusGenerator generates a Quartus project for the component.\r\n *\r\n * Generator creates two files:\r\n * - .qpf file which is the quartus project file\r\n * - .qsf file which contains list of needed files and possibly pin assignments\r\n *\tfor an FPGA board.\r\n *\r\n */\r\nclass QuartusGenerator: public QObject\r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\r\n\t/*! The constructor\r\n\t *\t \r\n\t *    @param [in] utility The Plugin utility, where to get libraries etc.\r\n\t *\r\n\t*/\r\n\texplicit QuartusGenerator(IPluginUtility* utility);\r\n\r\n\t//! The destructor\r\n\tvirtual ~QuartusGenerator() = default;\r\n\r\n    //! No copying\r\n    QuartusGenerator(const QuartusGenerator& other) = delete;\r\n\r\n    //! No assignment\r\n    QuartusGenerator& operator=(const QuartusGenerator& other) = delete;\r\n\r\n    /*! Read already saved pin mappings from file sets to store in the settings file later.\r\n    *\r\n    *    @param [in] component The component whose pin mappings to find.\r\n    */\r\n    void readExistingPinMap(QSharedPointer<Component> component);\r\n\r\n\t/*!\r\n\t *  Parse the files associated with the given view in the selected component.\r\n\t *\r\n\t *    @param [in] component   The selected component.\r\n\t *    @param [in] view\t\tThe view to parse file set references from.\r\n\t */\r\n\tvoid parseFiles(QSharedPointer<Component> component, QSharedPointer<View> view);\r\n\r\n  \r\n\t/*! Generate the Quartus project files (.qpf .qsf)\r\n\t *\r\n     *    @param [in] outputPath              The directory path, where the project files are generated.\r\n     *    @param [in] topEntity              The name of the topmost entity.\r\n     *    @param [in] generatorInformation    The generator information to write in the header.\r\n\t *\r\n\t */\r\n\tvoid generateProject(QString const& outputPath, QString const& topEntity,QString const& generatorInformation);\r\n\r\n    /*!\r\n     *  Replace the printed time with the given text.\r\n     *\r\n     *    @param [in] newTime     The replacement for the printed time.\r\n     */\r\n    void replaceTime(QString const& newTime);\r\n\r\nsignals:\r\n\r\n\t//! Send error message to user.\r\n\tvoid errorMessage(QString const& errorMessage);\r\n\r\n\t//! Send notification to user.\r\n\tvoid noticeMessage(QString const& noticeMessage);\r\n\r\nprivate:\r\n\r\n    /*!\r\n     *  Get the file containing a quartus pin map.\r\n     *\r\n     *    @param [in] component   The component where to search the file from.\r\n     *\r\n     *    @return The file that contains a quartus pin map. If no quartus pin map is found, returns a null.\r\n     */\r\n    QSharedPointer<File> getQuartusPinMap(QSharedPointer<Component> component);\r\n\r\n    /*! Writes the Quartus Project File into specified directory.\r\n    *\r\n    *    @param [in] outPutDir Path to the directory where the .qpf file is written to\r\n    */\r\n    void writeQuartusProjectFile(QString const& outputPath, QString const& topEntity, QString const& generatorInformation);\r\n    \r\n    /*!\r\n    *  Create a quartus file.\r\n    *\r\n    *    @param [in] outputDirectory     Path to the directory where the file is written to.\r\n    *    @param [in] topEntity           The name of the topmost entity for the file name.\r\n    *    @param [in] fileSuffix          The suffix for the file name.\r\n    *\r\n    *    @return Either a quartus project file or a quartus settings file, depending on the given suffix.\r\n    */\r\n    QFile* createQuartusProjectFile(QString const& outputPath, QString const& topEntity, QString const& fileSuffix);\r\n\r\n    /*! Writes the header info for the Quartus file.\r\n    *\r\n    *    @param [in] stream                   The QTextStream to write into.\r\n    *    @param [in] generatorInformation     The generator information to write in the header.\r\n    */\r\n    void writeHeader(QTextStream& stream, QString const& generatorInformation);\r\n\r\n    /*! Writes the Quartus Settings File into specified directory.\r\n    *\r\n    *    @param [in] outPutDir                Path to the directory where the .qsf file is written to.\r\n    *    @param [in] topEntity                The name of the topmost entity for the file name.\r\n    *    @param [in] generatorInformation     The generator information to write in the header.\r\n    */\r\n    void writeQuartusSettingsFile(QString const& outputPath, QString const& topEntity, QString const& generatorInformation);\r\n   \r\n    /*! Writes all the related files into the Quartus settings file.\r\n     *\r\n     *    @param [in] stream      The QTextStream to write into.\r\n     */\r\n    void writeIncludedFiles(QTextStream& stream);\r\n   \r\n    /*! Writes all the stored pin assignments into the Quartus settings file.\r\n     *\r\n     *    @param [in] stream      The QTextStream to write into.\r\n     */\r\n    void writePinAssignments(QTextStream& stream);\r\n\r\n    /*! Parse the component's file sets and add all vhdl- and verilog-files.\r\n    *\r\n    *    @param [in] component The component to search.\r\n    */\r\n    void parseAllFileSets(QSharedPointer<Component> component);\r\n\r\n    /*!\r\n     *  Parse a single file.\r\n     *\r\n     *    @param [in] targetFile      The selected file to parse.\r\n     *    @param [in] basePath        The path of the file.\r\n     *    @param [in] componentVLNV   The vlnv of the component in qstring format.\r\n     */\r\n    void parseSingleFile(QSharedPointer<File> targetFile, QString const& basePath, QString const& componentVLNV);\r\n\r\n    /*! Parse the given file sets and add their files to source files.\r\n    *\r\n    *    @param [in] component       The component that's files are wanted.\r\n    *    @param [in] fileSetNames     Names of the file sets to use.\r\n    */\r\n    void parseFileSets(QSharedPointer<Component> component, QStringList const& fileSetNames);\r\n\r\n    /*!\r\n     *  Parse the design / design configuration and the file sets of a hierarchical view of the selected component.\r\n     *\r\n     *    @param [in] view        The hierarchical view.\r\n     *    @param [in] component   The component of the hierarhical view.\r\n     */\r\n    void parseFilesFromHierarchicalView(QSharedPointer<View> view, QSharedPointer<Component> component);\r\n\r\n\t/*! Read the design and possibly design configuration and parse them.\r\n\t * \r\n\t * Design is read and component instances are parsed to get their files also.\r\n\t * \r\n\t *    @param [in] design  The design to parse.\r\n\t *    @param [in] desConf The design configuration to use\r\n\t *\r\n\t*/\r\n\tvoid readDesign(QSharedPointer<const Design> design, QSharedPointer<const DesignConfiguration> desConf);\r\n\r\n    /*! Parse the file sets in a given view and add their files to source files.\r\n    *\r\n    *    @param [in] component        The component that's files are wanted.\r\n    *    @param [in] view             The view whose filesets to search.\r\n    */\r\n    void parseFilesFromFlatView(QSharedPointer<Component> component, QSharedPointer<View> view);\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n\t//! The Plugin utility, where to get libraries etc.\r\n\tIPluginUtility* utility_;\r\n\r\n\t//! Contains the file paths of the needed files.\r\n\tQStringList files_;\r\n\r\n\t//! Contains the pin assignments retrieved from the IP-Xact metadata.\r\n\tQStringList assignments_;\r\n\r\n\t//! The instance managing the IP library.\r\n\tLibraryInterface* handler_;\r\n\r\n    //! Time replacement for the creation time. Used in tests.\r\n    QString timeReplacement_;\r\n};\r\n\r\n#endif /* QUARTUSGENERATOR_H */\r\n"
  },
  {
    "path": "Plugins/QuartusProjectGenerator/QuartusProjectGenerator.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: QuartusProjectGenerator.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 02.06.2015\r\n//\r\n// Description:\r\n// The plugin for generating quartus projects containing quartus project files and quartus settings files.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"QuartusProjectGenerator.h\"\r\n#include \"QuartusGenerator.h\"\r\n\r\n#include <KactusAPI/include/LibraryInterface.h>\r\n\r\n#include <KactusAPI/include/IPluginUtility.h>\r\n\r\n#include <IPXACTmodels/Design/Design.h>\r\n\r\n#include <IPXACTmodels/DesignConfiguration/DesignConfiguration.h>\r\n\r\n#include <IPXACTmodels/Component/Component.h>\r\n#include <IPXACTmodels/kactusExtensions/KactusAttribute.h>\r\n\r\n#include <IPXACTmodels/common/VLNV.h>\r\n\r\n#include <QtPlugin>\r\n#include <QDebug>\r\n#include <QFileDialog>\r\n#include <IPXACTmodels/Component/View.h>\r\n#include \"IPXACTmodels/Component/DesignConfigurationInstantiation.h\"\r\n#include \"IPXACTmodels/Component/DesignInstantiation.h\"\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: QuartusProjectGenerator::QuartusProjectGenerator()\r\n//-----------------------------------------------------------------------------\r\nQuartusProjectGenerator::QuartusProjectGenerator(): utility_(nullptr)\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: QuartusProjectGenerator::getName()\r\n//-----------------------------------------------------------------------------\r\nQString QuartusProjectGenerator::getName() const\r\n{\r\n\tstatic QString name(tr(\"Quartus Project Generator\"));\r\n\treturn name;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: QuartusProjectGenerator::getVersion()\r\n//-----------------------------------------------------------------------------\r\nQString QuartusProjectGenerator::getVersion() const\r\n{\r\n    static QString version(tr(\"1.1\"));\r\n    return version;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: QuartusProjectGenerator::getDescription()\r\n//-----------------------------------------------------------------------------\r\nQString QuartusProjectGenerator::getDescription() const\r\n{\r\n    static QString description(tr(\"Generates quartus project file and quartus settings file for a HW design.\"));\r\n    return description;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: QuartusProjectGenerator::getVendor()\r\n//-----------------------------------------------------------------------------\r\nQString QuartusProjectGenerator::getVendor() const\r\n{\r\n    static QString vendor(tr(\"TUT\"));\r\n    return vendor;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: QuartusProjectGenerator::getLicense()\r\n//-----------------------------------------------------------------------------\r\nQString QuartusProjectGenerator::getLicense() const\r\n{\r\n    static QString license(tr(\"GPL2\"));\r\n    return license;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: QuartusProjectGenerator::getLicenseHolder()\r\n//-----------------------------------------------------------------------------\r\nQString QuartusProjectGenerator::getLicenseHolder() const\r\n{\r\n    static QString holder(tr(\"Public\"));\r\n    return holder;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryMapHeaderGenerator::getSettingsWidget()\r\n//-----------------------------------------------------------------------------\r\nQWidget* QuartusProjectGenerator::getSettingsWidget()\r\n{\r\n    return nullptr;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryMapHeaderGenerator::getIcon()\r\n//-----------------------------------------------------------------------------\r\nQIcon QuartusProjectGenerator::getIcon() const\r\n{\r\n    return QIcon(QStringLiteral(\":icons/quartus_generator.png\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: QuartusProjectGenerator::checkGeneratorSupport()\r\n//-----------------------------------------------------------------------------\r\nbool QuartusProjectGenerator::checkGeneratorSupport(QSharedPointer<Component const> component,\r\n    QSharedPointer<Design const> design,\r\n    QSharedPointer<DesignConfiguration const> designConfiguration) const\r\n{\r\n    if (component && component->getImplementation() == KactusAttribute::HW)\r\n    {\r\n        if ((designConfiguration && designConfiguration->getDesignConfigImplementation() == KactusAttribute::HW) ||\r\n            (design && design->getDesignImplementation() == KactusAttribute::HW))\r\n        {\r\n            return true;\r\n        }\r\n    }\r\n\r\n    return false;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: QuartusProjectGenerator::runGenerator()\r\n//-----------------------------------------------------------------------------\r\nvoid QuartusProjectGenerator::runGenerator(IPluginUtility* utility, \r\n    QSharedPointer<Component> component,\r\n    QSharedPointer<Design> design,\r\n    QSharedPointer<DesignConfiguration> designConfiguration)\r\n{\r\n    utility->printInfo(tr(\"Running %1 %2.\").arg(getName(), getVersion()));\r\n\r\n    utility_ = utility;\r\n\r\n    QString path = QFileDialog::getExistingDirectory(utility->getParentWidget(),\r\n        tr(\"Set the directory for the Quartus project\"),\r\n        utility->getLibraryInterface()->getPath(component->getVlnv()));\r\n\r\n\tif (path.isEmpty())\r\n\t{\r\n\t\tutility->printInfo(tr(\"Generation aborted: No path given.\"));\r\n\t\treturn;\r\n\t}\r\n\r\n\tQSharedPointer<View> openView = getOpenView(component, designConfiguration, design);\r\n\r\n\tQuartusGenerator quartusGenerator(utility);\r\n\r\n\tconnect(&quartusGenerator, SIGNAL(errorMessage(QString const&)),\r\n\t\tthis, SLOT(onErrorMessage(QString const&)), Qt::UniqueConnection);\r\n\tconnect(&quartusGenerator, SIGNAL(noticeMessage(QString const&)),\r\n\t\tthis, SLOT(onNoticeMessage(QString const&)), Qt::UniqueConnection);\r\n\r\n\tQString generatorInformation = getName() + QLatin1Char(' ') + getVersion();\r\n\r\n\tquartusGenerator.readExistingPinMap(component);\r\n\tquartusGenerator.parseFiles(component, openView);\r\n\tquartusGenerator.generateProject(path, component->getVlnv().getName(), generatorInformation);\r\n\r\n\tutility->printInfo(tr(\"Quartus project generation complete.\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: QuartusProjectGenerator::getProgramRequirements()\r\n//-----------------------------------------------------------------------------\r\nQList<IPlugin::ExternalProgramRequirement> QuartusProjectGenerator::getProgramRequirements()\r\n{\r\n    return QList<IPlugin::ExternalProgramRequirement>();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: QuartusProjectGenerator::onErrorMessage()\r\n//-----------------------------------------------------------------------------\r\nvoid QuartusProjectGenerator::onErrorMessage(QString const& message)\r\n{\r\n    utility_->printError(message);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: QuartusProjectGenerator::onNoticeMessage()\r\n//-----------------------------------------------------------------------------\r\nvoid QuartusProjectGenerator::onNoticeMessage(QString const& message)\r\n{\r\n    utility_->printInfo(message);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: QuartusProjectGenerator::getOpenView()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<View> QuartusProjectGenerator::getOpenView(QSharedPointer<Component> component,\r\n\tQSharedPointer<DesignConfiguration> desConf, QSharedPointer<Design> design)\r\n{\r\n    foreach (QSharedPointer<View> currentView, *component->getViews())\r\n    {\r\n\t\tif ( desConf )\r\n\t\t{\r\n\t\t\tforeach ( QSharedPointer<DesignConfigurationInstantiation> insta,\r\n\t\t\t\t*component->getDesignConfigurationInstantiations() )\r\n\t\t\t{\r\n\t\t\t\tif ( (*insta->getDesignConfigurationReference()) == desConf->getVlnv()\r\n\t\t\t\t\t&& currentView->getDesignConfigurationInstantiationRef() == insta->name() )\r\n\t\t\t\t{\r\n\t\t\t\t\treturn currentView;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tif ( design )\r\n\t\t{\r\n\t\t\tforeach (QSharedPointer<DesignInstantiation> insta, *component->getDesignInstantiations() )\r\n\t\t\t{\r\n\t\t\t\tif ( (*insta->getDesignReference()) == design->getVlnv()\r\n\t\t\t\t\t&& currentView->getDesignInstantiationRef() == insta->name() )\r\n\t\t\t\t{\r\n\t\t\t\t\treturn currentView;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n    }\r\n\r\n    return QSharedPointer<View>();\r\n}\r\n"
  },
  {
    "path": "Plugins/QuartusProjectGenerator/QuartusProjectGenerator.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: QuartusProjectGenerator.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 02.06.2015\r\n//\r\n// Description:\r\n// The plugin for generating quartus projects containing quartus project files and quartus settings files.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef QUARTUSPROJECTGENERATOR_H\r\n#define QUARTUSPROJECTGENERATOR_H\r\n\r\n#include \"QuartusProjectGenerator_global.h\"\r\n\r\n#include <KactusAPI/include/IGeneratorPlugin.h>\r\n\r\n#include <IPXACTmodels/Component/Component.h>\r\n\r\n#include <QObject>\r\n#include <QSharedPointer>\r\n#include <QString>\r\n#include <QIcon>\r\n#include <QFileInfo>\r\n#include <QSettings>\r\n\r\nclass IPluginUtility;\r\nclass Design;\r\nclass DesignConfiguration;\r\n\r\n//-----------------------------------------------------------------------------\r\n// !The plugin for generating quartus projects containing quartus project files and quartus settings files.\r\n//-----------------------------------------------------------------------------\r\nclass QUARTUSPROJECTGENERATOR_EXPORT QuartusProjectGenerator : public QObject, public IGeneratorPlugin\r\n{\r\n\tQ_OBJECT\r\n\tQ_PLUGIN_METADATA(IID \"kactus2.plugins.QuartusProjectGenerator\" FILE \"QuartusProjectGenerator.json\")\r\n\r\n\tQ_INTERFACES(IPlugin)\r\n\tQ_INTERFACES(IGeneratorPlugin)\r\n\r\npublic:\r\n\r\n    /*!\r\n\t *  The constructor.\r\n\t */\r\n\tQuartusProjectGenerator();\r\n\t\r\n\t/*!\r\n\t *  The destructor.\r\n\t */\r\n\tvirtual ~QuartusProjectGenerator() = default;\r\n\r\n    //! No copying\r\n    QuartusProjectGenerator(const QuartusProjectGenerator& other) = delete;\r\n\r\n    //! No assignment\r\n    QuartusProjectGenerator& operator=(const QuartusProjectGenerator& other) = delete;\r\n\r\n    /*!\r\n     *  Gets the name of the plugin.\r\n     *\r\n     *    @return The name of the plugin.\r\n     */\r\n    virtual QString getName() const;\r\n\r\n    /*!\r\n     *  Gets the version of the plugin.\r\n     *\r\n     *    @return The version of the plugin\r\n     */\r\n    virtual QString getVersion() const;\r\n\r\n    /*!\r\n     *  Gets the description of the plugin.\r\n     *\r\n     *    @return The description of the plugin.\r\n     */\r\n    virtual QString getDescription() const;\r\n\r\n    /*!\r\n     *  Gets the vendor of the plugin.\r\n     *\r\n     *    @return The vendor of the plugin.\r\n     */\r\n    virtual QString getVendor() const;\r\n\r\n    /*!\r\n     *  Gets the license of the plugin.\r\n     *\r\n     *    @return The license of the plugin.\r\n     */\r\n    virtual QString getLicense() const;\r\n\r\n    /*!\r\n     *  Returns the holder of the license of the plugin.\r\n     *\r\n     *    @return The holder of the license of the plugin.\r\n     */\r\n    virtual QString getLicenseHolder() const;\r\n\r\n    /*!\r\n     *  Returns the settings widget.\r\n     *\r\n     *    @return The settings widget.\r\n     */\r\n    virtual QWidget* getSettingsWidget();\r\n\r\n    /*!\r\n     *  This is used to access the settings modified by function getSettingsWidget().\r\n     */\r\n    virtual PluginSettingsModel* getSettingsModel(){return NULL;}\r\n\r\n    /*!\r\n     *  Returns the icon for the generator.\r\n     *\r\n     *    @return The icon for the generator.\r\n     */\r\n    virtual QIcon getIcon() const;\r\n\r\n    /*!\r\n     *  Checks whether the generator may run for the given component or design. \r\n     *\r\n     *    @param [in] component\t        The component for which to check support. If design is not null, component\r\n\t *                                      will refer to design or designConfiguration.\r\n     *    @param [in] design\t            The design, if the generator is ran for a design.\r\n     *    @param [in] designConfiguration The design configuration for design, if it is not null.\r\n     *\r\n     *    @return True, if the generator may run the given component. Otherwise false.\r\n     */\r\n    virtual bool checkGeneratorSupport(QSharedPointer<Component const> component,\r\n        QSharedPointer<Design const> design,\r\n        QSharedPointer<DesignConfiguration const> designConfiguration) const;\r\n\r\n    /*!\r\n     *  Runs the generation, creating new files and/or modifying the IP-XACT metadata. The function has\r\n\t *  also access to the parent window widget, so that it can show dialogs for the user to aid the generation.\r\n     *\r\n     *    @param [in] utility\t\t\t    The plugin utility interface.\r\n     *    @param [in] component\t        The component for which to check support. If design is not null, component\r\n     *                                      will refer to design or designConfiguration.\r\n     *    @param [in] design\t            The design, if the generator is ran for a design.\r\n     *    @param [in] designConfiguration The design configuration for design, if it is not null.\r\n     */\r\n    virtual void runGenerator(IPluginUtility* utility, \r\n        QSharedPointer<Component> component,\r\n        QSharedPointer<Design> design,\r\n        QSharedPointer<DesignConfiguration> designConfiguration);\r\n\r\n    /*!\r\n     *  Get a list of external program requirements of the plugin.\r\n     *\r\n     *    @return A list of external program requirements of the plugin.\r\n     */\r\n    virtual QList<IPlugin::ExternalProgramRequirement> getProgramRequirements();\r\n\r\nprivate slots:\r\n\r\n    /*!\r\n     *  Handles the error messages of the quartus generator.\r\n     *\r\n     *    @param [in] message     The error message.\r\n     */\r\n    void onErrorMessage(QString const& message);\r\n\r\n    /*!\r\n     *  Handles the notification messages of the quartus generator.\r\n     *\r\n     *    @param [in] message     The notification message.\r\n     */\r\n    void onNoticeMessage(QString const& message);\r\n\r\nprivate:\r\n\r\n    /*!\r\n     *  Gets the view of the current design or design configuration.\r\n\t *\r\n\t *    @param [in] component   The component for which this plugin is run for.\r\n     *    @param [in] desConf\t\tThe design configuration object of a hierarchical component.\r\n     *    @param [in] design      The design object of a hierarchical component.\r\n     *\r\n     *    @return The view referencing to the open design.\r\n     */\r\n\tQSharedPointer<View> getOpenView(QSharedPointer<Component> component,\r\n\t\tQSharedPointer<DesignConfiguration> desConf, QSharedPointer<Design> design);\r\n\r\n\t//! The plugin utility.\r\n\tIPluginUtility* utility_;\r\n};\r\n\r\n#endif // QUARTUSPROJECTGENERATOR_H\r\n"
  },
  {
    "path": "Plugins/QuartusProjectGenerator/QuartusProjectGenerator.json",
    "content": "{\r\n\t\"Keys\": [ \"Quartus Project Generator\" ]\r\n}"
  },
  {
    "path": "Plugins/QuartusProjectGenerator/QuartusProjectGenerator.pri",
    "content": "# ----------------------------------------------------\r\n# This file is generated by the Qt Visual Studio Tools.\r\n# ------------------------------------------------------\r\n\r\nHEADERS += ../../IPXACTmodels/utilities/ComponentSearch.h \\\r\n    ../../IPXACTmodels/utilities/Search.h \\\r\n    ./QuartusProjectGenerator.h \\\r\n    ./QuartusGenerator.h\r\nSOURCES += ../../IPXACTmodels/utilities/ComponentSearch.cpp \\\r\n    ./QuartusGenerator.cpp \\\r\n    ./QuartusProjectGenerator.cpp\r\nRESOURCES += QuartusProjectGenerator.qrc\r\n"
  },
  {
    "path": "Plugins/QuartusProjectGenerator/QuartusProjectGenerator.pro",
    "content": "# ----------------------------------------------------\r\n# This file is generated by the Qt Visual Studio Add-in.\r\n# ------------------------------------------------------\r\n\r\nTEMPLATE = lib\r\n\r\nQT += core xml widgets gui printsupport\r\nCONFIG += c++11 plugin\r\n\r\nDEFINES += QUARTUSGENERATOR_LIB QT_NO_CAST_FROM_ASCII\r\nINCLUDEPATH += ./GeneratedFiles \\\r\n    . \\\r\n    ./../..\r\n\r\nCONFIG(debug, debug|release) {\r\n    # debug mode\r\n    LIBS += \\\r\n        -L../../executable -lIPXACTmodelsd\r\n\r\n    MOC_DIR += ./GeneratedFiles/Debug\r\n    OBJECTS_DIR += Debug\r\n    TARGET = QuartusProjectGeneratord\r\n\r\n} else {\r\n    # release mode \r\n    LIBS += \\\r\n        -L../../executable -lIPXACTmodels\r\n    \r\n    MOC_DIR += ./GeneratedFiles/Release\r\n    OBJECTS_DIR += Release\r\n    TARGET = QuartusProjectGenerator\r\n}\r\n\r\nDESTDIR = ../../executable/Plugins\r\n\r\nDEPENDPATH += .\r\nUI_DIR += ./GeneratedFiles\r\nRCC_DIR += ./GeneratedFiles\r\n\r\ninclude(QuartusProjectGenerator.pri)\r\n\r\ntarget.path = $$plugin_path\r\nINSTALLS += target\r\n"
  },
  {
    "path": "Plugins/QuartusProjectGenerator/QuartusProjectGenerator.qrc",
    "content": "<RCC>\n    <qresource prefix=\"/icons\">\n        <file>quartus_generator.png</file>\n    </qresource>\n</RCC>\n"
  },
  {
    "path": "Plugins/QuartusProjectGenerator/QuartusProjectGenerator.vcxproj",
    "content": "﻿<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n<Project DefaultTargets=\"Build\" ToolsVersion=\"15.0\" xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">\r\n  <ItemGroup Label=\"ProjectConfigurations\">\r\n    <ProjectConfiguration Include=\"Debug|x64\">\r\n      <Configuration>Debug</Configuration>\r\n      <Platform>x64</Platform>\r\n    </ProjectConfiguration>\r\n    <ProjectConfiguration Include=\"Release|x64\">\r\n      <Configuration>Release</Configuration>\r\n      <Platform>x64</Platform>\r\n    </ProjectConfiguration>\r\n  </ItemGroup>\r\n  <ItemGroup>\r\n    <QtMoc Include=\"QuartusProjectGenerator.h\">\r\n    </QtMoc>\r\n  </ItemGroup>\r\n  <ItemGroup>\r\n    <ClCompile Include=\"..\\..\\IPXACTmodels\\utilities\\ComponentSearch.cpp\" />\r\n    <ClCompile Include=\"QuartusGenerator.cpp\" />\r\n    <ClCompile Include=\"QuartusProjectGenerator.cpp\" />\r\n  </ItemGroup>\r\n  <ItemGroup>\r\n    <QtRcc Include=\"QuartusProjectGenerator.qrc\">\r\n    </QtRcc>\r\n  </ItemGroup>\r\n  <ItemGroup>\r\n    <None Include=\"quartus_generator.png\">\r\n      <ExcludedFromBuild Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">true</ExcludedFromBuild>\r\n      <ExcludedFromBuild Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">true</ExcludedFromBuild>\r\n    </None>\r\n  </ItemGroup>\r\n  <ItemGroup>\r\n    <QtMoc Include=\"QuartusGenerator.h\">\r\n    </QtMoc>\r\n  </ItemGroup>\r\n  <ItemGroup>\r\n    <ClInclude Include=\"..\\..\\IPXACTmodels\\utilities\\ComponentSearch.h\" />\r\n    <ClInclude Include=\"..\\..\\IPXACTmodels\\utilities\\Search.h\" />\r\n  </ItemGroup>\r\n  <PropertyGroup Label=\"Globals\">\r\n    <ProjectGuid>{19FABF05-9AD2-4437-84E9-5A60DF6E7BAE}</ProjectGuid>\r\n    <Keyword>QtVS_v304</Keyword>\r\n    <WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>\r\n    <QtMsBuild Condition=\"'$(QtMsBuild)'=='' or !Exists('$(QtMsBuild)\\qt.targets')\">$(MSBuildProjectDirectory)\\QtMsBuild</QtMsBuild>\r\n  </PropertyGroup>\r\n  <Import Project=\"$(VCTargetsPath)\\Microsoft.Cpp.Default.props\" />\r\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\" Label=\"Configuration\">\r\n    <ConfigurationType>DynamicLibrary</ConfigurationType>\r\n    <PlatformToolset>v143</PlatformToolset>\r\n  </PropertyGroup>\r\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\" Label=\"Configuration\">\r\n    <ConfigurationType>DynamicLibrary</ConfigurationType>\r\n    <PlatformToolset>v143</PlatformToolset>\r\n  </PropertyGroup>\r\n  <Import Project=\"$(VCTargetsPath)\\Microsoft.Cpp.props\" />\r\n  <Target Name=\"QtMsBuildNotFound\" BeforeTargets=\"CustomBuild;ClCompile\" Condition=\"!Exists('$(QtMsBuild)\\qt.targets') or !Exists('$(QtMsBuild)\\qt.props')\">\r\n    <Message Importance=\"High\" Text=\"QtMsBuild: could not locate qt.targets, qt.props; project may not build correctly.\" />\r\n  </Target>\r\n  <ImportGroup Label=\"ExtensionSettings\">\r\n  </ImportGroup>\r\n  <ImportGroup Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\" Label=\"PropertySheets\">\r\n    <Import Project=\"$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props\" Condition=\"exists('$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props')\" Label=\"LocalAppDataPlatform\" />\r\n  </ImportGroup>\r\n  <ImportGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\" Label=\"PropertySheets\">\r\n    <Import Project=\"$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props\" Condition=\"exists('$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props')\" Label=\"LocalAppDataPlatform\" />\r\n  </ImportGroup>\r\n  <PropertyGroup Label=\"UserMacros\" />\r\n  <ImportGroup Condition=\"Exists('$(QtMsBuild)\\qt_defaults.props')\">\r\n    <Import Project=\"$(QtMsBuild)\\qt_defaults.props\" />\r\n  </ImportGroup>\r\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n    <OutDir>$(SolutionDir)executable\\Plugins\\</OutDir>\r\n    <IntDir>$(ProjectDir)\\$(Configuration)\\</IntDir>\r\n  </PropertyGroup>\r\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n    <OutDir>$(SolutionDir)executable\\Plugins\\</OutDir>\r\n    <IntDir>$(ProjectDir)\\$(Configuration)\\</IntDir>\r\n  </PropertyGroup>\r\n  <PropertyGroup Label=\"QtSettings\" Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n    <QtInstall>6.2.4</QtInstall>\r\n    <QtModules>core;gui;widgets;help;printsupport;xml</QtModules>\r\n  </PropertyGroup>\r\n  <PropertyGroup Label=\"QtSettings\" Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n    <QtInstall>6.2.4</QtInstall>\r\n    <QtModules>core;gui;widgets;help;printsupport;xml</QtModules>\r\n  </PropertyGroup>\r\n  <ImportGroup Condition=\"Exists('$(QtMsBuild)\\qt.props')\">\r\n    <Import Project=\"$(QtMsBuild)\\qt.props\" />\r\n  </ImportGroup>\r\n  <PropertyGroup>\r\n    <_ProjectFileVersion>10.0.40219.1</_ProjectFileVersion>\r\n  </PropertyGroup>\r\n  <ItemDefinitionGroup Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n    <ClCompile>\r\n      <PreprocessorDefinitions>QUARTUSGENERATOR_LIB;QT_XMLPATTERNS_LIB;UNICODE;WIN32;QT_NO_CAST_FROM_ASCII;%(PreprocessorDefinitions)</PreprocessorDefinitions>\r\n      <AdditionalIncludeDirectories>.\\GeneratedFiles\\$(ConfigurationName);.\\GeneratedFiles;.\\GeneratedFiles\\$(Configuration);.;.\\..\\..;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\r\n      <Optimization>Disabled</Optimization>\r\n      <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>\r\n      <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>\r\n      <TreatWChar_tAsBuiltInType>true</TreatWChar_tAsBuiltInType>\r\n      <MultiProcessorCompilation>true</MultiProcessorCompilation>\r\n      <LanguageStandard>stdcpp17</LanguageStandard>\r\n      <AdditionalOptions>/Zc:__cplusplus %(AdditionalOptions)</AdditionalOptions>\r\n    </ClCompile>\r\n    <Link>\r\n      <SubSystem>Windows</SubSystem>\r\n      <OutputFile>$(OutDir)$(ProjectName).dll</OutputFile>\r\n      <AdditionalLibraryDirectories>..\\..\\executable;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>\r\n      <GenerateDebugInformation>true</GenerateDebugInformation>\r\n      <AdditionalDependencies>IPXACTmodelsd.lib;%(AdditionalDependencies)</AdditionalDependencies>\r\n      <TargetMachine>MachineX64</TargetMachine>\r\n      <AdditionalOptions> /SUBSYSTEM:WINDOWS</AdditionalOptions>\r\n    </Link>\r\n    <QtMoc>\r\n      <ExecutionDescription>Moc'ing %(Identity)...</ExecutionDescription>\r\n      <DynamicSource>output</DynamicSource>\r\n      <QtMocDir>.\\GeneratedFiles\\$(ConfigurationName)</QtMocDir>\r\n      <QtMocFileName>moc_%(Filename).cpp</QtMocFileName>\r\n    </QtMoc>\r\n    <QtRcc>\r\n      <InitFuncName>%(Filename)</InitFuncName>\r\n      <Compression>default</Compression>\r\n      <NoCompression>true</NoCompression>\r\n      <ExecutionDescription>Rcc'ing %(Identity)...</ExecutionDescription>\r\n      <QtRccDir>.\\GeneratedFiles</QtRccDir>\r\n      <QtRccFileName>qrc_%(Filename).cpp</QtRccFileName>\r\n    </QtRcc>\r\n  </ItemDefinitionGroup>\r\n  <ItemDefinitionGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n    <ClCompile>\r\n      <PreprocessorDefinitions>QUARTUSGENERATOR_LIB;NDEBUG;QT_NO_DEBUG;QT_XMLPATTERNS_LIB;UNICODE;WIN32;QT_NO_CAST_FROM_ASCII;%(PreprocessorDefinitions)</PreprocessorDefinitions>\r\n      <AdditionalIncludeDirectories>.\\GeneratedFiles\\$(ConfigurationName);.\\GeneratedFiles;.\\GeneratedFiles\\$(Configuration);.;.\\..\\..;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\r\n      <DebugInformationFormat>\r\n      </DebugInformationFormat>\r\n      <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>\r\n      <TreatWChar_tAsBuiltInType>true</TreatWChar_tAsBuiltInType>\r\n      <MultiProcessorCompilation>true</MultiProcessorCompilation>\r\n      <AdditionalOptions>/Zc:__cplusplus %(AdditionalOptions)</AdditionalOptions>\r\n      <LanguageStandard>stdcpp17</LanguageStandard>\r\n    </ClCompile>\r\n    <Link>\r\n      <SubSystem>Windows</SubSystem>\r\n      <OutputFile>$(OutDir)$(ProjectName).dll</OutputFile>\r\n      <AdditionalLibraryDirectories>..\\..\\executable;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>\r\n      <GenerateDebugInformation>false</GenerateDebugInformation>\r\n      <AdditionalDependencies>IPXACTmodels.lib;%(AdditionalDependencies)</AdditionalDependencies>\r\n      <TargetMachine>MachineX64</TargetMachine>\r\n      <AdditionalOptions> /SUBSYSTEM:WINDOWS</AdditionalOptions>\r\n    </Link>\r\n    <QtMoc>\r\n      <ExecutionDescription>Moc'ing %(Identity)...</ExecutionDescription>\r\n      <DynamicSource>output</DynamicSource>\r\n      <QtMocDir>.\\GeneratedFiles\\$(ConfigurationName)</QtMocDir>\r\n      <QtMocFileName>moc_%(Filename).cpp</QtMocFileName>\r\n    </QtMoc>\r\n    <QtRcc>\r\n      <InitFuncName>%(Filename)</InitFuncName>\r\n      <Compression>default</Compression>\r\n      <NoCompression>true</NoCompression>\r\n      <ExecutionDescription>Rcc'ing %(Identity)...</ExecutionDescription>\r\n      <QtRccDir>.\\GeneratedFiles</QtRccDir>\r\n      <QtRccFileName>qrc_%(Filename).cpp</QtRccFileName>\r\n    </QtRcc>\r\n  </ItemDefinitionGroup>\r\n  <Import Project=\"$(VCTargetsPath)\\Microsoft.Cpp.targets\" />\r\n  <ImportGroup Condition=\"Exists('$(QtMsBuild)\\qt.targets')\">\r\n    <Import Project=\"$(QtMsBuild)\\qt.targets\" />\r\n  </ImportGroup>\r\n  <ImportGroup Label=\"ExtensionTargets\">\r\n  </ImportGroup>\r\n  <ProjectExtensions>\r\n    <VisualStudio>\r\n      <UserProperties />\r\n    </VisualStudio>\r\n  </ProjectExtensions>\r\n</Project>"
  },
  {
    "path": "Plugins/QuartusProjectGenerator/QuartusProjectGenerator.vcxproj.filters",
    "content": "﻿<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n<Project ToolsVersion=\"4.0\" xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">\r\n  <ItemGroup>\r\n    <Filter Include=\"Source Files\">\r\n      <UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>\r\n      <Extensions>cpp;cxx;c;def</Extensions>\r\n    </Filter>\r\n    <Filter Include=\"Header Files\">\r\n      <UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>\r\n      <Extensions>h</Extensions>\r\n    </Filter>\r\n    <Filter Include=\"Generated Files\">\r\n      <UniqueIdentifier>{71ED8ED8-ACB9-4CE9-BBE1-E00B30144E11}</UniqueIdentifier>\r\n      <Extensions>moc;h;cpp</Extensions>\r\n      <SourceControlFiles>False</SourceControlFiles>\r\n    </Filter>\r\n    <Filter Include=\"Generated Files\\Debug\">\r\n      <UniqueIdentifier>{aadf1134-eca1-4c7e-afc5-1e558bce1cca}</UniqueIdentifier>\r\n      <Extensions>cpp;moc</Extensions>\r\n      <SourceControlFiles>False</SourceControlFiles>\r\n    </Filter>\r\n    <Filter Include=\"Generated Files\\Release\">\r\n      <UniqueIdentifier>{8d5952d1-aa69-48bb-8569-a9f6e60c9c17}</UniqueIdentifier>\r\n      <Extensions>cpp;moc</Extensions>\r\n      <SourceControlFiles>False</SourceControlFiles>\r\n    </Filter>\r\n    <Filter Include=\"Resource Files\">\r\n      <UniqueIdentifier>{D9D6E242-F8AF-46E4-B9FD-80ECBC20BA3E}</UniqueIdentifier>\r\n      <Extensions>qrc;*</Extensions>\r\n      <ParseFiles>false</ParseFiles>\r\n    </Filter>\r\n  </ItemGroup>\r\n  <ItemGroup>\r\n    <QtMoc Include=\"QuartusProjectGenerator.h\">\r\n      <Filter>Header Files</Filter>\r\n    </QtMoc>\r\n    <QtRcc Include=\"QuartusProjectGenerator.qrc\">\r\n      <Filter>Resource Files</Filter>\r\n    </QtRcc>\r\n    <QtMoc Include=\"QuartusGenerator.h\">\r\n      <Filter>Header Files</Filter>\r\n    </QtMoc>\r\n  </ItemGroup>\r\n  <ItemGroup>\r\n    <ClCompile Include=\"QuartusProjectGenerator.cpp\">\r\n      <Filter>Source Files</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"QuartusGenerator.cpp\">\r\n      <Filter>Source Files</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\IPXACTmodels\\utilities\\ComponentSearch.cpp\">\r\n      <Filter>Source Files</Filter>\r\n    </ClCompile>\r\n  </ItemGroup>\r\n  <ItemGroup>\r\n    <None Include=\"quartus_generator.png\">\r\n      <Filter>Resource Files</Filter>\r\n    </None>\r\n  </ItemGroup>\r\n  <ItemGroup>\r\n    <ClInclude Include=\"..\\..\\IPXACTmodels\\utilities\\ComponentSearch.h\">\r\n      <Filter>Header Files</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\IPXACTmodels\\utilities\\Search.h\">\r\n      <Filter>Header Files</Filter>\r\n    </ClInclude>\r\n  </ItemGroup>\r\n</Project>"
  },
  {
    "path": "Plugins/QuartusProjectGenerator/QuartusProjectGenerator_global.h",
    "content": "/* \r\n *\tCreated on:\t18.4.2013\r\n *\tAuthor:\t\tAntti Kamppi\r\n *\tFile name:\tQuartusProjectGenerator_global.h\r\n *\tProject:\t\tKactus 2\r\n*/\r\n\r\n#ifndef QUARTUSPROJECTGENERATOR_GLOBAL_H\r\n#define QUARTUSPROJECTGENERATOR_GLOBAL_H\r\n\r\n#include <QtCore/qglobal.h>\r\n\r\n#ifdef QUARTUSGENERATOR_LIB\r\n# define QUARTUSPROJECTGENERATOR_EXPORT Q_DECL_EXPORT\r\n#else\r\n# define QUARTUSPROJECTGENERATOR_EXPORT Q_DECL_IMPORT\r\n#endif\r\n\r\n#endif // QUARTUSPROJECTGENERATOR_GLOBAL_H\r\n"
  },
  {
    "path": "Plugins/RenodeGenerator/CPUDialog/RenodeColumns.h",
    "content": "//-----------------------------------------------------------------------------\n// File: RenodeColumns.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 08.03.2023\n//\n// Description:\n// Utility columns for Renode generator.\n//-----------------------------------------------------------------------------\n\n#ifndef RENODECOLUMNS_H\n#define RENODECOLUMNS_H\n\n#include <QString>\n\n//-----------------------------------------------------------------------------\n//! Columns for Renode peripherals.\n//-----------------------------------------------------------------------------\nnamespace PeripheralColumns\n{\n    //! The editable columns in the peripheral editor.\n    enum columns\n    {\n        NAME = 0,\n        BASEADDRESS,\n        SIZE,\n        CLASS,\n        INITABLE,\n        TEMPLATE,\n        FILEPATH,\n        COLUMN_COUNT\n    };\n}\n\n//-----------------------------------------------------------------------------\n//! Columns for Renode memories.\n//-----------------------------------------------------------------------------\nnamespace MemoryColumns\n{\n    //! The editable columns in the memory editor.\n    enum columns\n    {\n        NAME = 0,\n        CLASS,\n        BASEADDRESS,\n        SIZE,\n        COLUMN_COUNT\n    };\n\n};\n\n//-----------------------------------------------------------------------------\n//! Columns for Renode peripheral templates.\n//-----------------------------------------------------------------------------\nnamespace PeripheralTemplateColumns\n{\n    //! The columns in the peripheral template editor.\n    enum columns\n    {\n        NAME = 0,\n\t\tTEMPLATE,\n        PATH,\n        COLUMN_COUNT\n    };\n};\n\n#endif // RENODECOLUMNS_H"
  },
  {
    "path": "Plugins/RenodeGenerator/CPUDialog/RenodeConstants.h",
    "content": "//-----------------------------------------------------------------------------\n// File: RenodeConstants.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 24.05.2023\n//\n// Description:\n// Utility constants for Renode generator.\n//-----------------------------------------------------------------------------\n\n#ifndef RENODECONSTANTS_H\n#define RENODECONSTANTS_H\n\n#include <QString>\n\n//-----------------------------------------------------------------------------\n//! Utility constants for Renode generator.\n//-----------------------------------------------------------------------------\nnamespace RenodeConstants\n{\n    //! File type for renode files.\n    const QString RENODEFILETYPE = \"repl\";\n\n    //! File type for python files.\n    const QString PYTHONFILETYPE = \"py\";\n\n    //! File type for JSON files.\n    const QString JSONFILETYPE = \"json\";\n\n    //! File name for CPU.\n    const QString RENODECPUFILENAME = \"cpus\";\n\n    //! Identifier for CPU file name.\n    const QString RENODECPUFILEIDENTIFIER = \"cpuFileName\";\n\n    //! File name for memory.\n    const QString RENODEMEMORYFILENAME = \"memory\";\n\n    //! Identifier for memory file name.\n    const QString RENODEMEMORYFILEIDENTIFIER = \"memoryFileName\";\n\n    //! File name for peripherals.\n    const QString RENODEPERIPHERALFILENAME = \"peripherals\";\n\n    //! Identifier for peripherals file name.\n    const QString RENODEPERIPHERALFILEIDENTIFIER = \"peripheralsFileName\";\n\n    //! Identifier for multiple CPUs.\n    const QString CPUS = \"CPUs\";\n\n    //! Identifier for CPU configuration.\n    const QString SINGLECPU = \"CPU\";\n\n    //! Identifier for CPU name.\n    const QString CPUNAME = \"name\";\n\n    //! Identifier for CPU class configuration.\n    const QString CPUCLASS = \"class\";\n\n    //! Identifier for CPU type configuration.\n    const QString CPUTYPE = \"type\";\n\n    //! Identifier for CPU time provider configuration.\n    const QString CPUTIME = \"timeProvider\";\n\n    //! Identifier for memory configuration.\n    const QString MEMORY = \"memory\";\n\n    //! Identifier for memory name configuration.\n    const QString MEMORYNAME = \"name\";\n\n    //! Identifier for memory class configuration.\n    const QString MEMORYCLASS = \"class\";\n\n    //! Identifier for peripherals configuration.\n    const QString PERIPHERALS = \"peripherals\";\n\n    //! Identifier for peripheral name configuration.\n    const QString PERIPHERALNAME = \"name\";\n\n    //! Identifier for peripheral class configuration.\n    const QString PERIPHERALCLASS = \"class\";\n\n    //! Identifier for peripheral initable configuration.\n    const QString PERIPHERALINITABLE = \"initable\";\n\n    //! Identifier for peripheral file path configuration.\n    const QString PERIPHERALPATH = \"filePath\";\n\n    //! Identifier for peripheral template configuration.\n    const QString PERIPHERALTEMPLATE = \"template\";\n\n    //! Identifier for view selection.\n    const QString VIEW = \"view\";\n\n    //! Identifier for save to fileset flag.\n    const QString SAVETOFILESET = \"saveToFileSet\";\n\n    //! Identifier for file set name.\n    const QString FILESET = \"fileSet\";\n\n    //! Identifier for generation destination.\n    const QString FOLDERPATH = \"destinationFolder\";\n\n    //! Identifier for write flags.\n    const QString WRITEFILES = \"writeFiles\";\n\n    //! Identifier for renode configuration file.\n    const QString CONFIGURATIONFILEEXTENSION = \"renodeConfiguration\";\n\n    //! Python peripheral class for renode peripherals.\n    const QString PYTHONPERIPHERAL = \"Python.PythonPeripheral\";\n\n    //! Default file path for python peripherals.\n    const QString PYTHONPERIPHERALFILEPATH = \"python_peripherals\";\n\n    //! Default memory class.\n    const QString MAPPEDMEMORY = \"Memory.MappedMemory\";\n};\n\n//-----------------------------------------------------------------------------\n//! Utility constants for Renode generator peripheral templates.\n//-----------------------------------------------------------------------------\nnamespace RenodeTemplateConstants\n{\n    //! Identifier for template array.\n    const QString TEMPLATEARRAYKEY = \"Templates\";\n\n    //! Identifier for template name.\n    const QString TEMPLATENAME = \"name\";\n\n    //! Identifier for template path.\n    const QString TEMPLATEFILE = \"template\";\n\n    //! Identifier for template target folder.\n    const QString TARGETPATH = \"targetPath\";\n};\n\n#endif // RENODECONSTANTS_H"
  },
  {
    "path": "Plugins/RenodeGenerator/CPUDialog/RenodeCpuEditor.cpp",
    "content": "﻿//-----------------------------------------------------------------------------\n// File: RenodeCpuEditor.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 17.03.2023\n//\n// Description:\n// Editor for CPU details in renode generation.\n//-----------------------------------------------------------------------------\n\n#include \"RenodeCpuEditor.h\"\n\n#include <Plugins/RenodeGenerator/CPUDialog/RenodeCpuRoutesContainer.h>\n#include <Plugins/RenodeGenerator/CPUDialog/RenodeMemoriesEditor.h>\n#include <Plugins/RenodeGenerator/CPUDialog/RenodePeripheralsEditor.h>\n#include <Plugins/RenodeGenerator/CPUDialog/RenodeUtilities.h>\n#include <Plugins/RenodeGenerator/CPUDialog/TemplateEditor/PeripheralTemplateConfigurer.h>\n\n#include <editors/MemoryDesigner/ConnectivityInterface.h>\n#include <editors/MemoryDesigner/MemoryItem.h>\n\n#include <KactusAPI/include/IPluginUtility.h>\n\n#include <QVBoxLayout>\n#include <QFormLayout>\n#include <QLabel>\n\n//-----------------------------------------------------------------------------\n// Function: RenodeCpuEditor::RenodeCpuEditor()\n//-----------------------------------------------------------------------------\nRenodeCpuEditor::RenodeCpuEditor(IPluginUtility* utility, QJsonObject const& configurationObject, PeripheralTemplateConfigurer* templateConfigurer, QWidget* parent):\nCPUEditor(parent),\nutility_(utility),\nperipheralEditor_(new RenodePeripheralsEditor(templateConfigurer, this)),\nmemoryEditor_(new RenodeMemoriesEditor(this)),\ncpuSelector_(new QComboBox(this)),\ncpuClassCombo_(new QComboBox(this)),\ncpuTypeEditor_(new QLineEdit(this)),\ncpuTimeProviderEditor_(new QLineEdit(this)),\nconfigurationObject_(configurationObject),\ntemplateConfigurer_(templateConfigurer)\n{\n    setupCpuClassEditor();\n\n    cpuClassCombo_->setEditable(true);\n\n    auto cpuLayout(new QFormLayout());\n    cpuLayout->addRow(\"CPU\", cpuSelector_);\n    cpuLayout->addRow(\"Class\", cpuClassCombo_);\n    cpuLayout->addRow(\"Architecture\", cpuTypeEditor_);\n    cpuLayout->addRow(\"Time provider\", cpuTimeProviderEditor_);\n\n    auto cpuDetailsLabel = new QLabel(\"CPU details\");\n    auto memoriesLabel = new QLabel(\"Memory\");\n    auto peripheralsLabel = new QLabel(\"Peripherals\");\n\n    QFont summaryFont = memoriesLabel->font();\n    summaryFont.setBold(true);\n\n    cpuDetailsLabel->setFont(summaryFont);\n    memoriesLabel->setFont(summaryFont);\n    peripheralsLabel->setFont(summaryFont);\n\n    auto layout = new QVBoxLayout(this);\n    layout->addWidget(cpuDetailsLabel, 0, Qt::AlignCenter);\n    layout->addLayout(cpuLayout, 0);\n    layout->addWidget(memoriesLabel, 0, Qt::AlignCenter);\n    layout->addWidget(memoryEditor_, 1);\n    layout->addWidget(peripheralsLabel, 0, Qt::AlignCenter);\n    layout->addWidget(peripheralEditor_, 2);\n    layout->setContentsMargins(0, 0, 0, 0);\n}\n\n//-----------------------------------------------------------------------------\n// Function: RenodeCpuEditor::setupCpuClassEditor()\n//-----------------------------------------------------------------------------\nvoid RenodeCpuEditor::setupCpuClassEditor()\n{\n    cpuClassCombo_->addItem(\"\");\n    cpuClassCombo_->addItem(\"Arm\");\n    cpuClassCombo_->addItem(\"CortexA7\");\n    cpuClassCombo_->addItem(\"CortexM\");\n    cpuClassCombo_->addItem(\"CV32E40P\");\n    cpuClassCombo_->addItem(\"IbexRiscV32\");\n    cpuClassCombo_->addItem(\"Minerva\");\n    cpuClassCombo_->addItem(\"PicoRV32\");\n    cpuClassCombo_->addItem(\"PowerPc\");\n    cpuClassCombo_->addItem(\"PowerPc64\");\n    cpuClassCombo_->addItem(\"Ri5cy\");\n    cpuClassCombo_->addItem(\"RiscV32\");\n    cpuClassCombo_->addItem(\"RiscV64\");\n    cpuClassCombo_->addItem(\"Sparc\");\n    cpuClassCombo_->addItem(\"VexRiscv\");\n    cpuClassCombo_->addItem(\"X86\");\n    cpuClassCombo_->addItem(\"Xtensa\");\n\n    cpuClassCombo_->setCurrentText(\"\");\n}\n\n//-----------------------------------------------------------------------------\n// Function: RenodeCpuEditor::onHandleCpuChange()\n//-----------------------------------------------------------------------------\nvoid RenodeCpuEditor::onHandleCpuChange(QString const& newCPU)\n{\n    renodeCPU_ = getContainerForCpu(newCPU);\n    setupEditorsForCpu();\n}\n\n//-----------------------------------------------------------------------------\n// Function: RenodeCpuEditor::getContainerForCpu()\n//-----------------------------------------------------------------------------\nQSharedPointer<RenodeCpuRoutesContainer> RenodeCpuEditor::getContainerForCpu(QString const& cpuText) const\n{\n    for (auto container : availableCpuContainers_)\n    {\n        if (container->getFileID() == cpuText)\n        {\n            return container;\n        }\n    }\n\n    return QSharedPointer<RenodeCpuRoutesContainer>();\n}\n\n//-----------------------------------------------------------------------------\n// Function: RenodeCpuEditor::onHandleClassChange()\n//-----------------------------------------------------------------------------\nvoid RenodeCpuEditor::onHandleClassChange(QString const& newClass)\n{\n    if (renodeCPU_)\n    {\n        renodeCPU_->setClassName(newClass);\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: RenodeCpuEditor::onHandleTypeChange()\n//-----------------------------------------------------------------------------\nvoid RenodeCpuEditor::onHandleTypeChange(QString const& newType)\n{\n    if (renodeCPU_)\n    {\n        renodeCPU_->setCpuType(newType);\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: RenodeCpuEditor::onHandleTimeProviderChange()\n//-----------------------------------------------------------------------------\nvoid RenodeCpuEditor::onHandleTimeProviderChange(QString const& newTimeProvider)\n{\n    if (renodeCPU_)\n    {\n        renodeCPU_->setTimeProvider(newTimeProvider);\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: RenodeCpuEditor::setCPUDetails()\n//-----------------------------------------------------------------------------\nvoid RenodeCpuEditor::setupCPUDetails(LibraryInterface* library, QSharedPointer<Component> component, QString const& activeView)\n{\n    availableCpuContainers_ = RenodeUtilities::getRenodeCpuRoutes(configurationObject_, library, component, activeView, templateConfigurer_->getTemplates());\n    if (!availableCpuContainers_.isEmpty())\n    {\n        setupActiveCpuContainer();\n        setupEditorsForCpu();\n    }\n\n    connect(cpuSelector_, SIGNAL(currentTextChanged(QString const&)), this, SLOT(onHandleCpuChange(QString const&)), Qt::UniqueConnection);\n    connect(cpuClassCombo_, SIGNAL(currentTextChanged(QString const&)), this, SLOT(onHandleClassChange(QString const&)), Qt::UniqueConnection);\n    connect(cpuTypeEditor_, SIGNAL(textEdited(QString const&)), this, SLOT(onHandleTypeChange(QString const&)), Qt::UniqueConnection);\n    connect(cpuTimeProviderEditor_, SIGNAL(textEdited(QString const&)), this, SLOT(onHandleTimeProviderChange(QString const&)), Qt::UniqueConnection);\n}\n\n//-----------------------------------------------------------------------------\n// Function: RenodeCpuEditor::setupActiveCpuContainer()\n//-----------------------------------------------------------------------------\nvoid RenodeCpuEditor::setupActiveCpuContainer()\n{\n    QString selectedCpu = configurationObject_.value(RenodeConstants::SINGLECPU).toString(\"\");\n    if (selectedCpu.isEmpty())\n    {\n        selectedCpu = availableCpuContainers_.first()->getFileID();\n    }\n\n    for (auto cpuContainer : availableCpuContainers_)\n    {\n\t\tcpuSelector_->addItem(cpuContainer->getFileID());\n    }\n\n    renodeCPU_ = getContainerForCpu(selectedCpu);\n    cpuSelector_->setCurrentText(selectedCpu);\n}\n\n//-----------------------------------------------------------------------------\n// Function: RenodeCpuEditor::setupEditorsForCpu()\n//-----------------------------------------------------------------------------\nvoid RenodeCpuEditor::setupEditorsForCpu()\n{\n    checkStartingInterfacesForErrors();\n    QString cpuName = \"\";\n\n    if (renodeCPU_)\n    {\n\t\tcpuClassCombo_->setCurrentText(renodeCPU_->getClassName());\n\t\tcpuTypeEditor_->setText(renodeCPU_->getCpuType());\n\t\tcpuTimeProviderEditor_->setText(renodeCPU_->getTimeProvider());\n\n\t\tperipheralEditor_->setupPeripherals(renodeCPU_->getPeripherals());\n\t\tmemoryEditor_->setupMemories(renodeCPU_->getMemories());\n\n        cpuName = renodeCPU_->getCpu()->name();\n    }\n\n\temit(cpuChanged(cpuName));\n}\n\n//-----------------------------------------------------------------------------\n// Function: RenodeCpuEditor::checkStartingInterfacesForErrors()\n//-----------------------------------------------------------------------------\nvoid RenodeCpuEditor::checkStartingInterfacesForErrors()\n{\n    if (!renodeCPU_ || renodeCPU_->getRoutes().isEmpty())\n    {\n        return;\n    }\n\n    QSharedPointer<const ConnectivityInterface> firstInterface = renodeCPU_->getRoutes().first()->cpuInterface_;\n\n    QString firstAUB = firstInterface->getConnectedMemory()->getAUB();\n    QString firstWidth = firstInterface->getConnectedMemory()->getWidth();\n    QString firstSize = firstInterface->getConnectedMemory()->getSize();\n    QString firstBase = firstInterface->getBaseAddress();\n\n    for (int i = 1; i < renodeCPU_->getRoutes().size(); ++i)\n    {\n        QSharedPointer<const ConnectivityInterface> currentInterface = renodeCPU_->getRoutes().at(i)->cpuInterface_;\n\n        QString currentAUB = currentInterface->getConnectedMemory()->getAUB();\n        if (currentAUB != firstAUB)\n        {\n            utility_->printError(\"Mis-matching address unit bits found in \" + renodeCPU_->getFileName() + \" interface \" + currentInterface->getName());\n        }\n        QString currentWidth = currentInterface->getConnectedMemory()->getWidth();\n        if (currentWidth != firstWidth)\n        {\n            utility_->printError(\"Mis-matching width found in \" + renodeCPU_->getFileName() + \" interface \" + currentInterface->getName());\n        }\n        QString currentSize = currentInterface->getConnectedMemory()->getSize();\n        if (currentSize != firstSize)\n        {\n            utility_->printError(\"Mis-matching size found in \" + renodeCPU_->getFileName() + \" interface \" + currentInterface->getName());\n        }\n        QString currentBase = currentInterface->getBaseAddress();\n        if (currentBase != firstBase)\n        {\n            utility_->printError(\"Mis-matching base address found in \" + renodeCPU_->getFileName()  + \" interface \" + currentInterface->getName());\n        }\n\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: RenodeCpuEditor::getSelectedCPUs()\n//-----------------------------------------------------------------------------\nQVector<QSharedPointer<CpuRoutesContainer> > RenodeCpuEditor::getSelectedCPUs() const\n{\n    QVector<QSharedPointer<CpuRoutesContainer> > defaultCPUs;\n    if (renodeCPU_)\n    {\n        defaultCPUs.append(renodeCPU_);\n    }\n\n    return defaultCPUs;\n}\n\n//-----------------------------------------------------------------------------\n// Function: RenodeCpuEditor::getSelectedCpuName()\n//-----------------------------------------------------------------------------\nQString RenodeCpuEditor::getSelectedCpuName()\n{\n    return cpuSelector_->currentText();\n}\n\n//-----------------------------------------------------------------------------\n// Function: RenodeCpuEditor::setupFolderPath()\n//-----------------------------------------------------------------------------\nvoid RenodeCpuEditor::setupFolderPath(QString const& newFolderPath)\n{\n    peripheralEditor_->setupFolderPath(newFolderPath);\n}\n"
  },
  {
    "path": "Plugins/RenodeGenerator/CPUDialog/RenodeCpuEditor.h",
    "content": "//-----------------------------------------------------------------------------\n// File: RenodeCpuEditor.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 17.03.2023\n//\n// Description:\n// Editor for CPU details in renode generation.\n//-----------------------------------------------------------------------------\n\n#ifndef RENODECPUEDITOR_H\n#define RENODECPUEDITOR_H\n\n#include <QWidget>\n#include <QObject>\n#include <QTableView>\n\n#include <Plugins/common/ConnectivityGraphUtilities.h>\n#include <Plugins/common/CPUDialog/CPUEditor.h>\n\nclass CpuRoutesContainer;\nclass LibraryInterface;\nclass Component;\nclass RenodeCpuRoutesContainer;\nclass RenodePeripheralsEditor;\nclass RenodeMemoriesEditor;\nclass IPluginUtility;\nclass PeripheralTemplateConfigurer;\n\n#include <QComboBox>\n#include <QLineEdit>\n#include <QJsonObject>\n\n//-----------------------------------------------------------------------------\n//! Editor for CPU details in renode generation.\n//-----------------------------------------------------------------------------\nclass RenodeCpuEditor : public CPUEditor\n{\n    Q_OBJECT\n\npublic:\n\n    /*!\n     *  The constructor.\n     *\n     *    @param [in] utility                 Utility for plugins.\n     *    @param [in] configurationObject     JSON object containing the editor configuration.\n     *    @param [in] templateConfigurer      Configurer for peripheral templates.\n     *    @param [in] parent                  Pointer to the owner of this widget.\n     */\n    RenodeCpuEditor(IPluginUtility* utility,\n        QJsonObject const& configurationObject,\n        PeripheralTemplateConfigurer* templateConfigurer,\n        QWidget* parent = 0);\n\n    /*!\n     *  The destructor.\n     */\n    virtual ~RenodeCpuEditor() = default;\n\n    /*!\n     *  Setup the selected CPUs.\n     *\n     *    @param [in] library     Interface for accessing the library.\n     *    @param [in] component   Top component of the selected design.\n     *    @param [in] activeView  Active view of the design.\n     */\n    virtual void setupCPUDetails(LibraryInterface* library, QSharedPointer<Component> component, QString const& activeView) override final;\n\n    /*!\n     *  Get the selected CPUs.\n     *\n     *    @return List of the selected CPUs.\n     */\n    virtual QVector<QSharedPointer<CpuRoutesContainer> > getSelectedCPUs() const override final;\n\n    /*!\n     *  Get the name of the currently active CPU.\n     *\n     *    @return Name of the currently active CPU.\n     */\n    QString getSelectedCpuName();\n\n    //! No copying. No assignment.\n    RenodeCpuEditor(const RenodeCpuEditor& other) = delete;\n    RenodeCpuEditor& operator=(const RenodeCpuEditor& other) = delete;\n\npublic slots:\n\n\t/*!\n\t *  Setup the selected folder path.\n\t *\t\n\t *    @param [in] newFolderPath   The new folder path.\n\t */\n\tvirtual void setupFolderPath(QString const& newFolderPath) override final;\n\nsignals:\n\n    /*!\n     *  Inform of a change in CPU.\n     *\n     *    @param [in] newCpuName  Name of the new CPU.\n     */\n    void cpuChanged(QString const& newCpuName);\n\nprivate slots:\n\n    /*!\n     *  Handle the change in CPU selection.\n     *\n     *    @param [in] newCPU  Name of the new CPU.\n     */\n    void onHandleCpuChange(QString const& newCPU);\n\n    /*!\n     *  Handle the changes in the CPU class.\n     *\n     *    @param [in] newClass    The new class.\n     */\n    void onHandleClassChange(QString const& newClass);\n\n    /*!\n     *  Handle the change in cpu type.\n     *\n     *    @param [in] newType     The new type.\n     */\n    void onHandleTypeChange(QString const& newType);\n\n    /*!\n     *  Handle the change in time provider.\n     *\n     *    @param [in] newTimeProvider     The new time provider.\n     */\n    void onHandleTimeProviderChange(QString const& newTimeProvider);\n\nprivate:\n\n    /*!\n     *  Check the starting routes for errors.\n     */\n    void checkStartingInterfacesForErrors();\n\n    /*!\n     *  Set up the currently active CPU container.\n     */\n    void setupActiveCpuContainer();\n\n    /*!\n     *  Set up the editors for the currently active CPU.\n     */\n    void setupEditorsForCpu();\n\n    /*!\n     *  Setup the items for the CPU class selector.\n     */\n    void setupCpuClassEditor();\n\n    /*!\n     *  Get the CPU container for the selected CPU.\n     *\n     *    @param [in] cpuText     Identifier of the selected CPU.\n     *\n     *    @return CPU container for the selected CPU.\n     */\n    QSharedPointer<RenodeCpuRoutesContainer> getContainerForCpu(QString const& cpuText) const;\n\n    //-----------------------------------------------------------------------------\n    // Data.\n    //-----------------------------------------------------------------------------\n\n    //! The plugin utility interface.\n    IPluginUtility* utility_;\n\n    //! List of available cpu containers.\n    QVector<QSharedPointer<RenodeCpuRoutesContainer> > availableCpuContainers_;\n\n    //! The selected CPU (work in progress, should be multiple cpus).\n    QSharedPointer<RenodeCpuRoutesContainer> renodeCPU_ = nullptr;\n\n    //! Editor for peripherals.\n    RenodePeripheralsEditor* peripheralEditor_;\n\n    //! Editor for memory.\n    RenodeMemoriesEditor* memoryEditor_;\n\n    //! Selector for the currently active CPU.\n    QComboBox* cpuSelector_;\n\n    //! Editor for CPU class.\n    QComboBox* cpuClassCombo_;\n\n    //! Editor for CPU type.\n    QLineEdit* cpuTypeEditor_;\n\n    //! Editor for CPU time provider.\n    QLineEdit* cpuTimeProviderEditor_;\n\n    //! JSON object containing the editor configuration.\n    QJsonObject configurationObject_;\n\n    //! Configurer for peripheral templates.\n    PeripheralTemplateConfigurer* templateConfigurer_;\n};\n\n#endif // RENODECPUEDITOR_H\n"
  },
  {
    "path": "Plugins/RenodeGenerator/CPUDialog/RenodeCpuRoutesContainer.cpp",
    "content": "﻿//-----------------------------------------------------------------------------\n// File: RenodeCpuRoutesContainer.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 02.03.2023\n//\n// Description:\n// Container for routes connected to a master interface for Renode generator.\n//-----------------------------------------------------------------------------\n\n#include \"RenodeCpuRoutesContainer.h\"\n\n//-----------------------------------------------------------------------------\n// Function: RenodeCpuRoutesContainer::RenodeCpuRoutesContainer()\n//-----------------------------------------------------------------------------\nRenodeCpuRoutesContainer::RenodeCpuRoutesContainer(QSharedPointer<Cpu> renodeCpu):\nSingleCpuRoutesContainer(renodeCpu)\n{\n    initializeCpuData();\n}\n\n//-----------------------------------------------------------------------------\n// Function: RenodeCpuRoutesContainer::RenodeCpuRoutesContainer()\n//-----------------------------------------------------------------------------\nRenodeCpuRoutesContainer::RenodeCpuRoutesContainer(const SingleCpuRoutesContainer& other) :\nSingleCpuRoutesContainer(other)\n{\n    initializeCpuData();\n}\n\n//-----------------------------------------------------------------------------\n// Function: RenodeCpuRoutesContainer::initializeCpuData()\n//-----------------------------------------------------------------------------\nvoid RenodeCpuRoutesContainer::initializeCpuData()\n{\n    className_ = \"IbexRiscV32\";\n    cpuType_ = \"rv64gc\";\n    timeProvider_ = \"empty\";\n}\n\n//-----------------------------------------------------------------------------\n// Function: RenodeCpuRoutesContainer::setPeripherals()\n//-----------------------------------------------------------------------------\nvoid RenodeCpuRoutesContainer::setPeripherals(QVector<QSharedPointer<RenodeStructs::cpuPeripheral> > newPeripherals)\n{\n    peripherals_ = newPeripherals;\n}\n\n//-----------------------------------------------------------------------------\n// Function: RenodeCpuRoutesContainer::getPeripherals()\n//-----------------------------------------------------------------------------\nQVector<QSharedPointer<RenodeStructs::cpuPeripheral> > RenodeCpuRoutesContainer::getPeripherals() const\n{\n    return peripherals_;\n}\n\n//-----------------------------------------------------------------------------\n// Function: RenodeCpuRoutesContainer::setMemories()\n//-----------------------------------------------------------------------------\nvoid RenodeCpuRoutesContainer::setMemories(QVector<QSharedPointer<RenodeStructs::cpuMemories> > newMemories)\n{\n    memories_ = newMemories;\n}\n\n//-----------------------------------------------------------------------------\n// Function: RenodeCpuRoutesContainer::getMemories()\n//-----------------------------------------------------------------------------\nQVector<QSharedPointer<RenodeStructs::cpuMemories> > RenodeCpuRoutesContainer::getMemories() const\n{\n    return memories_;\n}\n\n//-----------------------------------------------------------------------------\n// Function: RenodeCpuRoutesContainer::setClassName()\n//-----------------------------------------------------------------------------\nvoid RenodeCpuRoutesContainer::setClassName(QString const& newClass)\n{\n    className_ = newClass;\n}\n\n//-----------------------------------------------------------------------------\n// Function: RenodeCpuRoutesContainer::getClassName()\n//-----------------------------------------------------------------------------\nQString RenodeCpuRoutesContainer::getClassName()\n{\n    return className_;\n}\n\n//-----------------------------------------------------------------------------\n// Function: RenodeCpuRoutesContainer::setCpuType()\n//-----------------------------------------------------------------------------\nvoid RenodeCpuRoutesContainer::setCpuType(QString const& newType)\n{\n    cpuType_ = newType;\n}\n\n//-----------------------------------------------------------------------------\n// Function: RenodeCpuRoutesContainer::getCpuType()\n//-----------------------------------------------------------------------------\nQString RenodeCpuRoutesContainer::getCpuType()\n{\n    return cpuType_;\n}\n\n//-----------------------------------------------------------------------------\n// Function: RenodeCpuRoutesContainer::setTimeProvider()\n//-----------------------------------------------------------------------------\nvoid RenodeCpuRoutesContainer::setTimeProvider(QString const& newTimeProvider)\n{\n    timeProvider_ = newTimeProvider;\n}\n\n//-----------------------------------------------------------------------------\n// Function: RenodeCpuRoutesContainer::getTimeProvider()\n//-----------------------------------------------------------------------------\nQString RenodeCpuRoutesContainer::getTimeProvider()\n{\n    return timeProvider_;\n}\n"
  },
  {
    "path": "Plugins/RenodeGenerator/CPUDialog/RenodeCpuRoutesContainer.h",
    "content": "//-----------------------------------------------------------------------------\n// File: RenodeCpuRoutesContainer.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 02.03.2023\n//\n// Description:\n// Container for routes connected to a master interface for Renode generator.\n//-----------------------------------------------------------------------------\n\n#ifndef RENODECPUROUTESCONTAINER_H\n#define RENODECPUROUTESCONTAINER_H\n\n#include <Plugins/common/SingleCpuRoutesContainer.h>\n#include <Plugins/RenodeGenerator/CPUDialog/RenodeStructs.h>\n\n//-----------------------------------------------------------------------------\n//! Container for routes connected to a master interface for Renode generator.\n//-----------------------------------------------------------------------------\nclass RenodeCpuRoutesContainer : public SingleCpuRoutesContainer\n{\n\npublic:\n\n    /*!\n     *  The constructor.\n     *\n     *    @param [in] renodeCpu   CPU for this container.\n     */\n    RenodeCpuRoutesContainer(QSharedPointer<Cpu> renodeCpu);\n\n    /*!\n     *  The destructor.\n     */\n    virtual ~RenodeCpuRoutesContainer() = default;\n\n    /*!\n     *  Creates a Renode CPU route from CPU route.\n     *\n     *    @return Renode CPU route.\n     */\n    RenodeCpuRoutesContainer(SingleCpuRoutesContainer const& other);\n\n    /*!\n     *  Set the peripheral data.\n     *\n     *    @param [in] newPeripherals  List of new peripherals.\n     */\n    void setPeripherals(QVector<QSharedPointer<RenodeStructs::cpuPeripheral> > newPeripherals);\n\n    /*!\n     *  Get the peripheral data.\n     *\n     *    @return List of peripheral data.\n     */\n    QVector<QSharedPointer<RenodeStructs::cpuPeripheral> > getPeripherals() const;\n\n    /*!\n     *  Set the available memory data.\n     *\n     *    @param [in] newMemories     List of new memory data.\n     */\n    void setMemories(QVector<QSharedPointer<RenodeStructs::cpuMemories> > newMemories);\n\n    /*!\n     *  Get the memory data.\n     *\n     *    @return List of the memory data.\n     */\n    QVector<QSharedPointer<RenodeStructs::cpuMemories> > getMemories() const;\n\n    /*!\n     *  Set a class name for the CPU.\n     *\n     *    @param [in] newClass    The new class name.\n     */\n    void setClassName(QString const& newClass);\n\n    /*!\n     *  Get the CPU class name.\n     *\n     *    @return The CPU class name.\n     */\n    QString getClassName();\n\n    /*!\n     *  Set the CPU type.\n     *\n     *    @param [in] newType     The new CPU type.\n     */\n    void setCpuType(QString const& newType);\n\n    /*!\n     *  Get the CPU type.\n     *\n     *    @return The CPU type.\n     */\n    QString getCpuType();\n\n    /*!\n     *  Set a new time provider.\n     *\n     *    @param [in] newTimeProvider     The new time provider.\n     */\n    void setTimeProvider(QString const& newTimeProvider);\n\n    /*!\n     *  Get the CPU time provider.\n     *\n     *    @return The CPU time provider.\n     */\n    QString getTimeProvider();\n\nprivate:\n\n    // Disable copying.\n    RenodeCpuRoutesContainer(RenodeCpuRoutesContainer const& rhs);\n    RenodeCpuRoutesContainer& operator=(RenodeCpuRoutesContainer const& rhs);\n\n    /*!\n     *  Initialize the CPU data.\n     */\n    void initializeCpuData();\n\n    //-----------------------------------------------------------------------------\n    // Data.\n    //-----------------------------------------------------------------------------\n\n    //! List of available peripheral data.\n    QVector<QSharedPointer<RenodeStructs::cpuPeripheral> > peripherals_;\n\n    //! List of available memory data.\n    QVector<QSharedPointer<RenodeStructs::cpuMemories> > memories_;\n\n    //! Class name of the CPU.\n    QString className_;\n\n    //! Type of the CPU.\n    QString cpuType_;\n\n    //! CPU time provider.\n    QString timeProvider_;\n};\n\n#endif // RENODECPUROUTESCONTAINER_H"
  },
  {
    "path": "Plugins/RenodeGenerator/CPUDialog/RenodeFileEditor.cpp",
    "content": "﻿//-----------------------------------------------------------------------------\n// File: RenodeFileEditor.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 22.05.2023\n//\n// Description:\n// Editor selecting files and file names for Renode generation.\n//-----------------------------------------------------------------------------\n\n#include \"RenodeFileEditor.h\"\n\n#include <Plugins/RenodeGenerator/CPUDialog/RenodeFileSelectionGroup.h>\n#include <Plugins/RenodeGenerator/CPUDialog/RenodeUtilities.h>\n\n#include <QVBoxLayout>\n#include <QFormLayout>\n\n//-----------------------------------------------------------------------------\n// Function: RenodeFileEditor::RenodeFileEditor()\n//-----------------------------------------------------------------------------\nRenodeFileEditor::RenodeFileEditor(QJsonObject const& configurationObject, QWidget *parent):\nQWidget(parent),\nfileSelectionGroup_(new RenodeFileSelectionGroup(configurationObject, this)),\ncpuFileNameEditor_(new QLineEdit(this)),\nmemoryFileNameEditor_(new QLineEdit(this)),\nperipheralFileNameEditor_(new QLineEdit(this))\n{\n    QFormLayout* lineEditLayout(new QFormLayout());\n    lineEditLayout->addRow(\"CPU:\", cpuFileNameEditor_);\n    lineEditLayout->addRow(\"Memory:\", memoryFileNameEditor_);\n    lineEditLayout->addRow(\"Peripherals:\", peripheralFileNameEditor_);\n\n    QGroupBox* fileNameGroup(new QGroupBox(\"File names\"));\n    fileNameGroup->setLayout(lineEditLayout);\n\n    QVBoxLayout* boxLayout(new QVBoxLayout());\n    boxLayout->addWidget(fileSelectionGroup_, 1);\n    boxLayout->addWidget(fileNameGroup);\n\n    setLayout(boxLayout);\n\n    applyConfigurations(configurationObject);\n}\n\n//-----------------------------------------------------------------------------\n// Function: RenodeFileEditor::applyConfigurations()\n//-----------------------------------------------------------------------------\nvoid RenodeFileEditor::applyConfigurations(QJsonObject const& configurationObject)\n{\n    QJsonValue writeFilesValue = configurationObject.value(RenodeConstants::WRITEFILES);\n    if (writeFilesValue.isObject())\n    {\n        QJsonObject writeFilesObject = writeFilesValue.toObject();\n\n        cpuFileNameEditor_->setText(writeFilesObject.value(RenodeConstants::RENODECPUFILEIDENTIFIER).toString(\"\"));\n        memoryFileNameEditor_->setText(writeFilesObject.value(RenodeConstants::RENODEMEMORYFILEIDENTIFIER).toString(\"\"));\n        peripheralFileNameEditor_->setText(writeFilesObject.value(RenodeConstants::RENODEPERIPHERALFILEIDENTIFIER).toString(\"\"));\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: RenodeFileEditor::writeCpu()\n//-----------------------------------------------------------------------------\nbool RenodeFileEditor::writeCpu()\n{\n    return fileSelectionGroup_->writeCpu();\n}\n\n//-----------------------------------------------------------------------------\n// Function: RenodeFileEditor::writeMemory()\n//-----------------------------------------------------------------------------\nbool RenodeFileEditor::writeMemory()\n{\n    return fileSelectionGroup_->writeMemory();\n}\n\n//-----------------------------------------------------------------------------\n// Function: RenodeFileEditor::writePeripherals()\n//-----------------------------------------------------------------------------\nbool RenodeFileEditor::writePeripherals()\n{\n    return fileSelectionGroup_->writePeripherals();\n}\n\n//-----------------------------------------------------------------------------\n// Function: RenodeFileEditor::changeFileNames()\n//-----------------------------------------------------------------------------\nvoid RenodeFileEditor::changeFileNames(QString const& newCpuName)\n{\n    cpuFileNameEditor_->setPlaceholderText(newCpuName + \"_\" + RenodeConstants::RENODECPUFILENAME);\n    memoryFileNameEditor_->setPlaceholderText(newCpuName + \"_\" + RenodeConstants::RENODEMEMORYFILENAME);\n    peripheralFileNameEditor_->setPlaceholderText(newCpuName + \"_\" + RenodeConstants::RENODEPERIPHERALFILENAME);\n}\n\n//-----------------------------------------------------------------------------\n// Function: RenodeFileEditor::getCpuFileName()\n//-----------------------------------------------------------------------------\nQString RenodeFileEditor::getCpuFileName() const\n{\n    return getFileName(cpuFileNameEditor_);\n}\n\n//-----------------------------------------------------------------------------\n// Function: RenodeFileEditor::getCpuEditorText()\n//-----------------------------------------------------------------------------\nQString RenodeFileEditor::getCpuEditorText() const\n{\n    return cpuFileNameEditor_->text();\n}\n\n//-----------------------------------------------------------------------------\n// Function: RenodeFileEditor::getmemoryFileName()\n//-----------------------------------------------------------------------------\nQString RenodeFileEditor::getmemoryFileName() const\n{\n    return getFileName(memoryFileNameEditor_);\n}\n\n//-----------------------------------------------------------------------------\n// Function: RenodeFileEditor::getMemoryEditorText()\n//-----------------------------------------------------------------------------\nQString RenodeFileEditor::getMemoryEditorText() const\n{\n    return memoryFileNameEditor_->text();\n}\n\n//-----------------------------------------------------------------------------\n// Function: RenodeFileEditor::getPeripheralFileName()\n//-----------------------------------------------------------------------------\nQString RenodeFileEditor::getPeripheralFileName() const\n{\n    return getFileName(peripheralFileNameEditor_);\n}\n\n//-----------------------------------------------------------------------------\n// Function: RenodeFileEditor::getPeripheralEditorText()\n//-----------------------------------------------------------------------------\nQString RenodeFileEditor::getPeripheralEditorText() const\n{\n    return peripheralFileNameEditor_->text();\n}\n\n//-----------------------------------------------------------------------------\n// Function: RenodeFileEditor::getFileName()\n//-----------------------------------------------------------------------------\ntemplate <typename fileEditor>\nQString RenodeFileEditor::getFileName(fileEditor* editor) const\n{\n    QString fileName = editor->text();\n    if (fileName.isEmpty())\n    {\n        fileName = editor->placeholderText();\n    }\n\n    return fileName;\n}\n"
  },
  {
    "path": "Plugins/RenodeGenerator/CPUDialog/RenodeFileEditor.h",
    "content": "//-----------------------------------------------------------------------------\n// File: RenodeFileEditor.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 22.05.2023\n//\n// Description:\n// Editor selecting files and file names for Renode generation.\n//-----------------------------------------------------------------------------\n\n#ifndef RENODEFILEEDITOR_H\n#define RENODEFILEEDITOR_H\n\n#include <QWidget>\n#include <QJsonObject>\n\nclass RenodeFileSelectionGroup;\n\n#include <QLineEdit>\n\n//-----------------------------------------------------------------------------\n//! Editor selecting files and file names for Renode generation.\n//-----------------------------------------------------------------------------\nclass RenodeFileEditor : public QWidget\n{\n    Q_OBJECT\n\npublic:\n\n    /*!\n     *  The constructor.\n     *\n     *    @param [in] configurationObject     JSON object containing the editor configuration.\n     *    @param [in] parent                  Pointer to the owner of this widget.\n     */\n    RenodeFileEditor(QJsonObject const& configurationObject, QWidget* parent = 0);\n\n    /*!\n     *  The destructor.\n     */\n    virtual ~RenodeFileEditor() = default;\n\n    /*!\n     *  Check if the CPU file should be written.\n     *\n     *    @return True, if the CPU file should be written, false otherwise.\n     */\n    bool writeCpu();\n\n    /*!\n     *  Check if the memory file should be written.\n     *\n     *    @return True, if the memory file should be written, false otherwise.\n     */\n    bool writeMemory();\n\n    /*!\n     *  Check if the peripherals file should be written.\n     *\n     *    @return True, if the peripherals file should be written, false otherwise.\n     */\n    bool writePeripherals();\n\n    /*!\n     *  Get the name of the CPU file.\n     *\n     *    @return Name of the CPU file.\n     */\n    QString getCpuFileName() const;\n\n    /*!\n     *  Get the current text in the CPU editor.\n     *\n     *    @return Current text in the CPU editor.\n     */\n    QString getCpuEditorText() const;\n\n    /*!\n     *  Get the name of the memory file.\n     *\n     *    @return Name of the memory file.\n     */\n    QString getmemoryFileName() const;\n\n    /*!\n     *  Get the current text in the memory editor.\n     *\n     *    @return Current text in the memory editor.\n     */\n    QString getMemoryEditorText() const;\n\n    /*!\n     *  Get the name of the peripherals file.\n     *\n     *    @return Name of the peripherals file.\n     */\n    QString getPeripheralFileName() const;\n\n    /*!\n     *  Get the current text in the peripherals editor.\n     *\n     *    @return Current text in the peripherals editor.\n     */\n    QString getPeripheralEditorText() const;\n\n    //! No copying. No assignment.\n    RenodeFileEditor(const RenodeFileEditor& other) = delete;\n    RenodeFileEditor& operator=(const RenodeFileEditor& other) = delete;\n\npublic slots:\n\n    /*!\n     *  Change the placeholder text in the file editors to match the new CPU name.\n     *\n     *    @param [in] newCpuName  The name of the new CPU.\n     */\n    void changeFileNames(QString const& newCpuName);\n\nprivate:\n\n    /*!\n     *  Template for getting the file name from the selected editor.\n     *\n     *    @param [in] editor  The selected file editor.\n     *\n     *    @return Name of the selected file.\n     */\n    template <typename fileEditor>\n    QString getFileName(fileEditor* editor) const;\n\n    /*!\n     *  Apply the configuration to file name editors.\n     *\n     *    @param [in] configurationObject     JSON object containing the editor configuration.\n     */\n    void applyConfigurations(QJsonObject const& configurationObject);\n\n    //-----------------------------------------------------------------------------\n    // Data.\n    //-----------------------------------------------------------------------------\n\n    //! Group for selecting files to generate.\n    RenodeFileSelectionGroup* fileSelectionGroup_;\n\n    //! Editor for CPU file name.\n    QLineEdit* cpuFileNameEditor_;\n\n    //! Editor for memory file name.\n    QLineEdit* memoryFileNameEditor_;\n\n    //! Editor for peripherals file name.\n    QLineEdit* peripheralFileNameEditor_;\n};\n\n#endif // RENODEFILEEDITOR_H\n"
  },
  {
    "path": "Plugins/RenodeGenerator/CPUDialog/RenodeFileSelectionGroup.cpp",
    "content": "﻿//-----------------------------------------------------------------------------\n// File: RenodeFileSelectionGroup.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 04.04.2023\n//\n// Description:\n// Group for selecting files to be written in Renode generation.\n//-----------------------------------------------------------------------------\n\n#include \"RenodeFileSelectionGroup.h\"\n\n#include <Plugins/RenodeGenerator/CPUDialog/RenodeUtilities.h>\n\n#include <QVBoxLayout>\n#include <QJsonObject>\n\n//-----------------------------------------------------------------------------\n// Function: RenodeFileSelectionGroup::RenodeFileSelectionGroup()\n//-----------------------------------------------------------------------------\nRenodeFileSelectionGroup::RenodeFileSelectionGroup(QJsonObject const& configurationObject, QWidget *parent):\nQGroupBox(parent),\nselectAll_(new QCheckBox(\"All\")),\ncpuCheck_(new QCheckBox(\"CPU\")),\nmemoryCheck_(new QCheckBox(\"Memory\")),\nperipheralsCheck_(new QCheckBox(\"Peripherals\")),\nboxStorage_()\n{\n    setTitle(\"Select files to write\");\n\n    boxStorage_.append(cpuCheck_);\n    boxStorage_.append(memoryCheck_);\n    boxStorage_.append(peripheralsCheck_);\n\n    selectAll_->setTristate(true);\n    selectAll_->setChecked(true);\n\n    connect(selectAll_, SIGNAL(clicked(bool)), this, SLOT(onCheckAllStateChange(bool)), Qt::UniqueConnection);\n\n    QFrame* line = new QFrame();\n    line->setLineWidth(1);\n    line->setMidLineWidth(1);\n    line->setFrameShape(QFrame::HLine);\n    line->setFrameShadow(QFrame::Sunken);\n    line->setContentsMargins(0, 0, 0, 0);\n\n    QVBoxLayout* checkBoxLayout(new QVBoxLayout(this));\n    checkBoxLayout->addWidget(selectAll_);\n    checkBoxLayout->addWidget(line);\n\n    for (auto box : boxStorage_)\n    {\n        connect(box, SIGNAL(clicked(bool)), this, SLOT(onItemClicked(bool)), Qt::UniqueConnection);\n\n        checkBoxLayout->addWidget(box);\n    }\n\n    applyConfigurations(configurationObject);\n}\n\n//-----------------------------------------------------------------------------\n// Function: RenodeFileSelectionGroup::applyConfigurations()\n//-----------------------------------------------------------------------------\nvoid RenodeFileSelectionGroup::applyConfigurations(QJsonObject const& configurationObject)\n{\n    bool writeCpuFlag = true;\n    bool writeMemoryFlag = true;\n    bool writePeripheralsFlag = true;\n\n    QJsonValue writeFlagsValue = configurationObject.value(RenodeConstants::WRITEFILES);\n    if (writeFlagsValue.type() == QJsonValue::Object)\n    {\n        QJsonObject writeFlagsObject = writeFlagsValue.toObject();\n\n        writeCpuFlag = writeFlagsObject.value(RenodeConstants::SINGLECPU).toBool(true);\n        writeMemoryFlag = writeFlagsObject.value(RenodeConstants::MEMORY).toBool(true);\n        writePeripheralsFlag = writeFlagsObject.value(RenodeConstants::PERIPHERALS).toBool(true);\n    }\n\n    cpuCheck_->setChecked(writeCpuFlag);\n    memoryCheck_->setChecked(writeMemoryFlag);\n    peripheralsCheck_->setChecked(writePeripheralsFlag);\n\n    onItemClicked(writePeripheralsFlag);\n}\n\n//-----------------------------------------------------------------------------\n// Function: RenodeFileSelectionGroup::onCheckAllStateChange()\n//-----------------------------------------------------------------------------\nvoid RenodeFileSelectionGroup::onCheckAllStateChange(bool newState)\n{\n    if (newState == true)\n    {\n        selectAll_->setChecked(true);\n        selectAll_->repaint();\n    }\n\n    cpuCheck_->setChecked(newState);\n    memoryCheck_->setChecked(newState);\n    peripheralsCheck_->setChecked(newState);\n}\n\n//-----------------------------------------------------------------------------\n// Function: RenodeFileSelectionGroup::onItemClicked()\n//-----------------------------------------------------------------------------\nvoid RenodeFileSelectionGroup::onItemClicked(bool newState)\n{\n    Qt::CheckState checkAllState = Qt::Checked;\n    if (newState == false)\n    {\n        checkAllState = Qt::Unchecked;\n    }\n\n    for (auto box : boxStorage_)\n    {\n        if (box->isChecked() != newState)\n        {\n            checkAllState = Qt::PartiallyChecked;\n            break;\n        }\n    }\n\n    selectAll_->setCheckState(checkAllState);\n    selectAll_->repaint();\n}\n\n//-----------------------------------------------------------------------------\n// Function: RenodeFileSelectionGroup::writeCpu()\n//-----------------------------------------------------------------------------\nbool RenodeFileSelectionGroup::writeCpu()\n{\n    return cpuCheck_->isChecked();\n}\n\n//-----------------------------------------------------------------------------\n// Function: RenodeFileSelectionGroup::writeMemory()\n//-----------------------------------------------------------------------------\nbool RenodeFileSelectionGroup::writeMemory()\n{\n    return memoryCheck_->isChecked();\n}\n\n//-----------------------------------------------------------------------------\n// Function: RenodeFileSelectionGroup::writePeripherals()\n//-----------------------------------------------------------------------------\nbool RenodeFileSelectionGroup::writePeripherals()\n{\n    return peripheralsCheck_->isChecked();\n}\n"
  },
  {
    "path": "Plugins/RenodeGenerator/CPUDialog/RenodeFileSelectionGroup.h",
    "content": "//-----------------------------------------------------------------------------\n// File: RenodeFileSelectionGroup.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 04.04.2023\n//\n// Description:\n// Group for selecting files to be written in Renode generation.\n//-----------------------------------------------------------------------------\n\n#ifndef RENODEFILESELECTIONGROUP_H\n#define RENODEFILESELECTIONGROUP_H\n\n#include <QCheckBox>\n#include <QGroupBox>\n#include <QObject>\n#include <QJsonObject>\n\n//-----------------------------------------------------------------------------\n//! Group for selecting files to be written in Renode generation.\n//-----------------------------------------------------------------------------\nclass RenodeFileSelectionGroup : public QGroupBox\n{\n    Q_OBJECT\n\npublic:\n\n    /*!\n     *  The constructor.\n     *\n     *    @param [in] configurationObject     JSON object containing the editor configuration.\n     *    @param [in] parent                  Pointer to the owner of this widget.\n     */\n    RenodeFileSelectionGroup(QJsonObject const& configurationObject, QWidget* parent = 0);\n\n    /*!\n     *  The destructor.\n     */\n    virtual ~RenodeFileSelectionGroup() = default;\n\n    /*!\n     *  Check if the CPU file should be written.\n     *\n     *    @return True, if the CPU file should be written, false otherwise.\n     */\n    bool writeCpu();\n\n    /*!\n     *  Check if the memory file should be written.\n     *\n     *    @return True, if the memory file should be written, false otherwise.\n     */\n    bool writeMemory();\n\n    /*!\n     *  Check if the peripherals file should be written.\n     *\n     *    @return True, if the peripherals file should be written, false otherwise.\n     */\n    bool writePeripherals();\n\n\n    //! No copying. No assignment.\n    RenodeFileSelectionGroup(const RenodeFileSelectionGroup& other) = delete;\n    RenodeFileSelectionGroup& operator=(const RenodeFileSelectionGroup& other) = delete;\n\nprivate slots:\n\n    /*!\n     *  Handle the state change in all check boxes.\n     *\n     *    @param [in] newState    The new state.\n     */\n    void onCheckAllStateChange(bool newState);\n\n    /*!\n     *  Handle the state change in a single check box. Change the state in the select all -check box accordingly.\n     *\n     *    @param [in] newState    The new state.\n     */\n    void onItemClicked(bool newState);\n\nprivate:\n\n    /*!\n     *  Apply the configuration to file selections.\n     *\n     *    @param [in] configurationObject     JSON object containing the editor configuration.\n     */\n    void applyConfigurations(QJsonObject const& configurationObject);\n\n    //-----------------------------------------------------------------------------\n    // Data.\n    //-----------------------------------------------------------------------------\n\n    //! Check box for selecting all the other check boxes.\n    QCheckBox* selectAll_;\n\n    //! Check box for selecting the CPU file to be written.\n    QCheckBox* cpuCheck_;\n\n    //! Check box for selecting the memory file to be written.\n    QCheckBox* memoryCheck_;\n    \n    //! Check box for selecting the peripherals file to be written.\n    QCheckBox* peripheralsCheck_;\n\n    //! Container for ease of access to the check boxes.\n    QVector<QCheckBox*> boxStorage_;\n};\n\n#endif // RENODEFILESELECTIONGROUP_H\n"
  },
  {
    "path": "Plugins/RenodeGenerator/CPUDialog/RenodeMemoriesEditor.cpp",
    "content": "﻿//-----------------------------------------------------------------------------\n// File: RenodeMemoriesEditor.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 20.03.2023\n//\n// Description:\n// Editor for CPU memory details in renode generation.\n//-----------------------------------------------------------------------------\n\n#include \"RenodeMemoriesEditor.h\"\n\n#include <Plugins/RenodeGenerator/CPUDialog/RenodeMemoriesModel.h>\n\n#include <QSortFilterProxyModel>\n#include <QVBoxLayout>\n#include <QHeaderView>\n\n//-----------------------------------------------------------------------------\n// Function: RenodeMemoriesEditor::RenodeMemoriesEditor()\n//-----------------------------------------------------------------------------\nRenodeMemoriesEditor::RenodeMemoriesEditor(QWidget *parent):\nQWidget(parent),\nview_(new QTableView(this)),\nmodel_(new RenodeMemoriesModel(this))\n{\n    QSortFilterProxyModel* proxy(new QSortFilterProxyModel(this));\n    proxy->setSourceModel(model_);\n\n    view_->horizontalHeader()->setSectionResizeMode(QHeaderView::Interactive);\n    view_->horizontalHeader()->setStretchLastSection(true);\n    view_->verticalHeader()->hide();\n    view_->verticalHeader()->setDefaultSectionSize(fontMetrics().height() + 8);\n\n    view_->setModel(proxy);\n\n    QVBoxLayout* layout = new QVBoxLayout(this);\n    layout->addWidget(view_, 1);\n    layout->setContentsMargins(0, 0, 0, 0);\n}\n\n//-----------------------------------------------------------------------------\n// Function: RenodeMemoriesEditor::setupMemories()\n//-----------------------------------------------------------------------------\nvoid RenodeMemoriesEditor::setupMemories(QVector<QSharedPointer<RenodeStructs::cpuMemories>> memories)\n{\n    model_->setupMemories(memories);\n    view_->resizeColumnsToContents();\n}\n"
  },
  {
    "path": "Plugins/RenodeGenerator/CPUDialog/RenodeMemoriesEditor.h",
    "content": "//-----------------------------------------------------------------------------\n// File: RenodeMemoriesEditor.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 20.03.2023\n//\n// Description:\n// Editor for CPU memory details in renode generation.\n//-----------------------------------------------------------------------------\n\n#ifndef RENODEMEMORIESEDITOR_H\n#define RENODEMEMORIESEDITOR_H\n\n#include <QWidget>\n#include <QObject>\n#include <QTableView>\n\n#include <Plugins/RenodeGenerator/CPUDialog/RenodeStructs.h>\n\nclass RenodeMemoriesModel;\n\n//-----------------------------------------------------------------------------\n//! Editor for CPU memory details in renode generation.\n//-----------------------------------------------------------------------------\nclass RenodeMemoriesEditor : public QWidget\n{\n    Q_OBJECT\n\npublic:\n\n    /*!\n     *  The constructor.\n     *\n     *    @param [in] parent  Pointer to the owner of this widget.\n     */\n    RenodeMemoriesEditor(QWidget *parent = 0);\n\n    /*!\n     *  The destructor.\n     */\n    virtual ~RenodeMemoriesEditor() = default;\n\n    /*!\n     *  Setup the selected CPUs.\n     *\n     *    @param [in] memories    List of the available memory items.\n     */\n    void setupMemories(QVector<QSharedPointer<RenodeStructs::cpuMemories> > memories);\n\n    //! No copying. No assignment.\n    RenodeMemoriesEditor(const RenodeMemoriesEditor& other) = delete;\n    RenodeMemoriesEditor& operator=(const RenodeMemoriesEditor& other) = delete;\n\nprivate:\n\n    //-----------------------------------------------------------------------------\n    // Data.\n    //-----------------------------------------------------------------------------\n\n    //! The view for the table.\n    QTableView* view_;\n\n    //! The containing model.\n    RenodeMemoriesModel* model_;\n};\n\n#endif // RENODEMEMORIESEDITOR_H\n"
  },
  {
    "path": "Plugins/RenodeGenerator/CPUDialog/RenodeMemoriesModel.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: RenodeMemoriesModel.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 20.03.2023\n//\n// Description:\n// The model to manage the Renode memory details.\n//-----------------------------------------------------------------------------\n\n#include \"RenodeMemoriesModel.h\"\n\n#include <common/KactusColors.h>\n\n#include <Plugins/RenodeGenerator/CPUDialog/RenodeColumns.h>\n\n#include <QColor>\n\n//-----------------------------------------------------------------------------\n// Function: RenodeMemoriesModel::RenodeMemoriesModel()\n//-----------------------------------------------------------------------------\nRenodeMemoriesModel::RenodeMemoriesModel(QObject *parent):\nQAbstractTableModel(parent),\nmemories_()\n{\n}\n\n//-----------------------------------------------------------------------------\n// Function: RenodeMemoriesModel::setupMemories()\n//-----------------------------------------------------------------------------\nvoid RenodeMemoriesModel::setupMemories(QVector<QSharedPointer<RenodeStructs::cpuMemories>> newMemories)\n{\n    beginResetModel();\n\n    memories_.clear();\n    memories_ = newMemories;\n\n    endResetModel();\n}\n\n//-----------------------------------------------------------------------------\n// Function: RenodeMemoriesModel::rowCount()\n//-----------------------------------------------------------------------------\nint RenodeMemoriesModel::rowCount(QModelIndex const& parent) const\n{\n\tif (parent.isValid())\n    {\n\t\treturn 0;\n\t}\n\n    return memories_.count();\n}\n\n//-----------------------------------------------------------------------------\n// Function: RenodeMemoriesModel::columnCount()\n//-----------------------------------------------------------------------------\nint RenodeMemoriesModel::columnCount(QModelIndex const& parent) const\n{\n\tif (parent.isValid())\n    {\n\t\treturn 0;\n\t}\n\n    return MemoryColumns::COLUMN_COUNT;\n}\n\n//-----------------------------------------------------------------------------\n// Function: RenodeMemoriesModel::flags()\n//-----------------------------------------------------------------------------\nQt::ItemFlags RenodeMemoriesModel::flags(QModelIndex const& index) const\n{\n\tif (!index.isValid() || index.column() == MemoryColumns::NAME || index.column() == MemoryColumns::BASEADDRESS || index.column() == MemoryColumns::SIZE)\n    {\n\t\treturn Qt::NoItemFlags;\n\t}\n    else\n    {\n        return Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsEditable;\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: RenodeMemoriesModel::headerData()\n//-----------------------------------------------------------------------------\nQVariant RenodeMemoriesModel::headerData(int section, Qt::Orientation orientation, int role) const\n{\n\tif (orientation != Qt::Horizontal)\n    {\n\t\treturn QVariant();\n\t}\n\n\tif (Qt::DisplayRole == role)\n    {\n        if (section == MemoryColumns::NAME)\n        {\n            return tr(\"Memory\");\n        }\n        else if (section == MemoryColumns::CLASS)\n        {\n            return tr(\"Class\");\n        }\n        else if (section == MemoryColumns::BASEADDRESS)\n        {\n            return tr(\"Base address\");\n        }\n        else if (section == MemoryColumns::SIZE)\n        {\n            return tr(\"Size\");\n        }\n\t}\n    \n    return QVariant();\n}\n\n//-----------------------------------------------------------------------------\n// Function: RenodeMemoriesModel::data()\n//-----------------------------------------------------------------------------\nQVariant RenodeMemoriesModel::data(QModelIndex const& index, int role) const\n{\n    if (!index.isValid() || index.row() < 0 || index.row() >= memories_.size())\n    {\n\t\treturn QVariant();\n\t}\n\n    if (role == Qt::DisplayRole || role == Qt::EditRole)\n    {\n        return valueForIndex(index);\n    }\n    else if (role == Qt::ToolTipRole)\n    {\n        return tooltipForIndex(index);\n    }\n\telse if (role == Qt::ForegroundRole)\n    {\n        if (index.column() == MemoryColumns::NAME || index.column() == MemoryColumns::BASEADDRESS || index.column() == MemoryColumns::SIZE)\n        {\n            return KactusColors::DISABLED_TEXT;\n        }\n        else\n        {\n            return KactusColors::REGULAR_TEXT;\n        }\n    }\n\n    return QVariant();\n}\n\n//-----------------------------------------------------------------------------\n// Function: RenodeMemoriesModel::setData()\n//-----------------------------------------------------------------------------\nbool RenodeMemoriesModel::setData(QModelIndex const& index, QVariant const& value, int role)\n{\n    if (!index.isValid() || index.row() < 0 || index.row() >= memories_.size())\n    {\n\t\treturn false;\n\t}\n\n    QSharedPointer<RenodeStructs::cpuMemories> indexedMemory = memories_.at(index.row());\n    if (Qt::EditRole == role)\n    {\n        if (index.column() == MemoryColumns::CLASS)\n        {\n            indexedMemory->className_ = value.toString();\n        }\n\n        emit dataChanged(index, index);\n        return true;\n    }\n\n    return false;\n}\n\n//-----------------------------------------------------------------------------\n// Function: RenodeMemoriesModel::valueForIndex()\n//-----------------------------------------------------------------------------\nQVariant RenodeMemoriesModel::valueForIndex(QModelIndex const& index) const\n{\n    QSharedPointer<RenodeStructs::cpuMemories> indexedMemory = memories_.at(index.row());\n\n    if (index.column() == MemoryColumns::NAME)\n    {\n        return indexedMemory->memoryName_;\n    }\n    else if (index.column() == MemoryColumns::CLASS)\n    {\n        return indexedMemory->className_;\n    }\n    else if (index.column() == MemoryColumns::BASEADDRESS)\n    {\n        return indexedMemory->baseAddress_;\n    }\n    else if (index.column() == MemoryColumns::SIZE)\n    {\n        return indexedMemory->size_;\n    }\n\n    return QVariant();\n}\n\n//-----------------------------------------------------------------------------\n// Function: RenodeMemoriesModel::tooltipForIndex()\n//-----------------------------------------------------------------------------\nQVariant RenodeMemoriesModel::tooltipForIndex(QModelIndex const& index) const\n{\n    if (index.column() == MemoryColumns::NAME)\n    {\n        return QString(\"Name of the memory\");\n    }\n    else if (index.column() == PeripheralColumns::CLASS)\n    {\n        return QString(\"The type name.\");\n    }\n    else if (index.column() == MemoryColumns::BASEADDRESS)\n    {\n        return QString(\"Base address of the memory as a hexadecimal value.\");\n    }\n    else if (index.column() == MemoryColumns::SIZE)\n    {\n        return QString(\"Size of the memory as a hexadecimal value.\");\n    }\n\n    return QVariant();\n}\n"
  },
  {
    "path": "Plugins/RenodeGenerator/CPUDialog/RenodeMemoriesModel.h",
    "content": "//-----------------------------------------------------------------------------\n// File: RenodeMemoriesModel.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 20.03.2023\n//\n// Description:\n// The model to manage the Renode memory details.\n//-----------------------------------------------------------------------------\n\n#ifndef RENODEMEMORIESMODEL_H\n#define RENODEMEMORIESMODEL_H\n\n#include <Plugins/common/ConnectivityGraphUtilities.h>\n#include <Plugins/RenodeGenerator/CPUDialog/RenodeStructs.h>\n\n#include <QAbstractTableModel>\n#include <QSharedPointer>\n\n//-----------------------------------------------------------------------------\n//! The model to manage the Renode memory details.\n//-----------------------------------------------------------------------------\nclass RenodeMemoriesModel : public QAbstractTableModel\n{\n\tQ_OBJECT\n\npublic:\n\n\t/*!\n\t *  The constructor.\n\t *\n\t *    @param [in] parent  Pointer to the owner of this model.\n\t */\n    RenodeMemoriesModel(QObject *parent);\n\t\n\t/*!\n     *  The destructor.\n     */\n    virtual ~RenodeMemoriesModel() = default;\n\n    /*!\n     *  Setup the selected memory items.\n     *\n     *    @param [in] newMemories     The selected memory items.\n     */\n    void setupMemories(QVector<QSharedPointer<RenodeStructs::cpuMemories> > newMemories);\n\n\t/*!\n     *  Get the number of rows an item contains.\n\t *\n\t *    @param [in] parent  Identifies the parent that's row count is requested.\n\t *\n\t *    @return Number of rows the item has.\n\t */\n\tvirtual int rowCount(QModelIndex const& parent = QModelIndex()) const;\n\n\t/*!\n     *  Get the number of columns the item has to be displayed.\n\t *\n\t *    @param [in] parent  Identifies the parent that's column count is requested.\n\t *\n\t *    @return The number of columns to be displayed.\n\t */\n\tvirtual int columnCount(QModelIndex const& parent = QModelIndex()) const;\n\n\t/*!\n     *  Get the item flags that defines the possible operations for the item.\n\t *\n\t *    @param [in] index   Model index that identifies the item.\n\t *\n\t *    @return Qt::ItemFlags specify the possible operations for the item.\n\t */\n\tQt::ItemFlags flags(QModelIndex const& index) const;\n\n\t/*!\n     *  Get the header data for specified header.\n\t *\n\t *    @param [in] section         The section specifies the row/column number for the header.\n\t *    @param [in] orientation     Specified if horizontal or vertical header is wanted.\n\t *    @param [in] role            Specifies the type of the requested data.\n\t *\n\t *    @return QVariant Contains the requested data.\n\t */\n\tvirtual QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;\n\n\t/*!\n     *  Get the data for specified item.\n\t *\n\t *    @param [in] index   Specifies the item that's data is requested.\n\t *    @param [in] role    The role that defines what kind of data is requested.\n\t *\n\t *    @return QVariant Contains the data for the item.\n\t */\n\tvirtual QVariant data(QModelIndex const& index, int role = Qt::DisplayRole) const;\n\n\t/*!\n     *  Save the data to the model for specified item.\n\t *\n\t *    @param [in] index   The model index of the item that's data is to be saved.\n\t *    @param [in] value   The data that is to be saved.\n\t *    @param [in] role    The role specifies what kind of data should be saved.\n\t *\n\t *    @return True if saving happened successfully.\n\t */\n\tbool setData(QModelIndex const& index, const QVariant& value, int role = Qt::EditRole);\n    \n    //! No copying. No assignment.\n    RenodeMemoriesModel(const RenodeMemoriesModel& other) = delete;\n    RenodeMemoriesModel& operator=(const RenodeMemoriesModel& other) = delete;\n\nprivate:\n\t\n    /*!\n     *  Gets the value for the given index.\n     *\n     *    @param [in] index   The index of the target data.\n     *\n     *    @return The data in the given index.\n     */\n    QVariant valueForIndex(QModelIndex const& index) const;\n\n    /*!\n     *  Gets the tooltip value for the given index.\n     *\n     *    @param [in] index   The index of the target data.\n     *\n     *    @return The tooltip data in the given index.\n     */\n    QVariant tooltipForIndex(QModelIndex const& index) const;\n\n    //-----------------------------------------------------------------------------\n    // Data.\n    //-----------------------------------------------------------------------------\n\n    //! The memory items being edited.\n    QVector<QSharedPointer<RenodeStructs::cpuMemories> > memories_;\n};\n\n#endif // RENODEMEMORIESMODEL_H\n"
  },
  {
    "path": "Plugins/RenodeGenerator/CPUDialog/RenodePeripheralsDelegate.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: RenodePeripheralsDelegate.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 03.03.2023\n//\n// Description:\n// The delegate that provides editors to edit Renode peripheral details.\n//-----------------------------------------------------------------------------\n\n#include \"RenodePeripheralsDelegate.h\"\n\n#include <Plugins/RenodeGenerator/CPUDialog/RenodeColumns.h>\n#include <Plugins/RenodeGenerator/CPUDialog/RenodeConstants.h>\n#include <Plugins/RenodeGenerator/CPUDialog/RenodeUtilities.h>\n\n#include <common/KactusColors.h>\n\n#include <QApplication>\n#include <QMouseEvent>\n#include <QPainter>\n#include <QComboBox>\n#include <QDir>\n#include <QCoreApplication>\n#include <QFileDialog>\n\n//-----------------------------------------------------------------------------\n// Function: RenodePeripheralsDelegate::RenodePeripheralsDelegate()\n//-----------------------------------------------------------------------------\nRenodePeripheralsDelegate::RenodePeripheralsDelegate(QWidget* parentWidget):\nQStyledItemDelegate(parentWidget),\nparentWidget_(parentWidget)\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: RenodePeripheralsDelegate::setupTemplates()\n//-----------------------------------------------------------------------------\nvoid RenodePeripheralsDelegate::setupTemplates(QVector<QSharedPointer<RenodeStructs::peripheralTemplate> > newTemplates)\n{\n    pythonTemplates_ = newTemplates;\n}\n\n//-----------------------------------------------------------------------------\n// Function: RenodePeripheralsDelegate::onFolderChanged()\n//-----------------------------------------------------------------------------\nvoid RenodePeripheralsDelegate::onFolderChanged(QString const& newFolder)\n{\n    generatorTargetFolder_ = newFolder;\n}\n\n//-----------------------------------------------------------------------------\n// Function: RenodePeripheralsDelegate::createEditor()\n//-----------------------------------------------------------------------------\nQWidget* RenodePeripheralsDelegate::createEditor(QWidget* parent, QStyleOptionViewItem const& option,\n    QModelIndex const& index) const\n{\n    if (index.column() == PeripheralColumns::CLASS || index.column() == PeripheralColumns::TEMPLATE)\n    {\n        auto editor(new QComboBox(parent));\n        return editor;\n    }\n    else\n    {\n        return QStyledItemDelegate::createEditor(parent, option, index);\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: RenodePeripheralsDelegate::setEditorData()\n//-----------------------------------------------------------------------------\nvoid RenodePeripheralsDelegate::setEditorData(QWidget* editor, QModelIndex const& index) const\n{\n    if (index.column() == PeripheralColumns::CLASS || index.column() == PeripheralColumns::TEMPLATE)\n    {\n\t\tauto comboEditor = dynamic_cast<QComboBox*>(editor);\n        if (comboEditor)\n        {\n            if (index.column() == PeripheralColumns::CLASS)\n            {\n\t\t\t\tcomboEditor->setEditable(true);\n                QString filePath = QCoreApplication::applicationDirPath() + \"/assets/peripherals.txt\";\n\t\t\t\tif (QFile peripheralClassFile(filePath); peripheralClassFile.open(QIODevice::ReadOnly))\n\t\t\t\t{\n\t\t\t\t\tQTextStream fileStream(&peripheralClassFile);\n\t\t\t\t\twhile (!fileStream.atEnd())\n\t\t\t\t\t{\n                        comboEditor->addItem(fileStream.readLine());\n\t\t\t\t\t}\n\n\t\t\t\t\tperipheralClassFile.close();\n\t\t\t\t}\n            }\n\t\t\telse if (index.column() == PeripheralColumns::TEMPLATE)\n\t\t\t{\n\t\t\t\tQStringList templateNames = { \"\" };\n\t\t\t\ttemplateNames.append(RenodeUtilities::getTemplateNames(pythonTemplates_));\n\t\t\t\tcomboEditor->addItems(templateNames);\n\t\t\t}\n\n            QString currentItem = index.data(Qt::DisplayRole).toString();\n\t\t\tcomboEditor->setCurrentIndex(comboEditor->findText(currentItem));\n        }\n    }\n    else\n    {\n        QStyledItemDelegate::setEditorData(editor, index);\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: RenodePeripheralsDelegate::editorEvent()\n//-----------------------------------------------------------------------------\nbool RenodePeripheralsDelegate::editorEvent(QEvent *event, QAbstractItemModel* model, QStyleOptionViewItem const& option,\n    QModelIndex const& index)\n{\n    Q_ASSERT(event);\n    Q_ASSERT(model);\n\n    // Always reset the ad-hoc group modify flag.\n    if (event->type() == QEvent::MouseButtonRelease)\n    {\n        booleanModify_ = false;\n        if (index.column() == PeripheralColumns::FILEPATH)\n        {\n            return handleEditorEventForPath(event, model, option, index);\n        }\n    }\n\n    // Make sure that the item is checkable.\n\tif (Qt::ItemFlags flags = model->flags(index); !(flags & Qt::ItemIsUserCheckable) || !(flags & Qt::ItemIsEnabled))\n    {\n        return false;\n    }\n\n    // Make sure that we have a check state.\n    QVariant value = index.data(Qt::CheckStateRole);\n\n    if (!value.isValid())\n    {\n        return false;\n    }\n\n\tauto newState = static_cast<Qt::CheckState>(value.toInt());\n\n    // Handle the mouse button events.\n    if (event->type() == QEvent::MouseButtonPress)\n    {\n        const int textMargin = QApplication::style()->pixelMetric(QStyle::PM_FocusFrameHMargin) + 1;\n\n        QRect checkRect = QStyle::alignedRect(option.direction, Qt::AlignCenter,\n            option.decorationSize,\n            QRect(option.rect.x() + (2 * textMargin), option.rect.y(),\n            option.rect.width() - (2 * textMargin),\n            option.rect.height()));\n\n        if (!checkRect.contains(static_cast<QMouseEvent*>(event)->pos()))\n        {\n            return false;\n        }\n\n        newState = (static_cast<Qt::CheckState>(value.toInt()) == Qt::Checked ? Qt::Unchecked : Qt::Checked);\n        booleanModify_ = true;\n        booleanState_ = newState;\n    }\n    else if (event->type() == QEvent::MouseMove)\n    {\n        if (!booleanModify_ || static_cast<Qt::CheckState>(value.toInt()) == booleanState_)\n        {\n            return false;\n        }\n\n        const int textMargin = QApplication::style()->pixelMetric(QStyle::PM_FocusFrameHMargin) + 1;\n\n        QRect checkRect = QStyle::alignedRect(option.direction, Qt::AlignCenter,\n            option.decorationSize,\n            QRect(option.rect.x() + (2 * textMargin), option.rect.y(),\n            option.rect.width() - (2 * textMargin),\n            option.rect.height()));\n\n        if (!checkRect.contains(static_cast<QMouseEvent*>(event)->pos()))\n        {\n            return false;\n        }\n        \n        newState = booleanState_;\n    }\n    else if (event->type() == QEvent::KeyPress)\n    {\n        if (static_cast<QKeyEvent*>(event)->key() != Qt::Key_Space &&\n            static_cast<QKeyEvent*>(event)->key() != Qt::Key_Select)\n        {\n            return false;\n        }\n    }\n    else\n    {\n        return false;\n    }\n\n    return model->setData(index, newState, Qt::CheckStateRole);\n}\n\n//-----------------------------------------------------------------------------\n// Function: RenodePeripheralsDelegate::paint()\n//-----------------------------------------------------------------------------\nvoid RenodePeripheralsDelegate::paint(QPainter* painter, QStyleOptionViewItem const& option, QModelIndex const& index) const\n{\n\tQStyleOptionViewItem viewItemOption(option);\n\n    if (index.column() == PeripheralColumns::INITABLE)\n    {\n        QColor rectangleColor = KactusColors::REGULAR_FIELD;\n\n        QModelIndex classIndex = index.sibling(index.row(), PeripheralColumns::CLASS);\n\t\tif (auto peripheralClass = classIndex.data(Qt::DisplayRole).toString(); peripheralClass != RenodeConstants::PYTHONPERIPHERAL)\n        {\n            rectangleColor = KactusColors::DISABLED_FIELD;\n        }\n\n        painter->fillRect(option.rect, rectangleColor);\n\n        const int textMargin = QApplication::style()->pixelMetric(QStyle::PM_FocusFrameHMargin) + 1;\n\n        QRect newRect = QStyle::alignedRect(option.direction, Qt::AlignCenter,\n                                            QSize(option.decorationSize.width() + 5, option.decorationSize.height()),\n                                            QRect(option.rect.x() + textMargin, option.rect.y(),\n                                                  option.rect.width() - (2 * textMargin), option.rect.height()));\n        viewItemOption.rect = newRect;\n    }\n\n    QStyledItemDelegate::paint(painter, viewItemOption, index);\n}\n\n//-----------------------------------------------------------------------------\n// Function: RenodePeripheralsDelegate::handleEditorEventForPath()\n//-----------------------------------------------------------------------------\nbool RenodePeripheralsDelegate::handleEditorEventForPath(QEvent* event, QAbstractItemModel* model, QStyleOptionViewItem const& option, QModelIndex const& index)\n{\n    const int textMargin = QApplication::style()->pixelMetric(QStyle::PM_FocusFrameHMargin) + 1;\n    \n    QRect rectangleIsinideCheckRect(option.rect.x() + (2 * textMargin),\n        option.rect.y(),\n        option.rect.width() - (2 * textMargin),\n        option.rect.height());\n    \n    QRect checkRect = QStyle::alignedRect(option.direction, Qt::AlignLeft, option.decorationSize, rectangleIsinideCheckRect);\n    if (checkRect.contains(static_cast<QMouseEvent*>(event)->pos()))\n    {\n        QString newPath = \"\";\n        newPath = QFileDialog::getExistingDirectory(parentWidget_, tr(\"Open Directory\"), generatorTargetFolder_,\n            QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks);\n\n        if (!newPath.isEmpty())\n        {\n            QDir appDirectory(generatorTargetFolder_);\n            newPath = appDirectory.relativeFilePath(newPath);\n        }\n\n        if (!newPath.isEmpty())\n        {\n            model->setData(index, newPath);\n        }\n\n        return true;\n    }\n\n    return QStyledItemDelegate::editorEvent(event, model, option, index);\n}\n"
  },
  {
    "path": "Plugins/RenodeGenerator/CPUDialog/RenodePeripheralsDelegate.h",
    "content": "//-----------------------------------------------------------------------------\n// File: RenodePeripheralsDelegate.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 03.03.2023\n//\n// Description:\n// The delegate that provides editors to edit Renode peripheral details.\n//-----------------------------------------------------------------------------\n\n#ifndef RENODEPERIPHERALSDELEGATE_H\n#define RENODEPERIPHERALSDELEGATE_H\n\n#include <Plugins/RenodeGenerator/CPUDialog/RenodeStructs.h>\n\n#include <QCompleter>\n#include <QStyledItemDelegate>\n\nclass Component;\nclass LibraryInterface;\n\n//-----------------------------------------------------------------------------\n//! The delegate that provides editors to edit Renode peripheral details.\n//-----------------------------------------------------------------------------\nclass RenodePeripheralsDelegate : public QStyledItemDelegate\n{\n\tQ_OBJECT\n\npublic:\n\n    /*!\n     *  The constructor.\n     * \n     *    @param [in] parentWidget    The parent widget.\n     */\n    RenodePeripheralsDelegate(QWidget* parentWidget);\n\n\t/*!\n     *  The destructor.\n     */\n    virtual ~RenodePeripheralsDelegate() = default;\n\n    /*!\n     *  Setup the available peripheral templates.\n     *\t\n     *    @param [in] newTemplates    List of the available peripheral templates.\n     */\n    void setupTemplates(QVector<QSharedPointer<RenodeStructs::peripheralTemplate> > newTemplates);\n\n\t/*!\n     *  Create a new editor for the given item\n\t *\n\t *    @param [in] parent  Owner for the editor.\n\t *    @param [in] option  Contains options for the editor.\n\t *    @param [in] index   Model index identifying the item.\n\t *\n\t *    @return The editor to be used to edit the item.\n     */\n\tvirtual QWidget* createEditor(QWidget* parent, QStyleOptionViewItem const& option, QModelIndex const& index)\n        const;\n\n\t/*!\n     *  Set the data for the editor.\n\t *\n\t *    @param [in] editor  The editor where the data is to be set.\n\t *    @param [in] index   Model index identifying the item that's data is to be set.\n     */\n\tvirtual void setEditorData(QWidget* editor, QModelIndex const& index) const;\n\n\t/*!\n\t *  Renders an item in the given index.\n\t *\n\t *    @param [in] painter     The painter to use for rendering.\n\t *    @param [in] option      The style options for the rendering.\n\t *    @param [in] index       The index to the data being rendered.\n\t */\n\tvirtual void paint(QPainter* painter, QStyleOptionViewItem const& option, QModelIndex const& index) const;\n\n    // Disable copying.\n    RenodePeripheralsDelegate(RenodePeripheralsDelegate const& rhs) = delete;\n    RenodePeripheralsDelegate& operator=(RenodePeripheralsDelegate const& rhs) = delete;\n\npublic slots:\n\n    /*!\n     *  Handle the change in file location.\n     *\n     *    @param [in] newFolder   The new location.\n     */\n    void onFolderChanged(QString const& newFolder);\n\nprotected:\n    \n    /*!\n     *  Handler for preprocessing events that starts editing.\n     *\n     *    @param [in] event   The event that triggered the editing.\n     *    @param [in] model   The underlying model to edit.\n     *    @param [in] option  Style options for rendering the item.\n     *    @param [in] index   The index being edited.\n     *\n     *    @return True, if the delegate handles the event, otherwise false.\n     */\n    virtual bool editorEvent(QEvent* event, QAbstractItemModel* model, QStyleOptionViewItem const& option, \n        QModelIndex const& index);\n\nprivate:\n\n    /*!\n     *  Handler for editor events in file path editor.\n     *\t\n     *    @param [in] event   The event that triggered the editing.\n     *    @param [in] model   The underlying model to edit.\n     *    @param [in] option  Style options for rendering the item.\n     *    @param [in] index   The index being edited.\n     *\n     *    @return True, if the event is handled, otherwise false.\n     */\n    bool handleEditorEventForPath(QEvent* event, QAbstractItemModel* model, QStyleOptionViewItem const& option, QModelIndex const& index);\n\n    //-----------------------------------------------------------------------------\n    // Data.\n    //-----------------------------------------------------------------------------\n\n    //! Boolean for boolean group modify.\n    bool booleanModify_ = false;\n\n    //! The new state for the boolean modify.\n    Qt::CheckState booleanState_ = Qt::Unchecked;\n\n    //! The current folder location.\n    QString generatorTargetFolder_ = QString(\"\");\n\n    //! List of the available peripheral templates.\n    QVector<QSharedPointer<RenodeStructs::peripheralTemplate> > pythonTemplates_;\n\n    //! The parent widget.\n    QWidget* parentWidget_;\n};\n\n#endif // RENODEPERIPHERALSDELEGATE_H\n"
  },
  {
    "path": "Plugins/RenodeGenerator/CPUDialog/RenodePeripheralsEditor.cpp",
    "content": "﻿//-----------------------------------------------------------------------------\n// File: RenodePeripheralsEditor.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 21.02.2023\n//\n// Description:\n// Editor for CPU peripheral details in renode generation.\n//-----------------------------------------------------------------------------\n\n#include \"RenodePeripheralsEditor.h\"\n\n#include <Plugins/RenodeGenerator/CPUDialog/RenodePeripheralsDelegate.h>\n#include <Plugins/RenodeGenerator/CPUDialog/RenodePeripheralsModel.h>\n#include <Plugins/RenodeGenerator/CPUDialog/TemplateEditor/PeripheralTemplatesDialog.h>\n#include <Plugins/RenodeGenerator/CPUDialog/TemplateEditor/PeripheralTemplateConfigurer.h>\n\n#include <QSortFilterProxyModel>\n#include <QVBoxLayout>\n#include <QHeaderView>\n#include <QPushButton>\n\n//-----------------------------------------------------------------------------\n// Function: RenodePeripheralsEditor::RenodePeripheralsEditor()\n//-----------------------------------------------------------------------------\nRenodePeripheralsEditor::RenodePeripheralsEditor(PeripheralTemplateConfigurer* templateConfigurer, QWidget* parent):\nQWidget(parent),\nview_(new QTableView(this)),\nmodel_(new RenodePeripheralsModel(this)),\nperipheralDelegate_(new RenodePeripheralsDelegate(parent)),\ntemplateConfigurer_(templateConfigurer)\n{\n    setupPeripheralTemplates(templateConfigurer_->getTemplates());\n\n    auto proxy(new QSortFilterProxyModel(this));\n    proxy->setSourceModel(model_);\n\n    view_->horizontalHeader()->setSectionResizeMode(QHeaderView::Interactive);\n    view_->horizontalHeader()->setStretchLastSection(true);\n    view_->verticalHeader()->hide();\n    view_->verticalHeader()->setDefaultSectionSize(fontMetrics().height() + 8);\n\n    view_->setModel(proxy);\n    view_->setItemDelegate(peripheralDelegate_);\n\n\tauto templatesButton(new QPushButton(\"Python peripheral templates\", this));\n\tconnect(templatesButton, SIGNAL(clicked()), this, SLOT(openTemplatesDialog()), Qt::UniqueConnection);\n\n    auto layout = new QVBoxLayout(this);\n    layout->addWidget(view_, 1);\n    layout->addWidget(templatesButton, 0, Qt::AlignLeft);\n    layout->setContentsMargins(0, 0, 0, 0);\n}\n\n//-----------------------------------------------------------------------------\n// Function: RenodePeripheralsEditor::setupPeripherals()\n//-----------------------------------------------------------------------------\nvoid RenodePeripheralsEditor::setupPeripherals(QVector<QSharedPointer<RenodeStructs::cpuPeripheral>> peripherals)\n{\n    model_->setupPeripherals(peripherals);\n    view_->resizeColumnsToContents();\n}\n\n//-----------------------------------------------------------------------------\n// Function: RenodePeripheralsEditor::setupFolderPath()\n//-----------------------------------------------------------------------------\nvoid RenodePeripheralsEditor::setupFolderPath(QString const& newFolderPath)\n{\n    generationFolder_ = newFolderPath;\n    peripheralDelegate_->onFolderChanged(newFolderPath);\n}\n\n//-----------------------------------------------------------------------------\n// Function: RenodePeripheralsEditor::openTemplatesDialog()\n//-----------------------------------------------------------------------------\nvoid RenodePeripheralsEditor::openTemplatesDialog()\n{\n    PeripheralTemplatesDialog templateDialog(generationFolder_, this);\n    templateDialog.setupTemplates(templateConfigurer_->getTemplates());\n\n    if (templateDialog.exec() == QDialog::Accepted)\n    {\n        QVector<QSharedPointer<RenodeStructs::peripheralTemplate> > newTemplates = templateDialog.getTemplates();\n        templateConfigurer_->setTemplates(newTemplates);\n        setupPeripheralTemplates(newTemplates);\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: RenodePeripheralsEditor::setupPeripheralTemplates()\n//-----------------------------------------------------------------------------\nvoid RenodePeripheralsEditor::setupPeripheralTemplates(QVector<QSharedPointer<RenodeStructs::peripheralTemplate>> templates)\n{\n    model_->setupTemplates(templates);\n    peripheralDelegate_->setupTemplates(templates);\n}\n"
  },
  {
    "path": "Plugins/RenodeGenerator/CPUDialog/RenodePeripheralsEditor.h",
    "content": "//-----------------------------------------------------------------------------\n// File: RenodePeripheralsEditor.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 21.02.2023\n//\n// Description:\n// Editor for CPU peripheral details in renode generation.\n//-----------------------------------------------------------------------------\n\n#ifndef RENODEPERIPHERALSEDITOR_H\n#define RENODEPERIPHERALSEDITOR_H\n\n#include <Plugins/RenodeGenerator/CPUDialog/RenodeStructs.h>\n\n#include <QWidget>\n#include <QObject>\n#include <QTableView>\n\nclass RenodePeripheralsModel;\nclass RenodePeripheralsDelegate;\nclass PeripheralTemplateConfigurer;\n\n//-----------------------------------------------------------------------------\n//! Editor for CPU peripheral details in renode generation.\n//-----------------------------------------------------------------------------\nclass RenodePeripheralsEditor : public QWidget\n{\n    Q_OBJECT\n\npublic:\n\n    /*!\n     *  The constructor.\n     *\n     *    @param [in] templateConfigurer  Handles configuration of peripheral templates.\n     *    @param [in] parent              Pointer to the owner of this widget.\n     */\n    RenodePeripheralsEditor(PeripheralTemplateConfigurer* templateConfigurer, QWidget* parent = 0);\n\n    /*!\n     *  The destructor.\n     */\n    virtual ~RenodePeripheralsEditor() = default;\n\n    /*!\n     *  Setup the selected peripherals.\n     *\n     *    @param [in] peripherals     The selected peripherals.\n     */\n    void setupPeripherals(QVector<QSharedPointer<RenodeStructs::cpuPeripheral> > peripherals);\n\n    /*!\n     *  Setup the folder path.\n     *\n     *    @param [in] newFolderPath   The new folder path.\n     */\n    void setupFolderPath(QString const& newFolderPath);\n\n    //! No copying. No assignment.\n    RenodePeripheralsEditor(const RenodePeripheralsEditor& other) = delete;\n    RenodePeripheralsEditor& operator=(const RenodePeripheralsEditor& other) = delete;\n\nprivate slots:\n\n\t/*!\n\t *  Open the peripherals template dialog.\n\t */\n\tvoid openTemplatesDialog();\n\nprivate:\n\n    /*!\n     *  Setup the peripheral templates.\n     *\t\n     *    @param [in] templates   List of new peripheral templates.\n     */\n    void setupPeripheralTemplates(QVector<QSharedPointer<RenodeStructs::peripheralTemplate> > templates);\n\n    //-----------------------------------------------------------------------------\n    // Data.\n    //-----------------------------------------------------------------------------\n\n    //! The view for the table.\n    QTableView* view_;\n\n    //! The containing model.\n    RenodePeripheralsModel* model_;\n\n    //! The delegate.\n    RenodePeripheralsDelegate* peripheralDelegate_;\n\n    //! Target folder for the Renode generator.\n    QString generationFolder_;\n\n    //! Configurer for peripheral templates.\n    PeripheralTemplateConfigurer* templateConfigurer_;\n};\n\n#endif // RENODEPERIPHERALSEDITOR_H\n"
  },
  {
    "path": "Plugins/RenodeGenerator/CPUDialog/RenodePeripheralsModel.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: RenodePeripheralsModel.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 24.02.2023\n//\n// Description:\n// The model to manage the Renode peripheral details.\n//-----------------------------------------------------------------------------\n\n#include \"RenodePeripheralsModel.h\"\n\n#include <common/KactusColors.h>\n\n#include <QColor>\n#include <QIcon>\n#include <QDir>\n\n#include <Plugins/RenodeGenerator/CPUDialog/RenodeColumns.h>\n#include <Plugins/RenodeGenerator/CPUDialog/RenodeUtilities.h>\n\n//-----------------------------------------------------------------------------\n// Function: RenodePeripheralsModel::RenodePeripheralsModel()\n//-----------------------------------------------------------------------------\nRenodePeripheralsModel::RenodePeripheralsModel(QObject *parent):\nQAbstractTableModel(parent)\n{\n}\n\n//-----------------------------------------------------------------------------\n// Function: RenodePeripheralsModel::setupPeripherals()\n//-----------------------------------------------------------------------------\nvoid RenodePeripheralsModel::setupPeripherals(QVector<QSharedPointer<RenodeStructs::cpuPeripheral>> newPeripherals)\n{\n    beginResetModel();\n\n    peripherals_.clear();\n    peripherals_ = newPeripherals;\n\n    endResetModel();\n}\n\n//-----------------------------------------------------------------------------\n// Function: RenodePeripheralsModel::setupTemplates()\n//-----------------------------------------------------------------------------\nvoid RenodePeripheralsModel::setupTemplates(QVector<QSharedPointer<RenodeStructs::peripheralTemplate> > newTemplates)\n{\n    pythonTemplates_ = newTemplates;\n}\n\n//-----------------------------------------------------------------------------\n// Function: RenodePeripheralsModel::rowCount()\n//-----------------------------------------------------------------------------\nint RenodePeripheralsModel::rowCount(QModelIndex const& parent) const\n{\n\tif (parent.isValid())\n    {\n\t\treturn 0;\n\t}\n\n    return peripherals_.count();\n}\n\n//-----------------------------------------------------------------------------\n// Function: RenodePeripheralsModel::columnCount()\n//-----------------------------------------------------------------------------\nint RenodePeripheralsModel::columnCount(QModelIndex const& parent) const\n{\n\tif (parent.isValid())\n    {\n\t\treturn 0;\n\t}\n\n    return PeripheralColumns::COLUMN_COUNT;\n}\n\n//-----------------------------------------------------------------------------\n// Function: RenodePeripheralsModel::flags()\n//-----------------------------------------------------------------------------\nQt::ItemFlags RenodePeripheralsModel::flags(QModelIndex const& index) const\n{\n\tif (!index.isValid() || index.column() == PeripheralColumns::NAME || index.column() == PeripheralColumns::BASEADDRESS || index.column() == PeripheralColumns::SIZE)\n    {\n\t\treturn Qt::NoItemFlags;\n\t}\n\n    Qt::ItemFlags flags = Qt::ItemIsEnabled | Qt::ItemIsSelectable;\n    if (index.column() == PeripheralColumns::INITABLE)\n    {\n        flags |= Qt::ItemIsUserCheckable;\n    }\n    else\n    {\n        flags |= Qt::ItemIsEditable;\n    }\n\n    return flags;\n}\n\n//-----------------------------------------------------------------------------\n// Function: RenodePeripheralsModel::headerData()\n//-----------------------------------------------------------------------------\nQVariant RenodePeripheralsModel::headerData(int section, Qt::Orientation orientation, int role) const\n{\n\tif (orientation != Qt::Horizontal)\n    {\n\t\treturn QVariant();\n\t}\n\n\tif (Qt::DisplayRole == role)\n    {\n        if (section == PeripheralColumns::NAME)\n        {\n            return tr(\"Peripheral\");\n        }\n        else if (section == PeripheralColumns::CLASS)\n        {\n            return tr(\"Class\");\n        }\n        else if (section == PeripheralColumns::BASEADDRESS)\n        {\n            return tr(\"Base address\");\n        }\n        else if (section == PeripheralColumns::SIZE)\n        {\n            return tr(\"Size\");\n        }\n        else if (section == PeripheralColumns::INITABLE)\n        {\n            return tr(\"Initable\");\n        }\n        else if (section == PeripheralColumns::TEMPLATE)\n        {\n            return tr(\"Template\");\n        }\n        else if (section == PeripheralColumns::FILEPATH)\n        {\n            return tr(\"File path\");\n        }\n\t}\n    \n    return QVariant();\n}\n\n//-----------------------------------------------------------------------------\n// Function: RenodePeripheralsModel::data()\n//-----------------------------------------------------------------------------\nQVariant RenodePeripheralsModel::data(QModelIndex const& index, int role) const\n{\n    if (!index.isValid() || index.row() < 0 || index.row() >= peripherals_.size())\n    {\n\t\treturn QVariant();\n\t}\n\n    if (role == Qt::DisplayRole || role == Qt::EditRole)\n    {\n        return valueForIndex(index);\n    }\n    else if (role == Qt::ToolTipRole)\n    {\n        return tooltipForIndex(index);\n    }\n\telse if (role == Qt::ForegroundRole)\n    {\n        if (index.column() == PeripheralColumns::NAME || index.column() == PeripheralColumns::BASEADDRESS ||\n            index.column() == PeripheralColumns::SIZE ||\n            ((index.column() == PeripheralColumns::INITABLE || index.column() == PeripheralColumns::FILEPATH || index.column() == PeripheralColumns::TEMPLATE) &&\n                classIsPythonPeripherals(index) == false))\n        {\n            return KactusColors::DISABLED_TEXT;\n        }\n        else\n        {\n            return KactusColors::REGULAR_TEXT;\n        }\n    }\n    else if (role == Qt::BackgroundRole)\n    {\n        return backgroundColourForIndex(index);\n    }\n    else if (Qt::CheckStateRole == role)\n    {\n        if (index.column() == PeripheralColumns::INITABLE)\n        {\n            QSharedPointer<RenodeStructs::cpuPeripheral> indexedPeripheral = peripherals_.at(index.row());\n            if (index.column() == PeripheralColumns::INITABLE && indexedPeripheral->initable_)\n            {\n                return Qt::Checked;\n            }\n            else\n            {\n                return Qt::Unchecked;\n            }\n        }\n        else\n        {\n            return QVariant();\n        }\n    }\n    else if (role == Qt::DecorationRole && index.column() == PeripheralColumns::FILEPATH)\n    {\n        return QIcon(QString(\":/icons/common/graphics/opened-folder.png\"));\n    }\n\n    return QVariant();\n}\n\n//-----------------------------------------------------------------------------\n// Function: RenodePeripheralsModel::setData()\n//-----------------------------------------------------------------------------\nbool RenodePeripheralsModel::setData(QModelIndex const& index, QVariant const& value, int role)\n{\n    if (!index.isValid() || index.row() < 0 || index.row() >= peripherals_.size())\n    {\n\t\treturn false;\n\t}\n\n    QSharedPointer<RenodeStructs::cpuPeripheral> indexedPeripheral = peripherals_.at(index.row());\n    if (Qt::EditRole == role)\n    {\n        if (index.column() == PeripheralColumns::CLASS)\n        {\n            indexedPeripheral->className_ = value.toString();\n        }\n        else if (index.column() == PeripheralColumns::FILEPATH)\n        {\n            indexedPeripheral->filePath_ = value.toString();\n        }\n        else if (index.column() == PeripheralColumns::TEMPLATE)\n        {\n            auto templateName = value.toString();\n            QSharedPointer<RenodeStructs::peripheralTemplate> selectedTemplate = RenodeUtilities::getTemplateFromList(templateName, pythonTemplates_);\n\n            indexedPeripheral->template_ = selectedTemplate;\n            if (selectedTemplate)\n            {\n                indexedPeripheral->filePath_ = selectedTemplate->path_;\n\n\t\t\t\tQModelIndex pathIndex = index.sibling(index.row(), PeripheralColumns::FILEPATH);\n\t\t\t\temit dataChanged(pathIndex, pathIndex);\n            }\n        }\n\n        emit dataChanged(index, index);\n        return true;\n    }\n    else if (role == Qt::CheckStateRole)\n    {\n        if (index.column() == PeripheralColumns::INITABLE)\n        {\n            indexedPeripheral->initable_ = value.toBool();\n        }\n\n        emit dataChanged(index, index);\n        return true;\n    }\n\n    return false;\n}\n\n//-----------------------------------------------------------------------------\n// Function: RenodePeripheralsModel::valueForIndex()\n//-----------------------------------------------------------------------------\nQVariant RenodePeripheralsModel::valueForIndex(QModelIndex const& index) const\n{\n    QSharedPointer<RenodeStructs::cpuPeripheral> indexedPeripheral = peripherals_.at(index.row());\n\n    if (index.column() == PeripheralColumns::NAME)\n    {\n        return indexedPeripheral->peripheralName_;\n    }\n    else if (index.column() == PeripheralColumns::BASEADDRESS)\n    {\n        return indexedPeripheral->baseAddress_;\n    }\n    else if (index.column() == PeripheralColumns::SIZE)\n    {\n        return indexedPeripheral->size_;\n    }\n    else if (index.column() == PeripheralColumns::CLASS)\n    {\n        return indexedPeripheral->className_;\n    }\n    else if (index.column() == PeripheralColumns::FILEPATH)\n    {\n        return indexedPeripheral->filePath_;\n    }\n    else if (index.column() == PeripheralColumns::TEMPLATE && indexedPeripheral->template_)\n    {\n        return indexedPeripheral->template_->identifier_;\n    }\n\n    return QVariant();\n}\n\n//-----------------------------------------------------------------------------\n// Function: RenodePeripheralsModel::tooltipForIndex()\n//-----------------------------------------------------------------------------\nQVariant RenodePeripheralsModel::tooltipForIndex(QModelIndex const& index) const\n{\n    if (index.column() == PeripheralColumns::NAME)\n    {\n        return QString(\"Name of the peripheral\");\n    }\n    else if (index.column() == PeripheralColumns::BASEADDRESS)\n    {\n        return QString(\"The base address\");\n    }\n    else if (index.column() == PeripheralColumns::SIZE)\n    {\n        return QString(\"Size of the peripheral as a hexadecimal value\");\n    }\n    else if (index.column() == PeripheralColumns::CLASS)\n    {\n        return QString(\"The type name. The default namespace Antmicro.Renode.Peripherals is omitted\");\n    }\n    else if (index.column() == PeripheralColumns::INITABLE)\n    {\n        return QString(\"If true, the peripheral can be initialized and executes code from the isInit section\\nOnly applicable for class \" + RenodeConstants::PYTHONPERIPHERAL);\n    }\n    else if (index.column() == PeripheralColumns::TEMPLATE)\n    {\n        return QString(\"Template for python peripherals.\");\n    }\n    else if (index.column() == PeripheralColumns::FILEPATH)\n    {\n        return QString(\"Relative path to the python file for this peripheral\\nOnly applicable for class \" + RenodeConstants::PYTHONPERIPHERAL);\n    }\n\n    return QVariant();\n}\n\n\n//-----------------------------------------------------------------------------\n// Function: RenodePeripheralsModel::backgroundColourForIndex()\n//-----------------------------------------------------------------------------\nQVariant RenodePeripheralsModel::backgroundColourForIndex(QModelIndex const& index) const\n{\n    if ((index.column() == PeripheralColumns::INITABLE || index.column() == PeripheralColumns::FILEPATH || index.column() == PeripheralColumns::TEMPLATE) && classIsPythonPeripherals(index) == false)\n    {\n        return KactusColors::DISABLED_FIELD;\n    }\n    \n    return KactusColors::REGULAR_FIELD;\n}\n\n//-----------------------------------------------------------------------------\n// Function: RenodePeripheralsModel::classIsPythonPeripherals()\n//-----------------------------------------------------------------------------\nbool RenodePeripheralsModel::classIsPythonPeripherals(QModelIndex const& index) const\n{\n    QModelIndex classIndex = index.sibling(index.row(), PeripheralColumns::CLASS);\n    QString peripheralClass = classIndex.data(Qt::DisplayRole).toString();\n    \n    return peripheralClass == RenodeConstants::PYTHONPERIPHERAL;\n}\n"
  },
  {
    "path": "Plugins/RenodeGenerator/CPUDialog/RenodePeripheralsModel.h",
    "content": "//-----------------------------------------------------------------------------\n// File: RenodePeripheralsModel.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 24.02.2023\n//\n// Description:\n// The model to manage the Renode peripheral details.\n//-----------------------------------------------------------------------------\n\n#ifndef RENODEPERIPHERALSMODEL_H\n#define RENODEPERIPHERALSMODEL_H\n\n#include <Plugins/common/ConnectivityGraphUtilities.h>\n#include <Plugins/RenodeGenerator/CPUDialog/RenodeStructs.h>\n\n#include <QAbstractTableModel>\n#include <QSharedPointer>\n\n//-----------------------------------------------------------------------------\n//! The model to manage the Renode peripheral details.\n//-----------------------------------------------------------------------------\nclass RenodePeripheralsModel : public QAbstractTableModel\n{\n\tQ_OBJECT\n\npublic:\n\n\t/*!\n\t *  The constructor.\n\t *\n\t *    @param [in] parent  Pointer to the owner of this model.\n\t */\n\tRenodePeripheralsModel(QObject *parent);\n\t\n\t/*!\n     *  The destructor.\n     */\n    virtual ~RenodePeripheralsModel() = default;\n\n    /*!\n     *  Setup the selected peripherals.\n     *\n     *    @param [in] newPeripherals  The selected peripherals.\n     */\n    void setupPeripherals(QVector<QSharedPointer<RenodeStructs::cpuPeripheral> > newPeripherals);\n\n\t/*!\n\t *  Setup the available peripheral templates.\n\t *\t\n\t *    @param [in] newTemplates    List of the available peripheral templates.\n\t */\n\tvoid setupTemplates(QVector<QSharedPointer<RenodeStructs::peripheralTemplate> > newTemplates);\n\n\t/*!\n     *  Get the number of rows an item contains.\n\t *\n\t *    @param [in] parent  Identifies the parent that's row count is requested.\n\t *\n\t *    @return Number of rows the item has.\n\t */\n\tvirtual int rowCount(QModelIndex const& parent = QModelIndex()) const;\n\n\t/*!\n     *  Get the number of columns the item has to be displayed.\n\t *\n\t *    @param [in] parent  Identifies the parent that's column count is requested.\n\t *\n\t *    @return The number of columns to be displayed.\n\t */\n\tvirtual int columnCount(QModelIndex const& parent = QModelIndex()) const;\n\n\t/*!\n     *  Get the item flags that defines the possible operations for the item.\n\t *\n\t *    @param [in] index   Model index that identifies the item.\n\t *\n\t *    @return Qt::ItemFlags specify the possible operations for the item.\n\t */\n\tQt::ItemFlags flags(QModelIndex const& index) const;\n\n\t/*!\n     *  Get the header data for specified header.\n\t *\n\t *    @param [in] section         The section specifies the row/column number for the header.\n\t *    @param [in] orientation     Specified if horizontal or vertical header is wanted.\n\t *    @param [in] role            Specifies the type of the requested data.\n\t *\n\t *    @return QVariant Contains the requested data.\n\t */\n\tvirtual QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;\n\n\t/*!\n     *  Get the data for specified item.\n\t *\n\t *    @param [in] index   Specifies the item that's data is requested.\n\t *    @param [in] role    The role that defines what kind of data is requested.\n\t *\n\t *    @return QVariant Contains the data for the item.\n\t */\n\tvirtual QVariant data(QModelIndex const& index, int role = Qt::DisplayRole) const;\n\n\t/*!\n     *  Save the data to the model for specified item.\n\t *\n\t *    @param [in] index   The model index of the item that's data is to be saved.\n\t *    @param [in] value   The data that is to be saved.\n\t *    @param [in] role    The role specifies what kind of data should be saved.\n\t *\n\t *    @return True if saving happened successfully.\n\t */\n\tbool setData(QModelIndex const& index, const QVariant& value, int role = Qt::EditRole);\n    \n    //! No copying. No assignment.\n    RenodePeripheralsModel(const RenodePeripheralsModel& other) = delete;\n    RenodePeripheralsModel& operator=(const RenodePeripheralsModel& other) = delete;\n\nprivate:\n\t\n    /*!\n     *  Gets the value for the given index.\n     *\n     *    @param [in] index   The index of the target data.\n     *\n     *    @return The data in the given index.\n     */\n    QVariant valueForIndex(QModelIndex const& index) const;\n\n    /*!\n     *  Gets the tooltip value for the given index.\n     *\n     *    @param [in] index   The index of the target data.\n     *\n     *    @return The tooltip data in the given index.\n     */\n    QVariant tooltipForIndex(QModelIndex const& index) const;\n\n    /*!\n     *  Get the background color for the selected index.\n     *\n     *    @param [in] index   The selected index.\n     *\n     *    @return Background color of the selected index.\n     */\n    QVariant backgroundColourForIndex(QModelIndex const& index) const;\n\n    /*!\n     *  Check if the class of the indexed peripheral is python peripheral.\n     *\n     *    @param [in] index   The selected index.\n     *\n     *    @return True, if the indexed peripheral class is python peripheral, false otherwise.\n     */\n    bool classIsPythonPeripherals(QModelIndex const& index) const;\n\n    //-----------------------------------------------------------------------------\n    // Data.\n    //-----------------------------------------------------------------------------\n\n    //! The peripheral details being edited.\n    QVector<QSharedPointer<RenodeStructs::cpuPeripheral> > peripherals_;\n\n    //! List of available peripheral templates.\n\tQVector<QSharedPointer<RenodeStructs::peripheralTemplate> > pythonTemplates_;\n\n    //! The folder path for the generated renode files.\n\tQString folderPath_ = QString();\n};\n\n#endif // RENODEPERIPHERALSMODEL_H\n"
  },
  {
    "path": "Plugins/RenodeGenerator/CPUDialog/RenodeStructs.h",
    "content": "//-----------------------------------------------------------------------------\n// File: RenodeStructs.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 24.05.2023\n//\n// Description:\n// Utility structs for Renode generator.\n//-----------------------------------------------------------------------------\n\n#ifndef RENODESTRUCTS_H\n#define RENODESTRUCTS_H\n\n#include <Plugins/RenodeGenerator/CPUDialog/RenodeConstants.h>\n\n#include <QSharedPointer>\n\n//-----------------------------------------------------------------------------\n//! Utility structs for Renode generator.\n//-----------------------------------------------------------------------------\nnamespace RenodeStructs\n{\n    //! Container for python peripheral templates.\n\tstruct peripheralTemplate\n\t{\n        //! Path for the template file.\n\t\tQString template_;\n\n        //! Target path for the generated peripheral file.\n\t\tQString path_;\n\n        //! Container identifier.\n\t\tQString identifier_;\n\t};\n\n    //! Container for renode peripheral data connected to a CPU.\n    struct cpuPeripheral\n    {\n        //! Name.\n        QString peripheralName_;\n\n        //! ID.\n        QString peripheralID_;\n\n        //! Type name.\n        QString className_ = RenodeConstants::PYTHONPERIPHERAL;\n\n        //! Base address.\n        QString baseAddress_;\n\n        //! Size.\n        QString size_;\n\n        //! Flag for if the peripheral can be initialized and executes code from the isInit section.\n        bool initable_ = true;\n\n        //! Relative path to the python file for this peripheral.\n        QString filePath_ = RenodeConstants::PYTHONPERIPHERALFILEPATH;\n\n        //! The used peripheral template container.\n        QSharedPointer<RenodeStructs::peripheralTemplate> template_;\n    };\n\n    //! Container for renode memory data connected to a CPU.\n    struct cpuMemories\n    {\n        //! Name.\n        QString memoryName_;\n\n        //! ID.\n        QString memoryID_;\n\n        //! Class name.\n        QString className_ = RenodeConstants::MAPPEDMEMORY;\n\n        //! Base address.\n        QString baseAddress_;\n\n        //! Size.\n        QString size_;\n    };\n};\n\n#endif // RENODESTRUCTS_H"
  },
  {
    "path": "Plugins/RenodeGenerator/CPUDialog/RenodeUtilities.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: RenodeUtilities.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 08.03.2023\n//\n// Description:\n// Utility functions for Renode generator.\n//-----------------------------------------------------------------------------\n\n#include \"RenodeUtilities.h\"\n\n#include <Plugins/common/ConnectivityGraphUtilities.h>\n\n#include <editors/MemoryDesigner/MemoryItem.h>\n#include <editors/MemoryDesigner/MemoryDesignerConstants.h>\n#include <editors/MemoryDesigner/MemoryConnectionAddressCalculator.h>\n\n#include <QJsonArray>\n\nnamespace\n{\n    //-----------------------------------------------------------------------------\n    // Function: valueToHexa()\n    //-----------------------------------------------------------------------------\n    QString valueToHexa(quint64 const& value)\n    {\n        QString valueInHexa = QString::number(value, 16).toUpper();\n\n        int valueNumbers =\n            MemoryDesignerConstants::getAmountOfNumbersInRange(valueInHexa, valueInHexa);\n\n        valueInHexa = \"0x\" +\n            MemoryDesignerConstants::getValueWithZerosAdded(valueInHexa, valueNumbers);\n\n        return valueInHexa;\n    }\n\n    //-----------------------------------------------------------------------------\n    // Function: SVDGenerator::getBlockMemoryItem()\n    //-----------------------------------------------------------------------------\n    QVector<QSharedPointer<MemoryItem>> getSubMemoryItems(QSharedPointer<MemoryItem> memoryItem, QString const& subItemType)\n    {\n        QVector<QSharedPointer<MemoryItem>> subItems;\n\n        for (auto const& subItem : memoryItem->getChildItems())\n        {\n            if (subItem->getType().compare(subItemType, Qt::CaseInsensitive) == 0)\n            {\n                subItems.append(subItem);\n            }\n        }\n\n        return subItems;\n    }\n\n    //-----------------------------------------------------------------------------\n    // Function: RenodeUtilities::getOrderedChildItems()\n    //-----------------------------------------------------------------------------\n    QMultiMap<quint64, QSharedPointer<MemoryItem> > getOrderedChildItems(QSharedPointer<MemoryItem> mapItem)\n    {\n        QMultiMap<quint64, QSharedPointer<MemoryItem>> blockItems;\n        for (auto const& subItem : mapItem->getChildItems())\n        {\n            blockItems.insert(subItem->getAddress().toULongLong(), subItem);\n        }\n\n        return blockItems;\n    }\n\n    //-----------------------------------------------------------------------------\n    // Function: CommonInterface::nameIsUnique()\n    //-----------------------------------------------------------------------------\n    bool nameIsUnique(QString const& mapName, QStringList const& peripheralNames)\n    {\n        return peripheralNames.contains(mapName) == false;\n    }\n\n    //-----------------------------------------------------------------------------\n    // Function: RenodeUtilities::getUniqueName()\n    //-----------------------------------------------------------------------------\n    QString getUniqueName(QString const& referenceName, QStringList const& peripheralNames)\n    {\n        QString newName(referenceName.toLower());\n\n        int runningNumber = 0;\n        while (!nameIsUnique(newName, peripheralNames))\n        {\n            newName = referenceName.toLower() + QString::number(runningNumber);\n\n            runningNumber++;\n        }\n\n        return newName;\n    }\n\n    //-----------------------------------------------------------------------------\n    // Function: RenodeUtilities::createPeripheral()\n    //-----------------------------------------------------------------------------\n    QSharedPointer<RenodeStructs::cpuPeripheral> createPeripheral(QSharedPointer<MemoryItem> mapItem,\n        quint64 mapBaseAddress, QVector<QSharedPointer<MemoryItem> > currentMemoryBlock,\n        QStringList& peripheralNames)\n    {\n        QSharedPointer<MemoryItem> firstBlock = currentMemoryBlock.first();\n        QSharedPointer<MemoryItem> lastBlock = currentMemoryBlock.last();\n\n        quint64 offset = mapBaseAddress + firstBlock->getAddress().toULongLong();\n        qint64 endAddress = mapBaseAddress + lastBlock->getAddress().toLongLong() + lastBlock->getRange().toLongLong() - 1;\n\n        quint64 size = endAddress - offset + 1;\n\n        QSharedPointer<RenodeStructs::cpuPeripheral> newPeripheral(new RenodeStructs::cpuPeripheral());\n        QString newPeripheralName = getUniqueName(mapItem->getName(), peripheralNames);\n        newPeripheral->peripheralName_ = newPeripheralName;\n        newPeripheral->peripheralID_ = \"\";\n        newPeripheral->baseAddress_ = valueToHexa(offset);\n        newPeripheral->size_ = valueToHexa(size);\n        newPeripheral->template_ = nullptr;\n\n        peripheralNames.append(newPeripheralName);\n\n        return newPeripheral;\n    }\n\n//-----------------------------------------------------------------------------\n// Function: RenodeUtilities::createMemory()\n//-----------------------------------------------------------------------------\n    QSharedPointer<RenodeStructs::cpuMemories> createMemory(QSharedPointer<MemoryItem> mapItem,\n        quint64 mapBaseAddress, QVector<QSharedPointer<MemoryItem> > currentMemoryBlock,\n        QStringList& memoryNames)\n    {\n        QSharedPointer<MemoryItem> firstBlock = currentMemoryBlock.first();\n        QSharedPointer<MemoryItem> lastBlock = currentMemoryBlock.last();\n\n        quint64 offset = mapBaseAddress + firstBlock->getAddress().toULongLong();\n        qint64 endAddress = mapBaseAddress + lastBlock->getAddress().toLongLong() + lastBlock->getRange().toLongLong() - 1;\n\n        quint64 size = endAddress - offset + 1;\n\n        QSharedPointer<RenodeStructs::cpuMemories> newMemory(new RenodeStructs::cpuMemories());\n        QString newMemoryName = getUniqueName(mapItem->getName() + \"_\" + firstBlock->getName(), memoryNames);\n\n        newMemory->memoryName_ = newMemoryName;\n        newMemory->memoryID_ = \"\";\n        newMemory->baseAddress_ = valueToHexa(offset);\n        newMemory->size_ = valueToHexa(size);\n\n        memoryNames.append(newMemoryName);\n\n        return newMemory;\n    }\n\n    //-----------------------------------------------------------------------------\n    // Function: RenodeUtilities::createAndAddPeripheralOrMemory()\n    //-----------------------------------------------------------------------------\n    void createItemBlock(General::Usage blockUsage, QVector<QSharedPointer<MemoryItem> >& currentMemoryBlock,\n        QVector<QSharedPointer<RenodeStructs::cpuPeripheral> >& peripherals,\n        QVector<QSharedPointer<RenodeStructs::cpuMemories> >& memories,\n        QSharedPointer<MemoryItem> interfaceMemory, quint64 const& memoryBaseAddress,\n        QStringList& peripheralNames, QStringList& memoryNames)\n    {\n        if (!currentMemoryBlock.isEmpty())\n        {\n            if (blockUsage == General::MEMORY)\n            {\n                memories.append(createMemory(interfaceMemory, memoryBaseAddress, currentMemoryBlock, memoryNames));\n            }\n            else\n            {\n                peripherals.append(createPeripheral(interfaceMemory, memoryBaseAddress, currentMemoryBlock, peripheralNames));\n            }\n        }\n    }\n\n    //-----------------------------------------------------------------------------\n    // Function: RenodeUtilities::usageIsMatching()\n    //-----------------------------------------------------------------------------\n    bool usageIsMatching(General::Usage currentUsage, General::Usage previousUsage)\n    {\n        return (currentUsage == General::MEMORY && currentUsage == previousUsage) || \n            (currentUsage != General::MEMORY && previousUsage != General::MEMORY);\n    }\n\n    //-----------------------------------------------------------------------------\n    // Function: RenodeUtilities::getFirstBlockUsage()\n    //-----------------------------------------------------------------------------\n    General::Usage getFirstBlockUsage(QMultiMap<quint64, QSharedPointer<MemoryItem> > orderedChildItems)\n    {\n        QMultiMapIterator blockIterator(orderedChildItems);\n        while (blockIterator.hasNext())\n        {\n            blockIterator.next();\n            QSharedPointer<MemoryItem> blockItem = blockIterator.value();\n\n            if (blockItem->getType().compare(MemoryDesignerConstants::ADDRESSBLOCK_TYPE, Qt::CaseInsensitive) == 0)\n            {\n                return blockItem->getUsage();\n            }\n        }\n\n        return General::USAGE_COUNT;\n    }\n\n    //-----------------------------------------------------------------------------\n    // Function: RenodeUtilities::findPeripheral()\n    //-----------------------------------------------------------------------------\n    QSharedPointer<RenodeStructs::cpuPeripheral> findPeripheral(QString const& peripheralName,\n        QVector<QSharedPointer<RenodeStructs::cpuPeripheral> > const& peripherals)\n    {\n        for (auto currentPeripheral : peripherals)\n        {\n            if (currentPeripheral->peripheralName_ == peripheralName)\n            {\n                return currentPeripheral;\n            }\n        }\n\n        return QSharedPointer<RenodeStructs::cpuPeripheral>();\n    }\n\n    //-----------------------------------------------------------------------------\n    // Function: RenodeUtilities::setupPeripheralConfiguration()\n    //-----------------------------------------------------------------------------\n    void setupPeripheralConfiguration(QJsonObject const& configurationObject,\n        QVector<QSharedPointer<RenodeStructs::cpuPeripheral> > const& peripherals,\n        QVector<QSharedPointer<RenodeStructs::peripheralTemplate> > peripheralTemplates)\n    {\n        QJsonValue peripheralsValue = configurationObject.value(RenodeConstants::PERIPHERALS);\n        if (peripheralsValue.isArray())\n        {\n            QJsonArray peripheralsArray = peripheralsValue.toArray();\n\n            for (int arrayIndex = 0; arrayIndex < peripheralsArray.count(); arrayIndex++)\n            {\n                QJsonValue singlePeripheralValue = peripheralsArray.at(arrayIndex);\n                if (singlePeripheralValue.isObject())\n                {\n                    QJsonObject peripheralObject = singlePeripheralValue.toObject();\n                    QString peripheralName = peripheralObject.value(RenodeConstants::PERIPHERALNAME).toString(\"\");\n\n                    QSharedPointer<RenodeStructs::cpuPeripheral> matchingPeripheral = findPeripheral(peripheralName, peripherals);\n                    if (matchingPeripheral)\n                    {\n                        matchingPeripheral->className_ = peripheralObject.value(RenodeConstants::PERIPHERALCLASS).toString(matchingPeripheral->className_);\n                        matchingPeripheral->filePath_ = peripheralObject.value(RenodeConstants::PERIPHERALPATH).toString(matchingPeripheral->filePath_);\n                        matchingPeripheral->initable_ = peripheralObject.value(RenodeConstants::PERIPHERALINITABLE).toBool(matchingPeripheral->initable_);\n\n                        QString templateName = peripheralObject.value(RenodeConstants::PERIPHERALTEMPLATE).toString(\"\");\n                        if (!templateName.isEmpty())\n                        {\n                            matchingPeripheral->template_ = RenodeUtilities::getTemplateFromList(templateName, peripheralTemplates);\n                        }\n                    }\n                }\n            }\n        }\n    }\n    \n    //-----------------------------------------------------------------------------\n    // Function: RenodeUtilities::findMemory()\n    //-----------------------------------------------------------------------------\n    QSharedPointer<RenodeStructs::cpuMemories> findMemory(QString const& memoryName,\n        QVector<QSharedPointer<RenodeStructs::cpuMemories> > const& memories)\n    {\n        for (auto const& currentMemory : memories)\n        {\n            if (currentMemory->memoryName_ == memoryName)\n            {\n                return currentMemory;\n            }\n        }\n\n        return QSharedPointer<RenodeStructs::cpuMemories>();\n    }\n\n    //-----------------------------------------------------------------------------\n    // Function: RenodeUtilities::setupMemoryConfiguration()\n    //-----------------------------------------------------------------------------\n    void setupMemoryConfiguration(QJsonObject const& configurationObject,\n        QVector<QSharedPointer<RenodeStructs::cpuMemories> >& memories)\n    {\n        QJsonValue memoriesValue = configurationObject.value(RenodeConstants::MEMORY);\n        if (memoriesValue.isArray())\n        {\n            QJsonArray memoryArray = memoriesValue.toArray();\n\n            for (int arrayIndex = 0; arrayIndex < memoryArray.count(); arrayIndex++)\n            {\n                QJsonValue singleMemoryValue = memoryArray.at(arrayIndex);\n                if (singleMemoryValue.isObject())\n                {\n                    QJsonObject memoryObject = singleMemoryValue.toObject();\n                    QString memoryName = memoryObject.value(RenodeConstants::MEMORYNAME).toString(\"\");\n\n                    QSharedPointer<RenodeStructs::cpuMemories> matchingMemory = findMemory(memoryName, memories);\n                    if (matchingMemory)\n                    {\n                        matchingMemory->className_ = memoryObject.value(RenodeConstants::MEMORYCLASS).toString(matchingMemory->className_);\n                    }\n                }\n            }\n        }\n    }\n\n    //-----------------------------------------------------------------------------\n    // Function: RenodeUtilities::getConfigurationObjectForCpu()\n    //-----------------------------------------------------------------------------\n    QSharedPointer<RenodeCpuRoutesContainer> createAndConfigureCpuContainer(QJsonObject const& configurationObject,\n        QSharedPointer<SingleCpuRoutesContainer> cpuContainer, QVector<QSharedPointer<RenodeStructs::cpuPeripheral> >& peripherals,\n        QVector<QSharedPointer<RenodeStructs::cpuMemories> >& memories,\n        QVector<QSharedPointer<RenodeStructs::peripheralTemplate> > templates)\n    {\n        QSharedPointer<RenodeCpuRoutesContainer> renodeCpuContainer(new RenodeCpuRoutesContainer(*cpuContainer.data()));\n\t\tif (auto multiCpuValue = configurationObject.value(RenodeConstants::CPUS); multiCpuValue.isArray())\n        {\n            QJsonArray cpuArray = multiCpuValue.toArray();\n            if (!cpuArray.isEmpty())\n            {\n                for (auto const& cpuValue : cpuArray)\n                {\n                    if (cpuValue.isObject())\n                    {\n                        QJsonObject cpuObject = cpuValue.toObject();\n                        if (cpuObject.value(RenodeConstants::CPUNAME) == renodeCpuContainer->getFileName())\n                        {\n                            renodeCpuContainer->setClassName(cpuObject.value(RenodeConstants::CPUCLASS).toString(renodeCpuContainer->getClassName()));\n                            renodeCpuContainer->setTimeProvider(cpuObject.value(RenodeConstants::CPUTIME).toString(renodeCpuContainer->getTimeProvider()));\n                            renodeCpuContainer->setCpuType(cpuObject.value(RenodeConstants::CPUTYPE).toString(renodeCpuContainer->getCpuType()));\n\n                            setupPeripheralConfiguration(cpuObject, peripherals, templates);\n                            setupMemoryConfiguration(cpuObject, memories);\n                        }\n                    }\n                }\n            }\n        }\n\n        renodeCpuContainer->setPeripherals(peripherals);\n        renodeCpuContainer->setMemories(memories);\n\n        return renodeCpuContainer;\n    }\n};\n\n//-----------------------------------------------------------------------------\n// Function: RenodeUtilities::getRenodeCpuRoutes()\n//-----------------------------------------------------------------------------\nQVector<QSharedPointer<RenodeCpuRoutesContainer> > RenodeUtilities::getRenodeCpuRoutes(\n    QJsonObject const& configurationObject, LibraryInterface* library, QSharedPointer<Component> component,\n    QString const& viewName, QVector<QSharedPointer<RenodeStructs::peripheralTemplate>> templates)\n{\n    QVector<QSharedPointer<RenodeCpuRoutesContainer> > cpuDetails;\n    for (auto defaultCPU : ConnectivityGraphUtilities::getDefaultCPUs(library, component, viewName))\n    {\n        QVector<QSharedPointer<RenodeStructs::cpuPeripheral> > peripherals;\n        QVector<QSharedPointer<RenodeStructs::cpuMemories> > memories;\n        QStringList peripheralNames;\n        QStringList memoryNames;\n\n        for (auto cpuInterfaceContainer : defaultCPU->getRoutes())\n        {\n            QSharedPointer<const ConnectivityInterface> cpuInterface = cpuInterfaceContainer->cpuInterface_;\n            for (auto const& masterSlaveRoute : cpuInterfaceContainer->routes_)\n            {\n                for (auto routeInterface : masterSlaveRoute)\n                {\n                    QSharedPointer<const ConnectivityComponent> interfacedComponent = routeInterface->getInstance();\n                    QSharedPointer<MemoryItem> interfaceMemory = routeInterface->getConnectedMemory();\n\n                    if (interfaceMemory && interfaceMemory->getType().compare(MemoryDesignerConstants::MEMORYMAP_TYPE, Qt::CaseInsensitive) == 0)\n                    {\n                        MemoryConnectionAddressCalculator::CalculatedPathAddresses pathAddresses =\n                            MemoryConnectionAddressCalculator::calculatePathAddresses(cpuInterface, routeInterface, masterSlaveRoute);\n\n                        quint64 memoryBaseAddress = pathAddresses.connectionBaseAddress_;\n\n                        QVector<QPair<General::Usage, QVector<QSharedPointer<MemoryItem> > > > subItemBlocks;\n\n                        QPair<General::Usage, QVector<QSharedPointer<MemoryItem> > > currentItemBlock;\n\n                        QMultiMap<quint64, QSharedPointer<MemoryItem> > orderedChildItems = getOrderedChildItems(interfaceMemory);\n                        currentItemBlock.first = getFirstBlockUsage(orderedChildItems);\n\n                        QMultiMapIterator blockIterator(orderedChildItems);\n                        while (blockIterator.hasNext())\n                        {\n                            blockIterator.next();\n                            QSharedPointer<MemoryItem> blockItem = blockIterator.value();\n\n                            if (blockItem->getType().compare(MemoryDesignerConstants::ADDRESSBLOCK_TYPE, Qt::CaseInsensitive) == 0)\n                            {\n                                if (usageIsMatching(currentItemBlock.first, blockItem->getUsage()))\n                                {\n                                    currentItemBlock.second.append(blockItem);\n                                }\n                                else\n                                {\n                                    createItemBlock(currentItemBlock.first, currentItemBlock.second,\n                                        peripherals, memories, interfaceMemory, memoryBaseAddress, peripheralNames, memoryNames);\n\n                                    currentItemBlock.first = blockItem->getUsage();\n                                    currentItemBlock.second.clear();\n                                    currentItemBlock.second.append(blockItem);\n                                }\n                            }\n                            else\n                            {\n                                createItemBlock(currentItemBlock.first, currentItemBlock.second,\n                                    peripherals, memories, interfaceMemory, memoryBaseAddress, peripheralNames, memoryNames);\n\n                                currentItemBlock.first = General::USAGE_COUNT;\n                                currentItemBlock.second.clear();\n                            }\n                        }\n\n                        createItemBlock(currentItemBlock.first, currentItemBlock.second, peripherals, memories, interfaceMemory,\n                            memoryBaseAddress, peripheralNames, memoryNames);\n                    }\n                }\n            }\n        }\n\n        QSharedPointer<RenodeCpuRoutesContainer> renodeCpuContainer =\n            createAndConfigureCpuContainer(configurationObject, defaultCPU, peripherals, memories, templates);\n        cpuDetails.append(renodeCpuContainer);\n    }\n\n    return cpuDetails;\n}\n\n//-----------------------------------------------------------------------------\n// Function: RenodeUtilities::getTemplateNames()\n//-----------------------------------------------------------------------------\nQStringList RenodeUtilities::getTemplateNames(QVector<QSharedPointer<RenodeStructs::peripheralTemplate> > templates)\n{\n    QStringList names;\n    for (auto const& singleTemplate : templates)\n    {\n        names.append(singleTemplate->identifier_);\n    }\n\n    return names;\n}\n\n//-----------------------------------------------------------------------------\n// Function: RenodeUtilities::getTemplateFromList()\n//-----------------------------------------------------------------------------\nQSharedPointer<RenodeStructs::peripheralTemplate> RenodeUtilities::getTemplateFromList(QString const& templateName,\n    QVector<QSharedPointer<RenodeStructs::peripheralTemplate> > templates)\n{\n    for (auto const& singleTemplate : templates)\n    {\n        if (singleTemplate->identifier_ == templateName)\n        {\n            return singleTemplate;\n        }\n    }\n\n    return nullptr;\n}\n"
  },
  {
    "path": "Plugins/RenodeGenerator/CPUDialog/RenodeUtilities.h",
    "content": "//-----------------------------------------------------------------------------\n// File: RenodeUtilities.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 03.03.2023\n//\n// Description:\n// Utility functions for Renode generator.\n//-----------------------------------------------------------------------------\n\n#ifndef RENODEUTILITIES_H\n#define RENODEUTILITIES_H\n\n#include <Plugins/RenodeGenerator/CPUDialog/RenodeCpuRoutesContainer.h>\n#include <Plugins/RenodeGenerator/CPUDialog/RenodeStructs.h>\n\n#include <KactusAPI/include/LibraryInterface.h>\n\n#include <IPXACTmodels/Component/Component.h>\n\n#include <QString>\n#include <QJsonObject>\n\n//-----------------------------------------------------------------------------\n//! Utility functions for Renode generator.\n//-----------------------------------------------------------------------------\nnamespace RenodeUtilities\n{\n    /*!\n     *  Get CPU detail routes for Renode generator.\n     *\n     *    @param [in] configurationObject     JSON object containing the editor configuration.\n     *    @param [in] library                 Interface for accessing the library.\n     *    @param [in] component               Top component of the design.\n     *    @param [in] viewName                The currently active view.\n     *    @param [in] templates               List of available peripheral templates.\n     *\n     *    @return List of CPU detail routes for Renode generator.\n     */\n    QVector<QSharedPointer<RenodeCpuRoutesContainer> > getRenodeCpuRoutes(\n        QJsonObject const& configurationObject,\n        LibraryInterface* library,\n        QSharedPointer<Component> component,\n        QString const& viewName,\n        QVector<QSharedPointer<RenodeStructs::peripheralTemplate> > templates);\n\n    /*!\n     *  Get the available peripheral template names.\n     *\t\n     *    @param [in] templates   List of available peripheral templates.\n     *\n     *    @return List of peripheral template names.\n     */\n    QStringList getTemplateNames(QVector<QSharedPointer<RenodeStructs::peripheralTemplate> > templates);\n\n    /*!\n     *  Get the selected peripheral template from the selected list.\n     *\t\n     *    @param [in] templateName    Name of the selected peripheral template.\n     *    @param [in] templates       List of available peripheral templates.\n     *\n     *    @return The selected peripheral template.\n     */\n    QSharedPointer<RenodeStructs::peripheralTemplate> getTemplateFromList(QString const& templateName, QVector<QSharedPointer<RenodeStructs::peripheralTemplate> > templates);\n};\n\n#endif //RENODEUTILITIES_H"
  },
  {
    "path": "Plugins/RenodeGenerator/CPUDialog/TemplateEditor/PeripheralTemplateConfigurer.cpp",
    "content": "﻿//-----------------------------------------------------------------------------\n// File: PeripheralTemplateConfigurer.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Mikko Teuho\n// Date: 08.06.2023\n//\n// Description:\n// Configures renode generator peripheral templates.\n//-----------------------------------------------------------------------------\n\n#include \"PeripheralTemplateConfigurer.h\"\n\n#include <Plugins/RenodeGenerator/RenodeSettingsModel.h>\n#include <Plugins/RenodeGenerator/CPUDialog/RenodeConstants.h>\n\n#include <QFile>\n#include <QJsonDocument>\n#include <QJsonObject>\n#include <QJsonArray>\n\n//-----------------------------------------------------------------------------\n// Function: RenodeSettingsModel::RenodeSettingsModel()\n//-----------------------------------------------------------------------------\nPeripheralTemplateConfigurer::PeripheralTemplateConfigurer(RenodeSettingsModel* settingsModel) :\nsettingsModel_(settingsModel)\n{\n    initializeTemplates();\n}\n\n//-----------------------------------------------------------------------------\n// Function: PeripheralTemplateConfigurer::getTemplates()\n//-----------------------------------------------------------------------------\nvoid PeripheralTemplateConfigurer::initializeTemplates()\n{\n    if (QFile configurationFile(settingsModel_->getFilePath()); configurationFile.open(QFile::ReadOnly))\n    {\n        if (QJsonDocument configurationDocument = QJsonDocument::fromJson(configurationFile.readAll()); configurationDocument.isObject())\n        {\n            QJsonObject configurationObject = configurationDocument.object();\n            if (QJsonValue templatesValue = configurationObject.value(RenodeTemplateConstants::TEMPLATEARRAYKEY); templatesValue.isArray())\n            {\n                QJsonArray templatesArray = templatesValue.toArray();\n                for (auto templateValue : templatesArray)\n                {\n                    if (templateValue.isObject())\n                    {\n                        QJsonObject templateObject = templateValue.toObject();\n\n                        QSharedPointer<RenodeStructs::peripheralTemplate> newTemplate(new RenodeStructs::peripheralTemplate());\n                        newTemplate->identifier_ = templateObject.value(RenodeTemplateConstants::TEMPLATENAME).toString(QString(\"\"));\n                        newTemplate->template_ = templateObject.value(RenodeTemplateConstants::TEMPLATEFILE).toString(QString(\"\"));\n                        newTemplate->path_ = templateObject.value(RenodeTemplateConstants::TARGETPATH).toString(QString(\"\"));\n\n                        templates_.append(newTemplate);\n                    }\n                }\n            }\n        }\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: PeripheralTemplateConfigurer::getTemplates()\n//-----------------------------------------------------------------------------\nQVector<QSharedPointer<RenodeStructs::peripheralTemplate> > PeripheralTemplateConfigurer::getTemplates() const\n{\n    return templates_;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PeripheralTemplateConfigurer::setTemplates()\n//-----------------------------------------------------------------------------\nvoid PeripheralTemplateConfigurer::setTemplates(QVector<QSharedPointer<RenodeStructs::peripheralTemplate>> newTemplates)\n{\n    templates_ = newTemplates;\n\n    QFile configurationFile(settingsModel_->getFilePath());\n    if (!configurationFile.open(QIODevice::WriteOnly))\n    {\n        return;\n    }\n\n    QJsonObject configurationObject;\n    if (!templates_.isEmpty())\n    {\n        QJsonArray templateArray;\n\n        for (auto currentTemplate : templates_)\n        {\n            QJsonObject templateObject;\n            templateObject.insert(RenodeTemplateConstants::TEMPLATENAME, currentTemplate->identifier_);\n            templateObject.insert(RenodeTemplateConstants::TEMPLATEFILE, currentTemplate->template_);\n            templateObject.insert(RenodeTemplateConstants::TARGETPATH, currentTemplate->path_);\n\n            templateArray.push_back(templateObject);\n        }\n\n        configurationObject.insert(RenodeTemplateConstants::TEMPLATEARRAYKEY, templateArray);\n    }\n\n    QJsonDocument document(configurationObject);\n    configurationFile.write(document.toJson());\n}\n"
  },
  {
    "path": "Plugins/RenodeGenerator/CPUDialog/TemplateEditor/PeripheralTemplateConfigurer.h",
    "content": "//-----------------------------------------------------------------------------\n// File: PeripheralTemplateConfigurer.h\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Mikko Teuho\n// Date: 08.06.2023\n//\n// Description:\n// Configures renode generator peripheral templates.\n//-----------------------------------------------------------------------------\n\n#ifndef PERIPHERALTEMPLATECONFIGURER_H\n#define PERIPHERALTEMPLATECONFIGURER_H\n\n#include <Plugins/RenodeGenerator/CPUDialog/RenodeStructs.h>\n\n#include <QSettings>\n\nclass RenodeSettingsModel;\n\n//-----------------------------------------------------------------------------\n//! Configures renode generator peripheral templates.\n//-----------------------------------------------------------------------------\nclass PeripheralTemplateConfigurer\n{\npublic:\n\n    /*!\n     *  Constructor.\n     * \n     *    @param [in] settingsModel   Container for Renode generator settings.\n     */\n    PeripheralTemplateConfigurer(RenodeSettingsModel* settingsModel);\n\n    /*!\n     *  Destructor.\n     */\n    virtual ~PeripheralTemplateConfigurer() = default;\n\n    /*!\n     *  Get the list of available peripheral templates.\n     *\t\n     *    @return List of available peripheral templates.\n     */\n    QVector<QSharedPointer<RenodeStructs::peripheralTemplate> > getTemplates() const;\n\n    /*!\n     *  Set a new list of peripheral templates.\n     *\t\n     *    @param [in] newTemplates    The new peripheral templates.\n     */\n    void setTemplates(QVector<QSharedPointer<RenodeStructs::peripheralTemplate> > newTemplates);\n\nprivate:\n\n    /*!\n     *  Initialize templates from the currently active settings model.\n     */\n    void initializeTemplates();\n\n    //-----------------------------------------------------------------------------\n    // Data.\n    //-----------------------------------------------------------------------------\n\n    //! List of available peripheral templates.\n    QVector<QSharedPointer<RenodeStructs::peripheralTemplate> > templates_;\n\n    // Container for Renode generator settings.\n    RenodeSettingsModel* settingsModel_;\n};\n\n//-----------------------------------------------------------------------------\n\n#endif // PERIPHERALTEMPLATECONFIGURER_H\n"
  },
  {
    "path": "Plugins/RenodeGenerator/CPUDialog/TemplateEditor/PeripheralTemplateDelegate.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: PeripheralTemplateDelegate.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 31.05.2023\n//\n// Description:\n// The delegate that provides editors to edit peripheral template details.\n//-----------------------------------------------------------------------------\n\n#include \"PeripheralTemplateDelegate.h\"\n\n#include <Plugins/RenodeGenerator/CPUDialog/RenodeColumns.h>\n\n#include <QFileDialog>\n#include <QApplication>\n#include <QMouseEvent>\n\n//-----------------------------------------------------------------------------\n// Function: PeripheralTemplateDelegate::PeripheralTemplateDelegate()\n//-----------------------------------------------------------------------------\nPeripheralTemplateDelegate::PeripheralTemplateDelegate(QString const& generationDestinationFolder,\n    QWidget* parentWidget, QObject* parent):\nQStyledItemDelegate(parent),\ngeneratorTargetFolder_(generationDestinationFolder),\nparentWidget_(parentWidget)\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: PeripheralTemplateDelegate::editorEvent()\n//-----------------------------------------------------------------------------\nbool PeripheralTemplateDelegate::editorEvent(QEvent *event, QAbstractItemModel* model, QStyleOptionViewItem const& option,\n    QModelIndex const& index)\n{\n    Q_ASSERT(event);\n    Q_ASSERT(model);\n\n    // Handle the mouse button events.\n    if (event->type() == QEvent::MouseButtonRelease &&\n        (index.column() == PeripheralTemplateColumns::PATH || index.column() == PeripheralTemplateColumns::TEMPLATE))\n    {\n        const int textMargin = QApplication::style()->pixelMetric(QStyle::PM_FocusFrameHMargin) + 1;\n\n        QStyleOptionViewItem::Position iconPosition = option.decorationPosition;\n        int iconWidth = option.decorationSize.width();\n\n        QRect rectangleIsinideCheckRect(option.rect.x() + (2 * textMargin), option.rect.y(),\n            option.rect.width() - (2 * textMargin),\n            option.rect.height());\n\n\t\tQRect checkRect = QStyle::alignedRect(option.direction, Qt::AlignLeft, option.decorationSize, rectangleIsinideCheckRect);\n        if (checkRect.contains(static_cast<QMouseEvent*>(event)->pos()))\n        {\n            QString newPath = \"\";\n            if (index.column() == PeripheralTemplateColumns::PATH)\n            {\n\t\t\t\tnewPath = QFileDialog::getExistingDirectory(parentWidget_, tr(\"Open Directory\"), generatorTargetFolder_,\n\t\t\t\t\tQFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks);\n\n                if (!newPath.isEmpty())\n                {\n                    QDir appDirectory(generatorTargetFolder_);\n                    newPath = appDirectory.relativeFilePath(newPath);\n                }\n            }\n            else if (index.column() == PeripheralTemplateColumns::TEMPLATE)\n            {\n                QString binaryFolder = QCoreApplication::applicationDirPath();\n\n                newPath = QFileDialog::getOpenFileName(parentWidget_, tr(\"Select python template\"), binaryFolder, tr(\"Python files (*.py)\"));\n\n                if (!newPath.isEmpty())\n                {\n                    QDir appDirectory(binaryFolder);\n                    newPath = appDirectory.relativeFilePath(newPath);\n                }\n            }\n\n            if (!newPath.isEmpty())\n            {\n                model->setData(index, newPath);\n            }\n\n            return true;\n        }\n    }\n\n    return QStyledItemDelegate::editorEvent(event, model, option, index);\n}\n"
  },
  {
    "path": "Plugins/RenodeGenerator/CPUDialog/TemplateEditor/PeripheralTemplateDelegate.h",
    "content": "//-----------------------------------------------------------------------------\n// File: PeripheralTemplateDelegate.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 31.05.2023\n//\n// Description:\n// The delegate that provides editors to edit peripheral template details.\n//-----------------------------------------------------------------------------\n\n#ifndef PERIPHERALTEMPLATEDELEGATE_H\n#define PERIPHERALTEMPLATEDELEGATE_H\n\n#include <QStyledItemDelegate>\n#include <QWidget>\n\n//-----------------------------------------------------------------------------\n//! The delegate that provides editors to edit peripheral template details.\n//-----------------------------------------------------------------------------\nclass PeripheralTemplateDelegate : public QStyledItemDelegate\n{\n\tQ_OBJECT\n\npublic:\n\n    /*!\n     *  The constructor.\n     */\n    PeripheralTemplateDelegate(QString const& generationDestinationFolder, QWidget* parentWidget, QObject* parent = 0);\n\n\t/*!\n     *  The destructor.\n     */\n    virtual ~PeripheralTemplateDelegate() = default;\n\n    // Disable copying.\n    PeripheralTemplateDelegate(PeripheralTemplateDelegate const& rhs) = delete;\n    PeripheralTemplateDelegate& operator=(PeripheralTemplateDelegate const& rhs) = delete;\n\nprotected:\n    \n    /*!\n     *  Handler for preprocessing events that starts editing.\n     *\n     *    @param [in] event   The event that triggered the editing.\n     *    @param [in] model   The underlying model to edit.\n     *    @param [in] option  Style options for rendering the item.\n     *    @param [in] index   The index being edited.\n     *\n     *    @return True, if the delegate handles the event, otherwise false.\n     */\n    virtual bool editorEvent(QEvent* event, QAbstractItemModel* model, QStyleOptionViewItem const& option, QModelIndex const& index);\n\nprivate:\n\n    //-----------------------------------------------------------------------------\n    // Data.\n    //-----------------------------------------------------------------------------\n\n    //! The current folder location.\n    QString generatorTargetFolder_;\n\n    //! The parent widget.\n    QWidget* parentWidget_;\n};\n\n#endif // PERIPHERALTEMPLATEDELEGATE_H\n"
  },
  {
    "path": "Plugins/RenodeGenerator/CPUDialog/TemplateEditor/PeripheralTemplateEditor.cpp",
    "content": "﻿//-----------------------------------------------------------------------------\n// File: PeripheralTemplateEditor.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 29.05.2023\n//\n// Description:\n// Editor for peripheral templates in renode generator.\n//-----------------------------------------------------------------------------\n\n#include \"PeripheralTemplateEditor.h\"\n\n#include <common/views/EditableTableView/editabletableview.h>\n\n#include <Plugins/RenodeGenerator/CPUDialog/TemplateEditor/PeripheralTemplateModel.h>\n#include <Plugins/RenodeGenerator/CPUDialog/TemplateEditor/PeripheralTemplateDelegate.h>\n\n#include <QSortFilterProxyModel>\n#include <QHeaderView>\n#include <QVBoxLayout>\n\n//-----------------------------------------------------------------------------\n// Function: PeripheralTemplateEditor::PeripheralTemplateEditor()\n//-----------------------------------------------------------------------------\nPeripheralTemplateEditor::PeripheralTemplateEditor(QString const& generationFolder, QWidget *parent /* = 0 */):\nQWidget(parent),\nview_(new EditableTableView(this)),\nmodel_(new PeripheralTemplateModel(this)),\ntemplateDelegate_(new PeripheralTemplateDelegate(generationFolder, this, this))\n{\n    auto proxy(new QSortFilterProxyModel(this));\n    proxy->setSourceModel(model_);\n\n    view_->setModel(proxy);\n    view_->setItemDelegate(templateDelegate_);\n\n    auto layout(new QVBoxLayout(this));\n    layout->addWidget(view_, 1);\n    layout->setContentsMargins(0, 0, 0, 0);\n\n    connectSignals();\n}\n\n//-----------------------------------------------------------------------------\n// Function: PeripheralTemplateEditor::connectSignals()\n//-----------------------------------------------------------------------------\nvoid PeripheralTemplateEditor::connectSignals() const\n{\n\tconnect(view_, SIGNAL(addItem(const QModelIndex&)), model_, SLOT(onAddItem(const QModelIndex&)), Qt::UniqueConnection);\n\tconnect(view_, SIGNAL(removeItem(const QModelIndex&)), model_, SLOT(onRemoveItem(const QModelIndex&)), Qt::UniqueConnection);\n}\n\n//-----------------------------------------------------------------------------\n// Function: PeripheralTemplateEditor::setupTemplates()\n//-----------------------------------------------------------------------------\nvoid PeripheralTemplateEditor::setupTemplates(QVector<QSharedPointer<RenodeStructs::peripheralTemplate> > newTemplars)\n{\n    model_->setupTemplates(newTemplars);\n\n    view_->resizeColumnsToContents();\n}\n\n//-----------------------------------------------------------------------------\n// Function: PeripheralTemplateEditor::getTemplates()\n//-----------------------------------------------------------------------------\nQVector<QSharedPointer<RenodeStructs::peripheralTemplate> > PeripheralTemplateEditor::getTemplates() const\n{\n    return model_->getTemplates();\n}\n"
  },
  {
    "path": "Plugins/RenodeGenerator/CPUDialog/TemplateEditor/PeripheralTemplateEditor.h",
    "content": "//-----------------------------------------------------------------------------\n// File: PeripheralTemplateEditor.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 29.05.2023\n//\n// Description:\n// Editor for peripheral templates in renode generator.\n//-----------------------------------------------------------------------------\n\n#ifndef PERIPHERALTEMPLATEEDITOR_H\n#define PERIPHERALTEMPLATEEDITOR_H\n\n#include <QWidget>\n\n#include <Plugins/RenodeGenerator/CPUDialog/RenodeStructs.h>\n\nclass EditableTableView;\nclass PeripheralTemplateModel;\nclass PeripheralTemplateDelegate;\n\n//-----------------------------------------------------------------------------\n//! Editor for peripheral templates in renode generator.\n//-----------------------------------------------------------------------------\nclass PeripheralTemplateEditor : public QWidget\n{\n    Q_OBJECT\n\npublic:\n\n    /*!\n     *  The constructor.\n     *\n     *    @param [in] parent  Pointer to the owner of this widget.\n     */\n    PeripheralTemplateEditor(QString const& generationFolder, QWidget *parent = 0);\n\n    /*!\n     *  Setup the peripheral template.\n     *\t\n     *    @param [in] newTemplates    List of new peripheral templates.\n     */\n    void setupTemplates(QVector<QSharedPointer<RenodeStructs::peripheralTemplate> > newTemplars);\n\n    /*!\n     *  The destructor.\n     */\n    virtual ~PeripheralTemplateEditor() = default;\n\n    /*!\n     *  Get the current peripheral templates.\n     *\t\n     *    @return The current peripheral templates.\n     */\n    QVector<QSharedPointer<RenodeStructs::peripheralTemplate> > getTemplates() const;\n\n    //! No copying. No assignment.\n    PeripheralTemplateEditor(const PeripheralTemplateEditor& other) = delete;\n    PeripheralTemplateEditor& operator=(const PeripheralTemplateEditor& other) = delete;\n\nprivate:\n\n    /*!\n     *  Connect editor signals.\n     */\n    void connectSignals() const;\n\n    //-----------------------------------------------------------------------------\n    // Data.\n    //-----------------------------------------------------------------------------\n\n    //! The view for the table.\n    EditableTableView* view_;\n\n    //! The containing model.\n    PeripheralTemplateModel* model_;\n\n    //! The delegate.\n    PeripheralTemplateDelegate* templateDelegate_;\n};\n\n#endif // PERIPHERALTEMPLATEEDITOR_H\n"
  },
  {
    "path": "Plugins/RenodeGenerator/CPUDialog/TemplateEditor/PeripheralTemplateModel.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: PeripheralTemplateModel.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 24.02.2023\n//\n// Description:\n// The model to manage the peripheral templates.\n//-----------------------------------------------------------------------------\n\n#include \"PeripheralTemplateModel.h\"\n\n#include <common/KactusColors.h>\n\n#include <QColor>\n#include <QCoreApplication>\n#include <QFile>\n#include <QIcon>\n\n#include <Plugins/RenodeGenerator/CPUDialog/RenodeColumns.h>\n\n//-----------------------------------------------------------------------------\n// Function: PeripheralTemplateModel::PeripheralTemplateModel()\n//-----------------------------------------------------------------------------\nPeripheralTemplateModel::PeripheralTemplateModel(QObject *parent):\nQAbstractTableModel(parent)\n{\n}\n\n//-----------------------------------------------------------------------------\n// Function: PeripheralTemplateModel::setupPeripherals()\n//-----------------------------------------------------------------------------\nvoid PeripheralTemplateModel::setupTemplates(QVector<QSharedPointer<RenodeStructs::peripheralTemplate>> newTemplates)\n{\n    beginResetModel();\n\n    templates_.clear();\n    templates_ = newTemplates;\n\n    endResetModel();\n}\n\n//-----------------------------------------------------------------------------\n// Function: PeripheralTemplateModel::getTemplates()\n//-----------------------------------------------------------------------------\nQVector<QSharedPointer<RenodeStructs::peripheralTemplate> > PeripheralTemplateModel::getTemplates() const\n{\n    return templates_;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PeripheralTemplateModel::rowCount()\n//-----------------------------------------------------------------------------\nint PeripheralTemplateModel::rowCount(QModelIndex const& parent) const\n{\n\tif (parent.isValid())\n    {\n\t\treturn 0;\n\t}\n\n    return static_cast<int>(templates_.count());\n}\n\n//-----------------------------------------------------------------------------\n// Function: PeripheralTemplateModel::columnCount()\n//-----------------------------------------------------------------------------\nint PeripheralTemplateModel::columnCount(QModelIndex const& parent) const\n{\n\tif (parent.isValid())\n    {\n\t\treturn 0;\n\t}\n\n    return PeripheralTemplateColumns::COLUMN_COUNT;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PeripheralTemplateModel::flags()\n//-----------------------------------------------------------------------------\nQt::ItemFlags PeripheralTemplateModel::flags(QModelIndex const& index) const\n{\n\tif (!index.isValid())\n    {\n\t\treturn Qt::NoItemFlags;\n\t}\n\n    Qt::ItemFlags flags = Qt::ItemIsEnabled | Qt::ItemIsSelectable |= Qt::ItemIsEditable;\n    return flags;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PeripheralTemplateModel::headerData()\n//-----------------------------------------------------------------------------\nQVariant PeripheralTemplateModel::headerData(int section, Qt::Orientation orientation, int role) const\n{\n\tif (orientation != Qt::Horizontal)\n    {\n\t\treturn QVariant();\n\t}\n\n\tif (Qt::DisplayRole == role)\n    {\n        if (section == PeripheralTemplateColumns::NAME)\n        {\n            return tr(\"Name\");\n        }\n        else if (section == PeripheralTemplateColumns::TEMPLATE)\n        {\n            return tr(\"Template path\");\n        }\n        else if (section == PeripheralTemplateColumns::PATH)\n        {\n            return tr(\"File path\");\n        }\n\t}\n    \n    return QVariant();\n}\n\n//-----------------------------------------------------------------------------\n// Function: PeripheralTemplateModel::data()\n//-----------------------------------------------------------------------------\nQVariant PeripheralTemplateModel::data(QModelIndex const& index, int role) const\n{\n    if (!index.isValid() || index.row() < 0 || index.row() >= templates_.size())\n    {\n\t\treturn QVariant();\n\t}\n\n    if (role == Qt::DisplayRole || role == Qt::EditRole)\n    {\n        return valueForIndex(index);\n    }\n    else if (role == Qt::ToolTipRole)\n    {\n        return tooltipForIndex(index);\n    }\n    else if (role == Qt::ForegroundRole)\n    {\n        return blackForValidRedForInvalidIndex(index);\n    }\n    else if (role == Qt::DecorationRole &&\n        (index.column() == PeripheralTemplateColumns::TEMPLATE || index.column() == PeripheralTemplateColumns::PATH))\n    {\n        return QIcon(QString(\":/icons/common/graphics/opened-folder.png\"));\n    }\n\n    return QVariant();\n}\n\n//-----------------------------------------------------------------------------\n// Function: PeripheralTemplateModel::setData()\n//-----------------------------------------------------------------------------\nbool PeripheralTemplateModel::setData(QModelIndex const& index, QVariant const& value, int role)\n{\n    if (!index.isValid() || index.row() < 0 || index.row() >= templates_.size())\n    {\n\t\treturn false;\n\t}\n\n    QSharedPointer<RenodeStructs::peripheralTemplate> indexedTemplate = templates_.at(index.row());\n    if (Qt::EditRole == role)\n    {\n        if (index.column() == PeripheralTemplateColumns::NAME)\n        {\n            indexedTemplate->identifier_ = value.toString();\n        }\n        else if (index.column() == PeripheralTemplateColumns::TEMPLATE)\n        {\n            indexedTemplate->template_ = value.toString();\n        }\n        else if (index.column() == PeripheralTemplateColumns::PATH)\n        {\n            indexedTemplate->path_ = value.toString();\n        }\n\n        emit dataChanged(index, index);\n        return true;\n    }\n\n    return false;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PeripheralTemplateModel::valueForIndex()\n//-----------------------------------------------------------------------------\nQVariant PeripheralTemplateModel::valueForIndex(QModelIndex const& index) const\n{\n    QSharedPointer<RenodeStructs::peripheralTemplate> indexedTemplate = templates_.at(index.row());\n\n\tif (index.column() == PeripheralTemplateColumns::NAME)\n\t{\n\t\treturn indexedTemplate->identifier_;\n\t}\n\telse if (index.column() == PeripheralTemplateColumns::TEMPLATE)\n\t{\n\t\treturn indexedTemplate->template_;\n\t}\n    else if (index.column() == PeripheralTemplateColumns::PATH)\n    {\n        return indexedTemplate->path_;\n    }\n   \n    return QVariant();\n}\n\n//-----------------------------------------------------------------------------\n// Function: PeripheralTemplateModel::tooltipForIndex()\n//-----------------------------------------------------------------------------\nQVariant PeripheralTemplateModel::tooltipForIndex(QModelIndex const& index) const\n{\n\tif (index.column() == PeripheralTemplateColumns::NAME)\n\t{\n        return QString(\"Name of the template\");\n    }\n\telse if (index.column() == PeripheralTemplateColumns::TEMPLATE)\n\t{\n        return QString(\"The template python file path relative to the installation folder.\\n\" + data(index).toString());\n\t}\n\telse if (index.column() == PeripheralTemplateColumns::PATH)\n\t{\n\t\treturn QString(\"The folder path for the created python file relative to the generation destination folder.\\n\" + data(index).toString());\n\t}\n\n    return QVariant();\n}\n\n//-----------------------------------------------------------------------------\n// Function: PeripheralTemplateModel::blackForValidRedForInvalidIndex()\n//-----------------------------------------------------------------------------\nQVariant PeripheralTemplateModel::blackForValidRedForInvalidIndex(QModelIndex const& index) const\n{\n    if (index.column() == PeripheralTemplateColumns::TEMPLATE)\n    {\n        QString templatePath = QCoreApplication::applicationDirPath() + \"/\" + index.data().toString();\n        if (!QFile::exists(templatePath))\n        {\n            return KactusColors::ERROR;\n        }\n    }\n\n    return KactusColors::REGULAR_TEXT;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PeripheralTemplateModel::onAddRow()\n//-----------------------------------------------------------------------------\nvoid PeripheralTemplateModel::onAddRow()\n{\n\tint lastRow = static_cast<int>(templates_.count());\n    addItem(lastRow);\n}\n\n//-----------------------------------------------------------------------------\n// Function: PeripheralTemplateModel::addItem()\n//-----------------------------------------------------------------------------\nvoid PeripheralTemplateModel::addItem(int newItemRow)\n{\n\tbeginInsertRows(QModelIndex(), newItemRow, newItemRow);\n\n\tQSharedPointer<RenodeStructs::peripheralTemplate> newTemplate(new RenodeStructs::peripheralTemplate());\n\ttemplates_.insert(newItemRow, newTemplate);\n\n\tendInsertRows();\n}\n\n//-----------------------------------------------------------------------------\n// Function: PeripheralTemplateModel::onAddItem()\n//-----------------------------------------------------------------------------\nvoid PeripheralTemplateModel::onAddItem(const QModelIndex& index)\n{\n\tint row = static_cast<int>(templates_.count());\n\tif (index.isValid())\n\t{\n\t\trow = index.row();\n\t}\n\n    addItem(row);\n}\n\n//-----------------------------------------------------------------------------\n// Function: PeripheralTemplateModel::onRemoveItem()\n//-----------------------------------------------------------------------------\nvoid PeripheralTemplateModel::onRemoveItem(const QModelIndex& index)\n{\n    onRemoveRow(index.row());\n}\n\n//-----------------------------------------------------------------------------\n// Function: PeripheralTemplateModel::onRemoveRow()\n//-----------------------------------------------------------------------------\nvoid PeripheralTemplateModel::onRemoveRow(int row)\n{\n\tif (row < 0 || row >= templates_.count())\n\t{\n\t\treturn;\n\t}\n\n\tbeginRemoveRows(QModelIndex(), row, row);\n\n    templates_.removeAt(row);\n\n\tendRemoveRows();\n}\n"
  },
  {
    "path": "Plugins/RenodeGenerator/CPUDialog/TemplateEditor/PeripheralTemplateModel.h",
    "content": "//-----------------------------------------------------------------------------\n// File: PeripheralTemplateModel.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 24.02.2023\n//\n// Description:\n// The model to manage the peripheral templates.\n//-----------------------------------------------------------------------------\n\n#ifndef PERIPHERALTEMPLATEMODEL_H\n#define PERIPHERALTEMPLATEMODEL_H\n\n#include <Plugins/RenodeGenerator/CPUDialog/RenodeStructs.h>\n\n#include <QAbstractTableModel>\n\n//-----------------------------------------------------------------------------\n//! The model to manage the peripheral templates.\n//-----------------------------------------------------------------------------\nclass PeripheralTemplateModel : public QAbstractTableModel\n{\n\tQ_OBJECT\n\npublic:\n\n\t/*!\n\t *  The constructor.\n\t *\n\t *    @param [in] parent  Pointer to the owner of this model.\n\t */\n\tPeripheralTemplateModel(QObject *parent);\n\t\n\t/*!\n     *  The destructor.\n     */\n    virtual ~PeripheralTemplateModel() = default;\n\n    /*!\n     *  Setup the peripheral templates.\n     *\n     *    @param [in] newTemplates\tThe selected peripheral templates.\n     */\n\tvoid setupTemplates(QVector<QSharedPointer<RenodeStructs::peripheralTemplate> > newTemplates);\n\n\t/*!\n\t *  Get the list of peripheral templates.\n\t *\n\t *    @return List of peripheral templates.\n\t */\n\tQVector<QSharedPointer<RenodeStructs::peripheralTemplate> > getTemplates() const;\n\n\t/*!\n     *  Get the number of rows an item contains.\n\t *\n\t *    @param [in] parent  Identifies the parent that's row count is requested.\n\t *\n\t *    @return Number of rows the item has.\n\t */\n\tvirtual int rowCount(QModelIndex const& parent = QModelIndex()) const;\n\n\t/*!\n     *  Get the number of columns the item has to be displayed.\n\t *\n\t *    @param [in] parent  Identifies the parent that's column count is requested.\n\t *\n\t *    @return The number of columns to be displayed.\n\t */\n\tvirtual int columnCount(QModelIndex const& parent = QModelIndex()) const;\n\n\t/*!\n     *  Get the item flags that defines the possible operations for the item.\n\t *\n\t *    @param [in] index   Model index that identifies the item.\n\t *\n\t *    @return Qt::ItemFlags specify the possible operations for the item.\n\t */\n\tQt::ItemFlags flags(QModelIndex const& index) const;\n\n\t/*!\n     *  Get the header data for specified header.\n\t *\n\t *    @param [in] section         The section specifies the row/column number for the header.\n\t *    @param [in] orientation     Specified if horizontal or vertical header is wanted.\n\t *    @param [in] role            Specifies the type of the requested data.\n\t *\n\t *    @return QVariant Contains the requested data.\n\t */\n\tvirtual QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;\n\n\t/*!\n     *  Get the data for specified item.\n\t *\n\t *    @param [in] index   Specifies the item that's data is requested.\n\t *    @param [in] role    The role that defines what kind of data is requested.\n\t *\n\t *    @return QVariant Contains the data for the item.\n\t */\n\tvirtual QVariant data(QModelIndex const& index, int role = Qt::DisplayRole) const;\n\n\t/*!\n     *  Save the data to the model for specified item.\n\t *\n\t *    @param [in] index   The model index of the item that's data is to be saved.\n\t *    @param [in] value   The data that is to be saved.\n\t *    @param [in] role    The role specifies what kind of data should be saved.\n\t *\n\t *    @return True if saving happened successfully.\n\t */\n\tbool setData(QModelIndex const& index, const QVariant& value, int role = Qt::EditRole);\n    \n    //! No copying. No assignment.\n\tPeripheralTemplateModel(const PeripheralTemplateModel& other) = delete;\n\tPeripheralTemplateModel& operator=(const PeripheralTemplateModel& other) = delete;\n\npublic slots:\n\t\n\t/*!\n\t *  Add a new empty row to the model\n\t */\n\tvoid onAddRow();\n\n\t/*!\n\t *  A new item should be added to given index.\n\t *\n\t *    @param [in] index   The position where new item should be added at.\n\t */\n\tvoid onAddItem(const QModelIndex& index);\n\n\t/*!\n\t *  An item should be removed from the model.\n\t *\n\t *    @param [in] index   Identifies the item that should be removed.\n\t */\n\tvoid onRemoveItem(const QModelIndex& index);\n\n\t/*!\n\t *  Remove a row from the model.\n\t *\n\t *    @param [in] row Specifies the row to remove\n\t */\n\tvoid onRemoveRow(int row);\n\nprivate:\n\n\t/*!\n\t *  Add a new item to the selected row.\n\t *\t\n\t *    @param [in] newItemRow\tThe selected row.\n\t */\n\tvoid addItem(int newItemRow);\n\n    /*!\n     *  Gets the value for the given index.\n     *\n     *    @param [in] index   The index of the target data.\n     *\n     *    @return The data in the given index.\n     */\n    QVariant valueForIndex(QModelIndex const& index) const;\n\n    /*!\n     *  Gets the tooltip value for the given index.\n     *\n     *    @param [in] index   The index of the target data.\n     *\n     *    @return The tooltip data in the given index.\n     */\n    QVariant tooltipForIndex(QModelIndex const& index) const;\n\n    /*!\n     *  Get the color for the selected index.\n     *\t\n     *    @param [in] index   The selected index.\n     *\n     *    @return Color of the selected index. Black for valid index, red for invalid index.\n     */\n    QVariant blackForValidRedForInvalidIndex(QModelIndex const& index) const;\n\n    //-----------------------------------------------------------------------------\n    // Data.\n    //-----------------------------------------------------------------------------\n\n    //! The peripheral template details being edited.\n\tQVector<QSharedPointer<RenodeStructs::peripheralTemplate> > templates_;\n};\n\n#endif // PERIPHERALTEMPLATEMODEL_H\n"
  },
  {
    "path": "Plugins/RenodeGenerator/CPUDialog/TemplateEditor/PeripheralTemplatesDialog.cpp",
    "content": "﻿//-----------------------------------------------------------------------------\n// File: PeripheralTemplatesDialog.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 29.05.2023\n//\n// Description:\n// Dialog for editing templates for python peripherals in Renode generator.\n//-----------------------------------------------------------------------------\n\n#include \"PeripheralTemplatesDialog.h\"\n\n#include <Plugins/RenodeGenerator/CPUDialog/TemplateEditor/PeripheralTemplateEditor.h>\n\n#include <QVBoxLayout>\n#include <QDialogButtonBox>\n#include <QPushButton>\n\n//-----------------------------------------------------------------------------\n// Function: PeripheralTemplatesDialog::PeripheralTemplatesDialog()\n//-----------------------------------------------------------------------------\nPeripheralTemplatesDialog::PeripheralTemplatesDialog(QString const& generationFolder, QWidget* parent):\nQDialog(parent),\ntemplatesEditor_(new PeripheralTemplateEditor(generationFolder, this))\n{\n    setWindowTitle(\"Peripheral Templates\");\n\n    setupLayout();\n\n    setMinimumWidth(800);\n}\n\n//-----------------------------------------------------------------------------\n// Function: PeripheralTemplatesDialog::setupLayout()\n//-----------------------------------------------------------------------------\nvoid PeripheralTemplatesDialog::setupLayout()\n{\n    auto dialogButtons(new QDialogButtonBox(QDialogButtonBox::Cancel, Qt::Horizontal));\n    QPushButton* okButton = dialogButtons->addButton(\"Ok\", QDialogButtonBox::AcceptRole);\n    okButton->setDefault(true);\n    okButton->setAutoDefault(true);\n    \n    connect(dialogButtons, SIGNAL(accepted()), this, SLOT(accept()), Qt::UniqueConnection);\n    connect(dialogButtons, SIGNAL(rejected()), this, SLOT(reject()), Qt::UniqueConnection);\n    \n    auto layout(new QVBoxLayout(this));\n    layout->addWidget(templatesEditor_, 1);\n    layout->addWidget(dialogButtons);\n}\n\n//-----------------------------------------------------------------------------\n// Function: PeripheralTemplatesDialog::setupTemplates()\n//-----------------------------------------------------------------------------\nvoid PeripheralTemplatesDialog::setupTemplates(QVector<QSharedPointer<RenodeStructs::peripheralTemplate> > newTemplates)\n{\n    templatesEditor_->setupTemplates(newTemplates);\n}\n\n//-----------------------------------------------------------------------------\n// Function: PeripheralTemplatesDialog::getTemplates()\n//-----------------------------------------------------------------------------\nQVector<QSharedPointer<RenodeStructs::peripheralTemplate> > PeripheralTemplatesDialog::getTemplates() const\n{\n    return templatesEditor_->getTemplates();\n}\n"
  },
  {
    "path": "Plugins/RenodeGenerator/CPUDialog/TemplateEditor/PeripheralTemplatesDialog.h",
    "content": "//-----------------------------------------------------------------------------\n// File: PeripheralTemplatesDialog.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 29.05.2023\n//\n// Description:\n// Dialog for editing templates for python peripherals in Renode generator.\n//-----------------------------------------------------------------------------\n\n#ifndef PERIPHERALTEMPLATESDIALOG_H\n#define PERIPHERALTEMPLATESDIALOG_H\n\n#include <Plugins/RenodeGenerator/CPUDialog/RenodeStructs.h>\n\n#include <QDialog>\n\nclass PeripheralTemplateEditor;\n\n//-----------------------------------------------------------------------------\n//! Dialog for editing templates for python peripherals in Renode generator.\n//-----------------------------------------------------------------------------\nclass PeripheralTemplatesDialog : public QDialog\n{\n    Q_OBJECT\n\npublic:\n\n    /*!\n     *  The constructor.\n     *\n     *    @param [in] configurationFolder     Folder path for the generator.\n     *    @param [in] parent                  Parent widget.\n     */\n\tPeripheralTemplatesDialog(QString const& generationFolder, QWidget* parent);\n\n\t/*!\n     *  The destructor.\n     */\n    virtual ~PeripheralTemplatesDialog() = default;\n\n    /*!\n     *  Setup the available peripheral templates.\n     *\t\n     *    @param [in] newTemplates    List of the selected peripheral templates.\n     */\n    void setupTemplates(QVector<QSharedPointer<RenodeStructs::peripheralTemplate> > newTemplates);\n\n    /*!\n     *  Get a list of the available peripheral templates.\n     *\n     *    @return List of peripheral templates.\n     */\n    QVector<QSharedPointer<RenodeStructs::peripheralTemplate> > getTemplates() const;\n\nprivate:\n\n    // Disable copying.\n    PeripheralTemplatesDialog(PeripheralTemplatesDialog const& rhs);\n    PeripheralTemplatesDialog& operator=(PeripheralTemplatesDialog const& rhs);\n\n    /*!\n     *  Setup the layout.\n     */\n    void setupLayout();\n\n    //-----------------------------------------------------------------------------\n    // Data.\n    //-----------------------------------------------------------------------------\n    \n    //! List of available peripheral templates.\n    PeripheralTemplateEditor* templatesEditor_;\n};\n\n#endif // PERIPHERALTEMPLATESDIALOG_H"
  },
  {
    "path": "Plugins/RenodeGenerator/RenodeConfigurationManager.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: RenodeConfigurationManager.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 21.04.2023\n//\n// Description:\n// Manager for storing and restoring renode editor configurations.\n//-----------------------------------------------------------------------------\n\n#include \"RenodeConfigurationManager.h\"\n\n#include <Plugins/RenodeGenerator/CPUDialog/RenodeUtilities.h>\n\n#include <IPXACTmodels/Component/File.h>\n\n#include <QJsonArray>\n\n//-----------------------------------------------------------------------------\n// Function: RenodeConfigurationManager::RenodeConfigurationManager()\n//-----------------------------------------------------------------------------\nRenodeConfigurationManager::RenodeConfigurationManager(IPluginUtility* utility) :\nPluginConfigurationManager(utility),\ncpuArray_()\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: RenodeConfigurationManager::getConfigurationObject()\n//-----------------------------------------------------------------------------\nQJsonObject RenodeConfigurationManager::getConfigurationObject(QSharedPointer<Component> component)\n{\n    QJsonDocument configurationDocument = getConfigurationDocument(component, RenodeConstants::CONFIGURATIONFILEEXTENSION);\n    if (configurationDocument.isObject())\n    {\n        QJsonObject configurationObject = configurationDocument.object();\n\n        QJsonValue multiCpuValue = configurationObject.value(RenodeConstants::CPUS);\n        if (multiCpuValue.isArray())\n        {\n            cpuArray_ = multiCpuValue.toArray();\n        }\n\n        return configurationObject;\n    }\n\n    return QJsonObject();\n}\n\n//-----------------------------------------------------------------------------\n// Function: RenodeConfigurationManager::createConfigureFile()\n//-----------------------------------------------------------------------------\nvoid RenodeConfigurationManager::createConfigureFile(QSharedPointer<RenodeCpuRoutesContainer> renodeData,\n    QString const& selectedView, bool saveToFileSet, QString const& selectedFileSet, QString const& folderPath,\n    bool writeCPU, QString const& cpuFileName, bool writeMemory, QString const& memoryFileName, bool writePeripherals,\n    QString const& peripheralsFileName, QString const& selectedCpu, QSharedPointer<Component> topComponent)\n{\n    QFile configurationFile(getPathToConfigurationFile(topComponent, RenodeConstants::CONFIGURATIONFILEEXTENSION));\n    if (!configurationFile.open(QIODevice::WriteOnly))\n    {\n        return;\n    }\n\n    QJsonDocument document = createJsonDocument(renodeData, selectedView, saveToFileSet, selectedFileSet, folderPath,\n        writeCPU, cpuFileName, writeMemory, memoryFileName, writePeripherals, peripheralsFileName, selectedCpu);\n    configurationFile.write(document.toJson());\n\n    writeModelToFile(topComponent);\n}\n\n//-----------------------------------------------------------------------------\n// Function: RenodeConfigurationManager::createJsonDocument()\n//-----------------------------------------------------------------------------\nQJsonDocument RenodeConfigurationManager::createJsonDocument(QSharedPointer<RenodeCpuRoutesContainer> renodeCpu,\n    QString const& selectedView, bool saveToFileSetFlag, QString const& selectedFileSet, QString const& folderPath,\n    bool writeCPU, QString const& cpuFileName, bool writeMemory, QString const& memoryFileName, bool writePeripherals,\n    QString const& peripheralsFileName, QString const& selectedCpu)\n{\n    QJsonObject configurationObject;\n\n    removeCpuContainerFromConfigurationArray(renodeCpu);\n\n    QJsonObject cpuObject;\n\n    cpuObject.insert(RenodeConstants::CPUNAME, renodeCpu->getFileName());\n    cpuObject.insert(RenodeConstants::CPUCLASS, renodeCpu->getClassName());\n    cpuObject.insert(RenodeConstants::CPUTYPE, renodeCpu->getCpuType());\n    cpuObject.insert(RenodeConstants::CPUTIME, renodeCpu->getTimeProvider());\n\n    if (!renodeCpu->getMemories().isEmpty())\n    {\n        QJsonArray memoryArray;\n\n        for (auto memory : renodeCpu->getMemories())\n        {\n            QJsonObject memoryObject;\n            memoryObject.insert(RenodeConstants::MEMORYNAME, memory->memoryName_);\n            memoryObject.insert(RenodeConstants::MEMORYCLASS, memory->className_);\n\n            memoryArray.push_back(memoryObject);\n        }\n\n        cpuObject.insert(RenodeConstants::MEMORY, memoryArray);\n    }\n\n    if (!renodeCpu->getPeripherals().isEmpty())\n    {\n        QJsonArray peripheralArray;\n\n        for (auto peripheral : renodeCpu->getPeripherals())\n        {\n            QJsonObject peripheralObject;\n\n            peripheralObject.insert(RenodeConstants::PERIPHERALNAME, peripheral->peripheralName_);\n            peripheralObject.insert(RenodeConstants::PERIPHERALCLASS, peripheral->className_);\n            peripheralObject.insert(RenodeConstants::PERIPHERALINITABLE, peripheral->initable_);\n            peripheralObject.insert(RenodeConstants::PERIPHERALPATH, peripheral->filePath_);\n\n            if (peripheral->template_)\n            {\n                peripheralObject.insert(RenodeConstants::PERIPHERALTEMPLATE, peripheral->template_->identifier_);\n            }\n\n            peripheralArray.push_back(peripheralObject);\n        }\n\n        cpuObject.insert(RenodeConstants::PERIPHERALS, peripheralArray);\n    }\n\n    cpuArray_.push_back(cpuObject);\n\n    configurationObject.insert(RenodeConstants::CPUS, cpuArray_);\n\n    configurationObject.insert(RenodeConstants::SINGLECPU, selectedCpu);\n    configurationObject.insert(RenodeConstants::VIEW, selectedView);\n    configurationObject.insert(RenodeConstants::FOLDERPATH, folderPath);\n    configurationObject.insert(RenodeConstants::SAVETOFILESET, saveToFileSetFlag);\n    configurationObject.insert(RenodeConstants::FILESET, selectedFileSet);\n\n    QJsonObject writeFlagsObject;\n    writeFlagsObject.insert(RenodeConstants::SINGLECPU, writeCPU);\n    writeFlagsObject.insert(RenodeConstants::MEMORY, writeMemory);\n    writeFlagsObject.insert(RenodeConstants::PERIPHERALS, writePeripherals);\n\n    if (!cpuFileName.isEmpty())\n    {\n        writeFlagsObject.insert(RenodeConstants::RENODECPUFILEIDENTIFIER, cpuFileName);\n    }\n    if (!memoryFileName.isEmpty())\n    {\n        writeFlagsObject.insert(RenodeConstants::RENODEMEMORYFILEIDENTIFIER, memoryFileName);\n    }\n    if (!peripheralsFileName.isEmpty())\n    {\n        writeFlagsObject.insert(RenodeConstants::RENODEPERIPHERALFILEIDENTIFIER, peripheralsFileName);\n    }\n\n    configurationObject.insert(RenodeConstants::WRITEFILES, writeFlagsObject);\n\n    QJsonDocument document(configurationObject);\n    return document;\n}\n\n//-----------------------------------------------------------------------------\n// Function: RenodeConfigurationManager::removeCpuContainerFromConfigurationArray()\n//-----------------------------------------------------------------------------\nvoid RenodeConfigurationManager::removeCpuContainerFromConfigurationArray(QSharedPointer<RenodeCpuRoutesContainer> cpuContainer)\n{\n    for (int i = 0; i < cpuArray_.size(); ++i)\n    {\n        auto configurationCpu = cpuArray_.at(i);\n        if (configurationCpu.isObject())\n        {\n            QJsonObject arraydCpuObject = configurationCpu.toObject();\n            if (arraydCpuObject.value(RenodeConstants::CPUNAME).toString() == cpuContainer->getFileName())\n            {\n                cpuArray_.removeAt(i);\n                return;\n            }\n        }\n    }\n}\n"
  },
  {
    "path": "Plugins/RenodeGenerator/RenodeConfigurationManager.h",
    "content": "//-----------------------------------------------------------------------------\n// File: RenodeConfigurationManager.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 21.04.2023\n//\n// Description:\n// Manager for storing and restoring renode editor configurations.\n//-----------------------------------------------------------------------------\n\n#ifndef RENODECONFIGURATIONMANAGER_H\n#define RENODECONFIGURATIONMANAGER_H\n\n#include <Plugins/common/PluginConfigurationManager.h>\n\nclass RenodeCpuRoutesContainer;\n\n#include <QJsonArray>\n\n//-----------------------------------------------------------------------------\n//! Manager for storing and restoring renode editor configurations.\n//-----------------------------------------------------------------------------\nclass RenodeConfigurationManager : public PluginConfigurationManager\n{\n\npublic:\n    \n    /*!\n     *  The constructor.\n     */\n    RenodeConfigurationManager(IPluginUtility* utility);\n    \n    /*!\n     * The destructor.\n     */\n    ~RenodeConfigurationManager() = default;\n    \n    /*!\n     *  Get the configuration object of a single CPU.\n     *\n     *    @param [in] component   The containing component.\n     *    @param [in] utility     Utilities for enabling plugin execution.\n     *\n     *    @return The configuration object.\n     */\n    QJsonObject getConfigurationObject(QSharedPointer<Component> component);\n    \n    /*!\n     *  Create a configuration file.\n     *\n     *    @param [in] renodeData              Container for renode generator data.\n     *    @param [in] selectedView            Name of the view to use in the generator.\n     *    @param [in] saveToFileSet           Flag for save to file set.\n     *    @param [in] selectedFileSet         Name of the target file set.\n     *    @param [in] folderPath              Path for the renode files.\n     *    @param [in] writeCPU                Flag for writing a CPU file.\n     *    @param [in] cpuFileName             Name for the CPU file.\n     *    @param [in] writeMemory             Flag for writing a memory file.\n     *    @param [in] memoryFileName          Name for the memory file.\n     *    @param [in] writePeripherals        Flag for writing a peripherals file.\n     *    @param [in] peripheralsFileName     Name for the peripherals file.\n     *    @param [in] selectedCpu             Name of the active CPU.\n     *    @param [in] topComponent            Top level component.\n     */\n    void createConfigureFile(QSharedPointer<RenodeCpuRoutesContainer> renodeData,\n        QString const& selectedView,\n        bool saveToFileSet,\n        QString const& selectedFileSet,\n        QString const& folderPath,\n        bool writeCPU,\n        QString const& cpuFileName,\n        bool writeMemory,\n        QString const& memoryFileName,\n        bool writePeripherals,\n        QString const& peripheralsFileName,\n        QString const& selectedCpu,\n        QSharedPointer<Component> topComponent);\n\nprivate:\n\n    /*!\n     *  Create a JSON document for storing the generator configurations.\n     *\n     *    @param [in] renodeCpu               Container for renode generator data.\n     *    @param [in] selectedView            Name of the view to use in the generator.\n     *    @param [in] saveToFileSetFlag       Flag for save to file set.\n     *    @param [in] selectedFileSet         Name of the target file set.\n     *    @param [in] folderPath              Path for the renode files.\n     *    @param [in] cpuFileName             Name for the CPU file.\n     *    @param [in] writeMemory             Flag for writing a memory file.\n     *    @param [in] memoryFileName          Name for the memory file.\n     *    @param [in] writePeripherals        Flag for writing a peripherals file.\n     *    @param [in] peripheralsFileName     Name for the peripherals file.\n     *    @param [in] selectedCpu             Name of the active CPU.\n     *\n     *    @return The JSON configuration document.\n     */\n    QJsonDocument createJsonDocument(QSharedPointer<RenodeCpuRoutesContainer> renodeCpu,\n        QString const& selectedView,\n        bool saveToFileSetFlag,\n        QString const& selectedFileSet,\n        QString const& folderPath,\n        bool writeCPU,\n        QString const& cpuFileName,\n        bool writeMemory,\n        QString const& memoryFileName,\n        bool writePeripherals,\n        QString const& peripheralsFileName,\n        QString const& selectedCpu);\n\n    /*!\n     *  Remove the selected CPU container from the CPU configuration array.\n     *\n     *    @param [in] cpuContainer    The selected CPU container.\n     */\n    void removeCpuContainerFromConfigurationArray(QSharedPointer<RenodeCpuRoutesContainer> cpuContainer);\n\n    //-----------------------------------------------------------------------------\n    // Data.\n    //-----------------------------------------------------------------------------\n\n    //! Configuration array for CPUs.\n    QJsonArray cpuArray_;\n};\n\n#endif // RENODECONFIGURATIONMANAGER_H\n"
  },
  {
    "path": "Plugins/RenodeGenerator/RenodeGenerator.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: RenodeGenerator.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Mikko Teuho\n// Date: 14.02.2023\n//\n// Description:\n// Creates a Renode file.\n//-----------------------------------------------------------------------------\n\n#include \"RenodeGenerator.h\"\n\n#include <IPXACTmodels/generaldeclarations.h>\n\n#include <Plugins/RenodeGenerator/CPUDialog/RenodeCpuRoutesContainer.h>\n#include <Plugins/RenodeGenerator/CPUDialog/RenodeUtilities.h>\n\n#include <QCoreApplication>\n#include <QDir>\n\n//-----------------------------------------------------------------------------\n// Function: RenodeGenerator::RenodeGenerator()\n//-----------------------------------------------------------------------------\nRenodeGenerator::RenodeGenerator(LibraryInterface* library):\nlibrary_(library)\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: RenodeGenerator::generate()\n//-----------------------------------------------------------------------------\nvoid RenodeGenerator::generate(QString const& componentPath, QSharedPointer<RenodeCpuRoutesContainer> const& cpuContainer,\n    bool createCpuFile, QString const& cpuFileName, bool createMemoryFile, QString const& memoryFileName,\n    bool createPeripheralFile, QString const& peripheralFileName)\n{\n    if (cpuContainer->getRoutes().empty() == false)\n    {\n        if (createCpuFile || createMemoryFile || createPeripheralFile)\n        {\n            writeFiles(componentPath, cpuContainer, createCpuFile, cpuFileName,\n                createMemoryFile, memoryFileName, createPeripheralFile, peripheralFileName);\n        }\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: RenodeGenerator::getGeneratedFiles()\n//-----------------------------------------------------------------------------\nQStringList RenodeGenerator::getGeneratedFiles() const\n{\n    return generatedFiles_;\n}\n\n//-----------------------------------------------------------------------------\n// Function: RenodeGenerator::writeFiles()\n//-----------------------------------------------------------------------------\nvoid RenodeGenerator::writeFiles(QString const& componentPath, QSharedPointer<RenodeCpuRoutesContainer> cpuRoute,\n    bool createCpuFile, QString const& cpuFileName, bool createMemoryFile,\n    QString const& memoryFileName, bool createPeripheralFile, QString const& peripheralFileName)\n{\n    QStringList fileNames;\n    QSharedPointer<const ConnectivityInterface> cpuInterface = cpuRoute->getRoutes().first()->cpuInterface_;\n    QSharedPointer<const ConnectivityComponent> routeComponent = cpuInterface->getInstance();\n    QSharedPointer<const Component> interfaceComponent =\n        ConnectivityGraphUtilities::getInterfacedComponent(library_, routeComponent);\n    if (interfaceComponent)\n    {\n        QString renodeFilePath = componentPath + \"/\";\n\n        if (createCpuFile)\n        {\n            writeCPU(renodeFilePath, cpuRoute, getUniqueFileName(fileNames, cpuFileName));\n        }\n        if (createMemoryFile)\n        {\n            writeMemories(renodeFilePath, cpuRoute, getUniqueFileName(fileNames, memoryFileName));\n        }\n        if (createPeripheralFile)\n        {\n            writePeripherals(renodeFilePath, componentPath, cpuRoute, getUniqueFileName(fileNames, peripheralFileName));\n        }\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: RenodeGenerator::getUniqueFileName()\n//-----------------------------------------------------------------------------\nQString RenodeGenerator::getUniqueFileName(QStringList& fileNames, QString const& currentFileName) const\n{\n    QString modifiedFileName = currentFileName;\n    if (fileNames.contains(modifiedFileName))\n    {\n        modifiedFileName = currentFileName + \"_\" + QString::number(getFileNumberExtension(fileNames, currentFileName));\n    }\n\n    fileNames.append(modifiedFileName);\n    return modifiedFileName;\n}\n\n//-----------------------------------------------------------------------------\n// Function: SVDGenerator::getFileNumberExtension()\n//-----------------------------------------------------------------------------\nint RenodeGenerator::getFileNumberExtension(QStringList const& fileNames, QString const& fileName) const\n{\n    int extensionNumber = -1;\n    for (QString file : fileNames)\n    {\n        if (file.contains(fileName))\n        {\n            extensionNumber++;\n        }\n    }\n\n    return extensionNumber;\n}\n\n//-----------------------------------------------------------------------------\n// Function: RenodeGenerator::writeCPU()\n//-----------------------------------------------------------------------------\nvoid RenodeGenerator::writeCPU(QString const& filePath, QSharedPointer<RenodeCpuRoutesContainer> cpuContainer,\n    QString const& fileName)\n{\n    QString cpuFilePath = filePath + fileName + \".\" + RenodeConstants::RENODEFILETYPE;\n\n    QFile outputFile(cpuFilePath);\n    if (!outputFile.open(QIODevice::WriteOnly))\n    {\n        return;\n    }\n\n    QTextStream stream(&outputFile);\n\n    const QString tab = \"    \";\n    stream << \"cpu: CPU.\" << cpuContainer->getClassName() << \" @ sysbus\" << Qt::endl;\n    stream << tab << \"cpuType: \\\"\" << cpuContainer->getCpuType() << \"\\\"\" << Qt::endl;\n    stream << tab << \"timeProvider: \" << cpuContainer->getTimeProvider() << Qt::endl;\n\n    generatedFiles_.append(cpuFilePath);\n}\n\n//-----------------------------------------------------------------------------\n// Function: RenodeGenerator::writePeripherals()\n//-----------------------------------------------------------------------------\nvoid RenodeGenerator::writePeripherals(QString const& filePath, QString const& peripheralPath,\n    QSharedPointer<RenodeCpuRoutesContainer> renodeCollection, QString const& fileName)\n{\n    if (renodeCollection->getPeripherals().isEmpty())\n    {\n        return;\n    }\n\n    QString peripheralFilePath = filePath + fileName + \".\" + RenodeConstants::RENODEFILETYPE;\n\n    QFile outputFile(peripheralFilePath);\n    if (!outputFile.open(QIODevice::WriteOnly))\n    {\n        return;\n    }\n\n    QTextStream stream(&outputFile);\n\n    const QString tab = \"    \";\n    for (auto const& peripheral : renodeCollection->getPeripherals())\n    {\n        writePeripheral(stream, peripheral, tab, peripheralPath);\n\n        if (peripheral != renodeCollection->getPeripherals().last())\n        {\n            stream << Qt::endl;\n        }\n    }\n\n    generatedFiles_.append(peripheralFilePath);\n}\n\n//-----------------------------------------------------------------------------\n// Function: RenodeGenerator::writePeripheral()\n//-----------------------------------------------------------------------------\nvoid RenodeGenerator::writePeripheral(QTextStream& stream, QSharedPointer<RenodeStructs::cpuPeripheral> peripheral,\n    QString const& tab, QString const& renodeFilePath)\n{\n    stream << peripheral->peripheralName_ << \": \" << peripheral->className_ << \" @ sysbus \" <<\n        peripheral->baseAddress_ << Qt::endl;\n    stream << tab << \"size: \" << peripheral->size_ << Qt::endl;\n\n    if (peripheral->className_ == RenodeConstants::PYTHONPERIPHERAL)\n    {\n        QString filePath = peripheral->filePath_;\n        if (filePath.last(1) != \"/\")\n        {\n            filePath.append(\"/\");\n        }\n\n        QString fileName = filePath + peripheral->peripheralName_ + \".\" + RenodeConstants::PYTHONFILETYPE;\n\n        stream << tab << \"initable: \" << QVariant(peripheral->initable_).toString() << Qt::endl;\n        stream << tab << \"filename: \\\"\" << fileName << \"\\\"\" << Qt::endl;\n\n        QString directoryPath = renodeFilePath + \"/\" + peripheral->filePath_;\n        \n        if (QDir pathDirectory(directoryPath); !pathDirectory.exists())\n        {\n            QDir currentDirectory(renodeFilePath);\n            currentDirectory.mkdir(peripheral->filePath_);\n        }\n\n        QString peripheralFilePath = renodeFilePath + \"/\" + fileName;\n        QFile peripheralOutputFile(peripheralFilePath);\n        peripheralOutputFile.open(QIODevice::WriteOnly);\n\n        if (peripheral->template_)\n        {\n            QString templatePath = QCoreApplication::applicationDirPath() + \"/\" + peripheral->template_->template_;\n            QFile templateFile(templatePath);\n            if (templateFile.open(QIODevice::ReadOnly))\n            {\n                QTextStream templateStream(&templateFile);\n                QTextStream peripheralStream(&peripheralOutputFile);\n\n                while (!templateStream.atEnd())\n                {\n                    peripheralStream << templateStream.readAll();\n                }\n            }\n        }\n\n        generatedFiles_.append(peripheralFilePath);\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: RenodeGenerator::writeMemories()\n//-----------------------------------------------------------------------------\nvoid RenodeGenerator::writeMemories(QString const& filePath,\n    QSharedPointer<RenodeCpuRoutesContainer> renodeCollection, QString const& fileName)\n{\n    if (renodeCollection->getMemories().isEmpty())\n    {\n        return;\n    }\n\n    QString memoryFilePath = filePath + fileName + \".\" + RenodeConstants::RENODEFILETYPE;\n    QFile outputFile(memoryFilePath);\n    if (!outputFile.open(QIODevice::WriteOnly))\n    {\n        return;\n    }\n\n    QTextStream stream(&outputFile);\n\n    const QString tab = \"    \";\n    for (auto const& memory : renodeCollection->getMemories())\n    {\n        writeMemory(stream, memory, tab);\n\n        if (memory != renodeCollection->getMemories().last())\n        {\n            stream << Qt::endl;\n        }\n    }\n\n    generatedFiles_.append(memoryFilePath);\n}\n\n//-----------------------------------------------------------------------------\n// Function: RenodeGenerator::writeMemory()\n//-----------------------------------------------------------------------------\nvoid RenodeGenerator::writeMemory(QTextStream& stream, QSharedPointer<RenodeStructs::cpuMemories> memory,\n    QString const& tab) const\n{\n    stream << memory->memoryName_ << \": \" << memory->className_ << \" @ sysbus \" << memory->baseAddress_ << Qt::endl;\n    stream << tab << \"size: \" << memory->size_ << Qt::endl;\n}\n"
  },
  {
    "path": "Plugins/RenodeGenerator/RenodeGenerator.h",
    "content": "//-----------------------------------------------------------------------------\n// File: RenodeGenerator.h\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Mikko Teuho\n// Date: 14.02.2023\n//\n// Description:\n// Creates Renode files for CPU, memory and peripherals.\n//-----------------------------------------------------------------------------\n\n#ifndef RENODEGENERATOR_H\n#define RENODEGENERATOR_H\n\n#include \"renodegeneratorplugin_global.h\"\n\n#include <Plugins/common/ConnectivityGraphUtilities.h>\n#include <Plugins/RenodeGenerator/CPUDialog/RenodeStructs.h>\n\nclass Component;\nclass LibraryInterface;\nclass RenodeCpuRoutesContainer;\n\n#include <QList>\n#include <QString>\n#include <QSharedPointer>\n#include <QTextStream>\n\n//-----------------------------------------------------------------------------\n//! Creates Renode files for CPU, memory and peripherals.\n//-----------------------------------------------------------------------------\nclass RENODEGENERATORPLUGIN_EXPORT RenodeGenerator\n{\npublic:\n    \n    /*!\n     *  The constructor.\n     *\n     *    @param [in] library     Interface for accessing libraries.\n     */\n    explicit RenodeGenerator(LibraryInterface* library);\n\n    /*!\n     *  The destructor.\n     */\n    ~RenodeGenerator() = default;\n\n    // Disable copying.\n    RenodeGenerator(RenodeGenerator const& rhs) = delete;\n    RenodeGenerator& operator=(RenodeGenerator const& rhs) = delete;\n\n    /*!\n     *  Generates slave memory listing for the given component.\n     *\n     *    @param [in] componentPath           Path to the component folder.\n     *    @param [in] cpuContainer            CPU and its connected routes.\n     *    @param [in] createCpuFile           Flag for creating a CPU file.\n     *    @param [in] cpuFileName             Name of the CPU file.\n     *    @param [in] createMemoryFile        Flag for creating a memory file.\n     *    @param [in] memoryFileName          Name of the memory file.\n     *    @param [in] createPeripheralFile    Flag for creating a peripherals file.\n     *    @param [in] peripheralFileName      Name of the peripherals file.\n     */\n    void generate(QString const& componentPath,\n        QSharedPointer<RenodeCpuRoutesContainer> const& cpuContainer,\n        bool createCpuFile,\n        QString const& cpuFileName,\n        bool createMemoryFile,\n        QString const& memoryFileName,\n        bool createPeripheralFile,\n        QString const& peripheralFileName);\n\n    /*!\n     *  Get the generated files.\n     *\n     *    @return The generated files.\n     */\n    QStringList getGeneratedFiles() const;\n\nprivate:\n\n    /*!\n     *  Writes the CPU listing into Renode platform files.\n     *\n     *    @param [in] componentPath           Path to the component folder.\n     *    @param [in] cpuRoute                The selected CPU route container.\n     *    @param [in] fileNames               Names of the generated Renode files.\n     *    @param [in] createCpuFile           Flag for creating a CPU file.\n     *    @param [in] cpuFileName             Name of the CPU file.\n     *    @param [in] createMemoryFile        Flag for creating a memory file.\n     *    @param [in] memoryFileName          Name of the memory file.\n     *    @param [in] createPeripheralFile    Flag for creating a peripherals file.\n     *    @param [in] peripheralFileName      Name of the peripherals file.\n     */\n    void writeFiles(QString const& componentPath,\n        QSharedPointer<RenodeCpuRoutesContainer> cpuRoute,\n        bool createCpuFile,\n        QString const& cpuFileName,\n        bool createMemoryFile,\n        QString const& memoryFileName,\n        bool createPeripheralFile,\n        QString const& peripheralFileName);\n\n    /*!\n     *  Get a unique file name using the selected file name.\n     *\n     *    @param [in] fileNames           List of used file names.\n     *    @param [in] currentFileName     The selected file name.\n     *\n     *    @return Unique file name.\n     */\n    QString getUniqueFileName(QStringList& fileNames, QString const& currentFileName) const;\n\n    /*!\n     *  Get the number of files containing the selected name.\n     *\n     *    @param [in] fileNames   List of the generated files.\n     *    @param [in] fileName    The selected file name.\n     *\n     *    @return Number of files containing the same name.\n     */\n    int getFileNumberExtension(QStringList const& fileNames, QString const& fileName) const;\n\n    /*!\n     *  Write the selected CPU.\n     *\n     *    @param [in] filePath        File path for the renode files.\n     *    @param [in] cpuContainer    The CPU data container.\n     *    @param [in] fileName        Name for the CPU file.\n     */\n    void writeCPU(QString const& filePath,\n        QSharedPointer<RenodeCpuRoutesContainer> cpuContainer,\n        QString const& fileName);\n\n    /*!\n     *  Write the peripherals of the selected CPU route container.\n     *\n     *    @param [in] filePath            File path for the renode files.\n     *    @param [in] peripheralPath      Path for the renode platform files.\n     *    @param [in] renodeCollection    The selected CPU route container.\n     *    @param [in] fileName            Name for the peripherals file.\n     */\n    void writePeripherals(QString const& filePath,\n        QString const& peripheralPath,\n        QSharedPointer<RenodeCpuRoutesContainer> renodeCollection,\n        QString const& fileName);\n\n    /*!\n     *  Write a single peripheral.\n     *\n     *    @param [in] stream          The text stream.\n     *    @param [in] peripheral      The selected peripheral item.\n     *    @param [in] tab             Current tab.\n     *    @param [in] renodeFilePath  The file path to the Renode platform files.\n     */\n    void writePeripheral(QTextStream& stream,\n        QSharedPointer<RenodeStructs::cpuPeripheral> peripheral,\n        QString const& tab,\n        QString const& renodeFilePath);\n\n    /*!\n     *  Write the memory of the selected CPU.\n     *\n     *    @param [in] filePath            File path for the Renode platform files.\n     *    @param [in] renodeCollection    The selected CPU route container.\n     *    @param [in] fileName            Name of the memory file.\n     */\n    void writeMemories(QString const& filePath,\n        QSharedPointer<RenodeCpuRoutesContainer> renodeCollection,\n        QString const& fileName);\n\n    /*!\n     *  Write a single memory item.\n     *\n     *    @param [in] stream      The text stream.\n     *    @param [in] memory      The selected memory item.\n     *    @param [in] tab         Current tab.\n     */\n    void writeMemory(QTextStream& stream, QSharedPointer<RenodeStructs::cpuMemories> memory, \n        QString const& tab) const;\n\n    //-----------------------------------------------------------------------------\n    // Data.\n    //-----------------------------------------------------------------------------\n\n    //! The available IP-XACT library.\n    LibraryInterface* library_;\n\n    //! Paths to the generated files.\n    QStringList generatedFiles_;\n};\n\n#endif // RENODEGENERATOR_H\n"
  },
  {
    "path": "Plugins/RenodeGenerator/RenodeGenerator.qrc",
    "content": "<RCC>\n    <qresource prefix=\"/icons\">\n        <file>RenodeGenerator.png</file>\n    </qresource>\n</RCC>\n"
  },
  {
    "path": "Plugins/RenodeGenerator/RenodeGeneratorPlugin.cpp",
    "content": "// Copyright Tampere University of Technology\n//-----------------------------------------------------------------------------\n// File: RenodeGeneratorPlugin.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 10.02.2023\n//\n// Description:\n// Renode generator plugin.\n//-----------------------------------------------------------------------------\n\n#include \"RenodeGeneratorPlugin.h\"\n\n#include <RenodeGenerator.h>\n\n#include <Plugins/common/HDLParser/HDLParserCommon.h>\n#include <Plugins/common/CPUDialog/CPUSelectionDialog.h>\n\n#include <Plugins/PluginSystem/GeneratorPlugin/GenerationControl.h>\n#include <Plugins/PluginSystem/GeneratorPlugin/MessagePasser.h>\n\n#include <Plugins/RenodeGenerator/RenodeConfigurationManager.h>\n#include <Plugins/RenodeGenerator/RenodeSettingsWidget.h>\n#include <Plugins/RenodeGenerator/CPUDialog/RenodeCpuEditor.h>\n#include <Plugins/RenodeGenerator/CPUDialog/RenodeCpuRoutesContainer.h>\n#include <Plugins/RenodeGenerator/CPUDialog/RenodeFileEditor.h>\n#include <Plugins/RenodeGenerator/CPUDialog/RenodeUtilities.h>\n#include <Plugins/RenodeGenerator/CPUDialog/TemplateEditor/PeripheralTemplateConfigurer.h>\n\n#include <IPXACTmodels/Component/Component.h>\n#include <IPXACTmodels/Component/FileSet.h>\n#include <IPXACTmodels/Component/File.h>\n\n#include <QCoreApplication>\n#include <QFileInfo>\n#include <QMessageBox>\n#include <QDir>\n#include <QJsonDocument>\n#include <QJsonArray>\n#include <QJsonObject>\n\n//-----------------------------------------------------------------------------\n// Function: RenodeGeneratorPlugin::RenodeGeneratorPlugin()\n//-----------------------------------------------------------------------------\nRenodeGeneratorPlugin::RenodeGeneratorPlugin() :\nQObject(nullptr)\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: RenodeGeneratorPlugin::getName()\n//----------------------------------------------------------------------------\nQString RenodeGeneratorPlugin::getName() const\n{\n    return tr(\"Renode Generator\");\n}\n\n//-----------------------------------------------------------------------------\n// Function: RenodeGeneratorPlugin::getVersion()\n//-----------------------------------------------------------------------------\nQString RenodeGeneratorPlugin::getVersion() const\n{\n    return QStringLiteral(\"1.0\");\n}\n\n//-----------------------------------------------------------------------------\n// Function: RenodeGeneratorPlugin::getDescription()\n//-----------------------------------------------------------------------------\nQString RenodeGeneratorPlugin::getDescription() const\n{\n    return tr(\"Generate Renode platform files for CPU, memory and peripherals.\");\n}\n\n//-----------------------------------------------------------------------------\n// Function: RenodeGeneratorPlugin::getVendor()\n//-----------------------------------------------------------------------------\nQString RenodeGeneratorPlugin::getVendor() const\n{\n    return QStringLiteral(\"Tampere University (tuni.fi)\");\n}\n\n//-----------------------------------------------------------------------------\n// Function: RenodeGeneratorPlugin::getLicence()\n//-----------------------------------------------------------------------------\nQString RenodeGeneratorPlugin::getLicense() const\n{\n    return tr(\"GPL2\");\n}\n\n//-----------------------------------------------------------------------------\n// Function: RenodeGeneratorPlugin::getLicenceHolder()\n//-----------------------------------------------------------------------------\nQString RenodeGeneratorPlugin::getLicenseHolder() const\n{\n    return tr(\"Public\");\n}\n\n//-----------------------------------------------------------------------------\n// Function: RenodeGeneratorPlugin::getSettingsWidget()\n//-----------------------------------------------------------------------------\nQWidget* RenodeGeneratorPlugin::getSettingsWidget()\n{\n    return new RenodeSettingsWidget(&settingsModel_);\n}\n\n//-----------------------------------------------------------------------------\n// Function: RenodeGeneratorPlugin::getSettingsModel()\n//-----------------------------------------------------------------------------\nPluginSettingsModel* RenodeGeneratorPlugin::getSettingsModel()\n{\n    return &settingsModel_;\n}\n\n//-----------------------------------------------------------------------------\n// Function: RenodeGeneratorPlugin::getIcon()\n//-----------------------------------------------------------------------------\nQIcon RenodeGeneratorPlugin::getIcon() const\n{\n    return QIcon(QStringLiteral(\":icons/RenodeGenerator.png\"));\n}\n\n//-----------------------------------------------------------------------------\n// Function: RenodeGeneratorPlugin::checkGeneratorSupport()\n//-----------------------------------------------------------------------------\nbool RenodeGeneratorPlugin::checkGeneratorSupport(QSharedPointer<Component const> /*component*/,\n    QSharedPointer<Design const> design,\n    QSharedPointer<DesignConfiguration const> designConfiguration) const\n{\n    // Must be ran on a design.\n    return (design != nullptr && designConfiguration != nullptr);\n}\n\n//-----------------------------------------------------------------------------\n// Function: RenodeGeneratorPlugin::runGenerator()\n//-----------------------------------------------------------------------------\nvoid RenodeGeneratorPlugin::runGenerator(IPluginUtility* utility, QSharedPointer<Component> component,\n    QSharedPointer<Design> design, QSharedPointer<DesignConfiguration> designConfiguration)\n{\n    utility->printInfo(tr(\"Running %1 %2.\").arg(getName(), getVersion()));\n\n    GenerationTuple controlTuple;\n    controlTuple.component = component;\n    controlTuple.design = design;\n    controlTuple.designConfiguration = designConfiguration;\n\n    QSharedPointer<QList<QSharedPointer<View> > > views = GenerationControl::findPossibleViews(controlTuple);\n    QStringList viewNames;\n    for (auto view : *views)\n    {\n        viewNames.append(view->name());\n    }\n\n    auto configManager(new RenodeConfigurationManager(utility));\n    QJsonObject configurationObject = configManager->getConfigurationObject(component);\n    auto templateConfigurationManager(new PeripheralTemplateConfigurer(&settingsModel_));\n\n    QString configurationFolderPath = configurationObject.value(RenodeConstants::FOLDERPATH).toString(\"\");\n    QString configurationView = configurationObject.value(RenodeConstants::VIEW).toString(\"\");\n    QString configurationFileSet = configurationObject.value(RenodeConstants::FILESET).toString(\"\");\n    bool saveToFileSetFlag = configurationObject.value(RenodeConstants::SAVETOFILESET).toBool(true);\n\n    auto fileEditor(new RenodeFileEditor(configurationObject));\n    auto cpuEditor(new RenodeCpuEditor(utility, configurationObject, templateConfigurationManager));\n\n    connect(cpuEditor, SIGNAL(cpuChanged(QString const&)), fileEditor, SLOT(changeFileNames(QString const&)), Qt::UniqueConnection);\n\n    CPUSelectionDialog selectionDialog(component, utility->getLibraryInterface(), viewNames, component->getFileSetNames(),\n        cpuEditor, \"Renode platform\", fileEditor, utility->getParentWidget(), 1000, configurationFolderPath,\n        saveToFileSetFlag, configurationFileSet, configurationView);\n\n    if (selectionDialog.exec() == QDialog::Accepted)\n    {\n        QVector<QSharedPointer<CpuRoutesContainer> > cpuRoutes = selectionDialog.getSelectedCPUs();\n        if (!cpuRoutes.isEmpty())\n        {\n            QSharedPointer<RenodeCpuRoutesContainer> renodeCpu = cpuRoutes.first().dynamicCast<RenodeCpuRoutesContainer>();\n            if (renodeCpu)\n            {\n                QString selectedView = selectionDialog.getView();\n                bool saveToFileSet = selectionDialog.saveToFileSet();\n                QString selectedFileSet = selectionDialog.getTargetFileSet();\n                QString xmlFilePath = selectionDialog.getTargetFolder();\n                bool writeCpuFlag = fileEditor->writeCpu();\n                bool writeMemoryFlag = fileEditor->writeMemory();\n                bool writePeripheralFlag = fileEditor->writePeripherals();\n\n                QString selectedCpuName = cpuEditor->getSelectedCpuName();\n\n                QString cpuFileName = fileEditor->getCpuFileName();\n                QString memoryFileName = fileEditor->getmemoryFileName();\n                QString peripheralFileName = fileEditor->getPeripheralFileName();\n\n                RenodeGenerator generator(utility->getLibraryInterface());\n                generator.generate(xmlFilePath, renodeCpu, writeCpuFlag, cpuFileName, writeMemoryFlag,\n                    memoryFileName, writePeripheralFlag, peripheralFileName);\n\n                QString cpuFileEditorText = fileEditor->getCpuEditorText();\n                QString memoryFileEditorText = fileEditor->getMemoryEditorText();\n                QString peripheralFileEditorText = fileEditor->getPeripheralEditorText();\n\n                configManager->createConfigureFile(renodeCpu, selectedView, saveToFileSet, selectedFileSet, xmlFilePath,\n                    writeCpuFlag, cpuFileEditorText, writeMemoryFlag, memoryFileEditorText, writePeripheralFlag,\n                    peripheralFileEditorText, selectedCpuName, component);\n\n                if (selectionDialog.saveToFileSet())\n                {\n                    QString fileSetName = selectionDialog.getTargetFileSet();\n                    if (!fileSetName.isEmpty())\n                    {\n                        QStringList generatedFiles = generator.getGeneratedFiles();\n                        saveToFileset(utility, generatedFiles, component, fileSetName);\n                    }\n                }\n\n                utility->printInfo(tr(\"Generation complete.\"));\n            }\n        }\n        else\n        {\n            utility->printError(tr(\"Could not find CPU routes. Aborting generation.\"));\n        }\n    }\n    else\n    {\n        utility->printInfo(tr(\"Generation aborted.\"));\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: RenodeGeneratorPlugin::saveToFileset()\n//-----------------------------------------------------------------------------\nvoid RenodeGeneratorPlugin::saveToFileset(IPluginUtility* utility, QStringList const& renodeFiles,\n    QSharedPointer<Component> component, QString const& fileSetName)\n{\n    if (renodeFiles.isEmpty())\n    {\n        return;\n    }\n\n    QString xmlFilePath = utility->getLibraryInterface()->getDirectoryPath(component->getVlnv());\n    QSharedPointer<FileSet> targetFileset = component->getFileSet(fileSetName);\n    if (!targetFileset)\n    {\n        targetFileset = QSharedPointer<FileSet>(new FileSet(fileSetName));\n        component->getFileSets()->append(targetFileset);\n    }\n\n    for (auto const& fileName : renodeFiles)\n    {\n        QString relativeFilePath = General::getRelativePath(xmlFilePath, fileName);\n\n        QSharedPointer<File> file;\n        for (QSharedPointer<File> filesetFile : *targetFileset->getFiles())\n        {\n            if (filesetFile->name().compare(relativeFilePath) == 0)\n            {\n                file = filesetFile;\n            }\n        }\n\n        if (!file)\n        {\n            file = QSharedPointer<File>(new File(relativeFilePath));\n\n            QString fileType = RenodeConstants::RENODEFILETYPE;\n            QString fileExtension = relativeFilePath.split(\".\").last();\n            if (fileExtension == RenodeConstants::PYTHONFILETYPE)\n            {\n                fileType = RenodeConstants::PYTHONFILETYPE;\n            }\n\n            file->getFileTypes()->append(FileType(fileType));\n\n            targetFileset->addFile(file);\n            utility->printInfo(tr(\"Added file %1 to top component file set %2.\").arg(fileName, fileSetName));\n        }\n\n        file->setDescription(tr(\"Generated on %1 by Kactus2 %2 plugin version %3.\").arg(\n            QDateTime::currentDateTime().toString(\"dd.MM.yyyy hh:mm:ss\"), getName(), getVersion()));\n    }\n\n\n    utility->getLibraryInterface()->writeModelToFile(component);\n}\n\n//-----------------------------------------------------------------------------\n// Function: RenodeGeneratorPlugin::runGenerator()\n//-----------------------------------------------------------------------------\nvoid RenodeGeneratorPlugin::runGenerator(IPluginUtility* utility, QSharedPointer<Component> component,\n    QSharedPointer<Design> design, QSharedPointer<DesignConfiguration> designConfiguration,\n    QString const& viewName, QString const& outputDirectory)\n{\n    utility->printInfo(tr(\"Running %1 %2.\").arg(getName(), getVersion()));\n    utility->printInfo(tr(\"Running generation for %1 and view '%2'.\").arg(component->getVlnv().toString(), viewName));\n\n    QDir targetDirectory;\n    if (!targetDirectory.mkpath(outputDirectory))\n    {\n        utility->printError(tr(\"Could not create target directory: %1\").arg(outputDirectory));\n        return;\n    }\n\n    utility->printInfo(tr(\"Target directory: %1\").arg(outputDirectory));\n\n\n    MessagePasser messages;\n\n    GenerationTuple input;\n    input.component = component;\n    input.design = design;\n    input.designConfiguration = designConfiguration;\n    input.messages = &messages;\n\n    LibraryInterface* utilityLibrary = utility->getLibraryInterface();\n\n    QVector<QSharedPointer<RenodeCpuRoutesContainer> > renodeCPUs;\n    for (auto defaultCPU : ConnectivityGraphUtilities::getDefaultCPUs(utilityLibrary, component, viewName))\n    {\n        QSharedPointer<RenodeCpuRoutesContainer> newCPU(new RenodeCpuRoutesContainer(*defaultCPU.data()));\n        renodeCPUs.append(newCPU);\n    }\n\n    if (renodeCPUs.isEmpty())\n    {\n        utility->printInfo(tr(\"Generation Failed. No CPUs found.\"));\n        return;\n    }\n\n    QString cpuName = renodeCPUs.first()->getCpu()->name();\n    QString cpuFileName = cpuName + \"_\" + RenodeConstants::RENODECPUFILENAME;\n    QString memoryFileName = cpuName + \"_\" + RenodeConstants::RENODEMEMORYFILENAME;\n    QString peripheralFileName = cpuName + \"_\" + RenodeConstants::RENODEPERIPHERALFILENAME;\n\n    RenodeGenerator generator(utilityLibrary);\n    generator.generate(outputDirectory, renodeCPUs.first(), true, cpuFileName, true, memoryFileName, true, peripheralFileName);\n\n    utility->printInfo(tr(\"Generation complete.\"));\n}\n\n//-----------------------------------------------------------------------------\n// Function: RenodeGeneratorPlugin::getProgramRequirements()\n//-----------------------------------------------------------------------------\nQList<IPlugin::ExternalProgramRequirement> RenodeGeneratorPlugin::getProgramRequirements()\n{\n    return QList<IPlugin::ExternalProgramRequirement>();\n}\n\n//-----------------------------------------------------------------------------\n// Function: RenodeGeneratorPlugin::getOutputFormat()\n//-----------------------------------------------------------------------------\nQString RenodeGeneratorPlugin::getOutputFormat() const\n{\n    return QStringLiteral(\"repl\");\n}\n"
  },
  {
    "path": "Plugins/RenodeGenerator/RenodeGeneratorPlugin.h",
    "content": "//-----------------------------------------------------------------------------\n// File: RenodeGeneratorPlugin.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 10.02.2023\n//\n// Description:\n// Renode generator plugin.\n//-----------------------------------------------------------------------------\n\n#ifndef RENODEGENERATORPLUGIN_H\n#define RENODEGENERATORPLUGIN_H\n\n#include \"renodegeneratorplugin_global.h\"\n\n#include <KactusAPI/include/IPlugin.h>\n#include <KactusAPI/include/IGeneratorPlugin.h>\n#include <KactusAPI/include/IPluginUtility.h>\n#include <KactusAPI/include/CLIGenerator.h>\n\n#include <Plugins/RenodeGenerator/RenodeSettingsModel.h>\n\nclass LibraryInterface;\nclass FileSet;\nclass File;\n\n#include <QFile>\n#include <QJsonDocument>\n#include <QJsonObject>\n\n//-----------------------------------------------------------------------------\n//! Renode generator plugin.\n//-----------------------------------------------------------------------------\nclass RENODEGENERATORPLUGIN_EXPORT RenodeGeneratorPlugin : public QObject, public IGeneratorPlugin, public CLIGenerator\n{\n    Q_OBJECT\n    Q_PLUGIN_METADATA(IID \"kactus2.plugins.renodeGeneratorPlugin\" FILE \"renodeGeneratorPlugin.json\")\n\n    Q_INTERFACES(IPlugin)\n    Q_INTERFACES(IGeneratorPlugin)\n\npublic:\n    \n    /*!\n     *  The constructor.\n     */\n    RenodeGeneratorPlugin();\n    \n    /*!\n     * The destructor.\n     */\n    ~RenodeGeneratorPlugin() final = default;\n\n    /*!\n     *  Returns the name of the plugin.\n     */\n    virtual QString getName() const;\n\n    /*!\n     *  Returns the version of the plugin.\n     */\n    virtual QString getVersion() const;\n\n    /*!\n     *  Returns the description of the plugin.\n     */\n    virtual QString getDescription() const;\n\n    /*!\n     *  Returns the vendor of the plugin.\n     */\n    virtual QString getVendor() const;\n\n    /*!\n     *  Returns the licence of the plugin.\n     */\n    virtual QString getLicense() const;\n\n    /*!\n     *  Returns the holder of the licence of the plugin.\n     */\n    virtual QString getLicenseHolder() const;\n\n    /*!\n     *  Returns the settings widget.\n     */\n    virtual QWidget* getSettingsWidget();\n\n    /*!\n     *  This is used to access the settings modified by function getSettingsWidget().\n     */\n    virtual PluginSettingsModel* getSettingsModel();\n\n    /*!\n     *  Returns the icon for the generator.\n     */\n    virtual QIcon getIcon() const;\n    \n    /*!\n     *  Checks whether the generator may run for the given component or design. \n     *\n     *    @param [in] component\t        The component for which to check support. If design is not null, component\n\t *                                      will refer to design or designConfiguration.\n     *    @param [in] design\t            The design, if the generator is ran for a design.\n     *    @param [in] designConfiguration The design configuration for design, if it is not null.\n     *\n     *    @return True, if the generator may run the given component. Otherwise false.\n     */\n    virtual bool checkGeneratorSupport(QSharedPointer<Component const> component,\n        QSharedPointer<Design const> design,\n        QSharedPointer<DesignConfiguration const> designConfiguration) const;\n\n    /*!\n     *  Runs the generation, creating new files and/or modifying the IP-XACT metadata. The function has\n     *  also access to the parent window widget, so that it can show dialogs for the user to aid the generation.\n     *\n     *    @param [in] utility\t\t\t    The plugin utility interface.\n     *    @param [in] component\t        The component for which to check support. If design is not null, component\n     *                                      will refer to design or designConfiguration.\n     *    @param [in] design\t            The design, if the generator is ran for a design.\n     *    @param [in] designConfiguration The design configuration for design, if it is not null.\n     */\n    virtual void runGenerator(IPluginUtility* utility,\n        QSharedPointer<Component> component,\n        QSharedPointer<Design> design,\n        QSharedPointer<DesignConfiguration> designConfiguration);\n\n    /*!\n     * Runs the generation.\n     *\n     *    @param [in] utility              Utilities for enabling plugin execution.\n     *    @param [in] component            The component to run the generation for.\n     *    @param [in] design               The design to run the generation for.\n     *    @param [in] designConfiguration  The design configuration to run the generation for.\n     *    @param [in] viewName             The component view name to run the generation for.\n     *    @param [in] outputDirectory      The output directory for the generation results.\n     */\n    virtual void runGenerator(IPluginUtility* utility,\n        QSharedPointer<Component> component,\n        QSharedPointer<Design> design,\n        QSharedPointer<DesignConfiguration> designConfiguration,\n        QString const& viewName,\n        QString const& outputDirectory) override final;\n\n    /*!\n     *  Returns the external program requirements of the plugin.\n     * */\n    virtual QList<IPlugin::ExternalProgramRequirement> getProgramRequirements();\n    \n    /*!\n     *  Gets the output format generated by the plugin.\n     *\n     *    @return The output file format generated by the plugin.\n     */\n    virtual QString getOutputFormat() const;\n\n\nprivate:\n\n    /*!\n     *  Saves the generated file to the selected file set of the top component.\n     *\n     *    @param [in] utility         The plugin utility interface.\n     *    @param [in] svdFiles        The generated file paths.\n     *    @param [in] component       The top level component.\n     *    @param [in] fileSetName     Name of the target file set.\n     */\n    void saveToFileset(IPluginUtility* utility,\n        QStringList const& renodeFiles,\n        QSharedPointer<Component> component,\n        QString const& fileSetName);\n\n    //-----------------------------------------------------------------------------\n    // Data.\n    //-----------------------------------------------------------------------------\n\n    //! The settings model for Renode generator.\n    RenodeSettingsModel settingsModel_{ };\n};\n\n#endif // RENODEGENERATORPLUGIN_H\n"
  },
  {
    "path": "Plugins/RenodeGenerator/RenodeGeneratorPlugin.pri",
    "content": "# ----------------------------------------------------\n# This file is generated by the Qt Visual Studio Tools.\n# ------------------------------------------------------\n\n# This is a reminder that you are using a generated .pro file.\n# Remove it when you are finished editing this file.\nmessage(\"You are running qmake on a generated .pro file. This may not work!\")\n\n\nHEADERS += ./RenodeSettingsModel.h \\\n    ./RenodeConfigurationManager.h \\\n    ./RenodeGenerator.h \\\n    ./RenodeSettingsWidget.h \\\n    ./RenodeGeneratorPlugin.h \\\n    ../PluginSystem/GeneratorPlugin/GenerationControl.h \\\n    ../PluginSystem/GeneratorPlugin/OutputControl.h \\\n    ../PluginSystem/GeneratorPlugin/ViewSelection.h \\\n    ../PluginSystem/GeneratorPlugin/MessagePasser.h \\\n    ../common/HDLParser/MetaComponent.h \\\n    ../common/HDLParser/MetaDesign.h \\\n    ../common/HDLParser/MetaInstance.h \\\n    ../../editors/MemoryDesigner/ConnectivityComponent.h \\\n    ../../editors/MemoryDesigner/ConnectivityConnection.h \\\n    ../../editors/MemoryDesigner/ConnectivityGraph.h \\\n    ../../editors/MemoryDesigner/ConnectivityGraphFactory.h \\\n    ../../editors/MemoryDesigner/ConnectivityInterface.h \\\n    ../../editors/MemoryDesigner/MasterSlavePathSearch.h \\\n    ../../editors/MemoryDesigner/MemoryConnectionAddressCalculator.h \\\n    ../../editors/MemoryDesigner/MemoryDesignerConstants.h \\\n    ../../editors/MemoryDesigner/MemoryItem.h \\\n    ../../IPXACTmodels/utilities/ComponentSearch.h \\\n    ./CPUDialog/RenodeColumns.h \\\n    ./CPUDialog/RenodeConstants.h \\\n    ./CPUDialog/RenodeCpuRoutesContainer.h \\\n    ./CPUDialog/RenodeStructs.h \\\n    ./CPUDialog/RenodeUtilities.h \\\n    ./CPUDialog/RenodePeripheralsModel.h \\\n    ./CPUDialog/RenodePeripheralsEditor.h \\\n    ./CPUDialog/RenodePeripheralsDelegate.h \\\n    ./CPUDialog/RenodeCpuEditor.h \\\n    ./CPUDialog/RenodeMemoriesEditor.h \\\n    ./CPUDialog/RenodeMemoriesModel.h \\\n    ./CPUDialog/RenodeFileSelectionGroup.h \\\n    ./CPUDialog/RenodeFileEditor.h \\\n    ../common/CPUDialog/CPUEditor.h \\\n    ../common/CPUDialog/CPUSelectionDialog.h \\\n    ./CPUDialog/TemplateEditor/PeripheralTemplatesDialog.h \\\n    ./CPUDialog/TemplateEditor/PeripheralTemplateEditor.h \\\n    ./CPUDialog/TemplateEditor/PeripheralTemplateModel.h \\\n    ./CPUDialog/TemplateEditor/PeripheralTemplateDelegate.h \\\n    ../common/ConfigurationManager.h \\\n    ../common/ConnectivityGraphUtilities.h \\\n    ../common/CpuRoutesContainer.h \\\n    ../common/PluginConfigurationManager.h \\\n    ../common/SingleCpuRoutesContainer.h \\\n    ../../common/views/EditableTableView/editabletableview.h \\\n    ./CPUDialog/TemplateEditor/PeripheralTemplateConfigurer.h\nSOURCES += ./RenodeConfigurationManager.cpp \\\n    ./RenodeGenerator.cpp \\\n    ./RenodeGeneratorPlugin.cpp \\\n    ./RenodeSettingsModel.cpp \\\n    ./RenodeSettingsWidget.cpp \\\n    ../PluginSystem/GeneratorPlugin/GenerationControl.cpp \\\n    ../PluginSystem/GeneratorPlugin/MessagePasser.cpp \\\n    ../PluginSystem/GeneratorPlugin/OutputControl.cpp \\\n    ../PluginSystem/GeneratorPlugin/ViewSelection.cpp \\\n    ../common/HDLParser/MetaComponent.cpp \\\n    ../common/HDLParser/MetaDesign.cpp \\\n    ../common/HDLParser/MetaInstance.cpp \\\n    ../../editors/MemoryDesigner/ConnectivityComponent.cpp \\\n    ../../editors/MemoryDesigner/ConnectivityConnection.cpp \\\n    ../../editors/MemoryDesigner/ConnectivityGraph.cpp \\\n    ../../editors/MemoryDesigner/ConnectivityGraphFactory.cpp \\\n    ../../editors/MemoryDesigner/ConnectivityInterface.cpp \\\n    ../../editors/MemoryDesigner/MasterSlavePathSearch.cpp \\\n    ../../editors/MemoryDesigner/MemoryConnectionAddressCalculator.cpp \\\n    ../../editors/MemoryDesigner/MemoryDesignerConstants.cpp \\\n    ../../editors/MemoryDesigner/MemoryItem.cpp \\\n    ../../IPXACTmodels/utilities/ComponentSearch.cpp \\\n    ../common/CPUDialog/CPUEditor.cpp \\\n    ../common/CPUDialog/CPUSelectionDialog.cpp \\\n    ./CPUDialog/RenodeCpuEditor.cpp \\\n    ./CPUDialog/RenodeCpuRoutesContainer.cpp \\\n    ./CPUDialog/RenodeFileEditor.cpp \\\n    ./CPUDialog/RenodeFileSelectionGroup.cpp \\\n    ./CPUDialog/RenodeMemoriesEditor.cpp \\\n    ./CPUDialog/RenodeMemoriesModel.cpp \\\n    ./CPUDialog/RenodePeripheralsDelegate.cpp \\\n    ./CPUDialog/RenodePeripheralsEditor.cpp \\\n    ./CPUDialog/RenodePeripheralsModel.cpp \\\n    ./CPUDialog/RenodeUtilities.cpp \\\n    ./CPUDialog/TemplateEditor/PeripheralTemplateDelegate.cpp \\\n    ./CPUDialog/TemplateEditor/PeripheralTemplateEditor.cpp \\\n    ./CPUDialog/TemplateEditor/PeripheralTemplateModel.cpp \\\n    ./CPUDialog/TemplateEditor/PeripheralTemplatesDialog.cpp \\\n    ../../common/views/EditableTableView/editabletableview.cpp \\\n    ../common/ConfigurationManager.cpp \\\n    ../common/ConnectivityGraphUtilities.cpp \\\n    ../common/CpuRoutesContainer.cpp \\\n    ../common/PluginConfigurationManager.cpp \\\n    ../common/SingleCpuRoutesContainer.cpp \\\n    ./CPUDialog/TemplateEditor/PeripheralTemplateConfigurer.cpp\nRESOURCES += RenodeGenerator.qrc\n"
  },
  {
    "path": "Plugins/RenodeGenerator/RenodeGeneratorPlugin.pro",
    "content": "# ----------------------------------------------------\n# This file is generated by the Qt Visual Studio Add-in.\n# ------------------------------------------------------\n\nTEMPLATE = lib\n\nQT += core xml widgets gui\nCONFIG += plugin c++17\nDEFINES += QT_DLL QT_XML_LIB RENODEGENERATORPLUGIN_LIB QT_WIDGETS_LIB\n\nINCLUDEPATH += ./GeneratedFiles \\\n    ./../.. \\\n    .\n\nCONFIG(debug, debug|release) {\n    # debug mode\n    LIBS += \\\n        -L../../executable -lIPXACTmodelsd \\\n        -L../../executable -lKactusAPId\n\n    MOC_DIR += ./GeneratedFiles/Debug\n    OBJECTS_DIR += Debug\n    TARGET = RenodeGeneratorPlugind\n\n} else {\n    # release mode \n    LIBS += \\\n        -L../../executable -lIPXACTmodels \\\n        -L../../executable -lKactusAPI\n    \n    MOC_DIR += ./GeneratedFiles/Release\n    OBJECTS_DIR += Release\n    TARGET = RenodeGeneratorPlugin\n}\nDESTDIR = ../../executable/Plugins\n\nDEPENDPATH += .\nUI_DIR += ./GeneratedFiles\nRCC_DIR += ./GeneratedFiles\n\ninclude(RenodeGeneratorPlugin.pri)\n\ntarget.path = $$plugin_path\nINSTALLS += target\n\n"
  },
  {
    "path": "Plugins/RenodeGenerator/RenodeGeneratorPlugin.vcxproj",
    "content": "﻿<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<Project DefaultTargets=\"Build\" ToolsVersion=\"15.0\" xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">\n  <ItemGroup Label=\"ProjectConfigurations\">\n    <ProjectConfiguration Include=\"Debug|x64\">\n      <Configuration>Debug</Configuration>\n      <Platform>x64</Platform>\n    </ProjectConfiguration>\n    <ProjectConfiguration Include=\"Release|x64\">\n      <Configuration>Release</Configuration>\n      <Platform>x64</Platform>\n    </ProjectConfiguration>\n  </ItemGroup>\n  <PropertyGroup Label=\"Globals\">\n    <ProjectGuid>{57BB9FA6-BA0C-4E70-83B3-DD973FED0FB4}</ProjectGuid>\n    <Keyword>QtVS_v304</Keyword>\n    <WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>\n    <QtMsBuild Condition=\"'$(QtMsBuild)'=='' or !Exists('$(QtMsBuild)\\qt.targets')\">$(MSBuildProjectDirectory)\\QtMsBuild</QtMsBuild>\n  </PropertyGroup>\n  <Import Project=\"$(VCTargetsPath)\\Microsoft.Cpp.Default.props\" />\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\" Label=\"Configuration\">\n    <ConfigurationType>DynamicLibrary</ConfigurationType>\n    <PlatformToolset>v143</PlatformToolset>\n  </PropertyGroup>\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\" Label=\"Configuration\">\n    <ConfigurationType>DynamicLibrary</ConfigurationType>\n    <PlatformToolset>v143</PlatformToolset>\n  </PropertyGroup>\n  <Import Project=\"$(VCTargetsPath)\\Microsoft.Cpp.props\" />\n  <Target Name=\"QtMsBuildNotFound\" BeforeTargets=\"CustomBuild;ClCompile\" Condition=\"!Exists('$(QtMsBuild)\\qt.targets') or !Exists('$(QtMsBuild)\\qt.props')\">\n    <Message Importance=\"High\" Text=\"QtMsBuild: could not locate qt.targets, qt.props; project may not build correctly.\" />\n  </Target>\n  <ImportGroup Label=\"ExtensionSettings\">\n  </ImportGroup>\n  <ImportGroup Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\" Label=\"PropertySheets\">\n    <Import Project=\"$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props\" Condition=\"exists('$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props')\" Label=\"LocalAppDataPlatform\" />\n  </ImportGroup>\n  <ImportGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\" Label=\"PropertySheets\">\n    <Import Project=\"$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props\" Condition=\"exists('$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props')\" Label=\"LocalAppDataPlatform\" />\n  </ImportGroup>\n  <PropertyGroup Label=\"UserMacros\" />\n  <ImportGroup Condition=\"Exists('$(QtMsBuild)\\qt_defaults.props')\">\n    <Import Project=\"$(QtMsBuild)\\qt_defaults.props\" />\n  </ImportGroup>\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\n    <OutDir>$(SolutionDir)executable\\Plugins\\</OutDir>\n  </PropertyGroup>\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\n    <OutDir>$(SolutionDir)executable\\Plugins\\</OutDir>\n    <TargetName>$(ProjectName)</TargetName>\n  </PropertyGroup>\n  <PropertyGroup Label=\"QtSettings\" Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\n    <QtInstall>6.2.4</QtInstall>\n    <QtModules>core;gui;widgets;xml</QtModules>\n  </PropertyGroup>\n  <PropertyGroup Label=\"QtSettings\" Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\n    <QtInstall>6.2.4</QtInstall>\n    <QtModules>core;gui;widgets;xml</QtModules>\n  </PropertyGroup>\n  <ImportGroup Condition=\"Exists('$(QtMsBuild)\\qt.props')\">\n    <Import Project=\"$(QtMsBuild)\\qt.props\" />\n  </ImportGroup>\n  <PropertyGroup>\n    <_ProjectFileVersion>10.0.40219.1</_ProjectFileVersion>\n  </PropertyGroup>\n  <ItemDefinitionGroup Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\n    <ClCompile>\n      <PreprocessorDefinitions>UNICODE;WIN32;WIN64;RENODEGENERATORPLUGIN_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>\n      <AdditionalIncludeDirectories>.\\GeneratedFiles\\$(ConfigurationName);.\\GeneratedFiles;..\\..\\;.;$(SolutionDir)KactusAPI\\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\n      <Optimization>Disabled</Optimization>\n      <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>\n      <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>\n      <TreatWChar_tAsBuiltInType>true</TreatWChar_tAsBuiltInType>\n      <MultiProcessorCompilation>true</MultiProcessorCompilation>\n      <LanguageStandard>stdcpp17</LanguageStandard>\n      <AdditionalOptions>/Zc:__cplusplus %(AdditionalOptions)</AdditionalOptions>\n    </ClCompile>\n    <Link>\n      <SubSystem>Windows</SubSystem>\n      <OutputFile>$(OutDir)\\$(ProjectName).dll</OutputFile>\n      <AdditionalLibraryDirectories>..\\..\\executable;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>\n      <GenerateDebugInformation>true</GenerateDebugInformation>\n      <AdditionalDependencies>IPXACTmodelsd.lib;KactusAPId.lib;%(AdditionalDependencies)</AdditionalDependencies>\n    </Link>\n    <QtMoc>\n      <ExecutionDescription>Moc'ing %(Identity)...</ExecutionDescription>\n      <DynamicSource>output</DynamicSource>\n      <QtMocDir>.\\GeneratedFiles\\$(ConfigurationName)</QtMocDir>\n      <QtMocFileName>moc_%(Filename).cpp</QtMocFileName>\n    </QtMoc>\n    <QtRcc>\n      <InitFuncName>%(Filename)</InitFuncName>\n      <Compression>default</Compression>\n      <NoCompression>true</NoCompression>\n      <ExecutionDescription>Rcc'ing %(Identity)...</ExecutionDescription>\n      <QtRccDir>.\\GeneratedFiles</QtRccDir>\n      <QtRccFileName>qrc_%(Filename).cpp</QtRccFileName>\n    </QtRcc>\n  </ItemDefinitionGroup>\n  <ItemDefinitionGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\n    <ClCompile>\n      <PreprocessorDefinitions>UNICODE;WIN32;WIN64;QT_NO_DEBUG;NDEBUG;RENODEGENERATORPLUGIN_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>\n      <AdditionalIncludeDirectories>.\\GeneratedFiles\\$(ConfigurationName);.\\GeneratedFiles;..\\..;.;$(SolutionDir)KactusAPI\\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\n      <DebugInformationFormat>\n      </DebugInformationFormat>\n      <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>\n      <TreatWChar_tAsBuiltInType>true</TreatWChar_tAsBuiltInType>\n      <MultiProcessorCompilation>true</MultiProcessorCompilation>\n      <AdditionalOptions>/Zc:__cplusplus %(AdditionalOptions)</AdditionalOptions>\n      <LanguageStandard>stdcpp17</LanguageStandard>\n    </ClCompile>\n    <Link>\n      <SubSystem>Windows</SubSystem>\n      <OutputFile>$(OutDir)$(ProjectName).dll</OutputFile>\n      <AdditionalLibraryDirectories>..\\..\\executable;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>\n      <GenerateDebugInformation>false</GenerateDebugInformation>\n      <AdditionalDependencies>IPXACTmodels.lib;KactusAPI.lib;%(AdditionalDependencies)</AdditionalDependencies>\n    </Link>\n    <QtMoc>\n      <ExecutionDescription>Moc'ing %(Identity)...</ExecutionDescription>\n      <DynamicSource>output</DynamicSource>\n      <QtMocDir>.\\GeneratedFiles\\$(ConfigurationName)</QtMocDir>\n      <QtMocFileName>moc_%(Filename).cpp</QtMocFileName>\n    </QtMoc>\n    <QtRcc>\n      <InitFuncName>%(Filename)</InitFuncName>\n      <Compression>default</Compression>\n      <NoCompression>true</NoCompression>\n      <ExecutionDescription>Rcc'ing %(Identity)...</ExecutionDescription>\n      <QtRccDir>.\\GeneratedFiles</QtRccDir>\n      <QtRccFileName>qrc_%(Filename).cpp</QtRccFileName>\n    </QtRcc>\n  </ItemDefinitionGroup>\n  <ItemGroup>\n    <ClCompile Include=\"..\\..\\common\\views\\EditableTableView\\editabletableview.cpp\" />\n    <ClCompile Include=\"..\\..\\editors\\MemoryDesigner\\ConnectivityComponent.cpp\" />\n    <ClCompile Include=\"..\\..\\editors\\MemoryDesigner\\ConnectivityConnection.cpp\" />\n    <ClCompile Include=\"..\\..\\editors\\MemoryDesigner\\ConnectivityGraph.cpp\" />\n    <ClCompile Include=\"..\\..\\editors\\MemoryDesigner\\ConnectivityGraphFactory.cpp\" />\n    <ClCompile Include=\"..\\..\\editors\\MemoryDesigner\\ConnectivityInterface.cpp\" />\n    <ClCompile Include=\"..\\..\\editors\\MemoryDesigner\\MasterSlavePathSearch.cpp\" />\n    <ClCompile Include=\"..\\..\\editors\\MemoryDesigner\\MemoryConnectionAddressCalculator.cpp\" />\n    <ClCompile Include=\"..\\..\\editors\\MemoryDesigner\\MemoryDesignerConstants.cpp\" />\n    <ClCompile Include=\"..\\..\\editors\\MemoryDesigner\\MemoryItem.cpp\" />\n    <ClCompile Include=\"..\\..\\IPXACTmodels\\utilities\\ComponentSearch.cpp\" />\n    <ClCompile Include=\"..\\common\\ConfigurationManager.cpp\" />\n    <ClCompile Include=\"..\\common\\ConnectivityGraphUtilities.cpp\" />\n    <ClCompile Include=\"..\\common\\CPUDialog\\CPUEditor.cpp\" />\n    <ClCompile Include=\"..\\common\\CPUDialog\\CPUSelectionDialog.cpp\" />\n    <ClCompile Include=\"..\\common\\CpuRoutesContainer.cpp\" />\n    <ClCompile Include=\"..\\common\\HDLParser\\MetaComponent.cpp\" />\n    <ClCompile Include=\"..\\common\\HDLParser\\MetaDesign.cpp\" />\n    <ClCompile Include=\"..\\common\\HDLParser\\MetaInstance.cpp\" />\n    <ClCompile Include=\"..\\common\\PluginConfigurationManager.cpp\" />\n    <ClCompile Include=\"..\\common\\SingleCpuRoutesContainer.cpp\" />\n    <ClCompile Include=\"..\\PluginSystem\\GeneratorPlugin\\GenerationControl.cpp\" />\n    <ClCompile Include=\"..\\PluginSystem\\GeneratorPlugin\\MessagePasser.cpp\" />\n    <ClCompile Include=\"..\\PluginSystem\\GeneratorPlugin\\OutputControl.cpp\" />\n    <ClCompile Include=\"..\\PluginSystem\\GeneratorPlugin\\ViewSelection.cpp\" />\n    <ClCompile Include=\"CPUDialog\\RenodeCpuEditor.cpp\" />\n    <ClCompile Include=\"CPUDialog\\RenodeCpuRoutesContainer.cpp\" />\n    <ClCompile Include=\"CPUDialog\\RenodeFileEditor.cpp\" />\n    <ClCompile Include=\"CPUDialog\\RenodeFileSelectionGroup.cpp\" />\n    <ClCompile Include=\"CPUDialog\\RenodeMemoriesEditor.cpp\" />\n    <ClCompile Include=\"CPUDialog\\RenodeMemoriesModel.cpp\" />\n    <ClCompile Include=\"CPUDialog\\RenodePeripheralsDelegate.cpp\" />\n    <ClCompile Include=\"CPUDialog\\RenodePeripheralsEditor.cpp\" />\n    <ClCompile Include=\"CPUDialog\\RenodePeripheralsModel.cpp\" />\n    <ClCompile Include=\"CPUDialog\\RenodeUtilities.cpp\" />\n    <ClCompile Include=\"CPUDialog\\TemplateEditor\\PeripheralTemplateConfigurer.cpp\" />\n    <ClCompile Include=\"CPUDialog\\TemplateEditor\\PeripheralTemplateDelegate.cpp\" />\n    <ClCompile Include=\"CPUDialog\\TemplateEditor\\PeripheralTemplateEditor.cpp\" />\n    <ClCompile Include=\"CPUDialog\\TemplateEditor\\PeripheralTemplateModel.cpp\" />\n    <ClCompile Include=\"CPUDialog\\TemplateEditor\\PeripheralTemplatesDialog.cpp\" />\n    <ClCompile Include=\"RenodeConfigurationManager.cpp\" />\n    <ClCompile Include=\"RenodeGenerator.cpp\" />\n    <ClCompile Include=\"RenodeGeneratorPlugin.cpp\" />\n    <ClCompile Include=\"RenodeSettingsModel.cpp\" />\n    <ClCompile Include=\"RenodeSettingsWidget.cpp\" />\n  </ItemGroup>\n  <ItemGroup>\n    <Image Include=\"RenodeGenerator.png\" />\n  </ItemGroup>\n  <ItemGroup>\n    <QtRcc Include=\"RenodeGenerator.qrc\" />\n  </ItemGroup>\n  <ItemGroup>\n    <ClInclude Include=\"CPUDialog\\TemplateEditor\\PeripheralTemplateConfigurer.h\" />\n    <ClInclude Include=\"RenodeSettingsModel.h\" />\n    <QtMoc Include=\"RenodeSettingsWidget.h\" />\n    <QtMoc Include=\"..\\..\\common\\views\\EditableTableView\\editabletableview.h\" />\n    <ClInclude Include=\"..\\..\\editors\\MemoryDesigner\\ConnectivityComponent.h\" />\n    <ClInclude Include=\"..\\..\\editors\\MemoryDesigner\\ConnectivityConnection.h\" />\n    <ClInclude Include=\"..\\..\\editors\\MemoryDesigner\\ConnectivityGraph.h\" />\n    <ClInclude Include=\"..\\..\\editors\\MemoryDesigner\\ConnectivityGraphFactory.h\" />\n    <ClInclude Include=\"..\\..\\editors\\MemoryDesigner\\ConnectivityInterface.h\" />\n    <ClInclude Include=\"..\\..\\editors\\MemoryDesigner\\MasterSlavePathSearch.h\" />\n    <ClInclude Include=\"..\\..\\editors\\MemoryDesigner\\MemoryConnectionAddressCalculator.h\" />\n    <ClInclude Include=\"..\\..\\editors\\MemoryDesigner\\MemoryDesignerConstants.h\" />\n    <ClInclude Include=\"..\\..\\editors\\MemoryDesigner\\MemoryItem.h\" />\n    <ClInclude Include=\"..\\..\\IPXACTmodels\\utilities\\ComponentSearch.h\" />\n    <ClInclude Include=\"..\\common\\ConfigurationManager.h\" />\n    <ClInclude Include=\"..\\common\\ConnectivityGraphUtilities.h\" />\n    <QtMoc Include=\"CPUDialog\\RenodePeripheralsModel.h\" />\n    <ClInclude Include=\"..\\common\\CpuRoutesContainer.h\" />\n    <ClInclude Include=\"..\\common\\PluginConfigurationManager.h\" />\n    <QtMoc Include=\"CPUDialog\\RenodePeripheralsEditor.h\" />\n    <QtMoc Include=\"CPUDialog\\RenodePeripheralsDelegate.h\" />\n    <QtMoc Include=\"CPUDialog\\RenodeCpuEditor.h\" />\n    <QtMoc Include=\"CPUDialog\\RenodeMemoriesEditor.h\" />\n    <QtMoc Include=\"CPUDialog\\RenodeMemoriesModel.h\" />\n    <QtMoc Include=\"CPUDialog\\RenodeFileSelectionGroup.h\" />\n    <ClInclude Include=\"..\\common\\SingleCpuRoutesContainer.h\" />\n    <ClInclude Include=\"CPUDialog\\RenodeColumns.h\" />\n    <ClInclude Include=\"CPUDialog\\RenodeConstants.h\" />\n    <ClInclude Include=\"CPUDialog\\RenodeCpuRoutesContainer.h\" />\n    <QtMoc Include=\"CPUDialog\\RenodeFileEditor.h\" />\n    <ClInclude Include=\"CPUDialog\\RenodeStructs.h\" />\n    <ClInclude Include=\"CPUDialog\\RenodeUtilities.h\" />\n    <QtMoc Include=\"CPUDialog\\TemplateEditor\\PeripheralTemplatesDialog.h\" />\n    <QtMoc Include=\"CPUDialog\\TemplateEditor\\PeripheralTemplateEditor.h\" />\n    <QtMoc Include=\"CPUDialog\\TemplateEditor\\PeripheralTemplateModel.h\" />\n    <QtMoc Include=\"CPUDialog\\TemplateEditor\\PeripheralTemplateDelegate.h\" />\n    <ClInclude Include=\"RenodeConfigurationManager.h\" />\n    <ClInclude Include=\"RenodeGenerator.h\" />\n    <QtMoc Include=\"RenodeGeneratorPlugin.h\" />\n    <QtMoc Include=\"..\\common\\CPUDialog\\CPUEditor.h\" />\n    <QtMoc Include=\"..\\common\\CPUDialog\\CPUSelectionDialog.h\" />\n    <ClInclude Include=\"..\\common\\HDLParser\\MetaComponent.h\" />\n    <ClInclude Include=\"..\\common\\HDLParser\\MetaDesign.h\" />\n    <ClInclude Include=\"..\\common\\HDLParser\\MetaInstance.h\" />\n    <ClInclude Include=\"..\\PluginSystem\\GeneratorPlugin\\GenerationControl.h\" />\n    <QtMoc Include=\"..\\PluginSystem\\GeneratorPlugin\\MessagePasser.h\">\n    </QtMoc>\n    <ClInclude Include=\"..\\PluginSystem\\GeneratorPlugin\\OutputControl.h\" />\n    <ClInclude Include=\"..\\PluginSystem\\GeneratorPlugin\\ViewSelection.h\" />\n  </ItemGroup>\n  <ItemGroup>\n    <Text Include=\"..\\..\\executable\\assets\\peripherals.txt\" />\n  </ItemGroup>\n  <Import Project=\"$(VCTargetsPath)\\Microsoft.Cpp.targets\" />\n  <ImportGroup Condition=\"Exists('$(QtMsBuild)\\qt.targets')\">\n    <Import Project=\"$(QtMsBuild)\\qt.targets\" />\n  </ImportGroup>\n  <ImportGroup Label=\"ExtensionTargets\">\n  </ImportGroup>\n  <ProjectExtensions>\n    <VisualStudio>\n      <UserProperties />\n    </VisualStudio>\n  </ProjectExtensions>\n</Project>"
  },
  {
    "path": "Plugins/RenodeGenerator/RenodeGeneratorPlugin.vcxproj.filters",
    "content": "﻿<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<Project ToolsVersion=\"4.0\" xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">\n  <ItemGroup>\n    <Filter Include=\"Source Files\">\n      <UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>\n      <Extensions>cpp;cxx;c;def</Extensions>\n    </Filter>\n    <Filter Include=\"Header Files\">\n      <UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>\n      <Extensions>h</Extensions>\n    </Filter>\n    <Filter Include=\"Generated Files\">\n      <UniqueIdentifier>{71ED8ED8-ACB9-4CE9-BBE1-E00B30144E11}</UniqueIdentifier>\n      <Extensions>moc;h;cpp</Extensions>\n      <SourceControlFiles>False</SourceControlFiles>\n    </Filter>\n    <Filter Include=\"Generated Files\\Debug\">\n      <UniqueIdentifier>{0dde34ad-54aa-4fc2-bbd2-8d5415f77af4}</UniqueIdentifier>\n      <Extensions>cpp;moc</Extensions>\n      <SourceControlFiles>False</SourceControlFiles>\n    </Filter>\n    <Filter Include=\"Generated Files\\Release\">\n      <UniqueIdentifier>{c8453e3e-ca63-45c5-a10f-423715481c0d}</UniqueIdentifier>\n      <Extensions>cpp;moc</Extensions>\n      <SourceControlFiles>False</SourceControlFiles>\n    </Filter>\n    <Filter Include=\"Resource Files\">\n      <UniqueIdentifier>{D9D6E242-F8AF-46E4-B9FD-80ECBC20BA3E}</UniqueIdentifier>\n      <Extensions>qrc;*</Extensions>\n      <ParseFiles>false</ParseFiles>\n    </Filter>\n    <Filter Include=\"Header Files\\GenerationControl\">\n      <UniqueIdentifier>{7009044a-86f3-4af6-bf37-2718bcc8c9d4}</UniqueIdentifier>\n    </Filter>\n    <Filter Include=\"Source Files\\GenerationControl\">\n      <UniqueIdentifier>{09c2593e-84c8-4829-84ba-ea995a46f97c}</UniqueIdentifier>\n    </Filter>\n    <Filter Include=\"Header Files\\Parsing\">\n      <UniqueIdentifier>{21a3e362-fae7-4c11-b06a-78360a46a713}</UniqueIdentifier>\n    </Filter>\n    <Filter Include=\"Source Files\\Parsing\">\n      <UniqueIdentifier>{d457893a-3fc6-4705-ad26-2411ca02bfb3}</UniqueIdentifier>\n    </Filter>\n    <Filter Include=\"Source Files\\Editors\">\n      <UniqueIdentifier>{8b7c8b51-97ee-4e83-bc23-6cbc7648e9dc}</UniqueIdentifier>\n    </Filter>\n    <Filter Include=\"Header Files\\Editors\">\n      <UniqueIdentifier>{ad685249-6c92-4ba6-a283-2dbb9b4844a8}</UniqueIdentifier>\n    </Filter>\n    <Filter Include=\"Header Files\\IPXACTModels\">\n      <UniqueIdentifier>{5f2340a1-6cb0-46cc-93bf-67124d1c2f7f}</UniqueIdentifier>\n    </Filter>\n    <Filter Include=\"Header Files\\IPXACTModels\\utilities\">\n      <UniqueIdentifier>{51de001f-37b7-4952-addf-629c03824504}</UniqueIdentifier>\n    </Filter>\n    <Filter Include=\"Source Files\\IPXACTModels\">\n      <UniqueIdentifier>{2971665b-6a04-407d-8318-6758c45d6da4}</UniqueIdentifier>\n    </Filter>\n    <Filter Include=\"Source Files\\IPXACTModels\\utilities\">\n      <UniqueIdentifier>{bf39ed15-309f-4b4c-8595-d1afb6ed401c}</UniqueIdentifier>\n    </Filter>\n    <Filter Include=\"Source Files\\Editors\\MemoryDesigner\">\n      <UniqueIdentifier>{5132b76e-10a7-494f-b1c3-ed8b39447b19}</UniqueIdentifier>\n    </Filter>\n    <Filter Include=\"Header Files\\Editors\\MemoryDesigner\">\n      <UniqueIdentifier>{c437154d-7686-4acf-b25f-b9ccbd0c3ed4}</UniqueIdentifier>\n    </Filter>\n    <Filter Include=\"Source Files\\CPUDialog\">\n      <UniqueIdentifier>{8b557752-6098-492e-aef8-0beab3b029d3}</UniqueIdentifier>\n    </Filter>\n    <Filter Include=\"Header Files\\CPUDialog\">\n      <UniqueIdentifier>{f9d45a70-c6c3-4863-8796-746a29d0c385}</UniqueIdentifier>\n    </Filter>\n    <Filter Include=\"Header Files\\common\">\n      <UniqueIdentifier>{dae175c4-e6e1-4f86-8a15-49bb5e9062b4}</UniqueIdentifier>\n    </Filter>\n    <Filter Include=\"Source Files\\common\">\n      <UniqueIdentifier>{d45be033-5577-4e31-bb23-12b0c19dcce5}</UniqueIdentifier>\n    </Filter>\n    <Filter Include=\"Source Files\\CPUDialog\\TemplateEditor\">\n      <UniqueIdentifier>{62e8ee45-dc4a-4a9e-b1c2-2255eae9293d}</UniqueIdentifier>\n    </Filter>\n    <Filter Include=\"Header Files\\CPUDialog\\TemplateEditor\">\n      <UniqueIdentifier>{58280bff-7d53-4249-a150-1ceef6502905}</UniqueIdentifier>\n    </Filter>\n  </ItemGroup>\n  <ItemGroup>\n    <ClCompile Include=\"..\\PluginSystem\\GeneratorPlugin\\GenerationControl.cpp\">\n      <Filter>Source Files\\GenerationControl</Filter>\n    </ClCompile>\n    <ClCompile Include=\"..\\PluginSystem\\GeneratorPlugin\\ViewSelection.cpp\">\n      <Filter>Source Files\\GenerationControl</Filter>\n    </ClCompile>\n    <ClCompile Include=\"..\\PluginSystem\\GeneratorPlugin\\OutputControl.cpp\">\n      <Filter>Source Files\\GenerationControl</Filter>\n    </ClCompile>\n    <ClCompile Include=\"..\\common\\HDLParser\\MetaComponent.cpp\">\n      <Filter>Source Files\\Parsing</Filter>\n    </ClCompile>\n    <ClCompile Include=\"..\\common\\HDLParser\\MetaDesign.cpp\">\n      <Filter>Source Files\\Parsing</Filter>\n    </ClCompile>\n    <ClCompile Include=\"..\\common\\HDLParser\\MetaInstance.cpp\">\n      <Filter>Source Files\\Parsing</Filter>\n    </ClCompile>\n    <ClCompile Include=\"..\\..\\IPXACTmodels\\utilities\\ComponentSearch.cpp\">\n      <Filter>Source Files\\IPXACTModels\\utilities</Filter>\n    </ClCompile>\n    <ClCompile Include=\"..\\..\\editors\\MemoryDesigner\\ConnectivityComponent.cpp\">\n      <Filter>Source Files\\Editors\\MemoryDesigner</Filter>\n    </ClCompile>\n    <ClCompile Include=\"..\\..\\editors\\MemoryDesigner\\ConnectivityConnection.cpp\">\n      <Filter>Source Files\\Editors\\MemoryDesigner</Filter>\n    </ClCompile>\n    <ClCompile Include=\"..\\..\\editors\\MemoryDesigner\\ConnectivityGraph.cpp\">\n      <Filter>Source Files\\Editors\\MemoryDesigner</Filter>\n    </ClCompile>\n    <ClCompile Include=\"..\\..\\editors\\MemoryDesigner\\ConnectivityGraphFactory.cpp\">\n      <Filter>Source Files\\Editors\\MemoryDesigner</Filter>\n    </ClCompile>\n    <ClCompile Include=\"..\\..\\editors\\MemoryDesigner\\ConnectivityInterface.cpp\">\n      <Filter>Source Files\\Editors\\MemoryDesigner</Filter>\n    </ClCompile>\n    <ClCompile Include=\"..\\..\\editors\\MemoryDesigner\\MasterSlavePathSearch.cpp\">\n      <Filter>Source Files\\Editors\\MemoryDesigner</Filter>\n    </ClCompile>\n    <ClCompile Include=\"..\\..\\editors\\MemoryDesigner\\MemoryItem.cpp\">\n      <Filter>Source Files\\Editors\\MemoryDesigner</Filter>\n    </ClCompile>\n    <ClCompile Include=\"..\\..\\editors\\MemoryDesigner\\MemoryDesignerConstants.cpp\">\n      <Filter>Source Files\\Editors\\MemoryDesigner</Filter>\n    </ClCompile>\n    <ClCompile Include=\"..\\..\\editors\\MemoryDesigner\\MemoryConnectionAddressCalculator.cpp\">\n      <Filter>Source Files\\Editors\\MemoryDesigner</Filter>\n    </ClCompile>\n    <ClCompile Include=\"..\\PluginSystem\\GeneratorPlugin\\MessagePasser.cpp\">\n      <Filter>Source Files\\GenerationControl</Filter>\n    </ClCompile>\n    <ClCompile Include=\"..\\common\\ConnectivityGraphUtilities.cpp\">\n      <Filter>Source Files\\common</Filter>\n    </ClCompile>\n    <ClCompile Include=\"..\\common\\CPUDialog\\CPUEditor.cpp\">\n      <Filter>Source Files\\CPUDialog</Filter>\n    </ClCompile>\n    <ClCompile Include=\"..\\common\\CPUDialog\\CPUSelectionDialog.cpp\">\n      <Filter>Source Files\\CPUDialog</Filter>\n    </ClCompile>\n    <ClCompile Include=\"RenodeGeneratorPlugin.cpp\">\n      <Filter>Source Files</Filter>\n    </ClCompile>\n    <ClCompile Include=\"RenodeGenerator.cpp\">\n      <Filter>Source Files</Filter>\n    </ClCompile>\n    <ClCompile Include=\"CPUDialog\\RenodePeripheralsModel.cpp\">\n      <Filter>Source Files\\CPUDialog</Filter>\n    </ClCompile>\n    <ClCompile Include=\"CPUDialog\\RenodePeripheralsEditor.cpp\">\n      <Filter>Source Files\\CPUDialog</Filter>\n    </ClCompile>\n    <ClCompile Include=\"CPUDialog\\RenodePeripheralsDelegate.cpp\">\n      <Filter>Source Files\\CPUDialog</Filter>\n    </ClCompile>\n    <ClCompile Include=\"CPUDialog\\RenodeUtilities.cpp\">\n      <Filter>Source Files\\CPUDialog</Filter>\n    </ClCompile>\n    <ClCompile Include=\"CPUDialog\\RenodeCpuEditor.cpp\">\n      <Filter>Source Files\\CPUDialog</Filter>\n    </ClCompile>\n    <ClCompile Include=\"CPUDialog\\RenodeMemoriesEditor.cpp\">\n      <Filter>Source Files\\CPUDialog</Filter>\n    </ClCompile>\n    <ClCompile Include=\"CPUDialog\\RenodeMemoriesModel.cpp\">\n      <Filter>Source Files\\CPUDialog</Filter>\n    </ClCompile>\n    <ClCompile Include=\"CPUDialog\\RenodeFileSelectionGroup.cpp\">\n      <Filter>Source Files\\CPUDialog</Filter>\n    </ClCompile>\n    <ClCompile Include=\"..\\common\\ConfigurationManager.cpp\">\n      <Filter>Source Files\\common</Filter>\n    </ClCompile>\n    <ClCompile Include=\"..\\common\\PluginConfigurationManager.cpp\">\n      <Filter>Source Files\\common</Filter>\n    </ClCompile>\n    <ClCompile Include=\"RenodeConfigurationManager.cpp\">\n      <Filter>Source Files</Filter>\n    </ClCompile>\n    <ClCompile Include=\"..\\common\\CpuRoutesContainer.cpp\">\n      <Filter>Source Files\\common</Filter>\n    </ClCompile>\n    <ClCompile Include=\"CPUDialog\\RenodeCpuRoutesContainer.cpp\">\n      <Filter>Source Files\\CPUDialog</Filter>\n    </ClCompile>\n    <ClCompile Include=\"..\\common\\SingleCpuRoutesContainer.cpp\">\n      <Filter>Source Files\\common</Filter>\n    </ClCompile>\n    <ClCompile Include=\"CPUDialog\\RenodeFileEditor.cpp\">\n      <Filter>Source Files\\CPUDialog</Filter>\n    </ClCompile>\n    <ClCompile Include=\"CPUDialog\\TemplateEditor\\PeripheralTemplatesDialog.cpp\">\n      <Filter>Source Files\\CPUDialog\\TemplateEditor</Filter>\n    </ClCompile>\n    <ClCompile Include=\"CPUDialog\\TemplateEditor\\PeripheralTemplateEditor.cpp\">\n      <Filter>Source Files\\CPUDialog\\TemplateEditor</Filter>\n    </ClCompile>\n    <ClCompile Include=\"..\\..\\common\\views\\EditableTableView\\editabletableview.cpp\">\n      <Filter>Source Files\\common</Filter>\n    </ClCompile>\n    <ClCompile Include=\"CPUDialog\\TemplateEditor\\PeripheralTemplateModel.cpp\">\n      <Filter>Source Files\\CPUDialog\\TemplateEditor</Filter>\n    </ClCompile>\n    <ClCompile Include=\"CPUDialog\\TemplateEditor\\PeripheralTemplateDelegate.cpp\">\n      <Filter>Source Files\\CPUDialog\\TemplateEditor</Filter>\n    </ClCompile>\n    <ClCompile Include=\"RenodeSettingsWidget.cpp\">\n      <Filter>Source Files</Filter>\n    </ClCompile>\n    <ClCompile Include=\"RenodeSettingsModel.cpp\">\n      <Filter>Source Files</Filter>\n    </ClCompile>\n    <ClCompile Include=\"CPUDialog\\TemplateEditor\\PeripheralTemplateConfigurer.cpp\">\n      <Filter>Source Files\\CPUDialog\\TemplateEditor</Filter>\n    </ClCompile>\n  </ItemGroup>\n  <ItemGroup>\n    <QtMoc Include=\"..\\PluginSystem\\GeneratorPlugin\\MessagePasser.h\">\n      <Filter>Header Files\\GenerationControl</Filter>\n    </QtMoc>\n    <QtMoc Include=\"..\\common\\CPUDialog\\CPUEditor.h\">\n      <Filter>Header Files\\CPUDialog</Filter>\n    </QtMoc>\n    <QtMoc Include=\"..\\common\\CPUDialog\\CPUSelectionDialog.h\">\n      <Filter>Header Files\\CPUDialog</Filter>\n    </QtMoc>\n    <QtMoc Include=\"RenodeGeneratorPlugin.h\">\n      <Filter>Header Files</Filter>\n    </QtMoc>\n    <QtMoc Include=\"CPUDialog\\RenodePeripheralsModel.h\">\n      <Filter>Header Files\\CPUDialog</Filter>\n    </QtMoc>\n    <QtMoc Include=\"CPUDialog\\RenodePeripheralsEditor.h\">\n      <Filter>Header Files\\CPUDialog</Filter>\n    </QtMoc>\n    <QtMoc Include=\"CPUDialog\\RenodePeripheralsDelegate.h\">\n      <Filter>Header Files\\CPUDialog</Filter>\n    </QtMoc>\n    <QtMoc Include=\"CPUDialog\\RenodeCpuEditor.h\">\n      <Filter>Header Files\\CPUDialog</Filter>\n    </QtMoc>\n    <QtMoc Include=\"CPUDialog\\RenodeMemoriesEditor.h\">\n      <Filter>Header Files\\CPUDialog</Filter>\n    </QtMoc>\n    <QtMoc Include=\"CPUDialog\\RenodeMemoriesModel.h\">\n      <Filter>Header Files\\CPUDialog</Filter>\n    </QtMoc>\n    <QtMoc Include=\"CPUDialog\\RenodeFileSelectionGroup.h\">\n      <Filter>Header Files\\CPUDialog</Filter>\n    </QtMoc>\n    <QtMoc Include=\"CPUDialog\\RenodeFileEditor.h\">\n      <Filter>Header Files\\CPUDialog</Filter>\n    </QtMoc>\n    <QtMoc Include=\"CPUDialog\\TemplateEditor\\PeripheralTemplatesDialog.h\">\n      <Filter>Header Files\\CPUDialog\\TemplateEditor</Filter>\n    </QtMoc>\n    <QtMoc Include=\"CPUDialog\\TemplateEditor\\PeripheralTemplateEditor.h\">\n      <Filter>Header Files\\CPUDialog\\TemplateEditor</Filter>\n    </QtMoc>\n    <QtMoc Include=\"..\\..\\common\\views\\EditableTableView\\editabletableview.h\">\n      <Filter>Header Files\\common</Filter>\n    </QtMoc>\n    <QtMoc Include=\"CPUDialog\\TemplateEditor\\PeripheralTemplateModel.h\">\n      <Filter>Header Files\\CPUDialog\\TemplateEditor</Filter>\n    </QtMoc>\n    <QtMoc Include=\"CPUDialog\\TemplateEditor\\PeripheralTemplateDelegate.h\">\n      <Filter>Header Files\\CPUDialog\\TemplateEditor</Filter>\n    </QtMoc>\n    <QtMoc Include=\"RenodeSettingsWidget.h\">\n      <Filter>Header Files</Filter>\n    </QtMoc>\n  </ItemGroup>\n  <ItemGroup>\n    <Image Include=\"RenodeGenerator.png\">\n      <Filter>Resource Files</Filter>\n    </Image>\n  </ItemGroup>\n  <ItemGroup>\n    <ClInclude Include=\"..\\PluginSystem\\GeneratorPlugin\\GenerationControl.h\">\n      <Filter>Header Files\\GenerationControl</Filter>\n    </ClInclude>\n    <ClInclude Include=\"..\\PluginSystem\\GeneratorPlugin\\ViewSelection.h\">\n      <Filter>Header Files\\GenerationControl</Filter>\n    </ClInclude>\n    <ClInclude Include=\"..\\PluginSystem\\GeneratorPlugin\\OutputControl.h\">\n      <Filter>Header Files\\GenerationControl</Filter>\n    </ClInclude>\n    <ClInclude Include=\"..\\common\\HDLParser\\MetaComponent.h\">\n      <Filter>Header Files\\Parsing</Filter>\n    </ClInclude>\n    <ClInclude Include=\"..\\common\\HDLParser\\MetaDesign.h\">\n      <Filter>Header Files\\Parsing</Filter>\n    </ClInclude>\n    <ClInclude Include=\"..\\common\\HDLParser\\MetaInstance.h\">\n      <Filter>Header Files\\Parsing</Filter>\n    </ClInclude>\n    <ClInclude Include=\"..\\..\\IPXACTmodels\\utilities\\ComponentSearch.h\">\n      <Filter>Header Files\\IPXACTModels\\utilities</Filter>\n    </ClInclude>\n    <ClInclude Include=\"..\\..\\editors\\MemoryDesigner\\ConnectivityComponent.h\">\n      <Filter>Header Files\\Editors\\MemoryDesigner</Filter>\n    </ClInclude>\n    <ClInclude Include=\"..\\..\\editors\\MemoryDesigner\\ConnectivityConnection.h\">\n      <Filter>Header Files\\Editors\\MemoryDesigner</Filter>\n    </ClInclude>\n    <ClInclude Include=\"..\\..\\editors\\MemoryDesigner\\ConnectivityGraph.h\">\n      <Filter>Header Files\\Editors\\MemoryDesigner</Filter>\n    </ClInclude>\n    <ClInclude Include=\"..\\..\\editors\\MemoryDesigner\\ConnectivityGraphFactory.h\">\n      <Filter>Header Files\\Editors\\MemoryDesigner</Filter>\n    </ClInclude>\n    <ClInclude Include=\"..\\..\\editors\\MemoryDesigner\\ConnectivityInterface.h\">\n      <Filter>Header Files\\Editors\\MemoryDesigner</Filter>\n    </ClInclude>\n    <ClInclude Include=\"..\\..\\editors\\MemoryDesigner\\MasterSlavePathSearch.h\">\n      <Filter>Header Files\\Editors\\MemoryDesigner</Filter>\n    </ClInclude>\n    <ClInclude Include=\"..\\..\\editors\\MemoryDesigner\\MemoryItem.h\">\n      <Filter>Header Files\\Editors\\MemoryDesigner</Filter>\n    </ClInclude>\n    <ClInclude Include=\"..\\..\\editors\\MemoryDesigner\\MemoryDesignerConstants.h\">\n      <Filter>Header Files\\Editors\\MemoryDesigner</Filter>\n    </ClInclude>\n    <ClInclude Include=\"..\\..\\editors\\MemoryDesigner\\MemoryConnectionAddressCalculator.h\">\n      <Filter>Header Files\\Editors\\MemoryDesigner</Filter>\n    </ClInclude>\n    <ClInclude Include=\"..\\common\\ConnectivityGraphUtilities.h\">\n      <Filter>Header Files\\common</Filter>\n    </ClInclude>\n    <ClInclude Include=\"RenodeGenerator.h\">\n      <Filter>Header Files</Filter>\n    </ClInclude>\n    <ClInclude Include=\"CPUDialog\\RenodeUtilities.h\">\n      <Filter>Header Files\\CPUDialog</Filter>\n    </ClInclude>\n    <ClInclude Include=\"..\\common\\ConfigurationManager.h\">\n      <Filter>Header Files\\common</Filter>\n    </ClInclude>\n    <ClInclude Include=\"..\\common\\PluginConfigurationManager.h\">\n      <Filter>Header Files\\common</Filter>\n    </ClInclude>\n    <ClInclude Include=\"RenodeConfigurationManager.h\">\n      <Filter>Header Files</Filter>\n    </ClInclude>\n    <ClInclude Include=\"..\\common\\CpuRoutesContainer.h\">\n      <Filter>Header Files\\common</Filter>\n    </ClInclude>\n    <ClInclude Include=\"CPUDialog\\RenodeCpuRoutesContainer.h\">\n      <Filter>Header Files\\CPUDialog</Filter>\n    </ClInclude>\n    <ClInclude Include=\"..\\common\\SingleCpuRoutesContainer.h\">\n      <Filter>Header Files\\common</Filter>\n    </ClInclude>\n    <ClInclude Include=\"CPUDialog\\RenodeColumns.h\">\n      <Filter>Header Files\\CPUDialog</Filter>\n    </ClInclude>\n    <ClInclude Include=\"CPUDialog\\RenodeStructs.h\">\n      <Filter>Header Files\\CPUDialog</Filter>\n    </ClInclude>\n    <ClInclude Include=\"CPUDialog\\RenodeConstants.h\">\n      <Filter>Header Files\\CPUDialog</Filter>\n    </ClInclude>\n    <ClInclude Include=\"RenodeSettingsModel.h\">\n      <Filter>Header Files</Filter>\n    </ClInclude>\n    <ClInclude Include=\"CPUDialog\\TemplateEditor\\PeripheralTemplateConfigurer.h\">\n      <Filter>Header Files\\CPUDialog\\TemplateEditor</Filter>\n    </ClInclude>\n  </ItemGroup>\n  <ItemGroup>\n    <QtRcc Include=\"RenodeGenerator.qrc\">\n      <Filter>Resource Files</Filter>\n    </QtRcc>\n  </ItemGroup>\n  <ItemGroup>\n    <Text Include=\"..\\..\\executable\\assets\\peripherals.txt\">\n      <Filter>Resource Files</Filter>\n    </Text>\n  </ItemGroup>\n</Project>"
  },
  {
    "path": "Plugins/RenodeGenerator/RenodeSettingsModel.cpp",
    "content": "﻿//-----------------------------------------------------------------------------\n// File: RenodeSettingsModel.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Mikko Teuho\n// Date: 05.06.2023\n//\n// Description:\n// Interface for renode generator settings model.\n//-----------------------------------------------------------------------------\n\n#include \"RenodeSettingsModel.h\"\n\n#include <QFile>\n\n#include <QDir>\n#include <QCoreApplication>\n\nnamespace\n{\n    //! Key for peripheral template configuration folder.\n\tQString const TEMPLATEFILEKEY = \"PythonPeripheralTemplateFile\";\n\n    //! Path to the default Renode generator peripheral template configuration.\n    QString const DEFAULTPATH = QCoreApplication::applicationDirPath() + QString(\"/templates/defaultTemplateConfiguration.json\");\n};\n\n\n//-----------------------------------------------------------------------------\n// Function: RenodeSettingsModel::loadSettings()\n//-----------------------------------------------------------------------------\nvoid RenodeSettingsModel::loadSettings(QSettings& settings)\n{\n    templateFilePath_ = settings.value(TEMPLATEFILEKEY).toString();\n}\n\n//-----------------------------------------------------------------------------\n// Function: RenodeSettingsModel::saveSettings()\n//-----------------------------------------------------------------------------\nvoid RenodeSettingsModel::saveSettings(QSettings& settings)\n{\n\tif (templateFilePath_.isEmpty() || !QFile::exists(templateFilePath_))\n\t{\n\t\tsettings.remove(TEMPLATEFILEKEY);\n\t}\n\telse\n\t{\n\t\tsettings.setValue(TEMPLATEFILEKEY, templateFilePath_);\n\t}\n}\n\n//-----------------------------------------------------------------------------\n// Function: RenodeSettingsModel::validateSettings()\n//-----------------------------------------------------------------------------\nbool RenodeSettingsModel::validateSettings() const\n{\n\treturn true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: RenodeSettingsModel::getFilePath()\n//-----------------------------------------------------------------------------\nQString RenodeSettingsModel::getFilePath() const\n{\n    if (!templateFilePath_.isEmpty())\n    {\n        return templateFilePath_;\n    }\n    else\n    {\n        return DEFAULTPATH;\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: RenodeSettingsModel::setFilePath()\n//-----------------------------------------------------------------------------\nvoid RenodeSettingsModel::setFilePath(QString const& newFolderPath)\n{\n    if (newFolderPath == DEFAULTPATH)\n    {\n        templateFilePath_.clear();\n    }\n    else\n    {\n        templateFilePath_ = newFolderPath;\n    }\n}\n"
  },
  {
    "path": "Plugins/RenodeGenerator/RenodeSettingsModel.h",
    "content": "//-----------------------------------------------------------------------------\n// File: RenodeSettingsModel.h\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Mikko Teuho\n// Date: 05.06.2023\n//\n// Description:\n// Interface for renode generator settings model.\n//-----------------------------------------------------------------------------\n\n#ifndef RENODESETTINGSMODEL_H\n#define RENODESETTINGSMODEL_H\n\n#include <KactusAPI/include/PluginSettingsModel.h>\n\n#include <Plugins/RenodeGenerator/CPUDialog/RenodeStructs.h>\n\n#include <QSettings>\n\n//-----------------------------------------------------------------------------\n//! Interface for renode generator settings model.\n//-----------------------------------------------------------------------------\nclass RenodeSettingsModel : public PluginSettingsModel\n{\npublic:\n\n    /*!\n     *  Destructor.\n     */\n    ~RenodeSettingsModel() final = default;\n    \n    /*!\n     *  Loads plugin settings from the given settings store. Is called when Kactus2 loads the plugin.\n     *\n     *    @param [in] settings The settings store.\n     */\n    virtual void loadSettings(QSettings& settings) override final;\n\n    /*!\n     *  Saves plugin settings to the given settings store. Is called when Kactus2 applies changes to settings.\n     *\n     *    @param [in,out] settings The settings store.\n     */\n    virtual void saveSettings(QSettings& settings) override final;\n\n    /*!\n     *  Validates the settings of the plugin.\n     */\n    virtual bool validateSettings() const override final;\n\n    /*!\n     *  Get the path to the current peripheral template configuration.\n     *\t\n     *    @return Path to the current peripheral template configuration.\n     */\n    QString getFilePath() const;\n\n    /*!\n     *  Set a new path for peripheral template configuration file.\n     *\t\n     *    @param [in] newFolderPath   The new path to peripheral template configuration file.\n     */\n    void setFilePath(QString const& newFolderPath);\n\nprivate:\n\n    //-----------------------------------------------------------------------------\n    // Data.\n    //-----------------------------------------------------------------------------\n\n    //! Path to the peripheral template configuration file.\n    QString templateFilePath_;\n};\n\n//-----------------------------------------------------------------------------\n\n#endif // RENODESETTINGSMODEL_H\n"
  },
  {
    "path": "Plugins/RenodeGenerator/RenodeSettingsWidget.cpp",
    "content": "﻿//-----------------------------------------------------------------------------\n// File: RenodeSettingsWidget.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 02.06.2023\n//\n// Description:\n// Widget for renode generator settings.\n//-----------------------------------------------------------------------------\n\n#include \"RenodeSettingsWidget.h\"\n\n#include <Plugins/RenodeGenerator/RenodeSettingsModel.h>\n\n#include <QHBoxLayout>\n\n#include <QLabel>\n#include <QPushButton>\n#include <QFileDialog>\n\n//-----------------------------------------------------------------------------\n// Function: RenodeSettingsWidget::RenodeSettingsWidget()\n//-----------------------------------------------------------------------------\nRenodeSettingsWidget::RenodeSettingsWidget(RenodeSettingsModel* settingsModel, QWidget *parent /* = 0 */):\nQWidget(parent),\nsettingsModel_(settingsModel),\ntemplatePathEditor_(new QLineEdit(settingsModel_->getFilePath(), this))\n{\n    templatePathEditor_->setToolTip(templatePathEditor_->text());\n\n    setupLayout();\n\n    connect(templatePathEditor_, SIGNAL(textChanged(QString const&)), this, SLOT(onPathChanged(QString const&)), Qt::UniqueConnection);\n}\n\n//-----------------------------------------------------------------------------\n// Function: RenodeSettingsWidget::setupLayout()\n//-----------------------------------------------------------------------------\nvoid RenodeSettingsWidget::setupLayout()\n{\n    auto mainLayout(new QHBoxLayout(this));\n\n\tmainLayout->addWidget(new QLabel(tr(\"Template path:\"), this));\n    mainLayout->addWidget(templatePathEditor_, 1);\n\n    auto fileBrowserButton(new QPushButton(this));\n    fileBrowserButton->setIcon(QIcon(QString(\":/icons/common/graphics/opened-folder.png\")));\n\n    connect(fileBrowserButton, SIGNAL(clicked()), this, SLOT(onBrowseTemplatePath()), Qt::UniqueConnection);\n\n    mainLayout->addWidget(fileBrowserButton);\n}\n\n//-----------------------------------------------------------------------------\n// Function: RenodeSettingsWidget::onBrowseTemplatePath()\n//-----------------------------------------------------------------------------\nvoid RenodeSettingsWidget::onBrowseTemplatePath()\n{\n\tQString newTemplatePath = QFileDialog::getOpenFileName(\n        this, tr(\"Select peripheral template configuration file\"), templatePathEditor_->text(), tr(\"JSON file (*.json)\"));\n\n    if (!newTemplatePath.isEmpty())\n    {\n        templatePathEditor_->setText(newTemplatePath);\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: RenodeSettingsWidget::onPathChanged()\n//-----------------------------------------------------------------------------\nvoid RenodeSettingsWidget::onPathChanged(QString const& newPath)\n{\n    settingsModel_->setFilePath(newPath);\n    templatePathEditor_->setToolTip(newPath);\n}\n"
  },
  {
    "path": "Plugins/RenodeGenerator/RenodeSettingsWidget.h",
    "content": "//-----------------------------------------------------------------------------\n// File: RenodeSettingsWidget.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 02.06.2023\n//\n// Description:\n// Widget for renode generator settings.\n//-----------------------------------------------------------------------------\n\n#ifndef RENODESETTINGSWIDGET_H\n#define RENODESETTINGSWIDGET_H\n\n#include <QWidget>\n#include <QLineEdit>\n\nclass RenodeSettingsModel;\n\n//-----------------------------------------------------------------------------\n//! Widget for renode generator settings.\n//-----------------------------------------------------------------------------\nclass RenodeSettingsWidget : public QWidget\n{\n    Q_OBJECT\n\npublic:\n\n    /*!\n     *  The constructor.\n     *\n     *    @param [in] settingsModel   Model for renode peripheral template settings.\n     *    @param [in] parent          Pointer to the owner of this widget.\n     */\n    RenodeSettingsWidget(RenodeSettingsModel* settingsModel, QWidget *parent = 0);\n\n    /*!\n     *  The destructor.\n     */\n    ~RenodeSettingsWidget() final = default;\n\n    //! No copying. No assignment.\n    RenodeSettingsWidget(const RenodeSettingsWidget& other) = delete;\n    RenodeSettingsWidget& operator=(const RenodeSettingsWidget& other) = delete;\n\nprivate slots:\n\n    /*!\n     *  Open file browser for peripheral template configuration.\n     */\n    void onBrowseTemplatePath();\n\n    /*!\n     *  Handle the change in the peripheral template configuration path.\n     *\t\n     *    @param [in] newPath     New path for peripheral template configuration file.\n     */\n    void onPathChanged(QString const& newPath);\n\nprivate:\n\n    /*!\n     *  Setup the layout.\n     */\n    void setupLayout();\n\n    //-----------------------------------------------------------------------------\n    // Data.\n    //-----------------------------------------------------------------------------\n\n    //! Model for renode peripheral template settings.\n    RenodeSettingsModel* settingsModel_;\n\n    //! Editor for peripheral template configuration file path.\n    QLineEdit* templatePathEditor_;\n};\n\n#endif // RENODESETTINGSWIDGET_H\n"
  },
  {
    "path": "Plugins/RenodeGenerator/renodeGeneratorPlugin.json",
    "content": "{\n\t\"Keys\": [ \"Renode Generator Plugin\" ]\n}"
  },
  {
    "path": "Plugins/RenodeGenerator/renodegeneratorplugin_global.h",
    "content": "#ifndef RENODEGENERATORPLUGIN_GLOBAL_H\n#define RENODEGENERATORPLUGIN_GLOBAL_H\n\n#include <QtCore/qglobal.h>\n\n#ifdef RENODEGENERATORPLUGIN_LIB\n# define RENODEGENERATORPLUGIN_EXPORT Q_DECL_EXPORT\n#else\n# define RENODEGENERATORPLUGIN_EXPORT Q_DECL_IMPORT\n#endif\n\n#endif // RENODEGENERATORPLUGIN_GLOBAL_H\n"
  },
  {
    "path": "Plugins/SVDGenerator/CPUDialog/SVDCPUColumns.h",
    "content": "//-----------------------------------------------------------------------------\n// File: SVDCPUColumns.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 18.05.2021\n//\n// Description:\n// SVD declarations for editing CPU details.\n//-----------------------------------------------------------------------------\n\n#ifndef SVDCPUCOLUMNS_H\n#define SVDCPUCOLUMNS_H\n\nnamespace SVDCPUColumns\n{\n    //! Defines the columns for the SVD CPU table.\n    enum Column\n    {\n        CREATESVD = 0,\n        NAME,\n        REVISION,\n        ENDIAN,\n        NVICPRIOBITS,\n        MPUPRESENT,\n        FPUPRESENT,\n        VENDORSYSTICKCONFIG,\n        COLUMN_COUNT\n    };\n}\n\n#endif // SVDCPUCOLUMNS_H\n"
  },
  {
    "path": "Plugins/SVDGenerator/CPUDialog/SVDCPUDelegate.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: SVDCPUDelegate.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 20.05.2021\n//\n// Description:\n// The delegate that provides editors to edit SVD CPU details.\n//-----------------------------------------------------------------------------\n\n#include \"SVDCPUDelegate.h\"\n\n#include <Plugins/SVDGenerator/CPUDialog/SVDCPUColumns.h>\n#include <Plugins/common/ConnectivityGraphUtilities.h>\n\n#include <QApplication>\n#include <QMouseEvent>\n#include <QPainter>\n#include <QComboBox>\n\n//-----------------------------------------------------------------------------\n// Function: SVDCPUDelegate::SVDCPUDelegate()\n//-----------------------------------------------------------------------------\nSVDCPUDelegate::SVDCPUDelegate(QObject* parent):\nQStyledItemDelegate(parent),\nbooleanModify_(false),\nbooleanState_(Qt::Unchecked)\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: SVDCPUDelegate::createEditor()\n//-----------------------------------------------------------------------------\nQWidget* SVDCPUDelegate::createEditor(QWidget* parent, QStyleOptionViewItem const& option,\n    QModelIndex const& index) const\n{\n    if (index.column() == SVDCPUColumns::ENDIAN)\n    {\n        QComboBox* editor(new QComboBox(parent));\n        return editor;\n    }\n    else\n    {\n        return QStyledItemDelegate::createEditor(parent, option, index);\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: SVDCPUDelegate::setEditorData()\n//-----------------------------------------------------------------------------\nvoid SVDCPUDelegate::setEditorData(QWidget* editor, QModelIndex const& index) const\n{\n    if (index.column() == SVDCPUColumns::ENDIAN)\n    {\n        QComboBox* endianEditor = dynamic_cast<QComboBox*>(editor);\n        if (endianEditor)\n        {\n            QString currentEndian = index.data(Qt::DisplayRole).toString();\n\n            endianEditor->addItem(\"\");\n            endianEditor->addItem(\"little\");\n            endianEditor->addItem(\"big\");\n            endianEditor->addItem(\"selectable\");\n            endianEditor->addItem(\"other\");\n\n            endianEditor->setCurrentIndex(endianEditor->findText(currentEndian));\n        }\n    }\n    else if (index.column() != SVDCPUColumns::REVISION ||\n        (index.column() == SVDCPUColumns::REVISION &&\n            index.data().toString() != ConnectivityGraphUtilities::REVISION_FORMAT))\n    {\n        QStyledItemDelegate::setEditorData(editor, index);\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: SVDCPUDelegate::editorEvent()\n//-----------------------------------------------------------------------------\nbool SVDCPUDelegate::editorEvent(QEvent *event, QAbstractItemModel* model, QStyleOptionViewItem const& option,\n    QModelIndex const& index)\n{\n    Q_ASSERT(event);\n    Q_ASSERT(model);\n\n    // Always reset the ad-hoc group modify flag.\n    if (event->type() == QEvent::MouseButtonRelease)\n    {\n        booleanModify_ = false;\n    }\n\n    // Make sure that the item is checkable.\n    Qt::ItemFlags flags = model->flags(index);\n\n    if (!(flags & Qt::ItemIsUserCheckable) || !(flags & Qt::ItemIsEnabled))\n    {\n        return false;\n    }\n\n    // Make sure that we have a check state.\n    QVariant value = index.data(Qt::CheckStateRole);\n\n    if (!value.isValid())\n    {\n        return false;\n    }\n\n    Qt::CheckState newState = static_cast<Qt::CheckState>(value.toInt());\n\n    // Handle the mouse button events.\n    if (event->type() == QEvent::MouseButtonPress)\n    {\n        const int textMargin = QApplication::style()->pixelMetric(QStyle::PM_FocusFrameHMargin) + 1;\n\n        QRect checkRect = QStyle::alignedRect(option.direction, Qt::AlignCenter,\n            option.decorationSize,\n            QRect(option.rect.x() + (2 * textMargin), option.rect.y(),\n            option.rect.width() - (2 * textMargin),\n            option.rect.height()));\n\n        if (!checkRect.contains(static_cast<QMouseEvent*>(event)->pos()))\n        {\n            return false;\n        }\n\n        newState = (static_cast<Qt::CheckState>(value.toInt()) == Qt::Checked ? Qt::Unchecked : Qt::Checked);\n        booleanModify_ = true;\n        booleanState_ = newState;\n    }\n    else if (event->type() == QEvent::MouseMove)\n    {\n        if (!booleanModify_ || static_cast<Qt::CheckState>(value.toInt()) == booleanState_)\n        {\n            return false;\n        }\n\n        const int textMargin = QApplication::style()->pixelMetric(QStyle::PM_FocusFrameHMargin) + 1;\n\n        QRect checkRect = QStyle::alignedRect(option.direction, Qt::AlignCenter,\n            option.decorationSize,\n            QRect(option.rect.x() + (2 * textMargin), option.rect.y(),\n            option.rect.width() - (2 * textMargin),\n            option.rect.height()));\n\n        if (!checkRect.contains(static_cast<QMouseEvent*>(event)->pos()))\n        {\n            return false;\n        }\n        \n        newState = booleanState_;\n    }\n    else if (event->type() == QEvent::KeyPress)\n    {\n        if (static_cast<QKeyEvent*>(event)->key() != Qt::Key_Space &&\n            static_cast<QKeyEvent*>(event)->key() != Qt::Key_Select)\n        {\n            return false;\n        }\n    }\n    else\n    {\n        return false;\n    }\n\n    return model->setData(index, newState, Qt::CheckStateRole);\n}\n\n//-----------------------------------------------------------------------------\n// Function: SVDCPUDelegate::paint()\n//-----------------------------------------------------------------------------\nvoid SVDCPUDelegate::paint(QPainter* painter, QStyleOptionViewItem const& option, QModelIndex const& index) const\n{\n\tQStyleOptionViewItem viewItemOption(option);\n\n    if (index.column() == SVDCPUColumns::CREATESVD || index.column() == SVDCPUColumns::MPUPRESENT ||\n        index.column() == SVDCPUColumns::FPUPRESENT || index.column() == SVDCPUColumns::VENDORSYSTICKCONFIG)\n    {\n        painter->fillRect(option.rect, Qt::white);\n\n        const int textMargin = QApplication::style()->pixelMetric(QStyle::PM_FocusFrameHMargin) + 1;\n\n        QRect newRect = QStyle::alignedRect(option.direction, Qt::AlignCenter,\n                                            QSize(option.decorationSize.width() + 5, option.decorationSize.height()),\n                                            QRect(option.rect.x() + textMargin, option.rect.y(),\n                                                  option.rect.width() - (2 * textMargin), option.rect.height()));\n        viewItemOption.rect = newRect;\n    }\n\n    QStyledItemDelegate::paint(painter, viewItemOption, index);\n}\n"
  },
  {
    "path": "Plugins/SVDGenerator/CPUDialog/SVDCPUDelegate.h",
    "content": "//-----------------------------------------------------------------------------\n// File: SVDCPUDelegate.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 20.05.2021\n//\n// Description:\n// The delegate that provides editors to edit SVD CPU details.\n//-----------------------------------------------------------------------------\n\n#ifndef SVDCPUDELEGATE_H\n#define SVDCPUDELEGATE_H\n\n#include <QCompleter>\n\n#include <QStyledItemDelegate>\n\n//-----------------------------------------------------------------------------\n//! The delegate that provides editors to edit SVD CPU details.\n//-----------------------------------------------------------------------------\nclass SVDCPUDelegate : public QStyledItemDelegate\n{\n\tQ_OBJECT\n\npublic:\n\n    /*!\n     *  The constructor.\n     */\n\tSVDCPUDelegate(QObject* parent = 0);\n\t\n\t/*!\n     *  The destructor.\n     */\n    virtual ~SVDCPUDelegate() = default;\n\n\t/*!\n     *  Create a new editor for the given item\n\t *\n\t *    @param [in] parent  Owner for the editor.\n\t *    @param [in] option  Contains options for the editor.\n\t *    @param [in] index   Model index identifying the item.\n\t *\n\t *    @return The editor to be used to edit the item.\n     */\n\tvirtual QWidget* createEditor(QWidget* parent, QStyleOptionViewItem const& option, QModelIndex const& index)\n        const;\n\n\t/*!\n     *  Set the data for the editor.\n\t *\n\t *    @param [in] editor  The editor where the data is to be set.\n\t *    @param [in] index   Model index identifying the item that's data is to be set.\n     */\n\tvirtual void setEditorData(QWidget* editor, QModelIndex const& index) const;\n\n\t/*!\n\t *  Renders an item in the given index.\n\t *\n\t *    @param [in] painter     The painter to use for rendering.\n\t *    @param [in] option      The style options for the rendering.\n\t *    @param [in] index       The index to the data being rendered.\n\t */\n\tvirtual void paint(QPainter* painter, QStyleOptionViewItem const& option, QModelIndex const& index) const;\n\n    // Disable copying.\n    SVDCPUDelegate(SVDCPUDelegate const& rhs) = delete;\n    SVDCPUDelegate& operator=(SVDCPUDelegate const& rhs) = delete;\n\nprotected:\n    \n    /*!\n     *  Handler for preprocessing events that starts editing.\n     *\n     *    @param [in] event   The event that triggered the editing.\n     *    @param [in] model   The underlying model to edit.\n     *    @param [in] option  Style options for rendering the item.\n     *    @param [in] index   The index being edited.\n     *\n     *    @return True, if the delegate handles the event, otherwise false.\n     */\n    virtual bool editorEvent(QEvent* event, QAbstractItemModel* model, QStyleOptionViewItem const& option, \n        QModelIndex const& index);\n\nprivate:\n\n    //-----------------------------------------------------------------------------\n    // Data.\n    //-----------------------------------------------------------------------------\n\n    //! Boolean for boolean group modify.\n    bool booleanModify_;\n\n    //! The new state for the boolean modify.\n    Qt::CheckState booleanState_;\n};\n\n#endif // SVDCPUDELEGATE_H\n"
  },
  {
    "path": "Plugins/SVDGenerator/CPUDialog/SVDCPUEditor.cpp",
    "content": "﻿//-----------------------------------------------------------------------------\n// File: SVDCPUEditor.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 18.05.2021\n//\n// Description:\n// Editor for CPU details in SVD generation.\n//-----------------------------------------------------------------------------\n\n#include \"SVDCPUEditor.h\"\n\n#include <Plugins/common/ConnectivityGraphUtilities.h>\n#include <Plugins/SVDGenerator/CPUDialog/SVDCPUModel.h>\n#include <Plugins/SVDGenerator/CPUDialog/SVDCPUDelegate.h>\n#include <Plugins/SVDGenerator/CPUDialog/SVDCpuRoutesContainer.h>\n#include <Plugins/SVDGenerator/CPUDialog/SVDUtilities.h>\n\n#include <QJsonArray>\n#include <QSortFilterProxyModel>\n#include <QVBoxLayout>\n#include <QHeaderView>\n\n//-----------------------------------------------------------------------------\n// Function: SVDCPUEditor::SVDCPUEditor()\n//-----------------------------------------------------------------------------\nSVDCPUEditor::SVDCPUEditor(QJsonObject const& configurationObject, QWidget *parent):\nCPUEditor(parent),\nview_(new QTableView(this)),\nmodel_(new SVDCPUModel(this)),\nconfigurationObject_(configurationObject)\n{\n    SVDCPUDelegate* cpuDelegate(new SVDCPUDelegate(parent));\n\n    QSortFilterProxyModel* proxy(new QSortFilterProxyModel(this));\n    proxy->setSourceModel(model_);\n\n    view_->horizontalHeader()->setSectionResizeMode(QHeaderView::Interactive);\n    view_->horizontalHeader()->setStretchLastSection(true);\n    view_->verticalHeader()->hide();\n    view_->verticalHeader()->setDefaultSectionSize(fontMetrics().height() + 8);\n\n    view_->setModel(proxy);\n    view_->setItemDelegate(cpuDelegate);\n\n    QVBoxLayout* layout = new QVBoxLayout(this);\n    layout->addWidget(view_, 1);\n    layout->setContentsMargins(0, 0, 0, 0);\n}\n\n//-----------------------------------------------------------------------------\n// Function: SVDCPUEditor::setCPUDetails()\n//-----------------------------------------------------------------------------\nvoid SVDCPUEditor::setupCPUDetails(LibraryInterface* library, QSharedPointer<Component> component, QString const& activeView)\n{\n    QVector<QSharedPointer<SVDCpuRoutesContainer> > cpuDetails = getSVDCPURoutes(library, component, activeView);\n\n    model_->setupCPUDetails(cpuDetails);\n    view_->resizeColumnsToContents();\n}\n\n//-----------------------------------------------------------------------------\n// Function: SVDCPUEditor::getSVDCPURoutes()\n//-----------------------------------------------------------------------------\nQVector<QSharedPointer<SVDCpuRoutesContainer> > SVDCPUEditor::getSVDCPURoutes(LibraryInterface* library, QSharedPointer<Component> component, QString const& activeView)\n{\n    QJsonValue cpusValue = configurationObject_.value(SVDConstants::CONFIGURATIONCPUS);\n    QJsonArray cpuArray;\n    if (cpusValue.isArray())\n    {\n        cpuArray = cpusValue.toArray();\n    }\n\n    QVector<QSharedPointer<SVDCpuRoutesContainer> > cpuDetails;\n    for (auto defaultCPU : ConnectivityGraphUtilities::getDefaultCPUs(library, component, activeView))\n    {\n        QSharedPointer<SVDCpuRoutesContainer> svdCPU(new SVDCpuRoutesContainer(*defaultCPU.data()));\n\n        for (auto cpuConfiguration : cpuArray)\n        {\n            if (cpuConfiguration.isObject())\n            {\n                QJsonObject cpuObject = cpuConfiguration.toObject();\n\n                QString configurationName = cpuObject.value(SVDConstants::NAME).toString();\n\n                if (configurationName == svdCPU->getFileName())\n                {\n                    svdCPU->setupConfiguration(cpuObject);\n                }\n            }\n        }\n\n        cpuDetails.append(svdCPU);\n    }\n\n    return cpuDetails;\n}\n\n//-----------------------------------------------------------------------------\n// Function: SVDCPUEditor::getSelectedCPUs()\n//-----------------------------------------------------------------------------\nQVector<QSharedPointer<CpuRoutesContainer> > SVDCPUEditor::getSelectedCPUs() const\n{\n    QVector<QSharedPointer<CpuRoutesContainer> > defaultCPUs;\n\n    for (auto svdCPU : model_->getCPUDetails())\n    {\n        defaultCPUs.append(svdCPU);\n    }\n\n    return defaultCPUs;\n}\n"
  },
  {
    "path": "Plugins/SVDGenerator/CPUDialog/SVDCPUEditor.h",
    "content": "//-----------------------------------------------------------------------------\n// File: SVDCPUEditor.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 18.05.2021\n//\n// Description:\n// Editor for CPU details in SVD generation.\n//-----------------------------------------------------------------------------\n\n#ifndef SVDCPUEDITOR_H\n#define SVDCPUEDITOR_H\n\n#include <QWidget>\n#include <QObject>\n#include <QTableView>\n#include <QJsonObject>\n\n#include <Plugins/common/ConnectivityGraphUtilities.h>\n#include <Plugins/common/CPUDialog/CPUEditor.h>\n\nclass SVDCPUModel;\nclass CpuRoutesContainer;\nclass SVDCpuRoutesContainer;\n\n//-----------------------------------------------------------------------------\n//! Editor for CPU details in SVD generation.\n//-----------------------------------------------------------------------------\nclass SVDCPUEditor : public CPUEditor\n{\n    Q_OBJECT\n\npublic:\n\n    /*!\n     *  The constructor.\n     *\n     *    @param [in] configurationObject     Object containing the SVD configurations.\n     *    @param [in] parent                  Pointer to the owner of this widget.\n     */\n    SVDCPUEditor(QJsonObject const& configurationObject, QWidget *parent = 0);\n\n    /*!\n     *  The destructor.\n     */\n    virtual ~SVDCPUEditor() = default;\n\n    /*!\n     *  Setup the selected CPUs.\n     *\n     *    @param [in] library     Interface for accessing the library.\n     *    @param [in] component   The top component of the design.\n     *    @param [in] activeView  Active view of the design.\n     */\n    virtual void setupCPUDetails(LibraryInterface* library, QSharedPointer<Component> component, QString const& activeView) override final;\n\n    /*!\n     *  Get a list of the selected CPU routes.\n     *\n     *    @return List of the selected CPU routes.\n     */\n    virtual QVector<QSharedPointer<CpuRoutesContainer> > getSelectedCPUs() const override final;\n\n    //! No copying. No assignment.\n    SVDCPUEditor(const SVDCPUEditor& other) = delete;\n    SVDCPUEditor& operator=(const SVDCPUEditor& other) = delete;\n\nprivate:\n\n    /*!\n     *  Create SVD CPU routes from the selected design.\n     *\n     *    @param [in] library     Interface for accessing the library.\n     *    @param [in] component   The top component of the design.\n     *    @param [in] activeView  Active view of the design.\n     *\n     *    @return The SVD CPU routes of the selected design.\n     */\n    QVector<QSharedPointer<SVDCpuRoutesContainer> > getSVDCPURoutes(LibraryInterface* library, QSharedPointer<Component> component, QString const& activeView);\n\n    //-----------------------------------------------------------------------------\n    // Data.\n    //-----------------------------------------------------------------------------\n\n    //! The view for the table.\n    QTableView* view_;\n\n    //! The containing model.\n    SVDCPUModel* model_;\n\n    //! The configuration container.\n    QJsonObject configurationObject_;\n};\n\n#endif // SVDCPUEDITOR_H\n"
  },
  {
    "path": "Plugins/SVDGenerator/CPUDialog/SVDCPUModel.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: SVDCPUModel.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 18.05.2021\n//\n// Description:\n// The model to manage the SVD CPU details.\n//-----------------------------------------------------------------------------\n\n#include \"SVDCPUModel.h\"\n\n#include \"SVDCPUColumns.h\"\n\n#include <common/KactusColors.h>\n\n#include <Plugins/common/ConnectivityGraphUtilities.h>\n#include <Plugins/SVDGenerator/CPUDialog/SVDCpuRoutesContainer.h>\n\n#include <QColor>\n\n//-----------------------------------------------------------------------------\n// Function: SVDCPUModel::SVDCPUModel()\n//-----------------------------------------------------------------------------\nSVDCPUModel::SVDCPUModel(QObject *parent):\nQAbstractTableModel(parent),\ncpus_()\n{\n}\n\n//-----------------------------------------------------------------------------\n// Function: SVDCPUModel::setupCPUDetails()\n//-----------------------------------------------------------------------------\nvoid SVDCPUModel::setupCPUDetails(QVector<QSharedPointer<SVDCpuRoutesContainer>> cpuDetails)\n{\n    beginResetModel();\n\n    cpus_.clear();\n    cpus_ = cpuDetails;\n\n    endResetModel();\n}\n\n//-----------------------------------------------------------------------------\n// Function: SVDCPUModel::getCPUDetails()\n//-----------------------------------------------------------------------------\nQVector<QSharedPointer<SVDCpuRoutesContainer> > SVDCPUModel::getCPUDetails() const\n{\n    return cpus_;\n}\n\n//-----------------------------------------------------------------------------\n// Function: SVDCPUModel::rowCount()\n//-----------------------------------------------------------------------------\nint SVDCPUModel::rowCount(QModelIndex const& parent) const\n{\n\tif (parent.isValid())\n    {\n\t\treturn 0;\n\t}\n\n\treturn cpus_.count();\n}\n\n//-----------------------------------------------------------------------------\n// Function: SVDCPUModel::columnCount()\n//-----------------------------------------------------------------------------\nint SVDCPUModel::columnCount(QModelIndex const& parent) const\n{\n\tif (parent.isValid())\n    {\n\t\treturn 0;\n\t}\n\n    return SVDCPUColumns::COLUMN_COUNT;\n}\n\n//-----------------------------------------------------------------------------\n// Function: SVDCPUModel::flags()\n//-----------------------------------------------------------------------------\nQt::ItemFlags SVDCPUModel::flags(QModelIndex const& index) const\n{\n\tif (!index.isValid() || index.column() == SVDCPUColumns::NAME)\n    {\n\t\treturn Qt::NoItemFlags;\n\t}\n\n    Qt::ItemFlags flags = Qt::ItemIsEnabled | Qt::ItemIsSelectable;\n\n    if (index.column() == SVDCPUColumns::CREATESVD || index.column() == SVDCPUColumns::MPUPRESENT ||\n        index.column() == SVDCPUColumns::FPUPRESENT || index.column() == SVDCPUColumns::VENDORSYSTICKCONFIG)\n    {\n        flags |= Qt::ItemIsUserCheckable;\n    }\n    else\n    {\n        flags |= Qt::ItemIsEditable;\n    }\n\n    return flags;\n}\n\n//-----------------------------------------------------------------------------\n// Function: SVDCPUModel::headerData()\n//-----------------------------------------------------------------------------\nQVariant SVDCPUModel::headerData(int section, Qt::Orientation orientation, int role) const \n{\n\tif (orientation != Qt::Horizontal)\n    {\n\t\treturn QVariant();\n\t}\n\n\tif (Qt::DisplayRole == role)\n    {\n        if (section == SVDCPUColumns::NAME)\n        {\n            return \"CPU\";\n        }\n        if (section == SVDCPUColumns::CREATESVD)\n        {\n            return \"Create\\nSVD\";\n        }\n        else if (section == SVDCPUColumns::REVISION)\n        {\n            return \"Revision\";\n        }\n        else if (section == SVDCPUColumns::NVICPRIOBITS)\n        {\n            return \"NVIC\\nbits\";\n        }\n        else if (section == SVDCPUColumns::ENDIAN)\n        {\n            return \"Endian\";\n        }\n        else if (section == SVDCPUColumns::MPUPRESENT)\n        {\n            return \"MPU\\npresence\";\n        }\n        else if (section == SVDCPUColumns::FPUPRESENT)\n        {\n            return \"FPU\\npresence\";\n        }\n        else if (section == SVDCPUColumns::VENDORSYSTICKCONFIG)\n        {\n            return \"Vendor specific\\nsystem tick timer\";\n        }\n\t}\n    \n    return QVariant();\n}\n\n//-----------------------------------------------------------------------------\n// Function: SVDCPUModel::data()\n//-----------------------------------------------------------------------------\nQVariant SVDCPUModel::data(QModelIndex const& index, int role) const\n{\n\tif (!index.isValid() || index.row() < 0 || index.row() >= cpus_.size())\n    {\n\t\treturn QVariant();\n\t}\n\n    if (role == Qt::DisplayRole || role == Qt::EditRole)\n    {\n        return valueForIndex(index);\n    }\n    else if (role == Qt::ToolTipRole)\n    {\n        return tooltipForIndex(index);\n    }\n\telse if (role == Qt::ForegroundRole)\n    {\n        if (index.column() == SVDCPUColumns::NAME)\n        {\n            return KactusColors::DISABLED_TEXT;\n        }\n        else if (index.column() == SVDCPUColumns::REVISION &&\n                valueForIndex(index).toString() == ConnectivityGraphUtilities::REVISION_FORMAT)\n        {\n            return QColor(Qt::lightGray);\n        }\n        else\n        {\n            return KactusColors::REGULAR_TEXT;\n        }\n    }\n    else if (Qt::CheckStateRole == role)\n    {\n        if (index.column() == SVDCPUColumns::CREATESVD || index.column() == SVDCPUColumns::MPUPRESENT ||\n            index.column() == SVDCPUColumns::FPUPRESENT || index.column() == SVDCPUColumns::VENDORSYSTICKCONFIG)\n        {\n            QSharedPointer<SVDCpuRoutesContainer> indexedCPU = cpus_.at(index.row());\n            if ((index.column() == SVDCPUColumns::CREATESVD && indexedCPU->shouldCreateFile()) ||\n                (index.column() == SVDCPUColumns::MPUPRESENT && indexedCPU->isMPUPresent()) ||\n                (index.column() == SVDCPUColumns::FPUPRESENT && indexedCPU->isFPUPresent()) ||\n                (index.column() == SVDCPUColumns::VENDORSYSTICKCONFIG && indexedCPU->isVendorSystickConfig()))\n            {\n                return Qt::Checked;\n            }\n            else\n            {\n                return Qt::Unchecked;\n            }\n        }\n        else\n        {\n            return QVariant();\n        }\n    }\n\n    return QVariant();\n}\n\n//-----------------------------------------------------------------------------\n// Function: MemoryMapModel::setData()\n//-----------------------------------------------------------------------------\nbool SVDCPUModel::setData(QModelIndex const& index, QVariant const& value, int role)\n{\n\tif (!index.isValid() || index.row() < 0 || index.row() >= cpus_.size())\n    {\n\t\treturn false;\n\t}\n\n    QSharedPointer<SVDCpuRoutesContainer> indexedCPU = cpus_.at(index.row());\n    if (Qt::EditRole == role)\n    {\n        if (index.column() == SVDCPUColumns::REVISION)\n        {\n            indexedCPU->setRevision(value.toString());\n        }\n        else if (index.column() == SVDCPUColumns::ENDIAN)\n        {\n            indexedCPU->setEndian(value.toString());\n        }\n        else if (index.column() == SVDCPUColumns::NVICPRIOBITS)\n        {\n            indexedCPU->setNVICPrioBits(value.toString());\n        }\n\n        emit dataChanged(index, index);\n        return true;\n    }\n    else if (role == Qt::CheckStateRole)\n    {\n        if (index.column() == SVDCPUColumns::CREATESVD)\n        {\n            indexedCPU->setCreateFileFlag(value.toBool());\n        }\n        if (index.column() == SVDCPUColumns::MPUPRESENT)\n        {\n            indexedCPU->setMPUPresence(value.toBool());\n        }\n        else if (index.column() == SVDCPUColumns::FPUPRESENT)\n        {\n            indexedCPU->setFPUPresence(value.toBool());\n        }\n        else if (index.column() == SVDCPUColumns::VENDORSYSTICKCONFIG)\n        {\n            indexedCPU->setVendorSystickConfig(value.toBool());\n        }\n\n        emit dataChanged(index, index);\n        return true;\n    }\n\n    return false;\n}\n\n//-----------------------------------------------------------------------------\n// Function: SVDCPUModel::valueForIndex()\n//-----------------------------------------------------------------------------\nQVariant SVDCPUModel::valueForIndex(QModelIndex const& index) const\n{\n    QSharedPointer<SVDCpuRoutesContainer> indexedCPU = cpus_.at(index.row());\n\n    if (index.column() == SVDCPUColumns::NAME)\n    {\n        return indexedCPU->getFileName();\n    }\n    else if (index.column() == SVDCPUColumns::REVISION)\n    {\n        QString revisionText = indexedCPU->getRevision();\n        if (revisionText.isEmpty())\n        {\n            revisionText = ConnectivityGraphUtilities::REVISION_FORMAT;\n        }\n\n        return revisionText;\n    }\n    else if (index.column() == SVDCPUColumns::ENDIAN)\n    {\n        return indexedCPU->getEndian();\n    }\n    else if (index.column() == SVDCPUColumns::NVICPRIOBITS)\n    {\n        return indexedCPU->getNVICPrioBits();\n    }\n   \n    return QVariant();\n}\n\n//-----------------------------------------------------------------------------\n// Function: SVDCPUModel::tooltipForIndex()\n//-----------------------------------------------------------------------------\nQVariant SVDCPUModel::tooltipForIndex(QModelIndex const& index) const\n{\n    if (index.column() == SVDCPUColumns::REVISION)\n    {\n        return QString(\"Define the HW revision of the processor.\\nThe version format is rNpM (N,M = [0 - 99])\");\n    }\n    else if (index.column() == SVDCPUColumns::ENDIAN)\n    {\n        return QString(\"Define the endianness of the processor being one of :\\n\"\n            \"little: little endian memory(least significant byte gets allocated at the lowest address).\\n\"\n            \"big : byte invariant big endian data organization(most significant byte gets allocated at the \"\n                \"lowest address).\\n\"\n            \"selectable : little and big endian are configurable for the device and become active after the \"\n                \"next reset.\\n\"\n            \"other : the endianness is neither little nor big endian.\");\n    }\n    else if (index.column() == SVDCPUColumns::NVICPRIOBITS)\n    {\n        return QString(\n            \"Define the number of bits available in the Nested Vectored Interrupt Controller(NVIC) for \"\n            \"configuring priority.\");\n    }\n    else if (index.column() == SVDCPUColumns::MPUPRESENT)\n    {\n        return QString(\"Indicate whether the processor is equipped with a memory protection unit(MPU).\");\n    }\n    else if (index.column() == SVDCPUColumns::FPUPRESENT)\n    {\n        return QString(\"Indicate whether the processor is equipped with a hardware floating point unit(FPU).\\n\"\n            \"Cortex - M4, Cortex - M7, Cortex - M33 and Cortex - M35P are the only available Cortex - M \"\n            \"processor with an optional FPU.\");\n    }\n    else if (index.column() == SVDCPUColumns::VENDORSYSTICKCONFIG)\n    {\n        return QString(\"Indicate whether the processor implements a vendor - specific System Tick Timer.\\n\"\n            \"If false, then the Arm - defined System Tick Timer is available.\\n\"\n            \"If true, then a vendor - specific System Tick Timer must be implemented.\");\n    }\n\n    return QVariant();\n}\n"
  },
  {
    "path": "Plugins/SVDGenerator/CPUDialog/SVDCPUModel.h",
    "content": "//-----------------------------------------------------------------------------\n// File: SVDCPUModel.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 18.05.2021\n//\n// Description:\n// The model to manage the SVD CPU details.\n//-----------------------------------------------------------------------------\n\n#ifndef SVDCPUMODEL_H\n#define SVDCPUMODEL_H\n\n#include <Plugins/common/ConnectivityGraphUtilities.h>\n\n#include <QAbstractTableModel>\n#include <QSharedPointer>\n\nclass SVDCpuRoutesContainer;\n\n//-----------------------------------------------------------------------------\n//! The model to manage the SVD CPU details.\n//-----------------------------------------------------------------------------\nclass SVDCPUModel : public QAbstractTableModel\n{\n\tQ_OBJECT\n\npublic:\n\n\t/*!\n\t *  The constructor.\n\t *\n\t *    @param [in] parent  Pointer to the owner of this model.\n\t */\n\tSVDCPUModel(QObject *parent);\n\t\n\t/*!\n     *  The destructor.\n     */\n    virtual ~SVDCPUModel() = default;\n\n    /*!\n     *  Setup the selected CPUs.\n     *\n     *    @param [in] cpuDetails  The selected CPUs.\n     */\n    void setupCPUDetails(QVector<QSharedPointer<SVDCpuRoutesContainer> > cpuDetails);\n\n    /*!\n     *  Get the CPU data.\n     *\n     *    @return List of CPU detail routes.\n     */\n    QVector<QSharedPointer<SVDCpuRoutesContainer> > getCPUDetails() const;\n\n\t/*!\n     *  Get the number of rows an item contains.\n\t *\n\t *    @param [in] parent  Identifies the parent that's row count is requested.\n\t *\n\t *    @return Number of rows the item has.\n\t */\n\tvirtual int rowCount(QModelIndex const& parent = QModelIndex()) const;\n\n\t/*!\n     *  Get the number of columns the item has to be displayed.\n\t *\n\t *    @param [in] parent  Identifies the parent that's column count is requested.\n\t *\n\t *    @return The number of columns to be displayed.\n\t */\n\tvirtual int columnCount(QModelIndex const& parent = QModelIndex()) const;\n\n\t/*!\n     *  Get the item flags that defines the possible operations for the item.\n\t *\n\t *    @param [in] index   Model index that identifies the item.\n\t *\n\t *    @return Qt::ItemFlags specify the possible operations for the item.\n\t */\n\tQt::ItemFlags flags(QModelIndex const& index) const;\n\n\t/*!\n     *  Get the header data for specified header.\n\t *\n\t *    @param [in] section         The section specifies the row/column number for the header.\n\t *    @param [in] orientation     Specified if horizontal or vertical header is wanted.\n\t *    @param [in] role            Specifies the type of the requested data.\n\t *\n\t *    @return QVariant Contains the requested data.\n\t */\n\tvirtual QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;\n\n\t/*!\n     *  Get the data for specified item.\n\t *\n\t *    @param [in] index   Specifies the item that's data is requested.\n\t *    @param [in] role    The role that defines what kind of data is requested.\n\t *\n\t *    @return QVariant Contains the data for the item.\n\t */\n\tvirtual QVariant data(QModelIndex const& index, int role = Qt::DisplayRole) const;\n\n\t/*!\n     *  Save the data to the model for specified item.\n\t *\n\t *    @param [in] index   The model index of the item that's data is to be saved.\n\t *    @param [in] value   The data that is to be saved.\n\t *    @param [in] role    The role specifies what kind of data should be saved.\n\t *\n\t *    @return True if saving happened successfully.\n\t */\n\tbool setData(QModelIndex const& index, const QVariant& value, int role = Qt::EditRole);\n    \n    //! No copying. No assignment.\n    SVDCPUModel(const SVDCPUModel& other) = delete;\n    SVDCPUModel& operator=(const SVDCPUModel& other) = delete;\n\nprivate:\n\t\n    /*!\n     *  Gets the value for the given index.\n     *\n     *    @param [in] index   The index of the target data.\n     *\n     *    @return The data in the given index.\n     */\n    QVariant valueForIndex(QModelIndex const& index) const;\n\n    /*!\n     *  Gets the tooltip value for the given index.\n     *\n     *    @param [in] index   The index of the target data.\n     *\n     *    @return The tooltip data in the given index.\n     */\n    QVariant tooltipForIndex(QModelIndex const& index) const;\n\n    //-----------------------------------------------------------------------------\n    // Data.\n    //-----------------------------------------------------------------------------\n\n    //! The CPU details being edited.\n    QVector<QSharedPointer<SVDCpuRoutesContainer> > cpus_;\n};\n\n#endif // SVDCPUMODEL_H\n"
  },
  {
    "path": "Plugins/SVDGenerator/CPUDialog/SVDCpuRoutesContainer.cpp",
    "content": "﻿//-----------------------------------------------------------------------------\n// File: SVDCpuRoutesContainer.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 24.02.2023\n//\n// Description:\n// Container for routes connected to a master interface for SVD generator.\n//-----------------------------------------------------------------------------\n\n#include \"SVDCpuRoutesContainer.h\"\n\n#include <Plugins/SVDGenerator/CPUDialog/SVDUtilities.h>\n\n#include <QJsonObject>\n\n//-----------------------------------------------------------------------------\n// Function: SVDCpuRoutesContainer::SVDCpuRoutesContainer()\n//-----------------------------------------------------------------------------\nSVDCpuRoutesContainer::SVDCpuRoutesContainer(QSharedPointer<Cpu> cpu):\nSingleCpuRoutesContainer(cpu),\nrevision_(QString(\"\")),\nendian_(QString(\"\")),\nmpuPresent_(false),\nfpuPresent_(false),\nnvicPrioBits_(QString(\"\")),\nvendorSystickConfig_(false)\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: SVDCpuRoutesContainer::SVDCpuRoutesContainer()\n//-----------------------------------------------------------------------------\nSVDCpuRoutesContainer::SVDCpuRoutesContainer(const SingleCpuRoutesContainer& other) :\nSingleCpuRoutesContainer(other),\nrevision_(QString()),\nendian_(QString()),\nmpuPresent_(false),\nfpuPresent_(false),\nnvicPrioBits_(QString()),\nvendorSystickConfig_(false)\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: SVDCpuRoutesContainer::setupConfiguration()\n//-----------------------------------------------------------------------------\nvoid SVDCpuRoutesContainer::setupConfiguration(QJsonObject const& configurationObject)\n{\n    setCreateFileFlag(configurationObject.value(SVDConstants::CREATESVDFLAG).toBool(false));\n    setEndian(configurationObject.value(SVDConstants::CPUENDIAN).toString(QString(\"\")));\n    setFPUPresence(configurationObject.value(SVDConstants::CPUFPUPRESENT).toBool(false));\n    setMPUPresence(configurationObject.value(SVDConstants::CPUMPUPRESENT).toBool(false));\n    setNVICPrioBits(configurationObject.value(SVDConstants::CPPUNVICPRIOBITS).toString(QString(\"\")));\n    setRevision(configurationObject.value(SVDConstants::CPUREVISION).toString(QString(\"\")));\n    setVendorSystickConfig(configurationObject.value(SVDConstants::CPUVENDORSYSTICKCONFIG).toBool(false));\n}\n\n//-----------------------------------------------------------------------------\n// Function: SVDCpuRoutesContainer::getRevision()\n//-----------------------------------------------------------------------------\nQString SVDCpuRoutesContainer::getRevision() const\n{\n    return revision_;\n}\n\n//-----------------------------------------------------------------------------\n// Function: SVDCpuRoutesContainer::setRevision()\n//-----------------------------------------------------------------------------\nvoid SVDCpuRoutesContainer::setRevision(QString const& newRevision)\n{\n    revision_ = newRevision;\n}\n\n//-----------------------------------------------------------------------------\n// Function: SVDCpuRoutesContainer::getEndian()\n//-----------------------------------------------------------------------------\nQString SVDCpuRoutesContainer::getEndian() const\n{\n    return endian_;\n}\n\n//-----------------------------------------------------------------------------\n// Function: SVDCpuRoutesContainer::setEndian()\n//-----------------------------------------------------------------------------\nvoid SVDCpuRoutesContainer::setEndian(QString const& newEndian)\n{\n    endian_ = newEndian;\n}\n\n//-----------------------------------------------------------------------------\n// Function: SVDCpuRoutesContainer::isMPUPresent()\n//-----------------------------------------------------------------------------\nbool SVDCpuRoutesContainer::isMPUPresent() const\n{\n    return mpuPresent_;\n}\n\n//-----------------------------------------------------------------------------\n// Function: SVDCpuRoutesContainer::setMPUPresence()\n//-----------------------------------------------------------------------------\nvoid SVDCpuRoutesContainer::setMPUPresence(bool newPresence)\n{\n    mpuPresent_ = newPresence;\n}\n\n//-----------------------------------------------------------------------------\n// Function: SVDCpuRoutesContainer::isFPUPresent()\n//-----------------------------------------------------------------------------\nbool SVDCpuRoutesContainer::isFPUPresent() const\n{\n    return fpuPresent_;\n}\n\n//-----------------------------------------------------------------------------\n// Function: SVDCpuRoutesContainer::setFPUPresence()\n//-----------------------------------------------------------------------------\nvoid SVDCpuRoutesContainer::setFPUPresence(bool newPresence)\n{\n    fpuPresent_ = newPresence;\n}\n\n//-----------------------------------------------------------------------------\n// Function: SVDCpuRoutesContainer::getNVICPrioBits()\n//-----------------------------------------------------------------------------\nQString SVDCpuRoutesContainer::getNVICPrioBits() const\n{\n    return nvicPrioBits_;\n}\n\n//-----------------------------------------------------------------------------\n// Function: SVDCpuRoutesContainer::setNVICPrioBits()\n//-----------------------------------------------------------------------------\nvoid SVDCpuRoutesContainer::setNVICPrioBits(QString const& newBits)\n{\n    nvicPrioBits_ = newBits;\n}\n\n//-----------------------------------------------------------------------------\n// Function: SVDCpuRoutesContainer::isVendorSystickConfig()\n//-----------------------------------------------------------------------------\nbool SVDCpuRoutesContainer::isVendorSystickConfig() const\n{\n    return vendorSystickConfig_;\n}\n\n//-----------------------------------------------------------------------------\n// Function: SVDCpuRoutesContainer::setVendorSystickConfig()\n//-----------------------------------------------------------------------------\nvoid SVDCpuRoutesContainer::setVendorSystickConfig(bool newConfig)\n{\n    vendorSystickConfig_ = newConfig;\n}\n"
  },
  {
    "path": "Plugins/SVDGenerator/CPUDialog/SVDCpuRoutesContainer.h",
    "content": "//-----------------------------------------------------------------------------\n// File: SVDCpuRoutesContainer.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 24.02.2023\n//\n// Description:\n// Container for routes connected to a master interface for SVD generator.\n//-----------------------------------------------------------------------------\n\n#ifndef SVDCPUROUTESCONTAINER_H\n#define SVDCPUROUTESCONTAINER_H\n\n#include <Plugins/common/SingleCpuRoutesContainer.h>\n\n#include <QJsonObject>\n\nclass Cpu;\n\n//-----------------------------------------------------------------------------\n//! Container for routes connected to a master interface for SVD generator.\n//-----------------------------------------------------------------------------\nclass SVDCpuRoutesContainer : public SingleCpuRoutesContainer\n{\n\npublic:\n\n    /*!\n     *  The constructor.\n     * \n     *    @param [in] cpu     The CPU.\n     */\n    SVDCpuRoutesContainer(QSharedPointer<Cpu> cpu);\n\n    /*!\n     *  The destructor.\n     */\n    virtual ~SVDCpuRoutesContainer() = default;\n\n    /*!\n     *  Creates an SVD CPU route from CPU route.\n     *\n     *    @return SVD CPU route.\n     */\n    SVDCpuRoutesContainer(SingleCpuRoutesContainer const& other);\n\n    /*!\n     *  Setup the data.\n     *\n     *    @param [in] configurationObject     Object containing the data.\n     */\n    void setupConfiguration(QJsonObject const& configurationObject);\n\n    /*!\n     *  Get the revision.\n     *\n     *    @return The revision.\n     */\n    QString getRevision() const;\n\n    /*!\n     *  Set the revision.\n     *\n     *    @param [in] newRevision     The new revision.\n     */\n    void setRevision(QString const& newRevision);\n\n    /*!\n     *  Get the endian.\n     *\n     *    @return The endian.\n     */\n    QString getEndian() const;\n\n    /*!\n     *  Set the endian.\n     *\n     *    @param [in] newEndian   The new endian.\n     */\n    void setEndian(QString const& newEndian);\n\n    /*!\n     *  Check the value of MPU presence.\n     *\n     *    @return True, if MPU is present, otherwise false.\n     */\n    bool isMPUPresent() const;\n\n    /*!\n     *  Set the MPU presence.\n     *\n     *    @param [in] newPresence     The new MPU presence.\n     */\n    void setMPUPresence(bool newPresence);\n\n    /*!\n     *  Check the FPU presence.\n     *\n     *    @return True, if the FPU is present, false otherwise.\n     */\n    bool isFPUPresent() const;\n\n    /*!\n     *  Set the FPU presence.\n     *\n     *    @param [in] newPresence     The new FPU presence.\n     */\n    void setFPUPresence(bool newPresence);\n\n    /*!\n     *  Get the number of NVIC bits.\n     *\n     *    @return Number of NVIC bits.\n     */\n    QString getNVICPrioBits() const;\n\n    /*!\n     *  Set the number of NVIC bits.\n     *\n     *    @param [in] newBits     The new NVIC bits.\n     */\n    void setNVICPrioBits(QString const& newBits);\n\n    /*!\n     *  Check if the CPU has a vendor specific system tick timer.\n     *\n     *    @return True, if the CPU has a vendor specific system tick timer, false otherwise.\n     */\n    bool isVendorSystickConfig() const;\n\n    /*!\n     *  Set the flag for vendor specific system tick timer.\n     *\n     *    @param [in] newConfig   The new vendor specific system tick timer.\n     */\n    void setVendorSystickConfig(bool newConfig);\n\nprivate:\n\n    // Disable copying.\n    SVDCpuRoutesContainer(SVDCpuRoutesContainer const& rhs);\n    SVDCpuRoutesContainer& operator=(SVDCpuRoutesContainer const& rhs);\n\n    //-----------------------------------------------------------------------------\n    // Data.\n    //-----------------------------------------------------------------------------\n\n    //! Revision of the CPU.\n    QString revision_;\n\n    //! Endian data of the CPU.\n    QString endian_;\n\n    //! MPU presence of the CPU.\n    bool mpuPresent_;\n\n    //! FPU presence of the CPU.\n    bool fpuPresent_;\n\n    //! Number of NVIC bits of the CPU.\n    QString nvicPrioBits_;\n\n    //! Vendor-specific system tick timer of the CPU.\n    bool vendorSystickConfig_;\n\n};\n\n#endif // SVDCPUROUTESCONTAINER_H"
  },
  {
    "path": "Plugins/SVDGenerator/CPUDialog/SVDUtilities.h",
    "content": "//-----------------------------------------------------------------------------\n// File: SVDUtilities.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 25.04.2023\n//\n// Description:\n// Utility functions for SVD generator.\n//-----------------------------------------------------------------------------\n\n#ifndef SVDUTILITIES_H\n#define SVDUTILITIES_H\n\n#include <QString>\n\n//-----------------------------------------------------------------------------\n// Function: SVDUtilities::SVDConstants()\n//-----------------------------------------------------------------------------\nnamespace SVDConstants\n{\n    //! File type for renode files.\n    const QString SVDFILETYPE = \"svd\";\n\n    //! File type for JSON files.\n    const QString JSONFILETYPE = \"json\";\n\n    //! Identifier for renode configuration file.\n    const QString CONFIGURATIONFILEEXTENSION = \"svdConfiguration\";\n\n    //! Identifier for view selection.\n    const QString VIEW = \"view\";\n\n    //! Identifier for save to fileset flag.\n    const QString SAVETOFILESET = \"saveToFileSet\";\n\n    //! Identifier for file set name.\n    const QString FILESET = \"fileSet\";\n\n    //! Identifier for generation destination.\n    const QString FOLDERPATH = \"destinationFolder\";\n\n    //! Identifier for write flags.\n    const QString WRITEFILES = \"writeFiles\";\n\n    //! Identifier for IP-XACT vendor element.\n    const QString VENDOR = \"vendor\";\n\n    //! Identifier for IP-XACT name element.\n    const QString NAME = \"name\";\n\n    //! Identifier for IP-XACT version element.\n    const QString VERSION = \"version\";\n\n    //! Identifier for description element.\n    const QString DESCRIPTION = \"description\";\n\n    //! Identifier for CPU element.\n    const QString CPUELEMENT = \"cpu\";\n\n    //! General type for CPUs.\n    const QString OTHERTYPE = \"other\";\n\n    //! Revision of the CPU.\n    const QString CPUREVISION = \"revision\";\n\n    //! Endian element of the CPU.\n    const QString CPUENDIAN = \"endian\";\n\n    //! MPU presence element.\n    const QString CPUMPUPRESENT = \"mpuPresent\";\n\n    //! FPU presence element.\n    const QString CPUFPUPRESENT = \"fpuPresent\";\n\n    //! NVIC prio bits element.\n    const QString CPPUNVICPRIOBITS = \"nvicPrioBits\";\n\n    //! Vendor-specific system tick timer element.\n    const QString CPUVENDORSYSTICKCONFIG = \"vendorSystickConfig\";\n\n    //! True for booleans in string.\n    const QString BOOLEANTRUE = \"true\";\n\n    //! False for booleans in string.\n    const QString BOOLEANFALSE = \"false\";\n\n    //! Address unit bits element.\n    const QString AUB = \"addressUnitBits\";\n\n    //! Width element.\n    const QString WIDTH = \"width\";\n\n    //! Size element.\n    const QString SIZE = \"size\";\n\n    //! Peripherals element.\n    const QString PERIPHERALSELEMENT = \"peripherals\";\n\n    //! Single peripheral element.\n    const QString SINGLEPERIPHERALELEMENT = \"peripheral\";\n\n    //! Peripheral version element.\n    const QString PERIPHERALVERSION = \"version\";\n\n    //! Peripheral base address element.\n    const QString PERIPHERALBASEADDRESS = \"baseAddress\";\n\n    //! Address block element.\n    const QString ADDRESSBLOCKELEMENT = \"addressBlock\";\n\n    //! Address block offset element.\n    const QString ADDRESSBLOCKOFFSET = \"offset\";\n\n    //! Address block usage: buffer element.\n    const QString BUFFERUSAGE = \"buffer\";\n\n    //! Address block usage: registers element.\n    const QString REGISTERSUSAGE = \"registers\";\n\n    //! Address block usage: reserved element.\n    const QString RESERVEDUSAGE = \"reserved\";\n\n    //! Address block usage element.\n    const QString USAGE = \"usage\";\n\n    //! Registers element.\n    const QString REGISTERSELEMENT = \"registers\";\n\n    //! Register cluster element.\n    const QString CLUSTER = \"cluster\";\n\n    //! Address offset element.\n    const QString ADDRESSOFFSET = \"addressOffset\";\n\n    //! Single register element.\n    const QString REGISTERELEMENT = \"register\";\n\n    //! Register dimension element.\n    const QString DIM = \"dim\";\n\n    //! Register dimension incremenet element.\n    const QString DIMINCREMENT = \"dimIncrement\";\n\n    //! Access element.\n    const QString ACCESS = \"access\";\n\n    //! The used hexadecimal format.\n    const QString HEXADECIMAL = \"0x\";\n\n    //! Reset value element.\n    const QString RESETVALUE = \"resetValue\";\n\n    //! Reset mask element.\n    const QString RESETMASK = \"resetMask\";\n\n    //! Fields element.\n    const QString FIELDSELEMENT = \"fields\";\n\n    //! Single field element.\n    const QString SINGLEFIELDELEMENT = \"field\";\n\n    //! Field bit range element.\n    const QString BITRANGE = \"bitRange\";\n\n    //! Enumerated values element.\n    const QString ENUMERATEDVALUESELEMENT = \"enumeratedValues\";\n\n    //! Single enumerated value element.\n    const QString SINGLEENUMERATEDVALUEELEMENT = \"enumeratedValue\";\n\n    //! Value element.\n    const QString VALUE = \"value\";\n\n    //! CPUs element.\n    const QString CONFIGURATIONCPUS = \"CPUs\";\n\n    //! Create SVD file element.\n    const QString CREATESVDFLAG = \"createSVD\";\n};\n\n#endif //RENODEUTILITIES_H"
  },
  {
    "path": "Plugins/SVDGenerator/SVDConfigurationManager.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: SVDConfigurationManager.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 25.04.2023\n//\n// Description:\n// Manager for storing and restoring SVD editor configurations.\n//-----------------------------------------------------------------------------\n\n#include \"SVDConfigurationManager.h\"\n\n#include <Plugins/SVDGenerator/CPUDialog/SVDUtilities.h>\n#include <Plugins/SVDGenerator/CPUDialog/SVDCpuRoutesContainer.h>\n\n#include <IPXACTmodels/Component/Component.h>\n#include <IPXACTmodels/Component/File.h>\n\n#include <KactusAPI/include/LibraryInterface.h>\n\n#include <QJsonArray>\n\n//-----------------------------------------------------------------------------\n// Function: SVDConfigurationManager::SVDConfigurationManager()\n//-----------------------------------------------------------------------------\nSVDConfigurationManager::SVDConfigurationManager(IPluginUtility* utility) :\nPluginConfigurationManager(utility)\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: SVDConfigurationManager::getConfigurationObject()\n//-----------------------------------------------------------------------------\nQJsonObject SVDConfigurationManager::getConfigurationObject(QSharedPointer<Component> component)\n{\n    QJsonDocument configurationDocument = getConfigurationDocument(component, SVDConstants::CONFIGURATIONFILEEXTENSION);\n    if (configurationDocument.isObject())\n    {\n        return configurationDocument.object();\n    }\n\n    return QJsonObject();\n}\n\n//-----------------------------------------------------------------------------\n// Function: SVDConfigurationManager::createConfigureFile()\n//-----------------------------------------------------------------------------\nvoid SVDConfigurationManager::createConfigureFile(QVector<QSharedPointer<SVDCpuRoutesContainer>> svdData,\n    QSharedPointer<Component> topComponent, QString const& selectedView, bool saveToFileSet,\n    QString const& selectedFileSet, QString const& folderPath)\n{\n    QFile configurationFile(getPathToConfigurationFile(topComponent, SVDConstants::CONFIGURATIONFILEEXTENSION));\n    if (!configurationFile.open(QIODevice::WriteOnly))\n    {\n        return;\n    }\n\n    QJsonDocument document = createJsonDocument(svdData, selectedView, saveToFileSet, selectedFileSet, folderPath);\n    configurationFile.write(document.toJson());\n\n    writeModelToFile(topComponent);\n}\n\n//-----------------------------------------------------------------------------\n// Function: SVDConfigurationManager::createJsonDocument()\n//-----------------------------------------------------------------------------\nQJsonDocument SVDConfigurationManager::createJsonDocument(QVector<QSharedPointer<SVDCpuRoutesContainer>> svdData,\n    QString const& selectedView, bool saveToFileSetFlag,\n    QString const& selectedFileSet, QString const& folderPath)\n{\n    QJsonObject configurationObject;\n\n    if (!svdData.isEmpty())\n    {\n        QJsonArray svdArray;\n\n        for (auto singleCPU : svdData)\n        {\n            QJsonObject cpuObject;\n            \n            cpuObject.insert(SVDConstants::NAME, singleCPU->getFileName());\n            cpuObject.insert(SVDConstants::CPUREVISION, singleCPU->getRevision());\n            cpuObject.insert(SVDConstants::CREATESVDFLAG, singleCPU->shouldCreateFile());\n            cpuObject.insert(SVDConstants::CPUENDIAN, singleCPU->getEndian());\n            cpuObject.insert(SVDConstants::CPPUNVICPRIOBITS, singleCPU->getNVICPrioBits());\n            cpuObject.insert(SVDConstants::CPUMPUPRESENT, singleCPU->isMPUPresent());\n            cpuObject.insert(SVDConstants::CPUFPUPRESENT, singleCPU->isFPUPresent());\n            cpuObject.insert(SVDConstants::CPUVENDORSYSTICKCONFIG, singleCPU->isVendorSystickConfig());\n\n            svdArray.push_back(cpuObject);\n        }\n\n        configurationObject.insert(SVDConstants::CONFIGURATIONCPUS, svdArray);\n    }\n\n    configurationObject.insert(SVDConstants::VIEW, selectedView);\n    configurationObject.insert(SVDConstants::FOLDERPATH, folderPath);\n    configurationObject.insert(SVDConstants::SAVETOFILESET, saveToFileSetFlag);\n    configurationObject.insert(SVDConstants::FILESET, selectedFileSet);\n\n    QJsonDocument document(configurationObject);\n    return document;\n}\n"
  },
  {
    "path": "Plugins/SVDGenerator/SVDConfigurationManager.h",
    "content": "//-----------------------------------------------------------------------------\n// File: SVDConfigurationManager.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 25.04.2023\n//\n// Description:\n// Manager for storing and restoring SVD editor configurations.\n//-----------------------------------------------------------------------------\n\n#ifndef SVDCONFIGURATIONMANAGER_H\n#define SVDCONFIGURATIONMANAGER_H\n\n#include <Plugins/common/PluginConfigurationManager.h>\n\nclass SVDCpuRoutesContainer;\n\n//-----------------------------------------------------------------------------\n//! Manager for storing and restoring SVD editor configurations.\n//-----------------------------------------------------------------------------\nclass SVDConfigurationManager : public PluginConfigurationManager\n{\n\npublic:\n    \n    /*!\n     *  The constructor.\n     */\n    SVDConfigurationManager(IPluginUtility* utility);\n    \n    /*!\n     * The destructor.\n     */\n    ~SVDConfigurationManager() = default;\n    \n    /*!\n     *  Get the configuration object of a single CPU.\n     *\n     *    @param [in] component   The containing component.\n     *\n     *    @return The configuration object.\n     */\n    QJsonObject getConfigurationObject(QSharedPointer<Component> component);\n    \n    /*!\n     *  Create a configuration file.\n     *\n     *    @param [in] svdData             Container for SVD generator data.\n     *    @param [in] topComponent        Top level component.\n     *    @param [in] selectedView        Name of the view to use in the generator.\n     *    @param [in] saveToFileSet       Flag for save to file set.\n     *    @param [in] selectedFileSet     Name of the target file set.\n     *    @param [in] folderPath          Path for the renode files.\n     */\n    void createConfigureFile(QVector<QSharedPointer<SVDCpuRoutesContainer> > svdData,\n        QSharedPointer<Component> topComponent,\n        QString const& selectedView,\n        bool saveToFileSet,\n        QString const& selectedFileSet,\n        QString const& folderPath);\n\nprivate:\n\n    /*!\n     *  Create a JSON document for storing the generator configurations.\n     *\n     *    @param [in] svdData             Container for SVD generator data.\n     *    @param [in] selectedView        Name of the view to use in the generator.\n     *    @param [in] saveToFileSetFlag   Flag for save to file set.\n     *    @param [in] selectedFileSet     Name of the target file set.\n     *    @param [in] folderPath          Path for the renode files.\n     *\n     *    @return The JSON configuration document.\n     */\n    QJsonDocument createJsonDocument(QVector<QSharedPointer<SVDCpuRoutesContainer> > svdData,\n        QString const& selectedView,\n        bool saveToFileSetFlag,\n        QString const& selectedFileSet,\n        QString const& folderPath);\n\n    //-----------------------------------------------------------------------------\n    // Data.\n    //-----------------------------------------------------------------------------\n};\n\n#endif // SVDCONFIGURATIONMANAGER_H\n"
  },
  {
    "path": "Plugins/SVDGenerator/SVDGenerator.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: SVDGenerator.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Mikko Teuho\n// Date: 14.04.2021\n//\n// Description:\n// Creates a CMSIS System View Description listing.\n//-----------------------------------------------------------------------------\n\n#include \"SVDGenerator.h\"\n\n#include <KactusAPI/include/LibraryInterface.h>\n\n#include <KactusAPI/include/SystemVerilogExpressionParser.h>\n#include <KactusAPI/include/IPluginUtility.h>\n\n#include <editors/MemoryDesigner/ConnectivityConnection.h>\n#include <editors/MemoryDesigner/ConnectivityGraph.h>\n#include <editors/MemoryDesigner/ConnectivityGraphFactory.h>\n#include <editors/MemoryDesigner/ConnectivityInterface.h>\n#include <editors/MemoryDesigner/MasterSlavePathSearch.h>\n#include <editors/MemoryDesigner/MemoryItem.h>\n#include <editors/MemoryDesigner/MemoryDesignerConstants.h>\n#include <editors/MemoryDesigner/MemoryConnectionAddressCalculator.h>\n\n#include <Plugins/SVDGenerator/CPUDialog/SVDCpuRoutesContainer.h>\n#include <Plugins/SVDGenerator/CPUDialog/SVDUtilities.h>\n\n#include <IPXACTmodels/Component/Component.h>\n#include <IPXACTmodels/Component/MemoryMap.h>\n#include <IPXACTmodels/Component/MemoryBlockBase.h>\n#include <IPXACTmodels/Component/AddressBlock.h>\n#include <IPXACTmodels/Component/RegisterBase.h>\n#include <IPXACTmodels/Component/Register.h>\n#include <IPXACTmodels/Component/Field.h>\n#include <IPXACTmodels/Component/EnumeratedValue.h>\n#include <IPXACTmodels/Design/Design.h>\n#include <IPXACTmodels/DesignConfiguration/DesignConfiguration.h>\n\n#include <QXmlStreamWriter>\n#include <QRegularExpression>\n\n//-----------------------------------------------------------------------------\n// Function: SVDGenerator::SVDGenerator()\n//-----------------------------------------------------------------------------\nSVDGenerator::SVDGenerator(IPluginUtility* utility):\nutility_(utility),\nlibrary_(utility->getLibraryInterface()),\ngraphFactory_(utility->getLibraryInterface())\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: SVDGenerator::generate()\n//-----------------------------------------------------------------------------\nvoid SVDGenerator::generate(QSharedPointer<Component> topComponent, QString const& componentPath, QVector<QSharedPointer<SVDCpuRoutesContainer>> const& cpuRoutes)\n{\n    QStringList fileNames;\n    for (auto cpuMasterRoute : cpuRoutes)\n    {\n        if (cpuMasterRoute->getRoutes().empty() == false)\n        {\n            writeFile(topComponent, componentPath, cpuMasterRoute, fileNames);\n        }\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: SVDGenerator::getGeneratedFiles()\n//-----------------------------------------------------------------------------\nQStringList SVDGenerator::getGeneratedFiles() const\n{\n    return generatedFiles_;\n}\n\n//-----------------------------------------------------------------------------\n// Function: SVDGenerator::writeFile()\n//-----------------------------------------------------------------------------\nvoid SVDGenerator::writeFile(QSharedPointer<Component> topComponent, QString const& componentPath,\n    QSharedPointer<SVDCpuRoutesContainer> cpuDetails, QStringList& fileNames)\n{\n    QVector<QSharedPointer<CpuRouteStructs::CpuRoute> > cpuRoutes = cpuDetails->getRoutes();\n    if (cpuRoutes.isEmpty())\n    {\n        return;\n    }\n\n    QSharedPointer<CpuRouteStructs::CpuRoute> firstCpuRouteDetails = cpuRoutes.first();\n\n    QSharedPointer<const ConnectivityComponent> routeComponent = firstCpuRouteDetails->cpuInterface_->getInstance();\n    QSharedPointer<const Component> interfaceComponent =\n        ConnectivityGraphUtilities::getInterfacedComponent(library_, routeComponent);\n    if (interfaceComponent)\n    {\n        QSharedPointer<Cpu> interfaceCPU = cpuDetails->getCpu();\n        QString fileName = topComponent->getVlnv().getName() + \"_\" + interfaceCPU->name();\n        if (fileNames.contains(interfaceCPU->name()))\n        {\n            fileName = fileName + \"_\" + QString::number(getFileNumberExtension(fileNames, fileName));\n        }\n        \n        QString svdFilePath = componentPath + \"/\" + fileName;\n        fileNames.append(fileName);\n        \n        svdFilePath += \".\" + SVDConstants::SVDFILETYPE;\n        \n        QFile outputFile(svdFilePath);\n        if (!outputFile.open(QIODevice::WriteOnly))\n        {\n            return;\n        }\n\n        QXmlStreamWriter xmlWriter(&outputFile);\n        xmlWriter.setAutoFormatting(true);\n        xmlWriter.setAutoFormattingIndent(-1);\n\n        xmlWriter.writeStartDocument();\n\n        writeDevice(xmlWriter, topComponent);\n        writeCPU(xmlWriter, interfaceCPU, cpuDetails);\n\n        writeAddressSpaceData(xmlWriter, firstCpuRouteDetails->cpuInterface_);\n\n        checkForErrorsInAddressSpaceData(fileName, firstCpuRouteDetails->cpuInterface_, cpuRoutes);\n\n        writePeripherals(xmlWriter, cpuRoutes);\n\n        xmlWriter.writeEndElement();    //! device\n\n        generatedFiles_.append(svdFilePath);\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: SVDGenerator::checkForErrorsInAddressSpaceData()\n//-----------------------------------------------------------------------------\nvoid SVDGenerator::checkForErrorsInAddressSpaceData(QString const& fileName, QSharedPointer<const ConnectivityInterface> comparisonInterface,\n    QVector<QSharedPointer<CpuRouteStructs::CpuRoute>> cpuRoutes)\n{\n    QString comparisonAUB = comparisonInterface->getConnectedMemory()->getAUB();\n    QString comparisonWidth = comparisonInterface->getConnectedMemory()->getWidth();\n    QString comparisonSize = comparisonInterface->getConnectedMemory()->getSize();\n    QString comparisonBase = comparisonInterface->getBaseAddress();\n\n    for (auto currentRoute : cpuRoutes)\n    {\n        QSharedPointer<const ConnectivityInterface> currentInterface = currentRoute->cpuInterface_;\n\n        QString currentAUB = currentInterface->getConnectedMemory()->getAUB();\n        if (currentAUB != comparisonAUB)\n        {\n            utility_->printError(\"Mis-matching address unit bits found in \" + fileName + \" interface \" + currentInterface->getName());\n        }\n        QString currentWidth = currentInterface->getConnectedMemory()->getWidth();\n        if (currentWidth != comparisonWidth)\n        {\n            utility_->printError(\"Mis-matching width found in \" + fileName + \" interface \" + currentInterface->getName());\n        }\n        QString currentSize = currentInterface->getConnectedMemory()->getSize();\n        if (currentSize != comparisonSize)\n        {\n            utility_->printError(\"Mis-matching size found in \" + fileName + \" interface \" + currentInterface->getName());\n        }\n        QString currentBase = currentInterface->getBaseAddress();\n        if (currentBase != comparisonBase)\n        {\n            utility_->printError(\"Mis-matching base address found in \" + fileName + \" interface \" + currentInterface->getName());\n        }\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: SVDGenerator::getFileNumberExtension()\n//-----------------------------------------------------------------------------\nint SVDGenerator::getFileNumberExtension(QStringList const& fileNames, QString const& fileName) const\n{\n    int extensionNumber = -1;\n    for (auto file : fileNames)\n    {\n        if (file.contains(fileName))\n        {\n            extensionNumber++;\n        }\n    }\n\n    return extensionNumber;\n}\n\n//-----------------------------------------------------------------------------\n// Function: SVDGenerator::writeDevice()\n//-----------------------------------------------------------------------------\nvoid SVDGenerator::writeDevice(QXmlStreamWriter& writer, QSharedPointer<Component> topComponent)\n{\n    writer.writeStartElement(QLatin1String(\"device\"));\n\n    writer.writeAttribute(QLatin1String(\"schemaVersion\"), QLatin1String(\"1.1\"));\n    writer.writeAttribute(QLatin1String(\"xmlns:xs\"), QLatin1String(\"http://www.w3.org/2001/XMLSchema-instance\"));\n    writer.writeAttribute(QLatin1String(\"xs:noNamespaceSchemaLocation\"), QLatin1String(\"CMSIS-SVD.xsd\"));\n\n    VLNV topVLNV = topComponent->getVlnv();\n    writer.writeTextElement(SVDConstants::VENDOR, topVLNV.getVendor());\n    writer.writeTextElement(SVDConstants::NAME, formatName(topVLNV.getName()));\n    writer.writeTextElement(SVDConstants::VERSION, topVLNV.getVersion());\n    writer.writeTextElement(SVDConstants::DESCRIPTION, topComponent->getDescription());\n}\n\n//-----------------------------------------------------------------------------\n// Function: SVDGenerator::formatName()\n//-----------------------------------------------------------------------------\nQString SVDGenerator::formatName(QString const& name) const\n{\n    QString formattedName = name;\n    formattedName = formattedName.trimmed();\n    formattedName = formattedName.replace(\" \", \"_\");\n    return formattedName;\n}\n\n//-----------------------------------------------------------------------------\n// Function: SVDGenerator::writeCPU()\n//-----------------------------------------------------------------------------\nvoid SVDGenerator::writeCPU(QXmlStreamWriter& writer, QSharedPointer<Cpu> currentCPU, QSharedPointer<SVDCpuRoutesContainer> cpuContainer)\n{\n    writer.writeStartElement(SVDConstants::CPUELEMENT);\n\n    QString cpuName = formatName(currentCPU->name());\n    QStringList knownNames({ \"CM0\", \"CM0PLUS\", \"CM0+\", \"CM1\", \"SC000\",\n        \"CM23\", \"CM3\", \"CM33\", \"CM35P\", \"SC300\", \"CM4\", \"CM7\",\n        \"CA5\", \"CA7\", \"CA8\", \"CA9\", \"CA15\", \"CA17\", \"CA53\", \"CA57\", \"CA72\"\n        });\n\n    if (knownNames.contains(cpuName) == false)\n    {\n        cpuName = SVDConstants::OTHERTYPE;\n    }\n\n    writer.writeTextElement(SVDConstants::NAME, cpuName);\n    writer.writeTextElement(SVDConstants::CPUREVISION , cpuContainer->getRevision());\n    writer.writeTextElement(SVDConstants::CPUENDIAN, cpuContainer->getEndian());\n    writeBoolean(writer, SVDConstants::CPUMPUPRESENT, cpuContainer->isMPUPresent());\n    writeBoolean(writer, SVDConstants::CPUFPUPRESENT, cpuContainer->isFPUPresent());\n    writer.writeTextElement(SVDConstants::CPPUNVICPRIOBITS, cpuContainer->getNVICPrioBits());\n    writeBoolean(writer, SVDConstants::CPUVENDORSYSTICKCONFIG, cpuContainer->isVendorSystickConfig());\n\n    writer.writeEndElement(); //! cpu\n}\n\n//-----------------------------------------------------------------------------\n// Function: SVDGenerator::writeBoolean()\n//-----------------------------------------------------------------------------\nvoid SVDGenerator::writeBoolean(QXmlStreamWriter& writer, QString const& elementName, bool state)\n{\n    if (state == true)\n    {\n        writer.writeTextElement(elementName, SVDConstants::BOOLEANTRUE);\n    }\n    else\n    {\n        writer.writeTextElement(elementName, SVDConstants::BOOLEANFALSE);\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: SVDGenerator::writeAddressSpaceData()\n//-----------------------------------------------------------------------------\nvoid SVDGenerator::writeAddressSpaceData(QXmlStreamWriter& writer,\n    QSharedPointer<const ConnectivityInterface> cpuInterface)\n{\n    writer.writeTextElement(SVDConstants::AUB, cpuInterface->getConnectedMemory()->getAUB());\n    writer.writeTextElement(SVDConstants::WIDTH, cpuInterface->getConnectedMemory()->getWidth());\n    writer.writeTextElement(SVDConstants::SIZE, cpuInterface->getConnectedMemory()->getWidth());\n}\n\n//-----------------------------------------------------------------------------\n// Function: SVDGenerator::writePeripherals()\n//-----------------------------------------------------------------------------\nvoid SVDGenerator::writePeripherals(QXmlStreamWriter& writer, QVector<QSharedPointer<CpuRouteStructs::CpuRoute>> cpuRouteDetails)\n{\n    writer.writeStartElement(SVDConstants::PERIPHERALSELEMENT);\n\n    for (auto singleRouteDetails : cpuRouteDetails)\n    {\n        for (auto& masterSlaveRoute : singleRouteDetails->routes_)\n        {\n            for (int i = 1; i < masterSlaveRoute.size(); ++i)\n            {\n                QSharedPointer<const ConnectivityInterface> routeInterface = masterSlaveRoute.at(i);\n                QSharedPointer<const ConnectivityComponent> interfacedComponent = routeInterface->getInstance();\n                QSharedPointer<MemoryItem> interfaceMemory = routeInterface->getConnectedMemory();\n\n                if (interfaceMemory && interfaceMemory->getType().compare(\n                    MemoryDesignerConstants::MEMORYMAP_TYPE, Qt::CaseInsensitive) == 0)\n                {\n                    QSharedPointer<const Component> component =\n                        ConnectivityGraphUtilities::getInterfacedComponent(library_, interfacedComponent);\n\n                    MemoryConnectionAddressCalculator::CalculatedPathAddresses pathAddresses =\n                        MemoryConnectionAddressCalculator::calculatePathAddresses(singleRouteDetails->cpuInterface_, routeInterface, masterSlaveRoute);\n\n                    quint64 memoryBaseAddress = pathAddresses.connectionBaseAddress_;\n                    QString baseAddressInHexa = valueToHexa(memoryBaseAddress);\n\n                    writePeripheral(writer, component, interfaceMemory, memoryBaseAddress, baseAddressInHexa);\n                }\n            }\n        }\n    }\n\n    writer.writeEndElement(); //! peripherals\n}\n\n//-----------------------------------------------------------------------------\n// Function: SVDGenerator::writePeripheral()\n//-----------------------------------------------------------------------------\nvoid SVDGenerator::writePeripheral(QXmlStreamWriter& writer, QSharedPointer<const Component> component,\n    QSharedPointer<MemoryItem> mapItem, quint64 mapBaseAddress, QString const& mapBaseAddressInHexa)\n{\n    QSharedPointer<MemoryMap> memoryMap = getMemoryMap(mapItem, component);\n    if (!memoryMap)\n    {\n        return;\n    }\n\n    writer.writeStartElement(SVDConstants::SINGLEPERIPHERALELEMENT);\n\n    writer.writeTextElement(SVDConstants::NAME, formatName(memoryMap->name()));\n    writer.writeTextElement(SVDConstants::PERIPHERALVERSION, component->getVlnv().getVersion());\n    writeOptionalElement(writer, SVDConstants::DESCRIPTION, memoryMap->description());\n\n    writer.writeTextElement(SVDConstants::PERIPHERALBASEADDRESS, mapBaseAddressInHexa);\n    writeAddressBlocks(writer, mapItem, mapBaseAddress);\n    writeRegisters(writer, component, mapItem, mapBaseAddress);\n    writer.writeEndElement(); //! peripheral\n}\n\n//-----------------------------------------------------------------------------\n// Function: SVDGenerator::getMemoryMap()\n//-----------------------------------------------------------------------------\nQSharedPointer<MemoryMap> SVDGenerator::getMemoryMap(QSharedPointer<MemoryItem> interfaceMemory,\n    QSharedPointer<const Component> containingComponent) const\n{\n    if (interfaceMemory)\n    {\n        for (auto map : *containingComponent->getMemoryMaps())\n        {\n            if (map->name() == interfaceMemory->getName())\n            {\n                return map;\n            }\n        }\n    }\n\n    return QSharedPointer<MemoryMap>();\n}\n\n//-----------------------------------------------------------------------------\n// Function: SVDGenerator::writeAddressBlock()\n//-----------------------------------------------------------------------------\nvoid SVDGenerator::writeAddressBlocks(QXmlStreamWriter& writer,\n    QSharedPointer<MemoryItem> mapItem,\n    quint64 mapBaseAddress)\n{\n    for (auto const& blockItem : getAddressBlockItems(mapItem))\n    {\n        quint64 blockBaseAddress = blockItem->getAddress().toULongLong();\n        if (blockBaseAddress >= mapBaseAddress)\n        {\n            blockBaseAddress = blockBaseAddress - mapBaseAddress;\n        }\n\n        writeSingleAddressBlock(writer, blockBaseAddress, blockItem);\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: SVDGenerator::getAddressBlockItems()\n//-----------------------------------------------------------------------------\nQVector<QSharedPointer<MemoryItem> > SVDGenerator::getAddressBlockItems(QSharedPointer<MemoryItem> mapItem) const\n{\n    QVector<QSharedPointer<MemoryItem> > blockItems;\n\n    for (auto subItem : getSubMemoryItems(mapItem, MemoryDesignerConstants::ADDRESSBLOCK_TYPE))\n    {\n        if (subItem->getUsage() != General::MEMORY)\n        {\n            blockItems.append(subItem);\n        }\n    }\n\n    return blockItems;\n}\n\n//-----------------------------------------------------------------------------\n// Function: SVDGenerator::getBlockMemoryItem()\n//-----------------------------------------------------------------------------\nQVector<QSharedPointer<MemoryItem>> SVDGenerator::getSubMemoryItems(QSharedPointer<MemoryItem> memoryItem,\n    QString const& subItemType) const\n{\n    QVector<QSharedPointer<MemoryItem>> subItems;\n\n    for (auto subItem : memoryItem->getChildItems())\n    {\n        if (subItem->getType().compare(subItemType, Qt::CaseInsensitive) == 0)\n        {\n            subItems.append(subItem);\n        }\n    }\n\n    return subItems;\n}\n\n//-----------------------------------------------------------------------------\n// Function: SVDGenerator::writeSingleAddressBlock()\n//-----------------------------------------------------------------------------\nvoid SVDGenerator::writeSingleAddressBlock(QXmlStreamWriter& writer, quint64 const& offset,\n    QSharedPointer<MemoryItem> blockItem)\n{\n    writer.writeStartElement(SVDConstants::ADDRESSBLOCKELEMENT);\n\n    QString addressOffsetInHexa = valueToHexa(offset);\n    QString rangeInHexa = valueToHexa(blockItem->getRange().toULongLong());\n\n    writer.writeTextElement(SVDConstants::ADDRESSBLOCKOFFSET, addressOffsetInHexa);\n    writer.writeTextElement(SVDConstants::SIZE, rangeInHexa);\n\n    QString usageString = SVDConstants::BUFFERUSAGE;\n    General::Usage blockUsage = blockItem->getUsage();\n    if (blockUsage == General::REGISTER || blockUsage == General::USAGE_COUNT)\n    {\n        usageString = SVDConstants::REGISTERSUSAGE;\n    }\n    if (blockUsage == General::RESERVED)\n    {\n        usageString = SVDConstants::RESERVEDUSAGE;\n    }\n\n    writer.writeTextElement(SVDConstants::USAGE, usageString);\n\n    writer.writeEndElement(); //! addressBlock\n}\n\n//-----------------------------------------------------------------------------\n// Function: SVDGenerator::writeRegisters()\n//-----------------------------------------------------------------------------\nvoid SVDGenerator::writeRegisters(QXmlStreamWriter& writer, QSharedPointer<const Component> containingComponent,\n    QSharedPointer<MemoryItem> mapItem, quint64 mapBaseAddress)\n{\n    writer.writeStartElement(SVDConstants::REGISTERSELEMENT);\n\n    for (auto blockItem : getAddressBlockItems(mapItem))\n    {\n        QSharedPointer<AddressBlock> containingBlock = getAddressBlock(containingComponent, mapItem, blockItem);\n        if (!containingBlock)\n        {\n            continue;\n        }\n\n        quint64 blockBaseAddress = blockItem->getAddress().toULongLong();\n        if (blockBaseAddress >= mapBaseAddress)\n        {\n            blockBaseAddress = blockBaseAddress - mapBaseAddress;\n        }\n\n        QString addressOffsetInHexa = valueToHexa(blockBaseAddress);\n\n        writeRegisterCluster(writer, containingBlock, blockItem, addressOffsetInHexa);\n    }\n\n    writer.writeEndElement(); // registers\n}\n\n//-----------------------------------------------------------------------------\n// Function: SVDGenerator::writeRegisterCluster()\n//-----------------------------------------------------------------------------\nvoid SVDGenerator::writeRegisterCluster(QXmlStreamWriter& writer, QSharedPointer<AddressBlock> containingBlock,\n    QSharedPointer<MemoryItem> blockItem, QString const& addressOffsetInHexa)\n{\n    QVector<QSharedPointer<MemoryItem> > registerItems =\n        getSubMemoryItems(blockItem, MemoryDesignerConstants::REGISTER_TYPE);\n    if (registerItems.isEmpty())\n    {\n        return;\n    }\n\n    writer.writeStartElement(SVDConstants::CLUSTER);\n\n    writer.writeTextElement(SVDConstants::NAME, blockItem->getName());\n    writer.writeTextElement(SVDConstants::ADDRESSOFFSET, addressOffsetInHexa);\n\n    for (auto registerItem : registerItems)\n    {\n        QSharedPointer<Register> realRegister = getRegister(containingBlock, registerItem);\n        if (!realRegister)\n        {\n            continue;\n        }\n\n        writeRegister(writer, registerItem, realRegister);\n    }\n\n    writer.writeEndElement(); //! cluster\n}\n\n//-----------------------------------------------------------------------------\n// Function: SVDGenerator::writeRegister()\n//-----------------------------------------------------------------------------\nvoid SVDGenerator::writeRegister(QXmlStreamWriter& writer, QSharedPointer<MemoryItem> registerItem,\n    QSharedPointer<Register> realRegister)\n{\n    // Skip all but first register in dimension array.\n    if (registerItem->getDimension().isEmpty() == false && registerItem->getIdentifier().endsWith(\"[0]\") == false)\n    {\n        return;\n    }\n\n    QString name = registerItem->getName();\n    quint64 registerOffset = registerItem->getOffset().toULongLong();\n    QString addressOffsetInHexa = valueToHexa(registerOffset);\n    QString sizeString = registerItem->getSize();\n\n    writer.writeStartElement(SVDConstants::REGISTERELEMENT);\n\n    if (registerItem->getDimension().isEmpty() == false)\n    {\n        writer.writeTextElement(SVDConstants::DIM, registerItem->getDimension());\n        writer.writeTextElement(SVDConstants::DIMINCREMENT, QString::number(sizeString.toInt() / 8));\n\n        name.append(\"[%s]\");\n    }\n\n    writer.writeTextElement(SVDConstants::NAME, formatName(name));\n    writeOptionalElement(writer, SVDConstants::DESCRIPTION, realRegister->description());\n\n    writer.writeTextElement(SVDConstants::ADDRESSOFFSET, addressOffsetInHexa);\n\n    QSharedPointer<MemoryItem> resetItem = getResetItem(registerItem);\n    if (resetItem)\n    {\n        writeReset(writer, resetItem);\n    }\n\n    writer.writeTextElement(SVDConstants::SIZE, sizeString);\n    writeOptionalElement(writer, SVDConstants::ACCESS, AccessTypes::access2Str(realRegister->getAccess()));\n\n    QMap<quint64, QSharedPointer<MemoryItem> > fieldItems = getFieldItemsInOrder(registerItem, registerOffset);\n    writeFields(writer, realRegister, fieldItems);\n\n    writer.writeEndElement(); //! register\n}\n\n//-----------------------------------------------------------------------------\n// Function: SVDGenerator::getResetItem()\n//-----------------------------------------------------------------------------\nQSharedPointer<MemoryItem> SVDGenerator::getResetItem(QSharedPointer<MemoryItem> registerItem) const\n{\n    for (auto subItem : registerItem->getChildItems())\n    {\n        if (subItem->getType() == MemoryDesignerConstants::RESET_TYPE)\n        {\n            return subItem;\n        }\n    }\n\n    return QSharedPointer<MemoryItem>();\n}\n\n//-----------------------------------------------------------------------------\n// Function: SVDGenerator::writeReset()\n//-----------------------------------------------------------------------------\nvoid SVDGenerator::writeReset(QXmlStreamWriter& writer, QSharedPointer<MemoryItem> resetItem) const\n{\n    bool transformSuccess = true;\n    QString registerResetValue = resetItem->getResetValue();\n    quint64 resetValue = registerResetValue.toULongLong(&transformSuccess, 2);\n    registerResetValue = QString::number(resetValue, 16).toUpper();\n\n    int valueNumbers = MemoryDesignerConstants::getAmountOfNumbersInRange(registerResetValue, registerResetValue);\n\n    QString registerResetMask = resetItem->getResetMask();\n    quint64 resetMask = registerResetMask.toULongLong(&transformSuccess, 2);\n    registerResetMask = QString::number(resetMask, 16).toUpper();\n\n    int maskNumbers = MemoryDesignerConstants::getAmountOfNumbersInRange(registerResetMask, registerResetMask);\n\n    int resetNumbers = valueNumbers;\n    if (maskNumbers > resetNumbers)\n    {\n        resetNumbers = maskNumbers;\n    }\n\n    registerResetValue = SVDConstants::HEXADECIMAL + MemoryDesignerConstants::getValueWithZerosAdded(registerResetValue, resetNumbers);\n    registerResetMask = SVDConstants::HEXADECIMAL + MemoryDesignerConstants::getValueWithZerosAdded(registerResetMask, resetNumbers);\n\n    writer.writeTextElement(SVDConstants::RESETVALUE, registerResetValue);\n    writer.writeTextElement(SVDConstants::RESETMASK, registerResetMask);\n}\n\n//-----------------------------------------------------------------------------\n// Function: SVDGenerator::getFieldItemsInOrder()\n//-----------------------------------------------------------------------------\nQMap<quint64, QSharedPointer<MemoryItem> > SVDGenerator::getFieldItemsInOrder(\n    QSharedPointer<MemoryItem> registerItem, quint64 const& registerOffset)\n{\n    QMap<quint64, QSharedPointer<MemoryItem> > orderedFieldItems;\n    \n    for (auto fieldItem : getSubMemoryItems(registerItem, MemoryDesignerConstants::FIELD_TYPE))\n    {\n        quint64 fieldStart = getFieldStart(fieldItem, registerOffset);\n        orderedFieldItems.insert(fieldStart, fieldItem);\n    }\n\n    return orderedFieldItems;\n}\n\n//-----------------------------------------------------------------------------\n// Function: SVDGenerator::writeFields()\n//-----------------------------------------------------------------------------\nvoid SVDGenerator::writeFields(QXmlStreamWriter& writer, QSharedPointer<Register> containingRegister,\n    QMap<quint64, QSharedPointer<MemoryItem>> fieldItems)\n{\n    if (fieldItems.isEmpty())\n    {\n        return;\n    }\n\n    writer.writeStartElement(SVDConstants::FIELDSELEMENT);\n\n    QMapIterator<quint64, QSharedPointer<MemoryItem> > fieldIterator(fieldItems);\n    while (fieldIterator.hasNext())\n    {\n        fieldIterator.next();\n        QSharedPointer<MemoryItem> fieldItem = fieldIterator.value();\n        QSharedPointer<Field> actualField = getField(containingRegister, fieldItem);\n        if (actualField)\n        {\n            writer.writeStartElement(SVDConstants::SINGLEFIELDELEMENT);\n\n            writer.writeTextElement(SVDConstants::NAME, formatName(fieldItem->getName()));\n            writeOptionalElement(writer, SVDConstants::DESCRIPTION, actualField->description());\n\n            QString fieldStart = fieldItem->getOffset();\n            QString fieldEnd = QString::number(getFieldEnd(fieldItem, fieldStart.toULongLong()));\n\n            writer.writeTextElement(SVDConstants::BITRANGE, \"[\" + fieldEnd + \":\" + fieldStart + \"]\");\n            writeOptionalElement(writer, SVDConstants::ACCESS, AccessTypes::access2Str(actualField->getAccess()));\n\n            writeEnumeratedValues(writer, actualField, fieldItem);\n\n            writer.writeEndElement(); //! field\n        }\n    }\n\n    writer.writeEndElement(); //! fields\n}\n\n//-----------------------------------------------------------------------------\n// Function: SVDGenerator::getFieldStart()\n//-----------------------------------------------------------------------------\nquint64 SVDGenerator::getFieldStart(QSharedPointer<MemoryItem> fieldItem, quint64 registerOffset)\n{\n    quint64 fieldAddress = fieldItem->getAddress().toInt();\n    quint64 fieldOffset = fieldItem->getOffset().toInt();\n\n    int aub = fieldItem->getAUB().toInt();\n\n    fieldOffset = (fieldAddress - registerOffset) * aub + fieldOffset;\n    return fieldOffset;\n}\n\n//-----------------------------------------------------------------------------\n// Function: SVDGenerator::getFieldEnd()\n//-----------------------------------------------------------------------------\nquint64 SVDGenerator::getFieldEnd(QSharedPointer<MemoryItem> fieldItem, quint64 fieldOffset)\n{\n    quint64 fieldWidth = fieldItem->getWidth().toInt();\n\n    if (fieldWidth > 0)\n    {\n        return fieldOffset + fieldWidth - 1;\n    }\n\n    return 0;\n}\n\n//-----------------------------------------------------------------------------\n// Function: SVDGenerator::writeEnumeratedValues()\n//-----------------------------------------------------------------------------\nvoid SVDGenerator::writeEnumeratedValues(QXmlStreamWriter& writer, QSharedPointer<Field> containingField,\n    QSharedPointer<MemoryItem> fieldItem)\n{\n    QVector<QSharedPointer<MemoryItem> > enumItems =\n        getSubMemoryItems(fieldItem, MemoryDesignerConstants::ENUMERATED_VALUE_TYPE);\n    if (enumItems.isEmpty())\n    {\n        return;\n    }\n\n    writer.writeStartElement(SVDConstants::ENUMERATEDVALUESELEMENT);\n\n    for (auto enumeratedItem : enumItems)\n    {\n        QSharedPointer<EnumeratedValue> actualEnumeration = getEnumeratedValue(containingField, enumeratedItem);\n        if (actualEnumeration)\n        {\n            writer.writeStartElement(SVDConstants::SINGLEENUMERATEDVALUEELEMENT);\n\n            writer.writeTextElement(SVDConstants::NAME, formatName(enumeratedItem->getName()));\n            writeOptionalElement(writer, SVDConstants::DESCRIPTION, actualEnumeration->description());\n\n            writer.writeTextElement(SVDConstants::VALUE, enumeratedItem->getValue());\n            writeOptionalElement(writer, SVDConstants::USAGE, EnumeratedValue::usage2Str(actualEnumeration->getUsage()));\n\n            writer.writeEndElement(); //! enumeratedValue\n        }\n    }\n\n    writer.writeEndElement(); //! enumeratedValues\n}\n\n//-----------------------------------------------------------------------------\n// Function: SVDGenerator::valueToHexa()\n//-----------------------------------------------------------------------------\nQString SVDGenerator::valueToHexa(quint64 const& value) const\n{\n    QString valueInHexa = QString::number(value, 16).toUpper();\n\n    int valueNumbers =\n        MemoryDesignerConstants::getAmountOfNumbersInRange(valueInHexa, valueInHexa);\n\n    valueInHexa = SVDConstants::HEXADECIMAL +\n        MemoryDesignerConstants::getValueWithZerosAdded(valueInHexa, valueNumbers);\n\n    return valueInHexa;\n}\n\n//-----------------------------------------------------------------------------\n// Function: SVDGenerator::writeOptionalElement()\n//-----------------------------------------------------------------------------\nvoid SVDGenerator::writeOptionalElement(QXmlStreamWriter& writer, QString const& elementName,\n    QString const& elementValue)\n{\n    if (!elementValue.isEmpty())\n    {\n        writer.writeTextElement(elementName, elementValue);\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: SVDGenerator::getAddressBlock()\n//-----------------------------------------------------------------------------\nQSharedPointer<AddressBlock> SVDGenerator::getAddressBlock(QSharedPointer<const Component> containingComponent,\n    QSharedPointer<MemoryItem> mapItem, QSharedPointer<MemoryItem> blockItem) const\n{\n    QSharedPointer<MemoryMap> containingMap = getMemoryMap(mapItem, containingComponent);\n    if (containingMap)\n    {\n        for (auto blockBase : *containingMap->getMemoryBlocks())\n        {\n            QSharedPointer<AddressBlock> block = blockBase.dynamicCast<AddressBlock>();\n            if (block && block->name() == blockItem->getName())\n            {\n                return block;\n            }\n        }\n    }\n\n    return QSharedPointer<AddressBlock>();\n}\n\n//-----------------------------------------------------------------------------\n// Function: SVDGenerator::getRegister()\n//-----------------------------------------------------------------------------\nQSharedPointer<Register> SVDGenerator::getRegister(QSharedPointer<AddressBlock> containingBlock,\n    QSharedPointer<MemoryItem> registerItem) const\n{\n    if (containingBlock)\n    {\n        for (auto baseRegister : *containingBlock->getRegisterData())\n        {\n            QSharedPointer<Register> currenRegister = baseRegister.dynamicCast<Register>();\n            if (currenRegister && currenRegister->name() == registerItem->getName())\n            {\n                return currenRegister;\n            }\n        }\n    }\n\n    return QSharedPointer<Register>();\n}\n\n//-----------------------------------------------------------------------------\n// Function: SVDGenerator::getField()\n//-----------------------------------------------------------------------------\nQSharedPointer<Field> SVDGenerator::getField(QSharedPointer<Register> containingRegister,\n    QSharedPointer<MemoryItem> fieldItem) const\n{\n    for (auto field : *containingRegister->getFields())\n    {\n        if (field->name() == fieldItem->getName())\n        {\n            return field;\n        }\n    }\n\n    return QSharedPointer<Field>();\n}\n\n//-----------------------------------------------------------------------------\n// Function: SVDGenerator::getEnumeratedValue()\n//-----------------------------------------------------------------------------\nQSharedPointer<EnumeratedValue> SVDGenerator::getEnumeratedValue(QSharedPointer<Field> containingField,\n    QSharedPointer<MemoryItem> enumeratedItem) const\n{\n    for (auto enumeration : *containingField->getEnumeratedValues())\n    {\n        if (enumeration->name() == enumeratedItem->getName())\n        {\n            return enumeration;\n        }\n    }\n\n    return QSharedPointer<EnumeratedValue>();\n}\n"
  },
  {
    "path": "Plugins/SVDGenerator/SVDGenerator.h",
    "content": "//-----------------------------------------------------------------------------\n// File: SVDGenerator.h\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Mikko Teuho\n// Date: 14.04.2021\n//\n// Description:\n// Creates a CMSIS System View Description listing.\n//-----------------------------------------------------------------------------\n\n#ifndef SVDGENERATOR_H\n#define SVDGENERATOR_H\n\n#include <QList>\n#include <QString>\n#include <QSharedPointer>\n\n#include \"svdgeneratorplugin_global.h\"\n\n#include <Plugins/common/ConnectivityGraphUtilities.h>\n\n#include <editors/MemoryDesigner/ConnectivityGraphFactory.h>\n\n#include <IPXACTmodels/Component/BusInterface.h>\n\n#include <IPXACTmodels/Design/ActiveInterface.h>\n#include <IPXACTmodels/Design/Design.h>\n\n#include <IPXACTmodels/generaldeclarations.h>\n\nclass AddressBlock;\nclass BusInterface;\nclass Component;\nclass ExpressionParser;\nclass Field;\nclass ConnectivityInterface;\nclass LibraryInterface;\nclass MemoryItem;\nclass Register;\nclass Cpu;\nclass MemoryMap;\nclass EnumeratedValue;\nclass SVDCpuRoutesContainer;\nclass IPluginUtility;\n\n//-----------------------------------------------------------------------------\n//! Creates a CMSIS System View Description listing.\n//-----------------------------------------------------------------------------\nclass SVDGENERATORPLUGIN_EXPORT SVDGenerator\n{\npublic:\n    \n    /*!\n     *  The constructor.\n     *\n     *    @param [in] utility     The plugin utility interface.\n     */\n    explicit SVDGenerator(IPluginUtility* utility);\n\n    /*!\n     *  The destructor.\n     */\n    ~SVDGenerator() = default;\n\n    // Disable copying.\n    SVDGenerator(SVDGenerator const& rhs) = delete;\n    SVDGenerator& operator=(SVDGenerator const& rhs) = delete;\n\n    /*!\n     *  Generates slave memory listing for the given component.\n     *\n     *    @param [in] topComponent            The top component in the hierarchy to generate listing for.\n     *    @param [in] componentPath           Path to the component folder.\n     *    @param [in] cpuRoutes               CPU and its connected routes.\n     */\n    void generate(QSharedPointer<Component> topComponent,\n        QString const& componentPath,\n        QVector<QSharedPointer<SVDCpuRoutesContainer> > const& cpuRoutes);\n\n    /*!\n     *  Get the generated files.\n     *\n     *    @return The generated files.\n     */\n    QStringList getGeneratedFiles() const;\n\nprivate:\n\n\n    /*!\n     *  Writes the CPU listing into a given file.\n     *\n     *    @param [in] topComponent    Top component of the design.\n     *    @param [in] componentPath   Path to the component folder.\n     *    @param [in] cpuDetails      Details for the selected CPU route container.\n     *    @param [in] fileNames       Names of the generated SVD files.\n     */\n    void writeFile(QSharedPointer<Component> topComponent,\n        QString const& componentPath,\n        QSharedPointer<SVDCpuRoutesContainer> cpuDetails,\n        QStringList& fileNames);\n\n    /*!\n     *  Get the number of files containing the selected name.\n     *\n     *    @param [in] fileNames   List of the generated files.\n     *    @param [in] fileName    The selected file name.\n     *\n     *    @return Number of files containing the same name.\n     */\n    int getFileNumberExtension(QStringList const& fileNames, QString const& fileName) const;\n\n    /*!\n     *  Write the device information.\n     *\n     *    @param [in] writer          The xml stream writer.\n     *    @param [in] topComponent    Top component of the containing design.\n     */\n    void writeDevice(QXmlStreamWriter& writer, QSharedPointer<Component> topComponent);\n\n    /*!\n     *  Remove ' ' from the front and back of the selected name and replace the remaining with _.\n     *\n     *    @param [in] name    The selected name.\n     *\n     *    @return The formatted name.\n     */\n    QString formatName(QString const& name) const;\n\n    /*!\n     *  Write the selected CPU.\n     *\n     *    @param [in] writer          The xml stream writer.\n     *    @param [in] currentCPU      The selected CPU.\n     *    @param [in] cpuContianer    The CPU data container.\n     */\n    void writeCPU(QXmlStreamWriter& writer,\n        QSharedPointer<Cpu> currentCPU,\n        QSharedPointer<SVDCpuRoutesContainer> cpuContainer);\n\n    /*!\n     *  Write a boolean flag.\n     *\n     *    @param [in] writer          The xml stream writer.\n     *    @param [in] elementName     Name of the selected boolean flag.\n     *    @param [in] state           The flag state.\n     */\n    void writeBoolean(QXmlStreamWriter& writer, QString const& elementName, bool state);\n\n    /*!\n     *  Write the address space of the selected CPU.\n     *\n     *    @param [in] writer          The xml stream writer.\n     *    @param [in] cpuInterface    Interface containing the selected CPU.\n     */\n    void writeAddressSpaceData(QXmlStreamWriter& writer, QSharedPointer<const ConnectivityInterface> cpuInterface);\n\n    /*!\n     *  Write the peripherals of the selected CPU route container.\n     *\n     *    @param [in] writer              The xml stream writer.\n     *    @param [in] cpuRouteDetails     The selected CPU route container.\n     */\n    void writePeripherals(QXmlStreamWriter& writer,\n        QVector<QSharedPointer<CpuRouteStructs::CpuRoute> > cpuRouteDetails);\n\n    /*!\n     *  Write memory map peripheral of the selected memory item.\n     *\n     *    @param [in] writer                  The xml stream writer.\n     *    @param [in] component               Component containing the interfaced memory map item.\n     *    @param [in] mapItem                 The selected memory item.\n     *    @param [in] mapBaseAddress          Base address of the memory map.\n     *    @param [in] mapBaseAddressInHexa    Base address of the memory map in hex format.\n     */\n    void writePeripheral(QXmlStreamWriter& writer,\n        QSharedPointer<const Component> component,\n        QSharedPointer<MemoryItem> mapItem,\n        quint64 mapBaseAddress,\n        QString const& mapBaseAddressInHexa);\n\n    /*!\n     *  Write address blocks of the selected memory map item.\n     *\n     *    @param [in] writer                  The xml stream writer.\n     *    @param [in] mapItem                 The selected memory map item.\n     *    @param [in] mapBaseAddress          Base address of the memory map.\n     */\n    void writeAddressBlocks(QXmlStreamWriter& writer, \n        QSharedPointer<MemoryItem> mapItem, quint64 mapBaseAddress);\n\n    /*!\n     *  Get the available address block items of the selected memory map item.\n     *\n     *    @param [in] mapItem     The selected memory map item.\n     *\n     *    @return Address blocks with usage other than memory of the selected memory map item.\n     */\n    QVector<QSharedPointer<MemoryItem> > getAddressBlockItems(QSharedPointer<MemoryItem> mapItem) const;\n\n    /*!\n     *  Get a list of the selected sub items of the selected memory item.\n     *\n     *    @param [in] memoryItem      The selected memory item.\n     *    @param [in] subItemType     Type of the sub item.\n     *\n     *    @return List of the selected sub items.\n     */\n    QVector<QSharedPointer<MemoryItem>> getSubMemoryItems(QSharedPointer<MemoryItem> memoryItem,\n        QString const& subItemType) const;\n\n    /*!\n     *  Write the selected address block.\n     *\n     *    @param [in] writer              The xml stream writer.\n     *    @param [in] offset              Offset of the address block.\n     *    @param [in] blockItem           The selected address block item.\n     */\n    void writeSingleAddressBlock(QXmlStreamWriter& writer, quint64 const& offset, \n         QSharedPointer<MemoryItem> blockItem);\n\n    void writeRegisters(QXmlStreamWriter& writer, QSharedPointer<const Component> containingComponent,\n        QSharedPointer<MemoryItem> mapItem, quint64 mapBaseAddress);\n\n    /*!\n     *  Write the register cluster.\n     *\n     *    @param [in] writer                  The xml stream writer.\n     *    @param [in] containingBlock         The address block containing the registers.\n     *    @param [in] blockItem               The selected address block item.\n     *    @param [in] addressOffsetInHexa     Offset of the address block in hex format.  \n     */\n    void writeRegisterCluster(QXmlStreamWriter& writer, QSharedPointer<AddressBlock> containingBlock,\n        QSharedPointer<MemoryItem> blockItem, QString const& addressOffsetInHexa);\n\n    /*!\n     *  Write the selected register elements.\n     *\n     *    @param [in] writer             The xml stream writer.\n     *    @param [in] registerItem       The selected register item.\n     *    @param [in] realRegister       The selected IP-XACT register.\n     */\n    void writeRegister(QXmlStreamWriter& writer, QSharedPointer<MemoryItem> registerItem,\n        QSharedPointer<Register> realRegister);\n\n    /*!\n     * Write the selected reset element.\n     *\n     *    @param [in] writer       The xml stream writer.\n     *    @param [in] resetItem    The selecter reset item.\n     */\n     void writeReset(QXmlStreamWriter& writer, QSharedPointer<MemoryItem> resetItem) const;\n\n    /*!\n     *  Get the field items of the selected register item in ascending offset order.\n     *\n     *    @param [in] registerItem    The selected register item.\n     *    @param [in] registerOffset  Offset of the register.\n     *\n     *    @return Field items of the selected register item in ascending offset order.\n     */\n    QMap<quint64, QSharedPointer<MemoryItem> > getFieldItemsInOrder(QSharedPointer<MemoryItem> registerItem,\n        quint64 const& registerOffset);\n\n    /*!\n     *  Get the first reset item of the selected memory item.\n     *\n     *    @param [in] registerItem    The selected memory item.\n     *\n     *    @return The first reset item of the selected memory item.\n     */\n    QSharedPointer<MemoryItem> getResetItem(QSharedPointer<MemoryItem> registerItem) const;\n\n    /*!\n     *  Write the fields of the selected register.\n     *\n     *    @param [in] writer              The xml stream writer.\n     *    @param [in] containingRegister  The selected register.\n     *    @param [in] fieldItems          Ordered field items.\n     */\n    void writeFields(QXmlStreamWriter& writer, QSharedPointer<Register> containingRegister,\n        QMap<quint64, QSharedPointer<MemoryItem> > fieldItems);\n\n    /*!\n     *  Write the enumerated values of the selected field.\n     *\n     *    @param [in] writer              The xml stream writer.\n     *    @param [in] containingField     The selected field.\n     *    @param [in] fieldItem           The selected field item.\n     */\n    void writeEnumeratedValues(QXmlStreamWriter& writer, QSharedPointer<Field> containingField,\n        QSharedPointer<MemoryItem> fieldItem);\n\n    /*!\n     *  Get the selected memory map.\n     *\n     *    @param [in] interfaceMemory         Memory item of the selected memory map.\n     *    @param [in] containingComponent     Component containing the memory map.\n     *\n     *    @return Memory map of the selected memory map item.\n     */\n    QSharedPointer<MemoryMap> getMemoryMap(QSharedPointer<MemoryItem> interfaceMemory,\n        QSharedPointer<const Component> containingComponent) const;\n\n    /*!\n     *  Get the selected address block.\n     *\n     *    @param [in] containingComponent     Component containing the address block.\n     *    @param [in] mapItem                 Memory item of the containing memory map.\n     *    @param [in] blockItem               Memory item of the selected address block.\n     *\n     *    @return Address block of the selected address block item.\n     */\n    QSharedPointer<AddressBlock> getAddressBlock(QSharedPointer<const Component> containingComponent,\n        QSharedPointer<MemoryItem> mapItem, QSharedPointer<MemoryItem> blockItem) const;\n\n    /*!\n     *  Get the selected register.\n     *\n     *    @param [in] containingBlock     Memory item of the containing address block.\n     *    @param [in] registerItem        Memory item of the selected register.\n     *\n     *    @return Register of the selected register item.\n     */\n    QSharedPointer<Register> getRegister(QSharedPointer<AddressBlock> containingBlock,\n        QSharedPointer<MemoryItem> registerItem) const;\n\n    /*!\n     *  Get the selected field.\n     *\n     *    @param [in] containingRegister  Memory item of the containing register.\n     *    @param [in] fieldItem           Memory item of the selected field.\n     *\n     *    @return Field of the selected field item.\n     */\n    QSharedPointer<Field> getField(QSharedPointer<Register> containingRegister,\n        QSharedPointer<MemoryItem> fieldItem) const;\n\n    /*!\n     *  Get the start of the selected field.\n     *\n     *    @param [in] fieldItem       The selected field item.\n     *    @param [in] registerOffset  Offset of the containing register.\n     *\n     *    @return Start of the selected field.\n     */\n    quint64 getFieldStart(QSharedPointer<MemoryItem> fieldItem, quint64 registerOffset);\n\n    /*!\n     *  Get the end of the selected field.\n     *\n     *    @param [in] fieldItem       The selected field item.\n     *    @param [in] registerOffset  Offset of the containing register.\n     *\n     *    @return End of the selected field.\n     */\n    quint64 getFieldEnd(QSharedPointer<MemoryItem> fieldItem, quint64 fieldOffset);\n\n    /*!\n     *  Get the selected enumerated value.\n     *\n     *    @param [in] containingField     Memory item of the containing field.\n     *    @param [in] enumeratedItem      Memory item of the selected enumerated value.\n     *\n     *    @return Enumerated value of the selected enumerated value item.\n     */\n    QSharedPointer<EnumeratedValue> getEnumeratedValue(QSharedPointer<Field> containingField,\n        QSharedPointer<MemoryItem> enumeratedItem) const;\n\n    /*!\n     *  Change the selected value to hex format.\n     *\n     *    @param [in] value   The selected value.\n     *\n     *    @return The selected value in hex format.\n     */\n    QString valueToHexa(quint64 const& value) const;\n\n    /*!\n     *  Write an optional the text element.\n     *\n     *    @param [in] writer          The xml stream writer.\n     *    @param [in] elementName     Name of the element.\n     *    @param [in] elementValue    Value of the element.\n     */\n    void writeOptionalElement(QXmlStreamWriter& writer, QString const& elementName, QString const& elementValue);\n\n    /*!\n     *  Check for errors in the interface data of the selected file.\n     *\n     *    @param [in] fileName                Name of the selected file.\n     *    @param [in] comparisonInterface     The interface compared to.\n     *    @param [in] cpuRoutes               List of the routes in the selected file.\n     */\n    void checkForErrorsInAddressSpaceData(QString const& fileName, QSharedPointer<const ConnectivityInterface> comparisonInterface,\n        QVector<QSharedPointer<CpuRouteStructs::CpuRoute> > cpuRoutes);\n\n    //-----------------------------------------------------------------------------\n    // Data.\n    //-----------------------------------------------------------------------------\n\n    //! The plugin utility interface.\n    IPluginUtility* utility_;\n\n    //! The available IP-XACT library.\n    LibraryInterface* library_;\n\n    //! Factory for creating connectivity graphs.\n    ConnectivityGraphFactory graphFactory_;\n\n    //! Paths to the generated files.\n    QStringList generatedFiles_;\n};\n\n#endif // SVDGENERATOR_H\n"
  },
  {
    "path": "Plugins/SVDGenerator/SVDGenerator.qrc",
    "content": "<RCC>\n    <qresource prefix=\"/icons\">\n        <file>SVDGenerator.png</file>\n    </qresource>\n</RCC>\n"
  },
  {
    "path": "Plugins/SVDGenerator/SVDGeneratorPlugin.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: SVDGeneratorPlugin.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Mikko Teuho\n// Date: 14.04.2021\n//\n// Description:\n// Plugin for creating a CMSIS System View Description listing.\n//-----------------------------------------------------------------------------\n\n#include \"SVDGeneratorPlugin.h\"\n#include \"SVDGenerator.h\"\n\n#include <IPXACTmodels/Component/Component.h>\n#include <IPXACTmodels/Component/File.h>\n#include <IPXACTmodels/Component/FileSet.h>\n\n#include <KactusAPI/include/IPluginUtility.h>\n#include <KactusAPI/include/LibraryInterface.h>\n\n#include <Plugins/common/HDLParser/HDLParserCommon.h>\n#include <Plugins/common/ConnectivityGraphUtilities.h>\n#include <Plugins/common/CPUDialog/CPUSelectionDialog.h>\n#include <Plugins/PluginSystem/GeneratorPlugin/GenerationControl.h>\n#include <Plugins/PluginSystem/GeneratorPlugin/MessagePasser.h>\n#include <Plugins/SVDGenerator/CPUDialog/SVDCPUEditor.h>\n#include <Plugins/SVDGenerator/CPUDialog/SVDCpuRoutesContainer.h>\n#include <Plugins/SVDGenerator/SVDConfigurationManager.h>\n#include <Plugins/SVDGenerator/CPUDialog/SVDUtilities.h>\n\n#include <editors/MemoryDesigner/ConnectivityGraphFactory.h>\n#include <editors/MemoryDesigner/MasterSlavePathSearch.h>\n\n#include <QDateTime>\n#include <QFileDialog>\n\n//----------------------------------------------------------------------------\n// Function: SVDGeneratorPlugin::SVDGeneratorPlugin()\n//-----------------------------------------------------------------------------\nSVDGeneratorPlugin::SVDGeneratorPlugin(): QObject(0)\n{\n}\n\n//-----------------------------------------------------------------------------\n// Function: SVDGeneratorPlugin::getName()\n//-----------------------------------------------------------------------------\nQString SVDGeneratorPlugin::getName() const\n{\n    return tr(\"SVD Generator\");\n}\n\n//-----------------------------------------------------------------------------\n// Function: SVDGeneratorPlugin::getVersion()\n//-----------------------------------------------------------------------------\nQString SVDGeneratorPlugin::getVersion() const\n{\n    return \"0.2\";\n}\n\n//-----------------------------------------------------------------------------\n// Function: SVDGeneratorPlugin::getDescription()\n//-----------------------------------------------------------------------------\nQString SVDGeneratorPlugin::getDescription() const\n{\n    return tr(\"Creates a CMSIS System View Description.\");\n}\n\n//-----------------------------------------------------------------------------\n// Function: SVDGeneratorPlugin::getVendor()\n//-----------------------------------------------------------------------------\nQString SVDGeneratorPlugin::getVendor() const\n{\n    return tr(\"Tampere University (tuni.fi)\");\n}\n\n//-----------------------------------------------------------------------------\n// Function: SVDGeneratorPlugin::getLicense()\n//-----------------------------------------------------------------------------\nQString SVDGeneratorPlugin::getLicense() const\n{\n    return tr(\"GPL2\");\n}\n\n//-----------------------------------------------------------------------------\n// Function: VerilogGeneratorPlugin::getLicenseHolder()\n//-----------------------------------------------------------------------------\nQString SVDGeneratorPlugin::getLicenseHolder() const\n{\n    return tr(\"Public\");\n}\n\n//-----------------------------------------------------------------------------\n// Function: SVDGeneratorPlugin::getSettingsWidget()\n//-----------------------------------------------------------------------------\nQWidget* SVDGeneratorPlugin::getSettingsWidget()\n{\n    return nullptr;\n}\n\n//-----------------------------------------------------------------------------\n// Function: SVDGeneratorPlugin::getSettingsModel()\n//-----------------------------------------------------------------------------\nPluginSettingsModel* SVDGeneratorPlugin::getSettingsModel()\n{\n    return nullptr;\n}\n\n//-----------------------------------------------------------------------------\n// Function: SVDGeneratorPlugin::getProgramRequirements()\n//-----------------------------------------------------------------------------\nQList<IPlugin::ExternalProgramRequirement> SVDGeneratorPlugin::getProgramRequirements()\n{\n    return QList<IPlugin::ExternalProgramRequirement>();\n}\n\n//-----------------------------------------------------------------------------\n// Function: SVDGeneratorPlugin::getIcon()\n//-----------------------------------------------------------------------------\nQIcon SVDGeneratorPlugin::getIcon() const\n{\n    return QIcon(\":icons/SVDGenerator.png\");\n}\n\n//-----------------------------------------------------------------------------\n// Function: SVDGeneratorPlugin::checkGeneratorSupport()\n//-----------------------------------------------------------------------------\nbool SVDGeneratorPlugin::checkGeneratorSupport(QSharedPointer<Component const> component,\n    QSharedPointer<Design const> design,\n    QSharedPointer<DesignConfiguration const> designConfiguration) const\n{\n    if (!component || component->getImplementation() != KactusAttribute::HW)\n    {\n        return false;\n    }\n\n    return design || designConfiguration;\n}\n\n//-----------------------------------------------------------------------------\n// Function: SVDGeneratorPlugin::runGenerator()\n//-----------------------------------------------------------------------------\nvoid SVDGeneratorPlugin::runGenerator(IPluginUtility* utility, QSharedPointer<Component> component,\n    QSharedPointer<Design> design, QSharedPointer<DesignConfiguration> designConfiguration)\n{\n    utility->printInfo(tr(\"Running %1 %2.\").arg(getName(), getVersion()));\n\n    GenerationTuple controlTuple;\n    controlTuple.component = component;\n    controlTuple.design = design;\n    controlTuple.designConfiguration = designConfiguration;\n\n    QSharedPointer<QList<QSharedPointer<View> > > views = GenerationControl::findPossibleViews(controlTuple);\n    QStringList viewNames;\n    for (auto view : *views)\n    {\n        viewNames.append(view->name());\n    }\n\n    SVDConfigurationManager* configManager(new SVDConfigurationManager(utility));\n    QJsonObject configurationObject = configManager->getConfigurationObject(component);\n\n    QString configurationFolderPath = configurationObject.value(SVDConstants::FOLDERPATH).toString(\"\");\n    QString configurationView = configurationObject.value(SVDConstants::VIEW).toString(\"\");\n    QString configurationFileSet = configurationObject.value(SVDConstants::FILESET).toString(\"\");\n    bool saveToFileSetFlag = configurationObject.value(SVDConstants::SAVETOFILESET).toBool(true);\n\n    SVDCPUEditor* cpuEditor(new SVDCPUEditor(configurationObject));\n\n    CPUSelectionDialog selectionDialog(component, utility->getLibraryInterface(), viewNames,\n        component->getFileSetNames(), cpuEditor, \"SVD\", nullptr, utility->getParentWidget(),\n        840, configurationFolderPath, saveToFileSetFlag, configurationFileSet,\n        configurationView);\n    if (selectionDialog.exec() == QDialog::Accepted)\n    {\n        QVector<QSharedPointer<CpuRoutesContainer> > cpuRoutes = selectionDialog.getSelectedCPUs();\n        if (!cpuRoutes.isEmpty())\n        {\n            QVector<QSharedPointer<SVDCpuRoutesContainer> > svdCPURoutes;\n            for (auto cpu : cpuRoutes)\n            {\n                QSharedPointer<SVDCpuRoutesContainer> svdCPU = cpu.dynamicCast<SVDCpuRoutesContainer>();\n                if (svdCPU)\n                {\n                    svdCPURoutes.append(svdCPU);\n                }\n            }\n\n            if (!svdCPURoutes.isEmpty())\n            {\n                QString selectedView = selectionDialog.getView();\n                bool saveToFileSet = selectionDialog.saveToFileSet();\n                QString selectedFileSet = selectionDialog.getTargetFileSet();\n                QString xmlFilePath = selectionDialog.getTargetFolder();\n\n                SVDGenerator generator(utility);\n                generator.generate(component, xmlFilePath, svdCPURoutes);\n\n                configManager->createConfigureFile(svdCPURoutes, component,\n                    selectedView, saveToFileSet, selectedFileSet, xmlFilePath);\n\n                if (selectionDialog.saveToFileSet())\n                {\n                    QString fileSetName = selectionDialog.getTargetFileSet();\n                    if (!fileSetName.isEmpty())\n                    {\n                        QStringList generatedFiles = generator.getGeneratedFiles();\n                        saveToFileset(utility, generatedFiles, component, fileSetName);\n                    }\n                }\n\n                utility->printInfo(tr(\"Generation complete.\"));\n            }\n        }\n        else\n        {\n            utility->printError(tr(\"Could not find CPU routes\"));\n        }\n    }\n    else\n    {\n        utility->printInfo(tr(\"Generation aborted.\"));\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: SVDGeneratorPlugin::runGenerator()\n//-----------------------------------------------------------------------------\nvoid SVDGeneratorPlugin::runGenerator(IPluginUtility* utility, QSharedPointer<Component> component, QSharedPointer<Design> design, QSharedPointer<DesignConfiguration> designConfiguration, QString const& viewName, QString const& outputDirectory)\n{\n    utility->printInfo(tr(\"Running %1 %2.\").arg(getName(), getVersion()));\n    utility->printInfo(tr(\"Running generation for %1 and view '%2'.\").arg(component->getVlnv().toString(),\n        viewName));\n\n    QDir targetDirectory;\n    if (!targetDirectory.mkpath(outputDirectory))\n    {\n        utility->printError(tr(\"Could not create target directory: %1\").arg(outputDirectory));\n        return;\n    }\n\n    utility->printInfo(tr(\"Target directory: %1\").arg(outputDirectory));\n\n\n    MessagePasser messages;\n\n    GenerationTuple input;\n    input.component = component;\n    input.design = design;\n    input.designConfiguration = designConfiguration;\n    input.messages = &messages;\n\n    LibraryInterface* utilityLibrary = utility->getLibraryInterface();\n\n    QVector<QSharedPointer<SVDCpuRoutesContainer> > svdCPUs;\n    for (auto defaultCPU : ConnectivityGraphUtilities::getDefaultCPUs(utilityLibrary, component, viewName))\n    {\n        QSharedPointer<SVDCpuRoutesContainer> newCPU(new SVDCpuRoutesContainer(*defaultCPU.data()));\n        svdCPUs.append(newCPU);\n    }\n\n    if (svdCPUs.isEmpty())\n    {\n        utility->printInfo(tr(\"Generation Failed. No CPUs found.\"));\n    }\n\n    SVDGenerator generator(utility);\n    generator.generate(component, outputDirectory, svdCPUs);\n\n    utility->printInfo(tr(\"Generation complete.\"));\n}\n\n//-----------------------------------------------------------------------------\n// Function: SVDGeneratorPlugin::getOutputFormat()\n//-----------------------------------------------------------------------------\nQString SVDGeneratorPlugin::getOutputFormat() const\n{\n    return QStringLiteral(\"SVD\");\n}\n\n//-----------------------------------------------------------------------------\n// Function: SVDGeneratorPlugin::saveToFileset()\n//-----------------------------------------------------------------------------\nvoid SVDGeneratorPlugin::saveToFileset(IPluginUtility* utility, QStringList const& svdFiles,\n    QSharedPointer<Component> component, QString const& fileSetName)\n{\n    if (svdFiles.isEmpty())\n    {\n        return;\n    }\n\n    QString xmlFilePath = utility->getLibraryInterface()->getDirectoryPath(component->getVlnv());\n    QSharedPointer<FileSet> targetFileset = component->getFileSet(fileSetName);\n    if (!targetFileset)\n    {\n        targetFileset = QSharedPointer<FileSet>(new FileSet(fileSetName));\n        component->getFileSets()->append(targetFileset);\n    }\n\n    for (auto fileName : svdFiles)\n    {\n        QString relativeFilePath = General::getRelativePath(xmlFilePath, fileName);\n\n        QSharedPointer<File> file;\n        foreach(QSharedPointer<File> filesetFile, *targetFileset->getFiles())\n        {\n            if (filesetFile->name().compare(relativeFilePath) == 0)\n            {\n                file = filesetFile;\n            }\n        }\n\n        if (!file)\n        {\n            file = QSharedPointer<File>(new File(relativeFilePath));\n            file->getFileTypes()->append(FileType(QStringLiteral(\"svd\")));\n\n            targetFileset->addFile(file);\n            utility->printInfo(tr(\"Added file %1 to top component file set %2.\").arg(fileName, fileSetName));\n        }\n\n        file->setDescription(tr(\"Generated on %1 by Kactus2 %2 plugin version %3.\").arg(\n            QDateTime::currentDateTime().toString(\"dd.MM.yyyy hh:mm:ss\"), getName(), getVersion()));\n    }\n\n\n    utility->getLibraryInterface()->writeModelToFile(component);\n}\n"
  },
  {
    "path": "Plugins/SVDGenerator/SVDGeneratorPlugin.h",
    "content": "//-----------------------------------------------------------------------------\n// File: SVDGeneratorPlugin.h\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Mikko Teuho\n// Date: 14.04.2021\n//\n// Description:\n// Plugin for creating a CMSIS System View Description listing.\n//-----------------------------------------------------------------------------\n\n#ifndef SVDGENERATORPLUGIN_H\n#define SVDGENERATORPLUGIN_H\n\n#include \"svdgeneratorplugin_global.h\"\n\n#include <KactusAPI/include/CLIGenerator.h>\n#include <KactusAPI/include/IPlugin.h>\n#include <KactusAPI/include/IGeneratorPlugin.h>\n\n//-----------------------------------------------------------------------------\n//! Plugin for creating a CMSIS System View Description listing.\n//-----------------------------------------------------------------------------\nclass SVDGENERATORPLUGIN_EXPORT SVDGeneratorPlugin : public QObject, public IGeneratorPlugin, public CLIGenerator\n{\n    Q_OBJECT\n    Q_PLUGIN_METADATA(IID \"kactus2.plugins.svdgeneratorplugin\" FILE \"svdgeneratorplugin.json\")\n\n    Q_INTERFACES(IPlugin)\n    Q_INTERFACES(IGeneratorPlugin)\n\npublic:\n\n\t/*!\n     *  The constructor.\n     */\n\tSVDGeneratorPlugin();\n\n\t/*!\n     *  The destructor.\n     */\n    virtual ~SVDGeneratorPlugin() = default;\n\n    /*!\n     *  Returns the name of the plugin.\n     */\n    virtual QString getName() const;\n\n    /*!\n     *  Returns the version of the plugin.\n     */\n    virtual QString getVersion() const;\n\n    /*!\n     *  Returns the description of the plugin.\n     */\n    virtual QString getDescription() const;\n\n    /*!\n     *  Returns the vendor of the plugin.\n     */\n    virtual QString getVendor() const;\n\n    /*!\n     *  Returns the license of the plugin.\n     */\n    virtual QString getLicense() const;\n\n    /*!\n     *  Returns the license holder of the plugin.\n     */\n    virtual QString getLicenseHolder() const;\n    \n    /*!\n     *  Returns the settings widget.\n     */\n    virtual QWidget* getSettingsWidget();\n\n    /*!\n     *  This is used to access the settings modified by function getSettingsWidget().\n     */\n    virtual PluginSettingsModel* getSettingsModel();\n\n    /*!\n     *  Returns the external program requirements of the plugin.\n     */\n    virtual QList<ExternalProgramRequirement> getProgramRequirements();\n\n    /*!\n     *  Returns the icon for the generator.\n     */\n    virtual QIcon getIcon() const;\n    \n    /*!\n     *  Checks whether the generator may run for the given component or design. \n     *\n     *    @param [in] component\t        The component for which to check support. If design is not null, component\n\t *                                      will refer to design or designConfiguration.\n     *    @param [in] design\t            The design, if the generator is ran for a design.\n     *    @param [in] designConfiguration The design configuration for design, if it is not null.\n     *\n     *    @return True, if the generator may run the given component. Otherwise false.\n     */\n    virtual bool checkGeneratorSupport(QSharedPointer<Component const> component,\n        QSharedPointer<Design const> design, QSharedPointer<DesignConfiguration const> designConfiguration) const;\n\n    /*!\n     *  Runs the generation, creating new files and/or modifying the IP-XACT metadata. The function has\n\t *  also access to the parent window widget, so that it can show dialogs for the user to aid the generation.\n     *\n     *    @param [in] utility\t\t\t    The plugin utility interface.\n     *    @param [in] component\t        The component for which to check support. If design is not null, component\n     *                                      will refer to design or designConfiguration.\n     *    @param [in] design\t            The design, if the generator is ran for a design.\n     *    @param [in] designConfiguration The design configuration for design, if it is not null.\n     */\n    virtual void runGenerator(IPluginUtility* utility, QSharedPointer<Component> component,\n        QSharedPointer<Design> design, QSharedPointer<DesignConfiguration> designConfiguration);\n\n    /*!\n     * Runs the generation.\n     *\n     *    @param [in] utility              Utilities for enabling plugin execution.\n     *    @param [in] component            The component to run the generation for.\n     *    @param [in] design               The design to run the generation for.\n     *    @param [in] designConfiguration  The design configuration to run the generation for.\n     *    @param [in] viewName             The component view name to run the generation for.\n     *    @param [in] outputDirectory      The output directory for the generation results.\n     */\n    virtual void runGenerator(IPluginUtility* utility,\n        QSharedPointer<Component> component,\n        QSharedPointer<Design> design,\n        QSharedPointer<DesignConfiguration> designConfiguration,\n        QString const& viewName,\n        QString const& outputDirectory) override final;\n\n    /*!\n     *  Gets the output format generated by the plugin.\n     *\n     *    @return The output file format generated by the plugin.\n     */\n    virtual QString getOutputFormat() const;\n\nprivate:\n\t// Disable copying.\n\tSVDGeneratorPlugin(SVDGeneratorPlugin const& rhs);\n    SVDGeneratorPlugin& operator=(SVDGeneratorPlugin const& rhs);\n\n    /*!\n     *  Saves the generated file to the selected file set of the top component.\n     *\n     *    @param [in] utility         The plugin utility interface.\n     *    @param [in] svdFiles        The generated file paths.\n     *    @param [in] component       The top level component.\n     *    @param [in] fileSetName     Name of the target file set.\n     */\n    void saveToFileset(IPluginUtility* utility, QStringList const& svdFiles, QSharedPointer<Component> component,\n        QString const& fileSetName);\n\n    //-----------------------------------------------------------------------------\n    // Data.\n    //-----------------------------------------------------------------------------\n\n};\n\n#endif // SVDGENERATORPLUGIN_H"
  },
  {
    "path": "Plugins/SVDGenerator/SVDGeneratorPlugin.pri",
    "content": "# ----------------------------------------------------\n# This file is generated by the Qt Visual Studio Tools.\n# ------------------------------------------------------\n\n# This is a reminder that you are using a generated .pro file.\n# Remove it when you are finished editing this file.\nmessage(\"You are running qmake on a generated .pro file. This may not work!\")\n\n\nHEADERS += ./SVDConfigurationManager.h \\\n    ./SVDGenerator.h \\\n    ./SVDGeneratorPlugin.h \\\n    ../PluginSystem/GeneratorPlugin/GenerationControl.h \\\n    ../PluginSystem/GeneratorPlugin/OutputControl.h \\\n    ../PluginSystem/GeneratorPlugin/ViewSelection.h \\\n    ../PluginSystem/GeneratorPlugin/MessagePasser.h \\\n    ../common/HDLParser/MetaComponent.h \\\n    ../common/HDLParser/MetaDesign.h \\\n    ../common/HDLParser/MetaInstance.h \\\n    ../../editors/MemoryDesigner/ConnectivityComponent.h \\\n    ../../editors/MemoryDesigner/ConnectivityConnection.h \\\n    ../../editors/MemoryDesigner/ConnectivityGraph.h \\\n    ../../editors/MemoryDesigner/ConnectivityGraphFactory.h \\\n    ../../editors/MemoryDesigner/ConnectivityInterface.h \\\n    ../../editors/MemoryDesigner/MasterSlavePathSearch.h \\\n    ../../editors/MemoryDesigner/MemoryConnectionAddressCalculator.h \\\n    ../../editors/MemoryDesigner/MemoryDesignerConstants.h \\\n    ../../editors/MemoryDesigner/MemoryItem.h \\\n    ../../IPXACTmodels/utilities/ComponentSearch.h \\\n    ./CPUDialog/SVDCPUColumns.h \\\n    ./CPUDialog/SVDCpuRoutesContainer.h \\\n    ./CPUDialog/SVDUtilities.h \\\n    ../common/CPUDialog/CPUEditor.h \\\n    ../common/CPUDialog/CPUSelectionDialog.h \\\n    ./CPUDialog/SVDCPUEditor.h \\\n    ./CPUDialog/SVDCPUModel.h \\\n    ./CPUDialog/SVDCPUDelegate.h \\\n    ../common/ConfigurationManager.h \\\n    ../common/ConnectivityGraphUtilities.h \\\n    ../common/CpuRoutesContainer.h \\\n    ../common/PluginConfigurationManager.h \\\n    ../common/SingleCpuRoutesContainer.h\nSOURCES += ./SVDConfigurationManager.cpp \\\n    ./SVDGenerator.cpp \\\n    ./SVDGeneratorPlugin.cpp \\\n    ../PluginSystem/GeneratorPlugin/GenerationControl.cpp \\\n    ../PluginSystem/GeneratorPlugin/MessagePasser.cpp \\\n    ../PluginSystem/GeneratorPlugin/OutputControl.cpp \\\n    ../PluginSystem/GeneratorPlugin/ViewSelection.cpp \\\n    ../common/HDLParser/MetaComponent.cpp \\\n    ../common/HDLParser/MetaDesign.cpp \\\n    ../common/HDLParser/MetaInstance.cpp \\\n    ../../editors/MemoryDesigner/ConnectivityComponent.cpp \\\n    ../../editors/MemoryDesigner/ConnectivityConnection.cpp \\\n    ../../editors/MemoryDesigner/ConnectivityGraph.cpp \\\n    ../../editors/MemoryDesigner/ConnectivityGraphFactory.cpp \\\n    ../../editors/MemoryDesigner/ConnectivityInterface.cpp \\\n    ../../editors/MemoryDesigner/MasterSlavePathSearch.cpp \\\n    ../../editors/MemoryDesigner/MemoryConnectionAddressCalculator.cpp \\\n    ../../editors/MemoryDesigner/MemoryDesignerConstants.cpp \\\n    ../../editors/MemoryDesigner/MemoryItem.cpp \\\n    ../../IPXACTmodels/utilities/ComponentSearch.cpp \\\n    ../common/CPUDialog/CPUEditor.cpp \\\n    ../common/CPUDialog/CPUSelectionDialog.cpp \\\n    ./CPUDialog/SVDCPUDelegate.cpp \\\n    ./CPUDialog/SVDCpuRoutesContainer.cpp \\\n    ./CPUDialog/SVDCPUEditor.cpp \\\n    ./CPUDialog/SVDCPUModel.cpp \\\n    ../common/ConfigurationManager.cpp \\\n    ../common/ConnectivityGraphUtilities.cpp \\\n    ../common/CpuRoutesContainer.cpp \\\n    ../common/PluginConfigurationManager.cpp \\\n    ../common/SingleCpuRoutesContainer.cpp\nRESOURCES += SVDGenerator.qrc\n"
  },
  {
    "path": "Plugins/SVDGenerator/SVDGeneratorPlugin.pro",
    "content": "# ----------------------------------------------------\n# This file is generated by the Qt Visual Studio Add-in.\n# ------------------------------------------------------\n\nTEMPLATE = lib\n\nQT += core xml widgets gui\nCONFIG += c++11\nDEFINES += SVDGENERATORPLUGIN_LIB\n\nINCLUDEPATH += ./GeneratedFiles \\\n    ./../.. \\\n    .\n\nCONFIG(debug, debug|release) {\n    # debug mode\n    LIBS += \\\n        -L../../executable -lIPXACTmodelsd \\\n        -L../../executable -lKactusAPId\n\n    MOC_DIR += ./GeneratedFiles/Debug\n    OBJECTS_DIR += Debug\n    TARGET = SVDGeneratorPlugind\n\n} else {\n    # release mode \n    LIBS += \\\n        -L../../executable -lIPXACTmodels \\\n        -L../../executable -lKactusAPI\n    \n    MOC_DIR += ./GeneratedFiles/Release\n    OBJECTS_DIR += Release\n    TARGET = SVDGeneratorPlugin\n}\n\nDESTDIR = ../../executable/Plugins\n\nDEPENDPATH += .\nUI_DIR += ./GeneratedFiles\nRCC_DIR += ./GeneratedFiles\n\ninclude(SVDGeneratorPlugin.pri)\n\ntarget.path = $$plugin_path\nINSTALLS += target\n"
  },
  {
    "path": "Plugins/SVDGenerator/SVDGeneratorPlugin.vcxproj",
    "content": "﻿<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<Project DefaultTargets=\"Build\" ToolsVersion=\"15.0\" xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">\n  <ItemGroup Label=\"ProjectConfigurations\">\n    <ProjectConfiguration Include=\"Debug|x64\">\n      <Configuration>Debug</Configuration>\n      <Platform>x64</Platform>\n    </ProjectConfiguration>\n    <ProjectConfiguration Include=\"Release|x64\">\n      <Configuration>Release</Configuration>\n      <Platform>x64</Platform>\n    </ProjectConfiguration>\n  </ItemGroup>\n  <PropertyGroup Label=\"Globals\">\n    <ProjectGuid>{81A006F2-4FC4-4187-93E9-98C5EB8523C3}</ProjectGuid>\n    <Keyword>QtVS_v304</Keyword>\n    <WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>\n    <QtMsBuild Condition=\"'$(QtMsBuild)'=='' or !Exists('$(QtMsBuild)\\qt.targets')\">$(MSBuildProjectDirectory)\\QtMsBuild</QtMsBuild>\n  </PropertyGroup>\n  <Import Project=\"$(VCTargetsPath)\\Microsoft.Cpp.Default.props\" />\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\" Label=\"Configuration\">\n    <ConfigurationType>DynamicLibrary</ConfigurationType>\n    <PlatformToolset>v143</PlatformToolset>\n  </PropertyGroup>\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\" Label=\"Configuration\">\n    <ConfigurationType>DynamicLibrary</ConfigurationType>\n    <PlatformToolset>v143</PlatformToolset>\n  </PropertyGroup>\n  <Import Project=\"$(VCTargetsPath)\\Microsoft.Cpp.props\" />\n  <Target Name=\"QtMsBuildNotFound\" BeforeTargets=\"CustomBuild;ClCompile\" Condition=\"!Exists('$(QtMsBuild)\\qt.targets') or !Exists('$(QtMsBuild)\\qt.props')\">\n    <Message Importance=\"High\" Text=\"QtMsBuild: could not locate qt.targets, qt.props; project may not build correctly.\" />\n  </Target>\n  <ImportGroup Label=\"ExtensionSettings\">\n  </ImportGroup>\n  <ImportGroup Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\" Label=\"PropertySheets\">\n    <Import Project=\"$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props\" Condition=\"exists('$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props')\" Label=\"LocalAppDataPlatform\" />\n  </ImportGroup>\n  <ImportGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\" Label=\"PropertySheets\">\n    <Import Project=\"$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props\" Condition=\"exists('$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props')\" Label=\"LocalAppDataPlatform\" />\n  </ImportGroup>\n  <PropertyGroup Label=\"UserMacros\" />\n  <ImportGroup Condition=\"Exists('$(QtMsBuild)\\qt_defaults.props')\">\n    <Import Project=\"$(QtMsBuild)\\qt_defaults.props\" />\n  </ImportGroup>\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\n    <OutDir>$(SolutionDir)executable\\Plugins\\</OutDir>\n  </PropertyGroup>\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\n    <OutDir>$(SolutionDir)executable\\Plugins\\</OutDir>\n    <TargetName>$(ProjectName)</TargetName>\n  </PropertyGroup>\n  <PropertyGroup Label=\"QtSettings\" Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\n    <QtInstall>6.2.4</QtInstall>\n    <QtModules>core;gui;widgets;xml</QtModules>\n  </PropertyGroup>\n  <PropertyGroup Label=\"QtSettings\" Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\n    <QtInstall>6.2.4</QtInstall>\n    <QtModules>core;gui;widgets;xml</QtModules>\n  </PropertyGroup>\n  <ImportGroup Condition=\"Exists('$(QtMsBuild)\\qt.props')\">\n    <Import Project=\"$(QtMsBuild)\\qt.props\" />\n  </ImportGroup>\n  <PropertyGroup>\n    <_ProjectFileVersion>10.0.40219.1</_ProjectFileVersion>\n  </PropertyGroup>\n  <ItemDefinitionGroup Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\n    <ClCompile>\n      <PreprocessorDefinitions>UNICODE;WIN32;WIN64;SVDGENERATORPLUGIN_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>\n      <AdditionalIncludeDirectories>.\\GeneratedFiles\\$(ConfigurationName);.\\GeneratedFiles;..\\..\\;.;$(SolutionDir)KactusAPI\\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\n      <Optimization>Disabled</Optimization>\n      <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>\n      <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>\n      <TreatWChar_tAsBuiltInType>true</TreatWChar_tAsBuiltInType>\n      <MultiProcessorCompilation>true</MultiProcessorCompilation>\n      <LanguageStandard>stdcpp17</LanguageStandard>\n      <AdditionalOptions>/Zc:__cplusplus %(AdditionalOptions)</AdditionalOptions>\n    </ClCompile>\n    <Link>\n      <SubSystem>Windows</SubSystem>\n      <OutputFile>$(OutDir)\\$(ProjectName).dll</OutputFile>\n      <AdditionalLibraryDirectories>..\\..\\executable;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>\n      <GenerateDebugInformation>true</GenerateDebugInformation>\n      <AdditionalDependencies>IPXACTmodelsd.lib;KactusAPId.lib;%(AdditionalDependencies)</AdditionalDependencies>\n    </Link>\n    <QtMoc>\n      <ExecutionDescription>Moc'ing %(Identity)...</ExecutionDescription>\n      <DynamicSource>output</DynamicSource>\n      <QtMocDir>.\\GeneratedFiles\\$(ConfigurationName)</QtMocDir>\n      <QtMocFileName>moc_%(Filename).cpp</QtMocFileName>\n    </QtMoc>\n    <QtRcc>\n      <InitFuncName>%(Filename)</InitFuncName>\n      <Compression>default</Compression>\n      <NoCompression>true</NoCompression>\n      <ExecutionDescription>Rcc'ing %(Identity)...</ExecutionDescription>\n      <QtRccDir>.\\GeneratedFiles</QtRccDir>\n      <QtRccFileName>qrc_%(Filename).cpp</QtRccFileName>\n    </QtRcc>\n  </ItemDefinitionGroup>\n  <ItemDefinitionGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\n    <ClCompile>\n      <PreprocessorDefinitions>UNICODE;WIN32;WIN64;QT_NO_DEBUG;NDEBUG;SVDGENERATORPLUGIN_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>\n      <AdditionalIncludeDirectories>.\\GeneratedFiles\\$(ConfigurationName);.\\GeneratedFiles;..\\..;.;$(SolutionDir)KactusAPI\\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\n      <DebugInformationFormat>\n      </DebugInformationFormat>\n      <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>\n      <TreatWChar_tAsBuiltInType>true</TreatWChar_tAsBuiltInType>\n      <MultiProcessorCompilation>true</MultiProcessorCompilation>\n      <AdditionalOptions>/Zc:__cplusplus %(AdditionalOptions)</AdditionalOptions>\n      <LanguageStandard>stdcpp17</LanguageStandard>\n    </ClCompile>\n    <Link>\n      <SubSystem>Windows</SubSystem>\n      <OutputFile>$(OutDir)$(ProjectName).dll</OutputFile>\n      <AdditionalLibraryDirectories>..\\..\\executable;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>\n      <GenerateDebugInformation>false</GenerateDebugInformation>\n      <AdditionalDependencies>IPXACTmodels.lib;KactusAPI.lib;%(AdditionalDependencies)</AdditionalDependencies>\n    </Link>\n    <QtMoc>\n      <ExecutionDescription>Moc'ing %(Identity)...</ExecutionDescription>\n      <DynamicSource>output</DynamicSource>\n      <QtMocDir>.\\GeneratedFiles\\$(ConfigurationName)</QtMocDir>\n      <QtMocFileName>moc_%(Filename).cpp</QtMocFileName>\n    </QtMoc>\n    <QtRcc>\n      <InitFuncName>%(Filename)</InitFuncName>\n      <Compression>default</Compression>\n      <NoCompression>true</NoCompression>\n      <ExecutionDescription>Rcc'ing %(Identity)...</ExecutionDescription>\n      <QtRccDir>.\\GeneratedFiles</QtRccDir>\n      <QtRccFileName>qrc_%(Filename).cpp</QtRccFileName>\n    </QtRcc>\n  </ItemDefinitionGroup>\n  <ItemGroup>\n    <ClCompile Include=\"..\\..\\editors\\MemoryDesigner\\ConnectivityComponent.cpp\" />\n    <ClCompile Include=\"..\\..\\editors\\MemoryDesigner\\ConnectivityConnection.cpp\" />\n    <ClCompile Include=\"..\\..\\editors\\MemoryDesigner\\ConnectivityGraph.cpp\" />\n    <ClCompile Include=\"..\\..\\editors\\MemoryDesigner\\ConnectivityGraphFactory.cpp\" />\n    <ClCompile Include=\"..\\..\\editors\\MemoryDesigner\\ConnectivityInterface.cpp\" />\n    <ClCompile Include=\"..\\..\\editors\\MemoryDesigner\\MasterSlavePathSearch.cpp\" />\n    <ClCompile Include=\"..\\..\\editors\\MemoryDesigner\\MemoryConnectionAddressCalculator.cpp\" />\n    <ClCompile Include=\"..\\..\\editors\\MemoryDesigner\\MemoryDesignerConstants.cpp\" />\n    <ClCompile Include=\"..\\..\\editors\\MemoryDesigner\\MemoryItem.cpp\" />\n    <ClCompile Include=\"..\\..\\IPXACTmodels\\utilities\\ComponentSearch.cpp\" />\n    <ClCompile Include=\"..\\common\\ConfigurationManager.cpp\" />\n    <ClCompile Include=\"..\\common\\ConnectivityGraphUtilities.cpp\" />\n    <ClCompile Include=\"..\\common\\CPUDialog\\CPUEditor.cpp\" />\n    <ClCompile Include=\"..\\common\\CPUDialog\\CPUSelectionDialog.cpp\" />\n    <ClCompile Include=\"..\\common\\CpuRoutesContainer.cpp\" />\n    <ClCompile Include=\"..\\common\\HDLParser\\MetaComponent.cpp\" />\n    <ClCompile Include=\"..\\common\\HDLParser\\MetaDesign.cpp\" />\n    <ClCompile Include=\"..\\common\\HDLParser\\MetaInstance.cpp\" />\n    <ClCompile Include=\"..\\common\\PluginConfigurationManager.cpp\" />\n    <ClCompile Include=\"..\\common\\SingleCpuRoutesContainer.cpp\" />\n    <ClCompile Include=\"..\\PluginSystem\\GeneratorPlugin\\GenerationControl.cpp\" />\n    <ClCompile Include=\"..\\PluginSystem\\GeneratorPlugin\\MessagePasser.cpp\" />\n    <ClCompile Include=\"..\\PluginSystem\\GeneratorPlugin\\OutputControl.cpp\" />\n    <ClCompile Include=\"..\\PluginSystem\\GeneratorPlugin\\ViewSelection.cpp\" />\n    <ClCompile Include=\"CPUDialog\\SVDCPUDelegate.cpp\" />\n    <ClCompile Include=\"CPUDialog\\SVDCPUEditor.cpp\" />\n    <ClCompile Include=\"CPUDialog\\SVDCPUModel.cpp\" />\n    <ClCompile Include=\"CPUDialog\\SVDCpuRoutesContainer.cpp\" />\n    <ClCompile Include=\"SVDConfigurationManager.cpp\" />\n    <ClCompile Include=\"SVDGenerator.cpp\" />\n    <ClCompile Include=\"SVDGeneratorPlugin.cpp\" />\n  </ItemGroup>\n  <ItemGroup>\n    <QtMoc Include=\"SVDGeneratorPlugin.h\">\n    </QtMoc>\n  </ItemGroup>\n  <ItemGroup>\n    <Image Include=\"SVDGenerator.png\">\n      <ExcludedFromBuild Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">true</ExcludedFromBuild>\n      <ExcludedFromBuild Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">true</ExcludedFromBuild>\n    </Image>\n  </ItemGroup>\n  <ItemGroup>\n    <QtRcc Include=\"SVDGenerator.qrc\">\n    </QtRcc>\n  </ItemGroup>\n  <ItemGroup>\n    <ClInclude Include=\"..\\..\\editors\\MemoryDesigner\\ConnectivityComponent.h\" />\n    <ClInclude Include=\"..\\..\\editors\\MemoryDesigner\\ConnectivityConnection.h\" />\n    <ClInclude Include=\"..\\..\\editors\\MemoryDesigner\\ConnectivityGraph.h\" />\n    <ClInclude Include=\"..\\..\\editors\\MemoryDesigner\\ConnectivityGraphFactory.h\" />\n    <ClInclude Include=\"..\\..\\editors\\MemoryDesigner\\ConnectivityInterface.h\" />\n    <ClInclude Include=\"..\\..\\editors\\MemoryDesigner\\MasterSlavePathSearch.h\" />\n    <ClInclude Include=\"..\\..\\editors\\MemoryDesigner\\MemoryConnectionAddressCalculator.h\" />\n    <ClInclude Include=\"..\\..\\editors\\MemoryDesigner\\MemoryDesignerConstants.h\" />\n    <ClInclude Include=\"..\\..\\editors\\MemoryDesigner\\MemoryItem.h\" />\n    <ClInclude Include=\"..\\..\\IPXACTmodels\\utilities\\ComponentSearch.h\" />\n    <ClInclude Include=\"..\\common\\ConfigurationManager.h\" />\n    <ClInclude Include=\"..\\common\\ConnectivityGraphUtilities.h\" />\n    <QtMoc Include=\"..\\common\\CPUDialog\\CPUEditor.h\" />\n    <QtMoc Include=\"..\\common\\CPUDialog\\CPUSelectionDialog.h\" />\n    <ClInclude Include=\"..\\common\\CpuRoutesContainer.h\" />\n    <ClInclude Include=\"..\\common\\HDLParser\\MetaComponent.h\" />\n    <ClInclude Include=\"..\\common\\HDLParser\\MetaDesign.h\" />\n    <ClInclude Include=\"..\\common\\HDLParser\\MetaInstance.h\" />\n    <ClInclude Include=\"..\\common\\PluginConfigurationManager.h\" />\n    <ClInclude Include=\"..\\common\\SingleCpuRoutesContainer.h\" />\n    <ClInclude Include=\"..\\PluginSystem\\GeneratorPlugin\\GenerationControl.h\" />\n    <QtMoc Include=\"..\\PluginSystem\\GeneratorPlugin\\MessagePasser.h\">\n    </QtMoc>\n    <ClInclude Include=\"..\\PluginSystem\\GeneratorPlugin\\OutputControl.h\" />\n    <ClInclude Include=\"..\\PluginSystem\\GeneratorPlugin\\ViewSelection.h\" />\n    <QtMoc Include=\"CPUDialog\\SVDCPUEditor.h\">\n    </QtMoc>\n    <QtMoc Include=\"CPUDialog\\SVDCPUModel.h\">\n    </QtMoc>\n    <ClInclude Include=\"CPUDialog\\SVDCPUColumns.h\" />\n    <QtMoc Include=\"CPUDialog\\SVDCPUDelegate.h\">\n    </QtMoc>\n    <ClInclude Include=\"CPUDialog\\SVDCpuRoutesContainer.h\" />\n    <ClInclude Include=\"CPUDialog\\SVDUtilities.h\" />\n    <ClInclude Include=\"SVDConfigurationManager.h\" />\n    <ClInclude Include=\"SVDGenerator.h\" />\n  </ItemGroup>\n  <Import Project=\"$(VCTargetsPath)\\Microsoft.Cpp.targets\" />\n  <ImportGroup Condition=\"Exists('$(QtMsBuild)\\qt.targets')\">\n    <Import Project=\"$(QtMsBuild)\\qt.targets\" />\n  </ImportGroup>\n  <ImportGroup Label=\"ExtensionTargets\">\n  </ImportGroup>\n  <ProjectExtensions>\n    <VisualStudio>\n      <UserProperties />\n    </VisualStudio>\n  </ProjectExtensions>\n</Project>"
  },
  {
    "path": "Plugins/SVDGenerator/SVDGeneratorPlugin.vcxproj.filters",
    "content": "﻿<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<Project ToolsVersion=\"4.0\" xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">\n  <ItemGroup>\n    <Filter Include=\"Source Files\">\n      <UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>\n      <Extensions>cpp;cxx;c;def</Extensions>\n    </Filter>\n    <Filter Include=\"Header Files\">\n      <UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>\n      <Extensions>h</Extensions>\n    </Filter>\n    <Filter Include=\"Generated Files\">\n      <UniqueIdentifier>{71ED8ED8-ACB9-4CE9-BBE1-E00B30144E11}</UniqueIdentifier>\n      <Extensions>moc;h;cpp</Extensions>\n      <SourceControlFiles>False</SourceControlFiles>\n    </Filter>\n    <Filter Include=\"Generated Files\\Debug\">\n      <UniqueIdentifier>{0dde34ad-54aa-4fc2-bbd2-8d5415f77af4}</UniqueIdentifier>\n      <Extensions>cpp;moc</Extensions>\n      <SourceControlFiles>False</SourceControlFiles>\n    </Filter>\n    <Filter Include=\"Generated Files\\Release\">\n      <UniqueIdentifier>{c8453e3e-ca63-45c5-a10f-423715481c0d}</UniqueIdentifier>\n      <Extensions>cpp;moc</Extensions>\n      <SourceControlFiles>False</SourceControlFiles>\n    </Filter>\n    <Filter Include=\"Resource Files\">\n      <UniqueIdentifier>{D9D6E242-F8AF-46E4-B9FD-80ECBC20BA3E}</UniqueIdentifier>\n      <Extensions>qrc;*</Extensions>\n      <ParseFiles>false</ParseFiles>\n    </Filter>\n    <Filter Include=\"Header Files\\GenerationControl\">\n      <UniqueIdentifier>{7009044a-86f3-4af6-bf37-2718bcc8c9d4}</UniqueIdentifier>\n    </Filter>\n    <Filter Include=\"Source Files\\GenerationControl\">\n      <UniqueIdentifier>{09c2593e-84c8-4829-84ba-ea995a46f97c}</UniqueIdentifier>\n    </Filter>\n    <Filter Include=\"Header Files\\Parsing\">\n      <UniqueIdentifier>{21a3e362-fae7-4c11-b06a-78360a46a713}</UniqueIdentifier>\n    </Filter>\n    <Filter Include=\"Source Files\\Parsing\">\n      <UniqueIdentifier>{d457893a-3fc6-4705-ad26-2411ca02bfb3}</UniqueIdentifier>\n    </Filter>\n    <Filter Include=\"Source Files\\Editors\">\n      <UniqueIdentifier>{8b7c8b51-97ee-4e83-bc23-6cbc7648e9dc}</UniqueIdentifier>\n    </Filter>\n    <Filter Include=\"Header Files\\Editors\">\n      <UniqueIdentifier>{ad685249-6c92-4ba6-a283-2dbb9b4844a8}</UniqueIdentifier>\n    </Filter>\n    <Filter Include=\"Header Files\\IPXACTModels\">\n      <UniqueIdentifier>{5f2340a1-6cb0-46cc-93bf-67124d1c2f7f}</UniqueIdentifier>\n    </Filter>\n    <Filter Include=\"Header Files\\IPXACTModels\\utilities\">\n      <UniqueIdentifier>{51de001f-37b7-4952-addf-629c03824504}</UniqueIdentifier>\n    </Filter>\n    <Filter Include=\"Source Files\\IPXACTModels\">\n      <UniqueIdentifier>{2971665b-6a04-407d-8318-6758c45d6da4}</UniqueIdentifier>\n    </Filter>\n    <Filter Include=\"Source Files\\IPXACTModels\\utilities\">\n      <UniqueIdentifier>{bf39ed15-309f-4b4c-8595-d1afb6ed401c}</UniqueIdentifier>\n    </Filter>\n    <Filter Include=\"Source Files\\Editors\\MemoryDesigner\">\n      <UniqueIdentifier>{5132b76e-10a7-494f-b1c3-ed8b39447b19}</UniqueIdentifier>\n    </Filter>\n    <Filter Include=\"Header Files\\Editors\\MemoryDesigner\">\n      <UniqueIdentifier>{c437154d-7686-4acf-b25f-b9ccbd0c3ed4}</UniqueIdentifier>\n    </Filter>\n    <Filter Include=\"Source Files\\CPUDialog\">\n      <UniqueIdentifier>{8b557752-6098-492e-aef8-0beab3b029d3}</UniqueIdentifier>\n    </Filter>\n    <Filter Include=\"Header Files\\CPUDialog\">\n      <UniqueIdentifier>{f9d45a70-c6c3-4863-8796-746a29d0c385}</UniqueIdentifier>\n    </Filter>\n    <Filter Include=\"Header Files\\common\">\n      <UniqueIdentifier>{dae175c4-e6e1-4f86-8a15-49bb5e9062b4}</UniqueIdentifier>\n    </Filter>\n    <Filter Include=\"Source Files\\common\">\n      <UniqueIdentifier>{d45be033-5577-4e31-bb23-12b0c19dcce5}</UniqueIdentifier>\n    </Filter>\n  </ItemGroup>\n  <ItemGroup>\n    <ClCompile Include=\"SVDGeneratorPlugin.cpp\">\n      <Filter>Source Files</Filter>\n    </ClCompile>\n    <ClCompile Include=\"SVDGenerator.cpp\">\n      <Filter>Source Files</Filter>\n    </ClCompile>\n    <ClCompile Include=\"..\\PluginSystem\\GeneratorPlugin\\GenerationControl.cpp\">\n      <Filter>Source Files\\GenerationControl</Filter>\n    </ClCompile>\n    <ClCompile Include=\"..\\PluginSystem\\GeneratorPlugin\\ViewSelection.cpp\">\n      <Filter>Source Files\\GenerationControl</Filter>\n    </ClCompile>\n    <ClCompile Include=\"..\\PluginSystem\\GeneratorPlugin\\OutputControl.cpp\">\n      <Filter>Source Files\\GenerationControl</Filter>\n    </ClCompile>\n    <ClCompile Include=\"..\\common\\HDLParser\\MetaComponent.cpp\">\n      <Filter>Source Files\\Parsing</Filter>\n    </ClCompile>\n    <ClCompile Include=\"..\\common\\HDLParser\\MetaDesign.cpp\">\n      <Filter>Source Files\\Parsing</Filter>\n    </ClCompile>\n    <ClCompile Include=\"..\\common\\HDLParser\\MetaInstance.cpp\">\n      <Filter>Source Files\\Parsing</Filter>\n    </ClCompile>\n    <ClCompile Include=\"..\\..\\IPXACTmodels\\utilities\\ComponentSearch.cpp\">\n      <Filter>Source Files\\IPXACTModels\\utilities</Filter>\n    </ClCompile>\n    <ClCompile Include=\"..\\..\\editors\\MemoryDesigner\\ConnectivityComponent.cpp\">\n      <Filter>Source Files\\Editors\\MemoryDesigner</Filter>\n    </ClCompile>\n    <ClCompile Include=\"..\\..\\editors\\MemoryDesigner\\ConnectivityConnection.cpp\">\n      <Filter>Source Files\\Editors\\MemoryDesigner</Filter>\n    </ClCompile>\n    <ClCompile Include=\"..\\..\\editors\\MemoryDesigner\\ConnectivityGraph.cpp\">\n      <Filter>Source Files\\Editors\\MemoryDesigner</Filter>\n    </ClCompile>\n    <ClCompile Include=\"..\\..\\editors\\MemoryDesigner\\ConnectivityGraphFactory.cpp\">\n      <Filter>Source Files\\Editors\\MemoryDesigner</Filter>\n    </ClCompile>\n    <ClCompile Include=\"..\\..\\editors\\MemoryDesigner\\ConnectivityInterface.cpp\">\n      <Filter>Source Files\\Editors\\MemoryDesigner</Filter>\n    </ClCompile>\n    <ClCompile Include=\"..\\..\\editors\\MemoryDesigner\\MasterSlavePathSearch.cpp\">\n      <Filter>Source Files\\Editors\\MemoryDesigner</Filter>\n    </ClCompile>\n    <ClCompile Include=\"..\\..\\editors\\MemoryDesigner\\MemoryItem.cpp\">\n      <Filter>Source Files\\Editors\\MemoryDesigner</Filter>\n    </ClCompile>\n    <ClCompile Include=\"..\\..\\editors\\MemoryDesigner\\MemoryDesignerConstants.cpp\">\n      <Filter>Source Files\\Editors\\MemoryDesigner</Filter>\n    </ClCompile>\n    <ClCompile Include=\"..\\..\\editors\\MemoryDesigner\\MemoryConnectionAddressCalculator.cpp\">\n      <Filter>Source Files\\Editors\\MemoryDesigner</Filter>\n    </ClCompile>\n    <ClCompile Include=\"CPUDialog\\SVDCPUEditor.cpp\">\n      <Filter>Source Files\\CPUDialog</Filter>\n    </ClCompile>\n    <ClCompile Include=\"CPUDialog\\SVDCPUModel.cpp\">\n      <Filter>Source Files\\CPUDialog</Filter>\n    </ClCompile>\n    <ClCompile Include=\"CPUDialog\\SVDCPUDelegate.cpp\">\n      <Filter>Source Files\\CPUDialog</Filter>\n    </ClCompile>\n    <ClCompile Include=\"..\\PluginSystem\\GeneratorPlugin\\MessagePasser.cpp\">\n      <Filter>Source Files\\GenerationControl</Filter>\n    </ClCompile>\n    <ClCompile Include=\"..\\common\\ConnectivityGraphUtilities.cpp\">\n      <Filter>Source Files\\common</Filter>\n    </ClCompile>\n    <ClCompile Include=\"..\\common\\CPUDialog\\CPUEditor.cpp\">\n      <Filter>Source Files\\CPUDialog</Filter>\n    </ClCompile>\n    <ClCompile Include=\"..\\common\\CPUDialog\\CPUSelectionDialog.cpp\">\n      <Filter>Source Files\\CPUDialog</Filter>\n    </ClCompile>\n    <ClCompile Include=\"SVDConfigurationManager.cpp\">\n      <Filter>Source Files</Filter>\n    </ClCompile>\n    <ClCompile Include=\"..\\common\\PluginConfigurationManager.cpp\">\n      <Filter>Source Files\\common</Filter>\n    </ClCompile>\n    <ClCompile Include=\"..\\common\\ConfigurationManager.cpp\">\n      <Filter>Source Files\\common</Filter>\n    </ClCompile>\n    <ClCompile Include=\"..\\common\\CpuRoutesContainer.cpp\">\n      <Filter>Source Files\\common</Filter>\n    </ClCompile>\n    <ClCompile Include=\"CPUDialog\\SVDCpuRoutesContainer.cpp\">\n      <Filter>Source Files\\CPUDialog</Filter>\n    </ClCompile>\n    <ClCompile Include=\"..\\common\\SingleCpuRoutesContainer.cpp\">\n      <Filter>Source Files\\common</Filter>\n    </ClCompile>\n  </ItemGroup>\n  <ItemGroup>\n    <QtMoc Include=\"SVDGeneratorPlugin.h\">\n      <Filter>Header Files</Filter>\n    </QtMoc>\n    <QtRcc Include=\"SVDGenerator.qrc\">\n      <Filter>Resource Files</Filter>\n    </QtRcc>\n    <QtMoc Include=\"CPUDialog\\SVDCPUEditor.h\">\n      <Filter>Header Files\\CPUDialog</Filter>\n    </QtMoc>\n    <QtMoc Include=\"CPUDialog\\SVDCPUModel.h\">\n      <Filter>Header Files\\CPUDialog</Filter>\n    </QtMoc>\n    <QtMoc Include=\"CPUDialog\\SVDCPUDelegate.h\">\n      <Filter>Header Files\\CPUDialog</Filter>\n    </QtMoc>\n    <QtMoc Include=\"..\\PluginSystem\\GeneratorPlugin\\MessagePasser.h\">\n      <Filter>Header Files\\GenerationControl</Filter>\n    </QtMoc>\n    <QtMoc Include=\"..\\common\\CPUDialog\\CPUEditor.h\">\n      <Filter>Header Files\\CPUDialog</Filter>\n    </QtMoc>\n    <QtMoc Include=\"..\\common\\CPUDialog\\CPUSelectionDialog.h\">\n      <Filter>Header Files\\CPUDialog</Filter>\n    </QtMoc>\n  </ItemGroup>\n  <ItemGroup>\n    <Image Include=\"SVDGenerator.png\">\n      <Filter>Resource Files</Filter>\n    </Image>\n  </ItemGroup>\n  <ItemGroup>\n    <ClInclude Include=\"SVDGenerator.h\">\n      <Filter>Header Files</Filter>\n    </ClInclude>\n    <ClInclude Include=\"..\\PluginSystem\\GeneratorPlugin\\GenerationControl.h\">\n      <Filter>Header Files\\GenerationControl</Filter>\n    </ClInclude>\n    <ClInclude Include=\"..\\PluginSystem\\GeneratorPlugin\\ViewSelection.h\">\n      <Filter>Header Files\\GenerationControl</Filter>\n    </ClInclude>\n    <ClInclude Include=\"..\\PluginSystem\\GeneratorPlugin\\OutputControl.h\">\n      <Filter>Header Files\\GenerationControl</Filter>\n    </ClInclude>\n    <ClInclude Include=\"..\\common\\HDLParser\\MetaComponent.h\">\n      <Filter>Header Files\\Parsing</Filter>\n    </ClInclude>\n    <ClInclude Include=\"..\\common\\HDLParser\\MetaDesign.h\">\n      <Filter>Header Files\\Parsing</Filter>\n    </ClInclude>\n    <ClInclude Include=\"..\\common\\HDLParser\\MetaInstance.h\">\n      <Filter>Header Files\\Parsing</Filter>\n    </ClInclude>\n    <ClInclude Include=\"..\\..\\IPXACTmodels\\utilities\\ComponentSearch.h\">\n      <Filter>Header Files\\IPXACTModels\\utilities</Filter>\n    </ClInclude>\n    <ClInclude Include=\"..\\..\\editors\\MemoryDesigner\\ConnectivityComponent.h\">\n      <Filter>Header Files\\Editors\\MemoryDesigner</Filter>\n    </ClInclude>\n    <ClInclude Include=\"..\\..\\editors\\MemoryDesigner\\ConnectivityConnection.h\">\n      <Filter>Header Files\\Editors\\MemoryDesigner</Filter>\n    </ClInclude>\n    <ClInclude Include=\"..\\..\\editors\\MemoryDesigner\\ConnectivityGraph.h\">\n      <Filter>Header Files\\Editors\\MemoryDesigner</Filter>\n    </ClInclude>\n    <ClInclude Include=\"..\\..\\editors\\MemoryDesigner\\ConnectivityGraphFactory.h\">\n      <Filter>Header Files\\Editors\\MemoryDesigner</Filter>\n    </ClInclude>\n    <ClInclude Include=\"..\\..\\editors\\MemoryDesigner\\ConnectivityInterface.h\">\n      <Filter>Header Files\\Editors\\MemoryDesigner</Filter>\n    </ClInclude>\n    <ClInclude Include=\"..\\..\\editors\\MemoryDesigner\\MasterSlavePathSearch.h\">\n      <Filter>Header Files\\Editors\\MemoryDesigner</Filter>\n    </ClInclude>\n    <ClInclude Include=\"..\\..\\editors\\MemoryDesigner\\MemoryItem.h\">\n      <Filter>Header Files\\Editors\\MemoryDesigner</Filter>\n    </ClInclude>\n    <ClInclude Include=\"..\\..\\editors\\MemoryDesigner\\MemoryDesignerConstants.h\">\n      <Filter>Header Files\\Editors\\MemoryDesigner</Filter>\n    </ClInclude>\n    <ClInclude Include=\"..\\..\\editors\\MemoryDesigner\\MemoryConnectionAddressCalculator.h\">\n      <Filter>Header Files\\Editors\\MemoryDesigner</Filter>\n    </ClInclude>\n    <ClInclude Include=\"CPUDialog\\SVDCPUColumns.h\">\n      <Filter>Header Files\\CPUDialog</Filter>\n    </ClInclude>\n    <ClInclude Include=\"..\\common\\ConnectivityGraphUtilities.h\">\n      <Filter>Header Files\\common</Filter>\n    </ClInclude>\n    <ClInclude Include=\"SVDConfigurationManager.h\">\n      <Filter>Header Files</Filter>\n    </ClInclude>\n    <ClInclude Include=\"CPUDialog\\SVDUtilities.h\">\n      <Filter>Header Files\\CPUDialog</Filter>\n    </ClInclude>\n    <ClInclude Include=\"..\\common\\PluginConfigurationManager.h\">\n      <Filter>Header Files\\common</Filter>\n    </ClInclude>\n    <ClInclude Include=\"..\\common\\ConfigurationManager.h\">\n      <Filter>Header Files\\common</Filter>\n    </ClInclude>\n    <ClInclude Include=\"..\\common\\CpuRoutesContainer.h\">\n      <Filter>Header Files\\common</Filter>\n    </ClInclude>\n    <ClInclude Include=\"CPUDialog\\SVDCpuRoutesContainer.h\">\n      <Filter>Header Files\\CPUDialog</Filter>\n    </ClInclude>\n    <ClInclude Include=\"..\\common\\SingleCpuRoutesContainer.h\">\n      <Filter>Header Files\\common</Filter>\n    </ClInclude>\n  </ItemGroup>\n</Project>"
  },
  {
    "path": "Plugins/SVDGenerator/svdgeneratorplugin.json",
    "content": "{\n\t\"Keys\": [ \"SVD Generator Plugin\" ]\n}"
  },
  {
    "path": "Plugins/SVDGenerator/svdgeneratorplugin_global.h",
    "content": "#ifndef SVDGENERATORPLUGIN_GLOBAL_H\n#define SVDGENERATORPLUGIN_GLOBAL_H\n\n#include <QtCore/qglobal.h>\n\n#ifdef SVDGENERATORPLUGIN_LIB\n# define SVDGENERATORPLUGIN_EXPORT Q_DECL_EXPORT\n#else\n# define SVDGENERATORPLUGIN_EXPORT Q_DECL_IMPORT\n#endif\n\n#endif // SVDGENERATORPLUGIN_GLOBAL_H\n"
  },
  {
    "path": "Plugins/VHDLAnalyzer/VHDLSourceAnalyzer.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: VHDLSourceAnalyzer.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Honkonen, Joni-Matti Maatta\r\n// Date: 18.1.2013\r\n//\r\n// Description:\r\n// VHDL source analyzer plugin.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"VHDLSourceAnalyzer.h\"\r\n\r\n#include <IPXACTmodels/Component/Component.h>\r\n#include <IPXACTmodels/Component/FileSet.h>\r\n#include <IPXACTmodels/Component/File.h>\r\n#include <IPXACTmodels/generaldeclarations.h>\r\n\r\n#include <QCryptographicHash>\r\n#include <QRegularExpression>\r\n//-----------------------------------------------------------------------------\r\n// Function: VHDLSourceAnalyzer::VHDLSourceAnalyzer()\r\n//-----------------------------------------------------------------------------\r\nVHDLSourceAnalyzer::VHDLSourceAnalyzer(): QObject(nullptr)\r\n{\r\n    \r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VHDLSourceAnalyzer::getName()\r\n//----------------------------------------------------------------------------\r\nQString VHDLSourceAnalyzer::getName() const\r\n{\r\n    return \"VHDL Source Analyzer\";\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VHDLSourceAnalyzer::getVersion()\r\n//-----------------------------------------------------------------------------\r\nQString VHDLSourceAnalyzer::getVersion() const\r\n{\r\n    return \"1.2\";\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VHDLSourceAnalyzer::getVendor()\r\n//-----------------------------------------------------------------------------\r\nQString VHDLSourceAnalyzer::getVendor() const\r\n{\r\n    return tr(\"tuni.fi\");\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VHDLSourceAnalyzer::getLicense()\r\n//-----------------------------------------------------------------------------\r\nQString VHDLSourceAnalyzer::getLicense() const\r\n{\r\n    return tr(\"GPL2\");\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VHDLSourceAnalyzer::getLicenseHolder()\r\n//-----------------------------------------------------------------------------\r\nQString VHDLSourceAnalyzer::getLicenseHolder() const\r\n{\r\n    return tr(\"Public\");\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VHDLSourceAnalyzer::getDescription()\r\n//-----------------------------------------------------------------------------\r\nQString VHDLSourceAnalyzer::getDescription() const\r\n{\r\n    return \"Analyzes file dependencies from VHDL files.\";\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VHDLSourceAnalyzer::getSettingsWidget()\r\n//-----------------------------------------------------------------------------\r\nQWidget* VHDLSourceAnalyzer::getSettingsWidget()\r\n{\r\n    return new QWidget();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VHDLSourceAnalyzer::getSupportedFileTypes()\r\n//-----------------------------------------------------------------------------\r\nQStringList VHDLSourceAnalyzer::getSupportedFileTypes() const\r\n{\r\n    return fileTypes_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VHDLSourceAnalyzer::calculateHash()\r\n//-----------------------------------------------------------------------------\r\nQString VHDLSourceAnalyzer::calculateHash(QString const& filename)\r\n{\r\n    QString source = getSourceData(filename);\r\n\r\n    // Calculate the hash\r\n    QCryptographicHash hash(QCryptographicHash::Sha1);\r\n    hash.addData(source.toLatin1());\r\n\r\n    return hash.result().toHex();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VHDLSourceAnalyzer::getFileDependencies()\r\n//-----------------------------------------------------------------------------\r\nQList<FileDependencyDesc> VHDLSourceAnalyzer::getFileDependencies(\r\n\tComponent const* /*component*/, QString const& /*componentPath*/, QString const& filename)\r\n{\r\n\tQList<FileDependencyDesc> dependencies;\r\n\r\n\t// Read file contents into a buffer.\r\n\tQString source = getSourceData(filename);\r\n\r\n\tscanEntityReferences(source, filename, dependencies);\r\n\tscanPackageReferences(source, filename, dependencies);\r\n\r\n\treturn dependencies;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VHDLSourceAnalyzer::getSourceData()\r\n//-----------------------------------------------------------------------------\r\nQString VHDLSourceAnalyzer::getSourceData(QString const& filename)\r\n{\r\n\t// Try to open the file\r\n\tQFile file(filename);\r\n\tif (!file.open(QIODevice::ReadOnly | QIODevice::Text))\r\n\t{\r\n\t\treturn QString();\r\n\t}\r\n\r\n    // Read the file data\r\n    QString contents = file.readAll();\r\n    contents.remove(QRegularExpression(\"--[^\\\\n]*\"));\r\n\r\n    return contents.simplified();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VHDLSourceAnalyzer::beginAnalysis()\r\n//-----------------------------------------------------------------------------\r\nvoid VHDLSourceAnalyzer::beginAnalysis(Component const* component, QString const& componentPath)\r\n{\r\n    scanDefinitions(component, componentPath);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VHDLSourceAnalyzer::endAnalysis()\r\n//-----------------------------------------------------------------------------\r\nvoid VHDLSourceAnalyzer::endAnalysis(Component const* /*component*/, QString const& /*componentPath*/)\r\n{\r\n    cachedEntities_.clear();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VHDLSourceAnalyzer::scanEntities()\r\n//-----------------------------------------------------------------------------\r\nvoid VHDLSourceAnalyzer::scanDefinitions(Component const* component, QString const& componentPath)\r\n{\r\n    // Scan all the file sets.\r\n    for (auto const& fileset : *component->getFileSets())\r\n    {\r\n        for (auto const& file : *fileset->getFiles())\r\n        {\r\n            for (auto const& fileType : *file->getFileTypes())\r\n            {\r\n                if (fileType.type_.contains(\"vhdlSource\"))\r\n                {\r\n                    QString filename = General::getAbsolutePath(componentPath, file->name());\r\n                    QString source = getSourceData(filename);\r\n\r\n                    scanEntities(source, filename);\r\n                    scanPackages(source, filename);\r\n                }\r\n            }\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VHDLSourceAnalyzer::getProgramRequirements()\r\n//-----------------------------------------------------------------------------\r\nQList<IPlugin::ExternalProgramRequirement> VHDLSourceAnalyzer::getProgramRequirements()\r\n{\r\n\treturn QList<IPlugin::ExternalProgramRequirement>();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VHDLSourceAnalyzer::scanEntities()\r\n//-----------------------------------------------------------------------------\r\nvoid VHDLSourceAnalyzer::scanEntities(QString const& source, QString const& filename)\r\n{\r\n    // Look for entities.\r\n    static QRegularExpression entityBeginExp(\"\\\\bENTITY\\\\s+(\\\\w+)\\\\s+(?:IS)\\\\s*\",\r\n\t\tQRegularExpression::CaseInsensitiveOption);\r\n\r\n\tauto matches = entityBeginExp.globalMatch(source);\r\n    while (matches.hasNext())\r\n    {\r\n\t\tauto match = matches.next();\r\n        // Register the entity name.\r\n        QString entityName = match.captured(1).toLower();\r\n        cachedEntities_[entityName].append(filename);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VHDLSourceAnalyzer::scanPackages()\r\n//-----------------------------------------------------------------------------\r\nvoid VHDLSourceAnalyzer::scanPackages(QString const& source, QString const& filename)\r\n{\r\n    // Look for packages.\r\n    static QRegularExpression packageBeginExp(\"\\\\bPACKAGE\\\\s+(\\\\w+)\\\\s+IS\\\\s*\",\r\n\t\tQRegularExpression::CaseInsensitiveOption);\r\n\t\r\n\tauto matches = packageBeginExp.globalMatch(source);\r\n\r\n    while (matches.hasNext())\r\n    {\r\n\t\tauto match = matches.next();\r\n        // Register the package name.\r\n        QString packageName = match.captured(1).toLower();\r\n        cachedPackages_[packageName].append(filename);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VHDLSourceAnalyzer::scanEntityReferences()\r\n//-----------------------------------------------------------------------------\r\nvoid VHDLSourceAnalyzer::scanEntityReferences(QString const& source, QString const& filename,\r\n\t QList<FileDependencyDesc>& dependencies)\r\n{\r\n\tstatic QRegularExpression entityExp(\r\n\t\t\"\\\\b(\\\\w+)\\\\s*\\\\:\\\\s*(ENTITY\\\\s+)?(\\\\w+\\\\.)?(\\\\w+)\\\\s+(GENERIC|PORT)\\\\s+MAP\\\\b\",\r\n\t\tQRegularExpression::CaseInsensitiveOption);\r\n\r\n\tauto entityMatches = entityExp.globalMatch(source);\r\n\twhile (entityMatches.hasNext())\r\n\t{\r\n\t\tauto entityMatch = entityMatches.next();\r\n\r\n\t\tQString entityName = entityMatch.captured(4);\r\n\t\taddEntityDependency(entityName, filename, dependencies);\r\n\t}\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VHDLSourceAnalyzer::scanPackageReferences()\r\n//-----------------------------------------------------------------------------\r\nvoid VHDLSourceAnalyzer::scanPackageReferences(QString const& source, QString const& filename,\r\n                                               QList<FileDependencyDesc>& dependencies)\r\n{\r\n    static QRegularExpression packageRefExp(\"\\\\bUSE\\\\s+(\\\\w+)\\\\.(\\\\w+)\\\\.(\\\\w+)\\\\b\",\r\n\t\tQRegularExpression::CaseInsensitiveOption);\r\n    \r\n\tauto matches = packageRefExp.globalMatch(source);\r\n    while (matches.hasNext())\r\n    {\r\n\t\tauto match = matches.next();\r\n\r\n        // Discard anything in the IEEE library.\r\n        QString libraryName = match.captured(1).toLower();\r\n        if (libraryName != QLatin1String(\"ieee\") && libraryName != QLatin1String(\"std\"))\r\n        {\r\n            QString packageName = match.captured(2);\r\n            addPackageDependency(packageName, filename, dependencies);\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VHDLSourceAnalyzer::addDependency()\r\n//-----------------------------------------------------------------------------\r\nvoid VHDLSourceAnalyzer::addEntityDependency(QString const& componentName, QString const& filename,\r\n                                             QList<FileDependencyDesc>& dependencies)\r\n{\r\n\tconst QString description(\"Component instantiation for entity %1\");\r\n  \r\n    QString lowCase = componentName.toLower();\r\n\r\n    if (cachedEntities_.contains(lowCase))\r\n    {\r\n        // Add all existing entities to the return value list.\r\n        for (auto const& cachedFile : cachedEntities_[lowCase])\r\n        {\r\n\t\t\tFileDependencyDesc dependency;\r\n\t\t\tdependency.description = description.arg(componentName);\r\n            dependency.filename = General::getRelativePath(filename, cachedFile);\r\n\r\n\t\t\taddUniqueDependency(dependency, dependencies);\r\n        }\r\n    }\r\n    else\r\n    {\r\n\t\tFileDependencyDesc dependency;\r\n\t\tdependency.description = description.arg(componentName);\r\n        dependency.filename = componentName + \" (VHDL entity)\";\r\n\r\n\t\taddUniqueDependency(dependency, dependencies);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VHDLSourceAnalyzer::addPackageDependency()\r\n//-----------------------------------------------------------------------------\r\nvoid VHDLSourceAnalyzer::addPackageDependency(QString const& packageName, QString const& filename,\r\n                                              QList<FileDependencyDesc> &dependencies)\r\n{\r\n\tconst QString description = \"Reference to package %1\";\r\n  \r\n    QString lowCase = packageName.toLower();\r\n    if (cachedPackages_.contains(lowCase))\r\n    {\r\n        // Add all existing entities to the return value list.\r\n        for (auto const& cachedFile : cachedPackages_[lowCase])\r\n        {\r\n\t\t\tFileDependencyDesc dependency;\r\n\t\t\tdependency.description = description.arg(packageName);\r\n            dependency.filename = General::getRelativePath(filename, cachedFile);\r\n\r\n\t\t\taddUniqueDependency(dependency, dependencies);\r\n        }\r\n    }\r\n    else\r\n    {\r\n\t\tFileDependencyDesc dependency;\r\n\t\tdependency.description = description.arg(packageName);\r\n        dependency.filename = packageName + \" (VHDL package)\";\r\n\r\n\t\taddUniqueDependency(dependency, dependencies);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VHDLSourceAnalyzer::addUniqueDependency()\r\n//-----------------------------------------------------------------------------\r\nvoid VHDLSourceAnalyzer::addUniqueDependency(FileDependencyDesc const& dependency,\r\n\tQList<FileDependencyDesc>& dependencies)\r\n{\r\n\t// Discard if this is a duplicate.\r\n\tif (dependencies.contains(dependency))\r\n\t{\r\n\t\treturn;\r\n\t}\r\n\r\n\tdependencies.append(dependency);\r\n}\r\n"
  },
  {
    "path": "Plugins/VHDLAnalyzer/VHDLSourceAnalyzer.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: VHDLSourceAnalyzer.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Honkonen, Joni-Matti Maatta\r\n// Date: 18.1.2013\r\n//\r\n// Description:\r\n// VHDL source analyzer plugin.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef VHDLSOURCEANALYZER_H\r\n#define VHDLSOURCEANALYZER_H\r\n\r\n#include <KactusAPI/include/ISourceAnalyzerPlugin.h>\r\n\r\n#include <QFile>\r\n\r\nclass IPluginUtility;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! VHDLSourceAnalyzer\r\n//-----------------------------------------------------------------------------\r\nclass VHDLSourceAnalyzer : public QObject, public ISourceAnalyzerPlugin\r\n{\r\n    Q_OBJECT\r\n    Q_PLUGIN_METADATA(IID \"kactus2.plugins.VHDLSourceAnalyzer\" FILE \"vhdlPlugin.json\")\r\n\r\n    Q_INTERFACES(IPlugin)\r\n    Q_INTERFACES(ISourceAnalyzerPlugin)\r\n\r\npublic:\r\n    //! The constructor.\r\n\tVHDLSourceAnalyzer();\r\n\r\n\t//! The destructor.\r\n    virtual ~VHDLSourceAnalyzer() = default;\r\n\r\n\t// Disable copying.\r\n\tVHDLSourceAnalyzer(VHDLSourceAnalyzer const& rhs) = delete;\r\n\tVHDLSourceAnalyzer& operator=(VHDLSourceAnalyzer const& rhs) = delete;\r\n\r\n    /*!\r\n     *  Returns the name of the plugin.\r\n     */\r\n    virtual QString getName() const;\r\n\r\n    /*!\r\n     *  Returns the version of the plugin.\r\n     */\r\n    virtual QString getVersion() const;\r\n\r\n    /*!\r\n     *  Returns the description of the plugin.\r\n     */\r\n    virtual QString getDescription() const;\r\n\r\n    /*!\r\n     *  Returns the vendor of the plugin.\r\n     */\r\n    virtual QString getVendor() const;\r\n\r\n    /*!\r\n     *  Returns the license of the plugin.\r\n     */\r\n    virtual QString getLicense() const;\r\n\r\n    /*!\r\n     *  Returns the holder of the license of the plugin.\r\n     */\r\n    virtual QString getLicenseHolder() const;\r\n\r\n    /*!\r\n     *  Returns the settings widget.\r\n     */\r\n    virtual QWidget* getSettingsWidget();\r\n\r\n    /*!\r\n     *  This is used to access the settings modified by function getSettingsWidget().\r\n     */\r\n    virtual PluginSettingsModel* getSettingsModel(){return nullptr;}\r\n\r\n    /*!\r\n     *  Returns the list of file types this plugin can run analysis for.\r\n     */\r\n    virtual QStringList getSupportedFileTypes() const;\r\n\r\n    /*!\r\n     *  Calculates a language-dependent hash for the given file.\r\n     *\r\n     *    @param [in] filename  The name of the file.\r\n     *\r\n     *    @return The hash value for the file.\r\n     *\r\n     *      @remarks Comments and whitespace are ignored and do not affect the hash value.\r\n     */\r\n    virtual QString calculateHash(QString const& filename);\r\n\r\n    /*!\r\n     *  Begins the analysis for the given component.\r\n     *\r\n     *    @param [in] component      The component.\r\n     *    @param [in] componentPath  The path to the directory where the component is located.\r\n     *\r\n     *      @remarks Any preparations needed for the file dependency analysis should be made here.\r\n     */\r\n    virtual void beginAnalysis(Component const* component, QString const& componentPath);\r\n\r\n    /*!\r\n     *  Ends the analysis for the given component.\r\n     *\r\n     *    @param [in] component      The component.\r\n     *    @param [in] componentPath  The path to the directory where the component is located.\r\n     *\r\n     *      @remarks Any cleanups needed should be made here.\r\n     */\r\n    virtual void endAnalysis(Component const* component, QString const& componentPath);\r\n\r\n    /*!\r\n     *  Retrieves all file dependencies the given file has.\r\n     *\r\n     *    @param [in]  component      The component to which the dependency scan is being run.\r\n     *    @param [in]  componentPath  The path to the directory where the component is located.\r\n     *    @param [in]  filename       The name of the file to which the analysis is run.\r\n     *\r\n\t *    @return The list of found dependencies.\r\n     */\r\n\tvirtual QList<FileDependencyDesc> getFileDependencies(Component const* component,\r\n\t\tQString const& componentPath, QString const& filename);\r\n\r\n    //! Returns the external program requirements of the plugin.\r\n\tvirtual QList<IPlugin::ExternalProgramRequirement> getProgramRequirements();\r\n\r\nprivate:\r\n\r\n    /*!\r\n     *  Reads source file data from given file.\r\n     *\r\n     *    @param [in] filename    The file that is read.\r\n     *\r\n     *    @return The meaningful source data of the file, with comments and empty lines removed.\r\n     */\r\n    QString getSourceData(QString const& filename);\r\n\r\n    /*!\r\n     *\r\n     * Scans all the files in the component to find VHDL entities and packages.\r\n     *\r\n     *    @param [in] component       The component from which files are scanned.\r\n     *    @param [in] componentPath   The path of of the component in the file system.\r\n     */\r\n    void scanDefinitions(Component const* component, QString const& componentPath);\r\n\r\n    /*!\r\n     *  Scans entity declarations in the given source string.\r\n     *\r\n     *    @param [in] source    The source string.\r\n     *    @param [in] filename  The name of the correspondent file.\r\n     */\r\n    void scanEntities(QString const& source, QString const& filename);\r\n\r\n    /*!\r\n     *  Scans package declarations in the given source string.\r\n     *\r\n     *    @param [in] source    The source string.\r\n     *    @param [in] filename  The name of the correspondent file.\r\n     */\r\n    void scanPackages(QString const& source, QString const& filename);\r\n\r\n    /*!\r\n     *  Scans entity references in the source string.\r\n     *\r\n     *    @param [in]  source        The source string.\r\n     *    @param [in]  filename      The name of the corresponding file.\r\n     *    @param [out] dependencies  The list of dependencies.\r\n     */\r\n    void scanEntityReferences(QString const& source, QString const& filename,\r\n                              QList<FileDependencyDesc>& dependencies);\r\n\r\n\r\n    /*!\r\n     *  Scans package references in the source string.\r\n     *\r\n     *    @param [in]  source        The source string.\r\n     *    @param [in]  filename      The name of the corresponding file.\r\n     *    @param [out] dependencies  The list of dependencies.\r\n     */\r\n    void scanPackageReferences(QString const& source, QString const& filename,\r\n                               QList<FileDependencyDesc>& dependencies);\r\n\r\n    /*!\r\n     *  Adds a new entity dependency to the list of dependencies.\r\n     *\r\n     *    @param [in] componentName  The name of the instantiated component.\r\n     *    @param [in] filename       The name of the file containing the instantiation.\r\n     *    @param [out] dependencies  The list of dependencies.\r\n     */\r\n    void addEntityDependency(QString const& componentName, QString const& filename,\r\n                             QList<FileDependencyDesc> &dependencies);\r\n\r\n    /*!\r\n     *  Adds a new package dependency to the list of dependencies.\r\n     *\r\n     *    @param [in] componentName  The name of the package.\r\n     *    @param [in] filename       The name of the file containing the dependency.\r\n     *    @param [out] dependencies  The list of dependencies.\r\n     */\r\n    void addPackageDependency(QString const& packageName, QString const& filename,\r\n                              QList<FileDependencyDesc> &dependencies);\r\n\t/*!\r\n\t *  Adds a new dependency to the list of dependencies, if it is unique i.e. not in the list already.\r\n\t *\r\n\t *    @param [in] dependency\t\tThe dependency to add.\r\n\t *    @param [out] dependencies\tThe list of dependencies.\r\n\t */\r\n\tvoid addUniqueDependency(FileDependencyDesc const& dependency, QList<FileDependencyDesc>& dependencies);\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! The supported file types.\r\n    QStringList fileTypes_ = QStringList(\"vhdlSource\");\r\n\r\n    //! The container used for caching scanned entities.\r\n    QMap<QString, QStringList> cachedEntities_;\r\n\r\n    //! The container used for caching scanned packages.\r\n    QMap<QString, QStringList> cachedPackages_;\r\n};\r\n\r\n#endif // VHDLSOURCEANALYZER_H\r\n"
  },
  {
    "path": "Plugins/VHDLAnalyzer/VHDLSourceAnalyzer.pri",
    "content": "# ----------------------------------------------------\r\n# This file is generated by the Qt Visual Studio Add-in.\r\n# ------------------------------------------------------\r\n\r\nHEADERS += ./VHDLSourceAnalyzer.h\r\nSOURCES += ./VHDLSourceAnalyzer.cpp\r\n"
  },
  {
    "path": "Plugins/VHDLAnalyzer/VHDLSourceAnalyzer.pro",
    "content": "# ----------------------------------------------------\r\n# This file is generated by the Qt Visual Studio Add-in.\r\n# ------------------------------------------------------\r\n\r\nTEMPLATE = lib\r\n\r\nQT += core widgets\r\nCONFIG += c++11 plugin\r\n\r\nDEFINES += VHDLSOURCEANALYZER_LIB\r\n\r\nINCLUDEPATH += ./GeneratedFiles \\\r\n    . \\\r\n    ./../.. \r\n\r\nCONFIG(debug, debug|release) {\r\n    # debug mode\r\n    LIBS += \\\r\n        -L../../executable -lIPXACTmodelsd\r\n\r\n    MOC_DIR += ./GeneratedFiles/Debug\r\n    OBJECTS_DIR += Debug\r\n    TARGET = VHDLSourceAnalyzerd\r\n\r\n} else {\r\n    # release mode \r\n    LIBS += \\\r\n        -L../../executable -lIPXACTmodels\r\n    \r\n    MOC_DIR += ./GeneratedFiles/Release\r\n    OBJECTS_DIR += Release\r\n    TARGET = VHDLSourceAnalyzer\r\n}\r\n\r\nDESTDIR = ../../executable/Plugins\r\n\r\nDEPENDPATH += .\r\nUI_DIR += ./GeneratedFiles\r\nRCC_DIR += ./GeneratedFiles\r\n\r\ninclude(VHDLSourceAnalyzer.pri)\r\n\r\nOTHER_FILES += vhdlPlugin.json\r\n\r\ntarget.path = $$plugin_path\r\nINSTALLS += target\r\n"
  },
  {
    "path": "Plugins/VHDLAnalyzer/VHDLSourceAnalyzer.vcproj",
    "content": "<?xml version=\"1.0\" encoding=\"Windows-1252\"?>\r\n<VisualStudioProject\r\n\tProjectType=\"Visual C++\"\r\n\tVersion=\"9,00\"\r\n\tName=\"VHDLSourceAnalyzer\"\r\n\tProjectGUID=\"{FD8026D5-50C6-4D30-B082-899FA4226C48}\"\r\n\tKeyword=\"Qt4VSv1.0\"\r\n\tTargetFrameworkVersion=\"0\"\r\n\t>\r\n\t<Platforms>\r\n\t\t<Platform\r\n\t\t\tName=\"Win32\"\r\n\t\t/>\r\n\t\t<Platform\r\n\t\t\tName=\"x64\"\r\n\t\t/>\r\n\t</Platforms>\r\n\t<ToolFiles>\r\n\t</ToolFiles>\r\n\t<Configurations>\r\n\t\t<Configuration\r\n\t\t\tName=\"Release|Win32\"\r\n\t\t\tOutputDirectory=\"$(SolutionDir)\\executable\\Plugins\"\r\n\t\t\tIntermediateDirectory=\"$(SolutionDir)$(ConfigurationName)\"\r\n\t\t\tConfigurationType=\"2\"\r\n\t\t\t>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCPreBuildEventTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCCustomBuildTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCXMLDataGeneratorTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCWebServiceProxyGeneratorTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCMIDLTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCCLCompilerTool\"\r\n\t\t\t\tAdditionalIncludeDirectories=\"&quot;.\\GeneratedFiles&quot;;&quot;$(QTDIR)\\include&quot;;&quot;.\\GeneratedFiles\\$(ConfigurationName)&quot;;&quot;$(QTDIR)\\include\\qtmain&quot;;&quot;$(QTDIR)\\include\\QtCore&quot;;&quot;.\\&quot;;&quot;..\\..\\&quot;;&quot;$(QTDIR)\\include\\QtXml&quot;;&quot;$(QTDIR)\\include\\QtXmlPatterns&quot;;&quot;$(QTDIR)\\include\\QtGui&quot;\"\r\n\t\t\t\tPreprocessorDefinitions=\",UNICODE,WIN32,QT_NO_DEBUG,NDEBUG;QT_CORE_LIB;VHDLSOURCEANALYZER_LIB;QT_XML_LIB;QT_XMLPATTERNS_LIB;QT_GUI_LIB;QT_DLL\"\r\n\t\t\t\tRuntimeLibrary=\"2\"\r\n\t\t\t\tTreatWChar_tAsBuiltInType=\"false\"\r\n\t\t\t\tDebugInformationFormat=\"0\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCManagedResourceCompilerTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCResourceCompilerTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCPreLinkEventTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCLinkerTool\"\r\n\t\t\t\tAdditionalDependencies=\"qtmain.lib QtCore4.lib QtXml4.lib QtXmlPatterns4.lib QtGui4.lib Kactus2.lib\"\r\n\t\t\t\tOutputFile=\"$(OutDir)\\$(ProjectName).dll\"\r\n\t\t\t\tAdditionalLibraryDirectories=\"&quot;..\\..\\executable&quot;;&quot;$(QTDIR)\\lib&quot;\"\r\n\t\t\t\tGenerateDebugInformation=\"false\"\r\n\t\t\t\tSubSystem=\"2\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCALinkTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCManifestTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCXDCMakeTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCBscMakeTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCFxCopTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCAppVerifierTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCPostBuildEventTool\"\r\n\t\t\t\tCommandLine=\"\"\r\n\t\t\t/>\r\n\t\t</Configuration>\r\n\t\t<Configuration\r\n\t\t\tName=\"Release|x64\"\r\n\t\t\tOutputDirectory=\"$(SolutionDir)\\x64\\executable\\Plugins\"\r\n\t\t\tIntermediateDirectory=\"$(PlatformName)\\$(ConfigurationName)\"\r\n\t\t\tConfigurationType=\"2\"\r\n\t\t\t>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCPreBuildEventTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCCustomBuildTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCXMLDataGeneratorTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCWebServiceProxyGeneratorTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCMIDLTool\"\r\n\t\t\t\tTargetEnvironment=\"3\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCCLCompilerTool\"\r\n\t\t\t\tAdditionalIncludeDirectories=\"&quot;.\\GeneratedFiles&quot;;&quot;$(QTDIR)\\include&quot;;&quot;.\\GeneratedFiles\\$(ConfigurationName)&quot;;&quot;$(QTDIR)\\include\\qtmain&quot;;&quot;$(QTDIR)\\include\\QtCore&quot;;&quot;.\\&quot;;&quot;..\\..\\&quot;;&quot;$(QTDIR)\\include\\QtXml&quot;;&quot;$(QTDIR)\\include\\QtXmlPatterns&quot;;&quot;$(QTDIR)\\include\\QtGui&quot;\"\r\n\t\t\t\tPreprocessorDefinitions=\",UNICODE,WIN32,QT_NO_DEBUG,NDEBUG;QT_CORE_LIB;VHDLSOURCEANALYZER_LIB;QT_XML_LIB;QT_XMLPATTERNS_LIB;QT_GUI_LIB;QT_DLL\"\r\n\t\t\t\tRuntimeLibrary=\"2\"\r\n\t\t\t\tTreatWChar_tAsBuiltInType=\"false\"\r\n\t\t\t\tDebugInformationFormat=\"0\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCManagedResourceCompilerTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCResourceCompilerTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCPreLinkEventTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCLinkerTool\"\r\n\t\t\t\tAdditionalDependencies=\"qtmain.lib QtCore4.lib QtXml4.lib QtXmlPatterns4.lib QtGui4.lib Kactus2.lib\"\r\n\t\t\t\tOutputFile=\"$(OutDir)\\$(ProjectName).dll\"\r\n\t\t\t\tAdditionalLibraryDirectories=\"&quot;..\\..\\x64\\executable&quot;;&quot;$(QTDIR)\\lib&quot;\"\r\n\t\t\t\tGenerateDebugInformation=\"false\"\r\n\t\t\t\tSubSystem=\"2\"\r\n\t\t\t\tTargetMachine=\"17\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCALinkTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCManifestTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCXDCMakeTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCBscMakeTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCFxCopTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCAppVerifierTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCPostBuildEventTool\"\r\n\t\t\t\tCommandLine=\"\"\r\n\t\t\t/>\r\n\t\t</Configuration>\r\n\t\t<Configuration\r\n\t\t\tName=\"Debug|Win32\"\r\n\t\t\tOutputDirectory=\"$(SolutionDir)\\executable\\Plugins\"\r\n\t\t\tIntermediateDirectory=\"$(SolutionDir)$(ConfigurationName)\"\r\n\t\t\tConfigurationType=\"2\"\r\n\t\t\t>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCPreBuildEventTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCCustomBuildTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCXMLDataGeneratorTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCWebServiceProxyGeneratorTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCMIDLTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCCLCompilerTool\"\r\n\t\t\t\tOptimization=\"0\"\r\n\t\t\t\tAdditionalIncludeDirectories=\"&quot;.\\GeneratedFiles&quot;;&quot;$(QTDIR)\\include&quot;;&quot;.\\GeneratedFiles\\$(ConfigurationName)&quot;;&quot;$(QTDIR)\\include\\qtmain&quot;;&quot;$(QTDIR)\\include\\QtCore&quot;;&quot;.\\&quot;;&quot;..\\..\\&quot;;&quot;$(QTDIR)\\include\\QtXml&quot;;&quot;$(QTDIR)\\include\\QtXmlPatterns&quot;;&quot;$(QTDIR)\\include\\QtGui&quot;\"\r\n\t\t\t\tPreprocessorDefinitions=\",UNICODE,WIN32,QT_CORE_LIB;VHDLSOURCEANALYZER_LIB;QT_XML_LIB;QT_XMLPATTERNS_LIB;QT_GUI_LIB;QT_DLL\"\r\n\t\t\t\tRuntimeLibrary=\"3\"\r\n\t\t\t\tTreatWChar_tAsBuiltInType=\"false\"\r\n\t\t\t\tDebugInformationFormat=\"3\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCManagedResourceCompilerTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCResourceCompilerTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCPreLinkEventTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCLinkerTool\"\r\n\t\t\t\tAdditionalDependencies=\"qtmaind.lib QtCored4.lib QtXmld4.lib QtXmlPatternsd4.lib QtGuid4.lib Kactus2_d.lib\"\r\n\t\t\t\tOutputFile=\"$(OutDir)\\$(ProjectName).dll\"\r\n\t\t\t\tAdditionalLibraryDirectories=\"&quot;..\\..\\executable&quot;;&quot;$(QTDIR)\\lib&quot;\"\r\n\t\t\t\tGenerateDebugInformation=\"true\"\r\n\t\t\t\tSubSystem=\"2\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCALinkTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCManifestTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCXDCMakeTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCBscMakeTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCFxCopTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCAppVerifierTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCPostBuildEventTool\"\r\n\t\t\t\tCommandLine=\"\"\r\n\t\t\t/>\r\n\t\t</Configuration>\r\n\t\t<Configuration\r\n\t\t\tName=\"Debug|x64\"\r\n\t\t\tOutputDirectory=\"$(SolutionDir)\\x64\\executable\\Plugins\"\r\n\t\t\tIntermediateDirectory=\"$(PlatformName)\\$(ConfigurationName)\"\r\n\t\t\tConfigurationType=\"2\"\r\n\t\t\t>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCPreBuildEventTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCCustomBuildTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCXMLDataGeneratorTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCWebServiceProxyGeneratorTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCMIDLTool\"\r\n\t\t\t\tTargetEnvironment=\"3\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCCLCompilerTool\"\r\n\t\t\t\tOptimization=\"0\"\r\n\t\t\t\tAdditionalIncludeDirectories=\"&quot;.\\GeneratedFiles&quot;;&quot;$(QTDIR)\\include&quot;;&quot;.\\GeneratedFiles\\$(ConfigurationName)&quot;;&quot;$(QTDIR)\\include\\qtmain&quot;;&quot;$(QTDIR)\\include\\QtCore&quot;;&quot;.\\&quot;;&quot;..\\..\\&quot;;&quot;$(QTDIR)\\include\\QtXml&quot;;&quot;$(QTDIR)\\include\\QtXmlPatterns&quot;;&quot;$(QTDIR)\\include\\QtGui&quot;\"\r\n\t\t\t\tPreprocessorDefinitions=\",UNICODE,WIN32,QT_CORE_LIB;VHDLSOURCEANALYZER_LIB;QT_XML_LIB;QT_XMLPATTERNS_LIB;QT_GUI_LIB;QT_DLL\"\r\n\t\t\t\tRuntimeLibrary=\"3\"\r\n\t\t\t\tTreatWChar_tAsBuiltInType=\"false\"\r\n\t\t\t\tDebugInformationFormat=\"3\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCManagedResourceCompilerTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCResourceCompilerTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCPreLinkEventTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCLinkerTool\"\r\n\t\t\t\tAdditionalDependencies=\"qtmaind.lib QtCored4.lib QtXmld4.lib QtXmlPatternsd4.lib QtGuid4.lib Kactus2_d.lib\"\r\n\t\t\t\tOutputFile=\"$(OutDir)\\$(ProjectName).dll\"\r\n\t\t\t\tAdditionalLibraryDirectories=\"&quot;..\\..\\x64\\executable&quot;;&quot;$(QTDIR)\\lib&quot;\"\r\n\t\t\t\tGenerateDebugInformation=\"true\"\r\n\t\t\t\tSubSystem=\"2\"\r\n\t\t\t\tTargetMachine=\"17\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCALinkTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCManifestTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCXDCMakeTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCBscMakeTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCFxCopTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCAppVerifierTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCPostBuildEventTool\"\r\n\t\t\t\tCommandLine=\"\"\r\n\t\t\t/>\r\n\t\t</Configuration>\r\n\t</Configurations>\r\n\t<References>\r\n\t</References>\r\n\t<Files>\r\n\t\t<Filter\r\n\t\t\tName=\"Source Files\"\r\n\t\t\tFilter=\"cpp;cxx;c;def\"\r\n\t\t\tUniqueIdentifier=\"{4FC737F1-C7A5-4376-A066-2A32D752A2FF}\"\r\n\t\t\t>\r\n\t\t\t<File\r\n\t\t\t\tRelativePath=\".\\VHDLSourceAnalyzer.cpp\"\r\n\t\t\t\t>\r\n\t\t\t</File>\r\n\t\t</Filter>\r\n\t\t<Filter\r\n\t\t\tName=\"Header Files\"\r\n\t\t\tFilter=\"h\"\r\n\t\t\tUniqueIdentifier=\"{93995380-89BD-4b04-88EB-625FBE52EBFB}\"\r\n\t\t\t>\r\n\t\t\t<File\r\n\t\t\t\tRelativePath=\".\\VHDLSourceAnalyzer.h\"\r\n\t\t\t\t>\r\n\t\t\t\t<FileConfiguration\r\n\t\t\t\t\tName=\"Release|Win32\"\r\n\t\t\t\t\t>\r\n\t\t\t\t\t<Tool\r\n\t\t\t\t\t\tName=\"VCCustomBuildTool\"\r\n\t\t\t\t\t\tDescription=\"Moc&apos;ing $(InputFileName)...\"\r\n\t\t\t\t\t\tCommandLine=\"&quot;$(QTDIR)\\bin\\moc.exe&quot;   -DUNICODE -DWIN32 -DQT_NO_DEBUG -DNDEBUG -DQT_CORE_LIB -DCPPSOURCEANALYZER_LIB -DQT_XML_LIB -DQT_XMLPATTERNS_LIB -DQT_GUI_LIB -DQT_DLL -D_WINDLL  &quot;-I.\\GeneratedFiles&quot; &quot;-I$(QTDIR)\\include&quot; &quot;-I.\\GeneratedFiles\\$(ConfigurationName)\\.&quot; &quot;-I$(QTDIR)\\include\\qtmain&quot; &quot;-I$(QTDIR)\\include\\QtCore&quot; &quot;-I.&quot; &quot;-I.\\..\\..&quot; &quot;-I$(QTDIR)\\include\\QtXml&quot; &quot;-I$(QTDIR)\\include\\QtXmlPatterns&quot; &quot;-I$(QTDIR)\\include\\QtGui&quot; &quot;.\\VHDLSourceAnalyzer.h&quot; -o &quot;.\\GeneratedFiles\\$(ConfigurationName)\\moc_$(InputName).cpp&quot;&#x0D;&#x0A;\"\r\n\t\t\t\t\t\tAdditionalDependencies=\"&quot;$(QTDIR)\\bin\\moc.exe&quot;;$(InputPath)\"\r\n\t\t\t\t\t\tOutputs=\"&quot;.\\GeneratedFiles\\$(ConfigurationName)\\moc_VHDLSourceAnalyzer.cpp&quot;\"\r\n\t\t\t\t\t/>\r\n\t\t\t\t</FileConfiguration>\r\n\t\t\t\t<FileConfiguration\r\n\t\t\t\t\tName=\"Release|x64\"\r\n\t\t\t\t\t>\r\n\t\t\t\t\t<Tool\r\n\t\t\t\t\t\tName=\"VCCustomBuildTool\"\r\n\t\t\t\t\t\tDescription=\"Moc&apos;ing $(InputFileName)...\"\r\n\t\t\t\t\t\tCommandLine=\"&quot;$(QTDIR)\\bin\\moc.exe&quot;   -DUNICODE -DWIN32 -DQT_NO_DEBUG -DNDEBUG -DQT_CORE_LIB -DCPPSOURCEANALYZER_LIB -DQT_XML_LIB -DQT_XMLPATTERNS_LIB -DQT_GUI_LIB -DQT_DLL -D_WINDLL  &quot;-I.\\GeneratedFiles&quot; &quot;-I$(QTDIR)\\include&quot; &quot;-I.\\GeneratedFiles\\$(ConfigurationName)\\.&quot; &quot;-I$(QTDIR)\\include\\qtmain&quot; &quot;-I$(QTDIR)\\include\\QtCore&quot; &quot;-I.&quot; &quot;-I.\\..\\..&quot; &quot;-I$(QTDIR)\\include\\QtXml&quot; &quot;-I$(QTDIR)\\include\\QtXmlPatterns&quot; &quot;-I$(QTDIR)\\include\\QtGui&quot; &quot;.\\VHDLSourceAnalyzer.h&quot; -o &quot;.\\GeneratedFiles\\$(ConfigurationName)\\moc_$(InputName).cpp&quot;&#x0D;&#x0A;\"\r\n\t\t\t\t\t\tAdditionalDependencies=\"&quot;$(QTDIR)\\bin\\moc.exe&quot;;$(InputPath)\"\r\n\t\t\t\t\t\tOutputs=\"&quot;.\\GeneratedFiles\\$(ConfigurationName)\\moc_VHDLSourceAnalyzer.cpp&quot;\"\r\n\t\t\t\t\t/>\r\n\t\t\t\t</FileConfiguration>\r\n\t\t\t\t<FileConfiguration\r\n\t\t\t\t\tName=\"Debug|Win32\"\r\n\t\t\t\t\t>\r\n\t\t\t\t\t<Tool\r\n\t\t\t\t\t\tName=\"VCCustomBuildTool\"\r\n\t\t\t\t\t\tDescription=\"Moc&apos;ing $(InputFileName)...\"\r\n\t\t\t\t\t\tCommandLine=\"&quot;$(QTDIR)\\bin\\moc.exe&quot;   -DUNICODE -DWIN32 -DQT_CORE_LIB -DCPPSOURCEANALYZER_LIB -DQT_XML_LIB -DQT_XMLPATTERNS_LIB -DQT_GUI_LIB -DQT_DLL -D_WINDLL  &quot;-I.\\GeneratedFiles&quot; &quot;-I$(QTDIR)\\include&quot; &quot;-I.\\GeneratedFiles\\$(ConfigurationName)\\.&quot; &quot;-I$(QTDIR)\\include\\qtmain&quot; &quot;-I$(QTDIR)\\include\\QtCore&quot; &quot;-I.&quot; &quot;-I.\\..\\..&quot; &quot;-I$(QTDIR)\\include\\QtXml&quot; &quot;-I$(QTDIR)\\include\\QtXmlPatterns&quot; &quot;-I$(QTDIR)\\include\\QtGui&quot; &quot;.\\VHDLSourceAnalyzer.h&quot; -o &quot;.\\GeneratedFiles\\$(ConfigurationName)\\moc_$(InputName).cpp&quot;&#x0D;&#x0A;\"\r\n\t\t\t\t\t\tAdditionalDependencies=\"&quot;$(QTDIR)\\bin\\moc.exe&quot;;$(InputPath)\"\r\n\t\t\t\t\t\tOutputs=\"&quot;.\\GeneratedFiles\\$(ConfigurationName)\\moc_VHDLSourceAnalyzer.cpp&quot;\"\r\n\t\t\t\t\t/>\r\n\t\t\t\t</FileConfiguration>\r\n\t\t\t\t<FileConfiguration\r\n\t\t\t\t\tName=\"Debug|x64\"\r\n\t\t\t\t\t>\r\n\t\t\t\t\t<Tool\r\n\t\t\t\t\t\tName=\"VCCustomBuildTool\"\r\n\t\t\t\t\t\tDescription=\"Moc&apos;ing $(InputFileName)...\"\r\n\t\t\t\t\t\tCommandLine=\"&quot;$(QTDIR)\\bin\\moc.exe&quot;   -DUNICODE -DWIN32 -DQT_CORE_LIB -DCPPSOURCEANALYZER_LIB -DQT_XML_LIB -DQT_XMLPATTERNS_LIB -DQT_GUI_LIB -DQT_DLL -D_WINDLL  &quot;-I.\\GeneratedFiles&quot; &quot;-I$(QTDIR)\\include&quot; &quot;-I.\\GeneratedFiles\\$(ConfigurationName)\\.&quot; &quot;-I$(QTDIR)\\include\\qtmain&quot; &quot;-I$(QTDIR)\\include\\QtCore&quot; &quot;-I.&quot; &quot;-I.\\..\\..&quot; &quot;-I$(QTDIR)\\include\\QtXml&quot; &quot;-I$(QTDIR)\\include\\QtXmlPatterns&quot; &quot;-I$(QTDIR)\\include\\QtGui&quot; &quot;.\\VHDLSourceAnalyzer.h&quot; -o &quot;.\\GeneratedFiles\\$(ConfigurationName)\\moc_$(InputName).cpp&quot;&#x0D;&#x0A;\"\r\n\t\t\t\t\t\tAdditionalDependencies=\"&quot;$(QTDIR)\\bin\\moc.exe&quot;;$(InputPath)\"\r\n\t\t\t\t\t\tOutputs=\"&quot;.\\GeneratedFiles\\$(ConfigurationName)\\moc_VHDLSourceAnalyzer.cpp&quot;\"\r\n\t\t\t\t\t/>\r\n\t\t\t\t</FileConfiguration>\r\n\t\t\t</File>\r\n\t\t</Filter>\r\n\t\t<Filter\r\n\t\t\tName=\"Form Files\"\r\n\t\t\tFilter=\"ui\"\r\n\t\t\tUniqueIdentifier=\"{99349809-55BA-4b9d-BF79-8FDBB0286EB3}\"\r\n\t\t\t>\r\n\t\t</Filter>\r\n\t\t<Filter\r\n\t\t\tName=\"Resource Files\"\r\n\t\t\tFilter=\"qrc;*\"\r\n\t\t\tUniqueIdentifier=\"{D9D6E242-F8AF-46E4-B9FD-80ECBC20BA3E}\"\r\n\t\t\tParseFiles=\"false\"\r\n\t\t\t>\r\n\t\t</Filter>\r\n\t\t<Filter\r\n\t\t\tName=\"Generated Files\"\r\n\t\t\tFilter=\"moc;h;cpp\"\r\n\t\t\tUniqueIdentifier=\"{71ED8ED8-ACB9-4CE9-BBE1-E00B30144E11}\"\r\n\t\t\tSourceControlFiles=\"false\"\r\n\t\t\t>\r\n\t\t\t<Filter\r\n\t\t\t\tName=\"Release\"\r\n\t\t\t\tFilter=\"cpp;moc\"\r\n\t\t\t\tSourceControlFiles=\"false\"\r\n\t\t\t\t>\r\n\t\t\t\t<File\r\n\t\t\t\t\tRelativePath=\".\\GeneratedFiles\\Release\\moc_VHDLSourceAnalyzer.cpp\"\r\n\t\t\t\t\t>\r\n\t\t\t\t\t<FileConfiguration\r\n\t\t\t\t\t\tName=\"Debug|Win32\"\r\n\t\t\t\t\t\tExcludedFromBuild=\"true\"\r\n\t\t\t\t\t\t>\r\n\t\t\t\t\t\t<Tool\r\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\r\n\t\t\t\t\t\t/>\r\n\t\t\t\t\t</FileConfiguration>\r\n\t\t\t\t\t<FileConfiguration\r\n\t\t\t\t\t\tName=\"Debug|x64\"\r\n\t\t\t\t\t\tExcludedFromBuild=\"true\"\r\n\t\t\t\t\t\t>\r\n\t\t\t\t\t\t<Tool\r\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\r\n\t\t\t\t\t\t/>\r\n\t\t\t\t\t</FileConfiguration>\r\n\t\t\t\t</File>\r\n\t\t\t</Filter>\r\n\t\t\t<Filter\r\n\t\t\t\tName=\"Debug\"\r\n\t\t\t\tFilter=\"cpp;moc\"\r\n\t\t\t\tSourceControlFiles=\"false\"\r\n\t\t\t\t>\r\n\t\t\t\t<File\r\n\t\t\t\t\tRelativePath=\".\\GeneratedFiles\\Debug\\moc_VHDLSourceAnalyzer.cpp\"\r\n\t\t\t\t\t>\r\n\t\t\t\t\t<FileConfiguration\r\n\t\t\t\t\t\tName=\"Release|Win32\"\r\n\t\t\t\t\t\tExcludedFromBuild=\"true\"\r\n\t\t\t\t\t\t>\r\n\t\t\t\t\t\t<Tool\r\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\r\n\t\t\t\t\t\t/>\r\n\t\t\t\t\t</FileConfiguration>\r\n\t\t\t\t\t<FileConfiguration\r\n\t\t\t\t\t\tName=\"Release|x64\"\r\n\t\t\t\t\t\tExcludedFromBuild=\"true\"\r\n\t\t\t\t\t\t>\r\n\t\t\t\t\t\t<Tool\r\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\r\n\t\t\t\t\t\t/>\r\n\t\t\t\t\t</FileConfiguration>\r\n\t\t\t\t</File>\r\n\t\t\t</Filter>\r\n\t\t</Filter>\r\n\t</Files>\r\n\t<Globals>\r\n\t\t<Global\r\n\t\t\tName=\"lreleaseOptions\"\r\n\t\t\tValue=\"\"\r\n\t\t/>\r\n\t\t<Global\r\n\t\t\tName=\"lupdateOnBuild\"\r\n\t\t\tValue=\"0\"\r\n\t\t/>\r\n\t\t<Global\r\n\t\t\tName=\"lupdateOptions\"\r\n\t\t\tValue=\"\"\r\n\t\t/>\r\n\t\t<Global\r\n\t\t\tName=\"MocDir\"\r\n\t\t\tValue=\".\\GeneratedFiles\\$(ConfigurationName)\"\r\n\t\t/>\r\n\t\t<Global\r\n\t\t\tName=\"MocOptions\"\r\n\t\t\tValue=\"\"\r\n\t\t/>\r\n\t\t<Global\r\n\t\t\tName=\"Qt5Version Win32\"\r\n\t\t\tValue=\"4.8.3\"\r\n\t\t/>\r\n\t\t<Global\r\n\t\t\tName=\"QtVersion Win32\"\r\n\t\t\tValue=\"4.8.3\"\r\n\t\t/>\r\n\t\t<Global\r\n\t\t\tName=\"QtVersion x64\"\r\n\t\t\tValue=\"4.8.3 x64\"\r\n\t\t/>\r\n\t\t<Global\r\n\t\t\tName=\"RccDir\"\r\n\t\t\tValue=\".\\GeneratedFiles\"\r\n\t\t/>\r\n\t\t<Global\r\n\t\t\tName=\"UicDir\"\r\n\t\t\tValue=\".\\GeneratedFiles\"\r\n\t\t/>\r\n\t</Globals>\r\n</VisualStudioProject>\r\n"
  },
  {
    "path": "Plugins/VHDLAnalyzer/VHDLSourceAnalyzer.vcxproj",
    "content": "﻿<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n<Project DefaultTargets=\"Build\" ToolsVersion=\"15.0\" xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">\r\n  <ItemGroup Label=\"ProjectConfigurations\">\r\n    <ProjectConfiguration Include=\"Debug|x64\">\r\n      <Configuration>Debug</Configuration>\r\n      <Platform>x64</Platform>\r\n    </ProjectConfiguration>\r\n    <ProjectConfiguration Include=\"Release|x64\">\r\n      <Configuration>Release</Configuration>\r\n      <Platform>x64</Platform>\r\n    </ProjectConfiguration>\r\n    <ProjectConfiguration Include=\"Template|x64\">\r\n      <Configuration>Template</Configuration>\r\n      <Platform>x64</Platform>\r\n    </ProjectConfiguration>\r\n  </ItemGroup>\r\n  <PropertyGroup Label=\"Globals\">\r\n    <ProjectGuid>{FD8026D5-50C6-4D30-B082-899FA4226C48}</ProjectGuid>\r\n    <Keyword>QtVS_v304</Keyword>\r\n    <WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>\r\n    <QtMsBuild Condition=\"'$(QtMsBuild)'=='' or !Exists('$(QtMsBuild)\\qt.targets')\">$(MSBuildProjectDirectory)\\QtMsBuild</QtMsBuild>\r\n  </PropertyGroup>\r\n  <Import Project=\"$(VCTargetsPath)\\Microsoft.Cpp.Default.props\" />\r\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Template|x64'\" Label=\"Configuration\">\r\n    <ConfigurationType>Application</ConfigurationType>\r\n    <PlatformToolset>v143</PlatformToolset>\r\n  </PropertyGroup>\r\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\" Label=\"Configuration\">\r\n    <ConfigurationType>DynamicLibrary</ConfigurationType>\r\n    <PlatformToolset>v143</PlatformToolset>\r\n  </PropertyGroup>\r\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\" Label=\"Configuration\">\r\n    <ConfigurationType>DynamicLibrary</ConfigurationType>\r\n    <PlatformToolset>v143</PlatformToolset>\r\n  </PropertyGroup>\r\n  <Import Project=\"$(VCTargetsPath)\\Microsoft.Cpp.props\" />\r\n  <Target Name=\"QtMsBuildNotFound\" BeforeTargets=\"CustomBuild;ClCompile\" Condition=\"!Exists('$(QtMsBuild)\\qt.targets') or !Exists('$(QtMsBuild)\\qt.props')\">\r\n    <Message Importance=\"High\" Text=\"QtMsBuild: could not locate qt.targets, qt.props; project may not build correctly.\" />\r\n  </Target>\r\n  <ImportGroup Label=\"ExtensionSettings\">\r\n  </ImportGroup>\r\n  <ImportGroup Condition=\"'$(Configuration)|$(Platform)'=='Template|x64'\" Label=\"PropertySheets\">\r\n    <Import Project=\"$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props\" Condition=\"exists('$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props')\" Label=\"LocalAppDataPlatform\" />\r\n  </ImportGroup>\r\n  <ImportGroup Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\" Label=\"PropertySheets\">\r\n    <Import Project=\"$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props\" Condition=\"exists('$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props')\" Label=\"LocalAppDataPlatform\" />\r\n  </ImportGroup>\r\n  <ImportGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\" Label=\"PropertySheets\">\r\n    <Import Project=\"$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props\" Condition=\"exists('$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props')\" Label=\"LocalAppDataPlatform\" />\r\n  </ImportGroup>\r\n  <PropertyGroup Label=\"UserMacros\" />\r\n  <ImportGroup Condition=\"Exists('$(QtMsBuild)\\qt_defaults.props')\">\r\n    <Import Project=\"$(QtMsBuild)\\qt_defaults.props\" />\r\n  </ImportGroup>\r\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Template|x64'\">\r\n    <OutDir>$(SolutionDir)executable\\Plugins\\</OutDir>\r\n    <IntDir>$(ProjectDir)\\$(Configuration)\\</IntDir>\r\n  </PropertyGroup>\r\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n    <OutDir>$(SolutionDir)executable\\Plugins\\</OutDir>\r\n    <IntDir>$(ProjectDir)\\$(Configuration)\\</IntDir>\r\n  </PropertyGroup>\r\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n    <OutDir>$(SolutionDir)executable\\Plugins\\</OutDir>\r\n    <IntDir>$(ProjectDir)\\$(Configuration)\\</IntDir>\r\n  </PropertyGroup>\r\n  <PropertyGroup Label=\"QtSettings\" Condition=\"'$(Configuration)|$(Platform)'=='Template|x64'\">\r\n    <QtInstall>6.2.4</QtInstall>\r\n    <QtModules>core;gui;widgets</QtModules>\r\n  </PropertyGroup>\r\n  <PropertyGroup Label=\"QtSettings\" Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n    <QtInstall>6.2.4</QtInstall>\r\n    <QtModules>core;gui;widgets</QtModules>\r\n  </PropertyGroup>\r\n  <PropertyGroup Label=\"QtSettings\" Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n    <QtInstall>6.2.4</QtInstall>\r\n    <QtModules>core;gui;widgets</QtModules>\r\n  </PropertyGroup>\r\n  <ImportGroup Condition=\"Exists('$(QtMsBuild)\\qt.props')\">\r\n    <Import Project=\"$(QtMsBuild)\\qt.props\" />\r\n  </ImportGroup>\r\n  <PropertyGroup>\r\n    <_ProjectFileVersion>10.0.40219.1</_ProjectFileVersion>\r\n  </PropertyGroup>\r\n  <ItemDefinitionGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n    <Midl>\r\n      <TargetEnvironment>X64</TargetEnvironment>\r\n    </Midl>\r\n    <ClCompile>\r\n      <AdditionalIncludeDirectories>.\\GeneratedFiles\\$(ConfigurationName);.\\GeneratedFiles;.\\GeneratedFiles\\$(Configuration);.\\;..\\..\\;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\r\n      <PreprocessorDefinitions>UNICODE;WIN32;QT_NO_DEBUG;NDEBUG;VHDLSOURCEANALYZER_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>\r\n      <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>\r\n      <TreatWChar_tAsBuiltInType>true</TreatWChar_tAsBuiltInType>\r\n      <DebugInformationFormat>\r\n      </DebugInformationFormat>\r\n      <MultiProcessorCompilation>true</MultiProcessorCompilation>\r\n      <AdditionalOptions>/Zc:__cplusplus %(AdditionalOptions)</AdditionalOptions>\r\n      <LanguageStandard>stdcpp17</LanguageStandard>\r\n    </ClCompile>\r\n    <Link>\r\n      <AdditionalDependencies>IPXACTmodels.lib;%(AdditionalDependencies)</AdditionalDependencies>\r\n      <OutputFile>$(OutDir)$(ProjectName).dll</OutputFile>\r\n      <AdditionalLibraryDirectories>..\\..\\executable;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>\r\n      <GenerateDebugInformation>false</GenerateDebugInformation>\r\n      <SubSystem>Windows</SubSystem>\r\n      <TargetMachine>MachineX64</TargetMachine>\r\n    </Link>\r\n    <PostBuildEvent>\r\n      <Command>\r\n      </Command>\r\n    </PostBuildEvent>\r\n    <QtMoc>\r\n      <ExecutionDescription>Moc'ing %(Identity)...</ExecutionDescription>\r\n      <DynamicSource>output</DynamicSource>\r\n      <QtMocDir>.\\GeneratedFiles\\$(ConfigurationName)</QtMocDir>\r\n      <QtMocFileName>moc_%(Filename).cpp</QtMocFileName>\r\n    </QtMoc>\r\n  </ItemDefinitionGroup>\r\n  <ItemDefinitionGroup Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n    <Midl>\r\n      <TargetEnvironment>X64</TargetEnvironment>\r\n    </Midl>\r\n    <ClCompile>\r\n      <Optimization>Disabled</Optimization>\r\n      <AdditionalIncludeDirectories>.\\GeneratedFiles\\$(ConfigurationName);.\\GeneratedFiles;.\\GeneratedFiles\\$(Configuration);.\\;..\\..\\;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\r\n      <PreprocessorDefinitions>UNICODE;WIN32;VHDLSOURCEANALYZER_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>\r\n      <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>\r\n      <TreatWChar_tAsBuiltInType>true</TreatWChar_tAsBuiltInType>\r\n      <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>\r\n      <MultiProcessorCompilation>true</MultiProcessorCompilation>\r\n      <LanguageStandard>stdcpp17</LanguageStandard>\r\n      <AdditionalOptions>/Zc:__cplusplus %(AdditionalOptions)</AdditionalOptions>\r\n    </ClCompile>\r\n    <Link>\r\n      <AdditionalDependencies>IPXACTmodelsd.lib;%(AdditionalDependencies)</AdditionalDependencies>\r\n      <OutputFile>$(OutDir)$(ProjectName).dll</OutputFile>\r\n      <AdditionalLibraryDirectories>..\\..\\executable;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>\r\n      <GenerateDebugInformation>true</GenerateDebugInformation>\r\n      <SubSystem>Windows</SubSystem>\r\n      <TargetMachine>MachineX64</TargetMachine>\r\n    </Link>\r\n    <PostBuildEvent>\r\n      <Command>\r\n      </Command>\r\n    </PostBuildEvent>\r\n    <QtMoc>\r\n      <ExecutionDescription>Moc'ing %(Identity)...</ExecutionDescription>\r\n      <DynamicSource>output</DynamicSource>\r\n      <QtMocDir>.\\GeneratedFiles\\$(ConfigurationName)</QtMocDir>\r\n      <QtMocFileName>moc_%(Filename).cpp</QtMocFileName>\r\n    </QtMoc>\r\n  </ItemDefinitionGroup>\r\n  <ItemDefinitionGroup Condition=\"'$(Configuration)|$(Platform)'=='Template|x64'\">\r\n    <ClCompile>\r\n      <PreprocessorDefinitions>%(PreprocessorDefinitions)</PreprocessorDefinitions>\r\n      <AdditionalIncludeDirectories>.\\GeneratedFiles\\$(ConfigurationName);.\\GeneratedFiles;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\r\n      <MultiProcessorCompilation>true</MultiProcessorCompilation>\r\n    </ClCompile>\r\n    <Link>\r\n      <AdditionalDependencies>%(AdditionalDependencies)</AdditionalDependencies>\r\n      <AdditionalLibraryDirectories>..\\..\\executable;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>\r\n    </Link>\r\n  </ItemDefinitionGroup>\r\n  <ItemGroup>\r\n    <ClCompile Include=\"VHDLSourceAnalyzer.cpp\" />\r\n  </ItemGroup>\r\n  <ItemGroup>\r\n    <QtMoc Include=\"VHDLSourceAnalyzer.h\">\r\n    </QtMoc>\r\n  </ItemGroup>\r\n  <ItemGroup>\r\n    <None Include=\"vhdlPlugin.json\" />\r\n  </ItemGroup>\r\n  <Import Project=\"$(VCTargetsPath)\\Microsoft.Cpp.targets\" />\r\n  <ImportGroup Condition=\"Exists('$(QtMsBuild)\\qt.targets')\">\r\n    <Import Project=\"$(QtMsBuild)\\qt.targets\" />\r\n  </ImportGroup>\r\n  <ImportGroup Label=\"ExtensionTargets\">\r\n  </ImportGroup>\r\n  <ProjectExtensions>\r\n    <VisualStudio>\r\n      <UserProperties QtVersion_x0020_Win32=\"4.8.3\" QtVersion_x0020_x64=\"4.8.3 x64\" />\r\n    </VisualStudio>\r\n  </ProjectExtensions>\r\n</Project>"
  },
  {
    "path": "Plugins/VHDLAnalyzer/VHDLSourceAnalyzer.vcxproj.filters",
    "content": "﻿<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n<Project ToolsVersion=\"4.0\" xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">\r\n  <ItemGroup>\r\n    <Filter Include=\"Source Files\">\r\n      <UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>\r\n      <Extensions>cpp;cxx;c;def</Extensions>\r\n    </Filter>\r\n    <Filter Include=\"Header Files\">\r\n      <UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>\r\n      <Extensions>h</Extensions>\r\n    </Filter>\r\n    <Filter Include=\"Form Files\">\r\n      <UniqueIdentifier>{99349809-55BA-4b9d-BF79-8FDBB0286EB3}</UniqueIdentifier>\r\n      <Extensions>ui</Extensions>\r\n    </Filter>\r\n    <Filter Include=\"Resource Files\">\r\n      <UniqueIdentifier>{D9D6E242-F8AF-46E4-B9FD-80ECBC20BA3E}</UniqueIdentifier>\r\n      <Extensions>qrc;*</Extensions>\r\n      <ParseFiles>false</ParseFiles>\r\n    </Filter>\r\n    <Filter Include=\"Generated Files\">\r\n      <UniqueIdentifier>{71ED8ED8-ACB9-4CE9-BBE1-E00B30144E11}</UniqueIdentifier>\r\n      <Extensions>moc;h;cpp</Extensions>\r\n      <SourceControlFiles>False</SourceControlFiles>\r\n    </Filter>\r\n    <Filter Include=\"Generated Files\\Release\">\r\n      <UniqueIdentifier>{fb8c7a1d-8581-4770-b517-851d4bdb78f7}</UniqueIdentifier>\r\n      <Extensions>cpp;moc</Extensions>\r\n      <SourceControlFiles>False</SourceControlFiles>\r\n    </Filter>\r\n    <Filter Include=\"Generated Files\\Debug\">\r\n      <UniqueIdentifier>{e5ea1b2e-c3de-43b6-847e-bade066d4737}</UniqueIdentifier>\r\n      <Extensions>cpp;moc</Extensions>\r\n      <SourceControlFiles>False</SourceControlFiles>\r\n    </Filter>\r\n  </ItemGroup>\r\n  <ItemGroup>\r\n    <ClCompile Include=\"VHDLSourceAnalyzer.cpp\">\r\n      <Filter>Source Files</Filter>\r\n    </ClCompile>\r\n    \r\n    \r\n  </ItemGroup>\r\n  <ItemGroup>\r\n    <QtMoc Include=\"VHDLSourceAnalyzer.h\">\r\n      <Filter>Header Files</Filter>\r\n    </QtMoc>\r\n  </ItemGroup>\r\n  <ItemGroup>\r\n    <None Include=\"vhdlPlugin.json\" />\r\n  </ItemGroup>\r\n</Project>"
  },
  {
    "path": "Plugins/VHDLAnalyzer/vhdlPlugin.json",
    "content": "\r\n{\r\n\t\"Keys\": [ \"VHDLSourceAnalyzer\" ]\r\n}"
  },
  {
    "path": "Plugins/VHDLGenerator/VHDLGenerator.json",
    "content": "{\n\t\"Keys\": [ \"VHDLGenerator\" ]\n}"
  },
  {
    "path": "Plugins/VHDLGenerator/VHDLGenerator.pri",
    "content": "# ----------------------------------------------------\n# This file is generated by the Qt Visual Studio Tools.\n# ------------------------------------------------------\n\n\nHEADERS += ../../IPXACTmodels/utilities/ComponentSearch.h \\\n    ../../IPXACTmodels/utilities/Search.h \\\n    ../PluginSystem/GeneratorPlugin/ViewSelection.h \\\n    ./vhdlcomponentdeclaration.h \\\n    ./vhdlconnectionendpoint.h \\\n    ./vhdlgeneral.h \\\n    ./vhdlgeneric.h \\\n    ./vhdlobject.h \\\n    ./vhdlport.h \\\n    ./vhdlportmap.h \\\n    ./vhdlportsorter.h \\\n    ./vhdlsignal.h \\\n    ./VhdlTypedObject.h \\\n    ./VHDLGenerator_global.h \\\n    ../PluginSystem/GeneratorPlugin/ViewSelectionWidget.h \\\n    ./VHDLGeneratorDialog.h \\\n    ./VHDLGeneratorPlugin.h \\\n    ./vhdlgenerator2.h \\\n    ./vhdlcomponentinstance.h\nSOURCES += ../../IPXACTmodels/utilities/ComponentSearch.cpp \\\n    ../PluginSystem/GeneratorPlugin/ViewSelection.cpp \\\n    ../PluginSystem/GeneratorPlugin/ViewSelectionWidget.cpp \\\n    ./vhdlcomponentdeclaration.cpp \\\n    ./vhdlcomponentinstance.cpp \\\n    ./vhdlconnectionendpoint.cpp \\\n    ./vhdlgeneral.cpp \\\n    ./vhdlgenerator2.cpp \\\n    ./VHDLGeneratorDialog.cpp \\\n    ./VHDLGeneratorPlugin.cpp \\\n    ./vhdlgeneric.cpp \\\n    ./vhdlobject.cpp \\\n    ./vhdlport.cpp \\\n    ./vhdlportmap.cpp \\\n    ./vhdlportsorter.cpp \\\n    ./vhdlsignal.cpp \\\n    ./VhdlTypedObject.cpp\nRESOURCES += VHDLGenerator.qrc\n"
  },
  {
    "path": "Plugins/VHDLGenerator/VHDLGenerator.pro",
    "content": "# ----------------------------------------------------\n# This file is generated by the Qt Visual Studio Add-in.\n# ------------------------------------------------------\n\nTEMPLATE = lib\n\nQT += core xml widgets gui\nCONFIG += c++11 plugin\n\nDEFINES += VHDLGENERATOR_LIB\n\nINCLUDEPATH += ./../.. \\\n    ./GeneratedFiles \\\n    .\n\nCONFIG(debug, debug|release) {\n    # debug mode\n    LIBS += \\\n        -L../../executable -lIPXACTmodelsd \\\n        -L../../executable -lKactusAPId\n\n    MOC_DIR += ./GeneratedFiles/Debug\n    OBJECTS_DIR += Debug\n    TARGET = VHDLGeneratord\n\n} else {\n    # release mode \n    LIBS += \\\n        -L../../executable -lIPXACTmodels \\\n        -L../../executable -lKactusAPI\n    \n    MOC_DIR += ./GeneratedFiles/Release\n    OBJECTS_DIR += Release\n    TARGET = VHDLGenerator\n}\n\nDESTDIR = ../../executable/Plugins\n\nDEPENDPATH += .\nUI_DIR += ./GeneratedFiles\nRCC_DIR += ./GeneratedFiles\n\ninclude(VHDLGenerator.pri)\n\ntarget.path = $$plugin_path\nINSTALLS += target\n"
  },
  {
    "path": "Plugins/VHDLGenerator/VHDLGenerator.qrc",
    "content": "<RCC>\n    <qresource prefix=\"/icons\">\n        <file>VHDLGenerator.png</file>\n    </qresource>\n</RCC>\n"
  },
  {
    "path": "Plugins/VHDLGenerator/VHDLGenerator.vcxproj",
    "content": "﻿<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<Project DefaultTargets=\"Build\" ToolsVersion=\"15.0\" xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">\n  <ItemGroup Label=\"ProjectConfigurations\">\n    <ProjectConfiguration Include=\"Debug|x64\">\n      <Configuration>Debug</Configuration>\n      <Platform>x64</Platform>\n    </ProjectConfiguration>\n    <ProjectConfiguration Include=\"Release|x64\">\n      <Configuration>Release</Configuration>\n      <Platform>x64</Platform>\n    </ProjectConfiguration>\n  </ItemGroup>\n  <PropertyGroup Label=\"Globals\">\n    <ProjectGuid>{733888AA-F653-4A92-817D-25EE4AB2BE54}</ProjectGuid>\n    <Keyword>QtVS_v304</Keyword>\n    <WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>\n    <QtMsBuild Condition=\"'$(QtMsBuild)'=='' or !Exists('$(QtMsBuild)\\qt.targets')\">$(MSBuildProjectDirectory)\\QtMsBuild</QtMsBuild>\n  </PropertyGroup>\n  <Import Project=\"$(VCTargetsPath)\\Microsoft.Cpp.Default.props\" />\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\" Label=\"Configuration\">\n    <ConfigurationType>DynamicLibrary</ConfigurationType>\n    <PlatformToolset>v143</PlatformToolset>\n  </PropertyGroup>\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\" Label=\"Configuration\">\n    <ConfigurationType>DynamicLibrary</ConfigurationType>\n    <PlatformToolset>v143</PlatformToolset>\n  </PropertyGroup>\n  <Import Project=\"$(VCTargetsPath)\\Microsoft.Cpp.props\" />\n  <Target Name=\"QtMsBuildNotFound\" BeforeTargets=\"CustomBuild;ClCompile\" Condition=\"!Exists('$(QtMsBuild)\\qt.targets') or !Exists('$(QtMsBuild)\\qt.props')\">\n    <Message Importance=\"High\" Text=\"QtMsBuild: could not locate qt.targets, qt.props; project may not build correctly.\" />\n  </Target>\n  <ImportGroup Label=\"ExtensionSettings\">\n  </ImportGroup>\n  <ImportGroup Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\" Label=\"PropertySheets\">\n    <Import Project=\"$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props\" Condition=\"exists('$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props')\" Label=\"LocalAppDataPlatform\" />\n  </ImportGroup>\n  <ImportGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\" Label=\"PropertySheets\">\n    <Import Project=\"$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props\" Condition=\"exists('$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props')\" Label=\"LocalAppDataPlatform\" />\n  </ImportGroup>\n  <PropertyGroup Label=\"UserMacros\" />\n  <ImportGroup Condition=\"Exists('$(QtMsBuild)\\qt_defaults.props')\">\n    <Import Project=\"$(QtMsBuild)\\qt_defaults.props\" />\n  </ImportGroup>\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\n    <OutDir>$(SolutionDir)executable\\Plugins\\</OutDir>\n  </PropertyGroup>\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\n    <OutDir>$(SolutionDir)executable\\Plugins\\</OutDir>\n  </PropertyGroup>\n  <PropertyGroup Label=\"QtSettings\" Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\n    <QtInstall>6.2.4</QtInstall>\n    <QtModules>core;gui;widgets;xml</QtModules>\n  </PropertyGroup>\n  <PropertyGroup Label=\"QtSettings\" Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\n    <QtInstall>6.2.4</QtInstall>\n    <QtModules>core;gui;widgets;xml</QtModules>\n  </PropertyGroup>\n  <ImportGroup Condition=\"Exists('$(QtMsBuild)\\qt.props')\">\n    <Import Project=\"$(QtMsBuild)\\qt.props\" />\n  </ImportGroup>\n  <PropertyGroup>\n    <_ProjectFileVersion>10.0.40219.1</_ProjectFileVersion>\n  </PropertyGroup>\n  <ItemDefinitionGroup Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\n    <ClCompile>\n      <PreprocessorDefinitions>VHDLGENERATOR_LIB;UNICODE;WIN32;WIN64;%(PreprocessorDefinitions)</PreprocessorDefinitions>\n      <AdditionalIncludeDirectories>.\\GeneratedFiles\\$(ConfigurationName);.\\GeneratedFiles;.\\..\\..;.;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\n      <Optimization>Disabled</Optimization>\n      <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>\n      <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>\n      <TreatWChar_tAsBuiltInType>true</TreatWChar_tAsBuiltInType>\n      <MultiProcessorCompilation>true</MultiProcessorCompilation>\n      <LanguageStandard>stdcpp17</LanguageStandard>\n      <AdditionalOptions>/Zc:__cplusplus %(AdditionalOptions)</AdditionalOptions>\n    </ClCompile>\n    <Link>\n      <SubSystem>Windows</SubSystem>\n      <OutputFile>$(OutDir)\\$(ProjectName).dll</OutputFile>\n      <AdditionalLibraryDirectories>..\\..\\executable;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>\n      <GenerateDebugInformation>true</GenerateDebugInformation>\n      <AdditionalDependencies>IPXACTmodelsd.lib;KactusAPId.lib;%(AdditionalDependencies)</AdditionalDependencies>\n      <TargetMachine>MachineX64</TargetMachine>\n      <AdditionalOptions> /SUBSYSTEM:WINDOWS</AdditionalOptions>\n    </Link>\n    <QtMoc>\n      <ExecutionDescription>Moc'ing %(Identity)...</ExecutionDescription>\n      <DynamicSource>output</DynamicSource>\n      <QtMocDir>.\\GeneratedFiles\\$(ConfigurationName)</QtMocDir>\n      <QtMocFileName>moc_%(Filename).cpp</QtMocFileName>\n    </QtMoc>\n    <QtRcc>\n      <InitFuncName>%(Filename)</InitFuncName>\n      <Compression>default</Compression>\n      <NoCompression>true</NoCompression>\n      <ExecutionDescription>Rcc'ing %(Identity)...</ExecutionDescription>\n      <QtRccDir>.\\GeneratedFiles</QtRccDir>\n      <QtRccFileName>qrc_%(Filename).cpp</QtRccFileName>\n    </QtRcc>\n  </ItemDefinitionGroup>\n  <ItemDefinitionGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\n    <ClCompile>\n      <PreprocessorDefinitions>VHDLGENERATOR_LIB;NDEBUG;QT_NO_DEBUG;UNICODE;WIN32;WIN64;%(PreprocessorDefinitions)</PreprocessorDefinitions>\n      <AdditionalIncludeDirectories>.\\GeneratedFiles\\$(ConfigurationName);.\\GeneratedFiles;.\\..\\..;.;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\n      <DebugInformationFormat>\n      </DebugInformationFormat>\n      <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>\n      <TreatWChar_tAsBuiltInType>true</TreatWChar_tAsBuiltInType>\n      <MultiProcessorCompilation>true</MultiProcessorCompilation>\n      <AdditionalOptions>/Zc:__cplusplus %(AdditionalOptions)</AdditionalOptions>\n      <LanguageStandard>stdcpp17</LanguageStandard>\n    </ClCompile>\n    <Link>\n      <SubSystem>Windows</SubSystem>\n      <OutputFile>$(OutDir)\\$(ProjectName).dll</OutputFile>\n      <AdditionalLibraryDirectories>..\\..\\executable;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>\n      <GenerateDebugInformation>false</GenerateDebugInformation>\n      <AdditionalDependencies>IPXACTmodels.lib;KactusAPI.lib;%(AdditionalDependencies)</AdditionalDependencies>\n      <TargetMachine>MachineX64</TargetMachine>\n      <AdditionalOptions> /SUBSYSTEM:WINDOWS</AdditionalOptions>\n    </Link>\n    <QtMoc>\n      <ExecutionDescription>Moc'ing %(Identity)...</ExecutionDescription>\n      <DynamicSource>output</DynamicSource>\n      <QtMocDir>.\\GeneratedFiles\\$(ConfigurationName)</QtMocDir>\n      <QtMocFileName>moc_%(Filename).cpp</QtMocFileName>\n    </QtMoc>\n    <QtRcc>\n      <InitFuncName>%(Filename)</InitFuncName>\n      <Compression>default</Compression>\n      <NoCompression>true</NoCompression>\n      <ExecutionDescription>Rcc'ing %(Identity)...</ExecutionDescription>\n      <QtRccDir>.\\GeneratedFiles</QtRccDir>\n      <QtRccFileName>qrc_%(Filename).cpp</QtRccFileName>\n    </QtRcc>\n  </ItemDefinitionGroup>\n  <ItemGroup>\n    <ClCompile Include=\"..\\..\\IPXACTmodels\\utilities\\ComponentSearch.cpp\" />\n    <ClCompile Include=\"..\\PluginSystem\\GeneratorPlugin\\AddToFilesetWidget.cpp\" />\n    <ClCompile Include=\"..\\PluginSystem\\GeneratorPlugin\\ViewSelection.cpp\" />\n    <ClCompile Include=\"..\\PluginSystem\\GeneratorPlugin\\ViewSelectionWidget.cpp\" />\n    <ClCompile Include=\"vhdlcomponentdeclaration.cpp\" />\n    <ClCompile Include=\"vhdlcomponentinstance.cpp\" />\n    <ClCompile Include=\"vhdlconnectionendpoint.cpp\" />\n    <ClCompile Include=\"vhdlgeneral.cpp\" />\n    <ClCompile Include=\"vhdlgenerator2.cpp\" />\n    <ClCompile Include=\"VHDLGeneratorDialog.cpp\" />\n    <ClCompile Include=\"VHDLGeneratorPlugin.cpp\" />\n    <ClCompile Include=\"vhdlgeneric.cpp\" />\n    <ClCompile Include=\"vhdlobject.cpp\" />\n    <ClCompile Include=\"vhdlport.cpp\" />\n    <ClCompile Include=\"vhdlportmap.cpp\" />\n    <ClCompile Include=\"vhdlportsorter.cpp\" />\n    <ClCompile Include=\"vhdlsignal.cpp\" />\n    <ClCompile Include=\"VhdlTypedObject.cpp\" />\n  </ItemGroup>\n  <ItemGroup>\n    <ClInclude Include=\"..\\..\\IPXACTmodels\\utilities\\ComponentSearch.h\" />\n    <ClInclude Include=\"..\\..\\IPXACTmodels\\utilities\\Search.h\" />\n    <QtMoc Include=\"..\\PluginSystem\\GeneratorPlugin\\AddToFilesetWidget.h\" />\n    <ClInclude Include=\"..\\PluginSystem\\GeneratorPlugin\\ViewSelection.h\" />\n    <QtMoc Include=\"..\\PluginSystem\\GeneratorPlugin\\ViewSelectionWidget.h\">\n    </QtMoc>\n    <ClInclude Include=\"vhdlcomponentdeclaration.h\" />\n    <ClInclude Include=\"vhdlconnectionendpoint.h\" />\n    <ClInclude Include=\"vhdlgeneral.h\" />\n    <QtMoc Include=\"VHDLGeneratorDialog.h\">\n    </QtMoc>\n    <QtMoc Include=\"VHDLGeneratorPlugin.h\">\n    </QtMoc>\n    <ClInclude Include=\"vhdlgeneric.h\" />\n    <ClInclude Include=\"vhdlobject.h\" />\n    <ClInclude Include=\"vhdlport.h\" />\n    <QtMoc Include=\"vhdlgenerator2.h\">\n    </QtMoc>\n    <QtMoc Include=\"vhdlcomponentinstance.h\">\n    </QtMoc>\n    <ClInclude Include=\"vhdlportmap.h\" />\n    <ClInclude Include=\"vhdlportsorter.h\" />\n    <ClInclude Include=\"vhdlsignal.h\" />\n    <ClInclude Include=\"VhdlTypedObject.h\" />\n    <ClInclude Include=\"VHDLGenerator_global.h\" />\n  </ItemGroup>\n  <ItemGroup>\n    <QtRcc Include=\"VHDLGenerator.qrc\">\n    </QtRcc>\n  </ItemGroup>\n  <ItemGroup>\n    <None Include=\"VHDLGenerator.json\" />\n    <None Include=\"VHDLGenerator.png\">\n      <ExcludedFromBuild Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">true</ExcludedFromBuild>\n      <ExcludedFromBuild Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">true</ExcludedFromBuild>\n    </None>\n  </ItemGroup>\n  <Import Project=\"$(VCTargetsPath)\\Microsoft.Cpp.targets\" />\n  <ImportGroup Condition=\"Exists('$(QtMsBuild)\\qt.targets')\">\n    <Import Project=\"$(QtMsBuild)\\qt.targets\" />\n  </ImportGroup>\n  <ImportGroup Label=\"ExtensionTargets\">\n  </ImportGroup>\n  <ProjectExtensions>\n    <VisualStudio>\n      <UserProperties />\n    </VisualStudio>\n  </ProjectExtensions>\n</Project>"
  },
  {
    "path": "Plugins/VHDLGenerator/VHDLGenerator.vcxproj.filters",
    "content": "﻿<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<Project ToolsVersion=\"4.0\" xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">\n  <ItemGroup>\n    <Filter Include=\"Source Files\">\n      <UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>\n      <Extensions>cpp;cxx;c;def</Extensions>\n    </Filter>\n    <Filter Include=\"Header Files\">\n      <UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>\n      <Extensions>h</Extensions>\n    </Filter>\n    <Filter Include=\"Resource Files\">\n      <UniqueIdentifier>{D9D6E242-F8AF-46E4-B9FD-80ECBC20BA3E}</UniqueIdentifier>\n      <Extensions>qrc;*</Extensions>\n      <ParseFiles>false</ParseFiles>\n    </Filter>\n    <Filter Include=\"Generated Files\">\n      <UniqueIdentifier>{71ED8ED8-ACB9-4CE9-BBE1-E00B30144E11}</UniqueIdentifier>\n      <Extensions>moc;h;cpp</Extensions>\n      <SourceControlFiles>False</SourceControlFiles>\n    </Filter>\n    <Filter Include=\"Generated Files\\Debug\">\n      <UniqueIdentifier>{1cab6335-8bf0-428b-b527-f4a97b93cf03}</UniqueIdentifier>\n      <Extensions>cpp;moc</Extensions>\n      <SourceControlFiles>False</SourceControlFiles>\n    </Filter>\n    <Filter Include=\"Generated Files\\Release\">\n      <UniqueIdentifier>{bcbe60b9-a5b8-4d37-b79f-8c561fe0c86a}</UniqueIdentifier>\n      <Extensions>cpp;moc</Extensions>\n      <SourceControlFiles>False</SourceControlFiles>\n    </Filter>\n  </ItemGroup>\n  <ItemGroup>\n    <ClCompile Include=\"vhdlconnectionendpoint.cpp\">\n      <Filter>Source Files</Filter>\n    </ClCompile>\n    <ClCompile Include=\"vhdlgeneral.cpp\">\n      <Filter>Source Files</Filter>\n    </ClCompile>\n    <ClCompile Include=\"vhdlgenerator2.cpp\">\n      <Filter>Source Files</Filter>\n    </ClCompile>\n    <ClCompile Include=\"vhdlgeneric.cpp\">\n      <Filter>Source Files</Filter>\n    </ClCompile>\n    <ClCompile Include=\"vhdlobject.cpp\">\n      <Filter>Source Files</Filter>\n    </ClCompile>\n    <ClCompile Include=\"vhdlport.cpp\">\n      <Filter>Source Files</Filter>\n    </ClCompile>\n    <ClCompile Include=\"vhdlportmap.cpp\">\n      <Filter>Source Files</Filter>\n    </ClCompile>\n    <ClCompile Include=\"vhdlportsorter.cpp\">\n      <Filter>Source Files</Filter>\n    </ClCompile>\n    <ClCompile Include=\"vhdlsignal.cpp\">\n      <Filter>Source Files</Filter>\n    </ClCompile>\n    <ClCompile Include=\"VhdlTypedObject.cpp\">\n      <Filter>Source Files</Filter>\n    </ClCompile>\n    <ClCompile Include=\"vhdlcomponentdeclaration.cpp\">\n      <Filter>Source Files</Filter>\n    </ClCompile>\n    <ClCompile Include=\"vhdlcomponentinstance.cpp\">\n      <Filter>Source Files</Filter>\n    </ClCompile>\n    <ClCompile Include=\"VHDLGeneratorDialog.cpp\">\n      <Filter>Source Files</Filter>\n    </ClCompile>\n    <ClCompile Include=\"..\\PluginSystem\\GeneratorPlugin\\ViewSelectionWidget.cpp\">\n      <Filter>Source Files</Filter>\n    </ClCompile>\n    <ClCompile Include=\"..\\PluginSystem\\GeneratorPlugin\\ViewSelection.cpp\">\n      <Filter>Source Files</Filter>\n    </ClCompile>\n    <ClCompile Include=\"VHDLGeneratorPlugin.cpp\">\n      <Filter>Source Files</Filter>\n    </ClCompile>\n    <ClCompile Include=\"..\\..\\IPXACTmodels\\utilities\\ComponentSearch.cpp\">\n      <Filter>Source Files</Filter>\n    </ClCompile>\n    <ClCompile Include=\"..\\PluginSystem\\GeneratorPlugin\\AddToFilesetWidget.cpp\">\n      <Filter>Source Files</Filter>\n    </ClCompile>\n  </ItemGroup>\n  <ItemGroup>\n    <ClInclude Include=\"VHDLGenerator_global.h\">\n      <Filter>Header Files</Filter>\n    </ClInclude>\n    <ClInclude Include=\"vhdlportmap.h\">\n      <Filter>Header Files</Filter>\n    </ClInclude>\n    <ClInclude Include=\"vhdlportsorter.h\">\n      <Filter>Header Files</Filter>\n    </ClInclude>\n    <ClInclude Include=\"vhdlsignal.h\">\n      <Filter>Header Files</Filter>\n    </ClInclude>\n    <ClInclude Include=\"VhdlTypedObject.h\">\n      <Filter>Header Files</Filter>\n    </ClInclude>\n    <ClInclude Include=\"vhdlcomponentdeclaration.h\">\n      <Filter>Header Files</Filter>\n    </ClInclude>\n    <ClInclude Include=\"vhdlconnectionendpoint.h\">\n      <Filter>Header Files</Filter>\n    </ClInclude>\n    <ClInclude Include=\"vhdlgeneral.h\">\n      <Filter>Header Files</Filter>\n    </ClInclude>\n    <ClInclude Include=\"vhdlgeneric.h\">\n      <Filter>Header Files</Filter>\n    </ClInclude>\n    <ClInclude Include=\"vhdlobject.h\">\n      <Filter>Header Files</Filter>\n    </ClInclude>\n    <ClInclude Include=\"vhdlport.h\">\n      <Filter>Header Files</Filter>\n    </ClInclude>\n    <ClInclude Include=\"..\\PluginSystem\\GeneratorPlugin\\ViewSelection.h\">\n      <Filter>Header Files</Filter>\n    </ClInclude>\n    <ClInclude Include=\"..\\..\\IPXACTmodels\\utilities\\ComponentSearch.h\">\n      <Filter>Header Files</Filter>\n    </ClInclude>\n    <ClInclude Include=\"..\\..\\IPXACTmodels\\utilities\\Search.h\">\n      <Filter>Header Files</Filter>\n    </ClInclude>\n  </ItemGroup>\n  <ItemGroup>\n    <QtRcc Include=\"VHDLGenerator.qrc\">\n      <Filter>Resource Files</Filter>\n    </QtRcc>\n    <QtMoc Include=\"vhdlcomponentinstance.h\">\n      <Filter>Header Files</Filter>\n    </QtMoc>\n    <QtMoc Include=\"vhdlgenerator2.h\">\n      <Filter>Header Files</Filter>\n    </QtMoc>\n    <QtMoc Include=\"VHDLGeneratorDialog.h\">\n      <Filter>Header Files</Filter>\n    </QtMoc>\n    <QtMoc Include=\"..\\PluginSystem\\GeneratorPlugin\\ViewSelectionWidget.h\">\n      <Filter>Header Files</Filter>\n    </QtMoc>\n    <QtMoc Include=\"VHDLGeneratorPlugin.h\">\n      <Filter>Header Files</Filter>\n    </QtMoc>\n  </ItemGroup>\n  <ItemGroup>\n    <None Include=\"VHDLGenerator.png\">\n      <Filter>Resource Files</Filter>\n    </None>\n    <None Include=\"VHDLGenerator.json\">\n      <Filter>Resource Files</Filter>\n    </None>\n  </ItemGroup>\n  <ItemGroup>\n    <QtMoc Include=\"..\\PluginSystem\\GeneratorPlugin\\AddToFilesetWidget.h\">\n      <Filter>Header Files</Filter>\n    </QtMoc>\n  </ItemGroup>\n</Project>"
  },
  {
    "path": "Plugins/VHDLGenerator/VHDLGeneratorDialog.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: VHDLGeneratorDialog.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Esko Pekkarinen\n// Date: 13.11.2017\n//\n// Description:\n// Dialog for setting VHDL generation options.\n//-----------------------------------------------------------------------------\n\n#include \"VHDLGeneratorDialog.h\"\n\n#include <QDialogButtonBox>\n#include <QFileDialog>\n#include <QFormLayout>\n#include <QGridLayout>\n#include <QGroupBox>\n#include <QHBoxLayout>\n#include <QVBoxLayout>\n#include <QLabel>\n#include <QLineEdit>\n#include <QPushButton>\n\n//-----------------------------------------------------------------------------\n// Function: VHDLGeneratorDialog::VHDLGeneratorDialog()\n//-----------------------------------------------------------------------------\nVHDLGeneratorDialog::VHDLGeneratorDialog(QSharedPointer<ViewSelection> viewConfiguration, \n    QString const& defaultPath,\n    QWidget* parent): QDialog(parent),\n    viewSelector_(new ViewSelectionWidget(viewConfiguration, this)),\n    fileEditor_(new QLineEdit(this))\n{\n    setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);\n\n    fileEditor_->setText(defaultPath);\n\n    setupLayout();\n}\n\n//-----------------------------------------------------------------------------\n// Function: VHDLGeneratorDialog::~VHDLGeneratorDialog()\n//-----------------------------------------------------------------------------\nVHDLGeneratorDialog::~VHDLGeneratorDialog()\n{\n}\n\n\n//-----------------------------------------------------------------------------\n// Function: VHDLGeneratorDialog::getOutputPath()\n//-----------------------------------------------------------------------------\nQString VHDLGeneratorDialog::getOutputPath() const\n{\n    return fileEditor_->text();\n}\n\n//-----------------------------------------------------------------------------\n// Function: VHDLGeneratorDialog::accept()\n//-----------------------------------------------------------------------------\nvoid VHDLGeneratorDialog::accept()\n{\n    if (fileEditor_->text().isEmpty())\n    {\n        return;\n    }\n\n    QDialog::accept();\n}\n\n//-----------------------------------------------------------------------------\n// Function: VHDLGeneratorDialog::onBrowse()\n//-----------------------------------------------------------------------------\nvoid VHDLGeneratorDialog::onBrowse()\n{\n    QString filePath = QFileDialog::getSaveFileName(this, tr(\"Select output file for generation\"), \n        fileEditor_->text(), \n        QStringLiteral(\"VHDL files (*.vhd)\"));\n\n    if (!filePath.isEmpty())\n    {\n        fileEditor_->setText(filePath);\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: VHDLGeneratorDialog::setupLayout()\n//-----------------------------------------------------------------------------\nvoid VHDLGeneratorDialog::setupLayout()\n{\n    QPushButton* browseButton = new QPushButton(tr(\"Browse...\"), this);\n\n    QHBoxLayout* fileLayout = new QHBoxLayout();\n    fileLayout->addWidget(new QLabel(tr(\"Output file:\"), this));\n    fileLayout->addWidget(fileEditor_);\n    fileLayout->addWidget(browseButton);\n    \n    QGroupBox* settingsGroup = new QGroupBox(tr(\"Settings\"), this);\n    QVBoxLayout* settingsLayout = new QVBoxLayout(settingsGroup);\n\n    settingsLayout->addWidget(viewSelector_);\n    settingsLayout->addLayout(fileLayout);\n\n    QDialogButtonBox* buttonBox = new QDialogButtonBox(Qt::Horizontal, this);\n    buttonBox->addButton(tr(\"Write file\"), QDialogButtonBox::AcceptRole);\n    buttonBox->addButton(QDialogButtonBox::Cancel);\n\n    QVBoxLayout* topLayout = new QVBoxLayout(this);  \n    topLayout->addWidget(settingsGroup);\n    topLayout->addWidget(buttonBox);\n\n    connect(browseButton, SIGNAL(clicked(bool)), this, SLOT(onBrowse()), Qt::UniqueConnection);\n    connect(buttonBox, SIGNAL(accepted()), this, SLOT(accept()), Qt::UniqueConnection);\n    connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject()), Qt::UniqueConnection);\n}\n"
  },
  {
    "path": "Plugins/VHDLGenerator/VHDLGeneratorDialog.h",
    "content": "//-----------------------------------------------------------------------------\n// File: VHDLGeneratorDialog.h\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Esko Pekkarinen\n// Date: 13.11.2017\n//\n// Description:\n// Dialog for setting VHDL generation options.\n//-----------------------------------------------------------------------------\n\n#ifndef VHDLGENERATORDIALOG_H\n#define VHDLGENERATORDIALOG_H\n\n#include <QDialog>\n#include <QComboBox>\n#include <QLineEdit>\n\n#include <Plugins/PluginSystem/GeneratorPlugin/ViewSelectionWidget.h>\n\nclass VHDLGeneratorDialog: public QDialog\n{\n    Q_OBJECT\npublic:\n    \n\n\t//! The constructor.\n\tVHDLGeneratorDialog(QSharedPointer<ViewSelection> viewConfiguration,\n            QString const& defaultPath,\n            QWidget* parent);\n\n\t//! The destructor.\n\tvirtual ~VHDLGeneratorDialog();\n\n    QString getOutputPath() const;\npublic slots:\n\n    void accept();\n\nprivate slots:\n\n    void onBrowse();\n\nprivate:\n\n\t// Disable copying.\n\tVHDLGeneratorDialog(VHDLGeneratorDialog const& rhs);\n\tVHDLGeneratorDialog& operator=(VHDLGeneratorDialog const& rhs);\n\n    void setupLayout();\n\n    ViewSelectionWidget* viewSelector_;\n\n    QLineEdit* fileEditor_;\n\n};\n\n#endif // VHDLGENERATORDIALOG_H\n"
  },
  {
    "path": "Plugins/VHDLGenerator/VHDLGeneratorPlugin.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: VHDLGenerator.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Esko Pekkarinen\n// Date: 13.11.2017\n//\n// Description:\n// Kactus2 plugin for VHDL file generation.\n//-----------------------------------------------------------------------------\n\n#include \"VHDLGeneratorPlugin.h\"\n\n#include \"vhdlgenerator2.h\"\n#include \"VHDLGeneratorDialog.h\"\n\n#include <KactusAPI/include/LibraryInterface.h>\n\n#include <IPXACTmodels/Component/Component.h>\n\n#include <Plugins/PluginSystem/GeneratorPlugin/ViewSelection.h>\n#include <Plugins/common/HDLParser/HDLCommandLineParser.h>\n\n#include <KactusAPI/include/ComponentParameterFinder.h>\n#include <KactusAPI/include/IPXactSystemVerilogParser.h>\n#include <KactusAPI/include/FileHandler.h>\n\n#include <QCoreApplication>\n#include <QFileDialog>\n#include <QFileInfo>\n#include <QMessageBox>\n\n//-----------------------------------------------------------------------------\n// Function: VHDLGeneratorPlugin::VHDLGeneratorPlugin()\n//-----------------------------------------------------------------------------\nVHDLGeneratorPlugin::VHDLGeneratorPlugin() : QObject(0), utility_(0), generationSettings_()\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: VHDLGeneratorPlugin::getName()\n//----------------------------------------------------------------------------\nQString VHDLGeneratorPlugin::getName() const\n{\n    return \"VHDL Generator\";\n}\n\n//-----------------------------------------------------------------------------\n// Function: VHDLGeneratorPlugin::getVersion()\n//-----------------------------------------------------------------------------\nQString VHDLGeneratorPlugin::getVersion() const\n{\n    return \"1.4\";\n}\n\n//-----------------------------------------------------------------------------\n// Function: VHDLGeneratorPlugin::getDescription()\n//-----------------------------------------------------------------------------\nQString VHDLGeneratorPlugin::getDescription() const\n{\n    return \"Generates a VHDL entity for a component or a structural description of a HW design.\";\n}\n\n//-----------------------------------------------------------------------------\n// Function: VHDLGeneratorPlugin::getVendor()\n//-----------------------------------------------------------------------------\nQString VHDLGeneratorPlugin::getVendor() const\n{\n    return tr(\"Tampere University (tuni.fi)\");\n}\n\n//-----------------------------------------------------------------------------\n// Function: VHDLGeneratorPlugin::getLicense()\n//-----------------------------------------------------------------------------\nQString VHDLGeneratorPlugin::getLicense() const\n{\n    return tr(\"GPL2\");\n}\n\n//-----------------------------------------------------------------------------\n// Function: VHDLGeneratorPlugin::getLicenseHolder()\n//-----------------------------------------------------------------------------\nQString VHDLGeneratorPlugin::getLicenseHolder() const\n{\n    return tr(\"Public\");\n}\n\n//-----------------------------------------------------------------------------\n// Function: VHDLGeneratorPlugin::getSettingsWidget()\n//-----------------------------------------------------------------------------\nQWidget* VHDLGeneratorPlugin::getSettingsWidget()\n{\n    return nullptr;\n}\n\n//-----------------------------------------------------------------------------\n// Function: VHDLGeneratorPlugin::getSettingsModel()\n//-----------------------------------------------------------------------------\nPluginSettingsModel* VHDLGeneratorPlugin::getSettingsModel()\n{\n    return nullptr;\n}\n\n//-----------------------------------------------------------------------------\n// Function: VHDLGeneratorPlugin::getIcon()\n//-----------------------------------------------------------------------------\nQIcon VHDLGeneratorPlugin::getIcon() const\n{\n    return QIcon(\":icons/VHDLGenerator.png\");\n}\n\n//-----------------------------------------------------------------------------\n// Function: VHDLGeneratorPlugin::checkGeneratorSupport()\n//-----------------------------------------------------------------------------\nbool VHDLGeneratorPlugin::checkGeneratorSupport(QSharedPointer<Component const> component,\n    QSharedPointer<Design const> /*design*/,\n    QSharedPointer<DesignConfiguration const> /*designConfiguration*/) const\n{\n    return component && component->getImplementation() == KactusAttribute::HW;\n}\n\n//-----------------------------------------------------------------------------\n// Function: VHDLGeneratorPlugin::runGenerator()\n//-----------------------------------------------------------------------------\nvoid VHDLGeneratorPlugin::runGenerator(IPluginUtility* utility, \n    QSharedPointer<Component> component,\n    QSharedPointer<Design> /*design*/,\n    QSharedPointer<DesignConfiguration> /*designConfiguration*/)\n{\n    utility_ = utility;\n\n    QFileInfo targetInfo(utility_->getLibraryInterface()->getPath(component->getVlnv()));\n\n    const bool saveToFileset = true;\n    QSharedPointer<ViewSelection> viewSettings(new ViewSelection(QStringLiteral(\"vhdl\"), saveToFileset,\n        QString(), &generationSettings_, component->getViews(), component->getComponentInstantiations(),\n        component->getFileSets()));\n\n    QString suggestedPath = targetInfo.absolutePath();\n    suggestedPath.append(QLatin1Char('/'));\n    suggestedPath.append(findEntityName(component, viewSettings->getViewName()));\n    suggestedPath.append(QStringLiteral(\".vhd\"));\n\n    VHDLGeneratorDialog dialog(viewSettings, suggestedPath, utility->getParentWidget());\n\n    if (dialog.exec() == QDialog::Accepted)\n    {\n        generate(component, dialog.getOutputPath(), viewSettings);\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: VHDLGeneratorPlugin::getOutputFormat()\n//-----------------------------------------------------------------------------\nQString VHDLGeneratorPlugin::getOutputFormat() const\n{\n    return QStringLiteral(\"VHDL\");\n}\n\n//-----------------------------------------------------------------------------\n// Function: VHDLGeneratorPlugin::runGenerator()\n//-----------------------------------------------------------------------------\nvoid VHDLGeneratorPlugin::runGenerator(IPluginUtility* utility, QSharedPointer<Component> component, \n    QSharedPointer<Design> /*design*/, QSharedPointer<DesignConfiguration> /*designConfiguration*/, \n    QString const& viewName, QString const& outputDirectory)\n{\n    utility_ = utility;\n\n    utility_->printInfo(tr(\"Running %1 %2.\").arg(getName(), getVersion()));\n\n    // Must have a component under any condition.\n    if (component == nullptr)\n    {\n        utility_->printError(tr(\"Invalid component given as a parameter.\"));\n        return;\n    }\n\n    utility_->printInfo(tr(\"Running generation for %1 and view '%2'.\").arg(component->getVlnv().toString(),\n        viewName));\n\n    QDir targetDirectory;\n    if (!targetDirectory.mkpath(outputDirectory))\n    {\n        utility_->printError(tr(\"Could not create target directory: %1\").arg(outputDirectory));\n        return;\n    }\n\n    utility_->printInfo(tr(\"Target directory: %1\").arg(outputDirectory));\n\n    const bool saveToFileset = false;\n    QSharedPointer<ViewSelection> viewSettings(new ViewSelection(QStringLiteral(\"vhdl\"), saveToFileset,\n        QString(), &generationSettings_, component->getViews(), component->getComponentInstantiations(),\n        component->getFileSets()));\n\n    QString filePath = outputDirectory;\n    filePath.append(QLatin1Char('/'));\n    filePath.append(findEntityName(component, viewName));\n    filePath.append(QStringLiteral(\".vhd\"));\n\n    generate(component, filePath, viewSettings);\n}\n\n//-----------------------------------------------------------------------------\n// Function: VHDLGeneratorPlugin::getProgramRequirements()\n//-----------------------------------------------------------------------------\nQList<IPlugin::ExternalProgramRequirement> VHDLGeneratorPlugin::getProgramRequirements()\n{\n    return QList<IPlugin::ExternalProgramRequirement>();\n}\n\n//-----------------------------------------------------------------------------\n// Function: VHDLGeneratorPlugin::noticeMessage()\n//-----------------------------------------------------------------------------\nvoid VHDLGeneratorPlugin::noticeMessage(QString const& message)\n{\n    utility_->printInfo(message);\n}\n\n//-----------------------------------------------------------------------------\n// Function: VHDLGeneratorPlugin::errorMessage()\n//-----------------------------------------------------------------------------\nvoid VHDLGeneratorPlugin::errorMessage(QString const& message)\n{\n    utility_->printError(message);\n}\n\n//-----------------------------------------------------------------------------\n// Function: VHDLGeneratorPlugin::findEntityName()\n//-----------------------------------------------------------------------------\nQString VHDLGeneratorPlugin::findEntityName(QSharedPointer<Component> component, QString const& viewName) const\n{\n    foreach (QSharedPointer<View> componentView, *component->getViews())\n    {\n        if (componentView->name().compare(viewName) == 0)\n        {\n            QString componentInstantiation = componentView->getComponentInstantiationRef();\n\n            for (QList<QSharedPointer<ComponentInstantiation> >::const_iterator iter = \n                component->getComponentInstantiations()->cbegin();\n                iter != component->getComponentInstantiations()->cend(); ++iter)\n            {\n                if ((*iter)->name().compare(componentInstantiation) == 0)\n                {\n                    return (*iter)->getModuleName();\n                }\n            }\n        }\n    }\n\n    return component->getVlnv().getName();\n}\n\n//-----------------------------------------------------------------------------\n// Function: VHDLGeneratorPlugin::generate()\n//-----------------------------------------------------------------------------\nvoid VHDLGeneratorPlugin::generate(QSharedPointer<Component> component, QString const& filePath, \n    QSharedPointer<ViewSelection> viewSettings)\n{\n    auto generatorFilePath = filePath;\n    if (filePath.endsWith(\".vhd\") == false && filePath.endsWith(\".vhdl\") == false)\n    {\n        generatorFilePath = FileHandler::getModifiedPathWithExtension(filePath, QString(\"vhd\"));\n    }\n\n    QSharedPointer<ParameterFinder> finder(new ComponentParameterFinder(component));\n    QSharedPointer<ExpressionParser> expressionParser(new IPXactSystemVerilogParser(finder));\n\n    VhdlGenerator2 generator(expressionParser, utility_->getLibraryInterface(), this);\n\n    connect(&generator, SIGNAL(errorMessage(const QString&)),\n        this, SLOT(errorMessage(const QString&)), Qt::UniqueConnection);\n    connect(&generator, SIGNAL(noticeMessage(const QString&)),\n        this, SLOT(noticeMessage(const QString&)), Qt::UniqueConnection);\n\n    // if errors are detected during parsing\n    if (!generator.parse(component, viewSettings->getViewName()))\n    {\n        return;\n    }\n\n    // Generate the VHDL code.\n\tgenerator.generate(generatorFilePath);\n\n    if (viewSettings->getSaveToFileset())\n    {\n        QString basePath = utility_->getLibraryInterface()->getPath(component->getVlnv());\n\t\tQString relativePath = General::getRelativePath(basePath, generatorFilePath);\n\n        generator.addRTLView(viewSettings->getFileSetName(), relativePath);\n        utility_->getLibraryInterface()->writeModelToFile(component);\n    }\n\n    // Inform when done.\n    utility_->printInfo( \"VHDL generation complete.\" );\n}\n"
  },
  {
    "path": "Plugins/VHDLGenerator/VHDLGeneratorPlugin.h",
    "content": "//-----------------------------------------------------------------------------\n// File: VHDLGenerator.h\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Esko Pekkarinen\n// Date: 13.11.2017\n//\n// Description:\n// Kactus2 plugin for VHDL file generation.\n//-----------------------------------------------------------------------------\n\n#ifndef VHDLGENERATORPLUGIN_H\n#define VHDLGENERATORPLUGIN_H\n\n#include \"VHDLGenerator_global.h\"\n\n\n#include <KactusAPI/include/IPluginUtility.h>\n#include <Plugins/PluginSystem/GeneratorPlugin/GenerationControl.h>\n#include <KactusAPI/include/IGeneratorPlugin.h>\n#include <KactusAPI/include/CLIGenerator.h>\n\n#include <QCommandLineParser>\n\n//-----------------------------------------------------------------------------\n//! Kactus2 plugin for VHDL file generation.\n//-----------------------------------------------------------------------------\nclass VHDLGENERATOR_EXPORT VHDLGeneratorPlugin : public QObject, public IGeneratorPlugin, public CLIGenerator\n{\n    Q_OBJECT\n    Q_PLUGIN_METADATA(IID \"kactus2.plugins.VHDLGenerator\" FILE \"VHDLGenerator.json\")\n\n    Q_INTERFACES(IPlugin)\n    Q_INTERFACES(IGeneratorPlugin)\n\npublic:\n    //! The constructor.\n    VHDLGeneratorPlugin();\n    \n    //! The destructor.\n    virtual ~VHDLGeneratorPlugin() = default;\n\n    /*!\n     *  Returns the name of the plugin.\n     */\n    virtual QString getName() const;\n\n    /*!\n     *  Returns the version of the plugin.\n     */\n    virtual QString getVersion() const;\n\n    /*!\n     *  Returns the description of the plugin.\n     */\n    virtual QString getDescription() const;\n\n    /*!\n     *  Returns the vendor of the plugin.\n     */\n    virtual QString getVendor() const;\n\n    /*!\n     *  Returns the license of the plugin.\n     */\n    virtual QString getLicense() const;\n\n    /*!\n     *  Returns the holder of the license of the plugin.\n     */\n    virtual QString getLicenseHolder() const;\n\n    /*!\n     *  Returns the settings widget.\n     */\n    virtual QWidget* getSettingsWidget();\n\n    /*!\n     *  This is used to access the settings modified by function getSettingsWidget().\n     */\n    virtual PluginSettingsModel* getSettingsModel();\n\n    /*!\n     *  Returns the icon for the generator.\n     */\n    virtual QIcon getIcon() const;\n    \n    /*!\n     *  Checks whether the generator may run for the given component or design. \n     *\n     *    @param [in] component\t        The component for which to check support. If design is not null, component\n\t *                                      will refer to design or designConfiguration.\n     *    @param [in] design\t            The design, if the generator is ran for a design.\n     *    @param [in] designConfiguration The design configuration for design, if it is not null.\n     *\n     *    @return True, if the generator may run the given component. Otherwise false.\n     */\n    virtual bool checkGeneratorSupport(QSharedPointer<Component const> component,\n        QSharedPointer<Design const> design,\n        QSharedPointer<DesignConfiguration const> designConfiguration) const;\n     \n    /*!\n     *  Runs the generation, creating new files and/or modifying the IP-XACT metadata. The function has\n\t *  also access to the parent window widget, so that it can show dialogs for the user to aid the generation.\n     *\n     *    @param [in] utility\t\t\t    The plugin utility interface.\n     *    @param [in] component\t        The component for which to check support. If design is not null, component\n     *                                      will refer to design or designConfiguration.\n     *    @param [in] design\t            The design, if the generator is ran for a design.\n     *    @param [in] designConfiguration The design configuration for design, if it is not null.\n     */\n    virtual void runGenerator(IPluginUtility* utility, \n        QSharedPointer<Component> component,\n        QSharedPointer<Design> design,\n        QSharedPointer<DesignConfiguration> designConfiguration);\n\n     //! Returns the external program requirements of the plugin.\n     virtual QList<IPlugin::ExternalProgramRequirement> getProgramRequirements();\n\n     /*!\n      *  Gets the output format generated by the plugin.\n      *\n      *    @return The output file format generated by the plugin.\n      */\n     virtual QString getOutputFormat() const override;\n\n     /*!\n       * Runs the generation.\n       *\n       *    @param [in] utility              Utilities for enabling plugin execution.\n       *    @param [in] component            The component to run the generation for.\n       *    @param [in] design               The design to run the generation for.\n       *    @param [in] designConfiguration  The design configuration to run the generation for.\n       *    @param [in] viewName             The component view name to run the generation for.\n       *    @param [in] outputDirectory      The output directory for the generation results.\n       */\n     virtual void runGenerator(IPluginUtility* utility, QSharedPointer<Component> component, \n         QSharedPointer<Design> design, QSharedPointer<DesignConfiguration> designConfiguration,\n         QString const& viewName, QString const& outputDirectory) override;\n\n\nprivate slots:\n    \n    //! Called when a user notification should be shown.\n    void noticeMessage(QString const& message);\n\n    //! Called when an error should be shown.\n    void errorMessage(QString const& message);\n   \nprivate:\n    //! The plugin utility provided by call runGenerator.\n    IPluginUtility* utility_;\n\n    //! Settings for the generation.\n    GenerationSettings generationSettings_;\n\n    /*!\n     *  Finds the name of the component entity.\n     *\n     *    @param [in] component   The component to search.\n     *    @param [in] viewName    The selected view to search.\n     *\n     *    @return The name of the VHDL entity for the component.\n     */\n    QString findEntityName(QSharedPointer<Component> component, QString const& viewName) const;\n\n    /*!\n     *  Runs the VHDL generation for the given component.\n     *\n     *    @param [in] component       The component to generate VHDL from.\n     *    @param [in] filePath        The file path to save the VHDL file.\n     *    @param [in] viewSettings    The view settings for the generation.\n     */\n    void generate(QSharedPointer<Component> component, QString const& filePath,\n        QSharedPointer<ViewSelection> viewSettings);\n};\n\n#endif // VHDLGENERATORPLUGIN_H\n"
  },
  {
    "path": "Plugins/VHDLGenerator/VHDLGenerator_global.h",
    "content": "#ifndef VHDLGENERATOR_GLOBAL_H\n#define VHDLGENERATOR_GLOBAL_H\n\n#include <QtCore/qglobal.h>\n\n#ifdef VHDLGENERATOR_LIB\n# define VHDLGENERATOR_EXPORT Q_DECL_EXPORT\n#else\n# define VHDLGENERATOR_EXPORT Q_DECL_IMPORT\n#endif\n\n#endif // VHDLGENERATOR_GLOBAL_H\n"
  },
  {
    "path": "Plugins/VHDLGenerator/VhdlTypedObject.cpp",
    "content": "// File: VhdlTypedObject.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 04.12.2012\r\n//\r\n// Description:\r\n// Class for containing VHDL type and default value.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"VhdlTypedObject.h\"\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VhdlTypedObject::VhdlTypedObject()\r\n//-----------------------------------------------------------------------------\r\nVhdlTypedObject::VhdlTypedObject (  const QString& name /* = QString() */, \r\n                                    const QString& type /* = QString() */, \r\n                                    const QString& defaultValue /* = QString() */, \r\n                                    const QString& description /* = QString() */):\r\nVhdlObject(name, description),\r\ntype_(type),\r\ndefaultValue_(defaultValue) \r\n{\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VhdlTypedObject::VhdlTypedObject()\r\n//-----------------------------------------------------------------------------\r\nQString VhdlTypedObject::type() const\r\n{\r\n    return type_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VhdlTypedObject::setType()\r\n//-----------------------------------------------------------------------------\r\nvoid VhdlTypedObject::setType(const QString& type)\r\n{\r\n    type_ = type;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VhdlTypedObject::defaultValue()\r\n//-----------------------------------------------------------------------------\r\nQString VhdlTypedObject::defaultValue() const\r\n{\r\n    return defaultValue_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VhdlTypedObject::setDefaultValue()\r\n//-----------------------------------------------------------------------------\r\nvoid VhdlTypedObject::setDefaultValue(const QString& defaultValue)\r\n{\r\n    defaultValue_ = defaultValue;\r\n}\r\n"
  },
  {
    "path": "Plugins/VHDLGenerator/VhdlTypedObject.h",
    "content": "// File: VhdlTypedObject.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 04.12.2012\r\n//\r\n// Description:\r\n// Class for containing VHDL type and default value.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef VHDLTYPEDOBJECT_H\r\n#define VHDLTYPEDOBJECT_H\r\n\r\n#include \"vhdlobject.h\"\r\n\r\n#include <QObject>\r\n#include <QString>\r\n#include <QTextStream>\r\n\r\nclass VhdlTypedObject : public VhdlObject\r\n{\r\n\r\npublic:\r\n\r\n\t/*!\r\n\t *  The constructor.\r\n\t *\r\n\t *    @param [in] parent   The owner of this vhdl object.\r\n\t *    @param [in] name   Name of this vhdl object.\r\n\t *    @param [in] type   Type of this vhdl object.\r\n\t *    @param [in] defaultValue   The default value for the object.\r\n\t *    @param [in] description   The Description for this vhdl object.\r\n\t */\r\n\tVhdlTypedObject(const QString& name = QString(),\r\n\t\tconst QString& type = QString(),\r\n\t\tconst QString& defaultValue = QString(),\r\n\t\tconst QString& description = QString());\r\n\t\r\n\t/*!\r\n\t *  The destructor.\r\n\t */\r\n\tvirtual ~VhdlTypedObject() = default;\r\n\r\n    //! Disable copying\r\n    VhdlTypedObject(const VhdlTypedObject& other) = default;\r\n\r\n\t/*! Write the contents of the object to the text stream.\r\n\t *\r\n\t * This is a pure virtual function and must be implemented in all classes \r\n\t * derived from this class.\r\n\t *\r\n\t * @param [in] stream The text stream to write the object into.\r\n\t *\r\n\t*/\r\n\tvirtual void write(QTextStream& stream) const override = 0;\r\n\r\n\t/*!\r\n\t *  Get the type of the vhdl object.\r\n     *\r\n\t *  @return     The type of the object.\r\n\t */\r\n\tvirtual QString type() const;\r\n\r\n\t/*!\r\n\t *  Set the type for the vhdl object.\r\n\t *\r\n\t *    @param [in] type   The type for the object.\r\n\t */\r\n\tvirtual void setType(const QString& type);\r\n\r\n\t/*!\r\n\t *  Get the default value of the object.\r\n\t *\r\n     *  @return     The default value of the object.\r\n\t */\r\n\tvirtual QString defaultValue() const;\r\n\r\n\t/*!\r\n\t *  Set the default value for the object.\r\n\t *\r\n\t *    @param [in] defaultValue   The default value to be set for the object.\r\n\t */\r\n\tvirtual void setDefaultValue(const QString& defaultValue);\r\n\r\nprivate:\r\n\r\n\t//! No assignment\r\n\tVhdlTypedObject& operator=(const VhdlTypedObject& other);\r\n\r\n    //! The type of the vhdl object.\r\n    QString type_;\r\n\r\n    //! The default value for the object.\r\n    QString defaultValue_;\r\n};\r\n\r\n#endif // VHDLTYPEDOBJECT_H\r\n"
  },
  {
    "path": "Plugins/VHDLGenerator/vhdlcomponentdeclaration.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: vhdlcomponentdeclaration.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Antti Kamppi\r\n// Date: 26.10.2011\r\n//\r\n// Description:\r\n// VHDL component declaration.\r\n//-----------------------------------------------------------------------------\r\n\r\n\r\n#include \"vhdlcomponentdeclaration.h\"\r\n\r\n#include \"vhdlgeneral.h\"\r\n\r\n#include <IPXACTmodels/Component/BusInterface.h>\r\n#include <IPXACTmodels/Component/Port.h>\r\n#include <IPXACTmodels/Component/View.h>\r\n#include <IPXACTmodels/Component/ComponentInstantiation.h>\r\n#include <IPXACTmodels/Component/PortMap.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: vhdlcomponentdeclaration::VhdlComponentDeclaration()\r\n//-----------------------------------------------------------------------------\r\nVhdlComponentDeclaration::VhdlComponentDeclaration(QSharedPointer<Component> component, \r\n    QSharedPointer<ExpressionParser> parser) :\r\nVhdlObject(component->getVlnv().getName(), QString()),\r\ncomponent_(component),\r\ntypeName_(component->getVlnv().getName()),\r\ngenerics_(),\r\nports_(),\r\ninstantations_() \r\n{\r\n\tQ_ASSERT(component);\r\n\r\n\r\n\t// parse the ports for the component declaration\r\n\tforeach (QSharedPointer<Port> port, *component_->getPorts())\r\n    {\r\n\t\t// do not add ports with invalid direction or phantom direction\r\n\t\tif (port->getDirection() == DirectionTypes::DIRECTION_INVALID ||\r\n\t\t\tport->getDirection() == DirectionTypes::DIRECTION_PHANTOM)\r\n        {\r\n\t\t\tcontinue;\r\n\t\t}\r\n\r\n\t\t// create the actual port\r\n\t\tQSharedPointer<VhdlPort> vhdlPort(new VhdlPort(port, parser));\r\n\r\n\t\t// create the sorter instance\r\n        QString busName = getContainingBusInterfaceName(port->name());\r\n\r\n\t\tVhdlPortSorter sorter(busName, vhdlPort->name(), port->getDirection());\r\n\r\n\t\t// this port can not be created yet\r\n\t\tQ_ASSERT(!ports_.contains(sorter));\r\n\r\n\t\tports_.insert(sorter, vhdlPort);\r\n\t}\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: vhdlcomponentdeclaration::write()\r\n//-----------------------------------------------------------------------------\r\nvoid VhdlComponentDeclaration::write( QTextStream& stream ) const\r\n{\r\n\t// if component contains a description\r\n\tif (!description().isEmpty())\r\n    {\r\n\t\tVhdlGeneral::writeDescription(description(), stream, QString(\"  \"));\r\n\t}\r\n\tstream << \"  \" << \"-- IP-XACT VLNV: \" << component_->getVlnv().toString() << Qt::endl;\r\n    stream << \"  \" << \"component \" << getVhdlLegalName() << Qt::endl;\r\n\r\n\t// write the generic declarations\r\n\tif (!generics_.isEmpty())\r\n    {\r\n        writeGenerics(stream);\r\n\t}\r\n\r\n\t// write the port declarations\r\n\tif (!ports_.isEmpty() && VhdlPort::hasRealPorts(ports_))\r\n    {\r\n        writePorts(stream);\r\n\t}\r\n\r\n\tstream << \"  end component;\" << Qt::endl;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: vhdlcomponentdeclaration::writeGenerics()\r\n//-----------------------------------------------------------------------------\r\nvoid VhdlComponentDeclaration::writeGenerics(QTextStream& stream) const\r\n{\r\n    stream << \"  \" << \"  \" << \"generic (\" << Qt::endl;\r\n    for (auto i = generics_.cbegin(); i != generics_.cend(); ++i)\r\n    {\r\n        stream << \"  \" << \"  \" << \"  \";\r\n        i.value()->write(stream);\r\n\r\n        // if this is not the last generic to write\r\n        if (std::distance(i, generics_.cend()) != 1)\r\n        {\r\n            stream << \";\";\r\n        }\r\n\r\n        if (!i.value()->description().isEmpty())\r\n        {\r\n            stream << \" \";\r\n            VhdlGeneral::writeDescription(i.value()->description(), stream);\r\n        }\r\n        else\r\n        {\r\n            stream << '\\n';\r\n        }\r\n    }\r\n    stream << \"  \" << \"  \" << \");\" << Qt::endl;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: vhdlcomponentdeclaration::writeGenerics()\r\n//-----------------------------------------------------------------------------\r\nvoid VhdlComponentDeclaration::writePorts(QTextStream& stream) const\r\n{\r\n    stream << \"  \" << \"  \" << \"port (\" << Qt::endl;\r\n    QString previousInterface;\r\n    for (auto i = ports_.cbegin(); i != ports_.cend(); ++i)\r\n    {\r\n        // if the port is first in the interface, then introduce the interface\r\n        if (i.key().interface() != previousInterface)\r\n        {\r\n            const QString interfaceName = i.key().interface();\r\n\r\n            stream << Qt::endl << \"  \" << \"  \" << \"  \" << \"-- \";\r\n\r\n            if (interfaceName == QString(\"none\"))\r\n            {\r\n                stream << \"These ports are not in any interface\" << Qt::endl;\r\n            }\r\n            else if (interfaceName == QString(\"several\"))\r\n            {\r\n                stream << \"There ports are contained in many interfaces\" << Qt::endl;\r\n            }\r\n            else\r\n            {\r\n                stream << \"Interface: \" << interfaceName << Qt::endl;\r\n                const QString description = component_->getBusInterface(\r\n                    interfaceName)->description();\r\n                if (!description.isEmpty())\r\n                {\r\n                    VhdlGeneral::writeDescription(description, stream, QString(\"      \"));\r\n                }\r\n            }\r\n            previousInterface = interfaceName;\r\n        }\r\n\r\n        stream << \"  \" << \"  \" << \"  \"; //3 indents\r\n        i.value()->write(stream); // print the actual port definition\r\n\r\n\r\n                                  // if this is not the last port to write\r\n        if (std::distance(i, ports_.end()) != 1)\r\n        {\r\n            stream << \";\";\r\n        }\r\n\r\n        if (!i.value()->description().isEmpty())\r\n        {\r\n            stream << \" \";\r\n            VhdlGeneral::writeDescription(i.value()->description(), stream);\r\n        }\r\n        else\r\n        {\r\n            stream << Qt::endl;\r\n        }\r\n    }\r\n    stream << \"    );\" << Qt::endl;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: vhdlcomponentdeclaration::typeName()\r\n//-----------------------------------------------------------------------------\r\nQString VhdlComponentDeclaration::typeName() const\r\n{\r\n\treturn typeName_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: vhdlcomponentdeclaration::description()\r\n//-----------------------------------------------------------------------------\r\nQString VhdlComponentDeclaration::description() const\r\n{\r\n\treturn component_->getDescription();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: vhdlcomponentdeclaration::componentModel()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<Component> VhdlComponentDeclaration::componentModel() const\r\n{\r\n\treturn component_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: vhdlcomponentdeclaration::addInstantiation()\r\n//-----------------------------------------------------------------------------\r\nvoid VhdlComponentDeclaration::addInstantiation( QSharedPointer<VhdlComponentInstance> instance )\r\n{\r\n\tQ_ASSERT(!instantations_.contains(instance));\r\n\r\n\tinstantations_.append(instance);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: vhdlcomponentdeclaration::hasGeneric()\r\n//-----------------------------------------------------------------------------\r\nbool VhdlComponentDeclaration::hasGeneric( const QString& genericName ) const\r\n{\r\n\treturn generics_.contains(genericName);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: vhdlcomponentdeclaration::checkPortConnections()\r\n//-----------------------------------------------------------------------------\r\nvoid VhdlComponentDeclaration::checkPortConnections()\r\n{\r\n\t// check each vhdl port\r\n\tforeach (QSharedPointer<VhdlPort> port, ports_)\r\n    {\r\n\t\t// check each instance of this type\r\n\t\tforeach (QSharedPointer<VhdlComponentInstance> instantation, instantations_)\r\n        {\r\n\t\t\t// if the named port is connected in this instance\r\n\t\t\tif (instantation->hasConnection(port->name()))\r\n            {\r\n\t\t\t\t// port is needed so it can not be commented and search can be stopped for this port\r\n\t\t\t\tport->setCommented(false);\r\n\t\t\t\tbreak;\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: vhdlcomponentdeclaration::portType()\r\n//-----------------------------------------------------------------------------\r\nQString VhdlComponentDeclaration::portType( const QString& portName ) const\r\n{\r\n    QString busInterfaceName = getContainingBusInterfaceName(portName);\r\n\r\n\t// used to search for the correct port\r\n    VhdlPortSorter sorter(busInterfaceName, portName, component_->getPort(portName)->getDirection());\r\n\t\r\n\t// if the named port is found\r\n\tif (ports_.contains(sorter))\r\n    {\r\n\t\treturn ports_.value(sorter)->type();\r\n\t}\r\n\telse\r\n    {\r\n\t\treturn QString(\"undefined port\");\r\n\t}\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: vhdlcomponentdeclaration::isScalarPort()\r\n//-----------------------------------------------------------------------------\r\nbool VhdlComponentDeclaration::isScalarPort( const QString& portName ) const\r\n{\r\n    QString busInterfaceName = getContainingBusInterfaceName(portName);\r\n\r\n    VhdlPortSorter sorter(busInterfaceName, portName, component_->getPort(portName)->getDirection());\r\n\r\n\tQString type;\r\n\r\n\tif (ports_.contains(sorter))\r\n    {\r\n\t\ttype = ports_.value(sorter)->type();\r\n\t\treturn VhdlGeneral::isScalarType(type);\r\n\t}\r\n\t// if port is not found then it is not scalar\r\n\telse\r\n    {\r\n\t\treturn false;\r\n\t}\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: vhdlcomponentdeclaration::setEntityName()\r\n//-----------------------------------------------------------------------------\r\nvoid VhdlComponentDeclaration::setEntityName( const QString& entityName )\r\n{\r\n\ttypeName_ = entityName;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: vhdlcomponentdeclaration::portDirection()\r\n//-----------------------------------------------------------------------------\r\nDirectionTypes::Direction VhdlComponentDeclaration::portDirection( const QString& portName ) const\r\n{\r\n\treturn component_->getPort(portName)->getDirection();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: vhdlcomponentdeclaration::getPortPhysLeftBound()\r\n//-----------------------------------------------------------------------------\r\nQString VhdlComponentDeclaration::getPortPhysLeftBound( const QString& portName ) const\r\n{\r\n\treturn component_->getPort(portName)->getLeftBound();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: vhdlcomponentdeclaration::getPortPhysRightBound()\r\n//-----------------------------------------------------------------------------\r\nQString VhdlComponentDeclaration::getPortPhysRightBound( const QString& portName ) const\r\n{\r\n\treturn component_->getPort(portName)->getRightBound();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: vhdlcomponentdeclaration::getContainingBusInterfaceName()\r\n//-----------------------------------------------------------------------------\r\nQString VhdlComponentDeclaration::getContainingBusInterfaceName(QString const& portName) const\r\n{\r\n    QString busName = \"none\";\r\n\r\n    QSharedPointer<BusInterface> containingInterface = component_->getInterfaceForPort(portName);\r\n    if (!containingInterface.isNull())\r\n    {\r\n        busName = containingInterface->name();\r\n    }\r\n\r\n    return busName;\r\n}"
  },
  {
    "path": "Plugins/VHDLGenerator/vhdlcomponentdeclaration.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: vhdlcomponentdeclaration.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Antti Kamppi\r\n// Date: 26.10.2011\r\n//\r\n// Description:\r\n// VHDL component declaration.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef VHDLCOMPONENTDECLARATION_H\r\n#define VHDLCOMPONENTDECLARATION_H\r\n\r\n#include <IPXACTmodels/Component/Component.h>\r\n#include <IPXACTmodels/common/DirectionTypes.h>\r\n\r\n#include \"vhdlobject.h\"\r\n#include \"vhdlgeneric.h\"\r\n#include \"vhdlport.h\"\r\n#include \"vhdlportsorter.h\"\r\n#include \"vhdlcomponentinstance.h\"\r\n\r\n#include <QObject>\r\n#include <QSharedPointer>\r\n#include <QMap>\r\n#include <QString>\r\n#include <QList>\r\n#include <QTextStream>\r\n\r\nclass ExpressionParser;\r\n//-----------------------------------------------------------------------------\r\n//! VHDL component declaration.\r\n//-----------------------------------------------------------------------------\r\nclass VhdlComponentDeclaration : public VhdlObject\r\n{\r\n\r\npublic:\r\n\r\n\t/*!\r\n     *  The constructor.\r\n\t *\r\n\t *    @param [in] component   The component model for this vhdl component.\r\n\t *    @param [in] parser      Parser for expressions within the declaration.\r\n\t */\r\n\tVhdlComponentDeclaration(QSharedPointer<Component> component, \r\n        QSharedPointer<ExpressionParser> parser);\r\n\t\r\n\t//! The destructor.\r\n\tvirtual ~VhdlComponentDeclaration() = default;\r\n\r\n\t/*!\r\n     *  Write the component declaration to the text stream.\r\n\t *\r\n\t *    @param [in] stream  The text stream to write into.\r\n\t */\r\n\tvirtual void write(QTextStream& stream) const override final;\r\n\r\n    /*!\r\n     *  Write the generic declarations of the component to the text stream.\r\n     *\r\n     *    @param [in] stream  The text stream to write into.\r\n     */\r\n    void writeGenerics(QTextStream& stream) const;\r\n    \r\n    /*!\r\n     *  Write the port declarations of the component to the text stream.\r\n     *\r\n     *    @param [in] stream  The text stream to write into.\r\n     */\r\n    void writePorts(QTextStream& stream) const;\r\n\r\n\t/*!\r\n     *  Get the type name of the vhdl component declaration.\r\n\t *\r\n\t *    @return QString contains the type name.\r\n\t */\r\n\tQString typeName() const;\r\n\r\n\t/*!\r\n     *  Get the description of the vhdl component declaration.\r\n\t *\r\n\t *    @return QString contains the description for the component declaration.\r\n\t */\r\n\tvirtual QString description() const override final;\r\n\r\n\t/*!\r\n     *  Get pointer to the IP-Xact model of the component declaration.\r\n\t *\r\n\t *    @return QSharedPointer<Component> Pointer to the IP-Xact model of component.\r\n\t */\r\n\tQSharedPointer<Component> componentModel() const;\r\n\r\n\t/*!\r\n     *  Add an instantiation of this component.\r\n\t *\r\n\t *    @param instance Pointer to the instance.\r\n\t */\r\n\tvoid addInstantiation(QSharedPointer<VhdlComponentInstance> instance);\r\n\r\n\t/*!\r\n     *  Check if the component has generic with given name.\r\n\t *\r\n\t *    @param [in] genericName The name of the generic to search for.\r\n\t *\r\n\t *    @return bool True if the generic is found.\r\n\t */\r\n\tbool hasGeneric(const QString& genericName) const;\r\n\r\n\t/*!\r\n     *  Check for port connections of the instances.\r\n\t * \r\n\t *  The ports that are not connected or don't have default value in any of the instances are commented out \r\n     *  and removed from the instance's port maps.\r\n\t */\r\n\tvoid checkPortConnections();\r\n\r\n\t/*!\r\n     *  Get the type of specified port.\r\n\t *\r\n\t *    @param [in] portName    The name of the port.\r\n\t *\r\n\t *    @return QString The type of the specified port.\r\n\t */\r\n\tQString portType(const QString& portName) const;\r\n\r\n\t/*!\r\n     *  Check if the type of the port is scalar.\r\n\t *\r\n\t *    @param [in] portName    Specifies the port to check.\r\n\t *\r\n\t *      return bool True if port is scalar.\r\n\t */\r\n\tbool isScalarPort(const QString& portName) const;\r\n\r\n\t/*!\r\n     *  Set the name of the entity for the component.\r\n\t *\r\n\t *    @param [in] entityName  The name for the entity of this component.\r\n\t */\r\n\tvoid setEntityName(const QString& entityName);\r\n\r\n\t/*!\r\n     *  Get the direction of the specified port on this component.\r\n\t *\r\n\t *    @param [in] portName    The name of the port that's direction is requested.\r\n\t *\r\n\t *    @return General::Direction Specifies the direction of the port.\r\n\t */\r\n\tDirectionTypes::Direction portDirection(const QString& portName) const;\r\n\r\n\t/*!\r\n     *  Get the physical left bound of the port.\r\n\t *\r\n\t *    @param [in] portName    The name of the port that's bound is wanted.\r\n\t *\r\n\t *    @return The left bound.\r\n\t */\r\n\tQString getPortPhysLeftBound(const QString& portName) const;\r\n\r\n\t/*!\r\n     *  Get the physical right bound of the port.\r\n\t *\r\n\t *    @param [in] portName    The name of the port that's bound is wanted.\r\n\t *\r\n\t *    @return The right bound.\r\n\t */\r\n\tQString getPortPhysRightBound(const QString& portName) const;\r\n\r\nprivate:\r\n\t\r\n    //! No copying.\r\n\tVhdlComponentDeclaration(const VhdlComponentDeclaration& other);\r\n\r\n\t//! No assignment.\r\n\tVhdlComponentDeclaration& operator=(const VhdlComponentDeclaration& other);\r\n\r\n    /*!\r\n     *  Get the name of the bus interface containing the selected port.\r\n     *\r\n     *    @param [in] portName    The name of the selected port.\r\n     *\r\n     *    @return The name of the contianing bus interface, or \"none\" if no interface is found.\r\n     */\r\n    QString getContainingBusInterfaceName(QString const& portName) const;\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n\t//! Pointer to the component that this declaration represents.\r\n\tQSharedPointer<Component> component_;\r\n\r\n\t//! The type of the vhdl component.\r\n\tQString typeName_;\r\n\r\n\t/*!\r\n     *  Contains the generic declarations for this component.\r\n\t *\r\n\t *  Key: The name of the generic. Value: Pointer to the generic.\r\n\t */\r\n\tQMap<QString, QSharedPointer<VhdlGeneric> > generics_;\r\n\r\n\t/*!\r\n     *  Contains the ports for this component.\r\n\t * \r\n\t *  Key: Class used to sort the ports in correct order. Value: Pointer to the port.\r\n\t */\r\n\tQMap<VhdlPortSorter, QSharedPointer<VhdlPort> > ports_;\r\n\r\n\t//! Contains pointer to the instances of this port.\r\n\tQList<QSharedPointer<VhdlComponentInstance> > instantations_;\r\n};\r\n\r\n#endif // VHDLCOMPONENTDECLARATION_H\r\n"
  },
  {
    "path": "Plugins/VHDLGenerator/vhdlcomponentinstance.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: vhdlcomponentinstance.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Antti Kamppi\r\n// Date: 26.10.2011\r\n//\r\n// Description:\r\n// Represents one vhdl component instantiation.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"vhdlcomponentinstance.h\"\r\n\r\n#include \"vhdlcomponentdeclaration.h\"\r\n#include \"vhdlgeneral.h\"\r\n\r\n#include <IPXACTmodels/utilities/ComponentSearch.h>\r\n\r\n#include <IPXACTmodels/Component/Component.h>\r\n#include <IPXACTmodels/Component/View.h>\r\n#include <IPXACTmodels/common/Document.h>\r\n#include <IPXACTmodels/AbstractionDefinition/AbstractionDefinition.h>\r\n#include <IPXACTmodels/AbstractionDefinition/PortAbstraction.h>\r\n#include <IPXACTmodels/Component/BusInterface.h>\r\n#include <IPXACTmodels/Component/ComponentInstantiation.h>\r\n#include <IPXACTmodels/Component/Port.h>\r\n\r\n#include <KactusAPI/include/LibraryInterface.h>\r\n#include <KactusAPI/include/ExpressionFormatter.h>\r\n\r\n#include <QSharedPointer>\r\n#include <QMultiMap>\r\n#include <QChar>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: vhdlcomponentinstance::VhdlComponentInstance()\r\n//-----------------------------------------------------------------------------\r\nVhdlComponentInstance::VhdlComponentInstance(QObject* parent, LibraryInterface* handler,\r\n\tVhdlComponentDeclaration* compDeclaration, const QString& instanceName, QSharedPointer<ExpressionParser> parser,\r\n\tconst QString& viewName, const QString& description):\r\nQObject(parent),\r\nVhdlObject(instanceName, description),\r\ncompDeclaration_(compDeclaration),\r\ninstanceName_(instanceName),\r\ncomponentModuleName_(compDeclaration->typeName()),\r\narchitecture_(),\r\ndescription_(description),\r\ndefaultPortConnections_(),\r\ngenericMap_(),\r\nportMap_(),\r\nparser_(parser)\r\n{\r\n\tQ_ASSERT(handler);\r\n\r\n\tQSharedPointer<Component> component = compDeclaration_->componentModel();\r\n\tQ_ASSERT(component);\r\n\r\n\t// Look up the component instantiation.\r\n\tQSharedPointer<ComponentInstantiation> instantiation =\r\n        ComponentSearch::findComponentInstantiation(component, viewName);\r\n \t\r\n\tif (instantiation)\r\n\t{\r\n\t\tcomponentModuleName_ = instantiation->getModuleName();\r\n\t\tcompDeclaration_->setEntityName(componentModuleName_);\r\n\t\tarchitecture_ = instantiation->getArchitectureName();\r\n\t}\r\n\r\n\t// Get the default values of the in and inout ports.\r\n\tfor (QSharedPointer<Port> port : *component->getPorts())\r\n\t{\r\n\t\tdefaultPortConnections_.insert( port->name(), port->getWire()->getDefaultDriverValue() );\r\n\t}\r\n\r\n\tQMap<QString, QString> tempDefaults;\r\n\r\n\tfor (QMap<QString, QString>::iterator i = defaultPortConnections_.begin();\r\n\t\ti != defaultPortConnections_.end(); ++i)\r\n\t{\r\n\t\t// Get the VLNVs of the abstraction definition for the port\r\n\t\tQSharedPointer<AbstractionType> absType;\r\n        QSharedPointer<BusInterface> portInterface(component->getInterfaceForPort(i.key()));\r\n        if (!portInterface.isNull())\r\n        {\r\n            absType = portInterface->getAbstractionContainingView(viewName);\r\n        }        \r\n\r\n\t\t// if the port is not in any interface then use the ports own default value.\r\n\t\tif (absType.isNull())\r\n\t\t{\r\n\t\t\ttempDefaults.insert(i.key(), i.value());\r\n\t\t}\r\n        else\r\n        {\r\n            // if the abs def does not exist in the library\r\n            VLNV abstractionVLNV = *absType->getAbstractionRef();\r\n            if (handler->getDocumentType(abstractionVLNV) != VLNV::ABSTRACTIONDEFINITION)\r\n            {\r\n                if (!tempDefaults.contains(i.key()))\r\n                {\r\n                    tempDefaults.insert(i.key(), i.value());\r\n                }                \r\n            }\r\n            else\r\n            {                \r\n                auto absDef = handler->getModelReadOnly<AbstractionDefinition>(abstractionVLNV);\r\n                auto absPort = absDef->getPort(i.key());\r\n                if (absPort.isNull() == false && absPort->getDefaultValue().isEmpty() == false)\r\n                {\r\n                    tempDefaults.insert(i.key(), absPort->getDefaultValue());\r\n                }\r\n                else if (!tempDefaults.contains(i.key()))\r\n                {\r\n                    tempDefaults.insert(i.key(), i.value());\r\n                }\r\n            }\r\n        }\r\n\t}\r\n\r\n\tdefaultPortConnections_ = tempDefaults;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: vhdlcomponentinstance::~VhdlComponentInstance()\r\n//-----------------------------------------------------------------------------\r\nVhdlComponentInstance::~VhdlComponentInstance()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: vhdlcomponentinstance::write()\r\n//-----------------------------------------------------------------------------\r\nvoid VhdlComponentInstance::write( QTextStream& stream ) const\r\n{\r\n\t// if instance has description\r\n\tif (!description_.isEmpty())\r\n    {\r\n\t\tstream << \"  \";\r\n\t\tVhdlGeneral::writeDescription(description_, stream, QString(\"  \"));\r\n\t}\r\n\r\n\t// write the instance name and type\r\n    stream << \" \" << getVhdlLegalName() << \" : \" << compDeclaration_->getVhdlLegalName();\r\n\r\n\t// if architecture has been defined\r\n\tif (!architecture_.isEmpty())\r\n    {\r\n\t\tstream << \"(\" << architecture_ << \")\";\r\n\t}\r\n\tstream << Qt::endl;\r\n\r\n\t// print the generic map\r\n\tif (!genericMap_.isEmpty())\r\n    {\r\n\t\tstream << \"    generic map (\" << Qt::endl;\r\n\t\tfor (auto i = genericMap_.cbegin(); i != genericMap_.cend(); ++i)\r\n        {\r\n\t\t\tstream << \"  \" << \"  \" << \"  \";\r\n\t\t\tstream << i.key().leftJustified(16, ' '); //align colons (:) at least roughly\r\n\t\t\tstream << \" => \" << i.value();\r\n\r\n\t\t\t// if this is not the last generic to print\r\n\t\t\tif (std::distance(i, genericMap_.cend()) != 1)\r\n            {\r\n\t\t\t\tstream << \",\" << Qt::endl;\r\n\t\t\t}\r\n\t\t}\r\n\t\tstream << Qt::endl << \"  \" << \"  \" << \")\" << Qt::endl;\r\n\t}\r\n\r\n\t// print the port map\r\n\tif (!portMap_.isEmpty())\r\n    {\r\n\t\tstream << \"    port map (\" << Qt::endl;\r\n\r\n        for (auto i = portMap_.cbegin(); i != portMap_.cend(); ++i)\r\n        {\r\n\t\t\tstream << \"  \" << \"  \" << \"  \" ;\r\n            stream << i.key().mappingWith(i.value());\r\n\t\t\r\n\r\n\t\t\t// if this is not the last port map to print, add comma (,)\r\n\t\t\tif (std::distance(i, portMap_.cend()) != 1)\r\n            {\r\n\t\t\t\tstream << \",\" << Qt::endl;\r\n\t\t\t}\r\n\t\t}\r\n\t\tstream << Qt::endl << \"  \" << \"  \" << \");\" << Qt::endl;\r\n\t}\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: vhdlcomponentinstance::name()\r\n//-----------------------------------------------------------------------------\r\nQString VhdlComponentInstance::name() const\r\n{\r\n\treturn instanceName_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: vhdlcomponentinstance::addPortMap()\r\n//-----------------------------------------------------------------------------\r\nvoid VhdlComponentInstance::addPortMap( const VhdlConnectionEndPoint& endpoint, const QString& signalName )\r\n{\r\n\t// create a map for the port of this instance\r\n\tVhdlPortMap instancePort(endpoint.portName(), endpoint.portLeft(), endpoint.portRight());\r\n\r\n\t// create a map for the defaultValue/top port that is connected\r\n\tVhdlPortMap signalMapping(signalName, endpoint.signalLeft(), endpoint.signalRight());\r\n\r\n\taddMapping(instancePort, signalMapping);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: vhdlcomponentinstance::addPortMap()\r\n//-----------------------------------------------------------------------------\r\nvoid VhdlComponentInstance::addPortMap(VhdlPortMap const& instancePort, VhdlPortMap const& signalMapping)\r\n{\r\n    addMapping(instancePort, signalMapping);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: vhdlcomponentinstance::addMapping()\r\n//-----------------------------------------------------------------------------\r\nvoid VhdlComponentInstance::addMapping(const VhdlPortMap &instancePort, const VhdlPortMap &signalMapping )\r\n{\r\n\t// if the same bits of port are already connected\r\n\tif (portMap_.contains(instancePort))\r\n    {\r\n\t\tVhdlPortMap previousValue = portMap_.value(instancePort);\r\n\r\n\t\t// inform user that the mapping for those bits already existed.\r\n\t\temit noticeMessage(tr(\"The instance %1:%2 already contains mapping \\\"%3 => %4\\\"\").\r\n            arg(componentModuleName_).arg(instanceName_).arg(instancePort.name()).\r\n            arg(previousValue.name()));\r\n\r\n\t\t// inform user that the new mapping is also added\r\n\t\temit noticeMessage(tr(\"Instance %1:%2 now has also port mapping \\\"%3 => %4\\\"\").\r\n            arg(componentModuleName_).arg(instanceName_).arg(instancePort.name()).\r\n            arg(signalMapping.name()));\r\n\t}\r\n\r\n\tportMap_.insert(instancePort, signalMapping);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: vhdlcomponentinstance::addGenericMap()\r\n//-----------------------------------------------------------------------------\r\nvoid VhdlComponentInstance::addGenericMap( const QString& genericName, const QString& genericValue )\r\n{\r\n\t// if the generics already contains a mapping for the generic\r\n\tif (genericMap_.contains(genericName))\r\n    {\r\n\t\tQString oldValue = genericMap_.value(genericName);\r\n\t\t\r\n\t\t// print a notification to user that the previous value for the generic\r\n\t\t// is overwritten with new value\r\n\t\temit noticeMessage(tr(\"The instance %1:%2 already contained generic mapping \\\"%3 => %4\\\" but \"\r\n            \"\\\"%3 => %5\\\" replaced it.\").\r\n            arg(componentModuleName_).arg(instanceName_).arg(genericName).arg(oldValue).arg(genericValue));\r\n\t}\r\n\r\n\tgenericMap_.insert(genericName, genericValue);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: vhdlcomponentinstance::hasConnection()\r\n//-----------------------------------------------------------------------------\r\nbool VhdlComponentInstance::hasConnection( const QString& portName )\r\n{\r\n\tfor (auto i = portMap_.cbegin(); i != portMap_.cend(); ++i)\r\n    {\r\n        // if the mapping is for port with same name\r\n        if (i.key().name().compare(portName, Qt::CaseInsensitive) == 0)\r\n        {\r\n            return true;\r\n        }\r\n\t}\r\n\r\n\t// not port mapping for named port was found\r\n\treturn false;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: vhdlcomponentinstance::useDefaultsForOtherPorts()\r\n//-----------------------------------------------------------------------------\r\nvoid VhdlComponentInstance::useDefaultsForOtherPorts()\r\n{\r\n\t// check all ports that have a connection\r\n\tfor (auto i = portMap_.cbegin(); i != portMap_.cend(); ++i)\r\n    {\r\n        defaultPortConnections_.remove(i.key().name());\r\n\t}\r\n\r\n\t// now default values remain only for ports with no connections at all\r\n\r\n\t// go through each default port value\r\n\tfor (auto i = defaultPortConnections_.cbegin(); i != defaultPortConnections_.cend();\r\n        ++i)\r\n    {\r\n\t\tQString portDefaultValue = i.value();\r\n        // if the default value is not set\r\n\t\tif (portDefaultValue.isEmpty())\r\n\t\t{\r\n            continue;\r\n        }\r\n\r\n        VhdlPortMap port(i.key(), QString(), QString(), QString());\r\n\r\n\t\tauto formattedDefaultValue = ExpressionFormatter::format(portDefaultValue, parser_);\r\n\r\n\t\t// get the type of the port\r\n\t\tQString portTypeStr(portType(i.key()));\r\n\r\n\t\t// make sure the default value is in correct form\r\n\t\tQString defaultStr = VhdlGeneral::convertDefaultValue(formattedDefaultValue, portTypeStr);\r\n\r\n\t\tVhdlPortMap defaultValue(defaultStr, QString(), QString(), QString());\r\n\t\taddMapping(port, defaultValue);\r\n\t}\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: vhdlcomponentinstance::interface()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<BusInterface> VhdlComponentInstance::interface( const QString& interfaceName ) const\r\n{\r\n\treturn compDeclaration_->componentModel()->getBusInterface(interfaceName);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: vhdlcomponentinstance::vlnv()\r\n//-----------------------------------------------------------------------------\r\nVLNV VhdlComponentInstance::vlnv() const\r\n{\r\n\tQ_ASSERT(compDeclaration_);\r\n\tQ_ASSERT(compDeclaration_->componentModel());\r\n\treturn compDeclaration_->componentModel()->getVlnv();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: vhdlcomponentinstance::componentModel()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<Component> VhdlComponentInstance::componentModel() const\r\n{\r\n\tQ_ASSERT(compDeclaration_);\r\n\treturn compDeclaration_->componentModel();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: vhdlcomponentinstance::portType()\r\n//-----------------------------------------------------------------------------\r\nQString VhdlComponentInstance::portType( const QString& portName ) const\r\n{\r\n\tQ_ASSERT(compDeclaration_);\r\n\treturn compDeclaration_->portType(portName);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: vhdlcomponentinstance::hasPort()\r\n//-----------------------------------------------------------------------------\r\nbool VhdlComponentInstance::hasPort( const QString& portName ) const\r\n{\r\n\tQ_ASSERT(compDeclaration_);\r\n\tQ_ASSERT(compDeclaration_->componentModel());\r\n\treturn compDeclaration_->componentModel()->hasPort(portName);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: vhdlcomponentinstance::typeName()\r\n//-----------------------------------------------------------------------------\r\nQString VhdlComponentInstance::typeName() const\r\n{\r\n\treturn componentModuleName_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: vhdlcomponentinstance::isScalarPort()\r\n//-----------------------------------------------------------------------------\r\nbool VhdlComponentInstance::isScalarPort( const QString& portName ) const\r\n{\r\n\tQ_ASSERT(compDeclaration_);\r\n\treturn compDeclaration_->isScalarPort(portName);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: vhdlcomponentinstance::portDirection()\r\n//-----------------------------------------------------------------------------\r\nDirectionTypes::Direction VhdlComponentInstance::portDirection( const QString& portName ) const\r\n{\r\n\treturn compDeclaration_->portDirection(portName);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: vhdlcomponentinstance::getPortPhysLeftBound()\r\n//-----------------------------------------------------------------------------\r\nQString VhdlComponentInstance::getPortPhysLeftBound( const QString& portName ) const\r\n{\r\n\treturn compDeclaration_->getPortPhysLeftBound(portName);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: vhdlcomponentinstance::getPortPhysRightBound()\r\n//-----------------------------------------------------------------------------\r\nQString VhdlComponentInstance::getPortPhysRightBound( const QString& portName ) const\r\n{\r\n\treturn compDeclaration_->getPortPhysRightBound(portName);\r\n}\r\n"
  },
  {
    "path": "Plugins/VHDLGenerator/vhdlcomponentinstance.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: vhdlcomponentinstance.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Antti Kamppi\r\n// Date: 26.10.2011\r\n//\r\n// Description:\r\n// Represents one vhdl component instantiation.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef VHDLCOMPONENTINSTANCE_H\r\n#define VHDLCOMPONENTINSTANCE_H\r\n\r\n#include \"vhdlobject.h\"\r\n#include \"vhdlportmap.h\"\r\n#include \"vhdlconnectionendpoint.h\"\r\n\r\n#include <IPXACTmodels/Component/Component.h>\r\n#include <IPXACTmodels/common/VLNV.h>\r\n\r\n#include <IPXACTmodels/common/DirectionTypes.h>\r\n\r\n#include <QObject>\r\n#include <QString>\r\n#include <QMap>\r\n#include <QTextStream>\r\n\r\nclass LibraryInterface;\r\nclass VhdlComponentDeclaration;\r\nclass ExpressionParser;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Represents one vhdl component instantiation.\r\n//-----------------------------------------------------------------------------\r\nclass VhdlComponentInstance : public QObject, public VhdlObject\r\n{\r\n    Q_OBJECT\r\n\r\npublic:\r\n\r\n\t/*!\r\n     *  The constructor.\r\n\t *\r\n\t *  @param [in] parent              Pointer to the owner of this component instance.\r\n\t *  @param [in] compDeclaration     Pointer to the component declaration of this instance.\r\n\t *  @param [in] instanceName        The name of the instance.\r\n\t *\t@param [in] parser\t\t\t\tThe expression parser.\r\n\t *  @param [in] viewName            The active view used for this instance.\r\n\t *  @param [in] description         The description for the instance.\r\n\t */\r\n\tVhdlComponentInstance(QObject* parent,\r\n\t\tLibraryInterface* handler,\r\n\t\tVhdlComponentDeclaration* compDeclaration,\r\n\t\tconst QString& instanceName,\r\n\t\tQSharedPointer<ExpressionParser> parser,\r\n\t\tconst QString& viewName = QString(),\r\n\t\tconst QString& description = QString());\r\n\r\n\t//! The destructor.\r\n\tvirtual ~VhdlComponentInstance();\r\n\r\n\t/*!\r\n     *  Write the instance to the text stream.\r\n\t *\r\n\t *    @param [in] stream  The text stream to write the instance into.\r\n\t */\r\n\tvirtual void write(QTextStream& stream) const override final;\r\n\r\n\t/*!\r\n     *  Get the name of the component instance.\r\n\t *\r\n\t *    @return QString contains the name of the instance.\r\n\t */\r\n\tQString name() const;\r\n\r\n\t/*!\r\n     *  Get the type name of the instance.\r\n\t *\r\n\t *    @return QString contains the type name.\r\n\t */\r\n\tQString typeName() const;\r\n\r\n\t/*!\r\n     *  Add a new port map for the instance.\r\n\t *\r\n\t *    @param [in] endpoint    The end point that specifies the port and signal bounds.\r\n\t *    @param [in] signalName  The name of the signal/top port to map the port to.\r\n\t */\r\n\tvoid addPortMap(const VhdlConnectionEndPoint& endpoint, const QString& signalName);\r\n\r\n\t/*!\r\n     *  Add a new port map for the instance.\r\n\t *\r\n\t *    @param [in] left        The left side of the port map connection.\r\n\t *    @param [in] right       The right side fo the port map connection.\r\n\t */\r\n    void addPortMap(VhdlPortMap const& left, VhdlPortMap const& right);\r\n\r\n\t/*!\r\n     *  Add a new generic map to the instance.\r\n\t *\r\n\t *    @param [in] genericName     The name of the generic on this instance.\r\n\t *    @param [in] genericValue    The value to map the generic to.\r\n\t */\r\n\tvoid addGenericMap(const QString& genericName, const QString& genericValue);\r\n\r\n\t/*!\r\n     *  Check if the specified port is connected within this instance.\r\n\t *\r\n\t *    @param [in] portName    The name of the port to check to connection for.\r\n\t *\r\n\t *    @return bool True if connection is found.\r\n\t */\r\n\tbool hasConnection(const QString& portName);\r\n\r\n\t/*!\r\n     *  Use default values for ports that don't have any connection.\r\n\t * \r\n\t *  If at least one bit of the port is connected then the default value is not used.\r\n\t */\r\n\tvoid useDefaultsForOtherPorts();\r\n\r\n\t/*!\r\n     *  Get the bus interface with given name.\r\n\t *\r\n\t *    @param [in] interfaceName   The name of the bus interface on the IP-Xact component model.\r\n\t *\r\n\t *    @return BusInterface* Pointer to the bus interface.\r\n\t */\r\n\tQSharedPointer<BusInterface> interface(const QString& interfaceName) const;\r\n\r\n\t/*!\r\n     *  Get the vlnv of the instance's IP-Xact model.\r\n\t *\r\n\t *    @return VLNV Identifies the IP-Xact model of the instance's type.\r\n\t */\r\n\tVLNV vlnv() const;\r\n\r\n\t/*!\r\n     *  Get pointer to the IP-Xact model of the component type.\r\n\t *\r\n\t *    @return QSharedPointer<Component> Pointer to the IP-Xact model.\r\n\t */\r\n\tQSharedPointer<Component> componentModel() const;\r\n\r\n\t/*!\r\n     *  Get the type of the specified port.\r\n\t *\r\n\t *    @param [in] portName    The name of the port on the component.\r\n\t *\r\n\t *    @return QString The type of the port.\r\n\t */\r\n\tQString portType(const QString& portName) const;\r\n\r\n\t/*!\r\n     *  Check if the instance has a specified port.\r\n\t *\r\n\t *    @param [in] portName    The name of the port to check.\r\n\t *\r\n\t *    @return bool True if the port is found.\r\n\t */\r\n\tbool hasPort(const QString& portName) const;\r\n\r\n\t/*!\r\n     *  Check if the type of the port is scalar.\r\n\t *\r\n\t *    @param [in] portName    Specifies the port to check.\r\n\t *\r\n\t *    @return bool True if port is scalar.\r\n\t */\r\n\tbool isScalarPort(const QString& portName) const;\r\n\r\n\t/*!\r\n     *  Get the direction of the specified port on this instance.\r\n\t *\r\n\t *    @param [in] portName    The name of the port that's direction is requested.\r\n\t *\r\n\t *    @return General::Direction Specifies the direction of the port.\r\n\t */\r\n\tDirectionTypes::Direction portDirection(const QString& portName) const;\r\n\r\n\t/*!\r\n     *  Get the physical left bound of the port.\r\n\t *\r\n\t *    @param [in] portName    The name of the port that's bound is wanted.\r\n\t *\r\n\t *    @return int The left bound.\r\n\t */\r\n\tQString getPortPhysLeftBound(const QString& portName) const;\r\n\r\n\t/*!\r\n     *  Get the physical right bound of the port.\r\n\t *\r\n\t *    @param [in] portName    The name of the port that's bound is wanted.\r\n\t *\r\n\t *      return int The right bound.\r\n\t */\r\n\tQString getPortPhysRightBound(const QString& portName) const;\r\n\r\nsignals:\r\n\r\n\t//! Send a notification to user.\r\n\tvoid noticeMessage(const QString& noticeMessage);\r\n\r\n\t//! Send an error message to user.\r\n\tvoid errorMessage(const QString& errorMessage);\r\n\r\nprivate:\r\n\r\n\t//! No copying.\r\n\tVhdlComponentInstance(const VhdlComponentInstance& other);\r\n\r\n\t//! No assignment.\r\n\tVhdlComponentInstance& operator=(const VhdlComponentInstance& other);\r\n\r\n\t/*!\r\n\t *  Add port mapping.\r\n\t *\r\n\t *    @param [in] instancePort    Selected VHDL port map object.\r\n\t *    @param [in] signalMapping   The VHDL mapped signal.\r\n\t */\r\n\tvoid addMapping(const VhdlPortMap& instancePort, const VhdlPortMap& signalMapping );\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! The component declaration.\r\n\tVhdlComponentDeclaration* compDeclaration_;\r\n\r\n\t//! The name of the component instance.\r\n\tQString instanceName_;\r\n\r\n\t//! The name of the type that is is an instantiation of.\r\n\tQString componentModuleName_;\r\n\r\n\t//! The name of the architecture used in this instance.\r\n\tQString architecture_;\r\n\r\n\t//! The description of the instance.\r\n\tQString description_;\r\n\r\n\t/*!\r\n     *  Contains the default values for the ports of this instance.\r\n\t * \r\n\t *  Key: The name of the port. Value: The default value for the port.\r\n\t */\r\n\tQMap<QString, QString> defaultPortConnections_;\r\n\r\n\t/*!\r\n     *  Contains the generic mappings for this instance.\r\n\t * \r\n\t *  Key: The name of the generic. Value: The value mapped for the generic.\r\n\t */\r\n\tQMap<QString, QString> genericMap_;\r\n\r\n\t/*!\r\n     *  Contains the port mappings for this instance.\r\n\t * \r\n\t *  Key: The port name and bounds of this instance.\r\n\t *  Value: The name of the signal/top port and it's bounds the port is connected to.\r\n\t */\r\n\tQMultiMap<VhdlPortMap, VhdlPortMap> portMap_;\r\n\r\n\t//! The used expression parser.\r\n\tQSharedPointer<ExpressionParser> parser_;\r\n};\r\n\r\n#endif // VHDLCOMPONENTINSTANCE_H\r\n"
  },
  {
    "path": "Plugins/VHDLGenerator/vhdlconnectionendpoint.cpp",
    "content": "/* \r\n *  \tCreated on: 26.10.2011\r\n *      Author: Antti Kamppi\r\n * \t\tfilename: vhdlconnectionendpoint.cpp\r\n *\t\tProject: Kactus 2\r\n */\r\n\r\n#include \"vhdlconnectionendpoint.h\"\r\n\r\nVhdlConnectionEndPoint::VhdlConnectionEndPoint():\r\ninstanceName_(),\r\nportName_(),\r\nsignalLeft_(),\r\nsignalRight_(),\r\nportLeft_(),\r\nportRight_() {\r\n}\r\n\r\nVhdlConnectionEndPoint::VhdlConnectionEndPoint(const QString& instanceName, \r\n\t\t\t\t\t\t\t\t\t\t\t   const QString& portName,\r\n\t\t\t\t\t\t\t\t\t\t\t   const QString& portLeft /*= -1*/, \r\n\t\t\t\t\t\t\t\t\t\t\t   const QString& portRight /*= -1*/, \r\n\t\t\t\t\t\t\t\t\t\t\t   const QString& signalLeft /*= -1*/,\r\n\t\t\t\t\t\t\t\t\t\t\t   const QString& signalRight /*= -1*/ ):\r\ninstanceName_(instanceName),\r\nportName_(portName),\r\nsignalLeft_(signalLeft),\r\nsignalRight_(signalRight),\r\nportLeft_(portLeft),\r\nportRight_(portRight) {\r\n}\r\n\r\n\r\nbool VhdlConnectionEndPoint::operator==( const VhdlConnectionEndPoint& other ) const {\r\n\tif (instanceName_ == other.instanceName_ &&\r\n\t\tportName_ == other.portName_ &&\r\n\t\tportLeft_ == other.portLeft_ &&\r\n\t\tportRight_ == other.portRight_) {\r\n\t\treturn true;\r\n\t}\r\n\treturn false;\r\n}\r\n\r\nbool VhdlConnectionEndPoint::operator!=( const VhdlConnectionEndPoint& other ) const {\r\n\tif (instanceName_ != other.instanceName_) \r\n\t\treturn true;\r\n\telse if (portName_ != other.portName_)\r\n\t\treturn true;\r\n\telse if (portLeft_ != other.portLeft_)\r\n\t\treturn true;\r\n\telse if (portRight_ != other.portRight_)\r\n\t\treturn true;\r\n\telse\r\n\t\treturn false;\r\n}\r\n\r\nbool VhdlConnectionEndPoint::operator<( const VhdlConnectionEndPoint& other ) const {\r\n\tif (0 == instanceName_.compare(other.instanceName_.simplified(), Qt::CaseInsensitive)) {\r\n\t\tif (0 == portName_.compare(other.portName_.simplified(), Qt::CaseInsensitive)) {\r\n\t\t\tif (portLeft_ == other.portLeft_) {\r\n\t\t\t\treturn portRight_ < other.portRight_;\r\n\t\t\t}\r\n\t\t\telse {\r\n\t\t\t\treturn portLeft_ < other.portLeft_;\r\n\t\t\t}\r\n\t\t}\r\n\t\telse {\r\n\t\t\treturn portName_.localeAwareCompare(other.portName_) < 0;\r\n\t\t}\r\n\t}\r\n\telse {\r\n\t\treturn instanceName_.localeAwareCompare(other.instanceName_) < 0;\r\n\t}\r\n}\r\n\r\nbool VhdlConnectionEndPoint::operator>( const VhdlConnectionEndPoint& other ) const {\r\n\tif (0 == instanceName_.compare(other.instanceName_.simplified(), Qt::CaseInsensitive)) {\r\n\t\tif (0 == portName_.compare(other.portName_.simplified(), Qt::CaseInsensitive)) {\r\n\t\t\tif (portLeft_ == other.portLeft_) {\r\n\t\t\t\treturn portRight_ > other.portRight_;\r\n\t\t\t}\r\n\t\t\telse {\r\n\t\t\t\treturn portLeft_ > other.portLeft_;\r\n\t\t\t}\r\n\t\t}\r\n\t\telse {\r\n\t\t\treturn portName_.localeAwareCompare(other.portName_) > 0;\r\n\t\t}\r\n\t}\r\n\telse {\r\n\t\treturn instanceName_.localeAwareCompare(other.instanceName_) > 0;\r\n\t}\r\n}\r\n\r\nQString VhdlConnectionEndPoint::instanceName() const {\r\n\treturn instanceName_;\r\n}\r\n\r\nQString VhdlConnectionEndPoint::portName() const {\r\n\treturn portName_;\r\n}\r\n\r\nQString VhdlConnectionEndPoint::signalLeft() const {\r\n\treturn signalLeft_;\r\n}\r\n\r\nQString VhdlConnectionEndPoint::signalRight() const {\r\n\treturn signalRight_;\t\r\n}\r\n\r\nQString VhdlConnectionEndPoint::portLeft() const {\r\n\treturn portLeft_;\r\n}\r\n\r\nQString VhdlConnectionEndPoint::portRight() const {\r\n\treturn portRight_;\r\n}\r\n"
  },
  {
    "path": "Plugins/VHDLGenerator/vhdlconnectionendpoint.h",
    "content": "/* \r\n *  \tCreated on: 26.10.2011\r\n *      Author: Antti Kamppi\r\n * \t\tfilename: vhdlconnectionendpoint.h\r\n *\t\tProject: Kactus 2\r\n */\r\n\r\n#ifndef VHDLCONNECTIONENDPOINT_H\r\n#define VHDLCONNECTIONENDPOINT_H\r\n\r\n#include <QString>\r\n\r\n/*! Used to identify end points for a signal.\r\n * \r\n * This class is used when parsing the connections between component instance \r\n * ports. One end point represents one port or part of it.\r\n */\r\nclass VhdlConnectionEndPoint {\r\n\r\npublic:\r\n\r\n\t/*! The constructor\r\n\t *\r\n\t*/\r\n\tVhdlConnectionEndPoint();\r\n\r\n\t/*! The constructor\r\n\t *\r\n\t * @param [in] instanceName The name of the instance for the end point.\r\n\t * @param [in] portName The name of the port for the end point.\r\n\t * @param [in] portLeft The left bound of the port.\r\n\t * @param [in] portRight The right bound of the port.\r\n\t * @param [in] signalLeft The left bound of the signal.\r\n\t * @param [in] signalRight The right bound of the signal.\r\n\t *\r\n\t*/\r\n\tVhdlConnectionEndPoint(const QString& instanceName,\t\r\n\t\tconst QString& portName, \r\n\t\tconst QString& portLeft = \"-1\",\r\n\t\tconst QString& portRight = \"-1\",\r\n\t\tconst QString& signalLeft = \"-1\",\r\n\t\tconst QString& signalRight = \"-1\");\r\n\r\n\t//! Copy constructor\r\n\tVhdlConnectionEndPoint(const VhdlConnectionEndPoint& other) = default;\r\n\r\n\t//! Assignment operator\r\n\tVhdlConnectionEndPoint& operator=(const VhdlConnectionEndPoint& other) = default;\r\n\r\n\t//! The == operator\r\n\tbool operator==(const VhdlConnectionEndPoint& other) const;\r\n\r\n\t//! The != operator\r\n\tbool operator!=(const VhdlConnectionEndPoint& other) const;\r\n\r\n\t//! The < operator\r\n\tbool operator<(const VhdlConnectionEndPoint& other) const;\r\n\r\n\t//! The > operator\r\n\tbool operator>(const VhdlConnectionEndPoint& other) const;\r\n\r\n\t//! The destructor\r\n\tvirtual ~VhdlConnectionEndPoint() = default;\r\n\r\n\t/*! Get the instance name of the end point.\r\n\t *\r\n\t * @return QString contains the instance name.\r\n\t*/\r\n\tQString instanceName() const;\r\n\r\n\t/*! Get the port name of the end point.\r\n\t *\r\n\t * @return QString contains the port name.\r\n\t*/\r\n\tQString portName() const;\r\n\r\n\t/*! Get the left bound of the signal.\r\n\t *\r\n\t * @return int The left bound.\r\n\t*/\r\n\tQString signalLeft() const;\r\n\r\n\t/*! Get the right bound of the signal.\r\n\t *\r\n\t * @return int The right bound.\r\n\t*/\r\n\tQString signalRight() const;\r\n\r\n\t/*! Get the left bound of the port.\r\n\t *\r\n\t * @return int The left bound.\r\n\t*/\r\n\tQString portLeft() const;\r\n\r\n\t/*! Get the right bound of the port.\r\n\t *\r\n\t * @return int The right bound.\r\n\t*/\r\n\tQString portRight() const;\r\n\r\nprivate:\r\n\r\n\t//! The name of the component instance for the end point.\r\n\tQString instanceName_;\r\n\r\n\t//! The name of the port for the end point.\r\n\tQString portName_;\r\n\r\n\t//! The left bound used from the signal.\r\n\tQString signalLeft_;\r\n\r\n\t//! The right bound used from the signal.\r\n\tQString signalRight_;\r\n\r\n\t//! The left bound used from the port.\r\n\tQString portLeft_;\r\n\r\n\t//! THe right bound used from the port.\r\n\tQString portRight_;\r\n\r\n};\r\n\r\n#endif // VHDLCONNECTIONENDPOINT_H\r\n"
  },
  {
    "path": "Plugins/VHDLGenerator/vhdlgeneral.cpp",
    "content": "/* \r\n *  \tCreated on: 27.10.2011\r\n *      Author: Antti Kamppi\r\n * \t\tfilename: vhdlgeneral.cpp\r\n *\t\tProject: Kactus 2\r\n */\r\n\r\n#include \"vhdlgeneral.h\"\r\n\r\n#include <QString>\r\n#include <QStringList>\r\n#include <QChar>\r\n#include <QObject>\r\n\r\nQString VhdlGeneral::useDefaultType( const int leftBound, const int rightBound )\r\n{\r\n\tQString result(\"std_logic\");\r\n\r\n\t// if port is larger than one bit\r\n\tint size = leftBound - rightBound + 1;\r\n\tif (size > 1)\r\n    {\r\n\t\tresult = QString(\"std_logic_vector\");\r\n\t}\r\n\r\n\treturn result;\r\n}\r\n\r\nQString VhdlGeneral::getDefaultVhdlTypeDef( const QString& typeName )\r\n{\r\n\t// types for package numeric_std\r\n\tif (typeName.compare(QString(\"signed\"), Qt::CaseInsensitive) == 0 ||\r\n\t\ttypeName.compare(QString(\"unsigned\"), Qt::CaseInsensitive) == 0)\r\n    {\r\n\t\treturn QString(\"IEEE.numeric_std.all\");\r\n\t}\r\n\r\n\t// types for package std_logic_1164\r\n\telse if (typeName.compare(QString(\"std_logic_vector\"), Qt::CaseInsensitive) == 0 ||\r\n\t\ttypeName.compare(QString(\"std_ulogic_vector\"), Qt::CaseInsensitive) == 0 ||\r\n\t\ttypeName.compare(QString(\"std_logic\"), Qt::CaseInsensitive) == 0 ||\r\n\t\ttypeName.compare(QString(\"std_ulogic\"), Qt::CaseInsensitive) == 0)\r\n    {\r\n\t\t\treturn QString(\"IEEE.std_logic_1164.all\");\r\n\t}\r\n\r\n\t// types for standard package or user defined types\r\n    return QString();\r\n}\r\n\r\nQString VhdlGeneral::vhdlType2String( const QString& type, int leftBound, int rightBound )\r\n{\r\n\t// the scalar types and types with predefined bounds\r\n\tif (0 == type.compare(QString(\"std_logic\"), Qt::CaseInsensitive) ||\r\n\t\t0 == type.compare(QString(\"bit\"), Qt::CaseInsensitive) ||\r\n\t\t0 == type.compare(QString(\"boolean\"), Qt::CaseInsensitive) ||\r\n\t\t0 == type.compare(QString(\"character\"), Qt::CaseInsensitive) ||\r\n\t\t0 == type.compare(QString(\"severity_level\"), Qt::CaseInsensitive) ||\r\n\t\t0 == type.compare(QString(\"std_ulogic\"), Qt::CaseInsensitive) ||\r\n\t\t0 == type.compare(QString(\"time\"), Qt::CaseInsensitive) ||\r\n\t\t0 == type.compare(QString(\"natural\"), Qt::CaseInsensitive) ||\r\n\t\t0 == type.compare(QString(\"positive\"), Qt::CaseInsensitive))\r\n    {\r\n\t\t// return the type as such because the bounds are not used.\r\n\t\treturn type;\r\n\t}\r\n\t\r\n\t// if the type is an array\r\n\telse if (0 == type.compare(QString(\"bit_vector\"), Qt::CaseInsensitive) ||\r\n\t\t0 == type.compare(QString(\"std_logic_vector\"), Qt::CaseInsensitive) ||\r\n\t\t0 == type.compare(QString(\"std_ulogic_vector\"), Qt::CaseInsensitive) ||\r\n\t\t0 == type.compare(QString(\"string\"), Qt::CaseInsensitive))\r\n    {\r\n\t\tQString result(type);\r\n\t\tresult += QString(\"(%1 downto %2)\").arg(leftBound).arg(rightBound);\r\n\t\treturn result;\r\n\t}\r\n\r\n\t// if the type is numeric\r\n\telse if (0 == type.compare(QString(\"integer\"), Qt::CaseInsensitive) ||\r\n\t\t0 == type.compare(QString(\"real\"), Qt::CaseInsensitive))\r\n    {\r\n\t\tQString result(type);\r\n\t\tresult += QString(\" range %1 to %2\").arg(rightBound).arg(leftBound);\r\n\t\treturn result;\r\n\t}\r\n\t// if user defined type then return it as such\r\n\telse\r\n    {\r\n\t\treturn type;\r\n\t}\r\n}\r\n\r\nvoid VhdlGeneral::writeDescription( const QString& description, QTextStream& stream, const QString& indentation)\r\n{\r\n\tif (description.isEmpty())\r\n    {\r\n\t\tstream << Qt::endl;\r\n\t\treturn;\r\n\t}\r\n\r\n\t// split the description into lines whenever there is a line separator\r\n\tQStringList lines = description.split(QString(\"\\n\"));\r\n\t\r\n\t// at least one line has to be because description was not empty\r\n\tQ_ASSERT(!lines.isEmpty());\r\n\r\n\t// Split long lines.  Simple routine, does not account \r\n\t// indentation and the line's last word can go over 80 chars\r\n\tfor (int i = 0; i < lines.size(); ++i)\r\n    {\r\n\t\tQStringList words = lines.at(i).split(\" \");\t\r\n\t\tint line_len = 0; // num of chars\r\n\t\tfor (int w = 0; w < words.size(); ++w)\r\n        {\t\t\t\r\n\t\t\tif (line_len == 0)\r\n            {\r\n\t\t\t\tstream << indentation << \"--\";\r\n\t\t\t}\r\n\t\t\tstream << \" \" << words.at(w);\r\n\t\t\tline_len += words.at(w).size() +1; //+1 = white space\t\r\n\r\n\t\t\tif (line_len > 70)\r\n            {\r\n\t\t\t\tstream << Qt::endl;\r\n\t\t\t\tline_len = 0;\r\n\t\t\t}\r\n\t\t}\t\t\t\r\n\t\tstream << Qt::endl;\r\n\t}\r\n}\r\n\r\n\r\nbool VhdlGeneral::isScalarType( const QString& typeName )\r\n{\r\n\tif (typeName.compare(QString(\"bit\"), Qt::CaseInsensitive) == 0 ||\r\n\t\ttypeName.compare(QString(\"boolean\"), Qt::CaseInsensitive) == 0 ||\r\n\t\ttypeName.compare(QString(\"character\"), Qt::CaseInsensitive) == 0 ||\r\n\t\ttypeName.compare(QString(\"severity_level\"), Qt::CaseInsensitive) == 0 ||\r\n\t\ttypeName.compare(QString(\"std_logic\"), Qt::CaseInsensitive) == 0 ||\r\n\t\ttypeName.compare(QString(\"std_ulogic\"), Qt::CaseInsensitive) == 0 ||\r\n\t\ttypeName.compare(QString(\"natural\"), Qt::CaseInsensitive) == 0 ||\r\n\t\ttypeName.compare(QString(\"positive\"), Qt::CaseInsensitive) == 0 ||\r\n\t\ttypeName.compare(QString(\"integer\"), Qt::CaseInsensitive) == 0 ||\r\n\t\ttypeName.compare(QString(\"real\"), Qt::CaseInsensitive) == 0)\r\n    {\r\n\t\t\treturn true;\r\n\t}\r\n\telse\r\n    {\r\n\t\treturn false;\r\n\t}\r\n}\r\n\r\nbool VhdlGeneral::checkVhdlTypeMatch( const QString& type1, const QString& type2 )\r\n{\r\n\t// if the types are the same then of course they are compatible\r\n\tif (type1 == type2)\r\n    {\r\n\t\treturn true;\r\n\t}\r\n\r\n\t// std_logic and std_logic_vector can be connected to each other\r\n\telse if ((type1 == \"std_logic\" && type2 == \"std_logic_vector\") ||\r\n        (type1 == \"std_logic_vector\" && type2 == \"std_logic\"))\r\n    {\r\n\t\treturn true;\r\n\t}\r\n\r\n\t// other types can't be connected to each other\r\n\telse\r\n    {\r\n\t\treturn false;\r\n\t}\r\n}\r\n\r\nQString VhdlGeneral::convertDefaultValue( const QString& originalDefaultValue, const QString& type )\r\n{\r\n\t// if there is no original default value given\r\n\tif (originalDefaultValue.isEmpty())\r\n    {\r\n\t\treturn QObject::tr(\"No default value given\");\r\n\t}\r\n\r\n\t// the types that do not need \"\" or ''\r\n\tif (type == \"boolean\" ||\r\n\t\ttype == \"integer\" ||\r\n\t\ttype == \"natural\" ||\r\n\t\ttype == \"positive\" ||\r\n\t\ttype == \"real\" ||\r\n\t\ttype == \"severity_level\" ||\r\n\t\ttype == \"time\")\r\n    {\r\n\t\treturn originalDefaultValue;\r\n\t}\r\n\t// the types that use ''\r\n\telse if (type == \"bit\" ||\r\n\t\ttype == \"character\" ||\r\n\t\ttype == \"std_logic\" ||\r\n\t\ttype == \"std_ulogic\")\r\n    {\r\n\t\t\t// char for '\r\n\t\t\tQChar charToAdd(39);\r\n\r\n\t\t\t// remove the white spaces from start and end\r\n\t\t\tQString result(originalDefaultValue.simplified());\r\n\r\n\t\t\t// if theres only one character then add ' to both start and end\r\n\t\t\tif (originalDefaultValue.size() == 1)\r\n            {\r\n\t\t\t\treturn QString(\"'%1'\").arg(originalDefaultValue);\r\n\t\t\t}\r\n\t\t\t// if start is missing '\r\n\t\t\telse if (result.at(0) != charToAdd)\r\n            {\r\n\t\t\t\tresult.prepend(charToAdd);\r\n\t\t\t}\r\n\t\t\t// if end is missing '\r\n\t\t\tif (result.at(result.size() - 1) != charToAdd)\r\n            {\r\n\t\t\t\tresult.append(charToAdd);\r\n\t\t\t} \r\n\r\n\t\t\treturn result;\r\n\t}\r\n\t\r\n\t// types that use \"\"\r\n\telse if (type == \"bit_vector\" ||\r\n\t\ttype == \"std_logic_vector\" ||\r\n\t\ttype == \"std_ulogic_vector\" ||\r\n\t\ttype == \"string\" ||\r\n\t\ttype == \"signed\" ||\r\n\t\ttype == \"unsigned\")\r\n    {\r\n\t\t// char for \"\r\n\t\tQChar charToAdd(34);\r\n\r\n\t\t// remove white space from start and end\r\n\t\tQString result(originalDefaultValue.simplified());\r\n\r\n\t\t// if the first letter is a decimal digit\r\n\t\tif (result.at(0) != charToAdd)\r\n\t\t{\r\n\t\t\tresult.prepend(charToAdd);\r\n\t\t}\r\n\r\n        // if end is missing \"\r\n        if (result.at(result.size() - 1) != charToAdd)\r\n        {\r\n            result.append(charToAdd);\r\n        }\r\n\r\n\t\treturn result;\r\n\t}\r\n\telse\r\n    {\r\n\t\treturn originalDefaultValue;\r\n\t}\r\n}\r\n"
  },
  {
    "path": "Plugins/VHDLGenerator/vhdlgeneral.h",
    "content": "/* \r\n *  \tCreated on: 27.10.2011\r\n *      Author: Antti Kamppi\r\n * \t\tfilename: vhdlgeneral.h\r\n *\t\tProject: Kactus 2\r\n */\r\n\r\n#ifndef VHDLGENERAL_H\r\n#define VHDLGENERAL_H\r\n\r\n#include <QString>\r\n#include <QTextStream>\r\n\r\nnamespace VhdlGeneral {\r\n\r\n\t//! The number of supported vhdl types.\r\n\tconst unsigned int VHDL_TYPE_COUNT = 17;\r\n\r\n\t//! The list of supported vhdl types.\r\n\tconst QString VHDL_TYPES[] = {\r\n\t\t\"bit\",\r\n\t\t\"bit_vector\",\r\n\t\t\"boolean\",\r\n\t\t\"character\",\r\n\t\t\"integer\",\r\n\t\t\"natural\",\r\n\t\t\"positive\",\r\n\t\t\"real\",\r\n\t\t\"severity_level\",\r\n\t\t\"signed\",\r\n\t\t\"std_logic\",\r\n\t\t\"std_logic_vector\",\r\n\t\t\"std_ulogic\",\r\n\t\t\"std_ulogic_vector\",\r\n\t\t\"string\",\r\n\t\t\"time\",\r\n\t\t\"unsigned\"\r\n\t};\r\n\r\n\t//! The number of supported vhdl type definitions\r\n\tconst unsigned int VHDL_TYPEDEF_COUNT = 2;\r\n\r\n\t//! The list of supported vhdl type definitions\r\n\tconst QString VHDL_TYPE_DEFINITIONS[] = {\r\n\t\t\"IEEE.std_logic_1164.all\",\r\n\t\t\"IEEE.numeric_std.all\",\r\n\t};\r\n\r\n\t/*! Check if the port type is scalar.\r\n\t *\r\n\t * @param [in] typeName The name of the port type to check.\r\n\t *\r\n\t * @return bool True if port type is for scalar port.\r\n\t*/\r\n\tbool isScalarType(const QString& typeName);\r\n\r\n\t/*! Get the default type definition for a given type name.\r\n\t *\r\n\t * @param [in] typeName Specified the name of the type.\r\n\t *\r\n\t * @return QString contains the default vhdl type definition for given type name.\r\n\t*/\r\n\tQString getDefaultVhdlTypeDef(const QString& typeName);\r\n\r\n\t/*! Create a string that defines a vhdl type.\r\n\t * \r\n\t * If the size of the given bounds is 1 then \"std_logic\" is returned.\r\n\t * If the size is greater than 1 then \"std_logic_vector\" is returned.\r\n\t * \r\n\t * @param [in] leftBound The left bound for the type.\r\n\t * @param [in] rightBound The right bound for the type.\r\n\t *\r\n\t * @return QString contains the the type.\r\n\t*/\r\n\tQString useDefaultType(const int leftBound, const int rightBound);\r\n\r\n\t/*! Create a string that contains the type and bounds for it.\r\n\t * \r\n\t * For std_logic_vector created string is: std_logic_vector(<left> downto <right>)\r\n\t * For std_logic created string is (bounds do not matter): std_logic\r\n\t * For integer created string is: integer range <right> to <left>\r\n\t * \r\n\t * @param [in] type Specifies the vhdl type.\r\n\t * @param [in] leftBound The left bound or the higher bound for the type.\r\n\t * @param [in] rightBound The right bound or the lower bound for the type.\r\n\t *\r\n\t * @return VhdlGeneral::QString\r\n\t*/\r\n\tQString vhdlType2String(const QString& type, \r\n\t\tconst int leftBound = -1,\r\n\t\tconst int rightBound = -1);\r\n\r\n\t/*! Write a description of some element to the stream.\r\n\t * \r\n\t * @param [in] description The description to write.\r\n\t * @param [in] stream      The text stream to write into.\r\n\t * @param [in] indentation Added to the beginning of each new line, e.g.\"  \" or  \"\\t\"\r\n\t *\r\n\t*/\r\n\tvoid writeDescription(const QString& description,\r\n\t\tQTextStream& stream, \r\n\t\tconst QString& indentation = QString(\"\"));\r\n\r\n\t/*! Check the vhdl types if they can be connected to each other.\r\n\t *\r\n\t * @param [in] type1 The first type to compare.\r\n\t * @param [in] type2 The second type to compare.\r\n\t *\r\n\t * @return bool True if the types are compatible.\r\n\t*/\r\n\r\n\r\n\tbool checkVhdlTypeMatch(const QString& type1, const QString& type2);\r\n\r\n\t/*! Take a default value and add \"\" or '' around it if needed depending on the type\r\n\t *\r\n\t * @param [in] originalDefaultValue The default value\r\n\t * @param [in] type The type of the value.\r\n\t *\r\n\t * @return QString The default value that can be written to vhdl (this contains the \"\" or '')\r\n\t*/\r\n\tQString convertDefaultValue(const QString& originalDefaultValue, \r\n\t\tconst QString& type);\r\n}\r\n\r\n#endif // VHDLGENERAL_H"
  },
  {
    "path": "Plugins/VHDLGenerator/vhdlgenerator2.cpp",
    "content": "/* \r\n *  \tCreated on: 26.10.2011\r\n *      Author: Antti Kamppi\r\n * \t\tfilename: vhdlgenerator2.cpp\r\n *\t\tProject: Kactus 2\r\n *\r\n *      Creates a structural VHDL file with following structure\r\n *      1. File header \r\n *      2. Libraries\r\n *      3. Entity declaration\r\n *      4. Architecture\r\n *         - Signals (+ user's own code)\r\n *         - Component declarations\r\n *         - Component instantiations (+ user's own code)\r\n */\r\n\r\n#include \"vhdlgenerator2.h\"\r\n\r\n#include \"vhdlgeneral.h\"\r\n#include \"vhdlportmap.h\"\r\n\r\n#include <KactusAPI/include/LibraryInterface.h>\r\n\r\n#include <IPXACTmodels/common/Document.h>\r\n#include <IPXACTmodels/common/PortAlignment.h>\r\n\r\n#include <IPXACTmodels/generaldeclarations.h>\r\n\r\n#include <IPXACTmodels/Component/BusInterface.h>\r\n#include <IPXACTmodels/Component/ComponentInstantiation.h>\r\n#include <IPXACTmodels/Component/DesignInstantiation.h>\r\n#include <IPXACTmodels/Component/DesignConfigurationInstantiation.h>\r\n#include <IPXACTmodels/Component/FileSet.h>\r\n#include <IPXACTmodels/Component/File.h>\r\n#include <IPXACTmodels/Component/PortMap.h>\r\n#include <IPXACTmodels/Component/Port.h>\r\n#include <IPXACTmodels/Component/View.h>\r\n\r\n#include <IPXACTmodels/Design/Interconnection.h>\r\n#include <IPXACTmodels/Design/validator/DesignValidator.h>\r\n#include <IPXACTmodels/DesignConfiguration/validators/DesignConfigurationValidator.h>\r\n\r\n#include <IPXACTmodels/utilities/ComponentSearch.h>\r\n\r\n#include <KactusAPI/include/ExpressionFormatter.h>\r\n#include <KactusAPI/include/ExpressionParser.h>\r\n#include <KactusAPI/include/IPXactSystemVerilogParser.h>\r\n#include <KactusAPI/include/ComponentParameterFinder.h>\r\n#include <KactusAPI/include/ExpressionFormatterFactoryImplementation.h>\r\n\r\n#include <KactusAPI/include/utils.h>\r\n\r\n#include <QFile>\r\n#include <QFileInfo>\r\n#include <QTime>\r\n#include <QDate>\r\n#include <QSettings>\r\n\r\nstatic const QString BLACK_BOX_DECL_START = \"-- ##KACTUS2_BLACK_BOX_DECLARATIONS_BEGIN##\";\r\nstatic const QString BLACK_BOX_DECL_END = \"-- ##KACTUS2_BLACK_BOX_DECLARATIONS_END##\";\r\nstatic const QString BLACK_BOX_ASSIGN_START = \"-- ##KACTUS2_BLACK_BOX_ASSIGNMENTS_BEGIN##\";\r\nstatic const QString BLACK_BOX_ASSIGN_END = \"-- ##KACTUS2_BLACK_BOX_ASSIGNMENTS_END##\";\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: vhdlgenerator2::VhdlGenerator2()\r\n//-----------------------------------------------------------------------------\r\nVhdlGenerator2::VhdlGenerator2(QSharedPointer<ExpressionParser> parser, LibraryInterface* handler, QObject* parent):\r\nQObject(parent),\r\nhandler_(handler)\r\n{\r\n\tQ_ASSERT(handler);\r\n\r\n    designvalidator_ = QSharedPointer<DesignValidator> (new DesignValidator(parser, handler_));\r\n    designConfigurationValidator_ =\r\n        QSharedPointer<DesignConfigurationValidator>(new DesignConfigurationValidator(parser, handler_));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: vhdlgenerator2::handler()\r\n//-----------------------------------------------------------------------------\r\nLibraryInterface* VhdlGenerator2::handler() const\r\n{\r\n\treturn handler_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: vhdlgenerator2::parse()\r\n//-----------------------------------------------------------------------------\r\nbool VhdlGenerator2::parse( QSharedPointer<Component> topLevelComponent, const QString& viewName )\r\n{\r\n\tQ_ASSERT(topLevelComponent);\r\n\tcomponent_ = topLevelComponent;\r\n\r\n    QSharedPointer<ComponentParameterFinder> topFinder (new ComponentParameterFinder(topLevelComponent));\r\n    topComponentParser_ = QSharedPointer<IPXactSystemVerilogParser>(new IPXactSystemVerilogParser(topFinder));\r\n\r\n\temit noticeMessage(tr(\"Parsing the IP-Xact models...\"));\r\n\r\n\t// the name of the top-level entity is the name of the top-level component\r\n\ttopLevelEntity_ = component_->getVlnv().getName();\r\n\tviewName_ = viewName;\r\n\t\r\n\t// if the parsing fails\r\n\tif (!parseDesignAndConfiguration())\r\n    {\r\n\t\treturn false;\r\n\t}\r\n\r\n\t// get the types that are used for the ports.\r\n\tfor (auto const& port : *component_->getPorts())\r\n\t{\r\n\t\ttypeDefinitions_.append( port->getTypeDefinitions() );\r\n\t}\r\n\r\n\t// parse the info for the top entity\r\n\tparseTopGenerics(viewName);\r\n\tparseTopPorts();\r\n\r\n\t// if design is used then these can be parsed also\r\n\tif (design_)\r\n    {\r\n\t\tparseInstances();\r\n\t\tparseInterconnections();\r\n\t\tparseAdHocConnections();\r\n\t\tmapPorts2Signals();\r\n\r\n\t\t// tell each instance to use the default port value for the unconnected ports.\r\n\t\tfor (auto const& instance : instances_)\r\n        {\r\n\t\t\tinstance->useDefaultsForOtherPorts();\r\n\t\t}\r\n\r\n\t\t// tell each component declaration to check for it's ports and uncomment those that are needed\r\n\t\tfor (auto const& comp : components_)\r\n        {\r\n\t\t\tcomp->checkPortConnections();\r\n\t\t}\r\n\t}\r\n\t// if design is not used then set all ports uncommented.\r\n\telse\r\n    {\r\n\t\tfor (QMap<VhdlPortSorter, QSharedPointer<VhdlPort> >::iterator i = topPorts_.begin();\r\n\t\t\ti != topPorts_.end(); ++i)\r\n        {\r\n\t\t\ti.value()->setCommented(false);\r\n\t\t}\r\n\t}\r\n\r\n\treturn true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: vhdlgenerator2::generate()\r\n//-----------------------------------------------------------------------------\r\nvoid VhdlGenerator2::generate( const QString& outputFileName)\r\n{\r\n\tif (outputFileName.isEmpty())\r\n    {\r\n\t\treturn;\r\n\t}\r\n\r\n\tQFile file(outputFileName);\r\n\r\n\t// if previous file exists then remove it.\r\n\tif (file.exists())\r\n    {\r\n\t\t// read the existing user-modifiable code from the file\r\n\t\treadUserModifiablePart(file);\r\n\r\n\t\tfile.remove();\r\n\t}\r\n\r\n\t// open the file and erase all old contents if any exists\r\n\t// if file could not be opened\r\n\tif (!file.open(QFile::Truncate | QFile::WriteOnly))\r\n    {\r\n\t\tQString message(tr(\"File: \"));\r\n\t\tmessage += outputFileName;\r\n\t\tmessage += tr(\" couldn't be opened for writing\");\r\n\t\temit errorMessage(message);\r\n\t\treturn;\r\n\t}\r\n\t// now file has been opened for writing\r\n\r\n\t// open file stream to write to\r\n\tQTextStream vhdlStream(&file);\r\n\r\n\tQFileInfo fileInfo(outputFileName);\r\n\r\n\temit noticeMessage(tr(\"Writing the vhdl file...\"));\r\n\r\n\t\r\n\t// write header comments of the file\r\n\twriteVhdlHeader(vhdlStream, fileInfo.fileName());\r\n\r\n\t// always add IEEE library\r\n\tvhdlStream << \"library IEEE;\" << Qt::endl;\r\n\r\n\t// write the libraries needed \r\n\tlibraries_.append(\"work\");\r\n\tlibraries_.removeDuplicates();\r\n\r\n\t// declare the libraries used.\r\n\tforeach (QString const& library, libraries_)\r\n    {\r\n\t\tif (!library.isEmpty())\r\n        {\r\n\t\t\tvhdlStream << \"library \" << library << \";\" << Qt::endl;\r\n\r\n\t\t\ttypeDefinitions_.append(QString(\"%1.all\").arg(library));\r\n\t\t}\r\n\t}\r\n\r\n\t// always add the library for std_logic and std_logic_vector\r\n\ttypeDefinitions_.append(\"IEEE.std_logic_1164.all\");\r\n\ttypeDefinitions_.removeDuplicates();\r\n\r\n    // write all type defs needed\r\n    foreach (QString const& portTypeDef, typeDefinitions_)\r\n    {\r\n        vhdlStream << \"use \" << portTypeDef << \";\" << Qt::endl;\r\n    }\r\n\tvhdlStream << Qt::endl;\r\n\r\n\t// write the top-level entity\r\n\tvhdlStream << \"entity \" << topLevelEntity_ << \" is\" << Qt::endl << Qt::endl;\r\n\r\n\t// write the top-level generics\r\n\twriteGenerics(vhdlStream);\r\n\r\n\t// write the top-level ports\r\n\twritePorts(vhdlStream);\r\n\r\n\t// end top-level entity definition\r\n\tvhdlStream << \"end \" << topLevelEntity_ << \";\" << Qt::endl << Qt::endl;\r\n\r\n\t// if view has description\r\n\tQString viewDescription;\r\n\t\r\n\tforeach ( QSharedPointer<View> currentView, *component_->getViews() )\r\n\t{\r\n\t\tif ( currentView->name() == viewName_ )\r\n\t\t{\r\n\t\t\tviewDescription = currentView->description();\r\n\t\t\tbreak;\r\n\t\t}\r\n\t}\r\n\r\n\tVhdlGeneral::writeDescription(viewDescription, vhdlStream);\r\n\r\n\tQString architectureName = viewName_;\r\n\tif (architectureName.isEmpty())\r\n    {\r\n\t\tarchitectureName = \"structural\";\r\n\t}\r\n\r\n\t// write the architecture of the entity\r\n\tvhdlStream << \"architecture \" << architectureName << \" of \" << topLevelEntity_ << \" is\" << Qt::endl << Qt::endl;\r\n\r\n\twriteSignalDeclarations(vhdlStream);\r\n\r\n\twriteComponentDeclarations(vhdlStream);\r\n\r\n\twriteUserModifiedDeclarations(vhdlStream);\r\n\r\n\t// start writing architecture component instances\r\n\tvhdlStream << Qt::endl << \"begin\" << Qt::endl << Qt::endl;\r\n\r\n\twriteUserModifiedAssignments(vhdlStream);\r\n\r\n\twriteComponentInstances(vhdlStream);\r\n\r\n\tvhdlStream << \"end \" << architectureName << \";\" << Qt::endl << Qt::endl;\r\n\r\n\tfile.close();\r\n\r\n\temit noticeMessage(tr(\"Done writing the vhdl file.\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: vhdlgenerator2::addRTLView()\r\n//-----------------------------------------------------------------------------\r\nbool VhdlGenerator2::addRTLView(QString const& fileSetName, const QString& vhdlFileName )\r\n{\r\n\t// ipDir represents the directory where the IP-Xact file is located in.\r\n\tQString ipDir(handler_->getPath(component_->getVlnv()));\r\n\tif (ipDir.isEmpty())\r\n    {\r\n\t\temit errorMessage(tr(\"Path to top-component was not found.\"));\r\n\t\treturn false;\r\n\t}\r\n    \r\n\t// get the relative path to add to file set\r\n\tQString relativePath = General::getRelativeSavePath(ipDir, vhdlFileName);\r\n\tif (relativePath.isEmpty())\r\n    {\r\n\t\temit errorMessage(tr(\"Could not create relative path to vhdl file.\"));\r\n\t\treturn false;\r\n\t}\r\n\r\n\tQSharedPointer<FileSet> topFileSet = component_->getFileSet(fileSetName);\r\n\r\n\t// if the top vhdl file set was not found. Create one\r\n\tif (!topFileSet)\r\n    {\r\n\t\ttopFileSet = QSharedPointer<FileSet>(new FileSet(fileSetName, \"sourceFiles\"));\r\n\t\tcomponent_->getFileSets()->append(topFileSet);\r\n\r\n\t\tQSharedPointer<FileBuilder> vhdlBuilder(new FileBuilder(\"vhdlSource\"));\r\n\t\tvhdlBuilder->setCommand(\"vcom\");\r\n\t\tvhdlBuilder->setFlags(\"-quiet -check_synthesis -work work\");\r\n\t\tvhdlBuilder->setReplaceDefaultFlags(\"true\");\r\n\t\ttopFileSet->getDefaultFileBuilders()->append(vhdlBuilder);\r\n\r\n\t\tQSharedPointer<FileBuilder> vhdl87Builder(new FileBuilder(\"vhdlSource-87\"));\r\n\t\tvhdl87Builder->setCommand(\"vcom\");\r\n\t\tvhdl87Builder->setFlags(\"-quiet -check_synthesis -work work\");\r\n\t\tvhdl87Builder->setReplaceDefaultFlags(\"true\");\r\n\t\ttopFileSet->getDefaultFileBuilders()->append(vhdl87Builder);\r\n\r\n\t\tQSharedPointer<FileBuilder> vhdl93Builder(new FileBuilder(\"vhdlSource-93\"));\r\n\t\tvhdl93Builder->setCommand(\"vcom\");\r\n\t\tvhdl93Builder->setFlags(\"-quiet -check_synthesis -work work\");\r\n\t\tvhdl93Builder->setReplaceDefaultFlags(\"true\");\r\n\t\ttopFileSet->getDefaultFileBuilders()->append(vhdl93Builder);\r\n\t}\r\n\r\n\tQSettings settings;\r\n    \r\n\t// create a new file\r\n\tQSharedPointer<File> topVhdlFile = topFileSet->addFile(relativePath, settings);\r\n\tFileType vhdlFileType(QStringLiteral(\"vhdlSource\"));\r\n\ttopVhdlFile->setIncludeFile(true);\r\n\ttopVhdlFile->setLogicalName(\"work\");\r\n\ttopVhdlFile->setCommand(QString(\"vcom\"));\r\n\ttopVhdlFile->setBuildFlags(\"-quiet -check_synthesis -work work\", \"true\");\r\n\ttopVhdlFile->getFileTypes()->append(vhdlFileType);\r\n\r\n    if (!component_->hasView(viewName_))\r\n    {\r\n        QSharedPointer<View> targetView(new View(viewName_));\r\n        QSharedPointer<View::EnvironmentIdentifier> envId( new View::EnvironmentIdentifier );\r\n        envId->language = \"vhdl\";\r\n        envId->tool = \"Kactus2\";\r\n        targetView->addEnvIdentifier(envId);\r\n    \r\n        component_->getViews()->append(targetView);\r\n    }\r\n\r\n    QSharedPointer<View> rtlView = component_->getModel()->findView(viewName_);\r\n\r\n    QString instantiationName = QString(\"%1_vhd\").arg(viewName_);\r\n    rtlView->setComponentInstantiationRef(instantiationName);\r\n\r\n    QSharedPointer<ComponentInstantiation> componentInstantiation = \r\n        component_->getModel()->findComponentInstantiation(instantiationName);\r\n    if (!componentInstantiation)\r\n    {\r\n        componentInstantiation = QSharedPointer<ComponentInstantiation>(new ComponentInstantiation(instantiationName));\r\n        component_->getComponentInstantiations()->append(componentInstantiation);\r\n    }\r\n\r\n    componentInstantiation->setModuleName(topLevelEntity_);\r\n    componentInstantiation->setLanguage(\"vhdl\");\r\n\r\n\tQString architectureName = viewName_;\r\n\tif (architectureName.isEmpty())\r\n    {\r\n        architectureName = \"rtl\";\t\t\r\n\t}\r\n\r\n    componentInstantiation->setArchitectureName(architectureName);\r\n\r\n    if (!componentInstantiation->getFileSetReferenceStrings().contains(fileSetName))\r\n    {\r\n        QSharedPointer<FileSetRef> newFileSetRef(new FileSetRef());\r\n        newFileSetRef->setReference(fileSetName);\r\n\r\n        componentInstantiation->getFileSetReferences()->append(newFileSetRef);\r\n    }\t\r\n\r\n\treturn true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: vhdlgenerator2::parseDesignAndConfiguration()\r\n//-----------------------------------------------------------------------------\r\nbool VhdlGenerator2::parseDesignAndConfiguration()\r\n{\r\n\tQ_ASSERT(component_);\r\n\r\n\t// if view is not specified it is not error it just means that only the top entity should be created.\r\n\tif (viewName_.isEmpty())\r\n    {\r\n\t\treturn true;\r\n\t}\r\n\r\n\t// if view is specified but it does not exist\r\n    QSharedPointer<View> view = ComponentSearch::findView(component_, viewName_);\r\n\r\n    // if view is not found\r\n    if (!view)\r\n    {\r\n        return false;\r\n    }\r\n    else if (view->isHierarchical())\r\n    {\r\n        VLNV designVLNV = ComponentSearch::findDesignReference(component_, handler_, view);\r\n        VLNV configurationVLNV = ComponentSearch::findDesignConfigurationReference(component_, view);        \r\n\r\n        design_ = handler_->getDesign(designVLNV);        \r\n        if (!design_)\r\n        {\r\n            emit errorMessage(tr(\"The design %1 referenced in component %2 was not found in library.\").arg(\r\n                designVLNV.toString()).arg(component_->getVlnv().toString()));\r\n            return false;\r\n        }\r\n        // if design is found then make sure it is valid\r\n        else\r\n        {\r\n            if (!designvalidator_->validate(design_))\r\n            {\r\n                QStringList errorList;\r\n                designvalidator_->findErrorsIn(errorList, design_);\r\n\r\n                emit noticeMessage(tr(\"The design '%1' contained the following errors:\").\r\n                    arg(design_->getVlnv().toString()));\r\n\r\n                for (auto const& designError : errorList)\r\n                {\r\n                    emit errorMessage(designError);\r\n                }\r\n\r\n                return false;\r\n            }\r\n        }\r\n        desConf_ = handler_->getModel<DesignConfiguration>(configurationVLNV);\r\n        // if design configuration is found the make sure it is also valid\r\n        if (desConf_ && !designConfigurationValidator_->validate(desConf_))\r\n        {\r\n            QVector<QString> errorList;\r\n            designConfigurationValidator_->findErrorsIn(errorList, desConf_);\r\n\r\n            emit noticeMessage(tr(\"The design configuration '%1' contained the following errors:\").\r\n                arg(desConf_->getVlnv().toString()));\r\n\r\n            for (auto const& configurationError : errorList)\r\n            {\r\n                emit errorMessage(configurationError);\r\n            }\r\n\r\n            return false;\r\n        }\r\n    }\r\n\r\n    // the design and possibly the configuration are now parsed\r\n    return true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: vhdlgenerator2::containsArchitecture()\r\n//-----------------------------------------------------------------------------\r\nbool VhdlGenerator2::containsArchitecture() const\r\n{\r\n\t// if design exists then architecture can be created\r\n\treturn design_.isNull() == false;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: vhdlgenerator2::parseTopGenerics()\r\n//-----------------------------------------------------------------------------\r\nvoid VhdlGenerator2::parseTopGenerics(QString const& viewName)\r\n{\r\n\tQSharedPointer<View> view = ComponentSearch::findView(component_, viewName);\r\n\r\n    if (view)\r\n    {\r\n        QSharedPointer<ComponentInstantiation> cimp;\r\n\r\n        foreach (QSharedPointer<ComponentInstantiation> currentInsta, *component_->getComponentInstantiations())\r\n        {\r\n            if (currentInsta->name() == view->getComponentInstantiationRef())\r\n            {\r\n                cimp = currentInsta;\r\n                break;\r\n            }\r\n        }\r\n        \r\n        if (cimp)\r\n        {\r\n            ExpressionFormatterFactoryImplementation formatterFactory;\r\n            QSharedPointer<ExpressionFormatter> formatter(formatterFactory.makeExpressionFormatter(component_));\r\n\r\n            foreach (QSharedPointer<ModuleParameter> moduleParam, *cimp->getModuleParameters())\r\n            {\r\n                QSharedPointer<VhdlGeneric> generic(new VhdlGeneric(moduleParam, formatter));\r\n                topGenerics_.insert(moduleParam->name(), generic);\r\n            }\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: vhdlgenerator2::parseTopPorts()\r\n//-----------------------------------------------------------------------------\r\nvoid VhdlGenerator2::parseTopPorts()\r\n{\r\n\tforeach (QSharedPointer<Port> port, *component_->getPorts())\r\n\t{\r\n\t\t// do not add ports with invalid direction or phantom direction\r\n\t\tif (port->getDirection() == DirectionTypes::DIRECTION_INVALID ||\r\n\t\t\tport->getDirection() == DirectionTypes::DIRECTION_PHANTOM)\r\n        {\r\n\t\t\t\tcontinue;\r\n\t\t}\r\n\r\n\t\t// create the actual port\r\n\t\tQSharedPointer<VhdlPort> vhdlPort(new VhdlPort(port, topComponentParser_));\r\n\r\n        QString busInterfaceName = getContainingBusInterfaceName(component_, port->name());\r\n\r\n\t\t// create the sorter instance\r\n        VhdlPortSorter sorter(busInterfaceName, vhdlPort->name(), port->getDirection());\r\n\r\n\t\t// this port can not be created yet\r\n\t\tQ_ASSERT(!topPorts_.contains(sorter));\r\n\r\n\t\ttopPorts_.insert(sorter, vhdlPort);\r\n\t}\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: vhdlgenerator2::parseInstances()\r\n//-----------------------------------------------------------------------------\r\nvoid VhdlGenerator2::parseInstances()\r\n{\r\n\tQ_ASSERT(design_);\r\n\r\n    ExpressionFormatterFactoryImplementation formatterFactory;\r\n\r\n\tfor (QSharedPointer<ComponentInstance> instance : *design_->getComponentInstances())\r\n    {\r\n\t\tVLNV::IPXactType instanceType = handler_->getDocumentType(*instance->getComponentRef());\r\n\r\n\t\t// if vlnv is not found in library\r\n\t\tif (instanceType == VLNV::INVALID)\r\n        {\r\n\t\t\temit errorMessage(tr(\"Component %1 referenced in design %2 was not found in library.\").arg(\r\n                instance->getComponentRef()->toString(), component_->getVlnv().toString()));\r\n\t\t\tcontinue;\r\n\t\t}\r\n\t\t// if vlnv does not reference a component\r\n\t\telse if (instanceType != VLNV::COMPONENT)\r\n        {\r\n\t\t\temit errorMessage(tr(\"VLNV %1 does not belong to a component.\").arg(\r\n\t\t\t\tinstance->getComponentRef()->toString()));\r\n\t\t\tcontinue;\r\n\t\t}\r\n\r\n        \t\t\tQSharedPointer<Document> libComp = handler_->getModel(*instance->getComponentRef());\r\n\t\t\tQSharedPointer<Component> component = libComp.staticCast<Component>();\r\n\t\t\tQ_ASSERT(component);\r\n\r\n        QSharedPointer<ParameterFinder> instanceFinder(new ComponentParameterFinder(component));\r\n        QSharedPointer<ExpressionParser> instanceParser(new IPXactSystemVerilogParser(instanceFinder));\r\n\r\n\t\t// pointer to the matching component declaration\r\n\t\tQSharedPointer<VhdlComponentDeclaration> compDeclaration;\r\n\t\t\r\n\t\t// if component declaration is already created\r\n\t\tif (components_.contains(*instance->getComponentRef()))\r\n        {\r\n\t\t\tcompDeclaration = components_.value(*instance->getComponentRef());\r\n\t\t}\r\n\r\n\t\t// if component declaration is not yet created then create it\r\n\t\telse\r\n        {\r\n\r\n\t\t\tcompDeclaration = QSharedPointer<VhdlComponentDeclaration>(new VhdlComponentDeclaration(component, instanceParser));\r\n\t\t\tcomponents_.insert(*instance->getComponentRef(), compDeclaration);\r\n\t\t}\r\n\t\tQ_ASSERT(compDeclaration);\r\n\r\n\t\tQString instanceActiveView;\r\n\t\t// if configuration is used then get the active view for the instance\r\n\t\tif (desConf_)\r\n        {\r\n\t\t\tinstanceActiveView = desConf_->getActiveView(instance->getInstanceName());\r\n\t\t}\r\n\r\n\t\t// create the instance\r\n\t\tQSharedPointer<VhdlComponentInstance> compInstance(new VhdlComponentInstance(this, handler_,\r\n            compDeclaration.data(), instance->getInstanceName(), instanceParser, instanceActiveView, instance->description()));\r\n\r\n        connect(compInstance.data(), SIGNAL(noticeMessage(const QString&)),\r\n            this, SIGNAL(noticeMessage(const QString&)), Qt::UniqueConnection);\r\n        connect(compInstance.data(), SIGNAL(errorMessage(const QString&)),\r\n            this, SIGNAL(errorMessage(const QString)), Qt::UniqueConnection);\r\n\r\n\t\tQSharedPointer<ComponentInstantiation> componentInstantiation;\r\n\r\n\t\tfor (QSharedPointer<ComponentInstantiation> currentInstantiation :\r\n\t\t\t*compInstance->componentModel()->getComponentInstantiations())\r\n\t\t{\r\n\t\t\tif (currentInstantiation->name() == instanceActiveView)\r\n\t\t\t{\r\n\t\t\t\tcomponentInstantiation = currentInstantiation;\r\n\t\t\t\tbreak;\r\n\t\t\t}\r\n\t\t}\r\n\r\n        if (componentInstantiation)\r\n        {\r\n            // add the libraries of the instantiated component to the library list.\r\n            for (auto const& fileSetRef : componentInstantiation->getFileSetReferenceStrings())\r\n            {\r\n                QSharedPointer<FileSet> fileSet = compInstance->componentModel()->getFileSet(fileSetRef);\r\n\r\n                if (fileSet)\r\n                {\r\n                    libraries_.append( fileSet->getVhdlLibraryNames() );\r\n                }\r\n            }\r\n        }\r\n\r\n        ExpressionFormatter* instanceFormatter =\r\n            formatterFactory.createDesignInstanceFormatter(compInstance->componentModel(), design_);\r\n\r\n        for (QSharedPointer<ConfigurableElementValue> configurableElement: \r\n            *instance->getConfigurableElementValues())\r\n        {\r\n            QString elementName =\r\n                instanceFormatter->formatReferringExpression(configurableElement->getReferenceId());\r\n            QString elementValue =\r\n                instanceFormatter->formatReferringExpression(configurableElement->getConfigurableValue());\r\n\r\n            compInstance->addGenericMap(elementName, elementValue);\r\n\t\t}\r\n\r\n\t\t// register the instance to the component declaration\r\n\t\tcompDeclaration->addInstantiation(compInstance);\r\n\r\n\t\tinstances_.insert(instance->getInstanceName(), compInstance);\r\n\t}\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: vhdlgenerator2::parseInterconnections()\r\n//-----------------------------------------------------------------------------\r\nvoid VhdlGenerator2::parseInterconnections()\r\n{\r\n\tQ_ASSERT(design_);\r\n\r\n\tQStringList connectionNames;\r\n\tforeach (QSharedPointer<Interconnection> interconnection, *design_->getInterconnections())\r\n    {\r\n\t\tbool invalidInterconnection = false;\r\n\t\tQSharedPointer<VhdlComponentInstance> instance1;\r\n\t\tQSharedPointer<BusInterface> interface1;\r\n\t\t\r\n\t\t// if there are several interconnections with same name\r\n\t\tif (connectionNames.contains(interconnection->name()))\r\n        {\r\n\t\t\temit errorMessage(tr(\"Design %1 contained more than one interconnection named %2\").arg(\r\n\t\t\t\tcomponent_->getVlnv().toString()).arg(interconnection->name()));\r\n\t\t}\r\n\t\telse\r\n        {\r\n\t\t\tconnectionNames.append(interconnection->name());\r\n\t\t}\r\n\r\n        QSharedPointer<ActiveInterface> firstInterface = interconnection->getStartInterface();\r\n\r\n\t\t// if the instance reference is incorrect\r\n\t\tif (!instances_.contains(firstInterface->getComponentReference()))\r\n        {\r\n\t\t\tinvalidInterconnection = true;\r\n\t\t\temit errorMessage(tr(\"Instance %1 was not found in component %2.\").\r\n                arg(firstInterface->getComponentReference(), component_->getVlnv().toString()));\r\n\t\t}\r\n\t\telse\r\n        { \r\n\t\t\tinstance1 = instances_.value(firstInterface->getComponentReference());\r\n\t\t\tinterface1 = instance1->interface(firstInterface->getBusReference());\r\n\t\t}\r\n\r\n\t\t// if the interface is not found\r\n\t\tif (!interface1)\r\n        {\r\n\t\t\temit errorMessage(tr(\"Bus interface %1 was not found in component %2.\").\r\n                arg(firstInterface->getBusReference(), instance1->vlnv().toString()));\r\n\t\t\tinvalidInterconnection = true;\r\n\t\t}\r\n\r\n        if (!interconnection->getActiveInterfaces()->isEmpty())\r\n        {\r\n            QSharedPointer<ActiveInterface> endInterface = interconnection->getActiveInterfaces()->first();\r\n            parseInstanceInterconnection(\r\n                interconnection, invalidInterconnection, instance1, interface1, endInterface);\r\n        }\r\n        else if (!interconnection->getHierInterfaces()->isEmpty())\r\n        {\r\n            QSharedPointer<HierInterface> endInterface = interconnection->getHierInterfaces()->first();\r\n            parseHierarchicalConnection(instance1, interface1, endInterface);\r\n        }\r\n\t}\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: vhdlgenerator2::parseInstanceInterconnection()\r\n//-----------------------------------------------------------------------------\r\nvoid VhdlGenerator2::parseInstanceInterconnection(QSharedPointer<Interconnection> connection,\r\n    bool& invalidInterconnection, QSharedPointer<VhdlComponentInstance> startInstance,\r\n    QSharedPointer<BusInterface> startInterface, QSharedPointer<ActiveInterface> connectionEndInterface)\r\n{\r\n    QSharedPointer<VhdlComponentInstance> endInstance;\r\n    QSharedPointer<BusInterface> endInterface;\r\n\r\n    if (!instances_.contains(connectionEndInterface->getComponentReference()))\r\n    {\r\n        invalidInterconnection = true;\r\n        emit errorMessage(tr(\"Instance %1 was not found in component %2.\").\r\n            arg(connectionEndInterface->getComponentReference(), component_->getVlnv().toString()));\r\n    }\r\n    else\r\n    {\r\n        endInstance = instances_.value(connectionEndInterface->getComponentReference());\r\n        endInterface = endInstance->interface(connectionEndInterface->getBusReference());\r\n    }\r\n    // if the interface is not found\r\n    if (!endInterface)\r\n    {\r\n        emit errorMessage(tr(\"Bus interface %1 was not found in component %2.\").\r\n            arg(connectionEndInterface->getBusReference(), endInstance->vlnv().toString()));\r\n        invalidInterconnection = true;\r\n    }\r\n\r\n    // if the interconnection is invalid then move on to next interconnection\r\n    if (invalidInterconnection == false)\r\n    {\r\n        connectInterfaces(connection->name(), connection->description(), startInstance, startInterface,\r\n            endInstance, endInterface);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: vhdlgenerator2::parseHierarchicalConnection()\r\n//-----------------------------------------------------------------------------\r\nvoid VhdlGenerator2::parseHierarchicalConnection(QSharedPointer<VhdlComponentInstance> startInstance,\r\n    QSharedPointer<BusInterface> startInterface, QSharedPointer<HierInterface> endInterface)\r\n{\r\n    // search all hierConnections within design\r\n    // find the top-level bus interface\r\n    QSharedPointer<BusInterface> topInterface = component_->getBusInterface(endInterface->getBusReference());\r\n\r\n\t\t// if the top level interface couldn't be found\r\n\t\tif (!topInterface)\r\n        {\r\n\t\t\temit errorMessage(tr(\"Interface %1 was not found in top component %2.\").\r\n                arg(endInterface->getBusReference(), component_->getVlnv().toString()));\r\n\t\t\treturn;\r\n\t\t}\r\n\r\n\t\t// if bus interface couldn't be found\r\n\t\tif (!startInterface)\r\n        {\r\n\t\t\temit errorMessage(tr(\"Interface %1 was not found in instance %2 of type %3\").\r\n                arg(startInterface->name()).arg(startInstance->name()).arg(startInstance->typeName()));\r\n\t\t\treturn;\r\n\t\t}\r\n\r\n        connectHierInterface(startInstance, startInterface, topInterface);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: vhdlgenerator2::connectInterfaces()\r\n//-----------------------------------------------------------------------------\r\nvoid VhdlGenerator2::connectInterfaces( const QString& connectionName, const QString& description,\r\n                                        QSharedPointer<VhdlComponentInstance> instance1,\r\n                                        QSharedPointer<BusInterface> interface1, \r\n                                        QSharedPointer<VhdlComponentInstance> instance2, \r\n                                        QSharedPointer<BusInterface> interface2 )\r\n{\r\n\tQ_ASSERT(instance1);\r\n\tQ_ASSERT(interface1);\r\n\tQ_ASSERT(instance2);\r\n\tQ_ASSERT(interface2);\r\n\r\n\t// get the IP-XACT models of both instances\r\n\tQSharedPointer<Component> component1 = instance1->componentModel();\r\n\tQSharedPointer<Component> component2 = instance2->componentModel();\r\n\r\n    QSharedPointer<ComponentParameterFinder> firstFinder(new ComponentParameterFinder(component1));\r\n    QSharedPointer<ComponentParameterFinder> secondFinder(new ComponentParameterFinder(component2));\r\n\r\n    QSharedPointer<IPXactSystemVerilogParser> firstParser(new IPXactSystemVerilogParser(firstFinder));\r\n    QSharedPointer<IPXactSystemVerilogParser> secondParser(new IPXactSystemVerilogParser(secondFinder));\r\n\r\n\t// Go through the port maps of both interfaces.\r\n    foreach (QSharedPointer<PortMap> portMap1, *interface1->getAllPortMaps())\r\n    {\r\n        foreach(QSharedPointer<PortMap> portMap2, *interface2->getAllPortMaps())\r\n        {\r\n\t\t\tQSharedPointer<PortMap::PhysicalPort> physPort1 = portMap1->getPhysicalPort();\r\n\t\t\tQSharedPointer<PortMap::PhysicalPort> physPort2 = portMap2->getPhysicalPort();\r\n\r\n\t\t\tQSharedPointer<Port> port1 = component1->getPort(physPort1->name_);\r\n\t\t\tQSharedPointer<Port> port2 = component2->getPort(physPort2->name_);\r\n\r\n\t\t\t// if the port maps are not for same logical signal\r\n\t\t\tif (portMap1->getLogicalPort()->name_ != portMap2->getLogicalPort()->name_)\r\n            {\r\n\t\t\t\tcontinue;\r\n\t\t\t}\r\n\t\t\t// if port does not exist in instance 1\r\n\t\t\telse if (!port1)\r\n            {\r\n\t\t\t\temit errorMessage(tr(\"Port %1 was not defined in component %2.\").\r\n                    arg(physPort1->name_).arg(component1->getVlnv().toString()));\r\n\t\t\t\tcontinue;\r\n\t\t\t}\r\n\t\t\t// if port does not exist in instance 2\r\n\t\t\telse if (!port2)\r\n            {\r\n\t\t\t\temit errorMessage(tr(\"Port %1 was not defined in component %2.\").\r\n                    arg(physPort2->name_).arg(component2->getVlnv().toString()));\r\n\t\t\t\tcontinue;\r\n\t\t\t}\r\n\r\n            General::PortAlignment alignment = calculatePortAlignment(\r\n                portMap1.data(), port1->getLeftBound(), port1->getRightBound(), firstParser,\r\n                portMap2.data(), port2->getLeftBound(), port2->getRightBound(), secondParser);\r\n\r\n\t\t\t// if the alignment is not valid (port sizes do not match or they do not have any common bits)\r\n\t\t\tif (alignment.invalidAlignment_)\r\n            {\r\n\t\t\t\tcontinue;\r\n\t\t\t}\r\n\r\n\t\t\t// create the name for the new signal\r\n\t\t\tconst QString signalName = connectionName + \"_\" + portMap1->getLogicalPort()->name_;\r\n\t\t\t\r\n            VhdlGenerator2::PortConnection physPort1Con(instance1, port1->name(), \r\n                alignment.port1Left_.toInt(), alignment.port1Right_.toInt());\r\n            VhdlGenerator2::PortConnection physPort2Con(instance2, port2->name(),\r\n                alignment.port2Left_.toInt(), alignment.port2Right_.toInt());\r\n\r\n            QList<VhdlGenerator2::PortConnection> ports;\r\n\t\t\tports.append(physPort1Con);\r\n\t\t\tports.append(physPort2Con);\r\n\r\n\t\t\t// connect the port from both port maps\r\n\t\t\tconnectPorts(signalName, description, ports);\r\n\t\t}\r\n\t}\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: vhdlgenerator2::connectPorts()\r\n//-----------------------------------------------------------------------------\r\nvoid VhdlGenerator2::connectPorts(const QString& connectionName, const QString& description,\r\n    const QList<VhdlGenerator2::PortConnection>& ports)\r\n{\r\n\t// at least 2 ports must be found\r\n    if (ports.size() < 2)\r\n    {\r\n        return;\r\n    }\r\n\r\n\t// the type of the signal\r\n\tQString type = ports.first().instance_->portType(ports.first().portName_);\r\n\r\n\t// the minSize for the signal\r\n\tint minSize = ports.first().leftBound_ - ports.first().rightBound_ + 1;\r\n\tint maxSize = minSize;\r\n\r\n\t// first find out the smallest possible minSize for the signal\r\n\tforeach (VhdlGenerator2::PortConnection connection, ports)\r\n    {\r\n\t\t// the smallest minSize needed is used\r\n\t\tminSize = qMin(minSize, (connection.leftBound_ - connection.rightBound_ + 1));\r\n\t}\r\n\r\n\t// calculate the bounds for the signal\r\n\tint left = minSize - 1;\t\r\n\tint right = 0;\r\n\r\n\t// create the endpoints\r\n\tQList<VhdlConnectionEndPoint> endpoints;\r\n\tforeach (VhdlGenerator2::PortConnection connection, ports)\r\n    {\r\n\t\tQString connectionType = connection.instance_->portType(connection.portName_);\r\n\r\n\t\t// make sure all ports are for compatible type\r\n\t\tif (!VhdlGeneral::checkVhdlTypeMatch(type, connectionType))\r\n        {\r\n\t\t\tQString instance1(QString(\"instance %1 port %2 type %3\").\r\n                arg(ports.first().instance_->name()).arg(ports.first().portName_).arg(type));\r\n\t\t\tQString instance2(QString(\"instance %1 port %2 type %3\").\r\n                arg(connection.instance_->name()).arg(connection.portName_).arg(connectionType));\r\n\t\t\temit errorMessage(tr(\"Type mismatch: %1 - %2.\").arg(instance1).arg(instance2));\r\n\t\t}\r\n\r\n        VhdlConnectionEndPoint endpoint(connection.instance_->name(), connection.portName_,\r\n            QString::number(connection.leftBound_), QString::number(connection.rightBound_),\r\n            QString::number(maxSize-1), QString::number(right));\r\n        endpoints.append(endpoint);\r\n\t}\r\n\r\n\t// if vectored but minSize is only one then convert to scalar signal type\r\n\tif (type == \"std_logic_vector\" && minSize == 1)\r\n    {\r\n\t\ttype = \"std_logic\";\r\n\t}\r\n\r\n\t// if scalar signal type but minSize is larger than 1 then convert to vectored\r\n\telse if (type == \"std_logic\" && minSize > 1)\r\n    {\r\n\t\ttype = \"std_logic_vector\";\r\n\t}\r\n\r\n\t// the signal that connects the end points\r\n\tQSharedPointer<VhdlSignal> signal;\r\n\r\n\t// find a signal to use for connecting the end points\r\n\tforeach (VhdlConnectionEndPoint endpoint, endpoints)\r\n    {\r\n\t\tif (signals_.contains(endpoint))\r\n        {\r\n\t\t\tsignal = signals_.value(endpoint);\r\n            signal->setBounds(qMax(left, signal->left()), qMin(right, signal->right()));\r\n\t\t\tbreak;\r\n\t\t}\r\n\t}\r\n\t// if signal was not found then create a new one \r\n\tif (!signal)\r\n    {\r\n\t\tsignal = QSharedPointer<VhdlSignal>(new VhdlSignal(connectionName, type, left, right, description));\r\n\t\tsignal->setBounds(left, right);\r\n\t}\r\n\r\n\t// connect each end point to given signal\r\n\tforeach (VhdlConnectionEndPoint endpoint, endpoints)\r\n    {\r\n\t\tconnectEndPoint(endpoint, signal);\r\n\t}\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: vhdlgenerator2::connectEndPoint()\r\n//-----------------------------------------------------------------------------\r\nvoid VhdlGenerator2::connectEndPoint( const VhdlConnectionEndPoint& endpoint,\r\n\t\t\t\t\t\t\t\t\t  const QSharedPointer<VhdlSignal> signal )\r\n{\r\n\tQ_ASSERT(signal);\r\n\r\n\t// if the end point already has a signal associated with it\r\n\tif (signals_.contains(endpoint))\r\n    {\r\n\t\tQSharedPointer<VhdlSignal> oldSignal = signals_.value(endpoint);\r\n\t\t// get all end points associated with signal for endpoint 2\r\n\t\tQList<VhdlConnectionEndPoint> endpoints = signals_.keys(oldSignal);\r\n\t\t// replace each end point with association to signal for endpoint\r\n\t\tforeach (VhdlConnectionEndPoint temp, endpoints)\r\n        {\r\n\t\t\tsignals_.insert(temp, signal);\r\n\t\t}\r\n\t}\r\n\t// if end point was not yet specified\r\n\telse\r\n    {\r\n\t\tsignals_.insert(endpoint, signal);\r\n\t}\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: vhdlgenerator2::parseAdHocConnections()\r\n//-----------------------------------------------------------------------------\r\nvoid VhdlGenerator2::parseAdHocConnections()\r\n{\r\n\tfor (QSharedPointer<AdHocConnection> adHoc : *design_->getAdHocConnections())\r\n    {\r\n\t\t// The data structure to store the ports to connect\r\n\t\tQList<VhdlGenerator2::PortConnection> ports;\r\n\r\n\t\tfor (QSharedPointer<PortReference> portRef : *adHoc->getInternalPortReferences())\r\n        {\r\n\t\t\t// if the instance is not found\r\n\t\t\tif (!instances_.contains(portRef->getComponentRef()))\r\n            {\r\n\t\t\t\temit errorMessage(tr(\"Instance %1 was not found in design.\").arg(portRef->getComponentRef()));\r\n\t\t\t\tcontinue;\r\n\t\t\t}\r\n\r\n\t\t\tQSharedPointer<VhdlComponentInstance> instance = instances_.value(portRef->getComponentRef());\r\n            Q_ASSERT(instance);\r\n\r\n            QSharedPointer<ParameterFinder> instanceFinder(\r\n                new ComponentParameterFinder(instance->componentModel()));\r\n            QSharedPointer<ExpressionParser> instanceParser (new IPXactSystemVerilogParser(instanceFinder));\r\n\r\n\t\t\t// if the specified port is not found\r\n\t\t\tif (!instance->hasPort(portRef->getPortRef()))\r\n            {\r\n\t\t\t\temit errorMessage(tr(\"Port %1 was not found in instance %2 of type %3\").arg(\r\n                    portRef->getPortRef(),\r\n\t\t\t\t\tportRef->getComponentRef(),\r\n\t\t\t\t\tinstance->vlnv().toString()));\r\n\t\t\t\tcontinue;\r\n\t\t\t}\r\n\r\n            int left = 0;\r\n            int right = 0;\r\n\r\n            QSharedPointer<PartSelect> part = portRef->getPartSelect();\r\n            if (part)\r\n            {\r\n                left = instanceParser->parseExpression(part->getLeftRange()).toInt();\r\n                right = instanceParser->parseExpression(part->getRightRange()).toInt();\r\n            }\r\n            else\r\n            {\r\n                left = instanceParser->parseExpression(\r\n                    instance->getPortPhysLeftBound(portRef->getPortRef())).toInt();\r\n                right = instanceParser->parseExpression(\r\n                    instance->getPortPhysRightBound(portRef->getPortRef())).toInt();\r\n            }\r\n\r\n\t\t\t// create the port specification\r\n\t\t\tVhdlGenerator2::PortConnection port(instance, portRef->getPortRef(), left, right);\r\n\r\n\t\t\t// add port to the list\r\n\t\t\tports.append(port);\r\n\t\t}\r\n\r\n        // Connect each external port to instance port.\r\n        for (QSharedPointer<PortReference> portRef : *adHoc->getExternalPortReferences())\r\n        {\r\n            QSharedPointer<Port> port = component_->getPort(portRef->getPortRef());\r\n\r\n            if (!port)\r\n            {\r\n                continue;\r\n            }\r\n\r\n            QString busInterfaceName = getContainingBusInterfaceName(component_, port->name());\r\n\r\n            // check that the port is found \r\n            VhdlPortSorter sorter(busInterfaceName, portRef->getPortRef(), port->getDirection());\r\n            QString left = QString();\r\n            QString right = QString();\r\n\r\n            QSharedPointer<PartSelect> part = portRef->getPartSelect();\r\n            if (part)\r\n            {\r\n                left = part->getLeftRange();\r\n                right = part->getRightRange();\r\n            }\r\n            else\r\n            {\r\n                QSharedPointer<VhdlPort> vport = topPorts_.value(sorter);\r\n                Q_ASSERT(vport);\r\n\r\n                left = vport->left();\r\n                right = vport->right();\r\n            }\r\n\r\n            // connect each instance port to the top port\r\n            connectHierPort(portRef->getPortRef(), left, right, ports);\r\n        }\r\n\t\t\r\n\t\t// otherwise the connection is just between the ports of the instances\r\n        if (adHoc->getExternalPortReferences()->isEmpty())       \r\n        {\r\n\t\t\tconnectPorts(adHoc->name(), adHoc->description(), ports);\r\n\t\t}\r\n\t}\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: vhdlgenerator2::connectHierPort()\r\n//-----------------------------------------------------------------------------\r\nvoid VhdlGenerator2::connectHierPort( const QString& topPortName, QString leftBound, QString rightBound,\r\n    const QList<VhdlGenerator2::PortConnection>& ports )\r\n{\r\n\tforeach (VhdlGenerator2::PortConnection port, ports)\r\n\t{\t\r\n\t\t// if port is scalar then don't add the bit boundaries\r\n        int portLeft = port.leftBound_;\r\n        int portRight = port.rightBound_;\r\n\t\tif (port.instance_->isScalarPort(port.portName_))\r\n        {\r\n\t\t\tportLeft = -1;\r\n\t\t\tportRight = -1;\r\n\t\t}\r\n\r\n\t\tQSharedPointer<Port> topPort = component_->getPort(topPortName);\r\n\r\n        QString busInterfaceName = getContainingBusInterfaceName(component_, topPortName);\r\n\r\n        VhdlPortSorter sorter(busInterfaceName, topPortName, topPort->getDirection());\r\n\r\n\t\t// if the port was found in top component then set it as uncommented because it is needed\r\n\t\tif (topPorts_.contains(sorter))\r\n        {\r\n\t\t\tQSharedPointer<VhdlPort> vhdlPort = topPorts_.value(sorter);\r\n\t\t\tvhdlPort->setCommented(false);\r\n\r\n\t\t\t// if the top port is scalar then don't use the bit boundaries\r\n\t\t\tif (VhdlGeneral::isScalarType(vhdlPort->type()))\r\n            {\r\n                leftBound = \"-1\";\r\n                rightBound = \"-1\";\r\n\t\t\t}\r\n\t\t}\r\n\t\telse\r\n        {\r\n\t\t\temit errorMessage(tr(\"Port %1 was not found in top component %2.\").\r\n                arg(topPortName).arg(component_->getVlnv().toString()));\r\n\t\t\tcontinue;\r\n\t\t}\r\n\r\n        VhdlPortMap portMap(port.portName_, QString::number(portLeft), QString::number(portRight),\r\n            port.instance_->portType(port.portName_));\r\n\r\n        VhdlPortMap topPortMap(topPortName, leftBound, rightBound, topPorts_.value(sorter)->type());\r\n\r\n\t\t// Tell each instance to create a port map between the ports.\r\n\t\tport.instance_->addPortMap(portMap, topPortMap);\r\n\t}\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: vhdlgenerator2::connectHierInterface()\r\n//-----------------------------------------------------------------------------\r\nvoid VhdlGenerator2::connectHierInterface( QSharedPointer<VhdlComponentInstance> instance,\r\n    QSharedPointer<BusInterface> instanceInterface, QSharedPointer<BusInterface> topInterface )\r\n{\r\n\tQ_ASSERT(instance);\r\n\tQ_ASSERT(instanceInterface);\r\n\tQ_ASSERT(topInterface);\r\n\r\n\t// get the IP-XACT model of the instance\r\n\tQSharedPointer<Component> instanceComponent = instance->componentModel();\r\n\r\n    QSharedPointer<ComponentParameterFinder> instanceFinder (new ComponentParameterFinder(instanceComponent));\r\n    QSharedPointer<ExpressionParser> instanceParser (new IPXactSystemVerilogParser(instanceFinder));\r\n\r\n    foreach (QSharedPointer<PortMap> instancePortMap, *instanceInterface->getAllPortMaps())\r\n    {\r\n\t\tforeach(QSharedPointer<PortMap> hierPortMap, *topInterface->getAllPortMaps())\r\n        {\r\n\t\t\tconst QString instancePortName = instancePortMap->getPhysicalPort()->name_;\r\n\t\t\tconst QString hierPortName = hierPortMap->getPhysicalPort()->name_;\r\n            QSharedPointer<Port> instancePort = instanceComponent->getPort(instancePortName);\r\n\t\t\tQSharedPointer<Port> hierPort = component_->getPort(hierPortName);\r\n\r\n\t\t\t// if the port maps are not for same logical signal\r\n            if (instancePortMap->getLogicalPort()->name_ != hierPortMap->getLogicalPort()->name_)\r\n            {\r\n\t\t\t\tcontinue;\r\n\t\t\t}\r\n\t\t\t// if port does not exist in instance 1\r\n\t\t\telse if (!instanceComponent->hasPort(instancePortName))\r\n            {\r\n\t\t\t\temit errorMessage(tr(\"Port %1 was not defined in component %2.\").\r\n                    arg(instancePortName).arg(instanceComponent->getVlnv().toString()));\r\n\t\t\t\tcontinue;\r\n\t\t\t}\r\n\t\t\t// if port does not exist in instance 2\r\n\t\t\telse if (!component_->hasPort(hierPortName))\r\n            {\r\n\t\t\t\temit errorMessage(tr(\"Port %1 was not defined in component %2.\").\r\n                    arg(hierPortName).arg(component_->getVlnv().toString()));\r\n\t\t\t\tcontinue;\r\n\t\t\t}\r\n\r\n\t\t\t// get the alignments of the ports\r\n            General::PortAlignment alignment = calculatePortAlignment(\r\n                instancePortMap.data(), instancePort->getLeftBound(), instancePort->getRightBound(), instanceParser,\r\n                hierPortMap.data(), hierPort->getLeftBound(), hierPort->getRightBound(), topComponentParser_);\r\n\r\n\t\t\t// if the alignment is not valid (port sizes do not match or they do not have any common bits)\r\n\t\t\tif (alignment.invalidAlignment_)\r\n            {\r\n\t\t\t\tcontinue;\r\n\t\t\t}\r\n\r\n\t\t\tVhdlGenerator2::PortConnection port1(\r\n                instance, instancePortName, alignment.port1Left_.toInt(), alignment.port1Right_.toInt());\r\n\t\t\tQList<VhdlGenerator2::PortConnection> ports;\r\n\t\t\tports.append(port1);\r\n\r\n\t\t\t// connect the port from instance to the top port\r\n\t\t\tconnectHierPort(hierPortName, alignment.port2Left_, alignment.port2Right_, ports);\r\n\t\t}\r\n\t}\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: vhdlgenerator2::mapPorts2Signals()\r\n//-----------------------------------------------------------------------------\r\nvoid VhdlGenerator2::mapPorts2Signals()\r\n{\r\n\t// search each endpoint\r\n\tfor (QMap<VhdlConnectionEndPoint, QSharedPointer<VhdlSignal> >::iterator i = signals_.begin(); \r\n\t\ti != signals_.end(); ++i)\r\n    {\r\n\t\t// if the component instance can't be found\r\n\t\tif (!instances_.contains(i.key().instanceName()))\r\n        {\r\n\t\t\temit errorMessage(tr(\"Instance %1 was not found in design.\").arg(i.key().instanceName()));\r\n\t\t\tcontinue;\r\n\t\t}\r\n\r\n\t\t// find the instance for the end point\r\n\t\tQSharedPointer<VhdlComponentInstance> instance = instances_.value(i.key().instanceName());\r\n\r\n\t\t// if port is scalar then don't add the bit boundaries\r\n\t\tQString portLeft = i.key().portLeft();\r\n\t\tQString portRight = i.key().portRight();\r\n\t\tif (instance->isScalarPort(i.key().portName()))\r\n        {\r\n\t\t\tportLeft = \"-1\";\r\n\t\t\tportRight = \"-1\";\r\n\t\t}\r\n\r\n\t\t// if signal is scalar then don't add the bit boundaries\r\n\t\tQString signalLeft = i.key().signalLeft();\r\n\t\tQString signalRight = i.key().signalRight();\r\n\t\tif (VhdlGeneral::isScalarType(i.value()->type()))\r\n        {\r\n\t\t\tsignalLeft = \"-1\";\r\n\t\t\tsignalRight = \"-1\";\r\n\t\t}\r\n\r\n        VhdlPortMap portMap(i.key().portName(), portLeft, portRight, instance->portType(i.key().portName()));\r\n        VhdlPortMap signalMap(i.value()->name(), signalLeft, signalRight, i.value()->type());\r\n\r\n\t\t// add a port map for the instance to connect port to signal\r\n\t\tinstance->addPortMap(portMap, signalMap);\t\r\n\t}\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: vhdlgenerator2::writeVhdlHeader()\r\n//-----------------------------------------------------------------------------\r\nvoid VhdlGenerator2::writeVhdlHeader( QTextStream& vhdlStream, const QString& fileName )\r\n{\r\n\tvhdlStream << \"-- ***************************************************\" << Qt::endl;\r\n\tvhdlStream << \"-- File         : \" << fileName << Qt::endl;\r\n\tvhdlStream << \"-- Creation date: \" << QDate::currentDate().toString(QString(\"dd.MM.yyyy\")) << Qt::endl;\r\n\tvhdlStream << \"-- Creation time: \" << QTime::currentTime().toString(QString(\"hh:mm:ss\")) << Qt::endl;\r\n\tvhdlStream << \"-- Description  : \" << Qt::endl;\r\n\tVhdlGeneral::writeDescription(component_->getDescription(), vhdlStream, QString(\"\"));\r\n\tvhdlStream << \"-- \" << Qt::endl;\r\n\r\n\tQSettings settings;\r\n\tQString userName = settings.value(\"General/Username\", Utils::getCurrentUser()).toString();\r\n\tvhdlStream << \"-- Created by   : \" << userName << Qt::endl; \r\n\tvhdlStream << \"-- This file was generated with Kactus2 vhdl generator\" << Qt::endl;\r\n\tVLNV vlnv = component_->getVlnv();\r\n\tvhdlStream << \"-- based on IP-XACT component \" << vlnv.toString() << Qt::endl;\r\n\tvhdlStream << \"-- whose XML file is \" << handler_->getPath(vlnv) << Qt::endl;\r\n\tvhdlStream << \"-- ***************************************************\" << Qt::endl;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: vhdlgenerator2::writeGenerics()\r\n//-----------------------------------------------------------------------------\r\nvoid VhdlGenerator2::writeGenerics( QTextStream& vhdlStream )\r\n{\r\n\t// if generics exist\r\n\tif (!topGenerics_.isEmpty())\r\n    {\r\n\t\t// the start tag\r\n\t\tvhdlStream << \"  \" << \"generic (\" << Qt::endl;\r\n\r\n\t\tfor (auto i = topGenerics_.cbegin(); i != topGenerics_.cend(); ++i)\r\n        {\r\n\t\t\tvhdlStream << \"  \" << \"  \";\r\n\t\t\ti.value()->write(vhdlStream);\r\n\r\n\t\t\t// if this is not the last generic to write\r\n\t\t\tif (std::distance(i, topGenerics_.cend()) != 1)\r\n            {\r\n\t\t\t\tvhdlStream << \";\";\r\n\t\t\t}\r\n\r\n\t\t\tif (!i.value()->description().isEmpty())\r\n            {\r\n\t\t\t\tvhdlStream << \" \";\r\n\t\t\t\tVhdlGeneral::writeDescription(i.value()->description(), vhdlStream);\r\n\t\t\t}\r\n\t\t\telse\r\n            {\r\n\t\t\t\tvhdlStream << Qt::endl;\r\n\t\t\t}\r\n\t\t}\r\n\t\tvhdlStream << \"  \" << \");\" << Qt::endl;\r\n\t\tvhdlStream << Qt::endl;\r\n\t}\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: vhdlgenerator2::writePorts()\r\n//-----------------------------------------------------------------------------\r\nvoid VhdlGenerator2::writePorts( QTextStream& vhdlStream )\r\n{\r\n\t// if ports exist\r\n\tif (!topPorts_.isEmpty() && VhdlPort::hasRealPorts(topPorts_))\r\n    {\r\n\t\tvhdlStream << \"  \" << \"port (\" << Qt::endl;\r\n\r\n\t\tQString previousInterface;\r\n\t\t// print each port\r\n\t\tfor (auto i = topPorts_.cbegin(); i != topPorts_.cend(); ++i)\r\n        {\r\n            // if the port is first in the interface then introduce it\r\n            if (i.key().interface() != previousInterface)\r\n            {\r\n                const QString interfaceName = i.key().interface();\r\n\r\n                vhdlStream << Qt::endl << \"  \" << \"  \" << \"-- \";\r\n\r\n                if (interfaceName == QString(\"none\"))\r\n                {\r\n                    vhdlStream << \"These ports are not in any interface\" << Qt::endl;\r\n                }\r\n                else if (interfaceName == QString(\"several\"))\r\n                {\r\n                    vhdlStream << \"There ports are contained in many interfaces\" << Qt::endl;\r\n                }\r\n                else\r\n                {\r\n                    vhdlStream << \"Interface: \" << interfaceName << Qt::endl;\r\n                    const QString description = component_->getBusInterface(interfaceName)->description();\r\n                    if (!description.isEmpty())\r\n                    {\r\n                        VhdlGeneral::writeDescription(description, vhdlStream, QString(\"    \"));\r\n                    }\r\n                }\r\n                previousInterface = interfaceName;\r\n            }\r\n\r\n            // write the port name and direction\r\n            vhdlStream << \"  \" << \"  \";\r\n            i.value()->write(vhdlStream);\r\n\r\n            // if this is not the last port to write\r\n            if (std::distance(i, topPorts_.cend()) != 1)\r\n            {\r\n                vhdlStream << \";\";\r\n            }\r\n\r\n            if (!i.value()->description().isEmpty())\r\n            {\r\n                vhdlStream << \" \";\r\n                VhdlGeneral::writeDescription(i.value()->description(), vhdlStream);\r\n            }\r\n            else\r\n            {\r\n                vhdlStream << Qt::endl;\r\n            }\r\n\t\t}\r\n\t\tvhdlStream << \"  \" << \");\" << Qt::endl;\r\n\t\t// write extra empty line to make code readable\r\n\t\tvhdlStream << Qt::endl;\r\n\t}\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: vhdlgenerator2::writeSignalDeclarations()\r\n//-----------------------------------------------------------------------------\r\nvoid VhdlGenerator2::writeSignalDeclarations( QTextStream& vhdlStream )\r\n{\r\n\tQList<QSharedPointer<VhdlSignal> > signalList;\r\n\r\n\t// get the unique signals that exist\r\n\tfor (QSharedPointer<VhdlSignal> signal : signals_.values())\r\n    {\r\n\t\tif (!signalList.contains(signal))\r\n        {\r\n\t\t\tsignalList.append(signal);\r\n\t\t}\r\n\t}\r\n\t// when the list contains only the unique signals then write them\r\n\tfor (QSharedPointer<VhdlSignal> signal : signalList)\r\n    {\r\n\t\tsignal->write(vhdlStream);\r\n\t}\r\n\tvhdlStream << Qt::endl;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: vhdlgenerator2::writeComponentDeclarations()\r\n//-----------------------------------------------------------------------------\r\nvoid VhdlGenerator2::writeComponentDeclarations( QTextStream& vhdlStream )\r\n{\r\n\tforeach (QSharedPointer<VhdlComponentDeclaration> comp, components_)\r\n    {\r\n\t\tcomp->write(vhdlStream);\r\n\t\tvhdlStream << Qt::endl;\r\n\t}\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: vhdlgenerator2::writeComponentInstances()\r\n//-----------------------------------------------------------------------------\r\nvoid VhdlGenerator2::writeComponentInstances( QTextStream& vhdlStream )\r\n{\r\n\tforeach (QSharedPointer<VhdlComponentInstance> instance, instances_)\r\n    {\r\n\t\tinstance->write(vhdlStream);\r\n\t\tvhdlStream << Qt::endl;\r\n\t}\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: vhdlgenerator2::readUserModifiablePart()\r\n//-----------------------------------------------------------------------------\r\nvoid VhdlGenerator2::readUserModifiablePart( QFile& previousFile )\r\n{\r\n\tQ_ASSERT(previousFile.exists());\r\n\r\n\t// clear the previous stuff\r\n\tuserModifiedAssignments_.clear();\r\n\tuserModifiedDeclarations_.clear();\r\n\r\n\t// open the file\r\n\t// if file could not be opened\r\n\tif (!previousFile.open(QFile::ReadOnly)) \r\n    {\r\n\t\temit errorMessage(tr(\"File: %1 couldn't be opened for reading\").arg(previousFile.fileName()));\r\n\t\treturn;\r\n\t}\r\n\r\n\tQTextStream stream(&previousFile);\r\n\r\n\tbool readingDeclarations = false;\r\n\tbool readingAssignments = false;\r\n\r\n\t// read as long as theres stuff in the stream to read.\r\n\twhile (!stream.atEnd())\r\n    {\r\n\t\tQString line = stream.readLine();\r\n\r\n\t\tQString lineCompare = line.trimmed();\r\n\r\n\t\t// if next line starts the declarations\r\n\t\tif (lineCompare == BLACK_BOX_DECL_START)\r\n        {\r\n\t\t\treadingDeclarations = true;\r\n\t\t}\r\n\t\t// if previous line was the last one of the declarations\r\n\t\telse if (lineCompare == BLACK_BOX_DECL_END)\r\n        {\r\n\t\t\treadingDeclarations = false;\r\n\t\t}\r\n\t\t// if the next line starts the assignments\r\n\t\telse if (lineCompare == BLACK_BOX_ASSIGN_START)\r\n        {\r\n\t\t\treadingAssignments = true;\r\n\t\t}\r\n\t\t// if previous line was the last of the assignments\r\n\t\telse if (lineCompare == BLACK_BOX_ASSIGN_END)\r\n        {\r\n\t\t\treadingAssignments = false;\r\n\t\t}\r\n\t\t// if the line is part of the declarations\r\n\t\telse if (readingDeclarations)\r\n        {\r\n\t\t\t// add the line to the declarations\r\n\t\t\tuserModifiedDeclarations_ += line;\r\n\t\t\tuserModifiedDeclarations_ += QString(\"\\n\");\r\n\t\t}\r\n\t\t// if the line is part of the assignments\r\n\t\telse if (readingAssignments)\r\n        {\r\n\t\t\t// add the line to the assignments\r\n\t\t\tuserModifiedAssignments_ += line;\r\n\t\t\tuserModifiedAssignments_ += QString(\"\\n\");\r\n\t\t}\r\n\t}\r\n\r\n\tpreviousFile.close();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: vhdlgenerator2::writeUserModifiedDeclarations()\r\n//-----------------------------------------------------------------------------\r\nvoid VhdlGenerator2::writeUserModifiedDeclarations( QTextStream& stream )\r\n{\r\n\tstream << \"  \" <<\"-- You can write vhdl code after this tag and it is saved through the generator.\" << Qt::endl;\r\n\tstream << \"  \" << BLACK_BOX_DECL_START << Qt::endl;\r\n\tstream << userModifiedDeclarations_;\r\n\tstream << \"  \" << BLACK_BOX_DECL_END << Qt::endl;\r\n\tstream << \"  \" << \"-- Do not write your code after this tag.\" << Qt::endl << Qt::endl;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: vhdlgenerator2::writeUserModifiedAssignments()\r\n//-----------------------------------------------------------------------------\r\nvoid VhdlGenerator2::writeUserModifiedAssignments( QTextStream& stream )\r\n{\r\n\tstream << \"  \" << \"-- You can write vhdl code after this tag and it is saved through the generator.\" << Qt::endl;\r\n\tstream << \"  \" << BLACK_BOX_ASSIGN_START << Qt::endl;\r\n\tstream << userModifiedAssignments_;\r\n\tstream << \"  \" << BLACK_BOX_ASSIGN_END << Qt::endl;\r\n\tstream << \"  \" << \"-- Do not write your code after this tag.\" << Qt::endl << Qt::endl;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: vhdlgenerator2::calculatePortAlignment()\r\n//-----------------------------------------------------------------------------\r\nGeneral::PortAlignment VhdlGenerator2::calculatePortAlignment(const PortMap* portMap1, QString const& phys1LeftBound,\r\n    QString const& phys1RightBound, QSharedPointer<ExpressionParser> firstParser, const PortMap* portMap2,\r\n    QString const& phys2LeftBound, QString const& phys2RightBound, QSharedPointer<ExpressionParser> secondParser) const\r\n{\r\n    General::PortAlignment alignment;\r\n\r\n    if (portMap1->getLogicalPort() && portMap2->getLogicalPort() &&\r\n        portMap1->getLogicalPort()->name_ == portMap2->getLogicalPort()->name_)\r\n    {\r\n        QSharedPointer<PortAlignment> firstPhysical =\r\n            getPhysicalAlignment(portMap1, phys1LeftBound, phys1RightBound, firstParser);\r\n        QSharedPointer<PortAlignment> secondPhysical =\r\n            getPhysicalAlignment(portMap2, phys2LeftBound, phys2RightBound, secondParser);\r\n\r\n        int firstLogicalMax = getLogicalValue(portMap1, firstParser, true);\r\n        int firstLogicalMin = getLogicalValue(portMap1, firstParser, false);\r\n        int secondLogicalMax = getLogicalValue(portMap2, secondParser, true);\r\n        int secondLogicalMin = getLogicalValue(portMap2, secondParser, false);\r\n\r\n        if (portMap1->getLogicalPort()->range_ && portMap2->getLogicalPort()->range_)\r\n        {\r\n            if (firstLogicalMin <= secondLogicalMax && firstLogicalMax >= secondLogicalMin)\r\n            {\r\n                int logicalLeft = qMin(firstLogicalMax, secondLogicalMax);\r\n                int logicalRight = qMax(firstLogicalMin, secondLogicalMin);\r\n\r\n                int firstDownSize = abs(firstLogicalMax - logicalLeft);\r\n                int firstUpSize = abs(logicalRight - firstLogicalMin);\r\n\r\n                alignment.port1Left_ = QString::number(firstPhysical->getLeftAlignment() - firstDownSize);\r\n                alignment.port1Right_ = QString::number(firstPhysical->getRightAlignment() + firstUpSize);\r\n\r\n                int secondDownSize = abs(secondLogicalMax - logicalLeft);\r\n                int secondUpSize = abs(logicalRight - secondLogicalMin);\r\n\r\n                alignment.port2Left_ = QString::number(secondPhysical->getLeftAlignment() - secondDownSize);\r\n                alignment.port2Right_ = QString::number(secondPhysical->getRightAlignment() + secondUpSize);\r\n            }\r\n        }\r\n        else if (portMap1->getLogicalPort() && !portMap2->getLogicalPort())\r\n        {\r\n            alignment.port1Left_ = QString::number(firstPhysical->getLeftAlignment());\r\n            alignment.port1Right_ = QString::number(firstPhysical->getRightAlignment());\r\n\r\n            alignment.port2Left_ = QString::number(firstLogicalMax);\r\n            alignment.port2Right_ = QString::number(firstLogicalMin);\r\n        }\r\n        else if (!portMap1->getLogicalPort() && portMap2->getLogicalPort())\r\n        {\r\n            alignment.port1Left_ = QString::number(secondLogicalMax);\r\n            alignment.port1Right_ = QString::number(secondLogicalMin);\r\n\r\n            alignment.port2Left_ = QString::number(secondPhysical->getLeftAlignment());\r\n            alignment.port2Right_ = QString::number(secondPhysical->getRightAlignment());\r\n        }\r\n        else\r\n        {\r\n            alignment.port1Left_ = QString::number(firstPhysical->getLeftAlignment());\r\n            alignment.port1Right_ = QString::number(firstPhysical->getRightAlignment());\r\n            alignment.port2Left_ = QString::number(secondPhysical->getLeftAlignment());\r\n            alignment.port2Right_ = QString::number(secondPhysical->getRightAlignment());\r\n        }\r\n\r\n        int firstPortSize = alignment.port1Left_.toInt() - alignment.port1Right_.toInt() + 1;\r\n        int secondPortSize = alignment.port2Left_.toInt() - alignment.port2Right_.toInt() + 1;\r\n\r\n        if (firstPortSize != secondPortSize)\r\n        {\r\n            alignment.invalidAlignment_ = true;\r\n        }\r\n        else\r\n        {\r\n            alignment.invalidAlignment_ = false;\r\n        }\r\n    }\r\n\r\n    return alignment;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: vhdlgenerator2::getPhysicalAlignment()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<PortAlignment> VhdlGenerator2::getPhysicalAlignment(const PortMap* portmap,\r\n    QString const& portLeftBound, QString const& portRightBound, QSharedPointer<ExpressionParser> parser) const\r\n{\r\n    int leftBoundInt = parser->parseExpression(portLeftBound).toInt();\r\n    int rightBoundInt = parser->parseExpression(portRightBound).toInt();\r\n\r\n    if (portmap->getPhysicalPort() && portmap->getPhysicalPort()->partSelect_)\r\n    {\r\n        leftBoundInt = parser->parseExpression(portmap->getPhysicalPort()->partSelect_->getLeftRange()).toInt();\r\n        rightBoundInt = parser->parseExpression(portmap->getPhysicalPort()->partSelect_->getRightRange()).toInt();\r\n    }\r\n    \r\n    int alignmentMax = qMax(leftBoundInt, rightBoundInt);\r\n    int alignmentMin = qMin(leftBoundInt, rightBoundInt);\r\n    QSharedPointer<PortAlignment> alignment (new PortAlignment(alignmentMax, alignmentMin));\r\n    return alignment;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: vhdlgenerator2::getLogicalValue()\r\n//-----------------------------------------------------------------------------\r\nint VhdlGenerator2::getLogicalValue(const PortMap* portMap, QSharedPointer<ExpressionParser> parser,\r\n    bool isMaximum) const\r\n{\r\n    QSharedPointer<PortMap::LogicalPort> logicalPort = portMap->getLogicalPort();\r\n\r\n    int logicalValue = 0;\r\n\r\n    if (logicalPort->range_)\r\n    {\r\n        int logicalLeft = parser->parseExpression(logicalPort->range_->getLeft()).toInt();\r\n        int logicalRight = parser->parseExpression(logicalPort->range_->getRight()).toInt();\r\n\r\n        if (isMaximum)\r\n        {\r\n            logicalValue = qMax(logicalLeft, logicalRight);\r\n        }\r\n        else\r\n        {\r\n            logicalValue = qMin(logicalLeft, logicalRight);\r\n        }\r\n    }\r\n\r\n    return logicalValue;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: vhdlgenerator2::getContainingBusInterfaceName()\r\n//-----------------------------------------------------------------------------\r\nQString VhdlGenerator2::getContainingBusInterfaceName(QSharedPointer<Component> containingComponent,\r\n    QString const& portName) const\r\n{\r\n    QString busInterfaceName = \"none\";\r\n\r\n    QSharedPointer<BusInterface> containingBus = containingComponent->getInterfaceForPort(portName);\r\n    if (!containingBus.isNull())\r\n    {\r\n        busInterfaceName = containingBus->name();\r\n    }\r\n\r\n    return busInterfaceName;\r\n}\r\n\r\n//----------------------------------------------------------------------------\r\n// Function: vhdlgenerator2::PortConnection::PortConnection()\r\n//-----------------------------------------------------------------------------\r\nVhdlGenerator2::PortConnection::PortConnection(QSharedPointer<VhdlComponentInstance> instance,\r\n    const QString& portName, int left, int right):\r\ninstance_(instance),\r\nportName_(portName),\r\nleftBound_(left),\r\nrightBound_(right)\r\n{\r\n\r\n}\r\n\r\n"
  },
  {
    "path": "Plugins/VHDLGenerator/vhdlgenerator2.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: vhdlgenerator.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Antti Kamppi\r\n// Date: 26.10.2011\r\n//\r\n// Description:\r\n// Vhdl Generator generates top-level vhdl for hierarchical component.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef VHDLGENERATOR2_H\r\n#define VHDLGENERATOR2_H\r\n\r\n#include <IPXACTmodels/Component/Component.h>\r\n#include <IPXACTmodels/Design/Design.h>\r\n#include <IPXACTmodels/DesignConfiguration/DesignConfiguration.h>\r\n\r\n#include <IPXACTmodels/common/VLNV.h>\r\n\r\n#include \"vhdlgeneric.h\"\r\n#include \"vhdlport.h\"\r\n#include \"vhdlportsorter.h\"\r\n#include \"vhdlconnectionendpoint.h\"\r\n#include \"vhdlsignal.h\"\r\n#include \"vhdlcomponentdeclaration.h\"\r\n#include \"vhdlcomponentinstance.h\"\r\n\r\n#include <QObject>\r\n#include <QSharedPointer>\r\n#include <QString>\r\n#include <QStringList>\r\n#include <QList>\r\n#include <QMap>\r\n\r\nclass LibraryInterface;\r\nclass VhdlConnectionEndPoint;\r\nclass HWDesignWidget;\r\nclass PortMap;\r\nclass DesignValidator;\r\nclass DesignConfigurationValidator;\r\nclass ExpressionParser;\r\nclass PortAlignment;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Vhdl Generator generates top-level vhdl for hierarchical component.\r\n//-----------------------------------------------------------------------------\r\nclass VhdlGenerator2 : public QObject\r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\r\n\t/*!\r\n     *  The constructor.\r\n\t *\r\n\t *    @param [in] handler     Pointer to the instance that manages the library.\r\n\t *    @param [in] parent      Pointer to the owner of this generator.\r\n\t */\r\n\tVhdlGenerator2(QSharedPointer<ExpressionParser> parser, LibraryInterface* handler,\r\n        QObject* parent);\r\n\t\r\n\t//! The destructor.\r\n\tvirtual ~VhdlGenerator2() = default;\r\n\r\n\t/*!\r\n     *  Get pointer to the instance that manages the library.\r\n\t *\r\n\t *    @return LibraryInterface* Pointer to the instance that manages the library.\r\n\t */\r\n\tLibraryInterface* handler() const;\r\n\r\n\t/*!\r\n     *  Parse the data needed to create the top-level vhdl entity.\r\n\t *\r\n\t *    @param [in] topLevelComponent   Pointer to the component that's entity is created.\r\n\t *    @param [in] viewName            The name of the view on the top component to generate the vhdl to.\r\n\t *\r\n\t *    @return bool True if the parsing was successful and the vhdl can be generated.\r\n\t */\r\n\tbool parse(QSharedPointer<Component> topLevelComponent, const QString& viewName);\r\n\r\n\t/*!\r\n     *  Generate the vhdl that has been parsed.\r\n\t * \r\n\t *  NOTE: Before calling this function the parse() function MUST be called so there is something to generate.\r\n\t *\r\n\t *    @param [in] outputFileName  The absolute file path of the vhdl file to be created.\r\n     *                                  If file exists it is overwritten.\r\n\t */\r\n\tvoid generate(const QString& outputFileName);\r\n\r\n\t/*!\r\n     *  Add a new view to the top component's IP-Xact metadata.\r\n\t * \r\n\t *  NOTE: Before calling this function the parse() function must be called and usually the generateVhdl() also.\r\n     *  If generateVhdl() is not called then the architecture name must be set other way.\r\n\t * \r\n\t *    @param [in] vhdlFileName    Absolute file path to the vhdl file to add to the metadata. This is \r\n     *                                  usually the same file that was set as output file when calling\r\n     *                                  generateVhdl().\r\n\t *\r\n\t *    @return bool True if the view was added successfully.\r\n\t */\r\n    bool addRTLView(QString const& fileSetName, const QString& vhdlFileName );\r\n\r\n    /*!\r\n     *  Check if the generator is able to generate and architecture for top entity.\r\n\t *\r\n\t *    @return True if component contains a design and is able to create an architecture for the entity.\r\n\t */\r\n\tbool containsArchitecture() const;\r\n\r\nsignals:\r\n\r\n\t//! Print a notification to user.\r\n\tvoid noticeMessage(const QString& noticeMessage);\r\n\r\n\t//! Print a error message to user.\r\n\tvoid errorMessage(const QString& errorMessage);\r\n\r\nprivate:\r\n\r\n\t//! No copying.\r\n\tVhdlGenerator2(const VhdlGenerator2& other);\r\n\r\n\t//! No assignment.\r\n\tVhdlGenerator2& operator=(const VhdlGenerator2& other);\r\n\r\n\t//! Contains info on what port to connect.\r\n\tstruct PortConnection\r\n    {\r\n\t\t//! Pointer to the instance the port belongs to.\r\n\t\tQSharedPointer<VhdlComponentInstance> instance_;\r\n\r\n\t\t//! The name of the port on the instance to connect.\r\n\t\tQString portName_;\r\n\r\n\t\t//! The left bound of the port to connect.\r\n        int leftBound_;\r\n\r\n\t\t//! The right bound of the port to connect.\r\n        int rightBound_;\r\n\r\n\t\t/*!\r\n         *  The constructor\r\n\t\t *\r\n\t\t *    @param [in] instance    Pointer to the instance to connect.\r\n\t\t *    @param [in] portName    The name of the port on the instance.\r\n\t\t *    @param [in] left        The left bound of the port.\r\n\t\t *    @param [in] right       The right bound of the port.\r\n\t\t */\r\n        PortConnection(QSharedPointer<VhdlComponentInstance> instance, const QString& portName,\r\n            int left = -1, int right = -1);\r\n\r\n\t\t//! Copy constructor.\r\n\t\tPortConnection(const PortConnection& other) = default;\r\n\r\n\t\t//! Assignment operator.\r\n\t\tPortConnection& operator=(const PortConnection& other) = default;\r\n\r\n        //! The destructor.\r\n        ~PortConnection() = default;\r\n\t};\r\n\r\n\t/*!\r\n     *  Parse the design and configuration used.\r\n\t * \r\n\t *    @return True if the design and configuration were parsed successfully.\r\n\t */\r\n\tbool parseDesignAndConfiguration();\r\n\r\n\t/*!\r\n     *  Parse the generics for the top entity to create.\r\n     *\r\n     *    @param [in] viewName    Name of the selected view.\r\n\t */\r\n\tvoid parseTopGenerics( QString const& viewName );\r\n\r\n\t/*!\r\n     *  Parse the ports for the top entity to create.\r\n\t */\r\n\tvoid parseTopPorts();\r\n\r\n\t/*!\r\n     *  Parse the component instances from the design.\r\n\t */\r\n\tvoid parseInstances();\r\n\r\n\t/*!\r\n     *  Parse the interconnections of a design.\r\n\t */\r\n\tvoid parseInterconnections();\r\n\r\n    void parseInstanceInterconnection(QSharedPointer<Interconnection> connection, bool& invalidInterconnection,\r\n        QSharedPointer<VhdlComponentInstance> startInstance, QSharedPointer<BusInterface> startInterface,\r\n        QSharedPointer<ActiveInterface> connectionEndInterface);\r\n\r\n    void parseHierarchicalConnection(QSharedPointer<VhdlComponentInstance> startInstance,\r\n        QSharedPointer<BusInterface> startInterface, QSharedPointer<HierInterface> endInterface);\r\n\r\n\t/*!\r\n     *  Parse the ad hoc connections of a design.\r\n\t */\r\n\tvoid parseAdHocConnections();\r\n\r\n\t/*!\r\n     *  Connect the two interfaces together with signals.\r\n\t *\r\n\t *    @param [in] connectionName  The name of the connection between the interfaces.\r\n\t *    @param [in] description     The description of the interconnection.\r\n\t *    @param [in] instance1       Pointer to the instance 1.\r\n\t *    @param [in] interface1      Pointer to the bus interface of instance 1.\r\n\t *    @param [in] instance2       Pointer to the instance 2.\r\n\t *    @param [in] interface2      Pointer to the bus interface of instance 2.\r\n\t */\r\n\tvoid connectInterfaces(const QString& connectionName, const QString& description,\r\n        QSharedPointer<VhdlComponentInstance> instance1, QSharedPointer<BusInterface> interface1,\r\n        QSharedPointer<VhdlComponentInstance> instance2, QSharedPointer<BusInterface> interface2);\r\n\r\n\t/*!\r\n     *  Connect the specified ports together.\r\n\t *\r\n\t *    @param [in] connectionName  The name of the connection.\r\n\t *    @param [in] description     Description for the connection.\r\n\t *    @param [in] ports           Contains the ports to connect.\r\n\t */\r\n\tvoid connectPorts(const QString& connectionName, const QString& description,\r\n        const QList<VhdlGenerator2::PortConnection>& ports);\r\n\r\n\t/*!\r\n     *  Connect the specified top port to specified instance ports.\r\n\t *\r\n\t *    @param [in] topPort     The name of the port on top component.\r\n\t *    @param [in] leftBound   The left bound of the port on top component.\r\n\t *    @param [in] rightBound  The right bound of the port on top component.\r\n\t *    @param [in] ports       List of ports to connect to the top port\r\n\t */\r\n\tvoid connectHierPort(const QString& topPortName, QString leftBound, QString rightBound,\r\n        const QList<VhdlGenerator2::PortConnection>& ports);\r\n\r\n\t/*!\r\n     *  Connect the given endpoint with the signal.\r\n\t *\r\n\t *    @param [in] endpoint    The end point that specified the port to connect.\r\n\t *    @param [in] signal      The signal the port is connected to.\r\n\t */\r\n\tvoid connectEndPoint(const VhdlConnectionEndPoint& endpoint, const QSharedPointer<VhdlSignal> signal);\r\n\r\n\t/*!\r\n     *  Connect the hierarchical interface to the instance interface.\r\n\t *\r\n\t *    @param [in] instance            Pointer to the instance that's interface is connected.\r\n\t *    @param [in] instanceInterface   Pointer to the interface of the instance.\r\n\t *    @param [in] topInterface        Pointer to the interface of the top component.\r\n\t */\r\n\tvoid connectHierInterface( QSharedPointer<VhdlComponentInstance> instance,\r\n        QSharedPointer<BusInterface> instanceInterface, QSharedPointer<BusInterface> topInterface );\r\n\r\n\t/*!\r\n     *  Map ports of component instances to signals.\r\n\t *\r\n\t *  NOTE: This function must be called only after all end points of signals have been parsed.\r\n\t */\r\n\tvoid mapPorts2Signals();\r\n\t\r\n\t/*!\r\n     *  Write the header of a vhdl file to be created.\r\n\t *\r\n\t *    @param [in] vhdlStream  The text stream to write into.\r\n\t *    @param [in] fileName    The name of the file that is being written.\r\n\t */\r\n\tvoid writeVhdlHeader( QTextStream& vhdlStream, const QString& fileName );\r\n\t\r\n\t/*!\r\n     *  Write the generics of the top entity.\r\n\t *\r\n\t *    @param [in] vhdlStream  The text stream to write into.\r\n\t */\r\n\tvoid writeGenerics( QTextStream& vhdlStream );\r\n\t\r\n\t/*!\r\n     *  Write the ports of the top entity.\r\n\t *\r\n\t *    @param [in] vhdlStream  The text stream to write into.\r\n\t */\r\n\tvoid writePorts( QTextStream& vhdlStream );\r\n\t\r\n\t/*!\r\n     *  Write the declarations of the signals.\r\n\t * \r\n\t *    @param [in] vhdlStream  The text stream to write into.\r\n\t */\r\n\tvoid writeSignalDeclarations( QTextStream& vhdlStream );\r\n\t\r\n\t/*!\r\n     *  Write the declarations of components.\r\n\t *\r\n\t *    @param [in] vhdlStream  The text stream to write into.\r\n\t */\r\n\tvoid writeComponentDeclarations( QTextStream& vhdlStream );\r\n\t\r\n\t/*!\r\n     *  Write the instances of components.\r\n\t *\r\n\t *    @param [in] vhdlStream  The text stream to write into.\r\n\t */\r\n\tvoid writeComponentInstances( QTextStream& vhdlStream );\r\n\r\n\t/*!\r\n     *  Read an old vhdl file and read the user modifiable parts from it.\r\n\t *\r\n\t *    @param [in] previousFile    The file to read.\r\n\t */\r\n\tvoid readUserModifiablePart(QFile& previousFile);\r\n\r\n\t/*!\r\n     *  Write the user modified declarations read from the previous file.\r\n\t *\r\n\t *    @param [in] stream  The text stream to write into.\r\n\t */\r\n\tvoid writeUserModifiedDeclarations(QTextStream& stream);\r\n\r\n\t/*!\r\n     *  Write the user modified assignments read from the previous file.\r\n\t *\r\n\t *    @param [in] stream  The text stream to write into.\r\n\t */\r\n\tvoid writeUserModifiedAssignments(QTextStream& stream);\r\n\t\r\n    /*!\r\n     *  Calculate the port alignment.\r\n     *\r\n     *    @param [in] portMap1            First port map.\r\n     *    @param [in] phys1LeftBound      Physical left bound of the first port.\r\n     *    @param [in] phys1RightBound     Physical right bound of the first port.\r\n     *    @param [in] portMap2            The second port map.\r\n     *    @param [in] phys2LeftBound      Physical left bound of the second port.\r\n     *    @param [in] phys2RightBound     Physical right bound of the second port.\r\n     */\r\n    General::PortAlignment calculatePortAlignment(const PortMap* portMap1, QString const& phys1LeftBound,\r\n        QString const& phys1RightBound, QSharedPointer<ExpressionParser> firstParser, const PortMap* portMap2,\r\n        QString const& phys2LeftBound, QString const& phys2RightBound, QSharedPointer<ExpressionParser> secondParser) const;\r\n\r\n    /*!\r\n     *  Get the alignment of the physical port mapping.\r\n     *\r\n     *    @param [in] portmap         The containing port map.\r\n     *    @param [in] portLeftBound   The left bound of the selected port.\r\n     *    @param [in] portRightBound  The right bound of the selected port.\r\n     *    @param [in] parser          Expression parser for the containing component.\r\n     *\r\n     *    @return The alignment of the physical port mapping.\r\n     */\r\n    QSharedPointer<PortAlignment> getPhysicalAlignment(const PortMap* portmap, QString const& portLeftBound,\r\n        QString const& portRightBound, QSharedPointer<ExpressionParser> parser) const;\r\n\r\n    /*!\r\n     *  Get the logical minimum or maximum port mapping value.\r\n     *\r\n     *    @param [in] portMap     Port map containing the logical port.\r\n     *    @param [in] parser      Expression parser for the containing component.\r\n     *    @param [in] isMaximum   Flag value for determining whether the maximum of minimum value is wanted.\r\n     *\r\n     *    @return A logical bound of the logical port mapping.\r\n     */\r\n    int getLogicalValue(const PortMap* portMap, QSharedPointer<ExpressionParser> parser, bool isMaximum) const;\r\n\r\n    /*!\r\n     *  Get the name of the containing bus interface.\r\n     *\r\n     *    @param [in] containingComponent     The component containing the port and the bus interface.\r\n     *    @param [in] portName                The name of the selected port.\r\n     *\r\n     *    @return The name of the containing bus interface, or \"none\" if one is not found.\r\n     */\r\n    QString getContainingBusInterfaceName(QSharedPointer<Component> containingComponent, QString const& portName)\r\n        const;\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n\t//! Pointer to the instance that manages the library.\r\n\tLibraryInterface* handler_;\r\n\r\n\t//! Pointer to the top component.\r\n\tQSharedPointer<Component> component_;\r\n\r\n\t//! Pointer to the top design.\r\n\tQSharedPointer<Design> design_;\r\n\r\n\t//! Pointer to the top configuration\r\n\tQSharedPointer<DesignConfiguration> desConf_;\r\n\r\n\t//! The name of the view used on the top component.\r\n\tQString viewName_;\r\n\r\n\t//! The name of the top level entity to create.\r\n\tQString topLevelEntity_;\r\n\r\n\t//! List of libraries to use\r\n\tQStringList libraries_;\r\n\r\n\t//! The type definitions of the port types used.\r\n\tQStringList typeDefinitions_;\r\n\r\n\t//! Contains the declarations that user has written by hand and that should be saved\r\n\tQString userModifiedDeclarations_;\r\n\r\n\t//! Contains the vhdl code that user has written by hand and that should be saved\r\n\tQString userModifiedAssignments_;\r\n\r\n\t/*! Contains the generics for the top level entity.\r\n\t *      Key = Name of the generic\r\n\t *      Value = Pointer to the generic.\r\n\t */\r\n\tQMap<QString, QSharedPointer<VhdlGeneric> > topGenerics_;\r\n\r\n\t/*! Contains the ports for the top level entity.\r\n\t *      Key = Element used to sort the ports in correct order.\r\n\t *      Value = Pointer to the port.\r\n\t */\r\n\tQMap<VhdlPortSorter, QSharedPointer<VhdlPort> > topPorts_;\r\n\r\n\t/*! Contains the signals for the architecture\r\n\t *      Key = The end point associated with the signal.\r\n\t *      Value = Pointer to the signal to use.\r\n\t */\r\n\tQMap<VhdlConnectionEndPoint, QSharedPointer<VhdlSignal> > signals_;\r\n\r\n\t/*! Contains the component declarations of the architecture\r\n\t *      Key = VLNV of the component IP-Xact model\r\n\t *      Value = Pointer to the vhdl component declaration\r\n\t */\r\n\tQMap<VLNV, QSharedPointer<VhdlComponentDeclaration> > components_;\r\n\r\n\t/*! Contains the instances of the architecture\r\n\t *      Key = Name of the instance\r\n\t *      Value = Pointer to the component instance\r\n\t */\r\n\tQMap<QString, QSharedPointer<VhdlComponentInstance> > instances_;\r\n\r\n    //! The used design validator.\r\n    QSharedPointer<DesignValidator> designvalidator_;\r\n\r\n    //! The used design configuration validator.\r\n    QSharedPointer<DesignConfigurationValidator> designConfigurationValidator_;\r\n\r\n    //! The expression parser for the top component parser.\r\n    QSharedPointer<ExpressionParser> topComponentParser_;\r\n};\r\n\r\n#endif // VHDLGENERATOR2_H\r\n"
  },
  {
    "path": "Plugins/VHDLGenerator/vhdlgeneric.cpp",
    "content": "/* \r\n *  \tCreated on: 26.10.2011\r\n *      Author: Antti Kamppi\r\n * \t\tfilename: vhdlgeneric.cpp\r\n *\t\tProject: Kactus 2\r\n */\r\n\r\n#include \"vhdlgeneric.h\"\r\n\r\n#include <IPXACTmodels/common/ModuleParameter.h>\r\n\r\n#include <KactusAPI/include/ExpressionFormatter.h>\r\n\r\n#include <QChar>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: vhdlgeneric::VhdlGeneric()\r\n//-----------------------------------------------------------------------------\r\nVhdlGeneric::VhdlGeneric(QSharedPointer<ModuleParameter> generic,  QSharedPointer<ExpressionFormatter> formatter):\r\nVhdlTypedObject(generic->name(),\r\n\t\t        generic->getDataType(),\r\n    \t        generic->getValue(),\r\n\t\t        generic->description()),\r\n                formatter_(formatter)\r\n{\r\n    if (type().isEmpty())\r\n    {\r\n        setType(QStringLiteral(\"integer\"));\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: vhdlgeneric::write()\r\n//-----------------------------------------------------------------------------\r\nvoid VhdlGeneric::write( QTextStream& stream ) const\r\n{\r\n\tQ_ASSERT(!name().isEmpty());\r\n\tQ_ASSERT(!type().isEmpty());\r\n\r\n    // align colons (:) at least roughly\r\n\tstream << getVhdlLegalName().leftJustified(16, ' ');\r\n    stream<< \" : \" << type();\r\n\r\n\t// if a default value has been specified\r\n\tif (!defaultValue().isEmpty())\r\n    {\r\n\t\tstream << \" := \";\r\n\t\r\n\t    // check if type is string then quotations must be used for default value\r\n\t    bool addQuotation = type().compare(QLatin1String(\"string\"), Qt::CaseInsensitive) == 0;\r\n\t\t\r\n\t\t// if default value does not start with quotation\r\n\t\tif (addQuotation && !defaultValue().startsWith(QChar('\"')))\r\n        {\r\n\t\t\tstream << \"\\\"\";\r\n\t\t}\r\n\t\t\r\n\t\t// write the default value\r\n\t\tstream << formatter_->formatReferringExpression(defaultValue());\r\n\r\n\t\t// if default value does not end with quotation\r\n\t\tif (addQuotation && !defaultValue().endsWith(QChar('\"')))\r\n        {\r\n\t\t\tstream << \"\\\"\";\r\n\t\t}\r\n\t}\r\n}\r\n"
  },
  {
    "path": "Plugins/VHDLGenerator/vhdlgeneric.h",
    "content": "/* \r\n *  \tCreated on: 26.10.2011\r\n *      Author: Antti Kamppi\r\n * \t\tfilename: vhdlgeneric.h\r\n *\t\tProject: Kactus 2\r\n */\r\n\r\n#ifndef VHDLGENERIC_H\r\n#define VHDLGENERIC_H\r\n\r\n#include \"VhdlTypedObject.h\"\r\n#include \"vhdlobject.h\"\r\n\r\n#include <QString>\r\n#include <QSharedPointer>\r\n\r\nclass ModuleParameter;\r\nclass ExpressionFormatter;\r\n\r\n/*! VhdlGeneric represents a vhdl generic in a component or entity declaration.\r\n *\r\n */\r\nclass VhdlGeneric : public VhdlTypedObject\r\n{\r\n\r\npublic:\r\n\r\n\t/*! The constructor\r\n\t *\r\n\t * @param [in] generic   The module parameter to create the generic from.\r\n\t * @param [in] formatter The formatter to use for expressions in the value.\r\n\t *\r\n\t*/\r\n\tVhdlGeneric(QSharedPointer<ModuleParameter> generic, QSharedPointer<ExpressionFormatter> formatter);\r\n\r\n    //! No copying\r\n    VhdlGeneric(const VhdlGeneric& other) = delete;\r\n\r\n    //! No assignment\r\n    VhdlGeneric& operator=(const VhdlGeneric& other) = delete;\r\n\r\n\t//! The destructor\r\n\tvirtual ~VhdlGeneric() = default;\r\n\r\n\t/*! Write the contents of the generic into text stream.\r\n\t *\r\n\t * @param [in] stream The text stream to write the generic into.\r\n\t *\r\n\t*/\r\n\tvirtual void write(QTextStream& stream) const override final;\r\n\r\nprivate:\r\n\r\n    // Formatter for expressions.\r\n    QSharedPointer<ExpressionFormatter> formatter_;\r\n};\r\n\r\n#endif // VHDLGENERIC_H\r\n"
  },
  {
    "path": "Plugins/VHDLGenerator/vhdlobject.cpp",
    "content": "/* \r\n *  \tCreated on: 26.10.2011\r\n *      Author: Antti Kamppi\r\n * \t\tfilename: vhdlobject.cpp\r\n *\t\tProject: Kactus 2\r\n */\r\n\r\n#include \"vhdlobject.h\"\r\n\r\n#include <QRegularExpression>\r\n#include <QRegularExpression>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: vhdlobject::VhdlObject()\r\n//-----------------------------------------------------------------------------\r\nVhdlObject::VhdlObject(const QString& name /*= QString()*/,\r\n\t\t\t\t\t   const QString& description /*= QString()*/ ):\r\nname_(name),\r\ndescription_(description)\r\n{\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: vhdlobject::name()\r\n//-----------------------------------------------------------------------------\r\nQString VhdlObject::name() const {\r\n\treturn name_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: vhdlobject::setName()\r\n//-----------------------------------------------------------------------------\r\nvoid VhdlObject::setName( const QString& name ) {\r\n\tname_ = name;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: vhdlobject::description()\r\n//-----------------------------------------------------------------------------\r\nQString VhdlObject::description() const {\r\n\treturn description_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: vhdlobject::setDescription()\r\n//-----------------------------------------------------------------------------\r\nvoid VhdlObject::setDescription( const QString& description ) {\r\n\tdescription_ = description;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: vhdlobject::getVhdlLegalName()\r\n//-----------------------------------------------------------------------------\r\nQString VhdlObject::getVhdlLegalName() const\r\n{\r\n    QString vhdlLegalName = name_;\r\n\r\n    QRegularExpression illegalCharacters(\"[:_.-]+\");\r\n    vhdlLegalName = vhdlLegalName.replace(illegalCharacters, \"_\");\r\n\r\n    QRegularExpression leadingUnderScore(\"^[_]\");\r\n    vhdlLegalName.remove(leadingUnderScore);\r\n    QRegularExpression trailingUnderScore(\"[_]$\");\r\n    vhdlLegalName.remove(trailingUnderScore);\r\n\r\n    return vhdlLegalName;\r\n}"
  },
  {
    "path": "Plugins/VHDLGenerator/vhdlobject.h",
    "content": "/* \r\n *  \tCreated on: 26.10.2011\r\n *      Author: Antti Kamppi\r\n * \t\tfilename: vhdlobject.h\r\n *\t\tProject: Kactus 2\r\n */\r\n\r\n#ifndef VHDLOBJECT_H\r\n#define VHDLOBJECT_H\r\n\r\n#include <QObject>\r\n#include <QString>\r\n#include <QTextStream>\r\n\r\n/*! VhdlObject is a pure virtual class that is used as a base class.\r\n * \r\n * VhdlObject is used as base class for the following classes:\r\n * - VhdlGeneric\r\n * - VhdlSignal\r\n * - VhdlPort\r\n * \r\n */\r\nclass VhdlObject \r\n{\r\n\r\npublic:\r\n\r\n\t/*! The constructor\r\n\t *\r\n\t * @param [in] parent Pointer to the owner of this vhdl object.\r\n\t * @param [in] name Name for this vhdl object.\r\n\t * @param [in] type Type for this vhdl object.\r\n\t * @param [in] defaultValue The default value for the object.\r\n\t * @param [in] description The description for this vhdl object.\r\n\t *\r\n\t*/\r\n\tVhdlObject(const QString& name = QString(), const QString& description = QString());\r\n\t\r\n\t//! The destructor\r\n\tvirtual ~VhdlObject() = default;\r\n\r\n    //! No copying\r\n    VhdlObject(const VhdlObject& other) = default;\r\n\r\n\t/*! Write the contents of the object to the text stream.\r\n\t *\r\n\t * This is a pure virtual function and must be implemented in all classes \r\n\t * derived from this class.\r\n\t *\r\n\t * @param [in] stream The text stream to write the object into.\r\n\t *\r\n\t*/\r\n\tvirtual void write(QTextStream& stream) const = 0;\r\n\r\n\t/*! Get the name of the vhdl object\r\n\t *\r\n\t *\r\n\t * @return QString contains the name of the object.\r\n\t*/\r\n\tvirtual QString name() const;\r\n\r\n\t/*! Set the name for the vhdl object.\r\n\t *\r\n\t * @param [in] name contains the name to set.\r\n\t *\r\n\t*/\r\n\tvirtual void setName(const QString& name);\r\n\r\n\t/*! Get the description of the vhdl object.\r\n\t *\r\n\t *\r\n\t * @return QString contains the description of the object.\r\n\t*/\r\n\tvirtual QString description() const;\r\n\r\n\t/*! Set the description for the vhdl object.\r\n\t *\r\n\t * @param [in] description contains the description for the object.\r\n\t *\r\n\t*/\r\n\tvirtual void setDescription(const QString& description);\r\n\r\n    /*!\r\n     *  Return the object name, where separators have been replaced with _.\r\n     *\r\n     *  @return     The replaced name.\r\n     */\r\n    virtual QString getVhdlLegalName() const;\r\n\r\nprivate:\r\n\r\n\t//! No assignment\r\n\tVhdlObject& operator=(const VhdlObject& other);\r\n\r\n    //! The name of the vhdl object.\r\n    QString name_;\r\n\r\n    //! The description of the vhdl object.\r\n    QString description_;\r\n};\r\n\r\n#endif // VHDLOBJECT_H\r\n"
  },
  {
    "path": "Plugins/VHDLGenerator/vhdlport.cpp",
    "content": "/* \r\n *  \tCreated on: 28.10.2011\r\n *      Author: Antti Kamppi\r\n * \t\tfilename: vhdlport.cpp\r\n *\t\tProject: Kactus 2\r\n */\r\n\r\n#include \"vhdlport.h\"\r\n\r\n#include \"vhdlgeneral.h\"\r\n\r\n#include <KactusAPI/include/ExpressionParser.h>\r\n\r\n#include <IPXACTmodels/Component/Port.h>\r\n\r\nVhdlPort::VhdlPort(QSharedPointer<Port> port, QSharedPointer<ExpressionParser> parser) :\r\n    VhdlTypedObject(port->name(), port->getTypeName(), port->getDefaultValue(), port->description()),\r\n    direction_(port->getDirection()),\r\n    left_(port->getLeftBound()),\r\n    right_(port->getRightBound()),\r\n    commentOut_(true),\r\n    parser_(parser)\r\n{\r\n    // if type is not set then use the defaults\r\n    if (port->getTypeName().isEmpty())\r\n    {\r\n        if (size() == 1)\r\n        {\r\n            setType(QString(\"std_logic\"));\r\n        }\r\n        else\r\n        {\r\n            setType(QString(\"std_logic_vector\"));\r\n        }\r\n    }\r\n}\r\n\r\nvoid VhdlPort::write( QTextStream& stream ) const\r\n{\r\n\tif (commentOut_)\r\n    {\r\n\t\tstream << \"-- \";\r\n\t}\r\n\r\n    stream << getVhdlLegalName().leftJustified(16, ' ');     //align colons (:) at least roughly\r\n\tstream << \" : \" << DirectionTypes::direction2Str(direction_) << \" \";\r\n\r\n\tstream << VhdlGeneral::vhdlType2String(type(), parser_->parseExpression(left_).toInt(), parser_->parseExpression(right_).toInt());\r\n}\r\n\r\nint VhdlPort::size() const\r\n{\r\n    return parser_->parseExpression(left_).toInt() - parser_->parseExpression(right_).toInt() + 1;\r\n}\r\n\r\nQString VhdlPort::left() const\r\n{\r\n\treturn left_;\r\n}\r\n\r\nQString VhdlPort::right() const\r\n{\r\n\treturn right_;\r\n}\r\n\r\nvoid VhdlPort::setCommented( bool commentOut )\r\n{\r\n\tcommentOut_ = commentOut;\r\n}\r\n\r\nbool VhdlPort::isCommented() const\r\n{\r\n\treturn commentOut_;\r\n}\r\n\r\nbool VhdlPort::hasRealPorts( const QMap<VhdlPortSorter, QSharedPointer<VhdlPort> >& ports )\r\n{\r\n    for (auto const& port : ports)\r\n    {\r\n\t\t// if at least one port that is uncommented is found\r\n\t\tif (!port->isCommented())\r\n        {\r\n\t\t\treturn true;\r\n\t\t}\r\n\t}\r\n\r\n\t// all ports were commented out so they are not in synthesis\r\n\treturn false;\r\n}\r\n"
  },
  {
    "path": "Plugins/VHDLGenerator/vhdlport.h",
    "content": "/* \r\n *  \tCreated on: 28.10.2011\r\n *      Author: Antti Kamppi\r\n * \t\tfilename: vhdlport.h\r\n *\t\tProject: Kactus 2\r\n */\r\n\r\n#ifndef VHDLPORT_H\r\n#define VHDLPORT_H\r\n\r\n#include \"VhdlTypedObject.h\"\r\n#include \"vhdlportsorter.h\"\r\n\r\n#include <QSharedPointer>\r\n\r\nclass Port;\r\nclass ExpressionParser;\r\n\r\n/*! VhdlPort represents one port declaration in vhdl.\r\n * \r\n * VhdlPort is used within top component entity and component declarations\r\n * to print the declaration for one port.\r\n */\r\nclass VhdlPort : public VhdlTypedObject\r\n{\r\n\r\npublic:\r\n\r\n\t/*! The constructor\r\n\t *\t \r\n\t * @param [in] port      The port that contains the details for this port.\r\n     * @param [in] parser    The expression parser to use.\r\n\t *\r\n\t*/\r\n\tVhdlPort(QSharedPointer<Port> port, QSharedPointer<ExpressionParser> parser);\r\n\t\r\n\t//! The destructor\r\n\tvirtual ~VhdlPort() = default;\r\n\r\n\t/*! Write the contents of the port to the text stream.\r\n\t *\r\n\t * @param [in] stream The text stream to write the port into.\r\n\t *\r\n\t*/\r\n\tvirtual void write(QTextStream& stream) const override final;\r\n\r\n\t/*! Get the size of the port.\r\n\t * \r\n\t * Size is calculated: left - right + 1\r\n\t * \r\n\t * @return int The size of the port.\r\n\t*/\r\n\tint size() const;\r\n\r\n\t/*! Get the left bound of the port.\r\n\t *\r\n\t * @return int The left bound.\r\n\t*/\r\n\tQString left() const;\r\n\r\n\t/*! Get the right bound of the port.\r\n\t *\r\n\t * @return int The right bound.\r\n\t*/\r\n\tQString right() const;\r\n\r\n\t/*! Set the port to be commented out or not.\r\n\t *\r\n\t * @param [in] commentOut If true then the port is commented out when written.\r\n\t *\r\n\t*/\r\n\tvoid setCommented(bool commentOut);\r\n\r\n\t/*! Check if the port is commented out or not.\r\n\t *\r\n\t * @return bool True if the port is commented out.\r\n\t*/\r\n\tbool isCommented() const;\r\n\r\n\t/*! Checks the map for uncommented ports that are used in synthesis.\r\n\t *\r\n\t * @param [in] QMap contains the ports that are checked.\r\n\t *\r\n\t * @return bool True if at least one uncommented port is found.\r\n\t*/\r\n\tstatic bool hasRealPorts(const QMap<VhdlPortSorter, QSharedPointer<VhdlPort> >& ports);\r\n\r\nprivate:\r\n\t//! No copying\r\n\tVhdlPort(const VhdlPort& other);\r\n\r\n\t//! No assignment\r\n\tVhdlPort& operator=(const VhdlPort& other);\r\n\r\n\t//! The direction of the port.\r\n\tDirectionTypes::Direction direction_;\r\n\r\n\t//! The left bound of the port.\r\n\tQString left_;\r\n\r\n\t//! The right bound of the port.\r\n\tQString right_;\r\n\r\n\t//! If true then the port is commented out when printed to text stream\r\n\tbool commentOut_;\r\n\r\n    QSharedPointer<ExpressionParser> parser_;\r\n};\r\n\r\n#endif // VHDLPORT_H\r\n"
  },
  {
    "path": "Plugins/VHDLGenerator/vhdlportmap.cpp",
    "content": "/* \r\n *  \tCreated on: 26.10.2011\r\n *      Author: Antti Kamppi\r\n * \t\tfilename: vhdlportmap.cpp\r\n *\t\tProject: Kactus 2\r\n */\r\n\r\n#include \"vhdlportmap.h\"\r\n\r\nVhdlPortMap::VhdlPortMap():\r\nVhdlTypedObject(\"\", \"std_logic\", \"\", \"\"),\r\nleft_(),\r\nright_()\r\n{\r\n\r\n}\r\n\r\nVhdlPortMap::VhdlPortMap(const QString& name, const QString& leftBound, const QString& rightBound, const QString& type) :\r\n    VhdlTypedObject(name, type, \"\", \"\"),\r\n    left_(leftBound),\r\n    right_(rightBound)\r\n{\r\n\r\n}\r\n\r\n\r\nbool VhdlPortMap::operator==(const VhdlPortMap& other) const\r\n{\r\n    if (name() == other.name() && left_ == other.left_ &&\tright_ == other.right_)\r\n    {\r\n        return true;\r\n    }\r\n    return false;\r\n}\r\n\r\nbool VhdlPortMap::operator!=(const VhdlPortMap& other) const\r\n{\r\n    if (name() != other.name())\r\n    {\r\n        return true;\r\n    }\r\n    else if (left_ != other.left_)\r\n    {\r\n        return true;\r\n    }\r\n    else if (right_ != other.right_)\r\n    {\r\n        return true;\r\n    }\r\n    return false;\r\n}\r\n\r\nbool VhdlPortMap::operator<( const VhdlPortMap& other ) const \r\n{\r\n\tif (name().compare(other.name(), Qt::CaseInsensitive) == 0) \r\n    {\r\n\t\tif (left_ == other.left_) \r\n        {\r\n\t\t\treturn right_ < other.right_;\r\n\t\t}\r\n\t\telse \r\n        {\r\n\t\t\treturn left_ < other.left_;\r\n\t\t}\r\n\t}\r\n\telse \r\n    {\r\n\t\treturn name().compare(other.name(), Qt::CaseInsensitive) < 0;\r\n\t}\r\n}\r\n\r\nbool VhdlPortMap::operator>( const VhdlPortMap& other ) const \r\n{\r\n\tif (name().compare(other.name(), Qt::CaseInsensitive) == 0) \r\n    {\r\n\t\tif (left_ == other.left_) \r\n        {\r\n\t\t\treturn right_ > other.right_;\r\n\t\t}\r\n\t\telse \r\n        {\r\n\t\t\treturn left_ > other.left_;\r\n\t\t}\r\n\t}\r\n\telse \r\n    {\r\n\t\treturn name().compare(other.name(), Qt::CaseInsensitive) > 0;\r\n\t}\r\n}\r\n\r\nvoid VhdlPortMap::write( QTextStream& stream ) const\r\n{\r\n\tstream << getVhdlLegalName().leftJustified(16, ' ');\r\n}\r\n\r\nQString VhdlPortMap::mappingWith(VhdlPortMap const& value) const\r\n{\r\n    bool writeBounds = (left_.compare(value.left_) != 0 || right_.compare(value.right_) != 0);\r\n\r\n    QString result(getVhdlLegalName() + \" => \" + value.getVhdlLegalName());\r\n\r\n    if (writeBounds && value.left_.isEmpty() == false && value.left_.compare(QLatin1String(\"-1\")) != 0 && \r\n        value.right_.isEmpty() == false && value.right_.compare(QLatin1String(\"-1\")) != 0)\r\n    {\r\n        result += QString(\"(%1 downto %2)\").arg(value.left_).arg(value.right_);\r\n    }\r\n   \r\n    return result;\r\n}\r\n"
  },
  {
    "path": "Plugins/VHDLGenerator/vhdlportmap.h",
    "content": "/* \r\n *  \tCreated on: 26.10.2011\r\n *      Author: Antti Kamppi\r\n * \t\tfilename: vhdlportmap.h\r\n *\t\tProject: Kactus 2\r\n */\r\n\r\n#ifndef VHDLPORTMAP_H\r\n#define VHDLPORTMAP_H\r\n\r\n#include \"VhdlTypedObject.h\"\r\n\r\n#include <QString>\r\n#include <QTextStream>\r\n\r\n/*! VhdlPortMap represents a port and it's optional bounds in vhdl.\r\n * \r\n * This class is used in VhdlComponentInstance to store a mapped port and the \r\n * boundaries of the mapping.\r\n */\r\nclass VhdlPortMap  : public VhdlTypedObject\r\n{\r\n\r\npublic:\r\n\r\n\t/*! The default constructor.\r\n\t *\r\n\t*/\r\n\tVhdlPortMap();\r\n\r\n\t/*! The constructor\r\n\t *\r\n\t * @param [in] name The name of the port\r\n\t * @param [in] leftBound The left bound of the port.\r\n\t * @param [in] rightBound The right bound of the port.\r\n\t * @param [in] type The type of the mapped item.\r\n\t *\r\n\t*/\r\n\tVhdlPortMap(const QString& name, \r\n\t\tconst QString& leftBound, \r\n\t\tconst QString& rightBound,\r\n\t\tconst QString& type = QString());\r\n\r\n\t//! Copy constructor\r\n\tVhdlPortMap(const VhdlPortMap& other) = default;\r\n\r\n\t//! Assignment operator\r\n\tVhdlPortMap& operator=(const VhdlPortMap& other) = default;\r\n\r\n\t//! The operator ==\r\n\tbool operator==(const VhdlPortMap& other) const;\r\n\r\n\t//! The operator !=\r\n\tbool operator!=(const VhdlPortMap& other) const;\r\n\r\n\t//! The operator <\r\n\tbool operator<(const VhdlPortMap& other) const;\r\n\r\n\t//! The operator >\r\n\tbool operator>(const VhdlPortMap& other) const;\r\n\r\n\t//! The destructor\r\n\tvirtual ~VhdlPortMap() = default;\r\n\r\n\t/*! Write the port map into the text stream.\r\n\t *\r\n\t * @param [in] stream The stream to write into.\r\n\t *\r\n\t*/\r\n\tvirtual void write(QTextStream& stream) const override final;\r\n\r\n    /*! Create a mapping statement for this map with the given map.\r\n     *\r\n     * The string is format: <port name> => <port name>(<left> downto <right>)\r\n     *\r\n     * @return The mapping with the given map.\r\n    */\r\n\r\n    QString mappingWith(VhdlPortMap const& value) const;\r\n\r\nprivate:\r\n\r\n\t//! The left bound of the port for the port map\r\n\tQString left_;\r\n\r\n\t//! The right bound of the port for the port map\r\n\tQString right_;\r\n\r\n};\r\n\r\n#endif // VHDLPORTMAP_H\r\n"
  },
  {
    "path": "Plugins/VHDLGenerator/vhdlportsorter.cpp",
    "content": "/* \r\n *  \tCreated on: 28.10.2011\r\n *      Author: Antti Kamppi\r\n * \t\tfilename: vhdlportsorter.cpp\r\n *\t\tProject: Kactus 2\r\n */\r\n\r\n#include \"vhdlportsorter.h\"\r\n\r\nVhdlPortSorter::VhdlPortSorter(const QString& interface,\r\n\t\t\t\t\t\t\t   const QString& name, \r\n\t\t\t\t\t\t\t   DirectionTypes::Direction direction ):\r\ninterface_(interface),\r\nname_(name),\r\ndirection_(direction) {\r\n\r\n}\r\n\r\n\r\nbool VhdlPortSorter::operator==( const VhdlPortSorter& other ) const {\r\n\treturn (0 == name_.compare(other.name_, Qt::CaseInsensitive));\r\n}\r\n\r\nbool VhdlPortSorter::operator!=( const VhdlPortSorter& other ) const {\r\n\treturn (0 != name_.compare(other.name_, Qt::CaseInsensitive));\r\n}\r\n\r\nbool VhdlPortSorter::operator<( const VhdlPortSorter& other ) const {\r\n\r\n\t// first compare the interface names\r\n\tif (interface_.compare(other.interface_, Qt::CaseInsensitive) == 0) {\r\n\t\t\r\n\t\t// same interface, then compare the direction, and then the name\r\n\t\tif (direction_ == other.direction_) {\r\n\t\t\treturn name_.compare(other.name_, Qt::CaseInsensitive) < 0;\r\n\t\t}\r\n\t\telse {\r\n\t\t\treturn direction_ < other.direction_;\r\n\t\t}\r\n\t}\r\n\telse {\r\n\t\treturn interface_.compare(other.interface_, Qt::CaseInsensitive) < 0;\r\n\t}\r\n\r\n}\r\n\r\nbool VhdlPortSorter::operator>( const VhdlPortSorter& other ) const {\r\n\r\n\t// first compare the interface names\r\n\tif (interface_.compare(other.interface_, Qt::CaseInsensitive) == 0) {\r\n\r\n\t\t// same interface, then compare the direction, and then the name\r\n\t\tif (direction_ == other.direction_) {\r\n\t\t\treturn name_.compare(other.name_, Qt::CaseInsensitive) > 0;\r\n\t\t}\r\n\t\telse {\r\n\t\t\treturn direction_ > other.direction_;\r\n\t\t}\r\n\t}\r\n\telse {\r\n\t\treturn interface_.compare(other.interface_, Qt::CaseInsensitive) > 0;\r\n\t}\r\n}\r\n\r\nQString VhdlPortSorter::interface() const {\r\n\treturn interface_;\r\n}\r\n"
  },
  {
    "path": "Plugins/VHDLGenerator/vhdlportsorter.h",
    "content": "/* \r\n *  \tCreated on: 28.10.2011\r\n *      Author: Antti Kamppi\r\n * \t\tfilename: vhdlportsorter.h\r\n *\t\tProject: Kactus 2\r\n */\r\n\r\n#ifndef VHDLPORTSORTER_H\r\n#define VHDLPORTSORTER_H\r\n\r\n#include <IPXACTmodels/common/DirectionTypes.h>\r\n\r\n#include <QString>\r\n\r\n/*! VhdlPortSorter can be used as a key in associative containers to sort VhdlPorts\r\n * \r\n */\r\nclass VhdlPortSorter {\r\n\r\npublic:\r\n\r\n\t/*! The constructor\r\n\t *\r\n\t * @param [in] interface The name of the interface the port belongs to.\r\n\t * @param [in] name The name of the port.\r\n\t * @param [in] direction The direction of the port.\r\n\t *\r\n\t*/\r\n\tVhdlPortSorter(const QString& interface, const QString& name, DirectionTypes::Direction direction);\r\n\t\r\n\t//! Copy constructor\r\n\tVhdlPortSorter(const VhdlPortSorter& other) = default;\r\n\r\n\t//! The destructor\r\n\t~VhdlPortSorter() = default;\r\n\r\n\t//! Assignment operator\r\n\tVhdlPortSorter& operator=(const VhdlPortSorter& other) = default;\r\n\r\n\t/*! The operator ==\r\n\t *\r\n\t * The ports are considered equal if they have the same name.\r\n\t * \r\n\t * @param [in] other Reference to the sorter to compare to.\r\n\t *\r\n\t * @return True if ports have same name.\r\n\t*/\r\n\tbool operator==(const VhdlPortSorter& other) const;\r\n\r\n\t/*! The operator !=\r\n\t * \r\n\t * The ports are considered unequal if they have different names.\r\n\t * \r\n\t * @param [in] other Reference to the sorter to compare to.\r\n\t *\r\n\t * @return True if ports have different names.\r\n\t*/\r\n\tbool operator!=(const VhdlPortSorter& other) const;\r\n\r\n\t/*! The operator <\r\n\t * \r\n\t * The ports are sorted according to the direction of the port.\r\n\t * \r\n\t * @param [in] other Reference to the sorter to compare to.\r\n\t *\r\n\t * @return bool VhdlPortSorter&\r\n\t*/\r\n\tbool operator<(const VhdlPortSorter& other) const;\r\n\r\n\t/*! The operator >\r\n\t *\r\n\t * The ports are sorted according to the direction of the port.\r\n\t *\r\n\t * @param [in] other Reference to the sorter to compare to.\r\n\t *\r\n\t * @return bool VhdlPortSorter&\r\n\t*/\r\n\tbool operator>(const VhdlPortSorter& other) const;\r\n\r\n\t/*! Get the name of the interface the port belongs to.\r\n\t *\r\n\t * @return QString The name for the interface.\r\n\t*/\r\n\tQString interface() const;\r\n\r\nprivate:\r\n\t\r\n\t//! The name of the interface the port belongs to.\r\n\tQString interface_;\r\n\r\n\t//! The name of the port.\r\n\tQString name_;\r\n\r\n\t//! The direction of the port.\r\n\tDirectionTypes::Direction direction_;\r\n};\r\n\r\n#endif // VHDLPORTSORTER_H\r\n"
  },
  {
    "path": "Plugins/VHDLGenerator/vhdlsignal.cpp",
    "content": "/* \r\n *  \tCreated on: 26.10.2011\r\n *      Author: Antti Kamppi\r\n * \t\tfilename: vhdlsignal.cpp\r\n *\t\tProject: Kactus 2\r\n */\r\n\r\n#include \"vhdlsignal.h\"\r\n\r\n#include \"vhdlgeneral.h\"\r\n\r\nVhdlSignal::VhdlSignal(const QString& name /*= QString()*/,\r\n\t\t\t\t\t   const QString& signalType /*= QString()*/,\r\n\t\t\t\t\t   int leftBound /*= -1*/, \r\n\t\t\t\t\t   int rightBound /*= -1*/, \r\n\t\t\t\t\t   const QString& description /*= QString()*/,\r\n\t\t\t\t\t   const QString& defaultValue /*= QString()*/):\r\nVhdlTypedObject(name, signalType, defaultValue, description),\r\nleft_(leftBound),\r\nright_(rightBound) {\r\n\r\n\tif (signalType.isEmpty()) {\r\n\t\tsetType(VhdlGeneral::useDefaultType(left_, right_));\r\n\t}\t\r\n\tQ_ASSERT(!type().isEmpty());\r\n}\r\n\r\n\r\nvoid VhdlSignal::write( QTextStream& stream ) const {\r\n\tQ_ASSERT(!name().isEmpty());\r\n\tQ_ASSERT(!type().isEmpty());\r\n\r\n\tif (!description().isEmpty()) {\r\n\t\tVhdlGeneral::writeDescription(description(), stream, QString(\"  \"));\r\n\t}\r\n\tstream << \"  signal \"; \r\n    stream << getVhdlLegalName().leftJustified(16, ' '); // align colons (:) at least roughly\r\n\tstream << \" : \";\r\n\tQString typeDefinition = VhdlGeneral::vhdlType2String(type(), left_, right_);\r\n\tstream << typeDefinition << \";\" << Qt::endl;\r\n}\r\n\r\nint VhdlSignal::left() const {\r\n\treturn left_;\r\n}\r\n\r\nvoid VhdlSignal::setLeft( int left ) {\r\n\tleft_ = left;\r\n}\r\n\r\nint VhdlSignal::right() const {\r\n\treturn right_;\r\n}\r\n\r\nvoid VhdlSignal::setRight( int right ) {\r\n\tright_ = right;\r\n}\r\n\r\nvoid VhdlSignal::setBounds( int left, int right ) {\r\n\tleft_ = left;\r\n\tright_ = right;\r\n\r\n\t// if scalar port changed to vectored\r\n\tif (type() == \"std_logic\" && left != right) {\r\n\t\tsetType(\"std_logic_vector\");\r\n\t}\r\n\r\n\t// if vectored port changed to scalar\r\n\telse if (type() == \"std_logic_vector\" && left == right) {\r\n\t\tsetType(\"std_logic\");\r\n\t}\r\n}\r\n\r\n"
  },
  {
    "path": "Plugins/VHDLGenerator/vhdlsignal.h",
    "content": "/* \r\n *  \tCreated on: 26.10.2011\r\n *      Author: Antti Kamppi\r\n * \t\tfilename: vhdlsignal.h\r\n *\t\tProject: Kactus 2\r\n */\r\n\r\n#ifndef VHDLSIGNAL_H\r\n#define VHDLSIGNAL_H\r\n\r\n#include \"VhdlTypedObject.h\"\r\n\r\nclass VhdlSignal : public VhdlTypedObject\r\n{\r\n\r\npublic:\r\n\r\n\t/*! The constructor\r\n\t *\r\n\t * @param [in] parent Pointer to the owner of this vhdl object.\r\n\t * @param [in] name Name for this vhdl object.\r\n\t * @param [in] type Type for this vhdl object.\r\n\t * @param [in] leftBound The left bound for the signal.\r\n\t * @param [in] rightBound The right bound for the signal.\r\n\t * @param [in] description The description for this vhdl object.\r\n\t * @param [in] defaultValue The default value for the signal.\r\n\t *\r\n\t*/\r\n\tVhdlSignal(const QString& name = QString(),\r\n\t\tconst QString& signalType = QString(),\r\n\t\tint leftBound = -1,\r\n\t\tint rightBound = -1,\r\n\t\tconst QString& description = QString(),\r\n\t\tconst QString& defaultValue = QString());\r\n\r\n\t\r\n\t//! The destructor\r\n\tvirtual ~VhdlSignal() = default;\r\n\r\n\t/*! Write the declaration of the signal to the text stream.\r\n\t *\r\n\t * @param [in] stream The text stream to write the signal declaration into.\r\n\t *\r\n\t*/\r\n\tvirtual void write(QTextStream& stream) const override final;\r\n\r\n\t/*! Get the left bound of the signal\r\n\t *\r\n\t *\r\n\t * @return int the left bound.\r\n\t*/\r\n\tint left() const;\r\n\r\n\t/*! Set the left bound of the signal.\r\n\t *\r\n\t * @param [in] left The left bound to set.\r\n\t *\r\n\t*/\r\n\tvoid setLeft(int left);\r\n\r\n\t/*! Get the right bound of the signal.\r\n\t *\r\n\t *\r\n\t * @return int the right bound\r\n\t*/\r\n\tint right() const;\r\n\r\n\t/*! Set the right bound of the signal.\r\n\t *\r\n\t * @param [in] right The right bound to set.\r\n\t *\r\n\t*/\r\n\tvoid setRight(int right);\r\n\r\n\t/*! Set bounds for the signal.\r\n\t *\r\n\t * @param [in] left The left bound for signal.\r\n\t * @param [in] right The right bound for signal.\r\n\t *\r\n\t*/\r\n\tvoid setBounds(int left, int right);\r\n\r\nprivate:\r\n\t//! No copying\r\n\tVhdlSignal(const VhdlSignal& other);\r\n\r\n\t//! No assignment\r\n\tVhdlSignal& operator=(const VhdlSignal& other);\r\n\r\n\t//! The left bound of the signal.\r\n\tint left_;\r\n\r\n\t//! The right bound of the signal.\r\n\tint right_;\r\n};\r\n\r\n#endif // VHDLSIGNAL_H\r\n"
  },
  {
    "path": "Plugins/VHDLPackageImport/VHDLPackageImport.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: VHDLPackageImport.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Antti Sillanpää\r\n// Date: 25.06.2015\r\n//\r\n// Description:\r\n// Import plugin for VHDL package.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"VHDLPackageImport.h\"\r\n#include \"VHDLSyntax.h\"\r\n\r\n#include <Plugins/PluginSystem/ImportPlugin/ImportColors.h>\r\n#include <Plugins/PluginSystem/ImportPlugin/Highlighter.h>\r\n#include <Plugins/PluginSystem/ImportPlugin/ModelParameterVisualizer.h>\r\n\r\n#include <IPXACTmodels/common/Parameter.h>\r\n\r\n#include <IPXACTmodels/Component/Component.h>\r\n#include <IPXACTmodels/Component/Model.h>\r\n#include <IPXACTmodels/Component/View.h>\r\n\r\n#include <stdio.h>\r\n#include <QRegularExpression>\r\n#include <QtGui>\r\n\r\nnamespace\r\n{\r\n    //QRegularExpression const PACKAGE(\"PACKAGE\\\\s+(\\\\w+)\\\\s+IS\\\\s+.*END\\\\s+(\\\\w+)\\\\s*[;]\",QRegularExpression::CaseInsensitiveOption);\r\n    QRegularExpression const PACKAGE_START(\"PACKAGE\\\\s+(\\\\w+)\\\\s+IS\\\\s+\",QRegularExpression::CaseInsensitiveOption);\r\n    QRegularExpression const PACKAGE_END(\"END\\\\s*(\\\\w+)\\\\s*[;]\",QRegularExpression::CaseInsensitiveOption);\r\n    //QRegularExpression const CONSTANT(\"\\\\bconstant\\\\s+\",QRegularExpression::CaseInsensitiveOption);\r\n    //QRegularExpression const CONSTANT_par(\"\\\\bconstant\\\\s*(\\\\w+)\\\\s*[:]\\\\s*(\\\\w+)(?:\\\\s*\"+ VHDLSyntax::DEFAULT +\")\\\\s*[;]\",QRegularExpression::CaseInsensitiveOption);\r\n    QRegularExpression const CONSTANT_par(\"\\\\bconstant\\\\s*(\\\\w+)\\\\s*[:]\\\\s*(\\\\w+)\\\\s*[:][=]\\\\s*(\\\\d*)\\\\s*[;]\",QRegularExpression::CaseInsensitiveOption);\r\n    //QRegularExpression const VARIABLE(\"variable\\\\s+\",QRegularExpression::CaseInsensitiveOption);\r\n    QRegularExpression const FUNCTION(\"^function\\\\s+\\\\w+.*return\\\\w+\\\\s*[;]$\",QRegularExpression::CaseInsensitiveOption);\r\n    QRegularExpression const PROCEDURE(\"procedure\\\\s*\\\\w+\\\\s*[(].*[)]\\\\s*[;]\",QRegularExpression::CaseInsensitiveOption);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VHDLPackageImport::VHDLPackageImport()\r\n//-----------------------------------------------------------------------------\r\nVHDLPackageImport::VHDLPackageImport() : QObject(0), highlighter_(0)\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VHDLPackageImport::~VHDLPackageImport()\r\n//-----------------------------------------------------------------------------\r\nVHDLPackageImport::~VHDLPackageImport()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VHDLPackageImport::getName()\r\n//-----------------------------------------------------------------------------\r\nQString VHDLPackageImport::getName() const\r\n{\r\n    return \"VHDL package import\";\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VHDLPackageImport::getVersion()\r\n//-----------------------------------------------------------------------------\r\nQString VHDLPackageImport::getVersion() const\r\n{\r\n    return \"1.0\";\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VHDLPackageImport::getDescription()\r\n//-----------------------------------------------------------------------------\r\nQString VHDLPackageImport::getDescription() const\r\n{\r\n    return \"Import constants from vhdl package file.\";\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VHDLPackageImport::getVendor()\r\n//-----------------------------------------------------------------------------\r\nQString VHDLPackageImport::getVendor() const\r\n{\r\n    return tr(\"TUT\");\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VHDLPackageImport::getLicence()\r\n//-----------------------------------------------------------------------------\r\nQString VHDLPackageImport::getLicence() const\r\n{\r\n    return tr(\"GPL2\");\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VHDLPackageImport::getLicenceHolder()\r\n//-----------------------------------------------------------------------------\r\nQString VHDLPackageImport::getLicenceHolder() const\r\n{\r\n    return tr(\"Public\");\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VHDLPackageImport::getSettingsWidget()\r\n//-----------------------------------------------------------------------------\r\nPluginSettingsWidget* VHDLPackageImport::getSettingsWidget()\r\n{\r\n    return new PluginSettingsWidget();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VHDLPackageImport::getProgramRequirements()\r\n//-----------------------------------------------------------------------------\r\nQList<IPlugin::ExternalProgramRequirement> VHDLPackageImport::getProgramRequirements()\r\n{\r\n    return QList<IPlugin::ExternalProgramRequirement>();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VHDLPackageImport::getSupportedFileTypes()\r\n//-----------------------------------------------------------------------------\r\nQStringList VHDLPackageImport::getSupportedFileTypes() const\r\n{\r\n    QStringList supportedTypes;\r\n    supportedTypes << \"vhdlSource\" << \"vhdlSource-87\" << \"vhdlSource-93\";\r\n    return supportedTypes;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VHDLPackageImport::getCompatibilityWarnings()\r\n//-----------------------------------------------------------------------------\r\nQString VHDLPackageImport::getCompatibilityWarnings() const\r\n{\r\n    return QString();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VHDLPackageImport::import()\r\n//-----------------------------------------------------------------------------\r\nvoid VHDLPackageImport::import(QString const& input, QSharedPointer<Component> targetComponent)\r\n{\r\n    if (hasPackageDeclaration(input))\r\n    {\r\n        QStringList constants;\r\n\r\n        int startIndex = PACKAGE_START.match(input).capturedEnd();\r\n        int length = input.indexOf(PACKAGE_END) - startIndex;\r\n\r\n        QString package = input.mid(startIndex, length);\r\n\r\n        QRegExp commentLine(\"^\" + VHDLSyntax::SPACE + VHDLSyntax::COMMENT_LINE_EXP + \"|\" +\r\n            VHDLSyntax::ENDLINE + VHDLSyntax::SPACE + VHDLSyntax::COMMENT_LINE_EXP);\r\n        package.remove(commentLine);\r\n        package.remove(FUNCTION);\r\n        package.remove(PROCEDURE);\r\n\r\n        //constants.append(findDeclarations(CONSTANT_par,package));\r\n        int nextGeneric = package.indexOf(CONSTANT_par, 0);\r\n        while (nextGeneric != -1)\r\n        {\r\n            QRegularExpressionMatch match = CONSTANT_par.match(package, nextGeneric);\r\n            constants.append(match.captured());\r\n            nextGeneric = package.indexOf(CONSTANT_par, nextGeneric + match.capturedLength());\r\n        }\r\n\r\n//        qDebug() << constants.size();\r\n//        qDebug() << package;\r\n\r\n//        for(int i = 0; i<constants.size();i++)\r\n//        {\r\n//            qDebug() << constants[i];\r\n//        }\r\n        foreach (QString constant, constants)\r\n        {\r\n\r\n            createModelParameterFromDefinition(constant,targetComponent);\r\n            highlightDefinition(constant);\r\n        }\r\n\r\n\r\n    }\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VHDLPackageImport::setHighlighter()\r\n//-----------------------------------------------------------------------------\r\nvoid VHDLPackageImport::setHighlighter(Highlighter* highlighter)\r\n{\r\n    highlighter_ = highlighter;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VerilogImporter::hasModuleDeclaration()\r\n//-----------------------------------------------------------------------------\r\nbool VHDLPackageImport::hasPackageDeclaration(QString const& input)\r\n{\r\n    int packageBegin = input.indexOf(PACKAGE_START);\r\n    int packageEnd = input.indexOf(PACKAGE_END,packageBegin);\r\n\r\n    return packageBegin != -1 && packageEnd != -1;\r\n}\r\n//-----------------------------------------------------------------------------\r\n// Function: VerilogParameterParser::findDeclarations()\r\n//-----------------------------------------------------------------------------\r\nQStringList VHDLPackageImport::findDeclarations(QRegularExpression const& declarationRule,\r\n    QString const& inspect)\r\n{\r\n    QStringList declarations;\r\n\r\n    int previousStart = 0;\r\n    int declarationStart = inspect.indexOf(declarationRule);\r\n\r\n    // Repeat the parsing until no more matches are found.\r\n    while (declarationStart != -1)\r\n    {\r\n        int declarationLength = declarationRule.match(inspect, declarationStart).capturedLength();\r\n\r\n        // Seek for the next match beginning from the end of the previous match.\r\n        previousStart = declarationStart;\r\n        declarationStart = inspect.indexOf(declarationRule, declarationStart  + declarationLength + 1);\r\n\r\n        // Take the matching part and append to the list.\r\n        QString declaration = inspect.mid(previousStart, declarationStart - previousStart);\r\n        declaration = declaration.trimmed();\r\n\r\n        // Highlight the selection if applicable.\r\n\r\n        //highlightDefinition(declaration);\r\n        declarations.append(declaration);\r\n\r\n    }\r\n    return declarations;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VHDLPackageImport::highlightDefinition()\r\n//-----------------------------------------------------------------------------\r\nvoid VHDLPackageImport::highlightDefinition(QString const& definition)\r\n{\r\n    if (highlighter_)\r\n    {\r\n        highlighter_->applyFontColor(definition, Qt::black);\r\n        highlighter_->applyHighlight(definition, ImportColors::MODELPARAMETER);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VHDLPackageImport::createParameterFromDefinition()\r\n//-----------------------------------------------------------------------------\r\nvoid VHDLPackageImport::createModelParameterFromDefinition(QString const& definition,\r\n    QSharedPointer<Component> targetComponent)\r\n{\r\n   // QRegularExpressionMatch match = CONSTANT_par.match(definition);\r\n    QString name = CONSTANT_par.match(definition).captured(1);\r\n    qDebug() << name;\r\n\r\n    QString dataType = CONSTANT_par.match(definition).captured(2);\r\n    QString value = CONSTANT_par.match(definition).captured(3);\r\n        qDebug() << dataType;\r\n        qDebug() << value;\r\n    QSharedPointer<ModelParameter> parameter = findModelParameterByName(targetComponent, name);\r\n    if (parameter.isNull())\r\n    {\r\n        parameter = QSharedPointer<ModelParameter>(new ModelParameter());\r\n        parameter->setName(name);\r\n        targetComponent->getModel()->getModelParameters()->append(parameter);\r\n    }\r\n\r\n    if (value.isEmpty())\r\n    {\r\n        value = \"0\";\r\n    }\r\n\r\n    parameter->setDataType(dataType);\r\n    parameter->setValue(value);\r\n    //parameter->setDescription(description);\r\n    parameter->setAttribute(\"imported\", \"true\");\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VHDLPackageImport::findParameterByName()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<ModelParameter> VHDLPackageImport::findModelParameterByName(QSharedPointer<Component> targetComponent,\r\n    QString const& name) const\r\n{\r\n    QSharedPointer<ModelParameter> modelparameter;\r\n    foreach (QSharedPointer<ModelParameter> existingModelParameter, *targetComponent->getModelParameters())\r\n    {\r\n        if (existingModelParameter->getName() == name)\r\n        {\r\n            return existingModelParameter;\r\n        }\r\n    }\r\n\r\n    return modelparameter;\r\n}\r\n"
  },
  {
    "path": "Plugins/VHDLPackageImport/VHDLPackageImport.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: VHDLPackageImport.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Antti Sillanpää\r\n// Date: 25.06.2015\r\n//\r\n// Description:\r\n// Import plugin for VHDL package.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef VHDLPACKAGEIMPORT_H\r\n#define VHDLPACKAGEIMPORT_H\r\n\r\n#include \"vhdlpackageimport_global.h\"\r\n\r\n#include <Plugins/PluginSystem/IPlugin.h>\r\n#include <Plugins/PluginSystem/ImportPlugin/ImportPlugin.h>\r\n//#include <Plugins/PluginSystem/ImportPlugin/IncludeImportPlugin.h>\r\n#include <Plugins/PluginSystem/ImportPlugin/HighlightSource.h>\r\n\r\n#include <QSharedPointer>\r\n#include <QObject>\r\n\r\nclass Component;\r\nclass ModelParameter;\r\n//-----------------------------------------------------------------------------\r\n//! Import plugin for VHDL package.\r\n//-----------------------------------------------------------------------------\r\n\r\nclass VHDLPACKAGEIMPORT_EXPORT VHDLPackageImport : public QObject, public ImportPlugin, public HighlightSource\r\n{\r\n    Q_OBJECT\r\n    Q_PLUGIN_METADATA(IID \"kactus2.plugins.vhdlpackageimportplugin\" FILE \"vhdlpackageimportplugin.json\")\r\n\r\n    Q_INTERFACES(IPlugin)\r\n    Q_INTERFACES(ImportPlugin)\r\n   // Q_INTERFACES(IncludeImportPlugin)\r\n\r\npublic:\r\n\r\n    //! The constructor.\r\n    VHDLPackageImport();\r\n\r\n    //! The destructor.\r\n    ~VHDLPackageImport();\r\n\r\n    /*!\r\n     *  Returns the name of the plugin.\r\n     */\r\n    virtual QString getName() const;\r\n\r\n    /*!\r\n     *  Returns the version of the plugin.\r\n     */\r\n    virtual QString getVersion() const;\r\n\r\n    /*!\r\n     *  Returns the description of the plugin.\r\n     */\r\n    virtual QString getDescription() const;\r\n\r\n    /*!\r\n     *  Returns the vendor of the plugin.\r\n     */\r\n    virtual QString getVendor() const;\r\n\r\n    /*!\r\n     *  Returns the licence of the plugin.\r\n     */\r\n    virtual QString getLicence() const;\r\n\r\n    /*!\r\n     *  Returns the licence holder of the plugin.\r\n     */\r\n    virtual QString getLicenceHolder() const;\r\n\r\n    /*!\r\n     *  Returns the settings widget.\r\n     */\r\n    virtual PluginSettingsWidget* getSettingsWidget();\r\n\r\n    //! \\brief Returns the external program requirements of the plugin.\r\n     virtual QList<ExternalProgramRequirement> getProgramRequirements();\r\n\r\n    /*!\r\n     *  Returns the supported import file types.\r\n     *\r\n     *    @return The file types the import plugin supports.\r\n     */\r\n    virtual QStringList getSupportedFileTypes() const;\r\n\r\n    /*!\r\n     *  Gets any compatibility warnings for the plugin.\r\n     *\r\n     *    @return The warning text.\r\n     */\r\n    virtual QString getCompatibilityWarnings() const;\r\n\r\n    /*!\r\n     *  Parses the given input and creates parameters from Verilog defines.\r\n     *\r\n     *    @param [in] input               The input text to parse.\r\n     *    @param [in] targetComponent     The component to apply all imported changes to.\r\n     */\r\n    virtual void import(QString const& input, QSharedPointer<Component> targetComponent);\r\n\r\n    /*!\r\n     *  Sets the given highlighter to be used by the plugin.\r\n     *\r\n     *    @param [in] highlighter   The highlighter to use.\r\n     */\r\n    virtual void setHighlighter(Highlighter* highlighter);\r\n\r\nprivate:\r\n\r\n    // Disable copying.\r\n    VHDLPackageImport(VHDLPackageImport const& rhs);\r\n    VHDLPackageImport& operator=(VHDLPackageImport const& rhs);\r\n\r\n    /*!\r\n     *  Checks if the given input has a valid package declaration.\r\n     *\r\n     *    @param [in] input   The input to search for package declaration.\r\n     *\r\n     *    @return True, if a valid module was found, otherwise false.\r\n     */\r\n    bool hasPackageDeclaration(QString const& input);\r\n\r\n    /*!\r\n     *  Finds constant declarations from the inspected string with provided rule.\r\n     *\r\n     *    @param [in] declarationRule   The rule for finding a constant.\r\n     *    @param [in] inspect           The input text containing the declarations.\r\n     *\r\n     *    @return   The resulting list of declarations.\r\n     */\r\n    QStringList findDeclarations(QRegularExpression const& declarationRule, QString const& inspect);\r\n\r\n    /*!\r\n     *  Highlights the given definition.\r\n     *\r\n     *    @param [in] definition   The defintion to highlight.\r\n     */\r\n\r\n    void highlightDefinition(QString const& definition);\r\n\r\n    /*!\r\n     *  Creates a parameter from the given definition and adds it to the component.\r\n     *  Existing parameter with the same name will be updated and no new parameter is added.\r\n     *\r\n     *    @param [in] definition          The definition to create the parameter from.\r\n     *    @param [in] targetComponent     The component to add the parameter to.\r\n     */\r\n    void createModelParameterFromDefinition(QString const& definition, QSharedPointer<Component> targetComponent);\r\n\r\n    /*!\r\n     *  Finds a parameter in the given component by the given name.\r\n     *\r\n     *    @param [in] targetComponent     The component the search in.\r\n     *    @param [in] name                The name of the parameter to find.\r\n     *\r\n     *    @return The parameter with the given name or null if no parameter matches the name.\r\n     */\r\n    QSharedPointer<ModelParameter> findModelParameterByName(QSharedPointer<Component> targetComponent,\r\n        QString const& name) const;\r\n\r\n    //! The highlighter to use.\r\n    Highlighter* highlighter_;\r\n};\r\n\r\n\r\n\r\n#endif // VHDLPACKAGEIMPORT_H\r\n"
  },
  {
    "path": "Plugins/VHDLPackageImport/VHDLPackageImport.pri",
    "content": "# ----------------------------------------------------\r\n# This file is generated by the Qt Visual Studio Add-in.\r\n# ------------------------------------------------------\r\n\r\nHEADERS += ./VHDLPackageImport.h \\\r\n           ./VHDLSyntax.h \\\r\n    ../PluginSystem/ImportPlugin/ImportColors.h \\\r\n    ./vhdlpackageimport_global.h\r\n\r\nSOURCES += ./VHDLPackageImport.cpp\r\n"
  },
  {
    "path": "Plugins/VHDLPackageImport/VHDLPackageImport.pro",
    "content": "# ----------------------------------------------------\r\n# Created by copying data from other .pro-files\r\n# ------------------------------------------------------\r\n\r\nTEMPLATE = lib\r\n\r\nQT += core xml widgets gui\r\nCONFIG += c++11\r\n\r\nDEFINES += VHDLPACKAGEIMPORT_LIB\r\n\r\nINCLUDEPATH += ./../.. \\\r\n    ./GeneratedFiles \\\r\n    . \\\r\n\r\nCONFIG(debug, debug|release) {\r\n    # debug mode\r\n    LIBS += \\\r\n        -L../../executable -lIPXACTmodelsd\r\n\r\n    MOC_DIR += ./GeneratedFiles/Debug\r\n    OBJECTS_DIR += Debug\r\n    TARGET = VHDLPackageImportd\r\n\r\n} else {\r\n    # release mode \r\n    LIBS += \\\r\n        -L../../executable -lIPXACTmodels\r\n    \r\n    MOC_DIR += ./GeneratedFiles/Release\r\n    OBJECTS_DIR += Release\r\n    TARGET = VHDLPackageImport\r\n}\r\n\r\nDESTDIR = ../../executable/Plugins\r\n\r\nDEPENDPATH += .\r\nUI_DIR += ./GeneratedFiles\r\nRCC_DIR += ./GeneratedFiles\r\ninclude(VHDLPackageImport.pri)\r\n\r\ntarget.path = $$plugin_path\r\nINSTALLS += target\r\n\r\n"
  },
  {
    "path": "Plugins/VHDLPackageImport/VHDLSyntax.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: VhdlSyntax.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Esko Pekkarinen\r\n// Date: 4.7.2013\r\n//\r\n// Description:\r\n// This file contains common elements of the VHDL language\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef VHDLSYNTAX_H\r\n#define VHDLSYNTAX_H\r\n\r\n#include <Plugins/common/HDLmath.h>\r\n\r\n#include <QRegularExpression>\r\n\r\nnamespace VHDLSyntax\r\n{\r\n    //! Whitespace without line end.\r\n    const QString SPACE = \"[ \\\\t]*\";    \r\n\r\n    //! Platform-independent endline.\r\n    const QString ENDLINE = \"(\\\\r\\\\n?|\\\\n\\\\r?)\";\r\n\r\n    //! VHDL comment.\r\n    const QString COMMENT = \"[-][-]\" + SPACE + \"([^\\\\r\\\\n]*)(?=\" + ENDLINE + \"|$)\";\r\n   \r\n    //! VHDL port and generic names are separated using a colon (,).\r\n    const QString NAMES = \"\\\\w+(?:\\\\s*[,]?\\\\s*\\\\w+)*\";\r\n\r\n    //! Supported std_logic values.\r\n    const QString STD_ULOGIC = \"['][U|X|0|1|Z|W|L|H|-][']\";\r\n\r\n    //! Others is used to initialize a group of bits in std_logic_vector.\r\n    const QString OTHERS_EXP = \"[(]\\\\s*others\\\\s*=>\\\\s*\" + STD_ULOGIC + \"\\\\s*[)]\";\r\n\r\n    //! VHDL default value definition is mathematical expression, vector assignment with others, logical value\r\n    // or other string value.\r\n    const QString DEFAULT = \"[:][=]\\\\s*((?:\" + HDLmath::TERM + \")|\" + OTHERS_EXP + \"|[^\\\\s:;]+)\";\r\n\r\n    //! VHDL pragmas begin like comments with -- followed by a reserved word.\r\n    const QString PRAGMA = \"[-][-]\" + SPACE + \"(?:PRAGMA|SYNTHESIS|SYNOPSYS)[^\\\\r\\\\n]*\";\r\n\r\n    //! VHDL comment line.\r\n    const QString COMMENT_LINE_EXP = SPACE + COMMENT + \"(?=\" + ENDLINE + \")\";\r\n\r\n    /*! All except the last port/generic declaration ends with a semicolon. \r\n     *  If there is a comment on the same line, it will be captured to the description by VhdlParser.\r\n     *  Additional comments may follow the last declaration before the end of the string.\r\n     */\r\n    const QString DECLARATION_END = \"(?:\\\\s*[;]\" + SPACE + \"(?:\" + COMMENT + \"))|\"\r\n                                    \"(?:(?=\\\\s*[;]))|\"\r\n                                    \"(?:\" + SPACE + \"(?:\" + COMMENT + \")?(?=(?:\\\\s*(?:\" + COMMENT + \")*\\\\s*)*$))\";\r\n    \r\n    //! Entity declaration is ENTITY <name> IS ... END [ENTITY] [<name>];\r\n    const QRegularExpression ENTITY_BEGIN_EXP(\"(ENTITY)\\\\s+(\\\\w+)\\\\s+(IS)\", \r\n        QRegularExpression::CaseInsensitiveOption);   \r\n    const QRegularExpression ENTITY_END_EXP(\"(END)\\\\s*(ENTITY)?\\\\s*(\\\\w+)?\\\\s*[;]\", \r\n        QRegularExpression::CaseInsensitiveOption);\r\n    const QRegularExpression SUPPORTED_TYPES(\"[std_logic|std_ulogic|integer|std_logic_vector]\",\r\n        QRegularExpression::CaseInsensitiveOption);\r\n\r\n}\r\n\r\n#endif // VHDLSYNTAX_H\r\n"
  },
  {
    "path": "Plugins/VHDLPackageImport/vhdlpackageimport_global.h",
    "content": "#ifndef VHDLPACKAGEIMPORT_GLOBAL_H\r\n#define VHDLPACKAGEIMPORT_GLOBAL_H\r\n\r\n#include <QtCore/qglobal.h>\r\n\r\n#ifdef VHDLPACKAGEIMPORT_LIB\r\n# define VHDLPACKAGEIMPORT_EXPORT Q_DECL_EXPORT\r\n#else\r\n# define VHDLPACKAGEIMPORT_EXPORT Q_DECL_IMPORT\r\n#endif\r\n\r\n#endif // VHDLPACKAGEIMPORTT_GLOBAL_H\r\n"
  },
  {
    "path": "Plugins/VHDLPackageImport/vhdlpackageimportplugin.json",
    "content": "{\r\n\t\"Keys\": [ \"VHDL import Plugin\" ]\r\n}"
  },
  {
    "path": "Plugins/VHDLimport/VHDLGenericParser.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: VHDLGenericParser.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Esko Pekkarinen\r\n// Date: 16.09.2014\r\n//\r\n// Description:\r\n// Parser for VHDL generics.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"VHDLGenericParser.h\"\r\n\r\n#include \"VHDLSyntax.h\"\r\n\r\n#include <KactusAPI/include/ImportColors.h>\r\n\r\n#include <IPXACTmodels/Component/Component.h>\r\n#include <IPXACTmodels/Component/Model.h>\r\n#include <IPXACTmodels/common/ModuleParameter.h>\r\n\r\n#include <QRegularExpression>\r\n\r\nnamespace\r\n{\r\n    //! Generics are declared inside entity by GENERIC ( <generic_declarations> );\r\n    const QRegularExpression GENERICS_BEGIN_EXP = QRegularExpression(\"(GENERIC)\\\\s*[(]\", \r\n        QRegularExpression::CaseInsensitiveOption);    \r\n\r\n    const QRegularExpression GENERICS_END_EXP = QRegularExpression(\"[)]\\\\s*[;](?=(?:(\\\\s*\" + VHDLSyntax::COMMENT +\r\n        \")\\\\s*)*\\\\s*(END|BEGIN|PORT|GENERIC))\", QRegularExpression::CaseInsensitiveOption);   \r\n\r\n    const QString GENERIC_TYPE = \"(\\\\w+)(?:\\\\s+range\\\\s+\\\\d+\\\\s+to\\\\s+\\\\d+)?\";\r\n\r\n    //! Generic declaration is <generic_names> : <type> [<default>] [pragma]; [description]\r\n    const QRegularExpression GENERIC_EXP = QRegularExpression(\r\n        \"(\" + VHDLSyntax::NAMES + \")\\\\s*[:]\\\\s*\" + GENERIC_TYPE + \"(?:\\\\s*\" + VHDLSyntax::DEFAULT + \")?\" +\r\n        \"(?:\\\\s*\" + VHDLSyntax::PRAGMA + \")?(?:\" + VHDLSyntax::DECLARATION_END + \")\", \r\n        QRegularExpression::CaseInsensitiveOption);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VHDLGenericParser::VHDLGenericParser()\r\n//-----------------------------------------------------------------------------\r\nVHDLGenericParser::VHDLGenericParser(QObject* parent): QObject(parent), highlighter_(0)\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VHDLGenericParser::import()\r\n//-----------------------------------------------------------------------------\r\nvoid VHDLGenericParser::import(QString const& input, QSharedPointer<Component> targetComponent,\r\n    QSharedPointer<ComponentInstantiation> targetComponentInstantiation)\r\n{\r\n    foreach (QSharedPointer<ModuleParameter> modelParameter, *targetComponentInstantiation->getModuleParameters())\r\n    {\r\n        modelParameter->setAttribute(\"kactus2:import\", \"no\");\r\n    }\r\n\r\n    foreach(QString const& declaration, findGenericDeclarations(input))\r\n    {\r\n        createModelParameterFromDeclaration(declaration, targetComponentInstantiation);\r\n        if (highlighter_)\r\n        {\r\n            highlighter_->applyHighlight(declaration, ImportColors::MODELPARAMETER, input);\r\n        }        \r\n    }\r\n\r\n    foreach (QSharedPointer<ModuleParameter> modelParameter, *targetComponentInstantiation->getModuleParameters())\r\n    {\r\n        if (modelParameter->getAttribute(\"kactus2:import\").compare(\"no\") == 0)\r\n        {\r\n            targetComponentInstantiation->getModuleParameters()->removeAll(modelParameter);\r\n        }\r\n    }\r\n\r\n    replaceNamesReferencesWithIds(targetComponent, targetComponentInstantiation);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VHDLGenericParser::setHighlighter()\r\n//-----------------------------------------------------------------------------\r\nvoid VHDLGenericParser::setHighlighter(Highlighter* highlighter)\r\n{\r\n    highlighter_ = highlighter;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VHDLGenericParser::findGenericDeclarations()\r\n//-----------------------------------------------------------------------------\r\nQStringList VHDLGenericParser::findGenericDeclarations(QString const& input) const\r\n{\r\n    QString genericSection = findGenericsSection(input);\r\n    QString sectionWithoutCommentLines = removeCommentLines(genericSection);\r\n\r\n    return genericDeclarationsIn(sectionWithoutCommentLines);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VHDLGenericParser::genericsSection()\r\n//-----------------------------------------------------------------------------\r\nQString VHDLGenericParser::findGenericsSection(QString const &input) const\r\n{\r\n    int entityBegin = input.indexOf(VHDLSyntax::ENTITY_BEGIN_EXP);\r\n    int entityEnd = input.indexOf(VHDLSyntax::ENTITY_END_EXP, entityBegin);\r\n\r\n    int genericsBeginIndex = GENERICS_BEGIN_EXP.match(input).capturedEnd(); \r\n\r\n    if (genericsBeginIndex > entityEnd)\r\n    {\r\n        return QString();\r\n    }\r\n\r\n    int genericsEndIndex = input.indexOf(GENERICS_END_EXP, genericsBeginIndex);\r\n\r\n    return input.mid(genericsBeginIndex, genericsEndIndex - genericsBeginIndex);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VHDLGenericParser::removeCommentLines()\r\n//-----------------------------------------------------------------------------\r\nQString VHDLGenericParser::removeCommentLines(QString section) const\r\n{\r\n    QRegularExpression commentLine(\"^\" + VHDLSyntax::SPACE + VHDLSyntax::COMMENT_LINE_EXP + \"|\" +\r\n        VHDLSyntax::ENDLINE + VHDLSyntax::SPACE + VHDLSyntax::COMMENT_LINE_EXP);\r\n\r\n    return section.remove(commentLine);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VHDLGenericParser::genericDeclarationsIn()\r\n//-----------------------------------------------------------------------------\r\nQStringList VHDLGenericParser::genericDeclarationsIn(QString const& sectionWithoutCommentLines) const\r\n{\r\n    QStringList genericDeclarations;\r\n\r\n    QRegularExpressionMatchIterator i = GENERIC_EXP.globalMatch(sectionWithoutCommentLines);\r\n    while(i.hasNext())\r\n    {    \r\n        genericDeclarations.append(i.next().captured());\r\n    }\r\n\r\n    return genericDeclarations;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VHDLGenericParser::createModelParameterFromDeclaration()\r\n//-----------------------------------------------------------------------------\r\nvoid VHDLGenericParser::createModelParameterFromDeclaration(QString const& declaration, \r\n    QSharedPointer<ComponentInstantiation> targetComponentInstantiation) const\r\n{\r\n    QRegularExpressionMatch matchedDeclaration = GENERIC_EXP.match(declaration);\r\n\r\n    QStringList genericNames = matchedDeclaration.captured(1).split(QRegularExpression(\"\\\\s*[,]\\\\s*\"),\r\n        Qt::SkipEmptyParts);\r\n    QString dataType = matchedDeclaration.captured(2);\r\n    QString type = findMatchingType(dataType);\r\n    QString defaultValue = matchedDeclaration.captured(3);\r\n\r\n    QString description = matchedDeclaration.captured(5).trimmed();\r\n    if (description.isEmpty())\r\n    {\r\n        description = matchedDeclaration.captured(6).trimmed();\r\n    }\r\n\r\n    for (QString const& name : genericNames)\r\n    {   \r\n        QSharedPointer<ModuleParameter> parameter = findModuleParameter(name.trimmed(), targetComponentInstantiation);\r\n        if (parameter.isNull())\r\n        {\r\n            parameter = QSharedPointer<ModuleParameter>(new ModuleParameter());\r\n            targetComponentInstantiation->getModuleParameters()->append(parameter);\r\n        }\r\n\r\n        parameter->setName(name.trimmed());\r\n        parameter->setDataType(dataType);\r\n        parameter->setType(type);\r\n        parameter->setDescription(description);\r\n        parameter->setValue(defaultValue);\r\n        parameter->setUsageType(\"nontyped\");\r\n        parameter->setAttribute(\"kactus2:import\", \"\");\r\n    } \r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VHDLGenericParser::findModuleParameter()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<ModuleParameter> VHDLGenericParser::findModuleParameter(QString const& name, \r\n    QSharedPointer<ComponentInstantiation> targetComponentInstantiation) const\r\n{\r\n    foreach (QSharedPointer<ModuleParameter> currentParameter, *targetComponentInstantiation->getModuleParameters())\r\n    {\r\n        if (currentParameter->name().compare(name) == 0)\r\n        {\r\n            return currentParameter;\r\n        }\r\n    }\t\r\n\r\n    return QSharedPointer<ModuleParameter>();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VHDLGenericParser::replaceReferenceNamesWithIds()\r\n//-----------------------------------------------------------------------------\r\nvoid VHDLGenericParser::replaceNamesReferencesWithIds(QSharedPointer<Component> targetComponent,\r\n    QSharedPointer<ComponentInstantiation> targetComponentInstantiation) const\r\n{\r\n    foreach (QSharedPointer<ModuleParameter> moduleParameter, *targetComponentInstantiation->getModuleParameters())\r\n    {\r\n        QSharedPointer<Parameter> targetParameter = findParameter(moduleParameter->name(), targetComponent);\r\n        if (targetParameter.isNull())\r\n        {\r\n            targetParameter = QSharedPointer<Parameter>(new Parameter());\r\n            targetParameter->setName(moduleParameter->name());\r\n            targetParameter->setType(moduleParameter->getType());\r\n            targetComponent->getParameters()->append(targetParameter);\r\n        }\r\n       \r\n        targetParameter->setValue(moduleParameter->getValue());\r\n        targetParameter->setDescription(moduleParameter->description());\r\n        targetParameter->increaseUsageCount();\r\n\r\n        moduleParameter->setValue(targetParameter->getValueId());\r\n    }\r\n\r\n    foreach (QSharedPointer<Parameter> parameter, *targetComponent->getParameters())\r\n    {\r\n        replaceNameReferencesWithParameterIds(parameter, targetComponent);\r\n    }\r\n\r\n    foreach (QSharedPointer<ModuleParameter> parameter, *targetComponentInstantiation->getModuleParameters())\r\n    {\r\n        replaceNameReferencesWithParameterIds(parameter, targetComponent);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VHDLGenericParser::findParameter()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<Parameter> VHDLGenericParser::findParameter(QString const& name, \r\n    QSharedPointer<Component> component) const\r\n{\r\n    foreach (QSharedPointer<Parameter> parameter, *component->getParameters())\r\n    {\r\n        if (parameter->name().compare(name) == 0)\r\n        {\r\n            return parameter;\r\n        }\r\n    }\r\n\r\n    return QSharedPointer<Parameter>();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VHDLGenericParser::replaceParameterNamesWithIds()\r\n//-----------------------------------------------------------------------------\r\nvoid VHDLGenericParser::replaceNameReferencesWithParameterIds(QSharedPointer<Parameter> parameter,\r\n    QSharedPointer<Component> targetComponent) const\r\n{\r\n    foreach (QSharedPointer<Parameter> reference, *targetComponent->getParameters())\r\n    {\r\n        QRegularExpression referenceUsage(\"\\\\b\" + reference->name() + \"\\\\b\");\r\n\r\n        QString parameterValue = replaceNameWithId(parameter->getValue(), referenceUsage, reference);\r\n        parameter->setValue(parameterValue);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VHDLGenericParser::replaceNameWithId()\r\n//-----------------------------------------------------------------------------\r\nQString VHDLGenericParser::replaceNameWithId(QString const& expression, QRegularExpression& namePattern, \r\n    QSharedPointer<Parameter> referenced) const\r\n{\r\n    QString replaced = expression;\r\n    QRegularExpressionMatch match = namePattern.match(expression);\r\n    if (match.hasMatch())\r\n    {\r\n        replaced.replace(namePattern, referenced->getValueId());\r\n\r\n        int count = match.capturedTexts().count();\r\n        for (int i = 0; i < count; i++)\r\n        {\r\n            referenced->increaseUsageCount();\r\n        }\r\n    }\r\n\r\n    return replaced;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VHDLGenericParser::replaceNameWithId()\r\n//-----------------------------------------------------------------------------\r\nQString VHDLGenericParser::findMatchingType(QString const& dataType) const\r\n{    \r\n    QMap<QString, QString> conversionMap\r\n    {\r\n        { \"integer\", \"int\"},\r\n        { \"natural\", \"int\"},\r\n        { \"positive\", \"int\"},\r\n        { \"real\", \"real\"},\r\n        { \"bit\", \"bit\"},\r\n        { \"string\", \"string\"}\r\n    };\r\n\r\n    return conversionMap.value(dataType);\r\n}\r\n"
  },
  {
    "path": "Plugins/VHDLimport/VHDLGenericParser.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: VHDLGenericParser.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Esko Pekkarinen\r\n// Date: 16.09.2014\r\n//\r\n// Description:\r\n// Parser for VHDL generics.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef VHDLGENERICPARSER_H\r\n#define VHDLGENERICPARSER_H\r\n\r\n#include <KactusAPI/include/HighlightSource.h>\r\n\r\n#include <QSharedPointer>\r\n#include <QString>\r\n\r\n#include <IPXACTmodels/Component/ComponentInstantiation.h>\r\n\r\nclass Component;\r\nclass ModuleParameter;\r\nclass ComponentInstantiation;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Parser for VHDL generics.\r\n//-----------------------------------------------------------------------------\r\nclass VHDLGenericParser : public QObject, public HighlightSource\r\n{    \r\n    Q_OBJECT\r\npublic:\r\n\r\n\t//! The constructor.\r\n\texplicit VHDLGenericParser(QObject* parent = 0);\r\n\r\n\t//! The destructor.\r\n\tvirtual ~VHDLGenericParser() = default;\r\n\r\n    /*!\r\n     *  Runs the generic parser for the given input and adds the module parameters to the given component.\r\n     *\r\n     *    @param [in] input                           The input text to parse.\r\n     *    @param [in/out] targetComponent             The component to add the parameters to.\r\n     *    @param [in] targetComponentInstantiation    The component instantiation to add the module parameters to.\r\n     */\r\n    void import(QString const& input, QSharedPointer<Component> targetComponent,\r\n        QSharedPointer<ComponentInstantiation> targetComponentInstantiation);\r\n\r\n    /*!\r\n     *  Sets the given highlighter to be used by the generic parser.\r\n     *\r\n     *    @param [in] highlighter   The highlighter to use.          \r\n     */\r\n    virtual void setHighlighter(Highlighter* highlighter) override final;\r\n\r\nprivate:\r\n\r\n\t// Disable copying.\r\n\tVHDLGenericParser(VHDLGenericParser const& rhs);\r\n\tVHDLGenericParser& operator=(VHDLGenericParser const& rhs);\r\n\r\n    /*!\r\n     *  Finds all generic declarations from input.\r\n     *\r\n     *    @param [in] input   The input to search for generic declarations.\r\n     *\r\n     *    @return Found generic declarations.\r\n     */\r\n    QStringList findGenericDeclarations(QString const& input) const;\r\n\r\n    /*!\r\n     *  Finds the section defining the generics of an entity.\r\n     *\r\n     *    @param [in] input   The input to search for generic section.\r\n     *\r\n     *    @return The sections containing all generics in entity.\r\n     */\r\n    QString findGenericsSection(QString const& input) const;\r\n\r\n    /*!\r\n     *  Removes all comment lines from a given input.\r\n     *\r\n     *    @param [in] input   The input to remove comments from.\r\n     *\r\n     *    @return The input without comment lines.\r\n     */\r\n    QString removeCommentLines(QString section) const;\r\n    \r\n    /*!\r\n     *  Finds all generic declarations from a generics section without comment lines.\r\n     *\r\n     *    @param [in] sectionWithoutCommentLines   The section of the VHDL containing the generics in entity\r\n     *                                               without comment lines.\r\n     *\r\n     *    @return The VHDL generic declarations.\r\n     */\r\n    QStringList genericDeclarationsIn(QString const& sectionWithoutCommentLines) const;\r\n\r\n    /*!\r\n     *  Creates a module parameter from a given VHDL declaration and adds it to the target component instantiation.\r\n     *  An equivalent parameter will be added to the component.\r\n     *\r\n     *    @param [in] declaration                         The declaration from which to create a model parameter.\r\n     *    @param [in/out] targetComponentInstantiation    The component instantiation to which add the module parameter.\r\n     */\r\n    void createModelParameterFromDeclaration(QString const& declaration, \r\n        QSharedPointer<ComponentInstantiation> targetComponentInstantiation) const;\r\n\r\n    /*!\r\n     *  Finds the given module parameter.\r\n     *\r\n     *    @param [in] name                            The name of the module parameter to find.\r\n     *    @param [in] targetComponentInstantiation    The instantiation to search in.\r\n     *\r\n     *    @return The found module parameter.\r\n     */\r\n    QSharedPointer<ModuleParameter> findModuleParameter(QString const& name,\r\n        QSharedPointer<ComponentInstantiation> targetComponentInstantiation) const;\r\n\r\n    /*!\r\n     *  Replaces all name references in the module parameters to parameter id references.\r\n     *\r\n     *    @param [in] targetComponent                 The component containing the parameters.\r\n     *    @param [in] targetComponentInstantiation    The component instantiation containing the module parameters.\r\n     */\r\n    void replaceNamesReferencesWithIds(QSharedPointer<Component> targetComponent, \r\n        QSharedPointer<ComponentInstantiation> targetComponentInstantiation) const;\r\n    \r\n    /*!\r\n     *  Finds the given parameter.\r\n     *\r\n     *    @param [in] name        The name of the parameter to find.\r\n     *    @param [in] component   The component to search in.\r\n     *\r\n     *    @return The found parameter.\r\n     */\r\n    QSharedPointer<Parameter> findParameter(QString const& name, QSharedPointer<Component> component) const;\r\n    \r\n    /*!\r\n     *  Replaces all name references in the given parameter to parameter id references.\r\n     *\r\n     *    @param [in] parameter    The parameter whose references to replace.\r\n     *    @param [in] component    The component containing the referenced parameters.\r\n     */\r\n    void replaceNameReferencesWithParameterIds(QSharedPointer<Parameter> parameter,\r\n        QSharedPointer<Component> targetComponent) const;\r\n\r\n    /*!\r\n     *  Replaces the given name in the given id in the referenced parameter.\r\n     *\r\n     *    @param [in] expression      The expression to replace names in.\r\n     *    @param [in] namePattern     The pattern for the given name.\r\n     *    @param [in] referenced      The referenced parameter.\r\n     *\r\n     *    @return The expression where name references have been replaced with ids.\r\n     */\r\n    QString replaceNameWithId(QString const& expression, QRegularExpression& namePattern,\r\n        QSharedPointer<Parameter> referenced) const;\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! The highlighter to use.\r\n    Highlighter* highlighter_;\r\n    \r\n    QString findMatchingType(QString const& dataType) const;\r\n};\r\n\r\n#endif // VHDLGENERICPARSER_H\r\n"
  },
  {
    "path": "Plugins/VHDLimport/VHDLPortParser.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: VHDLPortParser.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Esko Pekkarinen\r\n// Date: 15.09.2014\r\n//\r\n// Description:\r\n// Parser for VHDL ports.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"VHDLPortParser.h\"\r\n\r\n#include \"VHDLSyntax.h\"\r\n\r\n#include <KactusAPI/include/ImportColors.h>\r\n\r\n#include <IPXACTmodels/Component/Component.h>\r\n#include <IPXACTmodels/Component/ComponentInstantiation.h>\r\n#include <IPXACTmodels/Component/Port.h>\r\n#include <IPXACTmodels/common/ModuleParameter.h>\r\n\r\n#include <QRegularExpression>\r\n\r\nnamespace\r\n{\r\n    //! VHDL port direction.\r\n    const QString DIRECTION = \"in|out|inout|buffer|linkage\";\r\n\r\n    //! VHDL vector port boundary.\r\n    const QString BOUNDARY = \"[\\\\w\\\\d )(+*/-]+\";\r\n\r\n    //! VHDL port type definition is <typename>[(<left> to/downto <right>)].\r\n    const QString PORT_TYPE = \"(?:\\\\w+)\"\r\n        \"(?:\\\\s*[(]\\\\s*(?:\" + BOUNDARY + \")\\\\s+(?:down)?to\\\\s+(?:\" + BOUNDARY + \")\\\\s*[)])?\";\r\n\r\n    /*! Port declaration is <port_names> : <direction> <type> [<default>] [pragma] ; [description]    \r\n     *  A pragma e.g. synthesis translate_off may be inserted in the declaration before the ending\r\n     *  semicolon or string's end.\r\n     */\r\n    const QRegularExpression PORT_EXP(\r\n        \"(\" + VHDLSyntax::NAMES + \")+\\\\s*[:]\\\\s*(\" + DIRECTION + \")\\\\s+(\" + PORT_TYPE + \")\" +\r\n        \"(?:\\\\s*\" + VHDLSyntax::DEFAULT + \")?(?:\\\\s*\" + VHDLSyntax::PRAGMA + \")?\"\r\n        \"(?:\" + VHDLSyntax::DECLARATION_END + \")\", QRegularExpression::CaseInsensitiveOption);\r\n\r\n    //! Ports are declared inside entity by PORT ( <port_declarations> );\r\n    const QRegularExpression PORTS_BEGIN(\"(PORT)\\\\s*[(]\", QRegularExpression::CaseInsensitiveOption);\r\n    const QRegularExpression PORTS_END(\"[)]\\\\s*[;](?=\\\\s*(((PORT\\\\s*[(])|BEGIN)|(END\\\\s+(ENTITY\\\\s+)?\\\\w+)))\",\r\n        QRegularExpression::CaseInsensitiveOption);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VHDLPortParser::VHDLPortParser()\r\n//-----------------------------------------------------------------------------\r\nVHDLPortParser::VHDLPortParser(QObject* parent): QObject(parent), highlighter_(0)\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VHDLPortParser::import()\r\n//-----------------------------------------------------------------------------\r\nvoid VHDLPortParser::import(QString const& input, QSharedPointer<Component> targetComponent,\r\n    QSharedPointer<ComponentInstantiation> /*targetComponentInstantiation*/)\r\n{\r\n    //! The existing ports are changed to phantom in order to keep the component error-free.\r\n    //! These ports can then be deleted later.\r\n    foreach (QSharedPointer<Port> existingPort, *targetComponent->getPorts())\r\n    {\r\n        existingPort->setDirection(DirectionTypes::DIRECTION_PHANTOM);\r\n    }\r\n\r\n    foreach (QString const& portDeclaration, findPortDeclarations(input))\r\n    {\r\n        createPortFromDeclaration(portDeclaration, targetComponent);\r\n        if (highlighter_)\r\n        {\r\n            highlighter_->applyHighlight(portDeclaration, ImportColors::PORT, input);\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VHDLPortParser::setHighlighter()\r\n//-----------------------------------------------------------------------------\r\nvoid VHDLPortParser::setHighlighter(Highlighter* highlighter)\r\n{\r\n    highlighter_ = highlighter;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VHDLPortParser::parsePortDeclarations()\r\n//-----------------------------------------------------------------------------\r\nQStringList VHDLPortParser::findPortDeclarations(QString const& input) const\r\n{\r\n    QString portSectionInEntity = findPortsSection(input);\r\n    QString portSectionWithoutCommentLines = removeCommentLines(portSectionInEntity);\r\n\r\n    return portDeclarationsIn(portSectionWithoutCommentLines);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VHDLPortParser::findPortsSection()\r\n//-----------------------------------------------------------------------------\r\nQString VHDLPortParser::findPortsSection(QString const& input) const\r\n{\r\n    int entityBegin = input.indexOf(VHDLSyntax::ENTITY_BEGIN_EXP);\r\n    int entityEnd = input.indexOf(VHDLSyntax::ENTITY_END_EXP, entityBegin);\r\n\r\n    int portsBeginIndex = PORTS_BEGIN.match(input, entityBegin).capturedEnd();\r\n\r\n    if (portsBeginIndex > entityEnd)\r\n    {\r\n        return QString();\r\n    }\r\n\r\n    int portsEndIndex = input.indexOf(PORTS_END, portsBeginIndex);\r\n\r\n    return input.mid(portsBeginIndex, portsEndIndex - portsBeginIndex);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VHDLPortParser::removeCommentLines()\r\n//-----------------------------------------------------------------------------\r\nQString VHDLPortParser::removeCommentLines(QString input) const\r\n{\r\n    QRegularExpression commentLine(\"^\" + VHDLSyntax::SPACE + VHDLSyntax::COMMENT_LINE_EXP + \"|\" +\r\n        VHDLSyntax::ENDLINE + VHDLSyntax::SPACE + VHDLSyntax::COMMENT_LINE_EXP);\r\n\r\n    return input.remove(commentLine);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VHDLPortParser::parsePortDeclarations()\r\n//-----------------------------------------------------------------------------\r\nQStringList VHDLPortParser::portDeclarationsIn(QString const& portSectionWithoutCommentLines) const\r\n{\r\n    QStringList portDeclarations;\r\n\r\n    QRegularExpressionMatchIterator i = PORT_EXP.globalMatch(portSectionWithoutCommentLines);\r\n    while (i.hasNext())\r\n    {\r\n        portDeclarations.append(i.next().captured());\r\n    }\r\n\r\n    return portDeclarations;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VHDLPortParser::createPort()\r\n//-----------------------------------------------------------------------------\r\nvoid VHDLPortParser::createPortFromDeclaration(QString const& declaration,\r\n    QSharedPointer<Component> targetComponent) const\r\n{\r\n    QStringList portNames = parsePortNames(declaration);\r\n    DirectionTypes::Direction direction =  parsePortDirection(declaration); \r\n    QString type = parsePortType(declaration);\r\n    QString typeDefinition;\r\n    QString defaultValue = parseDefaultValue(declaration, targetComponent);\r\n    QString description = parseDescription(declaration);\r\n\r\n    QPair<QString, QString> bounds = parsePortBounds(declaration, targetComponent);\r\n    QString leftBound = bounds.first;\r\n    QString rightBound = bounds.second;\r\n\r\n    foreach(QString const& name, portNames)\r\n    {   \r\n        QSharedPointer<Port> port;        \r\n        if (targetComponent->hasPort(name))\r\n        {\r\n            port = targetComponent->getPort(name);\r\n            typeDefinition = port->getTypeDefinition(type);\r\n        }\r\n        else\r\n        {\r\n            port = QSharedPointer<Port>(new Port());           \r\n            port->setName(name);\r\n            typeDefinition = createDefaultTypeDefinition(type);\r\n            targetComponent->getPorts()->append(port);\r\n        }\r\n\r\n        port->setDirection(direction);\r\n        port->setLeftBound(leftBound);\r\n        port->setRightBound(rightBound);\r\n        port->setTypeName(type);\r\n        port->setTypeDefinition(type, typeDefinition);\r\n        port->setDefaultValue(defaultValue);\r\n        port->setDescription(description);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VHDLPortParser::parsePortNames()\r\n//-----------------------------------------------------------------------------\r\nQStringList VHDLPortParser::parsePortNames(QString const& declaration) const\r\n{\r\n    QString portNames = PORT_EXP.match(declaration).captured(1);\r\n    return portNames.split(QRegularExpression(\"\\\\s*[,]\\\\s*\"), Qt::SkipEmptyParts);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VHDLPortParser::parsePortDirection()\r\n//-----------------------------------------------------------------------------\r\nDirectionTypes::Direction VHDLPortParser::parsePortDirection(QString const& declaration) const\r\n{\r\n    QString direction = PORT_EXP.match(declaration).captured(2).toLower();    \r\n    return DirectionTypes::str2Direction(direction, DirectionTypes::DIRECTION_INVALID);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VHDLPortParser::parsePortType()\r\n//-----------------------------------------------------------------------------\r\nQString VHDLPortParser::parsePortType(QString const& declaration) const\r\n{\r\n    QString typePattern = PORT_TYPE;\r\n    typePattern.replace(\"(?:\",\"(\");\r\n\r\n    QRegularExpression typeExpression(typePattern, QRegularExpression::CaseInsensitiveOption);    \r\n   \r\n    QString fullType = PORT_EXP.match(declaration).captured(3);\r\n    return typeExpression.match(fullType).captured(1);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VHDLPortParser::parseDescription()\r\n//-----------------------------------------------------------------------------\r\nQString VHDLPortParser::parseDescription(QString const& declaration) const\r\n{\r\n    QString description = PORT_EXP.match(declaration).captured(6).trimmed();\r\n    if (description.isEmpty())\r\n    {\r\n        description = PORT_EXP.match(declaration).captured(7).trimmed();\r\n    }\r\n\r\n    return description;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VHDLPortParser::parseDefaultValue()\r\n//-----------------------------------------------------------------------------\r\nQString VHDLPortParser::parseDefaultValue(QString const& input, QSharedPointer<Component> targetComponent) const\r\n{\r\n    return replaceNameReferencesWithIds(PORT_EXP.match(input).captured(4).trimmed(), targetComponent);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VerilogPortParser::replaceNameReferencesWithIds()\r\n//-----------------------------------------------------------------------------\r\nQString VHDLPortParser::replaceNameReferencesWithIds(QString const& expression, \r\n    QSharedPointer<Component> targetComponent) const\r\n{\r\n    QString result = expression;\r\n\r\n    foreach (QSharedPointer<Parameter> define, *targetComponent->getParameters())\r\n    {\r\n        QRegularExpression macroUsage(\"\\\\b\" + define->name() + \"\\\\b\");\r\n        if (macroUsage.match(result).hasMatch())\r\n        {\r\n            result.replace(macroUsage, define->getValueId());\r\n\r\n            for(int i = 0; i < expression.count(macroUsage); i++)\r\n            {\r\n                define->increaseUsageCount();\r\n            }\r\n        }\r\n    }\r\n\r\n    return result;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VHDLPortParser::parsePortBounds()\r\n//-----------------------------------------------------------------------------\r\nQPair<QString, QString> VHDLPortParser::parsePortBounds(QString const& declaration, \r\n    QSharedPointer<Component> targetComponent) const\r\n{\r\n    QString fullType = PORT_EXP.match(declaration).captured(3);\r\n\r\n    QString leftValue = QString();\r\n    QString rightValue = QString();\r\n\r\n    int firstParenthesis = fullType.indexOf(QLatin1Char('('));\r\n    if (firstParenthesis != -1)\r\n    {\r\n        int endParenthesis = findMatchingEndParenthesis(fullType, firstParenthesis);\r\n        QString vectorBounds = fullType.mid(firstParenthesis + 1, endParenthesis - firstParenthesis - 1);\r\n\r\n        if (!vectorBounds.isEmpty())\r\n        {\r\n            QRegularExpression splitter(QString(\"\\\\s+(down)?to\\\\s+\"), QRegularExpression::CaseInsensitiveOption);\r\n            QRegularExpressionMatch splitMatch = splitter.match(vectorBounds);\r\n            QString leftEquation = vectorBounds.left(splitMatch.capturedStart());\r\n            QString rightEquation = vectorBounds.mid(splitMatch.capturedEnd());\r\n            \r\n            leftValue = replaceNameReferencesWithIds(leftEquation, targetComponent);\r\n            rightValue = replaceNameReferencesWithIds(rightEquation, targetComponent);\r\n        }\r\n    }\r\n\r\n    return qMakePair(leftValue, rightValue);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VHDLPortParser::findMatchingEndParenthesis()\r\n//-----------------------------------------------------------------------------\r\nint VHDLPortParser::findMatchingEndParenthesis(QString const& equation, int parenthesesStart) const\r\n{\r\n    QRegularExpression parenthesesExpression(\"[()]\");\r\n\r\n    int position = parenthesesStart + 1;\r\n    int depth = 1;\r\n\r\n    while (depth > 0)\r\n    {\r\n        position = equation.indexOf(parenthesesExpression, position);\r\n        if (parenthesesExpression.match(equation.at(position)).captured() == \"(\")\r\n        {\r\n            depth++;\r\n        }\r\n        else\r\n        {\r\n            depth--;\r\n        }\r\n        position++;\r\n    }\r\n\r\n    return position - 1;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VHDLPortParser::getDefaultTypeDefinition()\r\n//-----------------------------------------------------------------------------\r\nQString VHDLPortParser::createDefaultTypeDefinition(QString const& type) const\r\n{\r\n    QRegularExpression defaultLogicTypes(\"std_(u)?logic(_vector)?\", \r\n        QRegularExpression::CaseInsensitiveOption);\r\n\r\n    QRegularExpression defaultNumericTypes(\"(un)?signed\", \r\n        QRegularExpression::CaseInsensitiveOption);\r\n\r\n    if (defaultLogicTypes.match(type).hasMatch())\r\n    {\r\n        return QStringLiteral(\"IEEE.std_logic_1164.all\");\r\n    }\r\n    else if (defaultNumericTypes.match(type).hasMatch())\r\n    {\r\n        return QStringLiteral(\"IEEE.numeric_std.all\");\r\n    }\r\n    else\r\n    {\r\n        return QString();\r\n    }\r\n}\r\n"
  },
  {
    "path": "Plugins/VHDLimport/VHDLPortParser.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: VHDLPortParser.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Esko Pekkarinen\r\n// Date: 15.09.2014\r\n//\r\n// Description:\r\n// Parser for VHDL ports.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef VHDLPORTPARSER_H\r\n#define VHDLPORTPARSER_H\r\n\r\n#include <KactusAPI/include/HighlightSource.h>\r\n\r\n#include <IPXACTmodels/common/DirectionTypes.h>\r\n\r\n#include <QList>\r\n#include <QMap>\r\n#include <QSharedPointer>\r\n#include <QString>\r\n#include <QObject>\r\n\r\nclass Component;\r\nclass ComponentInstantiation;\r\nclass Port;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Parser for VHDL ports.\r\n//-----------------------------------------------------------------------------\r\nclass VHDLPortParser : public QObject, public HighlightSource\r\n{\r\n    Q_OBJECT\r\n\r\npublic:\r\n\r\n\t/*!\r\n\t *  The constructor.\r\n\t *\r\n\t *    @param [in] parent   The parent object.\t \r\n\t */\r\n\texplicit VHDLPortParser(QObject* parent = 0);\r\n\r\n\t//! The destructor.\r\n\tvirtual ~VHDLPortParser() = default;\r\n\r\n    // Disable copying.\r\n    VHDLPortParser(VHDLPortParser const& rhs) = delete;\r\n    VHDLPortParser& operator=(VHDLPortParser const& rhs) = delete;\r\n\r\n    /*!\r\n     *  Runs the port parsing for the given input and adds the parsed ports to the given component.\r\n     *\r\n     *    @param [in] input                               The input text to parse.\r\n     *    @param [in/out] targetComponent                 The component to add all the imported ports to.\r\n     *    @param [in] targetComponentInstantiation        The component instantiation for the import.\r\n     */\r\n    virtual void import(QString const& input, QSharedPointer<Component> targetComponent,\r\n        QSharedPointer<ComponentInstantiation> targetComponentInstantiation);\r\n\r\n    /*!\r\n     *  Sets the given highlighter to be used by the port parser.\r\n     *\r\n     *    @param [in] highlighter   The highlighter to use.          \r\n     */\r\n    virtual void setHighlighter(Highlighter* highlighter);\r\n\r\nprivate:\r\n\r\n    /*!\r\n     *  Finds all port declarations from input.\r\n     *\r\n     *    @param [in] input   The input to search for port declarations.\r\n     *\r\n     *    @return Found port declarations.\r\n     */\r\n    QStringList findPortDeclarations(QString const& input) const;\r\n\r\n    /*!\r\n     *  Finds the section defining the ports of an entity.\r\n     *\r\n     *    @param [in] input   The input to search for port section.\r\n     *\r\n     *    @return The sections containing all ports in entity.\r\n     */\r\n    QString findPortsSection(QString const& input) const;\r\n\r\n    /*!\r\n     *  Removes all comment lines from a given input.\r\n     *\r\n     *    @param [in] input   The input to remove comments from.\r\n     *\r\n     *    @return The input without comment lines.\r\n     */\r\n    QString removeCommentLines(QString input) const;\r\n\r\n    /*!\r\n     *  Finds all port declarations from a ports section without comment lines.\r\n     *\r\n     *    @param [in] portSectionWithoutCommentLines   The section of the VHDL containing the ports in entity\r\n     *                                                   without comment lines.\r\n     *\r\n     *    @return The VHDL port declarations.\r\n     */\r\n    QStringList portDeclarationsIn(QString const& portSectionWithoutCommentLines) const;\r\n\r\n    /*!\r\n     *  Creates a port from a given VHDL declaration and adds it to the target component.\r\n     *\r\n     *    @param [in] declaration             The declaration from which to create a port.\r\n     *    @param [in/out] targetComponent     The component to which add the port.\r\n     */\r\n    void createPortFromDeclaration(QString const& declaration,\r\n        QSharedPointer<Component> targetComponent) const;\r\n\r\n    /*!\r\n     *  Parses the port names from a VHDL port declaration.\r\n     *\r\n     *    @param [in] declaration   The VHDL port declaration to parse.\r\n     *\r\n     *    @return The port names in the declaration.\r\n     */\r\n    QStringList parsePortNames(QString const& declaration) const;\r\n\r\n    /*!\r\n     *  Parses the port direction from a VHDL port declaration.\r\n     *\r\n     *    @param [in] declaration   The VHDL port declaration to parse.\r\n     *\r\n     *    @return The port direction in the declaration.\r\n     */\r\n    DirectionTypes::Direction parsePortDirection(QString const& declaration) const;\r\n\r\n    /*!\r\n     *  Parses the port type from a VHDL port declaration.\r\n     *\r\n     *    @param [in] declaration   The VHDL port declaration to parse.\r\n     *\r\n     *    @return The port type in the declaration.\r\n     */\r\n    QString parsePortType(QString const& declaration) const;\r\n\r\n    /*!\r\n     *  Parses the port description from a comment tailing a VHDL port declaration.\r\n     *\r\n     *    @param [in] declaration   The VHDL port declaration to parse.\r\n     *\r\n     *    @return The port description.\r\n     */\r\n    QString parseDescription(QString const& declaration) const;\r\n\r\n    /*!\r\n     *  Parses the port default value from a VHDL port declaration.\r\n     *\r\n     *    @param [in] declaration   The VHDL port declaration to parse.\r\n     *\r\n     *    @return The port default value in the declaration.\r\n     */\r\n    QString parseDefaultValue(QString const& input, QSharedPointer<Component> targetComponent) const;\r\n\r\n    /*!\r\n     *  Replaces all name references in the given expression to parameter id references.\r\n     *\r\n     *    @param [in] expression          The expression whose references to replace.\r\n     *    @param [in] targetComponent     The component containing the referenced parameters.\r\n     *\r\n     *    @return The expression with replaced references.\r\n     */\r\n    QString replaceNameReferencesWithIds(QString const& expression, QSharedPointer<Component> targetComponent) const;\r\n\r\n    /*!\r\n     *  Parses the port bounds from a VHDL port declaration.\r\n     *\r\n     *    @param [in] declaration         The VHDL port declaration to parse.\r\n     *    @param [in] targetComponent     The component to which add the port.\r\n     *\r\n     *    @return The port bounds <left, right> in the given declaration.\r\n     */\r\n    QPair<QString, QString> parsePortBounds(QString const& declaration,\r\n        QSharedPointer<Component> targetComponent) const;\r\n   \r\n    int findMatchingEndParenthesis(QString const& equation, int parenthesesStart) const;\r\n\r\n    /*!\r\n     *  Creates a default type definition for the given type.\r\n     *\r\n     *    @param [in] type   The type whose type definition to create.\r\n     *\r\n     *    @return The default type defition for the type, if any.\r\n     */\r\n    QString createDefaultTypeDefinition(QString const& type) const;\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! The highlighter to use.\r\n    Highlighter* highlighter_;\r\n};\r\n\r\n#endif // VHDLPORTPARSER_H\r\n"
  },
  {
    "path": "Plugins/VHDLimport/VHDLSyntax.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: VhdlSyntax.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Esko Pekkarinen\r\n// Date: 4.7.2013\r\n//\r\n// Description:\r\n// This file contains common elements of the VHDL language\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef VHDLSYNTAX_H\r\n#define VHDLSYNTAX_H\r\n\r\n#include <QRegularExpression>\r\n\r\nnamespace VHDLSyntax\r\n{\r\n    //! Whitespace without line end.\r\n    const QString SPACE = \"[ \\\\t]*\";    \r\n\r\n    //! Platform-independent endLine.\r\n    const QString ENDLINE = \"(?:\\\\r\\\\n?|\\\\n\\\\r?)\";\r\n\r\n    //! VHDL comment.\r\n    const QString COMMENT = \"[-][-]\" + SPACE + \"([^\\\\r\\\\n]*)(?=\" + ENDLINE + \"|$)\";\r\n   \r\n    //! VHDL port and generic names are separated using a colon (,).\r\n    const QString NAMES = \"\\\\w+(?:\\\\s*[,]?\\\\s*\\\\w+)*\";\r\n\r\n    //! Supported std_logic values.\r\n    const QString STD_ULOGIC = \"['][U|X|0|1|Z|W|L|H|-][']\";\r\n\r\n    //! Others is used to initialize a group of bits in std_logic_vector.\r\n    const QString OTHERS_EXP = \"[(]\\\\s*others\\\\s*=>\\\\s*\" + STD_ULOGIC + \"\\\\s*[)]\";\r\n  \r\n    //! Supported mathematical operators in math expressions.\r\n    const QString OPERATOR = \"[+-]|[/*]{2}|[/*/]\";\r\n\r\n    //! Mathematical terms e.g. x or x + y.\r\n    const QString TERM = \"(?:\\\\w+)(?:\\\\s*(?:\" + OPERATOR + \")\\\\s*(?:\\\\w+))*\";\r\n\r\n    //! VHDL default value definition is mathematical expression, vector assignment with others, logical value\r\n    // or other string value.\r\n    const QString DEFAULT = \"[:][=]\\\\s*((?:\" + TERM + \")|\" + OTHERS_EXP + \"|[^\\\\s:;]+)\";\r\n\r\n    //! VHDL pragmas begin like comments with -- followed by a reserved word.\r\n    const QString PRAGMA = \"[-][-]\" + SPACE + \"(?:PRAGMA|SYNTHESIS|SYNOPSYS)[^\\\\r\\\\n]*\";\r\n\r\n    //! VHDL comment line.\r\n    const QString COMMENT_LINE_EXP = SPACE + COMMENT + \"(?=\" + ENDLINE + \")\";\r\n\r\n    /*! All except the last port/generic declaration ends with a semicolon. \r\n     *  If there is a comment on the same line, it will be captured to the description by VhdlParser.\r\n     *  Additional comments may follow the last declaration before the end of the string.\r\n     */\r\n    const QString DECLARATION_END = \"(?:\\\\s*[;]\" + SPACE + \"(\" + COMMENT + \"))|\"\r\n                                    \"(?:(?=\\\\s*[;]))|\"\r\n                                    \"(?:\" + SPACE + \"(?:\" + COMMENT + \")?(?=(?:\\\\s*(?:\" + COMMENT + \")*\\\\s*)*$))\";\r\n    \r\n    //! Entity declaration is ENTITY <name> IS ... END [ENTITY] [<name>];\r\n    const QRegularExpression ENTITY_BEGIN_EXP(\"(ENTITY)\\\\s+(\\\\w+)\\\\s+(IS)\", \r\n        QRegularExpression::CaseInsensitiveOption);   \r\n    const QRegularExpression ENTITY_END_EXP(\"(END)\\\\s*(ENTITY)?\\\\s*(\\\\w+)?\\\\s*[;]\", \r\n        QRegularExpression::CaseInsensitiveOption);\r\n\r\n}\r\n\r\n#endif // VHDLSYNTAX_H\r\n"
  },
  {
    "path": "Plugins/VHDLimport/VHDLimport.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: VHDLimport.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Esko Pekkarinen\r\n// Date: 10.06.2013\r\n//\r\n// Description:\r\n// VHDLimport reads a given input, creates ports and generics accordingly\r\n// and highlights the created ports and generics. \r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"VHDLimport.h\"\r\n\r\n#include <QRegularExpression>\r\n#include <QList>\r\n\r\n#include <KactusAPI/include/ImportColors.h>\r\n\r\n#include <IPXACTmodels/Component/Component.h>\r\n#include <IPXACTmodels/common/ModuleParameter.h>\r\n#include <IPXACTmodels/Component/Port.h>\r\n#include <IPXACTmodels/Component/View.h>\r\n\r\n#include <KactusAPI/include/Highlighter.h>\r\n#include <KactusAPI/include/ModelParameterVisualizer.h>\r\n\r\n#include <common/NameGenerationPolicy.h>\r\n\r\n#include \"VHDLPortParser.h\"\r\n#include \"VHDLGenericParser.h\"\r\n\r\nnamespace\r\n{\r\n    //!  Regular expression for VHDL entity.\r\n    const QRegularExpression ENTITY_EXP(\"ENTITY\\\\s+(\\\\w+)\\\\s+IS\\\\s+.*END(?:\\\\s+ENTITY)?(?:\\\\s+\\\\1)?\\\\s*[;]\",\r\n        QRegularExpression::CaseInsensitiveOption | QRegularExpression::DotMatchesEverythingOption);\r\n\r\n    //! Regular expression for finding the name of a VHDL entity.\r\n    const QRegularExpression ENTITYNAME_EXP(\"ENTITY\\\\s+(\\\\w+)\\\\s+IS\", QRegularExpression::CaseInsensitiveOption);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VHDLimport::VHDLimport()\r\n//-----------------------------------------------------------------------------\r\nVHDLimport::VHDLimport() : QObject(0),\r\n    portParser_(new VHDLPortParser(this)),\r\n    genericParser_(new VHDLGenericParser(this)),\r\n    targetComponent_(0),        \r\n    highlighter_(0)\r\n{\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VHDLimport::~VHDLimport()\r\n//-----------------------------------------------------------------------------\r\nVHDLimport::~VHDLimport()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VHDLimport::getName()\r\n//-----------------------------------------------------------------------------\r\nQString VHDLimport::getName() const\r\n{\r\n    return tr(\"VHDL importer\");\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VHDLimport::getVersion()\r\n//-----------------------------------------------------------------------------\r\nQString VHDLimport::getVersion() const\r\n{\r\n    return QStringLiteral(\"1.2\");\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VHDLimport::getDescription()\r\n//-----------------------------------------------------------------------------\r\nQString VHDLimport::getDescription() const\r\n{\r\n    return tr(\"Imports model parameters and ports from a VHDL file.\");\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VHDLimport::getVendor()\r\n//-----------------------------------------------------------------------------\r\nQString VHDLimport::getVendor() const\r\n{\r\n    return tr(\"TUT\");\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VHDLimport::getLicense()\r\n//-----------------------------------------------------------------------------\r\nQString VHDLimport::getLicense() const\r\n{\r\n    return tr(\"GPL2\");\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VHDLimport::getLicenseHolder()\r\n//-----------------------------------------------------------------------------\r\nQString VHDLimport::getLicenseHolder() const\r\n{\r\n    return tr(\"Public\");\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VHDLimport::getSettingsWidget()\r\n//-----------------------------------------------------------------------------\r\nQWidget* VHDLimport::getSettingsWidget()\r\n{\r\n    return nullptr;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VHDLimport::getProgramRequirements()\r\n//-----------------------------------------------------------------------------\r\nQList<IPlugin::ExternalProgramRequirement> VHDLimport::getProgramRequirements()\r\n{\r\n    return QList<IPlugin::ExternalProgramRequirement>();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VHDLimport::acceptedFileTypes()\r\n//-----------------------------------------------------------------------------\r\nQStringList VHDLimport::getSupportedFileTypes() const\r\n{\r\n    QStringList filetypes;\r\n    filetypes << \"vhdlSource\" << \"vhdlSource-87\" << \"vhdlSource-93\";\r\n\r\n    return filetypes;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VHDLimport::getCompatibilityWarnings()\r\n//-----------------------------------------------------------------------------\r\nQString VHDLimport::getCompatibilityWarnings() const\r\n{\r\n    return QString();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VHDLimport::parseFile()\r\n//-----------------------------------------------------------------------------\r\nvoid VHDLimport::import(QString const& input, QString const& componentDeclaration,\r\n    QSharedPointer<Component> targetComponent)\r\n{\r\n    targetComponent_ = targetComponent;\r\n \r\n    if (hasValidEntity(input))\r\n    {\r\n        highlightEntity(componentDeclaration);\r\n\r\n\t\tQSharedPointer<ComponentInstantiation> targetComponentInstantiation = setupComponentInstantiation();\r\n        parseModelNameAndArchitecture(input, componentDeclaration, targetComponentInstantiation);\r\n\r\n        genericParser_->import(componentDeclaration, targetComponent, targetComponentInstantiation);\r\n        portParser_->import(componentDeclaration, targetComponent, targetComponentInstantiation);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VHDLimport::getFileComponents()\r\n//-----------------------------------------------------------------------------\r\nQStringList VHDLimport::getFileComponents(QString const& input) const\r\n{\r\n    QStringList fileEntities;\r\n\r\n    QRegularExpressionMatchIterator matchIterator = ENTITY_EXP.globalMatch(input);\r\n    while (matchIterator.hasNext())\r\n    {\r\n        QRegularExpressionMatch match = matchIterator.next();\r\n        if (match.hasMatch())\r\n        {\r\n            fileEntities.append(match.captured());\r\n        }\r\n    }\r\n\r\n    return fileEntities;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VHDLimport::getComponentName()\r\n//-----------------------------------------------------------------------------\r\nQString VHDLimport::getComponentName(QString const& componentDeclaration) const\r\n{\r\n    QRegularExpressionMatch match = ENTITYNAME_EXP.match(componentDeclaration);\r\n    return match.captured(1);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VHDLimport::setHighlighter()\r\n//-----------------------------------------------------------------------------\r\nvoid VHDLimport::setHighlighter(Highlighter* highlighter)\r\n{\r\n    highlighter_ = highlighter;\r\n\r\n    portParser_->setHighlighter(highlighter);\r\n    genericParser_->setHighlighter(highlighter);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VHDLimport::setModelParameterVisualizer()\r\n//-----------------------------------------------------------------------------\r\nvoid VHDLimport::setModelParameterVisualizer(ModelParameterVisualizer* visualizer)\r\n{\r\n    visualizer->registerChangeListener(this);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VHDLimport::hasValidEntity()\r\n//-----------------------------------------------------------------------------\r\nbool VHDLimport::hasValidEntity(QString const& fileContent) const\r\n{\r\n    return fileContent.count(ENTITY_EXP) > 0;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VHDLimport::highlightEntity()\r\n//-----------------------------------------------------------------------------\r\nvoid VHDLimport::highlightEntity(QString const& fileContent) const\r\n{\r\n    if (highlighter_)\r\n    {\r\n        QRegularExpressionMatch match = ENTITY_EXP.match(fileContent);\r\n        highlighter_->applyFontColor(match.captured(), Qt::black);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VHDLimport::parseModelNameAndArchitecture()\r\n//-----------------------------------------------------------------------------\r\nvoid VHDLimport::parseModelNameAndArchitecture(QString const& input, QString const& componentDeclaration,\r\n    QSharedPointer<ComponentInstantiation> targetInstantiation) const\r\n{\r\n    QRegularExpressionMatch match = ENTITY_EXP.match(componentDeclaration);\r\n    QString entityName = match.captured(1);\r\n\r\n    QRegularExpression architectureExp(\"ARCHITECTURE\\\\s+((\\\\w+)\\\\s+OF\\\\s+(\" + entityName + \"))\\\\s+IS(?=\\\\s+)\", \r\n        QRegularExpression::CaseInsensitiveOption);\r\n\r\n    QRegularExpression configurationExp(\"CONFIGURATION\\\\s+((\\\\w+)\\\\s+OF\\\\s+\" + entityName + \")\\\\s+IS(?=\\\\s+)\", \r\n        QRegularExpression::CaseInsensitiveOption);\r\n\r\n    QRegularExpressionMatch architectureMatch = architectureExp.match(input);\r\n    QRegularExpressionMatch configurationMatch = configurationExp.match(input);\r\n\r\n    QString modelName = entityName;\r\n    QString architecture = QString();\r\n\r\n    if (architectureMatch.hasMatch())\r\n    {\r\n        architecture = architectureMatch.captured(2);\r\n        modelName = architectureMatch.captured(3);        \r\n        highlightArchitecture(architectureMatch);\r\n    }\r\n    else if(configurationMatch.hasMatch())\r\n    {\r\n        modelName = configurationMatch.captured(2);\r\n        highlightConfiguration(configurationMatch);\r\n    }\r\n\r\n    targetInstantiation->setModuleName(modelName); \r\n    targetInstantiation->setArchitectureName(architecture);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VHDLimport::highlightArchitecture()\r\n//-----------------------------------------------------------------------------\r\nvoid VHDLimport::highlightArchitecture(QRegularExpressionMatch const& architectureExp) const\r\n{\r\n    if (highlighter_)\r\n    {\r\n        highlighter_->applyFontColor(architectureExp.captured(0), Qt::black);\r\n        highlighter_->applyHighlight(architectureExp.captured(1), ImportColors::VIEWNAME);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VHDLimport::highlightConfiguration()\r\n//-----------------------------------------------------------------------------\r\nvoid VHDLimport::highlightConfiguration(QRegularExpressionMatch const& configurationExp) const\r\n{\r\n    if (highlighter_)\r\n    {\r\n        highlighter_->applyFontColor(configurationExp.captured(0), Qt::black);\r\n        highlighter_->applyHighlight(configurationExp.captured(2), ImportColors::VIEWNAME);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VHDLimport::findOrCreateFlatView()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<View> VHDLimport::findOrCreateFlatView() const\r\n{\r\n    QStringList flatViews = targetComponent_->getFlatViews();\r\n    if (flatViews.isEmpty())\r\n    {\r\n\t\tQSharedPointer<View> newView(new View());\r\n\t\tnewView->setName(NameGenerationPolicy::flatViewName(\"vhdl\"));\r\n\t\ttargetComponent_->getViews()->append(newView);\r\n\r\n\t\tflatViews.append(newView->name());\r\n    }\r\n\r\n    return targetComponent_->getModel()->findView(flatViews.first());\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VHDLimport::setupComponentInstantiation()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<ComponentInstantiation> VHDLimport::setupComponentInstantiation() const\r\n{\r\n    QSharedPointer<View> rtlView = findOrCreateFlatView();\r\n\r\n\t// Create environment identifiers for the view as needed.\r\n\tQSharedPointer<View::EnvironmentIdentifier> importIdentifier(new View::EnvironmentIdentifier);\r\n\timportIdentifier->language = QStringLiteral(\"VHDL\");\r\n\timportIdentifier->tool = QStringLiteral(\"Kactus2\");\r\n\r\n\tif (!rtlView->hasEnvIdentifier(importIdentifier))\r\n\t{\r\n\t\trtlView->getEnvIdentifiers()->append(importIdentifier);\r\n\t}\r\n\r\n\t// Must have a component instantiation for module parameters.\r\n\tQString instanceName = NameGenerationPolicy::componentInstantiationName(\"vhdl\");\r\n\tQSharedPointer<ComponentInstantiation> targetComponentInstantiation =\r\n\t\ttargetComponent_->getModel()->findComponentInstantiation(instanceName);\r\n\r\n\t// Create and add to the component if does not exist.\r\n\tif (!targetComponentInstantiation)\r\n\t{\r\n\t\ttargetComponentInstantiation = QSharedPointer<ComponentInstantiation>(new ComponentInstantiation());\r\n\t\ttargetComponentInstantiation->setName(instanceName);\r\n\t\ttargetComponentInstantiation->setLanguage(\"VHDL\");\r\n\r\n\t\ttargetComponent_->getComponentInstantiations()->append(targetComponentInstantiation);\r\n\t}\r\n\r\n\trtlView->setComponentInstantiationRef(instanceName);\r\n\r\n\treturn targetComponentInstantiation;\r\n}\r\n"
  },
  {
    "path": "Plugins/VHDLimport/VHDLimport.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: VHDLimport.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Esko Pekkarinen\r\n// Date: 10.06.2013\r\n//\r\n// Description:\r\n// VHDLimport reads a given input, creates ports and generics accordingly\r\n// and highlights the created ports and generics. \r\n//-----------------------------------------------------------------------------\r\n#ifndef VHDLIMPORT_H\r\n#define VHDLIMPORT_H\r\n\r\n#include \"vhdlimport_global.h\"\r\n\r\n#include <KactusAPI/include/IPlugin.h>\r\n#include <KactusAPI/include/ImportPlugin.h>\r\n#include <KactusAPI/include/HighlightSource.h>\r\n#include <KactusAPI/include/ModelParameterSource.h>\r\n\r\n#include \"IPXACTmodels/Component/ComponentInstantiation.h\"\r\n\r\n#include <QList>\r\n#include <QMap>\r\n#include <QtPlugin>\r\n#include <QRegularExpressionMatch>\r\n\r\nclass Highlighter;\r\nclass ModuleParameter;\r\nclass ModelParameterVisualizer;\r\nclass Port;\r\nclass PortVisualizer;\r\nclass VHDLPortParser;\r\nclass VHDLGenericParser;\r\nclass View;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Class VHDLimport.\r\n//-----------------------------------------------------------------------------\r\nclass VHDLIMPORT_EXPORT VHDLimport : public QObject, public ImportPlugin, public HighlightSource, \r\n    public ModelParameterSource\r\n{\r\n    Q_OBJECT\r\n    Q_PLUGIN_METADATA(IID \"kactus2.plugins.vhdlimportplugin\" FILE \"vhdlimportplugin.json\")\r\n    Q_INTERFACES(IPlugin)\r\n    Q_INTERFACES(ImportPlugin)\r\n\r\npublic:\r\n\r\n    /*!\r\n     * The constructor.\r\n     */\r\n    VHDLimport();\r\n\r\n    /*!\r\n     *  Destructor.\r\n     */\r\n    ~VHDLimport();\r\n    \r\n    /*!\r\n     *  Returns the name of the plugin.\r\n     */\r\n    virtual QString getName() const;\r\n\r\n    /*!\r\n     *  Returns the version of the plugin.\r\n     */\r\n    virtual QString getVersion() const;\r\n    \r\n    /*!\r\n     *  Returns the description of the plugin.\r\n     */\r\n    virtual QString getDescription() const;\r\n  \r\n    /*!\r\n     *  Returns the vendor of the plugin.\r\n     */\r\n    virtual QString getVendor() const;\r\n    \r\n    /*!\r\n     *  Returns the license of the plugin.\r\n     */\r\n    virtual QString getLicense() const;\r\n    \r\n    /*!\r\n     *  Returns the license holder of the plugin.\r\n     */\r\n    virtual QString getLicenseHolder() const;\r\n    \r\n    /*!\r\n     *  Returns the settings widget.\r\n     */\r\n    virtual QWidget* getSettingsWidget();\r\n\r\n    /*!\r\n     *  This is used to access the settings modified by function getSettingsWidget().\r\n     */\r\n    virtual PluginSettingsModel* getSettingsModel(){return NULL;}\r\n\r\n    /*! \r\n     *   Returns the external program requirements of the plugin.\r\n     */\r\n    virtual QList<ExternalProgramRequirement> getProgramRequirements();\r\n    \r\n    /*!\r\n     *  Returns the supported import file types.\r\n     *\r\n     *    @return The file types the import parser supports.\r\n     */\r\n    virtual QStringList getSupportedFileTypes() const;\r\n\r\n    /*!\r\n     *  Gets any compatibility warnings for the plugin.\r\n     *\r\n     *    @return The warning text.\r\n     */\r\n    virtual QString getCompatibilityWarnings() const;\r\n\r\n    /*!\r\n     *   Parses a vhdl input, sets up an rtl view and creates generics and ports.\r\n     *\r\n     *    @param [in] input                   The input text to parse.\r\n     *    @param [in] componentDeclaration    Declaration of the selected entity.\r\n     *    @param [in] targetComponent         The component to apply all imported changes to.\r\n     */\r\n    virtual void import(QString const& input, QString const& componentDeclaration,\r\n        QSharedPointer<Component> targetComponent) override final;\r\n\r\n    /*!\r\n     *  Sets the given highlighter to be used by the import.\r\n     *\r\n     *    @param [in] highlighter   The highlighter to use.          \r\n     */\r\n    virtual void setHighlighter(Highlighter* highlighter);\r\n        \r\n    /*!\r\n     *  Sets the given visualizer to be used by the import.\r\n     *\r\n     *    @param [in] visualizer   The visualizer to use.          \r\n     */\r\n    virtual void setModelParameterVisualizer(ModelParameterVisualizer* visualizer);\r\n\r\n    /*!\r\n     *  Get component declarations from the selected input file.\r\n     *\r\n     *    @param [in] input   The selected input file.\r\n     *\r\n     *    @return List of component declarations found in the selected input.\r\n     */\r\n    virtual QStringList getFileComponents(QString const& input) const override final;\r\n\r\n    /*!\r\n     *  Get the name of the selected component declaration.\r\n     *\r\n     *    @param [in] componentDeclaration    The selected component declaration.\r\n     *\r\n     *    @return Name of the selected component declaration.\r\n     */\r\n    virtual QString getComponentName(QString const& componentDeclaration) const override final;\r\n\r\nprivate:\r\n\r\n    //! No copying.\r\n    VHDLimport(const VHDLimport&);\r\n\r\n    //! No assignment.\r\n    VHDLimport& operator=(const VHDLimport&);\r\n\r\n\r\n    /*!\r\n     *   Checks if given vhdl file has a valid entity declaration.\r\n     *\r\n     *    @param [in] fileString The vhdl file as string.\r\n\t *\r\n\t *    @return True if the file has a valid entity, otherwise false.\r\n     */\r\n    bool hasValidEntity(QString const& fileContent) const;\r\n\r\n    /*!\r\n     *  Highlights the entity section in the input.\r\n     *\r\n     *    @param [in] fileContent   The input file content to highlight entity in.\r\n     */\r\n    void highlightEntity(QString const& fileContent) const;\r\n    \r\n    /*!\r\n     *  Parses the model name and architecture name from the input and sets it in the rtl view.\r\n     *\r\n     *    @param [in] input                       The input text to parse the model name from.\r\n     *    @param [in/out] targetInstantiation     The instantiation to set the names in.\r\n     */\r\n    void parseModelNameAndArchitecture(QString const& input, QString const& componentDeclaration,\r\n        QSharedPointer<ComponentInstantiation> targetInstantiation) const;\r\n\r\n    /*!\r\n     *  Highlights the architecture from which the model name was created.\r\n     *\r\n     *    @param [in] architectureExp   Regular expression for capturing architecture.\r\n     */\r\n    void highlightArchitecture(QRegularExpressionMatch const& architectureExp) const;\r\n\r\n    /*!\r\n     *  Highlights the configuration from which the model name was created.\r\n     *\r\n     *    @param [in] configurationExp   Regular expression for capturing configuration.\r\n     */\r\n    void highlightConfiguration(QRegularExpressionMatch const& configurationExp) const;\r\n\r\n    /*!\r\n     *  Setup the component instantiation and sets the language and environmental identifiers in the rtl view.\r\n     */\r\n    QSharedPointer<ComponentInstantiation> setupComponentInstantiation() const;\r\n\r\n    /*!\r\n     *  Finds a flat (rtl) view from the target component or creates one, if none are found.\r\n     *\r\n     *    @return Flat view to set up with model name and environmental identifiers.\r\n     */\r\n    QSharedPointer<View> findOrCreateFlatView() const;\r\n\r\n\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! Parser for ports.\r\n    VHDLPortParser* portParser_;\r\n\r\n    //! Parser for generics.\r\n    VHDLGenericParser* genericParser_;\r\n\r\n    //! The component to which add all parsed elements.\r\n    QSharedPointer<Component> targetComponent_;\r\n\r\n    //! The highlighter to use.\r\n    Highlighter* highlighter_;\r\n\r\n    //! Maps a generic to ports depending on it.\r\n    QMap< QSharedPointer<ModuleParameter>, QList< QSharedPointer<Port> > > dependedGenerics_;\r\n\r\n    //! All parsed ports and their declarations in the source file.\r\n    QMap<QSharedPointer<Port>, QString> parsedPortDeclarations_;\r\n};\r\n\r\n#endif // VHDLIMPORT_H\r\n"
  },
  {
    "path": "Plugins/VHDLimport/VHDLimport.pri",
    "content": "# ----------------------------------------------------\r\n# This file is generated by the Qt Visual Studio Tools.\r\n# ------------------------------------------------------\r\n\r\nHEADERS += ../../common/NameGenerationPolicy.h \\\r\n    ./VHDLSyntax.h \\\r\n    ./vhdlimport_global.h \\\r\n    ./VHDLimport.h \\\r\n    ./VHDLPortParser.h \\\r\n    ./VHDLGenericParser.h\r\nSOURCES += ../../common/NameGenerationPolicy.cpp \\\r\n    ./VHDLGenericParser.cpp \\\r\n    ./VHDLimport.cpp \\\r\n    ./VHDLPortParser.cpp\r\n"
  },
  {
    "path": "Plugins/VHDLimport/VHDLimport.pro",
    "content": "# ----------------------------------------------------\r\n# This file is generated by the Qt Visual Studio Add-in.\r\n# ------------------------------------------------------\r\n\r\nTEMPLATE = lib\r\n\r\nQT += core xml widgets gui\r\nCONFIG += c++11\r\n\r\nDEFINES += VHDLIMPORT_LIB\r\n\r\nINCLUDEPATH += ./GeneratedFiles \\\r\n    . \\\r\n    ./../..\r\n\r\nCONFIG(debug, debug|release) {\r\n    # debug mode\r\n    LIBS += \\\r\n        -L../../executable -lIPXACTmodelsd\r\n\r\n    MOC_DIR += ./GeneratedFiles/Debug\r\n    OBJECTS_DIR += Debug\r\n    TARGET = VHDLimportd\r\n\r\n} else {\r\n    # release mode \r\n    LIBS += \\\r\n        -L../../executable -lIPXACTmodels\r\n    \r\n    MOC_DIR += ./GeneratedFiles/Release\r\n    OBJECTS_DIR += Release\r\n    TARGET = VHDLimport\r\n}\r\n\r\nDESTDIR = ../../executable/Plugins\r\n\r\nDEPENDPATH += .\r\nUI_DIR += ./GeneratedFiles\r\nRCC_DIR += ./GeneratedFiles\r\n\r\ninclude(VHDLimport.pri)\r\n\r\ntarget.path = $$plugin_path\r\nINSTALLS += target\r\n"
  },
  {
    "path": "Plugins/VHDLimport/VHDLimport.vcxproj",
    "content": "﻿<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n<Project DefaultTargets=\"Build\" ToolsVersion=\"15.0\" xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">\r\n  <ItemGroup Label=\"ProjectConfigurations\">\r\n    <ProjectConfiguration Include=\"Debug|x64\">\r\n      <Configuration>Debug</Configuration>\r\n      <Platform>x64</Platform>\r\n    </ProjectConfiguration>\r\n    <ProjectConfiguration Include=\"Release|x64\">\r\n      <Configuration>Release</Configuration>\r\n      <Platform>x64</Platform>\r\n    </ProjectConfiguration>\r\n  </ItemGroup>\r\n  <PropertyGroup Label=\"Globals\">\r\n    <ProjectGuid>{939C5230-35C3-455B-98F6-51E47E9E3DBB}</ProjectGuid>\r\n    <Keyword>QtVS_v304</Keyword>\r\n    <WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>\r\n    <QtMsBuild Condition=\"'$(QtMsBuild)'=='' or !Exists('$(QtMsBuild)\\qt.targets')\">$(MSBuildProjectDirectory)\\QtMsBuild</QtMsBuild>\r\n  </PropertyGroup>\r\n  <Import Project=\"$(VCTargetsPath)\\Microsoft.Cpp.Default.props\" />\r\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\" Label=\"Configuration\">\r\n    <ConfigurationType>DynamicLibrary</ConfigurationType>\r\n    <PlatformToolset>v143</PlatformToolset>\r\n  </PropertyGroup>\r\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\" Label=\"Configuration\">\r\n    <ConfigurationType>DynamicLibrary</ConfigurationType>\r\n    <PlatformToolset>v143</PlatformToolset>\r\n  </PropertyGroup>\r\n  <Import Project=\"$(VCTargetsPath)\\Microsoft.Cpp.props\" />\r\n  <Target Name=\"QtMsBuildNotFound\" BeforeTargets=\"CustomBuild;ClCompile\" Condition=\"!Exists('$(QtMsBuild)\\qt.targets') or !Exists('$(QtMsBuild)\\qt.props')\">\r\n    <Message Importance=\"High\" Text=\"QtMsBuild: could not locate qt.targets, qt.props; project may not build correctly.\" />\r\n  </Target>\r\n  <ImportGroup Label=\"ExtensionSettings\">\r\n  </ImportGroup>\r\n  <ImportGroup Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\" Label=\"PropertySheets\">\r\n    <Import Project=\"$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props\" Condition=\"exists('$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props')\" Label=\"LocalAppDataPlatform\" />\r\n  </ImportGroup>\r\n  <ImportGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\" Label=\"PropertySheets\">\r\n    <Import Project=\"$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props\" Condition=\"exists('$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props')\" Label=\"LocalAppDataPlatform\" />\r\n  </ImportGroup>\r\n  <PropertyGroup Label=\"UserMacros\" />\r\n  <ImportGroup Condition=\"Exists('$(QtMsBuild)\\qt_defaults.props')\">\r\n    <Import Project=\"$(QtMsBuild)\\qt_defaults.props\" />\r\n  </ImportGroup>\r\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n    <OutDir>$(SolutionDir)executable\\Plugins\\</OutDir>\r\n  </PropertyGroup>\r\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n    <OutDir>$(SolutionDir)executable\\Plugins\\</OutDir>\r\n  </PropertyGroup>\r\n  <PropertyGroup Label=\"QtSettings\" Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n    <QtInstall>6.2.4</QtInstall>\r\n    <QtModules>core;gui;widgets;xml</QtModules>\r\n  </PropertyGroup>\r\n  <PropertyGroup Label=\"QtSettings\" Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n    <QtInstall>6.2.4</QtInstall>\r\n    <QtModules>core;gui;widgets;xml</QtModules>\r\n  </PropertyGroup>\r\n  <ImportGroup Condition=\"Exists('$(QtMsBuild)\\qt.props')\">\r\n    <Import Project=\"$(QtMsBuild)\\qt.props\" />\r\n  </ImportGroup>\r\n  <PropertyGroup>\r\n    <_ProjectFileVersion>10.0.40219.1</_ProjectFileVersion>\r\n  </PropertyGroup>\r\n  <ItemDefinitionGroup Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n    <ClCompile>\r\n      <PreprocessorDefinitions>UNICODE;VHDLIMPORT_LIB;WIN32;WIN64;%(PreprocessorDefinitions)</PreprocessorDefinitions>\r\n      <AdditionalIncludeDirectories>.\\GeneratedFiles\\$(ConfigurationName);.\\GeneratedFiles;.;.\\..\\..;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\r\n      <Optimization>Disabled</Optimization>\r\n      <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>\r\n      <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>\r\n      <TreatWChar_tAsBuiltInType>true</TreatWChar_tAsBuiltInType>\r\n      <MultiProcessorCompilation>true</MultiProcessorCompilation>\r\n      <LanguageStandard>stdcpp17</LanguageStandard>\r\n      <AdditionalOptions>/Zc:__cplusplus %(AdditionalOptions)</AdditionalOptions>\r\n    </ClCompile>\r\n    <Link>\r\n      <SubSystem>Windows</SubSystem>\r\n      <OutputFile>$(OutDir)\\$(ProjectName).dll</OutputFile>\r\n      <AdditionalLibraryDirectories>..\\..\\executable;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>\r\n      <GenerateDebugInformation>true</GenerateDebugInformation>\r\n      <AdditionalDependencies>IPXACTmodelsd.lib;%(AdditionalDependencies)</AdditionalDependencies>\r\n      <TargetMachine>MachineX64</TargetMachine>\r\n      <AdditionalOptions> /SUBSYSTEM:WINDOWS</AdditionalOptions>\r\n    </Link>\r\n    <QtMoc>\r\n      <ExecutionDescription>Moc'ing %(Identity)...</ExecutionDescription>\r\n      <DynamicSource>output</DynamicSource>\r\n      <QtMocDir>.\\GeneratedFiles\\$(ConfigurationName)</QtMocDir>\r\n      <QtMocFileName>moc_%(Filename).cpp</QtMocFileName>\r\n    </QtMoc>\r\n  </ItemDefinitionGroup>\r\n  <ItemDefinitionGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n    <ClCompile>\r\n      <PreprocessorDefinitions>NDEBUG;QT_NO_DEBUG;UNICODE;VHDLIMPORT_LIB;WIN32;WIN64;%(PreprocessorDefinitions)</PreprocessorDefinitions>\r\n      <AdditionalIncludeDirectories>.\\GeneratedFiles\\$(ConfigurationName);.\\GeneratedFiles;.\\..\\..;.;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\r\n      <DebugInformationFormat>\r\n      </DebugInformationFormat>\r\n      <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>\r\n      <TreatWChar_tAsBuiltInType>true</TreatWChar_tAsBuiltInType>\r\n      <MultiProcessorCompilation>true</MultiProcessorCompilation>\r\n      <AdditionalOptions>/Zc:__cplusplus %(AdditionalOptions)</AdditionalOptions>\r\n      <LanguageStandard>stdcpp17</LanguageStandard>\r\n    </ClCompile>\r\n    <Link>\r\n      <SubSystem>Windows</SubSystem>\r\n      <OutputFile>$(OutDir)\\$(ProjectName).dll</OutputFile>\r\n      <AdditionalLibraryDirectories>..\\..\\executable;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>\r\n      <GenerateDebugInformation>false</GenerateDebugInformation>\r\n      <AdditionalDependencies>IPXACTmodels.lib;%(AdditionalDependencies)</AdditionalDependencies>\r\n      <TargetMachine>MachineX64</TargetMachine>\r\n      <AdditionalOptions> /SUBSYSTEM:WINDOWS</AdditionalOptions>\r\n    </Link>\r\n    <QtMoc>\r\n      <ExecutionDescription>Moc'ing %(Identity)...</ExecutionDescription>\r\n      <DynamicSource>output</DynamicSource>\r\n      <QtMocDir>.\\GeneratedFiles\\$(ConfigurationName)</QtMocDir>\r\n      <QtMocFileName>moc_%(Filename).cpp</QtMocFileName>\r\n    </QtMoc>\r\n  </ItemDefinitionGroup>\r\n  <ItemGroup>\r\n    <ClInclude Include=\"..\\..\\common\\NameGenerationPolicy.h\" />\r\n    <ClInclude Include=\"VHDLSyntax.h\" />\r\n    <QtMoc Include=\"VHDLimport.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"VHDLPortParser.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"VHDLGenericParser.h\">\r\n    </QtMoc>\r\n    <ClInclude Include=\"vhdlimport_global.h\" />\r\n  </ItemGroup>\r\n  <ItemGroup>\r\n    <ClCompile Include=\"..\\..\\common\\NameGenerationPolicy.cpp\" />\r\n    <ClCompile Include=\"VHDLGenericParser.cpp\" />\r\n    <ClCompile Include=\"VHDLimport.cpp\" />\r\n    <ClCompile Include=\"VHDLPortParser.cpp\" />\r\n  </ItemGroup>\r\n  <Import Project=\"$(VCTargetsPath)\\Microsoft.Cpp.targets\" />\r\n  <ImportGroup Condition=\"Exists('$(QtMsBuild)\\qt.targets')\">\r\n    <Import Project=\"$(QtMsBuild)\\qt.targets\" />\r\n  </ImportGroup>\r\n  <ImportGroup Label=\"ExtensionTargets\">\r\n  </ImportGroup>\r\n  <ProjectExtensions>\r\n    <VisualStudio>\r\n      <UserProperties />\r\n    </VisualStudio>\r\n  </ProjectExtensions>\r\n</Project>"
  },
  {
    "path": "Plugins/VHDLimport/VHDLimport.vcxproj.filters",
    "content": "﻿<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n<Project ToolsVersion=\"4.0\" xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">\r\n  <ItemGroup>\r\n    <Filter Include=\"Source Files\">\r\n      <UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>\r\n      <Extensions>cpp;cxx;c;def</Extensions>\r\n    </Filter>\r\n    <Filter Include=\"Header Files\">\r\n      <UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>\r\n      <Extensions>h</Extensions>\r\n    </Filter>\r\n    <Filter Include=\"Form Files\">\r\n      <UniqueIdentifier>{99349809-55BA-4b9d-BF79-8FDBB0286EB3}</UniqueIdentifier>\r\n      <Extensions>ui</Extensions>\r\n    </Filter>\r\n    <Filter Include=\"Resource Files\">\r\n      <UniqueIdentifier>{D9D6E242-F8AF-46E4-B9FD-80ECBC20BA3E}</UniqueIdentifier>\r\n      <Extensions>qrc;*</Extensions>\r\n      <ParseFiles>false</ParseFiles>\r\n    </Filter>\r\n    <Filter Include=\"Generated Files\">\r\n      <UniqueIdentifier>{71ED8ED8-ACB9-4CE9-BBE1-E00B30144E11}</UniqueIdentifier>\r\n      <Extensions>moc;h;cpp</Extensions>\r\n      <SourceControlFiles>False</SourceControlFiles>\r\n    </Filter>\r\n    <Filter Include=\"Generated Files\\Debug\">\r\n      <UniqueIdentifier>{284d6905-e11a-4c6e-9ac3-7f48e584e1ce}</UniqueIdentifier>\r\n      <Extensions>cpp;moc</Extensions>\r\n      <SourceControlFiles>False</SourceControlFiles>\r\n    </Filter>\r\n    <Filter Include=\"Generated Files\\Release\">\r\n      <UniqueIdentifier>{38a3ae0b-c33d-4d03-a754-8604aa3f6f80}</UniqueIdentifier>\r\n      <Extensions>cpp;moc</Extensions>\r\n      <SourceControlFiles>False</SourceControlFiles>\r\n    </Filter>\r\n  </ItemGroup>\r\n  <ItemGroup>\r\n    <ClInclude Include=\"vhdlimport_global.h\">\r\n      <Filter>Header Files</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"VHDLSyntax.h\">\r\n      <Filter>Header Files</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\common\\NameGenerationPolicy.h\">\r\n      <Filter>Header Files</Filter>\r\n    </ClInclude>\r\n  </ItemGroup>\r\n  <ItemGroup>\r\n    <ClCompile Include=\"VHDLGenericParser.cpp\">\r\n      <Filter>Source Files</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"VHDLPortParser.cpp\">\r\n      <Filter>Source Files</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"VHDLimport.cpp\">\r\n      <Filter>Source Files</Filter>\r\n    </ClCompile>\r\n    \r\n    \r\n    \r\n    \r\n    \r\n    \r\n    <ClCompile Include=\"..\\..\\common\\NameGenerationPolicy.cpp\">\r\n      <Filter>Source Files</Filter>\r\n    </ClCompile>\r\n  </ItemGroup>\r\n  <ItemGroup>\r\n    <QtMoc Include=\"VHDLGenericParser.h\">\r\n      <Filter>Header Files</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"VHDLPortParser.h\">\r\n      <Filter>Header Files</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"VHDLimport.h\">\r\n      <Filter>Header Files</Filter>\r\n    </QtMoc>\r\n  </ItemGroup>\r\n</Project>"
  },
  {
    "path": "Plugins/VHDLimport/vhdlimport_global.h",
    "content": "#ifndef VHDLIMPORT_GLOBAL_H\r\n#define VHDLIMPORT_GLOBAL_H\r\n\r\n#include <QtCore/qglobal.h>\r\n\r\n#ifdef VHDLIMPORT_LIB\r\n# define VHDLIMPORT_EXPORT Q_DECL_EXPORT\r\n#else\r\n# define VHDLIMPORT_EXPORT Q_DECL_IMPORT\r\n#endif\r\n\r\n#endif // VHDLIMPORT_GLOBAL_H\r\n"
  },
  {
    "path": "Plugins/VHDLimport/vhdlimportplugin.json",
    "content": "{\r\n\t\"Keys\": [ \"VHDL import Plugin\" ]\r\n}"
  },
  {
    "path": "Plugins/VerilogGenerator/CommentWriter/CommentWriter.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: CommentWriter.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Esko Pekkarinen\r\n// Date: 08.08.2014\r\n//\r\n// Description:\r\n// Class for writing C/Verilog comments.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"CommentWriter.h\"\r\n\r\n#include <QStringList>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: CommentWriter::CommentWriter()\r\n//-----------------------------------------------------------------------------\r\nCommentWriter::CommentWriter(QString const& comment): comment_(comment), \r\n    lineLength_(DEFAULT_LINE_LENGHT), \r\n    indentSize_(0)\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: CommentWriter::~CommentWriter()\r\n//-----------------------------------------------------------------------------\r\nCommentWriter::~CommentWriter()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: CommentWriter::write()\r\n//-----------------------------------------------------------------------------\r\nvoid CommentWriter::write(QTextStream& output) const\r\n{\r\n    if (nothingToWrite())\r\n    {\r\n        return;\r\n    }\r\n\r\n    QString indent = QString(\" \").repeated(indentSize_);\r\n\r\n    for (QString line : comment_.split(\"\\n\", Qt::KeepEmptyParts))\r\n    {\r\n        do\r\n        {\r\n            auto lineEnd = line.length();\r\n\r\n            if (line.length() > lineLength_ && line.lastIndexOf(\" \", lineLength_) != -1)\r\n            {\r\n                lineEnd = line.lastIndexOf(\" \", lineLength_);\r\n            }\r\n            else if (line.length() > lineLength_ && line.indexOf(\" \", lineLength_) != -1)\r\n            {\r\n                lineEnd = line.indexOf(\" \", lineLength_);\r\n            }\r\n            \r\n            output << indent << \"// \" << line.left(lineEnd) << Qt::endl;\r\n            line = line.remove(0, lineEnd + 1);\r\n        } while (line.length() > 0);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: CommentWriter::nothingToWrite()\r\n//-----------------------------------------------------------------------------\r\nbool CommentWriter::nothingToWrite() const\r\n{\r\n    return comment_.isEmpty();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: CommentWriter::setLineLength()\r\n//-----------------------------------------------------------------------------\r\nvoid CommentWriter::setLineLength(int maxLength)\r\n{\r\n    lineLength_ = maxLength;        \r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: CommentWriter::setIndent()\r\n//-----------------------------------------------------------------------------\r\nvoid CommentWriter::setIndent(int size)\r\n{\r\n    indentSize_ = size;\r\n}\r\n"
  },
  {
    "path": "Plugins/VerilogGenerator/CommentWriter/CommentWriter.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: CommentWriter.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Esko Pekkarinen\r\n// Date: 08.08.2014\r\n//\r\n// Description:\r\n// Class for writing C/Verilog comments.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef COMMENTWRITER_H\r\n#define COMMENTWRITER_H\r\n\r\n#include \"../common/Writer.h\"\r\n#include \"../veriloggeneratorplugin_global.h\"\r\n\r\n#include <QTextStream>\r\n#include <QString>\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Class for writing C/Verilog comments.\r\n//-----------------------------------------------------------------------------\r\nclass VERILOGGENERATORPLUGIN_EXPORT CommentWriter : public Writer\r\n{\r\npublic:\r\n    //! Default number of characters per comment line.\r\n    static const int DEFAULT_LINE_LENGHT = 80;\r\n\r\n\t//! The constructor.\r\n\tCommentWriter(QString const& comment);\r\n\r\n\t//! The destructor.\r\n\tvirtual ~CommentWriter();\r\n\r\n    /*!\r\n     *  Writes the comment to the given output.\r\n     *\r\n     *    @param [in] output   The output to write to.\r\n     */\r\n    virtual void write(QTextStream& output) const;\r\n\r\n    /*!\r\n     *  Sets the maximum number of characters per line.\r\n     *\r\n     *    @param [in] maxLength   The maximum number of characters to set.\r\n     */\r\n    void setLineLength(int maxLength);\r\n\r\n    /*!\r\n     *  Sets the indent for each line.\r\n     *\r\n     *    @param [in] size   The number of spaces used for indent.\r\n     */\r\n    void setIndent(int size);\r\n\r\nprivate:\r\n\r\n\t// Disable copying.\r\n\tCommentWriter(CommentWriter const& rhs);\r\n\tCommentWriter& operator=(CommentWriter const& rhs);\r\n    \r\n    /*!\r\n     *  Checks if the writer should write nothing.\r\n     *\r\n     *    @return True, if the writer has nothing to write, otherwise false.\r\n     */\r\n    bool nothingToWrite() const;\r\n    \r\n    //! The comment to write.\r\n    QString comment_;\r\n\r\n    //! The maximum length of each line.\r\n    int lineLength_;\r\n\r\n    //! The number of indenting spaces.\r\n    int indentSize_;\r\n};\r\n\r\n#endif // COMMENTWRITER_H\r\n"
  },
  {
    "path": "Plugins/VerilogGenerator/ComponentInstanceVerilogWriter/ComponentInstanceVerilogWriter.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ComponentInstanceVerilogWriter.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Esko Pekkarinen\r\n// Date: 04.08.2014\r\n//\r\n// Description:\r\n// Class for writing a component instance as a Verilog instance.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"ComponentInstanceVerilogWriter.h\"\r\n\r\n#include <Plugins/VerilogGenerator/CommentWriter/CommentWriter.h>\r\n#include <Plugins/VerilogImport/VerilogSyntax.h>\r\n\r\n#include <IPXACTmodels/Component/Port.h>\r\n#include <IPXACTmodels/Component/BusInterface.h>\r\n\r\n#include <QRegularExpression>\r\n\r\nnamespace\r\n{\r\n    const int ALL_BITS = -1; //! Indicator for connecting all bits in a connection.\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentInstanceVerilogWriter::ComponentInstanceVerilogWriter()\r\n//-----------------------------------------------------------------------------\r\nComponentInstanceVerilogWriter::ComponentInstanceVerilogWriter(QSharedPointer<MetaInstance> instance,\r\n\tQSharedPointer<const PortSorter> sorter,\r\n\tbool useInterfaces) :\r\ninstance_(instance), \r\nsorter_(sorter),\r\nuseInterfaces_(useInterfaces)\r\n{\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentInstanceVerilogWriter::~ComponentInstanceVerilogWriter()\r\n//-----------------------------------------------------------------------------\r\nComponentInstanceVerilogWriter::~ComponentInstanceVerilogWriter()\r\n{\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentInstanceVerilogWriter::write()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentInstanceVerilogWriter::write(QTextStream& outputStream) const\r\n{\r\n    QString instanceString = \"<component> <parameters><instanceName>(<portConnections>);\";\r\n\r\n    instanceString.replace(\"<component>\", VerilogSyntax::legalizeName(instance_->getModuleName()));\r\n    instanceString.replace(\"<parameters>\", parameterAssignments());\r\n    instanceString.replace(\"<instanceName>\", formattedInstanceName());\r\n    instanceString.replace(\"<portConnections>\", portConnections());\r\n\r\n    outputStream << indentation() << instanceString << Qt::endl;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentInstanceVerilogWriter::formattedInstanceName()\r\n//-----------------------------------------------------------------------------\r\nQString ComponentInstanceVerilogWriter::formattedInstanceName() const\r\n{\r\n    QString instanceName = VerilogSyntax::legalizeName(instance_->getComponentInstance()->getInstanceName());\r\n\r\n    if (!instance_->getParameters()->isEmpty())\r\n    {\r\n        instanceName.prepend(indentation());\r\n    }\r\n\r\n    return instanceName;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentInstanceVerilogWriter::indentation()\r\n//-----------------------------------------------------------------------------\r\nQString ComponentInstanceVerilogWriter::indentation() const\r\n{\r\n    return \"    \";\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentInstanceVerilogWriter::parameterAssignments()\r\n//-----------------------------------------------------------------------------\r\nQString ComponentInstanceVerilogWriter::parameterAssignments() const\r\n{\r\n    QList<QSharedPointer<Parameter> > parameterToWrite;\r\n\r\n    for (QSharedPointer<Parameter> parameter : *instance_->getParameters())\r\n    {\r\n        // If the parameters are not user resolved nor generated, then there cannot be any override by the design.\r\n        if (parameter->getValueResolve() == \"user\" || parameter->getValueResolve() == \"generated\")\r\n        {\r\n            parameterToWrite.append(parameter);\r\n        }\r\n    }\r\n\r\n    if (parameterToWrite.isEmpty())\r\n    {\r\n        return \"\";\r\n    }\r\n\r\n\tQString instanceParameters(\"#(\\n<namesAndValues>)\\n\");\r\n\r\n\tQStringList assignments;\r\n\r\n\tfor (QSharedPointer<Parameter> parameter : parameterToWrite)\r\n\t{\r\n        // If the parameters are not user resolved nor generated, then there cannot be any override by the design.\r\n        if (parameter->getValueResolve() == \"user\" || parameter->getValueResolve() == \"generated\")\r\n        {\r\n            QString assignment(indentation().repeated(2) + \".<parameter>(<value>)\");\r\n            assignment.replace(\"<parameter>\", parameter->name().leftJustified(20));\r\n            assignment.replace(\"<value>\", parameter->getValue());\r\n            assignments.append(assignment);\r\n        }\r\n\t}\r\n\r\n    instanceParameters.replace(\"<namesAndValues>\", assignments.join(\",\\n\"));\r\n    return instanceParameters;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentInstanceVerilogWriter::portConnections()\r\n//-----------------------------------------------------------------------------\r\nQString ComponentInstanceVerilogWriter::portConnections() const\r\n{\r\n    QStringList portAssignments;\r\n    if (sorter_.isNull())\r\n    {\r\n\t\treturn \"\";\r\n\t}\r\n\r\n    QString previousInterfaceName = \"\";\r\n\r\n    // Pick the ports in sorted order.\r\n    QList<QSharedPointer<Port> > ports = sorter_->sortedPorts(instance_->getComponent());\r\n\r\n    foreach(QSharedPointer<Port> cPort, ports)\r\n    {\r\n        if (cPort->getDirection() == DirectionTypes::DIRECTION_PHANTOM)\r\n        {\r\n            ports.removeOne(cPort);\r\n        }\r\n    }\r\n\r\n    foreach(QSharedPointer<Port> cPort, ports)\r\n    {\r\n        QSharedPointer<MetaPort> mPort = instance_->getPorts()->value(cPort->name());\r\n\r\n        if (!mPort || mPort->isTransactional_)\r\n        {\r\n            // TODO: error\r\n            continue;\r\n        }\r\n\r\n        QSharedPointer<QList<QSharedPointer<BusInterface> > > busInterfaces =\r\n            instance_->getComponent()->getInterfacesUsedByPort(cPort->name());\r\n        QString interfaceName;\r\n\r\n        if (busInterfaces->size() == 1)\r\n        {\r\n            interfaceName = busInterfaces->first()->name();\r\n        }\r\n        else if (!busInterfaces->isEmpty())\r\n        {\r\n            interfaceName = QLatin1String(\"several\");\r\n        }\r\n        else\r\n        {\r\n            interfaceName = QLatin1String(\"none\");\r\n        }\r\n\r\n\r\n        QString interfaceSeparatorLine = createInterfaceSeparator(interfaceName, previousInterfaceName);\r\n        previousInterfaceName = interfaceName;\r\n\r\n        QString portAssignment = interfaceSeparatorLine + indentation().repeated(2) + \".<port>(<connection>)\";\r\n        portAssignment.replace(\"<port>\", mPort->port_->name().leftJustified(20));\r\n        portAssignment.replace(\"<connection>\", assignmentForInstancePort(mPort));\r\n\r\n        portAssignments.append(portAssignment);\r\n    }\r\n\r\n    return portAssignments.join(\",\\n\");\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentInstanceVerilogWriter::createInterfaceSeparator()\r\n//-----------------------------------------------------------------------------\r\nQString ComponentInstanceVerilogWriter::createInterfaceSeparator(QString const& interfaceName,\r\n    QString const& previousInteface) const\r\n{\r\n    QString interfaceIntroduction = \"\";\r\n\r\n    if (interfaceName.compare(previousInteface) != 0)\r\n    {\r\n        interfaceIntroduction.append(indentation().repeated(2));\r\n\r\n        if (interfaceName == \"none\")\r\n        {\r\n            interfaceIntroduction.append(\"// These ports are not in any interface\\n\");\r\n        }\r\n        else if (interfaceName == \"several\")\r\n        {\r\n            interfaceIntroduction.append(\"// There ports are contained in many interfaces\\n\");\r\n        }\r\n        else\r\n        {\r\n            interfaceIntroduction.append(\"// Interface: \" + interfaceName + \"\\n\");\r\n        }\r\n    }\r\n\r\n    // Begin first introduction on own line.\r\n    if (previousInteface.isEmpty())\r\n    {\r\n        interfaceIntroduction.prepend(\"\\n\");\r\n    }\r\n\r\n    return interfaceIntroduction;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentInstanceVerilogWriter::assignmentForPort()\r\n//-----------------------------------------------------------------------------\r\nQString ComponentInstanceVerilogWriter::assignmentForInstancePort(QSharedPointer<MetaPort> mPort) const\r\n{\r\n    // Use the default value of port, if no assignments exist.\r\n    if (mPort->upAssignments_.size() < 1)\r\n    {\r\n        return getDefaultValueAssignment(mPort);\r\n    }\r\n\r\n    // In case of an inout port, connect it directly the first encountered wire.\r\n    if (mPort->port_->getDirection() == DirectionTypes::INOUT)\r\n    {\r\n        return getInOutAssignment(mPort);\r\n    }\r\n\r\n    return VerilogSyntax::legalizeName(instance_->getComponentInstance()->getInstanceName() + \"_\"\r\n        + mPort->port_->name());\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentInstanceVerilogWriter::getDefaultValueAssignment()\r\n//-----------------------------------------------------------------------------\r\nQString ComponentInstanceVerilogWriter::getDefaultValueAssignment(QSharedPointer<MetaPort> mPort) const\r\n{\r\n    if (mPort->port_->getDirection() == DirectionTypes::IN)\r\n    {\r\n        bool defaultValueOk = false;\r\n        qint64 calculatedDefaultValue(mPort->defaultValue_.toULongLong(&defaultValueOk));\r\n        if (!defaultValueOk)\r\n        {\r\n            return \"\";\r\n        }\r\n\r\n        QString defaultValue = mPort->port_->getDefaultValue();\r\n\r\n        ComponentInstanceVerilogWriter::DefaultValueData defaultValueBasePair =\r\n            getDefaultValueBits(defaultValue, mPort);\r\n\r\n        int vectorWidth = defaultValueBasePair.bitvalue;\r\n        int base = defaultValueBasePair.base;\r\n\r\n        QString numberFormatLetter(QLatin1String(\"d\"));\r\n        if (base == 2)\r\n        {\r\n            numberFormatLetter = QLatin1String(\"b\");\r\n        }\r\n        else if (base == 8)\r\n        {\r\n            numberFormatLetter = QLatin1String(\"o\");\r\n        }\r\n        else if (base == 16)\r\n        {\r\n            numberFormatLetter = QLatin1String(\"h\");\r\n        }\r\n\r\n        QString vectorWidthString = \"\";\r\n        if (vectorWidth != 0)\r\n        {\r\n            vectorWidthString = QString::number(vectorWidth);\r\n        }\r\n\r\n        QString portName = mPort->port_->name();\r\n\r\n        QString numberFormat(\"\");\r\n        if (vectorWidth != 0 || numberFormatLetter != QStringLiteral(\"d\"))\r\n        {\r\n            numberFormat.append(\"'\");\r\n            if (defaultValueBasePair.isSigned)\r\n            {\r\n                numberFormat.append(\"s\");\r\n            }\r\n            \r\n            numberFormat.append(numberFormatLetter);\r\n        }\r\n\r\n        return vectorWidthString + numberFormat + QString::number(calculatedDefaultValue, base);\r\n    }\r\n\r\n    return \"\";\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentInstanceVerilogWriter::getDefaultValueBits()\r\n//-----------------------------------------------------------------------------\r\nComponentInstanceVerilogWriter::DefaultValueData ComponentInstanceVerilogWriter::getDefaultValueBits(\r\n    QString const& portDefaultValue, QSharedPointer<MetaPort> port) const\r\n{\r\n    QString portName = port->port_->name();\r\n\r\n    bool calculateBitValue = true;\r\n    quint64 bitValue = 0;\r\n    int base = 0;\r\n    bool isSigned = false;\r\n\r\n    QRegularExpression numberExpression(\"\\\\d+\");\r\n    QRegularExpression digitExpression(\"(\\\\w|')+\");\r\n\r\n    QStringList matchList;\r\n\r\n    QRegularExpressionMatchIterator matchIterator = digitExpression.globalMatch(portDefaultValue);\r\n    while (matchIterator.hasNext())\r\n    {\r\n        QRegularExpressionMatch match = matchIterator.next();\r\n        matchList.append(match.captured());\r\n    }\r\n\r\n    for (auto matchedWord : matchList)\r\n    {\r\n        if (matchedWord.contains(\"'\"))\r\n        {\r\n            int markIndex = matchedWord.indexOf(\"'\");\r\n\r\n            QString bitSideString = matchedWord.left(markIndex);\r\n            if (!bitSideString.isEmpty())\r\n            {\r\n                quint64 bitSide = bitSideString.toULongLong();\r\n                if (bitSide > bitValue)\r\n                {\r\n                    bitValue = bitSide;\r\n                    calculateBitValue = false;\r\n                }\r\n            }\r\n\r\n            QString format = matchedWord.mid(markIndex + 1, 2).toLower();\r\n            if (format.size() == 2)\r\n            {\r\n                bool newValueIsSigned = false;\r\n\r\n                int newBase = 0;\r\n                QString baseString = format.at(0);\r\n                if (baseString == (\"s\"))\r\n                {\r\n                    baseString = format.at(1);\r\n                    newValueIsSigned = true;\r\n                }\r\n\r\n                if (baseString == \"b\")\r\n                {\r\n                    newBase = 2;\r\n                }\r\n                else if (baseString == \"o\")\r\n                {\r\n                    newBase = 8;\r\n                }\r\n                else if (baseString == \"d\")\r\n                {\r\n                    newBase = 10;\r\n                }\r\n                else if (baseString == \"h\")\r\n                {\r\n                    newBase = 16;\r\n                }\r\n\r\n                if (newBase > base)\r\n                {\r\n                    base = newBase;\r\n                    isSigned = newValueIsSigned;\r\n                }\r\n            }\r\n        }\r\n        else\r\n        {\r\n            QRegularExpressionMatch match = numberExpression.match(matchedWord);\r\n            if (match.captured() == matchedWord && base < 10)\r\n            {\r\n                base = 10;\r\n                calculateBitValue = false;\r\n            }\r\n        }\r\n    }\r\n\r\n    if (calculateBitValue)\r\n    {\r\n        bool boundsFirstOk = false;\r\n        bool boundsSecondOk = false;\r\n        qint64 boundsFirst(port->vectorBounds_.first.toULongLong(&boundsFirstOk));\r\n        qint64 boundsSecond(port->vectorBounds_.second.toULongLong(&boundsSecondOk));\r\n\r\n        quint64 vectorWidth(0);\r\n\r\n        if (boundsFirstOk && boundsSecondOk)\r\n        {\r\n            vectorWidth = abs(boundsFirst - boundsSecond) + 1;\r\n        }\r\n\r\n        bitValue = vectorWidth;\r\n    }\r\n\r\n    if (base == 0)\r\n    {\r\n        if (bitValue < 8)\r\n        {\r\n            base = 2;\r\n        }\r\n        else if (bitValue < 16)\r\n        {\r\n            base = 10;\r\n        }\r\n        else\r\n        {\r\n            base = 16;\r\n        }\r\n    }\r\n\r\n    ComponentInstanceVerilogWriter::DefaultValueData defaultData;\r\n    defaultData.bitvalue = bitValue;\r\n    defaultData.base = base;\r\n    defaultData.isSigned = isSigned;\r\n\r\n    return defaultData;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentInstanceVerilogWriter::getInOutAssignment()\r\n//-----------------------------------------------------------------------------\r\nQString ComponentInstanceVerilogWriter::getInOutAssignment(QSharedPointer<MetaPort> mPort) const\r\n{\r\n    // Search for the first port assignment with a wire.\r\n\r\n    QStringList assignmentRows;\r\n    for (auto assignment : mPort->upAssignments_)\r\n    {\r\n        QSharedPointer<MetaWire> assignmentWire = assignment->wire_;\r\n\r\n        if (assignmentWire)\r\n        {\r\n            if (assignmentWire->hierPorts_.size() < 1)\r\n            {\r\n                assignmentRows.append(assignment->wire_->name_);\r\n            }\r\n            else\r\n            {\r\n                QString portName = mPort->port_->name();\r\n\r\n                QPair<QSharedPointer<MetaPort>, QSharedPointer<MetaPortAssignment> > hierarchicalPortAndAssignment\r\n                    = getConnectedHierarchicalPort(mPort, assignment, assignmentWire);\r\n\r\n                QSharedPointer<MetaPort> hierarchicalPort = hierarchicalPortAndAssignment.first;\r\n                QSharedPointer<MetaPortAssignment> hierarchicalAssignment = hierarchicalPortAndAssignment.second;\r\n                if (hierarchicalPort && hierarchicalAssignment)\r\n                {\r\n                    QString bounds;\r\n\r\n                    // If the assigned bounds are the same, different notation is needed.\r\n                    if (hierarchicalAssignment->physicalBounds_.first ==\r\n                        hierarchicalAssignment->physicalBounds_.second)\r\n                    {\r\n                        // If the vector bounds are not the same, use index instead.\r\n                        if (hierarchicalPort->vectorBounds_.first != hierarchicalPort->vectorBounds_.second)\r\n                        {\r\n                            bounds = \"[<left>]\";\r\n\r\n                            bounds.replace(\"<left>\", hierarchicalAssignment->physicalBounds_.first);\r\n                        }\r\n\r\n                        // Else no bounds are needed.\r\n                    }\r\n                    else\r\n                    {\r\n                        // If the assigned bounds differ, they must be generated.\r\n                        bounds = \"[<left>:<right>]\";\r\n\r\n                        bounds.replace(\"<left>\", hierarchicalAssignment->physicalBounds_.first);\r\n                        bounds.replace(\"<right>\", hierarchicalAssignment->physicalBounds_.second);\r\n                    }\r\n\r\n                    QString portAssignment(hierarchicalPort->port_->name() + bounds);\r\n                    assignmentRows.append(portAssignment);\r\n                }\r\n            }\r\n        }\r\n    }\r\n\r\n    if (assignmentRows.isEmpty())\r\n    {\r\n        return QString(\"\");\r\n    }\r\n    else\r\n    {\r\n        return assignmentRows.first();\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentInstanceVerilogWriter::getConnectedHierarchicalPort()\r\n//-----------------------------------------------------------------------------\r\nQPair<QSharedPointer<MetaPort>, QSharedPointer<MetaPortAssignment> > ComponentInstanceVerilogWriter::\r\n    getConnectedHierarchicalPort(QSharedPointer<MetaPort> metaPort,\r\n        QSharedPointer<MetaPortAssignment> metaAssignment, QSharedPointer<MetaWire> assignmentWire) const\r\n{\r\n    QPair<QSharedPointer<MetaPort>, QSharedPointer<MetaPortAssignment> > portAssignment;\r\n\r\n    QString portName = metaPort->port_->name();\r\n\r\n    QPair<QString, QString> portBounds = metaAssignment->logicalBounds_;\r\n    qint64 portLeft = portBounds.first.toLongLong();\r\n    qint64 portRight = portBounds.second.toLongLong();\r\n\r\n    if (portRight < portLeft)\r\n    {\r\n        qint64 temporary = portLeft;\r\n        portLeft = portRight;\r\n        portRight = temporary;\r\n    }\r\n\r\n    qint64 portWidth = abs(portLeft - portRight) + 1;\r\n\r\n    for (auto comparisonPort : assignmentWire->hierPorts_)\r\n    {\r\n        QString comparisonName = comparisonPort->port_->name();\r\n\r\n        QSharedPointer<MetaPortAssignment> comparisonAssignment =\r\n            getHierarchicalPortAssignmentConnectedToWire(comparisonPort, assignmentWire);\r\n        if (comparisonAssignment)\r\n        {\r\n            QPair<QString, QString> comparisonBounds = comparisonAssignment->logicalBounds_;\r\n\r\n            qint64 comparisonLeft = comparisonBounds.first.toLongLong();\r\n            qint64 comparisonRight = comparisonBounds.second.toLongLong();\r\n            if (comparisonRight < comparisonLeft)\r\n            {\r\n                qint64 temporary = comparisonLeft;\r\n                comparisonLeft = comparisonRight;\r\n                comparisonRight = temporary;\r\n            }\r\n\r\n            qint64 comparisonWidth = abs(comparisonLeft - comparisonRight) + 1;\r\n\r\n            if (portLeft >= comparisonLeft && portLeft <= comparisonRight && portWidth <= comparisonWidth)\r\n            {\r\n                portAssignment.first = comparisonPort;\r\n                portAssignment.second = comparisonAssignment;\r\n\r\n                break;\r\n            }\r\n        }\r\n    }\r\n\r\n    return portAssignment;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentInstanceVerilogWriter::portIsConnectedToWire()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<MetaPortAssignment> ComponentInstanceVerilogWriter::getHierarchicalPortAssignmentConnectedToWire(\r\n    QSharedPointer<MetaPort> hierarchicalPort, QSharedPointer<MetaWire> assignedWire) const\r\n{\r\n    for (auto comparisonAssignment : hierarchicalPort->downAssignments_)\r\n    {\r\n        if (comparisonAssignment->wire_ == assignedWire)\r\n        {\r\n            return comparisonAssignment;\r\n        }\r\n    }\r\n\r\n    return QSharedPointer<MetaPortAssignment>();\r\n}\r\n"
  },
  {
    "path": "Plugins/VerilogGenerator/ComponentInstanceVerilogWriter/ComponentInstanceVerilogWriter.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ComponentInstanceVerilogWriter.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Esko Pekkarinen\r\n// Date: 04.08.2014\r\n//\r\n// Description:\r\n// Class for writing a component instance as a Verilog instance.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef COMPONENTINSTANCEVERILOGWRITER_H\r\n#define COMPONENTINSTANCEVERILOGWRITER_H\r\n\r\n#include \"../veriloggeneratorplugin_global.h\"\r\n\r\n#include <IPXACTmodels/Component/Component.h>\r\n#include <IPXACTmodels/Design/ComponentInstance.h>\r\n\r\n#include <KactusAPI/include/ExpressionParser.h>\r\n#include <KactusAPI/include/ExpressionFormatter.h>\r\n\r\n#include <Plugins/common/PortSorter/PortSorter.h>\r\n#include <Plugins/VerilogGenerator/common/Writer.h>\r\n\r\n#include <QTextStream>\r\n#include <QSharedPointer>\r\n#include <Plugins/common/HDLParser/MetaDesign.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Class for writing a component instance as a Verilog instance.\r\n//-----------------------------------------------------------------------------\r\nclass VERILOGGENERATORPLUGIN_EXPORT ComponentInstanceVerilogWriter : public Writer\r\n{\r\npublic:\r\n\r\n\t/*!\r\n\t *  The constructor.\r\n\t *\r\n\t *    @param [in] instance                The component instance to write to Verilog\r\n     *    @param [in] sorter                  Sorter for the ports in the component.\r\n     *    @param [in] useInterfaces           True, if interfaces are used where applicable. False means always ports.\r\n\t */\r\n\tComponentInstanceVerilogWriter(QSharedPointer<MetaInstance> instance,\r\n        QSharedPointer<const PortSorter> sorter, bool useInterfaces);\r\n\r\n\t//! The destructor.\r\n\t~ComponentInstanceVerilogWriter();\r\n\r\n   /*!\r\n\t*  Writes the Verilog instance into a text stream.\r\n    *\r\n    *    @param [in] outputStream   The output to write to.    \r\n    */\r\n    virtual void write(QTextStream& outputStream) const;\r\n\r\n    /*!\r\n     *  Adds a port connection assignment for the instance.\r\n     *\r\n     *    @param [in] instancePortName    The name of the port in the instance to assign.\r\n     *    @param [in] assignedConnection  The name of the connection to assign.\r\n     */\r\n    void assignPortForFullWidth(QString const& instancePortName, QString const& assignedConnection);\r\n\r\n    /*!\r\n     *  Adds a port connection assignment for the instance for a range of bits.\r\n     *\r\n     *    @param [in] instancePortName    The name of the port in the instance to assign.\r\n     *    @param [in] assignedConnection  The name of the connection to assign.\r\n     *    @param [in] leftBound           The left bound of the connection to assign.\r\n     *    @param [in] rightBound          The right bound of the connection to assign.\r\n     */\r\n    void assignPortForRange(QString const& instancePortName, QString const& assignedConnection, \r\n        QPair<QString, QString> wireBounds);\r\n\r\n    /*!\r\n     *  Assigns a port tie off value for the instance writer.\r\n     *\r\n     *    @param [in] portName        The name of the port containing the tie off value.\r\n     *    @param [in] tieOffValue     The tie off value.\r\n     */\r\n    void assignPortTieOff(QString const& portName, QString const& tieOffValue);\r\n\r\nprivate:\r\n\r\n\t// Disable copying.\r\n\tComponentInstanceVerilogWriter(ComponentInstanceVerilogWriter const& rhs);\r\n\tComponentInstanceVerilogWriter& operator=(ComponentInstanceVerilogWriter const& rhs);\r\n\r\n    /*!\r\n     *  Gets the component instance name with or without indentation as required.\r\n     *\r\n     *    @return The formatted instance name.\r\n     */\r\n    QString formattedInstanceName() const;\r\n\r\n    /*!\r\n     *  Gets the indentation to use.\r\n     *\r\n     *    @return The indentation to use.\r\n     */\r\n    QString indentation() const;\r\n\r\n    /*!\r\n     *  Gets the instance-specific parameter assignments.\r\n     *\r\n     *    @return The Verilog description of the instance parameters and their values.\r\n     */\r\n    QString parameterAssignments() const;\r\n\r\n    /*!\r\n    *  Gets the instance ports and their connections.\r\n    *\r\n    *    @return The Verilog description of the instance ports and their connections.\r\n    */\r\n    QString portConnections() const;\r\n\r\n    /*!\r\n     *  Creates an interface separator for port connections.\r\n     *\r\n     *    @param [in] interfaceName       The name of the interface for the current port.\r\n     *    @param [in] previousInteface    The name of the interface for the previous port.\r\n     *\r\n     *    @return Separator for port interface.\r\n     */\r\n    QString createInterfaceSeparator(QString const& interfaceName, QString const& previousInteface) const;\r\n\r\n    /*!\r\n    *  Gets the connection assignment for a port of a module instance.\r\n    *\r\n    *    @param [in] mPort            The meta port whose connection assignment to get.\r\n    *\r\n    *    @return The Verilog description of the instance port connection assignment.\r\n    */\r\n    QString assignmentForInstancePort(QSharedPointer<MetaPort> mPort) const;\r\n\r\n    /*!\r\n     *  Get the default value assignment for a port.\r\n     *\r\n     *    @param [in] mPort   The selected port.\r\n     *\r\n     *    @return The default value assignment of the selected port.\r\n     */\r\n    QString getDefaultValueAssignment(QSharedPointer<MetaPort> mPort) const;\r\n\r\n    /*!\r\n     *  Get the connection assignment for an INOUT port.\r\n     *\r\n     *    @param [in] mPort   The selected INOUT port.\r\n     *\r\n     *    @return Verilog description of the port assignment.\r\n     */\r\n    QString getInOutAssignment(QSharedPointer<MetaPort> mPort) const;\r\n\r\n    /*!\r\n     *  Get the hierarchical port connected to the selected port.\r\n     *\r\n     *    @param [in] metaPort        The selected port.\r\n     *    @param [in] metaAssignment  Assignment for the selected port.\r\n     *    @param [in] assignmentWire  Wire of the connection.\r\n     *\r\n     *    @return The hierarchical port connected to the selected port and its port assignment.\r\n     */\r\n    QPair<QSharedPointer<MetaPort>, QSharedPointer<MetaPortAssignment> > getConnectedHierarchicalPort(\r\n        QSharedPointer<MetaPort> metaPort,\r\n        QSharedPointer<MetaPortAssignment> metaAssignment,\r\n        QSharedPointer<MetaWire> assignmentWire) const;\r\n\r\n    /*!\r\n     *  Get the port assignment for the selected port.\r\n     *\r\n     *    @param [in] hierarchicalPort    The selected port.\r\n     *    @param [in] assignedWire        Wire of the connection.\r\n     *\r\n     *    @return Port assignment of the selected port.\r\n     */\r\n    QSharedPointer<MetaPortAssignment> getHierarchicalPortAssignmentConnectedToWire(\r\n        QSharedPointer<MetaPort> hierarchicalPort,\r\n        QSharedPointer<MetaWire> assignedWire) const;\r\n\r\n    //! Data for the written default value.\r\n    struct DefaultValueData\r\n    {\r\n        //! The vector width.\r\n        int bitvalue;\r\n\r\n        //! Base of the value.\r\n        int base;\r\n\r\n        //! Flag for signed value.\r\n        bool isSigned;\r\n    };\r\n\r\n    /*!\r\n     *  Get the data required for writing the default value of the selected port.\r\n     *\r\n     *    @param [in] portDefaultValue    The default value.\r\n     *    @param [in] port                The selected port.\r\n     *\r\n     *    @return Data required for writing the default value.\r\n     */\r\n    DefaultValueData getDefaultValueBits(QString const& portDefaultValue, QSharedPointer<MetaPort> port) const;\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n\tQSharedPointer<MetaInstance> instance_;\r\n\r\n\t//! Sorter for the ports of the component.\r\n    QSharedPointer<const PortSorter> sorter_;\r\n\r\n    //! True, if interfaces are utilized separately from physical ports, else false.\r\n    bool useInterfaces_;\r\n};\r\n\r\n#endif // COMPONENTINSTANCEVERILOGWRITER_H\r\n"
  },
  {
    "path": "Plugins/VerilogGenerator/ComponentVerilogWriter/ComponentVerilogWriter.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ComponentVerilogWriter.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Esko Pekkarinen\r\n// Date: 01.08.2014\r\n//\r\n// Description:\r\n// Class for writing a component as a Verilog module.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"ComponentVerilogWriter.h\"\r\n\r\n#include <Plugins/VerilogGenerator/ModelParameterVerilogWriter/ModelParameterVerilogWriter.h>\r\n#include <Plugins/VerilogGenerator/VerilogPortWriter/VerilogPortWriter.h>\r\n\r\n#include <Plugins/VerilogGenerator/CommentWriter/CommentWriter.h>\r\n\r\n#include <IPXACTmodels/Component/Component.h>\r\n#include <IPXACTmodels/Component/RemapState.h>\r\n#include <IPXACTmodels/Component/BusInterface.h>\r\n#include <IPXACTmodels/Component/Port.h>\r\n#include <IPXACTmodels/common/ModuleParameter.h>\r\n#include <IPXACTmodels/common/VLNV.h>\r\n\r\n#include <IPXACTmodels/Component/View.h>\r\n#include <IPXACTmodels/Component/ComponentInstantiation.h>\r\n\r\n#include <Plugins/VerilogImport/VerilogSyntax.h>\r\n#include <Plugins/common/PortSorter/InterfaceDirectionNameSorter.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentVerilogWriter::ComponentVerilogWriter\r\n//-----------------------------------------------------------------------------\r\nComponentVerilogWriter::ComponentVerilogWriter(QSharedPointer<MetaComponent> component,\r\n    bool useInterfaces) :\r\ncomponent_(component),\r\nuseInterfaces_(useInterfaces),\r\nchildWriters_(),\r\nsorter_(new InterfaceDirectionNameSorter)\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentVerilogWriter::~ComponentVerilogWriter\r\n//-----------------------------------------------------------------------------\r\nComponentVerilogWriter::~ComponentVerilogWriter()\r\n{\r\n    childWriters_.clear();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentVerilogWriter::write\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentVerilogWriter::write(QTextStream& outputStream) const\r\n{\r\n    if (nothingToWrite())\r\n    {\r\n        return;\r\n    }\r\n\r\n    writeModuleDeclaration(outputStream);\r\n\r\n    writeInternalWiresAndComponentInstances(outputStream);\r\n\r\n\tif (implementation_)\r\n    {\r\n        // Implementing -> may need remap states.\r\n        writeRemapSates(outputStream);\r\n\r\n\t\t// If an implementation exists, there must be a warning about overwriting as well.\r\n\t\toutputStream << \"// \" << VerilogSyntax::TAG_OVERRIDE << Qt::endl;\r\n\r\n        implementation_->write(outputStream);\r\n\t}\r\n\t\t\r\n\twriteModuleEnd(outputStream);\r\n\r\n\tif (postModule_)\r\n\t{\r\n\t\tpostModule_->write(outputStream);\r\n\t}\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentVerilogWriter::setImplementation\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentVerilogWriter::setImplementation(QSharedPointer<TextBodyWriter> implementation)\r\n{\r\n\timplementation_ = implementation;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentVerilogWriter::setPostModule\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentVerilogWriter::setPostModule(QSharedPointer<TextBodyWriter> postModule)\r\n{\r\n\tpostModule_ = postModule;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentVerilogWriter::nothingToWrite\r\n//-----------------------------------------------------------------------------\r\nbool ComponentVerilogWriter::nothingToWrite() const\r\n{\r\n    return component_.isNull();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentVerilogWriter::writeModuleDeclaration()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentVerilogWriter::writeModuleDeclaration(QTextStream& outputStream) const\r\n{\r\n    outputStream << \"module \" << VerilogSyntax::legalizeName(component_->getModuleName());\r\n    \r\n    writeParameterDeclarations(outputStream);\r\n\r\n    writePortDeclarations(outputStream);     \r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentVerilogWriter::writeParameterDeclarations()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentVerilogWriter::writeParameterDeclarations(QTextStream& outputStream) const\r\n{\r\n\tif (component_->getMetaParameters()->isEmpty())\r\n    {\r\n        return;\r\n    }\r\n\r\n    outputStream << \" #(\" << Qt::endl;\r\n\r\n    for (QSharedPointer<Parameter> parameter : *component_->getMetaParameters())\r\n    {\r\n        bool isLastParameter = parameter == component_->getMetaParameters()->last();\r\n        writeParameter(outputStream, parameter, isLastParameter);\r\n    }\r\n\r\n    outputStream << \") \";\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentVerilogWriter::writeParameter()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentVerilogWriter::writeParameter(QTextStream& outputStream, QSharedPointer<Parameter> parameter,\r\n    bool isLast) const\r\n{\r\n    outputStream << indentation();\r\n    ModuleParameterVerilogWriter parameterWriter(parameter);\r\n    parameterWriter.write(outputStream);\r\n\r\n    if (!isLast)\r\n    {\r\n        outputStream << \",\";\r\n    }\r\n\r\n    CommentWriter descriptionWriter(parameter->description());\r\n    descriptionWriter.setIndent(4);\r\n    descriptionWriter.write(outputStream);\r\n\r\n    if (parameter->description().isEmpty())\r\n    {\r\n        outputStream << Qt::endl;\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentVerilogWriter::indentation()\r\n//-----------------------------------------------------------------------------\r\nQString ComponentVerilogWriter::indentation(int depth /*= 1*/) const\r\n{\r\n    QString indent = \"    \";\r\n\r\n    return indent.repeated(depth);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentVerilogWriter::writePortDeclarations()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentVerilogWriter::writePortDeclarations(QTextStream& outputStream) const\r\n{\r\n    QString previousInterfaceName = \"\";\r\n\r\n    outputStream << \"(\";\r\n\r\n    // Pick the ports in sorted order.\r\n    QList<QSharedPointer<Port> > ports = sorter_->sortedPorts(component_->getComponent());\r\n\r\n    foreach(QSharedPointer<Port> cPort, ports)\r\n    {\r\n        if (cPort->getDirection() == DirectionTypes::DIRECTION_PHANTOM || cPort->getTransactional())\r\n        {\r\n            ports.removeOne(cPort);\r\n        }\r\n    }\r\n\r\n    foreach(QSharedPointer<Port> cPort, ports)\r\n    {\r\n        QSharedPointer<MetaPort> mPort = component_->getPorts()->value(cPort->name());\r\n\r\n        if (!mPort || mPort->isTransactional_)\r\n        {\r\n            // TODO: error\r\n            continue;\r\n        }\r\n\r\n        QString interfaceName;\r\n        QString interfaceDescription;\r\n        QSharedPointer<QList<QSharedPointer<BusInterface> > > busInterfaces =\r\n            component_->getComponent()->getInterfacesUsedByPort(cPort->name());\r\n\r\n        if (busInterfaces->count() < 1 )\r\n        {\r\n            interfaceName = \"none\";\r\n        }\r\n        else if (useInterfaces_)\r\n        {\r\n            continue;\r\n        }\r\n        else\r\n        {\r\n            if (busInterfaces->count() == 1)\r\n            {\r\n                interfaceName  = busInterfaces->first()->name();\r\n                interfaceDescription = busInterfaces->first()->description();\r\n            }\r\n            else\r\n            {\r\n                interfaceName = \"several\";\r\n            }\r\n        }\r\n\r\n        writeInterfaceIntroduction(interfaceName, interfaceDescription, previousInterfaceName, outputStream);\r\n        bool lastPortToWrite = cPort == ports.last();\r\n        writePort(outputStream, mPort, lastPortToWrite);\r\n    }\r\n    \r\n    outputStream << \");\" << Qt::endl;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentVerilogWriter::writeInterfaceIntroduction()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentVerilogWriter::writeInterfaceIntroduction(QString const& interfaceName, QString const& interfaceDescription,\r\n    QString& previousInterfaceName, QTextStream& outputStream) const\r\n{\r\n    if (previousInterfaceName.compare(interfaceName) != 0)\r\n    {\r\n        outputStream << Qt::endl;\r\n\r\n        if (interfaceName == \"none\")\r\n        {\r\n            outputStream << indentation() << \"// These ports are not in any interface\" << Qt::endl;                \r\n        }\r\n        else if (interfaceName == \"several\")\r\n        {\r\n            outputStream << indentation() << \"// There ports are contained in many interfaces\" << Qt::endl;       \r\n        }\r\n        else\r\n        {\r\n            outputStream << indentation() << \"// Interface: \" << interfaceName << Qt::endl;\r\n\r\n            if (!interfaceDescription.isEmpty())\r\n            {\r\n                CommentWriter descriptionWriter(interfaceDescription);\r\n                descriptionWriter.setIndent(4);\r\n                descriptionWriter.write(outputStream);\r\n            }\r\n        }        \r\n        previousInterfaceName = interfaceName;                \r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentVerilogWriter::writePort()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentVerilogWriter::writePort(QTextStream& outputStream, QSharedPointer<MetaPort> port, bool isLast) const\r\n{\r\n    outputStream << indentation();\r\n\r\n    VerilogPortWriter writer(port);\r\n    writer.write(outputStream);\r\n\r\n    if (!isLast)\r\n    {\r\n        outputStream << \",\";\r\n    }\r\n\r\n    CommentWriter descriptionWriter(port->port_->description());\r\n    descriptionWriter.setIndent(4);\r\n    descriptionWriter.write(outputStream);\r\n\r\n    if (port->port_->description().isEmpty())\r\n    {\r\n        outputStream << Qt::endl;\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentVerilogWriter::writeInternalWiresAndComponentInstances()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentVerilogWriter::writeInternalWiresAndComponentInstances(QTextStream& outputStream) const\r\n{\r\n    outputStream << Qt::endl;\r\n\r\n    WriterGroup::write(outputStream);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentVerilogWriter:writeRemapSates()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentVerilogWriter::writeRemapSates(QTextStream& outputStream) const\r\n{\r\n    if (component_->getRemapStates()->isEmpty())\r\n    {\r\n       return;\r\n    }\r\n\r\n    outputStream << indentation() << \"// Remap states:\" << Qt::endl;\r\n\r\n    foreach (QSharedPointer<FormattedRemapState> grms, *component_->getRemapStates())\r\n    {\r\n        QString condition;\r\n\r\n        QSharedPointer<QPair<QSharedPointer<Port>, QString> > parsedPort;\r\n        foreach (parsedPort, grms->ports_)\r\n        {\r\n            condition += \"(\" + parsedPort->first->name() + \" == \" + parsedPort->second + \")\";\r\n\r\n            if (parsedPort != grms->ports_.last())\r\n            {\r\n                condition += \" && \";\r\n            }\r\n        }\r\n\r\n        outputStream << indentation() << \"`define \" << grms->state_->name() << \" \" << condition << Qt::endl;\r\n    }\r\n\r\n    outputStream << Qt::endl;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentVerilogWriter::writeModuleEnd()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentVerilogWriter::writeModuleEnd(QTextStream& outputStream) const\r\n{\r\n    outputStream << \"endmodule\" << Qt::endl;\r\n}\r\n"
  },
  {
    "path": "Plugins/VerilogGenerator/ComponentVerilogWriter/ComponentVerilogWriter.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ComponentVerilogWriter.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Esko Pekkarinen\r\n// Date: 01.08.2014\r\n//\r\n// Description:\r\n// Class for writing a component as a Verilog module.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef COMPONENTVERILOGWRITER_H\r\n#define COMPONENTVERILOGWRITER_H\r\n\r\n#include \"../veriloggeneratorplugin_global.h\"\r\n\r\n#include <IPXACTmodels/Component/Component.h>\r\n#include <IPXACTmodels/Component/View.h>\r\n#include <IPXACTmodels/Component/Port.h>\r\n\r\n#include <Plugins/common/PortSorter/PortSorter.h>\r\n#include <Plugins/VerilogGenerator/ModelParameterVerilogWriter/ModelParameterVerilogWriter.h>\r\n#include <Plugins/VerilogGenerator/common/Writer.h>\r\n#include <Plugins/VerilogGenerator/common/WriterGroup.h>\r\n\r\n#include <Plugins/VerilogGenerator/TextBodyWriter/TextBodyWriter.h>\r\n\r\n#include <Plugins/common/HDLParser/HDLParserCommon.h>\r\n#include <Plugins/common/HDLParser/MetaComponent.h>\r\n\r\n#include <QSharedPointer>\r\n#include <QTextStream>\r\n#include <QList>\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Class for writing a component as a Verilog module.\r\n//-----------------------------------------------------------------------------\r\nclass VERILOGGENERATORPLUGIN_EXPORT ComponentVerilogWriter : public WriterGroup\r\n{\r\npublic:\r\n\r\n\t/*!\r\n\t *  The constructor.\r\n\t *\r\n\t *    @param [in] component               The component to write to Verilog.\r\n     *    @param [in] useInterfaces           True, if interfaces are utilized separately from physical ports, else false.\r\n\t */\r\n\tComponentVerilogWriter(QSharedPointer<MetaComponent> component, bool useInterfaces);\r\n\r\n\t//! The destructor.\r\n\t~ComponentVerilogWriter();\r\n\r\n\t/*! Writes the Verilog module into a text stream.\r\n\t *\r\n     *    @param [in] output   The output to write to.\r\n\t */\r\n    virtual void write(QTextStream& outputStream) const;\r\n\r\n\t/*! \r\n\t *      Sets implementation module writer that will write the module implementation.\r\n\t */\r\n\tvoid setImplementation(QSharedPointer<TextBodyWriter> implementation);\r\n\t\r\n\t/*! \r\n\t *      Sets post module writer that will write the post module.\r\n\t */\r\n    void setPostModule(QSharedPointer<TextBodyWriter> postModule);\r\n\r\nprivate:\r\n\t// Disable copying.\r\n\tComponentVerilogWriter(ComponentVerilogWriter const& rhs);\r\n\tComponentVerilogWriter& operator=(ComponentVerilogWriter const& rhs);\r\n\r\n     /*!\r\n      *  Checks if the writer should write nothing.\r\n      *\r\n      *    @return True, if the writer has nothing to write, otherwise false.\r\n      */\r\n    bool nothingToWrite() const;\r\n\r\n    /*!\r\n     *  Writes the module declaration.\r\n     *\r\n     *    @param [in] outputStream   The output to write to.\r\n     */\r\n    void writeModuleDeclaration( QTextStream& outputStream ) const;\r\n\r\n     /*!\r\n      *  Writes the module parameter declaration.\r\n      *\r\n      *    @param [in] outputStream   The output to write to.\r\n      */\r\n    void writeParameterDeclarations(QTextStream& outputStream) const;\r\n\r\n    /*!\r\n     *  Writes a single parameter declaration.\r\n     *\r\n     *    @param [in] outputStream    The output to write to.\r\n     *    @param [in] parameter       The parameter to write.\r\n     *    @param [in] isLast          Indicates if the parameter is the last to write.\r\n     */\r\n    void writeParameter(QTextStream& outputStream, QSharedPointer<Parameter> parameter, bool isLast) const;\r\n\r\n    /*!\r\n     *  Writes the module port declaration.\r\n     *\r\n     *    @param [in] outputStream   The output to write to.\r\n     */\r\n    void writePortDeclarations(QTextStream& outputStream) const;\r\n    \r\n    /*!\r\n     *  Writes a single port declaration.\r\n     *\r\n     *    @param [in] outputStream    The output to write to.\r\n     *    @param [in] port            The port to write.\r\n     *    @param [in] isLast          Indicates if the port is the last to write.\r\n     */\r\n    void writePort(QTextStream& outputStream, QSharedPointer<MetaPort> port, bool isLast) const;\r\n\r\n    /*!\r\n     *  Writes a bus interface introduction.\r\n     *\r\n     *    @param [in] interfaceName           The name of the bus interface to introduce.\r\n     *    @param [in] previousInterfaceName   The name of the previously introduced bus interface.\r\n     *    @param [in] outputStream            The output to write to.\r\n     */\r\n    void writeInterfaceIntroduction(QString const& interfaceName, QString const& interfaceDescription, QString& previousInterfaceName,\r\n        QTextStream& outputStream ) const;\r\n\r\n    /*!\r\n     *  Writes the inserted wires and component instances of the top-level component.\r\n     *\r\n     *    @param [in] outputStream   The output to write to.\r\n     */\r\n    void writeInternalWiresAndComponentInstances(QTextStream& outputStream) const;\r\n    \r\n    /*!\r\n     *  Writes the defined conditions of the remap states.\r\n     *\r\n     *    @param [in] outputStream   The output to write to.\r\n     */\r\n    void writeRemapSates(QTextStream& outputStream) const;\r\n\r\n    /*!\r\n     *  Writes the module port declaration.\r\n     *\r\n     *    @param [in] outputStream   The output to write to.\r\n     */\r\n    void writeRegisters(QTextStream& outputStream) const;\r\n\r\n    /*!\r\n     *  Writes the ending clause for the module.\r\n     *\r\n     *    @param [in] outputStream   The output to write to.\r\n     */\r\n    void writeModuleEnd(QTextStream& outputStream) const;\r\n\r\n    /*!\r\n     *  Gets the indentation to use.\r\n     *\r\n     *    @return The indentation to use.\r\n     */\r\n    QString indentation(int depth = 1) const;\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! The component to write to Verilog module.\r\n    QSharedPointer<MetaComponent> component_;\r\n\r\n    //! True, if interfaces are utilized separately from physical ports, else false.\r\n    bool useInterfaces_;\r\n\r\n    //! Writers for the inner elements e.g. wires and subcomponent instances.\r\n    QList<QSharedPointer<Writer> > childWriters_;\r\n\r\n    //! Sorter for the ports of the component.\r\n    QSharedPointer<const PortSorter> sorter_;\r\n\r\n\t//! The implementation, which is essentially the user-written things in the module.\r\n\tQSharedPointer<TextBodyWriter> implementation_;\r\n\r\n\t//! The extra stuff that comes after the written module.\r\n    QSharedPointer<TextBodyWriter> postModule_;\r\n};\r\n\r\n#endif // COMPONENTVERILOGWRITER_H\r\n"
  },
  {
    "path": "Plugins/VerilogGenerator/ModelParameterVerilogWriter/ModelParameterVerilogWriter.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ModuleParameterVerilogWriter.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Esko Pekkarinen\r\n// Date: 14.7.2014\r\n//\r\n// Description:\r\n// Class for writing model parameter declarations in Verilog.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"ModelParameterVerilogWriter.h\"\r\n\r\n#include <IPXACTmodels/common/Parameter.h>\r\n\r\n#include <QRegularExpression>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ModuleParameterVerilogWriter::ModuleParameterVerilogWriter()\r\n//-----------------------------------------------------------------------------\r\nModuleParameterVerilogWriter::ModuleParameterVerilogWriter(QSharedPointer<Parameter> parameter) :\r\nparameter_(parameter)\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ModuleParameterVerilogWriter::~ModuleParameterVerilogWriter()\r\n//-----------------------------------------------------------------------------\r\nModuleParameterVerilogWriter::~ModuleParameterVerilogWriter()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ModuleParameterVerilogWriter::write()\r\n//-----------------------------------------------------------------------------\r\nvoid ModuleParameterVerilogWriter::write(QTextStream& output) const\r\n{\r\n    if (nothingToWrite())\r\n    {\r\n        return;\r\n    }\r\n\r\n    output << createDeclaration(); \r\n}    \r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ModuleParameterVerilogWriter::shouldNotWrite()\r\n//-----------------------------------------------------------------------------\r\nbool ModuleParameterVerilogWriter::nothingToWrite() const\r\n{\r\n    return parameter_.isNull() || parameter_->name().isEmpty();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ModuleParameterVerilogWriter::createDeclaration()\r\n//-----------------------------------------------------------------------------\r\nQString ModuleParameterVerilogWriter::createDeclaration() const\r\n{\r\n    QString parameterDeclaration(\"parameter <type> <arrayBounds> <name> = <default>\");\r\n\r\n    QString dataValue = parameter_->getAttribute(QStringLiteral(\"dataType\"));\r\n\r\n    parameterDeclaration.replace(\"<type>\", dataValue.leftJustified(7));\r\n    parameterDeclaration.replace(\"<arrayBounds>\", arrayBounds().leftJustified(20));\r\n    //parameterDeclaration.replace(\"<vectorBounds>\", vectorBounds());\r\n    parameterDeclaration.replace(\"<name>\", parameter_->name().leftJustified(16));\r\n    parameterDeclaration.replace(\"<default>\", formattedValue());\r\n\r\n    if (parameter_->getValue().isEmpty())\r\n    {\r\n        parameterDeclaration.remove(\" = \");\r\n    }\r\n\r\n    return parameterDeclaration;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ModuleParameterVerilogWriter::arrayBounds()\r\n//-----------------------------------------------------------------------------\r\nQString ModuleParameterVerilogWriter::arrayBounds() const\r\n{\r\n    QString arrayLeft = parameter_->getAttribute(\"kactus2:arrayLeft\");\r\n    QString arrayRight = parameter_->getAttribute(\"kactus2:arrayRight\");\r\n\r\n    QString arrayDefinition = \"[\" + arrayLeft + \":\" + arrayRight + \"]\";\r\n    arrayDefinition.remove(\" \");\r\n\r\n    if (arrayDefinition == \"[:]\")\r\n    {\r\n        arrayDefinition.clear();\r\n    }\r\n\r\n    QString vectorLeft = parameter_->getVectorLeft();\r\n    QString vectorRight = parameter_->getVectorRight();\r\n\r\n    QString vectorDefinition = \"[\" + vectorLeft + \":\" + vectorRight + \"]\";\r\n    vectorDefinition.remove(\" \");\r\n\r\n    if (vectorDefinition == \"[:]\")\r\n    {\r\n        vectorDefinition.clear();\r\n    }\r\n\r\n    return arrayDefinition + vectorDefinition;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ModuleParameterVerilogWriter::formattedValue()\r\n//-----------------------------------------------------------------------------\r\nQString ModuleParameterVerilogWriter::formattedValue() const\r\n{\r\n    QString value = parameter_->getValue();\r\n\r\n    if (QString::compare(parameter_->getType(), \"string\") == 0)\r\n    {\r\n        QRegularExpression expression(\"\\\".*\\\"\");\r\n        QRegularExpressionMatch expressionMatch = expression.match(value);\r\n\r\n        if (expressionMatch.hasMatch())\r\n        {\r\n            value = expressionMatch.captured(0);\r\n        }\r\n\r\n        if (!value.startsWith(\"\\\"\"))\r\n        {\r\n            value.prepend(\"\\\"\");\r\n        }\r\n\r\n        if (!value.endsWith(\"\\\"\"))\r\n        {\r\n            value.append(\"\\\"\");\r\n        }\r\n    }\r\n\r\n    else\r\n    {\r\n        value.remove(\" \");\r\n    }\r\n\r\n    return value;\r\n}\r\n"
  },
  {
    "path": "Plugins/VerilogGenerator/ModelParameterVerilogWriter/ModelParameterVerilogWriter.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ModuleParameterVerilogWriter.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Esko Pekkarinen\r\n// Date: 14.7.2014\r\n//\r\n// Description:\r\n// Class for writing model parameter declarations in Verilog.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef ModuleParameterVerilogWriter_H\r\n#define ModuleParameterVerilogWriter_H\r\n\r\n#include \"../veriloggeneratorplugin_global.h\"\r\n#include \"../common/Writer.h\"\r\n\r\n#include <QString>\r\n#include <QSharedPointer>\r\n#include <QTextStream>\r\n\r\nclass Parameter;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Class for writing model parameter declarations in Verilog.\r\n//-----------------------------------------------------------------------------\r\nclass VERILOGGENERATORPLUGIN_EXPORT ModuleParameterVerilogWriter : public Writer\r\n{\r\n\r\npublic:\r\n\r\n\t/*!\r\n\t *  The constructor.\r\n\t *\r\n\t *    @param [in] ModuleParameter  The model parameter represented by this object.\r\n\t */\r\n\tModuleParameterVerilogWriter(QSharedPointer<Parameter> parameter);\r\n\t\r\n\t//! The destructor\r\n\t~ModuleParameterVerilogWriter();\r\n\r\n\t/*! Write the contents of the model parameter into text stream.\r\n\t *\r\n\t *    @param [in] output   The text stream to write the model parameter into.\r\n\t*/\r\n\tvirtual void write(QTextStream& output) const;\r\n\r\nprivate:\r\n\t\r\n\t//! No copying.\r\n\tModuleParameterVerilogWriter(const ModuleParameterVerilogWriter& other);\r\n\r\n\t//! No assignment.\r\n\tModuleParameterVerilogWriter& operator=(const ModuleParameterVerilogWriter& other);\r\n\r\n    /*!\r\n     *  Checks if the writer should write nothing.\r\n     *\r\n     *    @return True, if the writer has nothing to write, otherwise false.\r\n     */\r\n    bool nothingToWrite() const;\r\n\r\n    /*!\r\n     *  Creates a Verilog parameter declaration from the model parameter.\r\n     *\r\n     *    @return A Verilog parameter declaration.\r\n     */\r\n    QString createDeclaration() const;\r\n    \r\n    /*!\r\n     *  Returns the array bounds for the model parameter.\r\n     *     \r\n     *    @return The array bounds.\r\n     */\r\n    QString arrayBounds() const;\r\n\r\n    /*!\r\n     *  Returns the formatted model parameter value.\r\n     *     \r\n     *    @return The formatted model parameter value.\r\n     */\r\n    QString formattedValue() const;\r\n   \r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! The model parameter to write to Verilog.\r\n    QSharedPointer<Parameter> parameter_;\r\n};\r\n\r\n#endif // ModuleParameterVerilogWriter_H\r\n"
  },
  {
    "path": "Plugins/VerilogGenerator/TextBodyWriter/TextBodyWriter.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: TextBodyWriter.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Janne Virtanen\r\n// Date: 09.06.2016\r\n//\r\n// Description:\r\n// Class for writing text body.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"TextBodyWriter.h\"\r\n\r\n#include <QStringList>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: TextBodyWriter::TextBodyWriter()\r\n//-----------------------------------------------------------------------------\r\nTextBodyWriter::TextBodyWriter(QString const& text): text_(text)\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: TextBodyWriter::~TextBodyWriter()\r\n//-----------------------------------------------------------------------------\r\nTextBodyWriter::~TextBodyWriter()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: TextBodyWriter::write()\r\n//-----------------------------------------------------------------------------\r\nvoid TextBodyWriter::write(QTextStream& output) const\r\n{\r\n    output << text_;\r\n}"
  },
  {
    "path": "Plugins/VerilogGenerator/TextBodyWriter/TextBodyWriter.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: TextBodyWriter.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Janne Virtanen\r\n// Date: 09.06.2016\r\n//\r\n// Description:\r\n// Class for writing text body.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef TEXTBODYWRITER_H\r\n#define TEXTBODYWRITER_H\r\n\r\n#include \"../common/Writer.h\"\r\n#include \"../veriloggeneratorplugin_global.h\"\r\n\r\n#include <QTextStream>\r\n#include <QString>\r\n\r\nclass VERILOGGENERATORPLUGIN_EXPORT TextBodyWriter : public Writer\r\n{\r\npublic:\r\n\t//! The constructor.\r\n\tTextBodyWriter(QString const& comment);\r\n\r\n\t//! The destructor.\r\n\tvirtual ~TextBodyWriter();\r\n\r\n    /*!\r\n     *  Writes the comment to the given output.\r\n     *\r\n     *    @param [in] output   The output to write to.\r\n     */\r\n    virtual void write(QTextStream& output) const;\r\n\r\nprivate:\r\n\r\n\t// Disable copying.\r\n\tTextBodyWriter(TextBodyWriter const& rhs);\r\n\tTextBodyWriter& operator=(TextBodyWriter const& rhs);\r\n    \r\n    //! The text to write.\r\n    QString text_;\r\n};\r\n\r\n#endif // TEXTBODYWRITER_H\r\n"
  },
  {
    "path": "Plugins/VerilogGenerator/VerilogAssignmentWriter/VerilogAssignmentWriter.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: VerilogAssignmentWriter.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Janne Virtanen\n// Date: 21.01.2017\n//\n// Description:\n// Class for writing a Verilog assignments.\n//-----------------------------------------------------------------------------\n\n#include \"VerilogAssignmentWriter.h\"\n\n#include <Plugins/VerilogImport/VerilogSyntax.h>\n\n//-----------------------------------------------------------------------------\n// Function: VerilogAssignmentWriter::VerilogAssignmentWriter()\n//-----------------------------------------------------------------------------\nVerilogAssignmentWriter::VerilogAssignmentWriter(QString portWireName,\n    QSharedPointer<MetaPortAssignment> portAssignment,\n    QSharedPointer<MetaPort> mPort,\n    bool isHierPort) :\n    portWireName_(portWireName),\n    portAssignment_(portAssignment),\n    mPort_(mPort),\n    isHierarchicalPort_(isHierPort)\n{\n}\n\n//-----------------------------------------------------------------------------\n// Function: VerilogAssignmentWriter::write()\n//-----------------------------------------------------------------------------\nvoid VerilogAssignmentWriter::write(QTextStream& output) const\n{\n    QString outputLine = assignmentForPort();\n\n    if (!outputLine.isEmpty())\n    {\n        output << QStringLiteral(\"    assign \") << outputLine << QStringLiteral(\";\") << Qt::endl;\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: VerilogAssignmentWriter::assignmentForPort()\n//-----------------------------------------------------------------------------\nQString VerilogAssignmentWriter::assignmentForPort() const\n{\n    DirectionTypes::Direction direction = mPort_->port_->getDirection();\n    bool isOutPort = (direction == DirectionTypes::OUT || direction == DirectionTypes::INOUT);\n    bool isInPort = (direction == DirectionTypes::IN || direction == DirectionTypes::INOUT);\n\n    bool assignToPort = (!isHierarchicalPort_ && isInPort) || (isHierarchicalPort_ && isOutPort);\n    bool assignToWire = (isHierarchicalPort_ && isInPort) || (!isHierarchicalPort_ && isOutPort);\n    \n    QString logicalAssign = createLogicalAssignment(assignToPort);\n    QString physicalAssign = createPhysicalAssignment();\n\n    if (logicalAssign.isEmpty() || physicalAssign.isEmpty())\n    {\n        return QString();\n    }\n\n    QString invert = QString();\n    if (portAssignment_->invert_ && !isHierarchicalPort_)\n    {\n        invert = QStringLiteral(\"~\");\n    }\n\n    if (assignToPort)\n    {\n        return physicalAssign +  QStringLiteral(\" = \") + invert + logicalAssign;\n    }\n    else if (assignToWire)\n    {\n        return logicalAssign + QStringLiteral(\" = \") + invert + physicalAssign;\n    }\n    else\n    {\n        return QString();\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: VerilogAssignmentWriter::createLogicalAssignment()\n//-----------------------------------------------------------------------------\nQString VerilogAssignmentWriter::createLogicalAssignment(bool assignToPort) const\n{\n    if (portAssignment_->wire_)\n    {\n        QString logicalAssign = QStringLiteral(\"<logicalWireName>[<logicalLeft>:<logicalRight>]\");\n\n        // The bounds of the selected part wire that will be assigned to selected bounds of the component port.\n        QPair<QString, QString> logicalBounds = portAssignment_->logicalBounds_;\n\n        // The bounds of the wire that will be assigned to selected bounds of the component port.\n        QPair<QString, QString> wireBounds = portAssignment_->wire_->bounds_;\n        if (logicalBounds == wireBounds)\n        {\n            logicalAssign.remove(QStringLiteral(\"[<logicalLeft>:<logicalRight>]\"));\n        }\n        else if (logicalBounds.first == logicalBounds.second)\n        {\n            if (wireBounds.first == wireBounds.second)\n            {\n                logicalAssign.remove(QStringLiteral(\"[<logicalLeft>:<logicalRight>]\"));\n            }\n            else  // If the chosen port bounds differ, must select the bit.\n            {\n                logicalAssign.replace(QStringLiteral(\"<logicalLeft>:<logicalRight>\"), logicalBounds.first);\n            }\n        }\n        else\n        {\n            logicalAssign.replace(QStringLiteral(\"<logicalLeft>\"), logicalBounds.first);\n            logicalAssign.replace(QStringLiteral(\"<logicalRight>\"), logicalBounds.second);\n        }\n\n        QString portName = VerilogSyntax::legalizeName(portAssignment_->wire_->name_);\n        logicalAssign.replace(QStringLiteral(\"<logicalWireName>\"), portName);\n        return logicalAssign;\n    }\n    else if (assignToPort)\n    {    \n        // If a default value is assigned to a physical port, it shall be used.\n        QString defaultValue = portAssignment_->defaultValue_;\n        if (defaultValue.isEmpty())\n        {\n            defaultValue = mPort_->defaultValue_;\n        }\n\n        return defaultValue;\n    }\n    else\n    {\n        return QString();\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: VerilogAssignmentWriter::createPhysicalAssignment()\n//-----------------------------------------------------------------------------\nQString VerilogAssignmentWriter::createPhysicalAssignment() const\n{\n    QString portAssign = portWireName_ + QStringLiteral(\"[<physicalLeft>:<physicalRight>]\");\n\n    QPair<QString, QString> portBounds = portAssignment_->physicalBounds_;\n    QPair<QString, QString> logicalBounds = portAssignment_->logicalBounds_;\n    if (logicalBounds == portBounds && logicalBounds == mPort_->vectorBounds_)\n    {\n        portAssign.remove(QStringLiteral(\"[<physicalLeft>:<physicalRight>]\"));\n    }\n    // Use bounds only if they are not the same.\n    else if (portBounds.first == portBounds.second)\n    {\n        if (mPort_->vectorBounds_.first == mPort_->vectorBounds_.second)\n        {\n            portAssign.remove(QStringLiteral(\"[<physicalLeft>:<physicalRight>]\"));\n        }\n        else // If the chosen wire bounds differ, must select the bit.\n        {\n            portAssign.replace(QStringLiteral(\"<physicalLeft>:<physicalRight>\"), portBounds.first);\n        }\n    }\n    else\n    {\n        portAssign.replace(QStringLiteral(\"<physicalLeft>\"), portBounds.first);\n        portAssign.replace(QStringLiteral(\"<physicalRight>\"), portBounds.second);\n    }\n\n    return portAssign;\n}\n"
  },
  {
    "path": "Plugins/VerilogGenerator/VerilogAssignmentWriter/VerilogAssignmentWriter.h",
    "content": "//-----------------------------------------------------------------------------\n// File: VerilogAssignmentWriter.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Janne Virtanen\n// Date: 21.01.2017\n//\n// Description:\n// Class for writing a Verilog assignments.\n//-----------------------------------------------------------------------------\n\n#ifndef VERILOGASSIGNMENTWRITER_H\n#define VERILOGASSIGNMENTWRITER_H\n\n#include <Plugins/VerilogGenerator/common/Writer.h>\n#include \"../veriloggeneratorplugin_global.h\"\n\n#include \"Plugins/common/HDLParser/HDLParserCommon.h\"\n\n#include <IPXACTmodels/Component/Port.h>\n\n//-----------------------------------------------------------------------------\n//!  Class for writing a Verilog assignments.\n//-----------------------------------------------------------------------------\nclass VERILOGGENERATORPLUGIN_EXPORT VerilogAssignmentWriter : public Writer\n{\npublic:\n\n\t/*!\n     *  The constructor.\n     */\n    VerilogAssignmentWriter(QString portWireName,\n        QSharedPointer<MetaPortAssignment> portAssignment,\n        QSharedPointer<MetaPort> mPort,\n        bool isInHierPort);\n\n\t/*!\n     *  The destructor.\n     */\n    virtual ~VerilogAssignmentWriter() = default;\n\n    // Disable copying.\n    VerilogAssignmentWriter(VerilogAssignmentWriter const& rhs) = delete;\n    VerilogAssignmentWriter& operator=(VerilogAssignmentWriter const& rhs) = delete;\n\n    /*!\n     *  Writes the assignments to the given output.\n     *\n     *    @param [in] output   The output to write to.\n     */\n    virtual void write(QTextStream& output) const override;    \n    \nprivate:\n\n    /*!\n    *  Creates an assignment for a port.\n    *\n    *    @return The Verilog description of the port connection assignment.\n    */\n    QString assignmentForPort() const;\n\n    /*!\n    *  Creates the logical side of the port assignment.\n    *\n    *    @return The logical side for the port connection.\n    */\n    QString createLogicalAssignment(bool assignToPort) const;\n\n    /*!\n    *  Creates the physical side of the port assignment.\n    *\n    *    @return The physical side for the port connection.\n    */\n    QString createPhysicalAssignment() const;\n\n    //-----------------------------------------------------------------------------\n    // Data.\n    //-----------------------------------------------------------------------------\n\n    //! Ports\n    QString portWireName_;\n\n    QSharedPointer<MetaPortAssignment> portAssignment_;\n\n    QSharedPointer<MetaPort> mPort_;\n\n    bool isHierarchicalPort_;\n};\n\n#endif // VERILOGASSIGNMENTWRITER_H\n"
  },
  {
    "path": "Plugins/VerilogGenerator/VerilogGenerator.qrc",
    "content": "<RCC>\r\n    <qresource prefix=\"/icons\">\r\n        <file>verilogGenerator.png</file>\r\n    </qresource>\r\n</RCC>\r\n"
  },
  {
    "path": "Plugins/VerilogGenerator/VerilogGeneratorPlugin.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: VerilogGeneratorPlugin.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Janne Virtanen\r\n// Date: 26.01.2017\r\n//\r\n// Description:\r\n// Plugin for Verilog generation.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"VerilogGeneratorPlugin.h\"\r\n\r\n#include \"VerilogSourceHighlight.h\"\r\n\r\n#include \"VerilogWriterFactory/VerilogWriterFactory.h\"\r\n\r\n#include <KactusAPI/include/LibraryInterface.h>\r\n\r\n#include <Plugins/common/LanguageHighlighter.h>\r\n#include <Plugins/common/HDLParser/HDLCommandLineParser.h>\r\n#include <Plugins/PluginSystem/GeneratorPlugin/MessagePasser.h>\r\n#include <KactusAPI/include/IPluginUtility.h>\r\n#include <Plugins/PluginSystem/GeneratorPlugin/HDLGenerationDialog.h>\r\n\r\n#include <IPXACTmodels/Design/Design.h>\r\n#include <IPXACTmodels/DesignConfiguration/DesignConfiguration.h>\r\n\r\n#include <QDir>\r\n\r\n//----------------------------------------------------------------------------\r\n// Function: VerilogGeneratorPlugin::VerilogGeneratorPlugin()\r\n//-----------------------------------------------------------------------------\r\nVerilogGeneratorPlugin::VerilogGeneratorPlugin(): QObject(0)\r\n{\r\n    settings_.generateInterfaces_ = false;\r\n    settings_.lastFileSetName_ = \"\";\r\n    settings_.lastViewName_ = \"\";\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VerilogGeneratorPlugin::getName()\r\n//-----------------------------------------------------------------------------\r\nQString VerilogGeneratorPlugin::getName() const\r\n{\r\n    return tr(\"Verilog Generator\");\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VerilogGeneratorPlugin::getVersion()\r\n//-----------------------------------------------------------------------------\r\nQString VerilogGeneratorPlugin::getVersion() const\r\n{\r\n    return \"2.4\";\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VerilogGeneratorPlugin::getDescription()\r\n//-----------------------------------------------------------------------------\r\nQString VerilogGeneratorPlugin::getDescription() const\r\n{\r\n    return tr(\"Generates a Verilog module for a HW component or a hierarchy of modules for a HW design.\");\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VerilogGeneratorPlugin::getVendor()\r\n//-----------------------------------------------------------------------------\r\nQString VerilogGeneratorPlugin::getVendor() const\r\n{\r\n    return tr(\"Tampere University (tuni.fi)\");\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VerilogGeneratorPlugin::getLicense()\r\n//-----------------------------------------------------------------------------\r\nQString VerilogGeneratorPlugin::getLicense() const\r\n{\r\n    return tr(\"GPL2\");\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VerilogGeneratorPlugin::getLicenseHolder()\r\n//-----------------------------------------------------------------------------\r\nQString VerilogGeneratorPlugin::getLicenseHolder() const\r\n{\r\n    return tr(\"Public\");\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VerilogGeneratorPlugin::getSettingsWidget()\r\n//-----------------------------------------------------------------------------\r\nQWidget* VerilogGeneratorPlugin::getSettingsWidget()\r\n{\r\n    return nullptr;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VerilogGeneratorPlugin::getSettingsModel()\r\n//-----------------------------------------------------------------------------\r\nPluginSettingsModel* VerilogGeneratorPlugin::getSettingsModel()\r\n{\r\n    return nullptr;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VerilogGeneratorPlugin::getProgramRequirements()\r\n//-----------------------------------------------------------------------------\r\nQList<IPlugin::ExternalProgramRequirement> VerilogGeneratorPlugin::getProgramRequirements()\r\n{\r\n    return QList<IPlugin::ExternalProgramRequirement>();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VerilogGeneratorPlugin::getIcon()\r\n//-----------------------------------------------------------------------------\r\nQIcon VerilogGeneratorPlugin::getIcon() const\r\n{\r\n    return QIcon(\":icons/verilogGenerator.png\");\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VerilogGeneratorPlugin::checkGeneratorSupport()\r\n//-----------------------------------------------------------------------------\r\nbool VerilogGeneratorPlugin::checkGeneratorSupport(QSharedPointer<Component const> component,\r\n    QSharedPointer<Design const> design,\r\n    QSharedPointer<DesignConfiguration const> designConfiguration) const\r\n{\r\n    // If design or design configuration exists, their implementation overrides the top component.\r\n    if (design)\r\n    {\r\n        return design->getImplementation() == KactusAttribute::HW;\r\n    }\r\n\r\n    if (designConfiguration)\r\n    {\r\n        return designConfiguration->getImplementation() == KactusAttribute::HW;\r\n    }\r\n    \r\n    // Else the availability is determined based on the top component.\r\n    return component && component->getImplementation() == KactusAttribute::HW;    \r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VerilogGeneratorPlugin::runGenerator()\r\n//-----------------------------------------------------------------------------\r\nvoid VerilogGeneratorPlugin::runGenerator(IPluginUtility* utility, \r\n    QSharedPointer<Component> component,\r\n    QSharedPointer<Design> design,\r\n    QSharedPointer<DesignConfiguration> designConfiguration)\r\n{\r\n    // First state we are running. Tell the version.\r\n    utility->printInfo(tr(\"Running %1 %2.\").arg(getName(), getVersion()));\r\n\r\n    // Must have a component under any condition.\r\n    if (component.isNull())\r\n    {\r\n        utility->printError(tr(\"Null component given as a parameter.\"));\r\n        return;\r\n    }\r\n\r\n    MessagePasser messages;\r\n\r\n    GenerationTuple input;\r\n    input.component = component;\r\n    input.design = design;\r\n    input.designConfiguration = designConfiguration;\r\n    input.messages = &messages;\r\n\r\n    VerilogWriterFactory factory(utility->getLibraryInterface(), &messages, &settings_,\r\n        utility->getKactusVersion(), getVersion());\r\n\r\n    // Create model for the configuration widget.\r\n    QSharedPointer<GenerationControl> configuration(new GenerationControl\r\n        (utility->getLibraryInterface(), &factory, input, &settings_));\r\n\r\n    // Create the dialog and execute: The user will accept/decline the configuration.\r\n    HDLGenerationDialog dialog(configuration, QStringLiteral(\"Verilog\"), utility->getParentWidget());\r\n    \r\n    LanguageHighlighter highlighter(0);\r\n    VerilogSourceHighlight style;\r\n    style.apply(&highlighter);\r\n\r\n    dialog.setPreviewHighlighter(&highlighter);\r\n\r\n    connect(&messages, SIGNAL(errorMessage(const QString&)),\r\n        &dialog, SLOT(onErrorMessage(const QString&)), Qt::UniqueConnection);\r\n    connect(&messages, SIGNAL(noticeMessage(const QString&)),\r\n       & dialog, SLOT(onNoticeMessage(const QString&)), Qt::UniqueConnection);\r\n\r\n    dialog.onViewChanged();\r\n\r\n    if (dialog.exec() == QDialog::Accepted)\r\n    {\r\n        utility->printInfo(tr(\"Generation complete.\"));\r\n    }\r\n    else\r\n    {\r\n        utility->printInfo(tr(\"Generation aborted.\"));    \r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VerilogGeneratorPlugin::getOutputFormat()\r\n//-----------------------------------------------------------------------------\r\nQString VerilogGeneratorPlugin::getOutputFormat() const\r\n{\r\n    return QStringLiteral(\"Verilog\");\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VerilogGeneratorPlugin::runGenerator()\r\n//-----------------------------------------------------------------------------\r\nvoid VerilogGeneratorPlugin::runGenerator(IPluginUtility* utility,\r\n    QSharedPointer<Component> component,\r\n    QSharedPointer<Design> design,\r\n    QSharedPointer<DesignConfiguration> designConfiguration,\r\n    QString const& viewName,\r\n    QString const& outputDirectory)\r\n{\r\n    utility->printInfo(tr(\"Running %1 %2.\").arg(getName(), getVersion()));\r\n\r\n    utility->printInfo(tr(\"Running generation for %1 and view '%2'.\").arg(component->getVlnv().toString(),\r\n        viewName));\r\n\r\n    QDir targetDirectory;\r\n    if (!targetDirectory.mkpath(outputDirectory))\r\n    {\r\n        utility->printError(tr(\"Could not create target directory: %1\").arg(outputDirectory));\r\n        return;\r\n    }\r\n\r\n    utility->printInfo(tr(\"Target directory: %1\").arg(outputDirectory));\r\n\r\n    settings_.lastViewName_ = viewName;    \r\n\r\n    MessagePasser messages;\r\n\r\n    GenerationTuple input;\r\n    input.component = component;\r\n    input.design = design;\r\n    input.designConfiguration = designConfiguration;\r\n    input.messages = &messages;\r\n\r\n    VerilogWriterFactory factory(utility->getLibraryInterface(), &messages, &settings_,\r\n        utility->getKactusVersion(), getVersion());\r\n\r\n    // Use configuration to drive the generation.\r\n    GenerationControl configuration(utility->getLibraryInterface(), &factory, input, &settings_);\r\n    configuration.getOutputControl()->setOutputPath(outputDirectory);\r\n    configuration.getViewSelection()->setSaveToFileset(false);\r\n\r\n    configuration.parseDocuments();\r\n    if (configuration.writeDocuments())\r\n    {\r\n        utility->printInfo(tr(\"Generation complete.\"));\r\n    }\r\n    else\r\n    {\r\n        utility->printInfo(tr(\"Generation failed.\"));\r\n    }\r\n}\r\n"
  },
  {
    "path": "Plugins/VerilogGenerator/VerilogGeneratorPlugin.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: VerilogGeneratorPlugin.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Janne Virtanen\r\n// Date: 26.01.2017\r\n//\r\n// Description:\r\n// Plugin for Verilog generation.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef VERILOGGENERATORPLUGIN_H\r\n#define VERILOGGENERATORPLUGIN_H\r\n\r\n#include \"veriloggeneratorplugin_global.h\"\r\n\r\n#include <KactusAPI/include/IGeneratorPlugin.h>\r\n#include <KactusAPI/include/CLIGenerator.h>\r\n#include <Plugins/PluginSystem/GeneratorPlugin/GenerationControl.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Plugin for structural Verilog generation.\r\n//-----------------------------------------------------------------------------\r\nclass VERILOGGENERATORPLUGIN_EXPORT VerilogGeneratorPlugin : public QObject, public IGeneratorPlugin, \r\n    public CLIGenerator\r\n{\r\n    Q_OBJECT\r\n    Q_PLUGIN_METADATA(IID \"kactus2.plugins.veriloggeneratorplugin\" FILE \"veriloggeneratorplugin.json\")\r\n\r\n    Q_INTERFACES(IPlugin)\r\n    Q_INTERFACES(IGeneratorPlugin)\r\n\r\npublic:\r\n\r\n\t//! The constructor.\r\n\tVerilogGeneratorPlugin();\r\n\r\n\t//! The destructor.\r\n\tvirtual ~VerilogGeneratorPlugin() = default;\r\n\r\n    // Disable copying.\r\n    VerilogGeneratorPlugin(VerilogGeneratorPlugin const& rhs) = delete;\r\n    VerilogGeneratorPlugin& operator=(VerilogGeneratorPlugin const& rhs) = delete;\r\n\r\n    /*!\r\n     *  Returns the name of the plugin.\r\n     */\r\n    virtual QString getName() const;\r\n\r\n    /*!\r\n     *  Returns the version of the plugin.\r\n     */\r\n    virtual QString getVersion() const;\r\n\r\n    /*!\r\n     *  Returns the description of the plugin.\r\n     */\r\n    virtual QString getDescription() const;\r\n\r\n    /*!\r\n     *  Returns the vendor of the plugin.\r\n     */\r\n    virtual QString getVendor() const;\r\n\r\n    /*!\r\n     *  Returns the license of the plugin.\r\n     */\r\n    virtual QString getLicense() const;\r\n\r\n    /*!\r\n     *  Returns the license holder of the plugin.\r\n     */\r\n    virtual QString getLicenseHolder() const;\r\n    \r\n    /*!\r\n     *  Returns the settings widget.\r\n     */\r\n    virtual QWidget* getSettingsWidget();\r\n\r\n    /*!\r\n     *  This is used to access the settings modified by function getSettingsWidget().\r\n     */\r\n    virtual PluginSettingsModel* getSettingsModel();\r\n\r\n    /*!\r\n     *  Returns the external program requirements of the plugin.\r\n     */\r\n    virtual QList<ExternalProgramRequirement> getProgramRequirements();\r\n\r\n    /*!\r\n     *  Returns the icon for the generator.\r\n     */\r\n    virtual QIcon getIcon() const;\r\n    \r\n        /*!\r\n     *  Checks whether the generator may run for the given component or design. \r\n     *\r\n     *    @param [in] component\t        The component for which to check support. If design is not null, component\r\n\t *                                      will refer to design or designConfiguration.\r\n     *    @param [in] design\t            The design, if the generator is ran for a design.\r\n     *    @param [in] designConfiguration The design configuration for design, if it is not null.\r\n     *\r\n     *    @return True, if the generator may run the given component. Otherwise false.\r\n     */\r\n    virtual bool checkGeneratorSupport(QSharedPointer<Component const> component,\r\n        QSharedPointer<Design const> design,\r\n        QSharedPointer<DesignConfiguration const> designConfiguration) const;\r\n\r\n    /*!\r\n     *  Runs the generation, creating new files and/or modifying the IP-XACT metadata. The function has\r\n\t *  also access to the parent window widget, so that it can show dialogs for the user to aid the generation.\r\n     *\r\n     *    @param [in] utility\t\t\t    The plugin utility interface.\r\n     *    @param [in] component\t        The component for which to check support. If design is not null, component\r\n     *                                      will refer to design or designConfiguration.\r\n     *    @param [in] design\t            The design, if the generator is ran for a design.\r\n     *    @param [in] designConfiguration The design configuration for design, if it is not null.\r\n     */\r\n    virtual void runGenerator(IPluginUtility* utility, \r\n        QSharedPointer<Component> component,\r\n        QSharedPointer<Design> design,\r\n        QSharedPointer<DesignConfiguration> designConfiguration);\r\n\r\n    /*!\r\n     *  Gets the output format generated by the plugin.\r\n     *\r\n     *    @return The output file format generated by the plugin.\r\n     */\r\n    virtual QString getOutputFormat() const override final;\r\n\r\n    /*!\r\n      * Runs the generation.\r\n      *\r\n      *    @param [in] utility              Utilities for enabling plugin execution.\r\n      *    @param [in] component            The component to run the generation for.\r\n      *    @param [in] design               The design to run the generation for.\r\n      *    @param [in] designConfiguration  The design configuration to run the generation for.\r\n      *    @param [in] viewName             The component view name to run the generation for.\r\n      *    @param [in] outputDirectory      The output directory for the generation results.\r\n      */\r\n     virtual void runGenerator(IPluginUtility* utility,\r\n         QSharedPointer<Component> component,\r\n         QSharedPointer<Design> design,\r\n         QSharedPointer<DesignConfiguration> designConfiguration,\r\n         QString const& viewName,\r\n         QString const& outputDirectory) override final;\r\n\r\nprivate:\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! The last values used by the generation.\r\n    GenerationSettings settings_;\r\n};\r\n\r\n#endif // VERILOGGENERATORPLUGIN_H"
  },
  {
    "path": "Plugins/VerilogGenerator/VerilogGeneratorPlugin.pri",
    "content": "# ----------------------------------------------------\r\n# This file is generated by the Qt Visual Studio Tools.\r\n# ------------------------------------------------------\r\n\r\n# This is a reminder that you are using a generated .pro file.\r\n# Remove it when you are finished editing this file.\r\nmessage(\"You are running qmake on a generated .pro file. This may not work!\")\r\n\r\n\r\nHEADERS += ../../IPXACTmodels/utilities/ComponentSearch.h \\\r\n    ../../IPXACTmodels/utilities/Search.h \\\r\n    ../common/HDLParser/HDLCommandLineParser.h \\\r\n    ../common/SourceHighlightStyle.h \\\r\n    ./VerilogSourceHighlight.h \\\r\n    ../VerilogImport/VerilogSyntax.h \\\r\n    ../common/LanguageHighlighter.h \\\r\n    ./VerilogGeneratorPlugin.h \\\r\n    ./common/Writer.h \\\r\n    ./common/WriterGroup.h \\\r\n    ./ComponentInstanceVerilogWriter/ComponentInstanceVerilogWriter.h \\\r\n    ./ComponentVerilogWriter/ComponentVerilogWriter.h \\\r\n    ./veriloggeneratorplugin_global.h \\\r\n    ./ModelParameterVerilogWriter/ModelParameterVerilogWriter.h \\\r\n    ../common/PortSorter/InterfaceDirectionNameSorter.h \\\r\n    ../common/PortSorter/PortSorter.h \\\r\n    ./VerilogHeaderWriter/VerilogHeaderWriter.h \\\r\n    ./VerilogWireWriter/VerilogWireWriter.h \\\r\n    ./CommentWriter/CommentWriter.h \\\r\n    ../../editors/common/TopComponentParameterFinder.h \\\r\n    ./TextBodyWriter/TextBodyWriter.h \\\r\n    ./VerilogInterconnectionWriter/VerilogInterconnectionWriter.h \\\r\n    ../PluginSystem/GeneratorPlugin/IWriterFactory.h \\\r\n    ./VerilogWriterFactory/VerilogDocument.h \\\r\n    ./VerilogWriterFactory/VerilogWriterFactory.h \\\r\n    ./VerilogAssignmentWriter/VerilogAssignmentWriter.h \\\r\n    ../PluginSystem/GeneratorPlugin/GenerationControl.h \\\r\n    ../PluginSystem/GeneratorPlugin/OutputControl.h \\\r\n    ../PluginSystem/GeneratorPlugin/ViewSelection.h \\\r\n    ../PluginSystem/GeneratorPlugin/MessagePasser.h \\\r\n    ../../mainwindow/MessageConsole/messageconsole.h \\\r\n    ../PluginSystem/GeneratorPlugin/HDLGenerationDialog.h \\\r\n    ../PluginSystem/GeneratorPlugin/ViewSelectionWidget.h \\\r\n    ../PluginSystem/GeneratorPlugin/FileOutputWidget.h \\\r\n    ../common/HDLParser/HDLParserCommon.h \\\r\n    ../common/HDLParser/MetaComponent.h \\\r\n    ../common/HDLParser/MetaDesign.h \\\r\n    ../common/HDLParser/MetaInstance.h \\\r\n    ./VerilogPortWriter/VerilogPortWriter.h \\\r\n    ./VerilogPortWriter/VerilogTopDefaultWriter.h \\\r\n    ../../common/expressions/utilities.h\r\nSOURCES += ../../IPXACTmodels/utilities/ComponentSearch.cpp \\\r\n    ../common/HDLParser/HDLCommandLineParser.cpp \\\r\n    ../common/LanguageHighlighter.cpp \\\r\n    ../common/SourceHighlightStyle.cpp \\\r\n    ../VerilogImport/VerilogSyntax.cpp \\\r\n    ./VerilogGeneratorPlugin.cpp \\\r\n    ./VerilogSourceHighlight.cpp \\\r\n    ./ComponentInstanceVerilogWriter/ComponentInstanceVerilogWriter.cpp \\\r\n    ./ComponentVerilogWriter/ComponentVerilogWriter.cpp \\\r\n    ./ModelParameterVerilogWriter/ModelParameterVerilogWriter.cpp \\\r\n    ../common/PortSorter/InterfaceDirectionNameSorter.cpp \\\r\n    ./VerilogHeaderWriter/VerilogHeaderWriter.cpp \\\r\n    ./VerilogWireWriter/VerilogWireWriter.cpp \\\r\n    ./CommentWriter/CommentWriter.cpp \\\r\n    ./common/WriterGroup.cpp \\\r\n    ../../editors/common/TopComponentParameterFinder.cpp \\\r\n    ./TextBodyWriter/TextBodyWriter.cpp \\\r\n    ./VerilogInterconnectionWriter/VerilogInterconnectionWriter.cpp \\\r\n    ./VerilogWriterFactory/VerilogDocument.cpp \\\r\n    ./VerilogWriterFactory/VerilogWriterFactory.cpp \\\r\n    ./VerilogAssignmentWriter/VerilogAssignmentWriter.cpp \\\r\n    ../PluginSystem/GeneratorPlugin/GenerationControl.cpp \\\r\n    ../PluginSystem/GeneratorPlugin/MessagePasser.cpp \\\r\n    ../PluginSystem/GeneratorPlugin/OutputControl.cpp \\\r\n    ../PluginSystem/GeneratorPlugin/ViewSelection.cpp \\\r\n    ../../mainwindow/MessageConsole/messageconsole.cpp \\\r\n    ../PluginSystem/GeneratorPlugin/FileOutputWidget.cpp \\\r\n    ../PluginSystem/GeneratorPlugin/HDLGenerationDialog.cpp \\\r\n    ../PluginSystem/GeneratorPlugin/ViewSelectionWidget.cpp \\\r\n    ../common/HDLParser/MetaComponent.cpp \\\r\n    ../common/HDLParser/MetaDesign.cpp \\\r\n    ../common/HDLParser/MetaInstance.cpp \\\r\n    ./VerilogPortWriter/VerilogPortWriter.cpp \\\r\n    ./VerilogPortWriter/VerilogTopDefaultWriter.cpp \\\r\n    ../../common/expressions/utilities.cpp\r\nRESOURCES += VerilogGenerator.qrc\r\n"
  },
  {
    "path": "Plugins/VerilogGenerator/VerilogGeneratorPlugin.pro",
    "content": "# ----------------------------------------------------\r\n# This file is generated by the Qt Visual Studio Add-in.\r\n# ------------------------------------------------------\r\n\r\nTEMPLATE = lib\r\n\r\nQT += core xml widgets gui\r\nCONFIG += c++11\r\nDEFINES += VERILOGGENERATORPLUGIN_LIB\r\n\r\nINCLUDEPATH += ./GeneratedFiles \\\r\n    ./../.. \\\r\n    .\r\n\r\nCONFIG(debug, debug|release) {\r\n    # debug mode\r\n    LIBS += \\\r\n        -L../../executable -lIPXACTmodelsd \\\r\n        -L../../executable -lKactusAPId\r\n\r\n    MOC_DIR += ./GeneratedFiles/Debug\r\n    OBJECTS_DIR += Debug\r\n    TARGET = VerilogGeneratorPlugind\r\n\r\n} else {\r\n    # release mode \r\n    LIBS += \\\r\n        -L../../executable -lIPXACTmodels \\\r\n        -L../../executable -lKactusAPI\r\n    \r\n    MOC_DIR += ./GeneratedFiles/Release\r\n    OBJECTS_DIR += Release\r\n    TARGET = VerilogGeneratorPlugin\r\n}\r\nDESTDIR = ../../executable/Plugins\r\n\r\nDEPENDPATH += .\r\nUI_DIR += ./GeneratedFiles\r\nRCC_DIR += ./GeneratedFiles\r\n\r\ninclude(VerilogGeneratorPlugin.pri)\r\n\r\ntarget.path = $$plugin_path\r\nINSTALLS += target\r\n"
  },
  {
    "path": "Plugins/VerilogGenerator/VerilogGeneratorPlugin.vcxproj",
    "content": "﻿<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n<Project DefaultTargets=\"Build\" ToolsVersion=\"15.0\" xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">\r\n  <ItemGroup Label=\"ProjectConfigurations\">\r\n    <ProjectConfiguration Include=\"Debug|x64\">\r\n      <Configuration>Debug</Configuration>\r\n      <Platform>x64</Platform>\r\n    </ProjectConfiguration>\r\n    <ProjectConfiguration Include=\"Release|x64\">\r\n      <Configuration>Release</Configuration>\r\n      <Platform>x64</Platform>\r\n    </ProjectConfiguration>\r\n  </ItemGroup>\r\n  <PropertyGroup Label=\"Globals\">\r\n    <ProjectGuid>{DF1D0F97-B7D8-4DF3-AB71-B2350E08F0F4}</ProjectGuid>\r\n    <Keyword>QtVS_v304</Keyword>\r\n    <WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>\r\n    <QtMsBuild Condition=\"'$(QtMsBuild)'=='' or !Exists('$(QtMsBuild)\\qt.targets')\">$(MSBuildProjectDirectory)\\QtMsBuild</QtMsBuild>\r\n  </PropertyGroup>\r\n  <Import Project=\"$(VCTargetsPath)\\Microsoft.Cpp.Default.props\" />\r\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\" Label=\"Configuration\">\r\n    <ConfigurationType>DynamicLibrary</ConfigurationType>\r\n    <PlatformToolset>v143</PlatformToolset>\r\n  </PropertyGroup>\r\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\" Label=\"Configuration\">\r\n    <ConfigurationType>DynamicLibrary</ConfigurationType>\r\n    <PlatformToolset>v143</PlatformToolset>\r\n  </PropertyGroup>\r\n  <Import Project=\"$(VCTargetsPath)\\Microsoft.Cpp.props\" />\r\n  <Target Name=\"QtMsBuildNotFound\" BeforeTargets=\"CustomBuild;ClCompile\" Condition=\"!Exists('$(QtMsBuild)\\qt.targets') or !Exists('$(QtMsBuild)\\qt.props')\">\r\n    <Message Importance=\"High\" Text=\"QtMsBuild: could not locate qt.targets, qt.props; project may not build correctly.\" />\r\n  </Target>\r\n  <ImportGroup Label=\"ExtensionSettings\">\r\n  </ImportGroup>\r\n  <ImportGroup Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\" Label=\"PropertySheets\">\r\n    <Import Project=\"$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props\" Condition=\"exists('$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props')\" Label=\"LocalAppDataPlatform\" />\r\n  </ImportGroup>\r\n  <ImportGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\" Label=\"PropertySheets\">\r\n    <Import Project=\"$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props\" Condition=\"exists('$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props')\" Label=\"LocalAppDataPlatform\" />\r\n  </ImportGroup>\r\n  <PropertyGroup Label=\"UserMacros\" />\r\n  <ImportGroup Condition=\"Exists('$(QtMsBuild)\\qt_defaults.props')\">\r\n    <Import Project=\"$(QtMsBuild)\\qt_defaults.props\" />\r\n  </ImportGroup>\r\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n    <OutDir>$(SolutionDir)executable\\Plugins\\</OutDir>\r\n  </PropertyGroup>\r\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n    <OutDir>$(SolutionDir)executable\\Plugins\\</OutDir>\r\n    <TargetName>$(ProjectName)</TargetName>\r\n  </PropertyGroup>\r\n  <PropertyGroup Label=\"QtSettings\" Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n    <QtInstall>6.2.4</QtInstall>\r\n    <QtModules>core;gui;widgets;xml</QtModules>\r\n  </PropertyGroup>\r\n  <PropertyGroup Label=\"QtSettings\" Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n    <QtInstall>6.2.4</QtInstall>\r\n    <QtModules>core;gui;widgets;xml</QtModules>\r\n  </PropertyGroup>\r\n  <ImportGroup Condition=\"Exists('$(QtMsBuild)\\qt.props')\">\r\n    <Import Project=\"$(QtMsBuild)\\qt.props\" />\r\n  </ImportGroup>\r\n  <PropertyGroup>\r\n    <_ProjectFileVersion>10.0.40219.1</_ProjectFileVersion>\r\n  </PropertyGroup>\r\n  <ItemDefinitionGroup Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n    <ClCompile>\r\n      <PreprocessorDefinitions>UNICODE;WIN32;WIN64;VERILOGGENERATORPLUGIN_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>\r\n      <AdditionalIncludeDirectories>.\\GeneratedFiles\\$(ConfigurationName);.\\GeneratedFiles;..\\..\\;.;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\r\n      <Optimization>Disabled</Optimization>\r\n      <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>\r\n      <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>\r\n      <TreatWChar_tAsBuiltInType>true</TreatWChar_tAsBuiltInType>\r\n      <LanguageStandard>stdcpp17</LanguageStandard>\r\n      <AdditionalOptions>/Zc:__cplusplus %(AdditionalOptions)</AdditionalOptions>\r\n      <MultiProcessorCompilation>true</MultiProcessorCompilation>\r\n    </ClCompile>\r\n    <Link>\r\n      <SubSystem>Windows</SubSystem>\r\n      <OutputFile>$(OutDir)\\$(ProjectName).dll</OutputFile>\r\n      <AdditionalLibraryDirectories>..\\..\\executable;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>\r\n      <GenerateDebugInformation>true</GenerateDebugInformation>\r\n      <AdditionalDependencies>IPXACTmodelsd.lib;KactusAPId.lib;%(AdditionalDependencies)</AdditionalDependencies>\r\n    </Link>\r\n    <QtMoc>\r\n      <ExecutionDescription>Moc'ing %(Identity)...</ExecutionDescription>\r\n      <DynamicSource>output</DynamicSource>\r\n      <QtMocDir>.\\GeneratedFiles\\$(ConfigurationName)</QtMocDir>\r\n      <QtMocFileName>moc_%(Filename).cpp</QtMocFileName>\r\n    </QtMoc>\r\n    <QtRcc>\r\n      <InitFuncName>%(Filename)</InitFuncName>\r\n      <Compression>default</Compression>\r\n      <NoCompression>true</NoCompression>\r\n      <ExecutionDescription>Rcc'ing %(Identity)...</ExecutionDescription>\r\n      <QtRccDir>.\\GeneratedFiles</QtRccDir>\r\n      <QtRccFileName>qrc_%(Filename).cpp</QtRccFileName>\r\n    </QtRcc>\r\n  </ItemDefinitionGroup>\r\n  <ItemDefinitionGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n    <ClCompile>\r\n      <PreprocessorDefinitions>UNICODE;WIN32;WIN64;QT_NO_DEBUG;NDEBUG;VERILOGGENERATORPLUGIN_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>\r\n      <AdditionalIncludeDirectories>.\\GeneratedFiles\\$(ConfigurationName);.\\GeneratedFiles;..\\..;.;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\r\n      <DebugInformationFormat>\r\n      </DebugInformationFormat>\r\n      <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>\r\n      <TreatWChar_tAsBuiltInType>true</TreatWChar_tAsBuiltInType>\r\n      <MultiProcessorCompilation>true</MultiProcessorCompilation>\r\n      <AdditionalOptions>/Zc:__cplusplus %(AdditionalOptions)</AdditionalOptions>\r\n      <LanguageStandard>stdcpp17</LanguageStandard>\r\n    </ClCompile>\r\n    <Link>\r\n      <SubSystem>Windows</SubSystem>\r\n      <OutputFile>$(OutDir)$(ProjectName).dll</OutputFile>\r\n      <AdditionalLibraryDirectories>..\\..\\executable;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>\r\n      <GenerateDebugInformation>false</GenerateDebugInformation>\r\n      <AdditionalDependencies>IPXACTmodels.lib;KactusAPI.lib;%(AdditionalDependencies)</AdditionalDependencies>\r\n    </Link>\r\n    <QtMoc>\r\n      <ExecutionDescription>Moc'ing %(Identity)...</ExecutionDescription>\r\n      <DynamicSource>output</DynamicSource>\r\n      <QtMocDir>.\\GeneratedFiles\\$(ConfigurationName)</QtMocDir>\r\n      <QtMocFileName>moc_%(Filename).cpp</QtMocFileName>\r\n    </QtMoc>\r\n    <QtRcc>\r\n      <InitFuncName>%(Filename)</InitFuncName>\r\n      <Compression>default</Compression>\r\n      <NoCompression>true</NoCompression>\r\n      <ExecutionDescription>Rcc'ing %(Identity)...</ExecutionDescription>\r\n      <QtRccDir>.\\GeneratedFiles</QtRccDir>\r\n      <QtRccFileName>qrc_%(Filename).cpp</QtRccFileName>\r\n    </QtRcc>\r\n  </ItemDefinitionGroup>\r\n  <ItemGroup>\r\n    <ClCompile Include=\"..\\..\\common\\expressions\\utilities.cpp\" />\r\n    <ClCompile Include=\"..\\..\\editors\\common\\TopComponentParameterFinder.cpp\" />\r\n    <ClCompile Include=\"..\\..\\IPXACTmodels\\utilities\\ComponentSearch.cpp\" />\r\n    <ClCompile Include=\"..\\..\\mainwindow\\MessageConsole\\messageconsole.cpp\" />\r\n    <ClCompile Include=\"..\\common\\HDLParser\\HDLCommandLineParser.cpp\" />\r\n    <ClCompile Include=\"..\\common\\HDLParser\\MetaComponent.cpp\" />\r\n    <ClCompile Include=\"..\\common\\HDLParser\\MetaDesign.cpp\" />\r\n    <ClCompile Include=\"..\\common\\HDLParser\\MetaInstance.cpp\" />\r\n    <ClCompile Include=\"..\\common\\LanguageHighlighter.cpp\" />\r\n    <ClCompile Include=\"..\\common\\PortSorter\\InterfaceDirectionNameSorter.cpp\" />\r\n    <ClCompile Include=\"..\\common\\SourceHighlightStyle.cpp\" />\r\n    <ClCompile Include=\"..\\PluginSystem\\GeneratorPlugin\\AddToFilesetWidget.cpp\" />\r\n    <ClCompile Include=\"..\\PluginSystem\\GeneratorPlugin\\FileOutputWidget.cpp\" />\r\n    <ClCompile Include=\"..\\PluginSystem\\GeneratorPlugin\\GenerationControl.cpp\" />\r\n    <ClCompile Include=\"..\\PluginSystem\\GeneratorPlugin\\HDLGenerationDialog.cpp\" />\r\n    <ClCompile Include=\"..\\PluginSystem\\GeneratorPlugin\\MessagePasser.cpp\" />\r\n    <ClCompile Include=\"..\\PluginSystem\\GeneratorPlugin\\OutputControl.cpp\" />\r\n    <ClCompile Include=\"..\\PluginSystem\\GeneratorPlugin\\ViewSelection.cpp\" />\r\n    <ClCompile Include=\"..\\PluginSystem\\GeneratorPlugin\\ViewSelectionWidget.cpp\" />\r\n    <ClCompile Include=\"..\\VerilogImport\\VerilogSyntax.cpp\" />\r\n    <ClCompile Include=\"CommentWriter\\CommentWriter.cpp\" />\r\n    <ClCompile Include=\"common\\WriterGroup.cpp\" />\r\n    <ClCompile Include=\"ComponentInstanceVerilogWriter\\ComponentInstanceVerilogWriter.cpp\" />\r\n    <ClCompile Include=\"ComponentVerilogWriter\\ComponentVerilogWriter.cpp\" />\r\n    <ClCompile Include=\"ModelParameterVerilogWriter\\ModelParameterVerilogWriter.cpp\" />\r\n    <ClCompile Include=\"TextBodyWriter\\TextBodyWriter.cpp\" />\r\n    <ClCompile Include=\"VerilogAssignmentWriter\\VerilogAssignmentWriter.cpp\" />\r\n    <ClCompile Include=\"VerilogGeneratorPlugin.cpp\" />\r\n    <ClCompile Include=\"VerilogHeaderWriter\\VerilogHeaderWriter.cpp\" />\r\n    <ClCompile Include=\"VerilogInterconnectionWriter\\VerilogInterconnectionWriter.cpp\" />\r\n    <ClCompile Include=\"VerilogPortWriter\\VerilogPortWriter.cpp\" />\r\n    <ClCompile Include=\"VerilogPortWriter\\VerilogTopDefaultWriter.cpp\" />\r\n    <ClCompile Include=\"VerilogSourceHighlight.cpp\" />\r\n    <ClCompile Include=\"VerilogWireWriter\\VerilogWireWriter.cpp\" />\r\n    <ClCompile Include=\"VerilogWriterFactory\\VerilogDocument.cpp\" />\r\n    <ClCompile Include=\"VerilogWriterFactory\\VerilogWriterFactory.cpp\" />\r\n  </ItemGroup>\r\n  <ItemGroup>\r\n    <ClInclude Include=\"..\\..\\common\\expressions\\utilities.h\" />\r\n    <ClInclude Include=\"..\\..\\editors\\common\\TopComponentParameterFinder.h\" />\r\n    <QtMoc Include=\"..\\..\\mainwindow\\MessageConsole\\messageconsole.h\">\r\n    </QtMoc>\r\n    <ClInclude Include=\"..\\..\\IPXACTmodels\\utilities\\ComponentSearch.h\" />\r\n    <ClInclude Include=\"..\\..\\IPXACTmodels\\utilities\\Search.h\" />\r\n    <ClInclude Include=\"..\\common\\HDLParser\\HDLCommandLineParser.h\" />\r\n    <ClInclude Include=\"..\\common\\HDLParser\\HDLParserCommon.h\" />\r\n    <ClInclude Include=\"..\\common\\HDLParser\\MetaComponent.h\" />\r\n    <ClInclude Include=\"..\\common\\HDLParser\\MetaDesign.h\" />\r\n    <ClInclude Include=\"..\\common\\HDLParser\\MetaInstance.h\" />\r\n    <QtMoc Include=\"..\\common\\LanguageHighlighter.h\">\r\n    </QtMoc>\r\n    <ClInclude Include=\"..\\common\\PortSorter\\InterfaceDirectionNameSorter.h\" />\r\n    <ClInclude Include=\"..\\common\\PortSorter\\PortSorter.h\" />\r\n    <ClInclude Include=\"..\\common\\SourceHighlightStyle.h\" />\r\n    <QtMoc Include=\"..\\PluginSystem\\GeneratorPlugin\\AddToFilesetWidget.h\" />\r\n    <ClInclude Include=\"..\\PluginSystem\\GeneratorPlugin\\GenerationControl.h\" />\r\n    <QtMoc Include=\"..\\PluginSystem\\GeneratorPlugin\\HDLGenerationDialog.h\">\r\n    </QtMoc>\r\n    <ClInclude Include=\"..\\PluginSystem\\GeneratorPlugin\\IWriterFactory.h\" />\r\n    <QtMoc Include=\"..\\PluginSystem\\GeneratorPlugin\\MessagePasser.h\">\r\n    </QtMoc>\r\n    <ClInclude Include=\"..\\PluginSystem\\GeneratorPlugin\\OutputControl.h\" />\r\n    <ClInclude Include=\"VerilogAssignmentWriter\\VerilogAssignmentWriter.h\" />\r\n    <ClInclude Include=\"VerilogPortWriter\\VerilogPortWriter.h\" />\r\n    <ClInclude Include=\"VerilogPortWriter\\VerilogTopDefaultWriter.h\" />\r\n    <ClInclude Include=\"VerilogSourceHighlight.h\" />\r\n    <ClInclude Include=\"VerilogWriterFactory\\VerilogDocument.h\" />\r\n    <CustomBuild Include=\"VerilogWriterFactory\\VerilogWriterFactory.h\">\r\n      <AdditionalInputs Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">%(AdditionalInputs)</AdditionalInputs>\r\n      <Message Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n      </Message>\r\n      <Outputs Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n      </Outputs>\r\n      <Command Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n      </Command>\r\n      <AdditionalInputs Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">%(AdditionalInputs)</AdditionalInputs>\r\n      <Message Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n      </Message>\r\n      <Outputs Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n      </Outputs>\r\n      <Command Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n      </Command>\r\n    </CustomBuild>\r\n    <QtMoc Include=\"..\\PluginSystem\\GeneratorPlugin\\ViewSelectionWidget.h\">\r\n    </QtMoc>\r\n    <QtMoc Include=\"..\\PluginSystem\\GeneratorPlugin\\FileOutputWidget.h\">\r\n    </QtMoc>\r\n    <ClInclude Include=\"..\\PluginSystem\\GeneratorPlugin\\ViewSelection.h\" />\r\n    <ClInclude Include=\"..\\VerilogImport\\VerilogSyntax.h\" />\r\n    <ClInclude Include=\"CommentWriter\\CommentWriter.h\" />\r\n    <ClInclude Include=\"common\\Writer.h\" />\r\n    <ClInclude Include=\"common\\WriterGroup.h\" />\r\n    <ClInclude Include=\"ComponentInstanceVerilogWriter\\ComponentInstanceVerilogWriter.h\" />\r\n    <ClInclude Include=\"ComponentVerilogWriter\\ComponentVerilogWriter.h\" />\r\n    <ClInclude Include=\"ModelParameterVerilogWriter\\ModelParameterVerilogWriter.h\" />\r\n    <QtMoc Include=\"VerilogGeneratorPlugin.h\">\r\n    </QtMoc>\r\n    <ClInclude Include=\"TextBodyWriter\\TextBodyWriter.h\" />\r\n    <ClInclude Include=\"VerilogHeaderWriter\\VerilogHeaderWriter.h\" />\r\n    <ClInclude Include=\"VerilogInterconnectionWriter\\VerilogInterconnectionWriter.h\" />\r\n    <ClInclude Include=\"VerilogWireWriter\\VerilogWireWriter.h\" />\r\n    <ClInclude Include=\"veriloggeneratorplugin_global.h\" />\r\n  </ItemGroup>\r\n  <ItemGroup>\r\n    <None Include=\"verilogGenerator.png\" />\r\n    <QtRcc Include=\"VerilogGenerator.qrc\">\r\n    </QtRcc>\r\n  </ItemGroup>\r\n  <Import Project=\"$(VCTargetsPath)\\Microsoft.Cpp.targets\" />\r\n  <ImportGroup Condition=\"Exists('$(QtMsBuild)\\qt.targets')\">\r\n    <Import Project=\"$(QtMsBuild)\\qt.targets\" />\r\n  </ImportGroup>\r\n  <ImportGroup Label=\"ExtensionTargets\">\r\n  </ImportGroup>\r\n  <ProjectExtensions>\r\n    <VisualStudio>\r\n      <UserProperties />\r\n    </VisualStudio>\r\n  </ProjectExtensions>\r\n</Project>"
  },
  {
    "path": "Plugins/VerilogGenerator/VerilogGeneratorPlugin.vcxproj.filters",
    "content": "﻿<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n<Project ToolsVersion=\"4.0\" xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">\r\n  <ItemGroup>\r\n    <Filter Include=\"Source Files\">\r\n      <UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>\r\n      <Extensions>cpp;cxx;c;def</Extensions>\r\n    </Filter>\r\n    <Filter Include=\"Header Files\">\r\n      <UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>\r\n      <Extensions>h</Extensions>\r\n    </Filter>\r\n    <Filter Include=\"Generated Files\">\r\n      <UniqueIdentifier>{71ED8ED8-ACB9-4CE9-BBE1-E00B30144E11}</UniqueIdentifier>\r\n      <Extensions>moc;h;cpp</Extensions>\r\n      <SourceControlFiles>False</SourceControlFiles>\r\n    </Filter>\r\n    <Filter Include=\"Generated Files\\Debug\">\r\n      <UniqueIdentifier>{0dde34ad-54aa-4fc2-bbd2-8d5415f77af4}</UniqueIdentifier>\r\n      <Extensions>cpp;moc</Extensions>\r\n      <SourceControlFiles>False</SourceControlFiles>\r\n    </Filter>\r\n    <Filter Include=\"Generated Files\\Release\">\r\n      <UniqueIdentifier>{c8453e3e-ca63-45c5-a10f-423715481c0d}</UniqueIdentifier>\r\n      <Extensions>cpp;moc</Extensions>\r\n      <SourceControlFiles>False</SourceControlFiles>\r\n    </Filter>\r\n    <Filter Include=\"Header Files\\common\">\r\n      <UniqueIdentifier>{96e9ee6a-c016-4cf5-be38-0f78a5982b1f}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Header Files\\ComponentInstanceVerilogWriter\">\r\n      <UniqueIdentifier>{4cdc09df-b4df-4816-a6ea-a85f4a6219b6}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Source Files\\ComponentInstanceVerilogWriter\">\r\n      <UniqueIdentifier>{8d3944ba-0c93-4f52-a12c-23988f8ace63}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Header Files\\ComponentVerilogWriter\">\r\n      <UniqueIdentifier>{c53cf5e3-54c6-442c-ac00-797d093c1876}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Source Files\\ComponentVerilogWriter\">\r\n      <UniqueIdentifier>{b4246f26-2288-4029-92ee-85654381f5b4}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Source Files\\ModelParameterVerilogWriter\">\r\n      <UniqueIdentifier>{a6c7b78d-06d9-42a6-97b2-7d129017ce68}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Header Files\\ModelParameterVerilogWriter\">\r\n      <UniqueIdentifier>{fdc9bd50-1c26-4f38-9bb7-f42a6d6cd845}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Header Files\\PortSorter\">\r\n      <UniqueIdentifier>{73f4f98f-54f9-4a96-9a6c-80764b0f5b5a}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Source Files\\PortSorter\">\r\n      <UniqueIdentifier>{8fe05d15-34a6-4e4f-a33a-39a6f648bc28}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Header Files\\VerilogHeaderWriter\">\r\n      <UniqueIdentifier>{155d93fc-49dc-4ed9-b490-f4b10067aabc}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Source Files\\VerilogHeaderWriter\">\r\n      <UniqueIdentifier>{bf4811d2-6433-4322-9873-4823e9c92d65}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Header Files\\VerilogWireWriter\">\r\n      <UniqueIdentifier>{30fdfd97-e7b3-44c9-bbc2-7dad54fdeb95}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Source Files\\VerilogWireWriter\">\r\n      <UniqueIdentifier>{8e320532-d8b0-4872-baf0-2e5b4264118d}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Header Files\\CommentWriter\">\r\n      <UniqueIdentifier>{468f1fa5-f1af-4d60-b857-c019ac60ef11}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Source Files\\CommentWriter\">\r\n      <UniqueIdentifier>{a47d1b0b-24ee-45bc-ba3a-98b00efca831}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Source Files\\common\">\r\n      <UniqueIdentifier>{4a27df50-07b3-4de2-b5a0-4286e816efb4}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Resource Files\">\r\n      <UniqueIdentifier>{D9D6E242-F8AF-46E4-B9FD-80ECBC20BA3E}</UniqueIdentifier>\r\n      <Extensions>qrc;*</Extensions>\r\n      <ParseFiles>false</ParseFiles>\r\n    </Filter>\r\n    <Filter Include=\"Source Files\\editors\">\r\n      <UniqueIdentifier>{4b5799d6-c1dd-45f6-96ae-d78b1137dec0}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Header Files\\editors\">\r\n      <UniqueIdentifier>{33366b37-96ed-4c9f-843f-9881ab444642}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Header Files\\TextBodyWrite\">\r\n      <UniqueIdentifier>{087779c9-1f4e-4c00-89b6-05295736929e}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Source Files\\TextBodyWrite\">\r\n      <UniqueIdentifier>{2d88d741-961b-458c-9da6-1fe4fcd13d83}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Source Files\\VerilogInterconnectionWriter\">\r\n      <UniqueIdentifier>{c959ce36-a9a5-45a8-80a6-4bce81d36a92}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Header Files\\VerilogInterconnectionWriter\">\r\n      <UniqueIdentifier>{49c1da0b-e2ef-4922-b33f-0b53c28cd4a4}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Header Files\\VerilogWriterFactory\">\r\n      <UniqueIdentifier>{1c531240-09d2-4215-acab-9e32c1022d3d}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Source Files\\VerilogWriterFactory\">\r\n      <UniqueIdentifier>{df935c43-bdc6-4b31-9901-9c1c5a63f862}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Header Files\\VerilogAssignmentWriter\">\r\n      <UniqueIdentifier>{eb136d54-9485-4133-b031-5e668f8daa3c}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Source Files\\VerilogAssignmentWriter\">\r\n      <UniqueIdentifier>{3fcc2a9d-b112-4143-8341-e27e3d9d8059}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Header Files\\GenerationControl\">\r\n      <UniqueIdentifier>{763961cb-58da-4c55-83d3-10b80c6e25a2}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Source Files\\GenerationControl\">\r\n      <UniqueIdentifier>{6c9da2cd-2b6e-492a-a913-41d81e41505e}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Header Files\\Widgets\">\r\n      <UniqueIdentifier>{b83d2cb6-0cdd-46fb-b9f6-23fa4f90f4eb}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Source Files\\Widgets\">\r\n      <UniqueIdentifier>{c7abcd51-8127-488f-9646-7db7fdff4c20}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Header Files\\Parsing\">\r\n      <UniqueIdentifier>{f3a5a54b-16c5-4acd-abb2-fc58c0b2146b}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Source Files\\Parsing\">\r\n      <UniqueIdentifier>{265b861a-684d-4adf-be14-c53097eb9d3f}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Source Files\\editors\\common\">\r\n      <UniqueIdentifier>{8cc2ee0f-0c89-4884-820e-d55e75404d3d}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Header Files\\editors\\common\">\r\n      <UniqueIdentifier>{28c052a9-942b-40c9-b59c-75c4c47e84b6}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Header Files\\VerilogPortWriter\">\r\n      <UniqueIdentifier>{2fa57958-0fe9-4a5d-b9f8-63e08e24f590}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Source Files\\VerilogPortWriter\">\r\n      <UniqueIdentifier>{a49610ef-34fe-4963-9d88-8dbef3d997ca}</UniqueIdentifier>\r\n    </Filter>\r\n  </ItemGroup>\r\n  <ItemGroup>\r\n    <ClCompile Include=\"ComponentVerilogWriter\\ComponentVerilogWriter.cpp\">\r\n      <Filter>Source Files\\ComponentVerilogWriter</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"ModelParameterVerilogWriter\\ModelParameterVerilogWriter.cpp\">\r\n      <Filter>Source Files\\ModelParameterVerilogWriter</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"VerilogHeaderWriter\\VerilogHeaderWriter.cpp\">\r\n      <Filter>Source Files\\VerilogHeaderWriter</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"VerilogWireWriter\\VerilogWireWriter.cpp\">\r\n      <Filter>Source Files\\VerilogWireWriter</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"CommentWriter\\CommentWriter.cpp\">\r\n      <Filter>Source Files\\CommentWriter</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"common\\WriterGroup.cpp\">\r\n      <Filter>Source Files\\common</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"VerilogGeneratorPlugin.cpp\">\r\n      <Filter>Source Files</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"TextBodyWriter\\TextBodyWriter.cpp\">\r\n      <Filter>Source Files\\TextBodyWrite</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\common\\PortSorter\\InterfaceDirectionNameSorter.cpp\">\r\n      <Filter>Source Files\\PortSorter</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"ComponentInstanceVerilogWriter\\ComponentInstanceVerilogWriter.cpp\">\r\n      <Filter>Source Files\\ComponentInstanceVerilogWriter</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"VerilogInterconnectionWriter\\VerilogInterconnectionWriter.cpp\">\r\n      <Filter>Source Files\\VerilogInterconnectionWriter</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"VerilogWriterFactory\\VerilogWriterFactory.cpp\">\r\n      <Filter>Source Files\\VerilogWriterFactory</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"VerilogWriterFactory\\VerilogDocument.cpp\">\r\n      <Filter>Source Files\\VerilogWriterFactory</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"VerilogAssignmentWriter\\VerilogAssignmentWriter.cpp\">\r\n      <Filter>Source Files\\VerilogAssignmentWriter</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\PluginSystem\\GeneratorPlugin\\GenerationControl.cpp\">\r\n      <Filter>Source Files\\GenerationControl</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\PluginSystem\\GeneratorPlugin\\ViewSelection.cpp\">\r\n      <Filter>Source Files\\GenerationControl</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\PluginSystem\\GeneratorPlugin\\ViewSelectionWidget.cpp\">\r\n      <Filter>Source Files\\Widgets</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\PluginSystem\\GeneratorPlugin\\FileOutputWidget.cpp\">\r\n      <Filter>Source Files\\Widgets</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\common\\HDLParser\\MetaDesign.cpp\">\r\n      <Filter>Source Files\\Parsing</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\common\\HDLParser\\MetaInstance.cpp\">\r\n      <Filter>Source Files\\Parsing</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\VerilogImport\\VerilogSyntax.cpp\">\r\n      <Filter>Source Files</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\PluginSystem\\GeneratorPlugin\\HDLGenerationDialog.cpp\">\r\n      <Filter>Source Files\\Widgets</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\PluginSystem\\GeneratorPlugin\\MessagePasser.cpp\">\r\n      <Filter>Source Files\\GenerationControl</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\mainwindow\\MessageConsole\\messageconsole.cpp\">\r\n      <Filter>Source Files\\Widgets</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\common\\HDLParser\\MetaComponent.cpp\">\r\n      <Filter>Source Files\\Parsing</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\PluginSystem\\GeneratorPlugin\\OutputControl.cpp\">\r\n      <Filter>Source Files\\GenerationControl</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\common\\LanguageHighlighter.cpp\">\r\n      <Filter>Source Files</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\common\\SourceHighlightStyle.cpp\">\r\n      <Filter>Source Files</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"VerilogSourceHighlight.cpp\">\r\n      <Filter>Source Files</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\editors\\common\\TopComponentParameterFinder.cpp\">\r\n      <Filter>Source Files\\editors\\common</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\common\\HDLParser\\HDLCommandLineParser.cpp\">\r\n      <Filter>Source Files</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\IPXACTmodels\\utilities\\ComponentSearch.cpp\">\r\n      <Filter>Source Files</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"VerilogPortWriter\\VerilogPortWriter.cpp\">\r\n      <Filter>Source Files\\VerilogPortWriter</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"VerilogPortWriter\\VerilogTopDefaultWriter.cpp\">\r\n      <Filter>Source Files\\VerilogPortWriter</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\common\\expressions\\utilities.cpp\">\r\n      <Filter>Source Files\\common</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\PluginSystem\\GeneratorPlugin\\AddToFilesetWidget.cpp\">\r\n      <Filter>Source Files\\Widgets</Filter>\r\n    </ClCompile>  </ItemGroup>\r\n  <ItemGroup>\r\n    <ClInclude Include=\"common\\Writer.h\">\r\n      <Filter>Header Files\\common</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"ComponentInstanceVerilogWriter\\ComponentInstanceVerilogWriter.h\">\r\n      <Filter>Header Files\\ComponentInstanceVerilogWriter</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"ComponentVerilogWriter\\ComponentVerilogWriter.h\">\r\n      <Filter>Header Files\\ComponentVerilogWriter</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"ModelParameterVerilogWriter\\ModelParameterVerilogWriter.h\">\r\n      <Filter>Header Files\\ModelParameterVerilogWriter</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"VerilogHeaderWriter\\VerilogHeaderWriter.h\">\r\n      <Filter>Header Files\\VerilogHeaderWriter</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"VerilogWireWriter\\VerilogWireWriter.h\">\r\n      <Filter>Header Files\\VerilogWireWriter</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"CommentWriter\\CommentWriter.h\">\r\n      <Filter>Header Files\\CommentWriter</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"common\\WriterGroup.h\">\r\n      <Filter>Header Files\\common</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"TextBodyWriter\\TextBodyWriter.h\">\r\n      <Filter>Header Files\\TextBodyWrite</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\common\\PortSorter\\InterfaceDirectionNameSorter.h\">\r\n      <Filter>Header Files\\PortSorter</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\common\\PortSorter\\PortSorter.h\">\r\n      <Filter>Header Files\\PortSorter</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"VerilogInterconnectionWriter\\VerilogInterconnectionWriter.h\">\r\n      <Filter>Header Files\\VerilogInterconnectionWriter</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"veriloggeneratorplugin_global.h\">\r\n      <Filter>Header Files\\ComponentVerilogWriter</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"VerilogAssignmentWriter\\VerilogAssignmentWriter.h\">\r\n      <Filter>Header Files\\VerilogAssignmentWriter</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\PluginSystem\\GeneratorPlugin\\IWriterFactory.h\">\r\n      <Filter>Header Files\\VerilogWriterFactory</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\PluginSystem\\GeneratorPlugin\\GenerationControl.h\">\r\n      <Filter>Header Files\\GenerationControl</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\PluginSystem\\GeneratorPlugin\\ViewSelection.h\">\r\n      <Filter>Header Files\\GenerationControl</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\common\\HDLParser\\MetaInstance.h\">\r\n      <Filter>Header Files\\Parsing</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\common\\HDLParser\\MetaDesign.h\">\r\n      <Filter>Header Files\\Parsing</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"VerilogWriterFactory\\VerilogDocument.h\">\r\n      <Filter>Header Files\\VerilogWriterFactory</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\VerilogImport\\VerilogSyntax.h\">\r\n      <Filter>Header Files</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\common\\HDLParser\\MetaComponent.h\">\r\n      <Filter>Header Files\\Parsing</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\PluginSystem\\GeneratorPlugin\\OutputControl.h\">\r\n      <Filter>Header Files\\GenerationControl</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\common\\SourceHighlightStyle.h\">\r\n      <Filter>Header Files</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"VerilogSourceHighlight.h\">\r\n      <Filter>Header Files</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\common\\HDLParser\\HDLParserCommon.h\">\r\n      <Filter>Header Files\\Parsing</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\editors\\common\\TopComponentParameterFinder.h\">\r\n      <Filter>Header Files\\editors\\common</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\common\\HDLParser\\HDLCommandLineParser.h\">\r\n      <Filter>Header Files</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\IPXACTmodels\\utilities\\ComponentSearch.h\">\r\n      <Filter>Header Files</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\IPXACTmodels\\utilities\\Search.h\">\r\n      <Filter>Header Files</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"VerilogPortWriter\\VerilogPortWriter.h\">\r\n      <Filter>Header Files\\VerilogPortWriter</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"VerilogPortWriter\\VerilogTopDefaultWriter.h\">\r\n      <Filter>Header Files\\VerilogPortWriter</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\common\\expressions\\utilities.h\">\r\n      <Filter>Header Files\\common</Filter>\r\n    </ClInclude>\r\n  </ItemGroup>\r\n  <ItemGroup>\r\n    <QtRcc Include=\"VerilogGenerator.qrc\">\r\n      <Filter>Resource Files</Filter>\r\n    </QtRcc>\r\n    <QtMoc Include=\"VerilogGeneratorPlugin.h\">\r\n      <Filter>Header Files</Filter>\r\n    </QtMoc>\r\n    <CustomBuild Include=\"VerilogWriterFactory\\VerilogWriterFactory.h\">\r\n      <Filter>Header Files\\VerilogWriterFactory</Filter>\r\n    </CustomBuild>\r\n    <QtMoc Include=\"..\\PluginSystem\\GeneratorPlugin\\FileOutputWidget.h\">\r\n      <Filter>Header Files\\Widgets</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"..\\PluginSystem\\GeneratorPlugin\\ViewSelectionWidget.h\">\r\n      <Filter>Header Files\\Widgets</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"..\\PluginSystem\\GeneratorPlugin\\HDLGenerationDialog.h\">\r\n      <Filter>Header Files\\Widgets</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"..\\PluginSystem\\GeneratorPlugin\\MessagePasser.h\">\r\n      <Filter>Header Files\\GenerationControl</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"..\\..\\mainwindow\\MessageConsole\\messageconsole.h\">\r\n      <Filter>Header Files\\Widgets</Filter>\r\n    </QtMoc>\r\n    <QtMoc Include=\"..\\common\\LanguageHighlighter.h\">\r\n      <Filter>Header Files</Filter>\r\n    </QtMoc>\r\n  </ItemGroup>\r\n  <ItemGroup>\r\n    <None Include=\"verilogGenerator.png\">\r\n      <Filter>Resource Files</Filter>\r\n    </None>\r\n  </ItemGroup>\r\n  <ItemGroup>\r\n    <QtMoc Include=\"..\\PluginSystem\\GeneratorPlugin\\AddToFilesetWidget.h\">\r\n      <Filter>Header Files\\Widgets</Filter>\r\n    </QtMoc>\r\n  </ItemGroup>\r\n</Project>"
  },
  {
    "path": "Plugins/VerilogGenerator/VerilogHeaderWriter/VerilogHeaderWriter.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: VerilogHeaderWriter.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Esko Pekkarinen\r\n// Date: 04.08.2014\r\n//\r\n// Description:\r\n// Class for generating a header for a Verilog file.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"VerilogHeaderWriter.h\"\r\n\r\n#include <IPXACTmodels/common/VLNV.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VerilogHeaderWriter::VerilogHeaderWriter()\r\n//-----------------------------------------------------------------------------\r\nVerilogHeaderWriter::VerilogHeaderWriter(VLNV const& vlnv, QString const& xmlPath, QString const& author,\r\n    QString const& description, QString const& kactusVersion, QString const& generatorVersion) : \r\n    vlnv_(vlnv), \r\n    xmlPath_(xmlPath),\r\n    author_(author),\r\n    description_(description),\r\n    generatorVersion_(generatorVersion),\r\n    kactusVersion_(kactusVersion)\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VerilogHeaderWriter::write()\r\n//-----------------------------------------------------------------------------\r\nvoid VerilogHeaderWriter::write(QTextStream& outputStream, QString const& fileName, QDateTime const& generationTime) const\r\n{\r\n    QStringList descriptionLines = description_.split(\"\\n\");\r\n\r\n    outputStream << \"//-----------------------------------------------------------------------------\" << Qt::endl;\r\n    outputStream << \"// File          : \" << fileName << Qt::endl;\r\n    outputStream << \"// Creation date : \" << generationTime.date().toString(\"dd.MM.yyyy\") << Qt::endl;\r\n\toutputStream << \"// Creation time : \" << generationTime.time().toString(\"hh:mm:ss\") << Qt::endl;\r\n    outputStream << \"// Description   : \" << descriptionLines.first() << Qt::endl;\r\n\r\n    for (int i = 1; i < descriptionLines.count(); i++)\r\n    {\r\n        outputStream << \"//                 \" << descriptionLines.at(i) << Qt::endl;\r\n    }\r\n\r\n\toutputStream << \"// Created by    : \" << author_ << Qt::endl;\r\n\toutputStream << \"// Tool : Kactus2 \" << kactusVersion_ << Qt::endl;\r\n\toutputStream << \"// Plugin : Verilog generator \" << generatorVersion_ << Qt::endl;\r\n\toutputStream << \"// This file was generated based on IP-XACT component \" << vlnv_.toString() << Qt::endl;\r\n    outputStream << \"// whose XML file is \" << xmlPath_ << Qt::endl;\r\n    outputStream << \"//-----------------------------------------------------------------------------\" << Qt::endl;\r\n    outputStream << Qt::endl;\r\n}\r\n"
  },
  {
    "path": "Plugins/VerilogGenerator/VerilogHeaderWriter/VerilogHeaderWriter.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: VerilogHeaderWriter.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Esko Pekkarinen\r\n// Date: 04.08.2014\r\n//\r\n// Description:\r\n// Class for generating a header for a Verilog file.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef VERILOGHEADERWRITER_H\r\n#define VERILOGHEADERWRITER_H\r\n\r\n#include \"../veriloggeneratorplugin_global.h\"\r\n\r\n#include <QDateTime>\r\n#include <QString>\r\n#include <QTextStream>\r\n\r\n#include <IPXACTmodels/common/VLNV.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Class for generating a header for a Verilog file.\r\n//-----------------------------------------------------------------------------\r\nclass VERILOGGENERATORPLUGIN_EXPORT VerilogHeaderWriter \r\n{\r\npublic:\r\n\r\n    /*!\r\n     *  The constructor.\r\n\t *\r\n\t *    @param [in] vlnv                The VLNV of the top level component.\r\n     *    @param [in] xmlPath             The path to the top level component XML file.\r\n     *    @param [in] author              The creator of the file.\r\n     *    @param [in] description\t\t    The description of the top level component.\r\n     *    @param [in] kactusVersion\t\tThe version of the current Kactus2 build.\r\n     *    @param [in] generatorVersion\tThe current version of the generator.\r\n\t */\r\n\tVerilogHeaderWriter(VLNV const& vlnv, QString const& xmlPath, QString const& author,\r\n        QString const& description, QString const& kactusVersion, QString const& generatorVersion);\r\n\r\n\t//! The destructor.\r\n\t~VerilogHeaderWriter() = default;\r\n\r\n    /*!\r\n     *  Writes a header to the given output.\r\n     *\r\n\t *    @param [in] outputStream\t\tThe output to write to.\r\n     *    @param [in] generationTime\t\tTime of the generation.\r\n     */\r\n    void write(QTextStream& outputStream, QString const& fileName, QDateTime const& generationTime) const;\r\n\r\nprivate:\r\n\r\n\t// Disable copying.\r\n\tVerilogHeaderWriter(VerilogHeaderWriter const& rhs);\r\n\tVerilogHeaderWriter& operator=(VerilogHeaderWriter const& rhs);\r\n\r\n    //! The VLNV of the top level component.\r\n    VLNV vlnv_;\r\n\r\n    //! The path to the top level component XML file.\r\n    QString xmlPath_;\r\n\r\n    //! The user who created the file.\r\n    QString author_;\r\n\r\n    //! The description of the top level component.\r\n    QString description_;\r\n\r\n    //! Version of the generator.\r\n    QString generatorVersion_;\r\n\r\n    //! Version of Kactus2.\r\n    QString kactusVersion_;\r\n};\r\n\r\n#endif // VERILOGHEADERWRITER_H\r\n"
  },
  {
    "path": "Plugins/VerilogGenerator/VerilogInterconnectionWriter/VerilogInterconnectionWriter.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: VerilogInterconnectionWriter.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Janne Virtanen\r\n// Date: 07.09.2014\r\n//\r\n// Description:\r\n// Class for writing a Verilog interconnection declaration.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"VerilogInterconnectionWriter.h\"\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VerilogInterconnectionWriter::InterconnectionVerilogWriter()\r\n//-----------------------------------------------------------------------------\r\nVerilogInterconnectionWriter::VerilogInterconnectionWriter(QSharedPointer<MetaInterconnection> interconnection) : interconnection_(interconnection)\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VerilogInterconnectionWriter::~InterconnectionVerilogWriter()\r\n//-----------------------------------------------------------------------------\r\nVerilogInterconnectionWriter::~VerilogInterconnectionWriter()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VerilogInterconnectionWriter::write()\r\n//-----------------------------------------------------------------------------\r\nvoid VerilogInterconnectionWriter::write(QTextStream& output) const\r\n{\r\n    QString instanceString = \"<typeName> <parameters><instanceName>();\";\r\n\r\n    // TODO: Interconnection typename.\r\n    //instanceString.replace(\"<typeName>\", interconnection_->typeName_);\r\n    instanceString.replace(\"<parameters>\", parameterAssignments());\r\n    instanceString.replace(\"<instanceName>\", interconnection_->name_);\r\n\r\n    output<< indentation() << instanceString << Qt::endl;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VerilogInterconnectionWriter::indentation()\r\n//-----------------------------------------------------------------------------\r\nQString VerilogInterconnectionWriter::indentation() const\r\n{\r\n    return \"    \";\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VerilogInterconnectionWriter::parameterAssignments()\r\n//-----------------------------------------------------------------------------\r\nQString VerilogInterconnectionWriter::parameterAssignments() const\r\n{\r\n    return \"\";\r\n    /*QString instanceParameters(\"#(\\n<namesAndValues>)\\n\");\r\n\r\n    QStringList assignments;\r\n\r\n    if (instance_->parameters.count() < 1)\r\n    {\r\n        return \"\";\r\n    }\r\n\r\n    foreach(QSharedPointer<Parameter> parameter, instance_->parameters)\r\n    {\r\n        // If the parameters are not user resolved nor generated, then there cannot be any override by the design.\r\n        if (parameter->getValueResolve() != \"user\" && parameter->getValueResolve() != \"generated\")\r\n        {\r\n            continue;\r\n        }\r\n\r\n        QString assignment(indentation().repeated(2) + \".<parameter>(<value>)\");\r\n        assignment.replace(\"<parameter>\", \r\n            expressionParser_->parseExpression(parameter->name()).leftJustified(20));\r\n        assignment.replace(\"<value>\", \r\n            expressionFormatter_->formatReferringExpression(parameter->getValue()));\r\n        assignments.append(assignment);\r\n    }\r\n\r\n    instanceParameters.replace(\"<namesAndValues>\", assignments.join(\",\\n\"));\r\n    return instanceParameters;*/\r\n}"
  },
  {
    "path": "Plugins/VerilogGenerator/VerilogInterconnectionWriter/VerilogInterconnectionWriter.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: VerilogInterconnectionWriter.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Janne Virtanen\r\n// Date: 07.09.2014\r\n//\r\n// Description:\r\n// Class for writing a Verilog interconnection declaration.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef VERILOGINTERCONNECTIONWRITER_H\r\n#define VERILOGINTERCONNECTIONWRITER_H\r\n\r\n#include <Plugins/VerilogGenerator/common/Writer.h>\r\n#include \"../veriloggeneratorplugin_global.h\"\r\n#include <Plugins/common/HDLParser/HDLParserCommon.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Class for writing a Verilog wire declaration.\r\n//-----------------------------------------------------------------------------\r\nclass VERILOGGENERATORPLUGIN_EXPORT VerilogInterconnectionWriter : public Writer\r\n{\r\npublic:\r\n\r\n\t//! The constructor.\r\n\tVerilogInterconnectionWriter(QSharedPointer<MetaInterconnection> interconnection);\r\n\r\n\t//! The destructor.\r\n\tvirtual ~VerilogInterconnectionWriter();\r\n\r\n    /*!\r\n     *  Writes the interconnection to given output.\r\n     *\r\n     *    @param [in] output   The output to write to.\r\n     */\r\n    virtual void write(QTextStream& output) const;    \r\n\r\nprivate:\r\n\r\n\t// Disable copying.\r\n\tVerilogInterconnectionWriter(VerilogInterconnectionWriter const& rhs);\r\n\tVerilogInterconnectionWriter& operator=(VerilogInterconnectionWriter const& rhs);\r\n\r\n    /*!\r\n     *  Gets the indentation to use.\r\n     *\r\n     *    @return The indentation to use.\r\n     */\r\n    QString indentation() const;\r\n\r\n    /*!\r\n     *  Gets the instance-specific parameter assignments.\r\n     *\r\n     *    @return The Verilog description of the instance parameters and their values.\r\n     */\r\n    QString parameterAssignments() const;\r\n\r\n    /*!\r\n     *  Gets the formatted size for the wire.\r\n     *\r\n     *    @return The formatted size.\r\n     */\r\n    QString formattedSize() const;\r\n\r\n    //! The interconnection.\r\n    QSharedPointer<MetaInterconnection> interconnection_;\r\n};\r\n\r\n#endif // VERILOGINTERCONNECTIONWRITER_H\r\n"
  },
  {
    "path": "Plugins/VerilogGenerator/VerilogPortWriter/VerilogPortWriter.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: VerilogPortWriter.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Esko Pekkarinen\n// Date: 28.7.2014\n//\n// Description:\n// Class for writing port declarations in Verilog.\n//-----------------------------------------------------------------------------\n\n#include \"VerilogPortWriter.h\"\n#include <IPXACTmodels/Component/Port.h>\n\n//-----------------------------------------------------------------------------\n// Function: VerilogPortWriter::VerilogPortWriter()\n//-----------------------------------------------------------------------------\nVerilogPortWriter::VerilogPortWriter(QSharedPointer<MetaPort> port) : port_(port)\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: VerilogPortWriter::write()\n//-----------------------------------------------------------------------------\nvoid VerilogPortWriter::write( QTextStream& outputStream ) const\n{\n    if (!nothingToWrite())\n    {\n        outputStream << createDeclaration();\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: VerilogPortWriter::nothingToWrite()\n//-----------------------------------------------------------------------------\nbool VerilogPortWriter::nothingToWrite() const\n{\n    return port_.isNull() || \n        port_->port_->getDirection() == DirectionTypes::DIRECTION_PHANTOM ||\n        port_->port_->getDirection() == DirectionTypes::DIRECTION_INVALID;\n}\n\n//-----------------------------------------------------------------------------\n// Function: VerilogPortWriter::createDeclaration()\n//-----------------------------------------------------------------------------\nQString VerilogPortWriter::createDeclaration() const\n{\n    QString portDeclaration(\"<direction> <type> <array> <vectorBounds> <name>\");\n\n    portDeclaration.replace(\"<direction>\", direction().leftJustified(6));\n    portDeclaration.replace(\"<type>\", port_->port_->getTypeName().leftJustified(7));\n    portDeclaration.replace(\"<vectorBounds>\", formatBounds(port_->vectorBounds_).leftJustified(14));\n    portDeclaration.replace(\"<array>\", formatBounds(port_->arrayBounds_).leftJustified(5));\n    portDeclaration.replace(\"<name>\", port_->port_->name());\n\n    return portDeclaration;\n}\n\n//-----------------------------------------------------------------------------\n// Function: VerilogPortWriter::direction()\n//-----------------------------------------------------------------------------\nQString VerilogPortWriter::direction() const\n{\n    QString directionString;\n\n    if (port_->port_->getDirection() == DirectionTypes::IN)\n    {\n        directionString = QStringLiteral(\"input\");\n    }\n    else if (port_->port_->getDirection() == DirectionTypes::OUT)    \n    {\n        directionString = QStringLiteral(\"output\");\n    }\n    else if (port_->port_->getDirection() == DirectionTypes::INOUT)   \n    {\n        directionString = QStringLiteral(\"inout\");\n    }\n\n    return directionString;\n}\n\n//-----------------------------------------------------------------------------\n// Function: VerilogPortWriter::formatBounds()\n//-----------------------------------------------------------------------------\nQString VerilogPortWriter::formatBounds(QPair<QString, QString> const& bounds) const\n{\n    QString vectorDefinition = \"[\" + bounds.first + \":\" + bounds.second + \"]\";\n    vectorDefinition.remove(QLatin1Char(' '));\n\n    if (vectorDefinition.compare(QLatin1String(\"[0:0]\")) == 0 || \n        vectorDefinition.compare(QLatin1String(\"[:]\")) == 0)\n    {\n        vectorDefinition.clear();\n    }\n\t\n    return vectorDefinition;\n}\n"
  },
  {
    "path": "Plugins/VerilogGenerator/VerilogPortWriter/VerilogPortWriter.h",
    "content": "//-----------------------------------------------------------------------------\n// File: VerilogPortWriter.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Esko Pekkarinen\n// Date: 28.7.2014\n//\n// Description:\n// Class for writing port declarations in Verilog.\n//-----------------------------------------------------------------------------\n\n#ifndef PORTVERILOGWRITER_H\n#define PORTVERILOGWRITER_H\n\n#include \"../veriloggeneratorplugin_global.h\"\n#include \"../common/Writer.h\"\n\n#include <Plugins/common/HDLParser/HDLParserCommon.h>\n\n#include <QTextStream>\n\n//-----------------------------------------------------------------------------\n// Class for writing port declarations in Verilog.\n//-----------------------------------------------------------------------------\nclass VERILOGGENERATORPLUGIN_EXPORT VerilogPortWriter : public Writer\n{\npublic:\n    /*!\n     *  The constructor.\n     *\n     *    @param [in] port                    The port to write to Verilog.\n     */\n    VerilogPortWriter(QSharedPointer<MetaPort> port);\n\n    //! The destructor.\n    virtual ~VerilogPortWriter() = default;\n\n\t/*! Writes the Verilog port declaration into a text stream.\n\t *\n\t *    @param [in] output   The text stream to write the port into.\n\t */\n    void write(QTextStream& outputStream) const;\n\nprivate:\n    \n    //! No copying.\n    VerilogPortWriter(const VerilogPortWriter& other);\n\n    //! No assignment.\n    VerilogPortWriter& operator=(const VerilogPortWriter& other);\n\n    /*!\n     *  Checks if the writer should write nothing.\n     *\n     *    @return True, if the writer has nothing to write, otherwise false.\n     */\n    bool nothingToWrite() const;\n\n    /*!\n     *  Creates a Verilog port declaration from the port model.     \n     *\n     *    @return A Verilog port declaration.\n     */\n    QString createDeclaration() const; \n\n    /*!\n     *  Creates a string representation of the port direction.\n     *\n     *    @return The port direction.\n     */\n    QString direction() const;\n    \n    /*!\n     *  Returns vector bounds representation for the port.\n     */\n    QString formatBounds(QPair<QString, QString> const& bounds) const;\n    \n    //-----------------------------------------------------------------------------\n    // Data.\n    //-----------------------------------------------------------------------------\n\n    //! The port to write to Verilog.\n    QSharedPointer<const MetaPort> port_;\n};\n\n#endif // PORTVERILOGWRITER_H\n"
  },
  {
    "path": "Plugins/VerilogGenerator/VerilogPortWriter/VerilogTopDefaultWriter.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: VerilogTopDefaultWriter.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Janne Virtanen\n// Date: 24.01.2017\n//\n// Description:\n// Class for writing default values for ports of the top component.\n//-----------------------------------------------------------------------------\n\n#include \"VerilogTopDefaultWriter.h\"\n\n//-----------------------------------------------------------------------------\n// Function: VerilogTopDefaultWriter::VerilogTopDefaultWriter()\n//-----------------------------------------------------------------------------\nVerilogTopDefaultWriter::VerilogTopDefaultWriter(QSharedPointer<MetaPort> mPort) : mPort_(mPort)\n{\n}\n\n//-----------------------------------------------------------------------------\n// Function: VerilogTopDefaultWriter::~VerilogTopDefaultWriter()\n//-----------------------------------------------------------------------------\nVerilogTopDefaultWriter::~VerilogTopDefaultWriter()\n{\n}\n\n//-----------------------------------------------------------------------------\n// Function: VerilogTopDefaultWriter::write()\n//-----------------------------------------------------------------------------\nvoid VerilogTopDefaultWriter::write(QTextStream& output) const\n{\n    if (mPort_->port_->getDirection() != DirectionTypes::OUT && mPort_->port_->getDirection() != DirectionTypes::INOUT)\n    {\n        return;\n    }\n\n    if (mPort_->defaultValue_.isEmpty())\n    {\n        return;\n    }\n\n    output << \"    assign \" << mPort_->port_->name() << \" = \" << mPort_->defaultValue_ << \";\" << Qt::endl;\n}"
  },
  {
    "path": "Plugins/VerilogGenerator/VerilogPortWriter/VerilogTopDefaultWriter.h",
    "content": "//-----------------------------------------------------------------------------\n// File: VerilogTopDefaultWriter.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Janne Virtanen\n// Date: 24.01.2017\n//\n// Description:\n// Class for writing default values for ports of the top component.\n//-----------------------------------------------------------------------------\n\n#ifndef VERILOGTOPDEFAULTWRITER_H\n#define VERILOGTOPDEFAULTWRITER_H\n\n#include <Plugins/VerilogGenerator/common/Writer.h>\n#include \"../veriloggeneratorplugin_global.h\"\n\n#include \"Plugins/common/HDLParser/HDLParserCommon.h\"\n\n#include <IPXACTmodels/Component/Port.h>\n\n//-----------------------------------------------------------------------------\n// Class for writing default values for ports of the top component.\n//-----------------------------------------------------------------------------\nclass VERILOGGENERATORPLUGIN_EXPORT VerilogTopDefaultWriter : public Writer\n{\npublic:\n\n\t/*!\n     *  The constructor.\n     *\n     *    @param [in] mPort           The port, which default value assignment will be written, if applicable.\n     */\n    VerilogTopDefaultWriter(QSharedPointer<MetaPort> mPort);\n\n\t/*!\n     *  The destructor.\n     */\n    virtual ~VerilogTopDefaultWriter();\n\n    /*!\n     *  Writes the assignments to the given output.\n     *\n     *    @param [in] output   The output to write to.\n     */\n    virtual void write(QTextStream& output) const;\n\nprivate:\n\n\t// Disable copying.\n\tVerilogTopDefaultWriter(VerilogTopDefaultWriter const& rhs);\n\tVerilogTopDefaultWriter& operator=(VerilogTopDefaultWriter const& rhs);\n       \n    //-----------------------------------------------------------------------------\n    // Data.\n    //-----------------------------------------------------------------------------\n\n    //! The port.\n    QSharedPointer<MetaPort> mPort_;\n};\n\n#endif // VERILOGTOPDEFAULTWRITER_H"
  },
  {
    "path": "Plugins/VerilogGenerator/VerilogSourceHighlight.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: VerilogHighlighter.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Esko Pekkarinen\n// Date: 15.02.2017\n//\n// Description:\n// Verilog language-specific highlight rules.\n//-----------------------------------------------------------------------------\n\n#include \"VerilogSourceHighlight.h\"\n\n#include <common/KactusColors.h>\n\n//-----------------------------------------------------------------------------\n// Function: VerilogSourceHighlight::VerilogSourceHighlight()\n//-----------------------------------------------------------------------------\nVerilogSourceHighlight::VerilogSourceHighlight(): SourceHighlightStyle()\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: VerilogSourceHighlight::~VerilogSourceHighlight()\n//-----------------------------------------------------------------------------\nVerilogSourceHighlight::~VerilogSourceHighlight()\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: VerilogSourceHighlight::preprocessorDirectives()\n//-----------------------------------------------------------------------------\nQStringList VerilogSourceHighlight::preprocessorDirectives() const\n{\n    QStringList directives;\n    directives << \"`include\" << \"`ifndef\" << \"`ifdef\"\n        << \"`if\" << \"`endif\" << \"`elsif\" << \"`else\" << \"`undef\" << \"`define\";\n\n    return directives;\n}\n\n//-----------------------------------------------------------------------------\n// Function: VerilogSourceHighlight::keywords()\n//-----------------------------------------------------------------------------\nQStringList VerilogSourceHighlight::keywords() const\n{\n    QStringList keywordList;\n    keywordList << \"assign\" << \"and\" << \"always\" << \"begin\" \n        << \"case\" << \"deassign\" << \"default\" \n        << \"defparam\" << \"end\" << \"edge\"\n        << \"else\" << \"endcase\" << \"endfunction\"\n        << \"endgenerate\" << \"endmodule\" << \"for\" \n        << \"if\" << \"function\" << \"generate\" \n        << \"integer\" << \"inout\" << \"input\"\n        << \"localparam\" << \"macromodule\" << \"module\"\n        << \"negedge\" << \"output\"  << \"or\" << \"parameter\"\n        << \"posedge\" << \"real\" << \"realtime\"\n        << \"reg\" << \"signed\" << \"time\"\n        << \"tri\" << \"tri0\" << \"tri1\"\n        << \"triand\" << \"wand\" << \"trior\"\n        << \"wor\" << \"trireg\" << \"while\"\n        << \"wire\";\n\n    return keywordList;\n}\n\n//-----------------------------------------------------------------------------\n// Function: VerilogSourceHighlight::applyLanguageSpecificRules()\n//-----------------------------------------------------------------------------\nvoid VerilogSourceHighlight::applyLanguageSpecificRules(LanguageHighlighter* highlighter) const\n{\n    HighlightStyleDesc stringStyle;\n    stringStyle.color = KactusColors::STRING_HIGHLIGHT;\n\n    highlighter->setStyle(LanguageHighlighter::STRING, stringStyle);\n\n    HighlightStyleDesc preprocessorStyle;\n    preprocessorStyle.color = KactusColors::PREPROCESSOR_HIGHLIGHT;\n\n    highlighter->setStyle(LanguageHighlighter::PREPROCESSOR, preprocessorStyle);\n\n    HighlightStyleDesc functionStyle;\n    functionStyle.color = KactusColors::FUNCTION_HIGHLIGHT;\n\n    highlighter->setStyle(LanguageHighlighter::LANGUAGE_SPECIFIC, functionStyle);\n\n    QRegularExpression function(\"[$]\\\\w+\");\n    highlighter->addRule(function, LanguageHighlighter::LANGUAGE_SPECIFIC);\n}\n"
  },
  {
    "path": "Plugins/VerilogGenerator/VerilogSourceHighlight.h",
    "content": "//-----------------------------------------------------------------------------\n// File: VerilogHighlighter.h\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Esko Pekkarinen\n// Date: 15.02.2017\n//\n// Description:\n// Verilog language-specific highlight rules.\n//-----------------------------------------------------------------------------\n\n#ifndef VERILOGSOURCEHIGHLIGHT_H\n#define VERILOGSOURCEHIGHLIGHT_H\n\n#include <QSyntaxHighlighter>\n#include <QTextEdit>\n#include <QString>\n#include <QVector>\n#include <QTextCharFormat>\n\n#include <Plugins/common/SourceHighlightStyle.h>\n\n//-----------------------------------------------------------------------------\n//! VerilogSourceHighlight class.\n//-----------------------------------------------------------------------------\nclass VerilogSourceHighlight : public SourceHighlightStyle\n{\npublic:\n   \n    //! The constructor.\n    VerilogSourceHighlight();\n\n    //! The destructor.\n    virtual ~VerilogSourceHighlight();\n\nprotected:\n\n    /*!\n     *  Get the language specific keywords.\n     *\n     *    @return The language keywords.\n     */\n    virtual QStringList keywords() const;\n        \n    /*!\n     *  Get the language specific preprocessor directives.\n     *\n     *    @return The preprocessor directives.\n     */\n    virtual QStringList preprocessorDirectives() const;\n  \n    /*!\n     *  Apply other language specific rules to highlighting.\n     *\n     *    @param [in] highlighter   The highlighter to apply the rules to.\n     */      \n    virtual void applyLanguageSpecificRules(LanguageHighlighter* highlighter) const;\n\nprivate:\n\n    // Disable copying.\n    VerilogSourceHighlight(VerilogSourceHighlight const& rhs);\n    VerilogSourceHighlight& operator=(VerilogSourceHighlight const& rhs);\n\n};\n\n//-----------------------------------------------------------------------------\n\n#endif // VERILOGSOURCEHIGHLIGHT_H\n"
  },
  {
    "path": "Plugins/VerilogGenerator/VerilogWireWriter/VerilogWireWriter.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: VerilogWireWriter.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Esko Pekkarinen\r\n// Date: 21.08.2014\r\n//\r\n// Description:\r\n// Class for writing a Verilog wire declaration.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"VerilogWireWriter.h\"\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VerilogWireWriter::VerilogWireWriter()\r\n//-----------------------------------------------------------------------------\r\nVerilogWireWriter::VerilogWireWriter(QString name, QPair<QString, QString> bounds, QPair<QString, QString> array)\r\n    : name_(name), bounds_(bounds), array_(array)\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VerilogWireWriter::~InterconnectionVerilogWriter()\r\n//-----------------------------------------------------------------------------\r\nVerilogWireWriter::~VerilogWireWriter()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VerilogWireWriter::write()\r\n//-----------------------------------------------------------------------------\r\nvoid VerilogWireWriter::write(QTextStream& output) const\r\n{\r\n    output << \"    \" << createDeclaration() << Qt::endl;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VerilogWireWriter::createDeclaration()\r\n//-----------------------------------------------------------------------------\r\nQString VerilogWireWriter::createDeclaration() const\r\n{\r\n    QString declaration(\"wire <array><size> <name>;\");    \r\n    declaration.replace(\"<array>\", formattedSize(array_)); \r\n    declaration.replace(\"<size>\", formattedSize(bounds_).leftJustified(5));\r\n    declaration.replace(\"<name>\", name_);\r\n\r\n    return declaration;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VerilogWireWriter::formattedSize()\r\n//-----------------------------------------------------------------------------\r\nQString VerilogWireWriter::formattedSize(QPair<QString, QString> const& bounds) const\r\n{\r\n\tQString sizeString;\r\n\r\n\tif (bounds.first != bounds.second)\r\n\t{\r\n\t\tsizeString = \"[\" + bounds.first + \":\" + bounds.second + \"]\";\r\n\t}\r\n\r\n    return sizeString;\r\n}\r\n"
  },
  {
    "path": "Plugins/VerilogGenerator/VerilogWireWriter/VerilogWireWriter.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: VerilogWireWriter.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Esko Pekkarinen\r\n// Date: 21.08.2014\r\n//\r\n// Description:\r\n// Class for writing a Verilog wire declaration.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef VERILOGWIREWRITER_H\r\n#define VERILOGWIREWRITER_H\r\n\r\n#include <Plugins/VerilogGenerator/common/Writer.h>\r\n#include \"../veriloggeneratorplugin_global.h\"\r\n#include <Plugins/common/HDLParser/HDLParserCommon.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Class for writing a Verilog wire declaration.\r\n//-----------------------------------------------------------------------------\r\nclass VERILOGGENERATORPLUGIN_EXPORT VerilogWireWriter : public Writer\r\n{\r\npublic:\r\n\r\n    //! The constructor.\r\n    VerilogWireWriter(QString name, QPair<QString, QString> bounds, QPair<QString, QString> array);\r\n\r\n\t//! The destructor.\r\n\tvirtual ~VerilogWireWriter();\r\n\r\n    /*!\r\n     *  Writes the wire to given output.\r\n     *\r\n     *    @param [in] output   The output to write to.\r\n     */\r\n    virtual void write(QTextStream& output) const;    \r\n\r\nprivate:\r\n\r\n\t// Disable copying.\r\n\tVerilogWireWriter(VerilogWireWriter const& rhs);\r\n\tVerilogWireWriter& operator=(VerilogWireWriter const& rhs);\r\n       \r\n    /*!\r\n     *  Creates a Verilog wire declaration.     \r\n     *\r\n     *    @return The Verilog wire declaration for this wire.\r\n     */\r\n    QString createDeclaration() const;\r\n\r\n    /*!\r\n     *  Gets the formatted size for the wire.\r\n     *\r\n     *    @return The formatted size.\r\n     */\r\n    QString formattedSize(QPair<QString, QString> const& bounds) const;\r\n\r\n    //! The wire.\r\n    QString name_;\r\n    QPair<QString, QString> bounds_;\r\n    QPair<QString, QString> array_;\r\n};\r\n\r\n#endif // VERILOGWIREWRITER_H\r\n"
  },
  {
    "path": "Plugins/VerilogGenerator/VerilogWriterFactory/VerilogDocument.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: VerilogDocument.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Janne Virtanen\n// Date: 26.01.2017\n//\n// Description:\n// Storage for Verilog writers.\n//-----------------------------------------------------------------------------\n\n#include \"VerilogDocument.h\"\n\n#include <QDateTime>\n#include <QTextStream>\n\n#include <Plugins/VerilogImport/VerilogSyntax.h>\n\n//-----------------------------------------------------------------------------\n// Function: VerilogDocument::VerilogDocument()\n//-----------------------------------------------------------------------------\nVerilogDocument::VerilogDocument()\n{\n}\n\n//-----------------------------------------------------------------------------\n// Function: VerilogDocument::write()\n//-----------------------------------------------------------------------------\nvoid VerilogDocument::write(QString const& /*outputDirectory*/)\n{\n    fileContent_.clear();\n    QTextStream outputStream(&fileContent_);\n    headerWriter_->write(outputStream, fileName_, QDateTime::currentDateTime());\n    topWriter_->write(outputStream);\n}\n\n//-----------------------------------------------------------------------------\n// Function: VerilogDocument::getImplementation()\n//-----------------------------------------------------------------------------\nvoid VerilogDocument::getBodyHighlight(int& begin, int& end) const\n{\n    QString error;\n    VerilogSyntax::findImplementation(fileContent_, begin, end, error);\n}\n\n//-----------------------------------------------------------------------------\n// Function: VerilogDocument::selectImplementation()\n//-----------------------------------------------------------------------------\nbool VerilogDocument::selectImplementation(QString const& code, QString& implementation,\n    QString& postModule, QString& error)\n{\n    // The Verilog syntax defines how it should be done.\n    return VerilogSyntax::selectImplementation(code, implementation, postModule, error);\n}\n"
  },
  {
    "path": "Plugins/VerilogGenerator/VerilogWriterFactory/VerilogDocument.h",
    "content": "//-----------------------------------------------------------------------------\n// File: VerilogDocument.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Janne Virtanen\n// Date: 26.01.2017\n//\n// Description:\n// Storage for Verilog writers.\n//-----------------------------------------------------------------------------\n\n#ifndef VERILOGDOCUMENT_H\n#define VERILOGDOCUMENT_H\n\n#include \"../veriloggeneratorplugin_global.h\"\n\n#include <Plugins/PluginSystem/GeneratorPlugin/OutputControl.h>\n\n#include <Plugins/VerilogGenerator/ComponentVerilogWriter/ComponentVerilogWriter.h>\n#include <Plugins/VerilogGenerator/ComponentInstanceVerilogWriter/ComponentInstanceVerilogWriter.h>\n#include <Plugins/VerilogGenerator/VerilogHeaderWriter/VerilogHeaderWriter.h>\n\n//-----------------------------------------------------------------------------\n// Verilog document.\n//-----------------------------------------------------------------------------\nstruct VerilogDocument : public GenerationOutput\n{\n    //! This will contain the found implementation, if success.\n    QString implementation_;\n    //! This may contain the text after the module definition, if success.\n    QString postModule_;\n\n    //! Writer for generating file header.\n    QSharedPointer<VerilogHeaderWriter> headerWriter_;\n\n    //! Writer for the component, is to contain everything that comes to document, except header writer.\n    QSharedPointer<ComponentVerilogWriter> topWriter_;\n\n    //! Writer for top defaults.\n    QSharedPointer<WriterGroup> topDefaultWriters_;\n\n    //! Writers for Verilog interconnections.\n    QSharedPointer<WriterGroup> interconnectionWriters_;\n\n    //! Writers for interconnection wires.\n    QSharedPointer<WriterGroup> connectionWireWriters_;\n\n    //! Writers for interconnection wires.\n    QSharedPointer<WriterGroup> adHocWireWriters_;\n\n    //! Writers for port assignment wires.\n    QSharedPointer<WriterGroup> portWireWriters_;\n\n    //! Writers for hierarchical port assignments.\n    QSharedPointer<WriterGroup> topAssignmentWriters_;\n\n    //! Writers for instance port assignments.\n    QSharedPointer<WriterGroup> instanceAssignmentWriters_;\n\n    //! Writers for Verilog instances.\n    QList<QSharedPointer<ComponentInstanceVerilogWriter> > instanceWriters_;\n\n    //! Writers for Verilog instances.\n    QMap<QSharedPointer<ComponentInstanceVerilogWriter>, QSharedPointer<Writer> > instanceHeaderWriters_;\n\n    //! The constructor.\n    VerilogDocument();\n    \n    //! The destructor.\n    virtual  ~VerilogDocument() = default;\n\n    /*!\n     *  Writes the content. \n     *\n     *    @param [in] outputDirectory         The possible output directory.\n     */\n\tvirtual void write(QString const& outputDirectory) override;\n    \n    /*!\n     *  Finds position for body text highlight in document, if any exists.\n     *\n\t *    @param [out] begin                  The position where the highlight begins, if successful.\n     *    @param [out] end                    The position where the highlight ends, if successful.\n     */\n    virtual void getBodyHighlight(int& begin, int& end) const override;\n\n    /*!\n     *  Finds the module implementation in Verilog code.\n     *\n     *    @param [in] code\t\t            The code that will be inspected.\n\t *    @param [out] implementation         The found module implementation, if successful.\n     *    @param [out] postModule\t\t        Anything that exists after the module declaration.\n     *    @param [out] error                  If fails, this will contain an error message.\n     *\n     *    @return True, if a single implementation could be found, else false.\n     */\n\tbool selectImplementation(QString const& code, QString& implementation,\n        QString& postModule, QString& error);\n};\n\n#endif // VERILOGDOCUMENT_H\n"
  },
  {
    "path": "Plugins/VerilogGenerator/VerilogWriterFactory/VerilogWriterFactory.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: VerilogWriterFactory.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Janne Virtanen\n// Date: 26.01.2017\n//\n// Description:\n// Creates writes for generating Verilog.\n//-----------------------------------------------------------------------------\n\n#include \"VerilogWriterFactory.h\"\n\n#include <KactusAPI/include/MessageMediator.h>\n\n#include <KactusAPI/include/LibraryInterface.h>\n\n#include <Plugins/VerilogGenerator/CommentWriter/CommentWriter.h>\n#include <Plugins/common/PortSorter/InterfaceDirectionNameSorter.h>\n#include <Plugins/VerilogGenerator/VerilogWireWriter/VerilogWireWriter.h>\n#include <Plugins/VerilogGenerator/VerilogAssignmentWriter/VerilogAssignmentWriter.h>\n#include <Plugins/VerilogGenerator/VerilogPortWriter/VerilogTopDefaultWriter.h>\n\n#include <Plugins/VerilogImport/VerilogSyntax.h>\n\n#include <Plugins/PluginSystem/GeneratorPlugin/GenerationControl.h>\n\n//-----------------------------------------------------------------------------\n// Function: VerilogWriterFactory::VerilogWriterFactory()\n//-----------------------------------------------------------------------------\nVerilogWriterFactory::VerilogWriterFactory(LibraryInterface* library,\n    MessageMediator* messages, GenerationSettings* settings,\n    QString const& kactusVersion, QString const& generatorVersion) :\n    library_(library),\n    messages_(messages),\n    settings_(settings),\n    generatorVersion_(generatorVersion),\n    kactusVersion_(kactusVersion),\n    sorter_(new InterfaceDirectionNameSorter())\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: VerilogWriterFactory::prepareComponent()\n//-----------------------------------------------------------------------------\nQSharedPointer<GenerationOutput> VerilogWriterFactory::prepareComponent(QString const& outputPath,\n    QSharedPointer<MetaComponent> component)\n{\n    // If we are not generating based on a design, we must parse the existing implementation.\n    QString fileName = component->getModuleName() + \".v\";\n    QString filePath = outputPath + \"/\" + fileName;\n\n    QSharedPointer<VerilogDocument> document = QSharedPointer<VerilogDocument>(new VerilogDocument);\n\n    document->fileName_ = fileName;\n    document->vlnv_ = component->getComponent()->getVlnv().toString();\n    document->metaComponent_ = component;\n\n    // Try to find an implementation from the file.\n    if (!readImplementation(document, filePath))\n    {\n        return QSharedPointer<VerilogDocument>();\n    }\n\n    // Create writers for module header etc.\n    initializeComponentWriters(document, component);\n\n    // Create writers.\n    QSharedPointer<TextBodyWriter> implementationWriter(new TextBodyWriter(document->implementation_));\n    document->topWriter_->setImplementation(implementationWriter);\n\n    QSharedPointer<TextBodyWriter> postModuleWriter(new TextBodyWriter(document->postModule_));\n    document->topWriter_->setPostModule(postModuleWriter);\n\n    return document;\n}\n\n//-----------------------------------------------------------------------------\n// Function: VerilogWriterFactory::prepareDesign()\n//-----------------------------------------------------------------------------\nQList<QSharedPointer<GenerationOutput> > VerilogWriterFactory::prepareDesign(QList<QSharedPointer<MetaDesign> >& designs)\n{\n    QList<QSharedPointer<GenerationOutput> > retval;\n\n    foreach(QSharedPointer<MetaDesign> mDesign, designs)\n    {\n        QSharedPointer<VerilogDocument> document = QSharedPointer<VerilogDocument>(new VerilogDocument);\n        initializeComponentWriters(document, mDesign->getTopInstance());\n        document->fileName_ = mDesign->getTopInstance()->getModuleName() + \".v\";\n        document->vlnv_ = mDesign->getTopInstance()->getComponent()->getVlnv().toString();\n        document->metaDesign_ = mDesign;\n\n        initializeDesignWriters(document, mDesign);\n\n        // Finally, add them to the top writer in desired order.\n        addWritersToTopInDesiredOrder(document);\n        retval.append(document);\n    }\n\n    return retval;\n}\n\n//-----------------------------------------------------------------------------\n// Function: VerilogWriterFactory::getLanguage()\n//-----------------------------------------------------------------------------\nQString VerilogWriterFactory::getLanguage() const\n{\n    return \"Verilog\";\n}\n\n//-----------------------------------------------------------------------------\n// Function: VerilogWriterFactory::getSaveToFileset()\n//-----------------------------------------------------------------------------\nbool VerilogWriterFactory::getSaveToFileset() const\n{\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: VerilogWriterFactory::getGroupIdentifier()\n//-----------------------------------------------------------------------------\nQString VerilogWriterFactory::getGroupIdentifier() const\n{\n    return QStringLiteral(\"generatedFiles\");\n}\n\n//-----------------------------------------------------------------------------\n// Function: VerilogWriterFactory::readImplementation()\n//-----------------------------------------------------------------------------\nbool VerilogWriterFactory::readImplementation(QSharedPointer<VerilogDocument> document, QString const& outputPath)\n{\n    // This will contain the found implementation, if success.\n    QString implementation;\n    // This may contain the text after the module definition, if success.\n    QString postModule;\n    // This will contain the error message, if not success.\n    QString error;\n\n    // Check if the output file already exists.\n    QFile outputFile(outputPath); \n\n    // If it does not, there is nothing do here.\n    if (!outputFile.exists())\n    {\n        return true;\n    }\n\n    // Must be able to open it for reading.\n    if (!outputFile.open(QIODevice::ReadOnly))\n    {\n        messages_->showError(QObject::tr(\"File %1: The output file exists, but could not open it for reading. The path: %2\").\n            arg(document->fileName_, outputPath));\n        return false;\n    }\n\n    // Read the content.\n    QTextStream inputStream(&outputFile);\n    QString fileContent = inputStream.readAll();\n    // Remove carriage return.\n    fileContent.remove('\\r');\n\n    // The document sub class is supposed to know how to find its implementation.\n    if (!document->selectImplementation(fileContent, implementation, postModule, error))\n    {\n        messages_->showError(QObject::tr(\"File %1: %2\").arg(document->fileName_, error));\n\n        return false;\n    }\n\n    document->implementation_ = implementation;\n    document->postModule_ = postModule;\n\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: VerilogWriterFactory::initializeComponentWriters()\n//-----------------------------------------------------------------------------\nvoid VerilogWriterFactory::initializeComponentWriters(QSharedPointer<VerilogDocument> document,\n    QSharedPointer<MetaComponent> component)\n{\n    QSettings settings;\n    QString currentUser = settings.value(\"General/Username\").toString();\n    QString componentXmlPath = library_->getPath(component->getComponent()->getVlnv());\n\n    document->headerWriter_ = QSharedPointer<VerilogHeaderWriter>(new VerilogHeaderWriter(component->getComponent()->getVlnv(), \n        componentXmlPath, currentUser, component->getComponent()->getDescription(), kactusVersion_, generatorVersion_));\n\n    document->topWriter_ = QSharedPointer<ComponentVerilogWriter>(new ComponentVerilogWriter\n        (component, settings_->generateInterfaces_));\n}\n\n//-----------------------------------------------------------------------------\n// Function: VerilogWriterFactory::initializeDesignWriters()\n//-----------------------------------------------------------------------------\nvoid VerilogWriterFactory::initializeDesignWriters(QSharedPointer<VerilogDocument> document,\n    QSharedPointer<MetaDesign> design)\n{\n    document->instanceWriters_.clear();\n\n    document->interconnectionWriters_ = QSharedPointer<WriterGroup>(new WriterGroup());\n\n    document->connectionWireWriters_ = QSharedPointer<WriterGroup>(new WriterGroup());\n\n    document->adHocWireWriters_ = QSharedPointer<WriterGroup>(new WriterGroup());\n\n    document->portWireWriters_ = QSharedPointer<WriterGroup>(new WriterGroup());\n\n    document->topAssignmentWriters_ = QSharedPointer<WriterGroup>(new WriterGroup());\n\n    document->topDefaultWriters_ = QSharedPointer<WriterGroup>(new WriterGroup());\n\n    document->instanceAssignmentWriters_ = QSharedPointer<WriterGroup>(new WriterGroup());\n\n    // Comment for top for assignments.\n    if (design->getTopInstance()->getPorts()->size() > 0)\n    {\n        QSharedPointer<CommentWriter> topAssignmentHeaderWriter(\n            new CommentWriter(\"Assignments for the ports of the encompassing component:\"));\n        topAssignmentHeaderWriter->setIndent(4);\n        document->topAssignmentWriters_->add(topAssignmentHeaderWriter);\n    }\n\n    // Create assignments fort top ports.\n    foreach (QSharedPointer<MetaPort> mPort, *design->getTopInstance()->getPorts())\n    {\n        if (mPort->isTransactional_)\n        {\n            continue;\n        }\n\n        if (mPort->downAssignments_.size() > 0)\n        {\n            // Create a writer for each assignment of the port.\n            foreach(QSharedPointer<MetaPortAssignment> mpa, mPort->downAssignments_)\n            {\n                // Current policy dictates that hierarchical inout ports are directly connected to an instance port.\n                // As an exception, it could have a default value assignment.\n                if (mPort->port_->getDirection() != DirectionTypes::INOUT || !mpa->wire_)\n                {\n                    QSharedPointer<VerilogAssignmentWriter> topAssignment = QSharedPointer<VerilogAssignmentWriter>\n                        (new VerilogAssignmentWriter(mPort->port_->name(), mpa, mPort, true));\n                    document->topAssignmentWriters_->add(topAssignment);\n                }\n            }\n        }\n        else\n        {\n            QSharedPointer<VerilogTopDefaultWriter> topDefault = QSharedPointer<VerilogTopDefaultWriter>\n                (new VerilogTopDefaultWriter(mPort));\n            document->topDefaultWriters_->add(topDefault);\n        }\n    }\n\n    // Create instance writers for the instances.\n    foreach(QSharedPointer<MetaInstance> mInstance, *design->getInstances())\n    {\n        QSharedPointer<ComponentInstance> instance = mInstance->getComponentInstance();\n\n        QSharedPointer<ComponentInstanceVerilogWriter> instanceWriter(new ComponentInstanceVerilogWriter(\n            mInstance, sorter_, settings_->generateInterfaces_));\n\n        document->instanceWriters_.append(instanceWriter);\n\n        document->instanceHeaderWriters_.insert(instanceWriter, createHeaderWriterForInstance(mInstance));\n\n        // Comment for instance assignments.\n        if (mInstance->getPorts()->size() > 0)\n        {\n            QSharedPointer<CommentWriter> portWireHeaderWriter(\n                new CommentWriter(instance->getInstanceName() + \" port wires:\"));\n            portWireHeaderWriter->setIndent(4);\n            document->portWireWriters_->add(portWireHeaderWriter);\n\n            QSharedPointer<CommentWriter> assignmentHeaderWriter(\n                new CommentWriter(instance->getInstanceName() + \" assignments:\"));\n            assignmentHeaderWriter->setIndent(4);\n            document->instanceAssignmentWriters_->add(assignmentHeaderWriter);\n        }\n\n        // Create writers for instance ports, wires, and assignments.\n        foreach (QSharedPointer<MetaPort> mPort, *mInstance->getPorts())\n        {\n            if (mPort->isTransactional_ || mPort->upAssignments_.size() < 1)\n            {\n                continue;\n            }\n\n            // Current policy dictates that instance inout ports are directly connected to wire or hierarchical port.\n            if (mPort->port_->getDirection() == DirectionTypes::INOUT)\n            {\n                continue;\n            }\n\n            // Determine the name for the connected element: Name of the instance plus port.\n            QString physName = VerilogSyntax::legalizeName(instance->getInstanceName() + \"_\" +\n                mPort->port_->name());\n\n            // Create a wire for it.\n            document->portWireWriters_->add(QSharedPointer<VerilogWireWriter>(new VerilogWireWriter\n                (physName, mPort->vectorBounds_, mPort->arrayBounds_)));\n\n            // Then create assignments, that connect it to logical wires.\n            foreach (QSharedPointer<MetaPortAssignment> mpa, mPort->upAssignments_)\n            {\n                QSharedPointer<VerilogAssignmentWriter> instanceAssignment = QSharedPointer<VerilogAssignmentWriter>\n                    (new VerilogAssignmentWriter(physName, mpa, mPort, false));\n                document->instanceAssignmentWriters_->add(instanceAssignment);\n            }\n        }\n    }\n\n    // Create wire writers for the interconnections\n    foreach (QSharedPointer<MetaInterconnection> mInterconnect, *design->getInterconnections())\n    {\n        if (mInterconnect->wires_.size() > 0)\n        {\n            QSharedPointer<CommentWriter> connectionWireHeaderWriter(\n                new CommentWriter(mInterconnect->name_ + \" wires:\"));\n            connectionWireHeaderWriter->setIndent(4);\n            document->connectionWireWriters_->add(connectionWireHeaderWriter);\n        }\n\n        foreach (QSharedPointer<MetaWire> gw, mInterconnect->wires_)\n        {\n            // Current policy dictates that hierarchical inout ports are directly connected to an instance port.\n            bool hierInout = false;\n            foreach (QSharedPointer<MetaPort> mPort, gw->hierPorts_)\n            {\n                if (mPort->port_->getDirection() == DirectionTypes::INOUT)\n                {\n                    hierInout = true;\n                    break;\n                }\n            }\n\n            if (!hierInout)\n            {\n                document->connectionWireWriters_->\n                    add(QSharedPointer<VerilogWireWriter>(new VerilogWireWriter\n                    (VerilogSyntax::legalizeName(gw->name_), gw->bounds_, gw->arrayBounds_)));\n            }\n        }\n    }\n\n    // Create wire writers for the ad-hoc connections\n    if (design->getAdHocWires()->size() > 0)\n    {\n        QSharedPointer<CommentWriter> adHocWireHeaderWriter(\n            new CommentWriter(\"Ad-hoc wires:\"));\n        adHocWireHeaderWriter->setIndent(4);\n       document->adHocWireWriters_->add(adHocWireHeaderWriter);\n    }\n\n    foreach (QSharedPointer<MetaWire> adHoc, *design->getAdHocWires())\n    {\n        // Current policy dictates that hierarchical in out ports are directly connected to an instance port.\n        bool hierInout = false;\n        foreach (QSharedPointer<MetaPort> mPort, adHoc->hierPorts_)\n        {\n            if (mPort->port_->getDirection() == DirectionTypes::INOUT)\n            {\n                hierInout = true;\n                break;\n            }\n        }\n\n        // Thus, if an ad-hoc wire is connected to any hierarchical inout ports, it is no written.\n        if (!hierInout)\n        {\n            document->adHocWireWriters_->\n                add(QSharedPointer<VerilogWireWriter>(new VerilogWireWriter(\n                VerilogSyntax::legalizeName(adHoc->name_), adHoc->bounds_, adHoc->arrayBounds_)));\n        }\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: VerilogWriterFactory::addWritersToTopInDesiredOrder()\n//-----------------------------------------------------------------------------\nvoid VerilogWriterFactory::addWritersToTopInDesiredOrder(QSharedPointer<VerilogDocument> document) const\n{\n    document->topWriter_->add(document->interconnectionWriters_);\n\n    document->topWriter_->add(document->connectionWireWriters_);\n\n    document->topWriter_->add(document->adHocWireWriters_);\n\n    document->topWriter_->add(document->portWireWriters_);\n\n    document->topWriter_->add(document->topAssignmentWriters_);\n\n    document->topWriter_->add(document->topDefaultWriters_);\n\n    document->topWriter_->add(document->instanceAssignmentWriters_);\n\n    foreach(QSharedPointer<ComponentInstanceVerilogWriter> instanceWriter, document->instanceWriters_)\n    {\n        QSharedPointer<Writer> headerWriter = document->instanceHeaderWriters_[instanceWriter];\n\n        QSharedPointer<WriterGroup> instanceGroup(new WriterGroup);\n        instanceGroup->add(headerWriter);\n        instanceGroup->add(instanceWriter);\n\n        document->topWriter_->add(instanceGroup);\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: VerilogWriterFactory::createHeaderWriterForInstance()\n//-----------------------------------------------------------------------------\nQSharedPointer<Writer> VerilogWriterFactory::createHeaderWriterForInstance(QSharedPointer<MetaInstance> instance) const\n{\n    QString header = instance->getComponentInstance()->description();\n    if (!header.isEmpty())\n    {\n        header.append(\"\\n\");\n    }\n\n    header.append(\"IP-XACT VLNV: \" + instance->getComponent()->getVlnv().toString());\n\n    QSharedPointer<CommentWriter> headerWriter(new CommentWriter(header));\n    headerWriter->setIndent(4);\n\n    return headerWriter;\n}"
  },
  {
    "path": "Plugins/VerilogGenerator/VerilogWriterFactory/VerilogWriterFactory.h",
    "content": "//-----------------------------------------------------------------------------\n// File: VerilogWriterFactory.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Janne Virtanen\n// Date: 26.01.2017\n//\n// Description:\n// Creates writes for generating Verilog.\n//-----------------------------------------------------------------------------\n\n#ifndef VERILOGWRITERFACTORY_H\n#define VERILOGWRITERFACTORY_H\n\n#include \"VerilogDocument.h\"\n\n#include <Plugins/PluginSystem/GeneratorPlugin/IWriterFactory.h>\n\nstruct GenerationSettings;\nclass MessageMediator;\n\n//-----------------------------------------------------------------------------\n// Verilog file generator.\n//-----------------------------------------------------------------------------\nclass VerilogWriterFactory : public IWriterFactory\n{\npublic:\n\n\t/*!\n\t *  The constructor.\n\t *\n     *    @param [in] library                 The component library.\n     *    @param [in] messages                For message output.\n     *    @param [in] settings                Points to the settings to be used within the generation.\n\t *    @param [in] kactusVersion\t\t    The version of the current Kactus build.\n\t *    @param [in] generatorVersion\t    The current version of the generator.\n\t */\n    VerilogWriterFactory(LibraryInterface* library, \n        MessageMediator* messages, GenerationSettings* settings,\n        QString const& kactusVersion, QString const& generatorVersion);\n\n    //! The destructor.\n    virtual ~VerilogWriterFactory() = default;\n\n    /*!\n     *  Creates writers for the given formatted HDL component.\n     *\n     *    @param [in] outputPath\t\t\tThe path to the output file.\n     *    @param [in] component           The component which is needs writing.\n     *\n     *    @return The objects that bundles the writers. Will be null, if could not be created.\n     */\n    virtual QSharedPointer<GenerationOutput> prepareComponent(QString const& outputPath,\n        QSharedPointer<MetaComponent> component) override final;\n\n    /*!\n     *  Creates writers for the given meta designs.\n     *\n     *    @param [in] designs             The designs that will yield documents.\n     *\n     *    @return The objects that bundles the writers. Will be null, if could not be created.\n     */\n    virtual QList<QSharedPointer<GenerationOutput> > prepareDesign(QList<QSharedPointer<MetaDesign> >& designs)\n        override final;\n    \n    /*!\n     *  Returns the language of the factory.\n     */\n    virtual QString getLanguage() const override final;\n    \n    /*!\n     *  Returns true, if it is desirable to save the output to file set by default.\n     */\n    virtual bool getSaveToFileset() const override final;\n    \n    /*!\n     *  Returns the group identifier suitable for the produced files.\n     */\n    virtual QString getGroupIdentifier() const override final;\n\nprivate:\n\n    // Disable copying.\n    VerilogWriterFactory(VerilogWriterFactory const& rhs);\n    VerilogWriterFactory& operator=(VerilogWriterFactory const& rhs);\n\n    /*!\n     *  Checks if given file exists, and tries to parse its existing implementation.\n     *\n     *    @param [in] document        \t    The document, which will get writers for writing design.\n     *    @param [in] outputPath        \t    The path of the potentially the existing file.\n\t *\n\t *    @return False, if the file exists, but could not be opened or parsed properly. Else true.\n     */\n    bool readImplementation(QSharedPointer<VerilogDocument> document, QString const& outputPath);\n\n    /*!\n     *  Initializes writers for component.\n     *\n     *    @param [in] document        \t    The document, which will get writers for writing component.\n     *    @param [in] component\t\t        The component, which data will be written.\n     */\n    void initializeComponentWriters(QSharedPointer<VerilogDocument> document, QSharedPointer<MetaComponent> component);\n    \n    /*!\n     *  Initializes writers for the given design.\n     *\n     *    @param [in] document        \tThe document, which will get writers for writing design.\n\t *    @param [in] design\t\t        The design, which data will be written.\n     */\n    void initializeDesignWriters(QSharedPointer<VerilogDocument> document, QSharedPointer<MetaDesign> design);\n   \n    /*!\n     *  Adds the generated writers to the top writer in correct order.            \n     */\n    void addWritersToTopInDesiredOrder(QSharedPointer<VerilogDocument> document) const;\n\n    /*!\n     *  Creates a writer for writing a preceding header for a component instance.\n     *\n     *    @param [in] instanceName   The name of the component instance to create the writer for.\n     *\n     *    @return A writer for the header.\n     */\n    QSharedPointer<Writer> createHeaderWriterForInstance(QSharedPointer<MetaInstance> instance) const;\n\n    //-----------------------------------------------------------------------------\n    // Data.\n    //-----------------------------------------------------------------------------\n\n    //! The component library.\n    LibraryInterface* library_;\n\n    //! The messages.\n    MessageMediator* messages_;\n\n    //! Points to the settings to be used within the generation.\n    GenerationSettings* settings_;\n\n    //! Version of the generator.\n    QString generatorVersion_;\n\n    //! Version of Kactus2.\n    QString kactusVersion_;\n\n    //! Sorter for component ports.\n    QSharedPointer<PortSorter> sorter_;\n};\n\n#endif // VERILOGWRITERFACTORY_H\n"
  },
  {
    "path": "Plugins/VerilogGenerator/common/Writer.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: Writer.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Esko Pekkarinen\r\n// Date: 21.08.2014\r\n//\r\n// Description:\r\n// Interface for writers.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef WRITER_H\r\n#define WRITER_H\r\n\r\n#include <QTextStream>\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Interface for writers.\r\n//-----------------------------------------------------------------------------\r\nclass Writer \r\n{\r\npublic:\r\n\r\n\t//! The destructor.\r\n    virtual ~Writer() {}\r\n\r\n    /*!\r\n     *  Writes the content to the given output.\r\n     *\r\n     *    @param [in] output   The output to write to.\r\n     */\r\n    virtual void write(QTextStream& output) const = 0;\r\n\r\n};\r\n\r\n#endif // WRITER_H\r\n"
  },
  {
    "path": "Plugins/VerilogGenerator/common/WriterGroup.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: WriterGroup.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Esko Pekkarinen\r\n// Date: 29.08.2014\r\n//\r\n// Description:\r\n// Composite for writers.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"WriterGroup.h\"\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: WriterGroup::WriterGroup()\r\n//-----------------------------------------------------------------------------\r\nWriterGroup::WriterGroup(): childWriters_()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: WriterGroup::~WriterGroup()\r\n//-----------------------------------------------------------------------------\r\nWriterGroup::~WriterGroup()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: WriterGroup::write()\r\n//-----------------------------------------------------------------------------\r\nvoid WriterGroup::write(QTextStream& output) const\r\n{\r\n    foreach(QSharedPointer<Writer> writer, childWriters_)\r\n    {\r\n        writer->write(output);\r\n    }\r\n\r\n    if (!childWriters_.isEmpty())\r\n    {\r\n        output << Qt::endl;\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: WriterGroup::add()\r\n//-----------------------------------------------------------------------------\r\nvoid WriterGroup::add(QSharedPointer<Writer> writer)\r\n{\r\n    childWriters_.append(writer);\r\n}\r\n"
  },
  {
    "path": "Plugins/VerilogGenerator/common/WriterGroup.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: WriterGroup.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Esko Pekkarinen\r\n// Date: 29.08.2014\r\n//\r\n// Description:\r\n// Composite for writers.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef WriterGROUP_H\r\n#define WriterGROUP_H\r\n\r\n#include \"Writer.h\"\r\n\r\n#include \"../veriloggeneratorplugin_global.h\"\r\n\r\n#include <QSharedPointer>\r\n#include <QTextStream>\r\n#include <QList>\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Composite for writers.\r\n//-----------------------------------------------------------------------------\r\nclass VERILOGGENERATORPLUGIN_EXPORT WriterGroup : public Writer\r\n{\r\npublic:\r\n\r\n    //! The constructor.\r\n    WriterGroup();\r\n\r\n\t//! The destructor.\r\n    virtual ~WriterGroup();\r\n\r\n    /*!\r\n     *  Writes the content to the given output.\r\n     *\r\n     *    @param [in] output   The output to write to.\r\n     */\r\n    virtual void write(QTextStream& outputStream) const;\r\n    \r\n    /*!\r\n     *  Adds a new writer to the group.\r\n     *\r\n     *    @param [in] writer   The writer to add.     \r\n     */\r\n     void add(QSharedPointer<Writer> writer);\r\n    \r\nprivate:\r\n    // Disable copying.\r\n    WriterGroup(WriterGroup const& rhs);\r\n    WriterGroup& operator=(WriterGroup const& rhs);\r\n\r\n    //! The writers in the group.\r\n    QList<QSharedPointer<Writer> > childWriters_;\r\n};\r\n\r\n#endif // WriterGROUP_H\r\n"
  },
  {
    "path": "Plugins/VerilogGenerator/veriloggeneratorplugin.json",
    "content": "{\r\n\t\"Keys\": [ \"Verilog Generator Plugin\" ]\r\n}"
  },
  {
    "path": "Plugins/VerilogGenerator/veriloggeneratorplugin_global.h",
    "content": "#ifndef VERILOGGENERATORPLUGIN_GLOBAL_H\r\n#define VERILOGGENERATORPLUGIN_GLOBAL_H\r\n\r\n#include <QtCore/qglobal.h>\r\n\r\n#ifdef VERILOGGENERATORPLUGIN_LIB\r\n# define VERILOGGENERATORPLUGIN_EXPORT Q_DECL_EXPORT\r\n#else\r\n# define VERILOGGENERATORPLUGIN_EXPORT Q_DECL_IMPORT\r\n#endif\r\n\r\n#endif // VERILOGGENERATORPLUGIN_GLOBAL_H\r\n"
  },
  {
    "path": "Plugins/VerilogImport/VerilogImport.pri",
    "content": "# ----------------------------------------------------\r\n# This file is generated by the Qt Visual Studio Tools.\r\n# ------------------------------------------------------\r\n\r\n\r\nHEADERS += ../../common/expressions/utilities.h \\\r\n    ../../common/NameGenerationPolicy.h \\\r\n    ../../IPXACTmodels/utilities/Search.h \\\r\n    ../../wizards/ComponentWizard/InstanceData.h \\\r\n    ../common/HDLmath.h \\\r\n    ./VerilogInstanceParser.h \\\r\n    ./VerilogParameterParser.h \\\r\n    ./VerilogPortParser.h \\\r\n    ./VerilogSyntax.h \\\r\n    ./verilogimport_global.h \\\r\n    ./VerilogImporter.h\r\nSOURCES += ../../common/expressions/utilities.cpp \\\r\n    ../../common/NameGenerationPolicy.cpp \\\r\n    ./VerilogImporter.cpp \\\r\n    ./VerilogInstanceParser.cpp \\\r\n    ./VerilogParameterParser.cpp \\\r\n    ./VerilogPortParser.cpp \\\r\n    ./VerilogSyntax.cpp\r\n"
  },
  {
    "path": "Plugins/VerilogImport/VerilogImport.pro",
    "content": "# ----------------------------------------------------\r\n# This file is generated by the Qt Visual Studio Add-in.\r\n# ------------------------------------------------------\r\n\r\nTEMPLATE = lib\r\n\r\nQT += core xml widgets gui\r\nCONFIG += c++11\r\n\r\nDEFINES += VERILOGIMPORT_LIB\r\n\r\nINCLUDEPATH += ./../.. \\\r\n    ./GeneratedFiles \\\r\n    .\r\n\r\nCONFIG(debug, debug|release) {\r\n    # debug mode\r\n    LIBS += \\\r\n        -L../../executable -lIPXACTmodelsd \\\r\n        -L../../executable -lKactusAPId\r\n\r\n    MOC_DIR += ./GeneratedFiles/Debug\r\n    OBJECTS_DIR += Debug\r\n    TARGET = VerilogImportd\r\n\r\n} else {\r\n    # release mode \r\n    LIBS += \\\r\n        -L../../executable -lIPXACTmodels \\\r\n        -L../../executable -lKactusAPI\r\n    \r\n    MOC_DIR += ./GeneratedFiles/Release\r\n    OBJECTS_DIR += Release\r\n    TARGET = VerilogImport\r\n}\r\n\r\nDESTDIR = ../../executable/Plugins\r\n\r\nDEPENDPATH += .\r\nUI_DIR += ./GeneratedFiles\r\nRCC_DIR += ./GeneratedFiles\r\n\r\ninclude(VerilogImport.pri)\r\n\r\ntarget.path = $$plugin_path\r\nINSTALLS += target\r\n\r\n"
  },
  {
    "path": "Plugins/VerilogImport/VerilogImport.vcxproj",
    "content": "﻿<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n<Project DefaultTargets=\"Build\" ToolsVersion=\"15.0\" xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">\r\n  <ItemGroup Label=\"ProjectConfigurations\">\r\n    <ProjectConfiguration Include=\"Debug|x64\">\r\n      <Configuration>Debug</Configuration>\r\n      <Platform>x64</Platform>\r\n    </ProjectConfiguration>\r\n    <ProjectConfiguration Include=\"Release|x64\">\r\n      <Configuration>Release</Configuration>\r\n      <Platform>x64</Platform>\r\n    </ProjectConfiguration>\r\n  </ItemGroup>\r\n  <PropertyGroup Label=\"Globals\">\r\n    <ProjectGuid>{85A166AC-D2CF-496C-9EFD-648765C4AC72}</ProjectGuid>\r\n    <Keyword>QtVS_v304</Keyword>\r\n    <WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>\r\n    <QtMsBuild Condition=\"'$(QtMsBuild)'=='' or !Exists('$(QtMsBuild)\\qt.targets')\">$(MSBuildProjectDirectory)\\QtMsBuild</QtMsBuild>\r\n  </PropertyGroup>\r\n  <Import Project=\"$(VCTargetsPath)\\Microsoft.Cpp.Default.props\" />\r\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\" Label=\"Configuration\">\r\n    <ConfigurationType>DynamicLibrary</ConfigurationType>\r\n    <PlatformToolset>v143</PlatformToolset>\r\n  </PropertyGroup>\r\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\" Label=\"Configuration\">\r\n    <ConfigurationType>DynamicLibrary</ConfigurationType>\r\n    <PlatformToolset>v143</PlatformToolset>\r\n  </PropertyGroup>\r\n  <Import Project=\"$(VCTargetsPath)\\Microsoft.Cpp.props\" />\r\n  <Target Name=\"QtMsBuildNotFound\" BeforeTargets=\"CustomBuild;ClCompile\" Condition=\"!Exists('$(QtMsBuild)\\qt.targets') or !Exists('$(QtMsBuild)\\qt.props')\">\r\n    <Message Importance=\"High\" Text=\"QtMsBuild: could not locate qt.targets, qt.props; project may not build correctly.\" />\r\n  </Target>\r\n  <ImportGroup Label=\"ExtensionSettings\">\r\n  </ImportGroup>\r\n  <ImportGroup Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\" Label=\"PropertySheets\">\r\n    <Import Project=\"$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props\" Condition=\"exists('$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props')\" Label=\"LocalAppDataPlatform\" />\r\n  </ImportGroup>\r\n  <ImportGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\" Label=\"PropertySheets\">\r\n    <Import Project=\"$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props\" Condition=\"exists('$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props')\" Label=\"LocalAppDataPlatform\" />\r\n  </ImportGroup>\r\n  <PropertyGroup Label=\"UserMacros\" />\r\n  <ImportGroup Condition=\"Exists('$(QtMsBuild)\\qt_defaults.props')\">\r\n    <Import Project=\"$(QtMsBuild)\\qt_defaults.props\" />\r\n  </ImportGroup>\r\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n    <OutDir>$(SolutionDir)executable\\Plugins\\</OutDir>\r\n  </PropertyGroup>\r\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n    <OutDir>$(SolutionDir)executable\\Plugins\\</OutDir>\r\n  </PropertyGroup>\r\n  <PropertyGroup Label=\"QtSettings\" Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n    <QtInstall>6.2.4</QtInstall>\r\n    <QtModules>core;gui;widgets;xml</QtModules>\r\n  </PropertyGroup>\r\n  <PropertyGroup Label=\"QtSettings\" Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n    <QtInstall>6.2.4</QtInstall>\r\n    <QtModules>core;gui;widgets;xml</QtModules>\r\n  </PropertyGroup>\r\n  <ImportGroup Condition=\"Exists('$(QtMsBuild)\\qt.props')\">\r\n    <Import Project=\"$(QtMsBuild)\\qt.props\" />\r\n  </ImportGroup>\r\n  <PropertyGroup>\r\n    <_ProjectFileVersion>10.0.40219.1</_ProjectFileVersion>\r\n  </PropertyGroup>\r\n  <ItemDefinitionGroup Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n    <ClCompile>\r\n      <PreprocessorDefinitions>UNICODE;VERILOGIMPORT_LIB;WIN32;WIN64;%(PreprocessorDefinitions)</PreprocessorDefinitions>\r\n      <AdditionalIncludeDirectories>.\\GeneratedFiles\\$(ConfigurationName);.\\GeneratedFiles;.\\..\\..;.;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\r\n      <Optimization>Disabled</Optimization>\r\n      <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>\r\n      <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>\r\n      <TreatWChar_tAsBuiltInType>true</TreatWChar_tAsBuiltInType>\r\n      <MultiProcessorCompilation>true</MultiProcessorCompilation>\r\n      <LanguageStandard>stdcpp17</LanguageStandard>\r\n      <AdditionalOptions>/Zc:__cplusplus %(AdditionalOptions)</AdditionalOptions>\r\n    </ClCompile>\r\n    <Link>\r\n      <SubSystem>Windows</SubSystem>\r\n      <OutputFile>$(OutDir)\\$(ProjectName).dll</OutputFile>\r\n      <AdditionalLibraryDirectories>..\\..\\executable;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>\r\n      <GenerateDebugInformation>true</GenerateDebugInformation>\r\n      <AdditionalDependencies>IPXACTmodelsd.lib;KactusAPId.lib;%(AdditionalDependencies)</AdditionalDependencies>\r\n      <TargetMachine>MachineX64</TargetMachine>\r\n      <AdditionalOptions>\r\n      </AdditionalOptions>\r\n    </Link>\r\n    <QtMoc>\r\n      <ExecutionDescription>Moc'ing %(Identity)...</ExecutionDescription>\r\n      <DynamicSource>output</DynamicSource>\r\n      <QtMocDir>.\\GeneratedFiles\\$(ConfigurationName)</QtMocDir>\r\n      <QtMocFileName>moc_%(Filename).cpp</QtMocFileName>\r\n    </QtMoc>\r\n  </ItemDefinitionGroup>\r\n  <ItemDefinitionGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n    <ClCompile>\r\n      <PreprocessorDefinitions>NDEBUG;QT_NO_DEBUG;UNICODE;VERILOGIMPORT_LIB;WIN32;WIN64;%(PreprocessorDefinitions)</PreprocessorDefinitions>\r\n      <AdditionalIncludeDirectories>.\\GeneratedFiles\\$(ConfigurationName);.\\GeneratedFiles;.\\..\\..;.;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\r\n      <DebugInformationFormat>\r\n      </DebugInformationFormat>\r\n      <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>\r\n      <TreatWChar_tAsBuiltInType>true</TreatWChar_tAsBuiltInType>\r\n      <MultiProcessorCompilation>true</MultiProcessorCompilation>\r\n      <AdditionalOptions>/Zc:__cplusplus %(AdditionalOptions)</AdditionalOptions>\r\n      <LanguageStandard>stdcpp17</LanguageStandard>\r\n    </ClCompile>\r\n    <Link>\r\n      <SubSystem>Windows</SubSystem>\r\n      <OutputFile>$(OutDir)\\$(ProjectName).dll</OutputFile>\r\n      <AdditionalLibraryDirectories>..\\..\\executable;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>\r\n      <GenerateDebugInformation>false</GenerateDebugInformation>\r\n      <AdditionalDependencies>IPXACTmodels.lib;KactusAPI.lib;%(AdditionalDependencies)</AdditionalDependencies>\r\n      <TargetMachine>MachineX64</TargetMachine>\r\n      <AdditionalOptions> /SUBSYSTEM:WINDOWS</AdditionalOptions>\r\n    </Link>\r\n    <QtMoc>\r\n      <ExecutionDescription>Moc'ing %(Identity)...</ExecutionDescription>\r\n      <DynamicSource>output</DynamicSource>\r\n      <QtMocDir>.\\GeneratedFiles\\$(ConfigurationName)</QtMocDir>\r\n      <QtMocFileName>moc_%(Filename).cpp</QtMocFileName>\r\n    </QtMoc>\r\n  </ItemDefinitionGroup>\r\n  <ItemGroup>\r\n    <ClCompile Include=\"..\\..\\common\\expressions\\utilities.cpp\" />\r\n    <ClCompile Include=\"..\\..\\common\\NameGenerationPolicy.cpp\" />\r\n    <ClCompile Include=\"VerilogImporter.cpp\" />\r\n    <ClCompile Include=\"VerilogInstanceParser.cpp\" />\r\n    <ClCompile Include=\"VerilogParameterParser.cpp\" />\r\n    <ClCompile Include=\"VerilogPortParser.cpp\" />\r\n    <ClCompile Include=\"VerilogSyntax.cpp\" />\r\n  </ItemGroup>\r\n  <ItemGroup>\r\n    <ClInclude Include=\"..\\..\\common\\expressions\\utilities.h\" />\r\n    <ClInclude Include=\"..\\..\\common\\NameGenerationPolicy.h\" />\r\n    <ClInclude Include=\"..\\..\\IPXACTmodels\\utilities\\Search.h\" />\r\n    <ClInclude Include=\"..\\..\\wizards\\ComponentWizard\\InstanceData.h\" />\r\n    <ClInclude Include=\"..\\common\\HDLmath.h\" />\r\n    <ClInclude Include=\"VerilogInstanceParser.h\" />\r\n    <ClInclude Include=\"VerilogParameterParser.h\" />\r\n    <ClInclude Include=\"VerilogPortParser.h\" />\r\n    <ClInclude Include=\"VerilogSyntax.h\" />\r\n    <QtMoc Include=\"VerilogImporter.h\">\r\n    </QtMoc>\r\n    <ClInclude Include=\"verilogimport_global.h\" />\r\n  </ItemGroup>\r\n  <ItemGroup>\r\n    <None Include=\"verilogimportplugin.json\" />\r\n  </ItemGroup>\r\n  <Import Project=\"$(VCTargetsPath)\\Microsoft.Cpp.targets\" />\r\n  <ImportGroup Condition=\"Exists('$(QtMsBuild)\\qt.targets')\">\r\n    <Import Project=\"$(QtMsBuild)\\qt.targets\" />\r\n  </ImportGroup>\r\n  <ImportGroup Label=\"ExtensionTargets\">\r\n  </ImportGroup>\r\n  <ProjectExtensions>\r\n    <VisualStudio>\r\n      <UserProperties />\r\n    </VisualStudio>\r\n  </ProjectExtensions>\r\n</Project>"
  },
  {
    "path": "Plugins/VerilogImport/VerilogImport.vcxproj.filters",
    "content": "﻿<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n<Project ToolsVersion=\"4.0\" xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">\r\n  <ItemGroup>\r\n    <Filter Include=\"Source Files\">\r\n      <UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>\r\n      <Extensions>cpp;cxx;c;def</Extensions>\r\n    </Filter>\r\n    <Filter Include=\"Header Files\">\r\n      <UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>\r\n      <Extensions>h</Extensions>\r\n    </Filter>\r\n    <Filter Include=\"Resource Files\">\r\n      <UniqueIdentifier>{D9D6E242-F8AF-46E4-B9FD-80ECBC20BA3E}</UniqueIdentifier>\r\n      <Extensions>qrc;*</Extensions>\r\n      <ParseFiles>false</ParseFiles>\r\n    </Filter>\r\n    <Filter Include=\"Generated Files\">\r\n      <UniqueIdentifier>{71ED8ED8-ACB9-4CE9-BBE1-E00B30144E11}</UniqueIdentifier>\r\n      <Extensions>moc;h;cpp</Extensions>\r\n      <SourceControlFiles>False</SourceControlFiles>\r\n    </Filter>\r\n    <Filter Include=\"Generated Files\\Debug\">\r\n      <UniqueIdentifier>{f5ff4028-2a25-4a30-806f-cc5a0cb069a7}</UniqueIdentifier>\r\n      <Extensions>cpp;moc</Extensions>\r\n      <SourceControlFiles>False</SourceControlFiles>\r\n    </Filter>\r\n    <Filter Include=\"Generated Files\\Release\">\r\n      <UniqueIdentifier>{cf2f1a47-20af-43b4-9654-05624d0a95f5}</UniqueIdentifier>\r\n      <Extensions>cpp;moc</Extensions>\r\n      <SourceControlFiles>False</SourceControlFiles>\r\n    </Filter>\r\n  </ItemGroup>\r\n  <ItemGroup>\r\n    <ClCompile Include=\"VerilogImporter.cpp\">\r\n      <Filter>Source Files</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"VerilogPortParser.cpp\">\r\n      <Filter>Source Files</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"VerilogParameterParser.cpp\">\r\n      <Filter>Source Files</Filter>\r\n    </ClCompile>\r\n    \r\n    \r\n    <ClCompile Include=\"VerilogSyntax.cpp\">\r\n      <Filter>Source Files</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\common\\NameGenerationPolicy.cpp\">\r\n      <Filter>Source Files</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"VerilogInstanceParser.cpp\">\r\n      <Filter>Source Files</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\common\\expressions\\utilities.cpp\">\r\n      <Filter>Source Files</Filter>\r\n    </ClCompile>\r\n  </ItemGroup>\r\n  <ItemGroup>\r\n    <ClInclude Include=\"verilogimport_global.h\">\r\n      <Filter>Header Files</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"VerilogPortParser.h\">\r\n      <Filter>Header Files</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\common\\HDLmath.h\">\r\n      <Filter>Header Files</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"VerilogParameterParser.h\">\r\n      <Filter>Header Files</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"VerilogSyntax.h\">\r\n      <Filter>Header Files</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\common\\NameGenerationPolicy.h\">\r\n      <Filter>Header Files</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\IPXACTmodels\\utilities\\Search.h\">\r\n      <Filter>Header Files</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"VerilogInstanceParser.h\">\r\n      <Filter>Header Files</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\common\\expressions\\utilities.h\">\r\n      <Filter>Header Files</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\wizards\\ComponentWizard\\InstanceData.h\">\r\n      <Filter>Header Files</Filter>\r\n    </ClInclude>\r\n  </ItemGroup>\r\n  <ItemGroup>\r\n    <QtMoc Include=\"VerilogImporter.h\">\r\n      <Filter>Header Files</Filter>\r\n    </QtMoc>\r\n  </ItemGroup>\r\n  <ItemGroup>\r\n    <None Include=\"verilogimportplugin.json\" />\r\n  </ItemGroup>\r\n</Project>"
  },
  {
    "path": "Plugins/VerilogImport/VerilogImporter.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: VerilogImporter.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Esko Pekkarinen\r\n// Date: 23.09.2014\r\n//\r\n// Description:\r\n// Import plugin for verilog source files.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"VerilogImporter.h\"\r\n\r\n#include \"VerilogSyntax.h\"\r\n\r\n#include <IPXACTmodels/Component/Component.h>\r\n\r\n#include <common/NameGenerationPolicy.h>\r\n\r\n#include <KactusAPI/include/ImportColors.h>\r\n\r\n#include <QString>\r\n\r\nnamespace\r\n{\r\n    const QRegularExpression MODULENAME_EXP(\"MODULE\\\\s+(\\\\w+)\", QRegularExpression::CaseInsensitiveOption);\r\n}\r\n\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VerilogImporter::VerilogImporter()\r\n//-----------------------------------------------------------------------------\r\nVerilogImporter::VerilogImporter():\r\nQObject(0),\r\nportParser_(),\r\nparameterParser_(),\r\ninstanceParser_(),\r\nhighlighter_(0)\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VerilogImporter::getName()\r\n//-----------------------------------------------------------------------------\r\nQString VerilogImporter::getName() const\r\n{\r\n    return \"Verilog importer\";\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VerilogImporter::getVersion()\r\n//-----------------------------------------------------------------------------\r\nQString VerilogImporter::getVersion() const\r\n{\r\n    return \"1.3\";\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VerilogImporter::getDescription()\r\n//-----------------------------------------------------------------------------\r\nQString VerilogImporter::getDescription() const\r\n{\r\n    return \"Imports model parameters and ports from a verilog file.\";\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VerilogImporter::getVendor()\r\n//-----------------------------------------------------------------------------\r\nQString VerilogImporter::getVendor() const\r\n{\r\n    return tr(\"Tampere University (tuni.fi)\");\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VerilogImporter::getLicense()\r\n//-----------------------------------------------------------------------------\r\nQString VerilogImporter::getLicense() const\r\n{\r\n    return tr(\"GPL2\");\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VerilogImporter::getLicenseHolder()\r\n//-----------------------------------------------------------------------------\r\nQString VerilogImporter::getLicenseHolder() const\r\n{\r\n    return tr(\"Public\");\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VerilogImporter::getSettingsWidget()\r\n//-----------------------------------------------------------------------------\r\nQWidget* VerilogImporter::getSettingsWidget()\r\n{\r\n    return nullptr;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VerilogImporter::getProgramRequirements()\r\n//-----------------------------------------------------------------------------\r\nQList<IPlugin::ExternalProgramRequirement> VerilogImporter::getProgramRequirements()\r\n{\r\n    return QList<IPlugin::ExternalProgramRequirement>();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VerilogImporter::acceptedFileTypes()\r\n//-----------------------------------------------------------------------------\r\nQStringList VerilogImporter::getSupportedFileTypes() const\r\n{\r\n    QStringList supportedTypes;\r\n    supportedTypes << \"verilogSource\" << \"verilogSource-95\" << \"verilogSource-2001\" << \"systemVerilogSource\";\r\n\r\n    return supportedTypes;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VerilogImporter::getCompatibilityWarnings()\r\n//-----------------------------------------------------------------------------\r\nQString VerilogImporter::getCompatibilityWarnings() const\r\n{\r\n    return QString();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VerilogImporter::getFileComponents()\r\n//-----------------------------------------------------------------------------\r\nQStringList VerilogImporter::getFileComponents(QString const& input) const\r\n{\r\n    QStringList fileModules;\r\n\r\n    QRegularExpression multilineComment(VerilogSyntax::MULTILINE_COMMENT);\r\n\r\n    QString inspect = input;\r\n    int moduleBegin = inspect.indexOf(VerilogSyntax::MODULE_BEGIN);\r\n    int moduleEnd = VerilogSyntax::MODULE_END.match(inspect).capturedEnd();\r\n\r\n    while (moduleBegin != -1)\r\n    {\r\n        QString newModule = inspect.mid(moduleBegin, moduleEnd - moduleBegin);\r\n        fileModules.append(newModule);\r\n        inspect.remove(newModule);\r\n\r\n        moduleBegin = inspect.indexOf(VerilogSyntax::MODULE_BEGIN);\r\n        moduleEnd = VerilogSyntax::MODULE_END.match(inspect).capturedEnd();\r\n    }\r\n\r\n    return fileModules;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VerilogImporter::getComponentName()\r\n//-----------------------------------------------------------------------------\r\nQString VerilogImporter::getComponentName(QString const& componentDeclaration) const\r\n{\r\n    QRegularExpressionMatch match = MODULENAME_EXP.match(componentDeclaration);\r\n    return match.captured(1);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VerilogImporter::import()\r\n//-----------------------------------------------------------------------------\r\nvoid VerilogImporter::import(QString const& input, QString const& componentDeclaration,\r\n    QSharedPointer<Component> targetComponent)\r\n{   \r\n    if (hasModuleDeclaration(componentDeclaration))\r\n    {\r\n        highlightModule(input, componentDeclaration);\r\n\r\n\t\tQSharedPointer<ComponentInstantiation> targetComponentInstantiation;\r\n\t\tsetLanguageAndEnvironmentalIdentifiers(targetComponent, targetComponentInstantiation);\r\n        importModelName(componentDeclaration, targetComponentInstantiation);\r\n\r\n        parameterParser_.import(componentDeclaration, targetComponent, targetComponentInstantiation);\r\n\t\tportParser_.import(componentDeclaration, targetComponent);\r\n        instanceParser_.import(input, componentDeclaration, targetComponent);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VerilogImporter::setHighlighter()\r\n//-----------------------------------------------------------------------------\r\nvoid VerilogImporter::setHighlighter(Highlighter* highlighter)\r\n{\r\n    highlighter_ = highlighter;\r\n\r\n    instanceParser_.setHighlighter(highlighter);\r\n    parameterParser_.setHighlighter(highlighter);\r\n    portParser_.setHighlighter(highlighter);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VerilogImporter::setExpressionParser()\r\n//-----------------------------------------------------------------------------\r\nvoid VerilogImporter::setExpressionParser(QSharedPointer<ExpressionParser> parser)\r\n{\r\n    portParser_.setExpressionParser(parser);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VerilogImporter::hasModuleDeclaration()\r\n//-----------------------------------------------------------------------------\r\nbool VerilogImporter::hasModuleDeclaration(QString const& input)\r\n{\r\n\tQRegularExpression multilineComment(VerilogSyntax::MULTILINE_COMMENT);\r\n\r\n\tQString inspect = input;\r\n\tinspect = inspect.remove(VerilogSyntax::COMMENTLINE).remove(multilineComment);\r\n\r\n    int moduleBegin = inspect.indexOf(VerilogSyntax::MODULE_BEGIN);\r\n    int moduleEnd = inspect.indexOf(VerilogSyntax::MODULE_END, moduleBegin);\r\n\r\n    return moduleBegin != -1 && moduleEnd != -1;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VerilogImporter::highlightModule()\r\n//-----------------------------------------------------------------------------\r\nvoid VerilogImporter::highlightModule(QString const& input, QString const& moduleDeclaration)\r\n{\r\n    QRegularExpressionMatch match = MODULENAME_EXP.match(moduleDeclaration);\r\n    QString moduleDeclarationLine = match.captured();\r\n\r\n    int moduleBegin = input.indexOf(moduleDeclarationLine);\r\n    int moduleEnd = VerilogSyntax::MODULE_END.match(input, moduleBegin).capturedEnd();\r\n\r\n    QString highlightedModule = input.mid(moduleBegin, moduleEnd - moduleBegin);\r\n    if (highlighter_)\r\n    {\r\n        highlighter_->applyFontColor(highlightedModule, KactusColors::REGULAR_TEXT);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VerilogImporter::importModelName()\r\n//-----------------------------------------------------------------------------\r\nvoid VerilogImporter::importModelName(QString const& moduleDeclaration,\r\n    QSharedPointer<ComponentInstantiation> targetComponentInstantiation)\r\n{\r\n    QRegularExpressionMatch match = MODULENAME_EXP.match(moduleDeclaration);\r\n\r\n    targetComponentInstantiation->setModuleName(match.captured(1));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VerilogImporter::findOrCreateFlatView()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<View> VerilogImporter::findOrCreateFlatView(QSharedPointer<Component> targetComponent) const\r\n{\r\n\t// Find any flat views from the target component.\r\n    QStringList flatViews = targetComponent->getFlatViews();\r\n\r\n    if (flatViews.isEmpty())\r\n    {\r\n\t\t// If there was none, create a new view.\r\n\t\tQSharedPointer<View> newView( new View() );\r\n\t\t// Rip its name from the generation policy.\r\n\t\tnewView->setName(NameGenerationPolicy::flatViewName(\"verilog\"));\r\n\t\t// Add to the component.\r\n\t\ttargetComponent->getViews()->append(newView);\r\n\r\n\t\t// Return the result.\r\n\t\treturn newView;\r\n    }\r\n\r\n\t// Return the first one from the list.\r\n    return targetComponent->getModel()->findView(flatViews.first());\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VerilogImporter::setLanguageAndEnvironmentalIdentifiers()\r\n//-----------------------------------------------------------------------------\r\nvoid VerilogImporter::setLanguageAndEnvironmentalIdentifiers(QSharedPointer<Component> targetComponent,\r\n\tQSharedPointer<ComponentInstantiation>& targetComponentInstantiation) const\r\n{\r\n\t// Needs a view, no matter if it exist.\r\n    QSharedPointer<View> flatView = findOrCreateFlatView(targetComponent);\r\n\r\n\t// Create environment identifiers for the view as needed.\r\n    QSharedPointer<View::EnvironmentIdentifier> envIdentifierForImport(\r\n        new View::EnvironmentIdentifier(QStringLiteral(\"Verilog\")));\r\n\tenvIdentifierForImport->tool = VerilogSyntax::TOOL_NAME;\r\n\r\n    if (!flatView->hasEnvIdentifier(envIdentifierForImport))\r\n    {\r\n        flatView->getEnvIdentifiers()->append(envIdentifierForImport);\r\n    }\r\n\r\n\t// Must have a component instantiation for module parameters.\r\n\ttargetComponentInstantiation = targetComponent->getModel()->\r\n\t\tfindComponentInstantiation(flatView->getComponentInstantiationRef());\r\n\r\n\tif ( !targetComponentInstantiation )\r\n\t{\r\n\t\t// Create if does not exist.\r\n\t\tQString instaName = NameGenerationPolicy::componentInstantiationName(\"verilog\");\r\n\t\ttargetComponentInstantiation = QSharedPointer<ComponentInstantiation>( new ComponentInstantiation );\r\n\t\t// Set appropriate name and language.\r\n\t\ttargetComponentInstantiation->setName(instaName);\r\n\t\ttargetComponentInstantiation->setLanguage(\"Verilog\");\r\n\r\n\t\t// Add to the component.\r\n\t\ttargetComponent->getComponentInstantiations()->append(targetComponentInstantiation);\r\n\t\t// Set the view to refer to it.\r\n\t\tflatView->setComponentInstantiationRef( instaName );\r\n\t}\r\n}\r\n"
  },
  {
    "path": "Plugins/VerilogImport/VerilogImporter.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: VerilogImporter.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Esko Pekkarinen\r\n// Date: 23.09.2014\r\n//\r\n// Description:\r\n// Import plugin for verilog source files.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef VERILOGIMPORTER_H\r\n#define VERILOGIMPORTER_H\r\n\r\n#include \"verilogimport_global.h\"\r\n\r\n#include \"VerilogPortParser.h\"\r\n#include \"VerilogParameterParser.h\"\r\n#include \"Plugins/VerilogImport/VerilogInstanceParser.h\"\r\n\r\n#include <KactusAPI/include/ExpressionSupport.h>\r\n#include <KactusAPI/include/ImportPlugin.h>\r\n#include <KactusAPI/include/HighlightSource.h>\r\n\r\n#include <QSharedPointer>\r\n#include <QString>\r\n\r\nclass Component;\r\nclass View;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Import plugin for verilog source files.\r\n//-----------------------------------------------------------------------------\r\nclass VERILOGIMPORT_EXPORT VerilogImporter: public QObject, public ImportPlugin, public HighlightSource, \r\n    public ExpressionSupport\r\n{\r\n    Q_OBJECT\r\n    Q_PLUGIN_METADATA(IID \"kactus2.plugins.verilogimportplugin\" FILE \"verilogimportplugin.json\")\r\n    Q_INTERFACES(IPlugin)\r\n    Q_INTERFACES(ImportPlugin)\r\n\r\npublic:\r\n\r\n\t//! The constructor.\r\n\tVerilogImporter();\r\n\r\n\t//! The destructor.\r\n\tvirtual ~VerilogImporter() = default;\r\n    \r\n    /*!\r\n     *  Returns the name of the plugin.\r\n     */\r\n    virtual QString getName() const override final;\r\n\r\n    /*!\r\n     *  Returns the version of the plugin.\r\n     */\r\n    virtual QString getVersion() const override final;\r\n    \r\n    /*!\r\n     *  Returns the description of the plugin.\r\n     */\r\n    virtual QString getDescription() const override final;\r\n  \r\n    /*!\r\n     *  Returns the vendor of the plugin.\r\n     */\r\n    virtual QString getVendor() const override final;\r\n    \r\n    /*!\r\n     *  Returns the license of the plugin.\r\n     */\r\n    virtual QString getLicense() const override final;\r\n    \r\n    /*!\r\n     *  Returns the license holder of the plugin.\r\n     */\r\n    virtual QString getLicenseHolder() const override final;\r\n    \r\n    /*!\r\n     *  Returns the settings widget.\r\n     */\r\n    virtual QWidget* getSettingsWidget() override final;\r\n\r\n    /*!\r\n     *  This is used to access the settings modified by function getSettingsWidget().\r\n     */\r\n    virtual PluginSettingsModel* getSettingsModel() override final {return nullptr;}\r\n\r\n    /*! \r\n     *   Returns the external program requirements of the plugin.\r\n     */\r\n    virtual QList<ExternalProgramRequirement> getProgramRequirements() override final;\r\n    \r\n    /*!\r\n     *  Returns the supported import file types.\r\n     *\r\n     *    @return The file types the import parser supports.\r\n     */\r\n    virtual QStringList getSupportedFileTypes() const override final;\r\n    \r\n    /*!\r\n     *  Gets any compatibility warnings for the plugin.\r\n     *\r\n     *    @return The warning text.\r\n     */\r\n    virtual QString getCompatibilityWarnings() const override final;\r\n\r\n    /*!\r\n     *  Get component declarations from the selected input file.\r\n     *\r\n     *    @param [in] input   The selected input file.\r\n     *\r\n     *    @return List of component declarations found in the selected input.\r\n     */\r\n    virtual QStringList getFileComponents(QString const& input) const override final;\r\n\r\n    /*!\r\n     *  Get the name of the selected component declaration.\r\n     *\r\n     *    @param [in] componentDeclaration    The selected component declaration.\r\n     *\r\n     *    @return Name of the selected component declaration.\r\n     */\r\n    virtual QString getComponentName(QString const& componentDeclaration) const override final;\r\n\r\n    /*!\r\n     *   Parses a verilog input, sets up an rtl view and creates model parameters and ports.\r\n     *\r\n     *    @param [in] input                   The input text to parse.\r\n     *    @param [in] componentDeclaration    Declaration of the selected component.\r\n     *    @param [in] targetComponent         The component to apply all imported changes to.\r\n     */\r\n    virtual void import(QString const& input, QString const& componentDeclaration,\r\n        QSharedPointer<Component> targetComponent) override final;\r\n\r\n    /*!\r\n     *  Sets the given visualizer to be used by the import.\r\n     *\r\n     *    @param [in] visualizer   The visualizer to use.          \r\n     */\r\n    virtual void setHighlighter(Highlighter* highlighter) override final;\r\n\r\n    /*!\r\n     *  Sets the parser to use for expressions.\r\n     *\r\n     *    @param [in] parser   The parser to use.\r\n     */\r\n    virtual void setExpressionParser(QSharedPointer<ExpressionParser> parser) override final;\r\n\r\nprivate:\r\n\r\n\t// Disable copying.\r\n\tVerilogImporter(VerilogImporter const& rhs);\r\n\tVerilogImporter& operator=(VerilogImporter const& rhs);\r\n    \r\n    \r\n    /*!\r\n     *  Checks if the given input has a valid module declaration.\r\n     *\r\n     *    @param [in] input   The input to search for module declaration.\r\n     *\r\n     *    @return True, if a valid module was found, otherwise false.\r\n     */\r\n    bool hasModuleDeclaration(QString const& input);\r\n\r\n    /*!\r\n     *  Highlights the module section in the input.\r\n     *\r\n     *    @param [in] input               The input file content to highlight entity in.\r\n     *    @param [in] moduleDeclaration   Selected module declaration from the file.\r\n     */\r\n    void highlightModule(QString const& input, QString const& moduleDeclaration);\r\n\r\n    /*!\r\n     *  Parses the model name from the input and sets it in the rtl view.\r\n     *\r\n     *    @param [in] moduleDeclaration                   The selected module declaration.\r\n     *    @param [in/out] targetComponentInstantiation    The component instance to set the name in.\r\n     */\r\n    void importModelName(QString const& moduleDeclaration,\r\n        QSharedPointer<ComponentInstantiation> targetComponentInstantiation);\r\n\r\n    /*!\r\n     *  Finds a flat (rtl) view from the target component or creates one, if none are found.\r\n     *\r\n     *    @return Flat view to set up with model name and environmental identifiers.\r\n     */\r\n    QSharedPointer<View> findOrCreateFlatView(QSharedPointer<Component> targetComponent) const;\r\n    \r\n    /*!\r\n     *  Sets the language and environmental identifiers in the rtl view.\r\n     */\r\n    void setLanguageAndEnvironmentalIdentifiers(QSharedPointer<Component> targetComponent,\r\n\t\tQSharedPointer<ComponentInstantiation>& targetComponentInstantiation) const;    \r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! The port parser to use for importing ports.\r\n    VerilogPortParser portParser_;\r\n\r\n    //! The parameter parser to use for importing model parameters.\r\n    VerilogParameterParser parameterParser_;\r\n\r\n    //! Instance parser used for importing contained component instances.\r\n    VerilogInstanceParser instanceParser_;\r\n\r\n    //! The highlighter to use.\r\n    Highlighter* highlighter_;\r\n};\r\n\r\n#endif // VERILOGIMPORTER_H\r\n"
  },
  {
    "path": "Plugins/VerilogImport/VerilogInstanceParser.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: VerilogInstanceParser.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Mikko Teuho\n// Date: 03.04.2019\n//\n// Description:\n// Parser for Verilog instances.\n//-----------------------------------------------------------------------------\n\n#include \"VerilogInstanceParser.h\"\n#include \"VerilogSyntax.h\"\n\n#include <common/expressions/utilities.h>\n\n#include <KactusAPI/include//ImportColors.h>\n\n#include <wizards/ComponentWizard/InstanceData.h>\n\n#include <IPXACTmodels/Component/Component.h>\n#include <IPXACTmodels/utilities/Search.h>\n#include <IPXACTmodels/kactusExtensions/Kactus2Value.h>\n#include <IPXACTmodels/kactusExtensions/Kactus2Group.h>\n\n#include <QRegularExpression>\n\n//-----------------------------------------------------------------------------\n// Function: VerilogInstanceParser::VerilogInstanceParser()\n//-----------------------------------------------------------------------------\nVerilogInstanceParser::VerilogInstanceParser():\nhighlighter_(0)\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: VerilogInstanceParser::setHighlighter()\n//-----------------------------------------------------------------------------\nvoid VerilogInstanceParser::setHighlighter(Highlighter* highlighter)\n{\n    highlighter_ = highlighter;\n}\n\n//-----------------------------------------------------------------------------\n// Function: VerilogInstanceParser::import()\n//-----------------------------------------------------------------------------\nvoid VerilogInstanceParser::import(QString const& input, QString const& componentDeclaration,\n    QSharedPointer<Component> targetComponent)\n{\n    QVector<QRegularExpressionMatch> instanceDeclarations = findInstances(input, componentDeclaration);\n\n    if (!instanceDeclarations.isEmpty())\n    {\n\t\tQString vlnvIdentifier = \"IP-XACT VLNV:\";\n        QSharedPointer<Kactus2Group> instancesGroup(new Kactus2Group(InstanceData::VERILOGINSTANCES));\n\n        for (auto& instanceMatch : instanceDeclarations)\n        {\n\t\t\tQString instanceModuleName = instanceMatch.captured(2);\n\t\t\tQString parameterDeclarations = instanceMatch.captured(3);\n\t\t\tQString instanceName = instanceMatch.captured(4);\n\t\t\tQString connectionDeclarations = instanceMatch.captured(5);\n\n            QSharedPointer<Kactus2Group> instanceExtension(new Kactus2Group(InstanceData::SINGLEINSTANCE));\n\n\t\t\tQString instanceVLNV = instanceMatch.captured(1);\n            if (instanceVLNV.isEmpty() == false)\n            {\n\t\t\t\tinstanceVLNV = instanceVLNV.remove(0, instanceVLNV.indexOf(vlnvIdentifier) + vlnvIdentifier.size()).simplified().remove(\" \");\n\t\t\t\t\n                QSharedPointer<Kactus2Value> componentVLNVExtension(new Kactus2Value(\n\t\t\t\t\tInstanceData::COMPONENTVLNV, instanceVLNV));\n\n\t\t\t\tinstanceExtension->addToGroup(componentVLNVExtension);\n            }\n            QSharedPointer<Kactus2Value> instanceNameExtension(new Kactus2Value(\n                InstanceData::INSTANCENAME, instanceName));\n            QSharedPointer<Kactus2Value> moduleExtension(new Kactus2Value(\n                InstanceData::MODULENAME, instanceModuleName));\n\n            instanceExtension->addToGroup(instanceNameExtension);\n            instanceExtension->addToGroup(moduleExtension);\n\n            if (!parameterDeclarations.isEmpty())\n            {\n                QVector<QPair<QString, QString> > instanceParameters = getSeparatedSubItems(parameterDeclarations);\n                QSharedPointer<Kactus2Group> parameterGroup = createSubItemGroup(\n                    InstanceData::PARAMETERS, InstanceData::SINGLEPARAMETER, instanceParameters);\n                if (parameterGroup)\n                {\n                    instanceExtension->addToGroup(parameterGroup);\n                }\n            }\n\n            if (!connectionDeclarations.isEmpty())\n            {\n                QVector<QPair<QString, QString> > instanceConnections = getSeparatedSubItems(connectionDeclarations);\n                QSharedPointer<Kactus2Group> connectionGroup = createSubItemGroup(\n                    InstanceData::CONNECTIONS, InstanceData::SINGLECONNECTION, instanceConnections);\n                if (connectionGroup)\n                {\n                    instanceExtension->addToGroup(connectionGroup);\n                }\n            }\n\n            instancesGroup->addToGroup(instanceExtension);\n        }\n\n        targetComponent->getVendorExtensions()->append(instancesGroup);\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: VerilogInstanceParser::findInstances()\n//-----------------------------------------------------------------------------\nQVector<QRegularExpressionMatch> VerilogInstanceParser::findInstances(QString const& input,\n    QString const& componentDeclaration)\n{\n    QVector<QRegularExpressionMatch> instances;\n    QString inspect = componentDeclaration;\n\n    QRegularExpression multilineComment(VerilogSyntax::MULTILINE_COMMENT);\n//     QRegularExpression strayComment(VerilogSyntax::COMMENT);\n//     inspect = inspect.remove(VerilogSyntax::COMMENTLINE).remove(multilineComment).remove(strayComment);\n    QRegularExpression commentsWithoutVLNVs(\"[\\\\n\\\\r]?[\\\\t\\\\f\\\\cK ]*[/]{2}(?! IP-XACT VLNV:).*\");\n    inspect = inspect.remove(commentsWithoutVLNVs).remove(multilineComment);\n\n    QString VLNVString = \"(\\\\/\\\\/\\\\s*IP-XACT VLNV:\\\\s*.*\\\\s*)?\";\n    QString expressionString =\n        \"\\\\b([a-zA-Z_][\\\\w$]*)(\\\\s+#(?:(?:.|\\\\n)(?!(?:[)]\\\\s*[a-zA-Z_]|;)))*(?:.|\\\\n)\\\\))?\\\\s+([a-zA-Z_][\\\\w$]*)\\\\s*(\\\\((?:(?:.|\\\\n)(?!\\\\);))*\\\\s*\\\\)+;)\";\n    expressionString = VLNVString + expressionString;\n    QRegularExpression instanceExpression(expressionString);\n    QRegularExpressionMatchIterator instanceMatchIterator = instanceExpression.globalMatch(inspect);\n\n    QRegularExpressionMatchIterator multilineCommentIterator = multilineComment.globalMatch(input);\n\n    while (instanceMatchIterator.hasNext())\n    {\n        QRegularExpressionMatch instanceMatch = instanceMatchIterator.next();\n\n        QString instanceModuleName = instanceMatch.captured(1);\n\t\tif (instanceMatch.captured(2).compare(QStringLiteral(\"module\"), Qt::CaseInsensitive) != 0)\n        {\n            instances.append(instanceMatch);\n            highlightInstance(input, componentDeclaration, instanceMatch, multilineCommentIterator);\n        }\n    }\n\n    return instances;\n}\n\n//-----------------------------------------------------------------------------\n// Function: VerilogInstanceParser::highlightInstance()\n//-----------------------------------------------------------------------------\nvoid VerilogInstanceParser::highlightInstance(QString const& input, QString const& /*moduleDeclaration*/,\n    QRegularExpressionMatch const& instanceMatch, QRegularExpressionMatchIterator const& multilineCommentIterator)\n{\n    QString instanceModuleName = instanceMatch.captured(1);\n    QString instanceName = instanceMatch.captured(3);\n\n    QRegularExpression inputInstanceExpression(\"\\\\b(\" + instanceModuleName +\n        \"\\\\s+(?:[^;])*?\" +\n        instanceName + \")\\\\s*(\\\\((?:(?:.|\\\\n)(?!\\\\);))*\\\\s*\\\\)+;)\", QRegularExpression::DotMatchesEverythingOption);\n\n    QRegularExpressionMatchIterator instanceIntroductionIterator = inputInstanceExpression.globalMatch(input);\n    while (instanceIntroductionIterator.hasNext())\n    {\n        QRegularExpressionMatch instanceIntroductionMatch = instanceIntroductionIterator.next();\n        if (!matchIsWithinComments(instanceIntroductionMatch, multilineCommentIterator))\n        {\n            QString matchedIntroduction = instanceIntroductionMatch.captured(1);\n            int instanceModuleBeginIndex =\n                instanceIntroductionMatch.capturedStart() + matchedIntroduction.indexOf(instanceModuleName);\n            int instanceModuleEndIndex = instanceModuleBeginIndex + instanceModuleName.length();\n\n            int instanceNameBeginIndex =\n                instanceIntroductionMatch.capturedStart() + matchedIntroduction.lastIndexOf(instanceName);\n            int instanceNameEndIndex = instanceNameBeginIndex + instanceName.length();\n\n            highlighter_->applyHighlight(\n                instanceModuleBeginIndex, instanceModuleEndIndex, ImportColors::INSTANCECOLOR);\n            highlighter_->applyHighlight(\n                instanceNameBeginIndex, instanceNameEndIndex, ImportColors::INSTANCECOLOR);\n        }\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: VerilogInstanceParser::matchIsWithinComments()\n//-----------------------------------------------------------------------------\nbool VerilogInstanceParser::matchIsWithinComments(QRegularExpressionMatch const& expressionMatch,\n    QRegularExpressionMatchIterator commentMatchIterator) const\n{\n    int expressionStart = expressionMatch.capturedStart();\n\n    while (commentMatchIterator.hasNext())\n    {\n        QRegularExpressionMatch commentMatch = commentMatchIterator.next();\n        int commentStart = commentMatch.capturedStart();\n        int commentEnd = commentMatch.capturedEnd();\n\n        if (expressionStart > commentStart && expressionStart < commentEnd)\n        {\n            return true;\n        }\n    }\n\n    return false;\n}\n\n//-----------------------------------------------------------------------------\n// Function: VerilogInstanceParser::getSeparatedSubItems()\n//-----------------------------------------------------------------------------\nQVector<QPair<QString, QString> > VerilogInstanceParser::getSeparatedSubItems(QString& subItemDeclarations) const\n{\n    QVector<QPair<QString, QString> > subItemReDeclarations;\n\n    QRegularExpression subItemSeparatorExpression(QStringLiteral(\"((?:.(?!\\\\())*.)(.*)\"));\n\n    QRegularExpression subItemExpression(QStringLiteral(\"\\\\.(?:(.|\\\\s)(?!(,|(\\\\)\\\\s*\\\\s))))*.*\\\\)\"));\n    QRegularExpressionMatchIterator subItemMatchIterator = subItemExpression.globalMatch(subItemDeclarations);\n\n    while (subItemMatchIterator.hasNext())\n    {\n        QRegularExpressionMatch subItemMatch = subItemMatchIterator.next();\n        QString subItemText = subItemMatch.captured().remove(0, 1);\n\n        QRegularExpressionMatch separatedSubItemMatch = subItemSeparatorExpression.match(subItemText);\n        QString subItemName = separatedSubItemMatch.captured(1).simplified();\n        QString subItemValue = separatedSubItemMatch.captured(2).remove(0, 1);\n        subItemValue.chop(1);\n        subItemValue = subItemValue.simplified();\n\n        QPair<QString, QString> subItem;\n        subItem.first = subItemName;\n        subItem.second = subItemValue;\n\n        subItemReDeclarations.append(subItem);\n    }\n\n    return subItemReDeclarations;\n}\n\n//-----------------------------------------------------------------------------\n// Function: VerilogInstanceParser::createSubItemGroup()\n//-----------------------------------------------------------------------------\nQSharedPointer<Kactus2Group> VerilogInstanceParser::createSubItemGroup(QString const& groupName,\n    QString const& itemType, QVector<QPair<QString, QString>> const& subItems) const\n{\n    if (subItems.isEmpty())\n    {\n        return QSharedPointer<Kactus2Group>();\n    }\n    \n    QSharedPointer<Kactus2Group> subItemGroup(new Kactus2Group(groupName));\n    for (auto const& item : subItems)\n    {\n        QSharedPointer<Kactus2Group> nameValueGroup(new Kactus2Group(itemType));\n\n        QSharedPointer<Kactus2Value> itemName(new Kactus2Value(InstanceData::SUBITEMNAME, item.first));\n        QSharedPointer<Kactus2Value> itemValue(new Kactus2Value(InstanceData::SUBITEMVALUE, item.second));\n\n        nameValueGroup->addToGroup(itemName);\n        nameValueGroup->addToGroup(itemValue);\n\n        subItemGroup->addToGroup(nameValueGroup);\n    }\n\n    return subItemGroup;\n}\n"
  },
  {
    "path": "Plugins/VerilogImport/VerilogInstanceParser.h",
    "content": "//-----------------------------------------------------------------------------\n// File: VerilogInstanceParser.h\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Mikko Teuho\n// Date: 03.04.2019\n//\n// Description:\n// Parser for Verilog instances.\n//-----------------------------------------------------------------------------\n\n#ifndef VERILOGINSTANCEPARSER_H\n#define VERILOGINSTANCEPARSER_H\n\n#include <KactusAPI/include/HighlightSource.h>\n\n#include <QSharedPointer>\n#include <QRegularExpressionMatchIterator>\n\nclass Component;\nclass Kactus2Group;\n\n//-----------------------------------------------------------------------------\n//! Parser for Verilog instances.\n//-----------------------------------------------------------------------------\nclass VerilogInstanceParser : public HighlightSource\n{\npublic:\n\n    /*!\n     *  The constructor.\n     */\n    VerilogInstanceParser();\n\n    /*!\n     *  The destructor.\n     */\n    virtual ~VerilogInstanceParser() = default;\n\n    // Disable copying.\n    VerilogInstanceParser(VerilogInstanceParser const& rhs) = delete;\n    VerilogInstanceParser& operator=(VerilogInstanceParser const& rhs) = delete;\n\n    /*!\n     *  Runs the port parsing for the given input and adds the parsed ports to the given component.\n     *\n     *    @param [in] input                   The input text to parse.\n     *    @param [in] componentDeclaration    The selected component declaration.\n     *    @param [in] targetComponent         The component to add all the imported parameters to.\n     */\n    virtual void import(QString const& input, QString const& componentDeclaration,\n        QSharedPointer<Component> targetComponent);\n\n    /*!\n     *  Sets the given highlighter to be used by the generic parser.\n     *\n     *    @param [in] highlighter   The highlighter to use.          \n     */\n    virtual void setHighlighter(Highlighter* highlighter);\n\nprivate:\n\n    /*!\n     *  Find matches for the component instances in the selected verilog file.\n     *\n     *    @param [in] input                   The selected verilog file.\n     *    @param [in] componentDeclaration    The selected component declaration.\n     *\n     *    @return List of component instance matches.\n     */\n    QVector<QRegularExpressionMatch> findInstances(QString const& input, QString const& componentDeclaration);\n\n    /*!\n     *  Highlight the selected component instance.\n     *\n     *    @param [in] input                       The selected verilog file.\n     *    @param [in] moduleDeclaration           The selected component declaration.\n     *    @param [in] instanceMatch               The selected component instance match.\n     *    @param [in] multilineCommentIterator    Regular expression Match iterator for multi line comments.\n     */\n    void highlightInstance(QString const& input, QString const& moduleDeclaration,\n        QRegularExpressionMatch const& instanceMatch,\n        QRegularExpressionMatchIterator const& multilineCommentIterator);\n\n    /*!\n     *  Check if a regular expression match is located within comments.\n     *\n     *    @param [in] expressionMatch         The selected regular expression match.\n     *    @param [in] commentMatchIterator    Regular expression Match iterator for multi line comments.\n     *\n     *    @return True, if the match is located within comments, false otherwise.\n     */\n    bool matchIsWithinComments(QRegularExpressionMatch const& expressionMatch,\n        QRegularExpressionMatchIterator commentMatchIterator) const;\n\n    /*!\n     *  Get a list of separated sub items and their values from the selected sub item declarations.\n     *\n     *    @param [in] subItemDeclarations     The selected sub item declarations.\n     *\n     *    @return List of sub item name value pairs.\n     */\n    QVector<QPair<QString, QString> > getSeparatedSubItems(QString& subItemDeclarations) const;\n\n    /*!\n     *  Create a vendor extension group for the contained sub items.\n     *\n     *    @param [in] groupName   Name of the sub items.\n     *    @param [in] itemType    Type of the sub items.\n     *    @param [in] subItems    List of sub item name value pairs.\n     *\n     *    @return The created sub item vendor extension group.\n     */\n    QSharedPointer<Kactus2Group> createSubItemGroup(QString const& groupName, QString const& itemType,\n        QVector<QPair<QString, QString> > const& subItems) const;\n\n    //-----------------------------------------------------------------------------\n    // Data.\n    //-----------------------------------------------------------------------------\n\n    //! The highlighter to use.\n    Highlighter* highlighter_;\n};\n\n#endif // VERILOGINSTANCEPARSER_H\n"
  },
  {
    "path": "Plugins/VerilogImport/VerilogParameterParser.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: VerilogParameterParser.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Janne Virtanen\r\n// Date: 26.09.2014\r\n//\r\n// Description:\r\n// Parser for Verilog parameters.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"VerilogParameterParser.h\"\r\n#include \"VerilogSyntax.h\"\r\n\r\n#include <IPXACTmodels/common/Parameter.h>\r\n\r\n#include <IPXACTmodels/Component/Component.h>\r\n#include <IPXACTmodels/Component/Model.h>\r\n\r\n#include <IPXACTmodels/utilities/Search.h>\r\n\r\n#include <KactusAPI/include/ImportColors.h>\r\n\r\n#include <KactusAPI/include/IPXactSystemVerilogParser.h>\r\n\r\n#include <common/expressions/utilities.h>\r\n\r\n#include <QList>\r\n#include <QString>\r\n#include <QRegularExpression>\r\n\r\nnamespace\r\n{\r\n    const QRegularExpression TYPE_RULE(\"(\\\\w+)\\\\s+(?:(\" + VerilogSyntax::RANGE + \")?\\\\s*(\" + \r\n        VerilogSyntax::RANGE + \"))?\\\\s*\" + VerilogSyntax::NAME_VALUE, QRegularExpression::CaseInsensitiveOption);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VerilogParameterParser::VerilogParameterParser()\r\n//-----------------------------------------------------------------------------\r\nVerilogParameterParser::VerilogParameterParser() : highlighter_(0)\r\n{\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VerilogParameterParser::~VerilogParameterParser()\r\n//-----------------------------------------------------------------------------\r\nVerilogParameterParser::~VerilogParameterParser()\r\n{\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VerilogParameterParser::setHighlighter()\r\n//-----------------------------------------------------------------------------\r\nvoid VerilogParameterParser::setHighlighter(Highlighter* highlighter)\r\n{\r\n    highlighter_ = highlighter;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VerilogParameterParser::import()\r\n//-----------------------------------------------------------------------------\r\nvoid VerilogParameterParser::import(QString const& componentDeclaration, QSharedPointer<Component> targetComponent,\r\n    QSharedPointer<ComponentInstantiation> targetComponentInstantiation)\r\n{\r\n    QStringList declarations = findDeclarations(componentDeclaration);\r\n\r\n    QList<QSharedPointer<ModuleParameter> > parsedParameters;\r\n    for (QString const& declaration : declarations)\r\n    {\r\n        parsedParameters.append(parseParameters(declaration));\r\n    }\r\n\r\n    if (targetComponentInstantiation.isNull() == false)\r\n    {\r\n        copyIdsFromOldModelParameters(parsedParameters, targetComponentInstantiation);\r\n\r\n        QList<QSharedPointer<ModuleParameter> > existingParameterList =\r\n            *targetComponentInstantiation->getModuleParameters();\r\n        for (int i = 0; i < existingParameterList.size(); ++i)\r\n        {\r\n            auto existingParameter = existingParameterList.at(i);\r\n            if (existingParameter->getAttribute(\"imported\").isEmpty())\r\n            {\r\n                targetComponentInstantiation->getModuleParameters()->removeAll(existingParameter);\r\n            }\r\n            else\r\n            {\r\n                existingParameter->setAttribute(\"imported\", \"\");\r\n            }\r\n        }\r\n\r\n        targetComponentInstantiation->getModuleParameters()->append(parsedParameters);\r\n    }\r\n\r\n    replaceNamesReferencesWithIds(parsedParameters, targetComponent, targetComponentInstantiation);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VerilogParameterParser::findDeclarations()\r\n//-----------------------------------------------------------------------------\r\nQStringList VerilogParameterParser::findDeclarations(QString const& input)\r\n{    \r\n    return findParameterDeclarations(input, findParameterSection(input));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VerilogParameterParser::findParameterSection()\r\n//-----------------------------------------------------------------------------\r\nQString VerilogParameterParser::findParameterSection(QString const &input)\r\n{\r\n    QString inspect = VerilogSyntax::cullStrayComments(input);\r\n\r\n    // Priority on parameters declared in ANSI-style at module header.\r\n    // Otherwise, search the whole input.\r\n    QRegularExpression parameterStart(QStringLiteral(\"#\\\\s*[(]\"));\r\n    QRegularExpressionMatch match = parameterStart.match(inspect);\r\n\r\n    int beginIndex = match.capturedEnd();\r\n    int endIndex = -1;\r\n    if (beginIndex != -1)\r\n    {\r\n        endIndex =\r\n            ExpressionUtilities::findMatchingEndParenthesis(inspect, beginIndex - 1, VerilogSyntax::COMMENT);\r\n    }\r\n\r\n    int length = input.length();\r\n    if (beginIndex == -1)\r\n    {\r\n        ++length;\r\n    }\r\n    else if (endIndex != -1)\r\n    {\r\n        length = endIndex - beginIndex;\r\n    }\r\n\r\n    return inspect.mid(beginIndex, length);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VerilogParameterParser::parseParameters()\r\n//-----------------------------------------------------------------------------\r\nQList<QSharedPointer<ModuleParameter> > VerilogParameterParser::parseParameters(QString const &input)\r\n{\r\n    QList<QSharedPointer<ModuleParameter> > parameters;\r\n\r\n    // Find the type and the declaration. Only one per declaration is supported.\r\n    QString type = parseType(input);\r\n    QString bitWidthLeft = parseBitWidthLeft(input);\r\n    QString bitWidthRight = parseBitWidthRight(input);\r\n    QString arrayLeft = parseArrayLeft(input);\r\n    QString arrayRight = parseArrayRight(input);\r\n    QString description = parseDescription(input);\r\n\r\n    QString inputWithoutComments = input;\r\n    inputWithoutComments.remove(QRegularExpression(VerilogSyntax::COMMENT));\r\n\r\n    QString parameterDefinition =  \"(\" + VerilogSyntax::NAMES + \")\\\\s*=((\\\\s*(\" + \r\n        VerilogSyntax::OPERATION_OR_ALPHANUMERIC + \")+\\\\s*)+)\";\r\n\r\n    QRegularExpression parameterRule(parameterDefinition + \"(\\\\s*,\\\\s*\" + parameterDefinition + \")*\", \r\n        QRegularExpression::CaseInsensitiveOption);    \r\n\r\n    QRegularExpression splitRule(parameterDefinition, QRegularExpression::CaseInsensitiveOption);\r\n\r\n    QString parametersString = parameterRule.match(inputWithoutComments).captured();\r\n\r\n    // We know for sure that each name value pair is separated by comma, and as such we get a list of them.\r\n    // Names are defined before the = operator.\r\n    foreach (QString const& parameter, \r\n        parametersString.split(QRegularExpression(\",(?=.*=)\", QRegularExpression::DotMatchesEverythingOption)))\r\n    {\r\n        // After acquiring a name value pair, we separate the name and the value from each other.\r\n        QString name = splitRule.match(parameter).captured(1).trimmed();\r\n        QString value = splitRule.match(parameter).captured(2).simplified();\r\n\r\n        // Each name value pair produces a new module parameter, but the type and the description is recycled.\r\n        QSharedPointer<ModuleParameter> moduleParameter =  QSharedPointer<ModuleParameter>(new ModuleParameter());      \r\n        moduleParameter->setName(name);\r\n        moduleParameter->setDataType(type);\r\n        moduleParameter->setType(createTypeFromDataType(type));\r\n        moduleParameter->setValue(value);\r\n        moduleParameter->setUsageType(\"nontyped\");\r\n        moduleParameter->setVectorLeft(bitWidthLeft);\r\n        moduleParameter->setVectorRight(bitWidthRight);\r\n        moduleParameter->setArrayLeft(arrayLeft);\r\n        moduleParameter->setArrayRight(arrayRight);\r\n        moduleParameter->setDescription(description);\r\n\r\n        // No type plus has vectors, means that we set type as bit for compatibility.\r\n        if (!moduleParameter->getVectors()->isEmpty() && moduleParameter->getType().isEmpty())\r\n        {\r\n            moduleParameter->setType(QStringLiteral(\"bit\"));\r\n        }\r\n\r\n        parameters.append(moduleParameter);\r\n    }\r\n\r\n    return parameters;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VerilogParameterParser::createTypeFromDataType()\r\n//-----------------------------------------------------------------------------\r\nQString VerilogParameterParser::createTypeFromDataType(QString const& dataType)\r\n{\r\n    QRegularExpression knownTypes(QStringLiteral(\"bit|byte|shortint|int|longint|shortreal|real|string\"));\r\n    return knownTypes.match(dataType).captured();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VerilogParameterParser::findDeclarations()\r\n//-----------------------------------------------------------------------------\r\nQStringList VerilogParameterParser::findParameterDeclarations(QString const& componentDeclaration,\r\n    QString const& parameterArea)\r\n{\r\n    // List of detected parameter declarations.\r\n    QStringList declarations;\r\n\r\n    // Rule used to detect parameter declarations.\r\n    QRegularExpression declarationRule(\"\\\\bparameter\\\\s+.*(?:\"\r\n        \"(;[ \\\\t]*\" + VerilogSyntax::COMMENT + \")|\"\r\n        \"(;|$)|\"\r\n        \"(,([ \\\\t]*\" + VerilogSyntax::COMMENT +\")?(?=\\\\s*\\\\bparameter\\\\b)))\",\r\n        QRegularExpression::CaseInsensitiveOption | QRegularExpression::InvertedGreedinessOption |\r\n        QRegularExpression::DotMatchesEverythingOption);\r\n\r\n    QRegularExpression commentBegin(QStringLiteral(\"//\"));\r\n    QRegularExpression lineBegin(QStringLiteral(\"^|\\\\r?\\\\n\"));\r\n\r\n    QRegularExpressionMatchIterator iter = declarationRule.globalMatch(parameterArea);\r\n    while (iter.hasNext())\r\n    {        \r\n        QRegularExpressionMatch match = iter.next();\r\n        QString declaration = match.captured();\r\n        int declarationBegin = match.capturedStart();\r\n\r\n        // Check keyword parameter is not inside a comment.\r\n        if (parameterArea.lastIndexOf(lineBegin, declarationBegin) > parameterArea.lastIndexOf(commentBegin, declarationBegin))\r\n        {\r\n            if (highlighter_)\r\n            {\r\n                highlighter_->applyHighlight(declaration, ImportColors::MODELPARAMETER, componentDeclaration);\r\n            }\r\n\r\n            declarations.append(declaration);\r\n        }\r\n    }\r\n\r\n    return declarations;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VerilogParameterParser::parseType()\r\n//-----------------------------------------------------------------------------\r\nQString VerilogParameterParser::parseType(QString const& input)\r\n{\r\n    // The type is assumed to be the first word in the declaration.\r\n    QString type = TYPE_RULE.match(input).captured(1);\r\n    if (type == QLatin1String(\"parameter\"))\r\n    {\r\n        type.clear();\r\n    }\r\n\r\n    return type;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VerilogParameterParser::parseBitWidthLeft()\r\n//-----------------------------------------------------------------------------\r\nQString VerilogParameterParser::parseBitWidthLeft(QString const& declaration)\r\n{\r\n    QString bitRange = TYPE_RULE.match(declaration).captured(3);\r\n\r\n    QRegularExpressionMatch rangeMatch = VerilogSyntax::CAPTURING_RANGE.match(bitRange);\r\n    QString left = rangeMatch.captured(1);\r\n\r\n    return left;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VerilogParameterParser::parseBitWidthRight()\r\n//-----------------------------------------------------------------------------\r\nQString VerilogParameterParser::parseBitWidthRight(QString const& declaration)\r\n{\r\n    QString bitRange = TYPE_RULE.match(declaration).captured(3);\r\n\r\n    QRegularExpressionMatch rangeMatch = VerilogSyntax::CAPTURING_RANGE.match(bitRange);\r\n    QString right = rangeMatch.captured(2);\r\n\r\n    return right;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VerilogParameterParser::parseArrayLeft()\r\n//-----------------------------------------------------------------------------\r\nQString VerilogParameterParser::parseArrayLeft(QString const& declaration)\r\n{\r\n    QString bitRange = TYPE_RULE.match(declaration).captured(2);\r\n\r\n    return VerilogSyntax::CAPTURING_RANGE.match(bitRange).captured(1);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VerilogParameterParser::parseArrayRight()\r\n//-----------------------------------------------------------------------------\r\nQString VerilogParameterParser::parseArrayRight(QString const& declaration)\r\n{\r\n    QString bitRange = TYPE_RULE.match(declaration).captured(2);\r\n\r\n    return VerilogSyntax::CAPTURING_RANGE.match(bitRange).captured(2);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VerilogParameterParser::parseDescription()\r\n//-----------------------------------------------------------------------------\r\nQString VerilogParameterParser::parseDescription(QString const& input)\r\n{\r\n    QString description;\r\n\r\n    // If exist, the description is the last comment in the declaration.\r\n    QRegularExpression commentRule(VerilogSyntax::COMMENT, QRegularExpression::CaseInsensitiveOption);\r\n    int lastCommentIndex = input.lastIndexOf(commentRule);\r\n\r\n    if (lastCommentIndex != -1)\r\n    {\r\n        QRegularExpressionMatch commmentMatch = commentRule.match(input, lastCommentIndex);\r\n\r\n        // Found the index. The description is starting index + length.\r\n        description = input.mid(commmentMatch.capturedStart(), commmentMatch.capturedLength());\r\n\r\n        // Some times the expression leaves the comment tag to the description.\r\n        if (description.startsWith(\"//\"))\r\n        {\r\n            description = description.remove(0, 2);\r\n        }\r\n\r\n        // No need for extra white spaces.\r\n        description = description.trimmed();\r\n    }\r\n\r\n    return description;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VerilogParameterParser::copyIdsFromOldModelParameters()\r\n//-----------------------------------------------------------------------------\r\nvoid VerilogParameterParser::copyIdsFromOldModelParameters(QList<QSharedPointer<ModuleParameter> > parsedParameters,\r\n    QSharedPointer<ComponentInstantiation> targetComponentInstantiation)\r\n{\r\n    for (QSharedPointer<ModuleParameter> parameter : parsedParameters)\r\n    {\r\n\t\tfor (QSharedPointer<ModuleParameter> existingParameter :\r\n            *targetComponentInstantiation->getModuleParameters())\r\n\t\t{\r\n\t\t\tif (existingParameter->name().compare(parameter->name()) == 0)\r\n\t\t\t{\r\n\t\t\t\tparameter->setValueId(existingParameter->getValueId());\r\n\t\t\t\tbreak;\r\n\t\t\t}\r\n\t\t}\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VerilogParameterParser::replaceReferenceNamesWithIds()\r\n//-----------------------------------------------------------------------------\r\nvoid VerilogParameterParser::replaceNamesReferencesWithIds(\r\n    QList<QSharedPointer<ModuleParameter> > parsedParameters,\r\n    QSharedPointer<Component> targetComponent,\r\n\tQSharedPointer<ComponentInstantiation> targetComponentInstantiation)\r\n{\r\n    for (QSharedPointer<ModuleParameter> moduleParameter : parsedParameters)\r\n    {\r\n        QSharedPointer<Parameter> targetParameter = \r\n            Search::findByName(moduleParameter->name(), *targetComponent->getParameters()); \r\n\r\n        if (targetParameter.isNull())\r\n        {\r\n            targetParameter = QSharedPointer<Parameter>(new Parameter());\r\n            targetParameter->setName(moduleParameter->name());\r\n            targetComponent->getParameters()->append(targetParameter);\r\n        }\r\n        \r\n        targetParameter->setValue(moduleParameter->getValue());\r\n        targetParameter->setType(moduleParameter->getType());\r\n        targetParameter->setArrayLeft(moduleParameter->getArrayLeft());\r\n        targetParameter->setArrayRight(moduleParameter->getArrayRight());\r\n        targetParameter->setVectorLeft(moduleParameter->getVectorLeft());\r\n        targetParameter->setVectorRight(moduleParameter->getVectorRight());\r\n        targetParameter->setDescription(moduleParameter->description());\r\n        targetParameter->increaseUsageCount();\r\n\r\n        moduleParameter->setValue(targetParameter->getValueId());\r\n    }\r\n    \r\n    for (QSharedPointer<Parameter> parameter : *targetComponent->getParameters())\r\n    {\r\n        replaceNameReferencesWithParameterIds(parameter, targetComponent);\r\n    }\r\n\r\n    if (targetComponentInstantiation.isNull() == false)\r\n    {\r\n        foreach(QSharedPointer<ModuleParameter> parameter, *targetComponentInstantiation->getModuleParameters())\r\n        {\r\n            replaceNameReferencesWithParameterIds(parameter, targetComponent);\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VerilogParameterParser::replaceParameterNamesWithIds()\r\n//-----------------------------------------------------------------------------\r\nvoid VerilogParameterParser::replaceNameReferencesWithParameterIds(QSharedPointer<Parameter> parameter,\r\n    QSharedPointer<Component> targetComponent) const\r\n{\r\n    foreach (QSharedPointer<Parameter> define, *targetComponent->getParameters())\r\n    {\r\n        QRegularExpression macroUsage(\"`?\" + define->name() + \"\\\\b\");\r\n\r\n        QString parameterValue = replaceNameWithId(parameter->getValue(), macroUsage, define);\r\n        parameter->setValue(parameterValue);\r\n\r\n        QString bitWidthLeft = replaceNameWithId(parameter->getVectorLeft(), macroUsage, define);\r\n        parameter->setVectorLeft(bitWidthLeft);\r\n\r\n        QString bitWidthRight = replaceNameWithId(parameter->getVectorRight(), macroUsage, define);\r\n        parameter->setVectorRight(bitWidthRight);\r\n\r\n        QString arrayLeft = replaceNameWithId(parameter->getArrayLeft(), macroUsage, define);\r\n        parameter->setArrayLeft(arrayLeft);\r\n\r\n        QString arrayRight = replaceNameWithId(parameter->getArrayRight(), macroUsage, define);\r\n        parameter->setArrayRight(arrayRight);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VerilogParameterParser::replaceNameWithId()\r\n//-----------------------------------------------------------------------------\r\nQString VerilogParameterParser::replaceNameWithId(QString const& expression, QRegularExpression& namePattern, \r\n    QSharedPointer<Parameter> referenced) const\r\n{\r\n    QString replaced = expression;\r\n    QRegularExpressionMatch match = namePattern.match(expression);\r\n    if (match.hasMatch())\r\n    {\r\n        replaced.replace(namePattern, referenced->getValueId());\r\n\r\n        int count = match.capturedTexts().count();\r\n        for (int i = 0; i < count; i++)\r\n        {\r\n            referenced->increaseUsageCount();\r\n        }\r\n    }\r\n\r\n    return replaced;\r\n}\r\n"
  },
  {
    "path": "Plugins/VerilogImport/VerilogParameterParser.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: VerilogParameterParser.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Janne Virtanen\r\n// Date: 25.09.2014\r\n//\r\n// Description:\r\n// Parser for Verilog parameters.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef VERILOGPARAMETERPARSER_H\r\n#define VERILOGPARAMETERPARSER_H\r\n\r\n#include <IPXACTmodels/generaldeclarations.h>\r\n\r\n#include <QSharedPointer>\r\n#include <QString>\r\n#include <IPXACTmodels/common/ModuleParameter.h>\r\n\r\n#include <KactusAPI/include/HighlightSource.h>\r\n\r\n#include \"IPXACTmodels/Component/ComponentInstantiation.h\"\r\n\r\nclass Component;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Parser for Verilog parameters.\r\n//-----------------------------------------------------------------------------\r\nclass VerilogParameterParser : public HighlightSource\r\n{\r\npublic:\r\n\r\n    //! The constructor.\r\n    VerilogParameterParser();\r\n\r\n    //! The destructor.\r\n    virtual ~VerilogParameterParser();\r\n\r\n    // Disable copying.\r\n    VerilogParameterParser(VerilogParameterParser const& rhs) = delete;\r\n    VerilogParameterParser& operator=(VerilogParameterParser const& rhs) = delete;\r\n\r\n    /*!\r\n     *  Runs the port parsing for the given input and adds the parsed ports to the given component.\r\n     *\r\n     *    @param [in] componentDeclaration            The selected component declaration from the input text.\r\n     *    @param [in] targetComponent                 The component to add all the imported parameters to.\r\n     *    @param [in] targetComponentInstantiation    The instantiation to add all the imported parameters to.\r\n     */\r\n    virtual void import(QString const& componentDeclaration, QSharedPointer<Component> targetComponent,\r\n        QSharedPointer<ComponentInstantiation> targetComponentInstantiation);\r\n\r\n    /*!\r\n     *  Sets the given highlighter to be used by the generic parser.\r\n     *\r\n     *    @param [in] highlighter   The highlighter to use.          \r\n     */\r\n    virtual void setHighlighter(Highlighter* highlighter);\r\n\r\n    /*!\r\n     *  Finds parameter declarations in the given input.\r\n     *\r\n     *    @param [in] input   The input text to parse.\r\n     *\r\n     *    @return   The resulting list of parameter declarations.\r\n     */\r\n    QStringList findDeclarations(QString const& input);\r\n\r\n    /*!\r\n     *  Parses parameters out of declaration.\r\n     *\r\n     *    @param [in] input   The input text containing a declaration of parameters.\r\n     *\r\n     *    @return The parsed model parameters.\r\n     */\r\n    QList<QSharedPointer<ModuleParameter> > parseParameters(QString const &input);\r\n\r\nprivate:\r\n\r\n    /*!\r\n     * Find the section in the input containing the parameter declarations.\r\n     *\r\n     *    @param [in] input  The input text to search.\r\n     *\r\n     *    @return The section of the text containing parameter declarations.\r\n     */\r\n     QString findParameterSection(QString const &input);\r\n\r\n    /*!\r\n     *  Finds parameter declarations from the given string.\r\n     *\r\n     *    @param [in] componentDeclaration    The component declaration containing the parameters.\r\n     *    @param [in] parameterArea           The input text containing the declarations.     \r\n     *\r\n     *    @return   The resulting list of declarations.\r\n     */\r\n     QStringList findParameterDeclarations(QString const& componentDeclaration, QString const& parameterArea);\r\n\r\n    /*!\r\n     *  Create an IP-XACT type for the parameter according to the given data type.\r\n     *\r\n     *    @param [in] dataType    The selected data type.\r\n     *\r\n     *    @return The type matching the data type, or none if data type does not match any IP-XACT type.\r\n     */\r\n    QString createTypeFromDataType(QString const& dataType);\r\n\r\n    /*!\r\n     *  Tries to parse the type of the declared parameters.\r\n     *\r\n     *    @param [in] input   The input text containing a declaration of parameters.\r\n     *\r\n     *    @return   The parsed type.\r\n     */\r\n     QString parseType(QString const& input);\r\n     \r\n     /*!\r\n      *  Parses the left value of bit width of the parameter.\r\n      *\r\n      *    @param [in] declaration    The parameter declaration to parse.\r\n      *\r\n      *    @return The left value of the parameters bit width vector.\r\n      */\r\n     QString parseBitWidthLeft(QString const& declaration);\r\n\r\n     /*!\r\n      *  Parses the right value of bit width of the parameter.\r\n      *\r\n      *    @param [in] declaration    The parameter declaration to parse.\r\n      *\r\n      *    @return The right value of the parameters bit width vector.\r\n      */\r\n     QString parseBitWidthRight(QString const& declaration);\r\n\r\n     /*!\r\n      *  Parses the left bound for the parameter array.\r\n      *\r\n      *    @param [in] declaration   The parameter declaration to parse.\r\n      *\r\n      *    @return The left array bound.\r\n      */\r\n     QString parseArrayLeft(QString const& declaration);\r\n     \r\n     /*!\r\n      *  Parses the right bound for the parameter array.\r\n      *\r\n      *    @param [in] declaration   The parameter declaration to parse.\r\n      *\r\n      *    @return The right array bound.\r\n      */\r\n     QString parseArrayRight(QString const& declaration);\r\n\r\n    /*!\r\n     *  Tries to parse the descriptions of the declared parameters.\r\n     *\r\n     *    @param [in] input   The input text containing a declaration of parameters.\r\n     *\r\n     *    @return   The parsed description.\r\n     */\r\n     QString parseDescription(QString const& input);\r\n\r\n     /*!\r\n      *  Copies the model parameter ids from the component to the parsed model parameters.\r\n      *\r\n      *    @param [in] parsedParameters   The parsed model parameters.\r\n      *    @param [in] targetComponent    The component to import to.\r\n      */\r\n     void copyIdsFromOldModelParameters(QList<QSharedPointer<ModuleParameter> > parsedParameters,\r\n         QSharedPointer<ComponentInstantiation> targetComponentInstantiation);\r\n\r\n     /*!\r\n      *  Replaces the referenced model parameter names with their ids in model parameter values.\r\n      *\r\n      *    @param [in] targetComponent   The component whose model parameter values to replace.\r\n      */\r\n     void replaceNamesReferencesWithIds(QList<QSharedPointer<ModuleParameter> > parsedParameters,\r\n         QSharedPointer<Component> targetComponent,\r\n         QSharedPointer<ComponentInstantiation> targetComponentInstantiation);\r\n\r\n     /*!\r\n      *  Replaces macro uses in parameter with corresponding id references.\r\n      *\r\n      *    @param [in] parameter          The parameter whose macro uses to replace.\r\n      *    @param [in] targetComponent    The containing component.\r\n      */\r\n     void replaceNameReferencesWithParameterIds(QSharedPointer<Parameter> parameter, \r\n         QSharedPointer<Component> targetComponent) const;\r\n\r\n     /*!\r\n      *  Replaces a name reference in an expression with id.\r\n      *  Increases reference count of the referenced parameter accordingly.\r\n      *\r\n      *    @param [in] expression   The expression to replace the references in.\r\n      *    @param [in] namePattern  The pattern for name reference search.\r\n      *    @param [in] referenced   The parameter that matches the name pattern.\r\n      *\r\n      *    @return The expression where names have been replaced with the id of the referenced parameter.\r\n      */\r\n     QString replaceNameWithId(QString const& expression, QRegularExpression& namePattern, \r\n         QSharedPointer<Parameter> referenced) const;\r\n\r\n     //-----------------------------------------------------------------------------\r\n     // Data.\r\n     //-----------------------------------------------------------------------------\r\n\r\n    //! The highlighter to use.\r\n    Highlighter* highlighter_;\r\n\r\n};\r\n\r\n#endif // VERILOGPARAMETERPARSER_H\r\n"
  },
  {
    "path": "Plugins/VerilogImport/VerilogPortParser.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: VerilogPortParser.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Esko Pekkarinen\r\n// Date: 24.09.2014\r\n//\r\n// Description:\r\n// Parser for Verilog ports.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"VerilogPortParser.h\"\r\n\r\n#include \"VerilogSyntax.h\"\r\n\r\n#include <common/expressions/utilities.h>\r\n\r\n#include <KactusAPI/include//ImportColors.h>\r\n\r\n#include <KactusAPI/include/ExpressionParser.h>\r\n#include <KactusAPI/include/NullParser.h>\r\n\r\n#include <IPXACTmodels/Component/Component.h>\r\n#include <IPXACTmodels/Component/Port.h>\r\n\r\n#include <QString>\r\n#include <QRegularExpression>\r\n\r\nnamespace\r\n{\r\n    //! Verilog port directions.\r\n    const QString PORT_DIRECTION(\"input|output|inout\");\r\n\r\n    //! Verilog port types.\r\n    const QString PORT_TYPE(\"\\\\w+\");\r\n\r\n    //! Subset of Verilog preprocessor commands.\r\n    const QString PREPROCESSOR_COMMAND(\"`(?:ifdef|ifndef|endif)[^\\\\r\\\\n]*\");\r\n\r\n    //! Port declaration ends if preprocessor command is found. Preceding comment will be included.\r\n    const QString END_BEFORE_PREPROCESSOR(\"(?:[ \\\\t]*\" + VerilogSyntax::COMMENT + \")?\"\r\n        \"(?=\\\\s*\" + PREPROCESSOR_COMMAND + \")\");\r\n\r\n    //! Port declaration ends if next port declaration is found.\r\n    const QString END_BEFORE_NEXT_ITEM(\"\\\\s*[,;][ \\\\t]*(?:\"+ VerilogSyntax::COMMENT + \")?\");\r\n\r\n    //! Port declaration ends if no more ports follow the declaration.\r\n    const QString LAST_PORT(\"(?:[ \\\\t]*\" + VerilogSyntax::COMMENT + \")?(?=\\\\s*$)\");\r\n\r\n    //! Port declaration must end with one of the conditions above.\r\n    const QString PORT_DECLARATION_END(\"(?:\" + END_BEFORE_PREPROCESSOR + \")|\"\r\n        \"(?:\" + END_BEFORE_NEXT_ITEM + \")|\"\r\n        \"(?:\" + LAST_PORT +\")\");\r\n\r\n    //! Verilog ports in both ANSI-C and Verilog-1995 style.\r\n    const QRegularExpression PORT_EXP(\"(\" + PORT_DIRECTION + \")\\\\s+(?:wire\\\\s+)?(?:(\" + PORT_TYPE + \")\\\\s+)?\"\r\n        \"(?:signed)?\\\\s*(?:(\" + VerilogSyntax::RANGE +\")?\\\\s*(\" + VerilogSyntax::RANGE + \"))?\\\\s*\"\r\n        \"(\" + VerilogSyntax::NAMES + \")(?:\" + PORT_DECLARATION_END + \")\");\r\n\r\n    //! Verilog ports in Verilog-1995 style.\r\n    const QRegularExpression PORT_1995(\"(\" + PORT_DIRECTION + \")\\\\s+\"\r\n        \"(?:(\" + PORT_TYPE + \")\\\\s+)?(\" + VerilogSyntax::RANGE + \")?\\\\s*\"\r\n        \"(\" + VerilogSyntax::NAMES + \")\\\\s*[;](?:[ \\\\t]*\"+ VerilogSyntax::COMMENT + \")?\");\r\n\r\n\t//! Declaration for verilog parameters.\r\n\tconst QString MODULE_PARAMETER_DECLARATION(\"\\\\s*#\\\\((\\\\s*parameter.*)+\\\\s*\\\\)\");\r\n\r\n    //! Port declaration for Verilog-1995 style.\r\n    const QString PORT_DECLARATION_1995(\"\\\\((\\\\s*\\\\w*,)*\\\\s*\\\\w+\\\\s*\\\\);\");\r\n\r\n    //! Combination declaration for verilog module and parameters.\r\n\tconst QString MODULE_AND_PARAMETERS_DECLARATION(VerilogSyntax::MODULE_BEGIN.pattern() + \"(\" + MODULE_PARAMETER_DECLARATION + \")?\\\\s*\");\r\n\r\n    //! Full declaration for verilog-1995\r\n    const QString DECLARATION_1995(MODULE_AND_PARAMETERS_DECLARATION + PORT_DECLARATION_1995);\r\n\r\n    //! Modified module declaration for use in checking ports\r\n    const QString NEW_MODULE_DECLARATION(\"(?:^|\\\\r?\\\\n)[ \\t]*(?:macro)?module\\\\s*\\\\w*\");\r\n\r\n    //! Everything after module and parameter declaration.\r\n    const QString MODULE_DECLARATION_REST(\"\\\\s*\\\\([^;]*\");\r\n\r\n    //! Full declaration of a verilog module.\r\n    const QString FULL_MODULE_DECLARATION(NEW_MODULE_DECLARATION + \"(\" + MODULE_PARAMETER_DECLARATION + \")?\" + MODULE_DECLARATION_REST);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VerilogPortParser::VerilogPortParser()\r\n//-----------------------------------------------------------------------------\r\nVerilogPortParser::VerilogPortParser(): highlighter_(0), parser_(new NullParser)\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VerilogPortParser::runParser()\r\n//-----------------------------------------------------------------------------\r\nvoid VerilogPortParser::import(QString const& input, QSharedPointer<Component> targetComponent)\r\n{\r\n    //! The existing ports are changed to phantom in order to keep the component error-free.\r\n    //! These ports can then be deleted later.\r\n    foreach (QSharedPointer<Port> existingPort, *targetComponent->getPorts())\r\n    {\r\n        existingPort->setDirection(DirectionTypes::DIRECTION_PHANTOM);\r\n    }\r\n\r\n    foreach (QString portDeclaration, findPortDeclarations(input))\r\n    {\r\n\t\tcreatePortFromDeclaration(portDeclaration, targetComponent);\r\n        highlight(portDeclaration, input);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VerilogPortParser::setHighlighter()\r\n//-----------------------------------------------------------------------------\r\nvoid VerilogPortParser::setHighlighter(Highlighter* highlighter)\r\n{\r\n    highlighter_ = highlighter;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VerilogPortParser::setExpressionParser()\r\n//-----------------------------------------------------------------------------\r\nvoid VerilogPortParser::setExpressionParser(QSharedPointer<ExpressionParser> parser)\r\n{\r\n    parser_ = parser;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VerilogPortParser::findPortDeclarations()\r\n//-----------------------------------------------------------------------------\r\nQStringList VerilogPortParser::findPortDeclarations(QString const& input) const\r\n{\r\n    QString portSection = findPortsSection(removeIgnoredLines(input));\r\n\r\n    return portDeclarationsIn(portSection);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VerilogPortParser::findPortsSection()\r\n//-----------------------------------------------------------------------------\r\nQString VerilogPortParser::findPortsSection(QString const& input) const\r\n{\r\n    bool noValidModule = input.indexOf(VerilogSyntax::MODULE_BEGIN) == -1 || \r\n        input.indexOf(VerilogSyntax::MODULE_END) == -1;\r\n\r\n    if (noValidModule)\r\n    {\r\n        return QString();\r\n    }\r\n\r\n    QString portSection;\r\n    if (hasVerilog1995Ports(input))\r\n    {\r\n        portSection = findVerilog1995PortsSectionInModule(input);\r\n    }\r\n    else\r\n    {\r\n        portSection = findVerilog2001PortsSection(input);\r\n    }\r\n\r\n    return portSection;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VerilogPortParser::hasVerilog1995Ports()\r\n//-----------------------------------------------------------------------------\r\nbool VerilogPortParser::hasVerilog1995Ports(QString const& input) const\r\n{\r\n\tQString simplifiedAndCommentsRemoved = removeAllComments(input).simplified();\r\n\r\n    QRegularExpression declaractionExpression(DECLARATION_1995);\r\n    QRegularExpressionMatch match = declaractionExpression.match(simplifiedAndCommentsRemoved);\r\n\r\n    return match.hasMatch();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VerilogPortParser::removeAllComments()\r\n//-----------------------------------------------------------------------------\r\nQString VerilogPortParser::removeAllComments(QString const& input) const\r\n{\r\n    auto commentsRemoved = input;\r\n    return commentsRemoved.remove(VerilogSyntax::MULTILINE_COMMENT).remove(QRegularExpression(\"\\\\/\\\\/.*\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VerilogPortParser::findStartOfPortList()\r\n//-----------------------------------------------------------------------------\r\nint VerilogPortParser::findStartOfPortList(QString const& input) const\r\n{\r\n    auto portStartIndex = -1;\r\n\r\n    QRegularExpression moduleExpression(FULL_MODULE_DECLARATION);\r\n\tif (auto moduleMatch = moduleExpression.match(input); moduleMatch.hasMatch())\r\n    {\r\n        auto moduleDeclaration = moduleMatch.captured();\r\n\r\n        QRegularExpression moduleAndParameterExpression(NEW_MODULE_DECLARATION + \"(\" + MODULE_PARAMETER_DECLARATION + \")?\");\r\n\t\tauto moduleWithoutPortsMatch = moduleAndParameterExpression.match(moduleDeclaration);\r\n        if (moduleWithoutPortsMatch.hasMatch())\r\n        {\r\n\t\t\tauto moduleBeginIndex = moduleMatch.capturedStart();\r\n            portStartIndex = moduleBeginIndex + moduleWithoutPortsMatch.capturedEnd();\r\n        }\r\n    }\r\n\r\n    return portStartIndex;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VerilogPortParser::findVerilog1995PortsSectionInModule()\r\n//-----------------------------------------------------------------------------\r\nQString VerilogPortParser::findVerilog1995PortsSectionInModule(QString const& input) const\r\n{    \r\n    QString section = input;\r\n\r\n\tQRegularExpression fullModuleExpression(FULL_MODULE_DECLARATION);\r\n    QString portDeclaration = \"\";\r\n    if (auto moduleMatch = fullModuleExpression.match(input); moduleMatch.hasMatch())\r\n    {\r\n        //! This can be used to find the port definitions from the declaration.\r\n        //! Just remove the module and parameter declarations. What is left is the port declarations.\r\n        portDeclaration = moduleMatch.captured();\r\n\r\n        QRegularExpression moduleExpression(NEW_MODULE_DECLARATION);\r\n        QRegularExpression parameterExpression(MODULE_PARAMETER_DECLARATION);\r\n\r\n        portDeclaration.remove(moduleExpression);\r\n        portDeclaration.remove(parameterExpression);\r\n\r\n        portDeclaration = removeAllComments(portDeclaration).simplified().remove(\" \");\r\n        portDeclaration = portDeclaration.mid(1, portDeclaration.size() - 2);\r\n    }\r\n\r\n\tauto startOfDeclaration = findStartOfPortList(section);\r\n\tauto endOfModule = section.indexOf(VerilogSyntax::MODULE_END, startOfDeclaration);\r\n\r\n    section = input.mid(startOfDeclaration, endOfModule - startOfDeclaration);\r\n\r\n\tQString portSection = \"\";\r\n\r\n\t\tfor (auto const& currentPort : portDeclaration.split(','))\r\n\t\t{\r\n\t\t\tQRegularExpression currentPortExpression(\"(\" + PORT_DIRECTION + \")\\\\s*.*\\\\s*\" + currentPort + \"\\\\s*;.*\");\r\n\t\t\tauto currentPortMatch = currentPortExpression.match(section);\r\n            if (currentPortMatch.hasMatch())\r\n            {\r\n                auto capturedPortMatch = currentPortMatch.captured();\r\n                if (PORT_1995.match(capturedPortMatch).hasMatch())\r\n                {\r\n\t\t\t\t\tportSection.append(capturedPortMatch + \"\\n\");\r\n                }\r\n            }\r\n\t\t}\r\n\r\n    return portSection;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VerilogPortParser::findVerilog2001PortsSection()\r\n//-----------------------------------------------------------------------------\r\nQString VerilogPortParser::findVerilog2001PortsSection(QString const& input) const\r\n{\r\n    QRegularExpression portsEnd(\"[)];\");\r\n\r\n    int portSectionBegin = findStartOfPortList(input);\r\n    int portSectionEnd = input.indexOf(portsEnd, portSectionBegin);\r\n\r\n    bool noPortSection = (portSectionBegin == -1 || portSectionEnd == -1);\r\n\r\n    if (noPortSection)\r\n    {\r\n        return QString();\r\n    }\r\n\r\n    int portSectionLength = portSectionEnd - portSectionBegin;\r\n\r\n    return input.mid(portSectionBegin, portSectionLength);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VerilogPortParser::removeIgnoredLines()\r\n//-----------------------------------------------------------------------------\r\nQString VerilogPortParser::removeIgnoredLines(QString const& portSection) const\r\n{\r\n    QString portSectionWithoutComments = portSection;\r\n    QRegularExpression multilineComment(VerilogSyntax::MULTILINE_COMMENT);\r\n\r\n    return  portSectionWithoutComments.remove(VerilogSyntax::COMMENTLINE).remove(multilineComment);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VerilogPortParser::portDeclarationsIn()\r\n//-----------------------------------------------------------------------------\r\nQStringList VerilogPortParser::portDeclarationsIn(QString const& portSection) const\r\n{\r\n    QStringList portDeclarations;\r\n\r\n    QRegularExpressionMatchIterator matches = PORT_EXP.globalMatch(portSection);\r\n    while (matches.hasNext())\r\n    {\r\n        portDeclarations.append(matches.next().captured());\r\n    }\r\n\r\n    return portDeclarations;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VerilogPortParser::createPortFromDeclaration()\r\n//-----------------------------------------------------------------------------\r\nvoid VerilogPortParser::createPortFromDeclaration(QString const& portDeclaration,\r\n    QSharedPointer<Component> targetComponent) const\r\n{\r\n    DirectionTypes::Direction direction = parseDirection(portDeclaration);\r\n\r\n    QString type = PORT_EXP.match(portDeclaration).captured(2);\r\n    if (type.compare(QLatin1String(\"signed\")) == 0)\r\n    {\r\n        type.clear();\r\n    }\r\n\r\n    QString typeDefinition;\r\n\r\n    QPair<QString, QString> vectorBounds = parseVectorBounds(portDeclaration, targetComponent);\r\n    QPair<QString, QString> arrayBounds = parseArrayBounds(portDeclaration, targetComponent);\r\n\r\n    QStringList portNames = parsePortNames(portDeclaration);\r\n\r\n    QString description = parseDescription(portDeclaration);\r\n\r\n    for (QString const& name : portNames)\r\n    {\r\n        QSharedPointer<Port> port;\r\n        if (targetComponent->hasPort(name))\r\n        {\r\n            port = targetComponent->getPort(name);\r\n            typeDefinition = port->getTypeDefinition(type);\r\n        }\r\n        else\r\n        {\r\n            port = QSharedPointer<Port>(new Port());       \r\n            targetComponent->getPorts()->append(port);\r\n        }\r\n\r\n        port->setName(name);\r\n        port->setDirection(direction);\r\n        port->setLeftBound(vectorBounds.first);\r\n        port->setRightBound(vectorBounds.second);\r\n        port->setArrayLeft(arrayBounds.first);\r\n        port->setArrayRight(arrayBounds.second);\r\n        port->setDescription(description);\r\n\r\n\t\tport->setTypeName(type);\r\n\t\tif (type.isEmpty() == false && typeDefinition.isEmpty() == false)\r\n\t\t{\r\n\t\t\tport->setTypeDefinition(type, typeDefinition);\r\n\t\t}\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VerilogPortParser::highlight()\r\n//-----------------------------------------------------------------------------\r\nvoid VerilogPortParser::highlight(QString const& portDeclaration, QString const& componentDeclaration)\r\n{\r\n    if (highlighter_)\r\n    {\r\n        highlighter_->applyHighlight(portDeclaration, ImportColors::PORT, componentDeclaration);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VerilogPortParser::parseDirection()\r\n//-----------------------------------------------------------------------------\r\nDirectionTypes::Direction VerilogPortParser::parseDirection(QString const& portDeclaration) const\r\n{\r\n    QString directionString = PORT_EXP.match(portDeclaration).captured(1);\r\n\r\n    DirectionTypes::Direction portDirection = DirectionTypes::DIRECTION_INVALID;\r\n    if (directionString == QLatin1String(\"input\"))\r\n    {\r\n        portDirection = DirectionTypes::IN;\r\n    }\r\n    else if (directionString == QLatin1String(\"output\"))\r\n    {\r\n        portDirection = DirectionTypes::OUT;\r\n    }\r\n    else if(directionString == QLatin1String(\"inout\"))\r\n    {\r\n        portDirection = DirectionTypes::INOUT;\r\n    }\r\n\r\n    return portDirection;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VerilogPortParser::parseArrayBounds()\r\n//-----------------------------------------------------------------------------\r\nQPair<QString, QString> VerilogPortParser::parseArrayBounds(QString const& portDeclaration,\r\n\tQSharedPointer<Component> targetComponent ) const\r\n{\r\n    QString vectorBounds = PORT_EXP.match(portDeclaration).captured(3);\r\n\r\n    return parseLeftAndRight(vectorBounds, targetComponent);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VerilogPortParser::parseLeftAndRight()\r\n//-----------------------------------------------------------------------------\r\nQPair<QString, QString> VerilogPortParser::parseLeftAndRight(QString const& bounds,\r\n\tQSharedPointer<Component> targetComponent) const\r\n{\r\n    auto leftBound = QString();\r\n    auto rightBound = QString();\r\n\r\n    if (!bounds.isEmpty())\r\n    {\r\n        // If there is a ternary operator, special handling is required.\r\n        QRegularExpressionMatch matchTernary = VerilogSyntax::TERNARY_LEFT.match(bounds);\r\n        if (matchTernary.hasMatch())\r\n        {\r\n            QString tempBounds(bounds);\r\n            QString placeholder(\"\");\r\n            for (int i = 0; i <= matchTernary.lastCapturedIndex(); ++i)\r\n            {\r\n                QString captured = matchTernary.captured(i);\r\n                // Removed captured text.\r\n                placeholder.resize(captured.length(), ' ');\r\n                tempBounds.replace(captured, placeholder);\r\n            }\r\n            auto boundsPos = tempBounds.lastIndexOf(QLatin1String(\":\"));\r\n            leftBound = bounds.left(boundsPos).remove('[');\r\n            rightBound = bounds.right(bounds.length() - boundsPos - 1).remove(']');\r\n        }\r\n        else\r\n        {\r\n            leftBound = VerilogSyntax::CAPTURING_RANGE.match(bounds).captured(1);\r\n            rightBound = VerilogSyntax::CAPTURING_RANGE.match(bounds).captured(2);\r\n        }\r\n\r\n        bool leftValid = false;\r\n        parser_->parseExpression(leftBound, &leftValid);\r\n        if (leftValid == false)\r\n        {\r\n            leftBound = replaceNameReferencesWithIds(leftBound, targetComponent);\r\n        }\r\n\r\n        bool rightValid = false;\r\n        parser_->parseExpression(rightBound, &rightValid);\r\n        if (rightValid == false)\r\n        {\r\n            rightBound = replaceNameReferencesWithIds(rightBound, targetComponent);\r\n        }\r\n    }\r\n\r\n    return qMakePair(leftBound, rightBound);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VerilogPortParser::parseVectorBounds()\r\n//-----------------------------------------------------------------------------\r\nQPair<QString, QString> VerilogPortParser::parseVectorBounds(QString const& portDeclaration,\r\n\tQSharedPointer<Component> targetComponent) const\r\n{\r\n    QString vectorBounds = PORT_EXP.match(portDeclaration).captured(4);\r\n\r\n    return parseLeftAndRight(vectorBounds, targetComponent);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VerilogPortParser::replaceNameReferencesWithIds()\r\n//-----------------------------------------------------------------------------\r\nQString VerilogPortParser::replaceNameReferencesWithIds(QString const& expression, \r\n    QSharedPointer<Component> targetComponent) const\r\n{\r\n    QString result = expression;\r\n\r\n        foreach (QSharedPointer<Parameter> define, *targetComponent->getParameters())\r\n        {\r\n            QRegularExpression macroUsage(\"`?\" + define->name() + \"\\\\b\");\r\n            if (macroUsage.match(result).hasMatch())\r\n            {\r\n                result.replace(macroUsage, define->getValueId());\r\n\r\n                for(int i = 0; i < expression.count(macroUsage); i++)\r\n                {\r\n                    define->increaseUsageCount();\r\n                }\r\n            }\r\n        }\r\n\r\n    return result;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VerilogPortParser::parsePortNames()\r\n//-----------------------------------------------------------------------------\r\nQStringList VerilogPortParser::parsePortNames(QString const& portDeclaration) const\r\n{\r\n    QString names = PORT_EXP.match(portDeclaration).captured(5);\r\n    \r\n    return names.split(QRegularExpression(QStringLiteral(\"\\\\s*[,]\\\\s*\")), Qt::SkipEmptyParts);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VerilogPortParser::parseDescription()\r\n//-----------------------------------------------------------------------------\r\nQString VerilogPortParser::parseDescription(QString const& portDeclaration) const\r\n{\r\n    QRegularExpression commentExp(VerilogSyntax::COMMENT);\r\n    return commentExp.match(portDeclaration).captured(1).trimmed();\r\n}\r\n"
  },
  {
    "path": "Plugins/VerilogImport/VerilogPortParser.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: VerilogPortParser.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Esko Pekkarinen\r\n// Date: 23.09.2014\r\n//\r\n// Description:\r\n// Parser for Verilog ports.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef VERILOGPORTPARSER_H\r\n#define VERILOGPORTPARSER_H\r\n\r\n#include <IPXACTmodels/common/DirectionTypes.h>\r\n\r\n#include <KactusAPI/include/HighlightSource.h>\r\n\r\n#include <QSharedPointer>\r\n#include <QString>\r\n#include \"IPXACTmodels/Component/ComponentInstantiation.h\"\r\n\r\nclass Component;\r\nclass ExpressionParser;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Parser for Verilog ports.\r\n//-----------------------------------------------------------------------------\r\nclass VerilogPortParser: public HighlightSource\r\n{\r\npublic:\r\n\r\n    //! The constructor.\r\n    VerilogPortParser();\r\n\r\n    //! The destructor.\r\n    virtual ~VerilogPortParser() = default;\r\n\r\n    /*!\r\n     *  Runs the port parsing for the given input and adds the parsed ports to the given component.\r\n     *\r\n     *    @param [in] input               The input text to parse.\r\n     *    @param [in] targetComponent     The component to add all the imported ports to.\r\n     */\r\n\tvirtual void import(QString const& input, QSharedPointer<Component> targetComponent);\r\n\r\n    /*!\r\n     *  Sets the given highlighter to be used by the port parser.\r\n     *\r\n     *    @param [in] highlighter   The highlighter to use.          \r\n     */\r\n    virtual void setHighlighter(Highlighter* highlighter) override final;\r\n    \r\n    /*!\r\n     *  Sets the parser to use for expressions.\r\n     *\r\n     *    @param [in] parser   The parser to use.\r\n     */\r\n    void setExpressionParser(QSharedPointer<ExpressionParser> parser);\r\n\r\nprivate:\r\n\r\n    // Disable copying.\r\n    VerilogPortParser(VerilogPortParser const& rhs);\r\n    VerilogPortParser& operator=(VerilogPortParser const& rhs);\r\n\r\n    /*!\r\n     *  Finds all port declarations from input.\r\n     *\r\n     *    @param [in] input   The input to search for port declarations.\r\n     *\r\n     *    @return Found port declarations.\r\n     */\r\n    QStringList findPortDeclarations(QString const& input) const;\r\n    \r\n    /*!\r\n     *  Finds the section defining the ports of an module.\r\n     *\r\n     *    @param [in] input   The input to search for port section.\r\n     *\r\n     *    @return The sections containing all ports in module.\r\n     */\r\n    QString findPortsSection(QString const& input) const;\r\n\r\n    /*!\r\n     *  Checks if the given input has ports declared in Verilog-1995 style.\r\n     *\r\n     *    @param [in] input   The input to check.\r\n     *\r\n     *    @return True, if Verilog-1995 style ports are found, otherwise false.\r\n     */\r\n    bool hasVerilog1995Ports(QString const& input) const;\r\n    \r\n    /*!\r\n     *  Finds the end of module declaration in given input.\r\n     *\r\n     *    @param [in] input   The input to search for module declaration end.\r\n     *\r\n     *    @return The character index in the input for the end of module declaration.\r\n     */\r\n    int findStartOfPortList(QString const& input) const;\r\n\r\n    /*!\r\n     *  Finds the section in the input containing all Verilog-1995 style ports.\r\n     *\r\n     *    @param [in] input   The input to search for.\r\n     *\r\n     *    @return The section of the input containing all Verilog-1995 style ports.\r\n     */\r\n    QString findVerilog1995PortsSectionInModule(QString const& input) const;\r\n\r\n    /*!\r\n     *  Finds the section in the input containing all Verilog-2001 style ports.\r\n     *\r\n     *    @param [in] input   The input to search for.\r\n     *\r\n     *    @return The section of the input containing all Verilog-2001 style ports.\r\n     */\r\n    QString findVerilog2001PortsSection(QString const& input) const;\r\n\r\n    /*!\r\n     *  Removes all ignored lines e.g. comments from a given input.\r\n     *\r\n     *    @param [in] input   The input to remove lines from.\r\n     *\r\n     *    @return The input without ignored lines.\r\n     */\r\n    QString removeIgnoredLines(QString const& portSection) const ;\r\n\r\n    /*!\r\n     *  Removes all the comments from the given input.\r\n     *\r\n     *    @param [in] input     The selected input.\r\n     *\r\n     *    @return Input without comments.\r\n     */\r\n    QString removeAllComments(QString const& input) const;\r\n\r\n    /*!\r\n     *  Finds all port declarations from a ports section without comment lines.\r\n     *\r\n     *    @param [in] portSectionWithoutCommentLines   The section of the Verilog containing the ports in module\r\n     *                                                   without comment lines.\r\n     *\r\n     *    @return The Verilog port declarations.\r\n     */\r\n    QStringList portDeclarationsIn(QString const& portSection) const;\r\n\r\n    /*!\r\n     *  Creates a port from a given Verilog declaration and adds it to the target component.\r\n     *\r\n     *    @param [in] declaration         The declaration from which to create a port.\r\n     *    @param [in] targetComponent     The component to which add the port.\r\n     */\r\n\tvoid createPortFromDeclaration(QString const& portDeclaration, QSharedPointer<Component> targetComponent) const;\r\n\r\n    /*!\r\n     *  Highlights the given port declaration.\r\n     *\r\n     *    @param [in] portDeclaration         The port declaration to highlight.\r\n     *    @param [in] componentDeclaration    Component declaration containing the selected port.\r\n     */\r\n    void highlight(QString const& portDeclaration, QString const& componentDeclaration);\r\n\r\n    /*!\r\n     *  Parses the port direction from a Verilog port declaration.\r\n     *\r\n     *    @param [in] declaration   The Verilog port declaration to parse.\r\n     *\r\n     *    @return The port direction in the declaration.\r\n     */\r\n    DirectionTypes::Direction parseDirection(QString const& portDeclaration) const;\r\n    \r\n    /*!\r\n     *  Parses the port array bounds from a Verilog port declaration.\r\n     *\r\n     *    @param [in] portDeclaration     The Verilog port declaration to parse.\r\n     *    @param [in] ownerComponent      The owner component of the port.\r\n     *\r\n     *    @return The port left and right array bound value in the declaration.\r\n     */\r\n    QPair<QString, QString> parseArrayBounds(QString const& portDeclaration, \r\n        QSharedPointer<Component> targetComponent) const;\r\n\r\n    /*!\r\n     *  Parses the left and right bounds of a bounds that is of format [left:right].\r\n     *  Any name references will be replaced with id references.\r\n     *\r\n     *    @param [in] bounds              The expression to parse.\r\n     *    @param [in] targetComponent     The owner component of the port.\r\n     *\r\n     *    @return The left and right bound value in the bounds.\r\n     */\r\n    QPair<QString, QString> parseLeftAndRight(QString const& bounds,\r\n        QSharedPointer<Component> targetComponent) const;\r\n\r\n    /*!\r\n     *  Parses the port vector bounds from a Verilog port declaration.\r\n     *\r\n     *    @param [in] portDeclaration     The Verilog port declaration to parse.\r\n     *    @param [in] ownerComponent      The owner component of the port.\r\n     *\r\n     *    @return The port left and right vector bound value in the declaration.\r\n     */\r\n    QPair<QString, QString> parseVectorBounds(QString const& portDeclaration,\r\n        QSharedPointer<Component> targetComponent) const;\r\n\r\n    /*!\r\n     *  Replaces any parameter names with their ids in an expression.\r\n     *\r\n     *    @param [in] expression          The expression to replace the names in.\r\n     *    @param [in] targetComponent     The containing component of the parameters.\r\n     *\r\n     *    @return The expression where the names have been replaced with corresponding ids.\r\n     */\r\n    QString replaceNameReferencesWithIds(QString const& expression, \r\n        QSharedPointer<Component> targetComponent) const;\r\n\r\n    /*!\r\n     *  Parses the port names from a Verilog port declaration.\r\n     *\r\n     *    @param [in] declaration   The Verilog port declaration to parse.\r\n     *\r\n     *    @return The port names in the declaration.\r\n     */\r\n    QStringList parsePortNames(QString const& portDeclaration) const;\r\n\r\n    /*!\r\n     *  Parses the port description from a comment tailing a Verilog port declaration.\r\n     *\r\n     *    @param [in] declaration   The Verilog port declaration to parse.\r\n     *\r\n     *    @return The port description.\r\n     */\r\n    QString parseDescription(QString const& portDeclaration) const;\r\n    \r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! The highlighter to use.\r\n    Highlighter* highlighter_;\r\n\r\n    //! The expression parser to use.\r\n    QSharedPointer<ExpressionParser> parser_;\r\n};\r\n\r\n#endif // VERILOGPORTPARSER_H\r\n"
  },
  {
    "path": "Plugins/VerilogImport/VerilogSyntax.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: VerilogSyntax.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Janne Virtanen\r\n// Date: 20.10.2016\r\n//\r\n// Description:\r\n// Common elements of the Verilog language.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"VerilogSyntax.h\"\r\n\r\n#include <QTextStream>\r\n#include <QFile>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VerilogSyntax::legalizeName()\r\n//-----------------------------------------------------------------------------\r\nQString VerilogSyntax::legalizeName(QString const& name)\r\n{\r\n    QRegularExpression illegalCharacters(\"[:.-]+\");\r\n    QString legitName = name;\r\n    legitName = legitName.replace(illegalCharacters, \"_\");\r\n\r\n    return legitName;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VerilogSyntax::cullStrayComments()\r\n//-----------------------------------------------------------------------------\r\nQString VerilogSyntax::cullStrayComments(QString const& input)\r\n{\r\n    // Make a copy, remove all multiline comments as well as lines that are purely comments.\r\n    QString inspectWithoutComments = input;\r\n    inspectWithoutComments.remove(VerilogSyntax::MULTILINE_COMMENT);\r\n    inspectWithoutComments.remove(VerilogSyntax::COMMENTLINE);\r\n\r\n    return inspectWithoutComments;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VerilogSyntax::findModuleHeader()\r\n//-----------------------------------------------------------------------------\r\nQPair<int,int> VerilogSyntax::findModuleDeclaration(QString const& input)\r\n{\r\n    // The return value.\r\n    QPair<int,int> retval;\r\n\r\n    // Find the beginning of the module header.\r\n    int moduleDeclarationBeginIndex = input.indexOf(VerilogSyntax::MODULE_KEY_WORD);\r\n\r\n    // Its shall be the first return value.\r\n    retval.first = moduleDeclarationBeginIndex;\r\n\r\n    // Make a copy of the input.\r\n    QString inspect = input;\r\n\r\n    // The ending position of the module header.\r\n    int moduleDeclarationEndIndex = -1;\r\n    \r\n    // We decide it is easier to read in stream format.\r\n    QTextStream sourceStream(&inspect);\r\n    // The last stream position.\r\n    int streamPos = -1;\r\n\r\n    // The alternative syntaxes for comment starts.\r\n    QRegularExpression comment(\"(////)|(//*)\");\r\n\r\n    while (!sourceStream.atEnd())\r\n    {\r\n        // Remember the position before this line.\r\n        streamPos = sourceStream.pos();\r\n\r\n        // Read the next line.\r\n        const QString currentLine = sourceStream.readLine();\r\n\r\n        // Find position of any comment start in the line, as well as declaration ending.\r\n        int commentPosition = currentLine.indexOf(comment);\r\n        int possibleEnding = currentLine.indexOf(\");\");\r\n\r\n        // If the declaration ending is actually before the comment, it is now valid.\r\n        if (commentPosition != -1 && commentPosition < possibleEnding)\r\n        {\r\n            continue;\r\n        }\r\n\r\n        // If the ending is detected, we are done looping.\r\n        if (possibleEnding != -1)\r\n        {\r\n            moduleDeclarationEndIndex = possibleEnding;\r\n            break;\r\n        }\r\n    }\r\n\r\n    // No ending for module declaration detected: Set return value as -1.\r\n    if (moduleDeclarationEndIndex == -1)\r\n    {\r\n        retval.second = -1;\r\n        return retval;\r\n    }\r\n\r\n    // The position for the module declaration ending = position on the line + stream position before the line.\r\n    moduleDeclarationEndIndex = moduleDeclarationEndIndex + streamPos;\r\n    // Set it as a return value.\r\n    retval.second = moduleDeclarationEndIndex - moduleDeclarationBeginIndex;\r\n\r\n    return retval;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VerilogSyntax::selectImplementation()\r\n//-----------------------------------------------------------------------------\r\nbool VerilogSyntax::selectImplementation(QString const& code, QString& implementation,\r\n    QString& postModule, QString& error)\r\n{\r\n    int implementationStart;\r\n    int implementationEnd;\r\n\r\n    if (!findImplementation(code, implementationStart, implementationEnd, error))\r\n    {\r\n        return false;\r\n    }\r\n\r\n    // Rip the implementation once detected.\r\n    int implementationLength = implementationEnd - implementationStart;\r\n    implementation = code.mid(implementationStart, implementationLength);\r\n\r\n    // Then take all the text that comes after the module, just in case.\r\n    int postStart = implementationEnd + 9;\r\n    postModule = code.mid(postStart);\r\n\r\n    // Also trim away extra white space.\r\n    postModule = postModule.trimmed();\r\n\r\n    // The destructor shall close the file. All done here.\r\n    return true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VerilogSyntax::findImplementation()\r\n//-----------------------------------------------------------------------------\r\nbool VerilogSyntax::findImplementation(QString const& code, int& implementationStart,\r\n    int& implementationEnd, QString& error)\r\n{\r\n    // We do not support multiple modules in the same file.\r\n    if (code.count(VerilogSyntax::MODULE_KEY_WORD) > 1)\r\n    {\r\n        error = QObject::tr(\"There was more than one module header in the code.\");\r\n        return false;\r\n    }\r\n\r\n    // Find the module header.\r\n    QPair<int,int> headerPosition = VerilogSyntax::findModuleDeclaration(code);\r\n    int moduleDeclarationBeginIndex = headerPosition.first;\r\n    int moduleDeclarationLength = headerPosition.second;\r\n\r\n    // Must have it to proceed.\r\n    if (moduleDeclarationBeginIndex == -1)\r\n    {\r\n        error = QObject::tr(\"Could not find module header start from the code.\");\r\n        return false;\r\n    }\r\n\r\n    // Must have it to proceed.\r\n    if (moduleDeclarationLength == -1)\r\n    {\r\n        error = QObject::tr(\"Could not find module header end from the code.\");\r\n        return false;\r\n    }\r\n\r\n    // The end of the override tag line is the beginning of the implementation.\r\n    implementationStart = code.indexOf(VerilogSyntax::TAG_OVERRIDE);\r\n\r\n    if (implementationStart == -1)\r\n    {\r\n        // If does not exist, the end of the header is the beginning of the implementation.\r\n        implementationStart = moduleDeclarationBeginIndex + moduleDeclarationLength + 3;\r\n    }\r\n    else\r\n    {\r\n        // Else we should seek the position where tag line ends.\r\n        implementationStart += VerilogSyntax::TAG_OVERRIDE.size() + 1;\r\n    }\r\n\r\n    // The end of the module is the end of the implementation.\r\n    implementationEnd = code.indexOf(VerilogSyntax::MODULE_END);\r\n\r\n    // The module must end some where.\r\n    if (implementationEnd == -1)\r\n    {\r\n        error = QObject::tr(\"Could not find module end from the code.\");\r\n        return false;\r\n    }\r\n\r\n    // The destructor shall close the file. All done here.\r\n    return true;\r\n}"
  },
  {
    "path": "Plugins/VerilogImport/VerilogSyntax.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: VerilogSyntax.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Esko Pekkarinen\r\n// Date: 26.09.2014\r\n//\r\n// Description:\r\n// Common elements of the Verilog language.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef VERILOGSYNTAX_H\r\n#define VERILOGSYNTAX_H\r\n\r\n#include <QRegularExpression>\r\n\r\nnamespace VerilogSyntax\r\n{\r\n    //! Used to identify the tool in environment identifiers.\r\n    QString const TOOL_NAME = QString(\"kactus2.cs.tut.fi\");\r\n\r\n\t//! Warning that is generated to generated files.\r\n\tconst QString TAG_OVERRIDE(\"WARNING: EVERYTHING ON AND ABOVE THIS LINE MAY BE OVERWRITTEN BY KACTUS2!!!\");\r\n\r\n    //! Module begins with module <name> #(<parameters>) (<ports>);.\r\n    const QRegularExpression MODULE_BEGIN(\"(?:^|\\\\r?\\\\n)[ \\t]*(?:macro)?module\\\\s+(\\\\w+)\\\\s*(#\\\\s*[(].*[)])?\\\\s*(?=([(][^)]*[)])?\\\\s*;)?\",\r\n        QRegularExpression::DotMatchesEverythingOption);\r\n\r\n\t//! Module header begins with module <name> #(.\r\n\tconst QRegularExpression MODULE_KEY_WORD(\"module\\\\s+(\\\\w+)\\\\s*(#?\\\\s*[(])\");\r\n\r\n    //! Module ends with keyword endmodule.\r\n    const QRegularExpression MODULE_END(\"endmodule\");\r\n\r\n    //! Pattern for ranges for e.g. port sizes are given as [left:right].\r\n    const QString RANGE(\"\\\\[.*?\\\\s*[:]\\\\s*.*?\\\\]\");\r\n\r\n    //! Regular expression for capturing range terms.\r\n    const QRegularExpression CAPTURING_RANGE(\"\\\\[(.*?)\\\\s*[:]\\\\s*(.*?)\\\\]\");\r\n\r\n    //! Pattern for ternary operator left part.\r\n    const QRegularExpression TERNARY_LEFT(\"\\\\?(?:[^?:]+|(?R))*+\\\\:\");\r\n\r\n    /*  Identifiers e.g. port names may contain characters a-z, A-Z, numbers, underscores and dollar signs.\r\n     *  Multiple identifiers declared at once must be comma separated.\r\n     */\r\n    const QString NAMES(\"[a-zA-Z0-9_$]+(?:\\\\s*[,]\\\\s*[a-zA-Z0-9_$]+)*\");\r\n\r\n    //! Pattern for one-line comments.\r\n    const QString COMMENT(\"[/]{2}[ \\\\t]*([^\\\\r\\\\n]*)(?=\\\\r?\\\\n|$)\");\r\n\r\n    //! Single-line comments.\r\n    const QRegularExpression COMMENTLINE(\"(^|\\\\r?\\\\n)[ \\\\t]*\" + COMMENT);\r\n\r\n    //! Multi-line comments.\r\n    const QRegularExpression MULTILINE_COMMENT(\"/\\\\*.*?\\\\*/\", QRegularExpression::DotMatchesEverythingOption);  \r\n\r\n    //! An expression that may contain an operator or an alphanumeric symbol.\r\n    const QString OPERATION_OR_ALPHANUMERIC(\"({[^}]*})|([$<>+*\\\\(\\\\)\\\\{\\\\}/-])|([']?[{(])|(`?\\\\w+)|((\\\\w+)?'\\\\w+)|\\\"\\\\w+\\\"\");\r\n    \r\n    //! Name + value pair, e.g. name=value.\r\n    const QString NAME_VALUE = \"\\\\w+\\\\s*=(\\\\s*(\" + OPERATION_OR_ALPHANUMERIC + \"))+\";  \r\n\r\n\t//! List of reserved keywords.\r\n\tconst QStringList KEYWORDS({\r\n\t\t\"alias\", \"always\", \"always_comb\", \"always_ff\", \"always_latch\", \"and\", \"assert\", \"assign\", \"assume\", \"automatic\",\r\n\t\t\"before\", \"begin\", \"bind\", \"bins\", \"binsof\", \"bit\", \"break\", \"buf\", \"bufif0\", \"bufif1\", \"byte\", \"case\", \"casex\",\r\n\t\t\"casez\", \"cell\", \"chandle\", \"class\", \"clocking\", \"cmos\", \"config\", \"const\", \"constraint\", \"context\", \"continue\",\r\n\t\t\"cover\", \"covergroup\", \"coverpoint\", \"cross\", \"deassign\", \"default\", \"defparam\", \"design\", \"disable\", \"dist\",\r\n\t\t\"do\", \"edge\", \"else\", \"end\", \"endcase\", \"endclass\", \"endclocking\", \"endconfig\", \"endfunction\", \"endgenerate\",\r\n\t\t\"endgroup\", \"endinterface\", \"endmodule\", \"endpackage\", \"endprimitive\", \"endprogram\", \"endproperty\",\r\n\t\t\"endspecify\", \"endsequence\", \"endtable\", \"endtask\", \"enum\", \"event\", \"expect\", \"export\", \"extends\", \"extern\",\r\n\t\t\"final\", \"first_match\", \"for\", \"force\", \"foreach\", \"forever\", \"fork\", \"forkjoin\", \"function\", \"generate\",\r\n\t\t\"genvar\", \"highz0\", \"highz1\", \"if\", \"iff\", \"ifnone\", \"ignore_bins\", \"illegal_bins\", \"import\", \"incdir\",\r\n\t\t\"include\", \"initial\", \"inout\", \"input\", \"inside\", \"instance\", \"int\", \"integer\", \"interface\", \"intersect\",\r\n\t\t\"join\", \"join_any\", \"join_none\", \"large\", \"liblist\", \"library\", \"local\", \"localparam\", \"logic\", \"longint\",\r\n\t\t\"macromodule\", \"matches\", \"medium\", \"modport\", \"module\", \"nand\", \"negedge\", \"new\", \"nmos\", \"nor\",\r\n\t\t\"noshowcancelled\", \"not\", \"notif0\", \"notif1\", \"null\", \" or \", \"output\", \"package\", \"packed\", \"parameter\",\r\n\t\t\"pmos\", \"posedge\", \"primitive\", \"priority\", \"program\", \"property\", \"protected\", \"pull0\", \"pull1\", \"pulldown\",\r\n\t\t\"pullup\", \"pulsestyle_onevent\", \"pulsestyle_ondetect\", \"pure\", \"rand\", \"randc\", \"randcase\", \"randsequence\",\r\n\t\t\"rcmos\", \"real\", \"realtime\", \"ref\", \"reg\", \"release\", \"repeat\", \"return\", \"rnmos\", \"rpmos\", \"rtran\", \"rtranif0\",\r\n\t\t\"rtranif1\", \"scalared\", \"sequence\", \"shortint\", \"shortreal\", \"showcancelled\", \"signed\", \"small\", \"solve\",\r\n\t\t\"specify\", \"specparam\", \"static\", \"string\", \"strong0\", \"strong1\", \"struct\", \"super\", \"supply0\", \"supply1\",\r\n\t\t\"table\", \"tagged\", \"task\", \"this\", \"throughout\", \"time\", \"timeprecision\", \"timeunit\", \"tran\", \"tranif0\", \r\n\t\t\"tranif1\", \"tri\", \"tri0\", \"tri1\", \"triand\", \"trior\", \"trireg\", \"type\", \"typedef\", \"union\", \"unique\", \"unsigned\",\r\n\t\t\"use\", \"uwire\", \"var\", \"vectored\", \"virtual\", \"void\", \"wait\", \"wait_order\", \"wand\", \"weak0\", \"weak1\", \"while\",\r\n\t\t\"wildcard\", \"wire\", \"with\", \"within\", \"wor\", \"xnor\", \"xor\"});\r\n\r\n    /*!\r\n     *  Returns the given name in a valid format for Verilog.\r\n     */\r\n    QString legalizeName(QString const& name);\r\n\r\n    /*!\r\n     *  Culls multi line comments and stray single line comments out of the input text.\r\n     *\r\n     *    @param [in] inspect   The input text to parse.\r\n     *\r\n     *    @return   The input without comments.\r\n     */\r\n    QString cullStrayComments(QString const& input);\r\n    \r\n    /*!\r\n     *  Finds the position and length of the first Verilog module declaration in the input.\r\n     *\r\n     *    @param [in] input   The input text to parse.\r\n     *\r\n     *    @return   The position and length of the module declaration.\r\n     */\r\n    QPair<int,int> findModuleDeclaration(QString const& input);\r\n\r\n    /*!\r\n     *  Finds the module implementation in Verilog code.\r\n     *\r\n\t *    @param [in] code\t\t            The code that will be inspected.\r\n\t *    @param [out] implementation\t        The module implementation.\r\n     *    @param [out] postModule\t\t        Anything that exists after the module.\r\n     *    @param [out] error                  If fails, this will contain an error message.\r\n\t *\r\n\t *    @return True, if a single implementation could be found, else false.\r\n     */\r\n\tbool selectImplementation(QString const& fileContent, QString& implementation,\r\n        QString& postModule, QString& error);\r\n    \r\n    /*!\r\n     *  Finds position of the module implementation in Verilog code.\r\n     *\r\n\t *    @param [in] code\t\t            The code that will be inspected.\r\n\t *    @param [out] implementationStart    The position where the implementation begins, if successful.\r\n     *    @param [out] implementationEnd      The position where the implementation ends, if successful.\r\n     *    @param [out] error                  If fails, this will contain an error message.\r\n\t *\r\n\t *    @return True, if a single implementation could be found, else false.\r\n     */\r\n    bool findImplementation(QString const& code, int& implementationStart, int& implementationEnd, QString& error);\r\n}\r\n\r\n#endif // VERILOGSYNTAX_H"
  },
  {
    "path": "Plugins/VerilogImport/verilogimport_global.h",
    "content": "#ifndef VERILOGIMPORT_GLOBAL_H\r\n#define VERILOGIMPORT_GLOBAL_H\r\n\r\n#include <QtCore/qglobal.h>\r\n\r\n#ifdef VERILOGIMPORT_LIB\r\n# define VERILOGIMPORT_EXPORT Q_DECL_EXPORT\r\n#else\r\n# define VERILOGIMPORT_EXPORT Q_DECL_IMPORT\r\n#endif\r\n\r\n#endif // VERILOGIMPORT_GLOBAL_H\r\n"
  },
  {
    "path": "Plugins/VerilogImport/verilogimportplugin.json",
    "content": "{\r\n\t\"Keys\": [ \"Verilos import Plugin\" ]\r\n}"
  },
  {
    "path": "Plugins/VerilogIncludeImport/VerilogIncludeImport.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: VerilogIncludeImport.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Esko Pekkarinen\r\n// Date: 30.03.2015\r\n//\r\n// Description:\r\n// Import plugin for Verilog definitions.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"VerilogIncludeImport.h\"\r\n\r\n#include <Plugins/VerilogImport/VerilogSyntax.h>\r\n#include <KactusAPI/include/ImportColors.h>\r\n\r\n#include <IPXACTmodels/Component/Component.h>\r\n#include <IPXACTmodels/common/Parameter.h>\r\n\r\n#include <QRegularExpression>\r\n\r\nnamespace\r\n{\r\n    QRegularExpression const DEFINE(\"`define (\\\\w+(?!\\\\s?[(].*?[)])) ((?:(?:\\\\\\\\\\\\\\n)|(.*?))*)?[ \\\\t]*(\" +\r\n        VerilogSyntax::COMMENT + \")?\\\\n\");\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VerilogIncludeImport::VerilogIncludeImport()\r\n//-----------------------------------------------------------------------------\r\nVerilogIncludeImport::VerilogIncludeImport() : QObject(0), parameterParser_(), highlighter_(0)\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VerilogIncludeImport::~VerilogIncludeImport()\r\n//-----------------------------------------------------------------------------\r\nVerilogIncludeImport::~VerilogIncludeImport()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VerilogIncludeImport::getName()\r\n//-----------------------------------------------------------------------------\r\nQString VerilogIncludeImport::getName() const\r\n{\r\n    return \"Verilog include import\";\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VerilogIncludeImport::getVersion()\r\n//-----------------------------------------------------------------------------\r\nQString VerilogIncludeImport::getVersion() const\r\n{\r\n    return \"1.1\";\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VerilogIncludeImport::getDescription()\r\n//-----------------------------------------------------------------------------\r\nQString VerilogIncludeImport::getDescription() const\r\n{\r\n    return \"Import defines and parameters from a verilog include file.\";\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VerilogIncludeImport::getVendor()\r\n//-----------------------------------------------------------------------------\r\nQString VerilogIncludeImport::getVendor() const\r\n{\r\n    return tr(\"TUT\");\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VerilogIncludeImport::getLicense()\r\n//-----------------------------------------------------------------------------\r\nQString VerilogIncludeImport::getLicense() const\r\n{\r\n    return tr(\"GPL2\");\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VerilogIncludeImport::getLicenseHolder()\r\n//-----------------------------------------------------------------------------\r\nQString VerilogIncludeImport::getLicenseHolder() const\r\n{\r\n    return tr(\"Public\");\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VerilogIncludeImport::getSettingsWidget()\r\n//-----------------------------------------------------------------------------\r\nQWidget* VerilogIncludeImport::getSettingsWidget()\r\n{\r\n    return nullptr;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VerilogIncludeImport::getProgramRequirements()\r\n//-----------------------------------------------------------------------------\r\nQList<IPlugin::ExternalProgramRequirement> VerilogIncludeImport::getProgramRequirements()\r\n{\r\n    return QList<IPlugin::ExternalProgramRequirement>();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VerilogIncludeImport::getSupportedFileTypes()\r\n//-----------------------------------------------------------------------------\r\nQStringList VerilogIncludeImport::getSupportedFileTypes() const\r\n{\r\n    QStringList supportedTypes;\r\n    supportedTypes << \"verilogSource\" << \"verilogSource-95\" << \"verilogSource-2001\" << \"systemVerilogSource\";\r\n    return supportedTypes;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VerilogIncludeImport::getCompatibilityWarnings()\r\n//-----------------------------------------------------------------------------\r\nQString VerilogIncludeImport::getCompatibilityWarnings() const\r\n{\r\n    return QString();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VerilogIncludeImport::getFileComponents()\r\n//-----------------------------------------------------------------------------\r\nQStringList VerilogIncludeImport::getFileComponents(QString const& input) const\r\n{\r\n    QStringList fileModules;\r\n\r\n    QRegularExpression multilineComment(VerilogSyntax::MULTILINE_COMMENT);\r\n\r\n    QString inspect = input;\r\n\r\n    int moduleBegin = inspect.indexOf(VerilogSyntax::MODULE_BEGIN);\r\n    int moduleEnd = VerilogSyntax::MODULE_END.match(inspect).capturedEnd();\r\n\r\n    while (moduleBegin != -1)\r\n    {\r\n        QString newModule = inspect.mid(moduleBegin, moduleEnd - moduleBegin);\r\n        fileModules.append(newModule);\r\n        inspect.remove(newModule);\r\n\r\n        moduleBegin = inspect.indexOf(VerilogSyntax::MODULE_BEGIN);\r\n        moduleEnd = VerilogSyntax::MODULE_END.match(inspect).capturedEnd();\r\n    }\r\n\r\n    return fileModules;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VerilogIncludeImport::getComponentName()\r\n//-----------------------------------------------------------------------------\r\nQString VerilogIncludeImport::getComponentName(QString const& /*componentDeclaration*/) const\r\n{\r\n    return QString();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VerilogIncludeImport::import()\r\n//-----------------------------------------------------------------------------\r\nvoid VerilogIncludeImport::import(QString const& input, QString const& /*componentDeclaration*/,\r\n    QSharedPointer<Component> targetComponent)\r\n{\r\n    QString nonCommentedInput = VerilogSyntax::cullStrayComments(input);\r\n\r\n    int position = 0;\r\n    QRegularExpressionMatch defineMatch = DEFINE.match(nonCommentedInput, position);\r\n    while (defineMatch.hasMatch())\r\n    {\r\n        QString definition = defineMatch.captured();\r\n\r\n        highlightDefinition(definition);\r\n        createParameterFromDefinition(definition, targetComponent);\r\n\r\n        position = defineMatch.capturedStart() + defineMatch.capturedLength();\r\n        defineMatch = DEFINE.match(nonCommentedInput, position);\r\n    }\r\n\r\n    parseParameters(input, targetComponent);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VerilogIncludeImport::setHighlighter()\r\n//-----------------------------------------------------------------------------\r\nvoid VerilogIncludeImport::setHighlighter(Highlighter* highlighter)\r\n{\r\n    highlighter_ = highlighter;\r\n    parameterParser_.setHighlighter(highlighter);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VerilogIncludeImport::highlightDefinition()\r\n//-----------------------------------------------------------------------------\r\nvoid VerilogIncludeImport::highlightDefinition(QString const& definition)\r\n{\r\n    if (highlighter_)\r\n    {     \r\n        highlighter_->applyFontColor(definition, Qt::black);\r\n        highlighter_->applyHighlight(definition, ImportColors::MODELPARAMETER);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VerilogIncludeImport::createParameterFromDefinition()\r\n//-----------------------------------------------------------------------------\r\nvoid VerilogIncludeImport::createParameterFromDefinition(QString const& definition, \r\n    QSharedPointer<Component> targetComponent)\r\n{\r\n    QRegularExpressionMatch match = DEFINE.match(definition);\r\n\r\n    QString name = match.captured(1);\r\n    QString value = match.captured(2).remove(QRegularExpression(\"\\\\\\\\\\\\\\n\"));\r\n    QString description = match.captured(5).simplified();\r\n\r\n    QSharedPointer<Parameter> parameter = findParameterByName(targetComponent, name);\r\n    if (parameter.isNull())\r\n    {\r\n        parameter = QSharedPointer<Parameter>(new Parameter());                    \r\n        parameter->setName(name);        \r\n        targetComponent->getParameters()->append(parameter);\r\n    }\r\n\r\n    if (value.isEmpty())\r\n    {\r\n        value = QStringLiteral(\"1\");\r\n    }\r\n\r\n    parameter->setValue(value);\r\n    parameter->setDescription(description);\r\n    parameter->setAttribute(\"imported\", \"true\");\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VerilogIncludeImport::findParameterByName()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<Parameter> VerilogIncludeImport::findParameterByName(\r\n    QSharedPointer<Component> targetComponent, QString const& name) const\r\n{\r\n    foreach (QSharedPointer<Parameter> existingParameter, *targetComponent->getParameters())\r\n    {\r\n        if (existingParameter->name() == name)\r\n        {\r\n            return existingParameter;            \r\n        }\r\n    }\t\r\n\r\n    return QSharedPointer<Parameter>();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VerilogIncludeImport::parseParameters()\r\n//-----------------------------------------------------------------------------\r\nvoid VerilogIncludeImport::parseParameters(QString const& input, QSharedPointer<Component> targetComponent)\r\n{\r\n    QStringList nonModuleAreas = getNonModuleAreas(input);\r\n\r\n    for (auto nonModule : nonModuleAreas)\r\n    {\r\n        parameterParser_.import(nonModule, targetComponent, QSharedPointer<ComponentInstantiation>(0));\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VerilogIncludeImport::getNonModuleAreas()\r\n//-----------------------------------------------------------------------------\r\nQStringList VerilogIncludeImport::getNonModuleAreas(QString const& input) const\r\n{\r\n    QString inspect = input;\r\n    QStringList nonModuleAreas;\r\n    QStringList containedModules = getFileComponents(input);\r\n\r\n    if (containedModules.isEmpty())\r\n    {\r\n        nonModuleAreas.append(input);\r\n    }\r\n    else\r\n    {\r\n        for (auto module : containedModules)\r\n        {\r\n            QStringList splitAreas = inspect.split(module);\r\n            nonModuleAreas.append(splitAreas.first());\r\n\r\n            inspect = splitAreas.last();\r\n            if (module == containedModules.last())\r\n            {\r\n                nonModuleAreas.append(inspect);\r\n            }\r\n        }\r\n    }\r\n\r\n    return nonModuleAreas;\r\n}\r\n"
  },
  {
    "path": "Plugins/VerilogIncludeImport/VerilogIncludeImport.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: VerilogIncludeImport.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Esko Pekkarinen\r\n// Date: 30.03.2015\r\n//\r\n// Description:\r\n// Import plugin for Verilog definitions.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef VERILOGINCLUDEIMPORT_H\r\n#define VERILOGINCLUDEIMPORT_H\r\n\r\n#include \"verilogincludeimport_global.h\"\r\n\r\n#include <KactusAPI/include/IPlugin.h>\r\n#include <KactusAPI/include/ImportPlugin.h>\r\n#include <KactusAPI/include/IncludeImportPlugin.h>\r\n#include <KactusAPI/include/HighlightSource.h>\r\n\r\n#include <Plugins/VerilogImport/VerilogParameterParser.h>\r\n\r\n#include <QSharedPointer>\r\n#include <QObject>\r\n\r\nclass Component;\r\nclass Parameter;\r\n//-----------------------------------------------------------------------------\r\n//! Import plugin for Verilog definitions.\r\n//-----------------------------------------------------------------------------\r\nclass VERILOGINCLUDEIMPORT_EXPORT VerilogIncludeImport : public QObject, public IncludeImportPlugin, public HighlightSource\r\n{\r\n    Q_OBJECT\r\n    Q_PLUGIN_METADATA(IID \"kactus2.plugins.verilogincludeimportplugin\" FILE \"verilogincludeimportplugin.json\")\r\n   \r\n    Q_INTERFACES(IPlugin)\r\n    Q_INTERFACES(ImportPlugin)\r\n    Q_INTERFACES(IncludeImportPlugin)\r\n\r\npublic:\r\n\r\n\t//! The constructor.\r\n\tVerilogIncludeImport();\r\n\r\n\t//! The destructor.\r\n\t~VerilogIncludeImport();\r\n\r\n    /*!\r\n     *  Returns the name of the plugin.\r\n     */\r\n    virtual QString getName() const;\r\n\r\n    /*!\r\n     *  Returns the version of the plugin.\r\n     */\r\n    virtual QString getVersion() const;\r\n\r\n    /*!\r\n     *  Returns the description of the plugin.\r\n     */\r\n    virtual QString getDescription() const;\r\n\r\n    /*!\r\n     *  Returns the vendor of the plugin.\r\n     */\r\n    virtual QString getVendor() const;\r\n\r\n    /*!\r\n     *  Returns the license of the plugin.\r\n     */\r\n    virtual QString getLicense() const;\r\n\r\n    /*!\r\n     *  Returns the license holder of the plugin.\r\n     */\r\n    virtual QString getLicenseHolder() const;\r\n\r\n    /*!\r\n     *  Returns the settings widget.\r\n     */\r\n    virtual QWidget* getSettingsWidget();\r\n\r\n    /*!\r\n     *  This is used to access the settings modified by function getSettingsWidget().\r\n     */\r\n    virtual PluginSettingsModel* getSettingsModel(){return NULL;}\r\n\r\n\t//! \\brief Returns the external program requirements of the plugin.\r\n\t virtual QList<ExternalProgramRequirement> getProgramRequirements();\r\n\r\n    /*!\r\n     *  Returns the supported import file types.\r\n     *\r\n     *    @return The file types the import plugin supports.\r\n     */\r\n    virtual QStringList getSupportedFileTypes() const;\r\n\r\n    /*!\r\n     *  Gets any compatibility warnings for the plugin.\r\n     *\r\n     *    @return The warning text.\r\n     */\r\n    virtual QString getCompatibilityWarnings() const;\r\n\r\n    /*!\r\n     *  Get component declarations from the selected input file.\r\n     *\r\n     *    @param [in] input   The selected input file.\r\n     *\r\n     *    @return List of component declarations found in the selected input.\r\n     */\r\n    virtual QStringList getFileComponents(QString const& input) const override final;\r\n\r\n    /*!\r\n     *  Get the name of the selected component declaration.\r\n     *\r\n     *    @param [in] componentDeclaration    The selected component declaration.\r\n     *\r\n     *    @return Name of the selected component declaration.\r\n     */\r\n    virtual QString getComponentName(QString const& componentDeclaration) const override final;\r\n\r\n    /*!\r\n     *  Parses the given input and creates parameters from Verilog defines.\r\n     *\r\n     *    @param [in] input                   The input text to parse.\r\n     *    @param [in] componentDeclaration    Declaration of the selected component.\r\n     *    @param [in] targetComponent         The component to apply all imported changes to.\r\n     */\r\n    virtual void import(QString const& input, QString const& componentDeclaration,\r\n        QSharedPointer<Component> targetComponent) override final;\r\n\r\n    /*!\r\n     *  Sets the given highlighter to be used by the plugin.\r\n     *\r\n     *    @param [in] highlighter   The highlighter to use.          \r\n     */\r\n    virtual void setHighlighter(Highlighter* highlighter);\r\n\r\nprivate:\r\n\r\n\t// Disable copying.\r\n\tVerilogIncludeImport(VerilogIncludeImport const& rhs);\r\n\tVerilogIncludeImport& operator=(VerilogIncludeImport const& rhs);\r\n        \r\n    /*!\r\n     *  Highlights the given definition.\r\n     *\r\n     *    @param [in] definition   The definition to highlight.\r\n     */\r\n    void highlightDefinition(QString const& definition);\r\n\r\n    /*!\r\n     *  Creates a parameter from the given definition and adds it to the component.\r\n     *  Existing parameter with the same name will be updated and no new parameter is added.\r\n     *\r\n     *    @param [in] definition          The definition to create the parameter from.\r\n     *    @param [in] targetComponent     The component to add the parameter to.\r\n     */\r\n    void createParameterFromDefinition(QString const& definition, QSharedPointer<Component> targetComponent);\r\n\r\n    /*!\r\n     *  Finds a parameter in the given component by the given name.\r\n     *\r\n     *    @param [in] targetComponent     The component the search in.\r\n     *    @param [in] name                The name of the model parameter to find.\r\n     *\r\n     *    @return The parameter with the given name or null if no parameter matches the name.\r\n     */\r\n    QSharedPointer<Parameter> findParameterByName(QSharedPointer<Component> targetComponent, \r\n        QString const& name) const;\r\n\r\n    /*!\r\n     *  Parse the included verilog parameters.\r\n     *\r\n     *    @param [in] input               The input text to parse.\r\n     *    @param [in] targetComponent     The component to add the parameter to.\r\n     */\r\n    void parseParameters(QString const& input, QSharedPointer<Component> targetComponent);\r\n\r\n    /*!\r\n     *  Get the areas from the input text that do not contain verilog modules.\r\n     *\r\n     *    @param [in] input   The selected input.\r\n     *\r\n     *    @return List of non module text areas.\r\n     */\r\n    QStringList getNonModuleAreas(QString const& input) const;\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! Parser for verilog parameters.\r\n    VerilogParameterParser parameterParser_;\r\n\r\n    //! The highlighter to use.\r\n    Highlighter* highlighter_;\r\n};\r\n\r\n#endif // VERILOGINCLUDEIMPORT_H\r\n"
  },
  {
    "path": "Plugins/VerilogIncludeImport/VerilogIncludeImport.pri",
    "content": "# ----------------------------------------------------\r\n# This file is generated by the Qt Visual Studio Tools.\r\n# ------------------------------------------------------\r\n\r\n\r\nHEADERS += ../../common/expressions/utilities.h \\\r\n    ../PluginSystem/ImportPlugin/ImportColors.h \\\r\n    ../VerilogImport/VerilogParameterParser.h \\\r\n    ./verilogincludeimport_global.h \\\r\n    ./VerilogIncludeImport.h\r\nSOURCES += ../../common/expressions/utilities.cpp \\\r\n    ../VerilogImport/VerilogParameterParser.cpp \\\r\n    ../VerilogImport/VerilogSyntax.cpp \\\r\n    ./VerilogIncludeImport.cpp\r\n"
  },
  {
    "path": "Plugins/VerilogIncludeImport/VerilogIncludeImport.pro",
    "content": "# ----------------------------------------------------\r\n# This file is generated by the Qt Visual Studio Add-in.\r\n# ------------------------------------------------------\r\n\r\nTEMPLATE = lib\r\n\r\nQT += core xml widgets gui\r\nCONFIG += c++11\r\n\r\n\r\nDEFINES += VERILOGINCLUDEIMPORT_LIB\r\nINCLUDEPATH += ./../.. \\\r\n    ./GeneratedFiles \\\r\n    .\r\n\r\nCONFIG(debug, debug|release) {\r\n    # debug mode\r\n    LIBS += \\\r\n        -L../../executable -lIPXACTmodelsd\r\n\r\n    MOC_DIR += ./GeneratedFiles/Debug\r\n    OBJECTS_DIR += Debug\r\n    TARGET = VerilogIncludeImportd\r\n\r\n} else {\r\n    # release mode \r\n    LIBS += \\\r\n        -L../../executable -lIPXACTmodels\r\n    \r\n    MOC_DIR += ./GeneratedFiles/Release\r\n    OBJECTS_DIR += Release\r\n    TARGET = VerilogIncludeImport\r\n}\r\n\r\nDESTDIR = ../../executable/Plugins\r\n\r\nDEPENDPATH += .\r\nUI_DIR += ./GeneratedFiles\r\nRCC_DIR += ./GeneratedFiles\r\n\r\ninclude(VerilogIncludeImport.pri)\r\n\r\ntarget.path = $$plugin_path\r\nINSTALLS += target\r\n"
  },
  {
    "path": "Plugins/VerilogIncludeImport/VerilogIncludeImport.vcxproj",
    "content": "﻿<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n<Project DefaultTargets=\"Build\" ToolsVersion=\"15.0\" xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">\r\n  <ItemGroup Label=\"ProjectConfigurations\">\r\n    <ProjectConfiguration Include=\"Debug|x64\">\r\n      <Configuration>Debug</Configuration>\r\n      <Platform>x64</Platform>\r\n    </ProjectConfiguration>\r\n    <ProjectConfiguration Include=\"Release|x64\">\r\n      <Configuration>Release</Configuration>\r\n      <Platform>x64</Platform>\r\n    </ProjectConfiguration>\r\n  </ItemGroup>\r\n  <PropertyGroup Label=\"Globals\">\r\n    <ProjectGuid>{2480AD41-D429-460B-9DAC-B1BA784F0FE1}</ProjectGuid>\r\n    <Keyword>QtVS_v304</Keyword>\r\n    <WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>\r\n    <QtMsBuild Condition=\"'$(QtMsBuild)'=='' or !Exists('$(QtMsBuild)\\qt.targets')\">$(MSBuildProjectDirectory)\\QtMsBuild</QtMsBuild>\r\n  </PropertyGroup>\r\n  <Import Project=\"$(VCTargetsPath)\\Microsoft.Cpp.Default.props\" />\r\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\" Label=\"Configuration\">\r\n    <ConfigurationType>DynamicLibrary</ConfigurationType>\r\n    <PlatformToolset>v143</PlatformToolset>\r\n  </PropertyGroup>\r\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\" Label=\"Configuration\">\r\n    <ConfigurationType>DynamicLibrary</ConfigurationType>\r\n    <PlatformToolset>v143</PlatformToolset>\r\n  </PropertyGroup>\r\n  <Import Project=\"$(VCTargetsPath)\\Microsoft.Cpp.props\" />\r\n  <Target Name=\"QtMsBuildNotFound\" BeforeTargets=\"CustomBuild;ClCompile\" Condition=\"!Exists('$(QtMsBuild)\\qt.targets') or !Exists('$(QtMsBuild)\\qt.props')\">\r\n    <Message Importance=\"High\" Text=\"QtMsBuild: could not locate qt.targets, qt.props; project may not build correctly.\" />\r\n  </Target>\r\n  <ImportGroup Label=\"ExtensionSettings\">\r\n  </ImportGroup>\r\n  <ImportGroup Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\" Label=\"PropertySheets\">\r\n    <Import Project=\"$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props\" Condition=\"exists('$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props')\" Label=\"LocalAppDataPlatform\" />\r\n  </ImportGroup>\r\n  <ImportGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\" Label=\"PropertySheets\">\r\n    <Import Project=\"$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props\" Condition=\"exists('$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props')\" Label=\"LocalAppDataPlatform\" />\r\n  </ImportGroup>\r\n  <PropertyGroup Label=\"UserMacros\" />\r\n  <ImportGroup Condition=\"Exists('$(QtMsBuild)\\qt_defaults.props')\">\r\n    <Import Project=\"$(QtMsBuild)\\qt_defaults.props\" />\r\n  </ImportGroup>\r\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n    <OutDir>$(SolutionDir)executable\\Plugins\\</OutDir>\r\n  </PropertyGroup>\r\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n    <OutDir>$(SolutionDir)executable\\Plugins\\</OutDir>\r\n  </PropertyGroup>\r\n  <PropertyGroup Label=\"QtSettings\" Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n    <QtInstall>6.2.4</QtInstall>\r\n    <QtModules>core;gui;widgets;xml</QtModules>\r\n  </PropertyGroup>\r\n  <PropertyGroup Label=\"QtSettings\" Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n    <QtInstall>6.2.4</QtInstall>\r\n    <QtModules>core;gui;widgets;xml</QtModules>\r\n  </PropertyGroup>\r\n  <ImportGroup Condition=\"Exists('$(QtMsBuild)\\qt.props')\">\r\n    <Import Project=\"$(QtMsBuild)\\qt.props\" />\r\n  </ImportGroup>\r\n  <PropertyGroup>\r\n    <_ProjectFileVersion>10.0.40219.1</_ProjectFileVersion>\r\n  </PropertyGroup>\r\n  <ItemDefinitionGroup Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n    <ClCompile>\r\n      <PreprocessorDefinitions>UNICODE;WIN32;WIN64;VERILOGINCLUDEIMPORT_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>\r\n      <AdditionalIncludeDirectories>.\\GeneratedFiles\\$(ConfigurationName);.\\GeneratedFiles;..\\..\\;.;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\r\n      <Optimization>Disabled</Optimization>\r\n      <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>\r\n      <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>\r\n      <TreatWChar_tAsBuiltInType>true</TreatWChar_tAsBuiltInType>\r\n      <MultiProcessorCompilation>true</MultiProcessorCompilation>\r\n      <LanguageStandard>stdcpp17</LanguageStandard>\r\n      <AdditionalOptions>/Zc:__cplusplus %(AdditionalOptions)</AdditionalOptions>\r\n    </ClCompile>\r\n    <Link>\r\n      <SubSystem>Windows</SubSystem>\r\n      <OutputFile>$(OutDir)\\$(ProjectName).dll</OutputFile>\r\n      <AdditionalLibraryDirectories>..\\..\\executable;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>\r\n      <GenerateDebugInformation>true</GenerateDebugInformation>\r\n      <AdditionalDependencies>IPXACTmodelsd.lib;%(AdditionalDependencies)</AdditionalDependencies>\r\n    </Link>\r\n    <QtMoc>\r\n      <ExecutionDescription>Moc'ing %(Identity)...</ExecutionDescription>\r\n      <DynamicSource>output</DynamicSource>\r\n      <QtMocDir>.\\GeneratedFiles\\$(ConfigurationName)</QtMocDir>\r\n      <QtMocFileName>moc_%(Filename).cpp</QtMocFileName>\r\n    </QtMoc>\r\n  </ItemDefinitionGroup>\r\n  <ItemDefinitionGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n    <ClCompile>\r\n      <PreprocessorDefinitions>UNICODE;WIN32;WIN64;QT_NO_DEBUG;NDEBUG;VERILOGINCLUDEIMPORT_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>\r\n      <AdditionalIncludeDirectories>.\\GeneratedFiles\\$(ConfigurationName);.\\GeneratedFiles;..\\..\\;.;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\r\n      <DebugInformationFormat>\r\n      </DebugInformationFormat>\r\n      <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>\r\n      <TreatWChar_tAsBuiltInType>true</TreatWChar_tAsBuiltInType>\r\n      <MultiProcessorCompilation>true</MultiProcessorCompilation>\r\n      <AdditionalOptions>/Zc:__cplusplus %(AdditionalOptions)</AdditionalOptions>\r\n      <LanguageStandard>stdcpp17</LanguageStandard>\r\n    </ClCompile>\r\n    <Link>\r\n      <SubSystem>Windows</SubSystem>\r\n      <OutputFile>$(OutDir)\\$(ProjectName).dll</OutputFile>\r\n      <AdditionalLibraryDirectories>..\\..\\executable;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>\r\n      <GenerateDebugInformation>false</GenerateDebugInformation>\r\n      <AdditionalDependencies>IPXACTmodels.lib;%(AdditionalDependencies)</AdditionalDependencies>\r\n    </Link>\r\n    <QtMoc>\r\n      <ExecutionDescription>Moc'ing %(Identity)...</ExecutionDescription>\r\n      <DynamicSource>output</DynamicSource>\r\n      <QtMocDir>.\\GeneratedFiles\\$(ConfigurationName)</QtMocDir>\r\n      <QtMocFileName>moc_%(Filename).cpp</QtMocFileName>\r\n    </QtMoc>\r\n  </ItemDefinitionGroup>\r\n  <ItemGroup>\r\n    <QtMoc Include=\"VerilogIncludeImport.h\">\r\n    </QtMoc>\r\n    <ClInclude Include=\"..\\..\\common\\expressions\\utilities.h\" />\r\n    <ClInclude Include=\"..\\PluginSystem\\ImportPlugin\\ImportColors.h\" />\r\n    <ClInclude Include=\"..\\VerilogImport\\VerilogParameterParser.h\" />\r\n    <ClInclude Include=\"verilogincludeimport_global.h\" />\r\n  </ItemGroup>\r\n  <ItemGroup>\r\n    <ClCompile Include=\"..\\..\\common\\expressions\\utilities.cpp\" />\r\n    <ClCompile Include=\"..\\VerilogImport\\VerilogParameterParser.cpp\" />\r\n    <ClCompile Include=\"..\\VerilogImport\\VerilogSyntax.cpp\" />\r\n    <ClCompile Include=\"VerilogIncludeImport.cpp\" />\r\n  </ItemGroup>\r\n  <ItemGroup>\r\n    <None Include=\"verilogincludeimportplugin.json\" />\r\n  </ItemGroup>\r\n  <Import Project=\"$(VCTargetsPath)\\Microsoft.Cpp.targets\" />\r\n  <ImportGroup Condition=\"Exists('$(QtMsBuild)\\qt.targets')\">\r\n    <Import Project=\"$(QtMsBuild)\\qt.targets\" />\r\n  </ImportGroup>\r\n  <ImportGroup Label=\"ExtensionTargets\">\r\n  </ImportGroup>\r\n  <ProjectExtensions>\r\n    <VisualStudio>\r\n      <UserProperties />\r\n    </VisualStudio>\r\n  </ProjectExtensions>\r\n</Project>"
  },
  {
    "path": "Plugins/VerilogIncludeImport/VerilogIncludeImport.vcxproj.filters",
    "content": "﻿<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n<Project ToolsVersion=\"4.0\" xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">\r\n  <ItemGroup>\r\n    <Filter Include=\"Source Files\">\r\n      <UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>\r\n      <Extensions>cpp;cxx;c;def</Extensions>\r\n    </Filter>\r\n    <Filter Include=\"Header Files\">\r\n      <UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>\r\n      <Extensions>h</Extensions>\r\n    </Filter>\r\n    <Filter Include=\"Form Files\">\r\n      <UniqueIdentifier>{99349809-55BA-4b9d-BF79-8FDBB0286EB3}</UniqueIdentifier>\r\n      <Extensions>ui</Extensions>\r\n    </Filter>\r\n    <Filter Include=\"Resource Files\">\r\n      <UniqueIdentifier>{D9D6E242-F8AF-46E4-B9FD-80ECBC20BA3E}</UniqueIdentifier>\r\n      <Extensions>qrc;*</Extensions>\r\n      <ParseFiles>false</ParseFiles>\r\n    </Filter>\r\n    <Filter Include=\"Generated Files\">\r\n      <UniqueIdentifier>{71ED8ED8-ACB9-4CE9-BBE1-E00B30144E11}</UniqueIdentifier>\r\n      <Extensions>moc;h;cpp</Extensions>\r\n      <SourceControlFiles>False</SourceControlFiles>\r\n    </Filter>\r\n    <Filter Include=\"Generated Files\\Debug\">\r\n      <UniqueIdentifier>{02f1b634-0d09-4474-9a5a-c5d09d3b7f8f}</UniqueIdentifier>\r\n      <Extensions>cpp;moc</Extensions>\r\n      <SourceControlFiles>False</SourceControlFiles>\r\n    </Filter>\r\n    <Filter Include=\"Generated Files\\Release\">\r\n      <UniqueIdentifier>{22d0229e-097b-42ef-8af2-91131208c611}</UniqueIdentifier>\r\n      <Extensions>cpp;moc</Extensions>\r\n      <SourceControlFiles>False</SourceControlFiles>\r\n    </Filter>\r\n  </ItemGroup>\r\n  <ItemGroup>\r\n    <ClInclude Include=\"verilogincludeimport_global.h\">\r\n      <Filter>Header Files</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\PluginSystem\\ImportPlugin\\ImportColors.h\">\r\n      <Filter>Header Files</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\VerilogImport\\VerilogParameterParser.h\">\r\n      <Filter>Header Files</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\common\\expressions\\utilities.h\">\r\n      <Filter>Header Files</Filter>\r\n    </ClInclude>\r\n  </ItemGroup>\r\n  <ItemGroup>\r\n    <QtMoc Include=\"VerilogIncludeImport.h\">\r\n      <Filter>Header Files</Filter>\r\n    </QtMoc>\r\n  </ItemGroup>\r\n  <ItemGroup>\r\n    \r\n    \r\n    <ClCompile Include=\"VerilogIncludeImport.cpp\">\r\n      <Filter>Source Files</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\VerilogImport\\VerilogParameterParser.cpp\">\r\n      <Filter>Source Files</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\VerilogImport\\VerilogSyntax.cpp\">\r\n      <Filter>Source Files</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\common\\expressions\\utilities.cpp\">\r\n      <Filter>Source Files</Filter>\r\n    </ClCompile>\r\n  </ItemGroup>\r\n  <ItemGroup>\r\n    <None Include=\"verilogincludeimportplugin.json\" />\r\n  </ItemGroup>\r\n</Project>"
  },
  {
    "path": "Plugins/VerilogIncludeImport/verilogincludeimport_global.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: verilogincludeimport_global.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Esko Pekkarinen\r\n// Date: 01.04.2015\r\n//\r\n// Description:\r\n// DLL export definitions for Verilog Include Import.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef VERILOGINCLUDEIMPORT_GLOBAL_H\r\n#define VERILOGINCLUDEIMPORT_GLOBAL_H\r\n\r\n#include <QtCore/qglobal.h>\r\n\r\n#ifdef VERILOGINCLUDEIMPORT_LIB\r\n# define VERILOGINCLUDEIMPORT_EXPORT Q_DECL_EXPORT\r\n#else\r\n# define VERILOGINCLUDEIMPORT_EXPORT Q_DECL_IMPORT\r\n#endif\r\n\r\n#endif // VERILOGINCLUDEIMPORT_GLOBAL_H\r\n"
  },
  {
    "path": "Plugins/VerilogIncludeImport/verilogincludeimportplugin.json",
    "content": "{\r\n\t\"Keys\": [ \"Verilog include import Plugin\" ]\r\n}"
  },
  {
    "path": "Plugins/VerilogSourceAnalyzer/VerilogSourceAnalyzer.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: VerilogSourceAnalyzer.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Esko Pekkarinen\r\n// Date: 07.04.2015\r\n//\r\n// Description:\r\n// Verilog source file analyzer for finding file dependencies.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"VerilogSourceAnalyzer.h\"\r\n\r\n#include <Plugins/VerilogImport/VerilogSyntax.h>\r\n\r\n#include <QCryptographicHash>\r\n#include <QDir>\r\n#include <QDebug>\r\n//-----------------------------------------------------------------------------\r\n// Function: VerilogSourceAnalyzer::VerilogSourceAnalyzer()\r\n//-----------------------------------------------------------------------------\r\nVerilogSourceAnalyzer::VerilogSourceAnalyzer() : QObject(nullptr)\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VerilogSourceAnalyzer::getName()\r\n//-----------------------------------------------------------------------------\r\nQString VerilogSourceAnalyzer::getName() const\r\n{\r\n    return \"Verilog Source Analyzer\";\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VerilogSourceAnalyzer::getVersion()\r\n//-----------------------------------------------------------------------------\r\nQString VerilogSourceAnalyzer::getVersion() const\r\n{\r\n    return \"0.10\";\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VerilogSourceAnalyzer::getDescription()\r\n//-----------------------------------------------------------------------------\r\nQString VerilogSourceAnalyzer::getDescription() const\r\n{\r\n    return \"Analyzes file dependencies from (System)Verilog files.\";\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VerilogSourceAnalyzer::getVendor()\r\n//-----------------------------------------------------------------------------\r\nQString VerilogSourceAnalyzer::getVendor() const\r\n{\r\n    return tr(\"tuni.fi\");\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VerilogSourceAnalyzer::getLicense()\r\n//-----------------------------------------------------------------------------\r\nQString VerilogSourceAnalyzer::getLicense() const\r\n{\r\n    return tr(\"GPL2\");\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VerilogSourceAnalyzer::getLicenseHolder()\r\n//-----------------------------------------------------------------------------\r\nQString VerilogSourceAnalyzer::getLicenseHolder() const\r\n{\r\n    return tr(\"Public\");\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VerilogSourceAnalyzer::getSettingsWidget()\r\n//-----------------------------------------------------------------------------\r\nQWidget* VerilogSourceAnalyzer::getSettingsWidget()\r\n{\r\n    return nullptr;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VerilogSourceAnalyzer::getProgramRequirements()\r\n//-----------------------------------------------------------------------------\r\nQList<IPlugin::ExternalProgramRequirement> VerilogSourceAnalyzer::getProgramRequirements()\r\n{\r\n    return QList<IPlugin::ExternalProgramRequirement>();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VerilogSourceAnalyzer::getSupportedFileTypes()\r\n//-----------------------------------------------------------------------------\r\nQStringList VerilogSourceAnalyzer::getSupportedFileTypes() const\r\n{\r\n    return QStringList({\"verilogSource\", \"verilogSource-95\", \"verilogSource-2001\", \"systemVerilogSource\"});\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VerilogSourceAnalyzer::calculateHash()\r\n//-----------------------------------------------------------------------------\r\nQString VerilogSourceAnalyzer::calculateHash(QString const& filename)\r\n{\r\n    QString content = readFileContentAndRemoveComments(filename);\r\n    if (content.isEmpty())\r\n    {\r\n        return QString();\r\n    }\r\n\r\n    QCryptographicHash hashFunction(QCryptographicHash::Sha1);\r\n    hashFunction.addData(content.toLatin1());\r\n\r\n    return hashFunction.result().toHex();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VerilogSourceAnalyzer::beginAnalysis()\r\n//-----------------------------------------------------------------------------\r\nvoid VerilogSourceAnalyzer::beginAnalysis(Component const* /*component*/, QString const& /*componentPath*/)\r\n{\r\n    // Nothing to do.\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VerilogSourceAnalyzer::endAnalysis()\r\n//-----------------------------------------------------------------------------\r\nvoid VerilogSourceAnalyzer::endAnalysis(Component const* /*component*/, QString const& /*componentPath*/)\r\n{\r\n\t// Nothing to do.\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VerilogSourceAnalyzer::getFileDependencies()\r\n//-----------------------------------------------------------------------------\r\nQList<FileDependencyDesc> VerilogSourceAnalyzer::getFileDependencies(Component const* component, \r\n    QString const& componentPath, QString const& filename)\r\n{\r\n\tQMap<QString, QString> itemsInFilesets = findItemsInFilesets(component, componentPath);\r\n\t\r\n\tQString sourceAbsolutePath = findAbsolutePathFor(filename, componentPath);\r\n\tQFileInfo sourceFileInfo(sourceAbsolutePath);\r\n\r\n\tQString fileContent = readFileContentAndRemoveComments(sourceAbsolutePath);\r\n\r\n\tQList<FileDependencyDesc> dependencies;\r\n\tdependencies.append(findIncludeDependencies(fileContent, sourceFileInfo, itemsInFilesets));\r\n\tdependencies.append(findInstantiationDependencies(fileContent, sourceFileInfo, itemsInFilesets));\r\n\r\n    return dependencies;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VerilogSourceAnalyzer::readFileContentAndRemoveComments()\r\n//-----------------------------------------------------------------------------\r\nQString VerilogSourceAnalyzer::readFileContentAndRemoveComments(QString const& filePath) const\r\n{\r\n    QFile targetFile(filePath);\r\n\r\n    if (!targetFile.open(QIODevice::ReadOnly | QIODevice::Text))\r\n    {\r\n        return QString();\r\n    }\r\n\r\n    QString fileContent = targetFile.readAll();\r\n    targetFile.close();\r\n\r\n    fileContent.remove(VerilogSyntax::MULTILINE_COMMENT);\r\n    fileContent.remove(QRegularExpression(VerilogSyntax::COMMENT));\r\n\r\n    return fileContent.simplified();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VerilogSourceAnalyzer::findAbsolutePathFor()\r\n//-----------------------------------------------------------------------------\r\nQString VerilogSourceAnalyzer::findAbsolutePathFor(QString const& filename, QString const& componentPath) const\r\n{\r\n\tQString path = filename;\r\n\tif (!QFileInfo(path).isAbsolute())\r\n\t{\r\n\t\tpath = componentPath + \"/\" + filename;\r\n\t}\r\n\r\n\treturn path;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VerilogSourceAnalyzer::findItemsInFilesets()\r\n//-----------------------------------------------------------------------------\r\nQMap<QString, QString> VerilogSourceAnalyzer::findItemsInFilesets(Component const* component,\r\n\tQString const& componentPath)\r\n{\r\n\tQMap<QString, QString> itemsInFilesets;\r\n\tfor (auto const& fileSet : *component->getFileSets())\r\n\t{\r\n\t\tfor (auto const& file : *fileSet->getFiles())\r\n\t\t{\r\n\t\t\tif (isOfSupportedFileType(file))\r\n\t\t\t{\r\n\t\t\t\tQString path = findAbsolutePathFor(file->name(), componentPath);\r\n\t\t\t\tQString content = readFileContentAndRemoveComments(path);\r\n\r\n\t\t\t\titemsInFilesets.insert(findItemsInFileContent(content, path));\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\treturn itemsInFilesets;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VerilogSourceAnalyzer::findItemsInFileContent()\r\n//-----------------------------------------------------------------------------\r\nQMap<QString, QString> VerilogSourceAnalyzer::findItemsInFileContent(QString const& content,\r\n\tQString const& filePath)\r\n{\r\n\tQMap<QString, QString> itemsInFile;\r\n\r\n\tauto modulesInFile = VerilogSyntax::MODULE_KEY_WORD.globalMatch(content);\r\n\tbool isHeader = modulesInFile.hasNext() == false;\r\n\twhile (modulesInFile.hasNext())\r\n\t{\r\n\t\tauto match = modulesInFile.next();\r\n\t\tQString moduleName = match.captured(1);\r\n\t\titemsInFile.insert(moduleName, filePath);\r\n\t}\r\n\r\n\tif (isHeader)\r\n\t{\r\n\t\titemsInFile.insert(QFileInfo(filePath).fileName(), filePath);\r\n\t}\r\n\r\n\treturn itemsInFile;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VerilogSourceAnalyzer::isOfSupportedFileType()\r\n//-----------------------------------------------------------------------------\r\nbool VerilogSourceAnalyzer::isOfSupportedFileType(QSharedPointer<File> file)\r\n{\r\n\tfor (auto const& filetype : *file->getFileTypes())\r\n\t{\r\n\t\tif (getSupportedFileTypes().contains(filetype.type_))\r\n\t\t{\r\n\t\t\treturn true;\r\n\t\t}\r\n\t}\r\n\r\n\treturn false;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VerilogSourceAnalyzer::findIncludeDependencies()\r\n//-----------------------------------------------------------------------------\r\nQList<FileDependencyDesc> VerilogSourceAnalyzer::findIncludeDependencies(QString const& fileContent,\r\n\tQFileInfo const& sourceFileInfo, QMap<QString, QString> const& itemsInFilesets) const\r\n{\r\n\tQList<FileDependencyDesc> dependencies;\r\n\r\n\tconst QDir sourceAbsoluteDir = sourceFileInfo.absoluteDir();\r\n\r\n\tQStringList includeFiles = findDependencies(fileContent, QRegularExpression(\"`include [\\\"<](.*?)[\\\">]\"));\r\n\tfor (auto const& includeName : includeFiles)\r\n\t{\r\n\t\tQString targetAbsolutePath = itemsInFilesets.value(includeName, includeName);\r\n\t\tQString targetRelativePath = sourceAbsoluteDir.relativeFilePath(targetAbsolutePath);\r\n\r\n\t\tFileDependencyDesc dependency;\r\n\t\tdependency.description = tr(\"Include reference to %1\").arg(includeName); \r\n\t\tdependency.filename =  targetRelativePath;\r\n\t\tdependencies.append(dependency);\r\n\t}\r\n\r\n\treturn dependencies;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VerilogSourceAnalyzer::findDependencies()\r\n//-----------------------------------------------------------------------------\r\nQStringList VerilogSourceAnalyzer::findDependencies(QString const& fileContent,\r\n\tQRegularExpression const& matchPattern) const\r\n{\r\n\tQStringList dependentFiles;\r\n\tauto matches = matchPattern.globalMatch(fileContent);\r\n\twhile (matches.hasNext())\r\n\t{\r\n\t\tauto match = matches.next();\r\n\t\tQString dependencyName = match.captured(1);\r\n\r\n\t\tif (VerilogSyntax::KEYWORDS.contains(dependencyName) == false && \r\n\t\t\tdependentFiles.contains(dependencyName) == false)\r\n\t\t{\r\n\t\t\tdependentFiles.append(dependencyName);\r\n\t\t}\r\n\t}\r\n\r\n\treturn dependentFiles;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VerilogSourceAnalyzer::findInstantiationDependencies()\r\n//-----------------------------------------------------------------------------\r\nQList<FileDependencyDesc>  VerilogSourceAnalyzer::findInstantiationDependencies(QString const& fileContent, \r\n\tQFileInfo const& sourceFileInfo, QMap<QString, QString> const& itemsInFilesets) const\r\n{\r\n\tQStringList instanceFiles = findDependencies(fileContent, \r\n\t\tQRegularExpression(\";\\\\s+([a-zA-Z_][\\\\w$]*)(\\\\s+#[(].*[)])?\\\\s+([a-zA-Z_][\\\\w$]*)\",\r\n\t\tQRegularExpression::DotMatchesEverythingOption | QRegularExpression::InvertedGreedinessOption));\r\n\r\n\tconst QString sourceFileSuffix = \".\" + sourceFileInfo.suffix();\r\n\tconst QDir sourceAbsoluteDir = sourceFileInfo.absoluteDir();\r\n\r\n\tQList<FileDependencyDesc> dependencies;\r\n\tfor (auto const& moduleName : instanceFiles)\r\n\t{\r\n\t\t// Add modules not found in filesets as external dependencies\r\n\t\tauto const& targetAbsolutePath = itemsInFilesets.value(moduleName);\r\n\t\tQString targetRelativePath;\r\n\r\n\t\tif (targetAbsolutePath.isEmpty())\r\n\t\t{\r\n\t\t\ttargetRelativePath = tr(\"%1 (Verilog module)\").arg(moduleName);\r\n\t\t}\r\n\t\telse\r\n\t\t{\r\n\t\t\ttargetRelativePath = sourceAbsoluteDir.relativeFilePath(targetAbsolutePath);\r\n\t\t}\r\n\r\n        FileDependencyDesc dependency;\r\n        dependency.description = tr(\"Submodule instantiation of module %1\").arg(moduleName);\r\n        dependency.filename = targetRelativePath;\r\n        dependencies.append(dependency);\r\n\t}\r\n\r\n\treturn dependencies;\r\n}\r\n"
  },
  {
    "path": "Plugins/VerilogSourceAnalyzer/VerilogSourceAnalyzer.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: VerilogSourceAnalyzer.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Esko Pekkarinen\r\n// Date: 07.04.2015\r\n//\r\n// Description:\r\n// Verilog source file analyzer for finding file dependencies.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef VERILOGSOURCEANALYZER_H\r\n#define VERILOGSOURCEANALYZER_H\r\n\r\n#include \"verilogsourceanalyzer_global.h\"\r\n\r\n#include <KactusAPI/include/ISourceAnalyzerPlugin.h>\r\n#include <IPXACTmodels/Component/File.h>\r\n#include <IPXACTmodels/Component/FileSet.h>\r\n#include <IPXACTmodels/Component/Component.h>\r\n\r\n#include <QDir>\r\n#include <QRegularExpression>\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Verilog source file analyzer for finding file dependencies.\r\n//-----------------------------------------------------------------------------\r\nclass VERILOGSOURCEANALYZER_EXPORT VerilogSourceAnalyzer : public QObject, public ISourceAnalyzerPlugin\r\n{\r\n    Q_OBJECT\r\n    Q_PLUGIN_METADATA(IID \"kactus2.plugins.VerilogSourceAnalyzer\" FILE \"VerilogSourceAnalyzer.json\")\r\n\r\n    Q_INTERFACES(IPlugin)\r\n    Q_INTERFACES(ISourceAnalyzerPlugin)\r\n\r\npublic:\r\n\r\n\t//! The constructor.\r\n\tVerilogSourceAnalyzer();\r\n\r\n\t//! The destructor.\r\n\tvirtual ~VerilogSourceAnalyzer() = default;\r\n\r\n\t// Disable copying.\r\n\tVerilogSourceAnalyzer(VerilogSourceAnalyzer const& rhs) = delete;\r\n\tVerilogSourceAnalyzer& operator=(VerilogSourceAnalyzer const& rhs) = delete;\r\n\r\n    /*!\r\n     *  Returns the name of the plugin.\r\n     */\r\n    virtual QString getName() const;\r\n\r\n    /*!\r\n     *  Returns the version of the plugin.\r\n     */\r\n    virtual QString getVersion() const;\r\n\r\n    /*!\r\n     *  Returns the description of the plugin.\r\n     */\r\n    virtual QString getDescription() const;\r\n\r\n    /*!\r\n     *  Returns the vendor of the plugin.\r\n     */\r\n    virtual QString getVendor() const;\r\n\r\n    /*!\r\n     *  Returns the license of the plugin.\r\n     */\r\n    virtual QString getLicense() const;\r\n\r\n    /*!\r\n     *  Returns the license holder of the plugin.\r\n     */\r\n    virtual QString getLicenseHolder() const;\r\n\r\n    /*!\r\n     *  Returns the settings widget.\r\n     */\r\n    virtual QWidget* getSettingsWidget();\r\n\r\n    /*!\r\n     *  This is used to access the settings modified by function getSettingsWidget().\r\n     */\r\n    virtual PluginSettingsModel* getSettingsModel(){return NULL;}\r\n\r\n\t//! Returns the external program requirements of the plugin.\r\n\t virtual QList<ExternalProgramRequirement> getProgramRequirements();\r\n\r\n    /*!\r\n     *  Returns the list of file types this plugin can run analysis for.\r\n     */\r\n    virtual QStringList getSupportedFileTypes() const;\r\n    \r\n    /*!\r\n     *  Calculates a language-dependent hash for the given file.\r\n     *\r\n     *    @param [in] filename  The name of the file.\r\n     *\r\n     *    @return The hash value for the file.\r\n     *\r\n     *      @remarks Comments and whitespace are ignored and do not affect the hash value.\r\n     */\r\n    virtual QString calculateHash(QString const& filename);\r\n     \r\n    /*!\r\n     *  Begins the analysis for the given component.\r\n     *\r\n     *    @param [in] component      The component.\r\n     *    @param [in] componentPath  The path to the directory where the component is located.\r\n     *\r\n     *      @remarks Any preparations needed for the file dependency analysis should be made here.\r\n     */\r\n    virtual void beginAnalysis(Component const* component, QString const& componentPath);\r\n    \r\n    /*!\r\n     *  Ends the analysis for the given component.\r\n     *\r\n     *    @param [in] component      The component.\r\n     *    @param [in] componentPath  The path to the directory where the component is located.\r\n     *\r\n     *      @remarks Any cleanups needed should be made here.\r\n     */\r\n    virtual void endAnalysis(Component const* component, QString const& componentPath);\r\n    \r\n    /*!\r\n     *  Retrieves all file dependencies the given file has.\r\n     *\r\n     *    @param [in]  component      The component to which the dependency scan is being run.\r\n     *    @param [in]  componentPath  The path to the directory where the component is located.\r\n     *    @param [in]  filename       The name of the file to which the analysis is run.\r\n     *\r\n     *    @return The list of found dependencies.\r\n     */\r\n    virtual QList<FileDependencyDesc> getFileDependencies(Component const* component, \r\n        QString const& componentPath, QString const& filename);\r\n\r\nprivate:\r\n\r\n    /*!\r\n     *  Reads the given file and removes comments and extra whitespace in it.\r\n     *\r\n     *    @param [in] filePath   The file to read.\r\n     *\r\n     *    @return The file content without comments and extra whitespace.\r\n     */\r\n    QString readFileContentAndRemoveComments(QString const& filePath) const;\r\n\r\n    /*!\r\n     *  Finds the absolute path for a given file.\r\n     *\r\n     *    @param [in] filename        The file whose absolute path to find.\r\n     *    @param [in] componentPath   The path to the containing component xml file.\r\n     *\r\n     *    @return Absolute path to filename.\r\n     */\r\n    QString findAbsolutePathFor(QString const& filename, QString const& componentPath) const;\r\n\t\r\n\t/*!\r\n\t *  Finds the items (modules, include files) already available in the file sets.\r\n\t *\r\n\t *    @param [in] component       The component whose file sets to search.\r\n\t *    @param [in] componentPath   The path to the component xml file.\r\n\t *\r\n\t *    @return Found items in filesets where key is the item identifier and value the path to the file.\r\n\t */\r\n\tQMap<QString, QString> findItemsInFilesets(Component const* component, QString const& componentPath);\r\n\r\n\t/*!\r\n\t *  Finds the items (modules, include files) already available in the file content.\r\n\t *\r\n\t *    @param [in] content\t\tThe file content.\r\n\t *    @param [in] filePath\tThe path to the given file.\r\n\t *\r\n\t *    @return Found items in file content where key is the item identifier and value the path to the file.\r\n\t */\r\n\tQMap<QString, QString> findItemsInFileContent(QString const& content, QString const& filePath);\r\n\r\n\t/*!\r\n\t *  Check if the given file is of supported file type.\r\n\t *\r\n\t *    @param [in] file        The file to check.\r\n\t *\r\n\t *    @return True, if the file is of supported type, otherwise false.\r\n\t */\r\n\tbool isOfSupportedFileType(QSharedPointer<File> file);\r\n\r\n\t/*!\r\n    *  Finds the dependencies of a file from include directives.\r\n    *\r\n    *    @param [in] fileContent         The file content to analyze.\r\n\t*    @param [in] sourceFileInfo      The source file (being analyzed) information.\r\n\t*    @param [in] itemsInFilesets     The available items in file sets.\r\n    *\r\n    *    @return The file dependencies for includes.\r\n    */\r\n\tQList<FileDependencyDesc> findIncludeDependencies(QString const& fileContent,\r\n\t\tQFileInfo const& sourceFileInfo, \r\n\t\tQMap<QString, QString> const& itemsInFilesets) const;\r\n\r\n\t/*!\r\n\t*  Finds the dependencies of a file with given pattern.\r\n\t*\r\n\t*    @param [in] fileContent       The file content to analyze.\r\n\t*    @param [in] matchPattern      The pattern for matching dependent items.\r\n\t*\r\n\t*    @return The identifiers for items found with the given pattern.\r\n\t*/\r\n\tQStringList findDependencies(QString const& fileContent, QRegularExpression const& matchPattern) const;\r\n\r\n\t/*!\r\n\t *  Finds the dependencies of a file from module instantiations.\r\n\t *\r\n\t *    @param [in] fileContent         The file content to analyze.\r\n\t *    @param [in] sourceFileInfo      The source file (being analyzed) information.\r\n\t *    @param [in] itemsInFilesets     The available items in file sets.\r\n\t *\r\n\t *    @return The file dependencies for instantiations.\r\n \t*/\r\n\tQList<FileDependencyDesc> findInstantiationDependencies(QString const& fileContent,\r\n\t\tQFileInfo const& sourceFileInfo,\r\n\t\tQMap<QString, QString> const& itemsInFilesets) const;\r\n\r\n};\r\n\r\n#endif // VERILOGSOURCEANALYZER_H\r\n"
  },
  {
    "path": "Plugins/VerilogSourceAnalyzer/VerilogSourceAnalyzer.json",
    "content": "{\r\n\t\"Keys\": [ \"Verilog\" ]\r\n}"
  },
  {
    "path": "Plugins/VerilogSourceAnalyzer/VerilogSourceAnalyzer.pri",
    "content": "# ----------------------------------------------------\r\n# This file is generated by the Qt Visual Studio Add-in.\r\n# ------------------------------------------------------\r\n\r\nHEADERS += ./verilogsourceanalyzer_global.h \\\r\n    ./VerilogSourceAnalyzer.h\r\n\r\nSOURCES += ./VerilogSourceAnalyzer.cpp\r\n"
  },
  {
    "path": "Plugins/VerilogSourceAnalyzer/VerilogSourceAnalyzer.pro",
    "content": "# ----------------------------------------------------\r\n# This file is generated by the Qt Visual Studio Add-in.\r\n# ------------------------------------------------------\r\n\r\nTEMPLATE = lib\r\n\r\nQT += core xml widgets\r\nCONFIG += c++11 plugin\r\n\r\nDEFINES += VERILOGSOURCEANALYZER_LIB\r\n\r\nINCLUDEPATH += ./GeneratedFiles \\\r\n    ./../.. \\\r\n    .\r\n\r\nCONFIG(debug, debug|release) {\r\n    # debug mode\r\n    LIBS += \\\r\n        -L../../executable -lIPXACTmodelsd\r\n\r\n    MOC_DIR += ./GeneratedFiles/Debug\r\n    OBJECTS_DIR += Debug\r\n    TARGET = VerilogSourceAnalyzerd\r\n\r\n} else {\r\n    # release mode \r\n    LIBS += \\\r\n        -L../../executable -lIPXACTmodels\r\n    \r\n    MOC_DIR += ./GeneratedFiles/Release\r\n    OBJECTS_DIR += Release\r\n    TARGET = VerilogSourceAnalyzer\r\n}\r\n\r\nDESTDIR = ../../executable/Plugins\r\n\r\nDEPENDPATH += .\r\nUI_DIR += ./GeneratedFiles\r\nRCC_DIR += ./GeneratedFiles\r\n\r\ninclude(VerilogSourceAnalyzer.pri)\r\n\r\ntarget.path = $$plugin_path\r\nINSTALLS += target\r\n"
  },
  {
    "path": "Plugins/VerilogSourceAnalyzer/VerilogSourceAnalyzer.vcxproj",
    "content": "﻿<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n<Project DefaultTargets=\"Build\" ToolsVersion=\"15.0\" xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">\r\n  <ItemGroup Label=\"ProjectConfigurations\">\r\n    <ProjectConfiguration Include=\"Debug|x64\">\r\n      <Configuration>Debug</Configuration>\r\n      <Platform>x64</Platform>\r\n    </ProjectConfiguration>\r\n    <ProjectConfiguration Include=\"Release|x64\">\r\n      <Configuration>Release</Configuration>\r\n      <Platform>x64</Platform>\r\n    </ProjectConfiguration>\r\n  </ItemGroup>\r\n  <PropertyGroup Label=\"Globals\">\r\n    <ProjectGuid>{537BFE8E-F268-4BED-8CF0-0E5C2A630F0F}</ProjectGuid>\r\n    <Keyword>QtVS_v304</Keyword>\r\n    <WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>\r\n    <QtMsBuild Condition=\"'$(QtMsBuild)'=='' or !Exists('$(QtMsBuild)\\qt.targets')\">$(MSBuildProjectDirectory)\\QtMsBuild</QtMsBuild>\r\n  </PropertyGroup>\r\n  <Import Project=\"$(VCTargetsPath)\\Microsoft.Cpp.Default.props\" />\r\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\" Label=\"Configuration\">\r\n    <ConfigurationType>DynamicLibrary</ConfigurationType>\r\n    <PlatformToolset>v143</PlatformToolset>\r\n  </PropertyGroup>\r\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\" Label=\"Configuration\">\r\n    <ConfigurationType>DynamicLibrary</ConfigurationType>\r\n    <PlatformToolset>v143</PlatformToolset>\r\n  </PropertyGroup>\r\n  <Import Project=\"$(VCTargetsPath)\\Microsoft.Cpp.props\" />\r\n  <Target Name=\"QtMsBuildNotFound\" BeforeTargets=\"CustomBuild;ClCompile\" Condition=\"!Exists('$(QtMsBuild)\\qt.targets') or !Exists('$(QtMsBuild)\\qt.props')\">\r\n    <Message Importance=\"High\" Text=\"QtMsBuild: could not locate qt.targets, qt.props; project may not build correctly.\" />\r\n  </Target>\r\n  <ImportGroup Label=\"ExtensionSettings\">\r\n  </ImportGroup>\r\n  <ImportGroup Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\" Label=\"PropertySheets\">\r\n    <Import Project=\"$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props\" Condition=\"exists('$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props')\" Label=\"LocalAppDataPlatform\" />\r\n  </ImportGroup>\r\n  <ImportGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\" Label=\"PropertySheets\">\r\n    <Import Project=\"$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props\" Condition=\"exists('$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props')\" Label=\"LocalAppDataPlatform\" />\r\n  </ImportGroup>\r\n  <PropertyGroup Label=\"UserMacros\" />\r\n  <ImportGroup Condition=\"Exists('$(QtMsBuild)\\qt_defaults.props')\">\r\n    <Import Project=\"$(QtMsBuild)\\qt_defaults.props\" />\r\n  </ImportGroup>\r\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n    <OutDir>$(SolutionDir)executable\\Plugins\\</OutDir>\r\n  </PropertyGroup>\r\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n    <OutDir>$(SolutionDir)executable\\Plugins\\</OutDir>\r\n  </PropertyGroup>\r\n  <PropertyGroup Label=\"QtSettings\" Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n    <QtInstall>6.2.4</QtInstall>\r\n    <QtModules>core;widgets;xml</QtModules>\r\n  </PropertyGroup>\r\n  <PropertyGroup Label=\"QtSettings\" Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n    <QtInstall>6.2.4</QtInstall>\r\n    <QtModules>core;widgets;xml</QtModules>\r\n  </PropertyGroup>\r\n  <ImportGroup Condition=\"Exists('$(QtMsBuild)\\qt.props')\">\r\n    <Import Project=\"$(QtMsBuild)\\qt.props\" />\r\n  </ImportGroup>\r\n  <PropertyGroup>\r\n    <_ProjectFileVersion>10.0.40219.1</_ProjectFileVersion>\r\n  </PropertyGroup>\r\n  <ItemDefinitionGroup Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n    <ClCompile>\r\n      <PreprocessorDefinitions>UNICODE;WIN32;WIN64;VERILOGSOURCEANALYZER_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>\r\n      <AdditionalIncludeDirectories>.\\GeneratedFiles\\$(ConfigurationName);.\\GeneratedFiles;..\\..\\;.;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\r\n      <Optimization>Disabled</Optimization>\r\n      <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>\r\n      <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>\r\n      <TreatWChar_tAsBuiltInType>true</TreatWChar_tAsBuiltInType>\r\n      <MultiProcessorCompilation>true</MultiProcessorCompilation>\r\n      <LanguageStandard>stdcpp17</LanguageStandard>\r\n      <AdditionalOptions>/Zc:__cplusplus %(AdditionalOptions)</AdditionalOptions>\r\n    </ClCompile>\r\n    <Link>\r\n      <SubSystem>Windows</SubSystem>\r\n      <OutputFile>$(OutDir)\\$(ProjectName).dll</OutputFile>\r\n      <AdditionalLibraryDirectories>..\\..\\executable;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>\r\n      <GenerateDebugInformation>true</GenerateDebugInformation>\r\n      <AdditionalDependencies>IPXACTmodelsd.lib;%(AdditionalDependencies)</AdditionalDependencies>\r\n    </Link>\r\n    <QtMoc>\r\n      <ExecutionDescription>Moc'ing %(Identity)...</ExecutionDescription>\r\n      <DynamicSource>output</DynamicSource>\r\n      <QtMocDir>.\\GeneratedFiles\\$(ConfigurationName)</QtMocDir>\r\n      <QtMocFileName>moc_%(Filename).cpp</QtMocFileName>\r\n    </QtMoc>\r\n  </ItemDefinitionGroup>\r\n  <ItemDefinitionGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n    <ClCompile>\r\n      <PreprocessorDefinitions>UNICODE;WIN32;WIN64;QT_NO_DEBUG;NDEBUG;VERILOGSOURCEANALYZER_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>\r\n      <AdditionalIncludeDirectories>.\\GeneratedFiles\\$(ConfigurationName);.\\GeneratedFiles;..\\..\\;.;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\r\n      <DebugInformationFormat>\r\n      </DebugInformationFormat>\r\n      <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>\r\n      <TreatWChar_tAsBuiltInType>true</TreatWChar_tAsBuiltInType>\r\n      <MultiProcessorCompilation>true</MultiProcessorCompilation>\r\n      <AdditionalOptions>/Zc:__cplusplus %(AdditionalOptions)</AdditionalOptions>\r\n      <LanguageStandard>stdcpp17</LanguageStandard>\r\n    </ClCompile>\r\n    <Link>\r\n      <SubSystem>Windows</SubSystem>\r\n      <OutputFile>$(OutDir)\\$(ProjectName).dll</OutputFile>\r\n      <AdditionalLibraryDirectories>..\\..\\executable;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>\r\n      <GenerateDebugInformation>false</GenerateDebugInformation>\r\n      <AdditionalDependencies>IPXACTmodels.lib;%(AdditionalDependencies)</AdditionalDependencies>\r\n    </Link>\r\n    <QtMoc>\r\n      <ExecutionDescription>Moc'ing %(Identity)...</ExecutionDescription>\r\n      <DynamicSource>output</DynamicSource>\r\n      <QtMocDir>.\\GeneratedFiles\\$(ConfigurationName)</QtMocDir>\r\n      <QtMocFileName>moc_%(Filename).cpp</QtMocFileName>\r\n    </QtMoc>\r\n  </ItemDefinitionGroup>\r\n  <ItemGroup>\r\n    <QtMoc Include=\"VerilogSourceAnalyzer.h\">\r\n    </QtMoc>\r\n    <ClInclude Include=\"verilogsourceanalyzer_global.h\" />\r\n  </ItemGroup>\r\n  <ItemGroup>\r\n    <ClCompile Include=\"VerilogSourceAnalyzer.cpp\" />\r\n  </ItemGroup>\r\n  <Import Project=\"$(VCTargetsPath)\\Microsoft.Cpp.targets\" />\r\n  <ImportGroup Condition=\"Exists('$(QtMsBuild)\\qt.targets')\">\r\n    <Import Project=\"$(QtMsBuild)\\qt.targets\" />\r\n  </ImportGroup>\r\n  <ImportGroup Label=\"ExtensionTargets\">\r\n  </ImportGroup>\r\n  <ProjectExtensions>\r\n    <VisualStudio>\r\n      <UserProperties />\r\n    </VisualStudio>\r\n  </ProjectExtensions>\r\n</Project>"
  },
  {
    "path": "Plugins/VerilogSourceAnalyzer/VerilogSourceAnalyzer.vcxproj.filters",
    "content": "﻿<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n<Project ToolsVersion=\"4.0\" xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">\r\n  <ItemGroup>\r\n    <Filter Include=\"Source Files\">\r\n      <UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>\r\n      <Extensions>cpp;cxx;c;def</Extensions>\r\n    </Filter>\r\n    <Filter Include=\"Header Files\">\r\n      <UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>\r\n      <Extensions>h</Extensions>\r\n    </Filter>\r\n    <Filter Include=\"Form Files\">\r\n      <UniqueIdentifier>{99349809-55BA-4b9d-BF79-8FDBB0286EB3}</UniqueIdentifier>\r\n      <Extensions>ui</Extensions>\r\n    </Filter>\r\n    <Filter Include=\"Resource Files\">\r\n      <UniqueIdentifier>{D9D6E242-F8AF-46E4-B9FD-80ECBC20BA3E}</UniqueIdentifier>\r\n      <Extensions>qrc;*</Extensions>\r\n      <ParseFiles>false</ParseFiles>\r\n    </Filter>\r\n    <Filter Include=\"Generated Files\">\r\n      <UniqueIdentifier>{71ED8ED8-ACB9-4CE9-BBE1-E00B30144E11}</UniqueIdentifier>\r\n      <Extensions>moc;h;cpp</Extensions>\r\n      <SourceControlFiles>False</SourceControlFiles>\r\n    </Filter>\r\n    <Filter Include=\"Generated Files\\Debug\">\r\n      <UniqueIdentifier>{686c820f-a830-422e-b4b1-4ead7088de45}</UniqueIdentifier>\r\n      <Extensions>cpp;moc</Extensions>\r\n      <SourceControlFiles>False</SourceControlFiles>\r\n    </Filter>\r\n    <Filter Include=\"Generated Files\\Release\">\r\n      <UniqueIdentifier>{28f6075c-52b9-4bf1-84e7-33bb8b24a85c}</UniqueIdentifier>\r\n      <Extensions>cpp;moc</Extensions>\r\n      <SourceControlFiles>False</SourceControlFiles>\r\n    </Filter>\r\n  </ItemGroup>\r\n  <ItemGroup>\r\n    <ClInclude Include=\"verilogsourceanalyzer_global.h\">\r\n      <Filter>Header Files</Filter>\r\n    </ClInclude>\r\n  </ItemGroup>\r\n  <ItemGroup>\r\n    \r\n    \r\n    <ClCompile Include=\"VerilogSourceAnalyzer.cpp\">\r\n      <Filter>Source Files</Filter>\r\n    </ClCompile>\r\n  </ItemGroup>\r\n  <ItemGroup>\r\n    <QtMoc Include=\"VerilogSourceAnalyzer.h\">\r\n      <Filter>Header Files</Filter>\r\n    </QtMoc>\r\n  </ItemGroup>\r\n</Project>"
  },
  {
    "path": "Plugins/VerilogSourceAnalyzer/verilogsourceanalyzer_global.h",
    "content": "#ifndef VERILOGSOURCEANALYZER_GLOBAL_H\r\n#define VERILOGSOURCEANALYZER_GLOBAL_H\r\n\r\n#include <QtCore/qglobal.h>\r\n\r\n#ifdef VERILOGSOURCEANALYZER_LIB\r\n# define VERILOGSOURCEANALYZER_EXPORT Q_DECL_EXPORT\r\n#else\r\n# define VERILOGSOURCEANALYZER_EXPORT Q_DECL_IMPORT\r\n#endif\r\n\r\n#endif // VERILOGSOURCEANALYZER_GLOBAL_H\r\n"
  },
  {
    "path": "Plugins/common/CPUDialog/CPUEditor.cpp",
    "content": "﻿//-----------------------------------------------------------------------------\n// File: CPUEditor.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 17.02.2023\n//\n// Description:\n// Editor for CPU details in generators.\n//-----------------------------------------------------------------------------\n\n#include \"CPUEditor.h\"\n\n#include <QVBoxLayout>\n#include <QHeaderView>\n\n//-----------------------------------------------------------------------------\n// Function: CPUEditor::CPUEditor()\n//-----------------------------------------------------------------------------\nCPUEditor::CPUEditor(QWidget *parent):\nQWidget(parent)\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: CPUEditor::setupFolderPath()\n//-----------------------------------------------------------------------------\nvoid CPUEditor::setupFolderPath(QString const& /*newFolderPath*/)\n{\n\n}\n"
  },
  {
    "path": "Plugins/common/CPUDialog/CPUEditor.h",
    "content": "//-----------------------------------------------------------------------------\n// File: CPUEditor.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 17.02.2023\n//\n// Description:\n// Editor for CPU details in generators.\n//-----------------------------------------------------------------------------\n\n#ifndef CPUEDITOR_H\n#define CPUEDITOR_H\n\n#include <QWidget>\n#include <QObject>\n#include <QTableView>\n\n#include <Plugins/common/ConnectivityGraphUtilities.h>\n\nclass CpuRoutesContainer;\nclass LibraryInterface;\nclass Component;\n\n//-----------------------------------------------------------------------------\n//! Editor for CPU details in generators.\n//-----------------------------------------------------------------------------\nclass CPUEditor : public QWidget\n{\n    Q_OBJECT\n\npublic:\n\n    /*!\n     *  The constructor.\n     *\n     *    @param [in] parent  Pointer to the owner of this widget.\n     */\n    CPUEditor(QWidget *parent = 0);\n\n    /*!\n     *  The destructor.\n     */\n    virtual ~CPUEditor() = default;\n\n    /*!\n     *  Setup the selected CPUs.\n     *\n     *    @param [in] library     Interface for accessing the library.\n     *    @param [in] component   Top component of the selected design.\n     *    @param [in] activeView  Active view of the design.\n     */\n    virtual void setupCPUDetails(LibraryInterface* library, QSharedPointer<Component> component, QString const& activeView) = 0;\n\n    /*!\n     *  Get the selected CPUs.\n     *\n     *    @return List of the selected CPUs.\n     */\n    virtual QVector<QSharedPointer<CpuRoutesContainer> > getSelectedCPUs() const = 0;\n\n    //! No copying. No assignment.\n    CPUEditor(const CPUEditor& other) = delete;\n    CPUEditor& operator=(const CPUEditor& other) = delete;\n\npublic slots:\n\n    /*!\n     *  Setup the folder path.\n     *\n     *    @param [in] newFolderPath   The new folder path.\n     */\n    virtual void setupFolderPath(QString const& newFolderPath);\n\nsignals:\n\n    /*!\n     *  Inform of a change in the destination folder path.\n     *\n     *    @param [in] newPath     The new folder path.\n     */\n    void changeInSelectedPath(QString const& newPath);\n\nprivate:\n    \n    //-----------------------------------------------------------------------------\n    // Data.\n    //-----------------------------------------------------------------------------\n};\n\n#endif // CPUEDITOR_H\n"
  },
  {
    "path": "Plugins/common/CPUDialog/CPUSelectionDialog.cpp",
    "content": "﻿//-----------------------------------------------------------------------------\n// File: CPUSelectionDialog.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 21.04.2021\n//\n// Description:\n// Dialog for selecting CPUs from a connectivity graph.\n//-----------------------------------------------------------------------------\n\n#include \"CPUSelectionDialog.h\"\n\n#include <IPXACTmodels/Component/Component.h>\n#include <IPXACTmodels/Component/Cpu.h>\n\n#include <common/widgets/EnumCollectionEditor/EnumCollectionEditor.h>\n\n#include <KactusAPI/include/LibraryInterface.h>\n\n#include <Plugins/common/CpuRoutesContainer.h>\n#include <Plugins/common/CPUDialog/CPUEditor.h>\n\n#include <QDialogButtonBox>\n#include <QPushButton>\n#include <QFormLayout>\n#include <QIcon>\n#include <QFileDialog>\n#include <QHBoxLayout>\n\n//-----------------------------------------------------------------------------\n// Function: CPUSelectionDialog::CPUSelectionDialog()\n//-----------------------------------------------------------------------------\nCPUSelectionDialog::CPUSelectionDialog(QSharedPointer<Component> topComponent, LibraryInterface* library,\n    QStringList const& viewNames, QStringList const& fileSetNames, CPUEditor* cpuEditor,\n    QString const& dialogType, QWidget* extraEditor, QWidget *parent, int minimumWidth,\n    QString const& configurationFolder, bool saveToFileSet, QString const& configurationFileSet,\n    QString const& configurationView):\nQDialog(parent),\nviewSelection_(new QComboBox(this)),\nfileSetSelection_(new QComboBox(this)),\nfileSetBox_(new QGroupBox(\"Add files to file set\")),\nlibrary_(library),\ncomponent_(topComponent),\ngraphFactory_(library),\ncpuDetailEditor_(cpuEditor),\nfolderLine_(new QLineEdit(this)),\nextraEditor_(extraEditor)\n{\n    cpuDetailEditor_->setParent(this);\n    if (extraEditor_)\n    {\n        extraEditor_->setParent(this);\n    }\n\n    setWindowTitle(\"File generation for \" + dialogType);\n\n    QString componentPath = library->getDirectoryPath(topComponent->getVlnv());\n    folderLine_->setText(componentPath);\n    folderLine_->setToolTip(componentPath);\n\n    cpuDetailEditor_->setupFolderPath(componentPath);\n\n    viewSelection_->addItems(viewNames);\n    viewSelection_->setCurrentIndex(0);\n\n    fileSetSelection_->addItem(\"\");\n    fileSetSelection_->addItems(fileSetNames);\n    fileSetSelection_->setEditable(true);\n\n    fileSetBox_->setCheckable(true);\n\n    setupConfiguration(configurationFolder, saveToFileSet, configurationFileSet, configurationView);\n\n    setupLayout();\n\n    setupCPUSelection();\n\n    connect(viewSelection_, SIGNAL(currentIndexChanged(int)), this, SLOT(onViewChanged()), Qt::UniqueConnection);\n\n\tconnect(folderLine_, SIGNAL(textChanged(QString const&)), cpuDetailEditor_, SLOT(setupFolderPath(QString const&)), Qt::UniqueConnection);\n\n    setMinimumWidth(minimumWidth);\n}\n\n//-----------------------------------------------------------------------------\n// Function: CPUSelectionDialog::setupConfiguration()\n//-----------------------------------------------------------------------------\nvoid CPUSelectionDialog::setupConfiguration(QString const& configurationFolder, bool saveToFileSet, QString const& configurationFileSet, QString const& configurationView)\n{\n    if (!configurationFolder.isEmpty())\n    {\n        folderLine_->setText(configurationFolder);\n        emit changeInSelectedPath(configurationFolder);\n    }\n\n    fileSetBox_->setChecked(saveToFileSet);\n    if (!configurationFileSet.isEmpty())\n    {\n        fileSetSelection_->setCurrentText(configurationFileSet);\n    }\n\n    if (!configurationView.isEmpty())\n    {\n        viewSelection_->setCurrentText(configurationView);\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: CPUSelectionDialog::onViewChanged()\n//-----------------------------------------------------------------------------\nvoid CPUSelectionDialog::onViewChanged()\n{\n    setupCPUSelection();\n}\n\n//-----------------------------------------------------------------------------\n// Function: CPUSelectionDialog::setupLayout()\n//-----------------------------------------------------------------------------\nvoid CPUSelectionDialog::setupLayout()\n{\n\tauto viewLabel(new QLabel(\"Select view:\"));\n\n\tauto viewLayout(new QHBoxLayout());\n    viewLayout->addWidget(viewLabel);\n    viewLayout->addWidget(viewSelection_, 1);\n\n\tauto filesetLayout(new QVBoxLayout());\n    filesetLayout->addWidget(fileSetSelection_);\n    fileSetBox_->setLayout(filesetLayout);\n\n\tauto openFolderButton(new QPushButton(QIcon(\":/icons/common/graphics/opened-folder.png\"), QString(), this));\n\n    connect(openFolderButton, SIGNAL(clicked()), this, SLOT(onChangeTargetFolder()), Qt::UniqueConnection);\n\n\tauto folderLayout(new QHBoxLayout());\n    folderLayout->addWidget(folderLine_, 1);\n    folderLayout->addWidget(openFolderButton);\n    folderLayout->setAlignment(Qt::AlignLeft | Qt::AlignTop);\n\n\tauto folderbox(new QGroupBox(\"Select destination folder\"));\n    folderbox->setLayout(folderLayout);\n\n\tauto leftLayout(new QVBoxLayout());\n    leftLayout->addLayout(viewLayout);\n    leftLayout->addWidget(fileSetBox_);\n    leftLayout->addWidget(folderbox);\n\n\tif (extraEditor_ != nullptr)\n    {\n        leftLayout->addWidget(extraEditor_);\n    }\n\n    leftLayout->addStretch(2);\n\n\tauto topLayout(new QHBoxLayout());\n    topLayout->addLayout(leftLayout);\n    topLayout->addWidget(cpuDetailEditor_, 1);\n\n\tauto dialogButtons(new QDialogButtonBox(QDialogButtonBox::Cancel, Qt::Horizontal));\n    QPushButton* writeButton = dialogButtons->addButton(\"Ok\", QDialogButtonBox::AcceptRole);\n    writeButton->setDefault(false);\n    writeButton->setAutoDefault(false);\n\n    connect(dialogButtons, SIGNAL(accepted()), this, SLOT(accept()), Qt::UniqueConnection);\n    connect(dialogButtons, SIGNAL(rejected()), this, SLOT(reject()), Qt::UniqueConnection);\n\n\tauto masterLayout(new QVBoxLayout(this));\n    masterLayout->addLayout(topLayout);\n    masterLayout->addWidget(dialogButtons);\n}\n\n//-----------------------------------------------------------------------------\n// Function: CPUSelectionDialog::setupCPUSelection()\n//-----------------------------------------------------------------------------\nvoid CPUSelectionDialog::setupCPUSelection()\n{\n    QString activeView = viewSelection_->currentText();\n\n    cpuDetailEditor_->setupCPUDetails(library_, component_, activeView);\n}\n\n//-----------------------------------------------------------------------------\n// Function: CPUSelectionDialog::getSelectedCPUs()\n//-----------------------------------------------------------------------------\nQVector<QSharedPointer<CpuRoutesContainer> > CPUSelectionDialog::getSelectedCPUs()\n{\n    return cpuDetailEditor_->getSelectedCPUs();\n}\n\n//-----------------------------------------------------------------------------\n// Function: CPUSelectionDialog::saveToFileSet()\n//-----------------------------------------------------------------------------\nbool CPUSelectionDialog::saveToFileSet() const\n{\n    return fileSetBox_->isChecked();\n}\n\n//-----------------------------------------------------------------------------\n// Function: CPUSelectionDialog::getTargetFileSet()\n//-----------------------------------------------------------------------------\nQString CPUSelectionDialog::getTargetFileSet() const\n{\n    return fileSetSelection_->currentText();\n}\n\n//-----------------------------------------------------------------------------\n// Function: CPUSelectionDialog::getTargetFolder()\n//-----------------------------------------------------------------------------\nQString CPUSelectionDialog::getTargetFolder() const\n{\n    return folderLine_->text();\n}\n\n//-----------------------------------------------------------------------------\n// Function: CPUSelectionDialog::getView()\n//-----------------------------------------------------------------------------\nQString CPUSelectionDialog::getView() const\n{\n    return viewSelection_->currentText();\n}\n\n//-----------------------------------------------------------------------------\n// Function: CPUSelectionDialog::onChangeTargetFolder()\n//-----------------------------------------------------------------------------\nvoid CPUSelectionDialog::onChangeTargetFolder()\n{\n    QString newDir = QFileDialog::getExistingDirectory(this, tr(\"Open Directory\"), folderLine_->text(),\n        QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks);\n\n    folderLine_->setText(newDir);\n    folderLine_->setToolTip(newDir);\n}\n"
  },
  {
    "path": "Plugins/common/CPUDialog/CPUSelectionDialog.h",
    "content": "//-----------------------------------------------------------------------------\n// File: CPUSelectionDialog.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 21.04.2021\n//\n// Description:\n// Dialog for selecting CPUs from a connectivity graph.\n//-----------------------------------------------------------------------------\n\n#ifndef CPUSELECTIONDIALOG_H\n#define CPUSELECTIONDIALOG_H\n\n#include <QDialog>\n#include <QLabel>\n#include <QPlainTextEdit>\n\n#include <QComboBox>\n#include <QCheckBox>\n#include <QGroupBox>\n#include <QVBoxLayout>\n#include <QLineEdit>\n\n#include <Plugins/common/ConnectivityGraphUtilities.h>\n\n#include <editors/MemoryDesigner/ConnectivityGraphFactory.h>\n\nclass Component;\nclass LibraryInterface;\nclass Cpu;\nclass CPUEditor;\nclass CpuRoutesContainer;\n\n#include <QJsonDocument>\n\n//-----------------------------------------------------------------------------\n//! Dialog for selecting CPUs from a connectivity graph.\n//-----------------------------------------------------------------------------\nclass CPUSelectionDialog : public QDialog\n{\n    Q_OBJECT\n\npublic:\n\n\t/*!\n     *  The constructor.\n     *\n\t *    @param [in] topComponent            Top component of the selected design.\n\t *    @param [in] library                 Interface for accessing the library.\n\t *    @param [in] viewsNames              Names of the available views.\n     *    @param [in] fileSetNames            Names of the available file sets.\n     *    @param [in] cpuEditor               Editor for CPU details.\n     *    @param [in] dialogType              The type text for dialog.\n     *    @param [in] extraEditor             An extra editor.\n\t *    @param [in] parent                  Parent widget.\n     *    @param [in] minimumWidth            The minimum width of the dialog.\n     *    @param [in] configurationFolder     Folder path for the generator.\n     *    @param [in] saveToFileSet           Flag for save to file set.\n     *    @param [in] configurationFileSet    Name of the target file set.\n     *    @param [in] configurationView       Name of the view to use in the generator.\n     */\n\tCPUSelectionDialog(QSharedPointer<Component> topComponent,\n        LibraryInterface* library,\n        QStringList const& viewNames,\n        QStringList const& fileSetNames,\n        CPUEditor* cpuEditor,\n        QString const& dialogType,\n        QWidget* extraEditor,\n        QWidget *parent,\n        int minimumWidth = 840,\n        QString const& configurationFolder = \"\",\n        bool saveToFileSet = true,\n        QString const& configurationFileSet = \"\",\n        QString const& configurationView = \"\");\n\n\t/*!\n     *  The destructor.\n     */\n    virtual ~CPUSelectionDialog() = default;\n\n    /*!\n     *  Get the list of the selected CPUs.\n     *\n     *    @return List of the CPU data and their connected paths.\n     */\n    QVector<QSharedPointer<CpuRoutesContainer> > getSelectedCPUs();\n\n    /*!\n     *  Check if the files should be saved to a file set.\n     *\n     *    @return True, if the files should be saved to a file set, false otherwise.\n     */\n    bool saveToFileSet() const;\n\n    /*!\n     *  Get the name of the file set to save the files to.\n     *\n     *    @return Name of the target file set.\n     */\n    QString getTargetFileSet() const;\n\n    /*!\n     *  Get the target folder for the SVD files.\n     *\n     *    @return Path to the target folder of the selected SVD files.\n     */\n    QString getTargetFolder() const;\n\n    /*!\n     *  Get the active view.\n     *\n     *    @return Name of the active view.\n     */\n    QString getView() const;\n\nprivate slots:\n\n    /*!\n     *  Handle the view selection.\n     */\n    void onViewChanged();\n\n    /*!\n     *  Handle the change of target folder.\n     */\n    void onChangeTargetFolder();\n\nsignals:\n\n    /*!\n     *  Signal informing of a change in the destination path.\n     *\n     *    @param [in] newFolderLocation   The new destination.\n     */\n    void changeInSelectedPath(QString const& newFolderLocation);\n\nprivate:\n\n    // Disable copying.\n    CPUSelectionDialog(CPUSelectionDialog const& rhs);\n    CPUSelectionDialog& operator=(CPUSelectionDialog const& rhs);\n\n    /*!\n     *  Setup the dialog.\n     *\n     *    @param [in] configurationFolder     Folder path for the generated files.\n     *    @param [in] saveToFileSet           Flag for saving to a file set.\n     *    @param [in] configurationFileSet    Name of the selected file set.\n     *    @param [in] configurationView       The currently active view.\n     */\n    void setupConfiguration(QString const& configurationFolder, bool saveToFileSet, QString const& configurationFileSet, QString const& configurationView);\n\n    /*!\n     *  Setup the layout.\n     */\n    void setupLayout();\n\n    /*!\n     *  Setup the CPU selection layout.\n     */\n    void setupCPUSelection();\n\n    //-----------------------------------------------------------------------------\n    // Data.\n    //-----------------------------------------------------------------------------\n    \n    //! Widget for selecting view.\n    QComboBox* viewSelection_;\n\n    //! Widget for selecting target file set.\n    QComboBox* fileSetSelection_;\n\n    //! Group box for containing the file set widget.\n    QGroupBox* fileSetBox_;\n\n    //! Interface for accessing the library.\n    LibraryInterface* library_;\n\n    //! Top component of the design.\n    QSharedPointer<Component> component_;\n\n    //! Graph factory for creating the design connections.\n    ConnectivityGraphFactory graphFactory_;\n\n    //! Editor for CPU details.\n    CPUEditor* cpuDetailEditor_;\n\n    //! Editor for folder path.\n    QLineEdit* folderLine_;\n\n    //! An extra editor.\n    QWidget* extraEditor_;\n};\n\n#endif //CPUSELECTIONDIALOG_H"
  },
  {
    "path": "Plugins/common/CSourceWriter.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: CSourceWriter.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Joni-Matti Maatta\r\n// Date: 6.12.2011\r\n//\r\n// Description:\r\n// Text writer for writing C source files.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"CSourceWriter.h\"\r\n\r\n#include <QFileInfo>\r\n#include <QDateTime>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: CSourceWriter::CSourceWriter()\r\n//-----------------------------------------------------------------------------\r\nCSourceWriter::CSourceWriter(QString const& filename, QString const& indentString)\r\n    : indentString_(indentString), indentLevel_(0), file_(filename), stream_()\r\n{\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: CSourceWriter::~CSourceWriter()\r\n//-----------------------------------------------------------------------------\r\nCSourceWriter::~CSourceWriter()\r\n{\r\n    file_.close();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: CSourceWriter::open()\r\n//-----------------------------------------------------------------------------\r\nbool CSourceWriter::open()\r\n{\r\n    // Open the file for writing.\r\n    if (!file_.open(QIODevice::WriteOnly | QIODevice::Text))\r\n    {\r\n        return false;\r\n    }\r\n\r\n    stream_.setDevice(&file_);\r\n\r\n    return true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: CSourceWriter::increaseIndentLevel()\r\n//-----------------------------------------------------------------------------\r\nvoid CSourceWriter::increaseIndentLevel()\r\n{\r\n    ++indentLevel_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: CSourceWriter::decreaseIndentLevel()\r\n//-----------------------------------------------------------------------------\r\nvoid CSourceWriter::decreaseIndentLevel()\r\n{\r\n    if (indentLevel_ > 0)\r\n    {\r\n        --indentLevel_;\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: CSourceWriter::writeFileHeader()\r\n//-----------------------------------------------------------------------------\r\nvoid CSourceWriter::writeFileHeader()\r\n{\r\n\tQDateTime now = QDateTime::currentDateTime();\r\n\r\n\t// Write the file header comment.\r\n\twriteLine(\"/*\");\r\n\twriteLine(\" * File: \" + QFileInfo(file_.fileName()).fileName());\r\n\twriteLine(\" *\");\r\n\twriteLine(\" *  Generated by Kactus2 on \" + now.date().toString(\"yyyy-MM-dd\") + \".\");\r\n\twriteLine(\" */\");\r\n\twriteEmptyLine();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: CSourceWriter::writeLine()\r\n//-----------------------------------------------------------------------------\r\nvoid CSourceWriter::writeLine(QString const& line)\r\n{\r\n    // Write indentation.\r\n    for (unsigned int i = 0; i < indentLevel_; ++i)\r\n    {\r\n        stream_ << indentString_;\r\n    }\r\n\r\n    stream_ << line << Qt::endl;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: CSourceWriter::writeEmptyLine()\r\n//-----------------------------------------------------------------------------\r\nvoid CSourceWriter::writeEmptyLine()\r\n{\r\n    stream_ << Qt::endl;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: CSourceWriter::writeInclude()\r\n//-----------------------------------------------------------------------------\r\nvoid CSourceWriter::writeInclude(QString const& headerName, bool local)\r\n{\r\n    if (local)\r\n    {\r\n        writeLine(\"#include \\\"\" + headerName + \"\\\"\");\r\n    }\r\n    else\r\n    {\r\n        writeLine(\"#include <\" + headerName + \">\");\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: CSourceWriter::beginBlock()\r\n//-----------------------------------------------------------------------------\r\nvoid CSourceWriter::beginBlock()\r\n{\r\n    writeLine(\"{\");\r\n    increaseIndentLevel();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: CSourceWriter::endBlock()\r\n//-----------------------------------------------------------------------------\r\nvoid CSourceWriter::endBlock()\r\n{\r\n    decreaseIndentLevel();\r\n    writeLine(\"}\");\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: CSourceWriter::writeHeaderComment()\r\n//-----------------------------------------------------------------------------\r\nvoid CSourceWriter::writeHeaderComment(QString const& desc)\r\n{\r\n    writeLine(\"//-----------------------------------------------------------------------------\");\r\n    writeLine(\"// \" + desc);\r\n    writeLine(\"//-----------------------------------------------------------------------------\");\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: CSourceWriter::beginStruct()\r\n//-----------------------------------------------------------------------------\r\nvoid CSourceWriter::beginStruct()\r\n{\r\n    writeLine(\"typedef struct\");\r\n    beginBlock();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: CSourceWriter::endStruct()\r\n//-----------------------------------------------------------------------------\r\nvoid CSourceWriter::endStruct(QString const& name)\r\n{\r\n    decreaseIndentLevel();\r\n    writeLine(\"} \" + name + \";\");\r\n}\r\n"
  },
  {
    "path": "Plugins/common/CSourceWriter.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: CSourceWriter.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Joni-Matti Maatta\r\n// Date: 6.12.2011\r\n//\r\n// Description:\r\n// Text writer for writing C source files.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef CSOURCEWRITER_H\r\n#define CSOURCEWRITER_H\r\n\r\n#include <QTextStream>\r\n#include <QFile>\r\n\r\n//-----------------------------------------------------------------------------\r\n//! CSourceWriter class.\r\n//-----------------------------------------------------------------------------\r\nclass CSourceWriter\r\n{\r\npublic:\r\n    /*!\r\n     * Constructor.\r\n     *\r\n     *    @param [in] filename      The name of the destination file.\r\n     *    @param [in] indentString  The indentation string.\r\n     */\r\n    explicit CSourceWriter(QString const& filename, QString const& indentString);\r\n\r\n    /*!\r\n     *  Destructor.\r\n     */\r\n    ~CSourceWriter();\r\n\r\n    /*!\r\n     *  Opens the file for writing.\r\n     *\r\n     *    @return False if errors. Otherwise true.\r\n     */\r\n    bool open();\r\n\r\n    /*!\r\n     *  Increases the indentation level by one.\r\n     */\r\n    void increaseIndentLevel();\r\n\r\n    /*!\r\n     *  Decreases the indentation level by one.\r\n     */\r\n\tvoid decreaseIndentLevel();\r\n\t\r\n    /*!\r\n     *  Writes a header for the file, including date and time.\r\n     */\r\n\tvoid writeFileHeader();\r\n\r\n    /*!\r\n     *  Writes a line to the source file. Newline is automatically written after the line.\r\n     *\r\n     *    @param [in] line The line to write.\r\n     */\r\n    void writeLine(QString const& line);\r\n\r\n    /*!\r\n     *  Writes an empty line to the source file.\r\n     */\r\n    void writeEmptyLine();\r\n\r\n    /*!\r\n     *  Writes a #include to the source file.\r\n     *\r\n     *    @param [in] headerName The name of the header file.\r\n     *    @param [in] local      If true, the header is included with \"\" instead of <>.\r\n     */\r\n    void writeInclude(QString const& headerName, bool local = false);\r\n\r\n    /*!\r\n     *  Begins an indented code block. Increases the indentation level by one.\r\n     */\r\n    void beginBlock();\r\n\r\n    /*!\r\n     *  Ends an indented code block. Decreases the indentation level by one.\r\n     */\r\n    void endBlock();\r\n\r\n    /*!\r\n     *  Begins a structure type definition.\r\n     */\r\n    void beginStruct();\r\n\r\n    /*!\r\n     *  Ends a structure type definition.\r\n     *\r\n     *    @param [in] name The name of the struct.\r\n     */\r\n    void endStruct(QString const& name);\r\n\r\n    /*!\r\n     *  Writes a header block comment.\r\n     *\r\n     *    @param [in] desc The descriptive text.\r\n     */\r\n    void writeHeaderComment(QString const& desc);\r\n\r\nprivate:\r\n    // Disable copying.\r\n    CSourceWriter(CSourceWriter const& rhs);\r\n    CSourceWriter& operator=(CSourceWriter const& rhs);\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! The indentation string.\r\n    QString indentString_;\r\n\r\n    //! The current indentation level.\r\n    unsigned int indentLevel_;\r\n\r\n    //! The file used as the IO device.\r\n    QFile file_;\r\n\r\n    //! The text stream used for writing the file.\r\n    QTextStream stream_;\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n\r\n#endif // CSOURCEWRITER_H\r\n"
  },
  {
    "path": "Plugins/common/ConfigurationManager.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: ConfigurationManager.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 21.04.2023\n//\n// Description:\n// Manager for storing and restoring editor configurations.\n//-----------------------------------------------------------------------------\n\n#include \"ConfigurationManager.h\"\n\n#include <KactusAPI/include/LibraryInterface.h>\n\n#include <IPXACTmodels/Component/Component.h>\n#include <IPXACTmodels/Component/File.h>\n#include <IPXACTmodels/Component/FileSet.h>\n\nnamespace\n{\n    //! Identifier for configuration file set name.\n    const QString CONFIGURATIONFILESETNAME = \"configurations\";\n\n    //! File type for JSON files.\n    const QString JSONFILETYPE = \"json\";\n\n};\n\n//-----------------------------------------------------------------------------\n// Function: ConfigurationManager::ConfigurationManager()\n//-----------------------------------------------------------------------------\nConfigurationManager::ConfigurationManager(LibraryInterface* library) :\nlibrary_(library)\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: ConfigurationManager::getConfigurationDocument()\n//-----------------------------------------------------------------------------\nQJsonDocument ConfigurationManager::getConfigurationDocument(QSharedPointer<Component> component, QString const& fileTypeName)\n{\n    QSharedPointer<FileSet> configurationFileSet = getConfigurationFileSet(component);\n    if (configurationFileSet)\n    {\n        QSharedPointer<File> configurationFileItem = getConfigurationFile(configurationFileSet, fileTypeName);\n        if (configurationFileItem)\n        {\n            QString componentPath = library_->getDirectoryPath(component->getVlnv()) + \"/\";\n            QString configurationFilePath = General::getAbsolutePath(componentPath, configurationFileItem->name());\n\n            QFile configurationFile(configurationFilePath);\n\n            if (!configurationFile.open(QFile::ReadOnly))\n            {\n                printError(\"Could not open configuration file \" + configurationFilePath);\n            }\n            else\n            {\n                QJsonDocument configurationDocument = QJsonDocument::fromJson(configurationFile.readAll());\n                return configurationDocument;\n            }\n        }\n    }\n\n    return QJsonDocument();\n}\n\n//-----------------------------------------------------------------------------\n// Function: ConfigurationManager::getPathToConfigurationFile()\n//-----------------------------------------------------------------------------\nQString ConfigurationManager::getPathToConfigurationFile(QSharedPointer<Component> component, QString const& fileExtension)\n{\n    QSharedPointer<File> configurationFileItem = getOrCreateConfigurationFile(component, fileExtension);\n    QString componentPath = library_->getDirectoryPath(component->getVlnv()) + \"/\";\n    QString configurationFilePath = General::getAbsolutePath(componentPath, configurationFileItem->name());\n\n    return configurationFilePath;\n}\n\n//-----------------------------------------------------------------------------\n// Function: ConfigurationManager::getOrCreateConfigurationFile()\n//-----------------------------------------------------------------------------\nQSharedPointer<File> ConfigurationManager::getOrCreateConfigurationFile(QSharedPointer<Component> containingComponent, QString const& fileTypeName)\n{\n    QSharedPointer<FileSet> configurationFileSet = getOrCreateConfigurationFileSet(containingComponent);\n    QSharedPointer<File> configurationFileItem = getConfigurationFile(configurationFileSet, fileTypeName);\n    if (!configurationFileItem)\n    {\n        QString configurationFileName = containingComponent->getVlnv().getName() + \".\" + containingComponent->getVlnv().getVersion() + \"_\" + fileTypeName + \".\" + JSONFILETYPE;\n\n        configurationFileItem = QSharedPointer<File>(new File(configurationFileName));\n        configurationFileItem->getFileTypes()->append(FileType(JSONFILETYPE));\n\n        configurationFileSet->getFiles()->append(configurationFileItem);\n    }\n\n    return configurationFileItem;\n}\n\n//-----------------------------------------------------------------------------\n// Function: ConfigurationManager::getOrCreateConfigurationFileSet()\n//-----------------------------------------------------------------------------\nQSharedPointer<FileSet> ConfigurationManager::getOrCreateConfigurationFileSet(QSharedPointer<Component> containingComponent)\n{\n    QSharedPointer<FileSet> configurationFileSet = getConfigurationFileSet(containingComponent);\n    if (!configurationFileSet)\n    {\n        configurationFileSet = QSharedPointer<FileSet>(new FileSet(CONFIGURATIONFILESETNAME));\n        containingComponent->getFileSets()->append(configurationFileSet);\n    }\n\n    return configurationFileSet;\n}\n\n//-----------------------------------------------------------------------------\n// Function: ConfigurationManager::getConfigurationFileSet()\n//-----------------------------------------------------------------------------\nQSharedPointer<FileSet> ConfigurationManager::getConfigurationFileSet(QSharedPointer<Component> targetComponent)\n{\n    for (auto fileSet : *targetComponent->getFileSets())\n    {\n        if (fileSet->name() == CONFIGURATIONFILESETNAME)\n        {\n            return fileSet;\n        }\n    }\n\n    return QSharedPointer<FileSet>();\n}\n\n//-----------------------------------------------------------------------------\n// Function: ConfigurationManager::getConfigurationFile()\n//-----------------------------------------------------------------------------\nQSharedPointer<File> ConfigurationManager::getConfigurationFile(QSharedPointer<FileSet> configurationFileSet, QString const& fileType)\n{\n    if (configurationFileSet)\n    {\n        for (auto containedFile : *configurationFileSet->getFiles())\n        {\n            if (containedFile->name().contains(fileType))\n            {\n                return containedFile;\n            }\n        }\n    }\n\n    return QSharedPointer<File>();\n}\n\n//-----------------------------------------------------------------------------\n// Function: ConfigurationManager::getLibrary()\n//-----------------------------------------------------------------------------\nLibraryInterface* ConfigurationManager::getLibrary() const\n{\n    return library_;\n}\n\n//-----------------------------------------------------------------------------\n// Function: ConfigurationManager::writeModelToFile()\n//-----------------------------------------------------------------------------\nvoid ConfigurationManager::writeModelToFile(QSharedPointer<Component> component)\n{\n    library_->writeModelToFile(component);\n}\n"
  },
  {
    "path": "Plugins/common/ConfigurationManager.h",
    "content": "//-----------------------------------------------------------------------------\n// File: ConfigurationManager.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 21.04.2023\n//\n// Description:\n// Manager for storing and restoring editor configurations.\n//-----------------------------------------------------------------------------\n\n#ifndef CONFIGURATIONMANAGER_H\n#define CONFIGURATIONMANAGER_H\n\nclass Component;\nclass LibraryInterface;\nclass FileSet;\nclass File;\n\n#include <QFile>\n#include <QJsonObject>\n#include <QJsonDocument>\n#include <QSharedPointer>\n\n//-----------------------------------------------------------------------------\n//! Manager for storing and restoring editor configurations.\n//-----------------------------------------------------------------------------\nclass ConfigurationManager\n{\n\npublic:\n    \n    /*!\n     *  The constructor.\n     * \n     *    @param [in] library     Interface for accessing the library.\n     */\n    ConfigurationManager(LibraryInterface* library);\n    \n    /*!\n     * The destructor.\n     */\n    ~ConfigurationManager() = default;\n\n    /*!\n     *  Get the configuration document.\n     *\n     *    @param [in] component       The containing component.\n     *    @param [in] fileTypeName    Type of the configuration file.\n     *\n     *    @return The configuration document.\n     */\n    QJsonDocument getConfigurationDocument(QSharedPointer<Component> component, QString const& fileTypeName);\n\nprotected:\n\n    /*!\n     *  Get the path to the selected configuration file.\n     *\n     *    @param [in] component       The top component.\n     *    @param [in] fileExtension   File extension for the selected file.\n     *\n     *    @return The path to the selected configuration file.\n     */\n    QString getPathToConfigurationFile(QSharedPointer<Component> component, QString const& fileExtension);\n\n    /*!\n     *  Get an existing configuration file, or create a new one if one is not found.\n     *\n     *    @param [in] containingComponent     Component containing the selected configuration file.\n     *    @param [in] fileTypeName            Type name for the configuration file.\n     *\n     *    @return The selected configuration file.\n     */\n    QSharedPointer<File> getOrCreateConfigurationFile(QSharedPointer<Component> containingComponent, QString const& fileTypeName);\n\n    /*!\n     *  Get the interface for accessing the library.\n     *\n     *    @return Interface for accessing the library.\n     */\n    LibraryInterface* getLibrary() const;\n\n    /*!\n     *  Write the selected component to the file system.\n     *\n     *    @param [in] component    The selected component.\n     */\n    void writeModelToFile(QSharedPointer<Component> component);\n\nprivate:\n\n    /*!\n     *  Print the selected error.\n     *\n     *    @param [in] errorMessage    The selected error message.\n     */\n    virtual void printError(QString const& errorMessage) const = 0;\n\n    /*!\n     *  Get an existing configuration file set, or create a new one if one is not found.\n     *\n     *    @param [in] containingComponent     Component containing the configuration file set.\n     *\n     *    @return The configuration file set.\n     */\n    QSharedPointer<FileSet> getOrCreateConfigurationFileSet(QSharedPointer<Component> containingComponent);\n\n    /*!\n     *  Get the file set for configurations.\n     *\n     *    @param [in] topComponent    Top level component.\n     *\n     *    @return File set for configurations.\n     */\n    QSharedPointer<FileSet> getConfigurationFileSet(QSharedPointer<Component> targetComponent);\n\n    /*!\n     *  Get the configuration file for the selected file type..\n     *\n     *    @param [in] configurationFileSet    File set for configurations.\n     *    @param [in] fileType                The selected file type.\n     *\n     *    @return Configuration file for the selected file type.\n     */\n    QSharedPointer<File> getConfigurationFile(QSharedPointer<FileSet> configurationFileSet, QString const& fileType);\n\n    //-----------------------------------------------------------------------------\n    // Data.\n    //-----------------------------------------------------------------------------\n\n    //! Interface for accessing the library.\n    LibraryInterface* library_;\n};\n\n#endif // CONFIGURATIONMANAGER_H\n"
  },
  {
    "path": "Plugins/common/ConnectivityGraphUtilities.cpp",
    "content": "﻿//-----------------------------------------------------------------------------\n// File: ConnectivityGraphUtilities.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 22.04.2021\n//\n// Description:\n// Utility functions for connectivity graphs.\n//-----------------------------------------------------------------------------\n\n#include \"ConnectivityGraphUtilities.h\"\n\n#include <KactusAPI/include/IPluginUtility.h>\n\n#include <editors/MemoryDesigner/ConnectivityGraphFactory.h>\n#include <editors/MemoryDesigner/MasterSlavePathSearch.h>\n#include <editors/MemoryDesigner/MemoryItem.h>\n#include <editors/MemoryDesigner/MemoryDesignerConstants.h>\n\nnamespace\n{\n    //-----------------------------------------------------------------------------\n    // Function: ConnectivityGraphUtilities::interfacedCpuExists()\n    //-----------------------------------------------------------------------------\n    bool interfacedCpuExists(QSharedPointer<const ConnectivityInterface> master, QVector<QSharedPointer<SingleCpuRoutesContainer>> cpuList)\n    {\n        for (auto checkInterface : cpuList)\n        {\n            for (auto cpuRoute : checkInterface->getRoutes())\n            {\n                if (cpuRoute->cpuInterface_ == master)\n                {\n                    return true;\n                }\n            }\n        }\n\n        return false;\n    }\n\n    //-----------------------------------------------------------------------------\n    // Function: ConnectivityGraphUtilities::getMatchingCheckInterface()\n    //-----------------------------------------------------------------------------\n    QVector<QSharedPointer<SingleCpuRoutesContainer> > getMatchingCpuContainers(\n        QSharedPointer<const ConnectivityInterface> master, QVector<QSharedPointer<SingleCpuRoutesContainer> > cpuList)\n    {\n        QVector<QSharedPointer<SingleCpuRoutesContainer> > cpuContainer;\n\n        for (auto checkInterface : cpuList)\n        {\n            for (auto cpuRoute : checkInterface->getRoutes())\n            {\n                if (cpuRoute->cpuInterface_ == master && !cpuContainer.contains(checkInterface))\n                {\n                    cpuContainer.append(checkInterface);\n                }\n            }\n        }\n\n        return cpuContainer;\n    }\n\n\n    //-----------------------------------------------------------------------------\n    // Function: ConnectivityGraphUtilities::getRouteForInterface()\n    //-----------------------------------------------------------------------------\n    QSharedPointer<CpuRouteStructs::CpuRoute> getRouteForInterface(QSharedPointer<const ConnectivityInterface> masterInterface, QVector<QSharedPointer<CpuRouteStructs::CpuRoute> > cpuRoutes)\n    {\n        for (auto cpuRouteDetail : cpuRoutes)\n        {\n            if (cpuRouteDetail->cpuInterface_ == masterInterface)\n            {\n                return cpuRouteDetail;\n            }\n        }\n\n        return QSharedPointer<CpuRouteStructs::CpuRoute>();\n    }\n\n    //-----------------------------------------------------------------------------\n    // Function: ConnectivityGraphUtilities::cpuIsConnectedToInterface22()\n    //-----------------------------------------------------------------------------\n    bool cpuIsConnectedToInterface22(QSharedPointer<Cpu> componentCPU, QSharedPointer<const ConnectivityComponent> routeComponent, QSharedPointer<const ConnectivityInterface> routeInterface)\n    {\n        for (auto memory : routeComponent->getMemories())\n        {\n            if (memory->getType() == MemoryDesignerConstants::MEMORYMAP_TYPE && memory->getName() == componentCPU->getMemoryMapReference())\n            {\n                for (auto subMemory : memory->getChildItems())\n                {\n                    if (subMemory->getType() == MemoryDesignerConstants::SUBSPACEMAP_TYPE && subMemory->getInitiatorReference() == routeInterface->getName())\n                    {\n                        return true;\n                    }\n                }\n            }\n        }\n\n        return false;\n    }\n\n    //-----------------------------------------------------------------------------\n    // Function: ConnectivityGraphUtilities::getInterfacedCPUs()\n    //-----------------------------------------------------------------------------\n    QVector<QSharedPointer<Cpu> > getInterfacedCPUs(QSharedPointer<const ConnectivityComponent> routeComponent,\n        QSharedPointer<const Component> containingComponent, QSharedPointer<const ConnectivityInterface> routeInterface)\n    {\n        QVector<QSharedPointer<Cpu> > cpus;\n        if (containingComponent->getRevision() == Document::Revision::Std22)\n        {\n            for (auto componentCPU : *containingComponent->getCpus())\n            {\n                if (cpuIsConnectedToInterface22(componentCPU, routeComponent, routeInterface))\n                {\n                    cpus.append(componentCPU);\n                }\n            }\n        }\n        else\n        {\n            if (auto interfacedMemory = routeInterface->getConnectedMemory(); interfacedMemory && interfacedMemory->getType() == MemoryDesignerConstants::ADDRESSSPACE_TYPE)\n            {\n                QString memoryName = interfacedMemory->getName();\n\n                for (auto componentCPU : *containingComponent->getCpus())\n                {\n                    if (componentCPU->getAddressSpaceRefs().contains(memoryName))\n                    {\n                        cpus.append(componentCPU);\n                    }\n                }\n            }\n        }\n\n        return cpus;\n    }\n\n    //-----------------------------------------------------------------------------\n    // Function: ConnectivityGraphUtilities::getCpuDetailRoute()\n    //-----------------------------------------------------------------------------\n    QSharedPointer<SingleCpuRoutesContainer> getCpuDetailRoute(QString const& cpuText, QVector<QSharedPointer<SingleCpuRoutesContainer>> existingRoutes)\n    {\n        for (auto currentRoute : existingRoutes)\n        {\n            if (currentRoute->getFileID() == cpuText)\n            {\n                return currentRoute;\n            }\n        }\n\n        return QSharedPointer<SingleCpuRoutesContainer>();\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: ConnectivityGraphUtilities::getDefaultCPUs()\n//-----------------------------------------------------------------------------\nQVector<QSharedPointer<SingleCpuRoutesContainer> > ConnectivityGraphUtilities::getDefaultCPUs(LibraryInterface* library, QSharedPointer<Component> component, QString const& viewName)\n{\n    QVector<QSharedPointer<SingleCpuRoutesContainer> > defaultCPUs;\n\n    ConnectivityGraphFactory graphFactory(library);\n    QSharedPointer<ConnectivityGraph> graph = graphFactory.createConnectivityGraph(component, viewName);\n    MasterSlavePathSearch searchAlgorithm;\n    QVector<QVector<QSharedPointer<const ConnectivityInterface>>> masterRoutes =\n        searchAlgorithm.findMasterSlavePaths(graph, true);\n\n    for (auto masterRoute : masterRoutes)\n    {\n        QSharedPointer<const ConnectivityInterface> master = masterRoute.first();\n        if (interfacedCpuExists(master, defaultCPUs))\n        {\n            for (auto checkInterface : getMatchingCpuContainers(master, defaultCPUs))\n            {\n                QSharedPointer<CpuRouteStructs::CpuRoute> cpuRouteDetail = getRouteForInterface(master, checkInterface->getRoutes());\n                if (cpuRouteDetail)\n                {\n                    cpuRouteDetail->routes_.append(masterRoute);\n                }\n                else\n                {\n                    QSharedPointer<CpuRouteStructs::CpuRoute> newRoute(new CpuRouteStructs::CpuRoute());\n                    newRoute->cpuInterface_ = master;\n                    newRoute->routes_.append(masterRoute);\n\n                    checkInterface->addRoute(newRoute);\n                }\n            }\n        }\n        else\n        {\n            QSharedPointer<const ConnectivityComponent> routeComponent = master->getInstance();\n            QSharedPointer<const Component> interfaceComponent = getInterfacedComponent(library, routeComponent);\n            if (interfaceComponent)\n            {\n                for (auto interfaceCPU : getInterfacedCPUs(routeComponent, interfaceComponent, master))\n                {\n                    QString checkBoxText = interfaceCPU->name() + \" [\" + routeComponent->getName() + \"]\";\n\n                    QSharedPointer<SingleCpuRoutesContainer> existingRoute = getCpuDetailRoute(checkBoxText, defaultCPUs);\n                    if (existingRoute)\n                    {\n                        QSharedPointer<CpuRouteStructs::CpuRoute> cpuRouteDetail = getRouteForInterface(master, existingRoute->getRoutes());\n                        if (!cpuRouteDetail)\n                        {\n                            QSharedPointer<CpuRouteStructs::CpuRoute> newRoute(new CpuRouteStructs::CpuRoute());\n                            newRoute->cpuInterface_ = master;\n                            newRoute->routes_.append(masterRoute);\n\n                            existingRoute->addRoute(newRoute);\n                        }\n                    }\n                    else\n                    {\n                        QSharedPointer<SingleCpuRoutesContainer> cpuInterface(new SingleCpuRoutesContainer(interfaceCPU));\n                        cpuInterface->setFileName(checkBoxText);\n                        cpuInterface->setFileID(checkBoxText);\n\n                        QSharedPointer<CpuRouteStructs::CpuRoute> newRoute(new CpuRouteStructs::CpuRoute());\n                        newRoute->cpuInterface_ = master;\n                        newRoute->routes_.append(masterRoute);\n\n                        cpuInterface->addRoute(newRoute);\n\n                        cpuInterface->setCreateFileFlag(true);\n\n                        defaultCPUs.append(cpuInterface);\n                    }\n                }\n            }\n        }\n    }\n\n    return defaultCPUs;\n}\n\n//-----------------------------------------------------------------------------\n// Function: ConnectivityGraphUtilities::getInterfacedComponent()\n//-----------------------------------------------------------------------------\nQSharedPointer<const Component> ConnectivityGraphUtilities::getInterfacedComponent(LibraryInterface* library, QSharedPointer<const ConnectivityComponent> masterComponent)\n{\n    QSharedPointer<const Component> interfaceComponent;\n\n    if (masterComponent)\n    {\n        QStringList vlnvList = masterComponent->getVlnv().split(\":\");\n        if (vlnvList.size() == 4)\n        {\n            VLNV componentVLNV(VLNV::COMPONENT, vlnvList.at(0), vlnvList.at(1), vlnvList.at(2), vlnvList.at(3));\n            QSharedPointer<const Document> vlnvDocument = library->getModelReadOnly(componentVLNV);\n            if (vlnvDocument)\n            {\n                interfaceComponent = vlnvDocument.dynamicCast<const Component>();\n            }\n        }\n    }\n\n    return interfaceComponent;\n}\n\n//-----------------------------------------------------------------------------\n// Function: ConnectivityGraphUtilities::getDesignView()\n//-----------------------------------------------------------------------------\nQString ConnectivityGraphUtilities::getDesignViewName(\n    QSharedPointer<Component> mainComponent,\n    QSharedPointer<Design> availableDesign /*= nullptr*/,\n    QSharedPointer<DesignConfiguration> availableDesignConfiguration /*= nullptr*/)\n{\n    QString designViewName = \"\";\n    if (!availableDesign)\n    {\n        return designViewName;\n    }\n\n    QList<QSharedPointer<View> > availableViews;\n\n\tfor (auto view : *mainComponent->getViews())\n\t{\n\t\tif (QSharedPointer<DesignInstantiation> viewDesignInstantiation =\n\t\t\tmainComponent->getModel()->findDesignInstantiation(view->getDesignInstantiationRef());\n\t\t\tviewDesignInstantiation && *viewDesignInstantiation->getDesignReference() != availableDesign->getVlnv())\n\t\t{\n\t\t\tcontinue;\n\t\t}\n\n\t\tQSharedPointer<DesignConfigurationInstantiation> viewDesignConfigInstantiation =\n            mainComponent->getModel()->findDesignConfigurationInstantiation(view->getDesignConfigurationInstantiationRef());\n\t\tif (!availableDesignConfiguration && viewDesignConfigInstantiation)\n\t\t{\n\t\t\tcontinue;\n\t\t}\n\n\t\tif ((availableDesignConfiguration && !viewDesignConfigInstantiation) ||\n\t\t\t(viewDesignConfigInstantiation && *viewDesignConfigInstantiation->getDesignConfigurationReference() != availableDesignConfiguration->getVlnv()))\n\t\t{\n\t\t\tcontinue;\n\t\t}\n\n\t\t// If above conditions are satisfied, the view may be used for generation.\n\t\tavailableViews.append(view);\n\t}\n\n    if (availableViews.size() > 0)\n    {\n\t\tdesignViewName = availableViews.first()->name();\n    }\n\n    return designViewName;\n}\n"
  },
  {
    "path": "Plugins/common/ConnectivityGraphUtilities.h",
    "content": "//-----------------------------------------------------------------------------\n// File: ConnectivityGraphUtilities.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 22.04.2021\n//\n// Description:\n// Utility functions for connectivity graphs.\n//-----------------------------------------------------------------------------\n\n#ifndef CONNECTIVITYGRAPHUTILITIES_H\n#define CONNECTIVITYGRAPHUTILITIES_H\n\n#include <IPXACTmodels/Component/Component.h>\n#include <IPXACTmodels/Component/Cpu.h>\n#include <IPXACTmodels/Design/Design.h>\n#include <IPXACTmodels/DesignConfiguration/DesignConfiguration.h>\n\n#include <editors/MemoryDesigner/ConnectivityInterface.h>\n#include <editors/MemoryDesigner/ConnectivityComponent.h>\n\n#include <Plugins/common/SingleCpuRoutesContainer.h>\n\n#include <KactusAPI/include/LibraryInterface.h>\n\nclass Cpu;\nclass IPluginUtility;\n\n//-----------------------------------------------------------------------------\n//! Utility functions for connectivity graphs.\n//-----------------------------------------------------------------------------\nnamespace ConnectivityGraphUtilities\n{\n    const QString REVISION_FORMAT = \"rNpM(N, M = [0 - 99])\";\n\n    /*!\n     *  Get the component contained within the connectivity component.\n     *\n     *    @param [in] library             Interface for accessing the library.\n     *    @param [in] masterComponent     The connectivity component.\n     *\n     *    @return Component contained within the connectivity component.\n     */\n    QSharedPointer<const Component> getInterfacedComponent(LibraryInterface* library,\n        QSharedPointer<const ConnectivityComponent> masterComponent);\n\n    /*!\n     *  Get the CPUs of the selected component.\n     *\n     *    @param [in] library     The library interface containing the selected component.\n     *    @param [in] component   The selected component.\n     *    @param [in] viewName    Name of the selected view.\n     *\n     *    @return List of the component CPU routes.\n     */\n    QVector<QSharedPointer<SingleCpuRoutesContainer> > getDefaultCPUs(LibraryInterface* library, QSharedPointer<Component> component, QString const& viewName);\n\n    /*!\n     *  Get the name of the design view.\n     *\n     *    @param [in] mainComponent                 The selected component.\n     *    @param [in] availableDesign               The selected design.\n     *    @param [in] availableDesignConfiguration  The selected design configuration.\n     *\n     *    @return Name of the component view that uses the selected design and design configuration.\n     */\n    QString getDesignViewName(QSharedPointer<Component> mainComponent,\n        QSharedPointer<Design> availableDesign = nullptr,\n        QSharedPointer<DesignConfiguration> availableDesignConfiguration = nullptr);\n};\n\n#endif //CONNECTIVITYGRAPHUTILITIES_H"
  },
  {
    "path": "Plugins/common/CpuRoutesContainer.cpp",
    "content": "﻿//-----------------------------------------------------------------------------\n// File: CpuRoutesContainer.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 24.02.2023\n//\n// Description:\n// Container for routes connected to a master interface.\n//-----------------------------------------------------------------------------\n\n#include \"CpuRoutesContainer.h\"\n\n//-----------------------------------------------------------------------------\n// Function: CpuRoutesContainer::CpuRoutesContainer()\n//-----------------------------------------------------------------------------\nCpuRoutesContainer::CpuRoutesContainer():\nfileName_(),\nfileID_(),\ncreateFile_(false),\nrouteContainers_()\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: CpuRoutesContainer::CpuRoutesContainer()\n//-----------------------------------------------------------------------------\nCpuRoutesContainer::CpuRoutesContainer(const CpuRoutesContainer& other) :\nfileName_(other.getFileName()),\nfileID_(other.getFileID()),\ncreateFile_(other.shouldCreateFile()),\nrouteContainers_()\n{\n    for (auto route : other.getRoutes())\n    {\n        QSharedPointer<CpuRouteStructs::CpuRoute> newRoute(new CpuRouteStructs::CpuRoute());\n        newRoute->cpuInterface_ = route->cpuInterface_;\n        newRoute->routes_ = route->routes_;\n\n        routeContainers_.append(newRoute);\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: CpuRoutesContainer::getFileName()\n//-----------------------------------------------------------------------------\nQString CpuRoutesContainer::getFileName() const\n{\n    return fileName_;\n}\n\n//-----------------------------------------------------------------------------\n// Function: CpuRoutesContainer::setFileName()\n//-----------------------------------------------------------------------------\nvoid CpuRoutesContainer::setFileName(QString const& newName)\n{\n    fileName_ = newName;\n}\n\n//-----------------------------------------------------------------------------\n// Function: CpuRoutesContainer::getFileID()\n//-----------------------------------------------------------------------------\nQString CpuRoutesContainer::getFileID() const\n{\n    return fileID_;\n}\n\n//-----------------------------------------------------------------------------\n// Function: CpuRoutesContainer::setCPUID()\n//-----------------------------------------------------------------------------\nvoid CpuRoutesContainer::setFileID(QString const& newID)\n{\n    fileID_ = newID;\n}\n\n//-----------------------------------------------------------------------------\n// Function: CpuRoutesContainer::shouldCreateFile()\n//-----------------------------------------------------------------------------\nbool CpuRoutesContainer::shouldCreateFile() const\n{\n    return createFile_;\n}\n\n//-----------------------------------------------------------------------------\n// Function: CpuRoutesContainer::setCreateFileFlag()\n//-----------------------------------------------------------------------------\nvoid CpuRoutesContainer::setCreateFileFlag(bool newFlag)\n{\n    createFile_ = newFlag;\n}\n\n//-----------------------------------------------------------------------------\n// Function: CpuRoutesContainer::getRoutes()\n//-----------------------------------------------------------------------------\nQVector <QSharedPointer<CpuRouteStructs::CpuRoute> > CpuRoutesContainer::getRoutes() const\n{\n    return routeContainers_;\n}\n\n//-----------------------------------------------------------------------------\n// Function: CpuRoutesContainer::setRoutes()\n//-----------------------------------------------------------------------------\nvoid CpuRoutesContainer::setRoutes(QVector <QSharedPointer<CpuRouteStructs::CpuRoute> > newRoutes)\n{\n    routeContainers_ = newRoutes;\n}\n\n//-----------------------------------------------------------------------------\n// Function: CpuRoutesContainer::addRoute()\n//-----------------------------------------------------------------------------\nvoid CpuRoutesContainer::addRoute(QSharedPointer<CpuRouteStructs::CpuRoute> newRoute)\n{\n    routeContainers_.append(newRoute);\n}\n"
  },
  {
    "path": "Plugins/common/CpuRoutesContainer.h",
    "content": "//-----------------------------------------------------------------------------\n// File: CpuRoutesContainer.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 24.02.2023\n//\n// Description:\n// Container for routes connected to a master interface.\n//-----------------------------------------------------------------------------\n\n#ifndef CPUROUTESCONTAINER_H\n#define CPUROUTESCONTAINER_H\n\n#include <editors/MemoryDesigner/ConnectivityInterface.h>\n\n#include <QString>\n#include <QSharedPointer>\n\nclass Cpu;\n\n//! CPU route utilities.\nnamespace CpuRouteStructs\n{\n    //! Container for CPU route details.\n    struct CpuRoute\n    {\n        //! Interface containing the CPU.\n        QSharedPointer<const ConnectivityInterface> cpuInterface_;\n\n        //! Routes connected to the master cpu interface.\n        QVector<QVector<QSharedPointer<const ConnectivityInterface> > > routes_;\n    };\n};\n\n//-----------------------------------------------------------------------------\n//! Container for routes connected to a master interface.\n//-----------------------------------------------------------------------------\nclass CpuRoutesContainer\n{\n\npublic:\n\n    /*!\n     *  The constructor.\n     */\n    CpuRoutesContainer();\n\n    /*!\n     *  The destructor.\n     */\n    virtual ~CpuRoutesContainer() = default;\n\n    /*!\n     *  Copy constructor.\n     */\n    CpuRoutesContainer(const CpuRoutesContainer& other);\n\n    /*!\n     *  Get the name.\n     *\n     *    @return Name of the CPU.\n     */\n    QString getFileName() const;\n\n    /*!\n     *  Set a new name.\n     *\n     *    @param [in] newName     The new name for the CPU.\n     */\n    void setFileName(QString const& newName);\n\n    /*!\n     *  Get the ID.\n     *\n     *    @return ID of the CPU.\n     */\n    QString getFileID() const;\n\n    /*!\n     *  Set a new ID.\n     *\n     *    @param [in] newID   The new ID.\n     */\n    void setFileID(QString const& newID);\n\n    /*!\n     *  Flag for creating a file from this CPU.\n     *\n     *    @return True, if a file should be created, false otherwise.\n     */\n    bool shouldCreateFile() const;\n\n    /*!\n     *  Set the flag fro creating a file from this CPU.\n     *\n     *    @param [in] newFlag     The new flag.\n     */\n    void setCreateFileFlag(bool newFlag);\n\n    /*!\n     *  Get a list of the interface routes connected to this CPU.\n     *\n     *    @return List of interface routes connected to this CPU.\n     */\n    QVector <QSharedPointer<CpuRouteStructs::CpuRoute> > getRoutes() const;\n\n    /*!\n     *  Set new interface routes.\n     *\n     *    @param [in] newRoutes   The selected interface routes.\n     */\n    virtual void setRoutes(QVector <QSharedPointer<CpuRouteStructs::CpuRoute> > newRoutes);\n\n    /*!\n     *  Add a new CPU route.\n     *\n     *    @param [in] newRoute    The selected interface route.\n     */\n    virtual void addRoute(QSharedPointer<CpuRouteStructs::CpuRoute> newRoute);\n\nprivate:\n\n    // Disable copying.\n    CpuRoutesContainer& operator=(CpuRoutesContainer const& rhs);\n\n    //-----------------------------------------------------------------------------\n    // Data.\n    //-----------------------------------------------------------------------------\n\n    //! Name of the container.\n    QString fileName_;\n\n    //! ID of the CPU.\n    QString fileID_;\n\n    //! Flag for creating an SVD file.\n    bool createFile_;\n\n    //! Routes connected to the CPU interface.\n    QVector<QSharedPointer<CpuRouteStructs::CpuRoute> > routeContainers_;\n};\n\n#endif // CPUROUTESCONTAINER_H"
  },
  {
    "path": "Plugins/common/HDLParser/HDLCommandLineParser.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: HDLCommandLineParser.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Esko Pekkarinen\n// Date: 07.05.2018\n//\n// Description:\n// Generic command-line argument parser for HDL generators.\n//-----------------------------------------------------------------------------\n\n#include \"HDLCommandLineParser.h\"\n\n#include <QStringList>\n\n//-----------------------------------------------------------------------------\n// Function: HDLCommandLineParser::HDLCommandLineParser()\n//-----------------------------------------------------------------------------\nHDLCommandLineParser::HDLCommandLineParser(QString const& command): command_(command)\n{\n    addHelpOption();\n\n    QCommandLineOption targetComponent(QStringList() << QStringLiteral(\"c\") << QStringLiteral(\"top-component\"), \n        QStringLiteral(\"The top-component VLNV separated by semicolons (:).\"), QStringLiteral(\"VLVN\"));\n\n    QCommandLineOption targetView(QStringList() << QStringLiteral(\"w\") << QStringLiteral(\"target-view\"), \n        QStringLiteral(\"The component view to use in generation.\"), QStringLiteral(\"view name\"));\n\n    QCommandLineOption outputDirectory(QStringList() << QStringLiteral(\"o\") << QStringLiteral(\"output\"), \n        QStringLiteral(\"The output directory for generation.\"), QStringLiteral(\"path\"), \n        QStringLiteral(\"generated_vhdl\"));\n\n    addOption(targetComponent);\n    addOption(targetView);\n    addOption(outputDirectory);\n}\n\n//-----------------------------------------------------------------------------\n// Function: HDLCommandLineParser::~HDLCommandLineParser()\n//-----------------------------------------------------------------------------\nHDLCommandLineParser::~HDLCommandLineParser()\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: HDLCommandLineParser::parseArguments()\n//-----------------------------------------------------------------------------\nHDLCommandLineParser::ParseResults HDLCommandLineParser::parseArguments(QStringList const& arguments)\n{\n    bool validArguments = parse(arguments);\n\n    ParseResults result;\n    result.vlnv = VLNV(VLNV::COMPONENT, value(\"c\"));\n    result.viewName = value(\"w\");\n    result.path = value(\"o\");\n    result.cancelRun = !validArguments;\n\n    if (isSet(QStringLiteral(\"help\")))\n    {\n        result.message = helpText();\n        result.message.replace(0, result.message.indexOf(QLatin1Char('[')), \n            QString(\"Usage: Kactus2 %1 \").arg(command_));\n\n        result.cancelRun = true;\n    }\n\n    return result;\n}\n"
  },
  {
    "path": "Plugins/common/HDLParser/HDLCommandLineParser.h",
    "content": "//-----------------------------------------------------------------------------\n// File: HDLCommandLineParser.h\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Esko Pekkarinen\n// Date: 07.05.2018\n//\n// Description:\n// Generic command-line argument parser for HDL generators.\n//-----------------------------------------------------------------------------\n\n#ifndef HDLCOMMANDLINEPARSER_H\n#define HDLCOMMANDLINEPARSER_H\n\n#include <IPXACTmodels/common/VLNV.h>\n\n#include <QCommandLineParser>\n\n//-----------------------------------------------------------------------------\n//! Generic command-line argument parser for HDL generators.\n//-----------------------------------------------------------------------------\nclass HDLCommandLineParser : public QCommandLineParser\n{\npublic:\n\n    /*!\n     *  The constructor.\n     *\n     *    @param [in] command   The command used to run the generator for the parser.\n     *\n     *    @return <Description>.\n     */\n    HDLCommandLineParser(QString const& command);\n\n    //! The destructor.\n    virtual ~HDLCommandLineParser();\n\n    //! Store parser results into a single structure.\n    struct ParseResults\n    {\n        VLNV vlnv;          //<! The parsed VLVN.\n        QString viewName;   //<! The parsed view name;\n        QString path;       //<! The parsed output path.\n\n        bool cancelRun;     //<! Flag for canceling the generator run e.g. for showing help or illegal options.\n        QString message;    //<! The message to show for cancel reason.\n    };\n\n    /*!\n     *  Parse the given arguments.\n     *\n     *    @param [in] arguments   The arguments to parse.\n     *\n     *    @return Collection of parse results.\n     */\n    ParseResults parseArguments(QStringList const& arguments);\n\nprivate:\n\n    // Disable copying.\n    HDLCommandLineParser(HDLCommandLineParser const& rhs);\n    HDLCommandLineParser& operator=(HDLCommandLineParser const& rhs);\n\n    // The command used to run the generator for the parser.\n    QString command_;\n};\n\n#endif // HDLCOMMANDLINEPARSER_H\n\n"
  },
  {
    "path": "Plugins/common/HDLParser/HDLParserCommon.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: HDLParserCommon.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Janne Virtanen\r\n// Date: 06.07.2016\r\n//\r\n// Description:\r\n// The structures utilized as intermediate storage for data for HDL generation.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef HDLPARSERCOMMON_H\r\n#define HDLPARSERCOMMON_H\r\n\r\n#include <QSharedPointer>\r\n#include <QString>\r\n\r\n#include <QMap>\r\n#include <QMultiMap>\r\n\r\nclass AbstractionType;\r\nclass AbstractionDefinition;\r\nclass BusInterface;\r\nclass Component;\r\nclass ComponentInstance;\r\nclass ComponentInstantiation;\r\nclass Design;\r\nclass DesignConfiguration;\r\nclass MessageMediator;\r\nclass Port;\r\nclass RemapState;\r\nclass View;\r\n\r\nstruct GenerationTuple\r\n{\r\n    // The component for which the generator is run. If design is not null, component\r\n    // will refer to design or designConfiguration.\r\n    QSharedPointer<Component> component;\r\n    // The design, if the generator is ran for a design.\r\n    QSharedPointer<Design> design;\r\n    // The design configuration for design, if it is not null.\r\n    QSharedPointer<DesignConfiguration> designConfiguration;\r\n    // The messages.\r\n    MessageMediator* messages;\r\n};\r\n\r\nstruct MetaPort;\r\n\r\nstruct MetaWire\r\n{\r\n    //! The bounds of the wire.\r\n    QPair<QString,QString> bounds_;\r\n    //! The array bounds of the wire.\r\n    QPair<QString, QString> arrayBounds_;\r\n    //! The name of the wire, to tell it apart from other wires of the same interconnection.\r\n    QString name_;\r\n    //! The hierarchical ports that are assigned to the wire.\r\n    QList<QSharedPointer<MetaPort> > hierPorts_;\r\n    //! How many times to the wire is referred by a port assignment.\r\n    int refCount;\r\n};\r\n\r\nstruct MetaTransactional\r\n{\r\n    //! Name of the transactional.\r\n    QString name_;\r\n\r\n    //! Hierarchical ports that are assigned to the transactional.\r\n    QList<QSharedPointer<MetaPort> > hierPorts_;\r\n\r\n    //! Number of times this transactional has been assigned to a port.\r\n    int refCount_;\r\n};\r\n\r\nstruct MetaInterface;\r\n\r\nstruct MetaPortAssignment\r\n{\r\n    //! The interface in which this mapping is made.\r\n    QSharedPointer<MetaInterface> mappedInterface_;\r\n    //! The physical bounds of the assignment.\r\n    QPair<QString,QString> physicalBounds_;\r\n    //! The logical bounds of the assignment.\r\n    QPair<QString,QString> logicalBounds_;\r\n    //! The wire of interconnection where port is assigned. Is null if there is none.\r\n    QSharedPointer<MetaWire> wire_;\r\n    //! Interconnection transactional where the port is assigned. Null if not assigned.\r\n    QSharedPointer<MetaTransactional> transactional_;\r\n    //! The assigned and parsed default value: Either a tie-off or the abstraction definition default.\r\n    QString defaultValue_;\r\n    //! Flag for inverting the signal.\r\n    bool invert_;\r\n};\r\n\r\nstruct MetaPort\r\n{\r\n    //! The matching IP-XACT port.\r\n    QSharedPointer<Port> port_;\r\n    //! The parsed vector bounds for the port. For wires.\r\n    QPair<QString,QString> vectorBounds_;\r\n    //! Port width. For transactional.\r\n    QString width_;\r\n    //! The parsed array bounds for the port.\r\n    QPair<QString,QString> arrayBounds_;\r\n    //! The parsed default value for port.\r\n    QString defaultValue_;\r\n    //! The parsed assignments for port that go upper level in hierarchy.\r\n    QMultiMap<QString, QSharedPointer<MetaPortAssignment> > upAssignments_;\r\n    //! The parsed assignments for port that go lower level in hierarchy.\r\n    QMultiMap<QString, QSharedPointer<MetaPortAssignment> > downAssignments_;\r\n    //! Flag for wire ports.\r\n    bool isWire_;\r\n    //! Flag for transactional ports.\r\n    bool isTransactional_;\r\n};\r\n\r\nstruct MetaInterconnection\r\n{\r\n    //! The name of the interconnection, to tell it apart from other interconnections of the design.\r\n    QString name_;\r\n    //! The wires for the logical wires in interconnections.\r\n    QMap<QString, QSharedPointer<MetaWire> > wires_;\r\n    //! The transactionals.\r\n    QMap<QString, QSharedPointer<MetaTransactional> > transactionals_;\r\n    //! The hierarchical interfaces that are assigned to the interconection.\r\n    QList<QSharedPointer<MetaInterface> > hierIfs_;\r\n};\r\n\r\nstruct MetaInterface\r\n{\r\n    //! The matching IP-XACT interface.\r\n    QSharedPointer<BusInterface> interface_;\r\n    //! The used abstraction type.\r\n    QSharedPointer<AbstractionType> absType_;\r\n    //! The abstraction definition of the abstraction type.\r\n    QSharedPointer<AbstractionDefinition> absDef_;\r\n    //! The parsed ports of the component keyed with its physical name.\r\n    QMap<QString, QSharedPointer<MetaPort> > ports_;\r\n    //! The interconnection attached to the interface go upper level in hierarchy.\r\n    QSharedPointer<MetaInterconnection> upInterconnection_;\r\n    //! The interconnection attached to the interface go lower level in hierarchy.\r\n    QSharedPointer<MetaInterconnection> downInterconnection_;\r\n};\r\n\r\nstruct FormattedRemapState\r\n{\r\n    //! Ports and their formatted values that are to be used as the condition for using the remap.\r\n    QList<QSharedPointer<QPair<QSharedPointer<Port>, QString> > > ports_;\r\n    //! The matching IP-XACT remap state.\r\n    QSharedPointer<RemapState> state_;\r\n};\r\n\r\n#endif // HDLPARSERCOMMON_H\r\n"
  },
  {
    "path": "Plugins/common/HDLParser/MetaComponent.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: MetaComponent.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Janne Virtanen\r\n// Date: 03.02.2017\r\n//\r\n// Description:\r\n// Class used to parse relevant information from IP-XACT component for HDL generation.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"MetaComponent.h\"\r\n\r\n#include <KactusAPI/include/MessageMediator.h>\r\n\r\n#include <IPXACTmodels/utilities/Search.h>\r\n\r\n#include <IPXACTmodels/Component/RemapState.h>\r\n#include <IPXACTmodels/Component/RemapPort.h>\r\n\r\n#include <KactusAPI/include/ComponentParameterFinder.h>\r\n#include <KactusAPI/include/MultipleParameterFinder.h>\r\n#include <KactusAPI/include/ListParameterFinder.h>\r\n#include <KactusAPI/include/ExpressionFormatter.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MetaComponent::MetaComponent\r\n//-----------------------------------------------------------------------------\r\nMetaComponent::MetaComponent(MessageMediator* messages,\r\n    QSharedPointer<Component> component,\r\n    QSharedPointer<View> activeView) :\r\n    messages_(messages),\r\n    component_(component),\r\n    activeView_(activeView),\r\n    parameters_(new QList<QSharedPointer<Parameter> >()),\r\n    moduleParameters_(new QList<QSharedPointer<Parameter> >()),\r\n    metaParameters_(new QList<QSharedPointer<Parameter> >()),\r\n    ports_(new QMap<QString,QSharedPointer<MetaPort> >()),\r\n    fileSets_(new QList<QSharedPointer<FileSet> >()),\r\n    moduleName_(),\r\n    activeInstantiation_(),\r\n    remapStates_(new QList<QSharedPointer<FormattedRemapState> >())\r\n{\r\n    // Try to find a component instantiation for the view.\r\n    if (activeView_)\r\n    {\r\n        activeInstantiation_ = Search::findByName(activeView_->getComponentInstantiationRef(),\r\n            *component_->getComponentInstantiations());\r\n\r\n        if (activeInstantiation_)\r\n        {\r\n            // If there is a named component instantiation, its module name shall be used.\r\n            moduleName_ = activeInstantiation_->getModuleName();\r\n            parsesFileSets();\r\n        }\r\n    }\r\n\r\n    if (moduleName_.isEmpty())\r\n    {\r\n        // If no module name is set, take the name from the VLNV of the component.\r\n        moduleName_ = component_->getVlnv().getName();\r\n    }\r\n\r\n    // Must parse the parameters before can use them!\r\n    parseParameters();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function:  MetaComponent::formatComponent()\r\n//-----------------------------------------------------------------------------\r\nvoid MetaComponent::formatComponent()\r\n{\r\n    // Initialize the parameter finders.\r\n    QSharedPointer<MultipleParameterFinder> parameterFinder(new MultipleParameterFinder());\r\n    QSharedPointer<ComponentParameterFinder> componentFinder(new ComponentParameterFinder(component_));\r\n    QSharedPointer<ListParameterFinder> moduleFinder(new ListParameterFinder());\r\n    moduleFinder->setParameterList(getModuleParameters());\r\n    parameterFinder->addFinder(componentFinder);\r\n    parameterFinder->addFinder(moduleFinder);\r\n\r\n    //! The formatter for expressions.\r\n    ExpressionFormatter formatter(parameterFinder);\r\n\r\n    parameters_->clear();\r\n    moduleParameters_->clear();\r\n    metaParameters_->clear();\r\n    parseParameters();\r\n    formatParameters(formatter);\r\n    formatPorts(formatter);\r\n    parseRemapStates(formatter);\r\n\r\n    parseMetaParameters();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MetaComponent::parseMetaParameters()\r\n//-----------------------------------------------------------------------------\r\nvoid MetaComponent::parseMetaParameters()\r\n{\r\n    for (QSharedPointer<Parameter> original : *getParameters())\r\n    {\r\n        metaParameters_->append(original);\r\n    }\r\n\r\n    for (QSharedPointer<Parameter> original : *getModuleParameters())\r\n    {\r\n        Q_ASSERT(original);\r\n\r\n        auto i = std::find_if(metaParameters_->begin(), metaParameters_->end(),\r\n            [&original](QSharedPointer<Parameter> parameter)\r\n        { return original->getValue().contains(parameter->name()); });\r\n\r\n        if (i != metaParameters_->end())\r\n        {\r\n            if (original->getValue().compare((*i)->name()) == 0)\r\n            {\r\n                original->setValue((*i)->getValue());\r\n            }\r\n\r\n            metaParameters_->erase(i);\r\n        }\r\n\r\n        metaParameters_->append(original);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MetaComponent::parseParameters()\r\n//-----------------------------------------------------------------------------\r\nvoid MetaComponent::parseParameters()\r\n{\r\n    // Copy all the component parameters for the original parameters.\r\n    for (QSharedPointer<Parameter> parameterOrig : *component_->getParameters())\r\n    {       \r\n        parameters_->append(QSharedPointer<Parameter>(new Parameter(*parameterOrig)));\r\n    }\r\n\r\n    // If there is an active component instantiation, take its module parameters as well.\r\n    if (activeInstantiation_)\r\n    {\r\n        for (QSharedPointer<ModuleParameter> parameterOrig : *activeInstantiation_->getModuleParameters())\r\n        {\r\n            moduleParameters_->append(QSharedPointer<ModuleParameter>(new ModuleParameter(*parameterOrig)));\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MetaComponent::formatParameters()\r\n//-----------------------------------------------------------------------------\r\nvoid MetaComponent::formatParameters(ExpressionFormatter const& formatter)\r\n{\r\n\tsortParameters(parameters_);\r\n    for (QSharedPointer<Parameter> parameter : *parameters_)\r\n    {\r\n        parameter->setValue(formatter.formatReferringExpression(parameter->getValue()));\r\n    }\r\n\r\n    sortParameters(moduleParameters_);\r\n    for (QSharedPointer<Parameter> moduleParameter : *moduleParameters_)\r\n    {\r\n        moduleParameter->setValue(formatter.formatReferringExpression(moduleParameter->getValue()));\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MetaComponent::sortParameters()\r\n//-----------------------------------------------------------------------------\r\nvoid MetaComponent::sortParameters(QSharedPointer<QList<QSharedPointer<Parameter> > > sortParameters)\r\n{\r\n    std::sort(sortParameters->begin(), sortParameters->end(),\r\n        [](QSharedPointer<Parameter>& currentParameter, QSharedPointer<Parameter>& nextParameter)\r\n        {\r\n            if (nextParameter->getValue().contains(currentParameter->getValueId()))\r\n            {\r\n                return true;\r\n            }\r\n\r\n            if (currentParameter->getValue().contains(nextParameter->getValueId()))\r\n            {\r\n                return false;\r\n            }\r\n        \r\n            return currentParameter->name() < nextParameter->name();\r\n        });\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MetaComponent::parsesFileSets()\r\n//-----------------------------------------------------------------------------\r\nvoid MetaComponent::parsesFileSets()\r\n{\r\n    for (auto const& fileSetRef : *activeInstantiation_->getFileSetReferences())\r\n    {\r\n        QSharedPointer<FileSet> fileSet = component_->getFileSet(fileSetRef->getReference());\r\n        if (fileSet)\r\n        {\r\n            fileSets_->append(fileSet);\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MetaComponent::formatPorts()\r\n//-----------------------------------------------------------------------------\r\nvoid MetaComponent::formatPorts(ExpressionFormatter const& formatter)\r\n{\r\n    for (QSharedPointer<Port> cport : *component_->getPorts())\r\n    {\r\n        QSharedPointer<MetaPort> mPort(new MetaPort);\r\n        mPort->port_ = cport;\r\n        mPort->arrayBounds_.first = \"\";\r\n        mPort->arrayBounds_.second = \"\";\r\n        mPort->width_ = \"\";\r\n        mPort->vectorBounds_.first = formatter.formatReferringExpression(cport->getLeftBound());\r\n        mPort->vectorBounds_.second = formatter.formatReferringExpression(cport->getRightBound());\r\n        mPort->isWire_ = false;\r\n        mPort->isTransactional_ = false;\r\n\r\n        if (cport->getWire())\r\n        {\r\n            mPort->isWire_ = true;\r\n            mPort->arrayBounds_.first = formatter.formatReferringExpression(cport->getArrayLeft());\r\n            mPort->arrayBounds_.second = formatter.formatReferringExpression(cport->getArrayRight());\r\n        }\r\n        else if (cport->getTransactional())\r\n        {\r\n            mPort->isTransactional_ = true;\r\n            mPort->width_ = formatter.formatReferringExpression(cport->getTransactional()->getBusWidth());\r\n        }\r\n\r\n        ports_->insert(cport->name(), mPort);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MetaComponent::parseRemapStates\r\n//-----------------------------------------------------------------------------\r\nvoid MetaComponent::parseRemapStates(ExpressionFormatter const& formatter)\r\n{\r\n    for (QSharedPointer<RemapState> currentState : *component_->getRemapStates())\r\n    {\r\n        QSharedPointer<FormattedRemapState> remapState(new FormattedRemapState);\r\n        remapState->state_ = currentState;\r\n        remapStates_->append(remapState);\r\n\r\n        // Each port referred by the state must be listed.\r\n        for (QSharedPointer<RemapPort> remapPort : *currentState->getRemapPorts())\r\n        {\r\n            // Pick the port name, and the value needed for it to remap state become effective.\r\n            QSharedPointer<QPair<QSharedPointer<Port>,QString> > parsedPort\r\n                (new QPair<QSharedPointer<Port>, QString>);\r\n            parsedPort->first = component_->getPort(remapPort->getPortNameRef());\r\n            parsedPort->second = formatter.formatReferringExpression(remapPort->getValue());\r\n\r\n            remapState->ports_.append(parsedPort);\r\n        }\r\n    }\r\n}\r\n"
  },
  {
    "path": "Plugins/common/HDLParser/MetaComponent.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: MetaComponent.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Janne Virtanen\r\n// Date: 03.02.2017\r\n//\r\n// Description:\r\n// Class used to parse relevant information from IP-XACT component for HDL generation.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef METACOMPONENT_H\r\n#define METACOMPONENT_H\r\n\r\n#include <IPXACTmodels/Component/Component.h>\r\n\r\n#include <Plugins/common/HDLParser/HDLParserCommon.h>\r\n\r\n#include <QTextStream>\r\n\r\nclass ExpressionFormatter;\r\nclass MessageMediator;\r\n\r\n//-----------------------------------------------------------------------------\r\n// Class used to parse relevant information from IP-XACT component for HDL generation.\r\n//-----------------------------------------------------------------------------\r\nclass MetaComponent\r\n{\r\npublic:\r\n    \r\n\t/*!\r\n\t *  The constructor.\r\n     *\r\n     *    @param [in] messages            For message output.\r\n\t *    @param [in] component           The instantiated component.\r\n     *    @param [in] activeView          The active view for the component.\r\n\t */\r\n    MetaComponent(MessageMediator* messages, QSharedPointer<Component> component, QSharedPointer<View> activeView);\r\n\r\n\t//! The destructor.\r\n\tvirtual ~MetaComponent() = default;\r\n    \r\n    // Disable copying.\r\n    MetaComponent(MetaComponent const& rhs) = delete;\r\n    MetaComponent& operator=(MetaComponent const& rhs) = delete;\r\n\r\n    /*!\r\n     *  Formats the parameters, ports and remap states, so that they are writable HDL.\r\n     */\r\n    void formatComponent();\r\n    \r\n    /*!\r\n     *  Returns the associated component.\r\n     */\r\n    QSharedPointer<Component> getComponent() const { return component_; }\r\n    \r\n    /*!\r\n     *  Returns the active view.\r\n     */\r\n    QSharedPointer<View> getActiveView() const { return activeView_; }\r\n\r\n    /*!\r\n     *  Returns list of culled parameters\r\n     */\r\n    QSharedPointer<QList<QSharedPointer<Parameter> > > getParameters() { return parameters_; }\r\n\r\n    /*!\r\n     *  Returns list of culled module parameters\r\n     */\r\n    QSharedPointer<QList<QSharedPointer<Parameter> > > getModuleParameters() { return moduleParameters_; }\r\n\r\n    /*!\r\n     *  Returns list of resolved meta parameters\r\n     */\r\n    QSharedPointer<QList<QSharedPointer<Parameter> > > getMetaParameters() { return metaParameters_; }\r\n\r\n    /*!\r\n     *  Returns list of culled ports.\r\n     */\r\n    QSharedPointer<QMap<QString,QSharedPointer<MetaPort> > > getPorts() { return ports_; }\r\n    \r\n    /*!\r\n     *  Returns name of the associated HDL module.\r\n     */\r\n    QString getModuleName() const { return moduleName_; }\r\n\r\n    /*!\r\n     *  Sets name of the associated HDL module.\r\n     */\r\n    void setModuleName(QString const& name) { moduleName_ = name; }\r\n    \r\n    /*!\r\n     *  Returns list of formatted remap states.\r\n     */\r\n    QSharedPointer<QList<QSharedPointer<FormattedRemapState> > > getRemapStates() const { return remapStates_; }\r\n\r\n    /*!\r\n     *  Returns list of culled file sets\r\n     */\r\n    QSharedPointer<QList<QSharedPointer<FileSet> > > getFileSets() { return fileSets_; }\r\n\r\n    /*!\r\n    *  Sorts list of parameters based on their interdependencies.\r\n    *\r\n    *    @param [out] parameters         The list containing the parameters that will be sorted.\r\n    */\r\n    static void sortParameters(QSharedPointer<QList<QSharedPointer<Parameter> > > parameters);\r\n\r\nprotected:\r\n\r\n    void parseMetaParameters();\r\n\r\n    //! The messages.\r\n    MessageMediator* messages_;\r\n\r\nprivate:\r\n\r\n    /*!\r\n    *  Parses and copies parameter declarations of the component and active instantiation if any exists.\r\n    */\r\n    virtual void parseParameters();\r\n\r\n    /*!\r\n    *  Formats the found parameter declarations.\r\n    */\r\n    void formatParameters(ExpressionFormatter const& formatter);\r\n\r\n    \r\n    /*!\r\n     *  Associates the meta object file sets pointed by the active component instance.\r\n     */\r\n    virtual void parsesFileSets();\r\n\r\n    \r\n    /*!\r\n     *  Culls and formats the ports of the component.\r\n     */\r\n    virtual void formatPorts(ExpressionFormatter const& formatter);\r\n\r\n    /*!\r\n     *  Goes through the remap states, connects remaps to correct ports.\r\n     */\r\n    void parseRemapStates(ExpressionFormatter const& formatter);\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! The matching IP-XACT component.\r\n    QSharedPointer<Component> component_;\r\n\r\n    //! The active view of the instance.\r\n    QSharedPointer<View> activeView_;\r\n\r\n    //! The parameters, which are either formatted or completely parsed.\r\n    QSharedPointer<QList<QSharedPointer<Parameter> > > parameters_;\r\n    QSharedPointer<QList<QSharedPointer<Parameter> > > moduleParameters_;\r\n\r\n    //! These parameters are actually generated.\r\n    QSharedPointer<QList<QSharedPointer<Parameter> > > metaParameters_;\r\n\r\n    //! The ports of the component keyed with its physical name.\r\n    QSharedPointer<QMap<QString,QSharedPointer<MetaPort> > > ports_;\r\n\r\n    //! The filesets referred by the activeInstantiation_;\r\n    QSharedPointer<QList<QSharedPointer<FileSet> > > fileSets_;\r\n\r\n    //! The module name for HDL.\r\n    QString moduleName_;\r\n\r\n    //! The component instantiation referred by the active view.\r\n    QSharedPointer<ComponentInstantiation> activeInstantiation_;\r\n\r\n    //! The formatted remap states.\r\n    QSharedPointer<QList<QSharedPointer<FormattedRemapState> > > remapStates_;\r\n};\r\n\r\n#endif // METACOMPONENT_H\r\n"
  },
  {
    "path": "Plugins/common/HDLParser/MetaDesign.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: MetaDesign.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Janne Virtanen\r\n// Date: 11.01.2017\r\n//\r\n// Description:\r\n// An instantiated design with all its parameters, instances, and interconnections parsed.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"MetaDesign.h\"\r\n\r\n#include <KactusAPI/include/MessageMediator.h>\r\n\r\n#include <KactusAPI/include/LibraryInterface.h>\r\n\r\n#include <IPXACTmodels/utilities/Search.h>\r\n\r\n#include <IPXACTmodels/utilities/ComponentSearch.h>\r\n\r\n#include <IPXACTmodels/Component/BusInterface.h>\r\n\r\n#include <IPXACTmodels/Design/Design.h>\r\n#include <IPXACTmodels/DesignConfiguration/DesignConfiguration.h>\r\n\r\n#include <IPXACTmodels/AbstractionDefinition/AbstractionDefinition.h>\r\n#include <IPXACTmodels/AbstractionDefinition/PortAbstraction.h>\r\n\r\n#include <KactusAPI/include/MultipleParameterFinder.h>\r\n#include <KactusAPI/include/ComponentParameterFinder.h>\r\n\r\n#include <QVector>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MetaDesign::MetaDesign()\r\n//-----------------------------------------------------------------------------\r\nMetaDesign::MetaDesign(LibraryInterface* library,\r\n    MessageMediator* messages,\r\n    QSharedPointer<Design const> design,\r\n    QSharedPointer<DesignInstantiation const> designInstantiation,\r\n    QSharedPointer<DesignConfiguration const> designConf,\r\n    QSharedPointer<MetaInstance> topInstance) :\r\nlibrary_(library),\r\nmessages_(messages),\r\ndesign_(design),\r\ndesignInstantiation_(designInstantiation),\r\ndesignConf_(designConf), \r\ntopInstance_(topInstance),\r\nparameters_(new QList<QSharedPointer<Parameter> >()),\r\ninstances_(new QMap<QString,QSharedPointer<MetaInstance> >),\r\ninterconnections_(new QList<QSharedPointer<MetaInterconnection> >),\r\nadHocWires_(new QList<QSharedPointer<MetaWire> >)\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MetaDesign::parseHierarchy()\r\n//-----------------------------------------------------------------------------\r\nQList<QSharedPointer<MetaDesign> > MetaDesign::parseHierarchy(LibraryInterface* library, GenerationTuple input,\r\n    QSharedPointer<View> topComponentView)\r\n{\r\n    QSharedPointer<ComponentInstance> componentInstance(nullptr);\r\n    QSharedPointer<QList<QSharedPointer<Parameter> > > topList(new QList<QSharedPointer<Parameter> >);\r\n    QSharedPointer<QList<QSharedPointer<ConfigurableElementValue> > > cevs(nullptr);\r\n\r\n    // Instantiate the top component with the selected design.\r\n    // Obviously, it cannot have CEVs or parameters of any other component.\r\n    QSharedPointer<MetaInstance> topMostInstance(new MetaInstance(componentInstance,\r\n        library, input.messages, input.component, topComponentView));\r\n\r\n    parseParameters(topMostInstance->getParameters(), topList, cevs);\r\n    topList->append(*topMostInstance->getParameters());\r\n\r\n    parseParameters(topMostInstance->getModuleParameters(), topList, cevs);\r\n    topMostInstance->parseInstance();\r\n\r\n    // Find the design instantiation matching the design.\r\n    QSharedPointer<DesignInstantiation> designInstantiation(nullptr);\r\n    foreach(QSharedPointer<DesignInstantiation> di, *input.component->getDesignInstantiations())\r\n    {\r\n        if (input.design->getVlnv() == *di->getDesignReference())\r\n        {\r\n            designInstantiation = di;\r\n            break;\r\n        }\r\n    }\r\n\r\n    // Create the design associated with the top component.\r\n    QSharedPointer<MetaDesign> topMostDesign(new MetaDesign(library, input.messages, input.design,\r\n        designInstantiation, input.designConfiguration, topMostInstance));\r\n\r\n    // Each module name, except the topmost instance, is associated with the count of the same name.\r\n    QMap<QString, int> names;\r\n\r\n    QList<QSharedPointer<MetaDesign> > parsedDesigns;\r\n    int subDesignCount = 0;\r\n    const int MAXIMUM_SUBDESIGNS = 1000;\r\n    \r\n    QVector<QSharedPointer<MetaDesign> > designsToParse({ topMostDesign });\r\n    while (!designsToParse.isEmpty())\r\n    {\r\n         QSharedPointer<MetaDesign> currentDesign = designsToParse.takeFirst();\r\n         currentDesign->findInstances();\r\n\r\n         subDesignCount += currentDesign->subDesigns_.count();\r\n         if (subDesignCount > MAXIMUM_SUBDESIGNS)\r\n         {\r\n             input.messages->showError(\r\n                 QObject::tr(\"Exceeded maximum number of designs in one hierarchy: %1.\").arg(MAXIMUM_SUBDESIGNS));\r\n             return parsedDesigns;\r\n         }\r\n\r\n         for (QSharedPointer<MetaDesign> subDesign : currentDesign->subDesigns_)\r\n         {\r\n             designsToParse.append(subDesign);\r\n\r\n             QString name = subDesign->getTopInstance()->getModuleName();\r\n             \r\n             int count = names.value(name, 0);\r\n             names.insert(name, count + 1);\r\n\r\n             subDesign->getTopInstance()->setModuleName(name + QLatin1Char('_') + QString::number(count));\r\n         }\r\n\r\n         currentDesign->parseDesign();\r\n         parsedDesigns.append(currentDesign);\r\n    }\r\n\r\n    return parsedDesigns;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MetaDesign::parseDesign()\r\n//-----------------------------------------------------------------------------\r\nvoid MetaDesign::parseDesign()\r\n{\r\n    parseDesignParamaters();\r\n    parseInstances();\r\n    parseInterconnections();\r\n    parseAdHocs();\r\n\r\n    // We know the unconnected assignments only after all of interconnections are parsed.\r\n    removeUnconnectedInterfaceAssignments();\r\n    removeUnconnectedAdHocAssignments();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MetaDesign::parseDesignParamaters()\r\n//-----------------------------------------------------------------------------\r\nvoid MetaDesign::parseDesignParamaters()\r\n{\r\n    // Copy all design parameters.\r\n    for(QSharedPointer<Parameter> parameterOrig : *design_->getParameters())\r\n    {\r\n        parameters_->append(QSharedPointer<Parameter>(new Parameter(*parameterOrig)));\r\n    }\r\n\r\n    QSharedPointer<QList<QSharedPointer<ConfigurableElementValue> > > cevs(nullptr);\r\n    if (designInstantiation_)\r\n    {\r\n        cevs = designInstantiation_->getDesignReference()->getConfigurableElementValues();\r\n    }\r\n\r\n    // Provide the list of parameters that are referable by CEVs.\r\n    QSharedPointer<QList<QSharedPointer<Parameter> > > topParameters(new QList<QSharedPointer<Parameter> >());\r\n    topParameters->append(*topInstance_->getParameters());\r\n\r\n    // Also other parameters within the component may be referred.\r\n    QSharedPointer<ComponentParameterFinder> componentParameters(new ComponentParameterFinder(topInstance_->getComponent()));\r\n    topParameters->append(componentParameters->allCpuParameters());\r\n    topParameters->append(componentParameters->allGeneratorParameters());\r\n    topParameters->append(componentParameters->allBusInterfaceParameters());\r\n    topParameters->append(componentParameters->allAddressSpaceParameters());\r\n    topParameters->append(componentParameters->allRegisterParameters());\r\n\r\n    parseParameters(parameters_, topParameters, cevs);\r\n\r\n    // Finally, add these parameters to the top instance.\r\n    for (QSharedPointer<Parameter> original : *parameters_)\r\n    {\r\n        // Try find an existing meta-parameter with a matching name.\r\n        auto foundParameter = Search::findByName(original->name(), *topInstance_->getMetaParameters());\r\n\r\n        if (foundParameter.isNull() == false)\r\n        {\r\n            foundParameter->setName(original->name());\r\n            foundParameter->setValue(original->getValue());\r\n            foundParameter->setValueResolve(original->getValueResolve());            \r\n        }\r\n        else\r\n        {\r\n            topInstance_->getMetaParameters()->append(original);\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MetaDesign::findInstances()\r\n//-----------------------------------------------------------------------------\r\nvoid MetaDesign::findInstances()\r\n{\r\n    for (QSharedPointer<ComponentInstance> instance : *design_->getComponentInstances())\r\n    {\r\n        VLNV instanceVLNV = design_->getHWComponentVLNV(instance->getInstanceName());\r\n        QSharedPointer<Component> component = library_->getModel<Component>(instanceVLNV);\r\n\r\n        if (!component)\r\n        {\r\n            messages_->showError(QObject::tr(\"Design %1: Component of instance %2 was not found: %3\")\r\n                .arg(design_->getVlnv().toString(), instance->getInstanceName(), instanceVLNV.toString()));\r\n            continue;   \r\n        }\r\n\r\n        // The instance may have an active view in the design configuration.\r\n        QSharedPointer<View> activeView;\r\n        if (designConf_)\r\n        {\r\n            activeView = ComponentSearch::findView(component,\r\n                designConf_->getActiveView(instance->getInstanceName()));\r\n        }\r\n\r\n        // No chosen active view -> If there is only one in the component, use it.\r\n        if (!activeView && component->getViews()->size() > 0)\r\n        {\r\n            if (component->getViews()->size() == 1)\r\n            {\r\n                activeView = component->getViews()->first();\r\n            }\r\n            else\r\n            {\r\n                messages_->showError(QObject::tr(\"Design %1: Instance %2 did not have specified active view, \"\r\n                    \"and its component %3 has multiple possible views, so no active view was chosen.\")\r\n                    .arg(design_->getVlnv().toString(), instance->getInstanceName(), instanceVLNV.toString()));\r\n            }\r\n        }\r\n\r\n        QSharedPointer<MetaInstance> mInstance(new MetaInstance(instance, library_, messages_, component,\r\n            activeView));\r\n        instances_->insert(instance->getInstanceName(), mInstance);\r\n        findHierarchy(mInstance);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MetaDesign::parseParameters()\r\n//-----------------------------------------------------------------------------\r\nvoid MetaDesign::parseParameters(QSharedPointer<QList<QSharedPointer<Parameter> > > subList,\r\n    QSharedPointer<QList<QSharedPointer<Parameter> > > topList,\r\n    QSharedPointer<QList<QSharedPointer<ConfigurableElementValue> > > cevs)\r\n{\r\n    // If CEVs have been supplied, use them.\r\n    if (cevs)\r\n    {\r\n        for (QSharedPointer<Parameter> parameter : *subList)\r\n        {\r\n            for (QSharedPointer<ConfigurableElementValue> cev : *cevs)\r\n            {\r\n                // If a CEV refers to the parameter, its value shall be the value of the parameter.\r\n                if (cev->getReferenceId().compare(parameter->getValueId()) == 0)\r\n                {\r\n                    parameter->setValue(cev->getConfigurableValue());\r\n                    break;\r\n                }\r\n            }\r\n        }\r\n    }\r\n\r\n    // Initialize the parameter parsing: Find parameters from both the instance and the top component.\r\n    QSharedPointer<ListParameterFinder> subFinder(new ListParameterFinder);\r\n    subFinder->setParameterList(subList);\r\n\r\n    QSharedPointer<MultipleParameterFinder> multiFinder(new MultipleParameterFinder());\r\n    multiFinder->addFinder(subFinder);\r\n\r\n    // If top list has been supplied, use it.\r\n    if (topList)\r\n    {\r\n        QSharedPointer<ListParameterFinder> topFinder(new ListParameterFinder);\r\n        topFinder->setParameterList(topList);\r\n\r\n        multiFinder->addFinder(topFinder);\r\n    }\r\n\r\n    IPXactSystemVerilogParser parser(multiFinder);\r\n    for (QSharedPointer<Parameter> parameter : *subList)\r\n    {\r\n        parameter->setValue(parser.parseExpression(parameter->getValue()));\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MetaDesign::parseInstances()\r\n//-----------------------------------------------------------------------------\r\nvoid MetaDesign::parseInstances()\r\n{    \r\n    for (QSharedPointer<MetaInstance> mInstance : *instances_)\r\n    {\r\n        // Parse parameters of the instance, which may be overridden by\r\n        // component instance CEVs, which may point to the design parameters.\r\n        parseParameters(mInstance->getParameters(), parameters_,\r\n            mInstance->getComponentInstance()->getConfigurableElementValues());\r\n\r\n        // Module parameters may refer to the component parameters.\r\n        QSharedPointer<QList<QSharedPointer<Parameter> > > topList(new QList<QSharedPointer<Parameter> >);\r\n      \r\n        topList->append(*mInstance->getParameters());\r\n        \r\n        QSharedPointer<QList<QSharedPointer<ConfigurableElementValue> > > cevs;\r\n\r\n        // Design configuration may have CEVs pointing to module parameters.\r\n        if (designConf_)\r\n        {\r\n            QSharedPointer<ViewConfiguration> viewConfig = designConf_->getViewConfiguration(\r\n                mInstance->getComponentInstance()->getInstanceName());\r\n\r\n            if (viewConfig)\r\n            {\r\n                // TODO: Use view configuration CEVs.\r\n                //cevs = viewConfig->getViewConfigurableElements();\r\n            }\r\n        }\r\n\r\n        // Parse module parameters of the instance, TODO: which may be overridden by view configuration CEVS,\r\n        // which may point to the design configuration parameters.\r\n        parseParameters(mInstance->getModuleParameters(), topList, cevs);\r\n\r\n        mInstance->parseInstance();\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MetaDesign::parseInterconnections()\r\n//-----------------------------------------------------------------------------\r\nvoid MetaDesign::parseInterconnections()\r\n{\r\n    // Go through each non-ad-hoc interconnection in the design.\r\n    for (QSharedPointer<Interconnection> connection : *design_->getInterconnections())\r\n    {\r\n        QList<QSharedPointer<ActiveInterface> > interfaces = *connection->getActiveInterfaces();\r\n        interfaces.append(connection->getStartInterface());\r\n\r\n        QList<QSharedPointer<MetaInterface> > foundInterInterfaces;\r\n        QList<QSharedPointer<MetaInterface> > foundHierInterfaces;\r\n\r\n        for (QSharedPointer<ActiveInterface> connectionInterface : interfaces)\r\n        {\r\n            QSharedPointer<MetaInstance> mInstance = \r\n                instances_->value(connectionInterface->getComponentReference());\r\n            if (!mInstance)\r\n            {\r\n                messages_->showError(QObject::tr(\"Design %1: Instance %2 referred by interconnection %3\"\r\n                    \" does not exist.\").arg(design_->getVlnv().toString(),\r\n                    connectionInterface->getComponentReference(), connection->name()));\r\n                continue;\r\n            }\r\n\r\n            QSharedPointer<MetaInterface> mInterface = mInstance->getInterfaces()->value(\r\n                connectionInterface->getBusReference());\r\n            if (!mInterface)\r\n            {\r\n                messages_->showError(QObject::tr(\"Design %1: Bus interface %2 referred by interconnection %3\"\r\n                    \" does not exist within component %4.\")\r\n                    .arg(design_->getVlnv().toString(), connectionInterface->getBusReference(),\r\n                    connection->name(), mInstance->getComponent()->getVlnv().toString()));\r\n                continue;\r\n            }\r\n\r\n            // TODO: Errr if mInterface already has an interconnection!\r\n\r\n            foundInterInterfaces.append(mInterface);\r\n        }\r\n\r\n        for (QSharedPointer<HierInterface> hierInterface : *connection->getHierInterfaces())\r\n        {\r\n            QSharedPointer<MetaInterface> mInterface = topInstance_->getInterfaces()->value(\r\n                hierInterface->getBusReference());\r\n\r\n            if (!mInterface)\r\n            {\r\n                messages_->showError(QObject::tr(\"Design %1: Bus interface %2 referred by interconnection %3\"\r\n                    \" does not exist within component %4.\").arg(design_->getVlnv().toString(),\r\n                        hierInterface->getBusReference(), connection->name(),\r\n                    topInstance_->getComponent()->getVlnv().toString()));\r\n                continue;\r\n            }\r\n\r\n            // TODO: Errr if mInterface already has an interconnection!\r\n\r\n            foundHierInterfaces.append(mInterface);\r\n        }\r\n\r\n        // If not enough interfaces are in the interconnect, drop it.\r\n        if (foundInterInterfaces.size() + foundHierInterfaces.size() < 2)\r\n        {\r\n            messages_->showError(\r\n                QObject::tr(\"Design %1: No bus interfaces were found for interconnection %2.\").arg(\r\n                    design_->getVlnv().toString(), connection->name()));\r\n            continue;\r\n        }\r\n\r\n        QSharedPointer<MetaInterconnection> mIterconnect;\r\n\r\n        // First, try to reuse an existing interconnection:\r\n        // If any of the found interfaces has an interconnection already, use it.\r\n        // TODO: Have validators enforce the rule that each interface may have only one interconnection.\r\n        // Then this step must be omitted.\r\n        for (QSharedPointer<MetaInterface> mInterface : foundInterInterfaces)\r\n        {\r\n            if (mInterface->upInterconnection_)\r\n            {\r\n                mIterconnect = mInterface->upInterconnection_;\r\n                break;\r\n            }\r\n        }\r\n\r\n        for (QSharedPointer<MetaInterface> mInterface : foundHierInterfaces)\r\n        {\r\n            if (mInterface->downInterconnection_)\r\n            {\r\n                mIterconnect = mInterface->downInterconnection_;\r\n                break;\r\n            }\r\n        }\r\n\r\n        // If a matching interconnection did not exist, create a new one.\r\n        if (!mIterconnect)\r\n        {\r\n            mIterconnect = QSharedPointer<MetaInterconnection>(new MetaInterconnection);\r\n            mIterconnect->name_ = connection->name();\r\n\r\n            interconnections_->append(mIterconnect);\r\n\r\n            // The interconnection needs to know of the hierarchical interfaces connected to it.\r\n            mIterconnect->hierIfs_ = foundHierInterfaces;\r\n        }\r\n\r\n        // Associate the interfaces with the interconnect.\r\n        for (QSharedPointer<MetaInterface> mInterface : foundInterInterfaces)\r\n        {\r\n            mInterface->upInterconnection_ = mIterconnect;\r\n            wireInterfacePorts(mInterface, mIterconnect, false);\r\n        }\r\n\r\n        for (QSharedPointer<MetaInterface> mInterface : foundHierInterfaces)\r\n        {\r\n            mInterface->downInterconnection_ = mIterconnect;\r\n            wireInterfacePorts(mInterface, mIterconnect, true);\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MetaDesign::wireInterfacePorts()\r\n//-----------------------------------------------------------------------------\r\nvoid MetaDesign::wireInterfacePorts(QSharedPointer<MetaInterface> mInterface,\r\n    QSharedPointer<MetaInterconnection> mIterconnect, bool isHierarchical)\r\n{\r\n    // Associate the port assignments with the wires of the interconnect.\r\n    for (QSharedPointer<MetaPort> mPort : mInterface->ports_)\r\n    {\r\n        for (QSharedPointer<PortAbstraction> pAbs : *mInterface->absDef_->getLogicalPorts())\r\n        {\r\n            // ...get all port assignments in the interface utilizing its logical port...\r\n            QList<QSharedPointer<MetaPortAssignment> > assignments;\r\n\r\n            if (isHierarchical)\r\n            {\r\n                assignments = mPort->downAssignments_.values(pAbs->getLogicalName());\r\n            }\r\n            else\r\n            {\r\n                assignments = mPort->upAssignments_.values(pAbs->getLogicalName());\r\n            }\r\n\r\n            QList<QSharedPointer<MetaWire> > connectedWires;\r\n            QList<QSharedPointer<MetaTransactional> > connectedTransactionals;\r\n\r\n            // ...and associate them with the wire.\r\n            for (QSharedPointer<MetaPortAssignment> assignment : assignments)\r\n            {\r\n                if (assignment->mappedInterface_ == mInterface)\r\n                {\r\n                    if (pAbs->hasWire())\r\n                    {\r\n                        associateWithWire(mIterconnect, pAbs, assignment, connectedWires, isHierarchical, mPort);\r\n                    }\r\n                    else if (pAbs->hasTransactional())\r\n                    {\r\n                        associateWithTransactional(\r\n                            mIterconnect, pAbs, assignment, connectedTransactionals, isHierarchical, mPort);\r\n                    }\r\n\r\n                }\r\n\r\n            }\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MetaDesign::associateWithWire()\r\n//-----------------------------------------------------------------------------\r\nvoid MetaDesign::associateWithWire(QSharedPointer<MetaInterconnection> metaInterconnect,\r\n    QSharedPointer<PortAbstraction> portAbstraction, QSharedPointer<MetaPortAssignment> assignment,\r\n    QList<QSharedPointer<MetaWire>>& connectedWires, bool isHierarchical, QSharedPointer<MetaPort> metaPort)\r\n{\r\n    QSharedPointer<MetaWire> mWire = metaInterconnect->wires_.value(portAbstraction->getLogicalName());\r\n    if (!mWire)\r\n    {\r\n        mWire = QSharedPointer<MetaWire>(new MetaWire);\r\n        mWire->name_ = metaInterconnect->name_ + QLatin1Char('_') + portAbstraction->getLogicalName();\r\n        mWire->refCount = 0;\r\n\r\n        metaInterconnect->wires_.insert(portAbstraction->getLogicalName(), mWire);\r\n    }\r\n\r\n    if (assignment->wire_.isNull() || connectedWires.contains(assignment->wire_))\r\n    {\r\n        ++mWire->refCount;\r\n        assignment->wire_ = mWire;\r\n        connectedWires.append(mWire);\r\n    }\r\n    else\r\n    {\r\n        ++assignment->wire_->refCount;\r\n        connectedWires.append(assignment->wire_);\r\n    }\r\n\r\n    // Also assign larger bounds for wire, if applicable.\r\n    assignLargerBounds(mWire, assignment->logicalBounds_);\r\n\r\n    // Associate the wire with the hierarchical ports.\r\n    if (isHierarchical && !mWire->hierPorts_.contains(metaPort))\r\n    {\r\n        mWire->hierPorts_.append(metaPort);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MetaDesign::associateWithTransactional()\r\n//-----------------------------------------------------------------------------\r\nvoid MetaDesign::associateWithTransactional(QSharedPointer<MetaInterconnection> metaInterconnect,\r\n    QSharedPointer<PortAbstraction> portAbstraction, QSharedPointer<MetaPortAssignment> assignment,\r\n    QList<QSharedPointer<MetaTransactional>>& connectedTransactionals, bool isHierarchical,\r\n    QSharedPointer<MetaPort> metaPort)\r\n{\r\n    QSharedPointer<MetaTransactional> metaTransactional =\r\n        metaInterconnect->transactionals_.value(portAbstraction->getLogicalName());\r\n    if (!metaTransactional)\r\n    {\r\n        metaTransactional = QSharedPointer<MetaTransactional>(new MetaTransactional);\r\n        metaTransactional->name_ = metaInterconnect->name_ + QLatin1Char('_') + portAbstraction->getLogicalName();\r\n        metaTransactional->refCount_ = 0;\r\n\r\n        metaInterconnect->transactionals_.insert(portAbstraction->getLogicalName(), metaTransactional);\r\n    }\r\n\r\n    if (assignment->transactional_.isNull() || connectedTransactionals.contains(assignment->transactional_))\r\n    {\r\n        ++metaTransactional->refCount_;\r\n        assignment->transactional_ = metaTransactional;\r\n        connectedTransactionals.append(metaTransactional);\r\n    }\r\n    else\r\n    {\r\n        ++assignment->transactional_->refCount_;\r\n        connectedTransactionals.append(assignment->transactional_);\r\n    }\r\n\r\n    // Associate the wire with the hierarchical ports.\r\n    if (isHierarchical && !metaTransactional->hierPorts_.contains(metaPort))\r\n    {\r\n        metaTransactional->hierPorts_.append(metaPort);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MetaDesign::parseAdHocs()\r\n//-----------------------------------------------------------------------------\r\nvoid MetaDesign::parseAdHocs()\r\n{\r\n    for (QSharedPointer<AdHocConnection> connection : *design_->getAdHocConnections())\r\n    {\r\n        QList<QSharedPointer<MetaPort> > foundPorts;\r\n        QList<QSharedPointer<MetaPort> > foundHierPorts;\r\n\r\n        // The part select is expected to be in the same index as its matching port reference.\r\n        QList<QSharedPointer<PartSelect> > matchingPartSelects;\r\n\r\n        findPortsInAdHoc(connection, foundPorts, matchingPartSelects);\r\n        findHierarchicalPortsInAdHoc(connection, foundPorts, foundHierPorts, matchingPartSelects);\r\n\r\n        // If not enough ports are in the connection, drop it.\r\n        if (foundPorts.size() < 1)\r\n        {\r\n            messages_->showError(QObject::tr(\"Design %1: No ports were found for ad-hoc connection %2.\").arg(\r\n                design_->getVlnv().toString(), connection->name()));\r\n            continue;\r\n        }\r\n\r\n        if (foundPorts.first()->isWire_)\r\n        {\r\n            QSharedPointer<MetaWire> mWire;\r\n            QString wireName = connection->name();\r\n\r\n            if (foundPorts.size() > 1)\r\n            {\r\n                mWire = QSharedPointer<MetaWire>(new MetaWire);\r\n                mWire->name_ = wireName;\r\n                mWire->refCount = 0;\r\n\r\n                // Append to the pool of detected interconnections.\r\n                adHocWires_->append(mWire);\r\n\r\n                // The interconnection needs to know of the hierarchical interfaces connected to it.\r\n                mWire->hierPorts_ = foundHierPorts;\r\n            }\r\n\r\n            for (int i = 0; i < foundPorts.size(); ++i)\r\n            {\r\n                QSharedPointer<MetaPort> mPort = foundPorts[i];\r\n                bool isHierarchical = foundHierPorts.contains(mPort);\r\n\r\n                if (mPort->isWire_)\r\n                {\r\n                    parseAdHocAssignmentForPort(mPort, connection, mWire, isHierarchical, wireName,\r\n                        matchingPartSelects.at(i));\r\n                }\r\n            }\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MetaDesign::parseAdHocAssignmentForPort()\r\n//-----------------------------------------------------------------------------\r\nvoid MetaDesign::parseAdHocAssignmentForPort(QSharedPointer<MetaPort> mPort,\r\n    QSharedPointer<AdHocConnection> connection,\r\n    QSharedPointer<MetaWire> mWire,\r\n    bool isHierarchical,\r\n    QString wireName,\r\n    QSharedPointer<PartSelect> partSelect)\r\n{\r\n    QString defaultValue;\r\n    if (connection->getTiedValue().compare(QLatin1String(\"open\")) == 0)\r\n    {\r\n        //defaultValue = \"\";\r\n    }\r\n    else if (connection->getTiedValue().compare(QLatin1String(\"default\")) == 0)\r\n    {\r\n        defaultValue = mPort->defaultValue_;\r\n    }\r\n    else\r\n    {\r\n        defaultValue = connection->getTiedValue();\r\n    }\r\n\r\n    // No wire or default value means no assignment.\r\n    if (!mWire)\r\n    {\r\n        if (defaultValue.isEmpty() )\r\n        {\r\n            messages_->showError(\r\n                QObject::tr(\"Design %1: Ad-hoc connection %2 needs either more ports or a tie-off.\").arg(\r\n                    design_->getVlnv().toString(), connection->name()));\r\n            return;\r\n        }\r\n    }\r\n    else\r\n    {\r\n        ++mWire->refCount;\r\n    }\r\n\r\n    // New port assignment must be created for the each port.\r\n    QSharedPointer<MetaPortAssignment> assignment(new MetaPortAssignment);\r\n\r\n    // Associate the port assignments with the wire.\r\n    assignment->wire_ = mWire;\r\n    assignment->defaultValue_ = defaultValue;\r\n    assignment->invert_ = false;\r\n\r\n    // Map the port assignment to the port using the name of the wire.\r\n    if (isHierarchical)\r\n    {\r\n        mPort->downAssignments_.insert(wireName, assignment);\r\n    }\r\n    else\r\n    {\r\n        mPort->upAssignments_.insert(wireName, assignment);\r\n    }\r\n\r\n    // Assigning bounds.\r\n    if (partSelect && !partSelect->getLeftRange().isEmpty() && !partSelect->getRightRange().isEmpty())\r\n    {\r\n        // If part select exists, it shall be used.\r\n        assignment->physicalBounds_.first = partSelect->getLeftRange();\r\n        assignment->physicalBounds_.second = partSelect->getRightRange();\r\n    }\r\n    else\r\n    {\r\n        // Else just choose the port bounds.\r\n        assignment->physicalBounds_ = mPort->vectorBounds_;\r\n    }\r\n\r\n    // Determine the part of the wire that shall be assigned to the port:\r\n    // This is [abs(physical.left  physical.right):0]\r\n    QPair<QString, QString> newBounds;\r\n    newBounds.first = QString::number(assignment->physicalBounds_.first.toInt() -\r\n        assignment->physicalBounds_.second.toInt());\r\n    newBounds.second = QStringLiteral(\"0\");\r\n\r\n    assignment->logicalBounds_ = newBounds;\r\n\r\n    // Also assign larger bounds for the wire, if applicable.\r\n    if (mWire)\r\n    {\r\n        assignLargerBounds(mWire, assignment->logicalBounds_);\r\n    }\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MetaDesign::findHierarchicalPortsInAdHoc()\r\n//-----------------------------------------------------------------------------\r\nvoid MetaDesign::findHierarchicalPortsInAdHoc(QSharedPointer<AdHocConnection> connection,\r\n    QList<QSharedPointer<MetaPort> > &foundPorts,\r\n    QList<QSharedPointer<MetaPort> > &foundHierPorts,\r\n    QList<QSharedPointer<PartSelect> > &matchingPartSelects)\r\n{\r\n    for (QSharedPointer<PortReference> portRef : *connection->getExternalPortReferences())\r\n    {\r\n        QSharedPointer<MetaPort> mPort = topInstance_->getPorts()->value(portRef->getPortRef());\r\n\r\n        if (!mPort)\r\n        {\r\n            messages_->showError(QObject::tr(\"Design %1: Port %2 referred by ad-hoc connection %3\"\r\n                \" does not exist within component %4.\")\r\n                .arg(design_->getVlnv().toString(),\r\n                portRef->getPortRef(),\r\n                connection->name(),\r\n                topInstance_->getComponent()->getVlnv().toString()));\r\n            continue;\r\n        }\r\n\r\n        foundPorts.append(mPort);\r\n        foundHierPorts.append(mPort);\r\n        matchingPartSelects.append(portRef->getPartSelect());\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MetaDesign::findPortsInAdHoc()\r\n//-----------------------------------------------------------------------------\r\nvoid MetaDesign::findPortsInAdHoc(QSharedPointer<AdHocConnection> connection,\r\n    QList<QSharedPointer<MetaPort> > &foundPorts,\r\n    QList<QSharedPointer<PartSelect> > &matchingPartSelects)\r\n{\r\n    for (QSharedPointer<PortReference> portRef : *connection->getInternalPortReferences())\r\n    {\r\n        QSharedPointer<MetaInstance> mInstance = instances_->value(portRef->getComponentRef());\r\n        if (!mInstance)\r\n        {\r\n            messages_->showError(\r\n                QObject::tr(\"Design %1: Instance %2 referred by ad-hoc connection %3 does not exist.\")\r\n                .arg(design_->getVlnv().toString(), portRef->getComponentRef(), connection->name()));\r\n            continue;\r\n        }\r\n\r\n        // The port must be found within the ad-hoc ports recognized for the instance.\r\n        QSharedPointer<MetaPort> mPort = mInstance->getPorts()->value(portRef->getPortRef());\r\n        if (!mPort)\r\n        {\r\n            messages_->showError(QObject::tr(\"Design %1: Port %2 referred by ad-hoc connection %3 does\"\r\n                \" not exist within component %4.\")\r\n                .arg(design_->getVlnv().toString(), portRef->getPortRef(), connection->name(),\r\n                mInstance->getComponent()->getVlnv().toString()));\r\n            continue;\r\n        }\r\n\r\n        foundPorts.append(mPort);\r\n        matchingPartSelects.append(portRef->getPartSelect());\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MetaDesign::removeUnconnectedInterfaceAssignments()\r\n//-----------------------------------------------------------------------------\r\nvoid MetaDesign::removeUnconnectedInterfaceAssignments()\r\n{\r\n    for (QSharedPointer<MetaInstance> mInstance : *instances_)\r\n    {\r\n        for (QSharedPointer<MetaPort> mPort : *mInstance->getPorts())\r\n        {\r\n            bool connected = false;\r\n            for (QSharedPointer<MetaPortAssignment> assignment : mPort->upAssignments_)\r\n            {\r\n                if ((mPort->isWire_ && ((assignment->wire_ && assignment->wire_->refCount >= 2) ||\r\n                        assignment->defaultValue_.isEmpty() == false)) ||\r\n                    (mPort->isTransactional_ && ((assignment->transactional_ &&\r\n                        assignment->transactional_->refCount_ >= 2) ||\r\n                        assignment->defaultValue_.isEmpty() == false)))\r\n                {\r\n                    connected = true;\r\n                }\r\n            }\r\n\r\n            if (connected == false)\r\n            {\r\n                mPort->upAssignments_.clear();\r\n            }\r\n        }\r\n    }\r\n\r\n    for (QSharedPointer<MetaInterface> mInterface : *topInstance_->getInterfaces())\r\n    {\r\n        for (QSharedPointer<MetaPort> mPort : *topInstance_->getPorts())\r\n        {\r\n            bool connected = false;\r\n            for (QSharedPointer<MetaPortAssignment> assignment : mPort->downAssignments_)\r\n            {\r\n                if ((mPort->isWire_ && assignment->wire_ && assignment->wire_->refCount >= 2) ||\r\n                    (mPort->isTransactional_ && assignment->transactional_ &&\r\n                        assignment->transactional_->refCount_ >= 2))\r\n                {\r\n                    connected = true;\r\n                }\r\n            }\r\n\r\n            // Don't remove down assignment if port has tied value.\r\n            bool hasTiedValue = std::any_of(mPort->downAssignments_.cbegin(), mPort->downAssignments_.cend(),\r\n                [](QSharedPointer<MetaPortAssignment> assignment)\r\n                {\r\n                    return !assignment->defaultValue_.isEmpty();\r\n                });\r\n\r\n            if (connected == false && hasTiedValue == false)\r\n            {\r\n                mPort->downAssignments_.clear();\r\n            }\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MetaDesign::removeUnconnectedAdHocAssignments()\r\n//-----------------------------------------------------------------------------\r\nvoid MetaDesign::removeUnconnectedAdHocAssignments()\r\n{\r\n    for (QSharedPointer<MetaInstance> mInstance : *instances_)\r\n    {\r\n        // Go through its ports.\r\n        for (QSharedPointer<MetaPort> mPort : *mInstance->getPorts())\r\n        {\r\n            auto iter = mPort->upAssignments_.begin();\r\n            auto end = mPort->upAssignments_.end();\r\n\r\n            while (iter != end)\r\n            {\r\n                QSharedPointer<MetaPortAssignment> assignment = *iter;\r\n                bool isAdHocWire = getAdHocWires()->contains(assignment->wire_);\r\n\r\n                // Wire does not have at least two users -> remove.\r\n                if (assignment->wire_ && assignment->wire_->refCount < 2)\r\n                {\r\n                    assignment->wire_ = QSharedPointer<MetaWire>();\r\n                }\r\n\r\n                // Remove port assignment that do not match the criteria. Applies only to the ad hoc wires \r\n                // and assignments in which the port is mapped to an interface.\r\n                if (!assignment->wire_ && assignment->defaultValue_.isEmpty() && \r\n                    (isAdHocWire || assignment->mappedInterface_))\r\n                {\r\n                    iter = mPort->upAssignments_.erase(iter);\r\n                }\r\n                else\r\n                {\r\n                    ++iter;\r\n                }\r\n            }\r\n        }\r\n    }\r\n\r\n    for (QSharedPointer<MetaPort> mPort : *topInstance_->getPorts())\r\n    {\r\n        auto iter = mPort->downAssignments_.begin();\r\n        auto end = mPort->downAssignments_.end();\r\n\r\n        while (iter != end)\r\n        {\r\n            QSharedPointer<MetaPortAssignment> assignment = *iter;\r\n            bool isAdHocWire = getAdHocWires()->contains(assignment->wire_);\r\n\r\n            // Wire does not have at least two users -> remove. Applies only to the ad hoc wires.\r\n            if (assignment->wire_ && assignment->wire_->refCount < 2)\r\n            {\r\n                assignment->wire_ = QSharedPointer<MetaWire>();\r\n            }\r\n\r\n            // Remove port assignment that do not match the criteria. Applies only to the ad hoc wires.\r\n            if (!assignment->wire_ && assignment->defaultValue_.isEmpty() && isAdHocWire)\r\n            {\r\n                iter = mPort->downAssignments_.erase(iter);\r\n            }\r\n            else\r\n            {\r\n                ++iter;\r\n            }\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MetaDesign::findHierarchy()\r\n//-----------------------------------------------------------------------------\r\nvoid MetaDesign::findHierarchy(QSharedPointer<MetaInstance> mInstance)\r\n{\r\n    QSharedPointer<View> activeView = mInstance->getActiveView();\r\n    if (!activeView)\r\n    {\r\n        return;\r\n    }\r\n\r\n    QSharedPointer<Component> component = mInstance->getComponent();\r\n\r\n    // Try to find the instantiations.\r\n    QSharedPointer<DesignConfigurationInstantiation> configurationInstantiation = component->getModel()->\r\n        findDesignConfigurationInstantiation(activeView->getDesignConfigurationInstantiationRef());\r\n\r\n    QSharedPointer<DesignInstantiation> designInstantiation = component->getModel()->findDesignInstantiation(\r\n        activeView->getDesignInstantiationRef());\r\n\r\n    // Try to find the referred documents.\r\n    QSharedPointer<DesignConfiguration> subDesignConfiguration =\r\n        findDesignConfigurationFromInsantiation(configurationInstantiation);\r\n    QSharedPointer<Design> subDesign = findDesignFromInstantiation(designInstantiation, subDesignConfiguration);\r\n\r\n    if (subDesign)\r\n    {\r\n        // If a sub design exists, it must be also parsed.\r\n        QSharedPointer<MetaDesign> subMetaDesign(new MetaDesign(library_, messages_, subDesign, \r\n            designInstantiation, subDesignConfiguration, mInstance));\r\n        subDesigns_.append(subMetaDesign);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MetaDesign::findDesignConfigurationFromInsantiation()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<DesignConfiguration> MetaDesign::findDesignConfigurationFromInsantiation(\r\n    QSharedPointer<DesignConfigurationInstantiation> configurationInstantiation)\r\n{\r\n    QSharedPointer<DesignConfiguration> referredDesignConfiguration(nullptr);\r\n\r\n    if (configurationInstantiation && configurationInstantiation->getDesignConfigurationReference())\r\n    {\r\n        // Try to find the referred design configuration.\r\n        referredDesignConfiguration = library_->getModel<DesignConfiguration>(\r\n            *(configurationInstantiation->getDesignConfigurationReference()));\r\n\r\n        // If instantiation exists, the referred document must exist!\r\n        if (!referredDesignConfiguration)\r\n        {\r\n            messages_->showError(QObject::tr\r\n                (\"Design %1: Design configuration referred by instantiation did not exist: %2\")\r\n                .arg(design_->getVlnv().toString(),\r\n                    configurationInstantiation->getDesignConfigurationReference()->toString()));\r\n        }\r\n    }\r\n\r\n    return referredDesignConfiguration;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MetaDesign::findDesignFromInstantiation()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<Design> MetaDesign::findDesignFromInstantiation(QSharedPointer<DesignInstantiation> designInstantiation,\r\n    QSharedPointer<DesignConfiguration> configuration)\r\n{\r\n    QSharedPointer<Design> referredDesign(nullptr);\r\n\r\n    if (designInstantiation && designInstantiation->getDesignReference())\r\n    {\r\n        referredDesign = library_->getModel<Design>(*(designInstantiation->getDesignReference()));        \r\n        if (!referredDesign)\r\n        {\r\n            messages_->showError(QObject::tr(\"Design %1: Subdesign referred by instantiation did not exist: %2\")\r\n                .arg(design_->getVlnv().toString(), designInstantiation->getDesignReference()->toString()));\r\n        }\r\n    }\r\n\r\n    if (configuration)\r\n    {\r\n        if (referredDesign)\r\n        {\r\n            // If the design is already found, check for discrepancy.\r\n            if (configuration->getDesignRef() != referredDesign->getVlnv())\r\n            {\r\n                messages_->showError(\r\n                    QObject::tr(\"Design %1: Design configuration %2 of sub design %3 refers to different VLNV: %4\")\r\n                    .arg(design_->getVlnv().toString(), configuration->getVlnv().toString(),\r\n                        referredDesign->getVlnv().toString(), configuration->getDesignRef().toString()));\r\n            }\r\n        }\r\n        else\r\n        {\r\n            referredDesign = library_->getModel<Design>(configuration->getDesignRef());\r\n        }\r\n    }\r\n\r\n    return referredDesign;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MetaDesign::assignLargerBounds()\r\n//-----------------------------------------------------------------------------\r\nvoid MetaDesign::assignLargerBounds(QSharedPointer<MetaWire> wire, QPair<QString,QString> const& boundCand)\r\n{\r\n    // Do the comparison only if there are existing bounds.\r\n    if (!wire->bounds_.first.isEmpty() && !wire->bounds_.second.isEmpty())\r\n    {\r\n        QPair<int,int> newBounds;\r\n\r\n        // Check the size of the new bounds.\r\n        newBounds.first = boundCand.first.toInt();\r\n        newBounds.second = boundCand.second.toInt();\r\n\r\n        // Find the widest alignment order of the new bounds.\r\n        int maxAlignment1 = qMax(newBounds.first, newBounds.second);\r\n        int minAlignment1 = qMin(newBounds.first, newBounds.second);\r\n\r\n        QPair<int,int> existingBound;\r\n\r\n        // Check the size of the existing bounds.\r\n        existingBound.first = wire->bounds_.first.toInt();\r\n        existingBound.second = wire->bounds_.second.toInt();\r\n\r\n        // Find the widest alignment order of the existing bounds.\r\n        int maxAlignment2 = qMax(existingBound.first, existingBound.second);\r\n        int minAlignment2 = qMin(existingBound.first, existingBound.second);\r\n\r\n        // Finally, compare and assign.\r\n        wire->bounds_.first = QString::number(qMax(maxAlignment1,maxAlignment2));\r\n        wire->bounds_.second = QString::number(qMin(minAlignment1,minAlignment2));\r\n    }\r\n    else\r\n    {\r\n        // No existing bounds -> This shall be the new one.\r\n        wire->bounds_.first = boundCand.first;\r\n        wire->bounds_.second = boundCand.second;\r\n    }\r\n}\r\n"
  },
  {
    "path": "Plugins/common/HDLParser/MetaDesign.h",
    "content": "//-----------------------------------------------------------------------------\n// File: MetaDesign.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Janne Virtanen\n// Date: 11.01.2017\n//\n// Description:\n// An instantiated design within a hierarchy with all its parameters, instances, and interconnections parsed.\n//-----------------------------------------------------------------------------\n\n#ifndef METADESIGN_H\n#define METADESIGN_H\n\n#include \"MetaInstance.h\"\n\nclass Design;\nclass DesignConfiguration;\nclass AdHocConnection;\nclass MessageMediator;\nclass PartSelect;\nclass PortAbstraction;\n\n//-----------------------------------------------------------------------------\n// An instantiated design with all its parameters, instances, and interconnections parsed.\n//-----------------------------------------------------------------------------\nclass MetaDesign\n{\npublic:\n    /*!\n     *  The constructor.\n     *\n     *    @param [in] library             The library which is expected to contain the parsed documents.\n     *    @param [in] messages\t\t    For message output.\n     *    @param [in] design              The design to parse.\n     *    @param [in] designConf          The design configuration to parse.\n     *    @param [in] topInstance         The parsed meta instance of the top component.\n     */\n    MetaDesign(LibraryInterface* library,\n        MessageMediator* messages,\n        QSharedPointer<Design const> design,\n        QSharedPointer<DesignInstantiation const> designInstantiation,\n        QSharedPointer<DesignConfiguration const> designConf,\n        QSharedPointer<MetaInstance> topInstance);\n\n    //! The destructor.\n    ~MetaDesign() = default;\n\n    // Disable copying.\n    MetaDesign(MetaDesign const& rhs) = delete;\n    MetaDesign& operator=(MetaDesign const& rhs) = delete;\n\n    /*!\n     *  Parses a hierarchy of designs and return the list of them.\n     *\n     *    @param [in] library                 The library which is expected to contain the parsed documents.\n     *    @param [in] input\t\t            The starting point for hierarchy parsing.\n     *    @param [in] topComponentView        The active view of the component in input.\n     */\n    static QList<QSharedPointer<MetaDesign> > parseHierarchy(LibraryInterface* library,\n        GenerationTuple input,\n        QSharedPointer<View> topComponentView);\n    \n    /*!\n     *  Returns the meta instance of the top component. Must exists even if is the topmost in hierarchy.\n     */\n    QSharedPointer<MetaInstance> getTopInstance() const {return topInstance_;}\n    \n    /*!\n     *  Returns map of the parsed meta instances within the design. Keyed with instance names.\n     */\n    QSharedPointer<QMap<QString,QSharedPointer<MetaInstance> > > getInstances() const {return instances_;}\n    \n    /*!\n     *  Returns list of the parsed meta interconnections within the design.\n     */\n    QSharedPointer<QList<QSharedPointer<MetaInterconnection> > > getInterconnections() const {return interconnections_;}\n    \n    /*!\n    *  Returns list of the parsed ad-hoc wires within the design.\n     */\n    QSharedPointer<QList<QSharedPointer<MetaWire> > > getAdHocWires() const {return adHocWires_;}\n\nprivate:\n\n    /*!\n     *  Finds the component instances within the design, also determines if they are hierarchical.\n     */\n    void findInstances();\n\n    /*!\n     *  Parses the design_: The instances, the interconnections, the ad-hocs.\n     */\n    void parseDesign();\n\n    /*!\n     *  Parses the design parameters. Also applies them to the meta parameters.\n     */\n    void parseDesignParamaters();\n    \n    /*!\n     *  Parses parameters within a list.\n     *\n     *    @param [inout] subList              The list which parameters are parsed.\n     *    @param [in] input\t\t            The list of parameters which may affect the parsing result. May be null.\n     *    @param [in] topComponentView        The list of overrides for the parsed parameters. May be null.\n     */\n    static void parseParameters(\n        QSharedPointer<QList<QSharedPointer<Parameter> > > subList,\n        QSharedPointer<QList<QSharedPointer<Parameter> > > topList,\n        QSharedPointer<QList<QSharedPointer<ConfigurableElementValue> > > cevs);\n\n    /*!\n     *  Parses instances in the design_.\n     */\n    void parseInstances();\n\n    /*!\n     *  Parses interconnections in the design_.\n     */\n    void parseInterconnections();\n    \n    /*!\n     *  Assigns ports of mInterface with the wires of mInterconnect.\n     *\n     *    @param [in] mInterface              The interface which will have the ports.\n     *    @param [in] mIterconnect\t\t    The interconnect which will have the wires.\n     *    @param [in] isHierarchical          True, if mInterface is in topInstance, else false.\n     */\n    void wireInterfacePorts(QSharedPointer<MetaInterface> mInterface,\n        QSharedPointer<MetaInterconnection> mIterconnect, bool isHierarchical);\n    \n    /*!\n     *  Associate the selected meta port with wire.\n     *\n     *    @param [in] metaInterconnect    Meta interconnection containing the wire.\n     *    @param [in] portAbstraction     Connected logical port.\n     *    @param [in] assignment          Meta assignment for the port.\n     *    @param [in] connectedWires      List of already connected meta wire.\n     *    @param [in] isHierarchical      Flag for hierarchical ports.\n     *    @param [in] metaPort            The selected meta port.\n     */\n    void associateWithWire(QSharedPointer<MetaInterconnection> metaInterconnect,\n        QSharedPointer<PortAbstraction> portAbstraction, QSharedPointer<MetaPortAssignment> assignment,\n        QList<QSharedPointer<MetaWire> >& connectedWires, bool isHierarchical, QSharedPointer<MetaPort> metaPort);\n\n    /*!\n     *  Associate the selected meta port with transactional.\n     *\n     *    @param [in] metaInterconnect            Meta interconnection containing the wire.\n     *    @param [in] portAbstraction             Connected logical port.\n     *    @param [in] assignment                  Meta assignment for the port.\n     *    @param [in] connectedTransactionals     List of already connected meta transactionals.\n     *    @param [in] isHierarchical              Flag for hierarchical ports.\n     *    @param [in] metaPort                    The selected meta port.\n     */\n    void associateWithTransactional(QSharedPointer<MetaInterconnection> metaInterconnect,\n        QSharedPointer<PortAbstraction> portAbstraction, QSharedPointer<MetaPortAssignment> assignment,\n        QList<QSharedPointer<MetaTransactional> >& connectedTransactionals, bool isHierarchical,\n        QSharedPointer<MetaPort> metaPort);\n\n    /*!\n     *  Parses ad-hocs in the design_.\n     */\n    void parseAdHocs();\n    \n    /*!\n     *  Parses a port assignment for an ad-hoc port.\n     *\n     *    @param [in] mPort                   The port which get an assignment.\n     *    @param [in] connection\t\t        The interconnect which is associated with IP-XACT port corresponding mPrt.\n     *    @param [in] mWire                   Wire which will be referred by the assignment.\n     *    @param [in] isHierarchical          True, if this connection is hierarchical.\n     *    @param [in] wireName                Name of mWire.\n     *    @param [in] matchingPartSelect      The part select that affects the bounds of the assignment.\n     */\n    void parseAdHocAssignmentForPort(QSharedPointer<MetaPort> mPort,\n        QSharedPointer<AdHocConnection> connection,\n        QSharedPointer<MetaWire> mWire,\n        bool isHierarchical,\n        QString wireName,\n        QSharedPointer<PartSelect> matchingPartSelect);\n    \n    /*!\n     *  Finds hierarchical ports within an ad-hoc interconnection.\n     *\n     *    @param [in] connection\t\t        The interconnect which ports are beign searched.\n     *    @param [out] foundPorts             Every port found for the interconnection.\n     *    @param [out] foundHierPorts         Every hierarchical port found for the interconnection.\n     *    @param [out] matchingPartSelects    The part select that affects the bounds of the assignment.\n     */\n    void findHierarchicalPortsInAdHoc(QSharedPointer<AdHocConnection> connection,\n        QList<QSharedPointer<MetaPort> > &foundPorts,\n        QList<QSharedPointer<MetaPort> > &foundHierPorts,\n        QList<QSharedPointer<PartSelect> > &matchingPartSelects);\n    \n    /*!\n     *  Finds ports within an ad-hoc interconnection.\n     *\n     *    @param [in] connection\t\t        The interconnect which ports are beign searched.\n     *    @param [out] foundPorts             Every port found for the interconnection.\n     *    @param [out] matchingPartSelects    The part select that affects the bounds of the assignment.\n     */\n    void findPortsInAdHoc(QSharedPointer<AdHocConnection> connection,\n        QList<QSharedPointer<MetaPort> > &foundPorts,\n        QList<QSharedPointer<PartSelect> > &matchingPartSelects);\n\n\n    /*!\n     *  Removes assignments without wire or default value from down ports of the topInstance_ and\n     *  up ports of others. Also culls cases where the wire has only one attached port assignment.\n     */\n    void removeUnconnectedInterfaceAssignments();\n\n    /*!\n     *  Removes assignments without wire or default value from down ports of the topInstance_ and\n     *  up ports of others. Also culls cases where the wire has only one attached port assignment\n     */\n    void removeUnconnectedAdHocAssignments();\n    \n    /*!\n     *  Tries to find hierarchy from mInstance for the active view and then create a sub design.\n     *  If sub design is created, it shall be appended to the list of the sub designs.\n     *\n     *    @param [in] mInstance\t\t        The instance, which component is expected to have needed instantiations.\n     *                                          Consequently, will be the top instance of the created meta design.\n     */\n    void findHierarchy(QSharedPointer<MetaInstance> mInstance);\n\n    /*!\n     *  Finds a design from a design instantiation.\n     *\n     *    @param [in] dis                     Where from the design is searched.\n     *\n     *    @return The found design, or null.\n     */\n    QSharedPointer<Design> findDesignFromInstantiation(QSharedPointer<DesignInstantiation> designInstantiation,\n        QSharedPointer<DesignConfiguration> configurationInstantiation);\n\n    /*!\n     *  Finds a design and design configuration from a design instantiation.\n     *\n     *    @param [in] configurationInstantiation                    Where from the design configuration is searched.\n     *\n     *    @return The found design configuration, or null.\n     */\n    QSharedPointer<DesignConfiguration> findDesignConfigurationFromInsantiation(\n        QSharedPointer<DesignConfigurationInstantiation> configurationInstantiation);\n\n\n    /*!\n     *  Compares new bounds to existing bounds of the wire and then assigns the largest combination of two\n     *  If even one of the existing bounds is missing, candidates will replace them both.\n     *\n     *    @param [in] wire                    The wire which bounds are possibly enlarged.\n     *    @param [in] boundCand\t\t        The candidate for new bounds.\n     */\n    void assignLargerBounds(QSharedPointer<MetaWire> wire, QPair<QString,QString> const& boundCand);\n\n    //-----------------------------------------------------------------------------\n    // Data.\n    //-----------------------------------------------------------------------------\n\n    //! The component library.\n    LibraryInterface* library_;\n\n    //! The messages.\n    MessageMediator* messages_;\n\n    //! The design to parse.\n    QSharedPointer<Design const> design_;\n\n    //! The design instantiation that matches the design.\n    QSharedPointer<DesignInstantiation const> designInstantiation_;\n\n    //! The design configuration to parse.\n    QSharedPointer<DesignConfiguration const> designConf_;\n\n    //! The parsed meta instance of the top component.\n    QSharedPointer<MetaInstance> topInstance_;\n\n    //! The parsed design parameters.\n    QSharedPointer<QList<QSharedPointer<Parameter> > > parameters_;\n\n    //! The parsed instances in the design_, keyed with their names.\n    QSharedPointer<QMap<QString,QSharedPointer<MetaInstance> > > instances_;\n    //! The parsed interconnections of the design_.\n    QSharedPointer<QList<QSharedPointer<MetaInterconnection> > > interconnections_;\n    //! The parsed ad-hoc connections of the design_.\n    QSharedPointer<QList<QSharedPointer<MetaWire> > > adHocWires_;\n\n    //! The list of all parsed designs that are below the current top are in this list.\n    QList<QSharedPointer<MetaDesign> > subDesigns_;\n};\n\n#endif // METADESIGN_H\n"
  },
  {
    "path": "Plugins/common/HDLParser/MetaInstance.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: MetaInstance.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Janne Virtanen\n// Date: 11.01.2017\n//\n// Description:\n// An instance of a component instance within a hierarchy with its parameters and interfaces parsed.\n//-----------------------------------------------------------------------------\n\n#include \"MetaInstance.h\"\n\n#include <KactusAPI/include/MessageMediator.h>\n\n#include <KactusAPI/include/LibraryInterface.h>\n\n#include <IPXACTmodels/AbstractionDefinition/AbstractionDefinition.h>\n#include <IPXACTmodels/AbstractionDefinition/PortAbstraction.h>\n#include <IPXACTmodels/Component/BusInterface.h>\n#include <IPXACTmodels/Component/PortMap.h>\n\n//-----------------------------------------------------------------------------\n// Function: MetaInstance::MetaInstance()\n//-----------------------------------------------------------------------------\nMetaInstance::MetaInstance(QSharedPointer<ComponentInstance> componentInstance,\n    LibraryInterface* library,\n    MessageMediator* messages,\n    QSharedPointer<Component> component,\n    QSharedPointer<View> activeView) :\nMetaComponent(messages, component, activeView),\n    componentInstance_(componentInstance),\n    library_(library),\n    interfaces_(new QMap<QString,QSharedPointer<MetaInterface> >)\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function:  MetaInstance::parseInstance()\n//-----------------------------------------------------------------------------\nvoid MetaInstance::parseInstance()\n{\n    // Initialize the parameter parsing: Find parameters from both the instance and the top component.\n    QSharedPointer<QList<QSharedPointer<Parameter> > > ilist(getParameters());\n    QSharedPointer<ListParameterFinder> instanceFinder(new ListParameterFinder);\n    instanceFinder->setParameterList(ilist);\n\n    // Create parser using the applicable finders.\n    IPXactSystemVerilogParser instanceParser(instanceFinder);\n\n    // Parse the interfaces and ports.\n    parseInterfaces();\n    parsePorts(instanceParser);\n    parsePortAssignments(instanceParser);\n\n    parseMetaParameters(); \n}\n\n//-----------------------------------------------------------------------------\n// Function: MetaInstance::parseExpression()\n//-----------------------------------------------------------------------------\nQString MetaInstance::parseExpression(IPXactSystemVerilogParser const& parser,  QString const& expression)\n{\n    QString value = parser.parseExpression(expression);\n\n    if (value == QStringLiteral(\"x\"))\n    {\n        return QStringLiteral(\"0\");\n    }\n\n    return value;\n}\n\n//-----------------------------------------------------------------------------\n// Function: MetaInstance::parseInterfaces()\n//-----------------------------------------------------------------------------\nvoid MetaInstance::parseInterfaces()\n{\n    foreach(QSharedPointer<BusInterface> busInterface, *getComponent()->getBusInterfaces())\n    {\n        // Find the correct abstraction type.        \n        QString viewName = QString();        \n        if (getActiveView())\n        {\n            viewName = getActiveView()->name();\n        }\n\n        QSharedPointer<AbstractionType> absType = busInterface->getAbstractionContainingView(viewName);\n        if (!absType)\n        {\n            messages_->showError(\n                QObject::tr(\"Component %1: Bus interface %2 does not have an abstraction type.\")\n                .arg(getComponent()->getVlnv().toString(), busInterface->name()));\n            continue;\n        }\n\n        // An abstraction definition is needed. It comes through VLNV reference.\n        QSharedPointer<ConfigurableVLNVReference> absRef = absType->getAbstractionRef();\n        if (!absRef)\n        {\n            messages_->showError(\n                QObject::tr(\"Component %1: Abstraction type in bus interface %2 does not have abstraction reference.\")\n                .arg(getComponent()->getVlnv().toString(), busInterface->name()));\n            continue;\n        }\n\n        // Find the abstraction definition from the library.\n        QSharedPointer<AbstractionDefinition> absDef = library_->getModel<AbstractionDefinition>(*absRef);\n        if (!absDef)\n        {\n            messages_->showError(\n                QObject::tr(\"Component %1: Abstraction definition for bus interface %2 was not found: %3\")\n                .arg(getComponent()->getVlnv().toString(), busInterface->name(), absRef->toString()));\n            continue;\n        }\n\n        // Create \"our\" interface for each IP-XACT interface. Take the relevant values.\n        QSharedPointer<MetaInterface> mInterface(new MetaInterface);\n        mInterface->interface_ = busInterface;\n        mInterface->absType_ = absType;\n        mInterface->absDef_ = absDef;\n\n        // Insert to the interface to the list.\n        interfaces_->insert(busInterface->name(), mInterface);\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: MetaInstance::parsePorts()\n//-----------------------------------------------------------------------------\nvoid MetaInstance::parsePorts(IPXactSystemVerilogParser const& parser)\n{\n    foreach (QSharedPointer<Port> cport, *getComponent()->getPorts())\n    {        \n        QSharedPointer<MetaPort> mPort(new MetaPort);\n        mPort->port_ = cport;\n        mPort->arrayBounds_.first = \"\";\n        mPort->arrayBounds_.second = \"\";\n        mPort->width_ = \"\";\n        mPort->vectorBounds_.first = parseExpression(parser, cport->getLeftBound());\n        mPort->vectorBounds_.second = parseExpression(parser, cport->getRightBound());\n        mPort->defaultValue_ = parseExpression(parser, cport->getDefaultValue());\n\n        mPort->isWire_ = false;\n        mPort->isTransactional_ = false;\n\n        if (cport->getWire())\n        {\n            mPort->isWire_ = true;\n            mPort->arrayBounds_.first = parseExpression(parser, cport->getArrayLeft());\n            mPort->arrayBounds_.second = parseExpression(parser, cport->getArrayRight());\n        }\n        else if (cport->getTransactional())\n        {\n            mPort->isTransactional_ = true;\n            mPort->width_ = parseExpression(parser, cport->getTransactional()->getBusWidth());\n        }\n\n        getPorts()->insert(cport->name(), mPort);\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: MetaInstance::parsePortAssignments()\n//-----------------------------------------------------------------------------\nvoid MetaInstance::parsePortAssignments(IPXactSystemVerilogParser const& parser)\n{\n    for (QSharedPointer<MetaInterface> mInterface: *interfaces_)\n    {\n        for (QSharedPointer<PortMap> pMap: *mInterface->absType_->getPortMaps())\n        {\n            if (!pMap->getPhysicalPort() || !pMap->getLogicalPort() ||\n                !getPorts()->contains(pMap->getPhysicalPort()->name_))\n            {\n                continue;\n            }\n\n            // The physical port must match an existing component port.\n            QSharedPointer<MetaPort> mPort = getPorts()->value(pMap->getPhysicalPort()->name_);\n\n            // The abstraction definition must have a port abstraction with the same name.\n            QSharedPointer<PortAbstraction> portAbstraction = mInterface->absDef_->getPort(pMap->getLogicalPort()->name_);\n\n            if (!portAbstraction)\n            {\n                messages_->showError(QObject::tr(\"Component %1, Bus interface %2: Port abstraction\"\n                    \" was not found for logical port %3 at abstraction definition %4.\")\n                    .arg(getComponent()->getVlnv().toString(),\n                    mInterface->interface_->name(),\n                    pMap->getLogicalPort()->name_,\n                    mInterface->absDef_->getVlnv().toString()));\n                continue;\n            }\n\n            // Parse the port map bounds.\n            QPair<QString, QString> logicalBounds = logicalPortBoundsInMapping(parser, pMap);\n            QPair<QString, QString> physicalBounds = physicalPortBoundsInMapping(parser, pMap);\n\n            // If physical bounds do not exist, they are the same as the port bounds.\n            if (physicalBounds.first.isEmpty() || physicalBounds.second.isEmpty())\n            {\n                physicalBounds = mPort->vectorBounds_;\n            }\n\n            // If logical bounds do not exist, they are the same as the physical bounds.\n            if (logicalBounds.first.isEmpty() || logicalBounds.second.isEmpty())\n            {\n                // Pick the total width of the physical bounds.\n                int left = parseExpression(parser, physicalBounds.first).toInt();\n                int right = parseExpression(parser, physicalBounds.second).toInt();\n\n                // This is [abs(physical.left  physical.right):0]\n                logicalBounds.first = QString::number(abs(left - right));\n                logicalBounds.second = QStringLiteral(\"0\");\n            }\n\n            // Every mapping using the port creates a new assignment for the port.\n            QSharedPointer<MetaPortAssignment> mUpPortAssignment(new MetaPortAssignment);\n            mUpPortAssignment->mappedInterface_ = mInterface;\n            mUpPortAssignment->logicalBounds_ = logicalBounds;\n            mUpPortAssignment->physicalBounds_ = physicalBounds;\n            mUpPortAssignment->invert_ = pMap->getInvert().toBool();\n\n            // The default value comes from the port abstraction.\n            mUpPortAssignment->defaultValue_ = portAbstraction->getDefaultValue();\n\n            // Create a copy of the assignments.\n            QSharedPointer<MetaPortAssignment> mDownPortAssignment(new MetaPortAssignment(*mUpPortAssignment));\n\n            // There must be an assignment for both directions in hierarchy.\n            mPort->upAssignments_.insert(pMap->getLogicalPort()->name_, mUpPortAssignment);\n            mPort->downAssignments_.insert(pMap->getLogicalPort()->name_, mDownPortAssignment);\n\n            // Associate the meta port with the interface.\n            mInterface->ports_.insert(mPort->port_->name(), mPort);\n        }\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: MetaInstance::logicalPortBoundsInMapping()\n//-----------------------------------------------------------------------------\nQPair<QString, QString> MetaInstance::logicalPortBoundsInMapping(IPXactSystemVerilogParser const& parser,\n    QSharedPointer<PortMap> portMap) const\n{\n    QPair<QString, QString> bounds;\n\n    QSharedPointer<PortMap::LogicalPort> logicalPort = portMap->getLogicalPort();\n\n    if (logicalPort && logicalPort->range_)\n    {\n        // Pick the range expressions as the logical bounds.\n        bounds.first = parseExpression(parser, logicalPort->range_->getLeft());\n        bounds.second = parseExpression(parser, logicalPort->range_->getRight());\n    }\n\n    return bounds;\n}\n\n//-----------------------------------------------------------------------------\n// Function: MetaInstance::physicalPortBoundsInMapping()\n//-----------------------------------------------------------------------------\nQPair<QString, QString> MetaInstance::physicalPortBoundsInMapping(IPXactSystemVerilogParser const& parser,\n    QSharedPointer<PortMap> portMap) const\n{\n    QPair<QString, QString> bounds;\n\n    QSharedPointer<PortMap::PhysicalPort> physPort = portMap->getPhysicalPort();\n\n    if (physPort && physPort->partSelect_)\n    {\n        // Pick the part select expressions as the total width of the physical bounds.\n        bounds.first = parseExpression(parser, physPort->partSelect_->getLeftRange());\n        bounds.second = parseExpression(parser, physPort->partSelect_->getRightRange());\n    }\n\n    return bounds;\n}\n"
  },
  {
    "path": "Plugins/common/HDLParser/MetaInstance.h",
    "content": "//-----------------------------------------------------------------------------\n// File: MetaInstance.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Janne Virtanen\n// Date: 11.01.2017\n//\n// Description:\n// An instance of a component instance within a hierarchy with its parameters and interfaces parsed.\n//-----------------------------------------------------------------------------\n\n#ifndef METAINSTANCE_H\n#define METAINSTANCE_H\n\n#include <Plugins/common/HDLParser/MetaComponent.h>\n\n#include <KactusAPI/include/ListParameterFinder.h>\n#include <KactusAPI/include/IPXactSystemVerilogParser.h>\n\nclass LibraryInterface;\nclass PortMap;\nclass MessageMediator;\n\n//-----------------------------------------------------------------------------\n// An instance of a component instance within a hierarchy with its parameters and interfaces parsed.\n//-----------------------------------------------------------------------------\nclass MetaInstance : public MetaComponent\n{\npublic:\n\n\t/*!\n\t *  The constructor.\n     *\n     *    @param [in] componentInstance   The instance under inspection.\n     *    @param [in] library             The library which is expected to contain the parsed documents.\n     *    @param [in] messages            For message output.\n     *    @param [in] component           The instantiated component.\n     *    @param [in] activeView          The active view for the component. May be null.\n\t */\n    MetaInstance(\n        QSharedPointer<ComponentInstance> componentInstance,\n        LibraryInterface* library,\n        MessageMediator* messages,\n        QSharedPointer<Component> component,\n        QSharedPointer<View> activeView);\n\n\t//! The destructor.\n    virtual ~MetaInstance() = default;\n    \n    // Disable copying.\n    MetaInstance(MetaInstance const& rhs) = delete;\n    MetaInstance& operator=(MetaInstance const& rhs) = delete;\n\n\t/*!\n\t *  Parses the interfaces and ports for explicit values of this particular meta instance.\n     *\n     */\n    void parseInstance();\n\n    /*!\n    *   Parses the expression using the parser and returns the result.\n    */\n    static QString parseExpression(IPXactSystemVerilogParser const& parser, QString const& expression);\n    \n    /*!\n     *  Returns list of culled interfaces.\n     */\n    QSharedPointer<QMap<QString,QSharedPointer<MetaInterface> > > getInterfaces() { return interfaces_; }\n    \n    /*!\n     *  Returns the associated component instance.\n     */\n    QSharedPointer<ComponentInstance> getComponentInstance() const { return componentInstance_; }\n\nprivate:\n    \n    /*!\n     *  Parse the interfaces of the component instance.\n     */\n    void parseInterfaces();\n    \n    /*!\n     *  Culls and parses the ports of the component.\n     *\n     *    @param [in] parser          Used to parse expressions.\n     */\n    void parsePorts(IPXactSystemVerilogParser const& parser);\n    \n    /*!\n     *  Creates assignments for port maps.\n     *\n     *    @param [in] parser          Used to parse expressions.\n     */\n    void parsePortAssignments(IPXactSystemVerilogParser const& parser);\n\n    /*!\n     *  Finds the mapped logical port bounds for a port map.\n     *\n     *    @param [in] parser          Used for parsing the bounds.\n     *    @param [in] portMap         The port map for the which to find the logical bounds.\n     *\n     *    @return The logical port bounds for the port map in an instance.\n     */\n\tQPair<QString, QString> logicalPortBoundsInMapping(IPXactSystemVerilogParser const& parser,\n        QSharedPointer<PortMap> portMap) const;\n    \n    /*!\n     *  Finds the mapped physical port bounds for a port map.\n     *\n     *    @param [in] parser          Used for parsing the bounds.\n     *    @param [in] portMap         The port map for the which to find the physical bounds.\n     *\n     *    @return The physical port bounds for the port map in an instance.\n     */\n    QPair<QString, QString> physicalPortBoundsInMapping(IPXactSystemVerilogParser const& parser,\n        QSharedPointer<PortMap> portMap) const;\n\n    //-----------------------------------------------------------------------------\n    // Data.\n    //-----------------------------------------------------------------------------\n\n    //! The matching IP-XACT component instance.\n    QSharedPointer<ComponentInstance> componentInstance_;\n\n    //! The component library.\n    LibraryInterface* library_;\n\n    //! The parsed interfaces of the instance, keyed with its name.\n    QSharedPointer<QMap<QString, QSharedPointer<MetaInterface> > > interfaces_;\n};\n\n#endif // METAINSTANCE_H\n"
  },
  {
    "path": "Plugins/common/LanguageHighlighter.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: LanguageHighlighter.h\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Esko Pekkarinen\n// Date: 15.02.2017\n//\n// Description:\n// Base class for language-specific highlighters.\n//-----------------------------------------------------------------------------\n\n#include \"LanguageHighlighter.h\"\n\n#include <QRegularExpressionMatch>\n\n//-----------------------------------------------------------------------------\n// Static member initializations.\n//-----------------------------------------------------------------------------\n\n//! Default style definitions.\nHighlightStyleDesc const LanguageHighlighter::DEFAULT_STYLES[STYLE_COUNT] =\n{\n    HighlightStyleDesc(Qt::blue, false, false),\n    HighlightStyleDesc(Qt::blue, false, false),\n    HighlightStyleDesc(QColor(163, 21, 21), false, false),\n    HighlightStyleDesc(Qt::darkGreen, false, false),\n    HighlightStyleDesc(Qt::darkGreen, false, false),\n    HighlightStyleDesc(Qt::blue, false, false),\n    HighlightStyleDesc(Qt::darkMagenta, true, false),\n    HighlightStyleDesc(Qt::darkMagenta, false, false)\n};\n\n//-----------------------------------------------------------------------------\n// Function: LanguageHighlighter::getStyleName()\n//-----------------------------------------------------------------------------\nQString LanguageHighlighter::getStyleName(StyleType type)\n{\n    static const QStringList styles = QStringList() \n        << \"Keywords\"\n        << \"Preprocessor\"\n        << \"Strings\"\n        << \"SinglelineComments\"\n        << \"MultilineComments\"\n        << \"APITypes\"\n        << \"APIFunc\"\n        << \"LanguageSpecific\";\n\n    if (type > STYLE_COUNT)\n    {\n        return QString();\n    }\n\n    return styles.at(type);\n}\n\n//-----------------------------------------------------------------------------\n// Function: LanguageHighlighter::LanguageHighlighter()\n//-----------------------------------------------------------------------------\nLanguageHighlighter::LanguageHighlighter(QTextDocument* parent): QSyntaxHighlighter(parent),\n    highlightRules_(),\n    commentStartExp_(\"/\\\\*\"),\n    commentEndExp_(\"\\\\*/\")\n{\n    for (int i = 0; i < STYLE_COUNT; ++i)\n    {\n        setStyle(static_cast<StyleType>(i), DEFAULT_STYLES[i]);\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: LanguageHighlighter::setStyle()\n//-----------------------------------------------------------------------------\nvoid LanguageHighlighter::setStyle(StyleType type, HighlightStyleDesc const& styleDesc)\n{\n    Q_ASSERT(type < STYLE_COUNT);\n\n    if (styleDesc.bold)\n    {\n        m_styleFormats[type].setFontWeight(QFont::Bold);\n    }\n    else\n    {\n        m_styleFormats[type].setFontWeight(QFont::Normal);\n    }\n\n    m_styleFormats[type].setFontItalic(styleDesc.italic);\n    m_styleFormats[type].setForeground(QBrush(styleDesc.color));\n}\n\n//-----------------------------------------------------------------------------\n// Function: LanguageHighlighter::addRule()\n//-----------------------------------------------------------------------------\nvoid LanguageHighlighter::addRule(QRegularExpression const& pattern, LanguageHighlighter::StyleType style)\n{\n    HighlightRule rule;\n    rule.pattern = pattern;\n    rule.format = &m_styleFormats[style];\n\n    highlightRules_.append(rule);\n}\n\n//-----------------------------------------------------------------------------\n// Function: LanguageHighlighter::addMultilineCommentRule()\n//-----------------------------------------------------------------------------\nvoid LanguageHighlighter::addMultilineCommentRule(QRegularExpression const& startPattern, \n    QRegularExpression const& endPattern)\n{\n    commentStartExp_ = startPattern;\n    commentEndExp_ = endPattern;\n}\n\n//-----------------------------------------------------------------------------\n// Function: LanguageHighlighter::highlightBlock()\n//-----------------------------------------------------------------------------\nvoid LanguageHighlighter::highlightBlock(QString const& text)\n{\n    for (HighlightRule const& rule : highlightRules_)\n    {\n        int index = text.indexOf(rule.pattern);\n\n        while (index >= 0)\n        {\n            int length = rule.pattern.match(text).capturedLength();\n            setFormat(index, length, *rule.format);\n            index = text.indexOf(rule.pattern, index + length);\n        }\n    }\n\n    setCurrentBlockState(0);\n\n    int startIndex = 0;\n    int startLength = 0;\n    if (previousBlockState() != 1)\n    {\n        QRegularExpressionMatch match = commentStartExp_.match(text);\n        startIndex = match.capturedStart();\n        startLength = match.capturedLength();\n    }\n\n    while (startIndex >= 0)\n    {\n        QRegularExpressionMatch match = commentEndExp_.match(text, startIndex + startLength);\n        int endIndex = match.capturedStart();\n        int commentLength;\n\n        if (endIndex == -1)\n        {\n            setCurrentBlockState(1);\n            commentLength = text.length() - startIndex;\n        }\n        else\n        {\n            commentLength = endIndex - startIndex + match.capturedLength();\n        }\n\n        setFormat(startIndex, commentLength, m_styleFormats[MULTI_LINE_COMMENT]);\n        startIndex = text.indexOf(commentStartExp_, startIndex + commentLength);\n    }\n}"
  },
  {
    "path": "Plugins/common/LanguageHighlighter.h",
    "content": "//-----------------------------------------------------------------------------\n// File: LanguageHighlighter.h\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Esko Pekkarinen\n// Date: 15.02.2017\n//\n// Description:\n// Base class for language-specific highlighters.\n//-----------------------------------------------------------------------------\n\n#ifndef LANGUAGEHIGHLIGHTER_H\n#define LANGUAGEHIGHLIGHTER_H\n\n#include <common/widgets/assistedTextEdit/HighlightStyleDesc.h>\n\n#include <QSyntaxHighlighter>\n#include <QTextEdit>\n#include <QString>\n#include <QVector>\n#include <QTextCharFormat>\n#include <QRegularExpression>\n\n//-----------------------------------------------------------------------------\n//! LanguageHighlighter class.\n//-----------------------------------------------------------------------------\nclass LanguageHighlighter : public QSyntaxHighlighter\n{\n    Q_OBJECT\n\npublic:\n\n    //-----------------------------------------------------------------------------\n    //! StyleType enumeration.\n    //-----------------------------------------------------------------------------\n    enum StyleType\n    {\n        KEYWORD = 0,\n        PREPROCESSOR,\n        STRING,\n        SINGLE_LINE_COMMENT,\n        MULTI_LINE_COMMENT,\n        API_DATA_TYPES,\n        API_FUNCTIONS,\n        LANGUAGE_SPECIFIC,\n        STYLE_COUNT\n    };\n\n    //! Default styles.\n    static HighlightStyleDesc const DEFAULT_STYLES[STYLE_COUNT];\n   \n    /*!\n     *  Gets the name for the given style type.\n     *\n     *    @param [in] type   The type whose name to find.\n     *\n     *    @return The name for the type.\n     */\n    static QString getStyleName(StyleType type);\n\n    /*!\n     *  Constructor.\n     *\n     *    @param [in] parent The parent text document.\n     */\n    explicit LanguageHighlighter(QTextDocument* parent);\n\n    /*!\n     *  Destructor.\n     */\n    virtual ~LanguageHighlighter() = default;\n\n    /*!\n     *  Sets the highlight style as a global style for all MCAPI highlighters.\n     *\n     *    @param [in] type       The style to set.\n     *    @param [in] styleDesc  The style description.\n     *\n     *      @remarks The styles must be taken into use by calling applyStyles().\n     */\n    void setStyle(StyleType type, HighlightStyleDesc const& styleDesc);\n    \n    /*!\n     *  Add a highlighting rule.\n     *\n     *    @param [in] pattern     Pattern to highlight.\n     *    @param [in] style       Style to apply to pattern.\n     */\n    void addRule(QRegularExpression const& pattern, LanguageHighlighter::StyleType style);\n\n    /*!\n     * Add highlighting rule for multiline comments. Formatting style for the comment is set with addRule().\n     *\n     *    @param [in] startPattern     Pattern for start of multiline comment.\n     *    @param [in] endPattern       Pattern for end of multiline comment.\n     */\n     void addMultilineCommentRule(QRegularExpression const& startPattern,\n        QRegularExpression const& endPattern);\n\nprotected:\n    /*!\n     *  Highlights a block of text.\n     */\n    void highlightBlock(QString const& text);\n\n    //-----------------------------------------------------------------------------\n    //! HighlightRule structure.\n    //-----------------------------------------------------------------------------\n    struct HighlightRule\n    {\n        QRegularExpression pattern;            //!< The pattern to which the rule is applied.\n        QTextCharFormat* format;    //!< The formatting for the rule.\n    };\n\nprivate:\n\n    // Disable copying.\n    LanguageHighlighter(LanguageHighlighter const& rhs);\n    LanguageHighlighter& operator=(LanguageHighlighter const& rhs);\n\n    //! The rules for highlighting.\n    QVector<HighlightRule> highlightRules_;\n\n    //! Comment start expression.\n    QRegularExpression commentStartExp_;\n\n    //! Comment end expression.\n    QRegularExpression commentEndExp_;\n\n    //! Style formats.\n    QTextCharFormat m_styleFormats[STYLE_COUNT];\n};\n\n//-----------------------------------------------------------------------------\n\n#endif // LANGUAGEHIGHLIGHTER_H\n"
  },
  {
    "path": "Plugins/common/PluginConfigurationManager.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: PluginConfigurationManager.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 21.04.2023\n//\n// Description:\n// Manager for storing and restoring plugin editor configurations.\n//-----------------------------------------------------------------------------\n\n#include \"PluginConfigurationManager.h\"\n\n//-----------------------------------------------------------------------------\n// Function: PluginConfigurationManager::PluginConfigurationManager()\n//-----------------------------------------------------------------------------\nPluginConfigurationManager::PluginConfigurationManager(IPluginUtility* utility):\nConfigurationManager(utility->getLibraryInterface()),\nutility_(utility)\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: PluginConfigurationManager::printError()\n//-----------------------------------------------------------------------------\nvoid PluginConfigurationManager::printError(QString const& errorMessage) const\n{\n    utility_->printError(errorMessage);\n}\n"
  },
  {
    "path": "Plugins/common/PluginConfigurationManager.h",
    "content": "//-----------------------------------------------------------------------------\n// File: PluginConfigurationManager.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 21.04.2023\n//\n// Description:\n// Manager for storing and restoring plugin editor configurations.\n//-----------------------------------------------------------------------------\n\n#ifndef PLUGINCONFIGURATIONMANAGER_H\n#define PLUGINCONFIGURATIONMANAGER_H\n\n#include <KactusAPI/include/IPluginUtility.h>\n\n#include <Plugins/common/ConfigurationManager.h>\n\n//-----------------------------------------------------------------------------\n//! Manager for storing and restoring plugin editor configurations.\n//-----------------------------------------------------------------------------\nclass PluginConfigurationManager : public ConfigurationManager\n{\n\npublic:\n    \n    /*!\n     *  The constructor.\n     */\n    PluginConfigurationManager(IPluginUtility* utility);\n    \n    /*!\n     * The destructor.\n     */\n    ~PluginConfigurationManager() = default;\n\nprivate:\n\n    /*!\n     *  Print the selected error.\n     *\n     *    @param [in] errorMessage    The selected error message.\n     */\n    virtual void printError(QString const& errorMessage) const override final;\n\n    //-----------------------------------------------------------------------------\n    // Data.\n    //-----------------------------------------------------------------------------\n\n    //! Utility for plugins.\n    IPluginUtility* utility_;\n};\n\n#endif // CONFIGURATIONMANAGER_H\n"
  },
  {
    "path": "Plugins/common/PortSorter/InterfaceDirectionNameSorter.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: InterfaceDirectionNameSorter.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Esko Pekkarinen\r\n// Date: 05.08.2014\r\n//\r\n// Description:\r\n// Class for sorting component port names by interface, direction and name.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"InterfaceDirectionNameSorter.h\"\r\n#include <IPXACTmodels/Component/BusInterface.h>\r\n#include <IPXACTmodels/Component/Model.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: InterfaceDirectionNameSorter::InterfaceDirectionNameSorter()\r\n//-----------------------------------------------------------------------------\r\nInterfaceDirectionNameSorter::InterfaceDirectionNameSorter()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: InterfaceDirectionNameSorter::InterfaceDirectionNameSorter()\r\n//-----------------------------------------------------------------------------\r\nInterfaceDirectionNameSorter::~InterfaceDirectionNameSorter()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: InterfaceDirectionNameSorter::sortedPortsNames()\r\n//-----------------------------------------------------------------------------\r\nQStringList InterfaceDirectionNameSorter::sortedPortNames(QSharedPointer<Component const> component) const\r\n{\r\n    QStringList portNames;\r\n\r\n    QList<QSharedPointer<Port> > ports = sortedPorts(component);\r\n\r\n    foreach(QSharedPointer<Port> port, ports)\r\n    {\r\n        portNames.append(port->name());\r\n    }\r\n\r\n    return portNames;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: InterfaceDirectionNameSorter::sortedPorts()\r\n//-----------------------------------------------------------------------------\r\nQList<QSharedPointer<Port> > InterfaceDirectionNameSorter::sortedPorts(QSharedPointer<Component const> component) const\r\n{\r\n    if (component.isNull())\r\n    {\r\n        return QList<QSharedPointer<Port> >();\r\n    }\r\n\r\n    QMap<SortKey, QSharedPointer<Port> > sortedPorts;\r\n    foreach(QSharedPointer<Port> port, *component->getPorts())\r\n    {\r\n        QSharedPointer<QList<QSharedPointer<BusInterface> > > busInterfaces =\r\n            component->getInterfacesUsedByPort(port->name());\r\n\r\n        if (busInterfaces->size() == 1)\r\n        {\r\n            SortKey key(busInterfaces->first()->name(), port->getDirection(), port);\r\n            sortedPorts.insert(key, port);\r\n        }\r\n        else if (!busInterfaces->isEmpty())\r\n        {\r\n            SortKey key(\"several\", port->getDirection(), port);\r\n            sortedPorts.insert(key, port);\r\n        }\r\n        else\r\n        {\r\n            SortKey key(\"none\", port->getDirection(), port);\r\n            sortedPorts.insert(key, port);\r\n        }\r\n    }\r\n\r\n    return sortedPorts.values();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: InterfaceDirectionNameSorter::Sorter::operator<()\r\n//-----------------------------------------------------------------------------\r\nbool InterfaceDirectionNameSorter::SortKey::operator<(SortKey const& other) const\r\n{\r\n    if (interfaceName != other.interfaceName)\r\n    {\r\n        if (interfaceName == \"none\")\r\n        {\r\n            return false;\r\n        }\r\n        else if (other.interfaceName == \"none\")\r\n        {\r\n            return true;\r\n        }    \r\n        else if (interfaceName == \"several\")\r\n        {\r\n            return false;\r\n        }\r\n        else if (other.interfaceName == \"several\")\r\n        {\r\n            return true;\r\n        }\r\n        else\r\n        {\r\n            return interfaceName < other.interfaceName;\r\n        }\r\n    }\r\n\r\n    if (portDirection != other.portDirection)\r\n    {\r\n        return portDirection < other.portDirection;\r\n    }\r\n\r\n    int less = port->name().compare(other.port->name(), Qt::CaseInsensitive);\r\n\r\n    if (less == 0)\r\n    {\r\n        return port->name().compare(other.port->name(), Qt::CaseSensitive) < 0;\r\n    }\r\n    \r\n    return less < 0;\r\n}\r\n"
  },
  {
    "path": "Plugins/common/PortSorter/InterfaceDirectionNameSorter.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: InterfaceDirectionNameSorter.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Esko Pekkarinen\r\n// Date: 05.08.2014\r\n//\r\n// Description:\r\n// Class for sorting component port names by interface, direction and name.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef INTERFACEDIRECTIONNAMESORTER_H\r\n#define INTERFACEDIRECTIONNAMESORTER_H\r\n\r\n#include \"PortSorter.h\"\r\n\r\n#include <IPXACTmodels/Component/Component.h>\r\n#include <IPXACTmodels/Component/Port.h>\r\n#include <IPXACTmodels/common/DirectionTypes.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Class for sorting component port names by interface, direction and name.\r\n//-----------------------------------------------------------------------------\r\nclass InterfaceDirectionNameSorter : public PortSorter\r\n{\r\npublic:\r\n\r\n\t//! The constructor.\r\n\tInterfaceDirectionNameSorter();\r\n\r\n\t//! The destructor.\r\n\t~InterfaceDirectionNameSorter();\r\n\r\n    /*!\r\n     *  Gets the sorted port names of a component.\r\n     *\r\n     *    @param [in] component   The component whose port names to find.\r\n     *\r\n     *    @return The sorted port names of a given component.\r\n     */\r\n    virtual QStringList sortedPortNames(QSharedPointer<Component const> component) const;\r\n\r\n    /*!\r\n     *  Gets the sorted ports of a component.\r\n     *\r\n     *    @param [in] component   The component whose ports to find.\r\n     *\r\n     *    @return The sorted ports of a given component.\r\n     */\r\n    virtual QList<QSharedPointer<Port> > sortedPorts(QSharedPointer<Component const> component) const;\r\n\r\nprivate:\r\n\r\n\t// Disable copying.\r\n\tInterfaceDirectionNameSorter(InterfaceDirectionNameSorter const& rhs);\r\n\tInterfaceDirectionNameSorter& operator=(InterfaceDirectionNameSorter const& rhs);\r\n\r\n    //! Helper struct for sorting port names.\r\n    struct SortKey \r\n    {\r\n        QString interfaceName;              //<! The name of the port's interface.\r\n        DirectionTypes::Direction portDirection;   //<! The direction of the port.\r\n        QSharedPointer<Port> port;                   //<! The name of the port.\r\n\r\n        //! Convenience constructor for SortKey.\r\n        SortKey(QString interfaceName, DirectionTypes::Direction direction, QSharedPointer<Port> port) : \r\n            interfaceName(interfaceName), portDirection(direction), port(port)  {}\r\n\r\n        //! Comparison operator for sorting.\r\n        bool operator<(SortKey const& other) const;\r\n    };\r\n};\r\n\r\n#endif // INTERFACEDIRECTIONNAMESORTER_H\r\n"
  },
  {
    "path": "Plugins/common/PortSorter/PortSorter.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: PortSorter.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Esko Pekkarinen\r\n// Date: 05.08.2014\r\n//\r\n// Description:\r\n// Interface for component port name sorter.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef PORTSORTER_H\r\n#define PORTSORTER_H\r\n\r\n#include <QSharedPointer>\r\n#include <QList>\r\n\r\nclass Component;\r\nclass Port;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Interface for component port name sorter.\r\n//-----------------------------------------------------------------------------\r\nclass PortSorter \r\n{\r\npublic:\r\n\r\n\t//! The destructor.\r\n    virtual ~PortSorter() {};\r\n\r\n    /*!\r\n     *  Gets the sorted port names of a component.\r\n     *\r\n     *    @param [in] component   The component whose port names to find.\r\n     *\r\n     *    @return The sorted port names of a given component.\r\n     */\r\n    virtual QStringList sortedPortNames(QSharedPointer<Component const> component) const = 0;\r\n\r\n    /*!\r\n     *  Gets the sorted ports of a component.\r\n     *\r\n     *    @param [in] component   The component whose ports to find.\r\n     *\r\n     *    @return The sorted ports of a given component.\r\n     */\r\n    virtual QList<QSharedPointer<Port> > sortedPorts(QSharedPointer<Component const> component) const = 0;\r\n};\r\n\r\n#endif // PORTSORTER_H\r\n"
  },
  {
    "path": "Plugins/common/SingleCpuRoutesContainer.cpp",
    "content": "﻿//-----------------------------------------------------------------------------\n// File: SingleCpuRoutesContainer.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 09.05.2023\n//\n// Description:\n// Container for routes connected to a single CPU.\n//-----------------------------------------------------------------------------\n\n#include \"SingleCpuRoutesContainer.h\"\n\n//-----------------------------------------------------------------------------\n// Function: SingleCpuRoutesContainer::SingleCpuRoutesContainer()\n//-----------------------------------------------------------------------------\nSingleCpuRoutesContainer::SingleCpuRoutesContainer(QSharedPointer<Cpu> cpu):\nCpuRoutesContainer(),\ncpu_(cpu)\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: SingleCpuRoutesContainer::SingleCpuRoutesContainer()\n//-----------------------------------------------------------------------------\nSingleCpuRoutesContainer::SingleCpuRoutesContainer(const SingleCpuRoutesContainer& other) :\nCpuRoutesContainer(other),\ncpu_(other.getCpu())\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: SingleCpuRoutesContainer::getCpu()\n//-----------------------------------------------------------------------------\nQSharedPointer<Cpu> SingleCpuRoutesContainer::getCpu() const\n{\n    return cpu_;\n}\n\n//-----------------------------------------------------------------------------\n// Function: SingleCpuRoutesContainer::setCpu()\n//-----------------------------------------------------------------------------\nvoid SingleCpuRoutesContainer::setCpu(QSharedPointer<Cpu> newCpu)\n{\n    cpu_ = newCpu;\n}\n"
  },
  {
    "path": "Plugins/common/SingleCpuRoutesContainer.h",
    "content": "//-----------------------------------------------------------------------------\n// File: SingleCpuRoutesContainer.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 09.05.2023\n//\n// Description:\n// Container for routes connected to a single CPU.\n//-----------------------------------------------------------------------------\n\n#ifndef SINGLECPUROUTESCONTAINER_H\n#define SINGLECPUROUTESCONTAINER_H\n\n#include <Plugins/common/CpuRoutesContainer.h>\n\n//-----------------------------------------------------------------------------\n//! Container for routes connected to a single CPU.\n//-----------------------------------------------------------------------------\nclass SingleCpuRoutesContainer : public CpuRoutesContainer\n{\n\npublic:\n\n    /*!\n     *  The constructor.\n     * \n     *    @param [in] CPU     The CPU.\n     */\n    SingleCpuRoutesContainer(QSharedPointer<Cpu> cpu);\n\n    /*!\n     *  The destructor.\n     */\n    virtual ~SingleCpuRoutesContainer() = default;\n\n    /*!\n     *  Copy constructor.\n     */\n    SingleCpuRoutesContainer(const SingleCpuRoutesContainer& other);\n\n    /*!\n     *  Get the containing CPU.\n     *\n     *    @return The containing CPU.\n     */\n    QSharedPointer<Cpu> getCpu() const;\n\n    /*!\n     *  Set the containing CPU.\n     *\n     *    @param [in] newCpu  The new CPU.\n     */\n    void setCpu(QSharedPointer<Cpu> newCpu);\n\nprivate:\n\n    // Disable copying.\n    SingleCpuRoutesContainer& operator=(SingleCpuRoutesContainer const& rhs);\n\n    //-----------------------------------------------------------------------------\n    // Data.\n    //-----------------------------------------------------------------------------\n\n    //! The containing CPU.\n    QSharedPointer<Cpu> cpu_;\n};\n\n#endif // SINGLECPUROUTESCONTAINER_H"
  },
  {
    "path": "Plugins/common/SourceHighlightStyle.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: SourceHighlightStyle.h\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Esko Pekkarinen\n// Date: 15.02.2017\n//\n// Description:\n// Base class for language-specific highlighters.\n//-----------------------------------------------------------------------------\n\n#include \"SourceHighlightStyle.h\"\n\n//-----------------------------------------------------------------------------\n// Function: SourceHighlightStyle::SourceHighlightStyle()\n//-----------------------------------------------------------------------------\nSourceHighlightStyle::SourceHighlightStyle()\n{\n    \n}\n\n//-----------------------------------------------------------------------------\n// Function: SourceHighlightStyle::apply()\n//-----------------------------------------------------------------------------\nvoid SourceHighlightStyle::apply(LanguageHighlighter* highlighter) const\n{\n    foreach(QString const& pattern, keywords())\n    {\n        highlighter->addRule(QRegularExpression(\"\\\\b\" + pattern + \"\\\\b\"), LanguageHighlighter::KEYWORD);\n    }\n\n    foreach(QString const& pattern, preprocessorDirectives())\n    {\n        highlighter->addRule(QRegularExpression(pattern), LanguageHighlighter::PREPROCESSOR);\n    }\n\n    QRegularExpression pattern = QRegularExpression(\"\\\"([^\\\"]|(\\\\\\\\\\\"))*\\\"\");\n    highlighter->addRule(pattern, LanguageHighlighter::STRING);\n\n    pattern = QRegularExpression(\"\\'([^\\']|(\\\\\\\\\\'))*\\'\");\n\n    highlighter->addRule(pattern, LanguageHighlighter::STRING);\n\n    pattern = QRegularExpression(\"//[^\\n]*\");\n    highlighter->addRule(pattern, LanguageHighlighter::SINGLE_LINE_COMMENT);\n\n    applyLanguageSpecificRules(highlighter);\n}\n\n//-----------------------------------------------------------------------------\n// Function: SourceHighlightStyle::applyLanguageSpecificRules()\n//-----------------------------------------------------------------------------\nvoid SourceHighlightStyle::applyLanguageSpecificRules(LanguageHighlighter* /*highlighter*/) const\n{\n    //! Nothing to do in base class.\n}\n"
  },
  {
    "path": "Plugins/common/SourceHighlightStyle.h",
    "content": "//-----------------------------------------------------------------------------\n// File: SourceHighlightStyle.h\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Esko Pekkarinen\n// Date: 15.02.2017\n//\n// Description:\n// Base class for language-specific highlighters.\n//-----------------------------------------------------------------------------\n\n#ifndef SOURECEHIGHLIGHSTYLE_H\n#define SOURECEHIGHLIGHSTYLE_H\n\n#include \"LanguageHighlighter.h\"\n\n//-----------------------------------------------------------------------------\n//! SourceHighlightStyle class.\n//-----------------------------------------------------------------------------\nclass SourceHighlightStyle\n{\npublic:\n    \n    //! The constructor.\n    SourceHighlightStyle();\n\n    //! The destructor.\n    virtual ~SourceHighlightStyle() = default;\n\n    // Disable copying.\n    SourceHighlightStyle(SourceHighlightStyle const& rhs) = delete;\n    SourceHighlightStyle& operator=(SourceHighlightStyle const& rhs) = delete;\n\n    /*!\n     *  Apply the language style rules on the given highlighter.\n     *\n     *    @param [in] highlighter     The highlighter to apply the highlight style rules to.\n     */\n    void apply(LanguageHighlighter* highlighter) const;\n\nprotected:\n   \n    /*!\n     *  Get the language specific keywords.\n     *\n     *    @return The language keywords.\n     */\n    virtual QStringList keywords() const = 0;\n       \n    /*!\n     *  Get the language specific preprocessor directives.\n     *\n     *    @return The preprocessor directives.\n     */\n    virtual QStringList preprocessorDirectives() const = 0;\n\n    /*!\n     *  Apply other language specific rules to highlighting.\n     *\n     *    @param [in] highlighter   The highlighter to apply the rules to.\n     */\n    virtual void applyLanguageSpecificRules(LanguageHighlighter* highlighter) const; \n\n\n};\n\n//-----------------------------------------------------------------------------\n\n#endif // SOURECEHIGHLIGHSTYLE_H\n"
  },
  {
    "path": "PythonAPI/ChannelRelay.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: ChannelRelay.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Esko Pekkarinen\n// Date: 05.02.2021\n//\n// Description:\n// <Short description of the class/file contents>\n//-----------------------------------------------------------------------------\n\n#include \"ChannelRelay.h\"\n\n\n//-----------------------------------------------------------------------------\n// Function: ChannelRelay::ChannelRelay()\n//-----------------------------------------------------------------------------\nChannelRelay::ChannelRelay(QObject* parent):\n    QObject(parent)\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: ChannelRelay::write()\n//-----------------------------------------------------------------------------\nvoid ChannelRelay::write(QString const& text)\n{\n    emit data(text);\n}\n"
  },
  {
    "path": "PythonAPI/ChannelRelay.h",
    "content": "//-----------------------------------------------------------------------------\n// File: StdOutChannel.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Esko Pekkarinen\n// Date: 05.02.2021\n//\n// Description:\n// <Short description of the class/file contents>\n//-----------------------------------------------------------------------------\n\n#ifndef CHANNELRELAY_H\n#define CHANNELRELAY_H\n\n#include <PythonAPI/WriteChannel.h>\n\n#include <QObject>\n#include <QString>\n\nclass ChannelRelay: public QObject, public WriteChannel\n{\n    Q_OBJECT\npublic:\n\n    //! The constructor.\n    explicit ChannelRelay(QObject* parent = nullptr);\n    \n    //! The destructor.\n    virtual ~ChannelRelay() = default;\n\n    virtual void write(QString const& text) override final;\n\nsignals:\n\n    void data(QString const& text);\n};\n\n\n#endif // CHANNELRELAY_H\n"
  },
  {
    "path": "PythonAPI/ExampleScripts/createComponent.py",
    "content": "import pythonAPI\n#from ExampleScripts.createComponentItems import createPort\n#from ExampleScripts.createComponentItems import createRegister\n#from ExampleScripts.createComponentItems import createField\n#from ExampleScripts.createComponentItems import createReset\nimport ExampleScripts.createComponentItems as itemConstructor\n\ndef constructComponent(api, vendor, library, name, version):\n\t\n\tif (api.vlnvExistsInLibrary(vendor, library, name, version)):\n\t\tprint (\"Component exists already\")\n\t\treturn False\n\n\t# Create a component.\n\tsuccess = api.createComponent(vendor, library, name, version)\n\tif (not success):\n\t\tprint (\"Could not create the example component\")\n\t\treturn False\n\t\n\tapi\n\tmapInterface = api.getMapInterface()\n\tmapName = \"memoryMap\"\n\tmapInterface.addMemoryMap(0, mapName)\n\tmapInterface.setAddressUnitBits(mapName, \"16\")\n\n\t# Set available address blocks for the address block interface.\n\tapi.setBlocksForInterface(mapName)\n\tblockInterface = mapInterface.getAddressBlockInterface()\n\tblockName = \"Address_Block\"\n\tblockInterface.addBlock(0, blockName)\n\tblockInterface.setDescription(blockName, \"Peripheral address block\")\n\tblockInterface.setBaseAddress(blockName, \"'h0\")\n\tblockInterface.setRange(blockName, \"32\")\n\tblockInterface.setWidth(blockName, \"32\")\n\n\t# Set available register for the register interface.\n\tapi.setRegistersForInterface(mapName, blockName)\n\tregisterInterface = blockInterface.getSubInterface()\n\tregisterName1 = \"STAT\"\n\tregisterIndex = 0\n\titemConstructor.createRegister(registerInterface, registerIndex, registerName1, \"Status register\", \"2\", \"32\")\n\n\t# Set available fields for the field interface.\n\tapi.setFieldsForInterface(mapName, blockName, registerName1)\n\tfieldInterface = registerInterface.getSubInterface()\n\tfieldName1 = \"RX_FIFO\"\n\tfieldIndex = 0\n\titemConstructor.createField(fieldInterface, fieldIndex, fieldName1, \"RX_FIFO Not Empty\", \"0\", \"1\", \"read-only\")\n\t\n\t# Set available resets for the reset interface.\n\tapi.setResetsForInterface(mapName, blockName, registerName1, fieldName1)\n\tresetInterface = fieldInterface.getSubInterface()\n\titemConstructor.createReset(resetInterface, 0, \"\", \"1'b1\", \"1'b1\")\n\t\n\tfieldName2 = \"RX_FIFO_OVFL\"\n\tfieldIndex = fieldIndex + 1\n\titemConstructor.createField(fieldInterface, fieldIndex, fieldName2, \"RX_FIFO Overflow\", \"1\", \"1\", \"read-write\")\n\n\t# Set available resets for the reset interface.\n\tapi.setResetsForInterface(mapName, blockName, registerName1, fieldName2)\n\titemConstructor.createReset(resetInterface, 0, \"\", \"1'b1\", \"1'b1\")\n\n\tregisterName2 = \"CMD\"\n\tregisterIndex = registerIndex + 1\n\titemConstructor.createRegister(registerInterface, registerIndex, registerName2, \"Command register\", \"4\", \"32\")\n\n\t# Set available fields for the field interface.\n\tapi.setFieldsForInterface(mapName, blockName, registerName2)\n\tfieldName3 = \"COMMAND\"\n\tfieldIndex = 0\n\titemConstructor.createField(fieldInterface, fieldIndex, fieldName3, \"Peripheral Command\", \"0\", \"4\", \"read-write\")\n\t\n\t# Set available resets for the reset interface.\n\tapi.setResetsForInterface(mapName, blockName, registerName2, fieldName3)\n\titemConstructor.createReset(resetInterface, 0, \"\", \"1'b1\", \"1'b1\")\n\t\n\t# Create ports\n\tportInterface = api.getPortsInterface()\n\titemConstructor.createPort(portInterface, \"inPort\", \"in\", \"31\", \"0\")\n\titemConstructor.createPort(portInterface, \"outPort\", \"out\", \"7\", \"0\")\n\titemConstructor.createPort(portInterface, \"inOutPort\", \"inout\", \"31\", \"0\")\n\n\treturn True\n\nprint (\"\\n\", end='')\nprint (\"Example for constructing a Kactus2 component\")\napi = pythonAPI.PythonAPI()\n\nvendor = \"tut.fi\"\nlibrary = \"example\"\nname = \"register_if\"\nversion = \"1.0\"\n\nsuccess = constructComponent(api, vendor, library, name, version)\nif (success):\n\tapi.saveComponent()\n\napi.closeOpenComponent()\n\nprint (\"Creation of component \" + vendor + \".\" + library + \".\" + name + \".\" + version + \" complete.\")"
  },
  {
    "path": "PythonAPI/ExampleScripts/createComponentItems.py",
    "content": "import pythonAPI\n\ndef createRegister(registerInterface, registerIndex, registerName, description, offset, size):\n\tregisterDataIndex = registerInterface.indexInRegisterData(registerIndex)\n\tregisterInterface.addRegister(registerIndex, registerDataIndex, registerName)\n\tregisterInterface.setDescription(registerName, description)\n\tregisterInterface.setOffset(registerName, offset)\n\tregisterInterface.setSize(registerName, size)\n\ndef createField(fieldInterface, fieldIndex, fieldName, description, offset, width, access):\n\tfieldInterface.addField(fieldIndex, fieldName)\n\tfieldInterface.setDescription(fieldName, description)\n\tfieldInterface.setOffset(fieldName, offset)\n\tfieldInterface.setWidth(fieldName, width)\n\tfieldInterface.setAccess(fieldName, access)\n\ndef createReset(resetInterface, resetIndex, resetType, resetValue, resetMask):\n\tresetInterface.addReset(resetIndex)\n\tresetInterface.setResetTypeReference(resetIndex, resetType)\n\tresetInterface.setResetValue(resetIndex, resetValue)\n\tresetInterface.setResetMask(resetIndex, resetMask)\n\ndef createPort(portInterface, portName, direction, leftBound, rightBound):\n\tportInterface.addWirePort(portName)\n\tportInterface.setDirection(portName, direction)\n\tportInterface.setLeftBound(portName, leftBound)\n\tportInterface.setRightBound(portName, rightBound)\n"
  },
  {
    "path": "PythonAPI/ExampleScripts/listRegisters.py",
    "content": "import pythonAPI\n\nindentationIncrease = \"  \"\n\ndef printRegisterData(registerInterface, indentation, registerName):\n\tprint (indentation + registerName)\n\tindentation = indentation + indentationIncrease\n\tprint (indentation + \"Offset: \" + registerInterface.getOffsetValue(registerName))\n\tprint (indentation + \"Size: \" + registerInterface.getSizeValue(registerName))\n\tprint (indentation + \"Access: \" + registerInterface.getAccessString(registerName))\n\ndef printRegisters(registerInterface, indentation):\n\tindentation = indentation + indentationIncrease\n\t\n\tfor registerIndex in range(registerInterface.itemCount()):\n\t\tregisterName = registerInterface.getIndexedItemName(registerIndex)\n\t\tprintRegisterData(registerInterface, indentation, registerName)\n\t\ndef printAddressBlocks(api, mapName, blockInterface, indentation):\n\t\tindentation = indentation + indentationIncrease\n\t\t\n\t\tfor blockName in blockInterface.getItemNames():\n\t\t\tprint (indentation + blockName)\n\t\t\t\n\t\t\tapi.setRegistersForInterface(mapName, blockName)\n\t\t\tregisterInterface = blockInterface.getSubInterface()\n\t\t\tif (registerInterface.itemCount() > 0):\n\t\t\t\tprintRegisters(registerInterface, indentation)\n\t\t\t\ndef printMemoryMaps(api, mapInterface, vlnv):\n\tprint (\"Memory map structure:\")\n\tfor mapName in mapInterface.getItemNames():\n\t\tindentation = indentationIncrease\n\t\tprint (indentation + mapName)\n\t\t\n\t\tapi.setBlocksForInterface(mapName)\n\t\tblockInterface = mapInterface.getAddressBlockInterface()\n\t\tif (blockInterface.itemCount() > 0):\n\t\t\tprintAddressBlocks(api, mapName, blockInterface, indentation)\n\ndef listComponentRegisters(api, vlnv):\n\tvlnvArray = vlnv.split(\":\")\n\tif (len(vlnvArray) != 4):\n\t\tprint (\"VLNV should be given in format vendor:library:name:version\")\n\t\treturn\n\t\n\tsuccess = api.openComponent(vlnv)\n\tif (success == False):\n\t\tprint (\"Cannot open component \" + vlnv)\n\t\treturn\n\n\tprint (vlnv)\n\t\n\tmapInterface = api.getMapInterface()\n\tif (mapInterface.itemCount() > 0):\n\t\tprintMemoryMaps(api, mapInterface, vlnv)\n\t\t\n\tapi.closeOpenComponent()\n\t\nprint (\"\\n\", end='')\nprint (\"Example for displaying registers of the selected component\")\napi = pythonAPI.PythonAPI()\n\n#command = input(\"VLNV: \")\n\nvendor = \"tut.fi\"\nlibrary = \"example\"\nname = \"register_if\"\nversion = \"1.0\"\n\ncommand = vendor + \":\" + library + \":\" + name + \":\" + version\n\nlistComponentRegisters(api, command)"
  },
  {
    "path": "PythonAPI/ExampleScripts/parameterUsage.py",
    "content": "import pythonAPI\n\nparameterName = \"DATA_WIDTH\"\n\ndef setParameterToPorts(api, parameterID):\n\tleftBoundExpression = parameterID + \"-1\"\n\tportsInterface = api.getPortsInterface()\n\tfor portName in portsInterface.getItemNames():\n\t\tleftValue = portsInterface.getLeftBoundExpression(portName)\n\t\tif (leftValue == \"31\"):\n\t\t\tportsInterface.setLeftBound(portName, leftBoundExpression)\n\ndef addParameter(api):\n\tparameterInterface = api.getComponentParameterInterface()\n\tnewParameterIndex = parameterInterface.itemCount()\n\tparameterInterface.addParameter(newParameterIndex, parameterName)\n\tparameterInterface.setValue(parameterName, \"32\")\n\treturn parameterInterface.getID(parameterName)\n\nprint (\"\\n\", end='')\nprint (\"Example for using parameters in a Kactus2 component\")\napi = pythonAPI.PythonAPI()\n\nvendor = \"tut.fi\"\nlibrary = \"example\"\nname = \"register_if\"\nversion = \"1.0\"\n\nvlnvString = vendor + \":\" + library + \":\" + name + \":\" + version\nsuccess = api.openComponent(vlnvString)\nif (success):\n\tparameterID = addParameter(api)\n\tsetParameterToPorts(api, parameterID)\n\t\n\tapi.saveComponent()\n\tapi.closeOpenComponent()\n\t\n\tprint (\"Changed the left bound values of the ports of component \" + vlnvString +\n\t\" to an expression using parameter \" + parameterName)\nelse:\n\tprint (\"Component \" + vlnvString + \" was not found.\")\n\tprint (\"Use createComponent.py to create the example component\")"
  },
  {
    "path": "PythonAPI/ExampleScripts/verilogGenerator.py",
    "content": "import datetime\nimport pythonAPI\nfrom ExampleScripts.createComponentItems import createPort\n#from ExampleScripts.createComponent import createPort\n\ndef constructFile(api, fileInterface, fileSetName, filePath):\n\tapi.setFilesForInterface(fileSetName)\n\n\tif (not fileInterface.itemHasValidName(filePath)):\n\t\tfileRow = fileInterface.itemCount()\n\t\tfileInterface.addFile(fileRow, filePath)\n\t\t\n\t\tfileName = fileInterface.getIndexedItemName(fileRow)\n\t\n\t\tfileInterface.addFileType(fileName, \"verilogSource\")\n\t\n\t\tcurrentDateTime = datetime.datetime.now()\n\t\tdate = currentDateTime.strftime(\"%d.%m.%Y\")\n\t\ttime = currentDateTime.strftime(\"%H:%M:%S\")\n\t\t\n\t\tfileDescription = \"Generated at \" + time + \" on \" + date + \" by Kactus2.\"\n\t\tfileInterface.setDescription(fileName, fileDescription)\n\t\ndef constructFileSet(fileSetInterface):\n\tfileSetName = \"verilogFiles\"\n\tif (not fileSetInterface.itemHasValidName(fileSetName)):\n\t\tnewRow = fileSetInterface.itemCount()\n\t\tfileSetInterface.addFileSet(newRow, fileSetName)\n\treturn fileSetName\n\t\ndef runVerilogGenerator(api, vendor, library, name, version, vlnvString, viewName):\n\tfilePath = api.getVLNVDirectory(vendor, library, name, version)\n\tif (not filePath):\n\t\tprint (\"Could not find file \" + vlnvString)\n\t\treturn \"\"\n\t\n\tapi.generate(\"verilog\", vlnvString, viewName, filePath)\n\t\n\tverilogFileName = name + \".v\"\n\treturn verilogFileName\n\t\ndef getViewName(api):\n\treturn api.getFirstViewName()\n\t\ndef portExists(portInterface, comparisonName):\n\tfor portName in portInterface.getItemNames():\n\t\tif (portName == comparisonName):\n\t\t\treturn True\n\treturn False\n\t\ndef createOneBitPorts(api):\n\tportInterface = api.getPortsInterface()\n\tclkName = \"clk\"\n\tif (not portExists(portInterface, clkName)):\n\t\tcreatePort(portInterface, clkName, \"in\", \"0\", \"0\")\n\trstName = \"rst_n\"\n\tif (not portExists(portInterface, rstName)):\n\t\tcreatePort(portInterface, rstName, \"out\", \"0\", \"0\")\n\tackName = \"ack\"\n\tif (not portExists(portInterface, ackName)):\n\t\tcreatePort(portInterface, ackName, \"inout\", \"0\", \"0\")\n\nprint (\"\\n\", end='')\nprint (\"Example for generating a verilog file from a Kactus2 component\")\napi = pythonAPI.PythonAPI()\n\nvendor = \"tut.fi\"\nlibrary = \"example\"\nname = \"register_if\"\nversion = \"1.0\"\n\nvlnvString = vendor + \":\" + library + \":\" + name + \":\" + version\nsuccess = api.openComponent(vlnvString)\nif (success):\n\t\n\tcreateOneBitPorts(api)\n\tviewName = getViewName(api)\n\t\n\t# Apply the changes to the component file before running the generator.\n\tapi.saveComponent()\n\n\tverilogFileName = runVerilogGenerator(api, vendor, library, name, version, vlnvString, viewName)\n\tif (len(verilogFileName) != 0):\n\t\tfileSetInterface = api.getFileSetInterface()\n\t\tfileSetName = constructFileSet(fileSetInterface)\n\t\tconstructFile(api, fileSetInterface.getFileInterface(), fileSetName, verilogFileName)\n\t\t\n\tapi.saveComponent()\n\tapi.closeOpenComponent()\n\t\n\tprint (\"The generated verilog file can be found in the file sets of component \" + vlnvString)\nelse:\n\tprint (\"Component \" + vlnvString + \" was not found.\")\n\tprint (\"Use createComponent.py to create the example component\")"
  },
  {
    "path": "PythonAPI/FileChannel.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: FileChannel.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Esko Pekkarinen\n// Date: 05.02.2021\n//\n// Description:\n// Writable output channel for files e.g stdout.\n//-----------------------------------------------------------------------------\n\n#include \"FileChannel.h\"\n\n//-----------------------------------------------------------------------------\n// Function: FileChannel::FileChannel()\n//-----------------------------------------------------------------------------\nFileChannel::FileChannel(FILE* fileHandle):\n    output_(fileHandle)\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: FileChannel::write()\n//-----------------------------------------------------------------------------\nvoid FileChannel::write(QString const& text)\n{\n    output_ << text;\n    output_.flush();\n}\n"
  },
  {
    "path": "PythonAPI/FileChannel.h",
    "content": "//-----------------------------------------------------------------------------\n// File: FileChannel.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Esko Pekkarinen\n// Date: 05.02.2021\n//\n// Description:\n// Writable output channel for files e.g stdout.\n//-----------------------------------------------------------------------------\n\n#ifndef FILECHANNEL_H\n#define FILECHANNEL_H\n\n#include <PythonAPI/WriteChannel.h>\n\n#include <QObject>\n#include <QString>\n#include <QTextStream>\n\nclass FileChannel: public QObject, public WriteChannel\n{\n    Q_OBJECT\npublic:\n\n    //! The constructor.\n    FileChannel(FILE* fileHandle);\n    \n    //! The destructor.\n    ~FileChannel() = default;\n\npublic slots:\n\n    // Called when text is written into the file.\n    virtual void write(QString const& text) override final;\n\nprivate:\n\n    QTextStream output_;\n};\n\n\n#endif // FILECHANNEL_H\n"
  },
  {
    "path": "PythonAPI/InterfaceFiles/NameGroup.i",
    "content": "/* NameGroup interface file for Python */\n%module NameGroup\n\n%include \"QString.i\"\n\n%{\n#include \"IPXACTmodels/common/NameGroup.h\"\n%}\n\nclass NameGroup\n{\n\npublic:\n\n\tNameGroup();\n\tNameGroup(QString const& name, QString const& displayName = QString(), QString const& description = QString());\n\tNameGroup(const NameGroup& other);\n\n    virtual ~NameGroup();\n\n    QString name() const;\n//    void setName(QString const& name);\n\n    QString displayName() const;\n//    void setDisplayName(QString const& displayName);\n\n    QString description() const;\n//    void setDescription(QString const& description);\n};\n"
  },
  {
    "path": "PythonAPI/InterfaceFiles/Port.i",
    "content": "/* Port interface file for Python */\n%module Port\n\n%include \"QString.i\"\n%include \"NameGroup.i\"\n\n%{\n#include \"IPXACTmodels\\common\\Port.h\"\n%}\n\nclass Port : public NameGroup\n{\npublic:\n\n\tQString getValue() const;\n//\tvoid setValue(QString const& value);\n    \n    QString getType() const;\n//    void setType(QString const& type);\n\n};\n"
  },
  {
    "path": "PythonAPI/InterfaceFiles/QString.i",
    "content": "/* QString interface file for Python */\n%module QString\n\n%{\n#include <QString>\n%}\n\nclass QString\n{\npublic:\n    static QString fromStdString(const std::string &s);\n    std::string toStdString() const;\n    \n    int size() const;\n    int count() const;\n    int length() const;\n    bool isEmpty() const;\n};\n"
  },
  {
    "path": "PythonAPI/PythonAPI.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: PythonAPI.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Mikko Teuho\n// Date: 12.02.2020\n//\n// Description:\n// Interface for accessing Kactus2 data using Python.\n//-----------------------------------------------------------------------------\n\n#include \"PythonAPI.h\"\n\n\n#include <KactusAPI/KactusAPI.h>\n\n#include <KactusAPI/include/IPlugin.h>\n#include <KactusAPI/include/IGeneratorPlugin.h>\n#include <KactusAPI/include/CLIGenerator.h>\n\n#include <KactusAPI/include/BusInterfaceUtilities.h>\n\n#include <KactusAPI/include/RegisterInterface.h>\n#include <KactusAPI/include/FieldInterface.h>\n#include <KactusAPI/include/AccessPolicyInterface.h>\n#include <KactusAPI/include/ModeReferenceInterface.h>\n#include <KactusAPI/include/ResetInterface.h>\n#include <KactusAPI/include/AddressBlockInterface.h>\n#include <KactusAPI/include/MemoryMapInterface.h>\n#include <KactusAPI/include/SubspaceMapInterface.h>\n#include <KactusAPI/include/FileSetInterface.h>\n#include <KactusAPI/include/FileInterface.h>\n#include <KactusAPI/include/FileBuilderInterface.h>\n#include <KactusAPI/include/PortAbstractionInterface.h>\n#include <KactusAPI/include/AbstractionTypeInterface.h>\n#include <KactusAPI/include/PortMapInterface.h>\n#include <KactusAPI/include/LibraryHandler.h>\n#include <KactusAPI/include/InterconnectGenerator.h>\n\n#include <IPXACTmodels/common/ConfigurableVLNVReference.h>\n#include <IPXACTmodels/common/validators/ParameterValidator.h>\n\n#include <IPXACTmodels/Component/Component.h>\n#include <IPXACTmodels/Component/Port.h>\n#include <IPXACTmodels/Component/View.h>\n#include <IPXACTmodels/Component/MemoryMap.h>\n#include <IPXACTmodels/Component/PortMap.h>\n#include <IPXACTmodels/Component/AddressBlock.h>\n#include <IPXACTmodels/Component/MemoryBlockBase.h>\n#include <IPXACTmodels/Component/RegisterBase.h>\n#include <IPXACTmodels/Component/Register.h>\n#include <IPXACTmodels/Component/Field.h>\n#include <IPXACTmodels/Component/validators/FieldValidator.h>\n#include <IPXACTmodels/Component/validators/EnumeratedValueValidator.h>\n#include <IPXACTmodels/Component/validators/RegisterValidator.h>\n#include <IPXACTmodels/Component/validators/RegisterFileValidator.h>\n#include <IPXACTmodels/Component/validators/AddressBlockValidator.h>\n#include <IPXACTmodels/Component/validators/SubspaceMapValidator.h>\n#include <IPXACTmodels/Component/validators/MemoryMapValidator.h>\n#include <IPXACTmodels/Component/validators/FileSetValidator.h>\n#include <IPXACTmodels/Component/validators/FileValidator.h>\n\n#include <IPXACTmodels/Design/Interconnection.h>\n#include <IPXACTmodels/Design/AdHocConnection.h>\n#include <IPXACTmodels/Design/ActiveInterface.h>\n#include <IPXACTmodels/Design/Design.h>\n\n\n#include <IPXACTmodels/DesignConfiguration/DesignConfiguration.h>\n\n//-----------------------------------------------------------------------------\n// Function: PythonAPI::PythonAPI()\n//-----------------------------------------------------------------------------\nPythonAPI::PythonAPI()\n{\n    constructMemoryValidators();\n    constructMemoryInterface();\n    constructFileSetInterface();\n}\n\n//-----------------------------------------------------------------------------\n// Function: PythonAPI::setupLibrary()\n//-----------------------------------------------------------------------------\nvoid PythonAPI::setupLibrary(std::string const& /*settingsFileString*/)\n{\n    library_->searchForIPXactFiles();\n}\n\n//-----------------------------------------------------------------------------\n// Function: PythonAPI::getVersion()\n//-----------------------------------------------------------------------------\nstd::string PythonAPI::getVersion() const\n{\n    return KactusAPI::getVersion().toStdString();\n}\n\n//-----------------------------------------------------------------------------\n// Function: PythonAPI::getLibraryPaths()\n//-----------------------------------------------------------------------------\nstd::vector<std::string> PythonAPI::getAllLibraryPaths() const\n{\n    QStringList locations = KactusAPI::getAllLibraryPaths();\n\n    std::vector<std::string> paths;\n    for (auto const& path : locations)\n    {\n        paths.push_back(path.toStdString());\n    }\n  \n    return paths;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PythonAPI::setLibraryPathActive()\n//-----------------------------------------------------------------------------\nvoid PythonAPI::setLibraryPathActive(std::string const& path, bool isActive)\n{\n    KactusAPI::setLibraryPathActive(QString::fromStdString(path), isActive);\n}\n\n//-----------------------------------------------------------------------------\n// Function: PythonAPI::addLibraryPath()\n//-----------------------------------------------------------------------------\nvoid PythonAPI::addLibraryPath(std::string const& path, bool isActive /*= true*/)\n{\n    KactusAPI::addLibraryPath(QString::fromStdString(path), isActive);\n}\n\n//-----------------------------------------------------------------------------\n// Function: PythonAPI::removeLibraryPath()\n//-----------------------------------------------------------------------------\nvoid PythonAPI::removeLibraryPath(std::string const& path)\n{\n    if (KactusAPI::removeLibraryPath(QString::fromStdString(path)) == false)\n    {\n        messager_->showError(QStringLiteral(\"Error: Cannot remove default library path\"));\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: PythonAPI::getActiveLibraryPaths()\n//-----------------------------------------------------------------------------\nstd::vector<std::string> PythonAPI::getActiveLibraryPaths() const\n{\n    QStringList locations = KactusAPI::getActiveLibraryPaths();\n\n    std::vector<std::string> paths;\n    for (auto const& path : locations)\n    {\n        paths.push_back(path.toStdString());\n    }\n\n    return paths;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PythonAPI::getPortsInterface()\n//-----------------------------------------------------------------------------\nPortsInterface* PythonAPI::getPortsInterface() const\n{\n    return portsInterface_;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PythonAPI::getComponentParameterInterface()\n//-----------------------------------------------------------------------------\nParametersInterface* PythonAPI::getComponentParameterInterface() const\n{\n    return componentParameterInterface_;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PythonAPI::getMapInterface()\n//-----------------------------------------------------------------------------\nMemoryMapInterface* PythonAPI::getMapInterface()\n{\n    return mapInterface_;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PythonAPI::getFileSetInterface()\n//-----------------------------------------------------------------------------\nFileSetInterface* PythonAPI::getFileSetInterface()\n{\n    return fileSetInterface_;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PythonAPI::getBusInterface()\n//-----------------------------------------------------------------------------\nBusInterfaceInterface* PythonAPI::getBusInterface()\n{\n    return busInterface_;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PythonAPI::setLibraryPaths()\n//-----------------------------------------------------------------------------\nvoid PythonAPI::setLibraryPaths(std::vector<std::string> const& paths) const\n{\n    QStringList libraryPaths;\n    for (auto const& path : paths)\n    {\n        libraryPaths.append(QString::fromStdString(path));\n    }\n\n    KactusAPI::setLibraryPaths(libraryPaths);\n}\n\n//-----------------------------------------------------------------------------\n// Function: PythonAPI::getDefaultLibraryPath()\n//-----------------------------------------------------------------------------\nstd::string PythonAPI::getDefaultLibraryPath() const\n{\n    return KactusAPI::getDefaultLibraryPath().toStdString();\n}\n\n//-----------------------------------------------------------------------------\n// Function: PythonAPI::setDefaultLibraryPath()\n//-----------------------------------------------------------------------------\nvoid PythonAPI::setDefaultLibraryPath(std::string const& path) const\n{\n    KactusAPI::setDefaultLibraryPath(QString::fromStdString(path));\n}\n\n//-----------------------------------------------------------------------------\n// Function: PythonAPI::setDefaultLibraryPath()\n//-----------------------------------------------------------------------------\nint PythonAPI::importFile(std::string const& path, std::string const& vlnv, bool overwrite /*= false*/) const\n{\n    VLNV targetVLNV(VLNV::COMPONENT, QString::fromStdString(vlnv));\n\n    return KactusAPI::importFile(QString::fromStdString(path), targetVLNV, overwrite);\n}\n\n//-----------------------------------------------------------------------------\n// Function: PythonAPI::generate()\n//-----------------------------------------------------------------------------\nvoid PythonAPI::generate(std::string const& format, std::string const& vlnv, std::string const& viewName,\n    std::string const& outputDirectory) const\n{\n    VLNV componentVLNV(VLNV::COMPONENT, QString::fromStdString(vlnv));\n    KactusAttribute::Implementation implementation = KactusAttribute::HW;\n\n    QString fileFormat = QString::fromStdString(format).toLower();\n\n    QStringList availableFormats;\n\n    IGeneratorPlugin* generator = nullptr;\n    for (auto plugin : KactusAPI::getPlugins())\n    {\n        CLIGenerator* runnable = dynamic_cast<CLIGenerator*>(plugin);\n        if (runnable != 0)\n        {\n            if (runnable->getOutputFormat().toLower() == fileFormat)\n            {\n                generator = dynamic_cast<IGeneratorPlugin*>(plugin);\n            }\n\n            availableFormats.append(runnable->getOutputFormat());\n        }\n    }\n    \n    if (generator != nullptr)\n    {\n        KactusAPI::runGenerator(generator, componentVLNV, QString::fromStdString(viewName),\n            QString::fromStdString(outputDirectory), implementation, nullptr);\n    }\n    else\n    {\n        availableFormats.sort(Qt::CaseInsensitive);\n        messager_->showError(QStringLiteral(\"No generator found for format %1. Available options are: %2\").arg(\n            fileFormat, availableFormats.join(',')));\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: PythonAPI::generateInterconnect()\n//-----------------------------------------------------------------------------\nvoid PythonAPI::generateInterconnect()\n{\n\n    auto interconGen = InterconnectGeneration::Generator(library_, messager_);\n\n    VLNV interconVLNV = interconGen.generate();\n}\n\n//-----------------------------------------------------------------------------\n// Function: PythonAPI::getFileCount()\n//-----------------------------------------------------------------------------\nint PythonAPI::getFileCount() const\n{\n    return library_->getAllVLNVs().count();\n}\n\n//-----------------------------------------------------------------------------\n// Function: PythonAPI::listVLNVs()\n//-----------------------------------------------------------------------------\nstd::vector<std::string> PythonAPI::listVLNVs(std::string const& vendor) const\n{\n    std::vector<std::string> vlnvStrings;\n\n    for (auto const& itemVLNV : library_->getAllVLNVs())\n    {\n        vlnvStrings.push_back(itemVLNV.toString().toStdString());\n    }\n\n    return vlnvStrings;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PythonAPI::listComponentVLNVs()\n//-----------------------------------------------------------------------------\nstd::vector<std::string> PythonAPI::listComponentVLNVs() const\n{\n    std::vector<std::string> componentVLNVs;\n\n    for (auto const& itemVLNV : library_->getAllVLNVs())\n    {\n        if (itemVLNV.getType() == VLNV::COMPONENT)\n        {\n            componentVLNVs.push_back(itemVLNV.toString().toStdString());\n        }\n    }\n\n    return componentVLNVs;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PythonAPI::vlnvExistsInLibrary()\n//-----------------------------------------------------------------------------\nbool PythonAPI::vlnvExistsInLibrary(std::string const& vendor, std::string const& library, std::string const& name,\n    std::string const& version) const\n{\n    if (vendor.empty() || library.empty() || name.empty() || version.empty())\n    {\n        messager_->showError(\"Error in given VLNV.\");\n        return false;\n    }\n\n    return library_->contains(VLNV(VLNV::INVALID,\n        QString::fromStdString(vendor),\n        QString::fromStdString(library),\n        QString::fromStdString(name),\n        QString::fromStdString(version)));\n}\n\n//-----------------------------------------------------------------------------\n// Function: PythonAPI::createComponent()\n//-----------------------------------------------------------------------------\nbool PythonAPI::createComponent(std::string const& vendor, std::string const& library, std::string const& name,\n    std::string const& version, StdRev revision /*= StdRev::Std22*/)\n{\n    if (vendor.empty() || library.empty() || name.empty() || version.empty())\n    {\n        messager_->showError(\"Error in given VLNV.\");\n        return false;\n    }\n\n    VLNV newComponentVLNV;\n    newComponentVLNV.setVendor(QString::fromStdString(vendor));\n    newComponentVLNV.setLibrary(QString::fromStdString(library));\n    newComponentVLNV.setName(QString::fromStdString(name));\n    newComponentVLNV.setVersion(QString::fromStdString(version));\n    newComponentVLNV.setType(VLNV::COMPONENT);\n\n    if (library_->contains(newComponentVLNV))\n    {\n        return false;\n    }\n\n    Document::Revision docRevision = revision == PythonAPI::StdRev::Std22 \n        ? Document::Revision::Std22 : Document::Revision::Std14;\n\n    QSharedPointer<Component> component = QSharedPointer<Component>(new Component(newComponentVLNV, docRevision));\n\n    component->setHierarchy(KactusAttribute::FLAT);\n    component->setFirmness(KactusAttribute::MUTABLE);\n    component->setImplementation(KactusAttribute::HW);\n    component->setVersion(KactusAPI::getVersionFileString());\n\n    QString directory = KactusAPI::getDefaultLibraryPath();\n    QString vlnvDir = \"/\" + newComponentVLNV.getVendor() + \"/\" + newComponentVLNV.getLibrary() + \"/\" +\n        newComponentVLNV.getName() + \"/\" + newComponentVLNV.getVersion();\n\n    directory += vlnvDir;\n\n    if (!library_->writeModelToFile(directory, component))\n    {\n        messager_->showError(\"Error saving file to disk.\");\n        return false;\n    }\n\n    openComponent(newComponentVLNV.toString().toStdString());\n\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PythonAPI::getVLNVDirectory()\n//-----------------------------------------------------------------------------\nstd::string PythonAPI::getVLNVDirectory(std::string const& vendor, std::string const& library,\n    std::string const& name, std::string const& version) const\n{\n    VLNV documentVLNV;\n    documentVLNV.setVendor(QString::fromStdString(vendor));\n    documentVLNV.setLibrary(QString::fromStdString(library));\n    documentVLNV.setName(QString::fromStdString(name));\n    documentVLNV.setVersion(QString::fromStdString(version));\n\n    return KactusAPI::getDocumentFilePath(documentVLNV).toStdString();\n}\n\n//-----------------------------------------------------------------------------\n// Function: PythonAPI::getFirstViewName()\n//-----------------------------------------------------------------------------\nstd::string PythonAPI::getFirstViewName() const\n{\n    if (activeComponent_)\n    {\n        QStringList componentNames = activeComponent_->getViewNames();\n        if (!componentNames.isEmpty())\n        {\n            return componentNames.first().toStdString();\n        }\n        else\n        {\n            QSharedPointer<View> newView(new View(\"mockView\"));\n            activeComponent_->getViews()->append(newView);\n            return newView->name().toStdString();\n        }\n    }\n\n    return std::string();\n}\n\n//-----------------------------------------------------------------------------\n// Function: PythonAPI::openComponent()\n//-----------------------------------------------------------------------------\nbool PythonAPI::openComponent(std::string const& vlnvString)\n{\n    QString componentVLNV = QString::fromStdString(vlnvString);\n    QSharedPointer<Document> componentDocument = getDocument(componentVLNV);\n    if (componentDocument)\n    {\n        QSharedPointer<Component> component = componentDocument.dynamicCast<Component>();\n        if (component)\n        {\n            parameterFinder_->setComponent(component);\n            portValidator_->componentChange(component->getViews());\n            portsInterface_->setPorts(component->getPorts());\n\n            parameterValidator_->componentChange(component->getChoices(), component->getRevision());\n            componentParameterInterface_->setParameters(component->getParameters());\n            componentParameterInterface_->setChoices(component->getChoices());\n\n            mapValidator_->componentChange(component);\n            mapInterface_->setMemoryMaps(component);\n\n            fileSetInterface_->setFileSets(component->getFileSets());\n\n            busInterface_->setBusInterfaces(component);\n\n            activeComponent_ = component;\n            messager_->showMessage(QString(\"Component %1 is open\").arg(componentVLNV));\n            return true;\n        }\n        else\n        {\n            messager_->showError(QString(\"The given VLNV %1 is not a component\").arg(componentVLNV));\n            return false;\n        }\n    }\n    else\n    {\n        messager_->showError(QString(\"Could not open document with VLNV %1\").arg(componentVLNV));\n        return false;\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: PythonAPI::getDocument()\n//-----------------------------------------------------------------------------\nQSharedPointer<Document> PythonAPI::getDocument(QString const& vlnvString) const\n{\n    QStringList vlnvArray = vlnvString.split(':');\n    if (vlnvArray.size() != 4)\n    {\n        messager_->showError(QString(\"The given VLNV %1 is not valid\").arg(vlnvString));\n        return QSharedPointer<Document>();\n    }\n\n    VLNV targetVLNV(VLNV::COMPONENT, vlnvArray.at(0), vlnvArray.at(1), vlnvArray.at(2), vlnvArray.at(3));\n    return library_->getModel(targetVLNV);\n}\n\n//-----------------------------------------------------------------------------\n// Function: PythonAPI::closeOpenComponent()\n//-----------------------------------------------------------------------------\nvoid PythonAPI::closeOpenComponent()\n{\n    if (activeComponent_)\n    {\n        messager_->showMessage(QString(\"Component %1 is closed\").arg(activeComponent_->getVlnv().toString()));\n    }\n\n    activeComponent_ = QSharedPointer<Component>();\n}\n\n//-----------------------------------------------------------------------------\n// Function: PythonAPI::getComponentName()\n//-----------------------------------------------------------------------------\nstd::string PythonAPI::getComponentName() const\n{\n    if (activeComponent_)\n    {\n        return activeComponent_->getVlnv().getName().toStdString();\n    }\n    else\n    {\n        return std::string();\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: PythonAPI::getComponentDescription()\n//-----------------------------------------------------------------------------\nstd::string PythonAPI::getComponentDescription() const\n{\n    if (activeComponent_)\n    {\n        return activeComponent_->getDescription().toStdString();\n    }\n    else\n    {\n        return std::string();\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: PythonAPI::getComponentStdRevision()\n//-----------------------------------------------------------------------------\nstd::string PythonAPI::getComponentStdRevision() const\n{\n    if (activeComponent_)\n    {\n        return Document::toStdString(activeComponent_->getRevision());\n    }\n\n    return std::string();\n}\n\n//-----------------------------------------------------------------------------\n// Function: PythonAPI::saveComponent()\n//-----------------------------------------------------------------------------\nvoid PythonAPI::saveComponent()\n{\n    if (activeComponent_)\n    {\n        messager_->showMessage(QString(\"Saving component %1 ...\").arg(activeComponent_->getVlnv().toString()));\n\n\n        if (library_->writeModelToFile(activeComponent_))\n        {\n            messager_->showMessage(QString(\"Save complete\"));\n        }\n        else\n        {\n            messager_->showError(QString(\"Could not save component %1\").arg(activeComponent_->getVlnv().toString()));\n        }\n    }\n}\n\n\n//-----------------------------------------------------------------------------\n// Function: PythonAPI::constructMemoryValidators()\n//-----------------------------------------------------------------------------\nvoid PythonAPI::constructMemoryValidators()\n{\n    QSharedPointer<EnumeratedValueValidator> enumValidator(new EnumeratedValueValidator(expressionParser_));\n    QSharedPointer<FieldValidator>fieldValidator(new FieldValidator(\n        expressionParser_, enumValidator, parameterValidator_));\n    QSharedPointer<RegisterValidator> registerValidator (new RegisterValidator(\n        expressionParser_, fieldValidator, parameterValidator_));\n    QSharedPointer<RegisterFileValidator> registerFileValidator(\n        new RegisterFileValidator(expressionParser_, registerValidator, parameterValidator_,\n            Document::Revision::Unknown));\n\n    QSharedPointer<AddressBlockValidator> blockValidator(new AddressBlockValidator(\n        expressionParser_, registerValidator, registerFileValidator, parameterValidator_, \n        Document::Revision::Unknown));\n\n    QSharedPointer<SubspaceMapValidator> subspaceValidator(\n        new SubspaceMapValidator(expressionParser_, parameterValidator_, Document::Revision::Unknown));\n\n    QSharedPointer<MemoryMapValidator> mapValidator(\n        new MemoryMapValidator(expressionParser_, blockValidator, subspaceValidator, QSharedPointer<Component>()));\n\n    mapValidator_ = mapValidator;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PythonAPI::constructMemoryInterface()\n//-----------------------------------------------------------------------------\nvoid PythonAPI::constructMemoryInterface()\n{\n    QSharedPointer<SubspaceMapValidator> subspaceValidator = mapValidator_->getSubspaceValidator();\n    QSharedPointer<AddressBlockValidator> blockValidator = mapValidator_->getAddressBlockValidator();\n    QSharedPointer<RegisterValidator> registerValidator = blockValidator->getRegisterValidator();\n    QSharedPointer<FieldValidator> fieldValidator = registerValidator->getFieldValidator();\n\n    ResetInterface* resetInterface(new ResetInterface(fieldValidator, expressionParser_, expressionFormatter_));\n    FieldInterface* fieldInterface(\n        new FieldInterface(fieldValidator, expressionParser_, expressionFormatter_, resetInterface));\n\n    ModeReferenceInterface* modeReferenceInterface(new ModeReferenceInterface());\n\n    AccessPolicyInterface* accessPolicyInterface(new AccessPolicyInterface(modeReferenceInterface));\n\n    RegisterInterface* registerInterface(\n        new RegisterInterface(registerValidator, expressionParser_, expressionFormatter_, fieldInterface, \n            accessPolicyInterface));\n\n    AddressBlockInterface* blockInterface(new AddressBlockInterface(blockValidator, expressionParser_,\n        expressionFormatter_, busInterface_, registerInterface, componentParameterInterface_));\n    SubspaceMapInterface* subspaceInterface(new SubspaceMapInterface(\n        subspaceValidator, expressionParser_, expressionFormatter_, busInterface_, componentParameterInterface_));\n\n    mapInterface_ = new MemoryMapInterface(mapValidator_, expressionParser_, expressionFormatter_);\n\n    mapInterface_->setAddressBlockInterface(blockInterface);\n    mapInterface_->setSubspaceMapInterface(subspaceInterface);\n    mapInterface_->setModeReferenceInterface(modeReferenceInterface);\n}\n\n//-----------------------------------------------------------------------------\n// Function: PythonAPI::setBlocksForInterface()\n//-----------------------------------------------------------------------------\nvoid PythonAPI::setBlocksForInterface(std::string const& mapName)\n{\n    AddressBlockInterface* blockInterface = mapInterface_->getAddressBlockInterface();\n\n    QString mapNameQT = QString::fromStdString(mapName);\n    QSharedPointer<MemoryMap> containingMap = getMemoryMap(mapNameQT);\n    if (!containingMap)\n    {\n        sendMemoryMapNotFoundError(mapNameQT);\n        return;\n    }\n\n    blockInterface->setMemoryBlocks(containingMap->getMemoryBlocks());\n    blockInterface->setAddressUnitBits(containingMap->getAddressUnitBits().toStdString());\n}\n\n//-----------------------------------------------------------------------------\n// Function: PythonAPI::setRegistersForInterface()\n//-----------------------------------------------------------------------------\nvoid PythonAPI::setRegistersForInterface(std::string const& mapName, std::string const& blockName)\n{\n    RegisterInterface* interfacePointer = mapInterface_->getAddressBlockInterface()->getSubInterface();\n\n    QString mapNameQT = QString::fromStdString(mapName);\n    QString blockNameQT = QString::fromStdString(blockName);\n\n    QSharedPointer<MemoryMap> containingMap = getMemoryMap(mapNameQT);\n    if (containingMap)\n    {\n        QSharedPointer<AddressBlock> containingBlock = getAddressBock(containingMap, blockNameQT);\n        if (containingBlock)\n        {\n            interfacePointer->setRegisters(containingBlock->getRegisterData());\n            interfacePointer->setAddressUnitBits(\n                expressionParser_->parseExpression(containingMap->getAddressUnitBits()).toInt());\n        }\n        else\n        {\n            sendAddressBlockNotFoundError(mapNameQT, blockNameQT);\n        }\n    }\n    else\n    {\n        sendMemoryMapNotFoundError(mapNameQT);\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: PythonAPI::setFieldsForInterface()\n//-----------------------------------------------------------------------------\nvoid PythonAPI::setFieldsForInterface(std::string const& mapName, std::string const& blockName,\n    std::string const& registerName)\n{\n    FieldInterface* interfacePointer =\n        mapInterface_->getAddressBlockInterface()->getSubInterface()->getSubInterface();\n\n    QString mapNameQT = QString::fromStdString(mapName);\n    QString blockNameQT = QString::fromStdString(blockName);\n    QString registerNameQT = QString::fromStdString(registerName);\n\n    QSharedPointer<MemoryMap> containingMap = getMemoryMap(mapNameQT);\n    if (containingMap)\n    {\n        QSharedPointer<AddressBlock> containingBlock = getAddressBock(containingMap, blockNameQT);\n        if (containingBlock)\n        {\n            QSharedPointer<Register> containingRegister = getRegister(containingBlock, registerNameQT);\n            if (containingRegister)\n            {\n                interfacePointer->setFields(containingRegister->getFields());\n            }\n            else\n            {\n                sendRegisterNotFoundError(mapNameQT, blockNameQT, registerNameQT);\n            }\n        }\n        else\n        {\n            sendAddressBlockNotFoundError(mapNameQT, blockNameQT);\n        }\n    }\n    else\n    {\n        sendMemoryMapNotFoundError(mapNameQT);\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: PythonAPI::setResetsForInterface()\n//-----------------------------------------------------------------------------\nvoid PythonAPI::setResetsForInterface(std::string const& mapName, std::string const& blockName,\n    std::string const& registerName, std::string const& fieldName)\n{\n    ResetInterface* interfacePointer =\n        mapInterface_->getAddressBlockInterface()->getSubInterface()->getSubInterface()->getSubInterface();\n\n    QString mapNameQT = QString::fromStdString(mapName);\n    QString blockNameQT = QString::fromStdString(blockName);\n    QString registerNameQT = QString::fromStdString(registerName);\n    QString fieldNameQT = QString::fromStdString(fieldName);\n\n    QSharedPointer<MemoryMap> containingMap = getMemoryMap(mapNameQT);\n    if (containingMap)\n    {\n        QSharedPointer<AddressBlock> containingBlock = getAddressBock(containingMap, blockNameQT);\n        if (containingBlock)\n        {\n            QSharedPointer<Register> containingRegister = getRegister(containingBlock, registerNameQT);\n            if (containingRegister)\n            {\n                QSharedPointer<Field> containingField = getField(containingRegister, fieldNameQT);\n                if (containingField)\n                {\n                    interfacePointer->setResets(containingField);\n                }\n                else\n                {\n                    sendFieldNotFoundError(mapNameQT, blockNameQT, registerNameQT, fieldNameQT);\n                }\n            }\n            else\n            {\n                sendRegisterNotFoundError(mapNameQT, blockNameQT, registerNameQT);\n            }\n        }\n        else\n        {\n            sendAddressBlockNotFoundError(mapNameQT, blockNameQT);\n        }\n    }\n    else\n    {\n        sendMemoryMapNotFoundError(mapNameQT);\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: PythonAPI::getMemoryMap()\n//-----------------------------------------------------------------------------\nQSharedPointer<MemoryMap> PythonAPI::getMemoryMap(QString const& mapName) const\n{\n    for (auto map : *activeComponent_->getMemoryMaps())\n    {\n        if (map->name() == mapName)\n        {\n            return map;\n        }\n    }\n\n    return QSharedPointer<MemoryMap>();\n}\n\n//-----------------------------------------------------------------------------\n// Function: PythonAPI::getAddressBock()\n//-----------------------------------------------------------------------------\nQSharedPointer<AddressBlock> PythonAPI::getAddressBock(QSharedPointer<MemoryMap> containingMap,\n    QString const& blockName) const\n{\n    for (auto baseBlock : *containingMap->getMemoryBlocks())\n    {\n        QSharedPointer<AddressBlock> block = baseBlock.dynamicCast<AddressBlock>();\n        if (block && block->name() == blockName)\n        {\n            return block;\n        }\n    }\n\n    return QSharedPointer<AddressBlock>();\n}\n\n//-----------------------------------------------------------------------------\n// Function: PythonAPI::getRegister()\n//-----------------------------------------------------------------------------\nQSharedPointer<Register> PythonAPI::getRegister(QSharedPointer<AddressBlock> containingBlock,\n    QString const& registerName) const\n{\n    for (auto baseRegister : *containingBlock->getRegisterData())\n    {\n        QSharedPointer<Register> currentRegister = baseRegister.dynamicCast<Register>();\n        if (currentRegister && currentRegister->name() == registerName)\n        {\n            return currentRegister;\n        }\n    }\n\n    return QSharedPointer<Register>();\n}\n\n//-----------------------------------------------------------------------------\n// Function: PythonAPI::getField()\n//-----------------------------------------------------------------------------\nQSharedPointer<Field> PythonAPI::getField(QSharedPointer<Register> containingRegister, QString const& fieldName)\n    const\n{\n    for (auto currentField : *containingRegister->getFields())\n    {\n        if (currentField->name() == fieldName)\n        {\n            return currentField;\n        }\n    }\n\n    return QSharedPointer<Field>();\n}\n\n//-----------------------------------------------------------------------------\n// Function: PythonAPI::constructFileSetInterface()\n//-----------------------------------------------------------------------------\nvoid PythonAPI::constructFileSetInterface()\n{\n    QSharedPointer<FileValidator> newFileValidator(new FileValidator(expressionParser_));\n    QSharedPointer<FileSetValidator> newFileSetValidator(\n        new FileSetValidator(newFileValidator, expressionParser_));\n\n    FileInterface* fileInterface = new FileInterface(newFileValidator, expressionParser_, expressionFormatter_);\n\n    FileBuilderInterface* fileBuilderInterface = new FileBuilderInterface(expressionParser_, expressionFormatter_);\n\n    fileSetInterface_ = new FileSetInterface(\n        newFileSetValidator, expressionParser_, expressionFormatter_, fileInterface, fileBuilderInterface);\n}\n\n//-----------------------------------------------------------------------------\n// Function: PythonAPI::setFilesForInterface()\n//-----------------------------------------------------------------------------\nvoid PythonAPI::setFilesForInterface(std::string const& setName)\n{\n    FileInterface* fileInterface = fileSetInterface_->getFileInterface();\n\n    QString fileSetNameQT = QString::fromStdString(setName);\n    QSharedPointer<FileSet> containingFileSet = getFileSet(fileSetNameQT);\n    if (!containingFileSet)\n    {\n        sendFileSetNotFoundError(fileSetNameQT);\n        return;\n    }\n\n    fileInterface->setFiles(containingFileSet->getFiles());\n}\n\n//-----------------------------------------------------------------------------\n// Function: PythonAPI::getFileSet()\n//-----------------------------------------------------------------------------\nQSharedPointer<FileSet> PythonAPI::getFileSet(QString const& setName) const\n{\n    for (auto fileSet : *activeComponent_->getFileSets())\n    {\n        if (fileSet->name() == setName)\n        {\n            return fileSet;\n        }\n    }\n\n    return QSharedPointer<FileSet>();\n}\n\n//-----------------------------------------------------------------------------\n// Function: PythonAPI::setFileBuildersForInterface()\n//-----------------------------------------------------------------------------\nvoid PythonAPI::setFileBuildersForInterface(std::string const& setName)\n{\n    FileBuilderInterface* builderInterface = fileSetInterface_->getFileBuilderInterface();\n\n    QString fileSetNameQT = QString::fromStdString(setName);\n    QSharedPointer<FileSet> containingFileSet = getFileSet(fileSetNameQT);\n    if (!containingFileSet)\n    {\n        sendFileSetNotFoundError(fileSetNameQT);\n        return;\n    }\n\n    builderInterface->setFileBuilders(containingFileSet->getDefaultFileBuilders());\n}\n\n//-----------------------------------------------------------------------------\n// Function: PythonAPI::createDesign()\n//-----------------------------------------------------------------------------\nbool PythonAPI::createDesign(std::string const& vendor, std::string const& library, \n    std::string const& name, std::string const& version, StdRev revision /*= StdRev::Std22*/)\n{\n    if (vendor.empty() || library.empty() || name.empty() || version.empty())\n    {\n        messager_->showError(\"Error in given VLNV.\");\n        return false;\n    }\n\n    VLNV componentVLNV(VLNV::DESIGN, \n        QString::fromStdString(vendor), \n        QString::fromStdString(library),\n        QString::fromStdString(name),\n        QString::fromStdString(version));\n\n    if (createComponent(vendor, library, name, version, revision) == false)\n    {\n        messager_->showError(\"Error in creating containing component.\");\n        return false;\n    }\n\n    VLNV designVLNV(VLNV::DESIGN, componentVLNV.getVendor(), componentVLNV.getLibrary(),\n        componentVLNV.getName() + \".design\", componentVLNV.getVersion());\n    VLNV desConfVLNV(VLNV::DESIGNCONFIGURATION, componentVLNV.getVendor(), componentVLNV.getLibrary(),\n        componentVLNV.getName()+ \".designcfg\", componentVLNV.getVersion());\n\n    if (library_->contains(designVLNV))\n    {\n        return false;\n    }\n\n    QSharedPointer<DesignConfigurationInstantiation> hierarchicalInstantiation\n    (new DesignConfigurationInstantiation(desConfVLNV.getName() + \"_\" + desConfVLNV.getVersion()));\n\n    QSharedPointer<ConfigurableVLNVReference> tempReference(new ConfigurableVLNVReference(desConfVLNV));\n    hierarchicalInstantiation->setDesignConfigurationReference(tempReference);\n\n    QSharedPointer<View> newHierarchicalView(new View(QStringLiteral(\"hierarchical\")));\n    newHierarchicalView->setDesignConfigurationInstantiationRef(hierarchicalInstantiation->name());\n\n    activeComponent_->getDesignConfigurationInstantiations()->append(hierarchicalInstantiation);\n    activeComponent_->getViews()->append(newHierarchicalView);\n\n    auto design = QSharedPointer<Design>(new Design(designVLNV, Document::Revision::Std14));\n    design->setVersion(KactusAPI::getVersionFileString());\n    design->setDesignImplementation(KactusAttribute::HW);\n\n\n    auto designConf = QSharedPointer<DesignConfiguration>(new DesignConfiguration(desConfVLNV, Document::Revision::Std14));\n    designConf->setDesignRef(designVLNV);\n    designConf->setDesignConfigImplementation(KactusAttribute::HW);\n    designConf->setVersion(KactusAPI::getVersionFileString());\n\n    if (QString directory = KactusAPI::getDefaultLibraryPath() + \"/\" + designVLNV.toString(QStringLiteral(\"/\"));        \n        !library_->writeModelToFile(activeComponent_) ||\n        !library_->writeModelToFile(directory, design) ||\n        !library_->writeModelToFile(directory, designConf))\n    {\n        messager_->showError(\"Error saving file to disk.\");\n        return false;\n    }\n\n    openDesign(designVLNV.toString().toStdString());\n\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PythonAPI::getDesignStdRevision()\n//-----------------------------------------------------------------------------\nstd::string PythonAPI::getDesignStdRevision() const\n{\n    if (activeDesign_)\n    {\n        return Document::toStdString(activeDesign_->getRevision());\n    }\n\n    return std::string();\n}\n\n//-----------------------------------------------------------------------------\n// Function: PythonAPI::sendMemoryMapNotFoundError()\n//-----------------------------------------------------------------------------\nvoid PythonAPI::sendMemoryMapNotFoundError(QString const& mapName) const\n{\n    messager_->showError(QString(\"Could not find memory map %1 within component %2\").\n        arg(mapName, activeComponent_->getVlnv().toString()));\n}\n\n//-----------------------------------------------------------------------------\n// Function: PythonAPI::sendAddressBlockNotFoundError()\n//-----------------------------------------------------------------------------\nvoid PythonAPI::sendAddressBlockNotFoundError(QString const& mapName, QString const& blockName) const\n{\n    messager_->showError(QString(\"Could not find address block %1 within memory map %2 in component %3\").\n        arg(blockName, mapName, activeComponent_->getVlnv().toString()));\n}\n\n//-----------------------------------------------------------------------------\n// Function: PythonAPI::sendRegisterNotFoundError()\n//-----------------------------------------------------------------------------\nvoid PythonAPI::sendRegisterNotFoundError(QString const& mapName, QString const& blockName,\n    QString const& registerName) const\n{\n    messager_->showError(\n        QString(\"Could not find register %1 within address block %2 in memory map %3 in component %4\").\n        arg(registerName, blockName, mapName, activeComponent_->getVlnv().toString()));\n}\n\n//-----------------------------------------------------------------------------\n// Function: PythonAPI::sendFieldNotFoundError()\n//-----------------------------------------------------------------------------\nvoid PythonAPI::sendFieldNotFoundError(QString const& mapName, QString const& blockName,\n    QString const& registerName, QString const& fieldName) const\n{\n    messager_->showError(\n        QString(\"Could not find field %1 within register %2 in address block %3 in memory map %4 in component %5\").\n        arg(fieldName, registerName, blockName, mapName, activeComponent_->getVlnv().toString()));\n}\n\n//-----------------------------------------------------------------------------\n// Function: PythonAPI::sendFileSetNotFoundError()\n//-----------------------------------------------------------------------------\nvoid PythonAPI::sendFileSetNotFoundError(QString const& setName) const\n{\n    messager_->showError(QString(\"Could not find file set %1 within component %2\").\n        arg(setName, activeComponent_->getVlnv().toString()));\n}\n\n//-----------------------------------------------------------------------------\n// Function: PythonAPI::openDesign()\n//-----------------------------------------------------------------------------\nbool PythonAPI::openDesign(std::string const& vlnvString)\n{\n    QString designVLNV = QString::fromStdString(vlnvString);\n    QSharedPointer<Document> designDocument = getDocument(designVLNV);\n    if (designDocument)\n    {\n        QSharedPointer<Design> design = designDocument.dynamicCast<Design>();\n        if (design)\n        {\n            activeDesign_ = design;\n            messager_->showMessage(QString(\"Design %1 is open\").arg(designVLNV));\n\n            instanceInterface_->setComponentInstances(activeDesign_);\n            connectionInterface_->setInterconnections(activeDesign_);\n            adhocConnectionInterface_->setConnections(activeDesign_);\n\n            return true;\n        }\n        else\n        {\n            messager_->showError(QString(\"The given VLNV %1 is not a design\").arg(designVLNV));\n            return false;\n        }\n    }\n    else\n    {\n        messager_->showError(QString(\"Could not open document with VLNV %1\").arg(designVLNV));\n        return false;\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: PythonAPI::closeOpenDesign()\n//-----------------------------------------------------------------------------\nvoid PythonAPI::closeOpenDesign()\n{\n    if (activeDesign_)\n    {\n        messager_->showMessage(QString(\"Design %1 is closed\").arg(activeDesign_->getVlnv().toString()));\n    }\n\n    activeDesign_ = QSharedPointer<Design>();\n}\n\n//-----------------------------------------------------------------------------\n// Function: PythonAPI::saveDesign()\n//-----------------------------------------------------------------------------\nvoid PythonAPI::saveDesign()\n{\n    if (activeDesign_)\n    {\n        messager_->showMessage(QString(\"Saving design %1 ...\").arg(activeDesign_->getVlnv().toString()));\n\n        if (library_->writeModelToFile(activeDesign_))\n        {\n            messager_->showMessage(QString(\"Save complete\"));\n        }\n        else\n        {\n            messager_->showError(QString(\"Could not save design %1\").arg(activeDesign_->getVlnv().toString()));\n        }\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: PythonAPI::addComponentInstance()\n//-----------------------------------------------------------------------------\nbool PythonAPI::addComponentInstance(std::string const& vlnvString, std::string const& instanceName)\n{\n    if (!activeDesign_)\n    {\n        messager_->showMessage(QString(\"No open design\"));\n        return false;\n    }\n\n    QString combinedVLNV = QString::fromStdString(vlnvString);\n    QSharedPointer<Document> instanceDocument = getDocument(combinedVLNV);\n    if (!instanceDocument)\n    {\n        messager_->showMessage(QString(\"Could not find document %1\").arg(combinedVLNV));\n        return false;\n    }\n\n    QSharedPointer<Component> instanceComponent = instanceDocument.dynamicCast<Component>();\n    if (!instanceComponent)\n    {\n        messager_->showMessage(QString(\"%1 is not a component\").arg(combinedVLNV));\n        return false;\n    }\n\n    QStringList vlnvList = combinedVLNV.split(\":\");\n    if (vlnvList.size() < 4)\n    {\n        messager_->showMessage(QString(\"The VLNV %1 is not correct\").arg(combinedVLNV));\n        return false;\n    }\n\n    std::string newVendor = vlnvList.at(0).toStdString();\n    std::string newLibrary = vlnvList.at(1).toStdString();\n    std::string newName = vlnvList.at(2).toStdString();\n    std::string newVersion = vlnvList.at(3).toStdString();\n\n    instanceInterface_->addComponentInstance(instanceName);\n    return instanceInterface_->setComponentReference(instanceName, newVendor, newLibrary, newName, newVersion);\n}\n\n//-----------------------------------------------------------------------------\n// Function: PythonAPI::removeComponentInstance()\n//-----------------------------------------------------------------------------\nbool PythonAPI::removeComponentInstance(std::string const& instanceName)\n{\n    if (!activeDesign_)\n    {\n        messager_->showMessage(QString(\"No open design\"));\n        return false;\n    }\n\n    return instanceInterface_->removeComponentInstance(instanceName);\n}\n\n//-----------------------------------------------------------------------------\n// Function: PythonAPI::removeInstanceConnections()\n//-----------------------------------------------------------------------------\nbool PythonAPI::removeInstanceConnections(std::string const& instanceName)\n{\n    return connectionInterface_->removeInstanceInterconnections(instanceName);\n}\n\n//-----------------------------------------------------------------------------\n// Function: PythonAPI::removeInstanceAdHocConnections()\n//-----------------------------------------------------------------------------\nbool PythonAPI::removeInstanceAdHocConnections(std::string const& instanceName)\n{\n    return adhocConnectionInterface_->removeInstanceAdHocConnections(instanceName);\n}\n\n//-----------------------------------------------------------------------------\n// Function: PythonAPI::renameInstance()\n//-----------------------------------------------------------------------------\nbool PythonAPI::renameInstance(std::string const& currentName, std::string const& newName)\n{\n    return instanceInterface_->setName(currentName, newName);\n}\n\n//-----------------------------------------------------------------------------\n// Function: PythonAPI::createConnection()\n//-----------------------------------------------------------------------------\nbool PythonAPI::createConnection(std::string const& startInstanceName, std::string const& startBus,\n    std::string const& endInstanceName, std::string const& endBus)\n{\n    QString startInstanceNameQ = QString::fromStdString(startInstanceName);\n    QString endInstanceNameQ = QString::fromStdString(endInstanceName);\n    QString startBusNameQ = QString::fromStdString(startBus);\n    QString endBusNameQ = QString::fromStdString(endBus);\n\n    if (!connectionEndsCheck(startInstanceNameQ, startBusNameQ, endInstanceNameQ, endBusNameQ, false))\n    {\n        messager_->showMessage(QString(\"Could not create connection\"));\n        return false;\n    }\n\n    connectionInterface_->addInterconnection(startInstanceName, startBus, endInstanceName, endBus);\n\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PythonAPI::createHierarchicalConnection()\n//-----------------------------------------------------------------------------\nbool PythonAPI::createHierarchicalConnection(std::string const& instanceName, std::string const& instanceBus,\n    std::string const& topBus)\n{\n    QString instanceNameQ = QString::fromStdString(instanceName);\n    QString instanceBusNameQ = QString::fromStdString(instanceBus);\n    QString topBusQ = QString::fromStdString(topBus);\n\n    if (!instanceExists(instanceNameQ))\n    {\n        messager_->showMessage(QString(\"Could not create connection\"));\n        return false;\n    }\n\n    connectionInterface_->addHierarchicalInterconnection(instanceName, instanceBus, topBus);\n\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PythonAPI::connectionExistenceCheck()\n//-----------------------------------------------------------------------------\nbool PythonAPI::connectionEndsCheck(QString const& startInstanceName, QString const& startBus,\n    QString const& endInstanceName, QString const& endBus, bool isAdHocConnection)\n{\n    if (instanceExists(startInstanceName) == false || instanceExists(endInstanceName) == false)\n    {\n        return false;\n    }\n\n    QSharedPointer<ConfigurableVLNVReference> startComponenReference =\n        instanceInterface_->getComponentReference(startInstanceName.toStdString());\n    QSharedPointer<ConfigurableVLNVReference> endComponentReference =\n        instanceInterface_->getComponentReference(endInstanceName.toStdString());\n    QSharedPointer<const Document> startDocument = library_->getModelReadOnly(*startComponenReference.data());\n    QSharedPointer<const Document> endDocument = library_->getModelReadOnly(*endComponentReference.data());\n    QSharedPointer<const Component> startComponent = startDocument.dynamicCast<const Component>();\n    QSharedPointer<const Component> endComponent = endDocument.dynamicCast<const Component>();\n\n\n    if (isAdHocConnection)\n    {\n        return endsCheckForAdHoc(\n            startComponent, startBus, startInstanceName, endComponent, endBus, endInstanceName);\n    }\n    else\n    {\n        return endsCheckForInterconnection(\n            startComponent, startBus, startInstanceName, endComponent, endBus, endInstanceName);\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: PythonAPI::instanceExists()\n//-----------------------------------------------------------------------------\nbool PythonAPI::instanceExists(QString const& instanceName) const\n{\n    if (!instanceInterface_->instanceExists(instanceName.toStdString()))\n    {\n        messager_->showMessage(QString(\"Could not find component instance %1 within %2\").\n            arg(instanceName, activeDesign_->getVlnv().toString()));\n        return false;\n    }\n\n    QSharedPointer<ConfigurableVLNVReference> instanceComponenReference =\n        instanceInterface_->getComponentReference(instanceName.toStdString());\n\n    if (!instanceComponenReference)\n    {\n        messager_->showMessage(QString(\"Component instance %1 does not have a component reference\").\n            arg(instanceName));\n        return false;\n    }\n\n    QSharedPointer<const Document> instanceDocument =\n        library_->getModelReadOnly(*instanceComponenReference.data());\n    if (!instanceDocument)\n    {\n        messager_->showMessage(QString(\"Component instance %1 references a non-existing document %2\").\n            arg(instanceName, instanceComponenReference->toString()));\n        return false;\n    }\n\n    QSharedPointer<const Component> instanceComponent = instanceDocument.dynamicCast<const Component>();\n    if (!instanceComponent)\n    {\n        messager_->showMessage(QString(\"Component instance %1 component reference %1 is not a component\").\n            arg(instanceName, instanceComponenReference->toString()));\n        return false;\n    }\n\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PythonAPI::endsCheckForAdHoc()\n//-----------------------------------------------------------------------------\nbool PythonAPI::endsCheckForAdHoc(QSharedPointer<const Component> startComponent, QString const& startBus,\n    QString const& startInstanceName, QSharedPointer<const Component> endComponent, QString const& endBus,\n    QString const& endInstanceName)\n{\n    openComponent(startComponent->getVlnv().toString().toStdString());\n\n    DirectionTypes::Direction startDirection =\n        DirectionTypes::str2Direction(QString::fromStdString(portsInterface_->getDirection(\n            startBus.toStdString())), DirectionTypes::DIRECTION_INVALID);\n\n    if (!portsInterface_->portExists(startBus.toStdString()))\n    {\n        messager_->showMessage(QString(\"Could not find port %1 within component instance %2.\").\n            arg(startBus, startInstanceName));\n        return false;\n    }\n\n    openComponent(endComponent->getVlnv().toString().toStdString());\n    DirectionTypes::Direction endDirection = DirectionTypes::str2Direction(QString::fromStdString(\n        portsInterface_->getDirection(endBus.toStdString())), DirectionTypes::DIRECTION_INVALID);\n\n    if (!portsInterface_->portExists(endBus.toStdString()))\n    {\n        messager_->showMessage(QString(\"Could not find port %1 within component instance %2.\").\n            arg(endBus, endInstanceName));\n        return false;\n    }\n\n    closeOpenComponent();\n\n    if (startDirection == DirectionTypes::DIRECTION_INVALID ||\n        endDirection == DirectionTypes::DIRECTION_INVALID ||\n        (startDirection == DirectionTypes::IN && endDirection == DirectionTypes::IN) ||\n        (startDirection == DirectionTypes::OUT && endDirection == DirectionTypes::OUT))\n    {\n        messager_->showMessage(QString(\"Ports %1 in %2 and %3 in %4 have incompatible directions %5 and %6.\").\n            arg(startBus, startInstanceName, endBus, endInstanceName,\n                DirectionTypes::direction2Str(startDirection), DirectionTypes::direction2Str(endDirection)));\n        return false;\n    }\n\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PythonAPI::endsCheckForInterconnection()\n//-----------------------------------------------------------------------------\nbool PythonAPI::endsCheckForInterconnection(QSharedPointer<const Component> startComponent,\n    QString const& startBus, QString const& startInstanceName, QSharedPointer<const Component> endComponent,\n    QString const& endBus, QString const& endInstanceName)\n{\n    openComponent(startComponent->getVlnv().toString().toStdString());\n\n    ConfigurableVLNVReference startBusType = busInterface_->getBusType(startBus.toStdString());\n    General::InterfaceMode startMode = busInterface_->getMode(startBus.toStdString());\n    General::InterfaceMode startMonitor = busInterface_->getMonitorMode(startBus.toStdString());\n\n    if (!busInterface_->busInterfaceExists(startBus.toStdString()))\n    {\n        messager_->showMessage(QString(\"Could not find bus interface %1 within component instance %2.\").\n            arg(startBus, startInstanceName));\n        return false;\n    }\n\n    openComponent(endComponent->getVlnv().toString().toStdString());\n\n    ConfigurableVLNVReference endBusType = busInterface_->getBusType(endBus.toStdString());\n    General::InterfaceMode endMode = busInterface_->getMode(endBus.toStdString());\n    General::InterfaceMode endMonitor = busInterface_->getMonitorMode(endBus.toStdString());\n\n    if (!busInterface_->busInterfaceExists(endBus.toStdString()))\n    {\n        messager_->showMessage(QString(\"Could not find bus interface %1 within component instance %2.\").\n            arg(endBus, endInstanceName));\n        return false;\n    }\n\n    closeOpenComponent();\n\n    if (!BusInterfaceUtilities::busDefinitionVLNVsMatch(startBusType, endBusType, library_))\n    {\n        messager_->showMessage(QString(\"Bus interfaces %1 in %2 and %3 in %4 are not of the same bus type\").\n            arg(startBus, startInstanceName, endBus, endInstanceName));\n        return false;\n    }\n\n    QVector<General::InterfaceMode> startCompatibleModes =\n        General::getCompatibleInterfaceModesForActiveInterface(startMode);\n\n    if ((startMode == General::MONITOR && startMonitor != endMode) ||\n        (endMode == General::MONITOR && endMonitor != startMode) ||\n        !startCompatibleModes.contains(endMode))\n    {\n        QString startModeString = General::interfaceMode2Str(startMode);\n        QString endModeString = General::interfaceMode2Str(endMode);\n        if (startMode == General::MONITOR)\n        {\n            startModeString = General::interfaceMode2Str(startMonitor);\n        }\n        if (endMode == General::MONITOR)\n        {\n            endModeString = General::interfaceMode2Str(endMonitor);\n        }\n\n        messager_->showMessage(QString(\n            \"Bus interface modes of %1 in %2 and %3 in %4 have incompatible bus interface modes %5 and %6.\").\n            arg(startBus, startInstanceName, endBus, endInstanceName, startModeString, endModeString));\n        return false;\n    }\n\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PythonAPI::removeConnection()\n//-----------------------------------------------------------------------------\nbool PythonAPI::removeInstanceConnection(std::string const& startInstanceName, std::string const& startBus,\n    std::string const& endInstanceName, std::string const& endBus)\n{\n    std::string connectionName =\n        connectionInterface_->getConnectionName(startInstanceName, startBus, endInstanceName, endBus);\n\n    return removeConnection(connectionName);\n}\n\n//-----------------------------------------------------------------------------\n// Function: PythonAPI::removeHierarchicalConnection()\n//-----------------------------------------------------------------------------\nbool PythonAPI::removeHierarchicalConnection(std::string const& instanceName, std::string const& instanceBus,\n    std::string const& topBus)\n{\n    std::string connectionName =\n        connectionInterface_->getHierarchicalConnectionName(instanceName, instanceBus, topBus);\n\n    return removeConnection(connectionName);\n}\n\n//-----------------------------------------------------------------------------\n// Function: PythonAPI::removeConnection()\n//-----------------------------------------------------------------------------\nbool PythonAPI::removeConnection(std::string const& connectionName)\n{\n    bool success = connectionInterface_->removeInterconnection(connectionName);\n\n    if (success == false)\n    {\n        messager_->showMessage(QString(\"Could not find connection %1.\").\n            arg(QString::fromStdString(connectionName)));\n    }\n\n    return success;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PythonAPI::renameConnection()\n//-----------------------------------------------------------------------------\nbool PythonAPI::renameConnection(std::string const& currentName, std::string const& newName)\n{\n    return connectionInterface_->setName(currentName, newName);\n}\n\n//-----------------------------------------------------------------------------\n// Function: PythonAPI::createAdHocConnection()\n//-----------------------------------------------------------------------------\nbool PythonAPI::createAdHocConnection(std::string const& startInstanceName, std::string const& startPort,\n    std::string const& endInstanceName, std::string const& endPort)\n{\n    QString startInstanceNameQ = QString::fromStdString(startInstanceName);\n    QString endInstanceNameQ = QString::fromStdString(endInstanceName);\n    QString startPortNameQ = QString::fromStdString(startPort);\n    QString endPortNameQ = QString::fromStdString(endPort);\n\n    if (!connectionEndsCheck(startInstanceNameQ, startPortNameQ, endInstanceNameQ, endPortNameQ, true))\n    {\n        messager_->showMessage(QString(\"Could not create connection\"));\n        return false;\n    }\n\n    adhocConnectionInterface_->addAdHocConnection(startInstanceName, startPort, endInstanceName, endPort);\n\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PythonAPI::createHierarchicalAdHocConnection()\n//-----------------------------------------------------------------------------\nbool PythonAPI::createHierarchicalAdHocConnection(std::string const& instanceName, std::string const& instancePort,\n    std::string const& topPort)\n{\n    QString instanceNameQ = QString::fromStdString(instanceName);\n    QString instancePortQ = QString::fromStdString(instancePort);\n    QString topPortQ = QString::fromStdString(topPort);\n\n    if (!instanceExists(instanceNameQ))\n    {\n        messager_->showMessage(QString(\"Could not create connection\"));\n        return false;\n    }\n\n    adhocConnectionInterface_->addHierarchicalAdHocConnection(instanceName, instancePort, topPort);\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PythonAPI::removeInstanceAdHocConnection()\n//-----------------------------------------------------------------------------\nbool PythonAPI::removeInstanceAdHocConnection(std::string const& startInstanceName, std::string const& startPort,\n    std::string const& endInstanceName, std::string const& endPort)\n{\n    std::string connectionName =\n        adhocConnectionInterface_->getConnectionName(startInstanceName, startPort, endInstanceName, endPort);\n\n    return removeAdHocConnection(connectionName);\n}\n\n//-----------------------------------------------------------------------------\n// Function: PythonAPI::removeAdHocConnection()\n//-----------------------------------------------------------------------------\nbool PythonAPI::removeAdHocConnection(std::string const& connectionName)\n{\n    bool success = adhocConnectionInterface_->removeAdHocConnection(connectionName);\n    if (success == false)\n    {\n        messager_->showMessage(QString(\"Could not find connection %1.\").\n            arg(QString::fromStdString(connectionName)));\n    }\n\n    return success;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PythonAPI::removeHierarchicalAdHocConnection()\n//-----------------------------------------------------------------------------\nbool PythonAPI::removeHierarchicalAdHocConnection(std::string const& instanceName, std::string const& instancePort,\n    std::string const& topPort)\n{\n    std::string connectionName =\n        adhocConnectionInterface_->getHierarchicalConnectionName(instanceName, instancePort, topPort);\n\n    return removeAdHocConnection(connectionName);\n}\n\n//-----------------------------------------------------------------------------\n// Function: PythonAPI::renameAdHocConnection()\n//-----------------------------------------------------------------------------\nbool PythonAPI::renameAdHocConnection(std::string const& currentName, std::string const& newName)\n{\n    return adhocConnectionInterface_->setName(currentName, newName);\n}\n"
  },
  {
    "path": "PythonAPI/PythonAPI.h",
    "content": "//-----------------------------------------------------------------------------\n// File: PythonAPI.h\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Mikko Teuho\n// Date: 12.02.2020\n//\n// Description:\n// Interface for accessing Kactus2 data using Python.\n//-----------------------------------------------------------------------------\n\n#ifndef PYTHON_API_H\n#define PYTHON_API_H\n\n#include \"pythonapi_global.h\"\n\n#include <KactusAPI/KactusAPI.h>\n\n#include <string>\n#include <vector>\n#include <QSharedPointer>\n\n#include <KactusAPI/include/ComponentInstanceInterface.h>\n#include <KactusAPI/include/InterconnectionInterface.h>\n#include <KactusAPI/include/AdHocConnectionInterface.h>\n\n#include <KactusAPI/include/BusInterfaceInterface.h>\n#include <KactusAPI/include/BusInterfaceInterfaceFactory.h>\n#include <KactusAPI/include/ComponentAndInstantiationsParameterFinder.h>\n#include <KactusAPI/include/IPXactSystemVerilogParser.h>\n#include <KactusAPI/include/ExpressionFormatter.h>\n\n#include <KactusAPI/include/PortsInterface.h>\n#include <KactusAPI/include/ParametersInterface.h>\n\n#include <IPXACTmodels/Component/validators/PortValidator.h>\n\nclass MessageMediator;\n\nclass Component;\nclass Field;\nclass Register;\nclass RegisterBase;\nclass AddressBlock;\nclass MemoryMap;\nclass FileSet;\n\nclass MemoryMapInterface;\nclass FileSetInterface;\n\nclass ComponentParameterFinder;\nclass ExpressionParser;\nclass PortValidator;\nclass ExpressionFormatter;\n\nclass ParameterValidator;\nclass MemoryMapValidator;\n\nclass Design;\n\n\n//-----------------------------------------------------------------------------\n//! Interface for accessing Kactus2 data using Python.\n//-----------------------------------------------------------------------------\nclass PythonAPI\n{\npublic:\n    \n    /*!\n     *  IP-XACT std revision for use in python.\n     */\n    enum StdRev\n    {\n        Std14, // IEEE 1685-2014\n        Std22  // IEEE 1685-2022\n    };\n\n    /*!\n     *  The constructor.\n     */\n    PythonAPI();\n\n    /*!\n     *  The destructor.\n     */\n    ~PythonAPI() = default;\n   \n    /*!\n     *  Get Kactus2 version.\n     *\n     *    @return The current Kactus2 version.\n     */\n    std::string getVersion() const;\n\n    /*!\n     *\tGet configured active library paths.\n     *\n     *    @return The configured active library paths.\n     */\n    std::vector<std::string> getActiveLibraryPaths() const;\n\n    /*!\n     *\tGet all configured active and inactive library paths.\n     *\t    \n     *    @return All of the configured library paths.\n     */\n    std::vector<std::string> getAllLibraryPaths() const;\n    \n    /*!\n     *\tSet a given library path as active or inactive. If set as active, also add the path if not found.\n     *\n     *    @param [in] path         The path to set active.\n     *    @param [in] isActive     Indicates if the path should be set active or inactive.\n     */\n    void setLibraryPathActive(std::string const& path, bool isActive);\n\n    /*!\n     *\tAdd a new library path and set as active by default.\n     *  \n     *    @param [in] path         The path to add.\n     *    @param [in] isActive     Indicates if the new path should be set active or not.\n     */\n    void addLibraryPath(std::string const& path, bool isActive = true);\n\n    /*!\n     *\tRemove a library path. Prints error if trying to remove default path.\n     *  \n     *    @param [in] path     The path to remove.\n     */\n    void removeLibraryPath(std::string const& path);\n\n    /*!\n     *  Get the interface for accessing the component ports.\n     *\n     *    @return Interface for accessing the component ports.\n     */\n    PortsInterface* getPortsInterface() const;\n\n    /*!\n     *  Get the interface for accessing the component parameters.\n     *\n     *    @return Interface for accessing the component parameters.\n     */\n    ParametersInterface* getComponentParameterInterface() const;\n\n    /*!\n     *  Get the interface for accessing component memory maps.\n     *\n     *    @return Interface for accessing component memory maps.\n     */\n    MemoryMapInterface* getMapInterface();\n\n    /*!\n     *  Get the interface for accessing file sets.\n     *\n     *    @return Interface for accessing file sets.\n     */\n    FileSetInterface* getFileSetInterface();\n\n    /*!\n     *  Get the interface for accessing bus interfaces.\n     *\n     *    @return Interface for accessing bus interfaces.\n     */\n    BusInterfaceInterface* getBusInterface();\n\n    /*!\n     * Gets the paths where IP-XACT files are stored.\n     *\n     *    @return The paths where IP-XACT files are stored.\n     */\n    void setupLibrary(std::string const& settingsFileString);\n\n    /*!\n     * Sets new active library paths. First path is set as default.\n     *\n     *    @param [in] paths  The new locations that are currently available to store the files.\n     */\n    void setLibraryPaths(std::vector<std::string> const& paths) const;\n\n    /*!\n     * Get the default library path for IP-XACT files.\n     *\n     *    @return The default path for IP-XACT files.\n     */\n    std::string getDefaultLibraryPath() const;\n\n    /*!\n     * Set the default library path for IP-XACT files.\n     *\n     *    @param [in] path  The default path to set for IP-XACT files.\n     */\n    void setDefaultLibraryPath(std::string const& path) const;\n    \n    /*!\n     * Import a source file (RTL) into the library as a component.\n     *\n     *    @param [in] filePath     The path to the file to import.\n     *    @param [in] targetVLNV   The VLNV to use for the imported component.\n     *    @param [in] overwrite    Overwrite the component in the library, if it already exists.\n     *\n     *    @return The number of imported IP-XACT components.\n     */\n    int importFile(std::string const& path, std::string const& vlnv, bool overwrite = false) const;\n\n    /*!\n     * Run a file generation for a component.\n     *\n     *    @param [in] format           The requested output format.\n     *    @param [in] vlnv             The component VLNV to run the generation for.\n     *    @param [in] viewName         The component view to run the generation for.\n     *    @param [in] outputDirectory  The output directory for the generation results.\n     */\n     void generate(std::string const& format, std::string const& vlnv, std::string const& viewName,\n        std::string const& outputDirectory) const;\n\n     void generateInterconnect();\n\n    /*!\n     *  Get the number of files in the library.\n     *\n     *    @return The number of files in the library.\n     */\n    int getFileCount() const;\n\n    /*!\n     *  List all the VLNVs in the library.\n     *\n     *    @param[in] vendor   The desired vendor.\n     *\n     *    @return List of VLNVs in Vendor:Library:Name:Version format.\n     */\n\n    std::vector<std::string> listVLNVs(std::string const& vendor = std::string()) const;\n\n    /*!\n     *  List all the component VLNVs in the library.\n     *\n     *    @return List of component VLNVs in Vendor:Library:Name:Version format.\n     */\n    std::vector<std::string> listComponentVLNVs() const;\n\n    /*!\n     *  Check if the selected VLNV exists in the library.\n     *\n     *    @param [in] vendor      Vendor of the selected VLNV.\n     *    @param [in] library     Library of the selected VLNV.\n     *    @param [in] name        Name of the selected VLNV.\n     *    @param [in] version     Version of the selected VLNV.\n     *\n     *    @return True, if the VLNV exists in the library, false otherwise.\n     */\n    bool vlnvExistsInLibrary(std::string const& vendor, std::string const& library, std::string const& name,\n        std::string const& version) const;\n\n    /*!\n     *  Create a new component with the selected VLNV. Defaults to IP-XACT 2022.\n     *\n     *    @param [in] vendor      Vendor of the selected VLNV.\n     *    @param [in] library     Library of the selected VLNV.\n     *    @param [in] name        Name of the selected VLNV.\n     *    @param [in] version     Version of the selected VLNV.\n     *    @param [in] revision    IP-XACT standard revision to use.\n     *\n     *    @return True, if the component was created successfully, false otherwise.\n     */\n    bool createComponent(std::string const& vendor, std::string const& library, std::string const& name,\n        std::string const& version, StdRev revision = StdRev::Std22);\n\n    /*!\n     *  Get the directory path of the selected VLNV document.\n     *\n     *    @param [in] vendor      Vendor of the selected VLNV.\n     *    @param [in] library     Library of the selected VLNV.\n     *    @param [in] name        Name of the selected VLNV.\n     *    @param [in] version     Version of the selected VLNV.\n     *\n     *    @return Path of the selected VLNV document.\n     */\n    std::string getVLNVDirectory(std::string const& vendor, std::string const& library, std::string const& name,\n        std::string const& version) const;\n\n    /*!\n     *  Get the name of the first view contained within the active component.\n     *\n     *    @return Name of the first view contained within the active component.\n     */\n    std::string getFirstViewName() const;\n\n    /*!\n     *  Set the selected component as active component.\n     *\n     *    @param [in] componentVLNV   VLNV of the selected component.\n     *\n     *    @return True, if the component exists, false otherwise.\n     */\n    bool openComponent(std::string const& vlnvString);\n\n    /*!\n     *  Remove the active component.\n     */\n    void closeOpenComponent();\n\n    /*!\n     *  Get the name of the active component.\n     */\n\n    std::string getComponentName() const;\n\n    /*!\n     *  Get the description of the active component.\n     */\n\n    std::string getComponentDescription() const;\n\n    /*!\n     *\tGet the IP-XACT standard revision of the active component\n     */\n    std::string getComponentStdRevision() const;\n\n    /*!\n     *  Save the component to the library.\n     */\n    void saveComponent();\n\n\n    /*!\n     *  Set the available address blocks for the address block interface.\n     *\n     *    @param [in] mapName     Name of the memory map containing the desired address blocks.\n     */\n    void setBlocksForInterface(std::string const& mapName);\n\n    /*!\n     *  Set the available registers for the register interface.\n     *\n     *    @param [in] mapName     Name of the memory map containing the desired address blocks.\n     *    @param [in] blockName   Name of the address block containing the desired registers.\n     */\n    void setRegistersForInterface(std::string const& mapName, std::string const& blockName);\n\n    /*!\n     *  Set the available fields for the field interface.\n     *\n     *    @param [in] mapName         Name of the memory map containing the desired address blocks.\n     *    @param [in] blockName       Name of the address block containing the desired registers.\n     *    @param [in] registerName    Name of the register containing the desired fields.\n     */\n    void setFieldsForInterface(std::string const& mapName, std::string const& blockName,\n        std::string const& registerName);\n\n    /*!\n     *  Set the available resets for the reset interface.\n     *\n     *    @param [in] mapName         Name of the memory map containing the desired address blocks.\n     *    @param [in] blockName       Name of the address block containing the desired registers.\n     *    @param [in] registerName    Name of the register containing the desired fields.\n     *    @param [in] fieldName       Name of the field containing the desired resets.\n     */\n    void setResetsForInterface(std::string const& mapName, std::string const& blockName,\n        std::string const& registerName, std::string const& fieldName);\n\n    /*!\n     *  Set the available files for the file interface.\n     *\n     *    @param [in] setName     Name of the file set containing the available files.\n     */\n    void setFilesForInterface(std::string const& setName);\n\n    /*!\n     *  Set the available file builders for the file interface.\n     *\n     *    @param [in] setName     Name of the file set containing the available file builders.\n     */\n    void setFileBuildersForInterface(std::string const& setName);\n        \n    /*!\n     *  Create a new design with the selected VLNV. Defaults to IP-XACT 2022.\n     *\n     *    @param [in] vendor      Vendor of the selected VLNV.\n     *    @param [in] library     Library of the selected VLNV.\n     *    @param [in] name        Name of the selected VLNV.\n     *    @param [in] version     Version of the selected VLNV.\n     *    @param [in] revision    IP-XACT standard revision to use.\n     *\n     *    @return True, if the design was created successfully, false otherwise.\n     */\n    bool createDesign(std::string const& vendor, std::string const& library, std::string const& name,\n        std::string const& version, StdRev revision = StdRev::Std22);\n    \n    /*!\n     *\tGet the IP-XACT standard revision of the active design.\n     */\n    std::string getDesignStdRevision() const;\n\n    /*!\n     *  Set the selected design as active design.\n     *\n     *    @param [in] vlnvString  VLNV of the selected design.\n     *\n     *    @return True, if the design exists, false otherwise.\n     */\n    bool openDesign(std::string const& vlnvString);\n\n    /*!\n     *  Remove the active design.\n     */\n    void closeOpenDesign();\n\n    /*!\n     *  Save the design to the library.\n     */\n    void saveDesign();\n\n    /*!\n     *  Add the selected component instance to the active design.\n     *\n     *    @param [in] vlnvString      VLNV of the component within the selected component instance.\n     *    @param [in] instanceName    Name for the new component instance.\n     *\n     *    @return True, if successful, false otherwise.\n     */\n    bool addComponentInstance(std::string const& vlnvString, std::string const& instanceName);\n\n    /*!\n     *  Remove the selected component instance from the active design.\n     *\n     *    @param [in] instanceName    Name of the selected component instance.\n     *\n     *    @return True, if successful, false otherwise.\n     */\n    bool removeComponentInstance(std::string const& instanceName);\n\n    /*!\n     *  Remove connections from the selected component instance.\n     *\n     *    @param [in] instanceName    Name of the selected component instance.\n     *\n     *    @return True, if successful, false otherwise.\n     */\n    bool removeInstanceConnections(std::string const& instanceName);\n\n    /*!\n     *  Remove ad hoc connections from the selected component instance.\n     *\n     *    @param [in] instanceName    Name of the selected component instance.\n     *\n     *    @return True, if successful, false otherwise.\n     */\n    bool removeInstanceAdHocConnections(std::string const& instanceName);\n\n    /*!\n     *  Set a new name for the selected component instance.\n     *\n     *    @param [in] currentName     Name of the selected component instance.\n     *    @param [in] newName         New name for the component instance.\n     *\n     *    @return True, if successful, false otherwise.\n     */\n    bool renameInstance(std::string const& currentName, std::string const& newName);\n\n    /*!\n     *  Create an interconnection between two bus interfaces.\n     *\n     *    @param [in] startInstanceName   Name of the component instance containing the first bus interface.\n     *    @param [in] startBus            Name of the first bus interface.\n     *    @param [in] endInstanceName     Name of the component instance containing the second bus interface.\n     *    @param [in] endBus              Name of the second bus interface.\n     *\n     *    @return True, if the connection was created, false otherwise.\n     */\n    bool createConnection(std::string const& startInstanceName, std::string const& startBus,\n        std::string const& endInstanceName, std::string const& endBus);\n\n    /*!\n     *  Create a hierarchical interconnection between two bus interfaces.\n     *\n     *    @param [in] instanceName    Name of the component instance containing the selected bus interface.\n     *    @param [in] instanceBus     Name of the component instance bus interface.\n     *    @param [in] topBus          Name of the top component bus interface.\n     *\n     *    @return True, if the connection was created, false otherwise.\n     */\n    bool createHierarchicalConnection(std::string const& instanceName, std::string const& instanceBus,\n        std::string const& topBus);\n\n    /*!\n     *  Remove an interconnection between two bus interfaces.\n     *\n     *    @param [in] startInstanceName   Name of the component instance containing the first bus interface.\n     *    @param [in] startBus            Name of the first bus interface.\n     *    @param [in] endInstanceName     Name of the component instance containing the second bus interface.\n     *    @param [in] endBus              Name of the second bus interface.\n     *\n     *    @return True, if the connection was removed, false otherwise.\n     */\n    bool removeInstanceConnection(std::string const& startInstanceName, std::string const& startBus,\n        std::string const& endInstanceName, std::string const& endBus);\n\n    /*!\n     *  Remove an interconnection between two bus interfaces.\n     *\n     *    @param [in] instanceName    Name of the component instance containing the selected bus interface.\n     *    @param [in] instanceBus     Name of the component instance bus interface.\n     *    @param [in] topBus          Name of the top component bus interface.\n     *\n     *    @return True, if successful, false otherwise.\n     */\n    bool removeHierarchicalConnection(std::string const& instanceName, std::string const& instanceBus,\n        std::string const& topBus);\n\n    /*!\n     *  Set a new name for the selected interconnection.\n     *\n     *    @param [in] currentName     Name of the selected interconnection.\n     *    @param [in] newName         New name for the interconnection.\n     *\n     *    @return True, if successful, false otherwise.\n     */\n    bool renameConnection(std::string const& currentName, std::string const& newName);\n\n    /*!\n     *  Create an ad hoc connection between two ports.\n     *\n     *    @param [in] startInstanceName   Name of the component instance containing the first port.\n     *    @param [in] startPort           Name of the first port.\n     *    @param [in] endInstanceName     Name of the component instance containing the second port.\n     *    @param [in] endPort             Name of the second port.\n     *\n     *    @return True, if the connection was created, false otherwise.\n     */\n    bool createAdHocConnection(std::string const& startInstanceName, std::string const& startPort,\n        std::string const& endInstanceName, std::string const& endPort);\n\n    /*!\n     *  Create a hierarchical ad hoc connection between two ports.\n     *\n     *    @param [in] instanceName    Name of the component instance containing the selected port.\n     *    @param [in] instancePort    Name of the component instance port.\n     *    @param [in] topPort         Name of the top component port.\n     *\n     *    @return True, if successful, false otherwise.\n     */\n    bool createHierarchicalAdHocConnection(std::string const& instanceName, std::string const& instancePort,\n        std::string const& topPort);\n\n    /*!\n     *  Remove an ad hoc connection between two ports.\n     *\n     *    @param [in] startInstanceName   Name of the component instance containing the first port.\n     *    @param [in] startPort           Name of the first port.\n     *    @param [in] endInstanceName     Name of the component instance containing the second port.\n     *    @param [in] endPort             Name of the second port.\n     *\n     *    @return True, if the ad hoc connection was removed, false otherwise.\n     */\n    bool removeInstanceAdHocConnection(std::string const& startInstanceName, std::string const& startPort,\n        std::string const& endInstanceName, std::string const& endPort);\n\n    /*!\n     *  Remove a hierarchical ad hoc connection between two ports.\n     *\n     *    @param [in] instanceName    Name of the component instance containing the selected port.\n     *    @param [in] instancePort    Name of the component instance port.\n     *    @param [in] topPort         Name of the top component port.\n     *\n     *    @return True, if successful, false otherwise.\n     */\n    bool removeHierarchicalAdHocConnection(std::string const& instanceName, std::string const& instancePort,\n        std::string const& topPort);\n\n    /*!\n     *  Set a new name for the selected ad hoc connection.\n     *\n     *    @param [in] currentName     Name of the selected ad hoc connection.\n     *    @param [in] newName         New name for the ad hoc connection.\n     *\n     *    @return True, if successful, false otherwise.\n     */\n    bool renameAdHocConnection(std::string const& currentName, std::string const& newName);\n\nprivate:\n\n    /*!\n     *  Check if the connection end points exist.\n     *\n     *    @param [in] startInstanceName   Name of the instance containing the first interface.\n     *    @param [in] startBus            Name of the first interface.\n     *    @param [in] endInstanceName     Name of the instance containing the second interface.\n     *    @param [in] endBus              Name of the second interface.\n     *    @param [in] isAdHocConnection   Flag for ad hoc connections.\n     *\n     *    @return True, if the connection end points exist, false otherwise.\n     */\n    bool connectionEndsCheck(QString const& startInstanceName, QString const& startBus,\n        QString const& endInstanceName, QString const& endBus, bool isAdHocConnection);\n\n    /*!\n     *  Check if the selected component instance exists.\n     *\n     *    @param [in] instanceName    Name of the selected component instance.\n     *\n     *    @return True, if the component instance exists, false otherwise.\n     */\n    bool instanceExists(QString const& instanceName) const;\n\n    /*!\n     *  Check if the ad hoc connection end points exist.\n     *\n     *    @param [in] startComponent      Component containing the first port.\n     *    @param [in] startBus            Name of the first port.\n     *    @param [in] startInstanceName   Name of the instance containing the first port.\n     *    @param [in] endComponent        Component containing the second port.\n     *    @param [in] endBus              Name of the second port.\n     *    @param [in] endInstanceName     Name of the instance containing the second port.\n     *\n     *    @return True, if the ad hoc connection end points exist, false otherwise.\n     */\n    bool endsCheckForAdHoc(QSharedPointer<const Component> startComponent, QString const& startBus,\n        QString const& startInstanceName, QSharedPointer<const Component> endComponent, QString const& endBus,\n        QString const& endInstanceName);\n\n    /*!\n     *  Check if the interconnection end points exist.\n     *\n     *    @param [in] startComponent      Component containing the first bus interface.\n     *    @param [in] startBus            Name of the first bus interface.\n     *    @param [in] startInstanceName   Name of the instance containing the first bus interface.\n     *    @param [in] endComponent        Component containing the second bus interface.\n     *    @param [in] endBus              Name of the second bus interface.\n     *    @param [in] endInstanceName     Name of the instance containing the second bus interface.\n     *\n     *    @return True, if the interconnection end points exist, false otherwise.\n     */\n    bool endsCheckForInterconnection(QSharedPointer<const Component> startComponent, QString const& startBus,\n        QString const& startInstanceName, QSharedPointer<const Component> endComponent, QString const& endBus,\n        QString const& endInstanceName);\n\n    /*!\n     *  Remove the selected interconnection.\n     *\n     *    @param [in] connectionName  Name of the selected interconnection.\n     *\n     *    @return True, if successful, false otherwise.\n     */\n    bool removeConnection(std::string const& connectionName);\n\n    /*!\n     *  Remove the selected ad hoc connection.\n     *\n     *    @param [in] connectionName  Name of the selected ad hoc connection.\n     *\n     *    @return True, if successful, false otherwise.\n     */\n    bool removeAdHocConnection(std::string const& connectionName);\n\n    /*!\n     *  Get the selected document.\n     *\n     *    @param [in] vlnvString  VLNV of the selected document in string form.\n     *\n     *    @return The selected document.\n     */\n    QSharedPointer<Document> getDocument(QString const& vlnvString) const;\n\n    /*!\n     *  Construct validator for memory items.\n     */\n    void constructMemoryValidators();\n\n    /*!\n     *  Construct interfaces for memory items.\n     */\n    void constructMemoryInterface();\n\n    /*!\n     *  Construct the interfaces for file sets.\n     */\n    void constructFileSetInterface();\n\n    /*!\n     *  Get the selected memory map.\n     *\n     *    @param [in] mapName     Name of the selected memory map.\n     *\n     *    @return The selected memory map.\n     */\n    QSharedPointer<MemoryMap> getMemoryMap(QString const& mapName) const;\n\n    /*!\n     *  Get the selected address block.\n     *\n     *    @param [in] containingMap   Memory map containing the address block.\n     *    @param [in] blockName       Name of the selected address block.\n     *\n     *    @return The selected address block.\n     */\n    QSharedPointer<AddressBlock> getAddressBock(QSharedPointer<MemoryMap> containingMap, QString const& blockName)\n        const;\n\n    /*!\n     *  Get the selected register.\n     *\n     *    @param [in] containingBlock     Address block containing the registers.\n     *    @param [in] registerName        Name of the selected register.\n     *\n     *    @return The selected register.\n     */\n    QSharedPointer<Register> getRegister(QSharedPointer<AddressBlock> containingBlock, QString const& registerName)\n        const;\n\n    /*!\n     *  Get the selected field.\n     *\n     *    @param [in] containingRegister  Register containing the fields.\n     *    @param [in] fieldName           Name of the selected field.\n     *\n     *    @return The selected field.\n     */\n    QSharedPointer<Field> getField(QSharedPointer<Register> containingRegister, QString const& fieldName) const;\n\n    /*!\n     *  Get the selected file set.\n     *\n     *    @param [in] setName     Name of the selected file set.\n     *\n     *    @return The selected file set.\n     */\n    QSharedPointer<FileSet> getFileSet(QString const& setName) const;\n\n    /*!\n     *  Send an error text for a non-existing memory map.\n     *\n     *    @param [in] mapName     Name of the memory map.\n     */\n    void sendMemoryMapNotFoundError(QString const& mapName) const;\n\n    /*!\n     *  Send an error text for a non-existing address block.\n     *\n     *    @param [in] mapName     Name of the memory map containing the address block.\n     *    @param [in] blockName   Name of the address block.\n     */\n    void sendAddressBlockNotFoundError(QString const& mapName, QString const& blockName) const;\n\n    /*!\n     *  Send an error text for a non-existing register.\n     *\n     *    @param [in] mapName         Name of the memory map containing the address block.\n     *    @param [in] blockName       Name of the address block containing the register.\n     *    @param [in] registerName    Name of the register.\n     */\n    void sendRegisterNotFoundError(QString const& mapName, QString const& blockName, QString const& registerName)\n        const;\n\n    /*!\n     *  Send an error text for a non-existing field.\n     *\n     *    @param [in] mapName         Name of the memory map containing the address block.\n     *    @param [in] blockName       Name of the address block containing the register.\n     *    @param [in] registerName    Name of the register containing the field.\n     *    @param [in] fieldName       Name of the field.\n     */\n    void sendFieldNotFoundError(QString const& mapName, QString const& blockName, QString const& registerName,\n        QString const& fieldName) const;\n\n    /*!\n     *  Send an error text for a non-existing file set.\n     *\n     *    @param [in] setName     Name of the file set.\n     */\n    void sendFileSetNotFoundError(QString const& setName) const;\n\n    //-----------------------------------------------------------------------------\n    // Data.\n    //-----------------------------------------------------------------------------\n\n    //! Interface to the library.\n    LibraryInterface* library_{ KactusAPI::getLibrary() };\n\n    //! Message handler.\n    MessageMediator* messager_{ KactusAPI::getMessageChannel() };\n\n    //! Component parameter finder.\n    QSharedPointer<ComponentParameterFinder> parameterFinder_{ new ComponentAndInstantiationsParameterFinder(nullptr) };\n\n    //! Parser for expressions.\n    QSharedPointer<ExpressionParser> expressionParser_{ new IPXactSystemVerilogParser(parameterFinder_) };\n\n    //! Formatter for expressions.\n    QSharedPointer<ExpressionFormatter>expressionFormatter_{ new ExpressionFormatter(parameterFinder_) };\n\n    //! Currently active component.\n    QSharedPointer<Component> activeComponent_{ nullptr };\n\n    //! Currently active design.\n    QSharedPointer<Design> activeDesign_{ nullptr };\n\n    //! Validator for ports.\n    QSharedPointer<PortValidator> portValidator_{ new PortValidator(expressionParser_,\n        QSharedPointer<QList<QSharedPointer<View> > >()) };\n\n    //! Validator for parameters.\n    QSharedPointer<ParameterValidator> parameterValidator_{ new ParameterValidator(expressionParser_,\n        QSharedPointer<QList<QSharedPointer<Choice> > >(), Document::Revision::Std22) };\n\n    //! Validator for memory maps.\n    QSharedPointer<MemoryMapValidator> mapValidator_{ nullptr };\n\n    //! Interface for accessing the component ports. \n    PortsInterface* portsInterface_{ new PortsInterface(portValidator_, expressionParser_, expressionFormatter_) };\n\n    //! Interface for accessing bus interfaces.\n    BusInterfaceInterface* busInterface_{ BusInterfaceInterfaceFactory::createBusInterface(parameterFinder_,\n        expressionFormatter_, expressionParser_,\n        QSharedPointer<Component>(new Component(VLNV(), Document::Revision::Unknown)), library_) };\n\n    //! Interface for accessing the component parameters.\n    ParametersInterface* componentParameterInterface_{ new ParametersInterface(parameterValidator_, \n        expressionParser_, expressionFormatter_) };\n\n    //! Interface for accessing memory maps.\n    MemoryMapInterface* mapInterface_{ nullptr };\n\n    //! Interface for accessing file sets.\n    FileSetInterface* fileSetInterface_{ nullptr };\n\n    //! Interface for accessing interconnections.\n    InterconnectionInterface* connectionInterface_{ new InterconnectionInterface() };\n\n    //! Interface for accessing ad hoc connections.\n    AdHocConnectionInterface* adhocConnectionInterface_{ new AdHocConnectionInterface() };\n\n    //! Interface for accessing component instances.\n    ComponentInstanceInterface* instanceInterface_{ new ComponentInstanceInterface(connectionInterface_, \n        adhocConnectionInterface_) };\n\n};\n\n#endif // !PYTHON_API_H\n"
  },
  {
    "path": "PythonAPI/PythonAPI.i",
    "content": "/* File : pythonAPI.i */\n\n//%feature(\"autodoc\", \"2\");\n%module pythonAPI\n\n%include \"std_string.i\"\n%include \"std_vector.i\"\n%include \"std_map.i\"\n%include \"InterfaceFiles/QString.i\"\n%include \"InterfaceFiles/NameGroup.i\"\n\n%include <windows.i>\n#define Q_DECL_EXPORT __declspec(dllexport)\n#define Q_DECL_IMPORT __declspec(dllimport)\n\n%include \"../KactusAPI/KactusAPIGlobal.h\"\n\n%{\n#include \"../KactusAPI/KactusAPIGlobal.h\"\n#include \"PythonAPI.h\"\n#include \"../KactusAPI/include/CommonInterface.h\"\n#include \"../KactusAPI/include/NameGroupInterface.h\"\n#include \"../KactusAPI/include/ParameterizableInterface.h\"\n#include \"../KactusAPI/include/MasterPortInterface.h\"\n#include \"../KactusAPI/include/PortsInterface.h\"\n#include \"../KactusAPI/include/AbstractParameterInterface.h\"\n#include \"../KactusAPI/include/ParametersInterface.h\"\n#include \"../KactusAPI/include/MemoryMapInterface.h\"\n#include \"../KactusAPI/include/MemoryBlockInterface.h\"\n#include \"../KactusAPI/include/SubspaceMapInterface.h\"\n#include \"../KactusAPI/include/AddressBlockInterface.h\"\n#include \"../KactusAPI/include/RegisterInterface.h\"\n#include \"../KactusAPI/include/FieldInterface.h\"\n#include \"../KactusAPI/include/ResetInterface.h\"\n#include \"../KactusAPI/include/FileSetInterface.h\"\n#include \"../KactusAPI/include/FileInterface.h\"\n#include \"../KactusAPI/include/FileBuilderInterface.h\"\n#include \"../KactusAPI/include/AbstractionTypeInterface.h\"\n#include \"../KactusAPI/include/PortAbstractionInterface.h\"\n#include \"../KactusAPI/include/PortMapInterface.h\"\n#include \"../KactusAPI/include/BusInterfaceInterface.h\"\n#include \"../KactusAPI/include/InterconnectGenerator.h\"\n%}\n\n\nnamespace std {\n//\t%template(portsVector) vector<SimplePort*>;\n\t%template(stringVector) vector<string>;\t\n//\t%template(fieldInterfaceVector) vector<FieldInterface*>;\n//\t%template(resetInterfaceVector) vector<ResetInterface*>;\n//\t%template(registerInterfaceVector) vector<RegisterInterface*>;\n};\n\n/* Let's just grab the original header file here */\n%include \"PythonAPI.h\"\n%include \"../KactusAPI/include/CommonInterface.h\"\n%include \"../KactusAPI/include/NameGroupInterface.h\"\n%include \"../KactusAPI/include/ParameterizableInterface.h\"\n%include \"../KactusAPI/include/MasterPortInterface.h\"\n%include \"../KactusAPI/include/PortsInterface.h\"\n%include \"../KactusAPI/include/AbstractParameterInterface.h\"\n%include \"../KactusAPI/include/ParametersInterface.h\"\n%include \"../KactusAPI/include/MemoryMapInterface.h\"\n%include \"../KactusAPI/include/MemoryBlockInterface.h\"\n%include \"../KactusAPI/include/SubspaceMapInterface.h\"\n%include \"../KactusAPI/include/AddressBlockInterface.h\"\n%include \"../KactusAPI/include/RegisterInterface.h\"\n%include \"../KactusAPI/include/FieldInterface.h\"\n%include \"../KactusAPI/include/ResetInterface.h\"\n%include \"../KactusAPI/include/FileSetInterface.h\"\n%include \"../KactusAPI/include/FileInterface.h\"\n%include \"../KactusAPI/include/FileBuilderInterface.h\"\n%include \"../KactusAPI/include/AbstractionTypeInterface.h\"\n%include \"../KactusAPI/include/PortAbstractionInterface.h\"\n%include \"../KactusAPI/include/PortMapInterface.h\"\n%include \"../KactusAPI/include/BusInterfaceInterface.h\"\n#include \"../KactusAPI/include/InterconnectGenerator.h\"\n\n// Workaround fix for calling AddressBlockInterface/SubspaceMapInterface::addBlock(std::string const&) from python\n%extend AddressBlockInterface {\n    void addBlock(std::string const& newBlockName = std::string(\"\")) {\n        return static_cast<MemoryBlockInterface*>(self)->addBlock(newBlockName);\n    }\n}\n\n%extend SubspaceMapInterface {\n    void addBlock(std::string const& newBlockName = std::string(\"\")) {\n        return static_cast<MemoryBlockInterface*>(self)->addBlock(newBlockName);\n    }\n}\n"
  },
  {
    "path": "PythonAPI/PythonAPI.pri",
    "content": "# ----------------------------------------------------\n# This file is generated by the Qt Visual Studio Tools.\n# ------------------------------------------------------\n\n\nHEADERS += ./PythonAPI.h \\\n    ./pythonapi_global.h \\\n    ../common/validators/LibraryPathValidator/librarypathvalidator.h \\\n    ../KactusAPI/include/InterconnectGenerator.h\n\nSOURCES += ./PythonAPI.cpp \\\n    ../common/validators/LibraryPathValidator/librarypathvalidator.cpp \\\n    ../KactusAPI/plugins/InterconnectGenerator/InterconnectGenerator.cpp \\\n    ./PythonAPI_wrap.cxx"
  },
  {
    "path": "PythonAPI/PythonAPI.pro",
    "content": "# ----------------------------------------------------\n# This file is generated by the Qt Visual Studio Tools.\n# ------------------------------------------------------\n\nTEMPLATE = lib\nTARGET = PythonAPI\nDESTDIR = .\nCONFIG += c++11 dll\nDEFINES += PYTHONAPI_LIB\nQT += core gui widgets xml\n\nDEPENDPATH += ..\nINCLUDEPATH += ..\\\n    ../KactusAPI/include \n\n\nCONFIG(debug, debug|release) {\n    # debug mode\n    LIBS += \\\n        -L../executable -lIPXACTmodelsd \\\n        -L../executable -lKactusAPId\n            \n    MOC_DIR += ./GeneratedFiles/Debug\n    OBJECTS_DIR += Debug\n    TARGET = PythonAPId\n\n} else {\n    # release mode \n    LIBS += \\\n        -L../executable -lIPXACTmodels \\\n        -L../executable -lKactusAPI\n    \n    MOC_DIR += ./GeneratedFiles/Release\n    OBJECTS_DIR += Release\n    TARGET = PythonAPI\n}\n\n\nUI_DIR += ./GeneratedFiles\nRCC_DIR += ./GeneratedFiles\n\nQMAKE_CXXFLAGS += $$PYTHON_C_FLAGS\n\ninclude(PythonAPI.pri)\n\n# Run SWIG to generate PythonAPI_wrap.cxx.\nswig.depends = ./PythonAPI.i\nswig.target = PythonAPI_wrap.cxx\nswig.commands = swig -python -doxygen -c++ -O PythonAPI.i\nswig.path = .\n\nQMAKE_EXTRA_TARGETS += swig\n\n# Rename shared library for SWIG wrapper.\nCONFIG(debug, debug|release) {\n    unix:QMAKE_POST_LINK = ln -s -f libPythonAPId.so.1.0.0 _pythonAPId.so\n} else {\n    unix:QMAKE_POST_LINK = ln -s -f libPythonAPI.so.1.0.0 _pythonAPI.so\n}\n\n# Install target\ntarget.path = $$lib_path\nCONFIG(debug, debug|release) {\n    target.files = _pythonAPId.so pythonAPI.py\n} else {\n    target.files = _pythonAPI.so pythonAPI.py\n}\nINSTALLS += target\n"
  },
  {
    "path": "PythonAPI/PythonAPI.vcxproj",
    "content": "﻿<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<Project DefaultTargets=\"Build\" ToolsVersion=\"15.0\" xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">\n  <ItemGroup Label=\"ProjectConfigurations\">\n    <ProjectConfiguration Include=\"Debug|x64\">\n      <Configuration>Debug</Configuration>\n      <Platform>x64</Platform>\n    </ProjectConfiguration>\n    <ProjectConfiguration Include=\"Release|x64\">\n      <Configuration>Release</Configuration>\n      <Platform>x64</Platform>\n    </ProjectConfiguration>\n  </ItemGroup>\n  <PropertyGroup Label=\"Globals\">\n    <ProjectGuid>{E8D9DD36-B0CA-4043-9B08-CEA96BED5266}</ProjectGuid>\n    <Keyword>QtVS_v304</Keyword>\n    <WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>\n    <QtMsBuild Condition=\"'$(QtMsBuild)'=='' OR !Exists('$(QtMsBuild)\\qt.targets')\">$(MSBuildProjectDirectory)\\QtMsBuild</QtMsBuild>\n  </PropertyGroup>\n  <Import Project=\"$(VCTargetsPath)\\Microsoft.Cpp.Default.props\" />\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\" Label=\"Configuration\">\n    <ConfigurationType>DynamicLibrary</ConfigurationType>\n    <PlatformToolset>v143</PlatformToolset>\n  </PropertyGroup>\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\" Label=\"Configuration\">\n    <ConfigurationType>DynamicLibrary</ConfigurationType>\n    <PlatformToolset>v143</PlatformToolset>\n  </PropertyGroup>\n  <Import Project=\"$(VCTargetsPath)\\Microsoft.Cpp.props\" />\n  <Target Name=\"QtMsBuildNotFound\" BeforeTargets=\"CustomBuild;ClCompile\" Condition=\"!Exists('$(QtMsBuild)\\qt.targets') or !Exists('$(QtMsBuild)\\qt.props')\">\n    <Message Importance=\"High\" Text=\"QtMsBuild: could not locate qt.targets, qt.props; project may not build correctly.\" />\n  </Target>\n  <ImportGroup Label=\"ExtensionSettings\" />\n  <ImportGroup Label=\"Shared\" />\n  <ImportGroup Label=\"PropertySheets\" Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\n    <Import Project=\"$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props\" Condition=\"exists('$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props')\" Label=\"LocalAppDataPlatform\" />\n  </ImportGroup>\n  <ImportGroup Label=\"PropertySheets\" Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\n    <Import Project=\"$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props\" Condition=\"exists('$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props')\" Label=\"LocalAppDataPlatform\" />\n  </ImportGroup>\n  <PropertyGroup Label=\"UserMacros\" />\n  <ImportGroup Condition=\"Exists('$(QtMsBuild)\\qt_defaults.props')\">\n    <Import Project=\"$(QtMsBuild)\\qt_defaults.props\" />\n  </ImportGroup>\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\n    <TargetName>_pythonAPI</TargetName>\n    <TargetExt>.pyd</TargetExt>\n    <OutDir>$(SolutionDir)PythonAPI\\</OutDir>\n  </PropertyGroup>\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\n    <TargetName>_pythonAPI_d</TargetName>\n    <TargetExt>.pyd</TargetExt>\n    <OutDir>$(SolutionDir)PythonAPI\\</OutDir>\n  </PropertyGroup>\n  <PropertyGroup Label=\"QtSettings\" Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\n    <QtInstall>6.2.4</QtInstall>\n    <QtModules>core;widgets;xml</QtModules>\n  </PropertyGroup>\n  <PropertyGroup Label=\"QtSettings\" Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\n    <QtInstall>6.2.4</QtInstall>\n    <QtModules>core;widgets;xml</QtModules>\n  </PropertyGroup>\n  <ImportGroup Condition=\"Exists('$(QtMsBuild)\\qt.props')\">\n    <Import Project=\"$(QtMsBuild)\\qt.props\" />\n  </ImportGroup>\n  <ItemDefinitionGroup Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\n    <ClCompile>\n      <MultiProcessorCompilation>true</MultiProcessorCompilation>\n      <Optimization>Disabled</Optimization>\n      <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>\n      <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>\n      <TreatWChar_tAsBuiltInType>true</TreatWChar_tAsBuiltInType>\n      <PreprocessorDefinitions>PYTHONAPI_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>\n      <AdditionalIncludeDirectories>.\\GeneratedFiles\\$(ConfigurationName);.\\GeneratedFiles;$(SolutionDir);$(PYTHON_DIR)\\include;$(SolutionDir)KactusAPI\\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\n      <LanguageStandard>stdcpp17</LanguageStandard>\n      <AdditionalOptions>/Zc:__cplusplus %(AdditionalOptions)</AdditionalOptions>\n      <MultiProcessorCompilation>true</MultiProcessorCompilation>\n      <WarningLevel>Level1</WarningLevel>\n    </ClCompile>\n    <Link>\n      <SubSystem>Windows</SubSystem>\n      <OutputFile>_pythonAPI_d.pyd</OutputFile>\n      <GenerateDebugInformation>true</GenerateDebugInformation>\n      <AdditionalLibraryDirectories>$(SolutionDir)executable;$(PYTHON_DIR)\\libs;$(QTDIR)\\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>\n      <AdditionalDependencies>python310_d.lib;IPXACTmodelsd.lib;KactusAPId.lib;%(AdditionalDependencies)</AdditionalDependencies>\n    </Link>\n    <PostBuildEvent>\n      <Command>cp _pythonAPI_d.pyd ..\\executable\\\ncp pythonAPI.py ..\\executable\\</Command>\n    </PostBuildEvent>\n    <PostBuildEvent>\n      <Message>Copy pythonapi files to executable dir</Message>\n    </PostBuildEvent>\n  </ItemDefinitionGroup>\n  <ItemDefinitionGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\n    <ClCompile>\n      <MultiProcessorCompilation>true</MultiProcessorCompilation>\n      <DebugInformationFormat />\n      <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>\n      <TreatWChar_tAsBuiltInType>true</TreatWChar_tAsBuiltInType>\n      <PreprocessorDefinitions>PYTHONAPI_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>\n      <AdditionalIncludeDirectories>.\\GeneratedFiles\\$(ConfigurationName);.\\GeneratedFiles;$(SolutionDir);$(PYTHON_DIR)\\include;$(SolutionDir)KactusAPI\\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\n      <LanguageStandard>stdcpp17</LanguageStandard>\n      <AdditionalOptions>/Zc:__cplusplus %(AdditionalOptions)</AdditionalOptions>\n      <MultiProcessorCompilation>true</MultiProcessorCompilation>\n    </ClCompile>\n    <Link>\n      <SubSystem>Windows</SubSystem>\n      <OutputFile>_pythonAPI.pyd</OutputFile>\n      <GenerateDebugInformation>false</GenerateDebugInformation>\n      <AdditionalDependencies>Python310.lib;IPXACTmodels.lib;KactusAPI.lib;%(AdditionalDependencies)</AdditionalDependencies>\n      <AdditionalLibraryDirectories>$(SolutionDir)executable;$(PYTHON_DIR)\\libs;$(QTDIR)\\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>\n    </Link>\n  </ItemDefinitionGroup>\n  <ItemGroup>\n    <ClCompile Include=\"..\\common\\validators\\LibraryPathValidator\\librarypathvalidator.cpp\" />\n    <ClCompile Include=\"PythonAPI.cpp\" />\n    <ClCompile Include=\"PythonAPI_wrap.cxx\">\n      <Command Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">swig -python -c++ PythonAPI.i</Command>\n    </ClCompile>\n  </ItemGroup>\n  <ItemGroup>\n    <QtMoc Include=\"..\\common\\validators\\LibraryPathValidator\\librarypathvalidator.h\" />\n    <ClInclude Include=\"PythonAPI.h\" />\n    <ClInclude Include=\"pythonapi_global.h\" />\n  </ItemGroup>\n  <ItemGroup>\n    <CustomBuild Include=\"PythonAPI.i\">\n      <FileType>Document</FileType>\n      <Command Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">swig -python -c++ -O -doxygen %(Identity)</Command>\n      <Message Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">Running SWIG</Message>\n      <Outputs Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">PythonAPI_wrap.cxx</Outputs>\n      <Command Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">swig -python -c++ -O -doxygen %(Identity)</Command>\n      <Message Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">Running SWIG</Message>\n      <Outputs Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">PythonAPI_wrap.cxx</Outputs>\n      <AdditionalInputs Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">PythonAPI.cpp;PythonAPI.h</AdditionalInputs>\n    </CustomBuild>\n  </ItemGroup>\n  <Import Project=\"$(VCTargetsPath)\\Microsoft.Cpp.targets\" />\n  <ImportGroup Condition=\"Exists('$(QtMsBuild)\\qt.targets')\">\n    <Import Project=\"$(QtMsBuild)\\qt.targets\" />\n  </ImportGroup>\n  <ImportGroup Label=\"ExtensionTargets\">\n  </ImportGroup>\n  <ProjectExtensions>\n    <VisualStudio>\n      <UserProperties MocDir=\".\\GeneratedFiles\\$(ConfigurationName)\" UicDir=\".\\GeneratedFiles\" RccDir=\".\\GeneratedFiles\" lupdateOptions=\"\" lupdateOnBuild=\"0\" lreleaseOptions=\"\" MocOptions=\"\" />\n    </VisualStudio>\n  </ProjectExtensions>\n</Project>"
  },
  {
    "path": "PythonAPI/PythonAPI.vcxproj.filters",
    "content": "﻿<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<Project ToolsVersion=\"4.0\" xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">\n  <ItemGroup>\n    <Filter Include=\"Source Files\">\n      <UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>\n      <Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>\n    </Filter>\n    <Filter Include=\"Header Files\">\n      <UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>\n      <Extensions>h;hh;hpp;hxx;hm;inl;inc;xsd</Extensions>\n    </Filter>\n    <Filter Include=\"Resource Files\">\n      <UniqueIdentifier>{D9D6E242-F8AF-46E4-B9FD-80ECBC20BA3E}</UniqueIdentifier>\n      <Extensions>qrc;*</Extensions>\n      <ParseFiles>false</ParseFiles>\n    </Filter>\n    <Filter Include=\"Resource Files\">\n      <UniqueIdentifier>{D9D6E242-F8AF-46E4-B9FD-80ECBC20BA3E}</UniqueIdentifier>\n      <Extensions>qrc;*</Extensions>\n      <ParseFiles>false</ParseFiles>\n    </Filter>\n    <Filter Include=\"Source Files\\common\">\n      <UniqueIdentifier>{a4643d2f-976e-41db-b8c3-dcebe194ff08}</UniqueIdentifier>\n    </Filter>\n    <Filter Include=\"Header Files\\common\">\n      <UniqueIdentifier>{99f1e110-e88d-439c-af55-b7c05e07fcf3}</UniqueIdentifier>\n    </Filter>\n    <Filter Include=\"Header Files\\common\\validators\">\n      <UniqueIdentifier>{8b35980a-477a-49b6-992e-6dbe8b13886e}</UniqueIdentifier>\n    </Filter>\n    <Filter Include=\"Source Files\\common\\validators\">\n      <UniqueIdentifier>{6eff49bd-1383-4976-b8a1-fed439e34c7d}</UniqueIdentifier>\n    </Filter>\n    <Filter Include=\"Generated Files\">\n      <UniqueIdentifier>{b161e93c-7d11-4c2a-b62d-0cf5561abd20}</UniqueIdentifier>\n    </Filter>\n  </ItemGroup>\n  <ItemGroup>\n    <ClCompile Include=\"PythonAPI.cpp\">\n      <Filter>Source Files</Filter>\n    </ClCompile>\n    <ClCompile Include=\"..\\common\\validators\\LibraryPathValidator\\librarypathvalidator.cpp\">\n      <Filter>Source Files\\common\\validators</Filter>\n    </ClCompile>\n    <ClCompile Include=\"PythonAPI_wrap.cxx\">\n      <Filter>Generated Files</Filter>\n    </ClCompile>\n  </ItemGroup>\n  <ItemGroup>\n    <ClInclude Include=\"PythonAPI.h\">\n      <Filter>Header Files</Filter>\n    </ClInclude>\n  </ItemGroup>\n  <ItemGroup>\n    <ClInclude Include=\"pythonapi_global.h\">\n      <Filter>Header Files</Filter>\n    </ClInclude>\n  </ItemGroup>\n  <ItemGroup>\n    <QtMoc Include=\"..\\common\\validators\\LibraryPathValidator\\librarypathvalidator.h\">\n      <Filter>Header Files\\common\\validators</Filter>\n    </QtMoc>\n  </ItemGroup>\n  <ItemGroup>\n    <CustomBuild Include=\"PythonAPI.i\" />\n  </ItemGroup>\n</Project>"
  },
  {
    "path": "PythonAPI/PythonInterpreter.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: PythonInterpreter.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Esko Pekkarinen\n// Date: 03.02.2021\n//\n// Description:\n// Convenience class for accessing Python interpreter.\n//-----------------------------------------------------------------------------\n#define PY_SSIZE_T_CLEAN\n#include <Python.h>\n\n#include \"PythonInterpreter.h\"\n\n#include <PythonAPI/extensions/IOCatcher.h>\n#include <PythonAPI/PythonAPI.h>\n\n#include <QApplication>\n\n//-----------------------------------------------------------------------------\n// Function: PythonInterpreter::PythonInterpreter()\n//-----------------------------------------------------------------------------\nPythonInterpreter::PythonInterpreter(WriteChannel* outputChannel, WriteChannel* errorChannel,\n    bool printPromt, QObject* parent) :\n    QObject(parent), \n    WriteChannel(),\n    printPrompt_(printPromt),\n    outputChannel_(outputChannel),\n    errorChannel_(errorChannel)\n{\n   \n}\n\n//-----------------------------------------------------------------------------\n// Function: PythonInterpreter::initialize()\n//-----------------------------------------------------------------------------\nbool PythonInterpreter::initialize(bool interactive)\n{\n    PyImport_AppendInittab(\"IOCatcher\", &PyInit_IOCatcher);\n\n    Py_InitializeEx(0); //<! Disable signals.\n    \n    if (Py_IsInitialized() == false)\n    {        \n        errorChannel_->write(QStringLiteral(\"Could not initialize Python interpreter.\"));\n        return false;\n    }\n\n    threadState_ = Py_NewInterpreter();\n\n    outputChannel_->write(QStringLiteral(\"Python \") + QString(Py_GetVersion()) + QString(\"\\n\"));    \n\n    PyObject *pyModule = PyImport_ImportModule(\"__main__\");\n    localContext_ = PyModule_GetDict(pyModule);\n    globalContext_ = localContext_;\n\n    if (redirectIO(interactive) == false)\n    {\n        return false;\n    }\n\n    setAPI();\n\n    PyEval_ReleaseThread(threadState_);\n\n    printPrompt();\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PythonInterpreter::finalize()\n//-----------------------------------------------------------------------------\nvoid PythonInterpreter::finalize()\n{\n    PyEval_AcquireThread(threadState_);\n    Py_FinalizeEx();\n}\n\n//-----------------------------------------------------------------------------\n// Function: PythonInterpreter::write()\n//-----------------------------------------------------------------------------\nvoid PythonInterpreter::write(QString const& command)\n{\n    execute(command.toStdString());\n}\n\n//-----------------------------------------------------------------------------\n// Function: PythonInterpreter::execute()\n//-----------------------------------------------------------------------------\nvoid PythonInterpreter::execute(std::string const& command)\n{\n    Q_ASSERT_X(Py_IsInitialized(), \"Python interpreter\", \"Trying to execute without initializing.\");\n\n    if (command.empty() && inputBuffer_.empty())\n    {\n        printPrompt();\n        return;\n    }    \n\n    inputBuffer_.append(command);\n    inputBuffer_.push_back('\\n');\n\n    auto inputSize = inputBuffer_.length();\n    bool endMultiline = runMultiline_ && inputSize >= 2 && inputBuffer_.at(inputSize - 2) == '\\n';\n\n\n    PyEval_AcquireThread(threadState_);\n\n    PyObject* src = Py_CompileString(inputBuffer_.c_str(), \"<stdin>\", Py_single_input);\n\n    /* compiled just fine - */\n    if (src != nullptr)\n    {\n        /* \">>> \" or \"... \" and double '\\n' */\n        if (runMultiline_ == false || endMultiline)\n        {                                               /* so execute it */\n            PyObject* dum = PyEval_EvalCode(src, globalContext_, localContext_);\n            Py_XDECREF(dum);\n            Py_XDECREF(src);\n\n            if (PyErr_Occurred())\n            {\n                PyErr_Print();\n            }                \n\n            runMultiline_ = false;\n            inputBuffer_.clear();\n        }\n        else\n        {\n            runMultiline_ = true;\n        }\n    }     \n    /* syntax error or E_EOF? */\n    else if (PyErr_ExceptionMatches(PyExc_SyntaxError))\n    {\n        PyObject* exc = nullptr;\n        PyObject* val = nullptr;\n        PyObject* trb = nullptr;\n        PyObject* obj = nullptr;\n\n        char *msg = nullptr;\n\n        /* clears exception! */\n        PyErr_Fetch(&exc, &val, &trb);  \n\n        if (PyArg_ParseTuple(val, \"sO\", &msg, &obj) && !strcmp(msg, \"unexpected EOF while parsing\") && \n            endMultiline == false) /* E_EOF */\n        {            \n            Py_XDECREF(exc);\n            Py_XDECREF(val);\n            Py_XDECREF(trb);\n\n            runMultiline_ = true;\n        }\n        else /* some other syntax error */\n        {\n            PyErr_Restore(exc, val, trb);\n            PyErr_Print();\n\n            runMultiline_ = false;\n            inputBuffer_.clear();\n        }\n    }\n    else /* some non-syntax error */\n    {\n        PyErr_Print();\n        runMultiline_ = false;\n        inputBuffer_.clear();\n    }\n\n    PyEval_ReleaseThread(threadState_);\n\n    printPrompt();\n    emit executeDone();\n}\n\n//-----------------------------------------------------------------------------\n// Function: PythonInterpreter::executeString()\n//-----------------------------------------------------------------------------\nvoid PythonInterpreter::executeString(QString const& string)\n{\n    PyEval_AcquireThread(threadState_);\n    PyObject* result = PyRun_String(string.toStdString().c_str(), Py_file_input, globalContext_, localContext_);\n\n    if (result == nullptr)\n    {\n        PyErr_Print();\n    }\n    else\n    {\n        Py_DECREF(result);\n    }\n\n    PyEval_ReleaseThread(threadState_);\n\n    printPrompt();\n    emit executeDone();\n}\n\n//-----------------------------------------------------------------------------\n// Function: PythonInterpreter::runFile()\n//-----------------------------------------------------------------------------\nint PythonInterpreter::runFile(QString const& filePath)\n{\n    Q_ASSERT_X(Py_IsInitialized(), \"Python interpreter\", \"Trying to execute file without initializing.\");\n    int retVal = 1;\n    QFile scriptFile(filePath);\n    if (scriptFile.open(QIODevice::ReadOnly | QIODevice::Text))\n    {\n        int fd = scriptFile.handle();\n        FILE* f = fdopen(dup(fd), \"rb\");\n\n        PyEval_AcquireThread(threadState_);\n        retVal = PyRun_SimpleFile(f, scriptFile.fileName().toLocal8Bit());\n        PyEval_ReleaseThread(threadState_);\n\n        fclose(f);\n\n        scriptFile.close();\n\n        printPrompt();\n    }\n\n    emit executeDone();\n    return retVal;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PythonInterpreter::setOutputChannels()\n//-----------------------------------------------------------------------------\nbool PythonInterpreter::redirectIO(bool interative)\n{\n    PyObject* IOCatcherName = PyUnicode_FromString(\"IOCatcher\");\n    if (IOCatcherName == NULL)\n    {\n        return false;\n    }\n\n    PyObject* IOCatcherModule = PyImport_Import(IOCatcherName);\n    Py_DECREF(IOCatcherName);\n    if (IOCatcherModule == NULL)\n    {\n        return false;\n    }\n\n    PyObject* dict = PyModule_GetDict(IOCatcherModule);\n    Py_DECREF(IOCatcherModule);\n\n    if (dict == NULL) \n    {\n        PyErr_Print();\n        errorChannel_->write(QStringLiteral(\"Fails to get the output dictionary.\\n\"));\n        return false;\n    }\n\n    PyObject* python_class = PyDict_GetItemString(dict, \"OutputCatcher\");\n    if (python_class == NULL) \n    {\n        PyErr_Print();\n        errorChannel_->write(QStringLiteral(\"Fails to get the output Python class.\\n\"));\n        return false;\n    }\n\n    PyObject* outCatcher = nullptr;\n    PyObject* errCatcher = nullptr;\n\n    // Creates an instance of the class\n    if (PyCallable_Check(python_class))\n    {\n        outCatcher = PyObject_CallObject(python_class, nullptr);\n        errCatcher = PyObject_CallObject(python_class, nullptr);\n    }\n    else\n    {\n        outputChannel_->write(QStringLiteral(\"Cannot instantiate the Python class for output\"));\n        return false;\n    }\n\n    ((OutputCatcherObject*)outCatcher)->channel = outputChannel_;\n    if (PySys_SetObject(\"stdout\", outCatcher) < 0)\n    {\n        return false;\n    }\n\n    ((OutputCatcherObject*)errCatcher)->channel = errorChannel_;\n    if (PySys_SetObject(\"stderr\", errCatcher) < 0)\n    {\n        return false;\n    }\n\n    if (interative == false)\n    {\n        PyObject* input_python_class = PyDict_GetItemString(dict, \"InputCatcher\");\n\n        if (input_python_class == NULL)\n        {\n            PyErr_Print();\n            errorChannel_->write(QStringLiteral(\"Fails to get the input Python class.\\n\"));\n            return false;\n        }\n\n        PyObject* inputBuffer;\n\n        // Creates an instance of the class\n        if (PyCallable_Check(input_python_class))\n        {\n            inputBuffer = PyObject_CallObject(input_python_class, nullptr);\n        }\n\n        if (PySys_SetObject(\"stdin\", inputBuffer) < 0)\n        {\n            return false;\n        }\n    }\n\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PythonInterpreter::setAPI()\n//-----------------------------------------------------------------------------\nbool PythonInterpreter::setAPI()\n{\n    PyObject* emptyList = PyList_New(0);\n    PyObject* apiModule = PyImport_ImportModuleEx(\"pythonAPI\", globalContext_, localContext_, emptyList);\n    Py_XDECREF(emptyList);\n\n    if (apiModule == NULL)\n    {\n        errorChannel_->write(QStringLiteral(\"Could not import Kactus2 PythonAPI.\\n\"));\n        PyErr_Print();\n    }\n    else\n    {\n        PyObject* dict = PyModule_GetDict(apiModule);\n\n        if (dict == NULL) {\n            PyErr_Print();\n            errorChannel_->write(QStringLiteral(\"Could not import Kactus2 PythonAPI.\\n\"));\n            return false;\n        }\n\n        PyObject* python_class = PyDict_GetItemString(dict, \"PythonAPI\");\n\n        if (python_class == NULL) {\n            PyErr_Print();\n            errorChannel_->write(QStringLiteral(\"Could not import Kactus2 PythonAPI.\\n\"));\n            return false;\n        }\n\n        // Creates an instance of the class\n        if (PyCallable_Check(python_class))\n        {\n            PyObject* apiObject = PyObject_CallObject(python_class, nullptr);\n            PyDict_SetItemString(localContext_, \"kactus2\", apiObject);\n        }\n    }\n\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PythonInterpreter::printPrompt()\n//-----------------------------------------------------------------------------\nvoid PythonInterpreter::printPrompt() const\n{\n    if (printPrompt_ == false)\n    {\n        return;\n    }\n\n    if (runMultiline_)\n    {\n        outputChannel_->write(\"... \");\n    }\n    else\n    {\n        outputChannel_->write(\">>> \");\n    }\n}\n"
  },
  {
    "path": "PythonAPI/PythonInterpreter.h",
    "content": "//-----------------------------------------------------------------------------\n// File: PythonInterpreter.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Esko Pekkarinen\n// Date: 03.02.2021\n//\n// Description:\n// Convenience class for accessing Python interpreter.\n//-----------------------------------------------------------------------------\n\n#ifndef PYTHON_INTERPRETER_H\n#define PYTHON_INTERPRETER_H\n\n#define PY_SSIZE_T_CLEAN\n#include <Python.h>\n\n#include <QObject>\n#include <QFile>\n\n#include <string>\n\n#include <PythonAPI/WriteChannel.h>\n\n//-----------------------------------------------------------------------------\n//! Convenience class for accessing Python interpreter.\n//-----------------------------------------------------------------------------\nclass PythonInterpreter : public QObject, public WriteChannel\n{\n    Q_OBJECT\n\npublic:\n\n    /*!\n     * The constructor.\n     *\n     *    @param [in] outputChannel    Channel for standard messages and interpreter output.\n     *    @param [in] errorChannel     Channel for error messages.\n     *    @param [in] printPromt       Flag for enabling prompt printing.\n     *    @param [in] parent           The parent object.\n     */\n     explicit PythonInterpreter(WriteChannel* outputChannel, \n         WriteChannel* errorChannel, bool printPromt = true,\n         QObject* parent = nullptr);\n\n     // ! The destructor.\n    ~PythonInterpreter() final = default;\n\n    /*!\n     * Initializes the interpreter. This function must be called before writing any commands with write().\n     *\n     *    @param [in] interactive  Flag for enabling interactive std input. Set to true on command-line.\n     *\n     *    @return True, if initialization was successful, otherwise false.\n     */\n     bool initialize(bool interactive = true);     \n     \n     /*!\n      * Clean up the interpreter state at end of life time.\n      */\n    void finalize();\n\n    /*!\n     * Execute a single line in the interpreter.\n     *\n     *    @param [in] line  The line to execute.\n     */\n     void execute(std::string const& line);\n\nsignals:\n    \n    void executeDone();\n\npublic slots:\n\n    /*!\n     * Write a command for interpreter to execute.\n     *\n     *    @param [in] command  The command to execute.\n     */\n    virtual void write(QString const& command) override final;\n\n    /*!\n     * Execute the given arbitrary long string in the interpreter.\n     *\n     *    @param [in] string  The string to execute.\n     */\n    void executeString(QString const& string);\n\n    /*!\n     * Run a script from a given file.\n     *\n     *    @param [in] filePath  Path to the file to run.\n     * \n     *    @return Return value of the script or 1 if script file couldn't be opened.\n     */\n    int runFile(QString const& filePath);\n\nprivate:\n\n    /*!\n     * Redirect the interpreter output and error output to WriteChannels.\n     *\n     *    @param [in] interactive  Flag for enabling interactive std input. Set to true on command-line.\n     *\n     *    @return True, if the input and outputs could be redirected, otherwise false.\n     */\n     bool redirectIO(bool interactive);\n\n     /*!\n      * Import and set the core api available in python context.\n      *\n      *    @return True, if the api was set, otherwise false.\n      */\n      bool setAPI();\n\n    /*!\n     * Write prompt to output.\n     */\n     void printPrompt() const;\n\n    //-----------------------------------------------------------------------------\n    // Data.\n    //-----------------------------------------------------------------------------\n\n    //! Buffer to store multiple lines for command to execute.\n    std::string inputBuffer_{ };\n\n    //! Flag for enabling prompt printing.\n    bool printPrompt_{ true };\n\n    //! True, if the current command requires multiple lines (e.g. loop).\n    bool runMultiline_{ false };\n\n    //! Channel for interpreter output.\n    WriteChannel* outputChannel_{ nullptr };\n\n    //! Channel for interpreter errors.\n    WriteChannel* errorChannel_{ nullptr };\n\n    //! The global context for the interpreter.\n    PyObject* globalContext_{ nullptr };\n\n    //! The local context for the interpreter when running a command.\n    PyObject* localContext_{ nullptr };\n\n    //! Interpreter thread state value holder.\n    PyThreadState* threadState_{ nullptr };\n};\n\n#endif // PYTHON_INTERPRETER_H"
  },
  {
    "path": "PythonAPI/StdInputListener.cpp",
    "content": "    //-----------------------------------------------------------------------------\n// File: InputListener.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Esko Pekkarinen\n// Date: 04.02.2021\n//\n// Description:\n// <Short description of the class/file contents>\n//-----------------------------------------------------------------------------\n#define PY_SSIZE_T_CLEAN\n#include <Python.h>\n\n#include \"StdInputListener.h\"\n\n#include <PythonAPI/WriteChannel.h>\n\n#include <QString>\n\n#include <iostream>\n\n#include <string>\n\nStdInputListener::StdInputListener(WriteChannel* outputChannel, QObject* parent /*= nullptr*/) :\n    QObject(parent),\n    outputChannel_(outputChannel),\n#ifdef Q_OS_WIN\n    notifier_(new QWinEventNotifier(GetStdHandle(STD_INPUT_HANDLE), this))\n{\n    QObject::connect(notifier_, &QWinEventNotifier::activated, this, &StdInputListener::inputReadable);\n\n#else\n    notifier_(new QSocketNotifier(fileno(stdin), QSocketNotifier::Read))\n{\n    connect(notifier_, &QSocketNotifier::activated, this, &StdInputListener::inputReadable);\n#endif\n}\n\nvoid StdInputListener::inputReadable()\n{\n    if (std::cin.eof())                          // Ctrl-D pressed \n    {\n        emit inputFailure();\n        return;\n    }\n\n    std::string line;\n    std::getline(std::cin, line);\n\n    outputChannel_->write(QString::fromStdString(line));\n}\n"
  },
  {
    "path": "PythonAPI/StdInputListener.h",
    "content": "//-----------------------------------------------------------------------------\n// File: InputListener.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Esko Pekkarinen\n// Date: 04.02.2021\n//\n// Description:\n// <Short description of the class/file contents>\n//-----------------------------------------------------------------------------\n\n#ifndef STDINPUTLISTENER_H\n#define STDINPUTLISTENER_H\n\n#include <QObject>\n\n#ifdef Q_OS_WIN\n#include <windows.h>\n#include <QWinEventNotifier>\n#else\n#include <QSocketNotifier>\n#endif\n\nclass WriteChannel;\n\nclass StdInputListener : public QObject\n{\n    Q_OBJECT\npublic:\n\n    //! The constructor.\n    StdInputListener(WriteChannel* outputChannel, QObject* parent = nullptr);\n\n    //! The destructor.\n    virtual ~StdInputListener() = default;\n\nsignals:\n\n    void inputFailure();\n\npublic slots:\n\n    void inputReadable();\n\nprivate:\n\n    WriteChannel* outputChannel_;\n\n#ifdef Q_OS_WIN\n    QWinEventNotifier* notifier_;\n#else\n    QSocketNotifier* notifier_;\n#endif\n\n};\n\n\n#endif // STDINPUTLISTENER_H\n"
  },
  {
    "path": "PythonAPI/WriteChannel.h",
    "content": "//-----------------------------------------------------------------------------\n// File: WriteChannel.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Esko Pekkarinen\n// Date: 05.02.2021\n//\n// Description:\n// <Short description of the class/file contents>\n//-----------------------------------------------------------------------------\n\n#ifndef WRITECHANNEL_H\n#define WRITECHANNEL_H\n\n#include <QString>\n\nclass WriteChannel\n{\npublic:\n    \n    //! The destructor.\n    virtual ~WriteChannel() = default;\n\n    virtual void write(QString const& text) = 0;\n\nprotected:\n\n    //! The constructor.\n    WriteChannel() = default;\n};\n\n#endif // WRITECHANNEL_H\n"
  },
  {
    "path": "PythonAPI/constructPythonComponent.py",
    "content": "from ipmm_core_pkg.component import Component\nfrom ipmm_core_pkg.port import Port\nfrom ipmm_core_pkg.parameter import Parameter\nfrom ipmm_core_pkg.addressBlock import AddressBlock\nfrom ipmm_core_pkg.register import Register\nfrom ipmm_core_pkg.field import Field\nfrom ipmm_core_pkg.reset import Reset\n\ndef createComponent(api, portsInterface, parameterInterface):\n\tcomponentName = api.getComponentName().toStdString()\n\tcomponentDescription = api.getComponentDescription().toStdString()\n\t\n\tnewComponent = Component(componentName, componentDescription)\n\t\n\tfor portName in portsInterface.getItemNames():\n\t\tif portsInterface.portIsWire(portName):\n\t\t\tportDescription = portsInterface.getDescription(portName)\n\t\t\tportDataType = \"\"\n\t\t\tportBitWidth = portsInterface.getWidth(portName)\n\t\t\tportDirection = portsInterface.getDirection(portName)\n\t\t\t\n\t\t\tnewComponent.add_port(Port(portName, portDescription, portDataType, portBitWidth, portDirection))\n\t\n\tfor parameterName in parameterInterface.getItemNames():\n\t\tdescription = parameterInterface.getDescription(parameterName)\n\t\tdataType = parameterInterface.getType(parameterName)\n\t\t\n\t\tbitWidthLeft = parameterInterface.getBitWidthLeftValue(parameterName, 10)\n\t\tif not bitWidthLeft:\n\t\t\tbitWidthLeft = \"0\"\n\t\tbitWidthRight = parameterInterface.getBitWidthRightValue(parameterName, 10)\n\t\tif not bitWidthRight:\n\t\t\tbitWidthRight = \"0\"\n\t\t\n\t\tbitWidth = abs(int(bitWidthLeft) - int(bitWidthRight)) + 1\n\t\tvalue = parameterInterface.getValueFormattedExpression(parameterName)\n\t\t\n\t\tnewComponent.add_parameter(Parameter(parameterName, description, dataType, bitWidth, value))\n\t\t\n\tmapName = \"Map\"\n\tmapInterface = api.getMapInterface()\n\tblockInterface = mapInterface.getSubInterface()\n\tregisterInterface = blockInterface.getSubInterface()\n\tfieldInterface = registerInterface.getSubInterface()\n\tresetInterface = fieldInterface.getSubInterface()\n\t\n\tif mapInterface is not None:\n\t\tfor mapName in mapInterface.getItemNames():\n\t\t\tapi.setBlocksForInterface(mapName)\n\n\t\t\tfor blockName in blockInterface.getItemNames():\n\t\t\t\tblockDescription = blockInterface.getDescription(blockName)\n\t\t\t\tblockRange = blockInterface.getRangeValue(blockName, 10)\n\t\t\t\tblockWidth = blockInterface.getWidthValue(blockName, 10)\n\t\t\t\t\n\t\t\t\tnewBlock  = AddressBlock(blockName, blockDescription, blockRange, blockWidth)\n\t\t\t\t\n\t\t\t\tapi.setRegistersForInterface(mapName, blockName)\n\t\t\t\t\n\t\t\t\tfor registerName in registerInterface.getItemNames():\n\t\t\t\t\tregisterDescription = registerInterface.getDescription(registerName)\n\t\t\t\t\tregisterOffset = registerInterface.getOffsetValue(registerName, 10)\n\t\t\t\t\tregisterSize = registerInterface.getSizeValue(registerName, 10)\n\t\t\t\t\t\n\t\t\t\t\tnewRegister = Register(registerName, registerDescription, registerOffset, registerSize)\n\t\t\t\t\tnewBlock.add_register(newRegister)\n\t\t\t\t\t\n\t\t\t\t\tapi.setFieldsForInterface(mapName, blockName, registerName)\n\t\t\t\t\t\n\t\t\t\t\tfor fieldName in fieldInterface.getItemNames():\n\t\t\t\t\t\tfieldDescription = fieldInterface.getDescription(fieldName)\n\t\t\t\t\t\tfieldBitOffset = fieldInterface.getOffsetValue(fieldName, 10)\n\t\t\t\t\t\tfieldBitWidth = fieldInterface.getWidthValue(fieldName, 10)\n\t\t\t\t\t\tfieldAccess = fieldInterface.getAccess(fieldName)\n\t\t\t\n\t\t\t\t\t\tnewField = Field(fieldName, fieldDescription, fieldBitOffset, fieldBitWidth, fieldAccess)\n\t\t\t\t\t\tnewRegister.add_field(newField)\n\t\t\t\t\n\t\t\t\t\t\tapi.setResetsForInterface(mapName, blockName, registerName, fieldName)\n\t\t\t\t\t\t\n\t\t\t\t\t\tfor resetType in resetInterface.getItemNames():\n\t\t\t\t\t\t\tnewResetType = resetType\n\t\t\t\t\t\t\tif not newResetType:\n\t\t\t\t\t\t\t\tnewResetType = \"HARD\"\n\t\t\t\t\t\t\tresetName = \"\"\n\t\t\t\t\t\t\tresetDescription = \"\"\n\t\t\t\t\t\t\tresetValue = resetInterface.getResetValue(resetType, 10)\n\t\t\t\t\t\t\tresetMask = resetInterface.getResetMaskValue(resetType, 10)\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\tnewField.add_reset(Reset(resetName, resetDescription, newResetType, resetValue, resetMask))\n\t\t\n\t\t\t\tnewBlock.printer()\n\t\t\t\tprint(\"\\n\")\n\n\treturn newComponent\n"
  },
  {
    "path": "PythonAPI/extensions/IOCatcher.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: IOCatcher.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Esko Pekkarinen\n// Date: 12.02.2021\n//\n// Description:\n// <Short description of the class/file contents>\n//-----------------------------------------------------------------------------\n\n#include \"IOCatcher.h\"\n\n#include <structmember.h>\n\nstatic void OutputCatcher_dealloc(OutputCatcherObject* self)\n{\n    ((OutputCatcherObject *)self)->channel = NULL;\n\n    Py_TYPE(self)->tp_free((PyObject *)self);\n}\n\nstatic PyObject* OutputCatcher_new(PyTypeObject* type, PyObject* /*args*/, PyObject* /*kwds*/)\n{\n    OutputCatcherObject *self = (OutputCatcherObject *)type->tp_alloc(type, 0);\n    if (self == NULL)\n    {\n        return NULL;\n    }\n\n    self->channel = NULL;\n\n    return (PyObject *)self;\n}\n\nstatic int OutputCatcher_init(OutputCatcherObject* self, PyObject* /*args*/, PyObject* /*kwds*/)\n{\n    self->channel = NULL;\n\n    return 0;\n}\n\nstatic PyMemberDef OutputCatcher_members[] = \n{\n    {\"channel\", T_OBJECT, offsetof(OutputCatcherObject, channel), 0,\n     \"OutputCatcher output channel\"},\n    {NULL}  /* Sentinel */\n};\n\nstatic PyObject* OutputCatcher_write(OutputCatcherObject* self, PyObject* args)\n{\n    char* s;\n    int res = PyArg_ParseTuple(args, \"s\", &s);\n    if (!res)\n    {\n        PyErr_Print();\n    }\n\n    QString text(s);\n    if (self->channel != NULL)\n    {\n        self->channel->write(s);\n    }\n\n    return Py_BuildValue(\"i\", text.length());\n}\n\nstatic PyObject* OutputCatcher_flush(OutputCatcherObject* /*self*/, PyObject* /*args*/)\n{\n    Py_INCREF(Py_None);\n    return Py_None;\n}\n\nstatic PyObject* OutputCatcher_isatty(OutputCatcherObject* /*self*/, PyObject* /*args*/)\n{\n    Py_INCREF(Py_False);\n    return Py_False;\n}\n\nstatic PyMethodDef OutputCatcher_methods[] = \n{\n    {\"write\", (PyCFunction)OutputCatcher_write, METH_VARARGS,\n    PyDoc_STR(\"Write\")\n    },\n    {\"flush\", (PyCFunction)OutputCatcher_flush, METH_NOARGS,\n    PyDoc_STR(\"Flush write buffer\")\n    },\n    { \"isatty\", (PyCFunction)OutputCatcher_isatty, METH_NOARGS,\n    PyDoc_STR(\"Check if object is a tty.\")\n    },\n    {NULL}  /* Sentinel */\n};\n\nstatic PyTypeObject OutputCatcherType =\n{\n    PyVarObject_HEAD_INIT(NULL, 0)\n    \"OutputCatcher.OutputCatcher\",           /*tp_name*/\n    sizeof(OutputCatcherObject),       /*tp_basicsize*/\n    0,                          /*tp_itemsize*/\n    (destructor)OutputCatcher_dealloc, /*tp_dealloc*/\n    0,                          /*tp_vectorcall_offset*/\n    0,                          /*tp_getattr*/\n    0,                          /*tp_setattr*/\n    0,                          /*tp_as_async*/\n    0,                          /*tp_repr*/\n    0,                          /*tp_as_number*/\n    0,                          /*tp_as_sequence*/\n    0,                          /*tp_as_mapping*/\n    0,                          /*tp_hash */\n    0,                          /*tp_call*/\n    0,                          /*tp_str*/\n    0,                          /*tp_getattro*/\n    0,                          /*tp_setattro*/\n    0,                          /*tp_as_buffer*/\n    Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,  /*tp_flags*/\n    PyDoc_STR(\"\"),              /* tp_doc */\n    0,                          /* tp_traverse */\n    0,                          /* tp_clear */\n    0,                          /* tp_richcompare */\n    0,                          /* tp_weaklistoffset */\n    0,                          /* tp_iter */\n    0,                          /* tp_iternext */\n    OutputCatcher_methods,             /* tp_methods */\n    OutputCatcher_members,             /* tp_members */\n    0,                          /* tp_getset */\n    0,                          /* tp_base */\n    0,                          /* tp_dict */\n    0,                          /* tp_descr_get */\n    0,                          /* tp_descr_set */\n    0,                          /* tp_dictoffset */\n    (initproc)OutputCatcher_init,      /* tp_init */\n    0,                          /* tp_alloc */\n    OutputCatcher_new,                 /* tp_new */\n    0,                          /* tp_free */\n    0,                          /* tp_is_gc */\n    0,                          /* tp_bases */\n    0,                          /* tp_mro */\n    0,                          /* tp_cache */\n    0,                          /* tp_subclasses */\n    0,                          /* tp_weaklist */\n    0,                          /* tp_del */\n    0,                          /* tp_version_tag */\n    0,                          /* tp_finalize */\n};\n\n\nstatic void InputCatcher_dealloc(InputCatcherObject* self)\n{\n    Py_TYPE(self)->tp_free((PyObject *)self);\n}\n\nstatic PyObject* InputCatcher_new(PyTypeObject* type, PyObject* /*args*/, PyObject* /*kwds*/)\n{\n    InputCatcherObject* self = (InputCatcherObject *)type->tp_alloc(type, 0);\n    if (self == NULL)\n    {\n        return NULL;\n    }\n\n    return (PyObject *)self;\n}\n\nstatic int InputCatcher_init(InputCatcherObject* /*self*/, PyObject* /*args*/, PyObject* /*kwds*/)\n{\n    return 0;\n}\n\nstatic PyMemberDef InputCatcher_members[] =\n{\n    {NULL}  /* Sentinel */\n};\n\nstatic PyObject* InputCatcher_readline(InputCatcherObject* /*self*/, PyObject* /*args*/)\n{\n    // Return empty string to indicate EOF.\n    return Py_BuildValue(\"s\", \"\");\n}\nstatic PyObject* InputCatcher_isatty(InputCatcherObject* /*self*/, PyObject* /*args*/)\n{\n    // Return false to indicate non-interactive input.\n    return Py_False;\n}\n\nstatic PyMethodDef InputCatcher_methods[] =\n{\n    {\"readline\", (PyCFunction)InputCatcher_readline, METH_VARARGS,\n    PyDoc_STR(\"Read a line from the stream.\")\n    },\n    { \"isatty\", (PyCFunction)InputCatcher_isatty, METH_NOARGS,\n    PyDoc_STR(\"Check if object is a tty.\")\n    },\n    {NULL}  /* Sentinel */\n};\n\nstatic PyTypeObject InputCatcherType =\n{\n    PyVarObject_HEAD_INIT(NULL, 0)\n    \"InputCatcher.InputCatcher\",           /*tp_name*/\n    sizeof(InputCatcherObject),       /*tp_basicsize*/\n    0,                          /*tp_itemsize*/\n    (destructor)InputCatcher_dealloc, /*tp_dealloc*/\n    0,                          /*tp_vectorcall_offset*/\n    0,                          /*tp_getattr*/\n    0,                          /*tp_setattr*/\n    0,                          /*tp_as_async*/\n    0,                          /*tp_repr*/\n    0,                          /*tp_as_number*/\n    0,                          /*tp_as_sequence*/\n    0,                          /*tp_as_mapping*/\n    0,                          /*tp_hash */\n    0,                          /*tp_call*/\n    0,                          /*tp_str*/\n    0,                          /*tp_getattro*/\n    0,                          /*tp_setattro*/\n    0,                          /*tp_as_buffer*/\n    Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,  /*tp_flags*/\n    PyDoc_STR(\"\"),              /* tp_doc */\n    0,                          /* tp_traverse */\n    0,                          /* tp_clear */\n    0,                          /* tp_richcompare */\n    0,                          /* tp_weaklistoffset */\n    0,                          /* tp_iter */\n    0,                          /* tp_iternext */\n    InputCatcher_methods,             /* tp_methods */\n    InputCatcher_members,             /* tp_members */\n    0,                          /* tp_getset */\n    0,                          /* tp_base */\n    0,                          /* tp_dict */\n    0,                          /* tp_descr_get */\n    0,                          /* tp_descr_set */\n    0,                          /* tp_dictoffset */\n    (initproc)InputCatcher_init,      /* tp_init */\n    0,                          /* tp_alloc */\n    InputCatcher_new,                 /* tp_new */\n    0,                          /* tp_free */\n    0,                          /* tp_is_gc */\n    0,                          /* tp_bases */\n    0,                          /* tp_mro */\n    0,                          /* tp_cache */\n    0,                          /* tp_subclasses */\n    0,                          /* tp_weaklist */\n    0,                          /* tp_del */\n    0,                          /* tp_version_tag */\n    0,                          /* tp_finalize */\n};\n\nstatic PyModuleDef IOCatchermodule =\n{\n    PyModuleDef_HEAD_INIT,\n   \"IOCatcher\",\n    PyDoc_STR(\"Module containing IO catchers for redirecting input and output streams.\"),\n    -1,\n};\n\nPyMODINIT_FUNC PyInit_IOCatcher(void)\n{    \n    if (PyType_Ready(&OutputCatcherType) < 0)\n    {\n        return NULL;\n    }\n\n    if (PyType_Ready(&InputCatcherType) < 0)\n    {\n        return NULL;\n    }\n\n    PyObject * module = PyModule_Create(&IOCatchermodule);\n    if (module == NULL)\n    {\n        return NULL;\n    }\n        \n    Py_INCREF(&OutputCatcherType);\n    if (PyModule_AddObject(module, \"OutputCatcher\", (PyObject *)&OutputCatcherType) < 0)\n    {\n        Py_DECREF(&OutputCatcherType);\n        Py_DECREF(module);\n\n        return NULL;\n    }\n\n    Py_INCREF(&InputCatcherType);\n    if (PyModule_AddObject(module, \"InputCatcher\", (PyObject *)&InputCatcherType) < 0)\n    {\n        Py_DECREF(&OutputCatcherType);\n        Py_DECREF(&InputCatcherType);\n        Py_DECREF(module);\n\n        return NULL;\n    }\n\n    return module;\n}\n"
  },
  {
    "path": "PythonAPI/extensions/IOCatcher.h",
    "content": "//-----------------------------------------------------------------------------\n// File: IOCatcher.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Esko Pekkarinen\n// Date: 12.02.2021\n//\n// Description:\n// <Short description of the class/file contents>\n//-----------------------------------------------------------------------------\n\n#ifndef OUTPUTFORWARDER_H\n#define OUTPUTFORWARDER_H\n\n#define PY_SSIZE_T_CLEAN\n#include <Python.h>\n\n#include <PythonAPI/WriteChannel.h>\n\ntypedef struct\n{\n    PyObject_HEAD\n    WriteChannel* channel;\n} OutputCatcherObject;\n\ntypedef struct\n{\n    PyObject_HEAD\n} InputCatcherObject;\n\n PyMODINIT_FUNC PyInit_IOCatcher(void);\n\n#endif // OUTPUTFORWARDER_H"
  },
  {
    "path": "PythonAPI/ipmm_core_pkg/__init__.py",
    "content": "# empty"
  },
  {
    "path": "PythonAPI/ipmm_core_pkg/addressBlock.py",
    "content": "#<ipxact:addressBlock>\n# But currently only can concist of register\n\n\nfrom ipmm_core_pkg.primitive import Primitive\nfrom ipmm_core_pkg.register import Register\n\nclass AddressBlock(Primitive):\n\n\tdef __init__(self, name, description, range, width):\n\t\tpass\n\t\tPrimitive.__init__(self, name, description)\n\t\tself.range = range\n\t\tself.width = width\n\t\tself.registers = []\n\t\t\n\tdef get_range(self):\n\t\treturn self.range\n\n\tdef get_width(self):\n\t\treturn self.width\n\n\tdef add_register(self, register):\n\t\tif type(register) is not Register:\n\t\t\tprint(\"Type of add_register parameter is not Register\")\n\t\telse:\n\t\t\tself.registers.append(register)\n\t\treturn 0\n\n\n\tdef printer(self):\n\t\tPrimitive.printer(self)\n\t\tprint(\"range: \", self.get_range())\n\t\tprint(\"width: \", self.get_width())\n\t\tfor r in self.registers:\n\t\t\tr.printer()\n\n\n# Stand-a-lone testing\nif __name__ == \"__main__\":\t\n\taddressBlock_1 = AddressBlock(\"PP_Address_Block\", \"Peripheral address block\", 2, 32)\n\taddressBlock_1.printer()\n\n\t\n\n"
  },
  {
    "path": "PythonAPI/ipmm_core_pkg/component.py",
    "content": "\n\nfrom ipmm_core_pkg.primitive import Primitive\nfrom ipmm_core_pkg.addressBlock import AddressBlock\nfrom ipmm_core_pkg.register import Register\nfrom ipmm_core_pkg.field import Field\nfrom ipmm_core_pkg.port import Port\nfrom ipmm_core_pkg.parameter import Parameter\n\n        \nclass Component(Primitive):\n\n        def __init__(self, name, description):\n            pass\n            Primitive.__init__(self, name, description)\n            self.parameters = []\n            self.ports = []\n            self.buses = []\n            self.constants = []\n            self.signals = []\n            self.memoryMaps = []\n            self.behavior = []\n            self.renderers = []\n            \n        #TODO: type checkings for add_\n        def add_parameter(self, parameter):\n            self.parameters.append(parameter)\n\n        def add_port(self, port):\n            self.ports.append(port)\n\n        def add_constant(self, constant):\n            self.constants.append(constant)\n        \n\n        def add_memoryMap(self, memoryMap):\n            self.memoryMaps.append(memoryMap)\n\n        def add_renderer(self, renderer):\n            self.renderers.append(renderer)\n\n        ## render can manipulate (remove, add, modify) parameters, ports, memorymaps    \n        def render(self):\n            for r in self.renderers:\n                r()\n\n        def printer(self):\n            Primitive.printer(self)\n\n            for p in self.ports:\n                p.printer()\n\n            for c in self.constants:\n                c.printer()\n\n\n            for mm in self.memoryMaps:\n                mm.printer()\n\n\n# Stand-a-lone testing\nif __name__ == \"__main__\":\t\n\n\n        register_1 = Register(\"STAT\", \"Status register.\", 2, 32)\n        field_1 = Field(\"RX-FIFO\", \"RX-FIFO Not Empty.\", 0, 1, \"read-only\")\n        field_2 = Field(\"RXFIFO_OVFL\", \"X-FIFO Overflow.\", 1, 1, \"read-write\")\n        \n        ## move this to rgister_if class\n        port_1 = Port(field_1.get_name()+\"_input\", \"RX-FIFO Not Empty inout\", \"logic\", field_1.get_bitWidth(), \"input\")\n        port_2 = Port(field_2.get_name()+\"_output\", \"RX-FIFO Overflow output\", \"logic\", field_2.get_bitWidth(), \"output\")\n\n\n        register_2 = Register(\"CMD\", \"Command register.\", 4, 32)\n        field_3 = Field(\"Command\", \"Peripheral Command.\", 0, 4, \"read-write\")\n    \n     \n        register_1.add_field(field_1)\n        register_1.add_field(field_2)\n        \n        register_2.add_field(field_3)\n\n        addressBlock_1 = AddressBlock(\"PP_Address_Block\", \"Peripheral address block\", 32, 32)\n        addressBlock_1.add_register(register_1)\n        addressBlock_1.add_register(register_2)\n\n\n        component_1 = Component(\"Helloder\", \"This components is Helloder\")\n        component_1.add_port(port_1)\n        component_1.add_port(port_2)\n\n        component_1.add_memoryMap(addressBlock_1)\n        \n\n        component_1.printer()\n"
  },
  {
    "path": "PythonAPI/ipmm_core_pkg/field.py",
    "content": "\n#<ipxact:field>\n#            <ipxact:name>RXFIFO_NE</ipxact:name>\n#            <ipxact:description>RX-FIFO Not Empty. This interrupt capable status flag indicates the RX-FIFO status and associated interrupt status before the enable stage. The flag can only be implicitly cleared by reading the RXFIFO_DAT register</ipxact:description>\n#            <ipxact:bitOffset>0</ipxact:bitOffset>\n#            <ipxact:bitWidth>1</ipxact:bitWidth>\n#            <ipxact:access>read-only</ipxact:access>\n#\n\nfrom ipmm_core_pkg.primitive import Primitive\nfrom ipmm_core_pkg.reset import Reset\n\n\nclass Field(Primitive):\n\n\tdef __init__(self, name, description, bitOffset, bitWidth, access):\n\t\tpass\n\t\tPrimitive.__init__(self, name, description)\n\t\tself.bitOffset = bitOffset\n\t\tself.bitWidth = bitWidth\n\t\tself.access = access\n\t\tself.resets = []\n\t\t\n\tdef get_bitOffset(self):\n\t\treturn self.bitOffset\n\t\t\n\tdef get_bitWidth(self):\n\t\treturn self.bitWidth\n\t\t\n\tdef get_access(self):\n\t\treturn self.access\n\n\tdef add_reset(self, reset):\n\t\tif type(reset) is not Reset:\n\t\t\tprint(\"Type of add_reset parameter is not Reset\")\n\t\telse:\n\t\t\tself.resets.append(reset)\n\t\treturn 0\n\tdef get_reset_by_type(self, typeName):\n\t\tfound = 0\n\t\tfor rst in self.resets:\n\t\t\tif rst.get_resetType() is \"HW\":\n\t\t\t\tfound = 1\n\t\t\t\tprint(\"get_reset_by_type found\", typeName)\n\t\t\t\treturn rst\n\t\treturn found\n\n\t\t\n\tdef printer(self):\n\t\tPrimitive.printer(self)\n\t\tprint(\"bitOffset: \", self.get_bitOffset())\n\t\tprint(\"bitWidth: \", self.get_bitWidth())\n\t\tprint(\"access: \", self.get_access())\n\t\tfor rst in self.resets:\n\t\t\trst.printer()\n\n# Stand-a-lone testing\nif __name__ == \"__main__\":\t\n\tfield_1 = Field(\"RX-FIFO\", \"RX-FIFO Not Empty.\", 0, 1, \"read-only\")\n\treset_1 = Reset(\"rstm\", \"Reset\", \"HW\", 1, 1)\n\tfield_1.add_reset(reset_1)\n\tfield_1.printer()\n\n\treset_2 = field_1.get_reset_by_type(\"HW\")\n\treset_2.printer()\n\n"
  },
  {
    "path": "PythonAPI/ipmm_core_pkg/parameter.py",
    "content": "# Parameter can represent configuration values and constants\n\n\nfrom ipmm_core_pkg.primitive import Primitive\n\nclass Parameter(Primitive):\n\n\tdef __init__(self, name, description, dataType, bitWidth, value):\n\t\tpass\n\t\tPrimitive.__init__(self, name, description)\n\t\tself.dataType = dataType\n\t\tself.bitWidth = bitWidth\n\t\tself.value = value\n\t\t\t\t\n\tdef get_dataType(self):\n\t\treturn self.dataType\n\t\t\n\tdef get_bitWidth(self):\n\t\treturn self.bitWidth\n\t\t\n\tdef get_value(self):\n\t\treturn self.value\n\n\tdef printer(self):\n\t\tPrimitive.printer(self)\n\t\tprint(\"dataType: \", self.get_dataType())\n\t\tprint(\"bitWidth: \", self.get_bitWidth())\n\t\tprint(\"value: \", self.get_value())\n\n# Stand-a-lone testing\nif __name__ == \"__main__\":\t\n\tparameter_1 = Parameter(\"RX_FIFO_const\", \"RX-FIFO threshold value parameter.\", \"logic\" , 4, 1)\n\tparameter_1.printer()\n"
  },
  {
    "path": "PythonAPI/ipmm_core_pkg/port.py",
    "content": "\n# Getting port and related bitwidth from IP-XACT is way too complex to serve simple templates.\n# Thus IR model has much simples port definition\n\nfrom ipmm_core_pkg.primitive import Primitive\n\nclass Port(Primitive):\n\n\tdef __init__(self, name, description, dataType, bitWidth, direction):\n\t\tpass\n\t\tPrimitive.__init__(self, name, description)\n\t\tself.dataType = dataType\n\t\tself.bitWidth = bitWidth\n\t\tself.direction = direction\n\t\t\t\t\n\tdef get_dataType(self):\n\t\treturn self.dataType\n\t\t\n\tdef get_bitWidth(self):\n\t\treturn self.bitWidth\n\t\t\n\tdef get_direction(self):\n\t\treturn self.direction\n\n\tdef printer(self):\n\t\tPrimitive.printer(self)\n\t\tprint(\"dataType: \", self.get_dataType())\n\t\tprint(\"bitWidth: \", self.get_bitWidth())\n\t\tprint(\"direction: \", self.get_direction())\n\t\t\n\n# Stand-a-lone testing\nif __name__ == \"__main__\":\t\n\tport_1 = Port(\"RX_FIFO_output\", \"RX-FIFO Not Empty output.\", \"logic\", 1, \"output\")\n\tport_1.printer()\n\n"
  },
  {
    "path": "PythonAPI/ipmm_core_pkg/primitive.py",
    "content": "\nclass Primitive(object):\n\n\tdef __init__(self, name, description):\n\t\tself.name = name\n\t\tself.description =  description\n\t\tself.elements = []\n\t\t\n\tdef get_name(self):\n\t\treturn self.name\n        \n\tdef get_description(self):\n\t\treturn self.description\n        \n\tdef add_element(self, element):\n\t\tself.elements.append(element)\n\n\tdef printer(self):\n\t\tprint(\"Type: \", type(self))\n\t\tprint(\"Name: \", self.get_name())\n\t\tprint(\"Description: \", self.get_description())\n\t\t\n\n# Stand-a-lone testing\nif __name__ == \"__main__\":\t\n\tprimitive_1 = Primitive(\"RX_FIFO\", \"RX-FIFO Not Empty element\")\n\tprimitive_1.printer()\n"
  },
  {
    "path": "PythonAPI/ipmm_core_pkg/register.py",
    "content": "#<ipxact:register>\n#          <ipxact:name>STAT</ipxact:name>\n#          <ipxact:description>Status register. Collection of Status flags including interrupt status before enabling</ipxact:description>\n#          <ipxact:addressOffset>'h0</ipxact:addressOffset>\n#          <ipxact:size>32</ipxact:size>\n\nfrom ipmm_core_pkg.primitive import Primitive\nfrom ipmm_core_pkg.field import Field\n\nclass Register(Primitive):\n\n\tdef __init__(self, name, description, addressOffset, size):\n\t\tpass\n\t\tPrimitive.__init__(self, name, description)\n\t\tself.addressOffset = addressOffset\n\t\tself.size = size\n\t\tself.fields = []\n\t\t\n\tdef get_addressOffset(self):\n\t\treturn self.addressOffset\n\n\tdef get_size(self):\n\t\treturn self.size\n\n\tdef add_field(self, field):\n\t\tif type(field) is not Field:\n\t\t\tprint(\"Type of add_field parameter is not Field\")\n\t\telse:\n\t\t\tself.fields.append(field)\n\t\treturn 0\n\n\n\tdef printer(self):\n\t\tPrimitive.printer(self)\n\t\tprint(\"addressOffset: \", self.get_addressOffset())\n\t\tprint(\"size: \", self.get_size())\n\t\tfor f in self.fields:\n\t\t\tf.printer()\n\n\n# Stand-a-lone testing\nif __name__ == \"__main__\":\n\tfrom ipmm_core_pkg.reset import Reset\n\tregister_1 = Register(\"STAT\", \"Status register.\", 0, 32)\n\tfield_1 = Field(\"RX-FIFO\", \"RX-FIFO Not Empty.\", 0, 1, \"read-only\")\n\tfield_2 = Field(\"RXFIFO_OVFL\", \"X-FIFO Overflow.\", 1, 1, \"read-write\")\n\treset_1 = Reset(\"rstm\", \"Reset\", \"HW\", 1, 1)\n\tfield_1.add_reset(reset_1)\n\tregister_1.add_field(field_1)\n\tregister_1.add_field(field_2)\n\n\tregister_1.printer()\n\n\n\t\n\t\n"
  },
  {
    "path": "PythonAPI/ipmm_core_pkg/reset.py",
    "content": "# ipxact:reset\n\n\nfrom ipmm_core_pkg.primitive import Primitive\n\nclass Reset(Primitive):\n\n\tdef __init__(self, name, description, resetType, value, mask):\n\t\tpass\n\t\tPrimitive.__init__(self, name, description)\n\t\tself.resetType = resetType\n\t\tself.value = value\n\t\tself.mask = mask\n\t\t\t\t\n\tdef get_resetType(self):\n\t\treturn self.resetType\n\t\t\n\tdef get_value(self):\n\t\treturn self.value\n\t\t\n\tdef get_mask(self):\n\t\treturn self.mask\n\n\tdef printer(self):\n\t\tPrimitive.printer(self)\n\t\tprint(\"resetType: \", self.get_resetType())\n\t\tprint(\"value: \", self.get_value())\n\t\tprint(\"mask: \", self.get_mask())\n\n# Stand-a-lone testing\nif __name__ == \"__main__\":\t\n\treset_1 = Reset(\"rstm\", \"Reset\", \"HW\", 1, 1)\n\treset_1.printer()\n"
  },
  {
    "path": "PythonAPI/python-3.10.6-embed-amd64/LICENSE.txt",
    "content": "A. HISTORY OF THE SOFTWARE\n==========================\n\nPython was created in the early 1990s by Guido van Rossum at Stichting\nMathematisch Centrum (CWI, see http://www.cwi.nl) in the Netherlands\nas a successor of a language called ABC.  Guido remains Python's\nprincipal author, although it includes many contributions from others.\n\nIn 1995, Guido continued his work on Python at the Corporation for\nNational Research Initiatives (CNRI, see http://www.cnri.reston.va.us)\nin Reston, Virginia where he released several versions of the\nsoftware.\n\nIn May 2000, Guido and the Python core development team moved to\nBeOpen.com to form the BeOpen PythonLabs team.  In October of the same\nyear, the PythonLabs team moved to Digital Creations, which became\nZope Corporation.  In 2001, the Python Software Foundation (PSF, see\nhttps://www.python.org/psf/) was formed, a non-profit organization\ncreated specifically to own Python-related Intellectual Property.\nZope Corporation was a sponsoring member of the PSF.\n\nAll Python releases are Open Source (see http://www.opensource.org for\nthe Open Source Definition).  Historically, most, but not all, Python\nreleases have also been GPL-compatible; the table below summarizes\nthe various releases.\n\n    Release         Derived     Year        Owner       GPL-\n                    from                                compatible? (1)\n\n    0.9.0 thru 1.2              1991-1995   CWI         yes\n    1.3 thru 1.5.2  1.2         1995-1999   CNRI        yes\n    1.6             1.5.2       2000        CNRI        no\n    2.0             1.6         2000        BeOpen.com  no\n    1.6.1           1.6         2001        CNRI        yes (2)\n    2.1             2.0+1.6.1   2001        PSF         no\n    2.0.1           2.0+1.6.1   2001        PSF         yes\n    2.1.1           2.1+2.0.1   2001        PSF         yes\n    2.1.2           2.1.1       2002        PSF         yes\n    2.1.3           2.1.2       2002        PSF         yes\n    2.2 and above   2.1.1       2001-now    PSF         yes\n\nFootnotes:\n\n(1) GPL-compatible doesn't mean that we're distributing Python under\n    the GPL.  All Python licenses, unlike the GPL, let you distribute\n    a modified version without making your changes open source.  The\n    GPL-compatible licenses make it possible to combine Python with\n    other software that is released under the GPL; the others don't.\n\n(2) According to Richard Stallman, 1.6.1 is not GPL-compatible,\n    because its license has a choice of law clause.  According to\n    CNRI, however, Stallman's lawyer has told CNRI's lawyer that 1.6.1\n    is \"not incompatible\" with the GPL.\n\nThanks to the many outside volunteers who have worked under Guido's\ndirection to make these releases possible.\n\n\nB. TERMS AND CONDITIONS FOR ACCESSING OR OTHERWISE USING PYTHON\n===============================================================\n\nPython software and documentation are licensed under the\nPython Software Foundation License Version 2.\n\nStarting with Python 3.8.6, examples, recipes, and other code in\nthe documentation are dual licensed under the PSF License Version 2\nand the Zero-Clause BSD license.\n\nSome software incorporated into Python is under different licenses.\nThe licenses are listed with code falling under that license.\n\n\nPYTHON SOFTWARE FOUNDATION LICENSE VERSION 2\n--------------------------------------------\n\n1. This LICENSE AGREEMENT is between the Python Software Foundation\n(\"PSF\"), and the Individual or Organization (\"Licensee\") accessing and\notherwise using this software (\"Python\") in source or binary form and\nits associated documentation.\n\n2. Subject to the terms and conditions of this License Agreement, PSF hereby\ngrants Licensee a nonexclusive, royalty-free, world-wide license to reproduce,\nanalyze, test, perform and/or display publicly, prepare derivative works,\ndistribute, and otherwise use Python alone or in any derivative version,\nprovided, however, that PSF's License Agreement and PSF's notice of copyright,\ni.e., \"Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,\n2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020, 2021, 2022 Python Software Foundation;\nAll Rights Reserved\" are retained in Python alone or in any derivative version\nprepared by Licensee.\n\n3. In the event Licensee prepares a derivative work that is based on\nor incorporates Python or any part thereof, and wants to make\nthe derivative work available to others as provided herein, then\nLicensee hereby agrees to include in any such work a brief summary of\nthe changes made to Python.\n\n4. PSF is making Python available to Licensee on an \"AS IS\"\nbasis.  PSF MAKES NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR\nIMPLIED.  BY WAY OF EXAMPLE, BUT NOT LIMITATION, PSF MAKES NO AND\nDISCLAIMS ANY REPRESENTATION OR WARRANTY OF MERCHANTABILITY OR FITNESS\nFOR ANY PARTICULAR PURPOSE OR THAT THE USE OF PYTHON WILL NOT\nINFRINGE ANY THIRD PARTY RIGHTS.\n\n5. PSF SHALL NOT BE LIABLE TO LICENSEE OR ANY OTHER USERS OF PYTHON\nFOR ANY INCIDENTAL, SPECIAL, OR CONSEQUENTIAL DAMAGES OR LOSS AS\nA RESULT OF MODIFYING, DISTRIBUTING, OR OTHERWISE USING PYTHON,\nOR ANY DERIVATIVE THEREOF, EVEN IF ADVISED OF THE POSSIBILITY THEREOF.\n\n6. This License Agreement will automatically terminate upon a material\nbreach of its terms and conditions.\n\n7. Nothing in this License Agreement shall be deemed to create any\nrelationship of agency, partnership, or joint venture between PSF and\nLicensee.  This License Agreement does not grant permission to use PSF\ntrademarks or trade name in a trademark sense to endorse or promote\nproducts or services of Licensee, or any third party.\n\n8. By copying, installing or otherwise using Python, Licensee\nagrees to be bound by the terms and conditions of this License\nAgreement.\n\n\nBEOPEN.COM LICENSE AGREEMENT FOR PYTHON 2.0\n-------------------------------------------\n\nBEOPEN PYTHON OPEN SOURCE LICENSE AGREEMENT VERSION 1\n\n1. This LICENSE AGREEMENT is between BeOpen.com (\"BeOpen\"), having an\noffice at 160 Saratoga Avenue, Santa Clara, CA 95051, and the\nIndividual or Organization (\"Licensee\") accessing and otherwise using\nthis software in source or binary form and its associated\ndocumentation (\"the Software\").\n\n2. Subject to the terms and conditions of this BeOpen Python License\nAgreement, BeOpen hereby grants Licensee a non-exclusive,\nroyalty-free, world-wide license to reproduce, analyze, test, perform\nand/or display publicly, prepare derivative works, distribute, and\notherwise use the Software alone or in any derivative version,\nprovided, however, that the BeOpen Python License is retained in the\nSoftware, alone or in any derivative version prepared by Licensee.\n\n3. BeOpen is making the Software available to Licensee on an \"AS IS\"\nbasis.  BEOPEN MAKES NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR\nIMPLIED.  BY WAY OF EXAMPLE, BUT NOT LIMITATION, BEOPEN MAKES NO AND\nDISCLAIMS ANY REPRESENTATION OR WARRANTY OF MERCHANTABILITY OR FITNESS\nFOR ANY PARTICULAR PURPOSE OR THAT THE USE OF THE SOFTWARE WILL NOT\nINFRINGE ANY THIRD PARTY RIGHTS.\n\n4. BEOPEN SHALL NOT BE LIABLE TO LICENSEE OR ANY OTHER USERS OF THE\nSOFTWARE FOR ANY INCIDENTAL, SPECIAL, OR CONSEQUENTIAL DAMAGES OR LOSS\nAS A RESULT OF USING, MODIFYING OR DISTRIBUTING THE SOFTWARE, OR ANY\nDERIVATIVE THEREOF, EVEN IF ADVISED OF THE POSSIBILITY THEREOF.\n\n5. This License Agreement will automatically terminate upon a material\nbreach of its terms and conditions.\n\n6. This License Agreement shall be governed by and interpreted in all\nrespects by the law of the State of California, excluding conflict of\nlaw provisions.  Nothing in this License Agreement shall be deemed to\ncreate any relationship of agency, partnership, or joint venture\nbetween BeOpen and Licensee.  This License Agreement does not grant\npermission to use BeOpen trademarks or trade names in a trademark\nsense to endorse or promote products or services of Licensee, or any\nthird party.  As an exception, the \"BeOpen Python\" logos available at\nhttp://www.pythonlabs.com/logos.html may be used according to the\npermissions granted on that web page.\n\n7. By copying, installing or otherwise using the software, Licensee\nagrees to be bound by the terms and conditions of this License\nAgreement.\n\n\nCNRI LICENSE AGREEMENT FOR PYTHON 1.6.1\n---------------------------------------\n\n1. This LICENSE AGREEMENT is between the Corporation for National\nResearch Initiatives, having an office at 1895 Preston White Drive,\nReston, VA 20191 (\"CNRI\"), and the Individual or Organization\n(\"Licensee\") accessing and otherwise using Python 1.6.1 software in\nsource or binary form and its associated documentation.\n\n2. Subject to the terms and conditions of this License Agreement, CNRI\nhereby grants Licensee a nonexclusive, royalty-free, world-wide\nlicense to reproduce, analyze, test, perform and/or display publicly,\nprepare derivative works, distribute, and otherwise use Python 1.6.1\nalone or in any derivative version, provided, however, that CNRI's\nLicense Agreement and CNRI's notice of copyright, i.e., \"Copyright (c)\n1995-2001 Corporation for National Research Initiatives; All Rights\nReserved\" are retained in Python 1.6.1 alone or in any derivative\nversion prepared by Licensee.  Alternately, in lieu of CNRI's License\nAgreement, Licensee may substitute the following text (omitting the\nquotes): \"Python 1.6.1 is made available subject to the terms and\nconditions in CNRI's License Agreement.  This Agreement together with\nPython 1.6.1 may be located on the internet using the following\nunique, persistent identifier (known as a handle): 1895.22/1013.  This\nAgreement may also be obtained from a proxy server on the internet\nusing the following URL: http://hdl.handle.net/1895.22/1013\".\n\n3. In the event Licensee prepares a derivative work that is based on\nor incorporates Python 1.6.1 or any part thereof, and wants to make\nthe derivative work available to others as provided herein, then\nLicensee hereby agrees to include in any such work a brief summary of\nthe changes made to Python 1.6.1.\n\n4. CNRI is making Python 1.6.1 available to Licensee on an \"AS IS\"\nbasis.  CNRI MAKES NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR\nIMPLIED.  BY WAY OF EXAMPLE, BUT NOT LIMITATION, CNRI MAKES NO AND\nDISCLAIMS ANY REPRESENTATION OR WARRANTY OF MERCHANTABILITY OR FITNESS\nFOR ANY PARTICULAR PURPOSE OR THAT THE USE OF PYTHON 1.6.1 WILL NOT\nINFRINGE ANY THIRD PARTY RIGHTS.\n\n5. CNRI SHALL NOT BE LIABLE TO LICENSEE OR ANY OTHER USERS OF PYTHON\n1.6.1 FOR ANY INCIDENTAL, SPECIAL, OR CONSEQUENTIAL DAMAGES OR LOSS AS\nA RESULT OF MODIFYING, DISTRIBUTING, OR OTHERWISE USING PYTHON 1.6.1,\nOR ANY DERIVATIVE THEREOF, EVEN IF ADVISED OF THE POSSIBILITY THEREOF.\n\n6. This License Agreement will automatically terminate upon a material\nbreach of its terms and conditions.\n\n7. This License Agreement shall be governed by the federal\nintellectual property law of the United States, including without\nlimitation the federal copyright law, and, to the extent such\nU.S. federal law does not apply, by the law of the Commonwealth of\nVirginia, excluding Virginia's conflict of law provisions.\nNotwithstanding the foregoing, with regard to derivative works based\non Python 1.6.1 that incorporate non-separable material that was\npreviously distributed under the GNU General Public License (GPL), the\nlaw of the Commonwealth of Virginia shall govern this License\nAgreement only as to issues arising under or with respect to\nParagraphs 4, 5, and 7 of this License Agreement.  Nothing in this\nLicense Agreement shall be deemed to create any relationship of\nagency, partnership, or joint venture between CNRI and Licensee.  This\nLicense Agreement does not grant permission to use CNRI trademarks or\ntrade name in a trademark sense to endorse or promote products or\nservices of Licensee, or any third party.\n\n8. By clicking on the \"ACCEPT\" button where indicated, or by copying,\ninstalling or otherwise using Python 1.6.1, Licensee agrees to be\nbound by the terms and conditions of this License Agreement.\n\n        ACCEPT\n\n\nCWI LICENSE AGREEMENT FOR PYTHON 0.9.0 THROUGH 1.2\n--------------------------------------------------\n\nCopyright (c) 1991 - 1995, Stichting Mathematisch Centrum Amsterdam,\nThe Netherlands.  All rights reserved.\n\nPermission to use, copy, modify, and distribute this software and its\ndocumentation for any purpose and without fee is hereby granted,\nprovided that the above copyright notice appear in all copies and that\nboth that copyright notice and this permission notice appear in\nsupporting documentation, and that the name of Stichting Mathematisch\nCentrum or CWI not be used in advertising or publicity pertaining to\ndistribution of the software without specific, written prior\npermission.\n\nSTICHTING MATHEMATISCH CENTRUM DISCLAIMS ALL WARRANTIES WITH REGARD TO\nTHIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND\nFITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH CENTRUM BE LIABLE\nFOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES\nWHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN\nACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT\nOF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.\n\nZERO-CLAUSE BSD LICENSE FOR CODE IN THE PYTHON DOCUMENTATION\n----------------------------------------------------------------------\n\nPermission to use, copy, modify, and/or distribute this software for any\npurpose with or without fee is hereby granted.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\nREGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY\nAND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\nINDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM\nLOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR\nOTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR\nPERFORMANCE OF THIS SOFTWARE.\n\n\n\nAdditional Conditions for this Windows binary build\n---------------------------------------------------\n\nThis program is linked with and uses Microsoft Distributable Code,\ncopyrighted by Microsoft Corporation. The Microsoft Distributable Code\nis embedded in each .exe, .dll and .pyd file as a result of running\nthe code through a linker.\n\nIf you further distribute programs that include the Microsoft\nDistributable Code, you must comply with the restrictions on\ndistribution specified by Microsoft. In particular, you must require\ndistributors and external end users to agree to terms that protect the\nMicrosoft Distributable Code at least as much as Microsoft's own\nrequirements for the Distributable Code. See Microsoft's documentation\n(included in its developer tools and on its website at microsoft.com)\nfor specific details.\n\nRedistribution of the Windows binary build of the Python interpreter\ncomplies with this agreement, provided that you do not:\n\n- alter any copyright, trademark or patent notice in Microsoft's\nDistributable Code;\n\n- use Microsoft's trademarks in your programs' names or in a way that\nsuggests your programs come from or are endorsed by Microsoft;\n\n- distribute Microsoft's Distributable Code to run on a platform other\nthan Microsoft operating systems, run-time technologies or application\nplatforms; or\n\n- include Microsoft Distributable Code in malicious, deceptive or\nunlawful programs.\n\nThese restrictions apply only to the Microsoft Distributable Code as\ndefined above, not to Python itself or any programs running on the\nPython interpreter. The redistribution of the Python interpreter and\nlibraries is governed by the Python Software License included with this\nfile, or by other licenses as marked.\n\n\n\n--------------------------------------------------------------------------\n\nThis program, \"bzip2\", the associated library \"libbzip2\", and all\ndocumentation, are copyright (C) 1996-2019 Julian R Seward.  All\nrights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions\nare met:\n\n1. Redistributions of source code must retain the above copyright\n   notice, this list of conditions and the following disclaimer.\n\n2. The origin of this software must not be misrepresented; you must \n   not claim that you wrote the original software.  If you use this \n   software in a product, an acknowledgment in the product \n   documentation would be appreciated but is not required.\n\n3. Altered source versions must be plainly marked as such, and must\n   not be misrepresented as being the original software.\n\n4. The name of the author may not be used to endorse or promote \n   products derived from this software without specific prior written \n   permission.\n\nTHIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS\nOR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\nWARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\nARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY\nDIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\nDAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE\nGOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS\nINTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\nWHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING\nNEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\nSOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\nJulian Seward, jseward@acm.org\nbzip2/libbzip2 version 1.0.8 of 13 July 2019\n\n--------------------------------------------------------------------------\n\n\n  LICENSE ISSUES\n  ==============\n\n  The OpenSSL toolkit stays under a double license, i.e. both the conditions of\n  the OpenSSL License and the original SSLeay license apply to the toolkit.\n  See below for the actual license texts.\n\n  OpenSSL License\n  ---------------\n\n/* ====================================================================\n * Copyright (c) 1998-2019 The OpenSSL Project.  All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n *\n * 1. Redistributions of source code must retain the above copyright\n *    notice, this list of conditions and the following disclaimer.\n *\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in\n *    the documentation and/or other materials provided with the\n *    distribution.\n *\n * 3. All advertising materials mentioning features or use of this\n *    software must display the following acknowledgment:\n *    \"This product includes software developed by the OpenSSL Project\n *    for use in the OpenSSL Toolkit. (http://www.openssl.org/)\"\n *\n * 4. The names \"OpenSSL Toolkit\" and \"OpenSSL Project\" must not be used to\n *    endorse or promote products derived from this software without\n *    prior written permission. For written permission, please contact\n *    openssl-core@openssl.org.\n *\n * 5. Products derived from this software may not be called \"OpenSSL\"\n *    nor may \"OpenSSL\" appear in their names without prior written\n *    permission of the OpenSSL Project.\n *\n * 6. Redistributions of any form whatsoever must retain the following\n *    acknowledgment:\n *    \"This product includes software developed by the OpenSSL Project\n *    for use in the OpenSSL Toolkit (http://www.openssl.org/)\"\n *\n * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY\n * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\n * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE OpenSSL PROJECT OR\n * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT\n * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,\n * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\n * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED\n * OF THE POSSIBILITY OF SUCH DAMAGE.\n * ====================================================================\n *\n * This product includes cryptographic software written by Eric Young\n * (eay@cryptsoft.com).  This product includes software written by Tim\n * Hudson (tjh@cryptsoft.com).\n *\n */\n\n Original SSLeay License\n -----------------------\n\n/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)\n * All rights reserved.\n *\n * This package is an SSL implementation written\n * by Eric Young (eay@cryptsoft.com).\n * The implementation was written so as to conform with Netscapes SSL.\n *\n * This library is free for commercial and non-commercial use as long as\n * the following conditions are aheared to.  The following conditions\n * apply to all code found in this distribution, be it the RC4, RSA,\n * lhash, DES, etc., code; not just the SSL code.  The SSL documentation\n * included with this distribution is covered by the same copyright terms\n * except that the holder is Tim Hudson (tjh@cryptsoft.com).\n *\n * Copyright remains Eric Young's, and as such any Copyright notices in\n * the code are not to be removed.\n * If this package is used in a product, Eric Young should be given attribution\n * as the author of the parts of the library used.\n * This can be in the form of a textual message at program startup or\n * in documentation (online or textual) provided with the package.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n * 1. Redistributions of source code must retain the copyright\n *    notice, this list of conditions and the following disclaimer.\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in the\n *    documentation and/or other materials provided with the distribution.\n * 3. All advertising materials mentioning features or use of this software\n *    must display the following acknowledgement:\n *    \"This product includes cryptographic software written by\n *     Eric Young (eay@cryptsoft.com)\"\n *    The word 'cryptographic' can be left out if the rouines from the library\n *    being used are not cryptographic related :-).\n * 4. If you include any Windows specific code (or a derivative thereof) from\n *    the apps directory (application code) you must include an acknowledgement:\n *    \"This product includes software written by Tim Hudson (tjh@cryptsoft.com)\"\n *\n * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND\n * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE\n * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\n * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\n * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\n * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\n * SUCH DAMAGE.\n *\n * The licence and distribution terms for any publically available version or\n * derivative of this code cannot be changed.  i.e. this code cannot simply be\n * copied and put under another distribution licence\n * [including the GNU Public Licence.]\n */\n\n\nlibffi - Copyright (c) 1996-2014  Anthony Green, Red Hat, Inc and others.\nSee source files for details.\n\nPermission is hereby granted, free of charge, to any person obtaining\na copy of this software and associated documentation files (the\n``Software''), to deal in the Software without restriction, including\nwithout limitation the rights to use, copy, modify, merge, publish,\ndistribute, sublicense, and/or sell copies of the Software, and to\npermit persons to whom the Software is furnished to do so, subject to\nthe following conditions:\n\nThe above copyright notice and this permission notice shall be\nincluded in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND,\nEXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.\nIN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY\nCLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,\nTORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\nSOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n\nThis software is copyrighted by the Regents of the University of\nCalifornia, Sun Microsystems, Inc., Scriptics Corporation, ActiveState\nCorporation and other parties.  The following terms apply to all files\nassociated with the software unless explicitly disclaimed in\nindividual files.\n\nThe authors hereby grant permission to use, copy, modify, distribute,\nand license this software and its documentation for any purpose, provided\nthat existing copyright notices are retained in all copies and that this\nnotice is included verbatim in any distributions. No written agreement,\nlicense, or royalty fee is required for any of the authorized uses.\nModifications to this software may be copyrighted by their authors\nand need not follow the licensing terms described here, provided that\nthe new terms are clearly indicated on the first page of each file where\nthey apply.\n\nIN NO EVENT SHALL THE AUTHORS OR DISTRIBUTORS BE LIABLE TO ANY PARTY\nFOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES\nARISING OUT OF THE USE OF THIS SOFTWARE, ITS DOCUMENTATION, OR ANY\nDERIVATIVES THEREOF, EVEN IF THE AUTHORS HAVE BEEN ADVISED OF THE\nPOSSIBILITY OF SUCH DAMAGE.\n\nTHE AUTHORS AND DISTRIBUTORS SPECIFICALLY DISCLAIM ANY WARRANTIES,\nINCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT.  THIS SOFTWARE\nIS PROVIDED ON AN \"AS IS\" BASIS, AND THE AUTHORS AND DISTRIBUTORS HAVE\nNO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR\nMODIFICATIONS.\n\nGOVERNMENT USE: If you are acquiring this software on behalf of the\nU.S. government, the Government shall have only \"Restricted Rights\"\nin the software and related documentation as defined in the Federal\nAcquisition Regulations (FARs) in Clause 52.227.19 (c) (2).  If you\nare acquiring the software on behalf of the Department of Defense, the\nsoftware shall be classified as \"Commercial Computer Software\" and the\nGovernment shall have only \"Restricted Rights\" as defined in Clause\n252.227-7014 (b) (3) of DFARs.  Notwithstanding the foregoing, the\nauthors grant the U.S. Government and others acting in its behalf\npermission to use and distribute the software in accordance with the\nterms specified in this license.\n\nThis software is copyrighted by the Regents of the University of\nCalifornia, Sun Microsystems, Inc., Scriptics Corporation, ActiveState\nCorporation, Apple Inc. and other parties.  The following terms apply to\nall files associated with the software unless explicitly disclaimed in\nindividual files.\n\nThe authors hereby grant permission to use, copy, modify, distribute,\nand license this software and its documentation for any purpose, provided\nthat existing copyright notices are retained in all copies and that this\nnotice is included verbatim in any distributions. No written agreement,\nlicense, or royalty fee is required for any of the authorized uses.\nModifications to this software may be copyrighted by their authors\nand need not follow the licensing terms described here, provided that\nthe new terms are clearly indicated on the first page of each file where\nthey apply.\n\nIN NO EVENT SHALL THE AUTHORS OR DISTRIBUTORS BE LIABLE TO ANY PARTY\nFOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES\nARISING OUT OF THE USE OF THIS SOFTWARE, ITS DOCUMENTATION, OR ANY\nDERIVATIVES THEREOF, EVEN IF THE AUTHORS HAVE BEEN ADVISED OF THE\nPOSSIBILITY OF SUCH DAMAGE.\n\nTHE AUTHORS AND DISTRIBUTORS SPECIFICALLY DISCLAIM ANY WARRANTIES,\nINCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT.  THIS SOFTWARE\nIS PROVIDED ON AN \"AS IS\" BASIS, AND THE AUTHORS AND DISTRIBUTORS HAVE\nNO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR\nMODIFICATIONS.\n\nGOVERNMENT USE: If you are acquiring this software on behalf of the\nU.S. government, the Government shall have only \"Restricted Rights\"\nin the software and related documentation as defined in the Federal\nAcquisition Regulations (FARs) in Clause 52.227.19 (c) (2).  If you\nare acquiring the software on behalf of the Department of Defense, the\nsoftware shall be classified as \"Commercial Computer Software\" and the\nGovernment shall have only \"Restricted Rights\" as defined in Clause\n252.227-7013 (b) (3) of DFARs.  Notwithstanding the foregoing, the\nauthors grant the U.S. Government and others acting in its behalf\npermission to use and distribute the software in accordance with the\nterms specified in this license.\n\nCopyright (c) 1993-1999 Ioi Kim Lam.\nCopyright (c) 2000-2001 Tix Project Group.\nCopyright (c) 2004 ActiveState\n\nThis software is copyrighted by the above entities\nand other parties.  The following terms apply to all files associated\nwith the software unless explicitly disclaimed in individual files.\n\nThe authors hereby grant permission to use, copy, modify, distribute,\nand license this software and its documentation for any purpose, provided\nthat existing copyright notices are retained in all copies and that this\nnotice is included verbatim in any distributions. No written agreement,\nlicense, or royalty fee is required for any of the authorized uses.\nModifications to this software may be copyrighted by their authors\nand need not follow the licensing terms described here, provided that\nthe new terms are clearly indicated on the first page of each file where\nthey apply.\n\nIN NO EVENT SHALL THE AUTHORS OR DISTRIBUTORS BE LIABLE TO ANY PARTY\nFOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES\nARISING OUT OF THE USE OF THIS SOFTWARE, ITS DOCUMENTATION, OR ANY\nDERIVATIVES THEREOF, EVEN IF THE AUTHORS HAVE BEEN ADVISED OF THE\nPOSSIBILITY OF SUCH DAMAGE.\n\nTHE AUTHORS AND DISTRIBUTORS SPECIFICALLY DISCLAIM ANY WARRANTIES,\nINCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT.  THIS SOFTWARE\nIS PROVIDED ON AN \"AS IS\" BASIS, AND THE AUTHORS AND DISTRIBUTORS HAVE\nNO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR\nMODIFICATIONS.\n\nGOVERNMENT USE: If you are acquiring this software on behalf of the\nU.S. government, the Government shall have only \"Restricted Rights\"\nin the software and related documentation as defined in the Federal \nAcquisition Regulations (FARs) in Clause 52.227.19 (c) (2).  If you\nare acquiring the software on behalf of the Department of Defense, the\nsoftware shall be classified as \"Commercial Computer Software\" and the\nGovernment shall have only \"Restricted Rights\" as defined in Clause\n252.227-7013 (c) (1) of DFARs.  Notwithstanding the foregoing, the\nauthors grant the U.S. Government and others acting in its behalf\npermission to use and distribute the software in accordance with the\nterms specified in this license. \n\n----------------------------------------------------------------------\n\nParts of this software are based on the Tcl/Tk software copyrighted by\nthe Regents of the University of California, Sun Microsystems, Inc.,\nand other parties. The original license terms of the Tcl/Tk software\ndistribution is included in the file docs/license.tcltk.\n\nParts of this software are based on the HTML Library software\ncopyrighted by Sun Microsystems, Inc. The original license terms of\nthe HTML Library software distribution is included in the file\ndocs/license.html_lib.\n\n"
  },
  {
    "path": "PythonAPI/python-3.10.6-embed-amd64/python310._pth",
    "content": "python310.zip\n.\n\n# Uncomment to run site.main() automatically\n#import site\n"
  },
  {
    "path": "PythonAPI/pythonHelps.py",
    "content": "exitWord = \"-exit\"\nlistWord = \"-list\"\nlistComponentsWord = \"-listComponents\"\nhelpWord = \"-help\"\nopenWord = \"-open\"\ncloseWord = \"-close\"\nportsWord = \"-ports\"\nportWord = \"-port\"\nsaveWord = \"-save\"\nmigrateWord = \"-migrate\"\n\nsetNameCommandWord = \"setName\"\n\ndef helpText():\n\tprint (exitWord, \"= exit\")\n\tprint (listWord, \"= list the VLNVs contained within the library\")\n\tprint (listComponentsWord, \"= list the VLNVs of components within the library\")\n\tprint (openWord, \"= open a VLNV document\")\n\tprint (helpWord, \"= show this help\")\n\ndef componentHelpText():\n\tprint (exitWord, \"= exit program\")\n\tprint (closeWord, \"= close component\")\n\tprint (portsWord, \"= list all the ports of the component\")\n\tprint (portWord, \"x\", setNameCommandWord, \"y = change the name of port x to y\")\n\tprint (saveWord, \"= save this component\")\n\tprint (migrateWord, \" = transfer data from the active component to a python component\")\n\tprint (helpWord, \"= show this help\")"
  },
  {
    "path": "PythonAPI/pythonapi_global.h",
    "content": "#pragma once\n\n#include <QtCore/qglobal.h>\n\n#ifndef BUILD_STATIC\n# if defined(PYTHONAPI_LIB)\n#  define PYTHONAPI_EXPORT Q_DECL_EXPORT\n# else\n#  define PYTHONAPI_EXPORT Q_DECL_IMPORT\n# endif\n#else\n# define PYTHONAPI_EXPORT\n#endif\n"
  },
  {
    "path": "PythonAPI/runPythonAPI.py",
    "content": "#from ipmm_core_pkg.component import Component\nimport pythonHelps\nfrom constructPythonComponent import createComponent\nimport pythonAPI\n\nprint (\"\\n\", end='')\nprint (\"Starting python program\")\napi = pythonAPI.PythonAPI()\nportsInterface = api.getPortsInterface()\nparameterInterface = api.getComponentParameterInterface()\n\ndef handleCommandsForOpenComponent(componentName):\n\tpythonHelps.componentHelpText()\n\tprint (\"\\n\", end='')\n\tcomponentCommand = input(\"Component command:\")\n\tcommandArray = []\n\twhile (componentCommand != pythonHelps.closeWord and componentCommand != pythonHelps.exitWord):\n\n\t\tif (componentCommand != \"\"):\n\t\t\tcommandArray = componentCommand.split()\n\t\t\tcomponentCommand = commandArray.pop(0)\n\t\t\t\n\t\tif (componentCommand == pythonHelps.portsWord):\n\t\t\tfor portName in portsInterface.getItemNames():\n\t\t\t\tprint (portName)\n\t\telif (componentCommand == pythonHelps.portWord and len(commandArray) == 3 and commandArray[1] == pythonHelps.setNameCommandWord):\n\t\t\tcurrentPortName = commandArray[0]\n\t\t\tnewPortName = commandArray[2]\n\t\t\tportsInterface.setName(currentPortName, newPortName);\n\n\t\t\tprint (\"Changed port %s name to %s\" % (currentPortName, newPortName))\n\t\t\t\n\t\telif (componentCommand == pythonHelps.saveWord):\n\t\t\tapi.saveComponent()\n\t\telif (componentCommand == pythonHelps.migrateWord):\n\t\t\tpythonComponent = createComponent(api, portsInterface, parameterInterface)\n\t\t\tprint ()\n\t\t\tpythonComponent.printer()\n\t\t\tfor parameter in pythonComponent.parameters:\n\t\t\t\tparameter.printer()\n\t\telif (componentCommand == pythonHelps.helpWord):\n\t\t\tpythonHelps.componentHelpText()\n\t\telse:\n\t\t\tprint(\"Error: unknown command\")\n\n\t\tprint (\"\\n\", end='')\n\t\tcomponentCommand = input(\"Component command: \")\n\tapi.closeOpenComponent()\n\tprint (\"Closing component\", componentName)\n\treturn componentCommand\n\nprint (api)\nprint (\"\\n\", end='')\n\nprint (\"\\n\", end='')\n\npythonHelps.helpText()\nprint(\"\\n\", end='')\n\ncommand = input(\"Command: \")\ncommandTarget = \"\"\nwhile (command != pythonHelps.exitWord):\n\t\n\tif (command != \"\"):\n\t\tcommandArray = command.split()\n\t\tcommand = commandArray[0]\n\t\tif (len(commandArray) > 1):\n\t\t\tcommandTarget = commandArray[1]\n\t\n\t\tif (command == pythonHelps.listWord):\n\t\t\t# List all VLNVs.\n\t\t\tapi.listVLNVs()\n\t\telif (command == pythonHelps.listComponentsWord):\n\t\t\t# List component VLNVs.\n\t\t\tapi.listComponentVLNVs()\n\t\telif (command == pythonHelps.openWord):\n\t\t\t# Open component for editing\n\t\t\tif (api.openComponent(pythonAPI.QString.fromStdString(commandTarget)) == True):\n\t\t\t\tprint(\"\\n\", end='')\n\t\t\t\tcomponentCommand = handleCommandsForOpenComponent(commandTarget)\n\t\t\t\tif (componentCommand == pythonHelps.exitWord):\n\t\t\t\t\tbreak\n\t\telif (command == pythonHelps.helpWord):\n\t\t\tpythonHelps.helpText()\n\t\telse:\n\t\t\tprint(\"Error: unknown command\")\n\t\n\tprint(\"\\n\", end='')\n\tcommand = input(\"Command: \")\n\nprint (\"Exiting...\")\ndel api"
  },
  {
    "path": "README.md",
    "content": "                                README : Kactus2\n\t\t\t\t   Copyright (c) 2012-2026 Tampere University\n                  https://research.tuni.fi/system-on-chip/tools\n\n## Summary\n![Kactus2 logo](common/graphics/appicon.png)\n\nKactus2 is a toolset for designing SoCs. The aim is easier IP reusability and integration for both hardware and\nsoftware. The tool supports both the IEEE 1685-2014 and IEEE 1685-2022 \"IP-XACT\" standards.\n\nWindows installer and tar-package for Linux are available in \n[SourceForge](https://sourceforge.net/projects/kactus2/)\n\nGuidelines for issue reporting and contributing are given in the wiki page [Contributing to Kactus2](https://github.com/kactus2/kactus2dev/wiki/Contributing-to-Kactus2).  \n\nOther support is provided by email: kactus2@tuni.fi\n\n### What you can do with Kactus2\nPackage IPs for reuse and exchange\n * Import your existing IPs as IP-XACT components\n * Create new IP-XACT components and generate their HDL module headers\n * Reuse IP-XACT files from any standard compatible vendor\n * Reuse the IPs in your designs and connect them with wires and busses\n\nCreate HW designs with hierarchy\n * Create multilevel hierarchies, where a design has multiple sub-designs\n * Configure component instances in designs, including the sub-designs\n * Use generator plugins to create HDL with wiring and parameterization\n\nIntegrate HW and SW\n * Use memory designer to preview memory maps and address spaces in your hierarchy\n * Package software to IP-XACT components and map them to hardware\n * Generate makefiles that build executables with rules defined in IP-XACT components\n \n### What you cannot do with Kactus2\n * Behavioral logic: Neither Kactus2 nor IP-XACT handles module implementations\n * Synthesis or simulation: These require tools that are specificly created for the purpose\n \n### Examples and tutorials\nExample IPs are available in GitHub [here](https://github.com/kactus2/ipxactexamplelib).\n\nVideo tutorials are available in [Youtube](https://www.youtube.com/user/Kactus2Tutorial).\n\n## Windows install\nAn installer (SourceForge link above) will guide you through the installation on Windows platforms.\n\nIf you want to build Kactus2 on Windows, see separate instructions in our project \n[wiki](https://github.com/kactus2/kactus2dev/wiki/Building-Kactus2-from-source#building-on-windows).\n\n## Linux install\n\nOn Linux systems Kactus2 must be built from source. Instructions can be found in the \n[wiki](https://github.com/kactus2/kactus2dev/wiki/Building-Kactus2-from-source#linux-build-install-and-run).\n\n## Settings and configurations\n\nKactus2 uses a settings file for storing user-specific tool settings. The file default location\nis **~/.config/TUT/Kactus2.ini** in Linux and **C:\\Users\\\\\\<username>\\AppData\\Roaming\\TUT\\Kactus2.ini**\nin Windows. The location can be checked on the general settings page in Kactus2.\n\nA system wide default settings file is located in /etc/xdg and C:\\ProgramData, respectively.\nThis will be used as a base for any new user-specific settings and a fallback mechanism, if\nthe user's file is missing a requested value.\n\nModifying the settings files manually is not recommended and should be done only by advanced \nusers. Most of the time all required changes can be applied in the Kactus2 GUI.\n\nIn addition, Kactus2 uses the file **configure.cfg**for updating the users' settings when\nnew setting options are introduced in the tool. Please do not modify this file as it will\nbreak the compatibility with earlier versions.\n\n## Contributors\nAntti Kamppi, Joni-Matti Määttä, Lauri Matilainen, Timo D. Hämäläinen,\nMikko Teuho, Juho Järvinen, Esko Pekkarinen, Janne Virtanen,\nAnton Hagqvist, Vasilii Feshchenko\n\nKactus2 uses [Icons8](https://icons8.com/) provided by Icons8 LLC.\n\n## Licensing\nThis software is licensed under the [GPL2 General Public License](LICENSE).\n\nKactus2 is also available for dual licensing. Please contact kactus2@tuni.fi\nto purchase a commercial license.\n\nKactus2 is dynamically linked using Qt 6.2.4 open source libraries (LGPL),\ncopyright The Qt Company.\n\nKactus2 uses the Python language and interpreter for automating design tasks.  \nPython is a registered trademark of the Python Software Foundation. See also the\n[PSF license](PSF_LICENSE.txt).\n"
  },
  {
    "path": "RunDeploy.bat",
    "content": "REM\nREM Run windeployqt on release build\nREM\n@echo off\n\ncall CreateHelp.bat\n\necho Running windeployqt\nwindeployqt executable/Kactus2.exe --no-translations\nwindeployqt executable/IPXACTmodels.dll --no-translations"
  },
  {
    "path": "common/GenericEditProvider.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: GenericEditProvider.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Joni-Matti Maatta\r\n// Date: 28.7.2011\r\n//\r\n// Description:\r\n// Generic edit provider implemented with stacks.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"GenericEditProvider.h\"\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: GenericEditProvider()\r\n//-----------------------------------------------------------------------------\r\nGenericEditProvider::GenericEditProvider(int historySize)\r\n    : historySize_(historySize),\r\n      undoStack_(),\r\n      redoStack_(),\r\n      undoing_(false),\r\n      redoing_(false)\r\n{\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ~GenericEditProvider()\r\n//-----------------------------------------------------------------------------\r\nGenericEditProvider::~GenericEditProvider()\r\n{\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: addAction()\r\n//-----------------------------------------------------------------------------\r\nvoid GenericEditProvider::addCommand(QSharedPointer<QUndoCommand> command)\r\n{\r\n    Q_ASSERT(undoStack_.size() <= historySize_);\r\n\r\n    if (!undoing_ || !redoing_)\r\n    {\r\n        // Erase the redo stack.\r\n        redoStack_.clear();\r\n\r\n        // Add the action to the undo stack.\r\n        undoStack_.append(command);\r\n\r\n        // Check if the undo stack is too large and in that chase, remove the oldest undo command.\r\n        if (undoStack_.size() > historySize_)\r\n        {\r\n            undoStack_.removeFirst();\r\n        }\r\n\r\n        // Inform others.\r\n        emit editStateChanged();\r\n        emit modified();\r\n    }\r\n\r\n    Q_ASSERT(undoStack_.size() <= historySize_);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: undo()\r\n//-----------------------------------------------------------------------------\r\nvoid GenericEditProvider::undo()\r\n{\r\n    // Check if we cannot undo.\r\n    if (!canUndo())\r\n    {\r\n        return;\r\n    }\r\n\r\n    undoing_ = true;\r\n\r\n    // Pop and undo the topmost command in the undo stack.\r\n    QSharedPointer<QUndoCommand> command = undoStack_.last();\r\n    undoStack_.removeLast();\r\n\r\n    command->undo();\r\n\r\n    // Push the command to the redo stack.\r\n    redoStack_.push(command);\r\n\r\n    undoing_ = false;\r\n    emit editStateChanged();\r\n    emit modified();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: redo()\r\n//-----------------------------------------------------------------------------\r\nvoid GenericEditProvider::redo()\r\n{\r\n    // Check if we cannot redo.\r\n    if (!canRedo())\r\n    {\r\n        return;\r\n    }\r\n\r\n    redoing_ = true;\r\n\r\n    // Pop and redo the topmost command in the redo stack.\r\n    QSharedPointer<QUndoCommand> command = redoStack_.pop();\r\n    command->redo();\r\n\r\n    // Push the command to the undo stack.\r\n    undoStack_.append(command);\r\n\r\n    redoing_ = false;\r\n    emit editStateChanged();\r\n    emit modified();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: canUndo()\r\n//-----------------------------------------------------------------------------\r\nbool GenericEditProvider::canUndo() const\r\n{\r\n    return !undoStack_.empty();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: canUndo()\r\n//-----------------------------------------------------------------------------\r\nbool GenericEditProvider::canRedo() const\r\n{\r\n    return !redoStack_.empty();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: isPerformingUndoRedo()\r\n//-----------------------------------------------------------------------------\r\nbool GenericEditProvider::isPerformingUndoRedo() const\r\n{\r\n    return (undoing_ || redoing_);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: clear()\r\n//-----------------------------------------------------------------------------\r\nvoid GenericEditProvider::clear()\r\n{\r\n    undoStack_.clear();\r\n    redoStack_.clear();\r\n    emit editStateChanged();\r\n}\r\n"
  },
  {
    "path": "common/GenericEditProvider.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: GenericEditProvider.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Joni-Matti Maatta\r\n// Date: 28.7.2011\r\n//\r\n// Description:\r\n// Generic edit provider implemented with stacks.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef GENERICEDITPROVIDER_H\r\n#define GENERICEDITPROVIDER_H\r\n\r\n#include \"IEditProvider.h\"\r\n\r\n#include <QStack>\r\n#include <QList>\r\n#include <QSharedPointer>\r\n#include <QUndoCommand>\r\n#include <QVariant>\r\n#include <QMap>\r\n\r\n//-----------------------------------------------------------------------------\r\n//! GenericEditProvider class.\r\n//-----------------------------------------------------------------------------\r\nclass GenericEditProvider : public IEditProvider\r\n{\r\n    Q_OBJECT\r\n\r\npublic:\r\n    /*!\r\n     *  Constructor.\r\n     *\r\n     *    @param [in] historySize The maximum number of undo commands kept in the history.\r\n     */\r\n    GenericEditProvider(int historySize);\r\n\r\n    /*!\r\n     *  Destructor.\r\n     */\r\n    virtual ~GenericEditProvider();\r\n\r\n    /*!\r\n     *  Stores a new command to the edit stack.\r\n     *\r\n     *    @param [in] command   The command to add.\r\n     */\r\n    void addCommand(QSharedPointer<QUndoCommand> command);\r\n\r\n    /*!\r\n     *  Clears the undo & redo stacks.\r\n     */\r\n    void clear();\r\n\r\n    /*!\r\n     *  Performs an undo.\r\n     */\r\n    virtual void undo();\r\n\r\n    /*!\r\n     *  Performs a redo.\r\n     */\r\n    virtual void redo();\r\n\r\n    /*!\r\n     *  Returns true if undo is possible.\r\n     */\r\n    virtual bool canUndo() const;\r\n\r\n    /*!\r\n     *  Returns true if redo is possible.\r\n     */\r\n    virtual bool canRedo() const;\r\n\r\n    /*!\r\n     *  Returns true if the an undo/redo is currently being performed.\r\n     */\r\n    bool isPerformingUndoRedo() const;\r\n    \r\nsignals:\r\n    //! Emitted when the stack is modified.\r\n    void modified();\r\n\r\nprivate:\r\n    // Disable copying.\r\n    GenericEditProvider(GenericEditProvider const& rhs);\r\n    GenericEditProvider& operator=(GenericEditProvider const& rhs);\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! The history size.\r\n    int historySize_;\r\n\r\n    //! Undo stack.\r\n    QList< QSharedPointer<QUndoCommand> > undoStack_;\r\n\r\n    //! Redo stack.\r\n    QStack< QSharedPointer<QUndoCommand> > redoStack_;\r\n\r\n    //! Boolean flag for undoing.\r\n    bool undoing_;\r\n\r\n    //! Boolean flag for redoing.\r\n    bool redoing_;\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n\r\n#endif // GENERICEDITPROVIDER_H\r\n"
  },
  {
    "path": "common/IEditProvider.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: IEditProvider.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Joni-Matti Maatta\r\n// Date: 28.7.2011\r\n//\r\n// Description:\r\n// IEditProvider interface for providing editing capabilities (undo & redo).\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef IEDITPROVIDER_H\r\n#define IEDITPROVIDER_H\r\n\r\n#include <QObject>\r\n#include <QSharedPointer>\r\n#include <QUndoCommand>\r\n\r\n//-----------------------------------------------------------------------------\r\n//! IEditProvider interface.\r\n//-----------------------------------------------------------------------------\r\nclass IEditProvider : public QObject\r\n{\r\n    Q_OBJECT\r\n\r\npublic:\r\n    /*!\r\n     *  Destructor.\r\n     */\r\n    virtual ~IEditProvider() {}\r\n\r\n    /*!\r\n     *  Stores a new command to the edit stack.\r\n     *\r\n     *    @param [in] command   The command to add.\r\n     */\r\n    virtual void addCommand(QSharedPointer<QUndoCommand> command) = 0;\r\n\r\n    /*!\r\n     *  Clears the undo & redo stacks.\r\n     */\r\n    virtual void clear() = 0;\r\n\r\n    /*!\r\n     *  Performs an undo.\r\n     */\r\n    virtual void undo() = 0;\r\n\r\n    /*!\r\n     *  Performs a redo.\r\n     */\r\n    virtual void redo() = 0;\r\n\r\n    /*!\r\n     *  Returns true if undo is possible.\r\n     */\r\n    virtual bool canUndo() const = 0;\r\n\r\n    /*!\r\n     *  Returns true if redo is possible.\r\n     */\r\n    virtual bool canRedo() const = 0;\r\n\r\nsignals:\r\n    //! Signaled when the state of the provider has changed.\r\n    void editStateChanged();\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n\r\n#endif // IEDITPROVIDER_H\r\n"
  },
  {
    "path": "common/KactusColors.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: KactusColors.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Joni-Matti Maatta\r\n// Date: 6.6.2012\r\n//\r\n// Description:\r\n// Common colors used in Kactus2.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef KACTUSCOLORS_H\r\n#define KACTUSCOLORS_H\r\n\r\n#include <QColor>\r\n\r\nnamespace KactusColors\r\n{\r\n    //! Icon and visual design base colors.\r\n    QColor const KACTUS_BLUE(0x1b, 0x65, 0xaf);\r\n    QColor const KACTUS_GREEN(0x32,0xbc, 0x8f);\r\n\r\n    //! Errors.\r\n    QColor const ERROR = Qt::red;\r\n\r\n    //! Warnings.\r\n    QColor const WARNING = QColor(255, 102, 45);\r\n\r\n    //! Colors used in text.\r\n    QColor const REGULAR_TEXT = Qt::black; // Regular text.\r\n    QColor const DISABLED_TEXT = Qt::darkGray; // Text in disabled or uneditable elements.\r\n    QColor const REGULAR_MESSAGE = Qt::blue; // Regular console messages.\r\n\r\n    //! Colors used as field backgrounds.\r\n    QColor const REGULAR_FIELD = Qt::white; // Backgrounds and regular fields.\r\n    QColor const MANDATORY_FIELD = QColor(QStringLiteral(\"LemonChiffon\")); // Must be filled.\r\n    QColor const DISABLED_FIELD = QColor(QStringLiteral(\"whiteSmoke\")); // Has no relevance in current context.\r\n    QColor const INVALID_FIELD = QColor(255, 192, 192); // The value is not valid.\r\n    QColor const STRONG_FIELD = QColor(QStringLiteral(\"gainsboro\")); // Has more weight than others.\r\n    QColor const LOGICAL_PORT_FIELD = QColor(QStringLiteral(\"aliceblue\")); // Relates to logical ports.\r\n\r\n    //! Colors for languages and generated texts.\r\n    QColor const TEXT_BODY_HIGHLIGHT = QColor::fromRgb(183,225,252); // Background for text bodies such as logic.\r\n    QColor const FUNCTION_HIGHLIGHT = QColor(QStringLiteral(\"darkviolet\")); // Functions().\r\n    QColor const PREPROCESSOR_HIGHLIGHT = QColor(QStringLiteral(\"chocolate\")); // Preprocessor #macros.\r\n    QColor const STRING_HIGHLIGHT = QColor(Qt::gray); // \"Character strings.\"\r\n\r\n    //! Colors used in design diagram interconnections.\r\n    QColor const REGULAR_CONNECTION = Qt::black; // Most connections.\r\n    QColor const BROKEN_CONNECTION = ERROR; // Broken/invalid connections.\r\n    QColor const COM_CONNECTION = QColor(49, 132, 61); // COM connections.\r\n    QColor const CONNECTION_UNDERCROSSING = QColor(160, 160, 160);  // Used for crossing interconnections.\r\n    QColor const UNKNOWN_CONNECTION = QColor(180, 180, 180); // Connections unfitting to other categories.\r\n\r\n    //! Colors corresponding each available interface mode.\r\n    QColor const MASTER_INTERFACE(0x32,0xcb,0xcb); \r\n    QColor const SLAVE_INTERFACE(0x32,0x99,0x64);\r\n    QColor const MIRROREDMASTER_INTERFACE(0xcb,0xfd,0xfd);\r\n    QColor const MIRROREDSLAVE_INTERFACE(0x00,0xfd,00);\r\n    QColor const SYSTEM_INTERFACE(165,74,170);\r\n    QColor const MIRROREDSYSTEM_INTERFACE(201,189,233);\r\n    QColor const MONITOR_INTERFACE(0xfd,0xfd,0xfd);\r\n    QColor const INVALID_INTERFACE = ERROR; // The interface is somehow invalid, eg. lacks a mode or type.\r\n    QColor const ENDPOINT_TYPE_API = QColor(0xcb,0xfd,0xfd); // The interface is for API connections.\r\n\r\n    //! Colors used in component instances.\r\n    QColor const MISSING_COMPONENT = QColor(240, 180, 180); // The component of the instance does not exist.\r\n    QColor const DRAFT_COMPONENT = QColor(217, 217, 217); // The instance is a draft for a new component.\r\n    QColor const HW_BUS_COMPONENT = QColor(0xce,0xdf,0xff); // The component of the instance is a bus or a bridge.\r\n    QColor const HW_COMPONENT = QColor(0xa5,0xc3,0xef); // The component of the instance is hardware component.\r\n    QColor const SW_COMPONENT = QColor(0xc5,0xff, 0xab); // The component of the instance is software component.\r\n\r\n    //! Other colors used in design.\r\n    QColor const DIAGRAM_SELECTION = Qt::blue; // Selections in design diagrams.\r\n    QColor const DIAGRAM_ALLOWED_INTERFACE = Qt::magenta; // Highlights allowed interface for a connection.\r\n    QColor const DIAGRAM_COLUMN_HEADER = QColor(160, 193, 226); // Background color for column headers.\r\n    QColor const STICKY_NOTE_BACKGROUND = QColor(QStringLiteral(\"lemonChiffon\")); // Sticky note background\r\n\r\n    //! Colors used for memory/address sections in the memory designer.\r\n    QColor const MEMORY_BLOCK = QColor(0xd6, 0xba, 0xff);\r\n    QColor const ADDRESS_SEGMENT = QColor(0xc6,0xef,0xd7);\r\n    QColor const ADDRESS_SEGMENT_UNSEGMENTED = QColor(217, 217, 217);\r\n\r\n    QColor const MEM_MAP_COLOR =  HW_COMPONENT;\r\n    QColor const ADDR_BLOCK_COLOR = QColor(194, 214, 244);\r\n    QColor const REGISTER_FILE_COLOR = QColor(203, 219, 244);\r\n    QColor const REGISTER_COLOR = QColor(216, 229, 248);\r\n    QColor const FIELD_COLOR = QColor(235, 241, 251);\r\n\r\n    //! Colors used in dependency analysis.\r\n    QColor const DEPENDECY_ADDED = QColor(0, 222, 0); // Added dependency.\r\n    QColor const DEPENDECY_COVERAGE = QColor(0, 158, 255); // Used to illustrate the extent of dependencies.\r\n    QColor const ROW_SEPARATOR = QColor(200, 200, 200); // Used to separate rows on a list.\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n\r\n#endif // KACTUSCOLORS_H\r\n"
  },
  {
    "path": "common/NameGenerationPolicy.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: NameGenerationPolicy.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Janne Virtanen\n// Date: 22.10.2015\n//\n// Description:\n// Used to generate names with predictable patterns.\n//-----------------------------------------------------------------------------\n\n#include \"NameGenerationPolicy.h\"\n\n\n\t// File set containing design configuration specific files = name + suffix.\n\tconst QString SYSVIEW_FILESET_SUFFIX = \"_general_files\";\n\t// File set containing instance specific files = name + suffix.\n\tconst QString INSTANCE_FILESET_SUFFIX = \"_headers\";\n\t\t\n\t//-----------------------------------------------------------------------------\n\t// Function: NameGenerationPolicy::systemViewFilesetName()\n\t//-----------------------------------------------------------------------------\n\tQString NameGenerationPolicy::systemViewFilesetName(QString const& systemViewName)\n\t{\n\t\treturn systemViewName + SYSVIEW_FILESET_SUFFIX;\n\t}\n\t\t\n\t//-----------------------------------------------------------------------------\n\t// Function: NameGenerationPolicy::instanceFilesetName()\n\t//-----------------------------------------------------------------------------\n\tQString NameGenerationPolicy::instanceFilesetName(QString const& systemViewName, QString const& instanceName)\n\t{\n\t\treturn systemViewName + \"_\" + instanceName + INSTANCE_FILESET_SUFFIX;\n\t}\n\n\t//-----------------------------------------------------------------------------\n\t// Function: NameGenerationPolicy::flatViewName()\n\t//-----------------------------------------------------------------------------\n\tQString NameGenerationPolicy::flatViewName(QString const& qualifierName)\n\t{\n        if (qualifierName.isEmpty())\n        {\n\t\t    return \"flat\";\n        }\n\n        return \"flat_\" + qualifierName;\n    }\n\n    //-----------------------------------------------------------------------------\n    // Function: NameGenerationPolicy::flatViewName()\n    //-----------------------------------------------------------------------------\n    QString NameGenerationPolicy::hierarchicalViewName(QString const& qualifierName)\n    {\n        if (qualifierName.isEmpty())\n        {\n            return \"hierarchical\";\n        }\n\n        return \"hierarchical_\" + qualifierName;\n    }\n\n\t//-----------------------------------------------------------------------------\n\t// Function: NameGenerationPolicy::componentInstantiationName()\n\t//-----------------------------------------------------------------------------\n\tQString NameGenerationPolicy::componentInstantiationName(QString const& qualifierName)\n    {\n        if (qualifierName.isEmpty())\n        {\n            return \"implementation\";\n        }\n\n\t\treturn qualifierName + \"_implementation\";\n\t}\n\n\t//-----------------------------------------------------------------------------\n\t// Function: NameGenerationPolicy::designInstanceName()\n\t//-----------------------------------------------------------------------------\n\tQString NameGenerationPolicy::designInstantiationName(QString const& qualifierName)\n\t{\n\t\treturn qualifierName + \"_design\";\n\t}\n\n\t//-----------------------------------------------------------------------------\n\t// Function: NameGenerationPolicy::designConfigurationInstanceName()\n\t//-----------------------------------------------------------------------------\n\tQString NameGenerationPolicy::designConfigurationInstantiationName(QString const& qualifierName)\n\t{\n\t\treturn qualifierName + \"_design_configuration\";\n\t}\n\n"
  },
  {
    "path": "common/NameGenerationPolicy.h",
    "content": "//-----------------------------------------------------------------------------\n// File: NameGenerationPolicy.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Janne Virtanen\n// Date: 22.10.2015\n//\n// Description:\n// Used to generate names for new elements.\n//-----------------------------------------------------------------------------\n\n#ifndef NAMEGENERATIION_POLICY_H\n#define NAMEGENERATIION_POLICY_H\n\n#include <QString>\n\nnamespace NameGenerationPolicy\n{\n    /*!\n     *  Returns name of a system view file set, based on the name of it.\n     *\n     *    @param [in] systemViewName  Name of the system view.\n\t *\n\t *    @return The resolved name for the file set.\n\t */\n\tQString systemViewFilesetName(QString const& systemViewName);\n\t\n    /*!\n     *  Returns name of a instance file set, based on the name of it. and its system view.\n     *\n     *    @param [in] systemViewName  Name of the system view.\n\t *    @param [in] instanceName   \tName of the component instance.\n\t *\n\t *    @return The resolved name for the file set.\n\t */\n\tQString instanceFilesetName(QString const& systemViewName, QString const& instanceName);\n\t\n    /*!\n     *  Returns name of a flat view, based on a qualifier.\n     *  If the qualifier is empty, returns a name without language.\n     *\n     *    @param [in] qualifierName       The qualifier that separates the view from others.\n\t */\n\tQString flatViewName(QString const& qualifierName = QString(\"\"));\n\t\n    /*!\n     *  Returns name of a hierarchical view, on a qualifier.\n     *  If the qualifier is empty, returns a name without language.\n     *\n     *    @param [in] qualifierName       The qualifier that separates the view from others.\n\t */\n\tQString hierarchicalViewName(QString const& qualifierName = QString(\"\"));\n\t\n    /*!\n     *  Returns name of a component instantiation, based on a qualifier.\n     *  If the qualifier is empty, returns a name without language.\n     *\n     *    @param [in] qualifierName       The qualifier that separates the instantiation from others.\n\t */\n\tQString componentInstantiationName(QString const& qualifierName = QString(\"\"));\n\t\n    /*!\n     *  Returns name of a design instantiation, based on a qualifier.\n     *\n     *    @param [in] qualifierName       The qualifier that separates the instantiation from others.\n\t */\n\tQString designInstantiationName(QString const& qualifierName);\n\t\n    /*!\n     *  Returns name of a design configuration instantiation, based on a qualifier.\n     *\n     *    @param [in] qualifierName       The qualifier that separates the instantiation from others.\n\t */\n\tQString designConfigurationInstantiationName(QString const& qualifierName);\n};\n\n#endif"
  },
  {
    "path": "common/TextEditProvider.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: TextEditProvider.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Joni-Matti Maatta\r\n// Date: 28.7.2011\r\n//\r\n// Description:\r\n// Specialized edit provider for QPlainTextEdit.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"TextEditProvider.h\"\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: TextEditProvider()\r\n//-----------------------------------------------------------------------------\r\nTextEditProvider::TextEditProvider(QPlainTextEdit& textEdit) :textEdit_(textEdit)\r\n{\r\n    connect(&textEdit_, SIGNAL(redoAvailable(bool)), this, SIGNAL(editStateChanged()));\r\n    connect(&textEdit_, SIGNAL(undoAvailable(bool)), this, SIGNAL(editStateChanged()));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: TextEditProvider::addCommand()\r\n//-----------------------------------------------------------------------------\r\nvoid TextEditProvider::addCommand(QSharedPointer<QUndoCommand> /*command*/)\r\n{\r\n    \r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: TextEditProvider::clear()\r\n//-----------------------------------------------------------------------------\r\nvoid TextEditProvider::clear()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: undo()\r\n//-----------------------------------------------------------------------------\r\nvoid TextEditProvider::undo()\r\n{\r\n    textEdit_.undo();\r\n    textEdit_.setFocus();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: redo()\r\n//-----------------------------------------------------------------------------\r\nvoid TextEditProvider::redo()\r\n{\r\n    textEdit_.redo();\r\n    textEdit_.setFocus();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: canUndo()\r\n//-----------------------------------------------------------------------------\r\nbool TextEditProvider::canUndo() const\r\n{\r\n    return textEdit_.document()->isUndoAvailable();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: canRedo()\r\n//-----------------------------------------------------------------------------\r\nbool TextEditProvider::canRedo() const\r\n{\r\n    return textEdit_.document()->isRedoAvailable();\r\n}\r\n"
  },
  {
    "path": "common/TextEditProvider.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: TextEditProvider.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Joni-Matti Maatta\r\n// Date: 28.7.2011\r\n//\r\n// Description:\r\n// Specialized edit provider for QPlainTextEdit.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef TEXTEDITPROVIDER_H\r\n#define TEXTEDITPROVIDER_H\r\n\r\n#include \"IEditProvider.h\"\r\n\r\n#include <QPlainTextEdit>\r\n\r\n//-----------------------------------------------------------------------------\r\n//! TextEditProvider class.\r\n//-----------------------------------------------------------------------------\r\nclass TextEditProvider : public IEditProvider\r\n{\r\npublic:\r\n    /*!\r\n     *  Constructor.\r\n     *\r\n     *    @param [in] textEdit The text editor to which the provider applies.\r\n     */\r\n    explicit TextEditProvider(QPlainTextEdit& textEdit);\r\n\r\n    /*!\r\n     *  Destructor.\r\n     */\r\n    virtual ~TextEditProvider() = default;\r\n\r\n    // Disable copying.\r\n    TextEditProvider(TextEditProvider const& rhs) = delete;\r\n    TextEditProvider& operator=(TextEditProvider const& rhs) = delete;\r\n\r\n    /*!\r\n     *  Stores a new command to the edit stack.\r\n     *\r\n     *    @param [in] command   The command to add.\r\n     */   \r\n    virtual void addCommand(QSharedPointer<QUndoCommand> command) override final;\r\n\r\n    /*!\r\n     *  Clears the undo & redo stacks.\r\n     */\r\n    virtual void clear() override final;\r\n\r\n    /*!\r\n     *  Performs an undo.\r\n     */\r\n    virtual void undo() override final;\r\n\r\n    /*!\r\n     *  Performs a redo.\r\n     */\r\n    virtual void redo() override final;\r\n\r\n    /*!\r\n     *  Returns true if undo is possible.\r\n     */\r\n    virtual bool canUndo() const override final;\r\n\r\n    /*!\r\n     *  Returns true if redo is possible.\r\n     */\r\n    virtual bool canRedo() const override final;\r\n\r\nprivate:\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! The text edit.\r\n    QPlainTextEdit& textEdit_;    \r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n\r\n#endif // TEXTEDITPROVIDER_H\r\n"
  },
  {
    "path": "common/delegates/ComboDelegate/combodelegate.cpp",
    "content": "/* \r\n *  \tCreated on: 9.12.2011\r\n *      Author: Antti Kamppi\r\n * \t\tfilename: combodelegate.cpp\r\n *\t\tProject: Kactus 2\r\n */\r\n\r\n#include \"combodelegate.h\"\r\n\r\n#include <QComboBox>\r\n\r\nComboDelegate::ComboDelegate(QObject *parent):\r\nQStyledItemDelegate(parent) {\r\n}\r\n\r\nComboDelegate::~ComboDelegate() {\r\n}\r\n\r\nQWidget* ComboDelegate::createEditor( QWidget* parent,\r\n\t\t\t\t\t\t\t\t\t const QStyleOptionViewItem&,\r\n\t\t\t\t\t\t\t\t\t const QModelIndex&) const {\r\n\r\n\tQComboBox* combo = new QComboBox(parent);\r\n\t\r\n\tcombo->setMinimumHeight(ComboDelegate::MINIMUM_EDITOR_HEIGHT);\r\n\treturn combo;\r\n}\r\n\r\nvoid ComboDelegate::setEditorData( QWidget* editor, \r\n\t\t\t\t\t\t\t\t  const QModelIndex& index ) const {\r\n\r\n\tQString text = index.model()->data(index, Qt::DisplayRole).toString();\r\n\r\n\tQComboBox* combo = qobject_cast<QComboBox*>(editor);\r\n\tQ_ASSERT(combo);\r\n\r\n\tint rowNumber = combo->findText(text);\r\n\t\r\n\t// if the current text was not found\r\n\tif (rowNumber < 0) {\r\n\t\tcombo->setEditText(text);\r\n\t}\r\n\t// if text was found then select it\r\n\telse {\r\n\t\tcombo->setCurrentIndex(rowNumber);\r\n\t}\r\n}\r\n\r\nvoid ComboDelegate::setModelData( QWidget* editor, \r\n\t\t\t\t\t\t\t\t QAbstractItemModel* model, \r\n\t\t\t\t\t\t\t\t const QModelIndex& index ) const {\r\n\r\n\tQComboBox* combo = qobject_cast<QComboBox*>(editor);\r\n\tQ_ASSERT(combo);\r\n\tQString text = combo->currentText();\r\n\tmodel->setData(index, text, Qt::EditRole);\r\n}\r\n"
  },
  {
    "path": "common/delegates/ComboDelegate/combodelegate.h",
    "content": "/* \r\n *  \tCreated on: 9.12.2011\r\n *      Author: Antti Kamppi\r\n * \t\tfilename: combodelegate.h\r\n *\t\tProject: Kactus 2\r\n */\r\n\r\n#ifndef COMBODELEGATE_H\r\n#define COMBODELEGATE_H\r\n\r\n#include <QStyledItemDelegate>\r\n\r\n/*! \\brief ComboDelegate is a base class to provide combo editors for widgets.\r\n * \r\n * This can be sub classed to provide more specific combo widgets.\r\n * In subclasses the createEditor() function can be reimplemented to set the \r\n * selectable items in the combo box.\r\n */\r\nclass ComboDelegate : public QStyledItemDelegate {\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\r\n\t//! \\brief The minimum height set for the editor.\r\n\tstatic const int MINIMUM_EDITOR_HEIGHT = 20;\r\n\r\n\t/*! \\brief The constructor\r\n\t *\r\n\t * \\param parent Pointer to the owner of this delegate.\r\n\t *\r\n\t*/\r\n\tComboDelegate(QObject *parent);\r\n\t\r\n\t//! \\brief The destructor\r\n\tvirtual ~ComboDelegate();\r\n\r\n\t/*! \\brief Create a new editor for the given item\r\n\t *\r\n\t * \\param parent Owner for the editor.\r\n\t * \\param option Contains options for the editor.\r\n\t * \\param index Model index identifying the item.\r\n\t *\r\n\t * \\return Pointer to the editor to be used to edit the item.\r\n\t*/\r\n\tvirtual QWidget* createEditor(QWidget* parent, \r\n\t\tconst QStyleOptionViewItem& option, \r\n\t\tconst QModelIndex& index) const;\r\n\r\n\t/*! \\brief Set the data for the editor.\r\n\t *\r\n\t * \\param editor Pointer to the editor where the data is to be set.\r\n\t * \\param index Model index identifying the item that's data is to be set.\r\n\t *\r\n\t*/\r\n\tvirtual void setEditorData(QWidget* editor, const QModelIndex& index) const;\r\n\r\n\t/*! \\brief Save the data from the editor to the model.\r\n\t *\r\n\t * \\param editor Pointer to the editor that contains the data to store.\r\n\t * \\param model Model that contains the data structure where data is to be saved to.\r\n\t * \\param index Model index identifying the item that's data is to be saved.\r\n\t *\r\n\t*/\r\n\tvirtual void setModelData(QWidget* editor, QAbstractItemModel* model, \r\n\t\tconst QModelIndex& index) const;\r\n\r\nprivate:\r\n\t//! \\brief No copying\r\n\tComboDelegate(const ComboDelegate& other);\r\n\r\n\t//! \\brief No assignment\r\n\tComboDelegate& operator=(const ComboDelegate& other);\r\n};\r\n\r\n#endif // COMBODELEGATE_H\r\n"
  },
  {
    "path": "common/delegates/LineEditDelegate/lineeditdelegate.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: lineeditdelegate.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Antti Kamppi\r\n// Date: 9.12.2011\r\n//\r\n// Description:\r\n// The base class to provide QLineEditor for a widget.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"lineeditdelegate.h\"\r\n\r\n#include <QLineEdit>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LineEditDelegate::LineEditDelegate()\r\n//-----------------------------------------------------------------------------\r\nLineEditDelegate::LineEditDelegate(QObject *parent):\r\nQStyledItemDelegate(parent)\r\n{\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LineEditDelegate::~LineEditDelegate()\r\n//-----------------------------------------------------------------------------\r\nLineEditDelegate::~LineEditDelegate()\r\n{\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LineEditDelegate::createEditor()\r\n//-----------------------------------------------------------------------------\r\nQWidget* LineEditDelegate::createEditor(QWidget* parent, QStyleOptionViewItem const&, QModelIndex const&) const\r\n{\r\n\tQLineEdit* editor = new QLineEdit(parent);\r\n\tconnect(editor, SIGNAL(editingFinished()), this, SLOT(commitAndCloseEditor()), Qt::UniqueConnection);\r\n\teditor->setMinimumHeight(LineEditDelegate::MINIMUM_EDITOR_HEIGHT);\r\n\treturn editor;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LineEditDelegate::setEditorData()\r\n//-----------------------------------------------------------------------------\r\nvoid LineEditDelegate::setEditorData(QWidget* editor, QModelIndex const& index ) const {\r\n\r\n\tQLineEdit* edit = qobject_cast<QLineEdit*>(editor);\r\n\tQ_ASSERT(edit);\r\n\r\n\tconst QString text = index.data(Qt::DisplayRole).toString();\r\n\tedit->setText(text);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LineEditDelegate::setModelData()\r\n//-----------------------------------------------------------------------------\r\nvoid LineEditDelegate::setModelData(QWidget* editor, QAbstractItemModel* model, QModelIndex const& index ) const\r\n{\r\n\tQLineEdit* edit = qobject_cast<QLineEdit*>(editor);\r\n\tQ_ASSERT(edit);\r\n\r\n\tQString text = edit->text();\r\n\tmodel->setData(index, text, Qt::EditRole);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LineEditDelegate::commitAndCloseEditor()\r\n//-----------------------------------------------------------------------------\r\nvoid LineEditDelegate::commitAndCloseEditor()\r\n{\r\n\tQLineEdit* edit = qobject_cast<QLineEdit*>(sender());\r\n\tQ_ASSERT(edit);\r\n\r\n\temit commitData(edit);\r\n\temit closeEditor(edit);\r\n}\r\n"
  },
  {
    "path": "common/delegates/LineEditDelegate/lineeditdelegate.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: lineeditdelegate.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Antti Kamppi\r\n// Date: 9.12.2011\r\n//\r\n// Description:\r\n// The base class to provide QLineEditor for a widget.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef LINEEDITDELEGATE_H\r\n#define LINEEDITDELEGATE_H\r\n\r\n#include <QStyledItemDelegate>\r\n\r\n/*! The base class to provide QLineEditor for a widget.\r\n * \r\n * LineEditDelegate can be sub classed to provide more specific editors.\r\n * In subclasses the createEditor() can be reimplemented to create more specific\r\n * line editors.\r\n */ \r\nclass LineEditDelegate : public QStyledItemDelegate\r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\r\n\t//! \\brief The minimum height for the editors provided.\r\n\tstatic const int MINIMUM_EDITOR_HEIGHT = 20;\r\n\r\n\t/*! \\brief The constructor\r\n\t *\r\n\t * \\param parent Pointer to the owner of this delegate.\r\n\t *\r\n\t*/\r\n\tLineEditDelegate(QObject *parent);\r\n\t\r\n\t//! \\brief The destructor\r\n\tvirtual ~LineEditDelegate();\r\n\r\n\t/*! \\brief Create a new editor for the given item\r\n\t *\r\n\t * \\param parent Owner for the editor.\r\n\t * \\param option Contains options for the editor.\r\n\t * \\param index Model index identifying the item.\r\n\t *\r\n\t * \\return Pointer to the editor to be used to edit the item.\r\n\t*/\r\n\tvirtual QWidget* createEditor(QWidget* parent, QStyleOptionViewItem const& option, \r\n        QModelIndex const& index) const;\r\n\r\n\t/*! \\brief Set the data for the editor.\r\n\t *\r\n\t * \\param editor Pointer to the editor where the data is to be set.\r\n\t * \\param index Model index identifying the item that's data is to be set.\r\n\t *\r\n\t*/\r\n\tvirtual void setEditorData(QWidget* editor, QModelIndex const& index) const;\r\n\r\n\t/*! \\brief Save the data from the editor to the model.\r\n\t *\r\n\t * \\param editor Pointer to the editor that contains the data to store.\r\n\t * \\param model Model that contains the data structure where data is to be saved to.\r\n\t * \\param index Model index identifying the item that's data is to be saved.\r\n\t *\r\n\t*/\r\n\tvirtual void setModelData(QWidget* editor, QAbstractItemModel* model, QModelIndex const& index) const;\r\n\r\nprivate slots:\r\n\r\n\t/*! \\brief Commit the data from the sending editor and close the editor.\r\n\t *\r\n\t*/\r\n\tvoid commitAndCloseEditor();\r\n\r\nprivate:\r\n\t//! \\brief No copying\r\n\tLineEditDelegate(const LineEditDelegate& other);\r\n\r\n\t//! \\brief No assignment\r\n\tLineEditDelegate& operator=(const LineEditDelegate& other);\r\n};\r\n\r\n#endif // LINEEDITDELEGATE_H\r\n"
  },
  {
    "path": "common/dialogs/LibrarySettingsDialog/LibrarySettingsColumns.h",
    "content": "//-----------------------------------------------------------------------------\n// File: LibrarySettingsColumns.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 15.11.2017\n//\n// Description:\n// Columns for library settings.\n//-----------------------------------------------------------------------------\n\nnamespace LibrarySettingsColumns\n{\n    //! Columns for library paths.\n    enum PathColumns\n    {\n        DEFAULT= 0,\n        ACTIVE,\n        PATH\n    };\n}\n"
  },
  {
    "path": "common/dialogs/LibrarySettingsDialog/LibrarySettingsDialog.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: LibrarySettingsDialog.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Joni-Matti Maatta\r\n// Date: 17.08.2012\r\n//\r\n// Description:\r\n// Dialog for configuring library locations.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"LibrarySettingsDialog.h\"\r\n#include \"librarysettingsdelegate.h\"\r\n\r\n#include <common/dialogs/LibrarySettingsDialog/LibrarySettingsColumns.h>\r\n\r\n#include <QCheckBox>\r\n#include <QDialogButtonBox>\r\n#include <QFileDialog>\r\n#include <QFileInfo>\r\n#include <QGroupBox>\r\n#include <QHBoxLayout>\r\n#include <QHeaderView>\r\n#include <QIcon>\r\n#include <QLabel>\r\n#include <QStringList>\r\n#include <QVBoxLayout>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LibrarySettingsDialog::LibrarySettingsDialog()\r\n//-----------------------------------------------------------------------------\r\nLibrarySettingsDialog::LibrarySettingsDialog(QSettings& settings, QWidget* parent):\r\nQDialog(parent),\r\nsettings_(settings),\r\niconProvider_(),\r\nlibLocationsTable_(0),\r\naddLocationButton_(new QPushButton(QIcon(\":/icons/common/graphics/add.png\"), QString(), this)),\r\nremoveLocationButton_(new QPushButton(QIcon(\":/icons/common/graphics/remove.png\"), QString(), this)),\r\nchanged_(false),\r\ncheckMarkIcon_(\":/icons/common/graphics/checkMark.png\")\r\n{\r\n    setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);\r\n    setWindowTitle(tr(\"Configure Library\"));\r\n\r\n    // Create the library location group box.\r\n    QGroupBox* locationGroup = new QGroupBox(tr(\"Library locations\"), this);\r\n\r\n    libLocationsTable_ = new QTableWidget(0, 3, locationGroup);\r\n\r\n    // the headers for the table\r\n    QStringList headers;\r\n    headers.append(tr(\"Default\"));\r\n    headers.append(tr(\"Active\"));\r\n    headers.append(tr(\"Library path\"));\r\n    libLocationsTable_->setHorizontalHeaderLabels(headers);\r\n\r\n    // Cells are resized to match contents.\r\n    libLocationsTable_->horizontalHeader()->setSectionResizeMode(QHeaderView::Interactive);\r\n    libLocationsTable_->horizontalHeader()->setStretchLastSection(true);\r\n    libLocationsTable_->setAlternatingRowColors(true);\r\n    libLocationsTable_->verticalHeader()->hide();\r\n\r\n    // Set the height of a row to be smaller than default.\r\n    libLocationsTable_->verticalHeader()->setDefaultSectionSize(fontMetrics().height() + 8);\r\n\r\n    libLocationsTable_->setMinimumWidth(500);\r\n    libLocationsTable_->setColumnWidth(LibrarySettingsColumns::DEFAULT, 50);\r\n    libLocationsTable_->setColumnWidth(LibrarySettingsColumns::ACTIVE, 50);\r\n\r\n    libLocationsTable_->setItemDelegate(new LibrarySettingsDelegate(this));\r\n\r\n    removeLocationButton_->setEnabled(false);\r\n\r\n    QWidget* introWidget = new QWidget(this);\r\n    QHBoxLayout* introLayout = new QHBoxLayout(introWidget);\r\n    introLayout->addWidget(new QLabel(tr(\"<b>Set library locations on disk</b><br>\"\r\n        \"Active directories and their sub-directories will be searched for IP-XACT files and \"\r\n        \"read into the library.\"), this));\r\n\r\n    QPalette introPalette = introWidget->palette();\r\n    introPalette.setColor(QPalette::Window, Qt::white);\r\n    introWidget->setPalette(introPalette);\r\n    introWidget->setAutoFillBackground(true);\r\n\r\n    QDialogButtonBox* listButtonBox = new QDialogButtonBox(Qt::Vertical);\r\n    listButtonBox->addButton(addLocationButton_, QDialogButtonBox::ActionRole);\r\n    listButtonBox->addButton(removeLocationButton_, QDialogButtonBox::ActionRole);\r\n\r\n    QHBoxLayout* locationLayout = new QHBoxLayout(locationGroup);\r\n    locationLayout->addWidget(libLocationsTable_);\r\n    locationLayout->addWidget(listButtonBox);\r\n\r\n    QGroupBox* separator = new QGroupBox(this);\r\n    separator->setFlat(true);\r\n\r\n    QDialogButtonBox* buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel,\r\n                                                       Qt::Horizontal, this);\r\n    // Setup the layout.\r\n    QVBoxLayout* topLayout = new QVBoxLayout(this);\r\n    topLayout->addWidget(introWidget);\r\n    topLayout->addWidget(locationGroup, 1);\r\n    topLayout->addWidget(separator);\r\n    topLayout->addWidget(buttonBox);\r\n\r\n    resize(700, sizeHint().height() + 50);\r\n\r\n    connect(libLocationsTable_, SIGNAL(itemClicked(QTableWidgetItem*)),\r\n        this, SLOT(onItemClicked(QTableWidgetItem*)), Qt::UniqueConnection);\r\n    connect(libLocationsTable_, SIGNAL(currentItemChanged(QTableWidgetItem*, QTableWidgetItem*)),\r\n        this, SLOT(onSelectLocation(QTableWidgetItem*, QTableWidgetItem*)), Qt::UniqueConnection);\r\n    connect(addLocationButton_, SIGNAL(clicked()), this, SLOT(addLocation()));\r\n    connect(removeLocationButton_, SIGNAL(clicked()), this, SLOT(removeLocation()));\r\n    connect(buttonBox->button(QDialogButtonBox::Ok), SIGNAL(clicked()), \r\n        this, SLOT(accept()), Qt::UniqueConnection);\r\n    connect(buttonBox->button(QDialogButtonBox::Cancel), SIGNAL(clicked()), \r\n        this, SLOT(reject()), Qt::UniqueConnection);\r\n\r\n    loadSettings();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LibrarySettingsDialog::~LibrarySettingsDialog()\r\n//-----------------------------------------------------------------------------\r\nLibrarySettingsDialog::~LibrarySettingsDialog()\r\n{\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LibrarySettingsDialog::validate()\r\n//-----------------------------------------------------------------------------\r\nbool LibrarySettingsDialog::validate()\r\n{\r\n    return true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LibrarySettingsDialog::apply()\r\n//-----------------------------------------------------------------------------\r\nvoid LibrarySettingsDialog::apply()\r\n{\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LibrarySettingsDialog::addLocation()\r\n//-----------------------------------------------------------------------------\r\nvoid LibrarySettingsDialog::addLocation()\r\n{\r\n    QString directory = QFileDialog::getExistingDirectory(this, tr(\"Select library location:\"));\r\n\r\n    if (!directory.isEmpty())\r\n    {\r\n        bool isDefault = libLocationsTable_->rowCount() == 0;\r\n        createRowForDirectory(directory, true, isDefault);\r\n        changed_ = true;\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LibrarySettingsDialog::removeLocation()\r\n//-----------------------------------------------------------------------------\r\nvoid LibrarySettingsDialog::removeLocation()\r\n{\r\n    if (int row = libLocationsTable_->currentRow(); row >= 0)\r\n    {\r\n        QTableWidgetItem* defItem = libLocationsTable_->takeItem(row, LibrarySettingsColumns::DEFAULT);\r\n        delete defItem;\r\n\r\n        QTableWidgetItem* activeItem = libLocationsTable_->takeItem(row, LibrarySettingsColumns::ACTIVE);\r\n        delete activeItem;\r\n\r\n        QTableWidgetItem* pathItem = libLocationsTable_->takeItem(row, LibrarySettingsColumns::PATH);\r\n        delete pathItem;\r\n\r\n        libLocationsTable_->removeRow(row);\r\n    }\r\n\r\n    changed_ = true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LibrarySettingsDialog::onSelectLocation()\r\n//-----------------------------------------------------------------------------\r\nvoid LibrarySettingsDialog::onSelectLocation(QTableWidgetItem* cur, QTableWidgetItem*)\r\n{\r\n    removeLocationButton_->setEnabled(cur != nullptr);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LibrarySettingsDialog::onItemClicked()\r\n//-----------------------------------------------------------------------------\r\nvoid LibrarySettingsDialog::onItemClicked(QTableWidgetItem* item)\r\n{\r\n    if (item->column() == LibrarySettingsColumns::DEFAULT || item->column() == LibrarySettingsColumns::ACTIVE)\r\n    {\r\n        changed_ = true;\r\n        if (item->column() == LibrarySettingsColumns::DEFAULT)\r\n        {\r\n            changeDefaultPath(item);\r\n        }\r\n        else if (item->column() == LibrarySettingsColumns::ACTIVE)\r\n        {\r\n            changeActivePathStatus(item);\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LibrarySettingsDialog::changeDefaultPath()\r\n//-----------------------------------------------------------------------------\r\nvoid LibrarySettingsDialog::changeDefaultPath(QTableWidgetItem* item)\r\n{\r\n    if (!item->icon().isNull())\r\n    {\r\n        return;\r\n    }\r\n\r\n    item->setIcon(checkMarkIcon_);\r\n    for (int index = 0; index < libLocationsTable_->rowCount(); ++index)\r\n    {\r\n        QTableWidgetItem* tableItem = libLocationsTable_->item(index, LibrarySettingsColumns::DEFAULT);\r\n        if (tableItem != item)\r\n        {\r\n            if (!tableItem->icon().isNull())\r\n            {\r\n                tableItem->setIcon(QIcon());\r\n            }\r\n        }\r\n        else\r\n        {\r\n            QTableWidgetItem* activeTableItem = libLocationsTable_->item(index, LibrarySettingsColumns::ACTIVE);\r\n            if (activeTableItem && activeTableItem->icon().isNull())\r\n            {\r\n                activeTableItem->setIcon(checkMarkIcon_);\r\n            }\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LibrarySettingsDialog::changeActivePathStatus()\r\n//-----------------------------------------------------------------------------\r\nvoid LibrarySettingsDialog::changeActivePathStatus(QTableWidgetItem* item)\r\n{\r\n    if (!item->icon().isNull())\r\n    {\r\n        QTableWidgetItem* defaultItem = libLocationsTable_->item(item->row(), LibrarySettingsColumns::DEFAULT);\r\n        if (defaultItem && defaultItem->icon().isNull())\r\n        {\r\n            item->setIcon(QIcon());\r\n        }\r\n    }\r\n    else\r\n    {\r\n        item->setIcon(checkMarkIcon_);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LibrarySettingsDialog::accept()\r\n//-----------------------------------------------------------------------------\r\nvoid LibrarySettingsDialog::accept()\r\n{\r\n    // Create a string list containing all the locations and save it to the settings.\r\n    QStringList locations;\r\n\r\n    // the active locations used to search for IP-XACT objects\r\n    QStringList activeLocations;\r\n\r\n    // the checked item in the list is the default location\r\n    QString defaultLocation;\r\n\r\n    for (int i = 0; i < libLocationsTable_->rowCount(); ++i)\r\n    {\r\n        QTableWidgetItem* defItem = libLocationsTable_->item(i, LibrarySettingsColumns::DEFAULT);\r\n        QTableWidgetItem* activeItem = libLocationsTable_->item(i, LibrarySettingsColumns::ACTIVE);\r\n        QTableWidgetItem* pathItem = libLocationsTable_->item(i, LibrarySettingsColumns::PATH);\r\n        \r\n        // if the row contains the default library\r\n        if (!defItem->icon().isNull())\r\n        {\r\n            defaultLocation = pathItem->text();\r\n        }\r\n        if (!activeItem->icon().isNull())\r\n        {\r\n            activeLocations.append(pathItem->text());\r\n        }\r\n\r\n        // add the library path to the known library locations\r\n        locations.append(pathItem->text());\r\n    }\r\n\r\n    settings_.setValue(\"Library/Locations\", locations);\r\n    settings_.setValue(\"Library/DefaultLocation\", defaultLocation);\r\n    settings_.setValue(\"Library/ActiveLocations\", activeLocations);\r\n\r\n    if (changed_)\r\n    {\r\n        emit scanLibrary();\r\n    }\r\n\r\n    QDialog::accept();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LibrarySettingsDialog::loadSettings()\r\n//-----------------------------------------------------------------------------\r\nvoid LibrarySettingsDialog::loadSettings()\r\n{\r\n    // Load the library locations.\r\n    QString defaultLocation = settings_.value(QStringLiteral(\"Library/DefaultLocation\")).toString();\r\n    QStringList activeLocations = settings_.value(QStringLiteral(\"Library/ActiveLocations\")).toStringList();\r\n    QStringList locations = settings_.value(QStringLiteral(\"Library/Locations\")).toStringList();\r\n\r\n    for (QString const& location : locations)\r\n    {\r\n        QString fullLocation = location;\r\n\r\n        if (QFileInfo(location).isRelative())\r\n        {\r\n            fullLocation = QFileInfo(location).absoluteFilePath();\r\n        }\r\n\r\n        bool isDefaultLocation = location.compare(defaultLocation) == 0;\r\n        createRowForDirectory(fullLocation, activeLocations.contains(location), isDefaultLocation);\r\n    }\r\n\r\n    libLocationsTable_->setCurrentIndex(QModelIndex());\r\n\r\n    changed_ = false;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LibrarySettingsDialog::createRowForDirectory()\r\n//-----------------------------------------------------------------------------\r\nvoid LibrarySettingsDialog::createRowForDirectory(QString const& directory, bool isActive, bool isDefault)\r\n{\r\n    int rowNumber = libLocationsTable_->rowCount();\r\n\r\n    libLocationsTable_->insertRow(rowNumber);\r\n\r\n    // Create the item for default column.\r\n    QTableWidgetItem* defaultItem = new QTableWidgetItem();\r\n    defaultItem->setFlags(Qt::ItemIsEnabled);\r\n\r\n    if (isDefault)\r\n    {        \r\n        defaultItem->setIcon(checkMarkIcon_);\r\n    }\r\n\r\n    libLocationsTable_->setItem(rowNumber, LibrarySettingsColumns::DEFAULT, defaultItem);\r\n\r\n    // create the item for the active column\r\n    QTableWidgetItem* activeItem = new QTableWidgetItem();\r\n    activeItem->setFlags(Qt::ItemIsEnabled);\r\n\r\n    if (isActive)\r\n    {\r\n        activeItem->setIcon(checkMarkIcon_);\r\n    }\r\n\r\n    libLocationsTable_->setItem(rowNumber, LibrarySettingsColumns::ACTIVE, activeItem);\r\n\r\n    QTableWidgetItem* pathItem = new QTableWidgetItem(directory);\r\n    pathItem->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);\r\n\r\n    if (QFileInfo directoryInfo(directory); directoryInfo.exists())\r\n    {\r\n         pathItem->setIcon(iconProvider_.icon(directoryInfo));\r\n    }\r\n    else\r\n    {\r\n        pathItem->setIcon(QIcon(QStringLiteral(\":/icons/common/graphics/exclamation--frame.png\")));\r\n    }\r\n\r\n    libLocationsTable_->setItem(rowNumber, LibrarySettingsColumns::PATH, pathItem);\r\n}\r\n"
  },
  {
    "path": "common/dialogs/LibrarySettingsDialog/LibrarySettingsDialog.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: LibrarySettingsDialog.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Joni-Matti Maatta\r\n// Date: 17.08.2012\r\n//\r\n// Description:\r\n// Dialog for configuring library locations.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef LIBRARYSETTINGSDIALOG_H\r\n#define LIBRARYSETTINGSDIALOG_H\r\n\r\n#include <QDialog>\r\n#include <QFileIconProvider>\r\n#include <QPushButton>\r\n#include <QSettings>\r\n#include <QTableWidget>\r\n#include <QTableWidgetItem>\r\n#include <QIcon>\r\n\r\n//-----------------------------------------------------------------------------\r\n//! The dialog to display library locations and select active and default library paths.\r\n//-----------------------------------------------------------------------------\r\nclass LibrarySettingsDialog : public QDialog\r\n{\r\n    Q_OBJECT\r\n\r\npublic:\r\n\r\n    /*!\r\n     *  Constructor.\r\n     *\r\n     *    @param [in/out] settings  The settings store.\r\n     *    @param [in]     parent    The parent widget.\r\n     */\r\n    LibrarySettingsDialog(QSettings& settings, QWidget* parent = 0);\r\n\r\n    /*!\r\n     *  Destructor.\r\n     */\r\n    ~LibrarySettingsDialog();\r\n\r\n    /*!\r\n     *  Validates the contents of the page thoroughly.\r\n     *\r\n     *    @return True, if the contents are valid. False, if they are invalid.\r\n     */\r\n    bool validate();\r\n\r\n    /*!\r\n     *  Applies the changes that were done in the page.\r\n     */\r\n    void apply();\r\n\r\npublic slots:\r\n\r\n    /*!\r\n     *  Adds a new directory to the library locations.\r\n     */\r\n    void addLocation();\r\n\r\n    /*!\r\n     *  Removes the currently selected library location.\r\n     */\r\n    void removeLocation();\r\n\r\n\t/*!\r\n     *  Called when a location is selected in the locations list.\r\n\t *\r\n\t *    @param [in] cur     Pointer to the selected item.\r\n\t *    @param [in] prev    Pointer to the previously selected item.\r\n     */\r\n\tvoid onSelectLocation(QTableWidgetItem* cur, QTableWidgetItem* prev);\r\n\r\nsignals:\r\n\t\r\n    /*!\r\n     *  Emitted when the library settings has changed and a scan should be performed.\r\n     */\r\n\tvoid scanLibrary();\r\n\r\nprivate slots:\r\n\r\n\t/*!\r\n     *  Handler for item clicks on the lib locations list.\r\n\t *\r\n\t *    @param [in] item    Pointer to the clicked item.\r\n     */\r\n\tvoid onItemClicked(QTableWidgetItem* item);\r\n\r\n    /*!\r\n     *  Called when the user presses OK.\r\n     */\r\n    virtual void accept();\r\n\r\nprivate:\r\n\r\n    // Disable copying.\r\n    LibrarySettingsDialog(LibrarySettingsDialog const& rhs);\r\n    LibrarySettingsDialog& operator=(LibrarySettingsDialog const& rhs);\r\n\r\n    /*!\r\n     *  Loads the settings from the settings store.\r\n     */\r\n    void loadSettings();\r\n\r\n    /*!\r\n     *  Creates a row in the library path table for the given directory.\r\n     *\r\n     *    @param [in] directory   The directory to add as library path.\r\n     *    @param [in] isActive    Is the directory is set active or not.\r\n     *    @param [in] isDefault   Is the directory is set default or not.\r\n     */\r\n    void createRowForDirectory(QString const& directory, bool isActive, bool isDefault);\r\n\r\n    /*!\r\n     *  Change the default path for the library.\r\n     *\r\n     *    @param [in] item    Table item for the new default path.\r\n     */\r\n    void changeDefaultPath(QTableWidgetItem* item);\r\n\r\n    /*!\r\n     *  Change the active status of the selected library path.\r\n     *\r\n     *    @param [in] item    The selected table item.\r\n     */\r\n    void changeActivePathStatus(QTableWidgetItem* item);\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n     //! The settings store.\r\n\t QSettings& settings_;\r\n\r\n     //! Icon provider for directory folders.\r\n     QFileIconProvider iconProvider_;\r\n\r\n\t //! Library locations table\r\n\t QTableWidget* libLocationsTable_;\r\n\r\n\t //! Add location button.\r\n\t QPushButton* addLocationButton_;\r\n\r\n\t //! Remove location button.\r\n\t QPushButton* removeLocationButton_;\r\n\r\n\t //! OK button.\r\n\t QPushButton* okButton_;\r\n\r\n\t //! Holds the info on if the user has changed the library or not.\r\n\t bool changed_;\r\n\r\n     //! Check icon for the active and default library paths.\r\n     QIcon checkMarkIcon_;\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n\r\n#endif // LIBRARYSETTINGSDIALOG_H\r\n"
  },
  {
    "path": "common/dialogs/LibrarySettingsDialog/librarysettingsdelegate.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: LibrarySettingsDelegate.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Antti Kamppi\r\n// Date: 07.02.2013\r\n//\r\n// Description:\r\n// This delegate is used to draw the check marks in the middle of default and active library columns.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"librarysettingsdelegate.h\"\r\n\r\n#include <common/dialogs/LibrarySettingsDialog/LibrarySettingsColumns.h>\r\n\r\n#include <QPainter>\r\n#include <QApplication>\r\n#include <QMouseEvent>\r\n#include <QEvent>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LibrarySettingsDelegate::LibrarySettingsDelegate()\r\n//-----------------------------------------------------------------------------\r\nLibrarySettingsDelegate::LibrarySettingsDelegate(QObject *parent): QStyledItemDelegate(parent)\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LibrarySettingsDelegate::~LibrarySettingsDelegate()\r\n//-----------------------------------------------------------------------------\r\nLibrarySettingsDelegate::~LibrarySettingsDelegate()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LibrarySettingsDelegate::paint()\r\n//-----------------------------------------------------------------------------\r\nvoid LibrarySettingsDelegate::paint(QPainter* painter, QStyleOptionViewItem const& option,\r\n    QModelIndex const& index) const\r\n{\r\n\tQStyleOptionViewItem viewItemOption(option);\r\n\r\n    if (index.column() == LibrarySettingsColumns::DEFAULT ||index.column() == LibrarySettingsColumns::ACTIVE)\r\n\t{\r\n        viewItemOption.decorationAlignment = Qt::AlignHCenter | Qt::AlignCenter;\r\n        viewItemOption.decorationPosition = QStyleOptionViewItem::Top;\r\n\t}\r\n\r\n\tQStyledItemDelegate::paint(painter, viewItemOption, index);\r\n}\r\n"
  },
  {
    "path": "common/dialogs/LibrarySettingsDialog/librarysettingsdelegate.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: LibrarySettingsDelegate.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Antti Kamppi\r\n// Date: 07.02.2013\r\n//\r\n// Description:\r\n// This delegate is used to draw the check marks in the middle of default and active library columns.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef LIBRARYSETTINGSDELEGATE_H\r\n#define LIBRARYSETTINGSDELEGATE_H\r\n\r\n#include <QStyledItemDelegate>\r\n\r\n//-----------------------------------------------------------------------------\r\n//! This delegate is used to draw the check marks in the middle of default and active library columns.\r\n//-----------------------------------------------------------------------------\r\nclass LibrarySettingsDelegate : public QStyledItemDelegate\r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\r\n\t/*!\r\n     *  The constructor. \r\n\t * \r\n\t *    @param [in] parent  Pointer to the owner of the delegate.\r\n     */\r\n\tLibrarySettingsDelegate(QObject *parent);\r\n\t\r\n\t/*!\r\n     *  The destructor.\r\n     */\r\n\tvirtual ~LibrarySettingsDelegate();\r\n\r\n\t/*!\r\n\t *  Paint the check marks in the middle of the active and default columns.\r\n\t *\r\n\t *    @param [in] painter     The selected painter.\r\n\t *    @param [in] option      Options of the painter.\r\n\t *    @param [in] index       Current table index.\r\n\t */\r\n\tvirtual void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const;\r\n\r\nprivate:\r\n\r\n\t//! No copying\r\n\tLibrarySettingsDelegate(const LibrarySettingsDelegate& other);\r\n\r\n\t//! No assignment\r\n\tLibrarySettingsDelegate& operator=(const LibrarySettingsDelegate& other);\r\n};\r\n\r\n#endif // LIBRARYSETTINGSDELEGATE_H\r\n"
  },
  {
    "path": "common/dialogs/NewBusDialog/NewBusDialog.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: NewBusDialog.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Esko Pekkarinen\r\n// Date: 25.11.2013\r\n//\r\n// Description:\r\n// Dialog for new bus VLNV selection and bus abstraction generation settings.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"NewBusDialog.h\"\r\n\r\n#include <common/dialogs/newObjectDialog/newobjectdialog.h>\r\n\r\n#include <IPXACTmodels/AbstractionDefinition/AbstractionDefinition.h>\r\n#include <IPXACTmodels/BusDefinition/BusDefinition.h>\r\n\r\n#include <IPXACTmodels/Component/FileSet.h>\r\n#include <IPXACTmodels/Component/Component.h>\r\n\r\n#include <KactusAPI/include/LibraryInterface.h>\r\n\r\n#include <editors/BusDefinitionEditor/busdefgroup.h>\r\n\r\n#include <QVBoxLayout>\r\n#include <QGroupBox>\r\n#include <QLabel>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: NewBusDialog::NewBusDialog()\r\n//-----------------------------------------------------------------------------\r\nNewBusDialog::NewBusDialog(LibraryInterface* handler, QWidget* parent) :\r\nNewObjectDialog(handler, VLNV::BUSDEFINITION , false, parent),\r\nnameSelection_(tr(\"Name\"), this),\r\ndescriptionSelection_(tr(\"Description\"), this)\r\n{         \r\n    setWindowTitle(tr(\"New bus interface\"));  \r\n\r\n    setupLayout();\r\n    setFixedHeight(sizeHint().height());\r\n    resize(400, sizeHint().height());\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: NewBusDialog::~NewBusDialog()\r\n//-----------------------------------------------------------------------------\r\nNewBusDialog::~NewBusDialog()\r\n{\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: NewBusDialog::getSignalSelection()\r\n//-----------------------------------------------------------------------------\r\nNewBusDialog::Signal_selection NewBusDialog::getSignalSelection() const\r\n{\r\n    if (nameSelection_.isChecked())\r\n    {\r\n        return USE_NAME;\r\n    }\r\n    else\r\n    {\r\n        return USE_DESCRIPTION;\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: NewBusDialog::~NewBusDialog()\r\n//-----------------------------------------------------------------------------\r\nvoid NewBusDialog::setupLayout()\r\n{\r\n    QGroupBox* signalButtonGroup = new QGroupBox(tr(\"Select source for logical signal generation\"), this);\r\n    QVBoxLayout* buttonLayout = new QVBoxLayout(signalButtonGroup);\r\n    buttonLayout->addWidget(&nameSelection_);\r\n    buttonLayout->addWidget(&descriptionSelection_);\r\n    nameSelection_.setChecked(true);\r\n\r\n    QVBoxLayout* topLayout = dynamic_cast<QVBoxLayout*>(layout());\r\n    if (topLayout)\r\n    {\r\n        topLayout->insertWidget(0, signalButtonGroup);    \r\n    }\r\n    else\r\n    {\r\n        layout()->addWidget(signalButtonGroup);\r\n    }\r\n}\r\n"
  },
  {
    "path": "common/dialogs/NewBusDialog/NewBusDialog.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: NewBusDialog.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Esko Pekkarinen\r\n// Date: 25.11.2013\r\n//\r\n// Description:\r\n// Dialog for new bus VLNV selection and bus abstraction generation settings.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef NewBusDialog_H\r\n#define NewBusDialog_H\r\n\r\n#include <QDialog>\r\n#include <QRadioButton>\r\n\r\n#include <common/dialogs/newObjectDialog/newobjectdialog.h>\r\n#include <editors/BusDefinitionEditor/BusDefinitionEditor.h>\r\n#include <IPXACTmodels/Component/BusInterface.h>\r\n\r\nclass LibraryInterface;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Dialog for selecting new bus VLNV and bus signal name source selection.\r\n//-----------------------------------------------------------------------------\r\nclass NewBusDialog : public NewObjectDialog\r\n{\r\npublic:\r\n\r\n    enum Signal_selection\r\n    {\r\n        USE_NAME = 0,\r\n        USE_DESCRIPTION\r\n    };\r\n\r\n    /*!\r\n    *  Constructor.\r\n    *\r\n    *    @param [in] lh     The library interface.\r\n    *    @param [in] parent The parent wizard.\r\n    */\r\n    NewBusDialog(LibraryInterface* lh, QWidget* parent);\r\n\r\n    /*!\r\n    *  Destructor.\r\n    */\r\n    ~NewBusDialog();\r\n  \r\n    /*!\r\n     *  Gets the selected source for logical signal name genertaion.\r\n     *\r\n     *    @return The selected source that is either name or description.\r\n     */\r\n    Signal_selection getSignalSelection() const;\r\n\r\n\r\nprivate:\r\n    // Disable copying.\r\n    NewBusDialog(NewBusDialog const& rhs);\r\n    NewBusDialog& operator=(NewBusDialog const& rhs);\r\n\r\n    //! Sets the dialog layout.\r\n    void setupLayout();\r\n   \r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! Button for name selection.\r\n    QRadioButton nameSelection_;\r\n\r\n    //! Button for description selection.\r\n    QRadioButton descriptionSelection_;\r\n\r\n};\r\n\r\n#endif // NewBusDialog_H\r\n"
  },
  {
    "path": "common/dialogs/NewDesignDialog/NewDesignDialog.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: NewDesignDialog.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Joni-Matti Maatta\r\n// Date: 2.8.2012\r\n//\r\n// Description:\r\n// Dialog used in creation of new designs to existing components.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"NewDesignDialog.h\"\r\n\r\n#include <QCoreApplication>\r\n#include <QDialog>\r\n#include <QDialogButtonBox>\r\n#include <QFormLayout>\r\n#include <QLabel>\r\n#include <QLineEdit>\r\n#include <QPushButton>\r\n#include <QMessageBox>\r\n#include <QVBoxLayout>\r\n\r\n#include <IPXACTmodels/Component/Component.h>\r\n\r\n#include <KactusAPI/include/LibraryInterface.h>\r\n\r\n#include <common/widgets/LibrarySelectorWidget/LibrarySelectorWidget.h>\r\n#include <common/widgets/LineEditEx/LineEditEx.h>\r\n#include <common/NameGenerationPolicy.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: NewDesignDialog::NewDesignDialog()\r\n//-----------------------------------------------------------------------------\r\nNewDesignDialog::NewDesignDialog(LibraryInterface* libInterface, QSharedPointer<Component> component,\r\n    KactusAttribute::Implementation designType, QWidget *parent):\r\nQDialog(parent), \r\n      library_(libInterface),\r\n      component_(component),\r\n      introLabel_(new QLabel(this)),\r\n      qualifierLabel_(new QLabel(tr(\"Qualifier:\"), this)),\r\n      qualifierEdit_(new LineEditEx(this)),\r\n      viewNameLabel_(new QLabel(tr(\"View name:\"), this)),\r\n      viewNameMatcher_(),\r\n      viewNameEdit_(new LineEditEx(this)),\r\n      designIcon_(new QLabel(this)),\r\n      vlnvEditor_(new VLNVEditor(VLNV::DESIGN, libInterface, this, this)),\r\n      directoryEditor_(new LibrarySelectorWidget(this)), \r\n      okButton_(new QPushButton(tr(\"&OK\"))),\r\n      designExt_(),\r\n      designConfExt_()\r\n{\r\n    setWindowFlags(windowFlags() &= ~Qt::WindowContextHelpButtonHint);\r\n\r\n    setStyleSheet(QString(\"*[mandatoryField=\\\"true\\\"] { background-color: LemonChiffon; }\"));\r\n\r\n    introLabel_->setWordWrap(true);\r\n    introLabel_->setText(tr(\"<b>Create a new design for the component.</b><br>\"\r\n        \"A new view will be added for the design in the component. An optional qualifier can be \"\r\n        \"used for differentiating the designs and views e.g. structural_rtl vs. structural_tlm. \"\r\n        \"The given VLNV will be used for identifying the new design within the library.\"));\r\n\r\n    if (designType == KactusAttribute::HW)\r\n    {\r\n        setWindowTitle(\"New HW Design\");\r\n        viewNameLabel_->setText(tr(\"View name:\"));\r\n        viewNameEdit_->setDisallowedInputs(component->getViewNames());\r\n        viewNameEdit_->setMessageTemplate(\"View name '%1' already exists!\");\r\n        vlnvEditor_->setTitle(\"VLNV for new HW design and design configuration\");\r\n        designExt_ = \".design\";\r\n        designConfExt_ = \".designcfg\";\r\n        designIcon_->setPixmap(QPixmap(\":/icons/common/graphics/hw-design.png\"));\r\n    }\r\n    else if (designType == KactusAttribute::SW)\r\n    {\r\n        setWindowTitle(tr(\"New SW Design\"));\r\n        viewNameLabel_->setText(tr(\"View name:\"));\r\n        viewNameEdit_->setDisallowedInputs(component->getViewNames());\r\n        viewNameEdit_->setMessageTemplate(\"View name '%1' already exists!\");\r\n        vlnvEditor_->setTitle(\"VLNV for new SW design and design configuration\");\r\n        designExt_ = \".swdesign\";\r\n        designConfExt_ = \".swdesigncfg\";\r\n        designIcon_->setPixmap(QPixmap(\":/icons/common/graphics/sw-design48x48.png\"));\r\n    }\r\n    else if (designType == KactusAttribute::SYSTEM)\r\n    {\r\n        setWindowTitle(tr(\"New System Design\"));\r\n        viewNameLabel_->setText(tr(\"System view name:\"));\r\n        viewNameEdit_->setDisallowedInputs(component->getSystemViewNames());\r\n        viewNameEdit_->setMessageTemplate(\"System view name '%1' already exists!\");\r\n        vlnvEditor_->setTitle(\"VLNV for new system design and design configuration\");\r\n        designExt_ = \".sysdesign\";\r\n        designConfExt_ = \".sysdesigncfg\";\r\n        designIcon_->setPixmap(QPixmap(\":/icons/common/graphics/sw-design48x48.png\"));\r\n    }\r\n    else\r\n    {\r\n        Q_ASSERT(false);\r\n    }\r\n\r\n    qualifierEdit_->setPlaceholderText(tr(\"optional category for the view and configuration\"));\r\n\r\n    viewNameEdit_->setMessageIcon(QPixmap(\":/icons/common/graphics/exclamation.png\"));\r\n    viewNameEdit_->setContentMatcher(&viewNameMatcher_);\r\n    viewNameEdit_->setProperty(\"mandatoryField\", true);\r\n\r\n    vlnvEditor_->addNameExtension(designExt_);\r\n    vlnvEditor_->addNameExtension(designConfExt_);\r\n    vlnvEditor_->addContentType(VLNV::DESIGNCONFIGURATION);\r\n    vlnvEditor_->setMandatory(true);\r\n\r\n    okButton_->setDefault(true);\r\n    okButton_->setEnabled(false);\r\n\r\n    connect(qualifierEdit_, SIGNAL(textChanged(QString const&)), this, SLOT(updateViewName()));\r\n    connect(qualifierEdit_, SIGNAL(textChanged(QString const&)), this, SLOT(updateVlnvName()));\r\n    connect(qualifierEdit_, SIGNAL(textChanged(QString const&)), this, SLOT(onContentChanged()));\r\n\r\n    connect(viewNameEdit_, SIGNAL(textChanged(QString const&)), this, SLOT(onContentChanged()));\r\n\r\n    connect(vlnvEditor_, SIGNAL(contentChanged()), this, SLOT(onContentChanged()));\r\n    connect(vlnvEditor_, SIGNAL(contentChanged()), this, SLOT(updateDirectory()));\r\n\r\n    connect(directoryEditor_, SIGNAL(contentChanged()), this, SLOT(onContentChanged()));\r\n\r\n    setupLayout();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: NewDesignDialog::setViewName()\r\n//-----------------------------------------------------------------------------\r\nvoid NewDesignDialog::setViewName(QString const& viewName)\r\n{\r\n    viewNameEdit_->setText(viewName);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: NewDesignDialog::getQualifierName()\r\n//-----------------------------------------------------------------------------\r\nQString NewDesignDialog::getQualifierName() const\r\n{\r\n    return qualifierEdit_->text();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: NewDesignDialog::getViewName()\r\n//-----------------------------------------------------------------------------\r\nQString NewDesignDialog::getViewName() const\r\n{\r\n    return viewNameEdit_->text();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: NewDesignDialog::getDesignVLNV()\r\n//-----------------------------------------------------------------------------\r\nVLNV NewDesignDialog::getDesignVLNV() const\r\n{\r\n    VLNV vlnv = vlnvEditor_->getVLNV();\r\n    vlnv.setType(VLNV::DESIGN);\r\n    vlnv.setName(vlnv.getName().remove(\".comp\") + designExt_);\r\n    return vlnv;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: NewDesignDialog::getDesignConfVLNV()\r\n//-----------------------------------------------------------------------------\r\nVLNV NewDesignDialog::getDesignConfVLNV() const\r\n{\r\n    VLNV vlnv = vlnvEditor_->getVLNV();\r\n    vlnv.setType(VLNV::DESIGNCONFIGURATION);\r\n\r\n    QString name = vlnv.getName().remove(\".comp\");\r\n    if (!qualifierEdit_->text().isEmpty())\r\n    {\r\n        name.append(\".\"  + qualifierEdit_->text());\r\n    }\r\n    name.append(designConfExt_);\r\n\r\n    vlnv.setName(name);\r\n    return vlnv;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: NewDesignDialog::getPath()\r\n//-----------------------------------------------------------------------------\r\nQString NewDesignDialog::getPath() const\r\n{\r\n    return directoryEditor_->getPath();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: NewDesignDialog::onContentChanged()\r\n//-----------------------------------------------------------------------------\r\nvoid NewDesignDialog::onContentChanged()\r\n{\r\n    okButton_->setEnabled(!viewNameEdit_->text().isEmpty() &&\r\n        viewNameEdit_->isInputValid() && directoryEditor_->isValid() && vlnvEditor_->isValid());\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: NewDesignDialog::accept()\r\n//-----------------------------------------------------------------------------\r\nvoid NewDesignDialog::accept()\r\n{\r\n    if (library_->contains(getDesignVLNV()))\r\n    {\r\n        QMessageBox::warning(this, QCoreApplication::applicationName(),\r\n            tr(\"VLNV %1 already exists in the library.\").arg(getDesignVLNV().toString()));\r\n\r\n        return;\r\n    }\r\n\r\n    if (library_->contains(getDesignConfVLNV()))\r\n    {\r\n        QMessageBox::warning(this, QCoreApplication::applicationName(),\r\n            tr(\"VLNV %1 already exists in the library.\").arg(getDesignConfVLNV().toString()));\r\n\r\n        return;\r\n    }\r\n\r\n    QDialog::accept();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: NewDesignDialog::setVLNV()\r\n//-----------------------------------------------------------------------------\r\nvoid NewDesignDialog::setVLNV( const VLNV& vlnv )\r\n{\r\n\tvlnvEditor_->setVLNV(vlnv);\r\n    updateDirectory();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: NewDesignDialog::updateDirectory()\r\n//-----------------------------------------------------------------------------\r\nvoid NewDesignDialog::updateDirectory()\r\n{\r\n    QString vlnvDir;\r\n\r\n    VLNV vlnv = vlnvEditor_->getVLNV();\r\n\r\n    if (!vlnv.getVendor().isEmpty())\r\n    {\r\n        vlnvDir += \"/\" + vlnv.getVendor();\r\n\r\n        if (!vlnv.getLibrary().isEmpty())\r\n        {\r\n            vlnvDir += \"/\" + vlnv.getLibrary();\r\n\r\n            if (!vlnv.getName().isEmpty())\r\n            {\r\n                vlnvDir += \"/\" + vlnv.getName();\r\n\r\n                if (!vlnv.getVersion().isEmpty())\r\n                {\r\n                    vlnvDir += \"/\" + vlnv.getVersion();\r\n                }\r\n            }\r\n        }\r\n    }\r\n\r\n    directoryEditor_->updatePath(vlnvDir);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: NewDesignDialog::updateViewName()\r\n//-----------------------------------------------------------------------------\r\nvoid NewDesignDialog::updateViewName()\r\n{\r\n    viewNameEdit_->setText(NameGenerationPolicy::hierarchicalViewName(qualifierEdit_->text()));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: NewDesignDialog::updateVlnvName()\r\n//-----------------------------------------------------------------------------\r\nvoid NewDesignDialog::updateVlnvName()\r\n{\r\n    QString name = component_->getVlnv().getName().remove(\".comp\");\r\n    if (!qualifierEdit_->text().isEmpty())\r\n    {\r\n        name.append(\".\" + qualifierEdit_->text());\r\n    }\r\n\r\n    vlnvEditor_->setName(name);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: NewDesignDialog::setViewNameSuggestions()\r\n//-----------------------------------------------------------------------------\r\nvoid NewDesignDialog::setViewNameSuggestions(QStringList const& suggestions)\r\n{\r\n    viewNameMatcher_.setItems(suggestions);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: NewDesignDialog::setupLayout()\r\n//-----------------------------------------------------------------------------\r\nvoid NewDesignDialog::setupLayout()\r\n{\r\n    QDialogButtonBox* buttonBox = new QDialogButtonBox(Qt::Horizontal);\r\n    buttonBox->addButton(okButton_, QDialogButtonBox::AcceptRole);\r\n    buttonBox->addButton(new QPushButton(tr(\"&Cancel\")), QDialogButtonBox::RejectRole);\r\n\r\n    connect(buttonBox, SIGNAL(accepted()), this, SLOT(accept()));\r\n    connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject()));\r\n\r\n    QWidget* introWidget = new QWidget(this);\r\n    QHBoxLayout* introLayout = new QHBoxLayout(introWidget);\r\n    introLayout->addWidget(introLabel_, 9);\r\n    introLayout->addWidget(designIcon_, 1);    \r\n    \r\n    QPalette introPalette = introWidget->palette();\r\n    introPalette.setColor(QPalette::Window, Qt::white);\r\n    introWidget->setPalette(introPalette);\r\n    introWidget->setAutoFillBackground(true);\r\n    \r\n    QGroupBox* viewSettingsBox = new QGroupBox(tr(\"View settings\"), this);    \r\n    QFormLayout* viewLayout = new QFormLayout(viewSettingsBox);\r\n    viewLayout->addRow(qualifierLabel_, qualifierEdit_);\r\n    viewLayout->addRow(viewNameLabel_, viewNameEdit_);\r\n\r\n    directoryEditor_->layout()->setContentsMargins(0, 4, 0, 4);\r\n\r\n    QGroupBox* separator = new QGroupBox(this);\r\n    separator->setFlat(true);\r\n\r\n    QVBoxLayout* mainLayout = new QVBoxLayout(this);\r\n    mainLayout->addWidget(introWidget);\r\n    mainLayout->addWidget(viewSettingsBox);\r\n    mainLayout->addWidget(vlnvEditor_);\r\n    mainLayout->addWidget(directoryEditor_);\r\n    mainLayout->addWidget(separator);\r\n    mainLayout->addWidget(buttonBox);    \r\n    \r\n    setFixedHeight(sizeHint().height());\r\n    resize(421, sizeHint().height());\r\n}\r\n"
  },
  {
    "path": "common/dialogs/NewDesignDialog/NewDesignDialog.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: NewDesignDialog.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Joni-Matti Maatta\r\n// Date: 2.8.2012\r\n//\r\n// Description:\r\n// Dialog used in creation of new designs to existing components.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef NEWDESIGNDIALOG_H\r\n#define NEWDESIGNDIALOG_H\r\n\r\n#include <IPXACTmodels/common/VLNV.h>\r\n\r\n#include <common/widgets/vlnvEditor/vlnveditor.h>\r\n#include <common/widgets/assistedLineEdit/BasicLineContentMatcher.h>\r\n#include <IPXACTmodels/kactusExtensions/KactusAttribute.h>\r\n\r\n#include <QDialog>\r\n#include <QPushButton>\r\n\r\nclass LibrarySelectorWidget;\r\nclass LibraryInterface;\r\nclass VLNVEditor;\r\nclass Component;\r\nclass LineEditEx;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! New design dialog.\r\n//-----------------------------------------------------------------------------\r\nclass NewDesignDialog : public QDialog\r\n{\r\n    Q_OBJECT\r\n\r\npublic:\r\n    /*!\r\n     *  Constructor.\r\n     *\r\n     *    @param [in] libInterface  The library interface.\r\n     *    @param [in] component     The component for which the design will be created.\r\n     *    @param [in] designType    The type of design to create.\r\n     *    @param [in] parent        The parent widget.\r\n     */\r\n    NewDesignDialog(LibraryInterface* libInterface, QSharedPointer<Component> component,\r\n                    KactusAttribute::Implementation designType, QWidget *parent = 0);\r\n    \r\n\r\n    /*!\r\n     *  Sets the pre-filled view name.\r\n     *\r\n     *    @param [in] viewName The view name to set.\r\n     */\r\n    void setViewName(QString const& viewName);\r\n\r\n    /*!\r\n     *  Sets the view name suggestions.\r\n     */\r\n    void setViewNameSuggestions(QStringList const& suggestions);\r\n\r\n\t/*!\r\n     *  Sets the pre-filled VLNV.\r\n     *\r\n     *    @param [in] vlnv The VLNV to set.\r\n     */\r\n\tvoid setVLNV(const VLNV& vlnv);\r\n\r\n    /*!\r\n     *  Returns the qualifier name.\r\n     */\r\n    QString getQualifierName() const;\r\n\r\n    /*!\r\n     *  Returns the view name.\r\n     */\r\n    QString getViewName() const;\r\n\r\n    /*!\r\n     *  Returns the design VLNV.\r\n     */\r\n    VLNV getDesignVLNV() const;\r\n\r\n    /*!\r\n     *  Returns the design configuration VLNV.\r\n     */\r\n    VLNV getDesignConfVLNV() const;\r\n\r\n    /*! \r\n     *  Returns the path where to save the design.\r\n     */\r\n    QString getPath() const;\r\n\r\nprivate slots:\r\n    /*!\r\n     *  Updates the directory based on the VLNV.\r\n     */\r\n    void updateDirectory();\r\n\r\n    /*!\r\n     *  Updates the View name based on the current qualifier.\r\n     */\r\n    void updateViewName();\r\n\r\n    /*!\r\n     *  Updates the VLNV name based on the current view name.\r\n     */\r\n    void updateVlnvName();\r\n\r\n    void onContentChanged();\r\n\r\n    /*!\r\n     *  Called when the user presses OK.\r\n     */\r\n    virtual void accept();\r\nprivate:\r\n\r\n    //! No copying\r\n    NewDesignDialog(NewDesignDialog const& other);\r\n    NewDesignDialog& operator=(NewDesignDialog const& other);\r\n\r\n    //! Sets the dialog layout.\r\n    void setupLayout();\r\n    \r\n    //! The library interface.\r\n    LibraryInterface* library_;\r\n\r\n    //! The component for which the design will be created.\r\n    QSharedPointer<Component> component_;\r\n\r\n    //! The used view names.\r\n    QStringList usedViewNames_;\r\n\r\n    //! Informational label at the top of the dialog.\r\n    QLabel* introLabel_; \r\n\r\n    //! Label for the view name.\r\n    QLabel* qualifierLabel_;\r\n\r\n    //! Edit box for the view name.\r\n    LineEditEx* qualifierEdit_;\r\n\r\n    //! Label for the view name.\r\n    QLabel* viewNameLabel_;\r\n\r\n    //! View name content matcher.\r\n    BasicLineContentMatcher viewNameMatcher_;\r\n\r\n    //! Edit box for the view name.\r\n    LineEditEx* viewNameEdit_;\r\n\r\n    //! Icon for different design types.\r\n    QLabel* designIcon_; \r\n\r\n    //! The VLNV editor.\r\n    VLNVEditor* vlnvEditor_;\r\n\r\n\t//! \\brief The editor to select the directory to save to. \r\n\tLibrarySelectorWidget* directoryEditor_;\r\n\r\n    //! OK button.\r\n    QPushButton* okButton_;\r\n\r\n    //! Extension for design object.\r\n    QString designExt_;\r\n\r\n    //! Extension for designcfg object.\r\n    QString designConfExt_;\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n\r\n#endif // NEWDESIGNDIALOG_H\r\n"
  },
  {
    "path": "common/dialogs/comboSelector/comboselector.cpp",
    "content": "/* \r\n *\r\n *  Created on: 4.2.2011\r\n *      Author: Antti Kamppi\r\n * \t\tfilename: comboselector.cpp\r\n */\r\n\r\n#include \"comboselector.h\"\r\n\r\n#include <IPXACTmodels/Component/Component.h>\r\n\r\n#include <IPXACTmodels/common/FileType.h>\r\n\r\n#include <QStringList>\r\n\r\nComboSelector::ComboSelector(QWidget *parent /* = 0*/,\r\n\t\t\t\t\t\t\t const QString selected /*= QString()*/,\t\t\t\t\t\t\t  \r\n\t\t\t\t\t\t\t Qt::WindowFlags f /*= Qt::Dialog*/):\r\nQInputDialog(parent, f) {\r\n\r\n\tsetCancelButtonText(tr(\"Cancel\"));\r\n\tsetComboBoxEditable(true);\r\n\tsetInputMode(QInputDialog::TextInput);\r\n\tsetLabelText(tr(\"Select group type or create your own group type\"));\r\n\tsetOkButtonText(tr(\"Ok\"));\r\n\tsetTextValue(selected);\r\n}\r\n\r\nComboSelector::~ComboSelector() {\r\n}\r\n\r\nQString ComboSelector::execDialog() {\r\n\r\n\t// if user clicked cancel\r\n\tif (!QInputDialog::exec()) {\r\n\t\treturn QString();\r\n\t}\r\n\t// otherwise return the string that was selected\r\n\treturn textValue();\r\n}\r\n\r\nQString ComboSelector::selectGroupType(QWidget* parent /* = 0*/,\r\n\t\t\t\t\t\t\t\t\t   const QString selected,\r\n\t\t\t\t\t\t\t\t\t   const QString label) {\r\n\r\n\t// create the selector instance\r\n\tComboSelector selector(parent, selected);\r\n\r\n\t// set options for the selector box\r\n\tselector.setCancelButtonText(tr(\"Cancel\"));\r\n\tselector.setComboBoxEditable(true);\r\n\tselector.setInputMode(QInputDialog::TextInput);\r\n\tselector.setLabelText(label);\r\n\tselector.setOkButtonText(tr(\"Ok\"));\r\n\r\n\t// add the items to the box\r\n\tQStringList comboItems;\r\n\tcomboItems.append(tr(\"diagnostics\"));\r\n    comboItems.append(tr(\"documentation\"));\r\n    comboItems.append(tr(\"generatedFiles\"));\r\n\tcomboItems.append(tr(\"projectFiles\"));\r\n\tcomboItems.append(tr(\"simulation\"));\r\n\tcomboItems.append(tr(\"sourceFiles\"));\r\n\tselector.setComboBoxItems(comboItems);\r\n\r\n\tselector.setTextValue(selected);\r\n\r\n    return selector.execDialog();\r\n}\r\n\r\nQString ComboSelector::selectFileType(QWidget* parent /*= 0*/, \r\n\t\t\t\t\t\t\t\t\t  const QString selected /*= QString()*/, \r\nconst QString label /*= tr(\"Select a file type or set your own file type\")*/ ) {\r\n\r\n\t// create the selector instance\r\n\tComboSelector selector(parent, selected);\r\n\r\n\t// set options for the selector box\r\n\tselector.setCancelButtonText(tr(\"Cancel\"));\r\n\tselector.setComboBoxEditable(true);\r\n\tselector.setInputMode(QInputDialog::TextInput);\r\n\tselector.setLabelText(label);\r\n\tselector.setOkButtonText(tr(\"Ok\"));\r\n\r\n\t// add items to the box\r\n\tQStringList comboItems = FileTypes::FILE_TYPES;\r\n\r\n\tselector.setComboBoxItems(comboItems);\r\n\r\n\tselector.setTextValue(selected);\r\n\r\n    return selector.execDialog();\r\n}\r\n\r\nQString ComboSelector::selectBusInterface(\r\n\tQSharedPointer<Component> component, \r\n\tQWidget* parent /*= 0*/, \r\n\tconst QString selected /*= QString()*/, \r\n\tconst QString label /*= tr(\"Select a bus interface to include in the channel\")*/ ) {\r\n\r\n\t// create the selector instance\r\n\tComboSelector selector(parent, selected);\r\n\r\n\t// set options for the selector box\r\n\tselector.setCancelButtonText(tr(\"Cancel\"));\r\n\tselector.setComboBoxEditable(true);\r\n\tselector.setInputMode(QInputDialog::TextInput);\r\n\tselector.setLabelText(label);\r\n\tselector.setOkButtonText(tr(\"Ok\"));\r\n\r\n\t// add items to the box\r\n\tQStringList interfaceNames = component->getBusInterfaceNames();\r\n\r\n\tselector.setComboBoxItems(interfaceNames);\r\n\r\n\tselector.setTextValue(selected);\r\n\r\n    return selector.execDialog();\r\n}\r\n\r\nQString ComboSelector::selectFileSet( QSharedPointer<Component> component, \r\n\t\t\t\t\t\t\t\t\t QWidget* parent /*= 0*/, \r\n\t\t\t\t\t\t\t\t\t const QString selected /*= QString()*/, \r\n\t\t\t\t\t\t\t\t\t const QString label /*= tr(\"Select a file set\")*/ ) {\r\n\r\n\t// create the selector instance\r\n\tComboSelector selector(parent, selected);\r\n\r\n\t// set options for the selector box\r\n\tselector.setCancelButtonText(tr(\"Cancel\"));\r\n\tselector.setComboBoxEditable(true);\r\n\tselector.setInputMode(QInputDialog::TextInput);\r\n\tselector.setLabelText(label);\r\n\tselector.setOkButtonText(tr(\"Ok\"));\r\n\r\n\t// add items to the box\r\n\tQStringList fileSetNames = component->getFileSetNames();\r\n\r\n\tselector.setComboBoxItems(fileSetNames);\r\n\r\n\tselector.setTextValue(selected);\r\n\r\n    return selector.execDialog();\r\n}\r\n\r\nQString ComboSelector::selectView( QSharedPointer<Component> component,\r\n\t\t\t\t\t\t\t\t  QWidget* parent /*= 0*/, \r\n\t\t\t\t\t\t\t\t  const QString selected /*= QString()*/,\r\n\t\t\t\t\t\t\t\t  const QString label /*= tr(\"Select a view\")*/) {\r\n\r\n\t// create the selector instance\r\n\tComboSelector selector(parent, selected);\r\n\r\n\t// set the options for the selector box\r\n\tselector.setCancelButtonText(tr(\"Cancel\"));\r\n\tselector.setComboBoxEditable(false);\r\n\tselector.setInputMode(QInputDialog::TextInput);\r\n\tselector.setLabelText(label);\r\n\tselector.setOkButtonText(tr(\"Ok\"));\r\n\r\n\t// add items to the box\r\n\tQStringList viewNames = component->getViewNames();\r\n\r\n\tselector.setComboBoxItems(viewNames);\r\n\r\n\tselector.setTextValue(selected);\r\n\r\n    return selector.execDialog();\r\n}\r\n"
  },
  {
    "path": "common/dialogs/comboSelector/comboselector.h",
    "content": "/* \r\n *\r\n *  Created on: 4.2.2011\r\n *      Author: Antti Kamppi\r\n * \t\tfilename: comboselector.h\r\n */\r\n\r\n#ifndef COMBOSELECTOR_H\r\n#define COMBOSELECTOR_H\r\n\r\n#include <QInputDialog>\r\n#include <QString>\r\n\r\nclass Component;\r\n\r\n/*! \\brief ComboSelector is a dialog that can be used to select an option.\r\n *\r\n * This dialog displays a list of options that user can choose from in a \r\n * combo box. User can also define an own option and select it.\r\n */\r\nclass ComboSelector : public QInputDialog {\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\r\n\t\r\n\t/*! \\brief The constructor\r\n\t *\r\n\t * \\param parent Pointer to the owner of this dialog.\r\n\t * \\param selected Defines the currently selected value in the combobox.\r\n\t * \\param f WindowFlags that define how the dialog is displayed.\r\n\t *\r\n\t*/\r\n\tComboSelector(QWidget *parent = 0, \r\n\t\tconst QString selected = QString(), \r\n\t\tQt::WindowFlags f = Qt::Dialog);\r\n\r\n\t//! \\brief The destructor\r\n\tvirtual ~ComboSelector();\r\n\r\n\t/*! \\brief Execute the dialog\r\n\t *\r\n\t * Executes the dialog modally and asks user to select one option in the\r\n\t * combobox.\r\n\t *\r\n\t * \\return QString containing the input that user selected.\r\n\t*/\r\n\tQString execDialog();\r\n\r\n\t\r\n\t/*! \\brief Static function that can be used to select a group type in FileSet\r\n\t *\r\n\t * \\param parent Pointer to the owner of the dialog.\r\n\t * \\param selected A voluntary preselected value in the dialog.\r\n\t * \\param label The text that is used to ask user input.\r\n\t *\r\n\t * \\return QString containing the selected value. Null string if cancel was\r\n\t * pressed.\r\n\t*/\r\n\tstatic QString selectGroupType(QWidget* parent = 0, \r\n\t\tconst QString selected = QString(),\r\n\t\tconst QString label = \r\n\t\ttr(\"Select group type or create your own group type\"));\r\n\r\n\t/*! \\brief Static function that can be used to select a file type for File.\r\n\t *\r\n\t * \\param parent Pointer to the owner of the dialog\r\n\t * \\param selected A voluntary preselected value in the dialog\r\n\t * \\param label The text that is used to ask user input.\r\n\t *\r\n\t * \\return QString Containing the selected value. Null string if cancel was\r\n\t * pressed.\r\n\t*/\r\n\tstatic QString selectFileType(QWidget* parent = 0,\r\n\t\tconst QString selected = QString(),\r\n\t\tconst QString label =\r\n\t\ttr(\"Select a file type or set your own file type\"));\r\n\r\n\t/*! \\brief Static function to select a bus interface name from component.\r\n\t *\r\n\t * \\param component Pointer to the component that's bus interface is wanted.\r\n\t * \\param parent Pointer to the owner of the combo selector.\r\n\t * \\param selected The value that is selected when combo box is opened.\r\n\t * \\param label The text to be displayed to user when input is asked.\r\n\t *\r\n\t * \\return QString containing the name of the selected bus interface.\r\n\t*/\r\n\tstatic QString selectBusInterface(QSharedPointer<Component> component,\r\n\t\tQWidget* parent = 0,\r\n\t\tconst QString selected = QString(),\r\n\t\tconst QString label =\r\n\t\ttr(\"Select a bus interface to include in the channel\"));\r\n\r\n\t/*! \\brief Static function to select a file set from component.\r\n\t *\r\n\t * \\param component Pointer to the component that's file set is wanted.\r\n\t * \\param parent Pointer to the owner of the combo selector.\r\n\t * \\param selected The value that is selected when combo box is opened.\r\n\t * \\param label The text to be displayed to user when input is asked.\r\n\t *\r\n\t * \\return QString containing the name of the selected file set.\r\n\t*/\r\n\tstatic QString selectFileSet(QSharedPointer<Component> component,\r\n\t\tQWidget* parent = 0,\r\n\t\tconst QString selected = QString(),\r\n\t\tconst QString label =\r\n\t\ttr(\"Select a file set\"));\r\n\r\n\t/*! \\brief Static function to select a view from component.\r\n\t *\r\n\t * \\param component Pointer to the component that's view is selected.\r\n\t * \\param parent Pointer to the owner of combo selector.\r\n\t * \\param selected The value that is selected when combo box is opened.\r\n\t * \\param label The text to be displayed to user when input is asked.\r\n\t *\r\n\t * \\return QString containing the name of the selected view.\r\n\t*/\r\n\tstatic QString selectView(QSharedPointer<Component> component,\r\n\t\tQWidget* parent = 0,\r\n\t\tconst QString selected = QString(),\r\n\t\tconst QString label = tr(\"Select a view\"));\r\n\r\nprivate:\r\n\r\n\t//! No copying\r\n\tComboSelector(const ComboSelector& other);\r\n\r\n\t//! No assignment\r\n\tComboSelector& operator=(const ComboSelector& other);\r\n\t\r\n};\r\n\r\n#endif // GROUPSELECTOR_H\r\n"
  },
  {
    "path": "common/dialogs/createConfigurationDialog/createconfigurationdialog.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: createconfigurationdialog.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Antti Kamppi\r\n// Date: 30.08.2011\r\n//\r\n// Description:\r\n// Dialog for user to input the info needed to create a new configuration for a component.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"createconfigurationdialog.h\"\r\n\r\n#include <KactusAPI/include/LibraryInterface.h>\r\n#include <IPXACTmodels/common/VLNV.h>\r\n\r\n#include <common/widgets/LineEditEx/LineEditEx.h>\r\n\r\n#include <IPXACTmodels/Component/Component.h>\r\n\r\n#include <QIcon>\r\n#include <QVBoxLayout>\r\n#include <QHBoxLayout>\r\n#include <QFormLayout>\r\n#include <QMessageBox>\r\n#include <QCoreApplication>\r\n#include <QSettings>\r\n#include <QStringList>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: createconfigurationdialog::CreateConfigurationDialog()\r\n//-----------------------------------------------------------------------------\r\nCreateConfigurationDialog::CreateConfigurationDialog(LibraryInterface* handler,\r\n    QSharedPointer<Component> component,\r\n    KactusAttribute::Implementation configType,\r\n    QWidget *parent):\r\nQDialog(parent, Qt::CustomizeWindowHint | Qt::WindowTitleHint | Qt::WindowCloseButtonHint),\r\n    library_(handler),\r\n    component_(component),\r\n    configNameEdit_(new LineEditEx(this)),\r\n    configNameMatcher_(),\r\n    useExistingButton_(new QRadioButton(tr(\"Use current design\"), this)),\r\n    createNewButton_(new QRadioButton(tr(\"Create new design\"), this)),\r\n    createCopyButton_(new QRadioButton(tr(\"Copy current design\"), this)),\r\n    vlnvEdit_(new VLNVEditor(VLNV::DESIGNCONFIGURATION, handler, this, this)),\r\n    okButton_(new QPushButton(tr(\"OK\"), this)),\r\n    cancelButton_(new QPushButton(tr(\"Cancel\"), this))\r\n{\r\n    Q_ASSERT(component);\r\n    Q_ASSERT(handler);\r\n\r\n    setStyleSheet(QString(\"*[mandatoryField=\\\"true\\\"] { background-color: LemonChiffon; }\"));\r\n\r\n    QSettings settings;\r\n    QStringList suggestedNames;\r\n    QStringList reservedNames;\r\n\r\n    if (configType == KactusAttribute::HW)\r\n    {\r\n        suggestedNames = settings.value(\"Policies/HWViewNames\").toStringList(); \r\n        reservedNames = component->getHierViews();\r\n    }\r\n    else if (configType == KactusAttribute::SW)\r\n    {\r\n        suggestedNames = settings.value(\"Policies/SWViewNames\").toStringList();\r\n        reservedNames = component->getHierViews();\r\n    }\r\n    else if (configType == KactusAttribute::SYSTEM)\r\n    {\r\n        suggestedNames = settings.value(\"Policies/SysViewNames\").toStringList();\r\n        reservedNames = component->getSystemViewNames();\r\n    }\r\n    else\r\n    {\r\n        Q_ASSERT(false);\r\n    }\r\n\r\n    configNameMatcher_.setItems(suggestedNames);\r\n    if (!suggestedNames.isEmpty())\r\n    {\r\n        QString initialName = suggestedNames.first();\r\n        configNameEdit_->setText(initialName);\r\n        onConfNameChanged(initialName);\r\n    }\r\n\r\n    configNameEdit_->setContentMatcher(&configNameMatcher_);    \r\n    configNameEdit_->setDisallowedInputs(reservedNames);\r\n    configNameEdit_->setMessageIcon(QPixmap(\":/icons/common/graphics/exclamation.png\"));\r\n    configNameEdit_->setMessageTemplate(tr(\"View '%1' already exists!\"));\r\n    configNameEdit_->setProperty(\"mandatoryField\", true);\r\n\r\n    VLNV topVLNV = component_->getVlnv();\r\n\tvlnvEdit_->setTitle(tr(\"Configuration VLNV\"));\t\r\n\tvlnvEdit_->setVendor(topVLNV.getVendor());\r\n\tvlnvEdit_->setLibrary(topVLNV.getLibrary());\r\n\tvlnvEdit_->setVersion(topVLNV.getVersion());\r\n    vlnvEdit_->setMandatory(true);\r\n\r\n    setupLayout();\r\n    setupConnections();\r\n\r\n\tsetWindowTitle(tr(\"Create New Configuration\"));\r\n    setFixedSize(470, heightForWidth(470));\r\n    \r\n    prevalidate();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: createconfigurationdialog::~CreateConfigurationDialog()\r\n//-----------------------------------------------------------------------------\r\nCreateConfigurationDialog::~CreateConfigurationDialog()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: createconfigurationdialog::getConfigurationVLNV()\r\n//-----------------------------------------------------------------------------\r\nVLNV CreateConfigurationDialog::getConfigurationVLNV() const\r\n{\r\n\tVLNV configVLNV = vlnvEdit_->getVLNV();\r\n\tconfigVLNV.setType(VLNV::DESIGNCONFIGURATION);\r\n\r\n\treturn configVLNV;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: createconfigurationdialog::getConfigurationName()\r\n//-----------------------------------------------------------------------------\r\nQString CreateConfigurationDialog::getConfigurationName() const\r\n{\r\n\treturn configNameEdit_->text();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: createconfigurationdialog::getDesignVLNV()\r\n//-----------------------------------------------------------------------------\r\nVLNV CreateConfigurationDialog::getDesignVLNV() const\r\n{\r\n\t// first get the inputted values\r\n\tVLNV designVLNV = getConfigurationVLNV();\r\n\tdesignVLNV.setType(VLNV::DESIGN);\r\n\r\n\t// remove the possible \".designcfg\" from the end\r\n\tQString name = designVLNV.getName().remove(QStringLiteral(\".designcfg\"));\r\n    name.append(QStringLiteral(\".design\"));\r\n\r\n\tdesignVLNV.setName(name);\r\n\treturn designVLNV;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: createconfigurationdialog::designSelection()\r\n//-----------------------------------------------------------------------------\r\nCreateConfigurationDialog::DesignSelection CreateConfigurationDialog::designSelection() const\r\n{\r\n    if (useExistingButton_->isChecked())\r\n    {\r\n        return CreateConfigurationDialog::USE_EXISTING;\r\n    }\r\n    else if (createNewButton_->isChecked())\r\n    {\r\n        return CreateConfigurationDialog::CREATE_EMPTY;\r\n    }\r\n    else\r\n    {\r\n        return CreateConfigurationDialog::CREATE_COPY;\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: createconfigurationdialog::onOk()\r\n//-----------------------------------------------------------------------------\r\nvoid CreateConfigurationDialog::onOk()\r\n{\r\n    // Make sure that the VLNVs are not already in use.\r\n    if (library_->contains(getConfigurationVLNV()))\r\n    {\r\n        QMessageBox msgBox(QMessageBox::Warning, QCoreApplication::applicationName(),\r\n            tr(\"VLNV %1 already exists in the library.\").arg(getConfigurationVLNV().toString()),\r\n            QMessageBox::Ok, this);\r\n        msgBox.exec();\r\n        return;\r\n    }\r\n\r\n    if (!useExistingButton_->isChecked() && library_->contains(getDesignVLNV()))\r\n    {\r\n        QMessageBox msgBox(QMessageBox::Warning, QCoreApplication::applicationName(),\r\n            tr(\"VLNV %1 already exists in the library.\").arg(getDesignVLNV().toString()),\r\n            QMessageBox::Ok, this);\r\n        msgBox.exec();\r\n        return;\r\n    }\r\n\r\n    accept();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: createconfigurationdialog::onConfNameChanged()\r\n//-----------------------------------------------------------------------------\r\nvoid CreateConfigurationDialog::onConfNameChanged(QString const& newName)\r\n{\r\n\tvlnvEdit_->setName(component_->getVlnv().getName() + \".\" + newName + \".designcfg\");\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: CreateConfigurationDialog::prevalidate()\r\n//-----------------------------------------------------------------------------\r\nvoid CreateConfigurationDialog::prevalidate()\r\n{\r\n    okButton_->setEnabled(!configNameEdit_->text().isEmpty() && configNameEdit_->isInputValid() &&\r\n        vlnvEdit_->isValid());\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: createconfigurationdialog::setupLayout()\r\n//-----------------------------------------------------------------------------\r\nvoid CreateConfigurationDialog::setupLayout()\r\n{\r\n    QLabel* introLabel = new QLabel(\r\n        tr(\"<b>Create a new design configuration.</b><br>\"\r\n        \"A new view will be added for the design configuration in the component. The given VLNV \"\r\n        \"will be used for identifying the design configuration within the library.\"), this);\r\n    introLabel->setWordWrap(true);\r\n\r\n    QLabel* configurationIcon = new QLabel(this);\r\n    configurationIcon->setPixmap(QPixmap(\":icons/common/graphics/configuration.png\"));\r\n    \r\n    QWidget* introWidget = new QWidget(this);\r\n    QHBoxLayout* introLayout = new QHBoxLayout(introWidget);\r\n    introLayout->addWidget(introLabel, 9);\r\n    introLayout->addWidget(configurationIcon, 1);    \r\n\r\n    QPalette introPalette = introWidget->palette();\r\n    introPalette.setColor(QPalette::Window, Qt::white);\r\n    introWidget->setPalette(introPalette);\r\n    introWidget->setAutoFillBackground(true);\r\n\r\n    QGroupBox* nameGroup = new QGroupBox(tr(\"Configuration settings\"), this);\r\n    QHBoxLayout* nameLayout = new QHBoxLayout(nameGroup);\r\n    nameLayout->addWidget(new QLabel(tr(\"Name:\"), this));\r\n    nameLayout->addWidget(configNameEdit_);\r\n\r\n    QGroupBox* radioGroup = new QGroupBox(tr(\"Select target design\"), this);\r\n\r\n    QFont buttonFont = useExistingButton_->font();\r\n    buttonFont.setBold(true);\r\n    useExistingButton_->setFont(buttonFont);\r\n    createNewButton_->setFont(buttonFont);\r\n    createCopyButton_->setFont(buttonFont);\r\n\r\n    QString buttonStyle = \"QRadioButton::indicator { width: 15px; height: 15px; }\";\r\n    useExistingButton_->setStyleSheet(buttonStyle);\r\n    createNewButton_->setStyleSheet(buttonStyle);\r\n    createCopyButton_->setStyleSheet(buttonStyle);\r\n\r\n    // by default an existing design is used.\r\n    useExistingButton_->toggle();\r\n\r\n    QString labelStyle = \"QLabel { padding-left: 19px; }\";\r\n    QLabel* useExistingLabel(new QLabel(tr(\"Creates a new configuration for the current design.\"), this));\r\n    useExistingLabel->setStyleSheet(labelStyle);\r\n    useExistingLabel->setWordWrap(true);\r\n\r\n    QLabel* createNewLabel(new QLabel(tr(\"Creates a new empty design and a new configuration.\"), this));\r\n    createNewLabel->setStyleSheet(labelStyle);\r\n    createNewLabel->setWordWrap(true);\r\n\r\n    QLabel* createCopyLabel(new QLabel(tr(\"Duplicates the current design with a new VLNV for \"\r\n        \"the new configuration.\"), this));\r\n    createCopyLabel->setStyleSheet(labelStyle);\r\n    createCopyLabel->setWordWrap(true);\r\n\r\n    QVBoxLayout* radioLayout = new QVBoxLayout(radioGroup);\r\n    radioLayout->addWidget(useExistingButton_);\r\n    radioLayout->addWidget(useExistingLabel);\r\n    radioLayout->addWidget(createNewButton_);\r\n    radioLayout->addWidget(createNewLabel);\r\n    radioLayout->addWidget(createCopyButton_);\r\n    radioLayout->addWidget(createCopyLabel);\r\n\r\n    QGroupBox* separator = new QGroupBox(this);\r\n    separator->setFlat(true);\r\n\r\n    QHBoxLayout* buttonLayout = new QHBoxLayout();\r\n    buttonLayout->addStretch();\r\n    buttonLayout->addWidget(okButton_, 0, Qt::AlignRight);\r\n    buttonLayout->addWidget(cancelButton_, 0, Qt::AlignRight);\r\n\r\n    QVBoxLayout* topLayout = new QVBoxLayout(this);   \r\n    topLayout->addWidget(introWidget);\r\n    topLayout->addWidget(nameGroup);\r\n    topLayout->addWidget(vlnvEdit_);\r\n    topLayout->addWidget(radioGroup);\r\n    topLayout->addWidget(separator);\r\n    topLayout->addLayout(buttonLayout);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: createconfigurationdialog::setupConnections()\r\n//-----------------------------------------------------------------------------\r\nvoid CreateConfigurationDialog::setupConnections()\r\n{\r\n    connect(okButton_, SIGNAL(clicked(bool)), this, SLOT(onOk()), Qt::UniqueConnection);\r\n    connect(cancelButton_, SIGNAL(clicked(bool)), this, SLOT(reject()), Qt::UniqueConnection);\r\n    connect(configNameEdit_, SIGNAL(textEdited(const QString&)),\r\n        this, SLOT(onConfNameChanged(const QString&)), Qt::UniqueConnection);\r\n\r\n    connect(configNameEdit_, SIGNAL(textChanged(QString const&)), this, SLOT(prevalidate()), Qt::UniqueConnection);\r\n    connect(vlnvEdit_, SIGNAL(contentChanged()), this, SLOT(prevalidate()), Qt::UniqueConnection);\r\n}\r\n"
  },
  {
    "path": "common/dialogs/createConfigurationDialog/createconfigurationdialog.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: createconfigurationdialog.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Antti Kamppi\r\n// Date: 30.08.2011\r\n//\r\n// Description:\r\n// Dialog for user to input the info needed to create a new configuration for a component.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef CREATECONFIGURATIONDIALOG_H\r\n#define CREATECONFIGURATIONDIALOG_H\r\n\r\n#include <common/widgets/vlnvEditor/vlnveditor.h>\r\n#include <common/widgets/assistedLineEdit/BasicLineContentMatcher.h>\r\n\r\n#include <QDialog>\r\n#include <QPushButton>\r\n#include <QRadioButton>\r\n#include <QComboBox>\r\n#include <QSharedPointer>\r\n\r\nclass LibraryInterface;\r\nclass LineEditEx;\r\nclass Component;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Dialog for user to input the info needed to create a new configuration for a component.\r\n//-----------------------------------------------------------------------------\r\nclass CreateConfigurationDialog : public QDialog\r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\r\n\t//! Enum to get info on what kind of operation user wanted for new configuration.\r\n\tenum DesignSelection\r\n    {\r\n\t\tUSE_EXISTING = 0,\t// use the same design as the previous configuration\r\n\t\tCREATE_EMPTY = 1,\t// create new empty design for the new configuration\r\n\t\tCREATE_COPY = 2\t\t// create new design by copying the previous design\r\n\t};\r\n\r\n\t/*!\r\n     *  The constructor.\r\n\t *\r\n\t *    @param [in] handler     Pointer to the instance that manages the library.\r\n\t *    @param [in] component   Pointer to the component to create the configuration for.\r\n     *    @param [in] configType  What kind of configuration is to be created.\r\n\t *    @param [in] parent      Pointer to the owner of this dialog\r\n\t */\r\n\tCreateConfigurationDialog(LibraryInterface* handler,\r\n\t\tQSharedPointer<Component> component,\r\n        KactusAttribute::Implementation configType,\r\n\t\tQWidget *parent);\r\n\t\r\n\t//! The destructor.\r\n\tvirtual ~CreateConfigurationDialog();\r\n\r\n\t/*!\r\n     *  Get the VLNV for the design configuration to create.\r\n\t *\r\n\t *    @return VLNV the vlnv for the design configuration.\r\n\t */\r\n\tVLNV getConfigurationVLNV() const;\r\n\r\n\t/*!\r\n     *  Get the VLNV for the design to create.\r\n\t *\r\n\t *    @return VLNV the vlnv for the design.\r\n\t */\r\n\tVLNV getDesignVLNV() const;\r\n\r\n\t/*!\r\n     *  Get the name for the view to be saved to the component.\r\n\t *\r\n\t *    @return QString Contains the name for the view.\r\n\t */\r\n\tQString getConfigurationName() const;\r\n\r\n\t/*!\r\n     *  Find out if user wanted to use existing design or create a new one.\r\n\t *\r\n\t *    @return CreateConfigurationDialog::DesignSelection specifies what kind of operation was selected.\r\n\t */\r\n\tDesignSelection designSelection() const;\r\n\r\nprivate slots:\r\n\r\n\t//! Handler for ok-button clicks.\r\n\tvoid onOk();\r\n\r\n\t//! Handler for configNameEdit's textEdited signal.\r\n\tvoid onConfNameChanged(const QString& newName);\r\n\r\n    //! Prevalidates the dialog input and either enables or disables the OK button.\r\n    void prevalidate();\r\n\r\nprivate:\r\n\t//! No copying.\r\n\tCreateConfigurationDialog(const CreateConfigurationDialog& other);\r\n\r\n\t//! No assignment.\r\n\tCreateConfigurationDialog& operator=(const CreateConfigurationDialog& other);\r\n\r\n\t//! Set up the layout of this dialog.\r\n\tvoid setupLayout();\r\n\r\n\t//! Set up the connections for the editors.\r\n\tvoid setupConnections();\r\n\r\n\t//! Pointer to the instance that manages the library.\r\n\tLibraryInterface* library_;\r\n\r\n\t//! Pointer to the component to create the configuration for.\r\n\tQSharedPointer<Component> component_;\r\n\r\n    //! Line editor to set the name for the new view.\r\n    LineEditEx* configNameEdit_;\r\n\r\n    //! Content matcher for the configuration name editor.\r\n    BasicLineContentMatcher configNameMatcher_;\r\n\r\n\t//! Radio button that selects that current design is to be used.\r\n\tQRadioButton* useExistingButton_;\r\n\r\n\t//! Radio button that selects that a new design is to be created.\r\n\tQRadioButton* createNewButton_;\r\n\r\n\t//! Radio button that selects a new design to be copied from the old one.\r\n\tQRadioButton* createCopyButton_;\r\n\r\n\t//! Editor to set the vlnv for the new configuration (and possibly design).\r\n\tVLNVEditor* vlnvEdit_;\r\n\r\n\t//! Accept the dialog.\r\n\tQPushButton* okButton_;\r\n\r\n\t//! Reject the dialog.\r\n\tQPushButton* cancelButton_;\r\n};\r\n\r\n#endif // CREATECONFIGURATIONDIALOG_H\r\n"
  },
  {
    "path": "common/dialogs/listSelectDialog/ListSelectDialog.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ListSelectDialog.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Joni-Matti Maatta\r\n// Date: 5.12.2011\r\n//\r\n// Description:\r\n// Dialog for making a selection from a list of strings.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"ListSelectDialog.h\"\r\n\r\n#include <QPushButton>\r\n#include <QHBoxLayout>\r\n#include <QVBoxLayout>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ListSelectDialog()\r\n//-----------------------------------------------------------------------------\r\nListSelectDialog::ListSelectDialog(QWidget* parent) : QDialog(parent), \r\n                                                      descLabel_(tr(\"Select item:\"), this),\r\n                                                      itemList_(this)\r\n{\r\n    // Create the layout for the dialog.\r\n    QPushButton* btnOK = new QPushButton(tr(\"OK\") , this);\r\n    QPushButton* btnCancel = new QPushButton(tr(\"Cancel\"), this);\r\n\r\n    QHBoxLayout* buttonLayout = new QHBoxLayout();\r\n    buttonLayout->addStretch(1);\r\n    buttonLayout->addWidget(btnOK);\r\n    buttonLayout->addWidget(btnCancel);\r\n\r\n    QVBoxLayout* mainLayout = new QVBoxLayout(this);\r\n    mainLayout->addWidget(&descLabel_);\r\n    mainLayout->addWidget(&itemList_, 1);\r\n    mainLayout->addLayout(buttonLayout);\r\n\r\n    connect(btnOK, SIGNAL(clicked()), this, SLOT(accept()));\r\n    connect(btnCancel, SIGNAL(clicked()), this, SLOT(reject()));\r\n    connect(&itemList_, SIGNAL(itemDoubleClicked(QListWidgetItem*)), this, SLOT(accept()));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ~ListSelectDialog()\r\n//-----------------------------------------------------------------------------\r\nListSelectDialog::~ListSelectDialog()\r\n{\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: setDescription()\r\n//-----------------------------------------------------------------------------\r\nvoid ListSelectDialog::setDescription(QString const& desc)\r\n{\r\n    descLabel_.setText(desc);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: addItem()\r\n//-----------------------------------------------------------------------------\r\nvoid ListSelectDialog::addItem(QListWidgetItem* item)\r\n{\r\n    itemList_.addItem(item);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: getSelectedItem()\r\n//-----------------------------------------------------------------------------\r\nQListWidgetItem* ListSelectDialog::getSelectedItem() const\r\n{\r\n    return itemList_.currentItem();\r\n}\r\n"
  },
  {
    "path": "common/dialogs/listSelectDialog/ListSelectDialog.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ListSelectDialog.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Joni-Matti Maatta\r\n// Date: 5.12.2011\r\n//\r\n// Description:\r\n// Dialog for making a selection from a list of strings.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef LISTSELECTDIALOG_H\r\n#define LISTSELECTDIALOG_H\r\n\r\n#include <QDialog>\r\n#include <QListWidget>\r\n#include <QLabel>\r\n\r\n//-----------------------------------------------------------------------------\r\n//! ListSelectDialog class.\r\n//-----------------------------------------------------------------------------\r\nclass ListSelectDialog : public QDialog\r\n{\r\npublic:\r\n    /*!\r\n     *  Constructor.\r\n     */\r\n    ListSelectDialog(QWidget* parent);\r\n\r\n    /*!\r\n     *  Destructor.\r\n     */\r\n    ~ListSelectDialog();\r\n\r\n    /*!\r\n     *  Sets the description text for the list.\r\n     *\r\n     *    @param [in] desc The description text.\r\n     */\r\n    void setDescription(QString const& desc);\r\n\r\n    /*!\r\n     *  Adds a new item to the list.\r\n     *\r\n     *    @param [in] item The item to add.\r\n     */\r\n    void addItem(QListWidgetItem* item);\r\n\r\n    /*!\r\n     *  Returns the selected item.\r\n     */\r\n    QListWidgetItem* getSelectedItem() const;\r\n\r\nprivate:\r\n    // Disable copying.\r\n    ListSelectDialog(ListSelectDialog const& rhs);\r\n    ListSelectDialog& operator=(ListSelectDialog const& rhs);\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! The description label.\r\n    QLabel descLabel_;\r\n\r\n    //! The list of possible items to choose from.\r\n    QListWidget itemList_;\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n\r\n#endif // LISTSELECTDIALOG_H\r\n"
  },
  {
    "path": "common/dialogs/newObjectDialog/newobjectdialog.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: newobjetdialog.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: \r\n// Date: \r\n//\r\n// Description:\r\n// NewObjectDialog is used to query the VLNV and path of a newly created document.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"newobjectdialog.h\"\r\n\r\n#include <common/widgets/kactusAttributeEditor/KactusAttributeEditor.h>\r\n#include <common/widgets/vlnvEditor/vlnveditor.h>\r\n\r\n#include <KactusAPI/include/LibraryInterface.h>\r\n\r\n#include <QDialogButtonBox>\r\n#include <QHBoxLayout>\r\n#include <QMessageBox>\r\n#include <QCoreApplication>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: NewObjectDialog::NewObjectDialog()\r\n//-----------------------------------------------------------------------------\r\nNewObjectDialog::NewObjectDialog(LibraryInterface* libInterface, VLNV::IPXactType type, bool showAttributes,\r\n    QWidget *parent):\r\nQDialog(parent), \r\n    library_(libInterface),\r\n    attributeEditor_(new KactusAttributeEditor(this)), \r\n    vlnvEditor_(new VLNVEditor(type, libInterface, this, this)),\r\n    directoryEditor_(new LibrarySelectorWidget(this)), \r\n    okButton_(new QPushButton(tr(\"&OK\")))\r\n{\r\n    setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);\r\n\r\n    setWindowTitle(\"New HW Design\");\r\n\r\n    attributeEditor_->setVisible(showAttributes);\r\n   \r\n    directoryEditor_->layout()->setContentsMargins(0,0,0,0);\r\n\r\n    okButton_->setDefault(true);\r\n    okButton_->setEnabled(false);\r\n\r\n    setupLayout();\r\n\r\n    onProductHierarchyChanged();\r\n\r\n    connect(attributeEditor_, SIGNAL(productHierarchyChanged()), this, SLOT(onProductHierarchyChanged()));\r\n\r\n    connect(vlnvEditor_, SIGNAL(contentChanged()), this, SLOT(onContentChanged()));\r\n    connect(vlnvEditor_, SIGNAL(contentChanged()), this, SLOT(updateDirectory()));\r\n    connect(directoryEditor_, SIGNAL(contentChanged()), this, SLOT(onContentChanged()));\r\n\r\n    connect(okButton_, SIGNAL(released()), this, SLOT(accept()));    \r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: NewObjectDialog::~NewObjectDialog()\r\n//-----------------------------------------------------------------------------\r\nNewObjectDialog::~NewObjectDialog()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: NewObjectDialog::getVLNV()\r\n//-----------------------------------------------------------------------------\r\nVLNV NewObjectDialog::getVLNV()\r\n{\r\n    return vlnvEditor_->getVLNV();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: NewObjectDialog::getPath()\r\n//-----------------------------------------------------------------------------\r\nQString NewObjectDialog::getPath()\r\n{\r\n    return directoryEditor_->getPath();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: NewObjectDialog::onContentChanged()\r\n//-----------------------------------------------------------------------------\r\nvoid NewObjectDialog::onContentChanged()\r\n{\r\n    okButton_->setEnabled(directoryEditor_->isValid() && vlnvEditor_->isValid());\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: NewObjectDialog::accept()\r\n//-----------------------------------------------------------------------------\r\nvoid NewObjectDialog::accept()\r\n{\r\n    // Make sure that the VLNV is not already in use.\r\n    if (library_->contains(vlnvEditor_->getVLNV()))\r\n    {\r\n        QMessageBox::critical(this, QCoreApplication::applicationName(),\r\n            tr(\"The document cannot be created because the VLNV already exists.\"),\r\n            QMessageBox::Ok);\r\n        \r\n        return;\r\n    }\r\n\r\n    QDialog::accept();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: NewObjectDialog::setVLNV()\r\n//-----------------------------------------------------------------------------\r\nvoid NewObjectDialog::setVLNV( const VLNV& vlnv )\r\n{\r\n\tvlnvEditor_->setVLNV(vlnv);\r\n    updateDirectory();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: NewObjectDialog::setKactusAttributes()\r\n//-----------------------------------------------------------------------------\r\nvoid NewObjectDialog::setKactusAttributes(KactusAttribute::ProductHierarchy prodHier,\r\n    KactusAttribute::Firmness firmness, QVector<TagData> tags)\r\n{\r\n    attributeEditor_->setAttributes(prodHier, firmness, tags);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: NewObjectDialog::getProductHierarchy()\r\n//-----------------------------------------------------------------------------\r\nKactusAttribute::ProductHierarchy NewObjectDialog::getProductHierarchy() const\r\n{\r\n    return attributeEditor_->getProductHierarchy();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: NewObjectDialog::getFirmness()\r\n//-----------------------------------------------------------------------------\r\nKactusAttribute::Firmness NewObjectDialog::getFirmness() const\r\n{\r\n    return attributeEditor_->getFirmness();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: newobjectdialog::getTags()\r\n//-----------------------------------------------------------------------------\r\nQVector<TagData> NewObjectDialog::getTags() const\r\n{\r\n    return attributeEditor_->getTags();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: NewObjectDialog::saveAsDialog()\r\n//-----------------------------------------------------------------------------\r\nbool NewObjectDialog::saveAsDialog(QWidget* parent, LibraryInterface* lh, VLNV const& oldVLNV,\r\n    KactusAttribute::ProductHierarchy& prodHier, KactusAttribute::Firmness& firmness, QVector<TagData>& tags,\r\n    VLNV& vlnv, QString& directory)\r\n{\r\n    VLNV suggestion = oldVLNV;\r\n    suggestion.setVersion(QString());\r\n\r\n    NewObjectDialog dialog(lh, oldVLNV.getType(), oldVLNV.getType() != VLNV::BUSDEFINITION, parent);\r\n    dialog.setWindowTitle(tr(\"Save As\"));\r\n    dialog.setVLNV(suggestion);\r\n    dialog.setKactusAttributes(prodHier, firmness, tags);\r\n\r\n    if (dialog.exec() == QDialog::Rejected)\r\n    {\r\n        return false;\r\n    }\r\n\r\n    prodHier = dialog.getProductHierarchy();\r\n    firmness = dialog.getFirmness();\r\n    tags = dialog.getTags();\r\n\r\n    vlnv = dialog.getVLNV();\r\n    directory = dialog.getPath();\r\n    return true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: NewObjectDialog::saveAsDialog()\r\n//-----------------------------------------------------------------------------\r\nbool NewObjectDialog::saveAsDialog(QWidget* parent, LibraryInterface* lh,\r\n    VLNV const& oldVLNV, VLNV& vlnv, QString& directory, QString const& windowTitle)\r\n{\r\n    VLNV suggestion = oldVLNV;\r\n    suggestion.setVersion(QString());\r\n\r\n    NewObjectDialog dialog(lh, oldVLNV.getType(), false, parent);\r\n    dialog.setWindowTitle(windowTitle);\r\n    dialog.setVLNV(suggestion);\r\n\r\n    if (dialog.exec() == QDialog::Rejected)\r\n    {\r\n        return false;\r\n    }\r\n\r\n    vlnv = dialog.getVLNV();\r\n    directory = dialog.getPath();\r\n    return true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: NewObjectDialog::updateDirectory()\r\n//-----------------------------------------------------------------------------\r\nvoid NewObjectDialog::updateDirectory()\r\n{\r\n    QString vlnvDir;\r\n\r\n    VLNV vlnv = vlnvEditor_->getVLNV();\r\n\r\n    if (!vlnv.getVendor().isEmpty())\r\n    {\r\n        vlnvDir += \"/\" + vlnv.getVendor();\r\n\r\n        if (!vlnv.getLibrary().isEmpty())\r\n        {\r\n            vlnvDir += \"/\" + vlnv.getLibrary();\r\n\r\n            if (!vlnv.getName().isEmpty())\r\n            {\r\n                vlnvDir += \"/\" + vlnv.getName();\r\n\r\n                if (!vlnv.getVersion().isEmpty())\r\n                {\r\n                    vlnvDir += \"/\" + vlnv.getVersion();\r\n                }\r\n            }\r\n        }\r\n    }\r\n\r\n    directoryEditor_->updatePath(vlnvDir);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: NewObjectDialog::onProductHierarchyChanged()\r\n//-----------------------------------------------------------------------------\r\nvoid NewObjectDialog::onProductHierarchyChanged()\r\n{\r\n    // Update the VLNV's library field if it is either empty or any of the predefined ones.\r\n    VLNV vlnv = vlnvEditor_->getVLNV();\r\n\r\n    if (vlnv.getLibrary().isEmpty())\r\n    {\r\n        vlnv.setLibrary(KactusAttribute::hierarchyToString(attributeEditor_->getProductHierarchy()).toLower());\r\n    }\r\n    else\r\n    {\r\n        for (unsigned int i = 0; i < KactusAttribute::KTS_PRODHIER_COUNT; ++i)\r\n        {\r\n            if (vlnv.getLibrary().toLower() ==\r\n                KactusAttribute::hierarchyToString(static_cast<KactusAttribute::ProductHierarchy>(i)).toLower())\r\n            {\r\n                vlnv.setLibrary(KactusAttribute::hierarchyToString(attributeEditor_->getProductHierarchy()).toLower());\r\n                break;\r\n            }\r\n        }\r\n    }\r\n\r\n    vlnvEditor_->setVLNV(vlnv);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: NewObjectDialog::setupLayout()\r\n//-----------------------------------------------------------------------------\r\nvoid NewObjectDialog::setupLayout()\r\n{\r\n    QGroupBox* separator = new QGroupBox(this);\r\n    separator->setFlat(true);\r\n\r\n    QPushButton* cancelButton = new QPushButton(tr(\"&Cancel\"));\r\n    connect(cancelButton, SIGNAL(released()), this, SLOT(reject()));\r\n\r\n    QDialogButtonBox *buttonBox = new QDialogButtonBox(Qt::Horizontal);\r\n    buttonBox->addButton(okButton_, QDialogButtonBox::ActionRole);\r\n    buttonBox->addButton(cancelButton, QDialogButtonBox::ActionRole);\r\n\r\n    QVBoxLayout *mainLayout = new QVBoxLayout(this);\r\n    mainLayout->addWidget(attributeEditor_);\r\n    mainLayout->addWidget(vlnvEditor_);\r\n    mainLayout->addWidget(directoryEditor_);\r\n    mainLayout->addWidget(separator);\r\n    mainLayout->addWidget(buttonBox);\r\n    mainLayout->addStretch(1);\r\n\r\n    setFixedHeight(sizeHint().height());\r\n    resize(421, sizeHint().height());\r\n}\r\n"
  },
  {
    "path": "common/dialogs/newObjectDialog/newobjectdialog.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: newobjetdialog.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: \r\n// Date: \r\n//\r\n// Description:\r\n// NewObjectDialog is used to query the VLNV and path of a newly created document.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef NEWOBJECTDIALOG_H\r\n#define NEWOBJECTDIALOG_H\r\n\r\n#include <common/widgets/LibrarySelectorWidget/LibrarySelectorWidget.h>\r\n\r\n#include <IPXACTmodels/common/VLNV.h>\r\n#include <IPXACTmodels/common/TagData.h>\r\n#include <IPXACTmodels/kactusExtensions/KactusAttribute.h>\r\n\r\n#include <QDialog>\r\n#include <QPushButton>\r\n\r\nclass LibraryInterface;\r\nclass VLNVEditor;\r\nclass KactusAttributeEditor;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! NewObjectDialog is used to query the VLNV and path of a newly created document.\r\n//-----------------------------------------------------------------------------\r\nclass NewObjectDialog: public QDialog\r\n{\r\n    Q_OBJECT\r\n\r\npublic:\r\n\r\n    /*!\r\n     *  The constructor.\r\n     *\r\n     *    @param [in] libInterface    The library interface.\r\n     *    @param [in] type            New object type.\r\n     *    @param [in] showAttributes  Flag for visible attributes.\r\n     *    @param [in] parent          Owner of this dialog.\r\n     */\r\n    NewObjectDialog(LibraryInterface* libInterface, VLNV::IPXactType type, bool showAttributes,\r\n        QWidget *parent = 0);\r\n    \r\n\r\n    //! The destructor.\r\n    virtual ~NewObjectDialog();\r\n\r\n\t/*!\r\n     *  Set the vlnv for the editor.\r\n\t *\r\n     *    @param [in] vlnv    Reference to the vlnv to set.\r\n\t */\r\n\tvoid setVLNV(const VLNV& vlnv);\r\n\r\n    /*!\r\n     *  Sets the Kactus attributes for the dialog.\r\n     *\r\n     *    @param [in] prodHier    Product hierarchy.\r\n     *    @param [in] firmness    firmness.\r\n     *    @param [in] tags        Tags.\r\n     */\r\n    void setKactusAttributes(KactusAttribute::ProductHierarchy prodHier, KactusAttribute::Firmness firmness,\r\n        QVector<TagData> tags);\r\n\r\n    /*!\r\n     *  Get the user inputted VLNV.\r\n     */\r\n    VLNV getVLNV();\r\n\r\n    /*!\r\n     *  Returns the product hierarchy attribute.\r\n     */\r\n    KactusAttribute::ProductHierarchy getProductHierarchy() const;\r\n\r\n    /*!\r\n     *  Returns the firmness.\r\n     */\r\n    KactusAttribute::Firmness getFirmness() const;\r\n\r\n    /*!\r\n     *  Get the document tags.\r\n     *\r\n     *    @return Document tags.\r\n     */\r\n    QVector<TagData> getTags() const;\r\n\r\n    /*!\r\n     *  Get the user inputted path.\r\n     */\r\n    QString getPath();\r\n\r\n    /*!\r\n     *  Shows a pre-filled dialog with the version field set empty.\r\n     *\r\n     *    @param [in] parent      The parent widget.\r\n     *    @param [in] lh          Interface to the library.\r\n     *    @param [in] oldVLNV     The old VLNV.\r\n     *    @param [in] prodHier    Product hierarchy.\r\n     *    @param [in] firmness    Firmness.\r\n     *    @param [in] tags        Document tags.\r\n     *    @param [in] vlnv        VLNV.\r\n     *    @param [in] directory   Directory.\r\n     *\r\n     *    @return True, if the user pressed OK. False if the user pressed Cancel.\r\n     */\r\n    static bool saveAsDialog(QWidget* parent, LibraryInterface* lh, VLNV const& oldVLNV,\r\n        KactusAttribute::ProductHierarchy& prodHier, KactusAttribute::Firmness& firmness, QVector<TagData>& tags,\r\n        VLNV& vlnv, QString& directory);\r\n\r\n    /*!\r\n     *  Shows a pre-filled dialog with the version field set empty and attributes hidden.\r\n     *\r\n     *    @return True, if the user pressed OK. False if the user pressed Cancel.\r\n     */\r\n    static bool saveAsDialog(QWidget* parent, LibraryInterface* lh, VLNV const& oldVLNV, VLNV& vlnv,\r\n                             QString& directory, QString const& windowTitle = QString(\"Save As\"));\r\n\r\nprivate slots:\r\n    /*!\r\n     *  Updates the directory based on the VLNV.\r\n     */\r\n    void updateDirectory();\r\n\r\n    /*!\r\n     *  Updates the OK button state when contents change.\r\n     */\r\n    void onContentChanged();\r\n\r\n    /*!\r\n     *  Called when the user presses OK.\r\n     */\r\n    virtual void accept();\r\n\r\n    /*!\r\n     *  Called when the product hierarchy has changed.\r\n     */\r\n    void onProductHierarchyChanged();\r\n\r\nprivate:\r\n\r\n    //! Disable copying.\r\n    NewObjectDialog(NewObjectDialog const& other);\r\n    NewObjectDialog& operator=(NewObjectDialog const& other);\r\n\r\n    //! Sets the widget layout.\r\n    void setupLayout();\r\n\r\n    //! The library interface.\r\n    LibraryInterface* library_;\r\n\r\n    //! Attribute editor.\r\n    KactusAttributeEditor* attributeEditor_;\r\n\r\n    //! The VLNV editor.\r\n    VLNVEditor* vlnvEditor_;\r\n\r\n\t//! The editor to select the directory to save to. \r\n\tLibrarySelectorWidget* directoryEditor_;\r\n\r\n    //! OK button.\r\n    QPushButton* okButton_;\r\n};\r\n\r\n#endif // NEWOBJECTDIALOG_H\r\n"
  },
  {
    "path": "common/dialogs/propertyPageDialog/PropertyPageDialog.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: PropertyPageDialog.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Joni-Matti Maatta\r\n// Date: 8.6.2011\r\n//\r\n// Description:\r\n// Generic property page dialog.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"PropertyPageDialog.h\"\r\n\r\n#include \"PropertyPageView.h\"\r\n\r\n#include <QHBoxLayout>\r\n#include <QVBoxLayout>\r\n#include <QGroupBox>\r\n#include <QDialogButtonBox>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PropertyPageDialog()\r\n//-----------------------------------------------------------------------------\r\nPropertyPageDialog::PropertyPageDialog(QSize const& listIconSize, int iconColumnCount,\r\n    ViewMode viewMode, ApplyMode applyMode, QWidget* parent):\r\nQDialog(parent),\r\n    iconColumnCount_(iconColumnCount),\r\n    contentsList_(new QListWidget(this)),\r\n    pages_(new QStackedWidget(this)),\r\n    btnOk_(new QPushButton(tr(\"OK\") , this)),\r\n    viewMode_(viewMode),\r\n    applyMode_(applyMode)\r\n{\r\n    setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);\r\n\r\n    contentsList_->setIconSize(listIconSize);\r\n\r\n    if (viewMode == VIEW_ICONS)\r\n    {\r\n        contentsList_->setViewMode(QListView::IconMode);\r\n        contentsList_->setMovement(QListView::Static);\r\n        \r\n        contentsList_->setUniformItemSizes(true);\r\n        contentsList_->setSelectionRectVisible(true);\r\n\r\n        contentsList_->setWrapping(iconColumnCount != 1);\r\n\r\n        contentsList_->setSpacing(ICON_SPACING);\r\n        contentsList_->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);\r\n        contentsList_->setFlow(QListView::TopToBottom);\r\n    }\r\n    else\r\n    {\r\n        contentsList_->setViewMode(QListView::ListMode);\r\n    }\r\n    \r\n    setupLayout();\r\n   \r\n    connect(contentsList_, SIGNAL(currentItemChanged(QListWidgetItem*, QListWidgetItem*)),\r\n            this, SLOT(changePage(QListWidgetItem*, QListWidgetItem*)), Qt::UniqueConnection);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ~PropertyPageDialog()\r\n//-----------------------------------------------------------------------------\r\nPropertyPageDialog::~PropertyPageDialog()\r\n{\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: addPage()\r\n//-----------------------------------------------------------------------------\r\nvoid PropertyPageDialog::addPage(QIcon const& icon, QString const& text, PropertyPageView* view)\r\n{\r\n    // Create the list widget item for the page.\r\n    QListWidgetItem* listItem = new QListWidgetItem(contentsList_);\r\n    listItem->setIcon(icon);\r\n    listItem->setText(text);\r\n    \r\n    if (viewMode_ == VIEW_ICONS)\r\n    {\r\n        listItem->setTextAlignment(Qt::AlignHCenter | Qt::AlignBottom);\r\n    }\r\n\r\n    listItem->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);\r\n\r\n    QFont font;\r\n    font.setPixelSize(11);\r\n    listItem->setFont(font);\r\n\r\n    // Add the page to the stacked pages.\r\n    pages_->addWidget(view);\r\n\r\n    if (pages_->count() == 1)\r\n    {\r\n        contentsList_->setCurrentRow(0);\r\n    }\r\n\r\n    // Connect the contentChanged() signal.\r\n    connect(view, SIGNAL(contentChanged()), this, SLOT(onContentChanged()));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: changePage()\r\n//-----------------------------------------------------------------------------\r\nvoid PropertyPageDialog::changePage(QListWidgetItem* current, QListWidgetItem* previous)\r\n{\r\n    if (current == nullptr)\r\n    {\r\n        current = previous;\r\n    }\r\n\r\n    // Call onPageChange() for the previous page.\r\n    if (previous != 0)\r\n    {\r\n        int prevIndex = contentsList_->row(previous);\r\n        PropertyPageView* prevPage = static_cast<PropertyPageView*>(pages_->widget(prevIndex));\r\n        Q_ASSERT(prevPage != 0);\r\n\r\n        // Reject the page change if the previous page disallows it.\r\n        if (!prevPage->onPageChange())\r\n        {\r\n            contentsList_->setCurrentItem(previous);\r\n            return;\r\n        }\r\n    }\r\n\r\n    pages_->setCurrentIndex(contentsList_->row(current));\r\n    onContentChanged();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: accept()\r\n//-----------------------------------------------------------------------------\r\nvoid PropertyPageDialog::accept()\r\n{\r\n    if (applyMode_ == APPLY_CURRENT)\r\n    {\r\n        Q_ASSERT(pages_->currentWidget() != 0);\r\n        PropertyPageView* page = static_cast<PropertyPageView*>(pages_->currentWidget());\r\n\r\n        // Validate the contents of the page.\r\n        if (!page->validate())\r\n        {\r\n            return;\r\n        }\r\n\r\n        QDialog::accept();\r\n\r\n        // Apply the page.\r\n        page->apply();\r\n    }\r\n    else if (applyMode_ == APPLY_ALL)\r\n    {\r\n        // First validate all pages.\r\n        for (int i = 0; i < pages_->count(); ++i)\r\n        {\r\n            PropertyPageView* page = static_cast<PropertyPageView*>(pages_->widget(i));\r\n\r\n            if (!page->validate())\r\n            {\r\n                return;\r\n            }\r\n        }\r\n\r\n        QDialog::accept();\r\n\r\n        // Then apply all pages.\r\n        for (int i = 0; i < pages_->count(); ++i)\r\n        {\r\n            PropertyPageView* page = static_cast<PropertyPageView*>(pages_->widget(i));\r\n            page->apply();\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: onContentChanged()\r\n//-----------------------------------------------------------------------------\r\nvoid PropertyPageDialog::onContentChanged()\r\n{\r\n    Q_ASSERT(pages_->currentWidget() != 0);\r\n\r\n    // Prevalidate the page to enable/disable the OK button.\r\n    PropertyPageView* page = static_cast<PropertyPageView*>(pages_->currentWidget());\r\n    btnOk_->setEnabled(page->prevalidate());\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: finalizePages()\r\n//-----------------------------------------------------------------------------\r\nvoid PropertyPageDialog::finalizePages()\r\n{\r\n    // Determine the best width for the list items.\r\n    int optimalWidth = contentsList_->sizeHintForColumn(0);    \r\n\r\n    // Update the width of the list.\r\n    if (viewMode_ == VIEW_ICONS)\r\n    {\r\n        optimalWidth += 40;\r\n\r\n        QFontMetrics metrics(contentsList_->font());\r\n        int textHeight = metrics.height();\r\n        int optimalHeight = contentsList_->iconSize().height() + textHeight + 4;\r\n                \r\n        for (int i = 0; i < contentsList_->count(); ++i)\r\n        {\r\n            contentsList_->item(i)->setSizeHint(QSize(optimalWidth, optimalHeight));\r\n        }\r\n\r\n        contentsList_->setFixedHeight((optimalHeight + ICON_SPACING) * contentsList_->count() + ICON_SPACING);\r\n        contentsList_->setFixedWidth(optimalWidth * iconColumnCount_);\r\n    }\r\n    else\r\n    {\r\n        contentsList_->setFixedWidth(optimalWidth + 30);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PropertyPageDialog::setupLayout()\r\n//-----------------------------------------------------------------------------\r\nvoid PropertyPageDialog::setupLayout()\r\n{\r\n    QDialogButtonBox* buttons = new QDialogButtonBox(this);\r\n    buttons->addButton(btnOk_, QDialogButtonBox::AcceptRole);\r\n    buttons->addButton(QDialogButtonBox::Cancel);\r\n\r\n    connect(buttons, SIGNAL(accepted()), this, SLOT(accept()), Qt::UniqueConnection);\r\n    connect(buttons, SIGNAL(rejected()), this, SLOT(reject()), Qt::UniqueConnection);\r\n\r\n    QGridLayout* topLayout = new QGridLayout(this);\r\n    topLayout->addWidget(contentsList_, 0, 0, 2, 1);\r\n    topLayout->addWidget(pages_, 0, 1, 2, 1);\r\n    topLayout->addWidget(buttons, 2, 0, 1, 2);\r\n}\r\n"
  },
  {
    "path": "common/dialogs/propertyPageDialog/PropertyPageDialog.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: PropertyPageDialog.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Joni-Matti Maatta\r\n// Date: 8.6.2011\r\n//\r\n// Description:\r\n// Generic property page dialog.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef PROPERTYPAGEDIALOG_H\r\n#define PROPERTYPAGEDIALOG_H\r\n\r\n#include <QDialog>\r\n#include <QListWidget>\r\n#include <QStackedWidget>\r\n#include <QListWidgetItem>\r\n#include <QPushButton>\r\n\r\nclass PropertyPageView;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! PropertyPageDialog class.\r\n//-----------------------------------------------------------------------------\r\nclass PropertyPageDialog : public QDialog\r\n{\r\n    Q_OBJECT\r\n\r\npublic:\r\n    //-----------------------------------------------------------------------------\r\n    //! ApplyMode enumeration.\r\n    //-----------------------------------------------------------------------------\r\n    enum ApplyMode\r\n    {\r\n        APPLY_CURRENT = 0,\r\n        APPLY_ALL\r\n    };\r\n\r\n    //-----------------------------------------------------------------------------\r\n    //! ViewMode enumeration.\r\n    //-----------------------------------------------------------------------------\r\n    enum ViewMode\r\n    {\r\n        VIEW_LIST = 0,\r\n        VIEW_ICONS\r\n    };\r\n\r\n    /*!\r\n     *  Constructor.\r\n     *\r\n     *    @param [in] listIconSize  The icon size in the contents list.\r\n     *    @param [in] viewMode      Specifies the view mode how the organizer is shown.\r\n     *    @param [in] applyMode     Apply mode which specifies what pages are applied when\r\n     *                                the user presses OK.\r\n     *    @param [in] parent        The parent widget. Can be null.\r\n     */\r\n    PropertyPageDialog(QSize const& listIconSize, int iconColumnCount,\r\n                       ViewMode viewMode, ApplyMode applyMode, QWidget* parent = 0);\r\n\r\n    /*!\r\n     *  Destructor.\r\n     */\r\n    virtual ~PropertyPageDialog();\r\n\r\n    /*!\r\n     *  Adds a new property page to the dialog.\r\n     *\r\n     *    @param [in] icon  The icon for the page.\r\n     *    @param [in] text  The text description for the page.\r\n     *    @param [in] view  The page view.\r\n     */\r\n    void addPage(QIcon const& icon, QString const& text, PropertyPageView* view);\r\n\r\n    /*!\r\n     *  Finalizes the pages for display.\r\n     */\r\n    void finalizePages();\r\n\r\npublic slots:\r\n    /*!\r\n     *  Changes the current page based on the selection in the contents list.\r\n     *\r\n     *    @param [in] current   The current list item selected in the contents list.\r\n     *    @param [in] previous  The previously selected item in the contents list.\r\n     */\r\n    void changePage(QListWidgetItem* current, QListWidgetItem* previous);\r\n\r\n    /*!\r\n     *  Called when the user presses the OK button.\r\n     */\r\n    virtual void accept();\r\n\r\n    /*!\r\n     *  Called when the contents of the current page have changed.\r\n     */\r\n    void onContentChanged();\r\n\r\nprivate:\r\n    // Disable copying.\r\n    PropertyPageDialog(PropertyPageDialog const& rhs);\r\n    PropertyPageDialog& operator=(PropertyPageDialog const& rhs);\r\n\r\n    //! Sets the dialog layout.\r\n    void setupLayout();\r\n\r\n    enum\r\n    {\r\n        ICON_SPACING = 10,\r\n        LAYOUT_SPACING = 10\r\n    };\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! The icon column count.\r\n    int iconColumnCount_;\r\n\r\n    //! The contents list widget.\r\n    QListWidget* contentsList_;\r\n\r\n    //! The pages.\r\n    QStackedWidget* pages_;\r\n\r\n    //! OK button.\r\n    QPushButton* btnOk_;\r\n\r\n    //! View mode.\r\n    ViewMode viewMode_;\r\n\r\n    //! Apply mode.\r\n    ApplyMode applyMode_;\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n\r\n#endif // PROPERTYPAGEDIALOG_H\r\n"
  },
  {
    "path": "common/dialogs/propertyPageDialog/PropertyPageView.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: PropertyPageView.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Joni-Matti Maatta\r\n// Date: 8.6.2011\r\n//\r\n// Description:\r\n// Base class for property page views.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"PropertyPageView.h\"\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PropertyPageView()\r\n//-----------------------------------------------------------------------------\r\nPropertyPageView::PropertyPageView() : QWidget()\r\n{\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ~PropertyPageView()\r\n//-----------------------------------------------------------------------------\r\nPropertyPageView::~PropertyPageView()\r\n{\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: prevalidate()\r\n//-----------------------------------------------------------------------------\r\nbool PropertyPageView::prevalidate() const\r\n{\r\n    return true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: validate()\r\n//-----------------------------------------------------------------------------\r\nbool PropertyPageView::validate()\r\n{\r\n    return true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: onPageChange()\r\n//-----------------------------------------------------------------------------\r\nbool PropertyPageView::onPageChange()\r\n{\r\n    return true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: apply()\r\n//-----------------------------------------------------------------------------\r\nvoid PropertyPageView::apply()\r\n{\r\n}\r\n\r\n"
  },
  {
    "path": "common/dialogs/propertyPageDialog/PropertyPageView.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: PropertyPageView.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Joni-Matti Maatta\r\n// Date: 8.6.2011\r\n//\r\n// Description:\r\n// Base class for property page views.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef PROPERTYPAGEVIEW_H\r\n#define PROPERTYPAGEVIEW_H\r\n\r\n#include <QWidget>\r\n\r\n//-----------------------------------------------------------------------------\r\n//! PropertyPageView class.\r\n//-----------------------------------------------------------------------------\r\nclass PropertyPageView : public QWidget\r\n{\r\n    Q_OBJECT\r\n\r\npublic:\r\n    /*!\r\n     *  Constructor.\r\n     */\r\n    PropertyPageView();\r\n\r\n    /*!\r\n     *  Destructor.\r\n     */\r\n    virtual ~PropertyPageView();\r\n\r\n    /*!\r\n     *  Pre-validates the contents of the page. This is used for enabling/disabling the OK button.\r\n     *\r\n     *    @return True, if the contents are valid and OK button should be enabled.\r\n     *              False, if the contents are invalid and OK button should be disabled.\r\n     *\r\n     *      @remarks Must not show any message boxes.\r\n     */\r\n    virtual bool prevalidate() const;\r\n\r\n    /*!\r\n     *  Validates the contents of the page thoroughly.\r\n     *\r\n     *    @return True, if the contents are valid. False, if they are invalid.\r\n     *\r\n     *      @remarks Showing message boxes for errors is allowed.\r\n     */\r\n    virtual bool validate();\r\n\r\n    /*!\r\n     *  Applies the changes that were done in the page.\r\n     */\r\n    virtual void apply();\r\n\r\n    /*!\r\n     *  Called when the page is to be changed and this page would be hidden.\r\n     *\r\n     *    @return False, if the page change should be rejected. Otherwise true.\r\n     */\r\n    virtual bool onPageChange();\r\n\r\nsignals:\r\n    void contentChanged();\r\n\r\nprivate:\r\n\r\n\t//! \\brief No copying\r\n\tPropertyPageView(const PropertyPageView& other);\r\n\r\n\t//! \\brief No assignment\r\n\tPropertyPageView& operator=(const PropertyPageView& other);\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n\r\n#endif // PROPERTYPAGEVIEW_H\r\n"
  },
  {
    "path": "common/expressions/utilities.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: Utilities.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Mikko Teuho\n// Date: 09.04.2019\n//\n// Description:\n// Declarations for general purpose functions in expressions.\n//-----------------------------------------------------------------------------\n\n#include \"utilities.h\"\n\n//-----------------------------------------------------------------------------\n// Function: ExpressionUtilities::findMatchingEndParenthesis()\n//-----------------------------------------------------------------------------\nint ExpressionUtilities::findMatchingEndParenthesis(QString const& equation, int parenthesesStart,\n    QString commentSyntax)\n{\n    QRegularExpression parenthesesExpression(\"[()]\");\n    QRegularExpression commentExpression(commentSyntax);\n\n    int position = parenthesesStart + 1;\n    QRegularExpressionMatch commentMatch = commentExpression.match(equation, position);\n\n    int depth = 1;\n    while (depth > 0)\n    {\n        position = equation.indexOf(parenthesesExpression, position);\n\n        if (commentMatch.hasMatch() && position > commentMatch.capturedStart())\n        {\n            position = commentMatch.capturedEnd();\n            commentMatch = commentExpression.match(equation, position);\n            continue;\n        }\n\n        if (parenthesesExpression.match(equation.at(position)).captured() == \"(\")\n        {\n            depth++;\n        }\n        else\n        {\n            depth--;\n        }\n        position++;\n    }\n\n    return position - 1;\n}\n"
  },
  {
    "path": "common/expressions/utilities.h",
    "content": " //-----------------------------------------------------------------------------\n // File: Utilities.h\n //-----------------------------------------------------------------------------\n // Project: Kactus 2\n // Author: Mikko Teuho\n // Date: 09.04.2019\n //\n // Description:\n // Declarations for general purpose functions in expressions.\n //-----------------------------------------------------------------------------\n\n#ifndef EXPRESSIONUTILITIES_H\n#define EXPRESSIONUTILITIES_H\n\n#include <QRegularExpression>\n#include <QObject>\n\n//-----------------------------------------------------------------------------\n//! Declarations for general purpose functions in expressions.\n//-----------------------------------------------------------------------------\nnamespace ExpressionUtilities\n{\n    /*!\n     *  Finds the index of a matching end parenthesis in an equation.\n     *\n     *    @param [in] equation            The selected equation.\n     *    @param [in] parenthesisStart    Index of the start parenthesis.\n     *    @param [in] commentSyntax       Syntax for possible comments in the equation.\n     *\n     *    @return Index of the end parenthesis matching the selected start parenthesis.\n     */\n    int findMatchingEndParenthesis(QString const& equation, int parenthesesStart,\n        QString commentSyntax = \"[/]{2}[\\\\t]*([^\\\\r\\\\n]*)(?=\\\\r?\\\\n|$)\");\n}\n\n#endif // EXPRESSIONUTILITIES_H\n"
  },
  {
    "path": "common/graphicsItems/CommonGraphicsUndoCommands.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: CommonGraphicsUndoCommands.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Joni-Matti Maatta\r\n// Date: 6.7.2012\r\n//\r\n// Description:\r\n// Common graphics item undo commands.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"CommonGraphicsUndoCommands.h\"\r\n\r\n#include \"IGraphicsItemStack.h\"\r\n\r\n#include <common/graphicsItems/GraphicsColumnConstants.h>\r\n\r\n#include <editors/common/DesignDiagram.h>\r\n#include <editors/HWDesign/HWComponentItem.h>\r\n#include <editors/SystemDesign/HWMappingItem.h>\r\n#include <editors/SystemDesign/SWComponentItem.h>\r\n\r\n#include <IPXACTmodels/Design/ComponentInstance.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ItemAddCommand()\r\n//-----------------------------------------------------------------------------\r\nItemAddCommand::ItemAddCommand(IGraphicsItemStack* stack, QGraphicsItem* item, DesignDiagram* diagram,\r\n    QUndoCommand* parent):\r\nQUndoCommand(parent),\r\nitem_(item),\r\nstack_(stack),\r\ndel_(false),\r\ndiagram_(diagram)\r\n{\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ~ItemAddCommand()\r\n//-----------------------------------------------------------------------------\r\nItemAddCommand::~ItemAddCommand()\r\n{\r\n    if (del_)\r\n    {\r\n        delete item_;\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: undo()\r\n//-----------------------------------------------------------------------------\r\nvoid ItemAddCommand::undo()\r\n{\r\n    // Remove the item from the stack and the scene.\r\n    stack_->removeItem(item_);\r\n    item_->scene()->removeItem(item_);\r\n    del_ = true;\r\n\r\n    // Execute child commands.\r\n    QUndoCommand::undo();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: redo()\r\n//-----------------------------------------------------------------------------\r\nvoid ItemAddCommand::redo()\r\n{\r\n    // Add the item to the stack.\r\n    stack_->addItem(item_);\r\n    del_ = false;\r\n\r\n    // Child commands need not be executed because the other items change their position\r\n    // in a deterministic way.\r\n    //QUndoCommand::redo();\r\n\r\n    if (item_->scenePos().y() + GraphicsColumnConstants::MIN_Y_PLACEMENT > item_->scene()->height())\r\n    {\r\n        diagram_->resetSceneRectangleForItems();\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ItemMoveCommand()\r\n//-----------------------------------------------------------------------------\r\nItemMoveCommand::ItemMoveCommand(QGraphicsItem* item, QPointF const& oldPos, IGraphicsItemStack* oldStack,\r\n    DesignDiagram* diagram, QUndoCommand* parent):\r\nQUndoCommand(parent),\r\nitem_(item),\r\noldPos_(oldPos),\r\noldStack_(oldStack),\r\nnewPos_(item->scenePos()),\r\nnewStack_(dynamic_cast<IGraphicsItemStack*>(item->parentItem())),\r\ndiagram_(diagram)\r\n{\r\n    Q_ASSERT(oldStack != 0);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ItemMoveCommand::ItemMoveCommand()\r\n//-----------------------------------------------------------------------------\r\nItemMoveCommand::ItemMoveCommand(QGraphicsItem* item, QPointF const& oldPos, IGraphicsItemStack* oldStack,\r\n    QPointF const& newPos, IGraphicsItemStack* newStack, DesignDiagram* diagram, QUndoCommand* parent):\r\nQUndoCommand(parent),\r\nitem_(item),\r\noldPos_(oldPos),\r\noldStack_(oldStack),\r\nnewPos_(newPos),\r\nnewStack_(newStack),\r\ndiagram_(diagram)\r\n{\r\n    Q_ASSERT(oldStack != 0);\r\n    Q_ASSERT(newStack != 0);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ~ItemMoveCommand()\r\n//-----------------------------------------------------------------------------\r\nItemMoveCommand::~ItemMoveCommand()\r\n{\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: undo()\r\n//-----------------------------------------------------------------------------\r\nvoid ItemMoveCommand::undo()\r\n{\r\n    newStack_->removeItem(item_);\r\n\r\n    item_->setPos(oldPos_);\r\n    oldStack_->addItem(item_);\r\n\r\n    SystemComponentItem* systemItem = dynamic_cast<SystemComponentItem*>(item_);\r\n    if (systemItem)\r\n    {\r\n        systemItem->getComponentInstance()->setPosition(oldPos_);\r\n        QSharedPointer<ComponentInstance> swInstance = systemItem->getComponentInstance();\r\n        if (swInstance)\r\n        {\r\n            HWMappingItem* hwMapItem = dynamic_cast<HWMappingItem*>(oldStack_);\r\n            if (hwMapItem && hwMapItem->getComponentInstance())\r\n            {\r\n                swInstance->setMapping(hwMapItem->getComponentInstance()->getUuid());\r\n            }\r\n            else\r\n            {\r\n                swInstance->setMapping(\"\");\r\n            }\r\n        }\r\n    }\r\n\r\n    // Execute child commands.\r\n    QUndoCommand::undo();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: redo()\r\n//-----------------------------------------------------------------------------\r\nvoid ItemMoveCommand::redo()\r\n{\r\n    oldStack_->removeItem(item_);\r\n\r\n    item_->setPos(newPos_);\r\n    newStack_->addItem(item_);\r\n\r\n    SystemComponentItem* systemItem = dynamic_cast<SystemComponentItem*>(item_);\r\n    if (systemItem)\r\n    {\r\n        systemItem->getComponentInstance()->setPosition(newPos_);\r\n        QSharedPointer<ComponentInstance> swInstance = systemItem->getComponentInstance();\r\n        if (swInstance)\r\n        {\r\n            HWMappingItem* hwMapItem = dynamic_cast<HWMappingItem*>(newStack_);\r\n            if (hwMapItem && hwMapItem->getComponentInstance())\r\n            {\r\n                swInstance->setMapping(hwMapItem->getComponentInstance()->getUuid());\r\n            }\r\n            else\r\n            {\r\n                swInstance->setMapping(\"\");\r\n            }\r\n        }\r\n    }\r\n\r\n\t// Execute child commands.\r\n\tQUndoCommand::redo();\r\n\r\n    if (item_->scenePos().y() + GraphicsColumnConstants::MIN_Y_PLACEMENT > item_->scene()->height())\r\n    {\r\n        diagram_->resetSceneRectangleForItems();\r\n    }\r\n}\r\n"
  },
  {
    "path": "common/graphicsItems/CommonGraphicsUndoCommands.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: CommonGraphicsUndoCommands.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Joni-Matti Maatta\r\n// Date: 6.7.2012\r\n//\r\n// Description:\r\n// Common graphics item undo commands.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef COMMONGRAPHICSUNDOCOMMANDS_H\r\n#define COMMONGRAPHICSUNDOCOMMANDS_H\r\n\r\n#include <QUndoCommand>\r\n#include <QGraphicsItem>\r\n#include <QGraphicsScene>\r\n#include <QString>\r\n\r\nclass IGraphicsItemStack;\r\nclass ComponentItem;\r\nclass DesignDiagram;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! ItemAddCommand class.\r\n//-----------------------------------------------------------------------------\r\nclass ItemAddCommand : public QUndoCommand\r\n{\r\n\r\npublic:\r\n    /*!\r\n     *  Constructor.\r\n     *\r\n     *    @param [in] stack       The stack to which to add the item.\r\n     *    @param [in] item        The item to add.\r\n     *    @param [in] diagram     Diagram containing the scene of the added item.\r\n     *    @param [in] parent      The parent command.\r\n     */\r\n    ItemAddCommand(IGraphicsItemStack* stack, QGraphicsItem* item, DesignDiagram* diagram,\r\n        QUndoCommand* parent = 0);\r\n\r\n    /*!\r\n     *  Destructor.\r\n     */\r\n    ~ItemAddCommand();\r\n\r\n    /*!\r\n     *  Undoes the command.\r\n     */\r\n    virtual void undo();\r\n\r\n    /*!\r\n     *  Redoes the command.\r\n     */\r\n    virtual void redo();\r\n\r\nprivate:\r\n    // Disable copying.\r\n    ItemAddCommand(ItemAddCommand const& rhs);\r\n    ItemAddCommand& operator=(ItemAddCommand const& rhs);\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! The graphics item.\r\n    QGraphicsItem* item_;\r\n\r\n    //! The item's parent column.\r\n    IGraphicsItemStack* stack_;\r\n\r\n    //! Boolean flag for indicating if the component should be deleted in the destructor.\r\n    bool del_;\r\n\r\n    //! Diagram containing the scene of the added item.\r\n    DesignDiagram* diagram_;\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n//! ItemMoveCommand class.\r\n//-----------------------------------------------------------------------------\r\nclass ItemMoveCommand : public QUndoCommand\r\n{\r\npublic:\r\n    /*!\r\n     *  Constructor.\r\n     *\r\n     *    @param [in] item        The item to move.\r\n     *    @param [in] oldPos      The item's old position.\r\n     *    @param [in] oldStack    The item's old stack.\r\n     *    @param [in] diagram     Diagram containing the scene of the moved item.\r\n     *    @param [in] parent      The parent command.\r\n     */\r\n    ItemMoveCommand(QGraphicsItem* item, QPointF const& oldPos, IGraphicsItemStack* oldStack,\r\n        DesignDiagram* diagram, QUndoCommand* parent = 0);\r\n\r\n    /*!\r\n     *  Constructor.\r\n     *\r\n     *    @param [in] item        The item to move.\r\n     *    @param [in] oldPos      The item's old position.\r\n     *    @param [in] oldStack    The item's old stack.\r\n     *    @param [in] newPos      The item's new position.\r\n     *    @param [in] newStacke   The item's new stack.\r\n     *    @param [in] diagram     Diagram containing the scene of the moved item.\r\n     *    @param [in] parent      The parent command.\r\n     */\r\n    ItemMoveCommand(QGraphicsItem* item, QPointF const& oldPos, IGraphicsItemStack* oldStack,\r\n        QPointF const& newPos, IGraphicsItemStack* newStack, DesignDiagram* diagram, QUndoCommand* parent = 0);\r\n\r\n    /*!\r\n     *  Destructor.\r\n     */\r\n    ~ItemMoveCommand();\r\n\r\n    /*!\r\n     *  Undoes the command.\r\n     */\r\n    virtual void undo();\r\n\r\n    /*!\r\n     *  Redoes the command.\r\n     */\r\n    virtual void redo();\r\n\r\nprivate:\r\n    // Disable copying.\r\n    ItemMoveCommand(ItemMoveCommand const& rhs);\r\n    ItemMoveCommand& operator=(ItemMoveCommand const& rhs);\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! The graphics item.\r\n    QGraphicsItem* item_;\r\n\r\n    //! The old position of the item.\r\n    QPointF oldPos_;\r\n\r\n    //! The old parent stack.\r\n    IGraphicsItemStack* oldStack_;\r\n\r\n    //! The new position of the item.\r\n    QPointF newPos_;\r\n\r\n    //! The new parent stack.\r\n    IGraphicsItemStack* newStack_;\r\n\r\n    //! Diagram containing the scene of the moved item.\r\n    DesignDiagram* diagram_;\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n\r\n#endif // COMMONGRAPHICSUNDOCOMMANDS_H"
  },
  {
    "path": "common/graphicsItems/ComponentItem.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ComponentItem.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Joni-Matti Maatta\r\n// Date: 6.11.2011\r\n//\r\n// Description:\r\n// Base class for all graphics items that represent an IP-XACT component.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"ComponentItem.h\"\r\n\r\n#include \"ConnectionEndpoint.h\"\r\n#include \"IGraphicsItemStack.h\"\r\n#include \"GraphicsConnection.h\"\r\n\r\n#include <IPXACTmodels/common/VLNV.h>\r\n\r\n#include <IPXACTmodels/Component/Component.h>\r\n\r\n#include <IPXACTmodels/Design/ComponentInstance.h>\r\n\r\n#include <QFont>\r\n#include <QPen>\r\n#include <QTextDocument>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentItem::ComponentItem()\r\n//-----------------------------------------------------------------------------\r\nComponentItem::ComponentItem(QRectF const& size, LibraryInterface* libInterface,\r\n    QSharedPointer<ComponentInstance> instance, QSharedPointer<Component> component,\r\n    QGraphicsItem* parent) : \r\nQGraphicsRectItem(parent),\r\n    Associable(),\r\n    libInterface_(libInterface),\r\n    component_(component), \r\n    componentInstance_(instance)\r\n{\r\n    setFlag(ItemSendsGeometryChanges);\r\n    setFlag(ItemIsSelectable);\r\n    setFlag(ItemSendsScenePositionChanges);\r\n    setAcceptHoverEvents(true); // Prevents hover events from propagating to interconnections beneath.\r\n\r\n    setRect(size);\r\n    setPen(QPen(Qt::black, 0));\r\n\r\n    // Create the name label.\r\n    QFont font = nameLabel_->font();\r\n    font.setWeight(QFont::Bold);\r\n\r\n    nameLabel_->setFont(font);\r\n    nameLabel_->setTextWidth(COMPONENTWIDTH - 20);\r\n    nameLabel_->setPos(-nameLabel_->boundingRect().width()/2, GridSize);\r\n    nameLabel_->setPlainText(instance->getInstanceName());\r\n\r\n    setPos(instance->getPosition());\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentItem::~ComponentItem()\r\n//-----------------------------------------------------------------------------\r\nComponentItem::~ComponentItem()\r\n{\r\n    emit destroyed(this);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentItem::updateComponent()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentItem::updateComponent()\r\n{\r\n    updateNameLabel();\r\n\r\n    VLNV vlnv = component_->getVlnv();\r\n\r\n    QString toolTipText;\r\n    if (!vlnv.isEmpty())\r\n    {\r\n        toolTipText += QStringLiteral(\"<b>Vendor:</b> \") + vlnv.getVendor() +\r\n            QStringLiteral(\"<br><b>Library:</b> \") + vlnv.getLibrary() + \r\n            QStringLiteral(\"<br><b>Name:</b> \") + vlnv.getName() + \r\n            QStringLiteral(\"<br><b>Version:</b> \") + vlnv.getVersion();\r\n    }\r\n    else\r\n    {\r\n        toolTipText += QStringLiteral(\"Unpackaged component. No VLNV assigned!\");\r\n    }\r\n\r\n    toolTipText += QStringLiteral(\"<br><br><b>Instance name:</b> \") + name();\r\n\r\n    if (!description().isEmpty())\r\n    {\r\n        toolTipText += QStringLiteral(\"<br><br><b>Description:</b><br>\") + description();\r\n    }\r\n\r\n    setToolTip(toolTipText);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentItem::updateSize()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentItem::updateSize()\r\n{\r\n\tQRectF oldRect = rect();\r\n\toldRect.setHeight(getHeight());\r\n\r\n\tqreal width = getWidth();\r\n\r\n\tsetRect(-width/2, oldRect.y(), width, oldRect.height());\r\n\r\n\tauto stack = dynamic_cast<IGraphicsItemStack*>(parentItem());\r\n\tif (stack != nullptr)\r\n\t{\r\n\t\tstack->updateItemPositions();\r\n\t}\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentItem::getWidth()\r\n//-----------------------------------------------------------------------------\r\nqreal ComponentItem::getWidth() noexcept\r\n{\r\n\treturn COMPONENTWIDTH;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentItem::setName()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentItem::setName(QString const& newName)\r\n{\r\n    QString oldName = name();\r\n\r\n    componentInstance_->setInstanceName(newName);\r\n\r\n    updateNameLabel();\r\n\r\n    updateComponent();\r\n    \r\n    emit nameChanged(newName, oldName);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentItem::setDisplayName()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentItem::setDisplayName(QString const& displayName)\r\n{\r\n    componentInstance_->setDisplayName(displayName);\r\n\r\n    updateNameLabel();\r\n\r\n    emit displayNameChanged(displayName);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentItem::setDescription()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentItem::setDescription(QString const& description)\r\n{\r\n    componentInstance_->setDescription(description);\r\n    updateComponent();\r\n    emit descriptionChanged(description);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentItem::name()\r\n//-----------------------------------------------------------------------------\r\nQString ComponentItem::name() const\r\n{\r\n    return componentInstance_->getInstanceName();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentItem::displayName()\r\n//-----------------------------------------------------------------------------\r\nQString ComponentItem::displayName() const\r\n{\r\n    return componentInstance_->displayName();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentItem::description()\r\n//-----------------------------------------------------------------------------\r\nQString ComponentItem::description() const\r\n{\r\n    return componentInstance_->description();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentItem::componentModel()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<Component> ComponentItem::componentModel() const\r\n{\r\n    return component_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentItem::getComponentInstance()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<ComponentInstance> ComponentItem::getComponentInstance() const\r\n{\r\n    return componentInstance_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentItem::getViews()\r\n//-----------------------------------------------------------------------------\r\nQStringList ComponentItem::getViews() const\r\n{\r\n    return component_->getViewNames();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentItem::itemChange()\r\n//-----------------------------------------------------------------------------\r\nQVariant ComponentItem::itemChange(GraphicsItemChange change, const QVariant &value)\r\n{\r\n    if (change == ItemPositionChange)\r\n    {\r\n        return snapPointToGrid(value.toPointF());\r\n    }\r\n    else if (change == ItemScenePositionHasChanged)\r\n    {\r\n        componentInstance_->setPosition(scenePos());\r\n        positionUpdated();\r\n    }\r\n\r\n    return QGraphicsItem::itemChange(change, value);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentItem::updateNameLabel()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentItem::updateNameLabel()\r\n{\r\n    auto text = QString();\r\n    if (!displayName().isEmpty())\r\n    {\r\n        text = displayName();\r\n    }\r\n    else\r\n    {\r\n        text = name();\r\n    }\r\n\r\n    nameLabel_->setHtml(QStringLiteral(\"<center>\") + text + QStringLiteral(\"</center>\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentItem::getEndpoints()\r\n//-----------------------------------------------------------------------------\r\nQList<ConnectionEndpoint*> ComponentItem::getEndpoints() const\r\n{\r\n    QList<ConnectionEndpoint*> endpoints;\r\n\r\n    for (QGraphicsItem* item : QGraphicsRectItem::childItems())\r\n    {\r\n        auto endpoint = dynamic_cast<ConnectionEndpoint*>(item);\r\n\r\n        if (endpoint != nullptr)\r\n        {\r\n            endpoints.append(endpoint);\r\n        }\r\n    }\r\n\r\n    return endpoints;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentItem::getParentStack()\r\n//-----------------------------------------------------------------------------\r\nIGraphicsItemStack* ComponentItem::getParentStack()\r\n{\r\n    return dynamic_cast<IGraphicsItemStack*>(parentItem());\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentItem::getUuid()\r\n//-----------------------------------------------------------------------------\r\nQString ComponentItem::getUuid() const\r\n{\r\n\treturn componentInstance_->getUuid();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentItem::connectionPoint()\r\n//-----------------------------------------------------------------------------\r\nQPointF ComponentItem::connectionPoint(QPointF const&) const\r\n{\r\n    return mapToScene(rect().center());\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentItem::getHeight()\r\n//-----------------------------------------------------------------------------\r\nqreal ComponentItem::getHeight()\r\n{\r\n    // Update the component's size based on the port that is positioned at\r\n    // the lowest level of them all.\r\n    qreal maxY = 4 * GridSize;\r\n\r\n    if (!leftPorts_.empty())\r\n    {\r\n        maxY = leftPorts_.back()->y();\r\n    }\r\n\r\n    if (!rightPorts_.empty())\r\n    {\r\n        maxY = qMax(maxY, rightPorts_.back()->y());\r\n    }\r\n\r\n    return (maxY + BOTTOM_MARGIN);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentItem::getLibraryInterface()\r\n//-----------------------------------------------------------------------------\r\nLibraryInterface* ComponentItem::getLibraryInterface()\r\n{\r\n    return libInterface_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentItem::addPortToSideByPosition()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentItem::addPortToSideByPosition(ConnectionEndpoint* port)\r\n{\r\n    if (port->pos().x() >= 0)\r\n    {\r\n        addPortToRight(port);\r\n    }\r\n    else\r\n    {\r\n        addPortToLeft(port);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentItem::addPortToSideWithLessPorts()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentItem::addPortToSideWithLessPorts(ConnectionEndpoint* port)\r\n{\r\n    // Place the port at the bottom of the side that contains fewer ports.\r\n    if (leftPorts_.size() < rightPorts_.size())\r\n    {\r\n        if (!leftPorts_.empty())\r\n        {\r\n            port->setPos(QPointF(0, leftPorts_.last()->pos().y() + GridSize * 3) + rect().topLeft());\r\n        }\r\n        else\r\n        {\r\n            port->setPos(QPointF(0, GridSize * 4) + rect().topLeft());\r\n        }\r\n\r\n        addPortToLeft(port);\r\n    }\r\n    else\r\n    {\r\n        if (!rightPorts_.empty())\r\n        {\r\n            port->setPos(QPointF(rect().width(), rightPorts_.last()->pos().y() + GridSize * 3) + rect().topLeft());\r\n        }\r\n        else\r\n        {\r\n            port->setPos(QPointF(rect().width(), GridSize * 4) + rect().topLeft());\r\n        }\r\n\r\n        addPortToRight(port);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentItem::addPortToLeft()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentItem::addPortToLeft(ConnectionEndpoint* port)\r\n{\r\n    connect(port, SIGNAL(moved(ConnectionEndpoint*)), this, SIGNAL(endpointMoved(ConnectionEndpoint*)));\r\n\r\n    leftPorts_.append(port);\r\n    portLayout_->updateItemMove(leftPorts_, port, MIN_Y_PLACEMENT);\r\n    portLayout_->setItemPos(leftPorts_, port, rect().left(), MIN_Y_PLACEMENT);\r\n    checkPortLabelSize(port, rightPorts_);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentItem::addPortToRight()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentItem::addPortToRight(ConnectionEndpoint* port)\r\n{\r\n    connect(port, SIGNAL(moved(ConnectionEndpoint*)), this, SIGNAL(endpointMoved(ConnectionEndpoint*)));\r\n\r\n    rightPorts_.append(port);\r\n    portLayout_->updateItemMove(rightPorts_, port, MIN_Y_PLACEMENT);\r\n    portLayout_->setItemPos(rightPorts_, port, rect().right(), MIN_Y_PLACEMENT);\r\n    checkPortLabelSize(port, leftPorts_);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SystemComponentItem::checkPortLabelSize()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentItem::checkPortLabelSize(ConnectionEndpoint* port, QList<ConnectionEndpoint*> const& otherSide)\r\n{\r\n    if (auto it = std::find_if(otherSide.cbegin(), otherSide.cend(),\r\n        [y = port->y()](auto const& otherPort) { return otherPort->y() == y; }); \r\n        it != otherSide.cend())\r\n    {\r\n        auto opposingPort = *it;\r\n        qreal portLabelWidth = port->getNameLength();\r\n        qreal otherLabelWidth = opposingPort->getNameLength();\r\n\r\n        constexpr auto halfWidth = ComponentItem::COMPONENTWIDTH/2;\r\n\r\n        // Check if both of the labels exceed the mid section of the component.\r\n        if (portLabelWidth + SPACING * 2 > halfWidth && otherLabelWidth + SPACING * 2 > halfWidth)\r\n        {\r\n            port->shortenNameLabel(halfWidth);\r\n            opposingPort->shortenNameLabel(halfWidth);\r\n        }\r\n        // Check if the other port is wider than the other.\r\n        else if (portLabelWidth > otherLabelWidth)\r\n        {\r\n            port->shortenNameLabel(ComponentItem::COMPONENTWIDTH - otherLabelWidth - SPACING * 2);\r\n        }\r\n        else\r\n        {\r\n            opposingPort->shortenNameLabel(ComponentItem::COMPONENTWIDTH - portLabelWidth - SPACING * 2);\r\n        }\r\n    }\r\n    else\r\n    {\r\n        // If there is no ports with the same y() value, the full port name width is restored.\r\n        port->shortenNameLabel(ComponentItem::COMPONENTWIDTH);\r\n    }\r\n}\r\n"
  },
  {
    "path": "common/graphicsItems/ComponentItem.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ComponentItem.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Joni-Matti Maatta\r\n// Date: 6.11.2011\r\n//\r\n// Description:\r\n// Base class for all graphics items that represent an IP-XACT component.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef COMPONENTITEM_H\r\n#define COMPONENTITEM_H\r\n\r\n#include \"ConnectionEndpoint.h\"\r\n\r\n#include <editors/common/diagramgrid.h>\r\n#include <editors/common/Association/Associable.h>\r\n\r\n#include <common/layouts/IVGraphicsLayout.h>\r\n#include <common/layouts/VCollisionLayout.h>\r\n\r\n#include <QGraphicsRectItem>\r\n#include <QSharedPointer>\r\n\r\nclass Component;\r\nclass ComponentInstance;\r\nclass LibraryInterface;\r\nclass IGraphicsItemStack;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! ComponentItem class.\r\n//-----------------------------------------------------------------------------\r\nclass ComponentItem : public QObject, public QGraphicsRectItem, public Associable\r\n{\r\n    Q_OBJECT \r\n\r\npublic:\r\n    /*!\r\n     *  Constructor.\r\n     *\r\n     *    @param [in] size                      The initial rectangle size.\r\n     *    @param [in] libInterface              The library interface.\r\n     *    @param [in] component                 The actual component.\r\n     *    @param [in] instanceName              The name of the component instance.\r\n     *    @param [in] parent                    The parent graphics item.\r\n     */\r\n\r\n\r\n    ComponentItem(QRectF const& size,\r\n        LibraryInterface* libInterface,\r\n        QSharedPointer<ComponentInstance> instance,\r\n        QSharedPointer<Component> component,\r\n        QGraphicsItem* parent);\r\n\r\n\t/*!\r\n     *  Destructor.\r\n     */\r\n\t~ComponentItem() override;\r\n\r\n    // Disable copying.\r\n    ComponentItem(ComponentItem const& rhs) = delete;\r\n    ComponentItem& operator=(ComponentItem const& rhs) = delete;\r\n\r\n    /*!\r\n     *  Updates the component item to reflect the current state of the component model.\r\n     */\r\n    virtual void updateComponent();\r\n\r\n    /*!\r\n     *  Updates the size of the component box.\r\n     */\r\n    void updateSize();\r\n\r\n    /*!\r\n\t *  Returns the height of the component box.\r\n\t */\r\n    virtual qreal getHeight();\r\n    \r\n    /*!\r\n\t *  Returns the width of the component box.\r\n\t */\r\n    virtual qreal getWidth() noexcept;\r\n\r\n\t/*!\r\n     *  Sets the instance name.\r\n     *\r\n     *    @param [in] newName The instance name to set.\r\n     */\r\n    void setName(QString const& newName);\r\n\r\n    /*!\r\n     *  Sets the display name for the component instance.\r\n     *\r\n     *    @param [in] displayName The display name to set.\r\n\t */\r\n\tvoid setDisplayName(QString const& displayName);\r\n\r\n    /*!\r\n     *  Sets the description of the component instance.\r\n     *\r\n     *    @param [in] description The description to set.\r\n     */\r\n\tvoid setDescription(const QString& description);\r\n\r\n    /*!\r\n     *  Returns the instance name.\r\n     */\r\n    QString name() const;\r\n\r\n\t/*!\r\n     *  Returns the display name of the component instance.\r\n     */\r\n\tQString displayName() const;\r\n\r\n\t/*!\r\n     *  Returns the description of the component instance.\r\n     */\r\n\tQString description() const;\r\n\r\n    /*!\r\n     *  Returns the IP-XACT component model.\r\n     */\r\n    QSharedPointer<Component> componentModel() const;\r\n\r\n    /*!\r\n     *  Returns the IP-XACT component instance.\r\n     */\r\n    QSharedPointer<ComponentInstance> getComponentInstance() const;\r\n\r\n\t/*! \\brief Get list of views the component has.\r\n\t *\r\n\t * \\return QStringList containing the names of the views for the component.\r\n\t*/\r\n\tQStringList getViews() const;\r\n\r\n    /*!\r\n     *  Returns the list of endpoints in the component.\r\n     */\r\n    QList<ConnectionEndpoint*> getEndpoints() const;\r\n\r\n    /*!\r\n     *  Returns the parent graphics item stack.\r\n     */\r\n    IGraphicsItemStack* getParentStack();\r\n\r\n\t/*! \\brief Get the uuid of the instance.\r\n     *\r\n\t * \\return QString containing uuid.\r\n\t */\r\n\tQString getUuid() const;\r\n\r\n    /*!\r\n     *  Defines the connection point for associations in scene coordinates.\r\n     *     \r\n     *    @param [in] otherEnd   The position of the other end connection point.\r\n     *\r\n     *    @return The connection point of the item.\r\n     */\r\n    virtual QPointF connectionPoint(QPointF const& otherEnd = QPointF()) const;\r\n\r\n    /*!\r\n     *  Marks the component as a packetized component.\r\n     */\r\n    virtual void setPackaged() = 0;\r\n\r\n    /*!\r\n     *  Marks the component as a draft component.\r\n     */\r\n    virtual void setDraft() = 0;\r\n\t\r\n    /*!\r\n     *  Handle the movement of a connection end point item.\r\n     *\r\n     *    @param [in] port    The selected connection end point item.\r\n     */\r\n    virtual void onMovePort(ConnectionEndpoint* port) = 0;\r\n\r\n    // The basic width of the components.\r\n    static constexpr qreal COMPONENTWIDTH = 220;\r\n\r\nsignals:\r\n    //! Emitted when an endpoint has been moved.\r\n    void endpointMoved(ConnectionEndpoint* endpoint);\r\n\r\n    //! Sends an error message to the user.\r\n    void errorMessage(const QString& errorMessage) const;\r\n\r\n\t//! \\brief Emitted when the name of the component item changes.\r\n\tvoid nameChanged(QString const& newName, QString const& oldName);\r\n\r\n\t//! \\brief Emitted when the display name changes.\r\n\tvoid displayNameChanged(QString const& newName);\r\n\r\n\t//! \\brief Emitted when the description changes.\r\n\tvoid descriptionChanged(QString const& newDescription);\r\n\r\n\t//! \\brief Emitted when the configurable elements change.\r\n\tvoid confElementsChanged(QMap<QString, QString> const& confElements);\r\n\r\n\t//! \\brief Emitted right before this component is destroyed.\r\n\tvoid destroyed(ComponentItem* comp);\r\n\r\nprotected:\r\n\r\n    QVariant itemChange(GraphicsItemChange change, const QVariant &value);\r\n\r\n    /*!\r\n     *  Returns the library interface.\r\n     */\r\n    LibraryInterface* getLibraryInterface();\r\n\r\n    /*!\r\n     *  Updates the name label with the given text.\r\n     *\r\n     *    @param [in] text The text to display in the label.\r\n     */\r\n    virtual void updateNameLabel();\r\n\r\n\r\n    /*!\r\n     *  Adds an interface item to component side determined by the item position.\r\n     *\r\n     *    @param [in] port   The interface item to add.\r\n     */\r\n    void addPortToSideByPosition(ConnectionEndpoint* port);\r\n\r\n    /*!\r\n     *  Adds an interface item to the component side with less ports.\r\n     *\r\n     *    @param [in] port   The interface item to add.\r\n     */\r\n    void addPortToSideWithLessPorts(ConnectionEndpoint* port);\r\n\r\n    /*!\r\n     *  Adds a bus interface on the left side of the component item.\r\n     *\r\n     *    @param [in] port   The port to add.\r\n     */\r\n    void addPortToLeft(ConnectionEndpoint* port);\r\n\r\n    /*!\r\n     *  Adds a bus interface on the right side of the component item.\r\n     *\r\n     *    @param [in] port   The port to add.\r\n     */\r\n    void addPortToRight(ConnectionEndpoint* port);\r\n\r\n\r\n    /*!\r\n     *  Check and resize the port labels to better match with the component width.\r\n     *\r\n     *    @param [in] port       The port that is compared to the other stack.\r\n     *    @param [in] otherSide  The stack containing the ports of the other side.\r\n     */\r\n    void checkPortLabelSize(ConnectionEndpoint* port, QList<ConnectionEndpoint*> const& otherSide);\r\n\r\n    static constexpr int SPACING = GridSize;\r\n    static constexpr int MIN_Y_PLACEMENT = 3 * GridSize;\r\n    static constexpr int BOTTOM_MARGIN = 2 * GridSize;\r\n\r\n\r\n    //! The layout for ports.\r\n    QSharedPointer< IVGraphicsLayout<ConnectionEndpoint> > portLayout_ =\r\n        QSharedPointer< IVGraphicsLayout<ConnectionEndpoint> >(new VCollisionLayout<ConnectionEndpoint>(SPACING));\r\n\r\n    //! The left and right port stacks.\r\n    QList<ConnectionEndpoint*> leftPorts_;\r\n    QList<ConnectionEndpoint*> rightPorts_;\r\n\r\nprivate:\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! The library interface.\r\n    LibraryInterface* libInterface_ = nullptr;\r\n\r\n    //! The component model.\r\n    QSharedPointer<Component> component_ = nullptr;\r\n\r\n    //! The component instance.\r\n    QSharedPointer<ComponentInstance> componentInstance_ = nullptr;\r\n\r\n    //! The name label.\r\n    QGraphicsTextItem* nameLabel_= new QGraphicsTextItem(this);\r\n\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n\r\n#endif // COMPONENTITEM_H\r\n"
  },
  {
    "path": "common/graphicsItems/ConnectionEndpoint.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ConnectionEndpoint.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Joni-Matti Maatta\r\n// Date: 4.6.2012\r\n//\r\n// Description:\r\n// Base class for connection endpoints (both SW and HW).\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"ConnectionEndpoint.h\"\r\n\r\n#include \"GraphicsConnection.h\"\r\n\r\n#include <IPXACTmodels/Component/BusInterface.h>\r\n#include <IPXACTmodels/Component/Component.h>\r\n#include <IPXACTmodels/kactusExtensions/ApiInterface.h>\r\n#include <IPXACTmodels/kactusExtensions/ComInterface.h>\r\n\r\n#include <common/KactusColors.h>\r\n\r\n#include <QGraphicsScene>\r\n#include <QPen>\r\n#include \"editors/HWDesign/OffPageConnectorItem.h\"\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ConnectionEndpoint::ConnectionEndpoint()\r\n//-----------------------------------------------------------------------------\r\nConnectionEndpoint::ConnectionEndpoint(QGraphicsItem* parent /*= 0*/) :\r\nQGraphicsPolygonItem(parent)\r\n{\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ConnectionEndpoint::~ConnectionEndpoint()\r\n//-----------------------------------------------------------------------------\r\nConnectionEndpoint::~ConnectionEndpoint()\r\n{\r\n    emit destroyed(this);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ConnectionEndpoint::setHighlight()\r\n//-----------------------------------------------------------------------------\r\nvoid ConnectionEndpoint::setHighlight(HighlightMode mode)\r\n{\r\n    if (mode == HIGHLIGHT_OFF)\r\n    {\r\n        if (isInvalid())\r\n        {\r\n            setPen(QPen(Qt::red, 0));\r\n        }\r\n        else\r\n        {\r\n            setPen(QPen(Qt::black, 0));\r\n        }\r\n    }\r\n    else if (mode == HIGHLIGHT_ALLOWED)\r\n    {\r\n        setPen(QPen(KactusColors::DIAGRAM_ALLOWED_INTERFACE, 2));\r\n    }\r\n    else if (mode == HIGHLIGHT_HOVER)\r\n    {\r\n        setPen(QPen(KactusColors::DIAGRAM_SELECTION, 2));\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ConnectionEndpoint::setSelectionHighlight()\r\n//-----------------------------------------------------------------------------\r\nvoid ConnectionEndpoint::setSelectionHighlight(bool on)\r\n{\r\n    if (on)\r\n    {\r\n        setHighlight(HIGHLIGHT_HOVER);\r\n    }\r\n    else\r\n    {\r\n        setHighlight(HIGHLIGHT_OFF);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ConnectionEndpoint::addConnection()\r\n//-----------------------------------------------------------------------------\r\nvoid ConnectionEndpoint::addConnection(GraphicsConnection* connection)\r\n{\r\n     connections_.append(connection);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ConnectionEndpoint::removeConnection()\r\n//-----------------------------------------------------------------------------\r\nvoid ConnectionEndpoint::removeConnection(GraphicsConnection* connection)\r\n{\r\n    connections_.removeAll(connection);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ConnectionEndpoint::getConnections()\r\n//-----------------------------------------------------------------------------\r\nQList<GraphicsConnection*> const& ConnectionEndpoint::getConnections() const\r\n{\r\n    return connections_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ConnectionEndpoint::isConnected()\r\n//-----------------------------------------------------------------------------\r\nbool ConnectionEndpoint::isConnected() const\r\n{\r\n    return (!connections_.empty());\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ConnectionEndpoint::beginUpdateConnectionPositions()\r\n//-----------------------------------------------------------------------------\r\nvoid ConnectionEndpoint::beginUpdateConnectionPositions() const\r\n{\r\n    for (QGraphicsItem* item : scene()->items())\r\n    {\r\n        auto conn = dynamic_cast<GraphicsConnection*>(item);\r\n        if (conn != nullptr)\r\n        {\r\n            conn->beginUpdatePosition();\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ConnectionEndpoint::endUpdateConnectionPositions()\r\n//-----------------------------------------------------------------------------\r\nvoid ConnectionEndpoint::endUpdateConnectionPositions(QUndoCommand* parentCommand) const\r\n{\r\n    for (QGraphicsItem* item : scene()->items())\r\n    {\r\n        auto conn = dynamic_cast<GraphicsConnection*>(item);\r\n        if (conn != nullptr)\r\n        {\r\n            conn->endUpdatePosition(parentCommand);\r\n        }\r\n    }\r\n}\r\n//-----------------------------------------------------------------------------\r\n// Function: ConnectionEndpoint::updateConnectionPositions()\r\n//-----------------------------------------------------------------------------\r\nvoid ConnectionEndpoint::updateConnectionPositions() const \r\n{\r\n    for (GraphicsConnection* connection : getConnections())\r\n    {\r\n        connection->updatePosition();\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ConnectionEndpoint::onDisconnect()\r\n//-----------------------------------------------------------------------------\r\nvoid ConnectionEndpoint::onDisconnect()\r\n{\r\n    // Intentionally empty.\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ConnectionEndpoint::canConnect()\r\n//-----------------------------------------------------------------------------\r\nbool ConnectionEndpoint::canConnect(ConnectionEndpoint const* other) const\r\n{\r\n    if (isConnected() && isExclusive())\r\n    {\r\n        return false;\r\n    }\r\n\r\n    return isConnectionValid(other);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ConnectionEndpoint::setDirection()\r\n//-----------------------------------------------------------------------------\r\nvoid ConnectionEndpoint::setDirection(QVector2D const& dir)\r\n{\r\n    // Determine the rotation based on the new direction.\r\n    if (qFuzzyCompare(dir, QVector2D(0.0f, -1.0f)))\r\n    {\r\n        setRotation(0.0);\r\n    }\r\n    else if (qFuzzyCompare(dir, QVector2D(0.0f, 1.0f)))\r\n    {\r\n        setRotation(180.0);\r\n    }\r\n    else if (qFuzzyCompare(dir, QVector2D(1.0f, 0.0f)))\r\n    {\r\n        setRotation(90.0);\r\n    }\r\n    else if (qFuzzyCompare(dir, QVector2D(-1.0f, 0.0f)))\r\n    {\r\n        setRotation(-90.0);\r\n    }\r\n\r\n    dir_ = dir;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ConnectionEndpoint::getDirection()\r\n//-----------------------------------------------------------------------------\r\nQVector2D ConnectionEndpoint::getDirection() const\r\n{\r\n    return dir_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ConnectionEndpoint::updateInterface()\r\n//-----------------------------------------------------------------------------\r\nvoid ConnectionEndpoint::updateInterface()\r\n{\r\n    if (isInvalid())\r\n    {\r\n        setPen(QPen(Qt::red, 0));\r\n    }\r\n    else\r\n    {\r\n        setPen(QPen(Qt::black, 0));\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ConnectionEndpoint::isDirectionFixed()\r\n//-----------------------------------------------------------------------------\r\nbool ConnectionEndpoint::isDirectionFixed() const noexcept\r\n{\r\n    // The endpoint direction is not fixed by default.\r\n    return false;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ConnectionEndpoint::getBusInterface()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<BusInterface> ConnectionEndpoint::getBusInterface() const\r\n{\r\n    return nullptr;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ConnectionEndpoint::getComInterface()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<ComInterface> ConnectionEndpoint::getComInterface() const\r\n{\r\n    return nullptr;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ConnectionEndpoint::getApiInterface()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<ApiInterface> ConnectionEndpoint::getApiInterface() const\r\n{\r\n    return nullptr;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ConnectionEndpoint::getPort()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<Port> ConnectionEndpoint::getPort() const\r\n{\r\n    return nullptr;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ConnectionEndpoint::isBus()\r\n//-----------------------------------------------------------------------------\r\nbool ConnectionEndpoint::isBus() const noexcept\r\n{\r\n    return false;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ConnectionEndpoint::isAdHoc()\r\n//-----------------------------------------------------------------------------\r\nbool ConnectionEndpoint::isAdHoc() const noexcept\r\n{\r\n    return false;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ConnectionEndpoint::isCom()\r\n//-----------------------------------------------------------------------------\r\nbool ConnectionEndpoint::isCom() const noexcept\r\n{\r\n    return false;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ConnectionEndpoint::isApi()\r\n//-----------------------------------------------------------------------------\r\nbool ConnectionEndpoint::isApi() const noexcept\r\n{\r\n    return false;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ConnectionEndpoint::getType()\r\n//-----------------------------------------------------------------------------\r\nConnectionEndpoint::EndpointType ConnectionEndpoint::getType() const noexcept\r\n{\r\n    return ConnectionEndpoint::ENDPOINT_TYPE_UNDEFINED;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ConnectionEndpoint::getOffPageConnector()\r\n//-----------------------------------------------------------------------------\r\nConnectionEndpoint* ConnectionEndpoint::getOffPageConnector() const\r\n{\r\n    return nullptr;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ConnectionEndpoint::getParentConnector()\r\n//-----------------------------------------------------------------------------\r\nConnectionEndpoint* ConnectionEndpoint::getParentConnector() const\r\n{\r\n    return nullptr;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ConnectionEndpoint::setTemporary()\r\n//-----------------------------------------------------------------------------\r\nvoid ConnectionEndpoint::setTemporary(bool temp)\r\n{\r\n    temporary_ = temp;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ConnectionEndpoint::isTemporary()\r\n//-----------------------------------------------------------------------------\r\nbool ConnectionEndpoint::isTemporary() const noexcept\r\n{\r\n    return temporary_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ConnectionEndpoint::isInvalid()\r\n//-----------------------------------------------------------------------------\r\nbool ConnectionEndpoint::isInvalid() const\r\n{\r\n    return (temporary_ && getOwnerComponent()->getVlnv().isValid());\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ConnectionEndpoint::setTypeLocked()\r\n//-----------------------------------------------------------------------------\r\nvoid ConnectionEndpoint::setTypeLocked(bool locked)\r\n{\r\n    typeLocked_ = locked;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ConnectionEndpoint::isTypeLocked()\r\n//-----------------------------------------------------------------------------\r\nbool ConnectionEndpoint::isTypeLocked() const\r\n{\r\n    return typeLocked_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ConnectionEndpoint::isConnectionValid()\r\n//-----------------------------------------------------------------------------\r\nbool ConnectionEndpoint::isConnectionValid(ConnectionEndpoint const* other) const\r\n{\r\n    // Invalid endpoints cannot be connected to.\r\n    // Two hierarchical endpoints cannot be connected.\r\n    if (isInvalid() || (!isAdHoc() && isHierarchical() && other->isHierarchical()))\r\n    {\r\n        return false;\r\n    }\r\n\r\n    // Prevent double connections\r\n    ConnectionEndpoint* thisOffPage = this->getOffPageConnector();\r\n    ConnectionEndpoint* otherOffPage = other->getOffPageConnector();\r\n    ConnectionEndpoint* thisParent = this->getParentConnector();\r\n    ConnectionEndpoint* otherParent = other->getParentConnector();\r\n\r\n    // All possible combinations are handled below.\r\n    if (!other->isOffPage())\r\n    {\r\n        if (!this->isOffPage())\r\n        {\r\n            return !(connectionToPointExists(other) ||\r\n                (thisOffPage && otherOffPage && thisOffPage->connectionToPointExists(otherOffPage)));\r\n        }\r\n        else \r\n        {\r\n            return !((otherOffPage && connectionToPointExists(otherOffPage) ||\r\n                thisParent->connectionToPointExists(other)));\r\n        }\r\n    }\r\n    else \r\n    {\r\n        if (!this->isOffPage())\r\n        {\r\n            return !(connectionToPointExists(otherParent) ||\r\n                (thisOffPage && thisOffPage->connectionToPointExists(other)));\r\n        }\r\n        else\r\n        {\r\n            return !(connectionToPointExists(other) ||\r\n                (thisParent->connectionToPointExists(otherParent)));\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ConnectionEndpoint::revalidateConnectionToEndpoint()\r\n//-----------------------------------------------------------------------------\r\nbool ConnectionEndpoint::isExistingConnectionValid(ConnectionEndpoint const* other) const\r\n{\r\n\tif (isInvalid() || (!isAdHoc() && isHierarchical() && other->isHierarchical()))\r\n\t{\r\n\t\treturn false;\r\n\t}\r\n\r\n\treturn std::any_of(other->getConnections().cbegin(), other->getConnections().cend(),\r\n\t\t[this](GraphicsConnection const* connection)\r\n\t\t{\r\n\t\t\treturn connection->endpoint1() == this || connection->endpoint2() == this;\r\n\t\t});\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ConnectionEndpoint::revalidateConnections()\r\n//-----------------------------------------------------------------------------\r\nvoid ConnectionEndpoint::revalidateConnections()\r\n{\r\n    for (GraphicsConnection* conn : getConnections())\r\n    {\r\n\t\tconn->reValidate();\r\n    }\r\n\r\n    if (getOffPageConnector() != nullptr)\r\n    {\r\n        for (GraphicsConnection* conn : getOffPageConnector()->getConnections())\r\n        {\r\n\t\t\tconn->reValidate();\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ConnectionEndpoint::beginUpdateConnectionNames()\r\n//-----------------------------------------------------------------------------\r\nvoid ConnectionEndpoint::beginUpdateConnectionNames()\r\n{\r\n    Q_ASSERT(connUpdateList_.isEmpty());\r\n\r\n    for (GraphicsConnection* conn : getConnections())\r\n    {\r\n        if (conn->hasDefaultName())\r\n        {\r\n            connUpdateList_.append(conn);\r\n        }\r\n    }\r\n\r\n    if (getOffPageConnector() != nullptr)\r\n    {\r\n        for (GraphicsConnection* conn : getOffPageConnector()->getConnections())\r\n        {\r\n            connUpdateList_.append(conn);\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ConnectionEndpoint::endUpdateConnectionNames()\r\n//-----------------------------------------------------------------------------\r\nvoid ConnectionEndpoint::endUpdateConnectionNames()\r\n{\r\n    for (GraphicsConnection* conn: connUpdateList_)\r\n    {\r\n        conn->setName(conn->createDefaultName());\r\n    }\r\n\r\n    connUpdateList_.clear();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ConnectionEndpoint::connectionToPointExists()\r\n//-----------------------------------------------------------------------------\r\nbool ConnectionEndpoint::connectionToPointExists(ConnectionEndpoint const* other) const\r\n{\r\n    return std::any_of(\r\n        other->getConnections().cbegin(),\r\n        other->getConnections().cend(),\r\n        [this](GraphicsConnection const* connection)\r\n        {\r\n            return connection->endpoint1() == this || connection->endpoint2() == this;\r\n        });\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ConnectionEndpoint::getInterfaceMode()\r\n//-----------------------------------------------------------------------------\r\nGeneral::InterfaceMode ConnectionEndpoint::getInterfaceMode() const\r\n{\r\n    return General::INTERFACE_MODE_COUNT;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ConnectionEndpoint::getNameLength()\r\n//-----------------------------------------------------------------------------\r\nqreal ConnectionEndpoint::getNameLength()\r\n{\r\n    return 0;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ConnectionEndpoint::shortenNameLabel()\r\n//-----------------------------------------------------------------------------\r\nvoid ConnectionEndpoint::shortenNameLabel( qreal /*width */)\r\n{\r\n    // Intentionally empty.\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ConnectionEndpoint::isOffPage()\r\n//-----------------------------------------------------------------------------\r\nbool ConnectionEndpoint::isOffPage() const\r\n{\r\n    return type() == OffPageConnectorItem::Type;\r\n}"
  },
  {
    "path": "common/graphicsItems/ConnectionEndpoint.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ConnectionEndpoint.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Joni-Matti Maatta\r\n// Date: 4.6.2012\r\n//\r\n// Description:\r\n// Base class for connection endpoints (both SW and HW).\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef CONNECTIONENDPOINT_H\r\n#define CONNECTIONENDPOINT_H\r\n\r\n#include <IPXACTmodels/common/DirectionTypes.h>\r\n#include <IPXACTmodels/Component/Component.h>\r\n\r\n#include <QList>\r\n#include <QPointF>\r\n#include <QVector2D>\r\n#include <QSharedPointer>\r\n#include <QGraphicsPolygonItem>\r\n#include <QUndoCommand>\r\n\r\nclass ApiInterface;\r\nclass Component;\r\nclass ComponentItem;\r\nclass ComInterface;\r\nclass BusInterface;\r\nclass GraphicsConnection;\r\nclass Port;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Base class for connection endpoints (both SW and HW).\r\n//-----------------------------------------------------------------------------\r\nclass ConnectionEndpoint : public QObject, public QGraphicsPolygonItem\r\n{\r\n    Q_OBJECT\r\n\r\npublic:\r\n    //-----------------------------------------------------------------------------\r\n    //! HighlightMode enumeration.\r\n    //-----------------------------------------------------------------------------\r\n    enum HighlightMode\r\n    {\r\n        HIGHLIGHT_OFF = 0,\r\n        HIGHLIGHT_ALLOWED,\r\n        HIGHLIGHT_HOVER,\r\n    };\r\n\r\n    //-----------------------------------------------------------------------------\r\n    //! Endpoint type enumeration.\r\n    //-----------------------------------------------------------------------------\r\n    enum EndpointType\r\n    {\r\n        ENDPOINT_TYPE_UNDEFINED = 0,    //!< The endpoint type is not set.\r\n        ENDPOINT_TYPE_API,              //!< The endpoint is an API interface.\r\n        ENDPOINT_TYPE_COM,              //!< The endpoint is a COM interface.\r\n        ENDPOINT_TYPE_BUS,              //!< The endpoint is a bus interface.\r\n        ENDPOINT_TYPE_ADHOC             //!< The endpoint is an ad-hoc port.\r\n    };\r\n\r\n    /*!\r\n     *  Constructor.\r\n     *\r\n     *    @param [in] parent     The parent graphics item.\r\n     */\r\n    ConnectionEndpoint(QGraphicsItem* parent = 0);\r\n\r\n    /*!\r\n     *  Destructor.\r\n     */\r\n    ~ConnectionEndpoint() override;\r\n\r\n\r\n    // Disable copying.\r\n    ConnectionEndpoint(ConnectionEndpoint const& rhs) = delete;\r\n    ConnectionEndpoint& operator=(ConnectionEndpoint const& rhs) = delete;\r\n\r\n    /*!\r\n     *  Sets the highlighting mode.\r\n     *\r\n     *    @param [in] mode The highlight mode.\r\n     */\r\n    void setHighlight(HighlightMode mode);\r\n\r\n    /*!\r\n     *  Sets the selection highlight on/off.\r\n     *\r\n     *    @param [in] on If true, the selection highlight is turned on. Otherwise it is turned off.\r\n     */\r\n    virtual void setSelectionHighlight(bool on);\r\n\r\n    /*!\r\n     *  Attaches the endpoint to a connection.\r\n     *\r\n     *    @param [in] connection The connection.\r\n     */\r\n    virtual void addConnection(GraphicsConnection* connection);\r\n\r\n    /*!\r\n     *  Unattaches the endpoint from a connection.\r\n     *\r\n     *    @param [in] connection The connection.\r\n     */\r\n    virtual void removeConnection(GraphicsConnection* connection);\r\n\r\n    /*!\r\n     *  Returns the list of connections that are connected to this endpoint.\r\n     */\r\n    virtual QList<GraphicsConnection*> const& getConnections() const;\r\n\r\n    /*!\r\n     *  Revalidates all connections.\r\n     */\r\n    void revalidateConnections();\r\n\r\n    /*!\r\n     *  Returns true if the endpoint has at least one connection.\r\n     */\r\n    bool isConnected() const;\r\n\r\n\r\n    /*!\r\n     *  Update the connection positions of the associated end points.\r\n     */\r\n    void beginUpdateConnectionPositions() const;\r\n\r\n    void endUpdateConnectionPositions(QUndoCommand* parentCommand) const;\r\n\r\n    void updateConnectionPositions() const;\r\n    \r\n    /*!\r\n     *  Called when a connection between this and another endpoint is done.\r\n     *\r\n     *    @param [in] other The other endpoint of the connection.\r\n     *\r\n     *    @return False if there was an error in the connection. Otherwise true.\r\n     */\r\n    virtual bool onConnect(ConnectionEndpoint const* other) = 0;\r\n\r\n    /*!\r\n     *  Called when a connection has been removed from between this and another endpoint.\r\n     *\r\n     *    @param [in] other The other endpoint of the connection.\r\n     */\r\n    virtual void onDisconnect();\r\n\r\n    /*! \r\n     *  Returns true if this endpoint can be connected to the given endpoint, taking existing\r\n     *  connections into account.\r\n     *\r\n     *    @param [in] other The endpoint to which to connect.\r\n     */\r\n    virtual bool canConnect(ConnectionEndpoint const* other) const;\r\n\r\n    /*!\r\n     *  Returns true if a connection is valid between the two endpoints.\r\n     *\r\n     *    @param [in] other     The other endpoint.\r\n     * \r\n     *    @return Boolean true if two endpoints can be connected, otherwise false.\r\n     */\r\n    virtual bool isConnectionValid(ConnectionEndpoint const* other) const;\r\n\r\n    /*!\r\n     *  Check if an existing connection is valid.\r\n     *\r\n     *    @param [in] other     The other endpoint of a connection.\r\n     *\r\n     *    @return True, if the two end points are connected, otherwise false.\r\n     */\r\n    virtual bool isExistingConnectionValid(ConnectionEndpoint const* other) const;\r\n\r\n    /*!\r\n     *  Returns true if the endpoint is exclusive, i.e. can only have one connection.\r\n     */\r\n    virtual bool isExclusive() const = 0;\r\n\r\n    /*!\r\n     *  Sets the draw direction of the endpoint.\r\n     *\r\n     *    @param [in] dir The draw direction to set.\r\n     *\r\n     *      @remarks The direction can be changed only if isDirectionFixed() returns false.\r\n     */\r\n    virtual void setDirection(QVector2D const& dir);\r\n\r\n    /*!\r\n\t *\tReturns the draw direction of the endpoint.\r\n\t */\r\n\tvirtual QVector2D getDirection() const;\r\n\r\n    /*!\r\n     *  Returns true if the draw direction is fixed and thus, cannot be changed.\r\n     */\r\n    virtual bool isDirectionFixed() const noexcept;\r\n\r\n    /*! \r\n     *  Returns the name of the endpoint.\r\n     */\r\n    virtual QString name() const = 0;\r\n\r\n\t/*! Set the name of the endpoint.\r\n\t *\r\n\t * \\param name The name to set for the endpoint.\r\n\t *\r\n\t*/\r\n\tvirtual void setName(QString const& name) = 0;\r\n\r\n\t/*! Get the description of the endpoint.\r\n\t *\r\n\t *\r\n\t * \\return QString contains the description.\r\n\t*/\r\n\tvirtual QString description() const = 0;\r\n\r\n\t/*! Set the description for the endpoint.\r\n\t *\r\n\t * \\param description Contains the description to set.\r\n\t *\r\n\t*/\r\n\tvirtual void setDescription(QString const& description) = 0;\r\n\r\n    /*!\r\n     *  Updates the endpoint interface.\r\n     */\r\n    virtual void updateInterface() = 0;\r\n\r\n    /*! \r\n     *  Returns the encompassing component, if the endpoint represents a COM/API interface on a component.\r\n     */\r\n    virtual ComponentItem* encompassingComp() const = 0;\r\n\r\n\t/*!\r\n     *  Returns pointer to the top component that owns this interface.\r\n\t */\r\n\tvirtual QSharedPointer<Component> getOwnerComponent() const = 0;\r\n\r\n    /*! \r\n     *  Returns the IP-XACT bus interface model of the endpoint.\r\n     *\r\n     *      @remarks The function returns a null pointer if the endpoint is not a bus interface.\r\n     *               Use isBus() function to check for bus interface support.\r\n     */\r\n    virtual QSharedPointer<BusInterface> getBusInterface() const;\r\n\r\n    /*! \r\n     *  Returns the COM interface model of the endpoint.\r\n     *\r\n     *      @remarks The function returns a null pointer if the endpoint is not a COM interface.\r\n     *               Use isCom() function to check for COM interface support.\r\n     */\r\n    virtual QSharedPointer<ComInterface> getComInterface() const;\r\n\r\n    /*! \r\n     *  Returns the API interface model of the endpoint.\r\n     *\r\n     *      @remarks The function returns a null pointer if the endpoint is not a API interface.\r\n     *               Use isApi() function to check for API interface support.\r\n     */\r\n    virtual QSharedPointer<ApiInterface> getApiInterface() const;\r\n\r\n    /*!\r\n     *  Returns the ad-hoc port of the endpoint.\r\n     *\r\n     *      @remarks The function returns a null pointer if the endpoint is a bus interface.\r\n     *               Use isAdHoc() function to check for ad-hoc support.\r\n     */\r\n    virtual QSharedPointer<Port> getPort() const;\r\n\r\n    /*!\r\n     *  Returns the corresponding off-page connector or a null pointer if the endpoint does not have one.\r\n     */\r\n    virtual ConnectionEndpoint* getOffPageConnector() const;\r\n\r\n    /*!\r\n     *  Returns the corresponding parent connector or a null pointer if the endpoint is not off-page.\r\n     */\r\n    virtual ConnectionEndpoint* getParentConnector() const;\r\n\r\n    /*!\r\n     *  Returns true if the endpoint represents a hierarchical connection.\r\n     */\r\n    virtual bool isHierarchical() const noexcept = 0;\r\n\r\n    /*!\r\n     *  Returns true if the endpoint is a bus interface endpoint.\r\n     */\r\n    virtual bool isBus() const noexcept;\r\n\r\n    /*!\r\n     *  Returns true if the endpoint is an ad-hoc port.\r\n     */\r\n    virtual bool isAdHoc() const noexcept;\r\n\r\n    /*!\r\n     *  Returns true if the endpoint is a COM interface endpoint.\r\n     */\r\n    virtual bool isCom() const noexcept;\r\n\r\n    /*!\r\n     *  Returns true if the endpoint is an API interface endpoint.\r\n     */\r\n    virtual bool isApi() const noexcept;\r\n\r\n    /*!\r\n     *  Returns the type of the endpoint (API/COM/bus/ad-hoc/undefined).\r\n     */\r\n    virtual EndpointType getType() const noexcept;\r\n\r\n    /*!\r\n     *  Sets the endpoint temporary or not temporary. Temporary endpoints can be deleted.\r\n     *\r\n     *    @param [in] temp True if temporary; false if not temporary.\r\n     */\r\n    virtual void setTemporary(bool temp);\r\n\r\n    /*!\r\n     *  Returns true if the endpoint is temporary.\r\n     */\r\n    bool isTemporary() const noexcept;\r\n\r\n    /*!\r\n     *  Returns true if the endpoint is invalid (i.e. a removed one).\r\n     */\r\n    bool isInvalid() const;\r\n\r\n    /*!\r\n     *  Sets the endpoint type locked or not. A locked endpoint has a strict type, while a non-locked\r\n     *  endpoint automatically adjusts its type when connections are added/removed.\r\n     *\r\n     *    @param [in] typed If true, the endpoint is set as typed.\r\n     */\r\n    void setTypeLocked(bool typed);\r\n\r\n    /*!\r\n     *  Returns true if the endpoint's type is locked.\r\n     */\r\n    bool isTypeLocked() const;\r\n\r\n    /*!\r\n     *  Get the interface mode of the connected bus interface.\r\n     *\r\n     *    @return The interface mode of the end point.\r\n     */\r\n    virtual General::InterfaceMode getInterfaceMode() const;\r\n    \r\n    /*!\r\n\t *  Return the correct length of the name label.\r\n\t */\r\n\tvirtual qreal getNameLength();\r\n\r\n\t/*!\r\n\t *  Shorten the name label to better fit the component.\r\n\t *  \r\n\t *    @param [in] width   The width of the shortened name.\r\n\t */\r\n\tvirtual void shortenNameLabel( qreal width );\r\n\r\n    /*!\r\n     *  Checks if the endpoint is off-page.\r\n     *\r\n     *    @return     Boolean true if endpoint is off-page, otherwise false.\r\n     */\r\n    bool isOffPage() const;\r\n\r\nsignals:\r\n    //! Signals that the contents of the interface have been changed.\r\n    void contentChanged();\r\n\r\n    //! Emitted when the endpoint is destroyed.\r\n    void destroyed(ConnectionEndpoint* endpoint);\r\n\r\n    //! Emitted when the end point has been moved.\r\n    void moved(ConnectionEndpoint* endpoint);\r\n\r\nprotected:\r\n    /*!\r\n     *  Begins updating connection names.\r\n     */\r\n    void beginUpdateConnectionNames();\r\n\r\n    /*!\r\n     *  Ends updating connection names.\r\n     */\r\n    void endUpdateConnectionNames();\r\n\r\nprivate:\r\n\r\n    /*!\r\n     *  Checks if points are connected\r\n     *\r\n     *    @param [in] other The other endpoint.\r\n     * \r\n     *    @return     Boolean true is the points are connected, otherwise false.\r\n     *\r\n     *      @remarks    Does  not take into account weather points are off-page\r\n                        or not, thus checking two points directly.\r\n     */\r\n    bool connectionToPointExists(ConnectionEndpoint const* other) const;\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! The endpoint's direction.\r\n    QVector2D dir_;\r\n\r\n    //! The connections to this endpoint.\r\n    QList<GraphicsConnection*> connections_;\r\n\r\n    //! Boolean flag for determining if the endpoint is temporary or not.\r\n    bool temporary_ = false;\r\n\r\n    //! Boolean flag for determining if the endpoint is typed or not (non-typed).\r\n    bool typeLocked_ = true;\r\n\r\n    //! Connection update list.\r\n    QList<GraphicsConnection*> connUpdateList_;\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n\r\n#endif // CONNECTIONENDPOINT_H\r\n"
  },
  {
    "path": "common/graphicsItems/ConnectionItem.h",
    "content": "//-----------------------------------------------------------------------------\n// File: ConnectionItem.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Esko Pekkarinen\n// Date: 01.06.2023\n//\n// Description:\n// Template for classes inheriting GraphicsConnection.\n//-----------------------------------------------------------------------------\n\n#ifndef CONNECTION_ITEM_H\n#define CONNECTION_ITEM_H\n\n#include \"GraphicsConnection.h\"\n\n#include <QSharedPointer>\n\n//-----------------------------------------------------------------------------\n//! Template for classes inheriting GraphicsConnection.\n//-----------------------------------------------------------------------------\ntemplate <typename T> \nclass ConnectionItem : public GraphicsConnection\n{\npublic:\n\n    /*!\n     *  Constructor.\n     */\n    ConnectionItem(ConnectionEndpoint* endpoint1, ConnectionEndpoint* endpoint2,\n        QSharedPointer<T> interconnection,\n        QSharedPointer<ConnectionRoute> route, bool autoConnect,\n        DesignDiagram* parent);\n\n    /*!\n     *  Constructor which creates an open-ended connection.\n     */\n    ConnectionItem(QPointF const& p1, QVector2D const& dir1,\n        QPointF const& p2, QVector2D const& dir2,\n        DesignDiagram* parent);\n\n    // Disable copying.\n    ConnectionItem(ConnectionItem const& rhs) = delete;\n    ConnectionItem& operator=(ConnectionItem const& rhs) = delete;\n\n    /*!\n     *  Set the name for the connection item.\n     *\n     *    @param [in] name    The new connection item name.\n     */\n    void setName(QString const& name) final;\n\n    /*!\n     *  Get the name of the connection item.\n     *\n     *    @return The name of the connection item.\n     */\n    QString name() const final;\n\n    /*!\n     *  Set the description for the connection item.\n     *\n     *    @param [in] description     The new description.\n     */\n    void setDescription(QString const& description) final;\n\n    /*!\n     *  Get the description for the connection item.\n     *\n     *    @return The description of the connection item.\n     */\n    QString description() const final;\n\n    /*!\n     *  Get the contained interconnection.\n     *\n     *    @return The interconnection contained within this item.\n     */\n    QSharedPointer<T> getInterconnection();\n\n    /*!\n     *  Change the component reference of a contained interface.\n     *\n     *    @param [in] oldName     The old component reference.\n     *    @param [in] newName     The new component reference.\n     */\n    void changeConnectionComponentReference(QString const& oldName, QString const& newName) final;\n\nprivate:\n\n    //-----------------------------------------------------------------------------\n    // Data.\n    //-----------------------------------------------------------------------------\n\n    //! The contained interconnection.\n    QSharedPointer<T> interconnection_;\n};\n\n#include \"ConnectionItem.inl\"\n//-----------------------------------------------------------------------------\n\n#endif // CONNECTION_ITEM_H\n"
  },
  {
    "path": "common/graphicsItems/ConnectionItem.inl",
    "content": "//-----------------------------------------------------------------------------\n// File: HWConnection.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Esko Pekkarinen\n// Date: 01.06.2023\n//\n// Description:\n// Template for classes inheriting GraphicsConnection.\n//-----------------------------------------------------------------------------\n\n\n//-----------------------------------------------------------------------------\n// Function: ConnectionItem::ConnectionItem()\n//-----------------------------------------------------------------------------\ntemplate <typename T> ConnectionItem<T>::ConnectionItem(ConnectionEndpoint* endpoint1, ConnectionEndpoint* endpoint2,\n    QSharedPointer<T> interconnection,\n    QSharedPointer<ConnectionRoute> route, bool autoConnect,\n    DesignDiagram* parent) :\n    GraphicsConnection(endpoint1, endpoint2, route, autoConnect, parent),\n    interconnection_(interconnection)\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: ConnectionItem::ConnectionItem()\n//-----------------------------------------------------------------------------\ntemplate <typename T> ConnectionItem<T>::ConnectionItem(QPointF const& p1, QVector2D const& dir1,\n    QPointF const& p2, QVector2D const& dir2,\n    DesignDiagram* parent):\n    GraphicsConnection(p1, dir1, p2, dir2, parent)\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: ConnectionItem::setName()\n//-----------------------------------------------------------------------------\ntemplate <typename T> void ConnectionItem<T>::setName(QString const& name)\n{\n    GraphicsConnection::setName(name);\n    interconnection_->setName(name);\n\n    emit contentChanged();\n}\n\n//-----------------------------------------------------------------------------\n// Function: ConnectionItem::name()\n//-----------------------------------------------------------------------------\ntemplate <typename T> QString ConnectionItem<T>::name() const\n{\n    return interconnection_->name();\n}\n\n//-----------------------------------------------------------------------------\n// Function: ConnectionItem::setDescription()\n//-----------------------------------------------------------------------------\ntemplate <typename T> void ConnectionItem<T>::setDescription(QString const& description)\n{\n    interconnection_->setDescription(description);\n\n    emit contentChanged();\n}\n\n//-----------------------------------------------------------------------------\n// Function: ConnectionItem::description()\n//-----------------------------------------------------------------------------\ntemplate <typename T> QString ConnectionItem<T>::description() const\n{\n    return interconnection_->description();\n}\n\n//-----------------------------------------------------------------------------\n// Function: ConnectionItem::getInterconnection()\n//-----------------------------------------------------------------------------\ntemplate <typename T> QSharedPointer<T> ConnectionItem<T>::getInterconnection()\n{\n    return interconnection_;\n}\n\n//-----------------------------------------------------------------------------\n// Function: ConnectionItem::changeConnectionComponentReference()\n//-----------------------------------------------------------------------------\ntemplate <typename T> void ConnectionItem<T>::changeConnectionComponentReference(QString const& oldName, \n    QString const& newName)\n{\n    interconnection_->changeInterfaceComponentReferences(oldName, newName);\n}\n"
  },
  {
    "path": "common/graphicsItems/ConnectionUndoCommands.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ConnectionUndoCommands.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Joni-Matti Maatta\r\n// Date: 5.6.2012\r\n//\r\n// Description:\r\n// Undo commands for graphical connections.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"ConnectionUndoCommands.h\"\r\n\r\n#include \"GraphicsConnection.h\"\r\n\r\n#include <QGraphicsScene>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ConnectionMoveCommand()\r\n//-----------------------------------------------------------------------------\r\nConnectionMoveCommand::ConnectionMoveCommand(GraphicsConnection* conn,\r\n                                             QList<QPointF> const& oldRoute,\r\n                                             QUndoCommand* parent)\r\n    : QUndoCommand(parent),\r\n      conn_(conn), oldRoute_(oldRoute),\r\n      newRoute_(conn->route())\r\n{\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ~ConnectionMoveCommand()\r\n//-----------------------------------------------------------------------------\r\nConnectionMoveCommand::~ConnectionMoveCommand()\r\n{\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: undo()\r\n//-----------------------------------------------------------------------------\r\nvoid ConnectionMoveCommand::undo()\r\n{\r\n    conn_->setRoute(oldRoute_);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: redo()\r\n//-----------------------------------------------------------------------------\r\nvoid ConnectionMoveCommand::redo()\r\n{\r\n    conn_->setRoute(newRoute_);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ConnectionChangeCommand()\r\n//-----------------------------------------------------------------------------\r\nConnectionChangeCommand::ConnectionChangeCommand(\r\n    GraphicsConnection* connection, \r\n    QString const& newName,\r\n    QString const& newDescription,\r\n    QUndoCommand* parent ) : QUndoCommand(parent),\r\n    connection_(connection),\r\n    newName_(newName),\r\n    newDescription_(newDescription),\r\n    oldName_(connection->name()),\r\n    oldDescription_(connection->description())\r\n{\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: undo()\r\n//-----------------------------------------------------------------------------\r\nvoid ConnectionChangeCommand::undo()\r\n{\r\n    connection_->setName(oldName_);\r\n    connection_->setDescription(oldDescription_);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: redo()\r\n//-----------------------------------------------------------------------------\r\nvoid ConnectionChangeCommand::redo()\r\n{\r\n    connection_->setName(newName_);\r\n    connection_->setDescription(newDescription_);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ConnectionExchangeCommand::ConnectionExchangeCommand()\r\n//-----------------------------------------------------------------------------\r\nConnectionExchangeCommand::ConnectionExchangeCommand(GraphicsConnection* connection,\r\n    ConnectionEndpoint* oldEndpoint, ConnectionEndpoint* newEndpoint, QUndoCommand* parent):\r\nQUndoCommand(parent),\r\nconnectionItem_(connection),\r\noldEndpoint_(oldEndpoint),\r\nnewEndpoint_(newEndpoint)\r\n{\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ConnectionExchangeCommand::~ConnectionExchangeCommand()\r\n//-----------------------------------------------------------------------------\r\nConnectionExchangeCommand::~ConnectionExchangeCommand()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ConnectionExchangeCommand::undo()\r\n//-----------------------------------------------------------------------------\r\nvoid ConnectionExchangeCommand::undo()\r\n{        \r\n    if (connectionItem_->endpoint1() == newEndpoint_)\r\n    {\r\n        connectionItem_->setEndpoint1(oldEndpoint_);\r\n    }\r\n    else\r\n    {\r\n        connectionItem_->setEndpoint2(oldEndpoint_);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ConnectionExchangeCommand::redo()\r\n//-----------------------------------------------------------------------------\r\nvoid ConnectionExchangeCommand::redo()\r\n{\r\n    if (connectionItem_->endpoint1() == oldEndpoint_)\r\n    {\r\n        connectionItem_->setEndpoint1(newEndpoint_);\r\n    }\r\n    else\r\n    {\r\n        connectionItem_->setEndpoint2(newEndpoint_);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ConnectionDeleteCommand()\r\n//-----------------------------------------------------------------------------\r\nConnectionToggleOffPageCommand::ConnectionToggleOffPageCommand(GraphicsConnection* conn, QUndoCommand* parent)\r\n    : QUndoCommand(parent),\r\n    conn_(conn)\r\n{\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ~ConnectionToggleOffPageCommand()\r\n//-----------------------------------------------------------------------------\r\nConnectionToggleOffPageCommand::~ConnectionToggleOffPageCommand()\r\n{\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: undo()\r\n//-----------------------------------------------------------------------------\r\nvoid ConnectionToggleOffPageCommand::undo()\r\n{\r\n    QUndoCommand::undo();\r\n\r\n    conn_->scene()->clearSelection();\r\n    conn_->toggleOffPage();\r\n    conn_->setSelected(true);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: redo()\r\n//-----------------------------------------------------------------------------\r\nvoid ConnectionToggleOffPageCommand::redo()\r\n{\r\n    conn_->scene()->clearSelection();\r\n    conn_->toggleOffPage();\r\n    conn_->setSelected(true);\r\n\r\n    QUndoCommand::redo();\r\n}\r\n\r\n"
  },
  {
    "path": "common/graphicsItems/ConnectionUndoCommands.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ConnectionUndoCommands.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Joni-Matti Maatta\r\n// Date: 5.6.2012\r\n//\r\n// Description:\r\n// Undo commands for graphics connections.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef CONNECTIONUNDOCOMMANDS_H\r\n#define CONNECTIONUNDOCOMMANDS_H\r\n\r\n#include <QUndoCommand>\r\n#include <QPointF>\r\n\r\nclass GraphicsConnection;\r\nclass ConnectionEndpoint;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! ConnectionMoveCommand class.\r\n//-----------------------------------------------------------------------------\r\nclass ConnectionMoveCommand : public QUndoCommand\r\n{\r\npublic:\r\n    /*!\r\n     *  Constructor.\r\n     *\r\n     *    @param [in] conn      The interconnection.\r\n     *    @param [in] oldRoute  The old route of the interconnection.\r\n     *    @param [in] parent    The parent command.\r\n     */\r\n    ConnectionMoveCommand(GraphicsConnection* connection, QList<QPointF> const& oldRoute,\r\n                          QUndoCommand* parent = 0);\r\n\r\n    /*!\r\n     *  Destructor.\r\n     */\r\n    ~ConnectionMoveCommand();\r\n\r\n    /*!\r\n     *  Undoes the command.\r\n     */\r\n    virtual void undo();\r\n\r\n    /*!\r\n     *  Redoes the command.\r\n     */\r\n    virtual void redo();\r\n\r\nprivate:\r\n    // Disable copying.\r\n    ConnectionMoveCommand(ConnectionMoveCommand const& rhs);\r\n    ConnectionMoveCommand& operator=(ConnectionMoveCommand const& rhs);\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! The connection.\r\n    GraphicsConnection* conn_;\r\n\r\n    //! The old route of the connection.\r\n    QList<QPointF> oldRoute_;\r\n\r\n    //! The new route of the connection.\r\n    QList<QPointF> newRoute_;\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Undo command for changes made to a DiagramInterConnection.\r\n//-----------------------------------------------------------------------------\r\nclass ConnectionChangeCommand : public QUndoCommand {\r\n\r\npublic:\r\n\r\n\t/*! \\brief The constructor\r\n\t *\r\n\t * \\param connection Pointer to the connection that was changed.\r\n\t * \\param newName The new name of the connection.\r\n\t * \\param newDescription The new description of the connection.\r\n\t * \\param parent Pointer to the parent of this undo command.\r\n\t *\r\n\t*/\r\n    ConnectionChangeCommand(GraphicsConnection* connection,\r\n        QString const& newName,\r\n        QString const& newDescription,\r\n        QUndoCommand* parent = nullptr);\r\n\r\n\t//! \\brief The destructor\r\n\t~ConnectionChangeCommand() final = default;\r\n\r\n\t/*! \\brief Undoes the command.\r\n\t *\r\n\t*/\r\n\tvirtual void undo();\r\n\r\n\t/*! \\brief Redoes the command.\r\n\t *\r\n\t * Redo is automatically executed when this command is added to the undo stack.\r\n\t*/\r\n\tvirtual void redo();\r\n\r\nprivate:\r\n\t//! \\brief No copying\r\n\tConnectionChangeCommand(const ConnectionChangeCommand& other);\r\n\r\n\t//! \\brief No assignment\r\n\tConnectionChangeCommand& operator=(const ConnectionChangeCommand& other);\r\n\r\n\t//! \\brief Pointer to the connection to change.\r\n\tGraphicsConnection* connection_ = nullptr;\r\n\r\n\t//! \\brief The new name for the connection.\r\n    QString newName_;\r\n\r\n\t//! \\brief The new description for the connection.\r\n    QString newDescription_;\r\n\r\n\t//! \\brief The old name of the connection.\r\n    QString oldName_;\r\n\r\n\t//! \\brief The old description of the connection.\r\n    QString oldDescription_;\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n//! ConnectionExchangeCommand class.\r\n//-----------------------------------------------------------------------------\r\nclass ConnectionExchangeCommand : public QUndoCommand\r\n{\r\npublic:\r\n    /*!\r\n     *  Constructor.\r\n     *\r\n     *    @param [in] conn         The connection.\r\n     *    @param [in] oldEndpoint  The old endpoint from which to disconnect the connection.\r\n     *    @param [in] newEndpoint  The new endpoint to which to connect the connection.\r\n     *    @param [in] parent       The parent command.\r\n     */\r\n    ConnectionExchangeCommand(GraphicsConnection* connection, ConnectionEndpoint* oldEndpoint,\r\n                              ConnectionEndpoint* newEndpoint, QUndoCommand* parent = 0);\r\n\r\n    /*!\r\n     *  Destructor.\r\n     */\r\n    ~ConnectionExchangeCommand();\r\n\r\n    /*!\r\n     *  Undoes the command.\r\n     */\r\n    virtual void undo();\r\n\r\n    /*!\r\n     *  Redoes the command.\r\n     */\r\n    virtual void redo();\r\n\r\nprivate:\r\n    // Disable copying.\r\n    ConnectionExchangeCommand(ConnectionExchangeCommand const& rhs);\r\n    ConnectionExchangeCommand& operator=(ConnectionExchangeCommand const& rhs);\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! The connection.\r\n    GraphicsConnection* connectionItem_;\r\n\r\n    //! The old endpoint.\r\n    ConnectionEndpoint* oldEndpoint_;\r\n\r\n    //! The new endpoint.\r\n    ConnectionEndpoint* newEndpoint_;\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n//! ConnectionToggleOffPageCommand class.\r\n//-----------------------------------------------------------------------------\r\nclass ConnectionToggleOffPageCommand : public QUndoCommand\r\n{\r\npublic:\r\n    /*!\r\n     *  Constructor.\r\n     *\r\n     *    @param [in] conn    The interconnection to delete.\r\n     */\r\n    ConnectionToggleOffPageCommand(GraphicsConnection* conn, QUndoCommand* parent = 0);\r\n\r\n    /*!\r\n     *  Destructor.\r\n     */\r\n    ~ConnectionToggleOffPageCommand();\r\n\r\n    /*!\r\n     *  Undoes the command.\r\n     */\r\n    virtual void undo();\r\n\r\n    /*!\r\n     *  Redoes the command.\r\n     */\r\n    virtual void redo();\r\n\r\nprivate:\r\n    // Disable copying.\r\n    ConnectionToggleOffPageCommand(ConnectionToggleOffPageCommand const& rhs);\r\n    ConnectionToggleOffPageCommand& operator=(ConnectionToggleOffPageCommand const& rhs);\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! The interconnection.\r\n    GraphicsConnection* conn_;\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n\r\n#endif // CONNECTIONUNDOCOMMANDS_H\r\n"
  },
  {
    "path": "common/graphicsItems/GraphicsColumn.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: GraphicsColumn.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Joni-Matti Maatta\r\n// Date: 1.6.2012\r\n//\r\n// Description:\r\n// Graphics column class for managing a collection of graphics items in one column.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"GraphicsColumn.h\"\r\n\r\n#include \"GraphicsColumnUndoCommands.h\"\r\n#include \"GraphicsColumnLayout.h\"\r\n\r\n#include <common/IEditProvider.h>\r\n#include <common/KactusColors.h>\r\n\r\n#include <common/layouts/VStackedLayout.h>\r\n#include <common/layouts/VCollisionLayout.h>\r\n\r\n#include <common/graphicsItems/GraphicsColumnConstants.h>\r\n\r\n#include <editors/common/diagramgrid.h>\r\n#include <editors/common/DiagramUtil.h>\r\n#include <editors/common/DesignDiagram.h>\r\n\r\n#include <QPen>\r\n#include <QFont>\r\n#include <QGraphicsSceneMouseEvent>\r\n#include <QCursor>\r\n#include <QApplication>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: GraphicsColumn::GraphicsColumn()\r\n//-----------------------------------------------------------------------------\r\nGraphicsColumn::GraphicsColumn(QSharedPointer<ColumnDesc> desc, GraphicsColumnLayout* layout,\r\n    bool itemsCanTransferToOtherColumns):\r\nQGraphicsRectItem(),\r\nlayout_(layout),\r\ncolumnData_(),\r\nnameLabel_(new QGraphicsTextItem(this)),\r\nitemLayout_(0),\r\nitems_(),\r\noldPos_(),\r\nmouseNearResizeArea_(false),\r\nresizeInProgress_(false),\r\noldWidth_(0),\r\nitemsAreTransferable_(itemsCanTransferToOtherColumns)\r\n{\r\n    setFlag(ItemIsMovable);\r\n    setFlag(ItemIsSelectable);\r\n    setFlag(ItemSendsGeometryChanges);\r\n    setBrush(QBrush(KactusColors::DIAGRAM_COLUMN_HEADER));\r\n    setPen(QPen(Qt::black, 1));\r\n    setAcceptHoverEvents(true);\r\n\r\n    // Update the name label.\r\n    nameLabel_->setAcceptHoverEvents(false);\r\n    QFont font = nameLabel_->font();\r\n    font.setBold(true);\r\n    nameLabel_->setFont(font);\r\n\r\n    setColumnDesc(desc);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: GraphicsColumn::~GraphicsColumn()\r\n//-----------------------------------------------------------------------------\r\nGraphicsColumn::~GraphicsColumn()\r\n{\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: GraphicsColumn::setName()\r\n//-----------------------------------------------------------------------------\r\nvoid GraphicsColumn::setName(QString const& name)\r\n{\r\n    columnData_->setName(name);\r\n    updateNameLabel();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: GraphicsColumn::name()\r\n//-----------------------------------------------------------------------------\r\nQString GraphicsColumn::name() const\r\n{\r\n    return columnData_->name();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: GraphicsColumn::setColumnDesc()\r\n//-----------------------------------------------------------------------------\r\nvoid GraphicsColumn::setColumnDesc(QSharedPointer<ColumnDesc> desc)\r\n{\r\n    columnData_ = desc;\r\n\r\n    if (desc->getContentType() == ColumnTypes::IO)\r\n    {\r\n        columnData_->setAllowedItems(ColumnTypes::INTERFACE);\r\n    }\r\n    else if (desc->getContentType() == ColumnTypes::COMPONENTS)\r\n    {\r\n        columnData_->setAllowedItems(ColumnTypes::COMPONENT);\r\n    }\r\n    else if (desc->getContentType() == ColumnTypes::BUSES)\r\n    {\r\n        columnData_->setAllowedItems(ColumnTypes::CHANNEL | ColumnTypes::BRIDGE);\r\n    }\r\n\r\n    if (desc->getContentType() == ColumnTypes::IO)\r\n    {\r\n        setItemLayout(QSharedPointer<IVGraphicsLayout<QGraphicsItem> >(\r\n            new VCollisionLayout<QGraphicsItem>(GraphicsColumnConstants::IO_SPACING)));\r\n    }\r\n    else\r\n    {\r\n        setItemLayout(QSharedPointer<IVGraphicsLayout<QGraphicsItem> >(\r\n            new VStackedLayout<QGraphicsItem>(GraphicsColumnConstants::SPACING)));\r\n    }\r\n\r\n    setRect(0, 0, columnData_->getWidth(), HEIGHT);\r\n    layout_->updateColumnPositions();\r\n\r\n    foreach (QGraphicsItem* item, items_)\r\n    {\r\n        item->setX(columnData_->getWidth() / 2);\r\n    }\r\n\r\n    updateNameLabel();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: GraphicsColumn::getColumnDesc()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<ColumnDesc> GraphicsColumn::getColumnDesc() const\r\n{\r\n    return columnData_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: GraphicsColumn::setWidth()\r\n//-----------------------------------------------------------------------------\r\nvoid GraphicsColumn::setWidth(unsigned int width)\r\n{\r\n    columnData_->setWidth(width);\r\n\r\n    setRect(0, 0, columnData_->getWidth(), HEIGHT);\r\n    layout_->updateColumnPositions();\r\n\r\n    unsigned int centerX = columnData_->getWidth() / 2;\r\n    foreach (QGraphicsItem* item, items_)\r\n    {\r\n        item->setX(centerX);\r\n    }\r\n\r\n    updateNameLabel();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: GraphicsColumn::setOffsetY()\r\n//-----------------------------------------------------------------------------\r\nvoid GraphicsColumn::setOffsetY(qreal y)\r\n{\r\n    // Update the rectangle and the label position.\r\n    setRect(0, y, columnData_->getWidth(), HEIGHT);\r\n    nameLabel_->setPos(nameLabel_->x(), 5 + y);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: GraphicsColumn::getItems()\r\n//-----------------------------------------------------------------------------\r\nQList<QGraphicsItem*> GraphicsColumn::getItems() const\r\n{\r\n    return items_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: GraphicsColumn::isAllowedItemsValid()\r\n//-----------------------------------------------------------------------------\r\nbool GraphicsColumn::isAllowedItemsValid(unsigned int allowedItems) const\r\n{\r\n    foreach (QGraphicsItem* item, items_)\r\n    {\r\n        if (!isItemAllowed(item, allowedItems))\r\n        {\r\n            return false;\r\n        }\r\n    }\r\n\r\n    return true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: GraphicsColumn::isEmpty()\r\n//-----------------------------------------------------------------------------\r\nbool GraphicsColumn::isEmpty() const\r\n{\r\n    return items_.empty();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: GraphicsColumn::addItem()\r\n//-----------------------------------------------------------------------------\r\nvoid GraphicsColumn::addItem(QGraphicsItem* item, bool load)\r\n{\r\n    // Remove the item from the previous column.\r\n    if (item->parentItem() != 0)\r\n    {\r\n        dynamic_cast<IGraphicsItemStack*>(item->parentItem())->removeItem(item);\r\n    }\r\n\r\n    // Constrain the item to the horizontal center of the column.\r\n    QPointF pos = mapFromScene(item->scenePos());\r\n    pos.setX(columnData_->getWidth() / 2.0);\r\n\r\n    item->setParentItem(this);\r\n    item->setPos(pos);\r\n    item->setFlag(ItemStacksBehindParent);\r\n\r\n    if (load)\r\n    {\r\n        // Place the item at the correct index in the items list.\r\n        for (int i = 0; i < items_.size(); ++i)\r\n        {\r\n            if (item->y() < items_.at(i)->y())\r\n            {\r\n                items_.insert(i, item);\r\n                return;\r\n            }\r\n        }\r\n\r\n        // If we got here, the item must be placed at the end of the list.\r\n        items_.append(item);\r\n    }\r\n    else\r\n    {\r\n        items_.append(item);\r\n\r\n        if (itemLayout_ != 0)\r\n        {\r\n            itemLayout_->updateItemMove(items_, item, GraphicsColumnConstants::MIN_Y_PLACEMENT);\r\n            itemLayout_->setItemPos(\r\n                items_, item, columnData_->getWidth() / 2, GraphicsColumnConstants::MIN_Y_PLACEMENT);\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: GraphicsColumn::removeItem()\r\n//-----------------------------------------------------------------------------\r\nvoid GraphicsColumn::removeItem(QGraphicsItem* item)\r\n{\r\n    items_.removeAll(item);\r\n\r\n    if (itemLayout_ != 0)\r\n    {\r\n        itemLayout_->updateItemPositions(\r\n            items_, columnData_->getWidth() / 2, GraphicsColumnConstants::MIN_Y_PLACEMENT);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: GraphicsColumn::onMoveItem()\r\n//-----------------------------------------------------------------------------\r\nvoid GraphicsColumn::onMoveItem(QGraphicsItem* item)\r\n{\r\n    if (itemLayout_ != 0)\r\n    {\r\n        itemLayout_->updateItemMove(items_, item, GraphicsColumnConstants::MIN_Y_PLACEMENT);\r\n    }\r\n\r\n    // Check if any graphics item stack is under the item.\r\n    foreach (QGraphicsItem* childItem, items_)\r\n    {\r\n        IGraphicsItemStack* childStack = dynamic_cast<IGraphicsItemStack*>(childItem);\r\n        if (childStack != 0 && childStack->isItemAllowed(item))\r\n        {\r\n            QRectF intersection = childItem->sceneBoundingRect().intersected(item->sceneBoundingRect());\r\n\r\n            if (intersection.height() >= 3*GridSize)\r\n            {\r\n                // Switch the mapping item as the parent.\r\n                removeItem(item);\r\n\r\n                setZValue(0.0);\r\n\r\n                QPointF newPos = childStack->mapStackFromScene(item->scenePos());\r\n                item->setParentItem(childItem);\r\n                item->setPos(newPos);\r\n                item->setFlag(ItemStacksBehindParent, false);\r\n\r\n                childStack->onMoveItem(item);\r\n                return;\r\n            }\r\n        }\r\n    }\r\n\r\n    // If none of the child components handled the movement, find the column under the item's current position.\r\n    if (itemsAreTransferable_)\r\n    {\r\n        GraphicsColumn* column = layout_->findColumnAt(item->scenePos());\r\n        if (column != 0 && column != this && column->isItemAllowed(item))\r\n        {\r\n            switchItemToColumn(item, column);\r\n            return;\r\n        }\r\n    }\r\n\r\n    // Check if auto-reorganize is enabled and the item needs to be moved somewhere else.\r\n    if (layout_->isAutoReorganized())\r\n    {\r\n        int index = layout_->getColumns().indexOf(this);\r\n        int newIndex = index;\r\n\r\n        for (; newIndex < layout_->getColumns().size(); newIndex++)\r\n        {\r\n            if (layout_->getColumns().at(newIndex)->isItemAllowed(item))\r\n            {\r\n                break;\r\n            }\r\n        }\r\n\r\n        // If not found, create a new one with default properties.\r\n        if (newIndex == layout_->getColumns().size())\r\n        {\r\n            layout_->autoCreateColumn();\r\n            return;\r\n        }\r\n\r\n        if (newIndex != index)\r\n        {\r\n            switchItemToColumn(item, layout_->getColumns().at(newIndex));\r\n            return;\r\n        }\r\n\r\n        // Remove unused columns from the right.\r\n        for (int i = layout_->getColumns().indexOf(this) + 1; i < layout_->getColumns().size(); i++)\r\n        {\r\n            if (layout_->getColumns().at(i)->isEmpty())\r\n            {\r\n                layout_->removeColumn(layout_->getColumns().at(i));\r\n                i--;\r\n            }\r\n        }\r\n    }\r\n\r\n    setZValue(1001.0);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: GraphicsColumn::onReleaseItem()\r\n//-----------------------------------------------------------------------------\r\nvoid GraphicsColumn::onReleaseItem(QGraphicsItem* item)\r\n{\r\n    setZValue(0.0);\r\n\r\n    if (itemLayout_ != 0)\r\n    {\r\n        itemLayout_->setItemPos(\r\n            items_, item, columnData_->getWidth() / 2, GraphicsColumnConstants::MIN_Y_PLACEMENT);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: GraphicsColumn::updateItemPositions()\r\n//-----------------------------------------------------------------------------\r\nvoid GraphicsColumn::updateItemPositions()\r\n{\r\n    if (itemLayout_ != 0)\r\n    {\r\n        itemLayout_->updateItemPositions(\r\n            items_, columnData_->getWidth() / 2, GraphicsColumnConstants::MIN_Y_PLACEMENT);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: GraphicsColumn::mapStackToScene()\r\n//-----------------------------------------------------------------------------\r\nQPointF GraphicsColumn::mapStackToScene(QPointF const& pos) const\r\n{\r\n    return mapToScene(pos);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: GraphicsColumn::mapStackFromScene()\r\n//-----------------------------------------------------------------------------\r\nQPointF GraphicsColumn::mapStackFromScene(QPointF const& pos) const\r\n{\r\n    return mapFromScene(pos);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: GraphicsColumn::isItemAllowed()\r\n//-----------------------------------------------------------------------------\r\nbool GraphicsColumn::isItemAllowed(QGraphicsItem* item) const\r\n{\r\n    return isItemAllowed(item, columnData_->getAllowedItems());\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: GraphicsColumn::getContentType()\r\n//-----------------------------------------------------------------------------\r\nColumnTypes::ColumnContentType GraphicsColumn::getContentType() const\r\n{\r\n    return columnData_->getContentType();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: GraphicsColumn::mousePressEvent()\r\n//-----------------------------------------------------------------------------\r\nvoid GraphicsColumn::mousePressEvent(QGraphicsSceneMouseEvent* event)\r\n{\r\n    if (auto designDiagram = dynamic_cast<DesignDiagram*>(scene()); designDiagram && designDiagram->isProtected())\r\n    {\r\n        return;\r\n    }\r\n\r\n    qreal cursorPosition = qAbs(event->pos().x() - boundingRect().right());\r\n    if (cursorPosition <= GridSize)\r\n    {\r\n        resizeInProgress_ = true;\r\n        oldWidth_ = columnData_->getWidth();\r\n    }\r\n    else\r\n    {\r\n        QGraphicsRectItem::mousePressEvent(event);\r\n\r\n        oldPos_ = pos();\r\n        prepareColumnMove();\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: GraphicsColumn::mouseMoveEvent()\r\n//-----------------------------------------------------------------------------\r\nvoid GraphicsColumn::mouseMoveEvent(QGraphicsSceneMouseEvent* event)\r\n{\r\n    // Discard mouse move if the diagram is protected.\r\n    if (auto designDiagram = dynamic_cast<DesignDiagram*>(scene()); designDiagram && designDiagram->isProtected())\r\n    {\r\n        return;\r\n    }\r\n\r\n    // If the mouse is moved near the resize area, change the column's width accordingly.\r\n    if (resizeInProgress_)\r\n    {\r\n        // Snap the resize to two grid units.\r\n        qreal snappedRight = (static_cast<int>(event->pos().x() + 10.0) / 20) * 20;\r\n        setWidth(qMax<int>(0, snappedRight - 1));\r\n    }\r\n    else\r\n    {\r\n        // Otherwise handle the movement of the column.\r\n        QGraphicsRectItem::mouseMoveEvent(event);\r\n\r\n        setZValue(1001.0);\r\n        layout_->onMoveColumn(this);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: GraphicsColumn::mouseReleaseEvent()\r\n//-----------------------------------------------------------------------------\r\nvoid GraphicsColumn::mouseReleaseEvent(QGraphicsSceneMouseEvent* event)\r\n{\r\n    if (resizeInProgress_ && columnData_->getWidth() != oldWidth_)\r\n    {\r\n        DesignDiagram* diagram = dynamic_cast<DesignDiagram*>(scene());\r\n        if (diagram)\r\n        {\r\n            QSharedPointer<QUndoCommand> cmd(new GraphicsColumnResizeCommand(this, oldWidth_, diagram));\r\n            diagram->getEditProvider()->addCommand(cmd);\r\n\r\n            cmd->redo();\r\n        }\r\n\r\n        resizeInProgress_ = false;\r\n    }\r\n    else if (!resizeInProgress_)\r\n    {\r\n        QGraphicsRectItem::mouseReleaseEvent(event);\r\n\r\n        setZValue(0.0);\r\n        layout_->onReleaseColumn(this);\r\n\r\n        DesignDiagram* diagram = dynamic_cast<DesignDiagram*>(scene());\r\n        if (diagram)\r\n        {\r\n            QSharedPointer<QUndoCommand> undoCommand = createMoveUndoCommand();\r\n            if (undoCommand->childCount() > 0 || pos() != oldPos_)\r\n            {\r\n                diagram->getEditProvider()->addCommand(undoCommand);\r\n            }\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: GraphicsColumn::hoverEnterEvent()\r\n//-----------------------------------------------------------------------------\r\nvoid GraphicsColumn::hoverEnterEvent(QGraphicsSceneHoverEvent* event)\r\n{\r\n    QGraphicsRectItem::hoverEnterEvent(event);\r\n\r\n    if (auto designDiagram = dynamic_cast<DesignDiagram*>(scene()); \r\n        designDiagram &&\r\n        designDiagram->isProtected() &&\r\n        qAbs(event->pos().x() - boundingRect().right()) <= 10 &&\r\n        !mouseNearResizeArea_)\r\n    {\r\n        QApplication::setOverrideCursor(Qt::SplitHCursor);\r\n        mouseNearResizeArea_ = true;\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: GraphicsColumn::hoverMoveEvent()\r\n//-----------------------------------------------------------------------------\r\nvoid GraphicsColumn::hoverMoveEvent(QGraphicsSceneHoverEvent* event)\r\n{\r\n    QGraphicsRectItem::hoverMoveEvent(event);\r\n\r\n    if (auto designDiagram = dynamic_cast<DesignDiagram*>(scene()); \r\n        designDiagram && designDiagram->isProtected())\r\n    {\r\n        return;\r\n    }\r\n\r\n    if (qAbs(event->pos().x() - boundingRect().right()) <= 10)\r\n    {\r\n        if (!mouseNearResizeArea_)\r\n        {\r\n            QApplication::setOverrideCursor(Qt::SplitHCursor);\r\n            mouseNearResizeArea_ = true;\r\n        }\r\n    }\r\n    else if (mouseNearResizeArea_)\r\n    {\r\n        QApplication::restoreOverrideCursor();\r\n        mouseNearResizeArea_ = false;\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: GraphicsColumn::hoverLeaveEvent()\r\n//-----------------------------------------------------------------------------\r\nvoid GraphicsColumn::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)\r\n{\r\n    QGraphicsRectItem::hoverLeaveEvent(event);\r\n\r\n    if (mouseNearResizeArea_)\r\n    {\r\n        QApplication::restoreOverrideCursor();\r\n        mouseNearResizeArea_ = false;\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: GraphicsColumn::itemChange()\r\n//-----------------------------------------------------------------------------\r\nQVariant GraphicsColumn::itemChange(GraphicsItemChange change, QVariant const& value)\r\n{\r\n    if (change == ItemPositionChange)\r\n    {\r\n        QPointF position(value.toPointF().x(), 0.0);\r\n        columnData_->setPosition(position.x());\r\n        return position;\r\n    }\r\n    else if (change == ItemChildRemovedChange)\r\n    {\r\n        removeItem(value.value<QGraphicsItem*>());\r\n    }\r\n\r\n    return QGraphicsRectItem::itemChange(change, value);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: GraphicsColumn::prepareColumnMove()\r\n//-----------------------------------------------------------------------------\r\nvoid GraphicsColumn::prepareColumnMove()\r\n{\r\n    // Nothing to do.\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: GraphicsColumn::createMoveUndoCommand()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<QUndoCommand> GraphicsColumn::createMoveUndoCommand()\r\n{\r\n    if (pos() != oldPos_)\r\n    {\r\n        return QSharedPointer<QUndoCommand>(new GraphicsColumnMoveCommand(layout_, this, oldPos_));\r\n    }\r\n    else\r\n    {\r\n        return QSharedPointer<QUndoCommand>(new QUndoCommand());\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: GraphicsColumn::setItemLayout()\r\n//-----------------------------------------------------------------------------\r\nvoid GraphicsColumn::setItemLayout(QSharedPointer< IVGraphicsLayout<QGraphicsItem> > itemLayout)\r\n{\r\n    itemLayout_ = itemLayout;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: GraphicsColumn::switchColumn()\r\n//-----------------------------------------------------------------------------\r\nvoid GraphicsColumn::switchItemToColumn(QGraphicsItem* item, GraphicsColumn* column)\r\n{\r\n    // We have to switch the column and update this column's item positions without the moving item.\r\n    QPointF newPos = column->mapFromScene(item->scenePos());\r\n    item->setParentItem(column);\r\n    item->setPos(newPos);\r\n\r\n    setZValue(0.0);\r\n    column->onMoveItem(item);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: GraphicsColumn::updateNameLabel()\r\n//-----------------------------------------------------------------------------\r\nvoid GraphicsColumn::updateNameLabel()\r\n{\r\n    nameLabel_->setHtml(\"<center>\" + columnData_->name() + \"</center>\");\r\n    nameLabel_->setTextWidth(qMax<unsigned int>(140, columnData_->getWidth()));\r\n    nameLabel_->setPos((columnData_->getWidth() - nameLabel_->textWidth()) / 2.0, 5.0);\r\n}\r\n"
  },
  {
    "path": "common/graphicsItems/GraphicsColumn.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: GraphicsColumn.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Joni-Matti Maatta\r\n// Date: 1.6.2012\r\n//\r\n// Description:\r\n// Graphics column class for managing a collection of graphics items in one\r\n// column.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef GRAPHICSCOLUMN_H\r\n#define GRAPHICSCOLUMN_H\r\n\r\n#include \"IGraphicsItemStack.h\"\r\n\r\n#include <common/layouts/IVGraphicsLayout.h>\r\n\r\n#include <IPXACTmodels/kactusExtensions/ColumnDesc.h>\r\n\r\n#include <QGraphicsRectItem>\r\n#include <QUndoCommand>\r\n\r\nclass GraphicsColumnLayout;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! GraphicsColumn class.\r\n//-----------------------------------------------------------------------------\r\nclass GraphicsColumn : public QObject, public QGraphicsRectItem, public IGraphicsItemStack\r\n{\r\n    Q_OBJECT\r\n\r\npublic:\r\n    enum\r\n    {\r\n        HEIGHT = 30\r\n    };\r\n\r\n    /*!\r\n     *  Constructor.\r\n     *\r\n     *    @param [in] desc                            The column description.\r\n     *    @param [in] layout                          The parent column layout.\r\n     *    @param [in] itemsCanTransferToOtherColumns  Possibility of item transfer between columns.\r\n     */\r\n    GraphicsColumn(QSharedPointer<ColumnDesc> desc, GraphicsColumnLayout* layout,\r\n        bool itemsCanTransferToOtherColumns = true);\r\n\r\n    /*!\r\n     *  Destructor.\r\n     */\r\n    virtual ~GraphicsColumn();\r\n\r\n    /*!\r\n     *  Sets the name of the system column.\r\n     *\r\n     *    @param [in] name The name of the column.\r\n     */\r\n    void setName(QString const& name);\r\n    \r\n    /*!\r\n     *  Returns the name of the system column.\r\n     */\r\n    QString name() const;\r\n\r\n    /*!\r\n     *  Sets the column description.\r\n     */\r\n    void setColumnDesc(QSharedPointer<ColumnDesc> desc);\r\n    \r\n    /*!\r\n     *  Returns the column description.\r\n     */\r\n    QSharedPointer<ColumnDesc> getColumnDesc() const;\r\n\r\n    /*!\r\n     *  Sets the column width.\r\n     *\r\n     *    @param [in] width The new width to set.\r\n     */\r\n    void setWidth(unsigned int width);\r\n\r\n    /*!\r\n     *  Sets the y coordinate offset.\r\n     *\r\n     *    @param [in] y The y coordinate offset.\r\n     */\r\n    void setOffsetY(qreal y);\r\n\r\n    /*!\r\n     *  Returns the items that are added to the column.\r\n     */\r\n    QList<QGraphicsItem*> getItems() const;\r\n\r\n    /*!\r\n     *  Returns true if the contents of the column conforms to the given allowed items configuration.\r\n     */\r\n    bool isAllowedItemsValid(unsigned int allowedItems) const;\r\n\r\n    /*!\r\n     *  Returns true if the column is empty (i.e. not containing any items).\r\n     */\r\n    bool isEmpty() const;\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // IGraphicsItemStack implementation.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    /*!\r\n     *  Adds an item to the system column.\r\n     *\r\n     *    @param [in] item  The item to add.\r\n     *    @param [in] load  If true, the item is being loaded from a design.\r\n     */\r\n    virtual void addItem(QGraphicsItem* item, bool load = false);\r\n\r\n    /*!\r\n     *  Removes an item from the system column.\r\n     *\r\n     *    @param [in] item the item to remove.\r\n     */\r\n    virtual void removeItem(QGraphicsItem* item);\r\n\r\n    /*!\r\n     *  Called when an item is moved within the column.\r\n     *\r\n     *    @param [in] item       The item that has been moved.\r\n     */\r\n    virtual void onMoveItem(QGraphicsItem* item);\r\n    \r\n    /*!\r\n     *  Called when an item is released from being moved by mouse.\r\n     *\r\n     *    @param [in] item The item that has been released.\r\n     */\r\n    virtual void onReleaseItem(QGraphicsItem* item);\r\n\r\n    /*!\r\n     *  Updates the item positions so that there are no violations of the stacking rule.\r\n     */\r\n    virtual void updateItemPositions();\r\n\r\n    /*!\r\n     *  Maps the given local position to scene coordinates.\r\n     */\r\n    virtual QPointF mapStackToScene(QPointF const& pos) const;\r\n\r\n    /*!\r\n     *  Maps the given scene position to local coordinates.\r\n     */\r\n    virtual QPointF mapStackFromScene(QPointF const& pos) const;\r\n\r\n    /*!\r\n     *  Returns true if the stack is allowed to contain the given item.\r\n     *\r\n     *    @param [in] item The item to test for.\r\n     */\r\n    virtual bool isItemAllowed(QGraphicsItem* item) const;\r\n    \r\n    /*!\r\n     *  Returns the content type.\r\n     */\r\n    virtual ColumnTypes::ColumnContentType getContentType() const;\r\n\r\nprotected:\r\n    //! Called when the user presses the mouse over the column.\r\n    void mousePressEvent(QGraphicsSceneMouseEvent* event);\r\n\r\n    //! Called when the user moves the column with the mouse.\r\n    void mouseMoveEvent(QGraphicsSceneMouseEvent* event);\r\n\r\n    //! Called when the user release the mouse.\r\n    void mouseReleaseEvent(QGraphicsSceneMouseEvent* event);\r\n\r\n    //! Called when the mouse hover enters the column header.\r\n    void hoverEnterEvent(QGraphicsSceneHoverEvent* event);\r\n\r\n    //! Called when the mouse hover moves inside the column header.\r\n    void hoverMoveEvent(QGraphicsSceneHoverEvent* event);\r\n\r\n    //! Called when the mouse hover leaves the column header.\r\n    void hoverLeaveEvent(QGraphicsSceneHoverEvent* event);\r\n\r\n    QVariant itemChange(GraphicsItemChange change, const QVariant &value);\r\n\r\n    /*!\r\n     *  Returns true if the given item is allowed to reside in the column based on the allowed items.\r\n     *\r\n     *    @param [in] item          The item.\r\n     *    @param [in] allowedItems  The allowed items flags.\r\n     */\r\n    virtual bool isItemAllowed(QGraphicsItem* item, unsigned int allowedItems) const = 0;\r\n\r\n    /*!\r\n     *  Prepares for column move.\r\n     */\r\n    virtual void prepareColumnMove();\r\n\r\n    /*!\r\n     *  Creates an undo command for the column move.\r\n     *\r\n     *    @return The created undo command.\r\n     */\r\n    virtual QSharedPointer<QUndoCommand> createMoveUndoCommand();\r\n\r\n    /*!\r\n     *  Changes the item layout.\r\n     *\r\n     *    @param [in] itemLayout The item layout to set.\r\n     */\r\n    void setItemLayout(QSharedPointer< IVGraphicsLayout<QGraphicsItem> > itemLayout);\r\n\r\nprivate:\r\n    // Disable copying.\r\n    GraphicsColumn(GraphicsColumn const& rhs);\r\n    GraphicsColumn& operator=(GraphicsColumn const& rhs);\r\n    \r\n    /*!\r\n     *  Switches the given item to another column.\r\n     *\r\n     *    @param [in] item    The item to move.\r\n     *    @param [in] column  The destination column.\r\n     */\r\n    void switchItemToColumn(QGraphicsItem* item, GraphicsColumn* column);\r\n\r\n    /*!\r\n     *  Updates the name label.\r\n     */\r\n    void updateNameLabel();\r\n    \r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! The parent column layout.\r\n    GraphicsColumnLayout* layout_;\r\n\r\n    //! The column description.\r\n    QSharedPointer<ColumnDesc> columnData_;\r\n\r\n    //! The column name label.\r\n    QGraphicsTextItem* nameLabel_;\r\n\r\n    //! The layout used for contained items.\r\n    QSharedPointer< IVGraphicsLayout<QGraphicsItem> > itemLayout_;\r\n\r\n    //! The node items ordered from top to bottom.\r\n    QList<QGraphicsItem*> items_;\r\n\r\n    //! The old position of the column before mouse move.\r\n    QPointF oldPos_;\r\n\r\n    //! If true, the mouse hovers near the resize area.\r\n    bool mouseNearResizeArea_;\r\n\r\n    //! Informs of a current resizing event.\r\n    bool resizeInProgress_;\r\n\r\n    //! The old column width before resize.\r\n    unsigned int oldWidth_;\r\n\r\n    //! Holds wether column items are transferable to other columns or not.\r\n    bool itemsAreTransferable_;\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n\r\n#endif // GRAPHICSCOLUMN_H\r\n"
  },
  {
    "path": "common/graphicsItems/GraphicsColumnAddCommand.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: GraphicsColumnAddCommand.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Mikko Teuho\n// Date: 23.10.2017\n//\n// Description:\n// Undo command for adding graphics columns.\n//-----------------------------------------------------------------------------\n\n#include \"GraphicsColumnAddCommand.h\"\n\n#include <common/graphicsItems/GraphicsColumn.h>\n#include <common/graphicsItems/GraphicsColumnLayout.h>\n\n#include <editors/common/DesignDiagram.h>\n\n#include <IPXACTmodels/Design/Design.h>\n\n//-----------------------------------------------------------------------------\n// Function: GraphicsColumnAddCommand()\n//-----------------------------------------------------------------------------\nGraphicsColumnAddCommand::GraphicsColumnAddCommand(GraphicsColumnLayout* layout, GraphicsColumn* column,\n    DesignDiagram* diagram, QUndoCommand* parent):\nQUndoCommand(parent),\nlayout_(layout),\ncolumn_(column),\ndiagram_(diagram),\ndel_(false)\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: ~GraphicsColumnAddCommand()\n//-----------------------------------------------------------------------------\nGraphicsColumnAddCommand::~GraphicsColumnAddCommand()\n{\n    if (del_)\n    {\n        delete column_;\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: undo()\n//-----------------------------------------------------------------------------\nvoid GraphicsColumnAddCommand::undo()\n{\n    QUndoCommand::undo();\n\n    Q_ASSERT(column_ != 0);\n\n    // Remove the column from the layout.\n    layout_->removeColumn(column_);\n    del_ = true;\n\n    diagram_->getDesign()->removeColumn(column_->getColumnDesc());\n}\n\n//-----------------------------------------------------------------------------\n// Function: redo()\n//-----------------------------------------------------------------------------\nvoid GraphicsColumnAddCommand::redo()\n{\n    // Add the column to the layout.\n    layout_->appendColumn(column_);\n    del_ = false;\n    diagram_->getDesign()->addColumn(column_->getColumnDesc());\n\n    QUndoCommand::redo();\n\n    diagram_->resetSceneRectangleForItems();\n}\n\n//-----------------------------------------------------------------------------\n// Function: GraphicsColumnAddCommand::getColumn()\n//-----------------------------------------------------------------------------\nGraphicsColumn* GraphicsColumnAddCommand::getColumn() const\n{\n    return column_;\n}\n\n//-----------------------------------------------------------------------------\n// Function: GraphicsColumnAddCommand::getLayout()\n//-----------------------------------------------------------------------------\nGraphicsColumnLayout* GraphicsColumnAddCommand::getLayout() const\n{\n    return layout_;\n}\n\n//-----------------------------------------------------------------------------\n// Function: GraphicsColumnAddCommand::getDiagram()\n//-----------------------------------------------------------------------------\nDesignDiagram* GraphicsColumnAddCommand::getDiagram() const\n{\n    return diagram_;\n}\n\n//-----------------------------------------------------------------------------\n// Function: GraphicsColumnAddCommand::columnShouldBeDeleted()\n//-----------------------------------------------------------------------------\nbool GraphicsColumnAddCommand::columnShouldBeDeleted() const\n{\n    return del_;\n}\n"
  },
  {
    "path": "common/graphicsItems/GraphicsColumnAddCommand.h",
    "content": "//-----------------------------------------------------------------------------\n// File: GraphicsColumnAddCommand.h\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Mikko Teuho\n// Date: 23.10.2017\n//\n// Description:\n// Undo command for adding graphics columns.\n//-----------------------------------------------------------------------------\n\n#ifndef GRAPHICSCOLUMNADDCOMMAND_H\n#define GRAPHICSCOLUMNADDCOMMAND_H\n\n#include <QSharedPointer>\n#include <QUndoCommand>\n\nclass GraphicsColumnLayout;\nclass GraphicsColumn;\nclass DesignDiagram;\n\n//-----------------------------------------------------------------------------\n//! Undo command for adding graphics columns.\n//-----------------------------------------------------------------------------\nclass GraphicsColumnAddCommand : public QUndoCommand\n{\npublic:\n\n    /*!\n     *  Constructor.\n     *\n     *    @param [in] layout      The column layout.\n     *    @param [in] column      The column to add.\n     *    @param [in] diagram     Design diagram containing the new column.\n     *    @param [in] parent      The parent command.\n     */\n    GraphicsColumnAddCommand(GraphicsColumnLayout* layout, GraphicsColumn* column, DesignDiagram* diagram,\n        QUndoCommand* parent = 0);\n\n    /*!\n     *  Destructor.\n     */\n    ~GraphicsColumnAddCommand();\n\n    /*!\n     *  Undoes the command.\n     */\n    virtual void undo();\n\n    /*!\n     *  Redoes the command.\n     */\n    virtual void redo();\n\nprotected:\n\n    /*!\n     *  Get the added graphics column.\n     *\n     *    @return The new graphics column.\n     */\n    GraphicsColumn* getColumn() const;\n\n    /*!\n     *  Get the column layout.\n     *\n     *    @return The column layout.\n     */\n    GraphicsColumnLayout* getLayout() const;\n\n    /*!\n     *  Get the design diagram.\n     *\n     *    @return The design diagram.\n     */\n    DesignDiagram* getDiagram() const;\n\n    /*!\n     *  Check if the column should be deleted.\n     *\n     *    @return True, if the column should be deleted, false otherwise.\n     */\n    bool columnShouldBeDeleted() const;\n\nprivate:\n\n    // Disable copying.\n    GraphicsColumnAddCommand(GraphicsColumnAddCommand const& rhs);\n    GraphicsColumnAddCommand& operator=(GraphicsColumnAddCommand const& rhs);\n\n    //-----------------------------------------------------------------------------\n    // Data.\n    //-----------------------------------------------------------------------------\n\n    //! The column layout.\n    GraphicsColumnLayout* layout_;\n\n    //! The column.\n    GraphicsColumn* column_;\n\n    //! Diagram containing the columns.\n    DesignDiagram* diagram_;\n\n    //! Boolean flag for indicating if the component should be deleted in the destructor.\n    bool del_;\n};\n\n//-----------------------------------------------------------------------------\n\n#endif // GRAPHICSCOLUMNADDCOMMAND_H\n"
  },
  {
    "path": "common/graphicsItems/GraphicsColumnConstants.h",
    "content": "//-----------------------------------------------------------------------------\n// File: GraphicsColumnConstants.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 13.02.2018\n//\n// Description:\n// Common declarations for graphics columns.\n//-----------------------------------------------------------------------------\n\n#ifndef GRAPHICSCOLUMNCONSTANTS_H\n#define GRAPHICSCOLUMNCONSTANTS_H\n\n//! Common declarations for graphics columns.\nnamespace GraphicsColumnConstants\n{\n    const int MIN_Y_PLACEMENT = 60;\n    \n    const int SPACING = 30;\n\n    const int IO_SPACING = 30;\n\n    //! Widths for design columns.\n    const int SYSTEM_COLUMN_WIDTH = 379;\n    const int COMPONENT_COLUMN_WIDTH = 319;\n    const int IO_COLUMN_WIDTH = 119;\n}\n\n#endif // GRAPHICSCOLUMNCONSTANTS_H\n"
  },
  {
    "path": "common/graphicsItems/GraphicsColumnLayout.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: GraphicsColumnLayout.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Joni-Matti Maatta\r\n// Date: 31.5.2011\r\n//\r\n// Description:\r\n// Graphics column layout which manages the ordering and positioning\r\n// of graphics columns.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"GraphicsColumnLayout.h\"\r\n\r\n#include \"GraphicsColumn.h\"\r\n\r\n#include <common/layouts/HStackedLayout.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: GraphicsColumnLayout::GraphicsColumnLayout()\r\n//-----------------------------------------------------------------------------\r\nGraphicsColumnLayout::GraphicsColumnLayout(QGraphicsScene* scene)\r\n    : scene_(scene),\r\n      layout_(new HStackedLayout<GraphicsColumn>(0.0)),\r\n      columns_(),\r\n      layoutWidth_(0.0),\r\n      offsetY_(0),\r\n      autoReorganized_(false),\r\n      autoCreateColumnFunc_(0)\r\n{\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: GraphicsColumnLayout::~GraphicsColumnLayout()\r\n//-----------------------------------------------------------------------------\r\nGraphicsColumnLayout::~GraphicsColumnLayout()\r\n{\r\n    // Delete all columns and clear the column list.\r\n    for (int i = 0; i < columns_.size(); ++i)\r\n    {\r\n        delete columns_.at(i);\r\n    }\r\n\r\n    columns_.clear();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: GraphicsColumnLayout::addItem()\r\n//-----------------------------------------------------------------------------\r\nvoid GraphicsColumnLayout::addItem(QGraphicsItem* item)\r\n{\r\n    for (int i = 0; i < columns_.size(); ++i)\r\n    {\r\n        if (columns_.at(i)->isItemAllowed(item))\r\n        {\r\n            columns_.at(i)->addItem(item);\r\n            break;\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n//  Function: GraphicsColumnLayout::addColumn()\r\n//-----------------------------------------------------------------------------\r\nvoid GraphicsColumnLayout::addColumn(GraphicsColumn* column, bool append)\r\n{\r\n    if (column->scene() == 0)\r\n    {\r\n        scene_->addItem(column);\r\n    }\r\n\r\n    if (append)\r\n    {\r\n        column->setPos(layoutWidth_, 0.0);\r\n    }\r\n\r\n    column->setOffsetY(offsetY_);\r\n\r\n    // Add the column to the list of columns and update the layout width.\r\n    columns_.append(column);\r\n    layoutWidth_ += column->boundingRect().width();\r\n\r\n    // Update the position in the layout.\r\n    layout_->updateItemMove(columns_, column);\r\n    layout_->setItemPos(columns_, column, 0.0);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: GraphicsColumnLayout::appendColumn()\r\n//-----------------------------------------------------------------------------\r\nvoid GraphicsColumnLayout::appendColumn(GraphicsColumn* column)\r\n{\r\n    column->setPos(layoutWidth_, 0);\r\n\r\n    if (column->scene() == 0)\r\n    {\r\n        scene_->addItem(column);\r\n    }\r\n\r\n    column->setOffsetY(offsetY_);\r\n\r\n    // Add the column to the list of columns and update the layout width.\r\n    columns_.append(column);\r\n    layoutWidth_ += column->boundingRect().width();\r\n\r\n    // Update the position in the layout.\r\n    layout_->updateItemMove(columns_, column);\r\n    layout_->setItemPos(columns_, column, 0.0);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: GraphicsColumnLayout::removeColumn()\r\n//-----------------------------------------------------------------------------\r\nvoid GraphicsColumnLayout::removeColumn(GraphicsColumn* column)\r\n{\r\n    if (columns_.removeAll(column) > 0)\r\n    {\r\n        layoutWidth_ -= column->boundingRect().width();\r\n        layout_->updateItemPositions(columns_, 0.0, 0.0);\r\n        scene_->removeItem(column);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: GraphicsColumnLayout::findColumnAt()\r\n//-----------------------------------------------------------------------------\r\nGraphicsColumn* GraphicsColumnLayout::findColumnAt(QPointF pt)\r\n{\r\n    foreach (GraphicsColumn* column, columns_)\r\n    {\r\n        QRectF columnRect = column->sceneBoundingRect();\r\n\r\n        // The point is inside the column if the x coordinate is within it (y can be anything).\r\n        if (columnRect.left() <= pt.x() && pt.x() < columnRect.right())\r\n        {\r\n            return column;\r\n        }\r\n    }\r\n\r\n    return 0;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: GraphicsColumnLayout::onMoveColumn()\r\n//-----------------------------------------------------------------------------\r\nvoid GraphicsColumnLayout::onMoveColumn(GraphicsColumn* column)\r\n{\r\n    // Clamp the coordinates.\r\n    QPointF pos = column->pos();\r\n    pos.setY(0.0);\r\n    pos.setX(qMax(qMin(pos.x(), layoutWidth_ - (column->boundingRect().width())), 0.0));\r\n    column->setPos(pos);\r\n    column->update();\r\n\r\n    layout_->updateItemMove(columns_, column);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: GraphicsColumnLayout::onReleaseColumn()\r\n//-----------------------------------------------------------------------------\r\nvoid GraphicsColumnLayout::onReleaseColumn(GraphicsColumn* column)\r\n{\r\n    layout_->setItemPos(columns_, column, 0.0);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: GraphicsColumnLayout::updateColumnPositions()\r\n//-----------------------------------------------------------------------------\r\nvoid GraphicsColumnLayout::updateColumnPositions()\r\n{\r\n    layout_->updateItemPositions(columns_, 0.0, 0.0);\r\n\r\n    layoutWidth_ = 0.0;\r\n\r\n    foreach (GraphicsColumn* column, columns_)\r\n    {\r\n        layoutWidth_ += column->boundingRect().width();\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: GraphicsColumnLayout::setOffsetY()\r\n//-----------------------------------------------------------------------------\r\nvoid GraphicsColumnLayout::setOffsetY(qreal y)\r\n{\r\n    for (int i = 0; i < columns_.size(); ++i)\r\n    {\r\n        columns_.at(i)->setOffsetY(y);\r\n    }\r\n\r\n    offsetY_ = y;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: GraphicsColumnLayout::getColumns()\r\n//-----------------------------------------------------------------------------\r\nQList<GraphicsColumn*> const& GraphicsColumnLayout::getColumns() const\r\n{\r\n    return columns_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: GraphicsColumnLayout::updatePositions()\r\n//-----------------------------------------------------------------------------\r\nvoid GraphicsColumnLayout::updatePositions()\r\n{\r\n    for (int i = 0; i < columns_.size(); ++i)\r\n    {\r\n        columns_[i]->updateItemPositions();\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: GraphicsColumnLayout::setAutoReorganize()\r\n//-----------------------------------------------------------------------------\r\nvoid GraphicsColumnLayout::setAutoReorganized(bool autoReorganized)\r\n{\r\n    autoReorganized_ = autoReorganized;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: GraphicsColumnLayout::isAutoReorganized()\r\n//-----------------------------------------------------------------------------\r\nbool GraphicsColumnLayout::isAutoReorganized() const\r\n{\r\n    return autoReorganized_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: GraphicsColumnLayout::autoCreateColumn()\r\n//-----------------------------------------------------------------------------\r\nint GraphicsColumnLayout::autoCreateColumn()\r\n{\r\n    Q_ASSERT(autoCreateColumnFunc_ != 0);\r\n\r\n    GraphicsColumn* column = autoCreateColumnFunc_(this);\r\n    addColumn(column, true);\r\n\r\n    return columns_.size() - 1;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: GraphicsColumnLayout::setAutoCreateColumnFunction()\r\n//-----------------------------------------------------------------------------\r\nvoid GraphicsColumnLayout::setAutoCreateColumnFunction(AutoCreateColumnFunc func)\r\n{\r\n    autoCreateColumnFunc_ = func;\r\n}\r\n"
  },
  {
    "path": "common/graphicsItems/GraphicsColumnLayout.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: GraphicsColumnLayout.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Joni-Matti Maatta\r\n// Date: 1.6.2012\r\n//\r\n// Description:\r\n// Graphics column layout which manages the ordering and positioning\r\n// of graphics columns.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef GRAPHICSCOLUMNLAYOUT_H\r\n#define GRAPHICSCOLUMNLAYOUT_H\r\n\r\n#include \"GraphicsColumn.h\"\r\n\r\n#include <common/layouts/IHGraphicsLayout.h>\r\n\r\n#include <QGraphicsScene>\r\n#include <QList>\r\n\r\n//-----------------------------------------------------------------------------\r\n//! GraphicsColumnLayout class.\r\n//-----------------------------------------------------------------------------\r\nclass GraphicsColumnLayout : public QObject\r\n{\r\n    Q_OBJECT\r\n\r\npublic:\r\n    typedef GraphicsColumn* (*AutoCreateColumnFunc)(GraphicsColumnLayout*);\r\n\r\n    /*!\r\n     *  Constructor.\r\n     *\r\n     *    @param [in] scene The parent graphics scene.\r\n     */\r\n    GraphicsColumnLayout(QGraphicsScene* scene = 0);\r\n\r\n    /*!\r\n     *  Destructor.\r\n     */\r\n    virtual ~GraphicsColumnLayout();\r\n\r\n    /*!\r\n     *  Adds an item to the first column where it is allowed to be placed.\r\n     *\r\n     *    @param [in] item The item to add.\r\n     */\r\n    void addItem(QGraphicsItem* item);\r\n\r\n    /*!\r\n     *  Adds a column to the layout.\r\n     *\r\n     *    @param [in] column  The column to add.\r\n     *    @param [in] append  If true, the column is appended to the end of the layout.\r\n     */\r\n    void addColumn(GraphicsColumn* column, bool append = false);\r\n\r\n    /*!\r\n     *  Add the selected column to the end of the layout.\r\n     *\r\n     *    @param [in] column  The selected column.\r\n     */\r\n    void appendColumn(GraphicsColumn* column);\r\n\r\n    /*!\r\n     *  Removes a column from the layout.\r\n     *\r\n     *    @param [in] column The column to remove.\r\n     */\r\n    void removeColumn(GraphicsColumn* column);\r\n\r\n    /*!\r\n     *  Searches for a column containing the given point.\r\n     *\r\n     *    @param [in] pt The point.\r\n     *\r\n     *    @return The column containing the given point, if found. Otherwise null.\r\n     */\r\n    GraphicsColumn* findColumnAt(QPointF pt);\r\n\r\n    /*!\r\n     *  Called when a column is moved within the layout.\r\n     *\r\n     *    @param [in] column The column that has been moved.\r\n     */\r\n    void onMoveColumn(GraphicsColumn* column);\r\n\r\n    /*!\r\n     *  Called when a column is released from being moved by mouse.\r\n     *\r\n     *    @param [in] column The column that has been released.\r\n     */\r\n    void onReleaseColumn(GraphicsColumn* column);\r\n\r\n    /*!\r\n     *  Updates the column positions.\r\n     */\r\n    void updateColumnPositions();\r\n\r\n    /*!\r\n     *  Sets auto-reorganize on/off.\r\n     *\r\n     *    @param [in] autoReorganized If true, auto-reorganize is set on.\r\n     */\r\n    void setAutoReorganized(bool autoReorganized);\r\n\r\n    /*!\r\n     *  Sets the column auto-creation function.\r\n     */\r\n    void setAutoCreateColumnFunction(AutoCreateColumnFunc func);\r\n\r\n    /*!\r\n     *  Creates a column with default properties by calling the auto-create function.\r\n     */\r\n    int autoCreateColumn();\r\n\r\n    /*!\r\n     *  Sets the drawing offset for the title bars.\r\n     *\r\n     *    @param [in] y The y coordinate offset.\r\n     */\r\n    void setOffsetY(qreal y);\r\n\r\n    /*!\r\n     *  Updates the positions of components in all columns.\r\n     */\r\n    void updatePositions();\r\n\r\n    /*!\r\n     *  Returns the columns in the column layout.\r\n     */\r\n    QList<GraphicsColumn*> const& getColumns() const;\r\n\r\n    /*!\r\n     *  Returns true if the layout is auto-reorganized.\r\n     */\r\n    bool isAutoReorganized() const;\r\n\r\nprivate:\r\n    // Disable copying.\r\n    GraphicsColumnLayout(GraphicsColumnLayout const& rhs);\r\n    GraphicsColumnLayout& operator=(GraphicsColumnLayout const& rhs);\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! The graphics scene.\r\n    QGraphicsScene* scene_;\r\n\r\n    //! Layouter for columns.\r\n    QSharedPointer< IHGraphicsLayout<GraphicsColumn> > layout_;\r\n\r\n    //! The columns.\r\n    QList<GraphicsColumn*> columns_;\r\n\r\n    //! The current layout width.\r\n    qreal layoutWidth_;\r\n\r\n    //! The y offset.\r\n    unsigned int offsetY_;\r\n\r\n    //! If true, the column layout can auto-reorganize (incl. growing and shrinking).\r\n    bool autoReorganized_;\r\n\r\n    //! The function pointer to the column auto-creation function.\r\n    AutoCreateColumnFunc autoCreateColumnFunc_;\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n\r\n#endif // GRAPHICSCOLUMNLAYOUT_H"
  },
  {
    "path": "common/graphicsItems/GraphicsColumnUndoCommands.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: GraphicsColumnUndoCommands.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Joni-Matti Maatta\r\n// Date: 1.6.2012\r\n//\r\n// Description:\r\n// Undo commands for graphics columns.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"GraphicsColumnUndoCommands.h\"\r\n\r\n#include \"GraphicsColumn.h\"\r\n#include \"GraphicsColumnLayout.h\"\r\n\r\n#include <editors/common/DesignDiagram.h>\r\n\r\n#include <IPXACTmodels/Design/Design.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: GraphicsColumnMoveCommand::GraphicsColumnMoveCommand()\r\n//-----------------------------------------------------------------------------\r\nGraphicsColumnMoveCommand::GraphicsColumnMoveCommand(GraphicsColumnLayout* layout, GraphicsColumn* column,\r\n    QPointF const& oldPos, QUndoCommand* parent):\r\nQUndoCommand(parent),\r\n    layout_(layout),\r\n    column_(column),\r\n    oldPos_(oldPos),\r\n    newPos_(column->pos())\r\n{\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: GraphicsColumnMoveCommand::~GraphicsColumnMoveCommand()\r\n//-----------------------------------------------------------------------------\r\nGraphicsColumnMoveCommand::~GraphicsColumnMoveCommand()\r\n{\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: GraphicsColumnMoveCommand::undo()\r\n//-----------------------------------------------------------------------------\r\nvoid GraphicsColumnMoveCommand::undo()\r\n{\r\n    column_->setPos(oldPos_);\r\n    layout_->onMoveColumn(column_);\r\n    layout_->onReleaseColumn(column_);\r\n\r\n    // Execute child commands.\r\n    QUndoCommand::undo();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: GraphicsColumnMoveCommand::redo()\r\n//-----------------------------------------------------------------------------\r\nvoid GraphicsColumnMoveCommand::redo()\r\n{\r\n    column_->setPos(newPos_);\r\n    layout_->onMoveColumn(column_);\r\n    layout_->onReleaseColumn(column_);\r\n\r\n    // Execute child commands.\r\n    QUndoCommand::redo();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: GraphicsColumnChangeCommand()\r\n//-----------------------------------------------------------------------------\r\nGraphicsColumnChangeCommand::GraphicsColumnChangeCommand(GraphicsColumn* column,\r\n    QSharedPointer<ColumnDesc> newDesc, DesignDiagram* diagram, QUndoCommand* parent):\r\nQUndoCommand(parent),\r\ncolumnItem_(column),\r\ncolumnDesc_(column->getColumnDesc()),\r\noldDesc_(new ColumnDesc(*column->getColumnDesc().data())),\r\nnewDesc_(newDesc),\r\ncontainingDesign_(diagram->getDesign()),\r\ndiagram_(diagram)\r\n{\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ~GraphicsColumnChangeCommand()\r\n//-----------------------------------------------------------------------------\r\nGraphicsColumnChangeCommand::~GraphicsColumnChangeCommand()\r\n{\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: undo()\r\n//-----------------------------------------------------------------------------\r\nvoid GraphicsColumnChangeCommand::undo()\r\n{\r\n    changeModifiedColumnInDesign(oldDesc_);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: redo()\r\n//-----------------------------------------------------------------------------\r\nvoid GraphicsColumnChangeCommand::redo()\r\n{\r\n    changeModifiedColumnInDesign(newDesc_);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: GraphicsColumnUndoCommands::changeModifiedColumnInDesign()\r\n//-----------------------------------------------------------------------------\r\nvoid GraphicsColumnChangeCommand::changeModifiedColumnInDesign(QSharedPointer<ColumnDesc> newColumn)\r\n{\r\n    columnDesc_->setAllowedItems(newColumn->getAllowedItems());\r\n    columnDesc_->setContentType(newColumn->getContentType());\r\n    columnDesc_->setName(newColumn->name());\r\n    //columnDesc_->setPosition(newColumn->getPosition());\r\n    columnDesc_->setWidth(newColumn->getWidth());\r\n\r\n    columnItem_->setColumnDesc(columnDesc_);\r\n\r\n    if (newDesc_ && oldDesc_ && newDesc_->getWidth() != oldDesc_->getWidth())\r\n    {\r\n        diagram_->resetSceneRectangleForItems();\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: GraphicsColumnResizeCommand::GraphicsColumnResizeCommand()\r\n//-----------------------------------------------------------------------------\r\nGraphicsColumnResizeCommand::GraphicsColumnResizeCommand(GraphicsColumn* column, unsigned int oldWidth,\r\n    DesignDiagram* diagram, QUndoCommand* parent):\r\nQUndoCommand(parent),\r\ncolumn_(column),\r\noldWidth_(oldWidth),\r\nnewWidth_(column_->getColumnDesc()->getWidth()),\r\ndiagram_(diagram)\r\n{\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: GraphicsColumnResizeCommand::~GraphicsColumnResizeCommand()\r\n//-----------------------------------------------------------------------------\r\nGraphicsColumnResizeCommand::~GraphicsColumnResizeCommand()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: GraphicsColumnResizeCommand::undo()\r\n//-----------------------------------------------------------------------------\r\nvoid GraphicsColumnResizeCommand::undo()\r\n{\r\n    changeWidth(oldWidth_);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: GraphicsColumnResizeCommand::redo()\r\n//-----------------------------------------------------------------------------\r\nvoid GraphicsColumnResizeCommand::redo()\r\n{\r\n    changeWidth(newWidth_);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: GraphicsColumnUndoCommands::changeWidth()\r\n//-----------------------------------------------------------------------------\r\nvoid GraphicsColumnResizeCommand::changeWidth(unsigned int selectedWidth)\r\n{\r\n    column_->setWidth(selectedWidth);\r\n\r\n    if (oldWidth_ != newWidth_)\r\n    {\r\n        diagram_->resetSceneRectangleForItems();\r\n    }\r\n}\r\n"
  },
  {
    "path": "common/graphicsItems/GraphicsColumnUndoCommands.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: GraphicsColumnUndoCommands.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Joni-Matti Maatta\r\n// Date: 1.6.2012\r\n//\r\n// Description:\r\n// Undo commands for graphics columns.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef GRAPHICSCOLUMNUNDOCOMMANDS_H\r\n#define GRAPHICSCOLUMNUNDOCOMMANDS_H\r\n\r\n#include <IPXACTmodels/kactusExtensions/ColumnDesc.h>\r\n\r\n#include <QSharedPointer>\r\n#include <QUndoCommand>\r\n#include <QPointF>\r\n\r\nclass GraphicsColumnLayout;\r\nclass GraphicsColumn;\r\nclass Design;\r\nclass DesignDiagram;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! GraphicsColumnMoveCommand class.\r\n//-----------------------------------------------------------------------------\r\nclass GraphicsColumnMoveCommand : public QUndoCommand\r\n{\r\npublic:\r\n    /*!\r\n     *  Constructor.\r\n     *\r\n     *    @param [in] layout  The column layout.\r\n     *    @param [in] column  The column to move.\r\n     *    @param [in] oldPos  The column's old position.\r\n     *    @param [in] parent  The parent command.\r\n     */\r\n    GraphicsColumnMoveCommand(GraphicsColumnLayout* layout, GraphicsColumn* column,\r\n                              QPointF const& oldPos, QUndoCommand* parent = 0);\r\n\r\n    /*!\r\n     *  Destructor.\r\n     */\r\n    ~GraphicsColumnMoveCommand();\r\n\r\n    /*!\r\n     *  Undoes the command.\r\n     */\r\n    virtual void undo();\r\n\r\n    /*!\r\n     *  Redoes the command.\r\n     */\r\n    virtual void redo();\r\n\r\nprivate:\r\n    // Disable copying.\r\n    GraphicsColumnMoveCommand(GraphicsColumnMoveCommand const& rhs);\r\n    GraphicsColumnMoveCommand& operator=(GraphicsColumnMoveCommand const& rhs);\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! The column layout.\r\n    GraphicsColumnLayout* layout_;\r\n\r\n    //! The diagram column.\r\n    GraphicsColumn* column_;\r\n\r\n    //! The old position of the column.\r\n    QPointF oldPos_;\r\n\r\n    //! The new position of the column.\r\n    QPointF newPos_;\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n//! GraphicsColumnChangeCommand class.\r\n//-----------------------------------------------------------------------------\r\nclass GraphicsColumnChangeCommand : public QUndoCommand\r\n{\r\npublic:\r\n    /*!\r\n     *  Constructor.\r\n     *\r\n     *    @param [in] column      The column.\r\n     *    @param [in] newDesc     The column's new description.\r\n     *    @param [in] diagram     Diagram containing the scene of the column.\r\n     */\r\n    GraphicsColumnChangeCommand(GraphicsColumn* column, QSharedPointer<ColumnDesc> newDesc,\r\n        DesignDiagram* diagram, QUndoCommand* parent = 0);\r\n\r\n    /*!\r\n     *  Destructor.\r\n     */\r\n    ~GraphicsColumnChangeCommand();\r\n\r\n    /*!\r\n     *  Undoes the command.\r\n     */\r\n    virtual void undo();\r\n\r\n    /*!\r\n     *  Redoes the command.\r\n     */\r\n    virtual void redo();\r\n\r\nprivate:\r\n    // Disable copying.\r\n    GraphicsColumnChangeCommand(GraphicsColumnChangeCommand const& rhs);\r\n    GraphicsColumnChangeCommand& operator=(GraphicsColumnChangeCommand const& rhs);\r\n\r\n    void changeModifiedColumnInDesign(QSharedPointer<ColumnDesc> newColumn);\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! The diagram column.\r\n    GraphicsColumn* columnItem_;\r\n    \r\n    //! The column description.\r\n    QSharedPointer<ColumnDesc> columnDesc_;\r\n\r\n    //! The column's old description.\r\n    QSharedPointer<ColumnDesc> oldDesc_;\r\n\r\n    //! The column's new description.\r\n    QSharedPointer<ColumnDesc> newDesc_;\r\n\r\n    //! The design containing the modified column.\r\n    QSharedPointer<Design> containingDesign_;\r\n\r\n    //! Diagram containing the scene of the column.\r\n    DesignDiagram* diagram_;\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n//! GraphicsColumnResizeCommand class.\r\n//-----------------------------------------------------------------------------\r\nclass GraphicsColumnResizeCommand : public QUndoCommand\r\n{\r\npublic:\r\n    /*!\r\n     *  Constructor.\r\n     *\r\n     *    @param [in] column      The column.\r\n     *    @param [in] oldWidth    The column's old width.\r\n     *    @param [in] diagram     Diagram containing the scene of the column.\r\n     */\r\n    GraphicsColumnResizeCommand(GraphicsColumn* column, unsigned int oldWidth, DesignDiagram* diagram,\r\n        QUndoCommand* parent = 0);\r\n\r\n    /*!\r\n     *  Destructor.\r\n     */\r\n    ~GraphicsColumnResizeCommand();\r\n\r\n    /*!\r\n     *  Undoes the command.\r\n     */\r\n    virtual void undo();\r\n\r\n    /*!\r\n     *  Redoes the command.\r\n     */\r\n    virtual void redo();\r\n\r\nprivate:\r\n    // Disable copying.\r\n    GraphicsColumnResizeCommand(GraphicsColumnResizeCommand const& rhs);\r\n    GraphicsColumnResizeCommand& operator=(GraphicsColumnResizeCommand const& rhs);\r\n\r\n    /*!\r\n     *  Change the width of the column.\r\n     *\r\n     *    @param [in] selectedWidth   The new width for the column.\r\n     */\r\n    void changeWidth(unsigned int selectedWidth);\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! The diagram column.\r\n    GraphicsColumn* column_;\r\n\r\n    //! The old width.\r\n    unsigned int oldWidth_;\r\n\r\n    //! The new width.\r\n    unsigned int newWidth_;\r\n\r\n    //! Diagram containing the scene of the column.\r\n    DesignDiagram* diagram_;\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n\r\n#endif // GRAPHICSCOLUMNUNDOCOMMANDS_H\r\n"
  },
  {
    "path": "common/graphicsItems/GraphicsConnection.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: GraphicsConnection.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Joni-Matti Maatta\r\n// Date: 5.6.2012\r\n//\r\n// Description:\r\n// Base class for graphical connections.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"GraphicsConnection.h\"\r\n\r\n#include \"ComponentItem.h\"\r\n#include \"ConnectionUndoCommands.h\"\r\n\r\n#include <common/GenericEditProvider.h>\r\n#include <common/KactusColors.h>\r\n\r\n#include <editors/HWDesign/OffPageConnectorItem.h>\r\n#include <editors/common/DesignDiagram.h>\r\n#include <editors/common/DiagramUtil.h>\r\n#include <editors/common/DefaultRouting.h>\r\n\r\n#include <QPen>\r\n#include <QStyleOptionGraphicsItem>\r\n#include <QGraphicsScene>\r\n#include <QPainter>\r\n#include <QGraphicsSceneMouseEvent>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: GraphicsConnection::GraphicsConnection()\r\n//-----------------------------------------------------------------------------\r\nGraphicsConnection::GraphicsConnection(ConnectionEndpoint* endpoint1, ConnectionEndpoint* endpoint2,\r\n    QSharedPointer<ConnectionRoute> route, bool autoConnect, DesignDiagram* parent) :\r\n    QGraphicsPathItem(),\r\n    Associable(),\r\n    parent_(parent),\r\n    endpoint1_(endpoint1),\r\n    endpoint2_(endpoint2),\r\n    route_(route)\r\n{\r\n    setItemSettings();\r\n    setAcceptHoverEvents(true);\r\n\r\n    if (autoConnect)\r\n    {\r\n        endpoint1_->onConnect(endpoint2_);\r\n        endpoint2_->onConnect(endpoint1_);\r\n\r\n        validate();\r\n\r\n        endpoint1_->addConnection(this);\r\n        endpoint2_->addConnection(this);\r\n\r\n        if (route_->name().isEmpty())\r\n        {\r\n            route_->setName(createDefaultName());\r\n        }\r\n    }\r\n\r\n    if (route_->getRoute().isEmpty())\r\n    {\r\n        createRoute(endpoint1_, endpoint2_);\r\n    }\r\n    else\r\n    {\r\n        setRoute(route_->getRoute());\r\n    }\r\n\r\n    setDefaultColor();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: GraphicsConnection::GraphicsConnection()\r\n//-----------------------------------------------------------------------------\r\nGraphicsConnection::GraphicsConnection(QPointF const& p1, QVector2D const& dir1,\r\n                                       QPointF const& p2, QVector2D const& dir2,\r\n                                       DesignDiagram* parent):\r\n    QGraphicsPathItem(), parent_(parent)\r\n{\r\n    setItemSettings();\r\n    pathPoints_ = DefaultRouting::createRoute(p1, p2, dir1, dir2);\r\n    setRoute(pathPoints_);        \r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: GraphicsConnection::~GraphicsConnection()\r\n//-----------------------------------------------------------------------------\r\nGraphicsConnection::~GraphicsConnection()\r\n{\r\n    disconnectEnds();\r\n    emit destroyed(this);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: GraphicsConnection::connectEnds()\r\n//-----------------------------------------------------------------------------\r\nbool GraphicsConnection::connectEnds()\r\n{\r\n    if (!scene())\r\n    {\r\n        return false;\r\n    }\r\n\r\n    prepareGeometryChange();\r\n\r\n    // Disconnect the previous ends.\r\n    disconnectEnds();\r\n\r\n    // Find the new end points.\r\n    endpoint1_ = DiagramUtil::snapToItem<ConnectionEndpoint>(pathPoints_.first(), scene(), GridSize);\r\n    Q_ASSERT(endpoint1_ != nullptr);\r\n\r\n    endpoint2_ = DiagramUtil::snapToItem<ConnectionEndpoint>(pathPoints_.last(), scene(), GridSize);\r\n    Q_ASSERT(endpoint2_ != nullptr);\r\n\r\n    // Swap the end points in a way that the first one at least has an encompassing component.\r\n    if (endpoint1_->encompassingComp() == nullptr && endpoint2_->encompassingComp() != nullptr)\r\n    {\r\n        std::swap(endpoint1_, endpoint2_);\r\n\r\n        // The path points have to be reversed.\r\n        for (int i = 0; i < pathPoints_.size() / 2; ++i)\r\n        {\r\n            pathPoints_.swapItemsAt(i, pathPoints_.size() - 1 - i);\r\n        }\r\n    }\r\n\r\n    // Make the connections and check for errors.\r\n    if (!endpoint1_->onConnect(endpoint2_))\r\n    {\r\n        endpoint1_ = nullptr;\r\n        return false;\r\n    }\r\n\r\n    if (!endpoint2_->onConnect(endpoint1_))\r\n    {\r\n        endpoint1_->onDisconnect();\r\n        endpoint1_ = nullptr;\r\n        endpoint2_ = nullptr;\r\n        return false;\r\n    }\r\n\r\n    validate();\r\n\r\n    endpoint1_->addConnection(this);\r\n    endpoint2_->addConnection(this);\r\n\r\n    setRoute(pathPoints_);\r\n\r\n    updatePosition();\r\n\r\n    route_->setName(createDefaultName());\r\n\r\n    return true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: GraphicsConnection::setRoute()\r\n//-----------------------------------------------------------------------------\r\nvoid GraphicsConnection::setRoute(QList<QPointF> path)\r\n{\r\n    if (path.size() < 2)\r\n    {\r\n        return;\r\n    }\r\n\r\n    QVector2D dir1 = QVector2D(path.at(1) - path.first()).normalized();\r\n    updateEndpointDirection(endpoint1_, dir1);\r\n\r\n    QVector2D dir2 = QVector2D(path.at(path.size() - 2) - path.last()).normalized();\r\n    updateEndpointDirection(endpoint2_, dir2);\r\n\r\n    pathPoints_ = path;\r\n    pathLines_ = pointsToLines(pathPoints_);\r\n\r\n    route_->setRoute(path);\r\n\r\n    paintConnectionPath();\r\n    positionUpdated();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: GraphicsConnection::setName()\r\n//-----------------------------------------------------------------------------\r\nvoid GraphicsConnection::setName(QString const& name)\r\n{\r\n    route_->setName(name);\r\n    emit contentChanged();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: GraphicsConnection::endpoint1()\r\n//-----------------------------------------------------------------------------\r\nConnectionEndpoint* GraphicsConnection::endpoint1() const\r\n{\r\n    return endpoint1_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: GraphicsConnection::endpoint2()\r\n//-----------------------------------------------------------------------------\r\nConnectionEndpoint* GraphicsConnection::endpoint2() const\r\n{\r\n    return endpoint2_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: GraphicsConnection::updatePosition()\r\n//-----------------------------------------------------------------------------\r\nvoid GraphicsConnection::updatePosition()\r\n{\r\n    if (routingMode_ == ROUTING_MODE_NORMAL)\r\n    {\r\n        QVector2D startDelta = QVector2D(endpoint1_->scenePos()) - QVector2D(pathPoints_.first());\r\n        QVector2D endDelta = QVector2D(endpoint2_->scenePos()) - QVector2D(pathPoints_.last());\r\n        QVector2D const& startDirection = endpoint1_->getDirection();\r\n        QVector2D const& endDirection = endpoint2_->getDirection();\r\n\r\n        // Recreate the route from scratch if there are not enough points in the path, the route is too \r\n        // complicated considering the position and direction of the endpoints, or the delta is away from the ends.\r\n        if (pathPoints_.size() < 2 ||\r\n            (pathPoints_.size() > 4 && qFuzzyCompare(QVector2D::dotProduct(startDirection, endDirection), -1.0f) &&\r\n            QVector2D::dotProduct(startDirection, QVector2D(endpoint2_->scenePos() - endpoint1_->scenePos())) > 0.0) ||\r\n            startDelta.x() * startDirection.x() < 0.0f || endDelta.x() * endDirection.x() < 0.0f)\r\n        {\r\n            createRoute(endpoint1_, endpoint2_);\r\n            return;\r\n        }\r\n\r\n        // If the delta movement of both endpoints was the same, we can just move all route points by the delta1.\r\n        if (!startDelta.isNull() && qFuzzyCompare(startDelta, endDelta))\r\n        {\r\n            for (int i = 0; i < pathPoints_.size(); ++i)\r\n            {\r\n                pathPoints_[i] += startDelta.toPointF();\r\n            }\r\n\r\n            setRoute(pathPoints_);\r\n        }\r\n        // Otherwise check if either the first or the last point was moved.\r\n        else if (!startDelta.isNull() || !endDelta.isNull())\r\n        {\r\n            QVector2D delta = startDelta;\r\n            QVector2D dir = startDirection;\r\n            QPointF endpointPosition = endpoint1_->scenePos();\r\n            int index0 = 0;\r\n            int index1 = 1;\r\n            int index2 = 2;\r\n            int index3 = 3;\r\n\r\n            if (!endDelta.isNull())\r\n            {\r\n                delta = endDelta;\r\n                endpointPosition = endpoint2_->scenePos();\r\n                dir = endDirection;\r\n                index0 = pathPoints_.size() - 1;\r\n                index1 = pathPoints_.size() - 2;\r\n                index2 = pathPoints_.size() - 3;\r\n                index3 = pathPoints_.size() - 4;\r\n            }\r\n\r\n            QVector2D seg1 = QVector2D(pathPoints_.at(index1) - pathPoints_.at(index0)).normalized();\r\n\r\n            bool pathOk = false;\r\n            // Try to fix the first segment with perpendicular projection.\r\n            // The path is ok if the moved point is still in view (not behind the left edge).\r\n            if (pathPoints_.size() >= 4 && pathPoints_.size() < 7 && qFuzzyCompare(dir, seg1))\r\n            {\r\n                QVector2D perp = delta - QVector2D::dotProduct(delta, seg1) * seg1;\r\n                pathPoints_[index1] += perp.toPointF();\r\n\r\n                pathOk = pathPoints_.at(index1).x() >= 10.0;\r\n            }\r\n\r\n            // Handle the parallel part of the delta.\r\n            pathPoints_[index0] = endpointPosition;\r\n            QVector2D newSeg1 = QVector2D(pathPoints_.at(index1) - pathPoints_.at(index0));\r\n\r\n            if (newSeg1.length() < DefaultRouting::MIN_START_LENGTH || !qFuzzyCompare(seg1, newSeg1.normalized()))\r\n            {\r\n                pathOk = false;\r\n            }\r\n\r\n            // Check for a special case when there would be intersecting parallel lines.\r\n            if (pathOk && pathPoints_.size() >= 4 ) \r\n            {\r\n                QVector2D seg2 = QVector2D(pathPoints_.at(index2) - pathPoints_.at(index1)).normalized();\r\n                QVector2D seg3 = QVector2D(pathPoints_.at(index3) - pathPoints_.at(index2)).normalized();\r\n              \r\n                if (QVector2D::dotProduct(seg1, seg2) < 0.0f ||\r\n                    (seg2.isNull() && QVector2D::dotProduct(seg1, seg3) < 0.0f))\r\n                {\r\n                     pathOk = false;\r\n                }               \r\n            }\r\n\r\n            if (pathOk)\r\n            {                \r\n                for (int i = 1; i < pathPoints_.size() - 1; i++)\r\n                {\r\n                    pathPoints_[i] = snapPointToGrid(pathPoints_.at(i));\r\n                }\r\n\r\n                setRoute(pathPoints_);\r\n            }\r\n            else //<! If the simple fix didn't result in a solution, just recreate the route.\r\n            {\r\n                createRoute(endpoint1_, endpoint2_);\r\n            }\r\n        }\r\n    }\r\n    else if (routingMode_ == ROUTING_MODE_OFFPAGE)\r\n    {\r\n        // Make a straight line from begin to end.\r\n        QList<QPointF> route;\r\n        route.append(endpoint1()->scenePos());\r\n        route.append(endpoint2()->scenePos());\r\n\r\n        setRoute(route);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: GraphicsConnection::route()\r\n//-----------------------------------------------------------------------------\r\nQList<QPointF> GraphicsConnection::route() const\r\n{\r\n    return pathPoints_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: GraphicsConnection::mousePressEvent()\r\n//-----------------------------------------------------------------------------\r\nvoid GraphicsConnection::mousePressEvent(QGraphicsSceneMouseEvent *mouseEvent)\r\n{\r\n    beginUpdatePosition();\r\n    \r\n    selected_ = -1;\r\n    selectionType_ = NONE;\r\n\r\n    QPointF pos = snapPointToGrid(mouseEvent->pos());    \r\n    if (pathPoints_.first() == pos)\r\n    {\r\n        selectionType_ = END;\r\n        selected_ = 0;\r\n    }\r\n    else if (pathPoints_.last() == pos)\r\n    {\r\n        selectionType_ = END;\r\n        selected_ = pathPoints_.size()-1;\r\n    }\r\n    else if (pathPoints_.size() > 1)\r\n    {\r\n        for (int i = 0; i < pathPoints_.size()-1; i++)\r\n        {\r\n            if ((i == 0 && endpoint1_) || (i == pathPoints_.size()-2 && endpoint2_))\r\n            {\r\n                continue;\r\n            }\r\n\r\n            if ((qFuzzyCompare(pathPoints_.at(i).x(), pos.x()) && qFuzzyCompare(pathPoints_.at(i+1).x(), pos.x())) ||\r\n                (qFuzzyCompare(pathPoints_.at(i).y(), pos.y()) && qFuzzyCompare(pathPoints_.at(i+1).y(), pos.y())))\r\n            {\r\n                selected_ = i;\r\n                selectionType_ = SEGMENT;\r\n            }\r\n        }\r\n    }\r\n\r\n    QGraphicsPathItem::mousePressEvent(mouseEvent);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: GraphicsConnection::mouseMoveEvent()\r\n//-----------------------------------------------------------------------------\r\nvoid GraphicsConnection::mouseMoveEvent(QGraphicsSceneMouseEvent* mouseEvent)\r\n{   \r\n    // Discard mouse move if the diagram is protected.\r\n    if (parent_->isProtected())\r\n    {\r\n        return;\r\n    }\r\n\r\n    QPointF newPos = snapPointToGrid(mouseEvent->pos());\r\n    if (selectionType_ == END)\r\n    {\r\n        disconnectEnds();\r\n\r\n        if (pathPoints_.first() != newPos || newPos != pathPoints_.last())\r\n        {\r\n            pathPoints_[selected_] = newPos;       \r\n\r\n            if (pathPoints_.size() > 2)\r\n            {\r\n                int adjacent = selected_ + 1;\r\n                int next = selected_ + 2;\r\n\r\n                if (selected_ == pathPoints_.size() - 1)\r\n                {\r\n                    adjacent = selected_ - 1;\r\n                    next = selected_ - 2;\r\n                }\r\n\r\n                // Adjust also the adjacent point to the same x- or y-axis.\r\n                if (qFuzzyCompare(pathPoints_.at(adjacent).x(), pathPoints_.at(next).x()))\r\n                {\r\n                    pathPoints_[adjacent].setY(newPos.y());\r\n                }\r\n                else\r\n                {\r\n                    pathPoints_[adjacent].setX(newPos.x());\r\n                }\r\n            }\r\n\r\n            setRoute(pathPoints_);\r\n        }\r\n    }\r\n    else if (selectionType_ == SEGMENT)\r\n    {\r\n        if (qFuzzyCompare(pathPoints_.at(selected_).x(), pathPoints_.at(selected_ + 1).x()))\r\n        {\r\n            // Clamp the movement delta.\r\n            qreal delta = newPos.x() - pathPoints_.at(selected_).x();\r\n            qreal prev = pathPoints_.at(selected_ - 1).x();\r\n            qreal cur = pathPoints_.at(selected_).x();\r\n            qreal next = pathPoints_.at(selected_ + 2).x();\r\n\r\n            if (cur > next)\r\n            {\r\n                delta = qMax(delta, DefaultRouting::MIN_START_LENGTH + next - cur);\r\n            }\r\n            else\r\n            {\r\n                delta = qMin(delta, -DefaultRouting::MIN_START_LENGTH + next - cur);\r\n            }\r\n\r\n            if (cur > prev)\r\n            {\r\n                delta = qMax(delta, DefaultRouting::MIN_START_LENGTH + prev - cur);\r\n            }\r\n            else\r\n            {\r\n                delta = qMin(delta, -DefaultRouting::MIN_START_LENGTH + prev - cur);\r\n            }\r\n\r\n            pathPoints_[selected_].setX(pathPoints_.at(selected_).x() + delta);\r\n            pathPoints_[selected_+1].setX(pathPoints_.at(selected_+1).x() + delta);\r\n        }\r\n        else if (qFuzzyCompare(pathPoints_.at(selected_).y(), pathPoints_.at(selected_+1).y()))\r\n        {\r\n            qreal prev = pathPoints_.at(selected_ - 1).y();\r\n            qreal next = pathPoints_.at(selected_ + 2).y();\r\n\r\n            // Change the route only if the next and previous segments would not be too short.\r\n            if (qAbs(newPos.y() - prev) >= DefaultRouting::MIN_LENGTH &&\r\n                qAbs(newPos.y() - next) >= DefaultRouting::MIN_LENGTH)\r\n            {\r\n                pathPoints_[selected_].setY(newPos.y());\r\n                pathPoints_[selected_+1].setY(newPos.y());\r\n            }\r\n        }\r\n\r\n        setRoute(pathPoints_);\r\n    }\r\n\r\n    QGraphicsPathItem::mouseMoveEvent(mouseEvent);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: GraphicsConnection::mouseReleaseEvent()\r\n//-----------------------------------------------------------------------------\r\nvoid GraphicsConnection::mouseReleaseEvent(QGraphicsSceneMouseEvent *mouseEvent)\r\n{\r\n    if (selectionType_ == END)\r\n    {\r\n        auto endpoint1 = DiagramUtil::snapToItem<ConnectionEndpoint>(pathPoints_.first(), scene(), GridSize);\r\n        auto endpoint2 = DiagramUtil::snapToItem<ConnectionEndpoint>(pathPoints_.last(), scene(), GridSize);\r\n\r\n        if (endpoint1 != nullptr && endpoint2 != nullptr &&\r\n            endpoint1->canConnect(endpoint2) && endpoint2->canConnect(endpoint1))\r\n        {\r\n            connectEnds();\r\n        }\r\n    }\r\n    else if (selectionType_ == SEGMENT && !parent_->isProtected())\r\n    {\r\n        fixOverlap();\r\n        setRoute(pathPoints_);\r\n    }\r\n\r\n    if (route() != oldRoute_)\r\n    {\r\n        QSharedPointer<QUndoCommand> cmd(new ConnectionMoveCommand(this, oldRoute_));\r\n        parent_->getEditProvider()->addCommand(cmd);\r\n        cmd->redo();\r\n    }\r\n\r\n    QGraphicsPathItem::mouseReleaseEvent(mouseEvent);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: GraphicsConnection::paint()\r\n//-----------------------------------------------------------------------------\r\nvoid GraphicsConnection::paint(QPainter* painter, QStyleOptionGraphicsItem const* option, QWidget* widget)\r\n{\r\n    bool selected = option->state & QStyle::State_Selected;\r\n\r\n    QStyleOptionGraphicsItem myoption = *option;\r\n    myoption.state &= !QStyle::State_Selected;\r\n\r\n    QGraphicsPathItem::paint(painter, &myoption, widget);\r\n\r\n    if (!selected && !positionUpdateInProcess_ && routingMode_ == ROUTING_MODE_NORMAL)\r\n    {\r\n        drawOverlapGraphics(painter);\r\n    }\r\n\r\n    if (!endpoint1_)\r\n    {\r\n        painter->fillRect(QRectF(pathPoints_.first() - QPointF(2,2), pathPoints_.first() + QPointF(2,2)),\r\n            QBrush(Qt::red));\r\n    }\r\n\r\n    if (!endpoint2_)\r\n    {\r\n        painter->fillRect(QRectF(pathPoints_.last() - QPointF(2,2), pathPoints_.last() + QPointF(2,2)),\r\n            QBrush(Qt::red));\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: GraphicsConnection::hoverEnterEvent()\r\n//-----------------------------------------------------------------------------\r\nvoid GraphicsConnection::hoverEnterEvent(QGraphicsSceneHoverEvent* hoverEvent)\r\n{\r\n    hoveredAbove_ = true;\r\n    setDefaultColor();\r\n    setZValue(-500); // Move current connection up.\r\n\r\n    auto hoverPosX = hoverEvent->pos().x();\r\n    auto hoverPosY = hoverEvent->pos().y();\r\n\r\n    // Look for intersections at and 2x2 pixels around hover position. Helps with highlighting \r\n    // items on top of each other.\r\n    auto const& intersectingItems = parent_->items(hoverPosX, hoverPosY, static_cast<qreal>(2), static_cast<qreal>(2), \r\n        Qt::IntersectsItemShape, Qt::DescendingOrder);\r\n\r\n    for (auto intersectingItem : intersectingItems)\r\n    {\r\n        // Highlight item and set topmost if graphics connection.\r\n        if (auto graphicsConnection = dynamic_cast<GraphicsConnection*>(intersectingItem))\r\n        {\r\n            graphicsConnection->setZValue(-500);\r\n            graphicsConnection->setHovered(true);\r\n            graphicsConnection->setDefaultColor();\r\n        }\r\n    }\r\n\r\n    QGraphicsPathItem::hoverEnterEvent(hoverEvent);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: GraphicsConnection::hoverLeaveEvent()\r\n//-----------------------------------------------------------------------------\r\nvoid GraphicsConnection::hoverLeaveEvent(QGraphicsSceneHoverEvent* hoverEvent)\r\n{\r\n    hoveredAbove_ = false;\r\n    setDefaultColor();\r\n    setZValue(-1000); // Move current connection back to original level.\r\n\r\n    for (auto intersectingItem : parent_->items(shape(), Qt::IntersectsItemShape, Qt::DescendingOrder))\r\n    {\r\n        if (auto graphicsConnection = dynamic_cast<GraphicsConnection*>(intersectingItem))\r\n        {\r\n            bool connectionIsSelected = graphicsConnection->isSelected();\r\n\r\n            // Reset z-value, if not selected.\r\n            graphicsConnection->setZValue(connectionIsSelected ? -500 : -1000);\r\n            graphicsConnection->setHovered(false);\r\n            graphicsConnection->setDefaultColor();\r\n        }\r\n    }\r\n\r\n    QGraphicsPathItem::hoverLeaveEvent(hoverEvent);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: GraphicsConnection::setItemSettings()\r\n//-----------------------------------------------------------------------------\r\nvoid GraphicsConnection::setItemSettings()\r\n{\r\n    setZValue(-1000);\r\n    setLineWidth(2);\r\n    setFlag(ItemIsSelectable);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: GraphicsConnection::createRoute()\r\n//-----------------------------------------------------------------------------\r\nvoid GraphicsConnection::createRoute(ConnectionEndpoint* endpoint1, ConnectionEndpoint* endpoint2)\r\n{\r\n    if (!endpoint1 || !endpoint2)\r\n    {\r\n        return;\r\n    }\r\n\r\n    QPointF startPoint = endpoint1->scenePos();\r\n    QPointF endPoint = endpoint2->scenePos();\r\n\r\n    if (!endpoint1->isDirectionFixed())\r\n    {\r\n        if (startPoint.x() <= endPoint.x())\r\n        {\r\n            endpoint1->setDirection(QVector2D(1.0f, 0.0f));\r\n        }\r\n        else\r\n        {\r\n            endpoint1->setDirection(QVector2D(-1.0f, 0.0f));\r\n        }\r\n    }\r\n\r\n    if (!endpoint2->isDirectionFixed())\r\n    {\r\n        if (startPoint.x() <= endPoint.x())\r\n        {\r\n            endpoint2->setDirection(QVector2D(-1.0f, 0.0f));\r\n        }\r\n        else\r\n        {\r\n            endpoint2->setDirection(QVector2D(1.0f, 0.0f));\r\n        }\r\n    }\r\n\r\n    pathPoints_ = DefaultRouting::createRoute(startPoint, endPoint, \r\n        endpoint1->getDirection(), endpoint2->getDirection());\r\n    \r\n    setRoute(pathPoints_);\r\n\r\n    paintConnectionPath();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: GraphicsConnection::paintConnectionPath()\r\n//-----------------------------------------------------------------------------\r\nvoid GraphicsConnection::paintConnectionPath()\r\n{\r\n    QListIterator<QPointF> i(pathPoints_);\r\n\r\n    QPainterPath path(i.next());\r\n\r\n    while (i.hasNext())\r\n    {\r\n        path.lineTo(i.next());\r\n    }\r\n\r\n    QPainterPathStroker stroker;\r\n    setPath(stroker.createStroke(path));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: GraphicsConnection::updateName()\r\n//-----------------------------------------------------------------------------\r\nQString GraphicsConnection::createDefaultName() const\r\n{\r\n    Q_ASSERT(endpoint1_ != 0);\r\n    Q_ASSERT(endpoint2_ != 0);\r\n\r\n    // Determine one of the end points as the starting point in a way that its encompassing component is defined.\r\n    ConnectionEndpoint* start = endpoint1_;\r\n    ConnectionEndpoint* end = endpoint2_;\r\n\r\n    if (start->encompassingComp() == nullptr && end->encompassingComp() != nullptr)\r\n    {\r\n        std::swap(start, end);\r\n    }\r\n\r\n    auto startComponentName = QString();\r\n    if (start->encompassingComp() != nullptr)\r\n    {\r\n        startComponentName = start->encompassingComp()->name() + \"_\";\r\n    }\r\n\r\n    auto endComponentName = QString();\r\n    if (end->encompassingComp() != nullptr)\r\n    {\r\n        endComponentName = end->encompassingComp()->name() + \"_\";\r\n    }\r\n\r\n    return startComponentName + start->name() + \"_to_\" + endComponentName + end->name();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: GraphicsConnection::disconnectEnds()\r\n//-----------------------------------------------------------------------------\r\nvoid GraphicsConnection::disconnectEnds()\r\n{\r\n    // Discard existing connections.\r\n    if (endpoint1_)\r\n    {\r\n        endpoint1_->removeConnection(this);\r\n        endpoint1_->onDisconnect();\r\n        endpoint1_->setSelectionHighlight(false);\r\n    }\r\n\r\n    if (endpoint2_)\r\n    {\r\n        endpoint2_->removeConnection(this);\r\n        endpoint2_->onDisconnect();\r\n        endpoint2_->setSelectionHighlight(false);\r\n    }\r\n\r\n    endpoint1_ = nullptr;\r\n    endpoint2_ = nullptr;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: GraphicsConnection::itemChange()\r\n//-----------------------------------------------------------------------------\r\nQVariant GraphicsConnection::itemChange(GraphicsItemChange change, const QVariant &value)\r\n{\r\n    if (change == ItemSelectedHasChanged)\r\n    {\r\n        bool selected = value.toBool();\r\n        setZValue(selected ? -500 : -1000); // Move up, if selected, down if unselected.\r\n        setDefaultColor();\r\n\r\n        if (endpoint1_ != nullptr)\r\n        {\r\n            endpoint1_->setSelectionHighlight(selected);\r\n        }\r\n\r\n        if (endpoint2_ != nullptr)\r\n        {\r\n            endpoint2_->setSelectionHighlight(selected);\r\n        }\r\n    }\r\n\r\n    return QGraphicsPathItem::itemChange(change, value);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: GraphicsConnection::shape()\r\n//-----------------------------------------------------------------------------\r\nQPainterPath GraphicsConnection::shape() const\r\n{\r\n    // Widen the shape of the connection item to make it easier to select.\r\n    QPainterPathStroker stroker;\r\n    stroker.setWidth(10);\r\n    return stroker.createStroke(path());\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: GraphicsConnection::beginUpdatePosition()\r\n//-----------------------------------------------------------------------------\r\nvoid GraphicsConnection::beginUpdatePosition()\r\n{\r\n    oldRoute_ = route();\r\n    positionUpdateInProcess_ = true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: GraphicsConnection::endUpdatePosition()\r\n//-----------------------------------------------------------------------------\r\nQUndoCommand* GraphicsConnection::endUpdatePosition(QUndoCommand* parent)\r\n{\r\n    positionUpdateInProcess_ = false;\r\n\r\n    if (!parent_->isProtected())\r\n    {\r\n        simplifyPath();\r\n        fixOverlap();        \r\n        setRoute(pathPoints_);\r\n    }\r\n\r\n    if (route() != oldRoute_)\r\n    {        \r\n        QUndoCommand* undoCommand = new ConnectionMoveCommand(this, oldRoute_, parent);\r\n        oldRoute_.clear();\r\n        return undoCommand;\r\n    }\r\n    else\r\n    {\r\n        return nullptr;\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: GraphicsConnection::setRoutingMode()\r\n//-----------------------------------------------------------------------------\r\nvoid GraphicsConnection::setRoutingMode(RoutingMode style)\r\n{\r\n    if (routingMode_ != style)\r\n    {\r\n        routingMode_ = style;\r\n        \r\n        if (style == ROUTING_MODE_NORMAL)\r\n        {\r\n            setVisible(true);\r\n        }\r\n\r\n        setDefaultColor();\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: GraphicsConnection::setDefaultColor()\r\n//-----------------------------------------------------------------------------\r\nvoid GraphicsConnection::setDefaultColor()\r\n{\r\n    QPen newPen = pen();\r\n\r\n    if (isSelected())\r\n    {\r\n        newPen.setColor(KactusColors::DIAGRAM_SELECTION);\r\n    }\r\n    else if (hoveredAbove_)\r\n    {\r\n        newPen.setColor(KactusColors::MASTER_INTERFACE);\r\n    }\r\n    else if (invalid_)\r\n    {\r\n        newPen.setColor(KactusColors::BROKEN_CONNECTION);\r\n    }\r\n    else if (routingMode_ == ROUTING_MODE_NORMAL)\r\n    {\r\n        if (getConnectionType() == ConnectionEndpoint::ENDPOINT_TYPE_COM)\r\n        {\r\n            newPen.setColor(KactusColors::COM_CONNECTION);\r\n        }\r\n        else\r\n        {\r\n            newPen.setColor(KactusColors::REGULAR_CONNECTION);\r\n        }\r\n    }\r\n    else\r\n    {\r\n        newPen.setColor(KactusColors::UNKNOWN_CONNECTION);\r\n    }\r\n\r\n    setPen(newPen);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: GraphicsConnection::drawOverlapGraphics()\r\n//-----------------------------------------------------------------------------\r\nvoid GraphicsConnection::drawOverlapGraphics(QPainter* painter)\r\n{\r\n    for (QGraphicsItem* item : scene()->items())\r\n    {\r\n        if (item->isVisible() && item != this)\r\n        {\r\n            auto connection = dynamic_cast<GraphicsConnection*>(item);\r\n            if (connection && collidesWithItem(item))\r\n            {\r\n                drawOverlapWithConnection(painter, connection);\r\n            }\r\n            else if(dynamic_cast<ComponentItem*>(item) && collidesWithItem(item))\r\n            {\r\n                drawOverlapWithComponent(painter, item);\r\n            }\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: GraphicsConnection::drawOverlapWithConnection()\r\n//-----------------------------------------------------------------------------\r\nvoid GraphicsConnection::drawOverlapWithConnection(QPainter* painter, GraphicsConnection* connection)\r\n{\r\n    QList<QLineF> connectionLines = pointsToLines(connection->route());\r\n\r\n    for (QLineF const& pathLine : pathLines_)\r\n    {                \r\n        if (!qFuzzyIsNull(pathLine.dy())) //<! Discard horizontal segments of this connection line.\r\n        {\r\n            for (QLineF const& connectionLine : connectionLines)\r\n            {             \r\n                if (!qFuzzyIsNull(connectionLine.dx())) //<! Discard vertical segments of the intersecting line.\r\n                {\r\n                    QPointF intersectionPoint;\r\n                    QLineF::IntersectType type = pathLine.intersects(connectionLine, &intersectionPoint);\r\n\r\n                    if (type == QLineF::BoundedIntersection)\r\n                    {\r\n                        // If the connections share an endpoint, draw a black junction circle.\r\n                        if (endpoint1() == connection->endpoint1() || endpoint2() == connection->endpoint2() ||\r\n                            endpoint1() == connection->endpoint2() || endpoint2() == connection->endpoint1())\r\n                        {\r\n                            drawJunctionPoint(painter, intersectionPoint);\r\n                        }\r\n                        else\r\n                        {\r\n                            // Otherwise draw a gray undercrossing line close to the intersection point.\r\n                            drawUndercrossing(painter, pathLine, intersectionPoint, connection->pen().width());\r\n                        }\r\n                    }\r\n                }\r\n            }\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: GraphicsConnection::drawJunctionPoint()\r\n//-----------------------------------------------------------------------------\r\nvoid GraphicsConnection::drawJunctionPoint(QPainter* painter, QPointF const& intersectionPoint)\r\n{\r\n    painter->setPen(QPen(Qt::black, 0));\r\n\r\n    QPainterPath circlePath;\r\n    circlePath.addEllipse(intersectionPoint, 5.0, 5.0);\r\n\r\n    painter->fillPath(circlePath, QBrush(Qt::black));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: GraphicsConnection::drawUndercrossing()\r\n//-----------------------------------------------------------------------------\r\nvoid GraphicsConnection::drawUndercrossing(QPainter* painter, QLineF const& path, QPointF const& crossingPoint, \r\n    int crossConnectionWidth)\r\n{   \r\n    // Drawing is performed using two lines, excluding the area close to\r\n    // the intersection point. This way the drawing is done correctly even though\r\n    // the connection is above the other connection.\r\n    QVector2D direction(path.dx(), path.dy());\r\n    direction.normalize();\r\n\r\n    qreal length1 = QVector2D(crossingPoint - path.p1()).length();\r\n    qreal length2 = QVector2D(crossingPoint - path.p2()).length();\r\n\r\n    qreal crossingWidth = 3;\r\n\r\n    // If both lines are thick, we have to use a thicker width.\r\n    if (pen().width() >= 3 && crossConnectionWidth >= 3)\r\n    {\r\n        crossingWidth++;\r\n    }\r\n\r\n    painter->setPen(QPen(KactusColors::CONNECTION_UNDERCROSSING, pen().width() + 1));\r\n\r\n    if (length1 > 0.5f)\r\n    {\r\n        QPointF seg2Pt1 = (QVector2D(crossingPoint) - direction * qMin(length1, crossingWidth)).toPointF();\r\n        QPointF seg2Pt2 = (QVector2D(crossingPoint) - direction * qMin(length1, (qreal)GridSize/2)).toPointF();\r\n        painter->drawLine(seg2Pt1, seg2Pt2);\r\n    }\r\n\r\n    if (length2 > 0.5f)\r\n    {\r\n        QPointF seg1Pt1 = (QVector2D(crossingPoint) + direction * qMin(length2, crossingWidth)).toPointF();\r\n        QPointF seg1Pt2 = (QVector2D(crossingPoint) + direction * qMin(length2, (qreal)GridSize/2)).toPointF();\r\n        painter->drawLine(seg1Pt1, seg1Pt2);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: GraphicsConnection::drawOverlapWithComponent()\r\n//-----------------------------------------------------------------------------\r\nvoid GraphicsConnection::drawOverlapWithComponent(QPainter* painter, QGraphicsItem* item)\r\n{\r\n    auto comp = static_cast<ComponentItem*>(item);\r\n    QRectF componentRect = comp->rect();\r\n\r\n    // Create the line objects for each edge of the diagram component rectangle.\r\n    QLineF leftEdge(comp->mapToScene(componentRect.topLeft()), comp->mapToScene(componentRect.bottomLeft()));\r\n    QLineF rightEdge(comp->mapToScene(componentRect.topRight()), comp->mapToScene(componentRect.bottomRight()));\r\n    QLineF topEdge(comp->mapToScene(componentRect.topLeft()), comp->mapToScene(componentRect.topRight()));\r\n    QLineF bottomEdge(comp->mapToScene(componentRect.bottomLeft()),\r\n        comp->mapToScene(componentRect.bottomRight()));\r\n\r\n    for (QLineF const& pathLine : pathLines_)\r\n    {                \r\n        // Check for intersections with the component rectangle's edges.\r\n        QPointF leftPoint;\r\n        QPointF rightPoint;\r\n        QPointF topPoint;\r\n        QPointF bottomPoint;\r\n\r\n        QLineF::IntersectType leftIntersection = pathLine.intersects(leftEdge, &leftPoint);\r\n        QLineF::IntersectType rightIntersection = pathLine.intersects(rightEdge, &rightPoint);\r\n        QLineF::IntersectType topIntersection = pathLine.intersects(topEdge, &topPoint);\r\n        QLineF::IntersectType bottomIntersection = pathLine.intersects(bottomEdge, &bottomPoint);\r\n\r\n        painter->setPen(QPen(KactusColors::CONNECTION_UNDERCROSSING, pen().width() + 1));\r\n\r\n        if (leftIntersection == QLineF::BoundedIntersection && leftPoint != pathPoints_.first() &&\r\n            leftPoint != pathPoints_.last())\r\n        {\r\n            drawLineGap(painter, pathLine, leftPoint);\r\n        }\r\n\r\n        if (rightIntersection == QLineF::BoundedIntersection && rightPoint != pathPoints_.first() &&\r\n            rightPoint != pathPoints_.last())\r\n        {\r\n            drawLineGap(painter, pathLine, rightPoint);\r\n\r\n            // Fill in the whole line segment under the component if the segment goes across the component\r\n            // horizontally.\r\n            if (leftIntersection == QLineF::BoundedIntersection)\r\n            {\r\n                painter->drawLine(leftPoint, rightPoint);\r\n            }\r\n        }\r\n\r\n        if (topIntersection == QLineF::BoundedIntersection)\r\n        {\r\n            drawLineGap(painter, pathLine, topPoint);\r\n        }\r\n\r\n        if (bottomIntersection == QLineF::BoundedIntersection)\r\n        {\r\n            drawLineGap(painter, pathLine, bottomPoint);\r\n\r\n            // Fill in the whole line segment under the component if the segment goes across the component\r\n            // vertically.\r\n            if (topIntersection == QLineF::BoundedIntersection)\r\n            {\r\n                painter->drawLine(topPoint, bottomPoint);\r\n            }\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: GraphicsConnection::drawLineGap()\r\n//-----------------------------------------------------------------------------\r\nvoid GraphicsConnection::drawLineGap(QPainter* painter, QLineF const& line1, QPointF const& pt)\r\n{\r\n    QVector2D dir(line1.dx(), line1.dy());\r\n    dir.normalize();\r\n\r\n    qreal length1 = QVector2D(pt - line1.p1()).length();\r\n    qreal length2 = QVector2D(pt - line1.p2()).length();\r\n\r\n    QPointF pt1 = (QVector2D(pt) + dir * qMin(length2, (qreal)GridSize / 2)).toPointF();\r\n    QPointF pt2 = (QVector2D(pt) - dir * qMin(length1, (qreal)GridSize) / 2).toPointF();\r\n    painter->drawLine(pt1, pt2);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: GraphicsConnection::setLineWidth()\r\n//-----------------------------------------------------------------------------\r\nvoid GraphicsConnection::setLineWidth(int width)\r\n{\r\n    QPen newPen = pen();\r\n    newPen.setWidth(width);\r\n    setPen(newPen);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: GraphicsConnection::getConnectionType()\r\n//-----------------------------------------------------------------------------\r\nConnectionEndpoint::EndpointType GraphicsConnection::getConnectionType() const\r\n{\r\n    if (endpoint1() == nullptr && endpoint2() == nullptr)\r\n    {\r\n        return ConnectionEndpoint::ENDPOINT_TYPE_UNDEFINED;\r\n    }\r\n\r\n    if (endpoint1()->getType() != ConnectionEndpoint::ENDPOINT_TYPE_UNDEFINED)\r\n    {\r\n        return endpoint1()->getType();\r\n    }\r\n    else\r\n    {\r\n        return endpoint2()->getType();\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: GraphicsConnection::getRoutingMode()\r\n//-----------------------------------------------------------------------------\r\nGraphicsConnection::RoutingMode GraphicsConnection::getRoutingMode() const\r\n{\r\n    return routingMode_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HWConnection::getRouteExtension()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<ConnectionRoute> GraphicsConnection::getRouteExtension() const\r\n{\r\n    return route_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: GraphicsConnection::setImported()\r\n//-----------------------------------------------------------------------------\r\nvoid GraphicsConnection::setImported(bool imported)\r\n{\r\n    imported_ = imported;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: GraphicsConnection::isImported()\r\n//-----------------------------------------------------------------------------\r\nbool GraphicsConnection::isImported() const\r\n{\r\n    return imported_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: GraphicsConnection::validate()\r\n//-----------------------------------------------------------------------------\r\nvoid GraphicsConnection::validate()\r\n{\r\n    invalid_ = !endpoint1_->isConnectionValid(endpoint2_) || !endpoint2_->isConnectionValid(endpoint1_);\r\n    commonValidation();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: GraphicsConnection::reValidate()\r\n//-----------------------------------------------------------------------------\r\nvoid GraphicsConnection::reValidate()\r\n{\r\n    invalid_ = !endpoint1()->isExistingConnectionValid(endpoint2_) || !endpoint2_->isExistingConnectionValid(endpoint1_);\r\n    commonValidation();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: GraphicsConnection::commonValidation()\r\n//-----------------------------------------------------------------------------\r\nvoid GraphicsConnection::commonValidation()\r\n{\r\n\tsetDefaultColor();\r\n\tendpoint1_->updateInterface();\r\n\tendpoint2_->updateInterface();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: GraphicsConnection::setEndpoint1()\r\n//-----------------------------------------------------------------------------\r\nvoid GraphicsConnection::setEndpoint1(ConnectionEndpoint* endpoint1)\r\n{\r\n    if (endpoint1_ != nullptr)\r\n    {\r\n        // Disconnect from the previous endpoint.\r\n        endpoint1_->removeConnection(this);\r\n        endpoint1_->onDisconnect();\r\n    }\r\n\r\n    // Connect to the new endpoint.\r\n    endpoint1_ = endpoint1;\r\n    endpoint1_->onConnect(endpoint2_);\r\n\r\n    validate();\r\n\r\n    endpoint1->addConnection(this);\r\n\r\n    updatePosition();\r\n    setName(createDefaultName());\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: GraphicsConnection::setEndpoint2()\r\n//-----------------------------------------------------------------------------\r\nvoid GraphicsConnection::setEndpoint2(ConnectionEndpoint* endpoint2)\r\n{\r\n    if (endpoint2_ != nullptr)\r\n    {\r\n        // Disconnect from the previous endpoint.\r\n        endpoint2_->removeConnection(this);\r\n        endpoint2_->onDisconnect();\r\n    }\r\n\r\n    // Connect to the new endpoint.\r\n    endpoint2_ = endpoint2;\r\n    endpoint2_->onConnect(endpoint1_);\r\n\r\n    validate();\r\n\r\n    endpoint2->addConnection(this);\r\n\r\n    updatePosition();\r\n    setName(createDefaultName());\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: GraphicsConnection::isInvalid()\r\n//-----------------------------------------------------------------------------\r\nbool GraphicsConnection::isInvalid() const\r\n{\r\n    return invalid_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: GraphicsConnection::setHovered()\r\n//-----------------------------------------------------------------------------\r\nvoid GraphicsConnection::setHovered(bool hovered)\r\n{\r\n    hoveredAbove_ = hovered;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: GraphicsConnection::getHovered()\r\n//-----------------------------------------------------------------------------\r\nbool GraphicsConnection::getHovered() const\r\n{\r\n    return hoveredAbove_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: GraphicsConnection::hasDefaultName()\r\n//-----------------------------------------------------------------------------\r\nbool GraphicsConnection::hasDefaultName() const\r\n{\r\n    return (createDefaultName() == route_->name());\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: GraphicsConnection::toggleOffPage()\r\n//-----------------------------------------------------------------------------\r\nvoid GraphicsConnection::toggleOffPage()\r\n{\r\n    route_->setOffpage(!route_->isOffpage());\r\n\r\n    // Determine the new end points for the connection.\r\n    ConnectionEndpoint* endpoint1 = endpoint1_;\r\n    ConnectionEndpoint* endpoint2 = endpoint2_;\r\n    \r\n    if (endpoint1->type() == OffPageConnectorItem::Type)\r\n    {\r\n        endpoint1 = static_cast<ConnectionEndpoint*>(endpoint1->parentItem());\r\n        endpoint2 = static_cast<ConnectionEndpoint*>(endpoint2->parentItem());\r\n    }\r\n    else\r\n    {\r\n        endpoint1 = endpoint1->getOffPageConnector();\r\n        endpoint2 = endpoint2->getOffPageConnector();\r\n    }\r\n\r\n    // Disconnect old endpoints.\r\n    endpoint1_->removeConnection(this);\r\n    endpoint2_->removeConnection(this);\r\n\r\n    // Connect new endpoints.\r\n    endpoint1_ = endpoint1;\r\n    endpoint2_ = endpoint2;\r\n\r\n    endpoint1_->addConnection(this);\r\n    endpoint2_->addConnection(this);\r\n\r\n    updatePosition();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: GraphicsConnection::isOffPage()\r\n//-----------------------------------------------------------------------------\r\nbool GraphicsConnection::isOffPage() const\r\n{\r\n    return route_->isOffpage();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: GraphicsConnection::fixOverlap()\r\n//-----------------------------------------------------------------------------\r\nvoid GraphicsConnection::fixOverlap()\r\n{\r\n    // Overlap fix is possible only for normally routed connections.\r\n    if (routingMode_ != ROUTING_MODE_NORMAL)\r\n    {\r\n        return;\r\n    }\r\n\r\n    // Build segment bounding lists based on the other existing connections.\r\n    QList<SegmentBound> horizontalBounds;\r\n    QList<SegmentBound> verticalBounds;\r\n    createSegmentBounds(verticalBounds, horizontalBounds);\r\n    \r\n    // Iteratively move segments until the solution does not change.\r\n    bool solutionChanged = true;\r\n\r\n    while (solutionChanged)\r\n    {\r\n        solutionChanged = false;\r\n\r\n        for (int i = 1; i < pathPoints_.size() - 2; ++i)\r\n        {\r\n            // Check if the segment is vertical.\r\n            if (qFuzzyCompare(pathPoints_.at(i).x(), pathPoints_.at(i + 1).x()))\r\n            {\r\n                if (fixVerticalSegmentClearance(verticalBounds, i))\r\n                {\r\n                    solutionChanged = true;\r\n                }\r\n            }\r\n            // Otherwise check if the segment is horizontal.\r\n            else if (qFuzzyCompare(pathPoints_.at(i).y(), pathPoints_.at(i + 1).y()))\r\n            {\r\n                if (fixHorizontalSegmentClearance(horizontalBounds, i))\r\n                {\r\n                    solutionChanged = true;\r\n                }\r\n            }\r\n        }\r\n    }\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: GraphicsConnection::createSegmentBounds()\r\n//-----------------------------------------------------------------------------\r\nvoid GraphicsConnection::createSegmentBounds(QList<SegmentBound>& verticalBounds,\r\n                                             QList<SegmentBound>& horizontalBounds)\r\n{\r\n    for (QGraphicsItem* item : scene()->items())\r\n    {\r\n        auto const conn = dynamic_cast<GraphicsConnection const*>(item);\r\n\r\n        // If the connections share an endpoint, discard it from the segment bounds.\r\n        if (conn != 0 && conn != this &&\r\n            endpoint1() != conn->endpoint1() && endpoint2() != conn->endpoint2() &&\r\n            endpoint1() != conn->endpoint2() && endpoint2() != conn->endpoint1())\r\n        {\r\n            for (int i = 0; i < conn->route().size() - 1; ++i)\r\n            {\r\n                if (qFuzzyCompare(conn->route().at(i).x(), conn->route().at(i + 1).x()))\r\n                {\r\n                    verticalBounds.append(SegmentBound(conn->route().at(i), conn->route().at(i + 1)));\r\n                }\r\n                else\r\n                {\r\n                    horizontalBounds.append(SegmentBound(conn->route().at(i), conn->route().at(i + 1)));\r\n                }\r\n            }\r\n        }\r\n    }\r\n\r\n    // Add start and end segments of this connection also to the list of horizontal bounds.\r\n    if (pathPoints_.size() >= 2)\r\n    {\r\n        horizontalBounds.append(SegmentBound(pathPoints_.first(), pathPoints_.at(1)));\r\n        horizontalBounds.append(SegmentBound(pathPoints_.at(pathPoints_.size() - 2), pathPoints_.last()));\r\n    }\r\n\r\n    std::sort(horizontalBounds.begin(), horizontalBounds.end(), sortBoundsByY);\r\n    std::sort(verticalBounds.begin(), verticalBounds.end(), sortBoundsByX);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: GraphicsConnection::sortBoundsByX()\r\n//-----------------------------------------------------------------------------\r\nbool GraphicsConnection::sortBoundsByX(SegmentBound const& lhs, SegmentBound const& rhs)\r\n{\r\n    return (lhs.minX < rhs.minX || (lhs.minX == rhs.minX && lhs.minY < rhs.minY));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: GraphicsConnection::sortBoundsByY()\r\n//-----------------------------------------------------------------------------\r\nbool GraphicsConnection::sortBoundsByY(SegmentBound const& lhs, SegmentBound const& rhs)\r\n{\r\n    return (lhs.minY < rhs.minY || (lhs.minY == rhs.minY && lhs.minX < rhs.minX));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: GraphicsConnection::simplifyPath()\r\n//-----------------------------------------------------------------------------\r\nvoid GraphicsConnection::simplifyPath()\r\n{\r\n    if (pathPoints_.size() < 3)\r\n    {\r\n        return;\r\n    }\r\n\r\n    for (int i = 0; i < pathPoints_.size() - 2; ++i)\r\n    {\r\n        QVector2D pt0 = QVector2D(pathPoints_[i]);\r\n        QVector2D pt1 = QVector2D(pathPoints_[i + 1]);\r\n        QVector2D pt2 = QVector2D(pathPoints_[i + 2]);\r\n\r\n        QVector2D delta1 = pt1 - pt0;\r\n        QVector2D delta2 = pt2 - pt1;\r\n\r\n        QVector2D deltaProj = QVector2D::dotProduct(delta2, delta1.normalized()) * delta1.normalized();\r\n\r\n        // If the path was otherwise ok, just remove parallel lines.\r\n        if (qFuzzyCompare(deltaProj, delta2))\r\n        {\r\n            pathPoints_.removeAt(i + 1);\r\n            --i;\r\n        }                                \r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: GraphicsConnection::getSegmentLimitsX()\r\n//-----------------------------------------------------------------------------\r\nQPair<qreal, qreal> GraphicsConnection::getSegmentLimitsX(int i) const\r\n{\r\n    // Prevent connections going out of the left edge.\r\n    qreal minX = 10.0;\r\n    qreal maxX = 100000.0f;\r\n\r\n    // Clamp the min and max.\r\n    qreal prev = pathPoints_.at(i - 1).x();\r\n    qreal cur = pathPoints_.at(i).x();\r\n    qreal next = pathPoints_.at(i + 2).x();\r\n\r\n    if (cur > next)\r\n    {\r\n        minX = qMax(minX, next + DefaultRouting::MIN_START_LENGTH);\r\n    }\r\n    else\r\n    {\r\n        maxX = qMin(maxX, next - DefaultRouting::MIN_START_LENGTH);\r\n    }\r\n\r\n    if (cur > prev)\r\n    {\r\n        minX = qMax(minX, DefaultRouting::MIN_START_LENGTH + prev);\r\n    }\r\n    else\r\n    {\r\n        maxX = qMin(maxX, prev - DefaultRouting::MIN_START_LENGTH);\r\n    }\r\n\r\n    return qMakePair(minX, maxX);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: GraphicsConnection::getSegmentLimitsY()\r\n//-----------------------------------------------------------------------------\r\nQPair<qreal, qreal> GraphicsConnection::getSegmentLimitsY(int i) const\r\n{\r\n    // Use simple distance based min and max.\r\n    qreal minY = qMax(30.0, pathPoints_.at(i).y() - 500.0);\r\n    qreal maxY = pathPoints_.at(i).y() + 500.0;\r\n\r\n    return qMakePair(minY, maxY);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: GraphicsConnection::findVerticalSegmentOverlap()\r\n//-----------------------------------------------------------------------------\r\nint GraphicsConnection::findVerticalSegmentOverlap(QList<SegmentBound> const& verBounds, SegmentBound const& bounds)\r\n{\r\n    // Check all bounds that have the same X.\r\n    for (int i = 0; i < verBounds.size(); i++)\r\n    {\r\n        if (qFuzzyCompare(verBounds.at(i).minX, bounds.minX) &&\r\n            qFuzzyCompare(verBounds.at(i).maxX, bounds.minX))\r\n        {\r\n            if (testSegmentOverlapY(verBounds.at(i), bounds))\r\n            {\r\n                return i;\r\n            }\r\n        }\r\n    }\r\n\r\n    return -1;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: GraphicsConnection::findHorizontalSegmentOverlap()\r\n//-----------------------------------------------------------------------------\r\nint GraphicsConnection::findHorizontalSegmentOverlap(QList<SegmentBound> const& horBounds, SegmentBound const& bounds)\r\n{\r\n    // Check all bounds that have the same Y.\r\n    for (int i = 0; i < horBounds.size(); i++)\r\n    {\r\n        if (qFuzzyCompare(horBounds.at(i).minY, bounds.minY) &&\r\n            qFuzzyCompare(horBounds.at(i).maxY, bounds.minY))\r\n        {\r\n            if (testSegmentOverlapX(horBounds.at(i), bounds))\r\n            {\r\n                return i;\r\n            }\r\n        }\r\n    }\r\n\r\n    return -1;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: GraphicsConnection::fixVerticalSegmentClearance()\r\n//-----------------------------------------------------------------------------\r\nbool GraphicsConnection::fixVerticalSegmentClearance(QList<SegmentBound> const& verticalBounds, int i)\r\n{\r\n    // Create segment bounds for the inspected segment.\r\n    SegmentBound bounds(pathPoints_.at(i), pathPoints_.at(i + 1));\r\n\r\n    // Check if the segment does not violate the clearance rule.\r\n    if (findVerticalSegmentOverlap(verticalBounds, bounds) == -1)\r\n    {\r\n        return false;\r\n    }\r\n    \r\n    // Retrieve segment limits.\r\n    QPair<qreal, qreal> limits = getSegmentLimitsX(i);\r\n    qreal minX = limits.first;\r\n    qreal maxX = limits.second;\r\n\r\n    qreal currentX = bounds.minX;\r\n    qreal newX = bounds.minX;\r\n\r\n    for (int move = GridSize; minX <= currentX - move || currentX + move <= maxX; move += GridSize)\r\n    {\r\n        SegmentBound leftCandidate(QPointF(currentX - move, pathPoints_.at(i).y()),\r\n            QPointF(currentX - move, pathPoints_.at(i + 1).y()));\r\n        SegmentBound rightCandidate(QPointF(currentX + move, pathPoints_.at(i).y()),\r\n            QPointF(currentX + move, pathPoints_.at(i + 1).y()));\r\n\r\n        if (minX <= currentX - move && findVerticalSegmentOverlap(verticalBounds, leftCandidate) == -1)\r\n        {\r\n            newX = currentX - move;\r\n            break;\r\n        }\r\n        else if (currentX + move <= maxX && findVerticalSegmentOverlap(verticalBounds, rightCandidate) == -1)\r\n        {\r\n            newX = currentX + move;\r\n            break;\r\n        }\r\n    }\r\n\r\n    // Check if we cannot change the bounds at all.\r\n    if (newX < minX || newX > maxX || qFuzzyCompare(newX, bounds.minX))\r\n    {\r\n        return false;\r\n    }\r\n\r\n    pathPoints_[i].setX(newX);\r\n    pathPoints_[i + 1].setX(newX);\r\n\r\n    return true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: GraphicsConnection::fixHorizontalSegmentClearance()\r\n//-----------------------------------------------------------------------------\r\nbool GraphicsConnection::fixHorizontalSegmentClearance(QList<SegmentBound> const& horBounds, int i)\r\n{\r\n    // Create segment bounds for the inspected segment.\r\n    SegmentBound bounds(pathPoints_.at(i), pathPoints_.at(i + 1));\r\n\r\n    // Check if the segment does not violate the clearance rule.\r\n    if (findHorizontalSegmentOverlap(horBounds, bounds) == -1)\r\n    {\r\n        return false;\r\n    }\r\n\r\n    // Retrieve segment limits.\r\n    QPair<qreal, qreal> limits = getSegmentLimitsY(i);\r\n    qreal minY = limits.first;\r\n    qreal maxY = limits.second;\r\n    \r\n    qreal newY = bounds.minY;\r\n    qreal currentY = bounds.minY;\r\n\r\n    for (int move = GridSize; minY <= currentY - move || currentY + move <= maxY; move += GridSize)\r\n    {\r\n        SegmentBound upCandidate(QPointF(pathPoints_.at(i).x(), currentY - move),\r\n            QPointF(pathPoints_.at(i + 1).x(), currentY - move));\r\n        SegmentBound downCandidate(QPointF(pathPoints_.at(i).x(), currentY + move),\r\n            QPointF(pathPoints_.at(i + 1).x(), currentY + move));\r\n\r\n        if (minY <= currentY - move && findHorizontalSegmentOverlap(horBounds, upCandidate) == -1)\r\n        {\r\n            newY = currentY - move;\r\n            break;\r\n        }\r\n        else if (currentY + move <= maxY && findHorizontalSegmentOverlap(horBounds, downCandidate) == -1)\r\n        {\r\n            newY = currentY + move;\r\n            break;\r\n        }\r\n    }\r\n\r\n    // Check if we cannot change the bounds at all.\r\n    if (newY < minY || newY > maxY || qFuzzyCompare(newY, bounds.minY))\r\n    {\r\n        return false;\r\n    }\r\n\r\n    pathPoints_[i].setY(newY);\r\n    pathPoints_[i + 1].setY(newY);\r\n    return true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: GraphicsConnection::testSegmentOverlapX()\r\n//-----------------------------------------------------------------------------\r\nbool GraphicsConnection::testSegmentOverlapX(SegmentBound const& bound1, SegmentBound const& bound2) const\r\n{\r\n    return !(bound1.maxX < bound2.minX || bound1.minX > bound2.maxX);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: GraphicsConnection::testSegmentOverlapY()\r\n//-----------------------------------------------------------------------------\r\nbool GraphicsConnection::testSegmentOverlapY(SegmentBound const& bound1, SegmentBound const& bound2) const\r\n{\r\n    return !(bound1.maxY < bound2.minY || bound1.minY > bound2.maxY);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: GraphicsConnection::updateEndpointDirection()\r\n//-----------------------------------------------------------------------------\r\nvoid GraphicsConnection::updateEndpointDirection(ConnectionEndpoint* endpoint, QVector2D dir)\r\n{\r\n    if (endpoint)\r\n    {\r\n        // Switch the direction of the end point if it is not correct.\r\n        if (!endpoint->isDirectionFixed() && QVector2D::dotProduct(dir, endpoint->getDirection()) < 0)\r\n        {\r\n            endpoint->setDirection(dir);\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: GraphicsConnection::connectionPoint()\r\n//-----------------------------------------------------------------------------\r\nQPointF GraphicsConnection::connectionPoint(QPointF const& otherEnd) const\r\n{\r\n    QList<QPointF> connectionPoints;\r\n    \r\n    if (otherEnd.isNull() || getRoutingMode() == ROUTING_MODE_OFFPAGE)\r\n    {        \r\n        connectionPoints.append(pathPoints_.first());\r\n        connectionPoints.append(pathPoints_.last());           \r\n    }\r\n    else\r\n    {\r\n        int segmentCount = pathPoints_.size() - 1;\r\n        for(int i = 0; i < segmentCount; i++)\r\n        {\r\n            QPointF segmentStart = pathPoints_.at(i);\r\n            QPointF segmentEnd = pathPoints_.at(i + 1);     \r\n            QPointF segmentCenter = segmentStart + (segmentEnd - segmentStart)/2;\r\n\r\n            connectionPoints.append(segmentCenter);\r\n        }\r\n    }\r\n\r\n    return findClosestPoint(connectionPoints, otherEnd);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: GraphicsConnection::findClosestPoint()\r\n//-----------------------------------------------------------------------------\r\nQPointF GraphicsConnection::findClosestPoint(QList<QPointF> const& sourcePoints, QPointF const& destination) const\r\n{\r\n    QPointF closest = sourcePoints.first();\r\n    qreal shortestDistance = QLineF(closest, destination).length();\r\n\r\n    for (QPointF const& candidate : sourcePoints)\r\n    {\r\n        qreal distance = QLineF(candidate, destination).length();\r\n        if (distance < shortestDistance)\r\n        {\r\n            shortestDistance = distance;\r\n            closest = candidate;\r\n        }\r\n    }\r\n\r\n    return closest;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: GraphicsConnection::changeConnectionComponentReference()\r\n//-----------------------------------------------------------------------------\r\nvoid GraphicsConnection::changeConnectionComponentReference(QString const&, QString const& )\r\n{\r\n    return;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: GraphicsConnection::pointsToLines()\r\n//-----------------------------------------------------------------------------\r\nQList<QLineF> GraphicsConnection::pointsToLines(QList<QPointF> const& points) const\r\n{\r\n    QList<QLineF> lines;\r\n    for (int i = 0; i < points.size() - 1; i++)\r\n    {\r\n        lines.append(QLineF(points.at(i), points.at(i + 1)));\r\n    }\r\n\r\n    return lines;\r\n}\r\n"
  },
  {
    "path": "common/graphicsItems/GraphicsConnection.h",
    "content": "//-----------------------------------------------------------------------------\n// File: GraphicsConnection.h\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Joni-Matti Maatta\n// Date: 5.6.2012\n//\n// Description:\n// Base class for graphical connections.\n//-----------------------------------------------------------------------------\n\n#ifndef GRAPHICSCONNECTION_H\n#define GRAPHICSCONNECTION_H\n\n#include <editors/common/Association/Associable.h>\n\n#include <common/graphicsItems/ConnectionEndpoint.h>\n\n#include <IPXACTmodels/kactusExtensions/ConnectionRoute.h>\n\n#include <QGraphicsPathItem>\n#include <QGraphicsTextItem>\n#include <QUndoCommand>\n\nclass DesignDiagram;\n\n//-----------------------------------------------------------------------------\n//! Base class for graphical connections.\n//-----------------------------------------------------------------------------\nclass GraphicsConnection : public QObject, public QGraphicsPathItem, public Associable\n{\n    Q_OBJECT\n\npublic:\n    //-----------------------------------------------------------------------------\n    //! RoutingMode enumeration.\n    //-----------------------------------------------------------------------------\n    enum RoutingMode\n    {\n        ROUTING_MODE_NORMAL = 0,  //!< The connection uses rectlinear routing.\n        ROUTING_MODE_OFFPAGE      //!< The connection goes straight from the location of the first\n                                  //!< endpoint to the location of the second endpoint.\n    };\n\n    /*!\n     *  Constructor.\n     */\n    GraphicsConnection(ConnectionEndpoint *endpoint1, ConnectionEndpoint *endpoint2,\n                       QSharedPointer<ConnectionRoute> route, bool autoConnect,\n                       DesignDiagram* parent);\n\n    /*!\n     *  Constructor which creates an open-ended connection.\n     */\n    GraphicsConnection(QPointF const& p1, QVector2D const& dir1,\n                       QPointF const& p2, QVector2D const& dir2,\n                       DesignDiagram* parent);\n\n    /*!\n     *  Destructor.\n     */\n    virtual ~GraphicsConnection();\n\n    // Disable copying.\n    GraphicsConnection(GraphicsConnection const& rhs) = delete;\n    GraphicsConnection& operator=(GraphicsConnection const& rhs) = delete;\n\n    /*!\n     *  Get the type of this connection.\n     *\n     *    @return HW connection.\n     */\n    virtual int type() const = 0;\n\n    /*!\n     *  Sets the routing mode.\n     *\n     *    @param [in] mode The routing mode.\n     */\n    void setRoutingMode(RoutingMode mode);\n\n    /*!\n     *  Sets the line width.\n     *\n     *    @param [in] width The line width in pixels.\n     */\n    void setLineWidth(int width);\n\n    /*! \n     *  Connects the ends of the connection.\n     *\n     *      @remarks There must be valid endpoints below the start and end positions\n     *               of the connection.\n     */\n    virtual bool connectEnds();\n\n    /*!\n     *  Sets the first endpoint. If the connection is already connected, the connection\n     *  is disconnected from the old endpoint and connected to the new given endpoint, updating the\n     *  route too.\n     *\n     *    @param [in] endpoint1 The first endpoint to set.\n     */\n    void setEndpoint1(ConnectionEndpoint* endpoint1);\n\n    /*!\n     *  Sets the first endpoint. If the connection is already connected, the connection\n     *  is disconnected from the old endpoint and connected to the new given endpoint, updating the\n     *  route too.\n     *\n     *    @param [in] endpoint2 The second endpoint to set.\n     */\n    void setEndpoint2(ConnectionEndpoint* endpoint2);\n\n    /*!\n     *  Validates the connection and draws it in red if it is not valid.\n     */\n    void validate();\n\n    /*!\n     *  Re validate the connection.\n     */\n    void reValidate();\n\n    /*! \n     *  Disconnects the ends of the connection.\n     */\n    void disconnectEnds();\n\n    /*!\n     *  Toggles the connection between normal and off-page.\n     */\n    void toggleOffPage();\n\n    bool isOffPage() const;\n\n    /*!\n     *  Sets the routing of the connection.\n     *\n     *    @param [in] path The route to set.\n     */\n    void setRoute(QList<QPointF> path);\n\n    /*!\n     *  Returns the route of this connection.\n     */\n    QList<QPointF> route() const;\n\n    /*! \n     *  Updates the end positions when connected endpoints are moved.\n     */\n    virtual void updatePosition();\n\n    /*!\n     *  Applies clearance algorithm to prevent connections from intersecting.\n     */\n    void fixOverlap();\n\n    /*!\n     *  Updates the name of the connection according to the default formatting.\n     */\n    QString createDefaultName() const;\n\n    /*!\n     *  Begins the position update of the connection.\n     */\n    void beginUpdatePosition();\n\n    /*!\n     *  Ends the position update of the connection and creates an undo command.\n     *\n     *    @param [in] parent The parent command.\n     *\n     *    @return The created (child) command.\n     */\n    QUndoCommand* endUpdatePosition(QUndoCommand* parent);\n\n    /*!\n     *  Set the name for the connection.\n\t *\n\t *    @param [in] name The name to set for the connection.\n\t */\n\tvirtual void setName(QString const& name);\n\n    /*!\n     *  Sets the description for the connection.\n\t *\n     *    @param [in] description The description to set.\n\t */\n\tvirtual void setDescription(QString const& /*description*/) {};\n\n    /*!\n     *  Sets the imported state.\n     *\n     *    @param [in] imported If true, the connection is an imported one.\n     */\n    void setImported(bool imported);\n\n    /*!\n     *  Returns the name of this connection\n     */\n    virtual QString name() const { return QString(); };\n\n\t/*!\n     *  Returns the description of the connection.\n\t */\n\tvirtual QString description() const { return QString(); };\n\n    /*!\n     *  Returns true if the connection is an imported one.\n     */\n    bool isImported() const;\n\n\t/*!\n     *  Returns the first endpoint connected.\n     */\n    ConnectionEndpoint* endpoint1() const;\n\n    /*!\n     *  Return the second endpoint connected.\n     */\n    ConnectionEndpoint* endpoint2() const;\n\n    /*!\n     *  Returns the type of the connection.\n     */\n    ConnectionEndpoint::EndpointType getConnectionType() const;\n\n    /*!\n     *  Returns the used routing mode.\n     */\n    RoutingMode getRoutingMode() const;\n\n    /*!\n     *  Get the route of the connection.\n     *\n     *    @return The connection route.\n     */\n    QSharedPointer<ConnectionRoute> getRouteExtension() const;\n\n    /*!\n     *  Returns true if the connection is invalid.\n     */\n    bool isInvalid() const;\n\n    /*!\n     *\tSet hovering flag indicating if the mouse is being hovered above the connection item.\n     *  \n     *    @param [in] hovered     Flag indicating if currently hovering.\n     */\n    void setHovered(bool hovered);\n\n    /*!\n     *\tGet the current mouse hover status.\n     *  \n     * \t    @return True, if the mouse is hovering above the item, otherwise false.\n     */\n    bool getHovered() const;\n\n    /*!\n     *  Returns true if the connection uses the default name.\n     */\n    bool hasDefaultName() const;\n\n    /*!\n     *  Defines the connection point for associations in scene coordinates.\n     *     \n     *    @param [in] otherEnd   The position of the other end connection point.\n     *\n     *    @return The connection point of the item.\n     */\n    virtual QPointF connectionPoint(QPointF const& otherEnd) const;\n\n    /*!\n     *  Change the component reference of a contained interface.\n     *\n     *    @param [in] oldName     The old component reference.\n     *    @param [in] newName     The new component reference.\n     */\n    virtual void changeConnectionComponentReference(QString const& oldName, QString const& newName);\n\nsignals:\n    //! Signals that the connection has changed.\n    void contentChanged();\n\n    //! Sends an error message to the user.\n    void errorMessage(const QString& errorMessage) const;\n\n    //! \\brief This signal is emitted when this connection is destroyed.\n    void destroyed(GraphicsConnection* connection);\n\nprotected:\n    void mousePressEvent(QGraphicsSceneMouseEvent *mouseEvent);\n    void mouseMoveEvent(QGraphicsSceneMouseEvent *mouseEvent);\n    void mouseReleaseEvent(QGraphicsSceneMouseEvent *mouseEvent);\n    void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);\n\n    /*!\n     *\tCalled when the mouse starts to hover above the connection item.\n     *  \n     *    @param [in] hoverEvent     The hover event.\n     */\n    virtual void hoverEnterEvent(QGraphicsSceneHoverEvent* hoverEvent);\n    \n    /*!\n     *\tCalled when the mouse stops hovering above the connection item.\n     *\n     *    @param [in] hoverEvent     The hover event.\n     */\n    virtual void hoverLeaveEvent(QGraphicsSceneHoverEvent* hoverEvent);\n\n    QVariant itemChange(GraphicsItemChange change, const QVariant &value);\n\n    /*!\n     *\tReturns the shape of this item.\n     *  \n     * \t    @return The shape of this item as a QPainterPath.\n     */\n    QPainterPath shape() const override;\n\nprivate:\n    //-----------------------------------------------------------------------------\n    //! Selection type enumeration.\n    //-----------------------------------------------------------------------------\n    enum SelectionType\n    {\n        END,\n        SEGMENT,\n        NONE\n    };\n\n    /*!\n     *  Common validation functions for both the initial and re validation of a connection.\n     */\n    void commonValidation();\n\n    /*!\n     *  Sets the default graphics item settings.\n     */\n    void setItemSettings();\n\n    /*!\n     *  Paints the current path of the connection.     \n     */\n    void paintConnectionPath();\n\n    /*!\n     *  Creates an optimal route between the given endpoints.\n     */\n    void createRoute(ConnectionEndpoint* endpoint1, ConnectionEndpoint* endpoint2);\n\n    /*!\n     *  Sets the default color based on the routing mode.\n     */\n    void setDefaultColor();\n\n    /*!\n     *  Draws specific helper graphics for overlapping graphics items.\n     *\n     *    @param [in] painter The painter.\n     */\n    void drawOverlapGraphics(QPainter* painter);\n\n    /*!\n     *  Draws overlapping graphics with another connection.\n     *\n     *    @param [in] painter     The painter to use.\n     *    @param [in] connection  The connection who overlaps with this.\n     */\n    void drawOverlapWithConnection(QPainter* painter, GraphicsConnection* connection);\n\n    /*!\n     *  Draws an undercrossing with another connection.\n     *\n     *    @param [in] painter                 The painter to use.\n     *    @param [in] path                    The segment of the connection intersecting with other connection.\n     *    @param [in] crossingPoint           The point where the connections intersect.\n     *    @param [in] crossConnectionWidth    The withd of the intersecting connection.\n     */\n    void drawUndercrossing(QPainter* painter, QLineF const& path, QPointF const& crossingPoint, int crossConnectionWidth);\n\n    /*!\n     *  Draws a junction point on the connection.\n     *\n     *    @param [in] painter             The painter to use.\n     *    @param [in] intersectionPoint   The point where the connections intersect.\n     */\n    void drawJunctionPoint(QPainter* painter, QPointF const& intersectionPoint);\n\n    /*!\n     *  Draws overlapping with a component item.\n     *\n     *    @param [in] painter     The painter to use.\n     *    @param [in] item        The component item overlapping the connection.     \n     */\n    void drawOverlapWithComponent(QPainter* painter, QGraphicsItem* item);\n\n    /*!\n     *  Draws a \"gap\" to a line with the currently selected pen.\n     *\n     *    @param [in] painter The painter.\n     *    @param [in] line    The line to which to draw the gap.\n     *    @param [in] pt      The intersection point where to draw the gap.\n     */\n    void drawLineGap(QPainter* painter, QLineF const& line, QPointF const& pt);\n\n    //-----------------------------------------------------------------------------\n    //! Segment bound structure.\n    //-----------------------------------------------------------------------------\n    struct SegmentBound\n    {\n        qreal minX;\n        qreal minY;\n        qreal maxX;\n        qreal maxY;\n\n        /*!\n         *  Constructor.\n         */\n        SegmentBound(QPointF const& p1, QPointF const& p2)\n            : minX(qMin(p1.x(), p2.x())),\n              minY(qMin(p1.y(), p2.y())),\n              maxX(qMax(p1.x(), p2.x())),\n              maxY(qMax(p1.y(), p2.y()))\n        {\n        }\n    };\n\n    /*!\n     *  Creates segment bounds from the existing connections.\n     *\n     *    @param [out] verBounds    The list of vertical segment bounds.\n     *    @param [out] horizontalBounds  The list of horizontal bounds.\n     */\n    void createSegmentBounds(QList<SegmentBound>& verBounds, QList<SegmentBound>& horizontalBounds);\n       \n    /*!\n     *  Sort operator for sorting segment bounds by X coordinate.\n     */\n    static bool sortBoundsByX(SegmentBound const& lhs, SegmentBound const& rhs);\n\n    /*!\n     *  Sort operator for sorting segment bounds by Y coordinate.\n     */\n    static bool sortBoundsByY(SegmentBound const& lhs, SegmentBound const& rhs);\n\n    /*!\n     *  Simplifies the current path.\n     */\n    void simplifyPath();\n\n    /*!\n     *  Retrieves the minimum and maximum X coordinates for the horizontal segment identified by index i.\n     *\n     *    @param [in]  i      The segment index.\n     *\n     *    @return The <min, max> limits for the segment.\n     */\n    QPair<qreal, qreal> getSegmentLimitsX(int i) const;\n\n    /*!\n     *  Retrieves the minimum and maximum Y coordinates for the vertical segment identified by index i.\n     *\n     *    @param [in]  i      The segment index.\n     *\n     *    @return The <min, max> limits for the segment.\n     */\n    QPair<qreal, qreal> getSegmentLimitsY(int i) const;\n\n    /*!\n     *  Searches for a vertical segment overlap.\n     *\n     *    @param [in] verBounds  The collection of vertical segment bounds to test against.\n     *    @param [in] bounds     The vertical segment being tested for overlap.\n     *\n     *    @return The index of the first found overlapping bound in the collection, or -1 if not found.\n     */\n    int findVerticalSegmentOverlap(QList<SegmentBound> const& verBounds, SegmentBound const& bounds);\n    \n    /*!\n     *  Fixes vertical segment overlap issues for the vertical segment identified by index i.\n     *\n     *    @param [in] verBounds  The collection of vertical segment bounds to test against.\n     *    @param [in] i          The index of the segment to fix.\n     *\n     *    @return True if modifications were made; false if nothing was changed.\n     */\n    bool fixVerticalSegmentClearance(QList<SegmentBound> const& verBounds, int i);\n\n    /*!\n     *  Searches for a horizontal segment overlap.\n     *\n     *    @param [in] horBounds  The collection of horizontal segment bounds to test against.\n     *    @param [in] bounds     The horizontal segment being tested for overlap.\n     *\n     *    @return The index of the first found overlapping bound in the collection, or -1 if not found.\n     */\n    int findHorizontalSegmentOverlap(QList<SegmentBound> const& horBounds, SegmentBound const& bounds);\n    \n    /*!\n     *  Fixes horizontal segment overlap issues for the horizontal segment identified by index i.\n     *\n     *    @param [in] horBounds  The collection of horizontal segment bounds to test against.\n     *    @param [in] i          The index of the segment to fix.\n     *\n     *    @return True if modifications were made; false if nothing was changed.\n     */\n    bool fixHorizontalSegmentClearance(QList<SegmentBound> const& horBounds, int i);\n\n    /*!\n     *  Tests for horizontal overlap between two segment bounds.\n     *\n     *    @param [in] bound1 The first segment bound.\n     *    @param [in] bound2 The second segment bound.\n     *\n     *    @return True if the bounds overlap by X coordinate.\n     */\n    bool testSegmentOverlapX(SegmentBound const& bound1, SegmentBound const& bound2) const;\n\n    /*!\n     *  Tests for vertical overlap between two segment bounds.\n     *\n     *    @param [in] bound1 The first segment bound.\n     *    @param [in] bound2 The second segment bound.\n     *\n     *    @return True if the bounds overlap by Y coordinate.\n     */\n    bool testSegmentOverlapY(SegmentBound const& bound1, SegmentBound const& bound2) const;\n\n    /*!\n     *  Updates the endpoint direction to given direction.\n     *\n     *    @param [in] endpoint   The endpoint to update.\n     *    @param [in] dir        The direction to change to.\n     */\n    void updateEndpointDirection(ConnectionEndpoint* endpoint, QVector2D dir);\n\n    /*!\n     *  Finds the point closest to the given point from a set of points.\n     *\n     *    @param [in] sourcePoints    The points to search through.\n     *    @param [in] destination     The point get closest to.\n     *\n     *    @return The point closest to destination.\n     */\n    QPointF findClosestPoint(QList<QPointF> const& sourcePoints, QPointF const& destination) const;\n\n    /*!\n     *  Creates lines connecting the given points.\n     *\n     *    @param [in] points   The line endpoints.\n     *\n     *    @return The lines connecting the given points.\n     */\n    QList<QLineF> pointsToLines(QList<QPointF> const& points) const;\n\n    //-----------------------------------------------------------------------------\n    // Data.\n    //-----------------------------------------------------------------------------\n\n    //! The parent diagram.\n    DesignDiagram* parent_ = nullptr;\n\n    //! The first endpoint.\n    ConnectionEndpoint* endpoint1_ = nullptr;\n\n    //! The second endpoint.\n    ConnectionEndpoint* endpoint2_ = nullptr;\n\n    //! The route path points.\n    QList<QPointF> pathPoints_;\n\n    //! The lines connecting the path points.\n    QList<QLineF> pathLines_;\n\n    //! The index of the segment that is currently selected.\n    int selected_ = -1;\n\n    //! The type of selection.\n    SelectionType selectionType_ = NONE;\n\n    //! The old route for creating undo commands.\n    QList<QPointF> oldRoute_;\n\n    //! The routing mode.\n    RoutingMode routingMode_ = ROUTING_MODE_NORMAL;\n\n    //! The route of the interconnection.\n    QSharedPointer<ConnectionRoute> route_ = QSharedPointer<ConnectionRoute>(new ConnectionRoute(QString()));\n\n    //! If true, the connection is an imported one.\n    bool imported_ = false;\n\n    //! The default color.\n    bool invalid_ = false;\n\n    //! If true, connection is being moved.\n    bool positionUpdateInProcess_ = false;\n\n    //! If true, mouse is being hovered above connection.\n    bool hoveredAbove_ = false;\n};\n\n//-----------------------------------------------------------------------------\n\n#endif // GRAPHICSCONNECTION_H\n"
  },
  {
    "path": "common/graphicsItems/GraphicsItemTypes.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: GraphicsItemTypes.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Joni-Matti Maatta\r\n// Date: 3.5.2012\r\n//\r\n// Description:\r\n// Enumeration of custom graphics item types.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef GRAPHICSITEMTYPES_H\r\n#define GRAPHICSITEMTYPES_H\r\n\r\n#include <QGraphicsItem>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Custom graphics item types.\r\n//-----------------------------------------------------------------------------\r\nenum GraphicsItemTypes\r\n{\r\n    GFX_TYPE_DIAGRAM_COMPONENT = QGraphicsItem::UserType + 1,\r\n    GFX_TYPE_DIAGRAM_INTERCONNECTION,\r\n    GFX_TYPE_DIAGRAM_PORT,\r\n    GFX_TYPE_DIAGRAM_INTERFACE,\r\n    GFX_TYPE_DIAGRAM_COLUMN,\r\n    GFX_TYPE_DIAGRAM_ADHOC_PORT,\r\n    GFX_TYPE_DIAGRAM_ADHOC_INTERFACE,\r\n    GFX_TYPE_DIAGRAM_ADHOC_CONNECTION,\r\n    GFX_TYPE_DIAGRAM_OFF_PAGE_CONNECTOR,\r\n    GFX_TYPE_DIAGRAM_STICKY_NOTE,\r\n    GFX_TYPE_DIAGRAM_ASSOCIATION,\r\n\r\n    GFX_TYPE_SYSTEM_COLUMN,\r\n    GFX_TYPE_PROGRAM_ENTITY,\r\n    GFX_TYPE_APP_PLACEHOLDER,\r\n    GFX_TYPE_ENDPOINT_STACK,\r\n    GFX_TYPE_ENDPOINT_CONNECTION,\r\n    GFX_TYPE_ENDPOINT,\r\n    GFX_TYPE_MAPPING_COMPONENT,\r\n    GFX_TYPE_PLATFORM_COMPONENT,\r\n    GFX_TYPE_PLATFORM_PLACEHOLDER,\r\n    GFX_TYPE_COMPONENT_ITEM,\r\n    GFX_TYPE_APPLICATION_ITEM,\r\n\r\n    GFX_TYPE_HW_MAPPING_ITEM,\r\n    GFX_TYPE_SW_COMPONENT_ITEM,\r\n    GFX_TYPE_SW_PORT_ITEM,\r\n    GFX_TYPE_SW_INTERFACE_ITEM,\r\n    GFX_TYPE_SW_CONNECTION,\r\n    GFX_TYPE_SW_COM_CONNECTION,\r\n    GFX_TYPE_SW_API_CONNECTION,\r\n\r\n    GFX_TYPE_MEMORY_ITEM,\r\n    GFX_TYPE_ADDRESS_SPACE_ITEM,\r\n    GFX_TYPE_ADDRESS_SECTION_ITEM,\r\n    GFX_TYPE_MEMORY_COLUMN,\r\n\r\n\tGFX_TYPE_EXPAND_COLLAPSE_ITEM\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n\r\n#endif // GRAPHICSITEMTYPES_H\r\n"
  },
  {
    "path": "common/graphicsItems/GraphicsLineEdit.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: GraphicsLineEdit.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Joni-Matti Maatta\r\n// Date: 25.9.2012\r\n//\r\n// Description:\r\n// Implements the graphics line edit class.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"GraphicsLineEdit.h\"\r\n\r\n#include <QEvent>\r\n#include <QKeyEvent>\r\n#include <QGraphicsSceneMouseEvent>\r\n#include <QTextCursor>\r\n#include <QTextDocument>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: GraphicsLineEdit::GraphicsLineEdit()\r\n//-----------------------------------------------------------------------------\r\nGraphicsLineEdit::GraphicsLineEdit(QGraphicsItem* parent)\r\n    : QGraphicsTextItem(parent),\r\n      readOnly_(false),\r\n      oldText_(),\r\n      validator_(0)\r\n{\r\n    connect(document(), SIGNAL(contentsChanged()), this, SLOT(onContentChanged()), Qt::UniqueConnection);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: GraphicsLineEdit::~GraphicsLineEdit()\r\n//-----------------------------------------------------------------------------\r\nGraphicsLineEdit::~GraphicsLineEdit()\r\n{\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: GraphicsLineEdit::setReadOnly()\r\n//-----------------------------------------------------------------------------\r\nvoid GraphicsLineEdit::setReadOnly(bool readOnly)\r\n{\r\n    readOnly_ = readOnly;\r\n\r\n    if (readOnly_)\r\n    {\r\n        setTextInteractionFlags(Qt::NoTextInteraction);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: GraphicsLineEdit::sceneEvent()\r\n//-----------------------------------------------------------------------------\r\nbool GraphicsLineEdit::sceneEvent(QEvent* event)\r\n{\r\n    if (event->type() == QEvent::KeyPress)\r\n    {\r\n        QKeyEvent* keyEvent = static_cast<QKeyEvent*>(event);\r\n\r\n        switch (keyEvent->key())\r\n        {\r\n        case Qt::Key_Escape:\r\n            {\r\n                cancelEdit();\r\n                return true;\r\n            }\r\n\r\n        case Qt::Key_Tab:\r\n        case Qt::Key_Return:\r\n            {\r\n                clearFocus();\r\n                return true;\r\n            }\r\n        }\r\n    }\r\n    else if (event->type() == QEvent::GraphicsSceneMousePress)\r\n    {\r\n        if (textInteractionFlags() == Qt::NoTextInteraction)\r\n        {\r\n            return true;\r\n        }\r\n    }\r\n    else if (event->type() == QEvent::GraphicsSceneMouseDoubleClick)\r\n    {\r\n        QGraphicsSceneMouseEvent* mouseEvent = static_cast<QGraphicsSceneMouseEvent*>(event);\r\n\r\n        if (mouseEvent->button() == Qt::LeftButton)\r\n        {\r\n            // Check if we're not yet editing.\r\n            if (!readOnly_ && textInteractionFlags() == Qt::NoTextInteraction)\r\n            {\r\n                beginEdit();\r\n            }\r\n        }\r\n\r\n        return true;\r\n    }\r\n    else if (event->type() == QEvent::FocusOut)\r\n    {\r\n        clearFocus();\r\n        commitEdit();\r\n        return true;\r\n    }\r\n\r\n    return QGraphicsTextItem::sceneEvent(event);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: GraphicsLineEdit::beginEdit()\r\n//-----------------------------------------------------------------------------\r\nvoid GraphicsLineEdit::beginEdit()\r\n{\r\n    oldText_ = toHtml();\r\n\r\n    setTextInteractionFlags(Qt::TextEditorInteraction);\r\n    setFocus();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: GraphicsLineEdit::cancelEdit()\r\n//-----------------------------------------------------------------------------\r\nvoid GraphicsLineEdit::cancelEdit()\r\n{\r\n    setHtml(oldText_);\r\n    setTextInteractionFlags(Qt::NoTextInteraction);\r\n    clearFocus();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: GraphicsLineEdit::commitEdit()\r\n//-----------------------------------------------------------------------------\r\nvoid GraphicsLineEdit::commitEdit()\r\n{\r\n    // Validate the text.\r\n    QString text = toPlainText();\r\n    int pos = textCursor().position();\r\n\r\n    if (validator_ != 0 && validator_->validate(text, pos) != QValidator::Acceptable)\r\n    {\r\n        // Try to fix the text.\r\n        validator_->fixup(text);\r\n\r\n        if (validator_->validate(text, pos) != QValidator::Acceptable)\r\n        {\r\n            emit invalidInputEntered();\r\n            setFocus();\r\n            return;\r\n        }\r\n\r\n        setPlainText(text);\r\n    }\r\n\r\n    setTextInteractionFlags(Qt::NoTextInteraction);\r\n    clearFocus();\r\n\r\n    emit textEdited();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: GraphicsLineEdit::setValidator()\r\n//-----------------------------------------------------------------------------\r\nvoid GraphicsLineEdit::setValidator(QValidator const* validator)\r\n{\r\n    validator_ = validator;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: GraphicsLineEdit::onContentChanged()\r\n//-----------------------------------------------------------------------------\r\nvoid GraphicsLineEdit::onContentChanged()\r\n{\r\n    disconnect(document(), SIGNAL(contentsChanged()), this, SLOT(onContentChanged()));\r\n\r\n    QString text = toPlainText();\r\n    int pos = textCursor().position();\r\n\r\n    if (validator_ != 0 && validator_->validate(text, pos) == QValidator::Invalid)\r\n    {\r\n        validator_->fixup(text);\r\n        setPlainText(text);\r\n\r\n        QTextCursor cursor = textCursor();\r\n\r\n        if (pos < text.length())\r\n        {\r\n            cursor.setPosition(pos);\r\n        }\r\n        else\r\n        {\r\n            cursor.setPosition(text.length());\r\n        }\r\n\r\n        setTextCursor(cursor);\r\n    }\r\n\r\n    connect(document(), SIGNAL(contentsChanged()), this, SLOT(onContentChanged()), Qt::UniqueConnection);\r\n}\r\n"
  },
  {
    "path": "common/graphicsItems/GraphicsLineEdit.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: GraphicsLineEdit.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Joni-Matti Maatta\r\n// Date: 25.9.2012\r\n//\r\n// Description:\r\n// Declares the graphics line edit class.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef GRAPHICSLINEEDIT_H\r\n#define GRAPHICSLINEEDIT_H\r\n\r\n#include <QGraphicsTextItem>\r\n#include <QValidator>\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Graphics item for representing a single-line text editor.\r\n//-----------------------------------------------------------------------------\r\nclass GraphicsLineEdit : public QGraphicsTextItem\r\n{\r\n    Q_OBJECT\r\n\r\npublic:\r\n    /*!\r\n     *  Constructor.\r\n     *  \r\n     *    @param [in] parent  The parent.\r\n     */\r\n    GraphicsLineEdit(QGraphicsItem* parent);\r\n\r\n    /*!\r\n     *  Destructor.\r\n     */\r\n    ~GraphicsLineEdit();\r\n\r\n    /*!\r\n     *  Sets the editor read only.\r\n     *  \r\n     *    @param [in] readOnly    True for read only.\r\n     */\r\n    void setReadOnly(bool readOnly);\r\n\r\n    /*!\r\n     *  Sets a validator for editing.\r\n     *  \r\n     *  @param [in] validator The validator.\r\n     */\r\n    void setValidator(QValidator const* validator);\r\n\r\nsignals:\r\n    //! Signaled when the text has been edited (and accepted with enter or tab).\r\n    void textEdited();\r\n\r\n    //! Signaled when invalid input has been entered.\r\n    void invalidInputEntered();\r\n\r\nprivate slots:\r\n    //! Updates the validation when the text has been modified but not committed.\r\n    void onContentChanged();\r\n\r\nprotected:\r\n    bool sceneEvent(QEvent* event);\r\n\r\nprivate:\r\n    // Disable copying.\r\n    GraphicsLineEdit(GraphicsLineEdit const& rhs);\r\n    GraphicsLineEdit& operator=(GraphicsLineEdit const& rhs);\r\n\r\n    /*!\r\n     *  Saves the previous text and enters the edit mode.\r\n     */\r\n    void beginEdit();\r\n\r\n    /*!\r\n     *  Cancels the edit and leaves edit mode.\r\n     */\r\n    void cancelEdit();\r\n\r\n    /*!\r\n     *  Commits the edit and leaves edit mode.\r\n     */\r\n    void commitEdit();\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! If true, the editor is read only and the text cannot be edited interactively.\r\n    bool readOnly_;\r\n\r\n    //! Old text before edit.\r\n    QString oldText_;\r\n\r\n    //! The validator.\r\n    QValidator const* validator_;\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n\r\n#endif // GRAPHICSLINEEDIT_H\r\n"
  },
  {
    "path": "common/graphicsItems/GraphicsRectButton.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: GraphicsRectButton.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Joni-Matti Maatta\r\n// Date: 1.6.2011\r\n//\r\n// Description:\r\n// Generic graphics rectangle button item.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"GraphicsRectButton.h\"\r\n\r\n#include <QGraphicsSceneMouseEvent>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: GraphicsRectButton()\r\n//-----------------------------------------------------------------------------\r\nGraphicsRectButton::GraphicsRectButton(QGraphicsItem* parent) : QGraphicsRectItem(parent)\r\n{\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ~GraphicsRectButton()\r\n//-----------------------------------------------------------------------------\r\nGraphicsRectButton::~GraphicsRectButton()\r\n{\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: mousePressEvent()\r\n//-----------------------------------------------------------------------------\r\nvoid GraphicsRectButton::mousePressEvent(QGraphicsSceneMouseEvent *event)\r\n{\r\n    QGraphicsRectItem::mousePressEvent(event);\r\n\r\n    if (event->button() == Qt::LeftButton)\r\n    {\r\n        emit clicked();\r\n    }\r\n}\r\n\r\n"
  },
  {
    "path": "common/graphicsItems/GraphicsRectButton.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: GraphicsRectButton.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Joni-Matti Maatta\r\n// Date: 1.6.2011\r\n//\r\n// Description:\r\n// Generic graphics rectangle button item.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef GRAPHICSRECTBUTTON_H\r\n#define GRAPHICSRECTBUTTON_H\r\n\r\n#include <QGraphicsRectItem>\r\n#include <QObject>\r\n#include <QGraphicsItem>\r\n\r\n//-----------------------------------------------------------------------------\r\n//! GraphicsRectButton class.\r\n//-----------------------------------------------------------------------------\r\nclass GraphicsRectButton : public QObject, public QGraphicsRectItem\r\n{\r\n    Q_OBJECT\r\n\r\npublic:\r\n    /*!\r\n     *  Constructor.\r\n     */\r\n    GraphicsRectButton(QGraphicsItem* parent = 0);\r\n\r\n    /*!\r\n     *  Destructor.\r\n     */\r\n    ~GraphicsRectButton();\r\n\r\nsignals:\r\n    //! Emitted when the user clicks the rectangle with the left mouse button.\r\n    void clicked();\r\n\r\nprotected:\r\n    //! Called when the user presses a mouse button.\r\n    void mousePressEvent(QGraphicsSceneMouseEvent *event);\r\n\r\nprivate:\r\n    // Disable copying.\r\n    GraphicsRectButton(GraphicsRectButton const& rhs);\r\n    GraphicsRectButton& operator=(GraphicsRectButton const& rhs);\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n\r\n#endif // GRAPHICSRECTBUTTON_H\r\n"
  },
  {
    "path": "common/graphicsItems/IGraphicsItemStack.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: IGraphicsItemStack.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Joni-Matti Maatta\r\n// Date: 30.4.2012\r\n//\r\n// Description:\r\n// Interface for managing a component stack.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef IGRAPHICSITEMSTACK_H\r\n#define IGRAPHICSITEMSTACK_H\r\n\r\n#include <editors/common/ColumnTypes.h>\r\n\r\n#include <QPointF>\r\n#include <QGraphicsItem>\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Interface for managing a component stack.\r\n//-----------------------------------------------------------------------------\r\nclass IGraphicsItemStack\r\n{\r\npublic:\r\n    /*!\r\n     *  Destructor.\r\n     */\r\n    virtual ~IGraphicsItemStack() {}\r\n\r\n    /*!\r\n     *  Adds an item to stack.\r\n     *\r\n     *    @param [in] item  The item to add.\r\n     *    @param [in] load  If true, the item is being loaded from a design.\r\n     */\r\n    virtual void addItem(QGraphicsItem* item, bool load = false) = 0;\r\n\r\n    /*!\r\n     *  Removes an item from the stack.\r\n     *\r\n     *    @param [in] item the item to remove.\r\n     */\r\n    virtual void removeItem(QGraphicsItem* item) = 0;\r\n\r\n    /*!\r\n     *  Called when an item is moved within the stack.\r\n     *\r\n     *    @param [in] item     The item that has been moved.\r\n     */\r\n    virtual void onMoveItem(QGraphicsItem* item) = 0;\r\n\r\n    /*!\r\n     *  Called when an item is released from being moved by mouse.\r\n     *\r\n     *    @param [in] item The item that has been released.\r\n     */\r\n    virtual void onReleaseItem(QGraphicsItem* item) = 0;\r\n\r\n    /*!\r\n     *  Updates the item positions so that there are no violations of the stacking rule.\r\n     */\r\n    virtual void updateItemPositions() = 0;\r\n\r\n    /*!\r\n     *  Maps the given local position to scene coordinates.\r\n     */\r\n    virtual QPointF mapStackToScene(QPointF const& pos) const = 0;\r\n\r\n    /*!\r\n     *  Maps the given scene position to local coordinates.\r\n     */\r\n    virtual QPointF mapStackFromScene(QPointF const& pos) const = 0;\r\n\r\n    /*!\r\n     *  Returns true if the stack is allowed to contain the given item.\r\n     *\r\n     *    @param [in] item The item to test for.\r\n     */\r\n    virtual bool isItemAllowed(QGraphicsItem* item) const = 0;\r\n\r\n    /*!\r\n     *  Returns the content type.\r\n     */\r\n    virtual ColumnTypes::ColumnContentType getContentType() const = 0;\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n\r\n#endif // IGRAPHICSITEMSTACK_H\r\n"
  },
  {
    "path": "common/graphicsItems/expandableitem.cpp",
    "content": "/* \r\n *  \tCreated on: 15.10.2012\r\n *      Author: Antti Kamppi\r\n * \t\tfilename: expandableitem.cpp\r\n *\t\tProject: Kactus 2\r\n */\r\n\r\n#include \"expandableitem.h\"\r\n#include \"graphicsexpandcollapseitem.h\"\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ExpandableItem::ExpandableItem()\r\n//-----------------------------------------------------------------------------\r\nExpandableItem::ExpandableItem(QGraphicsItem* parent):\r\nAddressableItem(parent)\r\n{\r\n\tconnect(expandCollapseItem_, SIGNAL(stateChanged(bool)),\r\n        this, SLOT(onExpandStateChange(bool)), Qt::UniqueConnection);\r\n\r\n    setShowExpandableItem(false);\r\n\r\n    expandCollapseItem_->setRect(-GraphicsExpandCollapseItem::SIDE, 0,\r\n        GraphicsExpandCollapseItem::SIDE, VisualizerItem::DEFAULT_HEIGHT);\r\n\r\n    updateExpandArrow(false);\r\n\r\n    expansionArrow_->setShapeMode(QGraphicsPixmapItem::BoundingRectShape);\r\n    expansionArrow_->setZValue(1);\r\n    \r\n    // Set the position for the expand/collapse item with the icon.\r\n    expansionArrow_->setPos(-GraphicsExpandCollapseItem::SIDE, \r\n        GraphicsExpandCollapseItem::SIDE / 2 + VisualizerItem::CORNER_INDENTATION);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ExpandableItem::isExpanded()\r\n//-----------------------------------------------------------------------------\r\nbool ExpandableItem::isExpanded() const\r\n{\r\n\treturn expandCollapseItem_->isExpanded();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ExpandableItem::resizeToContent()\r\n//-----------------------------------------------------------------------------\r\nvoid ExpandableItem::resizeToContent()\r\n{\r\n    updateRectangle();\r\n\trepositionLabels();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ExpandableItem::setConflicted()\r\n//-----------------------------------------------------------------------------\r\nvoid ExpandableItem::setConflicted(bool conflicted)\r\n{\r\n    AddressableItem::setConflicted(conflicted);\r\n    expandCollapseItem_->setBrush(brush());\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ExpandableItem::onExpandStateChange()\r\n//-----------------------------------------------------------------------------\r\nvoid ExpandableItem::onExpandStateChange(bool expanded)\r\n{\r\n    // if there are children\t\r\n    for (QGraphicsItem* child : childItems())\r\n    {\r\n        Q_ASSERT(child);\r\n\r\n        // if the item is visualizer item\r\n        VisualizerItem* childItem = dynamic_cast<VisualizerItem*>(child);\r\n        if (childItem)\r\n        {\r\n            childItem->setVisible(expanded && childItem->isPresent());\r\n        }\r\n    }\r\n\r\n    updateExpandArrow(expanded);\r\n\r\n    updateRectangle();\r\n\r\n    emit expandStateChanged();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ExpandableItem::setShowExpandableItem()\r\n//-----------------------------------------------------------------------------\r\nvoid ExpandableItem::setShowExpandableItem(bool show)\r\n{\r\n    expansionArrow_->setVisible(show);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ExpandableItem::setDefaultBrush()\r\n//-----------------------------------------------------------------------------\r\nvoid ExpandableItem::setDefaultBrush(QBrush brush)\r\n{\r\n    VisualizerItem::setDefaultBrush(brush);\r\n    expandCollapseItem_->setBrush(brush);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ExpandableItem::setExpansionPen()\r\n//-----------------------------------------------------------------------------\r\nvoid ExpandableItem::setExpansionPen(QPen const& pen)\r\n{\r\n    expandCollapseItem_->setPen(pen);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ExpandableItem::setExpansionRectVisible()\r\n//-----------------------------------------------------------------------------\r\nvoid ExpandableItem::setExpansionRectVisible(bool visible)\r\n{\r\n    expandCollapseItem_->setVisible(visible);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ExpandableItem::updateExpandArrow()\r\n//-----------------------------------------------------------------------------\r\nvoid ExpandableItem::updateExpandArrow(bool expanded)\r\n{\r\n    QString iconName;\r\n    if (expanded)\r\n    {\r\n        iconName = QStringLiteral(\":/icons/common/graphics/triangle_arrow_down.png\");\r\n    }\r\n    else\r\n    {\r\n        iconName = QStringLiteral(\":/icons/common/graphics/triangle_arrow_right.png\");\r\n    }\r\n\r\n    QPixmap pic(iconName);\r\n    QPixmap scaledPic = pic.scaled(GraphicsExpandCollapseItem::SIDE, GraphicsExpandCollapseItem::SIDE,\r\n        Qt::KeepAspectRatio);\r\n    expansionArrow_->setPixmap(scaledPic);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ExpandableItem::updateHeight()\r\n//-----------------------------------------------------------------------------\r\nvoid ExpandableItem::updateRectangle()\r\n{\r\n    // the rectangle that contains this item and children\r\n    QRectF totalRect = itemTotalRect();\r\n\r\n    // the rectangle is on the left side of the parent and children\r\n    expandCollapseItem_->setRect(-GraphicsExpandCollapseItem::SIDE, 0, \r\n        GraphicsExpandCollapseItem::SIDE, totalRect.height());\r\n}\r\n"
  },
  {
    "path": "common/graphicsItems/expandableitem.h",
    "content": "/* \r\n *  \tCreated on: 15.10.2012\r\n *      Author: Antti Kamppi\r\n * \t\tfilename: expandableitem.h\r\n *\t\tProject: Kactus 2\r\n */\r\n\r\n#ifndef EXPANDABLEITEM_H\r\n#define EXPANDABLEITEM_H\r\n\r\n#include <editors/ComponentEditor/visualization/AddressableItem.h>\r\n\r\n#include \"graphicsexpandcollapseitem.h\"\r\n\r\n#include <QGraphicsRectItem>\r\n#include <QBrush>\r\n\r\n\r\n/*! The base class to visualize IP-Xact models that contain child items.\r\n *\r\n */\r\nclass ExpandableItem : public AddressableItem {\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\r\n\t/*! The constructor.\r\n\t *\r\n\t * \\param parent Pointer to the owner of the item.\r\n\t *\r\n\t*/\r\n\tExpandableItem(QGraphicsItem* parent = 0);\r\n\t\r\n\t//! The destructor\r\n\tvirtual ~ExpandableItem() = default;\r\n\r\n    //! No copying\r\n    ExpandableItem(const ExpandableItem& other) = delete;\r\n\r\n    //! No assignment\r\n    ExpandableItem& operator=(const ExpandableItem& other) = delete;\r\n\r\n\t/*! Check if the item is expanded and has its children visible or not.\r\n\t *\r\n\t * \\return True if children are visible.\r\n\t*/\r\n\tbool isExpanded() const;\r\n\r\n    void resizeToContent();\r\n\r\n    /*! Get the rectangle reserved by this item and it's sub-items recursively.\r\n     *\r\n     *    @return The rectangle of this item and sub-items and their children recursively.\r\n    */\r\n    virtual QRectF itemTotalRect() const = 0;\r\n\r\n\r\n\tvoid setConflicted(bool conflicted) override;\r\n\r\nsignals:\r\n    //! Emitted when the item is expanded or collapsed.\r\n    void expandStateChanged();\r\n\r\nprotected slots:\r\n\r\n\t/*! Handler for expandCollapseItem's stateChanged()-signal.\r\n\t *\r\n\t * \\param expanded If true then child items are shown.\r\n\t *\r\n\t*/\r\n\tvoid onExpandStateChange(bool expanded);\r\n\r\n\t/*! Set the expand collapse item to hidden/shown state.\r\n\t *\r\n\t * \\param show If true then the item is shown.\r\n\t *\r\n\t*/\r\n\tvoid setShowExpandableItem(bool show);\r\n\r\nprotected:\r\n\r\n    /*!\r\n     *  Sets the default coloring brush for the item.\r\n     *\r\n     *    @param [in] brush   The brush to set.\r\n     */\r\n    void setDefaultBrush(QBrush brush) final;\r\n\r\n    void setExpansionPen(QPen const& pen);\r\n\r\n\t/*! Hide/show the rectangle that contains the expand/collapse icon.\r\n\t *\r\n\t * \\param visible If true then the rectangle is shown.\r\n\t *\r\n\t*/\r\n\tvoid setExpansionRectVisible(bool visible);\r\n\r\nprivate:\t\r\n\r\n    /*!\r\n     * Update the expand arrow direction based on expansion state.\r\n     *\r\n     *    @param [in] expanded     Indicates if the item is expanded or not.\r\n     */\r\n     void updateExpandArrow(bool expanded);\r\n\r\n    //! Updates the item rectangle to correct size.\r\n    void updateRectangle();\r\n\r\n\t//! The item to show/hide the child items\r\n\tGraphicsExpandCollapseItem* expandCollapseItem_ = new GraphicsExpandCollapseItem(this);\r\n\r\n\t//! Pointer to the image used to denote the expandability of the item.\r\n    QGraphicsPixmapItem* expansionArrow_ = new QGraphicsPixmapItem(this);\r\n\r\n};\r\n\r\n#endif // EXPANDABLEITEM_H\r\n"
  },
  {
    "path": "common/graphicsItems/graphicsexpandcollapseitem.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: graphicsexpandcollapseitem.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Antti Kamppi\r\n// Date: 15.10.2012\r\n//\r\n// Description:\r\n// This item provides an expand/collapse item.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"graphicsexpandcollapseitem.h\"\r\n\r\n#include <QGraphicsSceneMouseEvent>\r\n#include <QPixmap>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: graphicsexpandcollapseitem::GraphicsExpandCollapseItem()\r\n//-----------------------------------------------------------------------------\r\nGraphicsExpandCollapseItem::GraphicsExpandCollapseItem( QGraphicsItem* parent /*= 0*/ ):\r\nQGraphicsRectItem(parent)\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: graphicsexpandcollapseitem::expand()\r\n//-----------------------------------------------------------------------------\r\nvoid GraphicsExpandCollapseItem::expand()\r\n{\r\n\texpanded_ = true;\r\n    emit stateChanged(expanded_);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: graphicsexpandcollapseitem::isExpanded()\r\n//-----------------------------------------------------------------------------\r\nbool GraphicsExpandCollapseItem::isExpanded() const\r\n{\r\n\treturn expanded_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: graphicsexpandcollapseitem::collapse()\r\n//-----------------------------------------------------------------------------\r\nvoid GraphicsExpandCollapseItem::collapse()\r\n{\r\n\texpanded_ = false;\r\n    emit stateChanged(expanded_);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: graphicsexpandcollapseitem::isCollapsed()\r\n//-----------------------------------------------------------------------------\r\nbool GraphicsExpandCollapseItem::isCollapsed() const\r\n{\r\n\treturn !expanded_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: graphicsexpandcollapseitem::mousePressEvent()\r\n//-----------------------------------------------------------------------------\r\nvoid GraphicsExpandCollapseItem::mousePressEvent( QGraphicsSceneMouseEvent *event )\r\n{\r\n\tevent->accept();\r\n\tQGraphicsRectItem::mousePressEvent(event);\r\n\r\n\t// mouse left button changes the state of the item\r\n\tif (event->button() == Qt::LeftButton)\r\n    {\t\r\n\t\t// if was expanded then collapse\r\n\t\tif (expanded_)\r\n        {\r\n\t\t\tcollapse();\r\n\t\t}\r\n\t\t// if was collapsed then expand\r\n\t\telse\r\n        {\r\n\t\t\texpand();\r\n\t\t}\r\n\t}\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: graphicsexpandcollapseitem::type()\r\n//-----------------------------------------------------------------------------\r\nint GraphicsExpandCollapseItem::type() const\r\n{\r\n\treturn Type;\r\n}\r\n"
  },
  {
    "path": "common/graphicsItems/graphicsexpandcollapseitem.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: graphicsexpandcollapseitem.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Antti Kamppi\r\n// Date: 15.10.2012\r\n//\r\n// Description:\r\n// This item provides an expand/collapse item.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef GRAPHICSEXPANDCOLLAPSEITEM_H\r\n#define GRAPHICSEXPANDCOLLAPSEITEM_H\r\n\r\n#include <common/graphicsItems/GraphicsItemTypes.h>\r\n\r\n#include <QGraphicsRectItem>\r\n#include <QObject>\r\n\r\n//-----------------------------------------------------------------------------\r\n//! This item provides an expand/collapse item.\r\n//-----------------------------------------------------------------------------\r\nclass GraphicsExpandCollapseItem : public QObject, public QGraphicsRectItem\r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\r\n\t//! The length of one side of the rectangle.\r\n\tenum Bounds\r\n    {\r\n\t\tSIDE = 16\r\n\t};\r\n\r\n\tenum { Type = GFX_TYPE_EXPAND_COLLAPSE_ITEM};\r\n\r\n\t/*!\r\n     *  The constructor.\r\n\t *\r\n\t *    @param [in] parent  Pointer to the owner of this graphics item.\r\n\t */\r\n\tGraphicsExpandCollapseItem(QGraphicsItem* parent = 0);\r\n\t\r\n\t//! The destructor.\r\n\tvirtual ~GraphicsExpandCollapseItem() = default;\r\n\r\n    //! No copying.\r\n    GraphicsExpandCollapseItem(const GraphicsExpandCollapseItem& other) = delete;\r\n\r\n    //! No assignment.\r\n    GraphicsExpandCollapseItem& operator=(const GraphicsExpandCollapseItem& other) = delete;\r\n\r\n\t//! Set the item to expanded state.\r\n\tvirtual void expand();\r\n\r\n\t/*!\r\n     *  Check if the item is in expanded state.\r\n\t *\r\n\t *    @return True if the item is in expanded state.\r\n\t */\r\n\tvirtual bool isExpanded() const;\r\n\r\n\t//! Set the item to collapsed state.\r\n\tvirtual void collapse();\r\n\r\n\t/*!\r\n     *  Check if the item is in collapsed state.\r\n\t *\r\n\t *    @return True if the item is in collapsed state.\r\n\t */\r\n\tvirtual bool isCollapsed() const;\r\n\r\n\t/*!\r\n\t *  Get the type.\r\n\t */\r\n\tvirtual int type() const;\r\n\r\nsignals:\r\n\r\n\t/*!\r\n     *  Emitted when the state of the item changes.\r\n\t * \r\n\t *  This is emitted only when user clicks on the item.\r\n\t *  The expand() and collapse() functions do not emit this signal.\r\n\t * \r\n\t *    @param [in] expanded    True if the item changed to expanded state.\r\n\t */\r\n\tvoid stateChanged(bool expanded);\r\n\r\nprotected:\r\n\r\n\t//! Called when the user presses a mouse button.\r\n\t virtual void mousePressEvent(QGraphicsSceneMouseEvent *event);\r\n\r\nprivate:\r\n\r\n\t//! Contains the current state of the item.\r\n\tbool expanded_ = false;\r\n};\r\n\r\n#endif // GRAPHICSEXPANDCOLLAPSEITEM_H\r\n"
  },
  {
    "path": "common/graphicsItems/visualizeritem.cpp",
    "content": "/* \r\n *  \tCreated on: 15.10.2012\r\n *      Author: Antti Kamppi\r\n * \t\tfilename: visualizeritem.cpp\r\n *\t\tProject: Kactus 2\r\n */\r\n\r\n#include \"visualizeritem.h\"\r\n\r\n#include <QStringBuilder>\r\n#include <QFontMetrics>\r\n#include <QFont>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VisualizerItem::VisualizerItem()\r\n//-----------------------------------------------------------------------------\r\nVisualizerItem::VisualizerItem(QGraphicsItem* parent) :\r\n    QGraphicsRectItem(parent),\r\n    nameItem_(this),\r\n    topTextItem_(this),\r\n    bottomTextItem_(this)\r\n{\r\n\tsetRect(0, 0, VisualizerItem::DEFAULT_WIDTH, VisualizerItem::DEFAULT_HEIGHT);\r\n\r\n\tauto font = nameItem_.font();\r\n\tfont.setPointSize(VisualizerItem::FONT_NAMESIZE);\r\n\r\n\tnameItem_.setFont(font);\r\n\r\n\t// set the fonts for the corner labels\r\n\tauto cornerFont = topTextItem_.font();\r\n\tcornerFont.setPointSize(VisualizerItem::FONT_CORNERSIZE);\r\n\ttopTextItem_.setFont(cornerFont);\r\n\tbottomTextItem_.setFont(cornerFont);\r\n\t\r\n\tsetFlags(QGraphicsItem::ItemIsSelectable);    \r\n\r\n    setLayoutType(LABELS_LEFT);\r\n\trepositionLabels();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VisualizerItem::name()\r\n//-----------------------------------------------------------------------------\r\nQString VisualizerItem::name() const\r\n{\r\n    return name_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VisualizerItem::setWidth()\r\n//-----------------------------------------------------------------------------\r\nvoid VisualizerItem::setWidth(qreal width)\r\n{\r\n    setRect(0, 0, width, VisualizerItem::DEFAULT_HEIGHT);\r\n\r\n    if (clipText_)\r\n    {\r\n        clipName();\r\n        clipAddress(topText_, &topTextItem_);\r\n        clipAddress(bottomText_, &bottomTextItem_);\r\n    }\r\n\r\n    repositionLabels();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VisualizerItem::itemTotalWidth()\r\n//-----------------------------------------------------------------------------\r\nqreal VisualizerItem::itemTotalWidth() const\r\n{\r\n    return VisualizerItem::DEFAULT_WIDTH;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VisualizerItem::isPresent()\r\n//-----------------------------------------------------------------------------\r\nbool VisualizerItem::isPresent() const\r\n{\r\n    return true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VisualizerItem::repositionLabels()\r\n//-----------------------------------------------------------------------------\r\nvoid VisualizerItem::repositionLabels()\r\n{\r\n    if (labelPositioning_ == LABELS_LEFT)\r\n    {\r\n        setLeftTopPosition(&topTextItem_);\r\n        setLeftBottomPosition(&bottomTextItem_);\r\n\r\n        auto xCoordinate = rect().width() / 3 + VisualizerItem::NAME_INDENTATION;\r\n        auto yCoordinate = (rect().height() - nameItem_.boundingRect().height()) / 2;\r\n\r\n        nameItem_.setPos(xCoordinate, yCoordinate);\r\n    }\r\n    else if (labelPositioning_ == LABELS_RIGHT)\r\n    {\r\n        setRightTopPosition(&topTextItem_);\r\n        setRightBottomPosition(&bottomTextItem_);\r\n\r\n        auto xCoordinate = VisualizerItem::NAME_INDENTATION;\r\n        auto yCoordinate = (rect().height() - nameItem_.boundingRect().height()) / 2;\r\n        nameItem_.setPos(xCoordinate, yCoordinate);\r\n    }\r\n    else // TOP\r\n    {\r\n        setLeftTopPosition(&topTextItem_);\r\n        setRightTopPosition(&bottomTextItem_);\r\n\r\n        auto xCoordinate = qMax(qreal(0), rect().center().x() - (nameItem_.boundingRect().width() / 2));\r\n        auto yCoordinate = rect().bottomRight().y() - VisualizerItem::FONT_NAMESIZE -\r\n            3 * VisualizerItem::CORNER_INDENTATION;\r\n        nameItem_.setPos(xCoordinate, yCoordinate);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VisualizerItem::setName()\r\n//-----------------------------------------------------------------------------\r\nvoid VisualizerItem::setName(QString const& name)\r\n{\t\r\n    name_ = name;\r\n    if (clipText_)\r\n    {\r\n        clipName();\r\n    }\r\n    else\r\n    {\r\n        nameItem_.setText(name);\r\n    }    \r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VisualizerItem::setTopLabelText()\r\n//-----------------------------------------------------------------------------\r\nvoid VisualizerItem::setTopLabelText(QString const& text) \r\n{\r\n    topText_ = text;\r\n    if (clipText_)\r\n    {\r\n        clipAddress(text, &topTextItem_);\r\n    }\r\n    else\r\n    {\r\n        topTextItem_.setText(text);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VisualizerItem::setBottomLabelText()\r\n//-----------------------------------------------------------------------------\r\nvoid VisualizerItem::setBottomLabelText(QString const& text) \r\n{\r\n    bottomText_ = text;\r\n    if (clipText_)\r\n    {\r\n        clipAddress(text, &bottomTextItem_);\r\n    }\r\n    else\r\n    {\r\n        bottomTextItem_.setText(text);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VisualizerItem::setLayoutType()\r\n//-----------------------------------------------------------------------------\r\nvoid VisualizerItem::setLayoutType(LabelLayout labelLayout)\r\n{\r\n    bool changed = labelLayout != labelPositioning_;\r\n    labelPositioning_ = labelLayout;\r\n\r\n    if (changed)\r\n    {\r\n        setLabelPositions();\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VisualizerItem::setClipText()\r\n//-----------------------------------------------------------------------------\r\nvoid VisualizerItem::setClipText(bool enableClip)\r\n{\r\n    clipText_ = enableClip;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VisualizerItem::minimumRect()\r\n//-----------------------------------------------------------------------------\r\nQRectF VisualizerItem::minimumRect() const \r\n{\r\n\treturn QRectF(0, 0, VisualizerItem::DEFAULT_WIDTH, VisualizerItem::DEFAULT_HEIGHT);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VisualizerItem::setDefaultBrush()\r\n//-----------------------------------------------------------------------------\r\nvoid VisualizerItem::setDefaultBrush(QBrush brush)\r\n{\r\n    defaultBrush_ = brush;\r\n    setBrush(brush);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VisualizerItem::defaultBrush()\r\n//-----------------------------------------------------------------------------\r\nQBrush VisualizerItem::defaultBrush() const\r\n{\r\n    return defaultBrush_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VisualizerItem::setLabelPositions()\r\n//-----------------------------------------------------------------------------\r\nvoid VisualizerItem::setLabelPositions()\r\n{\r\n    if (labelPositioning_ == VisualizerItem::LABELS_LEFT)\r\n    {\r\n        setLeftTopPosition(&topTextItem_);\r\n        setLeftBottomPosition(&bottomTextItem_);\r\n\r\n        auto xCoordinate = rect().width() / 3 + VisualizerItem::NAME_INDENTATION;\r\n        auto yCoordinate = (rect().height() - nameItem_.boundingRect().height()) / 2;\r\n\r\n        nameItem_.setPos(xCoordinate, yCoordinate);\r\n    }\r\n    else if (labelPositioning_ == VisualizerItem::LABELS_RIGHT)\r\n    {\r\n        setRightTopPosition(&topTextItem_);\r\n        setRightBottomPosition(&bottomTextItem_);\r\n\r\n        auto xCoordinate = NAME_INDENTATION;\r\n        auto yCoordinate = (rect().height() - nameItem_.boundingRect().height()) / 2;\r\n        nameItem_.setPos(xCoordinate, yCoordinate);\r\n    }\r\n    else\r\n    {\r\n        setLeftTopPosition(&topTextItem_);\r\n        setRightTopPosition(&bottomTextItem_);\r\n\r\n        auto xCoordinate = qMax(qreal(0), rect().center().x() - (nameItem_.boundingRect().width() / 2));\r\n        auto yCoordinate = rect().bottomRight().y() - VisualizerItem::FONT_NAMESIZE -\r\n            3 * VisualizerItem::CORNER_INDENTATION;\r\n        nameItem_.setPos(xCoordinate, yCoordinate);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VisualizerItem::setLeftTopPosition()\r\n//-----------------------------------------------------------------------------\r\nvoid VisualizerItem::setLeftTopPosition(QGraphicsSimpleTextItem* label)\r\n{\r\n    label->setPos(VisualizerItem::CORNER_INDENTATION, VisualizerItem::CORNER_INDENTATION);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VisualizerItem::setLeftBottomPosition()\r\n//-----------------------------------------------------------------------------\r\nvoid VisualizerItem::setLeftBottomPosition(QGraphicsSimpleTextItem* label)\r\n{\r\n    label->setPos(VisualizerItem::CORNER_INDENTATION,\r\n        rect().bottomRight().y() - label->boundingRect().height() - VisualizerItem::CORNER_INDENTATION);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VisualizerItem::setRightTopPosition()\r\n//-----------------------------------------------------------------------------\r\nvoid VisualizerItem::setRightTopPosition(QGraphicsSimpleTextItem* label)\r\n{\r\n    label->setPos(rect().topRight().x() - label->boundingRect().width() -\r\n        VisualizerItem::CORNER_INDENTATION, VisualizerItem::CORNER_INDENTATION);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VisualizerItem::setRightBottomPosition()\r\n//-----------------------------------------------------------------------------\r\nvoid VisualizerItem::setRightBottomPosition(QGraphicsSimpleTextItem* label)\r\n{\r\n    label->setPos(rect().topRight().x() - label->boundingRect().width() - VisualizerItem::CORNER_INDENTATION,\r\n        rect().bottomRight().y() - label->boundingRect().height() - VisualizerItem::CORNER_INDENTATION);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VisualizerItem::clipName()\r\n//-----------------------------------------------------------------------------\r\nvoid VisualizerItem::clipName()\r\n{\r\n    int maxLength = 0;\r\n\r\n    if (labelPositioning_ == LABELS_TOP)\r\n    {\r\n        maxLength = rect().width() - 2 * CORNER_INDENTATION;\r\n    }\r\n    else\r\n    {\r\n        maxLength = 2 * rect().width() / 3 - 2 * NAME_INDENTATION;\r\n    }\r\n\r\n    QFontMetrics fontMetrics(nameItem_.font());\r\n    int charCount = qMax(int(0), maxLength) / fontMetrics.horizontalAdvance(QStringLiteral(\"x\"));\r\n\r\n    nameItem_.setText(clipText(name_, charCount));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VisualizerItem::clipAddress()\r\n//-----------------------------------------------------------------------------\r\nvoid VisualizerItem::clipAddress(QString const& text, QGraphicsSimpleTextItem* item)\r\n{\r\n    int maxLength = 0;\r\n\r\n    if (labelPositioning_ == LABELS_LEFT)\r\n    {\r\n        maxLength = rect().width() / 3 - NAME_INDENTATION;\r\n    }\r\n    else if (labelPositioning_ == LABELS_RIGHT)\r\n    {\r\n        maxLength = rect().width() / 3 - NAME_INDENTATION;\r\n    }\r\n    else\r\n    {\r\n        maxLength = rect().width() / 2 * VisualizerItem::CORNER_INDENTATION;\r\n    }\r\n\r\n    QFontMetrics labelMetrics(item->font());\r\n    int maxCharacters = qMax(int(0), maxLength) / labelMetrics.horizontalAdvance(QStringLiteral(\"x\"));\r\n\r\n    item->setText(clipText(text, maxCharacters));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VisualizerItem::clipText()\r\n//-----------------------------------------------------------------------------\r\nQString VisualizerItem::clipText(QString const& text, int maxChars) const\r\n{\r\n    // if the text is too wide to be displayed at all.\r\n    if (maxChars < 3)\r\n    {\r\n        return QString();\r\n    }\r\n\r\n    if (text.size() <= maxChars)\r\n    {\r\n        return text;\r\n    }\r\n\r\n    // add \"...\" to the end to indicate the text has been partly hidden.\r\n    return text.left(maxChars - 3) % QStringLiteral(\"...\");\r\n}\r\n"
  },
  {
    "path": "common/graphicsItems/visualizeritem.h",
    "content": "/* \r\n *  \tCreated on: 15.10.2012\r\n *      Author: Antti Kamppi\r\n * \t\tfilename: visualizeritem.h\r\n *\t\tProject: Kactus 2\r\n */\r\n\r\n#ifndef VISUALIZERITEM_H\r\n#define VISUALIZERITEM_H\r\n\r\n#include <QBrush>\r\n#include <QGraphicsRectItem>\r\n#include <QGraphicsTextItem>\r\n#include <QGraphicsSimpleTextItem>\r\n#include <QRectF>\r\n#include <QObject>\r\n\r\n/*! VisualizerItem is base class that provides interface to visualize IP-Xact models.\r\n *\r\n */\r\nclass VisualizerItem : public QObject, public QGraphicsRectItem\r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\r\n\t//! The minimum and maximum bounds for visualizer items.\r\n\tenum Bounds {\r\n\t\tDEFAULT_HEIGHT = 44,    //! The height of a single item\r\n\t\tMIN_WIDTH = 90,\t\t\t//! The minimum width of an item\r\n\t\tDEFAULT_WIDTH = 200,\t//! The default width of a single item\r\n\t\tNAME_INDENTATION = 15,  //! How much space the name leaves for left corners\r\n        CORNER_INDENTATION = 4\r\n\t};\r\n\r\n\t//! The font size to display text.\r\n\tenum FontSize {\r\n\t\tFONT_NAMESIZE = 10,\t\t//! The size for name field\r\n\t\tFONT_CORNERSIZE = 10\t//! The size for corner texts\r\n\t};\r\n\r\n    //! The address label position.\r\n    enum LabelLayout\r\n    {\r\n        LABELS_LEFT = 0,\r\n        LABELS_RIGHT,\r\n        LABELS_TOP,\r\n        UNDEFINED\r\n    };\r\n\r\n\t/*! The constructor.\r\n\t *\r\n\t *    @param parent Pointer to the owner of this graphics item.\r\n\t *\r\n\t*/\r\n\texplicit VisualizerItem(QGraphicsItem* parent = nullptr);\r\n\t\r\n\t//! The destructor\r\n\tvirtual ~VisualizerItem() = default;\r\n\r\n    //! No copying\r\n    VisualizerItem(const VisualizerItem& other) = delete;\r\n\r\n    //! No assignment\r\n    VisualizerItem& operator=(const VisualizerItem& other) = delete;\r\n\r\n\t/*! Get the displayed name of the object. \r\n     *\r\n\t *    @return The name of the object.\r\n\t*/\r\n\tvirtual QString name() const;\r\n\r\n\t/*! Set the width for the item.\r\n\t *\r\n\t *    @param width The new width of the item.\r\n\t *\r\n\t*/\r\n\tvirtual void setWidth(qreal width);\r\n\r\n\t/*! Get the width of the item.\r\n\t *\r\n\t * The width is dependent on the parents width.\r\n\t *\r\n\t *    @return The width of the item and it's sub-items.\r\n\t*/\r\n\tvirtual qreal itemTotalWidth() const;\r\n    \r\n    /*!\r\n     *  Checks if the item is to be used in the visualization.\r\n     *\r\n     *    @return True, if the item should be used, otherwise false.\r\n     */\r\n    virtual bool isPresent() const;\r\n \r\nprotected slots:\r\n\r\n\t/*! Set new positions for child items.\r\n\t * \r\n\t * The base class implementation only updates the position of the name and corner texts.\r\n\t*/\r\n\tvoid repositionLabels();\r\n\r\nprotected:\r\n\r\n\t/*! Set the display name of the item.\r\n\t *\r\n\t *    @param name The name to display.\r\n\t *\r\n\t*/\r\n\tvoid setName(QString const& name);\r\n\r\n\t/*! Set text to the top left corner.\r\n\t *\r\n\t *    @param text The text to display in the corner.\r\n\t *\r\n\t*/\r\n\tvirtual void setTopLabelText(QString const& text);\r\n\r\n\t/*! Set text to the bottom left corner.\r\n\t *\r\n\t *    @param text The text to display in the corner.\r\n\t *\r\n\t*/\r\n\tvirtual void setBottomLabelText(QString const& text);\r\n\r\n    /*!\r\n     * Set how the text labels are positioned within the item.\r\n     *\r\n     *    @param [in] labelLayout  The positioning style to set.     \r\n     */\r\n    void setLayoutType(VisualizerItem::LabelLayout labelLayout);\r\n\r\n    /*!\r\n     * Set the text labels contents to be shortened, if the label cannot fit within the item.\r\n     *\r\n     *    @param [in] enableClip  If true, text is shortened, otherwise not.\r\n     */\r\n     void setClipText(bool enableClip);\r\n\r\n\r\n\t/*! Get the minimum rectangle of the item.\r\n\t *\r\n\t *    @return The minimum size needed by this item.\r\n\t*/\r\n\tvirtual QRectF minimumRect() const;\r\n\r\n    /*!\r\n     *  Sets the default coloring brush for the item.\r\n     *\r\n     *    @param [in] brush   The brush to set.\r\n     */\r\n    virtual void setDefaultBrush(QBrush brush);\r\n\r\n    /*!\r\n     *  Gets the default coloring brush for the item.\r\n     *\r\n     *    @return [in] brush   The default brush.\r\n     */\r\n    QBrush defaultBrush() const;\r\n\r\nprivate:\r\n    void setLabelPositions();\r\n\r\n    //! Set the position for text in the top left corner.\r\n    void setLeftTopPosition(QGraphicsSimpleTextItem* label);\r\n\r\n    //! Set the position for text in the bottom left corner.\r\n    void setLeftBottomPosition(QGraphicsSimpleTextItem* label);\r\n\r\n    //! Set the position for text in the top right corner.\r\n    void setRightTopPosition(QGraphicsSimpleTextItem* label);\r\n\r\n    //! Set the position for text in the bottom right corner.\r\n    void setRightBottomPosition(QGraphicsSimpleTextItem* label);\r\n\r\n    void clipName();\r\n\r\n    void clipAddress(QString const& text, QGraphicsSimpleTextItem* item);\r\n\r\n    /*! If text is longer than maxChars, cuts the length to maxChars is and appends \"...\".\r\n     *\r\n\t *    @param text The text to clip.\r\n     *    @param maxChars Maximum number of characters to show.\r\n     *\r\n\t *    @return The string with maximum length of maxChars.\r\n\t*/\r\n    QString clipText(QString const& text, int maxChars) const;\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! The name of the item.\r\n    QString name_;\r\n\r\n    //! The text displayed at the top label.\r\n    QString topText_;\r\n\r\n    //! The text displayed at the bottom label.\r\n    QString bottomText_;\r\n    \r\n    //! Enable for text clipping i.e. shorten, if the text cannot fit in the given space.\r\n    bool clipText_ = false;\r\n\r\n    //! Default brush for item coloring.\r\n    QBrush defaultBrush_;\r\n\r\n    //! The layout style for labels.\r\n    LabelLayout labelPositioning_{ VisualizerItem::UNDEFINED };\r\n\r\n\t//! The label to display the name of the memory map.\r\n    QGraphicsSimpleTextItem nameItem_;\r\n\r\n\t//! The label to display text in the left top corner.\r\n\tQGraphicsSimpleTextItem topTextItem_;\r\n\r\n\t//! The label to display text in the left bottom corner.\r\n\tQGraphicsSimpleTextItem bottomTextItem_;\r\n\r\n};\r\n\r\n#endif // VISUALIZERITEM_H\r\n"
  },
  {
    "path": "common/layouts/HCollisionLayout.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: HCollisionLayout.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Joni-Matti Maatta\r\n// Date: 22.4.2011\r\n//\r\n// Description:\r\n// Horizontal collision-based layout.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef HCOLLISIONLAYOUT_H\r\n#define HCOLLISIONLAYOUT_H\r\n\r\n#include \"IHGraphicsLayout.h\"\r\n\r\n//-----------------------------------------------------------------------------\r\n\r\ntemplate <class T>\r\nclass HCollisionLayout : public IHGraphicsLayout<T>\r\n{\r\n    /*!\r\n     *  Constructor.\r\n     *  \r\n     *    @param [in] spacing The spacing.\r\n     */\r\n    HCollisionLayout(qreal spacing);\r\n\r\n    /*!\r\n     *  Destructor.\r\n     */\r\n    ~HCollisionLayout();\r\n\r\n    /*!\r\n     *  Updates the positions of the items when one item is being moved.\r\n     *\r\n     *    @param [in] items    The list of items.\r\n     *    @param [in] item     The item that is being moved.\r\n     *    @param [in] minY     The minimum x coordinate.\r\n     *\r\n     *      @remarks The list of items is assumed to initially have correct top-bottom\r\n     *               ordering and positioning.\r\n     */\r\n    void updateItemMove(QList<T*>& items, T* item, qreal minX = 0.0);\r\n\r\n    /*!\r\n     *  Sets the position of an item according to the collision-based layout.\r\n     *\r\n     *    @param [in] items    The list of items. Assumed to be already in correct order.\r\n     *    @param [in] item     The item to position.\r\n     *    @param [in] x        The y coordinate for the item's position.\r\n     *    @param [in] minY     The minimum x coordinate.\r\n     */\r\n    void setItemPos(QList<T*> const& items, T* item, qreal y, qreal minX = 0.0);\r\n\r\n    /*!\r\n     *  Updates the positions of all items using horizontal stacking.\r\n     *\r\n     *    @param [in] items    The list of items.\r\n     *    @param [in] x        The y coordinate for the items.\r\n     *    @param [in] minX     The minimum x coordinate.\r\n     */\r\n    void updateItemPositions(QList<T*>& items, qreal y, qreal minX = 0.0);\r\n\r\nprivate:\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! The spacing between items.\r\n    qreal spacing_;\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"HCollisionLayout.inl\"\r\n\r\n#endif // HCOLLISIONLAYOUT_H\r\n"
  },
  {
    "path": "common/layouts/HCollisionLayout.inl",
    "content": "//-----------------------------------------------------------------------------\r\n// File: HCollisionLayout.inl\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Joni-Matti Maatta\r\n// Date: 22.4.2011\r\n//\r\n// Description:\r\n// Horizontal collision-based layout.\r\n//-----------------------------------------------------------------------------\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HCollisionLayout<T>::HCollisionLayout()\r\n//-----------------------------------------------------------------------------\r\ntemplate <class T>\r\nHCollisionLayout<T>::HCollisionLayout(qreal spacing) : spacing_(spacing)\r\n{\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HCollisionLayout<T>::~HCollisionLayout()\r\n//-----------------------------------------------------------------------------\r\ntemplate <class T>\r\nHCollisionLayout<T>::~HCollisionLayout()\r\n{\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: updateItemMove()\r\n//-----------------------------------------------------------------------------\r\ntemplate <class T>\r\nvoid HCollisionLayout<T>::updateItemMove(QList<T*>& items, T* item, qreal minX)\r\n{\r\n    item->setY(qMax(minX - item->boundingRect().left(), item->y()));\r\n\r\n    // Remove the moved item from the list.\r\n    items.removeAt(items.indexOf(item));\r\n\r\n    int index = 0;\r\n    qreal x = minX;\r\n\r\n    // Phase 1. Skip over the items that are fully above the moved item.\r\n    for (index = 0; index < items.size(); ++index)\r\n    {\r\n        T* curItem = items.at(index);\r\n\r\n        if (curItem->x() + curItem->boundingRect().right() + spacing_ >\r\n            item->x() + item->boundingRect().left())\r\n        {\r\n            break;\r\n        }\r\n\r\n        x = curItem->x() + curItem->boundingRect().right() + spacing_;\r\n    }\r\n\r\n    // Phase 2. Move the first colliding item above the moved item if it is possible\r\n    // and the moved item is at least slightly over the colliding item.\r\n    if (index < items.size())\r\n    {\r\n        T* curItem = items.at(index);\r\n\r\n        if (item->x() < curItem->x() && curItem->x() + curItem->boundingRect().left() <\r\n            item->x() + item->boundingRect().right() + spacing_ &&\r\n            x + curItem->boundingRect().width() + spacing_ <= item->x() + item->boundingRect().left() &&\r\n            item->x() + item->boundingRect().left() - spacing_ - curItem->boundingRect().right() >= minX)\r\n        {\r\n            curItem->setY(item->x() + item->boundingRect().left() - spacing_ -\r\n                curItem->boundingRect().right());\r\n\r\n            ++index;\r\n        }\r\n    }\r\n\r\n    // Phase 3. Put the moved item to its correct place.\r\n    items.insert(index, item);\r\n\r\n    // Phase 4. Move the rest of the items below the moved item so that they do not collide.\r\n    while (index < items.size() - 1)\r\n    {\r\n        T* item1 = items.at(index);\r\n        T* item2 = items.at(index + 1);\r\n\r\n        if (item1->x() + item1->boundingRect().right() + spacing_ >\r\n            item2->x() + item2->boundingRect().left())\r\n        {\r\n            item2->setY(item1->x() + item1->boundingRect().right() + spacing_ -\r\n                item2->boundingRect().left());\r\n        }\r\n\r\n        ++index;\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: setItemPos()\r\n//-----------------------------------------------------------------------------\r\ntemplate <class T>\r\nvoid HCollisionLayout<T>::setItemPos(QList<T*> const& /*items*/, T* item, qreal y, qreal)\r\n{\r\n    item->setY(y);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HCollisionLayout<T>::updateItemPositions()\r\n//-----------------------------------------------------------------------------\r\ntemplate <class T>\r\nvoid HCollisionLayout<T>::updateItemPositions(QList<T*>& items, qreal y, qreal minX /*= 0.0*/)\r\n{\r\n    // Nothing to do.\r\n}\r\n"
  },
  {
    "path": "common/layouts/HStackedLayout.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: HStackedLayout.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Joni-Matti Maatta\r\n// Date: 22.4.2011\r\n//\r\n// Description:\r\n// Horizontal stacked layout.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef HSTACKEDLAYOUT_H\r\n#define HSTACKEDLAYOUT_H\r\n\r\n#include \"IHGraphicsLayout.h\"\r\n\r\n#include <editors/common/DiagramUtil.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Horizontal stacked layout.\r\n//-----------------------------------------------------------------------------\r\ntemplate <class T>\r\nclass HStackedLayout : public IHGraphicsLayout<T>\r\n{\r\npublic:\r\n    /*!\r\n     *  Constructor.\r\n     *  \r\n     *  @param [in] spacing The spacing.\r\n     */\r\n    HStackedLayout(qreal spacing);\r\n\r\n    /*!\r\n     *  Destructor.\r\n     */\r\n    ~HStackedLayout();\r\n\r\n    /*!\r\n     *  Updates the horizontal stacking of the items when one item is being moved.\r\n     *\r\n     *    @param [in] items    The list of items.\r\n     *    @param [in] item     The item that is being moved.\r\n     *    @param [in] minX     The minimum x coordinate.\r\n     *\r\n     *      @remarks The list of items is assumed to initially have correct left-right ordering and\r\n     *               positioning.\r\n     */\r\n    void updateItemMove(QList<T*>& items, T* item, qreal minX = 0.0);\r\n\r\n    /*!\r\n     *  Sets the position of an item based on its index in the list using horizontal stacking.\r\n     *\r\n     *    @param [in] items    The list of items. Assumed to be already in correct order.\r\n     *    @param [in] item     The item to position.\r\n     *    @param [in] y        The y coordinate for the item's position.\r\n     *    @param [in] minX     The minimum x coordinate.\r\n     */\r\n    void setItemPos(QList<T*> const& items, T* item, qreal y, qreal minX = 0.0);\r\n\r\n    /*!\r\n     *  Updates the positions of all items using horizontal stacking.\r\n     *\r\n     *    @param [in] items    The list of items.\r\n     *    @param [in] x        The y coordinate for the items.\r\n     *    @param [in] minX     The minimum x coordinate.\r\n     */\r\n    void updateItemPositions(QList<T*>& items, qreal y, qreal minX = 0.0);\r\n\r\nprivate:\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! The spacing between items.\r\n    qreal spacing_;\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"HStackedLayout.inl\"\r\n\r\n#endif // HSTACKEDLAYOUT_H\r\n"
  },
  {
    "path": "common/layouts/HStackedLayout.inl",
    "content": "//-----------------------------------------------------------------------------\r\n// File: HStackedLayout.inl\r\n//-----------------------------------------------------------------------------\r\n// Project: Endpoint Designer\r\n// Author: Joni-Matti Maatta\r\n// Date: 22.4.2011\r\n//\r\n// Description:\r\n// Horizontal stacked layout.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include <limits>\r\n#include <complex>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HStackedLayout<T>::HStackedLayout()\r\n//-----------------------------------------------------------------------------\r\ntemplate <class T>\r\nHStackedLayout<T>::HStackedLayout(qreal spacing) : spacing_(spacing)\r\n{\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HStackedLayout<T>::~HStackedLayout()\r\n//-----------------------------------------------------------------------------\r\ntemplate <class T>\r\nHStackedLayout<T>::~HStackedLayout()\r\n{\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: updateItemMove()\r\n//-----------------------------------------------------------------------------\r\ntemplate <class T>\r\nvoid HStackedLayout<T>::updateItemMove(QList<T*>& items, T* item, qreal minX)\r\n{\r\n    using DiagramUtil::clampCeil;\r\n\r\n    // Move the item to the last position (this simplifies the for loop).\r\n    items.removeAt(items.indexOf(item));\r\n    items.append(item);\r\n\r\n    // Determine the best position for the item (position where the item is closest to\r\n    // its resulting stacked position).\r\n    qreal refX = item->pos().x() + item->boundingRect().left();\r\n    qreal dist = std::numeric_limits<double>::max();\r\n    qreal x = minX;\r\n    int index = 0;\r\n\r\n    for (int i = 0; i < items.size(); ++i)\r\n    {\r\n        qreal newDist = std::fabs(x - refX);\r\n\r\n        // We can stop when the distance begins to grow.\r\n        if (newDist > dist)\r\n        {\r\n            break;\r\n        }\r\n\r\n        dist = newDist;\r\n        index = i;\r\n\r\n        // Otherwise increment the bookkeeping x.\r\n        x += clampCeil(items.at(index)->boundingRect().width(), GridSize) + spacing_;\r\n    }\r\n\r\n    // Change the item's position in the list.\r\n    items.removeAt(items.indexOf(item));\r\n    items.insert(index, item);\r\n\r\n    // Move the other columns accordingly.\r\n    x = minX;\r\n\r\n    for (int i = 0; i < items.size(); ++i)\r\n    {\r\n        if (i != index)\r\n        {\r\n            items.at(i)->setX(x + clampCeil(-items.at(i)->boundingRect().left(), GridSize));\r\n        }\r\n\r\n        x += clampCeil(items.at(i)->boundingRect().width(), GridSize) + spacing_;\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: setItemPos()\r\n//-----------------------------------------------------------------------------\r\ntemplate <class T>\r\nvoid HStackedLayout<T>::setItemPos(QList<T*> const& items, T* item, qreal y, qreal minX)\r\n{\r\n    using DiagramUtil::clampCeil;\r\n\r\n    int index = items.indexOf(item);\r\n    qreal x = minX;\r\n\r\n    for (int i = 0; i < index; ++i)\r\n    {\r\n        x += clampCeil(items.at(i)->boundingRect().width(), GridSize) + spacing_;\r\n    }\r\n\r\n    item->setPos(x + clampCeil(-item->boundingRect().left(), GridSize), y);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: updateItemPositions()\r\n//-----------------------------------------------------------------------------\r\ntemplate <class T>\r\nvoid HStackedLayout<T>::updateItemPositions(QList<T*>& items, qreal y, qreal minX)\r\n{\r\n    using DiagramUtil::clampCeil;\r\n\r\n    qreal x = minX;\r\n\r\n    for (int i = 0; i < items.size(); ++i)\r\n    {\r\n        items.at(i)->setPos(x + clampCeil(-items.at(i)->boundingRect().left(), GridSize), y);\r\n        x += clampCeil(items.at(i)->boundingRect().width(), GridSize) + spacing_;\r\n    }\r\n}\r\n"
  },
  {
    "path": "common/layouts/IHGraphicsLayout.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: IHGraphicsLayout.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Joni-Matti Maatta\r\n// Date: 9.10.2012\r\n//\r\n// Description:\r\n// Declares the vertical graphics layout interface.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef IHGRAPHICSLAYOUT_H\r\n#define IHGRAPHICSLAYOUT_H\r\n\r\n#include <QList>\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Vertical graphics layout interface.\r\n//-----------------------------------------------------------------------------\r\ntemplate <class T>\r\nclass IHGraphicsLayout\r\n{\r\npublic:\r\n    /*!\r\n     *  Destructor.\r\n     */\r\n    virtual ~IHGraphicsLayout() {}\r\n\r\n    /*!\r\n     *  Updates the horizontal stacking of the items when one item is being moved.\r\n     *\r\n     *    @param [in] items    The list of items.\r\n     *    @param [in] item     The item that is being moved.\r\n     *    @param [in] minX     The minimum x coordinate.\r\n     *\r\n     *      @remarks The list of items is assumed to initially have correct left-right ordering and\r\n     *               positioning.\r\n     */\r\n    virtual void updateItemMove(QList<T*>& items, T* item, qreal minX = 0.0) = 0;\r\n\r\n    /*!\r\n     *  Sets the position of an item based on its index in the list using horizontal stacking.\r\n     *\r\n     *    @param [in] items    The list of items. Assumed to be already in correct order.\r\n     *    @param [in] item     The item to position.\r\n     *    @param [in] y        The y coordinate for the item's position.\r\n     *    @param [in] minX     The minimum x coordinate.\r\n     */\r\n    virtual void setItemPos(QList<T*> const& items, T* item, qreal y, qreal minX = 0.0) = 0;\r\n\r\n    /*!\r\n     *  Updates the positions of all items using horizontal stacking.\r\n     *\r\n     *    @param [in] items    The list of items.\r\n     *    @param [in] x        The y coordinate for the items.\r\n     *    @param [in] minX     The minimum x coordinate.\r\n     */\r\n    virtual void updateItemPositions(QList<T*>& items, qreal y, qreal minX = 0.0) = 0;\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n\r\n#endif // IHGRAPHICSLAYOUT_H\r\n"
  },
  {
    "path": "common/layouts/IVGraphicsLayout.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: IVGraphicsLayout.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Joni-Matti Maatta\r\n// Date: 9.10.2012\r\n//\r\n// Description:\r\n// Declares the vertical graphics layout interface.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef IVGRAPHICSLAYOUT_H\r\n#define IVGRAPHICSLAYOUT_H\r\n\r\n#include <QList>\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Vertical graphics layout interface.\r\n//-----------------------------------------------------------------------------\r\ntemplate <class T>\r\nclass IVGraphicsLayout\r\n{\r\npublic:\r\n    /*!\r\n     *  Destructor.\r\n     */\r\n    virtual ~IVGraphicsLayout() {}\r\n\r\n    /*!\r\n     *  Updates the vertical stacking of the items when one item is being moved.\r\n     *\r\n     *    @param [in] items    The list of items.\r\n     *    @param [in] item     The item that is being moved.\r\n     *    @param [in] minY     The minimum y coordinate.\r\n     *\r\n     *      @remarks The list of items is assumed to initially have correct left-right ordering and\r\n     *               positioning.\r\n     */\r\n    virtual void updateItemMove(QList<T*>& items, T* item, qreal minY = 0.0) = 0;\r\n\r\n    /*!\r\n     *  Sets the position of an item based on its index in the list using vertical stacking.\r\n     *\r\n     *    @param [in] items    The list of items. Assumed to be already in correct order.\r\n     *    @param [in] item     The item to position.\r\n     *    @param [in] x        The x coordinate for the item's position.\r\n     *    @param [in] minY     The minimum y coordinate.\r\n     */\r\n    virtual void setItemPos(QList<T*> const& items, T* item, qreal x, qreal minY = 0.0) = 0;\r\n\r\n    /*!\r\n     *  Updates the positions of all items using vertical stacking.\r\n     *\r\n     *    @param [in] items    The list of items.\r\n     *    @param [in] x        The x coordinate for the items.\r\n     *    @param [in] minY     The minimum y coordinate.\r\n     */\r\n    virtual void updateItemPositions(QList<T*>& items, qreal x, qreal minY = 0.0) = 0;\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n\r\n#endif // IVGRAPHICSLAYOUT_H\r\n"
  },
  {
    "path": "common/layouts/VCollisionLayout.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: VCollisionLayout.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Joni-Matti Maatta\r\n// Date: 22.4.2011\r\n//\r\n// Description:\r\n// Vertical collision-based layout.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef VCOLLISIONLAYOUT_H\r\n#define VCOLLISIONLAYOUT_H\r\n\r\n#include \"IVGraphicsLayout.h\"\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Vertical collision layout.\r\n//-----------------------------------------------------------------------------\r\ntemplate <class T>\r\nclass VCollisionLayout : public IVGraphicsLayout<T>\r\n{\r\npublic:\r\n    /*!\r\n     *  Constructor.\r\n     *\r\n     *    @param [in] spacing The spacing between items.\r\n     */\r\n    VCollisionLayout(qreal spacing = 0.0);\r\n\r\n    /*!\r\n     *  Destructor.\r\n     */\r\n    ~VCollisionLayout();\r\n\r\n    /*!\r\n     *  Updates the positions of the items when one item is being moved.\r\n     *\r\n     *    @param [in] items    The list of items.\r\n     *    @param [in] item     The item that is being moved.\r\n     *    @param [in] minY     The minimum y coordinate.\r\n     *\r\n     *      @remarks The list of items is assumed to initially have correct top-bottom\r\n     *               ordering and positioning.\r\n     */\r\n    void updateItemMove(QList<T*>& items, T* item, qreal minY = 0.0);\r\n\r\n    /*!\r\n     *  Sets the position of an item according to the collision-based layout.\r\n     *\r\n     *    @param [in] items    The list of items. Assumed to be already in correct order.\r\n     *    @param [in] item     The item to position.\r\n     *    @param [in] x        The x coordinate for the item's position.\r\n     *    @param [in] minY     The minimum y coordinate.\r\n     */\r\n    void setItemPos(QList<T*> const& items, T* item, qreal x, qreal minY = 0.0);\r\n\r\n    /*!\r\n     *  Updates the positions of all items using vertical stacking.\r\n     *\r\n     *    @param [in] items    The list of items.\r\n     *    @param [in] x        The x coordinate for the items.\r\n     *    @param [in] minY     The minimum y coordinate.\r\n     */\r\n    void updateItemPositions(QList<T*>& items, qreal x, qreal minY = 0.0);\r\n\r\nprivate:\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! The spacing between items.\r\n    qreal spacing_;\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"VCollisionLayout.inl\"\r\n\r\n#endif // VCOLLISIONLAYOUT_H\r\n"
  },
  {
    "path": "common/layouts/VCollisionLayout.inl",
    "content": "//-----------------------------------------------------------------------------\r\n// File: VCollisionLayout.inl\r\n//-----------------------------------------------------------------------------\r\n// Project: Endpoint Designer\r\n// Author: Joni-Matti Maatta\r\n// Date: 22.4.2011\r\n//\r\n// Description:\r\n// Vertical collision-based layout.\r\n//-----------------------------------------------------------------------------\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VCollisionLayout<T>::VCollisionLayout()\r\n//-----------------------------------------------------------------------------\r\ntemplate <class T>\r\nVCollisionLayout<T>::VCollisionLayout(qreal spacing) : spacing_(spacing)\r\n{\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VCollisionLayout<T>::~VCollisionLayout()\r\n//-----------------------------------------------------------------------------\r\ntemplate <class T>\r\nVCollisionLayout<T>::~VCollisionLayout()\r\n{\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: updateItemMove()\r\n//-----------------------------------------------------------------------------\r\ntemplate <class T>\r\nvoid VCollisionLayout<T>::updateItemMove(QList<T*>& items, T* item, qreal minY)\r\n{\r\n    item->setY(qMax(minY - item->boundingRect().top(), item->y()));\r\n    QRectF itemRect = item->mapRectToParent(item->boundingRect());\r\n\r\n    // Remove the moved item from the list.\r\n    if (items.contains(item))\r\n    {\r\n        items.removeAt(items.indexOf(item));\r\n    }\r\n    \r\n\r\n    int index = 0;\r\n    qreal y = minY;\r\n\r\n    // Phase 1. Skip over the items that are fully above the moved item.\r\n    for (index = 0; index < items.size(); ++index)\r\n    {\r\n        T* curItem = items.at(index);\r\n        QRectF curItemRect = curItem->mapRectToParent(curItem->boundingRect());\r\n\r\n        if (curItemRect.bottom() + spacing_ > itemRect.top())\r\n        {\r\n            break;\r\n        }\r\n\r\n        y = curItemRect.bottom() + spacing_;\r\n    }\r\n\r\n    // Phase 2. Move the first colliding item above the moved item if it is possible\r\n    // and the moved item is at least slightly over the colliding item.\r\n    if (index < items.size())\r\n    {\r\n        T* curItem = items.at(index);\r\n        QRectF curItemRect = curItem->mapRectToParent(curItem->boundingRect());\r\n\r\n        if (item->y() < curItem->y() &&\r\n            curItemRect.top() < itemRect.bottom() + spacing_ &&\r\n            y + curItemRect.height() + spacing_ <= itemRect.top() &&\r\n            itemRect.top() - spacing_ - (curItemRect.bottom() - curItem->y()) >= minY)\r\n        {\r\n            curItem->setY(itemRect.top() - spacing_ - (curItemRect.bottom() - curItem->y()));\r\n            ++index;\r\n        }\r\n    }\r\n\r\n    // Phase 3. Put the moved item to its correct place.\r\n    items.insert(index, item);\r\n\r\n    // Phase 4. Move the rest of the items below the moved item so that they do not collide.\r\n    while (index < items.size() - 1)\r\n    {\r\n        T* item1 = items.at(index);\r\n        T* item2 = items.at(index + 1);\r\n\r\n        QRectF itemRect1 = item1->mapRectToParent(item1->boundingRect());\r\n        QRectF itemRect2 = item2->mapRectToParent(item2->boundingRect());\r\n\r\n        if (itemRect1.bottom() + spacing_ > itemRect2.top())\r\n        {\r\n            item2->setY(itemRect1.bottom() + spacing_ - (itemRect2.top() - item2->y()));\r\n        }\r\n\r\n        ++index;\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: setItemPos()\r\n//-----------------------------------------------------------------------------\r\ntemplate <class T>\r\nvoid VCollisionLayout<T>::setItemPos(QList<T*> const&, T* item, qreal x, qreal)\r\n{\r\n    item->setX(x);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VCollisionLayout<T>::updateItemPositions()\r\n//-----------------------------------------------------------------------------\r\ntemplate <class T>\r\nvoid VCollisionLayout<T>::updateItemPositions(QList<T*>&, qreal, qreal)\r\n{\r\n    // Nothing to do.\r\n}\r\n\r\n"
  },
  {
    "path": "common/layouts/VNoCollisionNoMovementLayout.h",
    "content": "//-----------------------------------------------------------------------------\n// File: VNoCollisionNoMovementLayout.h\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Mikko Teuho\n// Date: 17.04.2025\n//\n// Description:\n// Vertical layout. No collision and no movement allowed. Used in memory design columns.\n//-----------------------------------------------------------------------------\n\n#ifndef VNOCOLLISIONNOMOVEMENTLAYOUT_H\n#define VNOCOLLISIONNOMOVEMENTLAYOUT_H\n\n#include \"IVGraphicsLayout.h\"\n\n//-----------------------------------------------------------------------------\n//! Vertical collision layout.\n//-----------------------------------------------------------------------------\ntemplate <class T>\nclass VNoCollisionNoMovementLayout : public IVGraphicsLayout<T>\n{\npublic:\n    /*!\n     *  Constructor.\n     *\n     *    @param [in] spacing The spacing between items.\n     */\n    VNoCollisionNoMovementLayout(qreal spacing = 0.0);\n\n    /*!\n     *  Destructor.\n     */\n    ~VNoCollisionNoMovementLayout();\n\n    /*!\n     *  Updates the positions of the items when one item is being moved.\n     *\n     *    @param [in] items    The list of items.\n     *    @param [in] item     The item that is being moved.\n     *    @param [in] minY     The minimum y coordinate.\n     *\n     *      @remarks The list of items is assumed to initially have correct top-bottom\n     *               ordering and positioning.\n     */\n    void updateItemMove(QList<T*>& items, T* item, qreal minY = 0.0);\n\n    /*!\n     *  Sets the position of an item according to the collision-based layout.\n     *\n     *    @param [in] items    The list of items. Assumed to be already in correct order.\n     *    @param [in] item     The item to position.\n     *    @param [in] x        The x coordinate for the item's position.\n     *    @param [in] minY     The minimum y coordinate.\n     */\n    void setItemPos(QList<T*> const& items, T* item, qreal x, qreal minY = 0.0);\n\n    /*!\n     *  Updates the positions of all items using vertical stacking.\n     *\n     *    @param [in] items    The list of items.\n     *    @param [in] x        The x coordinate for the items.\n     *    @param [in] minY     The minimum y coordinate.\n     */\n    void updateItemPositions(QList<T*>& items, qreal x, qreal minY = 0.0);\n\nprivate:\n    //-----------------------------------------------------------------------------\n    // Data.\n    //-----------------------------------------------------------------------------\n\n    //! The spacing between items.\n    qreal spacing_;\n};\n\n//-----------------------------------------------------------------------------\n\n#include \"VNoCollisionNoMovementLayout.inl\"\n\n#endif // VNOCOLLISIONNOMOVEMENTLAYOUT_H\n"
  },
  {
    "path": "common/layouts/VNoCollisionNoMovementLayout.inl",
    "content": "//-----------------------------------------------------------------------------\n// File: VNoCollisionNoMovementLayout.inl\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Mikko Teuho\n// Date: 17.04.2025\n//\n// Description:\n// Vertical layout. No collision and no movement allowed. Used in memory design columns.\n//-----------------------------------------------------------------------------\n\n//-----------------------------------------------------------------------------\n// Function: VNoCollisionNoMovementLayout<T>::VNoCollisionNoMovementLayout()\n//-----------------------------------------------------------------------------\ntemplate <class T>\nVNoCollisionNoMovementLayout<T>::VNoCollisionNoMovementLayout(qreal spacing) : spacing_(spacing)\n{\n}\n\n//-----------------------------------------------------------------------------\n// Function: VNoCollisionNoMovementLayout<T>::~VNoCollisionNoMovementLayout()\n//-----------------------------------------------------------------------------\ntemplate <class T>\nVNoCollisionNoMovementLayout<T>::~VNoCollisionNoMovementLayout()\n{\n}\n\n//-----------------------------------------------------------------------------\n// Function: updateItemMove()\n//-----------------------------------------------------------------------------\ntemplate <class T>\nvoid VNoCollisionNoMovementLayout<T>::updateItemMove(QList<T*>&, T*, qreal)\n{\n    //! Nothing to do\n}\n\n//-----------------------------------------------------------------------------\n// Function: setItemPos()\n//-----------------------------------------------------------------------------\ntemplate <class T>\nvoid VNoCollisionNoMovementLayout<T>::setItemPos(QList<T*> const&, T*, qreal, qreal)\n{\n    //! Nothing to do\n}\n\n//-----------------------------------------------------------------------------\n// Function: VNoCollisionNoMovementLayout<T>::updateItemPositions()\n//-----------------------------------------------------------------------------\ntemplate <class T>\nvoid VNoCollisionNoMovementLayout<T>::updateItemPositions(QList<T*>&, qreal, qreal)\n{\n    // Nothing to do.\n}\n\n"
  },
  {
    "path": "common/layouts/VStackedLayout.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: VStackedLayout.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Joni-Matti Maatta\r\n// Date: 22.4.2011\r\n//\r\n// Description:\r\n// Vertical stacked layout.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef VSTACKEDLAYOUT_H\r\n#define VSTACKEDLAYOUT_H\r\n\r\n#include \"IVGraphicsLayout.h\"\r\n\r\n#include <editors/common/DiagramUtil.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Vertical stacked layout.\r\n//-----------------------------------------------------------------------------\r\ntemplate <class T>\r\nclass VStackedLayout : public IVGraphicsLayout<T>\r\n{\r\npublic:\r\n    /*!\r\n     *  Constructor.\r\n     *\r\n     *    @param [in] spacing The spacing between items.\r\n     */\r\n    VStackedLayout(qreal spacing);\r\n\r\n    /*!\r\n     *  Destructor.\r\n     */\r\n    ~VStackedLayout();\r\n\r\n    /*!\r\n     *  Updates the vertical stacking of the items when one item is being moved.\r\n     *\r\n     *    @param [in] items    The list of items.\r\n     *    @param [in] item     The item that is being moved.\r\n     *    @param [in] minY     The minimum y coordinate.\r\n     *\r\n     *      @remarks The list of items is assumed to initially have correct left-right ordering and\r\n     *               positioning.\r\n     */\r\n    void updateItemMove(QList<T*>& items, T* item, qreal minY = 0.0);\r\n\r\n    /*!\r\n     *  Sets the position of an item based on its index in the list using vertical stacking.\r\n     *\r\n     *    @param [in] items    The list of items. Assumed to be already in correct order.\r\n     *    @param [in] item     The item to position.\r\n     *    @param [in] x        The x coordinate for the item's position.\r\n     *    @param [in] minY     The minimum y coordinate.\r\n    */\r\n    void setItemPos(QList<T*> const& items, T* item, qreal x, qreal minY = 0.0);\r\n\r\n    /*!\r\n     *  Updates the positions of all items using vertical stacking.\r\n     *\r\n     *    @param [in] items    The list of items.\r\n     *    @param [in] x        The x coordinate for the items.\r\n     *    @param [in] minY     The minimum y coordinate.\r\n     */\r\n    void updateItemPositions(QList<T*>& items, qreal x, qreal minY = 0.0);\r\n\r\nprivate:\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! The spacing between items.\r\n    qreal spacing_;\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"VStackedLayout.inl\"\r\n\r\n#endif // VSTACKEDLAYOUT_H\r\n"
  },
  {
    "path": "common/layouts/VStackedLayout.inl",
    "content": "//-----------------------------------------------------------------------------\r\n// File: VStackedLayout.inl\r\n//-----------------------------------------------------------------------------\r\n// Project: Endpoint Designer\r\n// Author: Joni-Matti Maatta\r\n// Date: 22.4.2011\r\n//\r\n// Description:\r\n// Vertical stacked layout\r\n//-----------------------------------------------------------------------------\r\n\r\n#include <limits>\r\n#include <complex>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VStackedLayout<T>::VStackedLayout()\r\n//-----------------------------------------------------------------------------\r\ntemplate <class T>\r\nVStackedLayout<T>::VStackedLayout(qreal spacing) : spacing_(spacing)\r\n{\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VStackedLayout<T>::~VStackedLayout()\r\n//-----------------------------------------------------------------------------\r\ntemplate <class T>\r\nVStackedLayout<T>::~VStackedLayout()\r\n{\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: updateItemMove()\r\n//-----------------------------------------------------------------------------\r\ntemplate <class T>\r\nvoid VStackedLayout<T>::updateItemMove(QList<T*>& items, T* item, qreal minY)\r\n{\r\n    using DiagramUtil::clampCeil;\r\n\r\n    // Move the item to the last position (this simplifies the for loop).\r\n    if (items.contains(item))\r\n    {\r\n        items.removeAt(items.indexOf(item));\r\n    }\r\n    \r\n    items.append(item);\r\n\r\n    // Determine the best position for the item (position where the item is closest to\r\n    // its resulting stacked position).\r\n    qreal refY = item->pos().y() + item->boundingRect().top();\r\n    qreal dist = std::numeric_limits<double>::max();\r\n    qreal y = minY;\r\n    int index = 0;\r\n\r\n    for (int i = 0; i < items.size(); ++i)\r\n    {\r\n        qreal newDist = std::fabs(y - refY);\r\n\r\n        // We can stop when the distance begins to grow.\r\n        if (newDist > dist)\r\n        {\r\n            break;\r\n        }\r\n\r\n        dist = newDist;\r\n        index = i;\r\n\r\n        // Otherwise increment the bookkeeping x.\r\n        y += clampCeil(items.at(index)->boundingRect().height(), GridSize) + spacing_;\r\n    }\r\n\r\n    // Change the item's position in the list.\r\n    items.removeAt(items.indexOf(item));\r\n    items.insert(index, item);\r\n\r\n    // Move the other columns accordingly.\r\n    y = minY;\r\n\r\n    for (int i = 0; i < items.size(); ++i)\r\n    {\r\n        if (i != index)\r\n        {\r\n            items.at(i)->setY(y + clampCeil(-items.at(i)->boundingRect().top(), GridSize));\r\n        }\r\n\r\n        y += clampCeil(items.at(i)->boundingRect().height(), GridSize) + spacing_;\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: setItemPos()\r\n//-----------------------------------------------------------------------------\r\ntemplate <class T>\r\nvoid VStackedLayout<T>::setItemPos(QList<T*> const& items, T* item, qreal x, qreal minY)\r\n{\r\n    using DiagramUtil::clampCeil;\r\n\r\n    int index = items.indexOf(item);\r\n    qreal y = minY;\r\n\r\n    for (int i = 0; i < index; ++i)\r\n    {\r\n        y += clampCeil(items.at(i)->boundingRect().height(), GridSize) + spacing_;\r\n    }\r\n\r\n    item->setPos(x, y + clampCeil(-item->boundingRect().top(), GridSize));\r\n    //item->setPos(x, qMax(item->y(), minY - item->boundingRect().top()));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: updateItemPositions()\r\n//-----------------------------------------------------------------------------\r\ntemplate <class T>\r\nvoid VStackedLayout<T>::updateItemPositions(QList<T*>& items, qreal x, qreal minY)\r\n{\r\n    using DiagramUtil::clampCeil;\r\n\r\n    qreal y = minY;\r\n\r\n    for (int i = 0; i < items.size(); ++i)\r\n    {\r\n        items.at(i)->setPos(x, y + clampCeil(-items.at(i)->boundingRect().top(), GridSize));\r\n        y += clampCeil(items.at(i)->boundingRect().height(), GridSize) + spacing_;\r\n    }\r\n}\r\n"
  },
  {
    "path": "common/layouts/VStaticLayout.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: VStaticLayout.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Joni-Matti Maatta\r\n// Date: 17.10.2012\r\n//\r\n// Description:\r\n// Static layout which does not allow other items to be moved.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef VSTATICLAYOUT_H\r\n#define VSTATICLAYOUT_H\r\n\r\n#include \"IVGraphicsLayout.h\"\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Vertical static layout.\r\n//-----------------------------------------------------------------------------\r\ntemplate <class T>\r\nclass VStaticLayout : public IVGraphicsLayout<T>\r\n{\r\npublic:\r\n    /*!\r\n     *  Constructor.\r\n     *\r\n     *    @param [in] spacing The spacing between items.\r\n     */\r\n    VStaticLayout(qreal spacing = 0.0);\r\n\r\n    /*!\r\n     *  Destructor.\r\n     */\r\n    ~VStaticLayout();\r\n\r\n    /*!\r\n     *  Updates the positions of the items when one item is being moved.\r\n     *\r\n     *    @param [in] items    The list of items.\r\n     *    @param [in] item     The item that is being moved.\r\n     *    @param [in] minY     The minimum y coordinate.\r\n     *\r\n     *      @remarks The list of items is assumed to initially have correct top-bottom\r\n     *               ordering and positioning.\r\n     */\r\n    void updateItemMove(QList<T*>& items, T* item, qreal minY = 0.0);\r\n\r\n    /*!\r\n     *  Sets the position of an item according to the layout.\r\n     *\r\n     *    @param [in] items    The list of items. Assumed to be already in correct order.\r\n     *    @param [in] item     The item to position.\r\n     *    @param [in] x        The x coordinate for the item's position.\r\n     *    @param [in] minY     The minimum y coordinate.\r\n     */\r\n    void setItemPos(QList<T*> const& items, T* item, qreal x, qreal minY = 0.0);\r\n\r\n    /*!\r\n     *  Updates the positions of all items using.\r\n     *\r\n     *    @param [in] items    The list of items.\r\n     *    @param [in] x        The x coordinate for the items.\r\n     *    @param [in] minY     The minimum y coordinate.\r\n     */\r\n    void updateItemPositions(QList<T*>& items, qreal x, qreal minY = 0.0);\r\n\r\nprivate:\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! The spacing between items.\r\n    qreal spacing_;\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"VStaticLayout.inl\"\r\n\r\n#endif // VSTATICLAYOUT_H\r\n"
  },
  {
    "path": "common/layouts/VStaticLayout.inl",
    "content": "//-----------------------------------------------------------------------------\r\n// File: VStaticLayout.inl\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Joni-Matti Maatta\r\n// Date: 17.10.2012\r\n//\r\n// Description:\r\n// Vertical static layout.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include <editors/common/DiagramUtil.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VStaticLayout<T>::VStaticLayout()\r\n//-----------------------------------------------------------------------------\r\ntemplate <class T>\r\nVStaticLayout<T>::VStaticLayout(qreal spacing) : spacing_(spacing)\r\n{\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VStaticLayout<T>::~VStaticLayout()\r\n//-----------------------------------------------------------------------------\r\ntemplate <class T>\r\nVStaticLayout<T>::~VStaticLayout()\r\n{\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: updateItemMove()\r\n//-----------------------------------------------------------------------------\r\ntemplate <class T>\r\nvoid VStaticLayout<T>::updateItemMove(QList<T*>& items, T* item, qreal minY)\r\n{\r\n    item->setY(qMax(minY - item->boundingRect().top(), item->y()));\r\n    QRectF itemRect = item->mapRectToParent(item->boundingRect());\r\n\r\n    // Remove the moved item from the list.\r\n    items.removeAt(items.indexOf(item));\r\n\r\n    int index = 0;\r\n    //qreal y = minY;\r\n\r\n    // Phase 1. Skip over the items that are fully above the moved item.\r\n    for (index = 0; index < items.size(); ++index)\r\n    {\r\n        T* curItem = items.at(index);\r\n        QRectF curItemRect = curItem->mapRectToParent(curItem->boundingRect());\r\n\r\n        if (curItemRect.bottom() + spacing_ > itemRect.top())\r\n        {\r\n            break;\r\n        }\r\n\r\n        //y = curItemRect.bottom() + spacing_;\r\n    }\r\n\r\n    // Phase 3. Put the moved item to its correct place.\r\n    items.insert(index, item);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: setItemPos()\r\n//-----------------------------------------------------------------------------\r\ntemplate <class T>\r\nvoid VStaticLayout<T>::setItemPos(QList<T*> const&, T* item, qreal x, qreal)\r\n{\r\n    item->setX(x);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VStaticLayout<T>::updateItemPositions()\r\n//-----------------------------------------------------------------------------\r\ntemplate <class T>\r\nvoid VStaticLayout<T>::updateItemPositions(QList<T*>& items, qreal x, qreal minY)\r\n{\r\n    using DiagramUtil::clampCeil;\r\n\r\n    if (!items.empty())\r\n    {\r\n        T* firstItem = items.at(0);\r\n        firstItem->setY(qMax(minY - firstItem->boundingRect().top(), firstItem->y()));\r\n\r\n        qreal y = firstItem->y() + firstItem->boundingRect().bottom() + spacing_;\r\n\r\n        for (int i = 1; i < items.size(); ++i)\r\n        {\r\n            items.at(i)->setPos(x, y + clampCeil(-items.at(i)->boundingRect().top(), GridSize));\r\n            y += clampCeil(items.at(i)->boundingRect().height(), GridSize) + spacing_;\r\n        }\r\n    }\r\n}\r\n"
  },
  {
    "path": "common/ui/GraphicalMessageMediator.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: GraphicalMessageMediator.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Esko Pekkarinen\n// Date: 13.02.2018\n//\n// Description:\n// Graphical output for user messages.\n//-----------------------------------------------------------------------------\n\n#include \"GraphicalMessageMediator.h\"\n\n#include <mainwindow/MessageConsole/messageconsole.h>\n\n#include <QApplication>\n#include <QMessageBox>\n\n//-----------------------------------------------------------------------------\n// Function: GraphicalMessageMediator::GraphicalMessageMediator()\n//-----------------------------------------------------------------------------\nGraphicalMessageMediator::GraphicalMessageMediator(QObject* parent): QObject(parent)\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: GraphicalMessageMediator::showMessage()\n//-----------------------------------------------------------------------------\nvoid GraphicalMessageMediator::showMessage(QString const& message) const\n{\n    emit noticeMessage(message);\n}\n\n//-----------------------------------------------------------------------------\n// Function: GraphicalMessageMediator::showError()\n//-----------------------------------------------------------------------------\nvoid GraphicalMessageMediator::showError(QString const& error) const\n{\n    emit errorMessage(error);\n}\n\n//-----------------------------------------------------------------------------\n// Function: GraphicalMessageMediator::showFailure()\n//-----------------------------------------------------------------------------\nvoid GraphicalMessageMediator::showFailure(QString const& error) const\n{\n    QMessageBox msgBox(QMessageBox::Critical, QApplication::applicationName(),\n        error, QMessageBox::Ok, 0);\n\n    msgBox.exec();\n}\n\n//-----------------------------------------------------------------------------\n// Function: GraphicalMessageMediator::showStatusMessage()\n//-----------------------------------------------------------------------------\nvoid GraphicalMessageMediator::showStatusMessage(QString const& status) const\n{    \n    emit statusMessage(status);\n}\n"
  },
  {
    "path": "common/ui/GraphicalMessageMediator.h",
    "content": "//-----------------------------------------------------------------------------\n// File: GraphicalMessageMediator.h\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Esko Pekkarinen\n// Date: 13.02.2018\n//\n// Description:\n// Graphical output for user messages.\n//-----------------------------------------------------------------------------\n\n#ifndef GRAPHICALMESSAGEMEDIATOR_H\n#define GRAPHICALMESSAGEMEDIATOR_H\n\n#include <KactusAPI/include/MessageMediator.h>\n\n#include <QStatusBar>\n\nclass MessageConsole;\n\n//-----------------------------------------------------------------------------\n//! Graphical output for user messages.\n//-----------------------------------------------------------------------------\nclass GraphicalMessageMediator: public QObject, public MessageMediator\n{\n    Q_OBJECT\npublic:\n\n    //! The constructor.\n    GraphicalMessageMediator(QObject* parent = nullptr);\n\n    //! The destructor.\n    virtual ~GraphicalMessageMediator() = default;\n\n    // Disable copying.\n    GraphicalMessageMediator(GraphicalMessageMediator const& rhs) = delete;\n    GraphicalMessageMediator& operator=(GraphicalMessageMediator const& rhs) = delete;\n\n    //! Show the given message to the user.\n    virtual void showMessage(QString const& message) const;\n\n    //! Show the given error to the user.\n    virtual void showError(QString const& error) const;\n\n    //! Show the given failure message to the user.\n    virtual void showFailure(QString const& error) const;\n\n    //! Show the given status to the user.\n    virtual void showStatusMessage(QString const& status) const;\n\nsignals:\n\n    //! Show the given message to the user.\n    void noticeMessage(QString const& message) const;\n\n    //! Show the given error to the user.\n    void errorMessage(QString const& error) const;\n\n    //! Show the given status to the user.\n    void statusMessage(QString const& status) const;\n};\n\n#endif // GRAPHICALMESSAGEMEDIATOR_H\n"
  },
  {
    "path": "common/validators/LibraryPathValidator/librarypathvalidator.cpp",
    "content": "/* \r\n *  \tCreated on: 26.1.2012\r\n *      Author: Antti Kamppi\r\n * \t\tfilename: librarypathvalidator.cpp\r\n *\t\tProject: Kactus 2\r\n */\r\n\r\n#include \"librarypathvalidator.h\"\r\n\r\n#include <QRegularExpressionValidator>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LibraryPathValidator()\r\n//-----------------------------------------------------------------------------\r\nLibraryPathValidator::LibraryPathValidator(QObject *parent): QRegularExpressionValidator(parent)\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: validate()\r\n//-----------------------------------------------------------------------------\r\nQValidator::State LibraryPathValidator::validate(QString& input, int& pos) const\r\n{\r\n    State state = QRegularExpressionValidator::validate(input,pos);\r\n\r\n    // Partial library path is considered invalid.\r\n    if (state == QValidator::Intermediate)\r\n    {\r\n        return QValidator::Invalid;\r\n    }\r\n\r\n    return state;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LibraryPathValidator::setUnmodifiablePath()\r\n//-----------------------------------------------------------------------------\r\nvoid LibraryPathValidator::setUnmodifiablePath( const QString& path )\r\n{\r\n    QRegularExpression regExp(path + QString(\".*\"), \r\n        QRegularExpression::CaseInsensitiveOption | QRegularExpression::DotMatchesEverythingOption);\r\n\tsetRegularExpression(regExp);\r\n}"
  },
  {
    "path": "common/validators/LibraryPathValidator/librarypathvalidator.h",
    "content": "/* \r\n *  \tCreated on: 26.1.2012\r\n *      Author: Antti Kamppi\r\n * \t\tfilename: librarypathvalidator.h\r\n *\t\tProject: Kactus 2\r\n */\r\n\r\n#ifndef LIBRARYPATHVALIDATOR_H\r\n#define LIBRARYPATHVALIDATOR_H\r\n\r\n#include <QRegularExpressionValidator>\r\n\r\n/*! \\brief Validator that is used when editing a save path for a new item.\r\n * \r\n */\r\nclass LibraryPathValidator : public QRegularExpressionValidator {\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\r\n\t/*! \\brief The constructor\r\n\t *\r\n\t * \\param parent Pointer to the owner of this validator.\r\n\t *\r\n\t*/\r\n\tLibraryPathValidator(QObject *parent);\r\n\t\r\n\t//! \\brief The destructor\r\n\tvirtual ~LibraryPathValidator() = default;\r\n\r\n    //! \\brief No copying\r\n    LibraryPathValidator(const LibraryPathValidator& other) = delete;\r\n\r\n    //! \\brief No assignment\r\n    LibraryPathValidator& operator=(const LibraryPathValidator& other) = delete;\r\n\r\n\t/*! \\brief Validates a given input.\r\n\t *\r\n\t * \\param input Input to validate.\r\n\t * \\param pos   Length set to input, if input is not matched.\r\n\t *\r\n     * \\return Acceptable, if input is valid, otherwise Invalid. Intermediate is never returned.\r\n\t*/\r\n    virtual QValidator::State validate(QString& input, int& pos) const;\r\n\r\npublic slots:\r\n\r\n\tvoid setUnmodifiablePath(const QString& path);\r\n\r\n};\r\n\r\n#endif // LIBRARYPATHVALIDATOR_H\r\n"
  },
  {
    "path": "common/views/EditableListView/editablelistview.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: editablelistview.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Antti Kamppi\r\n// Date: 12.12.2011\r\n//\r\n// Description:\r\n// View-class with add, remove and move operations for lists of items.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"editablelistview.h\"\r\n\r\n#include <QMenu>\r\n#include <QPainter>\r\n\r\n#include <common/KactusColors.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: EditableListView::EditableListView()\r\n//-----------------------------------------------------------------------------\r\nEditableListView::EditableListView(QWidget *parent):\r\nQListView(parent),\r\n    pressedPoint_(),\r\n    addAction_(tr(\"Add new\"), this),\r\n    removeAction_(tr(\"Remove\"), this)\r\n{\r\n    setMovement(QListView::Free);\r\n\r\n    setToolTip(tr(\"Double click to add new item.\"));\r\n\r\n\tsetupActions();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: EditableListView::~EditableListView()\r\n//-----------------------------------------------------------------------------\r\nEditableListView::~EditableListView()\r\n{\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: EditableListView::paintEvent()\r\n//-----------------------------------------------------------------------------\r\nvoid EditableListView::paintEvent(QPaintEvent *event)\r\n{\r\n    QListView::paintEvent(event);\r\n\r\n    if (model() && model()->rowCount() == 0) \r\n    {     \r\n        const int MARGIN = 2;\r\n        QRect placeholderTextRec = rect();\r\n        placeholderTextRec.setX(placeholderTextRec.x() + MARGIN);\r\n        placeholderTextRec.setY(placeholderTextRec.y() + MARGIN);\r\n        placeholderTextRec.setWidth(placeholderTextRec.width() - MARGIN);\r\n        placeholderTextRec.setHeight(placeholderTextRec.height() - MARGIN);\r\n\r\n        QPainter p(this->viewport());\r\n        p.setPen(KactusColors::DISABLED_TEXT);\r\n        p.drawText(placeholderTextRec, Qt::AlignLeft | Qt::TextWordWrap, tr(\"Double click to add new item.\"));\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: EditableListView::mouseMoveEvent()\r\n//-----------------------------------------------------------------------------\r\nvoid EditableListView::mouseMoveEvent(QMouseEvent* e)\r\n{\r\n\t// if left mouse button was pressed \r\n\tif (e->buttons() & Qt::LeftButton)\r\n    {\r\n\t\tQModelIndex startIndex = indexAt(pressedPoint_);\r\n\t\tQModelIndex thisIndex = indexAt(e->pos());\r\n\r\n\t\t// if the item was dragged to new location\r\n\t\tif (startIndex.isValid() && startIndex != thisIndex)\r\n        {\r\n\t\t\tsetCursor(QCursor(Qt::ClosedHandCursor));\r\n\r\n\t\t\temit moveItem(startIndex, thisIndex);\r\n\r\n\t\t\t// update the pressed point so the dragging works also when moving further to another index\r\n\t\t\tpressedPoint_ = e->pos();\r\n\t\t}\r\n\t}\r\n\r\n\tQListView::mouseMoveEvent(e);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: EditableListView::mouseDoubleClickEvent()\r\n//-----------------------------------------------------------------------------\r\nvoid EditableListView::mouseDoubleClickEvent(QMouseEvent* event)\r\n{\r\n\t// if there is no item on the clicked position then a new item should be added\r\n\tQModelIndex index = indexAt(event->pos());\r\n\tif (!index.isValid())\r\n    {\r\n        onAddAction();\r\n\t\tevent->accept();                \r\n\t\treturn;\r\n\t}\r\n\r\n\tQListView::mouseDoubleClickEvent(event);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: EditableListView::mousePressEvent()\r\n//-----------------------------------------------------------------------------\r\nvoid EditableListView::mousePressEvent(QMouseEvent* event)\r\n{\r\n\tpressedPoint_ = event->pos();\r\n\tQListView::mousePressEvent(event);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: EditableListView::mouseReleaseEvent()\r\n//-----------------------------------------------------------------------------\r\nvoid EditableListView::mouseReleaseEvent(QMouseEvent* event)\r\n{\r\n\tsetCursor(QCursor(Qt::ArrowCursor));\r\n\tQListView::mouseReleaseEvent(event);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: EditableListView::contextMenuEvent()\r\n//-----------------------------------------------------------------------------\r\nvoid EditableListView::contextMenuEvent(QContextMenuEvent* event)\r\n{\r\n\tpressedPoint_ = event->pos();\r\n\r\n\tQMenu menu(this);\r\n\tmenu.addAction(&addAction_);\r\n\tmenu.addAction(&removeAction_);\r\n    \r\n    removeAction_.setEnabled(selectionModel()->hasSelection());\r\n\r\n\tmenu.exec(event->globalPos());\r\n\r\n    removeAction_.setEnabled(true);\r\n\tevent->accept();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: EditableListView::rowsInserted()\r\n//-----------------------------------------------------------------------------\r\nvoid EditableListView::rowsInserted(QModelIndex const& parent, int start, int end)\r\n{\r\n    QListView::rowsInserted(parent, start, end);\r\n\r\n    QModelIndex lastIndex = model()->index(end, 0, parent);\r\n    setCurrentIndex(lastIndex);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: EditableListView::onAddAction()\r\n//-----------------------------------------------------------------------------\r\nvoid EditableListView::onAddAction() \r\n{\r\n\tQModelIndex index = indexAt(pressedPoint_);\r\n\temit addItem(index);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: EditableListView::onRemoveAction()\r\n//-----------------------------------------------------------------------------\r\nvoid EditableListView::onRemoveAction()\r\n{\r\n\tQModelIndex index = currentIndex();\r\n\temit removeItem(index);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: EditableListView::setupActions()\r\n//-----------------------------------------------------------------------------\r\nvoid EditableListView::setupActions()\r\n{\r\n    addAction(&addAction_);\r\n    addAction_.setEnabled(true);\r\n    addAction_.setShortcut(QKeySequence::InsertLineSeparator);\r\n    addAction_.setShortcutContext(Qt::WidgetShortcut);\r\n    QString tooltipAdd = tr(\"Add a new item to list (%1)\").arg(addAction_.shortcut().toString(QKeySequence::NativeText));\r\n    addAction_.setToolTip(tooltipAdd);\r\n    addAction_.setStatusTip(tooltipAdd);\r\n    connect(&addAction_, SIGNAL(triggered()), this, SLOT(onAddAction()), Qt::UniqueConnection);\r\n\r\n    addAction(&removeAction_);\r\n    removeAction_.setEnabled(true);\r\n    removeAction_.setShortcut(QKeySequence::Delete);\r\n    removeAction_.setShortcutContext(Qt::WidgetShortcut);\r\n    QString tooltipRemove = tr(\"Remove an item from the list (%1)\").arg(removeAction_.shortcut().toString(QKeySequence::NativeText));\r\n    removeAction_.setToolTip(tooltipRemove);\r\n    removeAction_.setStatusTip(tooltipRemove);\r\n    connect(&removeAction_, SIGNAL(triggered()), this, SLOT(onRemoveAction()), Qt::UniqueConnection);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: EditableListView::currentChanged()\r\n//-----------------------------------------------------------------------------\r\nvoid EditableListView::currentChanged(QModelIndex const& current, QModelIndex const& previous)\r\n{\r\n    QListView::currentChanged(current, previous);\r\n    emit selectionChanged(current);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: editablelistview::keyPressEvent()\r\n//-----------------------------------------------------------------------------\r\nvoid EditableListView::keyPressEvent(QKeyEvent *event)\r\n{\r\n    int rowCount = model()->rowCount();\r\n\r\n    if (currentIndex().row() == 0 && event->key() == Qt::Key_Up)\r\n    {\r\n        setCurrentIndex(model()->index(rowCount - 1, 0));\r\n    }\r\n    else if (currentIndex().row() == rowCount - 1 && event->key() == Qt::Key_Down)\r\n    {\r\n        setCurrentIndex(model()->index(0, 0));\r\n    }\r\n    else\r\n    {\r\n        QListView::keyPressEvent(event);\r\n    }\r\n}\r\n"
  },
  {
    "path": "common/views/EditableListView/editablelistview.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: editablelistview.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Antti Kamppi\r\n// Date: 12.12.2011\r\n//\r\n// Description:\r\n// View-class with add, remove and move operations for lists of items.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef EDITABLELISTVIEW_H\r\n#define EDITABLELISTVIEW_H\r\n\r\n#include <QListView>\r\n#include <QPoint>\r\n#include <QMouseEvent>\r\n#include <QContextMenuEvent>\r\n#include <QAction>\r\n\r\n//-----------------------------------------------------------------------------\r\n//! View-class with add, remove and move operations for lists of items.\r\n//-----------------------------------------------------------------------------\r\nclass EditableListView : public QListView\r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\r\n\t/*!\r\n     *  The constructor.\r\n\t *\r\n\t *    @param [in] parent  The owner of this view.\r\n\t */\r\n\tEditableListView(QWidget *parent);\r\n\t\r\n\t/*!\r\n     *  The destructor.\r\n     */\r\n\tvirtual ~EditableListView();\r\n\r\nsignals:\r\n\r\n    /*!\r\n     *  Emitted when the selection has changed.\r\n     */\r\n    void selectionChanged(QModelIndex const& index);\r\n\r\n\t/*!\r\n     *  A new item should be added to given index.\r\n\t *\r\n\t *    @param [in] index The position where new item should be added at.\r\n     */\r\n\tvoid addItem(QModelIndex const& index);\r\n\r\n\t/*!\r\n     *  An item should be removed from the model.\r\n\t * \r\n\t *    @param [in] index Identifies the item that should be removed.\r\n     */\r\n\tvoid removeItem(QModelIndex const& index);\r\n\r\n\t/*!\r\n     *  Move item to another position.\r\n\t *\r\n\t *    @param [in] originalPos Identifies the item that should be moved.\r\n\t *    @param [in] newPos The new position the item should be moved to.\r\n     */\r\n\tvoid moveItem(QModelIndex const& originalPos, QModelIndex const& newPos);\r\n\r\nprotected:\r\n\r\n    /*!\r\n     *  Handler for paint events.\r\n     *\r\n     *    @param [in] event   The paint event.\r\n     */\r\n    virtual void paintEvent(QPaintEvent *event);\r\n\r\n\t/*!\r\n     *  Handler for mouse move events\r\n     *\r\n     *    @param [in] event   The mouse movement event.\r\n     */\r\n\tvirtual void mouseMoveEvent(QMouseEvent* event);\r\n\r\n\t/*!\r\n     *  Handler for mouse double click events\r\n     *\r\n     *    @param [in] event   The double click event.\r\n     */\r\n\tvirtual void mouseDoubleClickEvent(QMouseEvent* event);\r\n\r\n\t/*!\r\n     *  Handler for mouse press events\r\n     *\r\n     *    @param [in] event   The mouse press event.\r\n     */\r\n\tvirtual void mousePressEvent(QMouseEvent* event);\r\n\r\n\t/*!\r\n     *  Handler for mouse release events\r\n     *\r\n     *    @param [in] event   The mouse release event.\r\n     */\r\n\tvirtual void mouseReleaseEvent(QMouseEvent* event);\r\n\r\n\t/*!\r\n     * Handler for context menu events\r\n     *\r\n     *    @param [in] event   The context menu event.\r\n     */\r\n\tvirtual void contextMenuEvent(QContextMenuEvent* event);\r\n\r\n    /*!\r\n     *  Handler for key press events.\r\n     *\r\n     *    @param [in] event   The key press event.\r\n     */\r\n    virtual void keyPressEvent(QKeyEvent *event);\r\n    \r\n    /*!\r\n     *  Handler for changes in current selection.\r\n     *\r\n     *    @param [in] current     The current model index.\r\n     *    @param [in] previous    The previous model index.\r\n     */\r\n    virtual void currentChanged(const QModelIndex &current, const QModelIndex &previous);\r\n\r\nprotected slots:\r\n\r\n    /*!\r\n     *  Called when new rows have been inserted.\r\n     */\r\n    virtual void rowsInserted(QModelIndex const& parent, int start, int end);\r\n\r\nprivate slots:\r\n\r\n\t/*!\r\n     *  Handler for add action.\r\n     */\r\n\tvoid onAddAction();\r\n\r\n\t/*!\r\n     *  Handler for remove action.\r\n     */\r\n\tvoid onRemoveAction();\r\n\r\nprivate:\r\n\r\n\t//! No copying. No assignment.\r\n\tEditableListView(const EditableListView& other);\r\n\tEditableListView& operator=(const EditableListView& other);\r\n\r\n\t/*!\r\n     *  Set up the actions for the context menu\r\n     */\r\n\tvoid setupActions();\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n\t//! The point where mouse was clicked\r\n\tQPoint pressedPoint_;\r\n\r\n\t//! Action to add new item\r\n\tQAction addAction_;\r\n\r\n\t//! Action to remove item\r\n\tQAction removeAction_;\r\n};\r\n\r\n#endif // EDITABLELISTVIEW_H\r\n"
  },
  {
    "path": "common/views/EditableTableView/editabletableview.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: editabletableview.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Antti Kamppi\r\n// Date: 10.12.2011\r\n//\r\n// Description:\r\n// This view can be used to display contents of a table model and supports adding and removing items.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"editabletableview.h\"\r\n\r\n#include <QAbstractButton>\r\n#include <QAbstractTableModel>\r\n#include <QApplication>\r\n#include <QClipboard>\r\n#include <QFile>\r\n#include <QFileDialog>\r\n#include <QFontMetrics>\r\n#include <QHeaderView>\r\n#include <QKeySequence>\r\n#include <QMenu>\r\n#include <QMessageBox>\r\n#include <QMimeData>\r\n#include <QModelIndexList>\r\n#include <QSize>\r\n#include <QSortFilterProxyModel>\r\n#include <QStylePainter>\r\n#include <QTextStream>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: EditableTableView::EditableTableView()\r\n//-----------------------------------------------------------------------------\r\nEditableTableView::EditableTableView(QWidget *parent):\r\nQTableView(parent),\r\n    pressedPoint_(),\r\n    addAction_(tr(\"Add row\"), this),\r\n    removeAction_(tr(\"Remove row\"), this),\r\n    cutAction_(tr(\"Cut\"), this),\r\n    copyAction_(tr(\"Copy\"), this),\r\n    pasteAction_(tr(\"Paste\"), this),\r\n    clearAction_(tr(\"Clear\"), this),\r\n    importAction_(tr(\"Import csv-file\"), this),\r\n    exportAction_(tr(\"Export csv-file\"), this),\r\n    copyElementAction_(tr(\"Copy element\"), this),\r\n    pasteElementAction_(tr(\"Paste element\"), this),\r\n    importExportEnabled_(false),\r\n    elementCopyIsAllowed_(false),\r\n    defImportExportPath_(),\r\n    itemsDraggable_(true),\r\n    fitColumnsToContent_(true)\r\n{\r\n    horizontalHeader()->setSectionResizeMode(QHeaderView::Interactive);\r\n    horizontalHeader()->setStretchLastSection(true);\r\n\r\n    verticalHeader()->hide();\r\n\r\n    // set the height of a row to be smaller than default\r\n    verticalHeader()->setDefaultSectionSize(fontMetrics().height() + 8);\r\n\r\n    QAbstractButton* cornerButton = findChild<QAbstractButton*>();\r\n    if (cornerButton != 0)\r\n    {\r\n        cornerButton->setText(tr(\"Name\"));\r\n        cornerButton->setToolTip(tr(\"Click to select all\"));\r\n        cornerButton->installEventFilter(this);\r\n    }\r\n\r\n\tsetAlternatingRowColors(true);\r\n\r\n\t// words are wrapped in the cells to minimize space usage\r\n\tsetWordWrap(true);\r\n\r\n\t// user can select several items at a time\r\n\tsetSelectionMode(QAbstractItemView::ContiguousSelection);\r\n\r\n\tsetEditTriggers(QAbstractItemView::DoubleClicked |QAbstractItemView::SelectedClicked |\r\n\t\tQAbstractItemView::EditKeyPressed |\tQAbstractItemView::AnyKeyPressed);\r\n\r\n\tsetToolTip(tr(\"Double click to add a new item.\"));\r\n\t\r\n\tsetupActions();\r\n\r\n\tsetMinimumHeight(MINIMUM_TABLE_HEIGHT);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: EditableTableView::setAllowImportExport()\r\n//-----------------------------------------------------------------------------\r\nvoid EditableTableView::setAllowImportExport(bool allow)\r\n{\r\n    importExportEnabled_ = allow;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: EditableTableView::importExportAllowed()\r\n//-----------------------------------------------------------------------------\r\nbool EditableTableView::importExportAllowed() const\r\n{\r\n    return importExportEnabled_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: editabletableview::setAllowElementCopying()\r\n//-----------------------------------------------------------------------------\r\nvoid EditableTableView::setAllowElementCopying(bool allow)\r\n{\r\n    elementCopyIsAllowed_ = allow;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: EditableTableView::setCornerButtonText()\r\n//-----------------------------------------------------------------------------\r\nvoid EditableTableView::setCornerButtonText(QString const& text)\r\n{\r\n    QAbstractButton* cornerButton = findChild<QAbstractButton*>();\r\n    if (cornerButton != 0)\r\n    {\r\n        cornerButton->setText(text);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: EditableTableView::setFitColumnsToContent()\r\n//-----------------------------------------------------------------------------\r\nvoid EditableTableView::setFitColumnsToContent(bool fit)\r\n{\r\n    fitColumnsToContent_ = fit;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: EditableTableView::mouseMoveEvent()\r\n//-----------------------------------------------------------------------------\r\nvoid EditableTableView::mouseMoveEvent(QMouseEvent* event)\r\n{\r\n    QModelIndex selected = indexAt(event->pos());\r\n\r\n\tif (itemsDraggable_)\r\n    {\r\n\t\t// if left mouse button was pressed \r\n\t\tif (event->buttons() & Qt::LeftButton)\r\n        {\r\n\t\t\tQModelIndex startIndex = indexAt(pressedPoint_);\r\n\t\t\tQModelIndex thisIndex = selected;\r\n\r\n\t\t\t// if the model is a sort proxy then convert the indexes to source indexes\r\n\t\t\tQSortFilterProxyModel* sortProxy = dynamic_cast<QSortFilterProxyModel*>(model());\r\n\t\t\tif (sortProxy)\r\n            {\r\n\t\t\t\tstartIndex = sortProxy->mapToSource(startIndex);\r\n\t\t\t\tthisIndex = sortProxy->mapToSource(thisIndex);\r\n\t\t\t}\r\n\r\n\t\t\t// if the item was dragged to new location\r\n\t\t\tif (startIndex.isValid() && startIndex != thisIndex)\r\n            {\r\n\t\t\t\tsetCursor(QCursor(Qt::ClosedHandCursor));\r\n\t\t\t\temit moveItem(startIndex, thisIndex);\r\n\r\n\t\t\t\t// update the pressed point so the dragging works also when moving further to another index\r\n\t\t\t\tpressedPoint_ = event->pos();\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\tQTableView::mouseMoveEvent(event);\r\n\r\n\t// if item is being dragged then do not select an area\r\n\tif (itemsDraggable_)\r\n    {\r\n\t\tclearSelection();\r\n\t\tsetCurrentIndex(selected);\r\n\t}\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: EditableTableView::mouseDoubleClickEvent()\r\n//-----------------------------------------------------------------------------\r\nvoid EditableTableView::mouseDoubleClickEvent(QMouseEvent* event)\r\n{\r\n\t// if there is no item on the clicked position then a new item should be added\r\n\tQModelIndex index = indexAt(event->pos());\r\n\tif (!index.isValid())\r\n    {\r\n\t\temit addItem(index);\r\n\t\tevent->accept();\r\n\t\treturn;\r\n\t}\r\n\r\n\tQTableView::mouseDoubleClickEvent(event);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: EditableTableView::mousePressEvent()\r\n//-----------------------------------------------------------------------------\r\nvoid EditableTableView::mousePressEvent(QMouseEvent* event)\r\n{\r\n\tpressedPoint_ = event->pos();\r\n\r\n    /*\r\n\t// if user clicked area that has no item\r\n\tQModelIndex pressedIndex = indexAt(pressedPoint_);\r\n\tif (!pressedIndex.isValid())\r\n    {\r\n\t\tsetCurrentIndex(pressedIndex);\r\n\t}\r\n\r\n    */\r\n\tQTableView::mousePressEvent(event);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: EditableTableView::mouseReleaseEvent()\r\n//-----------------------------------------------------------------------------\r\nvoid EditableTableView::mouseReleaseEvent(QMouseEvent* event)\r\n{\r\n\tsetCursor(QCursor(Qt::ArrowCursor));\r\n\tQTableView::mouseReleaseEvent(event);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: EditableTableView::contextMenuEvent()\r\n//-----------------------------------------------------------------------------\r\nvoid EditableTableView::contextMenuEvent(QContextMenuEvent* event)\r\n{\r\n\tpressedPoint_ = event->pos();\r\n\r\n\tQModelIndex index = indexAt(pressedPoint_);\r\n\r\n\tQMenu menu(this);\r\n    addBasicActionsForContextMenu(menu, index);\r\n    addElementCopyActionForContextMenu(menu, index);\r\n    addImportExportActionsForContextMenu(menu);\r\n\r\n\tmenu.exec(event->globalPos());\r\n\r\n\tevent->accept();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: editabletableview::addBasicActionsForContextMenu()\r\n//-----------------------------------------------------------------------------\r\nvoid EditableTableView::addBasicActionsForContextMenu(QMenu& menu, QModelIndex const& index)\r\n{\r\n    menu.addAction(&addAction_);\r\n\r\n    if (index.isValid())\r\n    {\r\n        menu.addAction(&removeAction_);\r\n        menu.addAction(&clearAction_);\r\n        menu.addAction(&cutAction_);\r\n        menu.addAction(&copyAction_);\r\n        menu.addAction(&pasteAction_);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: editabletableview::addElementCopyActionForContextMenu()\r\n//-----------------------------------------------------------------------------\r\nvoid EditableTableView::addElementCopyActionForContextMenu(QMenu& menu, QModelIndex const& index)\r\n{\r\n    bool validIndex = index.isValid();\r\n\r\n    if (elementCopyIsAllowed_)\r\n    {\r\n        const QMimeData* clipMimeData = QApplication::clipboard()->mimeData();\r\n        QString modelAcceptedMimeType = model()->mimeTypes().last();\r\n\r\n        bool containsMimeData = (clipMimeData->hasImage() && clipMimeData->hasFormat(modelAcceptedMimeType));\r\n\r\n        if (validIndex || containsMimeData)\r\n        {\r\n            menu.addSeparator();\r\n            if (validIndex)\r\n            {\r\n                menu.addAction(&copyElementAction_);\r\n            }\r\n            if (containsMimeData)\r\n            {\r\n                menu.addAction(&pasteElementAction_);\r\n            }\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: editabletableview::addImportExportActionsForContextMenu()\r\n//-----------------------------------------------------------------------------\r\nvoid EditableTableView::addImportExportActionsForContextMenu(QMenu& menu)\r\n{\r\n    if (importExportAllowed())\r\n    {\r\n        menu.addSeparator();\r\n        menu.addAction(&importAction_);\r\n        menu.addAction(&exportAction_);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: EditableTableView::eventFilter()\r\n//-----------------------------------------------------------------------------\r\nbool EditableTableView::eventFilter(QObject* target, QEvent* event)\r\n{\r\n    if (event->type() == QEvent::Paint)\r\n    {\r\n        QAbstractButton* cornerButton = qobject_cast<QAbstractButton*>(target);\r\n        if (cornerButton)\r\n        {\r\n            // paint by hand (borrowed from QTableCornerButton)\r\n            QStyleOptionHeader opt;\r\n            opt.initFrom(cornerButton);\r\n\r\n            QStyle::State styleState = QStyle::State_None;\r\n\r\n            if (cornerButton->isEnabled())\r\n            {\r\n                styleState |= QStyle::State_Enabled;\r\n            }\r\n            if (cornerButton->isActiveWindow())\r\n            {\r\n                styleState |= QStyle::State_Active;\r\n            }\r\n            if (cornerButton->isDown())\r\n            {\r\n                styleState |= QStyle::State_Sunken;\r\n            }\r\n\r\n            opt.state = styleState;\r\n            opt.rect = cornerButton->rect();\r\n            opt.text = cornerButton->text();\r\n            opt.textAlignment = Qt::AlignCenter;\r\n            opt.fontMetrics = horizontalHeader()->fontMetrics();\r\n            opt.position = QStyleOptionHeader::OnlyOneSection;\r\n\r\n            QStylePainter painter(cornerButton);\r\n            painter.drawControl(QStyle::CE_Header, opt);\r\n            return true;\r\n        }\r\n    }\r\n\r\n    return false;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: EditableTableView::onAddAction()\r\n//-----------------------------------------------------------------------------\r\nvoid EditableTableView::onAddAction()\r\n{\r\n\tQModelIndexList indexes = selectedIndexes();\r\n\tQModelIndex posToAdd;\r\n\r\n    QSortFilterProxyModel* sortProxy = dynamic_cast<QSortFilterProxyModel*>(model());\r\n\r\n\tif (!indexes.isEmpty())\r\n    {\r\n\t\tstd::sort(indexes.begin(), indexes.end());\r\n\t\tposToAdd = indexes.first();\r\n\r\n\t\tif (sortProxy)\r\n        {\r\n\t\t\tposToAdd = sortProxy->mapToSource(posToAdd);\r\n\t\t}\r\n\t}\r\n    \r\n    int rowsToAdd = qMax(1, countRows(indexes));\r\n\tfor (int i = 0; i < rowsToAdd; ++i)\r\n    {\r\n\t\temit addItem(posToAdd);\r\n\t}\r\n   \r\n    QModelIndex firstCreatedIndex;\r\n    int nameColumn = NAME_COLUMN;\r\n    if (posToAdd.isValid() && (posToAdd.sibling(posToAdd.row(), NAME_COLUMN).flags() & Qt::ItemIsEditable) == 0)\r\n    {\r\n        nameColumn++;\r\n    }\r\n\r\n    if (posToAdd.isValid())\r\n    {\r\n        firstCreatedIndex = posToAdd.sibling(posToAdd.row(), nameColumn); \r\n        if (sortProxy)\r\n        {\r\n            firstCreatedIndex = sortProxy->mapFromSource(firstCreatedIndex);\r\n        }\r\n    }\r\n    else\r\n    {\r\n        firstCreatedIndex = model()->index(model()->rowCount() - 1, nameColumn);\r\n        if (sortProxy)\r\n        {\r\n            QModelIndex indexOnLastRow = sortProxy->sourceModel()->index(model()->rowCount() - 1, nameColumn);\r\n            firstCreatedIndex = sortProxy->mapFromSource(indexOnLastRow);\r\n        }\r\n    }\r\n\r\n    clearSelection();\r\n    setCurrentIndex(firstCreatedIndex);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: EditableTableView::onRemoveAction()\r\n//-----------------------------------------------------------------------------\r\nvoid EditableTableView::onRemoveAction()\r\n{\r\n    QModelIndexList indexes = selectedIndexes();\r\n    if (indexes.isEmpty())\r\n    {\r\n        return;\r\n    }\r\n\r\n    QApplication::setOverrideCursor(Qt::WaitCursor);\r\n\r\n    // Remove selected rows. Removal starts from the back of the selected indexes to remove correct rows.\r\n    // Sorting model apparently returns indexes in correct order when selectedIndexes() is called, which makes \r\n    // reverse removal possible.\r\n    auto sortProxy = dynamic_cast<QSortFilterProxyModel*>(model());\r\n    for (auto it = indexes.crbegin(); it != indexes.crend(); ++it)\r\n    {\r\n        if (sortProxy)\r\n        {\r\n            emit removeItem(sortProxy->mapToSource(*it));\r\n        }\r\n        else\r\n        {\r\n            emit removeItem(*it);\r\n        }\r\n    }\r\n    \r\n    clearSelection();\r\n    setCurrentIndex(QModelIndex());\r\n\r\n    QApplication::restoreOverrideCursor();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: editabletableview::onCutAction()\r\n//-----------------------------------------------------------------------------\r\nvoid EditableTableView::onCutAction()\r\n{\r\n    QModelIndexList indexes = selectedIndexes();\r\n    if (indexes.isEmpty())\r\n    {\r\n        return;\r\n    }\r\n\r\n    QApplication::setOverrideCursor(Qt::WaitCursor);\r\n\r\n    std::sort(indexes.begin(), indexes.end());\r\n    int lastColumn = indexes.last().column();\r\n\r\n    QString copyText;\r\n\r\n    for (QModelIndex const& index : indexes)\r\n    {\r\n        copyText.append(index.data(Qt::EditRole).toString());\r\n\r\n        model()->setData(index, QVariant(), Qt::EditRole);\r\n\r\n        if (index.column() < lastColumn)\r\n        {\r\n            copyText.append(\"\\t\");\r\n        }\r\n        else\r\n        {\r\n            copyText.append(\"\\n\");\r\n        }\r\n    }\r\n\r\n    QApplication::clipboard()->setText(copyText);\r\n    QApplication::restoreOverrideCursor();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: EditableTableView::setItemsDraggable()\r\n//-----------------------------------------------------------------------------\r\nvoid EditableTableView::setItemsDraggable(bool draggable)\r\n{\r\n\titemsDraggable_ = draggable;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: EditableTableView::onCopyAction()\r\n//-----------------------------------------------------------------------------\r\nvoid EditableTableView::onCopyAction()\r\n{\r\n\t// if nothing was selected then don't copy anything\r\n\tif (!currentIndex().isValid())\r\n    {\r\n\t\treturn;\r\n\t}\r\n\r\n\tQApplication::setOverrideCursor(Qt::WaitCursor);\r\n\r\n\tQModelIndexList indexes = selectedIndexes();\r\n    std::sort(indexes.begin(), indexes.end());\r\n\r\n    int lastColumn = indexes.last().column();\r\n    \r\n    QString copyText;\r\n    for (QModelIndex const& sourceIndex : indexes)\r\n    {\r\n        copyText.append(sourceIndex.data(Qt::EditRole).toString());\r\n\r\n        if (sourceIndex.column() < lastColumn)\r\n        {\r\n            copyText.append(\"\\t\");\r\n        }\r\n        else\r\n        {\r\n            copyText.append(\"\\n\");\r\n        }\r\n    }\r\n\t\r\n\tQApplication::clipboard()->setText(copyText);\r\n\tQApplication::restoreOverrideCursor();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: EditableTableView::onPasteAction()\r\n//-----------------------------------------------------------------------------\r\nvoid EditableTableView::onPasteAction()\r\n{\r\n\tQApplication::setOverrideCursor(Qt::WaitCursor);\r\n\r\n\t// find the highest row to start adding to\r\n\tQModelIndexList indexes = selectedIndexes();\r\n\tQModelIndex posToPaste;\r\n\tif (!indexes.isEmpty())\r\n    {\r\n        std::sort(indexes.begin(), indexes.end());\r\n\t\tposToPaste = indexes.first();\r\n\t}\r\n\r\n\tint targetRow = posToPaste.row();\r\n\tint startColumn = posToPaste.column();\r\n    \r\n    QString textType = QStringLiteral(\"plain\");\r\n    QString pasteText = QApplication::clipboard()->text(textType);\r\n\r\n\t// Split the string from clip board into rows.\r\n\tQStringList rowsToAdd = pasteText.split(\"\\n\", Qt::SkipEmptyParts);\r\n\r\n    bool useDynamicSorting = false;\r\n    QSortFilterProxyModel* proxyModel = qobject_cast<QSortFilterProxyModel*>(model());\r\n    if (proxyModel)\r\n    {\r\n        useDynamicSorting = proxyModel->dynamicSortFilter();\r\n        proxyModel->setDynamicSortFilter(false);\r\n    }\r\n\r\n\tfor (QString const& row : rowsToAdd)\r\n    {\r\n\t\t// New row starts always on same column.\r\n\t\tint targetColumn = qMax(0, startColumn);\r\n\r\n\t\t// Split the row into columns.\r\n\t\tQStringList columnsToAdd = row.split(\"\\t\");\r\n\t\tfor (QString column : columnsToAdd)\r\n        {\r\n\t\t\tQModelIndex itemToSet = model()->index(targetRow, targetColumn, QModelIndex());\r\n\t\t\tif (itemToSet.isValid())\r\n            {\r\n                // Check for name conflicts.   \r\n                if (targetColumn == NAME_COLUMN && column.size() > 0)\r\n                {\r\n                    column = getUniqueName(column);\r\n                }\r\n\r\n                model()->setData(itemToSet, column, Qt::EditRole);\r\n\t\t\t}\r\n\r\n\t\t\ttargetColumn++;\r\n\t\t}\r\n\t\t\r\n\t\tif (targetRow >= 0)\r\n        {\r\n\t\t\ttargetRow++;\r\n\t\t}\r\n\t}\r\n\r\n    if (proxyModel)\r\n    {\r\n        proxyModel->setDynamicSortFilter(useDynamicSorting);\r\n    }\r\n\r\n\tQApplication::restoreOverrideCursor();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: editabletableview::onCopyElementAction()\r\n//-----------------------------------------------------------------------------\r\nvoid EditableTableView::onCopyElementAction()\r\n{\r\n    // if nothing was selected then don't copy anything\r\n    if (!currentIndex().isValid())\r\n    {\r\n        return;\r\n    }\r\n\r\n    QApplication::setOverrideCursor(Qt::WaitCursor);\r\n\r\n    QModelIndexList indexList = selectedIndexes();\r\n    std::sort(indexList.begin(), indexList.end());\r\n\r\n    QSortFilterProxyModel* sortProxy = dynamic_cast<QSortFilterProxyModel*>(model());\r\n\r\n    QVector<int> usedRows;\r\n\r\n    QModelIndexList singleRowIndexList;\r\n    for (int i = 0; i < indexList.size(); i++)\r\n    {\r\n        QModelIndex index = indexList.at(i);\r\n\r\n        if (sortProxy != 0)\r\n        {\r\n            index = sortProxy->mapToSource(index);\r\n        }\r\n\r\n        if (!usedRows.contains(index.row()))\r\n        {\r\n            usedRows.append(index.row());\r\n            singleRowIndexList.append(index);\r\n        }\r\n    }\r\n\r\n    emit copyRows(singleRowIndexList);\r\n\r\n    QApplication::restoreOverrideCursor();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: EditableTableView::onClearAction()\r\n//-----------------------------------------------------------------------------\r\nvoid EditableTableView::onClearAction()\r\n{\t\r\n\tQModelIndexList indexes = selectedIndexes();\r\n\r\n\t// clear the contents of each cell\r\n\tfor (QModelIndex const& index : indexes)\r\n    {\r\n\t\tmodel()->setData(index, QVariant(), Qt::EditRole);\r\n\t}\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: EditableTableView::onCSVExport()\r\n//-----------------------------------------------------------------------------\r\nvoid EditableTableView::onCSVExport(const QString& filePath)\r\n{\r\n\tQString target(filePath);\r\n\r\n\tif (filePath.isEmpty())\r\n    {\r\n\t\ttarget = QFileDialog::getSaveFileName(this, tr(\"Set name and location for csv-file\"),\r\n\t\t\tdefImportExportPath_, tr(\"csv-files (*.csv)\"));\r\n\t}\r\n\r\n\tif (target.isEmpty())\r\n    {\r\n\t\treturn;\r\n\t}\r\n\r\n\tQFile file(target);\r\n\r\n\t// if file can not be opened \r\n\tif (!file.open(QIODevice::Truncate | QIODevice::WriteOnly))\r\n    {\r\n\t\tQMessageBox::critical(this, tr(\"Error opening file\"), tr(\"Could not open file %1 for writing\").arg(target));\r\n\t\treturn;\r\n\t}\r\n\r\n\tQApplication::setOverrideCursor(Qt::WaitCursor);\r\n\r\n\tint columnCount = model()->columnCount(QModelIndex());\r\n\tint rowCount = model()->rowCount(QModelIndex());\r\n\r\n\t// create a stream to write into\r\n\tQTextStream stream(&file);\r\n\r\n\t// write the headers\r\n\tfor (int i = 0; i < columnCount; i++)\r\n    {\r\n\t\tstream << model()->headerData(i, Qt::Horizontal, Qt::DisplayRole).toString().simplified() << \";\";\r\n\t}\r\n\tstream << Qt::endl;\r\n\r\n\t// write each row\r\n\tfor (int row = 0; row < rowCount; row++)\r\n    {\t\r\n\t\t// write each column\r\n\t\tfor (int column = 0; column < columnCount; column++)\r\n        {\r\n\t\t\tQModelIndex index = model()->index(row, column, QModelIndex());\r\n            QString data = index.data(Qt::EditRole).toString();\r\n\r\n            if (data.isEmpty())\r\n            {\r\n                data = index.data(Qt::DisplayRole).toString();\r\n            }\r\n\r\n            bool multiline = data.contains(QStringLiteral(\"\\n\"));\r\n            if (multiline)\r\n            {\r\n                stream << \"\\\"\" << data << \"\\\"\" << \";\";\r\n            }\r\n            else\r\n            {\r\n                stream << data << \";\";\r\n            }\r\n\t\t\t\r\n\t\t}\r\n\t\tstream << Qt::endl;\r\n\t}\r\n\tfile.close();\r\n\r\n\tQApplication::restoreOverrideCursor();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: EditableTableView::onCSVImport()\r\n//-----------------------------------------------------------------------------\r\nvoid EditableTableView::onCSVImport(const QString& filePath)\r\n{\r\n\tQString target(filePath);\r\n\t\r\n\tif (filePath.isEmpty())\r\n    {\r\n\t\ttarget = QFileDialog::getOpenFileName(this, tr(\"Open file\"), defImportExportPath_, tr(\"csv-files (*.csv)\"));\r\n\t}\r\n\r\n\tif (target.isEmpty())\r\n    {\r\n\t\treturn;\r\n\t}\r\n\t\r\n\tQFile file(target);\r\n\r\n\t// if file can not be opened \r\n\tif (!file.open(QIODevice::ReadOnly | QIODevice::Text))\r\n    {\r\n\t\tQMessageBox::critical(this, tr(\"Error opening file\"), tr(\"Could not open file %1 for reading\").arg(target));\r\n\t\treturn;\r\n\t}\r\n\r\n\tQApplication::setOverrideCursor(Qt::WaitCursor);\r\n\r\n\t// create a stream to read from\r\n\tQTextStream stream(&file);\r\n\r\n\t// read the headers from the file\r\n\tQString headers = stream.readLine();\r\n\r\n    // the model containing the actual data\r\n\tQAbstractTableModel* targetModel = NULL;\r\n\tQSortFilterProxyModel* proxyModel = qobject_cast<QSortFilterProxyModel*>(model());\r\n\t\r\n\t// if view is connected to proxy model\r\n\tif (proxyModel)\r\n    {\r\n\t\ttargetModel = qobject_cast<QAbstractTableModel*>(proxyModel->sourceModel());\r\n\t}\r\n\t// if view is connected directly to actual model\r\n\telse\r\n    {\r\n\t\ttargetModel = qobject_cast<QAbstractTableModel*>(model());\r\n\t}\r\n\tQ_ASSERT(targetModel);\r\n\r\n\tint columnCount = targetModel->columnCount(QModelIndex());\r\n    QList<QStringList> rowsToBeAdded;\r\n\r\n    // Validate csv first\r\n    while (!stream.atEnd())\r\n    {\r\n        QString line = stream.readLine();\r\n        QStringList items = line.split(\";\");\r\n\r\n        if (items.size() != columnCount)\r\n        {\r\n            QMessageBox::critical(this, tr(\"Error importing file\"), tr(\"Could not import '%1': invalid formatting\").arg(target));\r\n            file.close();\r\n            QApplication::restoreOverrideCursor();\r\n            return;\r\n        }\r\n\r\n        rowsToBeAdded.append(items);\r\n    }\r\n    \r\n    // Add data if csv was valid\r\n    for (auto const& row : rowsToBeAdded)\r\n    {\r\n        emit addItem(QModelIndex());\r\n        int rowCount = targetModel->rowCount(QModelIndex());\r\n\r\n        for (int column = 0; column < columnCount; ++column)\r\n        {\r\n            QString item = row.at(column);\r\n            if (item.startsWith(QLatin1Char('\"')) && item.endsWith(QLatin1Char('\"')))\r\n            {\r\n                item = item.mid(1, item.length() - 2);\r\n            }\r\n\r\n            QModelIndex index = targetModel->index(rowCount - 1, column, QModelIndex());\r\n            targetModel->setData(index, item, Qt::EditRole);\r\n        }\r\n    }\r\n\r\n\tfile.close();\r\n\r\n\tQApplication::restoreOverrideCursor();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: EditableTableView::setDefaultImportExportPath()\r\n//-----------------------------------------------------------------------------\r\nvoid EditableTableView::setDefaultImportExportPath(const QString& path)\r\n{\r\n\tdefImportExportPath_ = path;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: EditableTableView::setModel()\r\n//-----------------------------------------------------------------------------\r\nvoid EditableTableView::setModel(QAbstractItemModel* model)\r\n{\r\n\t// the base class implementation does most of the work\r\n\tQTableView::setModel(model);\r\n\r\n\t// contains info on the used font\r\n\tQFontMetrics fMetrics = fontMetrics();\r\n\r\n\t// set the widths for the columns\r\n\tint columnCount = model->columnCount(QModelIndex());\r\n\tfor (int i = 0; i < columnCount; ++i)\r\n    {\r\n\t\t// the width required by the contents of the model\r\n\t\tint contentSize = 0;\r\n        if (fitColumnsToContent_)\r\n        {\r\n            contentSize = sizeHintForColumn(i);\r\n        }\r\n\r\n\t\t// get the header for the section\r\n\t\tQString headerText = model->headerData(i, Qt::Horizontal, Qt::DisplayRole).toString();\r\n\t\t// if the header contains several lines\r\n\t\tQStringList headerLines = headerText.split(\"\\n\", Qt::SkipEmptyParts);\r\n\t\tint headerSize = 0;\r\n\r\n\t\t// find the line that needs most space\r\n\t\tfor (QString const& headerLine : headerLines)\r\n        {\r\n\t\t\theaderSize = qMax(headerSize, fMetrics.horizontalAdvance(headerLine));\r\n\t\t}\r\n        headerSize += 45;\r\n\r\n        // set the width for the column\r\n        setColumnWidth(i, qMax(contentSize, headerSize));\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: EditableTableView::setupActions()\r\n//-----------------------------------------------------------------------------\r\nvoid EditableTableView::setupActions()\r\n{\r\n    QList<QKeySequence> addRowShortcuts{\r\n    QKeySequence::InsertLineSeparator,\r\n    QKeySequence(Qt::SHIFT | Qt::Key_Return)\r\n    };\r\n\r\n    addAction(&addAction_);\r\n    addAction_.setShortcuts(addRowShortcuts);\r\n    addAction_.setShortcutContext(Qt::WidgetShortcut);\r\n    QString tooltipAddRow = tr(\"Add a new row to table (Shortcuts: %1, %2)\")\r\n        .arg(addAction_.shortcuts().at(0).toString(QKeySequence::NativeText))\r\n        .arg(addAction_.shortcuts().at(1).toString(QKeySequence::NativeText));\r\n    addAction_.setToolTip(tooltipAddRow);\r\n    addAction_.setStatusTip(tooltipAddRow);\r\n    connect(&addAction_, SIGNAL(triggered()), this, SLOT(onAddAction()), Qt::UniqueConnection);\r\n\r\n    addAction(&removeAction_);\r\n    removeAction_.setShortcut(Qt::SHIFT | Qt::Key_Delete);\r\n    removeAction_.setShortcutContext(Qt::WidgetShortcut);\r\n    QString tooltipRemoveRow = tr(\"Remove a row from the table (%1)\")\r\n        .arg(removeAction_.shortcut().toString(QKeySequence::NativeText));\r\n    removeAction_.setToolTip(tooltipRemoveRow);\r\n    removeAction_.setStatusTip(tooltipRemoveRow);\r\n    connect(&removeAction_, SIGNAL(triggered()), this, SLOT(onRemoveAction()), Qt::UniqueConnection);\r\n\r\n    addAction(&cutAction_);\r\n    cutAction_.setShortcut(QKeySequence::Cut);\r\n    cutAction_.setShortcutContext(Qt::WidgetShortcut);\r\n    QString tooltipCut = tr(\"Cut the contents of a cell from the table (%1)\")\r\n        .arg(cutAction_.shortcut().toString(QKeySequence::NativeText));\r\n    cutAction_.setToolTip(tooltipCut);\r\n    cutAction_.setStatusTip(tooltipCut);\r\n    connect(&cutAction_, SIGNAL(triggered()), this, SLOT(onCutAction()), Qt::UniqueConnection);\r\n\r\n    addAction(&copyAction_);\r\n    copyAction_.setShortcut(QKeySequence::Copy);\r\n    copyAction_.setShortcutContext(Qt::WidgetShortcut);\r\n    QString tooltipCopy = tr(\"Copy the contents of a cell from the table (%1)\")\r\n        .arg(copyAction_.shortcut().toString(QKeySequence::NativeText));\r\n    copyAction_.setToolTip(tooltipCopy);\r\n    copyAction_.setStatusTip(tooltipCopy);\r\n    connect(&copyAction_, SIGNAL(triggered()), this, SLOT(onCopyAction()), Qt::UniqueConnection);\r\n\r\n    addAction(&pasteAction_);\r\n    pasteAction_.setShortcut(QKeySequence::Paste);\r\n    pasteAction_.setShortcutContext(Qt::WidgetShortcut);\r\n    QString tooltipPaste = tr(\"Paste the contents of a cell to the table (%1)\")\r\n        .arg(pasteAction_.shortcut().toString(QKeySequence::NativeText));\r\n    pasteAction_.setToolTip(tooltipPaste);\r\n    pasteAction_.setStatusTip(tooltipPaste);\r\n    connect(&pasteAction_, SIGNAL(triggered()), this, SLOT(onPasteAction()), Qt::UniqueConnection);\r\n\r\n    addAction(&clearAction_);\r\n    clearAction_.setShortcut(QKeySequence::Delete);\r\n    clearAction_.setShortcutContext(Qt::WidgetShortcut);\r\n    QString tooltipClear = tr(\"Clear the contents of a cell (%1)\")\r\n        .arg(clearAction_.shortcut().toString(QKeySequence::NativeText));\r\n    clearAction_.setToolTip(tooltipClear);\r\n    clearAction_.setStatusTip(tooltipClear);\r\n    connect(&clearAction_, SIGNAL(triggered()), this, SLOT(onClearAction()), Qt::UniqueConnection);\r\n\r\n    addAction(&importAction_);\r\n    importAction_.setToolTip(tr(\"Import a csv-file to table\"));\r\n    importAction_.setStatusTip(tr(\"Import a csv-file to table\"));    \r\n    connect(&importAction_, SIGNAL(triggered()), this, SLOT(onCSVImport()), Qt::UniqueConnection);\r\n\r\n    addAction(&exportAction_);\r\n    exportAction_.setToolTip(tr(\"Export table to a csv-file\"));\r\n    exportAction_.setStatusTip(tr(\"Export table to a csv-file\"));\r\n    connect(&exportAction_, SIGNAL(triggered()), this, SLOT(onCSVExport()), Qt::UniqueConnection);\r\n\r\n    addAction(&copyElementAction_);\r\n    copyElementAction_.setToolTip(tr(\"Copy a row from the table\"));\r\n    copyElementAction_.setStatusTip(tr(\"Copy a row from the table\"));\r\n    connect(&copyElementAction_, SIGNAL(triggered()), this, SLOT(onCopyElementAction()), Qt::UniqueConnection);\r\n\r\n    addAction(&pasteElementAction_);\r\n    pasteElementAction_.setToolTip(tr(\"Paste a row from the table\"));\r\n    pasteElementAction_.setStatusTip(tr(\"Paste a row from the table\"));\r\n    connect(&pasteElementAction_, SIGNAL(triggered()), this, SIGNAL(pasteRows()), Qt::UniqueConnection);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: EditableTableView::countRows()\r\n//-----------------------------------------------------------------------------\r\nint EditableTableView::countRows(QModelIndexList const& indexes)\r\n{\r\n    if (indexes.empty())\r\n    {\r\n        return 0;\r\n    }\r\n\r\n    int rows = 1;\r\n\r\n    int previousRow = indexes.first().row();\r\n    for (QModelIndex const& index : indexes)\r\n    {\r\n        if (index.row() != previousRow)\r\n        {\r\n            rows++;\r\n        }\r\n\r\n        previousRow = index.row();\r\n    }\r\n\r\n    return rows;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: EditableTableView::getUniqueName()\r\n//-----------------------------------------------------------------------------\r\nQString EditableTableView::getUniqueName(QString const& original)\r\n{\r\n    int rowCount = model()->rowCount();\r\n\r\n    QString name = original;    \r\n    int trailingNumber = 1;\r\n    \r\n    bool match =  true;\r\n    while (match)\r\n    {\r\n        match = false;        \r\n        for(int row = 0; row < rowCount; row++)\r\n        {\r\n            QModelIndex index = model()->index(row, NAME_COLUMN);\r\n            if (name == index.data(Qt::DisplayRole).toString())\r\n            {\r\n                match = true;\r\n                name = original + \"_\" + QString::number(trailingNumber);\r\n                trailingNumber++;\r\n            }\r\n        }       \r\n    }\r\n    \r\n    return name;\r\n}\r\n"
  },
  {
    "path": "common/views/EditableTableView/editabletableview.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: editabletableview.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Antti Kamppi\r\n// Date: 10.12.2011\r\n//\r\n// Description:\r\n// This view can be used to display contents of a table model and supports adding and removing items.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef EDITABLETABLEVIEW_H\r\n#define EDITABLETABLEVIEW_H\r\n\r\n#include <QTableView>\r\n#include <QMouseEvent>\r\n#include <QPoint>\r\n#include <QAction>\r\n#include <QKeyEvent>\r\n#include <QContextMenuEvent>\r\n#include <QDragEnterEvent>\r\n#include <QDropEvent>\r\n\r\n//-----------------------------------------------------------------------------\r\n//! This view can be used to display contents of a table model and supports adding and removing items.\r\n//-----------------------------------------------------------------------------\r\nclass EditableTableView : public QTableView\r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\r\n\t//! The minimum height for the view.\r\n\tstatic const int MINIMUM_TABLE_HEIGHT = 100;\r\n\r\n    //! Number of the column for name.\r\n    static const int NAME_COLUMN = 0; \r\n\r\n\t/*!\r\n     *  The constructor.\r\n\t *\r\n     *    @param [in] parent  Pointer to the owner of this view.\r\n\t */\r\n\tEditableTableView(QWidget *parent);\r\n\t\r\n\t/*!\r\n     *  The destructor.\r\n     */\r\n\tvirtual ~EditableTableView() = default;\r\n\r\n\t/*!\r\n     *  Enable/disable the import/export csv file functionality.\r\n\t *\r\n\t *    @param [in] allow   If true then import/export is enabled.\r\n\t */\r\n\tvirtual void setAllowImportExport(bool allow);\r\n\r\n    /*!\r\n     *  Checks if import and export are allowed in the table.\r\n     *\r\n     *    @return True, if import and export are allowed, otherwise false.\r\n     */\r\n    bool importExportAllowed() const;\r\n\r\n    /*!\r\n     *  Enable / disable the element copying.\r\n     *\r\n     *    @param [in] allow   If true, element copying is allowed.\r\n     */\r\n    void setAllowElementCopying(bool allow);\r\n\r\n\t/*!\r\n     *  Set the model class for this view.\t \r\n\t *\r\n\t *    @param [in] model The model displayed by this view.\r\n\t */\r\n\tvirtual void setModel(QAbstractItemModel* model);\r\n\r\n    /*!\r\n     *  Sets the text visible in the corner button. Both headers must be visible for the text to show.\r\n     *\r\n     *    @param [in] text   The text to set.\r\n     */\r\n    void setCornerButtonText(QString const& text);\r\n\r\n    /*!\r\n    *  Sets if the column sizes are fit to content at model load.\r\n    *\r\n    *    @param [in] fit   To fit or not.\r\n    */\r\n    void setFitColumnsToContent(bool fit);\r\n\r\npublic slots:\r\n\r\n\t/*!\r\n     *  Set the items in the view to be draggable or not.\r\n\t *\r\n\t *    @param [in] draggable   If true the positions of the items can change by dragging.\r\n     */\r\n\tvoid setItemsDraggable(bool draggable);\r\n\r\n\t/*!\r\n     *  Create a csv-file of the editor contents.\r\n\t *\r\n\t *    @param [in] filePath    Contains an absolute file path to the file to create.\r\n\t */\r\n\tvoid onCSVExport(const QString& filePath = QString());\r\n\r\n\t/*!\r\n     *  Import contents of a csv-file to the editor.\r\n\t *\r\n\t *    @param [in] filePath    The path to the csv-file to import.\r\n\t */\r\n\tvoid onCSVImport(const QString& filePath = QString());\r\n\r\n\t/*!\r\n     *  Set the default path to use for import/export csv.\r\n\t *\r\n\t *    @param [in]  path   The path to use as default.\r\n\t */\r\n\tvirtual void setDefaultImportExportPath(const QString& path);\r\n\r\nsignals:\r\n\r\n\t/*!\r\n     *  A new item should be added to given index.\r\n\t *\r\n\t *    @param [in] index   The position where new item should be added at.\r\n\t */\r\n\tvoid addItem(const QModelIndex& index);\r\n\r\n\t/*!\r\n     *  An item should be removed from the model.\r\n\t * \r\n\t *  @param [in] index   Identifies the item that should be removed.\r\n\t */\r\n\tvoid removeItem(const QModelIndex& index);\r\n\r\n\t/*!\r\n     *  Move item to another position.\r\n\t *\r\n\t *    @param [in] originalPos     Identifies the item that should be moved.\r\n\t *    @param [in] newPos          The new position the item should be moved to.\r\n\t */\r\n\tvoid moveItem(const QModelIndex& originalPos, const QModelIndex& newPos);\r\n\r\n    /*!\r\n     *  Copy the selected rows.\r\n     *\r\n     *    @param [in] indexList   List of selected indexes containing the copied rows.\r\n     */\r\n    void copyRows(QModelIndexList indexList);\r\n\r\n    /*!\r\n     *  Paste the copied rows.\r\n     */\r\n    void pasteRows();\r\n\r\nprotected:\r\n\r\n\t//! Handler for mouse move events\r\n\tvirtual void mouseMoveEvent(QMouseEvent* e);\r\n\r\n\t//! Handler for mouse double click events\r\n\tvirtual void mouseDoubleClickEvent(QMouseEvent* event);\r\n\r\n\t//! Handler for mouse press events\r\n\tvirtual void mousePressEvent(QMouseEvent* event);\r\n\r\n\t//! Handler for mouse release events\r\n\tvirtual void mouseReleaseEvent(QMouseEvent* event);\r\n\r\n\t//! Handler for context menu events\r\n\tvirtual void contextMenuEvent(QContextMenuEvent* event);\r\n    \r\n    /*!\r\n     *  Adds basic actions for the context menu (add, remove, clear, cut, copy, paste).\r\n     *\r\n     *    @param [in] menu    Menu containing the actions.\r\n     *    @param [in] index   Index of the item at the context menu event position.\r\n     */\r\n    void addBasicActionsForContextMenu(QMenu& menu, QModelIndex const& index);\r\n\r\n    /*!\r\n     *  Add actions for copying and pasting elements to the context menu.\r\n     *\r\n     *    @param [in] menu    Menu containing the actions.\r\n     *    @param [in] index   Index of the item at the context menu event position.\r\n     */\r\n    void addElementCopyActionForContextMenu(QMenu& menu, QModelIndex const& index);\r\n\r\n    /*!\r\n     *  Add actions for importing and exporting to the context menu.\r\n     *\r\n     *    @param [in] menu    Menu containing the actions.\r\n     */\r\n    void addImportExportActionsForContextMenu(QMenu& menu);\r\n\r\n    /*!\r\n     *  Counts the number of rows in a list of indexes.\r\n     *\r\n     *    @param [in] indexes   The indexes to count.\r\n     *\r\n     *    @return The number of rows in the indexes.\r\n     */\r\n    int countRows(QModelIndexList const& indexes);\r\n\r\n    /*!\r\n     *  Handler for intercepting events.\r\n     *\r\n     *    @param [in] target   The target for the event.\r\n     *    @param [in] event    The event to intercept or pass to target.\r\n     *\r\n     *    @return True, if the event is filtered and not passed to target, otherwise false.\r\n     */\r\n    virtual bool eventFilter(QObject* target, QEvent* event);\r\n\r\n\t//! The point where mouse was clicked\r\n\tQPoint pressedPoint_;\r\n\r\n\t//! Action to add new item\r\n\tQAction addAction_;\r\n\r\n\t//! Action to remove item\r\n\tQAction removeAction_;\r\n\r\n    //! Action to cut item\r\n    QAction cutAction_;\r\n\r\n\t//! Action to copy item\r\n\tQAction copyAction_;\r\n\r\n\t//! Action to paste item\r\n\tQAction pasteAction_;\r\n\r\n\t//! Action to clear selected cells\r\n\tQAction clearAction_;\r\n\r\n\t//! Action to import a csv-file\r\n\tQAction importAction_;\r\n\r\n\t//! Action to export a csv-file\r\n\tQAction exportAction_;\r\n\r\n    //! The action to copy an element.\r\n    QAction copyElementAction_;\r\n\r\n    //! The action to paste an element.\r\n    QAction pasteElementAction_;\r\n\r\n\t//! Specified if the items can be imported/exported to a csv file.\r\n\tbool importExportEnabled_;\r\n\r\n    //! Specifies if the elements can be copied / pasted.\r\n    bool elementCopyIsAllowed_;\r\n\r\n    /*!\r\n     *  Set up the actions for the context menu\r\n     */\r\n    virtual void setupActions();\r\n\r\nprotected slots:\r\n\r\n\t//! Handler for add action\r\n\tvirtual void onAddAction();\r\n\r\n\t//! Handler for remove action\r\n\tvirtual void onRemoveAction();\r\n\r\n\t//! Handler for copy action.\r\n\tvirtual void onCopyAction();\r\n\r\n\t//! Handler for paste action\r\n\tvirtual void onPasteAction();\r\n\r\n\t//! Handler for cell clear action\r\n\tvirtual void onClearAction(); \r\n\r\n    //! Handler for cut action.\r\n    virtual void onCutAction();\r\n\r\n    /*!\r\n     *  Handler for element copy action.\r\n     */\r\n    virtual void onCopyElementAction();\r\n\r\nprivate:\r\n\r\n\t//! No copying\r\n\tEditableTableView(const EditableTableView& other);\r\n\tEditableTableView& operator=(const EditableTableView& other);\r\n\r\n\r\n\r\n    /*!\r\n     *  Generates a unique name within the table for the item.\r\n     *\r\n     *    @param [in] original     The original name of the item.\r\n     *\r\n     *    @return Unique name for the item.\r\n     */\r\n    QString getUniqueName(QString const& original);\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n\t//! The default path to use for import/export csv\r\n\tQString defImportExportPath_;\r\n\r\n\t//! Specifies if the items in the view can be dragged from position to another.\r\n\tbool itemsDraggable_;\r\n\r\n    //! Specifies if the columns sizes are fit to content on model load.\r\n    bool fitColumnsToContent_;\r\n};\r\n\r\n#endif // EDITABLETABLEVIEW_H\r\n"
  },
  {
    "path": "common/views/EditableTreeView/EditableTreeSortFilter.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: EditableTreeSortfilter.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 01.12.2017\n//\n// Description:\n// Sort filter model for editable tree view.\n//-----------------------------------------------------------------------------\n\n#include \"EditableTreeSortFilter.h\"\n\n//-----------------------------------------------------------------------------\n// Function: EditableTreeSortFilter::EditableTreeSortFilter()\n//-----------------------------------------------------------------------------\nEditableTreeSortFilter::EditableTreeSortFilter(QObject* parent):\nQSortFilterProxyModel(parent)\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: EditableTreeSortFilter::~EditableTreeSortFilter()\n//-----------------------------------------------------------------------------\nEditableTreeSortFilter::~EditableTreeSortFilter()\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: EditableTreeSortFilter::onAddItem()\n//-----------------------------------------------------------------------------\nvoid EditableTreeSortFilter::onAddItem(QModelIndexList const& indexes)\n{\n    QModelIndex posToAdd;\n    int rowCount = 1;\n\n    if (!indexes.isEmpty())\n    {\n        QModelIndexList sortedIndexes = indexes;\n        std::sort(sortedIndexes.begin(), sortedIndexes.end());\n        posToAdd = mapToSource(indexes.first());\n\n        int previousRow = indexes.first().row();\n        for(QModelIndex const& index : sortedIndexes)\n        {\n            if (index.row() != previousRow)\n            {\n                ++rowCount;\n            }\n\n            previousRow = index.row();\n        }\n    }\n\n    for (int i = 0; i < rowCount; ++i)\n    {\n        emit(addItem(posToAdd));\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: EditableTreeSortFilter::onAddSubItem()\n//-----------------------------------------------------------------------------\nvoid EditableTreeSortFilter::onAddSubItem(QModelIndexList const& parentIndexes)\n{\n    for(QModelIndex const& index : parentIndexes)\n    {\n        QModelIndex sourceParentIndex = mapToSource(index);\n        emit addSubItem(sourceParentIndex);\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: EditableTreeSortFilter::onRemoveSelectedRows()\n//-----------------------------------------------------------------------------\nvoid EditableTreeSortFilter::onRemoveSelectedRows(QModelIndexList const& indexes)\n{\n    if (indexes.isEmpty())\n    {\n        return;\n    }\n\n    QModelIndexList removableIndexList = getRemovableIndexes(concatIndexesToOneColumn(indexes));\n    std::sort(removableIndexList.begin(), removableIndexList.end());\n\n    for (int i = removableIndexList.size() - 1; i >= 0; i--)\n    {\n        QModelIndex index = mapToSource(removableIndexList.at(i));\n        emit removeItem(index);\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: EditableTreeSortFilter::concatIndexesToOneColumn()\n//-----------------------------------------------------------------------------\nQModelIndexList EditableTreeSortFilter::concatIndexesToOneColumn(QModelIndexList const& indexes) const\n{\n    QModelIndexList firstColumnIndexes;\n\n    for (auto const& index : indexes)\n    {\n        if (index.column() == 0)\n        {\n            firstColumnIndexes.append(index);\n        }\n        else\n        {\n            QModelIndex firstColumnIndex = index.sibling(index.row(), 0);\n            if (!firstColumnIndexes.contains(firstColumnIndex))\n            {\n                firstColumnIndexes.append(firstColumnIndex);\n            }\n        }\n    }\n\n    return firstColumnIndexes;\n}\n\n//-----------------------------------------------------------------------------\n// Function: EditableTreeSortFilter::getRemovableIndexes()\n//-----------------------------------------------------------------------------\nQModelIndexList EditableTreeSortFilter::getRemovableIndexes(QModelIndexList const& indexes) const\n{\n    QModelIndexList removableIndexes;\n\n    for (auto const& index : indexes)\n    {\n        if (indexIsRemovable(index, indexes))\n        {\n            removableIndexes.append(index);\n        }\n    }\n\n    return removableIndexes;\n}\n\n//-----------------------------------------------------------------------------\n// Function: EditableTreeSortFilter::indexIsRemovable()\n//-----------------------------------------------------------------------------\nbool EditableTreeSortFilter::indexIsRemovable(QModelIndex const& index, QModelIndexList indexList) const\n{\n    if (index.parent().isValid())\n    {\n        QModelIndex const& parentIndex = index.parent();\n        for (auto const& comparisonIndex : indexList)\n        {\n            if (parentIndex == comparisonIndex)\n            {\n                return false;\n            }\n        }\n\n        return indexIsRemovable(parentIndex, indexList);\n    }\n\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: EditableTreeSortFilter::onRemoveAllSubItemsFromIndexes()\n//-----------------------------------------------------------------------------\nvoid EditableTreeSortFilter::onRemoveAllSubItemsFromIndexes(QModelIndexList const& parentIndexes)\n{\n    if (!parentIndexes.isEmpty())\n    {\n        for(QModelIndex const& index : parentIndexes)\n        {\n            emit removeAllSubItemsFromIndex(mapToSource(index));\n        }\n    }\n}\n"
  },
  {
    "path": "common/views/EditableTreeView/EditableTreeSortFilter.h",
    "content": "//-----------------------------------------------------------------------------\n// File: EditableTreeSortfilter.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 01.12.2017\n//\n// Description:\n// Sort filter model for editable tree view.\n//-----------------------------------------------------------------------------\n\n#ifndef EDITABLETREESORTFILTER_H\n#define EDITABLETREESORTFILTER_H\n\n#include <QSortFilterProxyModel>\n#include <QObject>\n\n//-----------------------------------------------------------------------------\n//! Sort filter model for editable tree view.\n//-----------------------------------------------------------------------------\nclass EditableTreeSortFilter : public QSortFilterProxyModel\n{\n    Q_OBJECT\n\npublic:\n    \n    /*!\n     *  The constructor.\n     *\n     *    @param [in] parent  Parent object.\n     */\n    EditableTreeSortFilter(QObject* parent);\n\n    /*!\n     *  The destructor.\n     */\n    virtual ~EditableTreeSortFilter();\n\n    //! No copying. No assignment.\n    EditableTreeSortFilter(const EditableTreeSortFilter& other) = delete;\n    EditableTreeSortFilter& operator=(const EditableTreeSortFilter& other) = delete;\n\npublic slots:\n\n    /*!\n     *  Handle the item addition.\n     *\n     *    @param [in] indexes     Indexes the selected items.\n     */\n    void onAddItem(QModelIndexList const& indexes);\n\n    /*!\n     *  Handle the sub item addition.\n     *\n     *    @param [in] parentIndexes   Indexes of the selected parent.\n     */\n    void onAddSubItem(QModelIndexList const& parentIndexes);\n\n    /*!\n     *  Handle the item removal.\n     *\n     *    @param [in] indexes     Indexes of the selected items.\n     */\n    void onRemoveSelectedRows(QModelIndexList const& indexes);\n\n    /*!\n     *  Handle the removal of the sub items of the selected item.\n     *\n     *    @param [in] parentIndexes   Indexes of the selected items.\n     */\n    void onRemoveAllSubItemsFromIndexes(QModelIndexList const& parentIndexes);\n\nsignals:\n\n    /*!\n     *  Add a new item to the selected index position.\n     *\n     *    @param [in] newItemIndex    The selected index.\n     */\n    void addItem(QModelIndex const& newItemIndex);\n\n    /*!\n     *  Add a new sub item to the selected parent item.\n     *\n     *    @param [in] parentItemIndex     Index of the selected parent item.\n     */\n    void addSubItem(QModelIndex const& parentItemIndex);\n\n    /*!\n     *  Remove the selected item.\n     *\n     *    @param [in] itemIndex   Index of the selected item.\n     */\n    void removeItem(QModelIndex const& itemIndex);\n\n    /*!\n     *  Remove all of the sub items contained within the selected item.\n     *\n     *    @param [in] itemIndex   Index of the selected parent item.\n     */\n    void removeAllSubItemsFromIndex(QModelIndex const& itemIndex);\n\nprivate:\n\n    /*!\n     *  Change the selected index list To have indexes only from the first column.\n     *\n     *    @param [in] indexes     The selected index list.\n     *\n     *    @return List of indexes from the first column.\n     */\n    QModelIndexList concatIndexesToOneColumn(QModelIndexList const& indexes) const;\n\n    /*!\n     *  Removes child indexes that have parent indexes in the selected index list.\n     *\n     *    @param [in] indexes     The selected index list.\n     *\n     *    @return List of removable indexes.\n     */\n    QModelIndexList getRemovableIndexes(QModelIndexList const& indexes) const;\n\n    /*!\n     *  Check if the selected index is removable in the selected index list.\n     *\n     *    @param [in] index       The selected index.\n     *    @param [in] indexList   List of the comparison indexes.\n     *\n     *    @return True, if the selected index is removable, false otherwise.\n     */\n    bool indexIsRemovable(QModelIndex const& index, QModelIndexList indexList) const;\n};\n\n#endif // EDITABLETREESORTFILTER_H\n"
  },
  {
    "path": "common/views/EditableTreeView/EditableTreeView.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: EditableTreeView.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 30.11.2017\n//\n// Description:\n// A view for editable trees.\n//-----------------------------------------------------------------------------\n\n#include \"EditableTreeView.h\"\n\n#include <common/KactusColors.h>\n\n#include <QApplication>\n#include <QPainter>\n#include <QHeaderView>\n#include <QMenu>\n\n//-----------------------------------------------------------------------------\n// Function: EditableTreeView::EditableTreeView()\n//-----------------------------------------------------------------------------\nEditableTreeView::EditableTreeView(bool allowNewRows, QString const& addItemText, QString const& addSubItemText,\n    QString const& removeItemText, QString const& removeSubItemsText, QWidget* parent):\nQTreeView(parent),\nallowNewRows_(allowNewRows),\naddItemAction_(new QAction(addItemText, this)),\naddSubItemAction_(new QAction(addSubItemText, this)),\nremoveAction_(new QAction(removeItemText, this)),\nremoveAllSubItemsAction_(new QAction(removeSubItemsText, this)),\nclearAction_(new QAction(tr(\"Clear\"), this)),\nexpandAllItemsAction_(new QAction(tr(\"Expand all\"), this)),\ncollapseAllItemsAction_(new QAction(tr(\"Collapse all\"), this))\n{\n    header()->setDefaultAlignment(Qt::AlignCenter);\n\n    setIndentation(10);\n    setSelectionBehavior(QAbstractItemView::SelectItems);\n\n    setupActions(addItemText, addSubItemText, removeItemText, removeSubItemsText);\n}\n\n//-----------------------------------------------------------------------------\n// Function: EditableTreeView::setupActions()\n//-----------------------------------------------------------------------------\nvoid EditableTreeView::setupActions(QString const& addItemText, QString const& addSubItemText,\n    QString const& removeItemText, QString const& removeSubItemsText)\n{\n    addItemAction_->setToolTip(addItemText);\n    addItemAction_->setStatusTip(addItemText);\n    addSubItemAction_->setToolTip(addSubItemText);\n    addSubItemAction_->setStatusTip(addSubItemText);\n    removeAction_->setToolTip(removeItemText);\n    removeAction_->setStatusTip(removeItemText);\n    removeAllSubItemsAction_->setToolTip(removeSubItemsText);\n    removeAllSubItemsAction_->setStatusTip(removeSubItemsText);\n\n    expandAllItemsAction_->setToolTip(tr(\"Expand all port maps.\"));\n    expandAllItemsAction_->setStatusTip(tr(\"Expand all port maps.\"));\n    collapseAllItemsAction_->setToolTip(tr(\"Collapse all port maps.\"));\n    collapseAllItemsAction_->setStatusTip(tr(\"Collapse all port maps.\"));\n\n    addAction(clearAction_);\n    clearAction_->setShortcut(QKeySequence::Delete);\n    clearAction_->setShortcutContext(Qt::WidgetShortcut);\n    QString tooltipClear = tr(\"Clear the contents of a cell (%1)\").arg(clearAction_->shortcut().toString(QKeySequence::NativeText));\n    clearAction_->setToolTip(tooltipClear);\n    clearAction_->setStatusTip(tooltipClear);\n\n    connectActions();\n}\n\n//-----------------------------------------------------------------------------\n// Function: EditableTreeView::connectActions()\n//-----------------------------------------------------------------------------\nvoid EditableTreeView::connectActions()\n{\n    connect(addItemAction_, SIGNAL(triggered()), this, SLOT(onAddItem()), Qt::UniqueConnection);\n    connect(addSubItemAction_, SIGNAL(triggered()), this, SLOT(onAddSubItem()), Qt::UniqueConnection);\n\n    connect(removeAction_, SIGNAL(triggered()), this, SLOT(onRemoveSelectedItems()), Qt::UniqueConnection);\n    connect(removeAllSubItemsAction_, SIGNAL(triggered()),\n        this, SLOT(onRemoveAllSubItems()), Qt::UniqueConnection);\n\n    connect(clearAction_, SIGNAL(triggered()), this, SLOT(onClearAction()), Qt::UniqueConnection);\n\n    connect(expandAllItemsAction_, SIGNAL(triggered()), this, SLOT(expandAll()), Qt::UniqueConnection);\n    connect(collapseAllItemsAction_, SIGNAL(triggered()), this, SLOT(collapseAll()), Qt::UniqueConnection);\n}\n\n//-----------------------------------------------------------------------------\n// Function: EditableTreeView::~EditableTreeView()\n//-----------------------------------------------------------------------------\nEditableTreeView::~EditableTreeView()\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: EditableTreeView::contextMenuEvent()\n//-----------------------------------------------------------------------------\nvoid EditableTreeView::contextMenuEvent(QContextMenuEvent* event)\n{\n    QModelIndex contextMenuIndex = indexAt(event->pos());\n\n    QMenu contextMenu(this);\n\n    contextMenu.addAction(addItemAction_);\n\n    if (contextMenuIndex.isValid())\n    {\n        contextMenu.addAction(removeAction_);\n        contextMenu.addAction(clearAction_);\n\n        contextMenu.addSeparator();\n        contextMenu.addAction(addSubItemAction_);\n        contextMenu.addAction(removeAllSubItemsAction_);\n    }\n\n    contextMenu.addSeparator();\n\n    contextMenu.addAction(expandAllItemsAction_);\n    contextMenu.addAction(collapseAllItemsAction_);\n\n    contextMenu.exec(event->globalPos());\n\n    event->accept();\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: EditableTreeView::mouseDoubleClickEvent()\n//-----------------------------------------------------------------------------\nvoid EditableTreeView::mouseDoubleClickEvent(QMouseEvent* event)\n{\n    QModelIndex index = indexAt(event->pos());\n    if (allowNewRows_ && !index.isValid())\n    {\n        onAddItem();\n        event->accept();\n        return;\n    }\n    else\n    {\n        QTreeView::mouseDoubleClickEvent(event);\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: EditableTreeView::onAddItem()\n//-----------------------------------------------------------------------------\nvoid EditableTreeView::onAddItem()\n{\n    QApplication::setOverrideCursor(Qt::WaitCursor);\n\n    emit addItems(selectedIndexes());\n\n    clearSelection();\n    setCurrentIndex(QModelIndex());\n\n    QApplication::restoreOverrideCursor();\n}\n\n//-----------------------------------------------------------------------------\n// Function: EditableTreeView::onAddSubItem()\n//-----------------------------------------------------------------------------\nvoid EditableTreeView::onAddSubItem()\n{\n    QApplication::setOverrideCursor(Qt::WaitCursor);\n\n    QModelIndexList currentIndexes;\n    for (auto index : selectedIndexes())\n    {\n        currentIndexes.append(index.sibling(index.row(), 0));\n    }\n\n    emit addSubItem(currentIndexes);\n\n    foreach (QModelIndex index, currentIndexes)\n    {\n        expand(index);\n    }\n\n    QApplication::restoreOverrideCursor();\n}\n\n//-----------------------------------------------------------------------------\n// Function: EditableTreeView::onRemoveItem()\n//-----------------------------------------------------------------------------\nvoid EditableTreeView::onRemoveSelectedItems()\n{\n    QApplication::setOverrideCursor(Qt::WaitCursor);\n\n    emit removeSelectedItems(selectedIndexes());\n\n    clearSelection();\n    setCurrentIndex(QModelIndex());\n\n    QApplication::restoreOverrideCursor();\n}\n\n//-----------------------------------------------------------------------------\n// Function: EditableTreeView::onRemoveAllSubItems()\n//-----------------------------------------------------------------------------\nvoid EditableTreeView::onRemoveAllSubItems()\n{\n    QApplication::setOverrideCursor(Qt::WaitCursor);\n\n    emit removeAllSubItems(selectedIndexes());\n\n    clearSelection();\n    setCurrentIndex(QModelIndex());\n\n    QApplication::restoreOverrideCursor();\n}\n\n//-----------------------------------------------------------------------------\n// Function: EditableTreeView::()\n//-----------------------------------------------------------------------------\nvoid EditableTreeView::drawRow(QPainter* painter, QStyleOptionViewItem const& option,\n    QModelIndex const& index) const\n{\n    QTreeView::drawRow(painter, option, index);\n\n    painter->save();\n    painter->setPen(QPen(KactusColors::DISABLED_TEXT, 0));\n    painter->drawLine(option.rect.bottomLeft(), option.rect.bottomRight());\n    painter->restore();\n}\n\n//-----------------------------------------------------------------------------\n// Function: EditableTreeView::getAddItemAction()\n//-----------------------------------------------------------------------------\nQAction* EditableTreeView::getAddItemAction() const\n{\n    return addItemAction_;\n}\n\n//-----------------------------------------------------------------------------\n// Function: EditableTreeView::getAddSubItemAction()\n//-----------------------------------------------------------------------------\nQAction* EditableTreeView::getAddSubItemAction() const\n{\n    return addSubItemAction_;\n}\n\n//-----------------------------------------------------------------------------\n// Function: EditableTreeView::getRemoveAction()\n//-----------------------------------------------------------------------------\nQAction* EditableTreeView::getRemoveAction() const\n{\n    return removeAction_;\n}\n\n//-----------------------------------------------------------------------------\n// Function: EditableTreeView::getRemoveAllSubItemsAction()\n//-----------------------------------------------------------------------------\nQAction* EditableTreeView::getRemoveAllSubItemsAction() const\n{\n    return removeAllSubItemsAction_;\n}\n\n//-----------------------------------------------------------------------------\n// Function: EditableTreeView::getClearAction()\n//-----------------------------------------------------------------------------\nQAction* EditableTreeView::getClearAction() const\n{\n    return clearAction_;\n}\n\n//-----------------------------------------------------------------------------\n// Function: EditableTreeView::getExpandAllAction()\n//-----------------------------------------------------------------------------\nQAction* EditableTreeView::getExpandAllAction() const\n{\n    return expandAllItemsAction_;\n}\n\n//-----------------------------------------------------------------------------\n// Function: EditableTreeView::getCollapseAllAction()\n//-----------------------------------------------------------------------------\nQAction* EditableTreeView::getCollapseAllAction() const\n{\n    return collapseAllItemsAction_;\n}\n\n//-----------------------------------------------------------------------------\n// Function: EditableTreeView::onClearAction()\n//-----------------------------------------------------------------------------\nvoid EditableTreeView::onClearAction()\n{\n    QModelIndex selectedIndex = currentIndex();\n\n    QString oldValue = model()->data(selectedIndex, Qt::EditRole).toString();\n    QString newValue(\"\");\n    model()->setData(selectedIndex, newValue, Qt::EditRole);\n}\n"
  },
  {
    "path": "common/views/EditableTreeView/EditableTreeView.h",
    "content": "//-----------------------------------------------------------------------------\n// File: EditableTreeView.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 30.11.2017\n//\n// Description:\n// A view for editable trees.\n//-----------------------------------------------------------------------------\n\n#ifndef EDITABLETREEVIEW_H\n#define EDITABLETREEVIEW_H\n\n#include <QTreeView>\n#include <QContextMenuEvent>\n#include <QModelIndex>\n#include <QAction>\n#include <QModelIndexList>\n\n//-----------------------------------------------------------------------------\n//! A tree view for the configurable element tree model.\n//-----------------------------------------------------------------------------\nclass EditableTreeView : public QTreeView\n{\n    Q_OBJECT\n\npublic:\n   \n    /*!\n     *  The constructor.\n     *\n     *    @param [in] allowNewRows        Flag for allowing new items to be added.\n     *    @param [in] addItemText         Text for adding new items.\n     *    @param [in] addSubItemText      Text for adding new sub items.\n     *    @param [in] removeItemText      Text for removing items.\n     *    @param [in] removeSubItemsText  Text for removing all sub items.\n     *    @param [in] parent              The owner of this view.\n     */\n    EditableTreeView(bool allowNewRows, QString const& addItemText, QString const& addSubItemText,\n        QString const& removeItemText, QString const& removeSubItemsText, QWidget* parent);\n\n    /*!\n     *  The destructor.\n     */\n    virtual ~EditableTreeView();\n\nsignals:\n\n    /*!\n     *  Add items to the selected indexes.\n     *\n     *    @param [in] indexes     The selected indexes.\n     */\n    void addItems(QModelIndexList const& indexes);\n\n    /*!\n     *  Add sub items to the selected indexes.\n     *\n     *    @param [in] indexes     The selected indexes.\n     */\n    void addSubItem(QModelIndexList const& indexes);\n\n    /*!\n     *  Emitted when the user attempts to remove an item.\n     *\n     *    @param [in] index   The indexes of the item to be removed.\n     */\n    void removeSelectedItems(QModelIndexList const& indexes);\n\n    /*!\n     *  Emitted when the user attempts to remove all sub items from the selected items.\n     *\n     *    @param [in] index   The indexes of the items whose sub items are removed.\n     */\n    void removeAllSubItems(QModelIndexList const& indexes);\n\nprotected:\n    \n    /*!\n\t *  Handle the double click.\n\t *\n\t *    @param [in] event   The mouse event.\n\t */\n\tvirtual void mouseDoubleClickEvent(QMouseEvent* event) override;\n\n    /*!\n     *  Draws a row and.\n     *\n     *    @param [in] painter   The painter used for the drawing.\n     *    @param [in] option    Options for the drawing.\n     *    @param [in] index     Index of the item to draw.\n     */\n    virtual void drawRow(QPainter* painter, QStyleOptionViewItem const& option, QModelIndex const& index)\n        const override;\n\n    /*!\n     *  Handler for context menu events.\n     *\n     *    @param [in] event   The context menu event.\n     */\n    virtual void contextMenuEvent(QContextMenuEvent* event) override;\n\n    /*!\n     *  Gets the action for adding items.\n     *\n     *    @return The add item action.\n     */\n    QAction* getAddItemAction() const;\n\n    /*!\n     *  Gets the action for adding sub items.\n     *\n     *    @return The add sub item action.\n     */\n    QAction* getAddSubItemAction() const;\n\n    /*!\n     *  Gets the action for the remove command.\n     *\n     *    @return The action for the remove command.\n     */\n    QAction* getRemoveAction() const;\n\n    /*!\n     *  Gets the action for removing all sub items.\n     *\n     *    @return The remove all sub items action.\n     */\n    QAction* getRemoveAllSubItemsAction() const;\n\n    /*!\n     *  Gets the action for clearing an item.\n     *\n     *    @return The clear item action.\n     */\n    QAction* getClearAction() const;\n\n    /*!\n     *  Gets the action for displaying all child items of an item.\n     *\n     *    @return The expand all item action.\n     */\n    QAction* getExpandAllAction() const;\n\n    /*!\n     *  Gets the action for hiding all child items of an item.\n     *\n     *    @return The collapse all item action.\n     */\n    QAction* getCollapseAllAction() const;\n\nprotected slots:\n\n    /*!\n     *  Handles the clearing of the selected cell.\n     */\n    void onClearAction();\n\n    /*!\n     *  Handles the item addition.\n     */\n    void onAddItem();\n\n    /*!\n     *  Handles the sub item addition.\n     */\n    void onAddSubItem();\n\n    /*!\n     *  Handles the removal of the items.\n     */\n    void onRemoveSelectedItems();\n\n    /*!\n     *  Handles the removal of all sub items of the selected index.\n     */\n    void onRemoveAllSubItems();\n\nprivate:\n   \n    // No copying. No assignment.\n    EditableTreeView(EditableTreeView const& rhs);\n    EditableTreeView& operator=(EditableTreeView const& rhs);\n\n    /*!\n     *  Setup the actions.\n     *\n     *    @param [in] addItemText         Text for adding new items.\n     *    @param [in] addSubItemText      Text for adding new sub items.\n     *    @param [in] removeItemText      Text for removing items.\n     *    @param [in] removeSubItemsText  Text for removing all sub items.\n     */\n    void setupActions(QString const& addItemText, QString const& addSubItemText, QString const& removeItemText,\n        QString const& removeSubItemsText);\n\n    /*!\n     *  Connect the actions to their corresponding slots.\n     */\n    void connectActions();\n\n    //-----------------------------------------------------------------------------\n    // Data.\n    //-----------------------------------------------------------------------------\n\n    //! Flag for allowing new items to be added.\n    bool allowNewRows_;\n\n    //! Action for adding new items.\n    QAction* addItemAction_;\n\n    //! Action for adding new sub items.\n    QAction* addSubItemAction_;\n\n    //! Action for removing items.\n    QAction* removeAction_;\n\n    //! Action for removing all sub items.\n    QAction* removeAllSubItemsAction_;\n\n    //! Action for clearing a cell.\n    QAction* clearAction_;\n\n    //! Action for displaying all child items.\n    QAction* expandAllItemsAction_;\n\n    //! Action for hiding all child items.\n    QAction* collapseAllItemsAction_;\n};\n\n//-----------------------------------------------------------------------------\n\n#endif // CONFIGURABLEELEMENTSVIEW_H\n"
  },
  {
    "path": "common/views/ExpandingTreeView/ExpandingTreeView.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: ExpandingTreeView.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Esko Pekkarinen\n// Date: 20.06.2022\n//\n// Description:\n// Base class for treeviews with automatic expansion of lone children.\n//-----------------------------------------------------------------------------\n\n#include \"ExpandingTreeView.h\"\n\n//-----------------------------------------------------------------------------\n// Function: ExpandingTreeView::ExpandingTreeView()\n//-----------------------------------------------------------------------------\nExpandingTreeView::ExpandingTreeView(QWidget* parent):\n    QTreeView(parent)\n{\n    connect(this, SIGNAL(expanded(QModelIndex const&)), \n        this, SLOT(expandUntilFirstBranch(QModelIndex const&)), Qt::UniqueConnection);\n}\n\n//-----------------------------------------------------------------------------\n// Function: ExpandingTreeView::expandUntilFirstBranch()\n//-----------------------------------------------------------------------------\nvoid ExpandingTreeView::expandUntilFirstBranch(QModelIndex const& index)\n{\n    QModelIndex currentIndex = model()->index(0, 0, index);\n    if (currentIndex.isValid() && currentIndex.sibling(1, 0).isValid() == false)\n    {\n        expand(currentIndex);\n        currentIndex = model()->index(0, 0, currentIndex);\n    }\n}\n"
  },
  {
    "path": "common/views/ExpandingTreeView/ExpandingTreeView.h",
    "content": "//-----------------------------------------------------------------------------\n// File: ExpandingTreeView.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Esko Pekkarinen\n// Date: 20.06.2022\n//\n// Description:\n// Base class for treeviews with automatic expansion of lone children.\n//-----------------------------------------------------------------------------\n\n#ifndef EXPANDINGTREEVIEW_H\n#define EXPANDINGTREEVIEW_H\n\n#include <QTreeView>\n\nclass ExpandingTreeView : public QTreeView\n{\n    Q_OBJECT\npublic:\n\n    //! The constructor.\n    explicit ExpandingTreeView(QWidget* parent);\n    \n    //! The destructor.\n    virtual ~ExpandingTreeView() = default;\n    \n    //! No copying.\n    ExpandingTreeView(const ExpandingTreeView &other) = delete;\n\n    //! No assignment.\n    ExpandingTreeView &operator=(const ExpandingTreeView &other) = delete;\n\nprivate slots:\n\n    /*!\n     * Expand the tree until first branch i.e. index with more than one children is found.\n     *\n     *    @param [in] index  The starting index for expanding.\n     */\n    void expandUntilFirstBranch(QModelIndex const& index);\n};\n\n\n#endif // EXPANDINGTREEVIEW_H\n"
  },
  {
    "path": "common/widgets/DirectoryListSelector/DirectoryListSelector.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: DirectoryListSelector.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Esko Pekkarinen\r\n// Date: 2.1.2014\r\n//\r\n// Description:\r\n// Editor for selecting multiple directories.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"DirectoryListSelector.h\"\r\n\r\n#include <IPXACTmodels/generaldeclarations.h>\r\n\r\n#include <QModelIndex>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DirectoryListSelector::DirectoryListSelector()\r\n//-----------------------------------------------------------------------------\r\nDirectoryListSelector::DirectoryListSelector(QString const& basePath,\r\n    QStringList const& initialDirs, QWidget* parent) : \r\nQWidget(parent),\r\n    buttonAdd_(new QPushButton(QIcon(\":/icons/common/graphics/opened-folder.png\"), QString(), this)),\r\n    buttonRemove_(new QPushButton(QIcon(\":/icons/common/graphics/remove.png\"), QString(), this)),    \r\n    directoryListView_(new QListView(this)),\r\n    directoryListModel_(new QStringListModel(initialDirs)),\r\n    basePath_(QFileInfo(basePath).canonicalFilePath()),\r\n    persistentDirectories_()\r\n{\r\n    directoryListView_->setModel(directoryListModel_);\r\n   \r\n    buttonAdd_->setToolTip(tr(\"Browse...\"));\r\n\r\n    buttonRemove_->setEnabled(false); \r\n    buttonRemove_->setToolTip(tr(\"Remove selection\"));\r\n\r\n    connect(buttonAdd_, SIGNAL(clicked()), this, SLOT(addDirectory()));\r\n    connect(buttonRemove_, SIGNAL(clicked()), this, SLOT(removeDirectory()));\r\n    connect(directoryListView_, SIGNAL(clicked(const QModelIndex&)),\r\n        this, SLOT(onSelectionChanged()), Qt::UniqueConnection);\r\n\r\n    setupLayout();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DirectoryListSelector::~DirectoryListSelector()\r\n//-----------------------------------------------------------------------------\r\nDirectoryListSelector::~DirectoryListSelector()\r\n{\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DirectoryListSelector::addPersistentDirectory()\r\n//-----------------------------------------------------------------------------\r\nvoid DirectoryListSelector::setPersistentDirectory(QString const& directory)\r\n{\r\n    if (!persistentDirectories_.contains(directory))\r\n    {\r\n        persistentDirectories_.append(directory);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DirectoryListSelector::removePersistentDirectory()\r\n//-----------------------------------------------------------------------------\r\nvoid DirectoryListSelector::removePersistentDirectory(QString const& directory)\r\n{\r\n    persistentDirectories_.removeAll(directory);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DirectoryListSelector::getPersistentDirectories()\r\n//-----------------------------------------------------------------------------\r\nQStringList DirectoryListSelector::getPersistentDirectories() const\r\n{\r\n    return persistentDirectories_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DirectoryListSelector::getSourceDirectories()\r\n//-----------------------------------------------------------------------------\r\nQStringList DirectoryListSelector::getDirectories() const\r\n{\r\n    return directoryListModel_->stringList();   \r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DirectoryListSelector::addDirectory()\r\n//-----------------------------------------------------------------------------\r\nvoid DirectoryListSelector::addDirectory()\r\n{\r\n    QString newDirectory = QFileDialog::getExistingDirectory(this, tr(\"Choose Directory\"), basePath_);\r\n    if (newDirectory.size() < 1)\r\n    {\r\n        return;\r\n    }\r\n\r\n    newDirectory = QFileInfo(newDirectory).filePath();    \r\n    QString newAbsPath = newDirectory;\r\n\r\n    // Use relative path for subdirectories of base path.\r\n    // If relative path could not be resolved, use absolute path instead.\r\n    if (!basePath_.isEmpty() && newDirectory.startsWith(basePath_))\r\n    {\r\n        newDirectory = General::getRelativePath(basePath_, newDirectory);\r\n    }    \r\n    if (newDirectory.size() < 1)\r\n    {\r\n        newDirectory = newAbsPath;\r\n    }\r\n\r\n    // Check that new directory does not overlap with existing.\r\n    QStringList directories = directoryListModel_->stringList();\r\n    foreach(QString directory, directories)\r\n    {\r\n        if (QFileInfo(directory).isRelative())\r\n        {\r\n            directory = QFileInfo(basePath_ + \"/\" + directory).canonicalFilePath();\r\n        }\r\n\r\n        if (QString::compare(directory, newAbsPath) == 0)\r\n        {\r\n            return;\r\n        }\r\n    }\r\n\r\n    // Add the new directory to the list.\r\n    directories.push_back(newDirectory);\r\n    directoryListModel_->setStringList(directories);\r\n    emit contentChanged();    \r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DirectoryListSelector::removeDirectory()\r\n//-----------------------------------------------------------------------------\r\nvoid DirectoryListSelector::removeDirectory()\r\n{    \r\n    QModelIndex index = directoryListView_->selectionModel()->currentIndex();\r\n    \r\n    if (!index.isValid())\r\n    {\r\n        return;\r\n    }\r\n\r\n    // Do not allow persistent directories to be removed.\r\n    if (persistentDirectories_.contains(index.data().toString()))\r\n    {\r\n        return;\r\n    }\r\n\r\n    directoryListModel_->removeRow(index.row());\r\n\r\n    onSelectionChanged();    \r\n    emit contentChanged();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DirectoryListSelector::onSelectionChanged()\r\n//-----------------------------------------------------------------------------\r\nvoid DirectoryListSelector::onSelectionChanged()\r\n{    \r\n    QModelIndex index = directoryListView_->selectionModel()->currentIndex();\r\n    buttonRemove_->setEnabled(index.isValid() && \r\n        !persistentDirectories_.contains(directoryListModel_->data(index, Qt::DisplayRole).toString()));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DirectoryListSelector::setupLayout()\r\n//-----------------------------------------------------------------------------\r\nvoid DirectoryListSelector::setupLayout()\r\n{\r\n    QDialogButtonBox* addRemoveButtonBox = new QDialogButtonBox(Qt::Vertical);\r\n    addRemoveButtonBox->addButton(buttonAdd_, QDialogButtonBox::ActionRole);\r\n    addRemoveButtonBox->addButton(buttonRemove_, QDialogButtonBox::ActionRole);\r\n\r\n    QHBoxLayout* topLayout = new QHBoxLayout(this);    \r\n    topLayout->addWidget(directoryListView_, 1);\r\n    topLayout->addWidget(addRemoveButtonBox);\r\n    topLayout->setContentsMargins(0, 0, 0, 0);\r\n}\r\n"
  },
  {
    "path": "common/widgets/DirectoryListSelector/DirectoryListSelector.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: DirectoryListSelector.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Esko Pekkarinen\r\n// Date: 2.1.2014\r\n//\r\n// Description:\r\n// Editor for selecting multiple directories.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef DIRECTORYLISTSELECTOR_H\r\n#define DIRECTORYLISTSELECTOR_H\r\n\r\n#include <QDialog>\r\n#include <QStringList>\r\n#include <QDialogButtonBox>\r\n#include <QPushButton>\r\n#include <QGroupBox>\r\n#include <QVBoxLayout>\r\n#include <QHBoxLayout>\r\n#include <QListView>\r\n#include <QStringListModel>\r\n#include <QFileDialog>\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Editor for selecting multiple directories.\r\n//-----------------------------------------------------------------------------\r\nclass DirectoryListSelector : public QWidget\r\n{\r\n    Q_OBJECT\r\npublic:\r\n    /*!\r\n     *  Constructor.\r\n     *\r\n     *    @param [in] basePath    The path to base directory.\r\n     *    @param [in] initialDirs The current list of directories.\r\n     *    @param [in] parent      The parent widget.\r\n     */\r\n    DirectoryListSelector(QString const& basePath = QString(), \r\n        QStringList const& initialDirs = QStringList(), \r\n        QWidget* parent = 0);\r\n\r\n    /*!\r\n     *  Destructor.\r\n     */\r\n    ~DirectoryListSelector();\r\n\r\n    /*!\r\n     *  Sets a directory non-removable.\r\n     *\r\n     *    @param [in] directory   The directory to set.\r\n     */\r\n    void setPersistentDirectory(QString const& directory);\r\n\r\n    /*!\r\n     *  Sets a directory removable.\r\n     *\r\n     *    @param [in] directory   The directory to set.\r\n     */\r\n    void removePersistentDirectory(QString const& directory);\r\n\r\n    /*!\r\n     *  Gets the list of non-removable directories.\r\n     *     \r\n     *    @return List of non-removable directories.\r\n     */\r\n    QStringList getPersistentDirectories() const;\r\n\r\n    /*!\r\n     *  Retrieves the list of directories.\r\n     *\r\n     *    @return The list of directories.\r\n     */\r\n    QStringList getDirectories() const;\r\n\r\nsignals:\r\n    \r\n    //! Emitted when directories have been changed.\r\n    void contentChanged();\r\n\r\nprivate slots:\r\n\r\n    /*!\r\n     *  Adds a new directory to the list. The source directory is prompted with a folder selection dialog.\r\n     *\r\n     *      @remark Directories under the base directory are denoted with relative path. All other directories\r\n     *              use absolute paths.\r\n     */\r\n    void addDirectory();\r\n\r\n    /*!\r\n     *  Removes the currently selected directory from the list.\r\n     */\r\n    void removeDirectory();\r\n\r\n    \r\n    /*!\r\n     *  Handler for directory selection changes.\r\n     */\r\n    void onSelectionChanged();\r\n\r\nprivate:\r\n    // Disable copying.\r\n    DirectoryListSelector(DirectoryListSelector const& rhs);\r\n    DirectoryListSelector& operator=(DirectoryListSelector const& rhs);\r\n\r\n    //! Sets the widget layout.\r\n    void setupLayout();\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! Button for adding new directories.\r\n    QPushButton* buttonAdd_;\r\n\r\n    //! Button for removing directories.\r\n    QPushButton* buttonRemove_;\r\n\r\n    //! View for directories.\r\n    QListView* directoryListView_;\r\n\r\n    //! Model for directories.\r\n    QStringListModel* directoryListModel_;\r\n\r\n    //! The base path for directories.\r\n    QString basePath_;\r\n\r\n    //! List of persistent, non-removable directories.\r\n    QStringList persistentDirectories_;\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n\r\n#endif // DIRECTORYLISTSELECTOR_H\r\n"
  },
  {
    "path": "common/widgets/EnumCollectionEditor/EnumCollectionEditor.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: EnumCollectionEditor.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Joni-Matti Maatta\r\n// Date: 17.04.2013\r\n//\r\n// Description:\r\n// Editor for choosing multiple values from a collection of enumerables.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"EnumCollectionEditor.h\"\r\n\r\n#include <QEvent>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: EnumCollectionEditor::EnumCollectionEditor()\r\n//-----------------------------------------------------------------------------\r\nEnumCollectionEditor::EnumCollectionEditor(QWidget* parent):\r\nQWidget(parent),\r\nlayout_(new QVBoxLayout(this)),\r\nitems_(),\r\nexclusiveItems_()\r\n{\r\n    layout_->setContentsMargins(0, 0, 0, 0);\r\n\r\n    setAutoFillBackground(true);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: EnumCollectionEditor::addItem()\r\n//-----------------------------------------------------------------------------\r\nvoid EnumCollectionEditor::addItem(QString const& text, bool isExclusivePort, bool selected)\r\n{\r\n    QCheckBox* checkBox = createCheckBox(text, selected);\r\n\r\n    if (isExclusivePort)\r\n    {\r\n        exclusiveItems_.append(checkBox);\r\n        connect(checkBox, SIGNAL(clicked(bool)), this, SLOT(onExclusiveItemClicked(bool)), Qt::UniqueConnection);\r\n    }\r\n    else\r\n    {\r\n        connect(checkBox, SIGNAL(clicked(bool)), this, SLOT(onItemClicked(bool)), Qt::UniqueConnection);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: EnumCollectionEditor::clearItems()\r\n//-----------------------------------------------------------------------------\r\nvoid EnumCollectionEditor::clearItems()\r\n{\r\n    for (auto item : items_)\r\n    {\r\n        layout_->removeWidget(item);\r\n        item->deleteLater();\r\n    }\r\n    items_.clear();\r\n\r\n    for (auto item : exclusiveItems_)\r\n    {\r\n        layout_->removeWidget(item);\r\n        item->deleteLater();\r\n    }\r\n    exclusiveItems_.clear();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: EnumCollectionEditor::createCheckBox()\r\n//-----------------------------------------------------------------------------\r\nQCheckBox* EnumCollectionEditor::createCheckBox(QString const& text, bool isSelected)\r\n{\r\n    QCheckBox* checkBox = new QCheckBox(text, this);\r\n    checkBox->setChecked(isSelected);\r\n\r\n    items_.append(checkBox);\r\n    layout_->addWidget(checkBox);\r\n\r\n    setMinimumHeight(sizeHint().height());\r\n\r\n    return checkBox;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: EnumCollectionEditor::onExclusiveItemClicked()\r\n//-----------------------------------------------------------------------------\r\nvoid EnumCollectionEditor::onExclusiveItemClicked(bool newState)\r\n{\r\n    if (newState == true)\r\n    {\r\n        auto senderBox = dynamic_cast<QCheckBox const*>(sender());\r\n        \r\n        for (auto item : items_)\r\n        {\r\n            if (item != senderBox)\r\n            {\r\n                item->setChecked(false);\r\n            }\r\n        }\r\n    }\r\n\r\n    handleCheckAllStateChangeFromItemClick(newState);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: EnumCollectionEditor::onItemClicked()\r\n//-----------------------------------------------------------------------------\r\nvoid EnumCollectionEditor::onItemClicked(bool newState)\r\n{\r\n    for (auto item : exclusiveItems_)\r\n    {\r\n        if (item->isChecked())\r\n        {\r\n            item->setChecked(false);\r\n        }\r\n    }\r\n\r\n    handleCheckAllStateChangeFromItemClick(newState);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: EnumCollectionEditor::handleCheckAllStateChangeFromItemClick()\r\n//-----------------------------------------------------------------------------\r\nvoid EnumCollectionEditor::handleCheckAllStateChangeFromItemClick(bool newState)\r\n{\r\n    Qt::CheckState checkAllState = Qt::Checked;\r\n    if (newState == false)\r\n    {\r\n        checkAllState = Qt::Unchecked;\r\n    }\r\n\r\n    for (auto item : items_)\r\n    {\r\n        if (item->isChecked() != newState)\r\n        {\r\n            checkAllState = Qt::PartiallyChecked;\r\n            break;\r\n        }\r\n    }\r\n\r\n    emit itemStateChanged(checkAllState);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: EnumCollectionEditor::getSelectedItems()\r\n//-----------------------------------------------------------------------------\r\nQStringList EnumCollectionEditor::getSelectedItems() const\r\n{\r\n    QStringList selectedItems;\r\n\r\n    for (QCheckBox* checkBox : items_)\r\n    {\r\n        if (checkBox->isChecked())\r\n        {\r\n            selectedItems.append(checkBox->text());\r\n        }\r\n    }\r\n\r\n    return selectedItems;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: EnumCollectionEditor::rePosition()\r\n//-----------------------------------------------------------------------------\r\nvoid EnumCollectionEditor::rePosition()\r\n{\r\n    int availableHeight = parentWidget()->height() - parentWidget()->contentsMargins().bottom() -\r\n        parentWidget()->contentsMargins().top();\r\n\r\n    int yLeftBottom = pos().y() + height();\r\n    if (yLeftBottom > availableHeight)\r\n    {\r\n        int yChange = yLeftBottom - parentWidget()->height() + parentWidget()->contentsMargins().bottom();\r\n        int yCoordinate = pos().y() - yChange;\r\n        if (yCoordinate >= 0)\r\n        {\r\n            move(pos().x(), yCoordinate);\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: EnumCollectionEditor::changeStatesOfAllItems()\r\n//-----------------------------------------------------------------------------\r\nvoid EnumCollectionEditor::changeStatesOfAllItems(bool newState)\r\n{\r\n    for (auto item : items_)\r\n    {\r\n        item->setChecked(newState);\r\n    }\r\n}\r\n"
  },
  {
    "path": "common/widgets/EnumCollectionEditor/EnumCollectionEditor.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: EnumCollectionEditor.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Joni-Matti Maatta\r\n// Date: 17.04.2013\r\n//\r\n// Description:\r\n// Editor for choosing multiple values from a collection of enumerables.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef ENUMCOLLECTIONEDITOR_H\r\n#define ENUMCOLLECTIONEDITOR_H\r\n\r\n#include <QFrame>\r\n#include <QVBoxLayout>\r\n#include <QCheckBox>\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Editor for choosing multiple values from a collection of enumerables.\r\n//-----------------------------------------------------------------------------\r\nclass EnumCollectionEditor : public QWidget\r\n{\r\n    Q_OBJECT\r\n\r\npublic:\r\n    /*!\r\n     *  Constructor.\r\n     *\r\n     *    @param [in] parent The parent widget.\r\n     */\r\n    EnumCollectionEditor(QWidget* parent);\r\n\r\n    /*!\r\n     *  Destructor.\r\n     */\r\n    virtual ~EnumCollectionEditor() = default;\r\n\r\n    /*!\r\n     *  Adds a new enumerable item to the editor.\r\n     *\r\n     *    @param [in] text                The name of the item.\r\n     *    @param [in] isExclusivePort     Flag for exclusive ports.\r\n     *    @param [in] selected            If true, the item is initially selected.\r\n     */\r\n    void addItem(QString const& text, bool isExclusivePort, bool selected);\r\n\r\n    void clearItems();\r\n\r\n    /*!\r\n     *  Returns the selected items.\r\n     */\r\n    QStringList getSelectedItems() const;\r\n\r\n    /*!\r\n     *  Change the state of all the enumerations.\r\n     *\r\n     *    @param [in] newState    New state for the enumerations.\r\n     */\r\n    void changeStatesOfAllItems(bool newState);\r\n\r\nsignals:\r\n\r\n    /*!\r\n     *  Inform of a change in the combined state of the enumerations.\r\n     *\r\n     *    @param [in] newState    Combined state of the enumerations.\r\n     */\r\n    void itemStateChanged(Qt::CheckState newState);\r\n\r\nprotected:\r\n\r\n    /*!\r\n     *  Repositions the editor higher, if it would otherwise exceed the bottom of parent widget.\r\n     */\r\n    virtual void rePosition();\r\n\r\nprivate slots:\r\n\r\n    /*!\r\n     *  Handle the state change in enumeration check box.\r\n     *\r\n     *    @param [in] newState    New state of the enumeration check box.\r\n     */\r\n    void onItemClicked(bool newState);\r\n\r\n    /*!\r\n     *  Handle the state change in an exclusive enumeration check box.\r\n     *\r\n     *    @param [in] newState    New state of the exclusive enumeration check box.\r\n     */\r\n    void onExclusiveItemClicked(bool newState);\r\n\r\nprivate:\r\n    // Disable copying.\r\n    EnumCollectionEditor(EnumCollectionEditor const& rhs);\r\n    EnumCollectionEditor& operator=(EnumCollectionEditor const& rhs);\r\n\r\n    /*!\r\n     *  Create an enumeration check box.\r\n     *\r\n     *    @param [in] text        The name of the item.\r\n     *    @param [in] selected    If true, the item is initially selected.\r\n     *\r\n     *    @return The created enumeration check box.\r\n     */\r\n    QCheckBox* createCheckBox(QString const& text, bool isSelected);\r\n\r\n    /*!\r\n     *  Handle the change in the state of the check all check box.\r\n     *\r\n     *    @param [in] newState    New state of the item initiating this change.\r\n     */\r\n    void handleCheckAllStateChangeFromItemClick(bool newState);\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! The item layout.\r\n    QVBoxLayout* layout_;\r\n\r\n    //! The check boxes for the items.\r\n    QList<QCheckBox*> items_;\r\n\r\n    //! List of exclusive check boxes.\r\n    QList<QCheckBox*> exclusiveItems_;\r\n};\r\n\r\n#endif // ENUMCOLLECTIONEDITOR_H\r\n"
  },
  {
    "path": "common/widgets/EnumCollectionEditor/EnumerationEditor.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: EnumerationEditor.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Mikko Teuho\n// Date: 20.01.2023\n//\n// Description:\n// Editor for enumerations.\n//-----------------------------------------------------------------------------\n\n#include \"EnumerationEditor.h\"\n\n#include <common/widgets/EnumCollectionEditor/EnumCollectionEditor.h>\n\n#include <QPushButton>\n#include <QScrollArea>\n\n//-----------------------------------------------------------------------------\n// Function: EnumerationEditor::EnumerationEditor()\n//-----------------------------------------------------------------------------\nEnumerationEditor::EnumerationEditor(bool hideCheckAll, QWidget* parent):\nQFrame(parent),\nenumCollectionEditor_(new EnumCollectionEditor(this)),\nselectAllCheck_(new QCheckBox(\"All\"))\n{\n    if (hideCheckAll)\n    {\n        selectAllCheck_->hide();\n    }\n\n    selectAllCheck_->setToolTip(\"Select / deselect all\");\n\n    selectAllCheck_->setTristate(true);\n\n    setFrameStyle(QFrame::StyledPanel);\n    setFocusPolicy(Qt::StrongFocus);\n    setAttribute(Qt::WA_NoMousePropagation);\n    setAutoFillBackground(true);\n\n    setupLayout();\n\n    connect(enumCollectionEditor_, SIGNAL(itemStateChanged(Qt::CheckState)), this, SLOT(onChangeCheckAllState(Qt::CheckState)), Qt::UniqueConnection);\n}\n\n//-----------------------------------------------------------------------------\n// Function: EnumerationEditor::setupLayout()\n//-----------------------------------------------------------------------------\nvoid EnumerationEditor::setupLayout()\n{\n    enumCollectionEditor_->setContentsMargins(0, 0, 0, 0);\n\n    QScrollArea* scrollingWidget = new QScrollArea();\n    scrollingWidget->setWidgetResizable(true);\n    scrollingWidget->setWidget(enumCollectionEditor_);\n    scrollingWidget->setFrameShape(QFrame::NoFrame);\n    scrollingWidget->setContentsMargins(0, 0, 0, 0);\n\n    connect(selectAllCheck_, SIGNAL(clicked(bool)), this, SLOT(onCheckAllStateChange(bool)), Qt::UniqueConnection);\n\n    QPushButton* okButton = new QPushButton();\n    okButton->setIcon(QIcon(\":/icons/common/graphics/checkMark.png\"));\n    okButton->setToolTip(\"Accept\");\n\n    QPushButton* cancelButton = new QPushButton();\n    cancelButton->setIcon(QIcon(\":/icons/common/graphics/grey_cross.png\"));\n    cancelButton->setToolTip(\"Cancel\");\n\n    connect(okButton, SIGNAL(clicked()), this, SIGNAL(finishEditing()), Qt::UniqueConnection);\n    connect(cancelButton, SIGNAL(clicked()), this, SIGNAL(cancelEditing()), Qt::UniqueConnection);\n\n    QHBoxLayout* buttonLayout = new QHBoxLayout();\n    buttonLayout->addWidget(selectAllCheck_);\n    buttonLayout->addStretch(10);\n    buttonLayout->addWidget(okButton);\n    buttonLayout->addWidget(cancelButton);\n\n    QFrame* line = new QFrame();\n    line->setLineWidth(1);\n    line->setMidLineWidth(1);\n    line->setFrameShape(QFrame::HLine);\n    line->setFrameShadow(QFrame::Sunken);\n    line->setContentsMargins(0, 0, 0, 0);\n\n    QVBoxLayout* mainLayout = new QVBoxLayout(this);\n    mainLayout->addWidget(scrollingWidget, 10);\n    mainLayout->addWidget(line);\n    mainLayout->addLayout(buttonLayout, 0);\n}\n\n//-----------------------------------------------------------------------------\n// Function: EnumerationEditor::onCheckAllStateChange()\n//-----------------------------------------------------------------------------\nvoid EnumerationEditor::onCheckAllStateChange(bool newState)\n{\n    if (newState == true)\n    {\n        selectAllCheck_->setChecked(true);\n        selectAllCheck_->repaint();\n    }\n\n    enumCollectionEditor_->changeStatesOfAllItems(newState);\n}\n\n//-----------------------------------------------------------------------------\n// Function: EnumerationEditor::onChangeCheckAllState()\n//-----------------------------------------------------------------------------\nvoid EnumerationEditor::onChangeCheckAllState(Qt::CheckState newState)\n{\n    selectAllCheck_->setCheckState(newState);\n    selectAllCheck_->repaint();\n}\n\n//-----------------------------------------------------------------------------\n// Function: EnumerationEditor::getSelectedItems()\n//-----------------------------------------------------------------------------\nQStringList EnumerationEditor::getSelectedItems() const\n{\n    return enumCollectionEditor_->getSelectedItems();\n}\n\n//-----------------------------------------------------------------------------\n// Function: EnumerationEditor::setupItems()\n//-----------------------------------------------------------------------------\nvoid EnumerationEditor::setupItems(QStringList const& availableItems, QStringList const& exclusiveItems, QStringList const& selectedItems)\n{\n    int includedItemCount = 0;\n\n    foreach(QString const& name, availableItems)\n    {\n        bool nameIsSelected = selectedItems.contains(name);\n        if (nameIsSelected)\n        {\n            includedItemCount++;\n        }\n\n        bool portIsExclusive = false;\n        if (exclusiveItems.contains(name))\n        {\n            portIsExclusive = true;\n        }\n\n        enumCollectionEditor_->addItem(name, portIsExclusive, nameIsSelected);\n    }\n\n    Qt::CheckState selectAllState = Qt::PartiallyChecked;\n    if (includedItemCount == 0)\n    {\n        selectAllState = Qt::Unchecked;\n    }\n    else if (includedItemCount == availableItems.size())\n    {\n        selectAllState = Qt::Checked;\n    }\n\n    selectAllCheck_->setCheckState(selectAllState);\n}\n"
  },
  {
    "path": "common/widgets/EnumCollectionEditor/EnumerationEditor.h",
    "content": "//-----------------------------------------------------------------------------\n// File: EnumerationEditor.h\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Mikko Teuho\n// Date: 20.01.2023\n//\n// Description:\n// Editor for enumerations.\n//-----------------------------------------------------------------------------\n\n#ifndef ENUMERATIONEDITOR_H\n#define ENUMERATIONEDITOR_H\n\n#include <QFrame>\n#include <QCheckBox>\n\nclass EnumCollectionEditor;\n\n//-----------------------------------------------------------------------------\n//! Editor for enumerations.\n//-----------------------------------------------------------------------------\nclass EnumerationEditor : public QFrame\n{\n    Q_OBJECT\n\npublic:\n    /*!\n     *  Constructor.\n     *\n     *    @param [in] hideCheckAll    Flag for hiding the check all enumerations check box.\n     *    @param [in] parent          The parent widget.\n     */\n    EnumerationEditor(bool hideCheckAll, QWidget* parent);\n\n    /*!\n     *  Destructor.\n     */\n    virtual ~EnumerationEditor() = default;\n\n    /*!\n     *  Returns the selected items.\n     */\n    QStringList getSelectedItems() const;\n\n    /*!\n     *  Setup the list of selected enumerations.\n     *\n     *    @param [in] availableItems  List of the available enumerations.\n     *    @param [in] exclusiveItems  List of exclusive enumerations.\n     *    @param [in] selectedItems   List of the selected enumerations.\n     */\n    void setupItems(QStringList const& availableItems, QStringList const& exclusiveItems, QStringList const& selectedItems);\n\nsignals:\n\n    /*!\n     *  Signal for canceling the editing.\n     */\n    void cancelEditing();\n\n    /*!\n     *  Signal for accepting the edits.\n     */\n    void finishEditing();\n\nprivate slots:\n\n    /*!\n     *  Change the state of all the enumerations.\n     *\n     *    @param [in] newState    The new state for the enumerations.\n     */\n    void onCheckAllStateChange(bool newState);\n\n    /*!\n     *  Change the state of the check all button to match the state of the enumerations.\n     *\n     *    @param [in] newState    The new state.\n     */\n    void onChangeCheckAllState(Qt::CheckState newState);\n\nprivate:\n    // Disable copying.\n    EnumerationEditor(EnumerationEditor const& rhs);\n    EnumerationEditor& operator=(EnumerationEditor const& rhs);\n\n    /*!\n     *  Setup the layout.\n     */\n    void setupLayout();\n\n    //-----------------------------------------------------------------------------\n    // Data.\n    //-----------------------------------------------------------------------------\n\n    //! The editor for enumerations.\n    EnumCollectionEditor* enumCollectionEditor_;\n\n    //! Check box for selecting / deselecting all enumerations.\n    QCheckBox* selectAllCheck_;\n};\n\n#endif // ENUMERATIONEDITOR_H\n"
  },
  {
    "path": "common/widgets/EnumCollectionEditor/InterfaceEnumEditor.cpp",
    "content": "//-----------------------------------------------------------------------------------------\n// File: InterfaceEnumEditor.cpp\n//-----------------------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Sampo Suokuisma\n// Date: 05.06.2025\n//\n// Description:\n// Class for enumerating and selecting interfaces to connect to an interconnect.\n//-----------------------------------------------------------------------------------------\n\n#include \"InterfaceEnumEditor.h\"\n\n#include <KactusAPI/include/ParameterFinder.h>\n#include <editors/ComponentEditor/common/ExpressionEditor.h>\n#include <editors/ComponentEditor/parameters/ComponentParameterModel.h>\n\n//-----------------------------------------------------------------------------\n// Function: InterfaceEnumEditor::InterfaceEnumEditor()\n//-----------------------------------------------------------------------------\nInterfaceEnumEditor::InterfaceEnumEditor(ExpressionSet expressionSet, ComponentParameterModel* parameterCompleterModel, Document::Revision docRevision, QWidget* parent)\n    : QFrame(parent),\n    mainLayout_(new QVBoxLayout(this)),\n    itemLayout_(new QGridLayout()),\n    optionalStretchLayout_(new QHBoxLayout()),\n    parameterFinder_(expressionSet.finder),\n    parameterCompleterModel_(parameterCompleterModel),\n    expressionFormatter_(expressionSet.formatter)\n{\n    setFrameStyle(QFrame::StyledPanel);\n    setFocusPolicy(Qt::StrongFocus);\n    setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Minimum);\n\n    // Container widget for all interfaces\n    QWidget* itemContainer = new QWidget();\n    itemContainer->setLayout(itemLayout_);\n\n    optionalStretchLayout_->addWidget(itemContainer);\n    mainLayout_->addLayout(optionalStretchLayout_);\n\n    setLayout(mainLayout_);\n    isStd22_ = docRevision == Document::Revision::Std22;\n}\n\n//-----------------------------------------------------------------------------\n// Function: InterfaceEnumEditor::addItems()\n//-----------------------------------------------------------------------------\nvoid InterfaceEnumEditor::addItems(const QList<InterfaceInput>& items, General::InterfaceMode interfaceMode, bool isChannel)\n{\n    if (items.isEmpty())\n    {\n        return;\n    }\n\n    QLabel* typeLabel = new QLabel();\n\n    bool isTarget = interfaceMode == General::InterfaceMode::TARGET || interfaceMode == General::InterfaceMode::SLAVE;\n    bool isMirroredTarget = interfaceMode == General::InterfaceMode::MIRRORED_TARGET || interfaceMode == General::InterfaceMode::MIRRORED_SLAVE;\n    bool isInitiator = interfaceMode == General::InterfaceMode::INITIATOR || interfaceMode == General::InterfaceMode::MASTER;\n    bool isMirroredInitiator = interfaceMode == General::InterfaceMode::MIRRORED_INITIATOR || interfaceMode == General::InterfaceMode::MIRRORED_MASTER;\n\n    if (isInitiator)\n    {\n        typeLabel->setText(isStd22_ ? \"Initiators:\" : \"Masters:\");\n    }\n    else if (isMirroredInitiator)\n    {\n        typeLabel->setText(isStd22_ ? \"Mirrored initiators:\" : \"Mirrored masters:\");\n    }\n    else if (isTarget)\n    {\n        typeLabel->setText(isStd22_ ? \"Targets:\" : \"Slaves:\");\n    }\n    else if (isMirroredTarget)\n    {\n        typeLabel->setText(isStd22_ ? \"Mirrored targets:\" : \"Mirrored slaves:\");\n    }\n\n    itemLayout_->addWidget(typeLabel, itemLayout_->rowCount(), 0);\n    typeLabel->setMaximumSize(typeLabel->sizeHint());\n\n    int rowCounter = itemLayout_->rowCount();\n\n    for (auto const& item : items)\n    {\n        auto checkBox = new QCheckBox(item.interfaceName);\n        checkBox->setToolTip(item.interfaceName);\n        checkBox->adjustSize();\n        itemLayout_->addWidget(checkBox, rowCounter, 0);\n\n        QLabel* startLabel = nullptr;\n        QLabel* rangeLabel = nullptr;\n        ExpressionEditor* startEdit = nullptr;\n        ExpressionEditor* rangeEdit = nullptr;\n\n        // Add remapping editors if interface is target-adjacent.\n        // Only show start and range editors if channel is selected (configuring start for bridge would require \n        // creating address spaces etc.).\n        if (item.isTargetAdjacent && isChannel)\n        {\n            needInterfacesStretch_ = false;\n\n            startLabel = new QLabel(\"Start:\");\n            startEdit = new ExpressionEditor(parameterFinder_);\n            connect(startEdit, SIGNAL(editingFinished()), this, SLOT(onExpressionValueEdited()), Qt::UniqueConnection);\n\n            auto startCompleter = new QCompleter(parent());\n            startCompleter->setModel(parameterCompleterModel_);\n            startEdit->setAppendingCompleter(startCompleter);\n\n            itemLayout_->addWidget(startLabel, rowCounter, 1);\n            itemLayout_->addWidget(startEdit, rowCounter, 2);\n\n            rangeLabel = new QLabel(\"Range:\");\n            rangeEdit = new ExpressionEditor(parameterFinder_);\n            connect(rangeEdit, SIGNAL(editingFinished()), this, SLOT(onExpressionValueEdited()), Qt::UniqueConnection);\n\n            auto rangeCompleter = new QCompleter(parent());\n            rangeCompleter->setModel(parameterCompleterModel_);\n            rangeEdit->setAppendingCompleter(rangeCompleter);\n\n            // Set minimum dimensions of start and range editors so that there is no unnecessary scrolling needed\n            startLabel->setFixedWidth(startLabel->sizeHint().width());\n            startLabel->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Fixed);\n\n            startEdit->setFixedHeight(ExpressionEditor::DEFAULT_HEIGHT);\n            startEdit->setMinimumWidth(0);\n            startEdit->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Fixed);\n\n            rangeLabel->setFixedWidth(rangeLabel->sizeHint().width());\n            rangeLabel->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Fixed);\n\n            rangeEdit->setFixedHeight(ExpressionEditor::DEFAULT_HEIGHT);\n            rangeEdit->setMinimumWidth(0);\n            rangeEdit->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Fixed);\n\n            itemLayout_->addWidget(rangeLabel, rowCounter, 3);\n            itemLayout_->addWidget(rangeEdit, rowCounter, 4);   \n        }\n\n        singleInterfaces_.emplace(item.interfaceName, InterfaceItem{ checkBox, startLabel, startEdit, rangeLabel, rangeEdit });\n        rowCounter++;\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: InterfaceEnumEditor::addStretchIfNeeded()\n//-----------------------------------------------------------------------------\nvoid InterfaceEnumEditor::addStretchIfNeeded()\n{\n    if (needInterfacesStretch_)\n    {\n        optionalStretchLayout_->addStretch(1);\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: InterfaceEnumEditor::limitCheckboxTextWidths()\n//-----------------------------------------------------------------------------\nvoid InterfaceEnumEditor::limitCheckboxTextWidths()\n{\n    // Limit checkbox text widths to fraction of parent widget width\n    auto maxCheckboxSize = static_cast<int>(0.2 * parentWidget()->width());\n\n    for (auto const& interfaceName : singleInterfaces_.keys())\n    {\n        auto interfaceItem = singleInterfaces_.value(interfaceName);\n\n        // Cut off interface name (elide the text) if too long and readjust checkbox\n        auto possiblyElidedText = interfaceItem.checkBox->fontMetrics().elidedText(interfaceName, Qt::ElideRight, maxCheckboxSize);\n        interfaceItem.checkBox->setText(possiblyElidedText);\n        interfaceItem.checkBox->adjustSize();\n    }\n\n    itemLayout_->invalidate();\n}\n\n//-----------------------------------------------------------------------------\n// Function: InterfaceEnumEditor::clearAll()\n//-----------------------------------------------------------------------------\nvoid InterfaceEnumEditor::clearAll() {\n\n    QLayoutItem* currentChild;\n    while ((currentChild = itemLayout_->takeAt(0)) != nullptr)\n    {\n        delete currentChild->widget();\n        delete currentChild;\n    }\n\n    singleInterfaces_.clear();\n\n    // Also clear possible stretch item for interfaces\n    needInterfacesStretch_ = true;\n    if (auto stretchItem = dynamic_cast<QSpacerItem*>(optionalStretchLayout_->itemAt(optionalStretchLayout_->count() - 1)))\n    {\n        optionalStretchLayout_->removeItem(stretchItem);\n        stretchItem->widget()->deleteLater();\n        delete stretchItem;\n    }\n\n    itemLayout_->invalidate();\n}\n\n//-----------------------------------------------------------------------------\n// Function: InterfaceEnumEditor::onExpressionValueEdited()\n//-----------------------------------------------------------------------------\nvoid InterfaceEnumEditor::onExpressionValueEdited()\n{\n    if (auto senderEditor = qobject_cast<ExpressionEditor*>(sender()))\n    {\n        senderEditor->finishEditingCurrentWord();\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: InterfaceEnumEditor::getSelectedInterfaces()\n//-----------------------------------------------------------------------------\nQList<InterfaceEnumEditor::InterfaceData> InterfaceEnumEditor::getSelectedInterfaces() const\n{\n    QList<InterfaceEnumEditor::InterfaceData> selectedInterfaces;\n\n    for (auto const& singleInterfaceName : singleInterfaces_.keys())\n    {\n        auto interfaceEditor = singleInterfaces_.value(singleInterfaceName);\n        if (interfaceEditor.checkBox->isChecked())\n        {\n            auto selectedInterfaceData = InterfaceData{\n                singleInterfaceName\n            };\n\n            if (interfaceEditor.startEdit)\n            {\n                selectedInterfaceData.startValue = interfaceEditor.startEdit->getExpression();\n            }\n\n            if (interfaceEditor.rangeEdit)\n            {\n                selectedInterfaceData.range = interfaceEditor.rangeEdit->getExpression();\n            }\n\n            selectedInterfaces.push_back(selectedInterfaceData);\n        }\n    }\n\n    return selectedInterfaces;\n}\n"
  },
  {
    "path": "common/widgets/EnumCollectionEditor/InterfaceEnumEditor.h",
    "content": "//-----------------------------------------------------------------------------------------\n// File: InterfaceEnumEditor.h\n//-----------------------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Sampo Suokuisma\n// Date: 05.06.2025\n//\n// Description:\n// Class for enumerating and selecting interfaces to connect to an interconnect.\n//-----------------------------------------------------------------------------------------\n\n#ifndef INTERFACEENUMEDITOR_H\n#define INTERFACEENUMEDITOR_H\n\n#include <IPXACTmodels/generaldeclarations.h>\n#include <IPXACTmodels/common/Document.h>\n#include <editors/common/ExpressionSet.h>\n\n#include <QFrame>\n#include <QVBoxLayout>\n#include <QScrollArea>\n#include <QCheckBox>\n#include <QLineEdit>\n#include <QLabel>\n#include <QList>\n#include <QString>\n#include <QPair>\n\nclass ExpressionEditor;\nclass ExpressionFormatter;\nclass ParameterFinder;\nclass ComponentParameterModel;\n\n/*!\n *  Class for enumerating and selecting interface points for starting or ending connections.\n */\nclass InterfaceEnumEditor : public QFrame {\n    Q_OBJECT\n\npublic:\n    /*!\n     *  Constructor.\n     *\n     *  @param [in] parent  Parent widget.\n     */\n    explicit InterfaceEnumEditor(ExpressionSet expressionSet, ComponentParameterModel* parameterCompleterModel, Document::Revision docRevision, QWidget* parent = nullptr);\n\n    /*!\n     *  Destructor.\n     */\n    virtual ~InterfaceEnumEditor() = default;\n\n    //! Contains data about interface selected in editor\n    struct InterfaceData\n    {\n        QString name;\n        QString startValue;\n        QString range;\n    };\n\n    //! Contains data about an interface to be added as option in editor\n    struct InterfaceInput\n    {\n        QString interfaceName;\n\n        //! Flag indicating if the interface is able to \n        //! 1) connect to the bridge initiator(s), if interconnect is using bridge or\n        //! 2) connect to the interconnect tomponent mirrored target, if interconnect is using channel\n        bool isTargetAdjacent;\n    };\n\n    /*!\n     *  Get the details of selected interfaces.\n     *\n     *  @return List of interface data including names and address information.\n     */\n    QList<InterfaceData> getSelectedInterfaces() const;\n\n    /*!\n     *  Add a list of interface names to the editor.\n     *\n     *  @param [in] items         List of interface names to add.\n     *  @param [in] interfaceMode The mode of the interface.\n     *  @param [in] isChannel     True, if interconnect type is channel, otherwise false.\n     */\n    void addItems(const QList<InterfaceInput>& items, General::InterfaceMode interfaceMode, bool isChannel);\n\n    /*!\n     *\tAdd stretch to interfaces layout, if instance has no target-adjacent interfaces and used mode is channel.\n     *  Aligns non-target-adjacent interfaces properly.\n     */\n    void addStretchIfNeeded();\n\n    /*!\n     *\tLimit width of interface checkbox texts to fraction of parent widget width if needed.\n     */\n    void limitCheckboxTextWidths();\n\n    /*!\n     *  Remove all interface entries from the editor.\n     */\n    void clearAll();\n\n\nsignals:\n    /*!\n     *  Emitted when an endpoint interface is checked.\n     *\n     *  @param interfaceName  Name of the interface.\n     *  @param instanceName   Name of the associated instance.\n     */\n    void endpointInterfaceChecked(const QString& interfaceName, const QString& instanceName);\n\n    /*!\n     *  Emitted when an endpoint interface is unchecked.\n     *\n     *  @param interfaceName  Name of the interface.\n     *  @param instanceName   Name of the associated instance.\n     */\n    void endpointInterfaceUnchecked(const QString& interfaceName, const QString& instanceName);\n\n    /*!\n     *  Emitted when a starting point interface is checked.\n     *\n     *  @param interfaceName  Name of the interface.\n     *  @param instanceName   Name of the associated instance.\n     */\n    void startingPointInterfaceChecked(const QString& interfaceName, const QString& instanceName);\n\n    /*!\n     *  Emitted when a starting point interface is unchecked.\n     *\n     *  @param interfaceName  Name of the interface.\n     *  @param instanceName   Name of the associated instance.\n     */\n    void startingPointInterfaceUnchecked(const QString& interfaceName, const QString& instanceName);\n\nprivate slots:\n\n    //! Handles finishing editing of current word when focus is moved from calling editor\n    void onExpressionValueEdited();\n\nprivate:\n\n    /*!\n     *  Struct representing the UI elements associated with a single interface.\n     */\n    struct InterfaceItem\n    {\n        QCheckBox* checkBox;       /*!< Checkbox to enable or disable the interface. */\n        QLabel* startLabel;        /*!< Label for the start address. */\n        ExpressionEditor* startEdit;      /*!< Input field for the start address. */\n        QLabel* rangeLabel;        /*!< Label for the address range. */\n        ExpressionEditor* rangeEdit;      /*!< Input field for the address range. */\n    };\n\n    //! Map of displayed interface names and related widgets\n    QHash<QString, InterfaceItem> singleInterfaces_;\n\n    //! Main layout for the editor.\n    QVBoxLayout* mainLayout_;\n\n    //! Layout for interfaces and related widgets\n    QGridLayout* itemLayout_;\n\n    /*\n     *   Layout holding the gridlayout containing interfaces etc.\n     *   Possible to add stretch to end of layout, if no target adjacent interfaces are added\n     *   in order to align interface checkbox to the left.\n     *   Need for stretch must be checked in dialog.\n     */\n    QHBoxLayout* optionalStretchLayout_;\n\n    //! Keeps track of need to add stretch to interfaces based on added interfaces.\n    bool needInterfacesStretch_ = true;\n\n    //! Parameter finder for expression editors. Should use parameters of generated interconnect component.\n    QSharedPointer<ParameterFinder> parameterFinder_;\n\n    //! Parameter completer model for expression editors.\n    ComponentParameterModel* parameterCompleterModel_;\n\n    //! Formatter for interface start and range expressions.\n    QSharedPointer<ExpressionFormatter> expressionFormatter_;\n\n    //! Flag indicating the standard revision in use.\n    bool isStd22_ = true;\n};\n\n#endif\n"
  },
  {
    "path": "common/widgets/FileSelector/fileselector.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: fileselector.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Antti Kamppi\r\n// Date: 11.6.2013\r\n//\r\n// Description:\r\n// Used to select one file from the component's file sets.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"fileselector.h\"\r\n\r\n#include <IPXACTmodels/Component/Component.h>\r\n#include <IPXACTmodels/Component/FileSet.h>\r\n\r\n#include <QFileInfo>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: fileselector::FileSelector()\r\n//-----------------------------------------------------------------------------\r\nFileSelector::FileSelector( QSharedPointer<Component> component, QWidget *parent ):\r\nQComboBox(parent),\r\ncomponent_(component),\r\nfilters_()\r\n{\r\n\tQ_ASSERT(component_);\r\n\r\n\tsetEditable(false);\r\n\r\n\tconnect(this, SIGNAL(currentIndexChanged(int)), this, SLOT(onIndexChange(int)), Qt::UniqueConnection);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: fileselector::~FileSelector()\r\n//-----------------------------------------------------------------------------\r\nFileSelector::~FileSelector()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileSelector::addFilter()\r\n//-----------------------------------------------------------------------------\r\nvoid FileSelector::addFilter( const QString& suffix )\r\n{\r\n    if (suffix.isEmpty())\r\n    {\r\n        return;\r\n    }\r\n\r\n    // add the new filter\r\n    filters_.append(suffix);\r\n\r\n    // and refresh the combo box to display changes\r\n    refresh();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileSelector::clearFilters()\r\n//-----------------------------------------------------------------------------\r\nvoid FileSelector::clearFilters()\r\n{\r\n    filters_.clear();\r\n    refresh();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: fileselector::refresh()\r\n//-----------------------------------------------------------------------------\r\nvoid FileSelector::refresh()\r\n{\r\n\tdisconnect(this, SIGNAL(currentIndexChanged(int)), this, SLOT(onIndexChange(int)));\r\n\r\n\t// the file which is currently selected\r\n\tQString previouslySelected = currentText();\r\n\r\n\t// remove the previous items\r\n\tclear();\r\n\r\n\t// ask component for it's files\r\n    QStringList allFiles = getFileNames(component_);\r\n\r\n\t// all files that matched filters\r\n\tQStringList results;\r\n\r\n\t// filter the files according to given filters\r\n\tforeach (QString filePath, allFiles)\r\n    {\r\n\t\tif (filePath.isEmpty())\r\n        {\r\n\t\t\tcontinue;\r\n        }\r\n\r\n        if ( filters_.empty() )\r\n        {\r\n            results.append(filePath);\r\n        }\r\n        else\r\n        {\r\n            // if the file suffix is found in the filters\r\n            QFileInfo fileInfo(filePath);\r\n            if (filters_.contains(fileInfo.suffix()))\r\n            {\r\n                results.append(filePath);\r\n            }\r\n        }\r\n\t}\r\n\t// add also an empty item\r\n\taddItem(\"\");\r\n\taddItems(results);\r\n\r\n\tint index = findText(previouslySelected);\r\n\r\n\t// if the item is not found\r\n\tif (index < 0)\r\n    {\r\n\t\t// select the empty file\r\n\t\tindex = 0;\r\n\t}\r\n\r\n\tsetCurrentIndex(index);\r\n\r\n\tconnect(this, SIGNAL(currentIndexChanged(int)), this, SLOT(onIndexChange(int)), Qt::UniqueConnection);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: fileselector::selectFile()\r\n//-----------------------------------------------------------------------------\r\nvoid FileSelector::selectFile( const QString& filePath )\r\n{\r\n\tdisconnect(this, SIGNAL(currentIndexChanged(int)), this, SLOT(onIndexChange(int)));\r\n\r\n\tint index = findText(filePath);\r\n\r\n\t// if the item is not found\r\n\tif (index < 0)\r\n    {\r\n\t\t// select the empty file\r\n\t\tindex = 0;\r\n\t}\r\n\r\n\tsetCurrentIndex(index);\r\n\r\n\tconnect(this, SIGNAL(currentIndexChanged(int)), this, SLOT(onIndexChange(int)), Qt::UniqueConnection);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: fileselector::onIndexChange()\r\n//-----------------------------------------------------------------------------\r\nvoid FileSelector::onIndexChange( int newIndex )\r\n{\r\n\t// Find the text for the index.\r\n\tQString filePath = itemText(newIndex);\r\n\r\n\t// Find corresponding IP-XACT objects.\r\n\tQSharedPointer<FileSet> fileSet = fileSets_[filePath];\r\n\r\n\t// Emit signal with complete data.\r\n\temit fileSelected(filePath,fileSet);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: fileselector::getFileNames()\r\n//-----------------------------------------------------------------------------\r\nQStringList FileSelector::getFileNames(QSharedPointer<Component> component)\r\n{\r\n    QStringList fileNames;\r\n\r\n    foreach (QSharedPointer<FileSet> fileSet, *component->getFileSets())\r\n\t{\r\n\t\tforeach (QSharedPointer<File> file, *fileSet->getFiles())\r\n\t\t{\r\n\t\t\tfileSets_[file->name()] = fileSet;\r\n\t\t\tfileNames.append(file->name());\r\n\t\t}\r\n    }\r\n\r\n    return fileNames;\r\n}"
  },
  {
    "path": "common/widgets/FileSelector/fileselector.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: fileselector.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Antti Kamppi\r\n// Date: 11.6.2013\r\n//\r\n// Description:\r\n// Used to select one file from the component's file sets.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef FILESELECTOR_H\r\n#define FILESELECTOR_H\r\n\r\n#include <QComboBox>\r\n#include <QSharedPointer>\r\n#include <QStringList>\r\n\r\nclass Component;\r\nclass FileSet;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Used to select one file from the component's file sets.\r\n//-----------------------------------------------------------------------------\r\nclass FileSelector : public QComboBox\r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\r\n\t/*!\r\n     *  The constructor.\r\n\t *\r\n\t *    @param [in] component   Pointer to the component whose files are selected.\r\n\t *    @param [in] parent      Pointer to the owner of the combo box.\r\n\t */\r\n\tFileSelector(QSharedPointer<Component> component, QWidget *parent);\r\n\t\r\n\t//! The destructor.\r\n\tvirtual ~FileSelector();\r\n\r\n\t/*!\r\n     *  Add a file suffix to be used as filter when selecting files to display.\r\n\t *\r\n\t *    @param [in] suffix  The file suffix to use as filter.\r\n\t */\r\n\tvoid addFilter(const QString& suffix);\r\n\r\n    /*!\r\n     *  Clear the filters.\r\n     */\r\n    void clearFilters();\r\n\r\npublic slots:\r\n\r\n\t//! Refresh the items to be selected in the combo box.\r\n\tvoid refresh();\r\n\r\n\t/*!\r\n     *  Set the specified file as selected.\r\n\t *\r\n\t *    @param [in] filePath    The file path of the file to select.\r\n\t */\r\n\tvoid selectFile(const QString& filePath);\r\n\r\nsignals:\r\n\r\n\t//! Emitted when a file is selected.\r\n\tvoid fileSelected(const QString& filePath, QSharedPointer<FileSet> fileSet);\r\n\r\nprivate slots:\r\n\r\n\t//! Handler for selected index changes.\r\n\tvoid onIndexChange(int newIndex);\r\n\r\nprivate:\r\n\t\r\n    /*!\r\n     *  Get the file names.\r\n     *\r\n     *    @param [in] component   The component to search the files from.\r\n     */\r\n    QStringList getFileNames(QSharedPointer<Component> component);\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n\t//! No copying.\r\n\tFileSelector(const FileSelector& other);\r\n\r\n\t//! No assignment.\r\n\tFileSelector& operator=(const FileSelector& other);\r\n\r\n\t//! Pointer to the component containing the files.\r\n\tQSharedPointer<Component> component_;\r\n\r\n\t//! Contains the file suffixes used to filter file types.\r\n\tQStringList filters_;\r\n\r\n\t//! Contains IP-XACT file sets indexed by the file name/path.\r\n\tQMap<QString,QSharedPointer<FileSet> > fileSets_;\r\n};\r\n\r\n#endif // FILESELECTOR_H\r\n"
  },
  {
    "path": "common/widgets/GroupBoxWithAlertSign/GroupBoxWithAlertSign.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: GroupBoxWithAlertSign.h\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Vasilii Feshchenko\n// Date: 05.06.2024\n//\n// Description:\n// Group box with an alert sign in the title.\n// The main parts of the code have been created by Michael Scopchanov\n// Git hub: https://github.com/scopchanov/SO-DecoratedGroupBox.git ,\n// stackoverflow answer by Michael Scopchanov: https://stackoverflow.com/a/52630998 . \n// Read copyright below. \n//-----------------------------------------------------------------------------\n\n/**\nMIT License\n\nCopyright (c) 2018 Michael Scopchanov\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n*/\n\n#include<common/widgets/GroupBoxWithAlertSign/GroupBoxWithAlertSign.h>\n#include<common/widgets/GroupBoxWithAlertSign/StyleGroupBoxWithAlertSign.h>\n#include<common/widgets/GroupBoxWithAlertSign/StyleOptionGroupBoxWithAlertSign.h>\n#include <QVBoxLayout>\n#include <QIcon>\n#include <QPixmap>\n#include <QPainter>\n\n\n//-----------------------------------------------------------------------------\n// Function: GroupBoxWithAlertSign::GroupBoxWithAlertSign()\n//-----------------------------------------------------------------------------\nGroupBoxWithAlertSign::GroupBoxWithAlertSign(QString title, QWidget* parent) :\n\tQGroupBox(title, parent),\n\toffset_(5),\n\tleftSpace_(3),\n\trightSpace_(3),\n\tverticalIconOffset_(-3),\n\tisAlerted_(false)\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: GroupBoxWithAlertSign::getPixmap()\n//-----------------------------------------------------------------------------\nQPixmap GroupBoxWithAlertSign::getPixmap() const\n{\n\treturn pixmap_;\n}\n\n//-----------------------------------------------------------------------------\n// Function: GroupBoxWithAlertSign::setPixmap()\n//-----------------------------------------------------------------------------\nvoid GroupBoxWithAlertSign::setPixmap(const QPixmap& pixmap)\n{\n\tpixmap_ = pixmap;\n\tupdate();\n}\n\n//-----------------------------------------------------------------------------\n// Function: GroupBoxWithAlertSign::getOffset()\n//-----------------------------------------------------------------------------\nint GroupBoxWithAlertSign::getOffset() const\n{\n\treturn offset_;\n}\n\n//-----------------------------------------------------------------------------\n// Function: GroupBoxWithAlertSign::setOffset()\n//-----------------------------------------------------------------------------\nvoid GroupBoxWithAlertSign::setOffset(int offset)\n{\n\toffset_ = offset;\n\tupdate();\n}\n\n//-----------------------------------------------------------------------------\n// Function: GroupBoxWithAlertSign::getLeftSpace()\n//-----------------------------------------------------------------------------\nint GroupBoxWithAlertSign::getLeftSpace() const\n{\n\treturn leftSpace_;\n}\n\n//-----------------------------------------------------------------------------\n// Function: GroupBoxWithAlertSign::setLeftSpace()\n//-----------------------------------------------------------------------------\nvoid GroupBoxWithAlertSign::setLeftSpace(int leftSpace)\n{\n\tleftSpace_ = leftSpace;\n\tupdate();\n}\n\n//-----------------------------------------------------------------------------\n// Function: GroupBoxWithAlertSign::getRightSpace()\n//-----------------------------------------------------------------------------\nint GroupBoxWithAlertSign::getRightSpace() const\n{\n\treturn rightSpace_;\n}\n\n//-----------------------------------------------------------------------------\n// Function: GroupBoxWithAlertSign::setRightSpace()\n//-----------------------------------------------------------------------------\nvoid GroupBoxWithAlertSign::setRightSpace(int rightSpace)\n{\n\trightSpace_ = rightSpace;\n\tupdate();\n}\n\n//-----------------------------------------------------------------------------\n// Function: GroupBoxWithAlertSign::setSpaces()\n//-----------------------------------------------------------------------------\nvoid GroupBoxWithAlertSign::setSpaces(int leftSpace, int rightSpace)\n{\n\tsetLeftSpace(leftSpace);\n\tsetRightSpace(rightSpace);\n}\n\n//-----------------------------------------------------------------------------\n// Function: GroupBoxWithAlertSign::paintEvent()\n//-----------------------------------------------------------------------------\nvoid GroupBoxWithAlertSign::paintEvent(QPaintEvent* /*event*/)\n{\n\tStyleGroupBoxWithAlertSign style;\n\tQPainter painter(this);\n\tStyleOptionGroupBoxWithAlertSign option;\n\n\tinitStyleOption(&option);\n\toption.setPixmap(pixmap_);\n\toption.setOffset(offset_);\n\toption.setLeftSpace(leftSpace_);\n\toption.setRightSpace(rightSpace_);\n\n\tstyle.drawComplexControl(QStyle::CC_GroupBox, &option, &painter, this);\n}\n\n//-----------------------------------------------------------------------------\n// Function: GroupBoxWithAlertSign::setAlertIcon()\n//-----------------------------------------------------------------------------\nvoid GroupBoxWithAlertSign::setAlertIcon()\n{\n\tif (!isAlerted_)\n\t{\n\t\tsetPixmap(QIcon(\":/icons/common/graphics/exclamation--frame.png\").pixmap(QSize(22, 22)));\n\t\tisAlerted_ = true;\n\t}\t\n}\n\n//-----------------------------------------------------------------------------\n// Function: GroupBoxWithAlertSign::removeAlertIcon()\n//-----------------------------------------------------------------------------\nvoid GroupBoxWithAlertSign::removeAlertIcon()\n{\n\tif (isAlerted_)\n\t{\n\t\tsetPixmap(QPixmap());\n\t\tisAlerted_ = false;\n\t}\n}\n\n//-----------------------------------------------------------------------------\n// Function: GroupBoxWithAlertSign::getVerticalIconOffset()\n//-----------------------------------------------------------------------------\nint GroupBoxWithAlertSign::getVerticalIconOffset() const {\n\treturn verticalIconOffset_;\n}\n\n//-----------------------------------------------------------------------------\n// Function: GroupBoxWithAlertSign::setVerticalIconOffset()\n//-----------------------------------------------------------------------------\nvoid GroupBoxWithAlertSign::setVerticalIconOffset(int verticalOffset) {\n\tverticalIconOffset_ = verticalOffset;\n\tupdate();\n}"
  },
  {
    "path": "common/widgets/GroupBoxWithAlertSign/GroupBoxWithAlertSign.h",
    "content": "//-----------------------------------------------------------------------------\n// File: GroupBoxWithAlertSign.h\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Vasilii Feshchenko\n// Date: 05.06.2024\n//\n// Description:\n// Group box with an alert sign in the title.\n// The main parts of the code have been created by Michael Scopchanov\n// Git hub: https://github.com/scopchanov/SO-DecoratedGroupBox.git ,\n// stackoverflow answer by Michael Scopchanov: https://stackoverflow.com/a/52630998 . \n// Read copyright below. \n//-----------------------------------------------------------------------------\n\n/**\nMIT License\n\nCopyright (c) 2018 Michael Scopchanov\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n*/\n\n#ifndef GROUPBOXWITHALERTSIGN_H\n#define GROUPBOXWITHALERTSIGN_H\n\n#include <QGroupBox>\n#include <QString>\n\n\n //-----------------------------------------------------------------------------\n //! Group box with an alert sign in the title.\n //-----------------------------------------------------------------------------\nclass GroupBoxWithAlertSign : public QGroupBox\n{\n\tQ_OBJECT\n\npublic:\n\t/*!\n\t *\tConstructor.\n\t *\n\t *\t\t@param\t[in]\ttitle\t\tThe title of the group box.\n\t *\t\t@param\t[in]\tparent\t\tThe parent widget of the group box. Defaults to nullptr.\n\t */\n\texplicit GroupBoxWithAlertSign(QString title, QWidget* parent = nullptr);\n\n\t/*!\n\t *\tRetrieves the pixmap used for the alert icon.\n\t *\n\t *\t\t@return\tThe pixmap representing the alert icon.\n\t */\n\tQPixmap getPixmap() const;\n\n\t/*!\n\t *\tSets the pixmap for the alert icon.\n\t *\n\t *\t\t@param\t[in]\tpixmap\t\tThe new pixmap to use for the alert icon.\n\t */\n\tvoid setPixmap(const QPixmap& pixmap);\n\n\t/*!\n\t *\tRetrieves the offset for the alert icon from the left boundary.\n\t *\n\t *\t\t@return\tThe current offset for the alert icon.\n\t */\n\tint getOffset() const;\n\n\t/*!\n\t *\tSets the offset for the alert icon from the left boundary.\n\t *\n\t *\t\t@param\t[in]\toffset\t\tThe new offset to set for the alert icon.\n\t */\n\tvoid setOffset(int offset);\n\n\t/*!\n\t *\tRetrieves the left spacing for the alert icon.\n\t *\n\t *\t\t@return\tThe current left spacing for the icon.\n\t */\n\tint getLeftSpace() const;\n\n\t/*!\n\t *\tSets the left spacing for the alert icon.\n\t *\n\t *\t\t@param\t[in]\tleftSpace\tThe new left spacing to set for the icon.\n\t */\n\tvoid setLeftSpace(int leftSpace);\n\n\t/*!\n\t *\tRetrieves the right spacing for the alert icon.\n\t *\n\t *\t\t@return\tThe current right spacing for the icon.\n\t */\n\tint getRightSpace() const;\n\n\t/*!\n\t *\tSets the right spacing for the alert icon.\n\t *\n\t *\t\t@param\t[in]\trightSpace\tThe new right spacing to set for the icon.\n\t */\n\tvoid setRightSpace(int rightSpace);\n\n\t/*!\n\t *\tSets both the left and right spacing for the alert icon simultaneously.\n\t *\n\t *\t\t@param\t[in]\tleftSpace\tThe left spacing to set.\n\t *\t\t@param\t[in]\trightSpace\tThe right spacing to set.\n\t */\n\tvoid setSpaces(int leftSpace, int rightSpace);\n\n\t/*!\n\t *\tRetrieves the vertical offset for the alert icon.\n\t *\n\t *\t\t@return\tThe current vertical offset for the alert icon.\n\t */\n\tint getVerticalIconOffset() const;\n\n\t/*!\n\t *\tSets the vertical offset for the alert icon.\n\t *\n\t *\t\t@param\t[in]\tverticalOffset\tThe new vertical offset to set for the icon.\n\t */\n\tvoid setVerticalIconOffset(int verticalOffset);\n\nprotected:\n\t/*!\n\t *\tCustom paint event to handle the drawing of the group box with the alert icon.\n\t *\n\t *\t\t@param\t[in]\tevent\t\tThe paint event.\n\t */\n\tvoid paintEvent(QPaintEvent* event) override;\n\n\t/*!\n\t *\tSets the alert icon to a predefined icon. This method configures the pixmap\n\t *\tused for the alert based on a standard icon.\n\t */\n\tvoid setAlertIcon();\n\n\t/*!\n\t *\tRemoves the alert icon, making it invisible within the group box.\n\t */\n\tvoid removeAlertIcon();\n\nprivate:\n\t//! Pixmap for the alert icon.\n\tQPixmap pixmap_;\n\n\t//! Offset for the icon.\n\tint offset_;\n\n\t//! Left space for the icon.\n\tint leftSpace_;\n\n\t//! Right space for the icon.\n\tint rightSpace_;\n\n\t//! Vertical offset for the icon.\n\tint verticalIconOffset_;\n\n\t//! Determines if alert sign is present in the UI of the group box\n\tbool isAlerted_;\n};\n\n#endif // GROUPBOXWITHALERTSIGN_H"
  },
  {
    "path": "common/widgets/GroupBoxWithAlertSign/StyleGroupBoxWithAlertSign.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: GroupBoxWithAlertSign.h\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Vasilii Feshchenko\n// Date: 05.06.2024\n//\n// Description:\n// Group box with an alert sign in the title.\n// The main parts of the code have been created by Michael Scopchanov\n// Git hub: https://github.com/scopchanov/SO-DecoratedGroupBox.git ,\n// stackoverflow answer by Michael Scopchanov: https://stackoverflow.com/a/52630998 . \n// Read copyright below. \n//-----------------------------------------------------------------------------\n\n/**\nMIT License\n\nCopyright (c) 2018 Michael Scopchanov\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n*/\n\n#include<common/widgets/GroupBoxWithAlertSign/StyleOptionGroupBoxWithAlertSign.h>\n#include<common/widgets/GroupBoxWithAlertSign/GroupBoxWithAlertSign.h>\n#include<common/widgets/GroupBoxWithAlertSign/StyleGroupBoxWithAlertSign.h>\n#include <QPainter>\n\n//-----------------------------------------------------------------------------\n// Function: StyleGroupBoxWithAlertSign::StyleGroupBoxWithAlertSign()\n//-----------------------------------------------------------------------------\nStyleGroupBoxWithAlertSign::StyleGroupBoxWithAlertSign() :\n    QCommonStyle()\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: StyleGroupBoxWithAlertSign::drawComplexControl()\n//-----------------------------------------------------------------------------\nvoid StyleGroupBoxWithAlertSign::drawComplexControl(QStyle::ComplexControl cc, const QStyleOptionComplex* opt, QPainter* p, const QWidget* widget) const {\n    if (const StyleOptionGroupBoxWithAlertSign* groupBox = qstyleoption_cast<const StyleOptionGroupBoxWithAlertSign*>(opt)) {\n        QRect textRect = proxy()->subControlRect(CC_GroupBox, opt, SC_GroupBoxLabel, widget);\n        QRect checkBoxRect = proxy()->subControlRect(CC_GroupBox, opt, SC_GroupBoxCheckBox, widget);\n        int decorationOffset = 0;\n        int pixmapRectWidth = 0;\n        int pixmapHeight = 0;\n        int textOffset = 0;\n\n        if (!groupBox->getPixmap().isNull()) {\n            decorationOffset = groupBox->getOffset();\n            pixmapRectWidth = groupBox->getLeftSpace()\n                + groupBox->getPixmap().width()\n                + groupBox->getRightSpace();\n            pixmapHeight = groupBox->getPixmap().height();\n            textOffset = decorationOffset + pixmapRectWidth;\n        }\n\n        textRect.adjust(textOffset, 0, textOffset, 0);\n\n\n        if (groupBox->subControls & QStyle::SC_GroupBoxFrame) {\n            QStyleOptionFrame frame;\n            frame.QStyleOption::operator=(*groupBox);\n            frame.features = groupBox->features;\n            frame.lineWidth = groupBox->lineWidth;\n            frame.midLineWidth = groupBox->midLineWidth;\n            frame.rect = proxy()->subControlRect(CC_GroupBox, opt, SC_GroupBoxFrame, widget);\n            p->save();\n            QRegion region(groupBox->rect);\n            if (!groupBox->text.isEmpty()) {\n                bool ltr = groupBox->direction == Qt::LeftToRight;\n                QRect finalRect = groupBox->subControls & QStyle::SC_GroupBoxCheckBox ?\n                    checkBoxRect.united(textRect) :\n                    textRect;\n                finalRect.adjust(ltr ? -4 : 0, 0, ltr ? 0 : 4, 0);\n                region -= finalRect;\n            }\n            p->setClipRegion(region);\n            proxy()->drawPrimitive(PE_FrameGroupBox, &frame, p, widget);\n            p->restore();\n        }\n\n\n        if (!groupBox->getPixmap().isNull()) {\n            const GroupBoxWithAlertSign* groupBoxWidget = qobject_cast<const GroupBoxWithAlertSign*>(widget);\n            int verticalOffset = groupBoxWidget ? groupBoxWidget->getVerticalIconOffset() : 0;\n            p->fillRect(decorationOffset, verticalOffset, pixmapRectWidth, pixmapHeight, opt->palette.window().color());\n            proxy()->drawItemPixmap(p, QRect(decorationOffset, verticalOffset, pixmapRectWidth, pixmapHeight),\n                Qt::AlignCenter, groupBox->getPixmap());\n        }\n\n\n        if ((groupBox->subControls & QStyle::SC_GroupBoxLabel) && !groupBox->text.isEmpty()) {\n            QColor textColor = groupBox->textColor;\n            if (textColor.isValid())\n                p->setPen(textColor);\n            int alignment = int(groupBox->textAlignment);\n            if (!proxy()->styleHint(QStyle::SH_UnderlineShortcut, opt, widget))\n                alignment |= Qt::TextHideMnemonic;\n            proxy()->drawItemText(p, textRect, Qt::TextShowMnemonic | Qt::AlignHCenter | alignment,\n                groupBox->palette, groupBox->state & State_Enabled, groupBox->text,\n                textColor.isValid() ? QPalette::NoRole : QPalette::WindowText);\n            if (groupBox->state & State_HasFocus) {\n                QStyleOptionFocusRect fropt;\n                fropt.QStyleOption::operator=(*groupBox);\n                fropt.rect = textRect;\n                proxy()->drawPrimitive(PE_FrameFocusRect, &fropt, p, widget);\n            }\n        }\n    }\n    else {\n        QCommonStyle::drawComplexControl(cc, opt, p, widget);\n    }\n}"
  },
  {
    "path": "common/widgets/GroupBoxWithAlertSign/StyleGroupBoxWithAlertSign.h",
    "content": "//-----------------------------------------------------------------------------\n// File: GroupBoxWithAlertSign.h\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Vasilii Feshchenko\n// Date: 05.06.2024\n//\n// Description:\n// Group box with an alert sign in the title.\n// The main parts of the code have been created by Michael Scopchanov\n// Git hub: https://github.com/scopchanov/SO-DecoratedGroupBox.git ,\n// stackoverflow answer by Michael Scopchanov: https://stackoverflow.com/a/52630998 . \n// Read copyright below. \n//-----------------------------------------------------------------------------\n\n/**\nMIT License\n\nCopyright (c) 2018 Michael Scopchanov\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n*/\n\n#ifndef STYLEGROUPBOXWITHALERTSIGN_H\n#define STYLEGROUPBOXWITHALERTSIGN_H\n\n#include <QCommonStyle>\n\n//-----------------------------------------------------------------------------\n//! Style for GroupBoxWithAlertSign\n//-----------------------------------------------------------------------------\nclass StyleGroupBoxWithAlertSign : public QCommonStyle\n{\n\tQ_OBJECT\npublic:\n    /*!\n     *\tConstructor.\n     */\n    explicit StyleGroupBoxWithAlertSign();\n\n    /*!\n     *\tDraws complex control for the group box with alert sign.\n     *\n     *    @param [in] cc         The complex control to draw.\n     *    @param [in] opt        The style options for drawing.\n     *    @param [in] p          The painter object for drawing.\n     *    @param [in] widget     The widget to draw on.\n     * \n     *      @remarks    The function is slightly altered to incorporate vertical offset.\n     *                  To better understand structure of the funcition refer  to the source \n     *                  Git Hub page (check header comment for link).\n     *                              \n     */\n    void drawComplexControl(ComplexControl cc, const QStyleOptionComplex* opt, QPainter* p, const QWidget* widget) const override;\n};\n#endif // STYLEGROUPBOXWITHALERTSIGN_H"
  },
  {
    "path": "common/widgets/GroupBoxWithAlertSign/StyleOptionGroupBoxWithAlertSign.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: GroupBoxWithAlertSign.h\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Vasilii Feshchenko\n// Date: 05.06.2024\n//\n// Description:\n// Group box with an alert sign in the title.\n// The main parts of the code have been created by Michael Scopchanov\n// Git hub: https://github.com/scopchanov/SO-DecoratedGroupBox.git ,\n// stackoverflow answer by Michael Scopchanov: https://stackoverflow.com/a/52630998 . \n// Read copyright below. \n//-----------------------------------------------------------------------------\n\n/**\nMIT License\n\nCopyright (c) 2018 Michael Scopchanov\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n*/\n\n#include<common/widgets/GroupBoxWithAlertSign/StyleOptionGroupBoxWithAlertSign.h>\n//-----------------------------------------------------------------------------\n// Function: StyleOptionGroupBoxWithAlertSign::StyleOptionGroupBoxWithAlertSign()\n//-----------------------------------------------------------------------------\nStyleOptionGroupBoxWithAlertSign::StyleOptionGroupBoxWithAlertSign() :\n    QStyleOptionGroupBox(),\n    offset_(0),\n    leftSpace_(0),\n    rightSpace_(0)\n{\n    // Constructor\n}\n\n//-----------------------------------------------------------------------------\n// Function: StyleOptionGroupBoxWithAlertSign::getPixmap()\n//-----------------------------------------------------------------------------\nQPixmap StyleOptionGroupBoxWithAlertSign::getPixmap() const {\n    return pixmap_;\n}\n\n//-----------------------------------------------------------------------------\n// Function: StyleOptionGroupBoxWithAlertSign::setPixmap()\n//-----------------------------------------------------------------------------\nvoid StyleOptionGroupBoxWithAlertSign::setPixmap(QPixmap pixmap) {\n    pixmap_ = pixmap;\n}\n\n//-----------------------------------------------------------------------------\n// Function: StyleOptionGroupBoxWithAlertSign::getOffset()\n//-----------------------------------------------------------------------------\nint StyleOptionGroupBoxWithAlertSign::getOffset() const {\n    return offset_;\n}\n\n//-----------------------------------------------------------------------------\n// Function: StyleOptionGroupBoxWithAlertSign::setOffset()\n//-----------------------------------------------------------------------------\nvoid StyleOptionGroupBoxWithAlertSign::setOffset(int offset) {\n    offset_ = offset;\n}\n\n//-----------------------------------------------------------------------------\n// Function: StyleOptionGroupBoxWithAlertSign::getLeftSpace()\n//-----------------------------------------------------------------------------\nint StyleOptionGroupBoxWithAlertSign::getLeftSpace() const {\n    return leftSpace_;\n}\n\n//-----------------------------------------------------------------------------\n// Function: StyleOptionGroupBoxWithAlertSign::setLeftSpace()\n//-----------------------------------------------------------------------------\nvoid StyleOptionGroupBoxWithAlertSign::setLeftSpace(int leftSpace) {\n    leftSpace_ = leftSpace;\n}\n\n//-----------------------------------------------------------------------------\n// Function: StyleOptionGroupBoxWithAlertSign::getRightSpace()\n//-----------------------------------------------------------------------------\nint StyleOptionGroupBoxWithAlertSign::getRightSpace() const {\n    return rightSpace_;\n}\n\n//-----------------------------------------------------------------------------\n// Function: StyleOptionGroupBoxWithAlertSign::setRightSpace()\n//-----------------------------------------------------------------------------\nvoid StyleOptionGroupBoxWithAlertSign::setRightSpace(int rightSpace) {\n    rightSpace_ = rightSpace;\n}"
  },
  {
    "path": "common/widgets/GroupBoxWithAlertSign/StyleOptionGroupBoxWithAlertSign.h",
    "content": "//-----------------------------------------------------------------------------\n// File: GroupBoxWithAlertSign.h\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Vasilii Feshchenko\n// Date: 05.06.2024\n//\n// Description:\n// Group box with an alert sign in the title.\n// The main parts of the code have been created by Michael Scopchanov\n// Git hub: https://github.com/scopchanov/SO-DecoratedGroupBox.git ,\n// stackoverflow answer by Michael Scopchanov: https://stackoverflow.com/a/52630998 . \n// Read copyright below. \n//-----------------------------------------------------------------------------\n\n/**\nMIT License\n\nCopyright (c) 2018 Michael Scopchanov\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n*/\n\n#ifndef STYLEOPTIONGROUPBOXWITHALERTSIGN_H\n#define STYLEOPTIONGROUPBOXWITHALERTSIGN_H\n\n#include <QStyleOptionGroupBox>\n#include <QPixmap>\n\n//-----------------------------------------------------------------------------\n//! Style Option for GroupBoxWithAlertSign\n//-----------------------------------------------------------------------------\nclass StyleOptionGroupBoxWithAlertSign : public QStyleOptionGroupBox\n{\npublic:\n\t/*!\n\t *\tConstructor.\n\t */\n\texplicit StyleOptionGroupBoxWithAlertSign();\n\n\t/*!\n\t *\tRetrieves the pixmap used for the alert icon.\n\t *\n\t *\t\t@return The current pixmap of the alert icon.\n\t */\n\tQPixmap getPixmap() const;\n\n\t/*!\n\t *\tSets the pixmap for the alert icon.\n\t *\n\t *\t\t@param\t[in]\tpixmap\t\tThe pixmap to set for the alert icon.\n\t */\n\tvoid setPixmap(QPixmap pixmap);\n\n\t/*!\n\t *\tRetrieves the offset for the alert icon.\n\t *\n\t *\t\t@return The current offset for the alert icon.\n\t */\n\tint getOffset() const;\n\n\t/*!\n\t *\tSets the offset for the alert icon.\n\t *\n\t *\t\t@param\t[in]\toffset\t\tThe new offset to set for the alert icon.\n\t */\n\tvoid setOffset(int offset);\n\n\t/*!\n\t *\tRetrieves the left spacing for the alert icon.\n\t *\n\t *\t\t@return The current left spacing for the alert icon.\n\t */\n\tint getLeftSpace() const;\n\n\t/*!\n\t *\tSets the left spacing for the alert icon.\n\t *\n\t *\t\t@param\t[in]\tleftSpace\tThe new left spacing to set for the alert icon.\n\t */\n\tvoid setLeftSpace(int leftSpace);\n\n\t/*!\n\t *\tRetrieves the right spacing for the alert icon.\n\t *\n\t *\t\t@return The current right spacing for the alert icon.\n\t */\n\tint getRightSpace() const;\n\n\t/*!\n\t *\tSets the right spacing for the alert icon.\n\t *\n\t *\t\t@param\t[in]\trightSpace\tThe new right spacing to set for the alert icon.\n\t */\n\tvoid setRightSpace(int rightSpace);\n\nprivate:\n\t//! Pixmap of the alert icon.\n\tQPixmap pixmap_;\n\n\t//! Offset for the alert icon.\n\tint offset_;\n\n\t//! Left space for the alert icon.\n\tint leftSpace_;\n\n\t//! Right space for the alert icon.\n\tint rightSpace_;\n};\n\n#endif // STYLEOPTIONGROUPBOXWITHALERTSIGN_H"
  },
  {
    "path": "common/widgets/LibrarySelectorWidget/LibraryPathEditor/librarypatheditor.cpp",
    "content": "/* \r\n *  \tCreated on: 26.1.2012\r\n *      Author: Antti Kamppi\r\n * \t\tfilename: librarypatheditor.cpp\r\n *\t\tProject: Kactus 2\r\n */\r\n\r\n#include \"librarypatheditor.h\"\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LibraryPathEditor()\r\n//-----------------------------------------------------------------------------\r\nLibraryPathEditor::LibraryPathEditor(QWidget *parent):\r\nQLineEdit(parent),\r\nunmodifiablePath_() {\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ~LibraryPathEditor()\r\n//-----------------------------------------------------------------------------\r\nLibraryPathEditor::~LibraryPathEditor() {\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: setUnmodifiablePath()\r\n//-----------------------------------------------------------------------------\r\nvoid LibraryPathEditor::setUnmodifiablePath( const QString& path ) {\r\n\tunmodifiablePath_ = path;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: keyPressEvent()\r\n//-----------------------------------------------------------------------------\r\nvoid LibraryPathEditor::keyPressEvent( QKeyEvent* event ) {\r\n\r\n\t// if user clicks delete or back space\r\n\tif (event->key() == Qt::Key_Backspace || event->key() == Qt::Key_Delete) {\r\n\r\n\t\t// if the current path is the minimum path\r\n\t\tif (text() == unmodifiablePath_) {\r\n\t\t\t\r\n\t\t\t// the minimum path is not changed\r\n\t\t\tevent->accept();\r\n\t\t\treturn;\r\n\t\t}\r\n\t}\r\n\r\n\t// normally use the base class implementation\r\n\tQLineEdit::keyPressEvent(event);\r\n    emit contentChanged();\r\n}\r\n"
  },
  {
    "path": "common/widgets/LibrarySelectorWidget/LibraryPathEditor/librarypatheditor.h",
    "content": "/* \r\n *  \tCreated on: 26.1.2012\r\n *      Author: Antti Kamppi\r\n * \t\tfilename: librarypatheditor.h\r\n *\t\tProject: Kactus 2\r\n */\r\n\r\n#ifndef LIBRARYPATHEDITOR_H\r\n#define LIBRARYPATHEDITOR_H\r\n\r\n#include <QLineEdit>\r\n#include <QString>\r\n#include <QKeyEvent>\r\n\r\n/*! \\brief Line edit to manually set the path to save the new item to.\r\n *\r\n */\r\nclass LibraryPathEditor : public QLineEdit {\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\r\n\t/*! \\brief The constructor\r\n\t *\r\n\t * \\param parent Pointer to the owner of this line editor.\r\n\t *\r\n\t*/\r\n\tLibraryPathEditor(QWidget *parent);\r\n\r\n\t//! \\brief The destructor\r\n\tvirtual ~LibraryPathEditor();\r\n\r\n\t/*! \\brief Set the minimum path.\r\n\t *\r\n\t * \\param path The path to set.\r\n\t *\r\n\t*/\r\n\tvoid setUnmodifiablePath(const QString& path);\r\n\r\nsignals:\r\n\r\n    //! \\brief Emitted when the text in editor changes.\r\n    void contentChanged();\r\n\r\nprotected:\r\n\r\n\t/*! \\brief Handler for key press events.\r\n\t *\r\n\t * \\param event Pointer to the key event.\r\n\t *\r\n\t*/\r\n\tvirtual void keyPressEvent(QKeyEvent* event);\r\n\r\nprivate:\r\n\t\r\n\t//! \\brief No copying\r\n\tLibraryPathEditor(const LibraryPathEditor& other);\r\n\r\n\t//! \\brief No assignment\r\n\tLibraryPathEditor& operator=(const LibraryPathEditor& other);\r\n\r\n\t//! \\brief The minimum path that can not be changed.\r\n\tQString unmodifiablePath_;\r\n};\r\n\r\n#endif // LIBRARYPATHEDITOR_H\r\n"
  },
  {
    "path": "common/widgets/LibrarySelectorWidget/LibraryPathSelector/librarypathselector.cpp",
    "content": "/* \r\n *  \tCreated on: 26.1.2012\r\n *      Author: Antti Kamppi\r\n * \t\tfilename: librarypathselector.cpp\r\n *\t\tProject: Kactus 2\r\n */\r\n\r\n#include \"librarypathselector.h\"\r\n\r\n#include <QStringList>\r\n#include <QVariant>\r\n#include <QFileInfo>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LibraryPathSelector::LibraryPathSelector()\r\n//-----------------------------------------------------------------------------\r\nLibraryPathSelector::LibraryPathSelector(QWidget *parent):\r\nQComboBox(parent),\r\nsettings_(this),\r\nvalidator_(new LibraryPathValidator(this)),\r\nlibraryLocations_(),\r\npathEditor_(new LibraryPathEditor(this))\r\n{\r\n\trefresh();\r\n\r\n\tQString defaultPath = settings_.value(\"Library/DefaultLocation\", QString()).toString();\r\n\tif (!QFileInfo(defaultPath).isAbsolute())\r\n    {\r\n\t\tdefaultPath = QFileInfo(defaultPath).absoluteFilePath();\r\n\t}\r\n\r\n\t// if the default directory is found then select it\r\n\tint index = findText(defaultPath);\r\n\tif (index >= 0)\r\n    {\r\n\t\tsetCurrentIndex(index);\r\n\t}\r\n\r\n\tsetEditable(true);\r\n\r\n\tsetLineEdit(pathEditor_);\r\n\tpathEditor_->setUnmodifiablePath(defaultPath);\r\n\r\n\tsetValidator(validator_);\r\n\tvalidator_->setUnmodifiablePath(defaultPath);\r\n\r\n\tsetToolTip(tr(\"Select one of the active library locations you have listed in the settings.\"));\r\n\r\n    connect(pathEditor_, SIGNAL(contentChanged()), this, SIGNAL(contentChanged()));\r\n\r\n    connect(this, SIGNAL(currentIndexChanged(int)),\tthis, SLOT(onIndexChanged()), Qt::UniqueConnection);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LibraryPathSelector::~LibraryPathSelector()\r\n//-----------------------------------------------------------------------------\r\nLibraryPathSelector::~LibraryPathSelector()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LibraryPathSelector::isValid()\r\n//-----------------------------------------------------------------------------\r\nbool LibraryPathSelector::isValid()\r\n{\r\n    Q_ASSERT(pathEditor_);\r\n    return !currentText().isEmpty() && hasIndexFor(currentText());\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LibraryPathSelector::currentLocation()\r\n//-----------------------------------------------------------------------------\r\nQString LibraryPathSelector::currentLocation() const\r\n{\r\n\tint index = currentIndex();\r\n\treturn libraryLocations_.value(index, QString());\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LibraryPathSelector::refresh()\r\n//-----------------------------------------------------------------------------\r\nvoid LibraryPathSelector::refresh()\r\n{\r\n    // Clear previous known library locations.\r\n    libraryLocations_.clear();\r\n    clear();\r\n\r\n    // the active library locations\r\n    QStringList activeLocations = settings_.value(\"Library/ActiveLocations\", QStringList()).toStringList();\r\n    \r\n    // make sure all locations are absolute paths\r\n    foreach (QString location, activeLocations)\r\n    {\r\n        if (!QFileInfo(location).isAbsolute())\r\n        {\r\n            QString fullLocation = QFileInfo(location).absoluteFilePath();\r\n            libraryLocations_.append(fullLocation);\r\n        }\r\n        else\r\n        {\r\n            libraryLocations_.append(location);\r\n        }\r\n    }\r\n\r\n    addItems(libraryLocations_);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LibraryPathSelector::getLibraryLocations()\r\n//-----------------------------------------------------------------------------\r\nQStringList LibraryPathSelector::getLibraryLocations()\r\n{\r\n    return libraryLocations_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LibraryPathSelector::hasIndexFor()\r\n//-----------------------------------------------------------------------------\r\nbool LibraryPathSelector::hasIndexFor(QString const& path)\r\n{\r\n    foreach(QString libraryPath, libraryLocations_)\r\n    {\r\n        if (path.startsWith(libraryPath))\r\n        {\r\n            return true;\r\n        }\r\n    }\r\n\r\n    return false;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LibraryPathSelector::setIndexFor()\r\n//-----------------------------------------------------------------------------\r\nbool LibraryPathSelector::setIndexFor(QString const& path)\r\n{\r\n    foreach(QString libraryPath, libraryLocations_)\r\n    {\r\n        if (path.startsWith(libraryPath))\r\n        {\r\n            setCurrentIndex(findText(libraryPath));\r\n            setCurrentText(path);\r\n            return true;\r\n        }\r\n    }\r\n\r\n    return false;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LibraryPathSelector::onIndexChanged()\r\n//-----------------------------------------------------------------------------\r\nvoid LibraryPathSelector::onIndexChanged()\r\n{\r\n\tconst QString path = currentLocation();\r\n\r\n\tpathEditor_->setUnmodifiablePath(path);\r\n\tvalidator_->setUnmodifiablePath(path);\r\n}\r\n"
  },
  {
    "path": "common/widgets/LibrarySelectorWidget/LibraryPathSelector/librarypathselector.h",
    "content": "/* \r\n *  \tCreated on: 26.1.2012\r\n *      Author: Antti Kamppi\r\n * \t\tfilename: librarypathselector.h\r\n *\t\tProject: Kactus 2\r\n */\r\n\r\n#ifndef LIBRARYPATHSELECTOR_H\r\n#define LIBRARYPATHSELECTOR_H\r\n\r\n#include <common/widgets/LibrarySelectorWidget/LibraryPathEditor/librarypatheditor.h>\r\n#include <common/validators/LibraryPathValidator/librarypathvalidator.h>\r\n\r\n#include <QComboBox>\r\n#include <QSettings>\r\n#include <QStringList>\r\n\r\n/*! \\brief Combo box to select one of the previously set library locations.\r\n *\r\n */\r\nclass LibraryPathSelector : public QComboBox {\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\r\n\t/*! \\brief The constructor\r\n\t *\r\n\t * \\param parent Pointer to the owner of this combo box.\r\n\t *\r\n\t*/\r\n\tLibraryPathSelector(QWidget *parent);\r\n\t\r\n\t//! \\brief The destructor\r\n\tvirtual ~LibraryPathSelector();\r\n\r\n    bool isValid();\r\n\r\n\t/*! \\brief Get the currently selected base location.\r\n\t *\r\n\t * \\return QString containing the selected library location.\r\n\t*/\r\n    QString currentLocation() const;\r\n\r\n    /*!\r\n     *  Searches the active library locations.\r\n     */\r\n    void refresh();\r\n\r\n    /*!\r\n     *  Gets the active library paths.\r\n     *\r\n     *    @return     The active library locations. \r\n     */\r\n    QStringList getLibraryLocations();\r\n\r\n    /*!\r\n     *  Checks if there is a library for a given path.\r\n     *\r\n     *    @param [in] path   The path to search for.\r\n     *\r\n     *    @return     True, if the path is under any of the active libraries, otherwise false.\r\n     */\r\n    bool hasIndexFor(QString const& path);\r\n\r\n    /*!\r\n     *  Sets the index for the corresponding library for a given path.\r\n     *\r\n     *    @param [in] path   The path under a library.\r\n     *\r\n     *    @return     True, if the path is under any of the active libraries and can be set, otherwise false.\r\n     */\r\n    bool setIndexFor(QString const& path);\r\n\r\nsignals:\r\n\r\n    //! \\brief Emitted when the library path changes.\r\n    void contentChanged();\r\n\r\nprivate slots:\r\n\r\n\t/*! \\brief Handler for index changes on combo box.\r\n\t *\r\n\t*/\r\n\tvoid onIndexChanged();\r\n\r\nprivate:\r\n\t\r\n\t//! \\brief No copying\r\n\tLibraryPathSelector(const LibraryPathSelector& other);\r\n\r\n\t//! \\brief No assignment\r\n\tLibraryPathSelector& operator=(const LibraryPathSelector& other);\r\n\r\n\t//! \\brief Contains the Kactus2 settings.\r\n\tQSettings settings_;\r\n\r\n\t//! \\brief Validator used for the editable combo box.\r\n\tLibraryPathValidator* validator_;\r\n\r\n\t//! \\brief the library locations from the settings.\r\n\tQStringList libraryLocations_;\r\n\r\n\t//! \\brief The editor to display and edit the path.\r\n\tLibraryPathEditor* pathEditor_;\r\n};\r\n\r\n#endif // LIBRARYPATHSELECTOR_H\r\n"
  },
  {
    "path": "common/widgets/LibrarySelectorWidget/LibrarySelectorWidget.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: LibrarySelectorWidget.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Esko Pekkarinen\r\n// Date: 25.06.2013\r\n//\r\n// Description:\r\n// Widget for selecting a path under library locations.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"LibrarySelectorWidget.h\"\r\n\r\n#include <QHBoxLayout>\r\n#include <QMessageBox>\r\n#include <QFileDialog>\r\n#include <QLabel>\r\n\r\n#include <common/widgets/LibrarySelectorWidget/LibraryPathSelector/librarypathselector.h>\r\n#include <common/dialogs/LibrarySettingsDialog/LibrarySettingsDialog.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LibrarySelectorWidget::LibrarySelectorWidget()\r\n//-----------------------------------------------------------------------------\r\nLibrarySelectorWidget::LibrarySelectorWidget(QWidget* parent):\r\n    QWidget(parent),\r\n    librarySelector_(new LibraryPathSelector(this)),\r\n    browseButton_(new QPushButton(tr(\"Browse...\"),this)),\r\n    directorySet_(false)\r\n{\r\n    connect(browseButton_, SIGNAL(clicked()),this, SLOT(onBrowse()), Qt::UniqueConnection);\r\n    connect(librarySelector_, SIGNAL(contentChanged()), \r\n        this, SIGNAL(contentChanged()), Qt::UniqueConnection);\r\n    connect(librarySelector_, SIGNAL(editTextChanged(QString const&)), \r\n        this, SIGNAL(contentChanged()), Qt::UniqueConnection);\r\n\r\n    setupLayout();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LibrarySelectorWidget::~LibrarySelectorWidget()\r\n//-----------------------------------------------------------------------------\r\nLibrarySelectorWidget::~LibrarySelectorWidget()\r\n{\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LibrarySelectorWidget::getPath()\r\n//-----------------------------------------------------------------------------\r\nQString LibrarySelectorWidget::getPath() const\r\n{\r\n    return librarySelector_->currentText();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LibrarySelectorWidget::reset()\r\n//-----------------------------------------------------------------------------\r\nvoid LibrarySelectorWidget::reset()\r\n{\r\n    directorySet_ = false;\r\n    librarySelector_->refresh();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LibrarySelectorWidget::isValid()\r\n//-----------------------------------------------------------------------------\r\nbool LibrarySelectorWidget::isValid() const\r\n{\r\n    return librarySelector_->isValid();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LibrarySelectorWidget::onBrowse()\r\n//-----------------------------------------------------------------------------\r\nvoid LibrarySelectorWidget::onBrowse()\r\n{\r\n    QString baseDirectory = QFileInfo(librarySelector_->currentText()).filePath();\r\n    if (baseDirectory.size() < 1)\r\n    {\r\n        baseDirectory = librarySelector_->currentLocation();\r\n    }\r\n\r\n    QString targetDirectory = QFileDialog::getExistingDirectory(this, tr(\"Choose target directory\"),\r\n        baseDirectory);\r\n\r\n    if (targetDirectory.size() < 1)\r\n    {\r\n        return;\r\n    }\r\n\r\n    targetDirectory = QFileInfo(targetDirectory).filePath();\r\n\r\n    if (targetDirectory.size() < 1)\r\n    {\r\n        targetDirectory = \".\";\r\n    }\r\n\r\n    QSettings settings;\r\n    while (!librarySelector_->hasIndexFor(targetDirectory))\r\n    {\r\n        QMessageBox warningDialog(QMessageBox::Warning, \"Warning\", \r\n            \"Chosen path is not in any active library. Do you want to configure libraries?\",\r\n            QMessageBox::Yes | QMessageBox::Cancel, this);\r\n\r\n        warningDialog.setDetailedText(targetDirectory + \"\\nis not in any of the active libraries:\\n\" + \r\n            librarySelector_->getLibraryLocations().join(\"\\n\"));\r\n\r\n        if (warningDialog.exec() == QMessageBox::Yes)\r\n        {\r\n            LibrarySettingsDialog dialog(settings, this);\r\n            dialog.exec();\r\n            librarySelector_->refresh();\r\n        }\r\n        else //if( msg == QMessageBox::Cancel )\r\n        {\r\n            return;\r\n        }\r\n    }\r\n    \r\n    librarySelector_->setIndexFor(targetDirectory);\r\n    directorySet_ = true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LibrarySelectorWidget::updateDirectory()\r\n//-----------------------------------------------------------------------------\r\nvoid LibrarySelectorWidget::updatePath(QString const& path)\r\n{\r\n    if (!directorySet_)\r\n    {\r\n        QString directory = librarySelector_->currentLocation();\r\n\r\n        librarySelector_->setEditText(directory + path);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LibrarySelectorWidget::setupLayout()\r\n//-----------------------------------------------------------------------------\r\nvoid LibrarySelectorWidget::setupLayout()\r\n{\r\n    QHBoxLayout *widgetLayout = new QHBoxLayout(this);\r\n    widgetLayout->addWidget(new QLabel(tr(\"Directory:\"), this));\r\n    widgetLayout->addWidget(librarySelector_, 1);\r\n    widgetLayout->addWidget(browseButton_);\r\n\r\n    widgetLayout->setContentsMargins(0, 0, 0, 0);\r\n}\r\n"
  },
  {
    "path": "common/widgets/LibrarySelectorWidget/LibrarySelectorWidget.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: LibrarySelectorWidget.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Esko Pekkarinen\r\n// Date: 27.08.2013\r\n//\r\n// Description:\r\n// Widget for selecting a path under library locations\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef LIBRARYSELECTORWIDGET_H\r\n#define LIBRARYSELECTORWIDGET_H\r\n\r\n#include <QWidget>\r\n#include <QSharedPointer>\r\n#include <QPushButton>\r\n\r\nclass LibraryPathSelector;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Widget for selecting a path under library locations\r\n//-----------------------------------------------------------------------------\r\nclass LibrarySelectorWidget : public QWidget\r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\r\n    /*!\r\n     *  Constructor.\r\n     *      \r\n     *    @param [in] parent The parent widget.\r\n     */\r\n\tLibrarySelectorWidget(QWidget *parent = 0);\r\n\t\r\n\t//! \\brief The destructor.\r\n\t~LibrarySelectorWidget();\r\n\r\n    /*!\r\n     *  Get the edited path.\r\n     *      \r\n     *    @return Path in the edit field.\r\n     */\r\n    QString getPath() const;\r\n\r\n    /*!\r\n     *  Updates active libraries in combobox and enables path to be constructed using vlnv.\r\n     */\r\n    void reset();\r\n\r\n    /*!\r\n     *  Checks if the path is valid.\r\n     *      \r\n     *    @return True, if the path is in an active library, otherwise false.\r\n     */\r\n    bool isValid() const;\r\n\r\nsignals:\r\n\r\n    //! \\brief Emitted when the library path changes.\r\n    void contentChanged();\r\n\r\npublic slots:\r\n\r\n    //! Called when browse button is clicked.\r\n    virtual void onBrowse();\r\n\r\n    //! Called when vlnv is used to set the path. Path is appended to the active library path.\r\n    virtual void updatePath(QString const& path);\r\n\r\nprivate:\r\n\t\r\n\t//! \\brief No copying\r\n\tLibrarySelectorWidget(const LibrarySelectorWidget& other);\r\n\r\n\t//! \\brief No assignment\r\n\tLibrarySelectorWidget& operator=(const LibrarySelectorWidget& other);\r\n\r\n    //! Creates the layout for the widget.\r\n    void setupLayout();\r\n\r\n\t//! \\brief Used to select the library path.\r\n\tLibraryPathSelector* librarySelector_;\r\n\r\n    //! The browse button.\r\n    QPushButton* browseButton_;\r\n\r\n    //! Flag for indicating if the path set using browse or if vlnv should be used to set the path.\r\n    bool directorySet_;\r\n\r\n};\r\n\r\n#endif // LIBRARYSELECTORWIDGET_H\r\n"
  },
  {
    "path": "common/widgets/LineEditEx/LineEditEx.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: LineEditEx.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Joni-Matti Maatta\r\n// Date: 9.8.2012\r\n//\r\n// Description:\r\n// Line edit with extended functionality.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"LineEditEx.h\"\r\n\r\n#include <QStyle>\r\n#include <QPalette>\r\n\r\n#include <common/KactusColors.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LineEditEx::LineEditEx()\r\n//-----------------------------------------------------------------------------\r\nLineEditEx::LineEditEx(QWidget* parent /*= 0*/)\r\n    : AssistedLineEdit(parent, parent), // TODO: Main window!!\r\n      disallowedInputs_(),\r\n      messageTemplate_(tr(\"'%1' is already in use\")),\r\n      messageIcon_(),\r\n      iconWidget_(0)\r\n{\r\n    connect(this, SIGNAL(textChanged(QString const&)),\r\n            this, SLOT(validateText(QString const&)), Qt::UniqueConnection);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LineEditEx::~LineEditEx()\r\n//-----------------------------------------------------------------------------\r\nLineEditEx::~LineEditEx()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LineEditEx::setDisallowedInputs()\r\n//-----------------------------------------------------------------------------\r\nvoid LineEditEx::setDisallowedInputs(QStringList const& inputs)\r\n{\r\n    disallowedInputs_ = inputs;\r\n    validateText(text());\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LineEditEx::setMessageTemplate()\r\n//-----------------------------------------------------------------------------\r\nvoid LineEditEx::setMessageTemplate(QString const& messageTemplate)\r\n{\r\n    messageTemplate_ = messageTemplate;\r\n    validateText(text());\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LineEditEx::setMessageIcon()\r\n//-----------------------------------------------------------------------------\r\nvoid LineEditEx::setMessageIcon(QPixmap const& icon)\r\n{\r\n    if (iconWidget_ == 0)\r\n    {\r\n        iconWidget_ = new QLabel(this);\r\n        iconWidget_->setCursor(Qt::ArrowCursor);\r\n        iconWidget_->setStyleSheet(\"QWidget { border: none; padding: 0px; }\");\r\n    }\r\n\r\n    iconWidget_->setPixmap(icon);\r\n    iconWidget_->setFixedSize(icon.size());\r\n\r\n    updateIconPos();\r\n    validateText(text());\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LineEditEx::updateIconPos()\r\n//-----------------------------------------------------------------------------\r\nvoid LineEditEx::updateIconPos()\r\n{\r\n    if (iconWidget_ != 0)\r\n    {\r\n        int frameWidth = style()->pixelMetric(QStyle::PM_DefaultFrameWidth);\r\n\r\n        iconWidget_->move(rect().right() - frameWidth - iconWidget_->size().width(),\r\n                          rect().bottom() - 1 - iconWidget_->size().height());\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LineEditEx::resizeEvent()\r\n//-----------------------------------------------------------------------------\r\nvoid LineEditEx::resizeEvent(QResizeEvent*)\r\n{\r\n    updateIconPos();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LineEditEx::validateText()\r\n//-----------------------------------------------------------------------------\r\nvoid LineEditEx::validateText(QString const& text)\r\n{\r\n    if (iconWidget_ != 0)\r\n    {\r\n        bool invalid = disallowedInputs_.contains(text);\r\n        valid_ = !invalid;\r\n\r\n        iconWidget_->setVisible(invalid);\r\n        iconWidget_->setToolTip(messageTemplate_.arg(text));\r\n\r\n        if (invalid)\r\n        {\r\n            QPalette p = palette();\r\n            p.setColor(QPalette::Normal, QPalette::Base, KactusColors::INVALID_FIELD);\r\n            setPalette(p);\r\n        }\r\n        else\r\n        {\r\n            QPalette p = palette();\r\n            p.setColor(QPalette::Normal, QPalette::Base, KactusColors::REGULAR_FIELD);\r\n            setPalette(p);\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LineEditEx::isInputValid()\r\n//-----------------------------------------------------------------------------\r\nbool LineEditEx::isInputValid() const\r\n{\r\n    return valid_;\r\n}\r\n"
  },
  {
    "path": "common/widgets/LineEditEx/LineEditEx.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: LineEditEx.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Joni-Matti Maatta\r\n// Date: 9.8.2012\r\n//\r\n// Description:\r\n// Line edit with extended functionality.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef LINEEDITEX_H\r\n#define LINEEDITEX_H\r\n\r\n#include <common/widgets/assistedLineEdit/BasicLineContentMatcher.h>\r\n#include <common/widgets/assistedLineEdit/AssistedLineEdit.h>\r\n\r\n#include <QIcon>\r\n#include <QLabel>\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Line edit with extended functionality.\r\n//-----------------------------------------------------------------------------\r\nclass LineEditEx : public AssistedLineEdit\r\n{\r\n    Q_OBJECT\r\n\r\npublic:\r\n    /*!\r\n     *  Constructor.\r\n     *\r\n     *    @param [in] parent The parent widget.\r\n     */\r\n    LineEditEx(QWidget* parent = 0);\r\n\r\n    /*!\r\n     *  Destructor.\r\n     */\r\n    ~LineEditEx();\r\n\r\n    /*!\r\n     *  Sets the disallowed inputs.\r\n     */\r\n    void setDisallowedInputs(QStringList const& inputs);\r\n\r\n    /*!\r\n     *  Sets the notification message template which is used when the user inputs a\r\n     *  string that is included in the disallowed inputs. Example: \"View '%1' is already in use.\"\r\n     *\r\n     *    @param [in] template The template string. Must contain %1 to allow argumentation.\r\n     */\r\n    void setMessageTemplate(QString const& messageTemplate);\r\n\r\n    /*!\r\n     *  Sets the notification message icon.\r\n     *\r\n     *    @param [in] icon The icon to set.\r\n     */\r\n    void setMessageIcon(QPixmap const& icon);\r\n\r\n    /*!\r\n     *  Returns true if the input is valid.\r\n     */\r\n    bool isInputValid() const;\r\n\r\nprotected:\r\n    //! Called when the line edit has been resized.\r\n    virtual void resizeEvent(QResizeEvent* event);\r\n\r\nprivate slots:\r\n    /*!\r\n     *  Validates the given current text and either shows or hides the notification icon.\r\n     *\r\n     *    @param [in] text The text to validate.\r\n     */\r\n    void validateText(QString const& text);\r\n\r\nprivate:\r\n    // Disable copying.\r\n    LineEditEx(LineEditEx const& rhs);\r\n    LineEditEx& operator=(LineEditEx const& rhs);\r\n    void updateIconPos();\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! The list of disallowed inputs.\r\n    QStringList disallowedInputs_;\r\n\r\n    //! The notification message template.\r\n    QString messageTemplate_;\r\n\r\n    //! The notification message icon.\r\n    QIcon messageIcon_;\r\n\r\n    //! The notification icon widget.\r\n    QLabel* iconWidget_;    \r\n\r\n    //! If true, the input is valid.\r\n    bool valid_;\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n\r\n#endif // LINEEDITEX_H\r\n"
  },
  {
    "path": "common/widgets/ParameterGroupBox/parametergroupbox.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: parametergroupbox.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Antti Kamppi\r\n// Date: 23.2.2012\r\n//\r\n// Description:\r\n// Group box that can be used to edit list of parameters.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"parametergroupbox.h\"\r\n\r\n#include <editors/ComponentEditor/parameters/ParametersView.h>\r\n\r\n#include <editors/ComponentEditor/parameters/ComponentParameterModel.h>\r\n#include <editors/ComponentEditor/parameters/ParameterColumns.h>\r\n#include <editors/ComponentEditor/parameters/ParameterDelegate.h>\r\n#include <editors/ComponentEditor/parameters/ParameterEditorHeaderView.h>\r\n#include <editors/ComponentEditor/parameters/parametersmodel.h>\r\n#include <editors/ComponentEditor/parameters/LockableParametersModel.h>\r\n#include <KactusAPI/include/ParametersInterface.h>\r\n\r\n#include <KactusAPI/include/ComponentParameterFinder.h>\r\n#include <KactusAPI/include/ExpressionFormatter.h>\r\n#include <KactusAPI/include/IPXactSystemVerilogParser.h>\r\n#include <KactusAPI/include/ParameterFinder.h>\r\n#include <KactusAPI/include/ListParameterFinder.h>\r\n\r\n#include <IPXACTmodels/common/validators/ParameterValidator.h>\r\n\r\n#include <QCompleter>\r\n#include <QVBoxLayout>\r\n#include <QSortFilterProxyModel>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ParameterGroupBox::ParameterGroupBox()\r\n//-----------------------------------------------------------------------------\r\nParameterGroupBox::ParameterGroupBox(QSharedPointer<QList<QSharedPointer<Parameter> > > parameters,\r\n    QSharedPointer<QList<QSharedPointer<Choice> > > choices, QSharedPointer<ParameterFinder> parameterFinder,\r\n    QSharedPointer<ExpressionFormatter> expressionFormatter, Document::Revision docRevision, bool lockableParameters, QWidget *parent) :\r\nQGroupBox(tr(\"Parameters\"), parent),\r\nview_(new ParametersView(this)),\r\nproxy_(new QSortFilterProxyModel(this)),\r\nmodel_(0),\r\nparameterFinder_(parameterFinder),\r\nparameterInterface_()\r\n{\r\n    ParameterEditorHeaderView* parameterHorizontalHeader = new ParameterEditorHeaderView(Qt::Horizontal, this);\r\n    view_->setHorizontalHeader(parameterHorizontalHeader);\r\n\r\n    view_->verticalHeader()->show();\r\n    view_->verticalHeader()->setMaximumWidth(300);\r\n    view_->verticalHeader()->setMinimumWidth(view_->horizontalHeader()->fontMetrics().horizontalAdvance(tr(\"Name\"))*2);\r\n    view_->verticalHeader()->setSectionResizeMode(QHeaderView::Fixed);\r\n\r\n    QSharedPointer<IPXactSystemVerilogParser> expressionParser(new IPXactSystemVerilogParser(parameterFinder));\r\n\r\n    parameterValidator_ = QSharedPointer<ParameterValidator>(new ParameterValidator(expressionParser, \r\n        choices, docRevision));\r\n\r\n    parameterInterface_ = new ParametersInterface(parameterValidator_, expressionParser, expressionFormatter);\r\n\r\n    parameterInterface_->setParameters(parameters);\r\n    parameterInterface_->setChoices(choices);\r\n\r\n    if (lockableParameters)\r\n    {\r\n        model_ = new LockableParametersModel(parameterInterface_, expressionParser, parameterFinder_, parent);\r\n    }\r\n    else\r\n    {\r\n        model_ = new ParametersModel(parameterInterface_, expressionParser, parameterFinder, this);\r\n    }\r\n\r\n\tconnect(model_, SIGNAL(contentChanged()), this, SIGNAL(contentChanged()), Qt::UniqueConnection);\r\n\tconnect(model_, SIGNAL(dataChanged(const QModelIndex&, const QModelIndex&)),\r\n\t\tthis, SIGNAL(contentChanged()), Qt::UniqueConnection);\r\n\tconnect(model_, SIGNAL(errorMessage(const QString&)),\r\n        this, SIGNAL(errorMessage(const QString&)), Qt::UniqueConnection);\r\n\tconnect(model_, SIGNAL(noticeMessage(const QString&)),\r\n        this, SIGNAL(noticeMessage(const QString&)), Qt::UniqueConnection);\r\n\r\n\tconnect(view_, SIGNAL(addItem(const QModelIndex&)), \r\n        model_, SLOT(onAddItem(const QModelIndex&)), Qt::UniqueConnection);\r\n\tconnect(view_, SIGNAL(removeItem(const QModelIndex&)),\r\n\t\tmodel_, SLOT(onRemoveItem(const QModelIndex&)), Qt::UniqueConnection);\r\n\r\n\t// set view to be sortable\r\n\tview_->setSortingEnabled(true);\r\n\r\n\t// items can not be dragged\r\n\tview_->setItemsDraggable(false);\r\n\r\n    ComponentParameterModel* parameterModel = new ComponentParameterModel(parameterFinder, this);\r\n    parameterModel->setExpressionParser(expressionParser);\r\n\r\n    delegate_ = new ParameterDelegate(choices, parameterModel, parameterFinder,\r\n        expressionFormatter, this);\r\n\r\n    view_->setItemDelegate(delegate_);\r\n\r\n    connect(view_->itemDelegate(), SIGNAL(increaseReferences(QString)), \r\n        this, SIGNAL(increaseReferences(QString)), Qt::UniqueConnection);\r\n    connect(view_->itemDelegate(), SIGNAL(decreaseReferences(QString)),\r\n        this, SIGNAL(decreaseReferences(QString)), Qt::UniqueConnection);\r\n    connect(view_->itemDelegate(), SIGNAL(openReferenceTree(QString const&, QString const&)),\r\n        this, SIGNAL(openReferenceTree(QString const&, QString const&)), Qt::UniqueConnection);\r\n    connect(view_, SIGNAL(openReferenceTree(QString const&, QString const&)),\r\n        this, SIGNAL(openReferenceTree(QString const&, QString const&)), Qt::UniqueConnection);\r\n\r\n    connect(model_, SIGNAL(decreaseReferences(QString)),\r\n        this, SIGNAL(decreaseReferences(QString)), Qt::UniqueConnection);\r\n\r\n    connect(view_, SIGNAL(recalculateReferenceToIndexes(QModelIndexList)),\r\n        model_, SLOT(onGetParametersMachingIndexes(QModelIndexList)), Qt::UniqueConnection);\r\n    connect(model_,\r\n        SIGNAL(recalculateReferencesToParameters(QVector<QString> const&, AbstractParameterInterface*)),\r\n        this,\r\n        SIGNAL(recalculateReferencesToParameters(QVector<QString> const&, AbstractParameterInterface*)),\r\n        Qt::UniqueConnection);\r\n\r\n\t// set source model for proxy\r\n\tproxy_->setSourceModel(model_);\r\n\t// set proxy to be the source for the view\r\n\tview_->setModel(proxy_);\r\n\r\n\t// sort the view\r\n\tview_->sortByColumn(0, Qt::AscendingOrder);\r\n\r\n    view_->setColumnHidden(ParameterColumns::ID, true);\r\n\r\n\tQVBoxLayout* layout = new QVBoxLayout(this);\r\n\tlayout->addWidget(view_);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ParameterGroupBox::~ParameterGroupBox()\r\n//-----------------------------------------------------------------------------\r\nParameterGroupBox::~ParameterGroupBox()\r\n{\r\n    delete parameterInterface_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ParameterGroupBox::refresh()\r\n//-----------------------------------------------------------------------------\r\nvoid ParameterGroupBox::refresh() \r\n{\r\n    proxy_->invalidate();\r\n\tview_->update();\r\n\r\n    if (!view_->isColumnHidden(ParameterColumns::ID))\r\n    {\r\n        view_->setColumnHidden(ParameterColumns::ID, true);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: parametergroupbox::setNewParameters()\r\n//-----------------------------------------------------------------------------\r\nvoid ParameterGroupBox::setNewParameters(QSharedPointer<QList<QSharedPointer<Parameter> > > newParameters, \r\n    QSharedPointer<QList<QSharedPointer<Choice> > > newChoices, Document::Revision docRevision)\r\n{\r\n    parameterInterface_->setParameters(newParameters);\r\n    parameterInterface_->setChoices(newChoices);\r\n    model_->resetModelItems();\r\n    delegate_->setStdRevision(docRevision);\r\n    parameterValidator_->setStdRevision(docRevision);\r\n\r\n    QSharedPointer<ListParameterFinder> listFinder = parameterFinder_.dynamicCast<ListParameterFinder>();\r\n    if (listFinder)\r\n    {\r\n        listFinder->setParameterList(newParameters);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ParameterGroupBox::lockParameterColumn()\r\n//-----------------------------------------------------------------------------\r\nvoid ParameterGroupBox::lockParameterColumn(QString const& parameterName, ParameterColumns::columns column)\r\n{\r\n    auto modelCast = dynamic_cast<LockableParametersModel*>(model_);\r\n    \r\n    Q_ASSERT_X(dynamic_cast<LockableParametersModel*>(model_), \"ParameterGroupBox\", \"Call to lockParameterColumn() with model not of type LockableParametersModel\");\r\n\r\n    if (modelCast)\r\n        modelCast->lockParameterColumn(parameterName, column);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ParameterGroupBox::getInterface()\r\n//-----------------------------------------------------------------------------\r\nParametersInterface* ParameterGroupBox::getInterface() const\r\n{\r\n    return parameterInterface_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ParameterGroupBox::addParameter()\r\n//-----------------------------------------------------------------------------\r\nvoid ParameterGroupBox::addParameter(QString const& parameterName)\r\n{\r\n    model_->addParameterManually(parameterName);\r\n}\r\n"
  },
  {
    "path": "common/widgets/ParameterGroupBox/parametergroupbox.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: parametergroupbox.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Antti Kamppi\r\n// Date: 23.2.2012\r\n//\r\n// Description:\r\n// Group box that can be used to edit list of parameters.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef PARAMETERGROUPBOX_H\r\n#define PARAMETERGROUPBOX_H\r\n\r\n#include <IPXACTmodels/common/Parameter.h>\r\n#include <IPXACTmodels/common/Document.h>\r\n\r\n#include <editors/ComponentEditor/parameters/ParameterColumns.h>\r\n\r\n#include <QGroupBox>\r\n#include <QList>\r\n#include <QSharedPointer>\r\n#include <QSortFilterProxyModel>\r\n\r\nclass Component;\r\nclass Choice;\r\nclass ParameterFinder;\r\nclass ParametersModel;\r\nclass ParameterDelegate;\r\nclass ParameterValidator;\r\nclass ExpressionFormatter;\r\nclass ParametersView;\r\nclass ParametersInterface;\r\nclass AbstractParameterInterface;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Group box that can be used to edit list of parameters.\r\n//-----------------------------------------------------------------------------\r\nclass ParameterGroupBox : public QGroupBox \r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\r\n\t/*!\r\n\t *  The constructor.\r\n\t *\r\n\t *    @param [in]  parameters             The list containing the parameters.\r\n\t *    @param [in]  choices                The available choices for the parameters.\r\n\t *    @param [in]  parameterFinder        The parameter finder used to search the components parameters.\r\n\t *    @param [in]  expressionFormatter    The expression formatter.\r\n\t *    @param [in]  docRevision            The IP-XACT standard revision to use.\r\n\t *    @param [in]  lockableParameters     Flag indicating if parameters should be lockable in the editor or not.\r\n\t *    @param [in]  parent                 The owner of this editor.\r\n\t */\r\n\tParameterGroupBox(QSharedPointer<QList<QSharedPointer<Parameter> > > parameters,\r\n        QSharedPointer<QList<QSharedPointer<Choice> > > choices, QSharedPointer<ParameterFinder> parameterFinder,\r\n        QSharedPointer<ExpressionFormatter> expressionFormatter, Document::Revision docRevision, bool lockableParameters = false, QWidget *parent = nullptr);\r\n\r\n    //! No copying. No assignment.\r\n    ParameterGroupBox(const ParameterGroupBox& other) = delete;\r\n    ParameterGroupBox& operator=(const ParameterGroupBox& other) = delete;\r\n\r\n\t/*!\r\n     *  The destructor.\r\n     */\r\n\tvirtual ~ParameterGroupBox();\r\n\r\n\t/*!\r\n     *  Restore the changes made in the editor back to ones in parameter models.\r\n     */\r\n\tvirtual void refresh();\r\n\r\n    /*!\r\n     *  Setup a list of new parameters.\r\n     *\r\n     *    @param [in] newParameters   New parameter list.\r\n     */\r\n    void setNewParameters(QSharedPointer<QList<QSharedPointer<Parameter> > > newParameters, \r\n        QSharedPointer<QList<QSharedPointer<Choice> > > newChoices, Document::Revision docRevision);\r\n\r\n    /*!\r\n     *\tLock editing of a given column of a given parameter. Should be called only when lockable model is used.\r\n     *  \r\n     *    @param [in] parameterName     Parameter whose cell to lock.\r\n     *    @param [in] column            The column of the cell to lock.\r\n     */\r\n    void lockParameterColumn(QString const& parameterName, ParameterColumns::columns column);\r\n\r\n    /*!\r\n     *\tGet the parameters interface being used.\r\n     *  \r\n     *    @return The parameters interface.\r\n     */\r\n    ParametersInterface* getInterface() const;\r\n\r\n    /*!\r\n     *\tAdd a parameter to the editor and its model.\r\n     *  \r\n     *    @param [in] parameterName     The name of the added parameter.\r\n     */\r\n    void addParameter(QString const& parameterName);\r\n\r\nsignals:\r\n\r\n\t//! Emitted when contents of the editor change.\r\n\tvoid contentChanged();\r\n\r\n\t//! Prints an error message to the user.\r\n\tvoid errorMessage(const QString& msg) const;\r\n\r\n\t//! Prints a notification to user.\r\n\tvoid noticeMessage(const QString& msg) const;\r\n\r\n    /*!\r\n     *  Increase the amount of references to the parameter corresponding to the id.\r\n     *\r\n     *    @param [in] id      The id of the parameter being searched for.\r\n     */\r\n    void increaseReferences(QString id);\r\n\r\n    /*!\r\n     *  Decrease the amount of references to the parameter corresponding to the id.\r\n     *\r\n     *    @param [in] id      The id of the parameter being searched for.\r\n     */\r\n    void decreaseReferences(QString id);\r\n\r\n    /*!\r\n     *  Open the reference tree of the parameter with the id.\r\n     *\r\n     *    @param [in] id              The id of the parameter.\r\n     *    @param [in] parameterName   Name of the selected parameter.\r\n     */\r\n    void openReferenceTree(QString const& id, QString const& parameterName) const;\r\n\r\n    /*!\r\n     *  Recalculate references made to the selected parameters.\r\n     *\r\n     *    @param [in] parameterList       The selected parameters.\r\n     *    @param [in] parameterInterface  Interface for accessing parameters.\r\n     */\r\n    void recalculateReferencesToParameters(QVector<QString> const& parameterList,\r\n        AbstractParameterInterface* parameterInterface);\r\n\r\nprotected:\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n\t//! The view that displays the parameters.\r\n    ParametersView* view_;\r\n\r\n    //! The proxy that is used to do the sorting of parameters.\r\n    QSortFilterProxyModel* proxy_;\r\n\r\n\t//! The model that holds the data to be displayed to the user\r\n\tParametersModel* model_;\r\n\r\n    //! The parameter delegate.\r\n    ParameterDelegate* delegate_;\r\n\r\n    //! The parameter finder for locating the contained parameters.\r\n    QSharedPointer<ParameterFinder> parameterFinder_;\r\n\r\n    //! Interface for accessing parameters.\r\n    ParametersInterface* parameterInterface_;\r\n\r\n    //! The parameter validator.\r\n    QSharedPointer<ParameterValidator> parameterValidator_;\r\n};\r\n\r\n#endif // PARAMETERGROUPBOX_H\r\n"
  },
  {
    "path": "common/widgets/SnippetTextEdit/SnippetHighlighter.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: SnippetHighlighter.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Joni-Matti Maatta\r\n// Date: 22.08.2012\r\n//\r\n// Description:\r\n// Highlighter for snippet magic words.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"SnippetHighlighter.h\"\r\n\r\n#include <QRegularExpression>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SnippedHighlighter::SnippedHighlighter()\r\n//-----------------------------------------------------------------------------\r\nSnippetHighlighter::SnippetHighlighter(QTextDocument* parent)\r\n    : QSyntaxHighlighter(parent)\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SnippedHighlighter::~SnippedHighlighter()\r\n//-----------------------------------------------------------------------------\r\nSnippetHighlighter::~SnippetHighlighter()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SnippedHighlighter::addMagicWords()\r\n//-----------------------------------------------------------------------------\r\nvoid SnippetHighlighter::addMagicWords(QStringList const& magicWords)\r\n{\r\n    magicWords_.append(magicWords);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SnippedHighlighter::clearMagicWords()\r\n//-----------------------------------------------------------------------------\r\nvoid SnippetHighlighter::clearMagicWords()\r\n{\r\n    magicWords_.clear();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SnippedHighlighter::highlightBlock()\r\n//-----------------------------------------------------------------------------\r\nvoid SnippetHighlighter::highlightBlock(QString const& text)\r\n{\r\n    foreach (QString const& word, magicWords_)\r\n    {\r\n        QRegularExpression expression(QString(\"\\\\$\") + word + QString(\"(_\\\\d+)?\\\\$\"));\r\n        \r\n        QRegularExpressionMatch match = expression.match(text);\r\n        int index = match.capturedStart();\r\n\r\n        while (index >= 0)\r\n        {\r\n            int length = match.capturedLength();\r\n            setFormat(index, length, Qt::blue);\r\n\r\n            match = expression.match(text, index + length);\r\n            index = match.capturedStart();\r\n        }\r\n    }\r\n}\r\n"
  },
  {
    "path": "common/widgets/SnippetTextEdit/SnippetHighlighter.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: SnippetHighlighter.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Joni-Matti Maatta\r\n// Date: 22.08.2012\r\n//\r\n// Description:\r\n// Highlighter for snippet magic words.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef SNIPPETHIGHLIGHTER_H\r\n#define SNIPPETHIGHLIGHTER_H\r\n\r\n#include <QSyntaxHighlighter>\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Highlighter for snippet magic words.\r\n//-----------------------------------------------------------------------------\r\nclass SnippetHighlighter : public QSyntaxHighlighter\r\n{\r\npublic:\r\n    /*!\r\n     *  Constructor.\r\n     */\r\n    explicit SnippetHighlighter(QTextDocument* parent);\r\n\r\n    /*!\r\n     *  Destructor.\r\n     */\r\n    virtual ~SnippetHighlighter();\r\n\r\n    /*!\r\n     *  Adds magic words.\r\n     *\r\n     *    @param [in] magicWords The magic words to add.\r\n     */\r\n    void addMagicWords(QStringList const& magicWords);\r\n\r\n    /*!\r\n     *  Clears the magic words.\r\n     */\r\n    void clearMagicWords();\r\n\r\nprotected:\r\n    /*!\r\n     *  Highlights a block of text.\r\n     */\r\n    void highlightBlock(QString const& text);\r\n\r\nprivate:\r\n    // Disable copying.\r\n    SnippetHighlighter(SnippetHighlighter const& rhs);\r\n    SnippetHighlighter& operator=(SnippetHighlighter const& rhs);\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! Magic words to highlight.\r\n    QStringList magicWords_;\r\n};\r\n\r\n#endif // SNIPPETHIGHLIGHTER_H\r\n"
  },
  {
    "path": "common/widgets/SnippetTextEdit/SnippetTextEdit.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: SnippetTextEdit.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Joni-Matti Maatta\r\n// Date: 22.08.2012\r\n//\r\n// Description:\r\n// Text edit for writing snippets that can use magic words.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"SnippetTextEdit.h\"\r\n\r\n#include \"SnippetHighlighter.h\"\r\n\r\n#include <QActionGroup>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SnippetTextEdit::SnippetTextEdit()\r\n//-----------------------------------------------------------------------------\r\nSnippetTextEdit::SnippetTextEdit(QWidget* parent)\r\n    : QPlainTextEdit(parent),\r\n      highlighter_(new SnippetHighlighter(document())),\r\n      magicWordsMap_()\r\n{\r\n    setContextMenuPolicy(Qt::CustomContextMenu);\r\n    connect(this, SIGNAL(customContextMenuRequested(QPoint const&)),\r\n            this, SLOT(showContextMenu(QPoint const&)), Qt::UniqueConnection);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SnippetTextEdit::~SnippetTextEdit()\r\n//-----------------------------------------------------------------------------\r\nSnippetTextEdit::~SnippetTextEdit()\r\n{\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SnippetTextEdit::addMagicWords()\r\n//-----------------------------------------------------------------------------\r\nvoid SnippetTextEdit::addMagicWords(QStringList const& magicWords, QString const& category /*= QString(\"\")*/)\r\n{\r\n    if (!magicWordsMap_.contains(category))\r\n    {\r\n        magicWordsMap_.insert(category, QStringList());\r\n    }\r\n\r\n    magicWordsMap_[category].append(magicWords);\r\n    magicWordsMap_[category].sort();\r\n\r\n    highlighter_->addMagicWords(magicWords);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SnippetTextEdit::clearMagicWords()\r\n//-----------------------------------------------------------------------------\r\nvoid SnippetTextEdit::clearMagicWords()\r\n{\r\n    magicWordsMap_.clear();\r\n    highlighter_->clearMagicWords();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SnippetTextEdit::showContextMenu()\r\n//-----------------------------------------------------------------------------\r\nvoid SnippetTextEdit::showContextMenu(QPoint const& pt)\r\n{\r\n    QMenu* menu = createStandardContextMenu();\r\n    QMenu* insertMenu = menu->addMenu(tr(\"Insert\"));\r\n\r\n    QMapIterator<QString, QStringList> iter(magicWordsMap_);\r\n\r\n    bool foundUnsorted = false;\r\n    QActionGroup* actionGroup = new QActionGroup(menu);\r\n\r\n    while (iter.hasNext())\r\n    {\r\n        iter.next();\r\n        \r\n        if (iter.key() == \"\")\r\n        {\r\n            foundUnsorted = true;\r\n        }\r\n        else\r\n        {\r\n            QMenu* categoryMenu = insertMenu->addMenu(iter.key());\r\n\r\n            foreach (QString const& name, iter.value())\r\n            {\r\n                QAction* action = new QAction(name, menu);\r\n                categoryMenu->addAction(action);\r\n                actionGroup->addAction(action);\r\n            }\r\n        }\r\n    }\r\n\r\n    if (foundUnsorted)\r\n    {\r\n        foreach (QString const& name, magicWordsMap_[\"\"])\r\n        {\r\n            QAction* action = new QAction(name, menu);\r\n            insertMenu->addAction(action);\r\n            actionGroup->addAction(action);\r\n        }\r\n    }\r\n\r\n    connect(actionGroup, SIGNAL(triggered(QAction*)), this, SLOT(insertMagicWord(QAction*)));\r\n\r\n    menu->exec(mapToGlobal(pt));\r\n    delete menu;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SnippetTextEdit::insertMagicWord()\r\n//-----------------------------------------------------------------------------\r\nvoid SnippetTextEdit::insertMagicWord(QAction* action)\r\n{\r\n    insertPlainText(QString(\"$\") + action->text() + QString(\"$\"));\r\n}\r\n"
  },
  {
    "path": "common/widgets/SnippetTextEdit/SnippetTextEdit.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: SnippetTextEdit.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Joni-Matti Maatta\r\n// Date: 22.08.2012\r\n//\r\n// Description:\r\n// Text edit for writing snippets that can use magic words.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef SNIPPETTEXTEDIT_H\r\n#define SNIPPETTEXTEDIT_H\r\n\r\n#include <QPlainTextEdit>\r\n#include <QMenu>\r\n\r\nclass SnippetHighlighter;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Text edit for writing snippets that can use magic words.\r\n//-----------------------------------------------------------------------------\r\nclass SnippetTextEdit : public QPlainTextEdit\r\n{\r\n    Q_OBJECT\r\n\r\npublic:\r\n    /*!\r\n     *  Constructor.\r\n     *\r\n     *    @param [in] parent The parent widget.\r\n     */\r\n    SnippetTextEdit(QWidget* parent);\r\n\r\n    /*!\r\n     *  Destructor.\r\n     */\r\n    ~SnippetTextEdit();\r\n\r\n    /*!\r\n     *  Adds the given magic words available for use.\r\n     *\r\n     *    @param [in] magicWords  The magic words to add.\r\n     *    @param [in] category    The category name for the words. Empty if uncategorized.\r\n     */\r\n    void addMagicWords(QStringList const& magicWords, QString const& category = QString(\"\"));\r\n\r\n    /*!\r\n     *  Removes all magic words from use.\r\n     */\r\n    void clearMagicWords();\r\n\r\nprivate slots:\r\n    /*!\r\n     *  Shows a custom context menu.\r\n     *\r\n     *    @param [in] pt The upper-left corner coordinate for the context menu.\r\n     */\r\n    void showContextMenu(QPoint const& pt);\r\n\r\n    /*!\r\n     *  Insert the magic word indicated by the given action to the current cursor location in the text.\r\n     */\r\n    void insertMagicWord(QAction* action);\r\n\r\nprivate:\r\n    // Disable copying.\r\n    SnippetTextEdit(SnippetTextEdit const& rhs);\r\n    SnippetTextEdit& operator=(SnippetTextEdit const& rhs);\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! The syntax highlighter.\r\n    SnippetHighlighter* highlighter_;\r\n\r\n    //! The magic words map.\r\n    QMap<QString, QStringList> magicWordsMap_;\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n\r\n#endif // SNIPPETTEXTEDIT_H\r\n"
  },
  {
    "path": "common/widgets/TreeItemSelector/FramedTreeItemEditor.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: FramedTreeItemEditor.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Esko Pekkarinen\n// Date: 6.9.2023\n//\n// Description:\n// \n//-----------------------------------------------------------------------------\n\n#include \"FramedTreeItemEditor.h\"\n\n#include <common/widgets/EnumCollectionEditor/EnumCollectionEditor.h>\n\n#include <QPushButton>\n#include <QScrollArea>\n\n//-----------------------------------------------------------------------------\n// Function: FramedTreeItemEditor::FramedTreeItemEditor()\n//-----------------------------------------------------------------------------\nFramedTreeItemEditor::FramedTreeItemEditor(MemoryTreeFactory const* factory, QWidget* parent):\nQFrame(parent),\neditor_(factory, this)\n{\n    setFrameStyle(QFrame::StyledPanel);\n    setFocusPolicy(Qt::StrongFocus);\n    setAttribute(Qt::WA_NoMousePropagation);\n    setAutoFillBackground(true);\n\n    okButton_->setIcon(QIcon(\":/icons/common/graphics/checkMark.png\"));\n    okButton_->setToolTip(\"Accept\");\n    okButton_->setEnabled(false);\n\n    cancelButton_->setIcon(QIcon(\":/icons/common/graphics/cross.png\"));\n    cancelButton_->setToolTip(\"Cancel\");\n\n    connect(okButton_, SIGNAL(clicked()), this, SIGNAL(finishEditing()), Qt::UniqueConnection);\n    connect(cancelButton_, SIGNAL(clicked()), this, SIGNAL(cancelEditing()), Qt::UniqueConnection);\n\n    connect(&editor_, SIGNAL(selectionChanged()), this, SLOT(validateSelection()), Qt::UniqueConnection);\n\n    setupLayout();\n}\n\n//-----------------------------------------------------------------------------\n// Function: FramedTreeItemEditor::selectPath()\n//-----------------------------------------------------------------------------\nvoid FramedTreeItemEditor::selectPath(QStringList const& path)\n{\n    editor_.selectPath(path);\n    validateSelection();\n}\n\n//-----------------------------------------------------------------------------\n// Function: FramedTreeItemEditor::selectedPath()\n//-----------------------------------------------------------------------------\nQStringList FramedTreeItemEditor::selectedPath() const\n{\n    return editor_.selectedPath();\n}\n\n//-----------------------------------------------------------------------------\n// Function: FramedTreeItemEditor::validateSelection()\n//-----------------------------------------------------------------------------\nvoid FramedTreeItemEditor::validateSelection()\n{\n    auto path = editor_.selectedPath();\n\n    okButton_->setEnabled(path.isEmpty() == false && path.last().startsWith(\"Field\"));\n}\n\n//-----------------------------------------------------------------------------\n// Function: FramedTreeItemEditor::setupLayout()\n//-----------------------------------------------------------------------------\nvoid FramedTreeItemEditor::setupLayout()\n{\n    editor_.setContentsMargins(0, 0, 0, 0);\n\n    auto buttonLayout = new QHBoxLayout();\n    buttonLayout->addStretch(10);\n    buttonLayout->addWidget(okButton_);\n    buttonLayout->addWidget(cancelButton_);\n\n    auto mainLayout = new QVBoxLayout(this);\n    mainLayout->addWidget(&editor_, 10);\n    mainLayout->addLayout(buttonLayout, 0);\n    mainLayout->setSpacing(1);\n    mainLayout->setContentsMargins(0, 0, 0, 0);\n\n}\n"
  },
  {
    "path": "common/widgets/TreeItemSelector/FramedTreeItemEditor.h",
    "content": "//-----------------------------------------------------------------------------\n// File: FramedTreeItemEditor.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Esko Pekkarinen\n// Date: 6.9.2023\n//\n// Description:\n// \n//-----------------------------------------------------------------------------\n\n#ifndef FRAMED_TREEITEMEDITOR_H\n#define FRAMED_TREEITEMEDITOR_H\n\n#include <QFrame>\n#include <QCheckBox>\n\n#include <common/widgets/TreeItemSelector/TreeItemEditor.h>\n\n#include <editors/ComponentEditor/common/MemoryTreeFactory.h>\n\n//-----------------------------------------------------------------------------\n//! Editor for enumerations.\n//-----------------------------------------------------------------------------\nclass FramedTreeItemEditor : public QFrame\n{\n    Q_OBJECT\n\npublic:\n    /*!\n     *  Constructor.\n     *\n     *    @param [in] parent          The parent widget.\n     */\n    FramedTreeItemEditor(MemoryTreeFactory const* factory, QWidget* parent);\n\n    /*!\n     *  Destructor.\n     */\n    virtual ~FramedTreeItemEditor() = default;\n\n    // Disable copying.\n    FramedTreeItemEditor(FramedTreeItemEditor const& rhs) = delete;\n    FramedTreeItemEditor& operator=(FramedTreeItemEditor const& rhs) = delete;\n\n    void selectPath(QStringList const& path);\n\n    QStringList selectedPath() const;\n\nsignals:\n\n    /*!\n     *  Signal for canceling the editing.\n     */\n    void cancelEditing();\n\n    /*!\n     *  Signal for accepting the edits.\n     */\n    void finishEditing();\n\nprivate slots:\n\n    void validateSelection();\n\nprivate:\n    /*!\n     *  Setup the layout.\n     */\n    void setupLayout();\n\n    //-----------------------------------------------------------------------------\n    // Data.\n    //-----------------------------------------------------------------------------\n\n    //! The editor for tree items.\n    TreeItemEditor editor_;\n\n\n    QPushButton* okButton_ = new QPushButton(this);\n\n    QPushButton* cancelButton_ = new QPushButton(this);\n};\n\n#endif // FRAMED_TREEITEMEDITOR_H\n"
  },
  {
    "path": "common/widgets/TreeItemSelector/TreeItem.h",
    "content": "//-----------------------------------------------------------------------------\n// File: TreeItem.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Esko Pekkarinen\n// Date: 30.8.2023\n//\n// Description:\n// A generic tree item.\n//-----------------------------------------------------------------------------\n\n#include <QString>\n#include <QList>\n\n#ifndef TREEITEM_H\n#define TREEITEM_H\n\n//! A single item in a tree.\nstruct TreeItem \n{\n    /*!\n     *  The constructor.\n     *\n     *    @param [in] name    The name of the item.\n     *    @param [in] type    The type of the item.\n     *    @param [in] parent  The parent of the item.\n     *\n     *    @return \n     */\n    TreeItem(QString const& name, QString const& type) :\n        name(name), type(type), parent(nullptr) {};\n\n    //! The destructor.\n    ~TreeItem()\n    {\n        for (TreeItem* child : children)\n        {\n            delete child;\n        }\n    };\n\n    /*!\n     *  Adds a child to the item.\n     *\n     *    @param [in] child   The child to add.\n     */\n    void addChild(TreeItem* child)\n    {\n        children.append(child);\n        child->parent = this;\n    }\n\n    //-----------------------------------------------------------------------------\n    // Data.\n    //-----------------------------------------------------------------------------\n\n    QString name; \n    QString type;\n    TreeItem* parent;\n    QList<TreeItem*> children;\n};\n\n#endif // TREEITEM_H"
  },
  {
    "path": "common/widgets/TreeItemSelector/TreeItemEditor.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: TreeItemEditor.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Esko Pekkarinen\n// Date: 30.8.2023\n//\n// Description:\n// Editor for selecting a single item from a tree.\n//-----------------------------------------------------------------------------\n\n#include \"TreeItemEditor.h\"\n\n#include \"TreeItem.h\"\n\n#include <QVBoxLayout>\n#include <QHeaderView>\n\n//-----------------------------------------------------------------------------\n// Function: TreeItemEditor::TreeItemEditor()\n//-----------------------------------------------------------------------------\nTreeItemEditor::TreeItemEditor(MemoryTreeFactory const* factory, QWidget* parent) : QWidget(parent)\n{\n    setAutoFillBackground(true);\n\n    searchEditor_->addAction(QIcon(\":/icons/common/graphics/search.png\"), QLineEdit::LeadingPosition);\n    searchEditor_->setPlaceholderText(tr(\"Search\"));\n    searchEditor_->setClearButtonEnabled(true);\n\n    expandButton_->setFlat(true);\n    expandButton_->setToolTip(tr(\"Expand all\"));\n    expandButton_->setIcon(QIcon(\":/icons/common/graphics/triangle_arrow_down.png\"));\n\n    model_ = new TreeItemModel(factory->create(), this);\n    \n    proxy_->setSourceModel(model_);\n    proxy_->setFilterKeyColumn(0);\n    proxy_->setRecursiveFilteringEnabled(true);\n\n    view_->setModel(proxy_);\n    view_->setHeaderHidden(true);\n    view_->setUniformRowHeights(true);\n    view_->header()->setSectionResizeMode(QHeaderView::ResizeToContents);\n    view_->expandAll();\n\n    connect(searchEditor_, SIGNAL(textChanged(QString const&)), this, SLOT(onSearchChanged(QString const&)));\n    \n    connect(expandButton_, SIGNAL(clicked()), this, SLOT(onExpandCollapse()));\n\n    connect(view_, SIGNAL(clicked(QModelIndex)), this, SIGNAL(selectionChanged()), Qt::UniqueConnection);\n\n    setupLayout();\n}\n\n//-----------------------------------------------------------------------------\n// Function: TreeItemEditor::selectPath()\n//-----------------------------------------------------------------------------\nvoid TreeItemEditor::selectPath(QStringList const& path)\n{\n    auto index = proxy_->mapFromSource(QModelIndex());\n\n    // Select the item at the end of the path\n    for (auto const& item : path)\n    {\n        // find the child item with given name\n        index = findChild(index, item.split('/').last());\n\n        if (index.isValid() == false)\n        {\n            return;\n        }\n    }\n\n    view_->setCurrentIndex(index);\n}\n\n//-----------------------------------------------------------------------------\n// Function: TreeItemEditor::findChild()\n//-----------------------------------------------------------------------------\nQModelIndex TreeItemEditor::findChild(QModelIndex const& parent, QString const& name)\n{\n    for (int i = 0; i < proxy_->rowCount(parent); ++i)\n    {\n        auto child = proxy_->index(i, 0, parent);\n\n        if (child.data().toString() == name)\n        {\n            return child;\n\n        }\n    }\n\n    return QModelIndex();\n}\n\n//-----------------------------------------------------------------------------\n// Function: TreeItemEditor::selectedPath()\n//-----------------------------------------------------------------------------\nQStringList TreeItemEditor::selectedPath() const\n{\n    QStringList path;\n\n    if (auto const& index = proxy_->mapToSource(view_->currentIndex()); index.isValid())\n    {\n        auto treeItem = static_cast<TreeItem*>(index.internalPointer());\n\n        while (treeItem)\n        {\n            path.prepend(treeItem->type + \"/\" + treeItem->name);\n            treeItem = treeItem->parent;\n        }\n    }\n    \n    // Remove the root item\n    if (path.isEmpty() == false)\n    {\n        path.pop_front();\n    }\n    return path;\n}\n\n//-----------------------------------------------------------------------------\n// Function: TreeItemEditor::onSearchChanged()\n//-----------------------------------------------------------------------------\nvoid TreeItemEditor::onSearchChanged(QString const& searchText)\n{\n    proxy_->setFilterRegularExpression(QRegularExpression(searchText, QRegularExpression::CaseInsensitiveOption));\n}\n\n//-----------------------------------------------------------------------------\n// Function: TreeItemEditor::onExpandCollapse()\n//-----------------------------------------------------------------------------\nvoid TreeItemEditor::onExpandCollapse()\n{\n    if (expanded_)\n    {\n        view_->collapseAll();\n        expandButton_->setIcon(QIcon(\":/icons/common/graphics/triangle_arrow_right.png\"));\n        expandButton_->setToolTip(tr(\"Expand all\"));\n    }\n    else\n    {\n        view_->expandAll();\n        expandButton_->setIcon(QIcon(\":/icons/common/graphics/triangle_arrow_down.png\"));\n        expandButton_->setToolTip(tr(\"Collapse all\"));\n    }\n\n    expanded_ = !expanded_;\n}\n\n//-----------------------------------------------------------------------------\n// Function: TreeItemEditor::setupLayout()\n//-----------------------------------------------------------------------------\nvoid TreeItemEditor::setupLayout()\n{\n    auto controlLayout = new QHBoxLayout();\n    controlLayout->addWidget(searchEditor_);\n    controlLayout->addWidget(expandButton_);\n    controlLayout->setSpacing(1);\n\n    view_->setContentsMargins(0, 0, 0, 0);\n\n    auto layout = new QVBoxLayout(this);\n    layout->addLayout(controlLayout);\n    layout->addWidget(view_);\n    layout->setSpacing(2);\n    layout->setContentsMargins(0, 0, 0, 0);\n}\n"
  },
  {
    "path": "common/widgets/TreeItemSelector/TreeItemEditor.h",
    "content": "//-----------------------------------------------------------------------------\n// File: TreeItemEditor.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Esko Pekkarinen\n// Date: 30.8.2023\n//\n// Description:\n// Editor for selecting a single item from a tree.\n//-----------------------------------------------------------------------------\n\n#ifndef TREEITEMEDITOR_H\n#define TREEITEMEDITOR_H\n\n#include \"TreeItemModel.h\"\n\n#include <editors/ComponentEditor/common/MemoryTreeFactory.h>\n\n#include <QLineEdit>\n#include <QPushButton>\n#include <QSortFilterProxyModel>\n#include <QTreeView>\n#include <QWidget>\n\n//-----------------------------------------------------------------------------\n//! Editor for selecting a single item from a tree.\n//-----------------------------------------------------------------------------\nclass TreeItemEditor : public QWidget\n{\n    Q_OBJECT\n\npublic:\n\n    /*!\n     *  The constructor.\n     *\n     *    @param [in] factory     Factory for creating the tree.\n     *    @param [in] parent      The parent widget.\n     */\n    TreeItemEditor(MemoryTreeFactory const* factory, QWidget* parent = nullptr);\n\n\n    //! The destructor.\n    virtual ~TreeItemEditor() = default;\n\n    // Disable copying.\n    TreeItemEditor(TreeItemEditor const& rhs) = delete;\n    TreeItemEditor& operator=(TreeItemEditor const& rhs) = delete;\n\n    /*!\n     *  Selects the given path in the tree.\n     *\n     *    @param [in] path    The path to select.\n     */\n    void selectPath(QStringList const& path);\n\n    QStringList selectedPath() const;\n\nsignals:\n\n    //! Emitted when the selection changes.\n    void selectionChanged();\n\nprivate slots:\n\n    //! Handler for search bar text changes.\n    void onSearchChanged(QString const& searchText);\n\n    //! Handler for expand/collapse button clicks.\n    void onExpandCollapse();\n\nprivate:\n\n    /*!\n     *  Finds a child with the given name.\n     *\n     *    @param [in] parent  The parent of the child.\n     *    @param [in] name    The name of the child to find.\n     *\n     *    @return The index of the found child.\n     */\n    QModelIndex findChild(QModelIndex const& parent, QString const& name);\n\n    //! Setup the layout.\n    void setupLayout();\n\n    //-----------------------------------------------------------------------------\n    // Data.\n    //-----------------------------------------------------------------------------\n\n    //! The search bar.\n    QLineEdit* searchEditor_ = new QLineEdit(this);\n\n    //! The button for expanding/collapsing the tree.\n    QPushButton* expandButton_ = new QPushButton(this);\n    \n    //! The tree expand/collapse state.\n    bool expanded_ = true;\n\n    //! The tree view.\n    QTreeView* view_ = new QTreeView(this);\n\n    //! The proxy model for filtering the tree.\n    QSortFilterProxyModel* proxy_ = new QSortFilterProxyModel(this);\n\n    //! The tree model.\n    TreeItemModel* model_ = nullptr;\n};\n\n#endif // TREEITEMEDITOR_H"
  },
  {
    "path": "common/widgets/TreeItemSelector/TreeItemModel.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: TreeItemModel.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Esko Pekkarinen\n// Date: 30.8.2023\n//\n// Description:\n// A model for generic tree items.\n//-----------------------------------------------------------------------------\n\n#include \"TreeItemModel.h\"\n\n#include \"TreeItem.h\"\n\n#include <common/KactusColors.h>\n\n//-----------------------------------------------------------------------------\n// Function: TreeItemModel::TreeItemModel()\n//-----------------------------------------------------------------------------\nTreeItemModel::TreeItemModel(TreeItem* rootItem, QObject* parent): \n    QAbstractItemModel(parent), \n    rootItem_(rootItem)\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: TreeItemModel::index()\n//-----------------------------------------------------------------------------\nQModelIndex TreeItemModel::index(int row, int column, QModelIndex const& parent) const\n{\n    if (!hasIndex(row, column, parent))\n    {\n        return QModelIndex();\n    }\n\n    auto parentItem = getItem(parent);\n\n    if (auto childItem = parentItem->children.at(row); childItem != nullptr)\n    {\n        return createIndex(row, column, childItem);\n    }\n\n    return QModelIndex();\n}\n\n//-----------------------------------------------------------------------------\n// Function: TreeItemModel::parent()\n//-----------------------------------------------------------------------------\nQModelIndex TreeItemModel::parent(QModelIndex const& child) const\n{\n    if (!child.isValid())\n    {\n        return QModelIndex();\n    }\n\n    auto parentItem = getItem(child)->parent;\n\n    if (parentItem == rootItem_)\n    {\n        return QModelIndex();\n    }\n\n    int parentRow = parentItem->parent->children.indexOf(parentItem);\n\n    return createIndex(parentRow, 0, parentItem);\n}\n\n//-----------------------------------------------------------------------------\n// Function: TreeItemModel::rowCount()\n//-----------------------------------------------------------------------------\nint TreeItemModel::rowCount(QModelIndex const& parent) const\n{\n    if (parent.column() > 0)\n    {\n        return 0;\n    }\n\n    return getItem(parent)->children.count();\n}\n\n//-----------------------------------------------------------------------------\n// Function: TreeItemModel::columnCount()\n//-----------------------------------------------------------------------------\nint TreeItemModel::columnCount(QModelIndex const& /*parent*/) const\n{\n    return 2;\n}\n\n//-----------------------------------------------------------------------------\n// Function: TreeItemModel::flags()\n//-----------------------------------------------------------------------------\nQt::ItemFlags TreeItemModel::flags(const QModelIndex& index) const\n{\n    if (!index.isValid())\n    {\n        return Qt::NoItemFlags;\n    }\n\n\n    return Qt::ItemIsSelectable | Qt::ItemIsEnabled;\n}\n\n//-----------------------------------------------------------------------------\n// Function: TreeItemModel::data()\n//-----------------------------------------------------------------------------\nQVariant TreeItemModel::data(QModelIndex const& index, int role) const\n{\n    if (!index.isValid())\n    {\n        return QVariant();\n    }\n\n    auto item = getItem(index);\n\n    if (role == Qt::DisplayRole)\n    {\n        if (index.column() == 0)\n        {\n            return item->name;\n        }\n        else\n        {\n            return item->type;\n        }\n    }\n    else if (role == Qt::ForegroundRole)\n    {\n        if (index.column() == 0)\n        {\n            return KactusColors::REGULAR_TEXT;\n        }\n        else\n        {\n            return KactusColors::DISABLED_TEXT;\n        }\n    }\n\n    return QVariant();\n}\n\n//-----------------------------------------------------------------------------\n// Function: TreeItemModel::hasChildren()\n//-----------------------------------------------------------------------------\nbool TreeItemModel::hasChildren(QModelIndex const& parent) const\n{ \n    return getItem(parent)->children.isEmpty() == false;\n}\n\n\n//-----------------------------------------------------------------------------\n// Function: TreeItemModel::getItem()\n//-----------------------------------------------------------------------------\nTreeItem* TreeItemModel::getItem(QModelIndex const& index) const\n{\n    if (index.isValid())\n    {\n        return static_cast<TreeItem*>(index.internalPointer());\n    }\n        \n    return rootItem_;\n}\n"
  },
  {
    "path": "common/widgets/TreeItemSelector/TreeItemModel.h",
    "content": "//-----------------------------------------------------------------------------\n// File: TreeItemModel.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Esko Pekkarinen\n// Date: 30.8.2023\n//\n// Description:\n// A model for generic tree items.\n//-----------------------------------------------------------------------------\n\n#include \"TreeItem.h\"\n\n#include <QAbstractItemModel>\n\n//-----------------------------------------------------------------------------\n//! A model for generic tree items.\n//-----------------------------------------------------------------------------\nclass TreeItemModel : public QAbstractItemModel\n{\n    Q_OBJECT\n\npublic:\n\n    TreeItemModel(TreeItem* rootItem, QObject* parent = nullptr);\n\n    //! The destructor.\n    virtual ~TreeItemModel() = default;\n\n\n\n    QModelIndex index(int row, int column, const QModelIndex& parent = QModelIndex()) const override;\n\n\n    QModelIndex parent(const QModelIndex& child) const override;\n\n\n    int rowCount(const QModelIndex& parent = QModelIndex()) const override;\n\n\n\n    int columnCount(const QModelIndex& parent = QModelIndex()) const override;\n\n    Qt::ItemFlags flags(const QModelIndex& index) const override;\n\n    QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override;\n\n\n    bool hasChildren(const QModelIndex& parent = QModelIndex()) const override;\n\n\n\nprivate:\n\n    TreeItem* getItem(QModelIndex const& index ) const;\n\n    TreeItem* rootItem_ = nullptr;\n};"
  },
  {
    "path": "common/widgets/accessComboBox/accesscombobox.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: accesscombobox.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Antti Kamppi\r\n// Date: 23.08.2012\r\n//\r\n// Description:\r\n// The combo box to select one of the defined access types.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"accesscombobox.h\"\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AccessComboBox::AccessComboBox()\r\n//-----------------------------------------------------------------------------\r\nAccessComboBox::AccessComboBox(QWidget *parent):\r\nQComboBox(parent) \r\n{  \r\n\t// only the available options can be selected\r\n\tsetEditable(false);\r\n\r\n    // add items for all available access-values\r\n    for (int i = 0; i <= AccessTypes::ACCESS_COUNT; ++i)\r\n    {\r\n        QString text = AccessTypes::access2Str(static_cast<AccessTypes::Access>(i));\r\n        addItem(text);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AccessComboBox::~AccessComboBox()\r\n//-----------------------------------------------------------------------------\r\nAccessComboBox::~AccessComboBox() \r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AccessComboBox::getCurrentValue()\r\n//-----------------------------------------------------------------------------\r\nAccessTypes::Access AccessComboBox::getCurrentValue() const\r\n{\r\n\treturn static_cast<AccessTypes::Access>(currentIndex());\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AccessComboBox::setCurrentValue()\r\n//-----------------------------------------------------------------------------\r\nvoid AccessComboBox::setCurrentValue(AccessTypes::Access access)\r\n{\r\n\tsetCurrentIndex(access);\r\n}\t\r\n"
  },
  {
    "path": "common/widgets/accessComboBox/accesscombobox.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: accesscombobox.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Antti Kamppi\r\n// Date: 23.08.2012\r\n//\r\n// Description:\r\n// The combo box to select one of the defined access types.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef ACCESSCOMBOBOX_H\r\n#define ACCESSCOMBOBOX_H\r\n\r\n#include <IPXACTmodels/common/AccessTypes.h>\r\n\r\n#include <QComboBox>\r\n\r\n//-----------------------------------------------------------------------------\r\n//! The combo box to select one of the defined access types.\r\n//-----------------------------------------------------------------------------\r\nclass AccessComboBox : public QComboBox\r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\r\n\t/*!\r\n     *  The constructor.\r\n\t *\r\n     *      param [in] parent   Pointer to the owner of the combo box.\r\n\t */\r\n\tAccessComboBox(QWidget *parent);\r\n\t\r\n\t//! The destructor.\r\n\tvirtual ~AccessComboBox();\r\n\r\n\t/*!\r\n     *  Get the currently selected access value.\r\n\t *\r\n\t *    @return The selected value.\r\n\t */\r\n\tAccessTypes::Access getCurrentValue() const;\r\n\r\n\t/*!\r\n     *  Set the value to be currently selected.\r\n\t *\r\n\t *    @param [in] access  The value to select.\r\n\t */\r\n\tvoid setCurrentValue(AccessTypes::Access access);\r\n\r\nprivate:\r\n\t\r\n\t//! No copying.\r\n\tAccessComboBox(const AccessComboBox& other);\r\n\r\n\t//! No assignment.\r\n\tAccessComboBox& operator=(const AccessComboBox& other);\r\n};\r\n\r\n#endif // ACCESSCOMBOBOX_H\r\n"
  },
  {
    "path": "common/widgets/assistedLineEdit/AssistedLineEdit.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: AssistedLineEdit.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Joni-Matti Maatta\r\n// Date: 8.2.2010\r\n//\r\n// Description:\r\n// Assisted line edit widget.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"AssistedLineEdit.h\"\r\n\r\n#include <cassert>\r\n#include <algorithm>\r\n#include <QFont>\r\n#include <QApplication>\r\n#include <QTextBlock>\r\n\r\n#include \"LineContentAssistWidget.h\"\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AssistedTextEdit()\r\n//-----------------------------------------------------------------------------\r\nAssistedLineEdit::AssistedLineEdit(QWidget* parentWnd, QWidget* parent) : \r\nQLineEdit(parent),\r\ncontentAssist_(new LineContentAssistWidget(this, parentWnd)) // NOTE: parent window set as parent so that \r\n                                                             // content assist visibility isn't dependent \r\n                                                             // on \"real\" parent widget size!\r\n{\r\n    contentAssist_->setFocusProxy(this);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: keyPressEvent()\r\n//-----------------------------------------------------------------------------\r\nvoid AssistedLineEdit::keyPressEvent(QKeyEvent* e)\r\n{\r\n    // First try to handle the key fully by the content assist.\r\n    if (!contentAssist_->tryHandleKey(e))\r\n    {\r\n        // Otherwise process the key event as usual.\r\n        QLineEdit::keyPressEvent(e);\r\n        \r\n        contentAssist_->updateAssist(e);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: focusOutEvent()\r\n//-----------------------------------------------------------------------------\r\nvoid AssistedLineEdit::focusInEvent(QFocusEvent* e)\r\n{\r\n    QLineEdit::focusInEvent(e);\r\n\r\n    if (e->reason() != Qt::ActiveWindowFocusReason)\r\n    {\r\n        contentAssist_->setWidthForAssist(width());\r\n        contentAssist_->updateAssist(0);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: focusOutEvent()\r\n//-----------------------------------------------------------------------------\r\nvoid AssistedLineEdit::focusOutEvent(QFocusEvent* e)\r\n{\r\n    QLineEdit::focusOutEvent(e);\r\n\r\n    // Cancel the content assist if content is shown.\r\n    if (contentAssist_->isContentShown())\r\n    {\r\n        contentAssist_->cancel();\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AssistedLineEdit::setContentMatcher()\r\n//-----------------------------------------------------------------------------\r\nvoid AssistedLineEdit::setContentMatcher(ILineContentMatcher* matcher)\r\n{\r\n    matcher_ = matcher;\r\n    contentAssist_->setContentMatcher(matcher);\r\n}\r\n"
  },
  {
    "path": "common/widgets/assistedLineEdit/AssistedLineEdit.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: assistedlineedit.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Joni-Matti Maatta\r\n// Date: 8.2.2011\r\n//\r\n// Description:\r\n// Assisted line edit widget.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef ASSISTEDLINEEDIT_H\r\n#define ASSISTEDLINEEDIT_H\r\n\r\n#include <QLineEdit>\r\n\r\n#include <QWidget>\r\n#include <QLineEdit>\r\n#include <QSharedPointer>\r\n\r\nclass ILineContentMatcher;\r\nclass LineContentAssistWidget;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! AssistedLineEdit class.\r\n//-----------------------------------------------------------------------------\r\nclass AssistedLineEdit : public QLineEdit\r\n{\r\n    Q_OBJECT\r\n\r\npublic:\r\n\r\n    /*!\r\n     *  The constructor.\r\n     *\r\n     *    @param [in] parentWnd   The parent window of the line edit. Must not be null.\r\n     *    @param [in] parent      The parent widget. Can be null.\r\n     */\r\n    AssistedLineEdit(QWidget* parentWnd, QWidget* parent = 0);\r\n\r\n    /*!\r\n     *  The destructor.\r\n     */\r\n    virtual ~AssistedLineEdit() = default;\r\n\r\n    // Disable copying.\r\n    AssistedLineEdit(AssistedLineEdit const& rhs) = delete;\r\n    AssistedLineEdit& operator=(AssistedLineEdit const& rhs) = delete;\r\n\r\n    /*!\r\n     *  Sets the content matcher.\r\n     *\r\n     *    @param [in] matcher The matcher to set.\r\n     */\r\n    void setContentMatcher(ILineContentMatcher* matcher);\r\n\r\nprotected:\r\n\r\n    /*!\r\n     *  Handles the given key press event.\r\n     *\r\n     *    @param [in] e The key event.\r\n     */\r\n    void keyPressEvent(QKeyEvent* e);\r\n\r\n    /*!\r\n     *  Handles the focus in event.\r\n     */\r\n    void focusInEvent(QFocusEvent* e);\r\n\r\n    /*!\r\n     *  Handles the focus out event.\r\n     */\r\n    void focusOutEvent(QFocusEvent* e);\r\n\r\nprivate:\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! The content matcher.\r\n    ILineContentMatcher* matcher_ = nullptr;\r\n\r\n    //! Content assist list widget.\r\n    LineContentAssistWidget* contentAssist_;\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n\r\n#endif // ASSISTEDLINEEDIT_H\r\n"
  },
  {
    "path": "common/widgets/assistedLineEdit/BasicLineContentMatcher.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: BasicLineContentMatcher.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Joni-Matti Maatta\r\n// Date: 20.08.2012\r\n//\r\n// Description:\r\n// Line content matcher for simple list-based suggestions.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"BasicLineContentMatcher.h\"\r\n\r\n#include <QRegularExpression>\r\n#include <common/widgets/assistedLineEdit/LineContentAssistWidget.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BasicLineContentMatcher::BasicLineContentMatcher()\r\n//-----------------------------------------------------------------------------\r\nBasicLineContentMatcher::BasicLineContentMatcher()\r\n    : items_()\r\n{\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BasicLineContentMatcher::~BasicLineContentMatcher()\r\n//-----------------------------------------------------------------------------\r\nBasicLineContentMatcher::~BasicLineContentMatcher()\r\n{\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BasicLineContentMatcher::addItems()\r\n//-----------------------------------------------------------------------------\r\nvoid BasicLineContentMatcher::setItems(QStringList const& items)\r\n{\r\n    items_ = items;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BasicLineContentMatcher::lookForwardMatch()\r\n//-----------------------------------------------------------------------------\r\nbool BasicLineContentMatcher::lookForwardMatch(QString const& text)\r\n{\r\n    return enumerateMatches(text, 0);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BasicLineContentMatcher::fillWithContent()\r\n//-----------------------------------------------------------------------------\r\nbool BasicLineContentMatcher::fillWithContent(QString const& text, LineContentAssistWidget& assist,\r\n                                              int& startIndex, QString&, int&)\r\n{\r\n    startIndex = 0;\r\n    bool ret = enumerateMatches(text, &assist);\r\n    assist.sortItems();\r\n    return ret;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BasicLineContentMatcher::enumerateMatches()\r\n//-----------------------------------------------------------------------------\r\nbool BasicLineContentMatcher::enumerateMatches(QString const& text, LineContentAssistWidget* assist) const\r\n{\r\n    QRegularExpression exp(\"^\" + text.toLower() + \".*\", QRegularExpression::DotMatchesEverythingOption);\r\n\r\n    int count = 0;\r\n    bool exactMatch = false;\r\n\r\n    foreach (QString const& item, items_)\r\n    {\r\n        if (item.toLower().contains(exp))\r\n        {\r\n            if (assist != 0)\r\n            {\r\n                QListWidgetItem* listItem = new QListWidgetItem(item);\r\n                assist->addItem(listItem);\r\n            }\r\n\r\n            ++count;\r\n\r\n            if (!exactMatch && item == text)\r\n            {\r\n                exactMatch = true;\r\n            }\r\n        }\r\n    }\r\n\r\n    return (count > 1 || (count == 1 && !exactMatch));\r\n}\r\n"
  },
  {
    "path": "common/widgets/assistedLineEdit/BasicLineContentMatcher.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: BasicLineContentMatcher.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Joni-Matti Maatta\r\n// Date: 20.08.2012\r\n//\r\n// Description:\r\n// Line content matcher for simple list-based suggestions.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef BASICLINECONTENTMATCHER_H\r\n#define BASICLINECONTENTMATCHER_H\r\n\r\n#include <common/widgets/assistedLineEdit/ILineContentMatcher.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Line content matcher for simple list-based suggestions.\r\n//-----------------------------------------------------------------------------\r\nclass BasicLineContentMatcher : public ILineContentMatcher\r\n{\r\npublic:\r\n    /*!\r\n     *\tConstructor.\r\n     */\r\n    BasicLineContentMatcher();\r\n\r\n    /*!\r\n     *  Destructor.\r\n     */\r\n    virtual ~BasicLineContentMatcher();\r\n\r\n    /*!\r\n     *  Sets the items that will be suggested by the content assist.\r\n     *\r\n     *    @param [in] items A list of string items.\r\n     */\r\n    void setItems(QStringList const& items);\r\n\r\n    /*!\r\n     *  Looks forward for matching contents in the given text.\r\n     *\r\n     *    @param [in] text The text.\r\n     *\r\n     *    @return True, if there is a match. Otherwise false.\r\n     */\r\n    bool lookForwardMatch(QString const& text);\r\n\r\n    /*!\r\n     *  Fills the content assist with content based on the given text.\r\n     *\r\n     *    @param [in]  text          The text.\r\n     *    @param [in]  assist        The content assist to fill with content.\r\n     *    @param [out] startIndex    The start index of the selection to which the content applies.\r\n     *    @param [out] toolTipText   The tool tip hint text. Empty if no tool tip available.\r\n     *    @param [out] toolTipIndex  The index which specifies there start position for the tool tip hint.\r\n     *\r\n     *    @return True, if content was found; otherwise false.\r\n     */\r\n    bool fillWithContent(QString const& text, LineContentAssistWidget& assist,\r\n                         int& startIndex, QString& toolTipText, int& toolTipIndex);\r\n\r\nprivate:\r\n    // Disable copying.\r\n    BasicLineContentMatcher(BasicLineContentMatcher const& rhs);\r\n    BasicLineContentMatcher& operator=(BasicLineContentMatcher const& rhs);\r\n\r\n    /*!\r\n     *  Enumerates matches based on the string. If the content assist is specified, the matching\r\n     *  contents is also added to it.\r\n     *\r\n     *    @param [in] text    The text to which to match content.\r\n     *    @param [in] assist  The content assist to fill with content. Can be null.\r\n     *\r\n     *    @return True, if there was content found; otherwise false.\r\n     */\r\n    bool enumerateMatches(QString const& text, LineContentAssistWidget* assist) const;\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! The suggestions items list.\r\n    QStringList items_;\r\n};\r\n\r\n\r\n#endif // BASICLINECONTENTMATCHER_H\r\n"
  },
  {
    "path": "common/widgets/assistedLineEdit/ILineContentMatcher.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ILineContentMatcher.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Joni-Matti Maatta\r\n// Date: 11.1.2011\r\n//\r\n// Description:\r\n// Content matcher interface for assisted line edits.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef ILINECONTENTMATCHER_H\r\n#define ILINECONTENTMATCHER_H\r\n\r\n#include <QPlainTextEdit>\r\n\r\nclass LineContentAssistWidget;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! ILineContentMatcher class.\r\n//-----------------------------------------------------------------------------\r\nclass ILineContentMatcher\r\n{\r\npublic:\r\n    /*!\r\n     *  Destructor.\r\n     */\r\n    virtual ~ILineContentMatcher() {}\r\n\r\n    /*!\r\n     *  Looks forward for matching contents in the given text.\r\n     *\r\n     *    @param [in] text The text.\r\n     *\r\n     *    @return True, if there is a match. Otherwise false.\r\n     */\r\n    virtual bool lookForwardMatch(QString const& text) = 0;\r\n\r\n    /*!\r\n     *  Fills the content assist with content based on the given text.\r\n     *\r\n     *    @param [in]  text The text.\r\n     *    @param [in]  assist        The content assist to fill with content.\r\n     *    @param [out] startIndex    The start index of the selection to which the content applies.\r\n     *    @param [out] toolTipText   The tool tip hint text. Empty if no tool tip available.\r\n     *    @param [out] toolTipIndex  The index which specifies there start position for the tool tip hint.\r\n     *\r\n     *    @return True, if content was found; otherwise false.\r\n     */\r\n    virtual bool fillWithContent(QString const& text, LineContentAssistWidget& assist,\r\n                                 int& startIndex, QString& toolTipText, int& toolTipIndex) = 0;\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n\r\n#endif // ILINECONTENTMATCHER_H\r\n"
  },
  {
    "path": "common/widgets/assistedLineEdit/LineContentAssistWidget.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: LineContentAssistWidget.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Joni-Matti Maatta\r\n// Date: 4.1.2011\r\n//\r\n// Description:\r\n// Content assist widget.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"LineContentAssistWidget.h\"\r\n\r\n#include <common/KactusColors.h>\r\n\r\n#include <algorithm>\r\n#include <QScrollBar>\r\n#include <QRegularExpression>\r\n#include <QToolTip>\r\n#include <QTextCursor>\r\n#include <QApplication>\r\n#include <QLabel>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LineContentAssistWidget()\r\n//-----------------------------------------------------------------------------\r\nLineContentAssistWidget::LineContentAssistWidget(QLineEdit* target, QWidget* parentWnd):\r\nQListWidget(parentWnd),\r\ntarget_(target),\r\nmatcher_(0),\r\nmaxVisibleItems_(DEFAULT_MAX_VISIBLE_ITEMS),\r\nlastAssistStartPos_(-1),\r\ncontentFound_(false),\r\nlineAssistWidth_(0)\r\n{\r\n    Q_ASSERT(parentWnd != 0);\r\n    Q_ASSERT(target != 0);\r\n\r\n    // Set widget settings.\r\n    setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);\r\n    setFrameShadow(QFrame::Raised);\r\n    setFocusPolicy(Qt::NoFocus);\r\n    setFont(QFont(\"Tahoma\", 10));\r\n\r\n    // We want the widget to look active even though it is inactive.\r\n    QString borderColorName = KactusColors::DISABLED_TEXT.name();\r\n\r\n    setStyleSheet(\"border-style: solid;\"\r\n        \"border-width: 1px;\"\r\n        \"border-color: \" + borderColorName + \";\"\r\n        \"selection-color: black; selection-background-color: \"\r\n        \"QLinearGradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #d6e7ff, stop: 1 #84aede);\");\r\n\r\n    hideAssist();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: handleKey()\r\n//-----------------------------------------------------------------------------\r\nbool LineContentAssistWidget::tryHandleKey(QKeyEvent* e)\r\n{\r\n    if (matcher_ == 0)\r\n    {\r\n        return false;\r\n    }\r\n\r\n    if (e->key() == Qt::Key_Space && e->modifiers() == Qt::CTRL)\r\n    {\r\n        updateAssist(0);\r\n        return true;\r\n    }\r\n\r\n    QString text = target_->text().left(target_->cursorPosition()) + e->text();\r\n\r\n    // Check if we can commit.\r\n    if (contentFound_ && (e->key() == Qt::Key_Return || e->key() == Qt::Key_Tab ||\r\n                           (canCommitWith(e) && !matcher_->lookForwardMatch(text))))\r\n    {\r\n        // Commit the selection.\r\n        commitSelection();\r\n\r\n        // If the key is a character, let the editor handle it too.\r\n        if (e->key() != Qt::Key_Return && e->key() != Qt::Key_Tab)\r\n        {\r\n            return false;\r\n        }\r\n\r\n        // Otherwise we're fully done with it.\r\n        return true;\r\n    }\r\n\r\n    // Handle up and down arrows and escape, if the content is shown.\r\n    if (isContentShown())\r\n    {\r\n        int keyEvent = e->key();\r\n        if (keyEvent == Qt::Key_Up || keyEvent == Qt::Key_Down)\r\n        {\r\n            if (isVisible())\r\n            {\r\n                return handleKeyboardItemSelection(e, keyEvent);\r\n            }\r\n        }\r\n        else if (keyEvent == Qt::Key_Left || keyEvent == Qt::Key_Right || keyEvent == Qt::Key_Home ||\r\n            keyEvent == Qt::Key_End)\r\n        {\r\n            cancel();\r\n            return false;\r\n        }\r\n        else if (keyEvent == Qt::Key_A)\r\n        {\r\n            if (e->modifiers() == Qt::ControlModifier)\r\n            {\r\n                cancel();\r\n                return false;\r\n            }\r\n        }\r\n        else if (keyEvent == Qt::Key_Escape)\r\n        {\r\n            cancel();\r\n            return true;\r\n        }\r\n    }\r\n\r\n    return false;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: updateContent()\r\n//-----------------------------------------------------------------------------\r\nvoid LineContentAssistWidget::updateAssist(QKeyEvent* e)\r\n{\r\n    if (matcher_ == 0)\r\n    {\r\n        return;\r\n    }\r\n\r\n    // Invoke the content assist for certain keys.\r\n    if (e == 0 || (e->text().contains(QRegularExpression(\"^[a-z|A-z|0-9|_|||||||(|)|,|&]$\")) ||\r\n        e->key() == Qt::Key_Backspace || e->key() == Qt::Key_Return ||\r\n        e->key() == Qt::Key_Down || e->key() == Qt::Key_Up ||\r\n        (contentFound_ && e->text().contains(' '))))\r\n    {\r\n        updateMatches();\r\n    }\r\n    // Cancel assisting if needed.\r\n    else if (e->modifiers() == Qt::NoModifier)\r\n    {\r\n        hideAssist();\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: cancel()\r\n//-----------------------------------------------------------------------------\r\nvoid LineContentAssistWidget::cancel()\r\n{\r\n    hideAssist();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: setMaxVisibleItems()\r\n//-----------------------------------------------------------------------------\r\nvoid LineContentAssistWidget::setMaxVisibleItems(int count)\r\n{\r\n    Q_ASSERT(count > 0);\r\n    maxVisibleItems_ = count;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: isContentShown()\r\n//-----------------------------------------------------------------------------\r\nbool LineContentAssistWidget::isContentShown() const\r\n{\r\n    return (isVisible());\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: mousePressEvent()\r\n//-----------------------------------------------------------------------------\r\nvoid LineContentAssistWidget::mousePressEvent(QMouseEvent* event)\r\n{\r\n    QListWidget::mousePressEvent(event);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: mouseDoubleClickEvent()\r\n//-----------------------------------------------------------------------------\r\nvoid LineContentAssistWidget::mouseDoubleClickEvent(QMouseEvent* event)\r\n{\r\n    QListWidget::mouseDoubleClickEvent(event);\r\n\r\n    // Commit the selection.\r\n    commitSelection();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: updateMatches()\r\n//-----------------------------------------------------------------------------\r\nvoid LineContentAssistWidget::updateMatches()\r\n{\r\n    // Clear the content assist and fill it with new content.\r\n    clear();\r\n\r\n    QString toolTipText;\r\n    int toolTipIndex = -1;\r\n    QString text = target_->text().left(target_->cursorPosition());\r\n\r\n    contentFound_ = matcher_->fillWithContent(text, *this, lastAssistStartPos_, toolTipText, toolTipIndex);\r\n\r\n    // Check if content was found.\r\n    if (contentFound_)\r\n    {\r\n        // Fit the widget to the contents and move it accordingly.\r\n        fitToContents();\r\n        moveClose(lastAssistStartPos_);\r\n\r\n        setCurrentRow(0);\r\n        raise();\r\n        show();\r\n    }\r\n    else\r\n    {\r\n        hide();\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: moveClose()\r\n//-----------------------------------------------------------------------------\r\nvoid LineContentAssistWidget::moveClose(int /*cursorPos*/)\r\n{\r\n    // Determine the correct upper-left corner position for the widget.\r\n    int parentWidth = parentWidget()->width();\r\n    \r\n    // By default, the desired position is below line edit.\r\n    QPoint pos = target_->mapTo(parentWidget(), QPoint(0, 0)) + QPoint(0,  target_->height());\r\n    \r\n    // Restrict x coordinate by the screen width.\r\n    pos.setX(qMin(qMax(0, pos.x()), qMax(0, parentWidth - width())));\r\n    \r\n    // Move the widget to the final position.\r\n    move(pos);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: canCommitWith()\r\n//-----------------------------------------------------------------------------\r\nbool LineContentAssistWidget::canCommitWith(QKeyEvent* e) const\r\n{\r\n    return (!e->text().contains(QRegularExpression(\"^[a-z|A-z|0-9|_||||||]$\")) &&\r\n            e->key() != Qt::Key_Backspace && e->key() != Qt::Key_Escape &&\r\n            e->key() != Qt::Key_Up && e->key() != Qt::Key_Down &&\r\n            e->key() != Qt::Key_Left && e->key() != Qt::Key_Right &&\r\n            e->key() != Qt::Key_Space && e->modifiers() != Qt::ControlModifier);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: commitSelection()\r\n//-----------------------------------------------------------------------------\r\nvoid LineContentAssistWidget::commitSelection()\r\n{\r\n    Q_ASSERT(lastAssistStartPos_ != -1);\r\n\r\n    // Replace the text with the current content.\r\n    target_->setSelection(lastAssistStartPos_, target_->cursorPosition());\r\n    target_->insert(currentItem()->text());\r\n\r\n    hideAssist();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: fitToContents()\r\n//-----------------------------------------------------------------------------\r\nvoid LineContentAssistWidget::fitToContents()\r\n{\r\n    if (count() == 0)\r\n    {\r\n        return;\r\n    }\r\n\r\n    int visibleRowCount = qMin(count(), maxVisibleItems_);\r\n\r\n    int rowHeight = sizeHintForRow(0);\r\n    int height = visibleRowCount * rowHeight + frameWidth() * 2;\r\n\r\n    int parentHeight = parentWidget()->height();\r\n    int assistPosition = target_->mapTo(parentWidget(), QPoint(0, 0)).y() + target_->height();\r\n\r\n    if (assistPosition + height > parentHeight)\r\n    {\r\n        int availableHeight = parentHeight - assistPosition;\r\n        int availableRows = availableHeight / rowHeight;\r\n        height = availableRows * rowHeight + frameWidth() * 2;\r\n    }\r\n\r\n    setFixedSize(lineAssistWidth_, height);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: hideAssist()\r\n//-----------------------------------------------------------------------------\r\nvoid LineContentAssistWidget::hideAssist()\r\n{\r\n    hide();\r\n    clear();\r\n    contentFound_ = false;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LineContentAssistWidget::setContentMatcher()\r\n//-----------------------------------------------------------------------------\r\nvoid LineContentAssistWidget::setContentMatcher(ILineContentMatcher* matcher)\r\n{\r\n    matcher_ = matcher;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LineContentAssistWidget::setWidthForAssist()\r\n//-----------------------------------------------------------------------------\r\nvoid LineContentAssistWidget::setWidthForAssist(int newWidth)\r\n{\r\n    lineAssistWidth_ = newWidth;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LineContentAssistWidget::handleKeyboardItemSelection()\r\n//-----------------------------------------------------------------------------\r\nbool LineContentAssistWidget::handleKeyboardItemSelection(QKeyEvent* event, int key)\r\n{\r\n    int numberOfItems = count();\r\n\r\n    if (currentIndex().row() == 0 && key == Qt::Key_Up)\r\n    {\r\n        setCurrentIndex(model()->index(numberOfItems - 1, 0));\r\n    }\r\n    else if (currentIndex().row() == numberOfItems -1 && key == Qt::Key_Down)\r\n    {\r\n        setCurrentIndex(model()->index(0, 0));\r\n    }\r\n    else\r\n    {\r\n        keyPressEvent(event);\r\n    }\r\n\r\n    return true;\r\n}\r\n"
  },
  {
    "path": "common/widgets/assistedLineEdit/LineContentAssistWidget.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: LineContentAssistWidget.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Joni-Matti Maatta\r\n// Date: 4.1.2011\r\n//\r\n// Description:\r\n// Content assist widget.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef CONTENTASSISTWIDGET_H\r\n#define CONTENTASSISTWIDGET_H\r\n\r\n#include <QListWidget>\r\n#include <QLineEdit>\r\n#include <QSharedPointer>\r\n\r\n#include \"ILineContentMatcher.h\"\r\n\r\n//-----------------------------------------------------------------------------\r\n//! LineContentAssistWidget class.\r\n//-----------------------------------------------------------------------------\r\nclass LineContentAssistWidget : public QListWidget\r\n{\r\npublic:\r\n\r\n    /*!\r\n     *  The constructor.\r\n     *\r\n     *    @param [in] target     The target line edit. Must not be null.\r\n     *    @param [in] parentWnd  The parent window of the line edit.\r\n     */\r\n    LineContentAssistWidget(QLineEdit* target, QWidget* parentWnd);\r\n\r\n    /*!\r\n     *  The destructor.\r\n     */\r\n    virtual ~LineContentAssistWidget() = default;\r\n\r\n    // Disable copying.\r\n    LineContentAssistWidget(LineContentAssistWidget const& rhs) = delete;\r\n    LineContentAssistWidget& operator=(LineContentAssistWidget const& rhs) = delete;\r\n\r\n    /*!\r\n     *  Sets the content matcher.\r\n     *\r\n     *    @param [in] matcher The matcher to set.\r\n     */\r\n    void setContentMatcher(ILineContentMatcher* matcher);\r\n\r\n    /*!\r\n     *  Tries to handle the given key press fully, committing the selection if possible.\r\n     *\r\n     *    @return True, if the key was handle fully and the editor should not handle it.\r\n     *              False, if the editor still needs to handle the key.\r\n     *\r\n     *      @remarks Assumes that the given key event has not yet been handled by the editor.\r\n     */\r\n    bool tryHandleKey(QKeyEvent* e);\r\n\r\n    /*!\r\n     *  Updates the contents of the content assist.\r\n     *\r\n     *      @remarks Assumes that the given key event has already been handled by the editor.\r\n     */\r\n    void updateAssist(QKeyEvent* e);\r\n\r\n    /*!\r\n     *  Hide the content assist.\r\n     */\r\n    void hideAssist();\r\n\r\n    /*!\r\n     *  Cancels the content assist usage.\r\n     */\r\n    void cancel();\r\n\r\n    /*!\r\n     *  Sets the maximum number of items to be visible at once.\r\n     *\r\n     *    @param [in] count The maximum number of visible items at once.\r\n     */\r\n    void setMaxVisibleItems(int count);\r\n\r\n    /*!\r\n     *  Returns true if there is some content shown by the content assist widget.\r\n     */\r\n    bool isContentShown() const;\r\n\r\n    /*!\r\n     *  Set a new width for the assist.\r\n     *\r\n     *    @param [in] newWidth    The new assist width.\r\n     */\r\n    void setWidthForAssist(int newWidth);\r\n\r\nprotected:\r\n    /*!\r\n     *  Handles the mouse press event.\r\n     *\r\n     *    @param [in] event The mouse press event.\r\n     */\r\n    void mousePressEvent(QMouseEvent* event);\r\n\r\n    /*!\r\n     *  Handles the mouse double click event.\r\n     *\r\n     *    @param [in] event The mouse double click event.\r\n     */\r\n    void mouseDoubleClickEvent(QMouseEvent* event);\r\n\r\nprivate:\r\n\r\n    /*!\r\n     *  Handles the wrapping of item selection.\r\n     *\r\n     *    @param [in] event   The key event.\r\n     *    @param [in] key     The pressed key.\r\n     */\r\n    bool handleKeyboardItemSelection(QKeyEvent* event, int key);\r\n\r\n    /*!\r\n     *  Tries to match the contents to the text close to the text cursor. If there is a match, the content assist\r\n     *  is automatically shown. Otherwise it is hidden.\r\n     */\r\n    void updateMatches();\r\n\r\n    /*!\r\n     *  Returns true if the content assist can currently commit with the given key.\r\n     *\r\n     *    @param [in] key The commit key.\r\n     *\r\n     *    @return True, if the content assist can currently commit.\r\n     */\r\n    bool canCommitWith(QKeyEvent* e) const;\r\n\r\n    /*!\r\n     *  Commits the selection with the contents from the content assist.\r\n     *\r\n     *      @remarks    Assumes that there is at least a partial match found when match() was called the previous\r\n     *                  time.\r\n     */\r\n    void commitSelection();\r\n\r\n    /*!\r\n     *  Fits the widget to the contents.\r\n     */\r\n    void fitToContents();\r\n\r\n    /*!\r\n     *  Moves the widget close to the line edit, taking parent window dimensions into account.\r\n     */\r\n    void moveClose(int cursorPos);\r\n\r\n    //! The default maximum number of visible items.\r\n    static int const DEFAULT_MAX_VISIBLE_ITEMS = 15;\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! The target line edit.\r\n    QLineEdit* target_;\r\n\r\n    //! The content matcher.\r\n    ILineContentMatcher* matcher_;\r\n\r\n    //! Maximum number of visible items at once.\r\n    int maxVisibleItems_;\r\n\r\n    //! Last content position.\r\n    int lastAssistStartPos_;\r\n    \r\n    //! Current content state.\r\n    bool contentFound_;\r\n\r\n    //! Width of the line assist.\r\n    int lineAssistWidth_;\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n\r\n#endif // CONTENTASSISTWIDGET_H\r\n"
  },
  {
    "path": "common/widgets/assistedTextEdit/AssistedTextEdit.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: AssistedTextEdit.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Joni-Matti Maatta\r\n// Date: 21.12.2010\r\n//\r\n// Description:\r\n// Text edit widget which offers content assist.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"AssistedTextEdit.h\"\r\n\r\n#include <cassert>\r\n#include <algorithm>\r\n#include <QFont>\r\n#include <QRegularExpression>\r\n#include <QApplication>\r\n#include <QTextBlock>\r\n\r\n#include \"TextContentAssistWidget.h\"\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AssistedTextEdit()\r\n//-----------------------------------------------------------------------------\r\nAssistedTextEdit::AssistedTextEdit(QSharedPointer<ITextContentMatcher> contentMatcher,\r\n                                   QWidget* parentWnd, QWidget* parent)\r\n    : QPlainTextEdit(parent),\r\n      matcher_(contentMatcher),\r\n      contentAssist_(0),\r\n      indentStyle_(INDENT_STYLE_TAB),\r\n      indentWidth_(DEFAULT_INDENT_WIDTH)\r\n{\r\n    //setFont(QFont(\"Courier\", 10));\r\n    setLineWrapMode(NoWrap);\r\n\r\n    contentAssist_ = new TextContentAssistWidget(this, parentWnd, contentMatcher);\r\n\r\n    // Install this as an event filter so that we can track events from the main window.\r\n    parentWnd->installEventFilter(this);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ~AssistedTextEdit()\r\n//-----------------------------------------------------------------------------\r\nAssistedTextEdit::~AssistedTextEdit()\r\n{\r\n    delete contentAssist_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: setIndentStyle()\r\n//-----------------------------------------------------------------------------\r\nvoid AssistedTextEdit::setIndentStyle(IndentStyle style, unsigned int width)\r\n{\r\n    indentStyle_ = style;\r\n    indentWidth_ = width;\r\n\r\n    // Set the correct tab stop width.\r\n    QFontMetrics metrics(font());\r\n    setTabStopDistance(indentWidth_ * metrics.averageCharWidth());\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: getIndentStyle()\r\n//-----------------------------------------------------------------------------\r\nIndentStyle AssistedTextEdit::getIndentStyle() const\r\n{\r\n    return indentStyle_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: getIndentWidth()\r\n//-----------------------------------------------------------------------------\r\nunsigned int AssistedTextEdit::getIndentWidth() const\r\n{\r\n    return indentWidth_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: eventFilter()\r\n//-----------------------------------------------------------------------------\r\nbool AssistedTextEdit::eventFilter(QObject*, QEvent* e)\r\n{\r\n    // Cancel the assist if the main window is moved or resized.\r\n    if (contentAssist_->isContentShown() && (e->type() == QEvent::Move || e->type() == QEvent::Resize))\r\n    {\r\n        contentAssist_->cancel();\r\n    }\r\n\r\n    return false;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: keyPressEvent()\r\n//-----------------------------------------------------------------------------\r\nvoid AssistedTextEdit::keyPressEvent(QKeyEvent* e)\r\n{\r\n    // First try to handle the key full by the content assist.\r\n    if (!contentAssist_->tryHandleKey(e))\r\n    {\r\n        // Process the key event if it still needs handling by the editor.\r\n        switch (e->key())\r\n        {\r\n        case Qt::Key_Tab:\r\n            {\r\n                // Check if the tab indentation needs to be replaced with spaces.\r\n                if (indentStyle_ == INDENT_STYLE_SPACES)\r\n                {\r\n                    // Invoke a custom key press event for indentation.\r\n                    QKeyEvent indentEvent(QEvent::KeyPress, 0, Qt::NoModifier, createIndentString(1),\r\n                                          indentWidth_);\r\n                    QPlainTextEdit::keyPressEvent(&indentEvent);\r\n                }\r\n                break;\r\n            }\r\n\r\n        case Qt::Key_Return:\r\n            {\r\n                onReturnKeyPress(e);\r\n                break;\r\n            }\r\n\r\n        case Qt::Key_BraceRight:\r\n            {\r\n                // Handle the key event.\r\n                QPlainTextEdit::keyPressEvent(e);\r\n\r\n                // Indent the right brace.\r\n                indentRightBrace();\r\n                break;\r\n            }\r\n\r\n        case Qt::Key_Colon:\r\n            {\r\n                // Handle the key event.\r\n                QPlainTextEdit::keyPressEvent(e);\r\n\r\n                // Indent the colon correctly.\r\n                indentColon();\r\n                break;\r\n            }\r\n\r\n        default:\r\n            {\r\n                // Default operation.\r\n                QPlainTextEdit::keyPressEvent(e);\r\n                break;\r\n            }\r\n        }\r\n\r\n        // Update the content assist.\r\n        contentAssist_->updateAssist(e);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: mousePressEvent()\r\n//-----------------------------------------------------------------------------\r\nvoid AssistedTextEdit::mousePressEvent(QMouseEvent* e)\r\n{\r\n    QPlainTextEdit::mousePressEvent(e);\r\n\r\n    // Cancel the content assist if content is shown.\r\n    if (contentAssist_->isContentShown())\r\n    {\r\n        contentAssist_->cancel();\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: focusOutEvent()\r\n//-----------------------------------------------------------------------------\r\nvoid AssistedTextEdit::focusOutEvent(QFocusEvent* e)\r\n{\r\n    QPlainTextEdit::focusOutEvent(e);\r\n\r\n    // Cancel the content assist if content is shown.\r\n    if (contentAssist_->isContentShown())\r\n    {\r\n        contentAssist_->cancel();\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: createIndentString()\r\n//-----------------------------------------------------------------------------\r\nQString AssistedTextEdit::createIndentString(unsigned int depth)\r\n{\r\n    switch (indentStyle_)\r\n    {\r\n    case INDENT_STYLE_TAB:\r\n        {\r\n            return QString(depth, '\\t');\r\n        }\r\n\r\n    case INDENT_STYLE_SPACES:\r\n        {\r\n            return QString(depth * indentWidth_, ' ');\r\n        }\r\n    }\r\n\r\n    // Shouldn't ever get here.\r\n    assert(false);\r\n    return QString();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: calculateIndentDepth()\r\n//-----------------------------------------------------------------------------\r\nint AssistedTextEdit::calculateIndentDepth(int pos)\r\n{\r\n    int indentDepth = 0;\r\n    int searchPos = 0;\r\n    int discardPos = 0;\r\n    QString text = toPlainText();\r\n    QRegularExpression braceExp(\"(\\\\{|\\\\})\");\r\n    QRegularExpression discardExp(\"(\\\"([^\\\"]|(\\\\\\\\\\\"))*\\\")|(\\'([^\\']|(\\\\\\\\\\'))*\\')|(//[^\\n]*\\\\n)|(/\\\\*[^*/]*\\\\*/)\");\r\n\r\n    // Search all braces up to the cursor position discarding comments, strings and char literals.\r\n    searchPos = text.indexOf(braceExp);\r\n    discardPos = text.indexOf(discardExp);\r\n\r\n    while (searchPos >= 0 && searchPos < pos)\r\n    {\r\n        // If the search position has gone over the discard area, search the next discard area.\r\n        auto discardLength = discardExp.match(text, discardPos).capturedLength();\r\n        while (discardPos >= 0 && searchPos >= discardPos + discardLength)\r\n        {\r\n            discardPos = text.indexOf(discardExp, discardPos + discardLength);\r\n            discardLength = discardExp.match(text, discardPos).capturedLength();\r\n        }\r\n\r\n        if (discardPos < 0 || searchPos < discardPos || searchPos > discardPos + discardLength)\r\n        {\r\n            QChar c = text.at(searchPos);\r\n\r\n            if (c == '{')\r\n            {\r\n                ++indentDepth;\r\n            }\r\n            else if (c == '}')\r\n            {\r\n                --indentDepth;\r\n            }\r\n        }\r\n\r\n        searchPos = text.indexOf(braceExp, searchPos + 1);\r\n    }\r\n\r\n    return qMax(indentDepth, 0);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: indentRightBrace()\r\n//-----------------------------------------------------------------------------\r\nvoid AssistedTextEdit::indentRightBrace()\r\n{\r\n    static QRegularExpression braceRightExp(\"^\\\\s*(?=\\\\})\");\r\n    QString blockStr = textCursor().block().text();\r\n\r\n    // Update the beginning of the current text block with the correct indentation\r\n    // if there is only whitespace before the first right brace.\r\n    auto blockMatch = braceRightExp.match(blockStr);\r\n\r\n    if (blockMatch.hasMatch())\r\n    {\r\n        // Calculate the indentation depth.\r\n        int indentDepth = calculateIndentDepth(textCursor().block().position() +\r\n            blockMatch.capturedLength() + 1);\r\n\r\n        int startIndex = textCursor().block().position();\r\n        int endIndex = startIndex + blockMatch.capturedLength();\r\n\r\n        // Replace the area with the correct indentation.\r\n        replaceWithIndent(startIndex, endIndex, indentDepth);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: indentColon()\r\n//-----------------------------------------------------------------------------\r\nvoid AssistedTextEdit::indentColon()\r\n{\r\n    static QRegularExpression wpStartExp(\"^\\\\s*(?=[^;]*:)\");\r\n    QString blockStr = textCursor().block().text();\r\n\r\n    // Update the beginning of the current text block with the correct indentation\r\n    // for the whitespace part, if there is no following semicolon.\r\n    auto wpMatch = wpStartExp.match(blockStr);\r\n\r\n    if (wpMatch.hasMatch())\r\n    {\r\n        // Calculate the indentation depth.\r\n        int indentDepth = qMax(0, calculateIndentDepth(textCursor().block().position() +\r\n            wpMatch.capturedLength()) - 1);\r\n\r\n        int startIndex = textCursor().block().position();\r\n        int endIndex = startIndex + wpMatch.capturedLength();\r\n\r\n        // Replace the area with the correct indentation.\r\n        replaceWithIndent(startIndex, endIndex, indentDepth);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: replaceWithIndent()\r\n//-----------------------------------------------------------------------------\r\nvoid AssistedTextEdit::replaceWithIndent(int startIndex, int endIndex, int indentDepth)\r\n{\r\n    // Save the old cursor.\r\n    QTextCursor oldCursor = textCursor();\r\n\r\n    // Select the part of the block to auto-indent.\r\n    QTextCursor cursor = oldCursor;\r\n    cursor.setPosition(startIndex, QTextCursor::MoveAnchor);\r\n    cursor.setPosition(endIndex, QTextCursor::KeepAnchor);\r\n    setTextCursor(cursor);\r\n\r\n    // And then replace it with the correct indentation.\r\n    if (indentDepth > 0)\r\n    {\r\n        QKeyEvent indentEvent(QEvent::KeyPress, 0, Qt::NoModifier, createIndentString(indentDepth),\r\n                              indentDepth);\r\n        QPlainTextEdit::keyPressEvent(&indentEvent);\r\n    }\r\n    else\r\n    {\r\n        textCursor().removeSelectedText();\r\n    }\r\n\r\n    // Restore the cursor.\r\n    setTextCursor(oldCursor);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: onReturnKeyPress()\r\n//-----------------------------------------------------------------------------\r\nvoid AssistedTextEdit::onReturnKeyPress(QKeyEvent* e)\r\n{\r\n    // Calculate the indentation depth.\r\n    int indentDepth = calculateIndentDepth(textCursor().position());\r\n\r\n    // Handle the enter event.\r\n    QPlainTextEdit::keyPressEvent(e);\r\n\r\n    // Apply auto-indentation.\r\n    if (indentDepth > 0)\r\n    {\r\n        QKeyEvent indentEvent(QEvent::KeyPress, 0, Qt::NoModifier, createIndentString(indentDepth),\r\n                              indentDepth);\r\n        QPlainTextEdit::keyPressEvent(&indentEvent);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AssistedTextEdit::getMatcher()\r\n//-----------------------------------------------------------------------------\r\nITextContentMatcher& AssistedTextEdit::getMatcher()\r\n{\r\n    return *matcher_;\r\n}\r\n"
  },
  {
    "path": "common/widgets/assistedTextEdit/AssistedTextEdit.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: AssistedTextEdit.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Joni-Matti Maatta\r\n// Date: 21.12.2010\r\n//\r\n// Description:\r\n// Text edit widget which offers content assist.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef ASSISTEDTEXTEDIT_H\r\n#define ASSISTEDTEXTEDIT_H\r\n\r\n#include <QWidget>\r\n#include <QPlainTextEdit>\r\n#include <QListWidget>\r\n#include <QLineEdit>\r\n#include <QSharedPointer>\r\n\r\nclass ITextContentMatcher;\r\nclass TextContentAssistWidget;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! IndentStyle enumeration.\r\n//-----------------------------------------------------------------------------\r\nenum IndentStyle\r\n{\r\n    INDENT_STYLE_TAB = 0,\r\n    INDENT_STYLE_SPACES\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n//! AssistedTextEdit class.\r\n//-----------------------------------------------------------------------------\r\nclass AssistedTextEdit : public QPlainTextEdit\r\n{\r\n    Q_OBJECT\r\n\r\npublic:\r\n    /*!\r\n     *  Constructor.\r\n     *\r\n     *    @param [in] contentMatcher  The content matcher for the content assist.\r\n     *    @param [in] mainWnd         The program main window. Must not be null.\r\n     *    @param [in] parent          The parent widget. Can be null.\r\n     */\r\n    AssistedTextEdit(QSharedPointer<ITextContentMatcher> contentMatcher,\r\n                     QWidget* mainWnd, QWidget* parent = 0);\r\n\r\n    /*!\r\n     *  Destructor.\r\n     */\r\n    ~AssistedTextEdit();\r\n\r\n    /*!\r\n     *  Sets the indentation style.\r\n     *\r\n     *    @param [in] style The indentation style.\r\n     *    @param [in] width The indentation width.\r\n     */\r\n    void setIndentStyle(IndentStyle style, unsigned int width);\r\n\r\n    /*!\r\n     *  Returns the indent style.\r\n     */\r\n    IndentStyle getIndentStyle() const;\r\n\r\n    /*!\r\n     *  Returns the indent width.\r\n     */\r\n    unsigned int getIndentWidth() const;\r\n\r\n    /*!\r\n     *  Returns the content matcher.\r\n     */\r\n    ITextContentMatcher& getMatcher();\r\n\r\n    /*!\r\n     *  Filters events.\r\n     *\r\n     *    @param [in] obj  The event owner.\r\n     *    @param [in] e    The event.\r\n     */\r\n    bool eventFilter(QObject* obj, QEvent* e);\r\n    \r\nprotected:\r\n    /*!\r\n     *  Handles the given key press event.\r\n     *\r\n     *    @param [in] e The key event.\r\n     */\r\n    void keyPressEvent(QKeyEvent* e);\r\n\r\n    /*!\r\n     *  Handles the given mouse press event.\r\n     *\r\n     *    @param [in] e The mouse press event.\r\n     */\r\n    void mousePressEvent(QMouseEvent* e);\r\n\r\n    /*!\r\n     *  Handles the focus out event.\r\n     */\r\n    void focusOutEvent(QFocusEvent* e);\r\n\r\nprivate:\r\n    // Disable copying.\r\n    AssistedTextEdit(AssistedTextEdit const& rhs);\r\n    AssistedTextEdit& operator=(AssistedTextEdit const& rhs);\r\n\r\n    /*!\r\n     *  Creates a correct indentation string based on the indentation style.\r\n     *\r\n     *    @param [in] depth The indentation depth, that is, the number of indentations.\r\n     */\r\n    QString createIndentString(unsigned int depth);\r\n\r\n    /*!\r\n     *  Determines the correct indentation depth for the given position.\r\n     *\r\n     *    @param [in] The position index.\r\n     */\r\n    int calculateIndentDepth(int pos);\r\n\r\n    /*!\r\n     *  Indents the right brace correctly.\r\n     */\r\n    void indentRightBrace();\r\n\r\n    /*!\r\n     *  Indents the colon correctly.\r\n     */\r\n    void indentColon();\r\n\r\n    /*!\r\n     *  Replaces a substring in the text with the given indentation.\r\n     *\r\n     *    @param [in] startIndex   The start index of the substring.\r\n     *    @param [in] endIndex     The end index of the substring (excluded from the substring).\r\n     *    @param [in] indentDepth  The desired indentation depth.\r\n     */\r\n    void replaceWithIndent(int startIndex, int endIndex, int indentDepth);\r\n\r\n    /*!\r\n     *  Handles the Return key press event.\r\n     *\r\n     *    @param [in] e The Return key press event.\r\n     */\r\n    void onReturnKeyPress(QKeyEvent* e);\r\n\r\n    //! Default indentation width.\r\n    static unsigned int const DEFAULT_INDENT_WIDTH = 4;\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! The content matcher.\r\n    QSharedPointer<ITextContentMatcher> matcher_;\r\n\r\n    //! Content assist list widget.\r\n    TextContentAssistWidget* contentAssist_;\r\n\r\n    //! The indentation style.\r\n    IndentStyle indentStyle_;\r\n\r\n    //! The indentation width in characters.\r\n    unsigned int indentWidth_;\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n\r\n#endif // ASSISTEDTEXTEDIT_H\r\n"
  },
  {
    "path": "common/widgets/assistedTextEdit/HighlightStyleDesc.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: HighlightStyleDesc.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Joni-Matti Maatta\r\n// Date: 17.6.2011\r\n//\r\n// Description:\r\n// Basic highlight style description.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef HIGHLIGHTSTYLEDESC_H\r\n#define HIGHLIGHTSTYLEDESC_H\r\n\r\n#include <QColor>\r\n#include <QMetaType>\r\n#include <QDataStream>\r\n\r\n//-----------------------------------------------------------------------------\r\n//! HighlightStyleDesc structure.\r\n//-----------------------------------------------------------------------------\r\nstruct HighlightStyleDesc\r\n{\r\n    QColor color;       //!< The highlight color for the style.\r\n    bool bold;          //!< True for bold; false for normal text.\r\n    bool italic;        //!< True for italic; false for non-italic.\r\n\r\n    /*!\r\n     *  Default constructor.\r\n     */\r\n    HighlightStyleDesc() : color(Qt::black), bold(false), italic(false)\r\n    {\r\n    }\r\n\r\n    /*!\r\n     *  Constructor which takes the values for all fields.\r\n     */\r\n    HighlightStyleDesc(QColor color, bool bold, bool italic) : color(color), bold(bold), italic(italic)\r\n    {\r\n    }\r\n};\r\n\r\ninline QDataStream& operator<<(QDataStream& out, HighlightStyleDesc const& obj)\r\n{\r\n    out << obj.color << obj.bold << obj.italic;\r\n    return out;\r\n}\r\n\r\ninline QDataStream& operator>>(QDataStream& in, HighlightStyleDesc& obj)\r\n{\r\n    in >> obj.color >> obj.bold >> obj.italic;\r\n    return in;\r\n}\r\n\r\nQ_DECLARE_METATYPE(HighlightStyleDesc);\r\n\r\n//-----------------------------------------------------------------------------\r\n\r\n#endif // HIGHLIGHTSTYLEDESC_H\r\n"
  },
  {
    "path": "common/widgets/assistedTextEdit/ITextContentMatcher.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ITextContentMatcher.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Joni-Matti Maatta\r\n// Date: 11.1.2011\r\n//\r\n// Description:\r\n// Content matcher interface for filling content assist with content.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef ITEXTCONTENTMATCHER_H\r\n#define ITEXTCONTENTMATCHER_H\r\n\r\nclass TextContentAssistWidget;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! ITextContentMatcher class.\r\n//-----------------------------------------------------------------------------\r\nclass ITextContentMatcher\r\n{\r\npublic:\r\n    /*!\r\n     *  Destructor.\r\n     */\r\n    virtual ~ITextContentMatcher() {}\r\n\r\n    /*!\r\n     *  Looks forward for matching contents in the given text.\r\n     *\r\n     *    @param [in] text The text.\r\n     *\r\n     *    @return True, if there is a match. Otherwise false.\r\n     */\r\n    virtual bool lookForwardMatch(QString const& text) = 0;\r\n\r\n    /*!\r\n     *  Fills the content assist with content based on the given text.\r\n     *\r\n     *    @param [in]  text The text.\r\n     *    @param [in]  assist        The content assist to fill with content.\r\n     *    @param [out] startIndex    The start index of the selection to which the content applies.\r\n     *    @param [out] toolTipText   The tool tip hint text. Empty if no tool tip available.\r\n     *    @param [out] toolTipIndex  The index which specifies there start position for the tool tip hint.\r\n     *\r\n     *    @return The content state (what kind of content was detected).\r\n     */\r\n    virtual bool fillWithContent(QString const& text, TextContentAssistWidget& assist,\r\n                                 int& startIndex, QString& toolTipText, int& toolTipIndex) = 0;\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n\r\n#endif // ITEXTCONTENTMATCHER_H\r\n"
  },
  {
    "path": "common/widgets/assistedTextEdit/TextContentAssistWidget.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: TextContentAssistWidget.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Joni-Matti Maatta\r\n// Date: 4.1.2011\r\n//\r\n// Description:\r\n// Content assist widget.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"TextContentAssistWidget.h\"\r\n\r\n#include <algorithm>\r\n\r\n#include <QScrollBar>\r\n#include <QRegularExpression>\r\n#include <QToolTip>\r\n#include <QTextCursor>\r\n#include <QApplication>\r\n#include <QLabel>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: TextContentAssistWidget()\r\n//-----------------------------------------------------------------------------\r\nTextContentAssistWidget::TextContentAssistWidget(QPlainTextEdit* target, QWidget* parentWnd,\r\n                                                 QSharedPointer<ITextContentMatcher> matcher)\r\n    : QListWidget(parentWnd),\r\n      target_(target),\r\n      matcher_(matcher),\r\n      maxVisibleItems_(DEFAULT_MAX_VISIBLE_ITEMS),\r\n      lastAssistStartPos_(-1),\r\n      contentFound_(false),\r\n      toolTipHintWidget_()\r\n{\r\n    Q_ASSERT(target != 0);\r\n    Q_ASSERT(matcher != 0);\r\n    \r\n    // Set widget settings.\r\n    setFrameShadow(QFrame::Raised);\r\n    setFocusPolicy(Qt::NoFocus);\r\n    setFont(QFont(\"Tahoma\", 10));\r\n\r\n    // We want the widget to look active even though it is inactive.\r\n    QPalette pal = palette();\r\n    pal.setColor(QPalette::Inactive, QPalette::Highlight, Qt::darkBlue);\r\n    pal.setColor(QPalette::Inactive, QPalette::HighlightedText, Qt::white);\r\n    setPalette(pal);\r\n\r\n    hideAssist();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ~TextContentAssistWidget()\r\n//-----------------------------------------------------------------------------\r\nTextContentAssistWidget::~TextContentAssistWidget()\r\n{\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: handleKey()\r\n//-----------------------------------------------------------------------------\r\nbool TextContentAssistWidget::tryHandleKey(QKeyEvent* e)\r\n{\r\n    QString text = target_->toPlainText().left(target_->textCursor().position()) + e->text();\r\n\r\n    // Check if we can commit.\r\n    if (contentFound_ && (e->key() == Qt::Key_Return || e->key() == Qt::Key_Tab ||\r\n                           (canCommitWith(e) && !matcher_->lookForwardMatch(text))))\r\n    {\r\n        // Commit the selection.\r\n        commitSelection();\r\n\r\n        // If the key is a character, let the editor handle it too.\r\n        if (e->key() != Qt::Key_Return && e->key() != Qt::Key_Tab)\r\n        {\r\n            return false;\r\n        }\r\n\r\n        // Otherwise we're fully done with it.\r\n        return true;\r\n    }\r\n\r\n    // Handle up and down arrows and escape, if the content is shown.\r\n    if (isContentShown())\r\n    {\r\n        switch (e->key())\r\n        {\r\n        case Qt::Key_Up:\r\n        case Qt::Key_Down:\r\n            {\r\n                if (isVisible())\r\n                {\r\n                    keyPressEvent(e);\r\n                    return true;\r\n                }\r\n                break;\r\n            }\r\n\r\n        case Qt::Key_Left:\r\n        case Qt::Key_Right:\r\n        case Qt::Key_Home:\r\n        case Qt::Key_End:\r\n            {\r\n                cancel();\r\n                return false;\r\n            }\r\n\r\n        case Qt::Key_A:\r\n            {\r\n                if (e->modifiers() == Qt::ControlModifier)\r\n                {\r\n                    cancel();\r\n                    return false;\r\n                }\r\n                break;\r\n            }\r\n\r\n        case Qt::Key_Escape:\r\n            {\r\n                cancel();\r\n                return true;\r\n            }\r\n        }\r\n    }\r\n\r\n    return false;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: updateContent()\r\n//-----------------------------------------------------------------------------\r\nvoid TextContentAssistWidget::updateAssist(QKeyEvent* e)\r\n{\r\n    // Invoke the content assist for certain keys.\r\n    if (e->text().contains(QRegularExpression(\"^[a-z|A-z|0-9|_|;|||||||(|)|,|.|&]$\")) ||\r\n        e->key() == Qt::Key_Backspace || e->key() == Qt::Key_Return ||\r\n        (contentFound_ && (e->key() == Qt::Key_Down || e->key() == Qt::Key_Up || e->text().contains(' '))))\r\n    {\r\n        updateMatches();\r\n    }\r\n    // Cancel assisting if needed.\r\n    else if (e->modifiers() == Qt::NoModifier)\r\n    {\r\n        hideAssist();\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: cancel()\r\n//-----------------------------------------------------------------------------\r\nvoid TextContentAssistWidget::cancel()\r\n{\r\n    toolTipHintWidget_.hide();\r\n    hideAssist();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: setMaxVisibleItems()\r\n//-----------------------------------------------------------------------------\r\nvoid TextContentAssistWidget::setMaxVisibleItems(int count)\r\n{\r\n    Q_ASSERT(count > 0);\r\n    maxVisibleItems_ = count;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: isContentShown()\r\n//-----------------------------------------------------------------------------\r\nbool TextContentAssistWidget::isContentShown() const\r\n{\r\n    return (isVisible() || toolTipHintWidget_.isVisible());\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: mousePressEvent()\r\n//-----------------------------------------------------------------------------\r\nvoid TextContentAssistWidget::mousePressEvent(QMouseEvent* event)\r\n{\r\n    QListWidget::mousePressEvent(event);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: mouseDoubleClickEvent()\r\n//-----------------------------------------------------------------------------\r\nvoid TextContentAssistWidget::mouseDoubleClickEvent(QMouseEvent* event)\r\n{\r\n    QListWidget::mouseDoubleClickEvent(event);\r\n\r\n    // Commit the selection.\r\n    commitSelection();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: updateMatches()\r\n//-----------------------------------------------------------------------------\r\nvoid TextContentAssistWidget::updateMatches()\r\n{\r\n    // Clear the content assist and fill it with new content.\r\n    clear();\r\n\r\n    QString toolTipText;\r\n    int toolTipIndex = -1;\r\n    QString text = target_->toPlainText().left(target_->textCursor().position());\r\n\r\n    contentFound_ = matcher_->fillWithContent(text, *this, lastAssistStartPos_, toolTipText,\r\n                                              toolTipIndex);\r\n\r\n    // Show the tool tip if there was some content for it.\r\n    if (toolTipIndex > 0)\r\n    {\r\n        showToolTipHint(toolTipText, toolTipIndex);\r\n    }\r\n    else\r\n    {\r\n        toolTipHintWidget_.hide();\r\n    }\r\n    \r\n    // Check if content was found.\r\n    if (contentFound_)\r\n    {\r\n        // Fit the widget to the contents and move it accordingly.\r\n        fitToContents();\r\n        moveCloseToCursor(lastAssistStartPos_);\r\n\r\n        setCurrentRow(0);\r\n        raise();\r\n        show();\r\n    }\r\n    else\r\n    {\r\n        hide();\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: moveCloseToCursor()\r\n//-----------------------------------------------------------------------------\r\nvoid TextContentAssistWidget::moveCloseToCursor(int cursorPos)\r\n{\r\n    // Save the old cursor.\r\n    QTextCursor oldCursor = target_->textCursor();\r\n\r\n    // Move the cursor to the given position.\r\n    QTextCursor cursor = oldCursor;\r\n    cursor.setPosition(cursorPos, QTextCursor::MoveAnchor);\r\n    target_->setTextCursor(cursor);\r\n\r\n    // Determine the correct upper-left corner position for the widget.\r\n    int parentWidth = parentWidget()->width();\r\n    int parentHeight = parentWidget()->height();\r\n\r\n    // By default, the desired position is below the cursor position.\r\n    QPoint pos = target_->mapTo(parentWidget(), target_->cursorRect().bottomLeft()) + QPoint(-10, 10);\r\n    \r\n    // Restrict x coordinate by the screen width.\r\n    pos.setX(qMin(qMax(0, pos.x()), parentWidth - width()));\r\n\r\n    // Check if the tool tip hint is visible.\r\n    if (toolTipHintWidget_.isVisible())\r\n    {\r\n        // Then by default, place the widget above the cursor.\r\n        pos.setY(target_->mapTo(parentWidget(), target_->cursorRect().topLeft()).y() - height() - 10);\r\n\r\n        // Lift it up if the tool tip hint is also above the cursor.\r\n        if (pos.y() > toolTipHintWidget_.pos().y() - height())\r\n        {\r\n            pos.setY(toolTipHintWidget_.pos().y() - height());\r\n        }\r\n\r\n        // If the widget goes over the top edge of the screen, move it below the tool tip hint.\r\n        if (pos.y() < 0)\r\n        {\r\n            pos.setY(toolTipHintWidget_.pos().y() + toolTipHintWidget_.height());\r\n        }\r\n    }\r\n    // Otherwise lift the widget above the cursor only if necessary to keep it fully in view.\r\n    else if (pos.y() + height() > parentHeight)\r\n    {\r\n        pos.setY(target_->mapTo(parentWidget(), target_->cursorRect().topLeft()).y() - height() - 10);\r\n    }\r\n    \r\n    // Move the widget to the final position.\r\n    move(pos);\r\n\r\n    // Restore the old cursor.\r\n    target_->setTextCursor(oldCursor);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: canCommitWith()\r\n//-----------------------------------------------------------------------------\r\nbool TextContentAssistWidget::canCommitWith(QKeyEvent* e) const\r\n{\r\n    return (!e->text().contains(QRegularExpression(\"^[a-z|A-z|0-9|_|;||||||]$\")) &&\r\n            e->key() != Qt::Key_Backspace && e->key() != Qt::Key_Escape &&\r\n            e->key() != Qt::Key_Up && e->key() != Qt::Key_Down &&\r\n            e->key() != Qt::Key_Left && e->key() != Qt::Key_Right &&\r\n            e->key() != Qt::Key_Space && e->modifiers() != Qt::ControlModifier);\r\n}\r\n\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: commitSelection()\r\n//-----------------------------------------------------------------------------\r\nvoid TextContentAssistWidget::commitSelection()\r\n{\r\n    Q_ASSERT(lastAssistStartPos_ != -1);\r\n\r\n    // Setup the text cursor for replacement.\r\n    QTextCursor cursor = target_->textCursor();\r\n    cursor.setPosition(lastAssistStartPos_, QTextCursor::KeepAnchor);\r\n    cursor.insertText(currentItem()->text());    \r\n\r\n    hideAssist();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: fitToContents()\r\n//-----------------------------------------------------------------------------\r\nvoid TextContentAssistWidget::fitToContents()\r\n{\r\n    if (count() == 0)\r\n    {\r\n        return;\r\n    }\r\n\r\n    int visibleRowCount = qMin(count(), maxVisibleItems_);\r\n    int height = visibleRowCount * sizeHintForRow(0) + frameWidth() * 2;\r\n    int width = sizeHintForColumn(0) + frameWidth() * 2 + verticalScrollBar()->sizeHint().width();\r\n    \r\n    setFixedSize(width, height);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: showToolTipHint()\r\n//-----------------------------------------------------------------------------\r\nvoid TextContentAssistWidget::showToolTipHint(QString const& text, int cursorPos)\r\n{\r\n    // Set the tool tip hint text.\r\n    toolTipHintWidget_.setText(text);\r\n    toolTipHintWidget_.adjustSize();\r\n\r\n    // Retrieve the y coordinate from the current cursor.\r\n    QPoint pos;\r\n    pos.setY(target_->mapTo(parentWidget(), target_->cursorRect().bottomLeft()).y() + 5);\r\n\r\n    // Save the old cursor.\r\n    QTextCursor oldCursor = target_->textCursor();\r\n\r\n    // Move the cursor to the given position.\r\n    QTextCursor cursor = oldCursor;\r\n    cursor.setPosition(cursorPos, QTextCursor::MoveAnchor);\r\n    target_->setTextCursor(cursor);\r\n\r\n    // Determine the correct upper-left corner position for the widget.\r\n    int parentWidth = parentWidget()->width();\r\n    int parentHeight = parentWidget()->height();\r\n\r\n    // By default, the desired position is below the cursor position.\r\n    pos.setX(target_->mapTo(parentWidget(), target_->cursorRect().bottomLeft()).x());\r\n\r\n    // Restrict x coordinate by the screen width.\r\n    pos.setX(qMin(qMax(0, pos.x()), parentWidth - toolTipHintWidget_.width()));\r\n\r\n    // If the widget would be partially below the screen, lift it above the cursor.\r\n    if (pos.y() + toolTipHintWidget_.height() > parentHeight)\r\n    {\r\n        pos.setY(target_->mapTo(parentWidget(), target_->cursorRect().topLeft()).y() - toolTipHintWidget_.height() - 5);\r\n    }\r\n\r\n    // Move the widget to the final position.\r\n    toolTipHintWidget_.move(parentWidget()->mapToGlobal(pos));\r\n\r\n    // Restore the old cursor.\r\n    target_->setTextCursor(oldCursor);\r\n\r\n    // Show the hint.\r\n    toolTipHintWidget_.show();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: hideAssist()\r\n//-----------------------------------------------------------------------------\r\nvoid TextContentAssistWidget::hideAssist()\r\n{\r\n    hide();\r\n    clear();\r\n    contentFound_ = false;\r\n}\r\n"
  },
  {
    "path": "common/widgets/assistedTextEdit/TextContentAssistWidget.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: TextContentAssistWidget.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Joni-Matti Maatta\r\n// Date: 4.1.2011\r\n//\r\n// Description:\r\n// Content assist widget.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef CONTENTASSISTWIDGET_H\r\n#define CONTENTASSISTWIDGET_H\r\n\r\n#include <QListWidget>\r\n#include <QPlainTextEdit>\r\n#include <QSharedPointer>\r\n\r\n#include \"ITextContentMatcher.h\"\r\n#include \"ToolTipHintWidget.h\"\r\n\r\n//-----------------------------------------------------------------------------\r\n//! TextContentAssistWidget class.\r\n//-----------------------------------------------------------------------------\r\nclass TextContentAssistWidget : public QListWidget\r\n{\r\npublic:\r\n    /*!\r\n     *  Constructor.\r\n     *\r\n     *    @param [in] parent   The target text editor. Must not be null.\r\n     *    @param [in] matcher  The content matcher to use. Must not be null.\r\n     */\r\n    TextContentAssistWidget(QPlainTextEdit* target, QWidget* parentWnd,\r\n                            QSharedPointer<ITextContentMatcher> matcher);\r\n\r\n    /*!\r\n     *  Destructor.\r\n     */\r\n    ~TextContentAssistWidget();\r\n\r\n    /*!\r\n     *  Tries to handle the given key press fully, committing the selection if possible.\r\n     *\r\n     *    @return True, if the key was handle fully and the editor should not handle it.\r\n     *              False, if the editor still needs to handle the key.\r\n     *\r\n     *      @remarks Assumes that the given key event has not yet been handled by the editor.\r\n     */\r\n    bool tryHandleKey(QKeyEvent* e);\r\n\r\n    /*!\r\n     *  Updates the contents of the content assist.\r\n     *\r\n     *      @remarks Assumes that the given key event has already been handled by the editor.\r\n     */\r\n    void updateAssist(QKeyEvent* e);\r\n\r\n    void hideAssist();\r\n\r\n    /*!\r\n     *  Cancels the content assist usage.\r\n     */\r\n    void cancel();\r\n\r\n    /*!\r\n     *  Sets the maximum number of items to be visible at once.\r\n     *\r\n     *    @param [in] count The maximum number of visible items at once.\r\n     */\r\n    void setMaxVisibleItems(int count);\r\n\r\n    /*!\r\n     *  Returns true if there is some content shown by the content assist widget.\r\n     */\r\n    bool isContentShown() const;\r\n\r\nprotected:\r\n    /*!\r\n     *  Handles the mouse press event.\r\n     *\r\n     *    @param [in] event The mouse press event.\r\n     */\r\n    void mousePressEvent(QMouseEvent* event);\r\n\r\n    /*!\r\n     *  Handles the mouse double click event.\r\n     *\r\n     *    @param [in] event The mouse double click event.\r\n     */\r\n    void mouseDoubleClickEvent(QMouseEvent* event);\r\n\r\nprivate:\r\n    // Disable copying.\r\n    TextContentAssistWidget(TextContentAssistWidget const& rhs);\r\n    TextContentAssistWidget& operator=(TextContentAssistWidget const& rhs);\r\n\r\n    /*!\r\n     *  Tries to match the contents to the text close to the text cursor.\r\n     *  If there is a match, the content assist is automatically shown. Otherwise it is hidden.\r\n     */\r\n    void updateMatches();\r\n\r\n    /*!\r\n     *  Returns true if the content assist can currently commit with the given key.\r\n     *\r\n     *    @param [in] key The commit key.\r\n     *\r\n     *    @return True, if the content assist can currently commit.\r\n     */\r\n    bool canCommitWith(QKeyEvent* e) const;\r\n\r\n    /*!\r\n     *  Commits the selection with the contents from the content assist.\r\n     *\r\n     *      @remarks Assumes that there is at least a partial match found when match()\r\n     *               was called the previous time.\r\n     */\r\n    void commitSelection();\r\n\r\n    /*!\r\n     *  Fits the widget to the contents.\r\n     */\r\n    void fitToContents();\r\n\r\n    /*!\r\n     *  Moves the widget close to the given cursor in the text, taking screen dimensions into account.\r\n     */\r\n    void moveCloseToCursor(int cursorPos);\r\n\r\n    /*!\r\n     *  Shows the tool tip hint.\r\n     */\r\n    void showToolTipHint(QString const& text, int cursorPos);\r\n\r\n    //! The default maximum number of visible items.\r\n    static int const DEFAULT_MAX_VISIBLE_ITEMS = 6;\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! The parent text editor.\r\n    QPlainTextEdit* target_;\r\n\r\n    //! The content matcher.\r\n    QSharedPointer<ITextContentMatcher> matcher_;\r\n\r\n    //! Maximum number of visible items at once.\r\n    int maxVisibleItems_;\r\n\r\n    //! Last content position.\r\n    int lastAssistStartPos_;\r\n    \r\n    //! Current content state.\r\n    bool contentFound_;\r\n\r\n    //! The tool tip hint widget.\r\n    ToolTipHintWidget toolTipHintWidget_;\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n\r\n#endif // CONTENTASSISTWIDGET_H\r\n"
  },
  {
    "path": "common/widgets/assistedTextEdit/ToolTipHintWidget.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ToolTipHintWidget.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Joni-Matti Maatta\r\n// Date: 1.2.2011\r\n//\r\n// Description:\r\n// Tool tip hint widget.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"ToolTipHintWidget.h\"\r\n\r\n#include <QToolTip>\r\n#include <QStyle>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ToolTipHintWidget()\r\n//-----------------------------------------------------------------------------\r\nToolTipHintWidget::ToolTipHintWidget() : QLabel()\r\n{\r\n    setWindowFlags(Qt::Tool | Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint);\r\n    setFocusPolicy(Qt::NoFocus);\r\n    setForegroundRole(QPalette::ToolTipText);\r\n    setBackgroundRole(QPalette::ToolTipBase);\r\n    setPalette(QToolTip::palette());\r\n    setFrameStyle(QFrame::Box);\r\n    ensurePolished();\r\n\r\n    setMargin(1 + style()->pixelMetric(QStyle::PM_ToolTipLabelFrameWidth, 0, this));\r\n    setIndent(1);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ~ToolTipHintWidget()\r\n//-----------------------------------------------------------------------------\r\nToolTipHintWidget::~ToolTipHintWidget()\r\n{\r\n}"
  },
  {
    "path": "common/widgets/assistedTextEdit/ToolTipHintWidget.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ToolTipHintWidget.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Joni-Matti Maatta\r\n// Date: 1.2.2011\r\n//\r\n// Description:\r\n// Tool tip hint widget.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef TOOLTIPHINTWIDGET_H\r\n#define TOOLTIPHINTWIDGET_H\r\n\r\n#include <QLabel>\r\n\r\n//-----------------------------------------------------------------------------\r\n//! ToolTipHintWidget class.\r\n//-----------------------------------------------------------------------------\r\nclass ToolTipHintWidget : public QLabel\r\n{\r\n    Q_OBJECT\r\n\r\npublic:\r\n    /*!\r\n     *  Constructor.\r\n     */\r\n    ToolTipHintWidget();\r\n\r\n    /*!\r\n     *  Destructor.\r\n     */\r\n    ~ToolTipHintWidget();\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n\r\n#endif // TOOLTIPHINTWIDGET_H"
  },
  {
    "path": "common/widgets/booleanComboBox/booleancombobox.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: booleancombobox.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Antti Kamppi\r\n// Date: 01.04.2011\r\n//\r\n// Description:\r\n// Combo box that has \"true\", \"false\" or \"unspecified\" choices for user to select.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"booleancombobox.h\"\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: booleancombobox::BooleanComboBox()\r\n//-----------------------------------------------------------------------------\r\nBooleanComboBox::BooleanComboBox(QWidget *parent):\r\nQComboBox(parent)\r\n{\r\n\taddItem(tr(\"true\"));  // index 0\r\n\taddItem(tr(\"false\")); // index 1\r\n    addItem(tr(\"\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: booleancombobox::~BooleanComboBox()\r\n//-----------------------------------------------------------------------------\r\nBooleanComboBox::~BooleanComboBox()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: booleancombobox::getCurrentValue()\r\n//-----------------------------------------------------------------------------\r\nQString BooleanComboBox::getCurrentValue() const\r\n{\r\n\tif (currentIndex() == 0)\r\n    {\r\n        return QStringLiteral(\"true\");\r\n    }\r\n\telse if (currentIndex() == 1)\r\n    {\r\n        return QStringLiteral(\"false\");\r\n    }\r\n    else\r\n    {\r\n        return QStringLiteral(\"\");\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: booleancombobox::setCurrentValue()\r\n//-----------------------------------------------------------------------------\r\nvoid BooleanComboBox::setCurrentValue(QString const& value)\r\n{\r\n\tif (value == \"true\")\r\n    {\r\n\t\tsetCurrentIndex(0);\r\n    }\r\n\telse if (value == \"false\")\r\n    {\r\n\t\tsetCurrentIndex(1);\r\n    }\r\n    else\r\n    {\r\n        setCurrentIndex(2);\r\n    }\r\n}\r\n"
  },
  {
    "path": "common/widgets/booleanComboBox/booleancombobox.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: booleancombobox.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Antti Kamppi\r\n// Date: 01.04.2011\r\n//\r\n// Description:\r\n// Combo box that has \"true\", \"false\" or \"unspecified\" choices for user to select.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef BOOLEANCOMBOBOX_H\r\n#define BOOLEANCOMBOBOX_H\r\n\r\n#include <QComboBox>\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Combo box that has \"true\", \"false\" or \"unspecified\" choices for user to select.\r\n//-----------------------------------------------------------------------------\r\nclass BooleanComboBox : public QComboBox\r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\r\n\t/*!\r\n     *  The constructor.\r\n\t *\r\n\t *    @param [in] parent  Pointer to the owner of this widget.\r\n\t */\r\n\tBooleanComboBox(QWidget *parent);\r\n\r\n\t//! The destructor.\r\n\tvirtual ~BooleanComboBox();\r\n\r\n\t/*!\r\n     *  Get the value currently selected in the combo box.\r\n\t *\r\n\t *    @return Boolean value that matches the currently selected item.\r\n\t */\r\n    QString getCurrentValue() const;\r\n\r\n\t/*!\r\n     *  Set the current value to be selected.\r\n\t *\r\n\t *    @param [in] value   The value to be selected.\r\n\t */\r\n    void setCurrentValue(QString const& value);\r\n\r\nprivate:\r\n\r\n\t//! No copying.\r\n\tBooleanComboBox(const BooleanComboBox& other);\r\n\r\n\t//! No assignment.\r\n\tBooleanComboBox& operator=(const BooleanComboBox& other);\r\n};\r\n\r\n#endif // BOOLEANCOMBOBOX_H\r\n"
  },
  {
    "path": "common/widgets/busReferenceComboBox/BusReferenceComboBox.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: BusReferenceComboBox.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Mikko Teuho\n// Date: 24.02.2022\n//\n// Description:\n// The combo box to select one of the defined bus interfaces.\n//-----------------------------------------------------------------------------\n\n#include \"BusReferenceComboBox.h\"\n\n#include <KactusAPI/include/BusInterfaceInterface.h>\n\n//-----------------------------------------------------------------------------\n// Function: BusReferenceComboBox::BusReferenceComboBox()\n//-----------------------------------------------------------------------------\nBusReferenceComboBox::BusReferenceComboBox(BusInterfaceInterface* busInterface, QWidget *parent):\nQComboBox(parent),\nbusInterface_(busInterface)\n{\n    setEditable(false);\n}\n\n//-----------------------------------------------------------------------------\n// Function: BusReferenceComboBox::setBusInterfaces()\n//-----------------------------------------------------------------------------\nvoid BusReferenceComboBox::setupSelection(QString const& currentValue, General::InterfaceMode busMode)\n{\n    clear();\n\n    addItem(\"\");\n\n    for (auto busName : busInterface_->getItemNames())\n    {\n        if (busMode == General::INTERFACE_MODE_COUNT || busInterface_->getMode(busName) == busMode)\n        {\n            addItem(QString::fromStdString(busName));\n        }\n    }\n\n    if (findText(currentValue) < 0)\n    {\n        addItem(currentValue);\n    }\n\n    setCurrentText(currentValue);\n}\n"
  },
  {
    "path": "common/widgets/busReferenceComboBox/BusReferenceComboBox.h",
    "content": "//-----------------------------------------------------------------------------\n// File: BusReferenceComboBox.h\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Mikko Teuho\n// Date: 24.02.2022\n//\n// Description:\n// The combo box to select one of the defined bus interfaces.\n//-----------------------------------------------------------------------------\n\n#ifndef BUSREFERENCECOMBOBOX_H\n#define BUSREFERENCECOMBOBOX_H\n\n#include <QComboBox>\n\n#include <IPXACTmodels/generaldeclarations.h>\n\nclass BusInterfaceInterface;\n\n//-----------------------------------------------------------------------------\n//! The combo box to select one of the defined access types.\n//-----------------------------------------------------------------------------\nclass BusReferenceComboBox: public QComboBox\n{\n\tQ_OBJECT\n\npublic:\n\n\t/*!\n     *  The constructor.\n\t *\n     *    @param [in] busInterface    Interface for accessing bus interfaces.\n     *    @param [in] parent          Pointer to the owner of the combo box.\n\t */\n\tBusReferenceComboBox(BusInterfaceInterface* busInterface, QWidget *parent);\n\t\n\t/*!\n     *  The destructor.\n     */\n    virtual ~BusReferenceComboBox() = default;\n\n    /*!\n     *  Setup the combo box.\n     *\n     *    @param [in] currentValue    Currently selected bus interface.\n     *    @param [in] busMode         Filtering bus mode for available bus interfaces.\n     */\n    void setupSelection(QString const& currentValue = \"\",\n        General::InterfaceMode busMode = General::INTERFACE_MODE_COUNT);\n\nprivate:\n\t\n    //! No copying.\tNo assignment.\n    BusReferenceComboBox(const BusReferenceComboBox& other);\n    BusReferenceComboBox& operator=(const BusReferenceComboBox& other);\n\n    //-----------------------------------------------------------------------------\n    // Data.\n    //-----------------------------------------------------------------------------\n\n    //! Interface for accessing bus interfaces.\n    BusInterfaceInterface* busInterface_;\n};\n\n#endif // BUSREFERENCECOMBOBOX_H\n"
  },
  {
    "path": "common/widgets/colorBox/ColorBox.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ColorBox.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Joni-Matti Maatta\r\n// Date: 16.6.2011\r\n//\r\n// Description:\r\n// Color box widget which click support.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"ColorBox.h\"\r\n\r\n#include <QPalette>\r\n#include <QMouseEvent>\r\n#include <QVBoxLayout>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ColorBox()\r\n//-----------------------------------------------------------------------------\r\nColorBox::ColorBox(QSize const& size, QWidget* parent) : QFrame(parent), textLabel_(0)\r\n{\r\n    setLineWidth(1);\r\n    setFrameStyle(QFrame::Box | QFrame::Plain);\r\n    setAutoFillBackground(true);\r\n    setFixedSize(size);\r\n\r\n    color_ = palette().color(backgroundRole());\r\n\r\n    textLabel_ = new QLabel(this);\r\n    QVBoxLayout* layout = new QVBoxLayout(this);\r\n    layout->addWidget(textLabel_, 1, Qt::AlignHCenter | Qt::AlignVCenter);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ~ColorBox()\r\n//-----------------------------------------------------------------------------\r\nColorBox::~ColorBox()\r\n{\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: setColor()\r\n//-----------------------------------------------------------------------------\r\nvoid ColorBox::setColor(QColor const& color)\r\n{\r\n    QPalette pal = palette();\r\n    pal.setColor(backgroundRole(), color);\r\n    setPalette(pal);\r\n\r\n    color_ = color;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: getColor()\r\n//-----------------------------------------------------------------------------\r\nQColor const& ColorBox::getColor() const\r\n{\r\n    return color_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: mousePressEvent()\r\n//-----------------------------------------------------------------------------\r\nvoid ColorBox::mousePressEvent(QMouseEvent* event)\r\n{\r\n    QFrame::mousePressEvent(event);\r\n\r\n    if (event->button() == Qt::LeftButton)\r\n    {\r\n        emit clicked();\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: setText()\r\n//-----------------------------------------------------------------------------\r\nvoid ColorBox::setText(QString const& text)\r\n{\r\n    textLabel_->setText(text);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: setTextFont()\r\n//-----------------------------------------------------------------------------\r\nvoid ColorBox::setTextFont(QFont const& font)\r\n{\r\n    textLabel_->setFont(font);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: setTextColor()\r\n//-----------------------------------------------------------------------------\r\nvoid ColorBox::setTextColor(QColor const& color)\r\n{\r\n    QPalette pal = textLabel_->palette();\r\n    pal.setColor(textLabel_->foregroundRole(), color);\r\n    textLabel_->setPalette(pal);\r\n}\r\n"
  },
  {
    "path": "common/widgets/colorBox/ColorBox.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ColorBox.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Joni-Matti Maatta\r\n// Date: 16.6.2011\r\n//\r\n// Description:\r\n// Color box widget which click support.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef COLORBOX_H\r\n#define COLORBOX_H\r\n\r\n#include <QColor>\r\n#include <QFrame>\r\n#include <QLabel>\r\n\r\n//-----------------------------------------------------------------------------\r\n//! ColorBox class.\r\n//-----------------------------------------------------------------------------\r\nclass ColorBox : public QFrame\r\n{\r\n    Q_OBJECT\r\n\r\npublic:\r\n    /*!\r\n     *  Constructor.\r\n     *\r\n     *    @param [in] parent The parent widget.\r\n     */\r\n    ColorBox(QSize const& size, QWidget* parent = 0);\r\n\r\n    /*!\r\n     *  Destructor.\r\n     */\r\n    ~ColorBox();\r\n\r\n    /*!\r\n     *  Sets the color for the color box.\r\n     *\r\n     *    @param [in] color The color to set.\r\n     */\r\n    void setColor(QColor const& color);\r\n\r\n    /*!\r\n     *  Sets the text inside the box.\r\n     */\r\n    void setText(QString const& text);\r\n\r\n    /*!\r\n     *  Sets the text font.\r\n     *\r\n     *    @param [in] font The font to set.\r\n     */\r\n    void setTextFont(QFont const& font);\r\n\r\n    /*!\r\n     *  Sets the text color.\r\n     *\r\n     *    @param [in] color The color to set.\r\n     */\r\n    void setTextColor(QColor const& color);\r\n\r\n    /*!\r\n     *  Returns the color of the color box.\r\n     */\r\n    QColor const& getColor() const;\r\n\r\nsignals:\r\n    //! Signaled when the color box is clicked.\r\n    void clicked();\r\n\r\nprotected:\r\n    void mousePressEvent(QMouseEvent* event);\r\n\r\nprivate:\r\n    // Disable copying.\r\n    ColorBox(ColorBox const& rhs);\r\n    ColorBox& operator=(ColorBox const& rhs);\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! The current color.\r\n    QColor color_;\r\n\r\n    //! Text label.\r\n    QLabel* textLabel_;\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n\r\n#endif // COLORBOX_H\r\n"
  },
  {
    "path": "common/widgets/componentPreviewBox/ComponentPreviewBox.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ComponentPreviewBox.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Joni-Matti Maatta\r\n// Date: 1.8.2011\r\n//\r\n// Description:\r\n// Component preview box for visualizing HW components.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"ComponentPreviewBox.h\"\r\n\r\n#include <editors/SystemDesign/SWComponentItem.h>\r\n#include <editors/HWDesign/HWComponentItem.h>\r\n#include <editors/common/diagramgrid.h>\r\n\r\n#include <KactusAPI/include/LibraryInterface.h>\r\n\r\n#include <IPXACTmodels/Component/Component.h>\r\n#include <IPXACTmodels/common/ConfigurableVLNVReference.h>\r\n\r\n#include <IPXACTmodels/Design/ComponentInstance.h>\r\n\r\n#include <QLayout>\r\n#include <QPainter>\r\n#include <QRectF>\r\n\r\n//! The minimum size for the preview box.\r\nstatic const int MIN_BOX_HEIGHT = 120;\r\n\r\n//-----------------------------------------------------------------------------\r\n\r\nnamespace\r\n{\r\n    //-----------------------------------------------------------------------------\r\n    //! GridScene class.\r\n    //-----------------------------------------------------------------------------\r\n    class GridScene : public QGraphicsScene\r\n    {\r\n    public:\r\n        /*!\r\n         *  Constructor.\r\n         */\r\n        GridScene(QWidget* parent) : QGraphicsScene(parent) {}\r\n\r\n        /*!\r\n         *  Destructor.\r\n         */\r\n        ~GridScene() {}\r\n\r\n    protected:\r\n        //! Draw the scene background.\r\n        void drawBackground(QPainter* painter, QRectF const& rect);\r\n    };\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Function: drawBackground()\r\n    //-----------------------------------------------------------------------------\r\n    void GridScene::drawBackground(QPainter* painter, QRectF const& rect)\r\n    {\r\n        painter->setWorldMatrixEnabled(true);\r\n        painter->setBrush(Qt::lightGray);\r\n\r\n        qreal left = int(rect.left()) - (int(rect.left()) % GridSize );\r\n        qreal top = int(rect.top()) - (int(rect.top()) % GridSize );\r\n\r\n        for (qreal x = left; x < rect.right(); x += GridSize )\r\n        {\r\n            for (qreal y = top; y < rect.bottom(); y += GridSize )\r\n            {\r\n                painter->drawPoint(x, y);\r\n            }\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentPreviewBox::ComponentPreviewBox()\r\n//-----------------------------------------------------------------------------\r\nComponentPreviewBox::ComponentPreviewBox(LibraryInterface* lh, QWidget* parent):\r\nItemVisualizer(parent),\r\n    lh_(lh),\r\n    view_(new QGraphicsView(parent)),\r\n    scene_(new GridScene(view_))\r\n{\r\n    // Create the scene.\r\n    view_->setScene(scene_);\r\n    view_->centerOn(0, 0);\r\n\r\n    setMinimumHeight(MIN_BOX_HEIGHT);\r\n\r\n    // Disable interactivity by default.\r\n    view_->setInteractive(false);\r\n\r\n    auto layout = new QVBoxLayout(this);\r\n    layout->addWidget(view_);\r\n    layout->setContentsMargins(0, 0, 0, 0);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentPreviewBox::updatePreview()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentPreviewBox::updatePreview()\r\n{\r\n    // Re-create the scene.\r\n    delete scene_;\r\n    scene_ = new GridScene(view_);\r\n    view_->setScene(scene_);\r\n\r\n    if (component_ != 0)\r\n    {\r\n        ComponentItem* item = 0;\r\n\r\n        if (component_->getImplementation() == KactusAttribute::HW)\r\n        {\r\n\r\n            QSharedPointer<ComponentInstance> componentInstance(new ComponentInstance());\r\n            componentInstance->setInstanceName(component_->getVlnv().getName());\r\n            componentInstance->setComponentRef(QSharedPointer<ConfigurableVLNVReference>(\r\n                new ConfigurableVLNVReference(component_->getVlnv())));\r\n\r\n            item = new HWComponentItem(lh_, componentInstance, component_);\r\n        }\r\n        else if (component_->getImplementation() == KactusAttribute::SW)\r\n\t\t{\r\n\t\t\tQSharedPointer<ComponentInstance> swInstance(new ComponentInstance());\r\n\t\t\tswInstance->setInstanceName(component_->getVlnv().getName());\r\n\t\t\tswInstance->setComponentRef(QSharedPointer<ConfigurableVLNVReference>(\r\n\t\t\t\tnew ConfigurableVLNVReference(component_->getVlnv())));\r\n\r\n            item = new SWComponentItem(lh_, component_, swInstance);\r\n        }\r\n\r\n        if (item != 0)\r\n        {\r\n            connect(item, SIGNAL(endpointMoved(ConnectionEndpoint*)), this, SIGNAL(endpointsRearranged()));\r\n            scene_->addItem(item);\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentPreviewBox::setComponent()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentPreviewBox::setComponent(QSharedPointer<Component> component)\r\n{\r\n    component_ = component;\r\n    updatePreview();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentPreviewBox::setComponent()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentPreviewBox::setComponent( const VLNV& vlnv )\r\n{\r\n\tQSharedPointer<Component> component;\r\n\t\r\n\t// if the vlnv belongs to a component\r\n\tif (lh_->getDocumentType(vlnv) == VLNV::COMPONENT)\r\n    {\r\n\t\tcomponent = lh_->getModel(vlnv).staticCast<Component>();\r\n\t}\r\n\tsetComponent(component);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentPreviewBox::itemsBoundingRect()\r\n//-----------------------------------------------------------------------------\r\nQRectF ComponentPreviewBox::itemsBoundingRect() const\r\n{\r\n\treturn scene_->itemsBoundingRect();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentPreviewBox::scene()\r\n//-----------------------------------------------------------------------------\r\nQGraphicsScene* ComponentPreviewBox::scene() const\r\n{\r\n    return scene_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentPreviewBox::setInteractive()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentPreviewBox::setInteractive(bool interactive)\r\n{\r\n    view_->setInteractive(interactive);\r\n}\r\n"
  },
  {
    "path": "common/widgets/componentPreviewBox/ComponentPreviewBox.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ComponentPreviewBox.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Joni-Matti Maatta\r\n// Date: 1.8.2011\r\n//\r\n// Description:\r\n// Component preview box for visualizing HW components.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef COMPONENTPREVIEWBOX_H\r\n#define COMPONENTPREVIEWBOX_H\r\n\r\n#include <IPXACTmodels/common/VLNV.h>\r\n\r\n#include <editors/ComponentEditor/itemvisualizer.h>\r\n\r\n#include <QSharedPointer>\r\n#include <QGraphicsView>\r\n#include <QRectF>\r\n\r\nclass Component;\r\nclass LibraryInterface;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! ComponentPreviewBox class.\r\n//-----------------------------------------------------------------------------\r\nclass ComponentPreviewBox : public ItemVisualizer\r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n    /*!\r\n     *  Constructor.\r\n     *\r\n     *    @param [in] lh         The library interface. \r\n     *    @param [in] parent     The parent widget.\r\n     */\r\n    ComponentPreviewBox(LibraryInterface* lh, QWidget* parent = nullptr);\r\n\r\n    /*!\r\n     *  Destructor.\r\n     */\r\n    ~ComponentPreviewBox() override = default;\r\n\r\n    // Disable copying.\r\n    ComponentPreviewBox(ComponentPreviewBox const& rhs) = delete;\r\n    ComponentPreviewBox& operator=(ComponentPreviewBox const& rhs) = delete;\r\n\r\n    /*!\r\n     *  Sets the component that will be visualized.\r\n     *\r\n     *    @param [in] component  The component to visualize.\r\n     */\r\n    void setComponent(QSharedPointer<Component> component);\r\n\r\n    /*!\r\n     *  Updates the preview.\r\n     */\r\n    void updatePreview();\r\n\r\n\t/*!\r\n     *  Get the bounding rect of all items on the scene.\r\n\t *\r\n\t *    @return The rect that bounds all items.\r\n\t */\r\n\tQRectF itemsBoundingRect() const;\r\n\r\n    /*!\r\n     *  Get the graphics scene.\r\n     *\r\n     *    @return The graphics scene used by the preview.\r\n     */\r\n    QGraphicsScene* scene() const;\r\n\r\n    /*!\r\n     *  Set the preview interactive i.e. user can move interfaces.\r\n     *\r\n     *    @param [in] interactive  Interactive or view-only.\r\n     */\r\n    void setInteractive(bool interactive);\r\n\r\n\r\n\r\npublic slots:\r\n\r\n\t/*! \r\n\t * Sets the component that will be visualized.\r\n\t * \r\n\t *\t\t@param [in] vlnv The vlnv of the component. If vlnv does not belong\r\n\t *\t\tto component then the preview box is cleared.\r\n\t */\r\n\tvoid setComponent(const VLNV& vlnv);\r\n\r\nsignals:\r\n    //! Emitted when the terminal arrangement has changed.\r\n    void endpointsRearranged();\r\n\r\nprivate:\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! The library interface.\r\n    LibraryInterface* lh_;\r\n\r\n    //! The component to visualize.\r\n    QSharedPointer<Component> component_ = nullptr;\r\n\r\n    QGraphicsView* view_;\r\n\r\n    //! The graphics scene.\r\n    QGraphicsScene* scene_;\r\n\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n\r\n#endif // COMPONENTPREVIEWBOX_H\r\n"
  },
  {
    "path": "common/widgets/fileTypeSelector/filetypeselector.cpp",
    "content": "/* \r\n *\tCreated on:\t3.4.2013\r\n *\tAuthor:\t\tAntti Kamppi\r\n *\tFile name:\tfiletypeselector.cpp\r\n *\tProject:\t\tKactus 2\r\n*/\r\n\r\n#include \"filetypeselector.h\"\r\n\r\n#include <QSettings>\r\n\r\nFileTypeSelector::FileTypeSelector(QWidget *parent):\r\nQComboBox(parent) {\r\n\r\n\tsetEditable(true);\r\n\r\n\tconnect(this, SIGNAL(currentTextChanged(const QString&)),\r\n\t\tthis, SLOT(onFileChange(const QString&)), Qt::UniqueConnection);\r\n}\r\n\r\nFileTypeSelector::~FileTypeSelector() {\r\n}\r\n\r\nvoid FileTypeSelector::refresh() {\r\n\tdisconnect(this, SIGNAL(currentTextChanged(const QString&)),\r\n\t\tthis, SLOT(onFileChange(const QString&)));\r\n\r\n\t// remove the previous items\r\n\tclear();\r\n\r\n\t// read the possible file types from the settings\r\n\tQSettings settings;\r\n\r\n\tsettings.beginGroup(\"FileTypes\");\r\n\tQStringList typeNames = settings.childGroups();\r\n\tsettings.endGroup();\r\n\r\n\t// sort the names alphabetically\r\n\ttypeNames.sort(Qt::CaseInsensitive);\r\n\r\n\t// add the specified types to the combo box list\r\n\taddItems(typeNames);\r\n\r\n\tconnect(this, SIGNAL(currentTextChanged(const QString&)),\r\n\t\tthis, SLOT(onFileChange(const QString&)), Qt::UniqueConnection);\r\n}\r\n\r\nvoid FileTypeSelector::selectFileType( const QString& fileType ) {\r\n\tdisconnect(this, SIGNAL(currentTextChanged(const QString&)),\r\n\t\tthis, SLOT(onFileChange(const QString&)));\r\n\r\n\tint index = findText(fileType);\r\n\r\n\t// if the item is not found\r\n\tif (index < 0) {\r\n\t\taddItem(fileType);\r\n\t\tindex = count() - 1;\r\n\t}\r\n\r\n\tsetCurrentIndex(index);\r\n\r\n\tconnect(this, SIGNAL(currentTextChanged(const QString&)),\r\n\t\tthis, SLOT(onFileChange(const QString&)), Qt::UniqueConnection);\r\n}\r\n\r\nvoid FileTypeSelector::onFileChange( const QString& fileType ) {\r\n\temit fileTypeSelected(fileType);\r\n}\r\n"
  },
  {
    "path": "common/widgets/fileTypeSelector/filetypeselector.h",
    "content": "/* \r\n *\tCreated on:\t3.4.2013\r\n *\tAuthor:\t\tAntti Kamppi\r\n *\tFile name:\tfiletypeselector.h\r\n *\tProject:\t\tKactus 2\r\n*/\r\n\r\n#ifndef FILETYPESELECTOR_H\r\n#define FILETYPESELECTOR_H\r\n\r\n#include <QComboBox>\r\n\r\n/*! \\brief Combo box to select a file type.\r\n *\r\n */\r\nclass FileTypeSelector : public QComboBox {\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\r\n\t/*! \\brief The constructor.\r\n\t *\r\n\t * Method: \t\tFileTypeSelector\r\n\t * Full name:\tFileTypeSelector::FileTypeSelector\r\n\t * Access:\t\tprivate \r\n\t *\r\n\t * \\param parent Pointer to the owner of the combo box.\r\n\t *\r\n\t*/\r\n\tFileTypeSelector(QWidget *parent);\r\n\t\r\n\t//! \\brief The destructor.\r\n\tvirtual ~FileTypeSelector();\r\n\r\n\tpublic slots:\r\n\r\n\t//! \\brief Refresh the items to be selected in the combo box.\r\n\tvoid refresh();\r\n\r\n\t/*! \\brief Set the specified file type as selected.\r\n\t *\r\n\t * \\param fileType The name of the file type to select.\r\n\t *\r\n\t*/\r\n\tvoid selectFileType(const QString& fileType);\r\n\r\nsignals:\r\n\r\n\t//! \\brief Emitted when file type was selected by user.\r\n\tvoid fileTypeSelected(const QString& fileType);\r\n\r\nprivate slots:\r\n\r\n\t//! \\brief Handler for changes in combo box.\r\n\tvoid onFileChange(const QString& fileType);\r\n\r\nprivate:\r\n\t\r\n\t//! \\brief No copying\r\n\tFileTypeSelector(const FileTypeSelector& other);\r\n\r\n\t//! \\brief No assignment\r\n\tFileTypeSelector& operator=(const FileTypeSelector& other);\r\n\r\n};\r\n\r\n#endif // FILETYPESELECTOR_H\r\n"
  },
  {
    "path": "common/widgets/instanceWidgets/InstanceWidgets.cpp",
    "content": "#include \"InstanceWidgets.h\"\n\n// Implementation of InstanceComboBox\nInstanceComboBox::InstanceComboBox(QWidget* parent)\n    : QComboBox(parent)\n{\n}\n\nvoid InstanceComboBox::wheelEvent(QWheelEvent* event)\n{\n    event->ignore();\n}\n"
  },
  {
    "path": "common/widgets/instanceWidgets/InstanceWidgets.h",
    "content": "//-----------------------------------------------------------------------------\n// File: InstanceComboBox.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Sampo Suokuisma\n// Date: 05.06.2025\n//\n// Description:\n// A custom QComboBox that disables mouse wheel scrolling.\n//-----------------------------------------------------------------------------\n\n#ifndef INSTANCEWIDGETS_H\n#define INSTANCEWIDGETS_H\n\n#include <QComboBox>\n#include <QWheelEvent>\n\n/*!\n *  A custom QComboBox that disables mouse wheel scrolling.\n *\n *  This subclass of QComboBox overrides the default wheel event\n *  behavior to prevent accidental value changes caused by mouse wheel movements,\n *  especially when the combo box is not focused.\n */\nclass InstanceComboBox : public QComboBox\n{\n    Q_OBJECT\npublic:\n    /*!\n     *  Constructs the combo box with an optional parent widget.\n     *\n     *  @param [in] parent The parent widget. Defaults to nullptr.\n     */\n    explicit InstanceComboBox(QWidget* parent = nullptr);\n\nprotected:\n    /*!\n     *  Overrides the default wheel event to disable scrolling behavior.\n     *\n     *  @param [in] event The wheel event being processed.\n     */\n    void wheelEvent(QWheelEvent* event) override;\n};\n\n#endif // INSTANCEWIDGETS_H\n"
  },
  {
    "path": "common/widgets/interfaceModeSelector/interfacemodeselector.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: interfacemodeselector.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Antti Kamppi\r\n// Date: 15.06.2012\r\n//\r\n// Description:\r\n// The editor to select an interface mode for bus interface within a component.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"interfacemodeselector.h\"\r\n\r\n#include <IPXACTmodels/Component/BusInterface.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: InterfaceModeSelector::InterfaceModeSelector()\r\n//-----------------------------------------------------------------------------\r\nInterfaceModeSelector::InterfaceModeSelector(Document::Revision docRevision, General::InterfaceMode mode, \r\n\tbool showMonitor, QWidget* parent):\r\nQComboBox(parent),\r\nshowMonitor_(showMonitor)\r\n{\r\n\tinitialize(docRevision);\r\n\r\n\tsetCurrentText(General::interfaceMode2Str(mode));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: InterfaceModeSelector::initialize()\r\n//-----------------------------------------------------------------------------\r\nvoid InterfaceModeSelector::initialize(Document::Revision docRevision)\r\n{\r\n\t// mode names can not be edited\r\n\tsetEditable(false);\r\n\r\n\tsetSizeAdjustPolicy(QComboBox::AdjustToContents);\r\n\r\n\tQStringList items;\r\n\tif (docRevision == Document::Revision::Std14)\r\n\t{\r\n        items = General::INTERFACE_MODES.values();\r\n\t}\r\n\telse if (docRevision == Document::Revision::Std22)\r\n    {\r\n        items = General::INTERFACE_MODES_2022.values();\r\n\t}\r\n\r\n    items.prepend(\"\");\r\n\r\n    // if monitor should not be displayed then remove it\r\n    if (showMonitor_ == false)\r\n    {\r\n\t\titems.removeOne(General::interfaceMode2Str(General::MONITOR));\r\n    }\r\n    addItems(items);\r\n\r\n\tconnect(this, SIGNAL(currentTextChanged(const QString&)),\r\n\t\tthis, SLOT(setMode(const QString&)), Qt::UniqueConnection);\r\n\r\n\t// the interface mode is mandatory by default\r\n\tsetProperty(\"mandatoryField\", true);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: InterfaceModeSelector::setMode()\r\n//-----------------------------------------------------------------------------\r\nvoid InterfaceModeSelector::setMode(const General::InterfaceMode mode)\r\n{\r\n\t// if the mode the set is monitor and it is not shown\r\n\tif (!showMonitor_ && mode == General::MONITOR)\r\n    {\r\n\t\treturn;\r\n\t}\r\n\r\n\tdisconnect(this, SIGNAL(currentTextChanged(const QString&)), this, SLOT(setMode(const QString&)));\r\n\t\r\n    QString modeText = General::interfaceMode2Str(mode);\r\n    if (modeText == \"undefined\")\r\n    {\r\n        modeText = \"\";\r\n    }\r\n\tsetCurrentText(modeText);\r\n\t\r\n\tconnect(this, SIGNAL(currentTextChanged(const QString&)),\r\n        this, SLOT(setMode(const QString&)), Qt::UniqueConnection);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: InterfaceModeSelector::setMode()\r\n//-----------------------------------------------------------------------------\r\nvoid InterfaceModeSelector::setMode(QString const& modeName)\r\n{\r\n\tdisconnect(this, SIGNAL(currentTextChanged(const QString&)), this, SLOT(setMode(const QString&)));\r\n\r\n\t// find the item for the text\r\n\tint index = findText(modeName, Qt::MatchFixedString);\r\n\r\n\t// if text was found\r\n\tif (index >= 0)\r\n    {\r\n\t\tsetCurrentIndex(index);\r\n\t\temit modeSelected(General::str2Interfacemode(modeName, General::INTERFACE_MODE_COUNT));\r\n\t}\r\n\r\n\tconnect(this, SIGNAL(currentTextChanged(const QString&)),\r\n        this, SLOT(setMode(const QString&)), Qt::UniqueConnection);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: InterfaceModeSelector::selected()\r\n//-----------------------------------------------------------------------------\r\nGeneral::InterfaceMode InterfaceModeSelector::selected() const\r\n{\r\n\treturn General::str2Interfacemode(currentText(), General::INTERFACE_MODE_COUNT);\r\n}\r\n"
  },
  {
    "path": "common/widgets/interfaceModeSelector/interfacemodeselector.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: interfacemodeselector.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Antti Kamppi\r\n// Date: 15.06.2012\r\n//\r\n// Description:\r\n// The editor to select an interface mode for bus interface within a component.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef INTERFACEMODESELECTOR_H\r\n#define INTERFACEMODESELECTOR_H\r\n\r\n#include <IPXACTmodels/generaldeclarations.h>\r\n\r\n#include <IPXACTmodels/common/Document.h>\r\n\r\n#include <QComboBox>\r\n#include <QSharedPointer>\r\n\r\n//-----------------------------------------------------------------------------\r\n//! The editor to select an interface mode for bus interface within a component.\r\n//-----------------------------------------------------------------------------\r\nclass InterfaceModeSelector : public QComboBox\r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\r\n\t/*!\r\n     *  The constructor.\r\n     *\r\n     *    @param [in] docRevision     The IP-XACT version to comply to.\r\n\t *    @param [in] showMonitor     If this is true then also \"monitor\" option is shown.\r\n\t *    @param [in] mode            The interface mode that is selected at start.\r\n\t *    @param [in] parent          The owner of the editor.\r\n     */\r\n    InterfaceModeSelector(Document::Revision docRevision, \r\n\t\tGeneral::InterfaceMode mode = General::INTERFACE_MODE_COUNT,\r\n        bool showMonitor = true, QWidget * parent = nullptr);\r\n\r\n\t/*!\r\n     *  The destructor.\r\n     */\r\n\tvirtual ~InterfaceModeSelector() = default;\r\n\r\n    //! No copying\r\n    InterfaceModeSelector(const InterfaceModeSelector& other) = delete;\r\n\r\n    //! No assignment\r\n    InterfaceModeSelector& operator=(const InterfaceModeSelector& other) = delete;\r\n\r\n\t/*!\r\n     *  Get the currently selected mode.\r\n\t *\r\n\t *    @return The selected interface mode.\r\n     */\r\n\tGeneral::InterfaceMode selected() const;\r\n\r\npublic slots:\r\n\r\n\t/*! Set the selected mode.\r\n\t * \r\n\t * This slot does not emit any signals when it is called. \r\n\t *\r\n\t *    @param [in] mode The mode to set selected.\r\n\t*/\r\n\tvoid setMode(const General::InterfaceMode mode);\r\n\r\n\t/*! Set the selected mode.\r\n\t *\r\n\t * Calling this slot emits the modeSelected(mode) signal.\r\n\t * \r\n\t *    @param [in] modeName The name of the mode. This should be one of the defined in General::INTERFACE_MODE_NAMES\r\n\t*/\r\n\tvoid setMode(QString const& modeName);\r\n\r\nsignals:\r\n\r\n\t//! Emitted when the selected interface mode changes.\r\n\tvoid modeSelected(General::InterfaceMode mode);\r\n\r\nprivate:\r\n\r\n\r\n\t//! Set up the editor.\r\n\tvoid initialize(Document::Revision docRevision);\r\n\r\n\t//! If this is true then the \"monitor\" option is shown in drop down list.\r\n\tbool showMonitor_;\r\n};\r\n\r\n#endif // INTERFACEMODESELECTOR_H\r\n"
  },
  {
    "path": "common/widgets/interfaceSelector/interfaceselector.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: interfaceSelector.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Antti Kamppi\r\n// Date: 26.06.2012\r\n//\r\n// Description:\r\n// \r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"interfaceselector.h\"\r\n\r\n#include <IPXACTmodels/Component/BusInterface.h>\r\n#include <IPXACTmodels/Component/Component.h>\r\n\r\n#include <KactusAPI/include/BusInterfaceInterface.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: InterfaceSelector::InterfaceSelector()\r\n//-----------------------------------------------------------------------------\r\nInterfaceSelector::InterfaceSelector(BusInterfaceInterface* busInterface, QWidget* parent,\r\n    General::InterfaceMode mode):\r\nQComboBox(parent),\r\nmode_(mode),\r\nbusInterface_(busInterface)\r\n{\r\n\tsetEditable(false);\r\n\r\n\tconnect(this, SIGNAL(currentIndexChanged(int)),\tthis, SLOT(onIndexChange(int)), Qt::UniqueConnection);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: InterfaceSelector::~InterfaceSelector()\r\n//-----------------------------------------------------------------------------\r\nInterfaceSelector::~InterfaceSelector()\r\n{\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: InterfaceSelector::setInterfaceMode()\r\n//-----------------------------------------------------------------------------\r\nvoid InterfaceSelector::setInterfaceMode(General::InterfaceMode mode)\r\n{\r\n\tmode_ = mode;\r\n\trefresh();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: InterfaceSelector::refresh()\r\n//-----------------------------------------------------------------------------\r\nvoid InterfaceSelector::refresh()\r\n{\r\n\tdisconnect(this, SIGNAL(currentIndexChanged(int)), this, SLOT(onIndexChange(int)));\r\n\r\n\t// remove the previous items\r\n\tclear();\r\n\r\n\t// the list to add to combo box\r\n\tQStringList list;\r\n\r\n\t// if mode is specified then check that the modes match\r\n\tif (mode_ != General::INTERFACE_MODE_COUNT)\r\n    {\r\n\t\t// check that each name matches the mode\r\n        for (auto busName : busInterface_->getItemNames())\r\n        {\r\n\t\t\t// if theres a match then add the name to the list\r\n            if (busInterface_->getMode(busName) == mode_)\r\n            {\r\n                list.append(QString::fromStdString(busName));\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\t// if mode is unspecified then add all\r\n\telse\r\n    {\r\n        for (auto busName : busInterface_->getItemNames())\r\n        {\r\n            list.append(QString::fromStdString(busName));\r\n        }\r\n\t}\r\n\r\n\taddItems(list);\r\n\r\n\tconnect(this, SIGNAL(currentIndexChanged(int)),\tthis, SLOT(onIndexChange(int)), Qt::UniqueConnection);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: InterfaceSelector::refresh()\r\n//-----------------------------------------------------------------------------\r\nvoid InterfaceSelector::selectInterface(QString const& interfaceName)\r\n{\r\n\tdisconnect(this, SIGNAL(currentIndexChanged(int)), this, SLOT(onIndexChange(int)));\r\n\tsetCurrentIndex(findText(interfaceName));\r\n\tconnect(this, SIGNAL(currentIndexChanged(int)),\tthis, SLOT(onIndexChange(int)), Qt::UniqueConnection);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: InterfaceSelector::onIndexChange()\r\n//-----------------------------------------------------------------------------\r\nvoid InterfaceSelector::onIndexChange(int newIndex)\r\n{\r\n\t// find the text for the index\r\n\temit interfaceSelected(itemText(newIndex));\r\n}\r\n"
  },
  {
    "path": "common/widgets/interfaceSelector/interfaceselector.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: interfaceSelector.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Antti Kamppi\r\n// Date: 26.06.2012\r\n//\r\n// Description:\r\n// A combo box to select a bus interface within a component.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef INTERFACESELECTOR_H\r\n#define INTERFACESELECTOR_H\r\n\r\n#include <IPXACTmodels/generaldeclarations.h>\r\n\r\n#include <QComboBox>\r\n#include <QSharedPointer>\r\n\r\nclass Component;\r\nclass BusInterfaceInterface;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! A combo box to select a bus interface within a component.\r\n//-----------------------------------------------------------------------------\r\nclass InterfaceSelector : public QComboBox\r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\r\n\t/*! The constructor.\r\n\t *\r\n\t *    @param [in] busInterface    Interface for accessing bus interfaces.\r\n\t *    @param [in] parent          The owner of this combo box.\r\n\t *    @param [in] mode            The mode that defines the types of interfaces to show.\r\n\t*/\r\n    InterfaceSelector(BusInterfaceInterface* busInterface, QWidget* parent,\r\n        General::InterfaceMode mode = General::INTERFACE_MODE_COUNT);\r\n\r\n\t/*!\r\n     *  The destructor.\r\n     */\r\n\tvirtual\t~InterfaceSelector();\r\n\r\n\t/*!\r\n     *  Set the interface mode filter.\r\n\t *\r\n\t *    @param [in] mode The mode that defines the types of interfaces to show.\r\n\t *\r\n\t *  Note: If the mode is undefined (General::INTERFACE_MODE_COUNT) then all types of interfaces are shown.\r\n     */\r\n\tvoid setInterfaceMode(General::InterfaceMode mode);\r\n\r\npublic slots:\r\n\r\n\t/*!\r\n     *  Refresh the contents of the combo box.\r\n     */\r\n\tvoid refresh();\r\n\r\n\t/*!\r\n     *  Set the specified interface as selected.\r\n\t *\r\n\t *    @param [in] interfaceName The name of the interface to select.\r\n     */\r\n\tvoid selectInterface(const QString& interfaceName);\r\n\r\nsignals:\r\n\r\n\t/*!\r\n     *  Emitted when interface was selected by user.\r\n     */\r\n\tvoid interfaceSelected(const QString& interfaceName);\r\n\r\nprivate slots:\r\n\r\n\t/*!\r\n     *  Handler for selected index changes.\r\n     */\r\n\tvoid onIndexChange(int newIndex);\r\n\r\nprivate:\r\n\t\r\n    //! No copying. No assignment.\r\n\tInterfaceSelector(const InterfaceSelector& other);\r\n\tInterfaceSelector& operator=(const InterfaceSelector& other);\r\n\r\n\t//! The filter that is used to limit the possible options.\r\n\tGeneral::InterfaceMode mode_;\r\n\r\n    //! Interface for accessing bus interfaces.\r\n    BusInterfaceInterface* busInterface_;\r\n};\r\n\r\n#endif // INTERFACESELECTOR_H\r\n"
  },
  {
    "path": "common/widgets/kactusAttributeEditor/KactusAttributeEditor.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: KactusAttributeEditor.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Joni-Matti Maatta\r\n// Date: 23.6.2011\r\n//\r\n// Description:\r\n// Attribute editor for Kactus 2 -specific base attributes.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"KactusAttributeEditor.h\"\r\n\r\n#include <IPXACTmodels/kactusExtensions/KactusAttribute.h>\r\n\r\n#include <common/widgets/tagEditor/TagEditorContainer.h>\r\n\r\n#include <QFormLayout>\r\n#include <QString>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: KactusAttributeEditor::KactusAttributeEditor()\r\n//-----------------------------------------------------------------------------\r\nKactusAttributeEditor::KactusAttributeEditor(QWidget* parent) : QGroupBox(tr(\"Kactus attributes\"), parent),\r\n    prodHierLabel_(new QLabel(tr(\"Product Hierarchy:\"), this)), \r\n    prodHierCombo_(new QComboBox(this)),\r\n    firmnessLabel_(new QLabel(tr(\"Firmness:\"), this)),\r\n    firmnessCombo_(new QComboBox(this)),\r\n    implementationLabel_(new QLabel(tr(\"Implementation:\"), this)), \r\n    implementationValue_(new QLabel(tr(\"\"), this)),\r\n    tagEditor_(new TagEditorContainer(this))\r\n{\r\n    setFlat(true);\r\n\r\n    // The implementation label and value label are set to invisible by default.\r\n    implementationLabel_->setVisible(false);\r\n    implementationValue_->setVisible(false);\r\n\r\n    prodHierCombo_->addItem(QIcon(\":icons/common/graphics/square.png\"), \"Flat\");\r\n    prodHierCombo_->addItem(QIcon(\":icons/common/graphics/box.png\"), \"Product\");\r\n    prodHierCombo_->addItem(QIcon(\":icons/common/graphics/circuit.png\"), \"Board\");\r\n    prodHierCombo_->addItem(QIcon(\":icons/common/graphics/chip.png\"), \"Chip\");\r\n    prodHierCombo_->addItem(QIcon(\":icons/common/graphics/soc.png\"), \"SoC\");\r\n    prodHierCombo_->addItem(QIcon(\":icons/common/graphics/capacitor.png\"), \"IP\");\r\n\r\n    firmnessCombo_->addItem(QIcon(\":icons/common/graphics/mutable.png\"), \"Mutable\");\r\n    firmnessCombo_->addItem(QIcon(\":icons/common/graphics/template.png\"), \"Template\");\r\n    firmnessCombo_->addItem(QIcon(\":icons/common/graphics/fixed.png\"), \"Fixed\");\r\n\r\n    QFormLayout* layout = new QFormLayout(this);\r\n    layout->addRow(prodHierLabel_, prodHierCombo_);\r\n    layout->addRow(firmnessLabel_, firmnessCombo_);\r\n    layout->addRow(implementationLabel_, implementationValue_);\r\n    layout->addRow(new QLabel(QStringLiteral(\"Tags:\")), tagEditor_);\r\n\r\n    connect(prodHierCombo_, SIGNAL(currentIndexChanged(int)), this, SIGNAL(contentChanged()));\r\n    connect(prodHierCombo_, SIGNAL(currentIndexChanged(int)), this, SIGNAL(productHierarchyChanged()));\r\n    connect(firmnessCombo_, SIGNAL(currentIndexChanged(int)), this, SIGNAL(contentChanged()));\r\n    connect(tagEditor_, SIGNAL(contentChanged()), this, SIGNAL(contentChanged()), Qt::UniqueConnection);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: KactusAttributeEditor::~KactusAttributeEditor()\r\n//-----------------------------------------------------------------------------\r\nKactusAttributeEditor::~KactusAttributeEditor()\r\n{\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: KactusAttributeEditor::setAttributes()\r\n//-----------------------------------------------------------------------------\r\nvoid KactusAttributeEditor::setAttributes(KactusAttribute::ProductHierarchy prodHier,\r\n    KactusAttribute::Firmness firmness, QVector<TagData> tags)\r\n{\r\n    prodHierCombo_->setCurrentIndex(prodHier);\r\n    firmnessCombo_->setCurrentIndex(firmness);\r\n    tagEditor_->setupTags(tags);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: KactusAttributeEditor::getProductHierarchy()\r\n//-----------------------------------------------------------------------------\r\nKactusAttribute::ProductHierarchy KactusAttributeEditor::getProductHierarchy() const\r\n{\r\n    return static_cast<KactusAttribute::ProductHierarchy>(prodHierCombo_->currentIndex());\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: KactusAttributeEditor::getFirmness()\r\n//-----------------------------------------------------------------------------\r\nKactusAttribute::Firmness KactusAttributeEditor::getFirmness() const\r\n{\r\n    return static_cast<KactusAttribute::Firmness>(firmnessCombo_->currentIndex());\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: KactusAttributeEditor::getTags()\r\n//-----------------------------------------------------------------------------\r\nQVector<TagData> KactusAttributeEditor::getTags() const\r\n{\r\n    return tagEditor_->getTags();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: KactusAttributeEditor::setImplementation()\r\n//-----------------------------------------------------------------------------\r\nvoid KactusAttributeEditor::setImplementation(KactusAttribute::Implementation implementation)\r\n{\r\n    implementationValue_->setText(KactusAttribute::implementationToString(implementation));\r\n    implementationLabel_->setVisible(true);\r\n    implementationValue_->setVisible(true);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: KactusAttributeEditor::hideAttributes()\r\n//-----------------------------------------------------------------------------\r\nvoid KactusAttributeEditor::hideAttributes()\r\n{\r\n    prodHierLabel_->setVisible(false);\r\n    prodHierCombo_->setVisible(false);\r\n    firmnessLabel_->setVisible(false);\r\n    firmnessCombo_->setVisible(false);\r\n}\r\n"
  },
  {
    "path": "common/widgets/kactusAttributeEditor/KactusAttributeEditor.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: KactusAttributeEditor.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Joni-Matti Maatta\r\n// Date: 23.6.2011\r\n//\r\n// Description:\r\n// Attribute editor for Kactus 2 -specific base attributes.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef KACTUSATTRIBUTEEDITOR_H\r\n#define KACTUSATTRIBUTEEDITOR_H\r\n\r\n#include <IPXACTmodels/kactusExtensions/KactusAttribute.h>\r\n#include <IPXACTmodels/common/TagData.h>\r\n\r\n#include <QGroupBox>\r\n#include <QComboBox>\r\n#include <QLabel>\r\n\r\nclass TagContainer;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! KactusAttributeEditor class.\r\n//-----------------------------------------------------------------------------\r\nclass KactusAttributeEditor : public QGroupBox\r\n{\r\n    Q_OBJECT\r\n\r\npublic:\r\n    /*!\r\n     *  Constructor.\r\n     */\r\n    KactusAttributeEditor(QWidget* parent);\r\n\r\n    /*!\r\n     *  Destructor.\r\n     */\r\n    virtual ~KactusAttributeEditor();\r\n\r\n    /*!\r\n     *  Hides the editable attributes.\r\n     */\r\n    void hideAttributes();\r\n\r\n    /*!\r\n     *  Sets the given attributes as selected.\r\n     *\r\n     *    @param [in] prodHier    Product hierarchy.\r\n     *    @param [in] firmness\tFirmness.\r\n     *    @param [in] tags        Document tags.\r\n     */\r\n    void setAttributes(KactusAttribute::ProductHierarchy prodHier, KactusAttribute::Firmness firmness,\r\n        QVector<TagData> tags);\r\n\r\n    /*!\r\n     *  Sets the implementation visible with the given value.\r\n     *\r\n     *    @param [in] implementation Implementation.\r\n     */\r\n    void setImplementation(KactusAttribute::Implementation implementation);\r\n    \r\n    /*!\r\n     *  Returns the selected product hierarchy.\r\n     */\r\n    KactusAttribute::ProductHierarchy getProductHierarchy() const;\r\n\r\n    /*!\r\n     *  Returns the selected firmness.\r\n     */\r\n    KactusAttribute::Firmness getFirmness() const;\r\n\r\n    /*!\r\n     *  Get document tags.\r\n     *\r\n     *    @return Document tags.\r\n     */\r\n    QVector<TagData> getTags() const;\r\n\r\nsignals:\r\n    //! Signaled when the attributes have changed.\r\n    void contentChanged();\r\n\r\n    //! Signaled when the product hierarchy attribute has changed.\r\n    void productHierarchyChanged();\r\n\r\nprivate:\r\n    // Disable copying.\r\n    KactusAttributeEditor(KactusAttributeEditor const& rhs);\r\n    KactusAttributeEditor& operator=(KactusAttributeEditor const& rhs);\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! Product hierarchy label.\r\n    QLabel* prodHierLabel_;\r\n\r\n    //! Product hierarchy combo box.\r\n    QComboBox* prodHierCombo_;\r\n\r\n    //! Firmness label.\r\n    QLabel* firmnessLabel_;\r\n\r\n    //! Firmness combo box.\r\n    QComboBox* firmnessCombo_;\r\n\r\n    //! Implementation label.\r\n    QLabel* implementationLabel_;\r\n\r\n    //! Label for the implementation value.\r\n    QLabel* implementationValue_;\r\n\r\n    //! Editor for document tags.\r\n    TagContainer* tagEditor_;\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n\r\n#endif // KACTUSATTRIBUTEEDITOR_H\r\n"
  },
  {
    "path": "common/widgets/listManager/ListManager.pro",
    "content": "QT       += core gui\r\n\r\nTARGET = ListManager\r\nTEMPLATE = app\r\n\r\nHEADERS += \\\r\n    listmanager.h \\\r\n    listmanagermodel.h\r\n\r\nSOURCES += \\\r\n    listmanagermodel.cpp \\\r\n    listmanager.cpp \\\r\n    main.cpp\r\n"
  },
  {
    "path": "common/widgets/listManager/dirlistmanager.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: dirlistmanager.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Antti Kamppi\r\n// Date: 04.02.2011\r\n//\r\n// Description:\r\n// DirListManager can be used to manage a list of relative directory paths.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"dirlistmanager.h\"\r\n#include \"dirlistmanagermodel.h\"\r\n\r\n#include <common/delegates/LineEditDelegate/lineeditdelegate.h>\r\n\r\n#include <QHBoxLayout>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: dirlistmanager::DirListManager()\r\n//-----------------------------------------------------------------------------\r\nDirListManager::DirListManager(QString const& title, QString const& basePath, QWidget *parent) :\r\nListManager(title, parent), \r\n    basePath_(basePath)\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: dirlistmanager::~DirListManager()\r\n//-----------------------------------------------------------------------------\r\nDirListManager::~DirListManager()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: dirlistmanager::initialize()\r\n//-----------------------------------------------------------------------------\r\nvoid DirListManager::initialize( const QStringList& items /*= QStringList()*/ )\r\n{\r\n    // remove the previous model and view if there are one\r\n    if (model_)\r\n    {\r\n        delete model_;\r\n        model_ = 0;\r\n    }\r\n\r\n    if (view_)\r\n    {\r\n        delete view_;\r\n        view_ = 0;\r\n    }\r\n\r\n    // create new model and view\r\n    model_ = new DirListManagerModel(basePath_, items, this);\r\n\r\n    view_ = new EditableListView(this);\r\n\r\n    // the signals from the view\r\n    connect(view_, SIGNAL(removeItem(const QModelIndex&)),\r\n        model_, SLOT(remove(const QModelIndex&)), Qt::UniqueConnection);\r\n\r\n    connect(view_, SIGNAL(addItem(const QModelIndex&)),\r\n        model_, SLOT(addItem(const QModelIndex&)), Qt::UniqueConnection);\r\n\r\n    connect(view_, SIGNAL(moveItem(const QModelIndex&, const QModelIndex&)),\r\n        model_, SLOT(moveItem(const QModelIndex&, const QModelIndex&)), Qt::UniqueConnection);\r\n\r\n    // the signals from the model\r\n    connect(model_, SIGNAL(contentChanged()), this, SIGNAL(contentChanged()), Qt::UniqueConnection);\r\n\r\n    connect(model_, SIGNAL(dataChanged(const QModelIndex&, const QModelIndex&)),\r\n        this, SIGNAL(contentChanged()), Qt::UniqueConnection);\r\n\r\n    QLayout* topLayout = layout();\r\n\r\n    if (topLayout == 0)\r\n    {\r\n        // the top layout of the widget\r\n        topLayout = new QHBoxLayout(this);\r\n    }\r\n\r\n    // add the view on the left side\r\n    topLayout->addWidget(view_);\r\n\r\n    // connect the model to the view\r\n    view_->setModel(model_);\r\n\r\n    view_->setItemDelegate(new LineEditDelegate(this));\r\n}\r\n\r\n"
  },
  {
    "path": "common/widgets/listManager/dirlistmanager.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: dirlistmanager.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Antti Kamppi\r\n// Date: 04.02.2011\r\n//\r\n// Description:\r\n// DirListManager can be used to manage a list of relative directory paths.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef DIRLISTMANAGER_H\r\n#define DIRLISTMANAGER_H\r\n\r\n#include \"listmanager.h\"\r\n\r\n#include <QString>\r\n#include <QWidget>\r\n#include <QStringList>\r\n#include <QSharedPointer>\r\n\r\n//-----------------------------------------------------------------------------\r\n//! DirListManager can be used to manage a list of relative directory paths.\r\n//-----------------------------------------------------------------------------\r\nclass DirListManager : public ListManager\r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\r\n\t/*!\r\n     *  The constructor.\r\n\t *\r\n\t *    @param [in] title       Title to be set for the QGroupBox\r\n\t *    @param [in] basePath    Path to start relative paths from.\r\n\t *    @param [in] parent      The owner of this widget.\r\n\t */\r\n\tDirListManager(QString const& title, QString const& basePath, QWidget *parent = 0);\r\n\r\n\t//! The destructor.\r\n\tvirtual ~DirListManager();\r\n\r\n\t/*!\r\n     *  Initialize the directory list manager.\r\n\t *\r\n\t *  This function must be called after creating the directory list manager and before using it.\r\n\t * \r\n\t *    @param [in] items   QStringList that contains the items to add to the widget.\r\n\t */\r\n\tvirtual void initialize(const QStringList& items = QStringList());\r\n\r\nprivate:\r\n\t\r\n\t//! No copying. No assignment.\r\n\tDirListManager(const DirListManager& other);\r\n\tDirListManager& operator=(const DirListManager& other);\r\n\r\n    //! Path to start search for relative paths.\r\n    QString basePath_;\r\n};\r\n\r\n#endif // DIRLISTMANAGER_H\r\n"
  },
  {
    "path": "common/widgets/listManager/dirlistmanagermodel.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: dirlistmanagermodel.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Antti Kamppi\r\n// Date: 26.04.2013\r\n//\r\n// Description:\r\n// The model which re-implements the validity check of dir paths.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"dirlistmanagermodel.h\"\r\n\r\n#include <IPXACTmodels/generaldeclarations.h>\r\n\r\n#include <common/KactusColors.h>\r\n\r\n#include <KactusAPI/include/FileHandler.h>\r\n\r\n#include <QFileInfo>\r\n\r\n#include <QIcon>\r\n#include <QPixmap>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: dirlistmanagermodel::DirListManagerModel()\r\n//-----------------------------------------------------------------------------\r\nDirListManagerModel::DirListManagerModel(QString const& basePath, QStringList const& items, QObject* parent):\r\nListManagerModel(items, parent),\r\n    basePath_(basePath)\r\n{\r\n    if (!basePath_.endsWith(QLatin1Char('/')))\r\n    {\r\n        basePath_.append(QLatin1Char('/'));\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: dirlistmanagermodel::~DirListManagerModel()\r\n//-----------------------------------------------------------------------------\r\nDirListManagerModel::~DirListManagerModel()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: dirlistmanagermodel::data()\r\n//-----------------------------------------------------------------------------\r\nQVariant DirListManagerModel::data(QModelIndex const& index, int role) const\r\n{\r\n    if (!index.isValid())\r\n    {\r\n        return QVariant();\r\n    }\r\n\r\n    // if there are items to display then check the validity of them\r\n    else if (role == Qt::ForegroundRole && items_.isEmpty() == false)\r\n    {\r\n        if (FileHandler::isValidURI(basePath_, items_.at(index.row())))\r\n        {\r\n            return KactusColors::REGULAR_TEXT;\r\n        }\r\n        else\r\n        {\r\n            return KactusColors::ERROR;\r\n        }\r\n    }\r\n\r\n    else if (role == Qt::DecorationRole && !items_.isEmpty())\r\n    {\r\n        if (FileHandler::isValidURI(basePath_, items_.at(index.row())) == false)\r\n        {\r\n            return QIcon(QPixmap(\":/icons/common/graphics/exclamation.png\"));\r\n        }\r\n        else\r\n        {\r\n            return QVariant();\r\n        }\r\n    }\r\n\r\n    // other than fore ground role use the base class implementation\r\n    else\r\n    {\r\n        return ListManagerModel::data(index, role);\r\n    }\r\n}\r\n"
  },
  {
    "path": "common/widgets/listManager/dirlistmanagermodel.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: dirlistmanagermodel.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Antti Kamppi\r\n// Date: 26.04.2013\r\n//\r\n// Description:\r\n// The model which re-implements the validity check of dir paths.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef DIRLISTMANAGERMODEL_H\r\n#define DIRLISTMANAGERMODEL_H\r\n\r\n#include <common/widgets/listManager/listmanagermodel.h>\r\n\r\n#include <QSharedPointer>\r\n\r\n//-----------------------------------------------------------------------------\r\n//! The model which re-implements the validity check of dir paths.\r\n//-----------------------------------------------------------------------------\r\nclass DirListManagerModel : public ListManagerModel\r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\r\n\t/*!\r\n     *  The constructor.\r\n\t *\r\n\t *    @param [in] basePath    Path to start the relative paths from.\r\n\t *    @param [in] items       QStringList which contains the items to add.\r\n     *    @param [in] parent      The owner of the model.\r\n\t */\r\n\tDirListManagerModel(QString const& basePath, QStringList const& items = QStringList(), QObject* parent = 0);\r\n\t\r\n\t//! The destructor.\r\n\tvirtual ~DirListManagerModel();\r\n\r\n\t/*!\r\n     *  Get the data stored for the specified item.\r\n\t *\r\n\t *    @param [in] index   ModelIndex of the wanted item.\r\n\t *    @param [in] role    Specifies what kind of data is requested.\r\n\t */\r\n\tvirtual QVariant data(QModelIndex const& index, int role = Qt::DisplayRole) const;\r\n\r\nprivate:\r\n\t\r\n\t//! No copying. No assignment.\r\n\tDirListManagerModel(const DirListManagerModel& other);\r\n\tDirListManagerModel& operator=(const DirListManagerModel& other);\r\n\r\n\t//! The path to start relative paths from.\r\n\tQString basePath_;\r\n};\r\n\r\n#endif // DIRLISTMANAGERMODEL_H\r\n"
  },
  {
    "path": "common/widgets/listManager/listeditor.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ListEditor.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 30.05.2012\r\n//\r\n// Description:\r\n// Editor for a list of items.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"listeditor.h\"\r\n\r\n#include <QHBoxLayout>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: listeditor::ListEditor()\r\n//-----------------------------------------------------------------------------\r\nListEditor::ListEditor(QWidget *parent):\r\nQWidget(parent),\r\nmodel_(QStringList(), this),\r\nview_(this)\r\n{\r\n    // the signals from the view\r\n    connect(&view_, SIGNAL(removeItem(const QModelIndex&)),\r\n        &model_, SLOT(remove(const QModelIndex&)), Qt::UniqueConnection);\r\n\r\n    connect(&view_, SIGNAL(addItem(const QModelIndex&)),\r\n        &model_, SLOT(addItem(const QModelIndex&)), Qt::UniqueConnection);\r\n\r\n    connect(&view_, SIGNAL(moveItem(const QModelIndex&, const QModelIndex&)),\r\n        &model_, SLOT(moveItem(const QModelIndex&, const QModelIndex&)), Qt::UniqueConnection);\r\n\r\n    // the signals from the model\r\n    connect(&model_, SIGNAL(contentChanged()),\r\n        this, SIGNAL(contentChanged()), Qt::UniqueConnection);\r\n\r\n    connect(&model_, SIGNAL(dataChanged(const QModelIndex&, const QModelIndex&)),\r\n        this, SIGNAL(contentChanged()), Qt::UniqueConnection);\r\n\r\n    QHBoxLayout* topLayout = new QHBoxLayout(this);\r\n    topLayout->addWidget(&view_);\r\n    topLayout->setContentsMargins(0, 0, 0, 0);\r\n\r\n    // connect the model to the view\r\n    view_.setModel(&model_);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: listeditor::~ListEditor()\r\n//-----------------------------------------------------------------------------\r\nListEditor::~ListEditor()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: listeditor::items()\r\n//-----------------------------------------------------------------------------\r\nconst QStringList& ListEditor::items() const\r\n{\r\n    return model_.items();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: listeditor::setItems()\r\n//-----------------------------------------------------------------------------\r\nvoid ListEditor::setItems( const QStringList& items )\r\n{\r\n    model_.setItems(items);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: listeditor::size()\r\n//-----------------------------------------------------------------------------\r\nint ListEditor::size() const\r\n{\r\n    return model_.rowCount();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: listeditor::setItemDelegate()\r\n//-----------------------------------------------------------------------------\r\nvoid ListEditor::setItemDelegate( QStyledItemDelegate* delegate )\r\n{\r\n    view_.setItemDelegate(delegate);\r\n}\r\n"
  },
  {
    "path": "common/widgets/listManager/listeditor.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ListEditor.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 30.05.2012\r\n//\r\n// Description:\r\n// Editor for a list of items.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef LISTEDITOR_H\r\n#define LISTEDITOR_H\r\n\r\n#include <common/views/EditableListView/editablelistview.h>\r\n#include <common/widgets/listManager/listmanagermodel.h>\r\n\r\n#include <QWidget>\r\n#include <QStyledItemDelegate>\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Editor for a list of items.\r\n//-----------------------------------------------------------------------------\r\nclass ListEditor : public QWidget\r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\r\n\t/*!\r\n     *  The constructor.\r\n\t *\r\n\t *    @param [in] parent  Pointer to the owner of this editor.\r\n\t */\r\n\tListEditor(QWidget *parent);\r\n\t\r\n\t/*!\r\n     *  The destructor.\r\n     */\r\n\tvirtual ~ListEditor();\r\n\r\n\t/*!\r\n     *  Get the string items currently stored in the editor.\r\n     *\r\n     *    @return QStringList that contains the strings.\r\n     */\r\n\tconst QStringList& items() const;\r\n\r\n\t/*!\r\n     *  Set the items for the editor.\r\n     *\r\n     *    @param [in] items   QStringList containing the strings to edit.\r\n     */\r\n\tvoid setItems(const QStringList& items);\r\n\r\n\t/*!\r\n     *  Get the number of items stored in the list.\r\n\t *\r\n\t *    @return Number of items in the list.\r\n     */\r\n\tint size() const;\r\n\r\n\t/*!\r\n     *  Set delegate for the view.\r\n\t *\r\n     *    @param [in] delegate    Pointer to the delegate that provides editor for view.\r\n     */\r\n\tvirtual void setItemDelegate(QStyledItemDelegate* delegate);\r\n\r\nsignals:\r\n\r\n\t/*!\r\n     *  Emitted when contents of the editor change.\r\n     */\r\n\tvoid contentChanged();\r\n\r\n//     void closingEditor(QStringList const& listItems);\r\n//     void closingEditor();\r\n\r\nprivate:\r\n\t\r\n\t//! No copying. No assignment.\r\n\tListEditor(const ListEditor& other);\r\n\tListEditor& operator=(const ListEditor& other);\r\n\r\n\t//! The model that contains the list of strings.\r\n\tListManagerModel model_;\r\n\r\n\t//! The View to display the list of strings.\r\n\tEditableListView view_;\r\n};\r\n\r\n#endif // LISTEDITOR_H\r\n"
  },
  {
    "path": "common/widgets/listManager/listmanager.cpp",
    "content": "/* \r\n *\r\n *  Created on: 28.1.2011\r\n *      Author: Antti Kamppi\r\n *         filename: listmanager.cpp\r\n */\r\n\r\n#include \"listmanager.h\"\r\n\r\n#include <common/delegates/LineEditDelegate/lineeditdelegate.h>\r\n\r\n#include <QPushButton>\r\n#include <QVBoxLayout>\r\n#include <QHBoxLayout>\r\n#include <QInputDialog>\r\n#include <QModelIndex>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ListManager::ListManager()\r\n//-----------------------------------------------------------------------------\r\nListManager::ListManager(QString const& title, QWidget *parent): \r\nQGroupBox(title, parent), \r\n    model_(0), \r\n    view_(0)\r\n{\r\n    setFlat(true);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ListManager::~ListManager()\r\n//-----------------------------------------------------------------------------\r\nListManager::~ListManager()\r\n{\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ListManager::items()\r\n//-----------------------------------------------------------------------------\r\nQStringList ListManager::items() const\r\n{\r\n    Q_ASSERT(model_);\r\n    if (model_)\r\n    {\r\n        return model_->items();\r\n    }\r\n\r\n    return QStringList();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ListManager::setItems()\r\n//-----------------------------------------------------------------------------\r\nvoid ListManager::setItems(QStringList const& items)\r\n{\r\n    Q_ASSERT(model_);\r\n    if (model_)\r\n    {\r\n        model_->setItems(items);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ListManager::size()\r\n//-----------------------------------------------------------------------------\r\nint ListManager::size() const\r\n{\r\n    Q_ASSERT(model_);\r\n    if (model_)\r\n    {\r\n        return model_->rowCount(QModelIndex());\r\n    }\r\n\r\n    return 0;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: listmanager::initialize()\r\n//-----------------------------------------------------------------------------\r\nvoid ListManager::initialize(QStringList const& items) \r\n{\r\n    // remove the previous model and view if there are one\r\n    if (model_)\r\n    {\r\n        delete model_;\r\n        model_ = 0;\r\n    }\r\n\r\n    if (view_)\r\n    {\r\n        delete view_;\r\n        view_ = 0;\r\n    }\r\n\r\n    // create new model and view\r\n    model_ = new ListManagerModel(items, this);\r\n    view_ = new EditableListView(this);\r\n\r\n    // the signals from the view\r\n    connect(view_, SIGNAL(removeItem(const QModelIndex&)),\r\n        model_, SLOT(remove(const QModelIndex&)), Qt::UniqueConnection);\r\n\r\n    connect(view_, SIGNAL(addItem(const QModelIndex&)),\r\n        model_, SLOT(addItem(const QModelIndex&)), Qt::UniqueConnection);\r\n\r\n    connect(view_, SIGNAL(moveItem(const QModelIndex&, const QModelIndex&)),\r\n        model_, SLOT(moveItem(const QModelIndex&, const QModelIndex&)), Qt::UniqueConnection);\r\n\r\n    // the signals from the model\r\n    connect(model_, SIGNAL(contentChanged()), this, SIGNAL(contentChanged()), Qt::UniqueConnection);\r\n\r\n    connect(model_, SIGNAL(dataChanged(const QModelIndex&, const QModelIndex&)),\r\n        this, SIGNAL(contentChanged()), Qt::UniqueConnection);\r\n\r\n    QLayout* topLayout = layout();\r\n\r\n    if (!topLayout)\r\n    {\r\n        topLayout = new QHBoxLayout(this);\r\n    }\r\n\r\n    // add the view on the left side\r\n    topLayout->addWidget(view_);\r\n\r\n    // connect the model to the view\r\n    view_->setModel(model_);\r\n    view_->setItemDelegate(new LineEditDelegate(this));\r\n}\r\n"
  },
  {
    "path": "common/widgets/listManager/listmanager.h",
    "content": "/* \r\n *\r\n *  Created on: 28.1.2011\r\n *      Author: Antti Kamppi\r\n * \t\tfilename: listmanager.h\r\n */\r\n\r\n#ifndef LISTMANAGER_H\r\n#define LISTMANAGER_H\r\n\r\n#include \"listmanagermodel.h\"\r\n\r\n#include <common/views/EditableListView/editablelistview.h>\r\n\r\n#include <QWidget>\r\n#include <QGroupBox>\r\n#include <QPushButton>\r\n#include <QObject>\r\n#include <QStringList>\r\n\r\n//-----------------------------------------------------------------------------\r\n//! ListManager is a widget to manage a list of strings.\r\n//-----------------------------------------------------------------------------\r\nclass ListManager : public QGroupBox \r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\r\n\t/*! The constructor.\r\n\t *\r\n\t *    @param [in] title   The title to be set for the QGroupBox\r\n\t *    @param [in] parent  The owner of this widget.\r\n\t */\r\n\tListManager(QString const& title = tr(\"List\"), QWidget *parent = 0);\r\n\r\n\t//! the destructor\r\n\tvirtual ~ListManager();\r\n\r\n\t/*! Initialize the list manager.\r\n\t *\r\n\t * This function must be called after creating the list manager and before using it.\r\n\t * \r\n\t *    @param [in] items QStringList that contains the items to add to the widget.\r\n\t */\r\n\tvirtual void initialize(const QStringList& items = QStringList());\r\n\r\n\t/*! Get the string items currently stored in the model.\r\n\t *\r\n\t *    @return QStringList that is contained in this widget.\r\n\t */\r\n\tQStringList items() const;\r\n\r\n\t/*! Set the items to be stored in this widget.\r\n\t *\r\n\t *    @param [in] items QStringList containing the strings to add.\r\n\t */\r\n\tvoid setItems(const QStringList& items);\r\n\r\n\t/*! Get the number of items stored in the list.\r\n\t *\r\n\t *    @return Number of items in the list.\r\n\t */\r\n\tint size() const;\r\n\r\nsignals:\r\n\t//! Emitted when contents of the ListManager change.\r\n\tvoid contentChanged();\r\n\r\nprotected:\r\n\r\n\t//! The model that contains the list of strings.\r\n\tListManagerModel* model_;\r\n\r\n\t//! The View to display the list of strings.\r\n\tEditableListView* view_;\r\n\r\nprivate:\r\n\r\n\t//! No copying\r\n\tListManager(const ListManager& other);\r\n\r\n\t//! No assignment\r\n\tListManager& operator=(const ListManager& other);\r\n\r\n};\r\n\r\n#endif // LISTMANAGER_H\r\n"
  },
  {
    "path": "common/widgets/listManager/listmanagermodel.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ListManagerModel.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 28.01.2012\r\n//\r\n// Description:\r\n// Model class for managing a list of strings.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"listmanagermodel.h\"\r\n\r\n#include <QVariant>\r\n\r\n#include <common/KactusColors.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: listmanagermodel::ListManagerModel()\r\n//-----------------------------------------------------------------------------\r\nListManagerModel::ListManagerModel(QStringList const& items, QObject *parent): \r\nQAbstractListModel(parent),\r\n    items_(items)\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: listmanagermodel::~ListManagerModel()\r\n//-----------------------------------------------------------------------------\r\nListManagerModel::~ListManagerModel()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: listmanagermodel::rowCount()\r\n//-----------------------------------------------------------------------------\r\nint ListManagerModel::rowCount(QModelIndex const& /*parent*/) const\r\n{\r\n    return items_.size();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: listmanagermodel::data()\r\n//-----------------------------------------------------------------------------\r\nQVariant ListManagerModel::data(QModelIndex const& index, int role) const\r\n{\r\n    // nothing for invalid indexes\r\n    if (index.isValid() == false || index.row() < 0 || index.row() >= items_.size())\r\n    {\r\n        return QVariant();\r\n    }\r\n\r\n    // return data for display role\r\n    if (role == Qt::DisplayRole || role == Qt::EditRole)\r\n    {\r\n        return items_.at(index.row());\r\n    }\r\n    // if unsupported role\r\n    else\r\n    {\r\n        return QVariant();\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: listmanagermodel::headerData()\r\n//-----------------------------------------------------------------------------\r\nQVariant ListManagerModel::headerData(int section, Qt::Orientation orientation, int role) const\r\n{\r\n    if (section == 0 && orientation == Qt::Horizontal && role == Qt::DisplayRole)\r\n    {\r\n        return tr(\"Items\");\r\n    }\r\n    else\r\n    {\r\n        return QVariant();\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: listmanagermodel::setData()\r\n//-----------------------------------------------------------------------------\r\nbool ListManagerModel::setData(QModelIndex const& index, QVariant const& value, int role)\r\n{\r\n    if (index.isValid() == false || index.row() < 0 || index.row() >= items_.size() || index.column() != 0)\r\n    {\r\n        return false;\r\n    }\r\n\r\n    if (role == Qt::EditRole)\r\n    {\r\n        items_[index.row()] = value.toString();\r\n\r\n        emit dataChanged(index, index);\r\n        return true;\r\n    }\r\n\r\n    // unsupported role\r\n    else\r\n    {\r\n        return false;\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: listmanagermodel::flags()\r\n//-----------------------------------------------------------------------------\r\nQt::ItemFlags ListManagerModel::flags( QModelIndex const& index ) const\r\n{\r\n    if (index.isValid() == false)\r\n    {\r\n        return Qt::NoItemFlags;\r\n    }\r\n\r\n    return Qt::ItemIsEditable | Qt::ItemIsEnabled | Qt::ItemIsSelectable;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: listmanagermodel::appendItem()\r\n//-----------------------------------------------------------------------------\r\nvoid ListManagerModel::appendItem(QString const& item)\r\n{\r\n    beginInsertRows(QModelIndex(), items_.size(), items_.size());\r\n    items_.append(item);\r\n    endInsertRows();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: listmanagermodel::addItem()\r\n//-----------------------------------------------------------------------------\r\nvoid ListManagerModel::addItem(QModelIndex const& index)\r\n{\r\n    int row = items_.size();\r\n    \r\n    // if the index is valid then add the item to the correct position\r\n    if (index.isValid())\r\n    {\r\n        row = index.row();\r\n    }\r\n\r\n    beginInsertRows(QModelIndex(), row, row);\r\n    items_.insert(row, QString(\"new item\"));\r\n    endInsertRows();\r\n    emit contentChanged();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: listmanagermodel::items()\r\n//-----------------------------------------------------------------------------\r\nconst QStringList& ListManagerModel::items() const\r\n{\r\n    return items_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: listmanagermodel::setItems()\r\n//-----------------------------------------------------------------------------\r\nvoid ListManagerModel::setItems(QStringList const& items)\r\n{\r\n    beginResetModel();\r\n    items_ = items;\r\n    endResetModel();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: listmanagermodel::remove()\r\n//-----------------------------------------------------------------------------\r\nvoid ListManagerModel::remove(QModelIndex const& index)\r\n{\r\n    // don't remove anything if index is invalid\r\n    if (!index.isValid() || index.row() < 0 || index.row() >= items_.size())\r\n    {\r\n        return;\r\n    }\r\n\r\n    // remove the specified item\r\n    beginRemoveRows(QModelIndex(), index.row(), index.row());\r\n    items_.removeAt(index.row());\r\n    endRemoveRows();\r\n    emit contentChanged();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: listmanagermodel::moveItem()\r\n//-----------------------------------------------------------------------------\r\nvoid ListManagerModel::moveItem(QModelIndex const& originalPos, QModelIndex const& newPos)\r\n{\r\n    if (originalPos.isValid() == false || originalPos == newPos || \r\n        originalPos.row() < 0 || originalPos.row() >= items_.size())\r\n    {\r\n        return;\r\n    }\r\n\r\n    // if the new position is invalid index then put the item last in the list\r\n    if (newPos.isValid() == false || newPos.row() < 0 || newPos.row() >= items_.size())\r\n    {\r\n        beginResetModel();\r\n        QString value = items_.takeAt(originalPos.row());\r\n        items_.append(value);\r\n        endResetModel();\r\n    }\r\n    // if both indexes were valid\r\n    else\r\n    {\r\n        beginResetModel();\r\n        items_.swapItemsAt(originalPos.row(), newPos.row());\r\n        endResetModel();\r\n    }\r\n    emit contentChanged();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: listmanagermodel::replace()\r\n//-----------------------------------------------------------------------------\r\nvoid ListManagerModel::replace(QModelIndex& index, const QString newText)\r\n{\r\n    if (index.isValid() == false || index.row() < 0 || index.row() >= items_.size())\r\n    {\r\n        return;\r\n    }\r\n\r\n    items_.replace(index.row(), newText);\r\n    emit dataChanged(index, index);\r\n}\r\n"
  },
  {
    "path": "common/widgets/listManager/listmanagermodel.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ListManagerModel.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 28.01.2012\r\n//\r\n// Description:\r\n// Model class for managing a list of strings.\r\n//----------------------------------------------------------------------------- \r\n\r\n#ifndef LISTMANAGERMODEL_H\r\n#define LISTMANAGERMODEL_H\r\n\r\n#include <QObject>\r\n#include <QAbstractListModel>\r\n#include <QVariant>\r\n#include <QStringList>\r\n#include <QModelIndex>\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Model class for managing a list of strings.\r\n//-----------------------------------------------------------------------------\r\nclass ListManagerModel : public QAbstractListModel\r\n{\r\n    Q_OBJECT\r\n\r\npublic:\r\n\r\n    /*!\r\n     *  The constructor.\r\n     *     \r\n     *    @param [in] items   QStringList that contains the items to add.\r\n     *    @param [in] parent  The owner of this model.\r\n     */\r\n    ListManagerModel(QStringList const& items = QStringList(), QObject *parent = 0);\r\n\r\n    /*!\r\n     *  The destructor.\r\n     */\r\n    virtual ~ListManagerModel();\r\n\r\n    /*!\r\n     *  Get the number of rows in this model.\r\n     *\r\n     *    @param [in] parent  ModelIndex of the item that's rowCount is requested.\r\n     */\r\n    virtual int rowCount(QModelIndex const& parent = QModelIndex()) const;\r\n\r\n    /*!\r\n     *  Get the data stored for the specified item.\r\n     *\r\n     *    @param [in] index   ModelIndex of the wanted item.\r\n     *    @param [in] role    Specifies what kind of data is requested.\r\n     */\r\n    virtual QVariant data(QModelIndex const& index, int role = Qt::DisplayRole) const;\r\n\r\n    /*!\r\n     *  Get the data for the header of the list.\r\n     *\r\n     *    @param [in] section         Specifies the column for which the header is requested.\r\n     *    @param [in] orientation     The orientation of the header, only Qt::Horizontal is supported.\r\n     *    @param [in] role            Specifies what kind of header data is requested.\r\n     */\r\n    virtual QVariant headerData(int section, Qt::Orientation orientation,  int role = Qt::DisplayRole) const;\r\n\r\n    /*!\r\n     *  Save the data to the model for specified item.\r\n     *\r\n     *    @param [in] index   The model index of the item that's data is to be saved.\r\n     *    @param [in] value   The data that is to be saved.\r\n     *    @param [in] role    The role specifies what kind of data should be saved.\r\n     *\r\n     *    @return True if saving happened successfully.\r\n     */\r\n    virtual bool setData(QModelIndex const& index, QVariant const& value, int role = Qt::EditRole);\r\n\r\n    /*!\r\n     *  Get the item flags that defines the possible operations for the item.\r\n     *\r\n     *    @param [in] index   Model index that identifies the item.\r\n     *\r\n     *    @return Qt::ItemFlags specify the possible operations for the item.\r\n     */\r\n    virtual Qt::ItemFlags flags(QModelIndex const& index) const;\r\n\r\n    /*!\r\n     *  Append a new item to the end of the list.\r\n     *\r\n     *    @param [in] item    The string to be appended to the end of the list.\r\n     */\r\n    virtual void appendItem(QString const& item);\r\n\r\n    /*!\r\n     *  Get the items currently stored in the model.\r\n     *\r\n     *    @return QStringList containing the items.\r\n     */\r\n    virtual QStringList const& items() const;\r\n\r\n    /*!\r\n     *  Set the items to the model.\r\n     *\r\n     *    @param [in] items   QStringList containing the items to be contained in the model.\r\n     */\r\n    virtual void setItems(const QStringList& items);\r\n\r\n    /*!\r\n     *  Replace an item text in the list.\r\n     * \r\n     *    @param [in] index       ModelIndex of the item that is to be replaced.\r\n     *    @param [in] newText     The new text for the given item.\r\n     */\r\n    virtual void replace(QModelIndex& index, const QString newText);\r\n\r\npublic slots:\r\n     \r\n    /*!\r\n     *  Removes the specified item from the model.\r\n     *\r\n     *    @param [in] index   The model index of the item to remove.\r\n     */\r\n    virtual void remove(QModelIndex const& index);\r\n\r\n    /*!\r\n     *  A new item should be added to given index.\r\n     *\r\n     *    @param [in] index   The position where new item should be added at.\r\n     */\r\n    virtual void addItem(QModelIndex const& index);\r\n\r\n    /*!\r\n     *  Move item to another position.\r\n     *\r\n     *    @param [in] originalPos     Identifies the item that should be moved.\r\n     *    @param [in] newPos          The new position the item should be moved to.\r\n     */\r\n    virtual void moveItem(QModelIndex const& originalPos, QModelIndex const& newPos);\r\n\r\nsignals: \r\n\r\n    /*!\r\n     *  Emitted when contents of the model change.\r\n     */\r\n    void contentChanged();\r\n\r\nprotected:\r\n\r\n    /*!\r\n     *  Contains the items to be displayed in a list.\r\n     */\r\n    QStringList items_;\r\n\r\nprivate:\r\n\r\n    //! No copying. No assignment.\r\n    ListManagerModel(const ListManagerModel& other);\r\n    ListManagerModel& operator=(const ListManagerModel& other);\r\n};\r\n\r\n#endif // LISTMANAGERMODEL_H\r\n"
  },
  {
    "path": "common/widgets/modWriteComboBox/modwritecombobox.cpp",
    "content": "/* \r\n *  \tCreated on: 27.8.2012\r\n *      Author: Antti Kamppi\r\n * \t\tfilename: modwritecombobox.cpp\r\n *\t\tProject: Kactus 2\r\n */\r\n\r\n#include \"modwritecombobox.h\"\r\n\r\nModWriteComboBox::ModWriteComboBox(QWidget *parent):\r\nQComboBox(parent) {\r\n\r\n\tsetEditable(false);\r\n\r\n\tfor (unsigned int i = 0; i <= General::MODIFIED_WRITE_COUNT; ++i) {\r\n\t\taddItem(General::MODIFIED_WRITE_STRINGS[i]);\r\n\t}\r\n}\r\n\r\nModWriteComboBox::~ModWriteComboBox() {\r\n}\r\n\r\nGeneral::ModifiedWrite ModWriteComboBox::getCurrentValue() const {\r\n\treturn static_cast<General::ModifiedWrite>(currentIndex());\r\n}\r\n\r\nvoid ModWriteComboBox::setCurrentValue( General::ModifiedWrite modWriteValue ) {\r\n\tsetCurrentIndex(modWriteValue);\r\n}\r\n"
  },
  {
    "path": "common/widgets/modWriteComboBox/modwritecombobox.h",
    "content": "/* \r\n *  \tCreated on: 27.8.2012\r\n *      Author: Antti Kamppi\r\n * \t\tfilename: modwritecombobox.h\r\n *\t\tProject: Kactus 2\r\n */\r\n\r\n#ifndef MODWRITECOMBOBOX_H\r\n#define MODWRITECOMBOBOX_H\r\n\r\n#include <IPXACTmodels/generaldeclarations.h>\r\n\r\n#include <QComboBox>\r\n\r\n/*! \\brief The combo box to select one of the defined modified write values.\r\n *\r\n */\r\nclass ModWriteComboBox : public QComboBox {\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\r\n\t/*! \\brief The constructor\r\n\t *\r\n\t * \\param parent Pointer to the owner of the combo box.\r\n\t *\r\n\t*/\r\n\tModWriteComboBox(QWidget *parent);\r\n\r\n\t//! \\brief The destructor\r\n\tvirtual ~ModWriteComboBox();\r\n\r\n\t/*! \\brief Get the currently selected modified write value.\r\n\t *\r\n\t * \\return The currently selected value.\r\n\t*/\r\n\tGeneral::ModifiedWrite getCurrentValue() const;\r\n\r\n\t/*! \\brief Set the currently selected value.\r\n\t *\r\n\t * \\param modWriteValue The value to select in the combo box.\r\n\t *\r\n\t*/\r\n\tvoid setCurrentValue(General::ModifiedWrite modWriteValue);\r\n\r\nprivate:\r\n\t\r\n\t//! \\brief No copying\r\n\tModWriteComboBox(const ModWriteComboBox& other);\r\n\r\n\t//! \\brief No assignment\r\n\tModWriteComboBox& operator=(const ModWriteComboBox& other);\r\n};\r\n\r\n#endif // MODWRITECOMBOBOX_H\r\n"
  },
  {
    "path": "common/widgets/nameGroupBox/NameGroupBoxPlugin/namegroupboxPlugin.pro",
    "content": "TEMPLATE = lib\r\nHEADERS = ../namegroupbox.h \\\r\n    namegroupboxplugin.h\r\nSOURCES = ../namegroupbox.cpp \\\r\n    namegroupboxplugin.cpp\r\nTARGET = namegroupbox\r\n\r\nCONFIG      += designer plugin\r\nDESTDIR = $$[QT_INSTALL_PLUGINS]/designer\r\n\r\nINCLUDEPATH += ../../../../\r\n"
  },
  {
    "path": "common/widgets/nameGroupBox/NameGroupBoxPlugin/namegroupboxplugin.cpp",
    "content": "#include \"../namegroupbox.h\"\r\n#include \"namegroupboxplugin.h\"\r\n\r\n#include <QtCore/QtPlugin>\r\n\r\nNameGroupBoxPlugin::NameGroupBoxPlugin(QObject *parent)\r\n    : QObject(parent)\r\n{\r\n    m_initialized = false;\r\n}\r\n\r\nvoid NameGroupBoxPlugin::initialize(QDesignerFormEditorInterface * /* core */)\r\n{\r\n    if (m_initialized)\r\n        return;\r\n\r\n    // Add extension registrations, etc. here\r\n\r\n    m_initialized = true;\r\n}\r\n\r\nbool NameGroupBoxPlugin::isInitialized() const\r\n{\r\n    return m_initialized;\r\n}\r\n\r\nQWidget *NameGroupBoxPlugin::createWidget(QWidget *parent)\r\n{\r\n    return new NameGroupBox(parent);\r\n}\r\n\r\nQString NameGroupBoxPlugin::name() const\r\n{\r\n    return QLatin1String(\"NameGroupBox\");\r\n}\r\n\r\nQString NameGroupBoxPlugin::group() const\r\n{\r\n    return QLatin1String(\"IP-Xact widgets\");\r\n}\r\n\r\nQIcon NameGroupBoxPlugin::icon() const\r\n{\r\n    return QIcon();\r\n}\r\n\r\nQString NameGroupBoxPlugin::toolTip() const\r\n{\r\n    return QLatin1String(\"Element to edit spirit:nameGroup element\");\r\n}\r\n\r\nQString NameGroupBoxPlugin::whatsThis() const\r\n{\r\n    return QLatin1String(\"This widget provides means to edit/create spirit:nameGroup element in IP-Xact\");\r\n}\r\n\r\nbool NameGroupBoxPlugin::isContainer() const\r\n{\r\n    return false;\r\n}\r\n\r\nQString NameGroupBoxPlugin::domXml() const\r\n{\r\n    return QLatin1String(\"<widget class=\\\"NameGroupBox\\\" name=\\\"nameGroupBox\\\">\\n</widget>\\n\");\r\n}\r\n\r\nQString NameGroupBoxPlugin::includeFile() const\r\n{\r\n    return QLatin1String(\"namegroupbox.h\");\r\n}\r\n\r\nQ_EXPORT_PLUGIN2(namegroupboxplugin, NameGroupBoxPlugin)\r\n"
  },
  {
    "path": "common/widgets/nameGroupBox/NameGroupBoxPlugin/namegroupboxplugin.h",
    "content": "#ifndef NAMEGROUPBOXPLUGIN_H\r\n#define NAMEGROUPBOXPLUGIN_H\r\n\r\n#include <QDesignerCustomWidgetInterface>\r\n\r\nclass NameGroupBoxPlugin : public QObject, public QDesignerCustomWidgetInterface\r\n{\r\n    Q_OBJECT\r\n    Q_INTERFACES(QDesignerCustomWidgetInterface)\r\n\r\npublic:\r\n    NameGroupBoxPlugin(QObject *parent = 0);\r\n\r\n    bool isContainer() const;\r\n    bool isInitialized() const;\r\n    QIcon icon() const;\r\n    QString domXml() const;\r\n    QString group() const;\r\n    QString includeFile() const;\r\n    QString name() const;\r\n    QString toolTip() const;\r\n    QString whatsThis() const;\r\n    QWidget *createWidget(QWidget *parent);\r\n    void initialize(QDesignerFormEditorInterface *core);\r\n\r\nprivate:\r\n    bool m_initialized;\r\n};\r\n\r\n#endif\r\n"
  },
  {
    "path": "common/widgets/nameGroupBox/namegroupbox.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: NameGroupBox.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Antti Kamppi\r\n// Date: 16.01.2011\r\n//\r\n// Description:\r\n// This class provides 3 GUI items to set a name, displayName and description for an element in IP-Xact.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"namegroupbox.h\"\r\n\r\n#include <IPXACTmodels/common/validators/namevalidator.h>\r\n\r\n#include <QSizePolicy>\r\n#include <QLabel>\r\n#include <QGridLayout>\r\n#include <QValidator>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: namegroupbox::NameGroupBox()\r\n//-----------------------------------------------------------------------------\r\nNameGroupBox::NameGroupBox(QWidget* parent, const QString& title): \r\nQGroupBox(title, parent),\r\nnameEdit_(0),\r\ndisplayNameEdit_(0),\r\ndescriptionEdit_(0)\r\n{\r\n\t// set the size policy for the widget\r\n\tsetSizePolicy(QSizePolicy::Preferred, QSizePolicy::Maximum);\r\n\r\n\t// set the maximum height for the widget\r\n    setMaximumHeight(130);\r\n\r\n\t// the layout manager for this widget\r\n\tQGridLayout* layout = new QGridLayout(this);\r\n\r\n\tQLabel* nameLabel = new QLabel(tr(\"Name:\"), this);\r\n\tlayout->addWidget(nameLabel, 0, 0, 1, 1);\r\n\r\n\tnameEdit_ = new QLineEdit(this);\r\n\tnameEdit_->setToolTip(tr(\"Set the name for the element\"));\r\n\tnameEdit_->setProperty(\"mandatoryField\", true);\r\n\r\n\tNameValidator* validator = new NameValidator(nameEdit_);\r\n\tnameEdit_->setValidator(validator);\r\n\tlayout->addWidget(nameEdit_, 0, 1, 1, 1);\r\n\r\n\tQLabel* displayLabel = new QLabel(tr(\"Display Name:\"), this);\r\n\tlayout->addWidget(displayLabel, 1, 0, 1, 1);\r\n\r\n\tdisplayNameEdit_ = new QLineEdit(this);\r\n\tdisplayNameEdit_->setToolTip(tr(\"Set the display name for the element\"));\r\n\tlayout->addWidget(displayNameEdit_, 1, 1, 1, 1);\r\n\r\n\tQLabel* descriptionLabel = new QLabel(tr(\"Description:\"), this);\r\n    layout->addWidget(descriptionLabel, 2, 0, 1, 1, Qt::AlignTop);\r\n\r\n\tdescriptionEdit_ = new QPlainTextEdit(this);\r\n\tdescriptionEdit_->setToolTip(tr(\"Set the description for the element\"));\r\n    layout->addWidget(descriptionEdit_, 2, 1, 1, 1);\r\n\r\n\t// connect the signals that inform of changes made to items\r\n    connect(nameEdit_, SIGNAL(editingFinished()), this, SIGNAL(contentChanged()), Qt::UniqueConnection);\r\n    connect(nameEdit_, SIGNAL(editingFinished()), this, SIGNAL(nameChanged()), Qt::UniqueConnection);\r\n\r\n    connect(displayNameEdit_, SIGNAL(editingFinished()), this, SIGNAL(contentChanged()), Qt::UniqueConnection);\r\n    connect(displayNameEdit_, SIGNAL(editingFinished()), this, SIGNAL(displayNameChanged()), Qt::UniqueConnection);\r\n\r\n    connect(descriptionEdit_, SIGNAL(textChanged()), this, SIGNAL(contentChanged()), Qt::UniqueConnection);\r\n    connect(descriptionEdit_, SIGNAL(textChanged()), this, SIGNAL(descriptionChanged()), Qt::UniqueConnection);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: namegroupbox::~NameGroupBox()\r\n//-----------------------------------------------------------------------------\r\nNameGroupBox::~NameGroupBox()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: namegroupbox::name()\r\n//-----------------------------------------------------------------------------\r\nQString NameGroupBox::name() const\r\n{\r\n\treturn nameEdit_->text();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: namegroupbox::displayName()\r\n//-----------------------------------------------------------------------------\r\nQString NameGroupBox::displayName() const\r\n{\r\n\treturn displayNameEdit_->text();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: namegroupbox::description()\r\n//-----------------------------------------------------------------------------\r\nQString NameGroupBox::description() const\r\n{\r\n\treturn descriptionEdit_->toPlainText();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: namegroupbox::isValid()\r\n//-----------------------------------------------------------------------------\r\nbool NameGroupBox::isValid() const\r\n{\r\n\treturn !nameEdit_->text().isEmpty();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: namegroupbox::setName()\r\n//-----------------------------------------------------------------------------\r\nvoid NameGroupBox::setName( const QString& name )\r\n{\r\n\tnameEdit_->setText(name);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: namegroupbox::setDisplayName()\r\n//-----------------------------------------------------------------------------\r\nvoid NameGroupBox::setDisplayName( const QString& displayName )\r\n{\r\n\tdisplayNameEdit_->setText(displayName);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: namegroupbox::setDescription()\r\n//-----------------------------------------------------------------------------\r\nvoid NameGroupBox::setDescription( const QString& description )\r\n{\r\n\tdescriptionEdit_->setPlainText(description);\r\n}\r\n"
  },
  {
    "path": "common/widgets/nameGroupBox/namegroupbox.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: NameGroupBox.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Antti Kamppi\r\n// Date: 16.01.2011\r\n//\r\n// Description:\r\n// This class provides 3 GUI items to set a name, displayName and description for an element in IP-Xact.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef NAMEGROUPBOX_H_\r\n#define NAMEGROUPBOX_H_\r\n\r\n#include <QWidget>\r\n#include <QGroupBox>\r\n#include <QLineEdit>\r\n#include <QPlainTextEdit>\r\n#include <QString>\r\n#include <QValidator>\r\n\r\n//-----------------------------------------------------------------------------\r\n//! This class provides 3 GUI items to set a name, displayName and description for an element in IP-Xact.\r\n//-----------------------------------------------------------------------------\r\nclass NameGroupBox: public QGroupBox\r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\r\n\t/*!\r\n     *  The constructor.\r\n\t *\r\n\t *    @param [in] parent  Pointer to the owner of this widget.\r\n\t */\r\n\tNameGroupBox(QWidget* parent = 0, const QString& title = QString(\"Names\"));\r\n\r\n\t//! The destructor.\r\n\tvirtual ~NameGroupBox();\r\n\r\n\t/*!\r\n     *  Get the value of the name-field.\r\n\t *\r\n\t *    @return QString containing the name.\r\n\t */\r\n\tQString name() const;\r\n\r\n\t/*!\r\n     *  Get the value of the displayName-field.\r\n\t *\r\n\t *    @return QString containing the displayName.\r\n\t */\r\n\tQString displayName() const;\r\n\r\n\t/*!\r\n     *  Get the value of the description-field.\r\n\t *\r\n\t *    @return QString containing the description.\r\n\t */\r\n\tQString description() const;\r\n\r\n\t/*!\r\n     *  Check if the widget is in valid mode.\r\n\t *\r\n     *  This function checks that name-field is not empty and does not contain string with embedded whitespace \r\n     *  characters.\r\n\t *\r\n\t *    @return True if everything is ok.\r\n\t */\r\n\tbool isValid() const;\r\n\r\npublic slots:\r\n\r\n\t/*!\r\n     *  Set the value for the name-field.\r\n     *\r\n     *    @param [in] name    QString containing the name.\r\n\t */\r\n\tvoid setName(const QString& name);\r\n\r\n\t/*!\r\n     *  Set the value for the displayName-field.\r\n\t *\r\n\t *    @param [in] displayName     QString containing the displayName.\r\n\t */\r\n\tvoid setDisplayName(const QString& displayName);\r\n\r\n\t/*!\r\n     *  Set the value for the description-field.\r\n     *\r\n     *    @param [in] description     QString containing the description.\r\n\t */\r\n\tvoid setDescription(const QString& description);\r\n\r\nsignals:\r\n\r\n\t//! Emitted when contents of the widget change.\r\n\tvoid contentChanged();\r\n\r\n\t/*!\r\n     *  Emitted when the name-field changes.\r\n\t */\r\n    void nameChanged();\r\n\r\n\t/*!\r\n     *  Emitted when the display name-field changes.\r\n\t */\r\n    void displayNameChanged();\r\n\r\n\t/*!\r\n     *  Emitted when the description-field changes.\r\n\t */\r\n    void descriptionChanged();\r\n\r\nprivate:\r\n\r\n\t//! No copying\r\n\tNameGroupBox(const NameGroupBox& other);\r\n\r\n\t//! No assignment\r\n\tNameGroupBox& operator=(const NameGroupBox& other);\r\n\r\n\t//! Line edit to set the name.\r\n\tQLineEdit* nameEdit_;\r\n\r\n\t//! Line edit to set the displayName.\r\n\tQLineEdit* displayNameEdit_;\r\n\r\n\t//! Editor to write the description.\r\n\tQPlainTextEdit* descriptionEdit_;\r\n};\r\n\r\n#endif /* NAMEGROUPBOX_H_ */\r\n"
  },
  {
    "path": "common/widgets/nameGroupEditor/namegroupeditor.cpp",
    "content": "/* \r\n *  \tCreated on: 28.5.2012\r\n *      Author: Antti Kamppi\r\n * \t\tfilename: namegroupeditor.cpp\r\n *\t\tProject: Kactus 2\r\n */\r\n\r\n#include \"namegroupeditor.h\"\r\n#include <IPXACTmodels/common/validators/namevalidator.h>\r\n\r\n#include <QLabel>\r\n#include <QGridLayout>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: NameGroupEditor::NameGroupEditor()\r\n//-----------------------------------------------------------------------------\r\nNameGroupEditor::NameGroupEditor(QSharedPointer<NameGroup> nameGroup, Document::Revision docRevision,\r\n    QWidget* parent, QString const& title) :\r\nQGroupBox(title, parent),\r\n    nameGroup_(nameGroup),\r\n    nameEdit_(this),\r\n    displayNameEdit_(this),\r\n    shortDescriptionEdit_(this),\r\n    descriptionEdit_(this)\r\n{\r\n    setFlat(true);\r\n\r\n    descriptionEdit_.setTabChangesFocus(true);\r\n\r\n    shortDescriptionEdit_.setVisible(docRevision == Document::Revision::Std22);\r\n    setupLayout(docRevision);\r\n\r\n    connect(&nameEdit_, SIGNAL(textEdited(QString const&)),\r\n        this, SLOT(onNameChanged(QString const&)), Qt::UniqueConnection);\r\n    connect(&nameEdit_, SIGNAL(editingFinished()), this, SIGNAL(nameChanged()), Qt::UniqueConnection);\r\n    connect(&displayNameEdit_, SIGNAL(textEdited(QString const&)),\r\n        this, SLOT(onDisplayNameChanged(QString const&)), Qt::UniqueConnection);\r\n    connect(&shortDescriptionEdit_, SIGNAL(textEdited(QString const&)),\r\n            this, SLOT(onShortDescriptionChanged(QString const&)), Qt::UniqueConnection);\r\n    connect(&descriptionEdit_, SIGNAL(textChanged()),\r\n        this, SLOT(onDescriptionChanged()), Qt::UniqueConnection);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: NameGroupEditor::~NameGroupEditor()\r\n//-----------------------------------------------------------------------------\r\nNameGroupEditor::~NameGroupEditor()\r\n{\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: NameGroupEditor::name()\r\n//-----------------------------------------------------------------------------\r\nQString NameGroupEditor::name() const\r\n{\r\n\treturn nameGroup_->name();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: NameGroupEditor::displayName()\r\n//-----------------------------------------------------------------------------\r\nQString NameGroupEditor::displayName() const\r\n{\r\n\treturn nameGroup_->displayName();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: NameGroupEditor::description()\r\n//-----------------------------------------------------------------------------\r\nQString NameGroupEditor::description() const\r\n{\r\n\treturn nameGroup_->description();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: NameGroupEditor::onNameChanged()\r\n//-----------------------------------------------------------------------------\r\nvoid NameGroupEditor::onNameChanged(QString const& newName )\r\n{\r\n\tnameGroup_->setName(newName);\r\n\temit contentChanged();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: NameGroupEditor::onDisplayNameChanged()\r\n//-----------------------------------------------------------------------------\r\nvoid NameGroupEditor::onDisplayNameChanged(QString const& newDisplayName )\r\n{\r\n\tnameGroup_->setDisplayName(newDisplayName);\r\n\temit contentChanged();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: NameGroupEditor::onShortDescriptionChanged()\r\n//-----------------------------------------------------------------------------\r\nvoid NameGroupEditor::onShortDescriptionChanged(QString const& newShortDescription)\r\n{\r\n    nameGroup_->setShortDescription(newShortDescription);\r\n    emit contentChanged();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: NameGroupEditor::onDescriptionChanged()\r\n//-----------------------------------------------------------------------------\r\nvoid NameGroupEditor::onDescriptionChanged()\r\n{\r\n\tnameGroup_->setDescription(descriptionEdit_.toPlainText());\r\n\temit contentChanged();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: NameGroupEditor::isValid()\r\n//-----------------------------------------------------------------------------\r\nbool NameGroupEditor::isValid() const\r\n{\r\n\treturn !nameGroup_->name().isEmpty();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: NameGroupEditor::refresh()\r\n//-----------------------------------------------------------------------------\r\nvoid NameGroupEditor::refresh()\r\n{\r\n\tnameEdit_.setText(nameGroup_->name());\r\n\tdisplayNameEdit_.setText(nameGroup_->displayName());\r\n    \r\n    disconnect(&shortDescriptionEdit_, SIGNAL(textEdited(QString const&)), \r\n        this, SLOT(onShortDescriptionChanged(QString const&)));\r\n    shortDescriptionEdit_.setText(nameGroup_->shortDescription());\r\n    connect(&shortDescriptionEdit_, SIGNAL(textEdited(QString const&)),\r\n        this, SLOT(onShortDescriptionChanged(QString const&)), Qt::UniqueConnection);\r\n\t\r\n\tdisconnect(&descriptionEdit_, SIGNAL(textChanged()), this, SLOT(onDescriptionChanged()));\r\n\tdescriptionEdit_.setPlainText(nameGroup_->description());\r\n\tconnect(&descriptionEdit_, SIGNAL(textChanged()), this, SLOT(onDescriptionChanged()), Qt::UniqueConnection);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: NameGroupEditor::setupLayout()\r\n//-----------------------------------------------------------------------------\r\nvoid NameGroupEditor::setupLayout(Document::Revision docRevision)\r\n{\r\n    // the layout manager for this widget\r\n    QGridLayout* layout = new QGridLayout(this);\r\n\r\n    QLabel* nameLabel = new QLabel(tr(\"Name:\"), this);\r\n    layout->addWidget(nameLabel, 0, 0, 1, 1);\r\n\r\n    nameEdit_.setToolTip(tr(\"Set the name for the element\"));\r\n    nameEdit_.setProperty(\"mandatoryField\", true);\r\n\r\n    NameValidator* validator = new NameValidator(&nameEdit_);\r\n    nameEdit_.setValidator(validator);\r\n    layout->addWidget(&nameEdit_, 0, 1, 1, 1);\r\n\r\n    QLabel* displayLabel = new QLabel(tr(\"Display Name:\"), this);\r\n    layout->addWidget(displayLabel, 1, 0, 1, 1);\r\n\r\n    displayNameEdit_.setToolTip(tr(\"Set the display name for the element\"));\r\n    layout->addWidget(&displayNameEdit_, 1, 1, 1, 1);\r\n\r\n    if (docRevision == Document::Revision::Std22)\r\n    {\r\n        QLabel* shortDescriptionLabel = new QLabel(tr(\"Short Description:\"), this);\r\n        layout->addWidget(shortDescriptionLabel, 2, 0, 1, 1);\r\n\r\n        shortDescriptionEdit_.setToolTip(tr(\"Set the short description for the element\"));\r\n        layout->addWidget(&shortDescriptionEdit_, 2, 1, 1, 1);\r\n    }\r\n\r\n    QLabel* descriptionLabel = new QLabel(tr(\"Description:\"), this);\r\n    layout->addWidget(descriptionLabel, 3, 0, 1, 1, Qt::AlignTop);\r\n\r\n    descriptionEdit_.setToolTip(tr(\"Set the description for the element\"));\r\n    layout->addWidget(&descriptionEdit_, 3, 1, 1, 1);\r\n    layout->setRowStretch(3,1);\r\n}\r\n"
  },
  {
    "path": "common/widgets/nameGroupEditor/namegroupeditor.h",
    "content": "/* \r\n *  \tCreated on: 28.5.2012\r\n *      Author: Antti Kamppi\r\n * \t\tfilename: namegroupeditor.h\r\n *\t\tProject: Kactus 2\r\n */\r\n\r\n#ifndef NAMEGROUPEDITOR_H\r\n#define NAMEGROUPEDITOR_H\r\n\r\n#include <IPXACTmodels/common/NameGroup.h>\r\n#include <IPXACTmodels/common/Document.h>\r\n\r\n#include <QGroupBox>\r\n#include <QLineEdit>\r\n#include <QPlainTextEdit>\r\n#include <QString>\r\n\r\n/*! Editor to edit the details of a NameGroup-struct.\r\n *\r\n */\r\nclass NameGroupEditor : public QGroupBox {\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\r\n\t//! The maximum height for the editor\r\n\tconst int MAX_EDITOR_HEIGHT = 130;\r\n\r\n    NameGroupEditor(QSharedPointer<NameGroup> nameGroup,\r\n\t\tDocument::Revision docRevision,\r\n        QWidget *parent,\r\n        QString const& title = QString(\"Names\"));\r\n\r\n\t//! The destructor\r\n\tvirtual ~NameGroupEditor();\r\n\r\n\t//! No copying\r\n\tNameGroupEditor(const NameGroupEditor& other) = delete;\r\n\t//! No assignment\r\n\tNameGroupEditor& operator=(const NameGroupEditor& other) = delete;\r\n\r\n\t/*! Get the name of the name group.\r\n\t *\r\n\t * \\return The contents of the name field.\r\n\t*/\r\n\tQString name() const;\r\n\r\n\t/*! Get the display name of the name group.\r\n\t *\r\n\t * \\return The contents of the display name field.\r\n\t*/\r\n\tQString displayName() const;\r\n\r\n\t/*! Get the description of the name group.\r\n\t *\r\n\t * \\return The contents of the description field.\r\n\t*/\r\n\tQString description() const;\r\n\r\n\t/*! Check if the editor is in valid state.\r\n\t *\r\n\t * \\return True if the name-field is not empty.\r\n\t*/\r\n\tbool isValid() const;\r\n\r\npublic slots:\r\n\r\n\t/*! Refresh the edit fields.\r\n\t *\r\n\t*/\r\n\tvoid refresh();\r\n\r\nsignals:\r\n\r\n\t//! Emitted when user edits one of the fields.\r\n\tvoid contentChanged();\r\n\r\n    /*!\r\n     *  Informs of change in name.\r\n     */\r\n    void nameChanged();\r\n\r\nprivate slots:\r\n\r\n\t/*! Handler for editing of the name field.\r\n\t *\r\n\t * \\param newName The new name for the name group.\r\n\t *\r\n\t*/\r\n\tvoid onNameChanged(QString const& newName);\r\n\r\n\t/*! Handler for editing of the display name field.\r\n\t *\r\n\t * \\param newName The new display name for the name group.\r\n\t *\r\n\t*/\r\n\tvoid onDisplayNameChanged(QString const& newDisplayName);\r\n\r\n\t/*! Handler for editing of the description field.\r\n\t *\r\n\t*/\r\n\tvoid onShortDescriptionChanged(QString const& newShortDescription);\r\n\r\n\t/*! Handler for editing of the description field.\r\n\t *\r\n\t*/\r\n\tvoid onDescriptionChanged();\r\n\r\nprivate:\r\n\t//! Setup the widget layout.\r\n    void setupLayout(Document::Revision docRevision);\r\n\r\n\t//! The name group to edit.\r\n\tQSharedPointer<NameGroup> nameGroup_;\r\n\r\n\t//! Line edit to set the name.\r\n\tQLineEdit nameEdit_;\r\n\r\n\t//! Line edit to set the displayName.\r\n\tQLineEdit displayNameEdit_;\r\n\r\n\t//! Line edit to set the displayName.\r\n\tQLineEdit shortDescriptionEdit_;\r\n\r\n\t//! Editor to write the description.\r\n\tQPlainTextEdit descriptionEdit_;\r\n};\r\n\r\n#endif // NAMEGROUPEDITOR_H\r\n"
  },
  {
    "path": "common/widgets/readActionComboBox/readactioncombobox.cpp",
    "content": "/* \r\n *  \tCreated on: 27.8.2012\r\n *      Author: Antti Kamppi\r\n * \t\tfilename: readactioncombobox.cpp\r\n *\t\tProject: Kactus 2\r\n */\r\n\r\n#include \"readactioncombobox.h\"\r\n\r\nReadActionComboBox::ReadActionComboBox(QWidget *parent):\r\nQComboBox(parent) {\r\n\tsetEditable(false);\r\n\r\n\tfor (unsigned int i = 0; i <= General::READ_ACTION_COUNT; ++i) {\r\n\t\taddItem(General::READ_ACTION_STRINGS[i]);\r\n\t}\r\n}\r\n\r\nReadActionComboBox::~ReadActionComboBox() {\r\n}\r\n\r\nGeneral::ReadAction ReadActionComboBox::getCurrentValue() const {\r\n\treturn static_cast<General::ReadAction>(currentIndex());\r\n}\r\n\r\nvoid ReadActionComboBox::setCurrentValue( General::ReadAction readAction ) {\r\n\tsetCurrentIndex(readAction);\r\n}\r\n"
  },
  {
    "path": "common/widgets/readActionComboBox/readactioncombobox.h",
    "content": "/* \r\n *  \tCreated on: 27.8.2012\r\n *      Author: Antti Kamppi\r\n * \t\tfilename: readactioncombobox.h\r\n *\t\tProject: Kactus 2\r\n */\r\n\r\n#ifndef READACTIONCOMBOBOX_H\r\n#define READACTIONCOMBOBOX_H\r\n\r\n#include <IPXACTmodels/generaldeclarations.h>\r\n\r\n#include <QComboBox>\r\n\r\n/*! \\brief The combo box to select one of the defined read actions.\r\n *\r\n */\r\nclass ReadActionComboBox : public QComboBox {\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\r\n\t/*! \\brief The constructor.\r\n\t *\r\n\t * \\param parent Pointer to the owner of the combo box.\r\n\t *\r\n\t*/\r\n\tReadActionComboBox(QWidget *parent);\r\n\t\r\n\t//! \\brief The destructor\r\n\tvirtual ~ReadActionComboBox();\r\n\r\n\t/*! \\brief Get the currently selected read action.\r\n\t *\r\n\t * \\return The currently selected read action.\r\n\t*/\r\n\tGeneral::ReadAction getCurrentValue() const;\r\n\r\n\t/*! \\brief Set the selected read action.\r\n\t *\r\n\t * \\param readAction The read action to select.\r\n\t *\r\n\t*/\r\n\tvoid setCurrentValue(General::ReadAction readAction);\r\n\r\nprivate:\r\n\r\n\t//! \\brief No copying\r\n\tReadActionComboBox(const ReadActionComboBox& other);\r\n\r\n\t//! \\brief No assignment\r\n\tReadActionComboBox& operator=(const ReadActionComboBox& other);\r\n};\r\n\r\n#endif // READACTIONCOMBOBOX_H\r\n"
  },
  {
    "path": "common/widgets/segmentComboBox/SegmentComboBox.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: SegmentComboBox.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Mikko Teuho\n// Date: 24.02.2022\n//\n// Description:\n// The combo box to select one of the defined segments.\n//-----------------------------------------------------------------------------\n\n#include \"SegmentComboBox.h\"\n\n#include <IPXACTmodels/Component/AddressSpace.h>\n#include <IPXACTmodels/Component/Segment.h>\n\n//-----------------------------------------------------------------------------\n// Function: SegmentComboBox::SegmentComboBox()\n//-----------------------------------------------------------------------------\nSegmentComboBox::SegmentComboBox(QWidget *parent):\nQComboBox(parent)\n{\n    setEditable(false);\n}\n\n//-----------------------------------------------------------------------------\n// Function: SegmentComboBox::setupSelection()\n//-----------------------------------------------------------------------------\nvoid SegmentComboBox::setupSelection(QSharedPointer<AddressSpace> containingSpace, QString const& segmentReference)\n{\n    clear();\n\n    addItem(\"\");\n\n    if (containingSpace)\n    {\n        for (auto segment : *containingSpace->getSegments())\n        {\n            addItem(segment->name());\n        }\n    }\n\n    if (findText(segmentReference) < 0)\n    {\n        addItem(segmentReference);\n    }\n\n    setCurrentText(segmentReference);\n}\n"
  },
  {
    "path": "common/widgets/segmentComboBox/SegmentComboBox.h",
    "content": "//-----------------------------------------------------------------------------\n// File: SegmentComboBox.h\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Mikko Teuho\n// Date: 24.02.2022\n//\n// Description:\n// The combo box to select one of the defined segments.\n//-----------------------------------------------------------------------------\n\n#ifndef SEGMENTCOMBOBOX_H\n#define SEGMENTCOMBOBOX_H\n\n#include <QComboBox>\n\nclass AddressSpace;\nclass Component;\n\n//-----------------------------------------------------------------------------\n//! The combo box to select one of the defined segments.\n//-----------------------------------------------------------------------------\nclass SegmentComboBox : public QComboBox\n{\n\tQ_OBJECT\n\npublic:\n\n\t/*!\n     *  The constructor.\n\t *\n     *      param [in] parent   Pointer to the owner of the combo box.\n\t */\n    SegmentComboBox(QWidget *parent);\n\t\n\t/*!\n     *  The destructor.\n     */\n    virtual ~SegmentComboBox() = default;\n\n    /*!\n     *  Setup the combo box.\n     *\n     *    @param [in] containingSpace     Address space containing the available segments.\n     *    @param [in] segmentReference    Currently selected segment.\n     */\n    void setupSelection(QSharedPointer<AddressSpace> containingSpace, QString const& segmentReference = \"\");\n\nprivate:\n\t\n    //! No copying.\tNo assignment.\n    SegmentComboBox(const SegmentComboBox& other);\n    SegmentComboBox& operator=(const SegmentComboBox& other);\n};\n\n#endif // SEGMENTCOMBOBOX_H\n"
  },
  {
    "path": "common/widgets/summaryLabel/summarylabel.cpp",
    "content": "/* \r\n *  \tCreated on: 31.5.2012\r\n *      Author: Antti Kamppi\r\n * \t\tfilename: summarylabel.cpp\r\n *\t\tProject: Kactus 2\r\n */\r\n\r\n#include \"summarylabel.h\"\r\n\r\n#include <QFont>\r\n\r\n\r\n //-----------------------------------------------------------------------------\r\n // Function: SummaryLabel::SummaryLabel()\r\n //-----------------------------------------------------------------------------\r\nSummaryLabel::SummaryLabel( const QString& text, QWidget *parent, bool showExtensionIcon):\r\nQLabel(text, parent) {\r\n\r\n\tQFont usedFont = font();\r\n\tusedFont.setWeight(QFont::Bold);\r\n\tusedFont.setPointSize(usedFont.pointSize() + SummaryLabel::POINTSIZE_INCREMENT);\r\n\tsetFont(usedFont);\r\n\r\n    if (showExtensionIcon)\r\n    {\r\n        auto labelText = text;\r\n        auto size = fontMetrics().height();\r\n        setText(\"<html>\" + labelText + \"<img  src=':icons/common/graphics/appicon.png'\"\r\n            \"width='\" + QString::number(size) + \"' height='\" + QString::number(size) + \"' ></html>\");\r\n        setToolTip(tr(\"This is Kactus2 extension\"));\r\n    }\r\n}\r\n"
  },
  {
    "path": "common/widgets/summaryLabel/summarylabel.h",
    "content": "/* \r\n *  \tCreated on: 31.5.2012\r\n *      Author: Antti Kamppi\r\n * \t\tfilename: summarylabel.h\r\n *\t\tProject: Kactus 2\r\n */\r\n\r\n#ifndef SUMMARYLABEL_H\r\n#define SUMMARYLABEL_H\r\n\r\n#include <QLabel>\r\n\r\n/*! \\brief The label used to display summary headers in component editor.\r\n *\r\n */\r\nclass SummaryLabel : public QLabel {\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\r\n\t//! \\brief The increment amount for normal font point size.\r\n\tstatic const int POINTSIZE_INCREMENT = 6;\r\n\r\n\t/*!\r\n\t * The constructor\r\n\t *\r\n\t *    @param [in] text                 The text to display in the label.\r\n\t *    @param [in] parent               The owner of this label.\r\n\t *    @param [in] showExtensionIcon    If true, an extension icon is shown next to the label.\r\n\t */\r\n\t SummaryLabel(const QString& text, QWidget *parent, bool showExtensionIcon = false);\r\n\t\r\n\t//! \\brief The destructor\r\n\tvirtual ~SummaryLabel() = default;\r\n\r\n    //! \\brief No copying\r\n    SummaryLabel(const SummaryLabel& other) = delete;\r\n\r\n    //! \\brief No assignment\r\n    SummaryLabel& operator=(const SummaryLabel& other) = delete;\r\n\r\n\r\n};\r\n\r\n#endif // SUMMARYLABEL_H\r\n"
  },
  {
    "path": "common/widgets/tabDocument/TabDocument.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: TabDocument.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Joni-Matti Maatta\r\n// Date: 4.5.2011\r\n//\r\n// Description:\r\n// Tab document base class.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"TabDocument.h\"\r\n\r\n#include <QApplication>\r\n#include <QCoreApplication>\r\n#include <QMessageBox>\r\n#include <QPushButton>\r\n#include <QTimer>\r\n\r\n#include <KactusAPI/include/LibraryInterface.h>\r\n#include \"IPXACTmodels/common/Document.h\"\r\n\r\nclass LibraryInterface;\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: TabDocument::TabDocument()\r\n//-----------------------------------------------------------------------------\r\nTabDocument::TabDocument(QWidget* parent, LibraryInterface* libHandler, unsigned int flags, int minZoomLevel, int maxZoomLevel) :\r\n    QWidget(parent),\r\n    supportedWindows_(OUTPUTWINDOW | LIBRARYWINDOW | CONTEXT_HELP_WINDOW ),\r\n    flags_(flags),\r\n    modified_(false),\r\n    locked_(false),\r\n    zoomLevel_(100),\r\n    maxZoomLevel_(maxZoomLevel),\r\n    minZoomLevel_(minZoomLevel),\r\n    title_(\"\"),\r\n    docName_(\"\"),\r\n    previouslyUnlocked_(false),\r\n    relatedVLNVs_(),\r\n    refreshRequested_(false),\r\n    docType_(DocumentType::EMPTY),\r\n    libHandler_(libHandler)\r\n{\r\n    connect(this, SIGNAL(contentChanged()), this, SLOT(setModified()));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: TabDocument::~TabDocument()\r\n//-----------------------------------------------------------------------------\r\nTabDocument::~TabDocument()\r\n{\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: TabDocument::applySettings()\r\n//-----------------------------------------------------------------------------\r\nvoid TabDocument::applySettings(QSettings& settings)\r\n{\r\n    if (isProtected() && !settings.value(\"General/EnableLocking\").toBool())\r\n    {\r\n        setProtection(false);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: TabDocument::setDocumentName()\r\n//-----------------------------------------------------------------------------\r\nvoid TabDocument::setDocumentName(QString const& name)\r\n{\r\n    docName_ = name;\r\n    updateTabTitle();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: TabDocument::setDocumentType()\r\n//-----------------------------------------------------------------------------\r\nvoid TabDocument::setDocumentType(DocumentType const& type)\r\n{\r\n    docType_ = type;\r\n    updateTabTitle();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: TabDocument::fitInView()\r\n//-----------------------------------------------------------------------------\r\nvoid TabDocument::fitInView()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: TabDocument::setZoomLevel()\r\n//-----------------------------------------------------------------------------\r\nvoid TabDocument::setZoomLevel(int level)\r\n{\r\n    level = qMin(qMax(level, minZoomLevel_), maxZoomLevel_);\r\n\r\n    if (flags_ & DOC_ZOOM_SUPPORT)\r\n    {\r\n        zoomLevel_ = level;\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: TabDocument::setMode()\r\n//-----------------------------------------------------------------------------\r\nvoid TabDocument::setMode(DrawMode)\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: TabDocument::setProtection()\r\n//-----------------------------------------------------------------------------\r\nvoid TabDocument::setProtection(bool locked)\r\n{\r\n    locked_ = locked;\r\n\r\n    if (!locked_)\r\n    {\r\n        previouslyUnlocked_ = true;\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: TabDocument::setModified()\r\n//-----------------------------------------------------------------------------\r\nvoid TabDocument::setModified(bool modified)\r\n{\r\n\tif (modified == modified_)\r\n    {\r\n\t\treturn;\r\n    }\r\n\r\n    modified_ = modified;\r\n    updateTabTitle();\r\n\r\n\temit modifiedChanged(modified_);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: TabDocument::getDocumentName()\r\n//-----------------------------------------------------------------------------\r\nQString TabDocument::getDocumentName() const\r\n{\r\n    return docName_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: TabDocument::getZoomLevel()\r\n//-----------------------------------------------------------------------------\r\nint TabDocument::getZoomLevel() const\r\n{\r\n    return zoomLevel_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: TabDocument::getSupportedDrawModes()\r\n//-----------------------------------------------------------------------------\r\nunsigned int TabDocument::getSupportedDrawModes() const\r\n{\r\n    return MODE_NONE;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: TabDocument::isProtected()\r\n//-----------------------------------------------------------------------------\r\nbool TabDocument::isProtected() const\r\n{\r\n    return locked_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: TabDocument::getFlags()\r\n//-----------------------------------------------------------------------------\r\nunsigned int TabDocument::getFlags() const\r\n{\r\n    return flags_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: TabDocument::isModified()\r\n//-----------------------------------------------------------------------------\r\nbool TabDocument::isModified() const\r\n{\r\n    return modified_;\r\n}\r\n\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: TabDocument::validate()\r\n//-----------------------------------------------------------------------------\r\nbool TabDocument::validate(QVector<QString>&)\r\n{\r\n    return true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: TabDocument::save()\r\n//-----------------------------------------------------------------------------\r\nbool TabDocument::save()\r\n{\r\n    setModified(false);\r\n    if (refreshRequested_ == false) // Emit save signal only if initiated by saving in this tab\r\n    {\r\n        emit documentSaved(this);\r\n    }\r\n    return true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: TabDocument::saveAs()\r\n//-----------------------------------------------------------------------------\r\nbool TabDocument::saveAs()\r\n{\r\n\tsetModified(false);\r\n\treturn true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: TabDocument::print()\r\n//-----------------------------------------------------------------------------\r\nvoid TabDocument::print()\r\n{\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: TabDocument::exportImage()\r\n//-----------------------------------------------------------------------------\r\nbool TabDocument::exportImage()\r\n{\r\n    return false;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: TabDocument::getMaxZoomLevel()\r\n//-----------------------------------------------------------------------------\r\nint TabDocument::getMaxZoomLevel() const\r\n{\r\n    return maxZoomLevel_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: TabDocument::getMinZoomLevel()\r\n//-----------------------------------------------------------------------------\r\nint TabDocument::getMinZoomLevel() const\r\n{\r\n    return minZoomLevel_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: TabDocument::askSaveFile()\r\n//-----------------------------------------------------------------------------\r\nbool TabDocument::askSaveFile() const {\r\n\r\n\tQMessageBox::StandardButton button = QMessageBox::question(parentWidget(), \r\n\t\ttr(\"Save changes to file?\"), \r\n\t\ttr(\"Would you like to save the changes you have made to the file?\"),\r\n\t\tQMessageBox::Yes | QMessageBox::No, QMessageBox::Yes);\r\n\r\n\t// return true if user clicked yes\r\n\treturn QMessageBox::Yes == button;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: TabDocument::loadChangesFromSibling()\r\n//-----------------------------------------------------------------------------\r\nvoid TabDocument::loadChangesFromRelatedTab()\r\n{\r\n    // Implementation left for derived classes, if needed\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: TabDocument::updateTabTitle()\r\n//-----------------------------------------------------------------------------\r\nvoid TabDocument::updateTabTitle()\r\n{\r\n    if (isModified())\r\n    {\r\n        if (docType_!=DocumentType::EMPTY)\r\n        {\r\n            setTabTitle(docName_ + \" [\" + documentTypetoString(docType_) + \"]\" + \"*\");\r\n        }\r\n        else \r\n        {\r\n            setTabTitle(docName_ + \"*\");\r\n        }\r\n    }\r\n    else\r\n    {\r\n        if (docType_ != DocumentType::EMPTY)\r\n        {\r\n            setTabTitle(docName_ + \" [\" + documentTypetoString(docType_) + \"]\");\r\n        }\r\n        else\r\n        {\r\n            setTabTitle(docName_);\r\n        }        \r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: TabDocument::setTabTitle()\r\n//-----------------------------------------------------------------------------\r\nvoid TabDocument::setTabTitle(QString const& title)\r\n{\r\n    emit titleChanged(this, title);\r\n    title_ = title;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: TabDocument::getDocumentVLNV()\r\n//-----------------------------------------------------------------------------\r\nVLNV TabDocument::getDocumentVLNV() const \r\n{\r\n\treturn VLNV();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: TabDocument::getEditProvider()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<IEditProvider> TabDocument::getEditProvider() const\r\n{\r\n    return QSharedPointer<IEditProvider>();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: TabDocument::refresh()\r\n//-----------------------------------------------------------------------------\r\nvoid TabDocument::refresh()\r\n{\r\n\temit refreshed();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: TabDocument::getSupportedWindows()\r\n//-----------------------------------------------------------------------------\r\nunsigned int TabDocument::getSupportedWindows() const \r\n{\r\n\treturn supportedWindows_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: TabDocument::setPreviouslyUnlocked()\r\n//-----------------------------------------------------------------------------\r\nvoid TabDocument::setPreviouslyUnlocked()\r\n{\r\n    previouslyUnlocked_ = true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: TabDocument::isPreviouslyUnlocked()\r\n//-----------------------------------------------------------------------------\r\nbool TabDocument::isPreviouslyUnlocked() const\r\n{\r\n    return previouslyUnlocked_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: TabDocument::setVisibilityControlState()\r\n//-----------------------------------------------------------------------------\r\nvoid TabDocument::setVisibilityControlState(QString const& name, bool state)\r\n{\r\n    if (visibilityControls_.contains(name))\r\n    {\r\n        visibilityControls_.insert(name, state);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: TabDocument::addVisibilityControl()\r\n//-----------------------------------------------------------------------------\r\nvoid TabDocument::addVisibilityControl(QString const& name, bool state)\r\n{\r\n    visibilityControls_.insert(name, state);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: TabDocument::getVisibilityControls()\r\n//-----------------------------------------------------------------------------\r\nQMap<QString, bool> const& TabDocument::getVisibilityControls() const\r\n{\r\n    return visibilityControls_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: TabDocument::getDocType()\r\n//-----------------------------------------------------------------------------\r\nTabDocument::DocumentType TabDocument::getDocType() const\r\n{\r\n    return docType_;\r\n}\r\n\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: TabDocument::fileExists()\r\n//-----------------------------------------------------------------------------\r\nbool TabDocument::fileExists()\r\n{\r\n    if (!libHandler_)\r\n    {\r\n        return false;\r\n    }\r\n    return libHandler_->getModel<Document>(getIdentifyingVLNV())!=nullptr;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: TabDocument::documentTypetoString()\r\n//-----------------------------------------------------------------------------\r\nQString TabDocument::documentTypetoString(DocumentType documentType)\r\n{\r\n    switch (documentType)\r\n    {\r\n    case DocumentType::ABSTRACTION_DEFINITION:\r\n        return QStringLiteral(\"Abstraction Definition\");\r\n    case DocumentType::API_DEFINITION:\r\n        return QStringLiteral(\"API Definition\");\r\n    case DocumentType::BUS_DEFINITION:\r\n        return QStringLiteral(\"Bus Definition\");\r\n    case DocumentType::CATALOG:\r\n        return QStringLiteral(\"Catalog\");\r\n    case DocumentType::COM_DEFINITION:\r\n        return QStringLiteral(\"COM Definition\");\r\n    case DocumentType::HW_COMPONENT:\r\n        return QStringLiteral(\"HW Component\");\r\n    case DocumentType::SW_COMPONENT:\r\n        return QStringLiteral(\"SW Component\");\r\n    case DocumentType::UNMAPPED_SYSTEM:\r\n        return QStringLiteral(\"Unmapped System\");\r\n    case DocumentType::CODE:\r\n        return QStringLiteral(\"Code\");\r\n    case DocumentType::HW_DESIGN:\r\n        return QStringLiteral(\"HW Design\");\r\n    case DocumentType::MEMORY_DESIGN:\r\n        return QStringLiteral(\"Memory Design\");\r\n    case DocumentType::SW_DESIGN:\r\n        return QStringLiteral(\"SW Design\");\r\n    case DocumentType::SYSTEM_DESIGN:\r\n        return QStringLiteral(\"System Design\");\r\n    case DocumentType::EMPTY:\r\n        return QStringLiteral(\"\");\r\n    default:\r\n        Q_ASSERT(false); //please handle ToString conversion for every new document type you add.\r\n        return QStringLiteral(\"\");\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: TabDocument::addRelatedVLNV()\r\n//-----------------------------------------------------------------------------\r\nvoid TabDocument::addRelatedVLNV(VLNV const& vlnv)\r\n{\r\n    unsigned int count = relatedVLNVs_.value(vlnv, 0);\r\n    relatedVLNVs_.insert(vlnv, count + 1);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: TabDocument::removeRelatedVLNV()\r\n//-----------------------------------------------------------------------------\r\nvoid TabDocument::removeRelatedVLNV(VLNV const& vlnv)\r\n{\r\n    unsigned int count = relatedVLNVs_.value(vlnv, 0);\r\n\r\n    if (count == 1)\r\n    {\r\n        relatedVLNVs_.remove(vlnv);\r\n    }\r\n    else if (count > 0)\r\n    {\r\n        relatedVLNVs_.insert(vlnv, count - 1);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: TabDocument::getRelatedVLNVs()\r\n//-----------------------------------------------------------------------------\r\nQList<VLNV> TabDocument::getRelatedVLNVs() const\r\n{\r\n    return relatedVLNVs_.keys();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: TabDocument::getTitle()\r\n//-----------------------------------------------------------------------------\r\nQString TabDocument::getTitle() const\r\n{\r\n    return title_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: TabDocument::requestRefresh()\r\n//-----------------------------------------------------------------------------\r\nvoid TabDocument::requestRefresh()\r\n{\r\n    refreshRequested_ = true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: TabDocument::showEvent()\r\n//-----------------------------------------------------------------------------\r\nvoid TabDocument::showEvent(QShowEvent* event)\r\n{\r\n    QWidget::showEvent(event);\r\n\r\n    if (refreshRequested_)\r\n    {\r\n        //refreshRequested_ = false;\r\n        QTimer::singleShot(20, this, SLOT(handleRefreshRequest()));\r\n    }\r\n}\r\n\r\nLibraryInterface* TabDocument::getLibHandler() const\r\n{\r\n    return libHandler_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: TabDocument::refreshWasRequested()\r\n//-----------------------------------------------------------------------------\r\nbool TabDocument::refreshWasRequested() const\r\n{\r\n    return refreshRequested_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: TabDocument::clearRelatedVLNVs()\r\n//-----------------------------------------------------------------------------\r\nvoid TabDocument::clearRelatedVLNVs()\r\n{\r\n    relatedVLNVs_.clear();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: TabDocument::handleRefreshRequest()\r\n//-----------------------------------------------------------------------------\r\nvoid TabDocument::handleRefreshRequest()\r\n{\r\n    if (isModified())\r\n    {\r\n        QMessageBox msgBox(QMessageBox::Warning, QCoreApplication::applicationName(),\r\n            tr(\"Related documents contain modifications that affect this document.\"\r\n               \"Save changes and refresh?\"),\r\n            QMessageBox::Yes | QMessageBox::No, this);\r\n\r\n\t\tif (msgBox.exec() == QMessageBox::Yes)\r\n        {\r\n            loadChangesFromRelatedTab();\r\n            save();\r\n            refresh();\r\n            refreshRequested_ = false;\r\n            return;\r\n        }\r\n    }\r\n    \r\n    loadChangesFromRelatedTab();\r\n    refresh();\r\n    refreshRequested_ = false;\r\n}\r\n"
  },
  {
    "path": "common/widgets/tabDocument/TabDocument.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: TabDocument.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Joni-Matti Maatta\r\n// Date: 4.5.2011\r\n//\r\n// Description:\r\n// Tab document base class.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef TABDOCUMENT_H\r\n#define TABDOCUMENT_H\r\n\r\n#include <IPXACTmodels/common/VLNV.h>\r\n\r\n#include <editors/common/DrawMode.h>\r\n#include <common/IEditProvider.h>\r\n\r\n#include <QWidget>\r\n#include <QFileSystemWatcher>\r\n#include <QFocusEvent>\r\n#include <QString>\r\n#include <QSettings>\r\n#include <QMap>\r\n\r\nclass Extendable;\r\nclass LibraryInterface;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! TabDocument class.\r\n//-----------------------------------------------------------------------------\r\nclass TabDocument : public QWidget\r\n{\r\n    Q_OBJECT\r\n\r\npublic:\r\n    \r\n    //-----------------------------------------------------------------------------\r\n    //! DocSupportFlags enumeration.\r\n    //-----------------------------------------------------------------------------\r\n    enum DocSupportFlags\r\n    {\r\n        DOC_ZOOM_SUPPORT = 0x01,\r\n        DOC_DRAW_MODE_SUPPORT = 0x02,\r\n        DOC_PRINT_SUPPORT = 0x04,\r\n        DOC_PROTECTION_SUPPORT = 0x08,\r\n        DOC_EDIT_SUPPORT = 0x10,\r\n        DOC_VISIBILITY_CONTROL_SUPPORT = 0x20,\r\n    };\r\n\r\n\tenum SupportedWindows {\r\n\t\tOUTPUTWINDOW            = 0x001,\r\n\t\tLIBRARYWINDOW           = 0x004,\r\n\t\tCONFIGURATIONWINDOW     = 0x008,\r\n\t\tCONNECTIONWINDOW        = 0x010,\r\n\t\tINTERFACEWINDOW         = 0x020,\r\n\t\tINSTANCEWINDOW          = 0x040,\r\n        SYSTEM_DETAILS_WINDOW   = 0x100,\r\n        CONTEXT_HELP_WINDOW     = 0x200,\r\n        ADHOC_WINDOW            = 0x800,\r\n        DESIGNPARAMETERSWINDOW  = 0x1000,\r\n        VENDOREXTENSIONWINDOW   = 0x2000\r\n\t};\r\n\r\n    //-----------------------------------------------------------------------------\r\n    //! DocumentType enumeration.\r\n    //-----------------------------------------------------------------------------\r\n    enum class DocumentType {\r\n        ABSTRACTION_DEFINITION,\r\n        API_DEFINITION,\r\n        BUS_DEFINITION,\r\n        CATALOG,\r\n        COM_DEFINITION,\r\n        HW_COMPONENT,\r\n        SW_COMPONENT,\r\n        UNMAPPED_SYSTEM,\r\n        CODE,\r\n        HW_DESIGN,\r\n        MEMORY_DESIGN,\r\n        SW_DESIGN,\r\n        SYSTEM_DESIGN,\r\n        EMPTY\r\n    };\r\n\r\n    /*!\r\n     *  Constructor.\r\n     *\r\n     *    @param [in] parent        The parent widget.\r\n     *    @param [in] libHandler    The instance that handles the library.\r\n     *    @param [in] flags         The document support flags.\r\n     *    @param [in] minZoomLevel  The minimum zoom level.\r\n\t *    @param [in] maxZoomLevel  The maximum zoom level.\r\n\t */\r\n\tTabDocument(QWidget* parent, LibraryInterface* libHandler = nullptr, unsigned int flags = 0,\r\n\t\t        int minZoomLevel = 100, int maxZoomLevel = 100);\r\n\r\n\t/*!\r\n     *  Destructor.\r\n     */\r\n    virtual ~TabDocument();\r\n\r\n\t/*!\r\n     *  Get the VLNV that can be used to identify the document.\r\n\t *\r\n\t *  return The VLNV that identifies the document.\r\n     */\r\n\tvirtual VLNV getIdentifyingVLNV() const = 0;\r\n\r\n    /*!\r\n     *  Applies the current settings into use.\r\n     */\r\n    virtual void applySettings(QSettings& settings);\r\n\r\n    /*!\r\n     *  Changes the state of a visibility control.\r\n     *\r\n     *    @param [in] name   The name of the visibility control.\r\n     *    @param [in] state  The new state for the visibility control.\r\n     */\r\n    virtual void setVisibilityControlState(QString const& name, bool state);\r\n\r\n    /*!\r\n     *  Refreshes the document view.\r\n     */\r\n    virtual void refresh();\r\n\r\n    /*!\r\n     *  Fits the document fully in view. Supported only if the document can be zoomed.\r\n     */\r\n    virtual void fitInView();\r\n\r\n    /*!\r\n     *  Sets the zoom level.\r\n     *\r\n     *    @param [in] level The zoom level in percents.\r\n     */\r\n    virtual void setZoomLevel(int level);\r\n\r\n    /*!\r\n     *  Sets the draw mode of the document.\r\n     *\r\n     *    @param [in] mode The draw mode.\r\n     *\r\n     *      @remarks Proper implementation is required if the document is a diagram.\r\n     */\r\n    virtual void setMode(DrawMode mode);\r\n\r\n    /*!\r\n     *  Sets the protection state of the document.\r\n     *\r\n     *    @param [in] locked True for locked state; false for unlocked.\r\n     */\r\n    virtual void setProtection(bool locked);\r\n\r\n    /*!\r\n     *  Sets the state that the document has previously been unlocked.\r\n     */\r\n    void setPreviouslyUnlocked();\r\n\r\n    /*!\r\n     *  Returns the name of the document.\r\n     */\r\n    QString getDocumentName() const;\r\n\r\n    /*!\r\n     *  Returns the current zoom level in percents.\r\n     */\r\n    int getZoomLevel() const;\r\n\r\n    /*!\r\n     *  Returns the maximum allowed zoom level.\r\n     */\r\n    int getMaxZoomLevel() const;\r\n\r\n    /*!\r\n     *  Returns the minimum allowed zoom level.\r\n     */\r\n    int getMinZoomLevel() const;\r\n\r\n    /*!\r\n     *  Returns the supported draw modes.\r\n     */\r\n    virtual unsigned int getSupportedDrawModes() const;\r\n\r\n    /*!\r\n     *  Returns true if the document is protected (i.e. in locked state).\r\n     */\r\n    bool isProtected() const;\r\n\r\n    /*!\r\n     *  Returns the document flags.\r\n     */\r\n    unsigned int getFlags() const;\r\n    \r\n    /*!\r\n     *  Returns true if the document has been modified but not saved.\r\n     */\r\n    bool isModified() const;\r\n\r\n\t/*!\r\n     *  Ask the user if file should be saved or not\r\n\t *\r\n\t *      return True if user wants to save a file.\r\n     */\r\n\tbool askSaveFile() const;\r\n\r\n\t/*!\r\n     *  Get the vlnv of the current component\r\n\t *\r\n\t *      return Base class returns invalid vlnv.\r\n     */\r\n\tvirtual VLNV getDocumentVLNV() const;\r\n\r\n    /*!\r\n     *  Adds a related VLNV.\r\n     *\r\n     *    @param [in] vlnv The VLNV to add.\r\n     *\r\n     *      @remarks The occurrences of each unique VLNV are calculated internally.\r\n     */\r\n    void addRelatedVLNV(VLNV const& vlnv);\r\n\r\n    /*!\r\n     *  Removes a related VLNV.\r\n     *\r\n     *    @param [in] vlnv The VLNV to remove.\r\n     */\r\n    void removeRelatedVLNV(VLNV const& vlnv);    \r\n\r\n    /*!\r\n     *  Clears the list of related VLNVs.\r\n     */\r\n    void clearRelatedVLNVs();\r\n\r\n    /*!\r\n     *  Returns the list of related VLNVs.\r\n     */\r\n    QList<VLNV> getRelatedVLNVs() const;\r\n\r\n    QString getTitle() const;\r\n\r\n    /*!\r\n     *  Returns the edit provider.\r\n     *\r\n     *    @return Base class implementation returns null.\r\n     *\r\n     *      @remarks Edit support should be queried with getFlags().\r\n     */\r\n    virtual QSharedPointer<IEditProvider> getEditProvider() const;\r\n\r\n\t/*!\r\n     *  Get the bit fields that define which windows are supported by this tab.\r\n\t *\r\n\t *      return unsigned int which contains the bit fields specifying supported windows.\r\n     */\r\n\tvirtual unsigned int getSupportedWindows() const;\r\n\r\n    /*!\r\n     *  Returns true if the document has previously been unlocked.\r\n     */\r\n    bool isPreviouslyUnlocked() const;\r\n\r\n    /*!\r\n     *  Returns the supported visibility controls.\r\n     */\r\n    QMap<QString, bool> const& getVisibilityControls() const;\r\n\r\n    /*!\r\n     *  Returns the docType_.\r\n     */\r\n    DocumentType getDocType() const;\r\n\r\n    /*!\r\n     *  Validates that the file being edited in the tab exists.\r\n     *\r\n     *    @return True if libHandler is present and the file exists, otherwise false.\r\n     */\r\n    bool fileExists();\r\n\r\n    /*!\r\n     *  Returns a string representation of the DocumentType.\r\n     */\r\n    static QString documentTypetoString(DocumentType documentType);\r\n\r\npublic slots:\r\n\r\n    /*!\r\n     *  Validates the document against the IP-XACT standard.\r\n     *\r\n     *    @param [out] errorList Error message list for reporting standard violations.\r\n     *\r\n     *    @return True if the document is valid. False if there were any violations.\r\n     */\r\n    virtual bool validate(QVector<QString>& errorList);\r\n\r\n    //! Saves the document and resets the modified state.\r\n    virtual bool save();\r\n\r\n\t//! Saves the document as new object and resets the modified state.\r\n\tvirtual bool saveAs();\r\n\r\n    //! Prints the document, if the document supports printing. Support can be queried with getFlags().\r\n    virtual void print();\r\n\r\n    /*!\r\n     *  Exports a screenshot of the document as an image file.\r\n     */\r\n    virtual bool exportImage();\r\n\r\n    /*!\r\n     *  Sets the document modified/unmodified.\r\n     *\r\n     *    @param [in] modified True if the document should be set modified; otherwise false.\r\n     */\r\n    void setModified(bool modified = true);\r\n\r\n    /*!\r\n     *  Requests the document to be refreshed when shown the next time.\r\n     */\r\n    void requestRefresh();\r\n\r\nsignals:\r\n\t//! \\brief Emitted when contents of the widget change\r\n\tvoid contentChanged();\r\n\r\n\t//! \\brief Send an error message to be printed to user.\r\n\tvoid errorMessage(const QString& msg);\r\n\r\n\t//! \\brief Send a notification to be printed to user.\r\n\tvoid noticeMessage(const QString& msg);\r\n\r\n    //! Emitted when a help page should be changed in the context help window.\r\n    void helpUrlRequested(QString const& url);\r\n\r\n    //! Emitted when the title of the document changes.\r\n    void titleChanged(TabDocument* document, QString const& newTitle);\r\n\r\n\t//! \\brief Emitted when the tab document is refreshed.\r\n\tvoid refreshed();\r\n\r\n\t//! \\brief Emitted when the modified state changes.\r\n\tvoid modifiedChanged(bool modified);\r\n\r\n    //! Emitted when the document has been saved.\r\n    void documentSaved(TabDocument* doc);\r\n\r\n\t//! \\brief Emitted when a design editor should be opened for given hierarchical view.\r\n\tvoid openDesign(const VLNV& componentVLNV, const QString& viewName);\r\n\r\n\t//! \\brief Emitted when a bus editor should be opened for given bus.\r\n\tvoid openBus(const VLNV& busdefVLNV);\r\n\r\n    //! \\brief Emitted when a abstraction editor should be opened for given bus.\r\n    void openAbsDef(const VLNV& absdefVLNV);\r\n\r\n\t//! \\brief Emitted when a COM definition should be opened in an editor.\r\n\tvoid openComDefinition(const VLNV& comdefVLNV);\r\n\r\n\t//! \\brief Emitted when a SW design should be opened in an editor.\r\n\tvoid openSWDesign(const VLNV& componentVLNV, const QString& viewName);\r\n\r\n\t//! \\brief Emitted when a system design should be opened in an editor.\r\n\tvoid openSystemDesign(const VLNV& componentVLNV, const QString& viewName);\r\n\r\n    /*!\r\n     *  Change the vendor extensions of the vendor extensions editor.\r\n     *\r\n     *    @param [in] containingID    ID for the vendor extensions editor.\r\n     *    @param [in] extensionItem   The item containing the selected vendor extensions.\r\n     */\r\n    void changeVendorExtensions(QString const& containingID, QSharedPointer<Extendable> extensionItem);\r\n\r\nprotected:\r\n    /*!\r\n     *  Sets the name of the document.\r\n     *\r\n     *    @param [in] name The name of the document.\r\n     */\r\n    void setDocumentName(QString const& name);\r\n\r\n    /*!\r\n     *  Sets the type of the document. If not empty, the name of the tab will be shown as: DocName [DocType]\r\n     *\r\n     *    @param [in] type The type of the document.\r\n     */\r\n    void setDocumentType(DocumentType const& type);\r\n\r\n    /*!\r\n     *  Adds a new visibility control to the document.\r\n     *\r\n     *    @param [in] name   The name of the new visibility control.\r\n     *    @param [in] state  The initial state of the visibility control.\r\n     */\r\n    void addVisibilityControl(QString const& name, bool state);\r\n\r\n    /*!\r\n     *  Shows the document and asks to refresh it if refresh was requested.\r\n     */\r\n    virtual void showEvent(QShowEvent* event);\r\n\r\n\t//! \\brief Contains the bit fields that define which windows are supported for this tab.\r\n\tunsigned int supportedWindows_;\r\n\r\n    /*!\r\n     *  Returns instance that handles the library.\r\n     */\r\n    LibraryInterface* getLibHandler() const;\r\n\r\n    /*!\r\n     *\tReturns the status of if refresh was requested from another document.\r\n     *\t    \r\n     *    @return True, if the refresh request origin came from elsewhere, otherwise false.\r\n     */\r\n    bool refreshWasRequested() const;\r\n\r\nprivate slots:\r\n\r\n    //! Handles the refresh request.\r\n    void handleRefreshRequest();\r\n\r\nprivate:\r\n    // Disable copying.\r\n    TabDocument(TabDocument const& rhs);\r\n    TabDocument& operator=(TabDocument const& rhs);\r\n\r\n    /*!\r\n     *\tLoad changes made in related tabs. Reimplement to load editor/tab-specific changes. \r\n     *  Reimplementations should only load changes that can't cause conflicts.\r\n     */\r\n    virtual void loadChangesFromRelatedTab();\r\n\r\n    /*!\r\n     *  Updates the tab title.\r\n     */\r\n    void updateTabTitle();\r\n\r\n    /*!\r\n     *  Sets the tab title of this document.\r\n     *\r\n     *    @param [in] title The title text.\r\n     */\r\n    void setTabTitle(QString const& title);\r\n    \r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! Document flags.\r\n    unsigned int flags_;\r\n\r\n    //! Boolean flag for 'modified' state.\r\n    bool modified_;\r\n\r\n    //! The protection state (locked/unlocked).\r\n    bool locked_;\r\n\r\n    //! The zoom level as a percentage.\r\n    int zoomLevel_;\r\n\r\n    //! Maximum zoom level.\r\n    int maxZoomLevel_;\r\n\r\n    //! Minimum zoom level.\r\n    int minZoomLevel_;\r\n\r\n    //! The document title.\r\n    QString title_;\r\n\r\n    //! The name of the document.\r\n    QString docName_;\r\n\r\n    //! The document type.\r\n    DocumentType docType_;\r\n\r\n    //! If true, the document has been previously unlocked.\r\n    bool previouslyUnlocked_;\r\n\r\n    //! Visibility control map.\r\n    QMap<QString, bool> visibilityControls_;\r\n\r\n    //! Related VLNV registry.\r\n    QMap<VLNV, unsigned int> relatedVLNVs_;\r\n\r\n    //! If true, the document must be refreshed when shown the next time.\r\n    bool refreshRequested_;\r\n\r\n    //! The instance that handles the library.\r\n    LibraryInterface* libHandler_;\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n\r\n#endif // TABDOCUMENT_H\r\n"
  },
  {
    "path": "common/widgets/tagEditor/FlowLayout.cpp",
    "content": "/****************************************************************************\n**\n** Copyright (C) 2016 The Qt Company Ltd.\n** Contact: https://www.qt.io/licensing/\n**\n** This file is part of the examples of the Qt Toolkit.\n**\n** $QT_BEGIN_LICENSE:BSD$\n** Commercial License Usage\n** Licensees holding valid commercial Qt licenses may use this file in\n** accordance with the commercial license agreement provided with the\n** Software or, alternatively, in accordance with the terms contained in\n** a written agreement between you and The Qt Company. For licensing terms\n** and conditions see https://www.qt.io/terms-conditions. For further\n** information use the contact form at https://www.qt.io/contact-us.\n**\n** BSD License Usage\n** Alternatively, you may use this file under the terms of the BSD license\n** as follows:\n**\n** \"Redistribution and use in source and binary forms, with or without\n** modification, are permitted provided that the following conditions are\n** met:\n**   * Redistributions of source code must retain the above copyright\n**     notice, this list of conditions and the following disclaimer.\n**   * Redistributions in binary form must reproduce the above copyright\n**     notice, this list of conditions and the following disclaimer in\n**     the documentation and/or other materials provided with the\n**     distribution.\n**   * Neither the name of The Qt Company Ltd nor the names of its\n**     contributors may be used to endorse or promote products derived\n**     from this software without specific prior written permission.\n**\n**\n** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n** \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\"\n**\n** $QT_END_LICENSE$\n**\n****************************************************************************/\n\n#include <QtWidgets>\n#include <QtGlobal>\n\n#include \"FlowLayout.h\"\n\n//-----------------------------------------------------------------------------\n// Function: FlowLayout::FlowLayout()\n//-----------------------------------------------------------------------------\nFlowLayout::FlowLayout(QWidget *parent, int margin, int hSpacing, int vSpacing):\nQLayout(parent),\nm_hSpace_(hSpacing),\nm_vSpace_(vSpacing)\n{\n    setContentsMargins(margin, margin, margin, margin);\n}\n\n//-----------------------------------------------------------------------------\n// Function: FlowLayout::FlowLayout()\n//-----------------------------------------------------------------------------\nFlowLayout::FlowLayout(int margin, int hSpacing, int vSpacing):\nm_hSpace_(hSpacing),\nm_vSpace_(vSpacing)\n{\n    setContentsMargins(margin, margin, margin, margin);\n}\n\n//-----------------------------------------------------------------------------\n// Function: FlowLayout::~FlowLayout()\n//-----------------------------------------------------------------------------\nFlowLayout::~FlowLayout()\n{\n    QLayoutItem *item;\n    while ((item = takeAt(0)))\n    {\n        delete item;\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: FlowLayout::addItem()\n//-----------------------------------------------------------------------------\nvoid FlowLayout::addItem(QLayoutItem *item)\n{\n    itemList_.append(item);\n}\n\n//-----------------------------------------------------------------------------\n// Function: FlowLayout::horizontalSpacing()\n//-----------------------------------------------------------------------------\nint FlowLayout::horizontalSpacing() const\n{\n    if (m_hSpace_ >= 0)\n    {\n        return m_hSpace_;\n    }\n    else\n    {\n        return smartSpacing(QStyle::PM_LayoutHorizontalSpacing);\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: FlowLayout::verticalSpacing()\n//-----------------------------------------------------------------------------\nint FlowLayout::verticalSpacing() const\n{\n    if (m_vSpace_ >= 0)\n    {\n        return m_vSpace_;\n    }\n    else\n    {\n        return smartSpacing(QStyle::PM_LayoutVerticalSpacing);\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: FlowLayout::count()\n//-----------------------------------------------------------------------------\nint FlowLayout::count() const\n{\n    return itemList_.size();\n}\n\n//-----------------------------------------------------------------------------\n// Function: FlowLayout::itemAt()\n//-----------------------------------------------------------------------------\nQLayoutItem *FlowLayout::itemAt(int index) const\n{\n    return itemList_.value(index);\n}\n\n//-----------------------------------------------------------------------------\n// Function: FlowLayout::takeAt()\n//-----------------------------------------------------------------------------\nQLayoutItem *FlowLayout::takeAt(int index)\n{\n    if (index >= 0 && index < itemList_.size())\n    {\n        return itemList_.takeAt(index);\n    }\n\n    return nullptr;\n}\n\n//-----------------------------------------------------------------------------\n// Function: FlowLayout::expandingDirections()\n//-----------------------------------------------------------------------------\nQt::Orientations FlowLayout::expandingDirections() const\n{\n    return Qt::Orientations();\n}\n\n//-----------------------------------------------------------------------------\n// Function: FlowLayout::hasHeightForWidth()\n//-----------------------------------------------------------------------------\nbool FlowLayout::hasHeightForWidth() const\n{\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: FlowLayout::heightForWidth()\n//-----------------------------------------------------------------------------\nint FlowLayout::heightForWidth(int width) const\n{\n    int height = doLayout(QRect(0, 0, width, 0), true);\n    return height;\n}\n\n//-----------------------------------------------------------------------------\n// Function: FlowLayout::setGeometry()\n//-----------------------------------------------------------------------------\nvoid FlowLayout::setGeometry(const QRect &rect)\n{\n    QLayout::setGeometry(rect);\n    doLayout(rect, false);\n}\n\n//-----------------------------------------------------------------------------\n// Function: FlowLayout::sizeHint()\n//-----------------------------------------------------------------------------\nQSize FlowLayout::sizeHint() const\n{\n    return minimumSize();\n}\n\n//-----------------------------------------------------------------------------\n// Function: FlowLayout::minimumSize()\n//-----------------------------------------------------------------------------\nQSize FlowLayout::minimumSize() const\n{\n    QSize size;\n    for (const QLayoutItem *item : itemList_)\n    {\n        size = size.expandedTo(item->minimumSize());\n    }\n\n    const QMargins margins = contentsMargins();\n    size += QSize(margins.left() + margins.right(), margins.top() + margins.bottom());\n    return size;\n}\n\n//-----------------------------------------------------------------------------\n// Function: FlowLayout::doLayout()\n//-----------------------------------------------------------------------------\nint FlowLayout::doLayout(const QRect &rect, bool testOnly) const\n{\n    int left, top, right, bottom;\n    getContentsMargins(&left, &top, &right, &bottom);\n    QRect effectiveRect = rect.adjusted(+left, +top, -right, -bottom);\n    int x = effectiveRect.x();\n    int y = effectiveRect.y();\n    int lineHeight = 0;\n\n    for (QLayoutItem *item : itemList_)\n    {\n        const QWidget *wid = item->widget();\n        int spaceX = horizontalSpacing();\n        if (spaceX == -1)\n        {\n            spaceX = wid->style()->layoutSpacing(QSizePolicy::PushButton, QSizePolicy::PushButton, Qt::Horizontal);\n        }\n        int spaceY = verticalSpacing();\n        if (spaceY == -1)\n        {\n            spaceY = wid->style()->layoutSpacing(QSizePolicy::PushButton, QSizePolicy::PushButton, Qt::Vertical);\n        }\n\n        int nextX = x + item->sizeHint().width() + spaceX;\n        if (nextX - spaceX > effectiveRect.right() && lineHeight > 0)\n        {\n            x = effectiveRect.x();\n            y = y + lineHeight + spaceY;\n            nextX = x + item->sizeHint().width() + spaceX;\n            lineHeight = 0;\n        }\n\n        if (!testOnly)\n        {\n            item->setGeometry(QRect(QPoint(x, y), item->sizeHint()));\n        }\n\n        x = nextX;\n        lineHeight = qMax(lineHeight, item->sizeHint().height());\n    }\n    return y + lineHeight - rect.y() + bottom;\n}\n\n//-----------------------------------------------------------------------------\n// Function: FlowLayout::smartSpacing()\n//-----------------------------------------------------------------------------\nint FlowLayout::smartSpacing(QStyle::PixelMetric pm) const\n{\n    QObject *parent = this->parent();\n    if (!parent)\n    {\n        return -1;\n    }\n    else if (parent->isWidgetType())\n    {\n        QWidget *pw = static_cast<QWidget *>(parent);\n        return pw->style()->pixelMetric(pm, nullptr, pw);\n    }\n    else\n    {\n        return static_cast<QLayout *>(parent)->spacing();\n    }\n}\n"
  },
  {
    "path": "common/widgets/tagEditor/FlowLayout.h",
    "content": "/****************************************************************************\n**\n** Copyright (C) 2016 The Qt Company Ltd.\n** Contact: https://www.qt.io/licensing/\n**\n** This file is part of the examples of the Qt Toolkit.\n**\n** $QT_BEGIN_LICENSE:BSD$\n** Commercial License Usage\n** Licensees holding valid commercial Qt licenses may use this file in\n** accordance with the commercial license agreement provided with the\n** Software or, alternatively, in accordance with the terms contained in\n** a written agreement between you and The Qt Company. For licensing terms\n** and conditions see https://www.qt.io/terms-conditions. For further\n** information use the contact form at https://www.qt.io/contact-us.\n**\n** BSD License Usage\n** Alternatively, you may use this file under the terms of the BSD license\n** as follows:\n**\n** \"Redistribution and use in source and binary forms, with or without\n** modification, are permitted provided that the following conditions are\n** met:\n**   * Redistributions of source code must retain the above copyright\n**     notice, this list of conditions and the following disclaimer.\n**   * Redistributions in binary form must reproduce the above copyright\n**     notice, this list of conditions and the following disclaimer in\n**     the documentation and/or other materials provided with the\n**     distribution.\n**   * Neither the name of The Qt Company Ltd nor the names of its\n**     contributors may be used to endorse or promote products derived\n**     from this software without specific prior written permission.\n**\n**\n** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n** \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\"\n**\n** $QT_END_LICENSE$\n**\n****************************************************************************/\n\n#ifndef FLOWLAYOUT_H\n#define FLOWLAYOUT_H\n\n#include <QLayout>\n#include <QRect>\n#include <QStyle>\n\n//-----------------------------------------------------------------------------\n//! A space determined self adjusting layout.\n//-----------------------------------------------------------------------------\nclass FlowLayout : public QLayout\n{\npublic:\n\n    /*!\n     *  The constructor.\n     *\n     *    @param [in] parent      The parent widget.\n     *    @param [in] margin      Margin around the layout.\n     *    @param [in] hSpacing    Horizontal spacing of the items.\n     *    @param [in] vSpacing    Vertical spacing of the items.\n     */\n    explicit FlowLayout(QWidget *parent, int margin = -1, int hSpacing = -1, int vSpacing = -1);\n\n    /*!\n     *  The constructor.\n     *\n     *    @param [in] margin      Margin around the layout.\n     *    @param [in] hSpacing    Horizontal spacing of the items.\n     *    @param [in] vSpacing    Vertical spacing of the items.\n     */\n    explicit FlowLayout(int margin = -1, int hSpacing = -1, int vSpacing = -1);\n\n    /*!\n     *  The destructor.\n     */\n    ~FlowLayout();\n\n    /*!\n     *  Add a layout item to the layout.\n     *\n     *    @param [in] item    The selected layout item.\n     */\n    void addItem(QLayoutItem *item) override;\n\n    /*!\n     *  Get the current horizontal spacing.\n     *\n     *    @return The current horizontal spacing.\n     */\n    int horizontalSpacing() const;\n\n    /*!\n     *  Get the current vertical spacing.\n     *\n     *    @return The current vertical spacing.\n     */\n    int verticalSpacing() const;\n\n    /*!\n     *  Returns the direction in which the layout can use more space than allocated.\n     *\n     *    @return 0.\n     */\n    Qt::Orientations expandingDirections() const override;\n\n    /*!\n     *  Checks whether the layouts preferred height depends on width.\n     *\n     *    @return True.\n     */\n    bool hasHeightForWidth() const override;\n\n    /*!\n     *  Returns the preferred height for the selected width.\n     *\n     *    @param [in] width   The selected width.\n     *\n     *    @return The preferred height for the selected width.\n     */\n    int heightForWidth(int width) const override;\n\n    /*!\n     *  Get the number of items in the layout.\n     *\n     *    @return The number of items in the layout.\n     */\n    int count() const override;\n\n    /*!\n     *  Get the item at the selected index.\n     *\n     *    @param [in] index   Index of the selected item.\n     *\n     *    @return Item at the selected index.\n     */\n    QLayoutItem *itemAt(int index) const override;\n\n    /*!\n     *  Get the minimum size of this layout.\n     *\n     *    @return The minimum size of this layout.\n     */\n    QSize minimumSize() const override;\n\n    /*!\n     *  Calculates the geometry of the layouts items.\n     *\n     *    @param [in] rect    Rectangle of the available area.\n     */\n    void setGeometry(const QRect &rect) override;\n\n    /*!\n     *  Get the preferred size of the layout.\n     *\n     *    @return The preferred size of the layout.\n     */\n    QSize sizeHint() const override;\n\n    /*!\n     *  Remove the selected item from the layout.\n     *\n     *    @param [in] index   Index of the selected item.\n     *\n     *    @return The removed item.\n     */\n    QLayoutItem *takeAt(int index) override;\n\nprivate:\n\n    /*!\n     *  Handles the layout.\n     *\n     *    @param [in] rect        Rectangle containing the layout.\n     *    @param [in] testOnly    Holds whether the placement is being tested.\n     */\n    int doLayout(const QRect &rect, bool testOnly) const;\n\n    /*!\n     *  Get the default spacing.\n     *\n     *    @param [in] pm  The selected pixel metric.\n     */\n    int smartSpacing(QStyle::PixelMetric pm) const;\n\n    //-----------------------------------------------------------------------------\n    // Data.\n    //-----------------------------------------------------------------------------\n\n    //! List of the items in the layout.\n    QList<QLayoutItem *> itemList_;\n\n    //! Horizontal item spacing in the layout.\n    int m_hSpace_;\n\n    //! Vertical item spacing in the layout.\n    int m_vSpace_;\n};\n//! [0]\n\n#endif // FLOWLAYOUT_H"
  },
  {
    "path": "common/widgets/tagEditor/TagCompleterModel.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: TagCompleterModel.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Mikko Teuho\n// Date: 28.08.2019\n//\n// Description:\n// Model for tag completer.\n//-----------------------------------------------------------------------------\n\n#include \"TagCompleterModel.h\"\n\n#include <QColor>\n\n//-----------------------------------------------------------------------------\n// Function: TagCompleterModel::TagCompleterModel()\n//-----------------------------------------------------------------------------\nTagCompleterModel::TagCompleterModel(QVector<TagData> tagData, QObject* parent):\nQAbstractListModel(parent),\ntags_(tagData)\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: TagCompleterModel::rowCount()\n//-----------------------------------------------------------------------------\nint TagCompleterModel::rowCount(QModelIndex const& parent) const\n{\n    if (parent.isValid())\n    {\n        return 0;\n    }\n\n    return tags_.size();\n}\n\n//-----------------------------------------------------------------------------\n// Function: TagCompleterModel::data()\n//-----------------------------------------------------------------------------\nQVariant TagCompleterModel::data(const QModelIndex &index, int role /*= Qt::DisplayRole*/) const\n{\n    if (!index.isValid() || index.row() < 0 || index.row() >= rowCount())\n    {\n        return QVariant();\n    }\n\n    if (role == Qt::DisplayRole || role == Qt::EditRole)\n    {\n        QString tagName = tags_.at(index.row()).name_;\n        return tagName;\n    }\n    else if (role == Qt::DecorationRole)\n    {\n        QColor tagColor(tags_.at(index.row()).color_);\n        return tagColor;\n    }\n    else\n    {\n        return QVariant();\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: TagCompleterModel::itemSelected()\n//-----------------------------------------------------------------------------\nvoid TagCompleterModel::itemSelected(QModelIndex const& index)\n{\n    QVariant colorVariant = index.data(Qt::DecorationRole);\n    if (colorVariant.canConvert<QColor>())\n    {\n        QColor tagColor = colorVariant.value<QColor>();\n        emit selectedColor(tagColor);\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: TagCompleterModel::unfilteredItemSelected()\n//-----------------------------------------------------------------------------\nvoid TagCompleterModel::unfilteredItemSelected(int itemIndex)\n{\n    TagData indexedTag = tags_.at(itemIndex);\n\n    QColor tagColor = QColor(indexedTag.color_);\n    emit selectedColor(tagColor);\n}\n"
  },
  {
    "path": "common/widgets/tagEditor/TagCompleterModel.h",
    "content": "//-----------------------------------------------------------------------------\n// File: TagCompleterModel.h\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Mikko Teuho\n// Date: 28.08.2019\n//\n// Description:\n// Model for tag completer.\n//-----------------------------------------------------------------------------\n\n#ifndef TAGCOMPLETERMODEL_H\n#define TAGCOMPLETERMODEL_H\n\n#include <IPXACTmodels/common/TagData.h>\n\n#include <KactusAPI/include/TagManager.h>\n\n\n#include <QAbstractListModel>\n#include <QObject>\n\n//-----------------------------------------------------------------------------\n//! Model for tag completer.\n//-----------------------------------------------------------------------------\nclass TagCompleterModel : public QAbstractListModel\n{\n    Q_OBJECT\n\npublic:\n\n    /*!\n     *  The constructor.\n     *\n     *    @param [in] tagData     The available tag data.\n     *    @param [in] parent      Onwer of this model.\n     */\n    TagCompleterModel(QVector<TagData> tagData, QObject* parent = 0);\n\n    /*!\n     *  The destructor.\n     */\n    ~TagCompleterModel() = default;\n\n    /*!\n     *  Finds the number of rows in the model.\n     *\n     *    @param [in] parent   The parent index whose row count to find.\n     *\n     *    @return The number of rows in the model.\n     */\n    virtual int rowCount(QModelIndex const& parent = QModelIndex()) const;\n\n    /*!\n     *  Finds the data in the model for the given index.\n     *\n     *    @param [in] index   The index whose data to find.\n     *    @param [in] role    The role describing which aspect of the data to find.\n     *\n     *    @return The data in the given index.\n     */\n    virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;\n\npublic slots:\n\n    /*!\n     *  Handler for item selection.\n     *\n     *    @param [in] index   Index of the selected item.\n     */\n    void itemSelected(QModelIndex const& index);\n\n    /*!\n     *  Handler for item selection with item number.\n     *\n     *    @param [in] itemIndex   Index of the selected item.\n     */\n    void unfilteredItemSelected(int itemIndex);\n\nsignals:\n\n    /*!\n     *  Informs of the color of the selected item.\n     *\n     *    @param [in] itemColor   Color of the selected item.\n     */\n    void selectedColor(QColor const& itemColor);\n\nprivate:\n    // Disable copying.\n    TagCompleterModel(TagCompleterModel const& rhs);\n    TagCompleterModel& operator=(TagCompleterModel const& rhs);\n\n    //-----------------------------------------------------------------------------\n    // Data.\n    //-----------------------------------------------------------------------------\n    \n    //! List of available tags.\n    QVector<TagData> tags_;\n};\n\n//-----------------------------------------------------------------------------\n\n#endif // TAGCOMPLETERMODEL_H\n"
  },
  {
    "path": "common/widgets/tagEditor/TagContainer.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: TagContainer.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Mikko Teuho\n// Date: 14.08.2019\n//\n// Description:\n// Editor for tags.\n//-----------------------------------------------------------------------------\n\n#include \"TagContainer.h\"\n\n#include <common/widgets/tagEditor/TagDisplay.h>\n#include <common/widgets/tagEditor/FlowLayout.h>\n\n#include <IPXACTmodels/Component/Component.h>\n\n//-----------------------------------------------------------------------------\n// Function: TagContainer::TagContainer()\n//-----------------------------------------------------------------------------\nTagContainer::TagContainer(QWidget* parent):\nQWidget(parent)\n{\n    additionTag_->setToolTip(tr(\"Create new tag\"));\n    connect(additionTag_, SIGNAL(clicked(TagLabel*)), this, SLOT(createNewTag()), Qt::UniqueConnection);\n\n    setupLayout();\n    layout()->addWidget(additionTag_);\n}\n\n//-----------------------------------------------------------------------------\n// Function: TagContainer::setupTags()\n//-----------------------------------------------------------------------------\nvoid TagContainer::setupTags(QVector<TagData> documentTags)\n{\n    layout()->removeWidget(additionTag_);\n    for (auto oldTag : tags_)\n    {\n        layout()->removeWidget(oldTag);\n        oldTag->deleteLater();\n    }\n\n    tags_.clear();\n\n    for (auto const& tag : documentTags)\n    {\n        auto newTag(new TagLabel(tag.name_, this, tag.color_));\n        connectTagLabel(newTag);\n\n        tags_.append(newTag);\n        layout()->addWidget(newTag);\n    }\n\n    layout()->addWidget(additionTag_);\n}\n\n//-----------------------------------------------------------------------------\n// Function: TagContainer::connectTagLabel()\n//-----------------------------------------------------------------------------\nvoid TagContainer::connectTagLabel(QWidget* tagItem)\n{\n    connect(tagItem, SIGNAL(clicked(TagLabel*)), this, SLOT(itemClicked(TagLabel*)), Qt::UniqueConnection);\n}\n\n//-----------------------------------------------------------------------------\n// Function: TagContainer::setupLayout()\n//-----------------------------------------------------------------------------\nvoid TagContainer::setupLayout()\n{\n    auto layout = new FlowLayout(this);\n    layout->setContentsMargins(0, 0, 0, 0);\n}\n\n//-----------------------------------------------------------------------------\n// Function: TagContainer::createNewTag()\n//-----------------------------------------------------------------------------\nvoid TagContainer::createNewTag()\n{\n    layout()->removeWidget(additionTag_);\n\n    auto newLabel = new TagLabel(QStringLiteral(\"unnamed\"), this);\n    connectTagLabel(newLabel);\n    layout()->addWidget(newLabel);\n\n    tags_.append(newLabel);\n\n    layout()->addWidget(additionTag_);\n\n    itemClicked(newLabel);\n}\n\n//-----------------------------------------------------------------------------\n// Function: TagContainer::itemClicked()\n//-----------------------------------------------------------------------------\nvoid TagContainer::itemClicked(TagLabel* clickedItem)\n{\n    QVector<QWidget*> temporaryTags;\n\n    int itemIndex = tags_.indexOf(clickedItem);\n    for (int i = itemIndex + 1; i < tags_.size(); ++i)\n    {\n        temporaryTags.append(tags_.at(i));\n        layout()->removeWidget(tags_.at(i));\n    }\n\n    layout()->removeWidget(additionTag_);\n\n    clickedItem->hide();\n    layout()->removeWidget(clickedItem);\n\n    TagDisplay* newTagEditor = constructTagEditor(clickedItem);\n    for (auto newTag : temporaryTags)\n    {\n        layout()->addWidget(newTag);\n    }\n\n    layout()->addWidget(additionTag_);\n    tags_.replace(itemIndex, newTagEditor);\n\n    newTagEditor->setFocus(Qt::PopupFocusReason);\n}\n\n//-----------------------------------------------------------------------------\n// Function: TagContainer::itemChangesAccepted()\n//-----------------------------------------------------------------------------\nvoid TagContainer::itemChangesAccepted(TagLabel* editedTag, TagDisplay* tagEditor)\n{\n    if (tagExists(editedTag))\n    {\n        layout()->removeWidget(tagEditor);\n        editedTag->deleteLater();\n        tagEditor->deleteLater();\n\n        tags_.removeAt(tags_.indexOf(tagEditor));\n    }\n    else\n    {\n        editedTag->show();\n\n        int tagEditorIndex = tags_.indexOf(tagEditor);\n        tags_.replace(tagEditorIndex, editedTag);\n\n        QVector<QWidget*> temporaryTags;\n        for (int i = tagEditorIndex; i < tags_.size(); ++i)\n        {\n            temporaryTags.append(tags_.at(i));\n            layout()->removeWidget(tags_.at(i));\n        }\n        layout()->removeWidget(additionTag_);\n\n        layout()->addWidget(editedTag);\n        for (auto oldTag : temporaryTags)\n        {\n            layout()->addWidget(oldTag);\n        }\n        layout()->addWidget(additionTag_);\n\n        tagEditor->deleteLater();\n    }\n\n    emit contentChanged();\n}\n\n//-----------------------------------------------------------------------------\n// Function: TagContainer::tagExists()\n//-----------------------------------------------------------------------------\nbool TagContainer::tagExists(TagLabel* editedTag) const\n{\n    for (auto& comparisonWidget : tags_)\n    {\n        auto comparisonTag = dynamic_cast<TagLabel*>(comparisonWidget);\n        if (comparisonTag && comparisonTag->text().compare(editedTag->text()) == 0)\n        {\n            comparisonTag->setPalette(editedTag->palette());\n            return true;\n        }\n    }\n\n    return false;\n}\n\n//-----------------------------------------------------------------------------\n// Function: TagContainer::itemDeleted()\n//-----------------------------------------------------------------------------\nvoid TagContainer::itemDeleted(TagLabel* editedTag, TagDisplay* tagEditor)\n{\n    tags_.removeAt(tags_.indexOf(tagEditor));\n\n    layout()->removeWidget(editedTag);\n    layout()->removeWidget(tagEditor);\n    editedTag->deleteLater();\n    tagEditor->deleteLater();\n\n    emit contentChanged();\n}\n\n//-----------------------------------------------------------------------------\n// Function: TagContainer::getTags()\n//-----------------------------------------------------------------------------\nQVector<TagData> TagContainer::getTags() const\n{\n    QVector<TagData> finishedTags;\n\n    for (auto const& tagWidget : tags_)\n    {\n        auto tag = dynamic_cast<TagLabel*>(tagWidget);\n        if (tag)\n        {\n            QColor tagColor = tag->palette().color(QPalette::Window);\n            TagData newTagData({ tag->text(), tagColor.name() });\n\n            finishedTags.append(newTagData);\n        }\n    }\n\n    return finishedTags;\n}\n"
  },
  {
    "path": "common/widgets/tagEditor/TagContainer.h",
    "content": "//-----------------------------------------------------------------------------\n// File: TagContainer.h\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Mikko Teuho\n// Date: 14.08.2019\n//\n// Description:\n// Container for tags.\n//-----------------------------------------------------------------------------\n\n#ifndef TAGCONTAINER_H\n#define TAGCONTAINER_H\n\n#include <IPXACTmodels/common/TagData.h>\n\n#include <common/widgets/tagEditor/TagLabel.h>\n\n#include <QWidget>\n#include <QObject>\n\n\nclass TagDisplay;\n\n//-----------------------------------------------------------------------------\n//! Container for tags.\n//-----------------------------------------------------------------------------\nclass TagContainer : public QWidget\n{\n    Q_OBJECT\n\npublic:\n\n    /*!\n     *  The constructor.\n     *\n     *    @param [in] parent   The parent widget.\n     */\n    TagContainer(QWidget* parent);\n\n    /*!\n     *  The destructor.\n     */\n    virtual ~TagContainer() = default;\n\n    // Disable copying.\n    TagContainer(TagContainer const& rhs) = delete;\n    TagContainer& operator=(TagContainer const& rhs) = delete;\n\n\n    /*!\n     *  Setup the existing tags.\n     *\n     *    @param [in] documentTags    The tags of the selected document.\n     */\n    void setupTags(QVector<TagData> documentTags);\n\n    /*!\n     *  Get the tags.\n     *\n     *    @return A list of the edited document tags.\n     */\n    QVector<TagData> getTags() const;\n\nsignals:\n\n    /*!\n     *  Signaled when the tags have changed.\n     */\n    void contentChanged();\n\nprotected slots:\n\n    /*!\n     *  Handler for selecting a tag.\n     *\n     *    @param [in] clickedItem     The selected tag label.\n     */\n    void itemClicked(TagLabel* clickedItem);\n\n    /*!\n     *  Handler for accepting changes made to the selected tag label.\n     *\n     *    @param [in] editedTag   The edited tag label.\n     *    @param [in] tagEditor   Editor of the selected tag label.\n     */\n    void itemChangesAccepted(TagLabel* editedTag, TagDisplay* tagEditor);\n\n    /*!\n     *  Handler for removing a tag.\n     *\n     *    @param [in] editedTag   The edited tag label.\n     *    @param [in] tagEditor   Editor of the selected tag label.\n     */\n    void itemDeleted(TagLabel* editedTag, TagDisplay* tagEditor);\n\nprivate slots:\n\n    /*!\n     *  Handler for new tag creation.\n     */\n    void createNewTag();\n\nprotected:\n\n    /*!\n     *  Connect the selected tag label.\n     *\n     *    @param [in] tagItem The selected tag label.\n     */\n    void connectTagLabel(QWidget* tagItem);\n\nprivate:\n    /*!\n     *  Setup the layout.\n     */\n    void setupLayout();\n\n    /*!\n     *  Construct a tag editor for the selected tag label.\n     *\n     *    @param [in] editedLabel     The selected tag label.\n     *\n     *    @return The created tag editor.\n     */\n    virtual TagDisplay* constructTagEditor(TagLabel* editedLabel) = 0;\n\n    /*!\n     *  Check if the selected tag exists.\n     *\n     *    @param [in] editedTag   The selected tag.\n     *\n     *    @return True, if the tag label exists, false otherwise.\n     */\n    bool tagExists(TagLabel* editedTag) const;\n\n    //-----------------------------------------------------------------------------\n    // Data.\n    //-----------------------------------------------------------------------------\n\n    //! The button for creating new tags.\n    TagLabel* additionTag_ = new TagLabel(QStringLiteral(\"+\"), this);\n\n    //! List of all the constructed tags.\n    QVector<QWidget*> tags_;\n};\n\n//-----------------------------------------------------------------------------\n\n#endif // TAGEDITOR_H\n"
  },
  {
    "path": "common/widgets/tagEditor/TagDisplay.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: TagDisplay.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Mikko Teuho\n// Date: 03.09.2019\n//\n// Description:\n// Display for tags.\n//-----------------------------------------------------------------------------\n\n#include \"TagDisplay.h\"\n\n#include <IPXACTmodels/common/TagData.h>\n\n#include <common/widgets/tagEditor/TagLabel.h>\n#include <KactusAPI/include/TagManager.h>\n#include <common/widgets/tagEditor/TagCompleterModel.h>\n\n#include <QHBoxLayout>\n#include <QApplication>\n#include <QFocusEvent>\n\n//-----------------------------------------------------------------------------\n// Function: TagDisplay::TagDisplay()\n//-----------------------------------------------------------------------------\nTagDisplay::TagDisplay(TagLabel* tagLabel, QWidget* parent):\nQFrame(parent),\neditedLabel_(tagLabel)\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: TagDisplay::setupNameEditor()\n//-----------------------------------------------------------------------------\nvoid TagDisplay::setupEditors(QWidget* nameEditor)\n{\n    nameEditor->setFixedHeight(BUTTON_SIDE);\n\n    okButton_->setFixedHeight(BUTTON_SIDE);\n    okButton_->setFixedWidth(BUTTON_SIDE);\n\n    deleteButton_->setFixedHeight(BUTTON_SIDE);\n    deleteButton_->setFixedWidth(BUTTON_SIDE);\n\n    deleteButton_->adjustSize();\n\n    colorButton_->setToolTip(tr(\"Select Color\"));\n    okButton_->setToolTip(tr(\"Ok\"));\n    deleteButton_->setToolTip(tr(\"Delete Tag\"));\n\n    colorButton_->setColor(editedLabel_->palette().color(QPalette::Window));\n    colorButton_->update();\n    colorButton_->setVisible(showColorButton());\n\n    setupLayout(nameEditor);\n    connectSignals();\n\n    setFrameStyle(QFrame::Panel);\n    setLineWidth(1);\n}\n\n//-----------------------------------------------------------------------------\n// Function: TagDisplay::setupLayout()\n//-----------------------------------------------------------------------------\nvoid TagDisplay::setupLayout(QWidget* nameEditor)\n{\n    auto editorLayout = new QHBoxLayout(this);\n    editorLayout->setContentsMargins(1, 1, 1, 1);\n    editorLayout->setSpacing(2);\n\n    editorLayout->addWidget(nameEditor);\n    editorLayout->addWidget(colorButton_);\n    editorLayout->addWidget(okButton_);\n    editorLayout->addWidget(deleteButton_);\n}\n\n//-----------------------------------------------------------------------------\n// Function: TagDisplay::connectSignals()\n//-----------------------------------------------------------------------------\nvoid TagDisplay::connectSignals()\n{\n    connect(okButton_, SIGNAL(clicked()), this, SLOT(onAcceptChanges()), Qt::UniqueConnection);\n    connect(deleteButton_, SIGNAL(clicked()), this, SLOT(onDeleteItem()), Qt::UniqueConnection);\n}\n\n//-----------------------------------------------------------------------------\n// Function: TagDisplay::completerColorChange()\n//-----------------------------------------------------------------------------\nvoid TagDisplay::completerColorChange(QColor const& newColor)\n{\n    colorButton_->setColor(newColor);\n    colorButton_->update();\n}\n\n//-----------------------------------------------------------------------------\n// Function: TagDisplay::onAcceptChanges()\n//-----------------------------------------------------------------------------\nvoid TagDisplay::onAcceptChanges()\n{\n    if (QString newName = getNewName(); !newName.isEmpty())\n    {\n        editedLabel_->setText(newName);\n    }\n\n    editedLabel_->setPalette(colorButton_->palette());\n\n    emit acceptChanges(editedLabel_, this);\n}\n\n//-----------------------------------------------------------------------------\n// Function: TagDisplay::onDeleteItem()\n//-----------------------------------------------------------------------------\nvoid TagDisplay::onDeleteItem()\n{\n    emit deleteItem(editedLabel_, this);\n}\n\n//-----------------------------------------------------------------------------\n// Function: TagDisplay::focusOutEvent()\n//-----------------------------------------------------------------------------\nvoid TagDisplay::focusOutEvent(QFocusEvent* /*event*/)\n{\n    if ((QApplication::focusWidget() && QApplication::focusWidget()->parentWidget() == this) ||\n        (QApplication::activeWindow() && QApplication::activeWindow()->parentWidget() == this))\n    {\n        return;\n    }\n    else\n    {\n        onAcceptChanges();\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: TagDisplay::eventFilter()\n//-----------------------------------------------------------------------------\nbool TagDisplay::eventFilter(QObject *watched, QEvent *event)\n{\n    if (event->type() == QEvent::FocusOut)\n    {\n        focusOutEvent(dynamic_cast<QFocusEvent*>(event));\n        return true;\n    }\n    else\n    {\n        return QFrame::eventFilter(watched, event);\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: TagDisplay::showColorButton()\n//-----------------------------------------------------------------------------\nbool TagDisplay::showColorButton() const noexcept\n{\n    return false;\n}\n\n//-----------------------------------------------------------------------------\n// Function: TagDisplay::keyPressEvent()\n//-----------------------------------------------------------------------------\nvoid TagDisplay::keyPressEvent(QKeyEvent *event)\n{\n    QFrame::keyPressEvent(event);\n\n    if (event->key() == Qt::Key_Enter || event->key() == Qt::Key_Return)\n    {\n        onAcceptChanges();\n    }\n    else if (event->key() == Qt::Key_Escape)\n    {\n        emit acceptChanges(editedLabel_, this);\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: TagDisplay::getColorButton()\n//-----------------------------------------------------------------------------\nColorBox* TagDisplay::getColorButton()\n{\n    return colorButton_;\n}\n\n//-----------------------------------------------------------------------------\n// Function: TagDisplay::getEditedLabel()\n//-----------------------------------------------------------------------------\nTagLabel* TagDisplay::getEditedLabel() const\n{\n    return editedLabel_;\n}\n"
  },
  {
    "path": "common/widgets/tagEditor/TagDisplay.h",
    "content": "//-----------------------------------------------------------------------------\n// File: TagDisplay.h\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Mikko Teuho\n// Date: 03.09.2019\n//\n// Description:\n// Display for tags.\n//-----------------------------------------------------------------------------\n\n#ifndef TAGDISPLAY_H\n#define TAGDISPLAY_H\n\n#include <QFrame>\n#include <QObject>\n#include <QPushButton>\n\n#include <common/widgets/colorBox/ColorBox.h>\n\nclass TagLabel;\n\n//-----------------------------------------------------------------------------\n//! Display for tags.\n//-----------------------------------------------------------------------------\nclass TagDisplay : public QFrame\n{\n    Q_OBJECT\n\npublic:\n\n    /*!\n     *  The constructor.\n     *\n     *    @param [in] tagLabel    The tag label being edited.\n     *    @param [in] parent      The parent widget.\n     */\n    TagDisplay(TagLabel* tagLabel, QWidget* parent = nullptr);\n\n    /*!\n     *  The destructor.\n     */\n    virtual ~TagDisplay() = default;\n\n    // Disable copying.\n    TagDisplay(TagDisplay const& rhs) = delete;\n    TagDisplay& operator=(TagDisplay const& rhs) = delete;\n\n    /*!\n     *  The event filter.\n     *\n     *    @param [in] watched     The monitored object.\n     *    @param [in] event       The occurring event.\n     *\n     *    @return True, if the event is caught, false otherwise.\n     */\n    bool eventFilter(QObject *watched, QEvent *event) final;\n\n\nprotected:\n    \n    /*!\n     *  Check if color selection button should be shown.\n     *\n     *    @return True, if button should be shown, otherwise false.\n     */\n    virtual bool showColorButton() const noexcept;\n\n    /*!\n     *  Handler for focus out events.\n     *\n     *    @param [in] event   The focus event.\n     */\n    void focusOutEvent(QFocusEvent* event) final;\n\n    /*!\n     *  Handler for key press events.\n     *\n     *    @param [in] event   The key event.\n     */\n    void keyPressEvent(QKeyEvent *event) final;\n    \n    /*!\n     *  Get the color display button.\n     *\n     *    @return The color display button.\n     */\n    ColorBox* getColorButton();\n\n    /*!\n     *  Get the edited tag label.\n     *\n     *    @return The edited tag label.\n     */\n    TagLabel* getEditedLabel() const;\n\n    /*!\n     *  Connect signals.\n     */\n    virtual void connectSignals();\n\n    /*!\n     *  Setup the tag editors.\n     *\n     *    @param [in] nameEditor  The name editor for the tag.\n     */\n    virtual void setupEditors(QWidget* nameEditor);\n\nprotected slots:\n\n    /*!\n     *  Handler for changing color through completer.\n     *\n     *    @param [in] newColor    The color of the selected completer item.\n     */\n    void completerColorChange(QColor const& newColor);\n\nsignals:\n\n    /*!\n     *  Signals the accepted changes made in the editor.\n     *\n     *    @param [in] editedLabel     The edited tag label.\n     *    @param [in] tagEditor       This editor.\n     */\n    void acceptChanges(TagLabel* editedLabel, TagDisplay* tagEditor);\n\n    /*!\n     *  Signals the removal of this tag label.\n     *\n     *    @param [in] editedLabel     The edited tag label.\n     *    @param [in] tagEditor       This editor.\n     */\n    void deleteItem(TagLabel* editedLabel, TagDisplay* tagEditor);\n\nprivate slots:\n\n    /*!\n     *  Handler for accepting changes.\n     */\n    void onAcceptChanges();\n\n    /*!\n     *  Handler for deleting item.\n     */\n    void onDeleteItem();\n\nprivate:\n\n    /*!\n     *  Setup the layout.\n     *\n     *    @param [in] nameEditor  Name editor of the tag.\n     */\n    void setupLayout(QWidget* nameEditor);\n\n    /*!\n     *  Get the current name from the name editor.\n     *\n     *    @return The current name of the name editor.\n     */\n    virtual QString getNewName() const = 0;\n\n    //-----------------------------------------------------------------------------\n    // Data.\n    //-----------------------------------------------------------------------------\n\n    constexpr static int BUTTON_SIDE = 20;\n\n    //! Tag color editor.\n    ColorBox* colorButton_ =\n         new ColorBox(QSize(BUTTON_SIDE, BUTTON_SIDE), this);\n\n    //! Accept tag button.\n    QPushButton* okButton_ = new QPushButton(\n        QIcon(QStringLiteral(\":/icons/common/graphics/checkMark.png\")), QString(), this);\n\n    //! Delete tag button.\n    QPushButton* deleteButton_ = new QPushButton(\n        QIcon(QStringLiteral(\":/icons/common/graphics/cross.png\")), QString(), this);\n\n    //! The edited tag label.\n    TagLabel* editedLabel_;\n};\n\n//-----------------------------------------------------------------------------\n\n#endif // TAGDISPLAY_H\n"
  },
  {
    "path": "common/widgets/tagEditor/TagEditor.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: TagEditor.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Mikko Teuho\n// Date: 15.08.2019\n//\n// Description:\n// Editor for tags.\n//-----------------------------------------------------------------------------\n\n#include \"TagEditor.h\"\n\n#include <common/widgets/colorBox/ColorBox.h>\n#include <common/widgets/tagEditor/TagLabel.h>\n#include <KactusAPI/include/TagManager.h>\n#include <common/widgets/tagEditor/TagCompleterModel.h>\n\n#include <QColorDialog>\n#include <QCompleter>\n#include <QAction>\n\n//-----------------------------------------------------------------------------\n// Function: TagEditor::TagEditor()\n//-----------------------------------------------------------------------------\nTagEditor::TagEditor(TagLabel* tagLabel, QWidget* parent):\nTagDisplay(tagLabel, parent)\n{\n    TagEditor::setupEditors(nameEdit_);\n}\n\n//-----------------------------------------------------------------------------\n// Function: TagEditor::showColorButton()\n//-----------------------------------------------------------------------------\nbool TagEditor::showColorButton() const noexcept\n{\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: TagEditor::connectSignals()\n//-----------------------------------------------------------------------------\nvoid TagEditor::connectSignals()\n{\n    connect(getColorButton(), SIGNAL(clicked()), this, SLOT(changeColor()), Qt::UniqueConnection);\n\n    TagDisplay::connectSignals();\n}\n\n//-----------------------------------------------------------------------------\n// Function: TagEditor::setupEditors()\n//-----------------------------------------------------------------------------\nvoid TagEditor::setupEditors(QWidget* nameEditor)\n{\n    TagDisplay::setupEditors(nameEditor);\n\n    setFocusProxy(nameEdit_);\n    nameEdit_->installEventFilter(this);\n\n    auto completer = new QCompleter(this);\n\n    auto completerModel = new TagCompleterModel(TagManager::getInstance().getTags(), completer);\n    completer->setModel(completerModel);\n\n    completer->setCaseSensitivity(Qt::CaseInsensitive);\n\n    auto action = new QAction(this);\n    action->setShortcut(QKeySequence(Qt::CTRL | Qt::Key_Space));\n    action->setShortcutContext(Qt::WidgetShortcut);\n\n    connect(action, SIGNAL(triggered()), completer, SLOT(complete()), Qt::UniqueConnection);\n    connect(completer, SIGNAL(activated(QModelIndex const&)),\n        completerModel, SLOT(itemSelected(QModelIndex const&)), Qt::UniqueConnection);\n    connect(completerModel, SIGNAL(selectedColor(QColor const&)),\n        this, SLOT(completerColorChange(QColor const&)), Qt::UniqueConnection);\n\n    nameEdit_->addAction(action);\n    nameEdit_->setCompleter(completer);\n    nameEdit_->setFixedWidth(80);\n    nameEdit_->setText(getEditedLabel()->text());\n}\n\n//-----------------------------------------------------------------------------\n// Function: TagEditor::changeColor()\n//-----------------------------------------------------------------------------\nvoid TagEditor::changeColor()\n{\n    auto colorButton = getColorButton();\n\n    QColorDialog dialog(this);\n    dialog.setCurrentColor(colorButton->getColor());\n    if (dialog.exec() == QDialog::Accepted)\n    {\n        colorButton->setColor(dialog.currentColor());\n        colorButton->update();\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: TagEditor::getNewName()\n//-----------------------------------------------------------------------------\nQString TagEditor::getNewName() const\n{\n    return nameEdit_->text();\n}\n"
  },
  {
    "path": "common/widgets/tagEditor/TagEditor.h",
    "content": "//-----------------------------------------------------------------------------\n// File: TagEditor.h\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Mikko Teuho\n// Date: 15.08.2019\n//\n// Description:\n// Editor for tags.\n//-----------------------------------------------------------------------------\n\n#ifndef TAGEDITOR_H\n#define TAGEDITOR_H\n\n#include <common/widgets/tagEditor/TagDisplay.h>\n\n#include <QLineEdit>\n\nclass TagLabel;\n\n//-----------------------------------------------------------------------------\n//! Editor for tags.\n//-----------------------------------------------------------------------------\nclass TagEditor : public TagDisplay\n{\n    Q_OBJECT\n\npublic:\n\n    /*!\n     *  The constructor.\n     *\n     *    @param [in] tagLabel    The tag label being edited.\n     *    @param [in] parent      The parent widget.\n     */\n    TagEditor(TagLabel* tagLabel, QWidget* parent = nullptr);\n\n    /*!\n     *  The destructor.\n     */\n    virtual ~TagEditor() = default;\n\n    // Disable copying.\n    TagEditor(TagEditor const& rhs) = delete;\n    TagEditor& operator=(TagEditor const& rhs) = delete;\n\nprotected:\n\n    /*!\n     *  Check if color selection button should be shown.\n     *\n     *    @return True, if button should be shown, otherwise false.\n     */\n    bool showColorButton() const noexcept final;\n\n    /*!\n     *  Connect signals.\n     */\n    virtual void connectSignals();\n\n    /*!\n     *  Setup the tag editors.\n     *\n     *    @param [in] nameEditor  The name editor for the tag.\n     */\n    virtual void setupEditors(QWidget* nameEditor);\n\nprivate slots:\n\n    /*!\n     *  Handler for changing the color.\n     */\n    void changeColor();\n\nprivate:\n\n    /*!\n     *  Get the current name from the name editor.\n     *\n     *    @return The current name of the name editor.\n     */\n    virtual QString getNewName() const override final;\n\n    //-----------------------------------------------------------------------------\n    // Data.\n    //-----------------------------------------------------------------------------\n\n    //! Tag name editor.\n    QLineEdit* nameEdit_ = new QLineEdit(this);\n};\n\n//-----------------------------------------------------------------------------\n\n#endif // TAGEDITOR_H\n"
  },
  {
    "path": "common/widgets/tagEditor/TagEditorContainer.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: TagEditorContainer.h\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Mikko Teuho\n// Date: 03.09.2019\n//\n// Description:\n// Container for editable tags.\n//-----------------------------------------------------------------------------\n\n#include \"TagEditorContainer.h\"\n\n#include <common/widgets/tagEditor/TagLabel.h>\n#include <common/widgets/tagEditor/TagEditor.h>\n\n#include <QLayout>\n\n//-----------------------------------------------------------------------------\n// Function: TagEditorContainer::TagEditorContainer()\n//-----------------------------------------------------------------------------\nTagEditorContainer::TagEditorContainer(QWidget* parent):\nTagContainer(parent)\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: TagEditorContainer::constructTagEditor()\n//-----------------------------------------------------------------------------\nTagDisplay* TagEditorContainer::constructTagEditor(TagLabel* editedLabel)\n{\n    auto newTagEditor(new TagEditor(editedLabel, this));\n\n    connect(newTagEditor, SIGNAL(acceptChanges(TagLabel*, TagDisplay*)),\n        this, SLOT(itemChangesAccepted(TagLabel*, TagDisplay*)), Qt::UniqueConnection);\n    connect(newTagEditor, SIGNAL(deleteItem(TagLabel*, TagDisplay*)),\n        this, SLOT(itemDeleted(TagLabel*, TagDisplay*)), Qt::UniqueConnection);\n\n    layout()->addWidget(newTagEditor);\n\n    return newTagEditor;\n}\n"
  },
  {
    "path": "common/widgets/tagEditor/TagEditorContainer.h",
    "content": "//-----------------------------------------------------------------------------\n// File: TagEditorContainer.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Mikko Teuho\n// Date: 03.09.2019\n//\n// Description:\n// Container for editable tags.\n//-----------------------------------------------------------------------------\n\n#ifndef TAGEDITORCONTAINER_H\n#define TAGEDITORCONTAINER_H\n\n#include <common/widgets/tagEditor/TagContainer.h>\n\n//-----------------------------------------------------------------------------\n//! Container for editable tags.\n//-----------------------------------------------------------------------------\nclass TagEditorContainer : public TagContainer\n{\n    Q_OBJECT\n\npublic:\n\n    /*!\n     *  The constructor.\n     *\n     *    @param [in] parent   The parent widget.\n     */\n    TagEditorContainer(QWidget* parent);\n\n    /*!\n     *  The destructor.\n     */\n    virtual ~TagEditorContainer() = default;\n\n    // Disable copying.\n    TagEditorContainer(TagEditorContainer const& rhs) = delete;\n    TagEditorContainer& operator=(TagEditorContainer const& rhs) = delete;\n\nprivate:\n\n    /*!\n     *  Construct a tag editor for the selected tag label.\n     *\n     *    @param [in] editedLabel     The selected tag label.\n     *\n     *    @return The created tag editor.\n     */\n    virtual TagDisplay* constructTagEditor(TagLabel* editedLabel) final;\n};\n\n//-----------------------------------------------------------------------------\n\n#endif // TAGEDITORCONTAINER_H\n"
  },
  {
    "path": "common/widgets/tagEditor/TagLabel.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: TagLabel.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Mikko Teuho\n// Date: 14.08.2019\n//\n// Description:\n// The tag label.\n//-----------------------------------------------------------------------------\n\n#include \"TagLabel.h\"\n\n//-----------------------------------------------------------------------------\n// Function: TagLabel::TagLabel()\n//-----------------------------------------------------------------------------\nTagLabel::TagLabel(QString const& tagName, QWidget* parent, QString const& labelColor):\nQLabel(tagName, parent)\n{\n    setContentsMargins(5, 3, 5, 3);\n\n    setAutoFillBackground(true);\n    QPalette labelPalette = palette();\n    labelPalette.setColor(QPalette::Window, QColor(labelColor));\n    setPalette(labelPalette);\n\n    setCursor(Qt::PointingHandCursor);\n}\n\n//-----------------------------------------------------------------------------\n// Function: TagLabel::mouseReleaseEvent()\n//-----------------------------------------------------------------------------\nvoid TagLabel::mouseReleaseEvent(QMouseEvent *ev)\n{\n    QLabel::mouseReleaseEvent(ev);\n\n    emit clicked(this);\n}\n"
  },
  {
    "path": "common/widgets/tagEditor/TagLabel.h",
    "content": "//-----------------------------------------------------------------------------\n// File: TagLabel.h\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Mikko Teuho\n// Date: 14.08.2019\n//\n// Description:\n// The tag label.\n//-----------------------------------------------------------------------------\n\n#ifndef TAGLABEL_H\n#define TAGLABEL_H\n\n#include <QLabel>\n\n//-----------------------------------------------------------------------------\n//! The tag label.\n//-----------------------------------------------------------------------------\nclass TagLabel : public QLabel\n{\n    Q_OBJECT\n\npublic:\n\n    /*!\n     *  The constructor.\n     *\n     *    @param [in] tagName     Name of the tag.\n     *    @param [in] parent      The parent widget.\n     *    @param [in] labelColor  Color of the tag.\n     */\n    TagLabel(QString const& tagName, QWidget* parent = 0, QString const& labelColor = QLatin1String(\"#DAE1DF\"));\n\n    /*!\n     *  The destructor.\n     */\n    virtual ~TagLabel() = default;\n\nsignals:\n\n    /*!\n     *  Signal for informing tag label click.\n     *\n     *    @param [in] labelItem   This label.\n     */\n    void clicked(TagLabel* labelItem);\n\nprotected:\n\n    /*!\n     *  Event handling for mouse release.\n     *\n     *    @param [in] ev  The mouse event.\n     */\n    virtual void mouseReleaseEvent(QMouseEvent *ev) final;\n\nprivate:\n    // Disable copying.\n    TagLabel(TagLabel const& rhs);\n    TagLabel& operator=(TagLabel const& rhs);\n};\n\n//-----------------------------------------------------------------------------\n\n#endif // TAGLABEL_H\n"
  },
  {
    "path": "common/widgets/tagEditor/TagSelector.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: TagSelector.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Mikko Teuho\n// Date: 04.09.2019\n//\n// Description:\n// Selector for tags.\n//-----------------------------------------------------------------------------\n\n#include \"TagSelector.h\"\n\n#include <common/widgets/tagEditor/TagLabel.h>\n#include <KactusAPI/include/TagManager.h>\n#include <common/widgets/tagEditor/TagCompleterModel.h>\n\n//-----------------------------------------------------------------------------\n// Function: TagSelector::TagSelector()\n//-----------------------------------------------------------------------------\nTagSelector::TagSelector(TagLabel* tagLabel, QWidget* parent):\nTagDisplay(tagLabel, parent),\nnameEdit_(new QComboBox(this))\n{\n    setupEditors(nameEdit_);\n}\n\n//-----------------------------------------------------------------------------\n// Function: TagSelector::setupEditors()\n//-----------------------------------------------------------------------------\nvoid TagSelector::setupEditors(QWidget* nameEditor)\n{\n    TagDisplay::setupEditors(nameEditor);\n\n    TagCompleterModel* nameSelectorModel = new TagCompleterModel(TagManager::getInstance().getTags(), nameEdit_);\n\n    connect(nameEdit_, SIGNAL(currentIndexChanged(int)),\n        nameSelectorModel, SLOT(unfilteredItemSelected(int)), Qt::UniqueConnection);\n    connect(nameSelectorModel, SIGNAL(selectedColor(QColor const&)),\n        this, SLOT(completerColorChange(QColor const&)), Qt::UniqueConnection);\n\n    nameEdit_->setModel(nameSelectorModel);\n    nameEdit_->setFixedWidth(80);\n\n    int currentItemIndex = nameEdit_->findText(getEditedLabel()->text());\n    if (currentItemIndex < 0)\n    {\n        currentItemIndex = 0;\n    }\n\n    nameEdit_->setCurrentIndex(currentItemIndex);\n}\n\n//-----------------------------------------------------------------------------\n// Function: TagSelector::getNewName()\n//-----------------------------------------------------------------------------\nQString TagSelector::getNewName() const\n{\n    return nameEdit_->currentText();\n}\n"
  },
  {
    "path": "common/widgets/tagEditor/TagSelector.h",
    "content": "//-----------------------------------------------------------------------------\n// File: TagSelector.h\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Mikko Teuho\n// Date: 04.09.2019\n//\n// Description:\n// Selector for tags.\n//-----------------------------------------------------------------------------\n\n#ifndef TAGSELECTOR_H\n#define TAGSELECTOR_H\n\n#include <common/widgets/tagEditor/TagDisplay.h>\n\n#include <QComboBox>\n\nclass TagLabel;\n\n//-----------------------------------------------------------------------------\n//! Selector for tags.\n//-----------------------------------------------------------------------------\nclass TagSelector : public TagDisplay\n{\n    Q_OBJECT\n\npublic:\n\n    /*!\n     *  The constructor.\n     *\n     *    @param [in] tagLabel    The tag label being edited.\n     *    @param [in] parent      The parent widget.\n     */\n    TagSelector(TagLabel* tagLabel, QWidget* parent = 0);\n\n    /*!\n     *  The destructor.\n     */\n    virtual ~TagSelector() = default;\n\nprotected:\n\n    /*!\n     *  Setup the tag editors.\n     *\n     *    @param [in] nameEditor  The name editor for the tag.\n     */\n    virtual void setupEditors(QWidget* nameEditor);\n\nprivate:\n    // Disable copying.\n    TagSelector(TagSelector const& rhs);\n    TagSelector& operator=(TagSelector const& rhs);\n\n    /*!\n     *  Get the current name from the name editor.\n     *\n     *    @return The current name of the name editor.\n     */\n    virtual QString getNewName() const override final;\n\n    //-----------------------------------------------------------------------------\n    // Data.\n    //-----------------------------------------------------------------------------\n\n    //! Tag name selector.\n    QComboBox* nameEdit_;\n};\n\n//-----------------------------------------------------------------------------\n\n#endif // TAGSELECTOR_H\n"
  },
  {
    "path": "common/widgets/tagEditor/TagSelectorContainer.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: TagSelectorContainer.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Mikko Teuho\n// Date: 03.09.2019\n//\n// Description:\n// Container for displayed tags.\n//-----------------------------------------------------------------------------\n\n#include \"TagSelectorContainer.h\"\n\n#include <common/widgets/tagEditor/TagLabel.h>\n#include <common/widgets/tagEditor/TagSelector.h>\n\n#include <QLayout>\n\n//-----------------------------------------------------------------------------\n// Function: TagSelectorContainer::TagSelectorContainer()\n//-----------------------------------------------------------------------------\nTagSelectorContainer::TagSelectorContainer(QWidget* parent):\nTagContainer(parent)\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: TagSelectorContainer::constructTagEditor()\n//-----------------------------------------------------------------------------\nTagDisplay* TagSelectorContainer::constructTagEditor(TagLabel* editedLabel)\n{\n    TagSelector* newTagEditor(new TagSelector(editedLabel, this));\n\n    connect(newTagEditor, SIGNAL(acceptChanges(TagLabel*, TagDisplay*)),\n        this, SLOT(itemChangesAccepted(TagLabel*, TagDisplay*)), Qt::UniqueConnection);\n    connect(newTagEditor, SIGNAL(deleteItem(TagLabel*, TagDisplay*)),\n        this, SLOT(itemDeleted(TagLabel*, TagDisplay*)), Qt::UniqueConnection);\n\n    layout()->addWidget(newTagEditor);\n\n    return newTagEditor;\n}\n"
  },
  {
    "path": "common/widgets/tagEditor/TagSelectorContainer.h",
    "content": "//-----------------------------------------------------------------------------\n// File: TagSelectorContainer.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Mikko Teuho\n// Date: 03.09.2019\n//\n// Description:\n// Container for tag selectors.\n//-----------------------------------------------------------------------------\n\n#ifndef TAGSELECTORCONTAINER_H\n#define TAGSELECTORCONTAINER_H\n\n#include <common/widgets/tagEditor/TagContainer.h>\n\n//-----------------------------------------------------------------------------\n//! Container for tag selectors.\n//-----------------------------------------------------------------------------\nclass TagSelectorContainer : public TagContainer\n{\n    Q_OBJECT\n\npublic:\n\n    /*!\n     *  The constructor.\n     *\n     *    @param [in] parent   The parent widget.\n     */\n    TagSelectorContainer(QWidget* parent);\n\n    /*!\n     *  The destructor.\n     */\n    virtual ~TagSelectorContainer() = default;\n\nprivate:\n    // Disable copying.\n    TagSelectorContainer(TagSelectorContainer const& rhs);\n    TagSelectorContainer& operator=(TagSelectorContainer const& rhs);\n\n    /*!\n     *  Construct a tag editor for the selected tag label.\n     *\n     *    @param [in] editedLabel     The selected tag label.\n     *\n     *    @return The created tag editor.\n     */\n    virtual TagDisplay* constructTagEditor(TagLabel* editedLabel) final;\n};\n\n//-----------------------------------------------------------------------------\n\n#endif // TAGSELECTORCONTAINER_H\n"
  },
  {
    "path": "common/widgets/testConstraintComboBox/testconstraintcombobox.cpp",
    "content": "/* \r\n *  \tCreated on: 27.8.2012\r\n *      Author: Antti Kamppi\r\n * \t\tfilename: testconstraintcombobox.cpp\r\n *\t\tProject: Kactus 2\r\n */\r\n\r\n#include \"testconstraintcombobox.h\"\r\n\r\nTestConstraintComboBox::TestConstraintComboBox(QWidget *parent):\r\nQComboBox(parent) {\r\n\tsetEditable(false);\r\n\r\n\tfor (unsigned int i = 0; i <= General::TESTCONSTRAINT_COUNT; ++i) {\r\n\t\taddItem(General::TEST_CONSTRAINT_STRINGS[i]);\r\n\t}\r\n}\r\n\r\nTestConstraintComboBox::~TestConstraintComboBox() {\r\n}\r\n\r\nGeneral::TestConstraint TestConstraintComboBox::getCurrentValue() const {\r\n\treturn static_cast<General::TestConstraint>(currentIndex());\r\n}\r\n\r\nvoid TestConstraintComboBox::setCurrentValue( General::TestConstraint testConstraint ) {\r\n\tsetCurrentIndex(testConstraint);\r\n}\r\n"
  },
  {
    "path": "common/widgets/testConstraintComboBox/testconstraintcombobox.h",
    "content": "/* \r\n *  \tCreated on: 27.8.2012\r\n *      Author: Antti Kamppi\r\n * \t\tfilename: testconstraintcombobox.h\r\n *\t\tProject: Kactus 2\r\n */\r\n\r\n#ifndef TESTCONSTRAINTCOMBOBOX_H\r\n#define TESTCONSTRAINTCOMBOBOX_H\r\n\r\n#include <IPXACTmodels/generaldeclarations.h>\r\n\r\n#include <QComboBox>\r\n\r\n/*! \\brief The combo box to select one of the defined test constraints.\r\n *\r\n */\r\nclass TestConstraintComboBox : public QComboBox {\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\r\n\t/*! \\brief The constructor\r\n\t *\r\n\t * \\param parent Pointer to the owner of the combo box.\r\n\t *\r\n\t*/\r\n\tTestConstraintComboBox(QWidget *parent);\r\n\t\r\n\t//! \\brief The destructor\r\n\tvirtual ~TestConstraintComboBox();\r\n\r\n\t/*! \\brief Get the currently selected test constraint.\r\n\t *\r\n\t * \\return The currently selected test constraint.\r\n\t*/\r\n\tGeneral::TestConstraint getCurrentValue() const;\r\n\r\n\t/*! \\brief Set the currently selected value.\r\n\t *\r\n\t * \\param testConstraint The test constraint to select.\r\n\t *\r\n\t*/\r\n\tvoid setCurrentValue(General::TestConstraint testConstraint);\r\n\r\nprivate:\r\n\r\n\t//! \\brief No copying\r\n\tTestConstraintComboBox(const TestConstraintComboBox& other);\r\n\r\n\t//! \\brief No assignment\r\n\tTestConstraintComboBox& operator=(const TestConstraintComboBox& other);\r\n};\r\n\r\n#endif // TESTCONSTRAINTCOMBOBOX_H\r\n"
  },
  {
    "path": "common/widgets/usageComboBox/usagecombobox.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: usagecombobox.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Antti Kamppi\r\n// Date: 23.08.2012\r\n//\r\n// Description:\r\n// The combo box to select one of the defined usage types.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"usagecombobox.h\"\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: usagecombobox::UsageComboBox()\r\n//-----------------------------------------------------------------------------\r\nUsageComboBox::UsageComboBox(QWidget *parent):\r\nQComboBox(parent)\r\n{\r\n\t// add items for all available usage-values\r\n\tfor (int i = 0; i <= General::USAGE_COUNT; ++i)\r\n    {\r\n\t\tQString text = General::usage2Str(static_cast<General::Usage>(i));\r\n\t\taddItem(text);\r\n\t}\r\n\r\n\t// only the available options can be selected\r\n\tsetEditable(false);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: usagecombobox::~UsageComboBox()\r\n//-----------------------------------------------------------------------------\r\nUsageComboBox::~UsageComboBox()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: usagecombobox::getCurrentValue()\r\n//-----------------------------------------------------------------------------\r\nGeneral::Usage UsageComboBox::getCurrentValue() const\r\n{\r\n\treturn static_cast<General::Usage>(currentIndex());\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: usagecombobox::setCurrentValue()\r\n//-----------------------------------------------------------------------------\r\nvoid UsageComboBox::setCurrentValue( General::Usage usage )\r\n{\r\n\tsetCurrentIndex(usage);\r\n}\r\n"
  },
  {
    "path": "common/widgets/usageComboBox/usagecombobox.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: usagecombobox.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Antti Kamppi\r\n// Date: 23.08.2012\r\n//\r\n// Description:\r\n// The combo box to select one of the defined usage types.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef USAGECOMBOBOX_H\r\n#define USAGECOMBOBOX_H\r\n\r\n#include <IPXACTmodels/generaldeclarations.h>\r\n\r\n#include <QComboBox>\r\n\r\n//-----------------------------------------------------------------------------\r\n//! The combo box to select one of the defined usage types.\r\n//-----------------------------------------------------------------------------\r\nclass UsageComboBox : public QComboBox\r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\r\n\t/*!\r\n     *  The constructor.\r\n\t *\r\n     *      param [in] parent   Pointer to the owner of the combo box.\r\n\t */\r\n\tUsageComboBox(QWidget *parent);\r\n\t\r\n\t//! The destructor.\r\n\tvirtual ~UsageComboBox();\r\n\r\n\t/*!\r\n     *  Get the currently selected value on the combo box.\r\n\t *\r\n\t *    @return The selected usage value.\r\n\t */\r\n\tGeneral::Usage getCurrentValue() const;\r\n\r\n\t/*!\r\n     *  Set the given usage value as the selected value.\r\n\t *\r\n\t *    @param [in] usage   The value to select.\r\n\t */\r\n\tvoid setCurrentValue(General::Usage usage);\r\n\r\nprivate:\r\n\t\r\n\t//! No copying.\r\n\tUsageComboBox(const UsageComboBox& other);\r\n\r\n\t//! No assignment.\r\n\tUsageComboBox& operator=(const UsageComboBox& other);\r\n};\r\n\r\n#endif // USAGECOMBOBOX_H\r\n"
  },
  {
    "path": "common/widgets/viewSelector/viewselector.cpp",
    "content": "/* \r\n *\tCreated on:\t28.3.2013\r\n *\tAuthor:\t\tAntti Kamppi\r\n *\tFile name:\tviewselector.cpp\r\n *\tProject:\t\tKactus 2\r\n*/\r\n\r\n#include \"viewselector.h\"\r\n\r\nViewSelector::ViewSelector( ViewType mode, QSharedPointer<Component> component, QWidget *parent, bool allowEmpty):\r\nQComboBox(parent),\r\nmode_(mode),\r\ncomponent_(component),\r\nallowEmpty_(allowEmpty) {\r\n\r\n\tQ_ASSERT(component_);\r\n\r\n\tsetEditable(false);\r\n\r\n\tconnect(this, SIGNAL(currentIndexChanged(int)),\r\n\t\tthis, SLOT(onIndexChange(int)), Qt::UniqueConnection);\r\n}\r\n\r\nViewSelector::~ViewSelector() {\r\n}\r\n\r\nvoid ViewSelector::refresh() {\r\n\tdisconnect(this, SIGNAL(currentIndexChanged(int)),\r\n\t\tthis, SLOT(onIndexChange(int)));\r\n\r\n\t// remove the previous items\r\n\tclear();\r\n\r\n\tQStringList viewNames;\r\n\r\n\t// the mode specifies the available view types\r\n\tswitch (mode_) {\r\n\tcase ViewSelector::FLAT_HW_VIEWS: {\r\n\t\tviewNames = component_->getFlatViews();\r\n\t\tbreak;\r\n\t\t\t\t\t\t\t\t\t\t\t\t }\r\n\tcase ViewSelector::HIER_HW_VIEWS: {\r\n\t\tviewNames = component_->getHierViews();\r\n\t\tbreak;\r\n\t\t\t\t\t\t\t\t\t\t\t\t }\r\n\tcase ViewSelector::BOTH_HW_VIEWS: {\r\n\t\tviewNames = component_->getFlatViews();\r\n\t\tviewNames += component_->getHierViews();\r\n\t\tbreak;\r\n\t\t\t\t\t\t\t\t\t\t\t\t }\r\n\tcase ViewSelector::SYSTEM_VIEWS: {\r\n\t\tviewNames = component_->getSystemViewNames();\r\n\t\tbreak;\r\n\t\t\t\t\t\t\t\t\t\t\t\t}\r\n\tdefault: {\r\n\t\tbreak;\r\n\t\t\t\t}\r\n\t}\t\r\n\t\r\n\tif (allowEmpty_) {\r\n\t\taddItem(\"\");\r\n\t}\r\n\r\n\taddItems(viewNames);\r\n\r\n\tconnect(this, SIGNAL(currentIndexChanged(int)),\r\n\t\tthis, SLOT(onIndexChange(int)), Qt::UniqueConnection);\r\n}\r\n\r\nvoid ViewSelector::selectView( const QString& viewName ) {\r\n\tdisconnect(this, SIGNAL(currentIndexChanged(int)),\r\n\t\tthis, SLOT(onIndexChange(int)));\r\n\tint index = findText(viewName);\r\n\t\r\n\t// if the item is not found\r\n\tif (index < 0) {\r\n\t\taddItem(viewName);\r\n\t\tindex = count() - 1;\r\n\t}\r\n\r\n\tsetCurrentIndex(index);\r\n\tconnect(this, SIGNAL(currentIndexChanged(int)),\r\n\t\tthis, SLOT(onIndexChange(int)), Qt::UniqueConnection);\r\n}\r\n\r\nvoid ViewSelector::onIndexChange( int newIndex ) {\r\n\t// find the text for the index\r\n\tQString text = itemText(newIndex);\r\n\temit viewSelected(text);\r\n}\r\n"
  },
  {
    "path": "common/widgets/viewSelector/viewselector.h",
    "content": "/* \r\n *\tCreated on:\t28.3.2013\r\n *\tAuthor:\t\tAntti Kamppi\r\n *\tFile name:\tviewselector.h\r\n *\tProject:\t\tKactus 2\r\n*/\r\n\r\n#ifndef VIEWSELECTOR_H\r\n#define VIEWSELECTOR_H\r\n\r\n#include <IPXACTmodels/Component/Component.h>\r\n\r\n#include <QComboBox>\r\n#include <QSharedPointer>\r\n\r\n/*! \\brief This combo box can be used to select a view within a component.\r\n *\r\n */\r\nclass ViewSelector : public QComboBox {\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\r\n\t//! \\brief Specifies what kind of views can be selected in the combo box.\r\n\tenum ViewType {\r\n\t\tFLAT_HW_VIEWS = 0,\r\n\t\tHIER_HW_VIEWS,\r\n\t\tBOTH_HW_VIEWS,\r\n\t\tSYSTEM_VIEWS,\r\n\t\tMODE_COUNT\r\n\t};\r\n\r\n\t/*! \\brief The constructor\r\n\t *\r\n\t * Method: \t\tViewSelector\r\n\t * Full name:\tViewSelector::ViewSelector\r\n\t * Access:\t\tprivate \r\n\t *\r\n\t * \\param mode Specifies which kind of views can be selected.\r\n\t * \\param component Pointer to the component which's views are being selected.\r\n\t * \\param parent Pointer to the owner of the combo box.\r\n\t * \\param allowEmpty If true then empty option is added to allow unselecting a view.\r\n\t *\r\n\t*/\r\n\tViewSelector(ViewType mode, QSharedPointer<Component> component, QWidget *parent, bool allowEmpty = true);\r\n\t\r\n\t//! \\brief The destructor.\r\n\tvirtual ~ViewSelector();\r\n\r\npublic slots:\r\n\r\n\t//! \\brief Refresh the items to be selected in the combo box.\r\n\tvoid refresh();\r\n\r\n\t//! \\brief Select the named view in the combo box.\r\n\tvoid selectView(const QString& viewName);\r\n\r\nsignals:\r\n\r\n\t//! \\brief Emitted when a view changes.\r\n\tvoid viewSelected(const QString& viewName);\r\n\r\nprivate slots:\r\n\r\n\t\t//! \\brief Handler for selected index changes.\r\n\t\tvoid onIndexChange(int newIndex);\r\n\r\nprivate:\r\n\t\r\n\t//! \\brief No copying\r\n\tViewSelector(const ViewSelector& other);\r\n\r\n\t//! \\brief No assignment\r\n\tViewSelector& operator=(const ViewSelector& other);\r\n\r\n\t//! \\brief Specifies what kind of views can be selected in the combo box.\r\n\tViewType mode_;\r\n\r\n\t//! \\brief Pointer to the component, which's views are selected.\r\n\tQSharedPointer<Component> component_;\r\n\r\n\t//! \\brief Specified whether empty option is available in the combo box.\r\n\tbool allowEmpty_;\r\n};\r\n\r\n#endif // VIEWSELECTOR_H\r\n"
  },
  {
    "path": "common/widgets/vlnvDisplayer/vlnvdisplayer.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: vlnvdisplayer.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Antti Kamppi\r\n// Date: 11.03.2011\r\n//\r\n// Description:\r\n// VLNVDisplayer is a widget to display a vlnv tag in a GUI item.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"vlnvdisplayer.h\"\r\n\r\n#include <QGridLayout>\r\n#include <QHBoxLayout>\r\n#include <QSizePolicy>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: vlnvdisplayer::VLNVDisplayer()\r\n//-----------------------------------------------------------------------------\r\nVLNVDisplayer::VLNVDisplayer(QWidget* parent, VLNV const& vlnv, bool compact):\r\nQGroupBox(parent),\r\nvendorLabel_(tr(\"Vendor:\"), this),\r\nlibraryLabel_(tr(\"Library:\"), this),\r\nnameLabel_(tr(\"Name:\"), this),\r\nversionLabel_(tr(\"Version:\"), this),\r\nvendor_(this), library_(this),\r\nname_(this),\r\nversion_(this),\r\npathLabel_(this)\r\n{\r\n    setupLayout(compact);\r\n    setVLNV(vlnv);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: vlnvdisplayer::setupLayout()\r\n//-----------------------------------------------------------------------------\r\nvoid VLNVDisplayer::setupLayout(bool compact)\r\n{\r\n    pathLabel_.hide();\r\n\r\n    // Show the labels for non-compact layout.\r\n    vendorLabel_.setVisible(!compact);\r\n    libraryLabel_.setVisible(!compact);\r\n    nameLabel_.setVisible(!compact);\r\n    versionLabel_.setVisible(!compact);\r\n\r\n    if (compact)\r\n    {\r\n        QFrame* firstLine = new QFrame();\r\n        firstLine->setFrameShape(QFrame::VLine);\r\n        firstLine->setLineWidth(1);\r\n        QFrame* secondLine = new QFrame();\r\n        secondLine->setFrameShape(QFrame::VLine);\r\n        secondLine->setLineWidth(1);\r\n        QFrame* thirdLine = new QFrame();\r\n        thirdLine->setFrameShape(QFrame::VLine);\r\n        thirdLine->setLineWidth(1);\r\n\r\n        QHBoxLayout* compactLayout = new QHBoxLayout(this);\r\n        compactLayout->setSpacing(1);\r\n        compactLayout->addWidget(&vendor_);\r\n        compactLayout->addWidget(firstLine);\r\n        compactLayout->addWidget(&library_);\r\n        compactLayout->addWidget(secondLine);\r\n        compactLayout->addWidget(&name_);\r\n        compactLayout->addWidget(thirdLine);\r\n        compactLayout->addWidget(&version_);\r\n        compactLayout->addStretch(1);\r\n    }\r\n    else\r\n    {\r\n        QFormLayout* layout_ = new QFormLayout(this);\r\n        layout_->addRow(&vendorLabel_, &vendor_);\r\n        layout_->addRow(&libraryLabel_, &library_);\r\n        layout_->addRow(&nameLabel_, &name_);\r\n        layout_->addRow(&versionLabel_, &version_);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: vlnvdisplayer::setVLNV()\r\n//-----------------------------------------------------------------------------\r\nvoid VLNVDisplayer::setVLNV(const VLNV& vlnv)\r\n{\r\n    vendor_.setText(vlnv.getVendor());\r\n    library_.setText(vlnv.getLibrary());\r\n    name_.setText(vlnv.getName());\r\n    version_.setText(vlnv.getVersion());\r\n\r\n    if (!vlnv.isValid())\r\n    {\r\n        if (vlnv.getVendor().isEmpty())\r\n        {\r\n            vendor_.setText(\"unassigned\");\r\n        }\r\n        if (vlnv.getLibrary().isEmpty())\r\n        {\r\n            library_.setText(\"unassigned\");\r\n        }\r\n        if (vlnv.getName().isEmpty())\r\n        {\r\n            name_.setText(\"unassigned\");\r\n        }\r\n        if (vlnv.getVersion().isEmpty())\r\n        {\r\n            version_.setText(\"unassigned\");\r\n        }\r\n    }\r\n\r\n\r\n//     if (compact_)\r\n//     {\r\n//         // Set the compact layout.\r\n//         setLayout(compactLayout_);\r\n//     }\r\n//     else\r\n//     {\r\n//         vendor_.setMinimumWidth(vendor_.sizeHint().width());\r\n//         library_.setMinimumWidth(library_.sizeHint().width());\r\n//         \r\n//         // Set the non-compact layout.\r\n//         setLayout(layout_);\r\n//     }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: vlnvdisplayer::setPath()\r\n//-----------------------------------------------------------------------------\r\nvoid VLNVDisplayer::setPath(QString const& path)\r\n{\r\n    pathLabel_.setText(path);\r\n    pathLabel_.setToolTip(path);\r\n\r\n    pathLabel_.setVisible(path.isEmpty() == false);\r\n\r\n    if (auto activeLayout = dynamic_cast<QFormLayout*>(layout()); \r\n        activeLayout)\r\n    {\r\n        pathLabel_.setWordWrap(true);\r\n        pathLabel_.setMinimumWidth(20);\r\n\r\n        activeLayout->addRow(QString(\"Path:\"), &pathLabel_);\r\n    }\r\n}\r\n"
  },
  {
    "path": "common/widgets/vlnvDisplayer/vlnvdisplayer.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: vlnvdisplayer.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Antti Kamppi\r\n// Date: 11.03.2011\r\n//\r\n// Description:\r\n// VLNVDisplayer is a widget to display a vlnv tag in a GUI item.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef VLNVDISPLAYER_H\r\n#define VLNVDISPLAYER_H\r\n\r\n#include <IPXACTmodels/common/VLNV.h>\r\n\r\n#include <QGroupBox>\r\n#include <QLabel>\r\n#include <QFormLayout>\r\n#include <QHBoxLayout>\r\n\r\n//-----------------------------------------------------------------------------\r\n//! VLNVDisplayer is a widget to display a vlnv tag in a GUI item.\r\n//-----------------------------------------------------------------------------\r\nclass VLNVDisplayer : public QGroupBox\r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\r\n\t/*!\r\n     *  The constructor.\r\n\t *\r\n\t *    @param [in] parent      Pointer to the owner of this widget.\r\n\t *    @param [in] vlnv        Reference to the vlnv to be displayed\r\n     *    @param [in] compact     A compact VLNV display takes less space.\r\n\t */\r\n    VLNVDisplayer(QWidget *parent, VLNV const& vlnv, bool compact = false);\r\n\r\n\t/*!\r\n     *  The destructor.\r\n     */\r\n\t~VLNVDisplayer() final = default;\r\n\r\n\t/*!\r\n     *  Set the vlnv to be displayed in the widget.\r\n\t *\r\n\t *    @param [in] vlnv    Reference to the VLNV to be displayed\r\n\t */\r\n    void setVLNV(const VLNV& vlnv);\r\n\r\n\t/*!\r\n     *  Also display path along with the vlnv in the widget.\r\n\t *\r\n\t *    @param [in] path    The path to display\r\n\t */\r\n\tvoid setPath(const QString& path);\r\n\r\nprivate:\r\n\r\n\t//! No copying.\r\n\tVLNVDisplayer(const VLNVDisplayer& other);\r\n\r\n\t//! No assignment.\r\n\tVLNVDisplayer& operator=(const VLNVDisplayer& other);\r\n\r\n    /*!\r\n     *  Setup the VLNV layout.\r\n     */\r\n    void setupLayout(bool compact);\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! Title labels for each field.\r\n    QLabel vendorLabel_;\r\n    QLabel libraryLabel_;\r\n    QLabel nameLabel_;\r\n    QLabel versionLabel_;\r\n\r\n\t//! The label to display the vendor.\r\n\tQLabel vendor_;\r\n\r\n\t//! The label to display the library.\r\n\tQLabel library_;\r\n\r\n\t//! The label to display the name.\r\n\tQLabel name_;\r\n\r\n\t//! The label to display the version.\r\n\tQLabel version_;\r\n\r\n    //! Label containing the folder path of the displayed VLNV item.\r\n    QLabel pathLabel_;\r\n\r\n};\r\n\r\n#endif // VLNVDISPLAYER_H\r\n"
  },
  {
    "path": "common/widgets/vlnvEditor/VLNVContentMatcher.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: VLNVContentMatcher.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Joni-Matti Maatta\r\n// Date: 14.2.2011\r\n//\r\n// Description:\r\n// VLNV content matcher.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"VLNVContentMatcher.h\"\r\n\r\n#include <QRegularExpression>\r\n#include <common/widgets/assistedLineEdit/LineContentAssistWidget.h>\r\n#include <common/widgets/vlnvEditor/VLNVDataTree.h>\r\n\r\n#include <IPXACTmodels/Component/Component.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VLNVContentMatcher()\r\n//-----------------------------------------------------------------------------\r\nVLNVContentMatcher::VLNVContentMatcher() : node_(0)\r\n{\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ~VLNVContentMatcher()\r\n//-----------------------------------------------------------------------------\r\nVLNVContentMatcher::~VLNVContentMatcher()\r\n{\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: setDataNode()\r\n//-----------------------------------------------------------------------------\r\nvoid VLNVContentMatcher::setDataNode(VLNVDataNode const* node)\r\n{\r\n    node_ = node;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: getVLNVDataNode()\r\n//-----------------------------------------------------------------------------\r\nVLNVDataNode const* VLNVContentMatcher::getDataNode() const\r\n{\r\n    return node_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: lookForwardMatch()\r\n//-----------------------------------------------------------------------------\r\nbool VLNVContentMatcher::lookForwardMatch(QString const& text)\r\n{\r\n    return enumerateMatches(text, 0);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: fillWithContent()\r\n//-----------------------------------------------------------------------------\r\nbool VLNVContentMatcher::fillWithContent(QString const& text, LineContentAssistWidget& assist,\r\n                                         int& startIndex, QString& /*toolTipText*/, int& /*toolTipIndex*/)\r\n{\r\n    startIndex = 0;\r\n    bool ret = enumerateMatches(text, &assist);\r\n    assist.sortItems();\r\n    return ret;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: enumerateMatches()\r\n//-----------------------------------------------------------------------------\r\nbool VLNVContentMatcher::enumerateMatches(QString const& text, LineContentAssistWidget* assist) const\r\n{\r\n    QRegularExpression exp(\"^\" + text.toLower() + \".*\");\r\n\r\n    int count = 0;\r\n    bool exactMatch = false;\r\n\r\n    if (node_ != 0)\r\n    {\r\n        // Go through all the children and try to match with their names.\r\n        for (int i = 0; i < node_->getChildren().size(); ++i)\r\n        {\r\n            VLNVDataNode const* child = node_->getChildren()[i].data();\r\n\r\n            if (child->name().toLower().contains(exp))\r\n            {\r\n                if (assist != 0)\r\n                {\r\n                    QListWidgetItem* item = new QListWidgetItem(child->name());\r\n                    \r\n                    assist->addItem(item);\r\n                }\r\n\r\n                ++count;\r\n\r\n                if (!exactMatch && child->name() == text)\r\n                {\r\n                    exactMatch = true;\r\n                }\r\n            }\r\n        }\r\n    }\r\n\r\n    return (count > 1 || (count == 1 && !exactMatch));\r\n}"
  },
  {
    "path": "common/widgets/vlnvEditor/VLNVContentMatcher.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: VLNVContentMatcher.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Joni-Matti Maatta\r\n// Date: 11.2.2011\r\n//\r\n// Description:\r\n// VLNV content matcher.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef VLNVCONTENTMATCHER_H\r\n#define VLNVCONTENTMATCHER_H\r\n\r\n#include <common/widgets/assistedLineEdit/ILineContentMatcher.h>\r\n\r\nclass VLNVDataNode;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! VLNVContentMatcher class.\r\n//-----------------------------------------------------------------------------\r\nclass VLNVContentMatcher : public ILineContentMatcher\r\n{\r\npublic:\r\n    /*!\r\n     *\tConstructor.\r\n     */\r\n    VLNVContentMatcher();\r\n\r\n    /*!\r\n     *  Destructor.\r\n     */\r\n    virtual ~VLNVContentMatcher();\r\n\r\n    /*!\r\n     *  Sets the data node to use for finding content.\r\n     */\r\n    void setDataNode(VLNVDataNode const* item);\r\n\r\n    /*!\r\n     *  Returns the data node associated with the content matcher.\r\n     */\r\n    VLNVDataNode const* getDataNode() const;\r\n\r\n    /*!\r\n     *  Looks forward for matching contents in the given text.\r\n     *\r\n     *    @param [in] text The text.\r\n     *\r\n     *    @return True, if there is a match. Otherwise false.\r\n     */\r\n    bool lookForwardMatch(QString const& text);\r\n\r\n    /*!\r\n     *  Fills the content assist with content based on the given text.\r\n     *\r\n     *    @param [in]  text          The text.\r\n     *    @param [in]  assist        The content assist to fill with content.\r\n     *    @param [out] startIndex    The start index of the selection to which the content applies.\r\n     *    @param [out] toolTipText   The tool tip hint text. Empty if no tool tip available.\r\n     *    @param [out] toolTipIndex  The index which specifies there start position for the tool tip hint.\r\n     *\r\n     *    @return True, if content was found; otherwise false.\r\n     */\r\n    bool fillWithContent(QString const& text, LineContentAssistWidget& assist,\r\n                         int& startIndex, QString& toolTipText, int& toolTipIndex);\r\n\r\nprivate:\r\n    // Disable copying.\r\n    VLNVContentMatcher(VLNVContentMatcher const& rhs);\r\n    VLNVContentMatcher& operator=(VLNVContentMatcher const& rhs);\r\n\r\n    /*!\r\n     *  Enumerates matches based on the string. If the content assist is specified, the matching\r\n     *  contents is also added to it.\r\n     *\r\n     *    @param [in] text    The text to which to match content.\r\n     *    @param [in] assist  The content assist to fill with content. Can be null.\r\n     *\r\n     *    @return True, if there was content found; otherwise false.\r\n     */\r\n    bool enumerateMatches(QString const& text, LineContentAssistWidget* assist) const;\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! The data node.\r\n    VLNVDataNode const* node_;\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n\r\n#endif // VLNVCONTENTMATCHER_H\r\n"
  },
  {
    "path": "common/widgets/vlnvEditor/VLNVDataTree.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: VLNVDataTree.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Joni-Matti Maatta\r\n// Date: 5.1.2012\r\n//\r\n// Description:\r\n// Optimized VLNV data tree for VLNV editor data searches.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"VLNVDataTree.h\"\r\n\r\n#include <KactusAPI/include/LibraryInterface.h>\r\n#include <KactusAPI/include//LibraryItem.h>\r\n\r\n#include <IPXACTmodels/Component/Component.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VLNVDataNode()\r\n//-----------------------------------------------------------------------------\r\nVLNVDataNode::VLNVDataNode(QString const& name)\r\n    : name_(name),\r\n      vlnv_()\r\n{\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: name()\r\n//-----------------------------------------------------------------------------\r\nQString const& VLNVDataNode::name() const\r\n{\r\n    return name_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: getVLNV()\r\n//-----------------------------------------------------------------------------\r\nVLNV const& VLNVDataNode::getVLNV() const\r\n{\r\n    return vlnv_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: findChild()\r\n//-----------------------------------------------------------------------------\r\nVLNVDataNode* VLNVDataNode::findChild(QString const& name) const\r\n{\r\n    for (QSharedPointer<VLNVDataNode> node : children_)\r\n    {\r\n        if (node->name() == name)\r\n        {\r\n            return node.data();\r\n        }\r\n    }\r\n\r\n    return 0;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: getChildren()\r\n//-----------------------------------------------------------------------------\r\nQList< QSharedPointer<VLNVDataNode> > const& VLNVDataNode::getChildren() const\r\n{\r\n    return children_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VLNVDataNode::getChildren()\r\n//-----------------------------------------------------------------------------\r\nint VLNVDataNode::getChildCount() const\r\n{\r\n    return children_.count();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: addChild()\r\n//-----------------------------------------------------------------------------\r\nVLNVDataNode* VLNVDataNode::addChild(QString const& name)\r\n{\r\n    QSharedPointer<VLNVDataNode> child(new VLNVDataNode(name));\r\n    children_.append(child);\r\n    return child.data();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: removeChild()\r\n//-----------------------------------------------------------------------------\r\nvoid VLNVDataNode::removeChild(QString const& name)\r\n{\r\n    for (QSharedPointer<VLNVDataNode> node : children_)\r\n    {\r\n        if (node->name() == name)\r\n        {\r\n            children_.removeOne(node);\r\n            return;\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: removeChildren()\r\n//-----------------------------------------------------------------------------\r\nvoid VLNVDataNode::removeChildren()\r\n{\r\n    children_.clear();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: setVLNV()\r\n//-----------------------------------------------------------------------------\r\nvoid VLNVDataNode::setVLNV(VLNV const& vlnv)\r\n{\r\n    vlnv_ = vlnv;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VLNVDataTree()\r\n//-----------------------------------------------------------------------------\r\nVLNVDataTree::VLNVDataTree(): VLNVDataNode()\r\n{\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: parse()\r\n//-----------------------------------------------------------------------------\r\nvoid VLNVDataTree::parse(LibraryInterface* lh, QList<VLNV::IPXactType> const& types)\r\n{\r\n    // Parse all library objects.\r\n    parseSubtree(lh, lh->getTreeRoot(), *this, types);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: clear()\r\n//-----------------------------------------------------------------------------\r\nvoid VLNVDataTree::clear()\r\n{\r\n    removeChildren();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: setFirmnessFilter()\r\n//-----------------------------------------------------------------------------\r\nvoid VLNVDataTree::setFirmnessFilter(bool on, KactusAttribute::Firmness firmness)\r\n{\r\n    firmnessFilterEnabled_ = on;\r\n    firmnessFilter_ = firmness;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: setHierarchyFilter()\r\n//-----------------------------------------------------------------------------\r\nvoid VLNVDataTree::setHierarchyFilter(bool on, KactusAttribute::ProductHierarchy productHier)\r\n{\r\n    hierarchyFilterEnabled_ = on;\r\n    hierarchyFilter_ = productHier;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: setImplementationFilter()\r\n//-----------------------------------------------------------------------------\r\nvoid VLNVDataTree::setImplementationFilter(bool on, KactusAttribute::Implementation implementation)\r\n{\r\n    implementationFilterEnabled_ = on;\r\n    implementationFilter_ = implementation;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VLNVDataTree::setRevisionFilter()\r\n//-----------------------------------------------------------------------------\r\nvoid VLNVDataTree::setRevisionFilter(bool on, Document::Revision val)\r\n{\r\n    revisionFilterEnabled_ = on;\r\n    revisionFilter_ = val;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: parseVendor()\r\n//-----------------------------------------------------------------------------\r\nvoid VLNVDataTree::parseSubtree(LibraryInterface* lh, LibraryItem const* libItem, VLNVDataNode& node,\r\n                                QList<VLNV::IPXactType> const& types)\r\n{\r\n    const int childCount = libItem->getNumberOfChildren();\r\n    for (int i = 0; i < childCount; ++i)\r\n    {\r\n        LibraryItem const* item = libItem->child(i);\r\n\r\n        // Check if this is a leaf item.\r\n        if (item->getLevel() == LibraryItem::Level::VERSION)\r\n        {\r\n            // Check if the tree already contains an node with the same name.\r\n            // Check that the type is valid.\r\n            if (node.findChild(item->name()) || !types.contains(item->getVLNV().getType()))\r\n            {\r\n                continue;\r\n            }\r\n\r\n            VLNV const vlnv = item->getVLNV();\r\n\r\n            bool useComponentFilters = (vlnv.getType() == VLNV::COMPONENT);\r\n            KactusAttribute::Firmness firmness = KactusAttribute::KTS_REUSE_LEVEL_COUNT;\r\n            KactusAttribute::ProductHierarchy hierarchy = KactusAttribute::KTS_PRODHIER_COUNT;\r\n            KactusAttribute::Implementation implementation = KactusAttribute::KTS_IMPLEMENTATION_COUNT;\r\n            Document::Revision revision = Document::Revision::Unknown;\r\n            \r\n            QSharedPointer<Document const> document = lh->getModelReadOnly(vlnv);\r\n            if (document)\r\n            {\r\n                revision = document->getRevision();\r\n            }\r\n\r\n            if (useComponentFilters)\r\n            {\r\n                // Retrieve the library component for filtering.\r\n                QSharedPointer<Component const> component = document.dynamicCast<Component const>();\r\n                firmness = component->getFirmness();\r\n                hierarchy = component->getHierarchy();\r\n                implementation = component->getImplementation();\r\n            }\r\n\r\n            bool passesComponentFilters = (!firmnessFilterEnabled_ || firmnessFilter_ == firmness) &&\r\n                (!hierarchyFilterEnabled_ || hierarchyFilter_ == hierarchy) &&\r\n                (!implementationFilterEnabled_ || implementationFilter_ == implementation);\r\n            \r\n            // Accept the item if it passess filters or filters are off, and the revision matches with the parent\r\n            // editor item revision.\r\n            if ((passesComponentFilters || !useComponentFilters) && (revision == revisionFilter_ || !revisionFilterEnabled_))\r\n            {\r\n                VLNVDataNode* childNode = node.addChild(item->name());\r\n                childNode->setVLNV(vlnv);\r\n            }\r\n        }\r\n        else\r\n        {\r\n            QString name = item->name();\r\n\r\n            if (item->getLevel() == LibraryItem::Level::NAME)\r\n            {\r\n                // Filter out extensions.\r\n                for (QString const& ext : extensions_)\r\n                {\r\n                    if (name.endsWith(ext))\r\n                    {\r\n                        name = name.left(name.length() - ext.length());\r\n                    }\r\n                }\r\n            }\r\n\r\n            // Otherwise parse the subtree recursively.\r\n            VLNVDataNode* childNode = node.findChild(name);\r\n\r\n            if (childNode == 0)\r\n            {\r\n                childNode = node.addChild(name);\r\n            }\r\n\r\n            parseSubtree(lh, item, *childNode, types);\r\n\r\n            if (childNode->getChildCount() == 0)\r\n            {\r\n                node.removeChild(name);\r\n            }\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VLNVDataTree::addExtensionFilter()\r\n//-----------------------------------------------------------------------------\r\nvoid VLNVDataTree::addExtensionFilter(QString const& extension)\r\n{\r\n    extensions_.append(extension);\r\n}\r\n"
  },
  {
    "path": "common/widgets/vlnvEditor/VLNVDataTree.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: VLNVDataNode.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Joni-Matti Maatta\r\n// Date: 5.1.2012\r\n//\r\n// Description:\r\n// Optimized VLNV data tree for VLNV editor data searches.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef VLNVDATATREE_H\r\n#define VLNVDATATREE_H\r\n\r\n#include <IPXACTmodels/kactusExtensions/KactusAttribute.h>\r\n#include <IPXACTmodels/common/VLNV.h>\r\n#include <IPXACTmodels/common/Document.h>\r\n\r\n#include <QString>\r\n#include <QSharedPointer>\r\n\r\nclass LibraryInterface;\r\nclass LibraryItem;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! VLNVDataNode class.\r\n//-----------------------------------------------------------------------------\r\nclass VLNVDataNode\r\n{\r\npublic:\r\n\r\n\r\n    /*!\r\n     *  Constructor.\r\n     */\r\n    VLNVDataNode(QString const& name = QString());\r\n\r\n    /*!\r\n     *  Destructor.\r\n     */\r\n    virtual ~VLNVDataNode() = default;\r\n    \r\n    // Disable copying.\r\n    VLNVDataNode(VLNVDataNode const& rhs) = delete;\r\n    VLNVDataNode& operator=(VLNVDataNode const& rhs) = delete;\r\n\r\n    /*!\r\n     *  Returns the name of the node.\r\n     */\r\n    QString const& name() const;\r\n\r\n    /*!\r\n     *  Returns the VLNV of the node (valid only if the node level is version).\r\n     */\r\n    VLNV const& getVLNV() const;\r\n\r\n    /*!\r\n     *  Returns the child with the given name or null if not found.\r\n     *\r\n     *    @param [in] name The name of the child to search for.\r\n     */\r\n    VLNVDataNode* findChild(QString const& name) const;\r\n\r\n    /*!\r\n     *  Returns the node's children.\r\n     */\r\n    QList< QSharedPointer<VLNVDataNode> > const& getChildren() const;\r\n\r\n    \r\n    /*!\r\n     * Get the number of children the node has.\r\n     *\r\n     *    @return The number of children.\r\n     */\r\n     int getChildCount() const;\r\n\r\n    /*!\r\n     *  Sets the VLNV for the node.\r\n     *\r\n     *    @param [in] vlnv The vlnv to set.\r\n     */\r\n    void setVLNV(VLNV const& vlnv);\r\n\r\n    /*!\r\n     *  Adds a child to the node.\r\n     *\r\n     *    @param [in] name The name of the child.\r\n     *\r\n     *    @return The created child node.\r\n     */\r\n    VLNVDataNode* addChild(QString const& name);\r\n\r\n    /*!\r\n     *  Removes the child with the given name.\r\n     *\r\n     *    @param [in] name The name of the child.\r\n     */\r\n    void removeChild(QString const& name);\r\n\r\n    /*!\r\n     *  Removes all child nodes.\r\n     */\r\n    void removeChildren();\r\n    \r\n\r\nprivate:\r\n\r\n    //! The node name.\r\n    QString name_;\r\n\r\n    //! The object VLNV (only valid at the leaf nodes).\r\n    VLNV vlnv_;\r\n\r\n    //! The list of children.\r\n    QList< QSharedPointer<VLNVDataNode> > children_;\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n//! VLNVDataTree class.\r\n//-----------------------------------------------------------------------------\r\nclass VLNVDataTree : public VLNVDataNode\r\n{\r\npublic:\r\n    /*!\r\n     *  Constructor which creates an empty tree.\r\n     */\r\n    VLNVDataTree();\r\n\r\n    /*!\r\n     *  Destructor.\r\n     */\r\n    virtual ~VLNVDataTree() = default;\r\n    \r\n    // Disable copying.\r\n    VLNVDataTree(VLNVDataTree const& rhs) = delete;\r\n    VLNVDataTree& operator=(VLNVDataTree const& rhs) = delete;\r\n\r\n    /*! \r\n     *  Updates the tree based on the filters and the given library interface.\r\n     *\r\n     *    @param [in] lh     The library interface.\r\n     *    @param [in] type   The allowed document types.\r\n     */\r\n    void parse(LibraryInterface* lh, QList<VLNV::IPXactType> const& types);\r\n\r\n    /*!\r\n     *  Clears the tree so that it contains only the root node.\r\n     */\r\n    void clear();\r\n\r\n    /*!\r\n     *  Sets the firmness filter on/off.\r\n     *\r\n     *    @param [in] on        If true, the filter is turned on; otherwise it is turned off.\r\n     *    @param [in] firmness  The allowed firmness.\r\n     */\r\n    void setFirmnessFilter(bool on, KactusAttribute::Firmness firmness = KactusAttribute::TEMPLATE);\r\n\r\n    /*!\r\n     *  Sets the product hierarchy filter on/off.\r\n     *\r\n     *    @param [in] on           If true, the filter is turned on; otherwise it is turned off.\r\n     *    @param [in] productHier  The allowed product hierarchy.\r\n     */\r\n    void setHierarchyFilter(bool on, KactusAttribute::ProductHierarchy productHier = KactusAttribute::IP);\r\n\r\n    /*!\r\n     *  Sets the implementation filter on/off.\r\n     *\r\n     *    @param [in] on              If true, the filter is turned on; otherwise it is turned off.\r\n     *    @param [in] implementation  The allowed implementation.\r\n     */\r\n    void setImplementationFilter(bool on, KactusAttribute::Implementation implementation = KactusAttribute::HW);\r\n\r\n    /*!\r\n     *  Sets the IP-XACT revision filter on/off.\r\n     *\r\n     *    @param [in] on              If true, the filter is turned on; otherwise it is turned off.\r\n     *    @param [in] revision        The allowed IP-XACT standard revision.\r\n     */\r\n    void setRevisionFilter(bool on, Document::Revision revision = Document::Revision::Std22);\r\n\r\n    /*!\r\n     *  Adds an extension to be filtered out from the content search results.\r\n     *\r\n     *    @param [in] extension The extension to filter out.\r\n     */\r\n    void addExtensionFilter(QString const& extension);\r\n\r\nprivate:\r\n\r\n    /*!\r\n     *  Parses the library subtree indicated by the given library item and adds matching names\r\n     *  to the given data node.\r\n     *\r\n     *    @param [in] libItem  The library item containing the subtree.\r\n     *    @param [in] node     The target data node.\r\n     */\r\n    void parseSubtree(LibraryInterface* lh, LibraryItem const* libItem, VLNVDataNode& node,\r\n                      QList<VLNV::IPXactType> const& types);\r\n    \r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! Firmness filter data.\r\n    bool firmnessFilterEnabled_ = false;\r\n    KactusAttribute::Firmness firmnessFilter_ = KactusAttribute::TEMPLATE;\r\n\r\n    //! Product hierarchy filter data.\r\n    bool hierarchyFilterEnabled_ = false;\r\n    KactusAttribute::ProductHierarchy hierarchyFilter_ = KactusAttribute::IP;\r\n\r\n    //! Implementation filter data.\r\n    bool implementationFilterEnabled_ = false;\r\n    KactusAttribute::Implementation implementationFilter_ = KactusAttribute::HW;\r\n\r\n    //! IP-XACT standard revision filter data.\r\n    bool revisionFilterEnabled_ = false;\r\n    Document::Revision revisionFilter_ = Document::Revision::Unknown;\r\n\r\n    //! The extensions to filter.\r\n    QStringList extensions_;\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n\r\n#endif // VLNVDATATREE_H\r\n"
  },
  {
    "path": "common/widgets/vlnvEditor/vlnveditor.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: vlnveditor.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Joni-Matti Maatta\r\n// Date: 7.2.2011\r\n//\r\n// Description:\r\n// VLNV editor group box.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"vlnveditor.h\"\r\n\r\n#include <common/widgets/assistedLineEdit/AssistedLineEdit.h>\r\n\r\n#include <KactusAPI/include/LibraryInterface.h>\r\n#include <KactusAPI/include/LibraryItem.h>\r\n#include <KactusAPI/include/LibraryHandler.h>\r\n\r\n#include <IPXACTmodels/common/validators/namevalidator.h>\r\n#include <IPXACTmodels/common/validators/NMTokenValidator.h>\r\n\r\n#include <IPXACTmodels/kactusExtensions/KactusAttribute.h>\r\n\r\n#include <IPXACTmodels/AbstractionDefinition/AbstractionDefinition.h>\r\n#include <IPXACTmodels/DesignConfiguration/DesignConfiguration.h>\r\n\r\n#include <IPXACTmodels/Design/Design.h>\r\n\r\n#include <QGridLayout>\r\n#include <QVBoxLayout>\r\n#include <QLabel>\r\n#include <QMimeData>\r\n#include <QSharedPointer>\r\n#include <QMessageBox>\r\n#include <QCoreApplication>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VLNVEditor::VLNVEditor()\r\n//-----------------------------------------------------------------------------\r\nVLNVEditor::VLNVEditor(VLNV::IPXactType type, LibraryInterface* libHandler, QWidget* parentWnd, QWidget* parent):\r\nQGroupBox(parent),\r\ntype_(type),\r\ncontentTypes_(),\r\ndirty_(false),\r\ndataTree_(),\r\nvendorEdit_(0),\r\nvendorMatcher_(),\r\nlibraryEdit_(0),\r\nlibraryMatcher_(),\r\nnameEdit_(0),\r\nnameExtensionLabel_(this),\r\nnameMatcher_(),\r\nversionEdit_(0),\r\nversionMatcher_(),\r\nhandler_(libHandler),\r\nimplementationFilter_(KactusAttribute::HW)\r\n{\r\n    Q_ASSERT(libHandler != 0);\r\n    Q_ASSERT(type_ != VLNV::INVALID);\r\n\r\n    nameExtensionLabel_.setVisible(false);\r\n\r\n    // Set group box settings.\r\n    setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);\r\n    setTitle(tr(\"VLNV\"));\r\n\r\n    // Initialize the widgets and the connections between widgets.\r\n    initWidgets(parentWnd);\r\n    initConnections();\r\n\r\n\t// accept drops from drag & drop\r\n\tsetAcceptDrops(true);\r\n\r\n    // By default, add the VLNV type to edit to the content types.\r\n    addContentType(type);\r\n\r\n    vendorMatcher_.setDataNode(&dataTree_);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VLNVEditor::~VLNVEditor()\r\n//-----------------------------------------------------------------------------\r\nVLNVEditor::~VLNVEditor()\r\n{\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VLNVEditor::addContentType()\r\n//-----------------------------------------------------------------------------\r\nvoid VLNVEditor::addContentType(VLNV::IPXactType type)\r\n{\r\n    contentTypes_.append(type);\r\n    dirty_ = true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VLNVEditor::setVLNV()\r\n//-----------------------------------------------------------------------------\r\nvoid VLNVEditor::setVLNV(const VLNV& vlnv)\r\n{\r\n    if (dirty_)\r\n    {\r\n        updateFiltering();\r\n    }\r\n\r\n    // Set the fields according to the VLNV.\r\n    vendorEdit_->setText(vlnv.getVendor());\r\n    libraryEdit_->setText(vlnv.getLibrary());\r\n    nameEdit_->setText(vlnv.getName());\r\n    versionEdit_->setText(vlnv.getVersion());\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VLNVEditor::getVLNV()\r\n//-----------------------------------------------------------------------------\r\nVLNV VLNVEditor::getVLNV() const\r\n{\r\n    return VLNV(type_, vendorEdit_->text(), libraryEdit_->text(), nameEdit_->text(), versionEdit_->text());\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VLNVEditor::isValid()\r\n//-----------------------------------------------------------------------------\r\nbool VLNVEditor::isValid() const\r\n{\r\n    return (!vendorEdit_->text().isEmpty() && !libraryEdit_->text().isEmpty() &&\r\n            !nameEdit_->text().isEmpty() && !versionEdit_->text().isEmpty());\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VLNVEditor::updateMatcherItems()\r\n//-----------------------------------------------------------------------------\r\nvoid VLNVEditor::updateMatcherItems()\r\n{\r\n    updateLibraryMatcherItem();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VLNVEditor::updateLibraryMatcherItem()\r\n//-----------------------------------------------------------------------------\r\nvoid VLNVEditor::updateLibraryMatcherItem()\r\n{\r\n    VLNVDataNode const* foundItem = dataTree_.findChild(vendorEdit_->text());\r\n    libraryMatcher_.setDataNode(foundItem);\r\n\r\n    // Update \"recursively\" also the name matcher item.\r\n    updateNameMatcherItem();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VLNVEditor::updateNameMatcherItem()\r\n//-----------------------------------------------------------------------------\r\nvoid VLNVEditor::updateNameMatcherItem()\r\n{\r\n    VLNVDataNode const* libItem = libraryMatcher_.getDataNode();\r\n    VLNVDataNode const* foundItem = 0;\r\n\r\n    if (libItem != 0)\r\n    {\r\n        foundItem = libItem->findChild(libraryEdit_->text());\r\n    }\r\n\r\n    nameMatcher_.setDataNode(foundItem);\r\n\r\n    // Update \"recursively\" also the version matcher item.\r\n    updateVersionMatcherItem();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VLNVEditor::updateVersionMatcherItem()\r\n//-----------------------------------------------------------------------------\r\nvoid VLNVEditor::updateVersionMatcherItem()\r\n{\r\n    VLNVDataNode const* nameItem = nameMatcher_.getDataNode();\r\n    VLNVDataNode const* foundItem = 0;\r\n\r\n    if (nameItem != 0)\r\n    {\r\n        foundItem = nameItem->findChild(nameEdit_->text());\r\n    }\r\n\r\n    versionMatcher_.setDataNode(foundItem);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VLNVEditor::initWidgets()\r\n//-----------------------------------------------------------------------------\r\nvoid VLNVEditor::initWidgets(QWidget* parentWnd)\r\n{\r\n    // Create the labels.\r\n    QLabel* vendorLabel = new QLabel(tr(\"Vendor:\"), this);\r\n    QLabel* libraryLabel = new QLabel(tr(\"Library:\"), this);\r\n    QLabel* nameLabel = new QLabel(tr(\"Name:\"), this);\r\n    QLabel* versionLabel = new QLabel(tr(\"Version:\"), this);\r\n\r\n    // Create the line edits.\r\n    vendorEdit_ = new AssistedLineEdit(parentWnd, this);\r\n    vendorEdit_->setContentMatcher(&vendorMatcher_);\r\n    vendorEdit_->setValidator(new NameValidator(this));\r\n\tvendorEdit_->setProperty(\"mandatoryField\", true);\r\n\r\n    libraryEdit_ = new AssistedLineEdit(parentWnd, this);\r\n    libraryEdit_->setContentMatcher(&libraryMatcher_);\r\n    libraryEdit_->setValidator(new NameValidator(this));\r\n\tlibraryEdit_->setProperty(\"mandatoryField\", true);\r\n\r\n    nameEdit_ = new AssistedLineEdit(parentWnd, this);\r\n    nameEdit_->setContentMatcher(&nameMatcher_);\r\n\tnameEdit_->setValidator(new NMTokenValidator(this));\r\n\tnameEdit_->setProperty(\"mandatoryField\", true);\r\n\r\n    versionEdit_ = new AssistedLineEdit(parentWnd, this);\r\n    versionEdit_->setContentMatcher(&versionMatcher_);\r\n\tversionEdit_->setValidator(new NMTokenValidator(this));\r\n\tversionEdit_->setProperty(\"mandatoryField\", true);\r\n\r\n    QHBoxLayout* nameLayout = new QHBoxLayout();\r\n    nameLayout->addWidget(nameEdit_, 1);\r\n    nameLayout->addWidget(&nameExtensionLabel_);\r\n    \r\n    // Create the layout and add the widgets to it.\r\n    QGridLayout* layout = new QGridLayout(this);\r\n    layout->addWidget(vendorLabel, 0, 0, 1, 1);\r\n    layout->addWidget(vendorEdit_, 0, 1, 1, 1);\r\n    layout->addWidget(libraryLabel, 1, 0, 1, 1);\r\n    layout->addWidget(libraryEdit_, 1, 1, 1, 1);\r\n    layout->addWidget(nameLabel, 2, 0, 1, 1);\r\n    layout->addLayout(nameLayout, 2, 1, 1, 1);\r\n    layout->addWidget(versionLabel, 3, 0, 1, 1);\r\n    layout->addWidget(versionEdit_, 3, 1, 1, 1);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VLNVEditor::initConnections()\r\n//-----------------------------------------------------------------------------\r\nvoid VLNVEditor::initConnections()\r\n{\r\n    // Connect the signals informing of changes in items.\r\n    connect(vendorEdit_, SIGNAL(textChanged(QString const&)),\r\n        this, SIGNAL(contentChanged()), Qt::UniqueConnection);\r\n    connect(libraryEdit_, SIGNAL(textChanged(QString const&)),\r\n        this, SIGNAL(contentChanged()), Qt::UniqueConnection);\r\n    connect(nameEdit_, SIGNAL(textChanged(QString const&)),\r\n        this, SIGNAL(contentChanged()), Qt::UniqueConnection);\r\n    connect(versionEdit_, SIGNAL(textChanged(QString const&)),\r\n        this, SIGNAL(contentChanged()), Qt::UniqueConnection);\r\n\r\n    // Connect the signals informing the editing of items.\r\n    connect(vendorEdit_, SIGNAL(editingFinished()), this, SIGNAL(vlnvEdited()), Qt::UniqueConnection);\r\n    connect(libraryEdit_, SIGNAL(editingFinished()), this, SIGNAL(vlnvEdited()), Qt::UniqueConnection);\r\n    connect(nameEdit_, SIGNAL(editingFinished()), this, SIGNAL(vlnvEdited()), Qt::UniqueConnection);\r\n    connect(versionEdit_, SIGNAL(editingFinished()), this, SIGNAL(vlnvEdited()), Qt::UniqueConnection);\r\n\r\n    // Connect the matcher update slots to the textChanged signals.\r\n    connect(vendorEdit_, SIGNAL(textChanged(QString const&)),\r\n        this, SLOT(updateLibraryMatcherItem()), Qt::UniqueConnection);\r\n    connect(libraryEdit_, SIGNAL(textChanged(QString const&)),\r\n        this, SLOT(updateNameMatcherItem()), Qt::UniqueConnection);\r\n    connect(nameEdit_, SIGNAL(textChanged(QString const&)),\r\n        this, SLOT(updateVersionMatcherItem()), Qt::UniqueConnection);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VLNVEditor::isEmpty()\r\n//-----------------------------------------------------------------------------\r\nbool VLNVEditor::isEmpty() const\r\n{\r\n\treturn (vendorEdit_->text().isEmpty() && libraryEdit_->text().isEmpty() &&\r\n\t\tnameEdit_->text().isEmpty() && versionEdit_->text().isEmpty());\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VLNVEditor::setVendor()\r\n//-----------------------------------------------------------------------------\r\nvoid VLNVEditor::setVendor(QString const& vendor)\r\n{\r\n\tvendorEdit_->setText(vendor);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VLNVEditor::setLibrary()\r\n//-----------------------------------------------------------------------------\r\nvoid VLNVEditor::setLibrary(QString const& library)\r\n{\r\n\tlibraryEdit_->setText(library);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VLNVEditor::setName()\r\n//-----------------------------------------------------------------------------\r\nvoid VLNVEditor::setName(QString const& name)\r\n{\r\n\tnameEdit_->setText(name);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VLNVEditor::setVersion()\r\n//-----------------------------------------------------------------------------\r\nvoid VLNVEditor::setVersion(QString const& version)\r\n{\r\n\tversionEdit_->setText(version);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VLNVEditor::dropEvent()\r\n//-----------------------------------------------------------------------------\r\nvoid VLNVEditor::dropEvent(QDropEvent* event)\r\n{\r\n\t// Retrieve the vlnv.\r\n\tQVariant data = event->mimeData()->imageData();\r\n\tif (!data.canConvert<VLNV>())\r\n    {\r\n\t\treturn;\r\n\t}\r\n\r\n\tVLNV vlnv = data.value<VLNV>();\r\n\r\n    // If filtering is enabled and a design/design configuration is dropped, check the implementation.\r\n    VLNV::IPXactType type = handler_->getDocumentType(vlnv);\r\n    if (implementationFilterEnabled_)\r\n    {\r\n        if (type == VLNV::DESIGN)\r\n        {\r\n            if (handler_->getDesign(vlnv)->getDesignImplementation() != implementationFilter_)\r\n            {\r\n                return;\r\n            }\r\n\r\n        }\r\n        else if (type == VLNV::DESIGNCONFIGURATION)\r\n        {\r\n            QSharedPointer<Document> libComp = handler_->getModel(vlnv);\r\n            QSharedPointer<DesignConfiguration> designConf = libComp.staticCast<DesignConfiguration>();\r\n            if (designConf->getDesignConfigImplementation() != implementationFilter_)\r\n            {\r\n                return;\r\n            }\r\n        }    \r\n    }\r\n\r\n    // Check for revision mismatch on drop, if revision filtering is enabled.\r\n    if (auto document = handler_->getModelReadOnly(vlnv); \r\n        revisionFilterEnabled_ && document->getRevision() != revisionFilter_)\r\n    {\r\n        QMessageBox::warning(this, QCoreApplication::applicationName(),\r\n            tr(\"Dropped item cannot use different IP-XACT standard revision than the item being edited.\"),\r\n            QMessageBox::Close, QMessageBox::Close);\r\n        return;\r\n    }\r\n\r\n\tsetVLNV(vlnv);\r\n\tevent->acceptProposedAction();\r\n\r\n    // for abs def and bus def there is additional option to set the paired vlnv editor\r\n    if (type == VLNV::BUSDEFINITION)\r\n    {\r\n        // if there is only one abs def for the dropped bus def\r\n        QList<VLNV> absDefVLNVs;\r\n        if (handler_->getChildren(absDefVLNVs, vlnv) == 1)\r\n        {\r\n            emit setAbsDef(absDefVLNVs.first());\r\n        }\r\n\r\n        // if there are more than one abs defs for the bus def\r\n        else if (absDefVLNVs.size() > 1)\r\n        {\r\n            // if the signal is connected then inform user that the abs def must be\r\n            // selected manually\r\n            if (receivers(SIGNAL(setAbsDef(const VLNV&))) > 0)\r\n            {\r\n                QMessageBox::information(this, QCoreApplication::applicationName(),\r\n                    tr(\"More than one abstraction definitions exist for the dropped\"\r\n                    \" bus definition. Select one manually from the library.\"),\r\n                    QMessageBox::Close, QMessageBox::Close);\r\n            }\r\n        }\r\n\r\n    }\r\n    else if(type == VLNV::ABSTRACTIONDEFINITION)\r\n    {\r\n        QSharedPointer<Document> libComp = handler_->getModel(vlnv);\r\n        QSharedPointer<AbstractionDefinition> absDef = libComp.staticCast<AbstractionDefinition>();\r\n        Q_ASSERT(absDef);\r\n\r\n        VLNV busDefVLNV = absDef->getBusType();\r\n        emit setBusDef(busDefVLNV);\r\n    }\r\n\r\n    emit vlnvEdited();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VLNVEditor::dragEnterEvent()\r\n//-----------------------------------------------------------------------------\r\nvoid VLNVEditor::dragEnterEvent( QDragEnterEvent* event )\r\n{\r\n\tif (event->mimeData()->hasImage())\r\n    {\r\n\t\t// Retrieve the vlnv.\r\n\t\tQVariant data = event->mimeData()->imageData();\r\n\t\tif (!data.canConvert<VLNV>())\r\n        {\r\n\t\t\treturn;\r\n\t\t}\r\n\r\n\t\tVLNV vlnv = data.value<VLNV>();\r\n\t\t// if the vlnv is of correct type\r\n\t\tif (contentTypes_.contains(handler_->getDocumentType(vlnv)))\r\n        {\r\n\t\t\tevent->acceptProposedAction();\r\n\t\t}\r\n\t}\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VLNVEditor::setFirmnessFilter()\r\n//-----------------------------------------------------------------------------\r\nvoid VLNVEditor::setFirmnessFilter(bool on, KactusAttribute::Firmness firmness /*= KTS_TEMPLATE*/)\r\n{\r\n    dataTree_.setFirmnessFilter(on, firmness);\r\n    dirty_ = true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VLNVEditor::setHierarchyFilter()\r\n//-----------------------------------------------------------------------------\r\nvoid VLNVEditor::setHierarchyFilter(bool on, KactusAttribute::ProductHierarchy productHier /*= KactusAttribute::KTS_IP*/)\r\n{\r\n    dataTree_.setHierarchyFilter(on, productHier);\r\n    dirty_ = true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VLNVEditor::setImplementationFilter()\r\n//-----------------------------------------------------------------------------\r\nvoid VLNVEditor::setImplementationFilter(bool on, KactusAttribute::Implementation implementation /*= KTS_HW*/)\r\n{\r\n    dataTree_.setImplementationFilter(on, implementation);\r\n    dirty_ = true;\r\n    implementationFilterEnabled_ = on;\r\n    implementationFilter_ = implementation;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VLNVEditor::setRevisionFilter()\r\n//-----------------------------------------------------------------------------\r\nvoid VLNVEditor::setRevisionFilter(bool on, Document::Revision revision /*= Document::Revision::Std22*/)\r\n{\r\n    dataTree_.setRevisionFilter(on, revision);\r\n    dirty_ = true;\r\n    revisionFilterEnabled_ = on;\r\n    revisionFilter_ = revision;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VLNVEditor::updateFiltering()\r\n//-----------------------------------------------------------------------------\r\nvoid VLNVEditor::updateFiltering()\r\n{\r\n    dataTree_.clear();\r\n    dataTree_.parse(handler_, contentTypes_);\r\n    dirty_ = false;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VLNVEditor::setMandatory()\r\n//-----------------------------------------------------------------------------\r\nvoid VLNVEditor::setMandatory(bool mandatory)\r\n{\r\n\tvendorEdit_->setProperty(\"mandatoryField\", mandatory);\r\n\tlibraryEdit_->setProperty(\"mandatoryField\", mandatory);\r\n\tnameEdit_->setProperty(\"mandatoryField\", mandatory);\r\n\tversionEdit_->setProperty(\"mandatoryField\", mandatory);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VLNVEditor::addNameExtension()\r\n//-----------------------------------------------------------------------------\r\nvoid VLNVEditor::addNameExtension(QString const& extension)\r\n{\r\n    if (nameExtensionLabel_.text().isEmpty())\r\n    {\r\n        nameExtensionLabel_.setText(extension);\r\n    }\r\n    else\r\n    {\r\n        nameExtensionLabel_.setText(nameExtensionLabel_.text() + \"/\" + extension);\r\n    }\r\n\r\n    nameExtensionLabel_.setVisible(true);\r\n\r\n    dataTree_.addExtensionFilter(extension);\r\n    dirty_ = true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VLNVEditor::showEvent()\r\n//-----------------------------------------------------------------------------\r\nvoid VLNVEditor::showEvent(QShowEvent* event)\r\n{\r\n    if (dirty_)\r\n    {\r\n        refresh();\r\n    }\r\n\r\n    QGroupBox::showEvent(event);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VLNVEditor::focusNextPrevChild()\r\n//-----------------------------------------------------------------------------\r\nbool VLNVEditor::focusNextPrevChild(bool next)\r\n{\r\n    // Function overridden to fix tab and shift+tab behavior when created by delegate of EditableTableView.\r\n\r\n    if (next)\r\n    {\r\n        if (vendorEdit_->hasFocus())\r\n        {\r\n            libraryEdit_->setFocus();\r\n            return true;\r\n        }\r\n        else if (libraryEdit_->hasFocus())\r\n        {\r\n            nameEdit_->setFocus();\r\n            return true;\r\n        }\r\n        else if (nameEdit_->hasFocus())\r\n        {\r\n            versionEdit_->setFocus();\r\n            return true;\r\n        }\r\n    }\r\n    else\r\n    {\r\n        if (libraryEdit_->hasFocus())\r\n        {\r\n            vendorEdit_->setFocus();\r\n            return true;\r\n        }\r\n        else if (nameEdit_->hasFocus())\r\n        {\r\n            libraryEdit_->setFocus();\r\n            return true;\r\n        }\r\n        else if (versionEdit_->hasFocus())\r\n        {\r\n            nameEdit_->setFocus();\r\n            return true;\r\n        }\r\n    }\r\n\r\n    return QWidget::focusNextPrevChild(next);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VLNVEditor::refresh()\r\n//-----------------------------------------------------------------------------\r\nvoid VLNVEditor::refresh()\r\n{\r\n    updateFiltering();\r\n    updateMatcherItems();\r\n}\r\n"
  },
  {
    "path": "common/widgets/vlnvEditor/vlnveditor.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: vlnveditor.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Joni-Matti Maatta\r\n// Date: 7.2.2011\r\n//\r\n// Description:\r\n// VLNV editor group box.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef VLNVEDITOR_H\r\n#define VLNVEDITOR_H\r\n\r\n#include \"VLNVDataTree.h\"\r\n#include \"VLNVContentMatcher.h\"\r\n\r\n#include <IPXACTmodels/common/VLNV.h>\r\n#include <IPXACTmodels/kactusExtensions/KactusAttribute.h>\r\n\r\n#include <QGroupBox>\r\n#include <QLineEdit>\r\n#include <QDropEvent>\r\n#include <QDragEnterEvent>\r\n#include <QLabel>\r\n\r\nclass LibraryInterface;\r\nclass LibraryItem;\r\nclass AssistedLineEdit;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! VLNVEditor class.\r\n//-----------------------------------------------------------------------------\r\nclass VLNVEditor : public QGroupBox\r\n{\r\n    Q_OBJECT\r\n\r\npublic:\r\n\r\n    /*!\r\n     *  The constructor.\r\n     *\r\n     *    @param [in] type        The VLNV type which to edit.\r\n     *    @param [in] libHandler  The library handler.\r\n     *    @param [in] parentWnd   The parent window (having a title bar).\r\n     *    @param [in] parent      The parent widget.\r\n     */\r\n    VLNVEditor(VLNV::IPXactType type, LibraryInterface* libHandler, QWidget* parentWnd = 0, QWidget* parent = 0);\r\n\r\n    /*!\r\n     *  The destructor.\r\n     */\r\n    virtual ~VLNVEditor();\r\n\r\n    /*!\r\n     *  Adds a new VLNV object type to show in content assist.\r\n     */\r\n    void addContentType(VLNV::IPXactType type);\r\n\r\n    /*!\r\n     *  Sets the firmness filter on/off.\r\n     *\r\n     *    @param [in] on        If true, the filter is turned on; otherwise it is turned off.\r\n     *    @param [in] firmness  The allowed firmness.\r\n     */\r\n    void setFirmnessFilter(bool on, KactusAttribute::Firmness firmness = KactusAttribute::TEMPLATE);\r\n\r\n    /*!\r\n     *  Sets the product hierarchy filter on/off.\r\n     *\r\n     *    @param [in] on           If true, the filter is turned on; otherwise it is turned off.\r\n     *    @param [in] productHier  The allowed product hierarchy.\r\n     */\r\n    void setHierarchyFilter(bool on, KactusAttribute::ProductHierarchy productHier = KactusAttribute::IP);\r\n\r\n    /*!\r\n     *  Sets the implementation filter on/off.\r\n     *\r\n     *    @param [in] on              If true, the filter is turned on; otherwise it is turned off.\r\n     *    @param [in] implementation  The allowed implementation.\r\n     */\r\n    void setImplementationFilter(bool on, KactusAttribute::Implementation implementation = KactusAttribute::HW);\r\n\r\n    void setRevisionFilter(bool on, Document::Revision revision = Document::Revision::Std22);\r\n\r\n    /*!\r\n     *  Adds a new name extension that will be shown in the dialog.\r\n     *\r\n     *    @param [in] extension The extension to add.\r\n     */\r\n    void addNameExtension(QString const& extension);\r\n\r\n    /*!\r\n     *  Generates a VLNV that matches the contents of the editor.\r\n     */\r\n    VLNV getVLNV() const;\r\n\r\n    /*!\r\n     *  Returns true if the contents of the editor are valid for a VLNV.\r\n     */\r\n    bool isValid() const;\r\n\r\n\t/*!\r\n\t * Checks if the editor contains text in any field.\r\n\t */\r\n\tbool isEmpty() const;\r\n\r\nsignals:\r\n\r\n    /*!\r\n     *  Emitted when the contents of the editor have changed.\r\n     */\r\n    void contentChanged();\r\n\r\n    /*!\r\n     *  Emitted when the user edits the VLNV in the editor.\r\n     */\r\n    void vlnvEdited();\r\n\r\n\t/*!\r\n     *  Emitted when a vlnv for abstraction definition is dropped to this editor.\r\n\t *\r\n\t *    @param [in] busDefVLNV The vlnv of the matching bus definition.\r\n\t */\r\n\tvoid setBusDef(const VLNV& busDefVLNV);\r\n\r\n\t/*!\r\n     *  Emitted when a vlnv for bus definition is dropped to this editor. If there are several matching\r\n     *  abstraction definitions then this is not emitted.\r\n\t * \r\n     *    @param [in] absDefVLNV  Identifies the vlnv of matching abstraction definition.\r\n\t */\r\n\tvoid setAbsDef(const VLNV& absDefVLNV);\r\n\r\npublic slots:\r\n\t\r\n    /*!\r\n     *  Set the widget to be mandatory or not. The default setting is mandatory on.\r\n\t *\r\n\t *    @param [in] mandatory   If true then all 4 vlnv fields are displayed as mandatory fields.\r\n\t */\r\n\tvoid setMandatory(bool mandatory);\r\n\r\n\t/*! \r\n\t *  Set the contents of the editor to match the given VLNV.\r\n\t *\r\n\t *\t\t@param [in] vlnv The VLNV. \r\n\t */\r\n\tvoid setVLNV(VLNV const& vlnv);\r\n\r\n    /*!\r\n     *  Updates the data tree.\r\n     */\r\n    void updateFiltering();\r\n\r\n    /*!\r\n     *  Updates all matcher items based on the contents of the VLNV editor fields.\r\n     */\r\n    void updateMatcherItems();\r\n\r\n    /*!\r\n     *  Called when the vendor field has changed.\r\n     */\r\n    void updateLibraryMatcherItem();\r\n\r\n    /*!\r\n     *  Called when the library field has changed.\r\n     */\r\n    void updateNameMatcherItem();\r\n\r\n    /*!\r\n     *  Called when the name field has changed.\r\n     */\r\n    void updateVersionMatcherItem();\r\n\r\n\t/*!\r\n     *  Sets the vendor-field to contain the given string.\r\n     */\r\n\tvoid setVendor(QString const& vendor);\r\n\r\n\t/*!\r\n     *  Sets the library-field to contain the given string.\r\n     */\r\n\tvoid setLibrary(QString const& library);\r\n\r\n\t/*!\r\n     *  Sets the name-field to contain the given string.\r\n     */\r\n\tvoid setName(QString const& name);\r\n\r\n\t/*!\r\n     *  Sets the version-field to contain the given string.\r\n     */\r\n\tvoid setVersion(QString const& version);\r\n\r\nprotected:\r\n\t\r\n    /*!\r\n     *  Handler for drop events on drag & drop\r\n\t *\r\n\t *    @param [in] event   Pointer to the drop event.\r\n\t */\r\n\tvirtual void dropEvent(QDropEvent* event);\r\n\r\n\t/*!\r\n     *  Handler for drag enter events in drag & drop.\r\n\t *\r\n\t *    @param [in] event   Pointer to the event.\r\n\t */\r\n\tvirtual void dragEnterEvent(QDragEnterEvent* event);\r\n    \r\n    /*!\r\n     *  Handler for the show event.\r\n     *\r\n     *    @param [in] event   Pointer to the show event.\r\n     */\r\n    virtual void showEvent(QShowEvent* event);\r\n    \r\n    /*!\r\n     *\tFinds a new widget to give the keyboard focus to with tab and shift+tab.\r\n     *  \r\n     *    @param [in] next     Searches forward if true, otherwise searches backwards.\r\n     *\t    \r\n     *    @return True if it can find a new widget, false if it can't\r\n     */\r\n    bool focusNextPrevChild(bool next) override;\r\n\r\nprivate slots:\r\n\r\n    /*!\r\n     *  Refreshes the filtering and matcher items.\r\n     */\r\n    void refresh();\r\n\r\nprivate:\r\n    // Disable copying.\r\n    VLNVEditor(VLNVEditor const& rhs);\r\n    VLNVEditor& operator=(VLNVEditor const& rhs);\r\n\r\n    /*!\r\n     *  Initializes the Qt connections between signals and slots.\r\n     */\r\n    void initConnections();\r\n\r\n    /*!\r\n     *  Initializes the widgets of the vlnv editor.\r\n     *\r\n     *    @param [in] parentWnd   The parent window.\r\n     */\r\n    void initWidgets(QWidget* parentWnd);\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! The VLNV type which to edit.\r\n    VLNV::IPXactType type_;\r\n\r\n    //! The VLNV types which to show in content assist.\r\n    QList<VLNV::IPXactType> contentTypes_;\r\n\r\n    //! True if the filtering is \"dirty\" and needs to be updated.\r\n    bool dirty_;\r\n\r\n    //! The VLNV data tree.\r\n    VLNVDataTree dataTree_;\r\n\r\n    //! Line edit for the vendor element.\r\n    AssistedLineEdit* vendorEdit_;\r\n\r\n    //! Content matcher for the vendor field.\r\n    VLNVContentMatcher vendorMatcher_;\r\n\r\n    //! Line edit for the library element.\r\n    AssistedLineEdit* libraryEdit_;\r\n\r\n    //! Content matcher for the library field.\r\n    VLNVContentMatcher libraryMatcher_;\r\n\r\n    //! Line edit for the name element.\r\n    AssistedLineEdit* nameEdit_;\r\n\r\n    //! Name extension label.\r\n    QLabel nameExtensionLabel_;\r\n\r\n    //! Content matcher for the name field.\r\n    VLNVContentMatcher nameMatcher_;\r\n\r\n    //! Line edit for the version element.\r\n    AssistedLineEdit* versionEdit_;\r\n\r\n    //! Content matcher for the version field.\r\n    VLNVContentMatcher versionMatcher_;\r\n\r\n\t//! Pointer to the instance that manages the library\r\n\tLibraryInterface* handler_;\r\n\r\n    //! Implementation filter data.\r\n    bool implementationFilterEnabled_ = false;\r\n\r\n    //! Implementation filter.\r\n    KactusAttribute::Implementation implementationFilter_;\r\n\r\n    //! Revision filter.\r\n    bool revisionFilterEnabled_ = false;\r\n    Document::Revision revisionFilter_;\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n\r\n#endif // VLNVEDITOR_H"
  },
  {
    "path": "configure",
    "content": "#!/bin/sh\n\n# Change this to your Qt binaries directory.\nQTBIN_PATH=\"\"\n\necho \"Configuring Kactus2...\"\necho \"\"\n\n\nprint_success() {\n    if [ -f \"Makefile\" ];\n    then\n        echo \"\"\n        echo \"Kactus2 has now been configured. Run make to start the build.\"\n        echo \"To install, run make install after the build has completed.\"\n    else\n       echo \"\"\n       echo \"The makefile was not created.\"\n    fi\n}\n\n# Auto search QTBIN_PATH when empty and qmake already installed.\nif [ -z \"${QTBIN_PATH}\" ]; then\n    if command -v qmake6 >/dev/null 2>&1; then\n        # Default to qmake6, which will exist on some linux distributions.\n        QTBIN_PATH=\"$(qmake6 -query QT_INSTALL_BINS)/\"\n        QTLIBEXEC_PATH=\"$(qmake6 -query QT_INSTALL_LIBEXECS)/\"\n    elif command -v qmake >/dev/null 2>&1; then\n        # qmake exists on the vast majority of linux distributions.\n        QTBIN_PATH=\"$(qmake -query QT_INSTALL_BINS)/\"\n        QTLIBEXEC_PATH=\"$(qmake -query QT_INSTALL_LIBEXECS)/\"\n    fi\nfi\n\n# Generate compressed help files.\necho \"Generating compressed help files...\"\nif command -v ${QTBIN_PATH}qhelpgenerator >/dev/null 2>&1; then\n    \"${QTBIN_PATH}qhelpgenerator\" Help/kactus2help.qhcp -o Help/Kactus2Help.qhc\nelif command -v ${QTLIBEXEC_PATH}qhelpgenerator >/dev/null 2>&1; then\n    # QT6 put qhelpgenerator at QTLIBEXEC_PATH\n    \"${QTLIBEXEC_PATH}qhelpgenerator\" Help/kactus2help.qhcp -o Help/Kactus2Help.qhc\nelse\n    echo \"Qhelpgenerator not found. Please set variable QTBIN_PATH to Qt binary files.\"\nfi\n\nif command -v ${QTBIN_PATH}qmake >/dev/null 2>&1; then\n   echo \"Running qmake...\"\n   \"${QTBIN_PATH}qmake\" Kactus2_Solution.pro\n   print_success\nelse\n    echo \"Qmake not found. Please set variable QTBIN_PATH to Qt binary files.\"\nfi\n"
  },
  {
    "path": "createhelp",
    "content": "#!/bin/sh\n\n# Change this to your Qt binaries directory.\nQTBIN_PATH=\"\"\n\n# Auto search QTBIN_PATH when empty and qmake already installed.\nif [ -z \"${QTBIN_PATH}\" ]; then\n    if command -v qmake6 >/dev/null 2>&1; then\n        # Default to qmake6, which will exist on some linux distributions.\n        QTBIN_PATH=\"$(qmake6 -query QT_INSTALL_BINS)/\"\n        QTLIBEXEC_PATH=\"$(qmake6 -query QT_INSTALL_LIBEXECS)/\"\n    elif command -v qmake >/dev/null 2>&1; then\n        # qmake exists on the vast majority of linux distributions.\n        QTBIN_PATH=\"$(qmake -query QT_INSTALL_BINS)/\"\n        QTLIBEXEC_PATH=\"$(qmake -query QT_INSTALL_LIBEXECS)/\"\n    fi\nfi\n\nif [ ! -f Help/Kactus2Help.qch ] || [ ! -f Help/Kactus2Help.qhc ]; then\n    if command -v ${QTBIN_PATH}qhelpgenerator >/dev/null 2>&1; then\n        \"${QTBIN_PATH}qhelpgenerator\" Help/kactus2help.qhp -o Help/Kactus2Help.qch\n    elif command -v ${QTLIBEXEC_PATH}qhelpgenerator >/dev/null 2>&1; then\n        # QT6 put qhelpgenerator at QTLIBEXEC_PATH\n        \"${QTLIBEXEC_PATH}qhelpgenerator\" Help/kactus2help.qhp -o Help/Kactus2Help.qch\n    else\n        echo \"Qhelpgenerator not found. Please set variable QTBIN_PATH to Qt binary files.\"\n    fi\nfi\n\nrm -R -f executable/Help\nmkdir executable/Help\ncp -f Help/Kactus2Help.qhc executable/Help/Kactus2Help.qhc\ncp -f Help/Kactus2Help.qch executable/Help/Kactus2Help.qch\n"
  },
  {
    "path": "editors/AbstractionDefinitionEditor/AbsDefParameterReferenceCounter.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: AbsDefParameterReferenceCounter.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Anton Hagqvist\n// Date: 27.08.2024\n//\n// Description:\n// Calculates the amount of references made to abstraction definition parameters.\n//-----------------------------------------------------------------------------\n\n#include \"AbsDefParameterReferenceCounter.h\"\n\n#include <IPXACTmodels/AbstractionDefinition/AbstractionDefinition.h>\n#include <IPXACTmodels/AbstractionDefinition/PortAbstraction.h>\n#include <IPXACTmodels/AbstractionDefinition/WireAbstraction.h>\n#include <IPXACTmodels/AbstractionDefinition/TransactionalAbstraction.h>\n#include <IPXACTmodels/AbstractionDefinition/WirePort.h>\n#include <IPXACTmodels/generaldeclarations.h>\n\n#include <KactusAPI/include/ParameterFinder.h>\n#include <KactusAPI/include/AbstractParameterInterface.h>\n\n\n//-----------------------------------------------------------------------------\n// Function: AbsDefParameterReferenceCounter::AbsDefParameterReferenceCounter()\n//-----------------------------------------------------------------------------\nAbsDefParameterReferenceCounter::AbsDefParameterReferenceCounter(QSharedPointer<ParameterFinder> parameterFinder, QSharedPointer<AbstractionDefinition> absDef):\n    ParameterReferenceCounter(parameterFinder),\n    absDef_(absDef)\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: AbsDefParameterReferenceCounter::setAbstractionDefinition()\n//-----------------------------------------------------------------------------\nvoid AbsDefParameterReferenceCounter::setAbstractionDefinition(QSharedPointer<AbstractionDefinition> absDef)\n{\n    absDef_ = absDef;\n}\n\n//-----------------------------------------------------------------------------\n// Function: AbsDefParameterReferenceCounter::countReferencesInPorts()\n//-----------------------------------------------------------------------------\nint AbsDefParameterReferenceCounter::countReferencesInWirePorts(QString const& parameterID)\n{\n    int references = 0;\n\n    if (!absDef_)\n    {\n        return 0;\n    }\n\n    for (auto const& port : absDef_->getPortsWithWire())\n    {\n        references += countReferencesInWirePort(parameterID, port->getWire());\n    }\n\n    return references;\n}\n\n//-----------------------------------------------------------------------------\n// Function: AbsDefParameterReferenceCounter::countReferencesInTransactionalPorts()\n//-----------------------------------------------------------------------------\nint AbsDefParameterReferenceCounter::countReferencesInTransactionalPorts(QString const& parameterID)\n{\n    int references = 0;\n\n    if (!absDef_)\n    {\n        return 0;\n    }\n\n    for (auto const& port : absDef_->getPortsWithTransactional())\n    {\n        references += countReferencesInTransactionalPort(parameterID, port->getTransactional());\n    }\n\n    return references;\n}\n\n//-----------------------------------------------------------------------------\n// Function: AbsDefParameterReferenceCounter::countReferencesInWirePort()\n//-----------------------------------------------------------------------------\nint AbsDefParameterReferenceCounter::countReferencesInWirePort(QString const& parameterID, QSharedPointer<WireAbstraction> wireAbstraction)\n{\n    int references = 0;\n\n    references += countReferencesInExpression(parameterID, wireAbstraction->getDefaultValue());\n\n    auto initiatorMode = absDef_->getRevision() == Document::Revision::Std22\n        ? General::InterfaceMode::INITIATOR\n        : General::InterfaceMode::MASTER;\n\n    auto targetMode = absDef_->getRevision() == Document::Revision::Std22\n        ? General::InterfaceMode::TARGET\n        : General::InterfaceMode::SLAVE;\n\n    if (wireAbstraction->hasInitiatorPort())\n    {\n        references += countReferencesInExpression(parameterID, wireAbstraction->getWidth(initiatorMode, parameterID));\n    }\n    \n    if (wireAbstraction->hasTargetPort())\n    {\n        references += countReferencesInExpression(parameterID, wireAbstraction->getWidth(targetMode, parameterID));\n    }\n    \n    if (wireAbstraction->getSystemPorts()->isEmpty() == false)\n    {\n        for (auto const& systemPort : *wireAbstraction->getSystemPorts())\n        {\n            references += countReferencesInExpression(parameterID, systemPort->getWidth());\n        }\n    }\n\n    return references;\n}\n\n//-----------------------------------------------------------------------------\n// Function: AbsDefParameterReferenceCounter::countReferencesInTransactionalPort()\n//-----------------------------------------------------------------------------\nint AbsDefParameterReferenceCounter::countReferencesInTransactionalPort(QString const& parameterID, QSharedPointer<TransactionalAbstraction> transactional)\n{\n    int references = 0;\n\n    auto initiatorMode = absDef_->getRevision() == Document::Revision::Std22\n        ? General::InterfaceMode::INITIATOR\n        : General::InterfaceMode::MASTER;\n\n    auto targetMode = absDef_->getRevision() == Document::Revision::Std22\n        ? General::InterfaceMode::TARGET\n        : General::InterfaceMode::SLAVE;\n\n    if (transactional->hasInitiatorPort())\n    {\n        references += countReferencesInExpression(parameterID, transactional->getWidth(initiatorMode, parameterID));\n    }\n    \n    if (transactional->hasTargetPort())\n    {\n        references += countReferencesInExpression(parameterID, transactional->getWidth(targetMode, parameterID));\n    }\n\n    return references;\n}\n\n//-----------------------------------------------------------------------------\n// Function: AbsDefParameterReferenceCounter::recalculateReferencesToParameters()\n//-----------------------------------------------------------------------------\nvoid AbsDefParameterReferenceCounter::recalculateReferencesToParameters(QStringList const& parameterList, AbstractParameterInterface* parameterInterface)\n{\n    for (auto const& parameterName : parameterList)\n    {\n        int referenceCount = 0;\n        QString parameterID = QString::fromStdString(parameterInterface->getID(parameterName.toStdString()));\n        if (!parameterID.isEmpty())\n        {\n            referenceCount += countReferencesInWirePorts(parameterID);\n            referenceCount += countReferencesInTransactionalPorts(parameterID);\n            referenceCount += countReferencesInParameters(parameterID, absDef_->getParameters());\n\n            parameterInterface->setUsageCount(parameterName.toStdString(), referenceCount);\n        }\n    }\n}\n"
  },
  {
    "path": "editors/AbstractionDefinitionEditor/AbsDefParameterReferenceCounter.h",
    "content": "//-----------------------------------------------------------------------------\n// File: AbsDefParameterReferenceCounter.h\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Anton Hagqvist\n// Date: 27.08.2024\n//\n// Description:\n// Calculates the amount of references made to abstraction definition parameters.\n//-----------------------------------------------------------------------------\n\n#ifndef ABSDEFPARAMETERREFERENCECOUNTER_H\n#define ABSDEFPARAMETERREFERENCECOUNTER_H\n\n#include <editors/ComponentEditor/referenceCounter/ParameterReferenceCounter.h>\n\nclass AbstractionDefinition;\nclass AbstractParameterInterface;\nclass WirePort;\nclass WireAbstraction;\nclass TransactionalPort;\nclass TransactionalAbstraction;\n\nclass AbsDefParameterReferenceCounter : public ParameterReferenceCounter\n{\n    Q_OBJECT\n\npublic:\n\n    /*!\n     *\tThe constructor.\n     *  \n     *    @param [in] parameterFinder     The parameter finder to use.\n     *    @param [in] absDef              The abstraction definition whose parameter usage is calculated.\n     */\n    AbsDefParameterReferenceCounter(QSharedPointer<ParameterFinder> parameterFinder, QSharedPointer<AbstractionDefinition> absDef);\n    \n    AbsDefParameterReferenceCounter(AbsDefParameterReferenceCounter const& other) = delete;\n    AbsDefParameterReferenceCounter& operator=(AbsDefParameterReferenceCounter const& other) = delete;\n    \n    virtual ~AbsDefParameterReferenceCounter() = default;\n\n    /*!\n     *\tSet a new abstraction definition.\n     *  \n     *    @param [in] absDef     The new abstraction definition.\n     */\n    void setAbstractionDefinition(QSharedPointer<AbstractionDefinition> absDef);\n\n    /*!\n     *\tCount references to abs def parameters in wire ports.\n     *  \n     *    @param [in] parameterID     The parameter ID to look for.\n     *\t    \n     * \t    @return The parameter usage count in wire ports.\n     */\n    int countReferencesInWirePorts(QString const& parameterID);\n\n    /*!\n     *\tCount references to abs def parameters in transactional ports.\n     *\n     *    @param [in] parameterID     The parameter ID to look for.\n     *\n     * \t    @return The parameter usage count in transactional ports.\n     */\n    int countReferencesInTransactionalPorts(QString const& parameterID);\n\n    /*!\n     *\tCount references to abs def parameters in a single wire port.\n     *  \n     *    @param [in] parameterID     The parameter ID to look for.\n     *    @param [in] wirePort        The wire port to look into.\n     *\t    \n     * \t    @return The parameter usage count in the wire port.\n     */\n    int countReferencesInWirePort(QString const& parameterID, QSharedPointer<WireAbstraction> wirePort);\n\n    /*!\n     *\tCount references to abs def parameters in a single transactional port.\n     *\n     *    @param [in] parameterID     The parameter ID to look for.\n     *    @param [in] transactional   The transactional port to look into.\n     *\n     * \t    @return The parameter usage count in the transactional port.\n     */\n    int countReferencesInTransactionalPort(QString const& parameterID, QSharedPointer<TransactionalAbstraction> transactional);\n\npublic slots:\n\n    /*!\n     *  Recalculate references made to the selected parameters.\n     *\n     *    @param [in] parameterList       The selected parameters.\n     *    @param [in] parameterInterface  Interface for accessing parameters.\n     */\n    virtual void recalculateReferencesToParameters(QStringList const& parameterList,\n        AbstractParameterInterface* parameterInterface) override;\n\nprivate:\n\n    //! The current abstraction definition in use.\n    QSharedPointer<AbstractionDefinition> absDef_;\n};\n\n#endif // ABSDEFPARAMETERREFERENCECOUNTER_H"
  },
  {
    "path": "editors/AbstractionDefinitionEditor/AbsDefParameterReferenceTree.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: AbsDefParameterReferenceTree.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Anton Hagqvist\n// Date: 27.08.2024\n//\n// Description:\n// Tree widget for displaying references to a parameter within an abstraction definition.\n//-----------------------------------------------------------------------------\n\n#include \"AbsDefParameterReferenceTree.h\"\n\n#include \"AbsDefParameterReferenceCounter.h\"\n\n#include <IPXACTmodels/AbstractionDefinition/AbstractionDefinition.h>\n#include <IPXACTmodels/AbstractionDefinition/PortAbstraction.h>\n\n#include <IPXACTmodels/AbstractionDefinition/WireAbstraction.h>\n#include <IPXACTmodels/AbstractionDefinition/WirePort.h>\n\n#include <IPXACTmodels/AbstractionDefinition/TransactionalAbstraction.h>\n#include <IPXACTmodels/AbstractionDefinition/TransactionalPort.h>\n\n//-----------------------------------------------------------------------------\n// Function: AbsDefParameterReferenceTree::AbsDefParameterReferenceTree()\n//-----------------------------------------------------------------------------\nAbsDefParameterReferenceTree::AbsDefParameterReferenceTree(QSharedPointer<AbstractionDefinition> absDef,\n    QSharedPointer<AbsDefParameterReferenceCounter> referenceCounter, \n    QSharedPointer<ExpressionFormatter> expressionFormatter) :\nParameterReferenceTree(expressionFormatter),\nreferenceCounter_(referenceCounter),\nabsDef_(absDef)\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: AbsDefParameterReferenceTree::setAbsDef()\n//-----------------------------------------------------------------------------\nvoid AbsDefParameterReferenceTree::setAbsDef(QSharedPointer<AbstractionDefinition> absDef)\n{\n    absDef_ = absDef;\n}\n\n//-----------------------------------------------------------------------------\n// Function: AbsDefParameterReferenceTree::setupTree()\n//-----------------------------------------------------------------------------\nvoid AbsDefParameterReferenceTree::setupTree()\n{\n    if (!absDef_)\n    {\n        createTopItem(\"Abstraction definition does not exist.\");\n        return;\n    }\n\n    QString const& targetId = getTargetID();\n\n    // Create references in other parameters.\n    if (referenceCounter_->countReferencesInParameters(targetId, absDef_->getParameters()) > 0)\n    {\n        QTreeWidgetItem* topParametersItem = createTopItem(\"Parameters\");\n        createParameterReferences(absDef_->getParameters(), topParametersItem);\n    }\n\n    int referencesInWirePorts = referenceCounter_->countReferencesInWirePorts(targetId);\n    int referencesInTransactionalPorts = referenceCounter_->countReferencesInTransactionalPorts(targetId);\n\n    auto initiatorMode = absDef_->getRevision() == Document::Revision::Std22\n        ? General::InterfaceMode::INITIATOR\n        : General::InterfaceMode::MASTER;\n\n    auto targetMode = absDef_->getRevision() == Document::Revision::Std22\n        ? General::InterfaceMode::TARGET\n        : General::InterfaceMode::SLAVE;\n\n    // Create references in ports, if there are any.\n    if (referencesInWirePorts + referencesInTransactionalPorts > 0)\n    {\n        auto topPortsItem = createTopItem(\"Ports\");\n        \n        if (referencesInWirePorts > 0)\n        {\n            auto wirePortsItem = createMiddleItem(QStringLiteral(\"Wires\"), topPortsItem);\n\n            for (auto const& portWithWire : absDef_->getPortsWithWire())\n            {\n                auto wireAbstraction = portWithWire->getWire();\n                QTreeWidgetItem* singleWirePortItem = nullptr;\n\n                if (portWithWire->getDefaultValue().contains(targetId))\n                {\n                    // Create wire port item only if necessary\n                    singleWirePortItem = createMiddleItem(portWithWire->name(), wirePortsItem);\n                    createItem(QStringLiteral(\"Default value\"), portWithWire->getDefaultValue(), singleWirePortItem);\n                }\n\n                if (wireAbstraction->hasMode(initiatorMode, QString()) && \n                    wireAbstraction->getInitiatorPort()->getWidth().contains(targetId))\n                {\n                    if (!singleWirePortItem)\n                    {\n                        singleWirePortItem = createMiddleItem(portWithWire->name(), wirePortsItem);\n                    }\n\n                    auto initiatorItem = createMiddleItem(QStringLiteral(\"Initiator\"), singleWirePortItem);\n                    createItem(QStringLiteral(\"Width\"), wireAbstraction->getInitiatorPort()->getWidth(), initiatorItem);\n                }\n\n                if (wireAbstraction->hasMode(targetMode, QString()) &&\n                    wireAbstraction->getTargetPort()->getWidth().contains(targetId))\n                {\n                    if (!singleWirePortItem)\n                    {\n                        singleWirePortItem = createMiddleItem(portWithWire->name(), wirePortsItem);\n                    }\n\n                    auto targetItem = createMiddleItem(QStringLiteral(\"Target\"), singleWirePortItem);\n                    createItem(QStringLiteral(\"Width\"), wireAbstraction->getTargetPort()->getWidth(), targetItem);\n                }\n\n                for (auto const& systemPort : *wireAbstraction->getSystemPorts())\n                {\n                    if (systemPort->getWidth().contains(targetId))\n                    {\n                        if (!singleWirePortItem)\n                        {\n                            singleWirePortItem = createMiddleItem(portWithWire->name(), wirePortsItem);\n                        }\n\n                        auto systemItem = createMiddleItem(tr(\"System (%1)\").arg(systemPort->getSystemGroup()), singleWirePortItem);\n                        createItem(QStringLiteral(\"Width\"), systemPort->getWidth(), systemItem);\n                    }\n                }\n            }\n        }\n\n        if (referencesInTransactionalPorts > 0)\n        {\n            auto transactionalPortsItem = createMiddleItem(QStringLiteral(\"Transactionals\"), topPortsItem);\n            \n            for (auto const& portWithTransactional : absDef_->getPortsWithTransactional())\n            {\n                auto transactionalAbstraction = portWithTransactional->getTransactional();\n                \n                QTreeWidgetItem* singleTransactionalPortItem = nullptr;\n\n                if (transactionalAbstraction->hasMode(initiatorMode, QString()) &&\n                    transactionalAbstraction->getInitiatorPort()->getBusWidth().contains(targetId))\n                {\n                    singleTransactionalPortItem = createMiddleItem(portWithTransactional->name(), transactionalPortsItem);\n\n                    auto initiatorItem = createMiddleItem(QStringLiteral(\"Initiator\"), singleTransactionalPortItem);\n                    createItem(QStringLiteral(\"Bus width\"),\n                        transactionalAbstraction->getInitiatorPort()->getBusWidth(), initiatorItem);\n                }\n\n                if (transactionalAbstraction->hasMode(targetMode, QString()) &&\n                    transactionalAbstraction->getTargetPort()->getBusWidth().contains(targetId))\n                {\n                    if (!singleTransactionalPortItem)\n                    {\n                        singleTransactionalPortItem = createMiddleItem(portWithTransactional->name(), transactionalPortsItem);\n                    }\n\n                    auto targetItem = createMiddleItem(QStringLiteral(\"Target\"), singleTransactionalPortItem);\n                    createItem(QStringLiteral(\"Bus width\"), transactionalAbstraction->getTargetPort()->getBusWidth(), targetItem);\n                }\n\n                for (auto const& systemPort : *transactionalAbstraction->getSystemPorts())\n                {\n                    if (systemPort->getBusWidth().contains(targetId))\n                    {\n                        if (!singleTransactionalPortItem)\n                        {\n                            singleTransactionalPortItem = createMiddleItem(portWithTransactional->name(), transactionalPortsItem);\n                        }\n\n                        auto systemItem = createMiddleItem(tr(\"System (%1)\").arg(systemPort->getSystemGroup()), singleTransactionalPortItem);\n                        createItem(QStringLiteral(\"Bus width\"), systemPort->getBusWidth(), systemItem);\n                    }\n                }\n            }\n        }\n    }\n\n    if (topLevelItemCount() == 0)\n    {\n        createTopItem(\"No references found.\");\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: AbsDefParameterReferenceTree::getReferenceCounter()\n//-----------------------------------------------------------------------------\nQSharedPointer<ParameterReferenceCounter> AbsDefParameterReferenceTree::getReferenceCounter() const\n{\n    return referenceCounter_;\n}\n"
  },
  {
    "path": "editors/AbstractionDefinitionEditor/AbsDefParameterReferenceTree.h",
    "content": "//-----------------------------------------------------------------------------\n// File: AbsDefParameterReferenceTree.h\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Anton Hagqvist\n// Date: 27.08.2024\n//\n// Description:\n// Tree widget for displaying references to a parameter within an abstraction definition.\n//-----------------------------------------------------------------------------\n\n#ifndef ABSDEFPARAMETERREFERENCETREE_H\n#define ABSDEFPARAMETERREFERENCETREE_H\n\n#include <editors/ComponentEditor/parameterReferenceTree/ParameterReferenceTree.h>\n\nclass AbsDefParameterReferenceCounter;\nclass AbstractionDefinition;\n\nclass AbsDefParameterReferenceTree : public ParameterReferenceTree\n{\n    Q_OBJECT\n\npublic:\n    \n    /*!\n     *\tThe constructor.\n     *  \n     *    @param [in] absDef                  The abstraction definition.\n     *    @param [in] referenceCounter        The reference counter to use.\n     *    @param [in] expressionFormatter     The expression formatter to use.\n     */\n    AbsDefParameterReferenceTree(QSharedPointer<AbstractionDefinition> absDef,\n        QSharedPointer<AbsDefParameterReferenceCounter> referenceCounter,\n        QSharedPointer<ExpressionFormatter> expressionFormatter);\n\n    virtual ~AbsDefParameterReferenceTree() = default;\n\n    AbsDefParameterReferenceTree(AbsDefParameterReferenceTree const& other) = delete;\n    AbsDefParameterReferenceTree& operator=(AbsDefParameterReferenceTree const& other) = delete;\n\n    /*!\n     *\tSet a new abstraction definition.\n     *  \n     *    @param [in] absDef     The abstraction definition to set.\n     */\n    void setAbsDef(QSharedPointer<AbstractionDefinition> absDef);\n\nprivate:\n    \n    /*!\n     *  Setup the reference tree.\n     */\n    void setupTree() final;\n\n    /*!\n     *  Get the parameter reference calculator.\n     */\n    QSharedPointer<ParameterReferenceCounter> getReferenceCounter() const final;\n\n    //! The reference counter to use.\n    QSharedPointer<AbsDefParameterReferenceCounter> referenceCounter_;\n\n    //! The abstraction definition whose parameter references are counted.\n    QSharedPointer<AbstractionDefinition> absDef_;\n};\n\n#endif // ABSDEFPARAMETERREFERENCETREE_H\n"
  },
  {
    "path": "editors/AbstractionDefinitionEditor/AbstractionDefinitionEditor.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: AbstractionDefinitionEditor.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Antti Kamppi\n// Date: 20.6.2011\n//\n// Description:\n// Bus defition editor is an editor for Bus- and Abstraction definitions.\n//-----------------------------------------------------------------------------\n\n#include \"AbstractionDefinitionEditor.h\"\n\n#include <IPXACTmodels/common/VLNV.h>\n#include <IPXACTmodels/BusDefinition/validators/BusDefinitionValidator.h>\n#include <IPXACTmodels/AbstractionDefinition/validators/AbstractionDefinitionValidator.h>\n\n#include <common/dialogs/newObjectDialog/newobjectdialog.h>\n#include <common/widgets/summaryLabel/summarylabel.h>\n\n#include <KactusAPI/include/IPXactSystemVerilogParser.h>\n#include <KactusAPI/include/PortAbstractionInterface.h>\n#include <KactusAPI/include/ExpressionFormatter.h>\n\n#include \"AbsDefParameterReferenceCounter.h\"\n#include \"AbsDefParameterReferenceTree.h\"\n\n#include <editors/ComponentEditor/parameterReferenceTree/ParameterReferenceTreeWindow.h>\n\n#include <QApplication>\n#include <QFile>\n#include <QFileDialog>\n#include <QHBoxLayout>\n#include <QScrollArea>\n#include <QSplitter>\n#include <QVBoxLayout>\n\n//-----------------------------------------------------------------------------\n// Function: AbstractionDefinitionEditor::AbstractionDefinitionEditor()\n//-----------------------------------------------------------------------------\nAbstractionDefinitionEditor::AbstractionDefinitionEditor(QWidget *parent, LibraryInterface* libHandler, QSharedPointer<AbstractionDefinition> absDef, Document::Revision revision):\nTabDocument(parent, libHandler, DOC_PROTECTION_SUPPORT),\nabsDef_(absDef),\nexpressionFormatter_(new ExpressionFormatter(absDefParameterFinder_)),\nexpressionParser_(new IPXactSystemVerilogParser(absDefParameterFinder_)),\nportValidator_(new PortAbstractionValidator(libHandler, expressionParser_)),\nabsDefGroup_(revision, absDef, expressionFormatter_, expressionParser_, absDefParameterFinder_, libHandler,\n    createPortAbstractionInterface(), createPortAbstractionInterface(), this),\nabsDefinitionValidator_(new AbstractionDefinitionValidator(libHandler, expressionParser_)),\nreferenceCounter_(new AbsDefParameterReferenceCounter(absDefParameterFinder_, absDef)),\nparameterReferenceTree_(new AbsDefParameterReferenceTree(absDef, referenceCounter_, expressionFormatter_)),\nreferenceTreeWindow_(new ParameterReferenceTreeWindow(parameterReferenceTree_))\n{\n    setDocumentType(DocumentType::ABSTRACTION_DEFINITION);\n\n    if (absDef_)\n    {\n        absDefGroup_.setAbsDef(absDef_);\n\n        VLNV vlnv = absDef_->getVlnv();\n        setDocumentName(vlnv.getName() + \" (\" + vlnv.getVersion() + \")\");\n\n        // Open in unlocked mode by default only if the version is draft.\n        setProtection(vlnv.getVersion() != \"draft\");\n    }\n    else\n    {\n        setProtection(true);\n    }\n\n    setupLayout();\n\n    connect(&absDefGroup_, SIGNAL(contentChanged()), this, SIGNAL(contentChanged()), Qt::UniqueConnection);\n\n    connect(&absDefGroup_, SIGNAL(errorMessage(const QString&)),\n        this, SIGNAL(errorMessage(const QString&)), Qt::UniqueConnection);\n    connect(&absDefGroup_, SIGNAL(noticeMessage(const QString&)),\n        this, SIGNAL(noticeMessage(const QString&)), Qt::UniqueConnection);\n    connect(&absDefGroup_, SIGNAL(portRemoved(const QString&, const General::InterfaceMode)), \n        this, SIGNAL(portRemoved(const QString&, const General::InterfaceMode)), Qt::UniqueConnection);\n\n    connect(&absDefGroup_, SIGNAL(increaseReferences(QString)),\n        referenceCounter_.data(), SLOT(increaseReferenceCount(QString)), Qt::UniqueConnection);\n\n    connect(&absDefGroup_, SIGNAL(decreaseReferences(QString)),\n        referenceCounter_.data(), SLOT(decreaseReferenceCount(QString)), Qt::UniqueConnection);\n\n    connect(&absDefGroup_, SIGNAL(openReferenceTree(QString const&, QString const&)),\n        this, SLOT(onOpenReferenceTree(QString const&, QString const&)), Qt::UniqueConnection);\n\n    connect(&absDefGroup_, SIGNAL(recalculateReferencesToParameters(QVector<QString> const&, AbstractParameterInterface*)),\n        referenceCounter_.data(), SLOT(recalculateReferencesToParameters(QVector<QString> const&, AbstractParameterInterface*)), Qt::UniqueConnection);\n}\n\n//-----------------------------------------------------------------------------\n// Function: AbstractionDefinitionEditor::getIdentifyingVLNV()\n//-----------------------------------------------------------------------------\nVLNV AbstractionDefinitionEditor::getIdentifyingVLNV() const\n{\n    return getDocumentVLNV();\n}\n\n//-----------------------------------------------------------------------------\n// Function: AbstractionDefinitionEditor::refresh()\n//-----------------------------------------------------------------------------\nvoid AbstractionDefinitionEditor::refresh()\n{\n    QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));\n\n    if (absDef_)\n    {\n        absDef_ = getLibHandler()->getModel(absDef_->getVlnv()).dynamicCast<AbstractionDefinition>();\n        absDefGroup_.setAbsDef(absDef_);\n        referenceCounter_->setAbstractionDefinition(absDef_);\n        parameterReferenceTree_->setAbsDef(absDef_);\n    }\n\n    // The document is no longer modified.\n    setModified(false);\n    TabDocument::refresh();\n\n    QApplication::restoreOverrideCursor();\n}\n\n//-----------------------------------------------------------------------------\n// Function: setProtection()\n//-----------------------------------------------------------------------------\nvoid AbstractionDefinitionEditor::setProtection(bool locked)\n{\n    TabDocument::setProtection(locked);\n    setEnabled(!locked);\n}\n\n//-----------------------------------------------------------------------------\n// Function: AbstractionDefinitionEditor::getDocumentVLNV()\n//-----------------------------------------------------------------------------\nVLNV AbstractionDefinitionEditor::getDocumentVLNV() const\n{\n    // If abstraction definition is being edited then use it as the identifier.\n    if (absDef_)\n    {\n        return absDef_->getVlnv();\n    }\n    else\n    {\n        return VLNV();\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: AbstractionDefinitionEditor::setAbsDef()\n//-----------------------------------------------------------------------------\nvoid AbstractionDefinitionEditor::setAbsDef(QSharedPointer<AbstractionDefinition> absDef)\n{\n    absDef_ = absDef;\n\n    if (absDef_) \n    {\n        absDefGroup_.setAbsDef(absDef_);\n        referenceCounter_->setAbstractionDefinition(absDef_);\n        parameterReferenceTree_->setAbsDef(absDef_);\n    }\n\n    absDefGroup_.setDisabled(!absDef_);\n    \n}\n\n//-----------------------------------------------------------------------------\n// Function: AbstractionDefinitionEditor::validate()\n//-----------------------------------------------------------------------------\nbool AbstractionDefinitionEditor::validate(QVector<QString>& errorList)\n{\n    absDefGroup_.save();\n    absDefinitionValidator_->findErrorsIn(errorList, absDef_);\n\n    return errorList.isEmpty();\n}\n\n//-----------------------------------------------------------------------------\n// Function: AbstractionDefinitionEditor::save()\n//-----------------------------------------------------------------------------\nbool AbstractionDefinitionEditor::save()\n{  \n    absDefGroup_.save();\n    getLibHandler()->writeModelToFile(absDef_);\n\n\treturn TabDocument::save();\n}\n\n//-----------------------------------------------------------------------------\n// Function: AbstractionDefinitionEditor::saveAs()\n//-----------------------------------------------------------------------------\nbool AbstractionDefinitionEditor::saveAs()\n{\n    // Ask the user for a new VLNV along with the directory.\n    VLNV vlnv;\n\n    VLNV absDefVLNV;\n    QString absDirectory;\n\n    if (!NewObjectDialog::saveAsDialog(this, getLibHandler(), absDef_->getVlnv(), vlnv, absDirectory))\n    {\n        return false;\n    }\n\n    absDefVLNV = vlnv;\n    absDefVLNV.setType(VLNV::ABSTRACTIONDEFINITION);\n    absDef_->setVlnv(absDefVLNV);\n\n\n    absDefGroup_.save();\n  \n    getLibHandler()->writeModelToFile(absDirectory, absDef_);\n\n    setDocumentName(vlnv.getName() + \" (\" + vlnv.getVersion() + \")\");\n    return TabDocument::saveAs();\n}\n\n//-----------------------------------------------------------------------------\n// Function: AbstractionDefinitionEditor::showEvent()\n//-----------------------------------------------------------------------------\nvoid AbstractionDefinitionEditor::showEvent(QShowEvent* event)\n{\n    TabDocument::showEvent(event);\n\n    if (absDef_->getRevision() == Document::Revision::Std22)\n    {\n        emit helpUrlRequested(\"definitions/abstractiondefinition2022.html\");\n    }\n    else\n    {\n        emit helpUrlRequested(\"definitions/abstractiondefinition.html\");\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: AbstractionDefinitionEditor::onOpenReferenceTree()\n//-----------------------------------------------------------------------------\nvoid AbstractionDefinitionEditor::onOpenReferenceTree(QString const& parameterID, QString const& parameterName)\n{\n    // Refresh references before opening window.\n    parameterReferenceTree_->setAbsDef(absDef_);\n    referenceTreeWindow_->openReferenceTree(parameterID, parameterName);\n}\n\n//-----------------------------------------------------------------------------\n// Function: AbstractionDefinitionEditor::setupLayout()\n//-----------------------------------------------------------------------------\nvoid AbstractionDefinitionEditor::setupLayout()\n{    \n    QWidget* absDefGroup = new QWidget(this);\n    QVBoxLayout* absLayout = new QVBoxLayout(absDefGroup);\n    absLayout->addWidget(new SummaryLabel(tr(\"Abstraction definition\"), this), 0, Qt::AlignCenter);\n    absLayout->addWidget(&absDefGroup_);\n    absLayout->setContentsMargins(0, 0, 0, 0);\n\n    QHBoxLayout* topLayout = new QHBoxLayout(this);\n    topLayout->addWidget(absDefGroup);\n}\n\n//-----------------------------------------------------------------------------\n// Function: AbstractionDefinitionEditor::()\n//-----------------------------------------------------------------------------\nPortAbstractionInterface* AbstractionDefinitionEditor::createPortAbstractionInterface()\n{\n    PortAbstractionInterface* portInterface(new PortAbstractionInterface(expressionParser_, expressionFormatter_));\n    portInterface->setPortAbstractionValidator(portValidator_);\n    return portInterface;\n}\n"
  },
  {
    "path": "editors/AbstractionDefinitionEditor/AbstractionDefinitionEditor.h",
    "content": "//-----------------------------------------------------------------------------\n// File: AbstractionDefinitionEditor.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Antti Kamppi\n// Date: 20.6.2011\n//\n// Description:\n// Bus defition editor is an editor for Abstraction definitions.\n//-----------------------------------------------------------------------------\n\n#ifndef ABSTRACTIONDEFINITIONEDITOR_H\n#define ABSTRACTIONDEFINITIONEDITOR_H\n\n#include <common/widgets/tabDocument/TabDocument.h>\n\n#include <IPXACTmodels/AbstractionDefinition/AbstractionDefinition.h>\n#include <IPXACTmodels/BusDefinition/BusDefinition.h>\n#include <IPXACTmodels/AbstractionDefinition/validators/PortAbstractionValidator.h>\n\n#include <KactusAPI/include/LibraryInterface.h>\n#include <KactusAPI/include/ListParameterFinder.h>\n\n#include \"absdefgroup.h\"\n\n#include <QSharedPointer>\n\nclass AbstractionDefinitionValidator;\nclass BusDefinitionValidator;\nclass IPXactSystemVerilogParser;\nclass PortAbstractionInterface;\nclass ExpressionFormatter;\nclass AbsDefParameterReferenceCounter;\nclass AbsDefParameterReferenceTree;\nclass ParameterReferenceTreeWindow;\n\n//-----------------------------------------------------------------------------\n//! Bus Editor is editor for Abstraction definition.\n//-----------------------------------------------------------------------------\nclass AbstractionDefinitionEditor : public TabDocument\n{\n\tQ_OBJECT\n\npublic:\n\n\t/*!\n     *  The constructor.\n\t *\n\t *    @param [in] parent          The owner of this widget.\n\t *    @param [in] libHandler      The instance that manages library.\n\t *    @param [in] busDef          The bus definition to edit.\n     *    @param [in] revision        Currently active IP-XACT revision.\n     */\n\tAbstractionDefinitionEditor(QWidget *parent, LibraryInterface* libHandler, QSharedPointer<AbstractionDefinition> absDef, Document::Revision revision);\n\t\n\t/*!\n     *  The destructor.\n     */\n\t~AbstractionDefinitionEditor() override = default;\n\n    //! No copying. No assignment.\n    AbstractionDefinitionEditor(const AbstractionDefinitionEditor& other) = delete;\n    AbstractionDefinitionEditor& operator=(const AbstractionDefinitionEditor& other) = delete;\n\n\t/*!\n     *  Get the VLNV that can be used to identify the Bus.\n\t *\n\t *    @return The VLNV that identifies the Bus.\n     */\n\tVLNV getIdentifyingVLNV() const override;\n\n    /*!\n     *  Refreshes the editor.\n     */\n    void refresh() override;\n\n    /*!\n     *  Sets the protection state of the document.\n     *\n     *    @param [in] locked True for locked state; false for unlocked.\n     */\n    void setProtection(bool locked) override;\n\n\t/*!\n     *  Get the vlnv of the current bus definition.\n\t *\n\t *    @return VLNV of the bus definition/abstraction definition being edited.\n\t */\n\tVLNV getDocumentVLNV() const override;\n\n    /*!\n     *  Sets the edited abstraction definition.\n     * \n     *    @param [in] absDef   The bus definition to set. Must not be NULL.\n     */\n    void setAbsDef(QSharedPointer<AbstractionDefinition> absDef);\n\n\npublic slots:\n\n    /*!\n     *  Validates the document against the IP-XACT standard.\n     *\n     *    @param [out] errorList Error message list for reporting standard violations.\n     *\n     *    @return True if the document is valid. False if there were any violations.\n     */\n    virtual bool validate(QVector<QString>& errorList);\n\n\t/*!\n     *  Saves the document and resets the modified state.\n     */\n\tvirtual bool save();\n\n\t/*!\n     *  Saves the document as new object and resets modifies state\n     */\n\tvirtual bool saveAs();\n\nsignals:\n\n    /*!\n     *  Inform that a port abstraction has been removed.\n     *\n     *    @param [in] portName    Name of the removed port abstraction.\n     *    @param [in] mode        Mode of the removed port abstraction.\n     */\n    void portRemoved(QString const& portName, General::InterfaceMode const mode);\n\nprotected:\n    \n    /*!\n     *  Called when the editor is shown.\n     *\n     *    @param [in] event   The show event.\n     */\n    virtual void showEvent(QShowEvent* event);\n\nprivate slots:\n\n    void onOpenReferenceTree(QString const& parameterID, QString const& parameterName);\n\nprivate:\n\n\t/*!\n     *  Set the layout of the widget\n     */\n\tvoid setupLayout();\n\n    /*!\n     *  Create interface for accessing port abstractions.\n     *\n     *    @return Interface for accessing port abstractions.\n     */\n    PortAbstractionInterface* createPortAbstractionInterface();\n\n    //-----------------------------------------------------------------------------\n    // Data.\n    //-----------------------------------------------------------------------------\n\n\t//! The original bus definition to use when saving.\n\tQSharedPointer<BusDefinition> busDef_;\n\n\t//! The original abstraction definition to use when saving.\n\tQSharedPointer<AbstractionDefinition> absDef_;\n\n    //! The parameter finder to use in reference counting.\n    QSharedPointer<ListParameterFinder> absDefParameterFinder_ = \n        QSharedPointer<ListParameterFinder>(new ListParameterFinder());\n\n    //! The expression formatter to use in the parameter reference tree.\n    QSharedPointer<ExpressionFormatter> expressionFormatter_;\n\n    //! Parser for expressions in definitions.\n    QSharedPointer<IPXactSystemVerilogParser> expressionParser_;\n\n    //! Validator for port abstractions.\n    QSharedPointer<PortAbstractionValidator> portValidator_;\n\n\t//! Group containing elements to edit abstraction definition.\n\tAbsDefGroup absDefGroup_;\n\n    //! Validator for abstraction definition.\n    QSharedPointer<AbstractionDefinitionValidator> absDefinitionValidator_;\n\n    //! Reference counter for the bus definition parameter references.\n    QSharedPointer<AbsDefParameterReferenceCounter> referenceCounter_;\n\n    //! The parameter reference tree to use.\n    AbsDefParameterReferenceTree* parameterReferenceTree_;\n\n    //! The parameter reference window.\n    ParameterReferenceTreeWindow* referenceTreeWindow_;\n};\n\n#endif // ABSTRACTIONDEFINITIONEDITOR_H\n"
  },
  {
    "path": "editors/AbstractionDefinitionEditor/AbstractionDefinitionPortsSortFilter.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: AbstractionDefinitionPortsSortFilter.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 21.11.2017\n//\n// Description:\n// Sort filter proxy model for abstraction definition ports.\n//-----------------------------------------------------------------------------\n\n#include \"AbstractionDefinitionPortsSortFilter.h\"\n\n#include <common/KactusColors.h>\n\n#include \"AbstractionPortsModel.h\"\n#include \"LogicalPortColumns.h\"\n\n//-----------------------------------------------------------------------------\n// Function: AbstractionDefinitionPortsSortFilter::AbstractionDefinitionPortsSortFilter()\n//-----------------------------------------------------------------------------\nAbstractionDefinitionPortsSortFilter::AbstractionDefinitionPortsSortFilter(\n     PortAbstractionInterface* portInterface, QObject *parent) :\nQSortFilterProxyModel(parent),\nportInterface_(portInterface)\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: AbstractionDefinitionPortsSortFilter::data()\n//-----------------------------------------------------------------------------\nQVariant AbstractionDefinitionPortsSortFilter::data(const QModelIndex &index, int role) const\n{\n    if (role == Qt::BackgroundRole)\n    {\n        return getBackgroundColorForIndex(index);\n    }\n    else\n    {\n        return QSortFilterProxyModel::data(index, role);\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: AbstractionDefinitionPortsSortFilter::getBackgroundColorForIndex()\n//-----------------------------------------------------------------------------\nQColor AbstractionDefinitionPortsSortFilter::getBackgroundColorForIndex(QModelIndex const& index) const\n{\n    bool systemGroupIsMandatory = isSystemGroupMandatory(index);\n    if (index.column() == LogicalPortColumns::NAME || systemGroupIsMandatory)\n    {\n        return KactusColors::MANDATORY_FIELD;\n    }\n    else if ((index.column() == LogicalPortColumns::SYSTEM_GROUP && !systemGroupIsMandatory) ||\n        undefinedMode(index))\n    {\n        return KactusColors::DISABLED_FIELD;\n    }\n\n    int previousRow = index.row() - 1;\n    QString previousName(\"\");\n    QColor previousColor = KactusColors::REGULAR_FIELD;\n    if (previousRow < 0)\n    {\n        return previousColor;\n    }\n    else\n    {\n        QModelIndex previousNameIndex = index.sibling(previousRow, LogicalPortColumns::NAME);\n        previousName = previousNameIndex.data(Qt::DisplayRole).toString();\n    }\n\n    QModelIndex nameIndex = index.sibling(index.row(), LogicalPortColumns::NAME);\n    QString name = nameIndex.data(Qt::DisplayRole).toString();\n    previousColor = getPreviousColor(previousRow, index);\n\n    if (name.compare(previousName) == 0)\n    {\n        return previousColor;\n    }\n    else if (previousColor == KactusColors::REGULAR_FIELD)\n    {\n        return KactusColors::FIELD_COLOR;\n    }\n    \n    return KactusColors::REGULAR_FIELD;\n}\n\n//-----------------------------------------------------------------------------\n// Function: AbstractionDefinitionPortsSortFilter::getPreviousColor()\n//-----------------------------------------------------------------------------\nQColor AbstractionDefinitionPortsSortFilter::getPreviousColor(int const& previousRow, QModelIndex const& index)\n    const\n{\n    QModelIndex previousColorIndex = index.sibling(previousRow, LogicalPortColumns::PRESENCE);\n\n    QColor previousColor = previousColorIndex.data(Qt::BackgroundRole).value<QColor>();\n    if (previousColor == KactusColors::DISABLED_FIELD)\n    {\n        previousColorIndex = index.sibling(previousRow, LogicalPortColumns::DESCRIPTION);\n        previousColor = previousColorIndex.data(Qt::BackgroundRole).value<QColor>();\n    }\n\n    return previousColor;\n}\n\n//-----------------------------------------------------------------------------\n// Function: AbstractionDefinitionPortsSortFilter::isSystemGroupMandatory()\n//-----------------------------------------------------------------------------\nbool AbstractionDefinitionPortsSortFilter::isSystemGroupMandatory(QModelIndex const& index) const\n{\n    if (index.column() == LogicalPortColumns::SYSTEM_GROUP)\n    {\n        QModelIndex modeIndex = index.sibling(index.row(), LogicalPortColumns::MODE);\n        QString portMode = modeIndex.data(Qt::DisplayRole).toString();\n        if (portMode.compare(QStringLiteral(\"system\"), Qt::CaseInsensitive) == 0)\n        {\n            return true;\n        }\n    }\n\n    return false;\n}\n\n//-----------------------------------------------------------------------------\n// Function: AbstractionDefinitionPortsSortFilter::undefinedMode()\n//-----------------------------------------------------------------------------\nbool AbstractionDefinitionPortsSortFilter::undefinedMode(QModelIndex const& index) const\n{\n    if (index.column() == LogicalPortColumns::PRESENCE || index.column() == LogicalPortColumns::DIRECTION ||\n        index.column() == LogicalPortColumns::WIDTH || index.column() == LogicalPortColumns::DEFAULT_VALUE ||\n        index.column() == LogicalPortColumns::INITIATIVE || index.column() == LogicalPortColumns::KIND ||\n        index.column() == LogicalPortColumns::BUSWIDTH || index.column() == LogicalPortColumns::PROTOCOLTYPE ||\n        index.column() == LogicalPortColumns::PAYLOADNAME || index.column() == LogicalPortColumns::PAYLOADTYPE ||\n        index.column() == LogicalPortColumns::PAYLOADEXTENSION)\n    {\n        QModelIndex modeIndex = index.sibling(index.row(), LogicalPortColumns::MODE);\n\n        QVariant modeData = modeIndex.data(Qt::ForegroundRole);\n        QColor modeColor = modeData.value<QColor>();\n        if (modeColor == KactusColors::ERROR)\n        {\n            return true;\n        }\n    }\n\n    return false;\n}\n\n"
  },
  {
    "path": "editors/AbstractionDefinitionEditor/AbstractionDefinitionPortsSortFilter.h",
    "content": "//-----------------------------------------------------------------------------\n// File: AbstractionDefinitionPortsSortFilter.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 21.11.2017\n//\n// Description:\n// Sort filter proxy model for abstraction definition ports.\n//-----------------------------------------------------------------------------\n\n#ifndef ABSTRACTIONDEFINITIONPORTSSORTFILTER_H\n#define ABSTRACTIONDEFINITIONPORTSSORTFILTER_H\n\n#include <QSortFilterProxyModel>\n#include <QColor>\n\nclass PortAbstractionInterface;\n\n//-----------------------------------------------------------------------------\n//! Sort filter proxy model for abstraction definition ports.\n//-----------------------------------------------------------------------------\nclass AbstractionDefinitionPortsSortFilter : public QSortFilterProxyModel\n{\n\npublic:\n\n\t/*!\n\t *  The constructor.\n\t *\n     *    @param [in] parent  Pointer to the owner of this model.\n\t */\n    AbstractionDefinitionPortsSortFilter(\n        PortAbstractionInterface* portInterface, QObject *parent);\n\n\t/*!\n\t *  The destructor.\n\t */\n    virtual ~AbstractionDefinitionPortsSortFilter() = default;\n\n\t/*!\n\t *  Get the data for the specified item.\n\t *\n\t *    @param [in] index   Specifies the item that's data is requested.\n\t *    @param [in] role    The role that defines what kind of data is requested.\n     *\n     *    @return QVariant contains the data for the item.\n\t */\n    virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;\n\nprotected:\n\n    /*!\n     *  Get the background color for the selected index.\n     *\n     *    @param [in] index   Index of the selected item.\n     *\n     *    @return Background color for the selected index.\n     */\n    virtual QColor getBackgroundColorForIndex(QModelIndex const& index) const;\n\n    //! Interface for accessing port abstractions.\n    PortAbstractionInterface* portInterface_;\n\nprivate:\n\t//! No copying. No assignment.\n\tAbstractionDefinitionPortsSortFilter(const AbstractionDefinitionPortsSortFilter& other);\n\tAbstractionDefinitionPortsSortFilter& operator=(const AbstractionDefinitionPortsSortFilter& other);\n\n    /*!\n     *  Check if the system group column is mandatory for the selected index.\n     *\n     *    @param [in] index   The selected index.\n     *\n     *    @return True, if the system group is mandatory, false otherwise.\n     */\n    bool isSystemGroupMandatory(QModelIndex const& index) const;\n\n    /*!\n     *  Check if the selected signal has an undefined mode.\n     *\n     *    @param [in] index   Model index of the selected signal.\n     *\n     *    @return True, if the selected signal has an undefined mode, false otherwise.\n     */\n    bool undefinedMode(QModelIndex const& index) const;\n\n    /*!\n     *  Get the background colour on the previous row of the selected index.\n     *\n     *    @param [in] previousRow     The previous row.\n     *    @param [in] index           The selected index.\n     *\n     *    @return Background colour of the previous row.\n     */\n    QColor getPreviousColor(int const& previousRow, QModelIndex const& index) const;\n\n};\n\n#endif // ABSTRACTIONDEFINITIONPORTSSORTFILTER_H\n"
  },
  {
    "path": "editors/AbstractionDefinitionEditor/AbstractionDefinitionSignalRow.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: AbstractionDefinitionSignalRow.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 14.01.2020\n//\n// Description:\n// Represents a row in the abstraction ports table by grouping the Port, Wire and Transactional elements.\n//-----------------------------------------------------------------------------\n\n#include \"AbstractionDefinitionSignalRow.h\"\n\n#include <IPXACTmodels/AbstractionDefinition/PortAbstraction.h>\n#include <IPXACTmodels/AbstractionDefinition/WirePort.h>\n#include <IPXACTmodels/AbstractionDefinition/TransactionalPort.h>\n\n//-----------------------------------------------------------------------------\n// Function: AbstractionDefinitionSignalRow::()\n//-----------------------------------------------------------------------------\nAbstractionDefinitionSignalRow::AbstractionDefinitionSignalRow():\nabstraction_(QSharedPointer<PortAbstraction>(new PortAbstraction())),\nmode_(General::INTERFACE_MODE_COUNT),\nwire_(),\ntransactional_(),\nlockExtendData_(false),\nlockPortData_(false)\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: AbstractionDefinitionSignalRow::operator==()\n//-----------------------------------------------------------------------------\nbool AbstractionDefinitionSignalRow::operator==(AbstractionDefinitionSignalRow const& other) const\n{\n    return  abstraction_->getLogicalName() == other.abstraction_->getLogicalName() &&\n        mode_ == other.mode_ && comparedSignalIsSameType(other) &&\n        lockExtendData_ == other.lockExtendData_ && lockPortData_ == other.lockPortData_ &&\n        (mode_ != General::SYSTEM || getSystemGroup() == other.getSystemGroup());\n}\n\n//-----------------------------------------------------------------------------\n// Function: AbstractionDefinitionSignalRow::getSystemGroup()\n//-----------------------------------------------------------------------------\nQString AbstractionDefinitionSignalRow::getSystemGroup() const\n{\n    if (mode_ == General::SYSTEM)\n    {\n        if (wire_)\n        {\n            return wire_->getSystemGroup();\n        }\n        else if (transactional_)\n        {\n            return transactional_->getSystemGroup();\n        }\n    }\n\n    return QString(\"\");\n}\n\n//-----------------------------------------------------------------------------\n// Function: AbstractionDefinitionSignalRow::comparedSignalIsSameType()\n//-----------------------------------------------------------------------------\nbool AbstractionDefinitionSignalRow::comparedSignalIsSameType(\n    AbstractionDefinitionSignalRow const& comparisonSignal) const\n{\n    if ((wire_ && comparisonSignal.wire_) || (transactional_ && comparisonSignal.transactional_))\n    {\n        return true;\n    }\n    else\n    {\n        return false;\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: AbstractionDefinitionSignalRow::operator!=()\n//-----------------------------------------------------------------------------\nbool AbstractionDefinitionSignalRow::operator!=(AbstractionDefinitionSignalRow const& other) const\n{\n    return  abstraction_->getLogicalName() != other.abstraction_->getLogicalName() ||\n        mode_ != other.mode_ ||\n        !comparedSignalIsSameType(other) ||\n        getSystemGroup() != other.getSystemGroup() ||\n        lockExtendData_ != other.lockExtendData_ || lockPortData_ != other.lockPortData_;\n}\n\n//-----------------------------------------------------------------------------\n// Function: AbstractionDefinitionSignalRow::SignalRow::operator<()\n//-----------------------------------------------------------------------------\nbool AbstractionDefinitionSignalRow::operator<( const AbstractionDefinitionSignalRow& other ) const\n{\n\t// Order by name, mode and system group.\n\tif (abstraction_->getLogicalName() == other.abstraction_->getLogicalName()) \n    {\n        if (mode_ == other.mode_)\n        {\n            return getSystemGroup() < other.getSystemGroup();\n        }\n\n\t\treturn mode_ < other.mode_;\n\t}\n\telse\n    {\n\t\treturn abstraction_->getLogicalName() < other.abstraction_->getLogicalName();\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: AbstractionDefinitionSignalRow::getMode()\n//-----------------------------------------------------------------------------\nGeneral::InterfaceMode AbstractionDefinitionSignalRow::getMode() const\n{\n    return mode_;\n}\n\n//-----------------------------------------------------------------------------\n// Function: AbstractionDefinitionSignalRow::setMode()\n//-----------------------------------------------------------------------------\nvoid AbstractionDefinitionSignalRow::setMode(General::InterfaceMode const& newMode)\n{\n    mode_ = newMode;\n}\n\n//-----------------------------------------------------------------------------\n// Function: AbstractionDefinitionSignalRow::getPortAbstraction()\n//-----------------------------------------------------------------------------\nQSharedPointer<PortAbstraction> AbstractionDefinitionSignalRow::getPortAbstraction() const\n{\n    return abstraction_;\n}\n\n//-----------------------------------------------------------------------------\n// Function: AbstractionDefinitionSignalRow::setPortAbstraction()\n//-----------------------------------------------------------------------------\nvoid AbstractionDefinitionSignalRow::setPortAbstraction(QSharedPointer<PortAbstraction> newAbstraction)\n{\n    abstraction_ = newAbstraction;\n}\n\n//-----------------------------------------------------------------------------\n// Function: AbstractionDefinitionSignalRow::getWire()\n//-----------------------------------------------------------------------------\nQSharedPointer<WirePort> AbstractionDefinitionSignalRow::getWire() const\n{\n    return wire_;\n}\n\n//-----------------------------------------------------------------------------\n// Function: AbstractionDefinitionSignalRow::setWire()\n//-----------------------------------------------------------------------------\nvoid AbstractionDefinitionSignalRow::setWire(QSharedPointer<WirePort> newWire)\n{\n    wire_ = newWire;\n}\n\n//-----------------------------------------------------------------------------\n// Function: AbstractionDefinitionSignalRow::getTransactional()\n//-----------------------------------------------------------------------------\nQSharedPointer<TransactionalPort> AbstractionDefinitionSignalRow::getTransactional() const\n{\n    return transactional_;\n}\n\n//-----------------------------------------------------------------------------\n// Function: AbstractionDefinitionSignalRow::setTransactional()\n//-----------------------------------------------------------------------------\nvoid AbstractionDefinitionSignalRow::setTransactional(QSharedPointer<TransactionalPort> newTransactional)\n{\n    transactional_ = newTransactional;\n}\n\n//-----------------------------------------------------------------------------\n// Function: AbstractionDefinitionSignalRow::isExtendDataLocked()\n//-----------------------------------------------------------------------------\nbool AbstractionDefinitionSignalRow::isExtendDataLocked() const\n{\n    return lockExtendData_;\n}\n\n//-----------------------------------------------------------------------------\n// Function: AbstractionDefinitionSignalRow::lockExtendData()\n//-----------------------------------------------------------------------------\nvoid AbstractionDefinitionSignalRow::lockExtendData(bool newLockStatus)\n{\n    lockExtendData_ = newLockStatus;\n}\n\n//-----------------------------------------------------------------------------\n// Function: AbstractionDefinitionSignalRow::isPortDataLocked()\n//-----------------------------------------------------------------------------\nbool AbstractionDefinitionSignalRow::isPortDataLocked() const\n{\n    return lockPortData_;\n}\n\n//-----------------------------------------------------------------------------\n// Function: AbstractionDefinitionSignalRow::lockPortData()\n//-----------------------------------------------------------------------------\nvoid AbstractionDefinitionSignalRow::lockPortData(bool newLockStatus)\n{\n    lockPortData_ = newLockStatus;\n}\n"
  },
  {
    "path": "editors/AbstractionDefinitionEditor/AbstractionDefinitionSignalRow.h",
    "content": "//-----------------------------------------------------------------------------\n// File: AbstractionDefinitionSignalRow.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 14.01.2020\n//\n// Description:\n// Represents a row in the abstraction ports table by grouping the Port, Wire and Transactional elements.\n//-----------------------------------------------------------------------------\n\n#ifndef ABSTRACTIONDEFINITIONSIGNALROW_H\n#define ABSTRACTIONDEFINITIONSIGNALROW_H\n\n#include <IPXACTmodels/generaldeclarations.h>\n\n#include <QString>\n#include <QSharedPointer>\n\nclass PortAbstraction;\nclass WirePort;\nclass TransactionalPort;\n\n//-----------------------------------------------------------------------------\n//! Represents a row in the abstraction ports table by grouping the Port, Wire and Transactional elements.\n//-----------------------------------------------------------------------------\nclass AbstractionDefinitionSignalRow\n{\npublic:\n\n    /*!\n     *  The constructor.\n     */\n    AbstractionDefinitionSignalRow();\n\n    /*!\n     *  The destructor.\n     */\n    virtual ~AbstractionDefinitionSignalRow() = default;\n\n    /*!\n     *  Copy constructor\n     */\n    AbstractionDefinitionSignalRow(AbstractionDefinitionSignalRow const& other) = default;\n\n    /*!\n     *  Comparison of two SignalRows.\n     *\n     *    @param [in] other   The SignalRow to compare this to.\n     *\n     *    @return True, if the SignalRows are equal, otherwise false.\n     */\n    bool operator==(AbstractionDefinitionSignalRow const& other) const;\n    \n    /*!\n     *  Comparison of two SignalRows.\n     *\n     *    @param [in] other   The SignalRow to compare this to.\n     *\n     *    @return True, if the SignalRows are not equal, otherwise false.\n     */\n    bool operator!=(AbstractionDefinitionSignalRow const& other) const;\n    \n    /*!\n     *  Less than comparison of two SignalRows for table ordering.\n     *\n     *    @param [in] other   The SignalRow to compare this to.\n     *\n     *    @return True, if this precedes other, otherwise false.\n     */\n    bool operator<(AbstractionDefinitionSignalRow const& other) const;\n    \n    /*!\n     *  Get the current system group of the selected signal.\n     *\n     *    @param [in] signal  The selected signal.\n     *\n     *    @return The system group of the selected signal.\n     */\n    QString getSystemGroup() const;\n    \n    /*!\n     *  Check if the compared signal is of the same type.\n     *\n     *    @param [in] comparisonSignal    The selected comparison signal.\n     *\n     *    @return True, if the signals are of the same type, false otherwise.\n     */\n    bool comparedSignalIsSameType(AbstractionDefinitionSignalRow const& comparisonSignal) const;\n\n    /*!\n     *  Get the current interface mode.\n     *\n     *    @return The current interface mode.\n     */\n    General::InterfaceMode getMode() const;\n\n    /*!\n     *  Set the interface mode.\n     *\n     *    @param [in] newMode     The new interface mode.\n     */\n    void setMode(General::InterfaceMode const& newMode);\n\n    /*!\n     *  Get the port abstraction.\n     *\n     *    @return The port abstraction.\n     */\n    QSharedPointer<PortAbstraction> getPortAbstraction() const;\n\n    /*!\n     *  Set the port abstraction.\n     *\n     *    @param [in] newAbstraction  The new port abstraction.\n     */\n    void setPortAbstraction(QSharedPointer<PortAbstraction> newAbstraction);\n\n    /*!\n     *  Get the wire port.\n     *\n     *    @return The wire port.\n     */\n    QSharedPointer<WirePort> getWire() const;\n\n    /*!\n     *  Set the wire port.\n     *\n     *    @param[in] newWire  The new wire port.\n     */\n    void setWire(QSharedPointer<WirePort> newWire);\n\n    /*!\n     *  Get the transactional port.\n     *\n     *    @return The transactional port.\n     */\n    QSharedPointer<TransactionalPort> getTransactional() const;\n\n    /*!\n     *  Set the transactional port.\n     *\n     *    @param [in] newTRansactional    The new transactional port.\n     */\n    void setTransactional(QSharedPointer<TransactionalPort> newTransactional);\n\n    /*!\n     *  Check if the extend data is locked.\n     *\n     *    @return True, if the extend data is locked, false otherwise.\n     */\n    bool isExtendDataLocked() const;\n\n    /*!\n     *  Set the lock flag for extend data.\n     *\n     *    @param [in] newLockStatus   New extend lock flag.\n     */\n    void lockExtendData(bool newLockStatus);\n\n    /*!\n     *  Check if the port data is locked.\n     *\n     *    @return True, if the port data is locked, false otherwise.\n     */\n    bool isPortDataLocked() const;\n\n    /*!\n     *  Set the lock flag for port data.\n     *\n     *    @param [in] newLockStatus   New port data lock flag.\n     */\n    void lockPortData(bool newLockStatus);\n\nprivate:\n\n    //-----------------------------------------------------------------------------\n    // Data.\n    //-----------------------------------------------------------------------------\n\n    //! Defines the Port represented in the row.\n    QSharedPointer<PortAbstraction> abstraction_;\n\n    //! Defines the mode of the wirePort (master, slave or system).\n    General::InterfaceMode mode_;\n\n    //! Defines the wire port represented on the row.\n    QSharedPointer<WirePort> wire_;\n\n    //! Defines the transactional port represented on the row.\n    QSharedPointer<TransactionalPort> transactional_;\n\n    //! Flag for locking columns for extend signals.\n    bool lockExtendData_;\n\n    //! Flag for locking port abstraction columns.\n    bool lockPortData_;\n};\n\n#endif // ABSTRACTIONDEFINITIONEXTENDPORTHANDLER_H\n"
  },
  {
    "path": "editors/AbstractionDefinitionEditor/AbstractionPortsDelegate.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: AbstractionPortsDelegate.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 06.06.2018\n//\n// Description:\n// Master delegate for abstraction definition wire and transactional ports.\n//-----------------------------------------------------------------------------\n\n#include \"AbstractionPortsDelegate.h\"\n#include \"QualifierEditor.h\"\n\n#include <IPXACTmodels/BusDefinition/BusDefinition.h>\n#include <IPXACTmodels/common/Qualifier.h>\n\n#include <IPXACTmodels/utilities/BusDefinitionUtils.h>\n\n#include <editors/AbstractionDefinitionEditor/LogicalPortColumns.h>\n\n\n#include <KactusAPI/include/LibraryInterface.h>\n#include <KactusAPI/include/PortAbstractionInterface.h>\n\n#include <QComboBox>\n#include <QStringList>\n#include <QLineEdit>\n\n//-----------------------------------------------------------------------------\n// Function: AbstractionPortsDelegate::AbstractionPortsDelegate()\n//-----------------------------------------------------------------------------\nAbstractionPortsDelegate::AbstractionPortsDelegate(QAbstractItemModel* parametersModel,\n    QSharedPointer<ParameterFinder> parameterFinder, LibraryInterface* libraryAcces, \n    Document::Revision stdRevision, QObject* parent) :\nExpressionDelegate(parametersModel, parameterFinder, parent),\nstdRevision_(stdRevision),\nlibraryAccess_(libraryAcces),\nbusDefinition_(0)\n{\n    setModeOptions();\n}\n\n//-----------------------------------------------------------------------------\n// Function: AbstractionPortsDelegate::createEditor()\n//-----------------------------------------------------------------------------\nQWidget* AbstractionPortsDelegate::createEditor(QWidget* parent, QStyleOptionViewItem const& option,\n    const QModelIndex& index ) const\n{\n    if (index.column() == LogicalPortColumns::MODE)\n    {\n        QComboBox* box = new QComboBox(parent);\n\n        box->addItems(modeOptions_);\n\n        connect(box, SIGNAL(destroyed()), this, SLOT(commitAndCloseEditor()), Qt::UniqueConnection);\n        return box;\n    }\n    else if (index.column() == LogicalPortColumns::PRESENCE)\n    {\n        QComboBox* box = new QComboBox(parent);\n\n        QStringList list = { \"required\", \"optional\", \"illegal\" };\n        box->addItems(list);\n\n        connect(box, SIGNAL(destroyed()), this, SLOT(commitAndCloseEditor()), Qt::UniqueConnection);\n        return box;\n    }\n    else if (index.column() == LogicalPortColumns::SYSTEM_GROUP)\n    {\n        if (busDefinition_)\n        {\n            QComboBox* box = new QComboBox(parent);\n            box->addItem(\"\");\n            box->addItems(BusDefinitionUtils::getSystemGroups(busDefinition_, libraryAccess_));\n\n            connect(box, SIGNAL(destroyed()), this, SLOT(commitAndCloseEditor()), Qt::UniqueConnection);\n            return box;\n        }\n        else\n        {\n            return 0;\n        }\n    }\n    else if (index.column() == LogicalPortColumns::MATCH)\n    {\n        QComboBox* box = new QComboBox(parent);\n        box->addItems({\"true\", \"false\"});\n\n        connect(box, SIGNAL(destroyed()), this, SLOT(commitAndCloseEditor()), Qt::UniqueConnection);\n        return box;\n    }\n    else if (index.column() == LogicalPortColumns::QUALIFIER)\n    {\n        QualifierEditor* qualifierEditor = new QualifierEditor(stdRevision_, parent);\n        qualifierEditor->setupEditor(getQualifierList());\n        connect(qualifierEditor, SIGNAL(finishEditing()), this, SLOT(commitAndCloseEditor()), Qt::UniqueConnection);\n        connect(qualifierEditor, SIGNAL(cancelEditing()), this, SLOT(onEditingCanceled()), Qt::UniqueConnection);\n        return qualifierEditor;\n    }\n    else\n    {\n        return ExpressionDelegate::createEditor(parent, option, index);\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: AbstractionPortsDelegate::setEditorData()\n//-----------------------------------------------------------------------------\nvoid AbstractionPortsDelegate::setEditorData(QWidget* editor, QModelIndex const& index ) const\n{\n    if (editorIsLineEditor(index.column()))\n    {\n        QLineEdit* line = qobject_cast<QLineEdit*>(editor);\n        Q_ASSERT_X(line, \"BusPortsDelegate::setEditorData\", \"Type conversion failed for QLineEdit\");\n\n        QString text = index.data(Qt::DisplayRole).toString();\n        line->setText(text);\n\n        if (index.column() == LogicalPortColumns::NAME && text == QLatin1String(\"unnamed\"))\n        {\n            line->clear();\n        }\n    }\n    else if (editorIsComboBox(index.column()))\n    {\n        QComboBox* box = qobject_cast<QComboBox*>(editor);\n        Q_ASSERT_X(box, \"BusPortsDelegate::setEditorData\", \"Type conversion failed for combo box\");\n\n        QString text = index.data(Qt::DisplayRole).toString();\n        int textIndex = box->findText(text);\n        if (textIndex >= 0)\n        {\n            box->setCurrentIndex(textIndex);\n        }\n        else\n        {\n            box->setCurrentText(text);\n        }\n    }\n    else if (index.column() == LogicalPortColumns::QUALIFIER)\n    {\n        QualifierEditor* qualifierEditor = qobject_cast<QualifierEditor*>(editor);\n        Q_ASSERT_X(qualifierEditor, \"AbstractionPortsDelegate::setEditorData\",\n            \"Type conversion failed for QualifierEditor\");\n\n        auto setQualifiers = index.data(Qt::EditRole).value<QualifierData>();\n        \n        // Hide all attributes before showing only set attributes. Done here to make editor the right width.\n        qualifierEditor->hideAllAttributes();\n        qualifierEditor->setupEditorData(setQualifiers.activeQualifiers_, setQualifiers.attributes_);\n    }\n    else\n    {\n        ExpressionDelegate::setEditorData(editor, index);\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: AbstractionPortsDelegate::editorIsLineEditor()\n//-----------------------------------------------------------------------------\nbool AbstractionPortsDelegate::editorIsLineEditor(int indexColumn) const\n{\n    return indexColumn == LogicalPortColumns::NAME ||\n        indexColumn == LogicalPortColumns::PAYLOADNAME || indexColumn == LogicalPortColumns::PAYLOADEXTENSION;\n}\n\n//-----------------------------------------------------------------------------\n// Function: AbstractionPortsDelegate::editorIsComboBox()\n//-----------------------------------------------------------------------------\nbool AbstractionPortsDelegate::editorIsComboBox(int indexColumn) const\n{\n    return indexColumn == LogicalPortColumns::MODE || indexColumn == LogicalPortColumns::PRESENCE ||\n        indexColumn == LogicalPortColumns::SYSTEM_GROUP || indexColumn == LogicalPortColumns::PROTOCOLTYPE ||\n        indexColumn == LogicalPortColumns::PAYLOADTYPE || indexColumn == LogicalPortColumns::MATCH;\n}\n\n//-----------------------------------------------------------------------------\n// Function: AbstractionPortsDelegate::setModelData()\n//-----------------------------------------------------------------------------\nvoid AbstractionPortsDelegate::setModelData(QWidget* editor, QAbstractItemModel* model, QModelIndex const& index)\n    const\n{\n    if (editorIsLineEditor(index.column()))\n    {\n        QLineEdit* lineEditor = qobject_cast<QLineEdit*>(editor);\n        Q_ASSERT_X(lineEditor, \"BusPortsDelegate::setModelData\", \"Type conversion failed for normal QLineEdit\");\n\n        model->setData(index, lineEditor->text(), Qt::EditRole);\n    }\n    else if (editorIsComboBox(index.column()))\n    {\n        QComboBox* selector = qobject_cast<QComboBox*>(editor);\n        Q_ASSERT_X(selector, \"BusPortsDelegate::setModelData\", \"Type conversion failed for combo box\");\n\n        model->setData(index, selector->currentText(), Qt::EditRole);\n    }\n    else if (index.column() == LogicalPortColumns::QUALIFIER)\n    {\n        QualifierEditor* qualifierEditor = qobject_cast<QualifierEditor*>(editor);\n        Q_ASSERT_X(qualifierEditor, \"AbstractionPortsDelegate::setModelData\", \"Type conversion failed for qualifier editor\");\n\n        model->setData(index, QVariant::fromValue(qualifierEditor->getQualifierData()), Qt::EditRole);\n    }\n    else\n    {\n        ExpressionDelegate::setModelData(editor, model, index);\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: AbstractionPortsDelegate::commitAndCloseEditor()\n//-----------------------------------------------------------------------------\nvoid AbstractionPortsDelegate::commitAndCloseEditor()\n{\n\tQWidget* editor = qobject_cast<QWidget*>(sender());\n\n\tif (editor)\n    {\n\t\temit commitData(editor);\n\t\temit closeEditor(editor);\n\t}\n}\n\n//-----------------------------------------------------------------------------\n// Function: AbstractionPortsDelegate::onEditingCanceled()\n//-----------------------------------------------------------------------------\nvoid AbstractionPortsDelegate::onEditingCanceled()\n{\n    QWidget* edit = qobject_cast<QWidget*>(sender());\n    if (edit)\n    {\n        emit closeEditor(edit);\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: AbstractionPortsDelegate::setBusDef()\n//-----------------------------------------------------------------------------\nvoid AbstractionPortsDelegate::setBusDef(QSharedPointer<const BusDefinition> busDefinition)\n{\n    busDefinition_ = busDefinition;\n}\n\n//-----------------------------------------------------------------------------\n// Function: AbstractionPortsDelegate::updateEditorGeometry()\n//-----------------------------------------------------------------------------\nvoid AbstractionPortsDelegate::updateEditorGeometry(QWidget* editor, const QStyleOptionViewItem& option, const QModelIndex& index) const\n{\n    if (index.column() != LogicalPortColumns::QUALIFIER)\n    {\n        return ExpressionDelegate::updateEditorGeometry(editor, option, index);\n    }\n\n    int enumerationCount = getQualifierList().count();\n    int editorMinimumHeight = 25 * (enumerationCount + 2);\n\n    int editorWidth = editor->sizeHint().width();\n    if (editorWidth < 150)\n    {\n        editorWidth = 150;\n    }\n    else if (editorWidth > 380)\n    {\n        editorWidth = 380;\n    }\n\n    editor->setFixedWidth(editorWidth);\n\n    const int PARENT_HEIGHT = editor->parentWidget()->height();\n    const int AVAILABLE_HEIGHT_BELOW = PARENT_HEIGHT - option.rect.top();\n\n    if (AVAILABLE_HEIGHT_BELOW > editorMinimumHeight)\n    {\n        editor->move(option.rect.topLeft());\n    }\n    else\n    {\n        int editorNewY = PARENT_HEIGHT - editorMinimumHeight;\n        if (editorNewY <= 0)\n        {\n            editorNewY = 0;\n        }\n\n        editor->move(option.rect.left(), editorNewY);\n    }\n\n    if (editorMinimumHeight > PARENT_HEIGHT)\n    {\n        editor->setFixedHeight(PARENT_HEIGHT);\n    }\n    else\n    {\n        editor->setFixedHeight(editorMinimumHeight);\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: AbstractionPortsDelegate::getQualifierList()\n//-----------------------------------------------------------------------------\nQStringList AbstractionPortsDelegate::getQualifierList() const\n{\n    QStringList list = { \"address\", \"data\", };\n    if (stdRevision_ != Document::Revision::Std22)\n    {\n        return list;\n    }\n\n    list << QStringLiteral(\"clock\")\n        << QStringLiteral(\"reset\")\n        << QStringLiteral(\"valid\")\n        << QStringLiteral(\"interrupt\")\n        << QStringLiteral(\"clock enable\")\n        << QStringLiteral(\"power enable\")\n        << QStringLiteral(\"opcode\")\n        << QStringLiteral(\"protection\")\n        << QStringLiteral(\"flow control\")\n        << QStringLiteral(\"user\")\n        << QStringLiteral(\"request\")\n        << QStringLiteral(\"response\");\n\n    return list;\n}\n\n//-----------------------------------------------------------------------------\n// Function: AbstractionPortsDelegate::setModeOptions()\n//-----------------------------------------------------------------------------\nvoid AbstractionPortsDelegate::setModeOptions()\n{\n    if (stdRevision_ == Document::Revision::Std22)\n    {\n        modeOptions_ = { \"initiator\", \"target\", \"system\" };\n    }\n    else\n    {\n        modeOptions_ = { \"master\", \"slave\", \"system\" };\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: AbstractionPortsDelegate::descriptionColumn()\n//-----------------------------------------------------------------------------\nint AbstractionPortsDelegate::descriptionColumn() const\n{\n    return LogicalPortColumns::DESCRIPTION;\n}\n"
  },
  {
    "path": "editors/AbstractionDefinitionEditor/AbstractionPortsDelegate.h",
    "content": "//-----------------------------------------------------------------------------\n// File: AbstractionPortsDelegate.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 06.06.2018\n//\n// Description:\n// Master delegate for abstraction definition wire and transactional ports.\n//-----------------------------------------------------------------------------\n\n#ifndef ABSTRACTIONPORTSDELEGATE_H\n#define ABSTRACTIONPORTSDELEGATE_H\n\n#include <editors/ComponentEditor/common/ExpressionDelegate.h>\n\n#include <IPXACTmodels/common/Document.h>\n\n#include <QStyledItemDelegate>\n\nclass BusDefinition;\nclass LibraryInterface;\nclass PortAbstractionInterface;\nclass QualifierEditor;\n\n//-----------------------------------------------------------------------------\n//! Master delegate for abstraction definition wire and transactional ports.\n//-----------------------------------------------------------------------------\nclass AbstractionPortsDelegate : public ExpressionDelegate\n{\n\tQ_OBJECT\n\npublic:\n\n\t/*!\n     *  The constructor.\n\t *\n     *    @param [in] parametersModel The parameter completer model to use.\n     *    @param [in] parameterFinder The parameter finder to use.\n     *    @param [in] libraryAccess   Interface to the library.\n     *    @param [in] stdRevision     The revision of the standard used by the abstraction definition.\n\t *    @param [in] parent          The owner of this instance\n     */\n    AbstractionPortsDelegate(QAbstractItemModel* parametersModel, QSharedPointer<ParameterFinder> parameterFinder, \n        LibraryInterface* libraryAcces, Document::Revision stdRevision, QObject *parent);\n\n\t/*!\n     *  The destructor.\n     */\n\tvirtual ~AbstractionPortsDelegate() = default;\n\n\t/*!\n     *  Create a new editor for the given item\n\t *\n\t *    @param [in] parent  Owner for the editor.\n\t *    @param [in] option  Contains options for the editor.\n\t *    @param [in] index   Model index identifying the item.\n\t *\n\t *    @return The editor to be used to edit the item.\n     */\n\tvirtual QWidget* createEditor(QWidget* parent, QStyleOptionViewItem const& option, QModelIndex const& index)\n        const;\n\n\t/*!\n     *  Set the data for the editor.\n\t *\n\t *    @param [in] editor  The editor where the data is to be set.\n\t *    @param [in] index   Model index identifying the item that's data is to be set.\n\t */\n\tvirtual void setEditorData(QWidget* editor, QModelIndex const& index) const;\n\n\t/*!\n     *  Save the data from the editor to the model.\n\t *\n\t *    @param [in] editor The editor that contains the data to store.\n\t *    @param [in] model Model that contains the data structure where data is to be saved to.\n\t *    @param [in] index Model index identifying the item that's data is to be saved.\n\t */\n\tvirtual void setModelData(QWidget* editor, QAbstractItemModel* model, QModelIndex const& index) const;\n        \n\t/*!\n     *  Set the bus definition referenced by the edited abstraction definition.\n\t *\n\t *    @param [in] busDefinition  The referenced bus definition.\n     */\n    void setBusDef(QSharedPointer<const BusDefinition> busDefinition);\n\n    /*!\n     *  Updates the qualifier editor geometry.\n     *\n     *    @param [in] editor  The editor being updated.\n     *    @param [in] option  The options used to update the editor.\n     *    @param [in] index   The model index being edited.\n     */\n    virtual void updateEditorGeometry(QWidget* editor, const QStyleOptionViewItem& option, const QModelIndex& index) const override;\n\nprotected slots:\n\n\t/*!\n     *  Commit the data from the sending editor and close the editor.\n\t */\n\tvoid commitAndCloseEditor();\n\n    /*!\n     *  Cancel editing, close editor.\n     */\n    void onEditingCanceled();\n\nprotected:\n\n    /*!\n     *  Get the list of available qualifier values.\n     *\n     *    @return The list of available qualifier values.\n     */\n    virtual QStringList getQualifierList() const;\n\n    /*!\n     *  Check if the editor used in the selected index column is a line editor.\n     *\n     *    @param [in] indexColumn     The selected index column.\n     *\n     *    @return True, if the editor used in the selected column is a line editor, false otherwise.\n     */\n    virtual bool editorIsLineEditor(int indexColumn) const;\n\n    /*!\n     *  Check if the editor used in the selected index column is a combo box editor.\n     *\n     *    @param [in] indexColumn     The selected index column.\n     *\n     *    @return True, if the editor used in the selected column is a combo box editor, false otherwise.\n     */\n    virtual bool editorIsComboBox(int indexColumn) const;\n\n    Document::Revision stdRevision_;\n\nprivate:\n\t//! No copying. No assignment.\n    AbstractionPortsDelegate(const AbstractionPortsDelegate& other);\n    AbstractionPortsDelegate& operator=(const AbstractionPortsDelegate& other);\n\n    /*!\n     *\tSet the interface mode options depending on std revision.\n     */\n    void setModeOptions();\n\n    /*!\n     *\tGet the index of the description column.\n     *\t    \n     * \t    @return The description column index.\n     */\n    int descriptionColumn() const final;\n\n    //-----------------------------------------------------------------------------\n    // Data.\n    //-----------------------------------------------------------------------------\n\n    //! Interface to the library.\n    LibraryInterface* libraryAccess_;\n\n    //! The bus definition referenced by the edited abstraction definition.\n    QSharedPointer<const BusDefinition> busDefinition_;\n\n    QStringList modeOptions_ = { \"initiator\", \"target\", \"system\" };\n};\n\n#endif // ABSTRACTIONPORTSDELEGATE_H\n"
  },
  {
    "path": "editors/AbstractionDefinitionEditor/AbstractionPortsEditor.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: AbstractionPortsEditor.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 04.06.2018\n//\n// Description:\n// Editor for the ports of an abstraction definition.\n//-----------------------------------------------------------------------------\n\n#include \"AbstractionPortsEditor.h\"\n\n#include <IPXACTmodels/BusDefinition/BusDefinition.h>\n#include <IPXACTmodels/AbstractionDefinition/AbstractionDefinition.h>\n\n#include \"AbstractionPortsModel.h\"\n#include \"AbstractionWirePortsSortFilter.h\"\n#include \"AbstractionTransactionalPortsSortFilter.h\"\n#include \"AbstractionWirePortsDelegate.h\"\n#include \"AbstractionTransactionalPortsDelegate.h\"\n#include \"LogicalPortColumns.h\"\n\n#include <KactusAPI/include/ParameterFinder.h>\n\n#include <QHeaderView>\n#include <QVBoxLayout>\n\n//-----------------------------------------------------------------------------\n// Function: AbstractionPortsEditor::AbstractionPortsEditor()\n//-----------------------------------------------------------------------------\nAbstractionPortsEditor::AbstractionPortsEditor(QAbstractItemModel* parametersModel,\n    QSharedPointer<ParameterFinder> parameterFinder, LibraryInterface* libraryAccess,\n    PortAbstractionInterface* portInterface, Document::Revision stdRevision, AbstractionPortsModel* portModel,\n    LogicalPortColumns::AbstractionType type, QWidget* parent):\nQWidget(parent),\nportView_(this),\nportProxy_(nullptr),\nportModel_(portModel),\nportDelegate_(nullptr)\n{\n    if (type == LogicalPortColumns::AbstractionType::WIRE)\n    {\n        portProxy_ = new AbstractionWirePortsSortFilter(portInterface, this);\n        portDelegate_ = new AbstractionWirePortsDelegate(parametersModel, parameterFinder, libraryAccess, stdRevision, this);\n    }\n    else\n    {\n        portProxy_ = new AbstractionTransactionalPortsSortFilter(portInterface, this);\n        portDelegate_ = new AbstractionTransactionalPortsDelegate(parametersModel, parameterFinder, libraryAccess, stdRevision, this);\n    }\n\n    portProxy_->setSourceModel(portModel_);\n    \n    portView_.setModel(portProxy_);\n    portView_.setSortingEnabled(true);\n    portView_.setItemDelegate(portDelegate_);\n    portView_.setAllowImportExport(true);\n    portView_.setItemsDraggable(false);\n    portView_.setAlternatingRowColors(false);\n    portView_.sortByColumn(0, Qt::AscendingOrder);\n\n    if (type == LogicalPortColumns::AbstractionType::WIRE)\n    {\n        hideTransactionalColumns();\n    }\n    else\n    {\n        hideWireColumns();\n    }\n\n    setStdRevision(stdRevision);\n\n    connect(&portView_, SIGNAL(addMaster()), this, SLOT(onAddMaster()), Qt::UniqueConnection);\n    connect(&portView_, SIGNAL(addSlave()), this, SLOT(onAddSlave()), Qt::UniqueConnection);\n    connect(&portView_, SIGNAL(addSystem()), this, SLOT(onAddSystem()), Qt::UniqueConnection);\n    connect(&portView_, SIGNAL(addAllSystems()), this, SLOT(onAddAllSystems()), Qt::UniqueConnection);\n    connect(&portView_, SIGNAL(resetExtendPorts()), portModel_, SLOT(onResetExtendPorts()), Qt::UniqueConnection);\n\n    connect(portModel_, SIGNAL(dataChanged(const QModelIndex&, const QModelIndex&)),\n        this, SIGNAL(contentChanged()), Qt::UniqueConnection);\n    connect(portModel_, SIGNAL(contentChanged()), this, SIGNAL(contentChanged()), Qt::UniqueConnection);\n    connect(portModel_, SIGNAL(noticeMessage(const QString&)),\n        this, SIGNAL(noticeMessage(const QString&)), Qt::UniqueConnection);\n    connect(portModel_, SIGNAL(errorMessage(const QString&)),\n        this, SIGNAL(errorMessage(const QString&)), Qt::UniqueConnection);\n    connect(portModel_, SIGNAL(portRemoved(const QString&, const General::InterfaceMode)),\n        this, SIGNAL(portRemoved(const QString&, const General::InterfaceMode)), Qt::UniqueConnection);\n\n    connect(portModel_, SIGNAL(increaseReferences(QString const&)), this, SIGNAL(increaseReferences(QString)), Qt::UniqueConnection);\n    connect(portModel_, SIGNAL(decreaseReferences(QString const&)), this, SIGNAL(decreaseReferences(QString)), Qt::UniqueConnection);\n\n    connect(portDelegate_, SIGNAL(increaseReferences(QString)), this, SIGNAL(increaseReferences(QString)), Qt::UniqueConnection);\n    connect(portDelegate_, SIGNAL(decreaseReferences(QString)), this, SIGNAL(decreaseReferences(QString)), Qt::UniqueConnection);\n\n    if (type == LogicalPortColumns::AbstractionType::WIRE)\n    {\n        connect(&portView_, SIGNAL(addItem(const QModelIndex&)),\n            portModel_, SLOT(addWireSignal()), Qt::UniqueConnection);\n    }\n    else\n    {\n        connect(&portView_, SIGNAL(addItem(const QModelIndex&)),\n            portModel_, SLOT(addTransactionalSignal()), Qt::UniqueConnection);\n    }\n\n    connect(&portView_, SIGNAL(removeItem(const QModelIndex&)),\n        portModel_, SLOT(onRemoveItem(const QModelIndex&)), Qt::UniqueConnection);\n\n    setupLayout();\n}\n\n//-----------------------------------------------------------------------------\n// Function: AbstractionPortsEditor::onAddMaster()\n//-----------------------------------------------------------------------------\nvoid AbstractionPortsEditor::onAddMaster()\n{\n    QModelIndexList selection = getSelectedIndexes();\n    portModel_->addMaster(selection);\n}\n\n//-----------------------------------------------------------------------------\n// Function: AbstractionPortsEditor::onAddSlave()\n//-----------------------------------------------------------------------------\nvoid AbstractionPortsEditor::onAddSlave()\n{\n    QModelIndexList selection = getSelectedIndexes();\n    portModel_->addSlave(selection);\n}\n\n//-----------------------------------------------------------------------------\n// Function: AbstractionPortsEditor::onAddSystem()\n//-----------------------------------------------------------------------------\nvoid AbstractionPortsEditor::onAddSystem()\n{\n    QModelIndexList selection = getSelectedIndexes();\n    portModel_->addSystem(selection);\n}\n\n//-----------------------------------------------------------------------------\n// Function: AbstractionPortsEditor::onAddAllSystems()\n//-----------------------------------------------------------------------------\nvoid AbstractionPortsEditor::onAddAllSystems()\n{\n    QModelIndexList selection = getSelectedIndexes();\n    portModel_->addAllSystems(selection);\n}\n\n//-----------------------------------------------------------------------------\n// Function: AbstractionPortsEditor::getSelectedIndexes()\n//-----------------------------------------------------------------------------\nQModelIndexList AbstractionPortsEditor::getSelectedIndexes()\n{\n    QModelIndexList selection;\n    foreach(QModelIndex index, portView_.selected())\n    {\n        selection.append(portProxy_->mapToSource(index));\n    }\n\n    return selection;\n}\n\n//-----------------------------------------------------------------------------\n// Function: AbstractionPortsEditor::resetPortModel()\n//-----------------------------------------------------------------------------\nvoid AbstractionPortsEditor::resetPortModel()\n{\n    portModel_->resetPortModel();\n}\n\n//-----------------------------------------------------------------------------\n// Function: AbstractionPortsEditor::setBusDef()\n//-----------------------------------------------------------------------------\nvoid AbstractionPortsEditor::setBusDef(QSharedPointer<BusDefinition> busDefinition)\n{\n    portDelegate_->setBusDef(busDefinition);\n    portModel_->setBusDef(busDefinition);\n}\n\n//-----------------------------------------------------------------------------\n// Function: AbstractionPortsEditor::setStdRevision()\n//-----------------------------------------------------------------------------\nvoid AbstractionPortsEditor::setStdRevision(Document::Revision revision)\n{\n    if (revision != Document::Revision::Std22)\n    {\n        portView_.horizontalHeader()->hideSection(LogicalPortColumns::MATCH);\n    }\n\n    portView_.setRevision(revision);\n}\n\n//-----------------------------------------------------------------------------\n// Function: AbstractionPortsEditor::setupLayout()\n//-----------------------------------------------------------------------------\nvoid AbstractionPortsEditor::setupLayout()\n{\n    QVBoxLayout* topLayout = new QVBoxLayout(this);\n    topLayout->addWidget(&portView_);\n}\n\n//-----------------------------------------------------------------------------\n// Function: AbstractionPortsEditor::hideTransactionalColumns()\n//-----------------------------------------------------------------------------\nvoid AbstractionPortsEditor::hideTransactionalColumns()\n{\n    auto header = portView_.horizontalHeader();\n  \n    header->hideSection(LogicalPortColumns::INITIATIVE);\n    header->hideSection(LogicalPortColumns::KIND);\n    header->hideSection(LogicalPortColumns::BUSWIDTH);\n    header->hideSection(LogicalPortColumns::PROTOCOLTYPE);\n    header->hideSection(LogicalPortColumns::PAYLOADNAME);\n    header->hideSection(LogicalPortColumns::PAYLOADTYPE);\n    header->hideSection(LogicalPortColumns::PAYLOADEXTENSION);\n}\n\n//-----------------------------------------------------------------------------\n// Function: AbstractionPortsEditor::hideWireColumns()\n//-----------------------------------------------------------------------------\nvoid AbstractionPortsEditor::hideWireColumns()\n{\n    auto header = portView_.horizontalHeader();\n    \n    header->hideSection(LogicalPortColumns::DIRECTION);\n    header->hideSection(LogicalPortColumns::WIDTH);\n    header->hideSection(LogicalPortColumns::DEFAULT_VALUE);\n    header->hideSection(LogicalPortColumns::DRIVER);\n}\n"
  },
  {
    "path": "editors/AbstractionDefinitionEditor/AbstractionPortsEditor.h",
    "content": "//-----------------------------------------------------------------------------\n// File: AbstractionPortsEditor.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 04.06.2018\n//\n// Description:\n// Editor for the ports of an abstraction definition.\n//-----------------------------------------------------------------------------\n\n#ifndef ABSTRACTIONPORTSEDITOR_H\n#define ABSTRACTIONPORTSEDITOR_H\n\n#include <IPXACTmodels/generaldeclarations.h>\n\n#include <IPXACTmodels/common/Document.h>\n\n#include \"AbstractionPortsView.h\"\n#include \"LogicalPortColumns.h\"\n\n#include <QWidget>\n#include <QObject>\n\nclass AbstractionPortsModel;\nclass AbstractionDefinitionPortsSortFilter;\nclass AbstractionDefinition;\nclass AbstractionPortsDelegate;\nclass BusDefinition;\nclass PortAbstractionInterface;\nclass LibraryInterface;\nclass QAbstractItemModel;\nclass ParameterFinder;\n\n//-----------------------------------------------------------------------------\n//! Editor for the ports of an abstraction definition.\n//-----------------------------------------------------------------------------\nclass AbstractionPortsEditor : public QWidget\n{\n    Q_OBJECT\n\npublic:\n\n    /*!\n     *  The constructor.\n     *     \n     *    @param [in] parametersModel The parameter completer model to use.\n     *    @param [in] parameterFinder The parameter finder to use.\n     *    @param [in] libraryAccess   Interface to the library.\n     *    @param [in] portInterface   Interface for accessing port abstractions.\n     *    @param [in] stdRevision     The revision of the standard used by the abstraction definition.\n     *    @param [in] portsModel      Model for this editor.\n     *    @param [in] type            The type of ports the editor is targeted for: wire or transactional.\n     *    @param [in] parent          The owner of the editor.\n     */\n    AbstractionPortsEditor(QAbstractItemModel* parametersModel, QSharedPointer<ParameterFinder> parameterFinder,\n        LibraryInterface* libraryAccess, PortAbstractionInterface* portInterface,\n        Document::Revision stdRevision, AbstractionPortsModel* portModel,\n        LogicalPortColumns::AbstractionType type, QWidget* parent);\n\n    /*!\n     *  The destructor.\n     */\n    virtual ~AbstractionPortsEditor() = default;\n\n    /*!\n     *  Reset the port abstraction model.\n     */\n    void resetPortModel();\n\n    /*!\n     *  Set the bus definition referenced by the abstraction definition.\n     *\n     *    @param [in] busDefinition   The referenced bus definition.\n     */\n    void setBusDef(QSharedPointer<BusDefinition> busDefinition);\n\n    /*!\n     *\tSetup the editor according to document standard revision.\n     *  \n     *    @param [in] revision\tThe standard revision the abstraction definition is using.\n     */\n    void setStdRevision(Document::Revision revision);\n\nsignals:\n\n    /*!\n     *  Emitted when contents of this editor changes.\n     */\n    void contentChanged();\n\n    /*!\n     *  Emitted when an error should be printed to user.\n     */\n    void errorMessage(QString const& message);\n\n    /*!\n     *  Emitted when a notification should be printed to user.\n     */\n    void noticeMessage(QString const& message);\n\n    /*!\n     *  Inform that a port abstraction has been removed.\n     *\n     *    @param [in] portName    Name of the removed port abstraction.\n     *    @param [in] mode        Mode of the removed port abstraction.\n     */\n    void portRemoved(QString const& portName, General::InterfaceMode const mode);\n\n    /*!\n     *  Increase the amount of references to a parameter corresponding to the id.\n     *\n     *    @param [in] id      The id of the parameter being searched for.\n     */\n    void increaseReferences(QString id);\n\n    /*!\n     *  Decrease the amount of references to a parameter corresponding to the id.\n     *\n     *    @param [in] id      The id of the parameter being searched for.\n     */\n    void decreaseReferences(QString id);\n\nprivate slots:\n\n    /*!\n     *  Handles the adding of new master signals.\n     */\n    void onAddMaster();\n\n    /*!\n     *  Handles the adding of new slave signals.\n     */\n    void onAddSlave();\n\n    /*!\n     *  Handles the adding of new system signals.\n     */\n    void onAddSystem();\n\n    /*!\n     *  Handles the adding of missing system group signals.\n     */\n    void onAddAllSystems();\n\nprivate:\n    //! No copying. No assignment.\n    AbstractionPortsEditor(const AbstractionPortsEditor& other);\n    AbstractionPortsEditor& operator=(const AbstractionPortsEditor& other);\n\n    /*!\n     *  Sets the editor layout.\n     */\n    void setupLayout();\n\n   \n    /*!\n     *  Get a list of the selected indexes.\n     *\n     *    @return List of the selected indexes.\n     */\n    QModelIndexList getSelectedIndexes();\n\n    //! Hide columns specific to transactional ports.\n    void hideTransactionalColumns();\n\n    //! Hide columns specific to wire ports.\n    void hideWireColumns();\n\n    //-----------------------------------------------------------------------------\n    // Data.\n    //-----------------------------------------------------------------------------\n\n    //! The table view to display the logical signals\n    AbstractionPortsView portView_;\n\n    //! Proxy model for sorting abstract ports.\n    AbstractionDefinitionPortsSortFilter* portProxy_;\n\n    //! The model that contains the logical signals of Abstraction Definition.\n    AbstractionPortsModel* portModel_;\n\n    //! The item delegate for portView_.\n    AbstractionPortsDelegate* portDelegate_;\n\n};\n\n#endif // ABSTRACTIONPORTSEDITOR_H\n"
  },
  {
    "path": "editors/AbstractionDefinitionEditor/AbstractionPortsModel.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: AbstractionPortsModel.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 15.11.2019\n//\n// Description:\n// Data model for the signals within abstraction definition.\n//-----------------------------------------------------------------------------\n\n#include \"AbstractionPortsModel.h\"\n#include \"LogicalPortColumns.h\"\n#include \"QualifierData.h\"\n\n#include <IPXACTmodels/AbstractionDefinition/TransactionalAbstraction.h>\n#include <IPXACTmodels/AbstractionDefinition/TransactionalPort.h>\n#include <IPXACTmodels/AbstractionDefinition/WireAbstraction.h>\n#include <IPXACTmodels/AbstractionDefinition/WirePort.h>\n\n#include <IPXACTmodels/BusDefinition/BusDefinition.h>\n\n#include <IPXACTmodels/common/DirectionTypes.h>\n#include <IPXACTmodels/common/PresenceTypes.h>\n#include <IPXACTmodels/common/Protocol.h>\n\n#include <IPXACTmodels/utilities/BusDefinitionUtils.h>\n\n#include <common/KactusColors.h>\n\n#include <KactusAPI/include/PortAbstractionInterface.h>\n\n#include <QStringList>\n#include <QIcon>\n#include <QRegularExpression>\n\nnamespace {\n\n    const QList<LogicalPortColumns::Columns> extendLockedColumns({\n        LogicalPortColumns::NAME,\n        LogicalPortColumns::MODE,\n        LogicalPortColumns::QUALIFIER,\n        LogicalPortColumns::DIRECTION,\n        LogicalPortColumns::INITIATIVE,\n        LogicalPortColumns::KIND,\n        LogicalPortColumns::BUSWIDTH,\n        LogicalPortColumns::PROTOCOLTYPE,\n        LogicalPortColumns::PAYLOADNAME,\n        LogicalPortColumns::PAYLOADTYPE,\n        LogicalPortColumns::PAYLOADEXTENSION,\n        LogicalPortColumns::MATCH\n        });\n};\n\n//-----------------------------------------------------------------------------\n// Function: AbstractionPortsModel::AbstractionPortsModel()\n//-----------------------------------------------------------------------------\nAbstractionPortsModel::AbstractionPortsModel(QSharedPointer<ParameterFinder> parameterFinder,\n    QSharedPointer<ExpressionParser> expressionParser,\n    LibraryInterface* libraryAccess,\n    PortAbstractionInterface* portInterface, \n    PortAbstractionInterface* extendInterface,\n    QObject *parent) :\nReferencingTableModel(parameterFinder, parent),\nParameterizableTable(parameterFinder),\nbusDefinition_(),\nlibraryAccess_(libraryAccess),\nportInterface_(portInterface),\nextendInterface_(extendInterface)\n{\n    setExpressionParser(expressionParser);\n}\n\n//-----------------------------------------------------------------------------\n// Function: AbstractionPortsModel::rowCount()\n//-----------------------------------------------------------------------------\nint AbstractionPortsModel::rowCount(QModelIndex const& parent) const\n{\n    if (parent.isValid())\n    {\n        return 0;\n    }\n\n    return portInterface_->itemCount();\n}\n\n//-----------------------------------------------------------------------------\n// Function: AbstractionPortsModel::columnCount()\n//-----------------------------------------------------------------------------\nint AbstractionPortsModel::columnCount(QModelIndex const& parent) const\n{\n\tif (parent.isValid())\n    {\n\t\treturn 0;\n    }\n\n\treturn LogicalPortColumns::COLUMN_COUNT;\n}\n\n//-----------------------------------------------------------------------------\n// Function: AbstractionPortsModel::flags()\n//-----------------------------------------------------------------------------\nQt::ItemFlags AbstractionPortsModel::flags(const QModelIndex& index) const\n{\n    if (!index.isValid())\n    {\n        return Qt::NoItemFlags;\n    }\n\n    // Do not allow setting system groups for other than system mode.\n    if (index.column() == LogicalPortColumns::SYSTEM_GROUP &&\n        portInterface_->getMode(index.row()) != General::SYSTEM &&\n        portInterface_->getSystemGroup(index.row()).empty())\n    {\n        return Qt::ItemIsEnabled | Qt::ItemIsSelectable;\n    }\n\n    // Do not allow setting data defined in extended abstraction definition.\n    if (isLocked(index))\n    {\n        return Qt::ItemIsEnabled | Qt::ItemIsSelectable;\n    }\n    \n    return Qt::ItemIsEditable | Qt::ItemIsEnabled | Qt::ItemIsSelectable;\n}\n\n//-----------------------------------------------------------------------------\n// Function: AbstractionWirePortsModel::headerData()\n//-----------------------------------------------------------------------------\nQVariant AbstractionPortsModel::headerData(int section, Qt::Orientation orientation, int role) const\n{\n    if (role != Qt::DisplayRole && orientation == Qt::Horizontal)\n    {\n        return QVariant();\n    }\n\n    if (section == LogicalPortColumns::NAME)\n    {\t\t   \n        return tr(\"Name\");\n    }\n    else if (section == LogicalPortColumns::QUALIFIER)\n    {\n        return tr(\"Qualifier\");\n    }\n    else if (section == LogicalPortColumns::MATCH)\n    {\n        return tr(\"Port match\");\n    }\n    else if (section == LogicalPortColumns::WIDTH)\n    {\n        return tr(\"Width\") + getExpressionSymbol();\n    }\n    else if (section == LogicalPortColumns::DIRECTION)\n    {\n        return tr(\"Direction\");\n    }\n    else if (section == LogicalPortColumns::MODE)\n    {\n        return tr(\"Mode\");\n    }\n    else if (section == LogicalPortColumns::SYSTEM_GROUP)\n    {\n        return tr(\"System group\");\n    }\n    else if (section == LogicalPortColumns::PRESENCE)\n    {\n        return tr(\"Presence\");\n    }\n    else if (section == LogicalPortColumns::DEFAULT_VALUE)\n    {\n        return tr(\"Default value\") + getExpressionSymbol();\n    }\n    else if (section == LogicalPortColumns::DRIVER)\n    {\n        return tr(\"Driver\");\n    }\n    else if (section == LogicalPortColumns::DESCRIPTION)\n    {\n        return tr(\"Description\");\n    }\n    else if (section == LogicalPortColumns::INITIATIVE)\n    {\n        return tr(\"Initiative\");\n    }\n    else if (section == LogicalPortColumns::KIND)\n    {\n        return tr(\"Kind\");\n    }\n    else if (section == LogicalPortColumns::BUSWIDTH)\n    {\n        return tr(\"Bus width\") + getExpressionSymbol();\n    }\n    else if (section == LogicalPortColumns::PROTOCOLTYPE)\n    {\n        return tr(\"Protocol\\ntype\");\n    }\n    else if (section == LogicalPortColumns::PAYLOADNAME)\n    {\n        return tr(\"Payload\\nname\");\n    }\n    else if (section == LogicalPortColumns::PAYLOADTYPE)\n    {\n        return tr(\"Payload\\ntype\");\n    }\n    else if (section == LogicalPortColumns::PAYLOADEXTENSION)\n    {\n        return tr(\"Payload\\nextension\");\n    }\n    else\n    {\n        return QVariant();\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: AbstractionPortsModel::data()\n//-----------------------------------------------------------------------------\nQVariant AbstractionPortsModel::data(QModelIndex const& index, int role) const\n{\n    if (!index.isValid() || index.row() < 0 || index.row() >= portInterface_->itemCount())\n    {\n        return QVariant();\n    }\n\n    if (role == Qt::DisplayRole)\n    {\n        if (isValidExpressionColumn(index))\n        {\n            return formattedExpressionForIndex(index);\n        }\n        else if (index.column() == LogicalPortColumns::DESCRIPTION)\n        {\n            return valueForIndex(index).toString().replace(QRegularExpression(\"\\n.*$\",\n                QRegularExpression::DotMatchesEverythingOption), \"...\");\n        }\n        else\n        {\n            return valueForIndex(index);\n        }\n    }\n\n    else if (role == Qt::EditRole)\n    {\n        if (index.column() == LogicalPortColumns::QUALIFIER)\n        {\n            QStringList qualifierList;\n            for (auto const& qualifier : portInterface_->getQualifierStringList(index.row()))\n            {\n                qualifierList.append(QString::fromStdString(qualifier));\n            }\n\n            std::vector<std::string> attributesList = portInterface_->getQualifierAttributes(index.row());\n            QMap<QString, QString> attributes;\n\n            for (size_t i = 0; i + 1 < attributesList.size(); i += 2)\n            {\n                auto const& name = QString::fromStdString(attributesList.at(i));\n                auto const& value = QString::fromStdString(attributesList.at(i + 1));\n\n                attributes.insert(name, value);\n            }\n\n            return QVariant::fromValue(QualifierData{ qualifierList, attributes });\n        }\n\n        return expressionOrValueForIndex(index);\n    }\n\n    else if (role == Qt::ToolTipRole)\n    {\n        return valueForIndex(index);\n    }\n\n    else if (role == Qt::ForegroundRole)\n    {\n        return blackForValidOrRedForInvalidIndex(index);\n    }\n\n    else if (role == Qt::FontRole)\n    {\n        return italicForEvaluatedValue(index);\n    }\n\n    else if (role == Qt::DecorationRole && (index.column() == LogicalPortColumns::DIRECTION || index.column() == LogicalPortColumns::INITIATIVE))\n    {\n        std::string iconPath = portInterface_->getIconPathForSignal(index.row());\n        if (!iconPath.empty())\n        {\n            return QIcon(QString::fromStdString(iconPath));\n        }\n    }\n\n    return QVariant();\n}\n\n//-----------------------------------------------------------------------------\n// Function: AbstractionPortsModel::setData()\n//-----------------------------------------------------------------------------\nbool AbstractionPortsModel::setData(QModelIndex const& index, QVariant const& value, int role)\n{\n    QString newData = value.toString();\n    QString oldData = data(index, Qt::DisplayRole).toString();\n\n    if (!index.isValid() || index.row() < 0 || index.row() >= portInterface_->itemCount() || !(flags(index) & Qt::ItemIsEditable) || role != Qt::EditRole)\n    {\n        return false;\n    }\n\n    std::string portName = portInterface_->getIndexedItemName(index.row());\n    if (index.column() == LogicalPortColumns::NAME)\n    {\n        QString newName = value.toString();\n\n        portInterface_->setName(portName, newName.toStdString());\n    }\n    else if (index.column() == LogicalPortColumns::QUALIFIER)\n    {\n        setQualifierData(index, value);\n    }\n    else if (index.column() == LogicalPortColumns::MATCH)\n    {\n        portInterface_->setMatch(index.row(), value.toBool());\n    }\n    else if (index.column() == LogicalPortColumns::WIDTH)\n    {\n        if (!value.isValid())\n        {\n            removeReferencesFromSingleExpression(\n                QString::fromStdString(portInterface_->getWidthExpression(index.row())));\n        }\n\n        portInterface_->setWidth(index.row(), value.toString().toStdString());\n    }\n    else if (index.column() == LogicalPortColumns::DEFAULT_VALUE)\n    {\n        if (!value.isValid())\n        {\n            removeReferencesFromSingleExpression(\n                QString::fromStdString(portInterface_->getDefaultValueExpression(index.row())));\n        }\n\n        portInterface_->setDefaultValue(index.row(), value.toString().toStdString());\n    }\n    else if (index.column() == LogicalPortColumns::MODE)\n    {\n        portInterface_->setMode(index.row(), value.toString().toStdString());\n    }\n    else if (index.column() == LogicalPortColumns::INITIATIVE)\n    {\n        portInterface_->setInitiative(index.row(), value.toString().toStdString());\n    }\n    else if (index.column() == LogicalPortColumns::KIND)\n    {\n        portInterface_->setKind(index.row(), value.toString().toStdString());\n    }\n    else if (index.column() == LogicalPortColumns::BUSWIDTH)\n    {\n        if (!value.isValid())\n        {\n            removeReferencesFromSingleExpression(\n                QString::fromStdString(portInterface_->getBusWidthExpression(index.row())));\n        }\n\n        portInterface_->setBusWidth(index.row(), value.toString().toStdString());\n    }\n    else if (index.column() == LogicalPortColumns::SYSTEM_GROUP)\n    {\n        portInterface_->setSystemGroup(index.row(), value.toString().toStdString());\n    }\n    else if (index.column() == LogicalPortColumns::DIRECTION)\n    {\n        portInterface_->setDirection(index.row(), value.toString().toStdString());\n    }\n    else if (index.column() == LogicalPortColumns::PRESENCE)\n    {\n        portInterface_->setPresence(index.row(), value.toString().toStdString());\n    }\n    else if (index.column() == LogicalPortColumns::DRIVER)\n    {\n        portInterface_->setDriverType(index.row(), value.toString().toStdString());\n    }\n    else if (index.column() == LogicalPortColumns::PROTOCOLTYPE)\n    {\n        portInterface_->setProtocolType(index.row(), value.toString().toStdString());\n    }\n    else if (index.column() == LogicalPortColumns::PAYLOADNAME)\n    {\n        portInterface_->setPayloadName(index.row(), value.toString().toStdString());\n    }\n    else if (index.column() == LogicalPortColumns::PAYLOADTYPE)\n    {\n        portInterface_->setPayloadType(index.row(), value.toString().toStdString());\n    }\n    else if (index.column() == LogicalPortColumns::PAYLOADEXTENSION)\n    {\n        portInterface_->setPayloadExtension(index.row(), value.toString().toStdString());\n    }\n    else if (index.column() == LogicalPortColumns::DESCRIPTION)\n    {\n        portInterface_->setDescription(portName, value.toString().toStdString());\n    }\n    else\n    {\n        return false;\n    }\n\n    //! Indexing doesn't work correctly (select other than first index).\n    QModelIndexList indexList;\n    indexList.append(index);\n\n    if (index.column() == LogicalPortColumns::NAME || index.column() == LogicalPortColumns::DEFAULT_VALUE ||\n        index.column() == LogicalPortColumns::DRIVER || index.column() == LogicalPortColumns::QUALIFIER ||\n        index.column() == LogicalPortColumns::DESCRIPTION)\n    {\n        for (int i = 0; i < portInterface_->itemCount(); ++i)\n        {\n            std::string comparisonName = portInterface_->getIndexedItemName(i);\n            if (index.row() != i && portInterface_->portIsWire(portName) &&\n                portInterface_->portIsWire(comparisonName) &&\n                portName == comparisonName)\n            {\n                QModelIndex signalIndex = index.sibling(i, index.column());\n                indexList.append(signalIndex);\n            }\n        }\n    }\n\n    sendDataChangeForAllChangedItems(indexList);\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: AbstractionPortsModel::setQualifierData()\n//-----------------------------------------------------------------------------\nvoid AbstractionPortsModel::setQualifierData(QModelIndex const& index, QVariant const& value)\n{\n    QualifierData qualifierData = value.value<QualifierData>();\n    auto const& setQualifiers = qualifierData.activeQualifiers_;\n    auto const& setAttributes = qualifierData.attributes_;\n\n    std::vector<std::string> qualifierList;\n    std::vector<std::string> attributeList;\n\n    for (auto const& qualifier : setQualifiers)\n    {\n        qualifierList.push_back(qualifier.toStdString());\n    }\n\n    portInterface_->setQualifierStringList(index.row(), qualifierList);\n\n    if (portInterface_->getRevision() == Document::Revision::Std22)\n    {\n        for (auto const& attributeName : setAttributes.keys())\n        {\n            attributeList.push_back(attributeName.toStdString());\n            attributeList.push_back(setAttributes[attributeName].toStdString());\n        }\n\n        portInterface_->setQualifierAttributes(index.row(), attributeList);\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: AbstractionPortsModel::sendDataChangeForAllChangedItems()\n//-----------------------------------------------------------------------------\nvoid AbstractionPortsModel::sendDataChangeForAllChangedItems(QModelIndexList changedIndexes)\n{\n    QModelIndex firstIndex = changedIndexes.first();\n    QModelIndex lastIndex = changedIndexes.last();\n\n    for (QModelIndex const& currentIndex : changedIndexes)\n    {\n        if (currentIndex.row() < firstIndex.row())\n        {\n            firstIndex = currentIndex;\n        }\n        else if (currentIndex.row() > lastIndex.row())\n        {\n            lastIndex = currentIndex;\n        }\n    }\n\n    emit dataChanged(firstIndex, lastIndex);\n}\n\n//-----------------------------------------------------------------------------\n// Function: AbstractionPortsModel::resetPortModel()\n//-----------------------------------------------------------------------------\nvoid AbstractionPortsModel::resetPortModel()\n{\n    beginResetModel();\n    endResetModel();\n}\n\n\n//-----------------------------------------------------------------------------\n// Function: AbstractionPortsModel::setExtendedPorts()\n//-----------------------------------------------------------------------------\nvoid AbstractionPortsModel::setExtendedPorts()\n{\n    beginResetModel();\n    for (auto const& port : extendInterface_->getItemNames())\n    {\n        auto initiatorMode = extendInterface_->getRevision() == Document::Revision::Std22 ? General::INITIATOR : General::MASTER;\n        auto targetMode = extendInterface_->getRevision() == Document::Revision::Std22 ? General::TARGET : General::SLAVE;\n        if (extendInterface_->portIsWire(port))\n        {\n            extendWireMode(port, initiatorMode);\n            extendWireMode(port, targetMode);\n\n            for (auto const& systemGroup : extendInterface_->getSystemGroupsForPort(port))\n            {\n                extendWireMode(port, General::SYSTEM, systemGroup);\n            }\n        }\n        else if (extendInterface_->portIsTransactional(port))\n        {\n            extendTransactionalMode(port, initiatorMode);\n            extendTransactionalMode(port, targetMode);\n\n            for (auto const& systemGroup : extendInterface_->getSystemGroupsForPort(port))\n            {\n                extendTransactionalMode(port, General::SYSTEM, systemGroup);\n            }\n        }\n    }\n\n    endResetModel();\n}\n\n//-----------------------------------------------------------------------------\n// Function: AbstractionPortsModel::removeExtendedPorts()\n//-----------------------------------------------------------------------------\nvoid AbstractionPortsModel::removeExtendedPorts()\n{\n    for (int i = portInterface_->itemCount() - 1; i >= 0; --i)\n    {\n        if (isExtendedRow(i))\n        {\n            portInterface_->removeSignal(i);\n        }\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: AbstractionPortsModel::onResetExtendPorts()\n//-----------------------------------------------------------------------------\nvoid AbstractionPortsModel::onResetExtendPorts()\n{\n    setExtendedPorts();\n    emit contentChanged();\n}\n\n//-----------------------------------------------------------------------------\n// Function: AbstractionPortsModel::setBusDef()\n//-----------------------------------------------------------------------------\nvoid AbstractionPortsModel::setBusDef(QSharedPointer<BusDefinition> busDefinition)\n{\n    busDefinition_ = busDefinition;\n}\n\n//-----------------------------------------------------------------------------\n// Function: AbstractionPortsModel::addWireSignal()\n//-----------------------------------------------------------------------------\nvoid AbstractionPortsModel::addWireSignal()\n{\n    int itemCount = portInterface_->itemCount();\n    beginInsertRows(QModelIndex(), itemCount, itemCount);\n    portInterface_->addWirePort();\n    endInsertRows();\n\n    emit contentChanged();\n}\n\n//-----------------------------------------------------------------------------\n// Function: AbstractionPortsModel::addTransactionalSignal()\n//-----------------------------------------------------------------------------\nvoid AbstractionPortsModel::addTransactionalSignal()\n{\n    int itemCount = portInterface_->itemCount();\n    beginInsertRows(QModelIndex(), itemCount, itemCount);\n    portInterface_->addTransactionalPort();\n    endInsertRows();\n\n    emit contentChanged();\n}\n\n//-----------------------------------------------------------------------------\n// Function: AbstractionPortsModel::addMaster()\n//-----------------------------------------------------------------------------\nvoid AbstractionPortsModel::addMaster(QModelIndexList const& indexes)\n{\n    if (auto revision = portInterface_->getRevision();\n        revision == Document::Revision::Std22)\n    {\n        createNewSignal(General::INITIATOR, indexes);\n    }\n    else\n    {\n        createNewSignal(General::MASTER, indexes);\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: AbstractionPortsModel::addSlave()\n//-----------------------------------------------------------------------------\nvoid AbstractionPortsModel::addSlave(QModelIndexList const& indexes)\n{\n    if (auto revision = portInterface_->getRevision();\n        revision == Document::Revision::Std22)\n    {\n        createNewSignal(General::TARGET, indexes);\n    }\n    else\n    {\n        createNewSignal(General::SLAVE, indexes);\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: AbstractionPortsModel::createNewSignal()\n//-----------------------------------------------------------------------------\nvoid AbstractionPortsModel::createNewSignal(General::InterfaceMode newSignalMode,\n    QModelIndexList const& selection)\n{\n    QVector<int> targetSignals = getSelectedSignalRows(selection);\n    QVector<std::string> visitedPorts;\n\n    beginResetModel();\n\n    for (auto signalIndex : targetSignals)\n    {\n        std::string portName = portInterface_->getIndexedItemName(signalIndex);        \n        if (!visitedPorts.contains(portName))\n        {\n            visitedPorts.append(portName);\n            if (portInterface_->portIsWire(portName))\n            {\n                portInterface_->addModeSpecificWireSignal(portName, newSignalMode);\n            }\n            else \n            {\n                portInterface_->addModeSpecificTransactionalSignal(portName, newSignalMode);\n            }\n        }\n    }\n\n    endResetModel();\n\n    emit contentChanged();\n}\n\n//-----------------------------------------------------------------------------\n// Function: AbstractionPortsModel::getSelectedSignalRows()\n//-----------------------------------------------------------------------------\nQVector<int> AbstractionPortsModel::getSelectedSignalRows(QModelIndexList const& selection)\n{\n    QVector<int> targetSignalRows;\n\n    // Find all ports that match given indexes.\n    for(auto const& index : selection)\n    {\n        int indexRow = index.row();\n        if (0 <= indexRow && indexRow <= portInterface_->itemCount())\n        {\n            if (!targetSignalRows.contains(indexRow))\n            {\n                targetSignalRows.append(indexRow);\n            }\n        }\n    }\n\n    return targetSignalRows;\n}\n\n\n//-----------------------------------------------------------------------------\n// Function: AbstractionPortsModel::addSystem()\n//-----------------------------------------------------------------------------\nvoid AbstractionPortsModel::addSystem(QModelIndexList const& indexes)\n{\n    createNewSignal(General::SYSTEM, indexes);\n}\n\n//-----------------------------------------------------------------------------\n// Function: AbstractionPortsModel::addAllSystems()\n//-----------------------------------------------------------------------------\nvoid AbstractionPortsModel::addAllSystems(QModelIndexList const& indexes)\n{\n    QVector<int> targetSignals = getSelectedSignalRows(indexes);\n\n    beginResetModel();\n\n    for (auto const& signalIndex : targetSignals)\n    {\n        std::string portName = portInterface_->getIndexedItemName(signalIndex);\n        for (auto group : getMissingSystemGroupsForSignal(signalIndex))\n        {\n            if (portInterface_->portIsWire(portName))\n            {\n                portInterface_->addWireSystemSignal(portName, group.toStdString());\n            }\n            else\n            {\n                portInterface_->addTransactionalSystemSignal(portName, group.toStdString());\n            }\n        }\n    }\n\n    endResetModel();\n    emit contentChanged();\n}\n\n//-----------------------------------------------------------------------------\n// Function: AbstractionPortsModel::getMissingSystemGroupsForSignal()\n//-----------------------------------------------------------------------------\nQStringList AbstractionPortsModel::getMissingSystemGroupsForSignal(int const& signalIndex) const\n{\n    QStringList missingSystemGroups;\n    if (busDefinition_)\n    {\n        missingSystemGroups = BusDefinitionUtils::getSystemGroups(busDefinition_, libraryAccess_);\n    }\n\n    for (auto const& currentSystem :\n        portInterface_->getSystemGroupsForPort(portInterface_->getIndexedItemName(signalIndex)))\n    {\n        missingSystemGroups.removeAll(QString::fromStdString(currentSystem));\n    }\n\n    return missingSystemGroups;\n}\n\n//-----------------------------------------------------------------------------\n// Function: AbstractionPortsModel::isValidExpressionColumn()\n//-----------------------------------------------------------------------------\nbool AbstractionPortsModel::isValidExpressionColumn(QModelIndex const& index) const\n{\n    auto col = index.column();\n    return col == LogicalPortColumns::BUSWIDTH || col == LogicalPortColumns::WIDTH ||\n        col == LogicalPortColumns::DEFAULT_VALUE;\n}\n\n//-----------------------------------------------------------------------------\n// Function: AbstractionPortsModel::expressionOrValueForIndex()\n//-----------------------------------------------------------------------------\nQVariant AbstractionPortsModel::expressionOrValueForIndex(QModelIndex const& index) const\n{\n    if (isValidExpressionColumn(index))\n    {\n        return expressionForIndex(index);\n    }\n    else\n    {\n        return valueForIndex(index);\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: AbstractionPortsModel::expressionForIndex()\n//-----------------------------------------------------------------------------\nQVariant AbstractionPortsModel::expressionForIndex(QModelIndex const& index) const\n{\n    if (auto column = index.column(); column == LogicalPortColumns::BUSWIDTH)\n    {\n        return QString::fromStdString(portInterface_->getBusWidthExpression(index.row()));\n    }\n    else if (column == LogicalPortColumns::DEFAULT_VALUE)\n    {\n        return QString::fromStdString(portInterface_->getDefaultValueExpression(index.row()));\n    }\n    else if (column == LogicalPortColumns::WIDTH)\n    {\n        return QString::fromStdString(portInterface_->getWidthExpression(index.row()));\n    }\n\n    return QVariant();\n}\n\n//-----------------------------------------------------------------------------\n// Function: AbstractionPortsModel::validateIndex()\n//-----------------------------------------------------------------------------\nbool AbstractionPortsModel::validateIndex(QModelIndex const& index) const\n{\n    auto column = index.column();\n\n    auto portName = portInterface_->getIndexedItemName(index.row());\n\n    if (column == LogicalPortColumns::NAME)\n    {\n        return portInterface_->itemHasValidName(portName);\n    }\n    else if (column == LogicalPortColumns::BUSWIDTH)\n    {\n        return portInterface_->transactionalHasValidBusWidth(index.row());\n    }\n    else if (column == LogicalPortColumns::DEFAULT_VALUE)\n    {\n        return portInterface_->wireHasValidDefaultValue(index.row());\n    }\n    else if (column == LogicalPortColumns::WIDTH)\n    {\n        return portInterface_->wireHasValidWidth(index.row());\n    }\n\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: AbstractionPortsModel::getAllReferencesToIdInItemOnRow()\n//-----------------------------------------------------------------------------\nint AbstractionPortsModel::getAllReferencesToIdInItemOnRow(const int& row, QString const& valueID) const\n{\n    return portInterface_->getAllReferencesToIdInRow(row, valueID.toStdString());\n}\n\n//-----------------------------------------------------------------------------\n// Function: AbstractionPortsModel::valueForIndex()\n//-----------------------------------------------------------------------------\nQVariant AbstractionPortsModel::valueForIndex(const QModelIndex& index) const\n{\n    if (index.column() == LogicalPortColumns::NAME)\n    {\n        QString logicalName = QString::fromStdString(portInterface_->getIndexedItemName(index.row()));\n        if (logicalName.isEmpty())\n        {\n            return \"unnamed\";\n        }\n        else\n        {\n            return logicalName;\n        }\n    }\n    else if (index.column() == LogicalPortColumns::QUALIFIER)\n    {\n        QStringList qualifierList;\n        for (auto const& qualifier : portInterface_->getQualifierStringList(index.row()))\n        {\n            qualifierList.append(QString::fromStdString(qualifier));\n        }\n\n        return qualifierList.join(\", \");\n    }\n    else if (index.column() == LogicalPortColumns::MATCH)\n    {\n        return General::bool2Str(portInterface_->getMatch(index.row()));\n    }\n    else if (index.column() == LogicalPortColumns::WIDTH)\n    {\n        return QString::fromStdString(portInterface_->getWidthValue(index.row()));\n    }\n    else if (index.column() == LogicalPortColumns::DIRECTION)\n    {\n        return QString::fromStdString(portInterface_->getDirectionString(index.row()));\n    }\n    else if (index.column() == LogicalPortColumns::MODE)\n    {\n        return QString::fromStdString(portInterface_->getModeString(index.row()));\n    }\n    else if (index.column() == LogicalPortColumns::SYSTEM_GROUP)\n    {\n        return QString::fromStdString(portInterface_->getSystemGroup(index.row()));\n    }\n    else if (index.column() == LogicalPortColumns::PRESENCE)\n    {\n        return QString::fromStdString(portInterface_->getPresenceString(index.row()));\n    }\n    else if (index.column() == LogicalPortColumns::KIND)\n    {\n        return QString::fromStdString(portInterface_->getKind(index.row()));\n    }\n    else if (index.column() == LogicalPortColumns::INITIATIVE)\n    {\n        return QString::fromStdString(portInterface_->getInitiative(index.row()));\n    }\n    else if (index.column() == LogicalPortColumns::BUSWIDTH)\n    {\n        return QString::fromStdString(portInterface_->getBusWidthValue(index.row()));\n    }\n    else if (index.column() == LogicalPortColumns::DEFAULT_VALUE)\n    {\n        return QString::fromStdString(portInterface_->getDefaultValueValue(index.row()));\n    }\n    else if (index.column() == LogicalPortColumns::DRIVER)\n    {\n        return QString::fromStdString(portInterface_->getDriverString(index.row()));\n    }\n    else if (index.column() == LogicalPortColumns::DESCRIPTION)\n    {\n        std::string portName = portInterface_->getIndexedItemName(index.row());\n        return QString::fromStdString(portInterface_->getDescription(portName));\n    }\n    else if ((index.column() == LogicalPortColumns::PROTOCOLTYPE ||\n        index.column() == LogicalPortColumns::PAYLOADNAME ||\n        index.column() == LogicalPortColumns::PAYLOADTYPE ||\n        index.column() == LogicalPortColumns::PAYLOADEXTENSION) &&\n        portInterface_->hasProtocol(index.row()))\n    {\n        if (index.column() == LogicalPortColumns::PROTOCOLTYPE)\n        {\n            return QString::fromStdString(portInterface_->getProtocolType(index.row()));\n        }\n        else if (index.column() == LogicalPortColumns::PAYLOADNAME)\n        {\n            return QString::fromStdString(portInterface_->getPayloadName(index.row()));\n        }\n        else if (index.column() == LogicalPortColumns::PAYLOADTYPE)\n        {\n            return QString::fromStdString(portInterface_->getPayloadType(index.row()));\n        }\n        else if (index.column() == LogicalPortColumns::PAYLOADEXTENSION)\n        {\n            return QString::fromStdString(portInterface_->getPayloadExtension(index.row()));\n        }\n    }\n\n    return QVariant();\n}\n\n//-----------------------------------------------------------------------------\n// Function: AbstractionPortsModel::formattedExpressionForIndex()\n//-----------------------------------------------------------------------------\nQVariant AbstractionPortsModel::formattedExpressionForIndex(QModelIndex const& index) const\n{\n    int column = index.column();\n    int row = index.row();\n\n    if (column == LogicalPortColumns::WIDTH)\n    {\n        return QString::fromStdString(portInterface_->getWidthFormattedExpression(row));\n    }\n    else if (column == LogicalPortColumns::BUSWIDTH)\n    {\n        return QString::fromStdString(portInterface_->getBusWidthFormattedExpression(row));\n    }\n    else if (column == LogicalPortColumns::DEFAULT_VALUE)\n    {\n        return QString::fromStdString(portInterface_->getDefaultValueFormattedExpression(row));\n    }\n    \n    return QVariant();\n}\n\n//-----------------------------------------------------------------------------\n// Function: AbstractionWirePortsModel::onRemoveItem()\n//-----------------------------------------------------------------------------\nvoid AbstractionPortsModel::onRemoveItem(QModelIndex const& index)\n{\n    int indexRow = index.row();\n    if (0 <= index.row() && index.row() <= portInterface_->itemCount())\n    {\n        QString removedName = QString::fromStdString(portInterface_->getIndexedItemName(indexRow));\n        General::InterfaceMode removedMode = portInterface_->getMode(indexRow);\n\n        beginRemoveRows(QModelIndex(), index.row(), index.row());\n\n        portInterface_->removeSignal(indexRow);\n\n        endRemoveRows();\n\n        emit contentChanged();\n        emit portRemoved(removedName, removedMode);      \n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: AbstractionWirePortsModel::isLocked()\n//-----------------------------------------------------------------------------\nbool AbstractionPortsModel::isLocked(QModelIndex const& index) const\n{\n    return extendLockedColumns.contains(LogicalPortColumns::Columns(index.column())) &&\n        isExtendedRow(index.row());\n}\n\n//-----------------------------------------------------------------------------\n// Function: AbstractionWirePortsModel::isExtended()\n//-----------------------------------------------------------------------------\nbool AbstractionPortsModel::isExtendedRow(int row) const\n{\n    return extendInterface_->portHasMode(portInterface_->getIndexedItemName(row),\n        portInterface_->getModeString(row), portInterface_->getSystemGroup(row));\n}\n\n//-----------------------------------------------------------------------------\n// Function: AbstractionPortsModel::extendWireMode()\n//-----------------------------------------------------------------------------\nvoid AbstractionPortsModel::extendWireMode(std::string const& port, General::InterfaceMode mode,\n    std::string const& systemGroup)\n{\n    int extendIndex = extendInterface_->getItemIndex(port, mode, systemGroup);\n\n    if (extendIndex != -1)\n    {\n        std::string modeString = General::interfaceMode2Str(mode).toStdString();\n\n        if (portInterface_->portHasMode(port, modeString, systemGroup) == false)\n        {\n            if (mode == General::SYSTEM)\n            {\n                portInterface_->addWireSystemSignal(port, systemGroup);\n            }\n            else\n            {\n                portInterface_->addModeSpecificWireSignal(port, mode);\n            }\n\n            portInterface_->setDescription(port, extendInterface_->getDescription(port));\n        }\n\n        int index = portInterface_->getItemIndex(port, mode, systemGroup);\n\n        portInterface_->setDirection(index, extendInterface_->getDirectionString(extendIndex));\n        portInterface_->setMatch(index, extendInterface_->getMatch(extendIndex));\n        portInterface_->setQualifierStringList(index, extendInterface_->getQualifierStringList(extendIndex));\n        portInterface_->setQualifierAttributes(index, extendInterface_->getQualifierAttributes(extendIndex));\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: AbstractionPortsModel::extendTransactionalMode()\n//-----------------------------------------------------------------------------\nvoid AbstractionPortsModel::extendTransactionalMode(std::string const& port, General::InterfaceMode mode,\n    std::string const& systemGroup)\n{\n    int extendIndex = extendInterface_->getItemIndex(port, mode, systemGroup);\n\n    if (extendIndex != -1)\n    {\n        std::string modeString = General::interfaceMode2Str(mode).toStdString();\n\n        if (portInterface_->portHasMode(port, modeString, systemGroup) == false)\n        {\n            if (mode == General::SYSTEM)\n            {\n                portInterface_->addTransactionalSystemSignal(port, systemGroup);\n            }\n            else\n            {\n                portInterface_->addModeSpecificTransactionalSignal(port, mode);\n            }\n\n            portInterface_->setDescription(port, extendInterface_->getDescription(port));\n        }\n\n        int index = portInterface_->getItemIndex(port, mode, systemGroup);\n\n        portInterface_->setQualifierStringList(index, extendInterface_->getQualifierStringList(extendIndex));\n        portInterface_->setQualifierAttributes(index, extendInterface_->getQualifierAttributes(extendIndex));\n        portInterface_->setInitiative(index, extendInterface_->getInitiative(extendIndex));\n        portInterface_->setKind(index, extendInterface_->getKind(extendIndex));\n        portInterface_->setBusWidth(index, extendInterface_->getBusWidthExpression(extendIndex));\n        portInterface_->setMatch(index, extendInterface_->getMatch(extendIndex));\n\n        portInterface_->setProtocolType(index, extendInterface_->getProtocolType(extendIndex));\n        portInterface_->setPayloadName(index, extendInterface_->getPayloadName(extendIndex));\n        portInterface_->setPayloadType(index, extendInterface_->getPayloadType(extendIndex));\n        portInterface_->setPayloadExtension(index, extendInterface_->getPayloadExtension(extendIndex));\n    }\n}"
  },
  {
    "path": "editors/AbstractionDefinitionEditor/AbstractionPortsModel.h",
    "content": "//-----------------------------------------------------------------------------\n// File: AbstractionPortsModel.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 15.11.2019\n//\n// Description:\n// Data model for the signals within abstraction definition.\n//-----------------------------------------------------------------------------\n\n#ifndef ABSTRACTIONPORTSMODEL_H\n#define ABSTRACTIONPORTSMODEL_H\n\n#include <editors/ComponentEditor/common/ReferencingTableModel.h>\n#include <editors/ComponentEditor/common/ParameterizableTable.h>\n\n#include <IPXACTmodels/AbstractionDefinition/AbstractionDefinition.h>\n#include <IPXACTmodels/AbstractionDefinition/PortAbstraction.h>\n\n#include <IPXACTmodels/common/Qualifier.h>\n\n#include <IPXACTmodels/generaldeclarations.h>\n\n#include <QAbstractTableModel>\n#include <QList>\n#include <QSharedPointer>\n#include <QString>\n\n#include \"AbstractionDefinitionSignalRow.h\"\n\nclass BusDefinition;\nclass LibraryInterface;\nclass PortAbstractionInterface;\nclass Protocol;\nclass TransactionalPort;\nclass WirePort;\n\n//-----------------------------------------------------------------------------\n//! Data model for the signals within abstraction definition.\n//-----------------------------------------------------------------------------\nclass AbstractionPortsModel : public ReferencingTableModel, public ParameterizableTable\n{\n\tQ_OBJECT\n\npublic:\n\n    //! Roles for additional data.\n    enum portTypeRoles\n    {\n        isWireRole = Qt::UserRole,\n        isTransactionalRole = Qt::UserRole + 1,\n        isExtendLockedRole = Qt::UserRole + 2,\n        isPortLockedRole = Qt::UserRole + 3\n    };\n\n\t/*!\n\t *  The constructor.\n\t *\n     *    @param [in] parameterFinder     The parameter finder to use.\n     *    @param [in] expressionParser    The expression parser to use.\n     *    @param [in] libraryAccess       Interface to the library.\n     *    @param [in] portInterface       The port abstraction interface to use.\n     *    @param [in] extendInterface     The port abstraction interface to use for extended abstractions.\n     *    @param [in] parent              Pointer to the owner of this model.\n\t */\n    AbstractionPortsModel(QSharedPointer<ParameterFinder> parameterFinder,\n        QSharedPointer<ExpressionParser> expressionParser, LibraryInterface* libraryAccess,\n        PortAbstractionInterface* portInterface, PortAbstractionInterface* extendInterface, QObject *parent);\n\n\t/*!\n\t *  The destructor.\n\t */\n    virtual ~AbstractionPortsModel() = default;\n\n    //! No copying. No assignment.\n    AbstractionPortsModel(const AbstractionPortsModel& other) = delete;\n    AbstractionPortsModel& operator=(const AbstractionPortsModel& other) = delete;\n\n\n\t/*!\n\t *  Get the number of rows an item contains.\n\t *\n\t *    @param [in] parent      This should always be invalid model index.\n     *\n     *    @return                 Number of rows the item has.\n\t */\n\tvirtual int rowCount(const QModelIndex& parent = QModelIndex()) const;\n\n\t/*!\n\t *  Get the number of columns the model contains.\n\t *\n\t *    @param [in] parent      This should always be invalid model index.\n     *\n     *    @return                 Always returns 9 for invalid model indexes.\n\t */\n\tvirtual int columnCount(const QModelIndex& parent = QModelIndex()) const;\n    \n\t/*!\n\t *  Get the item flags that defines the possible operations for the item.\n\t *\n\t *    @param [in] index       Model index that identifies the item.\n     *\n     *    @return                 Qt::ItemFlags specify the possible operations for the item.\n\t */\n\tQt::ItemFlags flags(const QModelIndex& index) const;\n\n\t/*!\n\t *  Get the header data for specified header.\n\t *\n\t *    @param [in] section         The section specifies the row/column number for the header.\n\t *    @param [in] orientation     Specifies if horizontal or vertical header is wanted.\n\t *    @param [in] role            Specifies the type of the requested data.\n     *\n     *    @return                     QVariant contains the requested data.\n\t */\n\tvirtual QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;\n\n\t/*!\n\t *  Get the data for the specified item.\n\t *\n\t *    @param [in] index       Specifies the item that's data is requested.\n\t *    @param [in] role        The role that defines what kind of data is requested.\n     *\n     *    @return                 QVariant contains the data for the item.\n\t */\n\tvirtual QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const;\n\n\t/*!\n\t *  Save the data to the model for specified item.\n\t *\n\t *    @param [in] index   The model index of the item that's data is to be saved.\n\t *    @param [in] value   The data that is to be saved.\n\t *    @param [in] role    The role specifies what kind of data should be saved.\n     *\n     *    @return             True if saving happened successfully.\n\t */\n\tbool setData(const QModelIndex& index, const QVariant& value, int role = Qt::EditRole);\n\n    /*!\n     *\tSave the qualifier data to the IPXACT model.\n     *  \n     *    @param [in] index   The model index of the item that's data is to be saved.\n     *    @param [in] value   The data that is to be saved.\n     */\n    void setQualifierData(QModelIndex const& index, QVariant const& value);\n\n    /*!\n     *  Set the extend port abstractions.\n     */\n    void setExtendedPorts();\n\n    /*!\n     *  Remove the extend port abstractions.\n     */\n    void removeExtendedPorts();\n\n\t/*!\n\t *  Set the bus definition for the model.\n\t *\n\t *    @param [in] busDefinition      The bus definition to set.\n\t */\n    void setBusDef(QSharedPointer<BusDefinition> busDefinition);\n\n    void resetPortModel();\n\npublic slots:\n\n\t/*!\n\t *  Adds a new wire signal with mode as \"any\".\n\t */\n    void addWireSignal();\n\n    /*!\n     *  Adds a new transactional signal with mode as \"any\".\n     */\n    void addTransactionalSignal();\n\n    /*!\n     *  Adds the master mode for the selected ports.\n     *\n     *    @param [in] indexes     Indexes of the selected ports.\n     */\n    void addMaster(QModelIndexList const& indexes);\n\n    /*!\n     *  Adds the slave mode for the selected ports.\n     *\n     *    @param [in] indexes     Indexes of the selected ports.\n     */\n    void addSlave(QModelIndexList const& indexes);\n\n    /*!\n     *  Adds a system mode for the selected ports.\n     *\n     *    @param [in] indexes     Indexes of the selected ports.\n     */\n    void addSystem(QModelIndexList const& indexes);\n\n    /*!\n     *  Adds all the unconnected system groups for the selected ports.\n     *\n     *    @param [in] indexes     Indexes of the selected ports.\n     */\n    void addAllSystems(QModelIndexList const& indexes);\n\n    /*!\n     *  Remove the item with the given index.\n     *\n     *    @param [in] index       The index where to remove the item.\n     */\n    void onRemoveItem(QModelIndex const& index);\n   \n    /*!\n     *  Handle the reloading of extend ports.\n     */\n    void onResetExtendPorts();\n\nsignals:\n\n\t/*!\n\t *  Inform that the state of the model has changed.\n\t */\n\tvoid contentChanged();\n\n\t/*!\n\t *  Sends error message to be printed for the user.\n\t *\n\t *    @param [in] msg     The error message.\n\t */\n\tvoid errorMessage(QString const& msg);\n\n\t/*!\n\t *  Sends notification to be printed to user.\n\t *\n\t *    @param [in] msg   The notification message.\n\t */\n\tvoid noticeMessage(QString const& msg);\n\n    /*!\n     *  Inform that a port abstraction has been removed.\n     *\n     *    @param [in] portName    The port name.\n     *    @param [in] mode        The interface mode.\n     */\n    void portRemoved(QString const& portName, const General::InterfaceMode mode);\n\nprivate:\n\n    /*!\n     * Check if the given index is locked and cannot be edited.\n     *\n     *    @param [in] index  The index to check.\n     *\n     *    @return True, if the index is locked, otherwise false.\n     */\n    bool isLocked(QModelIndex const& index) const;\n\n    /*!\n     * Check if the given row is from extended abstractions.\n     *\n     *    @param [in] row  The row number to check.\n     *\n     *    @return True, if the given row is extended, otherwise false.\n     */\n     bool isExtendedRow(int row) const;\n\n    /*!\n     * Add definitions for extended wire.\n     *\n     *    @param [in] port         Name of the port to extend.\n     *    @param [in] mode         Mode of the port to extend.\n     *    @param [in] systemGroup  System group of the port to extend.\n     *\n     */\n    void extendWireMode(std::string const& port, General::InterfaceMode mode,\n        std::string const& systemGroup = std::string());\n\n    /*!\n     * Add definitions for extended transcational port.\n     *\n     *    @param [in] port         Name of the port to extend.\n     *    @param [in] mode         Mode of the port to extend.\n     *    @param [in] systemGroup  System group of the port to extend.\n     *\n     */\n    void extendTransactionalMode(std::string const& port, General::InterfaceMode mode,\n        std::string const& systemGroup = std::string());\n\n    /*!\n     *  Send change data signals for all the affected items.\n     *\n     *    @param [in] changedIndexes  List of all the changed model indexes.\n     */\n    void sendDataChangeForAllChangedItems(QModelIndexList changedIndexes);\n\n    /*!\n     *  Create new master or slave signals for the selected ports.\n     *\n     *    @param [in] newSignalMode   The new interface mode.\n     *    @param [in] selection       Indexes of the selected ports.\n     */\n    void createNewSignal(General::InterfaceMode newSignalMode, QModelIndexList const& selection);\n\n    QVector<int> getSelectedSignalRows(QModelIndexList const& selection);\n\n    /*!\n     *  Get the missing system groups for the selected port.\n     *\n     *    @param [in] signal  Signal of the selected port.\n     *\n     *    @return The system groups that have not been connected to the system signals of the selected port.\n     */\n\n    QStringList getMissingSystemGroupsForSignal(int const& signalIndex) const;\n\n    /*!\n     *  Check if the column index is valid for containing expressions.\n     *\n     *    @param [in] index   The index being evaluated.\n     *\n     *    @return     True, if column can have expressions, false otherwise.\n     */\n    bool isValidExpressionColumn(QModelIndex const& index) const final;\n\n    /*!\n     *  Gets the expression for the given index or the plain value if expression is not available.\n     *\n     *    @param [in] index   The index whose expression to get.\n     *\n     *    @return The expression for the index if available, otherwise the value for the given index.\n     */\n    QVariant expressionOrValueForIndex(QModelIndex const& index) const final;\n\n    /*!\n     *\tGet the unformatted expression for a selected index.\n     *  \n     *    @param [in] index     Index to get the expression of.\n     *\t    \n     * \t    @return The unformatted expression.\n     */\n    QVariant expressionForIndex(QModelIndex const& index) const;\n\n    /*!\n     *  Validates the data in an index.\n     *\n     *    @param [in] index   The index whose data to validate\n     *\n     *    @return True, if the data in the index is valid, otherwise false.\n     */\n    bool validateIndex(QModelIndex const& index) const final;\n\n    /*!\n     *  Gets the number of all the references made to a selected id on the selected row.\n     *\n     *    @param [in] row         The row of the selected item.\n     *    @param [in] valueID     The id of the referenced parameter.\n     *\n     *    @return The amount of references made to the selected id on the selected row.\n     */\n    int getAllReferencesToIdInItemOnRow(const int& row, QString const& valueID) const final;\n\n    /*!\n     *  Get the value for the corresponding index.\n     *\n     *    @param [in] index   The index whose value is being searched for.\n     */\n    QVariant valueForIndex(const QModelIndex& index) const;\n\n    /*!\n     *  Get the formatted value of an expression in the selected index.\n     *\n     *    @param [in] index   The selected index.\n     *\n     *    @return The formatted value of an expression in the selected index.\n     */\n    QVariant formattedExpressionForIndex(QModelIndex const& index) const;\n\n    //-----------------------------------------------------------------------------\n    // Data.\n    //-----------------------------------------------------------------------------\n\n    //! The bus definition detailed in the abstraction definition.\n    QSharedPointer<BusDefinition> busDefinition_;\n\n\t//! Contains the rows in the table.\n    QList<AbstractionDefinitionSignalRow> table_;\n\n    //! Interface to the library.\n    LibraryInterface* libraryAccess_;\n\n    //! Interface to the abstraction definition ports being edited.\n    PortAbstractionInterface* portInterface_;\n\n    //! Interface to the abstraction definition being extended, if any.\n    PortAbstractionInterface* extendInterface_;\n};\n\n#endif // ABSTRACTIONPORTSMODEL_H\n"
  },
  {
    "path": "editors/AbstractionDefinitionEditor/AbstractionPortsView.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: AbstractionPortsView.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Antti Kamppi\n// Date: 21.6.2011\n//\n// Description:\n// The view that displays the contents of the BusPortsModel.\n//-----------------------------------------------------------------------------\n\n#include \"AbstractionPortsView.h\"\n\n#include \"AbstractionPortsModel.h\"\n\n#include <QMenu>\n\n//-----------------------------------------------------------------------------\n// Function: AbstractionPortsView::AbstractionPortsView()\n//-----------------------------------------------------------------------------\nAbstractionPortsView::AbstractionPortsView(QWidget *parent):\nEditableTableView(parent),\naddMasterAction_(tr(\"Add master signal\"), this),\naddSlaveAction_(tr(\"Add slave signal\"), this),\naddSystemAction_(tr(\"Add system signal\"), this),\naddAllSystemsAction_(tr(\"Add all unconnected system signals\"), this),\nresetExtendPortsAction_(tr(\"Reset extend ports\"), this)\n{\n    connect(&addMasterAction_, SIGNAL(triggered()), this, SIGNAL(addMaster()), Qt::UniqueConnection);\n    connect(&addSlaveAction_, SIGNAL(triggered()), this, SIGNAL(addSlave()), Qt::UniqueConnection);\n    connect(&addSystemAction_, SIGNAL(triggered()), this, SIGNAL(addSystem()), Qt::UniqueConnection);\n    connect(&addAllSystemsAction_, SIGNAL(triggered()), this, SIGNAL(addAllSystems()), Qt::UniqueConnection);\n    connect(&resetExtendPortsAction_, SIGNAL(triggered()), this, SIGNAL(resetExtendPorts()), Qt::UniqueConnection);\n}\n\n//-----------------------------------------------------------------------------\n// Function: AbstractionPortsView::~AbstractionPortsView()\n//-----------------------------------------------------------------------------\nAbstractionPortsView::~AbstractionPortsView()\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: AbstractionPortsView::selected()\n//-----------------------------------------------------------------------------\nQModelIndexList AbstractionPortsView::selected() const\n{\n    return selectedIndexes();\n}\n\n//-----------------------------------------------------------------------------\n// Function: AbstractionPortsView::setRevision()\n//-----------------------------------------------------------------------------\nvoid AbstractionPortsView::setRevision(Document::Revision revision)\n{\n    if (revision == Document::Revision::Std22)\n    {\n        addMasterAction_.setText(QStringLiteral(\"Add initiator signal\"));\n        addSlaveAction_.setText(QStringLiteral(\"Add target signal\"));\n    }\n    else\n    {\n        addMasterAction_.setText(QStringLiteral(\"Add master signal\"));\n        addSlaveAction_.setText(QStringLiteral(\"Add slave signal\"));\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: AbstractionPortsView::contextMenuEvent()\n//-----------------------------------------------------------------------------\nvoid AbstractionPortsView::contextMenuEvent(QContextMenuEvent* event)\n{\n    pressedPoint_ = event->pos();\n\n    QModelIndex index = indexAt(pressedPoint_);\n\n    if (index.data(AbstractionPortsModel::isExtendLockedRole).toBool())\n    {\n        removeAction_.setDisabled(true);\n    }\n    else\n    {\n        removeAction_.setEnabled(true);\n    }\n\n    if (!(index.flags() & Qt::ItemIsEditable))\n    {\n        clearAction_.setDisabled(true);\n    }\n    else\n    {\n        clearAction_.setEnabled(true);\n    }\n\n    QMenu menu(this);\n    if (index.isValid())\n    {\n        menu.addAction(&addMasterAction_);\n        menu.addAction(&addSlaveAction_);\n        menu.addAction(&addSystemAction_);\n        menu.addAction(&addAllSystemsAction_);\n        menu.addSeparator();\n    }\n\n    menu.addAction(&resetExtendPortsAction_);\n    menu.addSeparator();\n\n    menu.addAction(&addAction_);\n    \n    // if at least one valid item is selected\n    if (index.isValid())\n    {\n        menu.addAction(&removeAction_);\n        menu.addAction(&clearAction_);\n        menu.addAction(&copyAction_);    \n    }\n    menu.addAction(&pasteAction_);\n\n    if (importExportAllowed())\n    {\n        menu.addSeparator();\n        menu.addAction(&importAction_);\n        menu.addAction(&exportAction_);\n    }\n\n    menu.exec(event->globalPos());\n\n    event->accept();\n}\n\n"
  },
  {
    "path": "editors/AbstractionDefinitionEditor/AbstractionPortsView.h",
    "content": "//-----------------------------------------------------------------------------\n// File: AbstractionPortsView.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Antti Kamppi\n// Date: 21.6.2011\n//\n// Description:\n// The view that displays the contents of the BusPortsModel.\n//-----------------------------------------------------------------------------\n\n#ifndef ABSTRACTIONPORTSVIEW_H\n#define ABSTRACTIONPORTSVIEW_H\n\n#include <common/views/EditableTableView/editabletableview.h>\n#include <IPXACTmodels/common/Document.h>\n\n#include <QAction>\n#include <QContextMenuEvent>\n#include <QModelIndexList>\n#include <QTableView>\n\n//-----------------------------------------------------------------------------\n//! The view that displays the contents of the BusPortsModel.\n//-----------------------------------------------------------------------------\nclass AbstractionPortsView : public EditableTableView\n{\n\tQ_OBJECT\n\npublic:\n\n\t/*!\n     *  The constructor.\n\t *\n\t *    @param [in] parent  The owner of this widget.\n     */\n    AbstractionPortsView(QWidget* parent);\n\t\n\t/*!\n     *  The destructor.\n     */\n\tvirtual ~AbstractionPortsView();\n\n\t/*!\n     *  Get list of currently selected indexes.\n\t *\n\t *    @return The model indexes of the selected items.\n     */\n\tQModelIndexList selected() const;\n\n    void setRevision(Document::Revision revision);\n\nsignals:\n\n    /*!\n     *  Emitted when a master mode should be added to the selected signal.\n     */\n    void addMaster();\n\n    /*!\n     *  Emitted when a slave mode should be added to the selected signal.\n     */\n    void addSlave();\n\n    /*!\n     *  Emitted when a system mode should be added to the selected signal.\n     */\n    void addSystem();\n\n    /*!\n     *  Emitted when the missing system group modes should be added to the selected signal.\n     */\n    void addAllSystems();\n\n    /*!\n     *  Emitted when the extend ports need to be reloaded from the extend abstraction definition.\n     */\n    void resetExtendPorts();\n\nprotected:\n\n\t//! Handler for context menu events\n\tvirtual void contextMenuEvent(QContextMenuEvent* e);\n\nprivate:\n\t//! No copying\n    AbstractionPortsView(const AbstractionPortsView& other);\n\n\t//! No assignment\n    AbstractionPortsView& operator=(const AbstractionPortsView& other);\n\n    //-----------------------------------------------------------------------------\n    // Data.\n    //-----------------------------------------------------------------------------\n\n    //! Action for adding a master mode for a signal.\n    QAction addMasterAction_;\n\n    //! Action for adding a slave mode for a signal.\n    QAction addSlaveAction_;\n\n    //! Action for adding a system mode for a signal.\n    QAction addSystemAction_;\n\n    //! Action for adding the missing system modes for a signal.\n    QAction addAllSystemsAction_;\n\n    //! Action for reloading the extended abstraction definition ports.\n    QAction resetExtendPortsAction_;\n};\n\n#endif // ABSTRACTIONPORTSVIEW_H\n"
  },
  {
    "path": "editors/AbstractionDefinitionEditor/AbstractionTransactionalPortsDelegate.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: AbstractionTransactionalPortsDelegate.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 06.06.2018\n//\n// Description:\n// The delegate that provides editors for transactional port properties in Abstraction Definition.\n//-----------------------------------------------------------------------------\n\n#include \"AbstractionTransactionalPortsDelegate.h\"\n\n#include <editors/AbstractionDefinitionEditor/LogicalPortColumns.h>\n\n#include <KactusAPI/include/PortAbstractionInterface.h>\n\n#include <QComboBox>\n#include <QStringList>\n#include <QLineEdit>\n\n//-----------------------------------------------------------------------------\n// Function: AbstractionTransactionalPortsDelegate::AbstractionTransactionalPortsDelegate()\n//-----------------------------------------------------------------------------\nAbstractionTransactionalPortsDelegate::AbstractionTransactionalPortsDelegate(QAbstractItemModel* parametersModel,\n    QSharedPointer<ParameterFinder> parameterFinder, LibraryInterface* libraryAccess,\n    Document::Revision stdRevision, QObject* parent) :\nAbstractionPortsDelegate(parametersModel, parameterFinder, libraryAccess, stdRevision, parent)\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: AbstractionTransactionalPortsDelegate::columnAcceptsExpression()\n//-----------------------------------------------------------------------------\nbool AbstractionTransactionalPortsDelegate::columnAcceptsExpression(int column) const\n{\n    return column == LogicalPortColumns::BUSWIDTH;\n}\n\n//-----------------------------------------------------------------------------\n// Function: AbstractionTransactionalPortsDelegate::createEditor()\n//-----------------------------------------------------------------------------\nQWidget* AbstractionTransactionalPortsDelegate::createEditor(QWidget* parent, QStyleOptionViewItem const& option,\n    const QModelIndex& index ) const\n{\n    if (index.column() == LogicalPortColumns::INITIATIVE)\n    {\n        QComboBox* initiativeCombo = new QComboBox(parent);\n\n        QStringList list{ \"none\", \"requires\", \"provides\", \"requires/provides\" };\n        initiativeCombo->addItems(list);\n\n        connect(initiativeCombo, SIGNAL(destroyed()), this, SLOT(commitAndCloseEditor()), Qt::UniqueConnection);\n        return initiativeCombo;\n    }\n    else if (index.column() == LogicalPortColumns::KIND)\n    {\n        QComboBox* kindCombo = new QComboBox(parent);\n        kindCombo->setEditable(true);\n\n        QStringList list = { \"tlm_port\", \"tlm_socket\", \"simple_socket\", \"multi_socket\" };\n        kindCombo->addItems(list);\n\n        connect(kindCombo, SIGNAL(destroyed()), this, SLOT(commitAndCloseEditor()), Qt::UniqueConnection);\n        return kindCombo;\n    }\n    else if (index.column() == LogicalPortColumns::PROTOCOLTYPE)\n    {\n        QComboBox* protocolTypeCombo = new QComboBox(parent);\n        protocolTypeCombo->setEditable(true);\n\n        QStringList list = { \"\", \"tlm\" };\n        protocolTypeCombo->addItems(list);\n\n        connect(protocolTypeCombo, SIGNAL(destroyed()), this, SLOT(commitAndCloseEditor()), Qt::UniqueConnection);\n        return protocolTypeCombo;\n    }\n    else if (index.column() == LogicalPortColumns::PAYLOADTYPE)\n    {\n        QComboBox* payloadTypeCombo = new QComboBox(parent);\n\n        QStringList list = { \"none\", \"generic\", \"specific\" };\n        payloadTypeCombo->addItems(list);\n\n        connect(payloadTypeCombo, SIGNAL(destroyed()), this, SLOT(commitAndCloseEditor()), Qt::UniqueConnection);\n        return payloadTypeCombo;\n    }\n    else\n    {\n        return AbstractionPortsDelegate::createEditor(parent, option, index);\n    }\n}\n"
  },
  {
    "path": "editors/AbstractionDefinitionEditor/AbstractionTransactionalPortsDelegate.h",
    "content": "//-----------------------------------------------------------------------------\n// File: AbstractionTransactionalPortsDelegate.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 06.06.2018\n//\n// Description:\n// The delegate that provides editors for transactional port properties in Abstraction Definition.\n//-----------------------------------------------------------------------------\n\n#ifndef ABSTRACTIONTRANSACTIONALPORTSDELEGATE_H\n#define ABSTRACTIONTRANSACTIONALPORTSDELEGATE_H\n\n#include \"AbstractionPortsDelegate.h\"\n\nclass PortAbstractionInterface;\n//-----------------------------------------------------------------------------\n//! The delegate that provides editors for transactional port properties in Abstraction Definition.\n//-----------------------------------------------------------------------------\nclass AbstractionTransactionalPortsDelegate : public AbstractionPortsDelegate\n{\n\tQ_OBJECT\n\npublic:\n\n\t/*!\n     *  The constructor.\n\t *\n     *    @param [in] parametersModel The parameter completer model to use.\n     *    @param [in] parameterFinder The parameter finder to use.\n     *    @param [in] libraryAccess   Interface to the library.\n     *    @param [in] stdRevision     The standard revision used by the abstraction definition.\n     *    @param [in] parent          The owner of this instance\n     */\n    AbstractionTransactionalPortsDelegate(QAbstractItemModel* parametersModel, \n        QSharedPointer<ParameterFinder> parameterFinder, LibraryInterface* libraryAccess, \n        Document::Revision stdRevision, QObject *parent);\n\n\t/*!\n     *  The destructor.\n     */\n\tvirtual ~AbstractionTransactionalPortsDelegate() = default;\n\n\t/*!\n     *  Create a new editor for the given item\n\t *\n\t *    @param [in] parent  Owner for the editor.\n\t *    @param [in] option  Contains options for the editor.\n\t *    @param [in] index   Model index identifying the item.\n\t *\n\t *    @return The editor to be used to edit the item.\n     */\n\tvirtual QWidget* createEditor(QWidget* parent, QStyleOptionViewItem const& option, QModelIndex const& index)\n        const;\n\n    //! No copying. No assignment.\n    AbstractionTransactionalPortsDelegate(const AbstractionTransactionalPortsDelegate& other) = delete;\n    AbstractionTransactionalPortsDelegate& operator=(const AbstractionTransactionalPortsDelegate& other) = delete;\n\nprivate:\n\n    /*!\n     *  Checks if the given column supports expressions in the editor.\n     *\n     *    @param [in] column   The column to check.\n     *\n     *    @return True, if the cells in the column allow expressions, otherwise false.\n     */\n    bool columnAcceptsExpression(int column) const final;\n\n};\n\n#endif // ABSTRACTIONTRANSACTIONALPORTSDELEGATE_H\n"
  },
  {
    "path": "editors/AbstractionDefinitionEditor/AbstractionTransactionalPortsSortFilter.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: AbstractionTransactionalPortsSortFilter.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 21.06.2018\n//\n// Description:\n// Sort filter proxy model for abstraction transactional ports.\n//-----------------------------------------------------------------------------\n\n#include \"AbstractionTransactionalPortsSortFilter.h\"\n\n#include <common/KactusColors.h>\n\n#include <KactusAPI/include/PortAbstractionInterface.h>\n#include <editors/AbstractionDefinitionEditor/LogicalPortColumns.h>\n\n//-----------------------------------------------------------------------------\n// Function: AbstractionTransactionalPortsSortFilter::AbstractionTransactionalPortsSortFilter()\n//-----------------------------------------------------------------------------\nAbstractionTransactionalPortsSortFilter::AbstractionTransactionalPortsSortFilter(\n    PortAbstractionInterface* portInterface,\n    QObject *parent):\nAbstractionDefinitionPortsSortFilter(portInterface, parent)\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: AbstractionTransactionalPortsSortFilter::getBackgroundColorForIndex()\n//-----------------------------------------------------------------------------\nQColor AbstractionTransactionalPortsSortFilter::getBackgroundColorForIndex(QModelIndex const& index) const\n{\n    if (index.column() == LogicalPortColumns::PROTOCOLTYPE && indexedRowContainsPayload(index))\n    {\n        return KactusColors::MANDATORY_FIELD;\n    }\n    else if (index.column() == LogicalPortColumns::PAYLOADTYPE &&\n        indexedRowContainsPayload(index))\n    {\n        return KactusColors::MANDATORY_FIELD;\n    }\n    \n    return AbstractionDefinitionPortsSortFilter::getBackgroundColorForIndex(index);\n}\n\n//-----------------------------------------------------------------------------\n// Function: AbstractionTransactionalPortsSortFilter::indexedRowContainsPayload()\n//-----------------------------------------------------------------------------\nbool AbstractionTransactionalPortsSortFilter::indexedRowContainsPayload(QModelIndex const& index) const\n{\n    QModelIndex payloadNameIndex = index.sibling(index.row(), LogicalPortColumns::PAYLOADNAME);\n    QModelIndex payloadTypeIndex = index.sibling(index.row(), LogicalPortColumns::PAYLOADTYPE);\n    QModelIndex payloadExtensionIndex =\n        index.sibling(index.row(), LogicalPortColumns::PAYLOADEXTENSION);\n\n    return !payloadNameIndex.data(Qt::DisplayRole).toString().isEmpty() ||\n        !payloadTypeIndex.data(Qt::DisplayRole).toString().isEmpty() ||\n        !payloadExtensionIndex.data(Qt::DisplayRole).toString().isEmpty();\n}\n\n//-----------------------------------------------------------------------------\n// Function: AbstractionTransactionalPortsSortFilter::filterAcceptsRow()\n//-----------------------------------------------------------------------------\nbool AbstractionTransactionalPortsSortFilter::filterAcceptsRow(int source_row, const QModelIndex &source_parent)\nconst\n{\n    if (source_parent.isValid())\n    {\n        return false;\n    }\n\n    std::string portName = portInterface_->getIndexedItemName(source_row);\n    return portInterface_->portIsTransactional(portName);\n}\n"
  },
  {
    "path": "editors/AbstractionDefinitionEditor/AbstractionTransactionalPortsSortFilter.h",
    "content": "//-----------------------------------------------------------------------------\n// File: AbstractionTransactionalPortsSortFilter.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 21.06.2018\n//\n// Description:\n// Sort filter proxy model for abstraction transactional ports.\n//-----------------------------------------------------------------------------\n\n#ifndef ABSTRACTIONTRANSACTIONALPORTSSORTFILTER_H\n#define ABSTRACTIONTRANSACTIONALPORTSSORTFILTER_H\n\n#include \"AbstractionDefinitionPortsSortFilter.h\"\n\n#include <QSortFilterProxyModel>\n#include <QColor>\n\n//-----------------------------------------------------------------------------\n//! Sort filter proxy model for abstraction definition ports.\n//-----------------------------------------------------------------------------\nclass AbstractionTransactionalPortsSortFilter : public AbstractionDefinitionPortsSortFilter\n{\n\npublic:\n\n\t/*!\n\t *  The constructor.\n\t *\n     *    @param [in] portInterface   Interface for accessing port abstractions.\n     *    @param [in] parent          Pointer to the owner of this model.\n\t */\n    AbstractionTransactionalPortsSortFilter(\n        PortAbstractionInterface* portInterface, QObject *parent);\n\t\n\t/*!\n\t *  The destructor.\n\t */\n    virtual ~AbstractionTransactionalPortsSortFilter() = default;\n\nprotected:\n\n    /*!\n     *  Get the background color for the selected index.\n     *\n     *    @param [in] index   Index of the selected item.\n     *\n     *    @return Background color for the selected index.\n     */\n    virtual QColor getBackgroundColorForIndex(QModelIndex const& index) const;\n\n    /*!\n     *  Check if the filter should accept the selected row.\n     *\n     *    @param [in] source_row      Row of the selected item.\n     *    @param [in] source_parent   Parent index of the item.\n     *\n     *    @return True, if the row is accepted, false otherwise.\n     */\n    virtual bool filterAcceptsRow(int source_row, const QModelIndex &source_parent) const override final;\n\nprivate:\n\t//! No copying. No assignment.\n    AbstractionTransactionalPortsSortFilter(const AbstractionTransactionalPortsSortFilter& other);\n\tAbstractionTransactionalPortsSortFilter& operator=(const AbstractionTransactionalPortsSortFilter& other);\n\n    /*!\n     *  Check if the indexed row contains a protocol payload.\n     *\n     *    @param [in] index   Index of the selected row.\n     *\n     *    @return True, if the indexed row contains a protocol payload, false otherwise.\n     */\n    bool indexedRowContainsPayload(QModelIndex const& index) const;\n};\n\n#endif // ABSTRACTIONTRANSACTIONALPORTSSORTFILTER_H\n"
  },
  {
    "path": "editors/AbstractionDefinitionEditor/AbstractionWirePortsDelegate.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: AbstractionWirePortsDelegate.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Antti Kamppi\n// Date: 27.6.2011\n//\n// Description:\n// The delegate that provides editors for logical port properties in Abstraction Definition.\n//-----------------------------------------------------------------------------\n\n#include \"AbstractionWirePortsDelegate.h\"\n#include \"LogicalPortColumns.h\"\n\n#include <KactusAPI/include/PortAbstractionInterface.h>\n\n#include <QComboBox>\n#include <QStringList>\n#include <QLineEdit>\n\n//-----------------------------------------------------------------------------\n// Function: AbstractionWirePortsDelegate::AbstractionWirePortsDelegate()\n//-----------------------------------------------------------------------------\nAbstractionWirePortsDelegate::AbstractionWirePortsDelegate(QAbstractItemModel* parametersModel, \n    QSharedPointer<ParameterFinder> parameterFinder, LibraryInterface* libraryAccess,\n    Document::Revision stdRevision, QObject *parent):\nAbstractionPortsDelegate(parametersModel, parameterFinder, libraryAccess, stdRevision, parent)\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: AbstractionWirePortsDelegate::createEditor()\n//-----------------------------------------------------------------------------\nQWidget* AbstractionWirePortsDelegate::createEditor(QWidget* parent, QStyleOptionViewItem const& option,\n    const QModelIndex& index ) const\n{\n    if (index.column() == LogicalPortColumns::DIRECTION)\n    {\n        QComboBox* box = new QComboBox(parent);\n\n        QStringList list;\n        list.append(\"in\");\n        list.append(\"out\");\n        list.append(\"inout\");\n        box->addItems(list);\n\n        connect(box, SIGNAL(destroyed()), this, SLOT(commitAndCloseEditor()), Qt::UniqueConnection);\n        return box;\n    }\n    else if (index.column() == LogicalPortColumns::DRIVER)\n    {\n        QComboBox* box = new QComboBox(parent);\n\n        QStringList list;\n        list.append(QString(\"none\"));\n        list.append(QString(\"any\"));\n        list.append(QString(\"clock\"));\n        list.append(QString(\"singleShot\"));\n        box->addItems(list);\n\n        connect(box, SIGNAL(destroyed()), this, SLOT(commitAndCloseEditor()), Qt::UniqueConnection);\n        return box;\n    }\n    else\n    {\n        return AbstractionPortsDelegate::createEditor(parent, option, index);\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: AbstractionWirePortsDelegate::getQualifierList()\n//-----------------------------------------------------------------------------\nQStringList AbstractionWirePortsDelegate::getQualifierList() const\n{\n    QStringList qualifierList = AbstractionPortsDelegate::getQualifierList();\n    \n    // In 1685-2014 clock and reset are only for wires\n    if (stdRevision_ != Document::Revision::Std22)\n    {\n        qualifierList << QStringLiteral(\"clock\") << QStringLiteral(\"reset\");\n    }\n\n    return qualifierList;\n}\n\n//-----------------------------------------------------------------------------\n// Function: AbstractionWirePortsDelegate::editorIsComboBox()\n//-----------------------------------------------------------------------------\nbool AbstractionWirePortsDelegate::editorIsComboBox(int indexColumn) const\n{\n    return AbstractionPortsDelegate::editorIsComboBox(indexColumn) ||\n        indexColumn == LogicalPortColumns::DIRECTION || indexColumn == LogicalPortColumns::DRIVER;\n}\n\n//-----------------------------------------------------------------------------\n// Function: AbstractionWirePortsDelegate::columnAcceptsExpression()\n//-----------------------------------------------------------------------------\nbool AbstractionWirePortsDelegate::columnAcceptsExpression(int column) const\n{\n    return column == LogicalPortColumns::DEFAULT_VALUE || column == LogicalPortColumns::WIDTH;\n}\n"
  },
  {
    "path": "editors/AbstractionDefinitionEditor/AbstractionWirePortsDelegate.h",
    "content": "//-----------------------------------------------------------------------------\n// File: AbstractionWirePortsDelegate.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Antti Kamppi\n// Date: 27.6.2011\n//\n// Description:\n// The delegate that provides editors for logical port properties in Abstraction Definition.\n//-----------------------------------------------------------------------------\n\n#ifndef ABSTRACTIONWIREPORTSDELEGATE_H\n#define ABSTRACTIONWIREPORTSDELEGATE_H\n\n#include \"AbstractionPortsDelegate.h\"\n\n//-----------------------------------------------------------------------------\n//! The delegate that provides editors for logical port properties in Abstraction Definition.\n//-----------------------------------------------------------------------------\nclass AbstractionWirePortsDelegate : public AbstractionPortsDelegate\n{\n\tQ_OBJECT\n\npublic:\n\n\t/*!\n     *  The constructor.\n     * \n     *    @param [in] parametersModel The parameter completer model to use.\n     *    @param [in] parameterFinder The parameter finder to use.\n     *    @param [in] libraryAccess   Interface to the library.\n     *    @param [in] stdRevision     The standard revision used by the abstraction definition.\n     *    @param [in] parent          The owner of this instance\n     */\n    AbstractionWirePortsDelegate(QAbstractItemModel* parametersModel, QSharedPointer<ParameterFinder> parameterFinder,\n        LibraryInterface* libraryAccess, Document::Revision stdRevision, QObject *parent);\n\t\n\t/*!\n     *  The destructor.\n     */\n\tvirtual ~AbstractionWirePortsDelegate() = default;\n\n\t/*!\n     *  Create a new editor for the given item\n\t *\n\t *    @param [in] parent  Owner for the editor.\n\t *    @param [in] option  Contains options for the editor.\n\t *    @param [in] index   Model index identifying the item.\n\t *\n\t *    @return The editor to be used to edit the item.\n     */\n\tvirtual QWidget* createEditor(QWidget* parent, QStyleOptionViewItem const& option, QModelIndex const& index)\n        const;\n\n    //! No copying. No assignment.\n    AbstractionWirePortsDelegate(const AbstractionWirePortsDelegate& other) = delete;\n    AbstractionWirePortsDelegate& operator=(const AbstractionWirePortsDelegate& other) = delete;\n\nprotected:\n\n    /*!\n     *  Get the list of available qualifier values.\n     *\n     *    @return The list of available qualifier values.\n     */\n    QStringList getQualifierList() const override;\n\n    /*!\n     *  Check if the editor used in the selected index column is a combo box editor.\n     *\n     *    @param [in] indexColumn     The selected index column.\n     *\n     *    @return True, if the editor used in the selected column is a combo box editor, false otherwise.\n     */\n    virtual bool editorIsComboBox(int indexColumn) const;\n\t\nprivate:\n    \n    /*!\n     *  Checks if the given column supports expressions in the editor.\n     *\n     *    @param [in] column   The column to check.\n     *\n     *    @return True, if the cells in the column allow expressions, otherwise false.\n     */\n    bool columnAcceptsExpression(int column) const final;\n\n};\n\n#endif // ABSTRACTIONWIREPORTSDELEGATE_H\n"
  },
  {
    "path": "editors/AbstractionDefinitionEditor/AbstractionWirePortsSortFilter.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: AbstractionWirePortsSortFilter.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 27.11.2019\n//\n// Description:\n// Sort filter proxy model for abstraction definition wire ports.\n//-----------------------------------------------------------------------------\n\n#include \"AbstractionWirePortsSortFilter.h\"\n\n#include <editors/AbstractionDefinitionEditor/LogicalPortColumns.h>\n\n#include \"AbstractionPortsModel.h\"\n#include <KactusAPI/include/PortAbstractionInterface.h>\n\n//-----------------------------------------------------------------------------\n// Function: AbstractionWirePortsSortFilter::AbstractionWirePortsSortFilter()\n//-----------------------------------------------------------------------------\nAbstractionWirePortsSortFilter::AbstractionWirePortsSortFilter(PortAbstractionInterface* portInterface,\n    QObject *parent):\n    AbstractionDefinitionPortsSortFilter(portInterface, parent)\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: AbstractionWirePortsSortFilter::filterAcceptsRow()\n//-----------------------------------------------------------------------------\nbool AbstractionWirePortsSortFilter::filterAcceptsRow(int source_row, const QModelIndex &source_parent) const\n{\n    if (source_parent.isValid())\n    {\n        return false;\n    }\n\n    std::string portName = portInterface_->getIndexedItemName(source_row);\n    return portInterface_->portIsWire(portName);\n}\n"
  },
  {
    "path": "editors/AbstractionDefinitionEditor/AbstractionWirePortsSortFilter.h",
    "content": "//-----------------------------------------------------------------------------\n// File: AbstractionWirePortsSortFilter.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 27.11.2019\n//\n// Description:\n// Sort filter proxy model for abstraction definition wire ports.\n//-----------------------------------------------------------------------------\n\n#ifndef ABSTRACTIONWIREPORTSSORTFILTER_H\n#define ABSTRACTIONWIREPORTSSORTFILTER_H\n\n#include \"AbstractionDefinitionPortsSortFilter.h\"\n\n//-----------------------------------------------------------------------------\n//! Sort filter proxy model for abstraction definition wire ports.\n//-----------------------------------------------------------------------------\nclass AbstractionWirePortsSortFilter : public AbstractionDefinitionPortsSortFilter\n{\n\npublic:\n\n\t/*!\n\t *  The constructor.\n\t *\n     *    @param [in] parent      Pointer to the owner of this model.\n\t */\n    AbstractionWirePortsSortFilter(PortAbstractionInterface* portInterface, QObject *parent);\n\n\t/*!\n\t *  The destructor.\n\t */\n    virtual ~AbstractionWirePortsSortFilter() = default;\n\n    //! No copying. No assignment.\n    AbstractionWirePortsSortFilter(const AbstractionWirePortsSortFilter& other) = delete;\n    AbstractionWirePortsSortFilter& operator=(const AbstractionWirePortsSortFilter& other) = delete;\n\nprotected:\n\n    /*!\n     *  Check if the filter accepts the selected row.\n     *\n     *    @param [in] source_row      The selected row.\n     *    @param [in] source_parent   Parent index of the selected row.\n     *\n     *    @return True, if the row is accepted, false otherwise.\n     */\n    virtual bool filterAcceptsRow(int source_row, const QModelIndex &source_parent) const override final;\n\n};\n\n#endif // ABSTRACTIONWIREPORTSSORTFILTER_H\n"
  },
  {
    "path": "editors/AbstractionDefinitionEditor/LogicalPortColumns.h",
    "content": "//-----------------------------------------------------------------------------\n// File: LogicalPortColumns.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Esko Pekkarinen\n// Date: 19.08.2015\n//\n// Description:\n// Common definitions for abstraction definition logical port table.\n//-----------------------------------------------------------------------------\n\n#ifndef LOGICAL_PORT_COLUMNS\n#define LOGICAL_PORT_COLUMNS\n\nnamespace LogicalPortColumns\n{\n    //! Enumeration for columns in abstraction definition logical port table.\n    enum Columns\n    {\n        NAME = 0,\n        MODE,\n        PRESENCE,\n        DIRECTION,\n        INITIATIVE,\n        KIND,\n        WIDTH,\n        BUSWIDTH,\n        DEFAULT_VALUE,\n        DRIVER,\n        QUALIFIER,\n        MATCH,\n        SYSTEM_GROUP,\n        PROTOCOLTYPE,\n        PAYLOADNAME,\n        PAYLOADTYPE,\n        PAYLOADEXTENSION,\n        DESCRIPTION,\n        COLUMN_COUNT\n    };\n\n    enum class AbstractionType\n    {\n        WIRE,\n        TRANSACTIONAL\n    };\n}\n\n#endif // !LOGICAL_PORT_COLUMNS"
  },
  {
    "path": "editors/AbstractionDefinitionEditor/QualifierData.h",
    "content": "//-----------------------------------------------------------------------------\n// File: QualifierData.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Anton Hagqvist\n// Date: 26.06.2023\n//\n// Description:\n// Data structure containing 2022 standard Abstraction Definition qualifier data.\n//-----------------------------------------------------------------------------\n\n#ifndef QUALIFIERDATA_H\n#define QUALIFIERDATA_H\n\n#include <QStringList>\n#include <QMap>\n#include <QMetaType>\n\n//-----------------------------------------------------------------------------\n//! Data structure containing 2022 standard Abstraction Definition qualifier data.\n//-----------------------------------------------------------------------------\nstruct QualifierData\n{\n    //! The currently set qualifiers\n    QStringList activeQualifiers_;\n\n    //! The set qualifier attributes\n    QMap<QString, QString> attributes_;\n};\n\n//! Declare metatype for use in QVariant\nQ_DECLARE_METATYPE(QualifierData);\n\n#endif // QUALIFIERDATA_H"
  },
  {
    "path": "editors/AbstractionDefinitionEditor/QualifierEditor.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: QualifierEditor.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Anton Hagqvist\n// Date: 16.06.2023\n//\n// Description:\n// Editor for qualifiers in 2022 standard Abstraction Definition.\n//-----------------------------------------------------------------------------\n\n#include \"QualifierEditor.h\"\n\n#include <QHBoxLayout>\n#include <QVBoxLayout>\n#include <QFormLayout>\n#include <QScrollArea>\n#include <QScrollBar>\n#include <QPushButton>\n\n//-----------------------------------------------------------------------------\n// Function: QualifierEditor::QualifierEditor()\n//-----------------------------------------------------------------------------\nQualifierEditor::QualifierEditor(Document::Revision stdRevision, QWidget *parent) :\n    QFrame(parent),\n    qualifierAndAttributelayout_(new QGridLayout()),\n    powerDomainLineEdit_(new QLineEdit()),\n    userDefinedLineEdit_(new QLineEdit()),\n    resetLevelSelector_(new QComboBox()),\n    clockEnableLevelSelector_(new QComboBox()),\n    powerEnableLevelSelector_(new QComboBox()),\n    flowTypeSelector_(new QComboBox()),\n    stdRevision_(stdRevision)\n{\n    setFrameStyle(QFrame::StyledPanel);\n    setFocusPolicy(Qt::StrongFocus);\n    setAttribute(Qt::WA_NoMousePropagation);\n    setAutoFillBackground(true);\n\n    resetLevelSelector_->addItems({ QStringLiteral(\"\"), QStringLiteral(\"low\"), QStringLiteral(\"high\")});\n    clockEnableLevelSelector_->addItems({ QStringLiteral(\"\"), QStringLiteral(\"low\"), QStringLiteral(\"high\") });\n    powerEnableLevelSelector_->addItems({ QStringLiteral(\"\"), QStringLiteral(\"low\"), QStringLiteral(\"high\") });\n\n    flowTypeSelector_->setEditable(true);\n    flowTypeSelector_->setInsertPolicy(QComboBox::InsertAtTop);\n    flowTypeSelector_->addItems({\n        QStringLiteral(\"creditReturn\"),\n        QStringLiteral(\"ready\"),\n        QStringLiteral(\"busy\")\n    });\n\n    resetLevelSelector_->setToolTip(QStringLiteral(\"Reset level\"));\n    clockEnableLevelSelector_->setToolTip(QStringLiteral(\"Clock enable level\"));\n    powerEnableLevelSelector_->setToolTip(QStringLiteral(\"Power enable level\"));\n    flowTypeSelector_->setToolTip(QStringLiteral(\"Flow type\"));\n    userDefinedLineEdit_->setToolTip(QStringLiteral(\"User defined\"));\n\n    flowTypeSelector_->lineEdit()->setPlaceholderText(QStringLiteral(\"Flow type\"));\n    userDefinedLineEdit_->setPlaceholderText(QStringLiteral(\"User defined attribute\"));\n\n    setupLayout();\n}\n\n//-----------------------------------------------------------------------------\n// Function: QualifierEditor::setupEditor()\n//-----------------------------------------------------------------------------\nvoid QualifierEditor::setupEditor(QStringList const& qualifierOptions)\n{    \n    for (auto const& qualifier : qualifierOptions)\n    {\n        auto qualifierAsType = Qualifier::stringToType(qualifier);\n        auto attributeEditor = getAttributeEditor(qualifierAsType);\n\n        QCheckBox* qualifierBox = new QCheckBox(qualifier, this);\n        qualifierBoxes_.insert(qualifierAsType, qualifierBox);\n\n        connect(qualifierBox, SIGNAL(clicked(bool)), this, SLOT(onItemClicked(bool)), Qt::UniqueConnection);\n        \n        qualifierAndAttributelayout_->addWidget(qualifierBox, qualifierAndAttributelayout_->rowCount(), 0);\n\n        if (attributeEditor)\n        {\n            qualifierAndAttributelayout_->addWidget(attributeEditor, qualifierAndAttributelayout_->rowCount() - 1, 1);\n        }\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: QualifierEditor::setupEditorData()\n//-----------------------------------------------------------------------------\nvoid QualifierEditor::setupEditorData(QStringList const& activeQualifiers, QMap<QString, QString> const& attributes)\n{\n    for (auto const& qualifier : activeQualifiers)\n    {\n        auto qualifierAsType = Qualifier::stringToType(qualifier);\n\n        if (qualifierBoxes_.contains(qualifierAsType))\n        {\n            qualifierBoxes_[qualifierAsType]->setChecked(true);            \n            setQualifierAttributesVisible(qualifierAsType, true);\n        }\n    }\n\n    for (auto const& attributeName : attributes.keys())\n    {\n        setQualifierAttribute(Qualifier::stringToAttributeName(attributeName), attributes[attributeName]);\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: QualifierEditor::hideAllAttributes()\n//-----------------------------------------------------------------------------\nvoid QualifierEditor::hideAllAttributes()\n{\n    setQualifierAttributesVisible(Qualifier::Type::ClockEnable, false);\n    setQualifierAttributesVisible(Qualifier::Type::FlowControl, false);\n    setQualifierAttributesVisible(Qualifier::Type::PowerEnable, false);\n    setQualifierAttributesVisible(Qualifier::Type::Reset, false);\n    setQualifierAttributesVisible(Qualifier::Type::User, false);\n}\n\n//-----------------------------------------------------------------------------\n// Function: QualifierEditor::getSelectedItems()\n//-----------------------------------------------------------------------------\nQStringList QualifierEditor::getSelectedItems() const\n{\n    QStringList selected;\n    for (auto const& item : qualifierBoxes_)\n    {\n        if (item->isChecked())\n        {\n            selected.append(item->text());\n        }\n    }\n\n    return selected;\n}\n\n//-----------------------------------------------------------------------------\n// Function: QualifierEditor::getAttributes()\n//-----------------------------------------------------------------------------\nQMap<QString, QString> QualifierEditor::getAttributes() const\n{\n    QMap<QString, QString> attributes;\n\n    auto resetLevel = resetLevelSelector_->isVisible() ? resetLevelSelector_->currentText() : QString();\n    auto clockEnableLevel = clockEnableLevelSelector_->isVisible() ? clockEnableLevelSelector_->currentText() : QString();\n    auto powerEnableLevel = powerEnableLevelSelector_->isVisible() ? powerEnableLevelSelector_->currentText() : QString();\n\n    attributes.insert(QStringLiteral(\"resetLevel\"), resetLevel);\n    attributes.insert(QStringLiteral(\"clockEnableLevel\"), clockEnableLevel);\n    attributes.insert(QStringLiteral(\"powerEnableLevel\"), powerEnableLevel);\n    attributes.insert(QStringLiteral(\"powerDomainReference\"), powerDomainLineEdit_->text());\n    \n    if (QString const& flowTypeText = flowTypeSelector_->currentText(); flowTypeText.isEmpty())\n    {\n        attributes.insert(QStringLiteral(\"flowType\"), QString());\n        attributes.insert(QStringLiteral(\"userFlowType\"), QString());\n    }\n    else if (flowTypes_.contains(flowTypeText))\n    {\n        attributes.insert(QStringLiteral(\"flowType\"), flowTypeText);\n        attributes.insert(QStringLiteral(\"userFlowType\"), QString());\n    }\n    else\n    {\n        attributes.insert(QStringLiteral(\"flowType\"), QStringLiteral(\"user\"));\n        attributes.insert(QStringLiteral(\"userFlowType\"), flowTypeText);\n    }\n\n    attributes.insert(QStringLiteral(\"userDefined\"), userDefinedLineEdit_->text());\n    return attributes;\n}\n\n//-----------------------------------------------------------------------------\n// Function: QualifierEditor::getQualifierData()\n//-----------------------------------------------------------------------------\nQualifierData QualifierEditor::getQualifierData() const\n{\n    return QualifierData{ getSelectedItems(), getAttributes() };\n}\n\n//-----------------------------------------------------------------------------\n// Function: QualifierEditor::onItemClicked()\n//-----------------------------------------------------------------------------\nvoid QualifierEditor::onItemClicked(bool isChecked)\n{\n    QCheckBox* sender = qobject_cast<QCheckBox*>(QObject::sender());\n    if (!sender)\n    {\n        return;\n    }\n\n    if (stdRevision_ == Document::Revision::Std22)\n    {\n        auto qualifier = Qualifier::stringToType(sender->text());\n        setQualifierAttributesVisible(qualifier, isChecked);\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: QualifierEditor::setupLayout()\n//-----------------------------------------------------------------------------\nvoid QualifierEditor::setupLayout()\n{\n    QVBoxLayout* editorLayout = new QVBoxLayout(this);\n\n    QWidget* qualifiersAndAttributes = new QWidget();\n\n    QScrollArea* scrollingWidget = new QScrollArea();\n    scrollingWidget->setWidgetResizable(true);\n    scrollingWidget->setWidget(qualifiersAndAttributes);\n    scrollingWidget->setFrameShape(QFrame::NoFrame);\n    scrollingWidget->setContentsMargins(0, 0, 0, 0);\n    \n    QPushButton* okButton = new QPushButton();\n    okButton->setIcon(QIcon(\":/icons/common/graphics/checkMark.png\"));\n    okButton->setToolTip(\"Accept\");\n\n    QPushButton* cancelButton = new QPushButton();\n    cancelButton->setIcon(QIcon(\":/icons/common/graphics/grey_cross.png\"));\n    cancelButton->setToolTip(\"Cancel\");\n\n    connect(okButton, SIGNAL(clicked()), this, SIGNAL(finishEditing()), Qt::UniqueConnection);\n    connect(cancelButton, SIGNAL(clicked()), this, SIGNAL(cancelEditing()), Qt::UniqueConnection);\n\n    QHBoxLayout* buttonLayout = new QHBoxLayout();\n    buttonLayout->addStretch(10);\n    buttonLayout->addWidget(okButton);\n    buttonLayout->addWidget(cancelButton);\n\n    qualifiersAndAttributes->setLayout(qualifierAndAttributelayout_);\n    qualifiersAndAttributes->setContentsMargins(0, 0, 0, 0);\n    setMinimumHeight(sizeHint().height());\n    editorLayout->addWidget(scrollingWidget);\n    editorLayout->addLayout(buttonLayout, 0);\n}\n\n//-----------------------------------------------------------------------------\n// Function: QualifierEditor::setQualifierAttribute()\n//-----------------------------------------------------------------------------\nvoid QualifierEditor::setQualifierAttribute(Qualifier::Attribute attributeType, QString const& attributeValue)\n{\n    if (attributeType == Qualifier::Attribute::UserDefined)\n    {\n        userDefinedLineEdit_->setText(attributeValue);\n    }\n    else if (attributeType == Qualifier::Attribute::UserFlowType && !attributeValue.isEmpty())\n    {\n        flowTypeSelector_->setCurrentText(attributeValue); // Display user attribute when flow type is user.\n    }\n    else\n    {\n        QComboBox* editor = getAttributeEditor(attributeType);\n\n        if (editor)\n        {\n            editor->setCurrentText(attributeValue);\n        }\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: QualifierEditor::getAttributeEditor()\n//-----------------------------------------------------------------------------\nQComboBox* QualifierEditor::getAttributeEditor(Qualifier::Attribute attribute)\n{\n    if (attribute == Qualifier::Attribute::ResetLevel)\n    {\n        return resetLevelSelector_;\n    }\n    else if (attribute == Qualifier::Attribute::ClockEnableLevel)\n    {\n        return clockEnableLevelSelector_;\n    }\n    else if (attribute == Qualifier::Attribute::PowerEnableLevel)\n    {\n        return powerEnableLevelSelector_;\n    }\n    else if (attribute == Qualifier::Attribute::FlowType)\n    {\n        return flowTypeSelector_;\n    }\n    else\n    {\n        return nullptr;\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: QualifierEditor::getAttributeEditor()\n//-----------------------------------------------------------------------------\nQWidget* QualifierEditor::getAttributeEditor(Qualifier::Type qualifierType)\n{\n    if (qualifierType == Qualifier::Type::Reset)\n    {\n        return resetLevelSelector_;\n    }\n    else if (qualifierType == Qualifier::Type::ClockEnable)\n    {\n        return clockEnableLevelSelector_;\n    }\n    else if (qualifierType == Qualifier::Type::PowerEnable)\n    {\n        return powerEnableLevelSelector_;\n    }\n    else if (qualifierType == Qualifier::Type::FlowControl)\n    {\n        return flowTypeSelector_;\n    }\n    else if (qualifierType == Qualifier::Type::User)\n    {\n        return userDefinedLineEdit_;\n    }\n    else\n    {\n        return nullptr;\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: QualifierEditor::setQualifierAttributesVisible()\n//-----------------------------------------------------------------------------\nvoid QualifierEditor::setQualifierAttributesVisible(Qualifier::Type qualifier, bool visible)\n{\n    if (qualifier == Qualifier::Type::User)\n    {\n        userDefinedLineEdit_->setVisible(visible);\n\n        if (!visible)\n        {\n            userDefinedLineEdit_->setText(\"\");\n        }\n\n        return;\n    }\n\n    for (auto attribute : getQualifierTypeAttributes(qualifier))\n    {\n        QComboBox* editor = getAttributeEditor(attribute);\n            \n        if (editor)\n        {\n            editor->setVisible(visible);\n            if (!visible)\n            {\n                editor->setCurrentText(\"\");\n            }\n        }\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: QualifierEditor::getQualifierTypeAttributes()\n//-----------------------------------------------------------------------------\nQList<Qualifier::Attribute> QualifierEditor::getQualifierTypeAttributes(Qualifier::Type qualifier)\n{\n    QList<Qualifier::Attribute> qualifierTypeAttributes;\n\n    if (qualifier == Qualifier::Type::Reset)\n    {\n        qualifierTypeAttributes.append(Qualifier::Attribute::ResetLevel);\n    }\n    else if (qualifier == Qualifier::Type::ClockEnable)\n    {\n        qualifierTypeAttributes.append(Qualifier::Attribute::ClockEnableLevel);\n    }\n    else if (qualifier == Qualifier::Type::PowerEnable)\n    {\n        qualifierTypeAttributes.append(Qualifier::Attribute::PowerEnableLevel);\n        qualifierTypeAttributes.append(Qualifier::Attribute::PowerDomainReference);\n    }\n    else if (qualifier == Qualifier::Type::FlowControl)\n    {\n        qualifierTypeAttributes.append(Qualifier::Attribute::FlowType);\n        qualifierTypeAttributes.append(Qualifier::Attribute::UserFlowType);\n    }\n    else if (qualifier == Qualifier::Type::User)\n    {\n        qualifierTypeAttributes.append(Qualifier::Attribute::UserDefined);\n    }\n\n    return qualifierTypeAttributes;\n}\n"
  },
  {
    "path": "editors/AbstractionDefinitionEditor/QualifierEditor.h",
    "content": "//-----------------------------------------------------------------------------\n// File: QualifierEditor.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Anton Hagqvist\n// Date: 16.06.2023\n//\n// Description:\n// Editor for qualifiers in 2022 standard Abstraction Definition.\n//-----------------------------------------------------------------------------\n\n#ifndef QUALIFIEREDITOR_H\n#define QUALIFIEREDITOR_H\n\n#include \"QualifierData.h\"\n\n#include <IPXACTmodels/common/Qualifier.h>\n#include <IPXACTmodels/common/Document.h>\n\n#include <QLineEdit>\n#include <QFrame>\n#include <QLabel>\n#include <QComboBox>\n#include <QCheckBox>\n\nclass QGridLayout;\n\n//-----------------------------------------------------------------------------\n//! Editor for qualifiers in 2022 standard Abstraction Definition.\n//-----------------------------------------------------------------------------\nclass QualifierEditor : public QFrame\n{\n\tQ_OBJECT\n\npublic:\n\n\t/*!\n     *  The constructor.\n\t *\n     *    @param [in] stdRevision\t    The IP-XACT standard revision in use.\n     *    @param [in] parent          The owner of this instance\n     */\n\tQualifierEditor(Document::Revision stdRevision, QWidget *parent);\n\n\tvirtual ~QualifierEditor() = default;\n\n    //! No copying. No assignment.\n\tQualifierEditor(const QualifierEditor& other) = delete;\n\tQualifierEditor& operator=(const QualifierEditor& other) = delete;\n\n\t/*!\n\t *\tSetup the qualifier editor.\n\t *  \n\t *    @param [in] qualifierOptions\t\tList of all possible qualifiers.\n\t */\n\tvoid setupEditor(QStringList const& qualifierOptions);\n\t\n\t/*!\n\t *\tSet the editor data.\n\t *  \n\t *    @param [in] activeQualifiers  The qualifiers that should be set checked.\n\t *    @param [in] attributes\t      The qualifier attributes to set.\n\t */\n\tvoid setupEditorData(QStringList const& activeQualifiers, QMap<QString, QString> const& attributes);\n\n\t/*!\n\t *\tHide all attribute editors from the editor.\n\t */\n\tvoid hideAllAttributes();\n\n\t/*!\n\t *\tGet the qualifier data from the editor.\n\t *\n\t * \t\t@return A struct containing the qualifier data.\n\t */\n\tQualifierData getQualifierData() const;\n\nsignals:\n\n\t/*!\n\t *\tSignal emitted when the user has pressed the accept button.\n\t */\n\tvoid finishEditing();\n\n\t/*!\n\t *\tSignal emitted when user cancels editing by pressing cross.\n\t */\n\tvoid cancelEditing();\n\nprivate slots:\n\n\t/*!\n\t *\tUpdate attribute visibility when qualifier checkbox is toggled.\n\t *  \n\t *    @param [in] isChecked\tFlag indicating if checkbox was checked or not.\n\t */\n\tvoid onItemClicked(bool isChecked);\n\nprivate:\n\n\t/*!\n\t *\tGet the currently selected qualifiers.\n\t *\t\t\n\t * \t\t@return A list of currently selected qualifiers, as strings.\n\t */\n\tQStringList getSelectedItems() const;\n\n\t/*!\n\t *\tGet the currently set qualifier attributes.\n\t *\t\t\n\t * \t\t@return A map of attributes that have been set.\n\t */\n\tQMap<QString, QString> getAttributes() const;\n\n\t/*!\n\t *\tSetup the editor layout.\n\t */\n\tvoid setupLayout();\n\n\t/*!\n\t *\tSet a single attribute value to the corresponding editor.\n\t *  \n\t *    @param [in] attributeType\tThe attribute to set.\n\t *    @param [in] attributeValue\tThe value to set.\n\t */\n\tvoid setQualifierAttribute(Qualifier::Attribute attributeType, QString const& attributeValue);\n\n\t/*!\n\t *\tGet the editor for a given attribute.\n\t *  \n\t *    @param [in] attribute\tThe attribute whose editor to look for.\n\t *\t\t\n\t * \t\t@return A pointer to the corresponding editor, or nullptr if invalid attribute type.\n\t */\n\tQComboBox* getAttributeEditor(Qualifier::Attribute attribute);\n\n\t/*!\n\t *\tGet the attribute editor for a given qualifier type.\n\t *  \n\t *    @param [in] qualifierType     The qualfier type whose attribute editor to get.\n\t *\t    \n\t * \t    @return The attribute editor, or nullptr if not found.\n\t */\n\tQWidget* getAttributeEditor(Qualifier::Type qualifierType);\n\t\n\t/*!\n\t *\tSet the visibility for the attributes of a qualifier, based on if qualifier is set.\n\t *  \n\t *    @param [in] qualifier\tThe qualifier, whose attributes are shown/hidden.\n\t *    @param [in] visible\t\tFlag indicating if attributes should be shown or hidden.\n\t */\n\tvoid setQualifierAttributesVisible(Qualifier::Type qualifier, bool visible);\n\n    //-----------------------------------------------------------------------------\n\t// Data.\n\t//-----------------------------------------------------------------------------\n\n\t/*!\n\t *\tGet the attributes for a given qualifier.\n\t *  \n\t *    @param [in] qualifier\tThe qualifier.\n\t *\t\t\n\t * \t\t@return A list of attributes for a qualifier.\n\t */\n\tQList<Qualifier::Attribute> getQualifierTypeAttributes(Qualifier::Type qualifier);\n\n\t//! The qualifiers and attributes layout.\n\tQGridLayout* qualifierAndAttributelayout_;\n\n\t//! The editor for the power domain reference. Not used in absDef.\n    QLineEdit* powerDomainLineEdit_;\n\n\t//! The editor for a user defined attribute.\n    QLineEdit* userDefinedLineEdit_;\n\n\t//! Combo boxes for pre-set levels.\n\tQComboBox* resetLevelSelector_;\n\tQComboBox* clockEnableLevelSelector_;\n\tQComboBox* powerEnableLevelSelector_;\n\n\t//! Editable combobox for flow control flow type.\n\tQComboBox* flowTypeSelector_;\n\n\t//! Map of qualifier checkboxes and their associated type.\n\tQHash<Qualifier::Type, QCheckBox*> qualifierBoxes_;\n\n\t//! List of pre-set flow types. If flow type is not in this list,\n\t//  Then it will be set as user.\n\tconst QStringList flowTypes_ = {\n\t\tQStringLiteral(\"creditReturn\"),\n\t\tQStringLiteral(\"ready\"),\n\t\tQStringLiteral(\"busy\")\n\t};\n\n\t//! The IP-XACT standard revision in use.\n\tDocument::Revision stdRevision_;\n};\n\n#endif // QUALIFIEREDITOR_H\n"
  },
  {
    "path": "editors/AbstractionDefinitionEditor/absdefgroup.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: absdefgroup.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Antti Kamppi\n// Date: 15.8.2011\n//\n// Description:\n// Editor for the logical ports of an abstraction definition.\n//-----------------------------------------------------------------------------\n\n#include \"absdefgroup.h\"\n\n#include <IPXACTmodels/BusDefinition/BusDefinition.h>\n#include <IPXACTmodels/AbstractionDefinition/PortAbstraction.h>\n\n#include <IPXACTmodels/utilities/BusDefinitionUtils.h>\n#include <KactusAPI/include/PortAbstractionInterface.h>\n\n#include <KactusAPI/include/ParameterFinder.h>\n#include <KactusAPI/include/ExpressionFormatter.h>\n#include <KactusAPI/include/ExpressionParser.h>\n#include <KactusAPI/include/AbstractParameterInterface.h>\n\n#include <common/widgets/vlnvDisplayer/vlnvdisplayer.h>\n#include <common/widgets/vlnvEditor/vlnveditor.h>\n#include <common/widgets/ParameterGroupBox/parametergroupbox.h>\n\n#include <editors/common/DocumentNameGroupEditor.h>\n#include <editors/ComponentEditor/parameters/ComponentParameterModel.h>\n\n#include \"AbstractionDefinitionPortsSortFilter.h\"\n#include \"AbstractionPortsModel.h\"\n#include \"LogicalPortColumns.h\"\n\n#include <KactusAPI/include/LibraryInterface.h>\n\n#include <QSortFilterProxyModel>\n#include <QVBoxLayout>\n#include <QSplitter>\n\n//-----------------------------------------------------------------------------\n// Function: AbsDefGroup::AbsDefGroup()\n//-----------------------------------------------------------------------------\nAbsDefGroup::AbsDefGroup(Document::Revision revision, QSharedPointer<AbstractionDefinition> absDef,\n    QSharedPointer<ExpressionFormatter> expressionFormatter, QSharedPointer<ExpressionParser> expressionParser,\n    QSharedPointer<ParameterFinder> parameterFinder, LibraryInterface* libraryHandler,\n    PortAbstractionInterface* portInterface, PortAbstractionInterface* extendInterface, QWidget* parent) :\nQWidget(parent),\ndocumentNameGroupEditor_(new DocumentNameGroupEditor(this)),\nextendEditor_(new VLNVEditor(VLNV::ABSTRACTIONDEFINITION, libraryHandler, this, this)),\nbusDisplay_(new VLNVDisplayer(this, VLNV())),\nportTabs_(this),\nportInterface_(portInterface),\nextendInterface_(extendInterface),\nparameterEditor_(new ParameterGroupBox(absDef->getParameters(), absDef->getChoices(), parameterFinder,\n    expressionFormatter, absDef->getRevision(), this)),\nparameterCompleter_(new ComponentParameterModel(parameterFinder, this)),\nportModel_(new AbstractionPortsModel(parameterFinder, expressionParser, libraryHandler, portInterface, \n    extendInterface, this)),\nwirePortsEditor_(new AbstractionPortsEditor(parameterCompleter_, parameterFinder, libraryHandler, \n    portInterface, revision, portModel_, LogicalPortColumns::AbstractionType::WIRE, &portTabs_)),\ntransactionalPortsEditor_(new AbstractionPortsEditor(parameterCompleter_, parameterFinder, libraryHandler, \n    portInterface, revision, portModel_, LogicalPortColumns::AbstractionType::TRANSACTIONAL, &portTabs_)),\nabstraction_(absDef),\nlibraryHandler_(libraryHandler)\n{\n    portInterface_->setAbsDef(abstraction_);\n\n    documentNameGroupEditor_->setTitle(QStringLiteral(\"Abstraction definition\"));\n    extendEditor_->setTitle(tr(\"Extended abstraction definition\"));\n    extendEditor_->setMandatory(false);\n    extendEditor_->setRevisionFilter(true, revision);\n\n    busDisplay_->setTitle(QStringLiteral(\"Bus Type\"));\n\n    portTabs_.addTab(wirePortsEditor_, QStringLiteral(\"Wire ports\"));\n    portTabs_.addTab(transactionalPortsEditor_, QStringLiteral(\"Transactional ports\"));\n\n    connect(parameterEditor_, SIGNAL(increaseReferences(QString)),\n        this, SIGNAL(increaseReferences(QString)), Qt::UniqueConnection);\n    connect(parameterEditor_, SIGNAL(decreaseReferences(QString)),\n        this, SIGNAL(decreaseReferences(QString)), Qt::UniqueConnection);\n    connect(parameterEditor_, SIGNAL(openReferenceTree(QString const&, QString const&)),\n        this, SIGNAL(openReferenceTree(QString const&, QString const&)), Qt::UniqueConnection);\n    connect(parameterEditor_, SIGNAL(contentChanged()), this, SIGNAL(contentChanged()), Qt::UniqueConnection);\n    connect(parameterEditor_,\n        SIGNAL(recalculateReferencesToParameters(QVector<QString> const&, AbstractParameterInterface*)),\n        this,\n        SIGNAL(recalculateReferencesToParameters(QVector<QString> const&, AbstractParameterInterface*)),\n        Qt::UniqueConnection);\n\n    connect(wirePortsEditor_, SIGNAL(contentChanged()), this, SIGNAL(contentChanged()), Qt::UniqueConnection);\n    connect(wirePortsEditor_, SIGNAL(noticeMessage(const QString&)),\n        this, SIGNAL(noticeMessage(const QString&)), Qt::UniqueConnection);\n    connect(wirePortsEditor_, SIGNAL(errorMessage(const QString&)),\n        this, SIGNAL(errorMessage(const QString&)), Qt::UniqueConnection);\n    connect(wirePortsEditor_, SIGNAL(portRemoved(const QString&, const General::InterfaceMode)),\n        this, SIGNAL(portRemoved(const QString&, const General::InterfaceMode)), Qt::UniqueConnection);\n    connect(wirePortsEditor_, SIGNAL(increaseReferences(QString)),\n        this, SIGNAL(increaseReferences(QString)), Qt::UniqueConnection);\n    connect(wirePortsEditor_, SIGNAL(decreaseReferences(QString)),\n        this, SIGNAL(decreaseReferences(QString)), Qt::UniqueConnection);\n\n    connect(transactionalPortsEditor_, SIGNAL(contentChanged()),\n        this, SIGNAL(contentChanged()), Qt::UniqueConnection);\n    connect(transactionalPortsEditor_, SIGNAL(noticeMessage(const QString&)),\n        this, SIGNAL(noticeMessage(const QString&)), Qt::UniqueConnection);\n    connect(transactionalPortsEditor_, SIGNAL(errorMessage(const QString&)),\n        this, SIGNAL(errorMessage(const QString&)), Qt::UniqueConnection);\n    connect(transactionalPortsEditor_, SIGNAL(portRemoved(const QString&, const General::InterfaceMode)),\n        this, SIGNAL(portRemoved(const QString&, const General::InterfaceMode)), Qt::UniqueConnection);\n    connect(transactionalPortsEditor_, SIGNAL(increaseReferences(QString)),\n        this, SIGNAL(increaseReferences(QString)), Qt::UniqueConnection);\n    connect(transactionalPortsEditor_, SIGNAL(decreaseReferences(QString)),\n        this, SIGNAL(decreaseReferences(QString)), Qt::UniqueConnection);\n\n    connect(documentNameGroupEditor_, SIGNAL(contentChanged()), this, SIGNAL(contentChanged()), Qt::UniqueConnection);\n\n    connect(extendEditor_, SIGNAL(vlnvEdited()), this, SLOT(onExtendChanged()), Qt::UniqueConnection);\n\n\tsetupLayout();\n}\n\n//-----------------------------------------------------------------------------\n// Function: AbsDefGroup::save()\n//-----------------------------------------------------------------------------\nvoid AbsDefGroup::save()\n{\n    portInterface_->save();\n}\n\n//-----------------------------------------------------------------------------\n// Function: AbsDefGroup::setAbsDef()\n//-----------------------------------------------------------------------------\nvoid AbsDefGroup::setAbsDef(QSharedPointer<AbstractionDefinition> absDef)\n{\n    abstraction_ = absDef;\n\n    portInterface_->setAbsDef(abstraction_);\n    parameterEditor_->setNewParameters(abstraction_->getParameters(), abstraction_->getChoices(), \n        abstraction_->getRevision());\n\n    auto busDefinition = libraryHandler_->getModel<BusDefinition>(absDef->getBusType());\n\n    wirePortsEditor_->setBusDef(busDefinition);\n    transactionalPortsEditor_->setBusDef(busDefinition);\n\n    wirePortsEditor_->resetPortModel();\n    transactionalPortsEditor_->resetPortModel();\n\n    documentNameGroupEditor_->setDocumentNameGroup(absDef, libraryHandler_->getPath(absDef->getVlnv()));\n\n    extendEditor_->setVLNV(absDef->getExtends());\n    extendEditor_->setRevisionFilter(true, absDef->getRevision());\n\n    busDisplay_->setVLNV(absDef->getBusType());\n\n    if (abstractionContainsTransactionalPorts())\n    {\n        portTabs_.setCurrentWidget(transactionalPortsEditor_);\n    }\n\n    if (absDef->getExtends().isValid())\n    {\n        setupExtendedAbstraction();\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: absdefgroup::abstractionContainsTransactionalPorts()\n//-----------------------------------------------------------------------------\nbool AbsDefGroup::abstractionContainsTransactionalPorts() const\n{\n    return std::any_of(abstraction_->getLogicalPorts()->cbegin(), abstraction_->getLogicalPorts()->cend(), \n        [](auto const& logicalPort) {return logicalPort->hasTransactional();});\n}\n\n//-----------------------------------------------------------------------------\n// Function: absdefgroup::onExtendChanged()\n//-----------------------------------------------------------------------------\nvoid AbsDefGroup::onExtendChanged()\n{\n    removeSignalsFromExtendedDefinition();\n\n    abstraction_->setExtends(extendEditor_->getVLNV());\n    setupExtendedAbstraction();\n\n    emit contentChanged();\n}\n\n//-----------------------------------------------------------------------------\n// Function: absdefgroup::setupExtendedAbstraction()\n//-----------------------------------------------------------------------------\nvoid AbsDefGroup::setupExtendedAbstraction()\n{\n    QSharedPointer<const AbstractionDefinition> extendedAbstraction = getExtendedAbstraction();\n    extendInterface_->setAbsDef(extendedAbstraction);\n    QString extendDescription = \"\";\n    if (extendedAbstraction)\n    {\n        extendDescription = extendedAbstraction->getDescription();\n\n        if (extendedAbstraction->getLogicalPorts() && !extendedAbstraction->getLogicalPorts()->isEmpty())\n        {\n            extendSignals(extendedAbstraction);\n        }\n    }\n\n    documentNameGroupEditor_->setPlaceholderDescription(extendDescription);\n}\n\n//-----------------------------------------------------------------------------\n// Function: absdefgroup::getExtendedAbstraction()\n//-----------------------------------------------------------------------------\nQSharedPointer<const AbstractionDefinition> AbsDefGroup::getExtendedAbstraction() const\n{\n    VLNV extendedVLNV = abstraction_->getExtends();\n    if (extendedVLNV.isValid() && extendedVLNV.getType() == VLNV::ABSTRACTIONDEFINITION)\n    {\n        QSharedPointer<const Document> extendedDocument = libraryHandler_->getModelReadOnly(extendedVLNV);\n        if (extendedDocument)\n        {\n            QSharedPointer<const AbstractionDefinition> extendAbstraction =\n                extendedDocument.dynamicCast<const AbstractionDefinition>();\n            if (extendAbstraction)\n            {\n                return extendAbstraction;\n            }\n        }\n    }\n\n    return QSharedPointer<const AbstractionDefinition>();\n}\n\n//-----------------------------------------------------------------------------\n// Function: absdefgroup::extendSignals()\n//-----------------------------------------------------------------------------\nvoid AbsDefGroup::extendSignals(QSharedPointer<const AbstractionDefinition> /*extendAbstraction*/)\n{\n    portModel_->setExtendedPorts();\n}\n\n//-----------------------------------------------------------------------------\n// Function: absdefgroup::removeSignalsFromExtendedDefinition()\n//-----------------------------------------------------------------------------\nvoid AbsDefGroup::removeSignalsFromExtendedDefinition()\n{\n    if (abstraction_->getExtends() != extendEditor_->getVLNV() || extendEditor_->getVLNV().isEmpty())\n    {\n        QSharedPointer<const AbstractionDefinition> extendedAbstraction = getExtendedAbstraction();\n        if (extendedAbstraction || extendEditor_->getVLNV().isEmpty())\n        {\n            portModel_->removeExtendedPorts();\n        }\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: AbsDefGroup::setupLayout()\n//-----------------------------------------------------------------------------\nvoid AbsDefGroup::setupLayout()\n{\n    QVBoxLayout* documentNameGroupLayout = new QVBoxLayout();\n    documentNameGroupLayout->addWidget(documentNameGroupEditor_);\n\n    QGridLayout* topLayout = new QGridLayout(this);\n    topLayout->addWidget(extendEditor_, 0, 1, 1, 1);\n    topLayout->addWidget(documentNameGroupEditor_, 0, 0, 2, 1);\n    topLayout->addWidget(busDisplay_, 1, 1, 1, 1);\n\n    QSplitter* splitter = new QSplitter(Qt::Vertical);\n    splitter->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);\n    splitter->addWidget(&portTabs_);\n    splitter->addWidget(parameterEditor_);\n\n    QSplitterHandle* handle = splitter->handle(1);\n    QVBoxLayout* handleLayout = new QVBoxLayout(handle);\n    handleLayout->setSpacing(0);\n    handleLayout->setContentsMargins(0, 0, 0, 0);\n\n    QFrame* line = new QFrame(handle);\n    line->setLineWidth(2);\n    line->setMidLineWidth(2);\n    line->setFrameShape(QFrame::HLine);\n    line->setFrameShadow(QFrame::Sunken);\n    handleLayout->addWidget(line);\n    \n    splitter->setStyleSheet(QStringLiteral(\"QSplitter::handle { background: white }\"));\n    splitter->setHandleWidth(18);\n\n    topLayout->addWidget(splitter, 2, 0, 1, 2);\n\n    topLayout->setColumnStretch(0, 1);\n    topLayout->setColumnStretch(1, 1);\n\n    topLayout->setRowStretch(0, 1);\n    topLayout->setRowStretch(1, 1);\n    topLayout->setRowStretch(2, 4);\n}\n"
  },
  {
    "path": "editors/AbstractionDefinitionEditor/absdefgroup.h",
    "content": "//-----------------------------------------------------------------------------\n// File: absdefgroup.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Antti Kamppi\n// Date: 15.8.2011\n//\n// Description:\n// Editor for the logical ports of an abstraction definition.\n//-----------------------------------------------------------------------------\n\n#ifndef ABSDEFGROUP_H\n#define ABSDEFGROUP_H\n\n#include \"AbstractionPortsEditor.h\"\n\n#include <IPXACTmodels/AbstractionDefinition/AbstractionDefinition.h>\n\n#include <QWidget>\n#include <QPushButton>\n#include <QSharedPointer>\n#include <QSortFilterProxyModel>\n#include <QPlainTextEdit>\n#include <QModelIndexList>\n#include <QTabWidget>\n\nclass VLNVDisplayer;\nclass VLNVEditor;\nclass LibraryInterface;\nclass AbstractionDefinitionPortsSortFilter;\nclass PortAbstractionInterface;\nclass DocumentNameGroupEditor;\nclass ParameterGroupBox;\nclass ExpressionFormatter;\nclass ExpressionParser;\nclass ParameterFinder;\nclass AbstractParameterInterface;\nclass ComponentParameterModel;\n\n//-----------------------------------------------------------------------------\n//! Editor for the logical ports of an abstraction definition.\n//-----------------------------------------------------------------------------\nclass AbsDefGroup : public QWidget\n{\n\tQ_OBJECT\n\npublic:\n\n\t/*!\n     *  The constructor.\n\t *\n     *    @param [in] revision            Currently active IP-XACT revision.\n     *    @param [in] absDef              The abstraction definition.\n     *    @param [in] expressionFormatter The expression formatter to use.\n     *    @param [in] expressionParser    The expression parser to use.\n     *    @param [in] parameterFinder     The parameter finder to use.\n     *    @param [in] libraryHandler      Allows access to the library.\n     *    @param [in] portInterface       Interface for accssing port abstractions.\n     *    @param [in] extendInterface     Interface for accssing extend port abstractions.\n\t *    @param [in] parent              The owner of the editor.\n\t */\n    AbsDefGroup(Document::Revision revision, QSharedPointer<AbstractionDefinition> absDef,\n        QSharedPointer<ExpressionFormatter> expressionFormatter, QSharedPointer<ExpressionParser> expressionParser, \n        QSharedPointer<ParameterFinder> parameterFinder, LibraryInterface* libraryHandler, \n        PortAbstractionInterface* portInterface, PortAbstractionInterface* extendInterface, QWidget* parent);\n\n\t/*!\n     *  The destructor.\n     */\n\t~AbsDefGroup() override = default;\n\n    //! No copying. No assignment.\n    AbsDefGroup(const AbsDefGroup& other) = delete;\n    AbsDefGroup& operator=(const AbsDefGroup& other) = delete;\n\n\t/*!\n     *  Saves the changes made in the editor.\n     */\n\tvoid save();\n\n\t/*!\n     *  Set the abstraction definition for the editor.\n\t *\n\t *    @param [in] absDef  The Abstraction definition to edit.\n     */\n\tvoid setAbsDef(QSharedPointer<AbstractionDefinition> absDef);\n    \n\nsignals:\n\n\t/*!\n     *  Emitted when contents of this editor changes.\n     */\n\tvoid contentChanged();\n\n\t/*!\n     *  Emitted when an error should be printed to user.\n     */\n\tvoid errorMessage(QString const& message);\n\n\t/*!\n     *  Emitted when a notification should be printed to user.\n     */\n\tvoid noticeMessage(QString const& message);\n\n    /*!\n     *  Inform that a port abstraction has been removed.\n     *\n     *    @param [in] portName    Name of the removed port abstraction.\n     *    @param [in] mode        Mode of the removed port abstraction.\n     */\n    void portRemoved(QString const& portName, General::InterfaceMode const mode);\n\n    /*!\n     *  Increase the amount of references to the parameter corresponding to the id.\n     *\n     *    @param [in] id      The id of the parameter being searched for.\n     */\n    void increaseReferences(QString id);\n\n    /*!\n     *  Decrease the amount of references to the parameter corresponding to the id.\n     *\n     *    @param [in] id      The id of the parameter being searched for.\n     */\n    void decreaseReferences(QString id);\n\n    /*!\n     *  Recalculate references made to the selected parameters.\n     *\n     *    @param [in] parameterList       The selected parameters.\n     *    @param [in] parameterInterface  Interface for accessing parameters.\n     */\n    void recalculateReferencesToParameters(QStringList const& parameterList,\n        AbstractParameterInterface* parameterInterface);\n\n    /*!\n     *  Open the reference tree of the parameter with the id.\n     *\n     *    @param [in] id              The id of the parameter.\n     *    @param [in] parameterName   Name of the selected parameter.\n     */\n    void openReferenceTree(QString const& id, QString const& parameterName);\n\nprivate slots:\n\n    /*!\n     *  Handle the change in abstraction definition extend.\n     */\n    void onExtendChanged();\n\nprivate:\n    \n    /*!\n     *  Check if the abstraction definition contains transactional ports.\n     *\n     *    @return True, if the abstraction definition contains any transactional ports.\n     */\n    bool abstractionContainsTransactionalPorts() const;\n\n    /*!\n     *  Setup the extended abstraction definition.\n     */\n    void setupExtendedAbstraction();\n\n    /*!\n     *  Get the extended abstraction definition.\n     *\n     *    @return The extended abstraction definition.\n     */\n    QSharedPointer<const AbstractionDefinition> getExtendedAbstraction() const;\n\n    /*!\n     *  Remove extend port abstractions.\n     */\n    void removeSignalsFromExtendedDefinition();\n\n    /*!\n     *  Extend the contained signals.\n     *\n     *    @param [in] extendAbstraction  The extended abstraction definition.\n     */\n    void extendSignals(QSharedPointer<const AbstractionDefinition> extendAbstraction);\n\n    /*!\n     *  Sets the editor layout.\n     */\n    void setupLayout();\n\n    //-----------------------------------------------------------------------------\n    // Data.\n    //-----------------------------------------------------------------------------\n\n    //! Editor for abstraction definition document name group\n    DocumentNameGroupEditor* documentNameGroupEditor_;\n\n    //! Editor for the abstraction definition extend.\n    VLNVEditor* extendEditor_;\n\n    //! Displays the VLNV of the referenced bus definition.\n    VLNVDisplayer* busDisplay_;\n\n    //! Contains tabs for wire and transactional ports.\n    QTabWidget portTabs_;\n\n    //! Interface for accessing port abstractions.\n    PortAbstractionInterface* portInterface_;\n\n    //! Interface for accessing extened port abstractions.\n    PortAbstractionInterface* extendInterface_;\n\n    //! The abstraction definition parameters editor.\n    ParameterGroupBox* parameterEditor_;\n\n    //! The parameter completer model to use.\n    ComponentParameterModel* parameterCompleter_;\n\n    //! The abstraction definition ports model.\n    AbstractionPortsModel* portModel_;\n \n    //! Editor for wire ports.\n    AbstractionPortsEditor* wirePortsEditor_;\n\n    //! Editor for transactional ports.\n    AbstractionPortsEditor* transactionalPortsEditor_;\n\n    //! The edited abstraction definition.\n    QSharedPointer<AbstractionDefinition> abstraction_;\n\n    //! The library interface.\n    LibraryInterface* libraryHandler_;\n};\n\n#endif // ABSDEFGROUP_H\n"
  },
  {
    "path": "editors/ApiDefinitionEditor/ApiDefinitionEditor.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ApiDefinitionEditor.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Joni-Matti Maatta\r\n// Date: 18.4.2012\r\n//\r\n// Description:\r\n// Editor for API definitions.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"ApiDefinitionEditor.h\"\r\n\r\n#include <common/dialogs/newObjectDialog/newobjectdialog.h>\r\n\r\n#include <IPXACTmodels/kactusExtensions/ComDefinition.h>\r\n#include <IPXACTmodels/kactusExtensions/ApiDefinition.h>\r\n#include <IPXACTmodels/kactusExtensions/validators/ApiDefinitionValidator.h>\r\n\r\n#include <QGridLayout>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ApiDefinitionEditor::ApiDefinitionEditor()\r\n//-----------------------------------------------------------------------------\r\nApiDefinitionEditor::ApiDefinitionEditor(QWidget *parent, LibraryInterface* libHandler,\r\n    QSharedPointer<ApiDefinition> apiDef) :\r\n    TabDocument(parent, libHandler, DOC_PROTECTION_SUPPORT),\r\n    nameGroup_(this),\r\n    apiDef_(apiDef),\r\n    comDefVLNVEdit_(VLNV::COMDEFINITION, libHandler, parent, this),\r\n    dataTypeList_(tr(\"Data types\"), this),\r\n    functionEditor_(this)\r\n{\r\n    // Initialize the editors.\r\n    nameGroup_.setTitle(tr(\"API definition\"));\r\n    nameGroup_.setDocumentNameGroup(apiDef_, getLibHandler()->getPath(apiDef_->getVlnv()));\r\n    nameGroup_.setFlat(true);\r\n    dataTypeList_.initialize(*apiDef->getDataTypes());\r\n\r\n    functionEditor_.updateDataTypes(*apiDef->getDataTypes());\r\n    functionEditor_.restore(*apiDef);\r\n    functionEditor_.setFlat(true);\r\n\r\n    comDefVLNVEdit_.setTitle(tr(\"COM definition reference\"));\r\n    comDefVLNVEdit_.setVLNV(apiDef->getComDefinitionRef());\r\n    comDefVLNVEdit_.setFlat(true);\r\n    comDefVLNVEdit_.setRevisionFilter(true, apiDef->getRevision());\r\n    updateComDefinition();\r\n\r\n    connect(&nameGroup_, SIGNAL(contentChanged()), this, SIGNAL(contentChanged()), Qt::UniqueConnection);\r\n    connect(&dataTypeList_, SIGNAL(contentChanged()), this, SIGNAL(contentChanged()), Qt::UniqueConnection);\r\n    connect(&dataTypeList_, SIGNAL(contentChanged()), this, SLOT(updateDataTypeLists()), Qt::UniqueConnection);\r\n    connect(&comDefVLNVEdit_, SIGNAL(contentChanged()), this, SIGNAL(contentChanged()), Qt::UniqueConnection);\r\n    connect(&comDefVLNVEdit_, SIGNAL(contentChanged()), this, SLOT(updateComDefinition()), Qt::UniqueConnection);\r\n    connect(&functionEditor_, SIGNAL(contentChanged()), this, SIGNAL(contentChanged()), Qt::UniqueConnection);\r\n\r\n    // Setup the layout.\r\n    auto layout = new QGridLayout(this);\r\n    layout->addWidget(&nameGroup_, 0, 0, 2, 1);\r\n    layout->addWidget(&dataTypeList_, 1, 1, 1, 1);\r\n    layout->addWidget(&comDefVLNVEdit_, 0, 1, 1, 1, Qt::AlignTop);\r\n    layout->addWidget(&functionEditor_, 2, 0, 1, 2);\r\n\r\n\r\n    layout->setRowStretch(0, 1);\r\n    layout->setRowStretch(1, 3);\r\n\r\n    setModified(false);\r\n\r\n    // Set the document name and type.\r\n    VLNV vlnv = apiDef_->getVlnv();\r\n    setDocumentName(vlnv.getName() + \" (\" + vlnv.getVersion() + \")\");\r\n    setDocumentType(DocumentType::API_DEFINITION);\r\n\r\n    // Open in unlocked mode by default only if the version is draft.\r\n    setProtection(vlnv.getVersion() != \"draft\");\r\n}\r\n\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ApiDefinitionEditor::setProtection()\r\n//-----------------------------------------------------------------------------\r\nvoid ApiDefinitionEditor::setProtection(bool locked)\r\n{\r\n    TabDocument::setProtection(locked);\r\n    setEnabled(!locked);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ApiDefinitionEditor::refresh()\r\n//-----------------------------------------------------------------------------\r\nvoid ApiDefinitionEditor::refresh()\r\n{\r\n    QSharedPointer<Document> libComp = getLibHandler()->getModel(apiDef_->getVlnv());\r\n    apiDef_ = libComp.staticCast<ApiDefinition>();\r\n\r\n    // Update the editors.\r\n    nameGroup_.setDocumentNameGroup(apiDef_, getLibHandler()->getPath(apiDef_->getVlnv()));\r\n    comDefVLNVEdit_.setVLNV(apiDef_->getComDefinitionRef());\r\n    dataTypeList_.initialize(*apiDef_->getDataTypes());\r\n    functionEditor_.restore(*apiDef_);\r\n\r\n    setModified(false);\r\n    TabDocument::refresh();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ApiDefinitionEditor::getDocumentVLNV()\r\n//-----------------------------------------------------------------------------\r\nVLNV ApiDefinitionEditor::getDocumentVLNV() const\r\n{\r\n    return apiDef_->getVlnv();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ApiDefinitionEditor::validate()\r\n//-----------------------------------------------------------------------------\r\nbool ApiDefinitionEditor::validate(QVector<QString>& errorList)\r\n{\r\n    applyChanges();\r\n\r\n\tApiDefinitionValidator validator;\r\n    validator.findErrorsIn( errorList, apiDef_ );\r\n\r\n    return errorList.isEmpty();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ApiDefinitionEditor::save()\r\n//-----------------------------------------------------------------------------\r\nbool ApiDefinitionEditor::save()\r\n{\r\n    applyChanges();\r\n    getLibHandler()->writeModelToFile(apiDef_);\r\n\r\n    return TabDocument::save();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ApiDefinitionEditor::saveAs()\r\n//-----------------------------------------------------------------------------\r\nbool ApiDefinitionEditor::saveAs()\r\n{\r\n    // Ask the user for a new VLNV and directory.\r\n    VLNV vlnv;\r\n    QString directory;\r\n\r\n    if (!NewObjectDialog::saveAsDialog(parentWidget(), getLibHandler(), apiDef_->getVlnv(), vlnv, directory))\r\n    {\r\n        return false;\r\n    }\r\n\r\n    // Create a copy of the object and update its VLNV.\r\n    apiDef_ = QSharedPointer<ApiDefinition>(new ApiDefinition(*apiDef_));\r\n\r\n    vlnv.setType(VLNV::APIDEFINITION);\r\n    apiDef_->setVlnv(vlnv);\r\n\r\n    // Apply changes to the copy.\r\n    applyChanges();\r\n\r\n    if (getLibHandler()->writeModelToFile(directory, apiDef_))\r\n    {\r\n        setDocumentName(vlnv.getName() + \" (\" + vlnv.getVersion() + \")\");\r\n        return TabDocument::saveAs();\r\n    }\r\n    else\r\n    {\r\n        return false;\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ApiDefinitionEditor::updateDataTypeLists()\r\n//-----------------------------------------------------------------------------\r\nvoid ApiDefinitionEditor::updateDataTypeLists()\r\n{\r\n    functionEditor_.updateDataTypes(dataTypeList_.items());\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ApiDefinitionEditor::applyChanges()\r\n//-----------------------------------------------------------------------------\r\nvoid ApiDefinitionEditor::applyChanges()\r\n{\r\n    apiDef_->setComDefinitionRef(comDefVLNVEdit_.getVLNV());\r\n    apiDef_->setDataTypes(dataTypeList_.items());\r\n    functionEditor_.save(*apiDef_);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ApiDefinitionEditor::updateComDefinition()\r\n//-----------------------------------------------------------------------------\r\nvoid ApiDefinitionEditor::updateComDefinition()\r\n{\r\n    VLNV vlnv = comDefVLNVEdit_.getVLNV();\r\n\r\n    // Retrieve the new COM definition if the VLNV is valid.\r\n    if (vlnv.isValid())\r\n    {\r\n        QSharedPointer<Document const> libComp = getLibHandler()->getModelReadOnly(vlnv);\r\n        QSharedPointer<ComDefinition const> comDef = libComp.dynamicCast<ComDefinition const>();\r\n        functionEditor_.setComDefinition(comDef);\r\n    }\r\n    else\r\n    {\r\n        functionEditor_.setComDefinition(QSharedPointer<ComDefinition const>());\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ApiDefinitionEditor::showEvent()\r\n//-----------------------------------------------------------------------------\r\nvoid ApiDefinitionEditor::showEvent(QShowEvent* event)\r\n{\r\n    TabDocument::showEvent(event);\r\n    emit helpUrlRequested(\"definitions/apidefinition.html\");\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ApiDefinitionEditor::getIdentifyingVLNV()\r\n//-----------------------------------------------------------------------------\r\nVLNV ApiDefinitionEditor::getIdentifyingVLNV() const\r\n{\r\n\treturn getDocumentVLNV();\r\n}\r\n\r\n"
  },
  {
    "path": "editors/ApiDefinitionEditor/ApiDefinitionEditor.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ApiDefinitionEditor.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Joni-Matti Maatta\r\n// Date: 18.4.2012\r\n//\r\n// Description:\r\n// Editor for API definitions.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef APIDEFINITIONEDITOR_H\r\n#define APIDEFINITIONEDITOR_H\r\n\r\n#include \"ApiFunctionEditor.h\"\r\n\r\n#include <common/widgets/tabDocument/TabDocument.h>\r\n#include <common/widgets/listManager/listmanager.h>\r\n#include <common/widgets/vlnvEditor/vlnveditor.h>\r\n\r\n#include <editors/common/DocumentNameGroupEditor.h>\r\n\r\n#include <KactusAPI/include/LibraryInterface.h>\r\n\r\n#include <QSharedPointer>\r\n#include <QPushButton>\r\n#include <QListWidget>\r\n#include <QGroupBox>\r\n#include <QString>\r\n#include <QMap>\r\n#include <QList>\r\n#include <QSharedPointer>\r\n#include <QSortFilterProxyModel>\r\n\r\nclass ApiDefinition;\r\n//-----------------------------------------------------------------------------\r\n//! Editor for editing API definitions.\r\n//-----------------------------------------------------------------------------\r\nclass ApiDefinitionEditor : public TabDocument\r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\t/*!\r\n     *  Constructor.\r\n\t *\r\n     *    @param [in] parent      The parent widget.\r\n\t *    @param [in] libHandler  The library interface.\r\n     *    @param [in] apiDef      The API definition.\r\n\t */\r\n\tApiDefinitionEditor(QWidget* parent, LibraryInterface* libHandler, QSharedPointer<ApiDefinition> apiDef);\r\n\t\r\n\t/*!\r\n     *  Destructor.\r\n     */\r\n\tvirtual ~ApiDefinitionEditor() = default;\r\n\r\n\t/*! \\brief Get the VLNV that can be used to identify the API definition.\r\n\t *\r\n\t * \\return The VLNV of the API definition.\r\n\t*/\r\n\tvirtual VLNV getIdentifyingVLNV() const;\r\n\r\n    /*!\r\n     *  Sets the protection state of the document.\r\n     *\r\n     *    @param [in] locked True for locked state; false for unlocked.\r\n     */\r\n    virtual void setProtection(bool locked);\r\n\r\n    /*!\r\n     *  Refreshes the editor.\r\n     */\r\n    virtual void refresh();\r\n\r\n\t/*!\r\n     *  Returns the VLNV of the SW design component.\r\n     */\r\n\tvirtual VLNV getDocumentVLNV() const;\r\n\r\npublic slots:\r\n    /*!\r\n     *  Validates the document against the IP-XACT standard.\r\n     *\r\n     *    @param [out] errorList Error message list for reporting standard violations.\r\n     *\r\n     *    @return True if the document is valid. False if there were any violations.\r\n     */\r\n    virtual bool validate(QVector<QString>& errorList);\r\n\r\n\t//! Saves the document and resets the modified state.\r\n\tvirtual bool save();\r\n\r\n\t//! \\brief Saves the document as new object and resets modifies state\r\n\tvirtual bool saveAs();\r\n\r\n    //! Updates the data types suggestion lists for return value and function parameter editors.\r\n    void updateDataTypeLists();\r\n\r\n    //! Updates the COM definition.\r\n    void updateComDefinition();\r\n    \r\nprotected:\r\n    //! Called when the editor is shown.\r\n    virtual void showEvent(QShowEvent* event);\r\n\r\nprivate:\r\n    // Disable copying.\r\n    ApiDefinitionEditor(ApiDefinitionEditor const& rhs);\r\n    ApiDefinitionEditor& operator=(ApiDefinitionEditor const& rhs);\r\n\r\n    /*!\r\n     *  Applies the changes made in the editor to the document.\r\n     */\r\n    void applyChanges();\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    DocumentNameGroupEditor nameGroup_;\r\n\r\n\t//! The API definition being edited.\r\n\tQSharedPointer<ApiDefinition> apiDef_;\r\n\r\n    //! VLNV editor for the linked COM definition.\r\n    VLNVEditor comDefVLNVEdit_;\r\n\r\n    //! The data type list manager.\r\n    ListManager dataTypeList_;\r\n\r\n    //! The function editor.\r\n    ApiFunctionEditor functionEditor_;\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n\r\n#endif // APIDEFINITIONEDITOR_H\r\n"
  },
  {
    "path": "editors/ApiDefinitionEditor/ApiFunctionColumns.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ApiFunctionColumns.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Esko Pekkarinen\r\n// Date: 20.10.2015\r\n//\r\n// Description:\r\n// Common declarations for editing API functions.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef API_FUNCTION_COLUMNS_H\r\n#define API_FUNCTION_COLUMNS_H\r\n\r\nnamespace ApiFunctionColumns\r\n{\r\n    //-----------------------------------------------------------------------------\r\n    // Constants defining which column represents what kind of information.\r\n    //-----------------------------------------------------------------------------\r\n    enum ApiFunctionParamColumn\r\n    {\r\n        API_FUNC_PARAM_COL_NAME = 0,      //!< Column for the parameter name.\r\n        API_FUNC_PARAM_COL_TYPE,          //!< Column for setting the value type for the parameter.\r\n        API_FUNC_PARAM_CONTENT_SOURCE,    //!< Column for setting COM content source.\r\n        API_FUNC_PARAM_COM_TRANSFER_TYPE, //!< Column for setting allowed COM transfer type.\r\n        API_FUNC_PARAM_COM_DIRECTION,     //!< Column for setting allowed COM direction.\r\n        API_FUNC_PARAM_DEPENDENT_PARAM,   //!< Column for setting the index of the dependent parameter.\r\n        API_FUNC_PARAM_COL_DESC,          //!< Column for adding a description for the parameter.\r\n        API_FUNC_PARAM_COL_COUNT\r\n    };\r\n}\r\n\r\n#endif // API_FUNCTION_COLUMNS_H"
  },
  {
    "path": "editors/ApiDefinitionEditor/ApiFunctionEditor.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ApiFunctionEditor.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Joni-Matti Maatta\r\n// Date: 18.4.2012\r\n//\r\n// Description:\r\n// Editor for API functions.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"ApiFunctionEditor.h\"\r\n\r\n#include <common/delegates/LineEditDelegate/lineeditdelegate.h>\r\n\r\n#include <IPXACTmodels/kactusExtensions/ApiFunction.h>\r\n#include <IPXACTmodels/kactusExtensions/ApiDefinition.h>\r\n#include <IPXACTmodels/kactusExtensions/ComDefinition.h>\r\n\r\n#include <QFormLayout>\r\n#include <QGridLayout>\r\n#include <QLabel>\r\n#include <QHeaderView>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ApiFunctionEditor::ApiFunctionEditor()\r\n//-----------------------------------------------------------------------------\r\nApiFunctionEditor::ApiFunctionEditor(QWidget* parent): QGroupBox(tr(\"Functions\"), parent),\r\n      functionList_(this),\r\n      functionModel_(this),\r\n      descEdit_(this),\r\n      returnTypeCombo_(this),\r\n      returnValueDesc_(this),\r\n      paramView_(this),\r\n      paramDelegate_(this),\r\n      paramModel_(this),\r\n      curFunc_()\r\n{\r\n    // Disable the function editor widgets by default\r\n    selectionFunctionChanged(QModelIndex());\r\n\r\n    // Set widget settings.\r\n    returnTypeCombo_.setEditable(true);\r\n    returnTypeCombo_.setInsertPolicy(QComboBox::InsertAlphabetically);\r\n    returnTypeCombo_.setEditText(\"\");\r\n\r\n    functionList_.setModel(&functionModel_);\r\n    functionList_.setItemDelegate(new LineEditDelegate(this));\r\n\r\n    paramView_.setCornerButtonText(QString());\r\n\r\n    paramView_.setModel(&paramModel_);\r\n    paramView_.setSortingEnabled(false);\r\n    paramView_.setItemsDraggable(false);\r\n    paramView_.setItemDelegate(&paramDelegate_);\r\n    paramView_.verticalHeader()->show();\r\n    paramView_.setItemsDraggable(true);\r\n\r\n    setupLayout();\r\n\r\n\r\n    connect(&paramModel_, SIGNAL(contentChanged()), this, SIGNAL(contentChanged()), Qt::UniqueConnection);\r\n    connect(&functionModel_, SIGNAL(contentChanged()), this, SIGNAL(contentChanged()), Qt::UniqueConnection);\r\n\r\n    connect(&paramView_, SIGNAL(addItem(const QModelIndex&)),\r\n            &paramModel_, SLOT(onAddItem(const QModelIndex&)), Qt::UniqueConnection);\r\n    connect(&paramView_, SIGNAL(removeItem(const QModelIndex&)),\r\n            &paramModel_, SLOT(onRemoveItem(const QModelIndex&)), Qt::UniqueConnection);\r\n    connect(&paramView_, SIGNAL(moveItem(const QModelIndex&, const QModelIndex&)),\r\n            &paramModel_, SLOT(onMoveItem(const QModelIndex&, const QModelIndex&)), Qt::UniqueConnection);\r\n\r\n    connect(&functionList_, SIGNAL(removeItem(const QModelIndex&)),\r\n            &functionModel_, SLOT(remove(const QModelIndex&)), Qt::UniqueConnection);\r\n    connect(&functionList_, SIGNAL(addItem(const QModelIndex&)),\r\n            &functionModel_, SLOT(addItem(const QModelIndex&)), Qt::UniqueConnection);\r\n    connect(&functionList_, SIGNAL(moveItem(const QModelIndex&, const QModelIndex&)),\r\n            &functionModel_, SLOT(moveItem(const QModelIndex&, const QModelIndex&)), Qt::UniqueConnection);\r\n\r\n    connect(&functionList_, SIGNAL(selectionChanged(QModelIndex const&)),\r\n            this, SLOT(selectionFunctionChanged(QModelIndex const&)), Qt::UniqueConnection);\r\n    connect(&descEdit_, SIGNAL(textEdited(QString const&)),\r\n            this, SLOT(descriptionEdited(QString const&)), Qt::UniqueConnection);\r\n    connect(&returnTypeCombo_, SIGNAL(editTextChanged(QString const&)),\r\n        this, SLOT(returnTypeEdited(QString const&)), Qt::UniqueConnection);\r\n    connect(&returnValueDesc_, SIGNAL(textEdited(QString const&)),\r\n        this, SLOT(returnValueDescriptionEdited(QString const&)), Qt::UniqueConnection);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ApiFunctionEditor::~ApiFunctionEditor()\r\n//-----------------------------------------------------------------------------\r\nApiFunctionEditor::~ApiFunctionEditor()\r\n{\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ApiFunctionEditor::updateDataTypes()\r\n//-----------------------------------------------------------------------------\r\nvoid ApiFunctionEditor::updateDataTypes(QStringList const& dataTypes)\r\n{\r\n    paramDelegate_.updateDataTypes(dataTypes);\r\n\r\n    QString value = returnTypeCombo_.currentText();\r\n    returnTypeCombo_.clear();\r\n    returnTypeCombo_.addItems(paramDelegate_.getDataTypesList());\r\n    returnTypeCombo_.setEditText(value);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ApiFunctionEditor::restore()\r\n//-----------------------------------------------------------------------------\r\nvoid ApiFunctionEditor::restore(ApiDefinition const& apiDef)\r\n{\r\n    functionModel_.restore(apiDef);\r\n    selectionFunctionChanged(functionList_.currentIndex());\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ApiFunctionEditor::save()\r\n//-----------------------------------------------------------------------------\r\nvoid ApiFunctionEditor::save(ApiDefinition& apiDef)\r\n{\r\n    functionModel_.save(apiDef);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ApiFunctionEditor::selectionFunctionChanged()\r\n//-----------------------------------------------------------------------------\r\nvoid ApiFunctionEditor::selectionFunctionChanged(QModelIndex const& cur)\r\n{\r\n    curFunc_ = functionModel_.getFunction(cur);\r\n\r\n    returnTypeCombo_.disconnect(this);\r\n\r\n    if (curFunc_ != 0)\r\n    {\r\n        descEdit_.setText(curFunc_->getDescription());\r\n        returnTypeCombo_.setEditText(curFunc_->getReturnValueType());\r\n        returnValueDesc_.setText(curFunc_->getReturnValueDescription());\r\n    }\r\n    else\r\n    {\r\n        descEdit_.setText(\"\");\r\n        returnTypeCombo_.setEditText(\"\");\r\n        returnValueDesc_.setText(\"\");\r\n    }\r\n\r\n    descEdit_.setEnabled(curFunc_ != 0);\r\n    returnTypeCombo_.setEnabled(curFunc_ != 0);\r\n    returnValueDesc_.setEnabled(curFunc_ != 0);\r\n    paramView_.setEnabled(curFunc_ != 0);\r\n\r\n    paramModel_.setFunction(curFunc_);\r\n\r\n    connect(&returnTypeCombo_, SIGNAL(editTextChanged(QString const&)),\r\n            this, SLOT(returnTypeEdited(QString const&)), Qt::UniqueConnection);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ApiFunctionEditor::descriptionEdited()\r\n//-----------------------------------------------------------------------------\r\nvoid ApiFunctionEditor::descriptionEdited(QString const& text)\r\n{\r\n    if (curFunc_ != 0)\r\n    {\r\n        emit contentChanged();\r\n        curFunc_->setDescription(text);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ApiFunctionEditor::returnTypeEdited()\r\n//-----------------------------------------------------------------------------\r\nvoid ApiFunctionEditor::returnTypeEdited(QString const& text)\r\n{\r\n    if (curFunc_ != 0)\r\n    {\r\n        emit contentChanged();\r\n        curFunc_->setReturnValueType(text);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ApiFunctionEditor::returnValueDescriptionEdited()\r\n//-----------------------------------------------------------------------------\r\nvoid ApiFunctionEditor::returnValueDescriptionEdited(QString const& text)\r\n{\r\n    if (curFunc_ != 0)\r\n    {\r\n        emit contentChanged();\r\n        curFunc_->setReturnValueDescription(text);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ApiFunctionEditor::setComDefinition()\r\n//-----------------------------------------------------------------------------\r\nvoid ApiFunctionEditor::setComDefinition(QSharedPointer<ComDefinition const> comDefinition)\r\n{\r\n    paramDelegate_.setComDefinition(comDefinition);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ApiFunctionEditor::setupLayout()\r\n//-----------------------------------------------------------------------------\r\nvoid ApiFunctionEditor::setupLayout()\r\n{\r\n    setFlat(true);\r\n\r\n    // Create the layouts.\r\n    QGroupBox* functionsBox = new QGroupBox(tr(\"Available functions\"), this);\r\n    QVBoxLayout* functionsLayout = new QVBoxLayout(functionsBox);\r\n    functionsBox->setFlat(true);\r\n\r\n    functionsLayout->addWidget(&functionList_);\r\n\r\n    QGroupBox* detailsBox = new QGroupBox(tr(\"Function details\"), this);\r\n    detailsBox->setFlat(true);\r\n\r\n    QFormLayout* detailsLayout = new QFormLayout(detailsBox);\r\n\r\n    detailsLayout->addRow(tr(\"Function description:\"), &descEdit_);\r\n    detailsLayout->addRow(tr(\"Return value type:\"), &returnTypeCombo_);\r\n    detailsLayout->addRow(tr(\"Return value description:\"), &returnValueDesc_);\r\n\r\n    QGroupBox* parameterBox = new QGroupBox(tr(\"Function parameters\"), this);\r\n    parameterBox->setFlat(true);\r\n\r\n    QVBoxLayout* parameterLayout = new QVBoxLayout(parameterBox);\r\n    parameterLayout->addWidget(&paramView_);\r\n\r\n    QGridLayout* layout = new QGridLayout(this);\r\n\r\n    layout->addWidget(functionsBox, 0, 0, 2, 1);\r\n    layout->addWidget(detailsBox, 0, 1, 1, 1);\r\n    layout->addWidget(parameterBox, 1, 1, 1, 1);\r\n\r\n    layout->setColumnStretch(0, 1);\r\n    layout->setColumnStretch(1, 3);\r\n}\r\n\r\n"
  },
  {
    "path": "editors/ApiDefinitionEditor/ApiFunctionEditor.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ApiFunctionEditor.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Joni-Matti Maatta\r\n// Date: 18.4.2012\r\n//\r\n// Description:\r\n// Editor for API functions.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef APIFUNCTIONEDITOR_H\r\n#define APIFUNCTIONEDITOR_H\r\n\r\n#include \"ApiFunctionParameterModel.h\"\r\n#include \"ApiFunctionModel.h\"\r\n#include \"ApiFunctionParameterDelegate.h\"\r\n\r\n#include <common/views/EditableTableView/editabletableview.h>\r\n#include <common/widgets/listManager/listmanager.h>\r\n\r\n#include <QGroupBox>\r\n#include <QLineEdit>\r\n#include <QComboBox>\r\n#include <QListWidget>\r\n#include <QSortFilterProxyModel>\r\n\r\nclass ApiFunction;\r\nclass ApiDefinition;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Property value editor.\r\n//-----------------------------------------------------------------------------\r\nclass ApiFunctionEditor : public QGroupBox\r\n{\r\n    Q_OBJECT\r\n\r\npublic:\r\n    /*!\r\n     *  Constructor.\r\n     *\r\n     *    @param [in] parent The parent widget.\r\n     */\r\n    ApiFunctionEditor(QWidget* parent);\r\n\r\n    /*!\r\n     *  Destructor.\r\n     */\r\n    virtual ~ApiFunctionEditor();\r\n\r\n    // Disable copying.\r\n    ApiFunctionEditor(ApiFunctionEditor const& rhs) = delete;\r\n\r\n    ApiFunctionEditor& operator=(ApiFunctionEditor const& rhs) = delete;\r\n\r\n    /*!\r\n     *  Sets the linked COM definition.\r\n     *\r\n     *    @param [in] comDefinition The COM definition to set.\r\n     */\r\n    void setComDefinition(QSharedPointer<ComDefinition const> comDefinition);\r\n\r\n    /*!\r\n     *  Updates the data types suggestions list.\r\n     *\r\n     *    @param [in] dataTypes The list of custom data types.\r\n     */\r\n    void updateDataTypes(QStringList const& dataTypes);\r\n\r\n    /*!\r\n     *  Restores the API functions from the given API definition.\r\n     */\r\n    void restore(ApiDefinition const& apiDef);\r\n\r\n    /*!\r\n     *  Applies the API function changes to the given API definition.\r\n     */\r\n    void save(ApiDefinition& apiDef);\r\n\r\npublic slots:\r\n    //! Called when the selection function has changed.\r\n    void selectionFunctionChanged(QModelIndex const& cur);\r\n\r\n    //! Called when the function description has been edited.\r\n    void descriptionEdited(QString const& text);\r\n\r\n    //! Called when the return type has been edited.\r\n    void returnTypeEdited(QString const& text);\r\n\r\n    //! Called when the return value description has been edited.\r\n    void returnValueDescriptionEdited(QString const& text);\r\n\r\n\r\nsignals:\r\n    //! Emitted when contents of the editor changes.\r\n    void contentChanged();\r\n\r\nprivate:\r\n\r\n    void setupLayout();\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! The list view for API functions.\r\n    EditableListView functionList_;\r\n\r\n    //! The model for the API functions.\r\n    ApiFunctionModel functionModel_;\r\n\r\n    //! Line edit for the function description.\r\n    QLineEdit descEdit_;\r\n\r\n    //! Combo box for the return value type.\r\n    QComboBox returnTypeCombo_;\r\n\r\n    //! Line edit for the return value description.\r\n    QLineEdit returnValueDesc_;\r\n\r\n    //! The table view widget for API function parameters.\r\n    EditableTableView paramView_;\r\n\r\n    //! The parameter delegate.\r\n    ApiFunctionParameterDelegate paramDelegate_;\r\n\r\n    //! The model to edit the parameters.\r\n    ApiFunctionParameterModel paramModel_;\r\n\r\n    //! The currently edited API function.\r\n    QSharedPointer<ApiFunction> curFunc_;\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n\r\n\r\n//-----------------------------------------------------------------------------\r\n\r\n#endif // APIFUNCTIONEDITOR_H\r\n"
  },
  {
    "path": "editors/ApiDefinitionEditor/ApiFunctionModel.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ApiFunctionModel.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Joni-Matti Maatta\r\n// Date: 18.4.2012\r\n//\r\n// Description:\r\n// Model for API functions.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"ApiFunctionModel.h\"\r\n\r\n#include <IPXACTmodels/kactusExtensions/ApiFunction.h>\r\n#include <IPXACTmodels/kactusExtensions/ApiDefinition.h>\r\n\r\n#include <QVariant>\r\n\r\n#include <common/KactusColors.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ApiFunctionModel::ApiFunctionModel()\r\n//-----------------------------------------------------------------------------\r\nApiFunctionModel::ApiFunctionModel(QObject *parent)\r\n    : QAbstractListModel(parent),\r\n      apiFunctions_()\r\n{\r\n    connect(this, SIGNAL(dataChanged(const QModelIndex&, const QModelIndex&)),\r\n            this, SIGNAL(contentChanged()), Qt::UniqueConnection);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ApiFunctionModel::~ApiFunctionModel()\r\n//-----------------------------------------------------------------------------\r\nApiFunctionModel::~ApiFunctionModel()\r\n{\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ApiFunctionModel::restore()\r\n//-----------------------------------------------------------------------------\r\nvoid ApiFunctionModel::restore(ApiDefinition const& apiDef)\r\n{\r\n    beginResetModel();\r\n\r\n    apiFunctions_.clear();\r\n\r\n    foreach ( QSharedPointer<ApiFunction> apiFunction, *apiDef.getFunctions() )\r\n    {\r\n        apiFunctions_.append(QSharedPointer<ApiFunction>(new ApiFunction(*apiFunction)));\r\n    }\r\n\r\n    endResetModel();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ApiFunctionModel::save()\r\n//-----------------------------------------------------------------------------\r\nvoid ApiFunctionModel::save(ApiDefinition& apiDef)\r\n{\r\n    apiDef.removeFunctions();\r\n\r\n    foreach (QSharedPointer<ApiFunction> func, apiFunctions_)\r\n    {\r\n        apiDef.getFunctions()->append(QSharedPointer<ApiFunction>(new ApiFunction(*func.data())));\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ApiFunctionModel::rowCount()\r\n//-----------------------------------------------------------------------------\r\nint ApiFunctionModel::rowCount( const QModelIndex&) const {\r\n\r\n    // if there are no items then there is the help text\r\n    if (apiFunctions_.isEmpty()) {\r\n        return 1;\r\n    }\r\n\r\n    return apiFunctions_.size();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ApiFunctionModel::data()\r\n//-----------------------------------------------------------------------------\r\nQVariant ApiFunctionModel::data( const QModelIndex& index, int role) const {\r\n\r\n    // nothing for invalid indexes\r\n    if (!index.isValid()) {\r\n        return QVariant();\r\n    }\r\n\r\n    // if there are no real items then display the help text\r\n    else if (index.row() == 0 && apiFunctions_.isEmpty()) {\r\n        switch (role) {\r\n            case Qt::DisplayRole: {\r\n                return tr(\"Double click to add new item.\");\r\n                                  }\r\n            case Qt::ForegroundRole: {\r\n                return KactusColors::DISABLED_TEXT;\r\n                                     }\r\n            default: {\r\n                return QVariant();\r\n                     }\r\n        }\r\n    }\r\n\r\n    // if index.row() is invalid\r\n    else if (index.row() < 0 || index.row() >= apiFunctions_.size()) {\r\n        return QVariant();\r\n    }\r\n\r\n    // return data for display role\r\n    if (role == Qt::DisplayRole) {\r\n        return apiFunctions_.at(index.row())->name();\r\n    }\r\n    // if unsupported role\r\n    else {\r\n        return QVariant();\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ApiFunctionModel::headerData()\r\n//-----------------------------------------------------------------------------\r\nQVariant ApiFunctionModel::headerData(int section, Qt::Orientation orientation, int role) const {\r\n\r\n    // only one column to display\r\n    if (section != 0) {\r\n        return QVariant();\r\n    }\r\n    // only horizontal headers\r\n    else if (orientation != Qt::Horizontal) {\r\n        return QVariant();\r\n    }\r\n\r\n    // data for displayRole\r\n    if (role == Qt::DisplayRole) {\r\n        return tr(\"Items\");\r\n    }\r\n    // unsupported role\r\n    else {\r\n        return QVariant();\r\n    }\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ApiFunctionModel::setData()\r\n//-----------------------------------------------------------------------------\r\nbool ApiFunctionModel::setData(const QModelIndex& index, const QVariant& value, int role)\r\n{\r\n    if (!index.isValid()) {\r\n        return false;\r\n    }\r\n\r\n    // if there are no real items then create one to avoid mis indexing\r\n    else if (index.row() == 0 && apiFunctions_.isEmpty()) {\r\n        apiFunctions_.append(QSharedPointer<ApiFunction>(new ApiFunction()));\r\n    }\r\n\r\n    // if row is invalid\r\n    else if (index.row() < 0 || index.row() >= apiFunctions_.size()) {\r\n        return false;\r\n    }\r\n\r\n    // list model has only one column\r\n    else if (index.column() != 0) {\r\n        return false;\r\n    }\r\n\r\n    if (role == Qt::EditRole) {\r\n        apiFunctions_[index.row()]->setName(value.toString());\r\n        emit dataChanged(index, index);\r\n        emit contentChanged();\r\n        return true;\r\n    }\r\n\r\n    // unsupported role\r\n    else {\r\n        return false;\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ApiFunctionModel::flags()\r\n//-----------------------------------------------------------------------------\r\nQt::ItemFlags ApiFunctionModel::flags( const QModelIndex& index ) const\r\n{\r\n    if (!index.isValid())\r\n        return Qt::NoItemFlags;\r\n\r\n    return Qt::ItemIsEditable | Qt::ItemIsEnabled | Qt::ItemIsSelectable;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ApiFunctionModel::addItem()\r\n//-----------------------------------------------------------------------------\r\nvoid ApiFunctionModel::addItem(const QModelIndex& index)\r\n{\r\n    int row = apiFunctions_.size();\r\n\r\n    // if the index is valid then add the item to the correct position\r\n    if (index.isValid()) {\r\n        row = index.row();\r\n    }\r\n\r\n    beginInsertRows(QModelIndex(), row, row);\r\n\r\n    QSharedPointer<ApiFunction> func(new ApiFunction());\r\n    func->setName(\"function\");\r\n\r\n    apiFunctions_.insert(row, func);\r\n\r\n    endInsertRows();\r\n    emit contentChanged();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ApiFunctionModel::remove()\r\n//-----------------------------------------------------------------------------\r\nvoid ApiFunctionModel::remove(const QModelIndex& index)\r\n{\r\n    // don't remove anything if index is invalid\r\n    if (!index.isValid()) {\r\n        return;\r\n    }\r\n    // make sure the row number if valid\r\n    else if (index.row() < 0 || index.row() >= apiFunctions_.size()) {\r\n        return;\r\n    }\r\n\r\n    // remove the specified item\r\n    beginRemoveRows(QModelIndex(), index.row(), index.row());\r\n    apiFunctions_.removeAt(index.row());\r\n    endRemoveRows();\r\n    emit contentChanged();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ApiFunctionModel::moveItem()\r\n//-----------------------------------------------------------------------------\r\nvoid ApiFunctionModel::moveItem( const QModelIndex& originalPos, \r\n                                 const QModelIndex& newPos )\r\n{\r\n    // if there was no item in the starting point\r\n    if (!originalPos.isValid()) {\r\n        return;\r\n    }\r\n    // if the indexes are the same\r\n    else if (originalPos == newPos) {\r\n        return;\r\n    }\r\n    else if (originalPos.row() < 0 || originalPos.row() >= apiFunctions_.size()) {\r\n        return;\r\n    }\r\n\r\n    // if the new position is invalid index then put the item last in the list\r\n    if (!newPos.isValid() || newPos.row() < 0 || newPos.row() >= apiFunctions_.size()) {\r\n\r\n        beginResetModel();\r\n        QSharedPointer<ApiFunction> func = apiFunctions_.takeAt(originalPos.row());\r\n        apiFunctions_.append(func);\r\n        endResetModel();\r\n    }\r\n    // if both indexes were valid\r\n    else {\r\n        beginResetModel();\r\n        apiFunctions_.swapItemsAt(originalPos.row(), newPos.row());\r\n        endResetModel();\r\n    }\r\n    emit contentChanged();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ApiFunctionModel::replace()\r\n//-----------------------------------------------------------------------------\r\nvoid ApiFunctionModel::replace(QModelIndex& index, const QString newText)\r\n{\r\n    if (!index.isValid()) {\r\n        return;\r\n    }\r\n    // make sure the row is correct\r\n    else if (index.row() < 0 || index.row() >= apiFunctions_.size()) {\r\n        return;\r\n    }\r\n\r\n    apiFunctions_[index.row()]->setName(newText);\r\n    emit dataChanged(index, index);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ApiFunctionModel::getFunction()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<ApiFunction> ApiFunctionModel::getFunction(QModelIndex const& index)\r\n{\r\n    if (!index.isValid() || index.row() < 0 || index.row() >= apiFunctions_.size())\r\n    {\r\n        return QSharedPointer<ApiFunction>();\r\n    }\r\n\r\n    return apiFunctions_.at(index.row());\r\n}\r\n\r\n"
  },
  {
    "path": "editors/ApiDefinitionEditor/ApiFunctionModel.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ApiFunctionModel.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Joni-Matti Maatta\r\n// Date: 18.4.2012\r\n//\r\n// Description:\r\n// Model for API functions.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef APIFUNCTIONMODEL_H\r\n#define APIFUNCTIONMODEL_H\r\n\r\n#include <QObject>\r\n#include <QAbstractListModel>\r\n#include <QVariant>\r\n#include <QStringList>\r\n#include <QModelIndex>\r\n#include <QSharedPointer>\r\n\r\nclass ApiFunction;\r\nclass ApiDefinition;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Model for API functions.\r\n//-----------------------------------------------------------------------------\r\nclass ApiFunctionModel : public QAbstractListModel\r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n    /*!\r\n     *  Constructor.\r\n     *\r\n     *    @param [in] parent The parent object.\r\n     */\r\n\tApiFunctionModel(QObject *parent = 0);\r\n\r\n\t/*!\r\n     *  Destructor.\r\n     */\r\n\tvirtual ~ApiFunctionModel();\r\n\r\n    /*!\r\n     *  Restores the model from an API definition.\r\n     *\r\n     *    @param [in] apiDef The source API definition.\r\n     */\r\n    void restore(ApiDefinition const& apiDef);\r\n\r\n    /*!\r\n     *  Saves the changes to an API definition.\r\n     *\r\n     *    @param [in,out] apiDef The destination API definition.\r\n     */\r\n    void save(ApiDefinition& apiDef);\r\n\r\n    /*!\r\n     *  Returns the API function at the given index.\r\n     *\r\n     *    @param [in] index The index.\r\n     */\r\n    QSharedPointer<ApiFunction> getFunction(QModelIndex const& index);\r\n\r\n\t/*!\r\n     *  Returns the number of rows in this model.\r\n\t *\r\n\t *    @param [in] parent ModelIndex of the item that's rowCount is requested.\r\n\t */\r\n\tvirtual int rowCount(const QModelIndex& parent = QModelIndex()) const;\r\n\r\n\t/*!\r\n     *  Returns the data stored for the specified item.\r\n\t *\r\n\t *    @param [in] index  ModelIndex of the wanted item.\r\n\t *    @param [in] role   Specifies what kind of data is requested.\r\n\t */\r\n\tvirtual QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const;\r\n\r\n\t/*!\r\n     *  Returns the data for the header of the list.\r\n\t *\r\n\t *    @param [in] section      Specifies the column for which the header is requested.\r\n\t *    @param [in] orientation  The orientation of the header, only Qt::Horizontal is supported.\r\n\t *    @param [in] role         Specifies what kind of header data is requested.\r\n\t */\r\n\tvirtual QVariant headerData(int section, Qt::Orientation orientation, \r\n\t\t                        int role = Qt::DisplayRole) const;\r\n\r\n\t/*!\r\n     *  Saves the data to the model for specified item\r\n\t *\r\n\t *    @param [in] index  The model index of the item that's data is to be saved.\r\n\t *    @param [in] value  The data that is to be saved.\r\n\t *    @param [in] role   The role specifies what kind of data should be saved.\r\n\t *\r\n\t *    @return True if saving happened successfully.\r\n\t */\r\n\tvirtual bool setData(const QModelIndex& index, const QVariant& value, int role = Qt::EditRole);\r\n\r\n\t/*!\r\n     *  Returns the item flags that defines the possible operations for the item.\r\n\t *\r\n\t *    @param [in] index Model index that identifies the item.\r\n\t *\r\n\t *    @return Qt::ItemFlags specify the possible operations for the item.\r\n\t */\r\n\tvirtual Qt::ItemFlags flags(const QModelIndex& index) const;\r\n\r\n\t/*!\r\n     *  Replace an item text in the list.\r\n\t * \r\n\t *    @param [in] index    ModelIndex of the item that is to be replaced.\r\n\t *    @param [in] newText  The new text for the given item.\r\n\t */\r\n\tvirtual void replace(QModelIndex& index, const QString newText);\r\n\r\npublic slots:\r\n\t \r\n\t/*!\r\n     *  Removes the specified item from the model.\r\n\t *\r\n     *    @param [in] index The model index of the item to remove.\r\n     */\r\n\tvirtual void remove(const QModelIndex& index);\r\n\r\n\t/*!\r\n     *  A new item should be added to given index.\r\n\t *\r\n\t *    @param [in] index The position where new item should be added at.\r\n\t */\r\n\tvirtual void addItem(const QModelIndex& index);\r\n\r\n\t/*!\r\n     *  Move item to another position.\r\n\t *\r\n\t *    @param [in] originalPos  Identifies the item that should be moved.\r\n\t *    @param [in] newPos       The new position the item should be moved to.\r\n\t */\r\n\tvirtual void moveItem(const QModelIndex& originalPos, const QModelIndex& newPos);\r\n\r\nsignals: \r\n\t//! Emitted when contents of the model change.\r\n\tvoid contentChanged();\r\n\r\nprivate:\r\n    // Disable copying.\r\n    ApiFunctionModel(ApiFunctionModel const& rhs);\r\n    ApiFunctionModel& operator=(ApiFunctionModel const& rhs);\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! The list of edited API functions.\r\n    QList< QSharedPointer<ApiFunction> > apiFunctions_;\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n\r\n#endif // APIFUNCTIONMODEL_H\r\n"
  },
  {
    "path": "editors/ApiDefinitionEditor/ApiFunctionParameterDelegate.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ApiFunctionParameterDelegate.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Joni-Matti Maatta\r\n// Date: 18.4.2012\r\n//\r\n// Description:\r\n// Delegate for editing API function parameters.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"ApiFunctionParameterDelegate.h\"\r\n#include \"ApiFunctionColumns.h\"\r\n\r\n#include <IPXACTmodels/kactusExtensions/ComDefinition.h>\r\n#include <IPXACTmodels/kactusExtensions/ComProperty.h>\r\n\r\n#include <QComboBox>\r\n#include <QLineEdit>\r\n#include <QSpinBox>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ApiFunctionParameterDelegate::ApiFunctionParameterDelegate()\r\n//-----------------------------------------------------------------------------\r\nApiFunctionParameterDelegate::ApiFunctionParameterDelegate(QObject* parent)\r\n    : QStyledItemDelegate(parent)\r\n{\r\n    builtInTypes_.append(\"char\");\r\n    builtInTypes_.append(\"char*\");\r\n    builtInTypes_.append(\"const char*\");\r\n    builtInTypes_.append(\"double\");\r\n    builtInTypes_.append(\"float\");\r\n    builtInTypes_.append(\"int\");\r\n    builtInTypes_.append(\"long\");\r\n    builtInTypes_.append(\"short\");\r\n    builtInTypes_.append(\"signed char\");\r\n    builtInTypes_.append(\"unsigned char\");\r\n    builtInTypes_.append(\"unsigned int\");\r\n    builtInTypes_.append(\"unsigned long\");\r\n    builtInTypes_.append(\"unsigned short\");\r\n    builtInTypes_.append(\"void\");\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ApiFunctionParameterDelegate::~ApiFunctionParameterDelegate()\r\n//-----------------------------------------------------------------------------\r\nApiFunctionParameterDelegate::~ApiFunctionParameterDelegate()\r\n{\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ApiFunctionParameterDelegate::updateDataTypes()\r\n//-----------------------------------------------------------------------------\r\nvoid ApiFunctionParameterDelegate::updateDataTypes(QStringList const& dataTypes)\r\n{\r\n    customTypes_ = dataTypes;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ApiFunctionParameterDelegate::createEditor()\r\n//-----------------------------------------------------------------------------\r\nQWidget* ApiFunctionParameterDelegate::createEditor(QWidget* parent, QStyleOptionViewItem const& option,\r\n                                                    QModelIndex const& index) const\r\n{\r\n    if (index.column() == ApiFunctionColumns::API_FUNC_PARAM_COL_NAME ||\r\n        index.column() == ApiFunctionColumns::API_FUNC_PARAM_COL_DESC)\r\n    {\r\n        QLineEdit* lineEditor = new QLineEdit(parent);\r\n        connect(lineEditor, SIGNAL(editingFinished()), this, SLOT(commitAndCloseEditor()), Qt::UniqueConnection);\r\n        return lineEditor;\r\n    }\r\n\r\n    else if (index.column() == ApiFunctionColumns::API_FUNC_PARAM_COL_TYPE)\r\n    {\r\n        QComboBox* box = new QComboBox(parent);\r\n        box->setEditable(true);\r\n        box->setInsertPolicy(QComboBox::InsertAlphabetically);\r\n\r\n        box->addItems(getDataTypesList());\r\n        return box;\r\n    }\r\n\r\n    else if (index.column() == ApiFunctionColumns::API_FUNC_PARAM_COM_DIRECTION)\r\n    {\r\n        QComboBox* box = new QComboBox(parent);\r\n        box->addItem(tr(\"any\"));\r\n        box->addItem(tr(\"in\"));\r\n        box->addItem(tr(\"out\"));\r\n        box->addItem(tr(\"inout\"));\r\n\r\n        return box;\r\n    }\r\n\r\n    else if (index.column() == ApiFunctionColumns::API_FUNC_PARAM_COM_TRANSFER_TYPE)\r\n    {\r\n        QComboBox* box = new QComboBox(parent);\r\n        box->addItem(\"any\");\r\n\r\n        // Fetch allowed transfer types from the linked COM definition.\r\n        if (comDefinition_ != 0)\r\n        {\r\n            box->addItems(*comDefinition_->getTransferTypes());\r\n        }\r\n\r\n        return box;\r\n    }\r\n\r\n    else if (index.column() == ApiFunctionColumns::API_FUNC_PARAM_CONTENT_SOURCE)\r\n    {\r\n        QComboBox* box = new QComboBox(parent);\r\n\r\n        // Fetch content sources from a COM definition properties.\r\n        box->addItem(\"\");\r\n        box->addItem(\"Name\");\r\n\r\n        if (comDefinition_ != 0)\r\n        {\r\n            for (QSharedPointer<ComProperty const> property : comDefinition_->getProperties())\r\n            {\r\n                box->addItem(property->name());\r\n            }\r\n        }\r\n\r\n        return box;\r\n    }\r\n\r\n    else if (index.column() == ApiFunctionColumns::API_FUNC_PARAM_DEPENDENT_PARAM)\r\n    {\r\n        QComboBox* box = new QComboBox(parent);\r\n        box->addItem(\"no\");\r\n\r\n        for (int i = 0; i < index.row(); ++i)\r\n        {\r\n            box->addItem(QString::number(i + 1));\r\n        }\r\n\r\n        return box;\r\n    }\r\n\r\n    else\r\n    {\r\n        return QStyledItemDelegate::createEditor(parent, option, index);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ApiFunctionParameterDelegate::setEditorData()\r\n//-----------------------------------------------------------------------------\r\nvoid ApiFunctionParameterDelegate::setEditorData(QWidget* editor, QModelIndex const& index) const\r\n{\r\n    if (index.column() == ApiFunctionColumns::API_FUNC_PARAM_COL_TYPE ||\r\n        index.column() == ApiFunctionColumns::API_FUNC_PARAM_COM_DIRECTION ||\r\n        index.column() == ApiFunctionColumns::API_FUNC_PARAM_COM_TRANSFER_TYPE ||\r\n        index.column() == ApiFunctionColumns::API_FUNC_PARAM_CONTENT_SOURCE ||\r\n        index.column() == ApiFunctionColumns::API_FUNC_PARAM_DEPENDENT_PARAM)  \r\n    {\r\n        QComboBox* box = qobject_cast<QComboBox*>(editor);\r\n        Q_ASSERT_X(box, \"ApiFunctionParameterDelegate::setEditorData\", \"Type conversion failed for QComboBox\");\r\n\r\n        QString text = index.model()->data(index, Qt::DisplayRole).toString();\r\n        box->setCurrentIndex(box->findText(text));\r\n    }\r\n\r\n    else if (index.column() == ApiFunctionColumns::API_FUNC_PARAM_COL_NAME ||\r\n        index.column() ==  ApiFunctionColumns::API_FUNC_PARAM_COL_DESC)\r\n    {\r\n        QLineEdit* line = qobject_cast<QLineEdit*>(editor);\r\n        Q_ASSERT_X(line, \"ApiFunctionParameterDelegate::setEditorData\", \"Type conversion failed for QLineEdit\");\r\n\r\n        QString text = index.model()->data(index, Qt::DisplayRole).toString();\r\n        line->setText(text);\r\n    }\r\n\r\n    else\r\n    {\r\n        QStyledItemDelegate::setEditorData(editor, index);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ApiFunctionParameterDelegate::setModelData()\r\n//-----------------------------------------------------------------------------\r\nvoid ApiFunctionParameterDelegate::setModelData(QWidget* editor, QAbstractItemModel* model, QModelIndex const& index) const\r\n{\r\n    if (index.column() == ApiFunctionColumns::API_FUNC_PARAM_COL_TYPE ||\r\n        index.column() == ApiFunctionColumns::API_FUNC_PARAM_COM_DIRECTION ||\r\n        index.column() == ApiFunctionColumns::API_FUNC_PARAM_COM_TRANSFER_TYPE ||\r\n        index.column() == ApiFunctionColumns::API_FUNC_PARAM_CONTENT_SOURCE ||\r\n        index.column() == ApiFunctionColumns::API_FUNC_PARAM_DEPENDENT_PARAM)  \r\n    {\r\n        QComboBox* box = qobject_cast<QComboBox*>(editor);\r\n        Q_ASSERT_X(box, \"ApiFunctionParameterDelegate::setEditorData\", \"Type conversion failed for QComboBox\");\r\n\r\n        QString text = box->currentText();\r\n        model->setData(index, text, Qt::EditRole);\r\n    }\r\n\r\n    else if (index.column() == ApiFunctionColumns::API_FUNC_PARAM_COL_NAME ||\r\n        index.column() ==  ApiFunctionColumns::API_FUNC_PARAM_COL_DESC)\r\n    {\r\n        QLineEdit* line = qobject_cast<QLineEdit*>(editor);\r\n        Q_ASSERT_X(line, \"ApiFunctionParameterDelegate::setEditorData\", \"Type conversion failed for QLineEdit\");\r\n\r\n        QString text = line->text();\r\n        model->setData(index, text, Qt::EditRole);\r\n    }\r\n\r\n    else\r\n    {\r\n        QStyledItemDelegate::setModelData(editor, model, index);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ApiFunctionParameterDelegate::commitAndCloseEditor()\r\n//-----------------------------------------------------------------------------\r\nvoid ApiFunctionParameterDelegate::commitAndCloseEditor()\r\n{\r\n    QLineEdit* lineEdit = qobject_cast<QLineEdit*>(sender());\r\n\r\n    if (lineEdit != 0)\r\n    {\r\n        emit commitData(lineEdit);\r\n        emit closeEditor(lineEdit);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ApiFunctionParameterDelegate::getDataTypesList()\r\n//-----------------------------------------------------------------------------\r\nQStringList ApiFunctionParameterDelegate::getDataTypesList() const\r\n{\r\n    QStringList list = builtInTypes_ + customTypes_;\r\n    list.sort();\r\n    list.removeDuplicates();\r\n    return list;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ApiFunctionParameterDelegate::setComDefinition()\r\n//-----------------------------------------------------------------------------\r\nvoid ApiFunctionParameterDelegate::setComDefinition(QSharedPointer<ComDefinition const> comDefinition)\r\n{\r\n    comDefinition_ = comDefinition;\r\n}\r\n"
  },
  {
    "path": "editors/ApiDefinitionEditor/ApiFunctionParameterDelegate.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ApiFunctionParameterDelegate.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Joni-Matti Maatta\r\n// Date: 18.4.2012\r\n//\r\n// Description:\r\n// Delegate for editing API function parameters.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef APIFUNCTIONPARAMETERDELEGATE_H\r\n#define APIFUNCTIONPARAMETERDELEGATE_H\r\n\r\n#include <QStyledItemDelegate>\r\n\r\nclass ComDefinition;\r\n\r\n//-----------------------------------------------------------------------------\r\n// Delegate for editing API function parameters.\r\n//-----------------------------------------------------------------------------\r\nclass ApiFunctionParameterDelegate : public QStyledItemDelegate\r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\t/*!\r\n     *  Constructor.\r\n     *\r\n     *    @param [in] parent The parent object.\r\n     */\r\n\tApiFunctionParameterDelegate(QObject* parent = 0);\r\n\r\n\t/*!\r\n     *  Destructor.\r\n     */\r\n\tvirtual ~ApiFunctionParameterDelegate();\r\n\r\n    /*!\r\n     *  Sets the linked COM definition.\r\n     *\r\n     *    @param [in] comDefinition The COM definition to set.\r\n     */\r\n    void setComDefinition(QSharedPointer<ComDefinition const> comDefinition);\r\n\r\n    /*!\r\n     *  Adds the given data types to the list of parameter type suggestions.\r\n     *\r\n     *    @param [in] dataTypes The list of data types to add.\r\n     */\r\n    void updateDataTypes(QStringList const& dataTypes);\r\n\r\n    /*!\r\n     *  Returns the list of all data type suggestions.\r\n     */\r\n    QStringList getDataTypesList() const;\r\n\r\n\t/*!\r\n     *  Creates a new editor for the given item.\r\n\t *\r\n\t *    @param [in] parent  The parent widget.\r\n     *    @param [in] option  Contains options for the editor.\r\n     *    @param [in] index   Model index identifying the item.\r\n\t *\r\n\t *    @return Pointer to the editor to be used to edit the item.\r\n\t */\r\n\tvirtual QWidget* createEditor(QWidget* parent, QStyleOptionViewItem const& option, \r\n\t\t                          QModelIndex const& index) const;\r\n\r\n\t/*!\r\n     *  Sets the data for the editor.\r\n\t *\r\n\t *    @param [in] editor  Pointer to the editor where the data is to be set.\r\n\t *    @param [in] index   Model index identifying the item that's data is to be set.\r\n\t */\r\n\tvirtual void setEditorData(QWidget* editor, QModelIndex const& index) const;\r\n\r\n\t/*!\r\n     *  Saves the data from the editor to the model.\r\n\t *\r\n\t *    @param [in] editor  Pointer to the editor that contains the data to store.\r\n\t *    @param [in] model   Model that contains the data structure where data is to be saved to.\r\n\t *    @param [in] index   Model index identifying the item that's data is to be saved.\r\n\t */\r\n\tvirtual void setModelData(QWidget* editor, QAbstractItemModel* model, \r\n\t\t                      QModelIndex const& index) const;\r\n\r\nprivate slots:\r\n\t/*! \r\n     *  Commits the data from the sending editor and close the editor.\r\n\t */\r\n\tvoid commitAndCloseEditor();\r\n\r\nprivate:\r\n    // Disable copying.\r\n    ApiFunctionParameterDelegate(ApiFunctionParameterDelegate const& rhs);\r\n    ApiFunctionParameterDelegate& operator=(ApiFunctionParameterDelegate const& rhs);\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! The list of built-in data types.\r\n    QStringList builtInTypes_;\r\n\r\n    //! The list of custom parameter data types.\r\n    QStringList customTypes_;\r\n\r\n    //! The linked COM definition.\r\n    QSharedPointer<ComDefinition const> comDefinition_;\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n\r\n#endif // APIFUNCTIONPARAMETERDELEGATE_H\r\n"
  },
  {
    "path": "editors/ApiDefinitionEditor/ApiFunctionParameterModel.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ApiFunctionParameterModel.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Joni-Matti Maatta\r\n// Date: 18.4.2012\r\n//\r\n// Description:\r\n// Model for API function parameters.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"ApiFunctionParameterModel.h\"\r\n\r\n#include \"ApiFunctionColumns.h\"\r\n\r\n#include <IPXACTmodels/common/DirectionTypes.h>\r\n\r\n#include <IPXACTmodels/kactusExtensions/ApiFunction.h>\r\n#include <IPXACTmodels/kactusExtensions/ApiFunctionParameter.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ApiFunctionParameterModel::ApiFunctionParameterModel()\r\n//-----------------------------------------------------------------------------\r\nApiFunctionParameterModel::ApiFunctionParameterModel(QObject *parent): QAbstractTableModel(parent), function_()\r\n{\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ApiFunctionParameterModel::~ApiFunctionParameterModel()\r\n//-----------------------------------------------------------------------------\r\nApiFunctionParameterModel::~ApiFunctionParameterModel()\r\n{\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ApiFunctionParameterModel::setFunction()\r\n//-----------------------------------------------------------------------------\r\nvoid ApiFunctionParameterModel::setFunction(QSharedPointer<ApiFunction> function)\r\n{\r\n    beginResetModel();\r\n    function_ = function;\r\n    endResetModel();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ApiFunctionParameterModel::rowCount()\r\n//-----------------------------------------------------------------------------\r\nint ApiFunctionParameterModel::rowCount(QModelIndex const& parent) const\r\n{\r\n    if (parent.isValid() || function_ == 0)\r\n    {\r\n        return 0;\r\n    }\r\n\r\n    return function_->getParamCount();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ApiFunctionParameterModel::columnCount()\r\n//-----------------------------------------------------------------------------\r\nint ApiFunctionParameterModel::columnCount(QModelIndex const& parent) const\r\n{\r\n    if (parent.isValid())\r\n    {\r\n        return 0;\r\n    }\r\n\r\n    return ApiFunctionColumns::API_FUNC_PARAM_COL_COUNT;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ApiFunctionParameterModel::data()\r\n//-----------------------------------------------------------------------------\r\nQVariant ApiFunctionParameterModel::data(QModelIndex const& index, int role) const\r\n{\r\n    if (role != Qt::DisplayRole || !index.isValid() || \r\n        function_ == 0 || index.row() < 0 || index.row() >= function_->getParamCount())\r\n    {\r\n        return QVariant();\r\n    }\r\n\r\n    if (index.column() == ApiFunctionColumns::API_FUNC_PARAM_COL_NAME)\r\n    {\r\n        return function_->getParam(index.row())->name();\r\n    }\r\n\r\n    else if (index.column() == ApiFunctionColumns::API_FUNC_PARAM_COL_TYPE)\r\n    {\r\n        return function_->getParam(index.row())->getType();\r\n    }\r\n\r\n    else if (index.column() == ApiFunctionColumns::API_FUNC_PARAM_COM_TRANSFER_TYPE)\r\n    {\r\n        QString transferType = function_->getParam(index.row())->getComTransferType();\r\n        if (transferType.isEmpty())\r\n        {\r\n            return tr(\"any\");\r\n        }\r\n\r\n        return transferType;\r\n    }\r\n\r\n    else if (index.column() == ApiFunctionColumns::API_FUNC_PARAM_COM_DIRECTION)\r\n    {\r\n        DirectionTypes::Direction direction = function_->getParam(index.row())->getComDirection();\r\n        if (direction == DirectionTypes::DIRECTION_INVALID)\r\n        {\r\n            return tr(\"any\");\r\n        }\r\n\r\n        return DirectionTypes::direction2Str(direction);\r\n    }\r\n\r\n    else if (index.column() == ApiFunctionColumns::API_FUNC_PARAM_CONTENT_SOURCE)\r\n    {\r\n        return function_->getParam(index.row())->getContentSource();\r\n    }\r\n\r\n    else if (index.column() == ApiFunctionColumns::API_FUNC_PARAM_DEPENDENT_PARAM)\r\n    {\r\n        int paramIndex = function_->getParam(index.row())->getDependentParameterIndex();\r\n        if (paramIndex < 0)\r\n        {\r\n            return \"no\";\r\n        }\r\n\r\n        return (function_->getParam(index.row())->getDependentParameterIndex() + 1);\r\n    }\r\n\r\n    else if (index.column() == ApiFunctionColumns::API_FUNC_PARAM_COL_DESC)\r\n    {\r\n        return function_->getParam(index.row())->getDescription();\r\n    }\r\n\r\n    else\r\n    {\r\n        return QVariant();\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ApiFunctionParameterModel::headerData()\r\n//-----------------------------------------------------------------------------\r\nQVariant ApiFunctionParameterModel::headerData(int section, Qt::Orientation orientation, int role) const\r\n{\r\n    if (role != Qt::DisplayRole)\r\n    {\r\n        return QVariant();\r\n    }\r\n\r\n    if (orientation == Qt::Horizontal)\r\n    {\r\n        if (section == ApiFunctionColumns::API_FUNC_PARAM_COL_NAME)\r\n        {\r\n            return tr(\"Name\");\r\n        }\r\n        else if (section == ApiFunctionColumns::API_FUNC_PARAM_COL_TYPE)\r\n        {\r\n            return tr(\"Type\");\r\n        }\r\n        else if (section == ApiFunctionColumns::API_FUNC_PARAM_COM_TRANSFER_TYPE)\r\n        {\r\n            return tr(\"COM transfer type\");\r\n        }\r\n        else if (section == ApiFunctionColumns::API_FUNC_PARAM_COM_DIRECTION)\r\n        {\r\n            return tr(\"COM direction\");\r\n        }\r\n        else if (section == ApiFunctionColumns::API_FUNC_PARAM_CONTENT_SOURCE)\r\n        {\r\n            return tr(\"Source\");\r\n        }\r\n        else if (section == ApiFunctionColumns::API_FUNC_PARAM_DEPENDENT_PARAM)\r\n        {\r\n            return tr(\"Dependent parameter\");\r\n        }\r\n        else if (section == ApiFunctionColumns::API_FUNC_PARAM_COL_DESC)\r\n        {\r\n            return tr(\"Description\");\r\n        }\r\n        else\r\n        {\r\n            return QVariant();\r\n        }\r\n    }\r\n    else\r\n    {\r\n        return section + 1;\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ApiFunctionParameterModel::flags()\r\n//-----------------------------------------------------------------------------\r\nQt::ItemFlags ApiFunctionParameterModel::flags(QModelIndex const& index) const\r\n{\r\n    if (!index.isValid())\r\n    {\r\n        return Qt::NoItemFlags;\r\n    }\r\n\r\n    if (index.column() == ApiFunctionColumns::API_FUNC_PARAM_COM_TRANSFER_TYPE ||\r\n        index.column() == ApiFunctionColumns::API_FUNC_PARAM_COM_DIRECTION ||\r\n        index.column() == ApiFunctionColumns::API_FUNC_PARAM_DEPENDENT_PARAM)\r\n    {\r\n        if (function_->getParam(index.row())->getContentSource().isEmpty())\r\n        {\r\n            return Qt::ItemIsSelectable;\r\n        }\r\n        else\r\n        {\r\n            return Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsEditable;\r\n        }\r\n    }\r\n\r\n    else\r\n    {\r\n        return Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsEditable;\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ApiFunctionParameterModel::setData()\r\n//-----------------------------------------------------------------------------\r\nbool ApiFunctionParameterModel::setData(QModelIndex const& index, QVariant const& value, int role)\r\n{\r\n    if (!index.isValid() || function_ == 0 || index.row() < 0 || index.row() >= function_->getParamCount())\r\n    {\r\n        return false;\r\n    }\r\n\r\n    if (role == Qt::EditRole)\r\n    {\r\n        if (index.column() == ApiFunctionColumns::API_FUNC_PARAM_COL_NAME)\r\n        {\r\n            function_->getParam(index.row())->setName(value.toString());\r\n        }\r\n\r\n        else if (index.column() == ApiFunctionColumns::API_FUNC_PARAM_COL_TYPE)\r\n        {\r\n            function_->getParam(index.row())->setType(value.toString());\r\n        }\r\n\r\n        else if (index.column() == ApiFunctionColumns::API_FUNC_PARAM_COM_TRANSFER_TYPE)\r\n        {\r\n            if (value.toString() == tr(\"any\"))\r\n            {\r\n                function_->getParam(index.row())->setComTransferType(\"\");\r\n            }\r\n            else\r\n            {\r\n                function_->getParam(index.row())->setComTransferType(value.toString());\r\n            }\r\n        }\r\n\r\n        else if (index.column() == ApiFunctionColumns::API_FUNC_PARAM_COM_DIRECTION)\r\n        {\r\n            function_->getParam(index.row())->setComDirection(DirectionTypes::str2Direction(value.toString(),\r\n                DirectionTypes::DIRECTION_INVALID));\r\n        }\r\n\r\n        else if (index.column() == ApiFunctionColumns::API_FUNC_PARAM_CONTENT_SOURCE)\r\n        {\r\n            if (value.toString().isEmpty())\r\n            {\r\n                function_->getParam(index.row())->setComDirection(DirectionTypes::DIRECTION_INVALID);\r\n                function_->getParam(index.row())->setComTransferType(\"\");\r\n                function_->getParam(index.row())->setDependentParameterIndex(-1);\r\n            }\r\n\r\n            function_->getParam(index.row())->setContentSource(value.toString());\r\n\r\n            emit dataChanged(index, this->index(index.row(), index.column() + 3));\r\n        }\r\n\r\n        else if (index.column() == ApiFunctionColumns::API_FUNC_PARAM_DEPENDENT_PARAM)\r\n        {\r\n            QString text = value.toString();\r\n\r\n            if (text == QLatin1String(\"no\"))\r\n            {\r\n                function_->getParam(index.row())->setDependentParameterIndex(-1);\r\n            }\r\n            else\r\n            {\r\n                function_->getParam(index.row())->setDependentParameterIndex(value.toInt() - 1);\r\n            }\r\n        }\r\n\r\n        else if (index.column() == ApiFunctionColumns::API_FUNC_PARAM_COL_DESC)\r\n        {\r\n            function_->getParam(index.row())->setDescription(value.toString());\r\n        }\r\n\r\n        else\r\n        {\r\n            return false;\r\n        }\r\n\r\n        emit dataChanged(index, index);\r\n        emit contentChanged();\r\n        return true;\r\n    }\r\n    else\r\n    {\r\n        return false;\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ApiFunctionParameterModel::isValid()\r\n//-----------------------------------------------------------------------------\r\nbool ApiFunctionParameterModel::isValid() const\r\n{\r\n    return true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ApiFunctionParameterModel::onAdd()\r\n//-----------------------------------------------------------------------------\r\nvoid ApiFunctionParameterModel::onAdd()\r\n{\r\n    beginInsertRows(QModelIndex(), function_->getParamCount(), function_->getParamCount());\r\n    function_->addParam(QSharedPointer<ApiFunctionParameter>(new ApiFunctionParameter()));\r\n    endInsertRows();\r\n    emit contentChanged();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ApiFunctionParameterModel::onAddItem()\r\n//-----------------------------------------------------------------------------\r\nvoid ApiFunctionParameterModel::onAddItem(QModelIndex const& index)\r\n{\r\n    int row = function_->getParamCount();\r\n\r\n    // if the index is valid then add the item to the correct position\r\n    if (index.isValid())\r\n    {\r\n        row = index.row();\r\n    }\r\n\r\n    beginInsertRows(QModelIndex(), row, row);\r\n    function_->addParam(QSharedPointer<ApiFunctionParameter>(new ApiFunctionParameter()), row);\r\n    endInsertRows();\r\n\r\n    // tell also parent widget that contents have been changed\r\n    emit contentChanged();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ApiFunctionParameterModel::onRemove()\r\n//-----------------------------------------------------------------------------\r\nvoid ApiFunctionParameterModel::onRemove(QModelIndex const& index)\r\n{\r\n    if (!index.isValid() || function_ == 0)\r\n    {\r\n        return;\r\n    }\r\n\r\n    // remove the indexed configurable element\r\n    beginRemoveRows(QModelIndex(), index.row(), index.row());\r\n    function_->removeParam(index.row());\r\n    endRemoveRows();\r\n\r\n    emit contentChanged();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ApiFunctionParameterModel::onRemoveItem()\r\n//-----------------------------------------------------------------------------\r\nvoid ApiFunctionParameterModel::onRemoveItem(QModelIndex const& index)\r\n{\r\n    // don't remove anything if index is invalid\r\n    if (!index.isValid() || function_ == 0 || index.row() < 0 || index.row() >= function_->getParamCount())\r\n    {\r\n        return;\r\n    }\r\n\r\n    // remove the indexed configurable element\r\n    beginRemoveRows(QModelIndex(), index.row(), index.row());\r\n    function_->removeParam(index.row());\r\n    endRemoveRows();\r\n\r\n    emit contentChanged();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ApiFunctionParameterModel::onMoveItem()\r\n//-----------------------------------------------------------------------------\r\nvoid ApiFunctionParameterModel::onMoveItem(QModelIndex const& originalPos, QModelIndex const& newPos)\r\n{\r\n    // if there was no item in the starting point\r\n    if (!originalPos.isValid() || originalPos == newPos || \r\n        originalPos.row() < 0 || originalPos.row() >= function_->getParamCount())\r\n    {\r\n        return;\r\n    }\r\n\r\n    // if the new position is invalid index then put the item last in the table\r\n    if (!newPos.isValid() || newPos.row() < 0 || newPos.row() >= function_->getParamCount())\r\n    {\r\n        beginResetModel();\r\n\r\n        QSharedPointer<ApiFunctionParameter> param = function_->getParam(originalPos.row());\r\n        function_->removeParam(originalPos.row());\r\n        function_->addParam(param);\r\n\r\n        endResetModel();\r\n    }\r\n    // if both indexes were valid\r\n    else\r\n    {\r\n        beginResetModel();\r\n        \r\n        QSharedPointer<ApiFunctionParameter> param = function_->getParam(originalPos.row());\r\n        function_->removeParam(originalPos.row());\r\n        function_->addParam(param, newPos.row());\r\n\r\n        endResetModel();\r\n    }\r\n\r\n    emit contentChanged();\r\n}"
  },
  {
    "path": "editors/ApiDefinitionEditor/ApiFunctionParameterModel.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ApiFunctionParameterModel.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Joni-Matti Maatta\r\n// Date: 18.4.2012\r\n//\r\n// Description:\r\n// Model for API function parameters.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef APIFUNCTIONPARAMETERMODEL_H\r\n#define APIFUNCTIONPARAMETERMODEL_H\r\n\r\n#include <QAbstractTableModel>\r\n#include <QMap>\r\n#include <QList>\r\n#include <QString>\r\n#include <QSharedPointer>\r\n\r\nclass ApiFunction;\r\nclass ApiFunctionParameter;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! ApiFunctionParameterModel class.\r\n//-----------------------------------------------------------------------------\r\nclass ApiFunctionParameterModel : public QAbstractTableModel\r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n    /*!\r\n     *  Constructor.\r\n     *\r\n     *    @param [in] parent The parent object.\r\n\t */\r\n\tApiFunctionParameterModel(QObject *parent);\r\n\r\n\t/*!\r\n     *  Destructor.\r\n     */\r\n\tvirtual ~ApiFunctionParameterModel();\r\n\r\n    /*!\r\n     *  Sets the edited API function.\r\n     *\r\n     *    @param [in] function The function to edit.\r\n     */\r\n    void setFunction(QSharedPointer<ApiFunction> function);\r\n\r\n    /*!\r\n     *  Returns the number of rows in the model.\r\n\t *\r\n\t *    @param [in] parent Model index of the parent of the item. Must be invalid\r\n\t *                         because this is not hierarchical model.\r\n\t *\r\n\t *    @return Number of rows currently in the model.\r\n\t */\r\n\tvirtual int rowCount(QModelIndex const& parent = QModelIndex()) const;\r\n\r\n\t/*! \r\n     *  Returns the number of columns in the model.\r\n\t *\r\n\t *    @param [in] parent Model index of the parent of the item. Must be invalid\r\n\t *                         because this is not hierarchical model.\r\n\t *\r\n\t *    @return Always returns API_FUNC_PARAM_COL_COUNT.\r\n\t */\r\n\tvirtual int columnCount(QModelIndex const& parent = QModelIndex()) const;\r\n\r\n\t/*!\r\n     *  Returns the data for the specified item for specified role.\r\n\t *\r\n\t *    @param [in] index  Identifies the item that's data is wanted.\r\n\t *    @param [in] role   Specifies what kind of data is wanted\r\n\t *\r\n\t *    @return QVariant containing the data.\r\n\t */\r\n\tvirtual QVariant data(QModelIndex const& index, int role = Qt::DisplayRole) const;\r\n\r\n\t/*!\r\n     *  Returns the data for the headers.\r\n\t *\r\n\t *    @param [in] section      The column that's header is wanted\r\n\t *    @param [in] orientation  Only Qt::Horizontal is supported\r\n\t *    @param [in] role         Specified the type of data that is wanted.\r\n\t *\r\n\t *    @return QVariant containing the header data.\r\n\t */\r\n\tvirtual QVariant headerData(int section, Qt::Orientation orientation, \r\n\t\t                        int role = Qt::DisplayRole) const;\r\n\r\n\t/*!\r\n     *  Returns information on how specified item can be handled.\r\n\t *\r\n\t *    @param [in] index Specifies the item that's flags are wanted.\r\n\t *\r\n\t *    @return Item flags that define how object can be handled.\r\n\t */\r\n\tvirtual Qt::ItemFlags flags(QModelIndex const& index) const;\r\n\r\n\t/*!\r\n     *  Returns the data for specified item.\r\n\t *\r\n\t *    @param [in] index  Specifies the item that's data is modified\r\n\t *    @param [in] value  The value to be set.\r\n\t *    @param [in] role   The role that is trying to modify the data. Only Qt::EditRole is supported.\r\n\t *\r\n\t *    @return True if data was successfully set.\r\n\t */\r\n\tvirtual bool setData(QModelIndex const& index, QVariant const& value, int role = Qt::EditRole);\r\n\r\n\t/*!\r\n     *  Checks whether the model is in valid state or not.\r\n     *\r\n\t *    @return True if all items in model are valid.\r\n\t */\r\n\tbool isValid() const;\r\n\r\npublic slots:\r\n    void onAdd();\r\n    void onAddItem(QModelIndex const& index);\r\n    void onRemove(QModelIndex const& index);\r\n    void onRemoveItem(QModelIndex const& index);\r\n    void onMoveItem( const QModelIndex& originalPos, const QModelIndex& newPos );\r\n\r\nsignals:\r\n\t//! Emitted when contents of the model change.\r\n\tvoid contentChanged();\r\n\r\n\t//! Prints an error message to the user.\r\n\tvoid errorMessage(const QString& msg) const;\r\n\t\r\n\t//! Prints a notification to user.\r\n\tvoid noticeMessage(const QString& msg) const;\r\n\r\nprivate:\r\n    // Disable copying.\r\n    ApiFunctionParameterModel(ApiFunctionParameterModel const& rhs);\r\n    ApiFunctionParameterModel& operator=(ApiFunctionParameterModel const& rhs);\r\n    \r\n    //! NameValuePair type.\r\n    typedef QPair<QString, QString> NameValuePair;\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\t\r\n\t//! The API function being edited.\r\n    QSharedPointer<ApiFunction> function_;\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n\r\n#endif // APIFUNCTIONPARAMETERMODEL_H\r\n"
  },
  {
    "path": "editors/BusDefinitionEditor/BusDefinitionEditor.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: BusDefinitionEditor.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 20.6.2011\r\n//\r\n// Description:\r\n// Bus defition editor is an editor for Bus- and Abstraction definitions.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"BusDefinitionEditor.h\"\r\n\r\n#include <IPXACTmodels/common/VLNV.h>\r\n#include <IPXACTmodels/BusDefinition/validators/BusDefinitionValidator.h>\r\n#include <IPXACTmodels/AbstractionDefinition/validators/AbstractionDefinitionValidator.h>\r\n\r\n#include <common/dialogs/newObjectDialog/newobjectdialog.h>\r\n#include <common/widgets/summaryLabel/summarylabel.h>\r\n\r\n#include <editors/ComponentEditor/parameterReferenceTree/ParameterReferenceTreeWindow.h>\r\n#include <editors/BusDefinitionEditor/BusDefinitionParameterReferenceTree.h>\r\n\r\n#include <KactusAPI/include/SystemVerilogExpressionParser.h>\r\n#include <KactusAPI/include/PortAbstractionInterface.h>\r\n#include <KactusAPI/include/ExpressionFormatter.h>\r\n#include <KactusAPI/include/ListParameterFinder.h>\r\n\r\n#include <QApplication>\r\n#include <QFile>\r\n#include <QFileDialog>\r\n#include <QHBoxLayout>\r\n#include <QScrollArea>\r\n#include <QSplitter>\r\n#include <QVBoxLayout>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusDefinitionEditor::BusDefinitionEditor()\r\n//-----------------------------------------------------------------------------\r\nBusDefinitionEditor::BusDefinitionEditor(QWidget *parent, LibraryInterface* libHandler,\r\n    QSharedPointer<BusDefinition> busDef):\r\nTabDocument(parent, libHandler, DOC_PROTECTION_SUPPORT),\r\nbusDef_(busDef),\r\nexpressionParser_(new SystemVerilogExpressionParser()),\r\nbusDefinitionValidator_(new BusDefinitionValidator(libHandler, expressionParser_)),\r\nbusDefParameterFinder_(new ListParameterFinder()),\r\nexpressionFormatter_(new ExpressionFormatter(busDefParameterFinder_)),\r\nreferenceCounter_(new ParameterReferenceCounter(busDefParameterFinder_)),\r\nparameterReferenceTree_(new BusDefinitionParameterReferenceTree(busDef, expressionFormatter_, referenceCounter_, this)),\r\nreferenceTreeWindow_(new ParameterReferenceTreeWindow(parameterReferenceTree_, this)),\r\nbusDefGroup_(libHandler, expressionFormatter_, busDefParameterFinder_, this)\r\n{\r\n    setDocumentType(DocumentType::BUS_DEFINITION);\r\n\r\n    if (busDef_)\r\n    {\r\n        busDefGroup_.setBusDef(busDef_);\r\n\r\n        VLNV vlnv = busDef_->getVlnv();\r\n        setDocumentName(vlnv.getName() + \" (\" + vlnv.getVersion() + \")\");\r\n\r\n        // Open in unlocked mode by default only if the version is draft.\r\n        setProtection(vlnv.getVersion() != \"draft\");\r\n    } \r\n    else\r\n    {\r\n        setProtection(true);\r\n    }    \r\n\r\n    busDefParameterFinder_->setParameterList(busDef_->getParameters());\r\n\r\n    setupLayout();\r\n\r\n    connect(&busDefGroup_, SIGNAL(contentChanged()), this, SIGNAL(contentChanged()), Qt::UniqueConnection);\r\n\r\n    connect(&busDefGroup_, SIGNAL(increaseReferences(QString)),\r\n        referenceCounter_.data(), SLOT(increaseReferenceCount(QString)), Qt::UniqueConnection);\r\n\r\n    connect(&busDefGroup_, SIGNAL(decreaseReferences(QString)),\r\n        referenceCounter_.data(), SLOT(decreaseReferenceCount(QString)), Qt::UniqueConnection);\r\n\r\n    connect(&busDefGroup_, SIGNAL(openReferenceTree(QString const&, QString const&)),\r\n        referenceTreeWindow_, SLOT(openReferenceTree(QString const&, QString const&)), Qt::UniqueConnection);\r\n\r\n    connect(&busDefGroup_, SIGNAL(recalculateReferencesToParameters(QVector<QString> const&, AbstractParameterInterface*)),\r\n        referenceCounter_.data(), SLOT(recalculateReferencesToParameters(QVector<QString> const&, AbstractParameterInterface*)), Qt::UniqueConnection);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusDefinitionEditor::getIdentifyingVLNV()\r\n//-----------------------------------------------------------------------------\r\nVLNV BusDefinitionEditor::getIdentifyingVLNV() const\r\n{\r\n    return getDocumentVLNV();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusDefinitionEditor::refresh()\r\n//-----------------------------------------------------------------------------\r\nvoid BusDefinitionEditor::refresh()\r\n{\r\n    QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));\r\n\r\n    if (busDef_)\r\n    {\r\n        busDef_ = getLibHandler()->getModel(busDef_->getVlnv()).dynamicCast<BusDefinition>();\r\n        busDefGroup_.setBusDef(busDef_);\r\n    } \r\n\r\n    // The document is no longer modified.\r\n    setModified(false);\r\n    TabDocument::refresh();\r\n\r\n    QApplication::restoreOverrideCursor();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: setProtection()\r\n//-----------------------------------------------------------------------------\r\nvoid BusDefinitionEditor::setProtection(bool locked)\r\n{\r\n    TabDocument::setProtection(locked);\r\n    setEnabled(!locked);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusDefinitionEditor::getDocumentVLNV()\r\n//-----------------------------------------------------------------------------\r\nVLNV BusDefinitionEditor::getDocumentVLNV() const\r\n{\r\n    // If bus definition is being edited then use it as identifier.\r\n    if (busDef_)\r\n    {\r\n        return busDef_->getVlnv();\t\r\n    }\r\n    else\r\n    {\r\n        return VLNV();\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusDefinitionEditor::setBusDef()\r\n//-----------------------------------------------------------------------------\r\nvoid BusDefinitionEditor::setBusDef(QSharedPointer<BusDefinition> busDef)\r\n{\r\n    Q_ASSERT_X(busDef, \"BusDefinitionEditor setBusDef\", \"Null Bus Definition pointer given as parameter\");\r\n\r\n    busDef_ = busDef;\r\n\r\n    busDefGroup_.setBusDef(busDef_);\r\n    busDefGroup_.setDisabled(false);\r\n    busDefParameterFinder_->setParameterList(busDef->getParameters());\r\n\r\n    VLNV vlnv = busDef_->getVlnv();\r\n    setDocumentName(vlnv.getName() + \" (\" + vlnv.getVersion() + \")\");\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusDefinitionEditor::validate()\r\n//-----------------------------------------------------------------------------\r\nbool BusDefinitionEditor::validate(QVector<QString>& errorList)\r\n{\r\n    QVector<QString> busDefinitionErrors;\r\n    busDefinitionValidator_->findErrorsIn(busDefinitionErrors, busDef_);\r\n\r\n    if (busDefinitionErrors.isEmpty() == false)\r\n    {\r\n        errorList.append(busDefinitionErrors);\r\n    }\r\n\r\n    return busDefinitionErrors.isEmpty();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusDefinitionEditor::save()\r\n//-----------------------------------------------------------------------------\r\nbool BusDefinitionEditor::save()\r\n{\r\n    getLibHandler()->writeModelToFile(busDef_);\r\n\r\n    return TabDocument::save();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusDefinitionEditor::saveAs()\r\n//-----------------------------------------------------------------------------\r\nbool BusDefinitionEditor::saveAs()\r\n{\r\n    // Ask the user for a new VLNV along with the directory.\r\n    VLNV vlnv;\r\n\r\n    VLNV busDefVLNV;\r\n    QString busDirectory;\r\n\r\n    VLNV absDefVLNV;\r\n    QString absDirectory;\r\n\r\n    if (!NewObjectDialog::saveAsDialog(this, getLibHandler(), busDef_->getVlnv(), vlnv, busDirectory))\r\n    {\r\n        return false;\r\n    }\r\n\r\n    busDefVLNV = vlnv;\r\n    busDefVLNV.setType(VLNV::BUSDEFINITION);\r\n    busDef_->setVlnv(busDefVLNV);\r\n    \r\n    getLibHandler()->writeModelToFile(busDirectory, busDef_);\r\n    setDocumentName(vlnv.getName() + \" (\" + vlnv.getVersion() + \")\");\r\n    return TabDocument::saveAs();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusDefinitionEditor::showEvent()\r\n//-----------------------------------------------------------------------------\r\nvoid BusDefinitionEditor::showEvent(QShowEvent* event)\r\n{\r\n    TabDocument::showEvent(event);\r\n\r\n    if (busDef_->getRevision() == Document::Revision::Std22)\r\n    {\r\n        emit helpUrlRequested(\"definitions/busdefinition2022.html\");\r\n    }\r\n    else\r\n    {\r\n        emit helpUrlRequested(\"definitions/busdefinition.html\");\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusDefinitionEditor::setupLayout()\r\n//-----------------------------------------------------------------------------\r\nvoid BusDefinitionEditor::setupLayout()\r\n{    \r\n    QWidget* busDefGroup = new QWidget(this);\r\n    QVBoxLayout* busLayout = new QVBoxLayout(busDefGroup);\r\n    busLayout->addWidget(new SummaryLabel(tr(\"Bus definition\"), this), 0, Qt::AlignCenter);\r\n    busLayout->addWidget(&busDefGroup_);\r\n    busLayout->setContentsMargins(0, 0, 0, 0);\r\n\r\n    QHBoxLayout* topLayout = new QHBoxLayout(this);\r\n    topLayout->addWidget(busDefGroup);\r\n}\r\n"
  },
  {
    "path": "editors/BusDefinitionEditor/BusDefinitionEditor.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: BusDefinitionEditor.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 20.6.2011\r\n//\r\n// Description:\r\n// Bus defition editor is an editor for Bus- and Abstraction definitions.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef BUSDEFINITIONEDITOR_H\r\n#define BUSDEFINITIONEDITOR_H\r\n\r\n#include <common/widgets/tabDocument/TabDocument.h>\r\n\r\n#include <IPXACTmodels/BusDefinition/BusDefinition.h>\r\n\r\n#include <KactusAPI/include/LibraryInterface.h>\r\n\r\n#include <editors/ComponentEditor/referenceCounter/ParameterReferenceCounter.h>\r\n\r\n#include \"busdefgroup.h\"\r\n\r\n#include <QSharedPointer>\r\n\r\nclass BusDefinitionValidator;\r\nclass ExpressionParser;\r\nclass ExpressionFormatter;\r\nclass BusDefinitionParameterReferenceTree;\r\nclass ParameterReferenceTreeWindow;\r\nclass ListParameterFinder;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Bus Editor is editor for Bus- and Abstraction definition.\r\n//-----------------------------------------------------------------------------\r\nclass BusDefinitionEditor : public TabDocument\r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\r\n\t/*!\r\n     *  The constructor.\r\n\t *\r\n\t *    @param [in] parent          The owner of this widget.\r\n\t *    @param [in] libHandler      The instance that manages library.\r\n\t *    @param [in] busDef          The bus definition to edit.\r\n     */\r\n\tBusDefinitionEditor(QWidget *parent, LibraryInterface* libHandler, QSharedPointer<BusDefinition> busDef);\r\n\t\r\n\t/*!\r\n     *  The destructor.\r\n     */\r\n\t~BusDefinitionEditor() override = default;\r\n\r\n    //! No copying. No assignment.\r\n    BusDefinitionEditor(const BusDefinitionEditor& other) = delete;\r\n    BusDefinitionEditor& operator=(const BusDefinitionEditor& other) = delete;\r\n\r\n\t/*!\r\n     *  Get the VLNV that can be used to identify the Bus.\r\n\t *\r\n\t *    @return The VLNV that identifies the Bus.\r\n     */\r\n\tVLNV getIdentifyingVLNV() const override;\r\n\r\n    /*!\r\n     *  Refreshes the editor.\r\n     */\r\n    void refresh() override;\r\n\r\n    /*!\r\n     *  Sets the protection state of the document.\r\n     *\r\n     *    @param [in] locked True for locked state; false for unlocked.\r\n     */\r\n    void setProtection(bool locked) override;\r\n\r\n\t/*!\r\n     *  Get the vlnv of the current bus definition.\r\n\t *\r\n\t *    @return VLNV of the bus definition/abstraction definition being edited.\r\n\t */\r\n\tVLNV getDocumentVLNV() const override;\r\n\r\n    /*!\r\n     *  Sets the edited bus definition.\r\n     * \r\n     *    @param [in] busDef   The bus definition to set. Must not be NULL.\r\n     */\r\n    void setBusDef(QSharedPointer<BusDefinition> busDef);\r\n\r\n\r\npublic slots:\r\n\r\n    /*!\r\n     *  Validates the document against the IP-XACT standard.\r\n     *\r\n     *    @param [out] errorList Error message list for reporting standard violations.\r\n     *\r\n     *    @return True if the document is valid. False if there were any violations.\r\n     */\r\n    virtual bool validate(QVector<QString>& errorList);\r\n\r\n\t/*!\r\n     *  Saves the document and resets the modified state.\r\n     */\r\n\tvirtual bool save();\r\n\r\n\t/*!\r\n     *  Saves the document as new object and resets modifies state\r\n     */\r\n\tvirtual bool saveAs();\r\n\r\nsignals:\r\n\r\n    /*!\r\n     *  Inform that a port abstraction has been removed.\r\n     *\r\n     *    @param [in] portName    Name of the removed port abstraction.\r\n     *    @param [in] mode        Mode of the removed port abstraction.\r\n     */\r\n    void portRemoved(QString const& portName, General::InterfaceMode const mode);\r\n\r\nprotected:\r\n    \r\n    /*!\r\n     *  Called when the editor is shown.\r\n     *\r\n     *    @param [in] event   The show event.\r\n     */\r\n    virtual void showEvent(QShowEvent* event);\r\n\r\nprivate:\r\n\r\n\t/*!\r\n     *  Set the layout of the widget\r\n     */\r\n\tvoid setupLayout();\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n\t//! The original bus definition to use when saving.\r\n\tQSharedPointer<BusDefinition> busDef_ = nullptr;\r\n\r\n    //! Parser for expressions in definitions.\r\n    QSharedPointer<ExpressionParser> expressionParser_ = nullptr;\r\n\r\n    //! Validator for bus definition.\r\n    QSharedPointer<BusDefinitionValidator> busDefinitionValidator_ =nullptr;\r\n\r\n    //! Flag for save status on bus definition.\r\n    bool busDefinitionSaved_= false;\r\n\r\n    //! Parameter finder for bus definitions.\r\n    QSharedPointer<ListParameterFinder> busDefParameterFinder_;\r\n    \r\n    //! Expression formatter to use.\r\n    QSharedPointer<ExpressionFormatter> expressionFormatter_;\r\n\r\n    //! Reference counter for the bus definition parameter references.\r\n    QSharedPointer<ParameterReferenceCounter> referenceCounter_;\r\n    \r\n    //! The parameter reference tree to use.\r\n    BusDefinitionParameterReferenceTree* parameterReferenceTree_;\r\n\r\n    //! The parameter reference window.\r\n    ParameterReferenceTreeWindow* referenceTreeWindow_;\r\n\r\n    //! Group containing elements to edit bus definition\r\n\tBusDefGroup busDefGroup_;\r\n};\r\n\r\n#endif // BUSDEFINITIONEDITOR_H\r\n"
  },
  {
    "path": "editors/BusDefinitionEditor/BusDefinitionParameterReferenceTree.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: BusDefinitionParameterReferenceTree.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Anton Hagqvist\n// Date: 22.08.2024\n//\n// Description:\n// Tree widget for displaying references to a parameter within a bus definition.\n//-----------------------------------------------------------------------------\n\n\n#include \"BusDefinitionParameterReferenceTree.h\"\n\n#include <IPXACTmodels/BusDefinition/BusDefinition.h>\n\n#include <editors/ComponentEditor/referenceCounter/ParameterReferenceCounter.h>\n\n//-----------------------------------------------------------------------------\n// Function: BusDefinitionParameterReferenceTree::BusDefinitionParameterReferenceTree()\n//-----------------------------------------------------------------------------\nBusDefinitionParameterReferenceTree::BusDefinitionParameterReferenceTree(QSharedPointer<BusDefinition> busDef,\n    QSharedPointer<ExpressionFormatter> expressionFormatter,\n    QSharedPointer<ParameterReferenceCounter> referenceCounter, QWidget* parent):\nParameterReferenceTree(expressionFormatter, parent),\nbusDef_(busDef),\nreferenceCounter_(referenceCounter)\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: BusDefinitionParameterReferenceTree::setupTree()\n//-----------------------------------------------------------------------------\nvoid BusDefinitionParameterReferenceTree::setupTree()\n{\n    if (!busDef_)\n    {\n        createTopItem(\"Bus definition does not exist.\");\n        return;\n    }\n\n    if (referenceCounter_->countReferencesInParameters(getTargetID(), busDef_->getParameters()) > 0)\n    {\n        QTreeWidgetItem* topParametersItem = createTopItem(\"Parameters\");\n        createParameterReferences(busDef_->getParameters(), topParametersItem);\n    }\n\n    if (topLevelItemCount() == 0)\n    {\n        createTopItem(\"No references found.\");\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: BusDefinitionParameterReferenceTree::getReferenceCounter()\n//-----------------------------------------------------------------------------\nQSharedPointer<ParameterReferenceCounter> BusDefinitionParameterReferenceTree::getReferenceCounter() const\n{\n    return referenceCounter_;\n}\n"
  },
  {
    "path": "editors/BusDefinitionEditor/BusDefinitionParameterReferenceTree.h",
    "content": "//-----------------------------------------------------------------------------\n// File: BusDefinitionParameterReferenceTree.h\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Anton Hagqvist\n// Date: 22.08.2024\n//\n// Description:\n// Tree widget for displaying references to a parameter within a bus definition.\n//-----------------------------------------------------------------------------\n\n#ifndef BUSDEFINITIONPARAMETERREFERENCETREE_H\n#define BUSDEFINITIONPARAMETERREFERENCETREE_H\n\n#include <editors/ComponentEditor/parameterReferenceTree/ParameterReferenceTree.h>\n\nclass ParameterReferenceCounter;\nclass BusDefinition;\n\nclass BusDefinitionParameterReferenceTree : public ParameterReferenceTree\n{\n    Q_OBJECT\n\npublic:\n\n    /*!\n     *   The constructor.\n     *\n     *    @param [in] busDef                  The bus definition whose references to display.\n     *    @param [in] expressionFormatter     Formatter for expressions.\n     *    @param [in] referenceCounter        Calculator for parameter references.\n     *    @param [in] parent                  The parent widget.\n     */\n    BusDefinitionParameterReferenceTree(QSharedPointer<BusDefinition> busDef, QSharedPointer<ExpressionFormatter> expressionFormatter,\n        QSharedPointer<ParameterReferenceCounter> referenceCounter, QWidget* parent = nullptr);\n\n    virtual ~BusDefinitionParameterReferenceTree() = default;\n    \n    /*\n     *  No copying or assignment.\n     */\n    BusDefinitionParameterReferenceTree(BusDefinitionParameterReferenceTree& other) = delete;\n    BusDefinitionParameterReferenceTree& operator=(BusDefinitionParameterReferenceTree& other) = delete;\n\nprivate:\n\n    /*!\n     *  Setup the reference tree.\n     */\n    void setupTree();\n\n    /*!\n     *  Get the parameter reference calculator.\n     */\n    QSharedPointer<ParameterReferenceCounter> getReferenceCounter() const;\n\n    //! The parameter reference counter to use.\n    QSharedPointer<ParameterReferenceCounter> referenceCounter_;\n\n    //! The bus definition containing the referenced parameter.\n    QSharedPointer<BusDefinition> busDef_;\n\n};\n\n#endif // BUSDEFINITIONPARAMETERREFERENCETREE_H\n"
  },
  {
    "path": "editors/BusDefinitionEditor/SystemGroupListEditor.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: SystemGroupListEditor.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 26.06.2018\n//\n// Description:\n// List editor for bus interface system groups.\n//-----------------------------------------------------------------------------\n\n#include \"SystemGroupListEditor.h\"\n\n#include <KactusAPI/include/LibraryInterface.h>\n\n#include <IPXACTmodels/common/VLNV.h>\n#include <IPXACTmodels/BusDefinition/BusDefinition.h>\n\n#include <IPXACTmodels/utilities/BusDefinitionUtils.h>\n\n#include <QContextMenuEvent>\n#include <QMenu>\n\n//-----------------------------------------------------------------------------\n// Function: SystemGroupListEditor::SystemGroupListEditor()\n//-----------------------------------------------------------------------------\nSystemGroupListEditor::SystemGroupListEditor(LibraryInterface* library, QWidget *parent):\nQListWidget(parent),\naddAction_(new QAction(tr(\"Add system group\"), this)),\nremoveAction_(new QAction(tr(\"Remove system group\"), this)),\nlibrary_(library)\n{\n    setSelectionMode(QAbstractItemView::SingleSelection);\n    setDragEnabled(true);\n    setDragDropMode(QAbstractItemView::InternalMove);\n\n    connect(addAction_, SIGNAL(triggered()), this, SLOT(onAddNewAction()), Qt::UniqueConnection);\n    connect(removeAction_, SIGNAL(triggered()), this, SLOT(onRemoveAction()), Qt::UniqueConnection);\n\n    connect(this, SIGNAL(itemChanged(QListWidgetItem*)), this, SIGNAL(contentChanged()), Qt::UniqueConnection);\n}\n\n//-----------------------------------------------------------------------------\n// Function: SystemGroupListEditor::setItems()\n//-----------------------------------------------------------------------------\nvoid SystemGroupListEditor::setItems(QSharedPointer<BusDefinition> busDefinition)\n{\n    blockSignals(true);\n\n    while (count() > 0)\n    {\n        takeItem(0);\n    }\n\n    QStringList extendedSystemNames = getExtendedSystemGroupNames(busDefinition);\n    foreach(QString extendSystemGroup, extendedSystemNames)\n    {\n        QListWidgetItem* newExtendItem = new QListWidgetItem(extendSystemGroup, this);\n        newExtendItem->setFlags(newExtendItem->flags() & ~Qt::ItemIsEnabled);\n    }\n\n    foreach(QString systemGroup, busDefinition->getSystemGroupNames())\n    {\n        if (!extendedSystemNames.contains(systemGroup))\n        {\n            QListWidgetItem* newItem = new QListWidgetItem(systemGroup, this);\n            newItem->setFlags(newItem->flags() | Qt::ItemIsEditable);\n        }\n    }\n\n    blockSignals(false);\n}\n\n//-----------------------------------------------------------------------------\n// Function: SystemGroupListEditor::getExtendedSystemGroupNames()\n//-----------------------------------------------------------------------------\nQStringList SystemGroupListEditor::getExtendedSystemGroupNames(QSharedPointer<BusDefinition> busDefinition) const\n{\n    QStringList extendedList;\n\n    VLNV extendVLNV = busDefinition->getExtends();\n    if (extendVLNV.isValid() && extendVLNV.getType() == VLNV::BUSDEFINITION)\n    {\n        QSharedPointer<Document> extendDocument = library_->getModel(extendVLNV);\n        if (extendDocument)\n        {\n            QSharedPointer<BusDefinition> extendBus = extendDocument.dynamicCast<BusDefinition>();\n            if (extendBus)\n            {\n                extendedList.append(BusDefinitionUtils::getSystemGroups(extendBus, library_));\n            }\n        }\n    }\n\n    return extendedList;\n}\n\n//-----------------------------------------------------------------------------\n// Function: SystemGroupListEditor::mouseDoubleClickEvent()\n//-----------------------------------------------------------------------------\nvoid SystemGroupListEditor::mouseDoubleClickEvent(QMouseEvent *event)\n{\n    QListWidgetItem* selectedItem = itemAt(event->pos());\n    if (!selectedItem)\n    {\n        onAddNewAction();\n    }\n    \n    QListWidget::mouseDoubleClickEvent(event);\n}\n\n//-----------------------------------------------------------------------------\n// Function: SystemGroupListEditor::contextMenuEvent()\n//-----------------------------------------------------------------------------\nvoid SystemGroupListEditor::contextMenuEvent(QContextMenuEvent* event)\n{\n    QMenu menu(this);\n    menu.addAction(addAction_);\n\n    QListWidgetItem* item = itemAt(event->pos());\n    if (item && item->flags() & Qt::ItemIsEnabled)\n    {\n        menu.addAction(removeAction_);\n    }\n\n    menu.exec(event->globalPos());\n    event->accept();\n}\n\n//-----------------------------------------------------------------------------\n// Function: SystemGroupListEditor::onAddNewAction()\n//-----------------------------------------------------------------------------\nvoid SystemGroupListEditor::onAddNewAction()\n{\n    QListWidgetItem* newItem = new QListWidgetItem(\"new item\", this);\n    newItem->setFlags(newItem->flags() | Qt::ItemIsEditable);\n\n    emit contentChanged();\n}\n\n//-----------------------------------------------------------------------------\n// Function: SystemGroupListEditor::onRemoveAction()\n//-----------------------------------------------------------------------------\nvoid SystemGroupListEditor::onRemoveAction()\n{\n    QModelIndex removedIndex = currentIndex();\n    if (removedIndex.isValid())\n    {\n        takeItem(removedIndex.row());\n    }\n\n    emit contentChanged();\n}\n"
  },
  {
    "path": "editors/BusDefinitionEditor/SystemGroupListEditor.h",
    "content": "//-----------------------------------------------------------------------------\n// File: SystemGroupListEditor.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 26.06.2018\n//\n// Description:\n// List editor for bus interface system groups.\n//-----------------------------------------------------------------------------\n\n#ifndef SYSTEMGROUPLISTEDITOR_H\n#define SYSTEMGROUPLISTEDITOR_H\n\n#include <QListWidget>\n#include <QAction>\n\nclass BusDefinition;\nclass LibraryInterface;\n\n//-----------------------------------------------------------------------------\n//! List editor for bus interface system groups.\n//-----------------------------------------------------------------------------\nclass SystemGroupListEditor : public QListWidget\n{\n\tQ_OBJECT\n\npublic:\n\n\t/*!\n     *  The constructor.\n\t *\n     *    @param [in] library     Interface to the library.\n\t *    @param [in] parent      The owner of this widget.\n\t */\n\tSystemGroupListEditor(LibraryInterface* library, QWidget *parent);\n\n    /*!\n     *  The destructor.\n     */\n    virtual ~SystemGroupListEditor() = default;\n\n\t/*!\n     *  Set the bus definition that is being edited.\n\t *\n\t *    @param [in] busDefinition   The bus definition\n\t */\n    void setItems(QSharedPointer<BusDefinition> busDefinition);\n\nsignals:\n\n\t/*!\n     *  Emitted when user changes the state of one of the elements.\n     */\n\tvoid contentChanged();\n\nprotected:\n\n    /*!\n     *  Handles the context menu events.\n     *\n     *    @param [in] event   The current context menu event.\n     */\n    virtual void contextMenuEvent(QContextMenuEvent* event);\n\n    /*!\n     *  Handles the double click events.\n     *\n     *    @param [in] event   The current double click event.\n     */\n    virtual void mouseDoubleClickEvent(QMouseEvent *event);\n\nprivate slots:\n\n    /*!\n     *  Handles the creation of new system group items.\n     */\n    void onAddNewAction();\n\n    /*!\n     *  Handles the removal of system group items.\n     */\n    void onRemoveAction();\n\nprivate:\n\t//! No copying. No assignment.\n\tSystemGroupListEditor(const SystemGroupListEditor& other);\n\tSystemGroupListEditor& operator=(const SystemGroupListEditor& other);\n\n    /*!\n     *  Get the system group names from the extended bus definitions.\n     *\n     *    @param [in] busDefinition   The selected bus definition.\n     *\n     *    @return List of the extended bus definition system group names.\n     */\n    QStringList getExtendedSystemGroupNames(QSharedPointer<BusDefinition> busDefinition) const;\n\n    //-----------------------------------------------------------------------------\n    // Data.\n    //-----------------------------------------------------------------------------\n\n    //! Action for creating new system group names.\n    QAction* addAction_;\n\n    //! Action for removing system group names.\n    QAction* removeAction_;\n\n    //! The library interface.\n    LibraryInterface* library_;\n};\n\n#endif // SYSTEMGROUPLISTEDITOR_H\n"
  },
  {
    "path": "editors/BusDefinitionEditor/busdefgroup.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: busdefgroup.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 21.6.2011\r\n//\r\n// Description:\r\n// BusDefGroup contains elements to set the properties of a Bus Definition.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"busdefgroup.h\"\r\n\r\n#include <IPXACTmodels/utilities/BusDefinitionUtils.h>\r\n\r\n#include <common/widgets/vlnvDisplayer/vlnvdisplayer.h>\r\n#include <common/widgets/vlnvEditor/vlnveditor.h>\r\n#include <common/widgets/ParameterGroupBox/parametergroupbox.h>\r\n\r\n#include <editors/common/DocumentNameGroupEditor.h>\r\n\r\n#include <KactusAPI/include/LibraryInterface.h>\r\n\r\n#include <KactusAPI/include/ExpressionFormatter.h>\r\n#include <KactusAPI/include/ParameterFinder.h>\r\n\r\n#include <QVBoxLayout>\r\n#include <QHBoxLayout>\r\n#include <QFormLayout>\r\n#include <QRegularExpressionValidator>\r\n#include <QRegularExpression>\r\n#include <QSizePolicy>\r\n#include <QLabel>\r\n#include <QSplitter>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusDefGroup::BusDefGroup()\r\n//-----------------------------------------------------------------------------\r\nBusDefGroup::BusDefGroup(LibraryInterface* libraryHandler, QSharedPointer<ExpressionFormatter> expressionFormatter,\r\n    QSharedPointer<ParameterFinder> parameterFinder, QWidget *parent) :\r\nQWidget(parent),\r\nlibrary_(libraryHandler),\r\nbusDef_(),\r\ndirectConnection_(tr(\"Allow direct connections\"), this),\r\nisBroadcast_(tr(\"Support broadcast\"), this),\r\nisAddressable_(tr(\"Addressable bus\"), this),\r\nmaxInitiatorsEditor_(this),\r\nmaxTargetsEditor_(this),\r\nsystemGroupEditor_(libraryHandler, this),\r\ndocumentNameGroupEditor_(this),\r\nextendEditor_(new VLNVEditor(VLNV::BUSDEFINITION, libraryHandler, parent, this))\r\n{\r\n    extendEditor_->setTitle(QStringLiteral(\"Extended bus definition\"));\r\n    extendEditor_->setMandatory(false);\r\n\r\n    QRegularExpression numberExpression(QString(\"[0-9]*\"));\r\n    QRegularExpressionValidator* numberValidator = new QRegularExpressionValidator(numberExpression, this);\r\n    maxInitiatorsEditor_.setValidator(numberValidator);\r\n    maxTargetsEditor_.setValidator(numberValidator);\r\n\r\n    maxInitiatorsEditor_.setPlaceholderText(tr(\"unbound\"));\r\n    maxTargetsEditor_.setPlaceholderText(tr(\"unbound\"));\r\n\r\n    documentNameGroupEditor_.setTitle(\"Bus definition\");\r\n\r\n    // Create parameter editor, but set parameters and choices later.\r\n    parameterEditor_ = new ParameterGroupBox(nullptr, nullptr, parameterFinder, expressionFormatter, \r\n        Document::Revision::Unknown, this);\r\n    parameterEditor_->setFlat(true);\r\n\r\n    setupLayout();\r\n\r\n    connect(parameterEditor_, SIGNAL(increaseReferences(QString)),\r\n        this, SIGNAL(increaseReferences(QString)), Qt::UniqueConnection);\r\n    connect(parameterEditor_, SIGNAL(decreaseReferences(QString)),\r\n        this, SIGNAL(decreaseReferences(QString)), Qt::UniqueConnection);\r\n    connect(parameterEditor_, SIGNAL(openReferenceTree(QString const&, QString const&)),\r\n        this, SIGNAL(openReferenceTree(QString const&, QString const&)), Qt::UniqueConnection);\r\n    connect(parameterEditor_, SIGNAL(contentChanged()), this, SIGNAL(contentChanged()), Qt::UniqueConnection);\r\n    connect(parameterEditor_,\r\n        SIGNAL(recalculateReferencesToParameters(QVector<QString> const&, AbstractParameterInterface*)),\r\n        this,\r\n        SIGNAL(recalculateReferencesToParameters(QVector<QString> const&, AbstractParameterInterface*)),\r\n        Qt::UniqueConnection);\r\n\r\n    connect(&maxInitiatorsEditor_, SIGNAL(editingFinished()), this, SLOT(onInitiatorsChanged()), Qt::UniqueConnection);\r\n    connect(&maxTargetsEditor_, SIGNAL(editingFinished()),\tthis, SLOT(onTargetsChanged()), Qt::UniqueConnection);\r\n     \r\n    connect(&directConnection_, SIGNAL(toggled(bool)),\r\n        this, SLOT(onDirectConnectionChanged(bool)), Qt::UniqueConnection);\r\n    connect(&isBroadcast_, SIGNAL(toggled(bool)), this, SLOT(onIsBroadcastChanged(bool)), Qt::UniqueConnection);\r\n    connect(&isAddressable_, SIGNAL(toggled(bool)),\r\n        this, SLOT(onIsAddressableChanged(bool)), Qt::UniqueConnection);\r\n\r\n    connect(&systemGroupEditor_, SIGNAL(contentChanged()),\r\n        this, SLOT(onSystemNamesChanged()), Qt::UniqueConnection);\r\n\r\n    connect(&documentNameGroupEditor_, SIGNAL(contentChanged()), this, SIGNAL(contentChanged()), Qt::UniqueConnection);\r\n\r\n    connect(extendEditor_, SIGNAL(vlnvEdited()), this, SLOT(onExtendChanged()), Qt::UniqueConnection);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusDefGroup::setBusDef()\r\n//-----------------------------------------------------------------------------\r\nvoid BusDefGroup::setBusDef( QSharedPointer<BusDefinition> busDef )\r\n{\r\n    busDef_ = busDef;\r\n    documentNameGroupEditor_.setDocumentNameGroup(busDef, library_->getPath(busDef->getVlnv()));\r\n\r\n    extendEditor_->setVLNV(busDef_->getExtends());\r\n    extendEditor_->setRevisionFilter(true, busDef_->getRevision());\r\n\r\n    if (busDef_->getExtends().isValid())\r\n    {\r\n        setupExtendedBus();\r\n    }\r\n\r\n    directConnection_.setChecked(busDef_->getDirectConnection());\r\n    isBroadcast_.setChecked(busDef_->getBroadcast().toBool());\r\n    isAddressable_.setChecked(busDef_->getIsAddressable());\r\n\r\n    maxInitiatorsEditor_.setText(QString::fromStdString(busDef_->getMaxInitiators()));\r\n    maxTargetsEditor_.setText(QString::fromStdString(busDef_->getMaxTargets()));\r\n\r\n    systemGroupEditor_.setItems(busDef_);\r\n\r\n    parameterEditor_->setNewParameters(busDef->getParameters(), busDef->getChoices(), busDef->getRevision());\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusDefGroup::onDirectConnectionChanged()\r\n//-----------------------------------------------------------------------------\r\nvoid BusDefGroup::onDirectConnectionChanged(bool checked)\r\n{\r\n    busDef_->setDirectConnection(checked);\r\n    emit contentChanged();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusDefGroup::onIsBroadcastChanged()\r\n//-----------------------------------------------------------------------------\r\nvoid BusDefGroup::onIsBroadcastChanged(bool checked)\r\n{\r\n    busDef_->setBroadcast(checked);\r\n    emit contentChanged();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusDefGroup::onIsAddressableChanged()\r\n//-----------------------------------------------------------------------------\r\nvoid BusDefGroup::onIsAddressableChanged(bool checked)\r\n{\r\n    busDef_->setIsAddressable(checked);\r\n    emit contentChanged();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusDefGroup::onInitiatorsChanged()\r\n//-----------------------------------------------------------------------------\r\nvoid BusDefGroup::onInitiatorsChanged()\r\n{\r\n    busDef_->setMaxInitiators(maxInitiatorsEditor_.text().toStdString());\r\n    emit contentChanged();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusDefGroup::onTargetsChanged()\r\n//-----------------------------------------------------------------------------\r\nvoid BusDefGroup::onTargetsChanged()\r\n{\r\n    busDef_->setMaxTargets(maxTargetsEditor_.text().toStdString());\r\n    emit contentChanged();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusDefGroup::onSystemNamesChanged()\r\n//-----------------------------------------------------------------------------\r\nvoid BusDefGroup::onSystemNamesChanged()\r\n{\r\n    QStringList systemGroupNames;\r\n    for (int i = 0; i < systemGroupEditor_.count(); ++i)\r\n    {\r\n        QListWidgetItem* systemItem = systemGroupEditor_.item(i);\r\n        QString systemName = systemItem->text();\r\n        if (!systemGroupNames.contains(systemName))\r\n        {\r\n            systemGroupNames.append(systemName);\r\n        }\r\n    }\r\n\r\n    busDef_->setSystemGroupNames(systemGroupNames);\r\n\r\n    emit contentChanged();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: busdefgroup::onExtendChanged()\r\n//-----------------------------------------------------------------------------\r\nvoid BusDefGroup::onExtendChanged()\r\n{\r\n    VLNV newExtendVLNV = extendEditor_->getVLNV();\r\n\r\n    removeSystemGroupsFromExtendedDefinition();\r\n\r\n    busDef_->setExtends(extendEditor_->getVLNV());\r\n    setupExtendedBus();\r\n\r\n    systemGroupEditor_.setItems(busDef_);\r\n    onSystemNamesChanged();\r\n\r\n    emit contentChanged();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: busdefgroup::removeSystemGroupsFromExtendedDefinition()\r\n//-----------------------------------------------------------------------------\r\nvoid BusDefGroup::removeSystemGroupsFromExtendedDefinition()\r\n{\r\n    QSharedPointer<const BusDefinition> extendedBus = getExtendedBus(busDef_);\r\n    if (extendedBus)\r\n    {\r\n        QStringList currentSystemGroups = busDef_->getSystemGroupNames();\r\n        QStringList extendSystemGroups = BusDefinitionUtils::getSystemGroups(extendedBus, library_);\r\n        for (auto extendSystem : extendSystemGroups)\r\n        {\r\n            if (currentSystemGroups.contains(extendSystem))\r\n            {\r\n                currentSystemGroups.removeAll(extendSystem);\r\n            }\r\n        }\r\n\r\n        busDef_->setSystemGroupNames(currentSystemGroups);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusDefGroup::setupLayout()\r\n//-----------------------------------------------------------------------------\r\nvoid BusDefGroup::setupLayout()\r\n{\r\n    QFormLayout* initiatorTargetLayout = new QFormLayout();\r\n    initiatorTargetLayout->addRow(tr(\"Max initiators on bus:\"), &maxInitiatorsEditor_);\r\n    initiatorTargetLayout->addRow(tr(\"Max targets on bus:\"), &maxTargetsEditor_);\r\n\r\n    QGroupBox* selectionGroup = new QGroupBox(tr(\"Constraints\"), this);\r\n\r\n    QVBoxLayout* selectionsLayout = new QVBoxLayout(selectionGroup);\r\n    selectionsLayout->addWidget(&directConnection_);\r\n    selectionsLayout->addWidget(&isBroadcast_);\r\n    selectionsLayout->addWidget(&isAddressable_);\r\n    selectionsLayout->addLayout(initiatorTargetLayout);\r\n    selectionsLayout->addStretch();    \r\n\r\n    QGroupBox* systemGroupBox = new QGroupBox(tr(\"System group names\"), this);\r\n\r\n    QVBoxLayout* systemGroupLayout = new QVBoxLayout(systemGroupBox);\r\n    systemGroupLayout->addWidget(&systemGroupEditor_);\r\n\r\n    QVBoxLayout* rootLayout = new QVBoxLayout(this);\r\n    \r\n    QWidget* topHalfWidget = new QWidget();\r\n    QHBoxLayout* topHalfLayout = new QHBoxLayout(topHalfWidget);\r\n\r\n    QWidget* rightSideContainer = new QWidget(this);\r\n    QVBoxLayout* containerLayout = new QVBoxLayout();\r\n    containerLayout->setContentsMargins(0, 0, 0, 0);\r\n    containerLayout->addWidget(extendEditor_);\r\n    containerLayout->addWidget(selectionGroup);\r\n    containerLayout->addWidget(systemGroupBox);\r\n    rightSideContainer->setLayout(containerLayout);\r\n    \r\n    topHalfLayout->addWidget(&documentNameGroupEditor_);\r\n    topHalfLayout->addWidget(rightSideContainer);\r\n\r\n    QSplitter* splitter = new QSplitter(Qt::Vertical);\r\n    splitter->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);\r\n    splitter->addWidget(topHalfWidget);\r\n    splitter->addWidget(parameterEditor_);\r\n\r\n    QSplitterHandle* handle = splitter->handle(1);\r\n    QVBoxLayout* handleLayout = new QVBoxLayout(handle);\r\n    handleLayout->setSpacing(0);\r\n    handleLayout->setContentsMargins(0, 0, 0, 0);\r\n\r\n    QFrame* line = new QFrame(handle);\r\n    line->setLineWidth(2);\r\n    line->setMidLineWidth(2);\r\n    line->setFrameShape(QFrame::HLine);\r\n    line->setFrameShadow(QFrame::Sunken);\r\n    handleLayout->addWidget(line);\r\n\r\n    splitter->setStyleSheet(QStringLiteral(\"QSplitter::handle { background: white }\"));\r\n    splitter->setHandleWidth(18);\r\n\r\n    rootLayout->addWidget(splitter);\r\n\r\n    maxInitiatorsEditor_.setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);\r\n    maxTargetsEditor_.setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: busdefgroup::setupExtendedBus()\r\n//-----------------------------------------------------------------------------\r\nvoid BusDefGroup::setupExtendedBus()\r\n{\r\n    QSharedPointer<const BusDefinition> extendedBus = getExtendedBus(busDef_);\r\n    if (extendedBus)\r\n    {\r\n        extendBusDefinition(extendedBus);\r\n        documentNameGroupEditor_.setPlaceholderDescription(extendedBus->getDescription());\r\n\r\n        return;\r\n    }\r\n\r\n    removeBusExtension();\r\n    documentNameGroupEditor_.setPlaceholderDescription(QString());\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: busdefgroup::getExtendedBus()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<const BusDefinition> BusDefGroup::getExtendedBus(QSharedPointer<const BusDefinition> busDefinition)\r\n    const\r\n{\r\n    VLNV extendedVLNV = busDefinition->getExtends();\r\n    if (extendedVLNV.isValid() && extendedVLNV.getType() == VLNV::BUSDEFINITION)\r\n    {\r\n        QSharedPointer<const Document> extendedDocument = library_->getModelReadOnly(extendedVLNV);\r\n        if (extendedDocument)\r\n        {\r\n            QSharedPointer<const BusDefinition> extendedBus = extendedDocument.dynamicCast<const BusDefinition>();\r\n            if (extendedBus)\r\n            {\r\n                return extendedBus;\r\n            }\r\n        }\r\n    }\r\n\r\n    return QSharedPointer<const BusDefinition>();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: busdefgroup::extendBusDefinition()\r\n//-----------------------------------------------------------------------------\r\nvoid BusDefGroup::extendBusDefinition(QSharedPointer<const BusDefinition> extendedBus)\r\n{\r\n    directConnection_.setChecked(extendedBus->getDirectConnection());\r\n    isBroadcast_.setChecked(extendedBus->getBroadcast().toBool());\r\n    isAddressable_.setChecked(extendedBus->getIsAddressable());\r\n\r\n    directConnection_.setDisabled(true);\r\n    isBroadcast_.setDisabled(true);\r\n    isAddressable_.setDisabled(true);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: busdefgroup::removeBusExtension()\r\n//-----------------------------------------------------------------------------\r\nvoid BusDefGroup::removeBusExtension()\r\n{\r\n    directConnection_.setDisabled(false);\r\n    isBroadcast_.setDisabled(false);\r\n    isAddressable_.setDisabled(false);\r\n}\r\n"
  },
  {
    "path": "editors/BusDefinitionEditor/busdefgroup.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: busdefgroup.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 21.6.2011\r\n//\r\n// Description:\r\n// BusDefGroup contains elements to set the properties of a Bus Definition.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef BUSDEFGROUP_H\r\n#define BUSDEFGROUP_H\r\n\r\n#include <common/widgets/listManager/listmanager.h>\r\n\r\n#include <editors/BusDefinitionEditor/SystemGroupListEditor.h>\r\n\r\n#include <editors/common/DocumentNameGroupEditor.h>\r\n\r\n\r\n#include <IPXACTmodels/BusDefinition/BusDefinition.h>\r\n\r\n#include <QGroupBox>\r\n#include <QCheckBox>\r\n#include <QLineEdit>\r\n#include <QSharedPointer>\r\n#include <QPlainTextEdit>\r\n\r\nclass VLNVDisplayer;\r\nclass VLNVEditor;\r\nclass LibraryInterface;\r\nclass ParameterGroupBox;\r\nclass ExpressionFormatter;\r\nclass ParameterFinder;\r\nclass AbstractParameterInterface;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! BusDefGroup contains elements to set the properties of a Bus Definition.\r\n//-----------------------------------------------------------------------------\r\nclass BusDefGroup : public QWidget\r\n{\r\n    Q_OBJECT\r\n\r\npublic:\r\n\r\n    /*!\r\n     *  The constructor.\r\n     *\r\n     *    @param [in] libraryHandler          Interface to the library.\r\n     *    @param [in] expressionFormatter     The expression formatter to use.\r\n     *    @param [in] parameterFinder         The parameter finder to use.\r\n     *    @param [in] parent                  The owner of this widget.\r\n     */\r\n    BusDefGroup(LibraryInterface* libraryHandler, QSharedPointer<ExpressionFormatter> expressionFormatter,\r\n        QSharedPointer<ParameterFinder> parameterFinder, QWidget *parent);\r\n\r\n    /*!\r\n     *  The destructor.\r\n     */\r\n    virtual ~BusDefGroup() = default;\r\n\r\n    /*!\r\n     *  Set the bus definition that is being edited.\r\n     *\r\n     *    @param [in] busDef The bus definition\r\n     */\r\n    void setBusDef(QSharedPointer<BusDefinition> busDef);\r\n\r\nsignals:\r\n\r\n    /*!\r\n     *  Emitted when user changes the state of one of the elements.\r\n     */\r\n    void contentChanged();\r\n\r\n    /*!\r\n     *  Increase the amount of references to the parameter corresponding to the id.\r\n     *\r\n     *    @param [in] id      The id of the parameter being searched for.\r\n     */\r\n    void increaseReferences(QString id);\r\n\r\n    /*!\r\n     *  Decrease the amount of references to the parameter corresponding to the id.\r\n     *\r\n     *    @param [in] id      The id of the parameter being searched for.\r\n     */\r\n    void decreaseReferences(QString id);\r\n\r\n    /*!\r\n     *  Recalculate references made to the selected parameters.\r\n     *\r\n     *    @param [in] parameterList       The selected parameters.\r\n     *    @param [in] parameterInterface  Interface for accessing parameters.\r\n     */\r\n    void recalculateReferencesToParameters(QStringList const& parameterList,\r\n        AbstractParameterInterface* parameterInterface);\r\n\r\n    /*!\r\n     *  Open the reference tree of the parameter with the id.\r\n     *\r\n     *    @param [in] id              The id of the parameter.\r\n     *    @param [in] parameterName   Name of the selected parameter.\r\n     */\r\n    void openReferenceTree(QString const& id, QString const& parameterName);\r\n\r\nprivate slots:\r\n\r\n    /*!\r\n     *  Handler for state changes on direct connection check box.\r\n     */\r\n    void onDirectConnectionChanged(bool checked);\r\n\r\n    /*!\r\n     *  Handler for state changes on is broadcast check box.\r\n     */\r\n    void onIsBroadcastChanged(bool checked);\r\n\r\n    /*!\r\n     *  Handler for state changes on is addressable check box.\r\n     */\r\n    void onIsAddressableChanged(bool checked);\r\n\r\n    /*!\r\n     *  Handler for changes in max masters line edit.\r\n     */\r\n    void onInitiatorsChanged();\r\n\r\n    /*!\r\n     *  Handler for changes in max slaves line edit.\r\n     */\r\n    void onTargetsChanged();\r\n\r\n    /*!\r\n     *  Handler for changes in system group names.\r\n     */\r\n    void onSystemNamesChanged();\r\n\r\n    /*!\r\n     *  Handles the changes in bus definition extend.\r\n     */\r\n    void onExtendChanged();\r\n\r\nprivate:\r\n    //! No copying. No assignment.\r\n    BusDefGroup(const BusDefGroup& other);\r\n    BusDefGroup& operator=(const BusDefGroup& other);\r\n\r\n    /*!\r\n     *  Sets the widget layout.\r\n     */\r\n    void setupLayout();\r\n\r\n    /*!\r\n     *  Setup the extended bus definition.\r\n     */\r\n    void setupExtendedBus();\r\n\r\n    /*!\r\n     *  Get the extended bus definition for the selected bus definition.\r\n     *\r\n     *    @param [in] busDefinition   The selected bus definition.\r\n     *\r\n     *    @return The extended bus definition.\r\n     */\r\n    QSharedPointer<const BusDefinition> getExtendedBus(QSharedPointer<const BusDefinition> busDefinition) const;\r\n    \r\n    /*!\r\n     *  Lock editors according to the selected extended bus definition.\r\n     *\r\n     *    @param [in] extendedBus     The selected extended bus definition.\r\n     */\r\n    void extendBusDefinition(QSharedPointer<const BusDefinition> extendedBus);\r\n\r\n    /*!\r\n     *  Remove extend system groups.\r\n     */\r\n    void removeSystemGroupsFromExtendedDefinition();\r\n\r\n    /*!\r\n     *  Remove the lock on editors caused by the previous extended bus definition.\r\n     */\r\n    void removeBusExtension();\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n    \r\n    //! The library interface.\r\n    LibraryInterface* library_;\r\n\r\n    //! The bus definition to edit.\r\n    QSharedPointer<BusDefinition> busDef_;\r\n\r\n    //! Check box to set the direct connection option.\r\n    QCheckBox directConnection_;\r\n\r\n    //! Check box to set the broadcast option.\r\n    QCheckBox isBroadcast_;\r\n\r\n    //! Check box to set the is addressable option.\r\n    QCheckBox isAddressable_;\r\n\r\n    //! Editor to set the maximum number of initiators.\r\n    QLineEdit maxInitiatorsEditor_;\r\n\r\n    //! Editor to set the maximum number of targets.\r\n    QLineEdit maxTargetsEditor_;\r\n\r\n    //! Editor for system group names.\r\n    SystemGroupListEditor systemGroupEditor_;\r\n\r\n    //! Editor for bus definition document name group\r\n    DocumentNameGroupEditor documentNameGroupEditor_;\r\n\r\n    //! Editor for the bus definition extension.\r\n    VLNVEditor* extendEditor_;\r\n\r\n    //! The bus definition parameters editor.\r\n    ParameterGroupBox* parameterEditor_;\r\n};\r\n\r\n#endif // BUSDEFGROUP_H\r\n"
  },
  {
    "path": "editors/CSourceEditor/CSourceContentMatcher.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: CSourceContentMatcher.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Joni-Matti Maatta\r\n// Date: 11.1.2011\r\n//\r\n// Description:\r\n// MCAPI-specific content matcher.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"CSourceContentMatcher.h\"\r\n\r\n#include <QTextCursor>\r\n\r\n#include <IPXACTmodels/common/DirectionTypes.h>\r\n#include <IPXACTmodels/Component/Component.h>\r\n\r\n#include <IPXACTmodels/kactusExtensions/ApiDefinition.h>\r\n#include <IPXACTmodels/kactusExtensions/ApiFunction.h>\r\n#include <IPXACTmodels/kactusExtensions/ApiFunctionParameter.h>\r\n#include <IPXACTmodels/kactusExtensions/ComDefinition.h>\r\n#include <IPXACTmodels/kactusExtensions/ComInterface.h>\r\n\r\n#include <common/widgets/assistedTextEdit/TextContentAssistWidget.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: CSourceContentMatcher()\r\n//-----------------------------------------------------------------------------\r\nCSourceContentMatcher::CSourceContentMatcher()\r\n    : ownerComponent_(),\r\n      sourceApiDefinitions_(),\r\n      sourceComDefinitions_(),\r\n      lastMatchType_(MATCH_NONE),\r\n      curAssist_(0),\r\n      tooltipText_()\r\n{\r\n    icons_[MCAPI_CONTENT_FUNC] = QIcon(\":icons/common/graphics/mcapi-func.png\");\r\n    icons_[MCAPI_CONTENT_TYPENAME] = QIcon(\":icons/common/graphics/mcapi-type.png\");\r\n    icons_[MCAPI_CONTENT_NODE_ID] = QIcon(\":icons/common/graphics/mcapi-node.png\");\r\n    icons_[MCAPI_CONTENT_PORT_ID] = QIcon(\":icons/common/graphics/mcapi-port.png\");\r\n    icons_[MCAPI_CONTENT_ENDPOINT] = QIcon(\":icons/common/graphics/mcapi-endpoint.png\");\r\n    icons_[MCAPI_CONTENT_ENDPOINT_HANDLE] = QIcon(\":icons/common/graphics/mcapi-endpoint_handle.png\");\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ~CSourceContentMatcher()\r\n//-----------------------------------------------------------------------------\r\nCSourceContentMatcher::~CSourceContentMatcher()\r\n{\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: lookForwardMatch()\r\n//-----------------------------------------------------------------------------\r\nbool CSourceContentMatcher::lookForwardMatch(QString const& text)\r\n{\r\n    int index = 0;\r\n    int toolTipIndex = 0;\r\n    return (lastMatchType_ != MATCH_NONE &&\r\n            enumerateMatches(text, 0, index, 0, toolTipIndex) == lastMatchType_);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: fillWithContent()\r\n//-----------------------------------------------------------------------------\r\nbool CSourceContentMatcher::fillWithContent(QString const& text, TextContentAssistWidget& assist,\r\n                                          int& startIndex, QString& toolTipText, int& toolTipIndex)\r\n{\r\n    curAssist_ = &assist;\r\n\r\n    toolTipText.clear();    \r\n    lastMatchType_ = enumerateMatches(text, &CSourceContentMatcher::addMatchToAssist,\r\n                                       startIndex, &toolTipText, toolTipIndex);\r\n\r\n    curAssist_->sortItems();\r\n\r\n    return (lastMatchType_ != MATCH_NONE);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: enumerateMatches()\r\n//-----------------------------------------------------------------------------\r\nCSourceContentMatcher::MatchType CSourceContentMatcher::enumerateMatches(QString const& text, MatchExecFunc func,\r\n                                                                     int& startIndex, QString* toolTipText,\r\n                                                                     int& toolTipIndex)\r\n{\r\n    static QRegularExpression funcCallExp(\"[a-z|A-Z|_][a-z|A-Z|0-9|_]*\\\\([a-z|A-Z|0-9|_|.|,|&|\\\\s]*$\");\r\n\r\n    bool exactMatch = false;\r\n    int count = 0;\r\n    \r\n    // Enumerate function parameters if a function call is found.\r\n    if (text.indexOf(funcCallExp) >= 0)\r\n    {\r\n        count = enumerateFunctionParams(text, func, startIndex, exactMatch, toolTipText, toolTipIndex);\r\n\r\n        if (count > 0 && !(count == 1 && exactMatch))\r\n        {\r\n            return MATCH_FUNCTION;\r\n        }\r\n    }\r\n    // If not found, enumerate plain names.\r\n    else\r\n    {\r\n        count = enumerateNames(text, func, startIndex, exactMatch);\r\n\r\n        if (count > 0 && !(count == 1 && exactMatch))\r\n        {\r\n            return MATCH_PARAM;\r\n        }\r\n    }\r\n\r\n    return MATCH_NONE;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: enumerateNames()\r\n//-----------------------------------------------------------------------------\r\nint CSourceContentMatcher::enumerateNames(QString const &text, MatchExecFunc func, int &startIndex,\r\n                                        bool& exactMatch)\r\n{\r\n    exactMatch = false;\r\n    int count = 0;\r\n\r\n    // Check if the last word could be a name.\r\n    static QRegularExpression lastWordExp(\"[a-z|A-Z|_][a-z|A-Z|0-9|_]*$\");\r\n    startIndex = text.indexOf(lastWordExp, 0);\r\n    auto wordMatch = lastWordExp.match(text);\r\n\r\n    if (wordMatch.hasMatch())\r\n    {\r\n        QString word = wordMatch.captured(); //text.mid(startIndex, wordMatch.capturedLength());\r\n        QRegularExpression matchExp(\"^\" + QRegularExpression::escape(word.toLower()) + \".*\");\r\n\r\n        for (QSharedPointer<ApiDefinition const> apiDef : sourceApiDefinitions_)\r\n        {\r\n\t\t\t// Search for functions that start with the retrieved word.\r\n\t\t\tfor ( QSharedPointer<ApiFunction> apiFunc : *apiDef->getFunctions() )\r\n            {\r\n                if (tryMatchIdentifier(apiFunc->name(), MCAPI_CONTENT_FUNC, matchExp, func, count))\r\n                {\r\n                    // Check if this was an exact match.\r\n                    if (!exactMatch && apiFunc->name() == word)\r\n                    {\r\n                        exactMatch = true;\r\n                    }\r\n                }\r\n            }\r\n\r\n            // Search for types that start with the retrieved word.\r\n            for (QString const& dataType : *apiDef->getDataTypes())\r\n            {\r\n                if (tryMatchIdentifier(dataType, MCAPI_CONTENT_TYPENAME, matchExp, func, count))\r\n                {\r\n                    // Check if this was an exact match.\r\n                    if (!exactMatch && dataType == word)\r\n                    {\r\n                        exactMatch = true;\r\n                    }\r\n                }\r\n            }\r\n        }\r\n    }\r\n\r\n    return count;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: enumerateFunctionParams()\r\n//-----------------------------------------------------------------------------\r\nint CSourceContentMatcher::enumerateFunctionParams(QString const &text, MatchExecFunc func,\r\n                                                 int &startIndex, bool& exactMatch,\r\n                                                 QString* toolTipText, int& toolTipIndex)\r\n{\r\n    // Used static regular expressions.\r\n    static QRegularExpression funcCallExp(\"[a-z|A-Z|_][a-z|A-Z|0-9|_]*\\\\([a-z|A-Z|0-9|_|,|.|&|\\\\s]*$\");\r\n    static QRegularExpression lastParamExp(\"[(|,]\\\\s*(&)?([a-z|A-Z|0-9|_][a-z|A-Z|0-9|_|.]*)?$\");\r\n    static QRegularExpression callStartExp(\"\\\\([a-z|A-Z|0-9|_|,|.|&|\\\\s]*$\");\r\n    \r\n    exactMatch = false;\r\n    int count = 0;\r\n\r\n    // Find the beginning of the function call.\r\n    int funcStartIndex = text.indexOf(funcCallExp, 0);\r\n    Q_ASSERT(funcStartIndex >= 0);\r\n    \r\n    // Search for the last param.\r\n    int index = text.indexOf(lastParamExp, funcStartIndex);\r\n    auto paramMatch = lastParamExp.match(text, funcStartIndex);\r\n\r\n    if (index >= 0)\r\n    {\r\n        // If found, discard the leading whitespaces, left parentheses and commas.\r\n        startIndex = text.indexOf(QRegularExpression(\"[&|a-z|A-Z|0-9|_]\"), index);\r\n\r\n        if (startIndex < 0)\r\n        {\r\n            startIndex = index + paramMatch.capturedLength();\r\n        }\r\n\r\n        QString word = text.mid(startIndex, paramMatch.capturedLength() - (startIndex - index));\r\n        \r\n        // Extract the function name & parameter list from the text.\r\n        index = text.indexOf(callStartExp, funcStartIndex);\r\n        Q_ASSERT(index >= 0);\r\n\r\n        QString funcName = text.mid(funcStartIndex, index - funcStartIndex);\r\n        QString paramListText = text.mid(index + 1);\r\n\r\n        // Extract previous parameters to a list for easy access.\r\n        QStringList params;\r\n        extractParams(paramListText, params);\r\n\r\n        // Based on the function description, try to match content.\r\n        ApiFunction const* matchingApiFunc = 0;\r\n\r\n        for (QSharedPointer<ApiDefinition const> apiDef : sourceApiDefinitions_)\r\n\t\t{\r\n\t\t\tfor ( QSharedPointer<ApiFunction> apiFunc : *apiDef->getFunctions() )\r\n            {\r\n                if (apiFunc->name() == funcName)\r\n                {\r\n                    matchingApiFunc = apiFunc.data();\r\n                    break;\r\n                }\r\n            }\r\n        }\r\n\r\n        if (matchingApiFunc != 0 && params.count() < matchingApiFunc->getParamCount())\r\n        {\r\n            // Generate a tooltip text.\r\n            if (toolTipText != 0)\r\n            {\r\n                matchingApiFunc->generateToolTipText(params.count(), *toolTipText);\r\n                toolTipIndex = index + 1;\r\n            }\r\n\r\n            tryMatchParam(matchingApiFunc, params, word, func, count);\r\n        }\r\n    }\r\n\r\n    return count;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: addMatchToAssist()\r\n//-----------------------------------------------------------------------------\r\nvoid CSourceContentMatcher::addMatchToAssist(TextContentAssistWidget& assist, QString const& match,\r\n                                           QIcon const& icon)\r\n{\r\n    if (assist.findItems(match, Qt::MatchExactly).isEmpty())\r\n    {\r\n        assist.addItem(new QListWidgetItem(icon, match));\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: CSourceContentMatcher::tryMatchParam()\r\n//-----------------------------------------------------------------------------\r\nvoid CSourceContentMatcher::tryMatchParam(ApiFunction const* apiFuncDesc, QStringList const& params,\r\n                                        QString const& word, MatchExecFunc func, int& count)\r\n{\r\n    // Find out the parameter index.\r\n    int paramIndex = params.count();\r\n\r\n    QRegularExpression matchExp(\"^\" + QRegularExpression::escape(word.toLower()) + \".*\");\r\n\r\n    // Based on the function parameter description, try to find matching content.\r\n    QSharedPointer<ApiFunctionParameter const> apiParam = apiFuncDesc->getParam(paramIndex);\r\n\r\n    // Check if the parameter is dependent on another parameter.\r\n    if (apiParam->getDependentParameterIndex() >= 0)\r\n    {\r\n        int index =  apiParam->getDependentParameterIndex();\r\n\r\n        if (index < params.count() && index < apiFuncDesc->getParamCount())\r\n        {\r\n            QSharedPointer<ApiFunctionParameter const> dependentParam =\r\n                apiFuncDesc->getParam(apiParam->getDependentParameterIndex());\r\n\r\n            // Find the matching COM interface.\r\n            foreach (QSharedPointer<ComInterface> comIf, ownerComponent_->getComInterfaces())\r\n            {\r\n                QString value = comIf->name();\r\n\r\n                if (dependentParam->getContentSource() != \"Name\")\r\n                {\r\n                    value = comIf->getPropertyValues().value(dependentParam->getContentSource(), \"\");\r\n                }\r\n\r\n                if (value == params.at(index) &&\r\n                    (comIf->getDirection() == dependentParam->getComDirection() ||\r\n                     dependentParam->getComDirection() == DirectionTypes::DIRECTION_INVALID) &&\r\n                    (comIf->getTransferType() == dependentParam->getComTransferType() ||\r\n                     dependentParam->getComTransferType() == \"\" ||\r\n                     dependentParam->getComTransferType() == \"any\"))\r\n                {\r\n                    QString identifier  = \"\";\r\n\r\n                    if (apiParam->getContentSource() == \"Name\")\r\n                    {\r\n                        identifier = comIf->name();\r\n                    }\r\n                    else\r\n                    {\r\n                        identifier = comIf->getPropertyValues().value(apiParam->getContentSource(), \"\");\r\n                    }\r\n\r\n                    if (apiParam->getType().contains('*'))\r\n                    {\r\n                        identifier = \"&\" + identifier;\r\n                    }\r\n\r\n                    tryMatchIdentifier(identifier, MCAPI_CONTENT_ENDPOINT, matchExp, func, count);                    \r\n                    break;\r\n                }\r\n            }\r\n        }\r\n    }\r\n    else if (!apiParam->getContentSource().isEmpty())\r\n    {\r\n        // Otherwise enumerate all COM interfaces that match with the requirements.\r\n        foreach (QSharedPointer<ComInterface> comIf, ownerComponent_->getComInterfaces())\r\n        {\r\n            if ((comIf->getDirection() == apiParam->getComDirection() ||\r\n                apiParam->getComDirection() == DirectionTypes::DIRECTION_INVALID) &&\r\n                (comIf->getTransferType() == apiParam->getComTransferType() ||\r\n                 apiParam->getComTransferType() == \"\" ||\r\n                 apiParam->getComTransferType() == \"any\"))\r\n            {\r\n                QString identifier = \"\";\r\n\r\n                if (apiParam->getContentSource() == \"Name\")\r\n                {\r\n                    identifier = comIf->name();\r\n                }\r\n                else\r\n                {\r\n                    identifier = comIf->getPropertyValues().value(apiParam->getContentSource(), \"\");\r\n                }\r\n\r\n                if (apiParam->getType().contains('*'))\r\n                {\r\n                    identifier = \"&\" + identifier;\r\n                }\r\n\r\n                tryMatchIdentifier(identifier, MCAPI_CONTENT_ENDPOINT, matchExp, func, count);\r\n            }\r\n        }\r\n    }\r\n}\r\n\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tryMatchIdentifier()\r\n//-----------------------------------------------------------------------------\r\nbool CSourceContentMatcher::tryMatchIdentifier(QString const& identifier, MCAPIContentType type,\r\n                                             QRegularExpression& exp, MatchExecFunc func, int& count)\r\n{\r\n    if (identifier.toLower().contains(exp))\r\n    {\r\n        if (func != 0)\r\n        {\r\n            func(*curAssist_, identifier, icons_[type]);\r\n        }\r\n\r\n        ++count;\r\n\r\n        return true;\r\n    }\r\n\r\n    return false;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: extractParams()\r\n//-----------------------------------------------------------------------------\r\nvoid CSourceContentMatcher::extractParams(QString const& paramsListStr, QStringList& params)\r\n{\r\n    static QRegularExpression paramExtractExp(\"([a-z|A-Z|0-9|_][^,]*)?(?=\\\\s*[,|$])\");\r\n\r\n    // Clear the parameter list.\r\n    params.clear();\r\n\r\n    // Extract parameters one-by-one.\r\n    auto paramMatch = paramExtractExp.match(paramsListStr);\r\n\r\n    while (paramMatch.hasMatch())\r\n    {\r\n        params.push_back(paramMatch.captured());\r\n\r\n        // Find the next comma to prepare for extracting the next parameter.\r\n        int index = paramMatch.capturedStart();\r\n        int nextComma = paramsListStr.indexOf(',', index + paramMatch.capturedLength());\r\n\r\n        // If not found, there are no more complete parameters (only the one that is\r\n        // being written at the moment).\r\n        if (nextComma < 0)\r\n        {\r\n            break;\r\n        }\r\n\r\n        paramMatch = paramExtractExp.match(paramsListStr, nextComma + 1);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: CSourceContentMatcher::addSourceApiDefinition()\r\n//-----------------------------------------------------------------------------\r\nvoid CSourceContentMatcher::addSourceApiDefinition(QSharedPointer<ApiDefinition const> apiDef)\r\n{\r\n    sourceApiDefinitions_.append(apiDef);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: CSourceContentMatcher::addSourceComDefinition()\r\n//-----------------------------------------------------------------------------\r\nvoid CSourceContentMatcher::addSourceComDefinition(QSharedPointer<ComDefinition const> comDef)\r\n{\r\n    sourceComDefinitions_.append(comDef);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: CSourceContentMatcher::setOwner()\r\n//-----------------------------------------------------------------------------\r\nvoid CSourceContentMatcher::setOwner(QSharedPointer<Component> component)\r\n{\r\n    ownerComponent_ = component;\r\n}\r\n\r\n"
  },
  {
    "path": "editors/CSourceEditor/CSourceContentMatcher.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: CSourceContentMatcher.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Joni-Matti Maatta\r\n// Date: 11.1.2011\r\n//\r\n// Description:\r\n// MCAPI-specific content matcher.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef CSOURCECONTENTMATCHER_H\r\n#define CSOURCECONTENTMATCHER_H\r\n\r\n#include <QIcon>\r\n#include <QList>\r\n#include <QStringList>\r\n#include <QSharedPointer>\r\n\r\n#include <common/widgets/assistedTextEdit/ITextContentMatcher.h>\r\n\r\nclass ApiDefinition;\r\nclass ApiFunction;\r\nclass ComDefinition;\r\nclass Component;\r\n//-----------------------------------------------------------------------------\r\n//! CSourceContentMatcher class.\r\n//-----------------------------------------------------------------------------\r\nclass CSourceContentMatcher : public ITextContentMatcher\r\n{\r\npublic:\r\n    /*!\r\n     *  Constructor.\r\n     */\r\n    CSourceContentMatcher();\r\n\r\n    /*!\r\n     *  Destructor.\r\n     */\r\n    ~CSourceContentMatcher();\r\n\r\n    /*!\r\n     *  Sets the component that owns this content matcher.\r\n     *\r\n     *    @param [in] component The component to set.\r\n     */\r\n    void setOwner(QSharedPointer<Component> component);\r\n\r\n    /*!\r\n     *  Adds a source API definition for content matching.\r\n     *\r\n     *    @param [in] apiDef The API definition to add.\r\n     */\r\n    void addSourceApiDefinition(QSharedPointer<ApiDefinition const> apiDef);\r\n\r\n    /*!\r\n     *  Adds a source COM definition for content matching.\r\n     *\r\n     *    @param [in] comDef The COM definition to add.\r\n     */\r\n    void addSourceComDefinition(QSharedPointer<ComDefinition const> comDef);\r\n\r\n    /*!\r\n     *  Looks forward for matching contents in the given text.\r\n     *\r\n     *    @param [in] text The text.\r\n     *\r\n     *    @return True, if there is a match. Otherwise false.\r\n     */\r\n    bool lookForwardMatch(QString const& text);\r\n\r\n    /*!\r\n     *  Fills the content assist with content based on the given text.\r\n     *\r\n     *    @param [in]  text The text.\r\n     *    @param [in]  assist        The content assist to fill with content.\r\n     *    @param [out] startIndex    The start index of the selection to which the content applies.\r\n     *    @param [out] toolTipText   The tool tip hint text. Empty if no tool tip available.\r\n     *    @param [out] toolTipIndex  The index which specifies there start position for the tool tip hint.\r\n     *\r\n     *    @return The content state (what kind of content was detected).\r\n     */\r\n    bool fillWithContent(QString const& text, TextContentAssistWidget& assist,\r\n                         int& startIndex, QString& toolTipText, int& toolTipIndex);\r\n\r\nprivate:\r\n\r\n    // Disable copying.\r\n    CSourceContentMatcher(CSourceContentMatcher const& rhs);\r\n    CSourceContentMatcher& operator=(CSourceContentMatcher const& rhs);\r\n\r\n    //! MatchExecFunc definition.\r\n    typedef void (*MatchExecFunc)(TextContentAssistWidget& assist, QString const& match, QIcon const& icon);\r\n\r\n    //-----------------------------------------------------------------------------\r\n    //! MatchType enumeration.\r\n    //-----------------------------------------------------------------------------\r\n    enum MatchType\r\n    {\r\n        MATCH_NONE = 0,\r\n        MATCH_FUNCTION,\r\n        MATCH_PARAM\r\n    };\r\n\r\n    //-----------------------------------------------------------------------------\r\n    //! MCAPI types and utility functions.\r\n    //-----------------------------------------------------------------------------\r\n    enum MCAPIContentType\r\n    {\r\n        MCAPI_CONTENT_FUNC = 0,\r\n        MCAPI_CONTENT_TYPENAME,\r\n        MCAPI_CONTENT_NODE_ID,\r\n        MCAPI_CONTENT_PORT_ID,\r\n        MCAPI_CONTENT_ENDPOINT,\r\n        MCAPI_CONTENT_ENDPOINT_HANDLE,\r\n        MCAPI_CONTENT_TYPE_COUNT\r\n    };\r\n\r\n    /*!\r\n     *  Searches for matches in the given text.\r\n     *\r\n     *    @param [in]  text          The text to search.\r\n     *    @param [in]  func          A function that is executed for each match. Can be null.\r\n     *    @param [out] startIndex    The start index of the part of the text to which the matches apply.\r\n     *    @param [out] toolTipText   The tool tip hint text. Empty if no tool tip available.\r\n     *    @param [out] toolTipIndex  The cursor position in the text to indicate correct\r\n     *                                 placement for the tool tip hint.\r\n     *\r\n     *    @return The content state (what kind of content was detected).\r\n     */\r\n    MatchType enumerateMatches(QString const& text, MatchExecFunc func, int& startIndex,\r\n                               QString* toolTipText, int& toolTipIndex);\r\n\r\n    /*!\r\n     *  Enumerates matching names (function or type) in the given text.\r\n     *\r\n     *    @param [in]  text        The text to search.\r\n     *    @param [in]  func        A function that is executed for each match. Can be null.\r\n     *    @param [out] startIndex  The start index of the part of the text to which the matches apply.\r\n     *    @param [out] exactMatch  If true, there was an exact match. Otherwise false.\r\n     *\r\n     *    @return The number of matches found.\r\n     */\r\n    int enumerateNames(QString const &text, MatchExecFunc func, int &startIndex, bool& exactMatch);\r\n\r\n    /*!\r\n     *  Enumerates matching function parameters in the given text.\r\n     *\r\n     *    @param [in]  text          The text to search.\r\n     *    @param [in]  func          A function that is executed for each match. Can be null.\r\n     *    @param [out] startIndex    The start index of the part of the text to which the matches apply.\r\n     *    @param [out] exactMatch    If true, there was an exact match. Otherwise false.\r\n     *    @param [out] toolTipText   The tool tip hint text. Empty if no tool tip available.\r\n     *    @param [out] toolTipIndex  The cursor position in the text to indicate correct\r\n     *                                 placement for the tool tip hint.\r\n     *\r\n     *    @return The number of matches found.\r\n     *\r\n     *      @remarks Assumes that there is valid function call up to the cursor.\r\n     */\r\n    int enumerateFunctionParams(QString const &text, MatchExecFunc func, int &startIndex,\r\n                                bool& exactMatch, QString* toolTipText, int& toolTipIndex);\r\n\r\n    /*!\r\n     *  Adds the given match to the content assist.\r\n     *\r\n     *    @param [in] assist  The content assist.\r\n     *    @param [in] match   The match to add.\r\n     *    @param [in] type    The icon for the match.\r\n     */\r\n    static void addMatchToAssist(TextContentAssistWidget& assist, QString const& match, QIcon const& icon);\r\n\r\n    /*!\r\n     *  Extracts parameter names to a list from a parameter list string.\r\n     *\r\n     *    @param [in]  paramsListStr  The parameter list string.\r\n     *    @param [out] params         The extracted parameter names.\r\n     */\r\n    static void extractParams(QString const& paramsListStr, QStringList& params);\r\n\r\n    /*!\r\n     *  Tries to match all available content to the parameter.\r\n     *\r\n     *    @param [in] apiFuncDesc  The API function corresponding to the function name.\r\n     *    @param [in] params       The previous parameters for the function.\r\n     *    @param [in] word         The partial content of the parameter to match.\r\n     *    @param [in] func         The match execution function.\r\n     *    @param [in,out] count    The accumulated number of matches.\r\n     */\r\n    void tryMatchParam(ApiFunction const* apiFuncDesc, QStringList const& params, QString const& word,\r\n                       MatchExecFunc func, int& count);\r\n\r\n    /*!\r\n     *  Tries to match an identifier to the regular expression.\r\n     *\r\n     *    @param [in]     identifier The identifier.\r\n     *    @param [in]     type       The identifier's MCAPI content type.\r\n     *    @param [in]     exp        The regular expression to use for matching.\r\n     *    @param [in]     func       The match execution function.\r\n     *    @param [in/out] count      The accumulated number of matches.\r\n     *\r\n     *    @return True, if the identifier matched with the regular expression. Otherwise false.\r\n     */\r\n    bool tryMatchIdentifier(QString const& identifier, MCAPIContentType type,\r\n                            QRegularExpression& exp, MatchExecFunc func, int& count);\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! Content icons.\r\n    QIcon icons_[MCAPI_CONTENT_TYPE_COUNT];\r\n\r\n    //! The owner component.\r\n    QSharedPointer<Component> ownerComponent_;\r\n\r\n    //! Source API definitions.\r\n    QList< QSharedPointer<ApiDefinition const> > sourceApiDefinitions_;\r\n\r\n    //! Source COM definitions.\r\n    QList< QSharedPointer<ComDefinition const> > sourceComDefinitions_;\r\n\r\n    //! Last found match type.\r\n    MatchType lastMatchType_;\r\n\r\n    //! The current assist that is being filled with content.\r\n    TextContentAssistWidget* curAssist_;\r\n\r\n    //! The generated tooltip text.\r\n    QString tooltipText_;\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n\r\n#endif // CSOURCECONTENTMATCHER_H\r\n"
  },
  {
    "path": "editors/CSourceEditor/CSourceHighlight.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: CSourceHighlight.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Esko Pekkarinen\n// Date: 15.02.2017\n//\n// Description:\n// C source language-specific highlight rules.\n//-----------------------------------------------------------------------------\n\n#include \"CSourceHighlight.h\"\n\n#include <QRegularExpression>\n\n//-----------------------------------------------------------------------------\n// Function: CSourceHighlight::CSourceHighlight()\n//-----------------------------------------------------------------------------\nCSourceHighlight::CSourceHighlight()\n{\n    \n}\n\n//-----------------------------------------------------------------------------\n// Function: CSourceHighlight::~CSourceHighlight()\n//-----------------------------------------------------------------------------\nCSourceHighlight::~CSourceHighlight()\n{\n\n}\n\n\n//-----------------------------------------------------------------------------\n// Function: CSourceHighlight::keywords()\n//-----------------------------------------------------------------------------\nQStringList CSourceHighlight::keywords() const\n{\n    QStringList keywordPatterns;\n    keywordPatterns << \"auto\" << \"break\" << \"case\"\n        << \"char\" << \"const\" << \"continue\"\n        << \"default\" << \"do\" << \"double\"\n        << \"else\" << \"enum\" << \"extern\"\n        << \"float\" << \"for\" << \"goto\"\n        << \"if\" << \"int\" << \"long\" \n        << \"register\" << \"return\" << \"short\"\n        << \"signed\" << \"sizeof\" << \"static\"\n        << \"struct\" << \"switch\" << \"typedef\"\n        << \"union\" << \"unsigned\" << \"void\"\n        << \"volatile\" << \"while\";\n\n    return keywordPatterns;\n}\n\n//-----------------------------------------------------------------------------\n// Function: CSourceHighlight::preprocessorDirectives()\n//-----------------------------------------------------------------------------\nQStringList CSourceHighlight::preprocessorDirectives() const\n{\n    QStringList preprocPatterns;\n    preprocPatterns << \"#include\" << \"#ifndef\" << \"#ifdef\" << \"#if\" << \"#endif\" << \"#pragma\" << \"#define\";\n\n    return preprocPatterns;\n}\n\n//-----------------------------------------------------------------------------\n// Function: CSourceHighlight::applyLanguageSpecificRules()\n//-----------------------------------------------------------------------------\nvoid CSourceHighlight::applyLanguageSpecificRules(LanguageHighlighter* highlighter) const\n{\n    QRegularExpression pattern = QRegularExpression(\"^#include <.*>\");\n    highlighter->addRule(pattern, LanguageHighlighter::STRING);\n}\n"
  },
  {
    "path": "editors/CSourceEditor/CSourceHighlight.h",
    "content": "//-----------------------------------------------------------------------------\n// File: CSourceHighlight.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Esko Pekkarinen\n// Date: 15.02.2017\n//\n// Description:\n// C source language-specific highlight rules.\n//-----------------------------------------------------------------------------\n\n#ifndef CSOURCEHIGHLIGHT_H\n#define CSOURCEHIGHLIGHT_H\n\n#include <Plugins/common/SourceHighlightStyle.h>\n\nclass LanguageHighlighter;\n\n//-----------------------------------------------------------------------------\n//! CSourceHighlight class.\n//-----------------------------------------------------------------------------\nclass CSourceHighlight: public SourceHighlightStyle\n{\npublic:\n\n    //! The constructor.\n    CSourceHighlight();\n\n    //! The destructor.\n    virtual ~CSourceHighlight();\n\nprotected:\n\n    /*!\n     *  Get the language specific keywords.\n     *\n     *    @return The language keywords.\n     */   \n    virtual QStringList keywords() const;\n            \n    /*!\n     *  Get the language specific preprocessor directives.\n     *\n     *    @return The preprocessor directives.\n     */\n    virtual QStringList preprocessorDirectives() const;\n\n    /*!\n     *  Apply other language specific rules to highlighting.\n     *\n     *    @param [in] highlighter   The highlighter to apply the rules to.\n     */\n    virtual void applyLanguageSpecificRules(LanguageHighlighter* highlighter) const; \n\nprivate:\n\n    // Disable copying.\n    CSourceHighlight(CSourceHighlight const& rhs);\n    CSourceHighlight& operator=(CSourceHighlight const& rhs);\n};\n\n//-----------------------------------------------------------------------------\n\n#endif // CSOURCEHIGHLIGHT_H\n"
  },
  {
    "path": "editors/CSourceEditor/CSourceHighlighter.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: CSourceHighlighter.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Joni-Matti Maatta\r\n// Date: 21.12.2010\r\n//\r\n// Description:\r\n// MCAPI/C syntax highlighter.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"CSourceHighlighter.h\"\r\n\r\n#include <IPXACTmodels/kactusExtensions/ApiDefinition.h>\r\n#include <IPXACTmodels/kactusExtensions/ApiFunction.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: CSourceHighlighter()\r\n//-----------------------------------------------------------------------------\r\nCSourceHighlighter::CSourceHighlighter(QTextDocument* parent): LanguageHighlighter(parent)\r\n{\r\n   \r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ~CSourceHighlighter()\r\n//-----------------------------------------------------------------------------\r\nCSourceHighlighter::~CSourceHighlighter()\r\n{\r\n}\r\n\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: CSourceHighlighter::registerAPI()\r\n//-----------------------------------------------------------------------------\r\nvoid CSourceHighlighter::registerAPI(QSharedPointer<ApiDefinition const> apiDef)\r\n{\r\n    // Register data type rules.\r\n    foreach (QString const& dataType, *apiDef->getDataTypes())\r\n    {\r\n        addRule(QRegularExpression(\"\\\\b\" + dataType + \"\\\\b\"), API_DATA_TYPES);\r\n    }\r\n\r\n\tforeach (QSharedPointer<ApiFunction> apiFunc, *apiDef->getFunctions())\r\n    {\r\n        addRule(QRegularExpression(\"\\\\b\" + apiFunc->name() + \"\\\\b\"), API_FUNCTIONS);\r\n    }\r\n}\r\n"
  },
  {
    "path": "editors/CSourceEditor/CSourceHighlighter.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: CSourceHighlighter.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Joni-Matti Maatta\r\n// Date: 21.12.2010\r\n//\r\n// Description:\r\n// MCAPI/C syntax highlighter.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef CSOURCEHIGHLIGHTER_H\r\n#define CSOURCEHIGHLIGHTER_H\r\n\r\n#include <Plugins/common/LanguageHighlighter.h>\r\n\r\n#include <common/widgets/assistedTextEdit/HighlightStyleDesc.h>\r\n\r\n#include <QSyntaxHighlighter>\r\n#include <QTextEdit>\r\n#include <QString>\r\n#include <QVector>\r\n#include <QTextCharFormat>\r\n\r\nclass ApiDefinition;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! CSourceHighlighter class.\r\n//-----------------------------------------------------------------------------\r\nclass CSourceHighlighter : public LanguageHighlighter\r\n{\r\n    Q_OBJECT\r\n\r\npublic:\r\n\r\n    /*!\r\n     *  Constructor.\r\n     *\r\n     *    @param [in] parent The parent text document.\r\n     */\r\n    CSourceHighlighter(QTextDocument* parent);\r\n\r\n    /*!\r\n     *  Destructor.\r\n     */\r\n    virtual ~CSourceHighlighter();\r\n\r\n    /*!\r\n     *  Registers data types and functions from the given API definition for syntax highlight.\r\n     *\r\n     *    @param [in] apiDef The API definition.\r\n     */\r\n    void registerAPI(QSharedPointer<ApiDefinition const> apiDef);\r\n\r\nprivate:\r\n\r\n    // Disable copying.\r\n    CSourceHighlighter(CSourceHighlighter const& rhs);\r\n    CSourceHighlighter& operator=(CSourceHighlighter const& rhs);\r\n\r\n    /*!\r\n     *  Applies MCAPI style to the highlighter.\r\n     */\r\n    void applyMCAPIStyle();\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n\r\n#endif // CSOURCEHIGHLIGHTER_H\r\n"
  },
  {
    "path": "editors/CSourceEditor/CSourceTextEdit.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: CSourceTextEdit.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Joni-Matti Maatta\r\n// Date: 21.2.2011\r\n//\r\n// Description:\r\n// C source text edit widget.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"CSourceTextEdit.h\"\r\n\r\n#include \"CSourceHighlight.h\"\r\n#include \"CSourceHighlighter.h\"\r\n#include \"CSourceContentMatcher.h\"\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: CSourceTextEdit::CSourceTextEdit()\r\n//-----------------------------------------------------------------------------\r\nCSourceTextEdit::CSourceTextEdit(QWidget* mainWnd, QWidget* parent):\r\nAssistedTextEdit(QSharedPointer<CSourceContentMatcher>(new CSourceContentMatcher()), mainWnd, parent),\r\n    highlighter_(new CSourceHighlighter(document()))\r\n{\r\n    CSourceHighlight style;\r\n    style.apply(highlighter_);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: CSourceTextEdit::~CSourceTextEdit()\r\n//-----------------------------------------------------------------------------\r\nCSourceTextEdit::~CSourceTextEdit()\r\n{\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: CSourceTextEdit::getMatcher()\r\n//-----------------------------------------------------------------------------\r\nCSourceContentMatcher& CSourceTextEdit::getMatcher()\r\n{\r\n    return static_cast<CSourceContentMatcher&>(AssistedTextEdit::getMatcher());\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: CSourceTextEdit::getHighlighter()\r\n//-----------------------------------------------------------------------------\r\nCSourceHighlighter& CSourceTextEdit::getHighlighter()\r\n{\r\n    return *highlighter_;\r\n}\r\n"
  },
  {
    "path": "editors/CSourceEditor/CSourceTextEdit.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: CSourceTextEdit.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Joni-Matti Maatta\r\n// Date: 21.2.2011\r\n//\r\n// Description:\r\n// C source text edit widget.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include <QWidget>\r\n\r\n#include <common/widgets/assistedTextEdit/AssistedTextEdit.h>\r\n\r\nclass CSourceContentMatcher;\r\nclass CSourceHighlighter;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! CSourceTextEdit class.\r\n//-----------------------------------------------------------------------------\r\nclass CSourceTextEdit : public AssistedTextEdit\r\n{\r\n    Q_OBJECT\r\n\r\npublic:\r\n    /*!\r\n     *  Constructor.\r\n     *\r\n     *    @param [in] mainWnd         The program main window. Must not be null.\r\n     *    @param [in] parent          The parent widget. Can be null.\r\n     */\r\n    CSourceTextEdit(QWidget* mainWnd, QWidget* parent = 0);\r\n\r\n    /*!\r\n     *  Destructor.\r\n     */\r\n    ~CSourceTextEdit();\r\n\r\n    /*!\r\n     *  Returns the content matcher.\r\n     */\r\n    CSourceContentMatcher& getMatcher();\r\n\r\n    /*!\r\n     *  Returns the highlighter.\r\n     */\r\n    CSourceHighlighter& getHighlighter();\r\n\r\nprivate:\r\n    // Disable copying.\r\n    CSourceTextEdit(CSourceTextEdit const& rhs);\r\n    CSourceTextEdit& operator=(CSourceTextEdit const& rhs);\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! The MCAPI highlighter.\r\n    CSourceHighlighter* highlighter_;\r\n\r\n    //! The used content matcher.\r\n    QSharedPointer<CSourceContentMatcher> m_matcher;\r\n};\r\n"
  },
  {
    "path": "editors/CSourceEditor/CSourceWidget.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: CSourceWidget.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Joni-Matti Maatta\r\n// Date: 9.5.2011\r\n//\r\n// Description:\r\n// C source widget.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"CSourceWidget.h\"\r\n\r\n#include \"CSourceTextEdit.h\"\r\n#include \"CSourceContentMatcher.h\"\r\n#include \"CSourceHighlighter.h\"\r\n\r\n#include <KactusAPI/include/LibraryInterface.h>\r\n\r\n#include <IPXACTmodels/Component/Component.h>\r\n#include <IPXACTmodels/kactusExtensions/ApiDefinition.h>\r\n#include <IPXACTmodels/kactusExtensions/ApiInterface.h>\r\n#include <IPXACTmodels/kactusExtensions/ComDefinition.h>\r\n\r\n#include <common/TextEditProvider.h>\r\n\r\n#include <QApplication>\r\n#include <QCoreApplication>\r\n#include <QFile>\r\n#include <QFileInfo>\r\n#include <QMessageBox>\r\n#include <QPrinter>\r\n#include <QPrintDialog>\r\n#include <QSettings>\r\n#include <QSharedPointer>\r\n#include <QTextStream>\r\n#include <QVBoxLayout>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: CSourceWidget::CSourceWidget()\r\n//-----------------------------------------------------------------------------\r\nCSourceWidget::CSourceWidget(QString const& sourceFile, QSharedPointer<Component> ownerComponent,\r\n    LibraryInterface* libHandler, QWidget* mainWnd, QWidget* parent):\r\nTabDocument(parent, libHandler, DOC_PRINT_SUPPORT | DOC_EDIT_SUPPORT),\r\n    textEdit_(new CSourceTextEdit(mainWnd, this)),\r\n    sourceFile_(sourceFile),\r\n    editProvider_(new TextEditProvider(*textEdit_))\r\n{\r\n    // Initialize content matcher and highlighter for the text editor.\r\n    textEdit_->getMatcher().setOwner(ownerComponent);\r\n\r\n    foreach (QSharedPointer<ApiInterface const> apiIf, ownerComponent->getApiInterfaces())\r\n    {\r\n        QSharedPointer<Document const> libComp = libHandler->getModelReadOnly(apiIf->getApiType());\r\n        QSharedPointer<ApiDefinition const> apiDef = libComp.dynamicCast<ApiDefinition const>();\r\n\r\n        if (apiDef != 0)\r\n        {\r\n            textEdit_->getMatcher().addSourceApiDefinition(apiDef);\r\n            textEdit_->getHighlighter().registerAPI(apiDef);\r\n\r\n            if (apiDef->getComDefinitionRef().isValid())\r\n            {\r\n                libComp = libHandler->getModelReadOnly(apiDef->getComDefinitionRef());\r\n                QSharedPointer<ComDefinition const> comDef = libComp.dynamicCast<ComDefinition const>();\r\n\r\n                if (comDef != 0)\r\n                {\r\n                    textEdit_->getMatcher().addSourceComDefinition(comDef);\r\n                }\r\n            }\r\n        }\r\n    }\r\n\r\n    // Create the layout.\r\n\tQVBoxLayout* layout = new QVBoxLayout(this);\r\n    layout->addWidget(textEdit_);\r\n\r\n    // Read and apply code editor settings.\r\n    QSettings settings;\r\n    applySettings(settings);\r\n    \r\n    readFileContentFromDisk();\r\n\r\n    setDocumentName(QFileInfo(sourceFile).fileName());\r\n    setDocumentType(DocumentType::CODE);\r\n\r\n    connect(textEdit_->document(), SIGNAL(contentsChanged()),\r\n            this, SIGNAL(contentChanged()), Qt::UniqueConnection);\r\n    connect(this, SIGNAL(contentChanged()), this, SLOT(onContentChanged()), Qt::UniqueConnection);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: CSourceWidget::~CSourceWidget()\r\n//-----------------------------------------------------------------------------\r\nCSourceWidget::~CSourceWidget()\r\n{\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: CSourceWidget::loadSettings()\r\n//-----------------------------------------------------------------------------\r\nvoid CSourceWidget::applySettings(QSettings& settings)\r\n{\r\n    TabDocument::applySettings(settings);\r\n\r\n    // Read indentation settings.\r\n    IndentStyle style = static_cast<IndentStyle>(settings.value(\"Editor/IndentStyle\",\r\n                                                                INDENT_STYLE_SPACES).toInt());\r\n    unsigned int width = settings.value(\"Editor/IndentWidth\", 4).toInt();    \r\n    textEdit_->setIndentStyle(style, width);\r\n\r\n    // Read font settings.\r\n    QFont font = settings.value(\"Editor/Font\", QFont(\"Courier New\", 10)).value<QFont>();\r\n    textEdit_->setFont(font);\r\n\r\n    // Read highlight style settings.\r\n    for (int i = 0; i < CSourceHighlighter::STYLE_COUNT; ++i)\r\n    {\r\n        HighlightStyleDesc styleDesc = settings.value(\"Editor/Highlight/\" + \r\n            CSourceHighlighter::getStyleName(static_cast<CSourceHighlighter::StyleType>(i)),\r\n            QVariant::fromValue(CSourceHighlighter::DEFAULT_STYLES[i])).value<HighlightStyleDesc>();\r\n\r\n        textEdit_->getHighlighter().setStyle(static_cast<CSourceHighlighter::StyleType>(i), styleDesc);\r\n    }\r\n\r\n    textEdit_->getHighlighter().rehighlight();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: CSourceWidget::getSourceFile()\r\n//-----------------------------------------------------------------------------\r\nQString const& CSourceWidget::getSourceFile() const\r\n{\r\n    return sourceFile_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: CSourceWidget::save()\r\n//-----------------------------------------------------------------------------\r\nbool CSourceWidget::save()\r\n{\r\n    QFile file(sourceFile_);\r\n\r\n    // Check if the file could not be opened.\r\n    if (!file.open(QIODevice::WriteOnly | QIODevice::Text))\r\n    {\r\n        QMessageBox msgBox(QMessageBox::Critical, QCoreApplication::applicationName(),\r\n                           tr(\"Unable to save source file \") + sourceFile_ +\r\n                           tr(\"! The file may be read only.\"), QMessageBox::Ok, this);\r\n\r\n        msgBox.exec();\r\n        return false;\r\n    }\r\n\r\n    file.write(textEdit_->toPlainText().toStdString().c_str());\r\n\r\n    return TabDocument::save();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: CSourceWidget::print()\r\n//-----------------------------------------------------------------------------\r\nvoid CSourceWidget::print()\r\n{\r\n    QPrinter printer;\r\n\r\n    // Query the user for printing settings.\r\n    QPrintDialog dlg(&printer, this);\r\n    dlg.setWindowTitle(tr(\"Print Source Document\"));\r\n\r\n    if (textEdit_->textCursor().hasSelection())\r\n    {\r\n        dlg.setOption(QAbstractPrintDialog::PrintSelection, true);\r\n    }\r\n\r\n    if (dlg.exec() != QDialog::Accepted)\r\n    {\r\n        return;\r\n    }\r\n    \r\n    // Print the document.\r\n    textEdit_->print(&printer);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: CSourceWidget::onContentChanged()\r\n//-----------------------------------------------------------------------------\r\nvoid CSourceWidget::onContentChanged()\r\n{\r\n    setModified(true);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: CSourceWidget::getEditProvider()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<IEditProvider> CSourceWidget::getEditProvider() const\r\n{\r\n    return editProvider_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: CSourceWidget::refresh()\r\n//-----------------------------------------------------------------------------\r\nvoid CSourceWidget::refresh()\r\n{\r\n    QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));\r\n\r\n    readFileContentFromDisk();\r\n    \r\n    setModified(false);\r\n    TabDocument::refresh();\r\n\r\n    QApplication::restoreOverrideCursor();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: CSourceWidget::getIdentifyingVLNV()\r\n//-----------------------------------------------------------------------------\r\nVLNV CSourceWidget::getIdentifyingVLNV() const\r\n{\r\n\treturn getDocumentVLNV();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: CSourceWidget::readFileContentFromDisk()\r\n//-----------------------------------------------------------------------------\r\nvoid CSourceWidget::readFileContentFromDisk()\r\n{\r\n    // Read the contents of the file to the text edit.\r\n    QFile file(sourceFile_);\r\n\r\n    bool success = file.open(QIODevice::ReadOnly | QIODevice::Text);\r\n\r\n    if (!success)\r\n    {\r\n        // TODO: Error checking.\r\n        return;\r\n    }\r\n\r\n    QTextStream stream(&file);\r\n    textEdit_->setPlainText(stream.readAll());\r\n}\r\n"
  },
  {
    "path": "editors/CSourceEditor/CSourceWidget.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: CSourceWidget.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Joni-Matti Maatta\r\n// Date: 9.5.2011\r\n//\r\n// Description:\r\n// C source widget.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef MCAPISOURCEWIDGET_H\r\n#define MCAPISOURCEWIDGET_H\r\n\r\n#include \"CSourceHighlighter.h\"\r\n\r\n#include <common/widgets/tabDocument/TabDocument.h>\r\n\r\n#include <QSharedPointer>\r\n#include <QList>\r\n\r\nclass CSourceTextEdit;\r\nclass TextEditProvider;\r\nclass Component;\r\nclass LibraryInterface;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! CSourceWidget class.\r\n//-----------------------------------------------------------------------------\r\nclass CSourceWidget : public TabDocument\r\n{\r\n    Q_OBJECT\r\n\r\npublic:\r\n    /*!\r\n     *  Constructor.\r\n     *\r\n     *    @param [in] sourceFile      The name of the source file in the file system.\r\n     *    @param [in] ownerComponent  The component who \"owns\" the source file that will be edited.\r\n     *    @param [in] libInterface    The library interface.\r\n     *    @param [in] mainWnd         The main window.\r\n     *    @param [in] parent          The parent widget.\r\n     *\r\n     *      @remarks The file is assumed to exist in the file system.\r\n     */\r\n    CSourceWidget(QString const& sourceFile,\r\n                  QSharedPointer<Component> ownerComponent,\r\n                  LibraryInterface* libHandler,\r\n                  QWidget* mainWnd, QWidget* parent = 0);\r\n\r\n    /*!\r\n     *  Destructor.\r\n     */\r\n    virtual ~CSourceWidget();\r\n\r\n\t/*! \\brief Get the VLNV that can be used to identify the document.\r\n\t *\r\n\t * \\return The VLNV that identifies the document.\r\n\t*/\r\n\tvirtual VLNV getIdentifyingVLNV() const;\r\n\r\n    /*!\r\n     *  Applies the current settings into use.\r\n     */\r\n    void applySettings(QSettings& settings) override;\r\n\r\n    /*!\r\n     *  Returns the name of the source file.\r\n     */\r\n    QString const& getSourceFile() const;\r\n\r\n    /*!\r\n     *  Returns the edit provider.\r\n     */\r\n    virtual QSharedPointer<IEditProvider> getEditProvider() const;\r\n        \r\n    virtual void refresh();\r\n\r\npublic slots:\r\n    //! Saves the source file.\r\n    virtual bool save();\r\n\r\n    //! Prints the source.\r\n    void print();\r\n\r\n    //! Called when the contents of the document have changed.\r\n    void onContentChanged();\r\n\r\nprivate:\r\n    // Disable copying.\r\n    CSourceWidget(CSourceWidget const& rhs);    \r\n    CSourceWidget& operator=(CSourceWidget const& rhs);\r\n\r\n    //! Reads the source file content into the editor.\r\n    void readFileContentFromDisk();\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! The MCAPI text edit.\r\n    CSourceTextEdit* textEdit_;\r\n\r\n    //! The source filename.\r\n    QString sourceFile_;\r\n\r\n    //! Edit provider for the text edit.\r\n    QSharedPointer<TextEditProvider> editProvider_;\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n\r\n#endif // MCAPISOURCEWIDGET_H\r\n"
  },
  {
    "path": "editors/CatalogEditor/CatalogEditor.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: CatalogEditor.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Esko Pekkarinen\n// Date: 02.02.2017\n//\n// Description:\n// Editor for editing Catalogs.\n//-----------------------------------------------------------------------------\n\n#include \"CatalogEditor.h\"\n\n#include \"CatalogFileColumns.h\"\n#include \"CatalogFileDelegate.h\"\n#include \"CatalogFileFilter.h\"\n#include \"CatalogFileModel.h\"\n#include \"CatalogFileView.h\"\n\n#include <common/dialogs/newObjectDialog/newobjectdialog.h>\n#include <common/widgets/summaryLabel/summarylabel.h>\n\n#include <KactusAPI/include/LibraryInterface.h>\n\n#include <IPXACTmodels/Catalog/Catalog.h>\n#include <IPXACTmodels/Catalog/validators/CatalogValidator.h>\n\n#include <common/views/EditableTableView/editabletableview.h>\n#include <common/widgets/vlnvDisplayer/vlnvdisplayer.h>\n\n#include <QCoreApplication>\n#include <QMessageBox>\n#include <QGridLayout>\n#include <QSortFilterProxyModel>\n\n//-----------------------------------------------------------------------------\n// Function: CatalogEditor::CatalogEditor()\n//-----------------------------------------------------------------------------\nCatalogEditor::CatalogEditor(LibraryInterface* libHandler, QSharedPointer<Catalog> catalog, QWidget* parent):\nTabDocument(parent, libHandler, DOC_PROTECTION_SUPPORT),\n    catalog_(catalog),\n    documentNameGroupEditor_(new DocumentNameGroupEditor(this)),\n    fileModel_(new CatalogFileModel(libHandler, this)),\n    fileView_(new CatalogFileView(this))\n{\n    // Set the document name and type.\n    VLNV vlnv = catalog_->getVlnv();\n    setDocumentName(vlnv.getName() + \" (\" + vlnv.getVersion() + \")\");\n    setDocumentType(DocumentType::CATALOG);\n\n    documentNameGroupEditor_->setDocumentNameGroup(catalog_, libHandler->getPath(vlnv));\n    documentNameGroupEditor_->setTitle(tr(\"Catalog\"));\n   \n    CatalogFileFilter* proxy = new CatalogFileFilter(catalog_->getRevision(), this);\n    proxy->setSourceModel(fileModel_);\n\n    fileView_->setModel(proxy);\n    fileView_->setItemDelegate(new CatalogFileDelegate(libHandler, this));\n    \n    refresh();\n\n    setupLayout();\n\n    connect(documentNameGroupEditor_, SIGNAL(contentChanged()), this, SIGNAL(contentChanged()), Qt::UniqueConnection);\n\n    connect(fileModel_, SIGNAL(contentChanged()), this, SIGNAL(contentChanged()), Qt::UniqueConnection);\n\n    connect(fileView_, SIGNAL(addItem(QModelIndex const&)),\n        proxy, SLOT(onAddItem(QModelIndex const&)), Qt::UniqueConnection);\n    connect(proxy, SIGNAL(addItem(QModelIndex const&)),\n        fileModel_, SLOT(onAddItem(QModelIndex const&)), Qt::UniqueConnection);\n\n    connect(fileView_, SIGNAL(removeItem(QModelIndex const&)),\n        proxy, SLOT(onRemoveItem(QModelIndex const&)), Qt::UniqueConnection);\n    connect(proxy, SIGNAL(removeItem(QModelIndex const&)),\n        fileModel_, SLOT(onRemoveItem(QModelIndex const&)), Qt::UniqueConnection);\n\n    connect(fileView_, SIGNAL(openItem(QModelIndex const&)),\n        proxy, SLOT(onOpenItem(QModelIndex const&)), Qt::UniqueConnection);\n    connect(proxy, SIGNAL(openItem(QModelIndex const&)),\n        fileModel_, SLOT(onOpenItem(QModelIndex const&)), Qt::UniqueConnection);\n\n    connect(fileModel_, SIGNAL(openCatalog(VLNV const&)),\n        this, SIGNAL(openCatalog(VLNV const&)), Qt::UniqueConnection);\n    connect(fileModel_, SIGNAL(openComponent(VLNV const&)),\n        this, SIGNAL(openComponent(VLNV const&)), Qt::UniqueConnection);\n    connect(fileModel_, SIGNAL(openBus(VLNV const&)),\n        this, SIGNAL(openBus(VLNV const&)), Qt::UniqueConnection);\n    connect(fileModel_, SIGNAL(stdRevisionMismatch()), \n        this, SLOT(showStdRevisionMismatchWarning()), Qt::UniqueConnection);\n}\n\n//-----------------------------------------------------------------------------\n// Function: CatalogEditor::~CatalogEditor()\n//-----------------------------------------------------------------------------\nCatalogEditor::~CatalogEditor()\n{\n}\n\n\n//-----------------------------------------------------------------------------\n// Function: CatalogEditor::getDocumentVLNV()\n//-----------------------------------------------------------------------------\nVLNV CatalogEditor::getDocumentVLNV() const\n{\n    return catalog_->getVlnv();\n}\n\n//-----------------------------------------------------------------------------\n// Function: CatalogEditor::getIdentifyingVLNV()\n//-----------------------------------------------------------------------------\nVLNV CatalogEditor::getIdentifyingVLNV() const\n{\n    return getDocumentVLNV();\n}\n\n//-----------------------------------------------------------------------------\n// Function: CatalogEditor::setProtection()\n//-----------------------------------------------------------------------------\nvoid CatalogEditor::setProtection(bool locked)\n{\n    documentNameGroupEditor_->setDisabled(locked);\n    fileModel_->setProtection(locked);\n    fileView_->setDisabled(locked);\n    \n    TabDocument::setProtection(locked);\n}\n\n//-----------------------------------------------------------------------------\n// Function: CatalogEditor::refresh()\n//-----------------------------------------------------------------------------\nvoid CatalogEditor::refresh()\n{\n    VLNV vlnv = catalog_->getVlnv();\n    catalog_ = getLibHandler()->getModel(vlnv).staticCast<Catalog>();\n\n    // Update the editors.\n    documentNameGroupEditor_->setDocumentNameGroup(catalog_, getLibHandler()->getPath(vlnv));\n    fileModel_->refresh(catalog_);\n\n    for (int row = 0; row <= CatalogFileColumns::CATEGORY_COUNT; row++)\n    {\n        fileView_->setFirstColumnSpanned(row, QModelIndex(), true);\n    }\n\n    fileView_->expandAll();\n\n    for (int column = 0; column <= CatalogFileColumns::COLUMN_COUNT; column++)\n    {\n        fileView_->resizeColumnToContents(column);\n    }\n\n    setModified(false);\n    TabDocument::refresh();\n}\n\n//-----------------------------------------------------------------------------\n// Function: CatalogEditor::validate()\n//-----------------------------------------------------------------------------\nbool CatalogEditor::validate(QVector<QString>& errorList)\n{\n\tCatalogValidator validator;\n    validator.findErrorsIn(errorList, catalog_);\n\n    return errorList.isEmpty();\n}\n\n//-----------------------------------------------------------------------------\n// Function: CatalogEditor::save()\n//-----------------------------------------------------------------------------\nbool CatalogEditor::save()\n{\n    getLibHandler()->writeModelToFile(catalog_);\n\n    return TabDocument::save();\n}\n\n//-----------------------------------------------------------------------------\n// Function: CatalogEditor::saveAs()\n//-----------------------------------------------------------------------------\nbool CatalogEditor::saveAs()\n{\n    // Ask the user for a new VLNV and directory.\n    VLNV vlnv;\n    QString directory;\n\n    if (!NewObjectDialog::saveAsDialog(parentWidget(), getLibHandler(), catalog_->getVlnv(), vlnv, directory))\n    {\n        return false;\n    }\n\n    // Create a copy of the object and update its VLNV.\n    catalog_ = QSharedPointer<Catalog>(new Catalog(*catalog_));\n\n    vlnv.setType(VLNV::CATALOG);\n    catalog_->setVlnv(vlnv);\n\n    if (getLibHandler()->writeModelToFile(directory, catalog_))\n    {\n        setDocumentName(vlnv.getName() + \" (\" + vlnv.getVersion() + \")\");\n        return TabDocument::saveAs();\n    }\n    else\n    {\n        return false;\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: CatalogEditor::showStdRevisionMismatchWarning()\n//-----------------------------------------------------------------------------\nvoid CatalogEditor::showStdRevisionMismatchWarning()\n{\n    QMessageBox::warning(this, QCoreApplication::applicationName(),\n        tr(\"Dropped item cannot use different IP-XACT standard revision than the item being edited.\"),\n        QMessageBox::Close, QMessageBox::Close);\n}\n\n//-----------------------------------------------------------------------------\n// Function: CatalogEditor::showEvent()\n//-----------------------------------------------------------------------------\nvoid CatalogEditor::showEvent(QShowEvent* event)\n{\n    TabDocument::showEvent(event);\n    if (catalog_->getRevision() == Document::Revision::Std14)\n    {\n        emit helpUrlRequested(\"definitions/catalog.html\");\n    }\n    else if (catalog_->getRevision() == Document::Revision::Std22)\n    {\n        emit helpUrlRequested(\"definitions/catalog2022.html\");\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: CatalogEditor::setupLayout()\n//-----------------------------------------------------------------------------\nvoid CatalogEditor::setupLayout()\n{\n    QGroupBox* filesBox = new QGroupBox(tr(\"Catalog files\"), this);\n\n    QVBoxLayout* filesLayout = new QVBoxLayout(filesBox);\n    filesLayout->addWidget(fileView_);\n\n    QHBoxLayout* docNameGroupAndFilesLayout = new QHBoxLayout(this);\n    docNameGroupAndFilesLayout->addWidget(documentNameGroupEditor_);\n    docNameGroupAndFilesLayout->addWidget(filesBox);\n\n    QWidget* docNameGroupAndFiles = new QWidget(this);\n    docNameGroupAndFiles->setLayout(docNameGroupAndFilesLayout);\n\n    QVBoxLayout* topLayout = new QVBoxLayout(this);\n    topLayout->addWidget(new SummaryLabel(tr(\"Catalog\"), this), 0, Qt::AlignCenter);\n    topLayout->addWidget(docNameGroupAndFiles);\n}\n"
  },
  {
    "path": "editors/CatalogEditor/CatalogEditor.h",
    "content": "//-----------------------------------------------------------------------------\n// File: CatalogEditor.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Esko Pekkarinen\n// Date: 02.02.2017\n//\n// Description:\n// Editor for editing Catalogs.\n//-----------------------------------------------------------------------------\n\n#ifndef CATALOGEDITOR_H\n#define CATALOGEDITOR_H\n\n#include <common/widgets/tabDocument/TabDocument.h>\n#include <common/widgets/vlnvEditor/vlnveditor.h>\n\n#include <editors/common/DocumentNameGroupEditor.h>\n\n#include <QTextEdit>\n#include <QTreeView>\n\nclass Catalog;\nclass CatalogFileModel;\nclass LibraryInterface;\nclass VLNVDisplayer;\n\n//-----------------------------------------------------------------------------\n//! Editor for editing Catalogs.\n//-----------------------------------------------------------------------------\nclass CatalogEditor : public TabDocument\n{\n\tQ_OBJECT\n\npublic:\n\t/*!\n     *  Constructor.\n\t *\n\t *    @param [in] library     The library of available IP-XACT documents.\n     *    @param [in] catalog     The catalog to edit.\n     *    @param [in] parent      The parent widget.\n\t */\n\tCatalogEditor(LibraryInterface* libHandler, QSharedPointer<Catalog> catalog, QWidget* parent);\n\t\n\t/*!\n     *  Destructor.\n     */\n\tvirtual ~CatalogEditor();\n\n\t/*! Get the VLNV that can be used to identify the catalog.\n\t *\n\t *    @return The VLNV of the catalog.\n\t*/\n\tvirtual VLNV getIdentifyingVLNV() const;\n\n\t/*!\n     *  Returns the VLNV of the SW design component.\n     */\n\tvirtual VLNV getDocumentVLNV() const;\n    \n    /*!\n     *  Refreshes the editor.\n     */\n    virtual void refresh();\n\n    /*!\n     *  Sets the protection state of the document.\n     *\n     *    @param [in] locked True for locked state; false for unlocked.\n     */\n    virtual void setProtection(bool locked);\n\nsignals:\n    \n    //! Emitted when a catalog should be opened.\n    void openCatalog(VLNV const&);\n\n    //! Emitted when a component should be opened.\n    void openComponent(VLNV const&);\n\npublic slots:\n    /*!\n     *  Validates the document against the IP-XACT standard.\n     *\n     *    @param [out] errorList Error message list for reporting standard violations.\n     *\n     *    @return True if the document is valid. False if there were any violations.\n     */\n    virtual bool validate(QVector<QString>& errorList);\n\n\t//! Saves the document and resets the modified state.\n\tvirtual bool save();\n\n\t//! Saves the document as new object and resets modifies state\n\tvirtual bool saveAs();\n\n    /*!\n     *  Displays warning message when trying to drag and drop an IP-XACT file using different standard revision\n     *  than the catalog.\n     */\n    void showStdRevisionMismatchWarning();\n    \nprotected:\n    //! Called when the editor is shown.\n    virtual void showEvent(QShowEvent* event);\n\nprivate:\n    // Disable copying.\n    CatalogEditor(CatalogEditor const& rhs);\n    CatalogEditor& operator=(CatalogEditor const& rhs);\n\n    //! Sets the editor layout.\n    void setupLayout();\n\n    //-----------------------------------------------------------------------------\n    // Data.\n    //-----------------------------------------------------------------------------\n\n    //! The catalog being edited.\n    QSharedPointer<Catalog> catalog_;\n\n    //! The document name group editor.\n    DocumentNameGroupEditor* documentNameGroupEditor_;\n\n    //! Model for catalog files.\n    CatalogFileModel* fileModel_;\n\n    //! View for catalog files.\n    QTreeView* fileView_;\n\n};\n\n//-----------------------------------------------------------------------------\n\n#endif // CATALOGEDITOR_H\n"
  },
  {
    "path": "editors/CatalogEditor/CatalogFileColumns.h",
    "content": "//-----------------------------------------------------------------------------\n// File: CatalogFileColumns.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Esko Pekkarinen\n// Date: 02.02.2017\n//\n// Description:\n// Common declarations for ipxactFiles in catalog editor.\n//-----------------------------------------------------------------------------\n\n#include <IPXACTmodels/common/VLNV.h>\n\nnamespace CatalogFileColumns\n{\n    //! The editable columns in the ipxactFiles of the catalog editor.\n    enum columns\n    {\n        VENDOR = 0,\n        LIBRARY,\n        NAME,\n        VERSION,\n        PATH,\n        COLUMN_COUNT\n    };\n\n    //! Types in the different categories.\n    enum categories{\n        CATALOGS = 0,\n        BUS_DEFINITIONS,\n        ABSTRACTION_DEFINITIONS,\n        COMPONENTS,\n        ABSTRACTORS,\n        DESIGNS,\n        DESIGN_CONFIGURATIONS,\n        GENERATOR_CHAINS,\n        TYPE_DEFINITIONS,\n        UNKNOWN,\n        CATEGORY_COUNT\n    };   \n\n    //! VLNV types in the different categories.\n    const VLNV::IPXactType CATEGORY_TYPES[CatalogFileColumns::CATEGORY_COUNT] =\n    {\n        VLNV::CATALOG,\n        VLNV::BUSDEFINITION,\n        VLNV::ABSTRACTIONDEFINITION,\n        VLNV::COMPONENT,\n        VLNV::ABSTRACTOR,\n        VLNV::DESIGN,\n        VLNV::DESIGNCONFIGURATION,\n        VLNV::GENERATORCHAIN,\n        VLNV::TYPEDEFINITION,\n        VLNV::INVALID\n    };\n\n}\n"
  },
  {
    "path": "editors/CatalogEditor/CatalogFileDelegate.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: CatalogFileDelegate.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Esko Pekkarinen\n// Date: 03.02.2017\n//\n// Description:\n// Delegate to provide editors to edit catalog files.\n//-----------------------------------------------------------------------------\n\n#include \"CatalogFileDelegate.h\"\n\n#include \"CatalogFileColumns.h\"\n\n#include <common/widgets/assistedLineEdit/AssistedLineEdit.h>\n#include <common/widgets/vlnvEditor/VLNVContentMatcher.h>\n\n#include <QPen>\n\n//-----------------------------------------------------------------------------\n// Function: CatalogFileDelegate::CatalogFileDelegate()\n//-----------------------------------------------------------------------------\nCatalogFileDelegate::CatalogFileDelegate(LibraryInterface* library, QObject *parent):\nQStyledItemDelegate(parent),    \n    library_(library),\nmatcher_(new VLNVContentMatcher()),\ndataTree_(new VLNVDataTree())\n\n{\n    \n}\n\n//-----------------------------------------------------------------------------\n// Function: CatalogFileDelegate::~CatalogFileDelegate()\n//-----------------------------------------------------------------------------\nCatalogFileDelegate::~CatalogFileDelegate()\n{\n    delete matcher_;\n    delete dataTree_;\n}\n\n//-----------------------------------------------------------------------------\n// Function: CatalogFileDelegate::sizeHint()\n//-----------------------------------------------------------------------------\nQSize CatalogFileDelegate::sizeHint(QStyleOptionViewItem const& option, QModelIndex const& index) const\n{\n    return QStyledItemDelegate::sizeHint(option, index) + QSize(0, 4);\n}\n\n//-----------------------------------------------------------------------------\n// Function: CatalogFileDelegate::paint()\n//-----------------------------------------------------------------------------\nvoid CatalogFileDelegate::paint(QPainter* painter, QStyleOptionViewItem const& option,\n    QModelIndex const& index) const\n{\n    QStyledItemDelegate::paint(painter, option, index);\n\n    painter->save();\n\n    QPen newPen(Qt::lightGray);\n    newPen.setWidth(1);\n    painter->setPen(newPen);\n\n    painter->drawLine(option.rect.topRight(), option.rect.bottomRight());\n\n    painter->restore();\n}\n\n//-----------------------------------------------------------------------------\n// Function: CatalogFileDelegate::createEditor()\n//-----------------------------------------------------------------------------\nQWidget * CatalogFileDelegate::createEditor(QWidget *parent, QStyleOptionViewItem const& option,\n    QModelIndex const& index) const\n{\n    if (index.column() < CatalogFileColumns::PATH)\n    {\n        updateSuggestedItems(index);\n\n        AssistedLineEdit* editor = new AssistedLineEdit(parent->window(), parent);\n        editor->setContentMatcher(matcher_);\n        return editor;\n    }\n    else\n    {\n        return QStyledItemDelegate::createEditor(parent, option, index);\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: CatalogFileDelegate::updateSuggestedItems()\n//-----------------------------------------------------------------------------\nvoid CatalogFileDelegate::updateSuggestedItems(QModelIndex const& index) const\n{\n    QList<VLNV::IPXactType> types;\n    VLNV::IPXactType type = CatalogFileColumns::CATEGORY_TYPES[index.parent().row()];\n    types.append(type);\n\n    dataTree_->clear();\n    dataTree_->parse(library_, types);\n\n    VLNVDataNode const* dataNode = dataTree_;\n    for (int column = CatalogFileColumns::VENDOR; column < index.column(); column++)\n    {\n        if (dataNode)\n        {\n            QString previousLevel = index.sibling(index.row(), column).data(Qt::DisplayRole).toString();\n            dataNode = dataNode->findChild(previousLevel);\n        }\n    }\n\n    matcher_->setDataNode(dataNode);\n}\n"
  },
  {
    "path": "editors/CatalogEditor/CatalogFileDelegate.h",
    "content": "//-----------------------------------------------------------------------------\n// File: CatalogFileDelegate.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Esko Pekkarinen\n// Date: 03.02.2017\n//\n// Description:\n// Delegate to provide editors to edit catalog files.\n//-----------------------------------------------------------------------------\n\n#ifndef CATALOGFILEDELEGATE_H\n#define CATALOGFILEDELEGATE_H\n\n#include <common/widgets/vlnvEditor/VLNVDataTree.h>\n\n#include <QPainter>\n#include <QSharedPointer>\n#include <QStyledItemDelegate>\n\n\nclass LibraryInterface;\nclass VLNVContentMatcher;\n\n//-----------------------------------------------------------------------------\n// ! Delegate to provide editors to edit catalog files.\n//-----------------------------------------------------------------------------\nclass CatalogFileDelegate : public QStyledItemDelegate\n{\n\tQ_OBJECT\n\npublic:\n\n\t/*!\n     *  The constructor.\n\t *\n     *    @param [in] library     The library of available IP-XACT documents.\n\t *    @param [in] parent      The parent of this delegate.\n\t */\n\tCatalogFileDelegate(LibraryInterface* library, QObject *parent);\n\t\n\t/*!\n     *  The destructor.\n     */\n    virtual ~CatalogFileDelegate();\n       \n    /*!\n     *  Returns the size hint for the given model index.\n     */\n    virtual QSize sizeHint(QStyleOptionViewItem const& option, QModelIndex const& index) const;\n\n    /*!\n     *  Paint the memory maps.\n     *\n     *    @param [in] painter     The used painter.\n     *    @param [in] option      Available style options.\n     *    @param [in] index       The current index.\n     */\n    virtual void paint(QPainter* painter, QStyleOptionViewItem const& option, QModelIndex const& index) const;\n    \n    /*!\n     *  Creates an editor for the given index.\n     *\n     *    @param [in] parent      The parent widget for the editor.\n     *    @param [in] option      Format options for the editor.\n     *    @param [in] index       The index whose content to edit in the editor.\n     *\n     *    @return Editor for the index.\n     */\n    virtual QWidget* createEditor(QWidget* parent,  QStyleOptionViewItem const& option, \n        QModelIndex const& index) const;\n  \nprivate:\n\n\t//! No copying.\n\tCatalogFileDelegate(const CatalogFileDelegate& other);\n\tCatalogFileDelegate& operator=(const CatalogFileDelegate& other);\n      \n    /*!\n     *  Updates the suggested items in the editor for the given index.\n     *\n     *    @param [in] index   The index whose content to suggest.\n     */\n    void updateSuggestedItems(QModelIndex const& index) const;\n\n    //-----------------------------------------------------------------------------\n    // Data.\n    //-----------------------------------------------------------------------------\n\n    //! The library of available IP-XACT documents.\n    LibraryInterface* library_;\n\n    //! Matcher for editor suggestions.\n    VLNVContentMatcher* matcher_;\n\n    //! The VLNV data tree.\n    VLNVDataTree* dataTree_;\n};\n\n#endif // CATALOGFILEDELEGATE_H\n"
  },
  {
    "path": "editors/CatalogEditor/CatalogFileFilter.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: CatalogFileFilter.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Esko Pekkarinen\n// Date: 10.03.2015\n//\n// Description:\n// Class for filtering catalog files model.\n//-----------------------------------------------------------------------------\n\n#include \"CatalogFileFilter.h\"\n#include \"CatalogFileColumns.h\"\n\n//-----------------------------------------------------------------------------\n// Function: CatalogFileFilter::CatalogFileFilter()\n//-----------------------------------------------------------------------------\nCatalogFileFilter::CatalogFileFilter(Document::Revision docRevision, QObject *parent): \n    QSortFilterProxyModel(parent),\n    docRevision_(docRevision)\n{\n    setSortCaseSensitivity(Qt::CaseInsensitive);\n}\n\n//-----------------------------------------------------------------------------\n// Function: CatalogFileFilter::~CatalogFileFilter()\n//-----------------------------------------------------------------------------\nCatalogFileFilter::~CatalogFileFilter()\n{\n}\n\n//-----------------------------------------------------------------------------\n// Function: CatalogFileFilter::onAddItem()\n//-----------------------------------------------------------------------------\nvoid CatalogFileFilter::onAddItem(QModelIndex const& index)\n{\n    emit addItem(mapToSource(index));\n}\n\n//-----------------------------------------------------------------------------\n// Function: CatalogFileFilter::onRemoveItem()\n//-----------------------------------------------------------------------------\nvoid CatalogFileFilter::onRemoveItem(QModelIndex const& index)\n{\n    emit removeItem(mapToSource(index));\n}\n\n//-----------------------------------------------------------------------------\n// Function: CatalogFileFilter::onOpenItem()\n//-----------------------------------------------------------------------------\nvoid CatalogFileFilter::onOpenItem(QModelIndex const& index)\n{\n    emit openItem(mapToSource(index));\n}\n\n//-----------------------------------------------------------------------------\n// Function: CatalogFileFilter::filterAcceptsColumn()\n//-----------------------------------------------------------------------------\nbool CatalogFileFilter::filterAcceptsRow(int source_row, const QModelIndex& /*source_parent*/) const\n{\n    if (source_row == CatalogFileColumns::TYPE_DEFINITIONS && docRevision_ != Document::Revision::Std22)\n    {\n        return false;\n    }\n\n    return true;\n}"
  },
  {
    "path": "editors/CatalogEditor/CatalogFileFilter.h",
    "content": "//-----------------------------------------------------------------------------\n// File: CatalogFileFilter.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Esko Pekkarinen\n// Date: 03.02.2017\n//\n// Description:\n// Class for filtering catalog files model.\n//-----------------------------------------------------------------------------\n\n#ifndef CatalogFileFILTER_H\n#define CatalogFileFILTER_H\n\n#include <KactusAPI/include/utils.h>\n#include <IPXACTmodels/common/Document.h>\n\n#include <QSharedPointer>\n#include <QSortFilterProxyModel>\n#include <QString>\n\n//-----------------------------------------------------------------------------\n//! Class for filtering catalog files model.\n//-----------------------------------------------------------------------------\nclass CatalogFileFilter : public QSortFilterProxyModel\n{\n\tQ_OBJECT\n\npublic:\n\n    /*!\n     *  The constructor.\n     *\n     *    @param [in] docRevision   The standard revision of the document.\n     *    @param [in] parent        The parent object.\n     */\n    CatalogFileFilter(Document::Revision docRevision, QObject *parent = 0);\n\n\t//! The destructor\n    virtual ~CatalogFileFilter();\n\npublic slots:\n\n    //! Called when an item should be added in the given index.\n    void onAddItem(QModelIndex const& index);\n\n    //! Called when an item should be removed from the given index.\n    void onRemoveItem(QModelIndex const& index);\n\n    //! Called when an item should be opened in the given index.\n    void onOpenItem(QModelIndex const& index);\n\nsignals:\n\n    //! Emitted when an item should be added in the given index.\n    void addItem(QModelIndex const& index);\n\n    //! Emitted when an item should be removed from the given index.\n    void removeItem(QModelIndex const& index);\n\n    //! Emitted when an item should be opened in the given index.\n    void openItem(QModelIndex const& index);\nprotected:\n\n    /*!\n     *  Implementation of the row filtering.\n     *\n     *    @param [in] source_row      The row to check for filtering.\n     *    @param [in] source_parent   The parent index of the row.\n     *\n     *    @return True, if the row passes the filters, otherwise false.\n     */\n    bool filterAcceptsRow(int source_row, const QModelIndex& source_parent) const override;\n\nprivate:\n\n\t//! No copying\n\tCatalogFileFilter(const CatalogFileFilter& other);\n\n\t//! No assignment\n\tCatalogFileFilter& operator=(const CatalogFileFilter& other);\n\n    //! The std revision of the catalog document.\n    Document::Revision docRevision_;\n\n};\n\n#endif // CatalogFileFILTER_H\n"
  },
  {
    "path": "editors/CatalogEditor/CatalogFileModel.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: CatalogFileModel.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Esko Pekkarinen\n// Date: 02.02.2017\n//\n// Description:\n// Model class for ipxactFiles in a catalog.\n//-----------------------------------------------------------------------------\n\n#include \"CatalogFileModel.h\"\n\n#include \"CatalogFileColumns.h\"\n\n#include <KactusAPI/include/FileHandler.h>\n#include <common/KactusColors.h>\n\n#include <KactusAPI/include/LibraryInterface.h>\n\n#include <IPXACTmodels/common/VLNV.h>\n#include <IPXACTmodels/common/DocumentUtils.h>\n\n#include <IPXACTmodels/AbstractionDefinition/AbstractionDefinition.h>\n#include <IPXACTmodels/Catalog/Catalog.h>\n#include <IPXACTmodels/Catalog/IpxactFile.h>\n\n#include <QFileInfo>\n#include <QIcon>\n#include <QSize>\n#include <QMimeData>\n\n//-----------------------------------------------------------------------------\n// Private namespace.\n//-----------------------------------------------------------------------------\nnamespace\n{\n    const QString CATEGORIES[CatalogFileColumns::CATEGORY_COUNT] =\n    {\n        QLatin1String(\"Catalogs\"),\n        QLatin1String(\"Bus definitions\"),\n        QLatin1String(\"Abstraction definitions\"),\n        QLatin1String(\"Components\"),\n        QLatin1String(\"Abstractors\"),\n        QLatin1String(\"Designs\"),\n        QLatin1String(\"Design configurations\"),\n        QLatin1String(\"Generator chains\"),\n        QLatin1String(\"Type definitions\"),\n        QLatin1String(\"Unknown\")\n    };\n\n    const QString ICONS[CatalogFileColumns::CATEGORY_COUNT] =\n    {\n        QLatin1String(\":icons/common/graphics/catalog.png\"),\n        QLatin1String(\":icons/common/graphics/bus-def.png\"),\n        QLatin1String(\":icons/common/graphics/abs-def.png\"),        \n        QLatin1String(\":icons/common/graphics/hw-component.png\"),\n        QLatin1String(\":icons/common/graphics/connect.png\"),\n        QLatin1String(\":icons/common/graphics/hw-design.png\"),\n        QLatin1String(\":icons/common/graphics/configuration.png\"),\n        QLatin1String(\":icons/common/graphics/generatorChain.png\"),\n        QLatin1String(\":icons/common/graphics/ruler.png\"),\n        QLatin1String(\":icons/common/graphics/exclamation--frame.png\")\n    };\n}\n\n//-----------------------------------------------------------------------------\n// Function: CatalogFileModel::CatalogFileModel()\n//-----------------------------------------------------------------------------\nCatalogFileModel::CatalogFileModel(LibraryInterface* library, QObject *parent) :\nQAbstractItemModel(parent),\n    catalog_(),\n    library_(library),\n    topLevelRows_(),\n    locked_(true)\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: CatalogFileModel::~CatalogFileModel()\n//-----------------------------------------------------------------------------\nCatalogFileModel::~CatalogFileModel()\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: CatalogFileModel::setProtection()\n//-----------------------------------------------------------------------------\nvoid CatalogFileModel::setProtection(bool locked)\n{\n    locked_ = locked;\n} \n\n//-----------------------------------------------------------------------------\n// Function: CatalogFileModel::refresh()\n//-----------------------------------------------------------------------------\nvoid CatalogFileModel::refresh(QSharedPointer<Catalog> catalog)\n{\n    catalog_ = catalog;\n    \n    beginResetModel();\n    topLevelRows_.clear();\n    topLevelRows_.append(catalog->getCatalogs());\n    topLevelRows_.append(catalog->getBusDefinitions());\n    topLevelRows_.append(catalog->getAbstractionDefinitions());\n    topLevelRows_.append(catalog->getComponents());\n    topLevelRows_.append(catalog->getAbstractors());\n    topLevelRows_.append(catalog->getDesigns());\n    topLevelRows_.append(catalog->getDesignConfigurations());\n    topLevelRows_.append(catalog->getGeneratorChains());\n    topLevelRows_.append(catalog->getTypeDefinitions());\n    topLevelRows_.append(QSharedPointer<QList<QSharedPointer<IpxactFile> > >(\n        new QList<QSharedPointer<IpxactFile> > ())); //<! Other, unknown items.\n    \n    endResetModel();\n\n    Q_ASSERT(topLevelRows_.count() == CatalogFileColumns::CATEGORY_COUNT);\n}\n\n//-----------------------------------------------------------------------------\n// Function: CatalogFileModel::columnCount()\n//-----------------------------------------------------------------------------\nint CatalogFileModel::columnCount(QModelIndex const& /*parent*/) const\n{\n    return CatalogFileColumns::COLUMN_COUNT;\n}\n\n//-----------------------------------------------------------------------------\n// Function: CatalogFileModel::rowCount()\n//-----------------------------------------------------------------------------\nint CatalogFileModel::rowCount(QModelIndex const& parent) const\n{\n    if (!parent.isValid())\n    {\n        return topLevelRows_.count();\n    }\n\n    for (int i = 0; i < topLevelRows_.count(); i++)\n    {\n        if (parent.internalPointer() == topLevelRows_.at(i).data())\n        {\n            return topLevelRows_.at(i)->count();\n        }\n    }\n\n    return 0;\n}\n\n//-----------------------------------------------------------------------------\n// Function: CatalogFileModel::index()\n//-----------------------------------------------------------------------------\nQModelIndex CatalogFileModel::index(int row, int column, QModelIndex const& parent) const\n{\n    if (!parent.isValid() && 0 <= row && row < topLevelRows_.count())\n    {\n        return createIndex(row, column, topLevelRows_.at(row).data());\n    }\n\n    for (int i = 0; i < topLevelRows_.count(); i++)\n    {\n        if (parent.internalPointer() == topLevelRows_.at(i).data() && row < topLevelRows_.at(i)->count())\n        {\n            return createIndex(row, column, topLevelRows_.at(i)->at(row).data());\n        }\n    }\n\n    return QModelIndex();\n}\n\n//-----------------------------------------------------------------------------\n// Function: CatalogFileModel::parent()\n//-----------------------------------------------------------------------------\nQModelIndex CatalogFileModel::parent(QModelIndex const& child) const\n{\n    for (int topRow = 0; topRow < topLevelRows_.count(); topRow++)\n    {\n        for (int childRow = 0; childRow < topLevelRows_.at(topRow)->count(); childRow++)\n        {\n            if (topLevelRows_.at(topRow)->at(childRow).data() == child.internalPointer())\n            {\n                return createIndex(topRow, 0, topLevelRows_.at(topRow).data());\n            }\n        }\n    }\n\n    return QModelIndex();\n}\n\n//-----------------------------------------------------------------------------\n// Function: CatalogFileModel::headerData()\n//-----------------------------------------------------------------------------\nQVariant CatalogFileModel::headerData(int section, Qt::Orientation orientation, int role) const\n{\n    if (orientation == Qt::Horizontal)\n    {\n        if (role == Qt::DisplayRole)\n        {\n            if (section == CatalogFileColumns::VENDOR)\n            {\n                return tr(\"Vendor\");\n            }\n            else if (section == CatalogFileColumns::LIBRARY)\n            {\n                return tr(\"Library\");\n            }\n            else if (section == CatalogFileColumns::NAME)\n            {\n                return tr(\"Name\");\n            }\n            else if (section == CatalogFileColumns::VERSION)\n            {\n                return tr(\"Version\");\n            }\n            else if (section == CatalogFileColumns::PATH)\n            {\n                return tr(\"Path\");\n            }          \n        }\n\n        else if (role == Qt::TextAlignmentRole)\n        {\n            return Qt::AlignCenter;\n        }\n    }\n\n    return QVariant();\n}\n\n//-----------------------------------------------------------------------------\n// Function: CatalogFileModel::data()\n//-----------------------------------------------------------------------------\nQVariant CatalogFileModel::data(QModelIndex const& index, int role) const\n{\n    if (!index.isValid())\n    {\n        return QVariant();\n    }\n\n    if (!index.parent().isValid())\n    {\n        if (index.column() == 0 && role == Qt::DisplayRole)\n        {\n            return CATEGORIES[index.row()];\n        }\n        else if (role == Qt::BackgroundRole)\n        {\n            return KactusColors::STRONG_FIELD;\n        }\n        else if (role == Qt::DecorationRole && index.column() == 0)\n        {\n            return QIcon(ICONS[index.row()]);\n        }\n    }\n\n    else\n    {\n        QSharedPointer<IpxactFile> file = topLevelRows_.at(index.parent().row())->at(index.row());\n\n        if (role == Qt::DisplayRole || role == Qt::EditRole)\n        {\n            if (index.column() == CatalogFileColumns::VENDOR)\n            {\n                return file->getVlnv().getVendor();\n            }\n            if (index.column() == CatalogFileColumns::LIBRARY)\n            {\n                return file->getVlnv().getLibrary();\n            }\n            if (index.column() == CatalogFileColumns::NAME)\n            {\n                return file->getVlnv().getName();\n            }\n            if (index.column() == CatalogFileColumns::VERSION)\n            {\n                return file->getVlnv().getVersion();\n            }\n            if (index.column() == CatalogFileColumns::PATH)\n            {\n                return file->getName();\n            }\n        }\n\n        if (role == Qt::ForegroundRole)\n        {\n            if (locked_)\n            {\n                return KactusColors::DISABLED_TEXT;\n            }\n\n            if (index.column() == CatalogFileColumns::PATH)\n            {\n                if (!isValidPath(file->getName()))\n                {\n                    return KactusColors::ERROR;\n                }\n            }\n            else if (library_->getDocumentType(file->getVlnv()) != \n                CatalogFileColumns::CATEGORY_TYPES[index.parent().row()])\n            {\n                return KactusColors::ERROR;\n            }\n        }\n    }\n\n    // Unsupported role.\n    return QVariant();\n}\n\n//-----------------------------------------------------------------------------\n// Function: CatalogFileModel::setData()\n//-----------------------------------------------------------------------------\nbool CatalogFileModel::setData(QModelIndex const& index, QVariant const& value, int role)\n{\n    if (locked_ || !index.isValid() || !index.parent().isValid())\n    {\n        return false;\n    }\n\n    if (role == Qt::EditRole)\n    {\n        QSharedPointer<IpxactFile> file = topLevelRows_.at(index.parent().row())->at(index.row());\n        VLNV fileVLNV = file->getVlnv();\n\n        if (index.column() == CatalogFileColumns::VENDOR)\n        {\n            fileVLNV.setVendor(value.toString());\n            file->setVlnv(fileVLNV);\n        }\n        else if (index.column() == CatalogFileColumns::LIBRARY)\n        {\n            fileVLNV.setLibrary(value.toString());\n            file->setVlnv(fileVLNV);\n        }\n        else if (index.column() == CatalogFileColumns::NAME)\n        {\n            fileVLNV.setName(value.toString());\n            file->setVlnv(fileVLNV);\n        }\n        else if (index.column() == CatalogFileColumns::VERSION)\n        {\n            fileVLNV.setVersion(value.toString());\n            file->setVlnv(fileVLNV);\n        }\n        else if (index.column() == CatalogFileColumns::PATH)\n        {\n            file->setName(value.toString());\n        }\n\n        emit dataChanged(index, index);\n        emit contentChanged();\n\n        return true;\n    }\n\n    return false;\n}\n\n//-----------------------------------------------------------------------------\n// Function: CatalogFileModel::flags()\n//-----------------------------------------------------------------------------\nQt::ItemFlags CatalogFileModel::flags(QModelIndex const& index) const\n{\n    Qt::ItemFlags itemFlags = Qt::ItemIsEnabled | Qt::ItemIsSelectable;\n\n    if (!locked_)\n    {\n        itemFlags |= Qt::ItemIsDropEnabled;\n    }\n\n    if (!locked_ && index.parent().isValid())\n    {\n        itemFlags |= Qt::ItemIsEditable; \n    }\n\n    return itemFlags;\n}\n\n//-----------------------------------------------------------------------------\n// Function: CatalogFileModel::mimeTypes()\n//-----------------------------------------------------------------------------\nQStringList CatalogFileModel::mimeTypes() const\n{\n    QStringList types(QAbstractItemModel::mimeTypes());\n    types << \"application/x-qt-image\";\n    return types;\n}\n\n//-----------------------------------------------------------------------------\n// Function: CatalogFileModel::supportedDropActions()\n//-----------------------------------------------------------------------------\nQt::DropActions CatalogFileModel::supportedDropActions() const\n{\n    return Qt::CopyAction | Qt::MoveAction;\n}\n\n//-----------------------------------------------------------------------------\n// Function: CatalogFileModel::dropMimeData()\n//-----------------------------------------------------------------------------\nbool CatalogFileModel::dropMimeData(QMimeData const* data, Qt::DropAction action, int /*row*/, int /*column*/,\n    QModelIndex const& /*parent*/)\n{\n    if (action == Qt::IgnoreAction)\n    {\n        return true;\n    }\n\n    QVariant variant = data->imageData();\n    if (!variant.canConvert<VLNV>())\n    {\n        return false;\n    }\n\n    VLNV vlnv = variant.value<VLNV>();\n    QString catalogPath = library_->getPath(catalog_->getVlnv());\n    QString path = General::getRelativePath(catalogPath, library_->getPath(vlnv));\n\n    QSharedPointer<IpxactFile> droppedFile(new IpxactFile());\n    droppedFile->setVlnv(vlnv);\n    droppedFile->setName(path);\n\n    if (!DocumentUtils::documentsHaveMatchingStdRevisions(catalog_->getVlnv(), vlnv, library_))\n    {\n        emit stdRevisionMismatch();\n        return false;\n    }\n\n    addFile(droppedFile);\n\n    if (vlnv.getType() != VLNV::CATALOG)\n    {\n        for (VLNV const& dependentVlnv : library_->getModelReadOnly(vlnv)->getDependentVLNVs())\n        {\n            QSharedPointer<IpxactFile> dependentFile(new IpxactFile());\n            dependentFile->setVlnv(dependentVlnv);\n\n            QString dependentPath = General::getRelativePath(catalogPath, library_->getPath(dependentVlnv));\n            dependentFile->setName(dependentPath);\n\n            addFile(dependentFile);\n        }\n    }\n\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: CatalogFileModel::onAddItem()\n//-----------------------------------------------------------------------------\nvoid CatalogFileModel::onAddItem(QModelIndex const& index)\n{\n    if (locked_)\n    {\n        return;\n    }\n\n    VLNV::IPXactType type = VLNV::INVALID;\n\n    if (index.isValid())\n    {\n        if (index.parent().isValid())\n        {\n            type = CatalogFileColumns::CATEGORY_TYPES[index.parent().row()];\n        }\n        else\n        {\n            type = CatalogFileColumns::CATEGORY_TYPES[index.row()];\n        }\n    }\n\n    VLNV vlnv;    \n    vlnv.setType(type);\n\n    QSharedPointer<IpxactFile> file(new IpxactFile());\n    file->setVlnv(vlnv);\n    addFile(file);  \n}\n\n//-----------------------------------------------------------------------------\n// Function: CatalogFileModel::onRemoveItem()\n//-----------------------------------------------------------------------------\nvoid CatalogFileModel::onRemoveItem(QModelIndex const& index)\n{\n    if (locked_ || !index.isValid() || !index.parent().isValid())\n    {\n        return;\n    }\n\n    int category = index.parent().row();\n    int row = index.row();\n\n    beginRemoveRows(index.parent(), row, row);\n    topLevelRows_.at(category)->removeAt(row);\n    endRemoveRows();\n\n    emit contentChanged();\n}\n\n//-----------------------------------------------------------------------------\n// Function: CatalogFileModel::onOpenItem()\n//-----------------------------------------------------------------------------\nvoid CatalogFileModel::onOpenItem(QModelIndex const& index)\n{\n    if (!index.isValid() || !index.parent().isValid())\n    {\n        return;\n    }\n\n    QSharedPointer<IpxactFile> file = topLevelRows_.at(index.parent().row())->at(index.row());\n    VLNV fileVLNV = file->getVlnv();\n\n    VLNV::IPXactType type = CatalogFileColumns::CATEGORY_TYPES[index.parent().row()];\n    if (type == VLNV::CATALOG)\n    {\n        emit openCatalog(fileVLNV);\n    }\n    else if (type == VLNV::BUSDEFINITION)\n    {\n        emit openBus(fileVLNV);\n    }\n    else if (type == VLNV::ABSTRACTIONDEFINITION)\n    {\n        emit openAbsDef(fileVLNV);\n    }\n    else if (type == VLNV::COMPONENT)\n    {\n        emit openComponent(fileVLNV);\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: CatalogFileModel::addFile()\n//-----------------------------------------------------------------------------\nvoid CatalogFileModel::addFile(QSharedPointer<IpxactFile> fileToAdd)\n{\n    VLNV vlnv = fileToAdd->getVlnv();\n\n    if (vlnv.isEmpty() || !contains(vlnv))\n    {\n        int category = 0;\n        for (category = 0; category < CatalogFileColumns::UNKNOWN; category++)\n        {\n            if (vlnv.getType() == CatalogFileColumns::CATEGORY_TYPES[category])\n            {\n                break;\n            }\n        }\n\n        QModelIndex parentIndex = index(category, 0, QModelIndex());\n        int lastRow = rowCount(parentIndex);\n\n        beginInsertRows(parentIndex, lastRow, lastRow);\n        topLevelRows_.at(category)->append(fileToAdd);\n        endInsertRows();\n           \n        emit contentChanged();\n    }   \n}\n\n//-----------------------------------------------------------------------------\n// Function: CatalogFileModel::contains()\n//-----------------------------------------------------------------------------\nbool CatalogFileModel::contains(VLNV const& vlnv) const\n{\n    foreach (QSharedPointer<QList<QSharedPointer<IpxactFile> > > topLevel, topLevelRows_)\n    {\n        foreach (QSharedPointer<IpxactFile> file, *topLevel)\n        {\n            if (file->getVlnv() == vlnv)\n            {\n                return true;\n            }\n        }\n    }\n    return false;\n}\n\n//-----------------------------------------------------------------------------\n// Function: CatalogFileModel::isValidPath()\n//-----------------------------------------------------------------------------\nbool CatalogFileModel::isValidPath(QString const& path) const\n{\n    QString basePath = library_->getPath(catalog_->getVlnv());\n    return FileHandler::isValidURI(basePath, path);\n}\n"
  },
  {
    "path": "editors/CatalogEditor/CatalogFileModel.h",
    "content": "//-----------------------------------------------------------------------------\n// File: CatalogFileModel.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Esko Pekkarinen\n// Date: 02.02.2017\n//\n// Description:\n// Model class for ipxactFiles in a catalog.\n//-----------------------------------------------------------------------------\n\n#ifndef CATALOGFILEMODEL_H\n#define CATALOGFILEMODEL_H\n\n#include <IPXACTmodels/common/VLNV.h>\n\n#include <QModelIndex>\n#include <QIcon>\n#include <QAbstractItemModel>\n#include <QSharedPointer>\n\nclass LibraryInterface;\n\nclass Catalog;\nclass IpxactFile;\n\n//-----------------------------------------------------------------------------\n//! Model class for ipxactFiles in a catalog.\n//-----------------------------------------------------------------------------\nclass CatalogFileModel : public QAbstractItemModel\n{\n    Q_OBJECT\n\npublic:\n\n    /*!\n     *  The constructor.\n     *\n     *    @param [in] library     The library of available IP-XACT documents.\n     *    @param [in] parent      The parent object.\n     */\n    CatalogFileModel(LibraryInterface* library, QObject *parent);\n\n    /*!\n     *  The destructor.\n     */\n    virtual ~CatalogFileModel();\n\n    /*!\n     *  Sets the protection against changes.\n     *\n     *    @param [in] locked   Lock against changes or not.\n     */\n    void setProtection(bool locked);\n\n    /*!\n     *  Refreshes the model content from the given catalog.\n     *\n     *    @param [in] catalog   The catalog whose files to display.\n     */\n    void refresh(QSharedPointer<Catalog> catalog);\n\n    /*!\n     *  Returns the number of columns in this model.\n     *\n     *    @param [in] parent  Model index identifying the item whose column count is requested.\n     *\n     *    @return The number of columns.\n     */\n    virtual int columnCount(QModelIndex const&  parent = QModelIndex() ) const;\n\n    /*! \n     *  Returns the number of rows an item has.\n     *\n     *    @param [in] parent  Model index identifying the item whose row count is wanted.\n     *\n     *    @return The number of rows the item has.\n     */\n    virtual int rowCount(QModelIndex const& parent = QModelIndex()) const;\n\n    /*!\n     *  Get the model index of the specified object.\n     *\n     *    @param [in] row     Row number of the object.\n     *    @param [in] column  Column number of the object.\n     *    @param [in] parent  Model index of the parent of the object.\n     *\n     *    @return QModelIndex that identifies the object.\n     */\n    virtual QModelIndex index(int row, int column, QModelIndex const& parent = QModelIndex()) const;\n\n    /*!\n     *  Get the model index of the parent of the object\n     *\n     *    @param [in] child   Model index that identifies the child of the object.\n     *\n     *    @return QModelIndex that identifies the parent of the given object.\n     */\n    virtual QModelIndex parent(QModelIndex const& child) const;\n        \n    /*!\n     *  Return header data for the given header column.\n     *\n     *    @param [in] section      The index of the header column.\n\t *    @param [in] orientation  The orientation of the header, only Qt::Horizontal supported.\n     *    @param [in] role         The role of the data.\n     *\n     *    @return QVariant containing the data.\n     */\n    virtual QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;\n\n    /*!\n     *  Get the data associated with given object.\n     *\n     *    @param [in] index Model index that identifies the object that's data is wanted.\n     *    @param [in] role Specifies the type of data wanted.\n     *\n     *    @return QVariant Containing the requested data.\n     */\n    virtual QVariant data(QModelIndex const& index, int role = Qt::DisplayRole) const;\n\n\t/*!\n     *  Set the data for specified item.\n\t *\n\t *    @param [in]  index  Specifies the item that's data is modified\n\t *    @param [in]  value  The value to be set.\n\t *    @param [in]  role   The role that is trying to modify the data. Only Qt::EditRole is supported.\n\t *\n\t *    @return  True, if data was successfully set, otherwise false.\n\t */\n    virtual bool setData(QModelIndex const& index, const QVariant &value, int role /* = Qt::EditRole */);\n\n    /*!\n     *  Get the flags that identify possible methods for given object.\n     *\n     *    @param [in] index   Model index identifying the object that's flags are requested.\n     *\n     *    @return Qt::ItemFlags that specify how the object can be handled.\n     */\n    Qt::ItemFlags flags(QModelIndex const& index) const;\n\n    /*!\n     *  Get the list of acceptable mime types.\n     *\n     *    @return The list of acceptable mime types.\n     */\n    QStringList mimeTypes() const;\n\n    /*!\n     *  Get the supported drop actions.\n     *\n     *    @return The supported drop actions.\n     */\n    virtual Qt::DropActions supportedDropActions() const;\n\n    /*!\n     *  Drop the mime data.\n     *\n     *    @param [in] data    The actual data.\n     *    @param [in] action  The used drop action.\n     *    @param [in] row     The selected row.\n     *    @param [in] column  The selected column.\n     *    @param [in] parent  Parent index of the new data.\n     */\n    virtual bool dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column,\n        QModelIndex const& parent);\n\nsignals:\n\n    //! Emitted when the contents have changed.\n    void contentChanged();\n\n    //! Emitted when a catalog should be opened.\n    void openCatalog(VLNV const& vlnv);\n\n    //! Emitted when a component should be opened.\n    void openComponent(VLNV const& vlnv);\n\n    //! Emitted when a bus should be opened.\n    void openBus(VLNV const& busVLNV);\n\n    //! Emitted when a bus should be opened.\n    void openAbsDef(VLNV const& absDefVLNV);\n\n    /*!\n     *  Emitted when an IP-XACT file using different std revision than the catalog is dropped in the editor.\n     */\n    void stdRevisionMismatch() const;\n\npublic slots:\n\n    //! Called when an item should be added in the given index.\n    void onAddItem(QModelIndex const& index);\n\n    //! Called when an item should be removed from the given index.\n    void onRemoveItem(QModelIndex const& index);\n\n    //! Called when an item should be opened in the given index.\n    void onOpenItem(QModelIndex const& index);\n\nprivate:\n\n    // Disable copying.\n    CatalogFileModel(CatalogFileModel const& rhs);\n    CatalogFileModel& operator=(CatalogFileModel const& rhs);\n\n    /*!\n     *  Adds the given file to correct category in the model.\n     *\n     *    @param [in] fileToAdd   The file to add.\n     */\n    void addFile(QSharedPointer<IpxactFile> fileToAdd);\n\n    /*!\n     *  Checks if the given VLNV is already contained in the catalog.\n     *\n     *    @param [in] vlnv   The VLNV to find.\n     *\n     *    @return True, if the VLNV is already in the catalog, otherwise false.\n     */\n    bool contains(VLNV const& vlnv) const;\n\n    /*!\n     *  Checks if the given path is valid.\n     *\n     *    @param [in] path   The path to check.\n     *\n     *    @return True, if the path is valid, otherwise false.\n     */\n    bool isValidPath(QString const& path) const;\n\n\n    //-----------------------------------------------------------------------------\n    // Data.\n    //----------------------------------------------------------------------------- \n\n    //! The catalog whose files to model.\n    QSharedPointer<Catalog> catalog_;\n\n    //! The instance that manages the library.\n    LibraryInterface* library_;\n\n    //! All the files in the model.\n    QVector<QSharedPointer<QList<QSharedPointer<IpxactFile> > > > topLevelRows_;\n\n    //! Lock for editing.\n    bool locked_;\n};\n\n//-----------------------------------------------------------------------------\n\n#endif // CATALOGFILEMODEL_H\n"
  },
  {
    "path": "editors/CatalogEditor/CatalogFileView.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: CatalogFileView.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Esko Pekkarinen\n// Date: 03.02.2017\n//\n// Description:\n// The widget to display the ipxact files of a catalog.\n//-----------------------------------------------------------------------------\n\n#include \"CatalogFileView.h\"\n\n#include \"CatalogFileColumns.h\"\n\n#include <common/KactusColors.h>\n\n#include <QApplication>\n#include <QClipboard>\n#include <QPainter>\n#include <QMenu>\n\n//-----------------------------------------------------------------------------\n// Function: CatalogFileView::CatalogFileView()\n//-----------------------------------------------------------------------------\nCatalogFileView::CatalogFileView(QWidget* parent): QTreeView(parent),\n    addAction_(new QAction(tr(\"Add row\"), this)),\n    removeAction_(new QAction(tr(\"Remove row\"), this)),\n    openAction_(new QAction(tr(\"Open\"), this)),\n    cutAction_(new QAction(tr(\"Cut\"), this)),\n    copyAction_(new QAction(tr(\"Copy\"), this)),\n    pasteAction_(new QAction(tr(\"Paste\"), this)),\n    clearAction_(new QAction(tr(\"Clear\"), this)),\n    expandAllIAction_(new QAction(tr(\"Expand all\"), this)),\n    collapseAllIAction_(new QAction(tr(\"Collapse all\"), this))\n{\n\tsetSelectionBehavior(QAbstractItemView::SelectItems);\n\tsetSelectionMode(QAbstractItemView::ContiguousSelection);\n\n    setDropIndicatorShown(true);   \n    viewport()->setAcceptDrops(true); \n    setDragDropMode(QAbstractItemView::DropOnly);\n\n    setEditTriggers(QAbstractItemView::DoubleClicked | QAbstractItemView::SelectedClicked |\n        QAbstractItemView::EditKeyPressed | QAbstractItemView::AnyKeyPressed);\n\n    setIndentation(10);\n\n\tsetupActions();\n}\n\n//-----------------------------------------------------------------------------\n// Function: CatalogFileView::~CatalogFileView()\n//-----------------------------------------------------------------------------\nCatalogFileView::~CatalogFileView()\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: CatalogFileView::drawRow()\n//-----------------------------------------------------------------------------\nvoid CatalogFileView::drawRow(QPainter* painter, QStyleOptionViewItem const& option,\n    QModelIndex const& index) const\n{\n    QTreeView::drawRow(painter, option, index);\n\n    painter->save();\n    painter->setPen(QPen(KactusColors::DISABLED_TEXT, 0));\n    painter->drawLine(option.rect.bottomLeft(), option.rect.bottomRight());\n    painter->restore();\n}\n\n//-----------------------------------------------------------------------------\n// Function: CatalogFileView::contextMenuEvent()\n//-----------------------------------------------------------------------------\nvoid CatalogFileView::contextMenuEvent(QContextMenuEvent* event)\n{\n    QModelIndex index = indexAt(event->pos());\n\n    QMenu menu(this);\n\n    if (index.isValid() && index.parent().isValid() && index.parent().row() <= CatalogFileColumns::COMPONENTS)\n    {\n        menu.addAction(openAction_);\n        openAction_->setEnabled(selectedIndexes().count() == 1);\n        menu.addSeparator();\n    }\n\n    menu.addAction(addAction_);\n\n    bool validIndex = index.isValid() && index.parent().isValid();\n\n    // if at least one valid item is selected.\n    if (validIndex)\n    {\n        menu.addAction(removeAction_);\n\n        menu.addSeparator();\n        menu.addAction(cutAction_);\n        menu.addAction(copyAction_);\n        menu.addAction(pasteAction_);\n        menu.addAction(clearAction_);\n    }\n\n    menu.addSeparator();\n    menu.addAction(expandAllIAction_);\n    menu.addAction(collapseAllIAction_);\n\n    menu.exec(event->globalPos());\n\n    event->accept();\n}\n\n//-----------------------------------------------------------------------------\n// Function: CatalogFileView::onAddAction()\n//-----------------------------------------------------------------------------\nvoid CatalogFileView::onAddAction()\n{\n    QModelIndexList indexes = selectedIndexes();\n    QModelIndex posToAdd;\n\n    if (!indexes.isEmpty())\n    {\n        posToAdd = indexes.first();\n    }\n\n    emit addItem(posToAdd);\n\n    clearSelection();\n}\n\n//-----------------------------------------------------------------------------\n// Function: CatalogFileView::onRemoveAction()\n//-----------------------------------------------------------------------------\nvoid CatalogFileView::onRemoveAction()\n{\n    QModelIndexList toRemove = sortAndMinimize(selectedIndexes());\n    if (toRemove.isEmpty())\n    {\n        return;\n    }\n\n    QApplication::setOverrideCursor(Qt::WaitCursor);\n\n    QModelIndex removeIndex = toRemove.first();\n\n    for (int i = 0; i < toRemove.count(); i++)\n    {\n        if (removeIndex.parent() != toRemove.at(i).parent())\n        {\n            removeIndex = toRemove.at(i);\n        }\n\n        emit removeItem(removeIndex);\n    }\n\n    clearSelection();\n    setCurrentIndex(QModelIndex());\n\n    QApplication::restoreOverrideCursor();\n}\n\n//-----------------------------------------------------------------------------\n// Function: CatalogFileView::onCopyAction()\n//-----------------------------------------------------------------------------\nvoid CatalogFileView::onCopyAction()\n{\n    // if nothing was selected then don't copy anything\n    if (!currentIndex().isValid())\n    {\n        return;\n    }\n\n    QApplication::setOverrideCursor(Qt::WaitCursor);\n\n    QModelIndexList indexes = selectedIndexes();\n    std::sort(indexes.begin(), indexes.end());\n\n    int lastColumn = indexes.last().column();\n\n    QString copyText;\n    foreach(QModelIndex sourceIndex, indexes)\n    {\n        copyText.append(sourceIndex.data(Qt::EditRole).toString());\n\n        if (sourceIndex.column() < lastColumn)\n        {\n            copyText.append(\"\\t\");\n        }\n        else\n        {\n            copyText.append(\"\\n\");\n        }\n    }\n\n    QApplication::clipboard()->setText(copyText);\n    QApplication::restoreOverrideCursor();\n}\n\n//-----------------------------------------------------------------------------\n// Function: CatalogFileView::onPasteAction()\n//-----------------------------------------------------------------------------\nvoid CatalogFileView::onPasteAction()\n{\n    QApplication::setOverrideCursor(Qt::WaitCursor);\n\n    // find the highest row to start adding to\n    QModelIndexList indexes = sortAndMinimize(selectedIndexes());\n\n    if (indexes.isEmpty())\n    {\n        QApplication::restoreOverrideCursor();\n        return;\n    }\n\n    QString subtype(\"plain\");\n    QString pasteText = QApplication::clipboard()->text(subtype);\n\n    // Split the string from clip board into rows.\n    QStringList rowsToAdd = pasteText.split(\"\\n\", Qt::SkipEmptyParts);\n\n    int current = 0;\n    QPersistentModelIndex currentIndex = indexes.first();\n    int startColumn = indexes.first().column();\n    \n    foreach (QString const& row, rowsToAdd)\n    {\n        int targetColumn = qMax(0, startColumn);\n\n        // Split the row into columns.\n        QStringList columnsToAdd = row.split(\"\\t\");\n        foreach (QString const& columnData, columnsToAdd)\n        {\n            QModelIndex itemToSet = currentIndex.sibling(currentIndex.row(), targetColumn);\n            if (itemToSet.isValid())\n            {\n                model()->setData(itemToSet, columnData, Qt::EditRole);\n            }\n\n            targetColumn++;\n        }\n\n        if (current < indexes.count() -1)\n        {           \n            current++;\n            currentIndex = indexes.at(current);\n        }\n        else\n        {\n            currentIndex = currentIndex.sibling(currentIndex.row() + 1, startColumn);\n        }\n    }\n\n    QApplication::restoreOverrideCursor();\n}\n\n//-----------------------------------------------------------------------------\n// Function: CatalogFileView::onCutAction()\n//-----------------------------------------------------------------------------\nvoid CatalogFileView::onCutAction()\n{\n    QModelIndexList indexes = selectedIndexes();\n    if (indexes.isEmpty())\n    {\n        return;\n    }\n\n    QApplication::setOverrideCursor(Qt::WaitCursor);\n\n    std::sort(indexes.begin(), indexes.end());\n    int lastColumn = indexes.last().column();\n\n    QString copyText;\n\n    foreach (QModelIndex index, indexes)\n    {\n        copyText.append(index.data(Qt::EditRole).toString());\n\n        model()->setData(index, QVariant(), Qt::EditRole);\n\n        if (index.column() < lastColumn)\n        {\n            copyText.append(\"\\t\");\n        }\n        else\n        {\n            copyText.append(\"\\n\");\n        }\n    }\n\n    QApplication::clipboard()->setText(copyText);\n    QApplication::restoreOverrideCursor();\n}\n\n//-----------------------------------------------------------------------------\n// Function: CatalogFileView::onClearAction()\n//-----------------------------------------------------------------------------\nvoid CatalogFileView::onClearAction()\n{\t\n    QModelIndexList indexes = selectedIndexes();\n\n    // clear the contents of each cell\n    foreach (QModelIndex const& index, indexes)\n    {\n        model()->setData(index, QVariant(), Qt::EditRole);\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: CatalogFileView::onOpenAction()\n//-----------------------------------------------------------------------------\nvoid CatalogFileView::onOpenAction()\n{\t\n    QModelIndexList indexes = selectedIndexes();\n\n    if (indexes.count() != 1) \n    {\n        return;\n    }\n\n    emit openItem(indexes.first());\n}\n\n//-----------------------------------------------------------------------------\n// Function: CatalogFileView::setupActions()\n//-----------------------------------------------------------------------------\nvoid CatalogFileView::setupActions()\n{\n    addAction(addAction_);\n    addAction_->setShortcut(QKeySequence::InsertLineSeparator);\n    addAction_->setShortcutContext(Qt::WidgetShortcut);\n\tconnect(addAction_, SIGNAL(triggered()), this, SLOT(onAddAction()), Qt::UniqueConnection);\n    \n    addAction(removeAction_);\n    removeAction_->setShortcut(Qt::SHIFT | Qt::Key_Delete);\n    removeAction_->setShortcutContext(Qt::WidgetShortcut);\n    connect(removeAction_, SIGNAL(triggered()), this, SLOT(onRemoveAction()), Qt::UniqueConnection);\n    \n    addAction(openAction_);\n    connect(openAction_, SIGNAL(triggered()), this, SLOT(onOpenAction()), Qt::UniqueConnection);\n\n    addAction(copyAction_);\n    copyAction_->setShortcut(QKeySequence::Copy);\n    copyAction_->setShortcutContext(Qt::WidgetShortcut);\n    connect(copyAction_, SIGNAL(triggered()), this, SLOT(onCopyAction()), Qt::UniqueConnection);\n\n    addAction(pasteAction_);\n    pasteAction_->setShortcut(QKeySequence::Paste);\n    pasteAction_->setShortcutContext(Qt::WidgetShortcut);\n    connect(pasteAction_, SIGNAL(triggered()), this, SLOT(onPasteAction()), Qt::UniqueConnection);\n\n    addAction(cutAction_);\n    cutAction_->setShortcut(QKeySequence::Cut);\n    cutAction_->setShortcutContext(Qt::WidgetShortcut);\n    connect(cutAction_, SIGNAL(triggered()), this, SLOT(onCutAction()), Qt::UniqueConnection);\n\n    addAction(clearAction_);\n    clearAction_->setShortcut(QKeySequence::Delete);\n    clearAction_->setShortcutContext(Qt::WidgetShortcut);\n    connect(clearAction_, SIGNAL(triggered()), this, SLOT(onClearAction()), Qt::UniqueConnection);\n\n    addAction(expandAllIAction_);\n    connect(expandAllIAction_, SIGNAL(triggered()), this, SLOT(expandAll()), Qt::UniqueConnection);\n\n    addAction(collapseAllIAction_);\n    connect(collapseAllIAction_, SIGNAL(triggered()), this, SLOT(collapseAll()), Qt::UniqueConnection);\n}\n\n//-----------------------------------------------------------------------------\n// Function: CatalogFileView::sortAndMinimize()\n//-----------------------------------------------------------------------------\nQModelIndexList CatalogFileView::sortAndMinimize(QModelIndexList const& indexes)\n{\n    QModelIndexList sorted = indexes;\n    std::sort(sorted.begin(), sorted.end());\n\n    QModelIndex previousRow = QModelIndex();\n\n    foreach (QModelIndex index, sorted)\n    {\n        if (!index.parent().isValid() || \n            (index.row() == previousRow.row() && index.parent() == previousRow.parent()))\n        {\n            sorted.removeAll(index);            \n        }\n        else\n        {\n            previousRow = index;\n        }\n    }\n\n    return sorted;\n}\n"
  },
  {
    "path": "editors/CatalogEditor/CatalogFileView.h",
    "content": "//-----------------------------------------------------------------------------\n// File: CatalogFileView.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Esko Pekkarinen\n// Date: 03.02.2017\n//\n// Description:\n// The widget to display the ipxact files of a catalog.\n//-----------------------------------------------------------------------------\n\n#ifndef CATALOGFILEVIEW_H\n#define CATALOGFILEVIEW_H\n\n\n#include <QTreeView>\n#include <QContextMenuEvent>\n#include <QAction>\n#include <QPoint>\n#include <QModelIndex>\n#include <QMouseEvent>\n\nclass LibraryInterface;\n\n//-----------------------------------------------------------------------------\n//! The widget to display the library in a tree.\n//-----------------------------------------------------------------------------\nclass CatalogFileView : public QTreeView\n{\n\tQ_OBJECT\n\npublic:\n\n\t/*! The constructor\n\t* \n\t*    @param [in] handler  The instance that manages the library.\n\t*    @param [in] filter   The class that does the filtering for the view.\n\t*    @param [in] parent   The owner of this widget.\n\t*\n\t*/\n\tCatalogFileView(QWidget* parent = 0);\n\n\t//! The destructor.\n\tvirtual ~CatalogFileView();\n\nsignals:\n\n    //! Emitted when an item should be added in the given index.\n    void addItem(QModelIndex const& index);\n\n    //! Emitted when an item should be removed from the given index.\n    void removeItem(QModelIndex const& index);\n\n    //! Emitted when an item should be opened in the given index.\n    void openItem(QModelIndex const& index);\n\nprotected:\n   \n    /*!\n     *  Draws a row and a separator line under it.\n     *\n     *    @param [in] painter   The painter used for the drawing.\n     *    @param [in] option    Options for the drawing.\n     *    @param [in] index     Index of the item to draw.\n     */\n    virtual void drawRow(QPainter* painter, QStyleOptionViewItem const& option, QModelIndex const& index) const;\n\n    /*! Handler for the context menu events.\n    *\n    *    @param [in] event The contextMenuEvent to be handled.\n    */\n    virtual void contextMenuEvent(QContextMenuEvent* event);\n\nprivate slots:\n\n    //! Handler for add row action.\n    void onAddAction();\n\n    //! Handler for remove row action.\n    void onRemoveAction();\n\n    //! Handler for copy action.\n    void onCopyAction();\n\n    //! Handler for paste action.\n    void onPasteAction();\n\n    //! Handler for cut action.\n    void onCutAction();\n\n    //! Handler for clear action.\n    void onClearAction();\n\n    //! Handler for open action.\n    void onOpenAction();\n\nprivate:\n\n    //! No assignment\n\tCatalogFileView(const CatalogFileView& other);\n\n\t//! No copying\n\tCatalogFileView& operator=(const CatalogFileView& other);\n\n\t//! Set up the actions for the context menu\n\tvoid setupActions();\n\n    /*!\n     *  Sorts the given indexes and removes all but one index for each row.\n     *\n     *    @param [in] indexes   the index to sort and minimize.\n     *\n     *    @return Indexes in sorted order with only one index per row.\n     */\n    QModelIndexList sortAndMinimize(QModelIndexList const& indexes);\n\n    //-----------------------------------------------------------------------------\n    // Data.\n    //-----------------------------------------------------------------------------\n\n    //! Action to add new item.\n    QAction* addAction_;\n\n    //! Action to remove item.\n    QAction* removeAction_;\n\n    //! Action to open an item.\n    QAction* openAction_;\n\n    //! Action to cut item.\n    QAction* cutAction_;\n\n    //! Action to copy item.\n    QAction* copyAction_;\n\n    //! Action to paste item.\n    QAction* pasteAction_;\n\n    //! Action to clear selected cells.\n    QAction* clearAction_;\n\n    //! Action to expand all branches.\n    QAction* expandAllIAction_;\n\n    //! Action to collapse all branches.\n    QAction* collapseAllIAction_;\n};\n\n#endif // CATALOGFILEVIEW_H\n"
  },
  {
    "path": "editors/ComDefinitionEditor/ComDefinitionEditor.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ComDefinitionEditor.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Joni-Matti Maatta\r\n// Date: 17.4.2012\r\n//\r\n// Description:\r\n// Editor for editing COM definitions.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"ComDefinitionEditor.h\"\r\n\r\n#include <common/dialogs/newObjectDialog/newobjectdialog.h>\r\n\r\n#include <IPXACTmodels/kactusExtensions/ComProperty.h>\r\n#include <IPXACTmodels/kactusExtensions/validators/ComDefinitionValidator.h>\r\n\r\n#include <QGridLayout>\r\n#include <QMessageBox>\r\n#include <QCoreApplication>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComDefinitionEditor()\r\n//-----------------------------------------------------------------------------\r\nComDefinitionEditor::ComDefinitionEditor(QWidget *parent, LibraryInterface* libHandler,\r\n    QSharedPointer<ComDefinition> comDef):\r\nTabDocument(parent, libHandler, DOC_PROTECTION_SUPPORT),\r\n    comDef_(comDef),\r\n    nameGroup_(this),\r\n    dataTypeList_(tr(\"Transfer types\"), this),\r\n    propertyEditor_(this)\r\n{\r\n    // Initialize the editors.\r\n    nameGroup_.setDocumentNameGroup(comDef_, getLibHandler()->getPath(comDef_->getVlnv()));\r\n    nameGroup_.setTitle(tr(\"COM definition\"));\r\n    dataTypeList_.initialize(*comDef_->getTransferTypes());\r\n    propertyEditor_.setProperties(comDef_->getProperties());\r\n\r\n    nameGroup_.setFlat(true);\r\n    propertyEditor_.setFlat(true);\r\n\r\n    connect(&nameGroup_, SIGNAL(contentChanged()), this, SIGNAL(contentChanged()), Qt::UniqueConnection);\r\n    connect(&dataTypeList_, SIGNAL(contentChanged()), this, SIGNAL(contentChanged()), Qt::UniqueConnection);\r\n    connect(&propertyEditor_, SIGNAL(contentChanged()), this, SIGNAL(contentChanged()), Qt::UniqueConnection);\r\n    \r\n    // Setup the layout.\r\n    auto layout = new QGridLayout(this);\r\n    layout->addWidget(&nameGroup_, 0, 0, 1, 1);\r\n    layout->addWidget(&dataTypeList_, 0, 1, 1, 1);\r\n    layout->addWidget(&propertyEditor_, 1, 0, 1, 2);\r\n    \r\n    setModified(false);\r\n\r\n    // Set the document name and type.\r\n    VLNV const vlnv = comDef_->getVlnv();\r\n    setDocumentName(vlnv.getName() + \" (\" + vlnv.getVersion() + \")\");\r\n    setDocumentType(DocumentType::COM_DEFINITION);\r\n\r\n    // Open in unlocked mode by default only if the version is draft.\r\n    setProtection(vlnv.getVersion() != \"draft\");\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComDefinitionEditor::getIdentifyingVLNV()\r\n//-----------------------------------------------------------------------------\r\nVLNV ComDefinitionEditor::getIdentifyingVLNV() const\r\n{\r\n    return getDocumentVLNV();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: setProtection()\r\n//-----------------------------------------------------------------------------\r\nvoid ComDefinitionEditor::setProtection(bool locked)\r\n{\r\n    TabDocument::setProtection(locked);\r\n    setEnabled(!locked);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComDefinitionEditor::refresh()\r\n//-----------------------------------------------------------------------------\r\nvoid ComDefinitionEditor::refresh()\r\n{\r\n    QSharedPointer<Document> libComp = getLibHandler()->getModel(comDef_->getVlnv());\r\n    comDef_ = libComp.staticCast<ComDefinition>();\r\n\r\n    // Initialize the editors.\r\n    nameGroup_.setDocumentNameGroup(comDef_, getLibHandler()->getPath(comDef_->getVlnv()));\r\n    dataTypeList_.initialize(*comDef_->getTransferTypes());\r\n    propertyEditor_.setProperties(comDef_->getProperties());\r\n\r\n    setModified(false);\r\n    TabDocument::refresh();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: getDocumentVLNV()\r\n//-----------------------------------------------------------------------------\r\nVLNV ComDefinitionEditor::getDocumentVLNV() const\r\n{\r\n    return comDef_->getVlnv();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComDefinitionEditor::validate()\r\n//-----------------------------------------------------------------------------\r\nbool ComDefinitionEditor::validate(QVector<QString>& errorList)\r\n{\r\n    applyChanges();\r\n\r\n\tComDefinitionValidator validator;\r\n\tvalidator.findErrorsIn(errorList, comDef_);\r\n\r\n    return errorList.isEmpty();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: save()\r\n//-----------------------------------------------------------------------------\r\nbool ComDefinitionEditor::save()\r\n{\r\n    applyChanges();\r\n    getLibHandler()->writeModelToFile(comDef_);\r\n\r\n    return TabDocument::save();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: saveAs()\r\n//-----------------------------------------------------------------------------\r\nbool ComDefinitionEditor::saveAs()\r\n{\r\n    // Ask the user for a new VLNV and directory.\r\n    VLNV vlnv;\r\n    QString directory;\r\n\r\n    if (!NewObjectDialog::saveAsDialog(parentWidget(), getLibHandler(), comDef_->getVlnv(), vlnv, directory))\r\n    {\r\n        return false;\r\n    }\r\n\r\n    // Create a copy of the object and update its VLNV.\r\n    comDef_ = QSharedPointer<ComDefinition>(new ComDefinition(*comDef_));\r\n\r\n    vlnv.setType(VLNV::COMDEFINITION);\r\n    comDef_->setVlnv(vlnv);\r\n\r\n    // Apply changes to the copy.\r\n    applyChanges();\r\n\r\n    if (getLibHandler()->writeModelToFile(directory, comDef_))\r\n    {\r\n        setDocumentName(vlnv.getName() + \" (\" + vlnv.getVersion() + \")\");\r\n        return TabDocument::saveAs();\r\n    }\r\n    else\r\n    {\r\n        return false;\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComDefinitionEditor::applyChanges()\r\n//-----------------------------------------------------------------------------\r\nvoid ComDefinitionEditor::applyChanges()\r\n{\r\n    QList< QSharedPointer<ComProperty> > properties;\r\n\r\n    for (QSharedPointer<ComProperty> prop : propertyEditor_.getProperties())\r\n    {\r\n        properties.append(QSharedPointer<ComProperty>(new ComProperty(*prop)));\r\n    }\r\n\r\n    comDef_->setProperties(properties);\r\n    comDef_->setTransferTypes(dataTypeList_.items());\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComDefinitionEditor::showEvent()\r\n//-----------------------------------------------------------------------------\r\nvoid ComDefinitionEditor::showEvent(QShowEvent* event)\r\n{\r\n    TabDocument::showEvent(event);\r\n    emit helpUrlRequested(\"definitions/comdefinition.html\");\r\n}\r\n\r\n"
  },
  {
    "path": "editors/ComDefinitionEditor/ComDefinitionEditor.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ComDefinitionEditor.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Joni-Matti Maatta\r\n// Date: 17.4.2012\r\n//\r\n// Description:\r\n// Editor for editing COM definitions.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef COMDEFINITIONEDITOR_H\r\n#define COMDEFINITIONEDITOR_H\r\n\r\n#include \"ComPropertyEditor.h\"\r\n\r\n#include <common/widgets/tabDocument/TabDocument.h>\r\n#include <common/widgets/vlnvEditor/vlnveditor.h>\r\n#include <common/widgets/listManager/listmanager.h>\r\n\r\n#include <editors/common/DocumentNameGroupEditor.h>\r\n\r\n#include <IPXACTmodels/kactusExtensions/ComDefinition.h>\r\n\r\n#include <KactusAPI/include/LibraryInterface.h>\r\n\r\n#include <QSharedPointer>\r\n#include <QPushButton>\r\n#include <QListWidget>\r\n#include <QGroupBox>\r\n#include <QString>\r\n#include <QMap>\r\n#include <QList>\r\n#include <QSharedPointer>\r\n#include <QSortFilterProxyModel>\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Editor for editing COM definitions.\r\n//-----------------------------------------------------------------------------\r\nclass ComDefinitionEditor : public TabDocument\r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\t/*!\r\n     *  Constructor.\r\n\t *\r\n\t *    @param [in] parent      The parent widget.\r\n     *    @param [in] libHandler  The library interface.\r\n     *    @param [in] comDef      The COM definition.\r\n\t */\r\n\tComDefinitionEditor(QWidget* parent, LibraryInterface* libHandler, QSharedPointer<ComDefinition> comDef);\r\n\t\r\n\t/*!\r\n     *  Destructor.\r\n     */\r\n\tvirtual ~ComDefinitionEditor() = default;\r\n\r\n    // Disable copying.\r\n    ComDefinitionEditor(ComDefinitionEditor const& rhs) = delete;\r\n    ComDefinitionEditor& operator=(ComDefinitionEditor const& rhs) = delete;\r\n\r\n\t/*! Get the VLNV that can be used to identify the COM definition.\r\n\t *\r\n\t *    @return The VLNV of the COM definition\r\n\t*/\r\n\tvirtual VLNV getIdentifyingVLNV() const;\r\n\r\n    /*!\r\n     *  Sets the protection state of the document.\r\n     *\r\n     *    @param [in] locked True for locked state; false for unlocked.\r\n     */\r\n    virtual void setProtection(bool locked);\r\n\r\n    /*!\r\n     *  Refreshes the editor.\r\n     */\r\n    virtual void refresh();\r\n\r\n\t/*!\r\n     *  Returns the VLNV of the SW design component.\r\n     */\r\n\tvirtual VLNV getDocumentVLNV() const;\r\n\r\npublic slots:\r\n    /*!\r\n     *  Validates the document against the IP-XACT standard.\r\n     *\r\n     *    @param [out] errorList Error message list for reporting standard violations.\r\n     *\r\n     *    @return True if the document is valid. False if there were any violations.\r\n     */\r\n    virtual bool validate(QVector<QString>& errorList);\r\n\r\n\t//! Saves the document and resets the modified state.\r\n\tvirtual bool save();\r\n\r\n\t//! Saves the document as new object and resets modifies state\r\n\tvirtual bool saveAs();\r\n\r\nprotected:\r\n    //! Called when the editor is shown.\r\n    virtual void showEvent(QShowEvent* event);\r\n\r\nprivate:\r\n\r\n    /*!\r\n     *  Applies the changes made in the editor to the document.\r\n     */\r\n    void applyChanges();\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n\t//! The COM definition being edited.\r\n\tQSharedPointer<ComDefinition> comDef_;\r\n\r\n    DocumentNameGroupEditor nameGroup_;\r\n\r\n    //! The data type list manager.\r\n    ListManager dataTypeList_;\r\n\r\n    //! The properties editor.\r\n    ComPropertyEditor propertyEditor_;\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n\r\n#endif // COMDEFINITIONEDITOR_H\r\n"
  },
  {
    "path": "editors/ComDefinitionEditor/ComPropertyColumns.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ComPropertyColumns.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Esko Pekkarinen\r\n// Date: 16.10.2015\r\n//\r\n// Description:\r\n// Common declarations for editing Com Definitions.\r\n//-----------------------------------------------------------------------------\r\n\r\nnamespace ComPropertyColumns\r\n{\r\n    //-----------------------------------------------------------------------------\r\n    // Constants defining which column represents what kind of information.\r\n    //-----------------------------------------------------------------------------\r\n    enum PropertyColumn\r\n    {\r\n        NAME = 0,           //!< Column for the property name.\r\n        REQUIRED,           //!< Column for the required/optional check box.\r\n        TYPE,               //!< Column for setting the value type for the property.\r\n        DEFAULT_VALUE,      //!< Column for setting the default value for the property.\r\n        DESCRIPTION,        //!< Column for adding a description for the property.\r\n        COLUMN_COUNT\r\n    };\r\n}\r\n"
  },
  {
    "path": "editors/ComDefinitionEditor/ComPropertyDelegate.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ComPropertyDelegate.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Joni-Matti Maatta\r\n// Date: 17.4.2012\r\n//\r\n// Description:\r\n// Delegate for editing COM properties.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"ComPropertyDelegate.h\"\r\n\r\n#include \"ComPropertyColumns.h\"\r\n\r\n#include <QComboBox>\r\n#include <QLineEdit>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComPropertyDelegate::ComPropertyDelegate()\r\n//-----------------------------------------------------------------------------\r\nComPropertyDelegate::ComPropertyDelegate(QObject* parent): QStyledItemDelegate(parent)\r\n{\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComPropertyDelegate::~ComPropertyDelegate()\r\n//-----------------------------------------------------------------------------\r\nComPropertyDelegate::~ComPropertyDelegate()\r\n{\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComPropertyDelegate::createEditor()\r\n//-----------------------------------------------------------------------------\r\nQWidget* ComPropertyDelegate::createEditor(QWidget* parent, QStyleOptionViewItem const& option,\r\n    QModelIndex const& index) const\r\n{\r\n    if (index.column() == ComPropertyColumns::NAME || \r\n        index.column() == ComPropertyColumns::DEFAULT_VALUE ||\r\n        index.column() == ComPropertyColumns::DESCRIPTION)\r\n    {\r\n        QLineEdit* line = new QLineEdit(parent);\r\n        connect(line, SIGNAL(editingFinished()), this, SLOT(commitAndCloseEditor()), Qt::UniqueConnection);\r\n        return line;\r\n    }\r\n\r\n    else if (index.column() == ComPropertyColumns::TYPE)\r\n    {\r\n        QComboBox* box = new QComboBox(parent);\r\n        box->setEditable(true);\r\n        box->setInsertPolicy(QComboBox::InsertAlphabetically);\r\n\r\n        box->addItem(\"integer\");\r\n        box->addItem(\"ip_address\");\r\n        box->addItem(\"string\");\r\n        return box;\r\n    }\r\n\r\n    else if (index.column() == ComPropertyColumns::REQUIRED)\r\n    {\r\n        QComboBox* box = new QComboBox(parent);\r\n        box->addItem(\"false\");\r\n        box->addItem(\"true\");\r\n        return box;\r\n    }\r\n\r\n    else\r\n    {\r\n        return QStyledItemDelegate::createEditor(parent, option, index);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComPropertyDelegate::setEditorData()\r\n//-----------------------------------------------------------------------------\r\nvoid ComPropertyDelegate::setEditorData(QWidget* editor, QModelIndex const& index) const\r\n{\r\n    if (index.column() == ComPropertyColumns::TYPE || \r\n        index.column() == ComPropertyColumns::REQUIRED)\r\n    {\r\n        QComboBox* box = qobject_cast<QComboBox*>(editor);\r\n        Q_ASSERT_X(box, \"ComPropertyDelegate::setEditorData\", \"Type conversion failed for QComboBox\");\r\n\r\n        QString text = index.data(Qt::DisplayRole).toString();\r\n        box->setCurrentIndex(box->findText(text));\r\n    }\r\n\r\n    else if (index.column() == ComPropertyColumns::NAME || \r\n        index.column() == ComPropertyColumns::DEFAULT_VALUE ||\r\n        index.column() == ComPropertyColumns::DESCRIPTION)\r\n    {\r\n        QLineEdit* line = qobject_cast<QLineEdit*>(editor);\r\n        Q_ASSERT_X(line, \"ComPropertyDelegate::setEditorData\", \"Type conversion failed for QLineEdit\");\r\n\r\n        QString text = index.data(Qt::DisplayRole).toString();\r\n        line->setText(text);\r\n    }\r\n\r\n    else\r\n    {\r\n        QStyledItemDelegate::setEditorData(editor, index);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComPropertyDelegate::setModelData()\r\n//-----------------------------------------------------------------------------\r\nvoid ComPropertyDelegate::setModelData(QWidget* editor, QAbstractItemModel* model, QModelIndex const& index) const\r\n{\r\n    if (index.column() == ComPropertyColumns::TYPE ||\r\n        index.column() == ComPropertyColumns::REQUIRED)\r\n    {\r\n        QComboBox* box = qobject_cast<QComboBox*>(editor);\r\n        Q_ASSERT_X(box, \"ComPropertyDelegate::setEditorData\", \"Type conversion failed for QComboBox\");\r\n\r\n        QString text = box->currentText();\r\n        model->setData(index, text, Qt::EditRole);\r\n    }\r\n\r\n    else if (index.column() == ComPropertyColumns::NAME || \r\n        index.column() == ComPropertyColumns::DEFAULT_VALUE ||\r\n        index.column() == ComPropertyColumns::DESCRIPTION)\r\n    {\r\n        QLineEdit* line = qobject_cast<QLineEdit*>(editor);\r\n        Q_ASSERT_X(line, \"ComPropertyDelegate::setEditorData\", \"Type conversion failed for QLineEdit\");\r\n\r\n        QString text = line->text();\r\n        model->setData(index, text, Qt::EditRole);\r\n    }\r\n    else\r\n    {\r\n        QStyledItemDelegate::setModelData(editor, model, index);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComPropertyDelegate::commitAndCloseEditor()\r\n//-----------------------------------------------------------------------------\r\nvoid ComPropertyDelegate::commitAndCloseEditor()\r\n{\r\n    QLineEdit* lineEdit = qobject_cast<QLineEdit*>(sender());\r\n\r\n    if (lineEdit != 0)\r\n    {\r\n        emit commitData(lineEdit);\r\n        emit closeEditor(lineEdit);\r\n    }\r\n}\r\n"
  },
  {
    "path": "editors/ComDefinitionEditor/ComPropertyDelegate.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ComPropertyDelegate.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Joni-Matti Maatta\r\n// Date: 17.4.2012\r\n//\r\n// Description:\r\n// Delegate for editing COM properties.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef COMPROPERTYDELEGATE_H\r\n#define COMPROPERTYDELEGATE_H\r\n\r\n#include <QStyledItemDelegate>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Delegate for editing COM properties.\r\n//-----------------------------------------------------------------------------\r\nclass ComPropertyDelegate : public QStyledItemDelegate\r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\t/*!\r\n     *  Constructor.\r\n     *\r\n     *    @param [in] parent The parent object.\r\n     */\r\n\tComPropertyDelegate(QObject* parent = 0);\r\n\r\n\t/*!\r\n     *  Destructor.\r\n     */\r\n\tvirtual ~ComPropertyDelegate();\r\n\r\n\t/*!\r\n     *  Creates a new editor for the given item.\r\n\t *\r\n\t *    @param [in] parent  The parent widget.\r\n     *    @param [in] option  Contains options for the editor.\r\n     *    @param [in] index   Model index identifying the item.\r\n\t *\r\n\t *    @return The editor to be used to edit the item.\r\n\t */\r\n\tvirtual QWidget* createEditor(QWidget* parent, QStyleOptionViewItem const& option, \r\n\t\t                          QModelIndex const& index) const;\r\n\r\n\t/*!\r\n     *  Sets the data for the editor.\r\n\t *\r\n\t *    @param [in] editor  The editor where the data is to be set.\r\n\t *    @param [in] index   Model index identifying the item that's data is to be set.\r\n\t */\r\n\tvirtual void setEditorData(QWidget* editor, QModelIndex const& index) const;\r\n\r\n\t/*!\r\n     *  Saves the data from the editor to the model.\r\n\t *\r\n\t *    @param [in] editor  The editor that contains the data to store.\r\n\t *    @param [in] model   Model that contains the data structure where data is to be saved to.\r\n\t *    @param [in] index   Model index identifying the item that's data is to be saved.\r\n\t */\r\n\tvirtual void setModelData(QWidget* editor, QAbstractItemModel* model, \r\n\t\t                      QModelIndex const& index) const;\r\n\r\nprivate slots:\r\n\t/*! \r\n     *  Commits the data from the sending editor and close the editor.\r\n\t */\r\n\tvoid commitAndCloseEditor();\r\n\r\nprivate:\r\n    // Disable copying.\r\n    ComPropertyDelegate(ComPropertyDelegate const& rhs);\r\n    ComPropertyDelegate& operator=(ComPropertyDelegate const& rhs);\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n\r\n#endif // COMPROPERTYDELEGATE_H\r\n"
  },
  {
    "path": "editors/ComDefinitionEditor/ComPropertyEditor.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ComPropertyEditor.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Joni-Matti Maatta\r\n// Date: 17.4.2012\r\n//\r\n// Description:\r\n// Editor for COM properties.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"ComPropertyEditor.h\"\r\n\r\n#include \"ComPropertyDelegate.h\"\r\n\r\n#include <QHBoxLayout>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComPropertyEditor::ComPropertyEditor()\r\n//-----------------------------------------------------------------------------\r\nComPropertyEditor::ComPropertyEditor(QWidget* parent)\r\n    : QGroupBox(tr(\"Properties\"), parent),\r\n      view_(this),\r\n      filter_(this),\r\n      model_(this)\r\n{\r\n    // Set the model source and other options for the view.\r\n    filter_.setSourceModel(&model_);\r\n\r\n    view_.setModel(&filter_);\r\n    view_.setSortingEnabled(true);\r\n    view_.setItemsDraggable(false);\r\n    view_.setItemDelegate(new ComPropertyDelegate(this));\r\n\r\n    QHBoxLayout* layout = new QHBoxLayout(this);\r\n    layout->addWidget(&view_);\r\n\r\n    connect(&model_, SIGNAL(contentChanged()),\r\n        this, SIGNAL(contentChanged()), Qt::UniqueConnection);\r\n    connect(&view_, SIGNAL(addItem(const QModelIndex&)),\r\n        &model_, SLOT(onAddItem(const QModelIndex&)), Qt::UniqueConnection);\r\n    connect(&view_, SIGNAL(removeItem(const QModelIndex&)),\r\n            &model_, SLOT(onRemoveItem(const QModelIndex&)), Qt::UniqueConnection);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComPropertyEditor::~ComPropertyEditor()\r\n//-----------------------------------------------------------------------------\r\nComPropertyEditor::~ComPropertyEditor()\r\n{\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComPropertyEditor::setData()\r\n//-----------------------------------------------------------------------------\r\nvoid ComPropertyEditor::setProperties(QList< QSharedPointer<ComProperty> > const& properties)\r\n{\r\n    model_.setProperties(properties);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComPropertyEditor::getData()\r\n//-----------------------------------------------------------------------------\r\nQList< QSharedPointer<ComProperty> > ComPropertyEditor::getProperties() const\r\n{\r\n    return model_.getProperties();\r\n}\r\n"
  },
  {
    "path": "editors/ComDefinitionEditor/ComPropertyEditor.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ComPropertyEditor.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Joni-Matti Maatta\r\n// Date: 17.4.2012\r\n//\r\n// Description:\r\n// Editor for COM properties.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef COMPROPERTYEDITOR_H\r\n#define COMPROPERTYEDITOR_H\r\n\r\n#include \"ComPropertyModel.h\"\r\n\r\n#include <common/views/EditableTableView/editabletableview.h>\r\n\r\n#include <QGroupBox>\r\n#include <QSortFilterProxyModel>\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Property value editor.\r\n//-----------------------------------------------------------------------------\r\nclass ComPropertyEditor : public QGroupBox\r\n{\r\n    Q_OBJECT\r\n\r\npublic:\r\n    /*!\r\n     *  Constructor.\r\n     *\r\n     *    @param [in] parent The parent widget.\r\n     */\r\n    ComPropertyEditor(QWidget* parent);\r\n\r\n    /*!\r\n     *  Destructor.\r\n     */\r\n    ~ComPropertyEditor();\r\n\r\n    /*!\r\n     *  Sets the properties for editing.\r\n     *\r\n     *    @param [in] properties The properties.\r\n     */\r\n    void setProperties(QList< QSharedPointer<ComProperty> > const& properties);\r\n\r\n    /*!\r\n     *  Returns the edited properties.\r\n     */\r\n    QList< QSharedPointer<ComProperty> > getProperties() const;\r\n\r\nsignals:\r\n    //! Emitted when contents of the editor changes.\r\n    void contentChanged();\r\n\r\nprivate:\r\n    // Disable copying.\r\n    ComPropertyEditor(ComPropertyEditor const& rhs);\r\n    ComPropertyEditor& operator=(ComPropertyEditor const& rhs);\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! The table view widget.\r\n    EditableTableView view_;\r\n\r\n    //! \\brief The filter to do the sorting of items to display.\r\n    QSortFilterProxyModel filter_;\r\n\r\n    //! \\brief The model to edit the properties.\r\n    ComPropertyModel model_;\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n\r\n#endif // COMPROPERTYEDITOR_H\r\n"
  },
  {
    "path": "editors/ComDefinitionEditor/ComPropertyModel.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ComPropertyModel.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Joni-Matti Maatta\r\n// Date: 17.4.2012\r\n//\r\n// Description:\r\n// Model for COM properties.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"ComPropertyModel.h\"\r\n\r\n#include \"ComPropertyColumns.h\"\r\n\r\n#include <IPXACTmodels/kactusExtensions/ComProperty.h>\r\n\r\n\r\n#include <QRegularExpression>\r\n\r\n#include <common/KactusColors.h>\r\n\r\nQString const ComPropertyModel::IP_ADDRESS_REGEX(\"^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\\\.\"\r\n    \"(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\\\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\\\.\"\r\n    \"(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$\");\r\nQString const ComPropertyModel::TIME_UNIT_REGEX(\"^(fs|ps|ns|us|µs|ms|sec|s)$\");\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComPropertyModel::ComPropertyModel()\r\n//-----------------------------------------------------------------------------\r\nComPropertyModel::ComPropertyModel(QObject *parent)\r\n    : QAbstractTableModel(parent),\r\n      table_()\r\n{\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComPropertyModel::~ComPropertyModel()\r\n//-----------------------------------------------------------------------------\r\nComPropertyModel::~ComPropertyModel()\r\n{\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComPropertyModel::setProperties()\r\n//-----------------------------------------------------------------------------\r\nvoid ComPropertyModel::setProperties( QList< QSharedPointer<ComProperty> >  properties)\r\n{\r\n    beginResetModel();\r\n\r\n    table_.clear();\r\n\r\n    for (QSharedPointer<ComProperty> comProperty : properties)\r\n    {\r\n        table_.append(QSharedPointer<ComProperty>(new ComProperty(*comProperty)));\r\n    }\r\n\r\n    endResetModel();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComPropertyModel::getProperties()\r\n//-----------------------------------------------------------------------------\r\nQList< QSharedPointer<ComProperty> > ComPropertyModel::getProperties() const\r\n{\r\n    return table_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComPropertyModel::rowCount()\r\n//-----------------------------------------------------------------------------\r\nint ComPropertyModel::rowCount(QModelIndex const& parent) const\r\n{\r\n    if (parent.isValid())\r\n    {\r\n        return 0;\r\n    }\r\n\r\n    return table_.size();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComPropertyModel::columnCount()\r\n//-----------------------------------------------------------------------------\r\nint ComPropertyModel::columnCount(QModelIndex const& parent) const\r\n{\r\n    if (parent.isValid())\r\n    {\r\n        return 0;\r\n    }\r\n\r\n    return ComPropertyColumns::COLUMN_COUNT;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComPropertyModel::data()\r\n//-----------------------------------------------------------------------------\r\nQVariant ComPropertyModel::data(QModelIndex const& index, int role) const\r\n{\r\n    if (!index.isValid() || index.row() < 0 || index.row() >= table_.size())\r\n    {\r\n        return QVariant();\r\n    }\r\n\r\n    if (role == Qt::DisplayRole)\r\n    {\r\n        if (index.column() == ComPropertyColumns::NAME)\r\n        {\r\n            return table_.at(index.row())->name();\r\n        }\r\n        else if (index.column() == ComPropertyColumns::REQUIRED)\r\n        {\r\n            return table_.at(index.row())->isRequired();\r\n        }\r\n        else if (index.column() == ComPropertyColumns::TYPE)\r\n        {\r\n            return table_.at(index.row())->getType();\r\n        }\r\n        else if (index.column() == ComPropertyColumns::DEFAULT_VALUE)\r\n        {\r\n            return table_.at(index.row())->getDefaultValue();\r\n        }\r\n        else if (index.column() == ComPropertyColumns::DESCRIPTION)\r\n        {\r\n            return table_.at(index.row())->getDescription();\r\n        }\r\n        else\r\n        {\r\n            return QVariant();\r\n        }\r\n    }\r\n    else if (role == Qt::ForegroundRole)\r\n    {\r\n        if (index.column() == ComPropertyColumns::DEFAULT_VALUE)\r\n        {\r\n            // Validate the default value against the data type.\r\n            QString const& value = table_.at(index.row())->getDefaultValue();\r\n            QString const& type = table_.at(index.row())->getType();\r\n            bool ok = true;\r\n\r\n            if (type == QLatin1String(\"integer\"))\r\n            {\r\n                value.toInt(&ok);\r\n            }\r\n            else if (type == QLatin1String(\"ip_address\"))\r\n            {\r\n                ok = value.contains(QRegularExpression(IP_ADDRESS_REGEX));\r\n            }\r\n\r\n            if (ok)\r\n            {\r\n                return KactusColors::REGULAR_TEXT;\r\n            }\r\n            else\r\n            {\r\n                return KactusColors::ERROR;\r\n            }\r\n        }\r\n\r\n        else\r\n        {\r\n            return KactusColors::REGULAR_TEXT;\r\n        }\r\n    }\r\n\telse if (role == Qt::BackgroundRole)\r\n    {\r\n        if (index.column() == ComPropertyColumns::NAME ||\r\n            index.column() == ComPropertyColumns::REQUIRED ||\r\n            index.column() == ComPropertyColumns::TYPE)\r\n        {\r\n            return KactusColors::MANDATORY_FIELD;\r\n        }\r\n        else\r\n        {\r\n            return KactusColors::REGULAR_FIELD;\r\n        }\r\n\t}\r\n    else\r\n    {\r\n        return QVariant();\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComPropertyModel::headerData()\r\n//-----------------------------------------------------------------------------\r\nQVariant ComPropertyModel::headerData(int section, Qt::Orientation orientation, int role) const\r\n{\r\n    if (orientation != Qt::Horizontal || role != Qt::DisplayRole)\r\n    {\r\n        return QVariant();\r\n    }\r\n\r\n    if (section == ComPropertyColumns::NAME)\r\n    {\r\n        return tr(\"Name\");\r\n    }\r\n    else if (section == ComPropertyColumns::REQUIRED)\r\n    {\r\n        return tr(\"Required\");\r\n    }\r\n    else if (section == ComPropertyColumns::TYPE)\r\n    {\r\n        return tr(\"Type\");\r\n    }\r\n    else if (section == ComPropertyColumns::DEFAULT_VALUE)\r\n    {\r\n        return tr(\"Default Value\");\r\n    }\r\n    else if (section == ComPropertyColumns::DESCRIPTION)\r\n    {\r\n        return tr(\"Description\");\r\n    }\r\n    else\r\n    {\r\n        return QVariant();\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComPropertyModel::flags()\r\n//-----------------------------------------------------------------------------\r\nQt::ItemFlags ComPropertyModel::flags(QModelIndex const& index) const\r\n{\r\n    if (!index.isValid())\r\n    {\r\n        return Qt::NoItemFlags;\r\n    }\r\n\r\n    return Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsEditable;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComPropertyModel::setData()\r\n//-----------------------------------------------------------------------------\r\nbool ComPropertyModel::setData(QModelIndex const& index, QVariant const& value, int role)\r\n{\r\n    if (!index.isValid() || index.row() < 0 || index.row() >= table_.size() || role != Qt::EditRole)\r\n    {\r\n        return false;\r\n    }\r\n\r\n    if (index.column() == ComPropertyColumns::NAME)\r\n    {\r\n        table_[index.row()]->setName(value.toString());\r\n    }\r\n    else if (index.column() == ComPropertyColumns::REQUIRED)\r\n    {\r\n        table_[index.row()]->setRequired(value.toBool());\r\n    }\r\n    else if (index.column() == ComPropertyColumns::TYPE)\r\n    {\r\n        table_[index.row()]->setType(value.toString());\r\n    }\r\n    else if (index.column() == ComPropertyColumns::DEFAULT_VALUE)\r\n    {\r\n        table_[index.row()]->setDefaultValue(value.toString());\r\n    }\r\n    else if (index.column() == ComPropertyColumns::DESCRIPTION)\r\n    {\r\n        table_[index.row()]->setDescription(value.toString());\r\n    }\r\n    else\r\n    {\r\n        return false;\r\n    }\r\n\r\n    emit dataChanged(index, index);\r\n    emit contentChanged();\r\n    return true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComPropertyModel::isValid()\r\n//-----------------------------------------------------------------------------\r\nbool ComPropertyModel::isValid() const\r\n{\r\n    return true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComPropertyModel::onAdd()\r\n//-----------------------------------------------------------------------------\r\nvoid ComPropertyModel::onAdd()\r\n{\r\n    beginInsertRows(QModelIndex(), table_.size(), table_.size());\r\n    table_.append(QSharedPointer<ComProperty>(new ComProperty()));\r\n    endInsertRows();\r\n    emit contentChanged();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComPropertyModel::onAddItem()\r\n//-----------------------------------------------------------------------------\r\nvoid ComPropertyModel::onAddItem(QModelIndex const& index)\r\n{\r\n    int row = table_.size();\r\n\r\n    // if the index is valid then add the item to the correct position\r\n    if (index.isValid())\r\n    {\r\n        row = index.row();\r\n    }\r\n\r\n    beginInsertRows(QModelIndex(), row, row);\r\n    table_.insert(row, QSharedPointer<ComProperty>(new ComProperty()));\r\n    endInsertRows();\r\n\r\n    // tell also parent widget that contents have been changed\r\n    emit contentChanged();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComPropertyModel::onRemove()\r\n//-----------------------------------------------------------------------------\r\nvoid ComPropertyModel::onRemove(QModelIndex const& index)\r\n{\r\n    if (!index.isValid())\r\n    {\r\n        return;\r\n    }\r\n\r\n    // remove the indexed configurable element\r\n    beginRemoveRows(QModelIndex(), index.row(), index.row());\r\n    table_.removeAt(index.row());\r\n    endRemoveRows();\r\n\r\n    emit contentChanged();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComPropertyModel::onRemoveItem()\r\n//-----------------------------------------------------------------------------\r\nvoid ComPropertyModel::onRemoveItem(QModelIndex const& index )\r\n{\r\n    // Don't remove anything if index or row is invalid.\r\n    if (!index.isValid() || index.row() < 0 || index.row() >= table_.size())\r\n    {\r\n        return;\r\n    }\r\n\r\n    // Remove the indexed property.\r\n    beginRemoveRows(QModelIndex(), index.row(), index.row());\r\n    table_.removeAt(index.row());\r\n    endRemoveRows();\r\n\r\n    emit contentChanged();\r\n}\r\n"
  },
  {
    "path": "editors/ComDefinitionEditor/ComPropertyModel.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ComPropertyModel.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Joni-Matti Maatta\r\n// Date: 17.4.2012\r\n//\r\n// Description:\r\n// Model for COM properties.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef COMPROPERTYMODEL_H\r\n#define COMPROPERTYMODEL_H\r\n\r\n#include <QAbstractTableModel>\r\n#include <QMap>\r\n#include <QList>\r\n#include <QString>\r\n#include <QSharedPointer>\r\n\r\nclass ComProperty;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! ComPropertyModel class.\r\n//-----------------------------------------------------------------------------\r\nclass ComPropertyModel : public QAbstractTableModel\r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n    /*!\r\n     *  Constructor.\r\n     *\r\n     *    @param [in] parent The parent object.\r\n\t */\r\n\tComPropertyModel(QObject *parent);\r\n\r\n\t/*!\r\n     *  Destructor.\r\n     */\r\n\tvirtual ~ComPropertyModel();\r\n\r\n    /*!\r\n     *  Sets the properties for editing.\r\n     *\r\n     *    @param [in] properties The list of properties.\r\n     */\r\n    void setProperties(QList< QSharedPointer<ComProperty> >  properties);\r\n\r\n    /*!\r\n     *  Returns the properties.\r\n     */\r\n    QList< QSharedPointer<ComProperty> >getProperties() const;\r\n\r\n    /*!\r\n     *  Returns the number of rows in the model.\r\n\t *\r\n\t *    @param [in] parent Model index of the parent of the item. Must be invalid\r\n\t *                         because this is not hierarchical model.\r\n\t *\r\n\t *    @return Number of rows currently in the model.\r\n\t */\r\n\tvirtual int rowCount(QModelIndex const& parent = QModelIndex()) const;\r\n\r\n\t/*! \r\n     *  Returns the number of columns in the model.\r\n\t *\r\n\t *    @param [in] parent Model index of the parent of the item. Must be invalid\r\n\t *                         because this is not hierarchical model.\r\n\t *\r\n\t *    @return Always returns PROPERTY_COL_COUNT.\r\n\t */\r\n\tvirtual int columnCount(QModelIndex const& parent = QModelIndex()) const;\r\n\r\n\t/*!\r\n     *  Returns the data for the specified item for specified role.\r\n\t *\r\n\t *    @param [in] index  Identifies the item that's data is wanted.\r\n\t *    @param [in] role   Specifies what kind of data is wanted\r\n\t *\r\n\t *    @return QVariant containing the data.\r\n\t */\r\n\tvirtual QVariant data(QModelIndex const& index, int role = Qt::DisplayRole) const;\r\n\r\n\t/*!\r\n     *  Returns the data for the headers.\r\n\t *\r\n\t *    @param [in] section      The column that's header is wanted\r\n\t *    @param [in] orientation  Only Qt::Horizontal is supported\r\n\t *    @param [in] role         Specified the type of data that is wanted.\r\n\t *\r\n\t *    @return QVariant containing the header data.\r\n\t */\r\n\tvirtual QVariant headerData(int section, Qt::Orientation orientation, \r\n\t\t                        int role = Qt::DisplayRole) const;\r\n\r\n\t/*!\r\n     *  Returns information on how specified item can be handled.\r\n\t *\r\n\t *    @param [in] index Specifies the item that's flags are wanted.\r\n\t *\r\n\t *    @return Item flags that define how object can be handled.\r\n\t */\r\n\tvirtual Qt::ItemFlags flags(QModelIndex const& index) const;\r\n\r\n\t/*!\r\n     *  Returns the data for specified item.\r\n\t *\r\n\t *    @param [in] index  Specifies the item that's data is modified\r\n\t *    @param [in] value  The value to be set.\r\n\t *    @param [in] role   The role that is trying to modify the data. Only Qt::EditRole is supported.\r\n\t *\r\n\t *    @return True if data was successfully set.\r\n\t */\r\n\tvirtual bool setData(QModelIndex const& index, QVariant const& value, \r\n\t\t                 int role = Qt::EditRole);\r\n\r\n\t/*!\r\n     *  Checks whether the model is in valid state or not.\r\n     *\r\n\t *    @return True if all items in model are valid.\r\n\t */\r\n\tbool isValid() const;\r\n\r\npublic slots:\r\n    void onAdd();\r\n    void onAddItem(QModelIndex const& index);\r\n    void onRemove(QModelIndex const& index );\r\n    void onRemoveItem(QModelIndex const& index );\r\n\r\nsignals:\r\n\t//! Emitted when contents of the model change.\r\n\tvoid contentChanged();\r\n\r\n\t//! Prints an error message to the user.\r\n\tvoid errorMessage(const QString& msg) const;\r\n\t\r\n\t//! Prints a notification to user.\r\n\tvoid noticeMessage(const QString& msg) const;\r\n\r\nprivate:\r\n    // Disable copying.\r\n    ComPropertyModel(ComPropertyModel const& rhs);\r\n    ComPropertyModel& operator=(ComPropertyModel const& rhs);\r\n    \r\n    //! IP address regular expression string.\r\n\tstatic QString const IP_ADDRESS_REGEX;\r\n\r\n\t//! Time unit regular expression string.\r\n\tstatic QString const TIME_UNIT_REGEX;\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\t\r\n\t//! The table that is displayed to the user.\r\n\tQList< QSharedPointer<ComProperty> > table_;\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n\r\n#endif // COMPROPERTYMODEL_H\r\n"
  },
  {
    "path": "editors/ComponentEditor/ParameterItemEditor.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: ParameterItemEditor.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 06.10.2017\n//\n// Description:\n// ItemEditor for component items containing parameters.\n//-----------------------------------------------------------------------------\n\n#include \"ParameterItemEditor.h\"\n\n//-----------------------------------------------------------------------------\n// Function: ParameterItemEditor::ParameterItemEditor()\n//-----------------------------------------------------------------------------\nParameterItemEditor::ParameterItemEditor( QSharedPointer<Component> component, LibraryInterface* handler,\n    QWidget *parent):\nItemEditor(component, handler, parent)\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: ParameterItemEditor::~ParameterItemEditor()\n//-----------------------------------------------------------------------------\nParameterItemEditor::~ParameterItemEditor()\n{\n\n}\n"
  },
  {
    "path": "editors/ComponentEditor/ParameterItemEditor.h",
    "content": "//-----------------------------------------------------------------------------\n// File: ParameterItemEditor.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 06.10.2017\n//\n// Description:\n// ItemEditor for component items containing parameters, containing signals for reference trees.\n//-----------------------------------------------------------------------------\n\n#ifndef PARAMETERITEMEDITOR_H\n#define PARAMETERITEMEDITOR_H\n\n#include <editors/ComponentEditor/itemeditor.h>\n\nclass Parameter;\nclass AbstractParameterInterface;\n\n//-----------------------------------------------------------------------------\n//! ItemEditor for component items containing parameters, containing signals for reference trees.\n//-----------------------------------------------------------------------------\nclass ParameterItemEditor : public ItemEditor\n{\n\tQ_OBJECT\n\npublic:\n\n\t/*!\n     *  The constructor.\n\t *\n\t *    @param [in] component   Pointer to the component instance that is being edited.\n\t *    @param [in] handler     Pointer to the instance that manages the library.\n\t *    @param [in] parent      Pointer to the owner of this widget.\n\t */\n\tParameterItemEditor(QSharedPointer<Component> component, LibraryInterface* handler, QWidget *parent = 0);\n\n\t/*!\n     *  The destructor.\n     */\n\tvirtual ~ParameterItemEditor();\n\n\t/*!\n     *  Reload the information from the model to the editor.\n\t */\n\tvirtual void refresh() = 0;\n\nsignals:\n\n    /*!\n     *  Open the reference tree of the selected parameter.\n     *\n     *    @param [in] id              Id of the selected parameter.\n     *    @param [in] parameterName   Name of the selected parameter.\n     */\n    void openReferenceTree(QString const& id, QString const& parameterName) const;\n\n    /*!\n     *  Recalculate references made to the selected parameters.\n     *\n     *    @param [in] parameterList       The selected parameters.\n     *    @param [in] parameterInterface  Interface for accessing parameters.\n     */\n    void recalculateReferencesToParameters(QVector<QString> const& parameterList,\n        AbstractParameterInterface* parameterInterface);\n\nprivate:\n\n\t//! No copying. No Assignment.\n\tParameterItemEditor(const ParameterItemEditor& other);\n\tParameterItemEditor& operator=(const ParameterItemEditor& other);\n};\n\n#endif // PARAMETERITEMEDITOR_H\n"
  },
  {
    "path": "editors/ComponentEditor/addressSpaces/AddressSpaceColumns.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: AddressSpaceColumns.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Esko Pekkarinen\r\n// Date: 11.05.2015\r\n//\r\n// Description:\r\n// Common declarations for editing memory map table columns.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef ADDRESS_SPACE_COLUMNS_H\r\n#define ADDRESS_SPACE_COLUMNS_H\r\n\r\nnamespace AddressSpaceColumns\r\n{\r\n    //! Defines the columns for the address space table.\r\n    enum Column\r\n    {\r\n        NAME = 0,\t\t\r\n        AUB,\t\r\n        RANGE,\r\n        WIDTH,\r\n        INTERFACE_BINDING,\r\n        IS_PRESENT,\r\n        DESCRIPTION,\r\n        COLUMN_COUNT\r\n    };\r\n}\r\n\r\n#endif //ADDRESS_SPACE_COLUMNS_H"
  },
  {
    "path": "editors/ComponentEditor/addressSpaces/SegmentColumns.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: SegmentColumns.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Mikko Teuho\r\n// Date: 22.10.2015\r\n//\r\n// Description:\r\n// Common declarations for segment table columns.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef SEGMENTCOLUMNS_H\r\n#define SEGMENTCOLUMNS_H\r\n\r\nnamespace SegmentColumns\r\n{\r\n    //! Defines the columns for the address space table.\r\n    enum Column\r\n    {\r\n        NAME = 0,\r\n        OFFSET,\r\n        RANGE,\r\n        IS_PRESENT,\r\n        DESCRIPTION,\r\n        COLUMN_COUNT\r\n    };\r\n}\r\n\r\n#endif // SEGMENTCOLUMNS_H"
  },
  {
    "path": "editors/ComponentEditor/addressSpaces/SegmentDelegate.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: SegmentDelegate.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Esko Pekkarinen\r\n// Date: 11.05.2015\r\n//\r\n// Description:\r\n// Delegate class for segments within an address space.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"SegmentDelegate.h\"\r\n#include \"SegmentColumns.h\"\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SegmentDelegate::SegmentDelegate()\r\n//-----------------------------------------------------------------------------\r\nSegmentDelegate::SegmentDelegate(QAbstractItemModel* completionModel, QSharedPointer<ParameterFinder> parameterFinder,\r\n    QObject* parent)\r\n    : ExpressionDelegate(completionModel, parameterFinder, parent)\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SegmentDelegate::columnAcceptsExpression()\r\n//-----------------------------------------------------------------------------\r\nbool SegmentDelegate::columnAcceptsExpression(int column) const\r\n{\r\n    return column == SegmentColumns::OFFSET || column == SegmentColumns::RANGE ||\r\n        column == SegmentColumns::IS_PRESENT;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SegmentDelegate::descriptionColumn()\r\n//-----------------------------------------------------------------------------\r\nint SegmentDelegate::descriptionColumn() const\r\n{\r\n    return SegmentColumns::DESCRIPTION;\r\n}\r\n\r\n"
  },
  {
    "path": "editors/ComponentEditor/addressSpaces/SegmentDelegate.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: SegmentDelegate.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Esko Pekkarinen\r\n// Date: 11.05.2015\r\n//\r\n// Description:\r\n// Delegate class for segments within an address space.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef SEGMENTDELEGATE_H\r\n#define SEGMENTDELEGATE_H\r\n\r\n#include <editors/ComponentEditor/common/ExpressionDelegate.h>\r\n\r\n#include <KactusAPI/include/ParameterFinder.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SegmentDelegate::SegmentDelegate()\r\n//-----------------------------------------------------------------------------\r\nclass SegmentDelegate : public ExpressionDelegate\r\n{\r\n    Q_OBJECT\r\n\r\npublic:\r\n    /*!\r\n     *  The constructor.\r\n     *\r\n     *    @param [in] completionModel     Model containing the completions used in expression editor.\r\n     *    @param [in] parameterFinder     The parameter finder to use for for expression editor.\r\n     *    @param [in] parent              The parent object.\r\n     */\r\n    SegmentDelegate(QAbstractItemModel* completionModel, QSharedPointer<ParameterFinder> parameterFinder,\r\n        QObject* parent);\r\n\r\n    //! The destructor.\r\n    virtual ~SegmentDelegate() = default;\r\n\r\n    // Disable copying.\r\n    SegmentDelegate(SegmentDelegate const& rhs) = delete;\r\n    SegmentDelegate& operator=(SegmentDelegate const& rhs) = delete;\r\n\r\nprotected:\r\n\r\n    /*!\r\n     *  Checks if the given column supports expressions in the editor.\r\n     *\r\n     *    @param [in] column   The column to check.\r\n     *\r\n     *    @return True, if the cells in the column allow expressions, otherwise false.\r\n     */\r\n    bool columnAcceptsExpression(int column) const final;\r\n\r\n    //! Gets the description column.\r\n    int descriptionColumn() const final;\r\n\r\n};\r\n\r\n#endif // SEGMENTDELEGATE_H\r\n"
  },
  {
    "path": "editors/ComponentEditor/addressSpaces/addressSpaceVisualizer/AddressSpaceConflictedItem.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: AddressSpaceConflictedItem.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Esko Pekkarinen\r\n// Date: 21.08.2013\r\n//\r\n// Description:\r\n// Overlapping memory item for segments and local memory blocks.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"AddressSpaceConflictedItem.h\"\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressSpaceConflictedItem()\r\n//-----------------------------------------------------------------------------\r\nAddressSpaceConflictedItem::AddressSpaceConflictedItem(VisualizerItem::LabelLayout addrPos,\r\n                                                       QString const& addressSpaceWidth,\r\n                                                       QSharedPointer<ExpressionParser> expressionParser,\r\n                                                       QGraphicsItem* parent):\r\nAddressSpaceGapItem(addrPos, addressSpaceWidth, expressionParser, parent)\r\n{\r\n    setConflicted(true);\r\n    setName(\"Conflicted\");\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressSpaceConflictedItem::refresh()\r\n//-----------------------------------------------------------------------------\r\nvoid AddressSpaceConflictedItem::refresh()\r\n{\r\n    AddressSpaceGapItem::refresh();\r\n\r\n    const int BIT_WIDTH = getBitWidth();\r\n    setToolTip(\"<b>Two or more memory blocks are mapped to these addresses.<br>First address: </b>\" + \r\n        toHexString(getOffset(), BIT_WIDTH) + \"<br>\" +\r\n        \"<b>Last address: </b>\" + toHexString(getLastAddress(), BIT_WIDTH));\r\n}\r\n"
  },
  {
    "path": "editors/ComponentEditor/addressSpaces/addressSpaceVisualizer/AddressSpaceConflictedItem.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: AddressSpaceConflictedItem.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Esko Pekkarinen\r\n// Date: 21.08.2013\r\n//\r\n// Description:\r\n// Overlapping memory item for segments and local memory blocks.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef AddressSpaceConflictedItem_H\r\n#define AddressSpaceConflictedItem_H\r\n\r\n#include <editors/ComponentEditor/addressSpaces/addressSpaceVisualizer/addressspacegapitem.h>\r\n\r\nclass ExpressionParser;\r\n//-----------------------------------------------------------------------------\r\n//! Visual item for overlapping memory segments and local memory blocks.\r\n//-----------------------------------------------------------------------------\r\nclass AddressSpaceConflictedItem : public AddressSpaceGapItem\r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\r\n\t/*!\r\n\t *  The constructor.\r\n\t *\r\n\t *    @param [in] addrPos             Address alignment.\r\n\t *    @param [in] addressSpaceWidth   Address space width.\r\n\t *    @param [in] expressionParser    The used expression parser.\r\n\t *    @param [in] parent              Pointer to the parent graph item.\r\n\t */\r\n\tAddressSpaceConflictedItem(VisualizerItem::LabelLayout addrPos,\r\n        QString const& addressSpaceWidth,\r\n        QSharedPointer<ExpressionParser> expressionParser,\r\n\t\tQGraphicsItem* parent = 0);\r\n\t\r\n\t//! The destructor.\r\n\tvirtual ~AddressSpaceConflictedItem() = default;\r\n\r\n    //! No copying\r\n    AddressSpaceConflictedItem(const AddressSpaceConflictedItem& other) = delete;\r\n\r\n    //! No assignment\r\n    AddressSpaceConflictedItem& operator=(const AddressSpaceConflictedItem& other) = delete;\r\n\r\n\t//! Refresh the item.\r\n    virtual void refresh() override final;\r\n\r\n};\r\n\r\n#endif // AddressSpaceConflictedItem_H\r\n"
  },
  {
    "path": "editors/ComponentEditor/addressSpaces/addressSpaceVisualizer/addressspacegapitem.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: addressspacegapitem.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 04.01.2013\r\n//\r\n// Description:\r\n// The graphical item that represents a gap in between address space objects.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"addressspacegapitem.h\"\r\n\r\n#include <KactusAPI/include/ExpressionParser.h>\r\n\r\n#include <QBrush>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressSpaceGapItem()\r\n//-----------------------------------------------------------------------------\r\nAddressSpaceGapItem::AddressSpaceGapItem(VisualizerItem::LabelLayout addrPos,\r\n                                         QString const& addressSpaceWidth,\r\n                                         QSharedPointer<ExpressionParser> expressionParser,\r\n\t\t\t\t\t\t\t\t\t\t QGraphicsItem* parent):\r\nAddressSpaceVisualizationItem(addressSpaceWidth, expressionParser, parent),\r\naddrPosition_(addrPos) \r\n{\r\n    VisualizerItem::setDefaultBrush(QBrush(Qt::white));\r\n\r\n    setLayoutType(addrPos);\r\n\tsetName(\"...\");\r\n    setToolTip(\"This memory block is unassigned.\");\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: refresh()\r\n//-----------------------------------------------------------------------------\r\nvoid AddressSpaceGapItem::refresh() \r\n{\r\n    if (addrPosition_ == LabelLayout::LABELS_LEFT)\r\n    {\r\n        setTopLabelText(start_);\r\n        if (end_ != start_)\r\n        {\r\n            setBottomLabelText(end_);\r\n        }\r\n        else\r\n        {\r\n            VisualizerItem::setBottomLabelText(\"\");\r\n        }\r\n    }\r\n\r\n    else\r\n    {\r\n        setTopLabelText(start_);\r\n        if (end_ != start_)\r\n        {\r\n            setBottomLabelText(end_);\r\n        }\r\n        else\r\n        {\r\n            VisualizerItem::setBottomLabelText(\"\");\r\n        }\r\n    }\r\n\r\n    setOverlappingTop(start_);\r\n    setOverlappingBottom(end_);\r\n\r\n    repositionLabels();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: getOffset()\r\n//-----------------------------------------------------------------------------\r\nquint64 AddressSpaceGapItem::getOffset() const\r\n{\r\n\treturn start_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: getLastAddress()\r\n//-----------------------------------------------------------------------------\r\nquint64 AddressSpaceGapItem::getLastAddress() const\r\n{\r\n\treturn end_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: setStartAddress()\r\n//-----------------------------------------------------------------------------\r\nvoid AddressSpaceGapItem::setStartAddress( quint64 address, bool contains /*= true*/ )\r\n{\r\n\tif (contains)\r\n    {\r\n\t\tstart_ = address;\r\n\t}\r\n\telse\r\n    {\r\n\t\tstart_ = ++address;\r\n\t}\r\n\trefresh();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: setEndAddress()\r\n//-----------------------------------------------------------------------------\r\nvoid AddressSpaceGapItem::setEndAddress( quint64 address, bool contains /*= true*/ )\r\n{\r\n\tif (contains)\r\n    {\r\n\t\tend_ = address;\r\n\t}\r\n\telse\r\n    {\r\n\t\tend_ = --address;\r\n\t}\r\n\trefresh();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: setOverlappingTop()\r\n//-----------------------------------------------------------------------------\r\nvoid AddressSpaceGapItem::setOverlappingTop(quint64 const& address)\r\n{\r\n    firstFreeAddress_ = address;\r\n\r\n    if (addrPosition_ == LabelLayout::LABELS_LEFT)\r\n    {\r\n        setTopLabelText(firstFreeAddress_);\r\n\r\n        if (firstFreeAddress_ == lastFreeAddress_)\r\n        {\r\n            VisualizerItem::setBottomLabelText(\"\");\r\n        }\r\n        else\r\n        {\r\n            setBottomLabelText(lastFreeAddress_);\r\n        }\r\n    }\r\n\r\n    else //if (addrPosition == LabelLayout::LABELS_RIGHT)\r\n    {\r\n        setTopLabelText(firstFreeAddress_);\r\n\r\n        if (firstFreeAddress_ == lastFreeAddress_)\r\n        {        \r\n            VisualizerItem::setBottomLabelText(\"\");\r\n        }\r\n        else\r\n        {\r\n            setBottomLabelText(lastFreeAddress_);\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: setOverlappingBottom()\r\n//-----------------------------------------------------------------------------\r\nvoid AddressSpaceGapItem::setOverlappingBottom(quint64 const& address)\r\n{\r\n    lastFreeAddress_ = address;\r\n\r\n    if (addrPosition_ == LabelLayout::LABELS_LEFT)\r\n    {\r\n        if (firstFreeAddress_ == lastFreeAddress_)\r\n        {\r\n            VisualizerItem::setBottomLabelText(\"\");\r\n        }\r\n        else\r\n        {\r\n            setBottomLabelText(lastFreeAddress_);\r\n        }\r\n    }\r\n\r\n    else //if (addrPosition == LabelLayout::LABELS_RIGHT)\r\n    {  \r\n        if (firstFreeAddress_ == lastFreeAddress_)\r\n        {\r\n            VisualizerItem::setBottomLabelText(\"\");\r\n        }\r\n        else\r\n        {\r\n            setBottomLabelText(lastFreeAddress_);\r\n        }\r\n    }\r\n}"
  },
  {
    "path": "editors/ComponentEditor/addressSpaces/addressSpaceVisualizer/addressspacegapitem.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: addressspacegapitem.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 04.01.2013\r\n//\r\n// Description:\r\n// The graphical item that represents a gap in between address space objects.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef ADDRESSSPACEGAPITEM_H\r\n#define ADDRESSSPACEGAPITEM_H\r\n\r\n#include <editors/ComponentEditor/addressSpaces/addressSpaceVisualizer/addressspacevisualizationitem.h>\r\n\r\nclass ExpressionParser;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! The graphical item that represents a gap in between address space objects.\r\n//-----------------------------------------------------------------------------\r\nclass AddressSpaceGapItem : public AddressSpaceVisualizationItem\r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\r\n\t/*!\r\n\t *  The constructor.\r\n\t *\r\n\t *    @param [in] addrPos             Position of the address space.\r\n\t *    @param [in] addressSpaceWidth   Width of the address space.\r\n\t *    @param [in] expressionParser    The used expression parser.\r\n\t *    @param [in] parent              Pointer to the parent graph item.\r\n\t */\r\n\tAddressSpaceGapItem(VisualizerItem::LabelLayout addrPos,\r\n        QString const& addressSpaceWidth,\r\n        QSharedPointer<ExpressionParser> expressionParser,\r\n\t\tQGraphicsItem* parent = 0);\r\n\t\r\n\t//! The destructor.\r\n\tvirtual ~AddressSpaceGapItem() = default;\r\n\r\n    //! No copying.\r\n    AddressSpaceGapItem(const AddressSpaceGapItem& other) = delete;\r\n\r\n    //! No assignment.\r\n    AddressSpaceGapItem& operator=(const AddressSpaceGapItem& other) = delete;\r\n\r\n\t//! Refresh the item.\r\n\tvirtual void refresh() override;\r\n\r\n\t/*!\r\n     *  Get the offset of the item. \r\n\t *\r\n\t *    @return int The offset of the item.\r\n\t */\r\n\tvirtual quint64 getOffset() const override final;\r\n\r\n\t/*!\r\n     *  Get the last address contained in the item.\r\n\t *\r\n\t *    @return The last address.\r\n\t */\r\n\tvirtual quint64 getLastAddress() const override final;\r\n\r\n\t/*!\r\n     *  Set start address for the gap.\r\n\t *\r\n\t *    @param [in] address     The address that limits the gap start.\r\n\t *    @param [in] contains    If true then the address is contained in the gap, otherwise the gap starts\r\n     *                              from next address.\r\n\t */\r\n\tvoid setStartAddress(quint64 address, bool contains = true);\r\n\r\n\t/*!\r\n     *  Set end address for the gap.\r\n\t *\r\n\t *    @param [in] address     The address that limits the gap end.\r\n\t *    @param [in] contains    If true then the address is contained in the gap, otherwise the gap ends\r\n     *                              before the specified address.\r\n\t */\r\n\tvoid setEndAddress(quint64 address, bool contains = true);\r\n\r\n    /*!\r\n     *  Sets the first non-overlapping address to display.\r\n\t *\r\n\t *    @param [in] address     The first address to set.\r\n\t */\r\n    virtual void setOverlappingTop(quint64 const& address) override final;\r\n\r\n\t/*!\r\n     *  Sets the last non-overlapping address to display.\r\n\t *\r\n\t *    @param [in] address     The last address to set.\r\n\t */\r\n    virtual void setOverlappingBottom(quint64 const& address) override final;\r\n\r\nprivate:\r\n\t\t\r\n\t//! The start address of the gap.\r\n\tquint64 start_{ 0 };\r\n\r\n\t//! The end address of the gap.\r\n\tquint64 end_{ 0 };\r\n\r\n\t//! Defines where the address limits are aligned.\r\n    VisualizerItem::LabelLayout addrPosition_;\r\n};\r\n\r\n#endif // ADDRESSSPACEGAPITEM_H\r\n"
  },
  {
    "path": "editors/ComponentEditor/addressSpaces/addressSpaceVisualizer/addressspacescene.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: addressspacescene.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 22.12.2012\r\n//\r\n// Description:\r\n// The graphics scene containing the segments and local memory map of an address space.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"addressspacescene.h\"\r\n#include \"segmentgraphitem.h\"\r\n#include \"addressspacevisualizationitem.h\"\r\n#include \"addressspacegapitem.h\"\r\n#include \"localaddrblockgraphitem.h\"\r\n#include \"AddressSpaceConflictedItem.h\"\r\n\r\n#include <KactusAPI/include/ExpressionParser.h>\r\n\r\n#include <IPXACTmodels/Component/AddressSpace.h>\r\n#include <IPXACTmodels/Component/MemoryMapBase.h>\r\n#include <IPXACTmodels/Component/MemoryBlockBase.h>\r\n#include <IPXACTmodels/Component/AddressBlock.h>\r\n\r\n#include <common/graphicsItems/visualizeritem.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressSpaceScene()\r\n//-----------------------------------------------------------------------------\r\nAddressSpaceScene::AddressSpaceScene(QSharedPointer<AddressSpace> addrSpace,\r\n                                     QSharedPointer<ExpressionParser> expressionParser,\r\n\t\t\t\t\t\t\t\t\t QObject *parent):\r\nMemoryAlignScene(expressionParser, parent),\r\naddrSpace_(addrSpace)\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressSpaceScene::getWidth()\r\n//-----------------------------------------------------------------------------\r\nQString AddressSpaceScene::getWidth() const\r\n{\r\n    return addrSpace_->getWidth();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressSpaceScene::getRange()\r\n//-----------------------------------------------------------------------------\r\nQString AddressSpaceScene::getRange() const\r\n{\r\n    return addrSpace_->getRange();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressSpaceScene::createRegionItems()\r\n//-----------------------------------------------------------------------------\r\nvoid AddressSpaceScene::createRegionItems()\r\n{\r\n    quint64 addressSpaceEnd = addressSpaceLastAddress();\r\n    QSharedPointer<QList<QSharedPointer<Segment> > > segments = addrSpace_->getSegments();\r\n    auto width = getWidth();\r\n    for (QSharedPointer<Segment> current : *segments)\r\n    {\r\n        if (current->getIsPresent().isEmpty() ||\r\n            expressionParser_->parseExpression(current->getIsPresent()).toInt() == 1)\r\n        {\r\n            auto segItem = new SegmentGraphItem(current, width, expressionParser_);\r\n            addItem(segItem);\r\n\r\n            if (segItem->getOffset() > addressSpaceEnd)\r\n            {\r\n                exceedingSegments_.insert(segItem->getOffset(), segItem);\r\n            }\r\n            else\r\n            {\r\n                segmentItems_.insert(segItem->getOffset(), segItem);\r\n            }\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressSpaceScene::createAddressBlockItems()\r\n//-----------------------------------------------------------------------------\r\nvoid AddressSpaceScene::createAddressBlockItems()\r\n{\r\n    quint64 addressSpaceEnd = addressSpaceLastAddress();\r\n\r\n    auto width = getWidth();\r\n    QSharedPointer<MemoryMapBase> localMap = addrSpace_->getLocalMemoryMap();\r\n    if (!localMap.isNull() && !localMap->getMemoryBlocks().isNull())\r\n    {\r\n        for (QSharedPointer<MemoryBlockBase> block : *localMap->getMemoryBlocks())\r\n        {\r\n            QSharedPointer<AddressBlock> addrBlock = block.dynamicCast<AddressBlock>();\r\n            if (addrBlock &&\r\n                (addrBlock->getIsPresent().isEmpty() ||\r\n                    expressionParser_->parseExpression(addrBlock->getIsPresent()).toInt() == 1))\r\n            {\r\n                auto blockItem = new LocalAddrBlockGraphItem(addrBlock, width, expressionParser_);\r\n                addItem(blockItem);\r\n\r\n                if (blockItem->getOffset() > addressSpaceEnd)\r\n                {\r\n                    exceedingAddrBlocks_.insert(blockItem->getOffset(), blockItem);\r\n                }\r\n                else\r\n                {\r\n                    addrBlockItems_.insert(blockItem->getOffset(), blockItem);\r\n                }\r\n            }\r\n        }\r\n    }\r\n}\r\n\r\n"
  },
  {
    "path": "editors/ComponentEditor/addressSpaces/addressSpaceVisualizer/addressspacescene.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: addressspacescene.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 22.12.2012\r\n//\r\n// Description:\r\n// The graphics scene containing the segments and local memory map of an address space.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef ADDRESSSPACESCENE_H\r\n#define ADDRESSSPACESCENE_H\r\n\r\n#include \"addressspacegapitem.h\"\r\n\r\n#include <editors/ComponentEditor/common/MemoryAlignScene.h>\r\n\r\n#include <QGraphicsScene>\r\n#include <QSharedPointer>\r\n#include <QMultiMap>\r\n\r\nclass AddressSpaceVisualizationItem;\r\nclass ExpressionParser;\r\nclass AddressSpace;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! The graphics scene containing the segments and local memory map of an address space.\r\n//-----------------------------------------------------------------------------\r\nclass AddressSpaceScene : public MemoryAlignScene\r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\r\n\t/*!\r\n     *  The constructor.\r\n\t *\r\n\t *    @param [in] addrSpace         The address space being visualized.\r\n     *    @param [in] expressionParser  The expression parser to use for local memory maps.\r\n\t *    @param [in] parent            The owner of the scene.\r\n\t */\r\n\tAddressSpaceScene(QSharedPointer<AddressSpace> addrSpace, \r\n        QSharedPointer<ExpressionParser> expressionParser,\r\n\t\tQObject *parent);\r\n\t\r\n\t//! The destructor.\r\n\tvirtual ~AddressSpaceScene() = default;\r\n\r\n    //! No copying.\r\n    AddressSpaceScene(const AddressSpaceScene& other) = delete;\r\n\r\n    //! No assignment.\r\n    AddressSpaceScene& operator=(const AddressSpaceScene& other) = delete;\r\n\r\nprotected:\r\n\r\n    /*!\r\n     *  Get the width of the visualized memory.\r\n     *\r\n     *    @return The width of the memory.\r\n     */\r\n    QString getWidth() const final;\r\n\r\n    /*!\r\n     *  Get the range of the visualized memory.\r\n     *\r\n     *    @return The range of the memory.\r\n     */\r\n    QString getRange() const final;\r\n\r\n    /*!\r\n     *  Create the region/segment items placed on left.\r\n     *\r\n     */\r\n    void createRegionItems() final;\r\n\r\n    /*!\r\n     *  Create the address block items placed on right.\r\n     *\r\n     */\r\n    void createAddressBlockItems() final;\r\n\r\nprivate:\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n\t//! The address space being visualized.\r\n\tQSharedPointer<AddressSpace> addrSpace_;\r\n\r\n};\r\n\r\n#endif // ADDRESSSPACESCENE_H\r\n"
  },
  {
    "path": "editors/ComponentEditor/addressSpaces/addressSpaceVisualizer/addressspacevisualizationitem.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: addressspacevisualizationitem.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 20.12.2012\r\n//\r\n// Description:\r\n// The base class to visualize objects in address space editor.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"addressspacevisualizationitem.h\"\r\n\r\n#include <KactusAPI/include/ExpressionParser.h>\r\n\r\n#include <common/KactusColors.h>\r\n\r\n#include <QBrush>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressSpaceVisualizationItem()\r\n//-----------------------------------------------------------------------------\r\nAddressSpaceVisualizationItem::AddressSpaceVisualizationItem(QString const& addressSpaceWidth,\r\n                                                             QSharedPointer<ExpressionParser> expressionParser,\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t QGraphicsItem* parent):\r\nAddressableItem(parent),\r\nexpressionParser_(expressionParser),\r\naddressSpaceWidth_(addressSpaceWidth)\r\n{\r\n    setRect(0, 0, VisualizerItem::DEFAULT_WIDTH, AddressSpaceVisualizationItem::SEGMENT_HEIGHT);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: getBitWidth()\r\n//-----------------------------------------------------------------------------\r\nint AddressSpaceVisualizationItem::getBitWidth() const\r\n{\r\n\treturn expressionParser_->parseExpression(addressSpaceWidth_).toInt();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: setBottomCoordinate()\r\n//-----------------------------------------------------------------------------\r\nvoid AddressSpaceVisualizationItem::setBottomCoordinate(qreal yCoordinate)\r\n{\r\n\tqreal width = rect().width();\r\n\tqreal height = yCoordinate - y();\r\n\tsetRect(0, 0, width, height);\r\n\trepositionLabels();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: setHeight()\r\n//-----------------------------------------------------------------------------\r\nvoid AddressSpaceVisualizationItem::setHeight(qreal height)\r\n{\r\n\tqreal width = rect().width();\r\n\r\n    setRect(0, 0, width, height);\r\n    \r\n\tVisualizerItem::repositionLabels();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: setOverlappingTop()\r\n//-----------------------------------------------------------------------------\r\nvoid AddressSpaceVisualizationItem::setOverlappingTop(quint64 const& address)\r\n{\r\n    firstFreeAddress_ = address;\r\n    setTopLabelText(firstFreeAddress_);\r\n\r\n    if (firstFreeAddress_ == lastFreeAddress_)\r\n    {        \r\n        VisualizerItem::setBottomLabelText(\"\");\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: getOverlappingTop()\r\n//-----------------------------------------------------------------------------\r\nquint64 AddressSpaceVisualizationItem::getOverlappingTop()\r\n{\r\n    return firstFreeAddress_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: setOverlappingBottom()\r\n//-----------------------------------------------------------------------------\r\nvoid AddressSpaceVisualizationItem::setOverlappingBottom(quint64 const& address)\r\n{\r\n    lastFreeAddress_ = address;\r\n    setBottomLabelText(lastFreeAddress_);\r\n\r\n    if (firstFreeAddress_ == lastFreeAddress_)\r\n    {\r\n        VisualizerItem::setBottomLabelText(\"\");\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: getOverlappingBottom()\r\n//-----------------------------------------------------------------------------\r\nquint64 AddressSpaceVisualizationItem::getOverlappingBottom()\r\n{\r\n    return lastFreeAddress_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: setCompleteOverlap()\r\n//-----------------------------------------------------------------------------\r\nvoid AddressSpaceVisualizationItem::setCompleteOverlap()\r\n{\r\n    overlapped_ = true;\r\n    hide();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: isCompletelyOverlapped()\r\n//-----------------------------------------------------------------------------\r\nbool AddressSpaceVisualizationItem::isCompletelyOverlapped() const\r\n{\r\n    return overlapped_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressSpaceVisualizationItem::getExpressionParser()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<ExpressionParser> AddressSpaceVisualizationItem::getExpressionParser() const\r\n{\r\n    return expressionParser_;\r\n}\r\n"
  },
  {
    "path": "editors/ComponentEditor/addressSpaces/addressSpaceVisualizer/addressspacevisualizationitem.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: addressspacevisualizationitem.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 20.12.2012\r\n//\r\n// Description:\r\n// The base class to visualize objects in address space editor.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef ADDRESSSPACEVISUALIZATIONITEM_H\r\n#define ADDRESSSPACEVISUALIZATIONITEM_H\r\n\r\n#include <editors/ComponentEditor/visualization/AddressableItem.h>\r\n\r\n#include <QSharedPointer>\r\n\r\nclass ExpressionParser;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! The base class to visualize objects in address space editor.\r\n//-----------------------------------------------------------------------------\r\nclass AddressSpaceVisualizationItem : public AddressableItem\r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\r\n    //! The minimum and maximum bounds for address space items.\r\n\tenum Bounds\r\n    {\r\n        PEN_WIDTH = 2,\r\n        MIN_HEIGHT = VisualizerItem::DEFAULT_HEIGHT/2 + PEN_WIDTH, //! Height for items with one address.\r\n        SEGMENT_HEIGHT = 2*MIN_HEIGHT + PEN_WIDTH                  //! Height for items with address range.\r\n\t};\r\n\r\n\t/*!\r\n     *  The constructor\r\n\t *\r\n\t *    @param [in] addrSpace           The address space being visualized.\r\n   \t *    @param [in] expressionParser    The expression parser to use.\r\n\t *    @param [in] parent              The parent graphics item.\r\n\t */\r\n\tAddressSpaceVisualizationItem(QString const& addressSpaceWidth,\r\n        QSharedPointer<ExpressionParser> expressionParser,\r\n\t\tQGraphicsItem* parent = nullptr);\r\n\t\r\n\t//! The destructor.\r\n\tvirtual ~AddressSpaceVisualizationItem() = default;\r\n\r\n    //! No copying. No assignment.\r\n    AddressSpaceVisualizationItem(const AddressSpaceVisualizationItem& other) = delete;\r\n    AddressSpaceVisualizationItem& operator=(const AddressSpaceVisualizationItem& other) = delete;\r\n\r\n\t/*!\r\n     *  Get the bit width of the address space.\r\n\t * \r\n\t *    @return The bit width of the address space.\r\n\t */\r\n\tvirtual int getBitWidth() const;\r\n\r\n\t/*!\r\n     *  Set the coordinate that is the bottom y-coordinate for the item.\r\n\t *\r\n\t *    @param [in] yCoordinate The y-coordinate of the bottom.\r\n\t */\r\n\tvirtual void setBottomCoordinate(qreal yCoordinate);\r\n\r\n\t/*!\r\n     *  Set the height for the item.\r\n\t *\r\n\t *    @param [in] height The height to set.\r\n\t */\r\n\tvirtual void setHeight(qreal height);\r\n\r\n\t/*!\r\n     *  Sets the first non-overlapping address to display.\r\n\t *\r\n\t *    @param [in] The first address to set.\r\n\t */\r\n    virtual void setOverlappingTop(quint64 const& address);\r\n\r\n\t/*!\r\n     *  Get the first non-overlapping address of the item.\r\n\t *\r\n\t *    @return The first non-overlapping address or -1 if completely overlapped.\r\n\t */\r\n    virtual quint64 getOverlappingTop();\r\n\r\n\t/*!\r\n     *  Sets the last non-overlapping address to display.\r\n\t *\r\n\t *    @param [in] The last address to set.\r\n\t */\r\n    virtual void setOverlappingBottom(quint64 const& address);\r\n\r\n    /*!\r\n     *  Get the last non-overlapping address of the item.\r\n     *\r\n     *    @return The last non-overlapping address or -1 if completely overlapped.\r\n     */\r\n    virtual quint64 getOverlappingBottom();\r\n\r\n    //! Tells the item that its memory block is shadowed by other memory blocks.\r\n    virtual void setCompleteOverlap();\r\n    \r\n    /*!\r\n     *  Tells if the item is completely overlapped by other items.\r\n     *\r\n     *    @return True, if the item's memory is completely under other memory blocks, otherwise false.\r\n     */\r\n    virtual bool isCompletelyOverlapped() const;\r\n\r\nprotected:\r\n\r\n    //! Get the expression parser for solving expression values.\r\n    QSharedPointer<ExpressionParser> getExpressionParser() const;\r\n\r\n    //! The first non-overlapping address.\r\n    quint64 firstFreeAddress_ = 0;\r\n\r\n    //! The last non-overlapping address.\r\n    quint64 lastFreeAddress_ = 0;\r\n\r\nprivate:\r\n\r\n    //! The expression parser to use.\r\n    QSharedPointer<ExpressionParser> expressionParser_;\r\n\r\n    //! The bit width of the address space.\r\n\tQString addressSpaceWidth_;\r\n\r\n    //! Tells if the item is completely overlapped by other items.\r\n    bool overlapped_ = false;\r\n};\r\n\r\n#endif // ADDRESSSPACEVISUALIZATIONITEM_H\r\n"
  },
  {
    "path": "editors/ComponentEditor/addressSpaces/addressSpaceVisualizer/addressspacevisualizer.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: addressspacevisualizer.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 19.12.2012\r\n//\r\n// Description:\r\n// The visualizer to display the contents of an address space.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"addressspacevisualizer.h\"\r\n\r\n#include <common/graphicsItems/visualizeritem.h>\r\n#include <common/widgets/summaryLabel/summarylabel.h>\r\n\r\n#include <IPXACTmodels/Component/Component.h>\r\n#include <IPXACTmodels/Component/AddressSpace.h>\r\n\r\n#include <QHBoxLayout>\r\n#include <QVBoxLayout>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressSpaceVisualizer::AddressSpaceVisualizer()\r\n//-----------------------------------------------------------------------------\r\nAddressSpaceVisualizer::AddressSpaceVisualizer(QSharedPointer<AddressSpace> addrSpace,\r\n                                               QSharedPointer<ExpressionParser> expressionParser,\r\n\t\t\t\t\t\t\t\t\t\t\t   QWidget *parent):\r\nItemVisualizer(parent),\r\naddrSpace_(addrSpace),\r\nview_(new QGraphicsView(this)),\r\nscene_(new AddressSpaceScene(addrSpace, expressionParser, this))\r\n{\r\n\t// display a label on top the table\r\n\tSummaryLabel* segmentLabel = new SummaryLabel(tr(\"Segments\"), this);\r\n\tSummaryLabel* localAddrBlockLabel = new SummaryLabel(tr(\"Address blocks\"), this);\r\n\r\n\tQHBoxLayout* labelLayout = new QHBoxLayout();\r\n\tlabelLayout->addWidget(segmentLabel, 0, Qt::AlignCenter);\r\n\tlabelLayout->addWidget(localAddrBlockLabel, 0, Qt::AlignCenter);\r\n\r\n\tQVBoxLayout* layout = new QVBoxLayout(this);\r\n\tlayout->addLayout(labelLayout);\r\n\tlayout->addWidget(view_);\r\n\tlayout->setContentsMargins(0, 0, 0, 0);\r\n\r\n\tview_->setAlignment(Qt::AlignLeft | Qt::AlignTop);\r\n\tview_->setScene(scene_);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressSpaceVisualizer::~AddressSpaceVisualizer()\r\n//-----------------------------------------------------------------------------\r\nAddressSpaceVisualizer::~AddressSpaceVisualizer()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressSpaceVisualizer::refresh()\r\n//-----------------------------------------------------------------------------\r\nvoid AddressSpaceVisualizer::refresh()\r\n{\r\n\tscene_->refresh();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressSpaceVisualizer::minimumSizeHint()\r\n//-----------------------------------------------------------------------------\r\nQSize AddressSpaceVisualizer::minimumSizeHint() const\r\n{\r\n\treturn QSize(VisualizerItem::DEFAULT_WIDTH * 2 + 3, VisualizerItem::DEFAULT_HEIGHT * 6);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressSpaceVisualizer::sizeHint()\r\n//-----------------------------------------------------------------------------\r\nQSize AddressSpaceVisualizer::sizeHint() const\r\n{\r\n\treturn minimumSizeHint();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressSpaceVisualizer::showEvent()\r\n//-----------------------------------------------------------------------------\r\nvoid AddressSpaceVisualizer::showEvent(QShowEvent* event)\r\n{\r\n    ItemVisualizer::showEvent(event);\r\n    refresh();\r\n}"
  },
  {
    "path": "editors/ComponentEditor/addressSpaces/addressSpaceVisualizer/addressspacevisualizer.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: addressspacevisualizer.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 19.12.2012\r\n//\r\n// Description:\r\n// The visualizer to display the contents of an address space.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef ADDRESSSPACEVISUALIZER_H\r\n#define ADDRESSSPACEVISUALIZER_H\r\n\r\n#include <editors/ComponentEditor/itemvisualizer.h>\r\n#include <editors/ComponentEditor/addressSpaces/addressSpaceVisualizer/addressspacescene.h>\r\n\r\n#include <QSharedPointer>\r\n#include <QGraphicsView>\r\n#include <QSize>\r\n\r\nclass ExpressionParser;\r\nclass Component;\r\nclass AddressSpace;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! The visualizer to display the contents of an address space.\r\n//-----------------------------------------------------------------------------\r\nclass AddressSpaceVisualizer : public ItemVisualizer\r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\r\n\t/*!\r\n     *  The constructor.\r\n\t *\r\n     *    @param [in] addrSpace          The address space being visualized.\r\n     *    @param [in] expressionParser   The expression parser to use.\r\n\t *    @param [in] parent             The owner of the visualizer.\r\n\t */\r\n\tAddressSpaceVisualizer(QSharedPointer<AddressSpace> addrSpace,\r\n        QSharedPointer<ExpressionParser> expressionParser,\r\n\t\tQWidget *parent = 0);\r\n\t\r\n\t//! The destructor.\r\n\tvirtual ~AddressSpaceVisualizer();\r\n\r\n\t//! Update the contents of the visualizer.\r\n\tvirtual void refresh();\r\n\r\n\t/*!\r\n     *  The minimum size hint for the visualizer.\r\n\t *\r\n\t *    @return The minimum size hint.\r\n\t */\r\n\tvirtual QSize minimumSizeHint() const;\r\n\r\n\t/*!\r\n     *  The size hint for the visualizer.\r\n\t *\r\n\t *    @return The size hint.\r\n\t */\r\n\tvirtual QSize sizeHint() const;\r\n\r\nprotected:\r\n\r\n    //! Handler for showing the widget.\r\n    virtual void showEvent(QShowEvent* event);\r\n\r\nprivate:\r\n\t\r\n\t//! No copying.\r\n\tAddressSpaceVisualizer(const AddressSpaceVisualizer& other);\r\n\r\n\t//! No assignment.\r\n\tAddressSpaceVisualizer& operator=(const AddressSpaceVisualizer& other);\r\n\r\n\t//! The address space being visualized.\r\n\tQSharedPointer<AddressSpace> addrSpace_;\r\n\r\n\t//! The view displaying the visualization items.\r\n\tQGraphicsView* view_;\r\n\r\n\t//! The scene that manages the visualization items.\r\n\tAddressSpaceScene* scene_;\r\n};\r\n\r\n#endif // ADDRESSSPACEVISUALIZER_H\r\n"
  },
  {
    "path": "editors/ComponentEditor/addressSpaces/addressSpaceVisualizer/localaddrblockgraphitem.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: localaddrblockgraphitem.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 14.01.2013\r\n//\r\n// Description:\r\n// The graph item to visualize address blocks in local memory map.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"localaddrblockgraphitem.h\"\r\n\r\n#include <common/KactusColors.h>\r\n\r\n#include <KactusAPI/include/ExpressionParser.h>\r\n\r\n#include <IPXACTmodels/Component/AddressBlock.h>\r\n\r\n#include <QBrush>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LocalAddrBlockGraphItem::LocalAddrBlockGraphItem()\r\n//-----------------------------------------------------------------------------\r\nLocalAddrBlockGraphItem::LocalAddrBlockGraphItem(QSharedPointer<AddressBlock> block,\r\n                                                 QString const& addressSpaceWidth,\r\n                                                 QSharedPointer<ExpressionParser> expressionParser,\r\n\t\t\t\t\t\t\t\t\t\t\t\t QGraphicsItem* parent /*= 0*/ ):\r\nAddressSpaceVisualizationItem(addressSpaceWidth, expressionParser, parent),\r\naddrBlock_(block)\r\n{\r\n\tQ_ASSERT(addrBlock_);\r\n\r\n\tQBrush brush(KactusColors::ADDR_BLOCK_COLOR);\r\n\tVisualizerItem::setDefaultBrush(brush);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LocalAddrBlockGraphItem::refresh()\r\n//-----------------------------------------------------------------------------\r\nvoid LocalAddrBlockGraphItem::refresh()\r\n{\r\n\tsetName(addrBlock_->name());\r\n    \r\n    quint64 offset = getOffset();\r\n    quint64 lastAddr = getLastAddress();\r\n    setOverlappingTop(offset);    \r\n    setOverlappingBottom(lastAddr);\r\n\t\r\n    // Set tooltip to show addresses in hexadecimals.\r\n    const int BIT_WIDTH = getBitWidth();\r\n    setToolTip(\"<b>Name: </b>\" + addrBlock_->name() + \"<br>\" +\r\n        \"<b>Base address: </b>\" + toHexString(offset, BIT_WIDTH) + \"<br>\" +\r\n        \"<b>Last address: </b>\" + toHexString(lastAddr, BIT_WIDTH) + \"<br>\" +\r\n        \"<b>Size [AUB]: </b>\" + getExpressionParser()->parseExpression(addrBlock_->getRange()));\r\n\r\n\trepositionLabels();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LocalAddrBlockGraphItem::getOffset()\r\n//-----------------------------------------------------------------------------\r\nquint64 LocalAddrBlockGraphItem::getOffset() const\r\n{\r\n\treturn getExpressionParser()->parseExpression(addrBlock_->getBaseAddress()).toULongLong();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LocalAddrBlockGraphItem::getLastAddress()\r\n//-----------------------------------------------------------------------------\r\nquint64 LocalAddrBlockGraphItem::getLastAddress() const \r\n{\r\n    quint64 base = getOffset();\r\n    quint64 range = getExpressionParser()->parseExpression(addrBlock_->getRange()).toULongLong();\r\n\r\n    quint64 lastAddr = base + range;\r\n\r\n    if (lastAddr == 0) \r\n    {\r\n        return 0;\r\n    }\r\n\r\n    return lastAddr -1;\r\n}\r\n"
  },
  {
    "path": "editors/ComponentEditor/addressSpaces/addressSpaceVisualizer/localaddrblockgraphitem.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: localaddrblockgraphitem.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 14.01.2013\r\n//\r\n// Description:\r\n// The graph item to visualize address blocks in local memory map.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef LOCALADDRBLOCKGRAPHITEM_H\r\n#define LOCALADDRBLOCKGRAPHITEM_H\r\n\r\n#include <editors/ComponentEditor/addressSpaces/addressSpaceVisualizer/addressspacevisualizationitem.h>\r\n\r\n#include <QSharedPointer>\r\n\r\nclass ExpressionParser;\r\nclass AddressBlock;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! The graph item to visualize address blocks in local memory map.\r\n//-----------------------------------------------------------------------------\r\nclass LocalAddrBlockGraphItem : public AddressSpaceVisualizationItem\r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\r\n\t/*!\r\n\t *  The constructor.\r\n\t *\r\n\t *    @param [in] block               The address block being visualized.\r\n\t *    @param [in] addressSpaceWidth   The width of the address space.\r\n\t *    @param [in] expressionParser    The used expression parser.\r\n\t *    @param [in] parent              The parent graph item.\r\n\t */\r\n\tLocalAddrBlockGraphItem(QSharedPointer<AddressBlock> block,\r\n        QString const& addressSpaceWidth,\r\n        QSharedPointer<ExpressionParser> expressionParser,\r\n\t\tQGraphicsItem* parent = 0);\r\n\t\r\n\t//! The destructor.\r\n\tvirtual ~LocalAddrBlockGraphItem() = default;\r\n\r\n    //! No copying.\r\n    LocalAddrBlockGraphItem(const LocalAddrBlockGraphItem& other) = delete;\r\n\r\n    //! No assignment.\r\n    LocalAddrBlockGraphItem& operator=(const LocalAddrBlockGraphItem& other) = delete;\r\n\r\n\t//! Refresh the item.\r\n\tvirtual void refresh() override final;\r\n\r\n\t/*!\r\n     *  Get the offset of the item. \r\n\t *\r\n\t *    @return int The offset of the item.\r\n\t */\r\n\tvirtual quint64 getOffset() const override final;\r\n\r\n\t/*!\r\n     *  Get the last address contained in the item.\r\n\t *\r\n\t *    @return The last address.\r\n\t */\r\n\tvirtual quint64 getLastAddress() const override final;\r\n\r\nprivate:\r\n\t\t\r\n\t//! The address block being visualized.\r\n\tQSharedPointer<AddressBlock> addrBlock_;\r\n};\r\n\r\n#endif // LOCALADDRBLOCKGRAPHITEM_H\r\n"
  },
  {
    "path": "editors/ComponentEditor/addressSpaces/addressSpaceVisualizer/segmentgraphitem.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: segmentgraphitem.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 20.12.2012\r\n//\r\n// Description:\r\n// The graph item to visualize segments in address space editor.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"segmentgraphitem.h\"\r\n\r\n#include <common/KactusColors.h>\r\n\r\n#include <KactusAPI/include/ExpressionParser.h>\r\n\r\n#include <IPXACTmodels/Component/Region.h>\r\n\r\n#include <QBrush>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SegmentGraphItem::SegmentGraphItem()\r\n//-----------------------------------------------------------------------------\r\nSegmentGraphItem::SegmentGraphItem(QSharedPointer<Region> segment, QString const& addressSpaceWidth,\r\n                                   QSharedPointer<ExpressionParser> expressionParser, QGraphicsItem* parent):\r\nAddressSpaceVisualizationItem(addressSpaceWidth, expressionParser, parent),\r\nsegment_(segment)\r\n{\r\n\tQ_ASSERT(segment_);\r\n\r\n\tQBrush brush(KactusColors::ADDRESS_SEGMENT);\r\n\tVisualizerItem::setDefaultBrush(brush);\r\n    setLayoutType(LABELS_RIGHT);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SegmentGraphItem::refresh()\r\n//-----------------------------------------------------------------------------\r\nvoid SegmentGraphItem::refresh()\r\n{\r\n    setName(segment_->name());\r\n\r\n    quint64 offset = getOffset();\r\n    quint64 lastAddr = getLastAddress();\r\n    setOverlappingTop(offset);\r\n    setOverlappingBottom(lastAddr);\r\n\r\n    const int BIT_WIDTH = getBitWidth();\r\n    setToolTip(\"<b>Name: </b>\" + segment_->name() + \"<br>\" +\r\n        \"<b>Offset: </b>\" + toHexString(offset, BIT_WIDTH) + \"<br>\" +\r\n        \"<b>Last address: </b>\" + toHexString(lastAddr, BIT_WIDTH)  + \"<br>\" +\r\n        \"<b>Size [AUB]: </b>\" + getExpressionParser()->parseExpression(segment_->getRange()));\r\n\r\n    repositionLabels(); \r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SegmentGraphItem::getOffset()\r\n//-----------------------------------------------------------------------------\r\nquint64 SegmentGraphItem::getOffset() const\r\n{\r\n\treturn getExpressionParser()->parseExpression(segment_->getAddressOffset()).toULongLong();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SegmentGraphItem::getLastAddress()\r\n//-----------------------------------------------------------------------------\r\nquint64 SegmentGraphItem::getLastAddress() const\r\n{\r\n    quint64 base = getOffset();\r\n    quint64 range = getExpressionParser()->parseExpression(segment_->getRange()).toULongLong();\r\n\r\n    quint64 lastAddr = base + range;\r\n\r\n    // if the base and range are undefined then return 0\r\n    if (lastAddr == 0)\r\n    {\r\n        return 0;\r\n    }\r\n\r\n    // if they are defined then return actual last address\r\n    if (range != 0)\r\n    {\r\n        return lastAddr - 1;\r\n    }\r\n    else\r\n    {\r\n        return lastAddr;\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SegmentGraphItem::setOverlappingTop()\r\n//-----------------------------------------------------------------------------\r\nvoid SegmentGraphItem::setOverlappingTop(quint64 const& address)\r\n{\r\n    firstFreeAddress_ = address;\r\n    setTopLabelText(firstFreeAddress_);\r\n\r\n    if (firstFreeAddress_ == lastFreeAddress_)\r\n    {\r\n        VisualizerItem::setBottomLabelText(\"\");\r\n    }\r\n    else\r\n    {\r\n        setBottomLabelText(lastFreeAddress_);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SegmentGraphItem::setOverlappingBottom()\r\n//-----------------------------------------------------------------------------\r\nvoid SegmentGraphItem::setOverlappingBottom(quint64 const& address)\r\n{\r\n    lastFreeAddress_ = address;\r\n\r\n    if (firstFreeAddress_ == lastFreeAddress_)\r\n    {\r\n        VisualizerItem::setBottomLabelText(\"\");\r\n    }\r\n    else\r\n    {\r\n        setBottomLabelText(lastFreeAddress_);\r\n    }\r\n}\r\n"
  },
  {
    "path": "editors/ComponentEditor/addressSpaces/addressSpaceVisualizer/segmentgraphitem.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: segmentgraphitem.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 20.12.2012\r\n//\r\n// Description:\r\n// The graph item to visualize segments in address space editor.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef SEGMENTGRAPHITEM_H\r\n#define SEGMENTGRAPHITEM_H\r\n\r\n#include <editors/ComponentEditor/addressSpaces/addressSpaceVisualizer/addressspacevisualizationitem.h>\r\n\r\n#include <QSharedPointer>\r\n\r\nclass ExpressionParser;\r\nclass Region;\r\n//-----------------------------------------------------------------------------\r\n//! The graph item to visualize segments in address space editor.\r\n//-----------------------------------------------------------------------------\r\nclass SegmentGraphItem : public AddressSpaceVisualizationItem\r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\r\n\t/*!\r\n\t *  The constructor.\r\n\t *\r\n\t *    @param [in] segment             Pointer to the segment represented by this graph item.\r\n\t *    @param [in] addressSpaceWidth   Width of the address space.\r\n\t *    @param [in] expressionParser    Pointer to the expression parser.\r\n\t *    @param [in] parent              Pointer to the parent graph item.\r\n\t */\r\n\tSegmentGraphItem(QSharedPointer<Region> segment, QString const& addressSpaceWidth,\r\n        QSharedPointer<ExpressionParser> expressionParser, QGraphicsItem* parent = 0);\r\n\t\r\n\t//! The destructor.\r\n\tvirtual ~SegmentGraphItem() = default;\r\n\r\n    //! No copying.\r\n    SegmentGraphItem(const SegmentGraphItem& other) = delete;\r\n\r\n    //! No assignment.\r\n    SegmentGraphItem& operator=(const SegmentGraphItem& other) = delete;\r\n\r\n\t//! Refresh the item.\r\n\tvirtual void refresh() override final;\r\n\r\n\t/*!\r\n     *  Get the offset of the item. \r\n\t *\r\n\t *    @return int The offset of the item.\r\n\t */\r\n\tvirtual quint64 getOffset() const override final;\r\n\r\n\t/*!\r\n     *  Get the last address contained in the item.\r\n\t *\r\n\t *    @return The last address.\r\n\t */\r\n\tvirtual quint64 getLastAddress() const override final;\r\n\r\n    /*!\r\n     *  Sets the first non-overlapping address to display.\r\n\t *\r\n\t *    @param [in] address     The first address to set.\r\n\t */\r\n    virtual void setOverlappingTop(quint64 const& address) override final;\r\n\r\n\t/*!\r\n     *  Sets the last non-overlapping address to display.\r\n\t *\r\n\t *    @param [in] address     The last address to set.\r\n\t */\r\n    virtual void setOverlappingBottom(quint64 const& address) override final;\r\n\r\nprivate:\r\n\t\r\n\t//! Pointer to the segment being visualized.\r\n\tQSharedPointer<Region> segment_;\r\n};\r\n\r\n#endif // SEGMENTGRAPHITEM_H\r\n"
  },
  {
    "path": "editors/ComponentEditor/addressSpaces/addressspaceeditor.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: addressspaceeditor.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 21.2.2012\r\n//\r\n// Description:\r\n// Editor to edit and save settings of an address space within component editor.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"addressspaceeditor.h\"\r\n\r\n#include <KactusAPI/include/LibraryInterface.h>\r\n\r\n#include <IPXACTmodels/Component/Component.h>\r\n#include <IPXACTmodels/Component/AddressSpace.h>\r\n\r\n#include <QVBoxLayout>\r\n#include <QGridLayout>\r\n#include <QScrollArea>\r\n#include <QSplitter>\r\n#include <QWidget>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressSpaceEditor::AddressSpaceEditor()\r\n//-----------------------------------------------------------------------------\r\nAddressSpaceEditor::AddressSpaceEditor(QSharedPointer<Component> component, LibraryInterface* handler,\r\n    QSharedPointer<AddressSpace> addrSpace, QSharedPointer<ParameterFinder> parameterFinder,\r\n    QSharedPointer<ExpressionFormatter> expressionFormatter, QSharedPointer<ExpressionParser> expressionParser,\r\n    AddressBlockInterface* blockInterface, QWidget* parent):\r\nItemEditor(component, handler, parent),\r\naddrSpace_(addrSpace),\r\nnameEditor_(addrSpace, component->getRevision(), this),\r\ngeneralEditor_(addrSpace, component->getInitiatorInterfaces(addrSpace_->name()), parameterFinder, expressionParser,\r\n    component->getRevision(), this),\r\nsegmentsEditor_(addrSpace, component, handler->getDirectoryPath(component->getVlnv()), parameterFinder,\r\n    expressionParser, expressionFormatter, this),\r\nlocalMemMapEditor_(addrSpace, component, handler, parameterFinder, blockInterface, this)\r\n{\r\n\tQ_ASSERT(addrSpace_);\r\n\r\n    nameEditor_.setTitle(tr(\"Address space name and description\"));\r\n    nameEditor_.setMaximumHeight(160);\r\n\r\n    connect(&nameEditor_, SIGNAL(contentChanged()),\tthis, SIGNAL(contentChanged()), Qt::UniqueConnection);\r\n\r\n    connect(&generalEditor_, SIGNAL(contentChanged()), this, SIGNAL(contentChanged()), Qt::UniqueConnection);\r\n    connect(&generalEditor_, SIGNAL(graphicsChanged()), this, SIGNAL(graphicsChanged()), Qt::UniqueConnection);\r\n\r\n    connect(&generalEditor_, SIGNAL(increaseReferences(QString)),\r\n        this, SIGNAL(increaseReferences(QString)), Qt::UniqueConnection);\r\n    connect(&generalEditor_, SIGNAL(decreaseReferences(QString)),\r\n        this, SIGNAL(decreaseReferences(QString)), Qt::UniqueConnection);\r\n\r\n    connect(&segmentsEditor_, SIGNAL(contentChanged()), this, SIGNAL(contentChanged()), Qt::UniqueConnection);\r\n    connect(&segmentsEditor_, SIGNAL(contentChanged()), this, SIGNAL(graphicsChanged()), Qt::UniqueConnection);\r\n\r\n    connect(&segmentsEditor_, SIGNAL(errorMessage(const QString&)),\r\n        this, SIGNAL(errorMessage(const QString&)), Qt::UniqueConnection);\r\n    connect(&segmentsEditor_, SIGNAL(noticeMessage(const QString&)),\r\n        this, SIGNAL(noticeMessage(const QString&)), Qt::UniqueConnection);\r\n\r\n    connect(&segmentsEditor_, SIGNAL(increaseReferences(QString)),\r\n        this, SIGNAL(increaseReferences(QString)), Qt::UniqueConnection);\r\n    connect(&segmentsEditor_, SIGNAL(decreaseReferences(QString)),\r\n        this, SIGNAL(decreaseReferences(QString)), Qt::UniqueConnection);\r\n\r\n\tconnect(&localMemMapEditor_, SIGNAL(contentChanged()), this, SIGNAL(contentChanged()), Qt::UniqueConnection);\r\n    connect(&localMemMapEditor_, SIGNAL(graphicsChanged()), this, SIGNAL(graphicsChanged()), Qt::UniqueConnection);\r\n    connect(&localMemMapEditor_, SIGNAL(childGraphicsChanged(int)), this, SIGNAL(childGraphicsChanged(int)), Qt::UniqueConnection);\r\n    connect(&localMemMapEditor_, SIGNAL(errorMessage(const QString&)),\r\n        this, SIGNAL(errorMessage(const QString&)), Qt::UniqueConnection);\r\n\tconnect(&localMemMapEditor_, SIGNAL(itemAdded(int)), this, SIGNAL(childAdded(int)), Qt::UniqueConnection);\r\n\tconnect(&localMemMapEditor_, SIGNAL(itemRemoved(int)), this, SIGNAL(childRemoved(int)), Qt::UniqueConnection);\r\n\r\n    connect(&localMemMapEditor_, SIGNAL(increaseReferences(QString)),\r\n        this, SIGNAL(increaseReferences(QString)), Qt::UniqueConnection);\r\n    connect(&localMemMapEditor_, SIGNAL(decreaseReferences(QString)),\r\n        this, SIGNAL(decreaseReferences(QString)), Qt::UniqueConnection);\r\n\r\n    connect(&localMemMapEditor_, SIGNAL(addressingChanged()),\r\n        this, SIGNAL(addressingChanged()), Qt::UniqueConnection);\r\n    connect(&localMemMapEditor_, SIGNAL(childAddressingChanged(int)),\r\n        this, SIGNAL(childAddressingChanged(int)), Qt::UniqueConnection); \r\n\r\n    connect(&generalEditor_, SIGNAL(assignNewAddressUnitBits(QString const&)),\r\n        &localMemMapEditor_, SIGNAL(assignNewAddressUnitBits(QString const&)), Qt::UniqueConnection);\r\n\r\n    connect(this, SIGNAL(assignNewAddressUnitBits(QString const&)),\r\n        &localMemMapEditor_, SIGNAL(assignNewAddressUnitBits(QString const&)), Qt::UniqueConnection);\r\n\r\n    connect(&generalEditor_, SIGNAL(assignNewAddressUnitBits(QString const&)),\r\n        this, SIGNAL(newAddressUnitBitsForAddressSpaceChildItems()), Qt::UniqueConnection);\r\n\r\n    setupLayout();\r\n\r\n\trefresh();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressSpaceEditor::refresh()\r\n//-----------------------------------------------------------------------------\r\nvoid AddressSpaceEditor::refresh()\r\n{\r\n    QStringList masterInterfaceList = component()->getInitiatorInterfaces(addrSpace_->name());\r\n\r\n    // Block signals from here for the duration of refreshing editors.\r\n    blockSignals(true);\r\n\r\n    nameEditor_.refresh();\r\n\tgeneralEditor_.refresh(masterInterfaceList);\r\n\tsegmentsEditor_.refresh();\r\n\tlocalMemMapEditor_.refresh();\r\n\r\n    blockSignals(false);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressSpaceEditor::showEvent()\r\n//-----------------------------------------------------------------------------\r\nvoid AddressSpaceEditor::showEvent( QShowEvent* event )\r\n{\r\n\tQWidget::showEvent(event);\r\n\r\n    if (component()->getRevision() == Document::Revision::Std22)\r\n    {\r\n        emit helpUrlRequested(\"componenteditor/addressspace2022.html\");\r\n    }\r\n    else\r\n    {\r\n        emit helpUrlRequested(\"componenteditor/addressspace.html\");\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressSpaceEditor::setupLayout()\r\n//-----------------------------------------------------------------------------\r\nvoid AddressSpaceEditor::setupLayout()\r\n{\r\n    QScrollArea* scrollArea = new QScrollArea(this);\r\n    scrollArea->setWidgetResizable(true);\r\n    scrollArea->setFrameShape(QFrame::NoFrame);\r\n\r\n    QVBoxLayout* scrollLayout = new QVBoxLayout(this);\r\n    scrollLayout->addWidget(scrollArea);\r\n    scrollLayout->setContentsMargins(0, 0, 0, 0);\r\n\r\n    QWidget* topWidget = new QWidget(scrollArea);\r\n    topWidget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);\r\n\r\n    QGridLayout* topLayout = new QGridLayout(topWidget);\r\n    \r\n    topLayout->addWidget(&nameEditor_, 0, 0, 1, 1, Qt::AlignTop);\r\n    topLayout->addWidget(&generalEditor_, 0, 1, 1, 1);\r\n    topLayout->addWidget(&segmentsEditor_, 1, 0, 1, 2);\r\n    topLayout->setColumnStretch(0, 1);\r\n    topLayout->setColumnStretch(1, 1);\r\n    topLayout->setContentsMargins(0, 0, 0, 0);\r\n\r\n    QWidget* bottomWidget = new QWidget(scrollArea);\r\n    bottomWidget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);\r\n\r\n    QVBoxLayout* bottomLayout = new QVBoxLayout(bottomWidget);\r\n    bottomLayout->addWidget(&localMemMapEditor_);\r\n    bottomLayout->setContentsMargins(0, 0, 0, 0);\r\n\r\n    QSplitter* verticalSplitter = new QSplitter(Qt::Vertical, scrollArea);\r\n    verticalSplitter->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);\r\n    verticalSplitter->addWidget(topWidget);\r\n    verticalSplitter->addWidget(bottomWidget);\r\n    verticalSplitter->setStretchFactor(1, 1);\r\n\r\n    QSplitterHandle* handle = verticalSplitter->handle(1);\r\n    QVBoxLayout* handleLayout = new QVBoxLayout(handle);\r\n    handleLayout->setSpacing(0);\r\n    handleLayout->setContentsMargins(0, 0, 0, 0);\r\n\r\n    QFrame* line = new QFrame(handle);\r\n    line->setLineWidth(2);\r\n    line->setMidLineWidth(2);\r\n    line->setFrameShape(QFrame::HLine);\r\n    line->setFrameShadow(QFrame::Sunken);\r\n    handleLayout->addWidget(line);\r\n\r\n    verticalSplitter->setHandleWidth(10);\r\n\r\n    scrollArea->setWidget(verticalSplitter);\r\n}\r\n"
  },
  {
    "path": "editors/ComponentEditor/addressSpaces/addressspaceeditor.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: addressspaceeditor.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 21.2.2012\r\n//\r\n// Description:\r\n// Editor to edit and save settings of an address space within component editor.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef ADDRESSSPACEEDITOR_H\r\n#define ADDRESSSPACEEDITOR_H\r\n\r\n#include \"addressspacegeneraleditor.h\"\r\n#include \"segmenteditor.h\"\r\n#include \"localMemoryMap/localmemorymapeditor.h\"\r\n\r\n#include <common/widgets/nameGroupEditor/namegroupeditor.h>\r\n\r\n#include <KactusAPI/include/ParameterFinder.h>\r\n#include <KactusAPI/include/ExpressionFormatter.h>\r\n\r\n#include <editors/ComponentEditor/itemeditor.h>\r\n\r\n#include <QSharedPointer>\r\n\r\nclass LibraryInterface;\r\nclass Component;\r\nclass AddressSpace;\r\nclass AddressBlockInterface;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Editor to edit and save settings of an address space within component editor.\r\n//-----------------------------------------------------------------------------\r\nclass AddressSpaceEditor : public ItemEditor\r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\r\n\t/*!\r\n\t *  The constructor.\r\n\t *\r\n\t *    @param [in] component               The component being edited.\r\n\t *    @param [in] handler                 The instance managing the library.\r\n\t *    @param [in] addrSpace               The address space being edited.\r\n\t *    @param [in] parameterFinder         The parameter finder.\r\n\t *    @param [in] expressionFormatter     The expression formatter.\r\n     *    @param [in] expressionParser        The expression parser to use.\r\n     *    @param [in] blockInterface          Interface for address blocks.\r\n\t *    @param [in] parent                  The owner of this editor.\r\n\t */\r\n    AddressSpaceEditor(QSharedPointer<Component> component,\r\n        LibraryInterface* handler,\r\n        QSharedPointer<AddressSpace> addrSpace,\r\n        QSharedPointer <ParameterFinder> parameterFinder,\r\n        QSharedPointer <ExpressionFormatter> expressionFormatter,\r\n        QSharedPointer<ExpressionParser> expressionParser,\r\n        AddressBlockInterface* blockInterface,\r\n        QWidget* parent = 0);\r\n\r\n\t//! The destructor.\r\n\tvirtual ~AddressSpaceEditor() = default;\r\n\r\n\t/*!\r\n     *  Reload the information from the model to the editor.\r\n\t */\r\n\tvirtual void refresh();\r\n\r\nsignals:\r\n\r\n    /*!\r\n     *  Assign new address unit bits for address blocks.\r\n     *\r\n     *    @param [in] newAddressUnitBits  The new address unit bits.\r\n     */\r\n    void assignNewAddressUnitBits(QString const& newAddressUnitBits);\r\n\r\n    /*!\r\n     *  Inform the address block items of a change in address unit bits.\r\n     */\r\n    void newAddressUnitBitsForAddressSpaceChildItems();\r\n\r\n    void addressingChanged();\r\n\r\n    void childAddressingChanged(int index);\r\n\r\n    void childGraphicsChanged(int index);\r\n\r\nprotected:\r\n\r\n\t//! Handler for widget's show event.\r\n\tvirtual void showEvent(QShowEvent* event);\r\n\r\nprivate:\r\n\r\n\t//! No copying. No assignment.\r\n\tAddressSpaceEditor(const AddressSpaceEditor& other);\r\n\tAddressSpaceEditor& operator=(const AddressSpaceEditor& other);\r\n\r\n    //! Sets the widget layout.\r\n    void setupLayout();\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n\t//! The address space being edited.\r\n\tQSharedPointer<AddressSpace> addrSpace_;\r\n\r\n\t//! The editor to set the name, display name and description.\r\n\tNameGroupEditor nameEditor_;\r\n\r\n\t//! The editor to set the general settings of address space.\r\n\tAddressSpaceGeneralEditor generalEditor_;\r\n\r\n\t//! The editor to set the segments of the address space.\r\n\tSegmentEditor segmentsEditor_;\r\n\r\n\t//! The editor to set the local memory map.\r\n\tLocalMemoryMapEditor localMemMapEditor_;\r\n};\r\n\r\n#endif // ADDRESSSPACEEDITOR_H\r\n"
  },
  {
    "path": "editors/ComponentEditor/addressSpaces/addressspacegeneraleditor.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: addressspacegeneraleditor.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 21.02.2012\r\n//\r\n// Description:\r\n// Editor to set the general settings of an address space.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"addressspacegeneraleditor.h\"\r\n\r\n#include <KactusAPI/include/utils.h>\r\n\r\n#include <editors/ComponentEditor/common/ExpressionEditor.h>\r\n#include <KactusAPI/include/ExpressionParser.h>\r\n#include <KactusAPI/include/ExpressionFormatter.h>\r\n\r\n#include <editors/ComponentEditor/parameters/ComponentParameterModel.h>\r\n\r\n\r\n#include <IPXACTmodels/Component/AddressSpace.h>\r\n\r\n#include <QCompleter>\r\n#include <QIntValidator>\r\n#include <QFormLayout>\r\n#include <QLabel>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressSpaceGeneralEditor::AddressSpaceGeneralEditor()\r\n//-----------------------------------------------------------------------------\r\nAddressSpaceGeneralEditor::AddressSpaceGeneralEditor(QSharedPointer<AddressSpace> addrSpace,\r\n    QStringList busInterfaceNames,\r\n    QSharedPointer<ParameterFinder> parameterFinder,\r\n    QSharedPointer<ExpressionParser> expressionParser,\r\n    Document::Revision docRevision,\r\n    QWidget *parent):\r\nQGroupBox(tr(\"General\"), parent),\r\naddrSpace_(addrSpace),\r\nexpressionParser_(expressionParser),\r\naddrUnitEditor_(this),\r\nrangeEditor_(new ExpressionEditor(parameterFinder, this)),\r\nwidthEditor_(new ExpressionEditor(parameterFinder, this)),\r\nisPresentEditor_(new ExpressionEditor(parameterFinder, this)),\r\ninitiatorInterfaceBindingLabel_(new QLabel(this))\r\n{\r\n\tQ_ASSERT(addrSpace_);\r\n\r\n    addrUnitEditor_.setValidator(new QIntValidator(this));\r\n    addrUnitEditor_.setPlaceholderText(\"8\");\r\n\r\n    rangeEditor_->setFixedHeight(ExpressionEditor::DEFAULT_HEIGHT);\r\n    widthEditor_->setFixedHeight(ExpressionEditor::DEFAULT_HEIGHT);\r\n    isPresentEditor_->setFixedHeight(ExpressionEditor::DEFAULT_HEIGHT);\r\n\r\n\t// Set the back ground colors for mandatory fields.\r\n\twidthEditor_->setProperty(\"mandatoryField\", true);\r\n\trangeEditor_->setProperty(\"mandatoryField\", true);\r\n\r\n    ComponentParameterModel* parameterCompletionModel = new ComponentParameterModel(parameterFinder, this);\r\n    parameterCompletionModel->setExpressionParser(expressionParser);\r\n\r\n    auto rangeEditorCompleter = new QCompleter(this);\r\n    rangeEditorCompleter->setModel(parameterCompletionModel);\r\n\r\n    auto widthEditorCompleter = new QCompleter(this);\r\n    widthEditorCompleter->setModel(parameterCompletionModel);\r\n\r\n    auto isPresentEditorCompleter = new QCompleter(this);\r\n    isPresentEditorCompleter->setModel(parameterCompletionModel);\r\n\r\n    rangeEditor_->setAppendingCompleter(rangeEditorCompleter);\r\n    widthEditor_->setAppendingCompleter(widthEditorCompleter);\r\n    isPresentEditor_->setAppendingCompleter(isPresentEditorCompleter);\r\n\r\n    setupLayout(docRevision);\r\n\r\n\trefresh(busInterfaceNames);\r\n\r\n    connect(&addrUnitEditor_, SIGNAL(editingFinished()), this, SLOT(onAddrUnitChanged()), Qt::UniqueConnection);\r\n    connect(&addrUnitEditor_, SIGNAL(editingFinished()), this, SIGNAL(graphicsChanged()), Qt::UniqueConnection);\r\n\r\n\tconnect(widthEditor_, SIGNAL(editingFinished()), this, SLOT(onWidthChanged()), Qt::UniqueConnection);\r\n    connect(widthEditor_, SIGNAL(editingFinished()), this, SIGNAL(graphicsChanged()), Qt::UniqueConnection);\r\n    \r\n    connect(widthEditor_, SIGNAL(increaseReference(QString)),\r\n        this, SIGNAL(increaseReferences(QString)), Qt::UniqueConnection);\r\n    connect(widthEditor_, SIGNAL(decreaseReference(QString)),\r\n        this, SIGNAL(decreaseReferences(QString)), Qt::UniqueConnection);\r\n\r\n\tconnect(rangeEditor_, SIGNAL(editingFinished()), this, SLOT(onRangeChanged()), Qt::UniqueConnection);\r\n    connect(rangeEditor_, SIGNAL(editingFinished()), this, SIGNAL(graphicsChanged()), Qt::UniqueConnection);\r\n\r\n    connect(rangeEditor_, SIGNAL(increaseReference(QString)),\r\n        this, SIGNAL(increaseReferences(QString)), Qt::UniqueConnection);\r\n    connect(rangeEditor_, SIGNAL(decreaseReference(QString)),\r\n        this, SIGNAL(decreaseReferences(QString)), Qt::UniqueConnection);\r\n\r\n    connect(isPresentEditor_, SIGNAL(editingFinished()), this, SLOT(onIsPresentChanged()), Qt::UniqueConnection);\r\n\r\n    connect(isPresentEditor_, SIGNAL(increaseReference(QString)),\r\n        this, SIGNAL(increaseReferences(QString)), Qt::UniqueConnection);\r\n    connect(isPresentEditor_, SIGNAL(decreaseReference(QString)),\r\n        this, SIGNAL(decreaseReferences(QString)), Qt::UniqueConnection);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressSpaceGeneralEditor::~AddressSpaceGeneralEditor()\r\n//-----------------------------------------------------------------------------\r\nAddressSpaceGeneralEditor::~AddressSpaceGeneralEditor()\r\n{\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressSpaceGeneralEditor::isValid()\r\n//-----------------------------------------------------------------------------\r\nbool AddressSpaceGeneralEditor::isValid() const\r\n{\r\n\treturn !rangeEditor_->getExpression().isEmpty();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressSpaceGeneralEditor::refresh()\r\n//-----------------------------------------------------------------------------\r\nvoid AddressSpaceGeneralEditor::refresh(QStringList masterInterfaceNames)\r\n{\r\n    widthEditor_->blockSignals(true);\r\n    rangeEditor_->blockSignals(true);\r\n    isPresentEditor_->blockSignals(true);\r\n\r\n    addrUnitEditor_.setText(addrSpace_->getAddressUnitBits());\r\n\taddrUnitEditor_.setToolTip(format(addrSpace_->getAddressUnitBits()));\r\n\r\n    widthEditor_->setExpression(addrSpace_->getWidth());\r\n    widthEditor_->setToolTip(format(addrSpace_->getWidth()));\r\n\r\n\trangeEditor_->setExpression(addrSpace_->getRange());\r\n    rangeEditor_->setToolTip(format(addrSpace_->getRange()));\r\n\r\n    isPresentEditor_->setExpression(addrSpace_->getIsPresent());\r\n    isPresentEditor_->setToolTip(format(addrSpace_->getIsPresent()));\r\n\r\n    widthEditor_->blockSignals(false);\r\n    rangeEditor_->blockSignals(false);\r\n    isPresentEditor_->blockSignals(false);\r\n\r\n    if (masterInterfaceNames.isEmpty())\r\n    {\r\n        initiatorInterfaceBindingLabel_->setText(tr(\"No binding\"));\r\n    }\r\n    else\r\n    {\r\n        initiatorInterfaceBindingLabel_->setText(masterInterfaceNames.join(\", \"));\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressSpaceGeneralEditor::onAddrUnitChanged()\r\n//-----------------------------------------------------------------------------\r\nvoid AddressSpaceGeneralEditor::onAddrUnitChanged()\r\n{\r\n    QString newAddressUnitBits = addrUnitEditor_.text();\r\n    addrSpace_->setAddressUnitBits(newAddressUnitBits);\r\n\r\n    addrUnitEditor_.setToolTip(format(newAddressUnitBits));\r\n\r\n    emit assignNewAddressUnitBits(newAddressUnitBits);\r\n\temit contentChanged();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressSpaceGeneralEditor::onWidthChanged()\r\n//-----------------------------------------------------------------------------\r\nvoid AddressSpaceGeneralEditor::onWidthChanged()\r\n{\r\n    widthEditor_->finishEditingCurrentWord();\r\n\r\n    addrSpace_->setWidth(widthEditor_->getExpression());   \r\n    widthEditor_->setToolTip(format(widthEditor_->getExpression()));\r\n\r\n\temit contentChanged();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressSpaceGeneralEditor::onRangeChanged()\r\n//-----------------------------------------------------------------------------\r\nvoid AddressSpaceGeneralEditor::onRangeChanged()\r\n{\r\n    rangeEditor_->finishEditingCurrentWord();\r\n    addrSpace_->setRange(rangeEditor_->getExpression());\r\n    rangeEditor_->setToolTip(format(rangeEditor_->getExpression()));\r\n\r\n\temit contentChanged();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressSpaceGeneralEditor::onIsPresentChanged()\r\n//-----------------------------------------------------------------------------\r\nvoid AddressSpaceGeneralEditor::onIsPresentChanged()\r\n{\r\n    isPresentEditor_->finishEditingCurrentWord();\r\n    addrSpace_->setIsPresent(isPresentEditor_->getExpression());\r\n    isPresentEditor_->setToolTip(format(isPresentEditor_->getExpression()));\r\n\r\n    emit contentChanged();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressSpaceGeneralEditor::setupLayout()\r\n//-----------------------------------------------------------------------------\r\nvoid AddressSpaceGeneralEditor::setupLayout(Document::Revision docRevision)\r\n{\r\n    QVBoxLayout* topLayout = new QVBoxLayout(this);\r\n\r\n    QFormLayout* layout = new QFormLayout();\r\n    layout->addRow(tr(\"Addressable unit bits (AUB):\"), &addrUnitEditor_);\r\n    layout->addRow(tr(\"Range (=size) [AUB], f(x):\"), rangeEditor_);\r\n    layout->addRow(tr(\"Width [bits], f(x):\"), widthEditor_);\r\n\r\n    if (docRevision == Document::Revision::Std22)\r\n    {\r\n        layout->addRow(tr(\"Initiator interface binding(s):\"), initiatorInterfaceBindingLabel_);\r\n        isPresentEditor_->setVisible(false);\r\n    }\r\n    else\r\n    {\r\n        layout->addRow(tr(\"Is present, f(x):\"), isPresentEditor_);\r\n        layout->addRow(tr(\"Master interface binding(s):\"), initiatorInterfaceBindingLabel_);\r\n    }\r\n\r\n    topLayout->addLayout(layout);\r\n    topLayout->addStretch(1); // For initiator/master interface binding label alignment\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressSpaceGeneralEditor::format()\r\n//-----------------------------------------------------------------------------\r\nQString AddressSpaceGeneralEditor::format(QString const& expression) const\r\n{\r\n    return ExpressionFormatter::format(expression, expressionParser_);\r\n}\r\n"
  },
  {
    "path": "editors/ComponentEditor/addressSpaces/addressspacegeneraleditor.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: addressspacegeneraleditor.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 21.02.2012\r\n//\r\n// Description:\r\n// Editor to set the general settings of an address space.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef ADDRESSSPACEGENERALEDITOR_H\r\n#define ADDRESSSPACEGENERALEDITOR_H\r\n\r\n#include <IPXACTmodels/common/Document.h>\r\n\r\n#include <QGroupBox>\r\n#include <QSharedPointer>\r\n#include <QLabel>\r\n#include <QLineEdit>\r\n\r\nclass ExpressionEditor;\r\nclass ExpressionParser;\r\nclass ParameterFinder;\r\nclass AddressSpace;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Editor to set the general settings of an address space.\r\n//-----------------------------------------------------------------------------\r\nclass AddressSpaceGeneralEditor : public QGroupBox\r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\r\n\t/*!\r\n\t *  The constructor.\r\n\t *\r\n\t *    @param [in] addrSpace           The address space being edited.\r\n\t *    @param [in] busInterfaceNames   A list of master interface names bound to this address space.\r\n\t *    @param [in] parameterFinder     The finder for parameters available in expressions.\r\n\t *    @param [in] expressionParser    The expression parser.\r\n\t *    @param [in] docRevision         The standard revision in use.\r\n\t *    @param [in] parent              The owner of the editor.\r\n\t */\r\n\tAddressSpaceGeneralEditor(QSharedPointer<AddressSpace> addrSpace,\r\n        QStringList busInterfaceNames,\r\n        QSharedPointer<ParameterFinder> parameterFinder, \r\n        QSharedPointer<ExpressionParser> expressionParser,\r\n        Document::Revision docRevision,\r\n        QWidget *parent);\r\n\r\n\t//! The destructor.\r\n\tvirtual ~AddressSpaceGeneralEditor();\r\n\r\n    //! No copying. No assignment.\r\n    AddressSpaceGeneralEditor(const AddressSpaceGeneralEditor& other) = delete;\r\n    AddressSpaceGeneralEditor& operator=(const AddressSpaceGeneralEditor& other) = delete;\r\n\r\n\t/*!\r\n     *  Check if the editor is in valid state and can be saved.\r\n\t *\r\n\t *    @return True if everything is ok.\r\n\t */\r\n\tbool isValid() const;\r\n\r\n\t/*!\r\n\t *  Read the settings from the address space model to the editor fields.\r\n\t *\r\n\t *    @param [in] masterInterfaceNames    A list of master interface names bound to this address space.\r\n\t */\r\n\tvoid refresh(QStringList masterInterfaceNames);\r\n\r\nsignals:\r\n\r\n\t//! Emitted when the contents of one of the editor fields changes.\r\n\tvoid contentChanged();\r\n\r\n    //! Emitted when the change in fields should be reflected in the visualization.\r\n    void graphicsChanged();\r\n\r\n\t/*! Emitted when user changes the size of an addressable unit.\r\n\t *\r\n\t *    @param units The new addressable unit size.\r\n\t*/\r\n\tvoid addressableUnitsChanged(int units);\r\n\r\n\t/*! Emitted when user changes the width of a row in address space.\r\n\t *\r\n\t *    @param width The new width of a row.\r\n\t*/\r\n\tvoid widthChanged(int width);\r\n\r\n\t/*! Emitted when user changes the range of an address space.\r\n\t *\r\n\t *    @param range The new range as number of addressable units.\r\n\t*/\r\n\tvoid rangeChanged(QString const& range);\r\n    \r\n    /*!\r\n     *  Increase the amount of references to a parameter with a matching id.\r\n     *\r\n     *    @param [in] id      Id of the parameter, whose references are being increased.\r\n     */\r\n    void increaseReferences(QString id);\r\n\r\n    /*!\r\n     *  Decrease the amount of references to a parameter with a matching id.\r\n     *\r\n     *    @param [in] id      Id of the parameter, whose references are being increased.\r\n     */\r\n    void decreaseReferences(QString id);\r\n\r\n    /*!\r\n     *  Assign new address unit bits for address blocks.\r\n     *\r\n     *    @param [in] newAddressUnitBits  The new address unit bits.\r\n     */\r\n    void assignNewAddressUnitBits(QString const&);\r\n\r\nprivate slots:\r\n\r\n\t//! Handler for changes in addressable unit.\r\n    void onAddrUnitChanged();\r\n\r\n\t//! Handler for changes in width.\r\n    void onWidthChanged();\r\n\r\n\t//! Handler for changes in range.\r\n    void onRangeChanged();\r\n\r\n    //! Handler for changes in range.\r\n    void onIsPresentChanged();\r\n\r\nprivate:\r\n    \r\n    /*!\r\n     *  Set up the layout for the editor.\r\n     */\r\n    void setupLayout(Document::Revision docRevision);\r\n\r\n    /*!\r\n     *  Formats a given expression to human-readable format.\r\n     *\r\n     *    @param [in] expression   The expression to format.\r\n     *\r\n     *    @return The formatted expression.\r\n     */\r\n    QString format(QString const& expression) const;\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! The address space being edited.\r\n    QSharedPointer<AddressSpace> addrSpace_;\r\n\r\n    //! The expression parser to use.\r\n    QSharedPointer<ExpressionParser> expressionParser_;\r\n\r\n\t//! Editor to set the size of an addressable unit.\r\n\tQLineEdit addrUnitEditor_;\r\n\r\n    //! Editor to set the range of the address space.\r\n    ExpressionEditor* rangeEditor_;\r\n\r\n\t//! Editor to set the width of one row in address space.\r\n\tExpressionEditor* widthEditor_;\r\n\r\n    //! Editor to set the is presence property of address space.\r\n    ExpressionEditor* isPresentEditor_;\r\n\r\n    //! Label for the initiator/master interface binding(s).\r\n    QLabel* initiatorInterfaceBindingLabel_;\r\n};\r\n\r\n#endif // ADDRESSSPACEGENERALEDITOR_H\r\n"
  },
  {
    "path": "editors/ComponentEditor/addressSpaces/addressspacesdelegate.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: addressspacesdelegate.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 11.6.2012\r\n//\r\n// Description:\r\n// The delegate that provides editors to edit the address spaces summary.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"addressspacesdelegate.h\"\r\n\r\n#include \"AddressSpaceColumns.h\"\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressSpacesDelegate::AddressSpacesDelegate()\r\n//-----------------------------------------------------------------------------\r\nAddressSpacesDelegate::AddressSpacesDelegate(QAbstractItemModel* completionModel,\r\n    QSharedPointer<ParameterFinder> parameterFinder, QObject *parent):\r\nExpressionDelegate(completionModel, parameterFinder, parent)\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressSpacesDelegate::~AddressSpacesDelegate()\r\n//-----------------------------------------------------------------------------\r\nAddressSpacesDelegate::~AddressSpacesDelegate()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressSpacesDelegate::columnAcceptsExpression()\r\n//-----------------------------------------------------------------------------\r\nbool AddressSpacesDelegate::columnAcceptsExpression(int column) const\r\n{\r\n    return column == AddressSpaceColumns::RANGE || column == AddressSpaceColumns::WIDTH ||\r\n        column == AddressSpaceColumns::IS_PRESENT;        \r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressSpacesDelegate::descriptionColumn()\r\n//-----------------------------------------------------------------------------\r\nint AddressSpacesDelegate::descriptionColumn() const\r\n{\r\n    return AddressSpaceColumns::DESCRIPTION;\r\n}\r\n"
  },
  {
    "path": "editors/ComponentEditor/addressSpaces/addressspacesdelegate.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: addressspacesdelegate.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 11.6.2012\r\n//\r\n// Description:\r\n// The delegate that provides editors to edit the address spaces summary.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef ADDRESSSPACESDELEGATE_H\r\n#define ADDRESSSPACESDELEGATE_H\r\n\r\n#include <editors/ComponentEditor/common/ExpressionDelegate.h>\r\n\r\n#include <QStyledItemDelegate>\r\n#include <QEvent>\r\n\r\n//-----------------------------------------------------------------------------\r\n//! The delegate that provides editors to edit the address spaces summary.\r\n//-----------------------------------------------------------------------------\r\nclass AddressSpacesDelegate : public ExpressionDelegate \r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\r\n    /*!\r\n     *  The constructor.\r\n     *\r\n     *    @param [in] completionModel     Model containing the completions used in expression editor.\r\n     *    @param [in] parameterFinder     The parameter finder to use for for expression editor.\r\n     *    @param [in] parent              The parent object.\r\n     */\r\n\tAddressSpacesDelegate(QAbstractItemModel* completionModel, QSharedPointer<ParameterFinder> parameterFinder,\r\n        QObject *parent);\r\n\t\r\n\t//! The destructor\r\n\tvirtual ~AddressSpacesDelegate();\r\n\r\nprotected:\r\n    \r\n    /*!\r\n     *  Checks if the given column supports expressions in the editor.\r\n     *\r\n     *    @param [in] column   The column to check.\r\n     *\r\n     *    @return True, if the cells in the column allow expressions, otherwise false.\r\n     */\r\n    virtual bool columnAcceptsExpression(int column) const;\r\n\r\n    //! Gets the description column.\r\n    virtual int descriptionColumn() const;\r\n\r\nprivate:\r\n\t//! No copying\r\n\tAddressSpacesDelegate(const AddressSpacesDelegate& other);\r\n\tAddressSpacesDelegate& operator=(const AddressSpacesDelegate& other);\r\n\r\n};\r\n\r\n#endif // ADDRESSSPACESDELEGATE_H\r\n"
  },
  {
    "path": "editors/ComponentEditor/addressSpaces/addressspaceseditor.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: addressspaceseditor.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 11.06.2012\r\n//\r\n// Description:\r\n// The editor to add/remove/edit address spaces of component.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"addressspaceseditor.h\"\r\n#include \"addressspacesdelegate.h\"\r\n\r\n#include \"AddressSpaceColumns.h\"\r\n\r\n#include <common/widgets/summaryLabel/summarylabel.h>\r\n\r\n#include <editors/ComponentEditor/parameters/ComponentParameterModel.h>\r\n#include <editors/ComponentEditor/memoryMaps/ExpressionProxyModel.h>\r\n\r\n#include <KactusAPI/include/LibraryInterface.h>\r\n\r\n#include <IPXACTmodels/Component/Component.h>\r\n\r\n#include <QCompleter>\r\n#include <QVBoxLayout>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressSpacesEditor::AddressSpacesEditor()\r\n//-----------------------------------------------------------------------------\r\nAddressSpacesEditor::AddressSpacesEditor(QSharedPointer<Component> component, LibraryInterface* handler,\r\n                                         QSharedPointer<ParameterFinder> parameterFinder,\r\n                                         QSharedPointer<ExpressionFormatter> expressionFormatter,\r\n                                         QSharedPointer<ExpressionParser> expressionParser,\r\n                                         QSharedPointer<AddressSpaceValidator> addressSpaceValidator):\r\nItemEditor(component, handler),\r\nview_(this),\r\nmodel_(component, parameterFinder, expressionFormatter, addressSpaceValidator, this)\r\n{\r\n    model_.setExpressionParser(expressionParser);\r\n\r\n    ExpressionProxyModel* proxy = new ExpressionProxyModel(expressionParser, this);\r\n    proxy->setColumnToAcceptExpressions(AddressSpaceColumns::RANGE);\r\n    proxy->setColumnToAcceptExpressions(AddressSpaceColumns::WIDTH);\r\n\r\n\tproxy->setSourceModel(&model_);\r\n\r\n\tview_.setModel(proxy);\r\n\r\n\tconst QString compPath = ItemEditor::handler()->getDirectoryPath(ItemEditor::component()->getVlnv());\r\n\tQString defPath = QString(\"%1/addrSpaceList.csv\").arg(compPath);\r\n\tview_.setDefaultImportExportPath(defPath);\r\n\tview_.setAllowImportExport(true);\r\n\r\n\tview_.setItemsDraggable(false);\r\n    view_.setSortingEnabled(true);\r\n    view_.setAllowElementCopying(true);\r\n\r\n    ComponentParameterModel* completionModel = new ComponentParameterModel(parameterFinder, this);\r\n    completionModel->setExpressionParser(expressionParser);\r\n\r\n\r\n    AddressSpacesDelegate* delegate = new AddressSpacesDelegate(completionModel, parameterFinder, this);\r\n \tview_.setItemDelegate(delegate);\r\n    \r\n    // display a label on top the table\r\n    SummaryLabel* summaryLabel = new SummaryLabel(tr(\"Address spaces summary\"), this);\r\n\r\n    QVBoxLayout* layout = new QVBoxLayout(this);\r\n    layout->addWidget(summaryLabel, 0, Qt::AlignCenter);\r\n    layout->addWidget(&view_);\r\n    layout->setContentsMargins(0, 0, 0, 0);\r\n\r\n    if (component->getRevision() == Document::Revision::Std22)\r\n    {\r\n        view_.hideColumn(AddressSpaceColumns::IS_PRESENT);\r\n    }\r\n\r\n\tconnect(&model_, SIGNAL(contentChanged()), this, SIGNAL(contentChanged()), Qt::UniqueConnection);\r\n\t\r\n\tconnect(&model_, SIGNAL(addrSpaceAdded(int)), this, SIGNAL(childAdded(int)), Qt::UniqueConnection);\r\n\tconnect(&model_, SIGNAL(addrSpaceRemoved(int)),\tthis, SIGNAL(childRemoved(int)), Qt::UniqueConnection);\r\n\r\n\tconnect(&view_, SIGNAL(addItem(const QModelIndex&)),\r\n\t\t&model_, SLOT(onAddItem(const QModelIndex&)), Qt::UniqueConnection);\r\n\tconnect(&view_, SIGNAL(removeItem(const QModelIndex&)),\r\n\t\t&model_, SLOT(onRemoveItem(const QModelIndex&)), Qt::UniqueConnection);\r\n\r\n\tconnect(&view_, SIGNAL(doubleClicked(const QModelIndex&)),\r\n\t\tthis, SLOT(onDoubleClick(const QModelIndex&)), Qt::UniqueConnection);\r\n\r\n    connect(delegate, SIGNAL(increaseReferences(QString)), \r\n        this, SIGNAL(increaseReferences(QString)), Qt::UniqueConnection);\r\n    connect(delegate, SIGNAL(decreaseReferences(QString)), \r\n        this, SIGNAL(decreaseReferences(QString)), Qt::UniqueConnection);;\r\n\r\n    connect(&model_, SIGNAL(decreaseReferences(QString)),\r\n        this, SIGNAL(decreaseReferences(QString)), Qt::UniqueConnection);\r\n    connect(&model_, SIGNAL(increaseReferences(QString)),\r\n        this, SIGNAL(increaseReferences(QString)), Qt::UniqueConnection);\r\n\r\n    connect(&view_, SIGNAL(copyRows(QModelIndexList)),\r\n        &model_, SLOT(onCopyRows(QModelIndexList)), Qt::UniqueConnection);\r\n    connect(&view_, SIGNAL(pasteRows()), &model_, SLOT(onPasteRows()), Qt::UniqueConnection);\r\n\r\n    connect(&model_, SIGNAL(aubChangedOnRow(int)), this, SIGNAL(aubChangedOnRow(int)), Qt::UniqueConnection);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressSpacesEditor::~AddressSpacesEditor()\r\n//-----------------------------------------------------------------------------\r\nAddressSpacesEditor::~AddressSpacesEditor()\r\n{\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressSpacesEditor::refresh()\r\n//-----------------------------------------------------------------------------\r\nvoid AddressSpacesEditor::refresh()\r\n{\r\n\tview_.update();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressSpacesEditor::showEvent()\r\n//-----------------------------------------------------------------------------\r\nvoid AddressSpacesEditor::showEvent(QShowEvent* event)\r\n{\r\n\tQWidget::showEvent(event);\r\n\r\n    if (component()->getRevision() == Document::Revision::Std22)\r\n    {\r\n        emit helpUrlRequested(\"componenteditor/addressspaces2022.html\");\r\n    }\r\n    else\r\n    {\r\n\t    emit helpUrlRequested(\"componenteditor/addressspaces.html\");\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressSpacesEditor::onDoubleClick()\r\n//-----------------------------------------------------------------------------\r\nvoid AddressSpacesEditor::onDoubleClick(QModelIndex const& index)\r\n{\r\n\t// if the column is for interface references\r\n\tif (index.isValid() && index.column() == AddressSpaceColumns::INTERFACE_BINDING)\r\n    {\r\n\t\t// get the names of the interface that refer to selected memory map\r\n\t\tQStringList busIfNames = index.data(Qt::UserRole).toStringList();\r\n\r\n\t\t// if there is exactly one bus interface\r\n        // inform component editor that bus interface editor should be selected\r\n        if (busIfNames.size() == 1)\r\n        {\r\n\t\t    emit selectBusInterface(busIfNames.first());\r\n\t\t}\r\n\t}\r\n}\r\n"
  },
  {
    "path": "editors/ComponentEditor/addressSpaces/addressspaceseditor.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: addressspaceseditor.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 11.06.2012\r\n//\r\n// Description:\r\n// The editor to add/remove/edit address spaces of component.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef ADDRESSSPACESEDITOR_H\r\n#define ADDRESSSPACESEDITOR_H\r\n\r\n#include \"addressspacesmodel.h\"\r\n\r\n#include <common/views/EditableTableView/editabletableview.h>\r\n#include <editors/ComponentEditor/itemeditor.h>\r\n\r\n#include <QSortFilterProxyModel>\r\n\r\nclass LibraryInterface;\r\nclass Component;\r\n\r\nclass AddressSpaceValidator;\r\n//-----------------------------------------------------------------------------\r\n//! The editor to add/remove/edit address spaces of component.\r\n//-----------------------------------------------------------------------------\r\nclass AddressSpacesEditor : public ItemEditor\r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\r\n\t/*!\r\n     *  The constructor\r\n\t *\r\n\t *    @param [in] component               The component being edited.\r\n\t *    @param [in] handler                 The instance managing the library.\r\n     *    @param [in] parameterFinder         Finder for parameter names.\r\n     *    @param [in] expressionFormatter     Formatter for expressions.\r\n     *    @param [in] expressionParser        The expression parser to use.\r\n     *    @param [in] addressSpaceValidator   Validator used for address spaces.\r\n\t */\r\n\tAddressSpacesEditor(QSharedPointer<Component> component,\r\n\t\t LibraryInterface* handler,\r\n         QSharedPointer<ParameterFinder> parameterFinder,\r\n         QSharedPointer<ExpressionFormatter> expressionFormatter,\r\n         QSharedPointer<ExpressionParser> expressionParser,\r\n         QSharedPointer<AddressSpaceValidator> addressSpaceValidator);\r\n\t\r\n\t//! The destructor\r\n\t~AddressSpacesEditor();\r\n\r\n\t/*!\r\n     *  Reload the information from the model to the editor.\r\n\t */\r\n\tvirtual void refresh();\r\n\r\nsignals:\r\n\r\n\t//! Emitted when a bus interface editor should be opened.\r\n\tvoid selectBusInterface(const QString& interfaceName);\r\n\r\n    /*!\r\n     *  Emitted when address unit bits change on the given row.\r\n     *\r\n     *    @param [in] spaceIndex  The index of the address space where address unit bits were changed.\r\n     */\r\n    void aubChangedOnRow(int spaceIndex) const;\r\n\r\nprotected:\r\n\r\n\t//! Handler for widget's show event\r\n\tvirtual void showEvent(QShowEvent* event);\r\n\r\nprivate slots:\r\n\r\n    //! Handler for view's doubleClicked-signal.\r\n    virtual void onDoubleClick(const QModelIndex& index);\r\n\r\nprivate:\r\n\t\r\n\t//! No copying.\r\n\tAddressSpacesEditor(const AddressSpacesEditor& other);\r\n\tAddressSpacesEditor& operator=(const AddressSpacesEditor& other);\r\n\r\n\t//! The view to display the address spaces.\r\n\tEditableTableView view_;\r\n\r\n\t//! The model that manages the file set objects for the view.\r\n\tAddressSpacesModel model_;\r\n};\r\n\r\n#endif // ADDRESSSPACESEDITOR_H\r\n"
  },
  {
    "path": "editors/ComponentEditor/addressSpaces/addressspacesmodel.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: addressspacesmodel.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 11.06.2012\r\n//\r\n// Description:\r\n// The model class to manage the objects for address spaces editor.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"addressspacesmodel.h\"\r\n\r\n#include \"AddressSpaceColumns.h\"\r\n\r\n#include <KactusAPI/include/ExpressionFormatter.h>\r\n\r\n#include <KactusAPI/include/AddressSpaceExpressionsGatherer.h>\r\n#include <editors/ComponentEditor/memoryMaps/memoryMapsExpressionCalculators/ReferenceCalculator.h>\r\n\r\n#include <IPXACTmodels/Component/Component.h>\r\n#include <IPXACTmodels/Component/AddressSpace.h>\r\n#include <IPXACTmodels/Component/validators/AddressSpaceValidator.h>\r\n\r\n#include <common/KactusColors.h>\r\n\r\n\r\n#include <QRegularExpression>\r\n#include <QApplication>\r\n#include <QClipboard>\r\n#include <QMimeData>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressSpacesModel::AddressSpacesModel()\r\n//-----------------------------------------------------------------------------\r\nAddressSpacesModel::AddressSpacesModel(QSharedPointer<Component> component,\r\n                                       QSharedPointer<ParameterFinder> parameterFinder,\r\n                                       QSharedPointer<ExpressionFormatter> expressionFormatter,\r\n                                       QSharedPointer<AddressSpaceValidator> addressSpaceValidator,\r\n                                       QObject *parent):\r\nReferencingTableModel(parameterFinder, parent),\r\nParameterizableTable(parameterFinder),\r\ncomponent_(component),\r\naddressSpaces_(component->getAddressSpaces()),\r\nexpressionFormatter_(expressionFormatter),\r\naddressSpaceValidator_(addressSpaceValidator)\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressSpacesModel::~AddressSpacesModel()\r\n//-----------------------------------------------------------------------------\r\nAddressSpacesModel::~AddressSpacesModel()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressSpacesModel::rowCount()\r\n//-----------------------------------------------------------------------------\r\nint AddressSpacesModel::rowCount(QModelIndex const& parent) const\r\n{\r\n\tif (parent.isValid())\r\n    {\r\n\t\treturn 0;\r\n\t}\r\n\treturn addressSpaces_->size();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressSpacesModel::columnCount()\r\n//-----------------------------------------------------------------------------\r\nint AddressSpacesModel::columnCount(QModelIndex const& parent) const\r\n{\r\n\tif (parent.isValid())\r\n    {\r\n\t\treturn 0;\r\n\t}\r\n\r\n\treturn AddressSpaceColumns::COLUMN_COUNT;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressSpacesModel::rowCount()\r\n//-----------------------------------------------------------------------------\r\nQt::ItemFlags AddressSpacesModel::flags(QModelIndex const& index ) const\r\n{\r\n\tif (!index.isValid())\r\n    {\r\n\t\treturn Qt::NoItemFlags;\r\n\t}\r\n\t// interface references are made in bus interface editor\r\n\tif (index.column() == AddressSpaceColumns::INTERFACE_BINDING)\r\n    {\r\n\t\treturn Qt::ItemIsSelectable | Qt::ItemIsEnabled;\r\n\t}\r\n\r\n\treturn Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsEditable;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressSpacesModel::headerData()\r\n//-----------------------------------------------------------------------------\r\nQVariant AddressSpacesModel::headerData( int section, Qt::Orientation orientation, int role) const\r\n{\r\n\tif (orientation != Qt::Horizontal)\r\n    {\r\n\t\treturn QVariant();\r\n\t}\r\n\tif (Qt::DisplayRole == role) \r\n    {\r\n        if (section == AddressSpaceColumns::NAME)\r\n        {\r\n            return tr(\"Name\");\r\n        }\r\n        else if (section == AddressSpaceColumns::AUB)\r\n        {\r\n            return tr(\"Addressable\\nunit bits (AUB)\");\r\n        }\r\n        else if (section == AddressSpaceColumns::RANGE)\r\n        {\r\n            return tr(\"Range\\n[AUB]\") + getExpressionSymbol();\r\n        }\r\n        else if (section == AddressSpaceColumns::WIDTH)\r\n        {\r\n            return tr(\"Width\\n [bits]\") + getExpressionSymbol();\r\n        }\r\n        else if (section == AddressSpaceColumns::IS_PRESENT)\r\n        {\r\n            return tr(\"Is present\") + getExpressionSymbol();\r\n        }\r\n        else if (section == AddressSpaceColumns::INTERFACE_BINDING)\r\n        {\r\n            if (component_->getRevision() == Document::Revision::Std22)\r\n            {\r\n                return tr(\"Initiator interface\\nbinding(s)\");\r\n            }\r\n            return tr(\"Master interface\\nbinding(s)\");\r\n        }\r\n        else if (section == AddressSpaceColumns::DESCRIPTION)\r\n        {\r\n            return tr(\"Description\");\r\n        }\r\n        else\r\n        {\r\n            return QVariant();\r\n        }\r\n\t}\r\n\telse\r\n    {\r\n\t\treturn QVariant();\r\n\t}\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressSpacesModel::data()\r\n//-----------------------------------------------------------------------------\r\nQVariant AddressSpacesModel::data(QModelIndex const& index, int role) const\r\n{\r\n\tif (!index.isValid() || index.row() < 0 || index.row() >= addressSpaces_->size())\r\n    {\r\n\t\treturn QVariant();\r\n\t}\r\n\r\n\tif (role == Qt::DisplayRole) \r\n    {\r\n        if (isValidExpressionColumn(index))\r\n        {\r\n            return expressionFormatter_->formatReferringExpression(expressionOrValueForIndex(index).toString());\r\n        }\r\n        else if (index.column() == AddressSpaceColumns::DESCRIPTION)\r\n        {\r\n            return expressionOrValueForIndex(index).toString().replace(QRegularExpression(\"\\n.*$\", \r\n                QRegularExpression::DotMatchesEverythingOption), \"...\");\r\n        }\r\n        return expressionOrValueForIndex(index);\r\n\t}\r\n    else if (role == Qt::EditRole)\r\n    {\r\n        if (index.column() == AddressSpaceColumns::DESCRIPTION)\r\n        {\r\n            return expressionOrValueForIndex(index);\r\n        }\r\n\r\n        return expressionOrValueForIndex(index);  \r\n    }\r\n\telse if (Qt::UserRole == role)\r\n    {\r\n\t\treturn component_->getInitiatorInterfaces(addressSpaces_->at(index.row())->name());\r\n\t}\r\n\telse if (Qt::ForegroundRole == role)\r\n    {\r\n        if (index.column() == AddressSpaceColumns::INTERFACE_BINDING)\r\n        {\r\n            return KactusColors::DISABLED_TEXT;\r\n        }\r\n        \r\n        return blackForValidOrRedForInvalidIndex(index);\r\n    }\r\n    else if (Qt::BackgroundRole == role)\r\n    {\r\n        if (index.column() == AddressSpaceColumns::NAME || index.column() ==  AddressSpaceColumns::AUB ||\r\n            index.column() ==  AddressSpaceColumns::WIDTH || index.column() ==  AddressSpaceColumns::RANGE)\r\n        {\r\n            return KactusColors::MANDATORY_FIELD;\r\n        }\r\n        else\r\n        {\r\n            return KactusColors::REGULAR_FIELD;\r\n        }\r\n    }\r\n    else if (role == Qt::ToolTipRole)\r\n    {\r\n        if (isValidExpressionColumn(index))\r\n        {\r\n            return formattedValueFor(expressionOrValueForIndex(index).toString());\r\n        }\r\n\r\n        return expressionOrValueForIndex(index);        \r\n    }\r\n    else\r\n    {\r\n        return QVariant();\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressSpacesModel::setData()\r\n//-----------------------------------------------------------------------------\r\nbool AddressSpacesModel::setData(QModelIndex const& index, QVariant const& value, int role)\r\n{\r\n\tif (!index.isValid() || index.row() < 0 || index.row() >= addressSpaces_->size())\r\n    {\r\n\t\treturn false;\r\n\t}\r\n\r\n\tif (Qt::EditRole == role)\r\n    {\r\n        if (index.column() == AddressSpaceColumns::NAME)\r\n        {\r\n            addressSpaces_->at(index.row())->setName(value.toString());\r\n        }\r\n        else if (index.column() == AddressSpaceColumns::AUB)\r\n        {\r\n            addressSpaces_->at(index.row())->setAddressUnitBits(value.toString());\r\n            emit aubChangedOnRow(index.row());\r\n        }\r\n        else if (index.column() == AddressSpaceColumns::WIDTH)\r\n        {\r\n            addressSpaces_->at(index.row())->setWidth(value.toString());\r\n        }\r\n        else if (index.column() == AddressSpaceColumns::RANGE)\r\n        {\r\n            addressSpaces_->at(index.row())->setRange(value.toString());\r\n        }\r\n        else if (index.column() == AddressSpaceColumns::IS_PRESENT)\r\n        {\r\n            addressSpaces_->at(index.row())->setIsPresent(value.toString());\r\n        }\r\n        else if (index.column() == AddressSpaceColumns::DESCRIPTION)\r\n        {\r\n            addressSpaces_->at(index.row())->setDescription(value.toString());\r\n        }\r\n        else\r\n        {\r\n            return false;\r\n        }\r\n\r\n\t\temit dataChanged(index, index);\r\n\t\temit contentChanged();\r\n\t\treturn true;\r\n\t}\r\n\telse\r\n    {\r\n\t\treturn false;\r\n\t}\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressSpacesModel::onAddItem()\r\n//-----------------------------------------------------------------------------\r\nvoid AddressSpacesModel::onAddItem(QModelIndex const& index )\r\n{\r\n\tint row = addressSpaces_->size();\r\n\r\n\t// if the index is valid then add the item to the correct position\r\n\tif (index.isValid())\r\n    {\r\n\t\trow = index.row();\r\n\t}\r\n\r\n\tbeginInsertRows(QModelIndex(), row, row);\r\n\taddressSpaces_->insert(row, QSharedPointer<AddressSpace>(new AddressSpace()));\r\n\tendInsertRows();\r\n\r\n\t// inform navigation tree that file set is added\r\n\temit addrSpaceAdded(row);\r\n\r\n\t// tell also parent widget that contents have been changed\r\n\temit contentChanged();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressSpacesModel::onRemoveItem()\r\n//-----------------------------------------------------------------------------\r\nvoid AddressSpacesModel::onRemoveItem(QModelIndex const& index )\r\n{\r\n\t// don't remove anything if index is invalid\r\n\tif (!index.isValid() || index.row() < 0 || index.row() >= addressSpaces_->size())\r\n    {\r\n\t\treturn;\r\n\t}\r\n\r\n    decreaseReferencesWithRemovedAddressSpace(addressSpaces_->at(index.row()));\r\n\r\n\t// remove the specified item\r\n\tbeginRemoveRows(QModelIndex(), index.row(), index.row());\r\n\taddressSpaces_->removeAt(index.row());\r\n\tendRemoveRows();\r\n\r\n\t// inform navigation tree that file set has been removed\r\n\temit addrSpaceRemoved(index.row());\r\n\r\n\t// tell also parent widget that contents have been changed\r\n\temit contentChanged();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressSpacesModel::isValidExpressionColumn()\r\n//-----------------------------------------------------------------------------\r\nbool AddressSpacesModel::isValidExpressionColumn(QModelIndex const& index) const\r\n{\r\n    return index.column() == AddressSpaceColumns::WIDTH || index.column() == AddressSpaceColumns::RANGE ||\r\n        index.column() == AddressSpaceColumns::IS_PRESENT;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressSpacesModel::expressionOrValueForIndex()\r\n//-----------------------------------------------------------------------------\r\nQVariant AddressSpacesModel::expressionOrValueForIndex(QModelIndex const& index) const\r\n{\r\n    if (index.column() == AddressSpaceColumns::NAME)\r\n    {\r\n        return addressSpaces_->at(index.row())->name();\r\n    }\r\n    else if (index.column() == AddressSpaceColumns::AUB)\r\n    {\r\n        return addressSpaces_->at(index.row())->getAddressUnitBits();\r\n    }\r\n    else if (index.column() == AddressSpaceColumns::WIDTH)\r\n    {\r\n        return addressSpaces_->at(index.row())->getWidth();\r\n    }\r\n    else if (index.column() == AddressSpaceColumns::RANGE)\r\n    {\r\n        return addressSpaces_->at(index.row())->getRange();\r\n    }\r\n    else if (index.column() == AddressSpaceColumns::IS_PRESENT)\r\n    {\r\n        return addressSpaces_->at(index.row())->getIsPresent();\r\n    }\r\n    else if (index.column() == AddressSpaceColumns::INTERFACE_BINDING)\r\n    {\r\n        QStringList interfaceNames = component_->getInitiatorInterfaces(addressSpaces_->at(index.row())->name());\r\n\r\n        // if no interface refers to the address space\r\n        if (interfaceNames.isEmpty())\r\n        {\r\n            return tr(\"No binding\");\r\n        }\r\n        // if there are then show them separated by space\r\n        else\r\n        {\r\n            return interfaceNames.join(\", \");\r\n        }\r\n    }\r\n    else if (index.column() == AddressSpaceColumns::DESCRIPTION)\r\n    {\r\n        return addressSpaces_->at(index.row())->description();\r\n    }\r\n    else\r\n    {\r\n        return QVariant();\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressSpacesModel::validateIndex()\r\n//-----------------------------------------------------------------------------\r\nbool AddressSpacesModel::validateIndex(QModelIndex const& index) const\r\n{\r\n    QSharedPointer<AddressSpace> currentSpace = addressSpaces_->at(index.row());\r\n\r\n    if (index.column() == AddressSpaceColumns::NAME)\r\n    {\r\n        return addressSpaceValidator_->hasValidName(currentSpace->name());\r\n    }\r\n    else if (index.column() == AddressSpaceColumns::AUB)\r\n    {\r\n        return addressSpaceValidator_->hasValidAddressUnitBits(currentSpace);\r\n    }\r\n    else if (index.column() == AddressSpaceColumns::RANGE)\r\n    {\r\n        return addressSpaceValidator_->hasValidRange(currentSpace);\r\n    }\r\n    else if (index.column() == AddressSpaceColumns::WIDTH)\r\n    {\r\n        return addressSpaceValidator_->hasValidWidth(currentSpace);\r\n    }\r\n    else if (index.column() == AddressSpaceColumns::IS_PRESENT)\r\n    {\r\n        return addressSpaceValidator_->hasValidIsPresent(currentSpace->getIsPresent());\r\n    }\r\n    else\r\n    {\r\n        return true;\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressSpacesModel::getAllReferencesToIdInItemOnRow()\r\n//-----------------------------------------------------------------------------\r\nint AddressSpacesModel::getAllReferencesToIdInItemOnRow(const int& row, QString const& valueID) const\r\n{\r\n    int referencesInRange = addressSpaces_->at(row)->getRange().count(valueID);\r\n    int referencesInWidth = addressSpaces_->at(row)->getWidth().count(valueID);\r\n    int referencesInPresence = addressSpaces_->at(row)->getIsPresent().count(valueID);\r\n\r\n    return referencesInRange + referencesInWidth + referencesInPresence;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: addressspacesmodel::decreaseReferencesWithRemovedAddressSpace()\r\n//-----------------------------------------------------------------------------\r\nvoid AddressSpacesModel::decreaseReferencesWithRemovedAddressSpace(\r\n    QSharedPointer<AddressSpace> removedAddressSpace)\r\n{\r\n    AddressSpaceExpressionGatherer addressSpaceGatherer;\r\n\r\n    QStringList expressionList = addressSpaceGatherer.getExpressions(removedAddressSpace);\r\n\r\n    ReferenceCalculator addressSpaceReferenceCalculator(getParameterFinder());\r\n\r\n    QMap<QString, int> referencedParameters = addressSpaceReferenceCalculator.getReferencedParameters(\r\n        expressionList);\r\n\r\n    foreach (QString referencedId, referencedParameters.keys())\r\n    {\r\n        for (int i = 0 ; i < referencedParameters.value(referencedId); ++i)\r\n        {\r\n            emit decreaseReferences(referencedId);\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressSpacesModel::onCopyRows()\r\n//-----------------------------------------------------------------------------\r\nvoid AddressSpacesModel::onCopyRows(QModelIndexList indexList)\r\n{\r\n    QList<QSharedPointer<AddressSpace> > copiedSpaces;\r\n    foreach (QModelIndex index, indexList)\r\n    {\r\n        QSharedPointer<AddressSpace> space = addressSpaces_->at(index.row());\r\n        copiedSpaces.append(space);\r\n    }\r\n\r\n    QVariant addressSpaceVariant;\r\n    addressSpaceVariant.setValue(copiedSpaces);\r\n\r\n    QMimeData* newMimeData = new QMimeData();\r\n    newMimeData->setData(\"text/xml/ipxact:addressSpace\", QByteArray());\r\n    newMimeData->setImageData(addressSpaceVariant);\r\n\r\n    QApplication::clipboard()->setMimeData(newMimeData);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressSpacesModel::onPasteRows()\r\n//-----------------------------------------------------------------------------\r\nvoid AddressSpacesModel::onPasteRows()\r\n{\r\n    const QMimeData* pasteData = QApplication::clipboard()->mimeData();\r\n\r\n    if (pasteData->hasImage())\r\n    {\r\n        QVariant pasteVariant = pasteData->imageData();\r\n        if (pasteVariant.canConvert<QList<QSharedPointer<AddressSpace> > >())\r\n        {\r\n            AddressSpaceExpressionGatherer gatherer;\r\n            ReferenceCalculator referenceCalculator(getParameterFinder());\r\n\r\n            QList<QSharedPointer<AddressSpace> > newAddressSpaces =\r\n                pasteVariant.value<QList<QSharedPointer<AddressSpace> > >();\r\n\r\n            int rowBegin = addressSpaces_->size();\r\n            int rowEnd = rowBegin + newAddressSpaces.size() - 1;\r\n\r\n            beginInsertRows(QModelIndex(), rowBegin, rowEnd);\r\n\r\n            foreach(QSharedPointer<AddressSpace> copySpace, newAddressSpaces)\r\n            {\r\n                QSharedPointer<AddressSpace> newSpace (new AddressSpace(*copySpace.data()));\r\n                newSpace->setName(getUniqueName(newSpace->name(), getCurrentItemNames()));\r\n                \r\n                addressSpaces_->append(newSpace);\r\n                \r\n                increaseReferencesInPastedAddressSpace(newSpace, gatherer, referenceCalculator);\r\n                \r\n                emit addrSpaceAdded(rowBegin);\r\n            }\r\n\r\n            endInsertRows();\r\n\r\n            emit contentChanged();\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressSpacesModel::getCurrentItemNames()\r\n//-----------------------------------------------------------------------------\r\nQStringList AddressSpacesModel::getCurrentItemNames()\r\n{\r\n    QStringList names;\r\n    foreach (QSharedPointer<AddressSpace> space, *addressSpaces_)\r\n    {\r\n        names.append(space->name());\r\n    }\r\n\r\n    return names;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressSpacesModel::increaseReferencesInPastedAddressBlock()\r\n//-----------------------------------------------------------------------------\r\nvoid AddressSpacesModel::increaseReferencesInPastedAddressSpace(QSharedPointer<AddressSpace> pastedSpace,\r\n    AddressSpaceExpressionGatherer& gatherer, ReferenceCalculator& referenceCalculator)\r\n{\r\n    QStringList spaceExpressions = gatherer.getExpressions(pastedSpace);\r\n\r\n    QMap<QString, int> referencedParameters = referenceCalculator.getReferencedParameters(spaceExpressions);\r\n\r\n    QMapIterator<QString, int> refParameterIterator (referencedParameters);\r\n    while (refParameterIterator.hasNext())\r\n    {\r\n        refParameterIterator.next();\r\n        for (int i = 0; i < refParameterIterator.value(); ++i)\r\n        {\r\n            emit increaseReferences(refParameterIterator.key());\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressSpacesModel::mimeTypes()\r\n//-----------------------------------------------------------------------------\r\nQStringList AddressSpacesModel::mimeTypes() const\r\n{\r\n    QStringList types(QAbstractItemModel::mimeTypes());\r\n\r\n    types << \"text/xml/ipxact:addressSpace\";\r\n\r\n    return types;\r\n}\r\n"
  },
  {
    "path": "editors/ComponentEditor/addressSpaces/addressspacesmodel.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: addressspacesmodel.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 11.06.2012\r\n//\r\n// Description:\r\n// The model class to manage the objects for address spaces editor.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef ADDRESSSPACESMODEL_H\r\n#define ADDRESSSPACESMODEL_H\r\n\r\n#include <editors/ComponentEditor/common/ParameterizableTable.h>\r\n#include <editors/ComponentEditor/common/ReferencingTableModel.h>\r\n\r\n#include <QSharedPointer>\r\n\r\nclass ExpressionFormatter;\r\nclass Component;\r\nclass AddressSpace;\r\nclass AddressSpaceValidator;\r\nclass AddressSpaceExpressionGatherer;\r\nclass ReferenceCalculator;\r\n//-----------------------------------------------------------------------------\r\n//! The model class to manage the objects for address spaces editor.\r\n//-----------------------------------------------------------------------------\r\nclass AddressSpacesModel : public ReferencingTableModel, public ParameterizableTable\r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\r\n   /*!\r\n    *   The constructor.\r\n    *\r\n    *    @param [in] component               The component being edited.\r\n    *    @param [in] parameterFinder         The finder for available parameter names.\r\n    *    @param [in] expressionFormatter     Formatter for expressions.\r\n    *    @param [in] addressSpaceValidator   Validator used for address spaces.\r\n    *    @param [in] parent                  The owner of the model.\r\n\t*/\r\n\tAddressSpacesModel(QSharedPointer<Component> component,\r\n        QSharedPointer<ParameterFinder> parameterFinder,\r\n        QSharedPointer<ExpressionFormatter> expressionFormatter,\r\n        QSharedPointer<AddressSpaceValidator> addressSpaceValidator,\r\n\t\tQObject *parent);\r\n\t\r\n\t//! The destructor.\r\n\tvirtual ~AddressSpacesModel();\r\n\r\n\t/*!\r\n     *  Get the number of rows an item contains.\r\n\t *\r\n\t *    @param [in] parent Identifies the parent that's row count is requested.\r\n\t *\r\n\t *    @return Number of rows the item has.\r\n\t */\r\n\tvirtual int rowCount(const QModelIndex& parent = QModelIndex()) const;\r\n\r\n\t/*!\r\n     *  Get the number of columns the item has to be displayed.\r\n\t *\r\n\t *    @param [in] parent Identifies the parent that's column count is requested.\r\n\t *\r\n\t *    @return The number of columns to be displayed.\r\n\t */\r\n\tvirtual int columnCount(const QModelIndex& parent = QModelIndex()) const;\r\n\r\n\t/*!\r\n     *  Get the item flags that defines the possible operations for the item.\r\n\t *\r\n\t *    @param [in] index Model index that identifies the item.\r\n\t *\r\n\t *    @return Qt::ItemFlags specify the possible operations for the item.\r\n\t */\r\n\tQt::ItemFlags flags(const QModelIndex& index) const;\r\n\r\n\t/*!\r\n     *  Get the header data for specified header.\r\n\t *\r\n\t *    @param [in] section The section specifies the row/column number for the header.\r\n\t *    @param [in] orientation Specified if horizontal or vertical header is wanted.\r\n\t *    @param [in] role Specifies the type of the requested data.\r\n\t *\r\n\t *    @return QVariant Contains the requested data.\r\n\t */\r\n\tvirtual QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;\r\n\r\n\t/*!\r\n     *  Get the data for specified item.\r\n\t *\r\n\t *    @param [in] index Specifies the item that's data is requested.\r\n\t *    @param [in] role The role that defines what kind of data is requested.\r\n\t *\r\n\t *    @return QVariant Contains the data for the item.\r\n\t */\r\n\tvirtual QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const;\r\n\r\n\t/*!\r\n     *  Save the data to the model for specified item\r\n\t *\r\n\t *    @param [in] index The model index of the item that's data is to be saved.\r\n\t *    @param [in] value The data that is to be saved.\r\n\t *    @param [in] role The role specifies what kind of data should be saved.\r\n\t *\r\n\t *    @return True if saving happened successfully.\r\n\t */\r\n\tbool setData(const QModelIndex& index, const QVariant& value, int role = Qt::EditRole);\r\n\r\n    /*!\r\n     *  Get the list of acceptable mime types.\r\n     *\r\n     *    @return The list of acceptable mime types.\r\n     */\r\n    virtual QStringList mimeTypes() const;\r\n\r\npublic slots:\r\n\r\n\t/*!\r\n     *  Add a new item to the given index.\r\n\t *\r\n\t *    @param [in] index The index identifying the position for new item.\r\n\t */\r\n\tvirtual void onAddItem(const QModelIndex& index);\r\n\r\n\t/*!\r\n     *  Remove the item in the given index.\r\n\t *\r\n\t *    @param [in] index The index identifying the item to remove.\r\n\t */\r\n\tvirtual void onRemoveItem(const QModelIndex& index);\r\n    \r\n    /*!\r\n     *  Copy the items in the selected rows.\r\n     *\r\n     *    @param [in] indexList   List of indexes pointing to the selected rows.\r\n     */\r\n    void onCopyRows(QModelIndexList indexList);\r\n\r\n    /*!\r\n     *  Paste the copied items.\r\n     */\r\n    void onPasteRows();\r\n\r\nsignals:\r\n\r\n\t//! Emitted when the contents of the model change.\r\n\tvoid contentChanged();\r\n\r\n\t/*!\r\n     *  Emitted when a new file set is added to the model.\r\n\t *\r\n\t *    @param [in] index The index of the added file set.\r\n\t */\r\n\tvoid addrSpaceAdded(int index);\r\n\r\n\t/*!\r\n     *  Emitted when a file set is removed from the model.\r\n\t *\r\n\t *    @param [in] index The index of the remove file set.\r\n\t */\r\n\tvoid addrSpaceRemoved(int index);\r\n\r\n    /*!\r\n     *  Emitted when address unit bits are changed in an address space.\r\n     *\r\n     *    @param [in] addressSpaceindex   Index of the target address space.\r\n     */\r\n    void aubChangedOnRow(int addressSpaceindex);\r\n\r\nprotected:\r\n    \r\n    /*!\r\n     *  Check if the column index is valid for containing expressions.\r\n     *\r\n     *    @param [in] index   The index being evaluated.\r\n     *\r\n     *    @return     True, if column can have expressions, false otherwise.\r\n     */\r\n    virtual bool isValidExpressionColumn(QModelIndex const& index) const;\r\n\r\n    /*!\r\n     *  Gets the expression for the given index or the plain value if expression is not available.\r\n     *\r\n     *    @param [in] index   The index whose expression to get.\r\n     *\r\n     *    @return The expression for the index if available, otherwise the value for the given index.\r\n     */\r\n    virtual QVariant expressionOrValueForIndex(QModelIndex const& index) const;\r\n    \r\n    /*!\r\n     *  Validates the data in an index.\r\n     *\r\n     *    @param [in] index   The index whose data to validate\r\n     *\r\n     *    @return True, if the data in the index is valid, otherwise false.\r\n     */\r\n    virtual bool validateIndex(QModelIndex const& index) const;\r\n\r\n    /*!\r\n     *  Gets the number of all the references made to a selected id on the selected row.\r\n     *\r\n     *    @param [in] row         The row of the selected item.\r\n     *    @param [in] valueID     The id of the referenced parameter.\r\n     *\r\n     *    @return The amount of references made to the selected id on the selected row.\r\n     */\r\n    virtual int getAllReferencesToIdInItemOnRow(const int& row, QString const& valueID) const;\r\n\r\nprivate:\r\n\t\r\n    /*!\r\n     *  Decrease the number of references made from a removed address space.\r\n     *\r\n     *    @param [in] removedAddressSpace     The removed address space.\r\n     */\r\n    void decreaseReferencesWithRemovedAddressSpace(QSharedPointer<AddressSpace> removedAddressSpace);\r\n    \r\n    /*!\r\n     *  Get the names of the contained address blocks.\r\n     *\r\n     *    @return The names of the contained address blocks.\r\n     */\r\n    QStringList getCurrentItemNames();\r\n\r\n    /*!\r\n     *  Increase the number of references made in the copied address space.\r\n     *\r\n     *    @param [in] pastedSpace             The copied address space.\r\n     *    @param [in] gatherer                Address space expressions gatherer.\r\n     *    @param [in] referenceCalculator     The reference calculator.\r\n     */\r\n    void increaseReferencesInPastedAddressSpace(QSharedPointer<AddressSpace> pastedSpace,\r\n        AddressSpaceExpressionGatherer& gatherer, ReferenceCalculator& referenceCalculator);\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n\t//! No copying\r\n\tAddressSpacesModel(const AddressSpacesModel& other);\r\n\tAddressSpacesModel& operator=(const AddressSpacesModel& other);\r\n\r\n\t//! Pointer to the component being edited.\r\n\tQSharedPointer<Component> component_;\r\n\r\n\t//! Contains the address spaces to edit.\r\n    QSharedPointer<QList<QSharedPointer<AddressSpace> > > addressSpaces_;\r\n\r\n    //! Expression formatter.\r\n    QSharedPointer<ExpressionFormatter> expressionFormatter_;\r\n\r\n    //! The used address space validator.\r\n    QSharedPointer<AddressSpaceValidator> addressSpaceValidator_;\r\n};\r\n\r\n#endif // ADDRESSSPACESMODEL_H\r\n"
  },
  {
    "path": "editors/ComponentEditor/addressSpaces/localMemoryMap/localmemorymapeditor.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: localmemorymapeditor.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 13.10.2012\r\n//\r\n// Description:\r\n// LocalMemoryMapEditor is used to edit a local memory map of an address space.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"localmemorymapeditor.h\"\r\n\r\n#include <common/widgets/summaryLabel/summarylabel.h>\r\n#include <common/widgets/nameGroupEditor/namegroupeditor.h>\r\n#include <common/views/EditableTableView/editabletableview.h>\r\n\r\n#include <KactusAPI/include/IPXactSystemVerilogParser.h>\r\n\r\n#include <editors/ComponentEditor/memoryMaps/MemoryMapColumns.h>\r\n#include <editors/ComponentEditor/memoryMaps/memorymapdelegate.h>\r\n#include <editors/ComponentEditor/memoryMaps/memorymapmodel.h>\r\n#include <editors/ComponentEditor/memoryMaps/ExpressionProxyModel.h>\r\n#include <KactusAPI/include/AddressBlockInterface.h>\r\n\r\n#include <editors/ComponentEditor/parameters/ComponentParameterModel.h>\r\n\r\n#include <KactusAPI/include/LibraryInterface.h>\r\n\r\n#include <IPXACTmodels/Component/AddressSpace.h>\r\n#include <IPXACTmodels/Component/Component.h>\r\n#include <IPXACTmodels/Component/MemoryMapBase.h>\r\n\r\n#include <QCompleter>\r\n#include <QVBoxLayout>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LocalMemoryMapEditor::LocalMemoryMapEditor()\r\n//-----------------------------------------------------------------------------\r\nLocalMemoryMapEditor::LocalMemoryMapEditor(QSharedPointer<AddressSpace> addressSpace,\r\n    QSharedPointer<Component> component, LibraryInterface* handler,\r\n    QSharedPointer<ParameterFinder> parameterFinder, AddressBlockInterface* blockInterface, QWidget *parent):\r\nQGroupBox(tr(\"Local memory map\"), parent),\r\naddressSpace_(addressSpace),\r\nlocalMemoryMap_(0),\r\nnameEditor_(0),\r\nview_(new EditableTableView(this)),\r\nmodel_(0),\r\ncomponent_(component),\r\nhandler_(handler)\r\n{\r\n    bool hasLocalMemoryMap = !addressSpace->getLocalMemoryMap().isNull();\r\n\r\n    localMemoryMap_ = addressSpace->getLocalMemoryMap();\r\n    if (!hasLocalMemoryMap)\r\n    {\r\n        localMemoryMap_ = QSharedPointer<MemoryMapBase>(new MemoryMapBase());\r\n    }\r\n\r\n    blockInterface->setMemoryBlocks(localMemoryMap_->getMemoryBlocks());\r\n\r\n    nameEditor_ = (new NameGroupEditor(localMemoryMap_, component->getRevision(), this));\r\n\r\n    setCheckable(true);\r\n    setChecked(hasLocalMemoryMap);\r\n\r\n    nameEditor_->setTitle(tr(\"Memory map name and description\"));\r\n\r\n    QSharedPointer<IPXactSystemVerilogParser> expressionParser(new IPXactSystemVerilogParser(parameterFinder));\r\n\r\n    model_ = new MemoryMapModel(blockInterface, expressionParser, parameterFinder, component->getRevision(), this);\r\n\r\n    ComponentParameterModel* componentParameterModel = new ComponentParameterModel(parameterFinder, this);\r\n    componentParameterModel->setExpressionParser(expressionParser);\r\n\r\n\r\n    ExpressionProxyModel* proxy = new ExpressionProxyModel(expressionParser, this);\r\n    proxy->setColumnToAcceptExpressions(MemoryMapColumns::BASE_COLUMN);\r\n    proxy->setColumnToAcceptExpressions(MemoryMapColumns::RANGE_COLUMN);\r\n\r\n\tproxy->setSourceModel(model_);\r\n\tview_->setModel(proxy);\r\n\r\n\t// display a label on top the table\r\n\tSummaryLabel* summaryLabel = new SummaryLabel(tr(\"Address blocks\"), this);\r\n\r\n\tproxy->setSourceModel(model_);\r\n\tview_->setModel(proxy);\r\n\r\n\tconst QString compPath = handler_->getDirectoryPath(component_->getVlnv());\r\n\tQString defPath = QString(\"%1/localAddrBlockList.csv\").arg(compPath);\r\n\tview_->setDefaultImportExportPath(defPath);\r\n\tview_->setAllowImportExport(true);\r\n\r\n\t// items can not be dragged\r\n\tview_->setItemsDraggable(false);\r\n    view_->setItemDelegate(new MemoryMapDelegate(componentParameterModel, parameterFinder, this));\r\n\tview_->setSortingEnabled(true);\r\n    view_->setAllowElementCopying(true);\r\n\r\n\tview_->sortByColumn(MemoryMapColumns::BASE_COLUMN, Qt::AscendingOrder);\r\n\r\n    // Is present only for 2014 std.\r\n    if (component->getRevision() == Document::Revision::Std22)\r\n    {\r\n        view_->hideColumn(MemoryMapColumns::IS_PRESENT);\r\n    }\r\n\r\n    connect(this, SIGNAL(toggled(bool)), this, SLOT(onCheckStateChanged()), Qt::UniqueConnection);\r\n\r\n\tconnect(nameEditor_, SIGNAL(contentChanged()), this, SIGNAL(contentChanged()), Qt::UniqueConnection);\r\n    \r\n\tconnect(model_, SIGNAL(contentChanged()), this, SIGNAL(contentChanged()), Qt::UniqueConnection);\r\n\tconnect(model_, SIGNAL(itemAdded(int)), this, SIGNAL(itemAdded(int)), Qt::UniqueConnection);\r\n\tconnect(model_, SIGNAL(itemRemoved(int)), this, SIGNAL(itemRemoved(int)), Qt::UniqueConnection);\r\n    connect(model_, SIGNAL(childAddressingChanged(int)),\r\n        this, SIGNAL(childAddressingChanged(int)), Qt::UniqueConnection);\r\n\r\n    connect(model_, SIGNAL(graphicsChanged(int)), this, SIGNAL(childGraphicsChanged(int)), Qt::UniqueConnection);\r\n    connect(model_, SIGNAL(itemAdded(int)), this, SIGNAL(graphicsChanged()), Qt::UniqueConnection);\r\n    connect(model_, SIGNAL(itemRemoved(int)), this, SIGNAL(graphicsChanged()), Qt::UniqueConnection);\r\n\r\n\t// connect view to model\r\n\tconnect(view_, SIGNAL(addItem(const QModelIndex&)),\r\n        model_, SLOT(onAddItem(const QModelIndex&)), Qt::UniqueConnection);\r\n\tconnect(view_, SIGNAL(removeItem(const QModelIndex&)),\r\n\t\tmodel_, SLOT(onRemoveItem(const QModelIndex&)), Qt::UniqueConnection);\r\n\r\n    connect(view_->itemDelegate(), SIGNAL(increaseReferences(QString)),\r\n        this, SIGNAL(increaseReferences(QString)), Qt::UniqueConnection);\r\n    connect(view_->itemDelegate(), SIGNAL(decreaseReferences(QString)),\r\n        this, SIGNAL(decreaseReferences(QString)), Qt::UniqueConnection);\r\n\r\n    connect(model_, SIGNAL(decreaseReferences(QString)),\r\n        this, SIGNAL(decreaseReferences(QString)), Qt::UniqueConnection);\r\n    connect(model_, SIGNAL(increaseReferences(QString)),\r\n        this, SIGNAL(increaseReferences(QString)), Qt::UniqueConnection);\r\n\r\n    connect(view_, SIGNAL(copyRows(QModelIndexList)),\r\n        model_, SLOT(onCopyRows(QModelIndexList)), Qt::UniqueConnection);\r\n    connect(view_, SIGNAL(pasteRows()), model_, SLOT(onPasteRows()), Qt::UniqueConnection);\r\n\r\n    connect(this, SIGNAL(assignNewAddressUnitBits(QString const&)),\r\n        model_, SLOT(addressUnitBitsUpdated(QString const&)), Qt::UniqueConnection);\r\n\r\n\tQVBoxLayout* layout = new QVBoxLayout(this);\r\n\tlayout->addWidget(nameEditor_);\r\n\tlayout->addWidget(summaryLabel, 0, Qt::AlignCenter);\r\n\tlayout->addWidget(view_);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LocalMemoryMapEditor::refresh()\r\n//-----------------------------------------------------------------------------\r\nvoid LocalMemoryMapEditor::refresh()\r\n{\r\n\tnameEditor_->refresh();\r\n\tview_->update();\r\n    \r\n    onCheckStateChanged();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LocalMemoryMapEditor::onCheckStateChanged()\r\n//-----------------------------------------------------------------------------\r\nvoid LocalMemoryMapEditor::onCheckStateChanged()\r\n{\r\n    /*if (!isChecked() && !localMemoryMap_->getMemoryBlocks()->isEmpty())\r\n    {\r\n        setChecked(true);\r\n        emit errorMessage(\"Cannot unselect local memory map since all fields are not empty.\");        \r\n    }\r\n    */\r\n\r\n    if (isChecked())\r\n    {\r\n        addressSpace_->setLocalMemoryMap(localMemoryMap_);\r\n    }\r\n    else\r\n    {\r\n        addressSpace_->setLocalMemoryMap(QSharedPointer<MemoryMapBase>(nullptr));\r\n    }\r\n\r\n    emit contentChanged();\r\n}\r\n"
  },
  {
    "path": "editors/ComponentEditor/addressSpaces/localMemoryMap/localmemorymapeditor.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: localmemorymapeditor.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 13.10.2012\r\n//\r\n// Description:\r\n// LocalMemoryMapEditor is used to edit a local memory map of an address space.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef LOCALMEMORYMAPEDITOR_H\r\n#define LOCALMEMORYMAPEDITOR_H\r\n\r\n#include <KactusAPI/include/ParameterFinder.h>\r\n\r\n#include <QGroupBox>\r\n#include <QSharedPointer>\r\n#include <QCheckBox>\r\n\r\nclass AddressSpace;\r\nclass Component;\r\nclass EditableTableView;\r\nclass LibraryInterface;\r\nclass MemoryMapBase;\r\nclass MemoryMapModel;\r\nclass NameGroupEditor;\r\n\r\nclass AddressBlockInterface;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! LocalMemoryMapEditor is used to edit a local memory map of an address space.\r\n//-----------------------------------------------------------------------------\r\nclass LocalMemoryMapEditor : public QGroupBox\r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\r\n\t/*!\r\n\t *  The constructor.\r\n\t *\r\n\t *    @param [in] addressSpace        Pointer to the local memory map being edited.\r\n\t *    @param [in] component           Pointer to the component being edited.\r\n\t *    @param [in] handler             Pointer to the instance managing the library.\r\n\t *    @param [in] parameterFinder     Pointer to the parameter finder.\r\n     *    @param [in] blockInterface      Interface for address blocks.\r\n\t *    @param [in] parent              Pointer to the owner of the editor.\r\n\t */\r\n\tLocalMemoryMapEditor(QSharedPointer<AddressSpace> addressSpace,\r\n\t\tQSharedPointer<Component> component,\r\n\t\tLibraryInterface* handler,\r\n        QSharedPointer <ParameterFinder> parameterFinder,\r\n        AddressBlockInterface* blockInterface,\r\n\t\tQWidget *parent);\r\n\t\r\n\t//! The destructor.\r\n\tvirtual ~LocalMemoryMapEditor() = default;\r\n\r\n    //! No copying. No assignment.\r\n    LocalMemoryMapEditor(const LocalMemoryMapEditor& other) = delete;\r\n    LocalMemoryMapEditor& operator=(const LocalMemoryMapEditor& other) = delete;\r\n\r\n\t//! Reload the information from the model to the editor.\r\n\tvoid refresh();\r\n\r\nsignals:\r\n\r\n\t//! Emitted when the contents of the model change.\r\n\tvoid contentChanged();\r\n\r\n    //! Emitted when the changes should be reflected in visualization.\r\n    void graphicsChanged();\r\n\r\n    //! Emitted when the changes should be reflected in visualization.\r\n    void childGraphicsChanged(int index);\r\n\r\n\t//! Emitted when a new memory map item is added to the given index.\r\n\tvoid itemAdded(int index);\r\n\r\n\t//! Emitted when a memory map item is removed from the given index.\r\n\tvoid itemRemoved(int index);\r\n\r\n    //! Prints an error message to the user.\r\n    void errorMessage(const QString& msg) const;\r\n\r\n    /*!\r\n     *  Increase the amount of references to a parameter.\r\n     *\r\n     *    @param [in] id  The id of the parameter.\r\n     */\r\n    void increaseReferences(QString id);\r\n\r\n    /*!\r\n     *  Decrease the amount of references to a parameter.\r\n     *\r\n     *    @param [in] id  The id of the parameter.\r\n     */\r\n    void decreaseReferences(QString id);\r\n\r\n    /*!\r\n     *  Assign the new address unit bits for address blocks.\r\n     *\r\n     *    @param [in] newAddressUnitBits  The new address unit bits.\r\n     */\r\n    void assignNewAddressUnitBits(QString const& newAddressUnitBits);\r\n\r\n    void addressingChanged();\r\n\r\n    void childAddressingChanged(int index);\r\n\r\npublic slots:\r\n\r\n    /*!\r\n     *  The check state has been changed.\r\n     */\r\n    void onCheckStateChanged();\r\n\r\nprivate:\r\n\r\n    //! The address space being edited.\r\n    QSharedPointer<AddressSpace> addressSpace_;\r\n\r\n\t//! Pointer to the local memory map being edited.\r\n\tQSharedPointer<MemoryMapBase> localMemoryMap_;\r\n\r\n\t//! Used to edit the name, display name and description.\r\n\tNameGroupEditor* nameEditor_;\r\n\r\n\t//! The view to display the table of local memory address blocks\r\n\tEditableTableView* view_;\r\n\r\n\t//! The model that manages the items.\r\n\tMemoryMapModel* model_;\r\n\r\n\t//! Pointer to the component being edited.\r\n\tQSharedPointer<Component> component_;\r\n\r\n\t//! Pointer to the instance managing the library.\r\n\tLibraryInterface* handler_;\r\n};\r\n\r\n#endif // LOCALMEMORYMAPEDITOR_H\r\n"
  },
  {
    "path": "editors/ComponentEditor/addressSpaces/localMemoryMap/localmemorymapgraphitem.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: localmemorymapgraphitem.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 17.12.2012\r\n//\r\n// Description:\r\n// The graph item that visualizes a local memory map within address space.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"localmemorymapgraphitem.h\"\r\n\r\n#include <IPXACTmodels/Component/MemoryMap.h>\r\n#include <IPXACTmodels/Component/AddressSpace.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LocalMemoryMapGraphItem::LocalMemoryMapGraphItem()\r\n//-----------------------------------------------------------------------------\r\nLocalMemoryMapGraphItem::LocalMemoryMapGraphItem(QSharedPointer<AddressSpace> addrSpace,\r\n    QSharedPointer<MemoryMapBase> localMemoryMap, QSharedPointer<ExpressionParser> expressionParser,\r\n    QGraphicsItem* parent):\r\nMemoryMapGraphItem(QSharedPointer<MemoryMap> (new MemoryMap()), localMemoryMap, expressionParser, parent),\r\naddrSpace_(addrSpace)\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LocalMemoryMapGraphItem::getAddressUnitSize()\r\n//-----------------------------------------------------------------------------\r\nunsigned int LocalMemoryMapGraphItem::getAddressUnitSize() const\r\n{\r\n    return parseExpression(addrSpace_->getAddressUnitBits());\r\n}\r\n"
  },
  {
    "path": "editors/ComponentEditor/addressSpaces/localMemoryMap/localmemorymapgraphitem.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: localmemorymapgraphitem.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 17.12.2012\r\n//\r\n// Description:\r\n// The graph item that visualizes a local memory map within address space.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef LOCALMEMORYMAPGRAPHITEM_H\r\n#define LOCALMEMORYMAPGRAPHITEM_H\r\n\r\n#include <editors/ComponentEditor/memoryMaps/memoryMapsVisualizer/memorymapgraphitem.h>\r\n\r\nclass ExpressionParser;\r\nclass AddressSpace;\r\nclass MemoryMapBase;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! The graph item that visualizes a local memory map within address space.\r\n//-----------------------------------------------------------------------------\r\nclass LocalMemoryMapGraphItem : public MemoryMapGraphItem\r\n{\r\n    Q_OBJECT\r\n\r\npublic:\r\n\r\n    /*! The constructor\r\n     *\r\n     *    @param [in] addrSpace       The address space that contains the local memory map.\r\n     *    @param [in] localMemoryMap  The local memory map.\r\n     *    @param [in] parent          The owner of the graphics item.\r\n     *\r\n    */\r\n    LocalMemoryMapGraphItem(QSharedPointer<AddressSpace> addrSpace,\r\n        QSharedPointer<MemoryMapBase> localMemoryMap,\r\n        QSharedPointer<ExpressionParser> expressionParser,\r\n        QGraphicsItem* parent = 0);\r\n\r\n    //! The destructor.\r\n    virtual ~LocalMemoryMapGraphItem() = default;\r\n\r\n    //! No copying.\r\n    LocalMemoryMapGraphItem(const LocalMemoryMapGraphItem& other) = delete;\r\n\r\n    //! No assignment.\r\n    LocalMemoryMapGraphItem& operator=(const LocalMemoryMapGraphItem& other) = delete;\r\n\r\n    /*!\r\n     *  Get number of bits the addressable unit contains.\r\n     *\r\n     *    @return The size of least addressable unit.\r\n     */\r\n    virtual unsigned int getAddressUnitSize() const override final;\r\n \r\n\r\nprivate:\r\n    \r\n    //! The address space containing the local memory map.\r\n    QSharedPointer<AddressSpace> addrSpace_;\r\n};\r\n\r\n#endif // LOCALMEMORYMAPGRAPHITEM_H\r\n"
  },
  {
    "path": "editors/ComponentEditor/addressSpaces/segmenteditor.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: segmenteditor.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 22.02.2012\r\n//\r\n// Description:\r\n// The editor to edit the segments of an address space.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"segmenteditor.h\"\r\n\r\n#include \"SegmentDelegate.h\"\r\n#include \"SegmentColumns.h\"\r\n\r\n#include <editors/ComponentEditor/parameters/ComponentParameterModel.h>\r\n#include <editors/ComponentEditor/memoryMaps/ExpressionProxyModel.h>\r\n\r\n#include <IPXACTmodels/Component/Component.h>\r\n#include <IPXACTmodels/Component/AddressSpace.h>\r\n#include <IPXACTmodels/Component/Segment.h>\r\n\r\n#include <QCompleter>\r\n#include <QVBoxLayout>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SegmentEditor::SegmentEditor()\r\n//-----------------------------------------------------------------------------\r\nSegmentEditor::SegmentEditor(QSharedPointer<AddressSpace> addrSpace, QSharedPointer<Component> component,\r\n                             QString const& componentPath, QSharedPointer<ParameterFinder> parameterFinder,\r\n                             QSharedPointer<ExpressionParser> expressionParser,\r\n                             QSharedPointer<ExpressionFormatter> expressionFormatter, QWidget *parent ):\r\nQGroupBox(tr(\"Segments\"), parent),\r\nview_(this),\r\nmodel_(addrSpace->getSegments(), parameterFinder, expressionFormatter, this),\r\ncomponent_(component)\r\n{\r\n    model_.setExpressionParser(expressionParser);\r\n\r\n\tconnect(&model_, SIGNAL(contentChanged()), this, SIGNAL(contentChanged()), Qt::UniqueConnection);\r\n\tconnect(&model_, SIGNAL(dataChanged(const QModelIndex&, const QModelIndex&)),\r\n\t\tthis, SIGNAL(contentChanged()), Qt::UniqueConnection);\r\n\tconnect(&model_, SIGNAL(errorMessage(const QString&)),\r\n\t\tthis, SIGNAL(errorMessage(const QString&)), Qt::UniqueConnection);\r\n\tconnect(&model_, SIGNAL(noticeMessage(const QString&)),\r\n\t\tthis, SIGNAL(noticeMessage(const QString&)), Qt::UniqueConnection);\r\n\r\n\tconnect(&model_, SIGNAL(segmentAdded(QSharedPointer<Segment>)),\r\n\t\tthis, SIGNAL(segmentAdded(QSharedPointer<Segment>)), Qt::UniqueConnection);\r\n\tconnect(&model_, SIGNAL(segmentRemoved(const QString&)),\r\n\t\tthis, SIGNAL(segmentRemoved(const QString&)), Qt::UniqueConnection);\r\n\tconnect(&model_, SIGNAL(segmentRenamed(const QString&, const QString&)),\r\n\t\tthis, SIGNAL(segmentRenamed(const QString&, const QString&)), Qt::UniqueConnection);\r\n\tconnect(&model_, SIGNAL(segmentChanged(QSharedPointer<Segment>)),\r\n\t\tthis, SIGNAL(segmentChanged(QSharedPointer<Segment>)), Qt::UniqueConnection);\r\n\r\n\tconnect(&view_, SIGNAL(addItem(const QModelIndex&)),\r\n\t\t&model_, SLOT(onAddItem(const QModelIndex&)), Qt::UniqueConnection);\r\n\tconnect(&view_, SIGNAL(removeItem(const QModelIndex&)),\r\n\t\t&model_, SLOT(onRemoveItem(const QModelIndex&)), Qt::UniqueConnection);\r\n\r\n\tQString defPath = QString(\"%1/segmentList.csv\").arg(componentPath);\r\n\tview_.setDefaultImportExportPath(defPath);\r\n\tview_.setAllowImportExport(true);\r\n\r\n\tview_.setSortingEnabled(true);\r\n\tview_.setItemsDraggable(false);\r\n    view_.setAllowElementCopying(true);\r\n\r\n    ComponentParameterModel* completionModel = new ComponentParameterModel(parameterFinder, this);\r\n    completionModel->setExpressionParser(expressionParser);\r\n\r\n\tview_.setItemDelegate(new SegmentDelegate(completionModel, parameterFinder, this));\r\n\r\n    ExpressionProxyModel* proxy = new ExpressionProxyModel(expressionParser, this);\r\n    proxy->setColumnToAcceptExpressions(SegmentColumns::OFFSET);\r\n    proxy->setColumnToAcceptExpressions(SegmentColumns::RANGE);\r\n    proxy->setColumnToAcceptExpressions(SegmentColumns::IS_PRESENT);\r\n\r\n\tproxy->setSourceModel(&model_);\r\n\tview_.setModel(proxy);\r\n\r\n\tview_.sortByColumn(1, Qt::AscendingOrder);\r\n\r\n\tQVBoxLayout* layout = new QVBoxLayout(this);\r\n\tlayout->addWidget(&view_);\r\n\r\n\tif (component->getRevision() == Document::Revision::Std22)\r\n\t{\r\n        view_.hideColumn(SegmentColumns::IS_PRESENT);\r\n\t}\r\n\r\n    connect(view_.itemDelegate(), SIGNAL(increaseReferences(QString)),\r\n        this, SIGNAL(increaseReferences(QString)), Qt::UniqueConnection);\r\n    connect(view_.itemDelegate(), SIGNAL(decreaseReferences(QString)),\r\n        this, SIGNAL(decreaseReferences(QString)), Qt::UniqueConnection);\r\n\r\n    connect(&model_, SIGNAL(decreaseReferences(QString)),\r\n        this, SIGNAL(decreaseReferences(QString)), Qt::UniqueConnection);\r\n    connect(&model_, SIGNAL(increaseReferences(QString)),\r\n        this, SIGNAL(increaseReferences(QString)), Qt::UniqueConnection);\r\n\r\n    connect(&view_, SIGNAL(copyRows(QModelIndexList)),\r\n        &model_, SLOT(onCopyRows(QModelIndexList)), Qt::UniqueConnection);\r\n    connect(&view_, SIGNAL(pasteRows()), &model_, SLOT(onPasteRows()), Qt::UniqueConnection);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SegmentEditor::~SegmentEditor()\r\n//-----------------------------------------------------------------------------\r\nSegmentEditor::~SegmentEditor()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SegmentEditor::refresh()\r\n//-----------------------------------------------------------------------------\r\nvoid SegmentEditor::refresh()\r\n{\r\n\tview_.update();\r\n\tview_.sortByColumn(1, Qt::AscendingOrder);\r\n}\r\n"
  },
  {
    "path": "editors/ComponentEditor/addressSpaces/segmenteditor.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: segmenteditor.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 22.02.2012\r\n//\r\n// Description:\r\n// The editor to edit the segments of an address space.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef SEGMENTEDITOR_H\r\n#define SEGMENTEDITOR_H\r\n\r\n#include \"segmentsmodel.h\"\r\n\r\n#include <common/views/EditableTableView/editabletableview.h>\r\n\r\n#include <QSharedPointer>\r\n#include <QGroupBox>\r\n\r\nclass LibraryInterface;\r\nclass ExpressionParser;\r\nclass ExpressionFormatter;\r\nclass Component;\r\nclass AddressSpace;\r\nclass Segment;\r\n//-----------------------------------------------------------------------------\r\n//! The editor to edit the segments of an address space.\r\n//-----------------------------------------------------------------------------\r\nclass SegmentEditor : public QGroupBox\r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\r\n    /*!\r\n     *  The constructor\r\n     *\r\n     *    @param [in] addrSpace               The address space whose segments are edited.\r\n     *    @param [in] component               The component being edited.\r\n     *    @param [in] componentPath           The path to component xml file.\r\n     *    @param [in] parameterFinder         Finder for available parameter names.\r\n     *    @param [in] expressionParser        Parser for expressions.\r\n     *    @param [in] expressionFormatter     Formatter for expressions.\r\n     *    @param [in] parent                  Pointer to the owner of this editor.\r\n\t */\r\n\tSegmentEditor(QSharedPointer<AddressSpace> addrSpace, \r\n\t\tQSharedPointer<Component> component,\r\n        QString const& componentPath,\r\n        QSharedPointer<ParameterFinder> parameterFinder,\r\n        QSharedPointer<ExpressionParser> expressionParser,\r\n        QSharedPointer<ExpressionFormatter> expressionFormatter,\r\n\t\tQWidget *parent);\r\n\t\r\n\t//! The destructor.\r\n\tvirtual ~SegmentEditor();\r\n\r\n\t/*!\r\n     *  Read the settings from the address space to the editor.\r\n\t */\r\n\tvoid refresh();\r\n\r\nsignals:\r\n\r\n\t//! Emitted when the contents of the editor change.\r\n\tvoid contentChanged();\r\n\r\n\t//! Print an error message to the user.\r\n\tvoid errorMessage(const QString& msg);\r\n\r\n\t//! Print a notification to the user.\r\n\tvoid noticeMessage(const QString& msg);\r\n\r\n\t//! Emitted when a new segment is added to the address space.\r\n\tvoid segmentAdded(QSharedPointer<Segment> segment);\r\n\r\n\t//! Emitted when a segment is removed from the address space.\r\n\tvoid segmentRemoved(const QString& segmentName);\r\n\r\n\t//! Emitted when a segment is renamed.\r\n\tvoid segmentRenamed(const QString& oldName, const QString& newName);\r\n\r\n\t//! Emitted when the range or offset of a segment has changed.\r\n\tvoid segmentChanged(QSharedPointer<Segment> segment);\r\n\r\n    /*!\r\n     *  Increase the amount of references to a parameter with a matching id.\r\n     *\r\n     *    @param [in] id      Id of the parameter, whose references are being increased.\r\n     */\r\n    void increaseReferences(QString id);\r\n\r\n    /*!\r\n     *  Decrease the amount of references to a parameter with a matching id.\r\n     *\r\n     *    @param [in] id      Id of the parameter, whose references are being increased.\r\n     */\r\n    void decreaseReferences(QString id);\r\n\r\nprivate:\r\n\r\n\t//! No copying. No assignment.\r\n\tSegmentEditor(const SegmentEditor& other);\r\n\tSegmentEditor& operator=(const SegmentEditor& other);\r\n\r\n\t//! The view to display the segments.\r\n\tEditableTableView view_;\r\n\r\n\t//! The model that contains the segments.\r\n\tSegmentsModel model_;\r\n\r\n\t//! Pointer to the component being edited.\r\n\tQSharedPointer<Component> component_;\r\n};\r\n\r\n#endif // SEGMENTEDITOR_H\r\n"
  },
  {
    "path": "editors/ComponentEditor/addressSpaces/segmentsmodel.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: segmentsmodel.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 22.02.2012\r\n//\r\n// Description:\r\n// The model that can be used to display the segments to be edited.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"segmentsmodel.h\"\r\n#include \"SegmentColumns.h\"\r\n\r\n#include <KactusAPI/include/ExpressionFormatter.h>\r\n#include <editors/ComponentEditor/memoryMaps/memoryMapsExpressionCalculators/ReferenceCalculator.h>\r\n\r\n#include <IPXACTmodels/Component/Segment.h>\r\n\r\n\r\n#include <QApplication>\r\n#include <QClipboard>\r\n#include <QMimeData>\r\n\r\n#include <common/KactusColors.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SegmentsModel::SegmentsModel()\r\n//-----------------------------------------------------------------------------\r\nSegmentsModel::SegmentsModel(QSharedPointer<QList<QSharedPointer<Segment> > > segments,\r\n    QSharedPointer<ParameterFinder> parameterFinder, QSharedPointer<ExpressionFormatter> expressionFormatter,\r\n    QObject *parent):\r\nReferencingTableModel(parameterFinder, parent),\r\nParameterizableTable(parameterFinder),\r\nsegments_(segments),\r\nexpressionFormatter_(expressionFormatter)\r\n{\r\n\tQ_ASSERT(segments_);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SegmentsModel::rowCount()\r\n//-----------------------------------------------------------------------------\r\nint SegmentsModel::rowCount(QModelIndex const& parent) const\r\n{\r\n\tif (parent.isValid())\r\n    {\r\n\t\treturn 0;\r\n\t}\r\n\treturn segments_->count();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SegmentsModel::columnCount()\r\n//-----------------------------------------------------------------------------\r\nint SegmentsModel::columnCount(QModelIndex const& parent) const\r\n{\r\n\tif (parent.isValid())\r\n    {\r\n\t\treturn 0;\r\n\t}\r\n\treturn SegmentColumns::COLUMN_COUNT;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SegmentsModel::setData()\r\n//-----------------------------------------------------------------------------\r\nQVariant SegmentsModel::headerData(int section, Qt::Orientation orientation, int role) const\r\n{\r\n    if (orientation != Qt::Horizontal)\r\n    {\r\n        return QVariant();\r\n    }\r\n\r\n    if (role == Qt::DisplayRole)\r\n    {\r\n        if (section == SegmentColumns::NAME)\r\n        {\r\n            return tr(\"Name\");\r\n        }\r\n        else if (section == SegmentColumns::OFFSET)\r\n        {\r\n            return tr(\"Offset [AUB]\") + getExpressionSymbol();\r\n        }\r\n        else if (section == SegmentColumns::RANGE)\r\n        {\r\n            return tr(\"Range [AUB]\") + getExpressionSymbol();\r\n        }\r\n        else if (section == SegmentColumns::IS_PRESENT)\r\n        {\r\n            return tr(\"Is present\") + getExpressionSymbol();\r\n        }\r\n        else if (section == SegmentColumns::DESCRIPTION)\r\n        {\r\n            return tr(\"Description\");\r\n        }\r\n        else\r\n        {\r\n            return QVariant();\r\n        }\r\n    }\r\n    else // if unsupported role\r\n    {\r\n        return QVariant();\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SegmentsModel::data()\r\n//-----------------------------------------------------------------------------\r\nQVariant SegmentsModel::data( QModelIndex const& index, int role) const\r\n{\r\n\tif (!index.isValid() || index.row() < 0 || index.row() >= segments_->size())\r\n    {\r\n\t\treturn QVariant();\r\n    }\r\n\r\n    if (role == Qt::DisplayRole)\r\n    {\r\n        if (isValidExpressionColumn(index))\r\n        {\r\n            return expressionFormatter_->formatReferringExpression(expressionOrValueForIndex(index).toString());\r\n        }\r\n\r\n        return expressionOrValueForIndex(index);\r\n    }\r\n    else if (role == Qt::EditRole)\r\n    {\r\n        return expressionOrValueForIndex(index);\r\n    }\r\n\telse if (role == Qt::BackgroundRole)\r\n    {\r\n        if (index.column() == SegmentColumns::NAME || index.column() ==  SegmentColumns::OFFSET ||\r\n            index.column() == SegmentColumns::RANGE)\r\n        {            \r\n            return KactusColors::MANDATORY_FIELD;\r\n        }\r\n        else\r\n        {\r\n            return KactusColors::REGULAR_FIELD;\r\n        }\r\n    }\r\n\telse if (role == Qt::ForegroundRole)\r\n    {\r\n        return blackForValidOrRedForInvalidIndex(index);\r\n    }\r\n    else if (role == Qt::ToolTipRole)\r\n    {\r\n        if (isValidExpressionColumn(index))\r\n        {\r\n            return formattedValueFor(expressionOrValueForIndex(index).toString());\r\n        }\r\n\r\n        return expressionOrValueForIndex(index);\r\n    }\r\n\telse // if unsupported role\r\n    {\r\n\t\treturn QVariant();\r\n\t}\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SegmentsModel::setData()\r\n//-----------------------------------------------------------------------------\r\nbool SegmentsModel::setData(QModelIndex const& index, QVariant const& value, int role)\r\n{\r\n\tif (!index.isValid() || index.row() < 0 || index.row() >= segments_->size())\r\n    {\r\n\t\treturn false;\r\n    }\r\n\r\n    if (role == Qt::EditRole) \r\n    {\r\n        QSharedPointer<Segment> targetSegment = segments_->at(index.row());\r\n        if (index.column() ==  SegmentColumns::NAME)\r\n        {\r\n            QString oldName = targetSegment->name();\r\n            targetSegment->setName(value.toString());\r\n\r\n            emit segmentRenamed(oldName, value.toString());\r\n        }\r\n        else if (index.column() == SegmentColumns::OFFSET)\r\n        {\r\n            targetSegment->setOffset(value.toString());\r\n            emit segmentChanged(targetSegment);\r\n        }\r\n        else if (index.column() == SegmentColumns::RANGE)\r\n        {\r\n            targetSegment->setRange(value.toString());\r\n            emit segmentChanged(targetSegment);\r\n        }\r\n        else if (index.column() == SegmentColumns::IS_PRESENT)\r\n        {\r\n            targetSegment->setIsPresent(value.toString());\r\n            emit segmentChanged(targetSegment);\r\n        }\r\n        else if (index.column() == SegmentColumns::DESCRIPTION)\r\n        {\r\n            targetSegment->setDescription(value.toString());\r\n        }\r\n        else\r\n        {\r\n            return false;\r\n        }\r\n\r\n        emit dataChanged(index, index);\r\n        return true;\r\n    }\r\n\telse // is unsupported role\r\n    {\r\n\t\treturn false;\r\n\t}\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SegmentsModel::flags()\r\n//-----------------------------------------------------------------------------\r\nQt::ItemFlags SegmentsModel::flags( QModelIndex const& index ) const\r\n{\r\n\tif (!index.isValid())\r\n    {\r\n\t\treturn Qt::NoItemFlags;\r\n    }\r\n\r\n\treturn Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsEditable;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SegmentsModel::onAddItem()\r\n//-----------------------------------------------------------------------------\r\nvoid SegmentsModel::onAddItem(QModelIndex const& index)\r\n{\r\n\tint row = segments_->size();\r\n\r\n\t// if the index is valid then add the item to the correct position\r\n\tif (index.isValid())\r\n    {\r\n\t\trow = index.row();\r\n\t}\r\n\r\n\t// the last segmented address\r\n\tquint64 previousEnd = 0;\r\n    \r\n\t// if this is the first item to add then do not increase address\r\n\tif (!segments_->isEmpty())\r\n    {\r\n\t\tpreviousEnd = getLastSegmentedAddress() + 1;\r\n\t}\r\n\r\n\t// convert the address to hexadecimal form\r\n\tQString newBase = QString::number(previousEnd, 16);\r\n\tnewBase = newBase.toUpper();\r\n\tnewBase.prepend(\"'h\");\r\n\r\n\tQSharedPointer<Segment> segment(new Segment());\r\n\tsegment->setOffset(newBase);\r\n\r\n\tbeginInsertRows(QModelIndex(), row, row);\r\n\tsegments_->insert(row, segment);\r\n\tendInsertRows();\r\n\r\n\t// tell also parent widget that contents have been changed\r\n\temit contentChanged();\r\n\r\n\temit segmentAdded(segment);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SegmentsModel::onRemoveItem()\r\n//-----------------------------------------------------------------------------\r\nvoid SegmentsModel::onRemoveItem(QModelIndex const& index)\r\n{\r\n\t// don't remove anything if index is invalid\r\n\tif (!index.isValid() || index.row() < 0 || index.row() >= segments_->size())\r\n    {\r\n\t\treturn;\r\n\t}\r\n\r\n    removeReferencesInItemOnRow(index.row());\r\n\r\n\temit segmentRemoved(segments_->at(index.row())->name());\r\n\r\n\t// remove the specified item\r\n\tbeginRemoveRows(QModelIndex(), index.row(), index.row());\r\n\tsegments_->removeAt(index.row());\r\n\tendRemoveRows();\r\n\r\n\t// tell also parent widget that contents have been changed\r\n\temit contentChanged();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SegmentsModel::isValidExpressionColumn()\r\n//-----------------------------------------------------------------------------\r\nbool SegmentsModel::isValidExpressionColumn(QModelIndex const& index) const\r\n{\r\n    return index.column() == SegmentColumns::OFFSET || index.column() == SegmentColumns::RANGE ||\r\n        index.column() == SegmentColumns::IS_PRESENT;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SegmentsModel::expressionOrValueForIndex()\r\n//-----------------------------------------------------------------------------\r\nQVariant SegmentsModel::expressionOrValueForIndex(QModelIndex const& index) const\r\n{\r\n    if (index.column() == SegmentColumns::NAME)\r\n    {\r\n        return segments_->at(index.row())->name();\r\n    }\r\n    else if (index.column() == SegmentColumns::OFFSET)\r\n    {\r\n        return segments_->at(index.row())->getAddressOffset();\r\n    }\r\n    else if (index.column() ==  SegmentColumns::RANGE)\r\n    {\r\n        return segments_->at(index.row())->getRange();\r\n    }\r\n    else if (index.column() ==  SegmentColumns::IS_PRESENT)\r\n    {\r\n        return segments_->at(index.row())->getIsPresent();\r\n    }\r\n    else if (index.column() ==  SegmentColumns::DESCRIPTION)\r\n    {\r\n        return segments_->at(index.row())->description();\r\n    }\r\n    else \r\n    {\r\n        return QVariant();\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SegmentsModel::validateIndex()\r\n//-----------------------------------------------------------------------------\r\nbool SegmentsModel::validateIndex(QModelIndex const& index) const\r\n{\r\n    if (index.column() == SegmentColumns::NAME)\r\n    {\r\n        QStringList segmentNames;\r\n        for (QSharedPointer<Segment> segment : *segments_)\r\n        {\r\n            segmentNames.append(segment->name());\r\n        }\r\n\r\n        return segmentNames.count(segments_->at(index.row())->name()) == 1;\r\n    }\r\n    else if (index.column() == SegmentColumns::OFFSET)\r\n    {\r\n        QString offset = segments_->at(index.row())->getAddressOffset();\r\n        return isValidExpression(offset);\r\n    }\r\n    else if (index.column() ==  SegmentColumns::RANGE)\r\n    {\r\n        QString range = segments_->at(index.row())->getRange();\r\n        return isValidExpression(range);\r\n    }\r\n    else if (index.column() ==  SegmentColumns::IS_PRESENT)\r\n    {\r\n        QString isPresent = segments_->at(index.row())->getIsPresent();\r\n        int value = parseExpressionToDecimal(isPresent).toInt();\r\n        return isPresent.isEmpty() || value == 1 || value == 0;\r\n    }\r\n    else if (index.column() ==  SegmentColumns::DESCRIPTION)\r\n    {\r\n        return true;\r\n    }\r\n\r\n    return false;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SegmentsModel::getAllReferencesToIdInItemOnRow()\r\n//-----------------------------------------------------------------------------\r\nint SegmentsModel::getAllReferencesToIdInItemOnRow(const int& row, QString const& valueID) const\r\n{\r\n    int referencesInOffset = segments_->at(row)->getAddressOffset().count(valueID);\r\n    int referencesInRange = segments_->at(row)->getRange().count(valueID);\r\n    int referencesInPresence = segments_->at(row)->getIsPresent().count(valueID);\r\n\r\n    return referencesInOffset + referencesInRange + referencesInPresence;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SegmentsModel::getLastSegmentedAddress()\r\n//-----------------------------------------------------------------------------\r\nquint64 SegmentsModel::getLastSegmentedAddress() const\r\n{\r\n    quint64 lastAddress = 0;\r\n    for (QSharedPointer<Segment> segment : *segments_)\r\n    {\r\n        quint64 segmentOffset = parseExpressionToDecimal(segment->getAddressOffset()).toUInt();\r\n        quint64 segmentSize = qMax(parseExpressionToDecimal(segment->getRange()).toUInt(), uint(1));\r\n        \r\n        lastAddress = qMax(lastAddress, segmentOffset + segmentSize - 1);\r\n    }\r\n\r\n    return lastAddress;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SegmentsModel::onCopyRows()\r\n//-----------------------------------------------------------------------------\r\nvoid SegmentsModel::onCopyRows(QModelIndexList indexList)\r\n{\r\n    QList<QSharedPointer<Segment> > copiedSegments;\r\n    for (QModelIndex const& index : indexList)\r\n    {\r\n        QSharedPointer<Segment> segment = segments_->at(index.row());\r\n        copiedSegments.append(segment);\r\n    }\r\n\r\n    QVariant addressSpaceVariant;\r\n    addressSpaceVariant.setValue(copiedSegments);\r\n\r\n    QMimeData* newMimeData = new QMimeData();\r\n    newMimeData->setData(\"text/xml/ipxact:segment\", QByteArray());\r\n    newMimeData->setImageData(addressSpaceVariant);\r\n\r\n    QApplication::clipboard()->setMimeData(newMimeData);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SegmentsModel::onPasteRows()\r\n//-----------------------------------------------------------------------------\r\nvoid SegmentsModel::onPasteRows()\r\n{\r\n    const QMimeData* pasteData = QApplication::clipboard()->mimeData();\r\n\r\n    if (pasteData->hasImage())\r\n    {\r\n        QVariant pasteVariant = pasteData->imageData();\r\n        if (pasteVariant.canConvert<QList<QSharedPointer<Segment> > >())\r\n        {\r\n            ReferenceCalculator referenceCalculator(getParameterFinder());\r\n\r\n            QList<QSharedPointer<Segment> > newSegments = pasteVariant.value<QList<QSharedPointer<Segment> > >();\r\n\r\n            int rowBegin = segments_->size();\r\n            int rowEnd = rowBegin + newSegments.size() - 1;\r\n\r\n            beginInsertRows(QModelIndex(), rowBegin, rowEnd);\r\n\r\n            for (QSharedPointer<Segment> copySegment : newSegments)\r\n            {\r\n                QSharedPointer<Segment> newSegment (new Segment(*copySegment));\r\n                newSegment->setName(getUniqueName(newSegment->name(), getCurrentItemNames()));\r\n\r\n                segments_->append(newSegment);\r\n\r\n                increaseReferencesInPastedSegment(newSegment, referenceCalculator);\r\n\r\n                emit segmentAdded(newSegment);\r\n            }\r\n\r\n            endInsertRows();\r\n\r\n            emit contentChanged();\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SegmentsModel::getCurrentItemNames()\r\n//-----------------------------------------------------------------------------\r\nQStringList SegmentsModel::getCurrentItemNames()\r\n{\r\n    QStringList names;\r\n    for (QSharedPointer<Segment> segment : *segments_)\r\n    {\r\n        names.append(segment->name());\r\n    }\r\n\r\n    return names;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SegmentsModel::increaseReferencesInPastedSegment()\r\n//-----------------------------------------------------------------------------\r\nvoid SegmentsModel::increaseReferencesInPastedSegment(QSharedPointer<Segment> pastedSegment,\r\n    ReferenceCalculator& referenceCalculator)\r\n{\r\n    QStringList segmentExpressions;\r\n    segmentExpressions.append(pastedSegment->getAddressOffset());\r\n    segmentExpressions.append(pastedSegment->getRange());\r\n\r\n    QMap<QString, int> referencedParameters = referenceCalculator.getReferencedParameters(segmentExpressions);\r\n\r\n    QMapIterator<QString, int> refParameterIterator (referencedParameters);\r\n    while (refParameterIterator.hasNext())\r\n    {\r\n        refParameterIterator.next();\r\n        for (int i = 0; i < refParameterIterator.value(); ++i)\r\n        {\r\n            emit increaseReferences(refParameterIterator.key());\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SegmentsModel::mimeTypes()\r\n//-----------------------------------------------------------------------------\r\nQStringList SegmentsModel::mimeTypes() const\r\n{\r\n    QStringList types(QAbstractItemModel::mimeTypes());\r\n\r\n    types << \"text/xml/ipxact:segment\";\r\n\r\n    return types;\r\n}\r\n"
  },
  {
    "path": "editors/ComponentEditor/addressSpaces/segmentsmodel.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: segmentsmodel.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 22.02.2012\r\n//\r\n// Description:\r\n// The model that can be used to display the segments to be edited.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef SEGMENTSMODEL_H\r\n#define SEGMENTSMODEL_H\r\n\r\n#include <editors/ComponentEditor/common/ParameterizableTable.h>\r\n#include <editors/ComponentEditor/common/ReferencingTableModel.h>\r\n\r\n#include <QList>\r\n#include <QSharedPointer>\r\n\r\nclass ExpressionFormatter;\r\nclass Segment;\r\nclass ReferenceCalculator;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! The model that can be used to display the segments to be edited.\r\n//-----------------------------------------------------------------------------\r\nclass SegmentsModel : public ReferencingTableModel, public ParameterizableTable\r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\r\n\t/*!\r\n\t *  The constructor.\r\n\t *\r\n\t *    @param [in] segments                The segments being edited.\r\n\t *    @param [in] parameterFinder         The finder for available parameter names.\r\n\t *    @param [in] expressionFormatter     Formatter for expressions.\r\n\t *    @param [in] parent                  The owner of this model.\r\n\t */\r\n\tSegmentsModel(QSharedPointer<QList<QSharedPointer<Segment> > > segments,\r\n        QSharedPointer<ParameterFinder> parameterFinder,\r\n        QSharedPointer<ExpressionFormatter> expressionFormatter,\r\n\t\tQObject *parent);\r\n\t\r\n\t//! The destructor.\r\n\tvirtual ~SegmentsModel() = default;\r\n\r\n\t/*!\r\n     *  Get the number of rows an item contains.\r\n\t *\r\n\t *    @param [in] parent Identifies the parent that's row count is requested.\r\n\t *\r\n\t *    @return Number of rows the item has.\r\n\t */\r\n\tvirtual int rowCount(const QModelIndex& parent = QModelIndex()) const;\r\n\r\n\t/*!\r\n     *  Get the number of columns the item has to be displayed.\r\n\t *\r\n\t *    @param [in] parent Identifies the parent that's column count is requested.\r\n\t *\r\n\t *    @return The number of columns to be displayed (always 4).\r\n\t */\r\n\tvirtual int columnCount(const QModelIndex& parent = QModelIndex()) const;\r\n\r\n\t/*!\r\n     *  Get the header data for specified header.\r\n\t *\r\n\t *    @param [in] section The section specifies the row/column number for the header.\r\n\t *    @param [in] orientation Specified if horizontal or vertical header is wanted.\r\n\t *    @param [in] role Specifies the type of the requested data.\r\n\t *\r\n\t *    @return QVariant Contains the requested data.\r\n\t */\r\n\tvirtual QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;\r\n\r\n\t/*!\r\n     *  Get the data for specified item.\r\n\t *\r\n\t *    @param [in] index Specifies the item that's data is requested.\r\n\t *    @param [in] role The role that defines what kind of data is requested.\r\n\t *\r\n\t *    @return QVariant Contains the data for the item.\r\n\t */\r\n\tvirtual QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const;\r\n\r\n\t/*!\r\n     *  Save the data to the model for specified item\r\n\t *\r\n\t *    @param [in] index The model index of the item that's data is to be saved.\r\n\t *    @param [in] value The data that is to be saved.\r\n\t *    @param [in] role The role specifies what kind of data should be saved.\r\n\t *\r\n\t *    @return True if saving happened successfully.\r\n\t */\r\n\tbool setData(const QModelIndex& index, const QVariant& value, int role = Qt::EditRole);\r\n\r\n\t/*!\r\n     *  Get the item flags that defines the possible operations for the item.\r\n\t *\r\n\t *    @param [in] index Model index that identifies the item.\r\n\t *\r\n\t *    @return Qt::ItemFlags specify the possible operations for the item.\r\n\t */\r\n\tQt::ItemFlags flags(const QModelIndex& index) const;\r\n\r\n    /*!\r\n     *  Get the list of acceptable mime types.\r\n     *\r\n     *    @return The list of acceptable mime types.\r\n     */\r\n    virtual QStringList mimeTypes() const;\r\n\r\npublic slots:\r\n\r\n\t/*!\r\n     *  A new item should be added to given index.\r\n\t *\r\n\t *    @param [in] index The position where new item should be added at.\r\n\t */\r\n\tvoid onAddItem(const QModelIndex& index);\r\n\r\n\t/*!\r\n     *  An item should be removed from the model.\r\n\t * \r\n\t *    @param [in] index Identifies the item that should be removed.\r\n\t */\r\n\tvoid onRemoveItem(const QModelIndex& index);\r\n    \r\n    /*!\r\n     *  Copy the items in the selected rows.\r\n     *\r\n     *    @param [in] indexList   List of indexes pointing to the selected rows.\r\n     */\r\n    void onCopyRows(QModelIndexList indexList);\r\n\r\n    /*!\r\n     *  Paste the copied items.\r\n     */\r\n    void onPasteRows();\r\n\r\nprotected:\r\n \r\n    /*!\r\n     *  Check if the column index is valid for containing expressions.\r\n     *\r\n     *    @param [in] index   The index being evaluated.\r\n     *\r\n     *    @return     True, if column can have expressions, false otherwise.\r\n     */\r\n    virtual bool isValidExpressionColumn(QModelIndex const& index) const;\r\n\r\n    /*!\r\n     *  Gets the expression for the given index or the plain value if expression is not available.\r\n     *\r\n     *    @param [in] index   The index whose expression to get.\r\n     *\r\n     *    @return The expression for the index if available, otherwise the value for the given index.\r\n     */\r\n    virtual QVariant expressionOrValueForIndex(QModelIndex const& index) const;\r\n    \r\n    /*!\r\n     *  Validates the data in an index.\r\n     *\r\n     *    @param [in] index   The index whose data to validate\r\n     *\r\n     *    @return True, if the data in the index is valid, otherwise false.\r\n     */\r\n    virtual bool validateIndex(QModelIndex const& index) const;\r\n\r\n    /*!\r\n     *  Gets the number of all the references made to a selected id on the selected row.\r\n     *\r\n     *    @param [in] row         The row of the selected item.\r\n     *    @param [in] valueID     The id of the referenced parameter.\r\n     *\r\n     *    @return The amount of references made to the selected id on the selected row.\r\n     */\r\n    virtual int getAllReferencesToIdInItemOnRow(const int& row, QString const& valueID) const;\r\n\r\nsignals:\r\n\r\n\t//! Emitted when contents of the model change\r\n\tvoid contentChanged();\r\n\r\n\t//! Prints an error message to the user.\r\n\tvoid errorMessage(const QString& msg) const;\r\n\t\r\n\t//! Prints a notification to user.\r\n\tvoid noticeMessage(const QString& msg) const;\r\n\r\n\t//! Emitted when a new segment is added to the address space.\r\n\tvoid segmentAdded(QSharedPointer<Segment> segment);\r\n\r\n\t//! Emitted when a segment is removed from the address space.\r\n\tvoid segmentRemoved(const QString& segmentName);\r\n\r\n\t//! Emitted when a segment is renamed.\r\n\tvoid segmentRenamed(const QString& oldName, const QString& newName);\r\n\r\n\t//! Emitted when the range or offset of a segment has changed.\r\n\tvoid segmentChanged(QSharedPointer<Segment> segment);\r\n\r\nprivate:\r\n\t//! No copying.\r\n\tSegmentsModel(const SegmentsModel& other);\r\n\r\n\t//! No assignment.\r\n\tSegmentsModel& operator=(const SegmentsModel& other);\r\n\r\n\t/*! Get the last address of the address space that has segment assigned to it.\r\n\t * \r\n\t * If there are no segments defined then 0 is returned.\r\n\t * \r\n\t *    @return The last address contained in a segment.\r\n\t*/\r\n\tquint64 getLastSegmentedAddress() const;\r\n\r\n    /*!\r\n     *  Get the names of the contained address blocks.\r\n     *\r\n     *    @return The names of the contained address blocks.\r\n     */\r\n    QStringList getCurrentItemNames();\r\n\r\n    /*!\r\n     *  Increase the number of references made in the copied address space segment.\r\n     *\r\n     *    @param [in] pastedSegment           The copied address space segment.\r\n     *    @param [in] referenceCalculator     The reference calculator.\r\n     */\r\n    void increaseReferencesInPastedSegment(QSharedPointer<Segment> pastedSegment,\r\n        ReferenceCalculator& referenceCalculator);\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n\t//! Pointer to the data structure that contains the real segments.\r\n    QSharedPointer<QList<QSharedPointer<Segment> > > segments_;\r\n\r\n    //! Pointer to the used expression formatter.\r\n    QSharedPointer<ExpressionFormatter> expressionFormatter_;\r\n};\r\n\r\n#endif // SEGMENTSMODEL_H\r\n"
  },
  {
    "path": "editors/ComponentEditor/busInterfaces/AbstractionTypesConstants.h",
    "content": "//-----------------------------------------------------------------------------\n// File: AbstractionTypesConstants.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 16.01.2018\n//\n// Description:\n// Common declarations for editing bus interface abstraction types.\n//-----------------------------------------------------------------------------\n\n#ifndef ABSTRACTIONTYPESCONSTANTS_H\n#define ABSTRACTIONTYPESCONSTANTS_H\n\nnamespace AbstractionTypesConstants\n{\n    //! Defines the columns for the abstraction types table.\n    enum Column\n    {\n        ABSTRACTIONDEFINITION = 0,\n        VIEWREFERENCES,\n        COLUMN_COUNT\n    };\n\n    //! Separating string for view references.\n    const QString VIEW_SEPARATOR = QLatin1String(\"; \");\n\n    //! Data role for gaining the VLNV of the referenced abstraction definition.\n    const int ABSTRACTIONVLNVROLE = Qt::UserRole + 1;\n}\n\n#endif //ABSTRACTIONTYPESCONSTANTS_H"
  },
  {
    "path": "editors/ComponentEditor/busInterfaces/AbstractionTypesDelegate.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: AbstractionTypesDelegate.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 16.01.2018\n//\n// Description:\n// The delegate that provides editors to edit bus interface abstraction types.\n//-----------------------------------------------------------------------------\n\n#include \"AbstractionTypesDelegate.h\"\n\n#include <editors/ComponentEditor/busInterfaces/AbstractionTypesConstants.h>\n\n#include <common/widgets/EnumCollectionEditor/EnumCollectionEditor.h>\n#include <common/widgets/vlnvEditor/vlnveditor.h>\n\n#include <IPXACTmodels/Component/Component.h>\n#include <IPXACTmodels/Component/View.h>\n\n#include <QComboBox>\n#include <QPen>\n#include <QPainter>\n\n//-----------------------------------------------------------------------------\n// Function: AbstractionTypesDelegate::AbstractionTypesDelegate()\n//-----------------------------------------------------------------------------\nAbstractionTypesDelegate::AbstractionTypesDelegate(QSharedPointer<Component> component, LibraryInterface* library,\n    QWidget* parentWindow, QObject* parent):\nEnumerationEditorConstructorDelegate(parent),\navailableViews_(component->getViews()),\nlibrary_(library),\nparentWindow_(parentWindow),\ncontainingComponent_(component)\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: AbstractionTypesDelegate::createEditor()\n//-----------------------------------------------------------------------------\nQWidget* AbstractionTypesDelegate::createEditor(QWidget* parent, QStyleOptionViewItem const& option, \n    QModelIndex const& index) const\n{\n    if (index.isValid())\n    {\n        if (index.column() == AbstractionTypesConstants::ABSTRACTIONDEFINITION)\n        {\n            return createVLNVEditor(parent);\n        }\n    }\n\n    return EnumerationEditorConstructorDelegate::createEditor(parent, option, index);\n}\n\n//-----------------------------------------------------------------------------\n// Function: AbstractionTypesDelegate::setEditorData()\n//-----------------------------------------------------------------------------\nvoid AbstractionTypesDelegate::setEditorData(QWidget* editor, QModelIndex const& index) const\n{\n    if (index.isValid() && !index.parent().isValid() && index.column() == AbstractionTypesConstants::ABSTRACTIONDEFINITION)\n    {\n        VLNVEditor* abstractionEditor = dynamic_cast<VLNVEditor*>(editor);\n        QVariant vlnvVariant = index.data(AbstractionTypesConstants::ABSTRACTIONVLNVROLE);\n\n        if (abstractionEditor && vlnvVariant.canConvert<VLNV>())\n        {\n            VLNV vlnvReference = vlnvVariant.value<VLNV>();\n            abstractionEditor->setVLNV(vlnvReference);\n        }\n    }\n\n    else\n    {\n        EnumerationEditorConstructorDelegate::setEditorData(editor, index);\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: AbstractionTypesDelegate::setModelData()\n//-----------------------------------------------------------------------------\nvoid AbstractionTypesDelegate::setModelData(QWidget* editor, QAbstractItemModel* model, QModelIndex const& index )\n    const\n{\n    if (index.isValid() && !index.parent().isValid() && index.column() == AbstractionTypesConstants::ABSTRACTIONDEFINITION)\n    {\n        VLNVEditor* abstractionEditor = dynamic_cast<VLNVEditor*>(editor);\n        if (abstractionEditor)\n        {\n            VLNV abstractionReference = abstractionEditor->getVLNV();\n            QVariant abstractionVariant;\n            abstractionVariant.setValue(abstractionReference);\n\n            model->setData(index, abstractionVariant, Qt::EditRole);\n        }\n    }\n    else\n    {\n        EnumerationEditorConstructorDelegate::setModelData(editor, model, index);\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: AbstractionTypesDelegate::createVLNVEditor()\n//-----------------------------------------------------------------------------\nQWidget* AbstractionTypesDelegate::createVLNVEditor(QWidget* parent) const\n{\n    VLNVEditor* abstractionEditor(new VLNVEditor(\n        VLNV::ABSTRACTIONDEFINITION, library_, parentWindow_, parent));\n\n    abstractionEditor->setFixedHeight(abstractionEditor->sizeHint().height());\n    abstractionEditor->setAutoFillBackground(true);\n    abstractionEditor->setFocusPolicy(Qt::StrongFocus);\n    abstractionEditor->setAttribute(Qt::WA_NoMousePropagation);\n    abstractionEditor->setRevisionFilter(true, containingComponent_->getRevision());\n\n    return abstractionEditor;\n}\n\n//-----------------------------------------------------------------------------\n// Function: AbstractionTypesDelegate::setComponent()\n//-----------------------------------------------------------------------------\nvoid AbstractionTypesDelegate::setComponent(QSharedPointer<Component> newComponent)\n{\n    availableViews_ = newComponent->getViews();\n}\n\n//-----------------------------------------------------------------------------\n// Function: AbstractionTypesDelegate::isEnumerationEditorColumn()\n//-----------------------------------------------------------------------------\nbool AbstractionTypesDelegate::isEnumerationEditorColumn(QModelIndex const& index) const\n{\n    return index.column() == AbstractionTypesConstants::VIEWREFERENCES;\n}\n\n//-----------------------------------------------------------------------------\n// Function: AbstractionTypesDelegate::getCurrentSelection()\n//-----------------------------------------------------------------------------\nQStringList AbstractionTypesDelegate::getCurrentSelection(QModelIndex const& index) const\n{\n    return index.data(Qt::DisplayRole).toString().split(AbstractionTypesConstants::VIEW_SEPARATOR);\n}\n\n//-----------------------------------------------------------------------------\n// Function: AbstractionTypesDelegate::getAvailableItems()\n//-----------------------------------------------------------------------------\nQStringList AbstractionTypesDelegate::getAvailableItems() const\n{\n    QStringList viewNames;\n    for (auto view : *availableViews_)\n    {\n        viewNames.append(view->name());\n    }\n\n    return viewNames;\n}\n\n//-----------------------------------------------------------------------------\n// Function: AbstractionTypesDelegate::setEnumerationDataToModel()\n//-----------------------------------------------------------------------------\nvoid AbstractionTypesDelegate::setEnumerationDataToModel(QModelIndex const& index, QAbstractItemModel* model, QStringList const& selectedItems) const\n{\n    model->setData(index, selectedItems, Qt::EditRole);\n}\n\n"
  },
  {
    "path": "editors/ComponentEditor/busInterfaces/AbstractionTypesDelegate.h",
    "content": "//-----------------------------------------------------------------------------\n// File: AbstractionTypesDelegate.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 16.01.2018\n//\n// Description:\n// The delegate that provides editors to edit bus interface abstraction types.\n//-----------------------------------------------------------------------------\n\n#ifndef ABSTRACTIONTYPESDELEGATE_H\n#define ABSTRACTIONTYPESDELEGATE_H\n\n#include <editors/ComponentEditor/common/EnumerationEditorConstructorDelegate.h>\n\nclass LibraryInterface;\nclass Component;\nclass View;\n\n//-----------------------------------------------------------------------------\n//! The delegate that provides editors to edit bus interface abstraction types.\n//-----------------------------------------------------------------------------\nclass AbstractionTypesDelegate : public EnumerationEditorConstructorDelegate\n{\n    Q_OBJECT\n\npublic:\n\n    /*!\n     *  The constructor.\n     *\n     *    @param [in] component       Component containing the abstraction types.\n     *    @param [in] library         VLNV library interface.\n     *    @param [in] parentWindow    The main window.\n     *    @param [in] parent          The parent object.\n     */\n    AbstractionTypesDelegate(QSharedPointer<Component> component, LibraryInterface* library, QWidget* parentWindow,\n        QObject* parent = 0);\n\n\t/*!\n     *  The destructor.\n     */\n    virtual ~AbstractionTypesDelegate() = default;\n\n    // No copying. No assignment.\n    AbstractionTypesDelegate(AbstractionTypesDelegate const& rhs) = delete;\n    AbstractionTypesDelegate& operator=(AbstractionTypesDelegate const& rhs) = delete;\n\n\t/*!\n     *  Create a new editor for the given item\n\t *\n\t *    @param [in] parent  Owner for the editor.\n\t *    @param [in] option  Contains options for the editor.\n\t *    @param [in] index   Model index identifying the item.\n\t *\n\t *    @return The editor to be used to edit the item.\n     */\n\tQWidget* createEditor(QWidget* parent, QStyleOptionViewItem const& option, QModelIndex const& index) const \n        final;\n\n\t/*!\n     *  Set the data for the editor.\n\t *\n\t *    @param [in] editor  The editor where the data is to be set.\n\t *    @param [in] index   Model index identifying the item that's data is to be set.\n\t */\n\tvoid setEditorData(QWidget* editor, QModelIndex const& index) const final;\n\n\t/*!\n     *  Save the data from the editor to the model.\n\t *\n\t *    @param [in] editor  The editor that contains the data to store.\n\t *    @param [in] model   Model that contains the data structure where data is to be saved to.\n\t *    @param [in] index   Model index identifying the item that's data is to be saved.\n\t */\n\tvoid setModelData(QWidget* editor, QAbstractItemModel* model, QModelIndex const& index) const final;\n\n    /*!\n     *  Set a new component.\n     *\n     *    @param [in] newComponent    The new component.\n     */\n    void setComponent(QSharedPointer<Component> newComponent);\n\nprivate:\n\n    /*!\n     *  Create the VLNV editor for abstraction definition references.\n     *\n     *    @param [in] parent  Parent item for the editor.\n     *\n     *    @return The created VLNV editor.\n     */\n    QWidget* createVLNVEditor(QWidget* parent) const;\n\n    /*!\n     *  Check if the column is used for enumerations.\n     *\n     *    @param [in] index   The selected index.\n     *\n     *    @return True, if the column is used for editing enumerations, false otherwise.\n     */\n    bool isEnumerationEditorColumn(QModelIndex const& index) const final;\n\n    /*!\n     *  The list of currently selected enumerations in the selected item.\n     *\n     *    @param [in] index   Index of the selected item.\n     *\n     *    @return List of currently selected enumerations.\n     */\n    QStringList getCurrentSelection(QModelIndex const& index) const final;\n\n    /*!\n     *  Get the list of the available enumerations.\n     *\n     *    @return List of the available enumerations.\n     */\n    QStringList getAvailableItems() const final;\n\n    /*!\n     *  Set the selected enumerations to the selected item.\n     *\n     *    @param [in] index           Model index identifying the item that's data is to be saved.\n     *    @param [in] model           Model that contains the data structure where data is to be saved to.\n     *    @param [in] selectedItems   List of the selected enumerations.\n     */\n    void setEnumerationDataToModel(QModelIndex const& index, QAbstractItemModel* model, \n        QStringList const& selectedItems) const final;\n\n    //-----------------------------------------------------------------------------\n    // Data.\n    //-----------------------------------------------------------------------------\n\n    //! List of all the referable views.\n    QSharedPointer<QList<QSharedPointer<View> > > availableViews_;\n\n    //! The VLNV library interface.\n    LibraryInterface* library_;\n\n    //! Main window.\n    QWidget* parentWindow_;\n\n    //! Containing component.\n    QSharedPointer<Component> containingComponent_;\n};\n\n#endif // ABSTRACTIONTYPESDELEGATE_H\n"
  },
  {
    "path": "editors/ComponentEditor/busInterfaces/AbstractionTypesEditor.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: AbstractionTypesEditor.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 15.01.2018\n//\n// Description:\n// Editor for the bus interface abstraction definitions.\n//-----------------------------------------------------------------------------\n\n#include \"AbstractionTypesEditor.h\"\n\n#include <IPXACTmodels/Component/Component.h>\n\n#include <common/views/EditableTableView/editabletableview.h>\n\n#include <editors/ComponentEditor/busInterfaces/AbstractionTypesModel.h>\n#include <editors/ComponentEditor/busInterfaces/AbstractionTypesDelegate.h>\n#include <KactusAPI/include/AbstractionTypeInterface.h>\n\n#include <KactusAPI/include/LibraryInterface.h>\n\n#include <QMessageBox>\n#include <QCoreApplication>\n\n#include <QHeaderView>\n#include <QVBoxLayout>\n\n//-----------------------------------------------------------------------------\n// Function: AbstractionTypesEditor::AbstractionTypesEditor()\n//-----------------------------------------------------------------------------\nAbstractionTypesEditor::AbstractionTypesEditor(QSharedPointer<Component> component, LibraryInterface* library,\n    AbstractionTypeInterface* abstractionTypeInterface, QWidget* parentWindow, QWidget* parent):\nQGroupBox(parent),\nabstractionTypeInterface_(abstractionTypeInterface),\nabstractionView_(new EditableTableView(this)),\nabstractionModel_(new AbstractionTypesModel(abstractionTypeInterface_, component, library, this)),\nabstractionDelegate_(new AbstractionTypesDelegate(component, library, parentWindow, this)),\nlibrary_(library)\n{\n    setTitle(QStringLiteral(\"Abstraction definition\"));\n\n    abstractionView_->setModel(abstractionModel_);\n    abstractionView_->setItemDelegate(abstractionDelegate_);\n    abstractionView_->setAlternatingRowColors(false);\n    abstractionView_->setSortingEnabled(false);\n    abstractionView_->horizontalHeader()->setStretchLastSection(true);\n    abstractionView_->setItemsDraggable(false);\n    abstractionView_->viewport()->setAcceptDrops(true); \n    abstractionView_->setDropIndicatorShown(true);   \n    abstractionView_->setDragDropMode(QAbstractItemView::DropOnly);\n\n    connectSignals();\n\n    QVBoxLayout* layout = new QVBoxLayout(this);\n    layout->addWidget(abstractionView_);\n    layout->setContentsMargins(4, 4, 4, 4);\n}\n\n//-----------------------------------------------------------------------------\n// Function: AbstractionTypesEditor::refresh()\n//-----------------------------------------------------------------------------\nvoid AbstractionTypesEditor::refresh()\n{\n    abstractionView_->update();\n    abstractionModel_->resetModel();\n}\n\n//-----------------------------------------------------------------------------\n// Function: AbstractionTypesEditor::stdRevisionMismatchWarning()\n//-----------------------------------------------------------------------------\nvoid AbstractionTypesEditor::stdRevisionMismatchWarning()\n{\n    QMessageBox::warning(this, QCoreApplication::applicationName(),\n        tr(\"Dropped item cannot use different IP-XACT standard revision than the item being edited.\"),\n        QMessageBox::Close, QMessageBox::Close);\n}\n\n//-----------------------------------------------------------------------------\n// Function: AbstractionTypesEditor::connectSignals()\n//-----------------------------------------------------------------------------\nvoid AbstractionTypesEditor::connectSignals()\n{\n    connect(abstractionModel_, SIGNAL(contentChanged()), this, SIGNAL(contentChanged()), Qt::UniqueConnection);\n    connect(abstractionModel_, SIGNAL(dataChanged(QModelIndex const&, QModelIndex const&)),\n        this, SIGNAL(contentChanged()), Qt::UniqueConnection);\n    connect(abstractionModel_, SIGNAL(stdRevisionMismatch()),\n        this, SLOT(stdRevisionMismatchWarning()), Qt::UniqueConnection);\n\n    connect(abstractionView_, SIGNAL(addItem(QModelIndex const&)),\n        abstractionModel_, SLOT(onAddItem(QModelIndex const&)), Qt::UniqueConnection);\n    connect(abstractionView_, SIGNAL(removeItem(QModelIndex const&)),\n        abstractionModel_, SLOT(onRemoveItem(QModelIndex const&)), Qt::UniqueConnection);\n}\n\n//-----------------------------------------------------------------------------\n// Function: AbstractionTypesEditor::setComponent()\n//-----------------------------------------------------------------------------\nvoid AbstractionTypesEditor::setComponent(QSharedPointer<Component> newComponent)\n{\n    abstractionDelegate_->setComponent(newComponent);\n}\n\n//-----------------------------------------------------------------------------\n// Function: AbstractionTypesEditor::setBusForModel()\n//-----------------------------------------------------------------------------\nvoid AbstractionTypesEditor::setBusForModel()\n{\n    abstractionModel_->onChangeSelectedBusInterface();\n    abstractionView_->resizeColumnsToContents();\n}\n\n//-----------------------------------------------------------------------------\n// Function: AbstractionTypesEditor::addNewAbstraction()\n//-----------------------------------------------------------------------------\nvoid AbstractionTypesEditor::addNewAbstraction(VLNV const& newAbstraction)\n{\n    abstractionModel_->addNewAbstractionTypeWithVLNV(newAbstraction);\n}\n"
  },
  {
    "path": "editors/ComponentEditor/busInterfaces/AbstractionTypesEditor.h",
    "content": "//-----------------------------------------------------------------------------\n// File: AbstractionTypesEditor.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 15.01.2018\n//\n// Description:\n// Editor for the bus interface abstraction definitions.\n//-----------------------------------------------------------------------------\n\n#ifndef ABSTRACTIONTYPESEDITOR_H\n#define ABSTRACTIONTYPESEDITOR_H\n\n#include <QWidget>\n#include <QGroupBox>\n\nclass AbstractionTypesModel;\nclass AbstractionTypesDelegate;\nclass EditableTableView;\nclass BusInterface;\nclass Component;\nclass ConfigurableVLNVReference;\nclass LibraryInterface;\nclass VLNV;\nclass AbstractionTypeInterface;\n\n//-----------------------------------------------------------------------------\n//! Editor for the bus interface abstraction definitions.\n//-----------------------------------------------------------------------------\nclass AbstractionTypesEditor : public QGroupBox\n{\n\tQ_OBJECT\n\npublic:\n\n\t/*!\n     *  The constructor.\n\t *\n     *    @param [in] component                   Component containing the edited port.\n     *    @param [in] library                     Interface for the VLNV library.\n     *    @param [in] abstractionTypeInterface    Interface for accessing abstraction types.\n     *    @param [in] parentWindow                The main window.\n\t *    @param [in] parent                      The owner of the editor.\n\t */\n    AbstractionTypesEditor(QSharedPointer<Component> component,\n        LibraryInterface* library,\n        AbstractionTypeInterface* abstractionTypeInterface,\n        QWidget* parentWindow,\n        QWidget* parent);\n\n\t/*!\n     *  The destructor.\n     */\n    virtual ~AbstractionTypesEditor() = default;\n\n    //! No copying. No assignment.\n    AbstractionTypesEditor(const AbstractionTypesEditor& other) = delete;\n    AbstractionTypesEditor& operator=(const AbstractionTypesEditor& other) = delete;\n\n    /*!\n     *  Set a new component.\n     *\n     *    @param [in] newComponent    The selected component.\n     */\n    void setComponent(QSharedPointer<Component> newComponent);\n\n    /*!\n     *  Set a new bus interface for the abstraction types model.\n     */\n    void setBusForModel();\n\n    /*!\n     *  Add a new abstraction definition referencing the selected VLNV to the bus interface.\n     *\n     *    @param [in] newAbstraction  The selected VLNV.\n     */\n    void addNewAbstraction(VLNV const& newAbstraction);\n\n    /*!\n     *  Reload the data in the editor.\n     */\n    void refresh();\n\nsignals:\n\n    /*!\n     *  Signal for informing changes in content.\n     */\n    void contentChanged();\n\npublic slots:\n\n    /*!\n     *  Displays warning message when trying to drag and drop an absDef using different standard revision.\n     */\n    void stdRevisionMismatchWarning();\n    \nprivate:\n    /*!\n     *  Connect the signals.\n     */\n    void connectSignals();\n\n    //-----------------------------------------------------------------------------\n    // Data.\n    //-----------------------------------------------------------------------------\n\n    //! Interface for accessing abstraction types.\n    AbstractionTypeInterface* abstractionTypeInterface_;\n\n    //! The abstraction types view.\n    EditableTableView* abstractionView_;\n\n    //! The model containing data of the abstraction types.\n    AbstractionTypesModel* abstractionModel_;\n\n    //! Delegate for handling the abstraction types data.\n    AbstractionTypesDelegate* abstractionDelegate_;\n\n    //! Interface for the VLNV library.\n    LibraryInterface* library_;\n};\n\n#endif // ABSTRACTIONTYPESEDITOR_H\n"
  },
  {
    "path": "editors/ComponentEditor/busInterfaces/AbstractionTypesModel.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: AbstractionTypesModel.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 15.01.2018\n//\n// Description:\n// Table model for bus interface abstraction types.\n//-----------------------------------------------------------------------------\n\n#include \"AbstractionTypesModel.h\"\n\n#include <common/KactusColors.h>\n\n#include <editors/ComponentEditor/busInterfaces/AbstractionTypesConstants.h>\n#include <KactusAPI/include/AbstractionTypeInterface.h>\n#include <KactusAPI/include/LibraryInterface.h>\n\n#include <IPXACTmodels/common/DocumentUtils.h>\n#include <IPXACTmodels/Component/Component.h>\n#include <IPXACTmodels/Component/BusInterface.h>\n#include <IPXACTmodels/Component/AbstractionType.h>\n#include <IPXACTmodels/Component/validators/AbstractionTypeValidator.h>\n\n#include <QFont>\n#include <QMimeData>\n\n//-----------------------------------------------------------------------------\n// Function: AbstractionTypesModel::AbstractionTypesModel()\n//-----------------------------------------------------------------------------\nAbstractionTypesModel::AbstractionTypesModel(AbstractionTypeInterface* abstractionInterface, \n    QSharedPointer<Component> component, LibraryInterface* library, QObject* parent) :\nQAbstractTableModel(parent),\nabstractionInterface_(abstractionInterface),\ncontainingComponent_(component),\nlibrary_(library)\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: AbstractionTypesModel::~AbstractionTypesModel()\n//-----------------------------------------------------------------------------\nAbstractionTypesModel::~AbstractionTypesModel()\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: AbstractionTypesModel::rowCount()\n//-----------------------------------------------------------------------------\nint AbstractionTypesModel::rowCount(const QModelIndex& parent) const\n{\n    if (parent.isValid())\n    {\n        return 0;\n    }\n\n    return abstractionInterface_->itemCount();\n}\n\n//-----------------------------------------------------------------------------\n// Function: AbstractionTypesModel::columnCount()\n//-----------------------------------------------------------------------------\nint AbstractionTypesModel::columnCount(const QModelIndex& /*parent*/) const\n{\n    return AbstractionTypesConstants::COLUMN_COUNT;\n}\n\n//-----------------------------------------------------------------------------\n// Function: AbstractionTypesModel::headerData()\n//-----------------------------------------------------------------------------\nQVariant AbstractionTypesModel::headerData(int section, Qt::Orientation orientation, int role) const\n{\n    if (role == Qt::DisplayRole && orientation == Qt::Horizontal)\n    {\n        if (section == AbstractionTypesConstants::ABSTRACTIONDEFINITION)\n        {\n            return tr(\"Abstraction definition\");\n        }\n        else if (section == AbstractionTypesConstants::VIEWREFERENCES)\n        {\n            return tr(\"View references\");\n        }\n    }\n\n    return QVariant();\n}\n\n//-----------------------------------------------------------------------------\n// Function: AbstractionTypesModel::data()\n//-----------------------------------------------------------------------------\nQVariant AbstractionTypesModel::data(QModelIndex const& index, int role) const\n{\n    if (!index.isValid() || index.row() < 0 || index.row() >= abstractionInterface_->itemCount())\n    {\n\t\treturn QVariant();\n\t}\n\n    bool rowHasAbstraction = abstractionInterface_->hasAbstractionReference(index.row());\n\n    if (role == AbstractionTypesConstants::ABSTRACTIONVLNVROLE && rowHasAbstraction)\n    {\n        VLNV abstractionVLNV = *abstractionInterface_->getAbstractionReference(index.row()).data();\n        return QVariant::fromValue(abstractionVLNV);\n    }\n    else if (role == Qt::DisplayRole || role == Qt::EditRole || role == Qt::ToolTipRole)\n    {\n        if (index.column() == AbstractionTypesConstants::ABSTRACTIONDEFINITION)\n        {\n            QString abstractionString(\"\");\n            if (rowHasAbstraction)\n            {\n                abstractionString =\n                    QString::fromStdString(abstractionInterface_->getIndexedAbstraction(index.row()));\n            }\n\n            return abstractionString;\n        }\n        else if (index.column() == AbstractionTypesConstants::VIEWREFERENCES)\n        {\n            return QString::fromStdString(abstractionInterface_->getCombinedViews(index.row()));\n        }\n    }\n    else if (Qt::ForegroundRole == role)\n    {\n        return blackForValidRedForInvalid(index);\n    }\n    else if (role == Qt::BackgroundRole)\n    {\n        if (index.column() == AbstractionTypesConstants::ABSTRACTIONDEFINITION)\n        {\n            return KactusColors::MANDATORY_FIELD;\n        }\n        else\n        {\n            return KactusColors::REGULAR_FIELD;\n        }\n    }\n    else if (!index.parent().isValid() && role == Qt::FontRole)\n    {\n        QFont font;\n        font.setBold(true);\n        return font;\n    }\n    \n    return QVariant();\n}\n\n//-----------------------------------------------------------------------------\n// Function: AbstractionTypesModel::setData()\n//-----------------------------------------------------------------------------\nbool AbstractionTypesModel::setData(QModelIndex const& index, QVariant const& value, int role)\n{\n    if (!index.isValid() || index.row() < 0)\n    {\n\t\treturn false;\n    }\n    else if (data(index, Qt::DisplayRole) == value)\n    {\n        return true;\n    }\n\n\tif (role == Qt::EditRole)\n    {\n        if (index.column() == AbstractionTypesConstants::ABSTRACTIONDEFINITION && value.canConvert<VLNV> ())\n        {\n            VLNV newAbstractionReference = value.value<VLNV>();\n\n            std::string referenceVendor = newAbstractionReference.getVendor().toStdString();\n            std::string referenceLibrary = newAbstractionReference.getLibrary().toStdString();\n            std::string referenceName = newAbstractionReference.getName().toStdString();\n            std::string referenceVersion = newAbstractionReference.getVersion().toStdString();\n\n            abstractionInterface_->setAbstraction(\n                index.row(), referenceVendor, referenceLibrary, referenceName, referenceVersion);\n        }\n\n        else if (index.column() == AbstractionTypesConstants::VIEWREFERENCES)\n        {\n            std::vector<std::string> newViews;\n            for (auto view : value.toStringList())\n            {\n                newViews.push_back(view.toStdString());\n            }\n\n            abstractionInterface_->setViewReferences(index.row(), newViews);\n        }\n\n        emit dataChanged(index, index);\n        return true;\n    }\n\n    return false;\n}\n\n//-----------------------------------------------------------------------------\n// Function: AbstractionTypesModel::setVLNVForAbstraction()\n//-----------------------------------------------------------------------------\nvoid AbstractionTypesModel::setVLNVForAbstraction(int const& abstractionIndex, VLNV const& newVLNV)\n{\n    std::string referenceVendor = newVLNV.getVendor().toStdString();\n    std::string referenceLibrary = newVLNV.getLibrary().toStdString();\n    std::string referenceName = newVLNV.getName().toStdString();\n    std::string referenceVersion = newVLNV.getVersion().toStdString();\n\n    abstractionInterface_->setAbstraction(\n        abstractionIndex, referenceVendor, referenceLibrary, referenceName, referenceVersion);\n}\n\n//-----------------------------------------------------------------------------\n// Function: AbstractionTypesModel::onAddItem()\n//-----------------------------------------------------------------------------\nvoid AbstractionTypesModel::onAddItem(QModelIndex const& index)\n{\n    int row = abstractionInterface_->itemCount();\n\n    if (index.isValid())\n    {\n        row = index.row();\n    }\n\n    beginInsertRows(QModelIndex(), row, row);\n\n    abstractionInterface_->addAbstraction(row);\n\n    endInsertRows();\n\n    emit contentChanged();\n}\n\n//-----------------------------------------------------------------------------\n// Function: AbstractionTypesModel::onRemoveItem()\n//-----------------------------------------------------------------------------\nvoid AbstractionTypesModel::onRemoveItem(QModelIndex const& index)\n{\n    if (!index.isValid() || index.row() < 0 || index.row() >= abstractionInterface_->itemCount())\n    {\n        return;\n    }\n\n    beginRemoveRows(QModelIndex(), index.row(), index.row());\n\n    abstractionInterface_->removeAbstraction(index.row());\n\n    endRemoveRows();\n\n    emit contentChanged();\n}\n\n//-----------------------------------------------------------------------------\n// Function: AbstractionTypesModel::onChangeSelectedBusInterface()\n//-----------------------------------------------------------------------------\nvoid AbstractionTypesModel::onChangeSelectedBusInterface()\n{\n    beginResetModel();\n    endResetModel();\n}\n\n//-----------------------------------------------------------------------------\n// Function: AbstractionTypesModel::flags()\n//-----------------------------------------------------------------------------\nQt::ItemFlags AbstractionTypesModel::flags(const QModelIndex& index) const\n{\n    if (!index.isValid())\n    {\n        return Qt::ItemIsDropEnabled;\n    }\n    else if (index.column() == AbstractionTypesConstants::ABSTRACTIONDEFINITION)\n    {\n        return Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsEditable | Qt::ItemIsDropEnabled;\n    }\n\n\treturn Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsEditable;\n}\n\n//-----------------------------------------------------------------------------\n// Function: AbstractionTypesModel::supportedDropActions()\n//-----------------------------------------------------------------------------\nQt::DropActions AbstractionTypesModel::supportedDropActions() const\n{\n    return Qt::CopyAction | Qt::MoveAction;\n}\n\n//-----------------------------------------------------------------------------\n// Function: AbstractionTypesModel::mimeTypes()\n//-----------------------------------------------------------------------------\nQStringList AbstractionTypesModel::mimeTypes() const\n{\n    QStringList types(QAbstractTableModel::mimeTypes());\n    types << \"application/x-qt-image\";\n    return types;\n}\n\n//-----------------------------------------------------------------------------\n// Function: AbstractionTypesModel::dropMimeData()\n//-----------------------------------------------------------------------------\nbool AbstractionTypesModel::dropMimeData(QMimeData const* data, Qt::DropAction action, int row, int column,\n    QModelIndex const& parent)\n{\n    if (action == Qt::IgnoreAction)\n    {\n        return true;\n    }\n    if (row != -1 || column != -1)\n    {\n        return false;\n    }\n\n    QVariant variant = data->imageData();\n    if (!variant.canConvert<VLNV>())\n    {\n        return false;\n    }\n\n    VLNV vlnv = variant.value<VLNV>();\n    if (vlnv.getType() != VLNV::ABSTRACTIONDEFINITION)\n    {\n        return false;\n    }\n\n    // Check compatibility of drag & dropped abstraction definition.\n    if (!DocumentUtils::documentsHaveMatchingStdRevisions(vlnv, containingComponent_->getVlnv(), library_))\n    {\n        emit stdRevisionMismatch();\n        return false;\n    }\n\n    QModelIndex abstractionIndex = parent;\n    if (!parent.isValid())\n    {\n        onAddItem(QModelIndex());\n\n        abstractionIndex =\n            index(abstractionInterface_->itemCount() - 1, AbstractionTypesConstants::ABSTRACTIONDEFINITION);\n    }\n\n    if (abstractionIndex.column() == AbstractionTypesConstants::ABSTRACTIONDEFINITION)\n    {\n        setData(abstractionIndex, variant);\n        emit contentChanged();\n    }\n\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: AbstractionTypesModel::addNewAbstractionTypeWithVLNV()\n//-----------------------------------------------------------------------------\nvoid AbstractionTypesModel::addNewAbstractionTypeWithVLNV(VLNV const& newAbstractionVLNV)\n{\n    onAddItem(QModelIndex());\n\n    int newAbstractionIndex = abstractionInterface_->itemCount() - 1;\n\n    std::string referenceVendor = newAbstractionVLNV.getVendor().toStdString();\n    std::string referenceLibrary = newAbstractionVLNV.getLibrary().toStdString();\n    std::string referenceName = newAbstractionVLNV.getName().toStdString();\n    std::string referenceVersion = newAbstractionVLNV.getVersion().toStdString();\n\n    abstractionInterface_->setAbstraction(\n        newAbstractionIndex, referenceVendor, referenceLibrary, referenceName, referenceVersion);\n}\n\n//-----------------------------------------------------------------------------\n// Function: AbstractionTypesModel::blackForValidRedForInvalid()\n//-----------------------------------------------------------------------------\nQVariant AbstractionTypesModel::blackForValidRedForInvalid(QModelIndex const& index) const\n{\n    if (validateIndex(index))\n    {\n        return KactusColors::REGULAR_TEXT;\n    }\n    else\n    {\n        return KactusColors::ERROR;\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: AbstractionTypesModel::validateIndex()\n//-----------------------------------------------------------------------------\nbool AbstractionTypesModel::validateIndex(QModelIndex const& index) const\n{\n    if (index.column() == AbstractionTypesConstants::ABSTRACTIONDEFINITION)\n    {\n        return abstractionInterface_->hasValidAbstractionReference(index.row());\n    }\n    else if (index.column() == AbstractionTypesConstants::VIEWREFERENCES)\n    {\n        return abstractionInterface_->hasValidViewReferences(index.row());\n    }\n\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: AbstractionTypesModel::resetModel()\n//-----------------------------------------------------------------------------\nvoid AbstractionTypesModel::resetModel()\n{\n    beginResetModel();\n    endResetModel();\n}\n"
  },
  {
    "path": "editors/ComponentEditor/busInterfaces/AbstractionTypesModel.h",
    "content": "//-----------------------------------------------------------------------------\n// File: AbstractionTypesModel.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 15.01.2018\n//\n// Description:\n// Table model for bus interface abstraction types.\n//-----------------------------------------------------------------------------\n\n#ifndef ABSTRACTIONTYPESMODEL_H\n#define ABSTRACTIONTYPESMODEL_H\n\n#include <IPXACTmodels/common/ConfigurableVLNVReference.h>\n#include <IPXACTmodels/common/VLNV.h>\n\n#include <IPXACTmodels/common/Document.h>\n\n#include <QAbstractTableModel>\n#include <QSharedPointer>\n\nclass BusInterface;\nclass AbstractionType;\nclass AbstractionTypeValidator;\nclass AbstractionTypeInterface;\nclass Component;\nclass LibraryInterface;\n\n//-----------------------------------------------------------------------------\n//! Table model for bus interface abstraction types.\n//-----------------------------------------------------------------------------\nclass AbstractionTypesModel : public QAbstractTableModel\n{\n    Q_OBJECT\n\npublic:\n\n\t/*!\n     *  The constructor.\n\t *\n     *    @param [in] abstractionInterface    Interface for accessing abstraction types.\n     *    @param [in] component               The conaining component.\n\t *    @param [in] parent                  Pointer to the owner of this model.\n     */\n    AbstractionTypesModel(AbstractionTypeInterface* abstractionInterface, QSharedPointer<Component> component, \n        LibraryInterface* library, QObject* parent);\n\n\t/*!\n     *  The destructor.\n     */\n    virtual ~AbstractionTypesModel();\n\n\t/*!\n     *  Get the number of rows in the model.\n\t *\n\t *    @param [in] parent  Model index of the parent of the item.\n\t *\n\t *    @return Number of rows currently in the model.\n     */\n\tvirtual int rowCount(const QModelIndex& parent = QModelIndex() ) const;\n\n\t/*!\n     *  Get the number of columns in the model.\n\t *\n\t *    @param [in] parent  Model index of the parent of the item.\n\t *\n\t *    @return Always returns 2.\n     */\n\tvirtual int columnCount(const QModelIndex& parent = QModelIndex() ) const;\n\n    /*!\n     *  Get the data for the headers.\n\t *\n\t *    @param [in] section         The column that's header is wanted.\n\t *    @param [in] orientation     Only Qt::Horizontal is supported.\n\t *    @param [in] role            Specified the type of data that is wanted.\n\t *\n\t *    @return QVariant containing the data to be displayed.\n\t */\n\tvirtual QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole ) const;\n\n\t/*!\n     *  Get the data for the specified item for specified role.\n\t *\n\t *    @param [in] index   Identifies the item that's data is wanted.\n\t *    @param [in] role    Specifies what kind of data is wanted.\n\t *\n\t *    @return QVariant containing the data.\n     */\n\tvirtual QVariant data(const QModelIndex& index, int role = Qt::DisplayRole ) const;\n\n\t/*!\n     *  Set the data for specified item.\n\t *\n\t *    @param [in] index   Specifies the item that's data is modified.\n\t *    @param [in] value   The value to be set.\n\t *    @param [in] role    The role that is trying to modify the data. Only Qt::EditRole is supported.\n\t *\n\t *    @return True if data was successfully set.\n\t */\n\tvirtual bool setData(QModelIndex const& index, QVariant const& value, int role = Qt::EditRole);\n    \n    /*!\n     *  Get information on how specified item can be handled.\n\t *\n\t *    @param [in] index   Specifies the item that's flags are wanted.\n\t *\n\t *    @return Qt::ItemFlags that define how object can be handled.\n     */\n\tvirtual Qt::ItemFlags flags(const QModelIndex& index) const;\n\n    /*!\n     *  Change the currently edited bus interface.\n     */\n    void onChangeSelectedBusInterface();\n\n    /*!\n     *  Returns the supported actions of a drop.\n     *\n     *    @return The drop actions supported by the model.\n     */\n    Qt::DropActions supportedDropActions() const;\n\n    /*!\n     *  Returns a list of supported MIME data types.\n     *\n     *    @return The supported MIME types.\n     */\n    QStringList mimeTypes() const;\n\n    /*!\n     *  Handler for the dropped MIME data.\n     *\n     *    @param [in] data    The data associated to the drop.\n     *    @param [in] action  The drop action.  \n     *    @param [in] row     The row beneath the drop position.\n     *    @param [in] column  The column beneath the drop position.\n     *    @param [in] parent  The parent index of the drop position.\n     *\n     *    @return True, if the model could handle the data, otherwise false.\n     */\n    bool dropMimeData(QMimeData const* data, Qt::DropAction action, int row, int column,\n        QModelIndex const& parent);\n\n    /*!\n     *  Add a new abstraction type referencing the selected abstraction definition VLNV.\n     *\n     *    @param [in] newAbstractionVLNV  The selected abstraction definition VLNV.\n     */\n    void addNewAbstractionTypeWithVLNV(VLNV const& newAbstractionVLNV);\n\n    /*!\n     *  Reset the model.\n     */\n    void resetModel();\n\npublic slots:\n\n\t/*!\n     *  Handles the addition of new abstraction types.\n\t *\n\t *    @param [in] index   Index of the new abstraction type.\n     */\n    virtual void onAddItem(QModelIndex const& index);\n\n\t/*!\n     *  Handles the removal of abstraction types.\n\t * \n\t *    @param [in] index   Identifies the abstraction type that should be removed.\n     */\n    virtual void onRemoveItem(QModelIndex const& index);\n\nsignals:\n\n\t/*!\n     *  Emitted when contents of the model change\n     */\n\tvoid contentChanged();\n\n\t/*!\n     *  Prints an error message to the user.\n     */\n\tvoid errorMessage(const QString& msg) const;\n\t\n\t/*!\n     *  Prints a notification to user.\n     */\n\tvoid noticeMessage(const QString& msg) const;\n\n    /*!\n     *  Emitted when a abstraction def with different std revision is dropped in the editor.\n     */\n    void stdRevisionMismatch() const;\n\nprivate:\n\t\n\t//! No copying. No assignment.\n    AbstractionTypesModel(const AbstractionTypesModel& other);\n    AbstractionTypesModel& operator=(const AbstractionTypesModel& other);\n\n    /*!\n     *  Get the color for the indexed abstraction type.\n     *\n     *    @param [in] index           The selected index.\n     *\n     *    @return Black for valid index, red for invalid index.\n     */\n    QVariant blackForValidRedForInvalid(QModelIndex const& index) const;\n\n    /*!\n     *  Validate the indexed abstraction type.\n     *\n     *    @param [in] index           The selected index.\n     *\n     *    @return True, if the indexed abstraction type is valid, false otherwise.\n     */\n    bool validateIndex(QModelIndex const& index) const;\n\n    /*!\n     *  Set a new abstraction reference to the selected abstraction type.\n     *\n     *    @param [in] abstractionIndex    Index of the selected abstraction type.\n     *    @param [in] newVLNV             VLNV of the new abstraction reference.\n     */\n    void setVLNVForAbstraction(int const& abstractionIndex, VLNV const& newVLNV);\n\n    //-----------------------------------------------------------------------------\n    // Data.\n    //-----------------------------------------------------------------------------\n\n    //! Interface for accessing abstraction types.\n    AbstractionTypeInterface* abstractionInterface_;\n\n    //! The containing component.\n    QSharedPointer<Component> containingComponent_;\n\n    //! The library handler.\n    LibraryInterface* library_;\n};\n\n#endif // ABSTRACTIONTYPESMODEL_H\n"
  },
  {
    "path": "editors/ComponentEditor/busInterfaces/BusInterfaceColumns.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: BusInterfaceColumns.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Esko Pekkarinen\r\n// Date: 27.07.2015\r\n//\r\n// Description:\r\n// Common declarations for editing bus interfaces table columns.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef BUS_INTERFACE_COLUMNS_H\r\n#define BUS_INTERFACE_COLUMNS_H\r\n\r\nnamespace BusInterfaceColumns\r\n{\r\n    //! Defines the columns for the bus interfaces table.\r\n    enum Column {\r\n        NAME = 0,\r\n        BUSDEF,\r\n        ABSDEF,\r\n        INTERFACE_MODE,\r\n        DESCRIPTION,\r\n        COLUMN_COUNT\r\n    };\r\n}\r\n\r\n#endif //BUS_INTERFACE_COLUMNS_H"
  },
  {
    "path": "editors/ComponentEditor/busInterfaces/businterfaceeditor.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: businterfaceeditor.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 05.04.2011\r\n//\r\n// Description:\r\n// Container for editors to edit a bus interface.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"businterfaceeditor.h\"\r\n\r\n#include <IPXACTmodels/Component/Component.h>\r\n#include <IPXACTmodels/Component/BusInterface.h>\r\n#include <IPXACTmodels/Component/validators/AbstractionTypeValidator.h>\r\n\r\n#include <KactusAPI/include/BusInterfaceInterface.h>\r\n#include <KactusAPI/include/AbstractionTypeInterface.h>\r\n\r\n#include <QHBoxLayout>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusInterfaceEditor::BusInterfaceEditor()\r\n//-----------------------------------------------------------------------------\r\nBusInterfaceEditor::BusInterfaceEditor(LibraryInterface* libHandler, QSharedPointer<Component> component,\r\n    QSharedPointer<BusInterface> busif, ExpressionSet expressions,\r\n    BusInterfaceInterface* busInterface,\r\n    PortMapInterface* portMapInterface, QWidget* parent, QWidget* parentWnd):\r\nParameterItemEditor(component, libHandler, parent),\r\ntabs_(this), \r\ngeneralEditor_(libHandler, busif, component, expressions, busInterface,\r\n    busif->name().toStdString(), &tabs_, parentWnd),\r\nportmapsEditor_(libHandler, component, busInterface, busif->name().toStdString(), expressions.parser,\r\n    expressions.finder, portMapInterface, &tabs_)\r\n{\r\n\tQ_ASSERT(component);\r\n\tQ_ASSERT(libHandler);\r\n\r\n\tQHBoxLayout* layout = new QHBoxLayout(this);\r\n\tlayout->addWidget(&tabs_);\r\n\tlayout->setContentsMargins(0, 0, 0, 0);\r\n\r\n\ttabs_.addTab(&generalEditor_, tr(\"General\"));\r\n\ttabs_.addTab(&portmapsEditor_, tr(\"Port maps\"));\r\n\r\n\tconnect(&portmapsEditor_, SIGNAL(contentChanged()), this, SIGNAL(contentChanged()), Qt::UniqueConnection);\r\n\tconnect(&portmapsEditor_, SIGNAL(errorMessage(QString const&)),\r\n        this, SIGNAL(errorMessage(QString const&)), Qt::UniqueConnection);\r\n\tconnect(&portmapsEditor_, SIGNAL(noticeMessage(QString const&)),\r\n        this, SIGNAL(noticeMessage(QString const&)), Qt::UniqueConnection);\r\n    connect(&portmapsEditor_, SIGNAL(helpUrlRequested(QString const&)),\r\n            this, SIGNAL(helpUrlRequested(QString const&)), Qt::UniqueConnection);\r\n\r\n    connect(&portmapsEditor_, SIGNAL(increaseReferences(QString)), this,\r\n        SIGNAL(increaseReferences(QString)), Qt::UniqueConnection);\r\n    connect(&portmapsEditor_, SIGNAL(decreaseReferences(QString)),\r\n        this, SIGNAL(decreaseReferences(QString)), Qt::UniqueConnection);\r\n\r\n\tconnect(&generalEditor_, SIGNAL(contentChanged()), this, SIGNAL(contentChanged()), Qt::UniqueConnection);\r\n\tconnect(&generalEditor_, SIGNAL(errorMessage(QString const&)),\r\n\t\tthis, SIGNAL(errorMessage(QString const&)), Qt::UniqueConnection);\r\n\tconnect(&generalEditor_, SIGNAL(noticeMessage(QString const&)),\r\n\t\tthis, SIGNAL(noticeMessage(QString const&)), Qt::UniqueConnection);\r\n\tconnect(&generalEditor_, SIGNAL(helpUrlRequested(QString const&)),\r\n\t\tthis, SIGNAL(helpUrlRequested(QString const&)), Qt::UniqueConnection);\r\n\r\n    connect(&generalEditor_, SIGNAL(nameChanged(std::string const&)),\r\n        &portmapsEditor_, SLOT(changeBusName(std::string const&)), Qt::UniqueConnection);\r\n\r\n    connect(&generalEditor_, SIGNAL(increaseReferences(QString)), this,\r\n        SIGNAL(increaseReferences(QString)), Qt::UniqueConnection);\r\n    connect(&generalEditor_, SIGNAL(decreaseReferences(QString)),\r\n        this, SIGNAL(decreaseReferences(QString)), Qt::UniqueConnection);\r\n    connect(&generalEditor_, SIGNAL(openReferenceTree(QString const&, QString const&)),\r\n        this, SIGNAL(openReferenceTree(QString const&, QString const&)), Qt::UniqueConnection);\r\n\r\n    connect(&generalEditor_,\r\n        SIGNAL(recalculateReferencesToParameters(QVector<QString> const&, AbstractParameterInterface*)),\r\n        this,\r\n        SIGNAL(recalculateReferencesToParameters(QVector<QString> const&, AbstractParameterInterface*)),\r\n        Qt::UniqueConnection);\r\n\r\n\tconnect(&tabs_, SIGNAL(currentChanged(int)), this, SLOT(onTabChange(int)), Qt::UniqueConnection);\r\n\r\n\trefresh();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusInterfaceEditor::~BusInterfaceEditor()\r\n//-----------------------------------------------------------------------------\r\nBusInterfaceEditor::~BusInterfaceEditor()\r\n{\r\n\ttabs_.disconnect();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusInterfaceEditor::onTabChange()\r\n//-----------------------------------------------------------------------------\r\nvoid BusInterfaceEditor::onTabChange(int index)\r\n{\r\n\t// if port maps tab is selected\r\n\tif (index == 1)\r\n    {\r\n        portmapsEditor_.setAbstractionDefinitions();\r\n\t}\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusInterfaceEditor::refresh()\r\n//-----------------------------------------------------------------------------\r\nvoid BusInterfaceEditor::refresh()\r\n{\r\n\tgeneralEditor_.refresh();\r\n\tportmapsEditor_.refresh();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusInterfaceEditor::setProtection()\r\n//-----------------------------------------------------------------------------\r\nvoid BusInterfaceEditor::setProtection(bool locked)\r\n{\r\n    generalEditor_.setDisabled(locked);\r\n    portmapsEditor_.setDisabled(locked);\r\n}\r\n"
  },
  {
    "path": "editors/ComponentEditor/busInterfaces/businterfaceeditor.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: businterfaceeditor.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 05.04.2011\r\n//\r\n// Description:\r\n// Container for editors to edit a bus interface.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef BUSINTERFACEEDITOR_H\r\n#define BUSINTERFACEEDITOR_H\r\n\r\n#include <editors/common/ExpressionSet.h>\r\n#include <editors/ComponentEditor/ParameterItemEditor.h>\r\n#include <editors/ComponentEditor/busInterfaces/general/busifgeneraltab.h>\r\n#include <editors/ComponentEditor/busInterfaces/portmaps/BusInterfacePortMapTab.h>\r\n\r\n#include <KactusAPI/include/ParameterFinder.h>\r\n#include <KactusAPI/include/ExpressionFormatter.h>\r\n#include <KactusAPI/include/ExpressionParser.h>\r\n\r\n#include <IPXACTmodels/Component/validators/BusInterfaceValidator.h>\r\n\r\n#include <QSharedPointer>\r\n#include <QTabWidget>\r\n\r\nclass BusInterface;\r\nclass Component;\r\nclass LibraryInterface;\r\nclass BusInterfaceInterface;\r\nclass PortMapInterface;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Container for editors to edit a bus interface.\r\n//-----------------------------------------------------------------------------\r\nclass BusInterfaceEditor : public ParameterItemEditor\r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\r\n\t/*!\r\n\t *  The constructor.\r\n\t *\r\n\t *    @param [in] libHandler              The library handler instance.\r\n\t *    @param [in] component               The component being edited.\r\n\t *    @param [in] busif                   The bus interface being edited.\r\n\t *    @param [in] parameterFinder         The parameter finder.\r\n\t *    @param [in] expressionFormatter     The expression formatter.\r\n     *    @param [in] expressionParser        The expression parser.\r\n     *    @param [in] busInterface            Interface for accessing bus interfaces.\r\n     *    @param [in] portMapInterface        Interface for accessing port maps.\r\n     *    @param [in] parent                  The owner of this container.\r\n\t *    @param [in] parentWnd               The parent window.\r\n\t */\r\n    BusInterfaceEditor(LibraryInterface* libHandler,\r\n        QSharedPointer<Component> component,\r\n        QSharedPointer<BusInterface> busif,\r\n\t\tExpressionSet expressions,\r\n        BusInterfaceInterface* busInterface,\r\n        PortMapInterface* portMapInterface,\r\n        QWidget* parent,\r\n        QWidget* parentWnd);\r\n\r\n\t//! The destructor\r\n\tvirtual ~BusInterfaceEditor();\r\n\r\n\t/*! Reload the information from the model to the editor.\r\n\t*/\r\n\tvirtual void refresh();\r\n\r\n    /*!\r\n     *  Sets the protection state of the editor.\r\n     *\r\n     *    @param [in] locked  True for locked state; false for unlocked.\r\n     */\r\n    virtual void setProtection(bool locked);\r\n\r\nprivate slots:\r\n\t//! When tab page changes\r\n\tvoid onTabChange(int index);\r\n\r\nprivate:\r\n\t\r\n\t//! No copying\r\n\tBusInterfaceEditor(const BusInterfaceEditor& other);\r\n\r\n\t//! No assignment\r\n\tBusInterfaceEditor& operator=(const BusInterfaceEditor& other);\r\n   \r\n\t//! The widget that contains the editor for bus interface.\r\n\tQTabWidget tabs_;\r\n\r\n\t//! The tab for general settings of bus interface\r\n\tBusIfGeneralTab generalEditor_;\r\n\r\n\t//! The tab for port maps of bus interface\r\n    BusInterfacePortMapTab portmapsEditor_;\r\n};\r\n\r\n#endif // BUSINTERFACEEDITOR_H\r\n"
  },
  {
    "path": "editors/ComponentEditor/busInterfaces/businterfacesdelegate.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: businterfacesdelegate.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 15.06.2012\r\n//\r\n// Description:\r\n// The delegate that provides editors for bus interfaces.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"businterfacesdelegate.h\"\r\n#include \"BusInterfaceColumns.h\"\r\n\r\n#include <common/widgets/interfaceModeSelector/interfacemodeselector.h>\r\n\r\n#include <QLineEdit>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusInterfacesDelegate::BusInterfacesDelegate()\r\n//-----------------------------------------------------------------------------\r\nBusInterfacesDelegate::BusInterfacesDelegate(Document::Revision docRevision, QObject *parent):\r\nMultilineDescriptionDelegate(parent),\r\ndocRevision_(docRevision)\r\n{\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusInterfacesDelegate::createEditor()\r\n//-----------------------------------------------------------------------------\r\nQWidget* BusInterfacesDelegate::createEditor(QWidget* parent, const QStyleOptionViewItem& option, \r\n    QModelIndex const& index) const\r\n{\r\n    if (index.column() == BusInterfaceColumns::NAME)\r\n    {\r\n        QLineEdit* edit = new QLineEdit(parent);\r\n        connect(edit, SIGNAL(editingFinished()), this, SLOT(commitAndCloseEditor()), Qt::UniqueConnection);\r\n        return edit;\r\n    }\r\n    else if (index.column() == BusInterfaceColumns::BUSDEF ||\r\n        index.column() == BusInterfaceColumns::ABSDEF) \r\n    {    \t\t\r\n        Q_ASSERT_X(false, \"BusInterfacesDelegate::createEditor()\", \r\n            \"Attempting to create editor for non-editable index.\");\r\n        return 0;\r\n    }\r\n    else if (index.column() == BusInterfaceColumns::INTERFACE_MODE)\r\n    {\r\n        InterfaceModeSelector* selector = new InterfaceModeSelector(docRevision_, General::INTERFACE_MODE_COUNT,\r\n            true, parent);\r\n        connect(selector, SIGNAL(currentIndexChanged(int)), \r\n            this, SLOT(commitAndCloseEditor()), Qt::UniqueConnection);\r\n        return selector;\r\n    }\r\n    else\r\n    {\r\n        return MultilineDescriptionDelegate::createEditor(parent, option, index);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusInterfacesDelegate::setEditorData()\r\n//-----------------------------------------------------------------------------\r\nvoid BusInterfacesDelegate::setEditorData(QWidget* editor, QModelIndex const& index) const\r\n{\r\n    if (index.column() == BusInterfaceColumns::NAME)\r\n    {\r\n        QLineEdit* edit = qobject_cast<QLineEdit*>(editor);\r\n        Q_ASSERT(edit);\r\n\r\n        const QString text = index.data(Qt::DisplayRole).toString();\r\n        edit->setText(text);\r\n    }\r\n    else if (index.column() == BusInterfaceColumns::BUSDEF ||\r\n        index.column() ==  BusInterfaceColumns::ABSDEF)\r\n    {\r\n        Q_ASSERT(false);\t\t\t\r\n    }\r\n    else if (index.column() == BusInterfaceColumns::INTERFACE_MODE)\r\n    {\r\n        InterfaceModeSelector* selector = qobject_cast<InterfaceModeSelector*>(editor);\r\n        Q_ASSERT(selector);\r\n\r\n        QString modeName = index.data(Qt::DisplayRole).toString();\r\n        selector->setMode(modeName);\r\n    }\r\n    else\r\n    {\r\n        MultilineDescriptionDelegate::setEditorData(editor, index);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusInterfacesDelegate::setModelData()\r\n//-----------------------------------------------------------------------------\r\nvoid BusInterfacesDelegate::setModelData(QWidget* editor, QAbstractItemModel* model, \r\n    QModelIndex const& index) const\r\n{\r\n    if (index.column() == BusInterfaceColumns::NAME)\r\n    {\r\n        QLineEdit* edit = qobject_cast<QLineEdit*>(editor);\r\n        Q_ASSERT(edit);\r\n\r\n        QString text = edit->text();\r\n        model->setData(index, text, Qt::EditRole);\r\n    }\r\n    else if (index.column() == BusInterfaceColumns::BUSDEF || \r\n        index.column() == BusInterfaceColumns::ABSDEF)\r\n    {\r\n        Q_ASSERT(false);\t\t\t\r\n    }\r\n    else if (index.column() == BusInterfaceColumns::INTERFACE_MODE)\r\n    {\r\n        InterfaceModeSelector* selector = qobject_cast<InterfaceModeSelector*>(editor);\r\n        Q_ASSERT(selector);\r\n\r\n        model->setData(index, selector->currentText(), Qt::EditRole);\r\n    }\t\r\n    else\r\n    {\r\n        MultilineDescriptionDelegate::setModelData(editor, model, index);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusInterfacesDelegate::descriptionColumn()\r\n//-----------------------------------------------------------------------------\r\nint BusInterfacesDelegate::descriptionColumn() const\r\n{\r\n    return BusInterfaceColumns::DESCRIPTION;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusInterfacesDelegate::commitAndCloseEditor()\r\n//-----------------------------------------------------------------------------\r\nvoid BusInterfacesDelegate::commitAndCloseEditor()\r\n{\r\n\tQWidget* edit = qobject_cast<QWidget*>(sender());\r\n\tQ_ASSERT(edit);\r\n\r\n\tQComboBox* combo = qobject_cast<QComboBox*>(edit);\r\n\r\n\tif (combo)\r\n    {\r\n\t\temit commitData(combo);\r\n\t}\r\n\telse {\r\n\t\temit commitData(edit);\r\n\t\temit closeEditor(edit);\r\n\t}\r\n}\r\n"
  },
  {
    "path": "editors/ComponentEditor/busInterfaces/businterfacesdelegate.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: businterfacesdelegate.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 15.06.2012\r\n//\r\n// Description:\r\n// The delegate that provides editors for bus interfaces.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef BUSINTERFACESDELEGATE_H\r\n#define BUSINTERFACESDELEGATE_H\r\n\r\n#include <editors/ComponentEditor/common/MultilineDescriptionDelegate.h>\r\n\r\n#include <IPXACTmodels/common/Document.h>\r\n\r\n#include \"BusInterfaceColumns.h\"\r\n\r\n//-----------------------------------------------------------------------------\r\n//! The delegate that provides editors for bus interfaces.\r\n//-----------------------------------------------------------------------------\r\nclass BusInterfacesDelegate : public MultilineDescriptionDelegate\r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\r\n\t/*! The constructor\r\n\t *\r\n\t *    @param [in] parent The owner of the delegate.\r\n\t*/\r\n\tBusInterfacesDelegate(Document::Revision docRevision, QObject *parent);\r\n\t\r\n\t//! The destructor\r\n\tvirtual ~BusInterfacesDelegate() = default;\r\n\r\n    //! No copying\r\n    BusInterfacesDelegate(const BusInterfacesDelegate& other) = delete;\r\n    BusInterfacesDelegate& operator=(const BusInterfacesDelegate& other) = delete;\r\n\r\n\t/*! Create a new editor for the given item\r\n\t *\r\n\t *    @param [in] parent Owner for the editor.\r\n\t *    @param [in] option Contains options for the editor.\r\n\t *    @param [in] index Model index identifying the item.\r\n\t *\r\n\t *    @return The editor to be used to edit the item.\r\n\t*/\r\n\tvirtual QWidget* createEditor(QWidget* parent, const QStyleOptionViewItem& option, \r\n        QModelIndex const& index) const;\r\n\r\n\t/*! Set the data for the editor.\r\n\t *\r\n\t *    @param [in] editor The editor where the data is to be set.\r\n\t *    @param [in] index Model index identifying the item that's data is to be set.\r\n\t *\r\n\t*/\r\n\tvirtual void setEditorData(QWidget* editor, QModelIndex const& index) const;\r\n\r\n\t/*! Save the data from the editor to the model.\r\n\t *\r\n\t *    @param [in] editor The editor that contains the data to store.\r\n\t *    @param [in] model Model that contains the data structure where data is to be saved to.\r\n\t *    @param [in] index Model index identifying the item that's data is to be saved.\r\n\t *\r\n\t*/\r\n\tvirtual void setModelData(QWidget* editor, QAbstractItemModel* model, QModelIndex const& index) const;\r\n\r\nprotected:\r\n\r\n    virtual int descriptionColumn() const;\r\n\r\nprivate slots:\r\n\r\n\t/*! Commit the data from the sending editor and close the editor.\r\n\t *\r\n\t*/\r\n\tvoid commitAndCloseEditor();\r\n\r\nprivate:\r\n\t\r\n\tDocument::Revision docRevision_;\r\n};\r\n\r\n#endif // BUSINTERFACESDELEGATE_H\r\n"
  },
  {
    "path": "editors/ComponentEditor/busInterfaces/businterfaceseditor.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: businterfaceseditor.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 15.06.2012\r\n//\r\n// Description:\r\n// Editor to add/remove/edit the bus interfaces of a component.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"businterfaceseditor.h\"\r\n\r\n#include \"businterfacesdelegate.h\"\r\n\r\n#include <common/widgets/summaryLabel/summarylabel.h>\r\n\r\n#include <KactusAPI/include/LibraryInterface.h>\r\n\r\n#include <IPXACTmodels/Component/Component.h>\r\n\r\n#include <QMessageBox>\r\n#include <QCoreApplication>\r\n#include <QVBoxLayout>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusInterfacesEditor::BusInterfacesEditor()\r\n//-----------------------------------------------------------------------------\r\nBusInterfacesEditor::BusInterfacesEditor(LibraryInterface* handler, QSharedPointer<Component> component,\r\n    BusInterfaceInterface* busInterface, QSharedPointer<ParameterFinder> parameterFinder, QWidget* parent):\r\nItemEditor(component, handler, parent),\r\nview_(this),\r\nproxy_(this),\r\nmodel_(handler, component, parameterFinder, busInterface, this)\r\n{\r\n\tSummaryLabel* summaryLabel = new SummaryLabel(tr(\"Bus interfaces summary\"), this);\r\n\r\n\tQVBoxLayout* layout = new QVBoxLayout(this);\r\n\tlayout->addWidget(summaryLabel, 0, Qt::AlignCenter);\r\n\tlayout->addWidget(&view_);\r\n\tlayout->setContentsMargins(0, 0, 0, 0);\r\n\r\n\tproxy_.setSourceModel(&model_);\r\n\tview_.setModel(&proxy_);\r\n\r\n\tconst QString componentPath = handler->getDirectoryPath(component->getVlnv());\r\n\tQString defaultPath = QString(\"%1/busIfListing.csv\").arg(componentPath);\r\n\tview_.setDefaultImportExportPath(defaultPath);\r\n\tview_.setAllowImportExport(true);\r\n    view_.setAllowElementCopying(true);\r\n\r\n    // Items can be dragged to change positions. Drop is enabled for vlnv columns.\r\n    view_.setItemsDraggable(true);\r\n    view_.viewport()->setAcceptDrops(true); \r\n    view_.setDropIndicatorShown(true);   \r\n    view_.setDragDropMode(QAbstractItemView::DropOnly);\r\n    view_.setItemDelegate(new BusInterfacesDelegate(component->getRevision(), this));\r\n    \r\n\tconnect(&model_, SIGNAL(contentChanged()), this, SIGNAL(contentChanged()), Qt::UniqueConnection);\r\n\tconnect(&model_, SIGNAL(busifAdded(int)), this, SIGNAL(childAdded(int)), Qt::UniqueConnection);\r\n\tconnect(&model_, SIGNAL(busifRemoved(int)),\tthis, SIGNAL(childRemoved(int)), Qt::UniqueConnection);\r\n    connect(&model_, SIGNAL(busIfMoved(int, int)), this, SIGNAL(childMoved(int, int)), Qt::UniqueConnection);\r\n    connect(&model_, SIGNAL(stdRevisionMismatch()), this, SLOT(stdRevisionMismatchWarning()), Qt::UniqueConnection);\r\n\r\n\tconnect(&view_, SIGNAL(addItem(const QModelIndex&)),\r\n        &model_, SLOT(onAddItem(const QModelIndex&)), Qt::UniqueConnection);\r\n\tconnect(&view_, SIGNAL(removeItem(const QModelIndex&)),\r\n\t\t&model_, SLOT(onRemoveItem(const QModelIndex&)), Qt::UniqueConnection);\r\n    connect(&view_, SIGNAL(moveItem(const QModelIndex&, const QModelIndex&)),\r\n        &model_, SLOT(onMoveItem(const QModelIndex&, const QModelIndex&)), Qt::UniqueConnection);\r\n\r\n    connect(&view_, SIGNAL(copyRows(QModelIndexList)),\r\n        &model_, SLOT(onCopyRows(QModelIndexList)), Qt::UniqueConnection);\r\n    connect(&view_, SIGNAL(pasteRows()), &model_, SLOT(onPasteRows()), Qt::UniqueConnection);\r\n\r\n    connect(&model_, SIGNAL(increaseReferences(QString)),\r\n        this, SIGNAL(increaseReferences(QString)), Qt::UniqueConnection);\r\n    connect(&model_, SIGNAL(decreaseReferences(QString)),\r\n        this, SIGNAL(decreaseReferences(QString)), Qt::UniqueConnection);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusInterfacesEditor::refresh()\r\n//-----------------------------------------------------------------------------\r\nvoid BusInterfacesEditor::refresh()\r\n{\r\n\tview_.setModel(&model_);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusInterfacesEditor::stdRevisionMismatchWarning()\r\n//-----------------------------------------------------------------------------\r\nvoid BusInterfacesEditor::stdRevisionMismatchWarning()\r\n{\r\n    QMessageBox::warning(this, QCoreApplication::applicationName(),\r\n        tr(\"Dropped item cannot use different IP-XACT standard revision than the item being edited.\"),\r\n        QMessageBox::Close, QMessageBox::Close);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusInterfacesEditor::showEvent()\r\n//-----------------------------------------------------------------------------\r\nvoid BusInterfacesEditor::showEvent(QShowEvent* event)\r\n{\r\n    QWidget::showEvent(event);\r\n    if (component()->getRevision() == Document::Revision::Std14)\r\n    {\r\n        emit helpUrlRequested(\"componenteditor/businterfaces.html\");\r\n    }\r\n    else if (component()->getRevision() == Document::Revision::Std22)\r\n    {\r\n        emit helpUrlRequested(\"componenteditor/businterfaces2022.html\");\r\n    }\r\n}\r\n"
  },
  {
    "path": "editors/ComponentEditor/busInterfaces/businterfaceseditor.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: businterfaceseditor.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 15.06.2012\r\n//\r\n// Description:\r\n// Editor to add/remove/edit the bus interfaces of a component.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef BUSINTERFACESEDITOR_H\r\n#define BUSINTERFACESEDITOR_H\r\n\r\n#include \"businterfacesmodel.h\"\r\n\r\n#include <common/views/EditableTableView/editabletableview.h>\r\n\r\n#include <editors/ComponentEditor/itemeditor.h>\r\n\r\n#include <QSortFilterProxyModel>\r\n#include <QSharedPointer>\r\n\r\nclass BusInterfaceValidator;\r\nclass Component;\r\nclass LibraryInterface;\r\nclass ParameterFinder;\r\nclass BusInterfaceInterface;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Editor to add/remove/edit the bus interfaces of a component.\r\n//-----------------------------------------------------------------------------\r\nclass BusInterfacesEditor : public ItemEditor\r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\r\n\t//! The width of the name column\r\n\tstatic const int NAME_COLUMN_WIDTH = 100;\r\n\r\n\t//! The width of the bus definition column.\r\n\tstatic const int BUS_COLUMN_WIDTH = 200;\r\n\r\n\t//! The width of the abs def column.\r\n\tstatic const int ABS_COLUMN_WIDTH = 200;\r\n\r\n\t//! The width of the interface mode column.\r\n\tstatic const int IF_MODE_COLUMN_WIDTH = 100;\r\n\r\n\t/*!\r\n\t *  The constructor.\r\n\t *\r\n\t *    @param [in] handler             The instance that manages the library.\r\n\t *    @param [in] component           The component being edited.\r\n     *    @param [in] busInterface        Interface for accessing bus interfaces.\r\n\t *    @param [in] parameterFinder     The parameter finder.\r\n\t *    @param [in] parent              The owner of this editor.\r\n\t */\r\n\tBusInterfacesEditor(LibraryInterface* handler,\r\n        QSharedPointer<Component> component,\r\n        BusInterfaceInterface* busInterface,\r\n        QSharedPointer<ParameterFinder> parameterFinder,\r\n        QWidget* parent = 0);\r\n\t\r\n\t/*!\r\n     *  The destructor.\r\n     */\r\n\tvirtual ~BusInterfacesEditor() = default;\r\n\r\n\t/*!\r\n     *  Reload the information from the model to the editor.\r\n     */\r\n\tvirtual void refresh();\r\n\r\npublic slots:\r\n\r\n\t/*!\r\n\t *  Displays warning message when trying to drag and drop a busDef or absDef using different standard revision\r\n\t *  than the containing component.\r\n\t */\r\n\tvoid stdRevisionMismatchWarning();\r\n\r\nprotected:\r\n\r\n\t/*!\r\n     *  Handler for widget's show event.\r\n     */\r\n\tvirtual void showEvent(QShowEvent* event);\r\n\r\nprivate:\r\n\r\n\t//! No copying\r\n\tBusInterfacesEditor(const BusInterfacesEditor& other);\r\n\tBusInterfacesEditor& operator=(const BusInterfacesEditor& other);\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n\t//! The view that displays the summary of the bus interfaces.\r\n\tEditableTableView view_;\r\n\r\n\t//! The model that does the sorting of items.\r\n\tQSortFilterProxyModel proxy_;\r\n\r\n\t//! The model that manages the bus interfaces being displayed.\r\n\tBusInterfacesModel model_;\r\n};\r\n\r\n#endif // BUSINTERFACESEDITOR_H\r\n"
  },
  {
    "path": "editors/ComponentEditor/busInterfaces/businterfacesmodel.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: businterfacesmodel.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 15.06.2012\r\n//\r\n// Description:\r\n// The model that manages the objects for BusInterfacesEditor.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"businterfacesmodel.h\"\r\n#include \"BusInterfaceColumns.h\"\r\n\r\n#include <KactusAPI/include/LibraryInterface.h>\r\n#include <IPXACTmodels/common/DocumentUtils.h>\r\n\r\n#include <IPXACTmodels/generaldeclarations.h>\r\n#include <IPXACTmodels/common/VLNV.h>\r\n#include <IPXACTmodels/Component/BusInterface.h>\r\n#include <IPXACTmodels/Component/Component.h>\r\n#include <IPXACTmodels/Component/InitiatorInterface.h>\r\n#include <IPXACTmodels/Component/MirroredTargetInterface.h>\r\n#include <IPXACTmodels/Component/validators/BusInterfaceValidator.h>\r\n\r\n#include <KactusAPI/include/BusInterfaceInterface.h>\r\n#include <editors/ComponentEditor/memoryMaps/memoryMapsExpressionCalculators/ReferenceCalculator.h>\r\n\r\n#include <common/KactusColors.h>\r\n\r\n#include <QCoreApplication>\r\n#include <QMap>\r\n#include <QMessageBox>\r\n#include <QMimeData>\r\n#include <QRegularExpression>\r\n#include <QString>\r\n#include <QVariant>\r\n#include <QClipboard>\r\n#include <QApplication>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusInterfacesModel::BusInterfacesModel()\r\n//-----------------------------------------------------------------------------\r\nBusInterfacesModel::BusInterfacesModel(LibraryInterface* libHandler, QSharedPointer<Component> component,\r\n    QSharedPointer<ParameterFinder> parameterFinder, BusInterfaceInterface* busInterface, QObject *parent) :\r\nQAbstractTableModel(parent),\r\nlibHandler_(libHandler),\r\nbusInterface_(busInterface),\r\nparameterFinder_(parameterFinder),\r\ncontainingComponent_(component)\r\n{\r\n    Q_ASSERT(libHandler_);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusInterfacesModel::rowCount()\r\n//-----------------------------------------------------------------------------\r\nint BusInterfacesModel::rowCount(QModelIndex const& parent) const\r\n{\r\n\tif (parent.isValid())\r\n    {\r\n\t\treturn 0;\r\n\t}\r\n\r\n    return busInterface_->itemCount();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusInterfacesModel::columnCount()\r\n//-----------------------------------------------------------------------------\r\nint BusInterfacesModel::columnCount(QModelIndex const& parent) const\r\n{\r\n\tif (parent.isValid())\r\n    {\r\n\t\treturn 0;\r\n\t}\r\n\r\n\treturn BusInterfaceColumns::COLUMN_COUNT;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusInterfacesModel::flags()\r\n//-----------------------------------------------------------------------------\r\nQt::ItemFlags BusInterfacesModel::flags(QModelIndex const& index) const\r\n{\r\n\tif (!index.isValid())\r\n    {\r\n\t\treturn Qt::NoItemFlags;\r\n\t}\r\n\t// bus def and abs def can not be edited but can have data dropped on them\r\n\telse if (index.column() == BusInterfaceColumns::BUSDEF || index.column() == BusInterfaceColumns::ABSDEF)\r\n    {\r\n        return Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsDropEnabled;\r\n\t}\r\n\r\n\treturn Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsEditable;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusInterfacesModel::headerData()\r\n//-----------------------------------------------------------------------------\r\nQVariant BusInterfacesModel::headerData(int section, Qt::Orientation orientation, int role) const\r\n{\r\n\tif (orientation != Qt::Horizontal || role != Qt::DisplayRole)\r\n    {\r\n\t\treturn QVariant();\r\n    }\r\n\r\n    if (section == BusInterfaceColumns::NAME)\r\n    {\r\n        return tr(\"Name\");\r\n    }\r\n    else if (section == BusInterfaceColumns::BUSDEF)\r\n    {\r\n        return tr(\"Bus definition\");\r\n    }\r\n    else if (section == BusInterfaceColumns::ABSDEF)\r\n    {\r\n        return tr(\"Abstraction definition\");\r\n    }\r\n    else if (section == BusInterfaceColumns::INTERFACE_MODE)\r\n    {\r\n        return tr(\"Interface mode\");\r\n    }\r\n    else if (section == BusInterfaceColumns::DESCRIPTION)\r\n    {\r\n        return tr(\"Description\");\r\n    }\r\n    else\r\n    {\r\n        return QVariant();\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusInterfacesModel::data()\r\n//-----------------------------------------------------------------------------\r\nQVariant BusInterfacesModel::data(QModelIndex const& index, int role) const\r\n{\r\n    if (!index.isValid() || index.row() < 0 || index.row() >= busInterface_->itemCount())\r\n    {\r\n\t\treturn QVariant();\r\n\t}\r\n\r\n    std::string busName = busInterface_->getIndexedItemName(index.row());\r\n\tif (role == Qt::DisplayRole || (\r\n        (role == Qt::EditRole || role == Qt::ToolTipRole) && index.column() != BusInterfaceColumns::DESCRIPTION))\r\n    {\r\n        if (index.column() == BusInterfaceColumns::NAME)\r\n        {\r\n            return QString::fromStdString(busName);\r\n        }\r\n        else if (index.column() == BusInterfaceColumns::BUSDEF)\r\n        {\r\n            return busInterface_->getBusType(busName).toString(\":\");\r\n        }\r\n        else if (index.column() == BusInterfaceColumns::ABSDEF)\r\n        {\r\n            if (role == Qt::ToolTipRole)\r\n            {\r\n                QStringList references;\r\n                for (auto abstractionReference : busInterface_->getAbstractionReferences(busName))\r\n                {\r\n                    references.append(QString::fromStdString(abstractionReference));\r\n                }\r\n\r\n                return references.join(\"\\n\");\r\n            }\r\n            else\r\n            {\r\n                return QString::fromStdString(busInterface_->getAbstractionReferenceString(busName));\r\n            }\r\n        }\r\n        else if (index.column() == BusInterfaceColumns::INTERFACE_MODE)\r\n        {\r\n            return QString::fromStdString(busInterface_->getModeString(busName));\r\n        }\r\n        else if (index.column() == BusInterfaceColumns::DESCRIPTION)\r\n        {\r\n            return QString::fromStdString(busInterface_->getDescription(busName)).replace(\r\n                QRegularExpression(\"\\n.*$\", QRegularExpression::DotMatchesEverythingOption), \"...\");\r\n        }\r\n        else\r\n        {\r\n            return QVariant();\r\n        }\r\n\t}\r\n    else if ((role == Qt::EditRole || role == Qt::ToolTipRole) && \r\n        index.column() == BusInterfaceColumns::DESCRIPTION)\r\n    {\r\n        return QString::fromStdString(busInterface_->getDescription(busName));\r\n    }\r\n\telse if (role == Qt::ForegroundRole)\r\n    {\r\n        if (index.column() == BusInterfaceColumns::NAME && busInterface_->itemHasValidName(busName))\r\n        {\r\n            return KactusColors::REGULAR_TEXT;     \r\n        }\r\n        else if (index.column() == BusInterfaceColumns::BUSDEF && busInterface_->hasValidBusType(busName))\r\n        {\r\n            return KactusColors::REGULAR_TEXT;\r\n        }\r\n        else if (index.column() == BusInterfaceColumns::ABSDEF && busInterface_->hasValidAbstractionTypes(busName))\r\n        {\r\n            return KactusColors::REGULAR_TEXT;\r\n        }\r\n        else if (index.column() == BusInterfaceColumns::INTERFACE_MODE &&\r\n            busInterface_->getMode(busName) != General::INTERFACE_MODE_COUNT)\r\n        {\r\n            return KactusColors::REGULAR_TEXT;  \r\n        }\r\n        else if (index.column() == BusInterfaceColumns::DESCRIPTION)\r\n        {\r\n            return KactusColors::REGULAR_TEXT;\r\n        }\r\n        else\r\n        {\r\n            return KactusColors::ERROR;\r\n        }\r\n\t}\r\n\telse if (role == Qt::BackgroundRole)\r\n    {\r\n        if (index.column() == BusInterfaceColumns::NAME ||\r\n            index.column() == BusInterfaceColumns::BUSDEF ||\r\n            index.column() == BusInterfaceColumns::INTERFACE_MODE)\r\n        {\r\n            return KactusColors::MANDATORY_FIELD;\r\n        }\r\n        else\r\n        {\r\n            return KactusColors::REGULAR_FIELD;\r\n        }\r\n\t}\r\n\telse \r\n    {\r\n\t\treturn QVariant();\r\n\t}\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusInterfacesModel::setData()\r\n//-----------------------------------------------------------------------------\r\nbool BusInterfacesModel::setData(QModelIndex const& index, const QVariant& value, int role)\r\n{\r\n    if (!index.isValid() || index.row() < 0 || index.row() >= busInterface_->itemCount())\r\n    {\r\n\t\treturn false;\r\n\t}\r\n\r\n    std::string busName = busInterface_->getIndexedItemName(index.row());\r\n    std::string valueString = value.toString().toStdString();\r\n\tif (role == Qt::EditRole)\r\n    {\r\n        if (index.column() == BusInterfaceColumns::NAME)\r\n        {\r\n            busInterface_->setName(busName, valueString);\r\n        }\r\n        else if (index.column() == BusInterfaceColumns::BUSDEF)\r\n        {\r\n            VLNV busType = VLNV(VLNV::BUSDEFINITION, value.toString(), \":\");\r\n            if (!busType.isValid())\r\n            {\r\n                return false;\r\n            }\r\n\r\n            busInterface_->setBustype(busName, busType.getVendor().toStdString(),\r\n                busType.getLibrary().toStdString(), busType.getName().toStdString(),\r\n                busType.getVersion().toStdString());\r\n        }\r\n        else if (index.column() == BusInterfaceColumns::ABSDEF)\r\n        {\r\n            if (value.toString().isEmpty())\r\n            {\r\n                busInterface_->removeAbstractionTypes(busName);\r\n            }\r\n            else\r\n            {\r\n                QSharedPointer<ConfigurableVLNVReference> absType(new ConfigurableVLNVReference(VLNV(\r\n                    VLNV::ABSTRACTIONDEFINITION, value.toString(), \":\")));\r\n\r\n                // Add abs def reference only if it's unique.\r\n                auto const& existingAbstractionRefs = busInterface_->getAbstractionReferences(busName);\r\n\r\n                bool abstractionTypeExists = std::find(existingAbstractionRefs.cbegin(),\r\n                    existingAbstractionRefs.cend(), valueString) != existingAbstractionRefs.cend();\r\n\r\n                if (!absType->isValid() || abstractionTypeExists)\r\n                {\r\n                    return false;\r\n                }\r\n\r\n                busInterface_->addAbstractionType(busName, absType->getVendor().toStdString(),\r\n                    absType->getLibrary().toStdString(), absType->getName().toStdString(),\r\n                    absType->getVersion().toStdString());\r\n            }\r\n        }\r\n        else if (index.column() == BusInterfaceColumns::INTERFACE_MODE)\r\n        {\r\n            busInterface_->setMode(busName, valueString);\r\n        }\r\n        else if (index.column() == BusInterfaceColumns::DESCRIPTION)\r\n        {\r\n            busInterface_->setDescription(busName, valueString);\r\n        }\r\n        else\r\n        {\r\n            return false;\r\n        }\r\n    \r\n\t\temit dataChanged(index, index);\r\n\t\temit contentChanged();\r\n\t\treturn true;\r\n\t}\r\n\telse\r\n    {\r\n\t\treturn false;\r\n\t}\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusInterfacesModel::supportedDropActions()\r\n//-----------------------------------------------------------------------------\r\nQt::DropActions BusInterfacesModel::supportedDropActions() const\r\n{\r\n    return Qt::CopyAction | Qt::MoveAction;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusInterfacesModel::mimeTypes()\r\n//-----------------------------------------------------------------------------\r\nQStringList BusInterfacesModel::mimeTypes() const\r\n{\r\n    QStringList types(QAbstractTableModel::mimeTypes());\r\n    types << \"application/x-qt-image\";\r\n    return types;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusInterfacesModel::dropMimeData()\r\n//-----------------------------------------------------------------------------\r\nbool BusInterfacesModel::dropMimeData(QMimeData const* data, Qt::DropAction action, int row, int column, \r\n    QModelIndex const& parent)\r\n{\r\n    if (action == Qt::IgnoreAction)\r\n    {\r\n        return true;\r\n    }\r\n\r\n    // Dropped data must be directly on parent.\r\n    if (row != -1 || column != -1 || !parent.isValid() || row > rowCount())\r\n    {\r\n        return false;\r\n    }\r\n\r\n    QVariant variant = data->imageData();\r\n    if (!variant.canConvert<VLNV>())\r\n    {\r\n        return false;\r\n    }\r\n\r\n    VLNV vlnv = variant.value<VLNV>();\r\n    auto componentVlnv = containingComponent_->getVlnv();\r\n\r\n    if (parent.column() == BusInterfaceColumns::BUSDEF)\r\n    {\r\n        if (vlnv.getType() != VLNV::BUSDEFINITION)\r\n        {\r\n            return false;\r\n        }\r\n\r\n        // Check std revision compatibility.\r\n        if (!DocumentUtils::documentsHaveMatchingStdRevisions(vlnv, componentVlnv, libHandler_))\r\n\r\n        {\r\n            emit stdRevisionMismatch();\r\n            return false;\r\n        }\r\n\r\n        setData(index(parent.row(), parent.column()), vlnv.toString(\":\"));\r\n\r\n        // If only one possible absDef, set it automatically.\r\n        QList<VLNV> absDefVLNVs;\r\n        if (libHandler_->getChildren(absDefVLNVs, vlnv) == 1) \r\n        {\r\n            setData(index(parent.row(), BusInterfaceColumns::ABSDEF), absDefVLNVs.first().toString(\":\"));\r\n        }\r\n\r\n        emit contentChanged();\r\n    }\r\n    else if (parent.column() == BusInterfaceColumns::ABSDEF)\r\n    {\r\n        if (vlnv.getType() != VLNV::ABSTRACTIONDEFINITION)\r\n        {\r\n            return false;\r\n        }\r\n\r\n        // Check std revision compatibility.\r\n        if (!DocumentUtils::documentsHaveMatchingStdRevisions(vlnv, componentVlnv, libHandler_))\r\n        {\r\n            emit stdRevisionMismatch();\r\n            return false;\r\n        }\r\n\r\n        setData(index(parent.row(),parent.column()),vlnv.toString(\":\"));\r\n        emit contentChanged();\r\n    }\r\n\r\n    return true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusInterfacesModel::onAddItem()\r\n//-----------------------------------------------------------------------------\r\nvoid BusInterfacesModel::onAddItem(QModelIndex const& index)\r\n{\r\n    int row = busInterface_->itemCount();\r\n\r\n\t// if the index is valid then add the item to the correct position\r\n\tif (index.isValid())\r\n    {\r\n\t\trow = index.row();\r\n\t}\r\n\r\n\tbeginInsertRows(QModelIndex(), row, row);\r\n    busInterface_->addBusInterface(row);\r\n\tendInsertRows();\r\n\r\n\temit busifAdded(row);\r\n\r\n\t// tell also parent widget that contents have been changed\r\n\temit contentChanged();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusInterfacesModel::onRemoveItem()\r\n//-----------------------------------------------------------------------------\r\nvoid BusInterfacesModel::onRemoveItem(QModelIndex const& index)\r\n{\r\n\t// don't remove anything if index is invalid\r\n    if (!index.isValid() || index.row() < 0 || index.row() >= busInterface_->itemCount())\r\n    {\r\n\t\treturn;\r\n\t}\r\n\r\n\t// remove the specified item\r\n\tbeginRemoveRows(QModelIndex(), index.row(), index.row());\r\n\r\n    removeReferencesFromExpressions(index.row());\r\n    busInterface_->removeBusInterface(busInterface_->getIndexedItemName(index.row()));\r\n\tendRemoveRows();\r\n\r\n\t// inform navigation tree that file set has been removed\r\n\temit busifRemoved(index.row());\r\n\r\n\t// tell also parent widget that contents have been changed\r\n\temit contentChanged();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: businterfacesmodel::removeReferencesFromExpressions()\r\n//-----------------------------------------------------------------------------\r\nvoid BusInterfacesModel::removeReferencesFromExpressions(int busInterfaceIndex)\r\n{\r\n    std::string busName = busInterface_->getIndexedItemName(busInterfaceIndex);\r\n\r\n    QStringList expressions;\r\n    for (auto singleExpression : busInterface_->getAllExpressions(busName))\r\n    {\r\n        expressions.append(QString::fromStdString(singleExpression));\r\n    }\r\n\r\n    ReferenceCalculator referenceCalculator(parameterFinder_);\r\n    QMap<QString, int> referencedParameters = referenceCalculator.getReferencedParameters(expressions);\r\n\r\n    foreach(QString referencedId, referencedParameters.keys())\r\n    {\r\n        for (int i = 0; i < referencedParameters.value(referencedId); ++i)\r\n        {\r\n            emit decreaseReferences(referencedId);\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusInterfacesModel::onMoveItem()\r\n//-----------------------------------------------------------------------------\r\nvoid BusInterfacesModel::onMoveItem(QModelIndex const& originalPos, QModelIndex const& newPos)\r\n{\r\n    // if there was no item in the starting point\r\n    if (!originalPos.isValid() || originalPos == newPos || originalPos.row() < 0 ||\r\n        originalPos.row() >= busInterface_->itemCount())\r\n    {\r\n        return;\r\n    }\r\n\r\n    int source = originalPos.row();\r\n    int target = 0;\r\n\r\n    beginResetModel();\r\n    busInterface_->swapBusInterfaces(originalPos.row(), newPos.row());\r\n    endResetModel();\r\n\r\n    if (!newPos.isValid() || newPos.row() < 0 || newPos.row() >= busInterface_->itemCount())\r\n    {\r\n        target = busInterface_->itemCount() - 1;\r\n    }\r\n    else\r\n    {\r\n        target = newPos.row();\r\n    }\r\n\r\n    emit busIfMoved(source, target);\r\n    emit contentChanged();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusInterfacesModel::onCopyRows()\r\n//-----------------------------------------------------------------------------\r\nvoid BusInterfacesModel::onCopyRows(QModelIndexList indexList)\r\n{\r\n    std::vector<int> busIndexes;\r\n    for (auto index : indexList)\r\n    {\r\n        busIndexes.push_back(index.row());\r\n    }\r\n    \r\n    busInterface_->copyRows(busIndexes);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusInterfacesModel::onPasteRows()\r\n//-----------------------------------------------------------------------------\r\nvoid BusInterfacesModel::onPasteRows()\r\n{\r\n    int pastedBusCount = busInterface_->getPasteRowCount();\r\n    if (pastedBusCount == 0)\r\n    {\r\n        return;\r\n    }\r\n\r\n    int rowBegin = busInterface_->itemCount();\r\n    int rowEnd = rowBegin + pastedBusCount - 1;\r\n\r\n    beginInsertRows(QModelIndex(), rowBegin, rowEnd);\r\n\r\n    busInterface_->pasteRows();\r\n\r\n    for (int i = rowBegin; i <= rowEnd; ++i)\r\n    {\r\n        emit busifAdded(i);\r\n        increaseReferencesInPastedBus(QString::fromStdString(busInterface_->getIndexedItemName(i)));\r\n    }\r\n\r\n    endInsertRows();\r\n\r\n    emit contentChanged();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: businterfacesmodel::increaseReferencesInPastedBus()\r\n//-----------------------------------------------------------------------------\r\nvoid BusInterfacesModel::increaseReferencesInPastedBus(QString const& busName)\r\n{\r\n    QMap<QString, int> referencedParameters = getReferencedParameters(busName);\r\n\r\n    QMapIterator<QString, int> refParameterIterator(referencedParameters);\r\n    while (refParameterIterator.hasNext())\r\n    {\r\n        refParameterIterator.next();\r\n        for (int i = 0; i < refParameterIterator.value(); ++i)\r\n        {\r\n            emit increaseReferences(refParameterIterator.key());\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: businterfacesmodel::getReferencedParameters()\r\n//-----------------------------------------------------------------------------\r\nQMap<QString, int> BusInterfacesModel::getReferencedParameters(QString const& busName) const\r\n{\r\n    auto expressionList = busInterface_->getAllExpressions(busName.toStdString());\r\n    QStringList expressionListQT;\r\n    for (auto expression : expressionList)\r\n    {\r\n        expressionListQT.append(QString::fromStdString(expression));\r\n    }\r\n\r\n    ReferenceCalculator refCalculator(parameterFinder_);\r\n\r\n    return refCalculator.getReferencedParameters(expressionListQT);\r\n}\r\n"
  },
  {
    "path": "editors/ComponentEditor/busInterfaces/businterfacesmodel.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: businterfacesmodel.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 15.06.2012\r\n//\r\n// Description:\r\n// The model that manages the objects for BusInterfacesEditor.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef BUSINTERFACESMODEL_H\r\n#define BUSINTERFACESMODEL_H\r\n\r\n#include <QAbstractTableModel>\r\n#include <QSharedPointer>\r\n#include <QList>\r\n\r\nclass LibraryInterface;\r\nclass ParameterFinder;\r\nclass Parameter;\r\nclass BusInterfaceInterface;\r\nclass Component;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! The model that manages the objects for BusInterfacesEditor.\r\n//-----------------------------------------------------------------------------\r\nclass BusInterfacesModel : public QAbstractTableModel\r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\r\n    /*!\r\n\t *  The constructor.\r\n\t *\r\n\t *    @param [in] libHandler          The instance that manages the library.\r\n\t *    @param [in] component           The containing component.\r\n\t *    @param [in] parameterFinder     The parameter finder.\r\n     *    @param [in] busInterface        Interface for accessing bus interfaces.\r\n\t *    @param [in] parent              The owner of this model.\r\n\t */\r\n    BusInterfacesModel(LibraryInterface* libHandler, QSharedPointer<Component> component, \r\n        QSharedPointer<ParameterFinder> parameterFinder, BusInterfaceInterface* busInterface, QObject *parent);\r\n\r\n\t/*!\r\n     *  The destructor.\r\n     */\r\n\tvirtual ~BusInterfacesModel() = default;\r\n\r\n\t/*!\r\n     *  Get the number of rows an item contains.\r\n\t *\r\n\t *    @param [in] parent Identifies the parent that's row count is requested.\r\n\t *\r\n\t *    @return Number of rows the item has.\r\n     */\r\n\tvirtual int rowCount(QModelIndex const& parent = QModelIndex()) const;\r\n\r\n\t/*!\r\n     *  Get the number of columns the item has to be displayed.\r\n\t *\r\n\t *    @param [in] parent Identifies the parent that's column count is requested.\r\n\t *\r\n\t *    @return The number of columns to be displayed.\r\n\t*/\r\n\tvirtual int columnCount(QModelIndex const& parent = QModelIndex()) const;\r\n\r\n\t/*!\r\n     *  Get the item flags that defines the possible operations for the item.\r\n\t *\r\n\t *    @param [in] index Model index that identifies the item.\r\n\t *\r\n\t *    @return Qt::ItemFlags specify the possible operations for the item.\r\n     */\r\n\tQt::ItemFlags flags(QModelIndex const& index) const;\r\n\r\n\t/*!\r\n     *  Get the header data for specified header.\r\n\t *\r\n\t *    @param [in] section The section specifies the row/column number for the header.\r\n\t *    @param [in] orientation Specified if horizontal or vertical header is wanted.\r\n\t *    @param [in] role Specifies the type of the requested data.\r\n\t *\r\n\t *    @return QVariant Contains the requested data.\r\n     */\r\n\tvirtual QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;\r\n\r\n\t/*!\r\n     *  Get the data for specified item.\r\n\t *\r\n\t *    @param [in] index Specifies the item that's data is requested.\r\n\t *    @param [in] role The role that defines what kind of data is requested.\r\n\t *\r\n\t *    @return QVariant Contains the data for the item.\r\n     */\r\n\tvirtual QVariant data(QModelIndex const& index, int role = Qt::DisplayRole) const;\r\n\r\n\t/*!\r\n     *  Save the data to the model for specified item\r\n\t *\r\n\t *    @param [in] index The model index of the item that's data is to be saved.\r\n\t *    @param [in] value The data that is to be saved.\r\n\t *    @param [in] role The role specifies what kind of data should be saved.\r\n\t *\r\n\t *    @return True if saving happened successfully.\r\n     */\r\n\tbool setData(QModelIndex const& index, const QVariant& value, int role = Qt::EditRole);\r\n\r\n    /*!\r\n     *  Returns the supported actions of a drop.\r\n     *\r\n     *    @return The drop actions supported by the model.\r\n     */\r\n    Qt::DropActions supportedDropActions() const;\r\n\r\n    /*!\r\n     *  Returns a list of supported MIME data types.\r\n     *\r\n     *    @return The supported MIME types.\r\n     */\r\n    QStringList mimeTypes() const;\r\n\r\n    /*!\r\n     *  Handler for the dropped MIME data.\r\n     *\r\n     *    @param [in] data   The data associated to the drop.\r\n     *    @param [in] action The drop action.  \r\n     *    @param [in] row    The row beneath the drop position.\r\n     *    @param [in] column The column beneath the drop position.\r\n     *    @param [in] parent The parent index of the drop position.\r\n     *\r\n     *    @return True, if the model could handle the data, otherwise false.\r\n     */\r\n    bool dropMimeData(QMimeData const* data, Qt::DropAction action, int row, int column,\r\n        QModelIndex const& parent);\r\n\r\npublic slots:\r\n\r\n\t/*!\r\n     *  Add a new item to the given index.\r\n\t *\r\n\t *    @param [in] index The index identifying the position for new item.\r\n     */\r\n\tvirtual void onAddItem(QModelIndex const& index);\r\n\r\n\t/*!\r\n     *  Remove the item in the given index.\r\n\t *\r\n\t *    @param [in] index The index identifying the item to remove.\r\n     */\r\n\tvirtual void onRemoveItem(QModelIndex const& index);\r\n\r\n\t/*!\r\n     *  Move item from the original position to new position.\r\n\t *\r\n\t *    @param [in] originalPos The index identifying the item to move.\r\n\t *    @param [in] newPos      The index identifying the position of the item after the move.\r\n     */\r\n    virtual void onMoveItem( QModelIndex const& originalPos, QModelIndex const& newPos );\r\n\r\n    /*!\r\n     *  Handle the bus interface copying.\r\n     *\r\n     *    @param [in] indexList   List of indexes to be copied.\r\n     */\r\n    void onCopyRows(QModelIndexList indexList);\r\n\r\n    /*!\r\n     *  Handle the bus interface pasteing.\r\n     */\r\n    void onPasteRows();\r\n\r\nsignals:\r\n\r\n\t/*!\r\n     *  Emitted when the contents of the model change.\r\n     */\r\n\tvoid contentChanged();\r\n\r\n\t/*!\r\n     *  Emitted when a new bus interface is added to the model.\r\n\t *\r\n\t *    @param [in] index The index of the added bus interface.\r\n     */\r\n\tvoid busifAdded(int index);\r\n\r\n\t/*!\r\n     *  Emitted when a bus interface is removed from the model.\r\n\t *\r\n\t *    @param [in] index The index of the bus interface to remove.\r\n     */\r\n\tvoid busifRemoved(int index);\r\n\r\n    /*!\r\n     *  Emitted when a bus interface is moved from one position to another.\r\n     *\r\n     *    @param [in] source The row number of the bus interface before the move.\r\n     *    @param [in] target The row number of the bus interface after the move.\r\n     */\r\n    void busIfMoved(int source, int target);\r\n\r\n    /*!\r\n     *  Increase the number of references made to the specified parameter.\r\n     *\r\n     *    @param [in] id  Id of the parameter whose reference count is increased.\r\n     */\r\n    void increaseReferences(QString id);\r\n\r\n    /*!\r\n     *  Decrease the number of references made to the specified parameter.\r\n     *\r\n     *    @param [in] id  Id of the parameter whose reference count is decreased.\r\n     */\r\n    void decreaseReferences(QString id);\r\n\r\n    /*!\r\n     *  Emitted when a abstraction def or bus def with different std revision is dropped in the editor.\r\n     */\r\n    void stdRevisionMismatch() const;\r\n\r\nprivate:\r\n\r\n    //! No copying. No assignment.\r\n\tBusInterfacesModel(const BusInterfacesModel& other);\r\n\tBusInterfacesModel& operator=(const BusInterfacesModel& other);\r\n\r\n    /*!\r\n     *  Remove references from the expressions contained within the removed bus interface.\r\n     *\r\n     *    @param [in] busInterfaceIndex   The index of the removed bus interface.\r\n     */\r\n    void removeReferencesFromExpressions(int busInterfaceIndex);\r\n\r\n    /*!\r\n     *  Increase the number of references made in the selected bus interface.\r\n     *\r\n     *    @param [in] registerName    Name of the selected bus interface.\r\n     */\r\n    void increaseReferencesInPastedBus(QString const& busName);\r\n\r\n    /*!\r\n     *  Calculates the parameters used in the selected bus interface.\r\n     *\r\n     *    @param [in] registerName    Name of the selected bus interface.\r\n     *\r\n     *    @return A map containing pairs of referenced ids and the number of references made to them.\r\n     */\r\n    QMap<QString, int> getReferencedParameters(QString const& busName) const;\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n\t//! The instance that manages the library.\r\n\tLibraryInterface* libHandler_;\r\n\r\n    //! Interface for accessing bus interfaces.\r\n    BusInterfaceInterface* busInterface_;\r\n\r\n    //! The parameter finder.\r\n    QSharedPointer<ParameterFinder> parameterFinder_;\r\n\r\n    //! The containing component.\r\n    QSharedPointer<Component> containingComponent_;\r\n};\r\n\r\n#endif // BUSINTERFACESMODEL_H\r\n"
  },
  {
    "path": "editors/ComponentEditor/busInterfaces/general/BridgeColumns.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: BridgeColumns.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Esko Pekkarinen\r\n// Date: 23.10.2015\r\n//\r\n// Description:\r\n// Common declarations for editing bridges of a slave interface.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef BRIDGE_COLUMNS_H\r\n#define BRIDGE_COLUMNS_H\r\n\r\nnamespace BridgeColumns\r\n{\r\n    //! Contains the columns for bridge properties.\r\n    enum Column\r\n    {\r\n        INITIATOR_COLUMN = 0,\r\n        COLUMN_COUNT\r\n    };\r\n\r\n}\r\n\r\n#endif // BRIDGE_COLUMNS_H"
  },
  {
    "path": "editors/ComponentEditor/busInterfaces/general/InitiatorModeEditor.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: InitiatorModeEditor.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Esko Pekkarinen\n// Date: 29.6.2023\n//\n// Description:\n// Editor to edit initiator settings of a bus interface.\n//-----------------------------------------------------------------------------\n\n#include \"InitiatorModeEditor.h\"\n\n#include <IPXACTmodels/Component/Component.h>\n#include <IPXACTmodels/generaldeclarations.h>\n\n#include <editors/ComponentEditor/common/ExpressionEditor.h>\n#include <KactusAPI/include/ExpressionParser.h>\n#include <editors/ComponentEditor/parameters/ComponentParameterModel.h>\n#include <editors/ComponentEditor/memoryMaps/memoryMapsExpressionCalculators/ReferenceCalculator.h>\n#include <KactusAPI/include/BusInterfaceInterface.h>\n\n#include <QCompleter>\n#include <QGridLayout>\n#include <QLabel>\n#include <QString>\n\n//-----------------------------------------------------------------------------\n// Function: InitiatorModeEditor::InitiatorModeEditor()\n//-----------------------------------------------------------------------------\nInitiatorModeEditor::InitiatorModeEditor(BusInterfaceInterface* busInterface, std::string const& busName,\n    QSharedPointer<Component> component, QSharedPointer<ParameterFinder> parameterFinder,\n    QSharedPointer<ExpressionParser> expressionParser, QWidget *parent):\nModeEditorBase(busInterface, busName, tr(\"Initiator\"), parent),\naddressSpaceReferenceSelector_(this),\nbaseAddressEditor_(new ExpressionEditor(parameterFinder, this)),\nparameterFinder_(parameterFinder),\ncomponent_(component)\n{\n    baseAddressEditor_->setFixedHeight(ExpressionEditor::DEFAULT_HEIGHT);\n\n    ComponentParameterModel* componentParameterModel = new ComponentParameterModel(parameterFinder, this);\n    componentParameterModel->setExpressionParser(expressionParser);\n   \n    auto baseAddressCompleter = new QCompleter(this);\n    baseAddressCompleter->setModel(componentParameterModel);\n    baseAddressEditor_->setAppendingCompleter(baseAddressCompleter);\n\n\tQLabel* addrSpaceLabel = new QLabel(tr(\"Address space:\"), this);\n\n    QString functionSymbol(QChar(0x0192));\n\tQLabel* baseAddrLabel = new QLabel(tr(\"Base address\") + \", \" + functionSymbol +\"(x):\", this);\n\n\tQGridLayout* topLayout = new QGridLayout(this);\n\ttopLayout->addWidget(addrSpaceLabel, 0, 0, 1, 1);\n\ttopLayout->addWidget(&addressSpaceReferenceSelector_, 0, 1, 1, 1);\n\ttopLayout->addWidget(baseAddrLabel, 1, 0, 1, 1);\n    topLayout->addWidget(baseAddressEditor_, 1, 1, 1, 1);\n    topLayout->setColumnStretch(1, 1);\n\ttopLayout->setRowStretch(2, 10);\n\n\tconnect(&addressSpaceReferenceSelector_, SIGNAL(itemSelected(const QString&)),\n\t\tthis, SLOT(onAddressSpaceChange(const QString&)), Qt::UniqueConnection);\n    connect(baseAddressEditor_, SIGNAL(editingFinished()), this, SLOT(onBaseAddressChange()), Qt::UniqueConnection);\n\n    connect(baseAddressEditor_, SIGNAL(increaseReference(QString)),\n        this, SIGNAL(increaseReferences(QString)), Qt::UniqueConnection);\n    connect(baseAddressEditor_, SIGNAL(decreaseReference(QString)),\n        this, SIGNAL(decreaseReferences(QString)), Qt::UniqueConnection);\n}\n\n//-----------------------------------------------------------------------------\n// Function: InitiatorModeEditor::isValid()\n//-----------------------------------------------------------------------------\nbool InitiatorModeEditor::isValid() const\n{\n\tQString selectedAddrSpace = addressSpaceReferenceSelector_.currentText();\n\n\t// address space ref is not mandatory\n\tif (selectedAddrSpace.isEmpty())\n    {\n\t\treturn true;\n\t}\n\t\n\t// if the selected address space does not belong to component\n    QStringList addrSpaceNames = component_->getAddressSpaceNames();\n\tif (!addrSpaceNames.contains(selectedAddrSpace))\n    {\n\t\treturn false;\n\t}\n\t\n\treturn true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: InitiatorModeEditor::refresh()\n//-----------------------------------------------------------------------------\nvoid InitiatorModeEditor::refresh()\n{\n    BusInterfaceInterface* busInterface = getBusInterface();\n    std::string busName = getBusName();\n\n\n\t// update the selectable items\n    addressSpaceReferenceSelector_.refresh(component_->getAddressSpaceNames());\n    QString addrSpaceRef = QString::fromStdString(busInterface->getAddressSpaceReference(busName));\n\n\t// if address space ref is empty then there can be no base address\n\tif (addrSpaceRef.isEmpty())\n    {\n        baseAddressEditor_->setDisabled(true);\n\t}\n\telse \n    {\n        baseAddressEditor_->blockSignals(true);\n\n        baseAddressEditor_->setEnabled(true);\n        baseAddressEditor_->setExpression(QString::fromStdString(busInterface->getBaseAddressExpression(busName)));\n        baseAddressEditor_->setToolTip(\n            QString::fromStdString(busInterface->getBaseAddressValue(busName)));\n\n        baseAddressEditor_->blockSignals(false);\n\t}\n\n\t// select the address space ref and base address\n\taddressSpaceReferenceSelector_.selectItem(addrSpaceRef);\n}\n\n//-----------------------------------------------------------------------------\n// Function: InitiatorModeEditor::getInterfaceMode()\n//-----------------------------------------------------------------------------\nGeneral::InterfaceMode InitiatorModeEditor::getInterfaceMode() const\n{\n    return General::INITIATOR;\n}\n\n//-----------------------------------------------------------------------------\n// Function: InitiatorModeEditor::onAddressSpaceChange()\n//-----------------------------------------------------------------------------\nvoid InitiatorModeEditor::onAddressSpaceChange(const QString& addrSpaceName)\n{\n    getBusInterface()->setAddressSpaceReference(getBusName(), addrSpaceName.toStdString());\n\n\t// if address space reference is empty then there can be no base address\n\tif (addrSpaceName.isEmpty())\n    {\n        removeReferencesFromExpressions();\n\n        baseAddressEditor_->setDisabled(true);\n\t}\n\telse\n    {\n        baseAddressEditor_->setEnabled(true);\n\t}\n\n\temit contentChanged();\n}\n\n//-----------------------------------------------------------------------------\n// Function: InitiatorModeEditor::onBaseAddressChange()\n//-----------------------------------------------------------------------------\nvoid InitiatorModeEditor::onBaseAddressChange()\n{\n    BusInterfaceInterface* busInterface = getBusInterface();\n    std::string busName = getBusName();\n\n    baseAddressEditor_->finishEditingCurrentWord();\n    busInterface->setBaseAddress(busName, baseAddressEditor_->getExpression().toStdString());\n    baseAddressEditor_->setToolTip(\n        QString::fromStdString(busInterface->getBaseAddressValue(busName)));\n\n    emit contentChanged();\n}\t\n\n//-----------------------------------------------------------------------------\n// Function: InitiatorModeEditor::saveModeSpecific()\n//-----------------------------------------------------------------------------\nvoid InitiatorModeEditor::saveModeSpecific()\n{\n    BusInterfaceInterface* busInterface = getBusInterface();\n    std::string busName = getBusName();\n\n    busInterface->setAddressSpaceReference(busName, addressSpaceReferenceSelector_.currentText().toStdString());\n    busInterface->setBaseAddress(busName, baseAddressEditor_->getExpression().toStdString());\n}\n\n//-----------------------------------------------------------------------------\n// Function: InitiatorModeEditor::removeReferencesFromExpressions()\n//-----------------------------------------------------------------------------\nvoid InitiatorModeEditor::removeReferencesFromExpressions()\n{\n    QStringList baseAddressExpression;\n    baseAddressExpression.append(baseAddressEditor_->getExpression());\n\n    ReferenceCalculator referenceCalculator(parameterFinder_);\n    QMap<QString, int> referencedParameters = referenceCalculator.getReferencedParameters(baseAddressExpression);\n\n    for (QString const& referencedId : referencedParameters.keys())\n    {\n        for (int i = 0; i < referencedParameters.value(referencedId); ++i)\n        {\n            emit decreaseReferences(referencedId);\n        }\n    }\n\n    baseAddressEditor_->clear();\n    getBusInterface()->setBaseAddress(getBusName(), \"\");\n}\n"
  },
  {
    "path": "editors/ComponentEditor/busInterfaces/general/InitiatorModeEditor.h",
    "content": "//-----------------------------------------------------------------------------\n// File: InitiatorModeEditor.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Esko Pekkarinen\n// Date: 29.6.2023\n//\n// Description:\n// Editor to edit initiator settings of a bus interface.\n//-----------------------------------------------------------------------------\n\n#ifndef INITIATOR_MODE_EDITOR_H\n#define INITIATOR_MODE_EDITOR_H\n\n#include \"ModeEditorBase.h\"\n\n#include <editors/ComponentEditor/common/ReferenceSelector/ReferenceSelector.h>\n\n#include <IPXACTmodels/generaldeclarations.h>\n\n#include <QString>\n#include <QSharedPointer>\n#include <QLineEdit>\n\nclass BusInterface;\nclass Component;\nclass ExpressionEditor;\nclass ExpressionParser;\nclass InitiatorInterface;\nclass ParameterFinder;\n\n//-----------------------------------------------------------------------------\n//! Editor to edit initiator settings of a bus interface.\n//-----------------------------------------------------------------------------\nclass InitiatorModeEditor : public ModeEditorBase\n{\n\tQ_OBJECT\n\npublic:\n\n    /*!\n\t *  The constructor.\n\t *\n\t *    @param [in] busInterface        Interface for accessing bus interfaces.\n     *    @param [in] busName             Name of the edited bus interface.\n\t *    @param [in] component           The component being edited.\n\t *    @param [in] parameterFinder     The parameter finder.\n\t *    @param [in] expressionParser    The expression parser.\n\t *    @param [in] parent              The owner of this editor.\n\t */\n    InitiatorModeEditor(\n        BusInterfaceInterface* busInterface,\n        std::string const& busName,\n        QSharedPointer<Component> component,\n        QSharedPointer<ParameterFinder> parameterFinder,\n        QSharedPointer<ExpressionParser> expressionParser,\n        QWidget *parent);\n\n\t//! The destructor\n\tvirtual ~InitiatorModeEditor() = default;\n\n    //! No copying. No assignment.\n    InitiatorModeEditor(const InitiatorModeEditor& other) = delete;\n    InitiatorModeEditor& operator=(const InitiatorModeEditor& other) = delete;\n\n\t/*! Check for the validity of the edited item.\n\t*\n\t*    @return True if item is valid.\n\t*/\n\tbool isValid() const final;\n\n\t/*! Restore the changes made in the editor back to ones in the model.\n\t*\n\t*/\n\tvoid refresh() final;\n\n\t/*! Get the interface mode of the editor\n\t * \n\t *    @return General::InterfaceMode Specifies the interface mode.\n\t*/\n\tGeneral::InterfaceMode getInterfaceMode() const final;\n\n\t//! Save the interface mode-specific details to the bus interface.\n\tvoid saveModeSpecific() final;\n\n    /*!\n     *  Remove the references from the expressions.\n     */\n    void removeReferencesFromExpressions();\n\nsignals:\n\n    /*!\n     *  Increase the number of references to the given parameter.\n     *\n     *    @param [in] id  The id of the target parameter.\n     */\n    void increaseReferences(QString const& id);\n\n    /*!\n     *  Decrease the number of references to the given parameter.\n     *\n     *    @param [in] id  The id of the target parameter.\n     */\n    void decreaseReferences(QString const& id);\n\nprivate slots:\n\n\t/*!\n\t *  Handler for changes in address space reference.\n\t *\n\t *    @param [in] addrSpaceName   The name of the referenced address space.\n\t */\n\tvoid onAddressSpaceChange(QString const& addrSpaceName);\n\n    /*!\n     *  Handler for changes in base address.\n     */\n    void onBaseAddressChange();\n\nprivate:\n\n    //-----------------------------------------------------------------------------\n    //! Data.\n    //-----------------------------------------------------------------------------\n\n\t//! Combo box to select an address space within component\n\tReferenceSelector addressSpaceReferenceSelector_;\n\n    //! Editor for the base address of an address space.\n    ExpressionEditor* baseAddressEditor_;\n\n    //! The parameter finder.\n    QSharedPointer<ParameterFinder> parameterFinder_;\n\n    //! The containing component.\n    QSharedPointer<Component> component_;\n};\n\n#endif // INITIATOR_MODE_EDITOR_H\n"
  },
  {
    "path": "editors/ComponentEditor/busInterfaces/general/MasterModeEditor.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: MasterModeEditor.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 7.4.2011\r\n//\r\n// Description:\r\n// Editor to edit master or mirrored master settings of a bus interface.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"MasterModeEditor.h\"\r\n\r\n#include <IPXACTmodels/Component/Component.h>\r\n#include <IPXACTmodels/generaldeclarations.h>\r\n\r\n#include <editors/ComponentEditor/common/ExpressionEditor.h>\r\n#include <KactusAPI/include/ExpressionParser.h>\r\n#include <editors/ComponentEditor/parameters/ComponentParameterModel.h>\r\n#include <editors/ComponentEditor/memoryMaps/memoryMapsExpressionCalculators/ReferenceCalculator.h>\r\n#include <KactusAPI/include/BusInterfaceInterface.h>\r\n\r\n#include <QCompleter>\r\n#include <QGridLayout>\r\n#include <QLabel>\r\n#include <QString>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MasterModeEditor::MasterModeEditor()\r\n//-----------------------------------------------------------------------------\r\nMasterModeEditor::MasterModeEditor(BusInterfaceInterface* busInterface, std::string const& busName,\r\n    QSharedPointer<Component> component, QSharedPointer<ParameterFinder> parameterFinder,\r\n    QSharedPointer<ExpressionParser> expressionParser, QWidget *parent):\r\nModeEditorBase(busInterface, busName, tr(\"Master\"), parent),\r\naddressSpaceReferenceSelector_(this),\r\nbaseAddressEditor_(new ExpressionEditor(parameterFinder, this)),\r\nparameterFinder_(parameterFinder),\r\ncomponent_(component)\r\n{\r\n    baseAddressEditor_->setFixedHeight(ExpressionEditor::DEFAULT_HEIGHT);\r\n\r\n    ComponentParameterModel* componentParameterModel = new ComponentParameterModel(parameterFinder, this);\r\n    componentParameterModel->setExpressionParser(expressionParser);\r\n\r\n    auto baseAddressCompleter = new QCompleter(this);\r\n    baseAddressCompleter->setModel(componentParameterModel);\r\n    baseAddressEditor_->setAppendingCompleter(baseAddressCompleter);\r\n\r\n\tQLabel* addrSpaceLabel = new QLabel(tr(\"Address space:\"), this);\r\n\r\n    QString functionSymbol(QChar(0x0192));\r\n\tQLabel* baseAddrLabel = new QLabel(tr(\"Base address\") + \", \" + functionSymbol +\"(x):\", this);\r\n\r\n\tQGridLayout* topLayout = new QGridLayout(this);\r\n\ttopLayout->addWidget(addrSpaceLabel, 0, 0, 1, 1);\r\n\ttopLayout->addWidget(&addressSpaceReferenceSelector_, 0, 1, 1, 1);\r\n\ttopLayout->addWidget(baseAddrLabel, 1, 0, 1, 1);\r\n    topLayout->addWidget(baseAddressEditor_, 1, 1, 1, 1);\r\n    topLayout->setColumnStretch(1, 1);\r\n\ttopLayout->setRowStretch(2, 10);\r\n\r\n\tconnect(&addressSpaceReferenceSelector_, SIGNAL(itemSelected(const QString&)),\r\n\t\tthis, SLOT(onAddressSpaceChange(const QString&)), Qt::UniqueConnection);\r\n    connect(baseAddressEditor_, SIGNAL(editingFinished()), this, SLOT(onBaseAddressChange()), Qt::UniqueConnection);\r\n\r\n    connect(baseAddressEditor_, SIGNAL(increaseReference(QString)),\r\n        this, SIGNAL(increaseReferences(QString)), Qt::UniqueConnection);\r\n    connect(baseAddressEditor_, SIGNAL(decreaseReference(QString)),\r\n        this, SIGNAL(decreaseReferences(QString)), Qt::UniqueConnection);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MasterModeEditor::isValid()\r\n//-----------------------------------------------------------------------------\r\nbool MasterModeEditor::isValid() const\r\n{\r\n\tQString selectedAddrSpace = addressSpaceReferenceSelector_.currentText();\r\n\r\n\t// address space ref is not mandatory\r\n\tif (selectedAddrSpace.isEmpty())\r\n    {\r\n\t\treturn true;\r\n\t}\r\n\t\r\n\t// if the selected address space does not belong to component\r\n    QStringList addrSpaceNames = component_->getAddressSpaceNames();\r\n\tif (!addrSpaceNames.contains(selectedAddrSpace))\r\n    {\r\n\t\treturn false;\r\n\t}\r\n\t\r\n\treturn true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MasterModeEditor::refresh()\r\n//-----------------------------------------------------------------------------\r\nvoid MasterModeEditor::refresh()\r\n{\r\n    BusInterfaceInterface* busInterface = getBusInterface();\r\n    std::string busName = getBusName();\r\n\r\n\r\n\t// update the selectable items\r\n    addressSpaceReferenceSelector_.refresh(component_->getAddressSpaceNames());\r\n    QString addrSpaceRef = QString::fromStdString(busInterface->getAddressSpaceReference(busName));\r\n\r\n\t// if address space ref is empty then there can be no base address\r\n\tif (addrSpaceRef.isEmpty())\r\n    {\r\n        baseAddressEditor_->setDisabled(true);\r\n\t}\r\n\telse \r\n    {\r\n        baseAddressEditor_->blockSignals(true);\r\n\r\n        baseAddressEditor_->setEnabled(true);\r\n        baseAddressEditor_->setExpression(QString::fromStdString(busInterface->getBaseAddressExpression(busName)));\r\n        baseAddressEditor_->setToolTip(\r\n            QString::fromStdString(busInterface->getBaseAddressValue(busName)));\r\n\r\n        baseAddressEditor_->blockSignals(false);\r\n\t}\r\n\r\n\t// select the address space ref and base address\r\n\taddressSpaceReferenceSelector_.selectItem(addrSpaceRef);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MasterModeEditor::getInterfaceMode()\r\n//-----------------------------------------------------------------------------\r\nGeneral::InterfaceMode MasterModeEditor::getInterfaceMode() const\r\n{\r\n    return General::MASTER;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MasterModeEditor::onAddressSpaceChange()\r\n//-----------------------------------------------------------------------------\r\nvoid MasterModeEditor::onAddressSpaceChange(const QString& addrSpaceName)\r\n{\r\n    getBusInterface()->setAddressSpaceReference(getBusName(), addrSpaceName.toStdString());\r\n\r\n\t// if address space reference is empty then there can be no base address\r\n\tif (addrSpaceName.isEmpty())\r\n    {\r\n        removeReferencesFromExpressions();\r\n\r\n        baseAddressEditor_->setDisabled(true);\r\n\t}\r\n\telse\r\n    {\r\n        baseAddressEditor_->setEnabled(true);\r\n\t}\r\n\r\n\temit contentChanged();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MasterModeEditor::onBaseAddressChange()\r\n//-----------------------------------------------------------------------------\r\nvoid MasterModeEditor::onBaseAddressChange()\r\n{\r\n    BusInterfaceInterface* busInterface = getBusInterface();\r\n    std::string busName = getBusName();\r\n\r\n    baseAddressEditor_->finishEditingCurrentWord();\r\n    busInterface->setBaseAddress(busName, baseAddressEditor_->getExpression().toStdString());\r\n    baseAddressEditor_->setToolTip(\r\n        QString::fromStdString(busInterface->getBaseAddressValue(busName)));\r\n\r\n    emit contentChanged();\r\n}\t\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MasterModeEditor::saveModeSpecific()\r\n//-----------------------------------------------------------------------------\r\nvoid MasterModeEditor::saveModeSpecific()\r\n{\r\n    BusInterfaceInterface* busInterface = getBusInterface();\r\n    std::string busName = getBusName();\r\n\r\n    busInterface->setAddressSpaceReference(busName, addressSpaceReferenceSelector_.currentText().toStdString());\r\n    busInterface->setBaseAddress(busName, baseAddressEditor_->getExpression().toStdString());\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MasterModeEditor::removeReferencesFromExpressions()\r\n//-----------------------------------------------------------------------------\r\nvoid MasterModeEditor::removeReferencesFromExpressions()\r\n{\r\n    QStringList baseAddressExpression;\r\n    baseAddressExpression.append(baseAddressEditor_->getExpression());\r\n\r\n    ReferenceCalculator referenceCalculator(parameterFinder_);\r\n    QMap<QString, int> referencedParameters = referenceCalculator.getReferencedParameters(baseAddressExpression);\r\n\r\n    for (QString const& referencedId : referencedParameters.keys())\r\n    {\r\n        for (int i = 0; i < referencedParameters.value(referencedId); ++i)\r\n        {\r\n            emit decreaseReferences(referencedId);\r\n        }\r\n    }\r\n\r\n    baseAddressEditor_->clear();\r\n    getBusInterface()->setBaseAddress(getBusName(), \"\");\r\n}\r\n"
  },
  {
    "path": "editors/ComponentEditor/busInterfaces/general/MasterModeEditor.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: MasterModeEditor.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 7.4.2011\r\n//\r\n// Description:\r\n// Editor to edit master or mirrored master settings of a bus interface.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef MASTER_MODE_EDITOR_H\r\n#define MASTER_MODE_EDITOR_H\r\n\r\n#include \"ModeEditorBase.h\"\r\n\r\n#include <editors/ComponentEditor/common/ReferenceSelector/ReferenceSelector.h>\r\n\r\n#include <IPXACTmodels/generaldeclarations.h>\r\n\r\n#include <QString>\r\n#include <QSharedPointer>\r\n#include <QLineEdit>\r\n\r\nclass BusInterface;\r\nclass Component;\r\nclass ExpressionEditor;\r\nclass ExpressionParser;\r\nclass InitiatorInterface;\r\nclass ParameterFinder;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Editor to edit master or mirrored master settings of a bus interface.\r\n//-----------------------------------------------------------------------------\r\nclass MasterModeEditor : public ModeEditorBase\r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\r\n    /*!\r\n\t *  The constructor.\r\n\t *\r\n\t *    @param [in] busInterface        Interface for accessing bud interfaces.\r\n     *    @param [in] busName             Name of the edited bus interface.\r\n\t *    @param [in] component           The component being edited.\r\n\t *    @param [in] parameterFinder     The parameter finder.\r\n\t *    @param [in] expressionParser    The expression parser.\r\n\t *    @param [in] parent              The owner of this editor.\r\n\t */\r\n    MasterModeEditor(\r\n        BusInterfaceInterface* busInterface,\r\n        std::string const& busName,\r\n        QSharedPointer<Component> component,\r\n        QSharedPointer<ParameterFinder> parameterFinder,\r\n        QSharedPointer<ExpressionParser> expressionParser,\r\n        QWidget *parent);\r\n\r\n\t//! The destructor\r\n\tvirtual ~MasterModeEditor() = default;\r\n\r\n    //! No copying. No assignment.\r\n    MasterModeEditor(const MasterModeEditor& other) = delete;\r\n    MasterModeEditor& operator=(const MasterModeEditor& other) = delete;\r\n\r\n\t/*! Check for the validity of the edited item.\r\n\t*\r\n\t*    @return True if item is valid.\r\n\t*/\r\n\tbool isValid() const final;\r\n\r\n\t/*! Restore the changes made in the editor back to ones in the model.\r\n\t*\r\n\t*/\r\n\tvoid refresh() final;\r\n\r\n\t/*! Get the interface mode of the editor\r\n\t * \r\n\t *    @return General::InterfaceMode Specifies the interface mode.\r\n\t*/\r\n\tGeneral::InterfaceMode getInterfaceMode() const final;\r\n\r\n\t//! Save the interface mode-specific details to the bus interface.\r\n\tvoid saveModeSpecific() final;\r\n\r\n    /*!\r\n     *  Remove the references from the expressions.\r\n     */\r\n    void removeReferencesFromExpressions();\r\n\r\nsignals:\r\n\r\n    /*!\r\n     *  Increase the number of references to the given parameter.\r\n     *\r\n     *    @param [in] id  The id of the target parameter.\r\n     */\r\n    void increaseReferences(QString id);\r\n\r\n    /*!\r\n     *  Decrease the number of references to the given parameter.\r\n     *\r\n     *    @param [in] id  The id of the target parameter.\r\n     */\r\n    void decreaseReferences(QString id);\r\n\r\nprivate slots:\r\n\r\n\t/*!\r\n\t *  Handler for changes in address space reference.\r\n\t *\r\n\t *    @param [in] addrSpaceName   The name of the referenced address space.\r\n\t */\r\n\tvoid onAddressSpaceChange(QString const& addrSpaceName);\r\n\r\n    /*!\r\n     *  Handler for changes in base address.\r\n     */\r\n    void onBaseAddressChange();\r\n\r\nprivate:\r\n\r\n    //-----------------------------------------------------------------------------\r\n    //! Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n\t//! Combo box to select an address space within component\r\n\tReferenceSelector addressSpaceReferenceSelector_;\r\n\r\n    //! Editor for the base address of an address space.\r\n    ExpressionEditor* baseAddressEditor_;\r\n\r\n    //! The parameter finder.\r\n    QSharedPointer<ParameterFinder> parameterFinder_;\r\n\r\n    //! The containing component.\r\n    QSharedPointer<Component> component_;\r\n};\r\n\r\n#endif // MASTER_MODE_EDITOR_H\r\n"
  },
  {
    "path": "editors/ComponentEditor/busInterfaces/general/MirroredInitiatorModeEditor.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: MirroredInitiatorModeEditor.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Esko Pekkarinen\n// Date: 29.6.2023\n//\n// Description:\n// Editor to edit mirrored initiator settings of a bus interface.\n//-----------------------------------------------------------------------------\n\n#include \"MirroredInitiatorModeEditor.h\"\n\n#include <QLabel>\n#include <QString>\n#include <QVBoxLayout>\n\n//-----------------------------------------------------------------------------\n// Function: MirroredInitiatorModeEditor::MirroredInitiatorModeEditor()\n//-----------------------------------------------------------------------------\nMirroredInitiatorModeEditor::MirroredInitiatorModeEditor(BusInterfaceInterface* busInterface,\n    std::string const& busName, QWidget* parent):\nModeEditorBase(busInterface, busName, tr(\"Mirrored initiator\"), parent)\n{\n    QLabel* textLabel = new QLabel(tr(\"No mode specific options.\"));\n\n    QVBoxLayout* verticalLayout = new QVBoxLayout(this);\n    verticalLayout->addWidget(textLabel, 0, Qt::AlignTop);\n}\n\n//-----------------------------------------------------------------------------\n// Function: MirroredInitiatorModeEditor::isValid()\n//-----------------------------------------------------------------------------\nbool MirroredInitiatorModeEditor::isValid() const\n{\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: MirroredInitiatorModeEditor::refresh()\n//-----------------------------------------------------------------------------\nvoid MirroredInitiatorModeEditor::refresh()\n{\n    // Intentionally empty.\n}\n\n//-----------------------------------------------------------------------------\n// Function: MirroredInitiatorModeEditor::getInterfaceMode()\n//-----------------------------------------------------------------------------\nGeneral::InterfaceMode MirroredInitiatorModeEditor::getInterfaceMode() const\n{\n    return General::MIRRORED_INITIATOR;\n}\n\n//-----------------------------------------------------------------------------\n// Function: MirroredInitiatorModeEditor::saveModeSpecific()\n//-----------------------------------------------------------------------------\nvoid MirroredInitiatorModeEditor::saveModeSpecific()\n{\n    // Intentionally empty.\n}\n"
  },
  {
    "path": "editors/ComponentEditor/busInterfaces/general/MirroredInitiatorModeEditor.h",
    "content": "//-----------------------------------------------------------------------------\n// File: MirroredInitiatorModeEditor.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Esko Pekkarinen\n// Date: 29.6.2023\n//\n// Description:\n// Editor to edit mirrored initiator settings of a bus interface.\n//-----------------------------------------------------------------------------\n\n#ifndef MIRRORED_INITIATOR_MODE_EDITOR_H\n#define MIRRORED_INITIATOR_MODE_EDITOR_H\n\n#include \"ModeEditorBase.h\"\n\nclass BusInterfaceInterface;\n\n//-----------------------------------------------------------------------------\n//! Editor to edit mirrored initiator settings of a bus interface.\n//-----------------------------------------------------------------------------\nclass MirroredInitiatorModeEditor : public ModeEditorBase\n{\n\npublic:\n\n    /*!\n     *  The constructor.\n     *\n     *    @param [in] busInterface    Interface for accessing bus interfaces.\n     *    @param [in] parent          Parent widget of this editor.\n     */\n    MirroredInitiatorModeEditor(BusInterfaceInterface* busInterface, std::string const& busName, QWidget* parent);\n\n\t/*!\n     *  The destructor.\n     */\n    virtual ~MirroredInitiatorModeEditor() = default;\n\n    //! No copying.\n    MirroredInitiatorModeEditor(const MirroredInitiatorModeEditor& other) = delete;\n\n    //! No assignment.\n    MirroredInitiatorModeEditor& operator=(const MirroredInitiatorModeEditor& other) = delete;\n\n\t/*!\n     *   Check for the validity of the edited item.\n\t *\n\t *    @return True if item is valid.\n\t */\n\tbool isValid() const final;\n\n\t/*!\n     *  Restore the changes made in the editor back to ones in the model.\n\t */\n\tvoid refresh() final;\n\n\t/*!\n     *  Get the interface mode of the editor\n\t * \n\t *    @return General::InterfaceMode Specifies the interface mode.\n\t */\n\tGeneral::InterfaceMode getInterfaceMode() const final;\n\n\t/*!\n     *  Save the interface mode-specific details to the bus interface.\n     */\n\tvoid saveModeSpecific() final;\n\n};\n\n#endif // MIRRORED_INITIATOR_MODE_EDITOR_H\n"
  },
  {
    "path": "editors/ComponentEditor/busInterfaces/general/MirroredMasterModeEditor.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: MirroredMasterModeEditor.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 06.03.2017\n//\n// Description:\n// Display for mirrored master bus interface.\n//-----------------------------------------------------------------------------\n\n#include \"MirroredMasterModeEditor.h\"\n\n#include <QLabel>\n#include <QString>\n#include <QVBoxLayout>\n\n//-----------------------------------------------------------------------------\n// Function: MirroredMasterModeEditor::MirroredMasterModeEditor()\n//-----------------------------------------------------------------------------\nMirroredMasterModeEditor::MirroredMasterModeEditor(BusInterfaceInterface* busInterface,\n    std::string const& busName, QWidget* parent):\nModeEditorBase(busInterface, busName, tr(\"Mirrored master\"), parent)\n{\n    QLabel* textLabel = new QLabel(tr(\"No mode specific options.\"));\n\n    QVBoxLayout* verticalLayout = new QVBoxLayout(this);\n    verticalLayout->addWidget(textLabel, 0, Qt::AlignTop);\n}\n\n//-----------------------------------------------------------------------------\n// Function: MirroredMasterModeEditor::isValid()\n//-----------------------------------------------------------------------------\nbool MirroredMasterModeEditor::isValid() const\n{\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: MirroredMasterModeEditor::refresh()\n//-----------------------------------------------------------------------------\nvoid MirroredMasterModeEditor::refresh()\n{\n    // Intentionally empty.\n}\n\n//-----------------------------------------------------------------------------\n// Function: MirroredMasterModeEditor::getInterfaceMode()\n//-----------------------------------------------------------------------------\nGeneral::InterfaceMode MirroredMasterModeEditor::getInterfaceMode() const\n{\n    return General::MIRRORED_MASTER;\n}\n\n//-----------------------------------------------------------------------------\n// Function: MirroredMasterModeEditor::saveModeSpecific()\n//-----------------------------------------------------------------------------\nvoid MirroredMasterModeEditor::saveModeSpecific()\n{\n    // Intentionally empty.\n}\n"
  },
  {
    "path": "editors/ComponentEditor/busInterfaces/general/MirroredMasterModeEditor.h",
    "content": "//-----------------------------------------------------------------------------\n// File: MirroredMasterModeEditor.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 06.03.2017\n//\n// Description:\n// Display for mirrored master bus interface.\n//-----------------------------------------------------------------------------\n\n#ifndef MIRRORED_MASTER_MODE_EDITOR_H\n#define MIRRORED_MASTER_MODE_EDITOR_H\n\n#include \"ModeEditorBase.h\"\n\nclass BusInterfaceInterface;\n\n//-----------------------------------------------------------------------------\n//! Editor to edit master or mirrored master settings of a bus interface.\n//-----------------------------------------------------------------------------\nclass MirroredMasterModeEditor : public ModeEditorBase\n{\n\npublic:\n\n    /*!\n     *  The constructor.\n     *\n     *    @param [in] busInterface    Interface for accessing bus interfaces.\n     *    @param [in] parent          Parent widget of this editor.\n     */\n    MirroredMasterModeEditor(BusInterfaceInterface* busInterface, std::string const& busName, QWidget* parent);\n\n\t/*!\n     *  The destructor.\n     */\n    virtual ~MirroredMasterModeEditor() = default;\n\n    //! No copying.\n    MirroredMasterModeEditor(const MirroredMasterModeEditor& other) = delete;\n\n    //! No assignment.\n    MirroredMasterModeEditor& operator=(const MirroredMasterModeEditor& other) = delete;\n\n\t/*!\n     *   Check for the validity of the edited item.\n\t *\n\t *    @return True if item is valid.\n\t */\n\tbool isValid() const final;\n\n\t/*!\n     *  Restore the changes made in the editor back to ones in the model.\n\t */\n\tvoid refresh() final;\n\n\t/*!\n     *  Get the interface mode of the editor\n\t * \n\t *    @return General::InterfaceMode Specifies the interface mode.\n\t */\n\tGeneral::InterfaceMode getInterfaceMode() const final;\n\n\t/*!\n     *  Save the interface mode-specific details to the bus interface.\n     */\n\tvoid saveModeSpecific() final;\n\n};\n\n#endif // MIRRORED_MASTER_MODE_EDITOR_H\n"
  },
  {
    "path": "editors/ComponentEditor/busInterfaces/general/MirroredSlaveModeEditor.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: MirroredSlaveModeEditor.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 7.4.2011\r\n//\r\n// Description:\r\n// Editor to edit mirrored slave details of a bus interface.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"MirroredSlaveModeEditor.h\"\r\n\r\n#include <IPXACTmodels/generaldeclarations.h>\r\n\r\n#include <IPXACTmodels/Component/Component.h>\r\n#include <IPXACTmodels/Component/BusInterface.h>\r\n#include <IPXACTmodels/Component/MirroredTargetInterface.h>\r\n\r\n#include <editors/ComponentEditor/common/ExpressionEditor.h>\r\n#include <KactusAPI/include/ExpressionFormatter.h>\r\n#include <KactusAPI/include/ExpressionParser.h>\r\n#include <editors/ComponentEditor/parameters/ComponentParameterModel.h>\r\n#include <editors/ComponentEditor/memoryMaps/memoryMapsExpressionCalculators/ReferenceCalculator.h>\r\n#include <KactusAPI/include/BusInterfaceInterface.h>\r\n\r\n#include <QCompleter>\r\n#include <QGridLayout>\r\n#include <QLabel>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MirroredSlaveModeEditor::MirroredSlaveModeEditor()\r\n//-----------------------------------------------------------------------------\r\nMirroredSlaveModeEditor::MirroredSlaveModeEditor(BusInterfaceInterface* busInterface, std::string const& busName,\r\n    QSharedPointer<ParameterFinder> parameterFinder, QSharedPointer<ExpressionParser> expressionParser,\r\n    QWidget *parent):\r\nModeEditorBase(busInterface, busName, tr(\"Mirrored slave\"), parent),\r\nremapEditor_(new ExpressionEditor(parameterFinder, this)),\r\nrangeEditor_(new ExpressionEditor(parameterFinder, this)),\r\nexpressionParser_(expressionParser),\r\nparameterFinder_(parameterFinder)\r\n{\r\n    QString functionSymbol(QChar(0x0192));\r\n\tQLabel* remapLabel = new QLabel(tr(\"Remap address\") + \", \" + functionSymbol + \"(x):\", this);\r\n\tQLabel* rangeLabel = new QLabel(tr(\"Range\") + \", \" + functionSymbol + \"(x):\", this);\r\n\r\n    remapEditor_->setFixedHeight(ExpressionEditor::DEFAULT_HEIGHT);\r\n    rangeEditor_->setFixedHeight(ExpressionEditor::DEFAULT_HEIGHT);\r\n\r\n    ComponentParameterModel* componentParameterModel = new ComponentParameterModel(parameterFinder, this);\r\n    componentParameterModel->setExpressionParser(expressionParser);\r\n\r\n    auto remapCompleter = new QCompleter(this);\r\n    remapCompleter->setModel(componentParameterModel);\r\n    remapEditor_->setAppendingCompleter(remapCompleter);\r\n\r\n    auto rangeCompleter = new QCompleter(this);\r\n    rangeCompleter->setModel(componentParameterModel);\r\n    rangeEditor_->setAppendingCompleter(rangeCompleter);\r\n\r\n\tQGridLayout* topLayout = new QGridLayout(this);\r\n\ttopLayout->addWidget(remapLabel, 0, 0, 1, 1);\r\n    topLayout->addWidget(remapEditor_, 0, 1, 1, 1);\r\n\ttopLayout->addWidget(rangeLabel, 1, 0, 1, 1);\r\n    topLayout->addWidget(rangeEditor_, 1, 1, 1, 1);\r\n\r\n\ttopLayout->setColumnStretch(1, 1);\r\n\ttopLayout->setRowStretch(2, 1);\r\n\r\n    connect(remapEditor_, SIGNAL(editingFinished()), this, SLOT(onRemapChange()), Qt::UniqueConnection);\r\n    connect(rangeEditor_, SIGNAL(editingFinished()), this, SLOT(onRangeChange()), Qt::UniqueConnection);\r\n\r\n    connect(remapEditor_, SIGNAL(increaseReference(QString)),\r\n        this, SIGNAL(increaseReferences(QString)), Qt::UniqueConnection);\r\n    connect(remapEditor_, SIGNAL(decreaseReference(QString)),\r\n        this, SIGNAL(decreaseReferences(QString)), Qt::UniqueConnection);\r\n    connect(rangeEditor_, SIGNAL(increaseReference(QString)),\r\n        this, SIGNAL(increaseReferences(QString)), Qt::UniqueConnection);\r\n    connect(rangeEditor_, SIGNAL(decreaseReference(QString)),\r\n        this, SIGNAL(decreaseReferences(QString)), Qt::UniqueConnection);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MirroredSlaveModeEditor::isValid()\r\n//-----------------------------------------------------------------------------\r\nbool MirroredSlaveModeEditor::isValid() const\r\n{\r\n\treturn true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MirroredSlaveModeEditor::refresh()\r\n//-----------------------------------------------------------------------------\r\nvoid MirroredSlaveModeEditor::refresh()\r\n{\r\n    rangeEditor_->blockSignals(true);\r\n\r\n    BusInterfaceInterface* busInterface = getBusInterface();\r\n    std::string busName = getBusName();\r\n\r\n    rangeEditor_->setExpression(QString::fromStdString(busInterface->getRangeExpression(busName)));\r\n    rangeEditor_->setToolTip(QString::fromStdString(busInterface->getRangeValue(busName)));\r\n\r\n    rangeEditor_->blockSignals(false);\r\n\r\n    remapEditor_->blockSignals(true);\r\n\r\n    remapEditor_->setExpression(QString::fromStdString(busInterface->getRemapAddressExpression(busName)));\r\n    remapEditor_->setToolTip(QString::fromStdString(busInterface->getRemapAddressValue(busName)));\r\n\r\n    remapEditor_->blockSignals(false);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MirroredSlaveModeEditor::getInterfaceMode()\r\n//-----------------------------------------------------------------------------\r\nGeneral::InterfaceMode MirroredSlaveModeEditor::getInterfaceMode() const\r\n{\r\n\treturn General::MIRRORED_SLAVE;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MirroredSlaveModeEditor::saveModeSpecific()\r\n//-----------------------------------------------------------------------------\r\nvoid MirroredSlaveModeEditor::saveModeSpecific()\r\n{\r\n    BusInterfaceInterface* busInterface = getBusInterface();\r\n    std::string busName = getBusName();\r\n\r\n    busInterface->setRange(busName, rangeEditor_->getExpression().toStdString());\r\n    busInterface->setRemapAddress(busName, remapEditor_->getExpression().toStdString());\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MirroredSlaveModeEditor::onRemapChange()\r\n//-----------------------------------------------------------------------------\r\nvoid MirroredSlaveModeEditor::onRemapChange()\r\n{\r\n    remapEditor_->finishEditingCurrentWord();\r\n\r\n    QString newRemapAddress = remapEditor_->getExpression();\r\n\r\n    BusInterfaceInterface* busInterface = getBusInterface();\r\n    std::string busName = getBusName();\r\n\r\n    busInterface->setRemapAddress(busName, newRemapAddress.toStdString());\r\n\r\n    remapEditor_->setToolTip(QString::fromStdString(busInterface->getRemapAddressValue(busName)));\r\n\r\n    emit contentChanged();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MirroredSlaveModeEditor::onRangeChange()\r\n//-----------------------------------------------------------------------------\r\nvoid MirroredSlaveModeEditor::onRangeChange()\r\n{\r\n    rangeEditor_->finishEditingCurrentWord();\r\n\r\n    BusInterfaceInterface* busInterface = getBusInterface();\r\n    std::string busName = getBusName();\r\n\r\n    busInterface->setRange(busName, rangeEditor_->getExpression().toStdString());\r\n    rangeEditor_->setToolTip(QString::fromStdString(busInterface->getRangeValue(busName)));\r\n\r\n    emit contentChanged();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MirroredSlaveModeEditor::removeReferencesFromExpressions()\r\n//-----------------------------------------------------------------------------\r\nvoid MirroredSlaveModeEditor::removeReferencesFromExpressions()\r\n{\r\n    QStringList expressionList;\r\n    expressionList.append(rangeEditor_->getExpression());\r\n    expressionList.append(remapEditor_->getExpression());\r\n\r\n    ReferenceCalculator referenceCalculator(parameterFinder_);\r\n    QMap<QString, int> referencedParameters = referenceCalculator.getReferencedParameters(expressionList);\r\n\r\n    for (QString const& referencedId : referencedParameters.keys())\r\n    {\r\n        for (int i = 0; i < referencedParameters.value(referencedId); ++i)\r\n        {\r\n            emit decreaseReferences(referencedId);\r\n        }\r\n    }\r\n\r\n    remapEditor_->clear();\r\n\r\n    BusInterfaceInterface* busInterface = getBusInterface();\r\n    std::string busName = getBusName();\r\n\r\n    busInterface->setRemapAddress(busName, \"\");\r\n\r\n    rangeEditor_->clear();\r\n    busInterface->setRange(busName, \"\");\r\n}\r\n"
  },
  {
    "path": "editors/ComponentEditor/busInterfaces/general/MirroredSlaveModeEditor.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: MirroredSlaveModeEditor.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 7.4.2011\r\n//\r\n// Description:\r\n// Editor to edit mirrored slave details of a bus interface.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef MIRRORED_SLAVE_MODE_EDITOR_H\r\n#define MIRRORED_SLAVE_MODE_EDITOR_H\r\n\r\n#include \"ModeEditorBase.h\"\r\n\r\n#include <KactusAPI/include/ParameterFinder.h>\r\n\r\n#include <QSharedPointer>\r\n#include <QLineEdit>\r\n\r\nclass BusInterface;\r\nclass Component;\r\nclass ExpressionEditor;\r\nclass ExpressionParser;\r\nclass MirroredSlaveInterface;\r\nclass BusInterfaceInterface;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Editor to edit mirrored slave details of a bus interface.\r\n//-----------------------------------------------------------------------------\r\nclass MirroredSlaveModeEditor : public ModeEditorBase\r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\r\n\t/*!\r\n\t *  The constructor.\r\n\t *\r\n\t *    @param [in] busInterface        Interface for accessing bus interfaces.\r\n     *    @param [in] busName             Name of the edited bus interface.\r\n\t *    @param [in] parameterFinder     The parameter finder.\r\n     *    @param [in] expressionParser    The expression parser.\r\n\t *    @param [in] parent              The owner of this editor.\r\n\t */\r\n    MirroredSlaveModeEditor(BusInterfaceInterface* busInterface,\r\n        std::string const& busName,\r\n        QSharedPointer<ParameterFinder> parameterFinder,\r\n        QSharedPointer<ExpressionParser> expressionParser,\r\n        QWidget *parent);\r\n\r\n\t/*!\r\n     *  The destructor.\r\n     */\r\n    virtual ~MirroredSlaveModeEditor() = default;\r\n\r\n    //! No copying. No assignment.\r\n    MirroredSlaveModeEditor(const MirroredSlaveModeEditor& other) = delete;\r\n    MirroredSlaveModeEditor& operator=(const MirroredSlaveModeEditor& other) = delete;\r\n\r\n\t/*!\r\n     *  Check for the validity of the edited item.\r\n     *\r\n     *    @return True if item is valid.\r\n     */\r\n\tbool isValid() const final;\r\n\r\n\t/*!\r\n     *  Restore the changes made in the editor back to ones in the model.\r\n     *\r\n     */\r\n\tvoid refresh() final;\r\n\r\n\t/*!\r\n     *  Get the interface mode of the editor.\r\n\t * \r\n\t *    @return General::InterfaceMode Specifies the interface mode.\r\n     */\r\n\tGeneral::InterfaceMode getInterfaceMode() const final;\r\n\r\n\t/*!\r\n     *  Save the interface mode-specific details to the bus interface.\r\n     */\r\n\tvoid saveModeSpecific() final;\r\n\r\n    /*!\r\n     *  Remove all the references from the expressions contained within this interface.\r\n     */\r\n    void removeReferencesFromExpressions();\r\n\r\nprivate slots:\r\n\r\n    /*!\r\n     *  Handler for changes in remap address.\r\n     */\r\n    void onRemapChange();\r\n\r\n    /*!\r\n     *  Handler for changes in range.\r\n     */\r\n    void onRangeChange();\r\n\r\nsignals:\r\n\r\n    /*!\r\n     *  Increase the number of references in the selected parameter.\r\n     *\r\n     *    @param [in] id      The id of the selected parameter.\r\n     */\r\n    void increaseReferences(QString const& id);\r\n\r\n    /*!\r\n     *  Decrease the number of references in the selected parameter.\r\n     *\r\n     *    @param [in] id      The id of the selected parameter.\r\n     */\r\n    void decreaseReferences(QString const& id);\r\n\r\nprivate:\r\n\r\n    //-----------------------------------------------------------------------------\r\n    //! Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! Editor for the mirrored slave remap address.\r\n    ExpressionEditor* remapEditor_;\r\n\r\n    //! Editor for the mirrored slave range.\r\n    ExpressionEditor* rangeEditor_;\r\n\r\n    //! The expression parser for calculating the expression.\r\n    QSharedPointer<ExpressionParser> expressionParser_;\r\n\r\n    //! The parameter finder for searching the component parameters.\r\n    QSharedPointer<ParameterFinder> parameterFinder_;\r\n};\r\n\r\n#endif // MIRRORED_SLAVE_MODE_EDITOR_H\r\n"
  },
  {
    "path": "editors/ComponentEditor/busInterfaces/general/MirroredTargetModeEditor.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: MirroredTargetModeEditor.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Esko Pekkarinen\n// Date: 29.6.2023\n//\n// Description:\n// Editor to edit mirrored target details of a bus interface.\n//-----------------------------------------------------------------------------\n\n#include \"MirroredTargetModeEditor.h\"\n\n#include <IPXACTmodels/generaldeclarations.h>\n\n#include <IPXACTmodels/Component/Component.h>\n#include <IPXACTmodels/Component/BusInterface.h>\n#include <IPXACTmodels/Component/MirroredTargetInterface.h>\n\n#include <editors/ComponentEditor/common/ExpressionEditor.h>\n#include <KactusAPI/include/ExpressionFormatter.h>\n#include <KactusAPI/include/ExpressionParser.h>\n#include <editors/ComponentEditor/parameters/ComponentParameterModel.h>\n#include <editors/ComponentEditor/memoryMaps/memoryMapsExpressionCalculators/ReferenceCalculator.h>\n#include <KactusAPI/include/BusInterfaceInterface.h>\n\n#include <QCompleter>\n#include <QGridLayout>\n#include <QLabel>\n\n//-----------------------------------------------------------------------------\n// Function: MirroredTargetModeEditor::MirroredTargetModeEditor()\n//-----------------------------------------------------------------------------\nMirroredTargetModeEditor::MirroredTargetModeEditor(BusInterfaceInterface* busInterface, std::string const& busName,\n    QSharedPointer<ParameterFinder> parameterFinder, QSharedPointer<ExpressionParser> expressionParser,\n    QWidget *parent):\nModeEditorBase(busInterface, busName, tr(\"Mirrored target\"), parent),\nremapEditor_(new ExpressionEditor(parameterFinder, this)),\nrangeEditor_(new ExpressionEditor(parameterFinder, this)),\nexpressionParser_(expressionParser),\nparameterFinder_(parameterFinder)\n{\n\tQLabel* remapLabel = new QLabel(tr(\"Remap address, f(x)\"), this);\n\tQLabel* rangeLabel = new QLabel(tr(\"Range, f(x):\"), this);\n\n    remapEditor_->setFixedHeight(ExpressionEditor::DEFAULT_HEIGHT);\n    rangeEditor_->setFixedHeight(ExpressionEditor::DEFAULT_HEIGHT);\n\n    ComponentParameterModel* componentParameterModel = new ComponentParameterModel(parameterFinder, this);\n    componentParameterModel->setExpressionParser(expressionParser);\n\n    auto remapCompleter = new QCompleter(this);\n    remapCompleter->setModel(componentParameterModel);\n    remapEditor_->setAppendingCompleter(remapCompleter);\n\n    auto rangeCompleter = new QCompleter(this);\n    rangeCompleter->setModel(componentParameterModel);\n    rangeEditor_->setAppendingCompleter(rangeCompleter);\n\n\tQGridLayout* topLayout = new QGridLayout(this);\n\ttopLayout->addWidget(remapLabel, 0, 0, 1, 1);\n    topLayout->addWidget(remapEditor_, 0, 1, 1, 1);\n\ttopLayout->addWidget(rangeLabel, 1, 0, 1, 1);\n    topLayout->addWidget(rangeEditor_, 1, 1, 1, 1);\n\n\ttopLayout->setColumnStretch(1, 1);\n\ttopLayout->setRowStretch(2, 1);\n\n    connect(remapEditor_, SIGNAL(editingFinished()), this, SLOT(onRemapChange()), Qt::UniqueConnection);\n    connect(rangeEditor_, SIGNAL(editingFinished()), this, SLOT(onRangeChange()), Qt::UniqueConnection);\n\n    connect(remapEditor_, SIGNAL(increaseReference(QString)),\n        this, SIGNAL(increaseReferences(QString)), Qt::UniqueConnection);\n    connect(remapEditor_, SIGNAL(decreaseReference(QString)),\n        this, SIGNAL(decreaseReferences(QString)), Qt::UniqueConnection);\n    connect(rangeEditor_, SIGNAL(increaseReference(QString)),\n        this, SIGNAL(increaseReferences(QString)), Qt::UniqueConnection);\n    connect(rangeEditor_, SIGNAL(decreaseReference(QString)),\n        this, SIGNAL(decreaseReferences(QString)), Qt::UniqueConnection);\n}\n\n//-----------------------------------------------------------------------------\n// Function: MirroredTargetModeEditor::isValid()\n//-----------------------------------------------------------------------------\nbool MirroredTargetModeEditor::isValid() const\n{\n\treturn true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: MirroredTargetModeEditor::refresh()\n//-----------------------------------------------------------------------------\nvoid MirroredTargetModeEditor::refresh()\n{\n    rangeEditor_->blockSignals(true);\n\n    BusInterfaceInterface* busInterface = getBusInterface();\n    std::string busName = getBusName();\n\n    rangeEditor_->setExpression(QString::fromStdString(busInterface->getRangeExpression(busName)));\n    rangeEditor_->setToolTip(QString::fromStdString(busInterface->getRangeValue(busName)));\n\n    rangeEditor_->blockSignals(false);\n\n    remapEditor_->blockSignals(true);\n\n    remapEditor_->setExpression(QString::fromStdString(busInterface->getRemapAddressExpression(busName)));\n    remapEditor_->setToolTip(QString::fromStdString(busInterface->getRemapAddressValue(busName)));\n\n    remapEditor_->blockSignals(false);\n}\n\n//-----------------------------------------------------------------------------\n// Function: MirroredTargetModeEditor::getInterfaceMode()\n//-----------------------------------------------------------------------------\nGeneral::InterfaceMode MirroredTargetModeEditor::getInterfaceMode() const\n{\n\treturn General::MIRRORED_SLAVE;\n}\n\n//-----------------------------------------------------------------------------\n// Function: MirroredTargetModeEditor::saveModeSpecific()\n//-----------------------------------------------------------------------------\nvoid MirroredTargetModeEditor::saveModeSpecific()\n{\n    BusInterfaceInterface* busInterface = getBusInterface();\n    std::string busName = getBusName();\n\n    busInterface->setRange(busName, rangeEditor_->getExpression().toStdString());\n    busInterface->setRemapAddress(busName, remapEditor_->getExpression().toStdString());\n}\n\n//-----------------------------------------------------------------------------\n// Function: MirroredTargetModeEditor::onRemapChange()\n//-----------------------------------------------------------------------------\nvoid MirroredTargetModeEditor::onRemapChange()\n{\n    remapEditor_->finishEditingCurrentWord();\n\n    QString newRemapAddress = remapEditor_->getExpression();\n\n    BusInterfaceInterface* busInterface = getBusInterface();\n    std::string busName = getBusName();\n\n    busInterface->setRemapAddress(busName, newRemapAddress.toStdString());\n\n    remapEditor_->setToolTip(QString::fromStdString(busInterface->getRemapAddressValue(busName)));\n\n    emit contentChanged();\n}\n\n//-----------------------------------------------------------------------------\n// Function: MirroredTargetModeEditor::onRangeChange()\n//-----------------------------------------------------------------------------\nvoid MirroredTargetModeEditor::onRangeChange()\n{\n    rangeEditor_->finishEditingCurrentWord();\n\n    BusInterfaceInterface* busInterface = getBusInterface();\n    std::string busName = getBusName();\n\n    busInterface->setRange(busName, rangeEditor_->getExpression().toStdString());\n    rangeEditor_->setToolTip(QString::fromStdString(busInterface->getRangeValue(busName)));\n\n    emit contentChanged();\n}\n\n//-----------------------------------------------------------------------------\n// Function: MirroredTargetModeEditor::removeReferencesFromExpressions()\n//-----------------------------------------------------------------------------\nvoid MirroredTargetModeEditor::removeReferencesFromExpressions()\n{\n    QStringList expressionList;\n    expressionList.append(rangeEditor_->getExpression());\n    expressionList.append(remapEditor_->getExpression());\n\n    ReferenceCalculator referenceCalculator(parameterFinder_);\n    QMap<QString, int> referencedParameters = referenceCalculator.getReferencedParameters(expressionList);\n\n    foreach (QString referencedId, referencedParameters.keys())\n    {\n        for (int i = 0; i < referencedParameters.value(referencedId); ++i)\n        {\n            emit decreaseReferences(referencedId);\n        }\n    }\n\n    remapEditor_->clear();\n\n    BusInterfaceInterface* busInterface = getBusInterface();\n    std::string busName = getBusName();\n\n    busInterface->setRemapAddress(busName, \"\");\n\n    rangeEditor_->clear();\n    busInterface->setRange(busName, \"\");\n}\n"
  },
  {
    "path": "editors/ComponentEditor/busInterfaces/general/MirroredTargetModeEditor.h",
    "content": "//-----------------------------------------------------------------------------\n// File: MirroredTargetModeEditor.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Esko Pekkarinen\n// Date: 29.6.2023\n//\n// Description:\n// Editor to edit mirrored target details of a bus interface.\n//-----------------------------------------------------------------------------\n\n#ifndef MIRRORED_TARGET_MODE_EDITOR_H\n#define MIRRORED_TARGET_MODE_EDITOR_H\n\n#include \"ModeEditorBase.h\"\n\n#include <KactusAPI/include/ParameterFinder.h>\n\n#include <QSharedPointer>\n#include <QLineEdit>\n\nclass BusInterface;\nclass Component;\nclass ExpressionEditor;\nclass ExpressionParser;\nclass MirroredSlaveInterface;\nclass BusInterfaceInterface;\n\n//-----------------------------------------------------------------------------\n//! Editor to edit mirrored slave details of a bus interface.\n//-----------------------------------------------------------------------------\nclass MirroredTargetModeEditor : public ModeEditorBase\n{\n\tQ_OBJECT\n\npublic:\n\n\t/*!\n\t *  The constructor.\n\t *\n\t *    @param [in] busInterface        Interface for accessing bus interfaces.\n     *    @param [in] busName             Name of the edited bus interface.\n\t *    @param [in] parameterFinder     The parameter finder.\n     *    @param [in] expressionParser    The expression parser.\n\t *    @param [in] parent              The owner of this editor.\n\t */\n    MirroredTargetModeEditor(BusInterfaceInterface* busInterface,\n        std::string const& busName,\n        QSharedPointer<ParameterFinder> parameterFinder,\n        QSharedPointer<ExpressionParser> expressionParser,\n        QWidget *parent);\n\n\t/*!\n     *  The destructor.\n     */\n    virtual ~MirroredTargetModeEditor() = default;\n\n    //! No copying. No assignment.\n    MirroredTargetModeEditor(const MirroredTargetModeEditor& other) = delete;\n    MirroredTargetModeEditor& operator=(const MirroredTargetModeEditor& other) = delete;\n\n\t/*!\n     *  Check for the validity of the edited item.\n     *\n     *    @return True if item is valid.\n     */\n\tbool isValid() const final;\n\n\t/*!\n     *  Restore the changes made in the editor back to ones in the model.\n     *\n     */\n\tvoid refresh() final;\n\n\t/*!\n     *  Get the interface mode of the editor.\n\t * \n\t *    @return General::InterfaceMode Specifies the interface mode.\n     */\n\tGeneral::InterfaceMode getInterfaceMode() const final;\n\n\t/*!\n     *  Save the interface mode-specific details to the bus interface.\n     */\n\tvoid saveModeSpecific() final;\n\n    /*!\n     *  Remove all the references from the expressions contained within this interface.\n     */\n    void removeReferencesFromExpressions();\n\nprivate slots:\n\n    /*!\n     *  Handler for changes in remap address.\n     */\n    void onRemapChange();\n\n    /*!\n     *  Handler for changes in range.\n     */\n    void onRangeChange();\n\nsignals:\n\n    /*!\n     *  Increase the number of references in the selected parameter.\n     *\n     *    @param [in] id      The id of the selected parameter.\n     */\n    void increaseReferences(QString const& id);\n\n    /*!\n     *  Decrease the number of references in the selected parameter.\n     *\n     *    @param [in] id      The id of the selected parameter.\n     */\n    void decreaseReferences(QString const& id);\n\nprivate:\n\n    //-----------------------------------------------------------------------------\n    //! Data.\n    //-----------------------------------------------------------------------------\n\n    //! Editor for the mirrored slave remap address.\n    ExpressionEditor* remapEditor_;\n\n    //! Editor for the mirrored slave range.\n    ExpressionEditor* rangeEditor_;\n\n    //! The expression parser for calculating the expression.\n    QSharedPointer<ExpressionParser> expressionParser_;\n\n    //! The parameter finder for searching the component parameters.\n    QSharedPointer<ParameterFinder> parameterFinder_;\n};\n\n#endif // MIRRORED_TARGET_MODE_EDITOR_H\n"
  },
  {
    "path": "editors/ComponentEditor/busInterfaces/general/ModeEditorBase.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ModeEditorBase.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 7.4.2011\r\n//\r\n// Description:\r\n// Base class for different interface mode editors of a bus interface.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"ModeEditorBase.h\"\r\n\r\n#include <KactusAPI/include/BusInterfaceInterface.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ModeEditorBase::ModeEditorBase()\r\n//-----------------------------------------------------------------------------\r\nModeEditorBase::ModeEditorBase(BusInterfaceInterface* busInterface, std::string const& busName,\r\n    QString const& title, QWidget* parent):\r\nQGroupBox(title, parent),\r\nbusInterface_(busInterface),\r\nbusName_(busName)\r\n{\r\n    Q_ASSERT(busInterface_);\r\n\r\n    setFlat(true);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ModeEditorBase::changeName()\r\n//-----------------------------------------------------------------------------\r\nvoid ModeEditorBase::changeName(std::string const& newName)\r\n{\r\n    busName_ = newName;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ModeEditorBase::getBusInterface()\r\n//-----------------------------------------------------------------------------\r\nBusInterfaceInterface* ModeEditorBase::getBusInterface() const\r\n{\r\n    return busInterface_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ModeEditorBase::getBusName()\r\n//-----------------------------------------------------------------------------\r\nstd::string ModeEditorBase::getBusName() const\r\n{\r\n    return busName_;\r\n}\r\n"
  },
  {
    "path": "editors/ComponentEditor/busInterfaces/general/ModeEditorBase.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ModeEditorBase.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 7.4.2011\r\n//\r\n// Description:\r\n// Base class for different interface mode editors of a bus interface.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef MODE_EDITOR_BASE_H\r\n#define MODE_EDITOR_BASE_H\r\n\r\n#include <IPXACTmodels/generaldeclarations.h>\r\n\r\n#include <QGroupBox>\r\n#include <QSharedPointer>\r\n\r\nclass BusInterface;\r\nclass Component;\r\nclass BusInterfaceInterface;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Base class for different interface mode editors of a bus interface.\r\n//-----------------------------------------------------------------------------\r\nclass ModeEditorBase : public QGroupBox\r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\r\n\t/*!\r\n     *  The constructor.\r\n\t *\r\n\t *    @param [in] busInterface    Interface for accessing bus interfaces.\r\n     *    @param [in] busName         Name of the edited bus interface.\r\n\t *    @param [in] title           The title for the group box\r\n\t *    @param [in] parent          The owner of this editor.\r\n     */\r\n    ModeEditorBase(BusInterfaceInterface* busInterface, std::string const& busName, QString const& title,\r\n        QWidget* parent);\r\n\r\n\t/*!\r\n     *  The destructor\r\n     */\r\n\tvirtual ~ModeEditorBase() = default;\r\n\r\n\r\n    //! No copying. No assignment.\r\n    ModeEditorBase(const ModeEditorBase& other) = delete;\r\n    ModeEditorBase& operator=(const ModeEditorBase& other) = delete;\r\n\r\n\t/*!\r\n     *  Check for the validity of the mode specific items.\r\n     *\r\n     *    @return True if item is valid.\r\n     */\r\n\tvirtual bool isValid() const = 0;\r\n\r\n\t/*!\r\n     *  Restore the changes made in the editor back to ones in the model.\r\n     */\r\n\tvirtual void refresh() = 0;\r\n\r\n\t/*!\r\n     *  Get the interface mode of the editor.\r\n\t * \r\n\t *    @return General::InterfaceMode Specifies the interface mode.\r\n     */\r\n\tvirtual General::InterfaceMode getInterfaceMode() const = 0;\r\n\r\n\t/*!\r\n     *  Save the interface mode-specific details to the bus interface.\r\n     */\r\n\tvirtual void saveModeSpecific() = 0;\r\n\r\n    /*!\r\n     *  Change the name of the edited bus interface.\r\n     *\r\n     *    @param [in] newName     New name of the bus interface.\r\n     */\r\n    void changeName(std::string const& newName);\r\n\r\nsignals:\r\n\r\n\t//! Emitted when contents of the model change\r\n\tvoid contentChanged();\r\n\r\n\t//! Prints an error message to the user.\r\n\tvoid errorMessage(QString const& msg) const;\r\n\r\n\t//! Prints a notification to user.\r\n\tvoid noticeMessage(QString const& msg) const;\r\n\r\nprotected:\r\n\r\n\t/*!\r\n     *  Get the interface for accessing bus interfaces.\r\n     */\r\n    BusInterfaceInterface* getBusInterface() const;\r\n\r\n    /*!\r\n     *  Get the name of the edited bus interfaces.\r\n     */\r\n    std::string getBusName() const;\r\n\r\n    //-----------------------------------------------------------------------------\r\n    //! Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! Interface for accessing bus interfaces.\r\n    BusInterfaceInterface* busInterface_;\r\n\r\n    //! Name of the edited bus interface.\r\n    std::string busName_;\r\n};\r\n\r\n#endif // MODE_EDITOR_BASE_H\r\n"
  },
  {
    "path": "editors/ComponentEditor/busInterfaces/general/MonitorModeEditor.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: MonitorModeEditor.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 7.4.2011\r\n//\r\n// Description:\r\n// Editor the edit a monitor settings of a bus interface.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"MonitorModeEditor.h\"\r\n\r\n#include <KactusAPI/include/LibraryInterface.h>\r\n\r\n#include <IPXACTmodels/generaldeclarations.h>\r\n#include <IPXACTmodels/common/VLNV.h>\r\n#include <IPXACTmodels/BusDefinition/BusDefinition.h>\r\n#include <IPXACTmodels/Component/Component.h>\r\n\r\n#include <KactusAPI/include/BusInterfaceInterface.h>\r\n\r\n#include <QGridLayout>\r\n#include <QLabel>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MonitorModeEditor::MonitorModeEditor()\r\n//-----------------------------------------------------------------------------\r\nMonitorModeEditor::MonitorModeEditor(BusInterfaceInterface* busInterface, std::string const& busName,\r\n\tDocument::Revision docRevision,\r\n    LibraryInterface* libHandler, QWidget *parent):\r\nModeEditorBase(busInterface, busName, tr(\"Monitor\"), parent),\r\nlibHandler_(libHandler),\r\ninterfaceMode_(docRevision, General::INTERFACE_MODE_COUNT, false, this), \r\ngroupLabel_(tr(\"Group:\"), this),\r\nsystemGroup_(this)\r\n{\r\n\tsetupLayout();\r\n\r\n\tconnect(&interfaceMode_, SIGNAL(modeSelected(General::InterfaceMode)),\r\n\t\tthis, SLOT(onInterfaceModeChange(General::InterfaceMode)), Qt::UniqueConnection);\r\n\tconnect(&systemGroup_, SIGNAL(currentTextChanged(QString const&)),\r\n\t\tthis, SLOT(onSystemGroupChange(QString const&)), Qt::UniqueConnection);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MonitorModeEditor::isValid()\r\n//-----------------------------------------------------------------------------\r\nbool MonitorModeEditor::isValid() const\r\n{\r\n\t// if no interface mode is not defined\r\n\tif (interfaceMode_.currentText().isEmpty())\r\n    {\r\n\t\treturn false;\r\n\t}\r\n\r\n\t// if interface mode is system or mirrored system but group is not defined\r\n\telse if ((interfaceMode_.selected() == General::SYSTEM ||\r\n\t\tinterfaceMode_.selected() == General::MIRRORED_SYSTEM) && \r\n\t\t(systemGroup_.currentText().isEmpty()))\r\n    {\r\n\t\treturn false;\r\n\t}\r\n\r\n\treturn true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MonitorModeEditor::refresh()\r\n//-----------------------------------------------------------------------------\r\nvoid MonitorModeEditor::refresh()\r\n{\r\n    BusInterfaceInterface* busInterface = getBusInterface();\r\n    std::string busName = getBusName();\r\n\r\n    General::InterfaceMode monitorMode = busInterface->getMonitorMode(busName);\r\n\r\n\t// select the mode in the selector\r\n\tinterfaceMode_.setMode(monitorMode);\r\n\r\n\t// disconnect the combo box to avoid emitting signals\r\n\tdisconnect(&systemGroup_, SIGNAL(currentTextChanged(QString const&)),\r\n\t\tthis, SLOT(onSystemGroupChange(QString const&)));\r\n\r\n\t// clear the previous items from the group combo box\r\n\tsystemGroup_.clear();\r\n\r\n\t// if selected interface mode is system or mirrored system then enable\r\n\t// the system group combo box\r\n    if (monitorMode == General::SYSTEM || monitorMode == General::MIRRORED_SYSTEM)\r\n    {\r\n        systemGroup_.setEnabled(true);\r\n\r\n        // find the current bus definition\r\n        VLNV busDefVLNV = busInterface->getBusType(busName);\r\n\r\n        if (libHandler_->getDocumentType(busDefVLNV) == VLNV::BUSDEFINITION)\r\n        {\r\n            QSharedPointer<Document> libComp = libHandler_->getModel(busDefVLNV);\r\n            Q_ASSERT(libComp);\r\n\r\n            // get the system groups from the bus definition\r\n            QSharedPointer<BusDefinition> busDef = libComp.staticCast<BusDefinition>();\r\n            QStringList groupList = busDef->getSystemGroupNames();\r\n\r\n            // add the system names to the list\r\n            systemGroup_.addItems(groupList);\r\n\r\n            // ask the monitor which group to select\r\n            QString selectedGroup = QString::fromStdString(busInterface->getMonitorGroup(busName));\r\n\r\n            // select the same text that was previously selected if it still can be found\r\n            int index = systemGroup_.findText(selectedGroup);\r\n            systemGroup_.setCurrentIndex(index);\r\n        }\r\n    }\r\n    // if interface mode is not system or mirrored system then disable the\r\n    // combo box and clear it's contents\r\n    else\r\n    {\r\n        systemGroup_.setDisabled(true);\r\n\r\n    }\r\n\r\n\t// reconnect the combo box\r\n\tconnect(&systemGroup_, SIGNAL(currentTextChanged(QString const&)),\r\n\t\tthis, SLOT(onSystemGroupChange(QString const&)), Qt::UniqueConnection);\t\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MonitorModeEditor::getInterfaceMode()\r\n//-----------------------------------------------------------------------------\r\nGeneral::InterfaceMode MonitorModeEditor::getInterfaceMode() const\r\n{\r\n\treturn General::MONITOR;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MonitorModeEditor::saveModeSpecific()\r\n//-----------------------------------------------------------------------------\r\nvoid MonitorModeEditor::saveModeSpecific()\r\n{\r\n    onSystemGroupChange(systemGroup_.currentText());\r\n\r\n    General::InterfaceMode monitorMode =\r\n        General::str2Interfacemode(interfaceMode_.currentText(), General::INTERFACE_MODE_COUNT);\r\n\r\n    onInterfaceModeChange(monitorMode);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MonitorModeEditor::onSystemGroupChange()\r\n//-----------------------------------------------------------------------------\r\nvoid MonitorModeEditor::onSystemGroupChange( QString const& groupName )\r\n{\r\n    getBusInterface()->setMonitorGroup(getBusName(), groupName.toStdString());\r\n\temit contentChanged();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MonitorModeEditor::onInterfaceModeChange()\r\n//-----------------------------------------------------------------------------\r\nvoid MonitorModeEditor::onInterfaceModeChange( General::InterfaceMode mode )\r\n{\r\n\t// update the mode to the monitor \r\n    BusInterfaceInterface* busInterface = getBusInterface();\r\n    std::string busName = getBusName();\r\n    std::string modeString = General::interfaceMode2Str(mode).toStdString();\r\n\r\n    busInterface->setMonitorMode(busName, modeString);\r\n\r\n\t// disconnect the combo box to avoid emitting signals\r\n\tdisconnect(&systemGroup_, SIGNAL(currentTextChanged(QString const&)),\r\n\t\tthis, SLOT(onSystemGroupChange(QString const&)));\r\n\r\n\tsystemGroup_.clear();\r\n\r\n\t// if selected interface mode is system or mirrored system then enable\r\n\t// the system group combo box\r\n    if (mode == General::SYSTEM || mode == General::MIRRORED_SYSTEM)\r\n    {\r\n        systemGroup_.setEnabled(true);\r\n        systemGroup_.setVisible(true);\r\n        groupLabel_.setVisible(true);\r\n\r\n        // find the current bus definition\r\n        VLNV busDefVLNV = busInterface->getBusType(busName);\r\n\r\n\t\t\t// if there is no bus definition\r\n        if (libHandler_->contains(busDefVLNV))\r\n        {\r\n            QSharedPointer<Document> libComp = libHandler_->getModel(busDefVLNV);\r\n            Q_ASSERT(libComp);\r\n\r\n            // if the library component with given vlnv was not a bus definition\r\n            if (libHandler_->getDocumentType(busDefVLNV) == VLNV::BUSDEFINITION)\r\n            {\r\n                // get the system groups from the bus definition\r\n                QSharedPointer<BusDefinition> busDef = libComp.staticCast<BusDefinition>();\r\n                QStringList groupList = busDef->getSystemGroupNames();\r\n\r\n                // add the system names to the list\r\n                systemGroup_.addItems(groupList);\r\n\r\n                // ask the monitor which group to select\r\n                QString selectedGroup = QString::fromStdString(busInterface->getMonitorGroup(busName));\r\n\r\n                // select the same text that was previously selected if it still can be found\r\n                int index = systemGroup_.findText(selectedGroup);\r\n                systemGroup_.setCurrentIndex(index);\r\n            }\r\n        }\r\n    }\r\n    // if interface mode is not system or mirrored system then disable the combo box\r\n    else\r\n    {\r\n        busInterface->setMonitorGroup(busName, std::string());\r\n\r\n        systemGroup_.setDisabled(true);\r\n        systemGroup_.setHidden(true);\r\n        systemGroup_.setCurrentIndex(-1);\r\n\r\n        groupLabel_.setHidden(true);\r\n    }\r\n\r\n\t// reconnect the combo box\r\n\tconnect(&systemGroup_, SIGNAL(currentTextChanged(QString const&)),\r\n\t\tthis, SLOT(onSystemGroupChange(QString const&)), Qt::UniqueConnection);\r\n\r\n\temit contentChanged();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MonitorModeEditor::setupLayout()\r\n//-----------------------------------------------------------------------------\r\nvoid MonitorModeEditor::setupLayout()\r\n{\r\n    QLabel* modeLabel = new QLabel(tr(\"Interface mode:\"), this);\r\n\r\n    QGridLayout* topLayout = new QGridLayout(this);\r\n    topLayout->addWidget(modeLabel, 0, 0, 1, 1);\r\n    topLayout->addWidget(&interfaceMode_, 0, 1, 1, 1);\r\n    topLayout->addWidget(&groupLabel_, 1, 0, 1, 1);\r\n    topLayout->addWidget(&systemGroup_, 1, 1, 1, 1);\r\n    topLayout->setColumnStretch(1, 1);\r\n    topLayout->setRowStretch(2, 10);\r\n}\r\n"
  },
  {
    "path": "editors/ComponentEditor/busInterfaces/general/MonitorModeEditor.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: MonitorModeEditor.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 7.4.2011\r\n//\r\n// Description:\r\n// Editor the edit a monitor settings of a bus interface.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef MonitorModeEditor_H\r\n#define MonitorModeEditor_H\r\n\r\n#include \"ModeEditorBase.h\"\r\n\r\n#include <common/widgets/interfaceModeSelector/interfacemodeselector.h>\r\n\r\n#include <IPXACTmodels/generaldeclarations.h>\r\n#include <IPXACTmodels/Component/BusInterface.h>\r\n\r\n#include <QLabel>\r\n#include <QSharedPointer>\r\n#include <QComboBox>\r\n\r\nclass Component;\r\nclass BusIfGeneralTab;\r\nclass LibraryInterface;\r\nclass BusInterfaceInterface;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Editor the edit a monitor settings of a bus interface.\r\n//-----------------------------------------------------------------------------\r\nclass MonitorModeEditor : public ModeEditorBase\r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\r\n\t/*!\r\n     *  The constructor.\r\n\t *\r\n\t *    @param [in] busInterface    Interface for accessing bus interfaces.\r\n     *    @param [in] busName         Name of the edited bus interface.\r\n\t *    @param [in] libHandler      The library handler instance.\r\n\t *    @param [in] parent          The owner of this editor.\r\n\t *\r\n     */\r\n    MonitorModeEditor(BusInterfaceInterface* busInterface,\r\n        std::string const& busName, \r\n        Document::Revision docRevision,\r\n        LibraryInterface* libHandler,\r\n        QWidget *parent);\r\n\r\n\t/*!\r\n     *  The destructor.\r\n     */\r\n\tvirtual ~MonitorModeEditor() = default;\r\n\r\n\r\n    //! No copying. No assignment.\r\n    MonitorModeEditor(const MonitorModeEditor& other) = delete;\r\n\r\n    MonitorModeEditor& operator=(const MonitorModeEditor& other) = delete;\r\n\r\n\r\n\t/*!\r\n     *  Check for the validity of the edited item.\r\n     *\r\n     *    @return True if item is valid.\r\n     */\r\n\tbool isValid() const final;\r\n\r\n\t/*!\r\n     *  Restore the changes made in the editor back to ones in the model.\r\n     */\r\n\tvoid refresh() final;\r\n\r\n\t/*!\r\n     *  Get the interface mode of the editor.\r\n\t *\r\n     *    @return General::InterfaceMode Specifies the interface mode.\r\n     */\r\n\tGeneral::InterfaceMode getInterfaceMode() const final;\r\n\r\n\t/*!\r\n     *  Save the interface mode-specific details to the bus interface.\r\n     */\r\n\tvoid saveModeSpecific() final;\r\n\r\nprivate slots:\r\n\r\n\t/*!\r\n     *  Handles the monitor interface mode change.\r\n     *\r\n     *    @param [in] mode    New interface mode.\r\n     */\r\n\tvoid onInterfaceModeChange(General::InterfaceMode mode);\r\n\r\n\t/*!\r\n     *  Handler for monitor system group changes.\r\n     *\r\n     *    @param [in] groupName   New system group.\r\n     */\r\n\tvoid onSystemGroupChange(QString const& groupName);\r\n\r\nprivate:\r\n\r\n    //! Set the widget layout.\r\n    void setupLayout();\r\n\r\n    //-----------------------------------------------------------------------------\r\n    //! Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n\t//! The instance that manages the library.\r\n\tLibraryInterface* libHandler_;\r\n\r\n\t//! Combo box to select the interface type for monitor.\r\n\tInterfaceModeSelector interfaceMode_;\r\n\r\n    //! Label for selecting system group.\r\n    QLabel groupLabel_;\r\n\r\n\t//! Combo box to select the group for system interface types.\r\n\tQComboBox systemGroup_;\r\n};\r\n\r\n#endif // MonitorModeEditor_H\r\n"
  },
  {
    "path": "editors/ComponentEditor/busInterfaces/general/SlaveModeEditor.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: SlaveModeEditor.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 7.4.2011\r\n//\r\n// Description:\r\n// Editor to the slave details of a bus interface.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"SlaveModeEditor.h\"\r\n\r\n#include <IPXACTmodels/generaldeclarations.h>\r\n\r\n#include <IPXACTmodels/Component/BusInterface.h>\r\n#include <IPXACTmodels/Component/Component.h>\r\n\r\n#include <KactusAPI/include/BusInterfaceInterface.h>\r\n#include <KactusAPI/include/TransparentBridgeInterface.h>\r\n#include <KactusAPI/include/MemoryMapInterface.h>\r\n#include <KactusAPI/include/FileSetInterface.h>\r\n\r\n#include <QFormLayout>\r\n#include <QVBoxLayout>\r\n#include <QHBoxLayout>\r\n#include <QLabel>\r\n\r\nnamespace\r\n{\r\n    QString const DEFAULT_FILEGROUP = QLatin1String(\"default\");\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SlaveModeEditor::SlaveModeEditor()\r\n//-----------------------------------------------------------------------------\r\nSlaveModeEditor::SlaveModeEditor(BusInterfaceInterface* busInterface, std::string const& busName, Document::Revision revision, QWidget* parent):\r\nModeEditorBase(busInterface, busName, tr(\"Slave\"), parent),\r\nmemoryMapSelector_(tr(\"Memory map\"), this),\r\nbridgesSelector_(tr(\"Transparent bridge\"), this),\r\nmemoryMapReferenceSelector_(this),\r\nslaveBridges_(busInterface->getBridges(busName)),\r\nbridges_(busInterface, slaveBridges_, revision, this),\r\nfileSetRefs_(busInterface->getFileSetInterface(), tr(\"File set references\"), this)\r\n{\r\n    fileSetRefs_.initialize();\r\n\r\n    memoryMapReferenceSelector_.setHidden(true);\r\n    bridges_.setHidden(true);\r\n\r\n    setupLayout();\r\n\r\n    connect(&memoryMapSelector_, SIGNAL(clicked(bool)),\r\n        this, SLOT(onMemoryMapSelected(bool)), Qt::UniqueConnection);\r\n    connect(&memoryMapSelector_, SIGNAL(toggled(bool)), &memoryMapReferenceSelector_, SLOT(setVisible(bool)));\r\n\r\n    connect(&bridgesSelector_, SIGNAL(clicked(bool)),\r\n        this, SLOT(onTransparentBridgeSelected(bool)), Qt::UniqueConnection);\r\n    connect(&bridgesSelector_, SIGNAL(toggled(bool)), &bridges_, SLOT(setVisible(bool)));\r\n\r\n\tconnect(&memoryMapReferenceSelector_, SIGNAL(itemSelected(QString const&)),\r\n\t\tthis, SLOT(onMemoryMapChange(QString const&)), Qt::UniqueConnection);\r\n\t\r\n    connect(&fileSetRefs_, SIGNAL(contentChanged()),\r\n        this, SLOT(onFileSetReferencesChanged()), Qt::UniqueConnection);\r\n\r\n    connect(&bridges_, SIGNAL(contentChanged()), this, SIGNAL(contentChanged()), Qt::UniqueConnection);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SlaveModeEditor::isValid()\r\n//-----------------------------------------------------------------------------\r\nbool SlaveModeEditor::isValid() const\r\n{\r\n\treturn true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SlaveModeEditor::refresh()\r\n//-----------------------------------------------------------------------------\r\nvoid SlaveModeEditor::refresh()\r\n{\r\n    BusInterfaceInterface* busInterface = getBusInterface();\r\n    std::string busName = getBusName();\r\n\r\n    QStringList mapNameList;\r\n    for (auto mapName : busInterface->getMemoryMapInterface()->getItemNames())\r\n    {\r\n        mapNameList.append(QString::fromStdString(mapName));\r\n    }\r\n\r\n    QString mapReference = QString::fromStdString(busInterface->getMemoryMapReference(busName));\r\n    memoryMapReferenceSelector_.refresh(mapNameList);\r\n    memoryMapReferenceSelector_.selectItem(mapReference);\r\n    memoryMapSelector_.setChecked(mapReference.isEmpty() == false);\r\n\r\n    setupFileSetReferences();\r\n\r\n    bridges_.refresh();\r\n    bridgesSelector_.setChecked(getBusInterface()->getBridgeInterface()->itemCount() != 0);\r\n}\r\n\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SlaveModeEditor::getInterfaceMode()\r\n//-----------------------------------------------------------------------------\r\nGeneral::InterfaceMode SlaveModeEditor::getInterfaceMode() const\r\n{\r\n\treturn General::SLAVE;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SlaveModeEditor::onMemoryMapChange()\r\n//-----------------------------------------------------------------------------\r\nvoid SlaveModeEditor::onMemoryMapChange(QString const& newMemoryMapName)\r\n{\r\n    getBusInterface()->setMemoryMapReference(getBusName(), newMemoryMapName.toStdString());\r\n\r\n\temit contentChanged();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SlaveModeEditor::onMemoryMapSelected()\r\n//-----------------------------------------------------------------------------\r\nvoid SlaveModeEditor::onMemoryMapSelected(bool checked)\r\n{\r\n    BusInterfaceInterface* busInterface = getBusInterface();\r\n\r\n    if (checked)\r\n    {\r\n        if (busInterface->getBridgeInterface()->itemCount() > 0)\r\n        {\r\n            memoryMapSelector_.setChecked(false);\r\n        }\r\n        else\r\n        {\r\n            bridgesSelector_.setChecked(false);\r\n        }\r\n    }\r\n    else if (!checked && !busInterface->getMemoryMapReference(getBusName()).empty())\r\n    {\r\n        memoryMapSelector_.setChecked(true);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SlaveModeEditor::onTransparentBridgeSelected()\r\n//-----------------------------------------------------------------------------\r\nvoid SlaveModeEditor::onTransparentBridgeSelected(bool checked)\r\n{\r\n    BusInterfaceInterface* busInterface = getBusInterface();\r\n    std::string busName = getBusName();\r\n\r\n    if (checked)\r\n    {\r\n        if (!QString::fromStdString(busInterface->getMemoryMapReference(busName)).isEmpty())\r\n        {\r\n            bridgesSelector_.setChecked(false);\r\n        }\r\n        else\r\n        {\r\n            memoryMapSelector_.setChecked(false);\r\n        }\r\n\r\n        if (!slaveBridges_)\r\n        {\r\n            slaveBridges_ = busInterface->createBridges(busName);\r\n            bridges_.setupBridges(slaveBridges_);\r\n        }\r\n    }\r\n    else if (!checked && busInterface->getBridgeInterface()->itemCount() > 0)\r\n    {\r\n        bridgesSelector_.setChecked(true);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SlaveModeEditor::onFileSetReferencesChanged()\r\n//-----------------------------------------------------------------------------\r\nvoid SlaveModeEditor::onFileSetReferencesChanged()\r\n{\r\n    saveFileSetReferences();\r\n    emit contentChanged();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SlaveModeEditor::saveModeSpecific()\r\n//-----------------------------------------------------------------------------\r\nvoid SlaveModeEditor::saveModeSpecific()\r\n{\r\n    saveFileSetReferences();\r\n\r\n    if (memoryMapSelector_.isChecked())\r\n    {\r\n        getBusInterface()->setMemoryMapReference(getBusName(), memoryMapReferenceSelector_.currentText().toStdString());\r\n    }\r\n    else if (bridgesSelector_.isChecked())\r\n    {\r\n        bridges_.refresh();\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SlaveModeEditor::setupFileSetReferences()\r\n//-----------------------------------------------------------------------------\r\nvoid SlaveModeEditor::setupFileSetReferences()\r\n{\r\n    QStringList newFileSetItems;\r\n\r\n    for (auto const& fileSetName : getBusInterface()->getFileSetReferences(getBusName()))\r\n    {\r\n        newFileSetItems.append(QString::fromStdString(fileSetName));\r\n    }\r\n\r\n    fileSetRefs_.setItems(newFileSetItems);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SlaveModeEditor::saveFileSetReferences()\r\n//-----------------------------------------------------------------------------\r\nvoid SlaveModeEditor::saveFileSetReferences()\r\n{\r\n    std::vector<std::string> newItems;\r\n    for (auto fileSetReference : fileSetRefs_.items())\r\n    {\r\n        newItems.push_back(fileSetReference.toStdString());\r\n    }\r\n\r\n    getBusInterface()->setFileSetReferences(getBusName(), newItems);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SlaveModeEditor::setupLayout()\r\n//-----------------------------------------------------------------------------\r\nvoid SlaveModeEditor::setupLayout()\r\n{\r\n    auto accessSelectionGroup = new QGroupBox(tr(\"Interface access target\"), this);\r\n    accessSelectionGroup->setFlat(true);\r\n\r\n    auto accessSelectionLayout = new QHBoxLayout(accessSelectionGroup);\r\n    accessSelectionLayout->addWidget(&memoryMapSelector_, 0, Qt::AlignLeft);\r\n    accessSelectionLayout->addWidget(&bridgesSelector_, 1, Qt::AlignLeft);\r\n\r\n    QVBoxLayout* mapBridgeLayout = new QVBoxLayout();\r\n    mapBridgeLayout->addWidget(&memoryMapReferenceSelector_);\r\n    mapBridgeLayout->addWidget(&bridges_);\r\n    mapBridgeLayout->addStretch();\r\n\r\n    auto topLayout = new QGridLayout(this);\r\n    topLayout->addWidget(accessSelectionGroup, 0, 0, 1, 1);\r\n    topLayout->addLayout(mapBridgeLayout, 1, 0, 1, 1);\r\n    topLayout->addWidget(&fileSetRefs_, 0, 1, 2, 1);\r\n    topLayout->setContentsMargins(0, 4, 0, 2);\r\n}\r\n"
  },
  {
    "path": "editors/ComponentEditor/busInterfaces/general/SlaveModeEditor.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: SlaveModeEditor.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 7.4.2011\r\n//\r\n// Description:\r\n// Editor to the slave details of a bus interface.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef SLAVE_MODE_EDITOR_H\r\n#define SLAVE_MODE_EDITOR_H\r\n\r\n#include \"ModeEditorBase.h\"\r\n#include \"bridgeseditor.h\"\r\n\r\n#include <editors/ComponentEditor/common/ReferenceSelector/ReferenceSelector.h>\r\n#include <editors/ComponentEditor/instantiations/filesetrefeditor.h>\r\n\r\n#include <IPXACTmodels/common/Document.h>\r\n#include <IPXACTmodels/Component/TargetInterface.h>\r\n\r\n#include <QSharedPointer>\r\n#include <QCheckBox>\r\n\r\nclass BusInterface;\r\nclass Component;\r\nclass BusInterfaceInterface;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Editor to the slave details of a bus interface.\r\n//-----------------------------------------------------------------------------\r\nclass SlaveModeEditor : public ModeEditorBase \r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\r\n\t/*!\r\n     *  The constructor.\r\n\t *\r\n     *    @param [in] busInterface    Interface for accessing bus interfaces.\r\n     *    @param [in] busName         Name of the edited bus interface.\r\n     *    @param [in] revision        Currently active IP-XACT revision.\r\n     *    @param [in] parent          The owner of this editor.\r\n     */\r\n    SlaveModeEditor(BusInterfaceInterface* busInterface, std::string const& busName, Document::Revision revision, QWidget* parent);\r\n\r\n\t/*!\r\n     *  The destructor.\r\n     */\r\n\t~SlaveModeEditor() final = default;\r\n\r\n\r\n    //! No copying. No assignment.\r\n    SlaveModeEditor(const SlaveModeEditor& other) = delete;\r\n    SlaveModeEditor& operator=(const SlaveModeEditor& other) = delete;\r\n\r\n\t/*!\r\n     *  Check for the validity of the edited item.\r\n     *\r\n     *    @return True if item is valid.\r\n     */\r\n\tbool isValid() const final;\r\n\r\n\t/*!\r\n     *  Restore the changes made in the editor back to ones in the model.\r\n     */\r\n\tvoid refresh() final;\r\n\r\n\t/*!\r\n     *  Get the interface mode of the editor\r\n\t * \r\n\t *    @return General::InterfaceMode Specifies the interface mode.\r\n     */\r\n\tGeneral::InterfaceMode getInterfaceMode() const final;\r\n\r\n\t/*!\r\n     *  Save the interface mode-specific details to the bus interface.\r\n     */\r\n\tvoid saveModeSpecific() final;\r\n\r\nprivate slots:\r\n\r\n\t/*!\r\n     *  Handler for changes in the memory map reference.\r\n     *\r\n     *    @param [in] newMemoryMapName    The name of the selected memory map.\r\n     */\r\n\tvoid onMemoryMapChange(QString const& newMemoryMapName);\r\n\r\n    /*!\r\n     *  Handler for selecting the memory map.\r\n     *\r\n     *    @param [in] checked     True, if the memory map was selected.\r\n     */\r\n    void onMemoryMapSelected(bool checked);\r\n\r\n    /*!\r\n     *  Handler for selecting the transparent bridges.\r\n     *\r\n     *    @param [in] checked     True, if the transparent bridges was selected.\r\n     */\r\n    void onTransparentBridgeSelected(bool checked);\r\n\r\n    /*!\r\n     *  Handler for changes in the file set references.\r\n     */\r\n    void onFileSetReferencesChanged();\r\n\r\nprivate:\r\n\r\n    /*!\r\n     *  Setup the current file set references.\r\n     */\r\n    void setupFileSetReferences();\r\n\r\n    //! Save the current file set references.\r\n    void saveFileSetReferences();\r\n\r\n    /*!\r\n     *  Sets the editor layout.\r\n     */\r\n    void setupLayout();\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! Select memory map as access target.\r\n    QCheckBox memoryMapSelector_;\r\n\r\n    //! Select transparent bridge(s) as access target.\r\n    QCheckBox bridgesSelector_;\r\n\r\n\t//! The editor to select a memory map from the component.\r\n\tReferenceSelector memoryMapReferenceSelector_;\r\n\r\n    //! List of available transparent bridges.\r\n    QSharedPointer<QList<QSharedPointer<TransparentBridge> > > slaveBridges_;\r\n\r\n\t//! The editor to edit the bridges of a slave interface.\r\n\tBridgesEditor bridges_;\r\n\r\n    //! Editor to set the file set references.\r\n    FileSetRefEditor fileSetRefs_;\r\n};\r\n\r\n#endif // SLAVE_MODE_EDITOR_H\r\n"
  },
  {
    "path": "editors/ComponentEditor/busInterfaces/general/SystemModeEditor.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: SystemModeEditor.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 7.4.2011\r\n//\r\n// Description:\r\n// Editor to edit system or mirrored system details of a bus interface.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"SystemModeEditor.h\"\r\n\r\n#include \"busifgeneraltab.h\"\r\n\r\n#include <KactusAPI/include/LibraryInterface.h>\r\n\r\n#include <IPXACTmodels/common/VLNV.h>\r\n#include <IPXACTmodels/BusDefinition/BusDefinition.h>\r\n#include <IPXACTmodels/Component/BusInterface.h>\r\n\r\n#include <KactusAPI/include/BusInterfaceInterface.h>\r\n\r\n#include <QFormLayout>\r\n#include <QStringList>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SystemModeEditor::SystemModeEditor()\r\n//-----------------------------------------------------------------------------\r\nSystemModeEditor::SystemModeEditor(BusInterfaceInterface* busInterface, std::string const& busName,\r\n    LibraryInterface* libHandler, QWidget *parent):\r\nModeEditorBase(busInterface, busName, tr(\"System\"), parent),\r\nlibHandler_(libHandler),\r\ngroupEditor_(this)\r\n{\r\n    if(busInterface->getMode(busName) == General::MIRRORED_SYSTEM) \r\n    {\r\n        setTitle(tr(\"Mirrored system\"));\r\n    }\r\n\r\n\tgroupEditor_.setProperty(\"mandatoryField\", true);\r\n\r\n\tconnect(&groupEditor_, SIGNAL(currentTextChanged(QString const&)),\r\n\t\tthis, SLOT(onGroupChange(QString const&)), Qt::UniqueConnection);\r\n\r\n    QFormLayout* groupLayout = new QFormLayout(this);\r\n    groupLayout->addRow(tr(\"System group:\"), &groupEditor_);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SystemModeEditor::isValid()\r\n//-----------------------------------------------------------------------------\r\nbool SystemModeEditor::isValid() const\r\n{\r\n\treturn !groupEditor_.currentText().isEmpty();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SystemModeEditor::refresh()\r\n//-----------------------------------------------------------------------------\r\nvoid SystemModeEditor::refresh()\r\n{\r\n\t// when the combo box changes it must be disconnected to avoid emitting signals\r\n\tdisconnect(&groupEditor_, SIGNAL(currentTextChanged(QString const&)), this, SLOT(onGroupChange(QString const&)));\r\n\t\r\n\t// update the combobox to display only the possible values\r\n\r\n\t// the text that was selected\r\n\tQString oldText = groupEditor_.currentText();\r\n\r\n\t// remove previous items in the combo box\r\n\tgroupEditor_.clear();\r\n\r\n    BusInterfaceInterface* busInterface = getBusInterface();\r\n    std::string busName = getBusName();\r\n\r\n\t// the selected bus definition defines the groups that can be used\r\n    VLNV busDefVLNV = busInterface->getBusType(busName);\r\n\r\n\t// if there is no bus definition specified there is nothing to select\r\n\tif (!busDefVLNV.isValid())\r\n    {\r\n\t\treturn;\r\n\t}\r\n\r\n\t// if the bus definition does not exist then it can't be read to find the groups\r\n\tif (!libHandler_->contains(busDefVLNV))\r\n    {\r\n\t\temit errorMessage(tr(\"The selected bus type does not exist in library.\"));\r\n\t\treturn;\r\n\t}\r\n\r\n\tQSharedPointer<Document> libComp = libHandler_->getModel(busDefVLNV);\r\n\tQ_ASSERT(libComp);\r\n\r\n\t// if the library component with given vlnv was not a bus definition\r\n\tif (libHandler_->getDocumentType(busDefVLNV) != VLNV::BUSDEFINITION)\r\n    {\r\n\t\temit errorMessage(tr(\"Bus type VLNV was wrong type\"));\r\n\t\treturn;\r\n\t}\r\n\r\n\tQSharedPointer<BusDefinition> busDef = libComp.staticCast<BusDefinition>();\r\n\tQStringList groupList = busDef->getSystemGroupNames();\r\n\r\n\t// add the system names to the list\r\n\tgroupEditor_.addItems(groupList);\r\n\r\n    // select the same text that was previously selected if it still can be found\r\n    int index;\r\n\r\n    if (oldText.isEmpty())\r\n    {\r\n        index = groupEditor_.findText(QString::fromStdString(busInterface->getSystemGroup(busName)));\r\n    }\r\n    else\r\n    {\r\n        index = groupEditor_.findText(oldText);\r\n    }\r\n\r\n\tgroupEditor_.setCurrentIndex(index);\r\n\r\n\t// reconnect the combo box\r\n\tconnect(&groupEditor_, SIGNAL(currentTextChanged(QString const&)),\r\n        this, SLOT(onGroupChange(QString const&)), Qt::UniqueConnection);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SystemModeEditor::getInterfaceMode()\r\n//-----------------------------------------------------------------------------\r\nGeneral::InterfaceMode SystemModeEditor::getInterfaceMode() const\r\n{\r\n    return getBusInterface()->getMode(getBusName());\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SystemModeEditor::onGroupChange()\r\n//-----------------------------------------------------------------------------\r\nvoid SystemModeEditor::onGroupChange(QString const&)\r\n{\r\n    getBusInterface()->setSystemGroup(getBusName(), groupEditor_.currentText().toStdString());\r\n\temit contentChanged();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SystemModeEditor::saveModeSpecific()\r\n//-----------------------------------------------------------------------------\r\nvoid SystemModeEditor::saveModeSpecific()\r\n{\r\n    getBusInterface()->setSystemGroup(getBusName(), groupEditor_.currentText().toStdString());\r\n}\r\n"
  },
  {
    "path": "editors/ComponentEditor/busInterfaces/general/SystemModeEditor.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: SystemModeEditor.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 7.4.2011\r\n//\r\n// Description:\r\n// Editor to edit system or mirrored system details of a bus interface.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef SYSTEM_MODE_EDITOR_H\r\n#define SYSTEM_MODE_EDITOR_H\r\n\r\n#include \"ModeEditorBase.h\"\r\n\r\n#include <IPXACTmodels/Component/BusInterface.h>\r\n\r\n#include <QComboBox>\r\n#include <QSharedPointer>\r\n\r\nclass Component;\r\nclass BusIfGeneralTab;\r\nclass LibraryInterface;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Editor to edit system or mirrored system details of a bus interface.\r\n//-----------------------------------------------------------------------------\r\nclass SystemModeEditor : public ModeEditorBase\r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\r\n\t/*!\r\n     *  The constructor.\r\n\t *\r\n     *    @param [in] busInterface    Interface for accessing bus interfaces.\r\n     *    @param [in] busName         Name of the edited bus interface.\r\n\t *    @param [in] libHandler      The library handler instance.\r\n\t *    @param [in] parent          The owner of this editor.\r\n     */\r\n    SystemModeEditor(BusInterfaceInterface* busInterface,\r\n        std::string const& busName,\r\n        LibraryInterface* libHandler,\r\n        QWidget *parent);\r\n\r\n\t/*!\r\n     *  The destructor.\r\n     */\r\n\tvirtual ~SystemModeEditor() = default;\r\n\r\n    //! No copying. No assignment.\r\n    SystemModeEditor(const SystemModeEditor& other) = delete;\r\n    SystemModeEditor& operator=(const SystemModeEditor& other) = delete;\r\n\r\n\t/*!\r\n     *  Check for the validity of the edited item.\r\n     *\r\n     *    @return True if item is valid.\r\n     */\r\n\tbool isValid() const final;\r\n\r\n\t/*!\r\n     *  Restore the changes made in the editor back to ones in the model.\r\n     */\r\n\tvoid refresh() final;\r\n\r\n\t/*!\r\n     *  Get the interface mode of the editor\r\n     * \r\n\t *    @return General::InterfaceMode Specifies the interface mode.\r\n     */\r\n\tGeneral::InterfaceMode getInterfaceMode() const final;\r\n\r\n\t/*!\r\n     *  Save the interface mode-specific details to the bus interface.\r\n     */\r\n\tvoid saveModeSpecific() final;\r\n\r\nprivate slots:\r\n\r\n\t/*!\r\n     *  Handler for changes in system group selector.\r\n     *\r\n     *    @param [in] newGroup    New system group.\r\n     */\r\n\tvoid onGroupChange(QString const& newGroup);\r\n\r\nprivate:\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n\t//! The general tab to ask for bus type.\r\n\tBusIfGeneralTab* generalTab_;\r\n\r\n\t//! The library handling interface.\r\n\tLibraryInterface* libHandler_;\r\n\r\n\t//! Select the group this interface belongs to.\r\n\tQComboBox groupEditor_;\r\n};\r\n\r\n#endif // SYSTEM_MODE_EDITOR_H\r\n"
  },
  {
    "path": "editors/ComponentEditor/busInterfaces/general/TargetModeEditor.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: TargetModeEditor.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Esko Pekkarinen\n// Date: 29.06.2023\n//\n// Description:\n// Editor to the target details of a bus interface.\n//-----------------------------------------------------------------------------\n\n#include \"TargetModeEditor.h\"\n\n#include <IPXACTmodels/generaldeclarations.h>\n\n#include <IPXACTmodels/Component/BusInterface.h>\n#include <IPXACTmodels/Component/Component.h>\n\n#include <KactusAPI/include/BusInterfaceInterface.h>\n#include <KactusAPI/include/TransparentBridgeInterface.h>\n#include <KactusAPI/include/MemoryMapInterface.h>\n#include <KactusAPI/include/FileSetInterface.h>\n\n#include <QFormLayout>\n#include <QVBoxLayout>\n#include <QHBoxLayout>\n#include <QLabel>\n\nnamespace\n{\n    QString const DEFAULT_FILEGROUP = QLatin1String(\"default\");\n};\n\n//-----------------------------------------------------------------------------\n// Function: TargetModeEditor::TargetModeEditor()\n//-----------------------------------------------------------------------------\nTargetModeEditor::TargetModeEditor(BusInterfaceInterface* busInterface, std::string const& busName, Document::Revision revision, QWidget* parent):\n    ModeEditorBase(busInterface, busName, tr(\"Target\"), parent),\n    memoryMapSelector_(tr(\"Memory map\"), this),\n    bridgesSelector_(tr(\"Transparent bridge\"), this),\n    memoryMapReferenceSelector_(this),\n    targetBridges_(busInterface->getBridges(busName)),\n    bridges_(busInterface, targetBridges_, revision, this),\n    modeReferences_(tr(\"Modes\"), this),\n    fileSetRefs_(busInterface->getFileSetInterface(), tr(\"File set references\"), this)\n{\n    fileSetRefs_.initialize();\n\n    modeReferences_.initialize();\n\n    memoryMapReferenceSelector_.setHidden(true);\n    modeReferences_.setHidden(true);\n    bridges_.setHidden(true);\n\n    setupLayout();\n\n    connect(&memoryMapSelector_, SIGNAL(clicked(bool)),\n        this, SLOT(onMemoryMapSelected(bool)), Qt::UniqueConnection);\n    connect(&memoryMapSelector_, SIGNAL(toggled(bool)), &memoryMapReferenceSelector_, SLOT(setVisible(bool)));\n    connect(&memoryMapSelector_, SIGNAL(toggled(bool)), &modeReferences_, SLOT(setVisible(bool)));\n\n\n    connect(&bridgesSelector_, SIGNAL(clicked(bool)),\n        this, SLOT(onTransparentBridgeSelected(bool)), Qt::UniqueConnection);\n    connect(&bridgesSelector_, SIGNAL(toggled(bool)), &bridges_, SLOT(setVisible(bool)));\n\n    connect(&memoryMapReferenceSelector_, SIGNAL(itemSelected(QString const&)),\n        this, SLOT(onMemoryMapChange(QString const&)), Qt::UniqueConnection);\n\t\n    connect(&fileSetRefs_, SIGNAL(contentChanged()),\n        this, SLOT(onFileSetReferencesChanged()), Qt::UniqueConnection);\n\n    connect(&bridges_, SIGNAL(contentChanged()), this, SIGNAL(contentChanged()), Qt::UniqueConnection);\n}\n\n//-----------------------------------------------------------------------------\n// Function: TargetModeEditor::isValid()\n//-----------------------------------------------------------------------------\nbool TargetModeEditor::isValid() const\n{\n\treturn true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: TargetModeEditor::refresh()\n//-----------------------------------------------------------------------------\nvoid TargetModeEditor::refresh()\n{\n    BusInterfaceInterface* busInterface = getBusInterface();\n    std::string busName = getBusName();\n\n    QStringList mapNameList;\n    for (auto mapName : busInterface->getMemoryMapInterface()->getItemNames())\n    {\n        mapNameList.append(QString::fromStdString(mapName));\n    }\n\n    QString mapReference = QString::fromStdString(busInterface->getMemoryMapReference(busName));\n\n    memoryMapReferenceSelector_.refresh(mapNameList);\n    memoryMapReferenceSelector_.selectItem(mapReference);\n    memoryMapSelector_.setChecked(mapReference.isEmpty() == false);\n\n\n    bridges_.refresh();\n    bridgesSelector_.setChecked(getBusInterface()->getBridgeInterface()->itemCount() != 0);\n    \n    setupFileSetReferences();\n}\n\n//-----------------------------------------------------------------------------\n// Function: TargetModeEditor::getInterfaceMode()\n//-----------------------------------------------------------------------------\nGeneral::InterfaceMode TargetModeEditor::getInterfaceMode() const\n{\n\treturn General::TARGET;\n}\n\n//-----------------------------------------------------------------------------\n// Function: TargetModeEditor::onMemoryMapChange()\n//-----------------------------------------------------------------------------\nvoid TargetModeEditor::onMemoryMapChange(QString const& newMemoryMapName)\n{\n    getBusInterface()->setMemoryMapReference(getBusName(), newMemoryMapName.toStdString());\n\n\temit contentChanged();\n}\n\n//-----------------------------------------------------------------------------\n// Function: TargetModeEditor::onMemoryMapSelected()\n//-----------------------------------------------------------------------------\nvoid TargetModeEditor::onMemoryMapSelected(bool checked)\n{\n    BusInterfaceInterface* busInterface = getBusInterface();\n\n    if (checked)\n    {\n        if (busInterface->getBridgeInterface()->itemCount() > 0)\n        {\n            memoryMapSelector_.setChecked(false);\n        }\n        else\n        {\n            bridgesSelector_.setChecked(false);\n        }\n    }\n    else if (!checked && !busInterface->getMemoryMapReference(getBusName()).empty())\n    {\n        memoryMapSelector_.setChecked(true);\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: TargetModeEditor::onTransparentBridgeSelected()\n//-----------------------------------------------------------------------------\nvoid TargetModeEditor::onTransparentBridgeSelected(bool checked)\n{\n    BusInterfaceInterface* busInterface = getBusInterface();\n    std::string busName = getBusName();\n\n    if (checked)\n    {\n        if (busInterface->getMemoryMapReference(busName).empty() == false)\n        {\n            bridgesSelector_.setChecked(false);\n        }\n        else\n        {\n            memoryMapSelector_.setChecked(false);    \n        }\n        \n        if (!targetBridges_)\n        {\n            targetBridges_ = busInterface->createBridges(busName);\n            bridges_.setupBridges(targetBridges_);\n        }\n    }\n    else if (!checked && busInterface->getBridgeInterface()->itemCount() > 0)\n    {\n        bridgesSelector_.setChecked(true);\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: TargetModeEditor::onFileSetReferencesChanged()\n//-----------------------------------------------------------------------------\nvoid TargetModeEditor::onFileSetReferencesChanged()\n{\n    saveFileSetReferences();\n    emit contentChanged();\n}\n\n//-----------------------------------------------------------------------------\n// Function: TargetModeEditor::saveModeSpecific()\n//-----------------------------------------------------------------------------\nvoid TargetModeEditor::saveModeSpecific()\n{\n    saveFileSetReferences();\n\n    if (memoryMapSelector_.isChecked())\n    {\n        getBusInterface()->setMemoryMapReference(getBusName(), memoryMapReferenceSelector_.currentText().toStdString());\n    }\n    else if (bridgesSelector_.isChecked())\n    {\n        bridges_.refresh();\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: TargetModeEditor::setupFileSetReferences()\n//-----------------------------------------------------------------------------\nvoid TargetModeEditor::setupFileSetReferences()\n{\n    QStringList newFileSetItems;\n\n    for (auto const& fileSetName : getBusInterface()->getFileSetReferences(getBusName()))\n    {\n        newFileSetItems.append(QString::fromStdString(fileSetName));\n    }\n\n    fileSetRefs_.setItems(newFileSetItems);\n}\n\n//-----------------------------------------------------------------------------\n// Function: TargetModeEditor::saveFileSetReferences()\n//-----------------------------------------------------------------------------\nvoid TargetModeEditor::saveFileSetReferences()\n{\n    std::vector<std::string> newItems;\n    for (auto fileSetReference : fileSetRefs_.items())\n    {\n        newItems.push_back(fileSetReference.toStdString());\n    }\n\n    getBusInterface()->setFileSetReferences(getBusName(), newItems);\n}\n\n//-----------------------------------------------------------------------------\n// Function: TargetModeEditor::setupLayout()\n//-----------------------------------------------------------------------------\nvoid TargetModeEditor::setupLayout()\n{\n    auto accessSelectionGroup = new QGroupBox(tr(\"Interface access target\"), this);\n    accessSelectionGroup->setFlat(true);\n    auto accessSelectionLayout = new QHBoxLayout(accessSelectionGroup);\n    accessSelectionLayout->addWidget(&memoryMapSelector_, 0, Qt::AlignLeft);\n    accessSelectionLayout->addWidget(&bridgesSelector_, 1, Qt::AlignLeft);\n\n\n    QVBoxLayout* mapBridgeLayout = new QVBoxLayout();\n    mapBridgeLayout->addWidget(&memoryMapReferenceSelector_);\n    mapBridgeLayout->addWidget(&bridges_);\n    mapBridgeLayout->addWidget(&modeReferences_);\n    mapBridgeLayout->addStretch();\n\n    auto topLayout = new QGridLayout(this);\n    topLayout->addWidget(accessSelectionGroup, 0, 0, 1, 1);\n    topLayout->addLayout(mapBridgeLayout, 1, 0, 1, 1);\n    topLayout->addWidget(&fileSetRefs_, 0, 1, 2, 1);\n    topLayout->setContentsMargins(0, 4, 0, 2);\n}\n"
  },
  {
    "path": "editors/ComponentEditor/busInterfaces/general/TargetModeEditor.h",
    "content": "//-----------------------------------------------------------------------------\n// File: TargetModeEditor.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Esko Pekkarinen\n// Date: 29.06.2023\n//\n// Description:\n// Editor to the target details of a bus interface.\n//-----------------------------------------------------------------------------\n\n#ifndef TARGET_MODE_EDITOR_H\n#define TARGET_MODE_EDITOR_H\n\n#include \"ModeEditorBase.h\"\n#include \"bridgeseditor.h\"\n\n#include <editors/ComponentEditor/common/ReferenceSelector/ReferenceSelector.h>\n#include <editors/ComponentEditor/instantiations/filesetrefeditor.h>\n\n#include <IPXACTmodels/common/Document.h>\n#include <IPXACTmodels/Component/TargetInterface.h>\n\n#include <QSharedPointer>\n#include <QCheckBox>\n\nclass BusInterface;\nclass Component;\nclass BusInterfaceInterface;\n\n//-----------------------------------------------------------------------------\n//! Editor to the slave details of a bus interface.\n//-----------------------------------------------------------------------------\nclass TargetModeEditor : public ModeEditorBase \n{\n\tQ_OBJECT\n\npublic:\n\n\t/*!\n     *  The constructor.\n\t *\n     *    @param [in] busInterface    Interface for accessing bus interfaces.\n     *    @param [in] busName         Name of the edited bus interface.\n     *    @param [in] revision        Currently active IP-XACT revision.\n     *    @param [in] parent          The owner of this editor.\n     */\n    TargetModeEditor(BusInterfaceInterface* busInterface, std::string const& busName, Document::Revision revision, QWidget* parent);\n\n\t/*!\n     *  The destructor.\n     */\n\t~TargetModeEditor() final = default;\n\n\n    //! No copying. No assignment.\n    TargetModeEditor(const TargetModeEditor& other) = delete;\n    TargetModeEditor& operator=(const TargetModeEditor& other) = delete;\n\n\t/*!\n     *  Check for the validity of the edited item.\n     *\n     *    @return True if item is valid.\n     */\n\tbool isValid() const final;\n\n\t/*!\n     *  Restore the changes made in the editor back to ones in the model.\n     */\n\tvoid refresh() final;\n\n\t/*!\n     *  Get the interface mode of the editor\n\t * \n\t *    @return General::InterfaceMode Specifies the interface mode.\n     */\n\tGeneral::InterfaceMode getInterfaceMode() const final;\n\n\t/*!\n     *  Save the interface mode-specific details to the bus interface.\n     */\n\tvoid saveModeSpecific() final;\n\nprivate slots:\n\n\t/*!\n     *  Handler for changes in the memory map reference.\n     *\n     *    @param [in] newMemoryMapName    The name of the selected memory map.\n     */\n\tvoid onMemoryMapChange(QString const& newMemoryMapName);\n\n    /*!\n     *  Handler for selecting the memory map.\n     *\n     *    @param [in] checked     True, if the memory map was selected.\n     */\n    void onMemoryMapSelected(bool checked);\n\n    /*!\n     *  Handler for selecting the transparent bridges.\n     *\n     *    @param [in] checked     True, if the transparent bridges was selected.\n     */\n    void onTransparentBridgeSelected(bool checked);\n\n    /*!\n     *  Handler for changes in the file set references.\n     */\n    void onFileSetReferencesChanged();\n\nprivate:\n\n    /*!\n     *  Setup the current file set references.\n     */\n    void setupFileSetReferences();\n\n    //! Save the current file set references.\n    void saveFileSetReferences();\n\n    /*!\n     *  Sets the editor layout.\n     */\n    void setupLayout();\n\n    //-----------------------------------------------------------------------------\n    // Data.\n    //-----------------------------------------------------------------------------\n\n    //! Select memory map as access target.\n    QCheckBox memoryMapSelector_;\n\n    //! Select transparent bridge(s) as access target.\n    QCheckBox bridgesSelector_;\n\n\t//! The editor to select a memory map from the component.\n\tReferenceSelector memoryMapReferenceSelector_;\n\n    //! List of available transparent bridges.\n    QSharedPointer<QList<QSharedPointer<TransparentBridge> > > targetBridges_;\n\n\t//! The editor to edit the bridges of a slave interface.\n\tBridgesEditor bridges_;\n\n    //! The editor for mode reference selections.\n    ListManager modeReferences_;\n\n    //! Editor to set the file set references.\n    FileSetRefEditor fileSetRefs_;\n};\n\n#endif // TARGET_MODE_EDITOR_H\n"
  },
  {
    "path": "editors/ComponentEditor/busInterfaces/general/bridgesdelegate.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: BridgesDelegate.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 21.6.2012\r\n//\r\n// Description:\r\n// \r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"bridgesdelegate.h\"\r\n\r\n#include \"BridgeColumns.h\"\r\n\r\n#include <common/widgets/interfaceSelector/interfaceselector.h>\r\n\r\n#include <IPXACTmodels/generaldeclarations.h>\r\n#include <IPXACTmodels/Component/Component.h>\r\n\r\n#include <QApplication>\r\n#include <QMouseEvent>\r\n#include <QPainter>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BridgesDelegate::BridgesDelegate()\r\n//-----------------------------------------------------------------------------\r\nBridgesDelegate::BridgesDelegate(BusInterfaceInterface* busInterface, Document::Revision revision, QObject* parent):\r\nQStyledItemDelegate(parent),\r\nbusInterface_(busInterface),\r\nrevision_(revision)\r\n{\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BridgesDelegate::createEditor()\r\n//-----------------------------------------------------------------------------\r\nQWidget* BridgesDelegate::createEditor(QWidget* parent, const QStyleOptionViewItem& option,\r\n    QModelIndex const& index) const\r\n{\r\n    if (index.column() == BridgeColumns::INITIATOR_COLUMN)\r\n    {\r\n        auto busSelector(new InterfaceSelector(busInterface_, parent, General::INITIATOR));\r\n        if (revision_ == Document::Revision::Std14)\r\n        {\r\n            busSelector->setInterfaceMode(General::MASTER);\r\n        }\r\n\r\n        return busSelector;\r\n    }\r\n    else\r\n    {\r\n        return QStyledItemDelegate::createEditor(parent, option, index);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BridgesDelegate::setEditorData()\r\n//-----------------------------------------------------------------------------\r\nvoid BridgesDelegate::setEditorData(QWidget* editor, QModelIndex const& index) const\r\n{\r\n    if (index.column() == BridgeColumns::INITIATOR_COLUMN)\r\n    {\r\n        InterfaceSelector* selector = qobject_cast<InterfaceSelector*>(editor);\r\n        Q_ASSERT(selector);\r\n\r\n        selector->refresh();\r\n        selector->selectInterface(index.model()->data(index, Qt::DisplayRole).toString());\r\n    }\r\n    else \r\n    {\r\n        QStyledItemDelegate::setEditorData(editor, index);\r\n    }\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BridgesDelegate::setModelData()\r\n//-----------------------------------------------------------------------------\r\nvoid BridgesDelegate::setModelData(QWidget* editor, QAbstractItemModel* model, QModelIndex const& index) const\r\n{\r\n    if (index.column() == BridgeColumns::INITIATOR_COLUMN)\r\n    {\r\n        InterfaceSelector* selector = qobject_cast<InterfaceSelector*>(editor);\r\n        Q_ASSERT(selector);\r\n\r\n        QString selected = selector->currentText();\r\n        model->setData(index, selected, Qt::EditRole);\r\n    }\r\n    else\r\n    {\r\n        QStyledItemDelegate::setModelData(editor, model, index);\r\n    }\r\n}\r\n"
  },
  {
    "path": "editors/ComponentEditor/busInterfaces/general/bridgesdelegate.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: BridgesDelegate.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 21.6.2012\r\n//\r\n// Description:\r\n// \r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef BRIDGESDELEGATE_H\r\n#define BRIDGESDELEGATE_H\r\n\r\n#include <QStyledItemDelegate>\r\n#include <QSharedPointer>\r\n\r\n#include <IPXACTmodels/common/Document.h>\r\n\r\nclass Component;\r\nclass BusInterfaceInterface;\r\n\r\n//-----------------------------------------------------------------------------\r\n// Data.\r\n//-----------------------------------------------------------------------------\r\nclass BridgesDelegate : public QStyledItemDelegate\r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\r\n\t/*!\r\n     *  The constructor.\r\n\t *\r\n\t *    @param [in] busInterface    Interface for accessing bus interfaces.\r\n     *    @param [in] revision        Currently active IP-XACT revision.\r\n\t *    @param [in] parent          The owner of this delegate.\r\n     */\r\n    BridgesDelegate(BusInterfaceInterface* busInterface, Document::Revision revision, QObject* parent);\r\n\r\n\t/*!\r\n     *  The destructor.\r\n     */\r\n\tvirtual ~BridgesDelegate() = default;\r\n\r\n    //! No copying. No assignment.\r\n    BridgesDelegate(const BridgesDelegate& other) = delete;\r\n    BridgesDelegate& operator=(const BridgesDelegate& other) = delete;\r\n\r\n\r\n\t/*!\r\n     *  Create a new editor for the given item\r\n\t *\r\n\t *    @param [in] parent Owner for the editor.\r\n\t *    @param [in] option Contains options for the editor.\r\n\t *    @param [in] index Model index identifying the item.\r\n\t *\r\n\t *    @return The editor to be used to edit the item.\r\n     */\r\n\tQWidget* createEditor(QWidget* parent, const QStyleOptionViewItem& option, QModelIndex const& index)\r\n        const final;\r\n\r\n\t/*!\r\n     *  Set the data for the editor.\r\n\t *\r\n\t *    @param [in] editor The editor where the data is to be set.\r\n\t *    @param [in] index Model index identifying the item that's data is to be set.\r\n     */\r\n\tvoid setEditorData(QWidget* editor, QModelIndex const& index) const final;\r\n\r\n\t/*!\r\n     *  Save the data from the editor to the model.\r\n\t *\r\n\t *    @param [in] editor The editor that contains the data to store.\r\n\t *    @param [in] model Model that contains the data structure where data is to be saved to.\r\n\t *    @param [in] index Model index identifying the item that's data is to be saved.\r\n     */\r\n\tvoid setModelData(QWidget* editor, QAbstractItemModel* model, QModelIndex const& index) const final;\r\n\r\nprivate:\r\n\t\r\n    //! Interface for accessing bus interfaces.\r\n    BusInterfaceInterface* busInterface_;\r\n\r\n    //! The currently active IP-XACT revision.\r\n    Document::Revision revision_;\r\n};\r\n\r\n#endif // BRIDGESDELEGATE_H\r\n"
  },
  {
    "path": "editors/ComponentEditor/busInterfaces/general/bridgeseditor.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: bridgeseditor.app\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 21.06.2012\r\n//\r\n// Description:\r\n// Editor to edit the transparent bridge-elements within a slave interface mode or indirect interface.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"bridgeseditor.h\"\r\n#include \"bridgesdelegate.h\"\r\n#include \"BridgeColumns.h\"\r\n\r\n#include <IPXACTmodels/Component/Component.h>\r\n#include <IPXACTmodels/Component/TransparentBridge.h>\r\n\r\n#include <KactusAPI/include/BusInterfaceInterface.h>\r\n#include <KactusAPI/include/TransparentBridgeInterface.h>\r\n\r\n#include <QVBoxLayout>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BridgesEditor::BridgesEditor()\r\n//-----------------------------------------------------------------------------\r\nBridgesEditor::BridgesEditor(BusInterfaceInterface* busInterface,\r\n    QSharedPointer<QList<QSharedPointer<TransparentBridge>>> bridges,\r\n    Document::Revision currentRevision, QWidget* parent):\r\nQGroupBox(tr(\"Transparent bridge(s)\"), parent),\r\nview_(this),\r\nproxy_(this),\r\nmodel_(busInterface->getBridgeInterface(), currentRevision, this),\r\nbridgeInterface_(busInterface->getBridgeInterface()),\r\nbridges_(bridges)\r\n{\r\n    view_.setItemDelegate(new BridgesDelegate(busInterface, currentRevision, this));\r\n\r\n    // items can not be dragged\r\n    view_.setItemsDraggable(false);\r\n\r\n\tproxy_.setSourceModel(&model_);\r\n\tview_.setModel(&proxy_);\r\n\r\n\tview_.setColumnWidth(BridgeColumns::INITIATOR_COLUMN, 200);    \r\n\r\n    setFlat(true);\r\n\r\n\tQVBoxLayout* layout = new QVBoxLayout(this);\r\n\tlayout->addWidget(&view_);\r\n\r\n\tconnect(&view_, SIGNAL(addItem(const QModelIndex&)),\r\n        &model_, SLOT(onAddItem(const QModelIndex&)), Qt::UniqueConnection);\r\n\tconnect(&view_, SIGNAL(removeItem(const QModelIndex&)),\r\n\t\t&model_, SLOT(onRemoveItem(const QModelIndex&)), Qt::UniqueConnection);\r\n\r\n\tconnect(&model_, SIGNAL(contentChanged()), this, SIGNAL(contentChanged()), Qt::UniqueConnection);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BridgesEditor::~BridgesEditor()\r\n//-----------------------------------------------------------------------------\r\nBridgesEditor::~BridgesEditor()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: bridgeseditor::setupBridges()\r\n//-----------------------------------------------------------------------------\r\nvoid BridgesEditor::setupBridges(QSharedPointer<QList<QSharedPointer<TransparentBridge> > > newBridges)\r\n{\r\n    bridges_ = newBridges;\r\n\r\n    refresh();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BridgesEditor::refresh()\r\n//-----------------------------------------------------------------------------\r\nvoid BridgesEditor::refresh()\r\n{\r\n    bridgeInterface_->setBridges(bridges_);\r\n\r\n    model_.refresh();\r\n}\r\n"
  },
  {
    "path": "editors/ComponentEditor/busInterfaces/general/bridgeseditor.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: bridgeseditor.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 21.06.2012\r\n//\r\n// Description:\r\n// Editor to edit the transparent bridge-elements within a slave interface mode or indirect interface.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef BRIDGESEDITOR_H\r\n#define BRIDGESEDITOR_H\r\n\r\n#include \"bridgesmodel.h\"\r\n\r\n#include <IPXACTmodels/common/Document.h>\r\n\r\n#include <common/views/EditableTableView/editabletableview.h>\r\n\r\n#include <QGroupBox>\r\n#include <QSortFilterProxyModel>\r\n#include <QSharedPointer>\r\n\r\nclass Component;\r\nclass TransparentBridge;\r\nclass TransparentBridgeInterface;\r\nclass BusInterfaceInterface;\r\nclass TargetInterface;\r\nclass BusInterfaceValidator;\r\nclass IndirectInterface;\r\nclass IndirectInterfaceValidator;\r\n\r\n //-----------------------------------------------------------------------------\r\n // Editor to edit the transparent bridge-elements within a slave interface mode or indirect interface.\r\n //-----------------------------------------------------------------------------\r\nclass BridgesEditor : public QGroupBox\r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\r\n\t/*!\r\n     *  The constructor.\r\n\t *\r\n     *    @param [in] busInterface        Interface for accessing bus interfaces.\r\n\t *    @param [in] bridges             The bridges to edit in the editor.\r\n     *    @param [in] currentRevision     Currently active IP-XACT revision.\r\n\t *    @param [in] parent              The parent of this editor.\r\n     */\r\n    BridgesEditor(BusInterfaceInterface* busInterface,\r\n        QSharedPointer<QList<QSharedPointer<TransparentBridge> > > bridges,\r\n        Document::Revision currentRevision,\r\n        QWidget* parent);\r\n\r\n\t/*!\r\n     *  The destructor.\r\n     */\r\n\tvirtual ~BridgesEditor();\r\n\r\n    /*!\r\n     *  Refresh the bridges in the editor.\r\n     */\r\n    void refresh();\r\n\r\n    /*!\r\n     *  Setup the bridges for the editor.\r\n     *\r\n     *    @param [in] newBridges  The new bridges.\r\n     */\r\n    void setupBridges(QSharedPointer<QList<QSharedPointer<TransparentBridge> > > newBridges);\r\n\r\nsignals:\r\n\r\n\t/*!\r\n     *  Emitted when the contents of the bridges change.\r\n     */\r\n\tvoid contentChanged();\r\n\r\nprivate:\r\n\t\r\n    //! No copying. No assignment.\r\n\tBridgesEditor(const BridgesEditor& other);\r\n\tBridgesEditor& operator=(const BridgesEditor& other);\r\n\r\n\t//! The view to display the bridges.\r\n\tEditableTableView view_;\r\n\r\n\t//! The proxy that does the sorting.\r\n\tQSortFilterProxyModel proxy_;\r\n\r\n\t//! Model that manages the bridges.\r\n\tBridgesModel model_;\r\n\r\n    //! Interface for accessing transparent bridges.\r\n    TransparentBridgeInterface* bridgeInterface_;\r\n\r\n    //! List of the available transparent bridges.\r\n    QSharedPointer<QList<QSharedPointer<TransparentBridge> > > bridges_;\r\n};\r\n\r\n#endif // BRIDGESEDITOR_H\r\n"
  },
  {
    "path": "editors/ComponentEditor/busInterfaces/general/bridgesmodel.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: bridgesmodel.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 21.06.2012\r\n//\r\n// Description:\r\n// The model to manage the bridges of a slave interface.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"bridgesmodel.h\"\r\n#include \"BridgeColumns.h\"\r\n\r\n#include <common/KactusColors.h>\r\n\r\n#include <KactusAPI/include/TransparentBridgeInterface.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BridgesModel::BridgesModel()\r\n//-----------------------------------------------------------------------------\r\nBridgesModel::BridgesModel(TransparentBridgeInterface* bridgeInterface, Document::Revision docRevision, QObject *parent):\r\nQAbstractTableModel(parent),\r\nbridgeInterface_(bridgeInterface),\r\ndocumentRevision_(docRevision)\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BridgesModel::~BridgesModel()\r\n//-----------------------------------------------------------------------------\r\nBridgesModel::~BridgesModel()\r\n{\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BridgesModel::rowCount()\r\n//-----------------------------------------------------------------------------\r\nint BridgesModel::rowCount(QModelIndex const& parent) const\r\n{\r\n\tif (parent.isValid())\r\n    {\r\n\t\treturn 0;\r\n\t}\r\n\r\n    return bridgeInterface_->itemCount();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BridgesModel::columnCount()\r\n//-----------------------------------------------------------------------------\r\nint BridgesModel::columnCount(QModelIndex const& parent) const\r\n{\r\n\tif (parent.isValid())\r\n    {\r\n\t\treturn 0;\r\n\t}\r\n\r\n\treturn BridgeColumns::COLUMN_COUNT;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BridgesModel::flags()\r\n//-----------------------------------------------------------------------------\r\nQt::ItemFlags BridgesModel::flags(QModelIndex const& index) const\r\n{\r\n\tif (!index.isValid())\r\n    {\r\n\t\treturn Qt::NoItemFlags;\r\n\t}\r\n\r\n\treturn Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsEditable;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BridgesModel::headerData()\r\n//-----------------------------------------------------------------------------\r\nQVariant BridgesModel::headerData(int section, Qt::Orientation orientation, int role) const\r\n{\r\n    if (orientation != Qt::Horizontal || role != Qt::DisplayRole)\r\n    {\r\n        return QVariant();\r\n    }\r\n\r\n    if (section == BridgeColumns::INITIATOR_COLUMN)\r\n    {\r\n        if (documentRevision_ == Document::Revision::Std14)\r\n        {\r\n            return tr(\"Master bus interface\");\r\n        }\r\n        else\r\n        {\r\n            return tr(\"Initiator bus interface\");\r\n        }\r\n    }\r\n    else\r\n    {\r\n        return QVariant();\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BridgesModel::data()\r\n//-----------------------------------------------------------------------------\r\nQVariant BridgesModel::data(QModelIndex const& index, int role) const\r\n{\r\n    if (!index.isValid() || index.row() < 0 || index.row() >= bridgeInterface_->itemCount())\r\n    {\r\n\t\treturn QVariant();\r\n\t}\r\n\t\r\n    QString masterReference = QString::fromStdString(bridgeInterface_->getIndexedMasterReference(index.row()));\r\n\r\n    if (role == Qt::DisplayRole) \r\n    {\r\n        if (index.column() == BridgeColumns::INITIATOR_COLUMN)\r\n        {\r\n            return masterReference;\r\n        }\r\n        else\r\n        {\r\n            return QVariant();\r\n        }\r\n    }\r\n\t\r\n\telse if (role == Qt::ForegroundRole)\r\n    {\r\n        if (masterReference.isEmpty())\r\n        {\r\n\t\t\treturn KactusColors::ERROR;\r\n\t\t}\r\n\t\telse\r\n        {\r\n\t\t\treturn KactusColors::REGULAR_TEXT;\r\n\t\t}\r\n\t}\r\n\telse if (role == Qt::BackgroundRole)\r\n    {\r\n        if (index.column() == BridgeColumns::INITIATOR_COLUMN)\r\n        {\r\n            return KactusColors::MANDATORY_FIELD;\r\n        }\r\n        else\r\n        {\r\n            return KactusColors::REGULAR_FIELD;\r\n        }\r\n    }\r\n\r\n\telse \r\n    {\r\n\t\treturn QVariant();\r\n\t}\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BridgesModel::setData()\r\n//-----------------------------------------------------------------------------\r\nbool BridgesModel::setData(QModelIndex const& index, const QVariant& value, int role)\r\n{\r\n    if (!index.isValid() || index.row() < 0 || index.row() >= bridgeInterface_->itemCount())\r\n    {\r\n\t\treturn false;\r\n    }\r\n\r\n    if (role == Qt::EditRole)\r\n    {\r\n        if (index.column() == BridgeColumns::INITIATOR_COLUMN)\r\n        {\r\n            std::string currentMaster = bridgeInterface_->getIndexedMasterReference(index.row());\r\n            bridgeInterface_->setMasterReference(currentMaster, value.toString().toStdString());\r\n        }\r\n        else\r\n        {\r\n            return false;\r\n        }\r\n        emit dataChanged(index, index);\r\n        emit contentChanged();\r\n        return true;\r\n\t}\r\n\t\r\n\telse\r\n    {\r\n\t\treturn false;\r\n\t}\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BridgesModel::onAddItem()\r\n//-----------------------------------------------------------------------------\r\nvoid BridgesModel::onAddItem(QModelIndex const& index)\r\n{\r\n    int row = bridgeInterface_->itemCount();\r\n\r\n\t// if the index is valid then add the item to the correct position\r\n\tif (index.isValid())\r\n    {\r\n\t\trow = index.row();\r\n\t}\r\n\r\n\tbeginInsertRows(QModelIndex(), row, row);\r\n\r\n    bridgeInterface_->addBridge(row);\r\n\r\n\tendInsertRows();\r\n\r\n\t// tell also parent widget that contents have been changed\r\n\temit contentChanged();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BridgesModel::onRemoveItem()\r\n//-----------------------------------------------------------------------------\r\nvoid BridgesModel::onRemoveItem(QModelIndex const& index)\r\n{\r\n\t// don't remove anything if index is invalid\r\n    if (!index.isValid() || index.row() < 0 || index.row() >= bridgeInterface_->itemCount())\r\n    {\r\n\t\treturn;\r\n\t}\r\n\r\n\t// remove the specified item\r\n\tbeginRemoveRows(QModelIndex(), index.row(), index.row());\r\n\r\n    std::string masterReference = bridgeInterface_->getIndexedMasterReference(index.row());\r\n    bridgeInterface_->removeTransparentBridge(masterReference);\r\n\r\n\tendRemoveRows();\r\n\r\n\t// tell also parent widget that contents have been changed\r\n\temit contentChanged();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BridgesModel::refresh()\r\n//-----------------------------------------------------------------------------\r\nvoid BridgesModel::refresh()\r\n{\r\n\tbeginResetModel();\r\n\tendResetModel();\r\n}\r\n"
  },
  {
    "path": "editors/ComponentEditor/busInterfaces/general/bridgesmodel.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: bridgesmodel.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 21.06.2012\r\n//\r\n// Description:\r\n// The model to manage the bridges of a slave interface.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef BRIDGESMODEL_H\r\n#define BRIDGESMODEL_H\r\n\r\n#include <IPXACTmodels/Component/TransparentBridge.h>\r\n#include <IPXACTmodels/common/Document.h>\r\n\r\n#include <QAbstractTableModel>\r\n#include <QSharedPointer>\r\n\r\nclass TransparentBridgeInterface;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! The model to manage the bridges of a slave interface.\r\n//-----------------------------------------------------------------------------\r\nclass BridgesModel : public QAbstractTableModel\r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\r\n\t/*!\r\n     *  The constructor\r\n\t *\r\n\t *    @param [in] bridgeInterface     Interface for accessing transparent bridges.\r\n     *    @param [in] docRevision         The IP-XACT version to comply to.\r\n\t *    @param [in] parent              The parent of this model.\r\n     */\r\n    BridgesModel(TransparentBridgeInterface* bridgeInterface, Document::Revision docRevision, QObject *parent);\r\n\r\n\t/*!\r\n     *  The destructor.\r\n     */\r\n\tvirtual ~BridgesModel();\r\n\r\n\t/*!\r\n     *  Get the number of rows an item contains.\r\n\t *\r\n\t *    @param [in] parent Identifies the parent that's row count is requested.\r\n\t *\r\n\t *    @return Number of rows the item has.\r\n     */\r\n\tvirtual int rowCount(QModelIndex const& parent = QModelIndex()) const;\r\n\r\n\t/*!\r\n     *  Get the number of columns the item has to be displayed.\r\n\t *\r\n\t *    @param [in] parent Identifies the parent that's column count is requested.\r\n\t *\r\n\t *    @return The number of columns to be displayed.\r\n     */\r\n\tvirtual int columnCount(QModelIndex const& parent = QModelIndex()) const;\r\n\r\n\t/*!\r\n     *  Get the item flags that defines the possible operations for the item.\r\n\t *\r\n\t *    @param [in] index Model index that identifies the item.\r\n\t *\r\n\t *    @return Qt::ItemFlags specify the possible operations for the item.\r\n     */\r\n\tQt::ItemFlags flags(QModelIndex const& index) const;\r\n\r\n\t/*!\r\n     *  Get the header data for specified header.\r\n\t *\r\n\t *    @param [in] section         The section specifies the row/column number for the header.\r\n\t *    @param [in] orientation     Specified if horizontal or vertical header is wanted.\r\n\t *    @param [in] role            Specifies the type of the requested data.\r\n\t *\r\n\t *    @return QVariant Contains the requested data.\r\n     */\r\n\tvirtual QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;\r\n\r\n\t/*!\r\n     *  Get the data for specified item.\r\n\t *\r\n\t *    @param [in] index   Specifies the item that's data is requested.\r\n\t *    @param [in] role    The role that defines what kind of data is requested.\r\n\t *\r\n\t *    @return QVariant Contains the data for the item.\r\n     */\r\n\tvirtual QVariant data(QModelIndex const& index, int role = Qt::DisplayRole) const;\r\n\r\n\t/*!\r\n     *  Save the data to the model for specified item\r\n\t *\r\n\t *    @param [in] index   The model index of the item that's data is to be saved.\r\n\t *    @param [in] value   The data that is to be saved.\r\n\t *    @param [in] role    The role specifies what kind of data should be saved.\r\n\t *\r\n\t *    @return True if saving happened successfully.\r\n     */\r\n\tbool setData(QModelIndex const& index, const QVariant& value, int role = Qt::EditRole);\r\n\r\n\t/*!\r\n     *  Refresh the model to match the slave interface.\r\n     */\r\n    void refresh();\r\n\r\npublic slots:\r\n\r\n\t/*! Add a new item to the given index.\r\n\t *\r\n\t *    @param [in] index The index identifying the position for new item.\r\n\t */\r\n\tvirtual void onAddItem(QModelIndex const& index);\r\n\r\n\t/*! Remove the item in the given index.\r\n\t *\r\n\t *    @param [in] index The index identifying the item to remove.\r\n\t */\r\n\tvirtual void onRemoveItem(QModelIndex const& index);\r\n\r\nsignals:\r\n\r\n\t//! Emitted when contents of the model change.\r\n\tvoid contentChanged();\r\n\r\nprivate:\r\n\r\n\t//! No copying\r\n\tBridgesModel(const BridgesModel& other);\r\n\tBridgesModel& operator=(const BridgesModel& other);\r\n\r\n\t//! Interface for accessing transparent bridges.\r\n    TransparentBridgeInterface* bridgeInterface_;\r\n\r\n    //! The IP-XACT version to comply to.\r\n    Document::Revision documentRevision_;\r\n};\r\n\r\n#endif // BRIDGESMODEL_H\r\n"
  },
  {
    "path": "editors/ComponentEditor/busInterfaces/general/busifgeneraldetails.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: busifgeneraldetails.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 05.04.2011\r\n//\r\n// Description:\r\n// Editor to edit the bus interface details.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"busifgeneraldetails.h\"\r\n\r\n#include <IPXACTmodels/generaldeclarations.h>\r\n\r\n#include <KactusAPI/include/BusInterfaceInterface.h>\r\n\r\n#include <editors/ComponentEditor/parameters/ComponentParameterModel.h>\r\n\r\n#include <common/KactusColors.h>\r\n\r\n#include <QCompleter>\r\n#include <QFormLayout>\r\n#include <QVBoxLayout>\r\n#include <QHBoxLayout>\r\n#include <QSizePolicy>\r\n#include <QLabel>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusIfGeneralDetails::BusIfGeneralDetails()\r\n//-----------------------------------------------------------------------------\r\nBusIfGeneralDetails::BusIfGeneralDetails(BusInterfaceInterface* busInterface, std::string const& busName,\r\n    Document::Revision docRevision, QSharedPointer<ParameterFinder> finder,\r\n    QSharedPointer<ExpressionParser> expressionParser,\r\n    QWidget* parent):\r\nQGroupBox(tr(\"General\") ,parent),\r\nbusInterface_(busInterface),\r\nbusName_(busName),\r\nmodeSelector_(docRevision, busInterface_->getMode(busName), true, this),\r\nconnectionRequired_(this),\r\nbitsInLauEditor_(finder, this),\r\nendiannessSelector_(this),\r\nbitSteeringSelector_(this),\r\nbitSteeringEditor_(finder, this)\r\n{\r\n    setFlat(true);\r\n    \r\n    ComponentParameterModel* componentParameterModel = new ComponentParameterModel(finder, this);\r\n    componentParameterModel->setExpressionParser(expressionParser);\r\n\r\n    auto bitInLauCompleter = new QCompleter(this);\r\n    bitInLauCompleter->setModel(componentParameterModel);\r\n    bitsInLauEditor_.setAppendingCompleter(bitInLauCompleter);\r\n    bitsInLauEditor_.setFixedHeight(ExpressionEditor::DEFAULT_HEIGHT);\r\n\r\n    endiannessSelector_.addItem(QString(\"little\"));\r\n\tendiannessSelector_.addItem(QString(\"big\"));\r\n    endiannessSelector_.addItem(QString(\"\"));\r\n\r\n\tbitSteeringSelector_.addItem(QString(\"on\"));\r\n\tbitSteeringSelector_.addItem(QString(\"off\"));\r\n    bitSteeringSelector_.addItem(QString(\"\"));\r\n    bitSteeringSelector_.setVisible(docRevision == Document::Revision::Std14);\r\n\r\n    auto bitSteeringCompleter = new QCompleter(this);\r\n    bitSteeringCompleter->setModel(componentParameterModel);\r\n    bitSteeringEditor_.setAppendingCompleter(bitSteeringCompleter);\r\n\r\n    bitSteeringEditor_.setFixedHeight(ExpressionEditor::DEFAULT_HEIGHT);\r\n    bitSteeringEditor_.setVisible(docRevision == Document::Revision::Std22);\r\n\r\n    connect(&modeSelector_, SIGNAL(modeSelected(General::InterfaceMode)),\r\n        this, SIGNAL(modeSelected(General::InterfaceMode)), Qt::UniqueConnection);\r\n\tconnect(&connectionRequired_, SIGNAL(stateChanged(int)),\r\n        this, SLOT(onConnectionRequiredChanged()), Qt::UniqueConnection);\r\n\tconnect(&bitsInLauEditor_, SIGNAL(editingFinished()),\r\n\t\tthis, SLOT(onAddressableUnitChanged()), Qt::UniqueConnection);\r\n\tconnect(&endiannessSelector_, SIGNAL(currentIndexChanged(int)),\r\n\t\tthis, SLOT(onEndiannessChanged()), Qt::UniqueConnection);\r\n\tconnect(&bitSteeringSelector_, SIGNAL(currentIndexChanged(int)),\r\n        this, SLOT(onBitSteeringChanged()), Qt::UniqueConnection);\r\n    connect(&bitSteeringEditor_, SIGNAL(editingFinished()),\r\n        this, SLOT(onBitSteeringExpressionChanged()), Qt::UniqueConnection);\r\n    connect(&modeSelector_, SIGNAL(modeSelected(General::InterfaceMode)),\r\n        this, SLOT(updateBitSteeringControls(General::InterfaceMode)), Qt::UniqueConnection);\r\n\r\n    setupLayout(docRevision);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: busifgeneraldetails::updateBitSteeringControls()\r\n//-----------------------------------------------------------------------------\r\nvoid BusIfGeneralDetails::updateBitSteeringControls(General::InterfaceMode mode)\r\n{\r\n    QPalette comboPalette = bitSteeringSelector_.palette();\r\n\r\n    QColor colour = KactusColors::REGULAR_TEXT;\r\n   \r\n    if (mode == General::MIRRORED_MASTER || mode == General::MIRRORED_INITIATOR ||\r\n        mode == General::SYSTEM || mode == General::MIRRORED_SYSTEM)\r\n    {\r\n        if (!busInterface_->getBitSteering(busName_).empty())\r\n        {\r\n            colour = KactusColors::ERROR;\r\n        }\r\n        else\r\n        {\r\n            bitSteeringSelector_.setDisabled(true);\r\n            bitSteeringEditor_.setDisabled(true);\r\n        }\r\n    }\r\n    else\r\n    {\r\n        bitSteeringSelector_.setEnabled(true);\r\n        bitSteeringEditor_.setEnabled(true);\r\n    }\r\n\r\n    comboPalette.setColor(QPalette::Text, colour);\r\n    bitSteeringSelector_.setPalette(comboPalette);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusIfGeneralDetails::isValid()\r\n//-----------------------------------------------------------------------------\r\nbool BusIfGeneralDetails::isValid() const\r\n{\r\n    return modeSelector_.currentIndex() != -1;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusIfGeneralDetails::refresh()\r\n//-----------------------------------------------------------------------------\r\nvoid BusIfGeneralDetails::refresh()\r\n{\r\n    auto mode = busInterface_->getMode(busName_);\r\n    modeSelector_.setMode(mode);\r\n\r\n    QString connectionRequirement = QString::fromStdString(busInterface_->connectionIsRequired(busName_));\r\n    connectionRequired_.setChecked(connectionRequirement == QLatin1String(\"true\"));\r\n\r\n    bitsInLauEditor_.setExpression(QString::fromStdString(busInterface_->getBitsInLau(busName_)));\r\n\r\n    endiannessSelector_.setCurrentIndex(busInterface_->getEndianness(busName_));\r\n\r\n    disconnect(&bitSteeringSelector_, SIGNAL(currentIndexChanged(int)),\tthis, SLOT(onBitSteeringChanged()));\r\n\r\n    auto bitSteering = QString::fromStdString(busInterface_->getBitSteering(busName_));\r\n    bitSteeringSelector_.setCurrentText(bitSteering);\r\n\r\n    updateBitSteeringControls(mode);\r\n\r\n    connect(&bitSteeringSelector_, SIGNAL(currentIndexChanged(int)),\r\n        this, SLOT(onBitSteeringChanged()), Qt::UniqueConnection);\r\n\r\n    bitSteeringEditor_.setExpression(bitSteering);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusIfGeneralDetails::onAddressableUnitChanged()\r\n//-----------------------------------------------------------------------------\r\nvoid BusIfGeneralDetails::onAddressableUnitChanged()\r\n{\r\n    bitsInLauEditor_.finishEditingCurrentWord();\r\n\r\n    busInterface_->setBitsInLau(busName_, bitsInLauEditor_.getExpression().toStdString());\r\n\temit contentChanged();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusIfGeneralDetails::onEndiannessChanged()\r\n//-----------------------------------------------------------------------------\r\nvoid BusIfGeneralDetails::onEndiannessChanged()\r\n{\r\n    busInterface_->setEndianness(busName_, endiannessSelector_.currentText().toStdString());\r\n\temit contentChanged();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusIfGeneralDetails::onBitSteeringChanged()\r\n//-----------------------------------------------------------------------------\r\nvoid BusIfGeneralDetails::onBitSteeringChanged()\r\n{\r\n    busInterface_->setBitSteering(busName_, bitSteeringSelector_.currentText().toStdString());\r\n    \r\n    updateBitSteeringControls(busInterface_->getMode(busName_));\r\n\r\n\temit contentChanged();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusIfGeneralDetails::onBitSteeringExpressionChanged()\r\n//-----------------------------------------------------------------------------\r\nvoid BusIfGeneralDetails::onBitSteeringExpressionChanged()\r\n{\r\n    bitSteeringEditor_.finishEditingCurrentWord();\r\n    busInterface_->setBitSteering(busName_, bitSteeringEditor_.getExpression().toStdString());\r\n\r\n    emit contentChanged();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusIfGeneralDetails::onConnectionRequiredChanged()\r\n//-----------------------------------------------------------------------------\r\nvoid BusIfGeneralDetails::onConnectionRequiredChanged()\r\n{\r\n    busInterface_->setConnectionIsRequired(busName_, connectionRequired_.isChecked());\r\n\temit contentChanged();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusIfGeneralDetails::setupLayout()\r\n//-----------------------------------------------------------------------------\r\nvoid BusIfGeneralDetails::setupLayout(Document::Revision docRevision)\r\n{\r\n    QFormLayout* modeLayout = new QFormLayout(this);\r\n    modeLayout->addRow(tr(\"Interface mode:\"), &modeSelector_);\r\n    modeLayout->addRow(tr(\"Addressable unit size, f(x):\"), &bitsInLauEditor_);\r\n\r\n    if (docRevision == Document::Revision::Std14)\r\n    {\r\n        modeLayout->addRow(tr(\"Bit steering:\"), &bitSteeringSelector_);\r\n    }\r\n    if (docRevision == Document::Revision::Std22)\r\n    {\r\n        modeLayout->addRow(tr(\"Bit steering, f(x):\"), &bitSteeringEditor_);\r\n    }\r\n\r\n    modeLayout->addRow(tr(\"Endianness:\"), &endiannessSelector_);\r\n    modeLayout->addRow(tr(\"Connection required:\"), &connectionRequired_);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: busifgeneraldetails::changeName()\r\n//-----------------------------------------------------------------------------\r\nvoid BusIfGeneralDetails::changeName(std::string const& newName)\r\n{\r\n    busName_ = newName;\r\n}\r\n"
  },
  {
    "path": "editors/ComponentEditor/busInterfaces/general/busifgeneraldetails.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: busifgeneraldetails.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 05.04.2011\r\n//\r\n// Description:\r\n// Editor to edit the bus interface details.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef BUSIFGENERALDETAILS_H\r\n#define BUSIFGENERALDETAILS_H\r\n\r\n#include <common/widgets/interfaceModeSelector/interfacemodeselector.h>\r\n\r\n#include <editors/ComponentEditor/common/ExpressionEditor.h>\r\n\r\n#include <KactusAPI/include/ExpressionParser.h>\r\n\r\n\r\n#include <QGroupBox>\r\n#include <QCheckBox>\r\n#include <QLineEdit>\r\n#include <QComboBox>\r\n#include <QSharedPointer>\r\n\r\nclass BusInterfaceInterface;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Editor to edit the bus interface details.\r\n//-----------------------------------------------------------------------------\r\nclass BusIfGeneralDetails : public QGroupBox\r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\r\n\t/*!\r\n     *  The constructor\r\n\t *\r\n\t *    @param [in] busInterface    Interface for accessing bus interfaces.\r\n     *    @param [in] busName         Name of the bus interface being edited.\r\n     *    @param [in] docRevision     The IP-XACT version to comply to.\r\n\t *    @param [in] parent          The owner of this editor.\r\n     */\r\n    BusIfGeneralDetails(BusInterfaceInterface* busInterface, std::string const& busName, \r\n\t\tDocument::Revision docRevision, QSharedPointer<ParameterFinder> finder, \r\n\t\tQSharedPointer<ExpressionParser> expressionParser,\r\n\t\tQWidget* parent);\r\n\r\n\t/*!\r\n     *  The destructor\r\n     */\r\n\tvirtual ~BusIfGeneralDetails() = default;\r\n\r\n    //! No copying\r\n    BusIfGeneralDetails(const BusIfGeneralDetails& other) = delete;\r\n\r\n    //! No assignment\r\n    BusIfGeneralDetails& operator=(const BusIfGeneralDetails& other) = delete;\r\n\r\n\t/*! Check for the validity of the edited item.\r\n\t*\r\n\t*    @return True if item is valid.\r\n\t*/\r\n\tvirtual bool isValid() const;\r\n\r\n\t/*! Restore the changes made in the editor back to ones in the model.\r\n\t*\r\n\t*/\r\n\tvirtual void refresh();\r\n\r\n    /*!\r\n     *  Change the name of the bus interface being edited.\r\n     *\r\n     *    @param [in] newName     The new bus interface name.\r\n     */\r\n    void changeName(std::string const& newName);\r\n\r\nsignals:\r\n\r\n\t//! Emitted when contents of the model change\r\n\tvoid contentChanged();\r\n\r\n\t//! Prints an error message to the user.\r\n\tvoid errorMessage(const QString& msg) const;\r\n\r\n\t//! Prints a notification to user.\r\n\tvoid noticeMessage(const QString& msg) const;\r\n\r\n    //! Emitted when a new interface mode has been selected.\r\n    void modeSelected(General::InterfaceMode);\r\n\r\nprivate slots:\r\n\r\n\t//! Handler for changes in least addressable unit (bits in lau)\r\n\tvoid onAddressableUnitChanged();\r\n\r\n\t//! Handler for changes in the endianness.\r\n\tvoid onEndiannessChanged();\r\n\r\n\t//! Handler for changes in bit steering.\r\n\tvoid onBitSteeringChanged();\r\n\r\n\t//! Handler for changes in bit steering expression.\r\n\tvoid onBitSteeringExpressionChanged();\r\n\r\n\t//! Handler for changes in connection required check box\r\n\tvoid onConnectionRequiredChanged();\r\n\r\n    /*!\r\n     *  Change the colouring of bit steering combobox determined by the currently selected interface mode.\r\n     */\r\n    void updateBitSteeringControls(General::InterfaceMode mode);\r\n\r\nprivate:\r\n\t\r\n    //! Sets the editor layout.\r\n    void setupLayout(Document::Revision docRevision);\r\n\r\n\t//! Interface for accesssing bus  interfaces.\r\n    BusInterfaceInterface* busInterface_;\r\n\r\n    //! Name of the edited bus interface.\r\n    std::string busName_;\r\n\r\n    //! The selector to select the interface mode.\r\n    InterfaceModeSelector modeSelector_;\r\n\r\n\t//! Set the connection required to true or false\r\n\tQCheckBox connectionRequired_;\r\n\r\n\t//! Sets the value for bits in lau.\r\n\tExpressionEditor bitsInLauEditor_;\r\n\r\n\t//! Set the endianness of interface\r\n\tQComboBox endiannessSelector_;\r\n\r\n\t//! Set bit steering on/off\r\n\tQComboBox bitSteeringSelector_;\r\n\r\n\t//! \r\n\tExpressionEditor bitSteeringEditor_;\r\n\r\n};\r\n\r\n#endif // BUSIFGENERALDETAILS_H\r\n"
  },
  {
    "path": "editors/ComponentEditor/busInterfaces/general/busifgeneraltab.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: busifgeneraltab.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 05.04.2011\r\n//\r\n// Description:\r\n// Container for editor on the general tab of a bus interface editor.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"busifgeneraltab.h\"\r\n\r\n#include <KactusAPI/include/LibraryInterface.h>\r\n\r\n#include <editors/ComponentEditor/busInterfaces/AbstractionTypesEditor.h>\r\n#include <KactusAPI/include/BusInterfaceInterface.h>\r\n#include <KactusAPI/include/AbstractionTypeInterface.h>\r\n\r\n#include <IPXACTmodels/common/VLNV.h>\r\n#include <IPXACTmodels/Component/Component.h>\r\n#include <IPXACTmodels/Component/BusInterface.h>\r\n\r\n#include <QHBoxLayout>\r\n#include <QScrollArea>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusIfGeneralTab::BusIfGeneralTab()\r\n//-----------------------------------------------------------------------------\r\nBusIfGeneralTab::BusIfGeneralTab(LibraryInterface* libHandler, QSharedPointer<BusInterface> busif,\r\n    QSharedPointer<Component> component, ExpressionSet expressions,\r\n    BusInterfaceInterface* busInterface, std::string const& busName, QWidget* parent, QWidget* parentWnd) :\r\nQWidget(parent),\r\n    busInterface_(busInterface),\r\n    nameEditor_(busif, component->getRevision(), this, tr(\"Name and description\")),\r\n    busType_(VLNV::BUSDEFINITION, libHandler, parentWnd, this),\r\n    abstractionEditor_(new AbstractionTypesEditor(component, libHandler, busInterface_->getAbstractionTypeInterface(),\r\n        parentWnd, this)),\r\n    modeStack_(busInterface_, busName, component, expressions.finder, libHandler, expressions.parser, this),\r\n    details_(busInterface_, busName, component->getRevision(), expressions.finder, expressions.parser, this),\r\n    parameters_(busif->getParameters(), component->getChoices(), expressions.finder, expressions.formatter, component->getRevision(), this),\r\n    libHandler_(libHandler),\r\n    docRevision_(component->getRevision())\r\n{\r\n\tQ_ASSERT_X(libHandler, \"BusIfGeneralTab constructor\", \"Null LibraryInterface-pointer given as parameter\");\r\n    Q_ASSERT(busInterface_);\r\n\r\n    busType_.setFlat(true);\r\n    busType_.setRevisionFilter(true, docRevision_);\r\n    abstractionEditor_->setFlat(true);\r\n    parameters_.setFlat(true);\r\n\r\n    connect(&parameters_, SIGNAL(increaseReferences(QString)),\r\n        this, SIGNAL(increaseReferences(QString)), Qt::UniqueConnection);\r\n    connect(&parameters_, SIGNAL(decreaseReferences(QString)),\r\n        this, SIGNAL(decreaseReferences(QString)), Qt::UniqueConnection);\r\n    connect(&parameters_, SIGNAL(openReferenceTree(QString const&, QString const&)),\r\n        this, SIGNAL(openReferenceTree(QString const&, QString const&)), Qt::UniqueConnection);\r\n\r\n    connect(&parameters_,\r\n        SIGNAL(recalculateReferencesToParameters(QVector<QString> const&, AbstractParameterInterface*)),\r\n        this,\r\n        SIGNAL(recalculateReferencesToParameters(QVector<QString> const&, AbstractParameterInterface*)),\r\n        Qt::UniqueConnection);\r\n\r\n    connect(&modeStack_, SIGNAL(increaseReferences(QString)),\r\n        this, SIGNAL(increaseReferences(QString)), Qt::UniqueConnection);\r\n    connect(&modeStack_, SIGNAL(decreaseReferences(QString)),\r\n        this, SIGNAL(decreaseReferences(QString)), Qt::UniqueConnection);\r\n\r\n\tconnect(&nameEditor_, SIGNAL(contentChanged()), this, SIGNAL(contentChanged()), Qt::UniqueConnection);\r\n    connect(&nameEditor_, SIGNAL(nameChanged()), this, SLOT(onNameChanged()), Qt::UniqueConnection);\r\n\r\n\tconnect(&busType_, SIGNAL(vlnvEdited()), this, SLOT(onBusTypeChanged()), Qt::UniqueConnection);\r\n\tconnect(&details_, SIGNAL(modeSelected(General::InterfaceMode)),\r\n\t\tthis, SLOT(onModeChanged(General::InterfaceMode)), Qt::UniqueConnection);\r\n\tconnect(&modeStack_, SIGNAL(contentChanged()), this, SIGNAL(contentChanged()), Qt::UniqueConnection);\r\n\tconnect(&details_, SIGNAL(contentChanged()), this, SIGNAL(contentChanged()), Qt::UniqueConnection);\r\n\tconnect(&parameters_, SIGNAL(contentChanged()), this, SIGNAL(contentChanged()), Qt::UniqueConnection);\r\n\r\n\tconnect(&busType_, SIGNAL(setAbsDef(const VLNV&)), this, SLOT(onSetAbsType(const VLNV&)), Qt::UniqueConnection);\r\n    connect(abstractionEditor_, SIGNAL(contentChanged()), this, SIGNAL(contentChanged()), Qt::UniqueConnection);\r\n\r\n\tbusType_.setTitle(tr(\"Bus definition\"));\r\n\r\n    setupLayout();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: busifgeneraltab::onNameChanged()\r\n//-----------------------------------------------------------------------------\r\nvoid BusIfGeneralTab::onNameChanged()\r\n{\r\n    std::string newName = nameEditor_.name().toStdString();\r\n    details_.changeName(newName);\r\n    modeStack_.nameChanged(newName);\r\n\r\n    emit nameChanged(newName);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusIfGeneralTab::refresh()\r\n//-----------------------------------------------------------------------------\r\nvoid BusIfGeneralTab::refresh()\r\n{\r\n    onNameChanged();\r\n    std::string currentName = nameEditor_.name().toStdString();\r\n\r\n\tnameEditor_.refresh();\r\n    busType_.setVLNV(busInterface_->getBusType(currentName));\r\n\r\n    busInterface_->setupSubInterfaces(currentName);\r\n\r\n    abstractionEditor_->refresh();\r\n\tmodeStack_.refresh();\r\n\tdetails_.refresh();\r\n\tparameters_.refresh();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusIfGeneralTab::isValid()\r\n//-----------------------------------------------------------------------------\r\nVLNV BusIfGeneralTab::getBusType() const\r\n{\r\n\treturn busType_.getVLNV();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusIfGeneralTab::onBusTypeChanged()\r\n//-----------------------------------------------------------------------------\r\nvoid BusIfGeneralTab::onBusTypeChanged()\r\n{\r\n    busInterface_->setBustype(nameEditor_.name().toStdString(), busType_.getVLNV());\r\n\r\n    modeStack_.refresh();\r\n\r\n\temit contentChanged();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusIfGeneralTab::setBusTypesLocked()\r\n//-----------------------------------------------------------------------------\r\nvoid BusIfGeneralTab::setBusTypesLock(bool locked)\r\n{\r\n    busType_.setEnabled(!locked);\r\n    abstractionEditor_->setEnabled(!locked);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusIfGeneralTab::onModeChanged()\r\n//-----------------------------------------------------------------------------\r\nvoid BusIfGeneralTab::onModeChanged(General::InterfaceMode mode)\r\n{\r\n\tmodeStack_.setMode(mode);\r\n\temit contentChanged();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusIfGeneralTab::showEvent()\r\n//-----------------------------------------------------------------------------\r\nvoid BusIfGeneralTab::showEvent(QShowEvent* event)\r\n{\r\n\tQWidget::showEvent(event);\r\n    if (docRevision_ == Document::Revision::Std14)\r\n    {\r\n        emit helpUrlRequested(\"componenteditor/businterfacegeneral.html\");\r\n    }\r\n    else if (docRevision_ == Document::Revision::Std22)\r\n    {\r\n        emit helpUrlRequested(\"componenteditor/businterfacegeneral2022.html\");\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusIfGeneralTab::onSetBusType()\r\n//-----------------------------------------------------------------------------\r\nvoid BusIfGeneralTab::onSetBusType(VLNV const& busDefVLNV)\r\n{\r\n    busInterface_->setBustype(nameEditor_.name().toStdString(), busType_.getVLNV());\r\n\r\n\tbusType_.setVLNV(busDefVLNV);\r\n\temit contentChanged();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusIfGeneralTab::onSetAbsType()\r\n//-----------------------------------------------------------------------------\r\nvoid BusIfGeneralTab::onSetAbsType(VLNV const& absDefVLNV)\r\n{\r\n    if (busInterface_->getAbstractionTypeInterface()->itemCount() == 0)\r\n    {\r\n        abstractionEditor_->addNewAbstraction(absDefVLNV);\r\n    }\r\n\r\n    emit contentChanged();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusIfGeneralTab::setupLayout()\r\n//-----------------------------------------------------------------------------\r\nvoid BusIfGeneralTab::setupLayout()\r\n{\r\n    QScrollArea* scrollArea = new QScrollArea(this);\r\n    scrollArea->setWidgetResizable(true);\r\n    scrollArea->setFrameShape(QFrame::NoFrame);\r\n\r\n    QHBoxLayout* scrollLayout = new QHBoxLayout(this);\r\n    scrollLayout->addWidget(scrollArea);\r\n    scrollLayout->setContentsMargins(0, 0, 0, 0);\r\n\r\n    // create the top widget and set it under the scroll area\r\n    QWidget* topWidget = new QWidget(scrollArea);\r\n    topWidget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);\r\n\r\n    QGridLayout* topLayout = new QGridLayout(topWidget);\r\n\r\n    topLayout->addWidget(&nameEditor_, 0, 0, 1, 1);\r\n    topLayout->addWidget(&busType_, 0, 1, 1, 1, Qt::AlignTop);\r\n    topLayout->addWidget(&details_, 1, 0, 1, 1);\r\n    topLayout->addWidget(abstractionEditor_, 1, 1, 2, 1);\r\n    topLayout->addWidget(&modeStack_, 2, 0, 1, 1);\r\n    topLayout->addWidget(&parameters_, 3, 0, 1, 2);\r\n\r\n    topLayout->setColumnStretch(0, 1);\r\n    topLayout->setColumnStretch(1, 1);\r\n\r\n    topLayout->setRowStretch(0, 5);\r\n    topLayout->setRowStretch(1, 1);\r\n    topLayout->setRowStretch(2, 5);\r\n    topLayout->setRowStretch(3, 10);\r\n\r\n    scrollArea->setWidget(topWidget);\r\n}\r\n"
  },
  {
    "path": "editors/ComponentEditor/busInterfaces/general/busifgeneraltab.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: busifgeneraltab.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 05.04.2011\r\n//\r\n// Description:\r\n// Container for editor on the general tab of a bus interface editor.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef BUSIFGENERALTAB_H\r\n#define BUSIFGENERALTAB_H\r\n\r\n#include \"busifgeneraldetails.h\"\r\n#include \"interfacemodestack.h\"\r\n\r\n#include <editors/common/ExpressionSet.h>\r\n\r\n#include <common/widgets/nameGroupEditor/namegroupeditor.h>\r\n#include <common/widgets/vlnvEditor/vlnveditor.h>\r\n#include <common/widgets/ParameterGroupBox/parametergroupbox.h>\r\n\r\n#include <KactusAPI/include/ParameterFinder.h>\r\n#include <KactusAPI/include/ExpressionFormatter.h>\r\n#include <KactusAPI/include/ExpressionParser.h>\r\n\r\n#include <QWidget>\r\n#include <QSharedPointer>\r\n\r\nclass BusInterface;\r\nclass Component;\r\nclass LibraryInterface;\r\nclass AbstractionTypesEditor;\r\nclass BusInterfaceInterface;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Container for editor on the general tab of a bus interface editor.\r\n//-----------------------------------------------------------------------------\r\nclass BusIfGeneralTab : public QWidget\r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\r\n\t/*!\r\n\t *  The constructor.\r\n\t *\r\n\t *    @param [in] libHandler              Pointer to the instance that manages the library.\r\n\t *    @param [in] busif                   Pointer to the bus interface being edited.\r\n\t *    @param [in] component               Pointer to the component being edited.\r\n\t *    @param [in] parameterFinder         Pointer to the parameter finder.\r\n\t *    @param [in] expressionFormatter     Pointer to the expression formatter.\r\n     *    @param [in] expressionParser        Pointer to the expression parser.\r\n     *    @param [in] busInterface            Interface for accessing bus interfaces.\r\n     *    @param [in] busName                 Name of the edited bus interface.\r\n\t *    @param [in] parent                  Pointer to the owner of this editor.\r\n\t *    @param [in] parentWnd               Pointer to the parent window.\r\n\t */\r\n    BusIfGeneralTab(LibraryInterface* libHandler,\r\n        QSharedPointer<BusInterface> busif,\r\n        QSharedPointer<Component> component,\r\n        ExpressionSet expressions,\r\n        BusInterfaceInterface* busInterface,\r\n        std::string const& busName,\r\n        QWidget* parent,\r\n        QWidget* parentWnd);\r\n\r\n\t/*!\r\n     *  The destructor.\r\n     */\r\n\tvirtual ~BusIfGeneralTab() = default;\r\n\r\n\t/*!\r\n     *  Restore the changes made in the editor back to ones in the model.\r\n\t */\r\n\tvirtual void refresh();\r\n\r\n\t/*!\r\n     *  Get the currently set bus type.\r\n\t *\r\n\t *    @return VLNV that is set for the current bus type.\r\n\t */\r\n\tVLNV getBusType() const;\r\n\r\n    /*!\r\n     *  Locks/unlocks the VLNV selection for bus definition and abstraction definition.\r\n     *\r\n     *    @param [in] locked   The lock to set.\r\n     */\r\n    void setBusTypesLock( bool locked );\r\n\r\nsignals:\r\n\r\n\t/*!\r\n     *  Emitted when contents of the model change\r\n     */\r\n\tvoid contentChanged();\r\n\r\n\t/*!\r\n     *  Prints an error message to the user.\r\n     */\r\n\tvoid errorMessage(const QString& msg) const;\r\n\r\n\t/*!\r\n     *  Prints a notification to user.\r\n     */\r\n\tvoid noticeMessage(const QString& msg) const;\r\n\r\n\t/*!\r\n     *  Emitted when a help page should be changed in the context help window.\r\n     */\r\n\tvoid helpUrlRequested(QString const& url);\r\n\r\n    /*!\r\n     *  Increase the amount of references to the parameter corresponding to the id.\r\n     *\r\n     *    @param [in] id      The id of the parameter being searched for.\r\n     */\r\n    void increaseReferences(QString id);\r\n\r\n    /*!\r\n     *  Decrease the amount of references to the parameter corresponding to the id.\r\n     *\r\n     *    @param [in] id      The id of the parameter being searched for.\r\n     */\r\n    void decreaseReferences(QString id);\r\n\r\n    /*!\r\n     *  Open the reference tree of the parameter corresponding to the ID.\r\n     *\r\n     *    @param [in] ID              The ID of the selected parameter.\r\n     *    @param [in] parameterName   Name of the selected parameter.\r\n     */\r\n    void openReferenceTree(QString const& id, QString const& parameterName) const;\r\n\r\n    /*!\r\n     *  Recalculate references made to the selected parameters.\r\n     *\r\n     *    @param [in] parameterList       The selected parameters.\r\n     *    @param [in] parameterInterface  Interface for accessing parameters.\r\n     */\r\n    void recalculateReferencesToParameters(QVector<QString> const& parameterList,\r\n        AbstractParameterInterface* parameterInterface);\r\n\r\n    /*!\r\n     *  Inform of the name change in the edited bus interface.\r\n     *\r\n     *    @param [in] newName     New name of the bus interface.\r\n     */\r\n    void nameChanged(std::string const& newName);\r\n\r\npublic slots:\r\n\r\n    /*!\r\n     *  Handle the change in name of the edited bus interface.\r\n     */\r\n    void onNameChanged();\r\n\r\nprotected:\r\n\r\n\t/*!\r\n     *  Handler for widget's show event\r\n     */\r\n\tvirtual void showEvent(QShowEvent* event);\r\n\r\nprivate slots:\r\n\r\n\t/*!\r\n     *  Handler for changes in the bus type.\r\n     */\r\n\tvoid onBusTypeChanged();\r\n\r\n\t/*!\r\n     *  Handler for changes in interface mode.\r\n     */\r\n\tvoid onModeChanged(General::InterfaceMode mode);\r\n\r\n\t/*!\r\n     *  Set the bus type for the bus interface.\r\n\t *\r\n\t *    @param [in] busDefVLNV The vlnv identifying the bus type.\r\n\t */\r\n\tvoid onSetBusType(const VLNV& busDefVLNV);\r\n\r\n\t/*!\r\n     *  Set the abstraction type for the bus interface.\r\n\t *\r\n\t *    @param [in] absDefVLNV The vlnv identifying the abstraction definition.\r\n\t */\r\n\tvoid onSetAbsType(const VLNV& absDefVLNV);\r\n\r\nprivate:\r\n\r\n\t//! No copying\r\n\tBusIfGeneralTab(const BusIfGeneralTab& other);\r\n\r\n\t//! No assignment\r\n\tBusIfGeneralTab& operator=(const BusIfGeneralTab& other);\r\n\r\n    //! Sets the widget layout.\r\n    void setupLayout();\r\n\r\n    //-----------------------------------------------------------------------------\r\n    //! Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! Interface for accessing bus interfaces.\r\n    BusInterfaceInterface* busInterface_;\r\n\r\n\t//! Contains the name, display name and description of bus interface.\r\n\tNameGroupEditor nameEditor_;\r\n\r\n\t//! Contains the vlnv of the bus type for this bus interface.\r\n\tVLNVEditor busType_;\r\n\r\n\t//! Contains the vlnv of the abstraction types for this interface.\r\n    AbstractionTypesEditor* abstractionEditor_;\r\n\r\n\t//! Contains the mode-specific editors.\r\n\tInterfaceModeStack modeStack_;\r\n\r\n\t//! Contains the details of this bus interface.\r\n\tBusIfGeneralDetails details_;\r\n\r\n\t//! Contains the parameters of bus interface.\r\n\tParameterGroupBox parameters_;\r\n\r\n\t//! Pointer to the instance that manages the library.\r\n\tLibraryInterface* libHandler_;\r\n\r\n    //! The used IP-XACT revision.\r\n    Document::Revision docRevision_;\r\n};\r\n\r\n#endif // BUSIFGENERALTAB_H\r\n"
  },
  {
    "path": "editors/ComponentEditor/busInterfaces/general/interfacemodestack.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: interfacemodestack.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 20.06.2012\r\n//\r\n// Description:\r\n// Container for editor on the general tab of a bus interface editor.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"interfacemodestack.h\"\r\n\r\n#include <IPXACTmodels/Component/BusInterface.h>\r\n#include <IPXACTmodels/Component/Component.h>\r\n\r\n#include <KactusAPI/include/ExpressionParser.h>\r\n#include <KactusAPI/include/BusInterfaceInterface.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: interfacemodestack::InterfaceModeStack()\r\n//-----------------------------------------------------------------------------\r\nInterfaceModeStack::InterfaceModeStack(BusInterfaceInterface* busInterface, std::string const& busName,\r\n    QSharedPointer<Component> component, QSharedPointer<ParameterFinder> parameterFinder,\r\n    LibraryInterface* handler, QSharedPointer<ExpressionParser> expressionParser, QWidget* parent) :\r\n    QStackedWidget(parent),\r\n    busInterface_(busInterface),\r\n    busName_(busName),\r\n    master_(busInterface_, busName_, component, parameterFinder, expressionParser, this),\r\n    slave_(busInterface_, busName_, component->getRevision(), this),\r\n    initiator_(busInterface_, busName_, component, parameterFinder, expressionParser, this),\r\n    target_(busInterface_, busName_, component->getRevision(), this),\r\n    system_(busInterface_, busName_, handler, this),\r\n    mirroredMaster_(busInterface_, busName_, this),\r\n    mirroredSlave_(busInterface_, busName_, parameterFinder, expressionParser, this),\r\n    mirroredInitiator_(busInterface_, busName_, this),\r\n    mirroredTarget_(busInterface_, busName_, parameterFinder, expressionParser, this),\r\n    mirroredSystem_(busInterface_, busName_, handler, this),\r\n    monitor_(busInterface_, busName_, component->getRevision(), handler, this)\r\n{\r\n    Q_ASSERT(component);\r\n    Q_ASSERT(parent);\r\n\r\n    insertWidget(General::MASTER, &master_);\r\n\tinsertWidget(General::SLAVE, &slave_);\r\n    insertWidget(General::INITIATOR, &initiator_);\r\n    insertWidget(General::TARGET, &target_);\r\n\tinsertWidget(General::SYSTEM, &system_);\r\n\tinsertWidget(General::MIRRORED_MASTER, &mirroredMaster_);\r\n\tinsertWidget(General::MIRRORED_SLAVE, &mirroredSlave_);\r\n    insertWidget(General::MIRRORED_INITIATOR, &mirroredInitiator_);\r\n    insertWidget(General::MIRRORED_TARGET, &mirroredTarget_);\r\n\tinsertWidget(General::MIRRORED_SYSTEM, &mirroredSystem_);\r\n\tinsertWidget(General::MONITOR, &monitor_);\r\n    insertWidget(General::INTERFACE_MODE_COUNT, new QGroupBox(tr(\"Interface mode specific options\"), this));\r\n\r\n    connect(&master_, SIGNAL(contentChanged()),\r\n\t\tthis, SIGNAL(contentChanged()), Qt::UniqueConnection);\r\n\tconnect(&slave_, SIGNAL(contentChanged()),\r\n        this, SIGNAL(contentChanged()), Qt::UniqueConnection);\r\n    connect(&initiator_, SIGNAL(contentChanged()),\r\n        this, SIGNAL(contentChanged()), Qt::UniqueConnection);\r\n    connect(&target_, SIGNAL(contentChanged()),\r\n        this, SIGNAL(contentChanged()), Qt::UniqueConnection);\r\n\tconnect(&system_, SIGNAL(contentChanged()),\r\n\t\tthis, SIGNAL(contentChanged()), Qt::UniqueConnection);\r\n\tconnect(&mirroredMaster_, SIGNAL(contentChanged()),\r\n        this, SIGNAL(contentChanged()), Qt::UniqueConnection);\r\n    connect(&mirroredSlave_, SIGNAL(contentChanged()),\r\n        this, SIGNAL(contentChanged()), Qt::UniqueConnection);\r\n    connect(&mirroredInitiator_, SIGNAL(contentChanged()),\r\n        this, SIGNAL(contentChanged()), Qt::UniqueConnection);\r\n    connect(&mirroredTarget_, SIGNAL(contentChanged()),\r\n        this, SIGNAL(contentChanged()), Qt::UniqueConnection);\r\n    connect(&mirroredSystem_, SIGNAL(contentChanged()),\r\n        this, SIGNAL(contentChanged()), Qt::UniqueConnection);\r\n\tconnect(&monitor_, SIGNAL(contentChanged()),\r\n\t\tthis, SIGNAL(contentChanged()), Qt::UniqueConnection);\r\n\r\n    connect(&mirroredSlave_, SIGNAL(increaseReferences(QString)),\r\n        this, SIGNAL(increaseReferences(QString)), Qt::UniqueConnection);\r\n    connect(&mirroredSlave_, SIGNAL(decreaseReferences(QString)),\r\n        this, SIGNAL(decreaseReferences(QString)), Qt::UniqueConnection);\r\n    connect(&mirroredTarget_, SIGNAL(increaseReferences(QString)),\r\n        this, SIGNAL(increaseReferences(QString)), Qt::UniqueConnection);\r\n    connect(&mirroredTarget_, SIGNAL(decreaseReferences(QString)),\r\n        this, SIGNAL(decreaseReferences(QString)), Qt::UniqueConnection);\r\n\r\n    connect(&master_, SIGNAL(increaseReferences(QString)),\r\n        this, SIGNAL(increaseReferences(QString)), Qt::UniqueConnection);\r\n    connect(&master_, SIGNAL(decreaseReferences(QString)),\r\n        this, SIGNAL(decreaseReferences(QString)), Qt::UniqueConnection);\r\n    connect(&initiator_, SIGNAL(increaseReferences(QString)),\r\n        this, SIGNAL(increaseReferences(QString)), Qt::UniqueConnection);\r\n    connect(&initiator_, SIGNAL(decreaseReferences(QString)),\r\n        this, SIGNAL(decreaseReferences(QString)), Qt::UniqueConnection);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: interfacemodestack::setMode()\r\n//-----------------------------------------------------------------------------\r\nvoid InterfaceModeStack::setMode( General::InterfaceMode mode )\r\n{\r\n    General::InterfaceMode currentMode = busInterface_->getMode(busName_);\r\n    if (currentMode == General::MIRRORED_SLAVE)\r\n    {\r\n        mirroredSlave_.removeReferencesFromExpressions();\r\n    }\r\n    else if (currentMode == General::MASTER)\r\n    {\r\n        master_.removeReferencesFromExpressions();\r\n    }\r\n    else if (currentMode == General::MIRRORED_TARGET)\r\n    {\r\n        mirroredTarget_.removeReferencesFromExpressions();\r\n    }\r\n    else if (currentMode == General::INITIATOR)\r\n    {\r\n        initiator_.removeReferencesFromExpressions();\r\n    }\r\n\r\n    std::string newMode = General::interfaceMode2Str(mode).toStdString();\r\n\r\n    busInterface_->setMode(busName_, newMode);\r\n\r\n\trefresh();\r\n\r\n\temit contentChanged();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: interfacemodestack::refresh()\r\n//-----------------------------------------------------------------------------\r\nvoid InterfaceModeStack::refresh()\r\n{\r\n    General::InterfaceMode currentMode = busInterface_->getMode(busName_);\r\n\r\n    // select the correct editor\r\n    setCurrentIndex(currentMode);\r\n\r\n    auto editor = qobject_cast<ModeEditorBase*>(widget(currentMode));\r\n\r\n    if (editor)\r\n    {\r\n        editor->refresh();\r\n        editor->saveModeSpecific();\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: interfacemodestack::nameChanged()\r\n//-----------------------------------------------------------------------------\r\nvoid InterfaceModeStack::nameChanged(std::string const& newName)\r\n{\r\n    busName_ = newName;\r\n    master_.changeName(newName);\r\n    slave_.changeName(newName);\r\n    initiator_.changeName(newName);\r\n    target_.changeName(newName);\r\n    system_.changeName(newName);\r\n    mirroredMaster_.changeName(newName);\r\n    mirroredSlave_.changeName(newName);\r\n    mirroredInitiator_.changeName(newName);\r\n    mirroredTarget_.changeName(newName);\r\n    mirroredSystem_.changeName(newName);\r\n    monitor_.changeName(newName);\r\n}\r\n"
  },
  {
    "path": "editors/ComponentEditor/busInterfaces/general/interfacemodestack.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: interfacemodestack.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 20.06.2012\r\n//\r\n// Description:\r\n// Container for editor on the general tab of a bus interface editor.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef INTERFACEMODESTACK_H\r\n#define INTERFACEMODESTACK_H\r\n\r\n#include \"MasterModeEditor.h\"\r\n#include \"MirroredMasterModeEditor.h\"\r\n#include \"SlaveModeEditor.h\"\r\n#include \"MirroredSlaveModeEditor.h\"\r\n#include \"InitiatorModeEditor.h\"\r\n#include \"MirroredInitiatorModeEditor.h\"\r\n#include \"TargetModeEditor.h\"\r\n#include \"MirroredTargetModeEditor.h\"\r\n#include \"MonitorModeEditor.h\"\r\n#include \"SystemModeEditor.h\"\r\n\r\n#include <IPXACTmodels/generaldeclarations.h>\r\n\r\n#include <KactusAPI/include/ParameterFinder.h>\r\n\r\n#include <QStackedWidget>\r\n#include <QSharedPointer>\r\n\r\nclass BusInterface;\r\nclass Component;\r\nclass BusIfGeneralTab;\r\nclass ExpressionParser;\r\nclass BusInterfaceInterface;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! This widget stack contains the different editors to edit interface mode specific details of bus interface.\r\n//-----------------------------------------------------------------------------\r\nclass InterfaceModeStack : public QStackedWidget\r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\r\n    /*!\r\n\t *  The constructor.\r\n\t *\r\n\t *    @param [in] busInterface        Interface for accessing bus interfaces.\r\n     *    @param [in] busName             Name of the edited bus interface.\r\n\t *    @param [in] component           The component being edited.\r\n\t *    @param [in] parameterFinder     The parameter finder.\r\n\t *    @param [in] handler             The instance that manages the library.\r\n\t *    @param [in] expressionParser    The expression parser.\r\n\t *    @param [in] parent              The owner of this stack.\r\n\t */\r\n    InterfaceModeStack(BusInterfaceInterface* busInterface,\r\n        std::string const& busName,\r\n        QSharedPointer<Component> component,\r\n        QSharedPointer<ParameterFinder> parameterFinder,\r\n        LibraryInterface* handler,\r\n        QSharedPointer<ExpressionParser> expressionParser,\r\n        QWidget* parent);\r\n\r\n\t/*!\r\n     *  The destructor.\r\n     */\r\n\tvirtual ~InterfaceModeStack() = default;\r\n\r\n\t/*!\r\n     *  Refresh the contents of the stack's editors.\r\n     */\r\n\tvoid refresh();\r\n\r\n    /*!\r\n     *  Change the name of the edited bus interface.\r\n     *\r\n     *    @param [in] newName     New name of the edited bus interface.\r\n     */\r\n    void nameChanged(std::string const& newName);\r\n\r\npublic slots:\r\n\r\n\t/*!\r\n     *  Select the correct editor for the given interface mode.\r\n\t *\r\n\t *    @param [in] mode The mode for the bus interface.\r\n     */\r\n\tvoid setMode(General::InterfaceMode mode);\r\n\r\nsignals:\r\n\r\n\t/*!\r\n     *  Emitted when the state of one of the editors change.\r\n     */\r\n\tvoid contentChanged();\r\n\r\n    /*!\r\n     *  Increase the number of references made to the selected parameter.\r\n     *\r\n     *    @param [in] id      The id of the selected parameter.\r\n     */\r\n    void increaseReferences(QString const& id);\r\n\r\n    /*!\r\n     *  Decrease the number of references made to the selected parameter.\r\n     *\r\n     *    @param [in] id      The id of the selected parameter.\r\n     */\r\n    void decreaseReferences(QString const& id);\r\n\r\nprivate:\r\n\t\r\n    //! No copying. No assignment.\r\n\tInterfaceModeStack(const InterfaceModeStack& other);\r\n\tInterfaceModeStack& operator=(const InterfaceModeStack& other);\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n\t//! Interface for accessing bus interfaces.\r\n    BusInterfaceInterface* busInterface_;\r\n\r\n    //! Name of the edited bus interface.\r\n    std::string busName_;\r\n\r\n    //! The master interface.\r\n\tMasterModeEditor master_;\r\n\r\n    //! The slave interface.\r\n\tSlaveModeEditor slave_;\r\n\r\n    //! The initiator interface.\r\n    InitiatorModeEditor initiator_;\r\n\r\n    //! The target interface.\r\n    TargetModeEditor target_;\r\n\r\n    //! The system interface.\r\n\tSystemModeEditor system_;\r\n\r\n    //! The mirrored master interface.\r\n    MirroredMasterModeEditor mirroredMaster_;\r\n\r\n    //! The mirrored slave interface.\r\n\tMirroredSlaveModeEditor mirroredSlave_;\r\n\r\n    //! The mirrored initiator interface.\r\n    MirroredInitiatorModeEditor mirroredInitiator_;\r\n\r\n    //! The mirrored tarGet interface.\r\n    MirroredTargetModeEditor mirroredTarget_;\r\n\r\n    //! The mirrored system interface.\r\n\tSystemModeEditor mirroredSystem_;\r\n\r\n    //! The monitor interface.\r\n\tMonitorModeEditor monitor_;\r\n};\r\n\r\n#endif // INTERFACEMODESTACK_H\r\n"
  },
  {
    "path": "editors/ComponentEditor/busInterfaces/portmaps/BusInterfacePortMapTab.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: BusInterfacePortMapTab.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Mikko Teuho\r\n// Date: 23.05.2016\r\n//\r\n// Description:\r\n// Tab for editing and viewing bus interface port maps.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"BusInterfacePortMapTab.h\"\r\n\r\n#include <editors/ComponentEditor/parameters/ComponentParameterModel.h>\r\n#include <KactusAPI/include/BusInterfaceInterface.h>\r\n#include <KactusAPI/include/AbstractionTypeInterface.h>\r\n#include <editors/ComponentEditor/busInterfaces/portmaps/PortMapDelegate.h>\r\n#include <editors/ComponentEditor/busInterfaces/portmaps/PortMapHeaderView.h>\r\n#include <editors/ComponentEditor/busInterfaces/portmaps/PortMapsColumns.h>\r\n#include <KactusAPI/include/PortMapInterface.h>\r\n\r\n#include <KactusAPI/include/LibraryInterface.h>\r\n\r\n#include <IPXACTmodels/common/VLNV.h>\r\n#include <IPXACTmodels/Component/Component.h>\r\n#include <IPXACTmodels/Component/BusInterface.h>\r\n#include <IPXACTmodels/Component/PortMap.h>\r\n#include <IPXACTmodels/AbstractionDefinition/AbstractionDefinition.h>\r\n\r\n#include <QCompleter>\r\n#include <QSplitter>\r\n#include <QSharedPointer>\r\n#include <QVBoxLayout>\r\n#include <QHBoxLayout>\r\n#include <QLabel>\r\n#include <QGroupBox>\r\n#include <QFormLayout>\r\n#include <QMenu>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusInterfacePortMapTab::BusInterfacePortMapTab()\r\n//-----------------------------------------------------------------------------\r\nBusInterfacePortMapTab::BusInterfacePortMapTab(LibraryInterface* libHandler, QSharedPointer<Component> component,\r\n    BusInterfaceInterface* busInterface, std::string const& busName,\r\n    QSharedPointer<ExpressionParser> expressionParser, QSharedPointer<ParameterFinder> finder,\r\n    PortMapInterface* portMapInterface, QWidget* parent):\r\nQWidget(parent),\r\nbusInterface_(busInterface),\r\nbusName_(busName),\r\ncomponent_(component),\r\nlibHandler_(libHandler),\r\nphysicalPortView_(this),\r\nphysicalPortModel_(portMapInterface->getPhysicalPortInterface(), this),\r\nphysicalPortSorter_(0, portMapInterface, busInterface->getAbstractionTypeInterface(), this),\r\nnameFilterEditor_(new QLineEdit(this)),\r\ntypeFilter_(this),\r\ndirectionFilter_(this),\r\nhideConnectedPortsBox_(this),\r\nphysicalPrefixEditor_(new QLineEdit(this)),\r\nportMapModel_(finder, portMapInterface, this),\r\nportMapSorter_(portMapInterface, this),\r\nportMapView_(portMapInterface, this),\r\nportMapDelegate_(0),\r\nautoConnectButton_(QIcon(\":/icons/common/graphics/connect.png\"), \"Auto connect all\", this),\r\nremoveAllMappingsButton_(QIcon(\":/icons/common/graphics/delete.png\"), \"Remove all\", this),\r\nautoConnector_(portMapInterface, this),\r\nabstractionSelector_(new QComboBox(this))\r\n{\r\n    hideConnectedPortsBox_.setCheckState(Qt::Checked);\r\n\r\n    physicalPortSorter_.setSourceModel(&physicalPortModel_);\r\n    physicalPortView_.setModel(&physicalPortSorter_);\r\n\r\n    portMapSorter_.setSourceModel(&portMapModel_);\r\n    portMapView_.setModel(&portMapSorter_);\r\n    portMapView_.sortByColumn(PortMapsColumns::LOGICAL_PORT, Qt::AscendingOrder);\r\n\r\n    ComponentParameterModel* componentParametersModel = new ComponentParameterModel(finder, this);\r\n    componentParametersModel->setExpressionParser(expressionParser);\r\n\r\n    QStringList portNames = component_->getPortNames();\r\n\r\n    portMapDelegate_ = new PortMapDelegate(componentParametersModel, finder, portMapInterface, this);\r\n\r\n    connect(portMapDelegate_, SIGNAL(increaseReferences(QString)),\r\n        this, SIGNAL(increaseReferences(QString)), Qt::UniqueConnection);\r\n    connect(portMapDelegate_, SIGNAL(decreaseReferences(QString)),\r\n        this, SIGNAL(decreaseReferences(QString)), Qt::UniqueConnection);\r\n\r\n    portMapView_.setItemDelegate(portMapDelegate_);\r\n    portMapView_.resizeColumnsToContents();\r\n    portMapView_.setDisabled(true);\r\n\r\n\tsetupLayout();\r\n\r\n    nameFilterEditor_->setToolTip(tr(\"Filter ports by name\"));\r\n    setTabOrder(nameFilterEditor_, &physicalPortView_);\r\n\r\n    setupTypeFilter();\r\n    addItemsToDirectionFilter();\r\n\r\n    connectItems();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusInterfacePortMapTab::setupTypeFilter()\r\n//-----------------------------------------------------------------------------\r\nvoid BusInterfacePortMapTab::setupTypeFilter()\r\n{\r\n    typeFilter_.addItem(PortTypes::WIRETYPE);\r\n    typeFilter_.addItem(PortTypes::TRANSACTIONALTYPE);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusInterfacePortMapTab::addItemsToDirectionFilter()\r\n//-----------------------------------------------------------------------------\r\nvoid BusInterfacePortMapTab::addItemsToDirectionFilter()\r\n{\r\n    QList<QPair<QString, QString> > const directions{ \r\n        {\"in\", \":icons/common/graphics/input.png\"},\r\n        {\"out\", \":icons/common/graphics/output.png\"},\r\n        {\"inout\", \":icons/common/graphics/inout.png\"}\r\n    };\r\n\r\n    directionFilter_.addItem(\"\");\r\n\r\n    for (auto const& [direction, iconPath] : directions)\r\n    {\r\n        directionFilter_.addItem(QIcon(iconPath), direction);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusInterfacePortMapTab::refresh()\r\n//-----------------------------------------------------------------------------\r\nvoid BusInterfacePortMapTab::refresh()\r\n{\r\n    setupAbstraction();\r\n\r\n    busInterface_->setupSubInterfaces(busName_);\r\n\r\n    physicalPortModel_.refresh();\r\n    portMapModel_.refresh();\r\n\r\n    physicalPortSorter_.onConnectionsReset();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusInterfacePortMapTab::setAbstractionDefinitions()\r\n//-----------------------------------------------------------------------------\r\nvoid BusInterfacePortMapTab::setAbstractionDefinitions()\r\n{\r\n    QString currentAbstraction = abstractionSelector_->currentText();\r\n\r\n    abstractionSelector_->clear();\r\n\r\n    busInterface_->setupSubInterfaces(busName_);\r\n\r\n    auto abstractionInterface = busInterface_->getAbstractionTypeInterface();\r\n    int abstractionCount = abstractionInterface->itemCount();\r\n    if (abstractionCount > 0)\r\n    {\r\n        int currentIndex = 0;\r\n        for (int i = 0; i < abstractionCount; ++i)\r\n        {\r\n            if (abstractionInterface->hasAbstractionReference(i))\r\n            {\r\n                QString abstractionReference =\r\n                    QString::fromStdString(abstractionInterface->getIndexedAbstraction(i));\r\n\r\n                abstractionSelector_->addItem(abstractionReference);\r\n\r\n                if (!currentAbstraction.isEmpty() && abstractionReference == currentAbstraction)\r\n                {\r\n                    currentIndex = i;\r\n                }\r\n            }\r\n        }\r\n\r\n        if (abstractionCount > 0)\r\n        {\r\n            abstractionSelector_->setCurrentIndex(currentIndex);\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusInterfacePortMapTab::onAbstractionChanged()\r\n//-----------------------------------------------------------------------------\r\nvoid BusInterfacePortMapTab::onAbstractionChanged()\r\n{\r\n    setupAbstraction();\r\n\r\n    refresh();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusInterfacePortMapTab::setupAbstraction()\r\n//-----------------------------------------------------------------------------\r\nvoid BusInterfacePortMapTab::setupAbstraction()\r\n{\r\n    int currentAbstractionIndex = abstractionSelector_->currentIndex();\r\n    setAbsType(currentAbstractionIndex);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusInterfacePortMapTab::setAbsType()\r\n//-----------------------------------------------------------------------------\r\nvoid BusInterfacePortMapTab::setAbsType(int const& abstractionIndex)\r\n{\r\n    AbstractionTypeInterface* abstractionInterface = busInterface_->getAbstractionTypeInterface();\r\n    General::InterfaceMode busMode = busInterface_->getMode(busName_);\r\n    QString systemGroup = QString::fromStdString(busInterface_->getSystemGroup(busName_));\r\n\r\n    if (busMode == General::MONITOR)\r\n    {\r\n        General::InterfaceMode monitorMode = busInterface_->getMonitorMode(busName_);\r\n        if (monitorMode != General::INTERFACE_MODE_COUNT)\r\n        {\r\n            busMode = monitorMode;\r\n            systemGroup = QString::fromStdString(busInterface_->getMonitorGroup(busName_));\r\n        }\r\n    }\r\n\r\n    VLNV definitionVLNV;\r\n    if (abstractionInterface->hasAbstractionReference(abstractionIndex))\r\n    {\r\n        definitionVLNV = *abstractionInterface->getAbstractionReference(abstractionIndex).data();\r\n    }\r\n\r\n    physicalPortSorter_.setNewAbstractionType(abstractionIndex);\r\n\r\n    QSharedPointer<Document const> absDefDocument = libHandler_->getModelReadOnly(definitionVLNV);\r\n    if (absDefDocument && libHandler_->getDocumentType(definitionVLNV) == VLNV::ABSTRACTIONDEFINITION)\r\n    {\r\n        QSharedPointer<AbstractionDefinition const> abstractionDefinition =\r\n            absDefDocument.dynamicCast<AbstractionDefinition const>();\r\n\r\n        PortMapInterface* portMapInterface = abstractionInterface->getPortMapInterface();\r\n        portMapInterface->setupAbstractionDefinition(abstractionDefinition);\r\n        portMapInterface->setupPortMaps(abstractionInterface->getAbstraction(abstractionIndex));\r\n        portMapInterface->setupBusMode(busMode);\r\n        portMapInterface->setupSystemGroup(systemGroup);\r\n        portMapInterface->setupPhysicalPorts(component_->getPorts());\r\n\r\n        portMapDelegate_->setBusMode(busMode);\r\n        portMapDelegate_->setSystemGroup(systemGroup);\r\n        portMapView_.setEnabled(true);\r\n    }\r\n    else\r\n    {\r\n        portMapView_.setDisabled(true);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusInterfacePortMapTab::setPhysicalPorts()\r\n//-----------------------------------------------------------------------------\r\nvoid BusInterfacePortMapTab::setPhysicalPorts(QStringList const& ports)\r\n{\r\n    nameFilterEditor_->setText(ports.join('|'));\r\n\r\n    refresh();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusInterfacePortMapTab::setupLayout()\r\n//-----------------------------------------------------------------------------\r\nvoid BusInterfacePortMapTab::setupLayout()\r\n{\r\n    QFormLayout* filterLayout = new QFormLayout(this);\r\n    filterLayout->addRow(\"Name:\", nameFilterEditor_);\r\n    filterLayout->addRow(\"Type:\", &typeFilter_);\r\n    filterLayout->addRow(\"Direction:\", &directionFilter_);\r\n    filterLayout->addRow(\"Hide connected:\", &hideConnectedPortsBox_);\r\n\r\n    QGroupBox* filterBox = new QGroupBox(tr(\"Physical port filters\"), this);\r\n    filterBox->setLayout(filterLayout);\r\n\r\n    QGroupBox* autoconnectBox = new QGroupBox(tr(\"Auto connect options\"), this);\r\n    QGridLayout* functionLayout = new QGridLayout(autoconnectBox);\r\n    functionLayout->addWidget(new QLabel(tr(\"Physical port prefix:\"), this), 0, 0, 1, 1);\r\n    functionLayout->addWidget(physicalPrefixEditor_, 0, 1, 1, 1);\r\n    functionLayout->addWidget(&autoConnectButton_, 1, 1, 1, 1);\r\n\r\n    QVBoxLayout* filterAndFunctionLayout = new QVBoxLayout();\r\n    filterAndFunctionLayout->addWidget(filterBox);\r\n    filterAndFunctionLayout->addWidget(autoconnectBox);\r\n\r\n    QVBoxLayout* physicalPortLayout = new QVBoxLayout();\r\n    physicalPortLayout->addWidget(&physicalPortView_);\r\n\r\n    QGroupBox* physicalGroupBox = new QGroupBox(tr(\"Physical ports\"), this);\r\n    physicalGroupBox->setLayout(physicalPortLayout);\r\n\r\n    QWidget* topWidget = new QWidget(this);\r\n    QHBoxLayout* topLayout = new QHBoxLayout(topWidget);\r\n    topLayout->addWidget(physicalGroupBox, 1);\r\n    topLayout->addLayout(filterAndFunctionLayout);\r\n\r\n    QLabel* abstractionLabel(new QLabel(tr(\"Abstraction definition: \"), this));\r\n    QHBoxLayout* abstractionLayout = new QHBoxLayout();\r\n    abstractionLayout->addWidget(abstractionLabel, 0, Qt::AlignLeft);\r\n    abstractionLayout->addWidget(abstractionSelector_, 0, Qt::AlignLeft);\r\n    abstractionLayout->addStretch(5);\r\n\r\n    QAction* requiredSignalsAction(new QAction(\"Required signals\", this));\r\n    QAction* optionalSignalsAction(new QAction(\"Optional signals\", this));\r\n    QAction* allSignalsAction(new QAction(\"All signals\", this));\r\n\r\n    connect(requiredSignalsAction, SIGNAL(triggered()),\r\n        this, SLOT(onCreateRequiredSignals()), Qt::UniqueConnection);\r\n    connect(optionalSignalsAction, SIGNAL(triggered()),\r\n        this, SLOT(onCreateOptionalSignals()), Qt::UniqueConnection);\r\n    connect(allSignalsAction, SIGNAL(triggered()), this, SLOT(onCreateAllSignals()), Qt::UniqueConnection);\r\n\r\n    QMenu* addSignalMenu(new QMenu());\r\n    addSignalMenu->addAction(allSignalsAction);\r\n    addSignalMenu->addAction(requiredSignalsAction);\r\n    addSignalMenu->addAction(optionalSignalsAction);\r\n\r\n    QPushButton* addSignalButton(new QPushButton(QIcon(\":/icons/common/graphics/add.png\"), \"Add\", this));\r\n    addSignalButton->setMenu(addSignalMenu);\r\n\r\n    QHBoxLayout* buttonLayout(new QHBoxLayout());\r\n    buttonLayout->addWidget(addSignalButton);\r\n    buttonLayout->addWidget(&removeAllMappingsButton_);\r\n    buttonLayout->addStretch(10);\r\n\r\n    QVBoxLayout* portMapsLayout = new QVBoxLayout();\r\n    portMapsLayout->addLayout(buttonLayout, 0);\r\n    portMapsLayout->addWidget(&portMapView_);\r\n\r\n    QGroupBox* portMapsGroupBox = new QGroupBox(tr(\"Port Maps\"), this);\r\n    portMapsGroupBox->setLayout(portMapsLayout);\r\n\r\n    QWidget* bottomWidget(new QWidget(this));\r\n    QVBoxLayout* bottomLayout(new QVBoxLayout(bottomWidget));\r\n    bottomLayout->addLayout(abstractionLayout);\r\n    bottomLayout->addWidget(portMapsGroupBox);\r\n\r\n    QVBoxLayout* masterLayout = new QVBoxLayout(this);\r\n\r\n    QSplitter* splitter = new QSplitter(Qt::Vertical, this);    \r\n    splitter->addWidget(topWidget);\r\n    splitter->addWidget(bottomWidget);\r\n    splitter->setStretchFactor(1, 1);\r\n\r\n    masterLayout->addWidget(splitter);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusInterfacePortMapTab::connectItems()\r\n//-----------------------------------------------------------------------------\r\nvoid BusInterfacePortMapTab::connectItems()\r\n{\r\n    // Connect signals from physical port filters.\r\n    connect(nameFilterEditor_, SIGNAL(textChanged(const QString&)), \r\n        &physicalPortSorter_, SLOT(setFilterPortName(const QString&)), Qt::UniqueConnection);\r\n    connect(nameFilterEditor_, SIGNAL(textChanged(const QString&)), \r\n        &physicalPortView_, SLOT(onFilterNameChanged(const QString&)), Qt::UniqueConnection);\r\n\r\n    connect(&typeFilter_, SIGNAL(currentTextChanged(QString const&)),\r\n        &physicalPortSorter_, SLOT(onChangeFilteredType(QString const&)), Qt::UniqueConnection);\r\n\r\n    connect(&directionFilter_, SIGNAL(currentTextChanged(QString const&)),\r\n        this, SLOT(onDirectionFilterChanged(QString const&)), Qt::UniqueConnection);\r\n\r\n    connect(&portMapModel_, SIGNAL(contentChanged()), this, SIGNAL(contentChanged()), Qt::UniqueConnection);\r\n    connect(&portMapModel_, SIGNAL(portConnected(QString const&)),\r\n        this, SLOT(onPortConnected(QString const&)), Qt::UniqueConnection);\r\n    connect(&portMapModel_, SIGNAL(portDisconnected(QString const&)),\r\n        this, SLOT(onPortDisconnected(QString const&)), Qt::UniqueConnection);\r\n\r\n    connect(&portMapView_, SIGNAL(addItem(const QModelIndex&)),\r\n        &portMapModel_, SLOT(onAddPortMap(const QModelIndex&)), Qt::UniqueConnection);\r\n\r\n    connect(&portMapView_, SIGNAL(removeItem(const QModelIndex&)),\r\n        &portMapModel_, SLOT(onRemovePortMap(QModelIndex const&)), Qt::UniqueConnection);\r\n\r\n    connect(&hideConnectedPortsBox_, SIGNAL(toggled(bool)),\r\n        &physicalPortSorter_, SLOT(setFilterHideConnected(bool)), Qt::UniqueConnection);\r\n\r\n    connect(&removeAllMappingsButton_, SIGNAL(clicked(bool)),\r\n        &portMapModel_, SLOT(onRemoveAllPortMappings()), Qt::UniqueConnection);\r\n\r\n    connect(physicalPrefixEditor_, SIGNAL(textChanged(QString const&)), \r\n        &autoConnector_, SLOT(setPrefix(QString const&)), Qt::UniqueConnection);\r\n    connect(&autoConnectButton_, SIGNAL(clicked()), &autoConnector_, SLOT(onAutoConnect()), Qt::UniqueConnection);\r\n\r\n    connect(&autoConnector_, SIGNAL(portMapsAutoConnected(QVector<QString>)),\r\n        &portMapModel_, SLOT(onAddAutoConnectedPortMaps(QVector<QString>)), Qt::UniqueConnection);\r\n    connect(&portMapView_, SIGNAL(autoConnecteLogicalSignals(QStringList const&)),\r\n        &autoConnector_, SLOT(onAutoConnectLogicalSignals(QStringList const&)), Qt::UniqueConnection);\r\n\r\n    connect(abstractionSelector_, SIGNAL(currentIndexChanged(int)),\r\n        this, SLOT(onAbstractionChanged()), Qt::UniqueConnection);\r\n\r\n    connect(&portMapView_, SIGNAL(createAllSignals()), this, SLOT(onCreateAllSignals()), Qt::UniqueConnection);\r\n    connect(&portMapView_, SIGNAL(createRequiredSignals()),\r\n        this, SLOT(onCreateRequiredSignals()), Qt::UniqueConnection);\r\n    connect(&portMapView_, SIGNAL(createOptionalSignals()),\r\n        this, SLOT(onCreateOptionalSignals()), Qt::UniqueConnection);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusInterfacePortMapTab::onPortConnected()\r\n//-----------------------------------------------------------------------------\r\nvoid BusInterfacePortMapTab::onPortConnected(QString const& portName)\r\n{\r\n    physicalPortSorter_.onPortConnected(portName);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusInterfacePortMapTab::onPortDisconnected()\r\n//-----------------------------------------------------------------------------\r\nvoid BusInterfacePortMapTab::onPortDisconnected(QString const& portName)\r\n{\r\n/*\r\n    foreach (QSharedPointer<BusInterface> busInterface, *component_->getBusInterfaces())\r\n    {\r\n        foreach (QSharedPointer<PortMap> interfacePortMap, *busInterface->getAllPortMaps())\r\n        {\r\n            if (interfacePortMap->getPhysicalPort())\r\n            {\r\n                if (interfacePortMap->getPhysicalPort()->name_ == portName)\r\n                {\r\n                    return;\r\n                }\r\n            }\r\n        }\r\n    }\r\n*/\r\n\r\n    physicalPortSorter_.onPortDisconnected(portName);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusInterfacePortMapTab::onDirectionFilterChanged()\r\n//-----------------------------------------------------------------------------\r\nvoid BusInterfacePortMapTab::onDirectionFilterChanged(QString const& newDirection)\r\n{\r\n    if (newDirection.compare(\"In\", Qt::CaseInsensitive) == 0)\r\n    {\r\n        physicalPortSorter_.setFilterInDirection(true);\r\n        physicalPortSorter_.setFilterOutDirection(false);\r\n    }\r\n    else if (newDirection.compare(\"Out\", Qt::CaseInsensitive) == 0)\r\n    {\r\n        physicalPortSorter_.setFilterInDirection(false);\r\n        physicalPortSorter_.setFilterOutDirection(true);\r\n    }\r\n    else if (newDirection.compare(\"InOut\", Qt::CaseInsensitive) == 0)\r\n    {\r\n        physicalPortSorter_.setFilterInDirection(true);\r\n        physicalPortSorter_.setFilterOutDirection(true);\r\n    }\r\n    else\r\n    {\r\n        physicalPortSorter_.setFilterInDirection(false);\r\n        physicalPortSorter_.setFilterOutDirection(false);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusIfPortmapTab::focusInEvent()\r\n//-----------------------------------------------------------------------------\r\nvoid BusInterfacePortMapTab::showEvent(QShowEvent* event)\r\n{\r\n    QWidget::showEvent(event);\r\n    if (component_->getRevision() == Document::Revision::Std14)\r\n    {\r\n        emit helpUrlRequested(\"componenteditor/portmaps.html\");\r\n    }\r\n    else if (component_->getRevision() == Document::Revision::Std22)\r\n    {\r\n        emit helpUrlRequested(\"componenteditor/portmaps2022.html\");\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusInterfacePortMapTab::changeBusName()\r\n//-----------------------------------------------------------------------------\r\nvoid BusInterfacePortMapTab::changeBusName(std::string const& newName)\r\n{\r\n    busName_ = newName;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusInterfacePortMapTab::onCreateRequiredSignals()\r\n//-----------------------------------------------------------------------------\r\nvoid BusInterfacePortMapTab::onCreateRequiredSignals()\r\n{\r\n    AbstractionTypeInterface* absType = busInterface_->getAbstractionTypeInterface();\r\n    if (absType)\r\n    {\r\n        PortMapInterface* portMapInterface = absType->getPortMapInterface();\r\n        if (portMapInterface)\r\n        {\r\n            int numSignalsBefore = portMapInterface->itemCount();\r\n            portMapInterface->createRequiredSignals();\r\n            portMapModel_.reset();\r\n            int numSignalsAfter = portMapInterface->itemCount();\r\n\r\n            if (numSignalsBefore != numSignalsAfter)\r\n            {\r\n                emit contentChanged();\r\n            }\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusInterfacePortMapTab::onCreateOptionalSignals()\r\n//-----------------------------------------------------------------------------\r\nvoid BusInterfacePortMapTab::onCreateOptionalSignals()\r\n{\r\n    AbstractionTypeInterface* absType = busInterface_->getAbstractionTypeInterface();\r\n    if (absType)\r\n    {\r\n        PortMapInterface* portMapInterface = absType->getPortMapInterface();\r\n        if (portMapInterface)\r\n        {\r\n            int numSignalsBefore = portMapInterface->itemCount();\r\n\r\n            portMapInterface->createOptionalSignals();\r\n            portMapModel_.reset();\r\n\r\n            int numSignalsAfter = portMapInterface->itemCount();\r\n\r\n            if (numSignalsBefore != numSignalsAfter)\r\n            {\r\n                emit contentChanged();\r\n            }\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusInterfacePortMapTab::onCreateAllSignals()\r\n//-----------------------------------------------------------------------------\r\nvoid BusInterfacePortMapTab::onCreateAllSignals()\r\n{\r\n    AbstractionTypeInterface* absType = busInterface_->getAbstractionTypeInterface();\r\n    if (absType)\r\n    {\r\n        PortMapInterface* portMapInterface = absType->getPortMapInterface();\r\n        if (portMapInterface)\r\n        {\r\n            int numSignalsBefore = portMapInterface->itemCount();\r\n\r\n            portMapInterface->createAllSignals();\r\n            portMapModel_.reset();\r\n\r\n            int numSignalsAfter = portMapInterface->itemCount();\r\n\r\n            if (numSignalsBefore != numSignalsAfter)\r\n            {\r\n                emit contentChanged();\r\n            }\r\n        }\r\n    }\r\n}\r\n"
  },
  {
    "path": "editors/ComponentEditor/busInterfaces/portmaps/BusInterfacePortMapTab.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: BusInterfacePortMapTab.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Mikko Teuho\r\n// Date: 23.05.2016\r\n//\r\n// Description:\r\n// Tab for editing and viewing bus interface port maps.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef BUSINTERFACEPORTMAPTAB_H\r\n#define BUSINTERFACEPORTMAPTAB_H\r\n\r\n#include <editors/ComponentEditor/busInterfaces/portmaps/PortMapView.h>\r\n#include <editors/ComponentEditor/busInterfaces/portmaps/PortMapModel.h>\r\n#include <editors/ComponentEditor/busInterfaces/portmaps/PortListSortProxyModel.h>\r\n#include <editors/ComponentEditor/busInterfaces/portmaps/PhysicalPortMappingTableView.h>\r\n#include <editors/ComponentEditor/busInterfaces/portmaps/PhysicalPortMappingTableModel.h>\r\n#include <editors/ComponentEditor/busInterfaces/portmaps/PortMapAutoConnector.h>\r\n#include <editors/ComponentEditor/busInterfaces/portmaps/PortMapSortFilter.h>\r\n\r\n#include <IPXACTmodels/generaldeclarations.h>\r\n\r\n#include <QCheckBox>\r\n#include <QWidget>\r\n#include <QPushButton>\r\n#include <QLineEdit>\r\n#include <QComboBox>\r\n#include <QComboBox>\r\n\r\n#include <QSortFilterProxyModel>\r\n\r\nclass BusInterface;\r\nclass Component;\r\nclass LibraryInterface;\r\nclass PortMap;\r\nclass ExpressionParser;\r\nclass VLNV;\r\nclass ParameterFinder;\r\nclass PortMapDelegate;\r\nclass PortMapValidator;\r\nclass PortMapAutoConnector;\r\nclass AbstractionType;\r\nclass PortMapInterface;\r\nclass BusInterfaceInterface;\r\nclass AbstractionTypeInterface;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Tab for editing and viewing bus interface port maps.\r\n//-----------------------------------------------------------------------------\r\nclass BusInterfacePortMapTab : public QWidget\r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\r\n\t/*!\r\n     *  The constructor\r\n\t *\r\n\t *    @param [in] libHandler          The instance that manages the library.\r\n\t *    @param [in] component           The component being edited.\r\n     *    @param [in] busInterface        Interface for accessing bus interfaces.\r\n     *    @param [in] busName             Name of the edited bus interface.\r\n     *    @param [in] expressionParser    The used expression parser.\r\n     *    @param [in] finder              The used parameter finder.\r\n     *    @param [in] portMapInterface    Interface for accessing port maps.\r\n\t *    @param [in] parent              The owner of the editor.\r\n\t */\r\n    BusInterfacePortMapTab(LibraryInterface* libHandler,\r\n        QSharedPointer<Component> component,\r\n        BusInterfaceInterface* busInterface,\r\n        std::string const& busName,\r\n        QSharedPointer<ExpressionParser> expressionParser,\r\n        QSharedPointer<ParameterFinder> finder,\r\n        PortMapInterface* portMapInterface,\r\n        QWidget* parent);\r\n\r\n\t/*!\r\n     *  The destructor.\r\n     */\r\n    virtual ~BusInterfacePortMapTab() = default;\r\n\r\n\t/*!\r\n     *  Restore the changes made in the editor back to ones in the model.\r\n\t */\r\n\tvirtual void refresh();\r\n\r\n\t/*!\r\n     *  Set the abstraction type that defines the logical signals to use.\r\n\t *\r\n     *    @param [in] abstractionIndex    Index of the selected abstraction type.\r\n\t */\r\n    virtual void setAbsType(int const& abstractionIndex);\r\n\r\n    /*!\r\n     *  Sets a subset of component ports to be visible in the physical port list.\r\n     *\r\n     *    @param [in] ports   List of port names to show.\r\n     */\r\n    virtual void setPhysicalPorts(QStringList const& ports);\r\n\r\n    /*!\r\n     *  Setup the available abstraction definitions.\r\n     */\r\n    void setAbstractionDefinitions();\r\n\r\npublic slots:\r\n\r\n    /*!\r\n     *  Handle the change in the name of the edited bus interface.\r\n     *\r\n     *    @param [in] newName     New name of the edited bus interface.\r\n     */\r\n    void changeBusName(std::string const& newName);\r\n\r\nsignals:\r\n\r\n    //! Emitted when an error occurs.\r\n    void errorMessage(QString const&);\r\n\r\n    //! Emitted when a notice should be sent to user.\r\n    void noticeMessage(QString const&);\r\n\r\n\t//! Emitted when contents of the model change.\r\n\tvoid contentChanged();\r\n\r\n    /*!\r\n     *  Emitted when a help page should be changed in the context help window.\r\n     *\r\n     *    @param [in] url     URL of the help page.\r\n     */\r\n    void helpUrlRequested(QString const& url);\r\n\r\n    /*!\r\n     *  Emitted when the selected parameter is referenced. Increases the number of references.\r\n     *\r\n     *    @param [in] id  The ID of the referenced parameter.\r\n     */\r\n    void increaseReferences(QString id);\r\n\r\n    /*!\r\n     *  Emitted when the selected parameter is referenced. Decreases the number of references.\r\n     *\r\n     *    @param [in] id  The ID of the referenced parameter.\r\n     */\r\n    void decreaseReferences(QString id);\r\n\r\nprotected:\r\n\r\n    //! Handler for widget's show event\r\n    virtual void showEvent(QShowEvent* event);\r\n\r\nprivate slots:\r\n\r\n    /*!\r\n     *  Handles the filtering of a connected port.\r\n     *\r\n     *    @param [in] portName    The name of the connected port.\r\n     */\r\n    void onPortConnected(QString const& portName);\r\n\r\n    /*!\r\n     *  Handles the filtering of a disconnected port.\r\n     *\r\n     *    @param [in] portName    The name of the disconnected port.\r\n     */\r\n    void onPortDisconnected(QString const& portName);\r\n\r\n    /*!\r\n     *  Handles the filtering by the selected direction.\r\n     *\r\n     *    @param [in] newDirection    The selected direction.\r\n     */\r\n    void onDirectionFilterChanged(QString const& newDirection);\r\n\r\n    /*!\r\n     *  Handle the selection of currently active the abstraction type.\r\n     */\r\n    void onAbstractionChanged();\r\n\r\n    /*!\r\n     *  Handle creation of port maps with required logical signals.\r\n     */\r\n    void onCreateRequiredSignals();\r\n\r\n    /*!\r\n     *  Handle creation of port maps with optional logical signals.\r\n     */\r\n    void onCreateOptionalSignals();\r\n\r\n    /*!\r\n     *  Handle creation of port maps with all logical signals.\r\n     */\r\n    void onCreateAllSignals();\r\n\r\nprivate:\r\n\t\r\n    //! No copying.\tNo assignment.\r\n\tBusInterfacePortMapTab(const BusInterfacePortMapTab& other);\r\n\tBusInterfacePortMapTab& operator=(const BusInterfacePortMapTab& other);\r\n\r\n    /*!\r\n     *  Setup the currently active abstraction type.\r\n     */\r\n    void setupAbstraction();\r\n\r\n\t/*!\r\n     *  Set up the layout of the GUI items\r\n     */\r\n\tvoid setupLayout();\r\n\r\n    /*!\r\n     *  Setup the port type filter.\r\n     *\r\n     */\r\n    void setupTypeFilter();\r\n\r\n    /*!\r\n     *  Add the required items to the direction filter.\r\n     */\r\n    void addItemsToDirectionFilter();\r\n\r\n    /*!\r\n     *  Connect the signals.\r\n     */\r\n    void connectItems();\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! Interface for accessing bus interfaces.\r\n    BusInterfaceInterface* busInterface_;\r\n\r\n    //! Name of the edited bus interface.\r\n    std::string busName_;\r\n\r\n\t//! The component being edited.\r\n\tQSharedPointer<Component> component_;\r\n\r\n\t//! The instance that manages the library.\r\n\tLibraryInterface* libHandler_;\r\n\r\n\t//! The view to display the physical ports.\r\n    PhysicalPortMappingTableView physicalPortView_;\r\n\r\n\t//! The model to present the physical ports.\r\n    PhysicalPortMappingTableModel physicalPortModel_;\r\n\r\n    //! Sorter for the physical ports.\r\n    PortListSortProxyModel physicalPortSorter_;\r\n\r\n    //! Editor for filtering of physical ports by name.\r\n    QLineEdit* nameFilterEditor_;\r\n\r\n    //! The port type selector.\r\n    QComboBox typeFilter_;\r\n\r\n    //! The direction filter.\r\n    QComboBox directionFilter_;\r\n\r\n    //! The connected ports filter.\r\n    QCheckBox hideConnectedPortsBox_;\r\n\r\n    //! Editor for physical port prefix for auto connect.\r\n    QLineEdit* physicalPrefixEditor_;\r\n\r\n    //! Model for the constructed port maps.\r\n    PortMapModel portMapModel_;\r\n\r\n    //! Proxy for filtering/sorting port maps.\r\n    PortMapSortFilter portMapSorter_;\r\n\r\n    //! View for the constructed port maps.\r\n    PortMapView portMapView_;\r\n\r\n    //! Delegate for the constructed port maps.\r\n    PortMapDelegate* portMapDelegate_;\r\n\r\n    //! Button for automatically constructing the port maps.\r\n    QPushButton autoConnectButton_;\r\n\r\n    //! Button for removing all the port maps.\r\n    QPushButton removeAllMappingsButton_;\r\n\r\n    //! Automatic port map creator.\r\n    PortMapAutoConnector autoConnector_;\r\n\r\n    //! Selects the active abstraction type.\r\n    QComboBox* abstractionSelector_;\r\n};\r\n\r\n#endif // BUSINTERFACEPORTMAPTAB_H\r\n"
  },
  {
    "path": "editors/ComponentEditor/busInterfaces/portmaps/JaroWinklerAlgorithm.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: JaroWinklerAlgorithm.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Esko Pekkarinen\r\n// Date: 24.10.2016\r\n//\r\n// Description:\r\n// Implementation of Jaro-Winkler distance algorithm for string similarity measurement.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"JaroWinklerAlgorithm.h\"\r\n\r\n#include <QtMath>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: JaroWinklerAlgorithm::calculateJaroDistance()\r\n//-----------------------------------------------------------------------------\r\ndouble JaroWinklerAlgorithm::calculateJaroDistance(QString const& firstString, QString const& secondString)\r\n{\r\n    QString firstMatch = Details::findMatchingCharacters(firstString, secondString);\r\n    QString secondMatch = Details::findMatchingCharacters(secondString, firstString);\r\n\r\n    double matchingCharacters = qMin(firstMatch.length(), secondMatch.length());\r\n    \r\n    double jaroDistance = 0;\r\n\r\n    if (matchingCharacters != 0)\r\n    {\r\n        double transpositions = Details::getTranspositions(firstMatch, secondMatch);\r\n\r\n        double firstPart = matchingCharacters / firstString.length();\r\n        double secondPart = matchingCharacters / secondString.length();\r\n        double transpositionPart = (matchingCharacters - transpositions) / matchingCharacters;\r\n\r\n        jaroDistance = (firstPart + secondPart + transpositionPart) / 3;\r\n    }\r\n\r\n    return jaroDistance;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: JaroWinklerAlgorithm::calculateJaroWinklerDistance()\r\n//-----------------------------------------------------------------------------\r\ndouble JaroWinklerAlgorithm::calculateJaroWinklerDistance(QString const& firstString, QString const& secondString, \r\n    double winklerScalingFactor)\r\n{\r\n    double jaroDistance = calculateJaroDistance(firstString, secondString);\r\n    double winklerDistance = Details::calculateWinklerDistance(firstString, secondString,\r\n        jaroDistance, winklerScalingFactor);\r\n\r\n    return jaroDistance + winklerDistance;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: JaroWinklerAlgorithm::Details::findMatchingCharacters()\r\n//-----------------------------------------------------------------------------\r\nQString JaroWinklerAlgorithm::Details::findMatchingCharacters(QString const& searched,\r\n    QString const& reference)\r\n{\r\n    int matchingDistanceStart = 2;\r\n    int matchingDistanceEnd = qMax(1, qMax(searched.length(), reference.length())/2 - 1);\r\n\r\n    QString matchingCharacters = \"\";\r\n\r\n    for (int i = 0; i < searched.length(); ++i)\r\n    {\r\n        int startPosition = qMax(0, i - matchingDistanceStart);\r\n        int endPosition = qMin(i + matchingDistanceEnd, reference.length() - 1);\r\n\r\n        int sectionLength = endPosition - startPosition + 1;\r\n\r\n        QString referenceSection = reference.mid(startPosition, sectionLength);\r\n        if (referenceSection.contains(searched.at(i), Qt::CaseInsensitive))\r\n        {\r\n            matchingCharacters.append(searched.at(i).toLower());\r\n        }\r\n    }\r\n\r\n    return matchingCharacters;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: JaroWinklerAlgorithm::Details::getTranspositions()\r\n//-----------------------------------------------------------------------------\r\nint JaroWinklerAlgorithm::Details::getTranspositions(QString const& firstMatch, QString const& secondMatch)\r\n{\r\n    int transpositions = 0;\r\n\r\n    int minLenght = qMin(firstMatch.length(), secondMatch.length());\r\n    \r\n    for (int i = 0; i < minLenght; i++)\r\n    {\r\n        if (firstMatch.at(i) != secondMatch.at(i))\r\n        {\r\n            transpositions++;\r\n        }\r\n    }\r\n\r\n    int maxLenght = qMax(firstMatch.length(), secondMatch.length());\r\n    transpositions += maxLenght - minLenght;\r\n\r\n    return transpositions;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: JaroWinklerAlgorithm::Details::calculateWinklerDistance()\r\n//-----------------------------------------------------------------------------\r\ndouble JaroWinklerAlgorithm::Details::calculateWinklerDistance(QString const& firstString,\r\n    QString const& secondString, double jaroDistance, double scalingFactor)\r\n{\r\n    int prefixLength = Details::findCommonPrefixLength(firstString, secondString);\r\n\r\n    return prefixLength*scalingFactor*(1 - jaroDistance);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: JaroWinklerAlgorithm::Details::findCommonPrefixLength()\r\n//-----------------------------------------------------------------------------\r\nint JaroWinklerAlgorithm::Details::findCommonPrefixLength(QString const& firstString, QString const& secondString)\r\n{\r\n    const int MAX_PREFIX_LENGTH = 4;\r\n    const int MAX_STEPS = qMin(MAX_PREFIX_LENGTH, qMin(firstString.length(), secondString.length()));\r\n\r\n    int prefixLength = 0;\r\n\r\n    for (int i = 0; i < MAX_STEPS && i == prefixLength; i++)\r\n    {\r\n        if (firstString.at(i).toLower() == secondString.at(i).toLower())\r\n        {\r\n            prefixLength++;\r\n        }\r\n    }  \r\n\r\n    return prefixLength;\r\n}\r\n"
  },
  {
    "path": "editors/ComponentEditor/busInterfaces/portmaps/JaroWinklerAlgorithm.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: JaroWinklerAlgorithm.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Esko Pekkarinen\r\n// Date: 24.10.2016\r\n//\r\n// Description:\r\n// Implementation of Jaro-Winkler distance algorithm for string similarity measurement.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef JAROWINKLERALGORITHM_H\r\n#define JAROWINKLERALGORITHM_H\r\n\r\n#include <QString>\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Implementation of Jaro-Winkler distance algorithm for string similarity measurement.\r\n//-----------------------------------------------------------------------------\r\nnamespace JaroWinklerAlgorithm\r\n{\r\n    /*!\r\n     *  Calculate a Jaro distance for two strings.\r\n     *\r\n     *    @param [in] firstString     The first string in comparison.\r\n     *    @param [in] secondString    The second string in comparison.\r\n     *\r\n     *    @return The similarity metric between the two strings on a scale of 0 to 1.0 where 1.0 is exact match.\r\n     */\r\n    double calculateJaroDistance(QString const& firstString, QString const& secondString);\r\n\r\n    /*!\r\n     *  Calculate a Jaro-Winkler distance for two strings. Favors strings with similar prefixes.\r\n     *\r\n     *    @param [in] firstString             The first string in comparison.\r\n     *    @param [in] secondString            The second string in comparison.\r\n     *    @param [in] winklerScalingFactor    The scaling factor for prefix. Should not exceed 0.25.\r\n     *\r\n     *    @return The similarity metric between the two strings on a scale of 0 to 1.0.\r\n     */\r\n    double calculateJaroWinklerDistance(QString const& firstString, QString const& secondString,\r\n        double winklerScalingFactor = 0.1);\r\n\r\n    namespace Details\r\n    {\r\n        /*!\r\n        *  Get the matching characters from the selected strings.\r\n        *\r\n        *    @param [in] searched             The string whose characters are searched in the reference.\r\n        *    @param [in] reference            The string whose characters are matched.\r\n        *\r\n        *    @return The matching characters.\r\n        */\r\n        QString findMatchingCharacters(QString const& searched, QString const& reference);\r\n\r\n        /*!\r\n        *  Get the number of transpositions from the matched strings.\r\n        *\r\n        *    @param [in] firstMatch      The first string.\r\n        *    @param [in] secondMatch     The second string.\r\n        *\r\n        *    @return The number of character movements required to make the selected strings equal.\r\n        */\r\n        int getTranspositions(QString const& firstMatch, QString const& secondMatch);\r\n        \r\n        /*!\r\n        *  Calculate the Winkler distance from the Jaro distance.\r\n        *\r\n        *    @param [in] firstString     The first string in comparison.\r\n        *    @param [in] secondString    The second string in comparison.\r\n        *    @param [in] jaroDistance    The calculated Jaro distance.\r\n        *    @param [in] scalingFactor   The scaling factor for the prefix. Should not exceed 0.25.\r\n        *\r\n        *    @return The similarity between two strings, weighted by the length of the prefix and scaling factor.\r\n        */\r\n        double calculateWinklerDistance(QString const& firstString, QString const& secondString,\r\n            double jaroDistance, double scalingFactor);\r\n        \r\n        /*!\r\n         *  Finds the number of characters in a common prefix for two strings.\r\n         *\r\n         *    @param [in] firstString     The first string.\r\n         *    @param [in] secondString    The second string.\r\n         *\r\n         *    @return The number of common characters in the beginning of the strings.\r\n         */\r\n        int findCommonPrefixLength(QString const& firstString, QString const& secondString);\r\n    };\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n\r\n#endif // JAROWINKLERALGORITHM_H\r\n"
  },
  {
    "path": "editors/ComponentEditor/busInterfaces/portmaps/PhysicalPortMappingTableModel.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: PhysicalPortMappingTableModel.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Mikko Teuho\r\n// Date: 19.05.2016\r\n//\r\n// Description:\r\n// Model to display the physical ports of a component in port mapping.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"PhysicalPortMappingTableModel.h\"\r\n#include \"PortMappingColumns.h\"\r\n\r\n#include <KactusAPI/include/ExpressionParser.h>\r\n#include <KactusAPI/include/PortsInterface.h>\r\n\r\n#include <IPXACTmodels/common/TransactionalTypes.h>\r\n#include <IPXACTmodels/common/DirectionTypes.h>\r\n#include <IPXACTmodels/Component/Component.h>\r\n#include <IPXACTmodels/Component/Port.h>\r\n\r\n#include <QIcon>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PhysicalPortMappingTableModel::PhysicalPortMappingTableModel()\r\n//-----------------------------------------------------------------------------\r\nPhysicalPortMappingTableModel::PhysicalPortMappingTableModel(PortsInterface* portInterface, QObject *parent):\r\nPortMappingTableModel(parent),\r\nportInterface_(portInterface)\r\n{\r\n    refresh();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PhysicalPortMappingTableModel::~PhysicalPortMappingTableModel()\r\n//-----------------------------------------------------------------------------\r\nPhysicalPortMappingTableModel::~PhysicalPortMappingTableModel()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PhysicalPortMappingTableModel::refresh()\r\n//-----------------------------------------------------------------------------\r\nvoid PhysicalPortMappingTableModel::refresh()\r\n{\r\n    beginResetModel();\r\n    endResetModel();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PhysicalPortMappingTableModel::rowCount()\r\n//-----------------------------------------------------------------------------\r\nint PhysicalPortMappingTableModel::rowCount(const QModelIndex& parent) const\r\n{\r\n    if (parent.isValid())\r\n    {\r\n        return 0;\r\n    }\r\n    else\r\n    {\r\n        return portInterface_->itemCount();\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PhysicalPortMappingTableModel::data()\r\n//-----------------------------------------------------------------------------\r\nQVariant PhysicalPortMappingTableModel::data(QModelIndex const& index, int role) const\r\n{\r\n    if (!index.isValid() || index.row() < 0 || index.row() >= portInterface_->itemCount())\r\n    {\r\n        return QVariant();\r\n    }\r\n\r\n    std::string portName = portInterface_->getIndexedItemName(index.row());\r\n\r\n    if (role == Qt::DisplayRole)\r\n    {\r\n        if (index.column() == PortMappingColumns::NAME)\r\n        {\r\n            return QString::fromStdString(portName);\r\n        }\r\n        else if (index.column() == PortMappingColumns::DIRECTION)\r\n        {\r\n            QString portDirection = QString::fromStdString(portInterface_->getDirection(portName));\r\n            return portDirection;\r\n        }\r\n        else if (index.column() == PortMappingColumns::INITIATIVE && portInterface_->portIsTransactional(portName))\r\n        {\r\n            QString transactionalInitiative = QString::fromStdString(portInterface_->getInitiative(portName));\r\n            if (transactionalInitiative == TransactionalTypes::INITIATIVE_BOTH)\r\n            {\r\n                transactionalInitiative = TransactionalTypes::INITIATIVE_REQUIRES_PROVIDES;\r\n            }\r\n\r\n            return transactionalInitiative;\r\n        }\r\n        else if (index.column() == PortMappingColumns::LEFT_BOUND)\r\n        {\r\n            QString leftExpression = QString::fromStdString(portInterface_->getLeftBoundValue(portName));\r\n            if (leftExpression.compare(QLatin1String(\"x\")) == 0)\r\n            {\r\n                return QString();\r\n            }\r\n\r\n            return leftExpression;\r\n        }\r\n        else if (index.column() == PortMappingColumns::RIGHT_BOUND)\r\n        {\r\n            QString rightExpression = QString::fromStdString(portInterface_->getRightBoundValue(portName));\r\n            if (rightExpression.compare(QLatin1String(\"x\")) == 0)\r\n            {\r\n                return QString();\r\n            }\r\n\r\n            return rightExpression;\r\n        }\r\n        else if (index.column() == PortMappingColumns::SIZE)\r\n        {\r\n            if (portInterface_->portIsTransactional(portName))\r\n            {\r\n                return QString::fromStdString(portInterface_->getBusWidthValue(portName));\r\n            }\r\n            else\r\n            {\r\n                return QString::fromStdString(portInterface_->getWidth(portName));\r\n            }\r\n        }\r\n    }\r\n    else if (role == Qt::DecorationRole && (index.column() == PortMappingColumns::DIRECTION ||\r\n        index.column() == PortMappingColumns::INITIATIVE))\r\n    {\r\n        return QIcon(QString::fromStdString(portInterface_->getIconPathForPort(portName)));\r\n    }\r\n    \r\n    return QVariant();\r\n}\r\n"
  },
  {
    "path": "editors/ComponentEditor/busInterfaces/portmaps/PhysicalPortMappingTableModel.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: PhysicalPortMappingTableModel.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Mikko Teuho\r\n// Date: 19.05.2016\r\n//\r\n// Description:\r\n// Model to display the physical ports of a component in port mapping.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef PHYSICALPORTMAPPINGTABLEMODEL_H\r\n#define PHYSICALPORTMAPPINGTABLEMODEL_H\r\n\r\n#include \"PortMappingTableModel.h\"\r\n\r\n#include <QAbstractTableModel>\r\n#include <QSharedPointer>\r\n\r\nclass Component;\r\nclass Port;\r\nclass ExpressionParser;\r\nclass PortsInterface;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Model to display the physical ports of a component in port mapping.\r\n//-----------------------------------------------------------------------------\r\nclass PhysicalPortMappingTableModel : public PortMappingTableModel\r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\r\n\t/*!\r\n     *  The constructor.\r\n\t *\r\n\t *    @param [in] portInterface   Interface for accessing ports.\r\n\t *    @param [in] parent          The owner of this model.\r\n\t */\r\n    PhysicalPortMappingTableModel(PortsInterface* portInterface, QObject *parent);\r\n\r\n\t/*!\r\n     *  The destructor.\r\n     */\r\n\tvirtual ~PhysicalPortMappingTableModel();;\r\n\r\n\t/*!\r\n     *  Refresh the list of physical ports.\r\n\t */\r\n\tvirtual void refresh();\r\n\r\n    /*!\r\n     *  Get the number of rows in the model.\r\n\t *\r\n\t *    @param [in] parent      Model index of the parent of the item. Must be invalid because this is not\r\n     *                              a hierarchical model.\r\n\t *\r\n\t *    @return Number of rows currently in the model.\r\n\t */\r\n\tvirtual int rowCount(const QModelIndex& parent = QModelIndex() ) const;\r\n\r\n\t/*!\r\n     *  Get the data for the specified item for specified role.\r\n\t *\r\n\t *    @param [in] index   Identifies the item that's data is wanted.\r\n\t *    @param [in] role    Specifies what kind of data is wanted\r\n\t *\r\n\t *    @return The requested data.\r\n\t */\r\n\tvirtual QVariant data(QModelIndex const& index, int role = Qt::DisplayRole) const;\r\n\r\nprivate:\r\n\r\n\t//! No copying.\r\n\tPhysicalPortMappingTableModel(const PhysicalPortMappingTableModel& other);\r\n\tPhysicalPortMappingTableModel& operator=(const PhysicalPortMappingTableModel& other);\r\n\t\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! Interface for accessing ports.\r\n    PortsInterface* portInterface_;\r\n};\r\n\r\n#endif // PHYSICALPORTMAPPINGTABLEMODEL_H\r\n"
  },
  {
    "path": "editors/ComponentEditor/busInterfaces/portmaps/PhysicalPortMappingTableView.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: PhysicalPortMappingTableView.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Mikko Teuho\r\n// Date: 19.05.2016\r\n//\r\n// Description:\r\n// Table view for physical ports.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"PhysicalPortMappingTableView.h\"\r\n\r\n#include <QApplication>\r\n#include <QMimeData>\r\n#include <QDrag>\r\n#include <QModelIndex>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PhysicalPortMappingTableView::PhysicalPortMappingTableView()\r\n//-----------------------------------------------------------------------------\r\nPhysicalPortMappingTableView::PhysicalPortMappingTableView(QWidget *parent):\r\nPortMappingTableView(parent)\r\n{\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PhysicalPortMappingTableView::~PhysicalPortMappingTableView()\r\n//-----------------------------------------------------------------------------\r\nPhysicalPortMappingTableView::~PhysicalPortMappingTableView()\r\n{\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PhysicalPortMappingTableView::onFilterNameChanged()\r\n//-----------------------------------------------------------------------------\r\nvoid PhysicalPortMappingTableView::onFilterNameChanged(QString const& portName)\r\n{    \r\n    QModelIndex matchingIndex = model()->index(0, 0);\r\n    \r\n    if (!matchingIndex.isValid())\r\n    {\r\n        return;\r\n    }\r\n\r\n    int bestMatch =  QString::compare(matchingIndex.data().toString(), portName, Qt::CaseInsensitive);\r\n\r\n    // Search for better matching port names.\r\n    int rowCount = model()->rowCount();\r\n    for (int row = 1; row < rowCount; row++)\r\n    {\r\n        QModelIndex index = model()->index(row, 0);\r\n        if (index.isValid())\r\n        {\r\n            int diff = QString::compare(index.data().toString(), portName, Qt::CaseInsensitive);\r\n            if (bestMatch > diff)\r\n            {\r\n                matchingIndex = index;\r\n                bestMatch = diff;\r\n            }\r\n        }\r\n    }\r\n\r\n    clearSelection();\r\n\r\n    // Select the best matching port.\r\n    if (matchingIndex.isValid())\r\n    {        \r\n        selectionModel()->select(matchingIndex, QItemSelectionModel::Select);        \r\n    }    \r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PhysicalPortMappingTableView::dropEvent()\r\n//-----------------------------------------------------------------------------\r\nvoid PhysicalPortMappingTableView::dropEvent(QDropEvent* event) \r\n{\r\n\t// make sure the source is not this view\r\n\tPortMappingTableView* source = qobject_cast<PortMappingTableView*>(event->source());\r\n\t\r\n\t// if source is neither of the supported\r\n\tif (!source)\r\n    {\r\n\t\treturn;\r\n\t}\r\n\r\n\t// tell source that nothing is to be done to item\r\n\tevent->setDropAction(Qt::IgnoreAction);\r\n\r\n\t// if no port name has been specified or drop index is invalid\r\n\tQString mimeText = event->mimeData()->text();\r\n\tif (mimeText.isEmpty())\r\n    {\r\n\t\tevent->accept();\r\n\t\treturn;\r\n\t}\r\n\r\n\t// get the ports that were selected\r\n\tQStringList dropped = mimeText.split(QString(\";\"), Qt::SkipEmptyParts);\r\n\r\n\t// if the item to drop is from this port list view\r\n\tif (source == this)\r\n    {\r\n\t\tevent->accept();\r\n\t\treturn;\r\n\t}\r\n\r\n\t// get the selected indexes in this view\r\n\tQModelIndexList indexes = selectedIndexes();\r\n\tQStringList physicals;\r\n\r\n\t// add the physical port that matches each selected index\r\n\tforeach (QModelIndex const& index, indexes)\r\n    {\r\n\t\tif (index.isValid())\r\n        {\r\n\t\t\tphysicals.append(index.model()->data(index, Qt::DisplayRole).toString());\r\n\t\t}\r\n\t}\r\n\r\n\t// accept the drop\r\n\tevent->accept();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PhysicalPortMappingTableView::mouseMoveEvent()\r\n//-----------------------------------------------------------------------------\r\nvoid PhysicalPortMappingTableView::mouseMoveEvent(QMouseEvent* event)\r\n{\r\n    // if either mouse button is pressed\r\n    if (event->buttons() == Qt::LeftButton || event->buttons() == Qt::RightButton)\r\n    {\r\n        // calculate how much mouse was moved\r\n        int distance = (event->pos() - startPos_).manhattanLength();\r\n\r\n        // if the move distance is enough to start the drag\r\n        if (distance >= QApplication::startDragDistance())\r\n        {\r\n            performDrag();\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PhysicalPortMappingTableView::mousePressEvent()\r\n//-----------------------------------------------------------------------------\r\nvoid PhysicalPortMappingTableView::mousePressEvent(QMouseEvent* event)\r\n{\r\n    if (event->button() == Qt::LeftButton || event->buttons() == Qt::RightButton)\r\n    {\r\n        startPos_ = event->pos();\r\n    }\r\n\r\n    QTableView::mousePressEvent(event);\r\n}\r\n"
  },
  {
    "path": "editors/ComponentEditor/busInterfaces/portmaps/PhysicalPortMappingTableView.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: PhysicalPortMappingTableView.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Mikko Teuho\r\n// Date: 19.05.2016\r\n//\r\n// Description:\r\n// Table view for physical ports.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef PHYSICALPORTMAPPINGTABLEVIEW_H\r\n#define PHYSICALPORTMAPPINGTABLEVIEW_H\r\n\r\n#include \"PortMappingTableView.h\"\r\n\r\n#include <QDropEvent>\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Table view for physical ports.\r\n//-----------------------------------------------------------------------------\r\nclass PhysicalPortMappingTableView : public PortMappingTableView\r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\r\n    /*!\r\n     *  The constructor.\r\n     *\r\n     *    @param [in] parent  The owner of this view.\r\n     */\r\n\tPhysicalPortMappingTableView(QWidget *parent);\r\n\r\n\t/*!\r\n     *  The destructor.\r\n     */\r\n    virtual ~PhysicalPortMappingTableView();\r\n\r\npublic slots:\r\n\r\n    /*!\r\n     *  Handles changes in the name filter by selecting the best matching port from the list.\r\n     *\r\n     *    @param [in] portName   Name given in filter.\r\n     */\r\n    virtual void onFilterNameChanged(QString const& portName);\r\n\r\nprotected:\r\n\r\n\t/*\r\n     *  Handler for drop events on drag & drop.\r\n\t *\r\n\t *    @param [in] event   Pointer to the event object.\r\n\t */\r\n\tvirtual void dropEvent(QDropEvent* event);\r\n\r\n    /*!\r\n     *  Handler for mouse move events.\r\n\t *\r\n\t *    @param [in] event   Pointer to the event object.\r\n\t */\r\n    void mouseMoveEvent(QMouseEvent* event);\r\n\t\r\n    /*!\r\n     *  Handler for mouse press events.\r\n\t *\r\n\t *    @param [in] event   Pointer to the event object.\r\n\t */\r\n    void mousePressEvent(QMouseEvent* event);\r\n\r\nprivate:\r\n\r\n\t// No copying.\r\n\tPhysicalPortMappingTableView(const PhysicalPortMappingTableView& other);\r\n\tPhysicalPortMappingTableView& operator=(const PhysicalPortMappingTableView& other);\r\n};\r\n\r\n#endif // PHYSICALPORTMAPPINGTABLEVIEW_H\r\n"
  },
  {
    "path": "editors/ComponentEditor/busInterfaces/portmaps/PortListSortProxyModel.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: PortListSortProxyModel.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Esko Pekkarinen\r\n// Date: 01.10.2013\r\n//\r\n// Description:\r\n// Sorting proxy model for port lists.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"PortListSortProxyModel.h\"\r\n\r\n#include <KactusAPI/include/PortsInterface.h>\r\n#include <editors/ComponentEditor/busInterfaces/portmaps/PortMappingColumns.h>\r\n#include <KactusAPI/include/PortMapInterface.h>\r\n#include <KactusAPI/include/AbstractionTypeInterface.h>\r\n\r\n#include <IPXACTmodels/Component/BusInterface.h>\r\n#include <IPXACTmodels/Component/Component.h>\r\n#include <IPXACTmodels/Component/PortMap.h>\r\n#include <IPXACTmodels/Component/Port.h>\r\n\r\n#include <QModelIndex>\r\n\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PortListSortProxyModel()\r\n//-----------------------------------------------------------------------------\r\nPortListSortProxyModel::PortListSortProxyModel(int const& abstractionIndex, PortMapInterface* portMapInterface,\r\n    AbstractionTypeInterface* abstractionInterface, QObject *parent):\r\nQSortFilterProxyModel(parent),\r\nfilterDirection_(DirectionFilter::ANY),\r\nhideConnected_(true),\r\nconnectedPorts_(),\r\nfilterPorts_(),\r\nvisibleType_(PortTypes::WIRETYPE),\r\nportMapInterface_(portMapInterface),\r\nportInterface_(portMapInterface_->getPhysicalPortInterface()),\r\nabstractionIndex_(abstractionIndex),\r\nabstractionInterface_(abstractionInterface)\r\n{\r\n    onConnectionsReset();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PortListSortProxyModel::filterDirection()\r\n//-----------------------------------------------------------------------------\r\nPortListSortProxyModel::DirectionFilter PortListSortProxyModel::filterDirection() const\r\n{\r\n    return filterDirection_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PortListSortProxyModel::setFilterPortName()\r\n//-----------------------------------------------------------------------------\r\nvoid PortListSortProxyModel::setFilterPortName(QString const& portName)\r\n{\r\n    setFilterRegularExpression(QRegularExpression(portName, QRegularExpression::CaseInsensitiveOption));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PortListSortProxyModel::setFilterPorts()\r\n//-----------------------------------------------------------------------------\r\nvoid PortListSortProxyModel::setFilterPorts(QStringList const& ports)\r\n{\r\n    filterPorts_ = ports;\r\n    invalidateFilter();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PortListSortProxyModel::setFilterInDirection()\r\n//-----------------------------------------------------------------------------\r\nvoid PortListSortProxyModel::setFilterInDirection(bool filterInDirection)\r\n{\r\n    if (filterDirection_ == DirectionFilter::IN && !filterInDirection)\r\n    {\r\n        filterDirection_ = DirectionFilter::ANY;\r\n    }\r\n    else if (filterDirection_ == DirectionFilter::OUT && filterInDirection)\r\n    {\r\n        filterDirection_ = DirectionFilter::INOUT;\r\n    }\r\n    else if (filterDirection_ == DirectionFilter::INOUT && !filterInDirection)\r\n    {\r\n        filterDirection_ = DirectionFilter::OUT;\r\n    }\r\n    else if (filterDirection_ == DirectionFilter::ANY && filterInDirection)\r\n    {\r\n        filterDirection_ = DirectionFilter::IN;\r\n    }\r\n    \r\n    invalidateFilter();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PortListSortProxyModel::setFilterOutDirection()\r\n//-----------------------------------------------------------------------------\r\nvoid PortListSortProxyModel::setFilterOutDirection(bool filterOutDirection)\r\n{\r\n    if (filterDirection_ == DirectionFilter::IN && filterOutDirection)\r\n    {\r\n        filterDirection_ = DirectionFilter::INOUT;\r\n    }\r\n    else if (filterDirection_ == DirectionFilter::OUT && !filterOutDirection)\r\n    {\r\n        filterDirection_ = DirectionFilter::ANY;\r\n    }\r\n    else if (filterDirection_ == DirectionFilter::INOUT && !filterOutDirection)\r\n    {\r\n        filterDirection_ = DirectionFilter::IN;\r\n    }\r\n    else if (filterDirection_ == DirectionFilter::ANY && filterOutDirection)\r\n    {\r\n        filterDirection_ = DirectionFilter::OUT;\r\n    }\r\n\r\n    invalidateFilter();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PortListSortProxyModel::filterHideConnected()\r\n//-----------------------------------------------------------------------------\r\nbool PortListSortProxyModel::filterHideConnected() const\r\n{\r\n    return hideConnected_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PortListSortProxyModel::filterPortNames()\r\n//-----------------------------------------------------------------------------\r\nQStringList PortListSortProxyModel::filterPortNames() const\r\n{\r\n    return filterPorts_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PortListSortProxyModel::setFilterHideConnected()\r\n//-----------------------------------------------------------------------------\r\nvoid PortListSortProxyModel::setFilterHideConnected(bool hide)\r\n{\r\n    hideConnected_ = hide;\r\n    invalidateFilter();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PortListSortProxyModel::onConnectionsChanged()\r\n//-----------------------------------------------------------------------------\r\nvoid PortListSortProxyModel::onConnectionsReset()\r\n{\r\n    connectedPorts_.clear();\r\n\r\n    addConnectedPortsFromAbstraction();\r\n\r\n/*\r\n    foreach (QSharedPointer<BusInterface> busIf, *component_->getBusInterfaces())\r\n    {\r\n        if (busIf->getAbstractionTypes() && !busIf->getAbstractionTypes()->isEmpty())\r\n        {\r\n            if (busIf->getAbstractionTypes()->size() == 1 &&\r\n                busIf->getAbstractionTypes()->first()->getViewReferences()->isEmpty())\r\n            {\r\n                QSharedPointer<AbstractionType> singleAbstraction = busIf->getAbstractionTypes()->first();\r\n                addConnectedPortsFromAbstraction(singleAbstraction);\r\n            }\r\n        }\r\n    }\r\n*/\r\n\r\n    invalidateFilter(); \r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PortListSortProxyModel::addConnectedPortsFromAbstraction()\r\n//-----------------------------------------------------------------------------\r\nvoid PortListSortProxyModel::addConnectedPortsFromAbstraction()\r\n{\r\n    QStringList physicalPorts;\r\n    std::vector<std::string> portMapPhysicalPorts =\r\n        abstractionInterface_->getPhysicalPortsFromPortMaps(abstractionIndex_);\r\n    for (auto portName : portMapPhysicalPorts)\r\n    {\r\n        physicalPorts.append(QString::fromStdString(portName));\r\n    }\r\n\r\n    if (!physicalPorts.isEmpty())\r\n    {\r\n        for (auto portName : physicalPorts)\r\n        {\r\n            if (!connectedPorts_.contains(portName))\r\n            {\r\n                connectedPorts_.append(portName);\r\n            }\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PortListSortProxyModel::filterAcceptsRow()\r\n//-----------------------------------------------------------------------------\r\nbool PortListSortProxyModel::filterAcceptsRow(int source_row, const QModelIndex& source_parent) const\r\n{   \r\n    QModelIndex nameIndex = sourceModel()->index(source_row, 0);\r\n    QString portName = sourceModel()->data(nameIndex).toString();\r\n\r\n    // Check filter for direction.\r\n    QString directionString = QString::fromStdString(portInterface_->getDirection(portName.toStdString()));\r\n    DirectionTypes::Direction portDirection =\r\n        DirectionTypes::str2Direction(directionString, DirectionTypes::DIRECTION_INVALID);\r\n    if (filterDirection_ != DirectionFilter::ANY &&\r\n        portDirection != static_cast<DirectionTypes::Direction>(filterDirection_))\r\n    {\r\n        return false;\r\n    }\r\n\r\n    // Check filter for connected ports.\r\n    if (hideConnected_ && connectedPorts_.contains(portName))\r\n    {\r\n        return false;\r\n    }\r\n\r\n    // Check filter for allowed port names.\r\n    if (!filterPorts_.isEmpty() && !filterPorts_.contains(portName))\r\n    {\r\n        return false;\r\n    }\r\n    if (visibleType_ == PortTypes::WIRETYPE && !portInterface_->portIsWire(portName.toStdString()))\r\n    {\r\n        return false;\r\n    }\r\n    else if (visibleType_ == PortTypes::TRANSACTIONALTYPE &&\r\n        !portInterface_->portIsTransactional(portName.toStdString()))\r\n    {\r\n        return false;\r\n    }\r\n\r\n    // Check filter for port name.\r\n    return QSortFilterProxyModel::filterAcceptsRow(source_row, source_parent);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PortListSortProxyModel::filterAcceptsColumn()\r\n//-----------------------------------------------------------------------------\r\nbool PortListSortProxyModel::filterAcceptsColumn(int source_column, const QModelIndex &source_parent) const\r\n{\r\n    if ((visibleType_ == PortTypes::WIRETYPE && source_column == PortMappingColumns::INITIATIVE) ||\r\n        (visibleType_ == PortTypes::TRANSACTIONALTYPE &&\r\n            (source_column == PortMappingColumns::DIRECTION || source_column == PortMappingColumns::LEFT_BOUND ||\r\n            source_column == PortMappingColumns::RIGHT_BOUND)))\r\n    {\r\n        return false;\r\n    }\r\n    else\r\n    {\r\n        return QSortFilterProxyModel::filterAcceptsColumn(source_column, source_parent);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PortListSortProxyModel::onChangeFilteredType()\r\n//-----------------------------------------------------------------------------\r\nvoid PortListSortProxyModel::onChangeFilteredType(QString const& newVisibleType)\r\n{\r\n    visibleType_ = newVisibleType;\r\n    invalidateFilter();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PortListSortProxyModel::onPortConnected()\r\n//-----------------------------------------------------------------------------\r\nvoid PortListSortProxyModel::onPortConnected(QString const& portName)\r\n{\r\n    if (!connectedPorts_.contains(portName))\r\n    {\r\n        connectedPorts_.append(portName);\r\n        invalidateFilter();\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PortListSortProxyModel::onPortDisconnected()\r\n//-----------------------------------------------------------------------------\r\nvoid PortListSortProxyModel::onPortDisconnected(QString const& portName)\r\n{\r\n    for (int i = 0; i < portMapInterface_->itemCount(); ++i)\r\n    {\r\n        QString physicalPortName = QString::fromStdString(portMapInterface_->getPhysicalPortName(i));\r\n        if (physicalPortName == portName)\r\n        {\r\n            return;\r\n        }\r\n    }\r\n\r\n    connectedPorts_.removeAll(portName);\r\n    invalidateFilter();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PortListSortProxyModel::setNewAbstractionType()\r\n//-----------------------------------------------------------------------------\r\nvoid PortListSortProxyModel::setNewAbstractionType(int const& newAbstractionIndex)\r\n{\r\n    abstractionIndex_ = newAbstractionIndex;\r\n}\r\n"
  },
  {
    "path": "editors/ComponentEditor/busInterfaces/portmaps/PortListSortProxyModel.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: PortListSortProxyModel.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Esko Pekkarinen\r\n// Date: 05.08.2013\r\n//\r\n// Description:\r\n// Sorting proxy model for port lists.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef PORTLISTSORTPROXYMODEL_H\r\n#define PORTLISTSORTPROXYMODEL_H\r\n\r\n#include <IPXACTmodels/common/DirectionTypes.h>\r\n\r\n#include <QSortFilterProxyModel>\r\n#include <QSharedPointer>\r\n\r\nclass Component;\r\nclass AbstractionType;\r\nclass PortsInterface;\r\nclass AbstractionTypeInterface;\r\nclass PortMapInterface;\r\n\r\n//! The port types.\r\nnamespace PortTypes\r\n{\r\n    QString const WIRETYPE = QStringLiteral(\"Wire\");\r\n    QString const TRANSACTIONALTYPE = QStringLiteral(\"Transactional\");\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Sorting proxy for port list view.\r\n//-----------------------------------------------------------------------------\r\nclass PortListSortProxyModel : public QSortFilterProxyModel\r\n{\r\n    Q_OBJECT\r\n\r\npublic:\r\n\r\n    /*!\r\n\t *  Allowed direction filters.\r\n\t */  \r\n    enum class DirectionFilter\r\n    {\r\n        IN = DirectionTypes::IN,\r\n        OUT = DirectionTypes::OUT,\r\n        INOUT = DirectionTypes::INOUT,\r\n        ANY\r\n    };\r\n\r\n\t /*!\r\n      *  Constructor.\r\n      *\r\n      *    @param [in] abstractionIndex        Index of the containing abstraction type.\r\n      *    @param [in] portMapInterface        Interface for accessing port maps.\r\n      *    @param [in] abstractionInterface    Interface for accessing abstraction types.\r\n      *    @param [in] parent                  The parent object.\r\n      */\r\n    PortListSortProxyModel(int const& abstractionIndex,\r\n        PortMapInterface* portMapInterface,\r\n        AbstractionTypeInterface* abstractionInterface,\r\n        QObject *parent = 0);\r\n\r\n\t /*!\r\n      * Destructor.\r\n      */\r\n    virtual ~PortListSortProxyModel() = default;    \r\n\r\n    /*!\r\n\t *  Gets the filter for direction of the ports.\r\n\t *\r\n\t *    @return The accepted direction.\r\n\t */\r\n    DirectionFilter filterDirection() const;\r\n\r\n    /*!\r\n\t *  Gets the filter for hiding connected ports.\r\n\t *\r\n\t *    @return True, if ports are hidden, otherwise false.\r\n\t */\r\n    bool filterHideConnected() const;\r\n\r\n    /*!\r\n     *  Gets the filter for allowed port names.\r\n     *\r\n     *    @return The allowed port names.\r\n     */\r\n    QStringList filterPortNames() const;\r\n\r\n    /*!\r\n     *  Setup a new abstraction type for sorting.\r\n     *\r\n     *    @param [in] newAbstractionIndex     Index of the selected abstraction type.\r\n     */\r\n    void setNewAbstractionType(int const& newAbstractionIndex);\r\n\r\npublic slots:\r\n\t \r\n    /*!\r\n     *  Sets the filter for port name(s).\r\n     *\r\n     *    @param [in] portName   The allowed port name.\r\n     */\r\n    virtual void setFilterPortName(QString const& portName);\r\n\r\n    /*!\r\n     *  Sets the filter for port names.\r\n     *\r\n     *    @param [in] ports   Allowed port names.\r\n     */\r\n    virtual void setFilterPorts( QStringList const& ports );\r\n\r\n    /*!\r\n     *  Sets the filter for in-direction.\r\n     *\r\n     *    @param [in] enabled   If true, filter using in-direction.\r\n     */\r\n    virtual void setFilterInDirection(bool enabled);\r\n\r\n    /*!\r\n     *  Sets the filter for out-direction.\r\n     *\r\n     *    @param [in] filterOutDirection   If true, filter using out-direction.\r\n     */\r\n    virtual void setFilterOutDirection(bool filterOutDirection);\r\n\r\n    /*!\r\n\t *  Sets to show or hide already connected ports.\r\n\t *\r\n\t *    @param [in] hide  True, if ports are hidden, otherwise false.\r\n\t */\r\n    virtual void setFilterHideConnected(bool hide = true);\r\n\r\n    /*!\r\n\t *  Called when port mappings have been reset.\r\n\t */    \r\n    virtual void onConnectionsReset();\r\n\r\n    /*!\r\n     *  Called to update filtering when a port has been connected in a port map.\r\n     *\r\n     *    @param [in] portName   The name of the connected port.\r\n     */\r\n    virtual void onPortConnected(QString const& portName);\r\n\r\n    /*!\r\n     *  Called to update filtering when a port has been disconnected from all port maps.\r\n     *\r\n     *    @param [in] portName   The name of the disconnected port.\r\n     */\r\n    virtual void onPortDisconnected(QString const& portName);\r\n\r\n    /*!\r\n     *  Called to change the filtered port type.\r\n     *\r\n     *    @param [in] newVisibleType  The new visible port type.\r\n     */\r\n    virtual void onChangeFilteredType(QString const& newVisibleType);\r\n\r\nprotected:\r\n\r\n    /*!\r\n\t *  Implementation of the row filtering.\r\n\t *\r\n\t *    @param [in] source_row      The row to check for filtering.\r\n     *    @param [in] source_parent   The parent index of the row.\r\n     *\r\n     *    @return True, if the row passes the filters, otherwise false.\r\n\t */\r\n    virtual bool filterAcceptsRow(int source_row, const QModelIndex & source_parent) const override;\r\n\r\n    /*!\r\n     *  Implementation of the column filtering.\r\n     *\r\n     *    @param [in] source_column   The column to check for filtering.\r\n     *    @param [in] source_parent   Parent index of the row.\r\n     *\r\n     *    @return True, if the column passes the filters, otherwise false.\r\n     */\r\n    virtual bool filterAcceptsColumn(int source_column, const QModelIndex &source_parent) const override;\r\n\r\nprivate:\r\n    //! No copying\r\n    PortListSortProxyModel(const PortListSortProxyModel& other);\r\n\r\n    //! No assignment\r\n    PortListSortProxyModel& operator=(const PortListSortProxyModel& other);  \r\n    \r\n    /*!\r\n     *  Add connected physical ports from the selected abstraction type port mappings.\r\n     */\r\n    void addConnectedPortsFromAbstraction();\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! Filter for allowed direction.\r\n    DirectionFilter filterDirection_;\r\n\r\n    //! Filter for connected ports.\r\n    bool hideConnected_; \r\n\r\n    //! Already connected ports.\r\n    QStringList connectedPorts_;\r\n\r\n    //! Filter for allowed port names. If set to empty, all ports are allowed by the filter.\r\n    QStringList filterPorts_;\r\n\r\n    //! The currently visible port type.\r\n    QString visibleType_;\r\n\r\n    //! Interface for accessing port maps.\r\n    PortMapInterface* portMapInterface_;\r\n\r\n    //! Interface for accessing ports.\r\n    PortsInterface* portInterface_;\r\n\r\n    //! Index of the selected abstraction type.\r\n    int abstractionIndex_;\r\n\r\n    //! Interface for accessing abstraction types.\r\n    AbstractionTypeInterface* abstractionInterface_;\r\n};\r\n\r\n#endif // PORTLISTSORTPROXYMODEL_H"
  },
  {
    "path": "editors/ComponentEditor/busInterfaces/portmaps/PortMapAutoConnector.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: PortMapAutoConnector.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Mikko Teuho\r\n// Date: 03.06.2016\r\n//\r\n// Description:\r\n// Automatically forms port maps between logical and physical ports.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"PortMapAutoConnector.h\"\r\n\r\n#include \"JaroWinklerAlgorithm.h\"\r\n\r\n#include <KactusAPI/include/PortMapInterface.h>\r\n#include <KactusAPI/include/ExpressionParser.h>\r\n#include <KactusAPI/include/PortsInterface.h>\r\n#include <KactusAPI/include/PortAbstractionInterface.h>\r\n#include <KactusAPI/include/LibraryInterface.h>\r\n\r\n#include <IPXACTmodels/AbstractionDefinition/AbstractionDefinition.h>\r\n#include <IPXACTmodels/AbstractionDefinition/PortAbstraction.h>\r\n#include <IPXACTmodels/AbstractionDefinition/WireAbstraction.h>\r\n#include <IPXACTmodels/Component/Component.h>\r\n#include <IPXACTmodels/Component/BusInterface.h>\r\n#include <IPXACTmodels/Component/PortMap.h>\r\n\r\n#include <QtMath>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PortMapAutoConnector::PortMapAutoConnector()\r\n//-----------------------------------------------------------------------------\r\nPortMapAutoConnector::PortMapAutoConnector(PortMapInterface* portMapInterface, QObject* parent):\r\nQObject(parent),\r\nphysicalPrefix_(),\r\nportMapInterface_(portMapInterface)\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PortMapAutoConnector::~PortMapAutoConnector()\r\n//-----------------------------------------------------------------------------\r\nPortMapAutoConnector::~PortMapAutoConnector()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PortMapAutoConnector::onAutoConnect()\r\n//-----------------------------------------------------------------------------\r\nvoid PortMapAutoConnector::onAutoConnect()\r\n{\r\n    if (portMapInterface_ && portMapInterface_->itemCount() > 0)\r\n    {\r\n        QStringList selectedPorts;\r\n        for (int i = 0; i < portMapInterface_->itemCount(); ++i)\r\n        {\r\n            if (portMapInterface_->getPhysicalPortName(i).empty() &&\r\n                portMapInterface_->getLogicalTieOffValue(i).empty())\r\n            {\r\n                selectedPorts.append(QString::fromStdString(portMapInterface_->getLogicalPortName(i)));\r\n            }\r\n        }\r\n\r\n        connectSelectedLogicalPorts(selectedPorts);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PortMapAutoConnector::onAutoConnectLogicalSignals()\r\n//-----------------------------------------------------------------------------\r\nvoid PortMapAutoConnector::onAutoConnectLogicalSignals(QStringList const& logicalSignals)\r\n{\r\n    connectSelectedLogicalPorts(logicalSignals);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PortMapAutoConnector::setPrefix()\r\n//-----------------------------------------------------------------------------\r\nvoid PortMapAutoConnector::setPrefix(QString const& prefix)\r\n{\r\n    physicalPrefix_ = prefix;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PortMapAutoConnector::connectSelectedLogicalPorts()\r\n//-----------------------------------------------------------------------------\r\nvoid PortMapAutoConnector::connectSelectedLogicalPorts(QStringList const& logicalPorts)\r\n{\r\n    QList<PossiblePortMaps> possiblePairings;\r\n\r\n    PortAbstractionInterface* logicalInterface = portMapInterface_->getLogicalPortInterface();\r\n    for (auto logicalPort : logicalPorts)\r\n    {\r\n        std::string portName(logicalPort.toStdString());\r\n\r\n        QString presenceString(QString::fromStdString(\r\n            portMapInterface_->getLogicalPresenceWithLogicalPort(portName)));\r\n        PresenceTypes::Presence presence = PresenceTypes::str2Presence(presenceString, PresenceTypes::OPTIONAL);\r\n\r\n        if (presence != PresenceTypes::ILLEGAL)\r\n        {\r\n            QMultiMap<double, QString> physicalPorts = getWeightedPhysicalPorts(portName, logicalInterface);\r\n\r\n            PossiblePortMaps newPairing;\r\n            newPairing.logicalPort_ = logicalPort;\r\n            newPairing.possiblePhysicals_ = physicalPorts;\r\n\r\n            possiblePairings.append(newPairing);\r\n        }\r\n    }\r\n\r\n    QVector<QString> connectedPhysicals;\r\n\r\n    for (int i = 0; i < possiblePairings.size(); i++)\r\n    {\r\n        QString logicalPort(possiblePairings.at(i).logicalPort_);\r\n\r\n        QString bestMatchingPhysicalPort = getBestMatchingPhysicalPort(i, possiblePairings);\r\n\r\n        if (!bestMatchingPhysicalPort.isEmpty())\r\n        {\r\n            portMapInterface_->connectPorts(logicalPort.toStdString(), bestMatchingPhysicalPort.toStdString());\r\n            connectedPhysicals.append(bestMatchingPhysicalPort);\r\n        }\r\n    }\r\n\r\n    if (!connectedPhysicals.isEmpty())\r\n    {\r\n        emit portMapsAutoConnected(connectedPhysicals);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PortMapAutoConnector::getWeightedPhysicalPorts()\r\n//-----------------------------------------------------------------------------\r\nQMultiMap<double, QString> PortMapAutoConnector::getWeightedPhysicalPorts(std::string const& logicalPort,\r\n    PortAbstractionInterface* logicalInterface) const\r\n{\r\n    QMultiMap<double, QString> weightedPhysicalPorts;\r\n\r\n    General::InterfaceMode busMode = portMapInterface_->getInterfaceMode();\r\n    std::string systemGroup = portMapInterface_->getSystemGroup();\r\n\r\n    DirectionTypes::Direction logicalDirection =\r\n        logicalInterface->getDirection(logicalPort, busMode, systemGroup);\r\n\r\n    QMap<QString, double> availablePorts = getPortsByDirection(logicalDirection);\r\n    if (!availablePorts.isEmpty())\r\n    {\r\n        QMap<QString, double> availableWeightedPorts;\r\n\r\n        bool isValidWidth = false;\r\n        QString logicalWidth =\r\n            QString::fromStdString(logicalInterface->getWidthValue(logicalPort, busMode, systemGroup));\r\n\r\n        int logicalWidthInt = logicalWidth.toInt(&isValidWidth);\r\n\r\n        if (isValidWidth)\r\n        {\r\n            availableWeightedPorts = getPortsByLogicalWidth(logicalWidthInt, availablePorts);\r\n        }\r\n        else\r\n        {\r\n            availableWeightedPorts = availablePorts;\r\n        }\r\n\r\n        if (!availableWeightedPorts.isEmpty())\r\n        {\r\n            availableWeightedPorts =\r\n                weightPortsByLogicalName(QString::fromStdString(logicalPort), availableWeightedPorts);\r\n        }\r\n\r\n        QMapIterator<QString, double> weightIterator(availableWeightedPorts);\r\n        while (weightIterator.hasNext())\r\n        {\r\n            weightIterator.next();\r\n\r\n            weightedPhysicalPorts.insert(weightIterator.value(), weightIterator.key());\r\n        }\r\n    }\r\n\r\n    return weightedPhysicalPorts;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PortMapAutoConnector::getBestMatchingPhysicalPort()\r\n//-----------------------------------------------------------------------------\r\nQString PortMapAutoConnector::getBestMatchingPhysicalPort(int logicalIndex,\r\n    QList<PossiblePortMaps> const& possiblePairings) const\r\n{\r\n    QMultiMapIterator<double, QString> physicalIterator(possiblePairings.at(logicalIndex).possiblePhysicals_);\r\n    physicalIterator.toBack();\r\n\r\n    QStringList skipTheseLogicals;\r\n    while (physicalIterator.hasPrevious())\r\n    {\r\n        physicalIterator.previous();\r\n\r\n        QString physicalPort = physicalIterator.value();\r\n        double comparisonWeight = physicalIterator.key();\r\n\r\n        bool physicalFound = true;\r\n\r\n        for (int j = logicalIndex + 1; j < possiblePairings.size() && physicalFound; j++)\r\n        {\r\n            QString comparisonLogical = possiblePairings.at(j).logicalPort_;\r\n            double comparisonValue = possiblePairings.at(j).possiblePhysicals_.key(physicalPort);\r\n            if (skipTheseLogicals.contains(comparisonLogical) == false && comparisonValue > comparisonWeight)\r\n            {\r\n                physicalFound = false;\r\n                skipTheseLogicals.append(comparisonLogical);\r\n            }\r\n        }\r\n\r\n        if (physicalFound)\r\n        {\r\n            return physicalPort;\r\n        }\r\n    }\r\n\r\n    return QString();\r\n}\r\n\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PortMapAutoConnector::getPortsByDirection()\r\n//-----------------------------------------------------------------------------\r\nQMap<QString, double> PortMapAutoConnector::getPortsByDirection(\r\n    DirectionTypes::Direction logicalDirection) const\r\n{\r\n    PortsInterface const* portInterface = portMapInterface_->getPhysicalPortInterface();\r\n    QMap<QString, double> availablePorts;\r\n\r\n    for (auto portName : portInterface->getItemNames())\r\n    {\r\n        if (portInterface->getDirectionType(portName) == logicalDirection)\r\n        {\r\n            availablePorts.insert(QString::fromStdString(portName), 2);\r\n        }\r\n        else if ((logicalDirection == DirectionTypes::IN || logicalDirection == DirectionTypes::OUT) &&\r\n            portInterface->getDirectionType(portName) == DirectionTypes::INOUT)\r\n        {\r\n            availablePorts.insert(QString::fromStdString(portName), 0);\r\n        }\r\n    }\r\n\r\n    return availablePorts;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PortMapAutoConnector::getPortsByLogicalWidth()\r\n//-----------------------------------------------------------------------------\r\nQMap<QString, double> PortMapAutoConnector::getPortsByLogicalWidth(double logicalWidth,\r\n    QMap<QString, double> portList) const\r\n{\r\n    const double WIDTH_WEIGHT = 0.2;\r\n    PortsInterface* portInterface = portMapInterface_->getPhysicalPortInterface();\r\n\r\n    QMap<QString, double> widthMatchingPorts;\r\n\r\n    QMapIterator<QString, double> portIterator(portList);\r\n    while (portIterator.hasNext())\r\n    {\r\n        portIterator.next();\r\n\r\n        std::string portName = portIterator.key().toStdString();\r\n\r\n        int calculatedLeftBound = QString::fromStdString(portInterface->getLeftBoundValue(portName)).toInt();\r\n        int calculatedRightBound = QString::fromStdString(portInterface->getRightBoundValue(portName)).toInt();\r\n        double portWidth = abs(calculatedLeftBound - calculatedRightBound) + 1;\r\n        double widthSimilarity = WIDTH_WEIGHT * (qMin(logicalWidth, portWidth)/(qMax(logicalWidth, portWidth)));\r\n\r\n        widthMatchingPorts.insert(portIterator.key(), widthSimilarity + portIterator.value());\r\n    }\r\n\r\n    return widthMatchingPorts;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PortMapAutoConnector::getPortsByLogicalName()\r\n//-----------------------------------------------------------------------------\r\nQMap<QString, double> PortMapAutoConnector::weightPortsByLogicalName(QString const& logicalName,\r\n    QMap<QString, double> portList) const\r\n{\r\n    const double JARO_WINKLER_THRESHOLD = 0.75;\r\n    const double JARO_BONUS = 0.75;\r\n\r\n    QMap<QString, double> jaroDistancedPorts;\r\n\r\n    auto logicalIsPrefixed = false;\r\n    auto physicalIsPrefixed = false;\r\n\r\n\tauto modifiedLogicalName = logicalName;\r\n    if (physicalPrefix_.isEmpty() == false)\r\n    {\r\n        if (modifiedLogicalName.startsWith(physicalPrefix_))\r\n        {\r\n            modifiedLogicalName = modifiedLogicalName.remove(0, physicalPrefix_.size());\r\n            logicalIsPrefixed = true;\r\n        }\r\n    }\r\n\r\n    QMapIterator<QString, double> portIterator(portList);\r\n    while (portIterator.hasNext())\r\n    {\r\n        portIterator.next();        \r\n        QString physicalName = portIterator.key();\r\n\r\n        if (physicalPrefix_.isEmpty() == false)\r\n        {\r\n            if (physicalName.startsWith(physicalPrefix_))\r\n            {\r\n\t\t\t\tphysicalName = physicalName.remove(0, physicalPrefix_.size());\r\n                physicalIsPrefixed = true;\r\n            }\r\n            else\r\n            {\r\n                continue;\r\n            }\r\n        }\r\n\r\n\t\tdouble jaroDistance = 0;\r\n        if (physicalPrefix_.isEmpty())\r\n        {\r\n\t\t\tjaroDistance = JaroWinklerAlgorithm::calculateJaroWinklerDistance(physicalName, modifiedLogicalName);\r\n        }\r\n        else\r\n        {\r\n\t\t\tjaroDistance = JaroWinklerAlgorithm::calculateJaroDistance(physicalName, modifiedLogicalName);\r\n        }\r\n\r\n        if (physicalIsPrefixed && logicalIsPrefixed)\r\n        {\r\n            jaroDistance += JARO_BONUS;\r\n        }\r\n\r\n        if (jaroDistance >= JARO_WINKLER_THRESHOLD)\r\n        {\r\n            jaroDistancedPorts.insert(portIterator.key(), jaroDistance + portIterator.value());\r\n        }\r\n    }\r\n\r\n    return jaroDistancedPorts;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PortMapAutoConnector::reorderPortsToWeight()\r\n//-----------------------------------------------------------------------------\r\nQStringList PortMapAutoConnector::reorderPortsToWeight(QMap<QString, double> portList) const\r\n{\r\n    int portCount = portList.count();\r\n\r\n    QStringList reorderedPorts;\r\n\r\n    for (int i = 0; i < portCount; ++i)\r\n    {\r\n        double bestWeight = portList.first();\r\n        QString bestPort = portList.firstKey();\r\n\r\n        QMapIterator<QString, double> portIterator(portList);\r\n        while(portIterator.hasNext())\r\n        {\r\n            portIterator.next();\r\n\r\n            if (portIterator.value() > bestWeight)\r\n            {\r\n                bestWeight = portIterator.value();\r\n                bestPort = portIterator.key();\r\n            }\r\n        }\r\n\r\n        reorderedPorts.append(bestPort);\r\n        portList.remove(bestPort);\r\n    }\r\n\r\n    return reorderedPorts;\r\n}\r\n"
  },
  {
    "path": "editors/ComponentEditor/busInterfaces/portmaps/PortMapAutoConnector.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: PortMapAutoConnector.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Mikko Teuho\r\n// Date: 03.06.2016\r\n//\r\n// Description:\r\n// Automatically forms port maps between logical and physical ports.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef PORTMAPAUTOCONNECTOR_H\r\n#define PORTMAPAUTOCONNECTOR_H\r\n\r\n#include <IPXACTmodels/generaldeclarations.h>\r\n\r\n#include <IPXACTmodels/common/DirectionTypes.h>\r\n\r\n#include <QObject>\r\n#include <QSharedPointer>\r\n#include <QMap>\r\n\r\nclass Component;\r\nclass AbstractionDefinition;\r\nclass VLNV;\r\nclass LibraryInterface;\r\nclass Port;\r\nclass PortAbstraction;\r\nclass ExpressionParser;\r\nclass PortMap;\r\nclass AbstractionType;\r\nclass PortMapInterface;\r\nclass PortAbstractionInterface;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Automatically forms port maps between logical and physical ports.\r\n//-----------------------------------------------------------------------------\r\nclass PortMapAutoConnector : public QObject\r\n{\r\n    Q_OBJECT\r\n\r\npublic:\r\n\r\n    /*!\r\n     *  The constructor.\r\n     *\r\n     *    @param [in] portMapInterface    Interface for accessing port maps.\r\n     *    @param [in] parent              The owner of this object.\r\n     */\r\n    PortMapAutoConnector(PortMapInterface* portMapInterface,\r\n        QObject* parent);\r\n\r\n    /*!\r\n     *  The destructor.\r\n     */\r\n    ~PortMapAutoConnector();\r\n\r\npublic slots:\r\n\r\n    /*!\r\n     *  Handler for automatic connection.\r\n     */\r\n    void onAutoConnect();\r\n\r\n    /*!\r\n     *  Handler for selective automatic connection.\r\n     *\r\n     *    @param [in] logicalSignals  The selected logical signals to be connected.\r\n     */\r\n    void onAutoConnectLogicalSignals(QStringList const& logicalSignals);\r\n\r\n    /*!\r\n     *  Sets a prefix for matching physical names to logical ports.\r\n     *\r\n     *    @param [in] prefix   The prefix to set.\r\n     */\r\n    void setPrefix(QString const& prefix);\r\n\r\nsignals:\r\n\r\n    /*!\r\n     *  Inform of a new port map.\r\n     *\r\n     *    @param [in] physicalPorts   List of the best matching physical ports.\r\n     */\r\n    void portMapsAutoConnected(QVector<QString> physicalPorts);\r\n\r\nprivate:\r\n\r\n    // Disable copying.\r\n    PortMapAutoConnector(PortMapAutoConnector const& rhs);\r\n    PortMapAutoConnector& operator=(PortMapAutoConnector const& rhs);\r\n\r\n    //! Structure for possible logical-physical pairs.\r\n    struct PossiblePortMaps\r\n    {\r\n        //! The logical signal name.\r\n        QString logicalPort_;\r\n\r\n        //! Possible physical ports in the order of their weights.\r\n        QMultiMap<double, QString> possiblePhysicals_;\r\n    };\r\n\r\n    /*!\r\n     *  Connect the selected logical signals.\r\n     *\r\n     *    @param [in] logicalPorts    List of the selected logical signals.\r\n     */\r\n    void connectSelectedLogicalPorts(QStringList const& logicalPorts);\r\n\r\n    /*!\r\n     *  Get the possible physical ports for the selected logical port.\r\n     *\r\n     *    @param [in] logicalPort         The selected logical port.\r\n     *    @param [in] logicalInterface    Interface for accessing logical ports.\r\n     *\r\n     *    @return The possible physical ports combined with weights.\r\n     */\r\n    QMultiMap<double, QString> getWeightedPhysicalPorts(std::string const& logicalPort,\r\n        PortAbstractionInterface* logicalInterface) const;\r\n\r\n    /*!\r\n     *  Get the best matching physical port. If another logical signal has the same port with a better value, it\r\n     *  is ignored.\r\n     *\r\n     *    @param [in] logicalPort         The selected logical port.\r\n     *    @param [in] logicalIndex        Index of the logical port.\r\n     *    @param [in] possiblePairings    A list of the possible logical-physical pairings.\r\n     *\r\n     *    @return Name of the best matching physical port.\r\n     */\r\n    QString getBestMatchingPhysicalPort(int logicalIndex,\r\n        QList<PossiblePortMaps> const& possiblePairings) const;\r\n\r\n    /*!\r\n     *  Get a list of possible weighted ports by the direction of the given logical direction.\r\n     *\r\n     *    @param [in] direction     Direction of the selected logical port.\r\n     *\r\n     *    @return A list of weighted physical ports with a suitable direction to the logical port.\r\n     */\r\n    QMap<QString, double> getPortsByDirection(DirectionTypes::Direction logicalDirection) const;\r\n\r\n    /*!\r\n     *  Get a list of physical ports weighted by the width of the logical port.\r\n     *\r\n     *    @param [in] logicalWidth    The width of the selected logical port.\r\n     *    @param [in] portList        Names of the available weighted physical ports.\r\n     *\r\n     *    @return A list of physical ports weighted by suitability to logical width.\r\n     */\r\n    QMap<QString, double> getPortsByLogicalWidth(double logicalWidth, QMap<QString, double> portList) const;\r\n\r\n    /*!\r\n     *  Get a list of physical ports weighted by the name of the logical port.\r\n     *\r\n     *    @param [in] logicalName     The name of the logical port.\r\n     *    @param [in] portList        A list of available weighted physical ports.\r\n     *\r\n     *    @return A list of physical ports weighted by the name of the logical port.\r\n     */\r\n    QMap<QString, double> weightPortsByLogicalName(QString const& logicalName, QMap<QString, double> portList) const;\r\n\r\n    /*!\r\n     *  Reorder the ports according to their weights.\r\n     *\r\n     *    @param [in] portList    A list of weighter physical ports.\r\n     *\r\n     *    @return A list of port names reordered according to the weights.\r\n     */\r\n    QStringList reorderPortsToWeight(QMap<QString, double> portList) const;\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //----------------------------------------------------------------------------- \r\n\r\n    //! Prefix for physical ports.\r\n    QString physicalPrefix_;\r\n\r\n    //! Interface for accessing port maps.\r\n    PortMapInterface* portMapInterface_;\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n\r\n#endif // PORTMAPAUTOCONNECTOR_H\r\n"
  },
  {
    "path": "editors/ComponentEditor/busInterfaces/portmaps/PortMapDelegate.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: PortMapDelegate.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 01.06.2022\n//\n// Description:\n// Delegate to provide editors to edit bus interface port maps.\n//-----------------------------------------------------------------------------\n\n#include \"PortMapDelegate.h\"\n\n\n#include <editors/ComponentEditor/busInterfaces/portmaps/PortMapsColumns.h>\n\n#include <KactusAPI/include/PortAbstractionInterface.h>\n#include <KactusAPI/include/PortMapInterface.h>\n#include <KactusAPI/include/PortsInterface.h>\n\n#include <QApplication>\n#include <QMouseEvent>\n\n//-----------------------------------------------------------------------------\n// Function: PortMapDelegate::PortMapDelegate()\n//-----------------------------------------------------------------------------\nPortMapDelegate::PortMapDelegate(QAbstractItemModel* completionModel, QSharedPointer<ParameterFinder> finder,\n    PortMapInterface* portMapInterface, QObject *parent):\nExpressionDelegate(completionModel, finder, parent),\ninvertModify_(false),\ninvertCheckState_(Qt::Unchecked),\nportMapInterface_(portMapInterface),\nbusMode_(General::INTERFACE_MODE_COUNT),\nsystemGroup_(\"\")\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortMapDelegate::setBusMode()\n//-----------------------------------------------------------------------------\nvoid PortMapDelegate::setBusMode(General::InterfaceMode newMode)\n{\n    busMode_ = newMode;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortMapDelegate::setSystemGroup()\n//-----------------------------------------------------------------------------\nvoid PortMapDelegate::setSystemGroup(QString const& newSystemGroup)\n{\n    systemGroup_ = newSystemGroup;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortMapDelegate::createEditor()\n//-----------------------------------------------------------------------------\nQWidget* PortMapDelegate::createEditor(QWidget* parent, const QStyleOptionViewItem& option,\n    const QModelIndex& index) const\n{\n    if (index.column() == PortMapsColumns::LOGICAL_PORT)\n    {\n        QComboBox* logicalSelector = new QComboBox(parent);\n        logicalSelector->addItem(\"\");\n\n        PortAbstractionInterface* logicalInterface = portMapInterface_->getLogicalPortInterface();\n        std::string busModeString = General::interfaceMode2Str(busMode_).toStdString();\n        std::string systemGroupString = systemGroup_.toStdString();\n\n        QStringList logicalPortNames;\n\n        for (auto portName : logicalInterface->getItemNamesWithModeAndGroup(busModeString, systemGroupString))\n        {\n            logicalPortNames.append(QString::fromStdString(portName));\n        }\n\n        logicalSelector->addItems(logicalPortNames);\n\n        setLogicalPortDirectionIcons(logicalPortNames, logicalSelector);\n\n        return logicalSelector;\n    }\n    else if (index.column() == PortMapsColumns::PHYSICAL_PORT)\n    {\n        QComboBox* portSelector = new QComboBox(parent);\n        portSelector->addItem(\"\");\n\n        QStringList physicalPortNames;\n        for (auto portName : portMapInterface_->getPhysicalPortInterface()->getItemNames())\n        {\n            physicalPortNames.append(QString::fromStdString(portName));\n        }\n\n        portSelector->addItems(physicalPortNames);\n\n        setPhysicalPortDirectionIcons(physicalPortNames, portSelector);\n\n        return portSelector;\n    }\n\n    return ExpressionDelegate::createEditor(parent, option, index);\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortMapDelegate::setPhysicalPortDirectionIcons()\n//-----------------------------------------------------------------------------\nvoid PortMapDelegate::setPhysicalPortDirectionIcons(QStringList const& physicalPortNames, QComboBox* portSelector)\nconst\n{\n    for (auto portName : physicalPortNames)\n    {\n        QString iconPath(QString::fromStdString(\n            portMapInterface_->getPhysicalPortInterface()->getIconPathForPort(portName.toStdString())));\n\n        QIcon directionIcon(iconPath);\n        int itemIndex = portSelector->findText(portName);\n\n        portSelector->setItemIcon(itemIndex, directionIcon);\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortMapDelegate::setLogicalPortDirectionIcons()\n//-----------------------------------------------------------------------------\nvoid PortMapDelegate::setLogicalPortDirectionIcons(QStringList const& physicalPortNames, QComboBox* portSelector)\nconst\n{\n    PortAbstractionInterface* portInterface = portMapInterface_->getLogicalPortInterface();\n\n    std::string busModeString = General::interfaceMode2Str(busMode_).toStdString();\n    std::string systemGroup = systemGroup_.toStdString();\n\n    for (auto portName : physicalPortNames)\n    {\n        QString iconPath(QString::fromStdString(portInterface->getIconPathForSignal(\n            portName.toStdString(), busModeString, systemGroup)));\n\n        QIcon directionIcon(iconPath);\n        int itemIndex = portSelector->findText(portName);\n\n        portSelector->setItemIcon(itemIndex, directionIcon);\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortMapDelegate::setEditorData()\n//-----------------------------------------------------------------------------\nvoid PortMapDelegate::setEditorData(QWidget* editor, const QModelIndex& index) const\n{\n    if (index.column() == PortMapsColumns::LOGICAL_PORT || index.column() == PortMapsColumns::PHYSICAL_PORT)\n    {\n        QString text = index.data(Qt::DisplayRole).toString();\n\n        QComboBox* portSelector = qobject_cast<QComboBox*>(editor);\n        if (portSelector)\n        {\n            int portIndex = portSelector->findText(text);\n            portSelector->setCurrentIndex(portIndex);\n        }\n    }\n    else\n    {\n        ExpressionDelegate::setEditorData(editor, index);\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortMapDelegate::setModelData()\n//-----------------------------------------------------------------------------\nvoid PortMapDelegate::setModelData(QWidget* editor, QAbstractItemModel* model, const QModelIndex& index) const\n{\n    if (index.column() == PortMapsColumns::LOGICAL_PORT || index.column() == PortMapsColumns::PHYSICAL_PORT)\n    {\n        QComboBox* portSelector = qobject_cast<QComboBox*>(editor);\n\n        QString text = portSelector->currentText();\n        model->setData(index, text, Qt::EditRole);\n    }\n    else\n    {\n        ExpressionDelegate::setModelData(editor, model, index);\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortMapDelegate::paint()\n//-----------------------------------------------------------------------------\nvoid PortMapDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const\n{\n\tQStyleOptionViewItem viewItemOption(option);\n\n    if (index.column() == PortMapsColumns::INVERT || index.column() == PortMapsColumns::ISINFORMATIVE)\n    {\n        QVariant colourVariant = index.data(Qt::BackgroundRole);\n        QColor backgroundColour = colourVariant.value<QColor>();\n\n        painter->fillRect(option.rect, backgroundColour);\n\n        const int textMargin = QApplication::style()->pixelMetric(QStyle::PM_FocusFrameHMargin) + 1;\n\n        QRect newRect = QStyle::alignedRect(option.direction, Qt::AlignCenter,\n            QSize(option.decorationSize.width() + 5, option.decorationSize.height()),\n            QRect(option.rect.x() + textMargin, option.rect.y(),\n            option.rect.width() - (2 * textMargin), option.rect.height()));\n\n        viewItemOption.rect = newRect;\n    }\n\n    QStyledItemDelegate::paint(painter, viewItemOption, index);\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortMapDelegate::columnAcceptsExpression()\n//-----------------------------------------------------------------------------\nbool PortMapDelegate::columnAcceptsExpression(int column) const\n{\n    return column == PortMapsColumns::LOGICAL_LEFT || column == PortMapsColumns::LOGICAL_RIGHT ||\n        column == PortMapsColumns::PHYSICAL_LEFT || column == PortMapsColumns::PHYSICAL_RIGHT ||\n        column == PortMapsColumns::TIEOFF;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortMapDelegate::descriptionColumn()\n//-----------------------------------------------------------------------------\nint PortMapDelegate::descriptionColumn() const\n{\n    return -1;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortMapDelegate::updateEditorGeometry()\n//-----------------------------------------------------------------------------\nvoid PortMapDelegate::updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option,\n    const QModelIndex &index) const\n{\n    ExpressionDelegate::updateEditorGeometry(editor, option, index);\n\n    if (index.column() == PortMapsColumns::PHYSICAL_PORT)\n    {\n        QComboBox* portSelector = dynamic_cast<QComboBox*>(editor);\n        if (portSelector)\n        {\n            int optionWidth = option.rect.width();\n\n            portSelector->move(option.rect.topLeft());\n            portSelector->setMinimumWidth(optionWidth);\n        }\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortMapDelegate::editorEvent()\n//-----------------------------------------------------------------------------\nbool PortMapDelegate::editorEvent(QEvent *event, QAbstractItemModel *model, const QStyleOptionViewItem &option,\n    const QModelIndex &index)\n{\n    Q_ASSERT(event);\n    Q_ASSERT(model);\n\n    // Always reset the ad-hoc group modify flag.\n    if (event->type() == QEvent::MouseButtonRelease)\n    {\n        invertModify_ = false;\n    }\n\n    // Make sure that the item is checkable.\n    Qt::ItemFlags flags = model->flags(index);\n\n    if (!(flags & Qt::ItemIsUserCheckable) || !(flags & Qt::ItemIsEnabled))\n    {\n        return false;\n    }\n\n    // Make sure that we have a check state.\n    QVariant value = index.data(Qt::CheckStateRole);\n\n    if (!value.isValid())\n    {\n        return false;\n    }\n\n    Qt::CheckState newState = static_cast<Qt::CheckState>(value.toInt());\n\n    // Handle the mouse button events.\n    if (event->type() == QEvent::MouseButtonPress)\n    {\n        const int textMargin = QApplication::style()->pixelMetric(QStyle::PM_FocusFrameHMargin) + 1;\n\n        QRect checkRect = QStyle::alignedRect(option.direction, Qt::AlignCenter,\n            option.decorationSize,\n            QRect(option.rect.x() + (2 * textMargin), option.rect.y(),\n            option.rect.width() - (2 * textMargin),\n            option.rect.height()));\n\n        if (!checkRect.contains(static_cast<QMouseEvent*>(event)->pos()))\n        {\n            return false;\n        }\n\n        newState = (static_cast<Qt::CheckState>(value.toInt()) == Qt::Checked ? Qt::Unchecked : Qt::Checked);\n        invertModify_ = true;\n        invertCheckState_ = newState;\n    }\n    else if (event->type() == QEvent::MouseMove)\n    {\n        if (!invertModify_ || static_cast<Qt::CheckState>(value.toInt()) == invertCheckState_)\n        {\n            return false;\n        }\n\n        const int textMargin = QApplication::style()->pixelMetric(QStyle::PM_FocusFrameHMargin) + 1;\n\n        QRect checkRect = QStyle::alignedRect(option.direction, Qt::AlignCenter,\n            option.decorationSize,\n            QRect(option.rect.x() + (2 * textMargin), option.rect.y(),\n            option.rect.width() - (2 * textMargin),\n            option.rect.height()));\n\n        if (!checkRect.contains(static_cast<QMouseEvent*>(event)->pos()))\n        {\n            return false;\n        }\n\n        newState = invertCheckState_;\n    }\n    else if (event->type() == QEvent::KeyPress)\n    {\n        if (static_cast<QKeyEvent*>(event)->key() != Qt::Key_Space &&\n            static_cast<QKeyEvent*>(event)->key() != Qt::Key_Select)\n        {\n            return false;\n        }\n    }\n    else\n    {\n        return false;\n    }\n\n    return model->setData(index, newState, Qt::CheckStateRole);\n}\n"
  },
  {
    "path": "editors/ComponentEditor/busInterfaces/portmaps/PortMapDelegate.h",
    "content": "//-----------------------------------------------------------------------------\n// File: PortMapDelegate.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 01.06.2022\n//\n// Description:\n// Delegate to provide editors to edit bus interface port maps.\n//-----------------------------------------------------------------------------\n\n#ifndef PORTMAPDELEGATE_H\n#define PORTMAPDELEGATE_H\n\n#include <editors/ComponentEditor/common/ExpressionDelegate.h>\n\n#include <IPXACTmodels/generaldeclarations.h>\n\n#include <QPainter>\n#include <QComboBox>\n\nclass PortMapInterface;\n\n//-----------------------------------------------------------------------------\n//! Delegate to provide editors to edit bus interface port maps.\n//-----------------------------------------------------------------------------\nclass PortMapDelegate : public ExpressionDelegate\n{\n\tQ_OBJECT\n\npublic:\n\n\t/*!\n     *  The constructor.\n\t *\n     *    @param [in] completionModel     Model containing the completions used in expression editor.\n     *    @param [in] finder              The parameter finder.\n     *    @param [in] portMapInterface    Interface for accessing port maps.\n\t *    @param [in] parent              The owner of this delegate.\n\t */\n\tPortMapDelegate(QAbstractItemModel* completionModel,\n        QSharedPointer<ParameterFinder> finder,\n        PortMapInterface* portMapInterface,\n        QObject *parent);\n\t\n\t/*!\n     *  The destructor.\n     */\n    virtual ~PortMapDelegate() = default;\n\n    /*!\n     *  Set a new bus interface mode.\n     *\n     *    @param [in] newMode     The new bus interface mode.\n     */\n    void setBusMode(General::InterfaceMode newMode);\n\n    /*!\n     *  Set a new system group.\n     *\n     *    @param [in] newSystemGroup  The new system group.\n     */\n    void setSystemGroup(QString const& newSystemGroup);\n\n    /*!\n\t *  Create a new editor for the given item.\n\t *\n\t *    @param [in] parent  Owner for the editor.\n\t *    @param [in] option  Contains options for the editor.\n\t *    @param [in] index   Model index identifying the item.\n     *\n     *    @return Pointer to the editor to be used to edit the item.\n\t */\n\tvirtual QWidget* createEditor(QWidget* parent, const QStyleOptionViewItem& option, const QModelIndex& index)\n        const;\n\n    /*!\n\t *  Set the data for the editor.\n\t *\n\t *    @param [in] editor  Pointer to the editor where the data is to be set.\n\t *    @param [in] index   The index of the item that's data is to be set.\n\t */\n\tvirtual void setEditorData(QWidget* editor, const QModelIndex& index) const;\n\n    /*!\n\t *  Save the data from the editor to the model.\n\t *\n\t *    @param [in] editor  Pointer to the editor that contains the data to store.\n\t *    @param [in] model   Model that contains the data structure where data is to be saved to.\n\t *    @param [in] index   The index of the item that's data is to be saved.\n\t */\n\tvirtual void setModelData(QWidget* editor, QAbstractItemModel* model, const QModelIndex& index) const;\n\n    /*!\n     *  Paint the memory maps.\n     *\n     *    @param [in] painter     The used painter.\n     *    @param [in] option      Available style options.\n     *    @param [in] index       The current index.\n     */\n    virtual void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const;\n    \n    /*!\n     *  Updates the editor geometry.\n     *\n     *    @param [in] editor  The editor being updated.\n     *    @param [in] option  The options used to update the editor.\n     *    @param [in] index   The model index being edited.\n     */\n    virtual void updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option,\n        const QModelIndex &index) const;\n\nprotected:\n\n    /*!\n     *  Column for the description.\n     *\n     *    @return -1. Port maps do not have a description column.\n     */\n    virtual int descriptionColumn() const;\n\n    /*!\n     *  Check if the selected column accepts expressions.\n     *\n     *    @param [in] column  The selected column.\n     *\n     *    @return True, if the column accepts expressions, otherwise false.\n     */\n    virtual bool columnAcceptsExpression(int column) const;\n\n    /*!\n     *  The editor events.\n     *\n     *    @param [in] event   The event itself.\n     *    @param [in] model   The used item model.\n     *    @param [in] option  The style options.\n     *    @param [in] index   The current model index.\n     */\n    virtual bool editorEvent(QEvent *event, QAbstractItemModel *model, const QStyleOptionViewItem &option,\n        const QModelIndex &index);\n\nprivate:\n\n\t//! No copying.\n\tPortMapDelegate(const PortMapDelegate& other);\n    PortMapDelegate& operator=(const PortMapDelegate& other);\n\n    /*!\n     *  Set direction icons for the physical port selector.\n     *\n     *    @param [in] portSelector    The port selector.\n     */\n    void setPhysicalPortDirectionIcons(QStringList const& physicalPortNames, QComboBox* portSelector) const;\n\n    /*!\n     *  Set direction icons for the logical port selector.\n     *\n     *    @param [in] portSelector    The port selector.\n     */\n    void setLogicalPortDirectionIcons(QStringList const& physicalPortNames, QComboBox* portSelector) const;\n\n    //-----------------------------------------------------------------------------\n    // Data.\n    //-----------------------------------------------------------------------------\n\n    //! Invert modify for checkbox editor.\n    bool invertModify_;\n\n    //! The new state for invert.\n    Qt::CheckState invertCheckState_;\n\n    //! Interface for accessing port maps.\n    PortMapInterface* portMapInterface_;\n\n    //! The available bus interface mode.\n    General::InterfaceMode busMode_;\n    \n    //! The available system group.\n    QString systemGroup_;\n};\n\n#endif // PORTMAPDELEGATE_H\n"
  },
  {
    "path": "editors/ComponentEditor/busInterfaces/portmaps/PortMapHeaderView.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: PortMapHeaderView.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Mikko Teuho\r\n// Date: 08.06.2016\r\n//\r\n// Description:\r\n// Header view for port map editor.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"PortMapHeaderView.h\"\r\n\r\n#include <editors/ComponentEditor/busInterfaces/portmaps/PortMapsColumns.h>\r\n\r\n#include <QPainter>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PortMapHeaderView::PortMapHeaderView()\r\n//-----------------------------------------------------------------------------\r\nPortMapHeaderView::PortMapHeaderView(Qt::Orientation orientation, QWidget* parent):\r\nQHeaderView(orientation, parent)\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PortMapHeaderView::~PortMapHeaderView()\r\n//-----------------------------------------------------------------------------\r\nPortMapHeaderView::~PortMapHeaderView()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PortMapHeaderView::paintSection()\r\n//-----------------------------------------------------------------------------\r\nvoid PortMapHeaderView::paintSection(QPainter *painter, const QRect &rect, int logicalIndex) const\r\n{\r\n    painter->save();\r\n    QHeaderView::paintSection(painter, rect, logicalIndex);\r\n    painter->restore();\r\n\r\n    if (logicalIndex == PortMapsColumns::LOGICAL_PRESENCE || logicalIndex == PortMapsColumns::ISINFORMATIVE)\r\n    {\r\n        QPen oldPen = painter->pen();\r\n        QPen newPen(Qt::lightGray);\r\n        newPen.setWidth(2);\r\n\r\n        painter->setPen(newPen);\r\n        painter->drawLine(rect.topRight(), rect.bottomRight());\r\n        painter->setPen(oldPen);\r\n    }\r\n}\r\n"
  },
  {
    "path": "editors/ComponentEditor/busInterfaces/portmaps/PortMapHeaderView.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: PortMapHeaderView.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Mikko Teuho\r\n// Date: 08.06.2016\r\n//\r\n// Description:\r\n// Header view for port map editor.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef PORTMAPHEADERVIEW_H\r\n#define PORTMAPHEADERVIEW_H\r\n\r\n#include <QHeaderView>\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Header view for port map editor.\r\n//-----------------------------------------------------------------------------\r\nclass PortMapHeaderView : public QHeaderView\r\n{\r\n\r\npublic:\r\n    /*!\r\n     *  The constructor.\r\n     *\r\n     *    @param [in] orientation     The headers orientation.\r\n     *    @param [in] parent          The parent of the header.\r\n     */\r\n    PortMapHeaderView(Qt::Orientation orientation, QWidget* parent = 0);\r\n\r\n    /*!\r\n     *  The destructor.\r\n     */\r\n    virtual ~PortMapHeaderView();\r\n\r\nprotected:\r\n    \r\n    /*!\r\n     *  The re-implemented paint section.\r\n     *\r\n     *    @param [in] painter         The given painter.\r\n     *    @param [in] rect            The given rectangle.\r\n     *    @param [in] logicalIndex    Specifies the section.\r\n     */\r\n    virtual void paintSection(QPainter *painter, const QRect &rect, int logicalIndex) const;\r\n\r\nprivate:\r\n\r\n    //! Disable copying and assignment\r\n    PortMapHeaderView(const PortMapHeaderView& other);\r\n    PortMapHeaderView& operator=(const PortMapHeaderView& other);\r\n};\r\n\r\n#endif // PORTMAPHEADERVIEW_H"
  },
  {
    "path": "editors/ComponentEditor/busInterfaces/portmaps/PortMapModel.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: PortMapModel.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 30.05.2022\n//\n// Description:\n// A model for displaying bus interface port maps.\n//-----------------------------------------------------------------------------\n\n#include \"PortMapModel.h\"\n\n#include \"PortMapsColumns.h\"\n\n#include <common/KactusColors.h>\n\n#include <KactusAPI/include/PortMapInterface.h>\n\n#include <IPXACTmodels/common/PresenceTypes.h>\n\n#include <QIcon>\n#include <QMimeData>\n\n//-----------------------------------------------------------------------------\n// Function: PortMapModel::PortMapModel()\n//-----------------------------------------------------------------------------\nPortMapModel::PortMapModel(QSharedPointer<ParameterFinder> parameterFinder, PortMapInterface* portMapInterface,\n    QObject* parent):\nReferencingTableModel(parameterFinder, parent),\nParameterizableTable(parameterFinder),\nportMapInterface_(portMapInterface)\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortMapModel::columnCount()\n//-----------------------------------------------------------------------------\nint PortMapModel::columnCount(const QModelIndex&) const\n{\n    return PortMapsColumns::COLUMN_COUNT;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortMapModel::rowCount()\n//-----------------------------------------------------------------------------\nint PortMapModel::rowCount(const QModelIndex &parent) const\n{\n    if (parent.isValid())\n    {\n        return 0;\n    }\n    else\n    {\n        return portMapInterface_->itemCount();\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortMapModel::headerData()\n//-----------------------------------------------------------------------------\nQVariant PortMapModel::headerData(int section, Qt::Orientation orientation, int role) const\n{\n    if (orientation == Qt::Horizontal)\n    {\n        if (role == Qt::DisplayRole)\n        {\n            if (section == PortMapsColumns::LOGICAL_PORT)\n            {\n                return tr(\"Logical signal\");\n            }\n            else if (section == PortMapsColumns::LOGICAL_PRESENCE)\n            {\n                return tr(\"Requirement\");\n            }\n            else if (section == PortMapsColumns::LOGICAL_LEFT)\n            {\n                QString logicalLeft = tr(\"Logical left\") + getExpressionSymbol();\n                return logicalLeft;\n            }\n            else if (section == PortMapsColumns::LOGICAL_RIGHT)\n            {\n                QString logicalRight = tr(\"Logical right\") + getExpressionSymbol();\n                return logicalRight;\n            }\n            else if (section == PortMapsColumns::PHYSICAL_PORT)\n            {\n                return tr(\"Physical port\");\n            }\n            else if (section == PortMapsColumns::PHYSICAL_LEFT)\n            {\n                QString physicalLeft = tr(\"Physical left\") + getExpressionSymbol();\n                return physicalLeft;\n            }\n            else if (section == PortMapsColumns::PHYSICAL_RIGHT)\n            {\n                QString physicalRight = tr(\"Physical right\") + getExpressionSymbol();\n                return physicalRight;\n            }\n            else if (section == PortMapsColumns::INVERT)\n            {\n                return tr(\"Invert\");\n            }\n            else if (section == PortMapsColumns::ISINFORMATIVE)\n            {\n                return tr(\"Informative\");\n            }\n            else if (section == PortMapsColumns::TIEOFF)\n            {\n                QString tieOff = tr(\"Tie Off\") + getExpressionSymbol();\n                return tieOff;\n            }\n        }\n\n        else if (role == Qt::TextAlignmentRole)\n        {\n            return Qt::AlignCenter;\n        }\n    }\n\n    return QVariant();\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortMapModel::data()\n//-----------------------------------------------------------------------------\nQVariant PortMapModel::data(QModelIndex const& index, int role) const\n{\n    if (!indexIsValid(index))\n    {\n        return QVariant();\n    }\n\n    int portMapIndex = index.row();\n    if (role == Qt::DisplayRole)\n    {\n        return formattedExpressionForIndex(index);\n    }\n\n    else if (role == Qt::CheckStateRole &&\n        (index.column() == PortMapsColumns::INVERT || index.column() == PortMapsColumns::ISINFORMATIVE))\n    {\n        if ((index.column() == PortMapsColumns::INVERT && portMapInterface_->getInvertValue(portMapIndex).toBool())\n            ||\n            (index.column() == PortMapsColumns::ISINFORMATIVE &&\n                portMapInterface_->getIsInformativeValue(portMapIndex)))\n        {\n            return Qt::Checked;\n        }\n        else\n        {\n            return Qt::Unchecked;\n        }\n    }\n\n    else if (role == Qt::EditRole)\n    {\n        return expressionOrValueForIndex(index);\n    }\n    else if (role == Qt::ToolTipRole)\n    {\n        return valueForIndex(index);\n    }\n    else if (role == Qt::ForegroundRole)\n    {\n        if (index.column() == PortMapsColumns::LOGICAL_PRESENCE)\n        {\n            return KactusColors::DISABLED_TEXT;\n        }\n        return blackForValidOrRedForInvalidIndex(index);\n    }\n    else if (role == Qt::DecorationRole)\n    {\n        if (!index.parent().isValid() && index.column() == PortMapsColumns::LOGICAL_PORT)\n        {\n            return QIcon(QString::fromStdString(portMapInterface_->getLogicalPortIconPath(portMapIndex)));\n        }\n        else if (index.column() == PortMapsColumns::PHYSICAL_PORT)\n        {\n            return QIcon(QString::fromStdString(portMapInterface_->getPhysicalPortIconPath(portMapIndex)));\n        }\n    }\n    else if (role == Qt::SizeHintRole)\n    {\n        return QSize(100, 20);\n    }\n    else if (role == Qt::UserRole + 1)\n    {\n        return portMapInterface_->logicalPortExists(portMapIndex);\n    }\n\n    // Unsupported role.\n    return QVariant();\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortMapModel::formattedExpressionForIndex()\n//-----------------------------------------------------------------------------\nQVariant PortMapModel::formattedExpressionForIndex(QModelIndex const& index) const\n{\n    if (index.column() == PortMapsColumns::LOGICAL_LEFT)\n    {\n        return QString::fromStdString(portMapInterface_->getLogicalLeftBoundFormattedExpression(index.row()));\n    }\n    else if (index.column() == PortMapsColumns::LOGICAL_RIGHT)\n    {\n        return QString::fromStdString(portMapInterface_->getLogicalRightBoundFormattedExpression(index.row()));\n    }\n    else if (index.column() == PortMapsColumns::PHYSICAL_LEFT)\n    {\n        return QString::fromStdString(portMapInterface_->getPhysicalLeftBoundFormattedExpression(index.row()));\n    }\n    else if (index.column() == PortMapsColumns::PHYSICAL_RIGHT)\n    {\n        return QString::fromStdString(portMapInterface_->getPhysicalRightBoundFormattedExpression(index.row()));\n    }\n    else if (index.column() == PortMapsColumns::TIEOFF)\n    {\n        return QString::fromStdString(portMapInterface_->getLogicalTieOffFormattedExpression(index.row()));\n    }\n\n    return valueForIndex(index);\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortMapModel::expressionForIndex()\n//-----------------------------------------------------------------------------\nQVariant PortMapModel::expressionForIndex(QModelIndex const& index) const\n{\n    if (index.column() == PortMapsColumns::LOGICAL_LEFT)\n    {\n        return QString::fromStdString(portMapInterface_->getLogicalLeftBoundExpression(index.row()));\n    }\n    else if (index.column() == PortMapsColumns::LOGICAL_RIGHT)\n    {\n        return QString::fromStdString(portMapInterface_->getLogicalRightBoundExpression(index.row()));\n    }\n    else if (index.column() == PortMapsColumns::PHYSICAL_LEFT)\n    {\n        return QString::fromStdString(portMapInterface_->getPhysicalLeftBoundExpression(index.row()));\n    }\n    else if (index.column() == PortMapsColumns::PHYSICAL_RIGHT)\n    {\n        return QString::fromStdString(portMapInterface_->getPhysicalRightBoundExpression(index.row()));\n    }\n    else if (index.column() == PortMapsColumns::TIEOFF)\n    {\n        return QString::fromStdString(portMapInterface_->getLogicalTieOffExpression(index.row()));\n    }\n\n    return valueForIndex(index);\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortMapModel::valueForIndex()\n//-----------------------------------------------------------------------------\nQVariant PortMapModel::valueForIndex(QModelIndex const& index) const\n{\n    if (index.column() == PortMapsColumns::LOGICAL_PORT)\n    {\n        return QString::fromStdString(portMapInterface_->getLogicalPortName(index.row()));\n    }\n    else if (index.column() == PortMapsColumns::PHYSICAL_PORT)\n    {\n        return QString::fromStdString(portMapInterface_->getPhysicalPortName(index.row()));\n    }\n    else if (!index.parent().isValid() && index.column() == PortMapsColumns::LOGICAL_PRESENCE)\n    {\n        return QString::fromStdString(portMapInterface_->getLogicalPresence(index.row()));\n    }\n    else if (index.column() == PortMapsColumns::INVERT)\n    {\n        return QString::fromStdString(portMapInterface_->getInvertString(index.row()));\n    }\n    else if (index.column() == PortMapsColumns::ISINFORMATIVE)\n    {\n        return QString::fromStdString(portMapInterface_->getIsInformativeString(index.row()));\n    }\n    else if (index.column() == PortMapsColumns::TIEOFF)\n    {\n        return QString::fromStdString(portMapInterface_->getLogicalTieOffValue(index.row()));\n    }\n    if (index.column() == PortMapsColumns::LOGICAL_LEFT)\n    {\n        return QString::fromStdString(portMapInterface_->getLogicalLeftBoundValue(index.row()));\n    }\n    else if (index.column() == PortMapsColumns::LOGICAL_RIGHT)\n    {\n        return QString::fromStdString(portMapInterface_->getLogicalRightBoundValue(index.row()));\n    }\n    else if (index.column() == PortMapsColumns::PHYSICAL_LEFT)\n    {\n        return QString::fromStdString(portMapInterface_->getPhysicalLeftBoundValue(index.row()));\n    }\n    else if (index.column() == PortMapsColumns::PHYSICAL_RIGHT)\n    {\n        return QString::fromStdString(portMapInterface_->getPhysicalRightBoundValue(index.row()));\n    }\n    else if (index.column() == PortMapsColumns::TIEOFF)\n    {\n        return QString::fromStdString(portMapInterface_->getLogicalTieOffValue(index.row()));\n    }\n\n    return QVariant();\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortMapModel::setData()\n//-----------------------------------------------------------------------------\nbool PortMapModel::setData(const QModelIndex &index, const QVariant &value, int role )\n{\n    bool success = false;\n\n    if (indexIsValid(index) && index.data(Qt::EditRole) != value)\n    {\n        if (role == Qt::EditRole)\n        {\n            if (index.column() == PortMapsColumns::LOGICAL_PORT)\n            {\n                portMapInterface_->setLogicalPort(index.row(), value.toString().toStdString());\n            }\n            else if (index.column() == PortMapsColumns::LOGICAL_LEFT)\n            {\n                portMapInterface_->setLogicalLeftBound(index.row(), value.toString().toStdString());\n            }\n            else if (index.column() == PortMapsColumns::LOGICAL_RIGHT)\n            {\n                portMapInterface_->setLogicalRightBound(index.row(), value.toString().toStdString());\n            }\n            else if (index.column() == PortMapsColumns::PHYSICAL_PORT)\n            {\n                QString oldPhysicalName = QString::fromStdString(portMapInterface_->getPhysicalPortName(index.row()));\n                QString newPhysicalName = value.toString();\n\n                portMapInterface_->setPhysicalPort(index.row(), newPhysicalName.toStdString());\n                sendPortConnectionSignal(oldPhysicalName, newPhysicalName);\n            }\n            else if (index.column() == PortMapsColumns::PHYSICAL_LEFT)\n            {\n                portMapInterface_->setPhysicalLeftBound(index.row(), value.toString().toStdString());\n            }\n            else if (index.column() == PortMapsColumns::PHYSICAL_RIGHT)\n            {\n                portMapInterface_->setPhysicalRightBound(index.row(), value.toString().toStdString());\n            }\n            else if (index.column() == PortMapsColumns::TIEOFF)\n            {\n                portMapInterface_->setLogicalTieOff(index.row(), value.toString().toStdString());\n            }\n        }\n        else if (role == Qt::CheckStateRole)\n        {\n            bool checkValue = (value == Qt::Checked);\n            if (index.column() == PortMapsColumns::INVERT)\n            {\n                portMapInterface_->setInvertValue(index.row(), checkValue);\n            }\n            else if (index.column() == PortMapsColumns::ISINFORMATIVE)\n            {\n                portMapInterface_->setIsInformativeValue(index.row(), checkValue);\n            }\n        }\n\n        emit dataChanged(index, index);\n        emit contentChanged();\n\n        success = true;\n    }\n\n    return success;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortMapModel::sendPortConnectionSignal()\n//-----------------------------------------------------------------------------\nvoid PortMapModel::sendPortConnectionSignal(QString const& oldName, QString const& newName)\n{\n    if (!oldName.isEmpty())\n    {\n        emit portDisconnected(oldName);\n    }\n\n    emit portConnected(newName);\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortMapModel::indexIsValid()\n//-----------------------------------------------------------------------------\nbool PortMapModel::indexIsValid(QModelIndex const& index) const\n{\n    if (!index.parent().isValid())\n    {\n        if (index.row() >= 0 && index.row() < portMapInterface_->itemCount())\n        {\n            return true;\n        }\n    }\n\n    return false;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortMapModel::flags()\n//-----------------------------------------------------------------------------\nQt::ItemFlags PortMapModel::flags(QModelIndex const& index) const\n{\n    if (!index.isValid())\n    {\n        return Qt::NoItemFlags;\n    }\n\n    Qt::ItemFlags itemFlags = Qt::ItemIsEnabled | Qt::ItemIsSelectable;\n\n    bool logicalPortExists = portMapInterface_->logicalPortExists(index.row());\n    if (logicalPortExists)\n    {\n        itemFlags |= Qt::ItemIsDropEnabled;\n    }\n\n    if (index.column() == PortMapsColumns::INVERT || index.column() == PortMapsColumns::ISINFORMATIVE)\n    {\n        itemFlags |= Qt::ItemIsUserCheckable;\n    }\n    else if (index.column() != PortMapsColumns::LOGICAL_PRESENCE)\n    {\n        itemFlags |= Qt::ItemIsEditable;\n    }\n\n    return itemFlags;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortMapModel::reset()\n//-----------------------------------------------------------------------------\nvoid PortMapModel::reset()\n{\n    beginResetModel();\n    endResetModel();\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortMapModel::refresh()\n//-----------------------------------------------------------------------------\nvoid PortMapModel::refresh()\n{\n    reset();\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortMapTreeModel::isValidExpressionColumn()\n//-----------------------------------------------------------------------------\nbool PortMapModel::isValidExpressionColumn(QModelIndex const& index) const\n{\n    return index.column() == PortMapsColumns::LOGICAL_LEFT || index.column() == PortMapsColumns::LOGICAL_RIGHT ||\n        index.column() == PortMapsColumns::PHYSICAL_LEFT || index.column() == PortMapsColumns::PHYSICAL_RIGHT ||\n        index.column() == PortMapsColumns::TIEOFF;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortMapTreeModel::expressionOrValueForIndex()\n//-----------------------------------------------------------------------------\nQVariant PortMapModel::expressionOrValueForIndex(QModelIndex const& index) const\n{\n    if (isValidExpressionColumn(index))\n    {\n        return expressionForIndex(index);\n    }\n    else\n    {\n        return valueForIndex(index);\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortMapTreeModel::validateIndex()\n//-----------------------------------------------------------------------------\nbool PortMapModel::validateIndex(QModelIndex const& index) const\n{\n    if (index.column() == PortMapsColumns::LOGICAL_PORT && !portMapInterface_->logicalPortExists(index.row()))\n    {\n        return false;\n    }\n\n    if (index.column() == PortMapsColumns::LOGICAL_PORT || index.column() == PortMapsColumns::LOGICAL_LEFT ||\n        index.column() == PortMapsColumns::LOGICAL_RIGHT || index.column() == PortMapsColumns::PHYSICAL_PORT ||\n        index.column() == PortMapsColumns::PHYSICAL_LEFT || index.column() == PortMapsColumns::PHYSICAL_RIGHT ||\n        index.column() == PortMapsColumns::TIEOFF)\n    {\n        if (portMapInterface_->logicalPortIsValid(index.row()))\n        {\n            if (portMapInterface_->physicalMappingIsValid(index.row()))\n            {\n                if (index.column() != PortMapsColumns::TIEOFF &&\n                    portMapInterface_->physicalPortIsValid(index.row()))\n                {\n                    if (index.column() == PortMapsColumns::LOGICAL_PORT ||\n                        index.column() == PortMapsColumns::PHYSICAL_PORT)\n                    {\n                        return portMapInterface_->connectedPortsHaveValidPortTypes(index.row()) &&\n                            portMapInterface_->connectedPortsHaveValidDirections(index.row()) &&\n                            portMapInterface_->connectedPortsHaveValidInitiatives(index.row());\n                    }\n                    else if (index.column() == PortMapsColumns::LOGICAL_LEFT ||\n                        index.column() == PortMapsColumns::LOGICAL_RIGHT ||\n                        index.column() == PortMapsColumns::PHYSICAL_LEFT ||\n                        index.column() == PortMapsColumns::PHYSICAL_RIGHT)\n                    {\n                        return portMapInterface_->connectedPortsHaveSameRange(index.row());\n                    }\n                }\n                else if (index.column() == PortMapsColumns::TIEOFF &&\n                    portMapInterface_->tieOffIsValid(index.row()))\n                {\n                    return true;\n                }\n            }\n\n            if (index.column() == PortMapsColumns::LOGICAL_PORT)\n            {\n                return true;\n            }\n            else if (index.column() == PortMapsColumns::LOGICAL_LEFT ||\n                index.column() == PortMapsColumns::LOGICAL_RIGHT)\n            {\n                return portMapInterface_->logicalPortHasValidRange(index.row());\n            }\n        }\n\n        return false;\n    }\n\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortMapModel::onAddPortMap()\n//-----------------------------------------------------------------------------\nvoid PortMapModel::onAddPortMap(QModelIndex const& itemIndex)\n{\n    int additionRow = itemIndex.row();\n    if (!itemIndex.isValid())\n    {\n        additionRow = portMapInterface_->itemCount();\n    }\n\n    beginInsertRows(QModelIndex(), additionRow, additionRow);\n\n    portMapInterface_->addPortMap(additionRow);\n\n    endInsertRows();\n\n    emit contentChanged();\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortMapModel::onRemovePortMap()\n//-----------------------------------------------------------------------------\nvoid PortMapModel::onRemovePortMap(QModelIndex const& itemIndex)\n{\n    if (!indexIsValid(itemIndex))\n    {\n        return;\n    }\n\n    QString physicalPortName(QString::fromStdString(portMapInterface_->getPhysicalPortName(itemIndex.row())));\n\n    beginRemoveRows(QModelIndex(), itemIndex.row(), itemIndex.row());\n\n    portMapInterface_->removePortMap(itemIndex.row());\n\n    endRemoveRows();\n\n    if (!physicalPortName.isEmpty())\n    {\n        emit portDisconnected(physicalPortName);\n    }\n\n    emit dataChanged(itemIndex, itemIndex);\n    emit contentChanged();\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortMapModel::mimeTypes()\n//-----------------------------------------------------------------------------\nQStringList PortMapModel::mimeTypes() const\n{\n    QStringList types(QAbstractItemModel::mimeTypes());\n    types << \"text/plain\";\n\n    return types;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortMapModel::supportedDropActions()\n//-----------------------------------------------------------------------------\nQt::DropActions PortMapModel::supportedDropActions() const\n{\n    return Qt::CopyAction | Qt::MoveAction;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortMapModel::dropMimeData()\n//-----------------------------------------------------------------------------\nbool PortMapModel::dropMimeData(const QMimeData *data, Qt::DropAction action, int, int,\n    const QModelIndex &parent)\n{\n    if (!parent.isValid())\n    {\n        return false;\n    }\n\n    if (action == Qt::IgnoreAction)\n    {\n        return true;\n    }\n\n    QString mimeText = data->text();\n\n    QStringList physicalPorts = mimeText.split(';');\n\n    beginResetModel();\n\n    QString firstPort = physicalPorts.takeFirst();\n    portMapInterface_->setPhysicalPort(parent.row(), firstPort.toStdString());\n\n    emit portConnected(firstPort);\n\n    endResetModel();\n\n    if (physicalPorts.size() > 0)\n    {\n        std::string logicalName = portMapInterface_->getLogicalPortName(parent.row());\n\n        int portMapIndex = portMapInterface_->itemCount();\n\n        beginInsertRows(QModelIndex(), portMapIndex, portMapIndex + physicalPorts.size() - 1);\n\n        for (QString const& currentPort : physicalPorts)\n        {\n            portMapInterface_->addPortMap(portMapIndex);\n            portMapInterface_->setPhysicalPort(portMapIndex, currentPort.toStdString());\n            portMapInterface_->setLogicalPort(portMapIndex, logicalName);\n\n            portMapIndex = portMapInterface_->itemCount();\n\n            emit portConnected(currentPort);\n        }\n\n        endInsertRows();\n    }\n\n    emit contentChanged();\n\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortMapModel::onRemoveAllPortMappings()\n//-----------------------------------------------------------------------------\nvoid PortMapModel::onRemoveAllPortMappings()\n{\n    if (portMapInterface_->itemCount() == 0)\n    {\n        return;\n    }\n\n    beginRemoveRows(QModelIndex(), 0, portMapInterface_->itemCount() - 1);\n\n    int itemCount = portMapInterface_->itemCount();\n    for (int i = 0; i < itemCount; ++i)\n    {\n        portMapInterface_->removePortMap(0);\n    }\n\n    endRemoveRows();\n\n    emit contentChanged();\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortMapModel::onAddAutoConnectedPortMaps()\n//-----------------------------------------------------------------------------\nvoid PortMapModel::onAddAutoConnectedPortMaps(QVector<QString> physicalPorts)\n{\n    beginResetModel();\n\n    for (auto const& portName : physicalPorts)\n    {\n        emit portConnected(portName);\n    }\n\n    endResetModel();\n\n    emit contentChanged();\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortMapModel::getAllReferencesToIdInItemOnRow()\n//-----------------------------------------------------------------------------\nint PortMapModel::getAllReferencesToIdInItemOnRow(const int& row, QString const& valueID) const\n{\n    return portMapInterface_->getAllReferencesToIdInItem(\n        portMapInterface_->getIndexedItemName(row), valueID.toStdString());\n}\n"
  },
  {
    "path": "editors/ComponentEditor/busInterfaces/portmaps/PortMapModel.h",
    "content": "//-----------------------------------------------------------------------------\n// File: PortMapModel.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 30.05.2022\n//\n// Description:\n// A model for displaying bus interface port maps.\n//-----------------------------------------------------------------------------\n\n#ifndef PORTMAPMODEL_H\n#define PORTMAPMODEL_H\n\n#include <editors/ComponentEditor/common/ParameterizableTable.h>\n#include <editors/ComponentEditor/common/ReferencingTableModel.h>\n\nclass PortMapInterface;\n\n//-----------------------------------------------------------------------------\n//! A model for displaying bus interface port maps.\n//-----------------------------------------------------------------------------\nclass PortMapModel : public ReferencingTableModel, ParameterizableTable\n{\n    Q_OBJECT\n\npublic:\n\n    /*!\n     *  The constructor.\n     *\n     *    @param [in] parameterFinder     The used parameter finder.\n     *    @param [in] portMapInterface    Interface for accessing port maps.\n     *    @param [in] parent              The owner of this model.\n     */\n    PortMapModel(QSharedPointer<ParameterFinder> parameterFinder, PortMapInterface* portMapInterface,\n        QObject* parent);\n\n    /*!\n     *  The destructor.\n     */\n    virtual ~PortMapModel() = default;\n\n    /*!\n     *  Refreshes the model so that modifications from outside are made visible.\n     */\n    void refresh();\n\n\n    /*!\n     *  Resets the model and restores the port maps from the component.\n     */\n    void reset();\n\n    /*!\n     *  Returns the number of columns in this model.\n     *\n     *    @param [in] parent  Model index identifying the item whose column count is requested.\n     *\n     *    @return The number of columns.\n     */\n    virtual int columnCount(const QModelIndex & parent = QModelIndex() ) const;\n\n    /*! \n     *  Returns the number of rows an item has.\n     *\n     *    @param [in] parent  Model index identifying the item whose row count is wanted.\n     *\n     *    @return The number of rows the item has.\n     */\n    virtual int rowCount(const QModelIndex &parent = QModelIndex()) const;\n\n    /*!\n     *  Return header data for the given header column.\n     *\n     *    @param [in] section      The index of the header column.\n\t *    @param [in] orientation  The orientation of the header, only Qt::Horizontal supported.\n     *    @param [in] role         The role of the data.\n     *\n     *    @return QVariant containing the data.\n     */\n    virtual QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;\n\n    /*!\n     *  Get the data associated with given object.\n     *\n     *    @param [in] index Model index that identifies the object that's data is wanted.\n     *    @param [in] role Specifies the type of data wanted.\n     *\n     *    @return QVariant Containing the requested data.\n     */\n    virtual QVariant data(QModelIndex const& index, int role = Qt::DisplayRole) const;\n\n\t/*!\n     *  Set the data for specified item.\n\t *\n\t *    @param [in]  index  Specifies the item that's data is modified\n\t *    @param [in]  value  The value to be set.\n\t *    @param [in]  role   The role that is trying to modify the data. Only Qt::EditRole is supported.\n\t *\n\t *    @return  True, if data was successfully set, otherwise false.\n\t */\n    virtual bool setData(const QModelIndex &index, const QVariant &value, int role /* = Qt::EditRole */);\n\n    /*!\n     *  Get the flags that identify possible methods for given object.\n     *\n     *    @param [in] index   Model index identifying the object that's flags are requested.\n     *\n     *    @return Qt::ItemFlags that specify how the object can be handled.\n     */\n    Qt::ItemFlags flags(QModelIndex const& index) const;\n\n    /*!\n     *  Get the list of acceptable mime types.\n     *\n     *    @return The list of acceptable mime types.\n     */\n    QStringList mimeTypes() const;\n\n    /*!\n     *  Get the supported drop actions.\n     *\n     *    @return The supported drop actions.\n     */\n    virtual Qt::DropActions supportedDropActions() const;\n\n    /*!\n     *  Drop the mime data.\n     *\n     *    @param [in] data    The actual data.\n     *    @param [in] action  The used drop action.\n     *    @param [in] row     The selected row.\n     *    @param [in] column  The selected column.\n     *    @param [in] parent  Parent index of the new data.\n     */\n    virtual bool dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column,\n        const QModelIndex &parent);\n\npublic slots:\n\n    /*!\n     *  Handler for adding a new port map.\n     *\n     *    @param [in] itemIndex   The index of the new port.\n     */\n    void onAddPortMap(QModelIndex const& itemIndex);\n\n    /*!\n     *  Handler for removing a port map.\n     *\n     *    @param [in] itemIndex   The index of the removed port.\n     */\n    void onRemovePortMap(QModelIndex const& itemIndex);\n\n    /*!\n     *  Handler for removing all port maps from all the logical ports.\n     */\n    void onRemoveAllPortMappings();\n\n    /*!\n     *  Add a port map to the correct parent item.\n     *\n     *    @param [in] physicalPorts   The weighted physical ports.\n     */\n    void onAddAutoConnectedPortMaps(QVector<QString> physicalPorts);\n\nsignals:\n\n    /*!\n     *  Emitted when the contents have changed.\n     */\n    void contentChanged();\n\n    /*!\n     *  Emitted when a port is connected.\n     *\n     *    @param [in] portName    The name of the connected port.\n     */\n    void portConnected(QString const& portName);\n\n    /*!\n     *  Emitted when a port is disconnected.\n     *\n     *    @param [in] portName    The name of the disconnected port.\n     */\n    void portDisconnected(QString const& portName);\n\nprotected:\n\n    /*!\n     *  Check if the column index is valid for containing expressions.\n     *\n     *    @param [in] index   The index being evaluated.\n     *\n     *    @return True, if column can have expressions, false otherwise.\n     */\n    virtual bool isValidExpressionColumn(QModelIndex const& index) const;\n    \n    /*!\n     *  Gets the expression for the given index or the plain value if expression is not available.\n     *\n     *    @param [in] index   The index whose expression to get.\n     *\n     *    @return The expression for the index if available, otherwise the value for the given index.\n     */\n    virtual QVariant expressionOrValueForIndex(QModelIndex const& index) const; \n\n    /*!\n     *  Validates the data in an index.\n     *\n     *    @param [in] index   The index whose data to validate\n     *\n     *    @return True, if the data in the index is valid, otherwise false.\n     */\n    virtual bool validateIndex(QModelIndex const& index) const;\n\n    /*!\n     *  Gets the number of all the references made to a selected id on the selected row.\n     *\n     *    @param [in] row         The row of the selected item.\n     *    @param [in] valueID     The id of the referenced parameter.\n     *\n     *    @return The amount of references made to the selected id on the selected row.\n     */\n    virtual int getAllReferencesToIdInItemOnRow(const int& row, QString const& valueID) const override final;\n\nprivate:\n\n    // Disable copying.\n    PortMapModel(PortMapModel const& rhs);\n    PortMapModel& operator=(PortMapModel const& rhs);\n\n    /*!\n     *  Get the formatted value of an expression in the selected index.\n     *\n     *    @param [in] index   The selected index.\n     *\n     *    @return The formatted value of an expression in the selected index.\n     */\n    virtual QVariant formattedExpressionForIndex(QModelIndex const& index) const;\n\n    /*!\n     *  Get the expression of the selected index.\n     *\n     *    @param [in] index   The selected index.\n     *\n     *    @return The expression of the selected index.\n     */\n    virtual QVariant expressionForIndex(QModelIndex const& index) const;\n\n    /*!\n     *  Get the value for the selected index.\n     *\n     *    @param [in] index           The selected index.\n     */\n    QVariant valueForIndex(QModelIndex const& index) const;\n\n    /*!\n     *  Check if an index is valid.\n     *\n     *    @param [in] index   The selected index.\n     *\n     *    @return True, if the selected index is valid, otherwise false.\n     */\n    bool indexIsValid(QModelIndex const& index) const;\n\n    /*!\n     *  Emit a port connection signal.\n     *\n     *    @param [in] oldName     The old name of the port.\n     *    @param [in] newName     The new name of the port.\n     */\n    void sendPortConnectionSignal(QString const& oldName, QString const& newName);\n\n    //-----------------------------------------------------------------------------\n    // Data.\n    //----------------------------------------------------------------------------- \n\n    //! Interface for accessing port maps.\n    PortMapInterface* portMapInterface_;\n};\n\n//-----------------------------------------------------------------------------\n\n#endif // PORTMAPMODEL_H\n"
  },
  {
    "path": "editors/ComponentEditor/busInterfaces/portmaps/PortMapSortFilter.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: PortMapSortFilter.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 01.06.2022\n//\n// Description:\n// Sort filter proxy model for port maps.\n//-----------------------------------------------------------------------------\n\n#include \"PortMapSortFilter.h\"\n\n#include <editors/ComponentEditor/busInterfaces/portmaps/PortMapsColumns.h>\n\n#include <KactusAPI/include/PortMapInterface.h>\n\n#include <common/KactusColors.h>\n\n//-----------------------------------------------------------------------------\n// Function: PortMapSortFilter::PortMapSortFilter()\n//-----------------------------------------------------------------------------\nPortMapSortFilter::PortMapSortFilter(PortMapInterface* portMapInterface, QObject *parent):\nQSortFilterProxyModel(parent),\nportMapInterface_(portMapInterface)\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortMapSortFilter::data()\n//-----------------------------------------------------------------------------\nQVariant PortMapSortFilter::data(const QModelIndex &index, int role) const\n{\n    if (role == Qt::BackgroundRole)\n    {\n        return getBackgroundColorForIndex(index);\n    }\n    else\n    {\n        return QSortFilterProxyModel::data(index, role);\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortMapSortFilter::getBackgroundColorForIndex()\n//-----------------------------------------------------------------------------\nQColor PortMapSortFilter::getBackgroundColorForIndex(QModelIndex const& index) const\n{\n    QModelIndex sourceIndex = mapToSource(index);\n\n    std::string logicalTieOff = portMapInterface_->getLogicalTieOffValue(sourceIndex.row());\n    bool physicalPortExists = portMapInterface_->hasPhysicalPort(sourceIndex.row());\n\n    if (index.column() == PortMapsColumns::LOGICAL_PORT ||\n        (index.column() == PortMapsColumns::PHYSICAL_PORT && logicalTieOff.empty()) ||\n        (index.column() == PortMapsColumns::TIEOFF && !physicalPortExists))\n    {\n        return KactusColors::MANDATORY_FIELD;\n    }\n\n\n    int previousRow = index.row() - 1;\n    std::string previousName(\"\");\n    QColor previousColor = KactusColors::REGULAR_FIELD;\n    if (previousRow < 0)\n    {\n        return previousColor;\n    }\n    else\n    {\n        QModelIndex previousIndex = mapToSource(index.sibling(previousRow, PortMapsColumns::LOGICAL_PORT));\n        previousName = portMapInterface_->getLogicalPortName(previousIndex.row());\n    }\n\n    std::string name = portMapInterface_->getLogicalPortName(sourceIndex.row());\n\n    previousColor = getPreviousColor(previousRow, index);\n\n    if (name == previousName)\n    {\n        return previousColor;\n    }\n    else if (previousColor == KactusColors::REGULAR_FIELD)\n    {\n        return KactusColors::FIELD_COLOR;\n    }\n\n    return KactusColors::REGULAR_FIELD;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortMapSortFilter::getPreviousColor()\n//-----------------------------------------------------------------------------\nQColor PortMapSortFilter::getPreviousColor(int const& previousRow, QModelIndex const& index) const\n{\n    QModelIndex previousColorIndex = index.sibling(previousRow, 0);\n\n    QColor previousColor = previousColorIndex.data(Qt::BackgroundRole).value<QColor>();\n    while ((previousColor == KactusColors::DISABLED_FIELD || previousColor == KactusColors::MANDATORY_FIELD) &&\n        previousColorIndex.column() < PortMapsColumns::COLUMN_COUNT)\n    {\n        previousColorIndex = previousColorIndex.sibling(previousRow, previousColorIndex.column() + 1);\n        previousColor = previousColorIndex.data(Qt::BackgroundRole).value<QColor>();\n    }\n\n    return previousColor;\n}\n"
  },
  {
    "path": "editors/ComponentEditor/busInterfaces/portmaps/PortMapSortFilter.h",
    "content": "//-----------------------------------------------------------------------------\n// File: PortMapSortFilter.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 01.06.2022\n//\n// Description:\n// Sort filter proxy model for port maps.\n//-----------------------------------------------------------------------------\n\n#ifndef PORTMAPSORTFILTER_H\n#define PORTMAPSORTFILTER_H\n\n#include <QSortFilterProxyModel>\n#include <QColor>\n\nclass PortMapInterface;\n\n//-----------------------------------------------------------------------------\n//! Sort filter proxy model for port maps.\n//-----------------------------------------------------------------------------\nclass PortMapSortFilter : public QSortFilterProxyModel\n{\n\npublic:\n\n    /*!\n     *  The constructor.\n     *\n     *    @param [in] portMapInterface    Interface for accessing port maps.\n     *    @param [in] parent              Pointer to the owner of this model.\n     */\n    PortMapSortFilter(PortMapInterface* portMapInterface, QObject *parent);\n\n    /*!\n     *  The destructor.\n     */\n    virtual ~PortMapSortFilter() = default;\n\n    /*!\n     *  Get the data for the specified item.\n     *\n     *    @param [in] index   Specifies the item that's data is requested.\n     *    @param [in] role    The role that defines what kind of data is requested.\n     *\n     *    @return QVariant contains the data for the item.\n     */\n    virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;\n\nprotected:\n\n    /*!\n     *  Get the background color for the selected index.\n     *\n     *    @param [in] index   Index of the selected item.\n     *\n     *    @return Background color for the selected index.\n     */\n    virtual QColor getBackgroundColorForIndex(QModelIndex const& index) const;\n\nprivate:\n    //! No copying. No assignment.\n    PortMapSortFilter(const PortMapSortFilter& other);\n    PortMapSortFilter& operator=(const PortMapSortFilter& other);\n\n    /*!\n     *  Get the background colour on the previous row of the selected index.\n     *\n     *    @param [in] previousRow     The previous row.\n     *    @param [in] index           The selected index.\n     *\n     *    @return Background colour of the previous row.\n     */\n    QColor getPreviousColor(int const& previousRow, QModelIndex const& index) const;\n\n    //! Interface for accessing port maps.\n    PortMapInterface* portMapInterface_;\n\n};\n\n#endif // PORTMAPSORTFILTER_H\n"
  },
  {
    "path": "editors/ComponentEditor/busInterfaces/portmaps/PortMapView.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: PortMapView.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 31.05.2022\n//\n// Description:\n// A view for bus interface port maps.\n//-----------------------------------------------------------------------------\n\n#include \"PortMapView.h\"\n\n#include <editors/ComponentEditor/busInterfaces/portmaps/PortMappingTableView.h>\n#include <editors/ComponentEditor/busInterfaces/portmaps/PortMapsColumns.h>\n\n#include <QHeaderView>\n#include <QMenu>\n#include <QMimeData>\n\n//-----------------------------------------------------------------------------\n// Function: PortMapView::PortMapView()\n//-----------------------------------------------------------------------------\nPortMapView::PortMapView(PortMapInterface* portMapInterface, QWidget* parent):\nEditableTableView(parent),\nautoConnectAction_(tr(\"Auto connect\"), this),\ncreateAllSignalsAction_(tr(\"All\"), this),\ncreateRequiredSignalsAction_(tr(\"Required\"), this),\ncreateOptionalSignalsAction_(tr(\"Optional\"), this),\nmapInterface_(portMapInterface)\n{\n    horizontalHeader()->setSectionResizeMode(QHeaderView::Interactive);\n    horizontalHeader()->setStretchLastSection(true);\n    \n    setEditTriggers(QAbstractItemView::DoubleClicked | QAbstractItemView::SelectedClicked |\n        QAbstractItemView::EditKeyPressed | QAbstractItemView::AnyKeyPressed);\n\n    setAlternatingRowColors(false);\n    setSortingEnabled(true);\n    setAcceptDrops(true);\n    viewport()->setAcceptDrops(true);\n    setDropIndicatorShown(true);\n    setDragDropMode(QAbstractItemView::DropOnly);\n    setSelectionMode(QAbstractItemView::ExtendedSelection);\n    setItemsDraggable(false);\n\n    setupActions();\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortMapView::setupActions()\n//-----------------------------------------------------------------------------\nvoid PortMapView::setupActions()\n{\n    autoConnectAction_.setToolTip(tr(\"Automatically connect logical signals to physical ports.\"));\n    autoConnectAction_.setStatusTip(tr(\"Automatically connect logical signals to physical ports.\"));\n    connect(&autoConnectAction_, SIGNAL(triggered()), this, SLOT(onAutoConnect()), Qt::UniqueConnection);\n\n    createAllSignalsAction_.setToolTip(tr(\"Create port maps from all signals\"));\n    createAllSignalsAction_.setStatusTip(tr(\"Create port maps from all signals\"));\n    connect(&createAllSignalsAction_, SIGNAL(triggered()), this, SIGNAL(createAllSignals()), Qt::UniqueConnection);\n\n\n    createRequiredSignalsAction_.setToolTip(tr(\"Create port maps from the required signals\"));\n    createRequiredSignalsAction_.setStatusTip(tr(\"Create port maps from the required signals\"));\n    connect(&createRequiredSignalsAction_, SIGNAL(triggered()),\n        this, SIGNAL(createRequiredSignals()), Qt::UniqueConnection);\n\n    createOptionalSignalsAction_.setToolTip(tr(\"Create port maps from the optional signals\"));\n    createOptionalSignalsAction_.setStatusTip(tr(\"Create port maps from the optional signals\"));\n    connect(&createOptionalSignalsAction_, SIGNAL(triggered()),\n        this, SIGNAL(createOptionalSignals()), Qt::UniqueConnection);\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortMapView::contextMenuEvent()\n//-----------------------------------------------------------------------------\nvoid PortMapView::contextMenuEvent(QContextMenuEvent* event)\n{\n    QModelIndex index = indexAt(event->pos());\n\n    QMenu menu(this);\n    menu.addAction(&addAction_);\n\n    // if at least one valid item is selected\n    if (index.isValid())\n    {\n        menu.addAction(&removeAction_);\n        menu.addAction(&clearAction_);\n        menu.addAction(&cutAction_);\n        menu.addAction(&copyAction_);\n        menu.addAction(&pasteAction_);\n\n        menu.addSeparator();\n        menu.addAction(&autoConnectAction_);\n    }\n\n    menu.addSeparator();\n\n    QMenu* signalAddMenu = menu.addMenu(\"Add signals\");\n    signalAddMenu->addAction(&createAllSignalsAction_);\n    signalAddMenu->addAction(&createRequiredSignalsAction_);\n    signalAddMenu->addAction(&createOptionalSignalsAction_);\n\n    menu.addMenu(signalAddMenu);\n\n    if (importExportAllowed())\n    {\n        menu.addSeparator();\n        menu.addAction(&importAction_);\n        menu.addAction(&exportAction_);\n    }\n\n    menu.exec(event->globalPos());\n\n    event->accept();\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortMapView::onAutoConnect()\n//-----------------------------------------------------------------------------\nvoid PortMapView::onAutoConnect()\n{\n    QModelIndexList indexList = selectedIndexes();\n\n    QStringList selectedLogicalSignals;\n\n    foreach (QModelIndex index, indexList)\n    {\n        if (!index.parent().isValid())\n        {\n            QModelIndex logicalSibling = index.sibling(index.row(), PortMapsColumns::LOGICAL_PORT);\n            QString logicalName = logicalSibling.data(Qt::DisplayRole).toString();\n\n            selectedLogicalSignals.append(logicalName);\n        }\n    }\n\n    emit autoConnecteLogicalSignals(selectedLogicalSignals);\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortMapView::dragEnterEvent()\n//-----------------------------------------------------------------------------\nvoid PortMapView::dragEnterEvent(QDragEnterEvent *event)\n{\n    PortMappingTableView* source = qobject_cast<PortMappingTableView*>(event->source());\n\n    // if source is port list view\n    if (source && event->mimeData()->hasFormat(\"text/plain\"))\n    {\n        event->acceptProposedAction();\n    }\n\n    EditableTableView::dragEnterEvent(event);\n}\n"
  },
  {
    "path": "editors/ComponentEditor/busInterfaces/portmaps/PortMapView.h",
    "content": "//-----------------------------------------------------------------------------\n// File: PortMapView.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 31.05.2022\n//\n// Description:\n// A view for bus interface port maps.\n//-----------------------------------------------------------------------------\n\n#ifndef PORTMAPVIEW_H\n#define PORTMAPVIEW_H\n\n#include <common/views/EditableTableView/editabletableview.h>\n\nclass PortMapInterface;\n\n//-----------------------------------------------------------------------------\n//! A view for bus interface port maps.\n//-----------------------------------------------------------------------------\nclass PortMapView : public EditableTableView\n{\n    Q_OBJECT\n\npublic:\n   \n    /*!\n     *  The constructor.\n     *\n     *    @param [in] portMapInterface    Interface for accessing port maps.\n     *    @param [in] parent              The parent widget.\n     */\n    PortMapView(PortMapInterface* portMapInterface, QWidget* parent);\n\n    /*!\n     *  The destructor.\n     */\n    ~PortMapView() = default;\n\nprotected:\n\n    /*!\n     *  Handler for context menu events.\n     *\n     *    @param [in] event   The context menu event.\n     */\n    virtual void contextMenuEvent(QContextMenuEvent* event) override final;\n\n    /*!\n     *  Handler for drag enter events\n\t *\n\t *    @param [in] event The event object.\n     */\n\tvirtual void dragEnterEvent(QDragEnterEvent* event) override final;\n\nsignals:\n\n    /*!\n     *  Automatically create port maps for the selected logical signals.\n     *\n     *    @param [in] logicalSignals  The selected logical signals.\n     */\n    void autoConnecteLogicalSignals(QStringList const& logicalSignals);\n\n    /*!\n     *  Automatically create port maps for all signals.\n     */\n    void createAllSignals();\n\n    /*!\n     *  Automatically create port maps for required signals.\n     */\n    void createRequiredSignals();\n\n    /*!\n     *  Automatically create port maps for optional signals.\n     */\n    void createOptionalSignals();\n\nprivate slots:\n\n    /*!\n     *  Handler for automatically creating port maps for selected logical signals.\n     */\n    void onAutoConnect();\n\nprivate:\n   \n    // Disable copying.\n    PortMapView(PortMapView const& rhs);\n    PortMapView& operator=(PortMapView const& rhs);\n\n    /*!\n     *  Setup the available context menu actions.\n     */\n    void setupActions();\n\n    //-----------------------------------------------------------------------------\n    // Data.\n    //-----------------------------------------------------------------------------\n\n    //! The action for automatically connecting logical signals to physical ports.\n    QAction autoConnectAction_;\n\n    //! Action for creating port maps from all signals.\n    QAction createAllSignalsAction_;\n\n    //! Action for creating port maps from required signals.\n    QAction createRequiredSignalsAction_;\n\n    //! Action for creating port maps from optional signals.\n    QAction createOptionalSignalsAction_;\n\n    //! Interface for accessing port maps.\n    PortMapInterface* mapInterface_;\n};\n\n//-----------------------------------------------------------------------------\n\n#endif // PORTMAPVIEW_H\n"
  },
  {
    "path": "editors/ComponentEditor/busInterfaces/portmaps/PortMappingColumns.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: PortMappingColumns.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Mikko Teuho\r\n// Date: 19.05.2016\r\n//\r\n// Description:\r\n// Common declarations for physical ports in port maps editor.\r\n//-----------------------------------------------------------------------------\r\n\r\nnamespace PortMappingColumns\r\n{\r\n    //! The editable columns in the physical ports of the port maps editor.\r\n    enum columns\r\n    {\r\n        NAME = 0,\r\n        DIRECTION,\r\n        INITIATIVE,\r\n        LEFT_BOUND,\r\n        RIGHT_BOUND,\r\n        SIZE,\r\n        COLUMN_COUNT\r\n    };\r\n}\r\n"
  },
  {
    "path": "editors/ComponentEditor/busInterfaces/portmaps/PortMappingTableModel.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: PortMappingTableModel.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Mikko Teuho\r\n// Date: 19.05.2016\r\n//\r\n// Description:\r\n// The base class for logical table model and physical table model.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"PortMappingTableModel.h\"\r\n#include \"PortMappingColumns.h\"\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PortMappingTableModel::PortMappingTableModel()\r\n//-----------------------------------------------------------------------------\r\nPortMappingTableModel::PortMappingTableModel(QObject *parent): \r\nQAbstractTableModel(parent)\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PortMappingTableModel::~PortMappingTableModel()\r\n//-----------------------------------------------------------------------------\r\nPortMappingTableModel::~PortMappingTableModel()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PortMappingTableModel::columnCount()\r\n//-----------------------------------------------------------------------------\r\nint PortMappingTableModel::columnCount(const QModelIndex& parent) const\r\n{\r\n    if (parent.isValid())\r\n    {\r\n        return 0;\r\n    }\r\n    else\r\n    {\r\n        return PortMappingColumns::COLUMN_COUNT;\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PortMappingTableModel::headerData()\r\n//-----------------------------------------------------------------------------\r\nQVariant PortMappingTableModel::headerData(int section, Qt::Orientation orientation, int role) const\r\n{\r\n    if (orientation == Qt::Horizontal)\r\n    {\r\n        if (role == Qt::DisplayRole)\r\n        {\r\n            if (section == PortMappingColumns::NAME)\r\n            {\r\n                return QString(tr(\"Name\"));\r\n            }\r\n            else if (section == PortMappingColumns::DIRECTION)\r\n            {\r\n                return QString(tr(\"Direction\"));\r\n            }\r\n            else if (section == PortMappingColumns::INITIATIVE)\r\n            {\r\n                return QString(tr(\"Initiative\"));\r\n            }\r\n            else if (section == PortMappingColumns::LEFT_BOUND)\r\n            {\r\n                return QString(tr(\"Left bound\"));\r\n            }\r\n            else if (section == PortMappingColumns::RIGHT_BOUND)\r\n            {\r\n                return QString(tr(\"Right bound\"));\r\n            }\r\n            else if (section == PortMappingColumns::SIZE)\r\n            {\r\n                return QString(tr(\"Size\"));\r\n            }\r\n        }\r\n    }\r\n\r\n    return QVariant();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PortMappingTableModel::flags()\r\n//-----------------------------------------------------------------------------\r\nQt::ItemFlags PortMappingTableModel::flags(QModelIndex const& index) const\r\n{\r\n    if (!index.isValid() || index.column() >= PortMappingColumns::COLUMN_COUNT)\r\n    {\r\n        return Qt::NoItemFlags;\r\n    }\r\n\r\n    Qt::ItemFlags flags = Qt::ItemIsEnabled | Qt::ItemIsSelectable;\r\n\r\n    return flags;\r\n}\r\n"
  },
  {
    "path": "editors/ComponentEditor/busInterfaces/portmaps/PortMappingTableModel.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: PortMappingTableModel.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Mikko Teuho\r\n// Date: 19.05.2016\r\n//\r\n// Description:\r\n// The base class for logical table model and physical table model.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef PORTMAPPINGTABLEMODEL_H\r\n#define PORTMAPPINGTABLEMODEL_H\r\n\r\n#include <QAbstractTableModel>\r\n#include <QStringList>\r\n\r\n//-----------------------------------------------------------------------------\r\n//! The base class for logical table model and physical table model.\r\n//-----------------------------------------------------------------------------\r\nclass PortMappingTableModel : public QAbstractTableModel\r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\r\n\t/*!\r\n     *  The constructor.\r\n\t *\r\n\t *    @param [in] parent  The owner of this model\r\n\t */\r\n\tPortMappingTableModel(QObject *parent);\r\n\t\r\n\t/*!\r\n     *  The destructor.\r\n     */\r\n\tvirtual ~PortMappingTableModel();\r\n\r\n    /*!\r\n     *  Get the number of columns in the model\r\n\t *\r\n\t *    @param [in] parent      Model index of the parent of the item. Must be invalid because this is not\r\n     *                              a hierarchical model.\r\n\t *\r\n\t *    @return Always returns 3\r\n\t */\r\n\tvirtual int columnCount(const QModelIndex& parent = QModelIndex() ) const;\r\n\r\n    /*!\r\n     *  Get the data for the headers\r\n\t *\r\n\t *    @param [in]  section        The column that's header is wanted.\r\n\t *    @param [in]  orientation    The orientation of the header data.\r\n\t *    @param [in]  role           Specified the type of data that is wanted.\r\n\t *\r\n\t *    @return  The header data for the given section.\r\n\t */\r\n\tvirtual QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole ) const;\r\n    \r\n\t/*! Get the data for the specified item for specified role.\r\n\t *\r\n\t *    @param [in] index Identifies the item that's data is wanted.\r\n\t *    @param [in] role Specifies what kind of data is wanted\r\n\t *\r\n\t *    @return The requested data.\r\n\t*/\r\n\tvirtual QVariant data(QModelIndex const& index, int role = Qt::DisplayRole) const = 0;\r\n\r\n    /*!\r\n     *  Get information on how specified item can be handled.\r\n\t *\r\n\t *    @param [in]  index Specifies the item that's flags are wanted.\r\n\t *\r\n\t *    @return  Qt::ItemFlags that define how object can be handled.\r\n\t */\r\n\tvirtual Qt::ItemFlags flags(QModelIndex const& index) const;\r\n\r\nprivate:\r\n\r\n\t//! No copying.\r\n\tPortMappingTableModel(const PortMappingTableModel& other);\r\n\r\n\t//! No assignment.\r\n\tPortMappingTableModel& operator=(const PortMappingTableModel& other);\r\n};\r\n\r\n#endif // PORTMAPPINGTABLEMODEL_H\r\n"
  },
  {
    "path": "editors/ComponentEditor/busInterfaces/portmaps/PortMappingTableView.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: PortMappingTableView.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Mikko Teuho\r\n// Date: 19.05.2016\r\n//\r\n// Description:\r\n// View to display a table of ports for port mapping.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"PortMappingTableView.h\"\r\n#include \"PortMappingColumns.h\"\r\n\r\n#include <QApplication>\r\n#include <QDrag>\r\n#include <QMimeData>\r\n#include <QModelIndex>\r\n#include <QHeaderView>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PortMappingTableView::PortMappingTableView()\r\n//-----------------------------------------------------------------------------\r\nPortMappingTableView::PortMappingTableView(QWidget *parent):\r\nQTableView(parent)\r\n{\r\n\tsetAlternatingRowColors(false);\r\n\r\n    setSelectionBehavior(QAbstractItemView::SelectRows);\r\n\r\n    setSelectionMode(QAbstractItemView::ExtendedSelection);\r\n\r\n    verticalHeader()->hide();\r\n\r\n    horizontalHeader()->setSectionResizeMode(QHeaderView::Interactive);\r\n    horizontalHeader()->setStretchLastSection(true);\r\n\r\n    verticalHeader()->setDefaultSectionSize(fontMetrics().height() + 8);\r\n\r\n    setWordWrap(true);\r\n\r\n    setSortingEnabled(true);\r\n\r\n    setEditTriggers(QAbstractItemView::NoEditTriggers);\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PortMappingTableView::~PortMappingTableView()\r\n//-----------------------------------------------------------------------------\r\nPortMappingTableView::~PortMappingTableView()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PortMappingTableView::dragEnterEvent()\r\n//-----------------------------------------------------------------------------\r\nvoid PortMappingTableView::dragEnterEvent(QDragEnterEvent* event)\r\n{\r\n\tPortMappingTableView* source = qobject_cast<PortMappingTableView*>(event->source());\r\n\t\r\n\t// if source is port list view\r\n\tif (source && event->mimeData()->hasFormat(\"text/plain\"))\r\n    {\r\n\t\t// the item can be removed from the original model\r\n\t\tevent->setDropAction(Qt::MoveAction);\r\n\t\tevent->accept();\r\n\t}\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PortMappingTableView::dragMoveEvent()\r\n//-----------------------------------------------------------------------------\r\nvoid PortMappingTableView::dragMoveEvent(QDragMoveEvent* e)\r\n{\r\n\tPortMappingTableView* source = qobject_cast<PortMappingTableView*>(e->source());\r\n\r\n\t// if the source is another port list view then select the item under the cursor.\r\n\tif (source && source != this) \r\n    {\r\n\t\tsetCurrentIndex(indexAt(e->position().toPoint()));\r\n    }\r\n\tif (source && e->mimeData()->hasFormat(\"text/plain\"))\r\n    {\r\n\t\t// the item can be removed from the original model\r\n\t\te->setDropAction(Qt::MoveAction);\r\n\t\te->accept();\r\n\t}\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PortMappingTableView::performDrag()\r\n//-----------------------------------------------------------------------------\r\nvoid PortMappingTableView::performDrag()\r\n{\r\n\tQModelIndexList indexes = selectedIndexes();\r\n\t\r\n    QModelIndexList changedIndexes = indexes;\r\n    foreach (QModelIndex index, indexes)\r\n    {\r\n        if (index.column() != PortMappingColumns::NAME)\r\n        {\r\n            changedIndexes.removeAll(index);\r\n        }\r\n    }\r\n\r\n    QStringList portNames;\r\n\tforeach (QModelIndex const& index, changedIndexes)\r\n    {\r\n\t\tif (index.isValid())\r\n        {\r\n            portNames.append(index.data(Qt::DisplayRole).toString());\r\n        }\r\n\t}\r\n\r\n    QString mimeText = portNames.join(';');\r\n\r\n\t// set the mime data\r\n\tQMimeData* mimeData = new QMimeData();\r\n\tmimeData->setText(mimeText);\r\n\r\n\tQDrag* drag = new QDrag(this);\r\n\tdrag->setMimeData(mimeData);\r\n\r\n\tif (drag->exec(Qt::MoveAction) == Qt::MoveAction)\r\n    {\r\n\t\t// inform the model that the dragged items could be removed\r\n\t\temit removeItems(indexes);\r\n\t}\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PortMappingTableView::mouseMoveEvent()\r\n//-----------------------------------------------------------------------------\r\nvoid PortMappingTableView::mouseMoveEvent(QMouseEvent* event)\r\n{\r\n\t// if left mouse button is pressed\r\n\tif (event->buttons() == Qt::LeftButton)\r\n    {\r\n\t\t// calculate how much mouse was moved\r\n\t\tint distance = (event->pos() - startPos_).manhattanLength();\r\n\r\n\t\t// if the move distance is enough to start the drag\r\n\t\tif (distance >= QApplication::startDragDistance())\r\n        {\r\n\t\t\tperformDrag();\r\n        }\r\n\t}\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PortMappingTableView::mousePressEvent()\r\n//-----------------------------------------------------------------------------\r\nvoid PortMappingTableView::mousePressEvent(QMouseEvent* event)\r\n{\r\n\tif (event->button() == Qt::LeftButton)\r\n    {\r\n\t\tstartPos_ = event->pos();\r\n    }\r\n\tQTableView::mousePressEvent(event);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PortMappingTableView::getSelectedPorts()\r\n//-----------------------------------------------------------------------------\r\nQStringList PortMappingTableView::getSelectedPorts()\r\n{\r\n\tQStringList portList;\r\n\tQModelIndexList indexList = selectedIndexes();\r\n\r\n    QModelIndexList removedIndexList = indexList;\r\n    foreach (QModelIndex index, indexList)\r\n    {\r\n        if (index.column() == PortMappingColumns::DIRECTION || index.column() == PortMappingColumns::SIZE)\r\n        {\r\n            removedIndexList.removeAll(index);\r\n        }\r\n    }\r\n\r\n\t// sort indexes so they are in order\r\n\tstd::sort(indexList.begin(), indexList.end());\r\n\r\n    foreach (QModelIndex const& index, removedIndexList)\r\n    {\r\n\t\t// dont append invalid indexes\r\n\t\tif (index.isValid())\r\n        {\r\n\t\t    portList.append(index.data(Qt::DisplayRole).toString());\r\n        }\r\n\t}\r\n\r\n\treturn portList;\r\n}\r\n"
  },
  {
    "path": "editors/ComponentEditor/busInterfaces/portmaps/PortMappingTableView.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: PortMappingTableView.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Mikko Teuho\r\n// Date: 19.05.2016\r\n//\r\n// Description:\r\n// View to display a table of ports for port mapping.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef PORTMAPPINGTABLEVIEW_H\r\n#define PORTMAPPINGTABLEVIEW_H\r\n\r\n#include <QDragEnterEvent>\r\n#include <QDragMoveEvent>\r\n#include <QModelIndex>\r\n#include <QPoint>\r\n#include <QTableView>\r\n\r\n//-----------------------------------------------------------------------------\r\n//! View to display a table of ports for port mapping.\r\n//-----------------------------------------------------------------------------\r\nclass PortMappingTableView : public QTableView\r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\r\n\t/*!\r\n     *  The constructor\r\n\t *\r\n\t *    @param [in] parent  The owner of this widget.\r\n\t */\r\n\tPortMappingTableView(QWidget *parent);\r\n\t\r\n\t/*!\r\n     *  The destructor.\r\n     */\r\n    virtual ~PortMappingTableView();\r\n\r\n\t/*!\r\n     *  Get names of the currently selected ports.\r\n\t * \r\n\t *    @return QStringList containing the names of the ports that are selected.\r\n\t */\r\n    QStringList getSelectedPorts();\r\n\r\nsignals:\r\n\r\n\t//! Emitted when port should be removed from the list.\r\n\tvoid removeItem(QModelIndex const& index) const;\r\n\r\n\t//! Emitted when a group of ports should be removed from list.\r\n\tvoid removeItems(const QModelIndexList& indexes) const;\r\n\r\n\t//! Emitted when group of ports should be moved to another location.\r\n\tvoid moveItems(const QStringList& portNames, QModelIndex const& targetIndex) const;\r\n\r\n\t//! Emitted when drop event occurs to inform connection between signals.\r\n\tvoid makeConnection(const QStringList& physicals, const QStringList& logicals) const;\r\n\r\nprotected:\r\n\r\n\t/*!\r\n     *  Handler for drag enter events.\r\n\t *\r\n\t *    @param [in] event   The event object.\r\n\t */\r\n\tvirtual void dragEnterEvent(QDragEnterEvent* event);\r\n\r\n\t/*!\r\n     *  Handler for drag move events on drag & drop.\r\n\t *\r\n\t *    @param [in] e   The event object.\r\n\t */\r\n\tvirtual void dragMoveEvent(QDragMoveEvent* e);\r\n\r\n\t/*!\r\n     *  Handler for mouse move events.\r\n\t *\r\n\t *    @param [in] event   The event object.\r\n\t */\r\n\tvirtual void mouseMoveEvent(QMouseEvent* event);\r\n\t\r\n\t/*!\r\n     *  Handler for mouse press events.\r\n\t *\r\n\t *    @param [in] event   The event object.\r\n\t */\r\n\tvirtual void mousePressEvent(QMouseEvent* event);\r\n\r\n    //! Initiates a drag operation from this view.\r\n    virtual void performDrag();\r\n\r\n    //! The position where mouse press happened to initiate a drag event.\r\n    QPoint startPos_;\r\n\r\nprivate:\r\n\r\n\t//! No copying.\r\n\tPortMappingTableView(const PortMappingTableView& other);\r\n\tPortMappingTableView& operator=(const PortMappingTableView& other);\r\n};\r\n\r\n#endif // PORTMAPPINGTABLEVIEW_H\r\n"
  },
  {
    "path": "editors/ComponentEditor/busInterfaces/portmaps/PortMapsColumns.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: PortMapsColumns.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Mikko Teuho\r\n// Date: 23.05.2016\r\n//\r\n// Description:\r\n// Common declarations for port maps.\r\n//-----------------------------------------------------------------------------\r\n\r\nnamespace PortMapsColumns\r\n{\r\n    //! The editable columns in the port maps editor.\r\n    enum columns\r\n    {\r\n        LOGICAL_PRESENCE = 0,\r\n        LOGICAL_LEFT,\r\n        LOGICAL_RIGHT,\r\n        LOGICAL_PORT,\r\n        PHYSICAL_PORT,\r\n        PHYSICAL_LEFT,\r\n        PHYSICAL_RIGHT,\r\n        INVERT,\r\n        ISINFORMATIVE,\r\n        TIEOFF,\r\n        COLUMN_COUNT\r\n    };\r\n}\r\n"
  },
  {
    "path": "editors/ComponentEditor/channels/ChannelColumns.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ChannelColumns.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Esko Pekkarinen\r\n// Date: 19.10.2015\r\n//\r\n// Description:\r\n// Common declarations for editing channels.\r\n//-----------------------------------------------------------------------------\r\n\r\nnamespace ChannelColumns\r\n{\r\n    //! The column numbers.\r\n    enum Column\r\n    {\r\n        NAME = 0,\r\n        DISPLAY_NAME,\r\n        INTERFACES,\r\n        SHORT_DESCRIPTION,\r\n        DESCRIPTION,\r\n        COLUMN_COUNT\r\n    };\r\n\r\n    //! The roles to display/edit interface column with QStringList.\r\n    enum Roles\r\n    {\r\n        USER_DISPLAY_ROLE = Qt::UserRole,\r\n        USER_EDIT_ROLE\r\n    };\r\n}\r\n"
  },
  {
    "path": "editors/ComponentEditor/channels/channelsdelegate.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: channelsdelegate.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 14.06.2012\r\n//\r\n// Description:\r\n// The delegate that provides editors to edit the channels of a component.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"channelsdelegate.h\"\r\n#include \"ChannelColumns.h\"\r\n\r\n#include <common/widgets/EnumCollectionEditor/EnumCollectionEditor.h>\r\n\r\n#include <IPXACTmodels/Component/Component.h>\r\n\r\n#include <QLineEdit>\r\n#include <QString>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ChannelsDelegate::ChannelsDelegate()\r\n//-----------------------------------------------------------------------------\r\nChannelsDelegate::ChannelsDelegate(QSharedPointer<Component> component, QObject* parent):\r\nEnumerationEditorConstructorDelegate(parent),\r\ncomponent_(component)\r\n{\r\n    Q_ASSERT(component_);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ChannelsDelegate::~ChannelsDelegate()\r\n//-----------------------------------------------------------------------------\r\nChannelsDelegate::~ChannelsDelegate()\r\n{\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ChannelsDelegate::createEditor()\r\n//-----------------------------------------------------------------------------\r\nQWidget* ChannelsDelegate::createEditor(QWidget* parent, QStyleOptionViewItem const& option, \r\n    QModelIndex const& index) const\r\n{\r\n    if (index.column() == ChannelColumns::NAME ||\r\n        index.column() == ChannelColumns::DISPLAY_NAME ||\r\n        index.column() == ChannelColumns::DESCRIPTION)\r\n    {\r\n        QLineEdit* lineEdit = new QLineEdit(parent);\r\n        connect(lineEdit, SIGNAL(editingFinished()), this, SLOT(commitAndCloseEditor()), Qt::UniqueConnection);\r\n\r\n        return lineEdit;\r\n    }\r\n    else\r\n    {\r\n        return EnumerationEditorConstructorDelegate::createEditor(parent, option, index);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ChannelsDelegate::setEditorData()\r\n//-----------------------------------------------------------------------------\r\nvoid ChannelsDelegate::setEditorData(QWidget* editor, QModelIndex const& index) const\r\n{\r\n    if (index.column() == ChannelColumns::NAME ||\r\n        index.column() == ChannelColumns::DISPLAY_NAME ||\r\n        index.column() == ChannelColumns::DESCRIPTION)\r\n    {\r\n        QLineEdit* edit = qobject_cast<QLineEdit*>(editor);\r\n        Q_ASSERT(edit);\r\n\r\n        edit->setText(index.data(Qt::DisplayRole).toString());\r\n    }\r\n    else\r\n    {\r\n        EnumerationEditorConstructorDelegate::setEditorData(editor, index);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ChannelsDelegate::setModelData()\r\n//-----------------------------------------------------------------------------\r\nvoid ChannelsDelegate::setModelData(QWidget* editor, QAbstractItemModel* model, QModelIndex const& index) const\r\n{\r\n    if (index.column() == ChannelColumns::NAME ||\r\n        index.column() == ChannelColumns::DISPLAY_NAME ||\r\n        index.column() == ChannelColumns::DESCRIPTION)\r\n    {\r\n        QLineEdit* edit = qobject_cast<QLineEdit*>(editor);\r\n        Q_ASSERT(edit);\r\n\r\n        model->setData(index, edit->text(), Qt::EditRole);\r\n    }\r\n    else\r\n    {\r\n        EnumerationEditorConstructorDelegate::setModelData(editor, model, index);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: channelsdelegate::isEnumerationEditorColumn()\r\n//-----------------------------------------------------------------------------\r\nbool ChannelsDelegate::isEnumerationEditorColumn(QModelIndex const& index) const\r\n{\r\n    if (index.column() == ChannelColumns::INTERFACES)\r\n    {\r\n        return true;\r\n    }\r\n\r\n    return false;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: channelsdelegate::getCurrentSelection()\r\n//-----------------------------------------------------------------------------\r\nQStringList ChannelsDelegate::getCurrentSelection(QModelIndex const& index) const\r\n{\r\n    return index.data(ChannelColumns::USER_DISPLAY_ROLE).toStringList();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: channelsdelegate::getAvailableItems()\r\n//-----------------------------------------------------------------------------\r\nQStringList ChannelsDelegate::getAvailableItems() const\r\n{\r\n    return component_->getBusInterfaceNames();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: channelsdelegate::setEnumerationDataToModel()\r\n//-----------------------------------------------------------------------------\r\nvoid ChannelsDelegate::setEnumerationDataToModel(QModelIndex const& index, QAbstractItemModel* model, QStringList const& selectedItems) const\r\n{\r\n    model->setData(index, selectedItems, ChannelColumns::USER_EDIT_ROLE);\r\n}\r\n"
  },
  {
    "path": "editors/ComponentEditor/channels/channelsdelegate.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: channelsdelegate.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 14.06.2012\r\n//\r\n// Description:\r\n// The delegate that provides editors to edit the channels of a component.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef CHANNELSDELEGATE_H\r\n#define CHANNELSDELEGATE_H\r\n\r\n#include <editors/ComponentEditor/common/EnumerationEditorConstructorDelegate.h>\r\n\r\n#include <QSharedPointer>\r\n\r\nclass Component;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! The delegate that provides editors to edit the channels of a component.\r\n//-----------------------------------------------------------------------------\r\nclass ChannelsDelegate : public EnumerationEditorConstructorDelegate\r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\r\n\t//! The minimum height for editor editing list of interfaces\r\n\tstatic const int LIST_EDITOR_MIN_HEIGHT = 100;\r\n\r\n\t/*! The constructor\r\n\t *\r\n\t *    @param [in] component   The component being edited.\r\n\t *    @param [in] parent      The owner of this delegate.\r\n\t*/\r\n\tChannelsDelegate(QSharedPointer<Component> component, QObject *parent);\r\n\t\r\n\t//! The destructor\r\n\tvirtual ~ChannelsDelegate();\r\n\r\n\t/*! Create a new editor for the given item\r\n\t *\r\n\t *    @param [in] parent  Owner for the editor.\r\n\t *    @param [in] option  Contains options for the editor.\r\n\t *    @param [in] index   Model index identifying the item.\r\n\t *\r\n\t *    @return The editor to be used to edit the item.\r\n\t*/\r\n\tvirtual QWidget* createEditor(QWidget* parent, QStyleOptionViewItem const& option,\r\n        QModelIndex const& index) const;\r\n\r\n\t/*! Set the data for the editor.\r\n\t *\r\n\t *    @param [in] editor  The editor where the data is to be set.\r\n\t *    @param [in] index   Model index identifying the item that's data is to be set.\r\n\t *\r\n\t*/\r\n\tvirtual void setEditorData(QWidget* editor, QModelIndex const& index) const;\r\n\r\n\t/*! Save the data from the editor to the model.\r\n\t *\r\n\t *    @param [in] editor  The editor that contains the data to store.\r\n\t *    @param [in] model   Model that contains the data structure where data is to be saved to.\r\n\t *    @param [in] index   Model index identifying the item that's data is to be saved.\r\n\t *\r\n\t*/\r\n\tvirtual void setModelData(QWidget* editor, QAbstractItemModel* model, \r\n\t\tQModelIndex const& index) const;\r\n\r\nprivate:\r\n\t\r\n\t//! No copying\r\n\tChannelsDelegate(const ChannelsDelegate& other);\r\n\tChannelsDelegate& operator=(const ChannelsDelegate& other);\r\n\r\n    /*!\r\n     *  Check if the column is used for enumerations.\r\n     *\r\n     *    @param [in] index   The selected index.\r\n     *\r\n     *    @return True, if the column is used for editing enumerations, false otherwise.\r\n     */\r\n    virtual bool isEnumerationEditorColumn(QModelIndex const& index) const override final;\r\n\r\n    /*!\r\n     *  The list of currently selected enumerations in the selected item.\r\n     *\r\n     *    @param [in] index   Index of the selected item.\r\n     *\r\n     *    @return List of currently selected enumerations.\r\n     */\r\n    virtual QStringList getCurrentSelection(QModelIndex const& index) const override final;\r\n\r\n    /*!\r\n     *  Get the list of the available enumerations.\r\n     *\r\n     *    @return List of the available enumerations.\r\n     */\r\n    virtual QStringList getAvailableItems() const override final;\r\n\r\n    /*!\r\n     *  Set the selected enumerations to the selected item.\r\n     *\r\n     *    @param [in] index           Model index identifying the item that's data is to be saved.\r\n     *    @param [in] model           Model that contains the data structure where data is to be saved to.\r\n     *    @param [in] selectedItems   List of the selected enumerations.\r\n     */\r\n    virtual void setEnumerationDataToModel(QModelIndex const& index, QAbstractItemModel* model, QStringList const& selectedItems) const override final;\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n    \r\n    //! The component being edited.\r\n\tQSharedPointer<Component> component_;\r\n};\r\n\r\n#endif // CHANNELSDELEGATE_H\r\n"
  },
  {
    "path": "editors/ComponentEditor/channels/channelseditor.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: channelseditor.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 14.06.2012\r\n//\r\n// Description:\r\n// The editor to add/remove/edit the channels of a component.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"channelseditor.h\"\r\n#include \"channelsdelegate.h\"\r\n#include \"ChannelColumns.h\"\r\n\r\n#include <common/widgets/summaryLabel/summarylabel.h>\r\n\r\n#include <KactusAPI/include/LibraryInterface.h>\r\n\r\n#include <IPXACTmodels/Component/Component.h>\r\n\r\n#include <QVBoxLayout>\r\n#include <QHeaderView>\r\n//-----------------------------------------------------------------------------\r\n// Function: ChannelsEditor::ChannelsEditor()\r\n//-----------------------------------------------------------------------------\r\nChannelsEditor::ChannelsEditor(QSharedPointer<Component> component, LibraryInterface* handler, \r\n    QSharedPointer<ChannelValidator> validator, QWidget* parent):\r\nItemEditor(component, handler, parent),\r\n    view_(this),\r\n    proxy_(this),\r\n    model_(component->getChannels(), validator, this)\r\n{\r\n    // display a label on top the table\r\n    SummaryLabel* summaryLabel = new SummaryLabel(tr(\"Channels\"), this);\r\n\r\n    QVBoxLayout* layout = new QVBoxLayout(this);\r\n    layout->addWidget(summaryLabel, 0, Qt::AlignCenter);\r\n    layout->addWidget(&view_);\r\n    layout->setContentsMargins(0, 0, 0, 0);\r\n\r\n    proxy_.setSourceModel(&model_);\r\n    view_.setModel(&proxy_);\r\n\r\n    const QString componentPath = handler->getDirectoryPath(component->getVlnv());\r\n\tQString defaultPath = QString(\"%1/channelListing.csv\").arg(componentPath);\r\n\tview_.setDefaultImportExportPath(defaultPath);\r\n\tview_.setAllowImportExport(true);\r\n\t\r\n\tview_.setItemsDraggable(false);\r\n\r\n\tview_.setItemDelegate(new ChannelsDelegate(component, this));\t\r\n\r\n\r\n    if (component->getRevision() == Document::Revision::Std14)\r\n    {\r\n        view_.hideColumn(ChannelColumns::SHORT_DESCRIPTION);\r\n    }\r\n\r\n\tconnect(&model_, SIGNAL(contentChanged()), this, SIGNAL(contentChanged()), Qt::UniqueConnection);\r\n\tconnect(&model_, SIGNAL(channelAdded(int)), this, SIGNAL(childAdded(int)), Qt::UniqueConnection);\r\n\tconnect(&model_, SIGNAL(channelRemoved(int)), this, SIGNAL(childRemoved(int)), Qt::UniqueConnection);\r\n\r\n\tconnect(&view_, SIGNAL(addItem(QModelIndex const&)),\r\n\t\t&model_, SLOT(onAddItem(QModelIndex const&)), Qt::UniqueConnection);\r\n\tconnect(&view_, SIGNAL(removeItem(QModelIndex const&)),\r\n\t\t&model_, SLOT(onRemoveItem(QModelIndex const&)), Qt::UniqueConnection);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ChannelsEditor::refresh()\r\n//-----------------------------------------------------------------------------\r\nvoid ChannelsEditor::refresh()\r\n{\r\n\tview_.update();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ChannelsEditor::showEvent()\r\n//-----------------------------------------------------------------------------\r\nvoid ChannelsEditor::showEvent(QShowEvent* event)\r\n{\r\n\tQWidget::showEvent(event);\r\n    if (component()->getRevision() == Document::Revision::Std22)\r\n    {\r\n        emit helpUrlRequested(\"componenteditor/channels2022.html\");\r\n    }\r\n    else\r\n    {\r\n        emit helpUrlRequested(\"componenteditor/channels.html\");\r\n    }\r\n}\r\n"
  },
  {
    "path": "editors/ComponentEditor/channels/channelseditor.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: channelseditor.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 14.06.2012\r\n//\r\n// Description:\r\n// The editor to add/remove/edit the channels of a component.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef CHANNELSEDITOR_H\r\n#define CHANNELSEDITOR_H\r\n\r\n#include <editors/ComponentEditor/itemeditor.h>\r\n\r\n#include \"channelsmodel.h\"\r\n\r\n#include <common/views/EditableTableView/editabletableview.h>\r\n\r\n#include <QSharedPointer>\r\n#include <QSortFilterProxyModel>\r\n\r\nclass ChannelValidator;\r\nclass Component;\r\nclass LibraryInterface;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! The editor to add/remove/edit the channels of a component.\r\n//-----------------------------------------------------------------------------\r\nclass ChannelsEditor : public ItemEditor\r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\t\r\n\t/*! The constructor\r\n\t *\r\n\t *    @param [in] component   The component being edited.\r\n\t *    @param [in] handler     The instance managing the library.\r\n     *    @param [in] validator   The validator for channel elements.\r\n\t *    @param [in] parent      The parent of this editor.\r\n\t*/\r\n\tChannelsEditor(QSharedPointer<Component> component,\tLibraryInterface* handler, \r\n        QSharedPointer<ChannelValidator> validator, QWidget* parent = nullptr);\r\n\t\r\n\t//! The destructor\r\n\tvirtual ~ChannelsEditor() = default;\r\n\r\n    //! No copying\r\n    ChannelsEditor(const ChannelsEditor& other) = delete;\r\n    ChannelsEditor& operator=(const ChannelsEditor& other) = delete;\r\n\r\n\t/*! Reload the information from the model to the editor.\r\n\t*/\r\n\tvirtual void refresh();\r\n\r\nprotected:\r\n\r\n\t//! Handler for widget's show event\r\n\tvirtual void showEvent(QShowEvent* event);\r\n\r\nprivate:\r\n\r\n\t//! The view that displays the channels.\r\n\tEditableTableView view_;\r\n\r\n\t//! The proxy that does the editing.\r\n\tQSortFilterProxyModel proxy_;\r\n\r\n\t//! The model that manages the channels being edited.\r\n\tChannelsModel model_;\r\n};\r\n\r\n#endif // CHANNELSEDITOR_H\r\n"
  },
  {
    "path": "editors/ComponentEditor/channels/channelsmodel.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: channelsmodel.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 14.06.2012\r\n//\r\n// Description:\r\n// The model class to manage the objects for channels editor.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"channelsmodel.h\"\r\n\r\n#include \"ChannelColumns.h\"\r\n\r\n#include <IPXACTmodels/Component/Channel.h>\r\n#include <IPXACTmodels/Component/validators/ChannelValidator.h>\r\n\r\n#include <common/KactusColors.h>\r\n\r\n#include <QStringList>\r\n\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ChannelsModel::ChannelsModel()\r\n//-----------------------------------------------------------------------------\r\nChannelsModel::ChannelsModel(QSharedPointer<QList<QSharedPointer<Channel> > > channels, \r\n    QSharedPointer<ChannelValidator> validator, QObject *parent ) :\r\nQAbstractTableModel(parent),\r\n    channels_(channels),\r\n    validator_(validator)\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ChannelsModel::rowCount()\r\n//-----------------------------------------------------------------------------\r\nint ChannelsModel::rowCount(QModelIndex const& parent) const\r\n{\r\n\tif (parent.isValid())\r\n    {\r\n\t\treturn 0;\r\n\t}\r\n\r\n\treturn channels_->size();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ChannelsModel::columnCount()\r\n//-----------------------------------------------------------------------------\r\nint ChannelsModel::columnCount(QModelIndex const& parent) const\r\n{\r\n\tif (parent.isValid())\r\n    {\r\n\t\treturn 0;\r\n\t}\r\n\r\n\treturn ChannelColumns::COLUMN_COUNT;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ChannelsModel::flags()\r\n//-----------------------------------------------------------------------------\r\nQt::ItemFlags ChannelsModel::flags(QModelIndex const& index) const\r\n{\r\n\tif (!index.isValid())\r\n    {\r\n\t\treturn Qt::NoItemFlags;\r\n\t}\r\n\r\n\treturn Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsEditable;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ChannelsModel::headerData()\r\n//-----------------------------------------------------------------------------\r\nQVariant ChannelsModel::headerData(int section, Qt::Orientation orientation, int role) const\r\n{\r\n    if (orientation != Qt::Horizontal || role != Qt::DisplayRole)\r\n    {\r\n        return QVariant();\r\n    }\r\n\r\n    if (section == ChannelColumns::NAME)\r\n    {\r\n        return tr(\"Name\");\r\n    }\r\n    else if (section == ChannelColumns::DISPLAY_NAME)\r\n    {\r\n        return tr(\"Display name\");\r\n    }\r\n    else if (section == ChannelColumns::INTERFACES) \r\n    {\r\n        return tr(\"Interface references\");\r\n    }\r\n    else if (section == ChannelColumns::SHORT_DESCRIPTION)\r\n    {\r\n        return tr(\"Short description\");\r\n    }\r\n    else if (section == ChannelColumns::DESCRIPTION)\r\n    {\r\n        return tr(\"Description\");\r\n    }\r\n    else\r\n    {\r\n        return QVariant();\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ChannelsModel::data()\r\n//-----------------------------------------------------------------------------\r\nQVariant ChannelsModel::data(QModelIndex const& index, int role) const\r\n{\r\n\tif (!index.isValid() || index.row() < 0 || index.row() >= channels_->size())\r\n    {\r\n\t\treturn QVariant();\r\n    }\r\n\r\n    if (role == Qt::DisplayRole)\r\n    {\r\n        if (index.column() == ChannelColumns::NAME)\r\n        {\r\n            return channels_->at(index.row())->name();\r\n        }\r\n        else if (index.column() == ChannelColumns::DISPLAY_NAME)\r\n        {\r\n            return channels_->at(index.row())->displayName();\r\n        }\r\n        else if (index.column() == ChannelColumns::INTERFACES)\r\n        {\r\n            QStringList interfaceNames = channels_->at(index.row())->getInterfaceNames();\r\n            return interfaceNames.join(' ');\r\n        }\r\n        else if (index.column() == ChannelColumns::SHORT_DESCRIPTION)\r\n        {\r\n            return channels_->at(index.row())->shortDescription();\r\n        }\r\n        else if (index.column() == ChannelColumns::DESCRIPTION)\r\n        {\r\n            return channels_->at(index.row())->description();\r\n        }\r\n        else\r\n        {\r\n            return QVariant();\r\n        }\r\n\r\n    }\r\n\r\n\t// user display role for interface column returns a QStringList\r\n\telse if (role == ChannelColumns::USER_DISPLAY_ROLE && index.column() == ChannelColumns::INTERFACES)\r\n    {\r\n\t\treturn channels_->at(index.row())->getInterfaceNames();\r\n\t}\r\n\r\n\telse if (role == Qt::ForegroundRole)\r\n    {\r\n\r\n        if (index.column() == ChannelColumns::INTERFACES && \r\n            !validator_->hasValidBusInterfaceReferences(channels_->at(index.row())))\r\n        {\r\n            return KactusColors::ERROR;\r\n        }\r\n        else\r\n        {\r\n            return KactusColors::REGULAR_TEXT;\r\n        }\r\n\t}\r\n\r\n\telse if (role == Qt::BackgroundRole)\r\n    {\r\n        if (index.column() == ChannelColumns::NAME || index.column() == ChannelColumns::INTERFACES)\r\n        {\r\n            return KactusColors::MANDATORY_FIELD;\r\n        }\r\n        else\r\n        {\r\n            return KactusColors::REGULAR_FIELD;\r\n        }\r\n    }\r\n\telse \r\n    {\r\n\t\treturn QVariant();\r\n\t}\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ChannelsModel::setData()\r\n//-----------------------------------------------------------------------------\r\nbool ChannelsModel::setData(QModelIndex const& index, QVariant const& value, int role)\r\n{\r\n\tif (!index.isValid() || index.row() < 0 || index.row() >= channels_->size())\r\n    {\r\n\t\treturn false;\r\n\t}\r\n\r\n\tif (role == Qt::EditRole)\r\n    {\r\n        if (index.column() ==  ChannelColumns::NAME)\r\n        {\r\n            channels_->at(index.row())->setName(value.toString());\r\n        }\r\n        else if (index.column() == ChannelColumns::DISPLAY_NAME)\r\n        {\r\n            channels_->at(index.row())->setDisplayName(value.toString());\t\t\r\n        }\r\n        else if (index.column() == ChannelColumns::INTERFACES)\r\n        {\r\n            QString str = value.toString();\r\n            QStringList interfaceNames = str.split(' ', Qt::SkipEmptyParts);\r\n            channels_->at(index.row())->setInterfaces(interfaceNames);\r\n        }\r\n        else if (index.column() == ChannelColumns::SHORT_DESCRIPTION)\r\n        {\r\n            channels_->at(index.row())->setShortDescription(value.toString());\r\n        }\r\n        else if (index.column() == ChannelColumns::DESCRIPTION)\r\n        {\r\n            channels_->at(index.row())->setDescription(value.toString());\r\n        }\r\n        else\r\n        {\r\n            return false;\r\n        }\r\n\r\n\r\n\t\temit dataChanged(index, index);\r\n\t\temit contentChanged();\r\n\t\treturn true;\r\n\t}\r\n\t// user edit role for interface column operates on QStringList\r\n\telse if (role == ChannelColumns::USER_EDIT_ROLE && ChannelColumns::INTERFACES == index.column())\r\n    {\r\n\t\tchannels_->at(index.row())->setInterfaces(value.toStringList());\r\n\t\temit dataChanged(index, index);\r\n\t\temit contentChanged();\r\n\t\treturn true;\r\n\t}\r\n\telse\r\n    {\r\n\t\treturn false;\r\n\t}\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ChannelsModel::onAddItem()\r\n//-----------------------------------------------------------------------------\r\nvoid ChannelsModel::onAddItem(QModelIndex const& index)\r\n{\r\n\tint row = channels_->size();\r\n\r\n\t// if the index is valid then add the item to the correct position\r\n\tif (index.isValid())\r\n    {\r\n\t\trow = index.row();\r\n\t}\r\n\r\n\tbeginInsertRows(QModelIndex(), row, row);\r\n\tchannels_->insert(row, QSharedPointer<Channel>(new Channel()));\r\n\tendInsertRows();\r\n\r\n\t// inform navigation tree that file set is added\r\n\temit channelAdded(row);\r\n\r\n\t// tell also parent widget that contents have been changed\r\n\temit contentChanged();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ChannelsModel::onRemoveItem()\r\n//-----------------------------------------------------------------------------\r\nvoid ChannelsModel::onRemoveItem(QModelIndex const& index)\r\n{\r\n\t// don't remove anything if index is invalid\r\n\tif (!index.isValid() || index.row() < 0 || index.row() >= channels_->size())\r\n    {\r\n\t\treturn;\r\n\t}\r\n\r\n\t// remove the specified item\r\n\tbeginRemoveRows(QModelIndex(), index.row(), index.row());\r\n\tchannels_->removeAt(index.row());\r\n\tendRemoveRows();\r\n\r\n\t// inform navigation tree that file set has been removed\r\n\temit channelRemoved(index.row());\r\n\r\n\t// tell also parent widget that contents have been changed\r\n\temit contentChanged();\r\n}\r\n"
  },
  {
    "path": "editors/ComponentEditor/channels/channelsmodel.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: channelsmodel.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 14.06.2012\r\n//\r\n// Description:\r\n// The model class to manage the objects for channels editor.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef CHANNELSMODEL_H\r\n#define CHANNELSMODEL_H\r\n\r\n#include <QAbstractTableModel>\r\n#include <QList>\r\n#include <QSharedPointer>\r\n\r\nclass Channel;\r\nclass ChannelValidator;\r\n//-----------------------------------------------------------------------------\r\n//! The model class to manage the objects for channels editor.\r\n//-----------------------------------------------------------------------------\r\nclass ChannelsModel : public QAbstractTableModel\r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\r\n\t/*! The constructor\r\n\t *\r\n\t *    @param [in] channels    The channels being edited.\r\n     *    @param [in] validator   The validator for channel elements.\r\n\t *    @param [in] parent      The owner of this model.\r\n\t*/\r\n\tChannelsModel(QSharedPointer<QList<QSharedPointer<Channel> > > channels, \r\n        QSharedPointer<ChannelValidator> validator, QObject *parent);\r\n\t\r\n\t//! The destructor.\r\n\tvirtual ~ChannelsModel() = default;\r\n\r\n    //! No copying\r\n    ChannelsModel(const ChannelsModel& other) = delete;\r\n    ChannelsModel& operator=(const ChannelsModel& other) = delete;\r\n\r\n\t/*! Get the number of rows an item contains.\r\n\t *\r\n\t *    @param [in] parent Identifies the parent that's row count is requested.\r\n\t *\r\n\t *    @return Number of rows the item has.\r\n\t*/\r\n\tvirtual int rowCount(QModelIndex const& parent = QModelIndex()) const;\r\n\r\n\t/*! Get the number of columns the item has to be displayed.\r\n\t *\r\n\t *    @param [in] parent Identifies the parent that's column count is requested.\r\n\t *\r\n\t *    @return The number of columns to be displayed.\r\n\t*/\r\n\tvirtual int columnCount(QModelIndex const& parent = QModelIndex()) const;\r\n\r\n\t/*! Get the item flags that defines the possible operations for the item.\r\n\t *\r\n\t *    @param [in] index Model index that identifies the item.\r\n\t *\r\n\t *    @return Qt::ItemFlags specify the possible operations for the item.\r\n\t*/\r\n\tQt::ItemFlags flags(QModelIndex const& index) const;\r\n\r\n\t/*! Get the header data for specified header.\r\n\t *\r\n\t *    @param [in] section         The section specifies the row/column number for the header.\r\n\t *    @param [in] orientation     Specified if horizontal or vertical header is wanted.\r\n\t *    @param [in] role            Specifies the type of the requested data.\r\n\t *\r\n\t *    @return QVariant Contains the requested data.\r\n\t*/\r\n\tvirtual QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;\r\n\r\n\t/*! Get the data for specified item.\r\n\t *\r\n\t *    @param [in] index   Specifies the item that's data is requested.\r\n\t *    @param [in] role    The role that defines what kind of data is requested.\r\n\t *\r\n\t *    @return QVariant Contains the data for the item.\r\n\t*/\r\n\tvirtual QVariant data(QModelIndex const& index, int role = Qt::DisplayRole) const;\r\n\r\n\t/*! Save the data to the model for specified item\r\n\t *\r\n\t *    @param [in] index   The model index of the item that's data is to be saved.\r\n\t *    @param [in] value   The data that is to be saved.\r\n\t *    @param [in] role    The role specifies what kind of data should be saved.\r\n\t *\r\n\t *    @return True if saving happened successfully.\r\n\t*/\r\n\tbool setData(QModelIndex const& index, const QVariant& value, int role = Qt::EditRole);\r\n\r\n\r\npublic slots:\r\n\r\n\t/*! Add a new item to the given index.\r\n\t *\r\n\t *    @param [in] index The index identifying the position for new item.\r\n\t *\r\n\t*/\r\n\tvirtual void onAddItem(QModelIndex const& index);\r\n\r\n\t/*! Remove the item in the given index.\r\n\t *\r\n\t *    @param [in] index The index identifying the item to remove.\r\n\t *\r\n\t*/\r\n\tvirtual void onRemoveItem(QModelIndex const& index);\r\n\r\nsignals:\r\n\r\n\t//! Emitted when the contents of the model change.\r\n\tvoid contentChanged();\r\n\r\n\t/*! Emitted when a new channel is added to the model.\r\n\t *\r\n\t *    @param [in] index The index of the added channel.\r\n\t *\r\n\t*/\r\n\tvoid channelAdded(int index);\r\n\r\n\t/*! Emitted when a channel is removed from the model.\r\n\t *\r\n\t *    @param [in] index The index of the channel to remove.\r\n\t *\r\n\t*/\r\n\tvoid channelRemoved(int index);\r\n\r\nprivate:\r\n\r\n\t//! The channels being edited.\r\n\tQSharedPointer<QList<QSharedPointer<Channel> > > channels_;\r\n\r\n    //! The validator for the channels.\r\n    QSharedPointer<ChannelValidator> validator_;\r\n};\r\n\r\n#endif // CHANNELSMODEL_H\r\n"
  },
  {
    "path": "editors/ComponentEditor/choices/ChoiceColumns.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ChoiceColumns.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Mikko Teuho\r\n// Date: 20.10.2015\r\n//\r\n// Description:\r\n// Common declarations for editing choices.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef CHOICECOLUMNS_H\r\n#define CHOICECOLUMNS_H\r\n\r\nnamespace ChoiceColumns\r\n{\r\n    //! The editable columns in the choices editor.\r\n    enum columns\r\n    {\r\n        CHOICE_NAME = 0,\r\n        CHOICE_ENUMERATIONS,\r\n        COLUMN_COUNT\r\n    };\r\n}\r\n\r\n#endif // CHOICECOLUMNS_H"
  },
  {
    "path": "editors/ComponentEditor/choices/ChoicesEditor.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ChoicesEditor.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Esko Pekkarinen\r\n// Date: 05.11.2014\r\n//\r\n// Description:\r\n// Editor for component choices.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"ChoicesEditor.h\"\r\n\r\n#include <common/delegates/LineEditDelegate/lineeditdelegate.h>\r\n\r\n#include <common/views/EditableTableView/editabletableview.h>\r\n\r\n#include <common/widgets/summaryLabel/summarylabel.h>\r\n\r\n#include <editors/ComponentEditor/choices/ChoicesModel.h>\r\n#include <editors/ComponentEditor/choices/EnumerationModel.h>\r\n\r\n#include <IPXACTmodels/common/Choice.h>\r\n#include <IPXACTmodels/Component/Component.h>\r\n\r\n#include <QSortFilterProxyModel>\r\n#include <QVBoxLayout>\r\n#include <QGroupBox>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ChoicesEditor::ChoicesEditor()\r\n//-----------------------------------------------------------------------------\r\nChoicesEditor::ChoicesEditor(QSharedPointer<Component> component, QSharedPointer<ChoiceValidator> validator,\r\n    QWidget* parent /* = 0 */):\r\nItemEditor(component, 0, parent),\r\nchoiceList_(this),\r\nchoiceModel_(new ChoicesModel(component->getChoices(), validator, this)),\r\nenumerationView_(new EditableTableView(this)),\r\nenumerationModel_(new EnumerationModel(this))\r\n{\r\n    choiceList_.setModel(choiceModel_);\r\n    choiceList_.setItemDelegate(new LineEditDelegate(this));\r\n\r\n    QSortFilterProxyModel* enumerationProxy(new QSortFilterProxyModel(this));\r\n    enumerationProxy->setSourceModel(enumerationModel_);\r\n\r\n    enumerationView_->setItemsDraggable(false);\r\n    enumerationView_->setSortingEnabled(true);\r\n    enumerationView_->setModel(enumerationProxy);\r\n    enumerationView_->setDisabled(true); // Set disabled before a choice has been selected or created.\r\n\r\n\tconnect(&choiceList_, SIGNAL(removeItem(const QModelIndex&)), choiceModel_, SLOT(remove(const QModelIndex&)), Qt::UniqueConnection);\r\n\tconnect(&choiceList_, SIGNAL(addItem(const QModelIndex&)), choiceModel_, SLOT(addItem(const QModelIndex&)), Qt::UniqueConnection);\r\n\tconnect(&choiceList_, SIGNAL(moveItem(const QModelIndex&, const QModelIndex&)), choiceModel_, SLOT(moveItem(const QModelIndex&, const QModelIndex&)), Qt::UniqueConnection);\r\n\r\n\tconnect(&choiceList_, SIGNAL(selectionChanged(QModelIndex const&)),\r\n\t\tthis, SLOT(selectionChoiceChanged(QModelIndex const&)), Qt::UniqueConnection);\r\n\r\n    connect(choiceModel_, SIGNAL(contentChanged()), this, SIGNAL(contentChanged()), Qt::UniqueConnection);\r\n    connect(choiceModel_, SIGNAL(choicesEmpty(bool)), this, SLOT(onChoiceListEmpty(bool)), Qt::UniqueConnection);\r\n\r\n    connect(enumerationModel_, SIGNAL(contentChanged()), this, SIGNAL(contentChanged()), Qt::UniqueConnection);\r\n\tconnect(enumerationModel_, SIGNAL(dataChanged(const QModelIndex&, const QModelIndex&)), this, SIGNAL(contentChanged()), Qt::UniqueConnection);\r\n\r\n\tconnect(enumerationView_, SIGNAL(addItem(const QModelIndex&)), enumerationModel_, SLOT(onAddItem(const QModelIndex&)), Qt::UniqueConnection);\r\n\tconnect(enumerationView_, SIGNAL(removeItem(const QModelIndex&)), enumerationModel_, SLOT(onRemoveItem(const QModelIndex&)), Qt::UniqueConnection);\r\n\r\n    setupLayout();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ChoicesEditor::selectionFunctionChanged()\r\n//-----------------------------------------------------------------------------\r\nvoid ChoicesEditor::selectionChoiceChanged(QModelIndex const& newIndex)\r\n{\r\n    QSharedPointer<Choice> currentChoice = choiceModel_->getChoice(newIndex);\r\n\r\n    if (currentChoice)\r\n    {\r\n        enumerationModel_->setupEnumerations(currentChoice->enumerations());\r\n        enumerationView_->setEnabled(true);\r\n    }\r\n    else\r\n    {\r\n        enumerationModel_->clearEnumerations();\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ChoicesEditor::isValid()\r\n//-----------------------------------------------------------------------------\r\nbool ChoicesEditor::isValid() const\r\n{\r\n    return choiceModel_->validate();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ChoicesEditor::refresh()\r\n//-----------------------------------------------------------------------------\r\nvoid ChoicesEditor::refresh()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ChoicesEditor::onChoiceListEmpty()\r\n//-----------------------------------------------------------------------------\r\nvoid ChoicesEditor::onChoiceListEmpty(bool isEmpty)\r\n{\r\n    enumerationView_->setDisabled(isEmpty);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ChoicesEditor::showEvent()\r\n//-----------------------------------------------------------------------------\r\nvoid ChoicesEditor::showEvent(QShowEvent* event)\r\n{\r\n    QWidget::showEvent(event);\r\n    emit helpUrlRequested(\"componenteditor/choices.html\");\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ChoicesEditor::setupLayout()\r\n//-----------------------------------------------------------------------------\r\nvoid ChoicesEditor::setupLayout()\r\n{\r\n    // display a label on top the table\r\n    SummaryLabel* summaryLabel = new SummaryLabel(tr(\"Choices\"), this);\r\n\r\n    // create the layout, add widgets to it\r\n    QVBoxLayout* choiceGroupLayout(new QVBoxLayout());\r\n    choiceGroupLayout->addWidget(&choiceList_);\r\n\r\n    QGroupBox* choiceGroup(new QGroupBox(\"Choice list\"));\r\n    choiceGroup->setLayout(choiceGroupLayout);\r\n\r\n\tQVBoxLayout* enumerationGroupLayout(new QVBoxLayout());\r\n\tenumerationGroupLayout->addWidget(enumerationView_);\r\n\r\n\tQGroupBox* enumerationGroup(new QGroupBox(\"Enumerations\"));\r\n    enumerationGroup->setLayout(enumerationGroupLayout);\r\n\r\n    QHBoxLayout* choicesLayout(new QHBoxLayout());\r\n    choicesLayout->addWidget(choiceGroup);\r\n\tchoicesLayout->addWidget(enumerationGroup, 4);\r\n\r\n    QVBoxLayout* mainLayout(new QVBoxLayout(this));\r\n    mainLayout->addWidget(summaryLabel, 0, Qt::AlignCenter);\r\n    mainLayout->addLayout(choicesLayout);\r\n\tmainLayout->setContentsMargins(0, 0, 0, 0);\r\n}\r\n"
  },
  {
    "path": "editors/ComponentEditor/choices/ChoicesEditor.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ChoicesEditor.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Esko Pekkarinen\r\n// Date: 05.11.2014\r\n//\r\n// Description:\r\n// Editor for component choices.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef CHOICESEDITOR_H\r\n#define CHOICESEDITOR_H\r\n\r\n#include <common/views/EditableListView/editablelistview.h>\r\n\r\n#include <editors/ComponentEditor/itemeditor.h>\r\n\r\n#include <QSortFilterProxyModel>\r\n#include <QSharedPointer>\r\n\r\nclass EditableTableView;\r\nclass ChoicesModel;\r\nclass Component;\r\nclass ChoiceValidator;\r\nclass EnumerationModel;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Editor for component choices.\r\n//-----------------------------------------------------------------------------\r\nclass ChoicesEditor : public ItemEditor\r\n{\r\n    Q_OBJECT\r\n\r\npublic:\r\n\r\n    /*!\r\n     *  The constructor.\r\n     *\r\n     *    @param [in] component   The component whose choices to edit.\r\n     *    @param [in] validator   The validator used for choices.\r\n     *    @param [in] parent      The parent widget.\r\n     *\r\n     *    @return <Description>.\r\n     */\r\n    ChoicesEditor(QSharedPointer<Component> component, QSharedPointer<ChoiceValidator> validator,\r\n        QWidget* parent = 0);\r\n\r\n    /*!\r\n     *\tThe destructor\r\n     */\r\n    virtual ~ChoicesEditor() = default;\r\n\r\n   /*! Check for the validity of the choices.\r\n    * \r\n    *    @return True, if all the choices are valid, otherwise false.\r\n    */\r\n    virtual bool isValid() const;\r\n    \r\n    /*!\r\n     *\tReloads the information from the model to the editor.\r\n     */\r\n    virtual void refresh();\r\n\r\npublic slots:\r\n\r\n    /*!\r\n     *\tCalled when the choise list is emptied or is no longer empty.\r\n     *  \r\n     *    @param [in] isEmpty     Indicates if the list was emptied or no longer empty.\r\n     */\r\n    void onChoiceListEmpty(bool isEmpty);\r\n\r\nprotected:\r\n\r\n    /*!\r\n     *\tCalled when the editor is shown.\r\n     */\r\n    void showEvent( QShowEvent* event );\r\n\r\nprivate slots:\r\n\r\n    /*!\r\n     *\tCalled when a choice has been selected.\r\n     * \r\n     *    @param [in] newIndex    Index of the selected choice.\r\n     */\r\n    void selectionChoiceChanged(QModelIndex const& newIndex);\r\n\r\nprivate:\r\n\r\n    //! No copying\r\n    ChoicesEditor(const ChoicesEditor& other);\r\n    ChoicesEditor& operator=(const ChoicesEditor& other);\r\n\r\n    //! Creates the editor layout.\r\n    void setupLayout();\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! The list view for choices.\r\n    EditableListView choiceList_;\r\n\r\n    //! Model for the component choices.\r\n    ChoicesModel* choiceModel_;\r\n\r\n    //! View for the choice enumerations.\r\n    EditableTableView* enumerationView_;\r\n\r\n    //! Model for choice enumerations.\r\n    EnumerationModel* enumerationModel_;\r\n};\r\n\r\n#endif // CHOICESEDITOR_H\r\n"
  },
  {
    "path": "editors/ComponentEditor/choices/ChoicesModel.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ChoicesModel.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Esko Pekkarinen\r\n// Date: 04.11.2014\r\n//\r\n// Description:\r\n// Model for editing choices in a component.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"ChoicesModel.h\"\r\n\r\n#include <IPXACTmodels/common/Choice.h>\r\n#include <IPXACTmodels/common/validators/ChoiceValidator.h>\r\n\r\n#include <common/KactusColors.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ChoicesModel::ChoicesModel()\r\n//-----------------------------------------------------------------------------\r\nChoicesModel::ChoicesModel(QSharedPointer<QList<QSharedPointer<Choice>>> choices, QSharedPointer<ChoiceValidator> validator, QObject* parent /* = 0 */) :\r\nQAbstractListModel(parent),\r\nchoices_(choices),\r\nvalidator_(validator)\r\n{\r\n    connect(this, SIGNAL(dataChanged(const QModelIndex&, const QModelIndex&)), this, SIGNAL(contentChanged()), Qt::UniqueConnection);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ChoicesModel::validate()\r\n//-----------------------------------------------------------------------------\r\nbool ChoicesModel::validate() const\r\n{\r\n    for (auto choice : *choices_)\r\n    {\r\n        if (!validator_->validate(choice))\r\n        {\r\n            return false;\r\n        }\r\n    }\r\n\r\n    return true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ChoicesModel::rowCount()\r\n//-----------------------------------------------------------------------------\r\nint ChoicesModel::rowCount(const QModelIndex&) const\r\n{\r\n    if (choices_)\r\n    {\r\n        return choices_->size();\r\n    }\r\n    else\r\n    {\r\n        return 0;\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ChoicesModel::data()\r\n//-----------------------------------------------------------------------------\r\nQVariant ChoicesModel::data(const QModelIndex& index, int role) const\r\n{\r\n    if (!index.isValid() || index.row() < 0 || index.row() >= choices_->size())\r\n    {\r\n        return QVariant();\r\n    }\r\n    \r\n    QSharedPointer<Choice> indexedChoice = choices_->at(index.row());\r\n    \r\n    if (role == Qt::DisplayRole)\r\n    {\r\n        return indexedChoice->name();\r\n    }\r\n    else if (role == Qt::ForegroundRole)\r\n    {\r\n        return validator_->validate(indexedChoice);\r\n    }\r\n    else\r\n    {\r\n        return QVariant();\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ChoicesModel::headerData()\r\n//-----------------------------------------------------------------------------\r\nQVariant ChoicesModel::headerData(int section, Qt::Orientation orientation, int role) const\r\n{\r\n    if (section != 0 || orientation != Qt::Horizontal || role != Qt::DisplayRole)\r\n    {\r\n        return QVariant();\r\n    }\r\n    else\r\n    {\r\n        return tr(\"Choices\");\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ChoicesModel::setData()\r\n//-----------------------------------------------------------------------------\r\nbool ChoicesModel::setData(const QModelIndex& index, const QVariant& value, int role)\r\n{\r\n    if (!index.isValid() || index.column() != 0 || index.row() < 0 || index.row() >= choices_->size())\r\n    {\r\n        return false;\r\n    }\r\n    \r\n    if (role == Qt::EditRole)\r\n    {\r\n        choices_->at(index.row())->setName(value.toString());\r\n        emit dataChanged(index, index);\r\n        emit contentChanged();\r\n        return true;\r\n    }\r\n    else\r\n    {\r\n        return false;\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ChoicesModel::flags()\r\n//-----------------------------------------------------------------------------\r\nQt::ItemFlags ChoicesModel::flags(const QModelIndex& index) const\r\n{\r\n    if (!index.isValid())\r\n    {\r\n        return Qt::NoItemFlags;\r\n    }\r\n    \r\n    return Qt::ItemIsEditable | Qt::ItemIsEnabled | Qt::ItemIsSelectable;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ChoicesModel::addItem()\r\n//-----------------------------------------------------------------------------\r\nvoid ChoicesModel::addItem(const QModelIndex& index)\r\n{\r\n    int row = choices_->size();\r\n\r\n    if (row == 0)\r\n    {\r\n        emit choicesEmpty(false);\r\n    }\r\n\r\n    if (index.isValid())\r\n    {\r\n        row = index.row();\r\n    }\r\n    \r\n    beginInsertRows(QModelIndex(), row, row);\r\n    \r\n    QSharedPointer<Choice> newChoice(new Choice());\r\n    newChoice->setName(\"newChoice\");\r\n\r\n    choices_->insert(row, newChoice);\r\n    \r\n    endInsertRows();\r\n    \r\n    emit contentChanged();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ChoicesModel::remove()\r\n//-----------------------------------------------------------------------------\r\nvoid ChoicesModel::remove(const QModelIndex& index)\r\n{\r\n    if (!index.isValid() || index.row() < 0 || index.row() >= choices_->size())\r\n    {\r\n        return;\r\n    }\r\n    \r\n    beginRemoveRows(QModelIndex(), index.row(), index.row());\r\n    \r\n    choices_->removeAt(index.row());\r\n    \r\n    endRemoveRows();\r\n    \r\n    emit contentChanged();\r\n\r\n    if (choices_->isEmpty())\r\n    {\r\n        emit choicesEmpty(true);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ChoicesModel::moveItem()\r\n//-----------------------------------------------------------------------------\r\nvoid ChoicesModel::moveItem(const QModelIndex& originalPos, const QModelIndex& newPos)\r\n{\r\n    if (!originalPos.isValid() || originalPos == newPos || originalPos.row() < 0 || originalPos.row() >= choices_->size())\r\n    {\r\n        return;\r\n    }\r\n    \r\n    if (!newPos.isValid() || newPos.row() < 0 || newPos.row() >= choices_->size())\r\n    {\r\n        beginResetModel();\r\n        \r\n        QSharedPointer<Choice> selectedChoice = choices_->takeAt(originalPos.row());\r\n        choices_->append(selectedChoice);\r\n        \r\n        endResetModel();\r\n    }\r\n    else\r\n    {\r\n        beginResetModel();\r\n        \r\n        choices_->swapItemsAt(originalPos.row(), newPos.row());\r\n        \r\n        endResetModel();\r\n    }\r\n    \r\n    emit contentChanged();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ChoicesModel::replace()\r\n//-----------------------------------------------------------------------------\r\nvoid ChoicesModel::replace(QModelIndex& index, const QString newText)\r\n{\r\n    if (!index.isValid() || index.row() < 0 || index.row() >= choices_->size())\r\n    {\r\n        return;\r\n    }\r\n\r\n    choices_->at(index.row())->setName(newText);\r\n    \r\n    emit dataChanged(index, index);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ChoicesModel::getChoice()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<Choice> ChoicesModel::getChoice(QModelIndex const& index) const\r\n{\r\n    if (!index.isValid() || index.row() < 0 || index.row() >= choices_->size())\r\n    {\r\n        return QSharedPointer<Choice>();\r\n    }\r\n    \r\n    return choices_->at(index.row());\r\n}\r\n"
  },
  {
    "path": "editors/ComponentEditor/choices/ChoicesModel.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ChoicesModel.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Esko Pekkarinen\r\n// Date: 04.11.2014\r\n//\r\n// Description:\r\n// Model for editing choices in a component.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef CHOICESMODEL_H\r\n#define CHOICESMODEL_H\r\n\r\n#include <QObject>\r\n#include <QAbstractListModel>\r\n#include <QVariant>\r\n#include <QModelIndex>\r\n#include <QSharedPointer>\r\n\r\nclass Choice;\r\nclass ChoiceValidator;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Model for editing choices in a component.\r\n//-----------------------------------------------------------------------------\r\nclass ChoicesModel : public QAbstractListModel\r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n    \r\n    /*!\r\n     *  Constructor.\r\n     *\r\n     *    @param [in] choices     List of the available choices.\r\n     *    @param [in] validator   Validator for choices.\r\n     *    @param [in] parent      The parent object.\r\n     */\r\n    ChoicesModel(QSharedPointer<QList<QSharedPointer<Choice> > > choices,\r\n        QSharedPointer<ChoiceValidator> validator,\r\n        QObject* parent = 0);\r\n    \r\n    /*!\r\n     *  Destructor.\r\n     */\r\n    virtual ~ChoicesModel() = default;\r\n\r\n    /*!\r\n     *  Validate the choices.\r\n     * \r\n     *    @return True, if the choices are valid, false otherwise.\r\n     */\r\n    bool validate() const;\r\n\r\n    /*!\r\n     *  Returns the choice at the given index.\r\n     *\r\n     *    @param [in] index   The selected index.\r\n     */\r\n    QSharedPointer<Choice> getChoice(QModelIndex const& index) const;\r\n    \r\n    /*!\r\n     *  Returns the number of rows in this model.\r\n     *\r\n     *    @param [in] parent ModelIndex of the item that's rowCount is requested.\r\n     */\r\n    virtual int rowCount(const QModelIndex& parent = QModelIndex()) const;\r\n    \r\n    /*!\r\n     *  Returns the data stored for the specified item.\r\n     *\r\n     *    @param [in] index  ModelIndex of the wanted item.\r\n     *    @param [in] role   Specifies what kind of data is requested.\r\n     */\r\n    virtual QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const;\r\n    \r\n    /*!\r\n     *  Returns the data for the header of the list.\r\n     *\r\n     *    @param [in] section      Specifies the column for which the header is requested.\r\n     *    @param [in] orientation  The orientation of the header, only Qt::Horizontal is supported.\r\n     *    @param [in] role         Specifies what kind of header data is requested.\r\n     */\r\n    virtual QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;\r\n    \r\n    /*!\r\n     *  Saves the data to the model for specified item\r\n     *\r\n     *    @param [in] index  The model index of the item that's data is to be saved.\r\n     *    @param [in] value  The data that is to be saved.\r\n     *    @param [in] role   The role specifies what kind of data should be saved.\r\n     *\r\n     *    @return True if saving happened successfully.\r\n     */\r\n    virtual bool setData(const QModelIndex& index, const QVariant& value, int role = Qt::EditRole);\r\n    \r\n    /*!\r\n     *  Returns the item flags that defines the possible operations for the item.\r\n     *\r\n     *    @param [in] index Model index that identifies the item.\r\n     *\r\n     *    @return Qt::ItemFlags specify the possible operations for the item.\r\n     */\r\n    virtual Qt::ItemFlags flags(const QModelIndex& index) const;\r\n    \r\n    /*!\r\n     *  Replace an item text in the list.\r\n     *\r\n     *    @param [in] index    ModelIndex of the item that is to be replaced.\r\n     *    @param [in] newText  The new text for the given item.\r\n     */\r\n    virtual void replace(QModelIndex& index, const QString newText);\r\n\r\npublic slots:\r\n    \r\n    /*!\r\n     *  Removes the specified item from the model.\r\n     *\r\n     *    @param [in] index The model index of the item to remove.\r\n     */\r\n    virtual void remove(const QModelIndex& index);\r\n    \r\n    /*!\r\n     *  A new item should be added to given index.\r\n     *\r\n     *    @param [in] index The position where new item should be added at.\r\n     */\r\n    virtual void addItem(const QModelIndex& index);\r\n    \r\n    /*!\r\n     *  Move item to another position.\r\n     *\r\n     *    @param [in] originalPos  Identifies the item that should be moved.\r\n     *    @param [in] newPos       The new position the item should be moved to.\r\n     */\r\n    virtual void moveItem(const QModelIndex& originalPos, const QModelIndex& newPos);\r\n\r\nsignals:\r\n\r\n    /*!\r\n     *  Emitted when contents of the model change.\r\n     */\r\n\tvoid contentChanged();\r\n    \r\n    /*!\r\n     *\tEmitted when the choice list empties or is no longer empty\r\n     *  \r\n     *    @param [in] isEmpty     Indicates if list was emptied or not.\r\n     */\r\n    void choicesEmpty(bool isEmpty);\r\n\r\nprivate:\r\n    \r\n    // Disable copying.\r\n    ChoicesModel(ChoicesModel const& rhs);\r\n    ChoicesModel& operator=(ChoicesModel const& rhs);\r\n    \r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n    \r\n    //! The list of available choices.\r\n    QSharedPointer<QList<QSharedPointer<Choice> > > choices_;\r\n    \r\n    //! Validator for choices.\r\n    QSharedPointer<ChoiceValidator> validator_;\r\n};\r\n\r\n#endif // CHOICESMODEL_H\r\n"
  },
  {
    "path": "editors/ComponentEditor/choices/EnumerationColumns.h",
    "content": "//-----------------------------------------------------------------------------\n// File: EnumerationColumns.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 10.10.2022\n//\n// Description:\n// Common declarations for editing choice enumerations.\n//-----------------------------------------------------------------------------\n\n#ifndef ENUMERATIONCOLUMNS_H\n#define ENUMERATIONCOLUMNS_H\n\nnamespace EnumerationColumns\n{\n    //! The editable columns in the enumerations editor.\n    enum columns\n    {\n\t\tENUMERATION = 0,\n\t\tTEXT,\n\t\tHELP,\n\t\tCOLUMN_COUNT\n    };\n}\n\n#endif // ENUMERATIONCOLUMNS_H"
  },
  {
    "path": "editors/ComponentEditor/choices/EnumerationModel.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: EnumerationModel.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Esko Pekkarinen\r\n// Date: 04.11.2014\r\n//\r\n// Description:\r\n// Model for editing Enumeration within a Choice element.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"EnumerationModel.h\"\r\n\r\n#include <common/KactusColors.h>\r\n\r\n#include <editors/ComponentEditor/choices/EnumerationColumns.h>\r\n\r\n#include <IPXACTmodels/common/Enumeration.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: EnumerationModel::EnumerationModel()\r\n//-----------------------------------------------------------------------------\r\nEnumerationModel::EnumerationModel(QObject* parent):\r\nQAbstractTableModel (parent),\r\nenumerations_()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: EnumerationModel::setupEnumerations()\r\n//-----------------------------------------------------------------------------\r\nvoid EnumerationModel::setupEnumerations(QSharedPointer<QList<QSharedPointer<Enumeration> > > newEnumerations)\r\n{\r\n    beginResetModel();\r\n\r\n    enumerations_ = newEnumerations;\r\n\r\n    endResetModel();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: EnumerationModel::setupEnumerations()\r\n//-----------------------------------------------------------------------------\r\nvoid EnumerationModel::clearEnumerations()\r\n{\r\n    beginResetModel();\r\n\r\n    enumerations_.clear();\r\n\r\n    endResetModel();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: EnumerationModel::columnCount()\r\n//-----------------------------------------------------------------------------\r\nint EnumerationModel::columnCount(QModelIndex const& parent) const\r\n{\r\n    if (parent.isValid())\r\n    {\r\n        return 0;\r\n    }\r\n\r\n    return EnumerationColumns::COLUMN_COUNT;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: EnumerationModel::rowCount()\r\n//-----------------------------------------------------------------------------\r\nint EnumerationModel::rowCount(QModelIndex const& parent) const\r\n{\r\n    if (parent.isValid() || enumerations_.isNull())\r\n    {\r\n        return 0;\r\n    }\r\n\r\n    return enumerations_->size();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: EnumerationModel::data()\r\n//-----------------------------------------------------------------------------\r\nQVariant EnumerationModel::data(QModelIndex const& index, int role) const\r\n{\r\n    if (isNotValidIndex(index))\r\n    {\r\n        return QVariant();\r\n    }\r\n    \r\n    if (index.column() == EnumerationColumns::ENUMERATION)\r\n    {\r\n        return getEnumerationColumnData(index.row(), role);\r\n    } \r\n    else if (index.column() == EnumerationColumns::TEXT)\r\n    {\r\n        return getTextColumnData(index.row(), role);\r\n    }\r\n    else if (index.column() == EnumerationColumns::HELP)\r\n    {\r\n        return getHelpColumnData(index.row(), role);\r\n    }\r\n    else\r\n    {\r\n        Q_ASSERT_X(false, \"data()\", \"Undefined column requested.\");\r\n        return QVariant();\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: EnumerationModel::headerData()\r\n//-----------------------------------------------------------------------------\r\nQVariant EnumerationModel::headerData(int section, Qt::Orientation orientation, int role) const\r\n{\r\n    if (orientation == Qt::Horizontal && role == Qt::DisplayRole)\r\n    {\r\n        if (section == EnumerationColumns::ENUMERATION)\r\n        {\r\n            return tr(\"Enumeration\");\r\n        }\r\n        else if (section == EnumerationColumns::TEXT)\r\n        {\r\n            return tr(\"Text\");\r\n        } \r\n        else if (section == EnumerationColumns::HELP)\r\n        {\r\n            return tr(\"Description\");\r\n        } \r\n    }\r\n\r\n    return QVariant();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: EnumerationModel::setData()\r\n//-----------------------------------------------------------------------------\r\nbool EnumerationModel::setData(QModelIndex const& index, QVariant const& value, int role)\r\n{\r\n    if (isNotValidIndex(index))\r\n    {\r\n        return false;\r\n    }\r\n\r\n    if (role == Qt::EditRole)\r\n    {\r\n        if (index.column() == EnumerationColumns::ENUMERATION)\r\n        {\r\n            enumerations_->at(index.row())->setValue(value.toString());\r\n        }\r\n        else if (index.column() == EnumerationColumns::TEXT)\r\n        {\r\n            enumerations_->at(index.row())->setText(value.toString());\r\n        }\r\n        else if (index.column() == EnumerationColumns::HELP)\r\n        {\r\n            enumerations_->at(index.row())->setHelp(value.toString());\r\n        }\r\n        else\r\n        {\r\n            Q_ASSERT_X(false, \"setData()\", \"Undefined column requested.\");\r\n            return false;\r\n        }\r\n    } \r\n\r\n    emit dataChanged(index, index);\r\n    return true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: EnumerationModel::flags()\r\n//-----------------------------------------------------------------------------\r\nQt::ItemFlags EnumerationModel::flags(QModelIndex const& index) const\r\n{\r\n    if (!index.isValid())\r\n    {\r\n        return Qt::NoItemFlags;\r\n    }\r\n\r\n    Qt::ItemFlags validFlags = QAbstractTableModel::flags(index);\r\n    validFlags |= Qt::ItemIsEditable;\r\n    return validFlags;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: EnumerationModel::onAddItem()\r\n//-----------------------------------------------------------------------------\r\nvoid EnumerationModel::onAddItem(QModelIndex const& index)\r\n{\r\n    if (enumerations_.isNull())\r\n    {\r\n        return;\r\n    }\r\n\r\n    int row = rowCount();\r\n\r\n    if (index.isValid())\r\n    {\r\n        row = index.row();\r\n    }\r\n\r\n    beginInsertRows(QModelIndex(), row, row);\r\n\r\n    QSharedPointer<Enumeration> enumeration(new Enumeration());\r\n    enumeration->setValue(QString::number(rowCount()));\r\n    enumerations_->insert(row, enumeration);\r\n    \r\n    endInsertRows();\r\n\r\n    emit contentChanged();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: EnumerationModel::onRemoveItem()\r\n//-----------------------------------------------------------------------------\r\nvoid EnumerationModel::onRemoveItem(QModelIndex const& index)\r\n{\r\n    if (isNotValidIndex(index))\r\n    {\r\n        return;\r\n    }\r\n\r\n    int row = index.row();\r\n    beginRemoveRows(QModelIndex(), row, row);\r\n\r\n    enumerations_->removeAt(row);\r\n\r\n    endRemoveRows();\r\n\r\n    emit contentChanged();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: EnumerationModel::isNotValidIndex()\r\n//-----------------------------------------------------------------------------\r\nbool EnumerationModel::isNotValidIndex(QModelIndex const& index) const\r\n{\r\n    return !index.isValid() ||  index.row() > enumerations_->size() || index.column() < 0 || index.column() >= EnumerationColumns::COLUMN_COUNT;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: EnumerationModel::getEnumerationColumnData()\r\n//-----------------------------------------------------------------------------\r\nQVariant EnumerationModel::getEnumerationColumnData(int row, int role) const\r\n{\r\n    QSharedPointer<Enumeration> enumeration = enumerations_->at(row);\r\n    if (role == Qt::DisplayRole || role == Qt::EditRole)\r\n    {\r\n        return enumeration->getValue();\r\n    }\r\n    else if (role == Qt::ForegroundRole)\r\n    {\r\n        return getForegroundColorForEnumeration(enumeration);\r\n    }\r\n    else if (role == Qt::BackgroundRole)\r\n    {\r\n        return KactusColors::MANDATORY_FIELD;\r\n    }\r\n    \r\n    return QVariant();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: EnumerationModel::getForegroundColorForEnumeration()\r\n//-----------------------------------------------------------------------------\r\nQVariant EnumerationModel::getForegroundColorForEnumeration(QSharedPointer<Enumeration> enumeration) const\r\n{\r\n    if (enumeration->getValue().isEmpty())\r\n    {\r\n        return KactusColors::ERROR;\r\n    }\r\n    else\r\n    {\r\n        return KactusColors::REGULAR_TEXT;\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: EnumerationModel::getTextColumnData()\r\n//-----------------------------------------------------------------------------\r\nQVariant EnumerationModel::getTextColumnData(int row, int role) const\r\n{\r\n    QSharedPointer<Enumeration> enumeration = enumerations_->at(row);\r\n    \r\n    if (role == Qt::DisplayRole || role == Qt::EditRole)\r\n    {\r\n        return enumeration->getText();\r\n    }\r\n    else if (role == Qt::ForegroundRole)\r\n    {\r\n        return getForegroundColorForEnumeration(enumeration);\r\n    }\r\n    \r\n    return QVariant();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: EnumerationModel::getHelpColumnData()\r\n//-----------------------------------------------------------------------------\r\nQVariant EnumerationModel::getHelpColumnData(int row, int role) const\r\n{\r\n    QSharedPointer<Enumeration> enumeration = enumerations_->at(row);\r\n    \r\n    if (role == Qt::DisplayRole || role == Qt::EditRole)\r\n    {\r\n        return enumeration->getHelp();\r\n    }\r\n    else if (role == Qt::ForegroundRole)\r\n    {\r\n        return getForegroundColorForEnumeration(enumeration);\r\n    }\r\n\r\n    return QVariant();\r\n}\r\n"
  },
  {
    "path": "editors/ComponentEditor/choices/EnumerationModel.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: EnumerationModel.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Esko Pekkarinen\r\n// Date: 04.11.2014\r\n//\r\n// Description:\r\n// Model for editing Enumeration within a Choice element.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef ENUMERATIONMODEL_H\r\n#define ENUMERATIONMODEL_H\r\n\r\n#include <QAbstractTableModel>\r\n\r\n#include <QSharedPointer>\r\n#include <QList>\r\n\r\nclass Enumeration;\r\n\r\n//-----------------------------------------------------------------------------\r\n// class EnumerationModel.\r\n//-----------------------------------------------------------------------------\r\nclass EnumerationModel : public QAbstractTableModel \r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n    \r\n    /*!\r\n     *  The constructor.\r\n     *\r\n     *    @param [in] parent         The parent object.\r\n     */\r\n    EnumerationModel(QObject* parent = 0);\r\n\r\n    /*!\r\n     *  The destructor.\r\n     */\r\n    ~EnumerationModel() = default;\r\n\r\n    /*!\r\n     *  Returns the amount of columns in the model.\r\n     *\r\n     *    @param [in] parent  If given, the row count of the children of the given parent is returned.\r\n     *\r\n     *    @return The amount of columns.\r\n     */\r\n    int columnCount(QModelIndex const& parent = QModelIndex()) const;\r\n\r\n    /*!\r\n     *  Returns the amount of columns in the model.\r\n     *\r\n     *    @param [in] parent  If given, the column count of the children of the given parent is returned.\r\n     *\r\n     *    @return The amount of columns.\r\n     */\r\n    int rowCount(QModelIndex const& parent = QModelIndex()) const;\r\n\r\n    /*!\r\n     *  Fetches the data for appropriate role at given index.\r\n     *\r\n     *    @param [in] index   The index of data to be returned.\r\n     *    @param [in] role    The role for which data is returned.\r\n     *\r\n     *    @return The requested data.\r\n     */\r\n    QVariant data(QModelIndex const& index, int role = Qt::DisplayRole) const;\r\n\r\n    /*!\r\n     *  Retrieves the header data for given column (used) or row (not used).\r\n     *\r\n     *    @param [in] section     The row or column from which the index is retrieved.\r\n     *    @param [in] orientation Whether the header is vertical or horizontal.\r\n     *    @param [in] role        The role for which the header is retrieved.\r\n     *\r\n     *    @return The header data.\r\n     */\r\n    QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;\r\n\r\n    /*!\r\n     *  Sets the data at given index.\r\n     *    \r\n     *    @param [in] index   The index at which the data is set.\r\n     *    @param [in] value   The new value being set.\r\n     *    @param [in] role    The role for which the data is set.\r\n     *\r\n     *    @return True, if data was set successfully, otherwise false.\r\n     */\r\n    bool setData(QModelIndex const& index, QVariant const& value, int role = Qt::EditRole);\r\n\r\n    /*!\r\n     *  Returns the flags for an object at given index.\r\n     *\r\n     *    @param [in] index   The index of the object queried.\r\n     *\r\n     *    @return The relevant flags.\r\n     */\r\n    Qt::ItemFlags flags(QModelIndex const& index) const;\r\n\r\nsignals:\r\n\r\n    /*!\r\n     *  Emitted when the model content has changed.\r\n     */\r\n    void contentChanged();\r\n\r\npublic slots:\r\n\r\n    /*!\r\n     *  Setup the available enumerations.\r\n     *\r\n     *    @param [in] newEnumerations     The new enumerations.\r\n     */\r\n    void setupEnumerations(QSharedPointer<QList<QSharedPointer<Enumeration> > > newEnumerations);\r\n\r\n    /*!\r\n     *  Clear the available enumerations.\r\n     */\r\n    void clearEnumerations();\r\n\r\n    /*!\r\n     *  Called when a new enumeration should be added to the model.\r\n     *\r\n     *    @param [in] index   The index to add the enumeration to.\r\n     */\r\n    void onAddItem(QModelIndex const& index);\r\n       \r\n    /*!\r\n     *  Called when an enumeration should be removed from the model.\r\n     *\r\n     *    @param [in] index   The index to remove the enumeration from.\r\n     */\r\n    void onRemoveItem(QModelIndex const& index);\r\n\r\nprivate:\r\n\t// Disable copying.\r\n\tEnumerationModel(EnumerationModel const& rhs);\r\n\r\n\t// Disable assignment.\r\n\tEnumerationModel& operator=(EnumerationModel const& rhs);\r\n\r\n    /*!\r\n     *  Checks if the given index is not valid and outside the model.\r\n     *\r\n     *    @param [in] index   The model index to check.\r\n     *\r\n     *    @return True, if the index is invalid, otherwise false.\r\n     */\r\n    bool isNotValidIndex(QModelIndex const& index) const;\r\n\r\n    /*!\r\n     *  Gets the data in the enumeration column.\r\n     *\r\n     *    @param [in] row     The row of data to be returned.\r\n     *    @param [in] role    The role for which data is returned.\r\n     *\r\n     *    @return The data in enumeration column for the given row and role.\r\n     */\r\n    QVariant getEnumerationColumnData(int row, int role) const;\r\n\r\n    /*!\r\n     *  Gets the foreground color for the given enumeration.\r\n     *\r\n     *    @param [in] enumeration   The enumeration for which the foreground color is fetched.\r\n     *\r\n     *    @return The foreground color for the enumeration cells.\r\n     */\r\n    QVariant getForegroundColorForEnumeration(QSharedPointer<Enumeration> enumeration) const;\r\n\r\n    /*!\r\n     *  Gets the data in the text column.\r\n     *\r\n     *    @param [in] row     The row of data to be returned.\r\n     *    @param [in] role    The role for which data is returned.\r\n     *\r\n     *    @return The data in text column for the given row and role.\r\n     */\r\n    QVariant getTextColumnData(int row, int role) const;\r\n    \r\n    /*!\r\n     *  Gets the data in the help column.\r\n     *\r\n     *    @param [in] row     The row of data to be returned.\r\n     *    @param [in] role    The role for which data is returned.\r\n     *\r\n     *    @return The data in help column for the given row and role.\r\n     */\r\n    QVariant getHelpColumnData(int row, int role) const;\r\n\r\n    //-----------------------------------------------------------------------------\r\n\t// Data.\r\n\t//-----------------------------------------------------------------------------\r\n    \r\n    //! The list of enumerations in the choice.\r\n    QSharedPointer<QList<QSharedPointer<Enumeration> > > enumerations_;\r\n};\r\n#endif // ENUMERATIONMODEL_H\r\n"
  },
  {
    "path": "editors/ComponentEditor/common/AbstractParameterModel.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: AbstractParameterModel.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Esko Pekkarinen\r\n// Date: 18.11.2014\r\n//\r\n// Description:\r\n// Base class for models editing parameters and model parameters.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"AbstractParameterModel.h\"\r\n\r\n#include <KactusAPI/include/AbstractParameterInterface.h>\r\n\r\n#include <common/KactusColors.h>\r\n\r\n#include <QFont>\r\n#include <QMessageBox>\r\n#include <QRegularExpression>\r\n#include <QApplication>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AbstractParameterModel::AbstractParameterModel()\r\n//-----------------------------------------------------------------------------\r\nAbstractParameterModel::AbstractParameterModel(AbstractParameterInterface* parameterInterface,\r\n    QSharedPointer<ExpressionParser> expressionParser, QSharedPointer<ParameterFinder> parameterFinder,\r\n    QObject *parent):\r\nReferencingTableModel(parameterFinder, parent),\r\nParameterizableTable(parameterFinder),\r\nparameterInterface_(parameterInterface)\r\n{\r\n    setExpressionParser(expressionParser);\r\n    parameterFinder->registerParameterModel(this);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AbstractParameterModel::rowCount()\r\n//-----------------------------------------------------------------------------\r\nint AbstractParameterModel::rowCount(QModelIndex const& parent) const\r\n{\r\n    // not hierarchical model\r\n    if (parent.isValid())\r\n    {\r\n        return 0;\r\n    }\r\n\r\n    return parameterInterface_->itemCount();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AbstractParameterModel::data()\r\n//-----------------------------------------------------------------------------\r\nQVariant AbstractParameterModel::data( QModelIndex const& index, int role /*= Qt::DisplayRole */ ) const \r\n{\r\n\tif (!index.isValid() || index.row() < 0 || index.row() >= rowCount())\r\n    {\r\n\t\treturn QVariant();\r\n    }\r\n    \r\n    if (role == Qt::DisplayRole)\r\n    {\r\n        if (index.column() == valueColumn() || \r\n            index.column() == bitWidthLeftColumn() || index.column() == bitWidthRightColumn() ||\r\n            index.column() == arrayLeftColumn() || index.column() == arrayRightColumn())\r\n        {\r\n            return formattedExpressionForIndex(index);\r\n        }\r\n        else if (index.column() == descriptionColumn())\r\n        {\r\n            return valueForIndex(index).toString().replace(QRegularExpression(\"\\n.*$\",\r\n                QRegularExpression::DotMatchesEverythingOption), QStringLiteral(\"...\"));\r\n        }\r\n        else\r\n        {\r\n            return valueForIndex(index);\r\n        }\r\n    }\r\n    else if (role == Qt::EditRole)\r\n    {\r\n        if (isValidExpressionColumn(index))\r\n        {\r\n            return expressionForIndex(index);\r\n        }\r\n        else\r\n        {\r\n            return valueForIndex(index);\r\n        }\r\n    }\r\n    else if (role == Qt::ToolTipRole)\r\n    {\r\n        return valueForIndex(index);\r\n    }\r\n    else if (role == Qt::BackgroundRole) \r\n    {\r\n        return backgroundColorForIndex(index);\r\n    }\r\n    else if (role == Qt::ForegroundRole)\r\n    {\r\n        return blackForValidOrRedForInvalidIndex(index);\r\n    }\r\n    else if (role == Qt::FontRole)\r\n    {\r\n        return italicForEvaluatedValue(index);\r\n    }\r\n    else // if unsupported role\r\n    {\r\n\t\treturn QVariant();\r\n\t}\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AbstractParameterModel::headerData()\r\n//-----------------------------------------------------------------------------\r\nQVariant AbstractParameterModel::headerData(int section, Qt::Orientation orientation, int role) const\r\n{\r\n    if (role == Qt::DisplayRole && orientation == Qt::Vertical)\r\n    {\r\n        return QString::fromStdString(parameterInterface_->getIndexedItemName(section));\r\n    }\r\n\r\n    if (role == Qt::DisplayRole && orientation == Qt::Horizontal) \r\n    {\r\n        if (section == nameColumn())\r\n        {\r\n            return tr(\"Name\");\r\n        }\r\n        else if (section == displayNameColumn())\r\n        {\r\n            return tr(\"Display\\nname\");\r\n        }\r\n        else if (section == typeColumn())\r\n        {\r\n            return tr(\"Type\");   \r\n        }\r\n        else if (section == bitWidthLeftColumn())\r\n        {\r\n            QString bitWidthLeft = tr(\"Bit vector\\nleft\") + getExpressionSymbol();\r\n            return bitWidthLeft;\r\n        }\r\n        else if (section == bitWidthRightColumn())\r\n        {\r\n            QString bitWidthRight = tr(\"Bit vector\\nright\") + getExpressionSymbol();\r\n            return bitWidthRight;\r\n        }\r\n        else if (section == minimumColumn())\r\n        {\r\n            return tr(\"Min\");\r\n        }\r\n        else if (section == maximumColumn())\r\n        {\r\n            return tr(\"Max\");\r\n        }\r\n        else if (section == choiceColumn())\r\n        {\r\n            return tr(\"Choice\");\r\n        }     \r\n        else if (section == valueColumn())\r\n        {\r\n            QString valueHeader = tr(\"Value\") + getExpressionSymbol();\r\n            return valueHeader;\r\n        }  \r\n        else if (section == resolveColumn())\r\n        {     \r\n            return tr(\"Resolve\");\r\n        }  \r\n        else if (section == arrayLeftColumn())\r\n        {\r\n            QString arrayLeftHeader = tr(\"Array\\nleft\") + getExpressionSymbol();\r\n            return arrayLeftHeader;\r\n        }  \r\n        else if (section == arrayRightColumn())\r\n        {\r\n            QString arrayRightHeader = tr(\"Array\\nright\") + getExpressionSymbol();\r\n            return arrayRightHeader;\r\n        } \r\n        else if (section == descriptionColumn())\r\n        { \r\n            return tr(\"Description\");\r\n        }\r\n        else if (section == idColumn())\r\n        {\r\n            return tr(\"Parameter id\");\r\n        }\r\n        else if (section == usageCountColumn())\r\n        {\r\n            return tr(\"Usage\\ncount\");\r\n        }\r\n\r\n        else\r\n        {\r\n            return QVariant();\r\n        }\r\n    }\r\n\r\n    // if unsupported role\r\n    else \r\n    {\r\n        return QVariant();\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AbstractParameterModel::setData()\r\n//-----------------------------------------------------------------------------\r\nbool AbstractParameterModel::setData(QModelIndex const& index, const QVariant& value, int role /*= Qt::EditRole */) \r\n{\r\n\tif (!index.isValid() || index.row() < 0 || index.row() >= rowCount())\r\n    {\r\n\t\treturn false;\r\n    }\r\n\r\n    if (role == Qt::EditRole)\r\n    {\r\n        std::string parameterName = parameterInterface_->getIndexedItemName(index.row());\r\n\r\n        if (index.column() == nameColumn())\r\n        {\r\n            parameterInterface_->setName(parameterName, value.toString().toStdString());\r\n            emit headerDataChanged(Qt::Vertical, index.row(), index.row());\r\n        }\r\n        else if (index.column() == displayNameColumn())\r\n        {\r\n            parameterInterface_->setDisplayName(parameterName, value.toString().toStdString());\r\n        }\r\n        else if (index.column() == typeColumn())\r\n        {\r\n            parameterInterface_->setType(parameterName, value.toString().toStdString());\r\n        }\r\n        else if (index.column() == bitWidthLeftColumn())\r\n        {\r\n            if (!value.isValid())\r\n            {\r\n                removeReferencesFromSingleExpression(\r\n                    QString::fromStdString(parameterInterface_->getBitWidthLeftExpression(parameterName)));\r\n\r\n                emit dataChanged(QAbstractTableModel::index(0, usageCountColumn()),\r\n                    QAbstractTableModel::index(rowCount() - 1, usageCountColumn()));\r\n            }\r\n\r\n            parameterInterface_->setBitWidthLeft(parameterName, value.toString().toStdString());\r\n\r\n            if (value.isValid() && parameterInterface_->getBitWidthRightExpression(parameterName).empty() &&\r\n                !value.toString().isEmpty())\r\n            {\r\n                parameterInterface_->setBitWidthRight(parameterName, \"0\");\r\n            }\r\n        }\r\n        else if (index.column() == bitWidthRightColumn())\r\n        {\r\n            if (!value.isValid())\r\n            {\r\n                removeReferencesFromSingleExpression(\r\n                    QString::fromStdString(parameterInterface_->getBitWidthRightExpression(parameterName)));\r\n\r\n                emit dataChanged(QAbstractTableModel::index(0, usageCountColumn()),\r\n                    QAbstractTableModel::index(rowCount() - 1, usageCountColumn()));\r\n            }\r\n\r\n            parameterInterface_->setBitWidthRight(parameterName, value.toString().toStdString());\r\n\r\n            if (value.isValid() && parameterInterface_->getBitWidthLeftExpression(parameterName).empty() &&\r\n                !value.toString().isEmpty())\r\n            {\r\n                parameterInterface_->setBitWidthLeft(parameterName, \"0\");\r\n            }\r\n        }\r\n        else if (index.column() == minimumColumn())\r\n        {\r\n            parameterInterface_->setMinimum(parameterName, value.toString().toStdString());\r\n        }\r\n        else if (index.column() == maximumColumn())\r\n        {\r\n            parameterInterface_->setMaximum(parameterName, value.toString().toStdString());\r\n        }\r\n        else if (index.column() == choiceColumn())\r\n        {\r\n            parameterInterface_->setChoice(parameterName, value.toString().toStdString());\r\n        }\r\n        else if (index.column() == valueColumn())\r\n        {\r\n            if (!value.isValid())\r\n            {\r\n                removeReferencesFromSingleExpression(\r\n                    QString::fromStdString(parameterInterface_->getValue(parameterName)));\r\n\r\n                emit dataChanged(QAbstractTableModel::index(0, usageCountColumn()),\r\n                    QAbstractTableModel::index(rowCount() - 1, usageCountColumn()));\r\n            }\r\n\r\n            parameterInterface_->setValue(parameterName, value.toString().toStdString());\r\n        }\r\n        else if (index.column() == resolveColumn())\r\n        {\r\n            parameterInterface_->setResolve(parameterName, value.toString().toStdString());\r\n        }\r\n        else if (index.column() == arrayLeftColumn())\r\n        {\r\n            if (!value.isValid())\r\n            {\r\n                removeReferencesFromSingleExpression(\r\n                    QString::fromStdString(parameterInterface_->getArrayLeftExpression(parameterName)));\r\n\r\n                emit dataChanged(QAbstractTableModel::index(0, usageCountColumn()),\r\n                    QAbstractTableModel::index(rowCount() - 1, usageCountColumn()));\r\n            }\r\n\r\n            parameterInterface_->setArrayLeft(parameterName, value.toString().toStdString());\r\n\r\n            if (value.isValid() && parameterInterface_->getArrayRightExpression(parameterName).empty() &&\r\n                !parameterInterface_->getArrayLeftExpression(parameterName).empty())\r\n            {\r\n                parameterInterface_->setArrayRight(parameterName, \"0\");\r\n            }\r\n        }\r\n        else if (index.column() == arrayRightColumn())\r\n        {\r\n            if (!value.isValid())\r\n            {\r\n                removeReferencesFromSingleExpression(\r\n                    QString::fromStdString(parameterInterface_->getArrayRightExpression(parameterName)));\r\n\r\n                emit dataChanged(QAbstractTableModel::index(0, usageCountColumn()),\r\n                    QAbstractTableModel::index(rowCount() - 1, usageCountColumn()));\r\n            }\r\n\r\n            parameterInterface_->setArrayRight(parameterName, value.toString().toStdString());\r\n\r\n            if (value.isValid() && parameterInterface_->getArrayLeftExpression(parameterName).empty() &&\r\n                !parameterInterface_->getArrayRightExpression(parameterName).empty())\r\n            {\r\n                parameterInterface_->setArrayLeft(parameterName, \"0\");\r\n            }\r\n        }\r\n        else if (index.column() == descriptionColumn())\r\n        {\r\n            parameterInterface_->setDescription(parameterName, value.toString().toStdString());\r\n        }\r\n        else\r\n        {\r\n            return false;\r\n        }\r\n\r\n        emit dataChanged(index, index);\r\n        emit contentChanged();\r\n        return true;\r\n    }\r\n    else // is unsupported role\r\n    {\r\n        return false;\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AbstractParameterModel::flags()\r\n//-----------------------------------------------------------------------------\r\nQt::ItemFlags AbstractParameterModel::flags(QModelIndex const& index ) const\r\n{\r\n\tif (!index.isValid())\r\n    {\r\n\t\treturn Qt::NoItemFlags;\r\n    }\r\n\r\n\treturn Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsEditable;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AbstractParameterModel::isMandatoryColumn()\r\n//-----------------------------------------------------------------------------\r\nbool AbstractParameterModel::isMandatoryColumn(int column) const\r\n{\r\n    return column == nameColumn() || column == valueColumn();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AbstractParameterModel::validateIndex()\r\n//-----------------------------------------------------------------------------\r\nbool AbstractParameterModel::validateIndex(QModelIndex const& index) const\r\n{\r\n    std::string parameterName = parameterInterface_->getIndexedItemName(index.row());\r\n\r\n    if (index.column() == nameColumn())\r\n    {\r\n        return parameterInterface_->itemHasValidName(parameterName);\r\n    }\r\n    else if (index.column() == typeColumn())\r\n    {\r\n        return parameterInterface_->hasValidType(parameterName);\r\n    }\r\n    else if (index.column() == bitWidthLeftColumn())\r\n    {\r\n        return parameterInterface_->hasValidBitWidth(parameterName);\r\n    }\r\n    else if (index.column() == bitWidthRightColumn())\r\n    {\r\n        return parameterInterface_->hasValidBitWidth(parameterName);\r\n    }\r\n    else if (index.column() == minimumColumn())\r\n    {\r\n        return parameterInterface_->hasValidMinimum(parameterName);\r\n    }\r\n    else if (index.column() == maximumColumn())\r\n    {\r\n        return parameterInterface_->hasValidMaximum(parameterName);\r\n    }\r\n    else if (index.column() == choiceColumn())\r\n    {\r\n        return parameterInterface_->hasValidChoice(parameterName);\r\n    }\r\n    else if (index.column() == valueColumn())\r\n    {\r\n        return parameterInterface_->hasValidValue(parameterName);\r\n    }\r\n    else if (index.column() == resolveColumn())\r\n    {\r\n        return parameterInterface_->hasValidResolve(parameterName);\r\n    }\r\n    else if (index.column() == arrayLeftColumn())\r\n    {\r\n        return parameterInterface_->hasValidArrayValues(parameterName);\r\n    }\r\n    else if (index.column() == arrayRightColumn())\r\n    {\r\n        return parameterInterface_->hasValidArrayValues(parameterName);\r\n    }\r\n\r\n    return true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AbstractParameterModel::isValidExpressionColumn()\r\n//-----------------------------------------------------------------------------\r\nbool AbstractParameterModel::isValidExpressionColumn(QModelIndex const& index) const\r\n{\r\n    std::string parameterName = parameterInterface_->getIndexedItemName(index.row());\r\n\r\n    if ((index.column() == valueColumn() && parameterInterface_->getType(parameterName) != \"string\") ||\r\n        index.column() == arrayLeftColumn() || index.column() == arrayRightColumn() ||\r\n        index.column() == bitWidthLeftColumn() || index.column() == bitWidthRightColumn())\r\n    {\r\n        return true;\r\n    }\r\n    else\r\n    {\r\n        return false;\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AbstractParameterModel::formattedExpressionForIndex()\r\n//-----------------------------------------------------------------------------\r\nQVariant AbstractParameterModel::formattedExpressionForIndex(QModelIndex const& index) const\r\n{\r\n    std::string parameterName = parameterInterface_->getIndexedItemName(index.row());\r\n\r\n    if (index.column() == bitWidthLeftColumn())\r\n    {\r\n        return QString::fromStdString(parameterInterface_->getBitWidthLeftFormattedExpression(parameterName));\r\n    }\r\n    else if (index.column() == bitWidthRightColumn())\r\n    {\r\n        return QString::fromStdString(parameterInterface_->getBitWidthRightFormattedExpression(parameterName));\r\n    }\r\n    else if (index.column() == valueColumn())\r\n    {\r\n        return QString::fromStdString(parameterInterface_->getValueFormattedExpression(parameterName));\r\n    }\r\n    else if (index.column() == arrayLeftColumn())\r\n    {\r\n        return QString::fromStdString(parameterInterface_->getArrayLeftFormattedExpression(parameterName));\r\n    }\r\n    else if (index.column() == arrayRightColumn())\r\n    {\r\n        return QString::fromStdString(parameterInterface_->getArrayRightFormattedExpression(parameterName));\r\n    }\r\n    \r\n    return QVariant();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AbstractParameterModel::expressionForIndex()\r\n//-----------------------------------------------------------------------------\r\nQVariant AbstractParameterModel::expressionForIndex(QModelIndex const& index) const\r\n{\r\n    std::string parameterName = parameterInterface_->getIndexedItemName(index.row());\r\n\r\n    if (index.column() == bitWidthLeftColumn())\r\n    {\r\n        return QString::fromStdString(parameterInterface_->getBitWidthLeftExpression(parameterName));\r\n    }\r\n    else if (index.column() == bitWidthRightColumn())\r\n    {\r\n        return QString::fromStdString(parameterInterface_->getBitWidthRightExpression(parameterName));\r\n    }\r\n    else if (index.column() == valueColumn())\r\n    {\r\n        return QString::fromStdString(parameterInterface_->getValueExpression(parameterName));\r\n    }\r\n    else if (index.column() == arrayLeftColumn())\r\n    {\r\n        return QString::fromStdString(parameterInterface_->getArrayLeftExpression(parameterName));\r\n    }\r\n    else if (index.column() == arrayRightColumn())\r\n    {\r\n        return QString::fromStdString(parameterInterface_->getArrayRightExpression(parameterName));\r\n    }\r\n    else\r\n    {\r\n        return QVariant();\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AbstractParameterModel::valueForIndex()\r\n//-----------------------------------------------------------------------------\r\nQVariant AbstractParameterModel::valueForIndex(QModelIndex const& index) const\r\n{\r\n    std::string parameterName = parameterInterface_->getIndexedItemName(index.row());\r\n\r\n    if (index.column() == nameColumn())\r\n    {\r\n        return QString::fromStdString(parameterName);\r\n    }\r\n    else if (index.column() == displayNameColumn())\r\n    {\r\n        return QString::fromStdString(parameterInterface_->getDisplayName(parameterName));\r\n    }\r\n    else if (index.column() == typeColumn())\r\n    {\r\n        return QString::fromStdString(parameterInterface_->getType(parameterName));\r\n    }\r\n    else if (index.column() == bitWidthLeftColumn())\r\n    {\r\n        return QString::fromStdString(parameterInterface_->getBitWidthLeftValue(parameterName));\r\n    }\r\n    else if (index.column() == bitWidthRightColumn())\r\n    {\r\n        return QString::fromStdString(parameterInterface_->getBitWidthRightValue(parameterName));\r\n    }\r\n    else if (index.column() == minimumColumn())\r\n    {\r\n        return QString::fromStdString(parameterInterface_->getMinimum(parameterName));\r\n    }\r\n    else if (index.column() == maximumColumn())\r\n    {\r\n        return QString::fromStdString(parameterInterface_->getMaximum(parameterName));\r\n    }\r\n    else if (index.column() == choiceColumn())\r\n    {\r\n        return QString::fromStdString(parameterInterface_->getChoice(parameterName));\r\n    }\r\n    else if (index.column() == valueColumn())\r\n    {\r\n        return QString::fromStdString(parameterInterface_->getValue(parameterName));\r\n    }\r\n    else if (index.column() == resolveColumn())\r\n    {\r\n        return QString::fromStdString(parameterInterface_->getResolve(parameterName));\r\n    }\r\n    else if (index.column() == arrayLeftColumn())\r\n    {\r\n        return QString::fromStdString(parameterInterface_->getArrayLeftValue(parameterName));\r\n    }\r\n    else if (index.column() == arrayRightColumn())\r\n    {\r\n        return QString::fromStdString(parameterInterface_->getArrayRightValue(parameterName));\r\n    }\r\n    else if (index.column() == descriptionColumn())\r\n    {\r\n        return QString::fromStdString(parameterInterface_->getDescription(parameterName));\r\n    }\r\n    else if (index.column() == idColumn())\r\n    {\r\n        return QString::fromStdString(parameterInterface_->getID(parameterName));\r\n    }\r\n    else if (index.column() == usageCountColumn())\r\n    {\r\n        return parameterInterface_->getUsageCount(parameterName);\r\n    }\r\n    else \r\n    {\r\n        return QVariant();\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AbstractParameterModel::expressionOrValueForIndex()\r\n//-----------------------------------------------------------------------------\r\nQVariant AbstractParameterModel::expressionOrValueForIndex(QModelIndex const& index) const\r\n{\r\n    if (isValidExpressionColumn(index))\r\n    {\r\n        return expressionForIndex(index);\r\n    }\r\n    else\r\n    {\r\n        return valueForIndex(index);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AbstractParameterModel::canRemoveRow()\r\n//-----------------------------------------------------------------------------\r\nbool AbstractParameterModel::canRemoveRow(int const& row) const\r\n{\r\n    std::string parameterName = parameterInterface_->getIndexedItemName(row);\r\n    int parameterUsageCount = parameterInterface_->getUsageCount(parameterName);\r\n\r\n    if (parameterUsageCount > 0)\r\n    {\r\n        QMessageBox removeWarning;\r\n        removeWarning.setText(\"Are you sure you want to remove \" + QString::fromStdString(parameterName) +\r\n            \"? There are \" + QString::number(parameterUsageCount) + \" references to it. \\n\\nTo see where \" +\r\n            QString::fromStdString(parameterName) + \" has been referenced, double click its usage count.\");\r\n        removeWarning.setStandardButtons(QMessageBox::Yes | QMessageBox::No);\r\n        removeWarning.setDefaultButton(QMessageBox::No);\r\n        removeWarning.setIcon(QMessageBox::Warning);\r\n\r\n        QApplication::setOverrideCursor(Qt::ArrowCursor);\r\n\r\n        if (removeWarning.exec() == QMessageBox::No)\r\n        {\r\n            QApplication::restoreOverrideCursor();\r\n            return false;\r\n        }\r\n\r\n        QApplication::restoreOverrideCursor();\r\n    }\r\n\r\n    removeReferencesInItemOnRow(row);\r\n\r\n    return true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AbstractParameterModel::backgroundColorForIndex()\r\n//-----------------------------------------------------------------------------\r\nQVariant AbstractParameterModel::backgroundColorForIndex(QModelIndex const& index) const\r\n{\r\n    std::string parameterName = parameterInterface_->getIndexedItemName(index.row());\r\n    std::string parameterType = parameterInterface_->getType(parameterName);\r\n\r\n    if (isMandatoryColumn(index.column())) \r\n    {\r\n        return KactusColors::MANDATORY_FIELD;\r\n    }\r\n    else if (((index.column() == minimumColumn() || index.column() == maximumColumn()) &&\r\n        (parameterType.empty() || parameterType == \"bit\" || parameterType == \"string\")) ||\r\n        ((index.column() == bitWidthLeftColumn() || index.column() == bitWidthRightColumn()) &&\r\n            parameterType != \"bit\"))\r\n    {\r\n        return KactusColors::DISABLED_FIELD;\r\n    }\r\n    else\r\n    {\r\n        return KactusColors::REGULAR_FIELD;\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AbstractParameterModel::getAllReferencesToIdInItemRow()\r\n//-----------------------------------------------------------------------------\r\nint AbstractParameterModel::getAllReferencesToIdInItemOnRow(const int& row, QString const& valueID) const\r\n{\r\n    return parameterInterface_->getAllReferencesToIdInItem(\r\n        parameterInterface_->getIndexedItemName(row), valueID.toStdString());\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AbstractParameterModel::onGetParametersMachingIndexes()\r\n//-----------------------------------------------------------------------------\r\nvoid AbstractParameterModel::onGetParametersMachingIndexes(QModelIndexList indexes)\r\n{\r\n    QVector<QString> parameterNames;\r\n    for (auto index : indexes)\r\n    {\r\n        std::string indexedName = parameterInterface_->getIndexedItemName(index.row());\r\n        parameterNames.append(QString::fromStdString(indexedName));\r\n    }\r\n\r\n    beginResetModel();\r\n\r\n    emit recalculateReferencesToParameters(parameterNames, parameterInterface_);\r\n\r\n    endResetModel();\r\n\r\n    emit contentChanged();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AbstractParameterModel::getInterface()\r\n//-----------------------------------------------------------------------------\r\nAbstractParameterInterface* AbstractParameterModel::getInterface() const\r\n{\r\n    return parameterInterface_;\r\n}\r\n"
  },
  {
    "path": "editors/ComponentEditor/common/AbstractParameterModel.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: AbstractParameterModel.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Esko Pekkarinen\r\n// Date: 18.11.2014\r\n//\r\n// Description:\r\n// Base class for models editing parameters and model parameters.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef ABSTRACTPARAMETERMODEL_H\r\n#define ABSTRACTPARAMETERMODEL_H\r\n\r\n#include \"ParameterizableTable.h\"\r\n#include \"ReferencingTableModel.h\"\r\n\r\n#include <QAbstractTableModel>\r\n#include <QSharedPointer>\r\n#include <QList>\r\n\r\nclass AbstractParameterInterface;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Base class for models editing parameters and model parameters.\r\n//-----------------------------------------------------------------------------\r\nclass AbstractParameterModel : public ReferencingTableModel, public ParameterizableTable\r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\r\n\t/*!\r\n\t *  The constructor.\r\n\t *\r\n     *    @param [in] parameterInterface  Interface for accessing parameters.\r\n     *    @param [in] expressionParser    Expression parser for configurable elements.\r\n\t *    @param [in] parameterFinder     Pointer to the instance for finding parameters.\r\n\t *    @param [in] parent              The parent object.\r\n\t */\r\n    AbstractParameterModel(AbstractParameterInterface* parameterInterface,\r\n        QSharedPointer<ExpressionParser> expressionParser,\r\n        QSharedPointer<ParameterFinder> parameterFinder, QObject *parent);\r\n\r\n    /*!\r\n     *  The destructor.\r\n     */\r\n\tvirtual ~AbstractParameterModel() = default;\r\n\r\n    /*!\r\n     *  Get the number of rows in the model.\r\n\t *\r\n\t *    @param [in]  parent Model index of the parent of the item.\r\n\t *\r\n\t *    @return  Number of rows currently in the model.\r\n\t */\r\n\tvirtual int rowCount(QModelIndex const& parent = QModelIndex()) const;\r\n\r\n\t/*!\r\n     *  Get the data for the specified item for specified role.\r\n\t *\r\n\t *    @param [in]  index  Identifies the item that's data is wanted.\r\n\t *    @param [in]  role   Specifies what kind of data is wanted.\r\n\t *\r\n\t *    @return  The data for the given index.\r\n     */\r\n\tvirtual QVariant data(QModelIndex const& index, int role = Qt::DisplayRole ) const;\r\n\r\n\t/*!\r\n     *  Get the data for the headers.\r\n\t *\r\n\t *    @param [in]  section        The column that's header is wanted.\r\n\t *    @param [in]  orientation    The orientation of the header data.\r\n\t *    @param [in]  role           Specified the type of data that is wanted.\r\n\t *\r\n\t *    @return  The header data for the given section.\r\n     */\r\n\tvirtual QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole ) const;\r\n\r\n\t/*!\r\n     *  Set the data for specified item.\r\n\t *\r\n\t *    @param [in]  index  Specifies the item that's data is modified\r\n\t *    @param [in]  value  The value to be set.\r\n\t *    @param [in]  role   The role that is trying to modify the data. Only Qt::EditRole is supported.\r\n\t *\r\n\t *    @return  True, if data was successfully set, otherwise false.\r\n     */\r\n\tvirtual bool setData(QModelIndex const& index, const QVariant& value, int role = Qt::EditRole );\r\n\r\n\t/*!\r\n     *  Get information on how specified item can be handled.\r\n\t *\r\n\t *    @param [in]  index Specifies the item that's flags are wanted.\r\n\t *\r\n\t *    @return  Qt::ItemFlags that define how object can be handled.\r\n     */\r\n\tvirtual Qt::ItemFlags flags(QModelIndex const& index) const;\r\n\r\npublic slots:\r\n\r\n\t/*!\r\n     *  A new item should be added to given index.\r\n\t *\r\n\t *    @param [in]  index The position where new item should be added at.\r\n     */\r\n\tvirtual void onAddItem(QModelIndex const& index) = 0;\r\n\r\n\t/*!\r\n     *  An item should be removed from the model.\r\n\t * \r\n\t *    @param [in]  index Identifies the item that should be removed.\r\n     */\r\n\tvirtual void onRemoveItem(QModelIndex const& index) = 0;\r\n\r\n    /*!\r\n     *  Handles calculation of references to the indexed parameters.\r\n     *\r\n     *    @param [in] indexes     The selected indexes.\r\n     */\r\n    virtual void onGetParametersMachingIndexes(QModelIndexList indexes);\r\n\r\nsignals:\r\n\r\n\t/*!\r\n     *  Emitted when contents of the model change.\r\n     */\r\n\tvoid contentChanged();\r\n\r\n\t/*!\r\n     *  Prints an error message to the user.\r\n     */\r\n\tvoid errorMessage(const QString& msg) const;\r\n\t\r\n\t/*!\r\n     *  Prints a notification to user.\r\n     */\r\n\tvoid noticeMessage(const QString& msg) const;\r\n\r\n    /*!\r\n     *  Recalculate references made to the selected parameters.\r\n     *\r\n     *    @param [in] parameterList       The selected parameters.\r\n     *    @param [in] parameterInterface  Interface for accessing parameters.\r\n     */\r\n    void recalculateReferencesToParameters(QVector<QString> const& parameterList,\r\n        AbstractParameterInterface* parameterInterface);\r\n\r\nprotected:\r\n                  \r\n    /*!\r\n     *  Get the interface for accessing parameters.\r\n     *\r\n     *    @return Interface for accessing parameters.\r\n     */\r\n    AbstractParameterInterface* getInterface() const;\r\n\r\n    /*!\r\n     *  Gets the column for name.\r\n     *\r\n     *    @return The column for editing name selection.\r\n     */\r\n    virtual int nameColumn() const = 0;\r\n        \r\n    /*!\r\n     *  Gets the column for display name.\r\n     *\r\n     *    @return The column for editing display name selection.\r\n     */\r\n    virtual int displayNameColumn() const = 0;\r\n\r\n    /*!\r\n     *  Gets the column for value type.\r\n     *\r\n     *    @return The column for editing type selection.\r\n     */\r\n    virtual int typeColumn() const = 0;\r\n        \r\n    /*!\r\n     *  Gets the column for the left value of bit width vector.\r\n     *\r\n     *    @return The column for editing the left value of the bit width vector.\r\n     */\r\n    virtual int bitWidthLeftColumn() const = 0;\r\n\r\n    /*!\r\n     *  Gets the column for the right value of bit width vector.\r\n     *\r\n     *    @return The column for editing the right value of the bit width vector.\r\n     */\r\n    virtual int bitWidthRightColumn() const = 0;\r\n\r\n    /*!\r\n     *  Gets the column for minimum value.\r\n     *\r\n     *    @return The column for editing the minimum value.\r\n     */\r\n    virtual int minimumColumn() const = 0;\r\n        \r\n    /*!\r\n     *  Gets the column for maximum value.\r\n     *\r\n     *    @return The column for editing the maximum value.\r\n     */\r\n    virtual int maximumColumn() const = 0;\r\n        \r\n    /*!\r\n     *  Gets the column for choices.\r\n     *\r\n     *    @return The column for editing choice selection.\r\n     */\r\n    virtual int choiceColumn() const = 0;\r\n\r\n    /*!\r\n     *  Gets the column for values.\r\n     *\r\n     *    @return The column for editing value selection.\r\n     */\r\n    virtual int valueColumn() const = 0;\r\n    \r\n    /*!\r\n     *  Gets the column for resolve.\r\n     *\r\n     *    @return The column for editing value selection.\r\n     */\r\n    virtual int resolveColumn() const = 0;\r\n    \r\n    /*!\r\n     *  Gets the column for array left.\r\n     *\r\n     *    @return The column for editing array left side.\r\n     */\r\n    virtual int arrayLeftColumn() const = 0;  \r\n\r\n    /*!\r\n     *  Gets the column for array right.\r\n     *\r\n     *    @return The column for editing array right side.\r\n     */\r\n    virtual int arrayRightColumn() const = 0;\r\n\r\n    /*!\r\n     *  Gets the column for description.\r\n     *\r\n     *    @return The column for editing description.\r\n     */\r\n    virtual int descriptionColumn() const = 0;\r\n\r\n    /*!\r\n     *  Gets the column index for parameter id.\r\n     *\r\n     *    @return     The column index for parameter id.\r\n     */\r\n    virtual int idColumn() const = 0;\r\n\r\n    /*!\r\n     *  Gets the column index for usage count.\r\n     *\r\n     *    @return     The column index for usage count.\r\n     */\r\n    virtual int usageCountColumn() const = 0;\r\n\r\n    /*!\r\n     *  Checks if the given column is mandatory.\r\n     *\r\n     *    @param [in] column   The column to check.\r\n     *\r\n     *    @return True, if the column is mandatory, otherwise false.\r\n     */\r\n    virtual bool isMandatoryColumn(int column) const;\r\n\r\n    /*!\r\n     *  Validates the data in a parameter corresponding to a given column.\r\n     *\r\n     *    @param [in] column      The column whose data to validate.\r\n     *    @param [in] parameter   The parameter whose data to validate.\r\n     *\r\n     *    @return True, if the data in the parameter is valid, otherwise false.\r\n     */\r\n    virtual bool validateIndex(QModelIndex const& index) const;\r\n\r\n    /*!\r\n     *  Check if the column index is valid for containing expressions.\r\n     *\r\n     *    @param [in] index   The index being evaluated.\r\n     *\r\n     *    @return     True, if column can have expressions, false otherwise.\r\n     */\r\n    virtual bool isValidExpressionColumn(QModelIndex const& index) const;\r\n\r\n    /*!\r\n     *  Gets the expression for the given index or the plain value if expression is not available.\r\n     *\r\n     *    @param [in] index   The index whose expression to get.\r\n     *\r\n     *    @return The expression for the index if available, otherwise the value for the given index.\r\n     */\r\n    virtual QVariant expressionOrValueForIndex(QModelIndex const& index) const;\r\n\r\n    /*!\r\n     *  Gets all the references to id from the register on the selected row.\r\n     *\r\n     *    @param [in] row         The row of the selected register.\r\n     *    @param [in] valueID     The id of the target parameter.\r\n     *\r\n     *    @return The amount of references made to the selected parameter.\r\n     */\r\n    virtual int getAllReferencesToIdInItemOnRow(const int& row, QString const& valueID) const;\r\n\r\n    /*!\r\n     *  Check if a parameter at row can be removed.\r\n     *\r\n     *    @param [in] row     The row of the parameter.\r\n     *\r\n     *    @return True if the parameter can be removed, false otherwise.\r\n     */\r\n    bool canRemoveRow(int const& row) const;\r\n\r\nprivate:\r\n\r\n\t//! No copying.\r\n\tAbstractParameterModel(const AbstractParameterModel& other);\r\n\r\n\t//! No assignment.\r\n\tAbstractParameterModel& operator=(const AbstractParameterModel& other);\r\n    \r\n    /*!\r\n     *  Get the formatted value of an expression in the selected index.\r\n     *\r\n     *    @param [in] index   The selected index.\r\n     *\r\n     *    @return The formatted value of an expression in the selected index.\r\n     */\r\n    virtual QVariant formattedExpressionForIndex(QModelIndex const& index) const;\r\n\r\n    /*!\r\n     *  Get the expression of the selected index.\r\n     *\r\n     *    @param [in] index   The selected index.\r\n     *\r\n     *    @return The expression of the selected index.\r\n     */\r\n    virtual QVariant expressionForIndex(QModelIndex const& index) const;\r\n\r\n    /*!\r\n     *  Gets the value for the given index.\r\n     *\r\n     *    @param [in] index   The index whose data to get.\r\n     *\r\n     *    @return The data in the given index.\r\n     */\r\n    QVariant valueForIndex(QModelIndex const& index) const;\r\n\r\n    /*!\r\n     *  Gets the background color for the given index.\r\n     *\r\n     *    @param [in] index   The index whose background color to get.\r\n     *\r\n     *    @return The color for the background.\r\n     */\r\n    QVariant backgroundColorForIndex(QModelIndex const& index) const;\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! Interface for accessing parameters.\r\n    AbstractParameterInterface* parameterInterface_;\r\n};\r\n\r\n#endif // ABSTRACTPARAMETERMODEL_H\r\n"
  },
  {
    "path": "editors/ComponentEditor/common/ConfigurableElementFinder.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: ConfigurableElementFinder.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 30.08.2017\n//\n// Description:\n// The implementation for finding configurable elements from a list with the correct ID.\n//-----------------------------------------------------------------------------\n\n#include \"ConfigurableElementFinder.h\"\n\n#include <editors/common/ComponentInstanceEditor/EditorConfigurableElement.h>\n\n//-----------------------------------------------------------------------------\n// Function: ConfigurableElementFinder::ConfigurableElementFinder()\n//-----------------------------------------------------------------------------\nConfigurableElementFinder::ConfigurableElementFinder():\nParameterFinder()\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: ConfigurableElementFinder::getParameterWithID()\n//-----------------------------------------------------------------------------\nQSharedPointer<Parameter> ConfigurableElementFinder::getParameterWithID(QStringView parameterId) const\n{\n    return  getElementForID(parameterId)->getReferencedParameter();\n}\n\n//-----------------------------------------------------------------------------\n// Function: ConfigurableElementFinder::hasId()\n//-----------------------------------------------------------------------------\nbool ConfigurableElementFinder::hasId(QStringView id) const\n{\n    for (QSharedPointer<EditorConfigurableElement> element : elementList_)\n    {\n        QSharedPointer<Parameter> referencedParameter = element->getReferencedParameter();\n        if (referencedParameter && referencedParameter->getValueId() == id)\n        {\n            return true;\n        }\n    }\n\n    return false;\n}\n\n//-----------------------------------------------------------------------------\n// Function: ConfigurableElementFinder::getElementForID()\n//-----------------------------------------------------------------------------\nQSharedPointer<EditorConfigurableElement> ConfigurableElementFinder::getElementForID(QStringView id) const\n{\n    for (QSharedPointer<EditorConfigurableElement> element : elementList_)\n    {\n        QSharedPointer<Parameter> referencedParameter = element->getReferencedParameter();\n        if (referencedParameter && referencedParameter->getValueId() == id)\n        {\n            return element;\n        }\n    }\n\n    return QSharedPointer<EditorConfigurableElement> ();\n}\n\n//-----------------------------------------------------------------------------\n// Function: ConfigurableElementFinder::nameForId()\n//-----------------------------------------------------------------------------\nQString ConfigurableElementFinder::nameForId(QStringView id) const\n{\n    if (QSharedPointer<EditorConfigurableElement> element = getElementForID(id); \n        element && element->getReferencedParameter())\n    {\n        return element->getReferencedParameter()->name();\n    }\n\n    return QString();\n}\n\n//-----------------------------------------------------------------------------\n// Function: ConfigurableElementFinder::valueForId()\n//-----------------------------------------------------------------------------\nQString ConfigurableElementFinder::valueForId(QStringView id) const\n{\n    if (QSharedPointer<EditorConfigurableElement> element = getElementForID(id); \n        element && element->getReferencedParameter())\n    {\n        return element->getConfiguratedValue();\n    }\n\n    return QString();\n}\n\n//-----------------------------------------------------------------------------\n// Function: ConfigurableElementFinder::getAllParameterIds()\n//-----------------------------------------------------------------------------\nQStringList ConfigurableElementFinder::getAllParameterIds() const\n{\n    QStringList allElementIDs;\n\n    for (QSharedPointer<EditorConfigurableElement> element : elementList_)\n    {\n        if (element->getReferencedParameter())\n        {\n            allElementIDs.append(element->getReferencedParameter()->getValueId());\n        }\n    }\n\n    allElementIDs.removeAll(QString());\n    return allElementIDs;\n}\n\n//-----------------------------------------------------------------------------\n// Function: ConfigurableElementFinder::getNumberOfParameters()\n//-----------------------------------------------------------------------------\nint ConfigurableElementFinder::getNumberOfParameters() const\n{\n    return elementList_.size();\n}\n\n//-----------------------------------------------------------------------------\n// Function: ConfigurableElementFinder::setParameterList()\n//-----------------------------------------------------------------------------\nvoid ConfigurableElementFinder::setConfigurableElementList(\n    QList<QSharedPointer<EditorConfigurableElement> > newElementList)\n{\n    elementList_ = newElementList;\n}\n\n//-----------------------------------------------------------------------------\n// Function: ConfigurableElementFinder::registerParameterModel()\n//-----------------------------------------------------------------------------\nvoid ConfigurableElementFinder::registerParameterModel(QAbstractItemModel const* /*model*/)\n{\n    // Nothing to do.\n}\n"
  },
  {
    "path": "editors/ComponentEditor/common/ConfigurableElementFinder.h",
    "content": "//-----------------------------------------------------------------------------\n// File: ConfigurableElementFinder.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 30.08.2017\n//\n// Description:\n// The implementation for finding configurable elements from a list with the correct ID.\n//-----------------------------------------------------------------------------\n\n#ifndef CONFIGURABLEELEMENTFINDER_H\n#define CONFIGURABLEELEMENTFINDER_H\n\n#include \"ParameterFinder.h\"\n\n#include <IPXACTmodels/common/Parameter.h>\n\n#include <QSharedPointer>\n#include <QList>\n\nclass EditorConfigurableElement;\n\n//-----------------------------------------------------------------------------\n//! The implementation for finding configurable elements from a list with the correct ID.\n//-----------------------------------------------------------------------------\nclass ConfigurableElementFinder : public ParameterFinder\n{\n\npublic:\n\n    /*!\n     *  The constructor.\n     */\n    ConfigurableElementFinder();\n\n    /*!\n     *  The Destructor.\n     */\n    ~ConfigurableElementFinder() override = default;\n\n    //! No copying. No assignment.\n    ConfigurableElementFinder(const ConfigurableElementFinder& other) = delete;\n    ConfigurableElementFinder& operator=(const ConfigurableElementFinder& other) = delete;\n\n    /*!\n     *  Get the parameter with the given id.\n     *\n     *    @param [in] parameterId     The id of the parameter being searched for.\n     *\n     *    @return The parameter with the selected ID.\n     */\n    QSharedPointer<Parameter> getParameterWithID(QStringView parameterId) const final;\n\n    /*!\n     *  Checks if a parameter with the given id exists.\n     *\n     *    @param [in] id      The id to search for.\n     *\n     *    @return True, if the parameter with the given id exists, otherwise false.\n     */\n    bool hasId(QStringView id) const final;\n\n    /*!\n     *  Finds the name of the parameter with the given id.\n     *\n     *    @param [in] id      The id to search for.\n     *\n     *    @return The name of the parameter.\n     */\n    QString nameForId(QStringView id) const final;\n\n    /*!\n     *  Finds the value of the parameter with the given id.\n     *\n     *    @param [in] id      The id of the parameter to search for.\n     *\n     *    @return The value of the parameter.\n     */\n    QString valueForId(QStringView id) const final;\n\n    /*!\n     *  Gets all of the ids of parameters in the list.\n     *\n     *    @return A list containing all of the ids.\n     */\n    QStringList getAllParameterIds() const final;\n\n    /*!\n     *  Gets the number of parameters in the list.\n     *\n     *    @return The number of parameters in the list.\n     */\n    int getNumberOfParameters() const final;\n\n    /*!\n     *  Set the configurable element list.\n     *\n     *    @param [in] newElementList  List containing the configurable elements.\n     */\n    void setConfigurableElementList(QList<QSharedPointer<EditorConfigurableElement> > newElementList);\n\n    /*!\n     *  Registers a parameter model that can modify parameters for the finder.\n     *\n     *    @param [in] model   The model to register.\n     */\n    void registerParameterModel(QAbstractItemModel const* model) final;\n\nprivate:\n\n    /*!\n     *  Get the configurable element referenced the selected parameter ID.\n     *\n     *    @param [in] id  ID of the selected parameter reference.\n     *\n     *    @return Configurable element containing the selected parameter reference.\n     */\n    QSharedPointer<EditorConfigurableElement> getElementForID(QStringView id) const;\n\n    //-----------------------------------------------------------------------------\n    // Data.\n    //-----------------------------------------------------------------------------\n\n    //! The configurable elements are searched from this list.\n    QList<QSharedPointer<EditorConfigurableElement> > elementList_;\n};\n\n#endif // LISTPARAMETERFINDER_H\n"
  },
  {
    "path": "editors/ComponentEditor/common/DesignConfigurationInstantiationParameterFinder.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: DesignConfigurationInstantiationParameterFinder.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Janne Virtanen\n// Date: 05.05.2017\n//\n// Description:\n// For finding parameters with the correct ID.\n//-----------------------------------------------------------------------------\n\n#include \"DesignConfigurationInstantiationParameterFinder.h\"\n\n#include <IPXACTmodels/Component/DesignConfigurationInstantiation.h>\n#include <IPXACTmodels/common/Parameter.h>\n\n//-----------------------------------------------------------------------------\n// Function: DesignConfigurationInstantiationParameterFinder::DesignConfigurationInstantiationParameterFinder()\n//-----------------------------------------------------------------------------\nDesignConfigurationInstantiationParameterFinder::DesignConfigurationInstantiationParameterFinder\n    (QSharedPointer<DesignConfigurationInstantiation const> designConfigurationInstantiation)\n    : designConfigurationInstantiation_(designConfigurationInstantiation)\n{\n}\n\n//-----------------------------------------------------------------------------\n// Function: DesignConfigurationInstantiationParameterFinder::DesignConfigurationInstantiationParameterFinder()\n//-----------------------------------------------------------------------------\nQSharedPointer<Parameter> DesignConfigurationInstantiationParameterFinder::getParameterWithID(\n    QStringView parameterId) const\n{\n    return searchParameter(parameterId);\n}\n\n//-----------------------------------------------------------------------------\n// Function: DesignConfigurationInstantiationParameterFinder::hasId()\n//-----------------------------------------------------------------------------\nbool DesignConfigurationInstantiationParameterFinder::hasId(QStringView id) const\n{\n    return searchParameter(id) != nullptr;\n}\n\n//-----------------------------------------------------------------------------\n// Function: DesignConfigurationInstantiationParameterFinder::nameForId()\n//-----------------------------------------------------------------------------\nQString DesignConfigurationInstantiationParameterFinder::nameForId(QStringView id) const\n{\n    if (QSharedPointer <Parameter> targetParameter = getParameterWithID(id);\n        targetParameter)\n    {\n        return targetParameter->name();\n    }\n\n    return QString();\n}\n\n//-----------------------------------------------------------------------------\n// Function: DesignConfigurationInstantiationParameterFinder::valueForId()\n//-----------------------------------------------------------------------------\nQString DesignConfigurationInstantiationParameterFinder::valueForId(QStringView id) const\n{\n    if (QSharedPointer<Parameter> targetParameter = getParameterWithID(id); \n        targetParameter)\n    {\n        return targetParameter->getValue();\n    }\n\n    return QString();\n}\n\n//-----------------------------------------------------------------------------\n// Function: DesignConfigurationInstantiationParameterFinder::getAllParameterIds()\n//-----------------------------------------------------------------------------\nQStringList DesignConfigurationInstantiationParameterFinder::getAllParameterIds() const\n{\n    QStringList allParameterIds;\n\n    if (designConfigurationInstantiation_)\n    {\n        for (QSharedPointer<Parameter> parameter : *designConfigurationInstantiation_->getParameters())\n        {\n            allParameterIds.append(parameter->getValueId());\n        }\n    }\n\n    allParameterIds.removeAll(QString());\n    return allParameterIds;\n}\n\n//-----------------------------------------------------------------------------\n// Function: DesignConfigurationInstantiationParameterFinder::getNumberOfParameters()\n//-----------------------------------------------------------------------------\nint DesignConfigurationInstantiationParameterFinder::getNumberOfParameters() const\n{\n    int parameterCount = 0;\n    if (designConfigurationInstantiation_)\n    {\n        parameterCount += designConfigurationInstantiation_->getParameters()->count();\n    }\n    return parameterCount;\n}\n\n//-----------------------------------------------------------------------------\n// Function: DesignConfigurationInstantiationParameterFinder::setDesignConfigurationInstantiation()\n//-----------------------------------------------------------------------------\nvoid DesignConfigurationInstantiationParameterFinder::setDesignConfigurationInstantiation\n    (QSharedPointer<DesignConfigurationInstantiation const> designConfigurationInstantiation)\n{\n    designConfigurationInstantiation_ = designConfigurationInstantiation;\n}\n\n//-----------------------------------------------------------------------------\n// Function: DesignConfigurationInstantiationParameterFinder::registerParameterModel()\n//-----------------------------------------------------------------------------\nvoid DesignConfigurationInstantiationParameterFinder::registerParameterModel(QAbstractItemModel const* /*model*/)\n{\n    // Nothing to do.\n}\n\n//-----------------------------------------------------------------------------\n// Function: DesignConfigurationInstantiationParameterFinder::searchParameter()\n//-----------------------------------------------------------------------------\nQSharedPointer<Parameter> DesignConfigurationInstantiationParameterFinder::searchParameter(\n    QStringView parameterId) const\n{\n    if (designConfigurationInstantiation_)\n    {\n        for (QSharedPointer<Parameter> parameter : *designConfigurationInstantiation_->getParameters())\n        {\n            if (parameter->getValueId().compare(parameterId) == 0)\n            {\n                return parameter;\n            }\n        }\n    }    \n\n    return QSharedPointer<Parameter>();\n}"
  },
  {
    "path": "editors/ComponentEditor/common/DesignConfigurationInstantiationParameterFinder.h",
    "content": "//-----------------------------------------------------------------------------\n// File: DesignConfigurationInstantiationParameterFinder.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Janne Virtanen\n// Date: 05.05.2017\n//\n// Description:\n// For finding parameters with the correct ID.\n//-----------------------------------------------------------------------------\n\n#ifndef DESIGNCONFIGURATIONINSTANTIATIONPARAMETERFINDER_H\n#define DESIGNCONFIGURATIONINSTANTIATIONPARAMETERFINDER_H\n\n#include \"ParameterFinder.h\"\n\nclass AbstractParameterModel;\nclass DesignConfigurationInstantiation;\n\n//-----------------------------------------------------------------------------\n//! The implementation for finding parameters with the correct ID.\n//-----------------------------------------------------------------------------\nclass DesignConfigurationInstantiationParameterFinder : public ParameterFinder\n{\n\npublic:\n\n    /*!\n     *  Constructor.\n     *\n\t *    @param [in] designConfigurationInstantiation\t\tThe element which parameters are being searched for.\n     */\n    explicit DesignConfigurationInstantiationParameterFinder\n        (QSharedPointer<DesignConfigurationInstantiation const> designConfigurationInstantiation);\n\n    /*!\n     *  Destructor.\n     */\n    ~DesignConfigurationInstantiationParameterFinder() final = default;\n\n    //! No copying\n    DesignConfigurationInstantiationParameterFinder(const DesignConfigurationInstantiationParameterFinder& other)\n        = delete;\n    //! No assignment\n    DesignConfigurationInstantiationParameterFinder& operator=(\n        const DesignConfigurationInstantiationParameterFinder& other) = delete;\n\n    /*!\n     *  Get the parameter with the given id.\n     *\n     *    @param [in] parameterId     The id of the parameter being searched for.\n     */\n    QSharedPointer<Parameter> getParameterWithID(QStringView parameterId) const final;\n\n    /*!\n     *  Checks if a parameter with the given id exists.\n     *\n     *    @param [in] id      The id to search for.\n     *\n     *    @return True, if the parameter with the given id exists, otherwise false.\n     */\n    bool hasId(QStringView id) const final;\n\n    /*!\n     *  Finds the name of the parameter with the given id.\n     *\n     *    @param [in] id      The id to search for.\n     *\n     *    @return The name of the parameter.\n     */\n    QString nameForId(QStringView id) const final;\n\n    /*!\n     *  Finds the value of the parameter with the given id.\n     *\n     *    @param [in] id      The id of the parameter to search for.\n     *\n     *    @return The value of the parameter.\n     */\n    QString valueForId(QStringView id) const final;\n\n    /*!\n     *  Gets all of the ids of design configuration instantiation parameters.\n     *\n     *    @return A list containing all of the ids.\n     */\n    QStringList getAllParameterIds() const final;\n\n    /*!\n     *  Gets the number of design configuration instantiation in the component.\n     *\n     *    @return The number of design configuration instantiation in the component.\n     */\n    int getNumberOfParameters() const final;\n\n    /*!\n     *  Sets a new component for the parameter finder.\n     */\n    virtual void setDesignConfigurationInstantiation\n        (QSharedPointer<DesignConfigurationInstantiation const> DesignConfigurationInstantiation);\n    \n    /*!\n     *  Registers a parameter model that can modify parameters for the finder.\n     *\n     *    @param [in] model   The model to register.\n     */\n    void registerParameterModel(QAbstractItemModel const* model) final;\n\nprivate:\n\n\t/*!\n\t *  Returns a parameter corresponding given id, if any exists.\n\t*/\n\tQSharedPointer<Parameter> searchParameter(QStringView parameterId) const;\n\n    //-----------------------------------------------------------------------------\n    // Data.\n    //-----------------------------------------------------------------------------\n\n    //! The parameters are searched from this component instantiation.\n    QSharedPointer<DesignConfigurationInstantiation const> designConfigurationInstantiation_;\n};\n\n#endif // DESIGNCONFIGURATIONINSTANTIATIONPARAMETERFINDER_H\n"
  },
  {
    "path": "editors/ComponentEditor/common/EnumerationEditorConstructorDelegate.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: EnumerationEditorConstructorDelegate.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 18.01.2023\n//\n// Description:\n// The delegate that provides enumeration editors.\n//-----------------------------------------------------------------------------\n\n#include \"EnumerationEditorConstructorDelegate.h\"\n\n#include <common/widgets/EnumCollectionEditor/EnumerationEditor.h>\n\n//-----------------------------------------------------------------------------\n// Function: EnumerationEditorConstructorDelegate::EnumerationEditorConstructorDelegate()\n//-----------------------------------------------------------------------------\nEnumerationEditorConstructorDelegate::EnumerationEditorConstructorDelegate(QObject* parent):\nQStyledItemDelegate(parent),\nhideCheckAll_(false)\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: EnumerationEditorConstructorDelegate::setHideCheckAll()\n//-----------------------------------------------------------------------------\nvoid EnumerationEditorConstructorDelegate::setHideCheckAll(bool newValue)\n{\n    hideCheckAll_ = newValue;\n}\n\n//-----------------------------------------------------------------------------\n// Function: EnumerationEditorConstructorDelegate::createEditor()\n//-----------------------------------------------------------------------------\nQWidget* EnumerationEditorConstructorDelegate::createEditor(QWidget* parent, QStyleOptionViewItem const& option, QModelIndex const& index) const\n{\n    if (isEnumerationEditorColumn(index))\n    {\n        EnumerationEditor* enumerationEditor = new EnumerationEditor(hideCheckAll_, parent);\n\n        connect(enumerationEditor, SIGNAL(cancelEditing()), this, SLOT(onEditorCancel()), Qt::UniqueConnection);\n        connect(enumerationEditor, SIGNAL(finishEditing()), this, SLOT(commitAndCloseEditor()), Qt::UniqueConnection);\n\n        return enumerationEditor;\n    }\n    else\n    {\n        return QStyledItemDelegate::createEditor(parent, option, index);\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: EnumerationEditorConstructorDelegate::setEditorData()\n//-----------------------------------------------------------------------------\nvoid EnumerationEditorConstructorDelegate::setEditorData(QWidget* editor, QModelIndex const& index) const\n{\n    if (index.isValid() && isEnumerationEditorColumn(index))\n    {\n        EnumerationEditor* enumerationEditor = dynamic_cast<EnumerationEditor*>(editor);\n        if (enumerationEditor)\n        {\n            QStringList sortedAvailableItems = getAvailableItems();\n            sortedAvailableItems.sort(Qt::CaseInsensitive);\n\n            QStringList exclusiveItems = getExclusiveItems();\n\n            enumerationEditor->setupItems(sortedAvailableItems, exclusiveItems, getCurrentSelection(index));\n        }\n    }\n\n    else\n    {\n        QStyledItemDelegate::setEditorData(editor, index);\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: EnumerationEditorConstructorDelegate::getExclusionItems()\n//-----------------------------------------------------------------------------\nQStringList EnumerationEditorConstructorDelegate::getExclusiveItems() const\n{\n    return QStringList();\n}\n\n//-----------------------------------------------------------------------------\n// Function: EnumerationEditorConstructorDelegate::setModelData()\n//-----------------------------------------------------------------------------\nvoid EnumerationEditorConstructorDelegate::setModelData(QWidget* editor, QAbstractItemModel* model, QModelIndex const& index) const\n{\n    if (isEnumerationEditorColumn(index)) \n    {\n        EnumerationEditor* enumerationEditor = dynamic_cast<EnumerationEditor*>(editor);\n        if (enumerationEditor)\n        {\n            QStringList selectedItems = enumerationEditor->getSelectedItems();\n            setEnumerationDataToModel(index, model, selectedItems);\n        }\n    }\n    else\n    {\n        QStyledItemDelegate::setModelData(editor, model, index);\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: EnumerationEditorConstructorDelegate::commitAndCloseEditor()\n//-----------------------------------------------------------------------------\nvoid EnumerationEditorConstructorDelegate::commitAndCloseEditor()\n{\n\tQWidget* edit = qobject_cast<QWidget*>(sender());\n\tQ_ASSERT(edit);\n\n\temit commitData(edit);\n\temit closeEditor(edit);\n}\n\n//-----------------------------------------------------------------------------\n// Function: EnumerationEditorConstructorDelegate::onEditorCancel()\n//-----------------------------------------------------------------------------\nvoid EnumerationEditorConstructorDelegate::onEditorCancel()\n{\n    QWidget* edit = qobject_cast<QWidget*>(sender());\n    if (edit)\n    {\n        emit closeEditor(edit);\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: EnumerationEditorConstructorDelegate::updateEditorGeometry()\n//-----------------------------------------------------------------------------\nvoid EnumerationEditorConstructorDelegate::updateEditorGeometry(QWidget* editor, const QStyleOptionViewItem& option,\n    const QModelIndex& index) const\n{\n    QStyledItemDelegate::updateEditorGeometry(editor, option, index);\n\n    if (isEnumerationEditorColumn(index))\n    {\n        repositionAndResizeEditor(editor, option, index);\n    }\n}\n\n\n//-----------------------------------------------------------------------------\n// Function: EnumerationEditorConstructorDelegate::repositionAndResizeEditor()\n//-----------------------------------------------------------------------------\nvoid EnumerationEditorConstructorDelegate::repositionAndResizeEditor(QWidget* editor,\n    QStyleOptionViewItem const& option, QModelIndex const& /*index*/) const\n{\n    int enumerationCount = getAvailableItems().count();\n    int editorMinimumSize = qMax(25 * (enumerationCount + 2), 80);\n\n    int editorWidth =  option.rect.right() - option.rect.left();\n    if (editorWidth < 150)\n    {\n        editorWidth = 150;\n    }\n    else if (editorWidth > 350)\n    {\n        editorWidth = 350;\n    }\n\n    editor->setFixedWidth(editorWidth);\n\n    const int PARENT_HEIGHT = editor->parentWidget()->height();\n    const int AVAILABLE_HEIGHT_BELOW = PARENT_HEIGHT - option.rect.top();\n\n    if (AVAILABLE_HEIGHT_BELOW > editorMinimumSize)\n    {\n        editor->move(option.rect.topLeft());\n    }\n    else\n    {\n        int editorNewY = PARENT_HEIGHT - editorMinimumSize;\n        if (editorNewY <= 0)\n        {\n            editorNewY = 0;\n        }\n\n        editor->move(option.rect.left(), editorNewY);\n    }\n\n    if (editorMinimumSize > PARENT_HEIGHT)\n    {\n        editor->setFixedHeight(PARENT_HEIGHT);\n    }\n    else\n    {\n        editor->setFixedHeight(editorMinimumSize);\n    }\n}\n"
  },
  {
    "path": "editors/ComponentEditor/common/EnumerationEditorConstructorDelegate.h",
    "content": "//-----------------------------------------------------------------------------\n// File: EnumerationEditorConstructorDelegate.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 18.01.2023\n//\n// Description:\n// The delegate that provides enumeration editors.\n//-----------------------------------------------------------------------------\n\n#ifndef ENUMERATIONEDITORCONSTRUCTORDELEGATE_H\n#define ENUMERATIONEDITORCONSTRUCTORDELEGATE_H\n\n#include <QStyledItemDelegate>\n// #include <QSharedPointer>\n\n// class Component;\n\n// #include <QKeyEvent>\n\n//-----------------------------------------------------------------------------\n//! The delegate that provides editors to edit enumerations.\n//-----------------------------------------------------------------------------\nclass EnumerationEditorConstructorDelegate : public QStyledItemDelegate\n{\n\tQ_OBJECT\n\npublic:\n\n\t//! The minimum height for editor editing list of interfaces\n\tstatic const int LIST_EDITOR_MIN_HEIGHT = 100;\n\n\t/*!\n     *  The constructor\n\t *\n\t *    @param [in] parent      The owner of this delegate.\n     */\n    EnumerationEditorConstructorDelegate(QObject* parent);\n\n    /*!\n     *  Set the flag for hiding the check all enumerations check box.\n     *\n     *    @param [in] newValue    The new flag.\n     */\n    void setHideCheckAll(bool newValue);\n\n\t/*!\n     *  The destructor\n     */\n    virtual ~EnumerationEditorConstructorDelegate() = default;\n\n\t/*!\n     *  Create a new editor for the given item\n\t *\n\t *    @param [in] parent  Owner for the editor.\n\t *    @param [in] option  Contains options for the editor.\n\t *    @param [in] index   Model index identifying the item.\n\t *\n\t *    @return The editor to be used to edit the item.\n     */\n\tvirtual QWidget* createEditor(QWidget* parent, QStyleOptionViewItem const& option, QModelIndex const& index) const;\n\n\t/*!\n     *  Set the data for the editor.\n\t *\n\t *    @param [in] editor  The editor where the data is to be set.\n\t *    @param [in] index   Model index identifying the item that's data is to be set.\n     */\n\tvirtual void setEditorData(QWidget* editor, QModelIndex const& index) const;\n\n\t/*!\n     *  Save the data from the editor to the model.\n\t *\n\t *    @param [in] editor  The editor that contains the data to store.\n\t *    @param [in] model   Model that contains the data structure where data is to be saved to.\n\t *    @param [in] index   Model index identifying the item that's data is to be saved.\n     */\n\tvirtual void setModelData(QWidget* editor, QAbstractItemModel* model, QModelIndex const& index) const;\n\n    /*!\n     *  Updates the editor geometry.\n     *\n     *    @param [in] editor  The editor being updated.\n     *    @param [in] option  The options used to update the editor.\n     *    @param [in] index   The model index being edited.\n     */\n    virtual void updateEditorGeometry(QWidget* editor, const QStyleOptionViewItem& option, const QModelIndex& index) const;\n\nprotected:\n\n    /*!\n     *  Repositions the editor if there is not enough space under the default position. The editor is then resized\n     *  to use the available space.\n     *\n     *    @param [in] editor  The editor to reposition.\n     *    @param [in] option  The style options for the editor.\n     *    @param [in] index   The current index.\n     */\n    void repositionAndResizeEditor(QWidget* editor, QStyleOptionViewItem const& option, QModelIndex const& index) const;\n\nprotected slots:\n\n    /*!\n     *  Commit the data from the sending editor and close the editor.\n     */\n    void commitAndCloseEditor();\n\nprivate slots:\n\n    /*!\n     *  Close the editor without committing the changes.\n     */\n    void onEditorCancel();\n\nprivate:\n\t\n\t//! No copying\n\tEnumerationEditorConstructorDelegate(const EnumerationEditorConstructorDelegate& other);\n    EnumerationEditorConstructorDelegate& operator=(const EnumerationEditorConstructorDelegate& other);\n\n    /*!\n     *  Check if the column is used for enumerations.\n     *\n     *    @param [in] index   The selected index.\n     *\n     *    @return True, if the column is used for editing enumerations, false otherwise.\n     */\n    virtual bool isEnumerationEditorColumn(QModelIndex const& index) const = 0;\n\n    /*!\n     *  The list of currently selected enumerations in the selected item.\n     *\n     *    @param [in] index   Index of the selected item.\n     *\n     *    @return List of currently selected enumerations.\n     */\n    virtual QStringList getCurrentSelection(QModelIndex const& index) const = 0;\n\n    /*!\n     *  Get the list of the available enumerations.\n     *\n     *    @return List of the available enumerations.\n     */\n    virtual QStringList getAvailableItems() const = 0;\n\n    /*!\n     *  Get the list of exclusive enumerations.\n     *\n     *    @return List of the exclusvie enumerations.\n     */\n    virtual QStringList getExclusiveItems() const;\n\n    /*!\n     *  Set the selected enumerations to the selected item.\n     *\n     *    @param [in] index           Model index identifying the item that's data is to be saved.\n     *    @param [in] model           Model that contains the data structure where data is to be saved to.\n     *    @param [in] selectedItems   List of the selected enumerations.\n     */\n    virtual void setEnumerationDataToModel(QModelIndex const& index, QAbstractItemModel* model, QStringList const& selectedItems) const = 0;\n\n    //-----------------------------------------------------------------------------\n    // Data.\n    //-----------------------------------------------------------------------------\n\n    //! Flag for hiding the check all enumerations check box.\n    bool hideCheckAll_;\n};\n\n#endif // ENUMERATIONEDITORCONSTRUCTORDELEGATE_H\n"
  },
  {
    "path": "editors/ComponentEditor/common/ExpressionDelegate.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ExpressionDelegate.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Esko Pekkarinen\r\n// Date: 27.01.2015\r\n//\r\n// Description:\r\n// Base class for delegates providing editors for expressions.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"ExpressionDelegate.h\"\r\n\r\n#include \"ExpressionEditor.h\"\r\n\r\n#include <editors/ComponentEditor/common/ExpressionLineEditor.h>\r\n\r\n#include <QAbstractItemView>\r\n#include <QCompleter>\r\n#include <QKeyEvent>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ExpressionDelegate::ExpressionDelegate()\r\n//-----------------------------------------------------------------------------\r\nExpressionDelegate::ExpressionDelegate(QAbstractItemModel* completionModel, QSharedPointer<ParameterFinder> parameterFinder, QObject *parent):\r\nMultilineDescriptionDelegate(parent), \r\ncompletionModel_(completionModel),\r\nparameterFinder_(parameterFinder)\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ExpressionDelegate::~ExpressionDelegate()\r\n//-----------------------------------------------------------------------------\r\nExpressionDelegate::~ExpressionDelegate()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ExpressionDelegate::createEditor()\r\n//-----------------------------------------------------------------------------\r\nQWidget* ExpressionDelegate::createEditor(QWidget* parent, QStyleOptionViewItem const& option, QModelIndex const& index) const\r\n{\r\n    if (columnAcceptsExpression(index.column()))\r\n    {\r\n        return createExpressionEditor(parent);\r\n    }\r\n    else\r\n    {\r\n        return MultilineDescriptionDelegate::createEditor(parent, option, index);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ExpressionDelegate::setEditorData()\r\n//-----------------------------------------------------------------------------\r\nvoid ExpressionDelegate::setEditorData(QWidget* editor, QModelIndex const& index) const\r\n{\r\n    if (columnAcceptsExpression(index.column()))\r\n    {\r\n        ExpressionEditor* expressionEditor = qobject_cast<ExpressionEditor*>(editor);\r\n        expressionEditor->setExpression(index.data(Qt::EditRole).toString());\r\n    }\r\n    else\r\n    {\r\n        MultilineDescriptionDelegate::setEditorData(editor, index);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ExpressionDelegate::setModelData()\r\n//-----------------------------------------------------------------------------\r\nvoid ExpressionDelegate::setModelData(QWidget* editor, QAbstractItemModel* model, QModelIndex const& index) const\r\n{\r\n    if (columnAcceptsExpression(index.column()))\r\n    {\r\n        ExpressionEditor* expressionEditor = qobject_cast<ExpressionEditor*>(editor);\r\n        expressionEditor->finishEditingCurrentWord();\r\n        model->setData(index, expressionEditor->getExpression(), Qt::EditRole);\r\n    }\r\n    else\r\n    {\r\n        MultilineDescriptionDelegate::setModelData(editor, model, index);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ExpressionDelegate::createExpressionEditor()\r\n//-----------------------------------------------------------------------------\r\nExpressionEditor* ExpressionDelegate::createExpressionEditor(QWidget* parent) const\r\n{\r\n    ExpressionEditor* editor = new ExpressionEditor(parameterFinder_, parent);\r\n    editor->setFrameShadow(QFrame::Plain);\r\n\r\n    auto parameterCompleter = new QCompleter(editor);\r\n    parameterCompleter->setModel(completionModel_);\r\n\r\n    editor->setAppendingCompleter(parameterCompleter);\r\n\r\n    connect(editor, SIGNAL(increaseReference(QString)),\r\n        this, SIGNAL(increaseReferences(QString)), Qt::UniqueConnection);\r\n    connect(editor, SIGNAL(decreaseReference(QString)),\r\n        this, SIGNAL(decreaseReferences(QString)), Qt::UniqueConnection);\r\n\r\n    return editor;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ExpressionDelegate::createExpressionLineEditor()\r\n//-----------------------------------------------------------------------------\r\nExpressionLineEditor* ExpressionDelegate::createExpressionLineEditor(QWidget* parent) const\r\n{\r\n\tauto editor = new ExpressionLineEditor(parameterFinder_, parent);\r\n\r\n\tauto parameterCompleter = new QCompleter(editor);\r\n\tparameterCompleter->setModel(completionModel_);\r\n\r\n\teditor->setAppendingCompleter(parameterCompleter);\r\n\r\n\tconnect(editor, SIGNAL(increaseReference(QString)), this, SIGNAL(increaseReferences(QString)), Qt::UniqueConnection);\r\n\tconnect(editor, SIGNAL(decreaseReference(QString)), this, SIGNAL(decreaseReferences(QString)), Qt::UniqueConnection);\r\n\r\n    return editor;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ExpressionDelegate::getParameterFinder()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<ParameterFinder> ExpressionDelegate::getParameterFinder() const\r\n{\r\n    return parameterFinder_;\r\n}\r\n"
  },
  {
    "path": "editors/ComponentEditor/common/ExpressionDelegate.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ExpressionDelegate.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Esko Pekkarinen\r\n// Date: 27.01.2015\r\n//\r\n// Description:\r\n// Base class for delegates providing editors for expressions.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef EXPRESSIONDELEGATE_H\r\n#define EXPRESSIONDELEGATE_H\r\n\r\n#include <editors/ComponentEditor/common/MultilineDescriptionDelegate.h>\r\n\r\n#include <QAbstractItemModel>\r\n#include <QEvent>\r\n\r\nclass ParameterFinder;\r\nclass ExpressionEditor;\r\nclass ExpressionLineEditor;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Base class for delegates providing editors for expressions.\r\n//-----------------------------------------------------------------------------\r\nclass ExpressionDelegate : public MultilineDescriptionDelegate\r\n{\r\n    Q_OBJECT\r\n\r\npublic:\r\n\r\n    /*!\r\n     *  The constructor.\r\n     *\r\n     *    @param [in] completionModel     Model containing the completions used in expression editor.\r\n     *    @param [in] parameterFinder     The parameter finder to use for for expression editor.\r\n     *    @param [in] parent              The parent object.\r\n     */\r\n    ExpressionDelegate(QAbstractItemModel* completionModel, QSharedPointer<ParameterFinder> parameterFinder,\r\n        QObject* parent);\r\n    \r\n    //! The destructor.\r\n    virtual ~ExpressionDelegate();\r\n\r\n    /*! Create a new editor for the given item\r\n\t *\r\n\t * @param [in] parent   Owner for the editor.\r\n\t * @param [in] option   Contains options for the editor.\r\n\t * @param [in] index    Model index identifying the item.\r\n\t *\r\n\t * @return Pointer to the editor to be used to edit the item.\r\n\t*/\r\n\tvirtual QWidget* createEditor(QWidget* parent, QStyleOptionViewItem const& option, \r\n        QModelIndex const& index) const;\r\n\r\n\t/*! Set the data for the editor.\r\n\t *\r\n\t * @param [in] editor   Pointer to the editor where the data is to be set.\r\n\t * @param [in] index    Model index identifying the item that's data is to be set.\r\n\t *\r\n\t*/\r\n\tvirtual void setEditorData(QWidget* editor, QModelIndex const& index) const;\r\n\r\n\t/*! Save the data from the editor to the model.\r\n\t *\r\n\t * @param [in] editor   Pointer to the editor that contains the data to store.\r\n\t * @param [in] model    Model that contains the data structure where data is to be saved to.\r\n\t * @param [in] index    Model index identifying the item that's data is to be saved.\r\n\t *\r\n\t*/\r\n\tvirtual void setModelData(QWidget* editor, QAbstractItemModel* model, QModelIndex const& index) const;\r\n\r\nsignals: \r\n\r\n    /*!\r\n    *  Increase the amount of references to a parameter corresponding to the id.\r\n    *\r\n    *    @param [in] id      The id of the parameter being searched for.\r\n    */\r\n    void increaseReferences(QString id);\r\n\r\n    /*!\r\n    *  Decrease the amount of references to a parameter corresponding to the id.\r\n    *\r\n    *    @param [in] id      The id of the parameter being searched for.\r\n    */\r\n    void decreaseReferences(QString id);\r\n\r\nprotected:\r\n\r\n    /*!\r\n     *  Checks if the given column supports expressions in the editor.\r\n     *\r\n     *    @param [in] column   The column to check.\r\n     *\r\n     *    @return True, if the cells in the column allow expressions, otherwise false.\r\n     */\r\n    virtual bool columnAcceptsExpression(int column) const = 0;\r\n\r\n    /*!\r\n     *  Gets the parameter finder used in expressions.\r\n     *\r\n     *    @return The parameter finder.\r\n     */\r\n    QSharedPointer<ParameterFinder> getParameterFinder() const;\r\n\r\n    /*!\r\n     *  Creates an editor for expressions.\r\n     *\r\n     *    @param [in] parent   The parent widget for the editor.\r\n     *\r\n     *    @return An editor for expressions.\r\n     */\r\n    ExpressionEditor* createExpressionEditor(QWidget* parent) const;\r\n\r\n    /*!\r\n     *  Creates a line editor for expressions.\r\n     *\r\n     *    @param [in] parent   The parent widget for the editor.\r\n     *\r\n     *    @return A line editor for expressions.\r\n     */\r\n    ExpressionLineEditor* createExpressionLineEditor(QWidget* parent) const;\r\n\r\nprotected:\r\n\r\n    //! The model containing parameter names that can be used in expressions.\r\n    QAbstractItemModel* completionModel_;\r\n\r\nprivate:\r\n    // Disable copying.\r\n    ExpressionDelegate(ExpressionDelegate const& rhs);\r\n    ExpressionDelegate& operator=(ExpressionDelegate const& rhs);\r\n\r\n\r\n    //! Finder for parameters in the containing component.\r\n    QSharedPointer<ParameterFinder> parameterFinder_;\r\n\r\n};\r\n\r\n#endif // EXPRESSIONDELEGATE_H\r\n"
  },
  {
    "path": "editors/ComponentEditor/common/ExpressionEditor.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ExpressionEditor.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Esko Pekkarinen\r\n// Date: 18.12.2014\r\n//\r\n// Description:\r\n// Editor for expressions with parameter name completion.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"ExpressionEditor.h\"\r\n\r\n#include <QCompleter>\r\n#include <QKeyEvent>\r\n#include <QRegularExpression>\r\n#include <QTextCursor>\r\n\r\n#include <KactusAPI/include/ParameterFinder.h>\r\n#include <KactusAPI/include/SystemVerilogSyntax.h>\r\n\r\n#include <editors/ComponentEditor/parameters/ComponentParameterColumns.h>\r\n\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ExpressionEditor::ExpressionEditor()\r\n//-----------------------------------------------------------------------------\r\nExpressionEditor::ExpressionEditor(QSharedPointer<ParameterFinder> parameterFinder, QWidget* parent):\r\nQTextEdit(parent),\r\nMasterExpressionEditor(parameterFinder, this)\r\n{\r\n    setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);\r\n    setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);\r\n    setUndoRedoEnabled(false);\r\n\r\n    setTabChangesFocus(true);\r\n    setLineWrapMode(QTextEdit::NoWrap);\r\n\r\n    setFrameStyle(QFrame::Plain);\r\n    setFrameShape(QFrame::Box);\r\n    setFrameShadow(QFrame::Sunken);\r\n\r\n    connect(this, SIGNAL(cursorPositionChanged()), this, SLOT(updateCompletions()), Qt::UniqueConnection);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ExpressionEditor::setAppendingCompleter()\r\n//-----------------------------------------------------------------------------\r\nvoid ExpressionEditor::setAppendingCompleter(QCompleter* completer)\r\n{\r\n    MasterExpressionEditor::setAppendingCompleter(completer);\r\n    completer->setWidget(this);\r\n\r\n    connect(completer, SIGNAL(activated(QModelIndex const&)), \r\n        this, SLOT(complete(QModelIndex const&)), Qt::UniqueConnection);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ExpressionEditor::setExpression()\r\n//-----------------------------------------------------------------------------\r\nvoid ExpressionEditor::setExpression(QString const& expression)\r\n{\r\n    clear();\r\n    QTextCursor cursor = textCursor();\r\n    cursor.setPosition(0);\r\n\r\n    auto const& delimiter = WORD_DELIMITER;\r\n    int delimiterIndex = expression.indexOf(delimiter, 0);\r\n\r\n    QString word = expression.mid(0, delimiterIndex);\r\n\r\n\tblockSignals(true);\r\n\r\n    insertWord(word, cursor);\r\n\r\n    while(delimiterIndex != -1)\r\n    {\r\n        int wordEndIndex = expression.indexOf(delimiter, delimiterIndex);\r\n\r\n        QString term = expression.mid(delimiterIndex, wordEndIndex - delimiterIndex);\r\n        insertWord(term, cursor);\r\n\r\n        QString operation = delimiter.match(expression, delimiterIndex).captured();\r\n        cursor.insertText(operation, colorFormat(Qt::black));\r\n\r\n        delimiterIndex = wordEndIndex + operation.length();\r\n    }\r\n\r\n    blockSignals(false);\r\n\r\n    MasterExpressionEditor::setExpression(expression);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ExpressionEditor::contextMenuEvent()\r\n//-----------------------------------------------------------------------------\r\nvoid ExpressionEditor::contextMenuEvent(QContextMenuEvent* menuEvent)\r\n{\r\n    menuEvent->accept();\r\n    return;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ExpressionEditor::mousePressEvent()\r\n//-----------------------------------------------------------------------------\r\nvoid ExpressionEditor::mousePressEvent(QMouseEvent* mouseEvent)\r\n{\r\n    finishEditingCurrentWord();\r\n\r\n    QTextEdit::mousePressEvent(mouseEvent);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ExpressionEditor::keyPressEvent()\r\n//-----------------------------------------------------------------------------\r\nvoid ExpressionEditor::keyPressEvent(QKeyEvent* keyEvent)\r\n{\r\n    if (keyEvent->key() == Qt::Key_Return || keyEvent->key() == Qt::Key_Enter)\r\n    {\r\n        QWidget::keyPressEvent(keyEvent);\r\n        return;\r\n    }\r\n\r\n    handleKeyPressEvent(keyEvent);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ExpressionEditor::focusInEvent()\r\n//-----------------------------------------------------------------------------\r\nvoid ExpressionEditor::focusInEvent(QFocusEvent* focusEvent)\r\n{\r\n    QTextEdit::focusInEvent(focusEvent);\r\n\r\n    if (focusEvent->reason() != Qt::PopupFocusReason )\r\n    {\r\n        selectAll();\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ExpressionEditor::complete()\r\n//-----------------------------------------------------------------------------\r\nvoid ExpressionEditor::complete(QModelIndex const& index)\r\n{\r\n    MasterExpressionEditor::complete(index);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ExpressionEditor::updateCompletions()\r\n//-----------------------------------------------------------------------------\r\nvoid ExpressionEditor::updateCompletions()\r\n{\r\n    updateCompleteWords();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ExpressionEditor::insertWord()\r\n//-----------------------------------------------------------------------------\r\nvoid ExpressionEditor::insertWord(QString const& word, QTextCursor& cursor)\r\n{\r\n    if (isReference(word))\r\n    {\r\n        cursor.insertText(getNameForParameterID(word), colorFormat(Qt::darkGreen));\r\n    }\r\n    else if (wordIsConstant(word) || getReservedWords().contains(word, Qt::CaseInsensitive) || wordIsMathFunction(word))\r\n    {\r\n        cursor.insertText(word, colorFormat(Qt::black));\r\n    }\r\n    else\r\n    {\r\n        cursor.insertText(word, colorFormat(Qt::red));\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ExpressionEditor::colorCurrentWordRed()\r\n//-----------------------------------------------------------------------------\r\nvoid ExpressionEditor::colorCurrentWordRed()\r\n{\r\n    QTextCursor cursor = textCursor();\r\n    cursor.movePosition(QTextCursor::StartOfWord, QTextCursor::MoveAnchor);\r\n    cursor.movePosition(QTextCursor::EndOfWord, QTextCursor::KeepAnchor);\r\n    cursor.setCharFormat(colorFormat(Qt::red));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ExpressionEditor::colorCurrentWordBlack()\r\n//-----------------------------------------------------------------------------\r\nvoid ExpressionEditor::colorCurrentWordBlack()\r\n{\r\n    QTextCursor cursor = textCursor();\r\n    cursor.movePosition(QTextCursor::StartOfWord, QTextCursor::MoveAnchor);\r\n    cursor.movePosition(QTextCursor::EndOfWord, QTextCursor::KeepAnchor);\r\n    cursor.setCharFormat(colorFormat(Qt::black));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ExpressionEditor::mouseMoveEvent()\r\n//-----------------------------------------------------------------------------\r\nvoid ExpressionEditor::mouseMoveEvent(QMouseEvent* mouseEvent)\r\n{\r\n    handleMouseMoveEvent(mouseEvent);\r\n\r\n    QTextEdit::mouseMoveEvent(mouseEvent);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ExpressionEditor::mouseReleaseEvent()\r\n//-----------------------------------------------------------------------------\r\nvoid ExpressionEditor::mouseReleaseEvent(QMouseEvent* mouseEvent)\r\n{\r\n    handleMouseReleaseEvent();\r\n\r\n    QTextEdit::mouseReleaseEvent(mouseEvent);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ExpressionEditor::focusOutEvent()\r\n//-----------------------------------------------------------------------------\r\nvoid ExpressionEditor::focusOutEvent(QFocusEvent *event)\r\n{\r\n    QTextEdit::focusOutEvent(event);\r\n\r\n    emit editingFinished();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ExpressionEditor::hasSelection()\r\n//-----------------------------------------------------------------------------\r\nbool ExpressionEditor::hasSelection()\r\n{\r\n    return textCursor().hasSelection();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ExpressionEditor::handleParentKeyPressEvent()\r\n//-----------------------------------------------------------------------------\r\nvoid ExpressionEditor::handleParentKeyPressEvent(QKeyEvent* keyEvent)\r\n{\r\n    if (keyEvent->text().isEmpty() == false)\r\n    {\r\n        auto cursor = textCursor();\r\n        cursor.setCharFormat(colorFormat(Qt::black));\r\n        setTextCursor(cursor);\r\n    }\r\n\r\n    QTextEdit::keyPressEvent(keyEvent);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ExpressionEditor::handleReferenceDecrease()\r\n//-----------------------------------------------------------------------------\r\nvoid ExpressionEditor::handleReferenceDecrease(QString const& referenceItem)\r\n{\r\n    emit decreaseReference(referenceItem);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ExpressionEditor::handleReferenceIncrease()\r\n//-----------------------------------------------------------------------------\r\nvoid ExpressionEditor::handleReferenceIncrease(QString const& referenceItem)\r\n{\r\n    emit increaseReference(referenceItem);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ExpressionEditor::setCompletedParameterName()\r\n//-----------------------------------------------------------------------------\r\nvoid ExpressionEditor::setCompletedParameterName(QString const& parameterName)\r\n{\r\n    QTextCursor cursor = textCursor();\r\n    cursor.setPosition(startOfCurrentWord());\r\n    cursor.movePosition(QTextCursor::EndOfWord, QTextCursor::KeepAnchor);\r\n    cursor.insertText(parameterName, colorFormat(Qt::darkGreen));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ExpressionEditor::getCursorPosition()\r\n//-----------------------------------------------------------------------------\r\nint ExpressionEditor::getCursorPosition() const\r\n{\r\n    return textCursor().position();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ExpressionEditor::getCurrentText()\r\n//-----------------------------------------------------------------------------\r\nQString ExpressionEditor::getCurrentText() const\r\n{\r\n    return toPlainText();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ExpressionEditor::getSelectedText()\r\n//-----------------------------------------------------------------------------\r\nQString ExpressionEditor::getSelectedText() const\r\n{\r\n    return textCursor().selectedText();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ExpressionEditor::getSelectionFirstWord()\r\n//-----------------------------------------------------------------------------\r\nint ExpressionEditor::getSelectionFirstWord() const\r\n{\r\n    return toPlainText().left(textCursor().selectionStart()).count(WORD_DELIMITER);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ExpressionEditor::getSelectionLastWord()\r\n//-----------------------------------------------------------------------------\r\nint ExpressionEditor::getSelectionLastWord() const\r\n{\r\n    return toPlainText().left(textCursor().selectionEnd()).count(WORD_DELIMITER);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ExpressionEditor::getSelectionStartIndex()\r\n//-----------------------------------------------------------------------------\r\nint ExpressionEditor::getSelectionStartIndex() const\r\n{\r\n    return textCursor().selectionStart();\r\n}\r\n"
  },
  {
    "path": "editors/ComponentEditor/common/ExpressionEditor.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ExpressionEditor.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Esko Pekkarinen\r\n// Date: 18.12.2014\r\n//\r\n// Description:\r\n// Editor for expressions with parameter name completion.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef EXPRESSIONEDITOR_H\r\n#define EXPRESSIONEDITOR_H\r\n\r\n#include <editors/ComponentEditor/common/MasterExpressionEditor.h>\r\n\r\n#include <QCompleter>\r\n#include <QTextEdit>\r\n\r\nclass ParameterFinder;\r\n//-----------------------------------------------------------------------------\r\n//! Editor for expressions with parameter name completion.\r\n//-----------------------------------------------------------------------------\r\nclass ExpressionEditor : public QTextEdit, public MasterExpressionEditor\r\n{\r\n    Q_OBJECT\r\npublic:\r\n\r\n    static constexpr auto DEFAULT_HEIGHT = 20;\r\n\r\n\t/*!\r\n     *  The constructor.\r\n     */\r\n    ExpressionEditor(QSharedPointer<ParameterFinder> parameterFinder, QWidget* parent = nullptr);\r\n\r\n\t/*!\r\n     *  The destructor.\r\n     */\r\n\tvirtual ~ExpressionEditor() = default;\r\n\r\n    // Disable copying.\r\n    ExpressionEditor(ExpressionEditor const& rhs) = delete;\r\n    ExpressionEditor& operator=(ExpressionEditor const& rhs) = delete;\r\n\r\n    /*!\r\n     *  Sets a completer whose selection will be appended to the text.\r\n     *\r\n     *    @param [in] completer   The completer to set.\r\n     */\r\n    void setAppendingCompleter(QCompleter* completer) final;\r\n    \r\n    /*!\r\n     *  Sets the expression in the editor.\r\n     *\r\n     *    @param [in] expression   The expression to set.\r\n     */\r\n    void setExpression(QString const& expression) final;\r\n\r\nprotected:\r\n\r\n    /*!\r\n     *  Captures the context menu event and accepts it.\r\n     *\r\n     *    @param [in] menuEvent   The event for context menu.\r\n     */\r\n    void contextMenuEvent(QContextMenuEvent* menuEvent) override;\r\n\r\n    /*!\r\n     *  Captures the mouse press event and finishes editing the current word.\r\n     *\r\n     *    @param [in] mouseEvent  The event representing user input.\r\n     */\r\n    void mousePressEvent(QMouseEvent* mouseEvent) override;\r\n\r\n    /*!\r\n     *  Captures the user input and edits the underlying expression accordingly.\r\n     *\r\n     *    @param [in] keyEvent   The event representing the user input.\r\n     */\r\n    void keyPressEvent(QKeyEvent* keyEvent) override;\r\n\r\n    /*!\r\n     *  Selects the text when the editor is opened.\r\n     *\r\n     *    @param [in] focusEvent   The event representing the focus change.\r\n     */\r\n    void focusInEvent(QFocusEvent* focusEvent) override;\r\n\r\n    /*!\r\n     *  Captures the mouse move and sets/clears notSelectingText flag according to mouse press.\r\n     *\r\n     *    @param [in] mouseEvent   The mouse event representing the mouse movement and button press.\r\n     */\r\n    void mouseMoveEvent(QMouseEvent* mouseEvent) override;\r\n\r\n    /*!\r\n     *  Clears notSelectingText flag when the mouse button is released.\r\n     *\r\n     *    @param [in] mouseEvent   The event representing the mouse button release.\r\n     */\r\n    void mouseReleaseEvent(QMouseEvent* mouseEvent) override;\r\n\r\n    /*!\r\n     *  Emits a signal informing of the ending of editing the expression.\r\n     *\r\n     *    @param [in] event   The event representing the changing of focus.\r\n     */\r\n    void focusOutEvent(QFocusEvent *event) override;\r\n\r\nsignals:\r\n\r\n    /*!\r\n     *  Increase the amount of references to a parameter corresponding to the id.\r\n     *\r\n     *    @param [in] parameterId     The id of the parameter being referenced.\r\n     */\r\n    void increaseReference(QString const& parameterId);\r\n\r\n    /*!\r\n     *  Decrease the amount of references to a parameter corresponding to the id.\r\n     *\r\n     *    @param [in] parameterId     The id of the parameter being referenced.\r\n     */\r\n    void decreaseReference(QString const& parameterId);\r\n\r\n    /*!\r\n     *  Informs that the editing of the expression has finished.\r\n     */\r\n    void editingFinished();\r\n\r\nprivate slots:\r\n\r\n    /*!\r\n     *  Called when a word completion has been selected. Replaces the word under the cursor with the selection.\r\n     *\r\n     *    @param [in] word   The selected word.\r\n     */\r\n    void complete(QModelIndex const& index);\r\n\r\n    /*!\r\n     *  Called when the cursor position changes. If a different word is under the new position, it is suggested\r\n     *  for new completion.\r\n     *\r\n     */\r\n    void updateCompletions();\r\n\r\nprivate:\r\n\r\n\r\n    /*!\r\n     *  Inserts a given word into the text using the given cursor.\r\n     *\r\n     *    @param [in] word    The word to insert into the text.\r\n     *    @param [in] cursor  The cursor to use to insert the text.\r\n     */\r\n    void insertWord(QString const& word, QTextCursor& cursor);\r\n\r\n    /*!\r\n     *  Changes the color of the font for the current word to red.\r\n     */\r\n    void colorCurrentWordRed() final;\r\n\r\n    /*!\r\n     *  Changes the color of the font for the current word to black.\r\n     */\r\n    void colorCurrentWordBlack() final;\r\n\r\n    /*!\r\n     *  Check if a selection exists.\r\n     *\r\n     *    @return True, if a selection exists, false otherwise.\r\n     */\r\n    bool hasSelection() final;\r\n\r\n    /*!\r\n     *  Let the parent widget handle the key press event.\r\n     *\r\n     *    @param [in] keyEvent    The selected key press event.\r\n     */\r\n    void handleParentKeyPressEvent(QKeyEvent* keyEvent) final;\r\n\r\n    /*!\r\n     *  Decrease references made to the selected ID.\r\n     *\r\n     *    @param [in] referenceItem   ID of the selected item.\r\n     */\r\n    void handleReferenceDecrease(QString const& referenceItem) final;\r\n\r\n    /*!\r\n     *  Increase references made to the selected ID.\r\n     *\r\n     *    @param [in] referenceItem   ID of the selected item.\r\n     */\r\n    void handleReferenceIncrease(QString const& referenceItem) final;\r\n\r\n    /*!\r\n     *  Set the completed parameter name for the editor.\r\n     *\r\n     *    @param [in] parameterName   The completed parameter name.\r\n     */\r\n    void setCompletedParameterName(QString const& parameterName) final;\r\n\r\n    /*!\r\n     *  Get the current cursor position.\r\n     *\r\n     *    @return The position of the cursor.\r\n     */\r\n    int getCursorPosition() const final;\r\n\r\n    /*!\r\n     *  Get the current text of the editor.\r\n     *\r\n     *    @return The current text.\r\n     */\r\n    QString getCurrentText() const final;\r\n\r\n    /*!\r\n     *  Get the selected text.\r\n     *\r\n     *    @return The selected text.\r\n     */\r\n    QString getSelectedText() const final;\r\n\r\n    /*!\r\n     *  Count the length of the first word in the current selection.\r\n     *\r\n     *    @return Length of the first word in the selection.\r\n     */\r\n    int getSelectionFirstWord() const final;\r\n\r\n    /*!\r\n     *  Count the length of the last word in the current selection.\r\n     *\r\n     *    @return Length of the last word in the selection.\r\n     */\r\n    int getSelectionLastWord() const final;\r\n\r\n    /*!\r\n     *\tGet the start index of the selection.\r\n     *\t    \r\n     * \t    @return The start index of the current selection.\r\n     */\r\n    int getSelectionStartIndex() const final;\r\n};\r\n\r\n#endif // EXPRESSIONEDITOR_H"
  },
  {
    "path": "editors/ComponentEditor/common/ExpressionLineEditor.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: ExpressionLineEditor.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 18.10.2022\n//\n// Description:\n// Line editor for expressions with parameter name completion.\n//-----------------------------------------------------------------------------\n\n#include \"ExpressionLineEditor.h\"\n\n#include <QKeyEvent>\n#include <QRegularExpression>\n\n#include <KactusAPI/include/ParameterFinder.h>\n\n#include <editors/ComponentEditor/parameters/ComponentParameterColumns.h>\n\n#include \"SystemVerilogSyntax.h\"\n\n//-----------------------------------------------------------------------------\n// Function: ExpressionLineEditor::ExpressionLineEditor()\n//-----------------------------------------------------------------------------\nExpressionLineEditor::ExpressionLineEditor(QSharedPointer<ParameterFinder> parameterFinder, QWidget* parent):\nQLineEdit(parent),\nMasterExpressionEditor(parameterFinder, this)\n{\n    connect(this, SIGNAL(cursorPositionChanged(int, int)), \n        this, SLOT(updateCompletions(int, int)), Qt::UniqueConnection);\n}\n\n//-----------------------------------------------------------------------------\n// Function: ExpressionLineEditor::setAppendingCompleter()\n//-----------------------------------------------------------------------------\nvoid ExpressionLineEditor::setAppendingCompleter(QCompleter* completer)\n{\n    MasterExpressionEditor::setAppendingCompleter(completer);\n    completer->setWidget(this);\n\n    connect(completer, SIGNAL(activated(QModelIndex const&)), \n        this, SLOT(complete(QModelIndex const&)), Qt::UniqueConnection);\n}\n\n//-----------------------------------------------------------------------------\n// Function: ExpressionLineEditor::setExpression()\n//-----------------------------------------------------------------------------\nvoid ExpressionLineEditor::setExpression(QString const& expression)\n{\n    MasterExpressionEditor::setExpression(expression);\n}\n\n//-----------------------------------------------------------------------------\n// Function: ExpressionEditor::contextMenuEvent()\n//-----------------------------------------------------------------------------\nvoid ExpressionLineEditor::contextMenuEvent(QContextMenuEvent* menuEvent)\n{\n    menuEvent->accept();\n}\n\n//-----------------------------------------------------------------------------\n// Function: ExpressionLineEditor::mousePressEvent()\n//-----------------------------------------------------------------------------\nvoid ExpressionLineEditor::mousePressEvent(QMouseEvent* mouseEvent)\n{\n    finishEditingCurrentWord();\n\n    QLineEdit::mousePressEvent(mouseEvent);\n}\n\n//-----------------------------------------------------------------------------\n// Function: ExpressionLineEditor::keyPressEvent()\n//-----------------------------------------------------------------------------\nvoid ExpressionLineEditor::keyPressEvent(QKeyEvent* keyEvent)\n{\n    if (keyEvent->key() == Qt::Key_Return || keyEvent->key() == Qt::Key_Enter)\n    {\n        QWidget::keyPressEvent(keyEvent);\n        return;\n    }\n\n    handleKeyPressEvent(keyEvent);\n}\n\n//-----------------------------------------------------------------------------\n// Function: ExpressionLineEditor::focusInEvent()\n//-----------------------------------------------------------------------------\nvoid ExpressionLineEditor::focusInEvent(QFocusEvent* focusEvent)\n{\n    QLineEdit::focusInEvent(focusEvent);\n\n    if (focusEvent->reason() != Qt::PopupFocusReason )\n    {\n        selectAll();\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: ExpressionLineEditor::complete()\n//-----------------------------------------------------------------------------\nvoid ExpressionLineEditor::complete(QModelIndex const& index)\n{\n    MasterExpressionEditor::complete(index);\n}\n\n//-----------------------------------------------------------------------------\n// Function: ExpressionLineEditor::updateCompletions()\n//-----------------------------------------------------------------------------\nvoid ExpressionLineEditor::updateCompletions(int /*oldPosition*/, int /*newPosition*/)\n{\n    updateCompleteWords();\n}\n\n//-----------------------------------------------------------------------------\n// Function: ExpressionLineEditor::colorCurrentWordRed()\n//-----------------------------------------------------------------------------\nvoid ExpressionLineEditor::colorCurrentWordRed()\n{\n    // Empty by intent.\n}\n\n//-----------------------------------------------------------------------------\n// Function: ExpressionLineEditor::colorCurrentWordBlack()\n//-----------------------------------------------------------------------------\nvoid ExpressionLineEditor::colorCurrentWordBlack()\n{\n    // Empty by intent.\n}\n\n//-----------------------------------------------------------------------------\n// Function: ExpressionLineEditor::mouseMoveEvent()\n//-----------------------------------------------------------------------------\nvoid ExpressionLineEditor::mouseMoveEvent(QMouseEvent* mouseEvent)\n{\n    handleMouseMoveEvent(mouseEvent);\n\n    QLineEdit::mouseMoveEvent(mouseEvent);\n}\n\n//-----------------------------------------------------------------------------\n// Function: ExpressionLineEditor::mouseReleaseEvent()\n//-----------------------------------------------------------------------------\nvoid ExpressionLineEditor::mouseReleaseEvent(QMouseEvent* mouseEvent)\n{\n    handleMouseReleaseEvent();\n\n    QLineEdit::mouseReleaseEvent(mouseEvent);\n}\n\n//-----------------------------------------------------------------------------\n// Function: ExpressionLineEditor::focusOutEvent()\n//-----------------------------------------------------------------------------\nvoid ExpressionLineEditor::focusOutEvent(QFocusEvent *event)\n{\n    QLineEdit::focusOutEvent(event);\n\n    emit editingFinished();\n}\n\n//-----------------------------------------------------------------------------\n// Function: ExpressionLineEditor::hasSelection()\n//-----------------------------------------------------------------------------\nbool ExpressionLineEditor::hasSelection()\n{\n    int textStart = selectionStart();\n    int textEnd = selectionEnd();\n\n    return textStart >= 0 && textEnd >= 0 && textStart != textEnd;\n}\n\n//-----------------------------------------------------------------------------\n// Function: ExpressionLineEditor::handleParentKeyPressEvent()\n//-----------------------------------------------------------------------------\nvoid ExpressionLineEditor::handleParentKeyPressEvent(QKeyEvent* keyEvent)\n{\n    QLineEdit::keyPressEvent(keyEvent);\n}\n\n//-----------------------------------------------------------------------------\n// Function: ExpressionLineEditor::handleReferenceDecrease()\n//-----------------------------------------------------------------------------\nvoid ExpressionLineEditor::handleReferenceDecrease(QString const& referenceItem)\n{\n    emit decreaseReference(referenceItem);\n}\n\n//-----------------------------------------------------------------------------\n// Function: ExpressionLineEditor::handleReferenceIncrease()\n//-----------------------------------------------------------------------------\nvoid ExpressionLineEditor::handleReferenceIncrease(QString const& referenceItem)\n{\n    emit increaseReference(referenceItem);\n}\n\n//-----------------------------------------------------------------------------\n// Function: ExpressionLineEditor::setCompletedParameterName()\n//-----------------------------------------------------------------------------\nvoid ExpressionLineEditor::setCompletedParameterName(QString const& parameterName)\n{\n    setText(replaceNthWordWith(currentWordIndex(), text(), parameterName));\n}\n\n//-----------------------------------------------------------------------------\n// Function: ExpressionLineEditor::getCursorPosition()\n//-----------------------------------------------------------------------------\nint ExpressionLineEditor::getCursorPosition() const\n{\n    return cursorPosition();\n}\n\n//-----------------------------------------------------------------------------\n// Function: ExpressionLineEditor::getCurrentText()\n//-----------------------------------------------------------------------------\nQString ExpressionLineEditor::getCurrentText() const\n{\n    return text();\n}\n\n//-----------------------------------------------------------------------------\n// Function: ExpressionLineEditor::getSelectedText()\n//-----------------------------------------------------------------------------\nQString ExpressionLineEditor::getSelectedText() const\n{\n    return selectedText();\n}\n\n//-----------------------------------------------------------------------------\n// Function: ExpressionLineEditor::getSelectionFirstWord()\n//-----------------------------------------------------------------------------\nint ExpressionLineEditor::getSelectionFirstWord() const\n{\n    return text().left(selectionStart()).count(WORD_DELIMITER);\n}\n\n//-----------------------------------------------------------------------------\n// Function: ExpressionLineEditor::getSelectionLastWord()\n//-----------------------------------------------------------------------------\nint ExpressionLineEditor::getSelectionLastWord() const\n{\n    return text().left(selectionEnd()).count(WORD_DELIMITER);\n}\n\n//-----------------------------------------------------------------------------\n// Function: ExpressionLineEditor::getSelectionStartIndex()\n//-----------------------------------------------------------------------------\nint ExpressionLineEditor::getSelectionStartIndex() const\n{\n    return selectionStart();\n}\n"
  },
  {
    "path": "editors/ComponentEditor/common/ExpressionLineEditor.h",
    "content": "//-----------------------------------------------------------------------------\n// File: ExpressionLineEditor.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 18.10.2022\n//\n// Description:\n// Line editor for expressions with parameter name completion.\n//-----------------------------------------------------------------------------\n\n#ifndef EXPRESSIONLINEEDITOR_H\n#define EXPRESSIONLINEEDITOR_H\n\n#include <editors/ComponentEditor/common/MasterExpressionEditor.h>\n\n#include <QCompleter>\n#include <QLineEdit>\n\nclass ParameterFinder;\n\n//-----------------------------------------------------------------------------\n//! Line editor for expressions with parameter name completion.\n//-----------------------------------------------------------------------------\nclass ExpressionLineEditor : public QLineEdit, public MasterExpressionEditor\n{\n    Q_OBJECT\npublic:\n\n\t/*!\n     *  The constructor.\n     * \n     *    @param [in] parameterFinder     The parameter finder.\n     *    @param [in] parent              The parent widget.\n     */\n    ExpressionLineEditor(QSharedPointer<ParameterFinder> parameterFinder, QWidget* parent = 0);\n\n\t/*!\n     *  The destructor.\n     */\n\tvirtual ~ExpressionLineEditor() = default;\n\n    // Disable copying.\n    ExpressionLineEditor(ExpressionLineEditor const& rhs) = delete;\n    ExpressionLineEditor& operator=(ExpressionLineEditor const& rhs) = delete;\n\n    /*!\n     *  Sets a completer whose selection will be appended to the text.\n     *\n     *    @param [in] completer   The completer to set.\n     */\n    void setAppendingCompleter(QCompleter* completer) final;\n    \n    /*!\n     *  Sets the expression in the editor.\n     *\n     *    @param [in] expression   The expression to set.\n     */\n    void setExpression(QString const& expression) final;\n\nprotected:\n\n    /*!\n     *  Captures the context menu event and accepts it.\n     *\n     *    @param [in] menuEvent   The event for context menu.\n     */\n    void contextMenuEvent(QContextMenuEvent* menuEvent) final;\n\n    /*!\n     *  Captures the mouse press event and finishes editing the current word.\n     *\n     *    @param [in] mouseEvent  The event representing user input.\n     */\n    void mousePressEvent(QMouseEvent* mouseEvent) final;\n\n    /*!\n     *  Captures the user input and edits the underlying expression accordingly.\n     *\n     *    @param [in] keyEvent   The event representing the user input.\n     */\n    void keyPressEvent(QKeyEvent* keyEvent) final;\n\n    /*!\n     *  Selects the text when the editor is opened.\n     *\n     *    @param [in] focusEvent   The event representing the focus change.\n     */\n    void focusInEvent(QFocusEvent* focusEvent) final;\n\n    /*!\n     *  Captures the mouse move and sets/clears notSelectingText flag according to mouse press.\n     *\n     *    @param [in] mouseEvent   The mouse event representing the mouse movement and button press.\n     */\n    void mouseMoveEvent(QMouseEvent* mouseEvent) final;\n\n    /*!\n     *  Clears notSelectingText flag when the mouse button is released.\n     *\n     *    @param [in] mouseEvent   The event representing the mouse button release.\n     */\n    void mouseReleaseEvent(QMouseEvent* mouseEvent) final;\n\n    /*!\n     *  Emits a signal informing of the ending of editing the expression.\n     *\n     *    @param [in] event   The event representing the changing of focus.\n     */\n    void focusOutEvent(QFocusEvent *event) final;\n\nsignals:\n\n    /*!\n     *  Increase the amount of references to a parameter corresponding to the id.\n     *\n     *    @param [in] parameterId     The id of the parameter being referenced.\n     */\n    void increaseReference(QString const& parameterId);\n\n    /*!\n     *  Decrease the amount of references to a parameter corresponding to the id.\n     *\n     *    @param [in] parameterId     The id of the parameter being referenced.\n     */\n    void decreaseReference(QString const& parameterId);\n\nprivate slots:\n\n    /*!\n     *  Called when a word completion has been selected. Replaces the word under the cursor with the selection.\n     *\n     *    @param [in] word   The selected word.\n     */\n    void complete(QModelIndex const& index);\n\n    /*!\n     *  Called when the cursor position changes. If a different word is under the new position, it is suggested\n     *  for new completion.\n     *\n     *    @param [in] oldPosition     Old position of the cursor.\n     *    @param [in] newPosition     New position of the cursor.\n     */\n    void updateCompletions(int oldPosition, int newPosition);\n\nprivate:\n\n    /*!\n     *  Changes the color of the font for the current word to red.\n     */\n    void colorCurrentWordRed() final;\n\n    /*!\n     *  Changes the color of the font for the current word to black.\n     */\n    void colorCurrentWordBlack() final;\n\n    /*!\n     *  Check if a selection exists.\n     *\n     *    @return True, if a selection exists, false otherwise.\n     */\n    bool hasSelection() final;\n\n    /*!\n     *  Let the parent widget handle the key press event.\n     *\n     *    @param [in] keyEvent    The selected key press event.\n     */\n    void handleParentKeyPressEvent(QKeyEvent* keyEvent) final;\n\n    /*!\n     *  Decrease references made to the selected ID.\n     *\n     *    @param [in] referenceItem   ID of the selected item.\n     */\n    void handleReferenceDecrease(QString const& referenceItem) final;\n\n    /*!\n     *  Increase references made to the selected ID.\n     *\n     *    @param [in] referenceItem   ID of the selected item.\n     */\n    void handleReferenceIncrease(QString const& referenceItem) final;\n\n    /*!\n     *  Set the completed parameter name for the editor.\n     *\n     *    @param [in] parameterName   The completed parameter name.\n     */\n    void setCompletedParameterName(QString const& parameterName) final;\n\n    /*!\n     *  Get the current cursor position.\n     *\n     *    @return The position of the cursor.\n     */\n    int getCursorPosition() const final;\n\n    /*!\n     *  Get the current text of the editor.\n     *\n     *    @return The current text.\n     */\n    QString getCurrentText() const final;\n\n    /*!\n     *  Get the selected text.\n     *\n     *    @return The selected text.\n     */\n    QString getSelectedText() const final;\n\n    /*!\n     *  Count the length of the first word in the current selection.\n     *\n     *    @return Length of the first word in the selection.\n     */\n    int getSelectionFirstWord() const final;\n\n    /*!\n     *  Count the length of the last word in the current selection.\n     *\n     *    @return Length of the last word in the selection.\n     */\n    int getSelectionLastWord() const final;\n\n    /*!\n     *\tGet the start index of the selection.\n     *\n     * \t    @return The start index of the current selection.\n     */\n    int getSelectionStartIndex() const final;\n};\n\n#endif // EXPRESSIONLINEEDITOR_H"
  },
  {
    "path": "editors/ComponentEditor/common/FloatingModeReferenceEditor.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: FloatingModeReferenceEditor.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Anton Hagqvist\n// Date: 16.10.2023\n//\n// Description:\n// A mode reference editor for tables containing mode references.\n//-----------------------------------------------------------------------------\n\n#include \"FloatingModeReferenceEditor.h\"\n#include \"ModeReferenceEditor.h\"\n\n#include <QVBoxLayout>\n#include <QPushButton>\n\n//-----------------------------------------------------------------------------\n// Function: FloatingModeReferenceEditor::FloatingModeReferenceEditor()\n//-----------------------------------------------------------------------------\nFloatingModeReferenceEditor::FloatingModeReferenceEditor(ModeReferenceInterface* modeRefInterface, QWidget* parent):\n    QFrame(parent)\n{\n    modeReferencesEditor_ = new ModeReferenceEditor(modeRefInterface, this);\n\n    setFrameStyle(QFrame::StyledPanel);\n    setAutoFillBackground(true);\n\n    setupLayout();\n}\n\n//-----------------------------------------------------------------------------\n// Function: FloatingModeReferenceEditor::getTableSizeHint()\n//-----------------------------------------------------------------------------\nQSize FloatingModeReferenceEditor::getTableSizeHint() const\n{\n    return modeReferencesEditor_->sizeHint();\n}\n\n//-----------------------------------------------------------------------------\n// Function: FloatingModeReferenceEditor::getTableMargins()\n//-----------------------------------------------------------------------------\nQMargins FloatingModeReferenceEditor::getTableMargins() const\n{\n    return layout()->contentsMargins();\n}\n\n//-----------------------------------------------------------------------------\n// Function: FloatingModeReferenceEditor::setupLayout()\n//-----------------------------------------------------------------------------\nvoid FloatingModeReferenceEditor::setupLayout()\n{\n    QVBoxLayout* topLayout = new QVBoxLayout(this);\n    topLayout->setContentsMargins(4, 4, 4, 4);\n    \n    QPushButton* okButton = new QPushButton();\n    okButton->setIcon(QIcon(\":/icons/common/graphics/checkMark.png\"));\n    okButton->setToolTip(\"Accept\");\n\n    QPushButton* cancelButton = new QPushButton();\n    cancelButton->setIcon(QIcon(\":/icons/common/graphics/grey_cross.png\"));\n    cancelButton->setToolTip(\"Cancel\");\n\n    QHBoxLayout* buttonLayout = new QHBoxLayout();\n    buttonLayout->addStretch(10);\n    buttonLayout->addWidget(okButton);\n    buttonLayout->addWidget(cancelButton);\n\n    topLayout->addWidget(modeReferencesEditor_);\n    topLayout->addLayout(buttonLayout, 0);\n\n    connect(okButton, SIGNAL(clicked()), this, SIGNAL(finishEditing()), Qt::UniqueConnection);\n    connect(cancelButton, SIGNAL(clicked()), this, SIGNAL(cancelEditing()), Qt::UniqueConnection);\n\n}\n"
  },
  {
    "path": "editors/ComponentEditor/common/FloatingModeReferenceEditor.h",
    "content": "//-----------------------------------------------------------------------------\n// File: FloatingModeReferenceEditor.h\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Anton Hagqvist\n// Date: 16.10.2023\n//\n// Description:\n// A mode reference editor for tables containing mode references.\n//-----------------------------------------------------------------------------\n\n#ifndef FLOATINGMODEREFERENCEEDITOR_H\n#define FLOATINGMODEREFERENCEEDITOR_H\n\n#include <QFrame>\n\nclass ModeReferenceInterface;\nclass ModeReferenceEditor;\n\nclass FloatingModeReferenceEditor : public QFrame\n{\n    Q_OBJECT\npublic:\n\n    /*!\n     *\tThe constructor.\n     *  \n     *    @param [in] model      The mode reference interface to use.\n     *    @param [in] parent     The parent widget.\n     */\n    FloatingModeReferenceEditor(ModeReferenceInterface* modeRefInterface, QWidget* parent);\n\n    virtual ~FloatingModeReferenceEditor() = default;\n\n    FloatingModeReferenceEditor(FloatingModeReferenceEditor& other) = delete;\n    FloatingModeReferenceEditor& operator=(FloatingModeReferenceEditor& other) = delete;\n\n    /*!\n     *\tGet the size hint of the mode reference table.\n     *  \n     *\t    \n     * \t    @return The size hint of the mode reference table.\n     */\n    QSize getTableSizeHint() const;\n\n    /*!\n     *\tGet the margins of the mode reference table.\n     *  \n     * \t    @return The margins of the mode reference table.\n     */\n    QMargins getTableMargins() const;\n\nsignals:\n\n    /*!\n     *\tSignal emitted when the user has pressed the accept button.\n     */\n    void finishEditing();\n\n    /*!\n     *\tSignal emitted when user cancels editing by pressing the cross.\n     */\n    void cancelEditing();\n\nprivate:\n\n    /*!\n     *\tSetup the layout of the editor.\n     */\n    void setupLayout();\n\n    //! The mode reference editor itself.\n    ModeReferenceEditor* modeReferencesEditor_;\n\n};\n\n#endif // FLOATINGMODEREFERENCEEDITOR_H\n"
  },
  {
    "path": "editors/ComponentEditor/common/InstantiationConfigurableElementEditor.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: InstantiationConfigurableElementEditor.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 01.09.2017\n//\n// Description:\n// Editor for configurable elements of a single category.\n//-----------------------------------------------------------------------------\n\n#include \"InstantiationConfigurableElementEditor.h\"\n\n#include <editors/common/ExpressionSet.h>\n#include <editors/common/ComponentInstanceEditor/ConfigurableElementsColumns.h>\n#include <editors/common/ComponentInstanceEditor/ConfigurableElementsFilter.h>\n\n#include <KactusAPI/include/ParameterConfigurableElementFinder.h>\n\n#include <QVBoxLayout>\n\n//-----------------------------------------------------------------------------\n// Function: InstantiationConfigurableElementEditor::InstantiationConfigurableElementEditor()\n//-----------------------------------------------------------------------------\nInstantiationConfigurableElementEditor::InstantiationConfigurableElementEditor(\n    QSharedPointer<ParameterConfigurableElementFinder> elementFinder,\n    ExpressionSet elementExpressions,\n    ExpressionSet designExpressions,\n    QAbstractItemModel* completionModel,\n    QWidget* parent):\nConfigurableElementEditor(elementExpressions, designExpressions, completionModel, parent),\nelementFinder_(elementFinder)\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: InstantiationConfigurableElementEditor::setParameters()\n//-----------------------------------------------------------------------------\nvoid InstantiationConfigurableElementEditor::setParameters(QString const& containerName,\n    QSharedPointer<QList<QSharedPointer<Parameter> > > parameters, Document::Revision docRevision,\n    QSharedPointer<QList<QSharedPointer<ConfigurableElementValue> > > storedElements)\n{\n    ConfigurableElementEditor::setParameters(containerName, parameters, \n        QSharedPointer<QList<QSharedPointer<Choice> > >(), docRevision, storedElements);\n\n    elementFinder_->setCEVList(storedElements);\n    elementFinder_->setParameterList(parameters);\n}\n"
  },
  {
    "path": "editors/ComponentEditor/common/InstantiationConfigurableElementEditor.h",
    "content": "//-----------------------------------------------------------------------------\n// File: InstantiationConfigurableElementEditor.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 01.09.2017\n//\n// Description:\n// Editor for configurable elements of a single category.\n//-----------------------------------------------------------------------------\n\n#ifndef INSTANTIATIONCONFIGURABLEELEMENTEDITOR_H\n#define INSTANTIATIONCONFIGURABLEELEMENTEDITOR_H\n\n#include <IPXACTmodels/common/Document.h>\n\n#include <editors/common/ComponentInstanceEditor/configurableelementeditor.h>\n#include <editors/common/ComponentInstanceEditor/ConfigurableElementsModel.h>\n\n#include <QAbstractItemModel>\n#include <QGroupBox>\n#include <QSharedPointer>\n#include <QCheckBox>\n\nclass ConfigurableElementFinder;\nclass ExpressionFormatter;\nclass ExpressionParser;\nclass ParameterFinder;\nclass ConfigurableElementValue;\nclass ConfigurableElementsFilter;\nclass ParameterConfigurableElementFinder;\n\n//-----------------------------------------------------------------------------\n//! Editor for configurable elements of a single category.\n//-----------------------------------------------------------------------------\nclass InstantiationConfigurableElementEditor : public ConfigurableElementEditor\n{\n    Q_OBJECT\n\npublic:\n\n\t/*!\n\t *  The constructor.\n\t *\n\t *    @param [in] elementFinder       The finder for the configurable element values.\n\t *    @param [in] parameterFinder     The finder for configurable elements and top parameters.\n\t *    @param [in] elementFormatter    Formats referencing expressions in configurable elements.\n\t *    @param [in] parameterFormatter  Formats referencing expressions in component instance.\n\t *    @param [in] elementParser       Solves expressions in configurable elements.\n\t *    @param [in] parameterParser     Solves expressions in default values (component instance).\n\t *    @param [in] completionModel     The completion model for selecting parameter references.\n\t *    @param [in] parent              The parent widget.\n\t */\n    InstantiationConfigurableElementEditor(\n        QSharedPointer<ParameterConfigurableElementFinder> elementFinder,\n        ExpressionSet elementExpressions,\n        ExpressionSet designExpressions,\n        QAbstractItemModel* completionModel, QWidget* parent);\n\n\t//! The destructor.\n    virtual ~InstantiationConfigurableElementEditor() = default;\n\n    /*!\n     *  Setup the configurable element values for the model.\n     *\n     *    @param [in] containerName     Name of the item containing the parameters.\n     *    @param [in] parameters        List of the selected parameters.\n     *    @param [in] docRevision       Version of the used IP-XACT standard.\n     *    @param [in] storedElements    List of the stored configurable element values.\n     */\n    void setParameters(QString const& containerName, QSharedPointer<QList<QSharedPointer<Parameter> > > parameters,\n        Document::Revision docRevision,\n        QSharedPointer<QList<QSharedPointer<ConfigurableElementValue> > > storedElements);\n\nprivate:\n\n    //! No copying.\tNo assignment.\n\tInstantiationConfigurableElementEditor(const InstantiationConfigurableElementEditor& other);\n\tInstantiationConfigurableElementEditor& operator=(const InstantiationConfigurableElementEditor& other);\n\n\n    //! The used configurable element finder.\n\tQSharedPointer<ParameterConfigurableElementFinder> elementFinder_;\n\n    //! Version of the used IP-XACT standard.\n    Document::Revision docRevision_;\n\n};\n\n#endif // INSTANTIATIONCONFIGURABLEELEMENTEDITOR_H\n"
  },
  {
    "path": "editors/ComponentEditor/common/MasterExpressionEditor.cpp",
    "content": "//---------\n// --------------------------------------------------------------------\n// File: MasterExpressionEditor.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 02.11.2022\n//\n// Description:\n// Parent class for expression editors with parameter name completion.\n//-----------------------------------------------------------------------------\n\n#include \"MasterExpressionEditor.h\"\n\n#include <QAbstractItemView>\n#include <QCompleter>\n#include <QKeyEvent>\n\n#include <KactusAPI/include/ParameterFinder.h>\n#include <KactusAPI/include/SystemVerilogSyntax.h>\n\n#include <editors/ComponentEditor/parameters/ComponentParameterModel.h>\n#include <editors/ComponentEditor/parameters/ComponentParameterColumns.h>\n\n//-----------------------------------------------------------------------------\n// Function: ExpressionLineEditor::ExpressionLineEditor()\n//-----------------------------------------------------------------------------\nMasterExpressionEditor::MasterExpressionEditor(QSharedPointer<ParameterFinder> parameterFinder, QWidget* parentWidget):\nnameCompleter_(new QCompleter(parentWidget)),\nparameterFinder_(parameterFinder)\n{\n    nameCompleter_->setWidget(parentWidget);\n}\n\n//-----------------------------------------------------------------------------\n// Function: MasterExpressionEditor::setAppendingCompleter()\n//-----------------------------------------------------------------------------\nvoid MasterExpressionEditor::setAppendingCompleter(QCompleter* completer)\n{\n    nameCompleter_ = completer;\n}\n\n//-----------------------------------------------------------------------------\n// Function: MasterExpressionEditor::completer()\n//-----------------------------------------------------------------------------\nQCompleter* MasterExpressionEditor::completer() const\n{\n    return nameCompleter_;\n}\n\n//-----------------------------------------------------------------------------\n// Function: MasterExpressionEditor::getExpression()\n//-----------------------------------------------------------------------------\nQString MasterExpressionEditor::getExpression() const\n{\n    return expression_;\n}\n\n//-----------------------------------------------------------------------------\n// Function: MasterExpressionEditor::setExpression()\n//-----------------------------------------------------------------------------\nvoid MasterExpressionEditor::setExpression(QString const& expression)\n{\n    auto parameterModel = dynamic_cast<ComponentParameterModel*>(nameCompleter_->model());\n    if (parameterModel)\n    {\n        parameterModel->resetParameterModel();\n    }\n\n    expression_ = expression;\n}\n\n//-----------------------------------------------------------------------------\n// Function: MasterExpressionEditor::finishEditingCurrentWord()\n//-----------------------------------------------------------------------------\nvoid MasterExpressionEditor::finishEditingCurrentWord()\n{\n    QString finishedWord = currentWord();\n    QString currentTerm = nthWordIn(currentWordIndex(), expression_);\n\n    bool termIsReference = isReference(currentTerm);\n    bool shouldChangeTerm = !termIsReference || parameterFinder_->nameForId(currentTerm) != finishedWord;\n\n    if (shouldChangeTerm)\n    {\n        expression_ = replaceNthWordWith(currentWordIndex(), expression_, finishedWord);\n\n        if (currentWordIsUniqueParameterName())\n        {\n            complete(nameCompleter_->currentIndex());\n        }\n        else if (reservedWords_.contains(finishedWord, Qt::CaseInsensitive))\n        {\n            colorCurrentWordBlack();\n        }\n        else if (!finishedWord.isEmpty() && !wordIsConstant(finishedWord) && !wordIsMathFunction(finishedWord))\n        {\n            colorCurrentWordRed();\n        }\n\n        if (termIsReference)\n        {\n            handleReferenceDecrease(currentTerm);\n        }\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: MasterExpressionEditor::handleKeyPressEvent()\n//-----------------------------------------------------------------------------\nvoid MasterExpressionEditor::handleKeyPressEvent(QKeyEvent* keyEvent)\n{\n    if (keysequenceCopyCutPaste(keyEvent))\n    {\n        keyEvent->accept();\n        return;\n    }\n\n    if (keyMovesCursor(keyEvent))\n    {\n        finishEditingCurrentWord();\n    }\n\n    else if (removesOrReplacesText(keyEvent))\n    {\n        if (hasSelection())\n        {\n            replaceSelectionInExpression(keyEvent);\n        }\n        else if (removesOperatorBeforeWord(keyEvent))\n        {\n            removeOperatorBeforeCursorInExpression();\n        }\n        else if (removesOperatorAfterCursor(keyEvent))\n        {\n            removeOperatorAfterCursorInExpression();\n        }\n        if (removesLastCharacterOfWord(keyEvent))\n        {\n            removeTermUnderCursor();\n        }\n    }\n    else if (isWordDelimiter(keyEvent->text()))\n    {\n        finishEditingCurrentWord();\n        finishEditingCurrentTerm(keyEvent->text());\n    }\n\n    if (!showCompletionsRequested(keyEvent))\n    {\n        handleParentKeyPressEvent(keyEvent);\n    }\n\n    if (!currentWord().isEmpty() || showCompletionsRequested(keyEvent))\n    {\n        nameCompleter_->setCompletionPrefix(currentWord());\n        nameCompleter_->complete();\n    }\n    else\n    {\n        nameCompleter_->popup()->hide();\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: MasterExpressionEditor::complete()\n//-----------------------------------------------------------------------------\nvoid MasterExpressionEditor::complete(QModelIndex const& index)\n{\n    int selectedRow = index.row();\n\n    auto const nameIndex = nameCompleter_->completionModel()->index(selectedRow, ComponentParameterColumns::NAME);\n    auto const parameterName = nameIndex.data().toString();\n\n    auto const idIndex = nameIndex.siblingAtColumn(ComponentParameterColumns::ID);\n    auto parameterId = idIndex.data().toString();\n   \n    if (parameterId.isEmpty())\n    {\n        parameterId = parameterName;\n    }\n\n    if (auto previousTerm = nthWordIn(currentWordIndex(), expression_); \n        isReference(previousTerm))\n    {\n        handleReferenceDecrease(previousTerm);\n    }\n\n    expression_ = replaceNthWordWith(currentWordIndex(), expression_, parameterId);\n\n    setCompletedParameterName(parameterName);\n\n    nameCompleter_->popup()->hide();\n\n    handleReferenceIncrease(parameterId);\n}\n\n//-----------------------------------------------------------------------------\n// Function: MasterExpressionEditor::updateCompleteWords()\n//-----------------------------------------------------------------------------\nvoid MasterExpressionEditor::updateCompleteWords()\n{\n    if (notSelectingText_)\n    {\n        nameCompleter_->setCompletionPrefix(currentWord());\n\n        if (!currentWord().isEmpty())\n        {\n            nameCompleter_->complete();\n        }\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: MasterExpressionEditor::isReference()\n//-----------------------------------------------------------------------------\nbool MasterExpressionEditor::isReference(QString const& text) const\n{\n    if (parameterFinder_.isNull())\n    {\n        return false;\n    }\n\n    return parameterFinder_->hasId(text);\n}\n\n//-----------------------------------------------------------------------------\n// Function: MasterExpressionEditor::wordIsConstant()\n//-----------------------------------------------------------------------------\nbool MasterExpressionEditor::wordIsConstant(QString const& word) \n{\n    static QRegularExpression constant(\"^\" + SystemVerilogSyntax::INTEGRAL_NUMBER + \"|\" +\n        SystemVerilogSyntax::STRING_LITERAL + \"$\");\n    return constant.match(word).hasMatch();\n}\n\n//-----------------------------------------------------------------------------\n// Function: MasterExpressionEditor::wordIsMathFunction()\n//-----------------------------------------------------------------------------\nbool MasterExpressionEditor::wordIsMathFunction(QString const& word)\n{\n    static const QRegularExpression mathOperator(\"^\" + SystemVerilogSyntax::MATH_FUNCTION + \"$\");\n    return mathOperator.match(word).hasMatch();\n}\n\n//-----------------------------------------------------------------------------\n// Function: MasterExpressionEditor::colorFormat()\n//-----------------------------------------------------------------------------\nQTextCharFormat MasterExpressionEditor::colorFormat(Qt::GlobalColor textColor) const\n{\n    QTextCharFormat format;\n    format.setForeground(textColor);\n    return format;\n}\n\n//-----------------------------------------------------------------------------\n// Function: MasterExpressionEditor::editingMiddleOfReference()\n//-----------------------------------------------------------------------------\nbool MasterExpressionEditor::editingMiddleOfReference() const\n{\n    int newCursorPosition = getCursorPosition();\n\n    return isReference(nthWordIn( currentWordIndex(), expression_)) && \n        newCursorPosition != startOfCurrentWord() &&\n        newCursorPosition != endOfCurrentWord();\n}\n\n//-----------------------------------------------------------------------------\n// Function: MasterExpressionEditor::removesLastCharacterOfWord()\n//-----------------------------------------------------------------------------\nbool MasterExpressionEditor::removesLastCharacterOfWord(QKeyEvent* keyEvent) const\n{\n    int newCursorPosition = getCursorPosition();\n\n    return ((keyEvent->key() == Qt::Key_Delete && newCursorPosition == startOfCurrentWord()) ||\n        (keyEvent->key() == Qt::Key_Backspace && newCursorPosition == endOfCurrentWord())) &&\n        currentWordLength() == 1;\n}\n\n//-----------------------------------------------------------------------------\n// Function: MasterExpressionEditor::removeTermUnderCursor()\n//-----------------------------------------------------------------------------\nvoid MasterExpressionEditor::removeTermUnderCursor()\n{\n    auto const removedReference = nthWordIn(currentWordIndex(), expression_);\n    expression_ = replaceNthWordWith(currentWordIndex(), expression_, \"\");\n\n    if (isReference(removedReference))\n    {\n        handleReferenceDecrease(removedReference);\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: MasterExpressionEditor::removesOperatorBeforeWord()\n//-----------------------------------------------------------------------------\nbool MasterExpressionEditor::removesOperatorBeforeWord(QKeyEvent* keyEvent) const\n{\n    return keyEvent->key() == Qt::Key_Backspace && getCursorPosition() == startOfCurrentWord();\n}\n\n//-----------------------------------------------------------------------------\n// Function: MasterExpressionEditor::removeOperatorBeforeCursorInExpression()\n//-----------------------------------------------------------------------------\nvoid MasterExpressionEditor::removeOperatorBeforeCursorInExpression()\n{\n    int position = indexOfNthWord(currentWordIndex(), expression_);\n    expression_.remove(position - 1, 1);\n}\n\n//-----------------------------------------------------------------------------\n// Function: MasterExpressionEditor::removesOperatorAfterCursor()\n//-----------------------------------------------------------------------------\nbool MasterExpressionEditor::removesOperatorAfterCursor(QKeyEvent* keyEvent) const\n{\n    return keyEvent->key() == Qt::Key_Delete && getCursorPosition() == endOfCurrentWord();\n}\n\n//-----------------------------------------------------------------------------\n// Function: MasterExpressionEditor::removeOperatorAfterCursorInExpression()\n//-----------------------------------------------------------------------------\nvoid MasterExpressionEditor::removeOperatorAfterCursorInExpression()\n{\n    int position = indexOfNthWord(currentWordIndex() + 1, expression_);\n    expression_.remove(position - 1, 1);\n}\n\n//-----------------------------------------------------------------------------\n// Function: MasterExpressionEditor::currentWord()\n//-----------------------------------------------------------------------------\nQString MasterExpressionEditor::currentWord() const\n{\n    return getCurrentText().mid(startOfCurrentWord(), currentWordLength());\n}\n\n//-----------------------------------------------------------------------------\n// Function: MasterExpressionEditor::startOfCurrentWord()\n//-----------------------------------------------------------------------------\nint MasterExpressionEditor::startOfCurrentWord() const\n{\n    auto plainText = getCurrentText();\n    auto leftSide = plainText.left(getCursorPosition());\n\n    int operandIndex = leftSide.lastIndexOf(WORD_DELIMITER);\n\n    int operatorSize = 1;\n\n    if (0 < operandIndex && operandIndex < leftSide.size())\n    {\n        operatorSize = WORD_DELIMITER.match(leftSide, operandIndex).capturedLength();\n    }\n\n    return operandIndex + operatorSize;\n}\n\n//-----------------------------------------------------------------------------\n// Function: MasterExpressionEditor::endOfCurrentWord()\n//-----------------------------------------------------------------------------\nint MasterExpressionEditor::endOfCurrentWord() const\n{\n    int endPos = getCurrentText().indexOf(WORD_DELIMITER, getCursorPosition());\n\n    if (endPos == -1)\n    {\n        endPos = getCurrentText().length();\n    }\n\n    return endPos;\n}\n\n//-----------------------------------------------------------------------------\n// Function: MasterExpressionEditor::currentWordLength()\n//-----------------------------------------------------------------------------\nint MasterExpressionEditor::currentWordLength() const\n{\n    return endOfCurrentWord() - startOfCurrentWord();\n}\n\n//-----------------------------------------------------------------------------\n// Function: MasterExpressionEditor::currentWordIndex()\n//-----------------------------------------------------------------------------\nint MasterExpressionEditor::currentWordIndex() const\n{\n    return getCurrentText().left(getCursorPosition()).count(WORD_DELIMITER);\n}\n\n//-----------------------------------------------------------------------------\n// Function: MasterExpressionEditor::replaceNthWordWith()\n//-----------------------------------------------------------------------------\nQString MasterExpressionEditor::replaceNthWordWith(int n, QString const& oldText, QString const& after) const\n{\n    QString replaced = oldText;\n    replaced.replace(indexOfNthWord(n, oldText), nthWordIn(n, oldText).length(), after);\n    return replaced;\n}\n\n//-----------------------------------------------------------------------------\n// Function: MasterExpressionEditor::nthWordIn()\n//-----------------------------------------------------------------------------\nQString MasterExpressionEditor::nthWordIn(int n, QString const& text) const\n{\n    int startIndex = indexOfNthWord(n, text);\n\n    int endIndex = text.indexOf(WORD_DELIMITER, startIndex);\n    if (endIndex == -1)\n    {\n        endIndex = text.length();\n    }\n\n    int wordLength = endIndex - startIndex;\n    return text.mid(startIndex, wordLength);\n}\n\n//-----------------------------------------------------------------------------\n// Function: MasterExpressionEditor::indexOfNthWord()\n//-----------------------------------------------------------------------------\nint MasterExpressionEditor::indexOfNthWord(int n, QString const& text) const\n{\n    int startIndex = 0;\n    for (int i = 0; i < n; i++)\n    {\n        startIndex = text.indexOf(WORD_DELIMITER, startIndex) + 1;\n    }\n\n    return startIndex;\n}\n\n//-----------------------------------------------------------------------------\n// Function: MasterExpressionEditor::currentWordIsUniqueParameterName()\n//-----------------------------------------------------------------------------\nbool MasterExpressionEditor::currentWordIsUniqueParameterName() const\n{\n    return nameCompleter_->completionCount() == 1 && currentWord() == nameCompleter_->currentCompletion();\n}\n\n//-----------------------------------------------------------------------------\n// Function: MasterExpressionEditor::isWordDelimiter()\n//-----------------------------------------------------------------------------\nbool MasterExpressionEditor::isWordDelimiter(QString const& text) const\n{\n    return WORD_DELIMITER.match(text).hasMatch();\n}\n\n//-----------------------------------------------------------------------------\n// Function: ExpressionMasterEditor::handleMouseMoveEvent()\n//-----------------------------------------------------------------------------\nvoid MasterExpressionEditor::handleMouseMoveEvent(QMouseEvent* mouseEvent)\n{\n    notSelectingText_ = !(mouseEvent->buttons() & Qt::LeftButton);\n}\n\n//-----------------------------------------------------------------------------\n// Function: MasterExpressionEditor::handleMouseReleaseEvent()\n//-----------------------------------------------------------------------------\nvoid MasterExpressionEditor::handleMouseReleaseEvent()\n{\n    notSelectingText_ = true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: MasterExpressionEditor::removesOrReplacesText()\n//-----------------------------------------------------------------------------\nbool MasterExpressionEditor::removesOrReplacesText(QKeyEvent* keyEvent)\n{\n    return keyEvent->key() == Qt::Key_Delete || keyEvent->key() == Qt::Key_Backspace ||\n        (hasSelection() && !keyEvent->text().isEmpty());\n}\n\n//-----------------------------------------------------------------------------\n// Function: MasterExpressionEditor::keysequenceCopyCutPaste()\n//-----------------------------------------------------------------------------\nbool MasterExpressionEditor::keysequenceCopyCutPaste(QKeyEvent* keyEvent) const\n{\n    return keyEvent == QKeySequence::Copy || keyEvent == QKeySequence::Cut || keyEvent == QKeySequence::Paste;\n}\n\n//-----------------------------------------------------------------------------\n// Function: MasterExpressionEditor::movesCursor()\n//-----------------------------------------------------------------------------\nbool MasterExpressionEditor::keyMovesCursor(QKeyEvent* keyEvent) const\n{\n    return keyEvent->key() == Qt::Key_Home || keyEvent->key() == Qt::Key_End || keyEvent->key() == Qt::Key_Left ||\n        keyEvent->key() == Qt::Key_Right;\n}\n\n//-----------------------------------------------------------------------------\n// Function: ExpressionLineEditor::removeSelectionInExpression()\n//-----------------------------------------------------------------------------\nvoid MasterExpressionEditor::replaceSelectionInExpression(QKeyEvent* keyEvent)\n{\n    QString selectedText = getSelectedText();\n\n    int firstWord = getSelectionFirstWord();\n    int lastWord = getSelectionLastWord();\n\n    replaceReferencesInExpressionWithNames(firstWord, lastWord);\n\n    int firstTermPos = indexOfNthWord(firstWord, expression_);\n    expression_.remove(expression_.indexOf(selectedText, firstTermPos), selectedText.length());\n    expression_.insert(getSelectionStartIndex(), keyEvent->text()); // Don't just remove selection, also insert whatever was typed.\n}\n\n//-----------------------------------------------------------------------------\n// Function: MasterExpressionEditor::replaceReferencesInExpressionWithNames()\n//-----------------------------------------------------------------------------\nvoid MasterExpressionEditor::replaceReferencesInExpressionWithNames(int firstWord, int lastWord)\n{\n    for (int i = firstWord; i <= lastWord; i++)\n    {\n        QString term = nthWordIn(i, expression_);\n        if (isReference(term))\n        {\n            handleReferenceDecrease(term);\n\n            expression_ = replaceNthWordWith(i, expression_, nthWordIn(i, getCurrentText()));\n        }\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: MasterExpressionEditor::finishEditingCurrentTerm()\n//-----------------------------------------------------------------------------\nvoid MasterExpressionEditor::finishEditingCurrentTerm(QString const& delimiter)\n{\n    QString term = nthWordIn(currentWordIndex(), expression_);\n    QString termAndDelimiter = term;\n    if (getCursorPosition() == startOfCurrentWord())\n    {\n        termAndDelimiter.prepend(delimiter);\n    }\n    else if (getCursorPosition() == endOfCurrentWord())\n    {\n        termAndDelimiter.append(delimiter);\n    }\n    else\n    {\n        if (isReference(term))\n        {\n            handleReferenceDecrease(term);\n\n            termAndDelimiter = nthWordIn(currentWordIndex(), getCurrentText());\n        }\n        termAndDelimiter.insert(getCursorPosition() - startOfCurrentWord(), delimiter);\n    }\n\n    expression_ = replaceNthWordWith(currentWordIndex(), expression_, termAndDelimiter);\n}\n\n//-----------------------------------------------------------------------------\n// Function: MasterExpressionEditor::showCompletionsReguested()\n//-----------------------------------------------------------------------------\nbool MasterExpressionEditor::showCompletionsRequested(QKeyEvent* keyEvent) const\n{\n    return keyEvent->key() == Qt::Key_Space && (keyEvent->modifiers() & Qt::ControlModifier);\n}\n\n//-----------------------------------------------------------------------------\n// Function: MasterExpressionEditor::setReservedWords()\n//-----------------------------------------------------------------------------\nvoid MasterExpressionEditor::setReservedWords(QStringList newReservations)\n{\n    reservedWords_ = newReservations;\n}\n\n//-----------------------------------------------------------------------------\n// Function: MasterExpressionEditor::getNameForParameterID()\n//-----------------------------------------------------------------------------\nQString MasterExpressionEditor::getNameForParameterID(QString const& parameterID) const\n{\n    return parameterFinder_->nameForId(parameterID);\n}\n\n//-----------------------------------------------------------------------------\n// Function: MasterExpressionEditor::getReservedWords()\n//-----------------------------------------------------------------------------\nQStringList MasterExpressionEditor::getReservedWords() const\n{\n    return reservedWords_;\n}\n"
  },
  {
    "path": "editors/ComponentEditor/common/MasterExpressionEditor.h",
    "content": "//-----------------------------------------------------------------------------\n// File: MasterExpressionEditor.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 02.11.2022\n//\n// Description:\n// Parent class for expression editors with parameter name completion.\n//-----------------------------------------------------------------------------\n\n#ifndef MASTEREXPRESSIONEDITOR_H\n#define MASTEREXPRESSIONEDITOR_H\n\n#include <QCompleter>\n#include <QWidget>\n#include <QKeyEvent>\n#include <QFocusEvent>\n#include <QTextCursor>\n#include <QRegularExpression>\n\nclass ParameterFinder;\n\n//-----------------------------------------------------------------------------\n//! Parent class for expression editors with parameter name completion.\n//-----------------------------------------------------------------------------\nclass MasterExpressionEditor\n{\n\npublic:\n\n\t/*!\n     *  The constructor.\n     */\n    MasterExpressionEditor(QSharedPointer<ParameterFinder> parameterFinder, QWidget* parentWidget);\n\n\t/*!\n     *  The destructor.\n     */\n\tvirtual ~MasterExpressionEditor() = default;\n\n    // Disable copying.\n    MasterExpressionEditor(MasterExpressionEditor const& rhs) = delete;\n    MasterExpressionEditor& operator=(MasterExpressionEditor const& rhs) = delete;\n\n    /*!\n     *  Sets a completer whose selection will be appended to the text.\n     *\n     *    @param [in] completer   The completer to set.\n     */\n    virtual void setAppendingCompleter(QCompleter* completer);\n\n    /*!\n     *  Gets the completer for the widget.\n     *\n     *    @return The completer of the widget.\n     */\n    QCompleter* completer() const;\n\n    /*!\n     *  Gets the underlying expression in the editor.\n     *\n     *    @return The expression in the editor.\n     */\n    QString getExpression() const;\n    \n    /*!\n     *  Sets the expression in the editor.\n     *\n     *    @param [in] expression   The expression to set.\n     */\n    virtual void setExpression(QString const& expression);\n\n    /*!\n     *  Ends the editing of current word and commits it to the expression.\n     */\n    void finishEditingCurrentWord();\n\n    /*!\n     *  Set the reserved words.\n     *\n     *    @param [in] newReservations     A list of the new reserved words.\n     */\n    void setReservedWords(QStringList newReservations);\n\nprotected:\n\n\n    /*!\n     *  Captures the user input and edits the underlying expression accordingly.\n     *\n     *    @param [in] keyEvent   The event representing the user input.\n     */\n    void handleKeyPressEvent(QKeyEvent* keyEvent);\n\n    /*!\n     *  Captures the mouse move and sets/clears notSelectingText flag according to mouse press.\n     *\n     *    @param [in] mouseEvent   The mouse event representing the mouse movement and button press.\n     */\n    void handleMouseMoveEvent(QMouseEvent* mouseEvent);\n\n    /*!\n     *  Clears notSelectingText flag when the mouse button is released.\n     *\n     *    @param [in] mouseEvent   The event representing the mouse button release.\n     */\n    void handleMouseReleaseEvent();\n\n    /*!\n     *  Emits a signal informing of the ending of editing the expression.\n     *\n     *    @param [in] event   The event representing the changing of focus.\n     */\n    void updateCompleteWords();\n\n    /*!\n     *  Called when a word completion has been selected. Replaces the word under the cursor with the selection.\n     *\n     *    @param [in] word   The selected word.\n     */\n    void complete(QModelIndex const& index);\n\n    /*!\n     *  Gives a format for a given text color.\n     *\n     *    @param [in] textColor   The name of the color in the format.\n     *\n     *    @return The format for the given color.\n     */\n    QTextCharFormat colorFormat(Qt::GlobalColor textColor) const;\n\n    /*!\n     *  Replaces a word in a given index with another.\n     *\n     *    @param [in] n           The index of the word to replace i.e 1 for second word in a sentence.\n     *    @param [in] oldText     The text to replace the word in.\n     *    @param [in] after       The word used to replace the old word.\n     *\n     *    @return A text where the nth word has been replaced.\n     */\n    QString replaceNthWordWith(int n, QString const& oldText, QString const& after) const;\n\n    /*!\n     *  Gives the index of the word currently under the cursor.\n     *\n     *    @return The index of the word.\n     */\n    int currentWordIndex() const;\n\n    /*!\n     *  Checks if a given text is a reference to a parameter.\n     *\n     *    @param [in] text   The text to check.\n     *\n     *    @return True, if the text is a reference, otherwise false.\n     */\n    bool isReference(QString const& text) const;\n\n    /*!\n     *  Find the name for the parameter with the selected ID.\n     *\n     *    @param [in] parameterID     The selected parameter ID.\n     *\n     *    @return Name of the selected parameter.\n     */\n    QString getNameForParameterID(QString const& parameterID) const;\n\n    /*!\n     *  Get the list of reserved words.\n     *\n     *    @return The list of reserved words.\n     */\n    QStringList getReservedWords() const;\n\n    /*!\n     *  Checks if a given word is a constant value.\n     *\n     *    @param [in] word   The word to check.\n     *\n     *    @return True, if the word is a constant, otherwise false.\n     */\n    static bool wordIsConstant(QString const& word);\n\n    /*!\n     *\tChecks if a given word is a math function.\n     *  \n     *    @param [in] word     The word to check.\n     *\t    \n     * \t    @return True, if the word is a math function, otherwise false.\n     */\n    bool wordIsMathFunction(QString const& word);\n\n    /*!\n     *  Finds the index for the start of the current word.\n     *\n     *    @return The index for the start of the current word.\n     */\n    int startOfCurrentWord() const;\n\n    inline static const QRegularExpression WORD_DELIMITER =\n        QRegularExpression(QStringLiteral(\"[-+/*() ,{}~^]|[<>]=?|[!=]=?|[|&]{1,2}\"));\n\nprivate:\n\n\n    /*!\n     *  Check if a selection exists.\n     *\n     *    @return True, if a selection exists, false otherwise.\n     */\n    virtual bool hasSelection() = 0;\n\n    /*!\n     *  Let the parent widget handle the key press event.\n     *\n     *    @param [in] keyEvent    The selected key press event.\n     */\n    virtual void handleParentKeyPressEvent(QKeyEvent* keyEvent) = 0;\n\n    /*!\n     *  Decrease references made to the selected ID.\n     *\n     *    @param [in] referenceItem   ID of the selected item.\n     */\n    virtual void handleReferenceDecrease(QString const& referenceItem) = 0;\n    \n    /*!\n     *  Increase references made to the selected ID.\n     *\n     *    @param [in] referenceItem   ID of the selected item.\n     */\n    virtual void handleReferenceIncrease(QString const& referenceItem) = 0;\n\n    /*!\n     *  Set the completed parameter name for the editor.\n     *\n     *    @param [in] parameterName   The completed parameter name.\n     */\n    virtual void setCompletedParameterName(QString const& parameterName) = 0;\n\n    /*!\n     *  Get the current cursor position.\n     *\n     *    @return The position of the cursor.\n     */\n    virtual int getCursorPosition() const = 0;\n\n    /*!\n     *  Get the current text of the editor.\n     *\n     *    @return The current text.\n     */\n    virtual QString getCurrentText() const = 0;\n\n    /*!\n     *  Get the selected text.\n     *\n     *    @return The selected text.\n     */\n    virtual QString getSelectedText() const = 0;\n\n    /*!\n     *  Count the length of the first word in the current selection.\n     *\n     *    @return Length of the first word in the selection.\n     */\n    virtual int getSelectionFirstWord() const = 0;\n\n    /*!\n     *  Count the length of the last word in the current selection.\n     *\n     *    @return Length of the last word in the selection.\n     */\n    virtual int getSelectionLastWord() const = 0;\n\n    /*!\n     *\tGet the start index of the selection.\n     *\n     * \t    @return The start index of the current selection.\n     */\n    virtual int getSelectionStartIndex() const = 0;\n\n    /*!\n     *  Checks if the editing would change text in the middle of a referencing term.\n     *\n     *    @return True, if the edit position is in the middle of a referencing term, otherwise false.\n     */\n    bool editingMiddleOfReference() const;\n\n    /*!\n     *  Checks if the given key event will remove the last character in a word.\n     *\n     *    @param [in] keyEvent   The key event to check.\n     *\n     *    @return True, if the event will remove the last character, otherwise false.\n     */\n    bool removesLastCharacterOfWord(QKeyEvent* keyEvent) const;\n    \n    /*!\n     *  Removes the term currently under cursor.\n     */\n    void removeTermUnderCursor();\n    \n    /*!\n     *  Checks if the given key event will remove an operator before the cursor.\n     *\n     *    @param [in] keyEvent   The key event to check.\n     *\n     *    @return True, if the event will remove an operator, otherwise false.\n     */\n    bool removesOperatorBeforeWord(QKeyEvent* keyEvent) const;\n\n    /*!\n     *  Removes an operator in the expression in front of the cursor.\n     */\n    void removeOperatorBeforeCursorInExpression();\n        \n    /*!\n     *  Checks if the given key event will remove an operator after the cursor.\n     *\n     *    @param [in] keyEvent   The key event to check.\n     *\n     *    @return True, if the event will remove an operator, otherwise false.\n     */\n    bool removesOperatorAfterCursor(QKeyEvent* keyEvent) const;\n        \n    /*!\n     *  Removes an operator in the expression after the cursor.\n     */\n    void removeOperatorAfterCursorInExpression();\n\n    /*!\n     *  Finds the word currently under cursor.\n     *\n     *    @return The word under cursor.\n     */\n    QString currentWord() const;\n    \n    /*!\n     *  Finds the index for the end of the current word.\n     *\n     *    @return The index for the end of the current word.\n     */\n    int endOfCurrentWord() const;\n\n    /*!\n     *  Finds the length of the current word.\n     *\n     *    @return The length of the current word.\n     */\n    int currentWordLength() const;\n\n    /*!\n     *  Finds the nth word in a text.\n     *\n     *    @param [in] n       The word index to find.\n     *    @param [in] text    The text to search in.\n     *\n     *    @return The nth word in a text.\n     */\n    QString nthWordIn(int n, QString const& text) const;\n\n    /*!\n     *  Finds the character index of the beginning of nth word in a text.\n     *\n     *    @param [in] n       The word to search.\n     *    @param [in] text    The text to search the word in.\n     *\n     *    @return The index at the beginning of the nth word.\n     */\n    int indexOfNthWord(int n, QString const& text) const;\n\n    /*!\n     * Checks if the current word is unambiguous name of a parameter.\n     *\n     *    @return True, if the word is unambiguous parameter name, otherwise false.\n     */\n    bool currentWordIsUniqueParameterName() const;\n\n    /*!\n     *  Changes the color of the font for the current word to red.\n     */\n    virtual void colorCurrentWordRed() = 0;\n\n    /*!\n     *  Changes the color of the font for the current word to black.\n     */\n    virtual void colorCurrentWordBlack() = 0;\n\n    /*!\n     *  Checks if the given text is a word delimiter.\n     *\n     *    @param [in] text   The text to check.\n     *\n     *    @return True, if the text is a word delimiter, otherwise false.\n     */\n    bool isWordDelimiter(QString const& text) const; \n\n    /*!\n     *  Checks if the given key event will remove or replace text.\n     *\n     *    @param [in] keyEvent   The event to check.\n     *\n     *    @return True, if the event will remove or replace text, otherwise false.\n     */\n    bool removesOrReplacesText(QKeyEvent* keyEvent);\n\n    /*!\n     *  Checks if the given event will copy, cut or paste text.\n     *\n     *    @param [in] keyEvent    The event to check.\n     *\n     *    @return True, if the event will copy, cut or paste text, otherwise false.\n     */\n    bool keysequenceCopyCutPaste(QKeyEvent* keyEvent) const;\n\n    /*!\n     *  Checks if the given event will move the cursor.\n     *\n     *    @param [in] keyEvent    The event to check.\n     *\n     *    @return True, if the event will move the cursor, otherwise false.\n     */\n    bool keyMovesCursor(QKeyEvent* keyEvent) const;\n\n    /*!\n     *  Replaces the current selection in the underlying expression with whatever was typed.\n     *      \n     *    @param [in] keyEvent    The event to check.\n     */\n    void replaceSelectionInExpression(QKeyEvent* keyEvent);\n\n    /*!\n     *  Replaces the references in the underlying expression with the referenced names.\n     *\n     *    @param [in] firstWord   The sequence number of the first word to replace.\n     *    @param [in] lastWord    The sequence number of the last word to replace.\n     */\n    void replaceReferencesInExpressionWithNames(int firstWord, int lastWord);\n\n    /*!\n     *  Ends the editing of current term in the underlying expression with the given word delimiter.\n     *\n     *    @param [in] delimiter   The word delimiter ending the term edit.\n     */\n    virtual void finishEditingCurrentTerm(QString const& delimiter);\n    \n    /*!\n     *  Checks if the given key event represents shortcut for showing all available completions.\n     *\n     *    @param [in] keyEvent   The key event to check.\n     *\n     *    @return True, if the key event requests showing completions, otherwise false.\n     */\n    bool showCompletionsRequested(QKeyEvent* keyEvent) const;\n\n    //-----------------------------------------------------------------------------\n    // Data.\n    //-----------------------------------------------------------------------------\n\n\n    //! The completer whose selection is used in the text.\n    QCompleter* nameCompleter_;\n\n    //! Resolver for parameter names.\n    QSharedPointer<ParameterFinder> parameterFinder_;\n\n    //! The underlying expression for the editor.\n    QString expression_;\n    \n    //! Flag for indicating that the user is not selecting text with the mouse.\n    bool notSelectingText_ = true;\n\n    //! The list of the reserved words for this editor.\n    QStringList reservedWords_{ \"true\" , \"false\" };\n\n};\n\n#endif // MASTEREXPRESSIONEDITOR_H"
  },
  {
    "path": "editors/ComponentEditor/common/MemoryAlignScene.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: MemoryAlignScene.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Antti Kamppi\n// Date: 22.12.2012\n//\n// Description:\n// Base class for scenes visualizing address spaces or CPU regions.\n//-----------------------------------------------------------------------------\n\n#include \"MemoryAlignScene.h\"\n#include <editors/ComponentEditor/addressSpaces/addressSpaceVisualizer/segmentgraphitem.h>\n#include <editors/ComponentEditor/addressSpaces/addressSpaceVisualizer/addressspacevisualizationitem.h>\n#include <editors/ComponentEditor/addressSpaces/addressSpaceVisualizer/addressspacegapitem.h>\n#include <editors/ComponentEditor/addressSpaces/addressSpaceVisualizer/localaddrblockgraphitem.h>\n#include <editors/ComponentEditor/addressSpaces/addressSpaceVisualizer/AddressSpaceConflictedItem.h>\n\n#include <KactusAPI/include/ExpressionParser.h>\n\n#include <IPXACTmodels/Component/AddressSpace.h>\n#include <IPXACTmodels/Component/MemoryMapBase.h>\n#include <IPXACTmodels/Component/MemoryBlockBase.h>\n#include <IPXACTmodels/Component/AddressBlock.h>\n\n#include <common/graphicsItems/visualizeritem.h>\n\n//-----------------------------------------------------------------------------\n// Function: MemoryAlignScene()\n//-----------------------------------------------------------------------------\nMemoryAlignScene::MemoryAlignScene(QSharedPointer<ExpressionParser> expressionParser, QObject *parent):\nQGraphicsScene(parent),\nexpressionParser_(expressionParser)\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: refresh()\n//-----------------------------------------------------------------------------\nvoid MemoryAlignScene::refresh() \n{\n\t// remove previous items\n    clear();\n\n    segmentItems_.clear();\n    exceedingSegments_.clear();\n    createRegionItems();\n\n    addrBlockItems_.clear();\n    exceedingAddrBlocks_.clear();\n    createAddressBlockItems();\n\n\trePosition();\n}\n\n//-----------------------------------------------------------------------------\n// Function: rePosition()\n//-----------------------------------------------------------------------------\nvoid MemoryAlignScene::rePosition() \n{\n    updateMaps(segmentItems_, exceedingSegments_, VisualizerItem::LABELS_RIGHT);\n    updateMaps(addrBlockItems_, exceedingAddrBlocks_, VisualizerItem::LABELS_LEFT);\n\n\t// remember which segment and address block are being operated on\n\tauto segIterator = segmentItems_.begin();\n\tauto blockIterator = addrBlockItems_.begin();\n\t\n\t// the previous segment and address block\n\tAddressSpaceVisualizationItem* prevSeg = nullptr;\n\tAddressSpaceVisualizationItem* prevBlock = nullptr;\n\n    // Y-coordinates for items.\n\tqreal segCoord = 0;\n\tqreal blockCoord = 0;\n\n\t// as long as there are both address blocks and segments left\n\twhile ((segIterator != segmentItems_.end()) && (blockIterator != addrBlockItems_.end()))\n    {\n\t\tAddressSpaceVisualizationItem* seg = segIterator.value();\n\t\tAddressSpaceVisualizationItem* block = blockIterator.value();\n\n        // if segment is overlapped by others, it need not be positioned.\n        if (seg->isCompletelyOverlapped())\n        {\n            ++segIterator;\n            continue;\n        }\n        // if address block is overlapped by others, it need not be positioned.\n        if (block->isCompletelyOverlapped())\n        {          \n            ++blockIterator;\n            continue;\n        }\n\n\t\t// if both have the same starting address\n\t\tif (seg->getOverlappingTop() == block->getOverlappingTop())\n        {\n\t\t\t// the y-coordinate where the both items are aligned\n\t\t\tqreal yCoord = qMax(segCoord, blockCoord);\n\n\t\t\t// if there are previous items then make them reach the starting point for\n\t\t\t// these new items\n\t\t\tif (prevSeg)\n            {\n\t\t\t\tprevSeg->setBottomCoordinate(yCoord);\n\t\t\t}\n\t\t\tif (prevBlock)\n            {\n\t\t\t\tprevBlock->setBottomCoordinate(yCoord);\n\t\t\t}\n\n\t\t\t// update the positions\n\t\t\tseg->setPos(0, yCoord);\n\t\t\tblock->setPos(VisualizerItem::DEFAULT_WIDTH, yCoord);\n\n\t\t\t// check if the items are different sizes\n\t\t\t\n\t\t\t// if block reaches further than segment\n            if (seg->getOverlappingBottom() < block->getOverlappingBottom())\n            {\n                qreal segHeight = AddressSpaceVisualizationItem::SEGMENT_HEIGHT;      \n                // Segment displaying one address should be smaller.  \n                if (seg->getOverlappingTop() == seg->getOverlappingBottom())\n                {\n                    segHeight = AddressSpaceVisualizationItem::MIN_HEIGHT;\n                }\n                seg->setHeight(segHeight);\n                segCoord += segHeight;\n\n                // Find the bottom of the address block.\n\t\t\t\tblockCoord = segCoord;\n                // If the next block begins at the ending address of the segment,\n                // they should align.\n                if (block->getOverlappingBottom() == seg->getOverlappingBottom() + 1)\n                {\n                    blockCoord += AddressSpaceVisualizationItem::MIN_HEIGHT +  AddressSpaceVisualizationItem::PEN_WIDTH;\n                }\n                // Otherwise the segment should stretch further down.\n                else\n                {\n                    blockCoord += AddressSpaceVisualizationItem::SEGMENT_HEIGHT +  AddressSpaceVisualizationItem::PEN_WIDTH;\n                }                \n\n\t\t\t\tblock->setBottomCoordinate(blockCoord);\n\t\t\t\t\n\t\t\t\t// the segment has been processed but block is needed on next loop iteration\n\t\t\t\tprevSeg = seg;\n\t\t\t\t++segIterator;\n\t\t\t}\n\n\t\t\t// if segment reaches further than block\n\t\t\telse if (seg->getOverlappingBottom() > block->getOverlappingBottom())\n            {                \n                qreal blockHeight = AddressSpaceVisualizationItem::SEGMENT_HEIGHT;\n                // Block displaying one address should be smaller.  \n                if (block->getOverlappingTop() == block->getOverlappingBottom())\n                {\n                    blockHeight = AddressSpaceVisualizationItem::MIN_HEIGHT;\n                }\n                block->setHeight(blockHeight);\n                blockCoord += blockHeight;\n\n\t\t\t\tsegCoord = blockCoord;\n                // If the next block begins at the ending address of the segment,\n                // they should align.\n                if (seg->getOverlappingBottom() == block->getOverlappingBottom() + 1)\n                {\n                    segCoord += AddressSpaceVisualizationItem::MIN_HEIGHT +  AddressSpaceVisualizationItem::PEN_WIDTH;\n                }\n                // Otherwise the segment should stretch further down.\n                else\n                {\n                    segCoord += AddressSpaceVisualizationItem::SEGMENT_HEIGHT +  AddressSpaceVisualizationItem::PEN_WIDTH;\n                }                \n\n\t\t\t\tseg->setBottomCoordinate(segCoord);\t\n\t\t\t\t\n\t\t\t\t// the block has been processed but segment is needed on next loop iteration\n\t\t\t\tprevBlock = block;\n\t\t\t\t++blockIterator;\n\t\t\t}\n\t\t\t// if blocks are of same size\n\t\t\telse\n            {\n                qreal height = AddressSpaceVisualizationItem::SEGMENT_HEIGHT;\n                 // Block and segment displaying one address should be smaller. \n                if (seg->getOverlappingTop() == seg->getOverlappingBottom())\n                {\n                    height = AddressSpaceVisualizationItem::MIN_HEIGHT;\n                }\n\t\t\t\tseg->setHeight(height);\n\t\t\t\tblock->setHeight(height);\n\n\t\t\t\t// update the y-coordinates for next items\n\t\t\t\tsegCoord += height;\n\t\t\t\tblockCoord += height;\n\t\t\t\t \n\t\t\t\t// both blocks are processed and next loop iteration starts on new items\n\t\t\t\tprevSeg = seg;\n\t\t\t\tprevBlock = block;\n\t\t\t\t++segIterator;\n\t\t\t\t++blockIterator;\n\t\t\t}\n\t\t}\n\n\t\t// if the segment starts before the block\n\t\telse if (seg->getOverlappingTop() < block->getOverlappingTop())\n        {\n\t\t\tblock->setPos(VisualizerItem::DEFAULT_WIDTH, blockCoord);\n\n\t\t\t// if block reaches further than segment\n\t\t\tif (seg->getOverlappingBottom() < block->getOverlappingBottom())\n            {\n                // Find the bottom of the segment.\n                blockCoord = seg->mapToScene(seg->rect().bottomRight()).y();\n                // If the next segment begins at the ending address of the block,\n                // they should align.\n                if (block->getOverlappingBottom() == seg->getOverlappingBottom() + 1)\n                {\n                    blockCoord += AddressSpaceVisualizationItem::MIN_HEIGHT +  AddressSpaceVisualizationItem::PEN_WIDTH;\n                }\n                // Otherwise the block should stretch further down.\n                else\n                {\n                    blockCoord += AddressSpaceVisualizationItem::SEGMENT_HEIGHT +  AddressSpaceVisualizationItem::PEN_WIDTH;\n                }\n                block->setBottomCoordinate(blockCoord);\n\n\t\t\t\t// the segment has been processed but block is needed on next loop iteration\n\t\t\t\tprevSeg = seg;\n\t\t\t\t++segIterator;\n\t\t\t}\n\n\t\t\t// if segment reaches further than block\n\t\t\telse if (seg->getOverlappingBottom() > block->getOverlappingBottom())\n            {\n                qreal blockHeight = AddressSpaceVisualizationItem::SEGMENT_HEIGHT;\n                if (block->getOverlappingTop() == block->getOverlappingBottom())\n                {\n                    blockHeight = AddressSpaceVisualizationItem::MIN_HEIGHT;\n                }\n\t\t\t\tblock->setHeight(blockHeight);\n\t\t\t\tblockCoord += blockHeight;\n\n\t\t\t\t// Find the bottom of the address block.\n\t\t\t\tsegCoord = blockCoord;\n                // If the next block begins at the ending address of the segment,\n                // they should align.\n                if (seg->getOverlappingBottom() == block->getOverlappingBottom() + 1)\n                {\n                    segCoord += AddressSpaceVisualizationItem::MIN_HEIGHT +  AddressSpaceVisualizationItem::PEN_WIDTH;\n                }\n                // Otherwise the segment should stretch further down.\n                else\n                {\n                    segCoord += AddressSpaceVisualizationItem::SEGMENT_HEIGHT +  AddressSpaceVisualizationItem::PEN_WIDTH;\n                }                \n\n\t\t\t\tseg->setBottomCoordinate(segCoord);\n\n\t\t\t\t// the block has been processed but segment is needed on next loop iteration\n\t\t\t\tprevBlock = block;\n\t\t\t\t++blockIterator;\n\t\t\t}\n\t\t\t// if blocks have the same ending address\n\t\t\telse\n            {\n                // Block displaying one address should be smaller. \n                if ( block->getOverlappingTop() != block->getOverlappingBottom())\n                {\n                    blockCoord += AddressSpaceVisualizationItem::SEGMENT_HEIGHT;\n                }\n                else\n                {\n                    blockCoord += AddressSpaceVisualizationItem::MIN_HEIGHT;\n                }\n\t\t\t\t// the common ending coordinate\n\t\t\t\tqreal yCoord = qMax(segCoord, blockCoord);\n\n\t\t\t\tseg->setBottomCoordinate(yCoord);\n\t\t\t\tsegCoord = yCoord;\n\n\t\t\t\tblock->setBottomCoordinate(yCoord);\n\t\t\t\tblockCoord = yCoord;\n\n\t\t\t\t// both blocks are processed and next loop iteration starts on new items\n\t\t\t\tprevSeg = seg;\n\t\t\t\tprevBlock = block;\n\t\t\t\t++segIterator;\n\t\t\t\t++blockIterator;\n\t\t\t}\n\t\t}\n\n\t\t// if the block starts before the segment\n\t\telse if (seg->getOverlappingTop() > block->getOverlappingTop())\n        {\n\t\t\tseg->setPos(0, segCoord);\n \n \t\t\t// if block reaches further than segment\n\t\t\tif (seg->getOverlappingBottom() < block->getOverlappingBottom())\n            {\n                qreal segHeight = AddressSpaceVisualizationItem::SEGMENT_HEIGHT;\n                // Segment displaying one address should be smaller.\n                if (seg->getOverlappingTop() == seg->getOverlappingBottom())\n                {\n                    segHeight = AddressSpaceVisualizationItem::MIN_HEIGHT;\n                }\n\t\t\t\tseg->setHeight(segHeight);\n\t\t\t\tsegCoord += segHeight;\n\n\t\t\t\t// Find the bottom of the segment.\n                blockCoord = seg->mapToScene(seg->rect().bottomRight()).y();\n                // If the next segment begins at the ending address of the address block,\n                // they should align.\n                if (block->getOverlappingBottom() == seg->getOverlappingBottom() + 1)\n                {\n                    blockCoord += AddressSpaceVisualizationItem::MIN_HEIGHT +  AddressSpaceVisualizationItem::PEN_WIDTH;\n                }\n                // Otherwise the block should stretch further down.\n                else\n                {\n                    blockCoord += AddressSpaceVisualizationItem::SEGMENT_HEIGHT +  AddressSpaceVisualizationItem::PEN_WIDTH;\n                }                \n\n                block->setBottomCoordinate(blockCoord);\n                // the segment has been processed but block is needed on next loop iteration\n                prevSeg = seg;\n\t\t\t\t++segIterator;\n\t\t\t}\n\n\t\t\t// if segment reaches further than block\n\t\t\telse if (seg->getOverlappingBottom() > block->getOverlappingBottom())\n            {\n                // Find the bottom of the block.\n                segCoord = block->mapToScene(block->rect().bottomRight()).y();\n                // If the next address block begins at the ending address of the segment,\n                // they should align.\n                if (seg->getOverlappingBottom() == block->getOverlappingBottom() + 1)\n                {\n                    segCoord += AddressSpaceVisualizationItem::MIN_HEIGHT +  AddressSpaceVisualizationItem::PEN_WIDTH;\n                }\n                // Otherwise the segment should stretch further down.\n                else\n                {\n                    segCoord += AddressSpaceVisualizationItem::SEGMENT_HEIGHT +  AddressSpaceVisualizationItem::PEN_WIDTH;\n                }\n                seg->setBottomCoordinate(segCoord);\n\n\t\t\t\t// the block has been processed but segment is needed on next loop iteration\n\t\t\t\tprevBlock = block;\n\t\t\t\t++blockIterator;\n\t\t\t}\n\t\t\t// if blocks have the same ending address\n            else\n            {\n                 // Block and segment displaying one address should be smaller.\n                if (seg->getOverlappingTop() != seg->getOverlappingBottom())\n                {\n                    segCoord += AddressSpaceVisualizationItem::SEGMENT_HEIGHT;\n                }\n                else\n                {\n                    segCoord += AddressSpaceVisualizationItem::MIN_HEIGHT;\n                }\n\t\t\t\t// the common ending coordinate\n\t\t\t\tqreal yCoord = qMax(segCoord, blockCoord);\n\n\t\t\t\tseg->setBottomCoordinate(yCoord);\n\t\t\t\tsegCoord = yCoord;\n\n\t\t\t\tblock->setBottomCoordinate(yCoord);\n\t\t\t\tblockCoord = yCoord;\n\n\t\t\t\t// both blocks are processed and next loop iteration starts on new items\n\t\t\t\tprevSeg = seg;\n\t\t\t\tprevBlock = block;\n\t\t\t\t++segIterator;\n\t\t\t\t++blockIterator;\n\t\t\t}\n\t\t}\t\t\n    }   \n\n    rePositionExceeding(qMax(segCoord, blockCoord)); \n}\n\n//-----------------------------------------------------------------------------\n// Function: updateMaps()\n//-----------------------------------------------------------------------------\nvoid MemoryAlignScene::updateMaps(QMultiMap<quint64, AddressSpaceVisualizationItem*>& itemMap, \n    QMultiMap<quint64, AddressSpaceVisualizationItem*> const& exceedingItemMap, \n    VisualizerItem::LabelLayout const align)\n{\n    quint64 addressSpaceEnd = addressSpaceLastAddress();\n\n    // Conflict all items outside address space.\n    for (AddressSpaceVisualizationItem* exceedingItem : exceedingItemMap)\n    {\n        exceedingItem->setConflicted(true);\n        exceedingItem->refresh();\n    }\n\n    // Replacing, updated map for itemMap.\n    QMultiMap<quint64, AddressSpaceVisualizationItem*> newMap;\n\n    // go through all items and update the segment offsets and remove gaps\n    for (AddressSpaceVisualizationItem* item : itemMap)\n    {\n        // if the item is gap item then remove it\n        auto gap = dynamic_cast<AddressSpaceGapItem*>(item);\n        if (gap)\n        {\n            removeItem(gap);\n\t\t\tdelete gap;\n\t\t\tgap = nullptr;\n            continue;\n        }\n\n        // update the offset for other than gap items\n        quint64 offset = item->getOffset();\n        newMap.insert(offset, item);\n        if (item->getLastAddress() > addressSpaceEnd)\n        {\n            item->setConflicted(true);\n        }\n        item->refresh();           \n    }\n\n    // The top-most item.\n    AddressSpaceVisualizationItem* topItem = nullptr;\n\n    // Previous conflict block.\n    AddressSpaceVisualizationItem* prevConflict = nullptr;\n\n    // Last processed address.    \n    quint64 lastAddress = 0;\n\n    auto width = getWidth();\n    // add gaps where a segment is not defined.\n    for (AddressSpaceVisualizationItem* item : newMap) \n    {\n        // if there is a gap between the last item and this item or first item\n        // begins at address 1.\n        if (item->getOffset() > lastAddress + 1 || \n            (topItem == nullptr && item->getOffset() == lastAddress + 1))\n        {\n            // create the gap item.\n            auto gap = new AddressSpaceGapItem(align, width, expressionParser_);\n            addItem(gap);\n\n            // if the gap is at the start of the address space.\n            if (lastAddress == 0 && !topItem) {\n                gap->setStartAddress(lastAddress, true);\n            }\n            // if the gap is between items.\n            else {\n                gap->setStartAddress(lastAddress, false);\n            }\n\n            // the gap ends at the start of the next item.\n            gap->setEndAddress(item->getOffset(), false);\n            gap->refresh();\n\n            // add the gap to the new map.\n            newMap.insert(gap->getOffset(), gap);\n        }\n\n        // Check for overlapping memory blocks.\n        resolveConflicts(item, topItem, prevConflict, align, newMap);       \n\n\t\t// update the last address of the item.\n\t\tlastAddress = qMax(item->getLastAddress(), lastAddress);\n\t}\n\n\t// add a gap to the end of the address space if last item < addr space size.\n\tif (addressSpaceEnd > lastAddress || (newMap.empty() && newMap == segmentItems_ && !addrBlockItems_.empty() )) \n        {\n\t\t// create the gap item.\n        auto gap = new AddressSpaceGapItem(align, width, expressionParser_);\n\t\taddItem(gap);\n\n\t    // set the first address of the gap.\n\t\t// if there were no address items then the end gap is also first gap.\n\t\tif (lastAddress == 0 && topItem == nullptr)\n        {\n\t\t\tgap->setStartAddress(lastAddress, true);\n\t\t}\n\t\t// otherwise the last gap starts after the previous ended.\n\t\telse\n        {\n\t\t\tgap->setStartAddress(lastAddress, false);\n\t\t}\n\n\t\t// set the last address for the gap\n\t\tgap->setEndAddress(addressSpaceEnd);\n\t\tgap->refresh();\n\n\t\tnewMap.insert(lastAddress + 1, gap);\n\t}       \n\n\n\t// finally update the original map to match the updated.\n\titemMap.clear();\n\titemMap = newMap;\n}\n\n//-----------------------------------------------------------------------------\n// Function: rePositionExceeding()\n//-----------------------------------------------------------------------------\nvoid MemoryAlignScene::rePositionExceeding(qreal const yStart)\n{\n    // Add segments outside address space to the end.\n    qreal yCoordinate = yStart + MARGIN;\n    for (AddressSpaceVisualizationItem* seg : exceedingSegments_)\n    {\n        seg->setHeight(AddressSpaceVisualizationItem::SEGMENT_HEIGHT);\n        seg->setPos(0, yCoordinate);\n        yCoordinate += AddressSpaceVisualizationItem::SEGMENT_HEIGHT;\n    }\n\n    // Add address blocks outside address space to the end.\n    yCoordinate = yStart + MARGIN;\n    for (AddressSpaceVisualizationItem* block : exceedingAddrBlocks_)\n    {\n        block->setHeight(AddressSpaceVisualizationItem::SEGMENT_HEIGHT);\n        block->setPos(VisualizerItem::DEFAULT_WIDTH, yCoordinate);\n        yCoordinate += AddressSpaceVisualizationItem::SEGMENT_HEIGHT;\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: resolveConflicts()\n//-----------------------------------------------------------------------------\nvoid MemoryAlignScene::resolveConflicts(AddressSpaceVisualizationItem* currentItem, \n    AddressSpaceVisualizationItem*& topItem, AddressSpaceVisualizationItem*& prevConflict,\n    VisualizerItem::LabelLayout const align,\n    QMultiMap<quint64, AddressSpaceVisualizationItem*>& map)\n{\n    Q_ASSERT(currentItem);\n\n    auto width = getWidth();\n    // If this item overlaps the previous top-most item.\n    if (topItem && currentItem->getOffset() <= topItem->getLastAddress())\n    {\n        currentItem->setOverlappingTop(topItem->getLastAddress() + 1);\n        currentItem->setConflicted(true);\n        topItem->setConflicted(true);\n\n        // item is completely inside other items.\n        if (currentItem->getLastAddress() <= topItem->getLastAddress())\n        {            \n            currentItem->setCompleteOverlap();\n        }\n\n        // Item partially overlaps with previous top-most item.\n        else\n        {\n            quint64 conflictEnd = topItem->getLastAddress();\n\n            // Previous top-most item is completely overlapped by this item and another item.\n            if (prevConflict && prevConflict->getLastAddress() + 1 >= currentItem->getOffset())\n            {\n                topItem->setCompleteOverlap();\n            }\n\n            // Previous top-most item is completely under this item. \n            else if (currentItem->getOffset() == topItem->getOffset())\n            {                                   \n                topItem->setCompleteOverlap();                  \n            }\n\n            // Previous top-most item is partially under this item. \n            else \n            {                 \n                topItem->setOverlappingBottom(currentItem->getOffset() - 1);                          \n            }\n\n            // Add conflicting item.\n            auto conflict = new AddressSpaceConflictedItem(align, width, expressionParser_);\n\n            addItem(conflict);                \n            conflict->setStartAddress(currentItem->getOffset(),true);\n            conflict->setEndAddress(conflictEnd,true); \n\n            map.insert(conflict->getOffset(), conflict);\n\n            prevConflict = conflict;\n            topItem = currentItem;\n        }\n\n    }\n    // No overlapping.\n    else\n    {\n        topItem = currentItem;\n    }\n\n}\n//-----------------------------------------------------------------------------\n// Function: MemoryAlignScene::addressSpaceLastAddress()\n//-----------------------------------------------------------------------------\nquint64 MemoryAlignScene::addressSpaceLastAddress() const\n{\n    QString rangeExpression = getRange();\n    quint64 range = expressionParser_->parseExpression(rangeExpression).toULongLong();\n    if (rangeExpression.isEmpty() || range <= 0)\n    {\n        return 0;\n    }\n\n    return range - 1;\n}\n"
  },
  {
    "path": "editors/ComponentEditor/common/MemoryAlignScene.h",
    "content": "//-----------------------------------------------------------------------------\n// File: MemoryAlignScene.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Antti Kamppi\n// Date: 22.12.2012\n//\n// Description:\n// Base class for scenes visualizing address spaces or CPU regions.\n//-----------------------------------------------------------------------------\n\n#ifndef MEMORYALIGNSCENE_H\n#define MEMORYALIGNSCENE_H\n\n#include <QGraphicsScene>\n#include <QSharedPointer>\n#include <QMultiMap>\n\n#include <common/graphicsItems/visualizeritem.h>\n\nclass AddressSpaceVisualizationItem;\nclass ExpressionParser;\nclass AddressSpace;\nclass AddressSpaceGapItem;\n\n\n//-----------------------------------------------------------------------------\n//! Base class for scenes visualizing address spaces or CPU regions..\n//-----------------------------------------------------------------------------\nclass MemoryAlignScene : public QGraphicsScene\n{\n\tQ_OBJECT\n\npublic:\n\n    //! Margin between segments/blocks and segments/blocks outside address space. \n    static const unsigned int MARGIN = 10;\n\n\t/*!\n     *  The constructor.\n\t *\n     *    @param [in] expressionParser  The expression parser to use for local memory maps.\n\t *    @param [in] parent            The owner of the scene.\n\t */\n\tMemoryAlignScene(QSharedPointer<ExpressionParser> expressionParser,\n\t\tQObject *parent);\n\t\n\t//! The destructor.\n\tvirtual ~MemoryAlignScene() = default;\n\n    //! No copying.\n    MemoryAlignScene(const MemoryAlignScene& other) = delete;\n\n    //! No assignment.\n    MemoryAlignScene& operator=(const MemoryAlignScene& other) = delete;\n\n\t/*!\n     *  Refresh the address space visualization.\n\t */\n\tvirtual void refresh();\n\n    /*!\n     *  Create the region/segment items placed on left.\n     *\n     */\n    virtual void createRegionItems() = 0;\n\n    /*!\n     *  Create the address block items placed on right.\n     *\n     */\n    virtual void createAddressBlockItems() = 0;\n    \n\t/*!\n     *  Get the last address contained in the item.\n\t *\n\t *    @return The last address.\n\t */\n    quint64 addressSpaceLastAddress() const;\n\n\t/*!\n     *  Reposition the items on the visualization.\n\t * \n\t *  The items are repositioned based on the offsets and new items are not created or old removed.\n\t */\n\tvirtual void rePosition();\n\nprotected:\n\n    /*!\n     *  Get the width of the visualized memory.\n     *\n     *    @return The width of the memory.\n     */\n    virtual QString getWidth() const = 0;\n\n    /*!\n     *  Get the range of the visualized memory.\n     *\n     *    @return The range of the memory.\n     */\n    virtual QString getRange() const = 0;\n\n    //! Contains the segments and segments gaps ordered by offsets\n    QMultiMap<quint64, AddressSpaceVisualizationItem*> segmentItems_;\n\n    //! Contains the local address blocks and gaps ordered by offsets\n    QMultiMap<quint64, AddressSpaceVisualizationItem*> addrBlockItems_;\n\n    //! Contains the segments outside address space ordered by offsets\n    QMultiMap<quint64, AddressSpaceVisualizationItem*> exceedingSegments_;\n\n    //! Contains the local address blocks outside address space ordered by offsets\n    QMultiMap<quint64, AddressSpaceVisualizationItem*> exceedingAddrBlocks_;\n\n    //! The used expression parser.\n    QSharedPointer<ExpressionParser> expressionParser_;\n\nprivate:\n\t\n    /*!\n     *   Update the offsets and overlapping blocks of the segments/address blocks.\n     *\n     *    @param [in/out] itemMap             Map of segments/blocks to update.\n     *    @param [in]     exceedingItemMap    Map of segments/blocks outside address space.\n     *    @param [in]     align               Alignment of text on items.\n     */\n\tvoid updateMaps(QMultiMap<quint64, AddressSpaceVisualizationItem*>& itemMap, \n        QMultiMap<quint64, AddressSpaceVisualizationItem*> const& exceedingItemMap, \n        VisualizerItem::LabelLayout const align);\n\n    /*!\n     *   Positions segments and address blocks outside address space.\n     *\n     *    @param [in] yStart             Minimum y-coordinate for items.\n     */\n    virtual void rePositionExceeding(qreal const yStart);\n\n    /*!\n     *   Checks if currentItem overlaps previous top-most item. Adds conflicted blocks\n     *   if memories overlap and hides completely overlapped memory blocks.\n     *\n     *    @param [in]     currentItem     Item to check.\n     *    @param [in/out] topItem         Top-most item so far.\n     *    @param [in/out] prevConflict    Previous conflicting memory block.\n     *    @param [in]     align           Alignment of text on items.\n     *    @param [in/out] map             Map to which add conflicting blocks.\n     */\n    virtual void resolveConflicts(AddressSpaceVisualizationItem* currentItem, \n        AddressSpaceVisualizationItem*& topItem, \n        AddressSpaceVisualizationItem*& prevConflict,\n        VisualizerItem::LabelLayout const align,\n        QMultiMap<quint64, AddressSpaceVisualizationItem*>& map);\n\n};\n\n#endif // MEMORYALIGNSCENE_H\n"
  },
  {
    "path": "editors/ComponentEditor/common/MemoryTreeFactory.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: MemoryTreeFactory.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Esko Pekkarinen\n// Date: 31.8.2023\n//\n// Description:\n// Creates a tree representation of component memory items.\n//-----------------------------------------------------------------------------\n\n#include \"MemoryTreeFactory.h\"\n\n#include <IPXACTmodels/Component/AddressSpace.h>\n#include <IPXACTmodels/Component/MemoryMap.h>\n#include <IPXACTmodels/Component/AddressBlock.h>\n#include <IPXACTmodels/Component/Register.h>\n#include <IPXACTmodels/Component/RegisterFile.h>\n#include <IPXACTmodels/Component/Field.h>\n\n#include <QSharedPointer>\n\n//-----------------------------------------------------------------------------\n// Function: MemoryTreeFactory::MemoryTreeFactory()\n//-----------------------------------------------------------------------------\nMemoryTreeFactory::MemoryTreeFactory(QSharedPointer<QList<QSharedPointer<MemoryMap> > > memoryMaps,\n    QSharedPointer<QList<QSharedPointer<AddressSpace> > > addressSpaces) :\n    memoryMaps_(memoryMaps),\n    addressSpaces_(addressSpaces)\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: MemoryTreeFactory::create()\n//-----------------------------------------------------------------------------\nTreeItem* MemoryTreeFactory::create() const\n{\n    auto root = new TreeItem(\"Memory\", QString(\"Root\"));\n\n    for (auto const& memoryMap : *memoryMaps_)\n    {\n        auto memoryMapItem = new TreeItem(memoryMap->name(), QObject::tr(\"Memory map\"));\n\n        for (auto const& memoryBlock : *memoryMap->getMemoryBlocks())\n        {\n            createAddressBlockItem(memoryBlock, memoryMapItem);\n        }\n\n        root->addChild(memoryMapItem);\n    }\n\n    for (auto const& addressSpace : *addressSpaces_)\n    {\n        auto addressSpaceItem = new TreeItem(addressSpace->name(), QObject::tr(\"Address space\"));\n\n        if (addressSpace->hasLocalMemoryMap())\n        {\n            for (auto const& memoryBlock : *addressSpace->getLocalMemoryMap()->getMemoryBlocks())\n            {\n                createAddressBlockItem(memoryBlock, addressSpaceItem);\n            }\n        }\n\n        root->addChild(addressSpaceItem);\n    }\n\n    return root;\n}\n\n//-----------------------------------------------------------------------------\n// Function: MemoryTreeFactory::createAddressBlockItem()\n//-----------------------------------------------------------------------------\nvoid MemoryTreeFactory::createAddressBlockItem(QSharedPointer<MemoryBlockBase> memoryBlock, TreeItem* parentItem) const\n{\n    auto const& addressBlock = memoryBlock.dynamicCast<AddressBlock>();\n    if (addressBlock)\n    {\n        auto addressBlockItem = new TreeItem(addressBlock->name(), QObject::tr(\"Address block\"));\n\n        for (auto const& registerBase : *addressBlock->getRegisterData())\n        {\n            createRegisterItem(registerBase, addressBlockItem);\n        }\n\n        parentItem->addChild(addressBlockItem);\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: MemoryTreeFactory::createRegisterItem()\n//-----------------------------------------------------------------------------\nvoid MemoryTreeFactory::createRegisterItem(QSharedPointer<RegisterBase> registerBase, TreeItem* parentItem) const\n{\n    if (auto const& reg = registerBase.dynamicCast<Register>())\n    {\n        auto registerItem = new TreeItem(reg->name(), QObject::tr(\"Register\"));\n\n        for (auto const& field : *reg->getFields())\n        {\n            auto fieldItem = new TreeItem(field->name(), QObject::tr(\"Field\"));\n            registerItem->addChild(fieldItem);\n        }\n\n        parentItem->addChild(registerItem);\n    }\n    else if (auto const& registerFile = registerBase.dynamicCast<RegisterFile>())\n    {\n        auto registerFileItem = new TreeItem(registerFile->name(), QObject::tr(\"Register file\"));\n\n        for (auto const& registerData : *registerFile->getRegisterData())\n        {\n            createRegisterItem(registerData, registerFileItem);\n        }\n\n        parentItem->addChild(registerFileItem);\n    }\n}\n"
  },
  {
    "path": "editors/ComponentEditor/common/MemoryTreeFactory.h",
    "content": "//-----------------------------------------------------------------------------\n// File: MemoryTreeFactory.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Esko Pekkarinen\n// Date: 31.8.2023\n//\n// Description:\n// Creates a tree representation of component memory items.\n//-----------------------------------------------------------------------------\n\n#ifndef MEMORYTREEFACTORY_H\n#define MEMORYTREEFACTORY_H\n\n#include <common/widgets/TreeItemSelector/TreeItem.h>\n\n#include <IPXACTmodels/Component/Component.h>\n#include <IPXACTmodels/Component/MemoryMapBase.h>\n#include <IPXACTmodels/Component/MemoryBlockBase.h>\n#include <IPXACTmodels/Component/RegisterBase.h>\n\n#include <QSharedPointer>\n\n//-----------------------------------------------------------------------------\n//! Creates a tree representation of component memory items.\n//-----------------------------------------------------------------------------\nclass MemoryTreeFactory\n{\npublic:\n\n\n    /*!\n     *  The constructor.\n     *\n     *    @param [in] memoryMaps      The memory maps available in the tree.\n     *    @param [in] addressSpaces   The address spaces available in the tree.\n     */\n    explicit MemoryTreeFactory(QSharedPointer<QList<QSharedPointer<MemoryMap> > > memoryMaps,\n        QSharedPointer<QList<QSharedPointer<AddressSpace> > > addressSpaces);\n\n    //! The destructor.\n    ~MemoryTreeFactory() = default;\n\n    //! No copy constructor.\n    MemoryTreeFactory(MemoryTreeFactory const&) = delete;\n\n    //! No assignment operator.\n    MemoryTreeFactory& operator=(MemoryTreeFactory const&) = delete;\n    \n    /*!\n     *  Creates a tree of component memory items.\n     *\n     *    @return The root item of the tree.\n     */\n    TreeItem* create() const;\n\nprivate:\n  \n    /*!\n     *  Creates a tree item for an address block.\n     *\n     *    @param [in] memoryBlock The represented address block.\n     *    @param [in] parentItem  The parent item.\n     */\n    void createAddressBlockItem(QSharedPointer<MemoryBlockBase> memoryBlock, TreeItem* parentItem) const;\n\n    /*!\n     *  Creates a tree item for a register file.\n     *\n     *    @param [in] registerFile The represented register or register file.\n     *    @param [in] parentItem   The parent item.\n     */\n    void createRegisterItem(QSharedPointer<RegisterBase> registerBase, TreeItem* parentItem) const;\n\n    //-----------------------------------------------------------------------------\n    // Data.\n    //-----------------------------------------------------------------------------\n\n    //! The available memory maps.\n    QSharedPointer<QList<QSharedPointer<MemoryMap> > > memoryMaps_;\n\n    //! The available address spaces.\n    QSharedPointer<QList<QSharedPointer<AddressSpace> > > addressSpaces_;\n};\n\n#endif // MEMORYTREEFACTORY_H"
  },
  {
    "path": "editors/ComponentEditor/common/ModeReferenceDelegate.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: ModeReferenceDelegate.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: \n// Date: 10.8.2023\n//\n// Description:\n// Delegate that provides editors for editing mode references.\n//-----------------------------------------------------------------------------\n\n#include \"ModeReferenceDelegate.h\"\n\n#include <QComboBox>\n#include <QLineEdit>\n\n#include <QRegularExpressionValidator>\n#include<QAbstractItemView>\n\n//-----------------------------------------------------------------------------\n// Function: ModeReferenceDelegate::ModeReferenceDelegate()\n//-----------------------------------------------------------------------------\nModeReferenceDelegate::ModeReferenceDelegate(QObject* parent):\n    QStyledItemDelegate(parent)\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: ModeReferenceDelegate::createEditor()\n//-----------------------------------------------------------------------------\nQWidget* ModeReferenceDelegate::createEditor(QWidget* parent, const QStyleOptionViewItem& option, const QModelIndex& index) const\n{\n    if (index.column() == 0)\n    {\n        auto lineEdit = new QLineEdit(parent);\n\n        lineEdit->setValidator(new QRegularExpressionValidator(QRegularExpression(\"\\\\d*\"), parent));\n        return lineEdit;\n    }\n    else if (index.column() == 1)\n    {\n        auto comboBox = new QComboBox(parent);\n        return comboBox;\n    }\n\n    return QStyledItemDelegate::createEditor(parent, option, index);\n}\n\n//-----------------------------------------------------------------------------\n// Function: ModeReferenceDelegate::setEditorData()\n//-----------------------------------------------------------------------------\nvoid ModeReferenceDelegate::setEditorData(QWidget* editor, const QModelIndex& index) const\n{\n    if (index.column() == 0)\n    {\n        if (auto lineEdit = qobject_cast<QLineEdit*>(editor))\n        {\n            lineEdit->setText(index.data(Qt::DisplayRole).toString());\n        }\n    }\n    else if (index.column() == 1)\n    {\n        if (auto comboBox = qobject_cast<QComboBox*>(editor))\n        {\n            QString text = index.data(Qt::DisplayRole).toString();\n            comboBox->setCurrentText(text);\n            comboBox->addItems(index.data(Qt::UserRole).toStringList());            \n            comboBox->addItem(QString());\n\n            //setting up curently selected mode to the comboBox\n            int index = comboBox->findText(text, Qt::MatchFixedString);\n            comboBox->setCurrentIndex(index);\n        }\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: ModeReferenceDelegate::setModelData()\n//-----------------------------------------------------------------------------\nvoid ModeReferenceDelegate::setModelData(QWidget* editor, QAbstractItemModel* model, const QModelIndex& index) const\n{\n    if (index.column() == 0)\n    {\n        if (auto lineEdit = qobject_cast<QLineEdit*>(editor))\n        {\n            model->setData(index, lineEdit->text(), Qt::EditRole);\n        }\n    }\n    else if (index.column() == 1)\n    {\n        if (auto comboBox = qobject_cast<QComboBox*>(editor))\n        {\n            model->setData(index, comboBox->currentText(), Qt::EditRole);\n        }\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: ModeReferenceDelegate::commitAndCloseEditor()\n//-----------------------------------------------------------------------------\nvoid ModeReferenceDelegate::commitAndCloseEditor()\n{\n    auto editor = qobject_cast<QWidget*>(sender());\n\n    if (editor)\n    {\n        emit commitData(editor);\n        emit closeEditor(editor);\n    }\n}\n"
  },
  {
    "path": "editors/ComponentEditor/common/ModeReferenceDelegate.h",
    "content": "//-----------------------------------------------------------------------------\n// File: ModeReferenceDelegate.h\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: \n// Date: 10.8.2023\n//\n// Description:\n// Delegate that provides editors for editing mode references.\n//-----------------------------------------------------------------------------\n\n#ifndef MODEREFERENCEDELEGATE_H\n#define MODEREFERENCEDELEGATE_H\n\n#include <QStyledItemDelegate>\n\nclass ModeReferenceDelegate : public QStyledItemDelegate\n{\n    Q_OBJECT\n\npublic:\n\n    /*!\n     *\tThe constructor.\n     *  \n     *    @param [in] parent     The parent object.\n     */\n    ModeReferenceDelegate(QObject* parent);\n\n    /*!\n     *  Create a new editor for the given item\n     *\n     *    @param [in] parent  Owner for the editor.\n     *    @param [in] option  Contains options for the editor.\n     *    @param [in] index   Model index identifying the item.\n     *\n     *    @return The editor to be used to edit the item.\n     */\n    virtual QWidget* createEditor(QWidget* parent, const QStyleOptionViewItem& option, const QModelIndex& index) const override;\n\n    /*!\n     *  Set the data for the editor.\n     *\n     *    @param [in] editor  The editor where the data is to be set.\n     *    @param [in] index   Model index identifying the item that's data is to be set.\n     */\n    virtual void setEditorData(QWidget* editor, const QModelIndex& index) const override;\n\n    /*!\n     *  Save the data from the editor to the model.\n     *\n     *    @param [in] editor The editor that contains the data to store.\n     *    @param [in] model  Model that contains the data structure where data is to be saved to.\n     *    @param [in] index  Model index identifying the item that's data is to be saved.\n     */\n    virtual void setModelData(QWidget* editor, QAbstractItemModel* model, const QModelIndex& index) const override;\n\nsignals:\n\n    void finishedEditing();\n\nprivate slots:\n\n    /*!\n     *  Commit the data from the sending editor and close the editor.\n     */\n    void commitAndCloseEditor();\n};\n\n\n#endif // MODEREFERENCEDELEGATE_H\n\n\n\n"
  },
  {
    "path": "editors/ComponentEditor/common/ModeReferenceEditor.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: ModeReferenceEditor.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: \n// Date: 10.8.2023\n//\n// Description:\n// Editor for mode references.\n//-----------------------------------------------------------------------------\n\n#include \"ModeReferenceEditor.h\"\n\n#include <common/views/EditableTableView/editabletableview.h>\n\n#include <QMap>\n#include <QVBoxLayout>\n#include <QScrollArea>\n\n#include <QSortFilterProxyModel>\n#include <QPushButton>\n#include <QHeaderView>\n\n//-----------------------------------------------------------------------------\n// Function: ModeReferenceEditor::ModeReferenceEditor()\n//-----------------------------------------------------------------------------\nModeReferenceEditor::ModeReferenceEditor(ModeReferenceInterface* modeRefInterface, QWidget* parent) :\n    QWidget(parent),\n    model_(new ModeReferenceModel(modeRefInterface, this)),\n    view_(new EditableTableView(this))\n{\n    setAttribute(Qt::WA_NoMousePropagation);\n    setAutoFillBackground(true);\n\n    auto delegate = new ModeReferenceDelegate(this);\n    auto proxy = new QSortFilterProxyModel(this);\n\n    view_->setSortingEnabled(true);\n    proxy->setSourceModel(model_);\n    view_->setModel(proxy);\n    view_->setItemDelegate(delegate);\n    view_->setContentsMargins(0, 0, 0, 0);\n    view_->sortByColumn(0, Qt::AscendingOrder); // sort by priority by default\n    view_->setItemsDraggable(false);\n\n    setupLayout();\n\n    connect(view_, SIGNAL(addItem(QModelIndex const&)), \n        model_, SLOT(onAddRow(QModelIndex const&)), Qt::UniqueConnection);\n    connect(view_, SIGNAL(removeItem(QModelIndex const&)), \n        model_, SLOT(onRemoveItem(QModelIndex const&)), Qt::UniqueConnection);\n    connect(model_, SIGNAL(invalidateFilter()), proxy, SLOT(invalidate()), Qt::UniqueConnection);\n    connect(model_, SIGNAL(dataChanged(const QModelIndex&, const QModelIndex&)),\n        this, SIGNAL(contentChanged()), Qt::UniqueConnection);\n    connect(model_, SIGNAL(contentChanged()), this, SIGNAL(contentChanged()), Qt::UniqueConnection);\n}\n\n//-----------------------------------------------------------------------------\n// Function: ModeReferenceEditor::setupLayout()\n//-----------------------------------------------------------------------------\nvoid ModeReferenceEditor::setupLayout()\n{\n    auto topLayout = new QVBoxLayout(this);\n    topLayout->setContentsMargins(0, 0, 0, 0);\n    topLayout->addWidget(view_);\n}\n"
  },
  {
    "path": "editors/ComponentEditor/common/ModeReferenceEditor.h",
    "content": "//-----------------------------------------------------------------------------\n// File: ModeReferenceEditor.h\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: \n// Date: 10.8.2023\n//\n// Description:\n// Editor for mode references.\n//-----------------------------------------------------------------------------\n\n#ifndef MODEREFERENCEEDITOR_H\n#define MODEREFERENCEEDITOR_H\n\n#include \"ModeReferenceDelegate.h\"\n#include \"ModeReferenceModel.h\"\n\nclass EditableTableView;\nclass ModeReferenceInterface;\n\nclass ModeReferenceEditor : public QWidget\n{\n    Q_OBJECT\n\npublic:\n\n    /*!\n     *\tThe constructor.\n     *  \n     *    @param [in] model        The mode reference model to use.\n     *    @param [in] parent       The parent widget.\n     */\n    ModeReferenceEditor(ModeReferenceInterface* modeRefInterface, QWidget* parent);\n\n    virtual ~ModeReferenceEditor() = default;\n\n    ModeReferenceEditor(ModeReferenceEditor& other) = delete;\n    ModeReferenceEditor& operator=(ModeReferenceEditor& other) = delete;\n\nsignals:\n\n    void contentChanged();\n\nprivate:\n\n    /*!\n     *\tSetup the layout of the editor.\n     */\n    void setupLayout();\n\n    //! The mode reference model.\n    ModeReferenceModel* model_;\n\n    //! The view displaying the modes and priorities in a table.\n    EditableTableView* view_;\n};\n\n#endif // MODEREFERENCEEDITOR_H\n"
  },
  {
    "path": "editors/ComponentEditor/common/ModeReferenceModel.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: ModeReferenceModel.h\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Anton Hagqvist\n// Date: 10.8.2023\n//\n// Description:\n// Model to manage mode references.\n//-----------------------------------------------------------------------------\n\n#include \"ModeReferenceModel.h\"\n\n#include <KactusAPI/include/ModeReferenceInterface.h>\n\n#include <IPXACTmodels/Component/Mode.h>\n\n#include <common/KactusColors.h>\n\n//-----------------------------------------------------------------------------\n// Function: ModeReferenceModel::ModeReferenceModel()\n//-----------------------------------------------------------------------------\nModeReferenceModel::ModeReferenceModel(ModeReferenceInterface* modeRefInterface, QObject* parent):\n    QAbstractTableModel(parent),\n    interface_(modeRefInterface)\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: ModeReferenceModel::rowCount()\n//-----------------------------------------------------------------------------\nint ModeReferenceModel::rowCount(const QModelIndex& parent /*= QModelIndex()*/) const\n{\n    if (parent.isValid())\n    {\n        return 0;\n    }\n\n    return interface_->getModeReferenceCount();\n}\n\n//-----------------------------------------------------------------------------\n// Function: ModeReferenceModel::columnCount()\n//-----------------------------------------------------------------------------\nint ModeReferenceModel::columnCount(const QModelIndex& parent /*= QModelIndex()*/) const\n{\n    if (parent.isValid())\n    {\n        return 0;\n    }\n\n    return 2;\n}\n\n//-----------------------------------------------------------------------------\n// Function: ModeReferenceModel::flags()\n//-----------------------------------------------------------------------------\nQt::ItemFlags ModeReferenceModel::flags(const QModelIndex& index) const\n{\n    if (!index.isValid())\n    {\n        return Qt::NoItemFlags;\n    }\n    return Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsEditable;\n}\n\n//-----------------------------------------------------------------------------\n// Function: ModeReferenceModel::headerData()\n//-----------------------------------------------------------------------------\nQVariant ModeReferenceModel::headerData(int section, Qt::Orientation orientation, int role /*= Qt::DisplayRole*/) const\n{\n    if (orientation != Qt::Horizontal)\n    {\n        return QVariant();\n    }\n\n    if (role == Qt::DisplayRole)\n    {\n        if (section == 0)\n        {\n            return QStringLiteral(\"Priority\");\n        }\n\n        if (section == 1)\n        {\n            return QStringLiteral(\"Mode\");\n        }\n    }\n\n    return QVariant();\n}\n\n//-----------------------------------------------------------------------------\n// Function: ModeReferenceModel::data()\n//-----------------------------------------------------------------------------\nQVariant ModeReferenceModel::data(const QModelIndex& index, int role /*= Qt::DisplayRole*/) const\n{\n    if (role == Qt::DisplayRole || role == Qt::EditRole || role == Qt::ToolTipRole)\n    {\n        if (index.column() == 0)\n        {\n            return QString::number(interface_->getModeReferencePriority(index.row()));\n        }\n\n        else if (index.column() == 1)\n        {\n            return QString::fromStdString(interface_->getModeReferenceValue(index.row()));\n        }\n    }\n\n    // For getting available component modes.\n    if (role == Qt::UserRole && index.column() == 1)\n    {\n        auto modes = interface_->getComponentModes();\n\n        QStringList modeNames;\n        std::for_each(modes.begin(), modes.end(), [&modeNames](std::string const& mode)\n            {\n                modeNames.append(QString::fromStdString(mode));\n            });\n\n        return modeNames;\n    }\n\n    // Show error, if mode ref value or priority is not valid.\n    if (role == Qt::ForegroundRole)\n    {\n        bool isValid = false;\n\n        if (index.column() == 0)\n        {\n            isValid = interface_->modeReferencePriorityIsValid(index.row());\n\n        }\n        else if (index.column() == 1)\n        {\n            isValid = interface_->modeReferenceValueIsValid(index.row());\n        }\n\n        return isValid ? KactusColors::REGULAR_TEXT : KactusColors::ERROR;\n\n    }\n\n    if (role == Qt::BackgroundRole)\n    {\n        return KactusColors::MANDATORY_FIELD;\n    }\n\n    return QVariant();\n}\n\n//-----------------------------------------------------------------------------\n// Function: ModeReferenceModel::setData()\n//-----------------------------------------------------------------------------\nbool ModeReferenceModel::setData(const QModelIndex& index, const QVariant& value, int role /*= Qt::EditRole*/)\n{\n    if (!index.isValid() || index.row() < 0 ||\n        index.row() >= interface_->getModeReferenceCount() ||\n        !(flags(index) & Qt::ItemIsEditable) || role != Qt::EditRole)\n    {\n        return false;\n    }\n\n    if (index.column() == 0)\n    {\n        interface_->setModeReferencePriority(index.row(), value.toInt());\n    }\n\n    else if (index.column() == 1)\n    {\n        interface_->setModeReferenceValue(index.row(), value.toString().toStdString());\n    }\n\n    emit dataChanged(index, index);\n    emit contentChanged();\n\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: ModeReferenceModel::onAddRow()\n//-----------------------------------------------------------------------------\nvoid ModeReferenceModel::onAddRow(QModelIndex const& index)\n{\n    int row = interface_->getModeReferenceCount();\n\n    // if the index is valid then add the item to the correct position\n    if (index.isValid())\n    {\n        row = index.row();\n    }\n\n    beginInsertRows(QModelIndex(), row, row);\n    interface_->addModeReference(row);\n    endInsertRows();\n\n    emit invalidateFilter();\n    emit contentChanged();\n}\n\n//-----------------------------------------------------------------------------\n// Function: ModeReferenceModel::onRemoveItem()\n//-----------------------------------------------------------------------------\nvoid ModeReferenceModel::onRemoveItem(QModelIndex const& index)\n{\n    int rowToRemove = index.row();\n\n    if (!index.isValid() || rowToRemove < 0 ||\n        rowToRemove >= interface_->getModeReferenceCount())\n    {\n        return;\n    }\n\n    beginRemoveRows(QModelIndex(), rowToRemove, rowToRemove);\n    interface_->removeModeReference(rowToRemove);\n    endRemoveRows();\n\n    emit contentChanged();\n}\n"
  },
  {
    "path": "editors/ComponentEditor/common/ModeReferenceModel.h",
    "content": "//-----------------------------------------------------------------------------\n// File: ModeReferenceModel.h\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Anton Hagqvist\n// Date: 10.8.2023\n//\n// Description:\n// Model to manage mode references.\n//-----------------------------------------------------------------------------\n\n#ifndef MODEREFERENCEMODEL_H\n#define MODEREFERENCEMODEL_H\n\n#include <QAbstractTableModel>\n\nclass ModeReferenceInterface;\n\nclass ModeReferenceModel : public QAbstractTableModel\n{\n    Q_OBJECT\n\npublic:\n\n    /*!\n     *\tThe constructor.\n     * \n     *    @param [in] modeRefInterface    The mode reference interface to use.\n     *    @param [in] modeRefs            The mode references to edit.\n     */\n    ModeReferenceModel(ModeReferenceInterface* modeRefInterface, QObject* parent);\n\n    /*!\n     *  Get the number of modes the model contains.\n     *\n     *    @param [in] parent  Identifies the parent whose row count is requested.\n     *\n     *    @return Number of rows the model has.\n     */\n    virtual int rowCount(const QModelIndex& parent = QModelIndex()) const;\n\n    /*!\n     *  Get the number of columns the model has to be displayed.\n     *\n     *    @param [in] parent  Identifies the parent whose column count is requested.\n     *\n     *    @return The number of columns to be displayed.\n     */\n    virtual int columnCount(const QModelIndex& parent = QModelIndex()) const;\n\n    /*!\n     *  Get the item flags that defines the possible operations for the item.\n     *\n     *    @param [in] index   Model index that identifies the item.\n     *\n     *    @return Qt::ItemFlags specifying the possible operations for the item.\n     */\n    Qt::ItemFlags flags(const QModelIndex& index) const;\n\n    /*!\n     *  Get the header data for specified header.\n     *\n     *    @param [in] section         The section specifies the row/column number for the header.\n     *    @param [in] orientation     Specified if horizontal or vertical header is wanted.\n     *    @param [in] role            Specifies the type of the requested data.\n     *\n     *    @return QVariant containing the requested data.\n     */\n    virtual QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;\n\n    /*!\n     *  Get the data for specified item.\n     *\n     *    @param [in] index   Specifies the item that's data is requested.\n     *    @param [in] role    The role that defines what kind of data is requested.\n     *\n     *    @return QVariant containing the data for the item.\n     */\n    virtual QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const;\n\n    /*!\n     *  Save the data to the model for specified item.\n     *\n     *    @param [in] index   The model index of the item that's data is to be saved.\n     *    @param [in] value   The data that is to be saved.\n     *    @param [in] role    The role specifies what kind of data should be saved.\n     *\n     *    @return True if saving happened successfully.\n     */\n    virtual bool setData(const QModelIndex& index, const QVariant& value, int role = Qt::EditRole);\n\npublic slots:\n    \n    /*!\n     *\tHandler for adding a new mode reference row.\n     *  \n     *    @param [in] index     The model index that was selected.\n     */\n    virtual void onAddRow(QModelIndex const& index);\n\n    /*!\n     *\tHandler for removing a mode reference row.\n     *  \n     *    @param [in] index     The mode reference to be removed.\n     */\n    virtual void onRemoveItem(QModelIndex const& index);\n\nsignals:\n\n    /*!\n     *\tEmitted when there has been a change in the number of rows.\n     */\n    void invalidateFilter();\n\n    /*!\n     *\tEmitted whenever a mode reference has been edited.\n     */\n    void contentChanged();\n\nprivate:\n\n    //! The interface to access mode references.\n    ModeReferenceInterface* interface_;\n\n};\n\n#endif // MODEREFERENCEMODEL_H\n\n\n\n"
  },
  {
    "path": "editors/ComponentEditor/common/MultilineDescriptionDelegate.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: MultilineDescriptionDelegate.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Esko Pekkarinen\r\n// Date: 27.07.2015\r\n//\r\n// Description:\r\n// A delegate that provides a multiline editor for descriptions.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"MultilineDescriptionDelegate.h\"\r\n\r\n#include <QKeyEvent>\r\n#include <QTextEdit>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MultilineDescriptionDelegate::MultilineDescriptionDelegate()\r\n//-----------------------------------------------------------------------------\r\nMultilineDescriptionDelegate::MultilineDescriptionDelegate(QObject* parent):\r\nQStyledItemDelegate(parent)\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MultilineDescriptionDelegate::~MultilineDescriptionDelegate()\r\n//-----------------------------------------------------------------------------\r\nMultilineDescriptionDelegate::~MultilineDescriptionDelegate()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MultilineDescriptionDelegate::createEditor()\r\n//-----------------------------------------------------------------------------\r\nQWidget* MultilineDescriptionDelegate::createEditor(QWidget* parent, QStyleOptionViewItem const& option,\r\n    QModelIndex const& index) const\r\n{\r\n    if (index.column() == descriptionColumn())\r\n    {\r\n        QTextEdit* editor = new QTextEdit(parent);\r\n        editor->setMinimumHeight(120);\r\n        return editor;\r\n    }\r\n    else\r\n    {\r\n        return QStyledItemDelegate::createEditor(parent, option, index);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MultilineDescriptionDelegate::setEditorData()\r\n//-----------------------------------------------------------------------------\r\nvoid MultilineDescriptionDelegate::setEditorData(QWidget* editor, QModelIndex const& index) const\r\n{\r\n    if (index.column() == descriptionColumn())\r\n    {\r\n        QString text = index.data(Qt::EditRole).toString();\r\n        QTextEdit* textEdit = qobject_cast<QTextEdit*>(editor);\r\n        textEdit->setText(text);\r\n    }\r\n    else\r\n    {\r\n        QStyledItemDelegate::setEditorData(editor, index);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MultilineDescriptionDelegate::setModelData()\r\n//-----------------------------------------------------------------------------\r\nvoid MultilineDescriptionDelegate::setModelData(QWidget* editor, QAbstractItemModel* model, QModelIndex const& index) const\r\n{\r\n    if (index.column() == descriptionColumn())\r\n    {\r\n        QTextEdit* textEdit = qobject_cast<QTextEdit*>(editor);\r\n        model->setData(index, textEdit->toPlainText(), Qt::EditRole);\r\n    }\r\n    else\r\n    {\r\n        QStyledItemDelegate::setModelData(editor, model, index);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MultilineDescriptionDelegate::eventFilter()\r\n//-----------------------------------------------------------------------------\r\nbool MultilineDescriptionDelegate::eventFilter(QObject* editor, QEvent* event)\r\n{\r\n    if (event->type() == QEvent::KeyPress)\r\n    {\r\n        QKeyEvent* keyEvent = dynamic_cast<QKeyEvent*>(event);\r\n        if ((keyEvent->key() == Qt::Key_Return || keyEvent->key() == Qt::Key_Enter) && \r\n            keyEvent->modifiers() == Qt::NoModifier)\r\n        {\r\n            QWidget* editorWidget = dynamic_cast<QWidget*>(editor);\r\n            commitData(editorWidget);\r\n            closeEditor(editorWidget);\r\n            return true;\r\n        }\r\n    }\r\n\r\n    return QStyledItemDelegate::eventFilter(editor, event);\r\n}\r\n"
  },
  {
    "path": "editors/ComponentEditor/common/MultilineDescriptionDelegate.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: MultilineDescriptionDelegate.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Esko Pekkarinen\r\n// Date: 27.07.2015\r\n//\r\n// Description:\r\n// A delegate that provides a multiline editor for descriptions.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef MULTILINEDESCRIPTIONDELEGATE_H\r\n#define MULTILINEDESCRIPTIONDELEGATE_H\r\n\r\n#include <QStyledItemDelegate>\r\n#include <QEvent>\r\n\r\n//-----------------------------------------------------------------------------\r\n//! A delegate that provides a multiline editor for descriptions.\r\n//-----------------------------------------------------------------------------\r\nclass MultilineDescriptionDelegate : public QStyledItemDelegate \r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\r\n    /*!\r\n     *  The constructor.\r\n     *\r\n     *    @param [in] parent      The parent object.\r\n     */\r\n\tMultilineDescriptionDelegate(QObject* parent);\r\n\t\r\n\t//! The destructor\r\n\tvirtual ~MultilineDescriptionDelegate();\r\n\r\n\t/*! Create a new editor for the given item\r\n\t *\r\n\t *    @param [in] parent  Owner for the editor.\r\n\t *    @param [in] option  Contains options for the editor.\r\n\t *    @param [in] index   Model index identifying the item.\r\n\t *\r\n\t * \\return Pointer to the editor to be used to edit the item.\r\n\t*/\r\n\tvirtual QWidget* createEditor(QWidget* parent, const QStyleOptionViewItem& option, \r\n        QModelIndex const& index) const;\r\n\r\n\r\n\t/*! Set the data for the editor.\r\n\t *\r\n\t *    @param [in] editor  The editor where the data is to be set.\r\n\t *    @param [in] index   Model index identifying the item that's data is to be set.\r\n\t *\r\n\t*/\r\n\tvirtual void setEditorData(QWidget* editor, QModelIndex const& index) const;\r\n\r\n\t/*! Save the data from the editor to the model.\r\n\t *\r\n\t *    @param [in] editor  The editor that contains the data to store.\r\n\t *    @param [in] model   Model that contains the data structure where data is to be saved to.\r\n\t *    @param [in] index   Model index identifying the item that's data is to be saved.\r\n\t*/\r\n\tvirtual void setModelData(QWidget* editor, QAbstractItemModel* model, QModelIndex const& index) const;\r\n\r\nprotected:\r\n\r\n    //! Filters events for editors.\r\n    virtual bool eventFilter(QObject* editor, QEvent *event);\r\n\r\n    virtual int descriptionColumn() const = 0;\r\n\r\nprivate:\r\n\t//! No copying\r\n\tMultilineDescriptionDelegate(const MultilineDescriptionDelegate& other);\r\n\tMultilineDescriptionDelegate& operator=(const MultilineDescriptionDelegate& other);\r\n\r\n};\r\n\r\n#endif // MULTILINEDESCRIPTIONDELEGATE_H\r\n"
  },
  {
    "path": "editors/ComponentEditor/common/ParameterizableTable.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ParametrizableTable.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Mikko Teuho\r\n// Date: 17.12.2014\r\n//\r\n// Description:\r\n// Base class for equation usage in parameter editors.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"ParameterizableTable.h\"\r\n\r\n#include <common/KactusColors.h>\r\n\r\n#include <KactusAPI/include/ExpressionFormatter.h>\r\n#include <KactusAPI/include/IPXactSystemVerilogParser.h>\r\n\r\n#include <QFont>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ParameterizableTable::ParametrizableTable()\r\n//-----------------------------------------------------------------------------\r\nParameterizableTable::ParameterizableTable(QSharedPointer<ParameterFinder> parameterFinder):\r\nexpressionParser_(),\r\nparameterFinder_(parameterFinder)\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ParameterizableTable::getExpressionSymbol()\r\n//-----------------------------------------------------------------------------\r\nQString ParameterizableTable::getExpressionSymbol() const\r\n{\r\n    QString functionSymbol(QChar(0x0192));\r\n    return QString(\", \" + functionSymbol + \"(x)\");\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ParameterizableTable::setExpressionParser()\r\n//-----------------------------------------------------------------------------\r\nvoid ParameterizableTable::setExpressionParser(QSharedPointer <ExpressionParser> expressionParser)\r\n{\r\n    expressionParser_ = expressionParser;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ParameterizableTable::formattedValueFor()\r\n//-----------------------------------------------------------------------------\r\nQString ParameterizableTable::formattedValueFor(QString const& expression) const\r\n{\r\n    return ExpressionFormatter::format(expression, expressionParser_);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ParameterizableTable::italicForEvaluatedValue()\r\n//-----------------------------------------------------------------------------\r\nQVariant ParameterizableTable::italicForEvaluatedValue(QModelIndex const& index) const\r\n{\r\n    QString valueOrExpression = expressionOrValueForIndex(index).toString();\r\n\r\n    if (isValidExpressionColumn(index) && !expressionParser_->isPlainValue(valueOrExpression))\r\n    {\r\n        QFont italicFont;\r\n        italicFont.setItalic(true);\r\n        return italicFont;\r\n    }\r\n    else\r\n    {\r\n        return QVariant();\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ParameterizableTable::blackForValidOrRefForInavlidIndex()\r\n//-----------------------------------------------------------------------------\r\nQVariant ParameterizableTable::blackForValidOrRedForInvalidIndex(QModelIndex const& index) const\r\n{\r\n    if (validateIndex(index))\r\n    {\r\n        return KactusColors::REGULAR_TEXT;\r\n    }\r\n    else\r\n    {\r\n        return KactusColors::ERROR;\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ParameterizableTable::isValidExpression()\r\n//-----------------------------------------------------------------------------\r\nbool ParameterizableTable::isValidExpression(QString const& value) const\r\n{\r\n    bool validExpression = false;\r\n    expressionParser_->parseExpression(value, &validExpression);\r\n    return validExpression;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ParameterizableTable::parsedExpression()\r\n//-----------------------------------------------------------------------------\r\nQString ParameterizableTable::parseExpressionToDecimal (QString const& expression) const\r\n{\r\n    return expressionParser_->parseExpression(expression);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ParameterizableTable::getParameterFinder()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<ParameterFinder> ParameterizableTable::getParameterFinder() const\r\n{\r\n    return parameterFinder_;\r\n}\r\n"
  },
  {
    "path": "editors/ComponentEditor/common/ParameterizableTable.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: Parameterizabletable.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Mikko Teuho\r\n// Date: 17.12.2014\r\n//\r\n// Description:\r\n// Base class for equation usage in parameter editors.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef PARAMETERIZABLETABLE_H\r\n#define PARAMETERIZABLETABLE_H\r\n\r\n#include <IPXACTmodels/common/Parameter.h>\r\n\r\n#include <KactusAPI/include/ParameterFinder.h>\r\n\r\n#include <QAbstractTableModel>\r\n\r\nclass ExpressionParser;\r\n//-----------------------------------------------------------------------------\r\n//! Base class for models editing parameters and model parameters.\r\n//-----------------------------------------------------------------------------\r\nclass ParameterizableTable\r\n{\r\n\r\npublic:\r\n\r\n\t/*!\r\n\t *  The constructor.\r\n\t *\r\n\t *    @param [in] parameterFinder     Parameter finder.\r\n\t */\r\n\tParameterizableTable(QSharedPointer<ParameterFinder> parameterFinder);\r\n\r\n    //! Disable copying and assignment.\r\n    ParameterizableTable(const ParameterizableTable& other) = delete;\r\n    ParameterizableTable& operator=(const ParameterizableTable& other) = delete;\r\n\r\n    /*!\r\n     *  The destructor.\r\n     */\r\n    virtual ~ParameterizableTable() = default;\r\n\r\n    /*!\r\n     *  Sets the expression parser.\r\n     *\r\n     *    @param [in] expressionParser    The expression parser.\r\n     */\r\n    void setExpressionParser(QSharedPointer<ExpressionParser> expressionParser);\r\n\r\nprotected:\r\n\r\n    /*!\r\n     *  Gets the symbol for functions.\r\n     */\r\n    QString getExpressionSymbol() const;\r\n\r\n    /*!\r\n     *  Gets a formatted value for a given expression.\r\n     *\r\n     *    @param [in] expression      The expression whose value to format.\r\n     *\r\n     *    @return     The formatted value for the expression.\r\n     */\r\n    virtual QString formattedValueFor(QString const& expression) const;\r\n\r\n    /*!\r\n     *  Gets an italic font for an evaluated value and normal font for others.\r\n     *\r\n     *    @param [in] value   The value.\r\n     *\r\n     *    @return     Italic font for evaluated value, normal for others.\r\n     */\r\n    QVariant italicForEvaluatedValue(QModelIndex const& index) const;\r\n\r\n    /*!\r\n     *  Check if the column index is valid for containing expressions.\r\n     *\r\n     *    @param [in] index   The index being evaluated.\r\n     *\r\n     *    @return     True, if column can have expressions, false otherwise.\r\n     */\r\n    virtual bool isValidExpressionColumn(QModelIndex const& index) const = 0;\r\n\r\n    /*!\r\n     *  Gets the expression for the given index or the plain value if expression is not available.\r\n     *\r\n     *    @param [in] index   The index whose expression to get.\r\n     *\r\n     *    @return The expression for the index if available, otherwise the value for the given index.\r\n     */\r\n    virtual QVariant expressionOrValueForIndex(QModelIndex const& index) const = 0; \r\n  \r\n    /*!\r\n     *  Validates the data in an index.\r\n     *\r\n     *    @param [in] index   The index whose data to validate\r\n     *\r\n     *    @return True, if the data in the index is valid, otherwise false.\r\n     */\r\n    virtual bool validateIndex(QModelIndex const& index) const = 0;\r\n\r\n    /*!\r\n     *  Gets a black color for valid index and red color for invalid index.\r\n     *\r\n     *    @param [in] index   The index for which to get the color.\r\n     *\r\n     *    @return Black for valid index, red for invalid index.\r\n     */\r\n    QVariant blackForValidOrRedForInvalidIndex(QModelIndex const& index) const;\r\n\r\n    /*!\r\n     *  Checks if the value is a valid expression.\r\n     *\r\n     *    @param [in] value   The value.\r\n     *\r\n     *    @return     True, if value is a valid expression, otherwise false.\r\n     */\r\n    bool isValidExpression(QString const& value) const;\r\n\r\n    /*!\r\n     *  Parse expression to decimal number.\r\n     *\r\n     *    @param [in] expression  The expression to be parsed.\r\n     *    @param [in] index       The model index of the expression.\r\n     *\r\n     *    @return     The decimal version of the number.\r\n     */\r\n    QString parseExpressionToDecimal(QString const& expression) const;\r\n\r\n    /*!\r\n     *  Get the parameter finder.\r\n     *\r\n     *    @return The parameter finder used in the table.\r\n     */\r\n    QSharedPointer<ParameterFinder> getParameterFinder() const;\r\n\r\nprivate:\r\n\r\n    //! Expression parser for configurable elements.\r\n    QSharedPointer<ExpressionParser> expressionParser_;\r\n\r\n    //! The parameter finder.\r\n    QSharedPointer<ParameterFinder> parameterFinder_;\r\n};\r\n\r\n#endif // PARAMETERIZABLETABLE_H\r\n"
  },
  {
    "path": "editors/ComponentEditor/common/ReferenceSelector/ReferenceSelector.cpp",
    "content": "/* \r\n *  \tCreated on: 21.6.2012\r\n *      Author: Antti Kamppi\r\n * \t\tfilename: memorymapselector.cpp\r\n *\t\tProject: Kactus2\r\n */\r\n\r\n#include \"ReferenceSelector.h\"\r\n\r\n#include <common/KactusColors.h>\r\n\r\n#include <QPalette>\r\n#include <QEvent>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ReferenceSelector::ReferenceSelector()\r\n//-----------------------------------------------------------------------------\r\nReferenceSelector::ReferenceSelector(QWidget *parent):\r\nQComboBox(parent)\r\n{\r\n\tsetEditable(false);\r\n\r\n\tconnect(this, SIGNAL(currentIndexChanged(int)),\tthis, SLOT(onIndexChange(int)), Qt::UniqueConnection);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ReferenceSelector::~ReferenceSelector()\r\n//-----------------------------------------------------------------------------\r\nReferenceSelector::~ReferenceSelector()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ReferenceSelector::setTextColor()\r\n//-----------------------------------------------------------------------------\r\nvoid ReferenceSelector::setTextColor(QColor const& color)\r\n{\r\n    QPalette coloredPalette = palette();\r\n    coloredPalette.setColor(QPalette::Text, color);\r\n    setPalette(coloredPalette);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ReferenceSelector::refresh()\r\n//-----------------------------------------------------------------------------\r\nvoid ReferenceSelector::refresh(QStringList const& itemNames)\r\n{\r\n\tdisconnect(this, SIGNAL(currentIndexChanged(int)), this, SLOT(onIndexChange(int)));\r\n\r\n\t// Remove the previous items\r\n\tclear();\r\n\r\n\t// Add an empty item and list of memory maps.\r\n\taddItem(\"\");\r\n\taddItems(itemNames);\r\n\r\n\tconnect(this, SIGNAL(currentIndexChanged(int)), this, SLOT(onIndexChange(int)), Qt::UniqueConnection);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ReferenceSelector::selectMemoryMap()\r\n//-----------------------------------------------------------------------------\r\nvoid ReferenceSelector::selectItem(QString const& itemName)\r\n{\r\n\tdisconnect(this, SIGNAL(currentIndexChanged(int)), this, SLOT(onIndexChange(int)));\r\n\r\n\tint index = findText(itemName);\r\n    if (!itemName.isEmpty() && index == -1)\r\n    {\r\n        setTextColor(Qt::red);\r\n\r\n        addItem(itemName);\r\n        index = findText(itemName);\r\n\r\n        setItemData(index, KactusColors::ERROR, Qt::ForegroundRole);\r\n        setItemIcon(index, QIcon(QPixmap(\":/icons/common/graphics/exclamation.png\")));\r\n    }\r\n    else if (!isEnabled())\r\n    {\r\n        setTextColor(Qt::gray);\r\n    }\r\n    else\r\n    {\r\n        setTextColor(Qt::black);\r\n    }\r\n\r\n    setCurrentIndex(index);\r\n\r\n\tconnect(this, SIGNAL(currentIndexChanged(int)),\tthis, SLOT(onIndexChange(int)), Qt::UniqueConnection);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ReferenceSelector::onIndexChange()\r\n//-----------------------------------------------------------------------------\r\nvoid ReferenceSelector::onIndexChange(int newIndex)\r\n{\r\n    if (itemIcon(newIndex).isNull())\r\n    {\r\n        setTextColor(Qt::black);\r\n    }\r\n    else\r\n    {\r\n        setTextColor(Qt::red);\r\n    }\r\n\r\n\t// find the text for the index\r\n\tQString text = itemText(newIndex);\r\n\temit itemSelected(text);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ReferenceSelector::changeEvent()\r\n//-----------------------------------------------------------------------------\r\nvoid ReferenceSelector::changeEvent(QEvent *currentEvent)\r\n{\r\n    QComboBox::changeEvent(currentEvent);\r\n\r\n    if (currentEvent->type() == QEvent::EnabledChange)\r\n    {\r\n        QPalette usedPalette = palette();\r\n        if (usedPalette.color(QPalette::Text) != Qt::red)\r\n        {\r\n            if (isEnabled())\r\n            {\r\n                usedPalette.setColor(QPalette::Text, Qt::black);\r\n            }\r\n            else\r\n            {\r\n                usedPalette.setColor(QPalette::Text, Qt::gray);\r\n            }\r\n        }\r\n\r\n        setPalette(usedPalette);\r\n    }\r\n}"
  },
  {
    "path": "editors/ComponentEditor/common/ReferenceSelector/ReferenceSelector.h",
    "content": "/* \r\n *  \tCreated on: 21.6.2012\r\n *      Author: Antti Kamppi\r\n * \t\tfilename: memorymapselector.h\r\n *\t\tProject: Kactus2\r\n */\r\n\r\n#ifndef REFERENCESELECTOR_H\r\n#define REFERENCESELECTOR_H\r\n\r\n\r\n#include <QComboBox>\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Combo box to select a name reference.\r\n//-----------------------------------------------------------------------------\r\nclass ReferenceSelector : public QComboBox\r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\r\n\t/*! The constructor.\r\n\t *\r\n\t * \\param component Pointer to the component that's memory maps are being selected.\r\n\t * \\param parent Pointer to the owner of this editor.\r\n\t *\r\n\t*/\r\n\tReferenceSelector(QWidget *parent);\r\n\t\r\n\t//! The destructor.\r\n\tvirtual ~ReferenceSelector();\r\n\r\n    /*!\r\n     *  Sets the color of the text of the current text.\r\n     *\r\n     *    @param [in] color   The color to set.\r\n     */\r\n    void setTextColor(QColor const& color);\r\n\r\npublic slots:\r\n\r\n\t//! Refresh the items to be selected in the combo box.\r\n    void refresh(QStringList const& itemNames);\r\n\r\n\t/*! Set the specified memory map as selected.\r\n\t *\r\n\t * \\param memoryMapName The name of the memory map to select.\r\n\t *\r\n\t*/\r\n    void selectItem(QString const& itemName);\r\n\r\nprotected:\r\n\r\n    /*!\r\n     *  Handles the change events and changes the text colour depengin on the enabled state of the component.\r\n     *\r\n     *    @param [in] currentEvent    The current change event.\r\n     */\r\n    virtual void changeEvent(QEvent *currentEvent);\r\n\r\nsignals:\r\n\r\n\t//! Emitted when memory map was selected by user.\r\n\tvoid itemSelected(QString const& memoryMapName);\r\n\r\nprivate slots:\r\n\r\n\t//! Handler for selected index changes.\r\n\tvoid onIndexChange(int newIndex);\r\n\r\nprivate:\r\n\t\r\n\t//! No copying\r\n\tReferenceSelector(const ReferenceSelector& other);\r\n\r\n\t//! No assignment\r\n\tReferenceSelector& operator=(const ReferenceSelector& other);\r\n\r\n};\r\n\r\n#endif // REFERENCESELECTOR_H\r\n"
  },
  {
    "path": "editors/ComponentEditor/common/ReferencingTableModel.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ReferencingTableModel.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Mikko Teuho\r\n// Date: 26.03.2015\r\n//\r\n// Description:\r\n// Base class for table model properties for editable tables.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"ReferencingTableModel.h\"\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ReferencingTableModel::ReferencingTableModel()\r\n//-----------------------------------------------------------------------------\r\nReferencingTableModel::ReferencingTableModel(QSharedPointer<ParameterFinder> parameterFinder, QObject *parent):\r\nQAbstractTableModel(parent),\r\nparameterFinder_(parameterFinder)\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ReferencingTableModel::~ReferencingTableModel()\r\n//-----------------------------------------------------------------------------\r\nReferencingTableModel::~ReferencingTableModel()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ReferencingTableModel::removeReferencesInItemOnRow()\r\n//-----------------------------------------------------------------------------\r\nvoid ReferencingTableModel::removeReferencesInItemOnRow(const int& row) const\r\n{\r\n    for (QString const& valueID : parameterFinder_->getAllParameterIds())\r\n    {\r\n        int totalreferences = getAllReferencesToIdInItemOnRow(row, valueID);\r\n        for (int i = 0; i < totalreferences; ++i)\r\n        {\r\n            emit decreaseReferences(valueID);\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ReferencingTableModel::removeReferencesFromSingleExpression()\r\n//-----------------------------------------------------------------------------\r\nvoid ReferencingTableModel::removeReferencesFromSingleExpression(QString const& expression) const\r\n{\r\n    QStringList allParameterIds = parameterFinder_->getAllParameterIds();\r\n    for (QString const& valueID : allParameterIds)\r\n    {\r\n        int referencesToId = expression.count(valueID);\r\n        for (int i = 0; i < referencesToId; ++i)\r\n        {\r\n            emit decreaseReferences(valueID);\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ReferencingTableModel::getUniqueName()\r\n//-----------------------------------------------------------------------------\r\nQString ReferencingTableModel::getUniqueName(QString const& originalName, QStringList currentNames) const\r\n{\r\n    QString name = originalName;\r\n    int trailingNumber = 1;\r\n\r\n    bool match =  true;\r\n    while (match)\r\n    {\r\n        match = false;        \r\n        for (int row = 0; row < currentNames.size(); row++)\r\n        {\r\n            if (name.compare(currentNames.at(row)) == 0)\r\n            {\r\n                match = true;\r\n                name = originalName + \"_\" + QString::number(trailingNumber);\r\n                trailingNumber++;\r\n            }\r\n        }\r\n    }\r\n\r\n    return name;\r\n}\r\n"
  },
  {
    "path": "editors/ComponentEditor/common/ReferencingTableModel.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ReferencingTableModel.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Mikko Teuho\r\n// Date: 26.03.2015\r\n//\r\n// Description:\r\n// Base class for table model properties for editable tables.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef REFERENCINGTABLEMODEL_H\r\n#define REFERENCINGTABLEMODEL_H\r\n\r\n#include <KactusAPI/include/ParameterFinder.h>\r\n\r\n#include <QAbstractTableModel>\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Base class for table model properties for editable tables.\r\n//-----------------------------------------------------------------------------\r\nclass ReferencingTableModel : public QAbstractTableModel\r\n{\r\n    Q_OBJECT\r\n\r\npublic:\r\n\r\n    /*!\r\n     *  [Description].\r\n     *\r\n     *    @param [in] parameterFinder     The parameter finder.\r\n     *    @param [in] parent              The owner of this table.\r\n     */\r\n    ReferencingTableModel(QSharedPointer<ParameterFinder> parameterFinder, QObject *parent);\r\n\r\n    /*!\r\n     *  The destructor.\r\n     */\r\n    virtual ~ReferencingTableModel();\r\n\r\nprotected:\r\n\r\n    /*!\r\n     *  Remove all the references to all parameters from the item on the selected row.\r\n     *\r\n     *    @param [in] row     The row of the selected item.\r\n     */\r\n    void removeReferencesInItemOnRow(const int& row) const;\r\n\r\n    /*!\r\n     *  Gets the number of all the references made to a selected id on the selected row.\r\n     *\r\n     *    @param [in] row         The row of the selected item.\r\n     *    @param [in] valueID     The id of the referenced parameter.\r\n     *\r\n     *    @return The amount of references made to the selected id on the selected row.\r\n     */\r\n    virtual int getAllReferencesToIdInItemOnRow(const int& row, QString const& valueID) const = 0;\r\n\r\n    /*!\r\n     *  Remove all the references from a single expression.\r\n     *\r\n     *    @param [in] expression  The expression, where to seek the references.\r\n     */\r\n    void removeReferencesFromSingleExpression(QString const& expression) const;\r\n\r\n    /*!\r\n     *  Get the unique name from the selected name.\r\n     *\r\n     *    @param [in] originalName    The selected name.\r\n     *    @param [in] currentNames    A list of already used names.\r\n     *\r\n     *    @return A unique name created from the selected name.\r\n     */\r\n    QString getUniqueName(QString const& originalName, QStringList currentNames) const;\r\n\r\nsignals:\r\n\r\n    /*!\r\n     *  Decrease the amount of references to the selected parameter.\r\n     *\r\n     *    @param [in] valueId   The id of the referenced parameter.\r\n     */\r\n    void decreaseReferences(const QString& valueId) const;\r\n\r\n    /*!\r\n     *  Increase the amount of references to the selected parameter.\r\n     *\r\n     *    @param [in] valueId   The id of the referenced parameter.\r\n     */\r\n    void increaseReferences(QString const& parameterID);\r\n\r\nprivate:\r\n\r\n    //! Disable copying and assignment.\r\n    ReferencingTableModel(const ReferencingTableModel& other);\r\n    ReferencingTableModel& operator=(const ReferencingTableModel& other);\r\n\r\n    //! The parameter finder.\r\n    QSharedPointer<ParameterFinder> parameterFinder_;\r\n};\r\n\r\n#endif // REFERENCINGTABLEMODEL_H\r\n"
  },
  {
    "path": "editors/ComponentEditor/componenteditor.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: componenteditor.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 16.5.2012\r\n//\r\n// Description:\r\n// The editor to edit/packet IP-Xact components.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"componenteditor.h\"\r\n\r\n#include <KactusAPI/include/LibraryInterface.h>\r\n\r\n#include <editors/ComponentEditor/treeStructure/componenteditorrootitem.h>\r\n#include <editors/ComponentEditor/treeStructure/componenteditorgeneralitem.h>\r\n#include <editors/ComponentEditor/treeStructure/componenteditorfilesetsitem.h>\r\n#include <editors/ComponentEditor/treeStructure/componenteditorparametersitem.h>\r\n#include <editors/ComponentEditor/treeStructure/componenteditormemmapsitem.h>\r\n#include <editors/ComponentEditor/treeStructure/componenteditoraddrspacesitem.h>\r\n#include <editors/ComponentEditor/treeStructure/componenteditorviewsitem.h>\r\n#include <editors/ComponentEditor/treeStructure/componenteditorportsitem.h>\r\n#include <editors/ComponentEditor/treeStructure/componenteditorbusinterfacesitem.h>\r\n#include <editors/ComponentEditor/treeStructure/componenteditorchannelsitem.h>\r\n#include <editors/ComponentEditor/treeStructure/ComponentEditorChoicesItem.h>\r\n#include <editors/ComponentEditor/treeStructure/componenteditorcpusitem.h>\r\n#include <editors/ComponentEditor/treeStructure/componenteditorotherclocksitem.h>\r\n#include <editors/ComponentEditor/treeStructure/ResetTypesItem.h>\r\n#include <editors/ComponentEditor/treeStructure/componenteditorcominterfacesitem.h>\r\n#include <editors/ComponentEditor/treeStructure/componenteditorapiinterfacesitem.h>\r\n#include <editors/ComponentEditor/treeStructure/componenteditorswpropertiesitem.h>\r\n#include <editors/ComponentEditor/treeStructure/ComponentEditorSystemViewsItem.h>\r\n#include <editors/ComponentEditor/treeStructure/RemapStatesItem.h>\r\n#include <editors/ComponentEditor/treeStructure/ModesItem.h>\r\n#include <editors/ComponentEditor/treeStructure/PowerDomainsItem.h>\r\n#include <editors/ComponentEditor/treeStructure/componenteditortreemodel.h>\r\n#include <editors/ComponentEditor/treeStructure/InstantiationsItem.h>\r\n#include <editors/ComponentEditor/treeStructure/TypeDefinitionsItem.h>\r\n#include <editors/ComponentEditor/treeStructure/ComponentEditorIndirectInterfacesItem.h>\r\n#include <editors/ComponentEditor/treeStructure/componenteditoritem.h>\r\n#include <editors/ComponentEditor/treeStructure/ComponentEditorTreeSortProxyModel.h>\r\n#include <editors/ComponentEditor/treeStructure/ComponentEditorTreeDelegate.h>\r\n#include <editors/ComponentEditor/treeStructure/WirePortsItem.h>\r\n\r\n#include <editors/ComponentEditor/parameterReferenceTree/ComponentParameterReferenceTree.h>\r\n#include <editors/ComponentEditor/parameterReferenceTree/ParameterReferenceTreeWindow.h>\r\n\r\n#include <editors/ComponentEditor/general/generaleditor.h>\r\n\r\n#include <editors/common/ExpressionSet.h>\r\n\r\n#include <KactusAPI/include/ParameterCache.h>\r\n#include <KactusAPI/include/IPXactSystemVerilogParser.h>\r\n#include <KactusAPI/include/ComponentAndInstantiationsParameterFinder.h>\r\n#include <KactusAPI/include/ModeConditionParserInterface.h>\r\n\r\n#include <common/dialogs/newObjectDialog/newobjectdialog.h>\r\n#include <common/dialogs/comboSelector/comboselector.h>\r\n\r\n#include <editors/ComponentEditor/itemeditor.h>\r\n#include <editors/ComponentEditor/itemvisualizer.h>\r\n\r\n#include <IPXACTmodels/common/TagData.h>\r\n\r\n#include <IPXACTmodels/Component/Component.h>\r\n#include <IPXACTmodels/Component/FileSet.h>\r\n#include <IPXACTmodels/Component/validators/ComponentValidator.h>\r\n\r\n#include <KactusAPI/include/BusInterfaceInterface.h>\r\n#include <KactusAPI/include/BusInterfaceInterfaceFactory.h>\r\n#include <KactusAPI/include/AbstractionTypeInterface.h>\r\n#include <KactusAPI/include/PortMapInterface.h>\r\n\r\n#include <QMessageBox>\r\n#include <QFileDialog>\r\n#include <QFileInfo>\r\n#include <QHBoxLayout>\r\n#include <QApplication>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditor::ComponentEditor()\r\n//-----------------------------------------------------------------------------\r\nComponentEditor::ComponentEditor(LibraryInterface* libHandler, QSharedPointer<Component> component, QWidget* parent) :\r\nTabDocument(parent, libHandler, DOC_PROTECTION_SUPPORT),\r\ncomponent_(component),\r\nnavigationSplitter_(Qt::Horizontal, this),\r\neditorVisualizerSplitter_(Qt::Horizontal, &navigationSplitter_),\r\nnavigationModel_(this),\r\nnavigationView_(libHandler, component->getVlnv(), &navigationSplitter_),\r\nproxy_(this),\r\neditorSlot_(&editorVisualizerSplitter_),\r\nvisualizerSlot_(&editorVisualizerSplitter_),\r\n//! \r\n//! This is the reason for weird sorting of the parameters, parameter cache uses uuid as the key, which is semi-random and causes weird sorting behaviour.\r\n//! \r\nparameterFinder_(new ParameterCache(component_)),\r\nfullParameterFinder_(QSharedPointer<ComponentAndInstantiationsParameterFinder>(\r\n    new ComponentAndInstantiationsParameterFinder(component))),\r\nreferenceCounter_(QSharedPointer<ComponentParameterReferenceCounter>(new ComponentParameterReferenceCounter(\r\n    fullParameterFinder_, component))),\r\nexpressionFormatter_(new ExpressionFormatter(parameterFinder_)),\r\nexpressionParser_(new IPXactSystemVerilogParser(parameterFinder_)),\r\nmodeConditionParserInterface_(new ModeConditionParserInterface(parameterFinder_)),\r\nvalidator_(new ComponentValidator(expressionParser_, modeConditionParserInterface_, getLibHandler(), component->getRevision()))\r\n{\r\n    QSharedPointer<ExpressionFormatter> fullFormatter(new ExpressionFormatter(fullParameterFinder_));\r\n    parameterReferenceTree_ =\r\n        new ComponentParameterReferenceTree(component_, fullFormatter, referenceCounter_);\r\n    parameterReferenceWindow_ = new ParameterReferenceTreeWindow(parameterReferenceTree_, this);\r\n\r\n    supportedWindows_ |= TabDocument::VENDOREXTENSIONWINDOW;\r\n\r\n    // these can be used when debugging to identify the objects\r\n\tsetObjectName(tr(\"ComponentEditor\"));\r\n\tnavigationSplitter_.setObjectName(tr(\"NavigationSplitter\"));\r\n\teditorVisualizerSplitter_.setObjectName(tr(\"EditorVisualizerSplitter\"));\r\n\teditorSlot_.setObjectName(tr(\"EditorSlot\"));\r\n\tvisualizerSlot_.setObjectName(tr(\"VisualizerSlot\"));\r\n\r\n\tQ_ASSERT(component_);\r\n\tQ_ASSERT(getLibHandler());\r\n\r\n\t// set the name and type for the tab\r\n    setDocumentName(QString(\"%1 (%2)\").arg(component_->getVlnv().getName(), component_->getVlnv().getVersion()));\r\n\r\n    if (component_->getImplementation() == KactusAttribute::HW)\r\n    {\r\n        setDocumentType(DocumentType::HW_COMPONENT);\r\n    }\r\n    else if (component_->getImplementation() == KactusAttribute::SW)\r\n    {\r\n        setDocumentType(DocumentType::SW_COMPONENT);\r\n    }\r\n    else if (component_->getImplementation() == KactusAttribute::SYSTEM)\r\n    {\r\n        setDocumentType(DocumentType::UNMAPPED_SYSTEM);\r\n    }\r\n\r\n    addRelatedVLNV(component_->getVlnv());\r\n\r\n    setupLayout();\r\n\r\n\t// set the component to be displayed in the navigation model\r\n    navigationModel_.setRootItem(createNavigationRootForComponent());\r\n\r\n\tQSettings settings;\r\n\tsetRowVisibility(settings);\r\n\r\n    // Set source model for the proxy.\r\n    proxy_.setSourceModel(&navigationModel_);\r\n\r\n    navigationView_.setItemDelegate(new ComponentEditorTreeDelegate(this));\r\n\r\n\t// connect the view with the model (proxy) and sort.\r\n\tnavigationView_.setModel(&proxy_);\r\n    navigationView_.sortByColumn(0, Qt::AscendingOrder);\r\n\r\n\t// when starting the component editor open the general editor.\r\n\tonItemActivated(proxy_.index(0, 0, QModelIndex()));\r\n\r\n\t// navigation model may request an item to be expanded\r\n\tconnect(&navigationModel_, SIGNAL(expandItem(const QModelIndex&)),\r\n\t\tthis, SLOT(onExpand(const QModelIndex&)), Qt::UniqueConnection);\r\n\r\n\tconnect(&navigationView_, SIGNAL(activated(const QModelIndex&)),\r\n\t\tthis, SLOT(onItemActivated(const QModelIndex&)), Qt::UniqueConnection);\r\n\r\n\tconnect(&navigationModel_, SIGNAL(dataChanged(const QModelIndex&, const QModelIndex&)),\r\n\t\t    this, SIGNAL(contentChanged()), Qt::UniqueConnection);\r\n    connect(&navigationModel_, SIGNAL(contentChanged()), this, SIGNAL(contentChanged()), Qt::UniqueConnection);\r\n    connect(&navigationModel_, SIGNAL(helpUrlRequested(QString const&)),\r\n            this, SIGNAL(helpUrlRequested(QString const&)), Qt::UniqueConnection);\r\n\tconnect(&navigationModel_, SIGNAL(errorMessage(const QString&)),\r\n\t\tthis, SLOT(onErrorDialog(const QString&)), Qt::UniqueConnection);\r\n\r\n    connect(&navigationModel_, SIGNAL(openCSource(QString const&, QSharedPointer<Component>)),\r\n            this, SIGNAL(openCSource(QString const&, QSharedPointer<Component>)), Qt::UniqueConnection);\r\n\r\n\tconnect(&navigationModel_, SIGNAL(selectItem(const QModelIndex&)),\r\n\t\tthis, SLOT(onNavigationTreeSelection(const QModelIndex&)), Qt::UniqueConnection);\r\n\tconnect(&navigationModel_, SIGNAL(openDesign(const VLNV&, const QString&)),\r\n\t\tthis, SIGNAL(openDesign(const VLNV&, const QString&)), Qt::UniqueConnection);\r\n\r\n    connect(&navigationModel_, SIGNAL(openAbsDef(const VLNV&)),\r\n        this, SIGNAL(openAbsDef(const VLNV&)), Qt::UniqueConnection);\r\n\r\n\tconnect(&navigationModel_, SIGNAL(openBus(const VLNV&)),\r\n\t\tthis, SIGNAL(openBus(const VLNV&)), Qt::UniqueConnection);\r\n\r\n\tconnect(&navigationModel_, SIGNAL(openComDefinition(const VLNV&)),\r\n\t\tthis, SIGNAL(openComDefinition(const VLNV&)), Qt::UniqueConnection);\r\n\tconnect(&navigationModel_, SIGNAL(openSWDesign(const VLNV&, const QString&)),\r\n\t\tthis, SIGNAL(openSWDesign(const VLNV&, const QString&)), Qt::UniqueConnection);\r\n\tconnect(&navigationModel_, SIGNAL(openSystemDesign(const VLNV&, const QString&)),\r\n\t\tthis, SIGNAL(openSystemDesign(const VLNV&, const QString&)), Qt::UniqueConnection);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditor::getIdentifyingVLNV()\r\n//-----------------------------------------------------------------------------\r\nVLNV ComponentEditor::getIdentifyingVLNV() const\r\n{\r\n    return getDocumentVLNV();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditor::getDocumentVLNV()\r\n//-----------------------------------------------------------------------------\r\nVLNV ComponentEditor::getDocumentVLNV() const\r\n{\r\n\treturn component_->getVlnv();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditor::isHWImplementation()\r\n//-----------------------------------------------------------------------------\r\nbool ComponentEditor::isHWImplementation() const\r\n{\r\n    return component_->getImplementation() == KactusAttribute::HW;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditor::refresh()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentEditor::refresh()\r\n{\r\n\tQApplication::setOverrideCursor(QCursor(Qt::WaitCursor));\r\n\r\n\t// remember the locked state\r\n\tbool locked = isProtected();\r\n\r\n\t// clear the slots\r\n\teditorSlot_.setWidget(nullptr);\r\n\tvisualizerSlot_.setWidget(nullptr);\r\n\r\n\t// get the VLNV of the component\r\n\tVLNV compVLNV = component_->getVlnv();\r\n\r\n\t// get the original model of the component\r\n\tQSharedPointer<Component> comp = getLibHandler()->getModel<Component>(compVLNV);\r\n\t//Q_ASSERT(comp.isNull() == false);\r\n\r\n    if (comp.isNull())\r\n    {\r\n        delete this;\r\n        QApplication::restoreOverrideCursor();\r\n        return;\r\n    }\r\n\t// rebuild the navigation tree\r\n\tcomponent_ = comp;\r\n\tnavigationModel_.setRootItem(createNavigationRootForComponent());\r\n\t//component_.clear();\r\n\r\n    referenceCounter_->setComponent(component_);\r\n    parameterReferenceTree_->setComponent(component_);\r\n\r\n    parameterFinder_->setComponent(comp);\r\n    fullParameterFinder_->setComponent(comp);\r\n\r\n\t// open the general editor.\r\n\tonItemActivated(proxy_.index(0, 0, QModelIndex()));\r\n\r\n\t// the document is no longer modified\r\n\tsetModified(false);\r\n\tTabDocument::refresh();\r\n\r\n\t// set the protection state to same as before refreshing\r\n\tsetProtection(locked);\r\n\r\n\tQApplication::restoreOverrideCursor();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditor::applySettings()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentEditor::applySettings(QSettings& settings)\r\n{\r\n    TabDocument::applySettings(settings);\r\n\tsetRowVisibility(settings);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: componenteditor::getHwItemNames()\r\n//-----------------------------------------------------------------------------\r\nQStringList ComponentEditor::getHwItemNames()\r\n{\r\n\tQStringList itemNames;\r\n\r\n\titemNames << \"File_sets\" << \"Choices\" << \"Parameters\" << \"Memory_maps\" <<\r\n\t\t\"Address_spaces\" << \"Instantiations\" << \"Views\" << \"Software_views\" << \"System_views\" << \"Ports\" <<\r\n        \"Bus_interfaces\" << \"Indirect_interfaces\" << \"Channels\" << \"Remap_states\" << \"Cpus\" <<\r\n        \"Other_clock_drivers\" << \"Reset_types\" << \"COM_interfaces\" << \"Software_properties\" << \r\n        \"Type_definitions\" << \"Modes\" << \"Power_domains\";\r\n\r\n\treturn itemNames;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: componenteditor::getSwItemNames()\r\n//-----------------------------------------------------------------------------\r\nQStringList ComponentEditor::getSwItemNames()\r\n{\r\n\tQStringList itemNames;\r\n\r\n\titemNames << \"File_sets\" << \"Choices\" << \"Parameters\" << \"Software_views\" << \"COM_interfaces\" <<\r\n\t\t\"API_interfaces\" << \"Software_properties\";\r\n\r\n\treturn itemNames;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditor::validate()\r\n//-----------------------------------------------------------------------------\r\nbool ComponentEditor::validate(QVector<QString>& errorList)\r\n{\r\n    if (validator_->validate(component_) == false)\r\n    {\r\n        validator_->findErrorsIn(errorList, component_);\r\n        return false;\r\n    }\r\n\r\n    return true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditor::save()\r\n//-----------------------------------------------------------------------------\r\nbool ComponentEditor::save()\r\n{\r\n\tif (getLibHandler()->writeModelToFile(component_))\r\n    {\r\n        navigationModel_.clearItemsModified();\r\n\t\treturn TabDocument::save();\r\n\t}\r\n\telse\r\n    {\r\n\t\temit errorMessage(tr(\"Component was not saved to disk.\"));\r\n\t\treturn false;\r\n\t}\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditor::saveAs()\r\n//-----------------------------------------------------------------------------\r\nbool ComponentEditor::saveAs()\r\n{\r\n\t// Ask the user for a new VLNV along with attributes and directory.\r\n    KactusAttribute::ProductHierarchy prodHier = component_->getHierarchy();\r\n    KactusAttribute::Firmness firmness = component_->getFirmness();\r\n    QVector<TagData> tags = component_->getTags();\r\n\r\n\tVLNV vlnv;\r\n\tQString directory;\r\n\r\n    if (component_->getImplementation() == KactusAttribute::HW)\r\n    {\r\n\t    if (!NewObjectDialog::saveAsDialog(\r\n            parentWidget(), getLibHandler(), component_->getVlnv(), prodHier, firmness, tags, vlnv, directory))\r\n        {\r\n\t\t    return false;\r\n\t    }\r\n    }\r\n    else\r\n    {\r\n        if (!NewObjectDialog::saveAsDialog(parentWidget(), getLibHandler(), component_->getVlnv(), vlnv, directory))\r\n        {\r\n            return false;\r\n        }\r\n    }\r\n\r\n\t// save pointer to the old component\r\n\tQSharedPointer<Component> oldComponent = component_;\r\n\r\n\t// create copies of the objects so saving is not done to the original component\r\n\tcomponent_ = QSharedPointer<Component>(new Component(*component_));\r\n\r\n\t// make sure the vlnv type is correct\r\n\tVLNV compVLNV = vlnv;\r\n\tcompVLNV.setType(VLNV::COMPONENT);\r\n\r\n\t// update the vlnv\r\n\tcomponent_->setVlnv(vlnv);\r\n    component_->setHierarchy(prodHier);\r\n    component_->setFirmness(firmness);\r\n\r\n\t// get the paths to the original xml file\r\n\tQFileInfo sourceInfo(getLibHandler()->getPath(oldComponent->getVlnv()));\r\n\tQString sourcePath = sourceInfo.absolutePath();\r\n\r\n\t// update the file paths and copy necessary files\r\n    updateComponentFiles(component_, oldComponent, sourcePath, directory);\r\n\r\n\t// Write the component to a file.\r\n\tif (getLibHandler()->writeModelToFile(directory, component_))\r\n    {\r\n\t\tsetDocumentName(compVLNV.getName() + \" (\" + compVLNV.getVersion() + \")\");\r\n        navigationModel_.clearItemsModified();\r\n\t\treturn TabDocument::saveAs();\r\n\t}\r\n\telse\r\n    {\r\n\t\temit errorMessage(tr(\"Component was not saved to disk.\"));\r\n\t\treturn false;\r\n\t}\r\n\r\n    clearRelatedVLNVs();\r\n    addRelatedVLNV(compVLNV);\r\n\r\n    return true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditor::onNavigationTreeSelection()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentEditor::onNavigationTreeSelection( const QModelIndex& index )\r\n{\r\n\tnavigationView_.setCurrentIndex(index);\r\n\tonItemActivated(index);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditor::onExpand()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentEditor::onExpand(const QModelIndex& index)\r\n{\r\n    // Expand parents until root is hit.\r\n    QModelIndex parentIndex = index;\r\n    while(parentIndex.isValid())\r\n    {\r\n        navigationView_.expand(proxy_.mapFromSource(parentIndex));\r\n        parentIndex = parentIndex.parent();\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditor::onErrorDialog()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentEditor::onErrorDialog(const QString& message)\r\n{\r\n    QMessageBox::warning(this, tr(\"Component editor\"), message);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditor::onItemActivated()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentEditor::onItemActivated( const QModelIndex& index )\r\n{\r\n    // If tree proxy model index is used, the item must be retrieved from the source model.\r\n    auto const indexModel = dynamic_cast<const ComponentEditorTreeProxyModel*>(index.model());\r\n\tComponentEditorItem* item = nullptr;\r\n    if ( indexModel == nullptr )\r\n    {\r\n        item = static_cast<ComponentEditorItem*>(index.internalPointer());\r\n    }\r\n    else\r\n    {\r\n        item = static_cast<ComponentEditorItem*>(proxy_.mapToSource(index).internalPointer());\r\n    }\r\n\r\n    Q_ASSERT(item);\r\n\r\n\tQList<int> editorVisualizerSizes;\r\n\r\n\tItemEditor* editor = item->editor();\r\n\tif (editor)\r\n    {\r\n\t\t// the width of the previous editor\r\n\t\tif (QWidget* prevEditor = editorSlot_.getWidget(); prevEditor != nullptr)\r\n        {\r\n\t\t\tint prevWidth = prevEditor->size().width();\r\n\t\t\teditorVisualizerSizes.append(prevWidth);\r\n\t\t}\r\n\t\t// if there was no previous editor then use the size hint\r\n\t\telse\r\n        {\r\n\t\t\teditorVisualizerSizes.append(editor->sizeHint().width());\r\n\t\t}\r\n\t\teditor->refresh();\r\n\t}\r\n\t// if there is no editor then hide the editor slot\r\n\telse\r\n    {\r\n\t\teditorVisualizerSizes.append(0);\r\n\t}\r\n\teditorSlot_.setWidget(editor);\r\n\r\n\tItemVisualizer* visualizer = item->visualizer();\r\n\tif (visualizer)\r\n    {\r\n\t\t// the width of the previous visualizer\r\n\t\tif (QWidget* prevVisualizer = visualizerSlot_.getWidget(); prevVisualizer)\r\n        {\r\n\t\t\tint prevWidth = prevVisualizer->size().width();\r\n\t\t\teditorVisualizerSizes.append(prevWidth);\r\n\t\t}\r\n\t\t// if there was no previous visualizer then use the size hint\r\n\t\telse\r\n        {\r\n\t\t\teditorVisualizerSizes.append(visualizer->sizeHint().width());\r\n\t\t}\r\n\t}\r\n\t// if there is no visualizer then hide the visualizer slot\r\n\telse\r\n    {\r\n\t\teditorVisualizerSizes.append(0);\r\n\t}\r\n\tvisualizerSlot_.setWidget(visualizer);\r\n\r\n\teditorVisualizerSplitter_.setSizes(editorVisualizerSizes);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditor::setProtection()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentEditor::setProtection( bool locked )\r\n{\r\n    TabDocument::setProtection(locked);\r\n\r\n    // tell tree items to change the state of the editors\r\n    navigationModel_.setLocked(locked);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditor::setRowVisibility()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentEditor::setRowVisibility(QSettings& settings)\r\n{\r\n    QString workSpace = settings.value(\"Workspaces/CurrentWorkspace\").toString();\r\n\r\n    settings.beginGroup(\"Workspaces/\" + workSpace + \"/ComponentEditorFilters\");\r\n\r\n    if (isHWImplementation())\r\n    {\r\n        settings.beginGroup(\"HW\");\r\n        settings.beginGroup(KactusAttribute::hierarchyToString(component_->getHierarchy()));\r\n    }\r\n    else\r\n    {\r\n        settings.beginGroup(\"SW\");\r\n    }\r\n\r\n    // List of the hidden rows in component editor.\r\n    QStringList hiddenRows;\r\n    for (auto name : settings.childKeys())\r\n    {\r\n        if (settings.value(name, true).toBool() == false)\r\n        {\r\n            QString wordReplaced = name.replace(\"_\",\" \");\r\n            hiddenRows.append(wordReplaced);\r\n        }\r\n    }\r\n\r\n    if (isHWImplementation())\r\n    {\r\n        // End hierarchy group.\r\n        settings.endGroup();\r\n    }\r\n\r\n    // End hardware or software group.\r\n    settings.endGroup();\r\n\r\n    // End Workspace/CurrentWorkspace/ComponentEditorFilters group.\r\n    settings.endGroup();\r\n\r\n    proxy_.setRowVisibility( hiddenRows );\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditor::createNavigationRootForComponent()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<ComponentEditorRootItem> ComponentEditor::createNavigationRootForComponent()\r\n{\r\n    ExpressionSet expressionsSupport({ parameterFinder_, expressionParser_, expressionFormatter_});\r\n\r\n    auto root = new ComponentEditorRootItem(getLibHandler(), component_, &navigationModel_);\r\n\r\n    if (component_->getImplementation() == KactusAttribute::SW)\r\n    {\r\n        addSWItems(root);\r\n    }\r\n    else\r\n    {\r\n        addHWItems(root, expressionsSupport);\r\n    }\r\n\r\n    return QSharedPointer<ComponentEditorRootItem>(root);\r\n}\r\n\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditor::addSWItems()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentEditor::addSWItems(ComponentEditorRootItem* root)\r\n{\r\n    root->addChildItem(createGeneralItem(root));\r\n\r\n    root->addChildItem(QSharedPointer<ComponentEditorFileSetsItem>(new ComponentEditorFileSetsItem(\r\n        &navigationModel_, getLibHandler(), component_, referenceCounter_, parameterFinder_,\r\n        expressionParser_, expressionFormatter_, root)));\r\n\r\n    root->addChildItem(createInstantiationsItem(root));\r\n\r\n    root->addChildItem(createViewsItem(root));\r\n\r\n    root->addChildItem(QSharedPointer<ComponentEditorAPIInterfacesItem>(\r\n        new ComponentEditorAPIInterfacesItem(&navigationModel_, getLibHandler(), component_, root)));\r\n\r\n    root->addChildItem(QSharedPointer<ComponentEditorComInterfacesItem>(\r\n        new ComponentEditorComInterfacesItem(&navigationModel_, getLibHandler(), component_, root)));\r\n\r\n    root->addChildItem(QSharedPointer<ComponentEditorSWPropertiesItem>(\r\n        new ComponentEditorSWPropertiesItem(&navigationModel_, getLibHandler(), component_, root)));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditor::addHWItems()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentEditor::addHWItems(ComponentEditorRootItem* root,\r\n    ExpressionSet const& expressionsSupport)\r\n{\r\n    root->addChildItem(createGeneralItem(root));\r\n\r\n    root->addChildItem(QSharedPointer<ComponentEditorChoicesItem>(\r\n        new ComponentEditorChoicesItem(&navigationModel_, getLibHandler(), component_, expressionParser_, root)));\r\n\r\n    root->addChildItem(createParametersItem(root));\r\n\r\n    auto docRevision = component_->getRevision();\r\n    // TODO: Enable, when type definitions are supported.\r\n    if (docRevision == Document::Revision::Std22)\r\n    {\r\n        root->addChildItem(QSharedPointer<TypeDefinitionsItem>(new TypeDefinitionsItem(&navigationModel_,\r\n            getLibHandler(), component_, root)));\r\n    }\r\n\r\n    root->addChildItem(QSharedPointer<ComponentEditorFileSetsItem>(new ComponentEditorFileSetsItem(\r\n        &navigationModel_, getLibHandler(), component_, referenceCounter_, parameterFinder_,\r\n        expressionParser_, expressionFormatter_, root)));\r\n\r\n    root->addChildItem(QSharedPointer<ComponentEditorMemMapsItem>(new ComponentEditorMemMapsItem(\r\n        &navigationModel_, getLibHandler(), component_, referenceCounter_, parameterFinder_, expressionFormatter_,\r\n        expressionParser_, root)));\r\n\r\n    root->addChildItem(QSharedPointer<ComponentEditorAddrSpacesItem>(new ComponentEditorAddrSpacesItem(\r\n        &navigationModel_, getLibHandler(), component_, referenceCounter_, parameterFinder_, expressionFormatter_,\r\n        expressionParser_, root)));\r\n\r\n    root->addChildItem(createInstantiationsItem(root));\r\n\r\n    root->addChildItem(createViewsItem(root));\r\n\r\n\r\n    root->addChildItem(QSharedPointer<ComponentEditorSystemViewsItem>(new ComponentEditorSystemViewsItem(\r\n        &navigationModel_, getLibHandler(), component_, parameterFinder_, expressionParser_, expressionFormatter_,\r\n        root)));\r\n\r\n    auto busInterface = BusInterfaceInterfaceFactory::createBusInterface(parameterFinder_, expressionFormatter_,\r\n        expressionParser_, component_, getLibHandler());\r\n\r\n    auto absTypeInterface = busInterface->getAbstractionTypeInterface();\r\n    Q_ASSERT(absTypeInterface);\r\n\r\n    auto portMapInterface = absTypeInterface->getPortMapInterface();\r\n    Q_ASSERT(portMapInterface);\r\n\r\n    root->addChildItem(createPortsItem(root, busInterface, expressionsSupport));\r\n\r\n    root->addChildItem(createBusInterfacesItem(root, busInterface, portMapInterface));\r\n\r\n    root->addChildItem(createIndirectInterfacesItem(root, busInterface));\r\n\r\n    root->addChildItem(QSharedPointer<ComponentEditorChannelsItem>(\r\n        new ComponentEditorChannelsItem(&navigationModel_, getLibHandler(), component_, expressionParser_, root)));\r\n\r\n    if (docRevision == Document::Revision::Std14)\r\n    {\r\n        root->addChildItem(QSharedPointer<RemapStatesItem>(\r\n            new RemapStatesItem(&navigationModel_, getLibHandler(), component_, referenceCounter_, parameterFinder_,\r\n                expressionFormatter_, expressionParser_, root)));\r\n    }\r\n    else if (docRevision == Document::Revision::Std22)\r\n    {\r\n        root->addChildItem(QSharedPointer<ModesItem>(\r\n            new ModesItem(&navigationModel_, getLibHandler(), component_, referenceCounter_, expressionsSupport, root)));\r\n    }\r\n\r\n    root->addChildItem(QSharedPointer<ComponentEditorCpusItem>(\r\n        new ComponentEditorCpusItem(&navigationModel_, getLibHandler(), component_, referenceCounter_,\r\n            expressionsSupport, root)));\r\n\r\n    root->addChildItem(QSharedPointer<ComponentEditorOtherClocksItem>(\r\n        new ComponentEditorOtherClocksItem(&navigationModel_, getLibHandler(), component_, expressionParser_, root)));\r\n\r\n    if (docRevision == Document::Revision::Std22)\r\n    {\r\n        root->addChildItem(QSharedPointer<PowerDomainsItem>(\r\n            new PowerDomainsItem(&navigationModel_, getLibHandler(), component_, referenceCounter_,\r\n                expressionsSupport, root)));\r\n    }\r\n\r\n    root->addChildItem(QSharedPointer<ResetTypesItem>(\r\n        new ResetTypesItem(&navigationModel_, getLibHandler(), component_, validator_, root)));\r\n\r\n\r\n    root->addChildItem(QSharedPointer<ComponentEditorComInterfacesItem>(\r\n        new ComponentEditorComInterfacesItem(&navigationModel_, getLibHandler(), component_, root)));\r\n\r\n    root->addChildItem(QSharedPointer<ComponentEditorSWPropertiesItem>(\r\n        new ComponentEditorSWPropertiesItem(&navigationModel_, getLibHandler(), component_, root)));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditor::createGeneralItem()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<ComponentEditorGeneralItem> ComponentEditor::createGeneralItem(\r\n    ComponentEditorRootItem* root)\r\n{\r\n    QSharedPointer<ComponentEditorGeneralItem> generalItem(new ComponentEditorGeneralItem(&navigationModel_,\r\n        getLibHandler(), component_, root));\r\n\r\n    connect(generalItem.data(), SIGNAL(changeVendorExtensions(QString const&, QSharedPointer<Extendable>)),\r\n        this, SIGNAL(changeVendorExtensions(QString const&, QSharedPointer<Extendable>)), Qt::UniqueConnection);\r\n\r\n    auto generalEditor = qobject_cast<GeneralEditor*>(generalItem->editor());\r\n    connect(generalEditor, SIGNAL(hierarchyChanged(QSettings&)), this, SLOT(setRowVisibility(QSettings&)));\r\n\r\n    return generalItem;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditor::createParametersItem()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<ComponentEditorParametersItem> ComponentEditor::createParametersItem(\r\n    ComponentEditorRootItem* root)\r\n{\r\n\r\n    QSharedPointer<ComponentEditorParametersItem> parametersItem(new ComponentEditorParametersItem(\r\n        &navigationModel_, getLibHandler(), component_, referenceCounter_, parameterFinder_, expressionParser_,\r\n        expressionFormatter_, root));\r\n\r\n    connect(parametersItem.data(), SIGNAL(openReferenceTree(QString const&, QString const&)),\r\n        parameterReferenceWindow_, SLOT(openReferenceTree(QString const&, QString const)),\r\n        Qt::UniqueConnection);\r\n\r\n    return parametersItem;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditor::createInstantiationsItem()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<InstantiationsItem> ComponentEditor::createInstantiationsItem(\r\n    ComponentEditorRootItem* root)\r\n{\r\n    QSharedPointer<InstantiationsItem> instantiationsItem(new InstantiationsItem(&navigationModel_, getLibHandler(),\r\n        component_, referenceCounter_, parameterFinder_, expressionFormatter_, expressionParser_, root));\r\n\r\n    connect(instantiationsItem.data(), SIGNAL(openReferenceTree(QString const&, QString const&)),\r\n        parameterReferenceWindow_, SLOT(openReferenceTree(QString const&, QString const&)), Qt::UniqueConnection);\r\n\r\n    return instantiationsItem;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditor::createViewsItem()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<ComponentEditorViewsItem> ComponentEditor::createViewsItem(\r\n    ComponentEditorRootItem* root)\r\n{\r\n    QSharedPointer<ComponentEditorViewsItem> viewsItem(new ComponentEditorViewsItem(&navigationModel_, getLibHandler(),\r\n        component_, referenceCounter_, parameterFinder_, expressionFormatter_, expressionParser_, root));\r\n\r\n    connect(viewsItem.data(), SIGNAL(openReferenceTree(QString const&, QString const&)),\r\n        parameterReferenceWindow_, SLOT(openReferenceTree(QString const&, QString const&)), Qt::UniqueConnection);\r\n\r\n    return viewsItem;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditor::createPortsItem()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<ComponentEditorPortsItem> ComponentEditor::createPortsItem(\r\n    ComponentEditorRootItem* root, BusInterfaceInterface* busInterface,\r\n    ExpressionSet const& expressionSupport)\r\n{\r\n    QSharedPointer<ComponentEditorPortsItem> portsItem(new ComponentEditorPortsItem(&navigationModel_,\r\n        getLibHandler(), component_, referenceCounter_, expressionSupport, busInterface, root));\r\n\r\n    connect(portsItem.data(), SIGNAL(createInterface()), root, SLOT(onInterfaceAdded()), Qt::UniqueConnection);\r\n\r\n    connect(portsItem.data(),\r\n        SIGNAL(changeVendorExtensions(QString const&, QSharedPointer<Extendable>)),\r\n        this, SIGNAL(changeVendorExtensions(QString const&, QSharedPointer<Extendable>)),\r\n        Qt::UniqueConnection);\r\n\r\n    return portsItem;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditor::createBusInterfacesItem()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<ComponentEditorBusInterfacesItem> ComponentEditor::createBusInterfacesItem(\r\n    ComponentEditorRootItem* root, BusInterfaceInterface* busInterface, PortMapInterface* portMapInterface)\r\n{\r\n    QSharedPointer<ComponentEditorBusInterfacesItem> busInterfaceItem(\r\n        new ComponentEditorBusInterfacesItem(busInterface, portMapInterface, &navigationModel_,\r\n            getLibHandler(), component_, referenceCounter_,\r\n            ExpressionSet({ parameterFinder_, expressionParser_, expressionFormatter_ }),\r\n            root, parentWidget()));\r\n\r\n    connect(busInterfaceItem.data(), SIGNAL(openReferenceTree(QString const&, QString const&)),\r\n        parameterReferenceWindow_, SLOT(openReferenceTree(QString const&, QString const&)),\r\n        Qt::UniqueConnection);\r\n\r\n    return busInterfaceItem;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditor::createIndirectInterfacesItem()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<ComponentEditorIndirectInterfacesItem> ComponentEditor::createIndirectInterfacesItem(\r\n    ComponentEditorRootItem* root, BusInterfaceInterface* busInterface)\r\n{\r\n    QSharedPointer<ComponentEditorIndirectInterfacesItem> indirectInterfacesItem(\r\n        new ComponentEditorIndirectInterfacesItem(&navigationModel_, getLibHandler(), component_,\r\n            referenceCounter_, parameterFinder_, expressionFormatter_, expressionParser_,\r\n            busInterface, root, parentWidget()));\r\n\r\n    connect(indirectInterfacesItem.data(), SIGNAL(openReferenceTree(QString const&, QString const&)),\r\n        parameterReferenceWindow_, SLOT(openReferenceTree(QString const&, QString const&)),\r\n        Qt::UniqueConnection);\r\n\r\n    return indirectInterfacesItem;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditor::setupLayout()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentEditor::setupLayout()\r\n{\r\n    // the top layout contains only the navigation splitter\r\n    auto layout = new QHBoxLayout(this);\r\n    layout->addWidget(&navigationSplitter_);\r\n    layout->setContentsMargins(5, 5, 5, 5);\r\n\r\n    // editor visualizer splitter contains the editor- and visualizer slots\r\n    editorVisualizerSplitter_.addWidget(&editorSlot_);\r\n    editorVisualizerSplitter_.addWidget(&visualizerSlot_);\r\n\r\n    // navigation splitter contains the navigation tree and the other splitter\r\n    navigationSplitter_.addWidget(&navigationView_);\r\n    navigationSplitter_.addWidget(&editorVisualizerSplitter_);\r\n    navigationSplitter_.setStretchFactor(1, 1);\r\n\r\n    // The navigation tree takes 1/5 of the space available and editor and\r\n    // visualizer take the rest\r\n    QList<int> navigationSize;\r\n    navigationSize.append(ComponentTreeView::DEFAULT_WIDTH);\r\n    navigationSize.append(4 * ComponentTreeView::DEFAULT_WIDTH);\r\n    navigationSplitter_.setSizes(navigationSize);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: componenteditor::updateComponentFiles()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentEditor::updateComponentFiles(QSharedPointer<Component> targetComponent,\r\n    QSharedPointer<Component> otherComponent, QString const& sourcePath, QString const& targetPath) const\r\n{\r\n    // can't operate on the same component\r\n    if (targetComponent == otherComponent)\r\n    {\r\n        return;\r\n    }\r\n\r\n    // get the files from the other component\r\n    for (auto const& file : getComponentFileNames(otherComponent))\r\n    {\r\n        // get the absolute path to the file\r\n        QDir source(sourcePath);\r\n        QString absoluteSource = source.absoluteFilePath(file);\r\n\r\n        // if file is located under the source directory\r\n        if (!file.contains(QString(\"../\")))\r\n        {\r\n\r\n            QDir target(targetPath);\r\n            QString absoluteTarget = target.absoluteFilePath(file);\r\n\r\n            QFileInfo targetInfo(absoluteTarget);\r\n\r\n            target.mkpath(targetInfo.absolutePath());\r\n            QFile::copy(absoluteSource, absoluteTarget);\r\n\r\n        }\r\n        // if file is higher in directory hierarchy than the source directory\r\n        else\r\n        {\r\n            // update the file name\r\n            changeFileName(file, absoluteSource, targetComponent);\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: componenteditor::getComponentFileNames()\r\n//-----------------------------------------------------------------------------\r\nQStringList ComponentEditor::getComponentFileNames(QSharedPointer<Component> component) const\r\n{\r\n    QStringList fileNames;\r\n    for (QSharedPointer<FileSet> fileSet : *component->getFileSets())\r\n    {\r\n        fileNames.append(fileSet->getFileNames());\r\n    }\r\n\r\n    return fileNames;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: componenteditor::changeFileName()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentEditor::changeFileName(QString const& from, QString const& to, QSharedPointer<Component> component)\r\n    const\r\n{\r\n    for (QSharedPointer<FileSet> fileSet : *component->getFileSets())\r\n    {\r\n        if (fileSet->contains(from))\r\n        {\r\n            fileSet->changeFileName(from, to);\r\n            return;\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: componenteditor::openItemEditor()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentEditor::openItemEditor(QVector<QString> itemIdentifierChain)\r\n{\r\n    QModelIndex itemIndex = navigationModel_.getIndexOfItem(itemIdentifierChain);\r\n    if (itemIndex.isValid())\r\n    {\r\n        onExpand(itemIndex);\r\n        onItemActivated(itemIndex);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditor::getComponent()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<Component> ComponentEditor::getComponent() const\r\n{\r\n    return component_;\r\n}\r\n"
  },
  {
    "path": "editors/ComponentEditor/componenteditor.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: componenteditor.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 16.5.2012\r\n//\r\n// Description:\r\n// The editor to edit/packet IP-Xact components.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef COMPONENTEDITOR_H\r\n#define COMPONENTEDITOR_H\r\n\r\n#include <common/widgets/tabDocument/TabDocument.h>\r\n\r\n#include <editors/common/ExpressionSet.h>\r\n#include <editors/ComponentEditor/referenceCounter/ComponentParameterReferenceCounter.h>\r\n#include <editors/ComponentEditor/treeStructure/componenttreeview.h>\r\n#include <editors/ComponentEditor/treeStructure/componenteditortreemodel.h>\r\n#include <editors/ComponentEditor/treeStructure/componenteditorgroupslot.h>\r\n#include <editors/ComponentEditor/treeStructure/ComponentEditorTreeSortProxyModel.h>\r\n#include <editors/ComponentEditor/treeStructure/componenteditorrootitem.h>\r\n#include <editors/ComponentEditor/treeStructure/componenteditorgeneralitem.h>\r\n#include <editors/ComponentEditor/treeStructure/componenteditorfilesetsitem.h>\r\n#include <editors/ComponentEditor/treeStructure/componenteditorparametersitem.h>\r\n#include <editors/ComponentEditor/treeStructure/componenteditormemmapsitem.h>\r\n#include <editors/ComponentEditor/treeStructure/componenteditoraddrspacesitem.h>\r\n#include <editors/ComponentEditor/treeStructure/componenteditorviewsitem.h>\r\n#include <editors/ComponentEditor/treeStructure/componenteditorportsitem.h>\r\n#include <editors/ComponentEditor/treeStructure/componenteditorbusinterfacesitem.h>\r\n#include <editors/ComponentEditor/treeStructure/componenteditorchannelsitem.h>\r\n#include <editors/ComponentEditor/treeStructure/ComponentEditorChoicesItem.h>\r\n#include <editors/ComponentEditor/treeStructure/componenteditorcpusitem.h>\r\n#include <editors/ComponentEditor/treeStructure/componenteditorotherclocksitem.h>\r\n#include <editors/ComponentEditor/treeStructure/ResetTypesItem.h>\r\n#include <editors/ComponentEditor/treeStructure/componenteditorcominterfacesitem.h>\r\n#include <editors/ComponentEditor/treeStructure/componenteditorapiinterfacesitem.h>\r\n#include <editors/ComponentEditor/treeStructure/componenteditorswpropertiesitem.h>\r\n#include <editors/ComponentEditor/treeStructure/ComponentEditorSystemViewsItem.h>\r\n#include <editors/ComponentEditor/treeStructure/RemapStatesItem.h>\r\n#include <editors/ComponentEditor/treeStructure/ModesItem.h>\r\n#include <editors/ComponentEditor/treeStructure/PowerDomainsItem.h>\r\n#include <editors/ComponentEditor/treeStructure/InstantiationsItem.h>\r\n#include <editors/ComponentEditor/treeStructure/ComponentEditorIndirectInterfacesItem.h>\r\n\r\n#include <KactusAPI/include/ComponentParameterFinder.h>\r\n#include <KactusAPI/include/ExpressionFormatter.h>\r\n#include <KactusAPI/include/BusInterfaceInterface.h>\r\n\r\n#include <IPXACTmodels/Component/validators/ComponentValidator.h>\r\n\r\n#include <QSharedPointer>\r\n#include <QSplitter>\r\n#include <QSettings>\r\n\r\nclass LibraryInterface;\r\nclass PluginManager;\r\nclass Component;\r\nclass ExpressionParser;\r\nclass ParameterFinder;\r\nclass ExpressionFormatter;\r\nclass ParameterReferenceTreeWindow;\r\nclass ComponentParameterReferenceTree;\r\nclass ComponentAndInstantiationsParameterFinder;\r\nclass BusInterfaceInterface;\r\nclass FileSetInterface;\r\nclass MemoryMapInterface;\r\nclass AbstractionTypeInterface;\r\nclass PortMapInterface;\r\nclass TransparentBridgeInterface;\r\nclass PortMapValidator;\r\nclass BusInterfaceInterface;\r\nclass ModeConditionParserInterface;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! The editor to edit/packet IP-Xact components.\r\n//-----------------------------------------------------------------------------\r\nclass ComponentEditor : public TabDocument\r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\r\n\t/*! The constructor.\r\n\t *\r\n\t *    @param [in] libHandler  The instance that manages the component library.\r\n\t *    @param [in] component   The component being edited.\r\n\t *    @param [in] parent      Parent widget of the editor.\r\n\t *\r\n\t */\r\n\tComponentEditor(LibraryInterface* libHandler, \r\n\t\tQSharedPointer<Component> component, \r\n\t\tQWidget *parent);\r\n\r\n\t//! The destructor\r\n\tvirtual ~ComponentEditor() = default;\r\n\r\n    //! No copying\r\n    ComponentEditor(const ComponentEditor& other) = delete;\r\n\r\n    //! No assignment\r\n    ComponentEditor& operator=(const ComponentEditor& other) = delete;\r\n\r\n\t/*! Get the VLNV that can be used to identify the component.\r\n\t *\r\n\t *    @return The VLNV of the component.\r\n\t*/\r\n\tVLNV getIdentifyingVLNV() const final;\r\n\r\n\t/*! Get the vlnv of the current component.\r\n\t *\r\n\t *    @return VLNV of the component being edited.\r\n\t*/\r\n\tVLNV getDocumentVLNV() const final;\r\n\r\n\t/*! Check if the editor is editing a hardware implementation or not.\r\n\t *\r\n\t *    @return True if the component is a hardware component.\r\n\t*/\r\n\tbool isHWImplementation() const;\r\n\r\n\t//! Refreshes the editor to display the changes made.\r\n    void refresh() final;\r\n\r\n\t/*!\r\n\t *  Applies the current settings into use.\r\n\t *\r\n\t *    @param [in] settings   The settings file.\r\n\t */\r\n\tvoid applySettings(QSettings& settings) override;\r\n\r\n\t/*!\r\n\t *  Gets the names of all component editor items for HW component.\r\n\t *\r\n\t *    @return The names of the items.\r\n\t */\r\n\tstatic QStringList getHwItemNames();\r\n\r\n\t/*!\r\n\t *  Gets the names of all component editor items for SW component.\r\n\t *\r\n\t *    @return The names of the items.\r\n\t */\r\n\tstatic QStringList getSwItemNames();\r\n\r\n    /*!\r\n     *  Open item editor for a component.\r\n     *\r\n     *    @param [in] itemIdentifierChain     List of string identifying the item to be opened.\r\n     */\r\n    void openItemEditor(QVector<QString> itemIdentifierChain);\r\n\r\n\t//! Get the edited component.\r\n    QSharedPointer<Component> getComponent() const;\r\n\r\npublic slots:\r\n\r\n    /*!\r\n     *  Validates the document against the IP-XACT standard.\r\n     *\r\n     *    @param [in] errorList   Error message list for reporting standard violations.\r\n     *\r\n     *    @return True if the document is valid. False if there were any violations.\r\n     */\r\n    virtual bool validate(QVector<QString>& errorList);\r\n\r\n\t//! Saves the document and resets the modified state.\r\n\tvirtual bool save();\r\n\r\n\t//! Saves the document as new object and resets modifies state\r\n\tvirtual bool saveAs();\r\n\r\n\t/*! Set the protection state of the document.\r\n\t *\r\n\t *    @param [in] locked True for locked state, false for unlocked.\r\n\t *\r\n\t*/\r\n\tvirtual void setProtection(bool locked);\r\n\r\n\t/*!\r\n\t *  Set the visibility of rows in tree view.\r\n\t */\r\n\tvoid setRowVisibility(QSettings& settings);\r\n\r\nprivate slots:\r\n\r\n\t/*! This slot is called when an item is selected in the navigation tree.\r\n\t *\r\n\t *    @param [in] index The index identifying the item.\r\n\t *\r\n\t*/\r\n\tvoid onItemActivated(const QModelIndex& index);\r\n\r\n\t/*! This slot is called when navigation tree sends a selectItem signal.\r\n\t * \r\n\t * This function tells navigation view to select the index in the tree and then\r\n\t * calls ComponentEditor::onItemActivated() slot.\r\n\t * \r\n\t *    @param [in] index Model index that identifies the item to select.\r\n\t *\r\n\t*/\r\n\tvoid onNavigationTreeSelection(const QModelIndex& index);\r\n\r\n\t/*! This slot is called when navigation tree sends an expandItem signal.\r\n\t * \r\n\t * This function tells navigation view to expand the index in the tree.\r\n\t * \r\n\t *    @param [in] index Model index that identifies the item to expand.\r\n\t *\r\n\t*/\r\n    void onExpand(const QModelIndex& index);\r\n    \r\n\t/*! \\brief Display an error dialog to user with given text.\r\n\t *\r\n\t *    @param [in] message Contains the text to display in the error dialog.\r\n\t*/\r\n\tvoid onErrorDialog(const QString& message);\r\n\r\nsignals:\r\n    /*!\r\n     *  Opens the specific C source file of the given component.\r\n     *\r\n     *    @param [in] filename   The name of the file to open.\r\n     *    @param [in] component  The component containing the file.\r\n     */\r\n    void openCSource(QString const& filename, QSharedPointer<Component> component);\r\n\r\nprivate:\r\n\r\n\r\n    /*!\r\n     *  Creates the root item for the navigation model for the given component.\r\n     *\r\n     *    @param [in] component   The component for which to create the root item.\r\n     *\r\n     *    @return The root item for the navigation model for the component.\r\n     */\r\n    QSharedPointer<ComponentEditorRootItem> createNavigationRootForComponent();\r\n\t    \r\n\t/*!\r\n     *  Creates child items for the navigation model for a SW component.\r\n     *\r\n     *    @param [in] root   The root item in the navigation model.\r\n     */\r\n    void addSWItems(ComponentEditorRootItem* root);\r\n\r\n\t/*!\r\n\t *  Creates child items for the navigation model for a HW component.\r\n\t *\r\n\t *    @param [in] root\t\t\t\tThe root item in the navigation model.\r\n\t *\t\t@param [in] expressionSupport\tCollection of classes for handling expressions.\r\n\t * \r\n\t */\r\n\tvoid addHWItems(ComponentEditorRootItem* root, ExpressionSet const& expressionsSupport);\r\n\t\r\n\t/*!\r\n\t *  Create the General item in the navigation tree.\r\n\t *\r\n\t *    @param [in] root\tThe root item in the navigation model.\r\n\t *\r\n\t *    @return The created item.\r\n\t */\r\n\tQSharedPointer<ComponentEditorGeneralItem> createGeneralItem(ComponentEditorRootItem* root);\r\n\r\n\t/*!\r\n\t *  Create the Parameters item in the navigation tree.\r\n\t *\r\n\t *    @param [in] root\tThe root item in the navigation model.\r\n\t *\r\n\t *    @return The created item.\r\n\t */\r\n\tQSharedPointer<ComponentEditorParametersItem> createParametersItem(ComponentEditorRootItem* root);\r\n\r\n\t/*!\r\n\t *  Create the Instantiations item in the navigation tree.\r\n\t *\r\n\t *    @param [in] root\tThe root item in the navigation model.\r\n\t *\r\n\t *    @return The created item.\r\n\t */\r\n\tQSharedPointer<InstantiationsItem> createInstantiationsItem(ComponentEditorRootItem* root);\r\n\r\n\t/*!\r\n\t *  Create the Views item in the navigation tree.\r\n\t *\r\n\t *    @param [in] root\tThe root item in the navigation model.\r\n\t *\r\n\t *    @return The created item.\r\n\t */\r\n\tQSharedPointer<ComponentEditorViewsItem> createViewsItem(ComponentEditorRootItem* root);\r\n\r\n\t/*!\r\n\t *  Create the Ports item in the navigation tree.\r\n\t *\r\n     *    @param [in] root\t\t\t\tThe root item in the navigation model.\r\n     *    @param [in] busInterface\t\tThe interface for accessing bus interface data.\r\n     *\t\t@param [in] expressionSupport\tCollection of classes for handling expressions.\r\n\t *\r\n\t *    @return The created item.\r\n\t */\r\n\tQSharedPointer<ComponentEditorPortsItem> createPortsItem(ComponentEditorRootItem* root, \r\n\t\tBusInterfaceInterface* busInterface, ExpressionSet const& expressionSupport);\r\n\r\n\t/*!\r\n\t *  Create the Bus Interfaces item in the navigation tree.\r\n\t *\r\n     *    @param [in] root\t\t\t\tThe root item in the navigation model.\r\n     *    @param [in] busInterface\t\tThe interface for accessing bus interface data.\r\n     *    @param [in] portMapInterface\tThe interface for accessing port map data.\r\n\t *\r\n\t *    @return The created item.\r\n\t */\r\n\tQSharedPointer<ComponentEditorBusInterfacesItem> createBusInterfacesItem(ComponentEditorRootItem* root,\r\n\t\tBusInterfaceInterface* busInterface, PortMapInterface* portMapInterface);\r\n\r\n\t/*!\r\n\t *  Create the Indirect Interfaces item in the navigation tree.\r\n\t *\r\n     *    @param [in] root\t\t\t\tThe root item in the navigation model.\r\n     *    @param [in] busInterface\t\tThe interface for accessing bus interface data.\r\n\t *\r\n\t *    @return The created item.\r\n\t */\r\n\tQSharedPointer<ComponentEditorIndirectInterfacesItem> createIndirectInterfacesItem(\r\n\t\tComponentEditorRootItem* root, BusInterfaceInterface* busInterface);\r\n\r\n\t//! Setups the editor layout.\r\n    void setupLayout();\r\n\r\n    /*!\r\n     *  Update component files of a target component.\r\n     *\r\n     *    @param [in] targetComponent     The component whose files are being updated.\r\n     *    @param [in] otherComponent      The other component.\r\n     *    @param [in] sourcePath          Source path.\r\n     *    @param [in] targetPath          Target path.\r\n     */\r\n    void updateComponentFiles(QSharedPointer<Component> targetComponent, QSharedPointer<Component> otherComponent,\r\n        QString const& sourcePath, QString const& targetPath) const;\r\n\r\n    /*!\r\n     *  Get a list of the file names of a component.\r\n     *\r\n     *    @param [in] component   The component whose file names are being looked.\r\n     *\r\n     *    @return A list of file names contained within a component.\r\n     */\r\n    QStringList getComponentFileNames(QSharedPointer<Component> component) const;\r\n\r\n    /*!\r\n     *  Change the name of a single file.\r\n     *\r\n     *    @param [in] from        The original file name.\r\n     *    @param [in] to          The new file name.\r\n     *    @param [in] component   The component containing the file.\r\n     */\r\n    void changeFileName(QString const& from, QString const& to, QSharedPointer<Component> component) const;\r\n\r\n\t//-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n\t//! The component being edited.\r\n\tQSharedPointer<Component> component_;\r\n\r\n\t//! The splitter to contain the navigation tree.\r\n\tQSplitter navigationSplitter_;\r\n\r\n\t//! The splitter to display the editors and visualizers.\r\n\tQSplitter editorVisualizerSplitter_;\r\n\r\n\t//! The model to control the navigation view.\r\n\tComponentEditorTreeModel navigationModel_;\r\n\r\n\t//! The tree view to navigate in the editor.\r\n\tComponentTreeView navigationView_;\r\n\r\n    //! The proxy model for sorting the tree items.\r\n    ComponentEditorTreeProxyModel proxy_;\r\n\r\n\t//! The slot to display the editors in.\r\n\tComponentEditorGroupSlot editorSlot_;\r\n\r\n\t//! The slot to display the visualizers in.\r\n\tComponentEditorGroupSlot visualizerSlot_;\r\n\r\n    //! Finds the specified parameter inside the component (does not include instantiations).\r\n    QSharedPointer<ComponentParameterFinder> parameterFinder_;\r\n\r\n    //! Parameter finder for all the contained parameters (includes instantiations).\r\n    QSharedPointer<ComponentAndInstantiationsParameterFinder> fullParameterFinder_;\r\n\r\n    //! The counter that increases the amount of references to parameters.\r\n    QSharedPointer<ComponentParameterReferenceCounter> referenceCounter_;\r\n\r\n    //! The expression formatter used to change ids to names in expressions.\r\n    QSharedPointer<ExpressionFormatter> expressionFormatter_;\r\n\r\n    //! The used expression parser.\r\n    QSharedPointer<ExpressionParser> expressionParser_;\r\n\r\n\t//! The mode condition parser interface to use in the component validator.\r\n\tQSharedPointer<ModeConditionParserInterface> modeConditionParserInterface_;\r\n\r\n    //! The used component validator.\r\n    QSharedPointer<ComponentValidator> validator_;\r\n\r\n    //! Parameter reference tree.\r\n    ComponentParameterReferenceTree* parameterReferenceTree_ = nullptr;\r\n\r\n    //! Window for the parameter reference tree.\r\n    ParameterReferenceTreeWindow* parameterReferenceWindow_;\r\n};\r\n\r\n#endif // COMPONENTEDITOR_H\r\n"
  },
  {
    "path": "editors/ComponentEditor/cpus/CpuColumns.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: CpuColumns.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Esko Pekkarinen\r\n// Date: 19.10.2015\r\n//\r\n// Description:\r\n// Common declarations for editing cpus.\r\n//-----------------------------------------------------------------------------\r\n\r\nnamespace CpuColumns\r\n{\r\n    //! Contains the columns for cpu properties.\r\n    enum Column\r\n    {\r\n        NAME = 0,\r\n        DISPLAY_NAME,\r\n        SHORT_DESCRIPTION,\r\n        ADDRSPACE,\r\n        MEMORY_MAP,\r\n        RANGE,\r\n        WIDTH,\r\n        AUB,\r\n        DESCRIPTION,\r\n        COLUMN_COUNT\r\n    };\r\n\r\n    //! The roles that can operate on QStringList on address space column.\r\n    enum Role\r\n    {\r\n        USER_DISPLAY_ROLE = Qt::UserRole,\r\n        USER_EDIT_ROLE\r\n    };\r\n}\r\n"
  },
  {
    "path": "editors/ComponentEditor/cpus/CpuDetailsEditor.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: CpuDetailsEditor.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Esko Pekkarinen\n// Date: 16.6.2023\n//\n// Description:\n// Editor for cpu properties.\n//-----------------------------------------------------------------------------\n\n#include \"CpuDetailsEditor.h\"\n\n#include <IPXACTmodels/generaldeclarations.h>\n\n#include <KactusAPI/include/ExpressionFormatter.h>\n\n#include <editors/ComponentEditor/parameters/ComponentParameterModel.h>\n\n#include <QCompleter>\n#include <QFormLayout>\n#include <QVBoxLayout>\n#include <QHBoxLayout>\n#include <QSizePolicy>\n#include <QLabel>\n\n//-----------------------------------------------------------------------------\n// Function: CpuDetailsEditor::CpuDetailsEditor()\n//-----------------------------------------------------------------------------\nCpuDetailsEditor::CpuDetailsEditor(QSharedPointer<Component> component,\n    QSharedPointer<Cpu> cpu, QSharedPointer<ParameterFinder> finder,\n    QSharedPointer<ExpressionParser> expressionParser,\n    QWidget* parent) :\nQGroupBox(tr(\"General\"), parent),\n    component_(component),\n    cpu_(cpu),\n    expressionParser_(expressionParser)\n{\n    createEditors(finder);\n\n    setupLayout();\n}\n\n//-----------------------------------------------------------------------------\n// Function: CpuDetailsEditor::refresh()\n//-----------------------------------------------------------------------------\nvoid CpuDetailsEditor::refresh()\n{\n    if (component_->getRevision() == Document::Revision::Std14)\n    {\n        auto presence = cpu_->getIsPresent();\n        presenceEditor_->setExpression(presence);\n        presenceEditor_->setToolTip(formattedValueFor(presence));\n\n        addressSpaceRefEditor_->clearItems();\n\n        auto currentRefs = cpu_->getAddressSpaceRefs();\n        for (QString const& name : component_->getAddressSpaceNames())\n        {\n            bool isSelected = currentRefs.contains(name);\n            addressSpaceRefEditor_->addItem(name, false, isSelected);\n        }\n    }\n    else if (component_->getRevision() == Document::Revision::Std22)\n    {\n        memoryMapRefSelector_->refresh(component_->getMemoryMapNames());\n        memoryMapRefSelector_->selectItem(cpu_->getMemoryMapReference());\n\n        rangeEditor_->blockSignals(true);\n        auto range = cpu_->getRange();\n        rangeEditor_->setExpression(cpu_->getRange());\n        rangeEditor_->setToolTip(formattedValueFor(range));\n        rangeEditor_->blockSignals(false);\n\n        widthEditor_->blockSignals(true);\n        auto width = cpu_->getWidth();\n        widthEditor_->setExpression(width);\n        widthEditor_->setToolTip(formattedValueFor(width));\n        widthEditor_->blockSignals(false);\n\n        aubEditor_->blockSignals(true);\n        auto aub = cpu_->getAddressUnitBits();\n        aubEditor_->setExpression(aub);\n        aubEditor_->setToolTip(formattedValueFor(aub));\n        aubEditor_->blockSignals(false);\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: CpuDetailsEditor::onIsPresentChanged()\n//-----------------------------------------------------------------------------\nvoid CpuDetailsEditor::onIsPresentChanged()\n{\n    presenceEditor_->finishEditingCurrentWord();\n    QString presence = presenceEditor_->getExpression();\n\n    if (cpu_->getIsPresent() != presence)\n    {\n        cpu_->setIsPresent(presence);\n\n        presenceEditor_->setToolTip(formattedValueFor(presence));\n        emit contentChanged();\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: CpuDetailsEditor::onAddressSpaceRefsChanged()\n//-----------------------------------------------------------------------------\nvoid CpuDetailsEditor::onAddressSpaceRefsChanged()\n{\n    cpu_->setAddressSpaceRefs(addressSpaceRefEditor_->getSelectedItems());\n    emit contentChanged();\n}\n\n//-----------------------------------------------------------------------------\n// Function: CpuDetailsEditor::onRangeChanged()\n//-----------------------------------------------------------------------------\nvoid CpuDetailsEditor::onRangeChanged()\n{\n    rangeEditor_->finishEditingCurrentWord();\n    QString range = rangeEditor_->getExpression();\n\n    if (cpu_->getRange() != range)\n    {\n        cpu_->setRange(range);\n        rangeEditor_->setToolTip(formattedValueFor(range));\n\n        emit contentChanged();\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: CpuDetailsEditor::onWidthChanged()\n//-----------------------------------------------------------------------------\nvoid CpuDetailsEditor::onWidthChanged()\n{\n    widthEditor_->finishEditingCurrentWord();\n    QString width = widthEditor_->getExpression();\n\n    if (cpu_->getWidth() != width)\n    {\n        cpu_->setWidth(width);\n        widthEditor_->setToolTip(formattedValueFor(width));\n\n        emit contentChanged();\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: CpuDetailsEditor::onAddressableUnitChanged()\n//-----------------------------------------------------------------------------\nvoid CpuDetailsEditor::onAddressUnitChanged()\n{\n    aubEditor_->finishEditingCurrentWord();\n    QString aub = aubEditor_->getExpression();\n\n    if (cpu_->getAddressUnitBits() != aub)\n    {\n        cpu_->setAddressUnitBits(aubEditor_->getExpression());\n        rangeEditor_->setToolTip(formattedValueFor(aub));\n\n        emit contentChanged();\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: CpuDetailsEditor::onMemoryMapRefChanged()\n//-----------------------------------------------------------------------------\nvoid CpuDetailsEditor::onMemoryMapRefChanged(QString const& selectedMemoryMap)\n{\n    if (cpu_->getMemoryMapReference() != selectedMemoryMap)\n    {\n        cpu_->setMemoryMapReference(selectedMemoryMap);\n\n        emit contentChanged();\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: CpuDetailsEditor::formattedValueFor()\n//-----------------------------------------------------------------------------\nQString CpuDetailsEditor::formattedValueFor(QString const& expression) const\n{\n    return ExpressionFormatter::format(expression, expressionParser_);\n}\n\n//-----------------------------------------------------------------------------\n// Function: CpuDetailsEditor::createEditors()\n//-----------------------------------------------------------------------------\nvoid CpuDetailsEditor::createEditors(QSharedPointer<ParameterFinder> finder)\n{\n    auto componentParametersModel = new ComponentParameterModel(finder, this);\n    componentParametersModel->setExpressionParser(expressionParser_);\n\n    if (component_->getRevision() == Document::Revision::Std14)\n    {\n        presenceEditor_ = new ExpressionEditor(finder, this);\n        presenceEditor_->setFixedHeight(ExpressionEditor::DEFAULT_HEIGHT);\n\n        auto presenceCompleter = new QCompleter(this);\n        presenceCompleter->setModel(componentParametersModel);\n        presenceEditor_->setAppendingCompleter(presenceCompleter);\n\n        connect(presenceEditor_, SIGNAL(increaseReference(QString const&)),\n            this, SIGNAL(increaseReferences(QString const&)), Qt::UniqueConnection);\n        connect(presenceEditor_, SIGNAL(decreaseReference(QString const&)),\n            this, SIGNAL(decreaseReferences(QString const&)), Qt::UniqueConnection);\n        connect(presenceEditor_, SIGNAL(editingFinished()), this, SLOT(onIsPresentChanged()), Qt::UniqueConnection);\n\n        addressSpaceRefEditor_ = new EnumCollectionEditor(this);\n\n        connect(addressSpaceRefEditor_, SIGNAL(itemStateChanged(Qt::CheckState)),\n            this, SLOT(onAddressSpaceRefsChanged()), Qt::UniqueConnection);\n\n    }\n    else if (component_->getRevision() == Document::Revision::Std22)\n    {\n        memoryMapRefSelector_ = new ReferenceSelector(this);\n        memoryMapRefSelector_->setProperty(\"mandatoryField\", true);\n\n        connect(memoryMapRefSelector_, SIGNAL(itemSelected(QString const&)),\n            this, SLOT(onMemoryMapRefChanged(QString const&)), Qt::UniqueConnection);\n\n        rangeEditor_ = new ExpressionEditor(finder, this);\n        rangeEditor_->setFixedHeight(ExpressionEditor::DEFAULT_HEIGHT);\n        rangeEditor_->setProperty(\"mandatoryField\", true);\n\n        auto rangeCompleter = new QCompleter(this);\n        rangeCompleter->setModel(componentParametersModel);\n        rangeEditor_->setAppendingCompleter(rangeCompleter);\n\n        connect(rangeEditor_, SIGNAL(increaseReference(QString const&)),\n            this, SIGNAL(increaseReferences(QString const&)), Qt::UniqueConnection);\n        connect(rangeEditor_, SIGNAL(decreaseReference(QString const&)),\n            this, SIGNAL(decreaseReferences(QString const&)), Qt::UniqueConnection);\n        connect(rangeEditor_, SIGNAL(editingFinished()), this, SLOT(onRangeChanged()), Qt::UniqueConnection);\n\n        widthEditor_ = new ExpressionEditor(finder, this);\n        widthEditor_->setFixedHeight(ExpressionEditor::DEFAULT_HEIGHT);\n        widthEditor_->setProperty(\"mandatoryField\", true);\n\n        auto widthCompleter = new QCompleter(this);\n        widthCompleter->setModel(componentParametersModel);\n        widthEditor_->setAppendingCompleter(widthCompleter);\n\n        connect(widthEditor_, SIGNAL(increaseReference(QString const&)),\n            this, SIGNAL(increaseReferences(QString const&)), Qt::UniqueConnection);\n        connect(widthEditor_, SIGNAL(decreaseReference(QString const&)),\n            this, SIGNAL(decreaseReferences(QString const&)), Qt::UniqueConnection);\n        connect(widthEditor_, SIGNAL(editingFinished()), this, SLOT(onWidthChanged()), Qt::UniqueConnection);\n\n        aubEditor_ = new ExpressionEditor(finder, this);\n        aubEditor_->setFixedHeight(ExpressionEditor::DEFAULT_HEIGHT);\n\n        auto aubCompleter = new QCompleter(this);\n        aubCompleter->setModel(componentParametersModel);\n        aubEditor_->setAppendingCompleter(aubCompleter);\n\n        connect(aubEditor_, SIGNAL(increaseReference(QString const&)),\n            this, SIGNAL(increaseReferences(QString const&)), Qt::UniqueConnection);\n        connect(aubEditor_, SIGNAL(decreaseReference(QString const&)),\n            this, SIGNAL(decreaseReferences(QString const&)), Qt::UniqueConnection);\n        connect(aubEditor_, SIGNAL(editingFinished()), this, SLOT(onAddressUnitChanged()), Qt::UniqueConnection);\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: CpuDetailsEditor::setupLayout()\n//-----------------------------------------------------------------------------\nvoid CpuDetailsEditor::setupLayout()\n{\n    setFlat(true);\n\n    auto layout = new QGridLayout(this);\n\n    int row = 0;\n    if (component_->getRevision() == Document::Revision::Std14)\n    {\n        layout->addWidget(new QLabel(tr(\"Is present, f(x):\"), this), row, 0, 1, 1);\n        layout->addWidget(presenceEditor_, row, 1, 1, 1);\n        ++row;\n\n        layout->addWidget(new QLabel(tr(\"Address spaces:\"), this), row, 0, 1, 1);\n        layout->addWidget(addressSpaceRefEditor_, row, 1, 1, 1);\n        ++row;\n    }\n    else if (component_->getRevision() == Document::Revision::Std22)\n    {\n        layout->addWidget(new QLabel(tr(\"Memory map:\"), this), row, 0, 1, 1);\n        layout->addWidget(memoryMapRefSelector_, row, 1, 1, 1);\n        ++row;\n\n        layout->addWidget(new QLabel(tr(\"Range [AUB], f(x):\"), this), row, 0, 1, 1);\n        layout->addWidget(rangeEditor_, row, 1, 1, 1);\n        ++row;\n\n        layout->addWidget(new QLabel(tr(\"Width [bits], f(x):\"), this), row, 0, 1, 1);\n        layout->addWidget(widthEditor_, row, 1, 1, 1);\n        ++row;\n\n        layout->addWidget(new QLabel(tr(\"Address unit bits (AUB), f(x):\"), this), row, 0, 1, 1);\n        layout->addWidget(aubEditor_, row, 1, 1, 1);\n        ++row;\n    }\n\n    layout->setRowStretch(row, 1);\n}\n"
  },
  {
    "path": "editors/ComponentEditor/cpus/CpuDetailsEditor.h",
    "content": "//-----------------------------------------------------------------------------\n// File: CpuDetailsEditor.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Esko Pekkarinen\n// Date: 16.6.2023\n//\n// Description:\n// Editor for cpu properties.\n//-----------------------------------------------------------------------------\n\n#ifndef CPU_DETAILS_EDITOR_H\n#define CPU_DETAILS_EDITOR_H\n\n#include <editors/ComponentEditor/common/ExpressionEditor.h>\n#include <editors/ComponentEditor/common/ReferenceSelector/ReferenceSelector.h>\n\n#include <common/widgets/EnumCollectionEditor/EnumCollectionEditor.h>\n\n#include <KactusAPI/include/ExpressionParser.h>\n#include <KactusAPI/include/ParameterFinder.h>\n\n#include <IPXACTmodels/Component/Component.h>\n#include <IPXACTmodels/Component/Cpu.h>\n\n#include <QGroupBox>\n#include <QCheckBox>\n#include <QLineEdit>\n#include <QComboBox>\n#include <QSharedPointer>\n\n//-----------------------------------------------------------------------------\n//! Editor for cpu properties.\n//-----------------------------------------------------------------------------\nclass CpuDetailsEditor : public QGroupBox\n{\n\tQ_OBJECT\n\npublic:\n\n\t/*!\n     *  The constructor\n     *\n     *    @param [in] component\tThe containing component.\n     *    @param [in] cpu\t\t\tThe cpu whose properties to edit.\n     *    @param [in] finder\t\tThe parameter finder to use.\n\t *    @param [in] parent      The owner of this editor.\n     */\n    CpuDetailsEditor(QSharedPointer<Component> component, \n\t\tQSharedPointer<Cpu> cpu, \n\t\tQSharedPointer<ParameterFinder> finder,\n\t\tQSharedPointer<ExpressionParser> expressionParser,\n\t\tQWidget* parent = nullptr);\n\n\t/*!\n     *  The destructor\n     */\n\tvirtual ~CpuDetailsEditor() = default;\n\n    //! No copying\n    CpuDetailsEditor(const CpuDetailsEditor& other) = delete;\n\n    \n\n    //! No assignment\n    CpuDetailsEditor& operator=(const CpuDetailsEditor& other) = delete;\n\n\t/*! Restore the changes made in the editor back to ones in the model.\n\t*\n\t*/\n\tvoid refresh();\n\n\nsignals:\n\n\t//! Emitted when contents of the model change\n\tvoid contentChanged();\n\n    /*!\n     *  Increase the amount of references made to the given parameter.\n     *\n     *    @param [in] id  The id of the given parameter.\n     */\n    void increaseReferences(QString const& id) const;\n\n    /*!\n     *  Decrease the amount of references made to the given parameter.\n     *\n     *    @param [in] id  The id the given parameter.\n     */\n    void decreaseReferences(QString const& id) const;\n\nprivate slots:\n\n    //! Handler for changes in isPresent.\n    void onIsPresentChanged();\n\n    //! Handler for changes in address space references.\n    void onAddressSpaceRefsChanged();\n\n    //! Handler for changes in range.\n    void onRangeChanged();\n\n    //! Handler for changes in width.\n    void onWidthChanged();\n\n    //! Handler for changes in address unit bits.\n    void onAddressUnitChanged();\n\n\t//! Handler for changes in memory map reference.\n\tvoid onMemoryMapRefChanged(QString const& selectedMemoryMap);\n\nprivate:\n\n    QString formattedValueFor(QString const& expression) const;\n    \n    void createEditors(QSharedPointer<ParameterFinder> finder);\n\n    //! Sets the editor layout.\n    void setupLayout();\n\n\tQSharedPointer<Component> component_;\n\n\t//! The edited cpu.\n    QSharedPointer<Cpu> cpu_;\n\n    //! The expression parser to use.\n\tQSharedPointer<ExpressionParser> expressionParser_;\n\n    //! Editor for isPresent.\n\tExpressionEditor* presenceEditor_ = nullptr;\n\n    //! Editor for selecting address space references.\n\tEnumCollectionEditor* addressSpaceRefEditor_ = nullptr;\n\n    //! Combo box to select an memory map within component\n    ReferenceSelector* memoryMapRefSelector_ = nullptr;\n\n    //! Editor for cpu address space range.\n    ExpressionEditor* rangeEditor_ = nullptr;\n\n    //! Editor for cpu address space width.\n\tExpressionEditor* widthEditor_ = nullptr;\n\n    //! Editor for cpu address space address unit bits.\n\tExpressionEditor* aubEditor_ = nullptr;\n};\n\n#endif // CPU_DETAILS_EDITOR_H\n"
  },
  {
    "path": "editors/ComponentEditor/cpus/CpuVisualizer.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: CpuVisualizer.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Esko Pekkarinen\n// Date: 04.09.2023\n//\n// Description:\n// The visualizer to display the regions of a CPU.\n//-----------------------------------------------------------------------------\n\n#include \"CpuVisualizer.h\"\n\n#include <common/graphicsItems/visualizeritem.h>\n#include <common/widgets/summaryLabel/summarylabel.h>\n\n#include <IPXACTmodels/Component/Component.h>\n#include <IPXACTmodels/Component/AddressSpace.h>\n\n#include <QHBoxLayout>\n#include <QVBoxLayout>\n\n//-----------------------------------------------------------------------------\n// Function: CpuVisualizer::CpuVisualizer()\n//-----------------------------------------------------------------------------\nCpuVisualizer::CpuVisualizer(QSharedPointer<Cpu> cpu,\n    QSharedPointer<QList<QSharedPointer<MemoryMap> > > memoryMaps,\n    QSharedPointer<ExpressionParser> expressionParser,\n    QWidget* parent) :\nItemVisualizer(parent),\n    view_(new QGraphicsView(this)),\n    scene_(new RegionScene(cpu, memoryMaps, expressionParser, this))\n{\n\t// display a label on top the table\n\tauto leftLabel = new SummaryLabel(tr(\"Regions\"), this);\n\tauto rightLabel = new SummaryLabel(tr(\"Memory map\"), this);\n\n\tauto labelLayout = new QHBoxLayout();\n\tlabelLayout->addWidget(leftLabel, 0, Qt::AlignCenter);\n\tlabelLayout->addWidget(rightLabel, 0, Qt::AlignCenter);\n\n\tauto layout = new QVBoxLayout(this);\n\tlayout->addLayout(labelLayout);\n\tlayout->addWidget(view_);\n\tlayout->setContentsMargins(0, 0, 0, 0);\n\n\tview_->setAlignment(Qt::AlignLeft | Qt::AlignTop);\n\tview_->setScene(scene_);\n}\n\n//-----------------------------------------------------------------------------\n// Function: CpuVisualizer::refresh()\n//-----------------------------------------------------------------------------\nvoid CpuVisualizer::refresh()\n{\n\tscene_->refresh();\n}\n\n//-----------------------------------------------------------------------------\n// Function: CpuVisualizer::minimumSizeHint()\n//-----------------------------------------------------------------------------\nQSize CpuVisualizer::minimumSizeHint() const\n{\n\treturn QSize(VisualizerItem::DEFAULT_WIDTH * 2 + 3, VisualizerItem::DEFAULT_HEIGHT * 6);\n}\n\n//-----------------------------------------------------------------------------\n// Function: CpuVisualizer::sizeHint()\n//-----------------------------------------------------------------------------\nQSize CpuVisualizer::sizeHint() const\n{\n\treturn minimumSizeHint();\n}\n\n//-----------------------------------------------------------------------------\n// Function: CpuVisualizer::showEvent()\n//-----------------------------------------------------------------------------\nvoid CpuVisualizer::showEvent(QShowEvent* event)\n{\n    ItemVisualizer::showEvent(event);\n    refresh();\n}\n"
  },
  {
    "path": "editors/ComponentEditor/cpus/CpuVisualizer.h",
    "content": "//-----------------------------------------------------------------------------\n// File: CpuVisualizer.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Esko Pekkarinen\n// Date: 04.09.2023\n//\n// Description:\n// The visualizer to display the regions of a CPU.\n//-----------------------------------------------------------------------------\n\n#ifndef CPUVISUALIZER_H\n#define CPUVISUALIZER_H\n\n#include <editors/ComponentEditor/itemvisualizer.h>\n#include <editors/ComponentEditor/cpus/RegionScene.h>\n\n#include <QSharedPointer>\n#include <QGraphicsView>\n#include <QSize>\n\nclass ExpressionParser;\n\n//-----------------------------------------------------------------------------\n//! The visualizer to display the regions of a CPU.\n//-----------------------------------------------------------------------------\nclass CpuVisualizer : public ItemVisualizer\n{\n\tQ_OBJECT\n\npublic:\n\n\t/*!\n     *  The constructor.\n\t *\n     *    @param [in] cpu\t\t\t\tThe CPU being visualized.\n     *    @param [in] memoryMaps\t\t\tThe available memory maps for the CPU to reference.\n     *    @param [in] expressionParser   The expression parser to use.\n\t *    @param [in] parent             The owner of the visualizer.\n\t */\n    CpuVisualizer(QSharedPointer<Cpu> cpu,\n        QSharedPointer<QList<QSharedPointer<MemoryMap> > > memoryMaps,\n        QSharedPointer<ExpressionParser> expressionParser,\n\t\tQWidget *parent = 0);\n\t\n\t//! The destructor.\n\tvirtual ~CpuVisualizer() = default;\n\n    //! No copying.\n    CpuVisualizer(const CpuVisualizer& other) = delete;\n\n    //! No assignment.\n\tCpuVisualizer& operator=(const CpuVisualizer& other) = delete;\n\n\t//! Update the contents of the visualizer.\n\tvoid refresh();\n\n\t/*!\n     *  The minimum size hint for the visualizer.\n\t *\n\t *    @return The minimum size hint.\n\t */\n\tQSize minimumSizeHint() const override;\n\n\t/*!\n     *  The size hint for the visualizer.\n\t *\n\t *    @return The size hint.\n\t */\n\tQSize sizeHint() const override;\n\nprotected:\n\n    //! Handler for showing the widget.\n    void showEvent(QShowEvent* event) override;\n\nprivate:\n\t\n\t//! The cpu being visualized.\n\tQSharedPointer<Cpu> cpu_;\n\n\t//! The view displaying the visualization items.\n\tQGraphicsView* view_;\n\n\t//! The scene that manages the visualization items.\n\tRegionScene* scene_;\n};\n\n#endif // CPUVISUALIZER_H\n"
  },
  {
    "path": "editors/ComponentEditor/cpus/RegionColumns.h",
    "content": "//-----------------------------------------------------------------------------\n// File: SegmentColumns.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Esko Pekkarinen\n// Date: 20.06.2023\n//\n// Description:\n// Common declarations for regions table columns.\n//-----------------------------------------------------------------------------\n\n#ifndef REGIONCOLUMNS_H\n#define REGIONCOLUMNS_H\n\nnamespace RegionColumns\n{\n    //! Defines the columns for the regions table.\n    enum Column\n    {\n        NAME = 0,\n        DISPLAY_NAME,\n        SHORT_DESCRIPTION,\n        OFFSET,\n        RANGE,\n        DESCRIPTION,\n        COLUMN_COUNT\n    };\n}\n\n#endif // SEGMENTCOLUMNS_H"
  },
  {
    "path": "editors/ComponentEditor/cpus/RegionScene.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: RegionScene.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Esko Pekkarinen\n// Date: 04.10.2023\n//\n// Description:\n// The graphics scene containing the regions and referenced memory map of a CPU.\n//-----------------------------------------------------------------------------\n\n#include \"RegionScene.h\"\n#include <editors/ComponentEditor/addressSpaces/addressSpaceVisualizer/segmentgraphitem.h>\n#include <editors/ComponentEditor/addressSpaces/addressSpaceVisualizer/addressspacevisualizationitem.h>\n#include <editors/ComponentEditor/addressSpaces/addressSpaceVisualizer/addressspacegapitem.h>\n#include <editors/ComponentEditor/addressSpaces/addressSpaceVisualizer/localaddrblockgraphitem.h>\n#include <editors/ComponentEditor/addressSpaces/addressSpaceVisualizer/AddressSpaceConflictedItem.h>\n\n#include <KactusAPI/include/ExpressionParser.h>\n\n#include <IPXACTmodels/Component/AddressSpace.h>\n#include <IPXACTmodels/Component/MemoryMapBase.h>\n#include <IPXACTmodels/Component/MemoryBlockBase.h>\n#include <IPXACTmodels/Component/AddressBlock.h>\n\n#include <IPXACTmodels/utilities/Search.h>\n\n#include <common/graphicsItems/visualizeritem.h>\n\n//-----------------------------------------------------------------------------\n// Function: RegionScene()\n//-----------------------------------------------------------------------------\nRegionScene::RegionScene(QSharedPointer<Cpu> cpu,\n    QSharedPointer<QList<QSharedPointer<MemoryMap> > > memoryMaps,\n    QSharedPointer<ExpressionParser> expressionParser,\n    QObject* parent) :\nMemoryAlignScene(expressionParser, parent),\n    cpu_(cpu),\n    memoryMaps_(memoryMaps)\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: RegionScene::getWidth()\n//-----------------------------------------------------------------------------\nQString RegionScene::getWidth() const\n{\n    return cpu_->getWidth();\n}\n\n//-----------------------------------------------------------------------------\n// Function: RegionScene::getRange()\n//-----------------------------------------------------------------------------\nQString RegionScene::getRange() const\n{\n    return cpu_->getRange();\n}\n\n//-----------------------------------------------------------------------------\n// Function: RegionScene::createRegionItems()\n//-----------------------------------------------------------------------------\nvoid RegionScene::createRegionItems()\n{\n    quint64 addressSpaceEnd = addressSpaceLastAddress();\n\n    QSharedPointer<QList<QSharedPointer<Region> > > segments = cpu_->getRegions();\n    auto width = getWidth();\n    for (QSharedPointer<Region> current : *segments)\n    {\n        auto segItem = new SegmentGraphItem(current, width, expressionParser_);\n        addItem(segItem);\n\n        if (segItem->getOffset() > addressSpaceEnd)\n        {\n            exceedingSegments_.insert(segItem->getOffset(), segItem);\n        }\n        else\n        {\n            segmentItems_.insert(segItem->getOffset(), segItem);\n        }\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: RegionScene::createAddressBlockItems()\n//-----------------------------------------------------------------------------\nvoid RegionScene::createAddressBlockItems()\n{\n    quint64 addressSpaceEnd = addressSpaceLastAddress();\n\n    auto width = getWidth();\n    auto memoryMapName = cpu_->getMemoryMapReference();\n\n    auto memoryMap = Search::findByName(memoryMapName, *memoryMaps_);\n\n    if (!memoryMap.isNull() && !memoryMap->getMemoryBlocks().isNull())\n    {\n        for (QSharedPointer<MemoryBlockBase> block : *memoryMap->getMemoryBlocks())\n        {\n            QSharedPointer<AddressBlock> addrBlock = block.dynamicCast<AddressBlock>();\n            if (addrBlock)\n            {\n                auto blockItem = new LocalAddrBlockGraphItem(addrBlock, width, expressionParser_);\n                addItem(blockItem);\n\n                if (blockItem->getOffset() > addressSpaceEnd)\n                {\n                    exceedingAddrBlocks_.insert(blockItem->getOffset(), blockItem);\n                }\n                else\n                {\n                    addrBlockItems_.insert(blockItem->getOffset(), blockItem);\n                }\n            }\n        }\n    }\n}\n\n"
  },
  {
    "path": "editors/ComponentEditor/cpus/RegionScene.h",
    "content": "//-----------------------------------------------------------------------------\n// File: RegionScene.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Esko Pekkarinen\n// Date: 04.10.2023\n//\n// Description:\n// The graphics scene containing the regions and referenced memory map of a CPU.\n//-----------------------------------------------------------------------------\n\n#ifndef REGIONSCENE_H\n#define REGIONSCENE_H\n\n\n#include <editors/ComponentEditor/common/MemoryAlignScene.h>\n\n#include <IPXACTmodels/Component/Cpu.h>\n#include <IPXACTmodels/Component/MemoryMap.h>\n\n#include <QGraphicsScene>\n#include <QSharedPointer>\n#include <QMultiMap>\n\nclass ExpressionParser;\n\n//-----------------------------------------------------------------------------\n//! The graphics scene containing the segments and local memory map of an address space.\n//-----------------------------------------------------------------------------\nclass RegionScene : public MemoryAlignScene\n{\n\tQ_OBJECT\n\npublic:\n\n\t/*!\n     *  The constructor.\n\t *\n\t *    @param [in] addrSpace         The address space being visualized.\n     *    @param [in] expressionParser  The expression parser to use for local memory maps.\n\t *    @param [in] parent            The owner of the scene.\n\t */\n    RegionScene(QSharedPointer<Cpu> cpu,\n        QSharedPointer<QList<QSharedPointer<MemoryMap> > > memoryMaps, \n        QSharedPointer<ExpressionParser> expressionParser,\n\t\tQObject *parent);\n\t\n\t//! The destructor.\n\tvirtual ~RegionScene() = default;\n\n    //! No copying.\n    RegionScene(const RegionScene& other) = delete;\n\n    //! No assignment.\n    RegionScene& operator=(const RegionScene& other) = delete;\n\n\nprotected:\n\n    /*!\n     *  Get the width of the visualized memory.\n     *\n     *    @return The width of the memory.\n     */\n    QString getWidth() const final;\n\n    /*!\n     *  Get the range of the visualized memory.\n     *\n     *    @return The range of the memory.\n     */\n    QString getRange() const final;\n\n    /*!\n     *  Create the region/segment items placed on left.\n     *\n     */\n    void createRegionItems() final;\n\n    /*!\n     *  Create the address block items placed on right.\n     *\n     */\n    void createAddressBlockItems() final;\n\nprivate:\n\n    //-----------------------------------------------------------------------------\n    // Data.\n    //-----------------------------------------------------------------------------\n\n\t//! The cpu whose regions are being visualized.\n\tQSharedPointer<Cpu> cpu_;\n\n\n    QSharedPointer<QList<QSharedPointer<MemoryMap> > > memoryMaps_;\n\n};\n\n#endif // REGIONSCENE_H\n"
  },
  {
    "path": "editors/ComponentEditor/cpus/RegionsDelegate.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: RegionDelegate.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Esko Pekkarinen\n// Date: 11.05.2015\n//\n// Description:\n// Delegate class for segments within an address space.\n//-----------------------------------------------------------------------------\n\n#include \"RegionsDelegate.h\"\n#include \"RegionColumns.h\"\n\n//-----------------------------------------------------------------------------\n// Function: RegionDelegate::RegionDelegate()\n//-----------------------------------------------------------------------------\nRegionsDelegate::RegionsDelegate(QAbstractItemModel* completionModel, QSharedPointer<ParameterFinder> parameterFinder,\n    QObject* parent): \n    ExpressionDelegate(completionModel, parameterFinder, parent)\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: RegionDelegate::columnAcceptsExpression()\n//-----------------------------------------------------------------------------\nbool RegionsDelegate::columnAcceptsExpression(int column) const\n{\n    return column == RegionColumns::OFFSET || column == RegionColumns::RANGE;\n}\n\n//-----------------------------------------------------------------------------\n// Function: RegionDelegate::descriptionColumn()\n//-----------------------------------------------------------------------------\nint RegionsDelegate::descriptionColumn() const\n{\n    return RegionColumns::DESCRIPTION;\n}\n\n"
  },
  {
    "path": "editors/ComponentEditor/cpus/RegionsDelegate.h",
    "content": "//-----------------------------------------------------------------------------\n// File: RegionsDelegate.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Esko Pekkarinen\n// Date: 20.6.2023\n//\n// Description:\n// Delegate class for CPU regions.\n//-----------------------------------------------------------------------------\n\n#ifndef REGIONSDELEGATE_H\n#define REGIONSDELEGATE_H\n\n#include <editors/ComponentEditor/common/ExpressionDelegate.h>\n\n#include <KactusAPI/include/ParameterFinder.h>\n\n#include <QCompleter>\n\n//-----------------------------------------------------------------------------\n// Delegate class for CPU regions.\n//-----------------------------------------------------------------------------\nclass RegionsDelegate : public ExpressionDelegate\n{\n    Q_OBJECT\n\npublic:\n    /*!\n     *  The constructor.\n     *\n     *    @param [in] parameterNameCompleter      The completer to use for parameter names in expression editor.\n     *    @param [in] parameterFinder             The parameter finder to use for for expression editor.\n     *    @param [in] parent                      The parent object.\n     */\n    RegionsDelegate(QAbstractItemModel* completionModel, QSharedPointer<ParameterFinder> parameterFinder,\n        QObject* parent);\n\n    //! The destructor.\n    virtual ~RegionsDelegate() = default;\n\n    // Disable copying.\n    RegionsDelegate(RegionsDelegate const& rhs) = delete;\n    RegionsDelegate& operator=(RegionsDelegate const& rhs) = delete;\n\nprotected:\n\n    /*!\n     *  Checks if the given column supports expressions in the editor.\n     *\n     *    @param [in] column   The column to check.\n     *\n     *    @return True, if the cells in the column allow expressions, otherwise false.\n     */\n    bool columnAcceptsExpression(int column) const final;\n\n    //! Gets the description column.\n    int descriptionColumn() const final;\n\n};\n\n#endif // REGIONSDELEGATE_H\n"
  },
  {
    "path": "editors/ComponentEditor/cpus/RegionsEditor.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: RegionsEditor.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Esko Pekkarinen\n// Date: 20.6.2023\n//\n// Description:\n// \n//-----------------------------------------------------------------------------\n\n#include \"RegionsEditor.h\"\n\n#include \"RegionColumns.h\"\n#include \"RegionsDelegate.h\"\n\n#include <editors/ComponentEditor/parameters/ComponentParameterModel.h>\n#include <editors/ComponentEditor/memoryMaps/ExpressionProxyModel.h>\n#include <editors/common/ExpressionSet.h>\n\n#include <IPXACTmodels/Component/Component.h>\n#include <IPXACTmodels/Component/Region.h>\n\n#include <QCompleter>\n#include <QVBoxLayout>\n\n//-----------------------------------------------------------------------------\n// Function: RegionsEditor::RegionsEditor()\n//-----------------------------------------------------------------------------\nRegionsEditor::RegionsEditor(QSharedPointer<QList<QSharedPointer<Region> > > regions,\n    QSharedPointer<RegionValidator> regionValidator,\n    QString const& componentPath, ExpressionSet expressions, QWidget* parent) :\nQGroupBox(tr(\"Regions\"), parent),\nview_(this),\nmodel_(regions, regionValidator, expressions, this)\n{\n\tsetFlat(true);\n\n    model_.setExpressionParser(expressions.parser);\n\n\tconnect(&model_, SIGNAL(contentChanged()), this, SIGNAL(contentChanged()), Qt::UniqueConnection);\n\tconnect(&model_, SIGNAL(dataChanged(const QModelIndex&, const QModelIndex&)),\n\t\tthis, SIGNAL(contentChanged()), Qt::UniqueConnection);\n\tconnect(&model_, SIGNAL(errorMessage(const QString&)),\n\t\tthis, SIGNAL(errorMessage(const QString&)), Qt::UniqueConnection);\n\tconnect(&model_, SIGNAL(noticeMessage(const QString&)),\n\t\tthis, SIGNAL(noticeMessage(const QString&)), Qt::UniqueConnection);\n\n\tconnect(&model_, SIGNAL(regionAdded(QSharedPointer<Region>)),\n\t\tthis, SIGNAL(regionAdded(QSharedPointer<Region>)), Qt::UniqueConnection);\n\tconnect(&model_, SIGNAL(regionRemoved(const QString&)),\n\t\tthis, SIGNAL(regionRemoved(const QString&)), Qt::UniqueConnection);\n\tconnect(&model_, SIGNAL(regionRenamed(const QString&, const QString&)),\n\t\tthis, SIGNAL(regionRenamed(const QString&, const QString&)), Qt::UniqueConnection);\n\tconnect(&model_, SIGNAL(regionChanged(QSharedPointer<Region>)),\n\t\tthis, SIGNAL(regionChanged(QSharedPointer<Region>)), Qt::UniqueConnection);\n\n\tconnect(&view_, SIGNAL(addItem(const QModelIndex&)),\n\t\t&model_, SLOT(onAddItem(const QModelIndex&)), Qt::UniqueConnection);\n\tconnect(&view_, SIGNAL(removeItem(const QModelIndex&)),\n\t\t&model_, SLOT(onRemoveItem(const QModelIndex&)), Qt::UniqueConnection);\n\n\tQString defaultPath = QString(\"%1/regionsList.csv\").arg(componentPath);\n\tview_.setDefaultImportExportPath(defaultPath);\n\tview_.setAllowImportExport(true);\n\n\tview_.setSortingEnabled(true);\n\tview_.setItemsDraggable(false);\n    view_.setAllowElementCopying(true);\n\n    ComponentParameterModel* completionModel = new ComponentParameterModel(expressions.finder, this);\n    completionModel->setExpressionParser(expressions.parser);\n\n\tauto delegate = new RegionsDelegate(completionModel, expressions.finder, this);\n\tview_.setItemDelegate(delegate);\n\n    connect(delegate, SIGNAL(increaseReferences(QString)),\n        this, SIGNAL(increaseReferences(QString)), Qt::UniqueConnection);\n    connect(delegate, SIGNAL(decreaseReferences(QString)),\n        this, SIGNAL(decreaseReferences(QString)), Qt::UniqueConnection);\n\n    connect(&model_, SIGNAL(decreaseReferences(QString)),\n        this, SIGNAL(decreaseReferences(QString)), Qt::UniqueConnection);\n\n    ExpressionProxyModel* proxy = new ExpressionProxyModel(expressions.parser, this);\n    proxy->setColumnToAcceptExpressions(RegionColumns::OFFSET);\n    proxy->setColumnToAcceptExpressions(RegionColumns::RANGE);\n\n\tproxy->setSourceModel(&model_);\n\tview_.setModel(proxy);\n\n\tview_.sortByColumn(1, Qt::AscendingOrder);\n\n\tQVBoxLayout* layout = new QVBoxLayout(this);\n\tlayout->addWidget(&view_);\n\n    connect(view_.itemDelegate(), SIGNAL(increaseReferences(QString const&)),\n        this, SIGNAL(increaseReferences(QString const&)), Qt::UniqueConnection);\n    connect(view_.itemDelegate(), SIGNAL(decreaseReferences(QString const&)),\n        this, SIGNAL(decreaseReferences(QString const&)), Qt::UniqueConnection);\n\n    connect(&model_, SIGNAL(decreaseReferences(QString const&)),\n        this, SIGNAL(decreaseReferences(QString const&)), Qt::UniqueConnection);\n    connect(&model_, SIGNAL(increaseReferences(QString const&)),\n        this, SIGNAL(increaseReferences(QString const&)), Qt::UniqueConnection);\n\n    connect(&view_, SIGNAL(copyRows(QModelIndexList)),\n        &model_, SLOT(onCopyRows(QModelIndexList)), Qt::UniqueConnection);\n    connect(&view_, SIGNAL(pasteRows()), &model_, SLOT(onPasteRows()), Qt::UniqueConnection);\n}\n\n//-----------------------------------------------------------------------------\n// Function: RegionsEditor::refresh()\n//-----------------------------------------------------------------------------\nvoid RegionsEditor::refresh()\n{\n\tview_.update();\n}\n"
  },
  {
    "path": "editors/ComponentEditor/cpus/RegionsEditor.h",
    "content": "\n#ifndef REGIONSEDITOR_H\n#define REGIONSEDITOR_H\n\n#include \"RegionsModel.h\"\n\n#include <common/views/EditableTableView/editabletableview.h>\n#include <editors/common/ExpressionSet.h>\n\n#include <QSharedPointer>\n#include <QGroupBox>\n\nclass LibraryInterface;\nclass Component;\nclass Region;\n\n//-----------------------------------------------------------------------------\n//! The editor to edit the regions of an address space.\n//-----------------------------------------------------------------------------\nclass RegionsEditor : public QGroupBox\n{\n\tQ_OBJECT\n\npublic:\n\n    /*!\n     *  The constructor\n     *\n     *    @param [in] regions                 The edited regions.\n     *    @param [in] regionValidator\t\t\tThe validator for regions.\n     *    @param [in] componentPath           The path to component xml file.\n     *    @param [in] expressions\t\t\t\tThe collection of objects for expression handling.\n     *    @param [in] parent                  Pointer to the owner of this editor.\n\t */\n\tRegionsEditor(QSharedPointer<QList<QSharedPointer<Region> > > regions,\n\t\tQSharedPointer<RegionValidator> regionValidator,\n        QString const& componentPath,\n\t\tExpressionSet expressions,\n\t\tQWidget *parent = nullptr);\n\t\n\t//! The destructor.\n\tvirtual ~RegionsEditor() = default;\n\n\n    //! No copying. No assignment.\n    RegionsEditor(const RegionsEditor& other) = delete;\n    RegionsEditor& operator=(const RegionsEditor& other) = delete;\n\n\t/*!\n     *  Read the settings from the address space to the editor.\n\t */\n\tvoid refresh();\n\nsignals:\n\n\t//! Emitted when the contents of the editor change.\n\tvoid contentChanged();\n\n\t//! Print an error message to the user.\n\tvoid errorMessage(const QString& msg);\n\n\t//! Print a notification to the user.\n\tvoid noticeMessage(const QString& msg);\n\n\t//! Emitted when a new region is added to the address space.\n\tvoid regionAdded(QSharedPointer<Region> region);\n\n\t//! Emitted when a region is removed from the address space.\n\tvoid regionRemoved(const QString& regionName);\n\n\t//! Emitted when a region is renamed.\n\tvoid regionRenamed(const QString& oldName, const QString& newName);\n\n\t//! Emitted when the range or offset of a region has changed.\n\tvoid regionChanged(QSharedPointer<Region> region);\n\n    /*!\n     *  Increase the amount of references to a parameter with a matching id.\n     *\n     *    @param [in] id      Id of the parameter, whose references are being increased.\n     */\n    void increaseReferences(QString const& id);\n\n    /*!\n     *  Decrease the amount of references to a parameter with a matching id.\n     *\n     *    @param [in] id      Id of the parameter, whose references are being increased.\n     */\n    void decreaseReferences(QString const& id);\n\nprivate:\n\t//! The view to display the regions.\n\tEditableTableView view_;\n\n\t//! The model that contains the regions.\n\tRegionsModel model_;\n};\n\n#endif // REGIONSEDITOR_H\n"
  },
  {
    "path": "editors/ComponentEditor/cpus/RegionsModel.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: Regionsmodel.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Esko Pekkarinen\n// Date: 20.06.2023\n//\n// Description:\n// The model that can be used to display the regions to be edited.\n//-----------------------------------------------------------------------------\n\n#include \"RegionsModel.h\"\n#include \"RegionColumns.h\"\n\n#include <KactusAPI/include/ExpressionFormatter.h>\n#include <editors/ComponentEditor/memoryMaps/memoryMapsExpressionCalculators/ReferenceCalculator.h>\n\n#include <IPXACTmodels/Component/Region.h>\n\n#include <IPXACTmodels/Component/validators/RegionValidator.h>\n\n\n#include <QApplication>\n#include <QClipboard>\n#include <QMimeData>\n\n#include <common/KactusColors.h>\n\n//-----------------------------------------------------------------------------\n// Function: RegionsModel::RegionsModel()\n//-----------------------------------------------------------------------------\nRegionsModel::RegionsModel(QSharedPointer<QList<QSharedPointer<Region> > > regions,\n    QSharedPointer<RegionValidator> validator,\n    ExpressionSet expressions, QObject *parent):\nReferencingTableModel(expressions.finder, parent),\nParameterizableTable(expressions.finder),\nregions_(regions),\nvalidator_(validator),\nexpressionFormatter_(expressions.formatter)\n{\n    setExpressionParser(expressions.parser);\n\tQ_ASSERT(regions_);\n}\n\n//-----------------------------------------------------------------------------\n// Function: RegionsModel::rowCount()\n//-----------------------------------------------------------------------------\nint RegionsModel::rowCount(QModelIndex const& parent) const\n{\n\tif (parent.isValid())\n    {\n\t\treturn 0;\n\t}\n\treturn regions_->count();\n}\n\n//-----------------------------------------------------------------------------\n// Function: RegionsModel::columnCount()\n//-----------------------------------------------------------------------------\nint RegionsModel::columnCount(QModelIndex const& parent) const\n{\n\tif (parent.isValid())\n    {\n\t\treturn 0;\n\t}\n\treturn RegionColumns::COLUMN_COUNT;\n}\n\n//-----------------------------------------------------------------------------\n// Function: RegionsModel::setData()\n//-----------------------------------------------------------------------------\nQVariant RegionsModel::headerData(int section, Qt::Orientation orientation, int role) const\n{\n    if (orientation != Qt::Horizontal)\n    {\n        return QVariant();\n    }\n\n    if (role == Qt::DisplayRole)\n    {\n        if (section == RegionColumns::NAME)\n        {\n            return tr(\"Name\");\n        }\n        else if (section == RegionColumns::DISPLAY_NAME)\n        {\n            return tr(\"Display\\nname\");\n        }\n        else if (section == RegionColumns::SHORT_DESCRIPTION)\n        {\n            return tr(\"Short\\ndescription\");\n        }\n        else if (section == RegionColumns::OFFSET)\n        {\n            return tr(\"Offset\\n[AUB]\") + getExpressionSymbol();\n        }\n        else if (section == RegionColumns::RANGE)\n        {\n            return tr(\"Range\\n[AUB]\") + getExpressionSymbol();\n        }\n        else if (section == RegionColumns::DESCRIPTION)\n        {\n            return tr(\"Description\");\n        }\n        else\n        {\n            return QVariant();\n        }\n    }\n    else // if unsupported role\n    {\n        return QVariant();\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: RegionsModel::data()\n//-----------------------------------------------------------------------------\nQVariant RegionsModel::data( QModelIndex const& index, int role) const\n{\n\tif (!index.isValid() || index.row() < 0 || index.row() >= regions_->size())\n    {\n\t\treturn QVariant();\n    }\n\n    if (role == Qt::DisplayRole)\n    {\n        if (isValidExpressionColumn(index))\n        {\n            return expressionFormatter_->formatReferringExpression(expressionOrValueForIndex(index).toString());\n        }\n\n        return expressionOrValueForIndex(index);\n    }\n    else if (role == Qt::EditRole)\n    {\n        return expressionOrValueForIndex(index);\n    }\n\telse if (role == Qt::BackgroundRole)\n    {\n        if (index.column() == RegionColumns::NAME || index.column() ==  RegionColumns::OFFSET ||\n            index.column() == RegionColumns::RANGE)\n        {            \n            return KactusColors::MANDATORY_FIELD;\n        }\n        else\n        {\n            return KactusColors::REGULAR_FIELD;\n        }\n    }\n\telse if (role == Qt::ForegroundRole)\n    {\n        return blackForValidOrRedForInvalidIndex(index);\n    }\n    else if (role == Qt::ToolTipRole)\n    {\n        if (isValidExpressionColumn(index))\n        {\n            return formattedValueFor(expressionOrValueForIndex(index).toString());\n        }\n\n        return expressionOrValueForIndex(index);\n    }\n\telse // if unsupported role\n    {\n\t\treturn QVariant();\n\t}\n}\n\n//-----------------------------------------------------------------------------\n// Function: RegionsModel::setData()\n//-----------------------------------------------------------------------------\nbool RegionsModel::setData(QModelIndex const& index, QVariant const& value, int role)\n{\n\tif (!index.isValid() || index.row() < 0 || index.row() >= regions_->size())\n    {\n\t\treturn false;\n    }\n\n    if (role == Qt::EditRole) \n    {\n        QSharedPointer<Region> targetRegion = regions_->at(index.row());\n        if (index.column() ==  RegionColumns::NAME)\n        {\n            QString oldName = targetRegion->name();\n            targetRegion->setName(value.toString());\n\n            emit regionRenamed(oldName, value.toString());\n        }\n        else if (index.column() == RegionColumns::DISPLAY_NAME)\n        {\n            targetRegion->setDisplayName(value.toString());\n\n            emit regionChanged(targetRegion);\n        }\n        else if (index.column() == RegionColumns::SHORT_DESCRIPTION)\n        {\n            targetRegion->setShortDescription(value.toString());\n\n            emit regionChanged(targetRegion);\n        }\n        else if (index.column() == RegionColumns::OFFSET)\n        {\n            targetRegion->setOffset(value.toString());\n            emit regionChanged(targetRegion);\n        }\n        else if (index.column() == RegionColumns::RANGE)\n        {\n            targetRegion->setRange(value.toString());\n            emit regionChanged(targetRegion);\n        }\n        else if (index.column() == RegionColumns::DESCRIPTION)\n        {\n            targetRegion->setDescription(value.toString());\n        }\n        else\n        {\n            return false;\n        }\n\n        emit dataChanged(index, index);\n        return true;\n    }\n\telse // is unsupported role\n    {\n\t\treturn false;\n\t}\n}\n\n//-----------------------------------------------------------------------------\n// Function: RegionsModel::flags()\n//-----------------------------------------------------------------------------\nQt::ItemFlags RegionsModel::flags( QModelIndex const& index ) const\n{\n\tif (!index.isValid())\n    {\n\t\treturn Qt::NoItemFlags;\n    }\n\n\treturn Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsEditable;\n}\n\n//-----------------------------------------------------------------------------\n// Function: RegionsModel::onAddItem()\n//-----------------------------------------------------------------------------\nvoid RegionsModel::onAddItem(QModelIndex const& index)\n{\n\tint row = regions_->size();\n\n\t// if the index is valid then add the item to the correct position\n\tif (index.isValid())\n    {\n\t\trow = index.row();\n\t}\n\n\t// the last segmented address\n\tquint64 previousEnd = 0;\n    \n\t// if this is the first item to add then do not increase address\n\tif (!regions_->isEmpty())\n    {\n\t\tpreviousEnd = getLastRegionedAddress() + 1;\n\t}\n\n\t// convert the address to hexadecimal form\n\tQString newBase = QString::number(previousEnd, 16);\n\tnewBase = newBase.toUpper();\n\tnewBase.prepend(\"'h\");\n\n\tQSharedPointer<Region> segment(new Region());\n\tsegment->setOffset(newBase);\n\n\tbeginInsertRows(QModelIndex(), row, row);\n\tregions_->insert(row, segment);\n\tendInsertRows();\n\n\t// tell also parent widget that contents have been changed\n\temit contentChanged();\n\n\temit regionAdded(segment);\n}\n\n//-----------------------------------------------------------------------------\n// Function: RegionsModel::onRemoveItem()\n//-----------------------------------------------------------------------------\nvoid RegionsModel::onRemoveItem(QModelIndex const& index)\n{\n\t// don't remove anything if index is invalid\n\tif (!index.isValid() || index.row() < 0 || index.row() >= regions_->size())\n    {\n\t\treturn;\n\t}\n\n    removeReferencesInItemOnRow(index.row());\n\n\temit regionRemoved(regions_->at(index.row())->name());\n\n\t// remove the specified item\n\tbeginRemoveRows(QModelIndex(), index.row(), index.row());\n    removeReferencesInItemOnRow(index.row());\n\tregions_->removeAt(index.row());\n\tendRemoveRows();\n\n\t// tell also parent widget that contents have been changed\n\temit contentChanged();\n}\n\n//-----------------------------------------------------------------------------\n// Function: RegionsModel::isValidExpressionColumn()\n//-----------------------------------------------------------------------------\nbool RegionsModel::isValidExpressionColumn(QModelIndex const& index) const\n{\n    return index.column() == RegionColumns::OFFSET || index.column() == RegionColumns::RANGE;\n}\n\n//-----------------------------------------------------------------------------\n// Function: RegionsModel::expressionOrValueForIndex()\n//-----------------------------------------------------------------------------\nQVariant RegionsModel::expressionOrValueForIndex(QModelIndex const& index) const\n{\n    if (index.column() == RegionColumns::NAME)\n    {\n        return regions_->at(index.row())->name();\n    }\n    else if (index.column() == RegionColumns::DISPLAY_NAME)\n    {\n        return regions_->at(index.row())->displayName();\n    }\n    else if (index.column() == RegionColumns::SHORT_DESCRIPTION)\n    {\n        return regions_->at(index.row())->shortDescription();\n    }\n    else if (index.column() == RegionColumns::OFFSET)\n    {\n        return regions_->at(index.row())->getAddressOffset();\n    }\n    else if (index.column() ==  RegionColumns::RANGE)\n    {\n        return regions_->at(index.row())->getRange();\n    }\n    else if (index.column() ==  RegionColumns::DESCRIPTION)\n    {\n        return regions_->at(index.row())->description();\n    }\n    else \n    {\n        return QVariant();\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: RegionsModel::validateIndex()\n//-----------------------------------------------------------------------------\nbool RegionsModel::validateIndex(QModelIndex const& index) const\n{\n    if (index.column() == RegionColumns::NAME)\n    {\n        QStringList segmentNames;\n        for (QSharedPointer<Region> segment : *regions_)\n        {\n            segmentNames.append(segment->name());\n        }\n\n        return segmentNames.count(regions_->at(index.row())->name()) == 1;\n    }\n    else if (index.column() == RegionColumns::OFFSET)\n    {\n        return validator_->hasValidAddressOffset(regions_->at(index.row()));\n    }\n    else if (index.column() ==  RegionColumns::RANGE)\n    {\n        return validator_->hasValidRange(regions_->at(index.row()));\n    }\n\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: RegionsModel::getAllReferencesToIdInItemOnRow()\n//-----------------------------------------------------------------------------\nint RegionsModel::getAllReferencesToIdInItemOnRow(const int& row, QString const& valueID) const\n{\n    int referencesInOffset = regions_->at(row)->getAddressOffset().count(valueID);\n    int referencesInRange = regions_->at(row)->getRange().count(valueID);\n\n    return referencesInOffset + referencesInRange;\n}\n\n//-----------------------------------------------------------------------------\n// Function: RegionsModel::getLastRegionedAddress()\n//-----------------------------------------------------------------------------\nquint64 RegionsModel::getLastRegionedAddress() const\n{\n    quint64 lastAddress = 0;\n    for (QSharedPointer<Region> segment : *regions_)\n    {\n        quint64 segmentOffset = parseExpressionToDecimal(segment->getAddressOffset()).toUInt();\n        quint64 segmentSize = qMax(parseExpressionToDecimal(segment->getRange()).toUInt(), uint(1));\n        \n        lastAddress = qMax(lastAddress, segmentOffset + segmentSize - 1);\n    }\n\n    return lastAddress;\n}\n\n//-----------------------------------------------------------------------------\n// Function: RegionsModel::onCopyRows()\n//-----------------------------------------------------------------------------\nvoid RegionsModel::onCopyRows(QModelIndexList indexList)\n{\n    QList<QSharedPointer<Region> > copiedRegions;\n    for (QModelIndex const& index : indexList)\n    {\n        QSharedPointer<Region> segment = regions_->at(index.row());\n        copiedRegions.append(segment);\n    }\n\n    QVariant addressSpaceVariant;\n    addressSpaceVariant.setValue(copiedRegions);\n\n    QMimeData* newMimeData = new QMimeData();\n    newMimeData->setData(\"text/xml/ipxact:region\", QByteArray());\n    newMimeData->setImageData(addressSpaceVariant);\n\n    QApplication::clipboard()->setMimeData(newMimeData);\n}\n\n//-----------------------------------------------------------------------------\n// Function: RegionsModel::onPasteRows()\n//-----------------------------------------------------------------------------\nvoid RegionsModel::onPasteRows()\n{\n    const QMimeData* pasteData = QApplication::clipboard()->mimeData();\n\n    if (pasteData->hasImage())\n    {\n        QVariant pasteVariant = pasteData->imageData();\n        if (pasteVariant.canConvert<QList<QSharedPointer<Region> > >())\n        {\n            ReferenceCalculator referenceCalculator(getParameterFinder());\n\n            QList<QSharedPointer<Region> > newRegions = pasteVariant.value<QList<QSharedPointer<Region> > >();\n\n            int rowBegin = regions_->size();\n            int rowEnd = rowBegin + newRegions.size() - 1;\n\n            beginInsertRows(QModelIndex(), rowBegin, rowEnd);\n\n            for (QSharedPointer<Region> copyRegion : newRegions)\n            {\n                QSharedPointer<Region> newRegion (new Region(*copyRegion));\n                newRegion->setName(getUniqueName(newRegion->name(), getCurrentItemNames()));\n\n                regions_->append(newRegion);\n\n                increaseReferencesInPastedRegion(newRegion, referenceCalculator);\n\n                emit regionAdded(newRegion);\n            }\n\n            endInsertRows();\n\n            emit contentChanged();\n        }\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: RegionsModel::getCurrentItemNames()\n//-----------------------------------------------------------------------------\nQStringList RegionsModel::getCurrentItemNames()\n{\n    QStringList names;\n    for (QSharedPointer<Region> segment : *regions_)\n    {\n        names.append(segment->name());\n    }\n\n    return names;\n}\n\n//-----------------------------------------------------------------------------\n// Function: RegionsModel::increaseReferencesInPastedRegion()\n//-----------------------------------------------------------------------------\nvoid RegionsModel::increaseReferencesInPastedRegion(QSharedPointer<Region> pastedRegion,\n    ReferenceCalculator& referenceCalculator)\n{\n    QStringList segmentExpressions;\n    segmentExpressions.append(pastedRegion->getAddressOffset());\n    segmentExpressions.append(pastedRegion->getRange());\n\n    QMap<QString, int> referencedParameters = referenceCalculator.getReferencedParameters(segmentExpressions);\n\n    QMapIterator<QString, int> refParameterIterator (referencedParameters);\n    while (refParameterIterator.hasNext())\n    {\n        refParameterIterator.next();\n        for (int i = 0; i < refParameterIterator.value(); ++i)\n        {\n            emit increaseReferences(refParameterIterator.key());\n        }\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: RegionsModel::mimeTypes()\n//-----------------------------------------------------------------------------\nQStringList RegionsModel::mimeTypes() const\n{\n    QStringList types(QAbstractItemModel::mimeTypes());\n\n    types << \"text/xml/ipxact:region\";\n\n    return types;\n}\n"
  },
  {
    "path": "editors/ComponentEditor/cpus/RegionsModel.h",
    "content": "//-----------------------------------------------------------------------------\n// File: Regionsmodel.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Esko Pekkarinen\n// Date: 20.06.2023\n//\n// Description:\n// The model that can be used to display the regions to be edited.\n//-----------------------------------------------------------------------------\n\n#ifndef REGIONSSMODEL_H\n#define REGIONSSMODEL_H\n\n#include <editors/ComponentEditor/common/ParameterizableTable.h>\n#include <editors/ComponentEditor/common/ReferencingTableModel.h>\n\n#include <editors/common/ExpressionSet.h>\n\n#include <IPXACTmodels/Component/Region.h>\n\n#include <QList>\n#include <QSharedPointer>\n\nclass ExpressionFormatter;\nclass ReferenceCalculator;\nclass AddressSpace;\nclass RegionValidator;\n\n//-----------------------------------------------------------------------------\n//! The model that can be used to display the regions to be edited.\n//-----------------------------------------------------------------------------\nclass RegionsModel : public ReferencingTableModel, public ParameterizableTable\n{\n\tQ_OBJECT\n\npublic:\n\n\t/*!\n\t *  The constructor.\n\t *\n     *    @param [in] regions\t\t\tThe regions being edited.\n     *    @param [in] validator\t\tThe validator to use to check regions.\n     *    @param [in] expressions\t\tThe collection of objects for expression handling.\n\t *    @param [in] parent          The owner of this model.\n\t */\n\tRegionsModel(QSharedPointer<QList<QSharedPointer<Region> > > regions,\n\t\tQSharedPointer<RegionValidator> validator,\n\t\tExpressionSet expressions,\n\t\tQObject *parent);\n\t\n\t//! The destructor.\n\tvirtual ~RegionsModel() = default;\n\n    //! No copying.\n    RegionsModel(const RegionsModel& other) = delete;\n\n    //! No assignment.\n    RegionsModel& operator=(const RegionsModel& other) = delete;\n\n\t/*!\n     *  Get the number of rows an item contains.\n\t *\n\t *    @param [in] parent Identifies the parent that's row count is requested.\n\t *\n\t *    @return Number of rows the item has.\n\t */\n\tint rowCount(const QModelIndex& parent = QModelIndex()) const final;\n\n\t/*!\n     *  Get the number of columns the item has to be displayed.\n\t *\n\t *    @param [in] parent Identifies the parent that's column count is requested.\n\t *\n\t *    @return The number of columns to be displayed (always 4).\n\t */\n\tint columnCount(const QModelIndex& parent = QModelIndex()) const final;\n\n\t/*!\n     *  Get the header data for specified header.\n\t *\n\t *    @param [in] section The section specifies the row/column number for the header.\n\t *    @param [in] orientation Specified if horizontal or vertical header is wanted.\n\t *    @param [in] role Specifies the type of the requested data.\n\t *\n\t *    @return QVariant Contains the requested data.\n\t */\n\tQVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const final;\n\n\t/*!\n     *  Get the data for specified item.\n\t *\n\t *    @param [in] index Specifies the item that's data is requested.\n\t *    @param [in] role The role that defines what kind of data is requested.\n\t *\n\t *    @return QVariant Contains the data for the item.\n\t */\n\tQVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const final;\n\n\t/*!\n     *  Save the data to the model for specified item\n\t *\n\t *    @param [in] index The model index of the item that's data is to be saved.\n\t *    @param [in] value The data that is to be saved.\n\t *    @param [in] role The role specifies what kind of data should be saved.\n\t *\n\t *    @return True if saving happened successfully.\n\t */\n\tbool setData(const QModelIndex& index, const QVariant& value, int role = Qt::EditRole) final;\n\n\t/*!\n     *  Get the item flags that defines the possible operations for the item.\n\t *\n\t *    @param [in] index Model index that identifies the item.\n\t *\n\t *    @return Qt::ItemFlags specify the possible operations for the item.\n\t */\n\tQt::ItemFlags flags(const QModelIndex& index) const final;\n\n    /*!\n     *  Get the list of acceptable mime types.\n     *\n     *    @return The list of acceptable mime types.\n     */\n    QStringList mimeTypes() const final;\n\npublic slots:\n\n\t/*!\n     *  A new item should be added to given index.\n\t *\n\t *    @param [in] index The position where new item should be added at.\n\t */\n\tvoid onAddItem(const QModelIndex& index);\n\n\t/*!\n     *  An item should be removed from the model.\n\t * \n\t *    @param [in] index Identifies the item that should be removed.\n\t */\n\tvoid onRemoveItem(const QModelIndex& index);\n    \n    /*!\n     *  Copy the items in the selected rows.\n     *\n     *    @param [in] indexList   List of indexes pointing to the selected rows.\n     */\n    void onCopyRows(QModelIndexList indexList);\n\n    /*!\n     *  Paste the copied items.\n     */\n    void onPasteRows();\n\nprotected:\n \n    /*!\n     *  Check if the column index is valid for containing expressions.\n     *\n     *    @param [in] index   The index being evaluated.\n     *\n     *    @return     True, if column can have expressions, false otherwise.\n     */\n    bool isValidExpressionColumn(QModelIndex const& index) const final;\n\n    /*!\n     *  Gets the expression for the given index or the plain value if expression is not available.\n     *\n     *    @param [in] index   The index whose expression to get.\n     *\n     *    @return The expression for the index if available, otherwise the value for the given index.\n     */\n    QVariant expressionOrValueForIndex(QModelIndex const& index) const final;\n    \n    /*!\n     *  Validates the data in an index.\n     *\n     *    @param [in] index   The index whose data to validate\n     *\n     *    @return True, if the data in the index is valid, otherwise false.\n     */\n    bool validateIndex(QModelIndex const& index) const final;\n\n    /*!\n     *  Gets the number of all the references made to a selected id on the selected row.\n     *\n     *    @param [in] row         The row of the selected item.\n     *    @param [in] valueID     The id of the referenced parameter.\n     *\n     *    @return The amount of references made to the selected id on the selected row.\n     */\n    int getAllReferencesToIdInItemOnRow(const int& row, QString const& valueID) const final;\n\nsignals:\n\n\t//! Emitted when contents of the model change\n\tvoid contentChanged();\n\n\t//! Prints an error message to the user.\n\tvoid errorMessage(const QString& msg) const;\n\t\n\t//! Prints a notification to user.\n\tvoid noticeMessage(const QString& msg) const;\n\n\t//! Emitted when a new Region is added to the address space.\n\tvoid regionAdded(QSharedPointer<Region> Region);\n\n\t//! Emitted when a Region is removed from the address space.\n\tvoid regionRemoved(const QString& RegionName);\n\n\t//! Emitted when a Region is renamed.\n\tvoid regionRenamed(const QString& oldName, const QString& newName);\n\n\t//! Emitted when the range or offset of a Region has changed.\n\tvoid regionChanged(QSharedPointer<Region> Region);\n\nprivate:\n\n\t/*! Get the last address of the address space that has Region assigned to it.\n\t * \n\t * If there are no Regions defined then 0 is returned.\n\t * \n\t *    @return The last address contained in a Region.\n\t*/\n\tquint64 getLastRegionedAddress() const;\n\n    /*!\n     *  Get the names of the contained address blocks.\n     *\n     *    @return The names of the contained address blocks.\n     */\n    QStringList getCurrentItemNames();\n\n    /*!\n     *  Increase the number of references made in the copied address space Region.\n     *\n     *    @param [in] pastedRegion           The copied address space Region.\n     *    @param [in] referenceCalculator     The reference calculator.\n     */\n    void increaseReferencesInPastedRegion(QSharedPointer<Region> pastedRegion,\n        ReferenceCalculator& referenceCalculator);\n\n    //-----------------------------------------------------------------------------\n    // Data.\n    //-----------------------------------------------------------------------------\n\n\t//! Pointer to the data structure that contains the regions.\n    QSharedPointer<QList<QSharedPointer<Region> > > regions_;\n\n\t//! Validator for regions.\n\tQSharedPointer<RegionValidator> validator_;\n\n    //! Pointer to the used expression formatter.\n    QSharedPointer<ExpressionFormatter> expressionFormatter_;\n};\n\n#endif // REGIONSSMODEL_H\n"
  },
  {
    "path": "editors/ComponentEditor/cpus/SingleCpuEditor.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: SingleCpuEditor.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Esko Pekkarinen\n// Date: 15.6.2023\n//\n// Description:\n// Editor to edit a single cpu in a component.\n//-----------------------------------------------------------------------------\n\n#include \"SingleCpuEditor.h\"\n\n#include <IPXACTmodels/Component/Component.h>\n#include <IPXACTmodels/Component/Cpu.h>\n\n#include <KactusAPI/include/LibraryInterface.h>\n\n#include <editors/ComponentEditor/memoryMaps/ExpressionProxyModel.h>\n#include <editors/ComponentEditor/parameters/ComponentParameterModel.h>\n\n#include <QCompleter>\n#include <QScrollArea>\n#include <QHBoxLayout>\n#include <QVBoxLayout>\n\n//-----------------------------------------------------------------------------\n// Function: SingleCpuEditor::SingleCpuEditor()\n//-----------------------------------------------------------------------------\nSingleCpuEditor::SingleCpuEditor(QSharedPointer<Component> component,\n    QSharedPointer<Cpu> cpu, QSharedPointer<RegionValidator> regionValidator, \n    LibraryInterface* libHandler,\n    ExpressionSet expressions,\n    QWidget* parent) :\n    ItemEditor(component, libHandler, parent),\n    cpu_(cpu),\n    nameEditor_(cpu_, component->getRevision(), this, tr(\"CPU name and description\")),\n    detailsEditor_(component, cpu, expressions.finder, expressions.parser, this),\n    regionsEditor_(cpu->getRegions(), regionValidator, libHandler->getDirectoryPath(component->getVlnv()), expressions, this)\n{\n    connect(&nameEditor_, SIGNAL(contentChanged()), this, SIGNAL(contentChanged()), Qt::UniqueConnection);\n    connect(&detailsEditor_, SIGNAL(contentChanged()), this, SIGNAL(contentChanged()), Qt::UniqueConnection);\n    connect(&regionsEditor_, SIGNAL(contentChanged()), this, SIGNAL(contentChanged()), Qt::UniqueConnection);\n    connect(&detailsEditor_, SIGNAL(contentChanged()), this, SIGNAL(graphicsChanged()), Qt::UniqueConnection);\n    connect(&regionsEditor_, SIGNAL(contentChanged()), this, SIGNAL(graphicsChanged()), Qt::UniqueConnection);\n\n    regionsEditor_.setVisible(component->getRevision() == Document::Revision::Std22);\n\n    connect(&detailsEditor_, SIGNAL(increaseReferences(QString const&)),\n        this, SIGNAL(increaseReferences(QString)), Qt::UniqueConnection);\n    connect(&detailsEditor_, SIGNAL(decreaseReferences(QString const&)),\n        this, SIGNAL(decreaseReferences(QString)), Qt::UniqueConnection);\n\n    connect(&regionsEditor_, SIGNAL(increaseReferences(QString const&)),\n        this, SIGNAL(increaseReferences(QString)), Qt::UniqueConnection);\n    connect(&regionsEditor_, SIGNAL(decreaseReferences(QString const&)),\n        this, SIGNAL(decreaseReferences(QString)), Qt::UniqueConnection);\n\n    setupLayout();\n}\n\n//-----------------------------------------------------------------------------\n// Function: SingleCpuEditor::refresh()\n//-----------------------------------------------------------------------------\nvoid SingleCpuEditor::refresh()\n{\n    nameEditor_.refresh();\n    detailsEditor_.refresh();\n    regionsEditor_.refresh();\n}\n\n//-----------------------------------------------------------------------------\n// Function: SingleCpuEditor::setupLayout()\n//-----------------------------------------------------------------------------\nvoid SingleCpuEditor::setupLayout()\n{\n    QScrollArea* scrollArea = new QScrollArea(this);\n    scrollArea->setWidgetResizable(true);\n    scrollArea->setFrameShape(QFrame::NoFrame);\n\n    QHBoxLayout* scrollLayout = new QHBoxLayout(this);\n    scrollLayout->addWidget(scrollArea);\n    scrollLayout->setContentsMargins(0, 0, 0, 0);\n\n    QWidget* topWidget = new QWidget(scrollArea);\n    topWidget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);\n    scrollArea->setWidget(topWidget);\n\n    auto topLayout = new QGridLayout(topWidget);\n    topLayout->addWidget(&nameEditor_, 0, 0, 1, 1);\n    topLayout->addWidget(&detailsEditor_, 0, 1, 1, 1);\n    topLayout->addWidget(&regionsEditor_, 1, 0, 1, 2);\n    topLayout->setContentsMargins(0,0,0,0);\n    topLayout->setRowStretch(1, 1);\n}\n\n//-----------------------------------------------------------------------------\n// Function: SingleCpuEditor::showEvent()\n//-----------------------------------------------------------------------------\nvoid SingleCpuEditor::showEvent(QShowEvent * event)\n{\n    QWidget::showEvent(event);\n\n    if (component()->getRevision() == Document::Revision::Std22)\n    {\n        emit helpUrlRequested(\"componenteditor/cpu2022.html\");\n    }\n    else\n    {\n        emit helpUrlRequested(\"componenteditor/cpu.html\");\n    }\n}\n"
  },
  {
    "path": "editors/ComponentEditor/cpus/SingleCpuEditor.h",
    "content": "//-----------------------------------------------------------------------------\n// File: SingleCpuEditor.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Esko Pekkarinen\n// Date: 15.6.2023\n//\n// Description:\n// Editor to edit a single cpu in a component.\n//-----------------------------------------------------------------------------\n\n#ifndef SINGLE_CPU_EDITOR_H\n#define SINGLE_CPU_EDITOR_H\n\n#include <editors/ComponentEditor/itemeditor.h>\n\n#include \"CpuDetailsEditor.h\"\n#include \"RegionsEditor.h\"\n\n#include <common/widgets/nameGroupEditor/namegroupeditor.h>\n\n#include <editors/common/ExpressionSet.h>\n\nclass Cpu;\nclass ExpressionParser;\nclass ParameterFinder;\n//-----------------------------------------------------------------------------\n//! Editor to edit a single cpu in a component.\n//-----------------------------------------------------------------------------\nclass SingleCpuEditor : public ItemEditor\n{\n\tQ_OBJECT\n\npublic:\n\n\t/*!\n\t *  The constructor.\n\t *\n\t *    @param [in] component               The component that contains the view.\n     *    @param [in] cpu                     The remap state being edited.\n     *    @param [in] regionValidator         The validator for regions in the cpu.\n\t *    @param [in] libHandler              The instance that manages the library.\n     *    @param [in] expressions             Changes the referenced ids to parameter names.\n\t *    @param [in] parent                  The owner of this editor.\n\t */\n    SingleCpuEditor(QSharedPointer<Component> component,\n        QSharedPointer<Cpu> cpu, \n        QSharedPointer<RegionValidator> regionValidator,\n        LibraryInterface* libHandler,\n        ExpressionSet expressions,\n        QWidget* parent = nullptr);\n\n\t//! The destructor\n    virtual ~SingleCpuEditor() = default;\n\n    //! No copying\n    SingleCpuEditor(const SingleCpuEditor& other) = delete;\n\n    //! No assignment\n    SingleCpuEditor& operator=(const SingleCpuEditor& other) = delete;\n\n\t/*!\n\t *  Reload the information from the model to the editor.\n\t */\n\tvoid refresh() final;\n\nprotected:\n    \n    /*!\n     *  The show event for this editor.\n     *\n     *    @param [in] event   The show event.\n     */\n    void showEvent(QShowEvent * event) final;\n\nprivate:\n\n\t/*!\n\t *  Set up the layout for the editor.\n\t */\n\tvoid setupLayout();\n\n    //-----------------------------------------------------------------------------\n    // Data.\n    //-----------------------------------------------------------------------------\n    \n    //! The remap state being edited.\n    QSharedPointer<Cpu> cpu_;\n\n\t//! Editor to set the name, display name and description of the view.\n\tNameGroupEditor nameEditor_;\n\n    //! Editor for memory references and other details.\n    CpuDetailsEditor detailsEditor_;\n\n    //! Editor for region data.\n    RegionsEditor regionsEditor_;\n\n};\n\n#endif // SINGLE_CPU_EDITOR_H\n"
  },
  {
    "path": "editors/ComponentEditor/cpus/cpusdelegate.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: cpusdelegate.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 14.06.2012\r\n//\r\n// Description:\r\n// The delegate to provide editors to add/remove/edit the cpus of a component.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"cpusdelegate.h\"\r\n\r\n#include \"CpuColumns.h\"\r\n\r\n\r\n#include <common/widgets/EnumCollectionEditor/EnumCollectionEditor.h>\r\n\r\n#include <editors/ComponentEditor/common/ExpressionEditor.h>\r\n#include <editors/ComponentEditor/common/ReferenceSelector/ReferenceSelector.h>\r\n\r\n#include <IPXACTmodels/Component/Component.h>\r\n\r\n#include <QAbstractItemView>\r\n#include <QLineEdit>\r\n#include <QStringList>\r\n#include <QString>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: CpusDelegate::CpusDelegate()\r\n//-----------------------------------------------------------------------------\r\nCpusDelegate::CpusDelegate(QSharedPointer<Component> component, QCompleter* parameterNameCompleter,\r\n    QSharedPointer<ParameterFinder> parameterFinder, QObject* parent):\r\nEnumerationEditorConstructorDelegate(parent),\r\ncomponent_(component),\r\nparameterNameCompleter_(parameterNameCompleter),\r\nparameterFinder_(parameterFinder)\r\n{\r\n    Q_ASSERT(component);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: CpusDelegate::createEditor()\r\n//-----------------------------------------------------------------------------\r\nQWidget* CpusDelegate::createEditor(QWidget* parent, QStyleOptionViewItem const& option, \r\n    QModelIndex const& index) const\r\n{\r\n    const int column = index.column();\r\n    if (column == CpuColumns::NAME || column == CpuColumns::DISPLAY_NAME ||\r\n        column == CpuColumns::SHORT_DESCRIPTION || column ==  CpuColumns::DESCRIPTION)\r\n    {\r\n        auto lineEdit = new QLineEdit(parent);\r\n        connect(lineEdit, SIGNAL(editingFinished()), this, SLOT(commitAndCloseEditor()), Qt::UniqueConnection);\r\n        return lineEdit;\r\n    }\r\n    else if (columnAcceptsExpression(column))\r\n    {\r\n        auto editor = new ExpressionEditor(parameterFinder_, parent);\r\n        editor->setAppendingCompleter(parameterNameCompleter_);\r\n\r\n        connect(editor, SIGNAL(increaseReference(QString const&)),\r\n            this, SIGNAL(increaseReferences(QString const&)), Qt::UniqueConnection);\r\n        connect(editor, SIGNAL(decreaseReference(QString const&)),\r\n            this, SIGNAL(decreaseReferences(QString const&)), Qt::UniqueConnection);\r\n\r\n        return editor;\r\n    }\r\n    else if (column == CpuColumns::MEMORY_MAP)\r\n    {\r\n        auto referenceSelector = new ReferenceSelector(parent);\r\n\r\n        QStringList names = component_->getMemoryMapNames();\r\n        QString selectedName = index.model()->data(index, Qt::DisplayRole).toString();\r\n        if (selectedName.isEmpty() == false && names.contains(selectedName) == false)\r\n        {\r\n            names.append(selectedName);\r\n        }\r\n\r\n        referenceSelector->refresh(names);\r\n\r\n        return referenceSelector;\r\n    }\r\n    else\r\n    {\r\n        return EnumerationEditorConstructorDelegate::createEditor(parent, option, index);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: CpusDelegate::setEditorData()\r\n//-----------------------------------------------------------------------------\r\nvoid CpusDelegate::setEditorData(QWidget* editor, QModelIndex const& index) const\r\n{\r\n    if (index.column() == CpuColumns::NAME ||\r\n        index.column() == CpuColumns::DISPLAY_NAME ||\r\n        index.column() == CpuColumns::SHORT_DESCRIPTION ||\r\n        index.column() ==  CpuColumns::DESCRIPTION)\r\n    {\r\n        QLineEdit* edit = qobject_cast<QLineEdit*>(editor);\r\n        Q_ASSERT(edit);\r\n\r\n        const QString text = index.data(Qt::DisplayRole).toString();\r\n        edit->setText(text);\r\n    }\r\n    else if (columnAcceptsExpression(index.column()))\r\n    {\r\n        auto expressionEditor = qobject_cast<ExpressionEditor*>(editor);\r\n        expressionEditor->setExpression(index.data(Qt::EditRole).toString());\r\n    }\r\n    else if (index.column() == CpuColumns::MEMORY_MAP)\r\n    {\r\n        QString text = index.model()->data(index, Qt::DisplayRole).toString();\r\n        ReferenceSelector* referenceSelector = qobject_cast<ReferenceSelector*>(editor);\r\n\r\n        referenceSelector->selectItem(text);\r\n    }\r\n    else\r\n    {\r\n        EnumerationEditorConstructorDelegate::setEditorData(editor, index);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: CpusDelegate::setModelData()\r\n//-----------------------------------------------------------------------------\r\nvoid CpusDelegate::setModelData(QWidget* editor, QAbstractItemModel* model, QModelIndex const& index) const\r\n{\r\n    if (index.column() == CpuColumns::NAME ||\r\n        index.column() == CpuColumns::DISPLAY_NAME ||\r\n        index.column() == CpuColumns::SHORT_DESCRIPTION ||\r\n        index.column() ==  CpuColumns::DESCRIPTION)\r\n    {\r\n        QLineEdit* edit = qobject_cast<QLineEdit*>(editor);\r\n        Q_ASSERT(edit);\r\n\r\n        QString text = edit->text();\r\n        model->setData(index, text, Qt::EditRole);\r\n    }\r\n    else if (columnAcceptsExpression(index.column()))\r\n    {\r\n        auto expressionEditor = qobject_cast<ExpressionEditor*>(editor);\r\n        expressionEditor->finishEditingCurrentWord();\r\n        model->setData(index, expressionEditor->getExpression(), Qt::EditRole);\r\n\r\n        parameterNameCompleter_->popup()->hide();\r\n    }\r\n    else if (index.column() == CpuColumns::MEMORY_MAP)\r\n    {\r\n        auto referenceSelector = qobject_cast<ReferenceSelector*>(editor);\r\n        QString text = referenceSelector->currentText();\r\n        model->setData(index, text, Qt::EditRole);\r\n    }\r\n    else\r\n    {\r\n        EnumerationEditorConstructorDelegate::setModelData(editor, model, index);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: CpusDelegate::eventFilter()\r\n//-----------------------------------------------------------------------------\r\nbool CpusDelegate::eventFilter(QObject* editor, QEvent* event)\r\n{\r\n    if (event->type() == QEvent::KeyPress)\r\n    {\r\n        auto keyEvent = dynamic_cast<QKeyEvent*>(event);\r\n        if ((keyEvent->key() == Qt::Key_Return || keyEvent->key() == Qt::Key_Enter) &&\r\n            keyEvent->modifiers() == Qt::NoModifier)\r\n        {\r\n            auto editorWidget = dynamic_cast<QWidget*>(editor);\r\n            commitData(editorWidget);\r\n            closeEditor(editorWidget);\r\n            return true;\r\n        }\r\n    }\r\n\r\n    return QStyledItemDelegate::eventFilter(editor, event);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: cpusdelegate::isEnumerationEditorColumn()\r\n//-----------------------------------------------------------------------------\r\nbool CpusDelegate::isEnumerationEditorColumn(QModelIndex const& index) const\r\n{\r\n    return index.column() == CpuColumns::ADDRSPACE;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: cpusdelegate::getCurrentSelection()\r\n//-----------------------------------------------------------------------------\r\nQStringList CpusDelegate::getCurrentSelection(QModelIndex const& index) const\r\n{\r\n    return index.data(CpuColumns::USER_DISPLAY_ROLE).toStringList();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: cpusdelegate::getAvailableItems()\r\n//-----------------------------------------------------------------------------\r\nQStringList CpusDelegate::getAvailableItems() const\r\n{\r\n    return component_->getAddressSpaceNames();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: cpusdelegate::setEnumerationDataToModel()\r\n//-----------------------------------------------------------------------------\r\nvoid CpusDelegate::setEnumerationDataToModel(QModelIndex const& index, QAbstractItemModel* model,\r\n    QStringList const& selectedItems) const\r\n{\r\n    model->setData(index, selectedItems, CpuColumns::USER_EDIT_ROLE);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: CpusDelegate::columnAcceptsExpression()\r\n//-----------------------------------------------------------------------------\r\nbool CpusDelegate::columnAcceptsExpression(int column) const\r\n{\r\n    return column == CpuColumns::RANGE || column == CpuColumns::WIDTH || column == CpuColumns::AUB;\r\n}\r\n"
  },
  {
    "path": "editors/ComponentEditor/cpus/cpusdelegate.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: cpusdelegate.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 14.06.2012\r\n//\r\n// Description:\r\n// The delegate to provide editors to add/remove/edit the cpus of a component.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef CPUSDELEGATE_H\r\n#define CPUSDELEGATE_H\r\n\r\n#include <editors/ComponentEditor/common/EnumerationEditorConstructorDelegate.h>\r\n\r\n#include <editors/ComponentEditor/common/ExpressionDelegate.h>\r\n\r\n#include <QStyledItemDelegate>\r\n#include <QSharedPointer>\r\n#include <QCompleter>\r\n\r\nclass Component;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! The delegate to provide editors to add/remove/edit the cpus of a component.\r\n//-----------------------------------------------------------------------------\r\nclass CpusDelegate : public EnumerationEditorConstructorDelegate\r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\r\n\t/*! The constructor\r\n\t *\r\n     *    @param [in] component               The component being edited.\r\n     *    @param [in] parameterNameCompleter  The completer to use for parameter names in expression editor.\r\n     *    @param [in] parameterFinder         The parameter finder to use for for expression editor.\r\n\t *    @param [in] parent                  The owner of the delegate.\r\n\t*/\r\n\tCpusDelegate(QSharedPointer<Component> component, QCompleter* parameterNameCompleter, \r\n\t\tQSharedPointer<ParameterFinder> parameterFinder, QObject *parent);\r\n\t\r\n\t//! The destructor.\r\n\tvirtual ~CpusDelegate() = default;\r\n\r\n    //! No copying\r\n    CpusDelegate(const CpusDelegate& other) = delete;\r\n    CpusDelegate& operator=(const CpusDelegate& other) = delete;\r\n\r\n\r\n\t/*! Create a new editor for the given item\r\n\t *\r\n\t *    @param [in] parent  Owner for the editor.\r\n\t *    @param [in] option  Contains options for the editor.\r\n\t *    @param [in] index   Model index identifying the item.\r\n\t *\r\n\t *    @return The editor to be used to edit the item.\r\n\t*/\r\n\tQWidget* createEditor(QWidget* parent, QStyleOptionViewItem const& option, \r\n        QModelIndex const& index) const final;\r\n\r\n\t/*! Set the data for the editor.\r\n\t *\r\n\t *    @param [in] editor The editor where the data is to be set.\r\n\t *    @param [in] index Model index identifying the item that's data is to be set.\r\n\t*/\r\n\tvoid setEditorData(QWidget* editor, QModelIndex const& index) const final;\r\n\r\n\t/*! Save the data from the editor to the model.\r\n\t *\r\n\t *    @param [in] editor  The editor that contains the data to store.\r\n\t *    @param [in] model   Model that contains the data structure where data is to be saved to.\r\n\t *    @param [in] index   Model index identifying the item that's data is to be saved.\r\n\t*/\r\n\tvoid setModelData(QWidget* editor, QAbstractItemModel* model, QModelIndex const& index) const final;\r\n\r\nsignals:\r\n\r\n    /*!\r\n     *  Increase the amount of references to a parameter corresponding to the id.\r\n     *\r\n     *    @param [in] id      The id of the parameter being searched for.\r\n     */\r\n    void increaseReferences(QString const& id);\r\n\r\n    /*!\r\n     *  Decrease the amount of references to a parameter corresponding to the id.\r\n     *\r\n     *    @param [in] id      The id of the parameter being searched for.\r\n     */\r\n    void decreaseReferences(QString const& id);\r\n\r\nprotected:\r\n\r\n    //! Filters events for editors.\r\n    bool eventFilter(QObject* editor, QEvent* event) final;\r\n\r\nprivate:\r\n\t\r\n    /*!\r\n     *  Check if the column is used for enumerations.\r\n     *\r\n     *    @param [in] index   The selected index.\r\n     *\r\n     *    @return True, if the column is used for editing enumerations, false otherwise.\r\n     */\r\n    bool isEnumerationEditorColumn(QModelIndex const& index) const final;\r\n\r\n    /*!\r\n     *  The list of currently selected enumerations in the selected item.\r\n     *\r\n     *    @param [in] index   Index of the selected item.\r\n     *\r\n     *    @return List of currently selected enumerations.\r\n     */\r\n    QStringList getCurrentSelection(QModelIndex const& index) const final;\r\n\r\n    /*!\r\n     *  Get the list of the available enumerations.\r\n     *\r\n     *    @return List of the available enumerations.\r\n     */\r\n    QStringList getAvailableItems() const final;\r\n\r\n    /*!\r\n     *  Set the selected enumerations to the selected item.\r\n     *\r\n     *    @param [in] index           Model index identifying the item that's data is to be saved.\r\n     *    @param [in] model           Model that contains the data structure where data is to be saved to.\r\n     *    @param [in] selectedItems   List of the selected enumerations.\r\n     */\r\n    void setEnumerationDataToModel(QModelIndex const& index, QAbstractItemModel* model, \r\n        QStringList const& selectedItems) const final;\r\n\r\n\t/*!\r\n\t *  Checks if given column accepts expressions as value.\r\n\t *\r\n\t *    @param [in] column The column number to check.\r\n\t *\r\n\t *    @return True, if column cells accept expressions, otherwise false.\r\n\t */\r\n\tbool columnAcceptsExpression(int column) const;\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n    // \r\n\t//! The component being edited.\r\n\tQSharedPointer<Component> component_;\r\n\r\n    //!  The completer to use for parameter names in expression editor.\r\n\tQCompleter* parameterNameCompleter_;\r\n\r\n    //! The parameter finder to use for for expression editor.\r\n\tQSharedPointer<ParameterFinder> parameterFinder_;\r\n\r\n};\r\n\r\n#endif // CPUSDELEGATE_H\r\n"
  },
  {
    "path": "editors/ComponentEditor/cpus/cpuseditor.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: cpuseditor.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 14.06.2012\r\n//\r\n// Description:\r\n// Editor to add/remove/edit the cpu-elements of a component.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"cpuseditor.h\"\r\n#include \"cpusdelegate.h\"\r\n#include \"CpuColumns.h\"\r\n\r\n#include <common/widgets/summaryLabel/summarylabel.h>\r\n#include <KactusAPI/include/LibraryInterface.h>\r\n\r\n#include <editors/ComponentEditor/parameters/ComponentParameterModel.h>\r\n\r\n#include <editors/common/ExpressionSet.h>\r\n\r\n#include <IPXACTmodels/Component/Component.h>\r\n\r\n#include <QCompleter>\r\n#include <QVBoxLayout>\r\n#include <QHeaderView>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: CpusEditor::CpusEditor()\r\n//-----------------------------------------------------------------------------\r\nCpusEditor::CpusEditor(QSharedPointer<Component> component, LibraryInterface* handler, \r\n    QSharedPointer<CPUValidator> validator, \r\n    ExpressionSet expressions,\r\n\tQWidget* parent) :\r\nItemEditor(component, handler, parent),\r\n    view_(this),\r\n    proxy_(this),\r\n    model_(component, validator, expressions, this)\r\n{\r\n    // display a label on top the table\r\n    SummaryLabel* summaryLabel = new SummaryLabel(tr(\"CPUs summary\"), this);\r\n\r\n\tQVBoxLayout* layout = new QVBoxLayout(this);\r\n\tlayout->addWidget(summaryLabel, 0, Qt::AlignCenter);\r\n\tlayout->addWidget(&view_);\r\n\tlayout->setContentsMargins(0, 0, 0, 0);\r\n\r\n\tproxy_.setSourceModel(&model_);\r\n\tview_.setModel(&proxy_);\r\n\r\n\tif (component->getRevision() == Document::Revision::Std14)\r\n    {\r\n        view_.horizontalHeader()->hideSection(CpuColumns::SHORT_DESCRIPTION);\r\n        view_.horizontalHeader()->hideSection(CpuColumns::MEMORY_MAP);\r\n        view_.horizontalHeader()->hideSection(CpuColumns::RANGE);\r\n        view_.horizontalHeader()->hideSection(CpuColumns::WIDTH);\r\n        view_.horizontalHeader()->hideSection(CpuColumns::AUB);\r\n\t}\r\n\telse if (component->getRevision() == Document::Revision::Std22)\r\n    {\r\n        view_.horizontalHeader()->hideSection(CpuColumns::ADDRSPACE);\r\n\t}\r\n\r\n\tconst QString compPath = handler->getDirectoryPath(component->getVlnv());\r\n\tQString defPath = QString(\"%1/cpusListing.csv\").arg(compPath);\r\n\tview_.setDefaultImportExportPath(defPath);\r\n\tview_.setAllowImportExport(true);\r\n\tview_.setItemsDraggable(false);\r\n\r\n    ComponentParameterModel* parameterModel = new ComponentParameterModel(expressions.finder, this);\r\n    parameterModel->setExpressionParser(expressions.parser);\r\n\r\n    auto parameterCompleter = new QCompleter(this);\r\n    parameterCompleter->setModel(parameterModel);\r\n\r\n\tauto delegate = new CpusDelegate(component, parameterCompleter, expressions.finder, this);\r\n\tview_.setItemDelegate(delegate);\r\n\r\n    connect(delegate, SIGNAL(increaseReferences(QString)),\r\n        this, SIGNAL(increaseReferences(QString)), Qt::UniqueConnection);\r\n    connect(delegate, SIGNAL(decreaseReferences(QString)),\r\n        this, SIGNAL(decreaseReferences(QString)), Qt::UniqueConnection);\r\n\r\n    connect(&model_, SIGNAL(decreaseReferences(QString)),\r\n        this, SIGNAL(decreaseReferences(QString)), Qt::UniqueConnection);\r\n\r\n\tconnect(&model_, SIGNAL(contentChanged()), this, SIGNAL(contentChanged()), Qt::UniqueConnection);\r\n\tconnect(&model_, SIGNAL(cpuAdded(int)),\tthis, SIGNAL(childAdded(int)), Qt::UniqueConnection);\r\n\tconnect(&model_, SIGNAL(cpuRemoved(int)), this, SIGNAL(childRemoved(int)), Qt::UniqueConnection);\r\n\r\n\tconnect(&view_, SIGNAL(addItem(const QModelIndex&)),\r\n        &model_, SLOT(onAddItem(const QModelIndex&)), Qt::UniqueConnection);\r\n\tconnect(&view_, SIGNAL(removeItem(const QModelIndex&)),\r\n\t\t&model_, SLOT(onRemoveItem(const QModelIndex&)), Qt::UniqueConnection);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: CpusEditor::refresh()\r\n//-----------------------------------------------------------------------------\r\nvoid CpusEditor::refresh()\r\n{\r\n\tview_.update();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: CpusEditor::showEvent()\r\n//-----------------------------------------------------------------------------\r\nvoid CpusEditor::showEvent(QShowEvent* event)\r\n{\r\n\tQWidget::showEvent(event);\r\n\t\r\n\tif (component()->getRevision() == Document::Revision::Std22)\r\n    {\r\n        emit helpUrlRequested(\"componenteditor/cpus2022.html\");\r\n\t}\r\n\telse\r\n\t{\r\n        emit helpUrlRequested(\"componenteditor/cpus.html\");\r\n\t}\r\n}\r\n"
  },
  {
    "path": "editors/ComponentEditor/cpus/cpuseditor.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: cpuseditor.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 14.06.2012\r\n//\r\n// Description:\r\n// Editor to add/remove/edit the cpu-elements of a component.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef CPUSEDITOR_H\r\n#define CPUSEDITOR_H\r\n\r\n#include <common/views/EditableTableView/editabletableview.h>\r\n\r\n#include <editors/ComponentEditor/itemeditor.h>\r\n\r\n#include \"cpusmodel.h\"\r\n\r\n#include <QSortFilterProxyModel>\r\n#include <QSharedPointer>\r\n\r\nclass Component;\r\nclass CPUValidator;\r\nclass LibraryInterface;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Editor to add/remove/edit the cpu-elements of a component.\r\n//-----------------------------------------------------------------------------\r\nclass CpusEditor : public ItemEditor\r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\r\n\t/*! The constructor\r\n\t *\r\n\t *    @param [in] component   The component being edited.\r\n\t *    @param [in] handler     The instance managing the library.\r\n     *    @param [in] validator   The validator for cpus.\r\n     *    @param [in] expressions\tThe collection of objects for expression handling.\r\n\t *    @param [in] parent      The parent of this editor.\r\n\t*/\r\n\tCpusEditor(QSharedPointer<Component> component, LibraryInterface* handler, \r\n        QSharedPointer<CPUValidator> validator,\r\n\t\tExpressionSet expressions,\r\n\t\tQWidget* parent = 0);\r\n\t\r\n\t//! The destructor\r\n\tvirtual ~CpusEditor() = default;\r\n\r\n    //! No copying\r\n    CpusEditor(const CpusEditor& other) = delete;\r\n    CpusEditor& operator=(const CpusEditor& other) = delete;\r\n\r\n\t//! Reload the information from the model to the editor.\t\r\n\tvoid refresh() final;\r\n\r\nprotected:\r\n\r\n\t//! Handler for widget's show event\r\n\tvoid showEvent(QShowEvent* event) final;\r\n\r\nprivate:\r\n\r\n\t//! The view to display the cpus\r\n\tEditableTableView view_;\r\n\r\n\t//! The model that does the sorting.\r\n\tQSortFilterProxyModel proxy_;\r\n\r\n\t//! The model that manages the cpus of the editor.\r\n\tCpusModel model_;\r\n};\r\n\r\n#endif // CPUSEDITOR_H\r\n"
  },
  {
    "path": "editors/ComponentEditor/cpus/cpusmodel.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: cpusmodel.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 14.06.2012\r\n//\r\n// Description:\r\n// Model for cpu elements within a component.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"cpusmodel.h\"\r\n\r\n#include \"CpuColumns.h\"\r\n\r\n#include <IPXACTmodels/Component/Component.h>\r\n#include <IPXACTmodels/Component/Cpu.h>\r\n\r\n#include <IPXACTmodels/Component/validators/CPUValidator.h>\r\n\r\n#include <QStringList>\r\n#include <QRegularExpression>\r\n\r\n#include <common/KactusColors.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: CpusModel::CpusModel()\r\n//-----------------------------------------------------------------------------\r\nCpusModel::CpusModel(QSharedPointer<Component> component, QSharedPointer<CPUValidator> validator,\r\n    ExpressionSet expressions,\r\n    QObject* parent): \r\n    ReferencingTableModel(expressions.finder, parent),\r\n    ParameterizableTable(expressions.finder),\r\n    component_(component),\r\n    cpus_(component->getCpus()),\r\n    validator_(validator),\r\n    expressionFormatter_(expressions.formatter)\r\n{\r\n    setExpressionParser(expressions.parser);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: CpusModel::rowCount()\r\n//-----------------------------------------------------------------------------\r\nint CpusModel::rowCount(QModelIndex const& parent) const\r\n{\r\n\tif (parent.isValid())\r\n    {\r\n\t\treturn 0;\r\n\t}\r\n\r\n\treturn cpus_->count();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: CpusModel::columnCount()\r\n//-----------------------------------------------------------------------------\r\nint CpusModel::columnCount(QModelIndex const& parent) const\r\n{\r\n\tif (parent.isValid())\r\n    {\r\n\t\treturn 0;\r\n\t}\r\n\r\n\treturn CpuColumns::COLUMN_COUNT;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: CpusModel::flags()\r\n//-----------------------------------------------------------------------------\r\nQt::ItemFlags CpusModel::flags(QModelIndex const& index) const\r\n{\r\n\tif (!index.isValid())\r\n    {\r\n\t\treturn Qt::NoItemFlags;\r\n\t}\r\n\r\n\treturn Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsEditable;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: CpusModel::headerData()\r\n//-----------------------------------------------------------------------------\r\nQVariant CpusModel::headerData(int section, Qt::Orientation orientation, int role) const\r\n{\r\n\tif (orientation != Qt::Horizontal || role != Qt::DisplayRole)\r\n    {\r\n        return QVariant();\r\n    }\r\n\r\n    if (section == CpuColumns::NAME)\r\n    {\r\n        return tr(\"Name\");\r\n    }\r\n    else if (section == CpuColumns::DISPLAY_NAME)\r\n    {\r\n        return tr(\"Display\\nname\");\r\n    }\r\n    else if (section == CpuColumns::SHORT_DESCRIPTION)\r\n    {\r\n        return tr(\"Short\\ndescription\");\r\n    }\r\n    else if (section == CpuColumns::ADDRSPACE)\r\n    {\r\n        return tr(\"Address space\\nreferences\");\r\n    }\r\n    else if (section == CpuColumns::MEMORY_MAP)\r\n    {\r\n        return tr(\"Memory map\\nreference\");\r\n    }\r\n    else if (section == CpuColumns::RANGE)\r\n    {\r\n        return tr(\"Range\") + getExpressionSymbol();\r\n    }\r\n    else if (section == CpuColumns::WIDTH)\r\n    {\r\n        return tr(\"Width\\n[bits]\") + getExpressionSymbol();\r\n    }\r\n    else if (section == CpuColumns::AUB)\r\n    {\r\n        return tr(\"Address unit\\nbits\") + getExpressionSymbol();\r\n    }\r\n    else if (section == CpuColumns::DESCRIPTION)\r\n    {\r\n        return tr(\"Description\");\r\n    }\r\n    else\r\n    {\r\n        return QVariant();\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: CpusModel::data()\r\n//-----------------------------------------------------------------------------\r\nQVariant CpusModel::data(QModelIndex const& index, int role) const\r\n{\r\n    if (!index.isValid() || index.row() < 0 || index.row() >= cpus_->size())\r\n    {\r\n        return QVariant();\r\n    }\r\n\r\n    QSharedPointer<Cpu> cpu = cpus_->at(index.row());\r\n    const int column = index.column(); \r\n\r\n    if (role == Qt::DisplayRole)\r\n    {\r\n        if (isValidExpressionColumn(index))\r\n        {\r\n            return expressionFormatter_->formatReferringExpression(valueForIndex(index).toString());\r\n        }\r\n        else if (index.column() == CpuColumns::DESCRIPTION)\r\n        {\r\n            return valueForIndex(index).toString().replace(QRegularExpression(\"\\n.*$\",\r\n                QRegularExpression::DotMatchesEverythingOption), \"...\");\r\n        }\r\n        else\r\n        {\r\n            return valueForIndex(index).toString();\r\n        }\r\n    }\r\n\r\n    else if (role == Qt::EditRole)\r\n    {\r\n        return expressionOrValueForIndex(index);\r\n    }\r\n\r\n    else if (role == Qt::ToolTipRole)\r\n    {\r\n        if (isValidExpressionColumn(index))\r\n        {\r\n            return formattedValueFor(valueForIndex(index).toString());\r\n        }\r\n        else\r\n        {\r\n            return expressionOrValueForIndex(index);\r\n        }\r\n    }\r\n    else if (role == CpuColumns::USER_DISPLAY_ROLE && column == CpuColumns::ADDRSPACE)\r\n    {\r\n        return cpu->getAddressSpaceRefs();\r\n    }\r\n    else if (role == Qt::ForegroundRole)\r\n    {\r\n\r\n        return blackForValidOrRedForInvalidIndex(index);\r\n    }\r\n    else if (role == Qt::BackgroundRole)\r\n    {\r\n        if (column == CpuColumns::NAME || column == CpuColumns::ADDRSPACE ||\r\n            column == CpuColumns::MEMORY_MAP || column == CpuColumns::RANGE || column == CpuColumns::WIDTH)\r\n        {\r\n            return KactusColors::MANDATORY_FIELD;\r\n        }\r\n        else\r\n        {\r\n            return KactusColors::REGULAR_FIELD;\r\n        }\r\n    }\r\n\r\n    // if unsupported role\r\n    return QVariant();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: CpusModel::setData()\r\n//-----------------------------------------------------------------------------\r\nbool CpusModel::setData(QModelIndex const& index, QVariant const& value, int role)\r\n{\r\n\tif (!index.isValid() || index.row() < 0 || index.row() >= cpus_->size())\r\n    {\r\n\t\treturn false;\r\n\t}\r\n\r\n    QSharedPointer<Cpu> cpu = cpus_->at(index.row());\r\n    const int column = index.column();\r\n    if (role == Qt::EditRole)\r\n    {\r\n        if (column == CpuColumns::NAME)\r\n        {\r\n            cpu->setName(value.toString());\r\n        }\r\n        else if (column == CpuColumns::DISPLAY_NAME)\r\n        {\r\n            cpu->setDisplayName(value.toString());\t\t\r\n        }\r\n        else if (column == CpuColumns::SHORT_DESCRIPTION)\r\n        {\r\n            cpu->setShortDescription(value.toString());\r\n        }\r\n        else if (column == CpuColumns::ADDRSPACE)\r\n        {\r\n            QString str = value.toString();\r\n            QStringList addrSpaceNames = str.split(' ', Qt::SkipEmptyParts);\r\n            cpu->setAddressSpaceRefs(addrSpaceNames);\r\n        }\r\n        else if (column == CpuColumns::MEMORY_MAP)\r\n        {\r\n            cpu->setMemoryMapReference(value.toString());\r\n        }\r\n        else if (column == CpuColumns::RANGE)\r\n        {\r\n            cpu->setRange(value.toString());\r\n        }\r\n        else if (column == CpuColumns::WIDTH)\r\n        {\r\n            cpu->setWidth(value.toString());\r\n        }\r\n        else if (column == CpuColumns::AUB)\r\n        {\r\n            cpu->setAddressUnitBits(value.toString());\r\n        }\r\n        else if (column == CpuColumns::DESCRIPTION)\r\n        {\r\n            cpus_->at(index.row())->setDescription(value.toString());\r\n        }\r\n        else\r\n        {\r\n            return false;\r\n        }\r\n\r\n\t\temit dataChanged(index, index);\r\n\t\temit contentChanged();\r\n\t\treturn true;\r\n\t}\r\n\r\n\t// user edit role for interface column operates on QStringList\r\n    else if (role == CpuColumns::USER_EDIT_ROLE && column == CpuColumns::ADDRSPACE)\r\n    {\r\n        cpu->setAddressSpaceRefs(value.toStringList());\r\n        emit dataChanged(index, index);\r\n        emit contentChanged();\r\n        return true;\r\n    }\r\n    else\r\n    {\r\n\t\treturn false;\r\n\t}\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: CpusModel::getAllReferencesToIdInItemOnRow()\r\n//-----------------------------------------------------------------------------\r\nint CpusModel::getAllReferencesToIdInItemOnRow(const int& row, QString const& valueID) const\r\n{\r\n    int total = 0;\r\n\r\n    QSharedPointer<Cpu> cpu = cpus_->at(row);\r\n    total += cpu->getRange().count(valueID);\r\n    total += cpu->getWidth().count(valueID);\r\n    total += cpu->getAddressUnitBits().count(valueID);\r\n\r\n    return total;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: CpusModel::isValidExpressionColumn()\r\n//-----------------------------------------------------------------------------\r\nbool CpusModel::isValidExpressionColumn(QModelIndex const& index) const\r\n{\r\n    return index.column() == CpuColumns::RANGE || index.column() == CpuColumns::WIDTH ||\r\n        index.column() == CpuColumns::AUB;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: CpusModel::expressionOrValueForIndex()\r\n//-----------------------------------------------------------------------------\r\nQVariant CpusModel::expressionOrValueForIndex(QModelIndex const& index) const\r\n{\r\n    QSharedPointer<Cpu> cpu = cpus_->at(index.row());\r\n    const int column = index.column();\r\n\r\n    if (column == CpuColumns::NAME)\r\n    {\r\n        return cpu->name();\r\n    }\r\n    else if (column == CpuColumns::DISPLAY_NAME)\r\n    {\r\n        return cpu->displayName();\r\n    }\r\n    else if (column == CpuColumns::SHORT_DESCRIPTION)\r\n    {\r\n        return cpu->shortDescription();\r\n    }\r\n    else if (column == CpuColumns::ADDRSPACE)\r\n    {\r\n        QStringList addrSpaceNames = cpu->getAddressSpaceRefs();\r\n        return addrSpaceNames.join(' ');\r\n    }\r\n    else if (column == CpuColumns::MEMORY_MAP)\r\n    {\r\n        return cpu->getMemoryMapReference();\r\n    }\r\n    else if (column == CpuColumns::RANGE)\r\n    {\r\n        return cpu->getRange();\r\n    }\r\n    else if (column == CpuColumns::WIDTH)\r\n    {\r\n        return cpu->getWidth();\r\n    }\r\n    else if (column == CpuColumns::AUB)\r\n    {\r\n        return cpu->getAddressUnitBits();\r\n    }\r\n    else if (column == CpuColumns::DESCRIPTION)\r\n    {\r\n        return cpu->description();\r\n    }\r\n    else\r\n    {\r\n        return QVariant();\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: CpusModel::validateIndex()\r\n//-----------------------------------------------------------------------------\r\nbool CpusModel::validateIndex(QModelIndex const& index) const\r\n{\r\n    if (index.column() == CpuColumns::ADDRSPACE &&\r\n        !validator_->hasValidAddressSpaceReferences(cpus_->at(index.row())))\r\n    {\r\n        return false;\r\n    }\r\n    else if (index.column() == CpuColumns::MEMORY_MAP &&\r\n        !validator_->hasValidMemoryMapReference(cpus_->at(index.row())))\r\n    {\r\n        return false;\r\n    }\r\n    else if (index.column() == CpuColumns::RANGE &&\r\n        !validator_->hasValidRange(cpus_->at(index.row())))\r\n    {\r\n        return false;\r\n    }\r\n    else if (index.column() == CpuColumns::WIDTH &&\r\n        !validator_->hasValidWidth(cpus_->at(index.row())))\r\n    {\r\n        return false;\r\n    }\r\n    else if (index.column() == CpuColumns::AUB && \r\n        !validator_->hasValidAddressUnitBits(cpus_->at(index.row())))\r\n    {\r\n        return false;\r\n    }\r\n    else\r\n    {\r\n        return true;\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: CpusModel::onAddItem()\r\n//-----------------------------------------------------------------------------\r\nvoid CpusModel::onAddItem(QModelIndex const& index)\r\n{\r\n\tint row = cpus_->size();\r\n\r\n\t// if the index is valid then add the item to the correct position\r\n\tif (index.isValid())\r\n    {\r\n\t\trow = index.row();\r\n\t}\r\n\r\n\tbeginInsertRows(QModelIndex(), row, row);\r\n\tcpus_->insert(row, QSharedPointer<Cpu>(new Cpu()));\r\n\tendInsertRows();\r\n\r\n\t// inform navigation tree that file set is added\r\n\temit cpuAdded(row);\r\n\r\n\t// tell also parent widget that contents have been changed\r\n\temit contentChanged();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: CpusModel::onRemoveItem()\r\n//-----------------------------------------------------------------------------\r\nvoid CpusModel::onRemoveItem(QModelIndex const& index)\r\n{\r\n\t// don't remove anything if index is invalid\r\n\tif (!index.isValid() || index.row() < 0 || index.row() >= cpus_->size())\r\n    {\r\n\t\treturn;\r\n\t}\r\n\r\n\t// remove the specified item\r\n\tbeginRemoveRows(QModelIndex(), index.row(), index.row());\r\n    removeReferencesInItemOnRow(index.row());\r\n\tcpus_->removeAt(index.row());\r\n\tendRemoveRows();\r\n\r\n\t// inform navigation tree that file set has been removed\r\n\temit cpuRemoved(index.row());\r\n\r\n\t// tell also parent widget that contents have been changed\r\n\temit contentChanged();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: CpusModel::valueForIndex()\r\n//-----------------------------------------------------------------------------\r\nQVariant CpusModel::valueForIndex(QModelIndex const& index) const\r\n{\r\n    return expressionOrValueForIndex(index);\r\n}\r\n"
  },
  {
    "path": "editors/ComponentEditor/cpus/cpusmodel.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: cpusmodel.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 14.06.2012\r\n//\r\n// Description:\r\n//! Model for cpu elements within a component.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef CPUSMODEL_H\r\n#define CPUSMODEL_H\r\n\r\n#include <editors/ComponentEditor/common/ParameterizableTable.h>\r\n#include <editors/ComponentEditor/common/ReferencingTableModel.h>\r\n\r\n#include <editors/common/ExpressionSet.h>\r\n\r\n#include <KactusAPI/include/ExpressionFormatter.h>\r\n\r\n#include <QAbstractTableModel>\r\n#include <QSharedPointer>\r\n#include <QList>\r\n\r\nclass Component;\r\nclass Cpu;\r\nclass CPUValidator;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Model for cpu elements within a component.\r\n//-----------------------------------------------------------------------------\r\nclass CpusModel : public ReferencingTableModel, public ParameterizableTable\r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\r\n\t/*! The constructor\r\n\t *\r\n\t *    @param [in] component   The component being edited.\r\n     *    @param [in] validator   The validator for cpus.\r\n\t *    @param [in] parent      The owner of this model.\r\n\t*/\r\n\tCpusModel(QSharedPointer<Component> component, QSharedPointer<CPUValidator> validator,\r\n\t\tExpressionSet expressions,\r\n        QObject* parent);\r\n\t\r\n\t//! The destructor\r\n\tvirtual ~CpusModel() = default;\r\n\r\n    //! No copying\r\n    CpusModel(const CpusModel& other) = delete;\r\n    CpusModel& operator=(const CpusModel& other) = delete;\r\n\r\n\t/*! Get the number of rows an item contains.\r\n\t *\r\n\t *    @param [in] parent Identifies the parent that's row count is requested.\r\n\t *\r\n\t *    @return Number of rows the item has.\r\n\t*/\r\n\tint rowCount(const QModelIndex& parent = QModelIndex()) const final;\r\n\r\n\t/*! Get the number of columns the item has to be displayed.\r\n\t *\r\n\t *    @param [in] parent Identifies the parent that's column count is requested.\r\n\t *\r\n\t *    @return The number of columns to be displayed.\r\n\t*/\r\n\tint columnCount(const QModelIndex& parent = QModelIndex()) const final;\r\n\r\n\t/*! Get the item flags that defines the possible operations for the item.\r\n\t *\r\n\t *    @param [in] index Model index that identifies the item.\r\n\t *\r\n\t *    @return Qt::ItemFlags specify the possible operations for the item.\r\n\t*/\r\n\tQt::ItemFlags flags(const QModelIndex& index) const final;\r\n\r\n\t/*! Get the header data for specified header.\r\n\t *\r\n\t *    @param [in] section The section specifies the row/column number for the header.\r\n\t *    @param [in] orientation Specified if horizontal or vertical header is wanted.\r\n\t *    @param [in] role Specifies the type of the requested data.\r\n\t *\r\n\t *    @return QVariant Contains the requested data.\r\n\t*/\r\n\tQVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const final;\r\n\r\n\t/*! Get the data for specified item.\r\n\t *\r\n\t *    @param [in] index Specifies the item that's data is requested.\r\n\t *    @param [in] role The role that defines what kind of data is requested.\r\n\t *\r\n\t *    @return QVariant Contains the data for the item.\r\n\t*/\r\n\tQVariant data(QModelIndex const& index, int role = Qt::DisplayRole) const final;\r\n\r\n\t/*! Save the data to the model for specified item\r\n\t *\r\n\t *    @param [in] index The model index of the item that's data is to be saved.\r\n\t *    @param [in] value The data that is to be saved.\r\n\t *    @param [in] role The role specifies what kind of data should be saved.\r\n\t *\r\n\t *    @return True if saving was successful.\r\n\t*/\r\n\tbool setData(QModelIndex const& index, QVariant const& value, int role = Qt::EditRole) final;\r\n\r\nprotected:\r\n\r\n\t/*!\r\n\t *  Gets the number of all the references made to a selected id on the selected row.\r\n\t *\r\n\t *    @param [in] row         The row of the selected item.\r\n\t *    @param [in] valueID     The id of the referenced parameter.\r\n\t *\r\n\t *    @return The amount of references made to the selected id on the selected row.\r\n\t */\r\n    int getAllReferencesToIdInItemOnRow(const int& row, QString const& valueID) const final;\r\n\r\n\t/*!\r\n\t*  Check if the column index is valid for containing expressions.\r\n\t*\r\n\t*    @param [in] index   The index being evaluated.\r\n\t*\r\n\t*    @return     True, if column can have expressions, false otherwise.\r\n\t*/\r\n\tbool isValidExpressionColumn(QModelIndex const& index) const final;\r\n\r\n\t/*!\r\n\t *  Gets the expression for the given index or the plain value if expression is not available.\r\n\t *\r\n\t *    @param [in] index   The index whose expression to get.\r\n\t *\r\n\t *    @return The expression for the index if available, otherwise the value for the given index.\r\n\t */\r\n\tQVariant expressionOrValueForIndex(QModelIndex const& index) const final;\r\n\r\n\t/*!\r\n\t *  Validates the data in an index.\r\n\t *\r\n\t *    @param [in] index   The index whose data to validate\r\n\t *\r\n\t *    @return True, if the data in the index is valid, otherwise false.\r\n\t */\r\n\tbool validateIndex(QModelIndex const& index) const final;\r\n\r\npublic slots:\r\n\r\n\t/*! Add a new item to the given index.\r\n\t *\r\n\t *    @param [in] index The index identifying the position for new item.\r\n\t*/\r\n\tvirtual void onAddItem(const QModelIndex& index);\r\n\r\n\t/*! Remove the item in the given index.\r\n\t *\r\n\t *    @param [in] index The index identifying the item to remove.\r\n\t*/\r\n\tvirtual void onRemoveItem(const QModelIndex& index);\r\n\r\nsignals:\r\n\r\n\t//! Emitted when the contents of the model change.\r\n\tvoid contentChanged();\r\n\r\n\t/*! Emitted when a new cpu is added to the model.\r\n\t *\r\n\t *    @param [in] index The index of the added cpu.\r\n\t*/\r\n\tvoid cpuAdded(int index);\r\n\r\n\t/*! Emitted when a cpu is removed from the model.\r\n\t *\r\n\t *    @param [in] index The index of the removed cpu.\r\n\t*/\r\n\tvoid cpuRemoved(int index);\r\n\r\nprivate:\r\n\r\n\t//! Gets the value of the cell in index.\r\n    QVariant valueForIndex(QModelIndex const& index) const;\r\n\r\n\t//! The component being edited.\r\n\tQSharedPointer<Component> component_;\r\n\r\n\t//! Contains the cpus being edited.\r\n\tQSharedPointer<QList<QSharedPointer<Cpu> > > cpus_;\r\n\r\n\t//! Validator for the CPU element.\r\n    QSharedPointer<CPUValidator> validator_;\r\n\r\n\t//! Formatter to use for expressions.\r\n\tQSharedPointer<ExpressionFormatter> expressionFormatter_;\r\n};\r\n\r\n#endif // CPUSMODEL_H\r\n"
  },
  {
    "path": "editors/ComponentEditor/fileBuilders/FileBuilderColumns.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: FileBuilderColumns.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Mikko Teuho\r\n// Date: 19.10.2015\r\n//\r\n// Description:\r\n// Common declarations for editing file builders.\r\n//-----------------------------------------------------------------------------\r\n\r\nnamespace FileBuilderColumns\r\n{\r\n    //! The editable columns in the file builder editor.\r\n    enum columns\r\n    {\r\n        FILETYPE_COLUMN = 0,\r\n        COMMAND_COLUMN,\r\n        FLAGS_COLUMN,\r\n        REPLACE_DEFAULT_COLUMN,\r\n        COLUMN_COUNT\r\n    };\r\n}\r\n"
  },
  {
    "path": "editors/ComponentEditor/fileBuilders/filebuildersdelegate.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: filebuildersdelegate.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 18.04.2011\r\n//\r\n// Description:\r\n// Delegate to provide editors to edit file builders.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"filebuildersdelegate.h\"\r\n#include \"FileBuilderColumns.h\"\r\n\r\n#include <common/widgets/booleanComboBox/booleancombobox.h>\r\n#include <common/widgets/fileTypeSelector/filetypeselector.h>\r\n\r\n#include <QComboBox>\r\n#include <QLineEdit>\r\n#include <QStringList>\r\n#include <QPainter>\r\n#include <QApplication>\r\n#include <QMouseEvent>\r\n#include <QEvent>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: filebuildersdelegate::FileBuildersDelegate()\r\n//-----------------------------------------------------------------------------\r\nFileBuildersDelegate::FileBuildersDelegate(QAbstractItemModel* completionModel,\r\n                                           QSharedPointer<ParameterFinder> parameterFinder, QObject *parent):\r\nExpressionDelegate(completionModel, parameterFinder, parent)\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: filebuildersdelegate::~FileBuildersDelegate()\r\n//-----------------------------------------------------------------------------\r\nFileBuildersDelegate::~FileBuildersDelegate()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: filebuildersdelegate::createEditor()\r\n//-----------------------------------------------------------------------------\r\nQWidget* FileBuildersDelegate::createEditor( QWidget* parent, const QStyleOptionViewItem& option,\r\n                                             const QModelIndex& index ) const\r\n{\r\n\t// if editor for file type or replace default flags\r\n\tif (index.column() == FileBuilderColumns::FILETYPE_COLUMN)\r\n    {\r\n\t\tFileTypeSelector* typeEditor = new FileTypeSelector(parent);\r\n\t\ttypeEditor->refresh();\r\n\t\ttypeEditor->setMaxVisibleItems(25);\r\n\t\ttypeEditor->setMinimumContentsLength(30);\r\n\r\n\t\treturn typeEditor;\r\n\t}\r\n\t// if editor for command or flags\r\n    else if (index.column() == FileBuilderColumns::COMMAND_COLUMN ||\r\n        index.column() == FileBuilderColumns::FLAGS_COLUMN)\r\n    {\r\n\t\tQLineEdit* lineEditor = new QLineEdit(parent);\r\n\t\tconnect(lineEditor, SIGNAL(editingFinished()), this, SLOT(commitAndCloseEditor()), Qt::UniqueConnection);\r\n\t\treturn lineEditor;\r\n\t}\r\n\telse\r\n    {\r\n        return ExpressionDelegate::createEditor(parent, option, index);\r\n\t}\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: filebuildersdelegate::setEditorData()\r\n//-----------------------------------------------------------------------------\r\nvoid FileBuildersDelegate::setEditorData( QWidget* editor, const QModelIndex& index ) const\r\n{\r\n\t// if editor for file type\r\n\tif (index.column() == FileBuilderColumns::FILETYPE_COLUMN)\r\n    {\r\n\t\tQString text = index.model()->data(index, Qt::DisplayRole).toString();\r\n\t\tFileTypeSelector* combo = qobject_cast<FileTypeSelector*>(editor);\r\n\r\n\t\tcombo->selectFileType(text);\r\n\t}\r\n\t// if editor for command or flags\r\n    else if (index.column() == FileBuilderColumns::COMMAND_COLUMN ||\r\n        index.column() == FileBuilderColumns::FLAGS_COLUMN)\r\n    {\r\n\t\tQLineEdit* defaultEdit = qobject_cast<QLineEdit*>(editor);\r\n\t\tQString value = index.model()->data(index, Qt::DisplayRole).toString();\r\n\t\tdefaultEdit->setText(value);\r\n\t}\r\n\t// use the default delegate\r\n\telse\r\n    {\r\n        ExpressionDelegate::setEditorData(editor, index);\r\n\t}\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: filebuildersdelegate::setModelData()\r\n//-----------------------------------------------------------------------------\r\nvoid FileBuildersDelegate::setModelData( QWidget* editor, QAbstractItemModel* model, const QModelIndex& index )\r\n    const\r\n{\r\n\t// if editor for file type\r\n\tif (index.column() == FileBuilderColumns::FILETYPE_COLUMN)\r\n    {\r\n\t\tFileTypeSelector* combo = qobject_cast<FileTypeSelector*>(editor);\r\n\t\tQString text = combo->currentText();\r\n\t\tmodel->setData(index, text, Qt::EditRole);\r\n\t}\r\n\t// if editor for command or flags\r\n    else if (index.column() == FileBuilderColumns::COMMAND_COLUMN ||\r\n        index.column() == FileBuilderColumns::FLAGS_COLUMN)\r\n    {\r\n\t\tQLineEdit* defaultEdit = qobject_cast<QLineEdit*>(editor);\r\n\t\tQString value = defaultEdit->text();\r\n\t\tmodel->setData(index, value, Qt::EditRole);\r\n\t}\r\n\t// use the default delegate\r\n\telse\r\n    {\r\n        ExpressionDelegate::setModelData(editor, model, index);\r\n\t}\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: filebuildersdelegate::commitAndCloseEditor()\r\n//-----------------------------------------------------------------------------\r\nvoid FileBuildersDelegate::commitAndCloseEditor()\r\n{\r\n\tQComboBox* comboEditor = qobject_cast<QComboBox*>(sender());\r\n\tQLineEdit* lineEditor = qobject_cast<QLineEdit*>(sender());\r\n\tQWidget* editor = qobject_cast<QWidget*>(sender());\r\n\r\n\tif (comboEditor)\r\n    {\r\n\t\temit commitData(comboEditor);\r\n\t\temit closeEditor(comboEditor);\r\n\t}\r\n\telse if (lineEditor)\r\n    {\r\n\t\temit commitData(lineEditor);\r\n\t\temit closeEditor(lineEditor);\r\n\t}\r\n\telse\r\n    {\r\n\t\temit commitData(editor);\r\n\t\temit closeEditor(editor);\r\n\t}\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: filebuildersdelegate::paint()\r\n//-----------------------------------------------------------------------------\r\nvoid FileBuildersDelegate::paint( QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index )\r\n    const\r\n{\r\n\tQStyleOptionViewItem viewItemOption(option);\r\n\tQStyledItemDelegate::paint(painter, viewItemOption, index);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: filebuildersdelegate::editorEvent()\r\n//-----------------------------------------------------------------------------\r\nbool FileBuildersDelegate::editorEvent( QEvent *event, QAbstractItemModel *model,\r\n                                        const QStyleOptionViewItem &option, const QModelIndex &index )\r\n{\r\n\tQ_ASSERT(event);\r\n\tQ_ASSERT(model);\r\n\r\n\t// Make sure that the item is checkable.\r\n\tQt::ItemFlags flags = model->flags(index);\r\n\r\n\tif (!(flags & Qt::ItemIsUserCheckable) || !(flags & Qt::ItemIsEnabled))\r\n\t{\r\n\t\treturn false;\r\n\t}\r\n\r\n\t// Make sure that we have a check state.\r\n\tQVariant value = index.data(Qt::CheckStateRole);\r\n\r\n\tif (!value.isValid())\r\n\t{\r\n\t\treturn false;\r\n\t}\r\n\r\n\tQt::CheckState newState;\r\n\r\n\t// Handle the mouse button events.\r\n\tif (event->type() == QEvent::MouseButtonPress)\r\n\t{\r\n\t\tconst int textMargin = QApplication::style()->pixelMetric(QStyle::PM_FocusFrameHMargin) + 1;\r\n\r\n\t\tQRect checkRect = QStyle::alignedRect(option.direction, Qt::AlignCenter,\r\n\t\t\toption.decorationSize,\r\n\t\t\tQRect(option.rect.x() + (2 * textMargin), option.rect.y(),\r\n\t\t\toption.rect.width() - (2 * textMargin),\r\n\t\t\toption.rect.height()));\r\n\r\n\t\tif (!checkRect.contains(static_cast<QMouseEvent*>(event)->pos()))\r\n\t\t{\r\n\t\t\treturn false;\r\n\t\t}\r\n\r\n\t\tnewState = (static_cast<Qt::CheckState>(value.toInt()) == Qt::Checked ? Qt::Unchecked : Qt::Checked);\r\n\t}\r\n\telse {\r\n\t\treturn false;\r\n\t}\r\n\r\n\treturn model->setData(index, newState, Qt::CheckStateRole);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: filebuildersdelegate::columnAcceptsExpression()\r\n//-----------------------------------------------------------------------------\r\nbool FileBuildersDelegate::columnAcceptsExpression(int column) const\r\n{\r\n    return column == FileBuilderColumns::REPLACE_DEFAULT_COLUMN;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: filebuildersdelegate::descriptionColumn()\r\n//-----------------------------------------------------------------------------\r\nint FileBuildersDelegate::descriptionColumn() const\r\n{\r\n    return FileBuilderColumns::COLUMN_COUNT;\r\n}\r\n"
  },
  {
    "path": "editors/ComponentEditor/fileBuilders/filebuildersdelegate.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: filebuildersdelegate.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 18.04.2011\r\n//\r\n// Description:\r\n// Delegate to provide editors to edit file builders.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef FILEBUILDERSDELEGATE_H\r\n#define FILEBUILDERSDELEGATE_H\r\n\r\n#include <editors/ComponentEditor/common/ExpressionDelegate.h>\r\n\r\n#include <QStyledItemDelegate>\r\n#include <QObject>\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Delegate to provide editors to edit file builders.\r\n//-----------------------------------------------------------------------------\r\nclass FileBuildersDelegate : public ExpressionDelegate\r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\r\n\t/*!\r\n     *  The constructor.\r\n\t *\r\n\t *    @param [in] completionModel     Model containing the completions used in expression editor.\r\n     *    @param [in] parameterFinder     The parameter finder to use for for expression editor.\r\n\t *    @param [in] parent              Pointer to the owner of the delegate.\r\n\t */\r\n    FileBuildersDelegate(QAbstractItemModel* completionModel, QSharedPointer<ParameterFinder> parameterFinder,\r\n        QObject *parent);\r\n\t\r\n\t//! The destructor.\r\n\tvirtual ~FileBuildersDelegate();\r\n\r\n\t/*!\r\n     *  Create a new editor for the given item.\r\n\t *\r\n\t *    @param [in] parent  Owner for the editor.\r\n\t *    @param [in] option  Contains options for the editor.\r\n\t *    @param [in] index   Model index idetifying the item.\r\n\t *\r\n\t *    @return Pointer to the editor to be used to edit the item.\r\n\t */\r\n\tvirtual QWidget* createEditor(QWidget* parent, const QStyleOptionViewItem& option, const QModelIndex& index)\r\n        const;\r\n\r\n\t/*!\r\n     *  Set the data for the editor.\r\n\t *\r\n\t *    @param [in] editor  Pointer to the editor where the data is to be set.\r\n\t *    @param [in] index   Model index identifying the item that's data is to be set.\r\n\t */\r\n\tvirtual void setEditorData(QWidget* editor, const QModelIndex& index) const;\r\n\r\n\t/*!\r\n     *  Save the data from the editor to the model.\r\n\t *\r\n\t *    @param [in] editor  Pointer to the editor that contains the data to store.\r\n\t *    @param [in] model   Model that contains the data structure where data is to be saved to.\r\n\t *    @param [in] index   Model index identifying the item that's data is to be saved.\r\n\t */\r\n\tvirtual void setModelData(QWidget* editor, QAbstractItemModel* model, const QModelIndex& index) const;\r\n\r\n\t/*!\r\n\t *  Paints the delegate.\r\n\t *\r\n\t *    @param [in] painter     The used painter.\r\n\t *    @param [in] option      The style options.\r\n\t *    @param [in] index       Index used for painting.\r\n\t */\r\n\tvirtual void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const;\r\n\r\nprotected:\r\n\r\n\t/*!\r\n\t *  Editor event.\r\n\t *\r\n\t *    @param [in] event   The editor event.\r\n\t *    @param [in] model   The item model.\r\n\t *    @param [in] option  Style option.\r\n\t *    @param [in] index   Model index.\r\n\t */\r\n\tvirtual bool editorEvent(QEvent *event, QAbstractItemModel *model, const QStyleOptionViewItem &option,\r\n        const QModelIndex &index);\r\n\r\n    /*!\r\n     *  Check if a given column accepts expressions.\r\n     *\r\n     *    @param [in] column  The selected column.\r\n     *\r\n     *    @return True, if the column accepts expressions, false otherwise.\r\n     */\r\n    virtual bool columnAcceptsExpression(int column) const;\r\n\r\n    /*!\r\n     *  Gets the column number for the description column.\r\n     *\r\n     *    @return File builders do not have description.\r\n     */\r\n    virtual int descriptionColumn() const;\r\n\r\nprivate slots:\r\n\r\n\t/*!\r\n     *  Commit the data from the sending editor and close the editor.\r\n\t */\r\n\tvoid commitAndCloseEditor();\r\n\r\nprivate:\r\n\t\r\n\t//! No copying. No assignment.\r\n\tFileBuildersDelegate(const FileBuildersDelegate& other);\r\n\tFileBuildersDelegate& operator=(const FileBuildersDelegate& other);\r\n};\r\n\r\n#endif // FILEBUILDERSDELEGATE_H\r\n"
  },
  {
    "path": "editors/ComponentEditor/fileBuilders/filebuilderseditor.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: filebuilderseditor.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 31.05.2012\r\n//\r\n// Description:\r\n// Editor to edit file builders.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"filebuilderseditor.h\"\r\n#include \"filebuildersdelegate.h\"\r\n\r\n#include <KactusAPI/include/IPXactSystemVerilogParser.h>\r\n#include <editors/ComponentEditor/parameters/ComponentParameterModel.h>\r\n#include <KactusAPI/include/FileBuilderInterface.h>\r\n\r\n#include <IPXACTmodels/common/FileBuilder.h>\r\n\r\n#include <QCompleter>\r\n#include <QVBoxLayout>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileBuildersEditor::FileBuildersEditor()\r\n//-----------------------------------------------------------------------------\r\nFileBuildersEditor::FileBuildersEditor(FileBuilderInterface* fileBuilderInterface,\r\n    QSharedPointer<ParameterFinder> parameterFinder, QSharedPointer<ExpressionParser> expressionParser,\r\n    QSharedPointer<ExpressionFormatter> expressionFormatter,\r\n    QSharedPointer<QList<QSharedPointer<FileBuilder>>> availableFileBuilders, QWidget* parent):\r\nQGroupBox(tr(\"Default file build commands\"), parent),\r\nview_(this), \r\nmodel_(0),\r\nproxy_(this),\r\navailableFileBuilders_(availableFileBuilders),\r\nfileBuilderInterface_(fileBuilderInterface)\r\n{\r\n    fileBuilderInterface_->setFileBuilders(availableFileBuilders_);\r\n\r\n    model_ =\r\n        new FileBuildersModel(fileBuilderInterface, parameterFinder, expressionFormatter, expressionParser, this);\r\n\r\n    ComponentParameterModel* componentParametersModel = new ComponentParameterModel(parameterFinder, this);\r\n    componentParametersModel->setExpressionParser(expressionParser);\r\n\r\n\t// set view to be sortable\r\n\tview_.setSortingEnabled(true);\r\n\r\n\t// items can not be dragged\r\n\tview_.setItemsDraggable(false);\r\n\r\n\t// set the delegate to provide editors\r\n    view_.setItemDelegate(new FileBuildersDelegate(componentParametersModel, parameterFinder, this));\r\n\r\n\t// set source model for proxy\r\n    proxy_.setSourceModel(model_);\r\n\t// set proxy to be the source for the view\r\n\tview_.setModel(&proxy_);\r\n\r\n\t// sort the view\r\n\tview_.sortByColumn(0, Qt::AscendingOrder);\r\n\r\n\t// create the layout, add widgets to it\r\n\tQVBoxLayout* layout = new QVBoxLayout(this);\r\n\tlayout->addWidget(&view_);\r\n\r\n    connect(model_, SIGNAL(contentChanged()), this, SIGNAL(contentChanged()), Qt::UniqueConnection);\r\n    connect(model_, SIGNAL(errorMessage(const QString&)),\r\n        this, SIGNAL(errorMessage(const QString&)), Qt::UniqueConnection);\r\n    connect(model_, SIGNAL(noticeMessage(const QString&)),\r\n        this, SIGNAL(noticeMessage(const QString&)), Qt::UniqueConnection);\r\n\r\n    connect(&view_, SIGNAL(addItem(const QModelIndex&)),\r\n        model_, SLOT(onAddItem(const QModelIndex&)), Qt::UniqueConnection);\r\n    connect(&view_, SIGNAL(removeItem(const QModelIndex&)),\r\n        model_, SLOT(onRemoveItem(const QModelIndex&)), Qt::UniqueConnection);\r\n\r\n    connect(view_.itemDelegate(), SIGNAL(increaseReferences(QString)), \r\n        this, SIGNAL(increaseReferences(QString)), Qt::UniqueConnection);\r\n    connect(view_.itemDelegate(), SIGNAL(decreaseReferences(QString)), \r\n        this, SIGNAL(decreaseReferences(QString)), Qt::UniqueConnection);\r\n\r\n    connect(model_, SIGNAL(decreaseReferences(QString)),\r\n        this, SIGNAL(decreaseReferences(QString)), Qt::UniqueConnection);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileBuildersEditor::~FileBuildersEditor()\r\n//-----------------------------------------------------------------------------\r\nFileBuildersEditor::~FileBuildersEditor()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileBuildersEditor::isValid()\r\n//-----------------------------------------------------------------------------\r\nbool FileBuildersEditor::isValid() const\r\n{\r\n    return model_->isValid();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileBuildersEditor::refresh()\r\n//-----------------------------------------------------------------------------\r\nvoid FileBuildersEditor::refresh()\r\n{\r\n    fileBuilderInterface_->setFileBuilders(availableFileBuilders_);\r\n\r\n\tview_.update();\r\n}\r\n"
  },
  {
    "path": "editors/ComponentEditor/fileBuilders/filebuilderseditor.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: filebuilderseditor.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 31.05.2012\r\n//\r\n// Description:\r\n// Editor to edit file builders.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef FILEBUILDERSEDITOR_H\r\n#define FILEBUILDERSEDITOR_H\r\n\r\n#include \"filebuildersmodel.h\"\r\n\r\n#include <common/views/EditableTableView/editabletableview.h>\r\n\r\n#include <QGroupBox>\r\n#include <QSortFilterProxyModel>\r\n#include <QTableView>\r\n#include <QObject>\r\n\r\nclass FileBuilder;\r\nclass ParameterFinder;\r\nclass ExpressionFormatter;\r\nclass ExpressionParser;\r\nclass FileBuilderInterface;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Editor to edit file builders.\r\n//-----------------------------------------------------------------------------\r\nclass FileBuildersEditor : public QGroupBox\r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\r\n\t/*!\r\n     *  The constructor.\r\n\t *\r\n     *    @param [in] fileBuilderInterface    Interface for accessing file builders.\r\n     *    @param [in] parameterFinder         Finder used to identify parameters.\r\n     *    @param [in] expressionParser        Parser used to calculate expressions.\r\n     *    @param [in] expressionFormatter     Formatter used to format expressions.\r\n     *    @param [in] availableFileBuilders   List of editable file builders.\r\n     *    @param [in] parent                  Pointer to the owner of this editor.\r\n\t */\r\n    FileBuildersEditor(FileBuilderInterface* fileBuilderInterface,\r\n        QSharedPointer<ParameterFinder> parameterFinder,\r\n        QSharedPointer<ExpressionParser> expressionParser,\r\n        QSharedPointer<ExpressionFormatter> expressionFormatter,\r\n        QSharedPointer<QList<QSharedPointer<FileBuilder> > > availableFileBuilders,\r\n        QWidget* parent);\r\n\r\n\t/*!\r\n     *  The destructor.\r\n     */\r\n\tvirtual ~FileBuildersEditor();\r\n\r\n\t/*!\r\n     *  Check for the validity of the edited file builders.\r\n\t *\r\n\t *    @return True if all file builders are in valid state.\r\n\t */\r\n\tvirtual bool isValid() const;\r\n\r\npublic slots:\r\n\r\n\t//! Refresh the contents to display.\r\n\tvoid refresh();\r\n\r\nsignals:\r\n\r\n\t//! Emit an error message to user.\r\n\tvoid errorMessage(const QString& msg);\r\n\r\n\t//! Emit a notice to user.\r\n\tvoid noticeMessage(const QString& msg);\r\n\r\n\t//! Inform that contents of this editor have changed.\r\n\tvoid contentChanged();\r\n\r\n    /*!\r\n     *  Increase the number of references in the selected parameter.\r\n     *\r\n     *    @param [in] id  Id of the selected parameter.\r\n     */\r\n    void increaseReferences(QString id) const;\r\n    \r\n    /*!\r\n     *  Decrease the number of references in the selected parameter.\r\n     *\r\n     *    @param [in] id  Id of the selected parameter.\r\n     */\r\n    void decreaseReferences(QString id) const;\r\n\r\nprivate:\r\n\r\n\t//! No copying. No assignment.\r\n\tFileBuildersEditor(const FileBuildersEditor& other);\r\n\tFileBuildersEditor& operator=(const FileBuildersEditor& other);\r\n\r\n\t//! The view that displays the parameters.\r\n\tEditableTableView view_;\r\n\r\n\t//! The model that holds the data to be displayed to the user.\r\n    FileBuildersModel* model_;\r\n\r\n\t//! \\brief Pointer to the proxy that is used to sort the view.\r\n\tQSortFilterProxyModel proxy_;\r\n\r\n    //! List of editable file builders.\r\n    QSharedPointer<QList<QSharedPointer<FileBuilder> > > availableFileBuilders_;\r\n\r\n    //! Interface for accsessing file builders.\r\n    FileBuilderInterface* fileBuilderInterface_;\r\n};\r\n\r\n#endif // FILEBUILDERSEDITOR_H\r\n"
  },
  {
    "path": "editors/ComponentEditor/fileBuilders/filebuildersmodel.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: filebuildersmodel.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 31.05.2012\r\n//\r\n// Description:\r\n// Model that contains the items to edit file builders.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"filebuildersmodel.h\"\r\n#include \"FileBuilderColumns.h\"\r\n\r\n#include <KactusAPI/include/ExpressionFormatter.h>\r\n#include <KactusAPI/include/FileBuilderInterface.h>\r\n#include <editors/ComponentEditor/memoryMaps/memoryMapsExpressionCalculators/ReferenceCalculator.h>\r\n\r\n#include <IPXACTmodels/common/FileBuilder.h>\r\n\r\n#include <common/KactusColors.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: filebuildersmodel::FileBuildersModel()\r\n//-----------------------------------------------------------------------------\r\nFileBuildersModel::FileBuildersModel(FileBuilderInterface* builderInterface,\r\n    QSharedPointer<ParameterFinder> parameterFinder, QSharedPointer<ExpressionFormatter> expressionFormatter,\r\n    QSharedPointer<ExpressionParser> expressionParser, QObject* parent):\r\nReferencingTableModel(parameterFinder, parent),\r\nParameterizableTable(parameterFinder),\r\nfileBuilderInterface_(builderInterface)\r\n{\r\n    setExpressionParser(expressionParser);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: filebuildersmodel::~FileBuildersModel()\r\n//-----------------------------------------------------------------------------\r\nFileBuildersModel::~FileBuildersModel()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: filebuildersmodel::rowCount()\r\n//-----------------------------------------------------------------------------\r\nint FileBuildersModel::rowCount( const QModelIndex& parent /*= QModelIndex() */ ) const\r\n{\r\n\tif (parent.isValid())\r\n    {\r\n\t\treturn 0;\r\n\t}\r\n\r\n    return fileBuilderInterface_->itemCount();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: filebuildersmodel::columnCount()\r\n//-----------------------------------------------------------------------------\r\nint FileBuildersModel::columnCount( const QModelIndex& parent /*= QModelIndex() */ ) const\r\n{\r\n\tif (parent.isValid())\r\n    {\r\n\t\treturn 0;\r\n\t}\r\n\r\n    return FileBuilderColumns::COLUMN_COUNT;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: filebuildersmodel::data()\r\n//-----------------------------------------------------------------------------\r\nQVariant FileBuildersModel::data( const QModelIndex& index, int role /*= Qt::DisplayRole */ ) const\r\n{\r\n\tif (!index.isValid())\r\n    {\r\n\t\treturn QVariant();\r\n\t}\r\n\r\n\t// if row is invalid\r\n    else if (index.row() < 0 || index.row() >= fileBuilderInterface_->itemCount())\r\n    {\r\n\t\treturn QVariant();\r\n\t}\r\n\r\n\tif (Qt::DisplayRole == role)\r\n    {\r\n        if (isValidExpressionColumn(index))\r\n        {\r\n            return formattedExpressionForIndex(index);\r\n        }\r\n        else\r\n        {\r\n            return valueForIndex(index);\r\n        }\r\n\t}\r\n    else if (role == Qt::EditRole)\r\n    {\r\n        return expressionOrValueForIndex(index);\r\n    }\r\n    else if (role == Qt::ToolTipRole)\r\n    {\r\n        return valueForIndex(index);\r\n    }\r\n\telse if (Qt::BackgroundRole == role)\r\n    {\r\n\t\tif (index.column() == 0)\r\n        {\r\n\t\t\treturn KactusColors::MANDATORY_FIELD;\r\n\t\t}\r\n\t\telse\r\n        {\r\n\t\t\treturn KactusColors::REGULAR_FIELD;\r\n\t\t}\r\n\t}\r\n\telse if (Qt::ForegroundRole == role)\r\n    {\r\n// \t\tif (fileBuilders_->at(index.row())->isValid())\r\n//         {\r\n\t\t\treturn KactusColors::REGULAR_TEXT;\r\n// \t\t}\r\n// \t\telse\r\n//         {\r\n// \t\t\treturn KactusColors::ERROR;\r\n// \t\t}\r\n\t}\r\n\r\n    return QVariant();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: filebuildersmodel::headerData()\r\n//-----------------------------------------------------------------------------\r\nQVariant FileBuildersModel::headerData( int section, Qt::Orientation orientation, int role /*= Qt::DisplayRole */ )\r\n    const\r\n{\r\n\tif (orientation != Qt::Horizontal)\r\n    {\r\n\t\treturn QVariant();\r\n\t}\r\n\r\n\tif (Qt::DisplayRole == role)\r\n    {\r\n        if (section == FileBuilderColumns::FILETYPE_COLUMN)\r\n        {\r\n            return tr(\"File type\");\r\n        }\r\n        else if (section == FileBuilderColumns::COMMAND_COLUMN)\r\n        {\r\n            return tr(\"Command\");\r\n        }\r\n        else if (section == FileBuilderColumns::FLAGS_COLUMN)\r\n        {\r\n            return tr(\"Flags\");\r\n        }\r\n        else if (section == FileBuilderColumns::REPLACE_DEFAULT_COLUMN)\r\n        {\r\n            QString replaceFlags = tr(\"Replace default flags\") + getExpressionSymbol();\r\n            return replaceFlags;\r\n        }\r\n\t}\r\n\r\n    return QVariant();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: filebuildersmodel::setData()\r\n//-----------------------------------------------------------------------------\r\nbool FileBuildersModel::setData( const QModelIndex& index, const QVariant& value, int role /*= Qt::EditRole */ )\r\n{\r\n\tif (!index.isValid())\r\n    {\r\n\t\treturn false;\r\n\t}\r\n\r\n\t// if row is invalid\r\n    else if (index.row() < 0 || index.row() >= fileBuilderInterface_->itemCount())\r\n    {\r\n\t\treturn false;\r\n\t}\r\n\r\n\tif (Qt::EditRole == role)\r\n    {\r\n        std::string builderType = fileBuilderInterface_->getIndexedFileType(index.row());\r\n\r\n        if (index.column() == FileBuilderColumns::FILETYPE_COLUMN)\r\n        {\r\n            fileBuilderInterface_->setFileType(builderType, value.toString().toStdString());\r\n        }\r\n        else if (index.column() == FileBuilderColumns::COMMAND_COLUMN)\r\n        {\r\n            fileBuilderInterface_->setCommand(builderType, value.toString().toStdString());\r\n        }\r\n        else if (index.column() == FileBuilderColumns::FLAGS_COLUMN)\r\n        {\r\n            fileBuilderInterface_->setFlags(builderType, value.toString().toStdString());\r\n        }\r\n        else if (index.column() == FileBuilderColumns::REPLACE_DEFAULT_COLUMN)\r\n        {\r\n            if (!value.isValid())\r\n            {\r\n                removeReferencesFromSingleExpression(\r\n                    QString::fromStdString(fileBuilderInterface_->getReplaceDefaultFlagsExpression(builderType)));\r\n            }\r\n            fileBuilderInterface_->setReplaceDefaultFlags(builderType, value.toString().toStdString());\r\n        }\r\n\r\n\t\temit contentChanged();\r\n\t\temit dataChanged(index, index);\r\n\t\treturn true;\r\n\t}\r\n\telse\r\n    {\r\n\t\treturn false;\r\n\t}\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: filebuildersmodel::flags()\r\n//-----------------------------------------------------------------------------\r\nQt::ItemFlags FileBuildersModel::flags( const QModelIndex& index ) const\r\n{\r\n\tif (!index.isValid())\r\n    {\r\n\t\treturn Qt::NoItemFlags;\r\n\t}\r\n\t\r\n\tQt::ItemFlags flags = Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsEditable;\r\n\r\n\treturn flags;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: filebuildersmodel::isValid()\r\n//-----------------------------------------------------------------------------\r\nbool FileBuildersModel::isValid() const\r\n{\r\n\t// check all file builders\r\n/*\r\n\tforeach (QSharedPointer<FileBuilder> fileBuilder, *fileBuilders_)\r\n    {\r\n\t\t// if one is invalid\r\n// \t\tif (!fileBuilder->isValid()) {\r\n// \t\t\treturn false;\r\n// \t\t}\r\n\t}\r\n*/\r\n\r\n\treturn true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: filebuildersmodel::onRemoveItem()\r\n//-----------------------------------------------------------------------------\r\nvoid FileBuildersModel::onRemoveItem( const QModelIndex& index )\r\n{\r\n\t// don't remove anything if index is invalid\r\n\tif (!index.isValid())\r\n    {\r\n\t\treturn;\r\n\t}\r\n\t// make sure the row number if valid\r\n    else if (index.row() < 0 || index.row() >= fileBuilderInterface_->itemCount())\r\n    {\r\n\t\treturn;\r\n\t}\r\n\r\n\t// remove the specified item\r\n\tbeginRemoveRows(QModelIndex(), index.row(), index.row());\r\n\r\n    removeReferencesInItemOnRow(index.row());\r\n    fileBuilderInterface_->removeFileBuilder(fileBuilderInterface_->getIndexedFileType(index.row()));\r\n\r\n\tendRemoveRows();\r\n\r\n\t// tell also parent widget that contents have been changed\r\n\temit contentChanged();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: filebuildersmodel::onAddItem()\r\n//-----------------------------------------------------------------------------\r\nvoid FileBuildersModel::onAddItem( const QModelIndex& index )\r\n{\r\n    int row = fileBuilderInterface_->itemCount();\r\n\r\n\t// if the index is valid then add the item to the correct position\r\n\tif (index.isValid())\r\n    {\r\n\t\trow = index.row();\r\n\t}\r\n\r\n\tbeginInsertRows(QModelIndex(), row, row);\r\n\r\n    fileBuilderInterface_->addFileBuilder(row);\r\n\r\n\tendInsertRows();\r\n\r\n\t// tell also parent widget that contents have been changed\r\n\temit contentChanged();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: filebuildersmodel::isValidExpressionColumn()\r\n//-----------------------------------------------------------------------------\r\nbool FileBuildersModel::isValidExpressionColumn(QModelIndex const& index) const\r\n{\r\n    if (index.column() == FileBuilderColumns::REPLACE_DEFAULT_COLUMN)\r\n    {\r\n        return true;\r\n    }\r\n    else\r\n    {\r\n        return false;\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: filebuildersmodel::expressionOrValueForIndex()\r\n//-----------------------------------------------------------------------------\r\nQVariant FileBuildersModel::expressionOrValueForIndex(QModelIndex const& index) const\r\n{\r\n    if (isValidExpressionColumn(index))\r\n    {\r\n        return expressionForIndex(index);\r\n    }\r\n    else\r\n    {\r\n        return valueForIndex(index);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileBuildersModel::formattedExpressionForIndex()\r\n//-----------------------------------------------------------------------------\r\nQVariant FileBuildersModel::formattedExpressionForIndex(QModelIndex const& index) const\r\n{\r\n    if (index.column() == FileBuilderColumns::REPLACE_DEFAULT_COLUMN)\r\n    {\r\n        std::string fileType = fileBuilderInterface_->getIndexedFileType(index.row());\r\n        return QString::fromStdString(fileBuilderInterface_->getReplaceDefaultFlagsFormattedExpression(fileType));\r\n    }\r\n\r\n    return valueForIndex(index);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileBuildersModel::expressionForIndex()\r\n//-----------------------------------------------------------------------------\r\nQVariant FileBuildersModel::expressionForIndex(QModelIndex const& index) const\r\n{\r\n    if (index.column() == FileBuilderColumns::REPLACE_DEFAULT_COLUMN)\r\n    {\r\n        std::string fileType = fileBuilderInterface_->getIndexedFileType(index.row());\r\n        return QString::fromStdString(fileBuilderInterface_->getReplaceDefaultFlagsExpression(fileType));\r\n    }\r\n\r\n    return valueForIndex(index);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileBuildersModel::valueForIndex()\r\n//-----------------------------------------------------------------------------\r\nQVariant FileBuildersModel::valueForIndex(QModelIndex const& index) const\r\n{\r\n    if (!index.isValid())\r\n    {\r\n        return QVariant();\r\n    }\r\n\r\n    std::string builderType = fileBuilderInterface_->getIndexedFileType(index.row());\r\n\r\n    if (index.column() == FileBuilderColumns::FILETYPE_COLUMN)\r\n    {\r\n        return QString::fromStdString(builderType);\r\n    }\r\n    else if (index.column() == FileBuilderColumns::COMMAND_COLUMN)\r\n    {\r\n        return QString::fromStdString(fileBuilderInterface_->getCommand(builderType));\r\n    }\r\n    else if (index.column() == FileBuilderColumns::FLAGS_COLUMN)\r\n    {\r\n        return QString::fromStdString(fileBuilderInterface_->getFlags(builderType));\r\n    }\r\n    else if (index.column() == FileBuilderColumns::REPLACE_DEFAULT_COLUMN)\r\n    {\r\n        return QString::fromStdString(fileBuilderInterface_->getReplaceDefaultFlagsValue(builderType));\r\n    }\r\n\r\n    return QVariant();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: filebuildersmodel::validateIndex()\r\n//-----------------------------------------------------------------------------\r\nbool FileBuildersModel::validateIndex(QModelIndex const& /*index*/) const\r\n{\r\n    return true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: filebuildersmodel::getAllReferencesToIdInItemOnRow()\r\n//-----------------------------------------------------------------------------\r\nint FileBuildersModel::getAllReferencesToIdInItemOnRow(const int& row, QString const& valueID) const\r\n{\r\n    return fileBuilderInterface_->getAllReferencesToIdInItem(\r\n        fileBuilderInterface_->getIndexedFileType(row), valueID.toStdString());\r\n}\r\n"
  },
  {
    "path": "editors/ComponentEditor/fileBuilders/filebuildersmodel.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: filebuildersmodel.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 31.05.2012\r\n//\r\n// Description:\r\n// Model that contains the items to edit file builders.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef FILEBUILDERSMODEL_H\r\n#define FILEBUILDERSMODEL_H\r\n\r\n#include <editors/ComponentEditor/common/ReferencingTableModel.h>\r\n#include <editors/ComponentEditor/common/ParameterizableTable.h>\r\n\r\n#include <QAbstractTableModel>\r\n#include <QList>\r\n#include <QSharedPointer>\r\n#include <QObject>\r\n\r\nclass FileBuilder;\r\nclass ParameterFinder;\r\nclass ExpressionFormatter;\r\nclass ExpressionParser;\r\nclass FileBuilderInterface;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Model that contains the items to edit file builders.\r\n//-----------------------------------------------------------------------------\r\nclass FileBuildersModel : public ReferencingTableModel, public ParameterizableTable\r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\r\n\t/*!\r\n     *  The constructor.\r\n\t *\r\n\t *    @param [in] builderInterface        Interface for accessing file builders.\r\n     *    @param [in] parameterFinder         Finder used to identify parameters.\r\n     *    @param [in] expressionFormatter     Formatter used to format expressions.\r\n     *    @param [in] expressionParser        Parser used to calculate expressions.\r\n\t *    @param [in] parent                  Pointer to the owner of this model.\r\n\t */\r\n    FileBuildersModel(FileBuilderInterface* builderInterface,\r\n        QSharedPointer<ParameterFinder> parameterFinder,\r\n        QSharedPointer<ExpressionFormatter> expressionFormatter,\r\n        QSharedPointer<ExpressionParser> expressionParser,\r\n        QObject* parent);\r\n\r\n\t/*!\r\n     *  The destructor.\r\n     */\r\n\tvirtual ~FileBuildersModel();\r\n\r\n\t/*!\r\n     *  Get the number of rows in the model.\r\n\t *\r\n\t *    @param [in] parent  Model index of the parent of the item.\r\n     *                          Must be invalid because this is not hierarchical model.\r\n\t *\r\n\t *    @return Number of rows currently in the model.\r\n\t */\r\n\tvirtual int rowCount(const QModelIndex& parent = QModelIndex() ) const;\r\n\r\n\t/*!\r\n     *  Get the number of columns in the model.\r\n\t *\r\n\t *    @param [in] parent  Model index of the parent of the item.\r\n     *                          Must be invalid because this is not hierarchical model.\r\n\t *\r\n\t *    @return Always returns 4\r\n\t */\r\n\tvirtual int columnCount(const QModelIndex& parent = QModelIndex() ) const;\r\n\r\n\t/*!\r\n     *  Get the data for the specified item for specified role.\r\n\t *\r\n\t *    @param [in] index   Identifies the item that's data is wanted.\r\n\t *    @param [in] role    Specifies what kind of data is wanted.\r\n\t *\r\n\t *    @return QVariant containing the data\r\n\t */\r\n\tvirtual QVariant data(const QModelIndex& index, int role = Qt::DisplayRole ) const;\r\n\r\n\t/*!\r\n     *  Get the data for the headers.\r\n\t *\r\n\t *    @param [in] section         The column that's header is wanted.\r\n\t *    @param [in] orientation     Only Qt::Horizontal is supported.\r\n\t *    @param [in] role            Specified the type of data that is wanted.\r\n\t *\r\n\t *    @return QVariant containing the data to be displayed\r\n\t */\r\n\tvirtual QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole ) const;\r\n\r\n\t/*!\r\n     *  Set the data for specified item.\r\n\t *\r\n\t *    @param [in] index   Specifies the item that's data is modified\r\n\t *    @param [in] value   The value to be set.\r\n\t *    @param [in] role    The role that is trying to modify the data. Only Qt::EditRole is supported.\r\n\t *\r\n\t *    @return True if data was successfully set.\r\n\t */\r\n\tvirtual bool setData(const QModelIndex& index, const QVariant& value, int role = Qt::EditRole );\r\n\r\n\t/*!\r\n     *  Get information on how specified item can be handled.\r\n\t *\r\n\t *    @param [in] index   Specifies the item that's flags are wanted.\r\n\t *\r\n\t *    @return Qt::ItemFlags that define how object can be handled.\r\n\t */\r\n\tvirtual Qt::ItemFlags flags(const QModelIndex& index) const;\r\n\r\n\t/*!\r\n     *  Check if the model is in valid state or not.\r\n\t *\r\n\t *    @return True if all items in model are valid.\r\n\t */\r\n\tbool isValid() const;\r\n\r\npublic slots:\r\n\r\n\t/*!\r\n     *  A new item should be added to given index.\r\n\t *\r\n\t *    @param [in] index   The position where new item should be added at.\r\n\t */\r\n\tvoid onAddItem(const QModelIndex& index);\r\n\r\n\t/*!\r\n     *  An item should be removed from the model.\r\n\t * \r\n\t *    @param [in] index   Identifies the item that should be removed.\r\n\t */\r\n\tvoid onRemoveItem(const QModelIndex& index);\r\n\r\nsignals:\r\n\r\n\t//! Emitted when contents of the model change.\r\n\tvoid contentChanged();\r\n\r\n\t//! Prints an error message to the user.\r\n\tvoid errorMessage(const QString& msg) const;\r\n\t\r\n\t//! Prints a notification to user.\r\n\tvoid noticeMessage(const QString& msg) const;\r\n\r\nprotected:\r\n\r\n    /*!\r\n     *  Check if the given column can contain expressions.\r\n     *\r\n     *    @param [in] index   The index of the selected column.\r\n     *\r\n     *    @return True, if the column can contain expressions, false otherwise.\r\n     */\r\n    virtual bool isValidExpressionColumn(QModelIndex const& index) const;\r\n\r\n    /*!\r\n     *  Get the value of the item in the given index.\r\n     *\r\n     *    @param [in] index   The selected index.\r\n     *\r\n     *    @return The value matching the index.\r\n     */\r\n    virtual QVariant expressionOrValueForIndex(QModelIndex const& index) const;\r\n\r\n    /*!\r\n     *  Validate the selected index.\r\n     *\r\n     *    @param [in] index   The selected index.\r\n     *\r\n     *    @return True, if the index is valid, otherwise false.\r\n     */\r\n    virtual bool validateIndex(QModelIndex const& index) const;\r\n\r\n    /*!\r\n     *  Get all the references to a selected parameter in the selected row.\r\n     *\r\n     *    @param [in] row         The selected row.\r\n     *    @param [in] valueID     The Id of the selected parameter.\r\n     *\r\n     *    @return The number of references made to teh selected Id.\r\n     */\r\n    virtual int getAllReferencesToIdInItemOnRow(const int& row, QString const& valueID) const;\r\n\r\nprivate:\r\n\r\n\t//! No copying. No assignment.\r\n\tFileBuildersModel(const FileBuildersModel& other);\r\n\tFileBuildersModel& operator=(const FileBuildersModel& other);\r\n\t\r\n    /*!\r\n     *  Get the formatted value of an expression in the selected index.\r\n     *\r\n     *    @param [in] index   The selected index.\r\n     *\r\n     *    @return The formatted value of an expression in the selected index.\r\n     */\r\n    virtual QVariant formattedExpressionForIndex(QModelIndex const& index) const;\r\n\r\n    /*!\r\n     *  Get the expression of the selected index.\r\n     *\r\n     *    @param [in] index   The selected index.\r\n     *\r\n     *    @return The expression of the selected index.\r\n     */\r\n    virtual QVariant expressionForIndex(QModelIndex const& index) const;\r\n\r\n    /*!\r\n     *  Gets the value for the given index.\r\n     *\r\n     *    @param [in] index   The index of target data.\r\n     *\r\n     *    @return     The data in the given index.\r\n     */\r\n    QVariant valueForIndex(QModelIndex const& index) const;\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! Interface for accessing file builders.\r\n    FileBuilderInterface* fileBuilderInterface_;\r\n};\r\n\r\n#endif // FILEBUILDERSMODEL_H\r\n"
  },
  {
    "path": "editors/ComponentEditor/fileSet/FileSetColumns.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: FileSetColumns.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Mikko Teuho\r\n// Date: 19.10.2015\r\n//\r\n// Description:\r\n// Common declarations for editing file sets.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef FILESETCOLUMNS_H\r\n#define FILESETCOLUMNS_H\r\n\r\nnamespace FileSetColumns\r\n{\r\n    //! The editable columns in the file sets editor.\r\n    enum columns\r\n    {\r\n        NAME_COLUMN = 0,\r\n        GROUP_COLUMN,\r\n        DESCRIPTION,\r\n        COLUMN_COUNT\r\n    };\r\n}\r\n\r\n#endif // FILESETCOLUMNS_H"
  },
  {
    "path": "editors/ComponentEditor/fileSet/dependencyAnalysis/FileDependencyColumns.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: FileDependencyColumns.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Mikko Teuho\r\n// Date: 19.10.2015\r\n//\r\n// Description:\r\n// Common declarations for editing file dependencies.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef FILE_DEPENDENCY_COLUMNS_H\r\n#define FILE_DEPENDENCY_COLUMNS_H\r\n\r\nnamespace FileDependencyColumns\r\n{\r\n    //! The editable columns in the file dependency editor.\r\n    enum columns\r\n    {\r\n        TREE_EXPAND = 0,\r\n        STATUS,\r\n        PATH,\r\n        FILESETS,\r\n        CREATE_DEPENDENCY,\r\n        DEPENDENCIES,\r\n        COLUMN_COUNT\r\n    };\r\n}\r\n\r\n#endif // FILE_DEPENDENCY_COLUMNS_H"
  },
  {
    "path": "editors/ComponentEditor/fileSet/dependencyAnalysis/FileDependencyDelegate.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: FileDependencyDelegate.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Joni-Matti Maatta\r\n// Date: 15.02.2013\r\n//\r\n// Description:\r\n// Delegate used in visualizing the file dependency model.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"FileDependencyDelegate.h\"\r\n\r\n#include \"FileDependencyModel.h\"\r\n#include \"FileDependencyItem.h\"\r\n#include \"FileDependencyColumns.h\"\r\n\r\n#include <common/widgets/EnumCollectionEditor/EnumCollectionEditor.h>\r\n\r\n#include <IPXACTmodels/Component/Component.h>\r\n#include <IPXACTmodels/Component/FileSet.h>\r\n\r\n#include <QPainter>\r\n#include <QApplication>\r\n#include <QComboBox>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileDependencyDelegate::FileDependencyDelegate()\r\n//-----------------------------------------------------------------------------\r\nFileDependencyDelegate::FileDependencyDelegate(QSharedPointer<Component> component, QObject* parent):\r\nEnumerationEditorConstructorDelegate(parent),\r\ncomponent_(component)\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileDependencyDelegate::~FileDependencyDelegate()\r\n//-----------------------------------------------------------------------------\r\nFileDependencyDelegate::~FileDependencyDelegate()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileDependencyDelegate::sizeHint()\r\n//-----------------------------------------------------------------------------\r\nQSize FileDependencyDelegate::sizeHint(QStyleOptionViewItem const& option, QModelIndex const& index) const\r\n{\r\n    return QStyledItemDelegate::sizeHint(option, index) + QSize(0, 4);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileDependencyDelegate::isEnumerationEditorColumn()\r\n//-----------------------------------------------------------------------------\r\nbool FileDependencyDelegate::isEnumerationEditorColumn(QModelIndex const& index) const\r\n{\r\n    return index.column() == FileDependencyColumns::FILESETS;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileDependencyDelegate::getCurrentSelection()\r\n//-----------------------------------------------------------------------------\r\nQStringList FileDependencyDelegate::getCurrentSelection(QModelIndex const& index) const\r\n{\r\n    return index.data(Qt::UserRole).toStringList();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileDependencyDelegate::getAvailableItems()\r\n//-----------------------------------------------------------------------------\r\nQStringList FileDependencyDelegate::getAvailableItems() const\r\n{\r\n    QStringList fileSetNames;\r\n    for (auto fileSet : *component_->getFileSets())\r\n    {\r\n        fileSetNames.append(fileSet->name());\r\n    }\r\n\r\n    return fileSetNames;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileDependencyDelegate::setEnumerationDataToModel()\r\n//-----------------------------------------------------------------------------\r\nvoid FileDependencyDelegate::setEnumerationDataToModel(QModelIndex const& index, QAbstractItemModel* model, QStringList const& selectedItems) const\r\n{\r\n    model->setData(index, selectedItems, Qt::EditRole);\r\n}\r\n"
  },
  {
    "path": "editors/ComponentEditor/fileSet/dependencyAnalysis/FileDependencyDelegate.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: FileDependencyDelegate.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Joni-Matti Maatta\r\n// Date: 15.02.2013\r\n//\r\n// Description:\r\n// Delegate used in visualizing the file dependency model.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef FILEDEPENDENCYDELEGATE_H\r\n#define FILEDEPENDENCYDELEGATE_H\r\n\r\n#include <editors/ComponentEditor/common/EnumerationEditorConstructorDelegate.h>\r\n\r\n#include <QItemDelegate>\r\n\r\nclass Component;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Delegate used in visualizing the file dependency model.\r\n//-----------------------------------------------------------------------------\r\nclass FileDependencyDelegate : public EnumerationEditorConstructorDelegate\r\n{\r\n    Q_OBJECT\r\n\r\npublic:\r\n    /*!\r\n     *  Constructor.\r\n     */\r\n    FileDependencyDelegate(QSharedPointer<Component> component, QObject* parent = 0);\r\n\r\n    /*!\r\n     *  Destructor.\r\n     */\r\n    ~FileDependencyDelegate();\r\n\r\n    /*!\r\n     *  Returns the size hint for the given model index.\r\n     */\r\n    virtual QSize sizeHint(QStyleOptionViewItem const& option, QModelIndex const& index) const;\r\n\r\nprivate:\r\n    // Disable copying.\r\n    FileDependencyDelegate(FileDependencyDelegate const& rhs);\r\n    FileDependencyDelegate& operator=(FileDependencyDelegate const& rhs);\r\n    \r\n    /*!\r\n     *  Check if the column is used for enumerations.\r\n     *\r\n     *    @param [in] index   The selected index.\r\n     *\r\n     *    @return True, if the column is used for editing enumerations, false otherwise.\r\n     */\r\n    virtual bool isEnumerationEditorColumn(QModelIndex const& index) const override final;\r\n\r\n    /*!\r\n     *  The list of currently selected enumerations in the selected item.\r\n     *\r\n     *    @param [in] index   Index of the selected item.\r\n     *\r\n     *    @return List of currently selected enumerations.\r\n     */\r\n    virtual QStringList getCurrentSelection(QModelIndex const& index) const override final;\r\n\r\n    /*!\r\n     *  Get the list of the available enumerations.\r\n     *\r\n     *    @return List of the available enumerations.\r\n     */\r\n    virtual QStringList getAvailableItems() const override final;\r\n\r\n    /*!\r\n     *  Set the selected enumerations to the selected item.\r\n     *\r\n     *    @param [in] index           Model index identifying the item that's data is to be saved.\r\n     *    @param [in] model           Model that contains the data structure where data is to be saved to.\r\n     *    @param [in] selectedItems   List of the selected enumerations.\r\n     */\r\n    virtual void setEnumerationDataToModel(QModelIndex const& index, QAbstractItemModel* model, QStringList const& selectedItems) const override final;\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! The component being edited.\r\n    QSharedPointer<Component> component_;\r\n};\r\n\r\n#endif // FILEDEPENDENCYDELEGATE_H\r\n"
  },
  {
    "path": "editors/ComponentEditor/fileSet/dependencyAnalysis/FileDependencyEditor.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: FileDependencyEditor.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Joni-Matti Maatta\r\n// Date: 22.01.2013\r\n//\r\n// Description:\r\n// File dependency editor which encapsulates the whole dependency UI.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"FileDependencyEditor.h\"\r\n\r\n#include \"FileDependencyColumns.h\"\r\n#include \"FileDependencyItem.h\"\r\n#include \"FileDependencyDelegate.h\"\r\n\r\n#include <KactusAPI/include/FileHandler.h>\r\n\r\n#include <IPXACTmodels/Component/Component.h>\r\n#include <IPXACTmodels/Component/FileSet.h>\r\n#include <IPXACTmodels/Component/File.h>\r\n\r\n#include <IPXACTmodels/common/VLNV.h>\r\n\r\n#include <KactusAPI/include/PluginManager.h>\r\n#include <KactusAPI/include/ISourceAnalyzerPlugin.h>\r\n\r\n#include <QApplication>\r\n#include <QVBoxLayout>\r\n#include <QIcon>\r\n#include <QFileInfoList>\r\n#include <QSettings>\r\n#include <QHeaderView>\r\n#include <QAction>\r\n#include <QVariant>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileDependencyEditor::FileDependencyEditor()\r\n//-----------------------------------------------------------------------------\r\nFileDependencyEditor::FileDependencyEditor(QSharedPointer<Component> component,\r\n    QString const& basePath, QWidget* parent):\r\nQWidget(parent),\r\n    toolbar_(this),\r\n    progressBar_(this),\r\n    graphWidget_(this),\r\n    infoWidget_(this),\r\n    directoryEditor_(basePath, component->getSourceDirectories(), this),\r\n    component_(component),\r\n    fileTypeLookup_(),\r\n    ignoreExtList_(),\r\n    model_(component, basePath + \"/\"),\r\n    basePath_(basePath),\r\n    scanning_(false),\r\n    filterActions_(this),\r\n    runAnalysisAction_(0),\r\n    timer_(0)\r\n{\r\n    // Initialize the widgets.\r\n    progressBar_.setStyleSheet(\"QProgressBar:horizontal { margin: 0px; border: none; background: #cccccc; } \"\r\n                               \"QProgressBar::chunk:horizontal { background: #009eff;}\");\r\n    progressBar_.setFixedHeight(2);\r\n    progressBar_.setTextVisible(false);\r\n    progressBar_.setContentsMargins(0, 0, 0, 0);\r\n    progressBar_.setValue(0);\r\n\r\n    graphWidget_.setContentsMargins(0, 0, 0, 0);\r\n    graphWidget_.getView()->setModel(&model_);\r\n    graphWidget_.getView()->setItemDelegate(new FileDependencyDelegate(component, this));\r\n\r\n    graphWidget_.getView()->resizeColumnToContents(FileDependencyColumns::TREE_EXPAND);\r\n    graphWidget_.getView()->resizeColumnToContents(FileDependencyColumns::STATUS);\r\n    graphWidget_.getView()->resizeColumnToContents(FileDependencyColumns::CREATE_DEPENDENCY);\r\n    graphWidget_.getView()->setColumnWidth(FileDependencyColumns::PATH, 250);\r\n    graphWidget_.getView()->header()->setSectionResizeMode(FileDependencyColumns::TREE_EXPAND, QHeaderView::Fixed);\r\n    graphWidget_.getView()->header()->setSectionResizeMode(FileDependencyColumns::STATUS, QHeaderView::Fixed);\r\n    graphWidget_.getView()->header()->setSectionResizeMode(FileDependencyColumns::CREATE_DEPENDENCY, QHeaderView::Fixed);\r\n\r\n    setupToolbar();\r\n\r\n    setupLayout();\r\n\r\n    connect(&model_, SIGNAL(contentChanged()), this, SIGNAL(contentChanged()), Qt::UniqueConnection);\r\n    connect(&model_, SIGNAL(dependencyChanged(FileDependency*)), this, SIGNAL(dependenciesChanged()), Qt::UniqueConnection);\r\n    connect(graphWidget_.getView(), SIGNAL(dependencyChanged(FileDependency*)), this, SIGNAL(dependenciesChanged()), Qt::UniqueConnection);\r\n    connect(&model_, SIGNAL(analysisProgressChanged(int)),\r\n            this, SLOT(updateProgressBar(int)), Qt::UniqueConnection);\r\n    connect(graphWidget_.getView(), SIGNAL(selectionChanged(FileDependency*)),\r\n            &infoWidget_, SLOT(setEditedDependency(FileDependency*)), Qt::UniqueConnection);\r\n\r\n    connect(&infoWidget_, SIGNAL(dependencyChanged(FileDependency*)),\r\n            &model_, SIGNAL(dependencyChanged(FileDependency*)), Qt::UniqueConnection);\r\n\r\n    connect(&directoryEditor_, SIGNAL(contentChanged()),\r\n        this, SLOT(onSourceDirectoriesChanged()), Qt::UniqueConnection);\r\n    connect(&directoryEditor_, SIGNAL(contentChanged()), this, SIGNAL(contentChanged()), Qt::UniqueConnection);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileDependencyEditor::~FileDependencyEditor()\r\n//-----------------------------------------------------------------------------\r\nFileDependencyEditor::~FileDependencyEditor()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileDependencyEditor::setCompact()\r\n//-----------------------------------------------------------------------------\r\nvoid FileDependencyEditor::setCompact(bool compact)\r\n{\r\n    toolbar_.setVisible(!compact);\r\n    infoWidget_.setVisible(!compact);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileDependencyEditor::setDependenciesEditable()\r\n//-----------------------------------------------------------------------------\r\nvoid FileDependencyEditor::setDependenciesEditable(bool editable)\r\n{\r\n    graphWidget_.getView()->setDependenciesEditable(editable);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileDependencyEditor::isScanning()\r\n//-----------------------------------------------------------------------------\r\nbool FileDependencyEditor::isScanning() const\r\n{\r\n    return scanning_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileDependencyEditor::refresh()\r\n//-----------------------------------------------------------------------------\r\nvoid FileDependencyEditor::refresh()\r\n{\r\n    model_.refresh();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileDependencyEditor::scan()\r\n//-----------------------------------------------------------------------------\r\nvoid FileDependencyEditor::scan()\r\n{\r\n    if (isScanning())\r\n    {\r\n        model_.stopAnalysis();\r\n        return;\r\n    }\r\n\r\n    emit scanStarted();\r\n\r\n    QApplication::setOverrideCursor(Qt::WaitCursor);\r\n\r\n    runAnalysisAction_->setIcon(QIcon(\":/icons/common/graphics/control-stop.png\"));\r\n    scanning_ = true;\r\n\r\n    // Preparations. Resolve file types for each extension.\r\n    resolveExtensionFileTypes();\r\n\r\n    timer_ = new QTimer(this);\r\n    connect(timer_, SIGNAL(timeout()), this, SLOT(scanDirectories()));\r\n    timer_->start();\r\n\r\n    // Phase 2. Run the dependency analysis.\r\n    if (isEnabled())\r\n    {\r\n        progressBar_.setMaximum(model_.getTotalStepCount());\r\n        model_.startAnalysis();\r\n    }\r\n    else\r\n    {\r\n        finishScan();\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileDependencyEditor::scanDirectories()\r\n//-----------------------------------------------------------------------------\r\nvoid FileDependencyEditor::scanDirectories()\r\n{\r\n    model_.beginReset();\r\n\r\n    // First scan the source directories.\r\n    if (isEnabled())\r\n    {\r\n        for (QString const& sourcePath: component_->getSourceDirectories())\r\n        {\r\n            scanFiles(sourcePath);\r\n        }\r\n    }\r\n\r\n    // Then add files that are part of the file sets but were not added in the file scan.\r\n    for (QSharedPointer<FileSet> fileSet : *component_->getFileSets())\r\n    {\r\n        for (QSharedPointer<File> file : *fileSet->getFiles())\r\n        {\r\n            // For non-url files, check if the model does not contain a corresponding file item.\r\n            if (FileHandler::isURI(FileHandler::resolveURI(file->name())) == false && \r\n                model_.findFileItem(file->name()) == nullptr)\r\n            {\r\n                QFileInfo info(FileHandler::resolvePath(file->name()));\r\n                QString folderPath = info.path();\r\n\r\n                // Create a folder item for the file if not already created.\r\n                FileDependencyItem* folderItem = model_.findFolderItem(folderPath);\r\n                if (folderItem == nullptr)\r\n                {\r\n                    folderItem = model_.addFolder(folderPath);\r\n                }\r\n\r\n                // Create a file item.\r\n                QList<QSharedPointer<File> > fileRefs;\r\n                for (QSharedPointer<FileSet> fileSet : *component_->getFileSets())\r\n                {\r\n                    for (QSharedPointer<File> filesetFile : *fileSet->getFiles())\r\n                    {\r\n                        if (filesetFile->name() == file->name())\r\n                        {\r\n                            fileRefs.append(filesetFile);\r\n                        }\r\n                    }\r\n                }\r\n\r\n                folderItem->addFile(component_, file->name(), fileRefs);\r\n            }\r\n        }\r\n    }\r\n\r\n    model_.endReset();\r\n\r\n    timer_->stop();\r\n    delete timer_;\r\n    timer_ = nullptr;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileDependencyEditor::updateProgressBar()\r\n//-----------------------------------------------------------------------------\r\nvoid FileDependencyEditor::updateProgressBar(int value)\r\n{\r\n    progressBar_.setValue(value);\r\n\r\n    if (value == 0)\r\n    {\r\n        finishScan();\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileDependencyEditor::filterToggle()\r\n//-----------------------------------------------------------------------------\r\nvoid FileDependencyEditor::filterToggle(QAction* action)\r\n{\r\n    // Get current filters from the graph.\r\n    FileDependencyGraphView::DependencyFilters filters = graphWidget_.getView()->getFilters();\r\n\r\n    // Toggle the appropriate filter based on the button that was clicked.\r\n    filters ^= action->data().toUInt();\r\n\r\n    // Apply the new filter setup to the view.\r\n    graphWidget_.getView()->setFilters(filters);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileDependencyEditor::onSourceDirectoriesChanged()\r\n//-----------------------------------------------------------------------------\r\nvoid FileDependencyEditor::onSourceDirectoriesChanged()\r\n{\r\n    component_->setSourceDirectories(directoryEditor_.getSourceDirectories());\r\n    scan();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileDependencyEditor::resolveExtensionFileSets()\r\n//-----------------------------------------------------------------------------\r\nvoid FileDependencyEditor::resolveExtensionFileTypes()\r\n{\r\n    fileTypeLookup_.clear();\r\n    \r\n    // Retrieve the file types information from the settings.\r\n    QSettings settings;\r\n    ignoreExtList_ = settings.value(\"FileTypes/IgnoredExtensions\").toString().split(';');\r\n\r\n    fileTypeLookup_ = FileHandler::constructFileSuffixTable();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileDependencyEditor::finishScan()\r\n//-----------------------------------------------------------------------------\r\nvoid FileDependencyEditor::finishScan()\r\n{\r\n    scanning_ = false;\r\n    runAnalysisAction_->setIcon(QIcon(\":/icons/common/graphics/control-play.png\"));\r\n\r\n    QApplication::restoreOverrideCursor();\r\n\r\n    emit filesUpdated();\r\n    emit scanCompleted();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileDependencyEditor::scanFiles()\r\n//-----------------------------------------------------------------------------\r\nvoid FileDependencyEditor::scanFiles(QString const& path)\r\n{\r\n    FileDependencyItem* folderItem = model_.addFolder(path);\r\n\r\n    QFileInfoList list = QDir(General::getAbsolutePath(basePath_ + \"/\", path)).entryInfoList(\r\n        QDir::Files | QDir::Dirs | QDir::NoDotAndDotDot);\r\n\r\n    for (QFileInfo const& info : list)\r\n    {\r\n        // Check if the entry is a directory.\r\n        if (info.isDir())\r\n        {\r\n            scanFiles(General::getRelativePath(basePath_, info.absoluteFilePath()));\r\n        }\r\n        // Otherwise add the file if it does not belong to ignored extensions or is not an IP-XACT file.\r\n        else if (!ignoreExtList_.contains(info.completeSuffix()) && !isFileIPXact(info.absoluteFilePath()))\r\n        {\r\n            QString fileType = fileTypeLookup_.value(info.completeSuffix(), \"unknown\");\r\n\r\n            // Check if the file is already packaged into the metadata.\r\n            QString relativePath = General::getRelativePath(basePath_, info.absoluteFilePath());\r\n\r\n            QList<QSharedPointer<File> > fileRefs;\r\n            for (QSharedPointer<FileSet> fileSet : *component_->getFileSets())\r\n            {\r\n                for (QSharedPointer<File> file : *fileSet->getFiles())\r\n                {\r\n                    if (FileHandler::resolvePath(file->name()) == relativePath)\r\n                    {\r\n                        fileRefs.append(file);\r\n                    }\r\n                }\r\n            }\r\n\r\n            // Add the file to the component file sets if not already found and is not yet ignored.\r\n            if (fileRefs.empty())\r\n            {\r\n                QSharedPointer<FileSet> fileSet;\r\n\r\n                QString fileSetName = QString(path).replace(QRegularExpression(\"^(./)?../.*/\"), \"external_\");\r\n                if (fileSetName == \".\")\r\n                {\r\n                    fileSetName = tr(\"base\");\r\n                }\r\n\r\n                // Check if the file set does not exist in the component.\r\n                if (component_->hasFileSet(fileSetName))\r\n                {\r\n                    fileSet = component_->getFileSet(fileSetName);\r\n                }\r\n                else\r\n                {\r\n                    fileSet.reset(new FileSet(fileSetName, \"\"));\r\n                    component_->getFileSets()->append(fileSet);\r\n                    emit fileSetAdded(fileSet.data());\r\n                }\r\n\r\n                QSharedPointer<File> file(new File(relativePath));\r\n                file->addFileType(fileType);\r\n                fileSet->addFile(file);\r\n                emit fileAdded(file.data());\r\n\r\n                fileRefs.append(file);\r\n            }\r\n\r\n            folderItem->addFile(component_, relativePath, fileRefs);\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileDependencyEditor::isFileIPXact()\r\n//-----------------------------------------------------------------------------\r\nbool FileDependencyEditor::isFileIPXact(QString const& filename) const\r\n{\r\n    // Try to open the file for reading.\r\n    QFile file(filename);\r\n    if (!file.open(QFile::ReadOnly))\r\n    {\r\n        return false;\r\n    }\r\n\r\n    QXmlStreamReader reader(&file);\r\n\r\n    if (!reader.readNextStartElement())\r\n    {\r\n        return false;\r\n    }\r\n\r\n    if (reader.hasError())\r\n    {\r\n        return false;\r\n    }\r\n\r\n    QString type = reader.qualifiedName().toString();\r\n    file.close();\r\n\r\n    // Check if the type is a valid IP-XACT/Kactus2 object type.\r\n    return (VLNV::string2Type(type) != VLNV::INVALID);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileDependencyEditor::setupToolbar()\r\n//-----------------------------------------------------------------------------\r\nvoid FileDependencyEditor::setupToolbar()\r\n{\r\n    filterActions_.setExclusive(false);\r\n\r\n    // Set up the toolbar\r\n    toolbar_.setFloatable(false);\r\n    toolbar_.setMovable(false);\r\n    toolbar_.setStyleSheet(QString(\"QToolBar { border: none; }\"));\r\n\r\n    // Create the filter buttons in the toolbar.\r\n    addFilterButton(QIcon(\":/icons/common/graphics/dependency_twoway.png\"),\r\n        tr(\"Show Bidirectional Dependencies\"),\r\n        FileDependencyGraphView::FILTER_TWO_WAY);\r\n    addFilterButton(QIcon(\":/icons/common/graphics/dependency_oneway.png\"), \r\n        tr(\"Show Unidirectional Dependencies\"),\r\n        FileDependencyGraphView::FILTER_ONE_WAY);\r\n    addFilterButton(QIcon(\":/icons/common/graphics/dependency_manual.png\"), \r\n        tr(\"Show Manual Dependencies\"),\r\n        FileDependencyGraphView::FILTER_MANUAL);\r\n    addFilterButton(QIcon(\":/icons/common/graphics/dependency_auto.png\"), \r\n        tr(\"Show Analyzed Dependencies\"),\r\n        FileDependencyGraphView::FILTER_AUTOMATIC);\r\n    addFilterButton(QIcon(\":/icons/common/graphics/external.png\"), tr(\"Show External\"),\r\n        FileDependencyGraphView::FILTER_EXTERNAL);\r\n    addFilterButton(QIcon(\":/icons/common/graphics/diff.png\"), tr(\"Show Differences\"),\r\n        FileDependencyGraphView::FILTER_DIFFERENCE);\r\n\r\n    connect(&filterActions_, SIGNAL(triggered(QAction*)), this, SLOT(filterToggle(QAction*)));\r\n\r\n    toolbar_.addSeparator();\r\n\r\n    runAnalysisAction_ = toolbar_.addAction(QIcon(\":/icons/common/graphics/control-play.png\"), tr(\"Rescan\"),\r\n        this, SLOT(scan()));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileDependencyEditor::addFilterButton()\r\n//-----------------------------------------------------------------------------\r\nvoid FileDependencyEditor::addFilterButton(QIcon const& icon, QString const& iconText,\r\n    FileDependencyGraphView::DependencyFilter filter)\r\n{\r\n    FileDependencyGraphView::DependencyFilters filters = graphWidget_.getView()->getFilters();\r\n\r\n    QAction* tmp = toolbar_.addAction(icon, iconText);\r\n    tmp->setData(filter);\r\n    tmp->setCheckable(true);\r\n    tmp->setChecked(filters & filter);\r\n\r\n    filterActions_.addAction(tmp);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileDependencyEditor::setupLayout()\r\n//-----------------------------------------------------------------------------\r\nvoid FileDependencyEditor::setupLayout()\r\n{\r\n    // Create the layout.\r\n    QGridLayout* layout = new QGridLayout(this);\r\n    layout->addWidget(&toolbar_, 0, 0, 1, 2);\r\n    layout->addWidget(&progressBar_, 1, 0, 1, 2);\r\n    layout->addWidget(&graphWidget_, 2, 0, 1, 2);    \r\n    layout->addWidget(&directoryEditor_, 3, 0, 1, 1);\r\n    layout->addWidget(&infoWidget_, 3, 1, 1, 1);\r\n    layout->setContentsMargins(0, 0, 0, 0);\r\n\r\n    layout->setRowStretch(2, 4);\r\n    layout->setRowStretch(3, 1);\r\n}\r\n"
  },
  {
    "path": "editors/ComponentEditor/fileSet/dependencyAnalysis/FileDependencyEditor.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: FileDependencyEditor.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Joni-Matti Maatta\r\n// Date: 19.01.2013\r\n//\r\n// Description:\r\n// File dependency editor which encapsulates the whole dependency UI.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef FILEDEPENDENCYEDITOR_H\r\n#define FILEDEPENDENCYEDITOR_H\r\n\r\n#include \"FileDependencyGraphWidget.h\"\r\n#include \"FileDependencyInfoWidget.h\"\r\n#include \"FileDependencySourceEditor.h\"\r\n#include \"FileDependencyModel.h\"\r\n\r\n#include <QGroupBox>\r\n#include <QToolBar>\r\n#include <QTableWidget>\r\n#include <QProgressBar>\r\n#include <QStringList>\r\n#include <QActionGroup>\r\n#include <QTimer>\r\n\r\nclass Component;\r\nclass ISourceAnalyzerPlugin;\r\nclass FileSet;\r\nclass File;\r\nclass ScanProgressWidget;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! File dependency editor which encapsulates the whole dependency UI.\r\n//-----------------------------------------------------------------------------\r\nclass FileDependencyEditor : public QWidget\r\n{\r\n    Q_OBJECT\r\n\r\npublic:\r\n    /*!\r\n     *  Constructor.\r\n     *\r\n     *    @param [in] component     The component being edited.\r\n     *    @param [in] basePath      The component's base path.\r\n     *    @param [in] parent        The parent widget.\r\n     */\r\n    FileDependencyEditor(QSharedPointer<Component> component, QString const& basePath,\r\n         QWidget* parent);\r\n\r\n    /*!\r\n     *  Destructor.\r\n     */\r\n    ~FileDependencyEditor();\r\n\r\n    /*!\r\n     *  Sets the editor in compact mode.\r\n     *\r\n     *    @param [in] compact If true, the editor is set compact with only the table-graph in view.\r\n     *                          If false, the full editor is shown.\r\n     */\r\n    void setCompact(bool compact);\r\n\r\n    /*!\r\n     *  Sets the dependencies editable/read-only.\r\n     */\r\n    void setDependenciesEditable(bool editable);\r\n\r\n    /*!\r\n     *  Returns true if the editor is scanning.\r\n     */\r\n    bool isScanning() const;\r\n\r\npublic slots:\r\n    /*!\r\n     *  Refreshes the view.\r\n     */\r\n    void refresh();\r\n\r\n    /*!\r\n     *  Scans the source directories for new files, adds them to the component\r\n     *  file sets and runs the dependency analysis.\r\n     */\r\n    void scan();\r\n\r\nsignals:\r\n    //! Emitted when a file set has been added.\r\n    void fileSetAdded(FileSet* fileSet);\r\n\r\n    //! Emitted when a file has been added.\r\n    void fileAdded(File* file);\r\n\r\n    //! Emitted when the files have been updated.\r\n    void filesUpdated();\r\n\r\n    //! Emitted when the dependencies have changed.\r\n    void dependenciesChanged();\r\n\r\n    //! Emitted when the contents have changed.\r\n    void contentChanged();\r\n\r\n    //! Emitted when the scan has started.\r\n    void scanStarted();\r\n\r\n    //! Emitted when the scan has completed.\r\n    void scanCompleted();\r\n\r\nprivate slots:\r\n\r\n    /*!\r\n     *  Scans the source directories.\r\n     */\r\n    void scanDirectories();\r\n\r\n    /*!\r\n     *  Updates the progress bar with the given value.\r\n     *\r\n     *    @param [in] value The value to set to the progress bar.\r\n     */\r\n    void updateProgressBar(int value);\r\n\r\n    /*!\r\n     *  Sends filters to the dependency graph.\r\n     *\r\n     *    @param [in] the filter being toggled.\r\n     */\r\n    void filterToggle(QAction* action);\r\n\r\n    //! Updated the source directories for analysis.\r\n    void onSourceDirectoriesChanged();\r\n\r\nprivate:\r\n    // Disable copying.\r\n    FileDependencyEditor(FileDependencyEditor const& rhs);\r\n    FileDependencyEditor& operator=(FileDependencyEditor const& rhs);\r\n\r\n    /*!\r\n     *  Resolves the correct file type for each extension specified in the settings.\r\n     */\r\n    void resolveExtensionFileTypes();\r\n    \r\n    /*!\r\n     *  Finishes the scan.\r\n     */\r\n    void finishScan();\r\n    \r\n    /*!\r\n     *  Scans recursively files in the given path and adds them to the component file sets.\r\n     *\r\n     *    @param [in] path The path to scan.\r\n     */\r\n    void scanFiles(QString const& path);\r\n\r\n    /*!\r\n     *  Returns true if the given file is IP-XACT.\r\n     *\r\n     *    @param [in] filename The name of the file to check.\r\n     */\r\n    bool isFileIPXact(QString const& filename) const;\r\n\r\n    //! Setups the toolbar for file dependency analysis.\r\n    void setupToolbar();\r\n    \r\n    /*\r\n     *  Adds a filter button to the toolbar.\r\n     *\r\n     *    @param [in] icon        The icon for the button.\r\n     *    @param [in] iconText    The text displayed for the icon.\r\n     *    @param [in] filter      The filter value for the button.\r\n     */\r\n    void addFilterButton(QIcon const& icon, QString const& iconText, FileDependencyGraphView::DependencyFilter filter);\r\n\r\n    //! Sets the widget layout.\r\n    void setupLayout();\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! Toolbar.\r\n    QToolBar toolbar_;\r\n\r\n    //! The progress bar.\r\n    QProgressBar progressBar_;\r\n\r\n    //! The dependency graph widget.\r\n    FileDependencyGraphWidget graphWidget_;\r\n\r\n    //! The dependency info widget.\r\n    FileDependencyInfoWidget infoWidget_;\r\n\r\n    FileDependencySourceEditor directoryEditor_;\r\n\r\n    //! The component being edited.\r\n    QSharedPointer<Component> component_;\r\n\r\n    //! Extension fileset lookup.\r\n    QMultiMap<QString, QString> fileTypeLookup_;\r\n\r\n    //! Ignore list for extensions.\r\n    QStringList ignoreExtList_;\r\n\r\n    //! The file dependency model.\r\n    FileDependencyModel model_;\r\n\r\n    //! The XML base path for the component.\r\n    QString basePath_;\r\n\r\n    //! If true, the editor is currently scanning.\r\n    bool scanning_;\r\n\r\n    //! Container for the filter button actions.\r\n    QActionGroup filterActions_;\r\n\r\n    //! Action to start the analysis.\r\n    QAction* runAnalysisAction_;\r\n\r\n    //! Timer for file scanning.\r\n    QTimer* timer_;\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n\r\n#endif // FILEDEPENDENCYEDITOR_H\r\n"
  },
  {
    "path": "editors/ComponentEditor/fileSet/dependencyAnalysis/FileDependencyGraphView.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: FileDependencyGraphWidget.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Joni-Matti Maatta\r\n// Date: 23.01.2013\r\n//\r\n// Description:\r\n// Widget for showing the table-style file dependency graph.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"FileDependencyGraphView.h\"\r\n\r\n#include \"FileDependencyColumns.h\"\r\n#include \"FileDependencyItem.h\"\r\n#include \"FileDependencyModel.h\"\r\n#include \"FileDependencySortFilter.h\"\r\n\r\n#include <IPXACTmodels/kactusExtensions/FileDependency.h>\r\n\r\n#include <common/KactusColors.h>\r\n\r\n#include <QHeaderView>\r\n#include <QPainter>\r\n#include <QPaintEvent>\r\n#include <QScrollBar>\r\n#include <QMenu>\r\n#include <QFileDialog>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileDependencyGraphWidget::FileDependencyGraphWidget()\r\n//-----------------------------------------------------------------------------\r\nFileDependencyGraphView::FileDependencyGraphView(QWidget* parent)\r\n    : QTreeView(parent),\r\n      sortFilter_(new FileDependencySortFilter(this)),\r\n      model_(0),\r\n      columns_(),\r\n      maxVisibleGraphColumns_(0),\r\n      scrollIndex_(0),\r\n      selectedDependency_(0),\r\n      drawingDependency_(false),\r\n      filters_(FILTER_DEFAULT),\r\n      manualDependencyStartItem_(0),\r\n      manualDependencyEndItem_(0),\r\n      multiManualCreation_(false)\r\n{\r\n    setUniformRowHeights(true);\r\n    setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);\r\n    setMouseTracking(true);\r\n\r\n    connect(header(), SIGNAL(sectionResized(int, int, int)), this, SLOT(onSectionResized()), Qt::UniqueConnection);\r\n\r\n    connect(this, SIGNAL(collapsed(QModelIndex const&)), this, SLOT(onDependenciesReset()), Qt::UniqueConnection);\r\n    connect(this, SIGNAL(expanded(QModelIndex const&)), this, SLOT(onDependenciesReset()), Qt::UniqueConnection);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileDependencyGraphWidget::~FileDependencyGraphWidget()\r\n//-----------------------------------------------------------------------------\r\nFileDependencyGraphView::~FileDependencyGraphView()\r\n{\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileDependencyGraphWidget::setModel()\r\n//-----------------------------------------------------------------------------\r\nvoid FileDependencyGraphView::setModel(QAbstractItemModel* model)\r\n{\r\n    // Disconnect the previous model.\r\n    if (model_ != 0)\r\n    {\r\n        model_->disconnect(this);\r\n    }\r\n\r\n    FileDependencyModel* depModel = dynamic_cast<FileDependencyModel*>(model);\r\n    if (depModel != 0)\r\n    {\r\n        connect(depModel, SIGNAL(dependencyAdded(FileDependency*, bool)),\r\n                this, SLOT(onDependencyAdded(FileDependency*, bool)), Qt::UniqueConnection);\r\n        connect(depModel, SIGNAL(dependencyChanged(FileDependency*)),\r\n                this, SLOT(onDependencyChanged(FileDependency*)), Qt::UniqueConnection);\r\n        connect(depModel, SIGNAL(dependencyRemoved(FileDependency*)),\r\n                this, SLOT(onDependencyRemoved(FileDependency*)), Qt::UniqueConnection);\r\n        connect(depModel, SIGNAL(dependenciesReset()),\r\n                this, SLOT(onDependenciesReset()), Qt::UniqueConnection);\r\n\r\n        connect(this, SIGNAL(dependencyChanged(FileDependency*)),\r\n                depModel, SIGNAL(dependencyChanged(FileDependency*)), Qt::UniqueConnection);\r\n\r\n        model_ = depModel;\r\n    }\r\n    else\r\n    {\r\n        model_ = 0;\r\n    }\r\n\r\n    sortFilter_->setSourceModel(model_);\r\n    QTreeView::setModel(sortFilter_);\r\n\r\n    // TODO: Remove this later and remove status traffic lights properly if no-one ever needs them again\r\n    hideColumn(FileDependencyColumns::STATUS);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileDependencyGraphWidget::setFilters()\r\n//-----------------------------------------------------------------------------\r\nvoid FileDependencyGraphView::setFilters(DependencyFilters filters)\r\n{\r\n    // Save filters and apply.\r\n    filters_ = filters;\r\n    sortFilter_->setFilters(filters_);\r\n    onDependenciesReset();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileDependencyGraphWidget::getFilters()\r\n//-----------------------------------------------------------------------------\r\nFileDependencyGraphView::DependencyFilters FileDependencyGraphView::getFilters() const\r\n{\r\n    return filters_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileDependencyGraphView::setDependenciesEditable()\r\n//-----------------------------------------------------------------------------\r\nvoid FileDependencyGraphView::setDependenciesEditable(bool editable)\r\n{\r\n    setColumnHidden(FileDependencyColumns::CREATE_DEPENDENCY, !editable);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileDependencyGraphView::setGraphColumnScrollIndex()\r\n//-----------------------------------------------------------------------------\r\nvoid FileDependencyGraphView::setGraphColumnScrollIndex(int index)\r\n{\r\n    scrollIndex_ = index;\r\n    viewport()->repaint();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileDependencyGraphWidget::paintEvent()\r\n//-----------------------------------------------------------------------------\r\nvoid FileDependencyGraphView::paintEvent(QPaintEvent* event)\r\n{\r\n    QTreeView::paintEvent(event);\r\n\r\n    QPainter painter(viewport());\r\n    painter.setRenderHint(QPainter::Antialiasing);\r\n\r\n    painter.save();\r\n\r\n    drawDependencyGraph(painter, event->rect());\r\n\r\n    if (drawingDependency_)\r\n    {\r\n        drawManualCreationArrow(painter);\r\n    }\r\n\r\n    painter.restore();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileDependencyGraphWidget::mousePressEvent()\r\n//-----------------------------------------------------------------------------\r\nvoid FileDependencyGraphView::mousePressEvent(QMouseEvent* event)\r\n{\r\n    if (event->button() == Qt::RightButton && manualDependencyStartItem_)\r\n    {\r\n        endDependencyDraw();\r\n        viewport()->repaint();\r\n    }\r\n\r\n    int column = columnAt(event->position().x());\r\n\r\n    // Check if the user pressed over the dependencies column.\r\n    if (column == FileDependencyColumns::DEPENDENCIES)\r\n    {\r\n        selectDependencyUnderCursor(event);        \r\n    }\r\n    // Check if click is on the path.\r\n    else if (column == FileDependencyColumns::PATH)\r\n    {\r\n        createContextMenuForDependency(event);\r\n    }\r\n    // Otherwise check if the user pressed over the manual creation column.\r\n    else if (column == FileDependencyColumns::CREATE_DEPENDENCY)\r\n    {\r\n        createDependency(event);\r\n    }\r\n    else\r\n    {\r\n        QTreeView::mousePressEvent(event);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileDependencyGraphView::mouseMoveEvent()\r\n//-----------------------------------------------------------------------------\r\nvoid FileDependencyGraphView::mouseMoveEvent(QMouseEvent* event)\r\n{\r\n    // If creating manual dependencies\r\n    if(manualDependencyStartItem_ && drawingDependency_)\r\n    {\r\n        QModelIndex currentPoint = sortFilter_->mapToSource(indexAt(event->pos()));\r\n        if (currentPoint.isValid())\r\n        {\r\n            FileDependencyItem* currentDependencyItem = \r\n                static_cast<FileDependencyItem*>(currentPoint.internalPointer());\r\n            manualDependencyEndItem_ = currentDependencyItem;\r\n            viewport()->repaint();\r\n        }\r\n    }\r\n    else\r\n    {\r\n        QTreeView::mouseMoveEvent(event);\r\n\r\n        FileDependency* hovered = findDependencyAt(event->pos());\r\n        if (hovered != 0)\r\n        {\r\n            setToolTip(hovered->getDescription());\r\n        }\r\n        else\r\n        {\r\n            setToolTip(\"\");\r\n        }\r\n\r\n        viewport()->repaint();\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileDependencyGraphView::keyPressEvent()\r\n//-----------------------------------------------------------------------------\r\nvoid FileDependencyGraphView::keyPressEvent(QKeyEvent* event)\r\n{\r\n    // When delete is pressed, attempt to delete the selected dependency.\r\n    if (event->key() == Qt::Key_Delete && selectedDependency_)\r\n    {\r\n        // Check that the selected dependency is a manual one and that it's not locked.\r\n        if (selectedDependency_->isManual() && !selectedDependency_->isLocked())\r\n        {\r\n            model_->removeDependency(selectedDependency_);\r\n            selectedDependency_ = 0;\r\n            emit selectionChanged(0);\r\n        }\r\n    }\r\n    else if (event->key() == Qt::Key_Shift)\r\n    {\r\n        multiManualCreation_ = true;\r\n    }\r\n    else\r\n    {\r\n        QTreeView::keyPressEvent(event);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Functi: FileDependencyGraphView::keyReleaseEvent()\r\n//-----------------------------------------------------------------------------\r\nvoid FileDependencyGraphView::keyReleaseEvent(QKeyEvent* event)\r\n{\r\n    // Stop creating multiple dependencies when shift is released.\r\n    if (event->key() == Qt::Key_Shift)\r\n    {\r\n        multiManualCreation_ = false;\r\n        manualDependencyStartItem_ = 0;\r\n        manualDependencyEndItem_ = 0;\r\n        drawingDependency_ = false;\r\n        viewport()->repaint();\r\n    }\r\n    else if (event->key() == Qt::Key_Escape)\r\n    {\r\n        manualDependencyStartItem_ = 0;\r\n        manualDependencyEndItem_ = 0;\r\n        drawingDependency_ = false;\r\n        viewport()->repaint();\r\n    }\r\n    // If key release isn't handled here, send to parent class.\r\n    else\r\n    {\r\n        QTreeView::keyReleaseEvent(event);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileDependencyGraphView::resizeEvent()\r\n//-----------------------------------------------------------------------------\r\nvoid FileDependencyGraphView::resizeEvent(QResizeEvent *event)\r\n{\r\n    QTreeView::resizeEvent(event);\r\n    onSectionResized();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileDependencyGraphView::rowsInserted()\r\n//-----------------------------------------------------------------------------\r\nvoid FileDependencyGraphView::rowsInserted(QModelIndex const& parent, int start, int end)\r\n{\r\n    QTreeView::rowsInserted(parent, start, end);\r\n\r\n    disconnect(this, SIGNAL(expanded(QModelIndex const&)), this, SLOT(onDependenciesReset()));\r\n    setExpanded(parent, true);\r\n    connect(this, SIGNAL(expanded(QModelIndex const&)), this, SLOT(onDependenciesReset()), Qt::UniqueConnection);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileDependencyGraphView::reset()\r\n//-----------------------------------------------------------------------------\r\nvoid FileDependencyGraphView::reset()\r\n{\r\n    emit graphColumnScollMaximumChanged(0);\r\n    emit selectionChanged(0);\r\n\r\n    QTreeView::reset();\r\n\r\n    disconnect(this, SIGNAL(expanded(QModelIndex const&)), this, SLOT(onDependenciesReset()));\r\n    expandAll();\r\n    connect(this, SIGNAL(expanded(QModelIndex const&)), this, SLOT(onDependenciesReset()), Qt::UniqueConnection);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileDependencyGraphWidget::onDependencyAdded()\r\n//-----------------------------------------------------------------------------\r\nvoid FileDependencyGraphView::onDependencyAdded(FileDependency* dependency, bool shouldNotify, bool immediateRepaint /*= true*/)\r\n{\r\n    FileDependencyItem* fromItem = model_->findFileItem(dependency->getFile1());\r\n    FileDependencyItem* toItem = model_->findFileItem(dependency->getFile2());\r\n\r\n    Q_ASSERT(fromItem != 0);\r\n    Q_ASSERT(toItem != 0);\r\n\r\n    // Check if the dependency should not be visible.\r\n    if (!filterDependency(dependency))\r\n    {\r\n        return;\r\n    }\r\n\r\n    if (fromItem != nullptr && toItem != nullptr)\r\n    {\r\n        // Determine the y coordinates for the dependency.\r\n        int fromY = 0;\r\n        int toY = 0;\r\n\r\n        getVisualRowY(sortFilter_->mapFromSource(model_->getItemIndex(fromItem, 0)), fromY);\r\n        getVisualRowY(sortFilter_->mapFromSource(model_->getItemIndex(toItem, 0)), toY);\r\n\r\n        // The user may be scrolling the view so scroll bar position must be taken into account.\r\n        int offset = verticalOffset();\r\n        fromY += offset;\r\n        toY += offset;\r\n\r\n        GraphDependency graphDep(dependency, fromY, toY);\r\n\r\n        // Find the first column from the left which has space for the dependency.\r\n        GraphColumn* selectedColumn = 0;\r\n        int x = GRAPH_MARGIN - scrollIndex_ * GRAPH_SPACING;\r\n\r\n        foreach (GraphColumn* column, columns_)\r\n        {\r\n            if (hasSpace(column, graphDep))\r\n            {\r\n                selectedColumn = column;\r\n                break;\r\n            }\r\n\r\n            x += GRAPH_SPACING;\r\n        }\r\n\r\n        // If no free column was found, create a new one.\r\n        if (selectedColumn == 0)\r\n        {            \r\n            selectedColumn = new GraphColumn();\r\n            columns_.append(selectedColumn);            \r\n\r\n            onSectionResized();\r\n        }\r\n        \r\n        selectedColumn->dependencies.append(graphDep);\r\n\r\n        // Repaint only the region of the new dependency.\r\n        if (immediateRepaint)\r\n        {\r\n            repaintArrowRegion(x, fromY, toY);\r\n        }\r\n        \r\n        // Emit changes only if needed\r\n        if (shouldNotify)\r\n        {\r\n            emit dependencyChanged(dependency);\r\n        }\r\n    }\r\n}\r\n\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileDependencyGraphView::onDependencyChanged()\r\n//-----------------------------------------------------------------------------\r\nvoid FileDependencyGraphView::onDependencyChanged(FileDependency* dependency)\r\n{\r\n    repaintDependency(dependency);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileDependencyGraphView::onDependencyRemoved()\r\n//-----------------------------------------------------------------------------\r\nvoid FileDependencyGraphView::onDependencyRemoved(FileDependency* dependency)\r\n{\r\n    int x = GRAPH_MARGIN - scrollIndex_ * GRAPH_SPACING;\r\n\r\n    foreach (GraphColumn* column, columns_)\r\n    {        \r\n        foreach (GraphDependency const& dep, column->dependencies)\r\n        {           \r\n            if (dep.dependency == dependency)\r\n            {\r\n                // Repaint only the area of the dependency.\r\n                int fromY = 0;\r\n                int toY = 0;\r\n                bool visible = getCoordinates(dep, fromY, toY);\r\n\r\n                if (dependency->isManual())\r\n                {\r\n                    emit dependencyChanged(dependency);\r\n                }\r\n\r\n                column->dependencies.removeOne(dep);\r\n\r\n                if (visible)\r\n                {\r\n                    repaintArrowRegion(x, fromY, toY);\r\n                }\r\n            }\r\n        }\r\n\r\n        x += GRAPH_SPACING;\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileDependencyGraphWidget::onDependenciesReset()\r\n//-----------------------------------------------------------------------------\r\nvoid FileDependencyGraphView::onDependenciesReset()\r\n{\r\n    selectedDependency_ = 0;\r\n    emit selectionChanged(0);\r\n\r\n    columns_.clear();\r\n    emit graphColumnScollMaximumChanged(0);\r\n\r\n    foreach (QSharedPointer<FileDependency> dependency, model_->getDependencies())\r\n    {\r\n        onDependencyAdded(dependency.data(), false, false);\r\n    }\r\n\r\n    viewport()->repaint();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileDependencyGraphView::onSectionResized()\r\n//-----------------------------------------------------------------------------\r\nvoid FileDependencyGraphView::onSectionResized()\r\n{\r\n    int width = columnWidth(FileDependencyColumns::DEPENDENCIES);\r\n    width -= 2 * GRAPH_MARGIN;\r\n\r\n    if (width <= 0)\r\n    {\r\n        maxVisibleGraphColumns_ = 0;\r\n    }\r\n    else\r\n    {\r\n        maxVisibleGraphColumns_ = 1 + width / GRAPH_SPACING;\r\n    }\r\n\r\n    emit graphColumnScollMaximumChanged(qMax<int>(0, columns_.size() - maxVisibleGraphColumns_));\r\n    emit dependencyColumnPositionChanged(columnViewportPosition(FileDependencyColumns::DEPENDENCIES));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileDependencyGraphView::onAddLocation()\r\n//-----------------------------------------------------------------------------\r\nvoid FileDependencyGraphView::onAddLocation()\r\n{\r\n    // Open a file dialog to define the location.\r\n    QString selectedDirectory = QFileDialog::getExistingDirectory(this, tr(\"Choose Source Directory\"));\r\n    if(selectedDirectory.isEmpty())\r\n    {\r\n        return;\r\n    }\r\n\r\n    selectedDirectory = QFileInfo(selectedDirectory).filePath();\r\n    model_->defineLocation(contextMenuItem_, selectedDirectory);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileDependencyGraphView::onLocationReset()\r\n//-----------------------------------------------------------------------------\r\nvoid FileDependencyGraphView::onLocationReset()\r\n{\r\n    model_->resetLocation(contextMenuItem_);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileDependencyGraphView::onMenuReverse()\r\n//-----------------------------------------------------------------------------\r\nvoid FileDependencyGraphView::onMenuReverse()\r\n{\r\n    selectedDependency_->reverse();\r\n    emit dependencyChanged(selectedDependency_);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileDependencyGraphView::onMenuBidirectional()\r\n//-----------------------------------------------------------------------------\r\nvoid FileDependencyGraphView::onMenuBidirectional()\r\n{\r\n    selectedDependency_->setBidirectional(!selectedDependency_->isBidirectional());\r\n    emit dependencyChanged(selectedDependency_);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileDependencyGraphView::onMenuLock()\r\n//-----------------------------------------------------------------------------\r\nvoid FileDependencyGraphView::onMenuLock()\r\n{\r\n    selectedDependency_->setLocked(!selectedDependency_->isLocked());\r\n    onDependencyChanged(selectedDependency_);\r\n    emit dependencyChanged(selectedDependency_);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileDependencyGraphView::onMenuDelete()\r\n//-----------------------------------------------------------------------------\r\nvoid FileDependencyGraphView::onMenuDelete()\r\n{\r\n    model_->removeDependency(selectedDependency_);\r\n    selectedDependency_ = 0;\r\n    emit selectionChanged(0);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileDependencyGraphView::selectDependencyUnderCursor()\r\n//-----------------------------------------------------------------------------\r\nvoid FileDependencyGraphView::selectDependencyUnderCursor(QMouseEvent* event)\r\n{\r\n    if ((event->button() == Qt::LeftButton || event->button() == Qt::RightButton) && !manualDependencyStartItem_)\r\n    {\r\n        FileDependency* pressedDependency = findDependencyAt(event->pos());\r\n\r\n        if (pressedDependency != selectedDependency_)\r\n        {\r\n            changeDependencySelection(pressedDependency);\r\n        }\r\n\r\n        if (event->button() == Qt::RightButton && selectedDependency_ != 0)\r\n        {\r\n            createContextMenu(event->globalPosition().toPoint());\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileDependencyGraphView::createContextMenuForDependency()\r\n//-----------------------------------------------------------------------------\r\nvoid FileDependencyGraphView::createContextMenuForDependency(QMouseEvent* event)\r\n{\r\n    if (event->button() == Qt::RightButton)\r\n    {\r\n        QModelIndex selectedIndex = sortFilter_->mapToSource(indexAt(event->pos()));\r\n        if (selectedIndex.isValid())\r\n        {\r\n            FileDependencyItem* selectedItem = static_cast<FileDependencyItem*>(selectedIndex.internalPointer());\r\n\r\n            if (selectedItem->getType() == FileDependencyItem::ITEM_TYPE_FILE && selectedItem->isExternal())\r\n            {\r\n                QMenu contextMenu;               \r\n                contextMenuItem_ = selectedItem;\r\n\r\n                if (selectedItem->getParent()->getType() == FileDependencyItem::ITEM_TYPE_UNKNOWN_LOCATION)\r\n                {\r\n                    QAction* locationAction = contextMenu.addAction(\"Define Location...\");\r\n                    connect(locationAction, SIGNAL(triggered()), this, SLOT(onAddLocation()));\r\n                }\r\n                else\r\n                {\r\n                    QAction* changeAction = contextMenu.addAction(\"Change Location...\");\r\n                    connect(changeAction, SIGNAL(triggered()), this, SLOT(onAddLocation()));\r\n\r\n                    QAction* resetAction = contextMenu.addAction(\"Reset\");\r\n                    connect(resetAction, SIGNAL(triggered()), this, SLOT(onLocationReset()));\r\n                }\r\n\r\n                contextMenu.exec(event->globalPosition().toPoint());\r\n            }\r\n        }\r\n    }\r\n    else\r\n    {\r\n        QTreeView::mousePressEvent(event);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileDependencyGraphView::createDependency()\r\n//-----------------------------------------------------------------------------\r\nvoid FileDependencyGraphView::createDependency(QMouseEvent* event)\r\n{\r\n    if (event->button() == Qt::LeftButton)\r\n    {\r\n        // Starting to create manual dependency\r\n        if (!manualDependencyStartItem_)\r\n        {\r\n            // Remove possible selection\r\n            if (selectedDependency_)\r\n            {\r\n                clearDependencySelection();\r\n            }\r\n\r\n            QModelIndex startPoint = sortFilter_->mapToSource(indexAt(event->pos()));\r\n\r\n            if (startPoint.isValid())\r\n            {\r\n                manualDependencyStartItem_ = static_cast<FileDependencyItem*>(startPoint.internalPointer());\r\n\r\n                if (manualDependencyStartItem_->getType() != FileDependencyItem::ITEM_TYPE_FILE)\r\n                {\r\n                    manualDependencyStartItem_ = 0;\r\n                }\r\n                else if (manualDependencyStartItem_->getParent()->getType() == FileDependencyItem::ITEM_TYPE_EXTERNAL_LOCATION ||\r\n                    manualDependencyStartItem_->getParent()->getType() == FileDependencyItem::ITEM_TYPE_UNKNOWN_LOCATION)\r\n                {\r\n                    manualDependencyStartItem_ = 0;\r\n                    emit warningMessage(tr(\"Cannot create manual dependency from external or unknown file location.\"));\r\n                }\r\n                else\r\n                {\r\n                    startDependencyDraw();\r\n                    emit warningMessage(\"\");\r\n                }\r\n            }\r\n        }\r\n        // Ending manual dependency creation.\r\n        else\r\n        {\r\n            if (manualDependencyEndItem_->getParent()->getType() == FileDependencyItem::ITEM_TYPE_EXTERNAL_LOCATION ||\r\n                manualDependencyEndItem_->getParent()->getType() == FileDependencyItem::ITEM_TYPE_UNKNOWN_LOCATION)\r\n            {\r\n                emit warningMessage(tr(\"Cannot create manual dependency to external or unknown file location.\"));\r\n            }\r\n            else if (manualDependencyStartItem_ &&\r\n                manualDependencyEndItem_->getType() == FileDependencyItem::ITEM_TYPE_FILE)\r\n            {\r\n                FileDependency* existingDependency = model_->findDependency(manualDependencyStartItem_->getPath(),\r\n                    manualDependencyEndItem_->getPath());\r\n\r\n                if (existingDependency)\r\n                {\r\n                    emit warningMessage(tr(\"Manually created dependency was discarded because it already exists.\"));\r\n                }\r\n                else\r\n                {\r\n                    // Check for a reversed dependency and whether the new dependency cannot be combined with it.\r\n                    FileDependency* reversedDependency = model_->findDependency(manualDependencyEndItem_->getPath(),\r\n                        manualDependencyStartItem_->getPath());\r\n\r\n                    if (reversedDependency == 0 || !reversedDependency->isManual())\r\n                    {\r\n                        FileDependency* createdDependency = createManualDependency();                           \r\n                        model_->addDependency(QSharedPointer<FileDependency>(createdDependency), true);\r\n\r\n                        // Selecting created manual dependency.\r\n                        changeDependencySelection(createdDependency);\r\n                        emit warningMessage(\"\");\r\n                    }\r\n                    else\r\n                    {\r\n                        reversedDependency->setBidirectional(true);\r\n                        changeDependencySelection(reversedDependency);\r\n                        emit warningMessage(tr(\"An existing manual dependency was changed to bidirectional.\"));\r\n                        emit dependencyChanged(existingDependency);\r\n                    }\r\n                }\r\n\r\n                // If shift-key is hold down not ending manual creation yet.\r\n                if (multiManualCreation_)\r\n                {\r\n                    startDependencyDraw();\r\n                }\r\n                else\r\n                {\r\n                    endDependencyDraw();\r\n                }\r\n\r\n                viewport()->repaint();\r\n            }\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileDependencyGraphWidget::drawDependencies()\r\n//-----------------------------------------------------------------------------\r\nvoid FileDependencyGraphView::drawDependencyGraph(QPainter& painter, QRect const& rect)\r\n{\r\n    int columnOffset = columnViewportPosition(FileDependencyColumns::DEPENDENCIES);\r\n    int x = GRAPH_MARGIN;\r\n\r\n    int lastColumnToDraw = qMin(columns_.size(), scrollIndex_ + maxVisibleGraphColumns_);\r\n    for (int i = scrollIndex_; i < lastColumnToDraw; ++i)\r\n    {\r\n        foreach (GraphDependency const& dep, columns_[i]->dependencies)\r\n        {\r\n            int fromY = 0;\r\n            int toY = 0;\r\n\r\n            if (getCoordinates(dep, fromY, toY) &&\r\n                ((filters_ & FILTER_DIFFERENCE) || dep.dependency->getStatus() != FileDependency::STATUS_REMOVED))\r\n            {\r\n                // Cull arrows that are not inside the view rectangle.\r\n                QRect arrowRect(columnOffset + x - ARROW_WIDTH, qMin(fromY, toY) - POINTER_OFFSET,\r\n                    2 * ARROW_WIDTH, qAbs(toY - fromY) + 2 * POINTER_OFFSET);\r\n\r\n                if (arrowRect.intersects(rect))\r\n                {\r\n                    // Choose color for the arrow based on the dependency information and the selected dependency.\r\n                    QColor color = KactusColors::REGULAR_TEXT;\r\n\r\n                    if (dep.dependency == selectedDependency_)\r\n                    {\r\n                        color = Qt::blue;\r\n                    }\r\n                    else if (dep.dependency->isManual())\r\n                    {\r\n                        color = Qt::magenta;\r\n                    }\r\n                    else if (filters_ & FILTER_DIFFERENCE)\r\n                    {\r\n                        if (dep.dependency->getStatus() == FileDependency::STATUS_ADDED)\r\n                        {\r\n                            color = KactusColors::DEPENDECY_ADDED;\r\n                        }\r\n                        else if (dep.dependency->getStatus() == FileDependency::STATUS_REMOVED)\r\n                        {\r\n                            color = KactusColors::ERROR;\r\n                        }\r\n                    }\r\n\r\n                    drawArrow(painter, columnOffset + x, fromY, toY, color, dep.dependency->isBidirectional());\r\n                }\r\n            }\r\n        }\r\n\r\n        x += GRAPH_SPACING;\r\n    }\r\n\r\n    // Draw coverage of the dependencies that are out of sight.\r\n    painter.setPen(QPen(KactusColors::DEPENDECY_COVERAGE, 2));\r\n    painter.setRenderHint(QPainter::Antialiasing, false);\r\n\r\n    // Left side coverage.\r\n    x = columnOffset + 2;\r\n\r\n    for (int i = 0; i < scrollIndex_; ++i)\r\n    {\r\n        foreach (GraphDependency const& dep, columns_[i]->dependencies)\r\n        {\r\n            int fromY = 0;\r\n            int toY = 0;\r\n\r\n            if (getCoordinates(dep, fromY, toY))\r\n            {\r\n                painter.drawLine(x, fromY, x, toY);\r\n            }\r\n        }\r\n    }\r\n\r\n    // Right side coverage.\r\n    x = columnOffset + columnWidth(FileDependencyColumns::DEPENDENCIES) - 2;\r\n\r\n    for (int i = scrollIndex_ + maxVisibleGraphColumns_; i < columns_.size(); ++i)\r\n    {\r\n        foreach (GraphDependency const& dep, columns_[i]->dependencies)\r\n        {\r\n            int fromY = 0;\r\n            int toY = 0;\r\n\r\n            if (getCoordinates(dep, fromY, toY))\r\n            {\r\n                painter.drawLine(x, fromY, x, toY);\r\n            }\r\n        }\r\n    }\r\n\r\n    painter.setRenderHint(QPainter::Antialiasing);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileDependencyGraphView::getCoordinates()\r\n//-----------------------------------------------------------------------------\r\nbool FileDependencyGraphView::getCoordinates(GraphDependency const &dep, int& fromY, int& toY) const\r\n{\r\n    FileDependencyItem* fromItem = model_->findFileItem(dep.dependency->getFile1());\r\n    FileDependencyItem* toItem = model_->findFileItem(dep.dependency->getFile2());\r\n\r\n    Q_ASSERT(fromItem != 0);\r\n    Q_ASSERT(toItem != 0);\r\n\r\n    // Determine the y coordinates for the dependency.\r\n    // If the item is not visible, reroute the dependency to the missing item's parent.\r\n    if (!getVisualRowY(sortFilter_->mapFromSource(model_->getItemIndex(fromItem, 0)), fromY))\r\n    {\r\n        fromItem = fromItem->getParent();\r\n\r\n        if (!getVisualRowY(sortFilter_->mapFromSource(model_->getItemIndex(fromItem, 0)), fromY))\r\n        {\r\n            return false;\r\n        }\r\n    }\r\n\r\n    if (!getVisualRowY(sortFilter_->mapFromSource(model_->getItemIndex(toItem, 0)), toY))\r\n    {\r\n        toItem = toItem->getParent();\r\n\r\n        if (!getVisualRowY(sortFilter_->mapFromSource(model_->getItemIndex(toItem, 0)), toY))\r\n        {\r\n            return false;\r\n        }\r\n    }\r\n\r\n    // The items can be same when both items are not visible and have a same parent.\r\n    // In that case, the dependency is invisible.\r\n    if (fromItem == toItem)\r\n    {\r\n        return false;\r\n    }\r\n\r\n    return true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileDependencyGraphWidget::drawManualCreationArrow()\r\n//-----------------------------------------------------------------------------\r\nvoid FileDependencyGraphView::drawManualCreationArrow(QPainter& painter)\r\n{\r\n    int x = columnViewportPosition(FileDependencyColumns::CREATE_DEPENDENCY) + \r\n        columnWidth(FileDependencyColumns::CREATE_DEPENDENCY) / 2;\r\n    int startY = 0;\r\n    int currentY = 0;\r\n\r\n    getVisualRowY(sortFilter_->mapFromSource(model_->getItemIndex(manualDependencyStartItem_, 0)), startY);\r\n    getVisualRowY(sortFilter_->mapFromSource(model_->getItemIndex(manualDependencyEndItem_, 0)), currentY);\r\n    drawArrow(painter, x, startY, currentY, Qt::blue, false);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileDependencyGraphWidget::drawArrow()\r\n//-----------------------------------------------------------------------------\r\nvoid FileDependencyGraphView::drawArrow(QPainter& painter, int x, int fromY, int toY,\r\n    QColor const& color, bool bidirectional)\r\n{\r\n    painter.setPen(QPen(color, 2));\r\n    painter.setBrush(QBrush(color));\r\n    painter.drawLine(x, fromY, x, toY);\r\n\r\n    if (bidirectional)\r\n    {\r\n        drawArrowHeadUp(painter, x, qMin(fromY, toY));\r\n        drawArrowHeadDown(painter, x, qMax(fromY, toY));\r\n    }\r\n    else\r\n    {\r\n        // Draw dot at the starting point.\r\n        painter.drawPie(x - DOT_RADIUS, fromY - DOT_RADIUS, DOT_DIAMETER, DOT_DIAMETER, 0, 5760);\r\n\r\n        if (fromY < toY)\r\n        {\r\n            drawArrowHeadDown(painter, x, toY);          \r\n        }\r\n        else\r\n        {\r\n            drawArrowHeadUp(painter, x, toY);\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileDependencyGraphView::drawArrowHeadUp()\r\n//-----------------------------------------------------------------------------\r\nvoid FileDependencyGraphView::drawArrowHeadUp(QPainter& painter, int x, int y)\r\n{\r\n    QPoint points[3] = {\r\n        QPoint(x - ARROW_WIDTH, y - POINTER_OFFSET + ARROW_HEIGHT),\r\n        QPoint(x + ARROW_WIDTH, y - POINTER_OFFSET + ARROW_HEIGHT),\r\n        QPoint(x, y - POINTER_OFFSET)\r\n    };\r\n\r\n    painter.drawPolygon(points, 3);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileDependencyGraphView::drawArrowHeadDown()\r\n//-----------------------------------------------------------------------------\r\nvoid FileDependencyGraphView::drawArrowHeadDown(QPainter& painter, int x, int y)\r\n{\r\n    QPoint points[3] = {\r\n        QPoint(x - ARROW_WIDTH, y + POINTER_OFFSET - ARROW_HEIGHT),\r\n        QPoint(x + ARROW_WIDTH, y + POINTER_OFFSET - ARROW_HEIGHT),\r\n        QPoint(x, y + POINTER_OFFSET)\r\n    };\r\n\r\n    painter.drawPolygon(points, 3);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileDependencyGraphWidget::getRowY()\r\n//-----------------------------------------------------------------------------\r\nbool FileDependencyGraphView::getVisualRowY(QModelIndex const& index, int& y) const\r\n{\r\n    QRect rect = visualRect(index);\r\n    \r\n    if (rect.isNull())\r\n    {\r\n        return false;\r\n    }\r\n\r\n    y = rect.center().y();\r\n    return true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileDependencyGraphWidget::hasSpace()\r\n//-----------------------------------------------------------------------------\r\nbool FileDependencyGraphView::hasSpace(GraphColumn const* column, GraphDependency const& dependency) const\r\n{\r\n    int minY = qMin(dependency.fromY, dependency.toY) - SAFE_MARGIN;\r\n    int maxY = qMax(dependency.fromY, dependency.toY) + SAFE_MARGIN;\r\n\r\n    foreach (GraphDependency const& dep, column->dependencies)\r\n    {\r\n        if (!(maxY < qMin(dep.fromY, dep.toY) || minY > qMax(dep.fromY, dep.toY)))\r\n        {\r\n            return false;\r\n        }\r\n    }\r\n\r\n    return true;\r\n}\r\n\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileDependencyGraphWidget::drawRow()\r\n//-----------------------------------------------------------------------------\r\nvoid FileDependencyGraphView::drawRow(QPainter* painter, QStyleOptionViewItem const& option,\r\n                                      QModelIndex const& index) const\r\n{\r\n    QTreeView::drawRow(painter, option, index);\r\n\r\n    // Draw a line below the row.\r\n    QRect rowRect = visualRect(index);\r\n\r\n    painter->save();\r\n    painter->setPen(QPen(KactusColors::ROW_SEPARATOR, 0));\r\n    painter->drawLine(option.rect.left(), rowRect.bottom(), option.rect.right(), rowRect.bottom());\r\n    painter->restore();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileDependencyGraphView::findDependencyAt()\r\n//-----------------------------------------------------------------------------\r\nFileDependency* FileDependencyGraphView::findDependencyAt(QPoint const& point) const\r\n{\r\n    int x = columnViewportPosition(FileDependencyColumns::DEPENDENCIES) + GRAPH_MARGIN;\r\n\r\n    for (int i = scrollIndex_; i < columns_.size(); i++)\r\n    {\r\n        // Check if the column contains the x coordinate.\r\n        if (qAbs(x - point.x()) <= ARROW_WIDTH + SELECTION_MARGIN)\r\n        {\r\n            // Go through all dependencies in the column until we find a match.\r\n            foreach (GraphDependency const& dep, columns_[i]->dependencies)\r\n            {\r\n                int fromY = 0;\r\n                int toY = 0;\r\n\r\n                if (getCoordinates(dep, fromY, toY))\r\n                {\r\n                    // Interval intersection test.\r\n                    if (qMin(fromY, toY) - SELECTION_MARGIN <= point.y() &&\r\n                        point.y() <= qMax(fromY, toY) + SELECTION_MARGIN)\r\n                    {\r\n                        return dep.dependency;\r\n                    }\r\n                }\r\n            }\r\n\r\n            break;\r\n        }\r\n\r\n        x += GRAPH_SPACING;\r\n    }\r\n\r\n    return 0;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileDependencyGraphView::filterDependency()\r\n//-----------------------------------------------------------------------------\r\nbool FileDependencyGraphView::filterDependency(FileDependency const* dependency) const\r\n{\r\n    bool typeFilter = ((filters_ & FILTER_AUTOMATIC) && !dependency->isManual()) ||\r\n                      ((filters_ & FILTER_MANUAL) && dependency->isManual());\r\n\r\n    bool wayFilter = ((filters_ & FILTER_TWO_WAY) && dependency->isBidirectional()) ||\r\n                     ((filters_ & FILTER_ONE_WAY) && !dependency->isBidirectional());\r\n\r\n    bool extFilter = ((filters_ & FILTER_INTERNAL) && !model_->findFileItem(dependency->getFile2())->isExternal()) ||\r\n                     ((filters_ & FILTER_EXTERNAL) && model_->findFileItem(dependency->getFile2())->isExternal());\r\n\r\n    bool changesFilter = !(filters_ & FILTER_DIFFERENCE) ||\r\n                         dependency->getStatus() != FileDependency::STATUS_UNCHANGED;\r\n\r\n    bool existFilter = (filters_ & FILTER_DIFFERENCE) || dependency->getStatus() != FileDependency::STATUS_REMOVED;\r\n\r\n    return (typeFilter && wayFilter && extFilter && changesFilter && existFilter);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileDependencyGraphView::repaintDependency()\r\n//-----------------------------------------------------------------------------\r\nvoid FileDependencyGraphView::repaintDependency(FileDependency const* dependency)\r\n{\r\n    // Repaint only the area of the dependency.\r\n    int x = GRAPH_MARGIN - scrollIndex_ * GRAPH_SPACING;\r\n\r\n    foreach (GraphColumn const* column, columns_)\r\n    {\r\n        foreach (GraphDependency const& dep, column->dependencies)\r\n        {\r\n            if (dep.dependency == dependency)\r\n            {\r\n                int fromY = 0;\r\n                int toY = 0;\r\n\r\n                if (getCoordinates(dep, fromY, toY))\r\n                {\r\n                    repaintArrowRegion(x, fromY, toY);\r\n                }\r\n\r\n                break;\r\n            }\r\n        }\r\n\r\n        x += GRAPH_SPACING;\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileDependencyGraphView::repaintArrowRegion()\r\n//-----------------------------------------------------------------------------\r\nvoid FileDependencyGraphView::repaintArrowRegion(int x, int fromY, int toY)\r\n{\r\n    int columnOffset = columnViewportPosition(FileDependencyColumns::DEPENDENCIES);\r\n    viewport()->repaint(QRect(columnOffset + x - ARROW_WIDTH - SAFE_MARGIN,\r\n        qMin(fromY, toY) - POINTER_OFFSET - SAFE_MARGIN,\r\n        2 * (ARROW_WIDTH + SAFE_MARGIN),\r\n        qAbs(toY - fromY) + 2 * (POINTER_OFFSET + SAFE_MARGIN)));\r\n\r\n}\r\n//-----------------------------------------------------------------------------\r\n// Function: FileDependencyGraphView::createContextMenu()\r\n//-----------------------------------------------------------------------------\r\nvoid FileDependencyGraphView::createContextMenu(const QPoint& position)\r\n{\r\n    if (!selectedDependency_->isManual())\r\n    {\r\n        return;\r\n    }\r\n\r\n    QMenu contextMenu;\r\n\r\n    QAction* reverseAction = contextMenu.addAction(\"Reverse\");\r\n    if (selectedDependency_->isLocked() || selectedDependency_->isBidirectional())\r\n    {\r\n        reverseAction->setEnabled(false);\r\n    }\r\n    connect(reverseAction, SIGNAL(triggered()), this, SLOT(onMenuReverse()));\r\n\r\n    QAction* directionChangeAction;\r\n    if (selectedDependency_->isBidirectional())\r\n    {\r\n        directionChangeAction = contextMenu.addAction(\"Make unidirectional\");\r\n    }\r\n    else\r\n    {\r\n        directionChangeAction = contextMenu.addAction(\"Make bidirectional\");\r\n    }\r\n    if (selectedDependency_->isLocked())\r\n    {\r\n        directionChangeAction->setEnabled(false);\r\n        directionChangeAction->setCheckable(true);\r\n        directionChangeAction->setChecked(selectedDependency_->isBidirectional());\r\n    }\r\n    connect(directionChangeAction, SIGNAL(triggered()), this, SLOT(onMenuBidirectional()));\r\n\r\n    contextMenu.addSeparator();\r\n\r\n    QAction* lockAction;\r\n    if (selectedDependency_->isLocked())\r\n    {\r\n        lockAction = contextMenu.addAction(\"Unlock\");\r\n    }\r\n    else\r\n    {\r\n        lockAction = contextMenu.addAction(\"Lock\");\r\n    }\r\n    connect(lockAction, SIGNAL(triggered()), this, SLOT(onMenuLock()));\r\n\r\n    contextMenu.addSeparator();\r\n\r\n    QAction* deleteAction = contextMenu.addAction(\"Delete\");\r\n    if (selectedDependency_->isLocked())\r\n    {\r\n        deleteAction->setEnabled(false);\r\n    }\r\n    connect(deleteAction, SIGNAL(triggered()), this, SLOT(onMenuDelete()));\r\n    \r\n    // Open the context menu.\r\n    contextMenu.exec(position);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileDependencyGraphView::changeDependencySelection()\r\n//-----------------------------------------------------------------------------\r\nvoid FileDependencyGraphView::changeDependencySelection(FileDependency* newSelection)\r\n{\r\n    FileDependency* oldDependency = selectedDependency_;\r\n    selectedDependency_ = newSelection;\r\n\r\n    repaintDependency(oldDependency);\r\n    repaintDependency(selectedDependency_);                \r\n\r\n    emit selectionChanged(selectedDependency_);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileDependencyGraphView::clearDependencySelection()\r\n//-----------------------------------------------------------------------------\r\nvoid FileDependencyGraphView::clearDependencySelection()\r\n{\r\n    FileDependency* oldDependency = selectedDependency_;\r\n    selectedDependency_ = 0;\r\n\r\n    repaintDependency(oldDependency);            \r\n    emit selectionChanged(selectedDependency_);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileDependencyGraphView::startDependencyDraw()\r\n//-----------------------------------------------------------------------------\r\nvoid FileDependencyGraphView::startDependencyDraw()\r\n{\r\n    manualDependencyEndItem_ = manualDependencyStartItem_;\r\n    drawingDependency_ = true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileDependencyGraphView::endDependencyDraw()\r\n//-----------------------------------------------------------------------------\r\nvoid FileDependencyGraphView::endDependencyDraw()\r\n{\r\n    manualDependencyStartItem_ = 0;\r\n    manualDependencyEndItem_ = 0;\r\n    drawingDependency_ = false;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileDependencyGraphView::createManualDependency()\r\n//-----------------------------------------------------------------------------\r\nFileDependency* FileDependencyGraphView::createManualDependency()\r\n{\r\n    FileDependency* createdDependency = new FileDependency();\r\n    createdDependency->setFile1(manualDependencyStartItem_->getPath());\r\n    createdDependency->setFile2(manualDependencyEndItem_->getPath());\r\n    createdDependency->setManual(true);\r\n    createdDependency->setStatus(FileDependency::STATUS_ADDED);\r\n    return createdDependency;\r\n}\r\n"
  },
  {
    "path": "editors/ComponentEditor/fileSet/dependencyAnalysis/FileDependencyGraphView.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: FileDependencyGraphWidget.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Joni-Matti Maatta\r\n// Date: 19.01.2013\r\n//\r\n// Description:\r\n// Widget for showing the table-style file dependency graph.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef FILEDEPENDENCYGRAPHVIEW_H\r\n#define FILEDEPENDENCYGRAPHVIEW_H\r\n\r\n#include <QTreeView>\r\n\r\n#include \"FileDependencyItem.h\"\r\n\r\nclass FileDependency;\r\nclass FileDependencyModel;\r\nclass FileDependencySortFilter;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Widget for showing the table-style file dependency graph.\r\n//-----------------------------------------------------------------------------\r\nclass FileDependencyGraphView : public QTreeView\r\n{\r\n    Q_OBJECT\r\n\r\npublic:\r\n    //-----------------------------------------------------------------------------\r\n    //! Filter enumeration.\r\n    //-----------------------------------------------------------------------------\r\n    enum DependencyFilter\r\n    {\r\n        FILTER_GREEN        = 0x0001,\r\n        FILTER_YELLOW       = 0x0002,\r\n        FILTER_RED          = 0x0004,\r\n        FILTER_TWO_WAY      = 0x0008,\r\n        FILTER_ONE_WAY      = 0x0010,\r\n        FILTER_MANUAL       = 0x0020,\r\n        FILTER_AUTOMATIC    = 0x0040,\r\n        FILTER_INTERNAL     = 0x0080,\r\n        FILTER_EXTERNAL     = 0x0100,\r\n        FILTER_DIFFERENCE   = 0x0200,\r\n\r\n        FILTER_DEFAULT = FILTER_GREEN | FILTER_YELLOW | FILTER_RED |\r\n                         FILTER_TWO_WAY | FILTER_ONE_WAY |\r\n                         FILTER_MANUAL | FILTER_AUTOMATIC |\r\n                         FILTER_INTERNAL \r\n    };\r\n\r\n    //! Bit field type for the filters.\r\n    typedef unsigned int DependencyFilters;\r\n\r\n    /*!\r\n     *  Constructor.\r\n     *\r\n     *    @param [in] parent The parent widget.\r\n     */\r\n    FileDependencyGraphView(QWidget* parent);\r\n\r\n    /*!\r\n     *  Destructor.\r\n     */\r\n    ~FileDependencyGraphView();\r\n\r\n    /*!\r\n     *  Sets the item model.\r\n     *\r\n     *    @param [in] model The model to set.\r\n     */\r\n    virtual void setModel(QAbstractItemModel* model);\r\n\r\n    /*!\r\n     *  Sets the filters for the graph.\r\n     */\r\n    void setFilters(DependencyFilters filters);\r\n    \r\n    /*!\r\n     *  Returns the currently set filters for the graph.\r\n     */\r\n    DependencyFilters getFilters() const;\r\n\r\n    /*!\r\n     *  Sets the dependencies editable/read-only.\r\n     *\r\n     *    @param [in] editable If true, the dependencies are editable. If false, they are read-only.\r\n     */\r\n    void setDependenciesEditable(bool editable);\r\n\r\nsignals:\r\n    /*!\r\n     *  Emitted when a file dependency selection has changed.\r\n     */\r\n    void selectionChanged(FileDependency* dependency);\r\n\r\n    /*!\r\n     *  Emitted when the maximum for the graph column scroll has changed.\r\n     */\r\n    void graphColumnScollMaximumChanged(int maximum);\r\n\r\n    /*!\r\n     *  Emitted when the dependency column (left edge) position changes.\r\n     */\r\n    void dependencyColumnPositionChanged(int pos);\r\n\r\n    /*!\r\n     *  Prints a warning message to the information display.\r\n     */\r\n    void warningMessage(const QString& msg) const;\r\n\r\n    /*!\r\n     *  Emitted when a file dependency has changed.\r\n     */\r\n    void dependencyChanged(FileDependency* dependency);\r\n\r\npublic slots:\r\n    /*!\r\n     *  Sets the graph column scroll index.\r\n     *\r\n     *    @param [in] index The index to set.\r\n     */\r\n    void setGraphColumnScrollIndex(int index);\r\n\r\nprotected:\r\n    /*!\r\n     *  Draws the dependency graph on top of the tree view.\r\n     */\r\n    virtual void paintEvent(QPaintEvent* event);\r\n\r\n    /*!\r\n     *  Draws a row.\r\n     */\r\n    virtual void drawRow(QPainter* painter, QStyleOptionViewItem const& option, QModelIndex const& index) const;\r\n\r\n    /*!\r\n     *  Handles mouse press events and manual connection creation.\r\n     */\r\n    virtual void mousePressEvent(QMouseEvent* event);\r\n  \r\n    /*!\r\n     *  Handles mouse move events and manual connection creation.\r\n     */\r\n    virtual void mouseMoveEvent(QMouseEvent* event);\r\n    \r\n    /*!\r\n     *  Handles key presses.\r\n     */\r\n    virtual void keyPressEvent(QKeyEvent* event);\r\n\r\n    /*!\r\n     *  Handles key presses.\r\n     */\r\n    virtual void keyReleaseEvent(QKeyEvent* event);\r\n\r\n    /*!\r\n     *  Handles resize of the graph view.\r\n     *\r\n     *    @param [in] event The resize event.\r\n     */\r\n    virtual void resizeEvent(QResizeEvent *event);\r\n\r\n    /*!\r\n     *  Handles auto-expand when rows are inserted.\r\n     *\r\n     *    @param [in] parent The parent model index.\r\n     *    @param [in] start  The start index of the inserted rows.\r\n     *    @param [in] end    The end index of the inserted rows.\r\n     */\r\n    virtual void rowsInserted(QModelIndex const& parent, int start, int end);\r\n\r\n    virtual void reset();\r\n\r\nprivate slots:\r\n    /*!\r\n     *  Called when a dependency has been added.\r\n     */\r\n    void onDependencyAdded(FileDependency* dependency, bool shouldNotify, bool immediateRepaint = true);\r\n\r\n    /*!\r\n     *  Called when a dependency has been changed.\r\n     */\r\n    void onDependencyChanged(FileDependency* dependency);\r\n\r\n    /*!\r\n     *  Called when a dependency has been removed.\r\n     */\r\n    void onDependencyRemoved(FileDependency* dependency);\r\n\r\n    /*!\r\n     *  Called when the model has been reset.\r\n     */\r\n    void onDependenciesReset();\r\n\r\n    /*!\r\n     *  Called when any header section has been resized.\r\n     */\r\n    void onSectionResized();\r\n\r\n    /*!\r\n     *  Called when adding a location to external dependency.\r\n     */\r\n    void onAddLocation();\r\n\r\n    /*!\r\n     *  Called when resetting location of external dependency.\r\n     */\r\n    void onLocationReset();\r\n\r\n    /*!\r\n     *  Called when a dependency is reversed from context menu.\r\n     */\r\n    void onMenuReverse();\r\n\r\n    /*!\r\n     *  Called when a dependency is made uni-/bidirectional from context menu.\r\n     */\r\n    void onMenuBidirectional();\r\n\r\n    /*!\r\n     *  Called when a dependency is locked/unlocked from context menu.\r\n     */\r\n    void onMenuLock();\r\n\r\n    /*!\r\n     *  Called when a dependency is deleted from context menu.\r\n     */\r\n    void onMenuDelete();\r\n\r\nprivate:\r\n    //-----------------------------------------------------------------------------\r\n    //! Graph dependency structure.\r\n    //-----------------------------------------------------------------------------\r\n    struct GraphDependency\r\n    {\r\n        FileDependency* dependency;\r\n        int fromY;\r\n        int toY;\r\n\r\n        /*!\r\n         *  Constructor.\r\n         */\r\n        GraphDependency(FileDependency* dependency, int fromY, int toY)\r\n            : dependency(dependency),\r\n              fromY(fromY),\r\n              toY(toY)\r\n        {\r\n        }\r\n\r\n        bool operator==(GraphDependency const& other) const\r\n        {\r\n            return dependency == other.dependency && fromY == other.fromY && toY == other.toY;                 \r\n        }\r\n    };\r\n    \r\n    //-----------------------------------------------------------------------------\r\n    //! Graph column structure.\r\n    //-----------------------------------------------------------------------------\r\n    struct GraphColumn\r\n    {\r\n        QList<GraphDependency> dependencies;\r\n        \r\n        //! The constructor.\r\n        GraphColumn() : dependencies()\r\n        {\r\n        }\r\n    };\r\n\r\n    // Disable copying.\r\n    FileDependencyGraphView(FileDependencyGraphView const& rhs);\r\n    FileDependencyGraphView& operator=(FileDependencyGraphView const& rhs);\r\n\r\n    // Selects the dependency under cursor on mouse click.\r\n    void selectDependencyUnderCursor(QMouseEvent* event);\r\n\r\n    // Creates a context menu for the dependency under cursor on mouse right click.\r\n    void createContextMenuForDependency(QMouseEvent* event);\r\n\r\n    // Creates a new dependency on mouse click.\r\n    void createDependency(QMouseEvent* event);\r\n\r\n    /*!\r\n     *  Draws the dependency graph into the dependencies column.\r\n     *\r\n     *    @param [in] painter  The drawing context.\r\n     *    @param [in] rect     The currently visible drawing area.\r\n     */\r\n    void drawDependencyGraph(QPainter& painter, QRect const& rect);\r\n\r\n    /*!\r\n     *  Retrieves the final drawing coordinates and the items for the given dependency.\r\n     *\r\n     *    @param [in]  dep    The dependency.\r\n     *    @param [out] fromY  The resulted from y coordinate.\r\n     *    @param [out] toY    The resulted to y coordinate.\r\n     */\r\n    bool getCoordinates(GraphDependency const& dep, int& fromY, int& toY) const;\r\n\r\n    /*!\r\n     *  Draws the temporary manual dependency arrow when the user is creating a manual connection.\r\n     *\r\n     *    @param [in] painter The drawing context.\r\n     */\r\n    void drawManualCreationArrow(QPainter& painter);\r\n\r\n    /*!\r\n     *  Draws a dependency arrow.\r\n     *\r\n     *    @param [in] painter        The painter context.\r\n     *    @param [in] x              The x coordinate for the arrow.\r\n     *    @param [in] fromY          The \"from\" y coordinate.\r\n     *    @param [in] toY            The \"to\" y coordinate.\r\n     *    @param [in] color          The arrow color.\r\n     *    @param [in] bidirectional  If true, arrow heads will be drawn to both ends.\r\n     */\r\n    void drawArrow(QPainter& painter, int x, int fromY, int toY, QColor const& color, bool bidirectional = false);\r\n    \r\n    /*!\r\n     *  Draws an arrow head pointing down.\r\n     *\r\n     *    @param [in] painter     The painter to use for drawing.\r\n     *    @param [in] x           The x coordinate of the arrow head.\r\n     *    @param [in] y           The y coordinate of the arrow head.\r\n     */\r\n    void drawArrowHeadDown(QPainter& painter, int x, int y);\r\n        /*!\r\n     *  Draws an arrow head pointing up.\r\n     *\r\n     *    @param [in] painter     The painter to use for drawing.\r\n     *    @param [in] x           The x coordinate of the arrow head.\r\n     *    @param [in] y           The y coordinate of the arrow head.\r\n     */\r\n    void drawArrowHeadUp(QPainter& painter, int x, int y);\r\n\r\n    /*!\r\n     *  Retrieves the center y coordinate for the row specified by the given model index.\r\n     *\r\n     *    @param [in] index  The model index of the row.\r\n     *    @param [in] y      The retrieved y coordinate.\r\n     *\r\n     *    @return True, if the row is visible. False if hidden.\r\n     */\r\n    bool getVisualRowY(QModelIndex const& index, int& y) const;\r\n\r\n    /*!\r\n     *  Checks whether the given column has space for the given dependency.\r\n     */\r\n    bool hasSpace(GraphColumn const* column, GraphDependency const& dependency) const;\r\n\r\n    /*!\r\n     *  Searches for a dependency at the given mouse coordinate.\r\n     *\r\n     *    @param [in] pt The mouse coordinate point to test for.\r\n     *\r\n     *    @return If found, the dependency at the given coordinate. Otherwise null.\r\n     */\r\n    FileDependency* findDependencyAt(QPoint const& point) const;\r\n\r\n    /*!\r\n     *  Checks the dependency against the filters.\r\n     *\r\n     *    @param [in] dependency The dependency to check.\r\n     *\r\n     *    @return False, if the dependency should not be shown. Otherwise true.\r\n     */\r\n    bool filterDependency(FileDependency const* dependency) const;\r\n\r\n    /*!\r\n     *  Repaints the given dependency.\r\n     *\r\n     *    @param [in] dependency The dependency to repaint.\r\n     */\r\n    void repaintDependency(FileDependency const* dependency);\r\n\r\n    /*!\r\n     *  Repaints a region containing a dependency arrow.\r\n     *\r\n     *    @param [in] x       The x coordinate of the arrow.\r\n     *    @param [in] fromY   The starting y coordinate of the arrow.\r\n     *    @param [in] toY     The ending y coordinate of the arrow.\r\n     */\r\n    void repaintArrowRegion(int x, int fromY, int toY);\r\n\r\n    /*!\r\n     *  Creates a context menu for the currently selected dependency.\r\n     *\r\n     *    @param [in] position    The global position for the context menu.\r\n     */\r\n    void createContextMenu(const QPoint& position);\r\n\r\n\r\n    /*!\r\n     *  Changes the selected dependency and repaints the previous and current selection.\r\n     *\r\n     *    @param [in] newSelection   The dependency to select.\r\n     */\r\n    void changeDependencySelection(FileDependency* newSelection);\r\n\r\n    /*!\r\n     *  Clears the selected dependency and repaints the previous selection.\r\n     */\r\n    void clearDependencySelection();\r\n\r\n    /*!\r\n     *  Sets the dependency start item and starts the dependency draw.\r\n     */\r\n    void startDependencyDraw();    \r\n\r\n    /*!\r\n     *  Ends the dependency draw and clears the start and end item.\r\n     */\r\n    void endDependencyDraw();\r\n\r\n    /*!\r\n     *  Creates a new dependency using the start and end item.\r\n     *\r\n     *    @return The created dependency.\r\n     */\r\n    FileDependency* createManualDependency();\r\n\r\n    enum\r\n    {\r\n        DOT_RADIUS = 2,                 //!< The radius of the \"from\" dot for the arrows.\r\n        DOT_DIAMETER = 2* DOT_RADIUS,   //!< The diameter of the \"from\" dot for the arrows.\r\n        ARROW_WIDTH = 3,                //!< The half width of the arrow head.\r\n        ARROW_HEIGHT = 6,               //!< The height of the arrow head.\r\n        POINTER_OFFSET = 2,             //!< Pointer offset for drawing the arrow heads.\r\n        SAFE_MARGIN = 5,                //!< Safe margin for placing the dependencies into the columns.\r\n        GRAPH_MARGIN = 10,              //!< Left & right for the dependency graph in the Dependencies column.\r\n        GRAPH_SPACING = 20,             //!< Spacing between consecutive graph columns.\r\n        SELECTION_MARGIN = 4,           //!< Mouse selection margin for dependencies.\r\n    };\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! The sort filter.\r\n    FileDependencySortFilter* sortFilter_;\r\n\r\n    //! The data model.\r\n    FileDependencyModel* model_;\r\n\r\n    //! The graph columns.\r\n    QList<GraphColumn*> columns_;\r\n\r\n    //! The number of graph columns that can be visible.\r\n    int maxVisibleGraphColumns_;\r\n\r\n    //! The current scroll value of the dependency graph column.\r\n    int scrollIndex_;\r\n\r\n    //! The currently selected dependency.\r\n    FileDependency* selectedDependency_;\r\n\r\n    //! If true, the user is currently drawing a dependency.\r\n    bool drawingDependency_;\r\n\r\n    //! Current filters used on the graph.\r\n    DependencyFilters filters_;\r\n\r\n    //! The start item of manual dependency creation\r\n    FileDependencyItem* manualDependencyStartItem_;\r\n    \r\n    //! The end item of manual dependency creation\r\n    FileDependencyItem* manualDependencyEndItem_;\r\n\r\n    //! The file dependency item context menu was opened on\r\n    FileDependencyItem* contextMenuItem_;\r\n\r\n    //! If true, the shift key is pressed.\r\n    bool multiManualCreation_;\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n\r\n#endif // FILEDEPENDENCYGRAPHVIEW_H\r\n"
  },
  {
    "path": "editors/ComponentEditor/fileSet/dependencyAnalysis/FileDependencyGraphWidget.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: FileDependencyGraphWidget.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Joni-Matti Maatta\r\n// Date: 06.03.2013\r\n//\r\n// Description:\r\n// Widget which encapsulates the dependency graph view and a scroll bar\r\n// for scrolling the dependencies.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"FileDependencyGraphWidget.h\"\r\n\r\n#include <QVBoxLayout>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileDependencyGraphWidget::FileDependencyGraphWidget()\r\n//-----------------------------------------------------------------------------\r\nFileDependencyGraphWidget::FileDependencyGraphWidget(QWidget* parent)\r\n    : QWidget(parent),\r\n      view_(new FileDependencyGraphView(this)),\r\n      scrollBar_(Qt::Horizontal, parent),\r\n      barLayout_(0),\r\n      infoLabel_(this)\r\n{\r\n    view_->setContentsMargins(0, 0, 0, 0);\r\n    scrollBar_.setContentsMargins(0, 0, 0, 0);\r\n\r\n    barLayout_ = new QHBoxLayout();\r\n    barLayout_->addWidget(&infoLabel_);\r\n    barLayout_->addWidget(&scrollBar_);\r\n\r\n    QVBoxLayout* layout = new QVBoxLayout(this);\r\n    layout->setSpacing(0);\r\n    layout->addWidget(view_, 1);\r\n    layout->addLayout(barLayout_);\r\n    layout->setContentsMargins(0, 0, 0, 0);\r\n\r\n    connect(view_, SIGNAL(graphColumnScollMaximumChanged(int)),\r\n            this, SLOT(onGraphColumnScrollMaximumChanged(int)), Qt::UniqueConnection);\r\n    connect(view_, SIGNAL(dependencyColumnPositionChanged(int)),\r\n            this, SLOT(onDependencyColumnPositionChanged(int)), Qt::UniqueConnection);\r\n    connect(view_, SIGNAL(warningMessage(const QString&)),\r\n            this, SLOT(showWarningMessage(const QString&)), Qt::UniqueConnection);\r\n\r\n    connect(&scrollBar_, SIGNAL(valueChanged(int)),\r\n            view_, SLOT(setGraphColumnScrollIndex(int)), Qt::UniqueConnection);\r\n\r\n    infoLabel_.setTextFormat(Qt::RichText);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileDependencyGraphWidget::~FileDependencyGraphWidget()\r\n//-----------------------------------------------------------------------------\r\nFileDependencyGraphWidget::~FileDependencyGraphWidget()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileDependencyGraphWidget::getView()\r\n//-----------------------------------------------------------------------------\r\nFileDependencyGraphView* FileDependencyGraphWidget::getView()\r\n{\r\n    return view_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileDependencyGraphWidget::onGraphColumnCountChanged()\r\n//-----------------------------------------------------------------------------\r\nvoid FileDependencyGraphWidget::onGraphColumnScrollMaximumChanged(int maximum)\r\n{\r\n    scrollBar_.setEnabled(maximum >= 0);\r\n    scrollBar_.setMaximum(maximum);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileDependencyGraphWidget::onDependencyColumnPositionChanged()\r\n//-----------------------------------------------------------------------------\r\nvoid FileDependencyGraphWidget::onDependencyColumnPositionChanged(int pos)\r\n{\r\n    infoLabel_.setFixedWidth(pos);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileDependencyGraphWidget::showWarningMessage()\r\n//-----------------------------------------------------------------------------\r\nvoid FileDependencyGraphWidget::showWarningMessage(QString const& message)\r\n{\r\n    infoLabel_.setText(\"<font color=\\\"red\\\">\" + message + \"</font>\");\r\n}\r\n"
  },
  {
    "path": "editors/ComponentEditor/fileSet/dependencyAnalysis/FileDependencyGraphWidget.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: FileDependencyGraphWidget.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Joni-Matti Maatta\r\n// Date: 06.03.2013\r\n//\r\n// Description:\r\n// Widget which encapsulates the dependency graph view and a scroll bar\r\n// for scrolling the dependencies.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef FILEDEPENDENCYGRAPHWIDGET_H\r\n#define FILEDEPENDENCYGRAPHWIDGET_H\r\n\r\n#include \"FileDependencyGraphView.h\"\r\n\r\n#include <QWidget>\r\n#include <QScrollBar>\r\n#include <QHBoxLayout>\r\n#include <QLabel>\r\n\r\n//-----------------------------------------------------------------------------\r\n//! File dependency graph widget.\r\n//-----------------------------------------------------------------------------\r\nclass FileDependencyGraphWidget : public QWidget\r\n{\r\n    Q_OBJECT\r\n\r\npublic:\r\n    /*!\r\n     *  Constructor.\r\n     */\r\n    FileDependencyGraphWidget(QWidget* parent);\r\n\r\n    /*!\r\n     *  Destructor.\r\n     */\r\n    ~FileDependencyGraphWidget();\r\n\r\n    /*!\r\n     * Returns the view.\r\n     */\r\n    FileDependencyGraphView* getView();\r\n\r\nprivate slots:\r\n    /*!\r\n     *  Updates the progress bar when the graph column count has changed.\r\n     */\r\n    void onGraphColumnScrollMaximumChanged(int count);\r\n\r\n    /*!\r\n     *  Updates the progress bar to match the given column width.\r\n     */\r\n    void onDependencyColumnPositionChanged(int width);\r\n\r\n    /*!\r\n     *  Shows a warning message on the information display.\r\n     *\r\n     *    @param [in] message The message to show.\r\n     */\r\n    void showWarningMessage(QString const& message);\r\n\r\nprivate:\r\n    // Disable copying.\r\n    FileDependencyGraphWidget(FileDependencyGraphWidget const& rhs);\r\n    FileDependencyGraphWidget& operator=(FileDependencyGraphWidget const& rhs);\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! The graph view.\r\n    FileDependencyGraphView* view_;\r\n\r\n    //! The scroll bar for dependencies.\r\n    QScrollBar scrollBar_;\r\n\r\n    //! The scroll bar layout.\r\n    QHBoxLayout* barLayout_;\r\n\r\n    //! The information label.\r\n    QLabel infoLabel_;\r\n};\r\n\r\n#endif // FILEDEPENDENCYGRAPHWIDGET_H\r\n"
  },
  {
    "path": "editors/ComponentEditor/fileSet/dependencyAnalysis/FileDependencyInfoWidget.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: FileDependencyInfoWidget.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Joni-Matti Maatta, Tommi Korhonen\r\n// Date: 03.03.2013\r\n//\r\n// Description:\r\n// Widget for showing information about one file dependency.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"FileDependencyInfoWidget.h\"\r\n\r\n#include <IPXACTmodels/kactusExtensions/FileDependency.h>\r\n\r\n#include <QGridLayout>\r\n#include <QLabel>\r\n#include <QFileInfo>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileDependencyInfoWidget::FileDependencyInfoWidget()\r\n//-----------------------------------------------------------------------------\r\nFileDependencyInfoWidget::FileDependencyInfoWidget(QWidget* parent):\r\nQGroupBox(tr(\"Dependency information\"), parent),\r\n    descEdit_(this),\r\n    bidirectionalCheck_(tr(\"Bidirectional\"), this),\r\n    lockedCheck_(tr(\"Locked\"), this),\r\n    directionButton_(QIcon(\":icons/common/graphics/imported.png\"), tr(\"Reverse direction\"), this),\r\n    dependency_(0)\r\n{\r\n    setFlat(true);\r\n    setupLayout();\r\n\r\n    connect(&bidirectionalCheck_, SIGNAL(stateChanged(int)), this, SLOT(directionChanged(int)));\r\n    connect(&lockedCheck_, SIGNAL(stateChanged(int)), this, SLOT(lockedCheckChanged(int)));\r\n    connect(&descEdit_, SIGNAL(textChanged()), this, SLOT(descriptionChanged()));\r\n    connect(&directionButton_, SIGNAL(clicked()), this, SLOT(directionReversed()));\r\n\r\n    // Disabling the widgets.\r\n    descEdit_.setEnabled(false);\r\n    bidirectionalCheck_.setEnabled(false);\r\n    lockedCheck_.setEnabled(false);\r\n    directionButton_.setEnabled(false);\r\n    directionButton_.setFlat(true);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileDependencyInfoWidget::setEditedDependency()\r\n//-----------------------------------------------------------------------------\r\nvoid FileDependencyInfoWidget::setEditedDependency(FileDependency* dependency)\r\n{\r\n    dependency_ = dependency;\r\n\r\n    disconnect(&bidirectionalCheck_, SIGNAL(stateChanged(int)), this, SLOT(directionChanged(int)));\r\n    disconnect(&lockedCheck_, SIGNAL(stateChanged(int)), this, SLOT(lockedCheckChanged(int)));\r\n    disconnect(&descEdit_, SIGNAL(textChanged()), this, SLOT(descriptionChanged()));\r\n    disconnect(&directionButton_, SIGNAL(clicked()), this, SLOT(directionReversed()));\r\n\r\n    setTitle(tr(\"Dependency information\"));\r\n\r\n    descEdit_.setEnabled(dependency_ != 0);\r\n    descEdit_.clear();\r\n    if (dependency_ != 0)\r\n    {\r\n        descEdit_.setPlainText(dependency_->getDescription());\r\n    }\r\n\r\n    bidirectionalCheck_.setEnabled(dependency_ != 0 && dependency_->isManual());\r\n    bidirectionalCheck_.setChecked(dependency_ != 0 && dependency_->isBidirectional());\r\n\r\n    lockedCheck_.setEnabled(dependency_ != 0 && dependency_->isManual() && !dependency_->isBidirectional());\r\n    lockedCheck_.setChecked(dependency_ != 0 && dependency_->isLocked());\r\n\r\n    directionButton_.setEnabled(dependency_ != 0 && dependency_->isManual());\r\n    \r\n    if (dependency_ != 0)\r\n    {\r\n        if (dependency_->isManual())\r\n        {\r\n            lockEverything(lockedCheck_.isChecked());\r\n        }\r\n\r\n        updateFileLabel();\r\n    }\r\n\r\n    connect(&bidirectionalCheck_, SIGNAL(stateChanged(int)), this, SLOT(directionChanged(int)));\r\n    connect(&lockedCheck_, SIGNAL(stateChanged(int)), this, SLOT(lockedCheckChanged(int)));\r\n    connect(&descEdit_, SIGNAL(textChanged()), this, SLOT(descriptionChanged()));\r\n    connect(&directionButton_, SIGNAL(clicked()), this, SLOT(directionReversed()));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileDependencyInfoWidget::getEditedDependency()\r\n//-----------------------------------------------------------------------------\r\nFileDependency* FileDependencyInfoWidget::getEditedDependency() const\r\n{\r\n    return dependency_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileDependencyInfoWidget::directionChanged()\r\n//-----------------------------------------------------------------------------\r\nvoid FileDependencyInfoWidget::directionChanged(int /*state*/)\r\n{\r\n    if (!dependency_->isLocked())\r\n    {\r\n        dependency_->setBidirectional(bidirectionalCheck_.isChecked());\r\n        emit dependencyChanged(dependency_);\r\n        updateFileLabel();\r\n\r\n        directionButton_.setEnabled(!dependency_->isBidirectional());\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileDependencyInfoWidget::lockedCheckChanged()\r\n//-----------------------------------------------------------------------------\r\nvoid FileDependencyInfoWidget::lockedCheckChanged(int /*state*/)\r\n{\r\n    dependency_->setLocked(lockedCheck_.isChecked());\r\n    lockEverything(lockedCheck_.isChecked());\r\n    emit dependencyChanged(dependency_);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileDependencyInfoWidget::descriptionChanged()\r\n//-----------------------------------------------------------------------------\r\nvoid FileDependencyInfoWidget::descriptionChanged()\r\n{\r\n    if (!dependency_->isLocked())\r\n    {\r\n        dependency_->setDescription(descEdit_.toPlainText());\r\n        emit dependencyChanged(dependency_);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileDependencyInfoWidget::directionReversed()\r\n//-----------------------------------------------------------------------------\r\nvoid FileDependencyInfoWidget::directionReversed()\r\n{\r\n    if (!dependency_->isLocked())\r\n    {\r\n        dependency_->reverse();\r\n        emit dependencyChanged(dependency_);\r\n        updateFileLabel();\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileDependencyInfoWidget::updateFileLabel()\r\n//-----------------------------------------------------------------------------\r\nvoid FileDependencyInfoWidget::updateFileLabel()\r\n{\r\n    QString fileLabelText = tr(\"Dependency information: \");\r\n\r\n    QFileInfo fromInfo(dependency_->getFile1());\r\n    fileLabelText += fromInfo.fileName();\r\n\r\n    if (dependency_->isBidirectional())\r\n    {\r\n        fileLabelText.append(QLatin1String(\" <--> \"));\r\n    }\r\n    else\r\n    {\r\n        fileLabelText.append(QLatin1String(\" ---> \"));\r\n    }\r\n\r\n    QFileInfo toInfo(dependency_->getFile2());\r\n    fileLabelText.append(toInfo.fileName());\r\n    \r\n    setTitle(fileLabelText);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileDependencyInfoWidget::lockEverything()\r\n//-----------------------------------------------------------------------------\r\nvoid FileDependencyInfoWidget::lockEverything(bool isLocked)\r\n{\r\n    descEdit_.setEnabled(!isLocked);\r\n    bidirectionalCheck_.setEnabled(!isLocked);\r\n    directionButton_.setEnabled(!isLocked && !bidirectionalCheck_.isChecked());\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileDependencyInfoWidget::setupLayout()\r\n//-----------------------------------------------------------------------------\r\nvoid FileDependencyInfoWidget::setupLayout()\r\n{\r\n    auto buttonLayout = new QHBoxLayout();\r\n    buttonLayout->addWidget(&directionButton_);\r\n    buttonLayout->addWidget(&bidirectionalCheck_);\r\n    buttonLayout->addWidget(&lockedCheck_);\r\n    buttonLayout->addStretch();\r\n\r\n    auto topLayout = new QGridLayout(this);\r\n    topLayout->addLayout(buttonLayout, 0, 0, 1, 1);\r\n    topLayout->addWidget(new QLabel(tr(\"Description:\"), this), 1, 0, 1, 1);\r\n    topLayout->addWidget(&descEdit_, 2, 0, 1, 1);\r\n}\r\n"
  },
  {
    "path": "editors/ComponentEditor/fileSet/dependencyAnalysis/FileDependencyInfoWidget.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: FileDependencyInfoWidget.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Joni-Matti Maatta, Tommi Korhonen\r\n// Date: 19.01.2013\r\n//\r\n// Description:\r\n// Widget for showing information about one file dependency.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef FILEDEPENDENCYINFOWIDGET_H\r\n#define FILEDEPENDENCYINFOWIDGET_H\r\n\r\n#include <QGroupBox>\r\n#include <QPlainTextEdit>\r\n#include <QCheckBox>\r\n#include <QComboBox>\r\n#include <QPushButton>\r\n#include <QLabel>\r\n\r\nclass FileDependency;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Widget for showing information about one file dependency.\r\n//-----------------------------------------------------------------------------\r\nclass FileDependencyInfoWidget : public QGroupBox\r\n{\r\n    Q_OBJECT\r\n\r\npublic:\r\n    /*!\r\n     *  Constructor.\r\n     *\r\n     *    @param [in] parent The parent widget.\r\n     */\r\n    FileDependencyInfoWidget(QWidget* parent );\r\n\r\n    /*!\r\n     *  Destructor.\r\n     */\r\n    ~FileDependencyInfoWidget() final = default;\r\n\r\n    /*!\r\n     *  Returns the currently edited dependency.\r\n     */\r\n    FileDependency* getEditedDependency() const;\r\n\r\nsignals:\r\n\r\n    /*!\r\n     *  Emitted when the dependency has been changed.\r\n     */\r\n    void dependencyChanged(FileDependency* dependency);\r\n\r\npublic slots:\r\n    /*!\r\n     *  Sets the given file dependency editable in the widget.\r\n     *\r\n     *    @param [in] dependency The dependency to set for editing.\r\n     *\r\n     *      @remarks If the dependency is null, all contents of the widgets are cleared and\r\n     *               the widgets are set to disabled mode.\r\n     */\r\n    void setEditedDependency(FileDependency* dependency);\r\n\r\nprivate slots:\r\n\r\n    /*!\r\n     *  Handles a change in the direction..\r\n     *\r\n     *    @param [in] state   The new state for the direction.\r\n     */\r\n    void directionChanged(int state);\r\n\r\n    /*!\r\n     *  Handles the change in the locked check.\r\n     *\r\n     *    @param [in] state   The new state.\r\n     */\r\n    void lockedCheckChanged(int state);\r\n    \r\n    /*!\r\n     *  Handles the change in the description change.\r\n     */\r\n    void descriptionChanged();\r\n\r\n    /*!\r\n     *  Handles the reversing of the direction.\r\n     */\r\n    void directionReversed();\r\n\r\nprivate:\r\n    // Disable copying.\r\n    FileDependencyInfoWidget(FileDependencyInfoWidget const& rhs);\r\n    void setupLayout();\r\n\r\n    FileDependencyInfoWidget& operator=(FileDependencyInfoWidget const& rhs);\r\n\r\n    /*!\r\n     *  Update the file label.\r\n     */\r\n    void updateFileLabel();\r\n\r\n    /*!\r\n     *  Locks / unlocks everything.\r\n     *\r\n     *    @param [in] isLocked    The lock status.\r\n     */\r\n    void lockEverything(bool isLocked);\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! Editor for description.\r\n    QPlainTextEdit descEdit_;\r\n\r\n    //! Check box for changing whether direction is bidirectional.\r\n    QCheckBox bidirectionalCheck_;\r\n    \r\n    //! Check box for locked state.\r\n    QCheckBox lockedCheck_;\r\n\r\n    //! Button for reversing the direction.\r\n    QPushButton directionButton_;\r\n\r\n    //! The currently edited dependency.\r\n    FileDependency* dependency_;\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n\r\n#endif // FILEDEPENDENCYINFOWIDGET_H\r\n"
  },
  {
    "path": "editors/ComponentEditor/fileSet/dependencyAnalysis/FileDependencyItem.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: FileDependencyItem.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Joni-Matti Maatta\r\n// Date: 13.02.2013\r\n//\r\n// Description:\r\n// Base class for dependency items.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"FileDependencyItem.h\"\r\n\r\n#include <IPXACTmodels/Component/Component.h>\r\n#include <IPXACTmodels/Component/File.h>\r\n#include <IPXACTmodels/Component/FileSet.h>\r\n\r\n#include <QFileInfo>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileDependencyItem::FileDependencyItem()\r\n//-----------------------------------------------------------------------------\r\nFileDependencyItem::FileDependencyItem()\r\n    : parent_(0),\r\n      type_(ITEM_TYPE_ROOT),\r\n      component_(),\r\n      path_(),\r\n      references_(),\r\n      fileRefs_(),\r\n      children_()\r\n{\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileDependencyItem::~FileDependencyItem()\r\n//-----------------------------------------------------------------------------\r\nFileDependencyItem::~FileDependencyItem()\r\n{\r\n    foreach (FileDependencyItem* item, children_)\r\n    {\r\n        delete item;\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileDependencyItem::getChild()\r\n//-----------------------------------------------------------------------------\r\nFileDependencyItem* FileDependencyItem::getChild(int index)\r\n{\r\n    if (index < 0 || index >= getChildCount())\r\n    {\r\n        return 0;\r\n    }\r\n\r\n    return children_[index];\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileDependencyItem::getChild()\r\n//-----------------------------------------------------------------------------\r\nFileDependencyItem const* FileDependencyItem::getChild(int index) const\r\n{\r\n    if (index < 0 || index >= getChildCount())\r\n    {\r\n        return 0;\r\n    }\r\n\r\n    return children_[index];\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileDependencyItem::getChildCount()\r\n//-----------------------------------------------------------------------------\r\nint FileDependencyItem::getChildCount() const\r\n{\r\n    return children_.size();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileDependencyItem::getParent()\r\n//-----------------------------------------------------------------------------\r\nFileDependencyItem* FileDependencyItem::getParent()\r\n{\r\n    return parent_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileDependencyItem::getIndex()\r\n//-----------------------------------------------------------------------------\r\nint FileDependencyItem::getIndex()\r\n{\r\n    if (parent_ == 0)\r\n    {\r\n        return -1;\r\n    }\r\n\r\n    return parent_->children_.indexOf(this);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileDependencyItem::getType()\r\n//-----------------------------------------------------------------------------\r\nFileDependencyItem::ItemType FileDependencyItem::getType() const\r\n{\r\n    return type_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileDependencyItem::getSimplePath()\r\n//-----------------------------------------------------------------------------\r\nQString FileDependencyItem::getDisplayPath() const\r\n{\r\n    if (type_ == ITEM_TYPE_FILE)\r\n    {\r\n        if (isExternal())\r\n        {\r\n            QString filename = path_.mid(path_.indexOf('$', 1) + 2);\r\n            return filename;\r\n        }\r\n        else\r\n        {\r\n            QFileInfo info(path_);\r\n            return info.fileName();\r\n        }\r\n    }\r\n\r\n    else if (type_ == ITEM_TYPE_EXTERNAL_LOCATION)\r\n    {\r\n        return tr(\"External: \") + path_.mid(1, path_.length() - 2) + \"/\";\r\n    }\r\n\r\n    else if (type_ == ITEM_TYPE_UNKNOWN_LOCATION)\r\n    {\r\n        return tr(\"Unspecified\");\r\n    }\r\n\r\n    else\r\n    {\r\n        return path_ + \"/\";\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileDependencyItem::getFileSetNames()\r\n//-----------------------------------------------------------------------------\r\nQStringList FileDependencyItem::getFileSetNames() const\r\n{\r\n    QStringList names;\r\n    foreach (QSharedPointer<FileSet> fileSet, getFileSets())\r\n    {\r\n        names.append(fileSet->name());\r\n    }\r\n\r\n    return names;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileDependencyItem::addFile()\r\n//-----------------------------------------------------------------------------\r\nFileDependencyItem* FileDependencyItem::addFile(QSharedPointer<Component> component, QString const& path,\r\n    QList<QSharedPointer<File> > const& fileRefs)\r\n{\r\n    FileDependencyItem* item = new FileDependencyItem(component, path, fileRefs, this);\r\n    \r\n    for (int i = 0; i < children_.size(); ++i)\r\n    {\r\n        if (children_.at(i)->getPath() > path)\r\n        {\r\n            children_.insert(i, item);\r\n            return item;\r\n        }\r\n    }\r\n\r\n    children_.append(item);\r\n    return item;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileDependencyItem::addFolder()\r\n//-----------------------------------------------------------------------------\r\nFileDependencyItem* FileDependencyItem::addFolder(QSharedPointer<Component> component, QString const& path)\r\n{        \r\n    FileDependencyItem* item = new FileDependencyItem(component, path, this);\r\n\r\n    const int childCount = getChildCount();\r\n    for (int i = 0; i < childCount; i++)\r\n    {\r\n        if (getChild(i)->getPath() > path)\r\n        {\r\n            children_.insert(i, item);\r\n            return item;\r\n        }\r\n    }\r\n\r\n    children_.append(item);\r\n    return item;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileDependencyItem::getFileTypes()\r\n//-----------------------------------------------------------------------------\r\nQStringList FileDependencyItem::getFileTypes() const\r\n{\r\n    QStringList list;\r\n\r\n    for (QSharedPointer<File> file : fileRefs_)\r\n    {\r\n        for (auto const& type : *file->getFileTypes())\r\n        {\r\n            if (!list.contains(type.type_))\r\n            {\r\n                list.append(type.type_);\r\n            }\r\n        }\r\n    }\r\n\r\n    return list;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileDependencyItem::getName()\r\n//-----------------------------------------------------------------------------\r\nQString FileDependencyItem::getPath() const\r\n{\r\n    return path_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileDependencyItem::isExternal()\r\n//-----------------------------------------------------------------------------\r\nbool FileDependencyItem::isExternal() const\r\n{\r\n    if (type_ == ITEM_TYPE_FILE)\r\n    {\r\n        return (parent_->type_ != ITEM_TYPE_FOLDER);\r\n    }\r\n    else\r\n    {\r\n        return (type_ != ITEM_TYPE_FOLDER);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileDependencyItem::insertItem()\r\n//-----------------------------------------------------------------------------\r\nvoid FileDependencyItem::insertItem(FileDependencyItem* item)\r\n{\r\n    Q_ASSERT(item->parent_ == 0);\r\n\r\n    children_.append(item);\r\n    item->parent_ = this;\r\n    item->path_ = path_ + \"/\" + item->path_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileDependencyItem::removeItem()\r\n//-----------------------------------------------------------------------------\r\nvoid FileDependencyItem::removeItem(FileDependencyItem* item)\r\n{\r\n    Q_ASSERT(item->parent_ != 0);\r\n\r\n    children_.removeOne(item);\r\n    item->parent_ = 0;\r\n    item->path_ = item->path_.mid(item->path_.indexOf('$', 1) + 2);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileDependencyItem::hasMultipleFileSets()\r\n//-----------------------------------------------------------------------------\r\nbool FileDependencyItem::hasMultipleFileSets() const\r\n{\r\n    if (type_ == ITEM_TYPE_FILE)\r\n    {\r\n        return false;\r\n    }\r\n\r\n    // For folders/locations, we must check in what file sets the files belong to.\r\n    return getAllChildFileSets().count() > 1; \r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileDependencyItem::setFileSets()\r\n//-----------------------------------------------------------------------------\r\nvoid FileDependencyItem::setFileSets(QList<QSharedPointer<FileSet> > fileSets)\r\n{\r\n    Q_ASSERT(type_ != ITEM_TYPE_ROOT);\r\n\r\n    if (type_ == ITEM_TYPE_FILE)\r\n    {\r\n        QList<QSharedPointer<File> > newFileRefs;\r\n        QStringList fileTypes = getFileTypes();\r\n\r\n        foreach (QSharedPointer<FileSet> fileSet, fileSets)\r\n        {\r\n            // Check if the file already belongs to the file set --> no changes required.\r\n            bool found = false;\r\n\r\n            for (int i = 0; i < fileRefs_.size(); ++i)\r\n            {\r\n                foreach (QSharedPointer<File> containedFile, *fileSet->getFiles())\r\n                {\r\n                    \r\n                    if (containedFile == fileRefs_.at(i))\r\n                    {\r\n                        // Add the existing file ref to the new file ref list.\r\n                        newFileRefs.append(fileRefs_[i]);\r\n\r\n                        fileRefs_.removeAt(i);\r\n                        --i;\r\n                        found = true;\r\n                        break;\r\n                    }\r\n                }\r\n                if (found == true)\r\n                {\r\n                    break;\r\n                }\r\n            }\r\n\r\n            if (!found)\r\n            {\r\n                // Otherwise create a new file reference.\r\n                QSharedPointer<File> file(new File(path_));\r\n\r\n                for (auto const& fileType : fileTypes)\r\n                {\r\n                    file->getFileTypes()->append(FileType(fileType));\r\n                }\r\n\r\n                fileSet->addFile(file);\r\n\r\n                newFileRefs.append(file);\r\n            }\r\n        }\r\n\r\n        // Go through remaining old file refs and remove them.\r\n        foreach (QSharedPointer<File> fileToBeRemoved, fileRefs_)\r\n        {\r\n            foreach (QSharedPointer<FileSet> singleFileSet, *component_->getFileSets())\r\n            {\r\n                foreach (QSharedPointer<File> containedFile, *singleFileSet->getFiles())\r\n                {\r\n                    if (fileToBeRemoved == containedFile)\r\n                    {\r\n                        singleFileSet->removeFile(fileToBeRemoved->name());\r\n                    }\r\n                }\r\n            }\r\n        }\r\n\r\n        fileRefs_ = newFileRefs;\r\n    }\r\n    else\r\n    {\r\n        for (int i = 0; i < getChildCount(); ++i)\r\n        {\r\n            getChild(i)->setFileSets(fileSets);\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileDependencyItem::refreshFileRefs()\r\n//-----------------------------------------------------------------------------\r\nvoid FileDependencyItem::refreshFileRefs()\r\n{\r\n    fileRefs_.clear();\r\n    foreach (QSharedPointer<FileSet> containingFileSet, *component_->getFileSets())\r\n    {\r\n        foreach (QSharedPointer<File> containedFile, *containingFileSet->getFiles())\r\n        {\r\n            if (containedFile->name() == path_)\r\n            {\r\n                fileRefs_.append(containedFile);\r\n            }\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileDependencyItem::FileDependencyItem()\r\n//-----------------------------------------------------------------------------\r\nFileDependencyItem::FileDependencyItem(QSharedPointer<Component> component, QString const& path,\r\n    QList<QSharedPointer<File> > const& fileRefs, FileDependencyItem* parent):\r\nparent_(parent),\r\n      type_(ITEM_TYPE_FILE),\r\n      component_(component),\r\n      path_(path),\r\n      references_(),\r\n      fileRefs_(fileRefs),\r\n      children_()\r\n{\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileDependencyItem::FileDependencyItem()\r\n//-----------------------------------------------------------------------------\r\nFileDependencyItem::FileDependencyItem(QSharedPointer<Component> component, QString const& path,\r\n    FileDependencyItem* parent): parent_(parent),\r\n    type_(ITEM_TYPE_FOLDER),\r\n    component_(component),\r\n    path_(path),\r\n    references_(),\r\n    fileRefs_(),\r\n    children_()\r\n{\r\n    if (path.compare(QLatin1String(\"$External$\"), Qt::CaseInsensitive) == 0)\r\n    {\r\n        type_ = FileDependencyItem::ITEM_TYPE_UNKNOWN_LOCATION;\r\n    }\r\n    else if (path.startsWith(QLatin1Char('$')) && path.endsWith(QLatin1Char('$')))\r\n    {\r\n        type_ = FileDependencyItem::ITEM_TYPE_EXTERNAL_LOCATION;\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileDependencyItem::getFileSets()\r\n//-----------------------------------------------------------------------------\r\nQList<QSharedPointer<FileSet> > FileDependencyItem::getFileSets() const\r\n{\r\n    QList<QSharedPointer<FileSet> > fileSets;\r\n\r\n    if (type_ == ITEM_TYPE_FILE)\r\n    {\r\n        foreach (QSharedPointer<File> file, fileRefs_)\r\n        {\r\n            foreach (QSharedPointer<FileSet> singleFileSet, *component_->getFileSets())\r\n            {\r\n                if (!fileSets.contains(singleFileSet) && singleFileSet->getFiles()->contains(file))\r\n                {\r\n                    fileSets.append(singleFileSet);\r\n                }\r\n            }\r\n        }\r\n    }\r\n    else if (type_ != ITEM_TYPE_ROOT)\r\n    {\r\n        // For folders/locations, we must check in what file sets the files belong to.\r\n        // Otherwise determine the folder filesets.\r\n        fileSets = getAllChildFileSets();\r\n    }\r\n\r\n    return fileSets;\r\n}\r\n\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileDependencyItem::getAllChildFileSets()\r\n//-----------------------------------------------------------------------------\r\nQList<QSharedPointer<FileSet> > FileDependencyItem::getAllChildFileSets() const\r\n{\r\n    QList<QSharedPointer<FileSet> > fileSets;\r\n\r\n    for (int i = 0; i < getChildCount(); i++)\r\n    {\r\n        foreach (QSharedPointer<FileSet> fileSet, getChild(i)->getFileSets())\r\n        {\r\n            if (fileSets.contains(fileSet) == false)\r\n            {\r\n                fileSets.append(fileSet);\r\n            }\r\n        }\r\n    }\r\n\r\n    return fileSets;\r\n}\r\n"
  },
  {
    "path": "editors/ComponentEditor/fileSet/dependencyAnalysis/FileDependencyItem.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: FileDependencyItem.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Joni-Matti Maatta\r\n// Date: 13.02.2013\r\n//\r\n// Description:\r\n// Base class for file dependency items.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef FILEDEPENDENCYITEM_H\r\n#define FILEDEPENDENCYITEM_H\r\n\r\n#include <IPXACTmodels/common/VLNV.h>\r\n\r\n#include <QObject>\r\n#include <QString>\r\n#include <QList>\r\n#include <QSharedPointer>\r\n\r\nclass File;\r\nclass FileSet;\r\nclass Component;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Base class for file dependency items.\r\n//-----------------------------------------------------------------------------\r\nclass FileDependencyItem : public QObject\r\n{\r\n    Q_OBJECT\r\n\r\npublic:\r\n    //-----------------------------------------------------------------------------\r\n    //! Item type enumeration.\r\n    //-----------------------------------------------------------------------------\r\n    enum ItemType\r\n    {\r\n        ITEM_TYPE_ROOT = 0,\r\n        ITEM_TYPE_FOLDER,               //!< For packaged folders.\r\n        ITEM_TYPE_EXTERNAL_LOCATION,    //!< For external but specified locations.\r\n        ITEM_TYPE_UNKNOWN_LOCATION,     //!< For files whose location is unknown.\r\n        ITEM_TYPE_FILE                  //!< For any files.\r\n    };\r\n    \r\n    /*!\r\n     *  Default constructor which creates a root item.\r\n     */\r\n    FileDependencyItem();\r\n\r\n    /*!\r\n     *  Destructor.\r\n     */\r\n    virtual ~FileDependencyItem();\r\n\r\n    /*!\r\n     *  Adds a file item.\r\n     *\r\n     *    @param [in] type       The item type.\r\n     *    @param [in] component  The component being edited.\r\n     *    @param [in] path       The file path.\r\n     *    @param [in] fileRefs   The file references.\r\n     */\r\n    FileDependencyItem* addFile(QSharedPointer<Component> component, QString const& path,\r\n                                QList<QSharedPointer<File> > const& fileRefs);\r\n\r\n    /*!\r\n     *  Adds a folder item.\r\n     *\r\n     *    @param [in] component  The component being edited.\r\n     *    @param [in] path       The folder path. Enclose external locations with with '$' e.g. $path$.\r\n     *\r\n     *    @return The created item.\r\n     */\r\n    FileDependencyItem* addFolder(QSharedPointer<Component> component, QString const& path);\r\n\r\n    /*!\r\n     *  Inserts an item.\r\n     *\r\n     *    @param [in] item The item to insert.\r\n     */\r\n    void insertItem(FileDependencyItem* item);\r\n\r\n    /*!\r\n     *  Removes an item.\r\n     *\r\n     *    @param [in] item The item to remove.\r\n     */\r\n    void removeItem(FileDependencyItem* item);\r\n\r\n    /*!\r\n     *  Assigns the file into the given file sets.\r\n     *\r\n     *    @param [in] fileSets          The file sets where the file is assigned.\r\n     */\r\n    void setFileSets(QList<QSharedPointer<FileSet> > fileSets);\r\n\r\n    /*!\r\n     *  Refreshes the file references.\r\n     */\r\n    void refreshFileRefs();\r\n\r\n    /*!\r\n     *  Returns the child at the given index.\r\n     *\r\n     *    @param [in] index The index of the child to retrieve.\r\n     */\r\n    FileDependencyItem* getChild(int index);\r\n\r\n    /*!\r\n     *  Returns the child at the given index.\r\n     *\r\n     *    @param [in] index The index of the child to retrieve.\r\n     */\r\n    FileDependencyItem const* getChild(int index) const;\r\n\r\n    /*!\r\n     *  Returns the number of child items.\r\n     */\r\n    int getChildCount() const;\r\n\r\n    /*!\r\n     *  Returns the parent item.\r\n     */\r\n    FileDependencyItem* getParent();\r\n\r\n    /*!\r\n     *  Returns the index of this item.\r\n     */\r\n    int getIndex();\r\n\r\n    /*!\r\n     *  Returns the item type.\r\n     */\r\n    ItemType getType() const;\r\n\r\n    /*!\r\n     *  Gets the names of all the contained file sets.\r\n     *\r\n     *    @return The names of the contained file sets.\r\n     */\r\n    QStringList getFileSetNames() const;\r\n\r\n    /*!\r\n     *  Returns true if children have multiple (differing) filesets.\r\n     */\r\n    bool hasMultipleFileSets() const;\r\n\r\n    /*!\r\n     *  Returns the all file types the file represents.\r\n     */\r\n    QStringList getFileTypes() const;\r\n\r\n    /*!\r\n     *  Returns a shortened version of the path.\r\n     */\r\n    QString getDisplayPath() const;\r\n\r\n    /*!\r\n     *  Returns the name of the file (i.e. the packaged relative name).\r\n     */\r\n    QString getPath() const;\r\n\r\n    /*!\r\n     *  Returns true if the item is considered as external (not packaged).\r\n     */\r\n    bool isExternal() const;\r\n\r\nprivate:\r\n    // Disable copying.\r\n    FileDependencyItem(FileDependencyItem const& rhs);\r\n    FileDependencyItem& operator=(FileDependencyItem const& rhs);\r\n\r\n    /*!\r\n     *  Constructor which creates a file item.\r\n     *\r\n     *    @param [in] component  The component being edited.\r\n     *    @param [in] path       The path of the file.\r\n     *    @param [in] fileRefs   The file references.\r\n     *    @param [in] parent     The parent item.\r\n     */\r\n    FileDependencyItem( QSharedPointer<Component> component, QString const& path,\r\n        QList<QSharedPointer<File> > const& fileRefs, FileDependencyItem* parent);\r\n\r\n    /*!\r\n     *  Constructor which creates a folder item.\r\n     *     \r\n     *    @param [in] component  The component being edited.\r\n     *    @param [in] path       The path of the file/folder.\r\n     *    @param [in] parent     The parent item.\r\n     */\r\n    FileDependencyItem(QSharedPointer<Component> component, QString const& path, FileDependencyItem* parent);\r\n    \r\n    /*!\r\n     *  Returns the file sets where the file is currently contained.\r\n     */\r\n    QList<QSharedPointer<FileSet> > getFileSets() const;\r\n\r\n    /*!\r\n     *  Returns the file sets of all the child items.\r\n     */\r\n    QList<QSharedPointer<FileSet> > getAllChildFileSets() const;\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! The parent item.\r\n    FileDependencyItem* parent_;\r\n    \r\n    //! The item type.\r\n    ItemType type_;\r\n\r\n    //! The component being edited.\r\n    QSharedPointer<Component> component_;\r\n\r\n    //! The file path of the file/folder.\r\n    QString path_;\r\n\r\n    //! VLNV references.\r\n    QList<VLNV> references_;\r\n\r\n    //! File pointers.\r\n    QList<QSharedPointer<File> >fileRefs_;\r\n\r\n    //! The child items.\r\n    QList<FileDependencyItem*> children_;\r\n\r\n};\r\n\r\n#endif // FILEDEPENDENCYITEM_H\r\n"
  },
  {
    "path": "editors/ComponentEditor/fileSet/dependencyAnalysis/FileDependencyModel.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: FileDependencyModel.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Joni-Matti Maatta\r\n// Date: 12.02.2013\r\n//\r\n// Description:\r\n// The data model for the file dependencies.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"FileDependencyModel.h\"\r\n\r\n#include \"FileDependencyColumns.h\"\r\n#include \"FileDependencyItem.h\"\r\n\r\n#include <IPXACTmodels/Component/Component.h>\r\n#include <IPXACTmodels/Component/FileSet.h>\r\n#include <IPXACTmodels/kactusExtensions/FileDependency.h>\r\n\r\n#include <KactusAPI/include/FileHandler.h>\r\n#include <KactusAPI/include/PluginManager.h>\r\n#include <KactusAPI/include/ISourceAnalyzerPlugin.h>\r\n\r\n#include <common/KactusColors.h>\r\n\r\n#include <QIcon>\r\n#include <QDir>\r\n#include <QCryptographicHash>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileDependencyModel::FileDependencyModel()\r\n//-----------------------------------------------------------------------------\r\nFileDependencyModel::FileDependencyModel(QSharedPointer<Component> component, QString const& basePath):\r\ncomponent_(component),\r\n    basePath_(basePath),\r\n    root_(new FileDependencyItem()),\r\n    timer_(0),\r\n    curFolderIndex_(0),\r\n    curFileIndex_(0),\r\n    progressValue_(0),\r\n    dependencies_()\r\n{\r\n    connect(this, SIGNAL(dependencyChanged(FileDependency*)),\r\n        this, SIGNAL(dependenciesChanged()), Qt::UniqueConnection);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileDependencyModel::~FileDependencyModel()\r\n//-----------------------------------------------------------------------------\r\nFileDependencyModel::~FileDependencyModel()\r\n{\r\n    delete root_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileDependencyModel::headerData()\r\n//-----------------------------------------------------------------------------\r\nQVariant FileDependencyModel::headerData(int section, Qt::Orientation /*orientation*/, int role) const\r\n{\r\n    if (role == Qt::DisplayRole)\r\n    {\r\n        if (section == FileDependencyColumns::STATUS)\r\n        {\r\n            return tr(\"Status\");\r\n        }\r\n        else if (section == FileDependencyColumns::PATH)\r\n        {\r\n            return tr(\"Path\");\r\n        }\r\n        else if (section == FileDependencyColumns::FILESETS)\r\n        {\r\n            return tr(\"Filesets\");\r\n        }\r\n        else if (section == FileDependencyColumns::CREATE_DEPENDENCY)\r\n        {\r\n            return tr(\"#\");\r\n        }\r\n        else if (section == FileDependencyColumns::DEPENDENCIES)\r\n        {\r\n            return tr(\"Dependencies\");\r\n        }\r\n    }\r\n    else if (role == Qt::TextAlignmentRole)\r\n    {\r\n        return Qt::AlignCenter;\r\n    }\r\n\r\n    return QVariant();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileDependencyModel::columnCount()\r\n//-----------------------------------------------------------------------------\r\nint FileDependencyModel::columnCount(QModelIndex const& /*parent*/) const\r\n{\r\n    return FileDependencyColumns::COLUMN_COUNT;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileDependencyModel::rowCount()\r\n//-----------------------------------------------------------------------------\r\nint FileDependencyModel::rowCount(QModelIndex const& parent) const\r\n{\r\n    if (parent.isValid())\r\n    {\r\n        return static_cast<FileDependencyItem*>(parent.internalPointer())->getChildCount();\r\n    }\r\n    else\r\n    {\r\n        return root_->getChildCount();\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileDependencyModel::index()\r\n//-----------------------------------------------------------------------------\r\nQModelIndex FileDependencyModel::index(int row, int column, QModelIndex const& parent) const\r\n{\r\n    FileDependencyItem* parentItem = root_;\r\n\r\n    if (parent.isValid())\r\n    {\r\n        parentItem = static_cast<FileDependencyItem*>(parent.internalPointer());\r\n    }\r\n\r\n    auto child = parentItem->getChild(row);\r\n    \r\n    if (child == nullptr)\r\n    {\r\n        return QModelIndex();\r\n    }\r\n\r\n    return createIndex(row, column, child);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileDependencyModel::parent()\r\n//-----------------------------------------------------------------------------\r\nQModelIndex FileDependencyModel::parent(QModelIndex const& child) const\r\n{\r\n    if (child.isValid() == false)\r\n    {\r\n        return QModelIndex();\r\n    }\r\n\r\n    auto childItem = static_cast<FileDependencyItem*>(child.internalPointer());\r\n    FileDependencyItem* parent = childItem->getParent();\r\n\r\n    if (parent == 0 || parent == root_)\r\n    {\r\n        return QModelIndex();\r\n    }\r\n\r\n    int index = parent->getIndex();\r\n\r\n    if (index < 0)\r\n    {\r\n        return QModelIndex();\r\n    }\r\n\r\n    return createIndex(index, 0, parent);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileDependencyModel::setData()\r\n//-----------------------------------------------------------------------------\r\nbool FileDependencyModel::setData(QModelIndex const& index, QVariant const& value, int role)\r\n{\r\n    if (index.isValid() == false)\r\n    {\r\n        return false;\r\n    }\r\n\r\n    auto item = static_cast<FileDependencyItem*>(index.internalPointer());\r\n\r\n    if (role == Qt::EditRole && index.column() == FileDependencyColumns::FILESETS)\r\n    {\r\n        QStringList fileSetNames = value.toStringList();\r\n\r\n        // Retrieve correct file sets from the component.\r\n        QList<QSharedPointer<FileSet> > fileSets;\r\n        for (QString const& name : fileSetNames)\r\n        {\r\n            QSharedPointer<FileSet> fileSet = component_->getFileSet(name);\r\n            fileSets.append(fileSet);\r\n        }\r\n\r\n        bool canSet = fileSets.isEmpty() == false;\r\n        if (canSet)\r\n        {\r\n            item->setFileSets(fileSets);\r\n            emit dataChanged(index, index);\r\n            emit contentChanged();\r\n        }\r\n\r\n        return canSet;\r\n    }\r\n\r\n    return false;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileDependencyModel::data()\r\n//-----------------------------------------------------------------------------\r\nQVariant FileDependencyModel::data(QModelIndex const& index, int role) const\r\n{\r\n    if (index.isValid() == false)\r\n    {\r\n        return QVariant();\r\n    }\r\n\r\n    auto item = static_cast<FileDependencyItem*>(index.internalPointer());\r\n\r\n    if (role == Qt::DisplayRole)\r\n    {\r\n        if (index.column() == FileDependencyColumns::PATH)\r\n        {\r\n            return item->getDisplayPath();\r\n        }\r\n        else if (index.column() == FileDependencyColumns::FILESETS)\r\n        {\r\n            if (item->isExternal())\r\n            {\r\n                return QVariant();\r\n            }\r\n\r\n            QStringList fileSets = item->getFileSetNames();\r\n   \r\n            if (fileSets.isEmpty())\r\n            {\r\n                return tr(\"[none]\");\r\n            }\r\n            else if (item->getChildCount() > 1 && item->hasMultipleFileSets())\r\n            {\r\n                return tr(\"[multiple]\");\r\n            }\r\n            else\r\n            {\r\n                return fileSets.join(QStringLiteral(\"; \"));\r\n            }\r\n        }\r\n    }\r\n    else if (role == Qt::SizeHintRole && index.column() == FileDependencyColumns::STATUS)\r\n    {\r\n            return QSize(16, 16);\r\n    }\r\n    else if (role == Qt::ForegroundRole)\r\n    {\r\n        if (item->getType() == FileDependencyItem::ITEM_TYPE_FILE &&\r\n            item->getParent()->getType() == FileDependencyItem::ITEM_TYPE_FOLDER)\r\n        {\r\n            if (FileHandler::isValidURI(basePath_, item->getPath()) == false)\r\n            {\r\n                return KactusColors::ERROR;\r\n            }\r\n            else if (item->getFileSetNames().isEmpty())\r\n            {\r\n                return KactusColors::DISABLED_TEXT;\r\n            }\r\n        }\r\n    }\r\n    else if (role == Qt::BackgroundRole)\r\n    {\r\n        if (item->getType() == FileDependencyItem::ITEM_TYPE_FOLDER ||\r\n            item->getType() == FileDependencyItem::ITEM_TYPE_EXTERNAL_LOCATION ||\r\n            item->getType() == FileDependencyItem::ITEM_TYPE_UNKNOWN_LOCATION)\r\n        {\r\n            return KactusColors::STRONG_FIELD;\r\n        }\r\n        else if (item->getParent()->getType() == FileDependencyItem::ITEM_TYPE_FOLDER &&\r\n            FileHandler::isValidURI(basePath_, item->getPath()) == false)\r\n        {\r\n            return KactusColors::INVALID_FIELD;\r\n        }\r\n\r\n        if (index.column() == FileDependencyColumns::CREATE_DEPENDENCY)\r\n        {\r\n            return KactusColors::STRONG_FIELD;\r\n        }\r\n    }\r\n    else if (role == Qt::UserRole)\r\n    {\r\n        return item->getFileSetNames();\r\n    }\r\n\r\n    return QVariant();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileDependencyModel::hasChildren()\r\n//-----------------------------------------------------------------------------\r\nbool FileDependencyModel::hasChildren(QModelIndex const& parent /*= QModelIndex()*/) const\r\n{\r\n    FileDependencyItem* parentItem = root_;\r\n\r\n    if (parent.isValid())\r\n    {\r\n        parentItem = static_cast<FileDependencyItem*>(parent.internalPointer());\r\n    }\r\n\r\n    return (parentItem->getChildCount() > 0);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileDependencyModel::flags()\r\n//-----------------------------------------------------------------------------\r\nQt::ItemFlags FileDependencyModel::flags(QModelIndex const& index) const\r\n{\r\n    if (index.isValid() == false)\r\n    {\r\n        return Qt::NoItemFlags;\r\n    }\r\n\r\n    if (index.column() == FileDependencyColumns::CREATE_DEPENDENCY ||\r\n        index.column() == FileDependencyColumns::DEPENDENCIES)\r\n    {\r\n        return Qt::ItemIsSelectable;\r\n    }\r\n    else if (index.column() == FileDependencyColumns::FILESETS)\r\n    {\r\n        FileDependencyItem* item = static_cast<FileDependencyItem*>(index.internalPointer());\r\n        \r\n        if ((item->getType() == FileDependencyItem::ITEM_TYPE_FILE && item->isExternal()) == false || \r\n            item->getChildCount() > 0)\r\n        {\r\n            return Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsEditable;\r\n        }\r\n        else\r\n        {\r\n            return Qt::ItemIsEnabled | Qt::ItemIsSelectable;\r\n        }\r\n    }\r\n    else\r\n    {\r\n        return Qt::ItemIsEnabled | Qt::ItemIsSelectable;\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileDependencyModel::startAnalysis()\r\n//-----------------------------------------------------------------------------\r\nvoid FileDependencyModel::startAnalysis()\r\n{\r\n    // Reset state variables.\r\n    curFolderIndex_ = 0;\r\n    curFileIndex_ = 0;\r\n    progressValue_ = 0;\r\n    emit analysisProgressChanged(progressValue_ + 1);\r\n\r\n    // Start the analysis timer. Timer is used to scan files one at a time and allow user to cancel analysis.\r\n    timer_ = new QTimer(this);\r\n    connect(timer_, SIGNAL(timeout()), this, SLOT(performAnalysisStep()));\r\n    timer_->start();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileDependencyModel::stopAnalysis()\r\n//-----------------------------------------------------------------------------\r\nvoid FileDependencyModel::stopAnalysis()\r\n{\r\n    if (timer_ != 0)\r\n    {\r\n        timer_->stop();\r\n        delete timer_;\r\n        timer_ = 0;\r\n\r\n        // Reset the progress.\r\n        emit analysisProgressChanged(0);\r\n\r\n        // End analysis for each plugin.\r\n        for (ISourceAnalyzerPlugin* plugin : usedPlugins_)\r\n        {\r\n            plugin->endAnalysis(component_.data(), basePath_);\r\n        }\r\n\r\n        emit dependenciesReset();\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileDependencyModel::addFolder()\r\n//-----------------------------------------------------------------------------\r\nFileDependencyItem* FileDependencyModel::addFolder(QString const& path)\r\n{\r\n    return root_->addFolder(QSharedPointer<Component>(), path);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileDependencyModel::beginReset()\r\n//-----------------------------------------------------------------------------\r\nvoid FileDependencyModel::beginReset()\r\n{\r\n    beginResetModel();\r\n\r\n    delete root_;\r\n    root_ = new FileDependencyItem();\r\n\r\n    dependencies_.clear();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileDependencyModel::endReset()\r\n//-----------------------------------------------------------------------------\r\nvoid FileDependencyModel::endReset()\r\n{\r\n    // Add the existing dependencies to the model.\r\n    for (QSharedPointer<FileDependency> dependency : component_->getFileDependencies())\r\n    {\r\n        QSharedPointer<FileDependency> copy(new FileDependency(*dependency));\r\n        copy->setStatus(FileDependency::STATUS_UNCHANGED);\r\n\r\n        FileDependencyItem* startItem = findFileItem(copy->getFile1());\r\n\r\n        // First item should always be valid. Otherwise the dependency should be discarded altogether.\r\n        if (startItem == nullptr)\r\n        {\r\n            emit dependenciesChanged();\r\n            continue;\r\n        }\r\n\r\n        // Check if the second one is an external (not found).\r\n        if (findFileItem(copy->getFile2()) == nullptr)\r\n        {\r\n            // Extract the name of the external folder.\r\n            int endIndex = copy->getFile2().indexOf('$', 1);\r\n\r\n            if (copy->getFile2().at(0) != '$' || endIndex == -1)\r\n            {\r\n                continue;\r\n            }\r\n\r\n            // Search for a corresponding folder item.\r\n            QString folderName = copy->getFile2().mid(0, endIndex + 1);\r\n            FileDependencyItem* parent = findFolderItem(folderName);\r\n\r\n            // Create the folder item if not found.\r\n            if (parent == nullptr)\r\n            {\r\n                parent = root_->addFolder(component_, folderName);\r\n            }\r\n\r\n            parent->addFile(component_, copy->getFile2(), QList<QSharedPointer<File> >());\r\n        }\r\n\r\n        dependencies_.append(copy);\r\n    }\r\n\r\n    endResetModel();\r\n\r\n    emit dependenciesReset();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileDependencyModel::performAnalysisStep()\r\n//-----------------------------------------------------------------------------\r\nvoid FileDependencyModel::performAnalysisStep()\r\n{\r\n    // Safe-check whether the analysis has already ended.\r\n    if (progressValue_ == getTotalStepCount())\r\n    {\r\n        return;\r\n    }\r\n\r\n    // On first step begin analysis for each resolved plugin.\r\n    if (progressValue_ == 0)\r\n    {\r\n        resolvePlugins();\r\n\r\n        // remove old dependencies, except manual ones\r\n        for (auto const& dep : dependencies_)\r\n        {\r\n            if (!dep->isManual())\r\n            {\r\n                removeDependency(dep.data());\r\n            }\r\n        }\r\n\r\n        // Begin analysis for each plugin.\r\n        for (ISourceAnalyzerPlugin* plugin : usedPlugins_)\r\n        {\r\n            plugin->beginAnalysis(component_.data(), basePath_);\r\n        }\r\n\r\n        progressValue_++;\r\n    }\r\n    // Otherwise scan one file on each step.\r\n    else\r\n    {\r\n        // Don't scan external files\r\n        if (root_->getChild(curFolderIndex_)->getType() != FileDependencyItem::ITEM_TYPE_FOLDER)\r\n        {\r\n            curFolderIndex_++;\r\n        }\r\n        else\r\n        {\r\n            // Run the dependency analysis for the current file.\r\n            if (curFileIndex_ < root_->getChild(curFolderIndex_)->getChildCount())\r\n            {\r\n                FileDependencyItem* fileItem = root_->getChild(curFolderIndex_)->getChild(curFileIndex_);\r\n                analyze(fileItem);\r\n\r\n                curFileIndex_++;\r\n                progressValue_++;\r\n            }\r\n\r\n            // Check if all files in the current folder have been analyzed.\r\n            while (curFileIndex_ == root_->getChild(curFolderIndex_)->getChildCount())\r\n            {\r\n                // Update the status of the folder and continue to the next folder.\r\n                FileDependencyItem* folderItem = root_->getChild(curFolderIndex_);\r\n\r\n                emit dataChanged(getItemIndex(folderItem, 0), getItemIndex(folderItem,\r\n                    FileDependencyColumns::DEPENDENCIES));\r\n\r\n                curFolderIndex_++;\r\n                curFileIndex_ = 0;\r\n\r\n                if (curFolderIndex_ == root_->getChildCount() ||\r\n                    root_->getChild(curFolderIndex_)->getType() != FileDependencyItem::ITEM_TYPE_FOLDER)\r\n                {\r\n                    break;\r\n                }\r\n            }\r\n        }\r\n    }\r\n\r\n    // Stop the timer when there are no more folders.\r\n    if (progressValue_ == getTotalStepCount())\r\n    {\r\n        stopAnalysis();\r\n    }\r\n    else\r\n    {\r\n        // Otherwise notify progress of the next file.\r\n        emit analysisProgressChanged(progressValue_ + 1);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileDependencyModel::getTotalFileCount()\r\n//-----------------------------------------------------------------------------\r\nint FileDependencyModel::getTotalStepCount() const\r\n{\r\n    int count = 1;\r\n\r\n    for (int i = 0; i < root_->getChildCount(); ++i)\r\n    {\r\n        if (auto childDependencyItem = root_->getChild(i);\r\n            childDependencyItem->getType() == FileDependencyItem::ITEM_TYPE_FOLDER)\r\n        {\r\n            count += childDependencyItem->getChildCount();\r\n        }\r\n    }\r\n\r\n    return count;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileDependencyModel::getItemIndex()\r\n//-----------------------------------------------------------------------------\r\nQModelIndex FileDependencyModel::getItemIndex(FileDependencyItem* item, int column) const\r\n{\r\n    if (item == nullptr)\r\n    {\r\n        return QModelIndex();\r\n    }\r\n\r\n    FileDependencyItem* parent = item->getParent();\r\n\r\n    if (parent == nullptr)\r\n    {\r\n        return QModelIndex();\r\n    }\r\n\r\n    return createIndex(item->getIndex(), column, item);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileDependencyModel::resolvePlugins()\r\n//-----------------------------------------------------------------------------\r\nvoid FileDependencyModel::resolvePlugins()\r\n{\r\n    analyzerPluginMap_.clear();\r\n    usedPlugins_.clear();\r\n\r\n    for (IPlugin* plugin : PluginManager::getInstance().getActivePlugins())\r\n    {\r\n        ISourceAnalyzerPlugin* analyzer = dynamic_cast<ISourceAnalyzerPlugin*>(plugin);\r\n        if (analyzer != 0)\r\n        {\r\n            for (QString const& fileType : analyzer->getSupportedFileTypes())\r\n            {\r\n                if (analyzerPluginMap_.contains(fileType) == false)\r\n                {\r\n                    analyzerPluginMap_.insert(fileType, analyzer);\r\n                }\r\n            }\r\n\r\n            usedPlugins_.append(analyzer);\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileDependencyModel::analyze()\r\n//-----------------------------------------------------------------------------\r\nvoid FileDependencyModel::analyze(FileDependencyItem* fileItem)\r\n{\r\n    Q_ASSERT(fileItem != 0);\r\n\r\n    // Retrieve the corresponding plugin based on the file type.\r\n    ISourceAnalyzerPlugin* plugin = 0;\r\n    \r\n    for (QString const& fileType : fileItem->getFileTypes())\r\n    {\r\n        plugin = analyzerPluginMap_.value(fileType);\r\n        if (plugin != 0)\r\n        {\r\n            break;\r\n        }\r\n    }\r\n\r\n    // Check the file for modifications by calculating its hash and comparing to the saved value.\r\n    QString absPath = General::getAbsolutePath(basePath_, FileHandler::resolvePath(fileItem->getPath()));\r\n    bool dependenciesChanged = false;\r\n\r\n    // If a corresponding plugin was found, let it calculate the hash.\r\n    if (plugin != nullptr)\r\n    {\r\n        QList<FileDependency*> oldDependencies = findDependencies(fileItem->getPath());\r\n\r\n        // Scan the current dependencies.\r\n        QList<FileDependencyDesc> analyzedDependencies = plugin->getFileDependencies(component_.data(), \r\n            basePath_, absPath);\r\n\r\n        QString file1 = fileItem->getPath();\r\n\r\n        // Go through all current dependencies.\r\n        for (FileDependencyDesc const& desc : analyzedDependencies)\r\n        {\r\n            QString file2 = General::getRelativePath(basePath_,\r\n                QFileInfo(QFileInfo(absPath).path() + \"/\" + desc.filename).canonicalFilePath());\r\n\r\n            FileDependencyItem* fileItem2 = findFileItem(file2);\r\n                \r\n            // Check if the second file was an external (not found).\r\n            if (fileItem2 == nullptr)\r\n            {\r\n                file2 = desc.filename;\r\n                fileItem2 = findExternalFileItem(file2);\r\n            }\r\n\r\n            // Check if the dependency already exists.\r\n            FileDependency* found = findDependency(oldDependencies, file1, file2);\r\n\r\n            if (found == nullptr)\r\n            {\r\n                // Create the item for external file if not found.\r\n                if (fileItem2 == nullptr)\r\n                {\r\n                    FileDependencyItem* folderItem = findFolderItem(\"$External$\");\r\n                    if (folderItem == nullptr)\r\n                    {\r\n                        beginInsertRows(getItemIndex(root_, 0), root_->getChildCount(), root_->getChildCount());\r\n                        folderItem = root_->addFolder(component_, \"$External$\");\r\n                        endInsertRows();\r\n                    }\r\n\r\n                    file2 = \"$External$/\" + desc.filename;\r\n\r\n                    beginInsertRows(getItemIndex(folderItem, 0), folderItem->getChildCount(),\r\n                        folderItem->getChildCount());\r\n                    folderItem->addFile(component_, file2, QList<QSharedPointer<File> >());\r\n                    endInsertRows();\r\n                }\r\n\r\n                // Create a new dependency if not found.\r\n                QSharedPointer<FileDependency> dependency(new FileDependency());\r\n                dependency->setFile1(file1);\r\n                dependency->setFile2(file2);\r\n                dependency->setDescription(desc.description);\r\n                dependency->setStatus(FileDependency::STATUS_ADDED);\r\n\r\n                addDependency(dependency);\r\n            }\r\n            else\r\n            {\r\n                // Remove the dependency from the temporary list.\r\n                oldDependencies.removeOne(found);\r\n\r\n                // Check if the existing dependency needs updating to a bidirectional one.\r\n                if (found->isBidirectional() == false && found->getFile1() != file1)\r\n                {\r\n                    found->setBidirectional(true);\r\n\r\n                    // Combine the descriptions.\r\n                    found->setDescription(found->getDescription() + \"\\n\" + desc.description);\r\n                    emit dependencyChanged(found);\r\n                }\r\n            }\r\n        }\r\n    }\r\n\r\n    emit dataChanged(getItemIndex(fileItem, FileDependencyColumns::STATUS),\r\n                     getItemIndex(fileItem, FileDependencyColumns::STATUS));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileDependencyModel::calculateMd5forFile()\r\n//-----------------------------------------------------------------------------\r\nQString FileDependencyModel::calculateMd5forFile(QString const& absPath) const\r\n{\r\n    QFile file(absPath);\r\n    QCryptographicHash cryptoHash(QCryptographicHash::Md5);\r\n\r\n    if (file.open(QIODevice::ReadOnly))\r\n    {\r\n        int const MAX_BYTES_PER_READ = 1024 * 256;\r\n        char readBuffer[MAX_BYTES_PER_READ];\r\n        int bytesRead = 0;\r\n\r\n        do \r\n        {\r\n            bytesRead = file.read(readBuffer, MAX_BYTES_PER_READ);\r\n            cryptoHash.addData(readBuffer, bytesRead);\r\n        }\r\n        while (bytesRead == MAX_BYTES_PER_READ);\r\n    }\r\n\r\n    file.close();\r\n\r\n    return cryptoHash.result().toHex();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileDependencyModel::findItem()\r\n//-----------------------------------------------------------------------------\r\nFileDependencyItem* FileDependencyModel::findFileItem(QString const& path)\r\n{\r\n    // Extract the folder part of the path.\r\n    QFileInfo info(path);\r\n    QString folderPath = FileHandler::resolvePath(info.path());\r\n\r\n    // External folders need a special treatment.\r\n    if (path.startsWith(\"$External\"))\r\n    {\r\n        folderPath = path.left(path.indexOf('$', 1) + 1);\r\n    }\r\n\r\n    // Search for a matching folder.\r\n    for (int i = 0; i < root_->getChildCount(); ++i)\r\n    {\r\n        FileDependencyItem* folderItem = root_->getChild(i);\r\n\r\n        if (folderItem->getPath() == folderPath)\r\n        {\r\n            for (int j = 0; j < folderItem->getChildCount(); ++j)\r\n            {\r\n                FileDependencyItem* fileItem = folderItem->getChild(j);\r\n\r\n                if (fileItem->getPath() == path)\r\n                {\r\n                    return fileItem;\r\n                }\r\n            }\r\n        }\r\n    }\r\n\r\n    return nullptr;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileDependencyModel::findExternalFileItem()\r\n//-----------------------------------------------------------------------------\r\nFileDependencyItem* FileDependencyModel::findExternalFileItem(QString& path)\r\n{\r\n    // Search for the file from all external locations.\r\n    for (int i = 0; i < root_->getChildCount(); ++i)\r\n    {\r\n        FileDependencyItem* folderItem = root_->getChild(i);\r\n\r\n        if (folderItem->isExternal())\r\n        {\r\n            for (int j = 0; j < folderItem->getChildCount(); ++j)\r\n            {\r\n                FileDependencyItem* fileItem = folderItem->getChild(j);\r\n\r\n                // Check if the file's path ends with the path we're searching for.\r\n                if (fileItem->getPath().endsWith(path))\r\n                {\r\n                    // TODO: Verify that it is fully correct?\r\n                    path = fileItem->getPath();                   \r\n                    return fileItem;\r\n                }\r\n            }\r\n        }\r\n    }\r\n\r\n    return nullptr;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileDependencyModel::findFolderItem()\r\n//-----------------------------------------------------------------------------\r\nFileDependencyItem* FileDependencyModel::findFolderItem(QString const& path)\r\n{\r\n    // Search for a matching folder.\r\n    for (int i = 0; i < root_->getChildCount(); ++i)\r\n    {\r\n        if (root_->getChild(i)->getPath() == path)\r\n        {\r\n            return root_->getChild(i);\r\n        }\r\n    }\r\n\r\n    return nullptr;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileDependencyModel::findDependency()\r\n//-----------------------------------------------------------------------------\r\nFileDependency* FileDependencyModel::findDependency(QList<FileDependency*> const& dependencies,\r\n                                                    QString const& file1, QString const& file2) const\r\n{\r\n    for (FileDependency* dependency : dependencies)\r\n    {\r\n        if ((dependency->getFile1() == file1 && dependency->getFile2() == file2) ||\r\n            (dependency->getFile1() == file2 && dependency->getFile2() == file1))\r\n        {\r\n            return dependency;\r\n        }\r\n    }\r\n\r\n    return nullptr;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileDependencyModel::findDependency()\r\n//-----------------------------------------------------------------------------\r\nFileDependency* FileDependencyModel::findDependency(QString const& file1, QString const& file2) const\r\n{\r\n    for (QSharedPointer<FileDependency> dependency : dependencies_)\r\n    {\r\n        if ((dependency->getFile1() == file1 && dependency->getFile2() == file2) ||\r\n            (dependency->isBidirectional() && dependency->getFile1() == file2 && dependency->getFile2() == file1))\r\n        {\r\n            return dependency.data();\r\n        }\r\n    }\r\n\r\n    return nullptr;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileDependencyModel::addDependency()\r\n//-----------------------------------------------------------------------------\r\nvoid FileDependencyModel::addDependency(QSharedPointer<FileDependency> dependency, bool byUser /*= false*/)\r\n{\r\n    dependencies_.append(dependency);\r\n    component_->setFileDependendencies(dependencies_);\r\n\r\n    if (byUser)\r\n    {\r\n        emit dependencyAdded(dependency.data(), true);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileDependencyModel::removeDependency()\r\n//-----------------------------------------------------------------------------\r\nvoid FileDependencyModel::removeDependency(FileDependency* dependency)\r\n{\r\n    for (QSharedPointer<FileDependency> dep : dependencies_)\r\n    {\r\n        if (dep == dependency)\r\n        {\r\n            emit dependencyRemoved(dependency);\r\n            dependencies_.removeOne(dep);\r\n            component_->setFileDependendencies(dependencies_);\r\n            return;\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileDependencyModel::getDependencies()\r\n//-----------------------------------------------------------------------------\r\nQList< QSharedPointer<FileDependency> > FileDependencyModel::getDependencies() const\r\n{\r\n    return dependencies_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileDependencyModel::findDependencies()\r\n//-----------------------------------------------------------------------------\r\nQList<FileDependency*> FileDependencyModel::findDependencies(QString const& file) const\r\n{\r\n    QList<FileDependency*> dependencies;\r\n\r\n    for (QSharedPointer<FileDependency> dep : dependencies_)\r\n    {\r\n        if (dep->getFile1() == file || dep->getFile2() == file)\r\n        {\r\n            dependencies.append(dep.data());\r\n        }\r\n    }\r\n\r\n    return dependencies;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileDependencyModel::defineLocation()\r\n//-----------------------------------------------------------------------------\r\nvoid FileDependencyModel::defineLocation(FileDependencyItem* item, QString const& path)\r\n{\r\n    // Only the location of externals files can be changed.\r\n    if (item->isExternal() == false || item->getType() != FileDependencyItem::ITEM_TYPE_FILE)\r\n    {\r\n        return;\r\n    }\r\n\r\n    // Search for a matching external folder.\r\n    QString fullPath = \"$\" + path + \"$\";\r\n    FileDependencyItem* parent = findFolderItem(fullPath);\r\n\r\n    // Check if a new external folder needs to be created.\r\n    if (parent == nullptr)\r\n    {\r\n        int index = root_->getChildCount() - 1;\r\n\r\n        beginInsertRows(getItemIndex(root_, 0), index, index);\r\n        parent = root_->addFolder(component_, fullPath);\r\n        endInsertRows();\r\n    }\r\n\r\n    moveItem(item, parent);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileDependencyModel::resetLocation()\r\n//-----------------------------------------------------------------------------\r\nvoid FileDependencyModel::resetLocation(FileDependencyItem* item)\r\n{\r\n    // Only the location of externals files can be changed.\r\n    if (item->isExternal() == false || item->getType() != FileDependencyItem::ITEM_TYPE_FILE)\r\n    {\r\n        return;\r\n    }\r\n\r\n    if (item->getParent()->getType() == FileDependencyItem::ITEM_TYPE_EXTERNAL_LOCATION)\r\n    {\r\n        moveItem(item, root_->getChild(root_->getChildCount() - 1));\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileDependencyModel::moveItem()\r\n//-----------------------------------------------------------------------------\r\nvoid FileDependencyModel::moveItem(FileDependencyItem* item, FileDependencyItem* parent)\r\n{\r\n    FileDependencyItem* oldParent = item->getParent();\r\n    QString oldPath = item->getPath();\r\n\r\n    // Move the item into its new parent.\r\n    beginRemoveRows(getItemIndex(oldParent, 0), item->getIndex(), item->getIndex());\r\n    oldParent->removeItem(item);\r\n    endRemoveRows();\r\n\r\n    beginInsertColumns(getItemIndex(parent, 0), parent->getChildCount(), parent->getChildCount());\r\n    parent->insertItem(item);\r\n    endInsertRows();\r\n\r\n    // Remove the old parent if it got empty and is an external location.\r\n    if (oldParent->getChildCount() == 0 &&\r\n        oldParent->getType() == FileDependencyItem::ITEM_TYPE_EXTERNAL_LOCATION)\r\n    {\r\n        beginRemoveRows(getItemIndex(root_, 0), oldParent->getIndex(), oldParent->getIndex());\r\n        root_->removeItem(oldParent);\r\n        delete oldParent;\r\n        endRemoveRows();\r\n    }\r\n\r\n    onExternalRelocated(item, oldPath);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileDependencyModel::onFileRelocated()\r\n//-----------------------------------------------------------------------------\r\nvoid FileDependencyModel::onExternalRelocated(FileDependencyItem* item, QString const& oldPath)\r\n{\r\n    for (QSharedPointer<FileDependency> dependency : dependencies_)\r\n    {\r\n        if (dependency->getFile2() == oldPath)\r\n        {\r\n            dependency->setFile2(item->getPath());\r\n        }\r\n    }\r\n\r\n    component_->setFileDependendencies(dependencies_);\r\n    emit dependenciesReset();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileDependencyModel::refresh()\r\n//-----------------------------------------------------------------------------\r\nvoid FileDependencyModel::refresh()\r\n{\r\n    for (int i = 0; i < root_->getChildCount(); ++i)\r\n    {\r\n        FileDependencyItem* folderItem = root_->getChild(i);\r\n\r\n        if (folderItem->getType() == FileDependencyItem::ITEM_TYPE_FOLDER)\r\n        {\r\n            for (int j = 0; j < folderItem->getChildCount(); ++j)\r\n            {\r\n                folderItem->getChild(j)->refreshFileRefs();\r\n            }\r\n        }\r\n    }\r\n\r\n    emit dataChanged(getItemIndex(root_->getChild(0), 0),\r\n        getItemIndex(root_->getChild(root_->getChildCount() - 1), FileDependencyColumns::DEPENDENCIES));\r\n}\r\n"
  },
  {
    "path": "editors/ComponentEditor/fileSet/dependencyAnalysis/FileDependencyModel.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: FileDependencyModel.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Joni-Matti Maatta\r\n// Date: 19.01.2013\r\n//\r\n// Description:\r\n// The data model for the file dependencies.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef FILEDEPENDENCYMODEL_H\r\n#define FILEDEPENDENCYMODEL_H\r\n\r\n#include <QAbstractItemModel>\r\n#include <QTimer>\r\n#include <QMap>\r\n#include <QSharedPointer>\r\n\r\nclass FileDependencyItem;\r\nclass FileDependency;\r\nclass ISourceAnalyzerPlugin;\r\nclass Component;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! The data model for the file dependencies.\r\n//-----------------------------------------------------------------------------\r\nclass FileDependencyModel : public QAbstractItemModel\r\n{\r\n    Q_OBJECT\r\n\r\npublic:\r\n    /*!\r\n     *  Constructor.\r\n     *\r\n     *    @param [in] component  The component to which this model is made.\r\n     *    @param [in] basePath   The component's base path.\r\n     */\r\n    FileDependencyModel(QSharedPointer<Component> component,\r\n                        QString const& basePath);\r\n\r\n    /*!\r\n     *  Destructor.\r\n     */\r\n    ~FileDependencyModel();\r\n\r\n    /*!\r\n     *  Refreshes the model so that modifications from outside are made visible.\r\n     */\r\n    void refresh();\r\n\r\n    /*!\r\n     *  Adds a new dependency to the model.\r\n     *\r\n     *    @param [in] dependency The file dependency to add.\r\n     *    @param [in] byUser     Indicates if dependency was manually added by user.\r\n     */\r\n    void addDependency(QSharedPointer<FileDependency> dependency, bool byUser = false);\r\n\r\n    /*!\r\n     *  Removes a dependency from the model.\r\n     *\r\n     *    @param [in] dependency The file dependency to remove.\r\n     */\r\n    void removeDependency(FileDependency* dependency);\r\n\r\n    /*!\r\n     *  Defines the location for the given item.\r\n     *\r\n     *    @param [in] item  The item whose location to define.\r\n     *    @param [in] path  The path where the file resides.\r\n     */\r\n    void defineLocation(FileDependencyItem* item, QString const& path);\r\n\r\n    /*!\r\n     *  Resets the location of the given item.\r\n     *\r\n     *    @param [in] item  The item whose location to reset.\r\n     */\r\n    void resetLocation(FileDependencyItem* item);\r\n\r\n    /*!\r\n     *  Searches for a file item with the given path.\r\n     *\r\n     *    @param [in] path The path.\r\n     *\r\n     *    @return The corresponding item of null if not found in the model.\r\n     */\r\n    FileDependencyItem* findFileItem(QString const& path);\r\n\r\n    /*!\r\n     *  Searches for an external file item with the given path.\r\n     *\r\n     *    @param [in,out] path The base path as an input. The found path if the item was found.\r\n     *\r\n     *    @return The corresponding item of null if not found in the model.\r\n     */\r\n    FileDependencyItem* findExternalFileItem(QString& path);\r\n\r\n    /*!\r\n     *  Searches for a folder item with the given path.\r\n     *\r\n     *    @param [in] path The path.\r\n     *\r\n     *    @return The corresponding item of null if not found in the model.\r\n     */\r\n    FileDependencyItem* findFolderItem(QString const& path);\r\n\r\n    /*!\r\n     *  Searches for a dependency between the given files.\r\n     *\r\n     *    @param [in] file1 The first file.\r\n     *    @param [in] file2 The second file.\r\n     */\r\n    FileDependency* findDependency(QString const& file1, QString const& file2) const;\r\n\r\n    /*!\r\n     *  Returns the model index of the given file dependency item.\r\n     *\r\n     *    @param [in] item The file dependency item.\r\n     */\r\n    QModelIndex getItemIndex(FileDependencyItem* item, int column) const;\r\n\r\n    /*!\r\n     *  Begins reset.\r\n     */\r\n    void beginReset();\r\n\r\n    /*!\r\n     *  Ends reset.\r\n     */\r\n    void endReset();\r\n\r\n    /*!\r\n     *  Starts the dependency analysis.\r\n     */\r\n    void startAnalysis();\r\n\r\n    /*!\r\n     *  Stops the dependency analysis.\r\n     */\r\n    void stopAnalysis();\r\n\r\n    /*!\r\n     *  Adds a new folder item to the model.\r\n     *\r\n     *    @param [in] path The folder path.\r\n     */\r\n    FileDependencyItem* addFolder(QString const& path);\r\n\r\n    /*!\r\n     *  Return header data for the given header column.\r\n     *\r\n     *    @param [in] section      The index of the header column.\r\n\t *    @param [in] orientation  The orientation of the header, only Qt::Horizontal supported.\r\n     *    @param [in] role         The role of the data.\r\n     *\r\n     *    @return QVariant containing the data.\r\n    */\r\n    virtual QVariant headerData(int section, Qt::Orientation orientation,\r\n    \t\t                    int role = Qt::DisplayRole) const;\r\n\r\n    /*!\r\n     *  Returns the number of columns in this model.\r\n     *\r\n     *    @param [in] parent Model index identifying the item whose column count is requested.\r\n     *\r\n     *    @return The number of columns.\r\n     */\r\n    virtual int columnCount(const QModelIndex & parent = QModelIndex() ) const;\r\n\r\n    /*! \r\n     *  Returns the number of rows an item has.\r\n     *\r\n     *    @param [in] parent Model index identifying the item whose row count is wanted.\r\n     *\r\n     *    @return The number of rows the item has.\r\n    */\r\n    virtual int rowCount(const QModelIndex &parent = QModelIndex()) const;\r\n\r\n    /*! \\brief Get the model index of the specified object.\r\n     *\r\n     * \\param row Row number of the object.\r\n     * \\param column Column number of the object.\r\n     * \\param parent Model index of the parent of the object.\r\n     *\r\n     * \\return QModelIndex that identifies the object.\r\n    */\r\n    virtual QModelIndex index(int row, int column,\r\n    \t\tconst QModelIndex &parent = QModelIndex()) const;\r\n\r\n    /*! \\brief Get the model index of the parent of the object\r\n     *\r\n     * \\param child Model index that identifies the child of the object.\r\n     *\r\n     * \\return QModelIndex that identifies the parent of the given object.\r\n    */\r\n    virtual QModelIndex parent(const QModelIndex &child) const;\r\n\r\n    /*! \\brief Get the data associated with given object.\r\n     *\r\n     * \\param index Model index that identifies the object that's data is wanted.\r\n     * \\param role Specifies the type of data wanted.\r\n     *\r\n     * \\return QVariant Containing the requested data.\r\n    */\r\n    virtual QVariant data(QModelIndex const& index,\r\n    \t\t              int role = Qt::DisplayRole) const;\r\n\r\n    virtual bool setData(const QModelIndex &index, const QVariant &value, int role /* = Qt::EditRole */);\r\n\r\n    /*! \\brief Does the specified item have child items or not.\r\n     *\r\n     * \\param parent Model index identifying the object that's children are asked.\r\n     *\r\n     * \\return True if object has child objects.\r\n    */\r\n    virtual bool hasChildren(QModelIndex const& parent = QModelIndex()) const;\r\n\r\n    /*! \\brief Get the flags that identify possible methods for given object.\r\n     *\r\n     * \\param index Model index identifying the object that's flags are requested.\r\n     *\r\n     * \\return Qt::ItemFlags that specify how the object can be handled.\r\n    */\r\n    Qt::ItemFlags flags(QModelIndex const& index) const;\r\n\r\n    /*!\r\n     *  Returns the number of files in the model.\r\n     */\r\n    int getTotalStepCount() const;\r\n\r\n    /*!\r\n     *  Returns the list of dependencies.\r\n     */\r\n    QList< QSharedPointer<FileDependency> > getDependencies() const;\r\n\r\n\r\nsignals:\r\n    /*!\r\n     *  Emitted when the analysis progress has changed.\r\n     */\r\n    void analysisProgressChanged(int value);\r\n\r\n    /*!\r\n     *  Emitted when a file dependency has been added to the model.\r\n     */\r\n    void dependencyAdded(FileDependency* dependency, bool shouldNotify);\r\n\r\n    /*!\r\n     *  Emitted when a file dependency has been removed from the model.\r\n     */\r\n    void dependencyRemoved(FileDependency* dependency);\r\n\r\n    /*!\r\n     *  Emitted when a file dependency has changed.\r\n     */\r\n    void dependencyChanged(FileDependency* dependency);\r\n\r\n    /*!\r\n     *  Emitted when the dependencies have been reset.\r\n     */\r\n    void dependenciesReset();\r\n\r\n    /*!\r\n     *  Emitted when the contents have changed.\r\n     */\r\n    void contentChanged();\r\n\r\n    /*!\r\n     *  Emitted when the dependencies have changed.\r\n     */\r\n    void dependenciesChanged();\r\n\r\nprivate slots:\r\n    /*!\r\n     *  Performs one step of the dependency analysis.\r\n     */\r\n    void performAnalysisStep();\r\n\r\nprivate:\r\n    // Disable copying.\r\n    FileDependencyModel(FileDependencyModel const& rhs);\r\n    FileDependencyModel& operator=(FileDependencyModel const& rhs);\r\n\r\n    /*!\r\n     *  Resolves plugins for each file type.\r\n     */\r\n    void resolvePlugins();\r\n\r\n    /*!\r\n     *  Analyzes the given file item.\r\n     *\r\n     *    @param [in] fileItem The file item to analyze.\r\n     */\r\n    void analyze(FileDependencyItem* fileItem);\r\n\r\n    /*!\r\n     *  Calculates an Md5 sum for a given file. Changes in Md5 indicate change in file content.\r\n     *\r\n     *    @param [in] absPath   Absolute path to the file to calculate Md5 for.\r\n     *\r\n     *    @return The calculated Md5 sum.\r\n     */\r\n    QString calculateMd5forFile(QString const& absPath) const;\r\n\r\n    /*!\r\n     *  Searches for a dependency between the given files in the given container.\r\n     *\r\n     *    @param [in] dependencies  The list of dependencies.\r\n     *    @param [in] file1         File path of the first file.\r\n     *    @param [in] file2         File path of the second file.\r\n     */\r\n    FileDependency* findDependency(QList<FileDependency*> const& dependencies,\r\n                                   QString const& file1, QString const& file2) const;\r\n\r\n    /*!\r\n     *  Searches for all dependencies that reference the given file.\r\n     *\r\n     *    @param [in]  file          File path of the file.\r\n     *    @param [out] dependencies  The found dependencies.\r\n     */\r\n    QList<FileDependency*> findDependencies(QString const& file) const;\r\n\r\n    /*!\r\n     *  Moves the item to the new parent.\r\n     *\r\n     *    @param [in] item    The item to move.\r\n     *    @param [in] parent  The new parent for the item.\r\n     */\r\n    void moveItem(FileDependencyItem* item, FileDependencyItem* parent);\r\n\r\n    /*!\r\n     *  Updates dependencies due to file relocation.\r\n     */\r\n    void onExternalRelocated(FileDependencyItem* item, QString const& oldPath);\r\n    \r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! The parent component.\r\n    QSharedPointer<Component> component_;\r\n\r\n    //! The component's base path.\r\n    QString basePath_;\r\n\r\n    //! The dependency tree root.\r\n    FileDependencyItem* root_;\r\n\r\n    //! The externals item (for fast access).\r\n    FileDependencyItem* unspecifiedLocation_;\r\n\r\n    //! The timer for running the analysis.\r\n    QTimer* timer_;\r\n\r\n    //! The current folder scan index.\r\n    int curFolderIndex_;\r\n\r\n    //! The current file scan index.\r\n    int curFileIndex_;\r\n\r\n    //! The current analysis progress.\r\n    int progressValue_;\r\n\r\n    //! The list of used plugins on the current run.\r\n    QList<ISourceAnalyzerPlugin*> usedPlugins_;\r\n\r\n    //! Analyzer plugin map for fast access to correct plugin for each file type.\r\n    QMap<QString, ISourceAnalyzerPlugin*> analyzerPluginMap_;\r\n\r\n    //! Dependency list.\r\n    QList< QSharedPointer<FileDependency> > dependencies_;\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n\r\n#endif // FILEDEPENDENCYMODEL_H\r\n"
  },
  {
    "path": "editors/ComponentEditor/fileSet/dependencyAnalysis/FileDependencySortFilter.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: FileDependencySortFilter.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Joni-Matti Maatta\r\n// Date: 22.03.2013\r\n//\r\n// Description:\r\n// Sort filter for the file dependency view.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"FileDependencySortFilter.h\"\r\n\r\n#include \"FileDependencyItem.h\"\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileDependencySortFilter::FileDependencySortFilter()\r\n//-----------------------------------------------------------------------------\r\nFileDependencySortFilter::FileDependencySortFilter(QObject* parent)\r\n    : QSortFilterProxyModel(parent),\r\n      filters_(FileDependencyGraphView::FILTER_DEFAULT)\r\n{\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileDependencySortFilter::~FileDependencySortFilter()\r\n//-----------------------------------------------------------------------------\r\nFileDependencySortFilter::~FileDependencySortFilter()\r\n{\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileDependencySortFilter::filterAcceptsRow()\r\n//-----------------------------------------------------------------------------\r\nbool FileDependencySortFilter::filterAcceptsRow(int sourceRow, QModelIndex const& sourceParent) const\r\n{\r\n    QModelIndex index = sourceModel()->index(sourceRow, 0, sourceParent);\r\n\r\n    // Root item is always ok.\r\n    if (!index.isValid())\r\n    {\r\n        return true;\r\n    }\r\n\r\n    FileDependencyItem* item = static_cast<FileDependencyItem*>(index.internalPointer());\r\n    Q_ASSERT(item != 0);\r\n\r\n    //FileDependencyItem::FileDependencyStatus status = item->getStatus();\r\n\r\n    //return (status == FileDependencyItem::FILE_DEPENDENCY_STATUS_UNKNOWN) ||\r\n    //    ((filters_ & FileDependencyGraphView::FILTER_GREEN) &&\r\n    //        status == FileDependencyItem::FILE_DEPENDENCY_STATUS_OK) ||\r\n    //    ((filters_ & FileDependencyGraphView::FILTER_YELLOW) && status ==\r\n    //        FileDependencyItem::FILE_DEPENDENCY_STATUS_CHANGED);\r\n\r\n    return true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileDependencySortFilter::setFilters()\r\n//-----------------------------------------------------------------------------\r\nvoid FileDependencySortFilter::setFilters(FileDependencyGraphView::DependencyFilters filters)\r\n{\r\n    filters_ = filters;\r\n    invalidateFilter();\r\n}\r\n"
  },
  {
    "path": "editors/ComponentEditor/fileSet/dependencyAnalysis/FileDependencySortFilter.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: FileDependencySortFilter.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Joni-Matti Maatta\r\n// Date: 22.03.2013\r\n//\r\n// Description:\r\n// Sort filter for the file dependency view.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef FILEDEPENDENCYSORTFILTER_H\r\n#define FILEDEPENDENCYSORTFILTER_H\r\n\r\n#include \"FileDependencyGraphView.h\"\r\n\r\n#include <QSortFilterProxyModel>\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Sort filter for the file dependency view.\r\n//-----------------------------------------------------------------------------\r\nclass FileDependencySortFilter : public QSortFilterProxyModel\r\n{\r\npublic:\r\n    /*!\r\n     *  Constructor.\r\n     */\r\n    FileDependencySortFilter(QObject* parent = 0);\r\n\r\n    /*!\r\n     *  Destructor.\r\n     */\r\n    ~FileDependencySortFilter();\r\n\r\n    /*!\r\n     *  Sets the filters.\r\n     */\r\n    void setFilters(FileDependencyGraphView::DependencyFilters filters);\r\n    \r\nprotected:\r\n    virtual bool filterAcceptsRow(int sourceRow, QModelIndex const& sourceParent) const;\r\n\r\nprivate:\r\n    // Disable copying.\r\n    FileDependencySortFilter(FileDependencySortFilter const& rhs);\r\n    FileDependencySortFilter& operator=(FileDependencySortFilter const& rhs);\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! The dependency graph filters.\r\n    FileDependencyGraphView::DependencyFilters filters_;\r\n};\r\n\r\n#endif // FILEDEPENDENCYSORTFILTER_H\r\n"
  },
  {
    "path": "editors/ComponentEditor/fileSet/dependencyAnalysis/FileDependencySourceEditor.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: FileDependencySourceEditor.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Joni-Matti Maatta\r\n// Date: 06.06.2013\r\n//\r\n// Description:\r\n// Editor for changing source directories.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"FileDependencySourceEditor.h\"\r\n\r\n#include <common/views/EditableListView/editablelistview.h>\r\n\r\n#include <IPXACTmodels/generaldeclarations.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileDependencySourceEditor::FileDependencySourceEditor()\r\n//-----------------------------------------------------------------------------\r\nFileDependencySourceEditor::FileDependencySourceEditor(QString const& basePath, QStringList const& sourceDirs,\r\n                                                       QWidget* parent):\r\nDirListManager(tr(\"File set source directories\"), basePath, parent),\r\n    basePath_(basePath)\r\n{   \r\n    if (basePath_.endsWith(QLatin1Char('/')) == false)\r\n    {\r\n        basePath_.append(QLatin1Char('/'));\r\n    }\r\n\r\n    initialize(sourceDirs);\r\n}\r\n    \r\n//-----------------------------------------------------------------------------\r\n// Function: FileDependencySourceEditor::~FileDependencySourceEditor()\r\n//-----------------------------------------------------------------------------\r\nFileDependencySourceEditor::~FileDependencySourceEditor()\r\n{\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileDependencySourceEditor::getSourceDirectories()\r\n//-----------------------------------------------------------------------------\r\nQStringList FileDependencySourceEditor::getSourceDirectories() const\r\n{\r\n    QStringList directories = items();\r\n    directories.removeAll(QString());\r\n\r\n    return directories;   \r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileDependencySourceEditor::initialize()\r\n//-----------------------------------------------------------------------------\r\nvoid FileDependencySourceEditor::initialize(QStringList const& items)\r\n{\r\n    DirListManager::initialize(items);\r\n\r\n    disconnect(view_, SIGNAL(addItem(QModelIndex const&)), model_, SLOT(addItem(QModelIndex const&)));\r\n    connect(view_, SIGNAL(addItem(QModelIndex const&)), this, SLOT(addSource()), Qt::UniqueConnection);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileDependencySourceEditor::addSource()\r\n//-----------------------------------------------------------------------------\r\nvoid FileDependencySourceEditor::addSource()\r\n{\r\n    QString newDirectory = QFileDialog::getExistingDirectory(this, tr(\"Choose Source Directory\"), basePath_);\r\n\r\n    if (newDirectory.isEmpty())\r\n    {\r\n        return;\r\n    }\r\n\r\n    newDirectory = QFileInfo(newDirectory).filePath();\r\n    newDirectory = General::getRelativePath(basePath_, newDirectory);\r\n\r\n    if (newDirectory.isEmpty())\r\n    {\r\n        newDirectory = QStringLiteral(\".\");\r\n    }\r\n\r\n    if (checkIfSelectedDirectoryHasBeenPreviouslyAdded(newDirectory) == false)\r\n    {\r\n        removeUnnecessaryDirectories(newDirectory);\r\n\r\n        QStringList newDirectories = items();\r\n        newDirectories.push_back(newDirectory);\r\n        setItems(newDirectories);\r\n        emit contentChanged();\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------------------\r\n// Function: FileDependencySourceEditor::checkIfSelectedDirectoryHasBeenPreviouslyAdded()\r\n//-----------------------------------------------------------------------------------------\r\nbool FileDependencySourceEditor::checkIfSelectedDirectoryHasBeenPreviouslyAdded(QString const& newDirectory)\r\n{\r\n    QStringList oldDirectoriesAbs = getAbsoluteDirectories();\r\n    oldDirectoriesAbs.removeAll(QString());\r\n\r\n    QString newDirAbs = QFileInfo(General::getAbsolutePath(basePath_, newDirectory)).canonicalFilePath();\r\n    \r\n    // Check if the selected directory is part of any existing directory.\r\n    for (int i = 0; i < oldDirectoriesAbs.count(); ++i)\r\n    {\r\n        if (newDirAbs.startsWith(oldDirectoriesAbs.at(i)))\r\n        {\r\n            return true;\r\n        }\r\n    }\r\n\r\n    return false;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileDependencySourceEditor::removeUnnecessaryDirectories()\r\n//-----------------------------------------------------------------------------\r\nvoid FileDependencySourceEditor::removeUnnecessaryDirectories(QString const& newDirectory)\r\n{ \r\n    QString newDirAbs = QFileInfo(General::getAbsolutePath(basePath_, newDirectory)).canonicalFilePath();\r\n    if (newDirAbs.isEmpty())\r\n    {\r\n        return;\r\n    }\r\n\r\n    // First change everything to absolute paths.\r\n    QStringList oldDirectoriesAbs =  getAbsoluteDirectories();\r\n\r\n    QStringList tempDirectoryList;\r\n\r\n    // Checking if unnecessary directories exist in the list.\r\n    for (int i = 0; i < oldDirectoriesAbs.count(); ++i)\r\n    {\r\n        if (oldDirectoriesAbs.at(i).startsWith(newDirAbs) == false)\r\n        {\r\n            tempDirectoryList.append(items().at(i));\r\n        }\r\n    }\r\n\r\n    // Update the source directory model.\r\n    setItems(tempDirectoryList);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileDependencySourceEditor::getAbsoluteDirectories()\r\n//-----------------------------------------------------------------------------\r\nQStringList FileDependencySourceEditor::getAbsoluteDirectories()\r\n{\r\n    QStringList directories;\r\n\r\n    foreach (QString const& directory, items())\r\n    {\r\n        QString absolutePath = General::getAbsolutePath(basePath_, directory);\r\n        directories.push_back(QFileInfo(absolutePath).canonicalFilePath());     \r\n    }\r\n\r\n    return directories;\r\n}\r\n"
  },
  {
    "path": "editors/ComponentEditor/fileSet/dependencyAnalysis/FileDependencySourceEditor.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: FileDependencySourceEditor.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Joni-Matti Maatta\r\n// Date: 06.06.2013\r\n//\r\n// Description:\r\n// Editor for changing source directories.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef FILEDEPENDENCYSOURCEEDITOR_H\r\n#define FILEDEPENDENCYSOURCEEDITOR_H\r\n\r\n#include <QDialog>\r\n#include <QStringList>\r\n#include <QDialogButtonBox>\r\n#include <QPushButton>\r\n#include <QGroupBox>\r\n#include <QVBoxLayout>\r\n#include <QHBoxLayout>\r\n#include <QStringListModel>\r\n#include <QFileDialog>\r\n\r\n#include <common/widgets/listManager/dirlistmanager.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Editor for changing source directories.\r\n//-----------------------------------------------------------------------------\r\nclass FileDependencySourceEditor : public DirListManager\r\n{\r\n    Q_OBJECT\r\npublic:\r\n    /*!\r\n     *  Constructor.\r\n     *\r\n     *    @param [in] xmlPath     The directory path where the parent component is located.\r\n     *                              Source directories are saved relative to this path.\r\n     *    @param [in] sourceDirs  The current list of source directories.\r\n     *    @param [in] parent      The parent widget.\r\n     */\r\n    FileDependencySourceEditor(QString const& basePath, QStringList const& sourceDirs, QWidget* parent = 0);\r\n\r\n    /*!\r\n     *  Destructor.\r\n     */\r\n    ~FileDependencySourceEditor();\r\n\r\n    /*!\r\n     *  Retrieves the new list of source directories.\r\n     *\r\n     *    @return The list of source directories.\r\n     */\r\n    QStringList getSourceDirectories() const;\r\n    \t\r\n    /*!\r\n     *  Initializes the editor.\r\n\t * \r\n\t *    @param [in] items   QStringList that contains the items to add to the widget.\r\n     *\r\n     *      @remark FileDependencySourceEditor calls initialize() in constructor.\r\n\t */\r\n    virtual void initialize(QStringList const& items = QStringList());\r\n\r\nprivate slots:\r\n\r\n    /*!\r\n     *  Adds a new source to the list.\r\n     */\r\n    void addSource();\r\n\r\nprivate:\r\n    // Disable copying.\r\n    FileDependencySourceEditor(FileDependencySourceEditor const& rhs);\r\n    FileDependencySourceEditor& operator=(FileDependencySourceEditor const& rhs);\r\n\r\n    // Help functions.\r\n    bool checkIfSelectedDirectoryHasBeenPreviouslyAdded(QString const& newDirectory);\r\n    \r\n    void removeUnnecessaryDirectories(QString const& newDirectory);\r\n\r\n    /*!\r\n     *  Returns the currently selected directories in absolute paths.\r\n     *\r\n     *    @return The absolute paths for the directories.\r\n     */\r\n    QStringList getAbsoluteDirectories();\r\n\r\n    //! Path to start search for relative paths.\r\n    QString basePath_;\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n\r\n#endif // FILEDEPENDENCYSOURCEEDITOR_H\r\n"
  },
  {
    "path": "editors/ComponentEditor/fileSet/file/FileColumns.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: FileColumns.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Mikko Teuho\r\n// Date: 16.10.2015\r\n//\r\n// Description:\r\n// Common declarations for editing files.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef FILECOLUMNS_H\r\n#define FILECOLUMNS_H\r\n\r\nnamespace FileColumns\r\n{\r\n    //! The editable columns in the files editor.\r\n    enum columns\r\n    {\r\n        NAME_COLUMN = 0,\r\n        PATH_COLUMN,\r\n        TYPES_COLUMN,\r\n        DESCRIPTION,\r\n        COLUMN_COUNT\r\n    };\r\n}\r\n\r\n#endif // FILECOLUMNS_H"
  },
  {
    "path": "editors/ComponentEditor/fileSet/file/filebuildcommand.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: filebuildcommand.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 7.2.2011\r\n//\r\n// Description:\r\n// FileBuildCommand is a group box for editing buildCommand of a file.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"filebuildcommand.h\"\r\n\r\n#include <editors/ComponentEditor/common/ExpressionEditor.h>\r\n#include <KactusAPI/include/ParameterFinder.h>\r\n#include <KactusAPI/include/ExpressionParser.h>\r\n#include <KactusAPI/include/ExpressionFormatter.h>\r\n#include <KactusAPI/include/FileInterface.h>\r\n#include <editors/ComponentEditor/parameters/ComponentParameterModel.h>\r\n\r\n#include <IPXACTmodels/generaldeclarations.h>\r\n#include <IPXACTmodels/Component/File.h>\r\n#include <IPXACTmodels/Component/BuildCommand.h>\r\n\r\n#include <QCompleter>\r\n#include <QFileDialog>\r\n#include <QGroupBox>\r\n#include <QHBoxLayout>\r\n#include <QLabel>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileBuildCommand::FileBuildCommand()\r\n//-----------------------------------------------------------------------------\r\nFileBuildCommand::FileBuildCommand(std::string fileName, FileInterface* fileInterface,\r\n    QString const& componentPath, QSharedPointer<ParameterFinder> parameterFinder,\r\n    QSharedPointer<ExpressionParser> expressionParser, QWidget *parent):\r\nQGroupBox(tr(\"Build command\"), parent),\r\nfileName_(fileName),\r\nfileInterface_(fileInterface),\r\ncomponentPath_(componentPath),\r\ntargetEditor_(this),\r\nbrowseTargetButton_(QIcon(\":icons/common/graphics/opened-folder.png\"), QString(), this),\r\ncommandEditor_(this),\r\nflagsEditor_(this),\r\nreplaceDefaultEditor_(new ExpressionEditor(parameterFinder, this)),\r\nexpressionParser_(expressionParser)\r\n{\r\n    setFlat(true);\r\n    browseTargetButton_.setFlat(true);\r\n\r\n    Q_ASSERT_X(\r\n        fileInterface_, \"FileBuildCommand constructor\", \"Null File interface-pointer given to the constructor\");\r\n\r\n    replaceDefaultEditor_->setFixedHeight(ExpressionEditor::DEFAULT_HEIGHT);\r\n\r\n    ComponentParameterModel* componentParametersModel = new ComponentParameterModel(parameterFinder, this);\r\n    componentParametersModel->setExpressionParser(expressionParser);\r\n\r\n    auto replaceCompleter = new QCompleter(this);\r\n    replaceCompleter->setModel(componentParametersModel);\r\n\r\n    replaceDefaultEditor_->setAppendingCompleter(replaceCompleter);\r\n\r\n    targetEditor_.setAcceptDrops(true);\r\n    \r\n    browseTargetButton_.setToolTip(tr(\"Browse...\"));\r\n\r\n    setupLayout();\r\n\r\n\trefresh();\r\n\r\n    connect(&targetEditor_, SIGNAL(editingFinished()), this, SLOT(onTargetChanged()), Qt::UniqueConnection);\r\n    connect(&browseTargetButton_, SIGNAL(clicked()), this, SLOT(onBrowseTarget()), Qt::UniqueConnection);\r\n    connect(&commandEditor_, SIGNAL(textEdited(QString const& )), \r\n        this, SLOT(onCommandChanged()), Qt::UniqueConnection);\r\n    connect(&flagsEditor_, SIGNAL(textEdited(QString const& )), this, SLOT(onFlagsChanged()), Qt::UniqueConnection);\r\n\r\n    connect(replaceDefaultEditor_, SIGNAL(editingFinished()),\r\n        this, SLOT(onReplaceDefaultChanged()), Qt::UniqueConnection);\r\n    connect(replaceDefaultEditor_, SIGNAL(editingFinished()), this, SIGNAL(contentChanged()), Qt::UniqueConnection);\r\n\r\n    connect(replaceDefaultEditor_, SIGNAL(increaseReference(QString)),\r\n        this, SIGNAL(increaseReferences(QString)), Qt::UniqueConnection);\r\n    connect(replaceDefaultEditor_, SIGNAL(decreaseReference(QString)),\r\n        this, SIGNAL(decreaseReferences(QString)), Qt::UniqueConnection);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileBuildCommand::refresh()\r\n//-----------------------------------------------------------------------------\r\nvoid FileBuildCommand::refresh()\r\n{   \r\n    commandEditor_.setText(QString::fromStdString(fileInterface_->getBuildCommandText(fileName_)));\r\n    flagsEditor_.setText(QString::fromStdString(fileInterface_->getBuildCommandFlags(fileName_)));\r\n\r\n    replaceDefaultEditor_->blockSignals(true);\r\n\r\n    replaceDefaultEditor_->setExpression(\r\n        QString::fromStdString(fileInterface_->getBuildCommandReplaceDefaultFlagsExpression(fileName_)));\r\n    replaceDefaultEditor_->setToolTip(\r\n        QString::fromStdString(fileInterface_->getBuildCommandReplaceDefaultFlagsValue(fileName_)));\r\n\r\n    replaceDefaultEditor_->blockSignals(false);\r\n\r\n    targetEditor_.setText(QString::fromStdString(fileInterface_->getBuildCommandTarget(fileName_)));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileBuildCommand::onCommandChanged()\r\n//-----------------------------------------------------------------------------\r\nvoid FileBuildCommand::onCommandChanged()\r\n{\r\n    fileInterface_->setBuildCommand(fileName_, commandEditor_.text().toStdString());\r\n\r\n\temit contentChanged();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileBuildCommand::onFlagsChanged()\r\n//-----------------------------------------------------------------------------\r\nvoid FileBuildCommand::onFlagsChanged()\r\n{\r\n    fileInterface_->setBuildCommandFlags(fileName_, flagsEditor_.text().toStdString());\r\n\r\n\temit contentChanged();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileBuildCommand::onTargetChanged()\r\n//-----------------------------------------------------------------------------\r\nvoid FileBuildCommand::onTargetChanged()\r\n{\r\n    fileInterface_->setBuildCommandTarget(fileName_, targetEditor_.text().toStdString());\r\n\r\n\temit contentChanged();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileBuildCommand::onReplaceDefaultChanged()\r\n//-----------------------------------------------------------------------------\r\nvoid FileBuildCommand::onReplaceDefaultChanged()\r\n{\r\n    replaceDefaultEditor_->finishEditingCurrentWord();\r\n\r\n    QString newReplace = replaceDefaultEditor_->getExpression();\r\n    fileInterface_->setbuildCommandReplaceDefaultFlags(fileName_, newReplace.toStdString());\r\n\r\n    replaceDefaultEditor_->setToolTip(\r\n        QString::fromStdString(fileInterface_->getBuildCommandReplaceDefaultFlagsValue(fileName_)));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileBuildCommand::onBrowseTarget()\r\n//-----------------------------------------------------------------------------\r\nvoid FileBuildCommand::onBrowseTarget()\r\n{\r\n    QFileDialog browseDialog(this, tr(\"Set a target file\"), componentPath_);\r\n    if (browseDialog.exec() == QDialog::Accepted)\r\n    {\r\n        QStringList selectedFiles = browseDialog.selectedFiles();\r\n\r\n        if (!selectedFiles.isEmpty())\r\n        {\r\n            QString relativePath = General::getRelativeSavePath(componentPath_, selectedFiles.first());\r\n\r\n            targetEditor_.setText(relativePath);\r\n            onTargetChanged();\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileBuildCommand::setupLayout()\r\n//-----------------------------------------------------------------------------\r\nvoid FileBuildCommand::setupLayout()\r\n{\r\n    QGridLayout* topLayout = new QGridLayout(this);\r\n\r\n    QString targetToolTip(tr(\"Target defines the path to the file derived from the source file.\"));\r\n    QLabel* targetLabel = new QLabel(tr(\"Target file:\"), this);\r\n    targetLabel->setToolTip(targetToolTip);\r\n    targetEditor_.setToolTip(targetToolTip);\r\n\r\n    topLayout->addWidget(targetLabel, 0, 0, 1, 1);\r\n    topLayout->addWidget(&targetEditor_, 0, 1, 1, 1);\r\n    topLayout->addWidget(&browseTargetButton_, 0, 2, 1, 1);\r\n\r\n    QString commandToolTip(tr(\"Command defines a compiler or assembler tool that processes files of this type.\"));\r\n    QLabel* commandLabel = new QLabel(tr(\"Command:\"), this);\r\n    commandLabel->setToolTip(commandToolTip);\r\n    commandEditor_.setToolTip(commandToolTip);\r\n\r\n    topLayout->addWidget(commandLabel, 1, 0, 1, 1);\r\n    topLayout->addWidget(&commandEditor_, 1, 1, 1, 2);\r\n\r\n    QString flagToolTip(tr(\"Documents any flags to be passed along with the software tool command.\"));\r\n    QLabel* flagLabel = new QLabel(tr(\"Flags:\"), this);\r\n    flagLabel->setToolTip(flagToolTip);\r\n    flagsEditor_.setToolTip(flagToolTip);\r\n\r\n    topLayout->addWidget(flagLabel, 2, 0, 1, 1);\r\n    topLayout->addWidget(&flagsEditor_, 2, 1, 1, 2);\r\n\r\n    QString replaceFlagsToolTip(tr(\"Expression that must evaluate to true or false. When true, the flags replace \"\r\n        \"any default flags from the build script. When false, the given flags are appended.\"));\r\n    QLabel* replaceLabel = new QLabel(tr(\"Replace default flags, f(x):\"), this);\r\n    replaceLabel->setToolTip(replaceFlagsToolTip);\r\n\r\n    topLayout->addWidget(replaceLabel, 3, 0, 1, 1);\r\n    topLayout->addWidget(replaceDefaultEditor_, 3, 1, 1, 2);\r\n    topLayout->setColumnStretch(1, 1);\r\n\r\n    setContentsMargins(0, 0, 0, 0);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileBuildCommand::fileRenamed()\r\n//-----------------------------------------------------------------------------\r\nvoid FileBuildCommand::fileRenamed(std::string const& newName)\r\n{\r\n    fileName_ = newName;\r\n}\r\n"
  },
  {
    "path": "editors/ComponentEditor/fileSet/file/filebuildcommand.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: filebuildcommand.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 7.2.2011\r\n//\r\n// Description:\r\n// FileBuildCommand is a group box for editing buildCommand of a file.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef FILEBUILDCOMMAND_H\r\n#define FILEBUILDCOMMAND_H\r\n\r\n#include <QCheckBox>\r\n#include <QFileInfo>\r\n#include <QGridLayout>\r\n#include <QGroupBox>\r\n#include <QLineEdit>\r\n#include <QPushButton>\r\n#include <QSharedPointer>\r\n\r\nclass LibraryInterface;\r\nclass BuildCommand;\r\nclass File;\r\nclass Component;\r\nclass ExpressionEditor;\r\nclass ParameterFinder;\r\nclass ExpressionParser;\r\nclass FileInterface;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! FileBuildCommand is a group box for editing buildCommand of a file.\r\n//-----------------------------------------------------------------------------\r\nclass FileBuildCommand : public QGroupBox\r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\r\n\t/*!\r\n     *  The constructor.\r\n\t *\r\n\t *    @param [in] fileName            The file that is being edited.\r\n     *    @param [in] fileInterface       Interface for files.\r\n     *    @param [in] componentPath       The path to the component containing the file.\r\n     *    @param [in] parameterFinder     The used parameter finder.\r\n     *    @param [in] expressionParser    Parser for calculating expressions.\r\n     *    @param [in] parent              The owner of this widget.\r\n\t */\r\n    FileBuildCommand(std::string fileName,\r\n        FileInterface* fileInterface,\r\n        QString const& componentPath,\r\n        QSharedPointer<ParameterFinder> parameterFinder,\r\n        QSharedPointer<ExpressionParser> expressionParser,\r\n        QWidget *parent);\r\n\r\n\t/*!\r\n     *  The destructor.\r\n     */\r\n\tvirtual ~FileBuildCommand() = default;\r\n\r\n\t/*!\r\n     *  Restore the changes from the model to the editor.\r\n\t */\r\n\tvoid refresh();\r\n\r\n    /*!\r\n     *  Handle the name change of the containing file.\r\n     *\r\n     *    @param [in] newName     The new name of the file.\r\n     */\r\n    void fileRenamed(std::string const& newName);\r\n\r\nsignals:\r\n\r\n\t/*!\r\n     *  Emitted when contents of the widget change.\r\n     */\r\n\tvoid contentChanged();\r\n\r\n    /*!\r\n     *  Increase the number of references made to the selected parameter.\r\n     *\r\n     *    @param [in] id  ID of the selected parameter.\r\n     */\r\n    void increaseReferences(QString id);\r\n\r\n    /*!\r\n     *  Decrease the number of references made to the selected parameter.\r\n     *\r\n     *    @param [in] id  ID of the selected parameter.\r\n     */\r\n    void decreaseReferences(QString id);\r\n\r\nprivate slots:\r\n\r\n\t/*!\r\n     *  Handler for command changes.\r\n     */\r\n    void onCommandChanged();\r\n\r\n    /*!\r\n     *  Handler for flag changes.\r\n     */\r\n    void onFlagsChanged();\r\n\r\n    /*!\r\n     *  Handler for target changes.\r\n     */\r\n    void onTargetChanged();\r\n\r\n    /*!\r\n     *  Handler for changes in the replace default flags.\r\n     */\r\n    void onReplaceDefaultChanged();\r\n\r\n    /*!\r\n     *  Handler for target browsing.\r\n     */\r\n    void onBrowseTarget();\r\n\r\nprivate:\r\n\r\n\t/*!\r\n     *  No copying. No assignment.\r\n     */\r\n\tFileBuildCommand(const FileBuildCommand& other);\r\n\r\n    /*!\r\n     *  Equals operator.\r\n     */\r\n    FileBuildCommand& operator=(const FileBuildCommand& other);\r\n\r\n    /*!\r\n     *  Setup the layout.\r\n     */\r\n    void setupLayout();\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! Name of the file whose build command is being edited.\r\n    std::string fileName_;\r\n\r\n    //! Interface for files.\r\n    FileInterface* fileInterface_;\r\n\r\n    //! Path to the containing component.\r\n    QString componentPath_;\r\n\r\n    //! Editor to set build command's target file.\r\n    QLineEdit targetEditor_;\r\n\r\n    //! Button for browsing the build command target file.\r\n    QPushButton browseTargetButton_;\r\n\r\n\t//! Editor to set file's build command.\r\n\tQLineEdit commandEditor_;\r\n\r\n\t//! Editor to set build command's flags.\r\n\tQLineEdit flagsEditor_;\r\n\r\n\t//! Expression editor to set build command's replaceDefaultFlags setting.\r\n    ExpressionEditor* replaceDefaultEditor_;\r\n\r\n    //! The used expression parser.\r\n    QSharedPointer<ExpressionParser> expressionParser_;\r\n};\r\n\r\n#endif // FILEBUILDCOMMAND_H\r\n"
  },
  {
    "path": "editors/ComponentEditor/fileSet/file/filedefinemodel.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: filedefinemodel.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Esko Pekkarinen\r\n// Date: 17.11.2015\r\n//\r\n// Description:\r\n// Model to display the define-elements for a file.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"filedefinemodel.h\"\r\n\r\n#include <IPXACTmodels/common/NameValuePair.h>\r\n\r\n#include <IPXACTmodels/Component/File.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileDefineModel::FileDefineModel()\r\n//-----------------------------------------------------------------------------\r\nFileDefineModel::FileDefineModel(QSharedPointer<File> file, QObject* parent): \r\nQAbstractTableModel(parent), \r\n    defines_(file->getDefines())\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileDefineModel::~FileDefineModel()\r\n//-----------------------------------------------------------------------------\r\nFileDefineModel::~FileDefineModel()\r\n{\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileDefineModel::rowCount()\r\n//-----------------------------------------------------------------------------\r\nint FileDefineModel::rowCount(QModelIndex const& parent) const\r\n{\r\n\tif (parent.isValid())\r\n    {\r\n\t\treturn 0;\r\n\t}\r\n\r\n\treturn defines_->count();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileDefineModel::columnCount()\r\n//-----------------------------------------------------------------------------\r\nint FileDefineModel::columnCount(QModelIndex const& parent) const \r\n{\r\n\tif (parent.isValid())\r\n    {\r\n\t\treturn 0;\r\n\t}\r\n\r\n\treturn 4;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileDefineModel::data()\r\n//-----------------------------------------------------------------------------\r\nQVariant FileDefineModel::data(QModelIndex const& index, int role) const\r\n{\r\n    if (!index.isValid() || index.row() < 0 || index.row() >= defines_->count() || role != Qt::DisplayRole)\r\n    {\r\n\t\treturn QVariant();\r\n\t}\r\n\r\n    switch (index.column())\r\n    {\r\n    case 0: \r\n        return defines_->at(index.row())->name();\r\n    case 1:\r\n        return defines_->at(index.row())->getValue();\r\n    case 2:\r\n        return defines_->at(index.row())->displayName();\r\n    case 3:\r\n        return defines_->at(index.row())->description();\r\n    default:\r\n        return QVariant();\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileDefineModel::headerData()\r\n//-----------------------------------------------------------------------------\r\nQVariant FileDefineModel::headerData(int section, Qt::Orientation orientation, int role) const\r\n{\r\n\tif (role != Qt::DisplayRole)\r\n    {\r\n        return QVariant();\r\n    }\r\n\r\n    if (orientation == Qt::Horizontal)\r\n    {\r\n        switch (section)\r\n        {\r\n        case 0:\r\n            return tr(\"Name\");\r\n        case 1:\r\n            return tr(\"Value\");\r\n        case 2:\r\n            return tr(\"Display name\");\r\n        case 3:\r\n            return tr(\"Description\");\r\n        default:\r\n            return QVariant();\r\n        }\r\n    }\r\n    else if (orientation == Qt::Vertical)\r\n    {\r\n        return section;\r\n    }\r\n    else\r\n    {\r\n        return QVariant();\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileDefineModel::setData()\r\n//-----------------------------------------------------------------------------\r\nbool FileDefineModel::setData(QModelIndex const& index, QVariant const& value, int role)\r\n{\r\n\tif (!index.isValid())\r\n    {\r\n\t\treturn false;\r\n\t}\r\n\r\n\tif (role == Qt::EditRole)\r\n    {\r\n\t\tswitch (index.column())\r\n        {\r\n        case 0: \r\n            {\r\n                defines_->at(index.row())->setName(value.toString());\r\n                break;\r\n            }\r\n        case 1: \r\n            {\r\n                defines_->at(index.row())->setValue(value.toString());\r\n                break;\r\n            }\r\n        case 2: \r\n            {\r\n                defines_->at(index.row())->setDisplayName(value.toString());\r\n                break;\r\n            }\r\n        case 3: \r\n            {\r\n                defines_->at(index.row())->setDescription(value.toString());\r\n                break;\r\n            }\r\n        default:\r\n            {\r\n                return false;\r\n            }\r\n\t\t}\r\n\t\temit dataChanged(index, index);\r\n\t\temit contentChanged();\r\n\t\treturn true;\r\n\t}\r\n\t// if unsupported role\r\n\telse\r\n    {\r\n\t\treturn false;\r\n\t}\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileDefineModel::flags()\r\n//-----------------------------------------------------------------------------\r\nQt::ItemFlags FileDefineModel::flags(QModelIndex const& index) const\r\n{\r\n\tif (!index.isValid())\r\n    {\r\n\t\treturn Qt::NoItemFlags;\r\n\t}\r\n\r\n\treturn Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsEditable;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileDefineModel::insertRows()\r\n//-----------------------------------------------------------------------------\r\nbool FileDefineModel::insertRows(int row, int count, QModelIndex const& parent)\r\n{\r\n\t// row has to be valid\r\n\tif (row < 0 || row > defines_->size() || parent.isValid())\r\n    {\r\n\t\treturn false;\r\n\t}\r\n\r\n\tbeginInsertRows(parent, row, row + count -1);\r\n\tfor (int i = 0; i < count; ++i)\r\n    {\r\n\t\tdefines_->insert(row, QSharedPointer<NameValuePair>(new NameValuePair()));\r\n\t}\r\n\tendInsertRows();\r\n\temit contentChanged();\r\n\treturn true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileDefineModel::removeRows()\r\n//-----------------------------------------------------------------------------\r\nbool FileDefineModel::removeRows(int row, int count, QModelIndex const& parent)\r\n{\r\n\t// row has to be valid and there must be enough rows to remove\r\n\tif (row < 0 || row >= defines_->count() || (row + count >= defines_->count()) || parent.isValid())\r\n    {\r\n\t\treturn false;\r\n\t}\r\n\r\n\tbeginRemoveRows(parent, row, row + count -1);\r\n\t// remove the right amount of rows\r\n\tfor (int i = 0; i < count; ++i)\r\n    {\r\n\t\tdefines_->removeAt(row);\r\n\t}\r\n\tendInsertRows();\r\n\temit contentChanged();\r\n\treturn true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileDefineModel::isValid()\r\n//-----------------------------------------------------------------------------\r\nbool FileDefineModel::isValid() const\r\n{\r\n\t// check all define items\r\n\tfor (int i = 0; i < defines_->count(); ++i)\r\n    {\t\r\n\t\t// if one item has mandatory element missing\r\n\t\tif (defines_->at(i)->name().isEmpty() || defines_->at(i)->getValue().isEmpty())\r\n        {\r\n\t\t\t\treturn false;\r\n\t\t}\r\n\t}\r\n\treturn true;\r\n}\r\n"
  },
  {
    "path": "editors/ComponentEditor/fileSet/file/filedefinemodel.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: filedefinemodel.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Esko Pekkarinen\r\n// Date: 17.11.2015\r\n//\r\n// Description:\r\n// Model to display the define-elements for a file.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef FILEDEFINEMODEL_H\r\n#define FILEDEFINEMODEL_H\r\n\r\n#include <QAbstractTableModel>\r\n#include <QString>\r\n#include <QList>\r\n#include <QSharedPointer>\r\n\r\nclass File;\r\nclass NameValuePair;\r\n//-----------------------------------------------------------------------------\r\n//! Model to display the define-elements for a file.\r\n//-----------------------------------------------------------------------------\r\nclass FileDefineModel : public QAbstractTableModel\r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\r\n\t/*! The constructor\r\n\t *\r\n\t *    @param [in] file    The file being modified.\r\n     *    @param [in] parent  The owner of this widget.\r\n\t*/\r\n\tFileDefineModel(QSharedPointer<File> file, QObject* parent);\r\n\r\n\t//! The destructor\r\n\tvirtual ~FileDefineModel();\r\n\r\n\t/*! Get the number of rows in the model.\r\n\t *\r\n\t *    @param [in] parent Model index of the parent of the item. \r\n\t *\r\n\t *    @return Number of rows currently in the model.\r\n\t*/\r\n\tvirtual int rowCount(QModelIndex const& parent = QModelIndex()) const;\r\n\r\n\t/*! Get the number of columns in the model\r\n\t *\r\n\t *    @param [in] parent Model index of the parent of the item.\r\n\t *\r\n\t *    @return Number of columns currently in the model.\r\n\t*/\r\n\tvirtual int columnCount(QModelIndex const& parent = QModelIndex()) const;\r\n\r\n\t/*! Get the data for the specified item for specified role.\r\n\t *\r\n\t *    @param [in] index   Identifies the item that's data is wanted.\r\n\t *    @param [in] role    Specifies what kind of data is wanted\r\n\t *\r\n\t *    @return QVariant containing the data\r\n\t*/\r\n\tvirtual QVariant data(QModelIndex const& index, int role = Qt::DisplayRole) const;\r\n\r\n\t/*! Get the data for the headers\r\n\t *\r\n\t *    @param [in] section         The column that's header is wanted\r\n\t *    @param [in] orientation     Only Qt::Horizontal is supported\r\n\t *    @param [in] role            Specified the type of data that is wanted.\r\n\t *\r\n\t *    @return The string to display as header.\r\n\t*/\r\n\tvirtual QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;\r\n\r\n\t/*! Get information on how specified item can be handled.\r\n\t *\r\n\t *    @param [in] index Specifies the item that's flags are wanted.\r\n\t *\r\n\t *    @return Qt::ItemFlags that define how object can be handled.\r\n\t*/\r\n\tvirtual Qt::ItemFlags flags(QModelIndex const& index) const;\r\n\r\n\t/*! Set the data for specified item.\r\n\t *\r\n\t *    @param [in] index   Specifies the item that's data is modified\r\n\t *    @param [in] value   The value to be set.\r\n\t *    @param [in] role    The role that is trying to modify the data. \r\n\t *\r\n\t *    @return True if data was successfully set.\r\n\t*/\r\n\tvirtual bool setData(QModelIndex const& index, QVariant const& value, int role = Qt::EditRole);\r\n\r\n\t/*! Insert rows to the model\r\n\t *\r\n\t *    @param [in] row     The row to start inserting rows to.\r\n\t *    @param [in] count   The number of rows to insert.\r\n\t *    @param [in] parent  Model index of the parent to which the rows are inserted.\r\n\t *\r\n\t *    @return True if rows were successfully inserted.\r\n\t*/\r\n\tbool insertRows(int row, int count, QModelIndex const& parent = QModelIndex());\r\n\r\n\t/*! Remove rows from the model\r\n\t *\r\n\t *    @param [in] row     The row to start removing rows from.\r\n\t *    @param [in] count   The number of rows to remove\r\n\t *    @param [in] parent  Model index of the parent from which the rows are removed.\r\n\t *\r\n\t *    @return True if rows were successfully removed.\r\n\t*/\r\n\tbool removeRows(int row, int count, QModelIndex const& parent = QModelIndex());\r\n\r\n\t/*! Is the model in valid condition.\r\n\t *\r\n\t *    @return True if the items in the model are valid.\r\n\t*/\r\n\tbool isValid() const;\r\n\r\nsignals:\r\n\r\n\t//! Emitted when the contents of the editor change\r\n\tvoid contentChanged();\r\n\r\nprivate:\r\n\r\n\t//! No copying\r\n\tFileDefineModel(const FileDefineModel& other);\r\n\r\n\t//! No assignment\r\n\tFileDefineModel& operator=(const FileDefineModel& other);\r\n\t\r\n\t//! The defines displayed in the model.\r\n\tQSharedPointer<QList<QSharedPointer<NameValuePair> > > defines_;\r\n\r\n};\r\n\r\n#endif // FILEDEFINEMODEL_H\r\n"
  },
  {
    "path": "editors/ComponentEditor/fileSet/file/filedefineview.cpp",
    "content": "/* \r\n *\r\n *  Created on: 17.2.2011\r\n *      Author: Antti Kamppi\r\n * \t\tfilename: filedefineview.cpp\r\n */\r\n\r\n#include \"filedefineview.h\"\r\n\r\n#include <QHeaderView>\r\n\r\nFileDefineView::FileDefineView(QWidget *parent): QTableView(parent)\r\n{\r\n\tsetCornerButtonEnabled(false);\r\n\tsetShowGrid(true);\r\n\tsetSortingEnabled(true);\r\n\tsetWordWrap(true);\r\n\tsetAlternatingRowColors(true);\r\n\tsetEditTriggers(QAbstractItemView::DoubleClicked | QAbstractItemView::SelectedClicked |\r\n        QAbstractItemView::EditKeyPressed);\r\n\thorizontalHeader()->setStretchLastSection(true);\r\n}\r\n\r\nFileDefineView::~FileDefineView()\r\n{\r\n}\r\n"
  },
  {
    "path": "editors/ComponentEditor/fileSet/file/filedefineview.h",
    "content": "/* \r\n *\r\n *  Created on: 15.2.2011\r\n *      Author: Antti Kamppi\r\n * \t\tfilename: filedefineview.h\r\n */\r\n\r\n//-----------------------------------------------------------------------------\r\n// File: filedefineview.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Esko Pekkarinen\r\n// Date: 17.11.2015\r\n//\r\n// Description:\r\n// <Short description of the class/file contents>\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef FILEDEFINEVIEW_H\r\n#define FILEDEFINEVIEW_H\r\n\r\n#include <QTableView>\r\n\r\n/*! \\brief Table view to display the define-elements for the file.\r\n *\r\n */\r\nclass FileDefineView : public QTableView{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\r\n\t/*! \\brief The constructor\r\n\t *\r\n\t * \\param parent The owner of this widget.\r\n\t *\r\n\t*/\r\n\tFileDefineView(QWidget* parent);\r\n\r\n\t//! \\brief The destructor\r\n\tvirtual ~FileDefineView();\r\n\r\nprivate:\r\n\r\n\t//! \\brief No copying\r\n\tFileDefineView(const FileDefineView& other);\r\n\r\n\t//! No assignment\r\n\tFileDefineView& operator=(const FileDefineView& other);\r\n\t\r\n};\r\n\r\n#endif // FILEDEFINEVIEW_H\r\n"
  },
  {
    "path": "editors/ComponentEditor/fileSet/file/fileeditor.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: fileeditor.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 5.2.2011\r\n//\r\n// Description:\r\n// Editor for the details of a file.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"fileeditor.h\"\r\n\r\n#include <IPXACTmodels/Component/File.h>\r\n#include <IPXACTmodels/Component/FileSet.h>\r\n#include <IPXACTmodels/Component/Component.h>\r\n\r\n#include <KactusAPI/include/LibraryInterface.h>\r\n\r\n#include <KactusAPI/include/FileInterface.h>\r\n\r\n#include <QScrollArea>\r\n#include <QVBoxLayout>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: fileeditor::FileEditor()\r\n//-----------------------------------------------------------------------------\r\nFileEditor::FileEditor(LibraryInterface* handler, QSharedPointer<Component> component, std::string const& fileName,\r\n    QSharedPointer<ParameterFinder> parameterFinder, QSharedPointer<ExpressionParser> expressionParser,\r\n    FileInterface* fileInterface, QSharedPointer<QList<QSharedPointer<File>>> files, QWidget *parent):\r\nItemEditor(component, handler, parent),\r\nfileName_(fileName),\r\nnameEditor_(fileName, fileInterface, this),\r\nfileTypeEditor_(component->getRevision(), this, fileName, fileInterface),\r\ngeneralEditor_(this, fileName, fileInterface),\r\nexportedNamesEditor_(tr(\"Exported names\"), this),\r\nbuildCommand_(fileName, fileInterface, handler->getDirectoryPath(component->getVlnv()), parameterFinder,\r\n    expressionParser, this),\r\nimageTypesEditor_(tr(\"Image types\"), this),\r\ndependenciesEditor_(tr(\"Dependent directories\"), handler->getDirectoryPath(component->getVlnv()), this),\r\neditButton_(new QPushButton(QIcon(\":/icons/common/graphics/edit.png\"), tr(\"Edit file\"), this)),\r\nrunButton_(new QPushButton(QIcon(\":/icons/common/graphics/script-run-file.png\"), tr(\"Run file\"), this)),\r\nopenFolderButton_(new QPushButton(QIcon(\":/icons/common/graphics/opened-folder.png\"), tr(\"Open file location\"), this)),\r\nfileInterface_(fileInterface),\r\navailableFiles_(files)\r\n{\r\n    fileInterface_->setFiles(availableFiles_);\r\n\r\n    editButton_->setFlat(true);\r\n    runButton_->setFlat(true);\r\n    openFolderButton_->setFlat(true);\r\n\r\n    exportedNamesEditor_.setFlat(true);\r\n    imageTypesEditor_.setFlat(true);\r\n    dependenciesEditor_.setFlat(true);\r\n\r\n    setupLayout();\r\n    \r\n    fileTypeEditor_.initialize();\r\n    exportedNamesEditor_.initialize();\r\n    imageTypesEditor_.initialize();\r\n    dependenciesEditor_.initialize();\r\n\r\n    connect(editButton_, SIGNAL(clicked(bool)), this, SIGNAL(editFile()), Qt::UniqueConnection);\r\n    connect(runButton_, SIGNAL(clicked(bool)), this, SIGNAL(runFile()), Qt::UniqueConnection);\r\n    connect(openFolderButton_, SIGNAL(clicked(bool)), this, SIGNAL(openContainingFolder()), Qt::UniqueConnection);\r\n\r\n    connect(&generalEditor_, SIGNAL(contentChanged()), this, SIGNAL(contentChanged()), Qt::UniqueConnection);\r\n    connect(&fileTypeEditor_, SIGNAL(contentChanged()), this, SLOT(onFileTypesChanged()), Qt::UniqueConnection);\r\n    connect(&buildCommand_, SIGNAL(contentChanged()), this, SIGNAL(contentChanged()), Qt::UniqueConnection);\r\n\r\n    connect(&nameEditor_, SIGNAL(contentChanged()), this, SIGNAL(contentChanged()), Qt::UniqueConnection);\r\n    connect(&dependenciesEditor_, SIGNAL(contentChanged()),\r\n        this, SLOT(onDependenciesChanged()), Qt::UniqueConnection);\r\n    connect(&exportedNamesEditor_, SIGNAL(contentChanged()),\r\n        this, SLOT(onExportedNamesChanged()), Qt::UniqueConnection);\r\n    connect(&imageTypesEditor_, SIGNAL(contentChanged()), this, SLOT(onImageTypesChanged()), Qt::UniqueConnection);\r\n\r\n    connect(&buildCommand_, SIGNAL(increaseReferences(QString)),\r\n        this, SIGNAL(increaseReferences(QString)), Qt::UniqueConnection);\r\n    connect(&buildCommand_, SIGNAL(decreaseReferences(QString)),\r\n        this, SIGNAL(decreaseReferences(QString)), Qt::UniqueConnection);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: fileeditor::refresh()\r\n//-----------------------------------------------------------------------------\r\nvoid FileEditor::refresh()\r\n{\r\n    fileInterface_->setFiles(availableFiles_);\r\n\r\n    nameEditor_.refresh();\r\n    generalEditor_.refresh();\r\n    fileTypeEditor_.restore();\r\n    buildCommand_.refresh();\r\n\r\n    std::vector<std::string> fileDependenciesSTD = fileInterface_->getDependencies(fileName_);\r\n    QStringList fileDependencies;\r\n    for (auto dependency : fileDependenciesSTD)\r\n    {\r\n        fileDependencies.append(QString::fromStdString(dependency));\r\n    }\r\n    dependenciesEditor_.setItems(fileDependencies);\r\n\r\n    std::vector<std::string> fileExportedNamesSTD = fileInterface_->getExportedNames(fileName_);\r\n    QStringList fileExportedNames;\r\n    for (auto name : fileExportedNamesSTD)\r\n    {\r\n        fileExportedNames.append(QString::fromStdString(name));\r\n    }\r\n    exportedNamesEditor_.setItems(fileExportedNames);\r\n\r\n    std::vector<std::string> fileImageTypesSTD = fileInterface_->getImageTypes(fileName_);\r\n    QStringList fileImageTypes;\r\n    for (auto imageType : fileImageTypesSTD)\r\n    {\r\n        fileImageTypes.append(QString::fromStdString(imageType));\r\n    }\r\n    imageTypesEditor_.setItems(fileImageTypes);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: fileeditor::showEvent()\r\n//-----------------------------------------------------------------------------\r\nvoid FileEditor::showEvent(QShowEvent* event)\r\n{\r\n    ItemEditor::showEvent(event);\r\n    emit helpUrlRequested(\"componenteditor/filegeneral.html\");\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: fileeditor::onFileTypesChanged()\r\n//-----------------------------------------------------------------------------\r\nvoid FileEditor::onFileTypesChanged()\r\n{\r\n    fileInterface_->clearFileTypes(fileName_);\r\n\r\n    std::vector<std::string> fileTypesInSTD;\r\n    for (auto fileType : fileTypeEditor_.items())\r\n    {\r\n        fileTypesInSTD.push_back(fileType.toStdString());\r\n    }\r\n\r\n    fileInterface_->addMultipleFileTypes(fileName_, fileTypesInSTD);\r\n\r\n    emit contentChanged();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: fileeditor::onDependenciesChanged()\r\n//-----------------------------------------------------------------------------\r\nvoid FileEditor::onDependenciesChanged()\r\n{\r\n    fileInterface_->clearDependencies(fileName_);\r\n\r\n    std::vector<std::string> dependenciesInSTD;\r\n    for (auto dependency : dependenciesEditor_.items())\r\n    {\r\n        dependenciesInSTD.push_back(dependency.toStdString());\r\n    }\r\n\r\n    fileInterface_->addMultipleDependencies(fileName_, dependenciesInSTD);\r\n\r\n    emit contentChanged();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: fileeditor::onDependenciesChanged()\r\n//-----------------------------------------------------------------------------\r\nvoid FileEditor::onExportedNamesChanged()\r\n{\r\n    fileInterface_->clearExportedNames(fileName_);\r\n\r\n    std::vector<std::string> exportedNamesInSTD;\r\n    for (auto name : exportedNamesEditor_.items())\r\n    {\r\n        exportedNamesInSTD.push_back(name.toStdString());\r\n    }\r\n\r\n    fileInterface_->addMultipleExportedNames(fileName_, exportedNamesInSTD);\r\n\r\n    emit contentChanged();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: fileeditor::onDependenciesChanged()\r\n//-----------------------------------------------------------------------------\r\nvoid FileEditor::onImageTypesChanged()\r\n{\r\n    fileInterface_->clearImageTypes(fileName_);\r\n\r\n    std::vector<std::string> imageTypesInSTD;\r\n    for (auto imageType : imageTypesEditor_.items())\r\n    {\r\n        imageTypesInSTD.push_back(imageType.toStdString());\r\n    }\r\n\r\n    fileInterface_->addMultipleImageTypes(fileName_, imageTypesInSTD);\r\n\r\n    emit contentChanged();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: fileeditor::setupLayout()\r\n//-----------------------------------------------------------------------------\r\nvoid FileEditor::setupLayout()\r\n{\r\n    QScrollArea* scrollArea = new QScrollArea(this);\r\n    scrollArea->setWidgetResizable(true);\r\n    scrollArea->setFrameShape(QFrame::NoFrame);\r\n\r\n    QVBoxLayout* scrollLayout = new QVBoxLayout(this);\r\n    scrollLayout->addWidget(scrollArea);\r\n    scrollLayout->setContentsMargins(0, 0, 0, 0);\r\n\r\n    QHBoxLayout* buttonLayout = new QHBoxLayout();\r\n    buttonLayout->addWidget(editButton_);\r\n    buttonLayout->addWidget(runButton_);\r\n    buttonLayout->addWidget(openFolderButton_);\r\n    buttonLayout->setSpacing(1);\r\n    buttonLayout->addStretch(1);\r\n\r\n    QWidget* topWidget = new QWidget(scrollArea);\r\n    topWidget->setContentsMargins(0, 0, 0, 0);\r\n\r\n    QGridLayout* topLayout = new QGridLayout(topWidget);\r\n    topLayout->setContentsMargins(0, 0, 0, 0);\r\n\r\n    topLayout->addWidget(&nameEditor_, 0, 0, 1, 1);\r\n    topLayout->addWidget(&fileTypeEditor_, 0, 1, 1, 1);\r\n    topLayout->addWidget(&generalEditor_, 1, 0, 1, 1);\r\n    topLayout->addWidget(&exportedNamesEditor_, 1, 1, 1, 1);\r\n    topLayout->addWidget(&buildCommand_, 2, 0, 1, 1);\r\n    topLayout->addWidget(&imageTypesEditor_, 2, 1, 1, 1);\r\n    topLayout->addLayout(buttonLayout, 3, 0, 1, 2, Qt::AlignTop);\r\n    topLayout->addWidget(&dependenciesEditor_, 3, 1, 1, 1);\r\n\r\n    topLayout->setRowStretch(3, 2);\r\n\r\n    scrollArea->setWidget(topWidget);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: fileeditor::fileRenamed()\r\n//-----------------------------------------------------------------------------\r\nvoid FileEditor::fileRenamed(std::string const& oldName, std::string const& newName)\r\n{\r\n    if (oldName == fileName_)\r\n    {\r\n        fileName_ = newName;\r\n\r\n        nameEditor_.fileRenamed(newName);\r\n        fileTypeEditor_.fileRenamed(newName);\r\n        generalEditor_.fileRenamed(newName);\r\n        buildCommand_.fileRenamed(newName);\r\n    }\r\n}\r\n"
  },
  {
    "path": "editors/ComponentEditor/fileSet/file/fileeditor.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: fileeditor.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 5.2.2011\r\n//\r\n// Description:\r\n// Editor for the details of a file.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef FILEEDITOR_H\r\n#define FILEEDITOR_H\r\n\r\n#include <editors/ComponentEditor/itemeditor.h>\r\n\r\n#include \"filenameeditor.h\"\r\n#include \"filegeneraleditor.h\"\r\n#include \"filetypeeditor.h\"\r\n#include \"filebuildcommand.h\"\r\n\r\n#include <common/widgets/listManager/dirlistmanager.h>\r\n#include <common/widgets/listManager/listmanager.h>\r\n\r\n#include <QWidget>\r\n#include <QSharedPointer>\r\n\r\nclass LibraryInterface;\r\nclass Component;\r\nclass File;\r\nclass ParameterFinder;\r\nclass ExpressionParser;\r\nclass FileInterface;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Editor for the details of a file.\r\n//-----------------------------------------------------------------------------\r\nclass FileEditor : public ItemEditor\r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\r\n\t/*!\r\n     *  The constructor.\r\n\t *\r\n\t *    @param [in] handler             Pointer to the instance that manages the library.\r\n\t *    @param [in] component           Pointer to the component being edited.\r\n\t *    @param [in] fileName            Name of the file that is edited.\r\n     *    @param [in] parameterFinder     The used parameter finder.\r\n     *    @param [in] expressionParser    Parser for calculating expressions.\r\n     *    @param [in] fileInterface       Interface for files.\r\n     *    @param [in] files               The available files.\r\n\t *    @param [in] parent              Pointer to the owner of this widget.\r\n\t */\r\n    FileEditor(LibraryInterface* handler,\r\n        QSharedPointer<Component> component,\r\n        std::string const& fileName,\r\n        QSharedPointer<ParameterFinder> parameterFinder,\r\n        QSharedPointer<ExpressionParser> expressionParser,\r\n        FileInterface* fileInterface,\r\n        QSharedPointer<QList<QSharedPointer<File> > > files,\r\n        QWidget *parent = 0);\r\n\r\n\t/*!\r\n     *  The destructor.\r\n     */\r\n\tvirtual ~FileEditor() = default;\r\n\r\n\t/*!\r\n     *  Reload the information from the model to the editor.\r\n\t */\r\n\tvirtual void refresh();\r\n\r\npublic slots:\r\n\r\n    /*!\r\n     *  Handle the name change of the containing file.\r\n     *\r\n     *    @param [in] oldName     Old name of the file.\r\n     *    @param [in] newName     The new name of the file.\r\n     */\r\n    void fileRenamed(std::string const& oldName, std::string const& newName);\r\n\r\nsignals:\r\n\r\n    //! Emitted when the file should be opened in default editor.\r\n    void editFile();\r\n\r\n    //! Emitted when the file should be run.\r\n    void runFile();\r\n\r\n    //! Emitted when the containing folder should be opened.\r\n    void openContainingFolder();\r\n\r\nprotected:\r\n\r\n    /*!\r\n     *  Shows the editor and emits a request for the help file.\r\n     *\r\n     *    @param [in] event   The show event.\r\n     */\r\n    virtual void showEvent(QShowEvent* event);\r\n\r\nprivate slots:\r\n\r\n    /*!\r\n     *  Changes the file types in the current file.\r\n     */\r\n    void onFileTypesChanged();\r\n\r\n    /*!\r\n     *  Changes the dependencies of the current file.\r\n     */\r\n    void onDependenciesChanged();\r\n\r\n    /*!\r\n     *  Changes the exported names of the current file.\r\n     */\r\n    void onExportedNamesChanged();\r\n\r\n    /*!\r\n     *  Changes the image types of the current file.\r\n     */\r\n    void onImageTypesChanged();\r\n\r\nprivate:\r\n\r\n\t//! No copying. No assignment.\r\n\tFileEditor(const FileEditor& other);\r\n\tFileEditor& operator=(const FileEditor& other);\r\n\r\n    /*!\r\n     *  Setups the layout for the editor.\r\n     */\r\n    void setupLayout();\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! Name of the file that is edited in this editor.\r\n    std::string fileName_;\r\n\r\n    //! The editor for the file name and description.\r\n    FileNameEditor nameEditor_;\r\n\r\n    //! Editor for the file types of a file.\r\n    FileTypeEditor fileTypeEditor_;\r\n\r\n    //! Editor for the files general settings.\r\n    FileGeneralEditor generalEditor_;\r\n\r\n    //! Editor for the exported names of a file.\r\n    ListManager exportedNamesEditor_;\r\n\r\n    //! Editor for the build commands of a file.\r\n    FileBuildCommand buildCommand_;\r\n\r\n    //! Editor for the image types of a file.\r\n    ListManager imageTypesEditor_;\r\n\r\n    //! Editor for the dependencies of a file.\r\n    DirListManager dependenciesEditor_;\r\n\r\n    //! The button for editing the current file.\r\n    QPushButton* editButton_;\r\n\r\n    //! The button for running the current file.\r\n    QPushButton* runButton_;\r\n\r\n    //! The button for opening containing folder.\r\n    QPushButton* openFolderButton_;\r\n\r\n    //! Interface for files.\r\n    FileInterface* fileInterface_;\r\n\r\n    //! The available files.\r\n    QSharedPointer<QList<QSharedPointer<File> > > availableFiles_;\r\n};\r\n\r\n#endif // FILEEDITOR_H\r\n"
  },
  {
    "path": "editors/ComponentEditor/fileSet/file/filegeneraleditor.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: filegeneraleditor.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 6.2.2011\r\n//\r\n// Description:\r\n// FileGeneralEditor is a widget to edit File's general settings.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"filegeneraleditor.h\"\r\n\r\n#include <KactusAPI/include/utils.h>\r\n\r\n#include <IPXACTmodels/Component/File.h>\r\n\r\n#include <KactusAPI/include/FileInterface.h>\r\n\r\n#include <QLabel>\r\n#include <QVBoxLayout>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: filegeneraleditor::FileGeneralEditor()\r\n//-----------------------------------------------------------------------------\r\nFileGeneralEditor::FileGeneralEditor(QWidget *parent, std::string const& fileName, FileInterface* fileInterface):\r\nQGroupBox(tr(\"General options\"), parent), \r\nfileName_(fileName),\r\nlogicalName_(this), \r\nlogicalDefault_(tr(\"Generators can override logical name\"), this),\r\nstructuralFile_(tr(\"File is structural RTL\"), this),\r\nincludeFile_(tr(\"File is include file\"), this),\r\nexternalDec_(tr(\"File contains external declarations\"), this),\r\nfileInterface_(fileInterface)\r\n{\r\n    setFlat(true);\r\n\r\n\tQLabel* logicNameLabel = new QLabel(tr(\"Logical name:\"), this);\r\n\tlogicNameLabel->setToolTip(tr(\"Logical name for the file or directory.\\n\"\r\n\t\t\"For example VHDL library name for a vhdl-file\"));\r\n\r\n    QVBoxLayout* topLayout = new QVBoxLayout(this);\r\n\r\n    QHBoxLayout* nameLayout = new QHBoxLayout();\r\n\tnameLayout->addWidget(logicNameLabel);\r\n\tnameLayout->addWidget(&logicalName_);\r\n\r\n    topLayout->addLayout(nameLayout);\r\n    topLayout->addWidget(&logicalDefault_);\r\n    topLayout->addWidget(&structuralFile_);\r\n    topLayout->addWidget(&includeFile_);\r\n\ttopLayout->addWidget(&externalDec_);\r\n\r\n\tconnect(&logicalName_, SIGNAL(textEdited(const QString&)),\r\n        this, SLOT(onLogicalNameChanged()), Qt::UniqueConnection);\r\n\tconnect(&logicalDefault_, SIGNAL(clicked(bool)), this, SLOT(onLogicalNameChanged()), Qt::UniqueConnection);\r\n    connect(&structuralFile_, SIGNAL(clicked(bool)), this, SLOT(onStructuralFileChanged()), Qt::UniqueConnection);\r\n\tconnect(&includeFile_, SIGNAL(clicked(bool)), this, SLOT(onIncludeFileChanged()), Qt::UniqueConnection);\r\n\tconnect(&externalDec_, SIGNAL(clicked(bool)), this, SLOT(onExternalDecChanged()), Qt::UniqueConnection);\r\n\r\n\trefresh();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: filegeneraleditor::refresh()\r\n//-----------------------------------------------------------------------------\r\nvoid FileGeneralEditor::refresh()\r\n{\r\n    logicalName_.setText(QString::fromStdString(fileInterface_->getLogicalName(fileName_)));\r\n\r\n    logicalDefault_.setChecked(fileInterface_->isLogicalNameDefault(fileName_));\r\n    structuralFile_.setChecked(fileInterface_->isStructural(fileName_));\r\n    includeFile_.setChecked(fileInterface_->isIncludeFile(fileName_));\r\n    externalDec_.setChecked(fileInterface_->hasExternalDeclarations(fileName_));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: filegeneraleditor::onLogicalNameChanged()\r\n//-----------------------------------------------------------------------------\r\nvoid FileGeneralEditor::onLogicalNameChanged()\r\n{\r\n    fileInterface_->setLogicalName(fileName_, logicalName_.text().toStdString());\r\n    fileInterface_->setLogicalNameDefault(fileName_, logicalDefault_.isChecked());\r\n\r\n\temit contentChanged();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: filegeneraleditor::onStructuralFileChanged()\r\n//-----------------------------------------------------------------------------\r\nvoid FileGeneralEditor::onStructuralFileChanged()\r\n{\r\n    fileInterface_->setStructural(fileName_, structuralFile_.isChecked());\r\n    emit contentChanged();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: filegeneraleditor::onIncludeFileChanged()\r\n//-----------------------------------------------------------------------------\r\nvoid FileGeneralEditor::onIncludeFileChanged()\r\n{\r\n    fileInterface_->setIncludeFile(fileName_, includeFile_.isChecked());\r\n    emit contentChanged();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: filegeneraleditor::onExternalDecChanged()\r\n//-----------------------------------------------------------------------------\r\nvoid FileGeneralEditor::onExternalDecChanged()\r\n{\r\n    fileInterface_->setExternalDeclarations(fileName_, externalDec_.isChecked());\r\n    emit contentChanged();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileGeneralEditor::fileRenamed()\r\n//-----------------------------------------------------------------------------\r\nvoid FileGeneralEditor::fileRenamed(std::string const& newName)\r\n{\r\n    fileName_ = newName;\r\n}\r\n"
  },
  {
    "path": "editors/ComponentEditor/fileSet/file/filegeneraleditor.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: filegeneraleditor.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 6.2.2011\r\n//\r\n// Description:\r\n// FileGeneralEditor is a widget to edit File's general settings.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef FILEGENERALEDITOR_H\r\n#define FILEGENERALEDITOR_H\r\n\r\n#include <QGroupBox>\r\n#include <QLineEdit>\r\n#include <QCheckBox>\r\n#include <QPlainTextEdit>\r\n#include <QSharedPointer>\r\n\r\nclass File;\r\nclass FileInterface;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! FileGeneralEditor is a widget to edit File's general settings.\r\n//-----------------------------------------------------------------------------\r\nclass FileGeneralEditor : public QGroupBox\r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\r\n\t/*!\r\n     *  The constructor.\r\n\t *\r\n\t *    @param [in] parent          Pointer to the owner of this widget\r\n\t *    @param [in] fileName        Name of the file that is being edited.\r\n     *    @param [in] fileInterface   Interface for accessing files.\r\n\t */\r\n    FileGeneralEditor(QWidget *parent, std::string const& fileName, FileInterface* fileInterface);\r\n\r\n\t/*!\r\n     *  The destructor.\r\n     */\r\n\tvirtual ~FileGeneralEditor() = default;\r\n\r\n\t/*!\r\n     *  Restore the settings from the model.\r\n\t */\r\n\tvoid refresh();\r\n\r\n    /*!\r\n     *  Handle the name change of the containing file.\r\n     *\r\n     *    @param [in] newName     The new name of the file.\r\n     */\r\n    void fileRenamed(std::string const& newName);\r\n\r\nsignals:\r\n\r\n\t//! Emitted when the contents on one of the elements change.\r\n\tvoid contentChanged();\r\n\r\nprivate slots:\r\n\r\n\t//! Handler for changes in logical name.\r\n\tvoid onLogicalNameChanged();\r\n\r\n    //! Handler for changes in structural file setting.\r\n    void onStructuralFileChanged();\r\n\r\n    //! Handler for changes in include file setting.\r\n\tvoid onIncludeFileChanged();\r\n\r\n\t//! Handler for external declarations changes.\r\n\tvoid onExternalDecChanged();\r\n\r\nprivate:\r\n\r\n\t//! No copying. No assignment. No regret.\r\n\tFileGeneralEditor(const FileGeneralEditor& other);\r\n\tFileGeneralEditor& operator=(const FileGeneralEditor& other);\r\n\t\r\n\t//! Name of the file that is modified.\r\n    std::string fileName_;\r\n\r\n\t//! The editor to set the logical name for the file.\r\n\tQLineEdit logicalName_;\r\n\r\n\t//! The check box to set the logical name as default or not.\r\n\tQCheckBox logicalDefault_;\r\n\r\n    //! The check box to set the file as structural file or not.\r\n    QCheckBox structuralFile_;\r\n\r\n\t//! The check box to set the file as include file or not.\r\n\tQCheckBox includeFile_;\r\n\r\n\t//! The check box to inform that file contains external declarations.\r\n\tQCheckBox externalDec_;\r\n\r\n    //! Interface for accessing files.\r\n    FileInterface* fileInterface_;\r\n};\r\n\r\n#endif // FILEGENERALEDITOR_H\r\n"
  },
  {
    "path": "editors/ComponentEditor/fileSet/file/filenameeditor.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: filenameeditor.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 5.2.2011\r\n//\r\n// Description:\r\n// FileNameEditor is a widget to display the name element in FileSet.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"filenameeditor.h\"\r\n\r\n#include <KactusAPI/include/FileInterface.h>\r\n\r\n#include <IPXACTmodels/Component/File.h>\r\n\r\n#include <QFormLayout>\r\n#include <QLabel>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileNameEditor::FileNameEditor()\r\n//-----------------------------------------------------------------------------\r\nFileNameEditor::FileNameEditor(std::string const& fileName, FileInterface* fileInterface, QWidget *parent):\r\nQGroupBox(tr(\"File name and location\"), parent),\r\nfileNameLabel_(QString::fromStdString(fileName)),\r\ndescriptionEditor_(this),\r\nfileName_(fileName),\r\nfileInterface_(fileInterface)\r\n{\r\n    setFlat(true);\r\n\r\n    fileNameLabel_.setWordWrap(true);\r\n\r\n    fileNameLabel_.setToolTip(tr(\"The name field contains an absolute or relative\\n\"\r\n        \"path to a file name or directory\"));\r\n\r\n    descriptionEditor_.setToolTip(\"Set the description for the file\");\r\n    descriptionEditor_.setTabChangesFocus(true);\r\n\r\n    QFormLayout* topLayout = new QFormLayout(this);\r\n    topLayout->addRow(tr(\"Name:\"), &fileNameLabel_);\r\n    topLayout->addRow(tr(\"Description:\"), &descriptionEditor_);\r\n\r\n    connect(&descriptionEditor_, SIGNAL(textChanged()), this, SLOT(onDescriptionChanged()), Qt::UniqueConnection);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileNameEditor::refresh()\r\n//-----------------------------------------------------------------------------\r\nvoid FileNameEditor::refresh()\r\n{\r\n    fileNameLabel_.setText(QString::fromStdString(fileName_));\r\n\r\n    disconnect(&descriptionEditor_, SIGNAL(textChanged()), this, SLOT(onDescriptionChanged()));\r\n\r\n    descriptionEditor_.setPlainText(\r\n        QString::fromStdString(fileInterface_->getDescription(fileName_)));\r\n\r\n    connect(&descriptionEditor_, SIGNAL(textChanged()), this, SLOT(onDescriptionChanged()), Qt::UniqueConnection);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: filenameeditor::onDescriptionChanged()\r\n//-----------------------------------------------------------------------------\r\nvoid FileNameEditor::onDescriptionChanged()\r\n{\r\n    fileInterface_->setDescription(fileName_, descriptionEditor_.toPlainText().toStdString());\r\n    emit contentChanged();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: filenameeditor::fileRenamed()\r\n//-----------------------------------------------------------------------------\r\nvoid FileNameEditor::fileRenamed(std::string const& newName)\r\n{\r\n    fileName_ = newName;\r\n}\r\n"
  },
  {
    "path": "editors/ComponentEditor/fileSet/file/filenameeditor.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: filenameeditor.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 5.2.2011\r\n//\r\n// Description:\r\n// FileNameEditor is a widget to display the name element in FileSet.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef FILENAMEEDITOR_H\r\n#define FILENAMEEDITOR_H\r\n\r\n#include <QGroupBox>\r\n#include <QSharedPointer>\r\n#include <QLabel>\r\n#include <QPlainTextEdit>\r\n\r\nclass File;\r\nclass FileInterface;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! FileNameEditor is a widget to display the name element in FileSet.\r\n//-----------------------------------------------------------------------------\r\nclass FileNameEditor : public QGroupBox \r\n{\r\n    Q_OBJECT\r\n\r\npublic:\r\n\t\r\n\t/*!\r\n     *  The constructor\r\n\t *\r\n\t *    @param [in] fileName        Name of to the file being edited.\r\n     *    @param [in] fileInterface   Interface for accessing files.\r\n     *    @param [in] parent          Pointer to the owner of this widget     \r\n\t */\r\n    FileNameEditor(std::string const& fileName, FileInterface* fileInterface, QWidget *parent);\r\n\r\n\t/*!\r\n     *  The destructor\r\n     */\r\n\tvirtual ~FileNameEditor() = default;\r\n\r\n    //! No copying. No assignment.\r\n    FileNameEditor(const FileNameEditor& other) = delete;\r\n    FileNameEditor& operator=(const FileNameEditor& other) = delete;\r\n\r\n\t/*!\r\n     *  Refresh the editor.\r\n     */\r\n\tvoid refresh();\r\n\r\n    /*!\r\n     *  Handle the name change of the containing file.\r\n     *\r\n     *    @param [in] newName     The new name of the file.\r\n     */\r\n    void fileRenamed(std::string const& newName);\r\n\r\nsignals:\r\n\r\n    /*!\r\n     *  Informs of a change of content in the component.\r\n     */\r\n    void contentChanged();\r\n\r\nprivate slots:\r\n\r\n    /*!\r\n     *  Handles the change of description of file.\r\n     */\r\n    void onDescriptionChanged();\r\n\r\nprivate:\r\n\r\n\t\r\n\t//! The label to display the file name.\r\n    QLabel fileNameLabel_;\r\n\r\n    //! The editor for description of a file.\r\n    QPlainTextEdit descriptionEditor_;\r\n\r\n\t//! Name of the file being edited.\r\n    std::string fileName_;\r\n\r\n    //! Interface for accessing files.\r\n    FileInterface* fileInterface_;\r\n};\r\n\r\n#endif // FILENAMEEDITOR_H\r\n"
  },
  {
    "path": "editors/ComponentEditor/fileSet/file/filesdelegate.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: filesdelegate.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 6.6.2012\r\n//\r\n// Description:\r\n// Delegate for creating editors for files.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"filesdelegate.h\"\r\n#include \"filetypeeditordelegate.h\"\r\n#include \"FileColumns.h\"\r\n\r\n#include <common/widgets/listManager/listeditor.h>\r\n\r\n#include <QComboBox>\r\n#include <QLineEdit>\r\n#include <QTextEdit>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FilesDelegate::FilesDelegate()\r\n//-----------------------------------------------------------------------------\r\nFilesDelegate::FilesDelegate(Document::Revision docRevision, QObject *parent):\r\nMultilineDescriptionDelegate(parent),\r\nrevision_(docRevision)\r\n{\r\n\r\n}\r\n\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FilesDelegate::~FilesDelegate()\r\n//-----------------------------------------------------------------------------\r\nFilesDelegate::~FilesDelegate()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FilesDelegate::createEditor()\r\n//-----------------------------------------------------------------------------\r\nQWidget* FilesDelegate::createEditor(QWidget* parent, const QStyleOptionViewItem& option, QModelIndex const& index) const\r\n{\r\n\tif (index.column() == FileColumns::NAME_COLUMN)// || index.column() == FileColumns::PATH_COLUMN)\r\n\t{\r\n        return 0;\r\n\t}\r\n    else if (index.column() == FileColumns::TYPES_COLUMN)\r\n    {\r\n        // create the editor\r\n        ListEditor* listEditor = new ListEditor(parent);\r\n        listEditor->setMinimumHeight(FilesDelegate::LIST_EDITOR_MIN_HEIGHT);\r\n\r\n        // create the delegate for the editor\r\n        FileTypeEditorDelegate* delegate = new FileTypeEditorDelegate(revision_, parent);\r\n        listEditor->setItemDelegate(delegate);\r\n\r\n        return listEditor;\r\n    }\r\n    else \r\n    {\r\n        return MultilineDescriptionDelegate::createEditor(parent, option, index);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FilesDelegate::setEditorData()\r\n//-----------------------------------------------------------------------------\r\nvoid FilesDelegate::setEditorData(QWidget* editor, QModelIndex const& index ) const\r\n{\r\n    if (index.column() == FileColumns::NAME_COLUMN)// || index.column() == FileColumns::PATH_COLUMN)\r\n    {\r\n        return;\r\n    }\r\n    if (index.column() == FileColumns::TYPES_COLUMN)\r\n    {\r\n        ListEditor* listEditor = qobject_cast<ListEditor*>(editor);\r\n        Q_ASSERT(listEditor);\r\n        QStringList groups = index.data(Qt::DisplayRole).toString().split(\"; \");\r\n        listEditor->setItems(groups);\r\n    }\r\n    else\r\n    {\r\n        MultilineDescriptionDelegate::setEditorData(editor, index);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FilesDelegate::setModelData()\r\n//-----------------------------------------------------------------------------\r\nvoid FilesDelegate::setModelData(QWidget* editor, QAbstractItemModel* model, QModelIndex const& index) const\r\n{\r\n\tif (index.column() == FileColumns::NAME_COLUMN)// || index.column() == FileColumns::PATH_COLUMN)\r\n    {\r\n        return;\r\n    }\r\n    else if (index.column() == FileColumns::TYPES_COLUMN)\r\n    {\r\n        ListEditor* listEditor = qobject_cast<ListEditor*>(editor);\r\n        Q_ASSERT(listEditor);\r\n\r\n        QStringList fileTypes = listEditor->items();\r\n        model->setData(index, fileTypes.join(\"; \"), Qt::EditRole);\r\n    }\r\n    else\r\n    {\r\n        MultilineDescriptionDelegate::setModelData(editor, model, index);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FilesDelegate::descriptionColumn()\r\n//-----------------------------------------------------------------------------\r\nint FilesDelegate::descriptionColumn() const\r\n{\r\n    return FileColumns::DESCRIPTION;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FilesDelegate::commitAndCloseEditor()\r\n//-----------------------------------------------------------------------------\r\nvoid FilesDelegate::commitAndCloseEditor()\r\n{\r\n\tQWidget* edit = qobject_cast<QWidget*>(sender());\r\n\tQ_ASSERT(edit);\r\n\r\n\temit commitData(edit);\r\n\temit closeEditor(edit);\r\n}\r\n"
  },
  {
    "path": "editors/ComponentEditor/fileSet/file/filesdelegate.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: filesdelegate.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 6.6.2012\r\n//\r\n// Description:\r\n// Delegate for creating editors for files.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef FILESDELEGATE_H\r\n#define FILESDELEGATE_H\r\n\r\n#include <editors/ComponentEditor/common/MultilineDescriptionDelegate.h>\r\n\r\n#include <IPXACTmodels/common/Document.h>\r\n\r\n#include <QStyledItemDelegate>\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Delegate for creating editors for files.\r\n//-----------------------------------------------------------------------------\r\nclass FilesDelegate : public MultilineDescriptionDelegate\r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\r\n\t//! The minimum height for the editor.\r\n\tstatic const int LIST_EDITOR_MIN_HEIGHT = 100;\r\n\r\n\t/*!\r\n     *  The constructor.\r\n\t *\r\n\t *    @param [in] parent  Pointer to the owner of the delegate.\r\n\t */\r\n\tFilesDelegate(Document::Revision docRevision, QObject *parent);\r\n\t\r\n\t//! The destructor.\r\n\tvirtual ~FilesDelegate();\r\n\r\n\t//! No copying. No assignment.\r\n\tFilesDelegate(const FilesDelegate& other) = delete;\r\n\tFilesDelegate& operator=(const FilesDelegate& other) = delete;\r\n\r\n\t/*!\r\n     *  Create a new editor for the given item.\r\n\t *\r\n\t *    @param [in] parent  Owner for the editor.\r\n\t *    @param [in] option  Contains options for the editor.\r\n\t *    @param [in] index   Model index identifying the item.\r\n\t *\r\n\t *    @return Pointer to the editor to be used to edit the item.\r\n\t */\r\n\tvirtual QWidget* createEditor(QWidget* parent, const QStyleOptionViewItem& option, const QModelIndex& index)\r\n        const;\r\n\r\n\t/*!\r\n     *  Set the data for the editor.\r\n\t *\r\n\t *    @param [in] editor  Pointer to the editor where the data is to be set.\r\n\t *    @param [in] index   Model index identifying the item that's data is to be set.\r\n\t */\r\n\tvirtual void setEditorData(QWidget* editor, const QModelIndex& index) const;\r\n\r\n\t/*!\r\n     *  Save the data from the editor to the model.\r\n\t *\r\n\t *    @param [in] editor  Pointer to the editor that contains the data to store.\r\n\t *    @param [in] model   Model that contains the data structure where data is to be saved to.\r\n\t *    @param [in] index   Model index identifying the item that's data is to be saved.\r\n\t */\r\n\tvirtual void setModelData(QWidget* editor, QAbstractItemModel* model, const QModelIndex& index) const;\r\n\r\nprotected:\r\n\r\n    //! Gets the descriptions column.\r\n    virtual int descriptionColumn() const;\r\n\r\nprivate slots:\r\n\r\n\t/*!\r\n     *  Commit the data from the sending editor and close the editor.\r\n\t */\r\n\tvoid commitAndCloseEditor();\r\n\r\nprivate:\r\n\r\n\tDocument::Revision revision_;\r\n};\r\n\r\n#endif // FILESDELEGATE_H\r\n"
  },
  {
    "path": "editors/ComponentEditor/fileSet/file/fileseditor.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: fileseditor.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 1.6.2012\r\n//\r\n// Description:\r\n// The editor to add/remove/edit files of a file set.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"fileseditor.h\"\r\n#include \"filesdelegate.h\"\r\n\r\n#include <KactusAPI/include/LibraryInterface.h>\r\n\r\n#include <KactusAPI/include/FileInterface.h>\r\n\r\n#include <IPXACTmodels/Component/Component.h>\r\n\r\n#include <QVBoxLayout>\r\n\r\n#include <QStringList>\r\n#include <QFileDialog>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: fileseditor::FilesEditor()\r\n//-----------------------------------------------------------------------------\r\nFilesEditor::FilesEditor(QSharedPointer<QList<QSharedPointer<File>>> availableFiles, FileInterface* fileInterface,\r\n    QSharedPointer<Component> component, LibraryInterface* handler,\r\n    QWidget *parent, const QString& title):\r\nQGroupBox(title, parent),\r\nhandler_(handler),\r\ncomponent_(component),\r\nview_(handler, component, this),\r\nmodel_(handler, component, fileInterface, this),\r\nfileInterface_(fileInterface),\r\navailableFiles_(availableFiles)\r\n{\r\n\tsetFlat(true);\r\n\r\n    fileInterface_->setFiles(availableFiles_);\r\n\r\n\tQVBoxLayout* layout = new QVBoxLayout(this);\r\n\tlayout->addWidget(&view_);\r\n\r\n    view_.setAlternatingRowColors(false);\r\n\r\n    view_.setAcceptDrops(true);\r\n    view_.setDropIndicatorShown(true);\r\n    \r\n\tview_.setAllowImportExport(true);\r\n\r\n\tview_.setModel(&model_);\r\n\r\n\t// the order of files must be maintained\r\n\tview_.setSortingEnabled(false);\r\n\r\n\tview_.setItemsDraggable(true);\r\n\r\n\t// set the delegate to provide editors\r\n\tview_.setItemDelegate(new FilesDelegate(component->getRevision(), this));\r\n\r\n\tconnect(&view_, SIGNAL(addItemByBrowsing()), this, SLOT(onAddFiles()), Qt::UniqueConnection);\r\n    connect(&view_, SIGNAL(addItem(const QModelIndex&)),\r\n        &model_, SLOT(onAddItem(const QModelIndex&)), Qt::UniqueConnection);\r\n\tconnect(&view_, SIGNAL(removeItem(const QModelIndex&)),\r\n        &model_, SLOT(onRemoveItem(const QModelIndex&)), Qt::UniqueConnection);\r\n\tconnect(&view_, SIGNAL(moveItem(const QModelIndex&, const QModelIndex&)),\r\n        &model_, SLOT(onMoveItem(const QModelIndex&, const QModelIndex&)), Qt::UniqueConnection);\r\n\tconnect(&model_, SIGNAL(contentChanged()), this, SIGNAL(contentChanged()), Qt::UniqueConnection);\r\n\r\n\t// the signals from model informing that a child is added/removed\r\n\tconnect(&model_, SIGNAL(fileAdded(int)), this, SIGNAL(fileAdded(int)), Qt::UniqueConnection);\r\n\tconnect(&model_, SIGNAL(fileRemoved(int)), this, SIGNAL(fileRemoved(int)), Qt::UniqueConnection);\r\n\tconnect(&model_, SIGNAL(fileMoved(int, int)), this, SIGNAL(fileMoved(int, int)), Qt::UniqueConnection);\r\n\r\n    connect(&model_, SIGNAL(fileRenamed(std::string const&, std::string const&)),\r\n        this, SIGNAL(fileRenamed(std::string const&, std::string const&)), Qt::UniqueConnection);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: fileseditor::~FilesEditor()\r\n//-----------------------------------------------------------------------------\r\nFilesEditor::~FilesEditor()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: fileseditor::refresh()\r\n//-----------------------------------------------------------------------------\r\nvoid FilesEditor::refresh()\r\n{\r\n    fileInterface_->setFiles(availableFiles_);\r\n\r\n\tview_.update();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: fileseditor::onAddFiles()\r\n//-----------------------------------------------------------------------------\r\nvoid FilesEditor::onAddFiles()\r\n{\r\n\tQStringList filePaths = QFileDialog::getOpenFileNames(this, tr(\"Select files to add.\"),\r\n\t\thandler_->getPath(component_->getVlnv()));\r\n\r\n\tfor (QString const& file : filePaths)\r\n    {\r\n\t\tmodel_.onAddItem(QModelIndex(), file);\r\n\t}\r\n}\r\n"
  },
  {
    "path": "editors/ComponentEditor/fileSet/file/fileseditor.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: fileseditor.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 1.6.2012\r\n//\r\n// Description:\r\n// The editor to add/remove/edit files of a file set.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef FILESEDITOR_H\r\n#define FILESEDITOR_H\r\n\r\n#include \"filesmodel.h\"\r\n#include \"filesview.h\"\r\n\r\n#include <QGroupBox>\r\n#include <QSharedPointer>\r\n\r\nclass LibraryInterface;\r\nclass Component;\r\nclass FileSet;\r\nclass File;\r\nclass FileInterface;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! The editor to add/remove/edit files of a file set.\r\n//-----------------------------------------------------------------------------\r\nclass FilesEditor : public QGroupBox\r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\r\n\t/*!\r\n     *  The constructor.\r\n\t *\r\n     *    @param [in] availableFiles  List of editable files.\r\n     *    @param [ni] fileInterface   Interface for accessing files.\r\n\t *    @param [in] component       Pointer to the component being edited.\r\n\t *    @param [in] handler         Pointer to the instance that manages the library.\r\n\t *    @param [in] parent          Pointer to the owner of this editor.\r\n\t *    @param [in] title           The title for the group box.\r\n\t */\r\n    FilesEditor(QSharedPointer<QList<QSharedPointer<File> > > availableFiles,\r\n        FileInterface* fileInterface,\r\n        QSharedPointer<Component> component,\r\n        LibraryInterface* handler,\r\n        QWidget *parent,\r\n        const QString& title = tr(\"Files\"));\r\n\r\n\t/*!\r\n     *  The destructor.\r\n     */\r\n\t~FilesEditor();\r\n\r\npublic slots:\r\n\r\n\t/*!\r\n     *  Reload the information from the model to the editor.\r\n\t */\r\n\tvirtual void refresh();\r\n\r\nsignals:\r\n\r\n\t//! Emitted when the files change.\r\n\tvoid contentChanged();\r\n\r\n\t//! Emitted when a file is added to the list.\r\n\tvoid fileAdded(int index);\r\n\r\n\t//! Emitted when a file is removed from the list.\r\n\tvoid fileRemoved(int index);\r\n\r\n\t//! Emitted when a file is moved from position to another\r\n\tvoid fileMoved(int source, int target);\r\n\r\n    /*!\r\n     *  Inform of a name change in a file.\r\n     *\r\n     *    @param [in] oldName     Old name of the file.\r\n     *    @param [in] newName     The new name of the file.\r\n     */\r\n    void fileRenamed(std::string const& oldName, std::string const& newName);\r\n\r\nprivate slots:\r\n\r\n\t//! Handler for addFilesButton clicked() signal.\r\n\tvoid onAddFiles();\r\n\r\nprivate:\r\n\t\r\n\t//! No copying. No Assignment.\r\n\tFilesEditor(const FilesEditor& other);\r\n\tFilesEditor& operator=(const FilesEditor& other);\r\n\r\n\t//! Pointer to the instance that manages the library.\r\n\tLibraryInterface* handler_;\r\n\r\n\t//! Pointer to the component being edited.\r\n\tQSharedPointer<Component> component_;\r\n\r\n\t//! The view to display the file information.\r\n\tFilesView view_;\r\n\r\n\t//! The model to edit the file summary.\r\n\tFilesModel model_;\r\n\r\n    //! Interface for accessing files.\r\n    FileInterface* fileInterface_;\r\n\r\n    //! The editable files.\r\n    QSharedPointer<QList<QSharedPointer<File> > > availableFiles_;\r\n};\r\n\r\n#endif // FILESEDITOR_H\r\n"
  },
  {
    "path": "editors/ComponentEditor/fileSet/file/filesmodel.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: filesmodel.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 1.6.2012\r\n//\r\n// Description:\r\n// The model that contains the files to edit in files summary editor.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"filesmodel.h\"\r\n#include \"FileColumns.h\"\r\n\r\n#include <KactusAPI/include/FileHandler.h>\r\n#include <common/KactusColors.h>\r\n#include <KactusAPI/include/LibraryInterface.h>\r\n\r\n#include <IPXACTmodels/generaldeclarations.h>\r\n#include <IPXACTmodels/Component/File.h>\r\n#include <IPXACTmodels/Component/FileSet.h>\r\n#include <IPXACTmodels/Component/Component.h>\r\n\r\n#include <KactusAPI/include/FileInterface.h>\r\n\r\n#include <QFileInfo>\r\n#include <QMimeData>\r\n#include <QProcessEnvironment>\r\n#include <QRegularExpression>\r\n#include <QStringList>\r\n#include <QUrl>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FilesModel::FilesModel()\r\n//-----------------------------------------------------------------------------\r\nFilesModel::FilesModel(LibraryInterface* handler, QSharedPointer<Component> component,\r\n    FileInterface* fileInterface, QObject* parent):\r\nQAbstractTableModel(parent),\r\nhandler_(handler),\r\ncomponent_(component),\r\nfileInterface_(fileInterface)\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FilesModel::rowCount()\r\n//-----------------------------------------------------------------------------\r\nint FilesModel::rowCount(QModelIndex const& parent /*= QModelIndex()*/ ) const\r\n{\r\n\tif (parent.isValid())\r\n    {\r\n\t\treturn 0;\r\n\t}\r\n\r\n    return fileInterface_->itemCount();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FilesModel::columnCount()\r\n//-----------------------------------------------------------------------------\r\nint FilesModel::columnCount(QModelIndex const& parent /*= QModelIndex()*/ ) const\r\n{\r\n\tif (parent.isValid())\r\n    {\r\n\t\treturn 0;\r\n\t}\r\n\r\n    return FileColumns::COLUMN_COUNT;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FilesModel::flags()\r\n//-----------------------------------------------------------------------------\r\nQt::ItemFlags FilesModel::flags(QModelIndex const& index ) const\r\n{\r\n\tif (!index.isValid())\r\n    {\r\n\t\treturn Qt::ItemIsDropEnabled;\r\n\t}\r\n\t\r\n    if (index.column() == FileColumns::NAME_COLUMN)\r\n    {\r\n\t\treturn Qt::ItemIsSelectable | Qt::ItemIsEnabled;\r\n\t}\r\n\r\n\treturn Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsEditable;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FilesModel::headerData()\r\n//-----------------------------------------------------------------------------\r\nQVariant FilesModel::headerData(int section, Qt::Orientation orientation, int role) const\r\n{\r\n\tif (orientation != Qt::Horizontal)\r\n    {\r\n\t\treturn QVariant();\r\n\t}\r\n\r\n\tif (role == Qt::DisplayRole)\r\n    {\r\n        if (section == FileColumns::NAME_COLUMN)\r\n        {\r\n            return tr(\"File name\");\r\n        }\r\n        else if (section == FileColumns::PATH_COLUMN)\r\n        {\r\n            return tr(\"File path\");\r\n        }\r\n        else if (section == FileColumns::TYPES_COLUMN)\r\n        {\r\n            return tr(\"File types\");\r\n        }\r\n        else if (section == FileColumns::DESCRIPTION)\r\n        {\r\n            return tr(\"Description\");\r\n        }\r\n\t}\r\n\r\n    return QVariant();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FilesModel::data()\r\n//-----------------------------------------------------------------------------\r\nQVariant FilesModel::data(QModelIndex const& index, int role) const\r\n{\r\n    if (!index.isValid() || index.row() < 0 || index.row() >= fileInterface_->itemCount())\r\n    {\r\n\t\treturn QVariant();\r\n\t}\r\n\r\n    std::string fileName = fileInterface_->getIndexedItemName(index.row());\r\n\r\n    if (role == Qt::DisplayRole || role == Qt::EditRole)\r\n    {\r\n        if (index.column() == FileColumns::NAME_COLUMN)\r\n        {\r\n            QFileInfo fileInfo(QString::fromStdString(fileName));\r\n            QString name = fileInfo.fileName();\r\n            if (name.isEmpty())\r\n            {\r\n                name = tr(\"unnamed\");\r\n            }\r\n\r\n            return name;\r\n        }\r\n        else if (index.column() == FileColumns::PATH_COLUMN)\r\n        {\r\n            QString filePath = QString::fromStdString(fileName);\r\n            if (filePath.isEmpty() && role == Qt::DisplayRole)\r\n            {\r\n                filePath = tr(\"no path or URI defined\");\r\n            }\r\n\r\n            return filePath;\r\n        }\r\n        else if (index.column() == FileColumns::TYPES_COLUMN)\r\n        {\r\n            return getFileTypesString(fileName);\r\n        }\r\n        else if (index.column() == FileColumns::DESCRIPTION)\r\n        {\r\n            QString fileDescription = QString::fromStdString(fileInterface_->getDescription(fileName));\r\n\r\n            if (role == Qt::DisplayRole)\r\n            {\r\n                return fileDescription.replace(\r\n                    QRegularExpression(\"\\n.*$\", QRegularExpression::DotMatchesEverythingOption), \"...\");\r\n            }\r\n            else\r\n            {\r\n                return fileDescription;\r\n            }\r\n        }\r\n\t}\r\n\r\n\telse if (role == Qt::ForegroundRole)\r\n    {\r\n        if (index.column() == FileColumns::NAME_COLUMN)\r\n        {\r\n            if (fileName.empty())\r\n            {\r\n                return KactusColors::ERROR;\r\n            }\r\n            else\r\n            {\r\n                return KactusColors::REGULAR_TEXT;\r\n            }\r\n        }\r\n        if (index.column() == FileColumns::PATH_COLUMN && \r\n            !(FileHandler::isValidURI(handler_->getPath(component_->getVlnv()),QString::fromStdString(fileName))))\r\n        {\r\n            return KactusColors::ERROR;\r\n        }\r\n\t}\r\n\r\n    else if (role == Qt::ToolTipRole)\r\n    {\r\n        if (index.column() == FileColumns::DESCRIPTION)\r\n        {\r\n            return QString::fromStdString(fileInterface_->getDescription(fileName));\r\n        }\r\n        else if (!FileHandler::isValidURI(handler_->getPath(component_->getVlnv()),\r\n            QString::fromStdString(fileName)))\r\n        {\r\n            return tr(\"File path is not found or defines an invalid URI.\");\r\n        }\r\n    }\r\n\r\n    else if (role == Qt::BackgroundRole && (index.column() == FileColumns::PATH_COLUMN ||\r\n        index.column() == FileColumns::TYPES_COLUMN))\r\n    {\r\n        return KactusColors::MANDATORY_FIELD;\r\n    }\r\n\r\n    return QVariant();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: filesmodel::getFileTypesString()\r\n//-----------------------------------------------------------------------------\r\nQString FilesModel::getFileTypesString(std::string const& fileName) const\r\n{\r\n    QStringList types;\r\n\r\n    for (auto fileType : fileInterface_->getFileTypes(fileName))\r\n    {\r\n        types.append(QString::fromStdString(fileType));\r\n    }\r\n\r\n    return types.join(\"; \");\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FilesModel::setData()\r\n//-----------------------------------------------------------------------------\r\nbool FilesModel::setData(QModelIndex const& index, const QVariant& value, int role)\r\n{\r\n    if (!index.isValid() || index.row() < 0 || index.row() >= fileInterface_->itemCount())\r\n    {\r\n\t\treturn false;\r\n\t}\r\n\r\n    std::string fileName = fileInterface_->getIndexedItemName(index.row());\r\n\r\n    if (role == Qt::EditRole)\r\n    {\r\n        if (index.column() == FileColumns::NAME_COLUMN)\r\n        {\r\n            // User can not edit the file name, it must be done through file path.\r\n            return false;\r\n        }\r\n        else if (index.column() == FileColumns::PATH_COLUMN)\r\n        {\r\n            QString filePath = value.toString();\r\n            if (filePath.isEmpty())\r\n            {\r\n                return false;\r\n            }\r\n\r\n            std::string newName = value.toString().toStdString();\r\n            fileInterface_->setName(fileName, newName);\r\n\r\n            //! Send information of the new name to the matching file editor...\r\n            emit fileRenamed(fileName, newName);\r\n        }\r\n        else if (index.column() == FileColumns::TYPES_COLUMN)\r\n        {\r\n            QString str = value.toString();\r\n            QStringList fileTypes = str.split(\"; \", Qt::SkipEmptyParts);\r\n\r\n            std::vector<std::string> newFileTypes;\r\n            for (auto singleType : fileTypes)\r\n            {\r\n                newFileTypes.push_back(singleType.toStdString());\r\n            }\r\n\r\n            fileInterface_->setFileTypes(fileName, newFileTypes);\r\n        }\r\n        else if (index.column() == FileColumns::DESCRIPTION)\r\n        {\r\n            fileInterface_->setDescription(fileName, value.toString().toStdString());\r\n        }\r\n        else\r\n        {\r\n            return false;\r\n        }\r\n\r\n\t\temit dataChanged(index, index);\r\n\t\temit contentChanged();\r\n\t\treturn true;\r\n\t}\r\n\r\n    return false;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FilesModel::mimeTypes()\r\n//-----------------------------------------------------------------------------\r\nQStringList FilesModel::mimeTypes() const\r\n{\r\n    return QStringList(QStringLiteral(\"text/uri-list\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FilesModel::supportedDropActions()\r\n//-----------------------------------------------------------------------------\r\nQt::DropActions FilesModel::supportedDropActions() const\r\n{\r\n    return Qt::CopyAction;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FilesModel::dropMimeData()\r\n//-----------------------------------------------------------------------------\r\nbool FilesModel::dropMimeData(QMimeData const* data, Qt::DropAction action, int /*row*/, int /*column*/,\r\n    QModelIndex const& /*parent*/)\r\n{\r\n    if (action == Qt::IgnoreAction)\r\n    {\r\n        return true;\r\n    }\r\n\r\n    foreach(QUrl const& filePath, data->urls())\r\n    {\r\n        if (filePath.isLocalFile())\r\n        {\r\n            onAddItem(QModelIndex(), filePath.toLocalFile());\r\n        }      \r\n    }\r\n\r\n    return true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FilesModel::onAddItem()\r\n//-----------------------------------------------------------------------------\r\nvoid FilesModel::onAddItem(QModelIndex const& index)\r\n{\r\n    int row = fileInterface_->itemCount();\r\n\r\n    // if the index is valid then add the item to the correct position\r\n    if (index.isValid())\r\n    {\r\n        row = index.row();\r\n    }\r\n\r\n    beginInsertRows(QModelIndex(), row, row);\r\n\r\n    fileInterface_->addFile(row, \"unknown\");\r\n\r\n    endInsertRows();\r\n\r\n    // inform navigation tree that file set is added\r\n    emit fileAdded(row);\r\n\r\n    // tell also parent widget that contents have been changed\r\n    emit contentChanged();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FilesModel::onAddItem()\r\n//-----------------------------------------------------------------------------\r\nvoid FilesModel::onAddItem(QModelIndex const& index, const QString& filePath)\r\n{\r\n    int row = fileInterface_->itemCount();\r\n\r\n\t// if the index is valid then add the item to the correct position\r\n\tif (index.isValid())\r\n    {\r\n\t\trow = index.row();\r\n\t}\r\n\r\n\t// convert the given path into relative path\r\n\tconst QString xmlPath = handler_->getPath(component_->getVlnv());\r\n\tconst QString relPath = General::getRelativePath(xmlPath, filePath);\r\n\r\n\t// if relative path could not be created.\r\n\tif (relPath.isEmpty())\r\n    {\r\n\t\treturn;\r\n\t}\r\n\r\n\t// if the file is already contained in the list\r\n    auto const relativePath = relPath.toStdString();\r\n    for (auto const& fileName : fileInterface_->getItemNames())\r\n    {\r\n        if (fileName == relativePath)\r\n        {\r\n            return;\r\n        }\r\n    }\r\n\r\n\tbeginInsertRows(QModelIndex(), row, row);\r\n    fileInterface_->addFile(row, relPath.toStdString());\r\n\tendInsertRows();\r\n\r\n\t// inform navigation tree that file set is added\r\n\temit fileAdded(row);\r\n\r\n\t// tell also parent widget that contents have been changed\r\n\temit contentChanged();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FilesModel::onRemoveItem()\r\n//-----------------------------------------------------------------------------\r\nvoid FilesModel::onRemoveItem(QModelIndex const& index )\r\n{\r\n\t// don't remove anything if index is invalid\r\n    if (!index.isValid() || index.row() < 0 || index.row() >= fileInterface_->itemCount())\r\n    {\r\n\t\treturn;\r\n\t}\r\n\r\n    std::string removedFileName = fileInterface_->getIndexedItemName(index.row());\r\n\r\n\t// remove the specified item\r\n\tbeginRemoveRows(QModelIndex(), index.row(), index.row());\r\n\r\n    fileInterface_->removeFile(removedFileName);\r\n\r\n\tendRemoveRows();\r\n\r\n\t// inform navigation tree that file set has been removed\r\n\temit fileRemoved(index.row());\r\n\r\n\t// tell also parent widget that contents have been changed\r\n\temit contentChanged();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FilesModel::onMoveItem()\r\n//-----------------------------------------------------------------------------\r\nvoid FilesModel::onMoveItem(QModelIndex const& originalPos, QModelIndex const& newPos )\r\n{\r\n\tif (!originalPos.isValid() || originalPos == newPos || originalPos.row() < 0 ||\r\n        originalPos.row() >= fileInterface_->itemCount())\r\n    {\r\n\t\treturn;\r\n\t}\r\n\r\n\tint source = originalPos.row();\r\n\tint target = 0;\r\n\r\n\t// if the new position is invalid index then put the item last in the table\r\n    if (!newPos.isValid() || newPos.row() < 0 || newPos.row() >= fileInterface_->itemCount())\r\n    {\r\n\t\tbeginResetModel();\r\n\r\n        std::string fileName = fileInterface_->getIndexedItemName(originalPos.row());\r\n        target = fileInterface_->itemCount() - 1;\r\n        fileInterface_->swapFiles(originalPos.row(), target);\r\n\r\n        endResetModel();\r\n\t}\r\n\t// if both indexes were valid\r\n\telse\r\n    {\r\n\t\tbeginResetModel();\r\n        fileInterface_->swapFiles(originalPos.row(), newPos.row());\r\n\t\ttarget = newPos.row();\r\n\t\tendResetModel();\r\n\t}\r\n\r\n\temit fileMoved(source, target);\r\n\r\n\temit contentChanged();\r\n}\r\n"
  },
  {
    "path": "editors/ComponentEditor/fileSet/file/filesmodel.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: filesmodel.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 1.6.2012\r\n//\r\n// Description:\r\n// The model that contains the files to edit in files summary editor.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef FILESMODEL_H\r\n#define FILESMODEL_H\r\n\r\n#include <QAbstractTableModel>\r\n#include <QList>\r\n#include <QSharedPointer>\r\n\r\nclass LibraryInterface;\r\nclass File;\r\nclass FileSet;\r\nclass Component;\r\nclass FileInterface;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! The model that contains the files to edit in files summary editor.\r\n//-----------------------------------------------------------------------------\r\nclass FilesModel : public QAbstractTableModel\r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\r\n\r\n\t/*! The constructor.\r\n\t * \r\n\t *    @param [in] handler         The instance that manages the library.\r\n\t *    @param [in] component       The component being edited.\r\n     *    @param [in] fileInterface   Interface for accessing files.\r\n\t *    @param [in] parent          The owner of this model.\r\n\t *\r\n\t */\r\n    FilesModel(LibraryInterface* handler,\r\n        QSharedPointer<Component> component,\r\n        FileInterface* fileInterface,\r\n        QObject* parent);\r\n\r\n\t/*!\r\n     *  The destructor.\r\n     */\r\n\t~FilesModel() = default;\r\n\r\n\t/*!\r\n     *  Get the number of rows an item contains.\r\n\t *\r\n\t *    @param [in] parent Identifies the parent that's row count is requested.\r\n\t *\r\n\t *    @return Number of rows the item has.\r\n\t */\r\n\tvirtual int rowCount(QModelIndex const& parent = QModelIndex()) const;\r\n\r\n\t/*!\r\n     *  Get the number of columns the item has to be displayed.\r\n\t *\r\n\t *    @param [in] parent Identifies the parent that's column count is requested.\r\n\t *\r\n\t *    @return The number of columns to be displayed.\r\n\t */\r\n\tvirtual int columnCount(QModelIndex const& parent = QModelIndex()) const;\r\n\r\n\t/*!\r\n     *  Get the item flags that defines the possible operations for the item.\r\n\t *\r\n\t *    @param [in] index Model index that identifies the item.\r\n\t *\r\n\t *    @return Flags specifying the possible operations for the item.\r\n\t */\r\n\tQt::ItemFlags flags(QModelIndex const& index) const;\r\n\r\n\t/*!\r\n     *  Get the header data for specified header.\r\n\t *\r\n\t *    @param [in] section     The section specifies the row/column number for the header.\r\n\t *    @param [in] orientation Specified if horizontal or vertical header is wanted.\r\n\t *    @param [in] role        Specifies the type of the requested data.\r\n\t *\r\n\t *    @return The requested data.\r\n\t */\r\n\tvirtual QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;\r\n\r\n\t/*!\r\n     *  Get the data for specified item.\r\n\t *\r\n\t *    @param [in] index    Specifies the item that's data is requested.\r\n\t *    @param [in] role     The role that defines what kind of data is requested.\r\n\t *\r\n\t *    @return  The data for the item.\r\n\t */\r\n\tvirtual QVariant data(QModelIndex const& index, int role = Qt::DisplayRole) const;\r\n\r\n\t/*!\r\n     *  Save the data to the model for specified item\r\n\t *\r\n\t *    @param [in] index   The model index of the item that's data is to be saved.\r\n\t *    @param [in] value   The data that is to be saved.\r\n\t *    @param [in] role    The role specifies what kind of data should be saved.\r\n\t *\r\n\t *    @return True if save was successful, otherwise false.\r\n\t */\r\n\tbool setData(QModelIndex const& index, const QVariant& value, int role = Qt::EditRole);\r\n    \r\n    /*!\r\n     *  Returns a list of supported MIME data types.\r\n     *\r\n     *    @return The supported MIME types.\r\n     */\r\n    virtual QStringList mimeTypes() const;\r\n   \r\n    /*!\r\n     *  Returns the supported actions of a drop.\r\n     *\r\n     *    @return The drop actions supported by the model.\r\n     */\r\n    virtual Qt::DropActions supportedDropActions() const;\r\n\r\n    /*!\r\n     *  Handler for the dropped MIME data.\r\n     *\r\n     *    @param [in] data    The data associated to the drop.\r\n     *    @param [in] action  The drop action.  \r\n     *    @param [in] row     The row beneath the drop position.\r\n     *    @param [in] column  The column beneath the drop position.\r\n     *    @param [in] parent  The parent index of the drop position.\r\n     *\r\n     *    @return True, if the model could handle the data, otherwise false.\r\n     */\r\n    virtual bool dropMimeData(QMimeData const* data, Qt::DropAction action, int row, int column, \r\n        QModelIndex const& parent);\r\n\r\npublic slots:\r\n\r\n\t/*!\r\n     *  Add a new item to the given index.\r\n\t *\r\n\t *    @param [in] index       The index identifying the position for new file.\r\n\t */\r\n    virtual void onAddItem(QModelIndex const& index);\r\n\r\n\t/*!\r\n     *  Add a new item to the given index.\r\n\t *\r\n\t *    @param [in] index       The index identifying the position for new file.\r\n\t *    @param [in] filePath    The file path to the file to be added.\r\n\t */\r\n\tvirtual void onAddItem(QModelIndex const& index, const QString& filePath);\r\n\r\n\t/*!\r\n     *  Remove the item in the given index.\r\n\t *\r\n\t *    @param [in] index The index identifying the item to remove.\r\n\t */\r\n\tvirtual void onRemoveItem(QModelIndex const& index);\r\n\r\n\t/*!\r\n     *  Move item from one position to another.\r\n\t *\r\n\t *    @param [in] originalPos The index identifying which item to move.\r\n\t *    @param [in] newPos The position to move the item to.\r\n\t */\r\n\tvirtual void onMoveItem(QModelIndex const& originalPos, QModelIndex const& newPos);\r\n\r\nsignals:\r\n\r\n\t//! Emitted when the model changes.\r\n\tvoid contentChanged();\r\n\r\n\t//! Emitted when a file is added to the list.\r\n\tvoid fileAdded(int index);\r\n\r\n\t//! Emitted when a file is removed from the list.\r\n\tvoid fileRemoved(int index);\r\n\r\n\t//! Emitted when a file is moved from one position to another.\r\n\tvoid fileMoved(int source, int target);\r\n\r\n    /*!\r\n     *  Informs of a file name change.\r\n     *\r\n     *    @param [in] oldName     Old name of the file.\r\n     *    @param [in] newName     New name of the file.\r\n     */\r\n    void fileRenamed(std::string const& oldName, std::string const& newName);\r\n\r\nprivate:\r\n\t//! No copying\r\n\tFilesModel(const FilesModel& other);\r\n\tFilesModel& operator=(const FilesModel& other);\r\n\r\n    /*!\r\n     *  Get the file types of the selected file as a combined string.\r\n     *\r\n     *    @param [in] fileName    Name of the selected file.\r\n     *\r\n     *    @return File types of the selected file as a combined string.\r\n     */\r\n    QString getFileTypesString(std::string const& fileName) const;\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n\t//! The instance that manages the library.\r\n\tLibraryInterface* handler_;\r\n\r\n\t//! The component being edited.\r\n\tQSharedPointer<Component> component_;\r\n\r\n    //! Interface for accessing files.\r\n    FileInterface* fileInterface_;\r\n};\r\n\r\n#endif // FILESMODEL_H\r\n"
  },
  {
    "path": "editors/ComponentEditor/fileSet/file/filesview.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: filesview.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 4.6.2012\r\n//\r\n// Description:\r\n// The view to display the files contained in a file set.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"filesview.h\"\r\n\r\n#include <KactusAPI/include/LibraryInterface.h>\r\n\r\n#include <IPXACTmodels/Component/Component.h>\r\n\r\n#include <QFileDialog>\r\n#include <QMenu>\r\n#include <QSortFilterProxyModel>\r\n#include <QStringList>\r\n\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: filesview::FilesView()\r\n//-----------------------------------------------------------------------------\r\nFilesView::FilesView(LibraryInterface* handler, QSharedPointer<Component> component, QWidget *parent):\r\nEditableTableView(parent),\r\nhandler_(handler),\r\ncomponent_(component),\r\naddByBrowsingAction_(new QAction(tr(\"Add file(s)...\"), this))\r\n{\r\n    connect(addByBrowsingAction_, SIGNAL(triggered()), this, SIGNAL(addItemByBrowsing()), Qt::UniqueConnection);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: filesview::~FilesView()\r\n//-----------------------------------------------------------------------------\r\nFilesView::~FilesView()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FilesView::contextMenuEvent()\r\n//-----------------------------------------------------------------------------\r\nvoid FilesView::contextMenuEvent(QContextMenuEvent* event)\r\n{\r\n    pressedPoint_ = event->pos();\r\n\r\n    QModelIndex index = indexAt(pressedPoint_);\r\n\r\n    QMenu menu(this);\r\n\r\n    menu.addAction(addByBrowsingAction_);\r\n    menu.addSeparator();\r\n    menu.addAction(&addAction_);\r\n\r\n    // if at least one valid item is selected\r\n    if (index.isValid())\r\n    {\r\n        menu.addAction(&removeAction_);\r\n        menu.addAction(&clearAction_);\r\n        menu.addAction(&copyAction_);\r\n        menu.addAction(&pasteAction_);\r\n    }\r\n\r\n    if (importExportAllowed())\r\n    {\r\n        menu.addSeparator();\r\n        menu.addAction(&importAction_);\r\n        menu.addAction(&exportAction_);\r\n    }\r\n\r\n    menu.exec(event->globalPos());\r\n\r\n    event->accept();\r\n}\r\n"
  },
  {
    "path": "editors/ComponentEditor/fileSet/file/filesview.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: filesview.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 4.6.2012\r\n//\r\n// Description:\r\n// The view to display the files contained in a file set.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef FILESVIEW_H\r\n#define FILESVIEW_H\r\n\r\n#include <common/views/EditableTableView/editabletableview.h>\r\n\r\n#include <QAction>\r\n#include <QMouseEvent>\r\n#include <QSharedPointer>\r\n\r\nclass LibraryInterface;\r\nclass Component;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! The view to display the files contained in a file set.\r\n//-----------------------------------------------------------------------------\r\nclass FilesView : public EditableTableView\r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\r\n\t/*!\r\n     *  The constructor.\r\n\t * \r\n\t *    @param [in] handler     Pointer to the instance that manages the library.\r\n\t *    @param [in] component   Pointer to the component being edited.\r\n\t *    @param [in] parent      Pointer to the owner of this view.\r\n\t */\r\n\tFilesView(LibraryInterface* handler, QSharedPointer<Component> component, QWidget *parent);\r\n\t\r\n\t//! The destructor.\r\n\tvirtual ~FilesView();\r\n\r\nsignals:\r\n\r\n    //! Emitted when a new file should be added by file browsing.\r\n    void addItemByBrowsing();\r\n\r\nprotected:\r\n\r\n\t//! Handler for context menu events.\r\n    virtual void contextMenuEvent(QContextMenuEvent* event);\r\n\r\nprivate:\r\n\t\r\n\t//! No copying. No assignment.\r\n\tFilesView(const FilesView& other);\r\n\tFilesView& operator=(const FilesView& other);\r\n\r\n\t//! The instance that manages the library.\r\n\tLibraryInterface* handler_;\r\n\r\n\t//! The component being edited.\r\n\tQSharedPointer<Component> component_;\r\n\r\n    //! Action for adding new files by browsing.\r\n    QAction* addByBrowsingAction_;\r\n};\r\n\r\n#endif // FILESVIEW_H\r\n"
  },
  {
    "path": "editors/ComponentEditor/fileSet/file/filetypeeditor.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: filetypeeditor.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 7.2.2011\r\n//\r\n// Description:\r\n// FileTypeEditor is used to specify a file type for a file.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"filetypeeditor.h\"\r\n#include \"filetypeeditordelegate.h\"\r\n\r\n#include <common/dialogs/comboSelector/comboselector.h>\r\n\r\n#include <KactusAPI/include/FileInterface.h>\r\n\r\n#include <IPXACTmodels/Component/File.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: filetypeeditor::FileTypeEditor()\r\n//-----------------------------------------------------------------------------\r\nFileTypeEditor::FileTypeEditor(Document::Revision docRevision, QWidget *parent, std::string const& fileName, FileInterface* fileInterface):\r\nListManager(tr(\"File types\"), parent), \r\nfileName_(fileName),\r\nfileInterface_(fileInterface),\r\nrevision_(docRevision)\r\n{\r\n    setFlat(true);\r\n    Q_ASSERT_X(fileInterface_, \"FileTypeEditor constructor\", \"Null File interface-pointer given as parameter\");\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: filetypeeditor::apply()\r\n//-----------------------------------------------------------------------------\r\nvoid FileTypeEditor::apply()\r\n{\r\n\t// get all items from the model\r\n\tQStringList items = model_->items();\r\n\r\n\t// remove all previous file types and userFileTypes from the model\r\n    fileInterface_->clearFileTypes(fileName_);\r\n\r\n    for (QString const& fileType : items)\r\n    {\r\n        fileInterface_->addFileType(fileName_, fileType.toStdString());\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: filetypeeditor::()\r\n//-----------------------------------------------------------------------------\r\nvoid FileTypeEditor::restore()\r\n{\r\n    QStringList fileTypes;\r\n    std::vector<std::string> types = fileInterface_->getFileTypes(fileName_);\r\n    for (auto const& singleType : types)\r\n    {\r\n        fileTypes.append(QString::fromStdString(singleType));\r\n    }\r\n\r\n\tmodel_->setItems(fileTypes);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: filetypeeditor::isValid()\r\n//-----------------------------------------------------------------------------\r\nbool FileTypeEditor::isValid() const\r\n{\r\n\t// at least one file type has to be specified\r\n\tif (model_->rowCount() <= 0)\r\n    {\r\n\t\treturn false;\r\n\t}\r\n\r\n\treturn !model_->items().contains(\"\");\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: filetypeeditor::initialize()\r\n//-----------------------------------------------------------------------------\r\nvoid FileTypeEditor::initialize(QStringList const& items)\r\n{\r\n\tListManager::initialize(items);\r\n\r\n\tview_->setProperty(\"mandatoryField\", true);\r\n\r\n\tview_->setItemDelegate(new FileTypeEditorDelegate(revision_, this));\r\n\r\n\trestore();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileTypeEditor::fileRenamed()\r\n//-----------------------------------------------------------------------------\r\nvoid FileTypeEditor::fileRenamed(std::string const& newName)\r\n{\r\n    fileName_ = newName;\r\n}\r\n"
  },
  {
    "path": "editors/ComponentEditor/fileSet/file/filetypeeditor.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: filetypeeditor.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 7.2.2011\r\n//\r\n// Description:\r\n// FileTypeEditor is used to specify a file type for a file.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef FILETYPEEDITOR_H\r\n#define FILETYPEEDITOR_H\r\n\r\n#include <common/widgets/listManager/listmanager.h>\r\n\r\n#include <IPXACTmodels/common/Document.h>\r\n\r\n#include <QSharedPointer>\r\n\r\nclass File;\r\nclass FileInterface;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! FileTypeEditor is used to specify a file type for a file.\r\n//-----------------------------------------------------------------------------\r\nclass FileTypeEditor : public ListManager\r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\r\n\t/*!\r\n     *  The constructor.\r\n\t *\r\n\t *    @param [in] parent          Pointer to the owner of this widget\r\n\t *    @param [in] fileName        Name of the file being edited\r\n     *    @param [in] fileInterface   Interface for accessing files.\r\n\t */\r\n    FileTypeEditor(Document::Revision docRevision, QWidget *parent, std::string const& fileName, FileInterface* fileInterface);\r\n\r\n\t/*!\r\n     *  The destructor.\r\n     */\r\n\tvirtual ~FileTypeEditor() = default;\r\n\r\n\t/*!\r\n     *  Initialize the file type editor.\r\n\t *\r\n\t * This function must be called after creating the file type editor and before using it.\r\n\t * \r\n\t *    @param [in] items   QStringList that contains the items to add to the widget.\r\n\t */\r\n\tvirtual void initialize(const QStringList& items = QStringList());\r\n\r\n\t/*!\r\n     *  Apply the changes from the editor to the model.\r\n\t */\r\n\tvoid apply();\r\n\r\n\t/*!\r\n     *  Restore the changes from the model to the editor.\r\n\t */\r\n\tvoid restore();\r\n\r\n\t/*!\r\n     *  Check if the editor is in a valid state or not.\r\n\t *\r\n\t *    @return True if the editor is in valid state\r\n\t */\r\n\tbool isValid() const;\r\n\r\n    /*!\r\n     *  Handle the name change of the containing file.\r\n     *\r\n     *    @param [in] newName     The new name of the file.\r\n     */\r\n    void fileRenamed(std::string const& newName);\r\n\r\nprivate:\r\n\r\n\t//! No copying. No assignment. No quarter.\r\n\tFileTypeEditor(const FileTypeEditor& other);\r\n\tFileTypeEditor& operator=(const FileTypeEditor& other);\r\n\r\n\t//! Name of the file-model being edited.\r\n    std::string fileName_;\r\n\r\n    //! Interface for accessing files.\r\n    FileInterface* fileInterface_;\r\n\r\n\tDocument::Revision revision_;\r\n};\r\n\r\n#endif // FILETYPEEDITOR_H\r\n"
  },
  {
    "path": "editors/ComponentEditor/fileSet/file/filetypeeditordelegate.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: filetypeeditordelegate.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 07.12.2011\r\n//\r\n// Description:\r\n// Provides editor to select a type for a file.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"filetypeeditordelegate.h\"\r\n\r\n#include <common/widgets/assistedLineEdit/AssistedLineEdit.h>\r\n\r\n#include <IPXACTmodels/common/FileType.h>\r\n\r\n#include <QStringList>\r\n#include <QSettings>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileTypeEditorDelegate::FileTypeEditorDelegate()\r\n//-----------------------------------------------------------------------------\r\nFileTypeEditorDelegate::FileTypeEditorDelegate(Document::Revision docRevision, QObject *parent):\r\nQStyledItemDelegate(parent),\r\n    revision_(docRevision)\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileTypeEditorDelegate::~FileTypeEditorDelegate()\r\n//-----------------------------------------------------------------------------\r\nFileTypeEditorDelegate::~FileTypeEditorDelegate()\r\n{\r\n    delete matcher_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileTypeEditorDelegate::createEditor()\r\n//-----------------------------------------------------------------------------\r\nQWidget* FileTypeEditorDelegate::createEditor(QWidget* parent, QStyleOptionViewItem const& /*option*/,\r\n\tQModelIndex const& /*index*/ ) const\r\n{\r\n    AssistedLineEdit* editor = new AssistedLineEdit(parent->window(), parent);\r\n\r\n    updateSuggestedItems();\r\n    editor->setContentMatcher(matcher_);\r\n    \r\n\treturn editor;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileTypeEditorDelegate::setEditorData()\r\n//-----------------------------------------------------------------------------\r\nvoid FileTypeEditorDelegate::setEditorData(QWidget* editor, QModelIndex const& index) const\r\n{\r\n\tQString text = index.model()->data(index, Qt::EditRole).toString();\r\n\r\n\tAssistedLineEdit* assistedEditor = qobject_cast<AssistedLineEdit*>(editor);\r\n\tQ_ASSERT(assistedEditor);\r\n\r\n\tassistedEditor->setText(text);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileTypeEditorDelegate::setModelData()\r\n//-----------------------------------------------------------------------------\r\nvoid FileTypeEditorDelegate::setModelData(QWidget* editor, QAbstractItemModel* model,\r\n    QModelIndex const& index) const\r\n{\r\n\tAssistedLineEdit* assistedEditor = qobject_cast<AssistedLineEdit*>(editor);\r\n\tQ_ASSERT(assistedEditor);\r\n\r\n\tmodel->setData(index, assistedEditor->text(), Qt::EditRole);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileTypeEditorDelegate::updateSuggestedItems()\r\n//-----------------------------------------------------------------------------\r\nvoid FileTypeEditorDelegate::updateSuggestedItems() const\r\n{\r\n    QSettings settings;\r\n    settings.beginGroup(\"FileTypes\");\r\n    QStringList typeNames = settings.childGroups();\r\n    settings.endGroup();\r\n\r\n    typeNames.append(FileTypes::FILE_TYPES);\r\n    if (revision_ == Document::Revision::Std22)\r\n    {\r\n        typeNames.append(FileTypes::FILE_TYPES_2022);\r\n    }\r\n    typeNames.removeDuplicates();\r\n\r\n    matcher_->setItems(typeNames);\r\n}\r\n"
  },
  {
    "path": "editors/ComponentEditor/fileSet/file/filetypeeditordelegate.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: filetypeeditordelegate.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 07.12.2011\r\n//\r\n// Description:\r\n// Provides editor to select a type for a file.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef FILETYPEEDITORDELEGATE_H\r\n#define FILETYPEEDITORDELEGATE_H\r\n\r\n#include <QStyledItemDelegate>\r\n\r\n#include <IPXACTmodels/common/Document.h>\r\n\r\n#include <common/widgets/assistedLineEdit/BasicLineContentMatcher.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Provides editor to select a type for a file.\r\n//-----------------------------------------------------------------------------\r\nclass FileTypeEditorDelegate : public QStyledItemDelegate\r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\r\n\t/*! The constructor\r\n\t *\r\n\t *    @param [in] parent  The owner of this delegate.\r\n\t *\r\n\t*/\r\n\tFileTypeEditorDelegate(Document::Revision docRevision, QObject *parent);\r\n\t\r\n\t//! The destructor\r\n\tvirtual ~FileTypeEditorDelegate();\r\n\r\n\t/*! Create a new editor for the given item\r\n\t *\r\n\t *    @param [in] parent  Owner for the editor.\r\n\t *    @param [in] option  Contains options for the editor.\r\n\t *    @param [in] index   Model index identifying the item.\r\n\t *\r\n\t *    @return The editor to be used to edit the item.\r\n\t */\r\n\tvirtual QWidget* createEditor(QWidget* parent, QStyleOptionViewItem const& option, \r\n\t\tQModelIndex const& index) const;\r\n\r\n\t/*! Set the data for the editor.\r\n\t *\r\n\t *    @param [in] editor  The editor where the data is to be set.\r\n\t *    @param [in] index   Model index identifying the item that's data is to be set.\r\n\t */\r\n\tvirtual void setEditorData(QWidget* editor, QModelIndex const& index) const;\r\n\r\n\t/*! Save the data from the editor to the model.\r\n\t *\r\n\t *    @param [in] editor  The editor that contains the data to store.\r\n\t *    @param [in] model   Model that contains the data structure where data is to be saved to.\r\n\t *    @param [in] index   Model index identifying the item that's data is to be saved.\r\n\t */\r\n\tvirtual void setModelData(QWidget* editor, QAbstractItemModel* model, QModelIndex const& index) const;\r\n\r\nprivate:\r\n\r\n\t//! No copying\r\n\tFileTypeEditorDelegate(const FileTypeEditorDelegate& other);\r\n    FileTypeEditorDelegate& operator=(const FileTypeEditorDelegate& other);\r\n\r\n    //! Updates the suggested file types.\r\n    void updateSuggestedItems() const;\r\n\r\n    //! Matcher for assisting editing with type suggestions.\r\n    BasicLineContentMatcher* matcher_ = new BasicLineContentMatcher;\r\n\r\n\tDocument::Revision revision_;\r\n};\r\n\r\n#endif // FILETYPEEDITORDELEGATE_H\r\n"
  },
  {
    "path": "editors/ComponentEditor/fileSet/fileseteditor.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: fileseteditor.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 03.02.2011\r\n//\r\n// Description:\r\n// FileSetEditor is an editor used to edit the details of a FileSet.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"fileseteditor.h\"\r\n\r\n#include <KactusAPI/include/LibraryInterface.h>\r\n\r\n#include <IPXACTmodels/Component/Component.h>\r\n#include <IPXACTmodels/Component/FileSet.h>\r\n\r\n#include <KactusAPI/include/FileSetInterface.h>\r\n\r\n#include <QGridLayout>\r\n#include <QScrollArea>\r\n#include <QStringList>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileSetEditor::FileSetEditor()\r\n//-----------------------------------------------------------------------------\r\nFileSetEditor::FileSetEditor(LibraryInterface* handler, QSharedPointer<Component> component,\r\n    QSharedPointer<FileSet> fileSet, QSharedPointer<ParameterFinder> parameterFinder,\r\n    QSharedPointer<ExpressionParser> expressionParser, QSharedPointer<ExpressionFormatter> expressionFormatter,\r\n    FileSetInterface* fileSetInterface, QWidget *parent):\r\nItemEditor(component, handler, parent),\r\nbaseLocation_(handler->getPath(component->getVlnv())),\r\nnameEditor_(fileSet, component->getRevision(), this),\r\ngroupsEditor_(tr(\"Group identifiers\"), this),\r\nfileBuilderEditor_(fileSetInterface->getFileBuilderInterface(), parameterFinder, expressionParser,\r\n    expressionFormatter, fileSet->getDefaultFileBuilders(), this),\r\nfiles_(fileSet->getFiles(), fileSetInterface->getFileInterface(), component, handler, this),\r\ndependencies_(tr(\"Dependent directories\"), handler->getDirectoryPath(component->getVlnv()), this),\r\nfileSetInterface_(fileSetInterface),\r\navailableFileSets_(component->getFileSets())\r\n{\r\n    nameEditor_.setTitle(\"File set name and description\");\r\n\r\n    groupsEditor_.setFlat(true);\r\n    fileBuilderEditor_.setFlat(true);\r\n    dependencies_.setFlat(true);\r\n\r\n    setupLayout();\r\n\r\n    connectSignals();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileSetEditor::~FileSetEditor()\r\n//-----------------------------------------------------------------------------\r\nFileSetEditor::~FileSetEditor()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileSetEditor::refresh()\r\n//-----------------------------------------------------------------------------\r\nvoid FileSetEditor::refresh()\r\n{\r\n    fileSetInterface_->setFileSets(availableFileSets_);\r\n\r\n\t// set the values for the nameGroupBox\r\n\tnameEditor_.refresh();\r\n\r\n    QStringList fileSetGroups;\r\n    for (auto singleGroup : fileSetInterface_->getGroups(nameEditor_.name().toStdString()))\r\n    {\r\n        fileSetGroups.append(QString::fromStdString(singleGroup));\r\n    }\r\n\r\n\t// initialize groups \r\n    groupsEditor_.initialize(fileSetGroups);\r\n\r\n\tfiles_.refresh();\r\n\r\n\tfileBuilderEditor_.refresh();\r\n\r\n\t// initialize dependencies\r\n    QStringList fileSetDependencies;\r\n    for (auto singleDependency : fileSetInterface_->getDependencies(nameEditor_.name().toStdString()))\r\n    {\r\n        fileSetDependencies.append(QString::fromStdString(singleDependency));\r\n    }\r\n\r\n    dependencies_.initialize(fileSetDependencies);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileSetEditor::onGroupsChange()\r\n//-----------------------------------------------------------------------------\r\nvoid FileSetEditor::onGroupsChange()\r\n{\r\n    std::vector<std::string> newGroups;\r\n    for (auto group : groupsEditor_.items())\r\n    {\r\n        newGroups.push_back(group.toStdString());\r\n    }\r\n\r\n    fileSetInterface_->setGroups(nameEditor_.name().toStdString(), newGroups);\r\n\r\n\temit contentChanged();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileSetEditor::onDependenciesChange()\r\n//-----------------------------------------------------------------------------\r\nvoid FileSetEditor::onDependenciesChange()\r\n{\r\n    std::vector<std::string> newDependencies;\r\n    for (auto dependency : dependencies_.items())\r\n    {\r\n        newDependencies.push_back(dependency.toStdString());\r\n    }\r\n\r\n    fileSetInterface_->setDependencies(nameEditor_.name().toStdString(), newDependencies);\r\n\r\n\temit contentChanged();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileSetEditor::showEvent()\r\n//-----------------------------------------------------------------------------\r\nvoid FileSetEditor::showEvent(QShowEvent* event)\r\n{\r\n\tQWidget::showEvent(event);\r\n\r\n    if (component()->getRevision() == Document::Revision::Std22)\r\n    {\r\n        emit helpUrlRequested(\"componenteditor/fileset2022.html\");\r\n    }\r\n    else\r\n    {\r\n        emit helpUrlRequested(\"componenteditor/fileset.html\");\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileSetEditor::setupLayout()\r\n//-----------------------------------------------------------------------------\r\nvoid FileSetEditor::setupLayout()\r\n{\r\n    QScrollArea* scrollArea = new QScrollArea(this);\r\n    scrollArea->setWidgetResizable(true);\r\n    scrollArea->setFrameShape(QFrame::NoFrame);\r\n    scrollArea->setContentsMargins(0, 0, 0, 0);\r\n\r\n    QVBoxLayout* scrollLayout = new QVBoxLayout(this);\r\n    scrollLayout->addWidget(scrollArea);\r\n    scrollLayout->setContentsMargins(0, 0, 0, 0);\r\n\r\n    QWidget* topWidget = new QWidget(scrollArea);\r\n\r\n    QGridLayout* topLayout = new QGridLayout(topWidget);\r\n    topLayout->setContentsMargins(0, 0, 0, 0);\r\n\r\n    topLayout->addWidget(&nameEditor_, 0, 0, 1, 1);\r\n    topLayout->addWidget(&groupsEditor_, 0, 1, 1, 1);\r\n    topLayout->addWidget(&files_, 1, 0, 1, 2);    \r\n    topLayout->addWidget(&fileBuilderEditor_, 2, 0, 1, 2);\r\n    topLayout->addWidget(&dependencies_, 3, 0, 1, 1);\r\n    topLayout->setRowStretch(0, 1);\r\n    topLayout->setRowStretch(1, 4);\r\n    topLayout->setRowStretch(2, 2);\r\n    topLayout->setRowStretch(3, 1);\r\n\r\n    scrollArea->setWidget(topWidget);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: fileseteditor::connectSignals()\r\n//-----------------------------------------------------------------------------\r\nvoid FileSetEditor::connectSignals()\r\n{\r\n    connect(&nameEditor_, SIGNAL(contentChanged()), this, SIGNAL(contentChanged()), Qt::UniqueConnection);\r\n\r\n    connect(&files_, SIGNAL(contentChanged()), this, SIGNAL(contentChanged()), Qt::UniqueConnection);\r\n    connect(&files_, SIGNAL(fileAdded(int)), this, SIGNAL(childAdded(int)), Qt::UniqueConnection);\r\n    connect(&files_, SIGNAL(fileRemoved(int)),this, SIGNAL(childRemoved(int)), Qt::UniqueConnection);\r\n    connect(&files_, SIGNAL(fileMoved(int, int)), this, SIGNAL(childMoved(int, int)), Qt::UniqueConnection);\r\n\r\n    connect(&fileBuilderEditor_, SIGNAL(contentChanged()), this, SIGNAL(contentChanged()), Qt::UniqueConnection);\r\n\r\n    connect(&groupsEditor_, SIGNAL(contentChanged()),\tthis, SLOT(onGroupsChange()), Qt::UniqueConnection);\r\n\r\n    connect(&dependencies_, SIGNAL(contentChanged()), this, SLOT(onDependenciesChange()), Qt::UniqueConnection);\r\n\r\n    connect(&fileBuilderEditor_, SIGNAL(increaseReferences(QString)),\r\n        this, SIGNAL(increaseReferences(QString)), Qt::UniqueConnection);\r\n    connect(&fileBuilderEditor_, SIGNAL(decreaseReferences(QString)),\r\n        this, SIGNAL(decreaseReferences(QString)), Qt::UniqueConnection);\r\n\r\n    connect(&files_, SIGNAL(fileRenamed(std::string const&, std::string const&)),\r\n        this, SIGNAL(fileRenamed(std::string const&, std::string const&)), Qt::UniqueConnection);\r\n}\r\n"
  },
  {
    "path": "editors/ComponentEditor/fileSet/fileseteditor.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: fileseteditor.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 03.02.2011\r\n//\r\n// Description:\r\n// FileSetEditor is an editor used to edit the details of a FileSet.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef FILESETEDITOR_H\r\n#define FILESETEDITOR_H\r\n\r\n#include \"groupmanager.h\"\r\n\r\n#include <editors/ComponentEditor/itemeditor.h>\r\n#include <editors/ComponentEditor/fileSet/file/fileseditor.h>\r\n#include <editors/ComponentEditor/fileBuilders/filebuilderseditor.h>\r\n\r\n#include <common/widgets/nameGroupEditor/namegroupeditor.h>\r\n#include <common/widgets/listManager/dirlistmanager.h>\r\n\r\n#include <QWidget>\r\n#include <QFileInfo>\r\n#include <QSharedPointer>\r\n#include <QString>\r\n\r\nclass LibraryInterface;\r\nclass FileSet;\r\nclass ExpressionParser;\r\nclass ExpressionFormatter;\r\nclass ParameterFinder;\r\nclass FileSetInterface;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! FileSetEditor is a widget to edit the details of a FileSet.\r\n//-----------------------------------------------------------------------------\r\nclass FileSetEditor : public ItemEditor\r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\r\n\t/*!\r\n     *  The constructor.\r\n\t *\r\n\t *    @param [in] handler                 Pointer to the instance that manages the library.\r\n\t *    @param [in] component               Pointer to the component model that is being edited.\r\n     *    @param [in] fileSet                 The edited fileset.\r\n     *    @param [in] parameterFinder         Finder used to identify parameters.\r\n     *    @param [in] expressionParser        Parser used to calculate expressions.\r\n     *    @param [in] expressionFormatter     Formatter used to format expressions.\r\n     *    @param [in] fileSetInterface        Interface for accessing file sets.\r\n\t *    @param [in] parent                  Pointer to the owner of this widget.\r\n\t */\r\n    FileSetEditor(LibraryInterface* handler,\r\n        QSharedPointer<Component> component,\r\n        QSharedPointer<FileSet> fileSet,\r\n        QSharedPointer<ParameterFinder> parameterFinder,\r\n        QSharedPointer<ExpressionParser> expressionParser,\r\n        QSharedPointer<ExpressionFormatter> expressionFormatter,\r\n        FileSetInterface* fileSetInterface,\r\n        QWidget *parent);\r\n\r\n\t//! The destructor.\r\n\tvirtual ~FileSetEditor();\r\n\r\n\t//! Reload the information from the model to the editor.\r\n\tvirtual void refresh();\r\n\r\nprotected:\r\n\r\n\t//! Handler for widget's show event.\r\n\tvirtual void showEvent(QShowEvent* event);\r\n\r\nsignals:\r\n\r\n    /*!\r\n     *  Handle the name change of a file.\r\n     *\r\n     *    @param [in] oldName     Old name of the selected file.\r\n     *    @param [in] newName     The new name for the selected file.\r\n     */\r\n    void fileRenamed(std::string const& oldName, std::string const& newName);\r\n\r\nprivate slots:\r\n\r\n\t/*!\r\n     *  Handler for changes in the group manager.\r\n\t */\r\n\tvoid onGroupsChange();\r\n\r\n\t//! Handler for changes in the dependency manager.\r\n\tvoid onDependenciesChange();\r\n\r\nprivate:\r\n\r\n\t//! No copying. No assignment.\r\n\tFileSetEditor(const FileSetEditor& other);\r\n\tFileSetEditor& operator=(const FileSetEditor& other);\r\n\r\n    /*!\r\n     *  Setup the layout for file set editor.\r\n     */\r\n    void setupLayout();\r\n\r\n    /*!\r\n     *  Connect the signals.\r\n     */\r\n    void connectSignals();\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! Refers to the location of the base xml-file.\r\n\tQFileInfo baseLocation_;\r\n\r\n\t//! Used to edit the name, display name and description.\r\n\tNameGroupEditor nameEditor_;\r\n\r\n\t//! Used to manage groups of FileSet.\r\n\tGroupManager groupsEditor_;\r\n\r\n\t//! Used to edit the default file builders of file set.\r\n\tFileBuildersEditor fileBuilderEditor_;\r\n\r\n\t//! The editor to add/remove/edit the files of file set.\r\n\tFilesEditor files_;\r\n\r\n\t//! Used to manage dependencies of the FileSet.\r\n\tDirListManager dependencies_;\r\n\r\n    //! Interface for accessing file sets.\r\n    FileSetInterface* fileSetInterface_;\r\n\r\n    //! List of the available file sets.\r\n    QSharedPointer<QList<QSharedPointer<FileSet> > > availableFileSets_;\r\n};\r\n\r\n#endif // FILESETEDITOR_H\r\n"
  },
  {
    "path": "editors/ComponentEditor/fileSet/filesetsdelegate.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: filesetsdelegate.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 29.5.2012\r\n//\r\n// Description:\r\n// The delegate class to provide editors for file sets editor.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"filesetsdelegate.h\"\r\n\r\n#include <common/widgets/listManager/listeditor.h>\r\n#include <editors/ComponentEditor/fileSet/groupmanagerdelegate.h>\r\n\r\n#include <QStringList>\r\n#include <QLineEdit>\r\n#include <QTextEdit>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileSetsDelegate::FileSetsDelegate()\r\n//-----------------------------------------------------------------------------\r\nFileSetsDelegate::FileSetsDelegate(QObject *parent):\r\nMultilineDescriptionDelegate(parent)\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileSetsDelegate::~FileSetsDelegate()\r\n//-----------------------------------------------------------------------------\r\nFileSetsDelegate::~FileSetsDelegate()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileSetsDelegate::createEditor()\r\n//-----------------------------------------------------------------------------\r\nQWidget* FileSetsDelegate::createEditor(QWidget* parent, const QStyleOptionViewItem& option,\r\n    QModelIndex const& index ) const\r\n{\r\n\tif (index.column() == NAME_COLUMN)\r\n    {\r\n        QLineEdit* edit = new QLineEdit(parent);\r\n        connect(edit, SIGNAL(editingFinished()), this, SLOT(commitAndCloseEditor()), Qt::UniqueConnection);\r\n        return edit;\r\n    }\r\n    else if (index.column() == GROUP_COLUMN)\r\n    {\r\n        ListEditor* editor = new ListEditor(parent);\r\n        editor->setMinimumHeight(FileSetsDelegate::LIST_EDITOR_MIN_HEIGHT);\r\n        \r\n        // set the editing delegate for the editor\r\n        GroupManagerDelegate* groupDelegate = new GroupManagerDelegate(parent);\r\n        editor->setItemDelegate(groupDelegate);\r\n\r\n        return editor;\r\n    }\r\n    else\r\n    {\r\n        return MultilineDescriptionDelegate::createEditor(parent, option, index);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileSetsDelegate::setEditorData()\r\n//-----------------------------------------------------------------------------\r\nvoid FileSetsDelegate::setEditorData(QWidget* editor, QModelIndex const& index) const\r\n{\r\n    if (index.column() == NAME_COLUMN)\r\n    {\r\n        QLineEdit* edit = qobject_cast<QLineEdit*>(editor);\r\n        const QString text = index.data(Qt::DisplayRole).toString();\r\n        edit->setText(text);\r\n    }\r\n    else if (index.column() == GROUP_COLUMN)\r\n    {\r\n        ListEditor* listEditor = qobject_cast<ListEditor*>(editor);\r\n        Q_ASSERT(listEditor);\r\n        QStringList groups = index.data(Qt::DisplayRole).toString().split(' ', Qt::SkipEmptyParts);\r\n        listEditor->setItems(groups);\r\n    }\r\n    else\r\n    {\r\n        MultilineDescriptionDelegate::setEditorData(editor, index);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileSetsDelegate::setModelData()\r\n//-----------------------------------------------------------------------------\r\nvoid FileSetsDelegate::setModelData( QWidget* editor, QAbstractItemModel* model, QModelIndex const& index ) const\r\n{\t\r\n    if (index.column() == NAME_COLUMN)\r\n    {\r\n        QLineEdit* edit = qobject_cast<QLineEdit*>(editor);\r\n        Q_ASSERT(edit);\r\n\r\n        QString text = edit->text();\r\n        model->setData(index, text, Qt::EditRole);\r\n    }\r\n    else if (index.column() == GROUP_COLUMN)\r\n    {\r\n        ListEditor* listEditor = qobject_cast<ListEditor*>(editor);\r\n        Q_ASSERT(listEditor);\r\n\r\n        QStringList groups = listEditor->items();\r\n        model->setData(index, groups.join(' '), Qt::EditRole);\r\n    }\r\n    else\r\n    {\r\n        MultilineDescriptionDelegate::setModelData(editor, model, index);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileSetsDelegate::descriptionColumn()\r\n//-----------------------------------------------------------------------------\r\nint FileSetsDelegate::descriptionColumn() const\r\n{\r\n    return DESC_COLUMN;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileSetsDelegate::commitAndCloseEditor()\r\n//-----------------------------------------------------------------------------\r\nvoid FileSetsDelegate::commitAndCloseEditor()\r\n{\r\n\tQWidget* edit = qobject_cast<QWidget*>(sender());\r\n\tQ_ASSERT(edit);\r\n\r\n\temit commitData(edit);\r\n\temit closeEditor(edit);\r\n}\r\n"
  },
  {
    "path": "editors/ComponentEditor/fileSet/filesetsdelegate.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: filesetsdelegate.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 29.5.2012\r\n//\r\n// Description:\r\n// The delegate class to provide editors for file sets editor.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef FILESETSDELEGATE_H\r\n#define FILESETSDELEGATE_H\r\n\r\n#include <editors/ComponentEditor/common/MultilineDescriptionDelegate.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n//! The delegate class to provide editors for file sets editor.\r\n//-----------------------------------------------------------------------------\r\nclass FileSetsDelegate : public MultilineDescriptionDelegate\r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\r\n\t//! The column number for name field.\r\n\tstatic const int NAME_COLUMN = 0;\r\n\r\n\t//! The column number for group identifiers.\r\n\tstatic const int GROUP_COLUMN = 1;\r\n\r\n    //! The column number for description field.\r\n    static const int DESC_COLUMN = 2;\r\n\r\n\t//! The minimum height for the custom list editor.\r\n\tstatic const int LIST_EDITOR_MIN_HEIGHT = 100;\r\n\r\n\t/*!\r\n     *  The constructor\r\n\t *\r\n\t *    @param [in] parent Pointer to the owner of the delegate.\r\n\t */\r\n\tFileSetsDelegate(QObject *parent);\r\n\t\r\n\t//! The destructor\r\n\t~FileSetsDelegate();\r\n\r\n\t/*!\r\n     *  Create a new editor for the given item\r\n\t *\r\n\t *    @param [in] parent  Owner for the editor.\r\n\t *    @param [in] option  Contains options for the editor.\r\n\t *    @param [in] index   Model index identifying the item.\r\n\t *\r\n\t *    @return Pointer to the editor to be used to edit the item.\r\n\t */\r\n\tvirtual QWidget* createEditor(QWidget* parent, QStyleOptionViewItem const& option, QModelIndex const& index)\r\n        const;\r\n\r\n\t/*!\r\n     *  Set the data for the editor.\r\n\t *\r\n\t *    @param [in] editor  The editor where the data is to be set.\r\n\t *    @param [in] index   Model index identifying the item that's data is to be set.\r\n\t */\r\n\tvirtual void setEditorData(QWidget* editor, QModelIndex const& index) const;\r\n\r\n\t/*!\r\n     *  Save the data from the editor to the model.\r\n\t *\r\n\t *    @param [in] editor  The editor that contains the data to store.\r\n\t *    @param [in] model   Model that contains the data structure where data is to be saved to.\r\n\t *    @param [in] index   Model index identifying the item that's data is to be saved.\r\n\t */\r\n\tvirtual void setModelData(QWidget* editor, QAbstractItemModel* model, QModelIndex const& index) const;\r\n\r\nprotected:\r\n\r\n    //! Gets the description column.\r\n    virtual int descriptionColumn() const;\r\n\r\nprivate slots:\r\n\r\n\t/*!\r\n     *  Commit the data from the sending editor and close the editor.\r\n\t */\r\n\tvoid commitAndCloseEditor();\r\n\r\nprivate:\r\n\t\r\n\t//! No copying\r\n\tFileSetsDelegate(const FileSetsDelegate& other);\r\n\r\n\t//! No assignment\r\n\tFileSetsDelegate& operator=(const FileSetsDelegate& other);\r\n};\r\n\r\n#endif // FILESETSDELEGATE_H\r\n"
  },
  {
    "path": "editors/ComponentEditor/fileSet/filesetseditor.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: filesetseditor.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 25.5.2012\r\n//\r\n// Description:\r\n// The editor to add/remove/edit file sets of a component.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"filesetseditor.h\"\r\n#include \"filesetsdelegate.h\"\r\n\r\n#include <common/widgets/summaryLabel/summarylabel.h>\r\n\r\n#include <KactusAPI/include/FileSetInterface.h>\r\n\r\n#include <KactusAPI/include/LibraryInterface.h>\r\n\r\n#include <KactusAPI/include/PluginManager.h>\r\n\r\n#include <IPXACTmodels/Component/Component.h>\r\n\r\n#include <QVBoxLayout>\r\n#include <QFileInfo>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileSetsEditor::FileSetsEditor()\r\n//-----------------------------------------------------------------------------\r\nFileSetsEditor::FileSetsEditor(QSharedPointer<Component> component, LibraryInterface* libInterface,\r\n    QSharedPointer<ParameterFinder> parameterFinder, FileSetInterface* fileSetInterface):\r\nItemEditor(component, libInterface),\r\nsplitter_(Qt::Vertical, this),\r\nview_(&splitter_),\r\nmodel_(fileSetInterface, parameterFinder, this),\r\nproxy_(this),\r\ndependencyEditor_(component, QFileInfo(libInterface->getPath(component->getVlnv())).path(), &splitter_),\r\nfirstShow_(true),\r\nfileSetInterface_(fileSetInterface),\r\navailableFileSets_(component->getFileSets())\r\n{\r\n    fileSetInterface_->setFileSets(availableFileSets_);\r\n\r\n    proxy_.setSourceModel(&model_);\r\n\r\n    view_.setModel(&proxy_);\r\n    view_.setItemDelegate(new FileSetsDelegate(this));\r\n    view_.setItemsDraggable(false);\r\n    view_.setAllowImportExport(true);\r\n\r\n    QString defPath = libInterface->getDirectoryPath(ItemEditor::component()->getVlnv()) + \r\n        QStringLiteral(\"/fileSetList.csv\");\r\n\r\n    view_.setDefaultImportExportPath(defPath);\r\n\r\n    setupLayout();\r\n\r\n    connect(&model_, SIGNAL(contentChanged()), this, SIGNAL(contentChanged()), Qt::UniqueConnection);\r\n    connect(&model_, SIGNAL(fileSetAdded(int)),    this, SIGNAL(childAdded(int)), Qt::UniqueConnection);\r\n    connect(&model_, SIGNAL(fileSetRemoved(int)), this, SIGNAL(childRemoved(int)), Qt::UniqueConnection);\r\n\r\n    connect(&model_, SIGNAL(contentChanged()), &dependencyEditor_, SLOT(refresh()), Qt::UniqueConnection);\r\n\r\n    connect(&dependencyEditor_, SIGNAL(contentChanged()), this, SIGNAL(contentChanged()), Qt::UniqueConnection);\r\n    connect(&dependencyEditor_, SIGNAL(dependenciesChanged()),\r\n        this, SIGNAL(dependenciesChanged()), Qt::UniqueConnection);\r\n    connect(&dependencyEditor_, SIGNAL(fileSetAdded(FileSet*)),\r\n        &model_, SLOT(onFileSetAdded(FileSet*)), Qt::UniqueConnection);\r\n    connect(&dependencyEditor_, SIGNAL(fileAdded(File*)), this, SIGNAL(fileAdded(File*)), Qt::UniqueConnection);\r\n    connect(&dependencyEditor_, SIGNAL(filesUpdated()), this, SIGNAL(filesUpdated()), Qt::UniqueConnection);\r\n\r\n    connect(&view_, SIGNAL(addItem(const QModelIndex&)),\r\n        &model_, SLOT(onAddItem(const QModelIndex&)), Qt::UniqueConnection);\r\n    connect(&view_, SIGNAL(removeItem(const QModelIndex&)),\r\n        &model_, SLOT(onRemoveItem(const QModelIndex&)), Qt::UniqueConnection);\r\n\r\n    connect(&model_, SIGNAL(decreaseReferences(QString)), this,\r\n        SIGNAL(decreaseReferences(QString)), Qt::UniqueConnection);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileSetsEditor::refresh()\r\n//-----------------------------------------------------------------------------\r\nvoid FileSetsEditor::refresh()\r\n{\r\n    fileSetInterface_->setFileSets(availableFileSets_);\r\n\r\n    view_.update();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileSetsEditor::showEvent()\r\n//-----------------------------------------------------------------------------\r\nvoid FileSetsEditor::showEvent( QShowEvent* event )\r\n{\r\n    QWidget::showEvent(event);\r\n    emit helpUrlRequested(\"componenteditor/filesets.html\");\r\n\r\n    if (firstShow_)\r\n    {\r\n        dependencyEditor_.scan();\r\n        firstShow_ = false;\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileSetsEditor::refreshDependencyModel()\r\n//-----------------------------------------------------------------------------\r\nvoid FileSetsEditor::refreshDependencyModel()\r\n{\r\n    dependencyEditor_.refresh();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileSetsEditor::setupLayout()\r\n//-----------------------------------------------------------------------------\r\nvoid FileSetsEditor::setupLayout()\r\n{\r\n    SummaryLabel* summaryLabel = new SummaryLabel(tr(\"File sets summary\"), this);\r\n\r\n    QGroupBox* dependencyWidget = new QGroupBox(tr(\"File dependencies\"), this);\r\n\r\n    QVBoxLayout* dependencyLayout = new QVBoxLayout(dependencyWidget);\r\n    dependencyLayout->addWidget(&dependencyEditor_);\r\n\r\n    splitter_.addWidget(&view_);\r\n    splitter_.addWidget(dependencyWidget);\r\n\r\n    QVBoxLayout* layout = new QVBoxLayout(this);\r\n    layout->addWidget(summaryLabel, 0, Qt::AlignCenter);\r\n    layout->addWidget(&splitter_, 1);\r\n    layout->setContentsMargins(0, 0, 0, 0);\r\n}\r\n"
  },
  {
    "path": "editors/ComponentEditor/fileSet/filesetseditor.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: filesetseditor.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 25.5.2012\r\n//\r\n// Description:\r\n// The editor to add/remove/edit file sets of a component.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef FILESETSEDITOR_H\r\n#define FILESETSEDITOR_H\r\n\r\n#include \"filesetsmodel.h\"\r\n#include \"dependencyAnalysis/FileDependencyEditor.h\"\r\n\r\n#include <editors/ComponentEditor/itemeditor.h>\r\n#include <common/views/EditableTableView/editabletableview.h>\r\n\r\n#include <QSortFilterProxyModel>\r\n#include <QSplitter>\r\n\r\nclass LibraryInterface;\r\nclass Component;\r\nclass ParameterFinder;\r\nclass FileSetInterface;\r\nclass FileSet;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! The editor to add/remove/edit file sets of a component.\r\n//-----------------------------------------------------------------------------\r\nclass FileSetsEditor : public ItemEditor\r\n{\r\n    Q_OBJECT\r\n\r\npublic:\r\n\r\n    /*! The constructor\r\n     *\r\n     *    @param [in] component           The component being edited.\r\n     *    @param [in] libInterface        The library interface.\r\n     *    @param [in] parameterFinder     Finder used to identify parameters.\r\n     *    @param [in] fileSetInterface    Interface for accessing file sets.\r\n     */\r\n    FileSetsEditor(QSharedPointer<Component> component,\r\n        LibraryInterface* libInterface,\r\n        QSharedPointer<ParameterFinder> parameterFinder,\r\n        FileSetInterface* fileSetInterface);\r\n    \r\n    //! The destructor\r\n    virtual ~FileSetsEditor() = default;\r\n\r\n\r\n    //! No copying\r\n    FileSetsEditor(const FileSetsEditor& other) = delete;\r\n    FileSetsEditor& operator=(const FileSetsEditor& other) = delete;\r\n\r\n    //! Reload the information from the model to the editor.\r\n    virtual void refresh();\r\n\r\nsignals:\r\n    //! Emitted when a file has been added to any file set.\r\n    void fileAdded(File* file);\r\n\r\n    //! Emitted when the files have been updated.\r\n    void filesUpdated();\r\n\r\n    //! Emitted when the file dependencies have changed.\r\n    void dependenciesChanged();\r\n\r\npublic slots:\r\n    /*!\r\n     *  Refreshes the dependency model.\r\n     */\r\n    void refreshDependencyModel();\r\n\r\nprotected:\r\n    //! Handler for widget's show event\r\n    virtual void showEvent(QShowEvent* event);\r\n\r\nprivate:\r\n\r\n    //! Sets the widget layout.\r\n    void setupLayout();\r\n\r\n    //! Splitter for the fileset table and dependency graph.\r\n    QSplitter splitter_;\r\n    \r\n    //! The view to display the file sets.\r\n    EditableTableView view_;\r\n\r\n    //! The model that manages the file set objects for the view.\r\n    FileSetsModel model_;\r\n\r\n    //! The proxy to do the sorting.\r\n    QSortFilterProxyModel proxy_;\r\n\r\n    //! The file dependency editor.\r\n    FileDependencyEditor dependencyEditor_;\r\n\r\n    //! If true, the widget has not yet been shown at all.\r\n    bool firstShow_;\r\n\r\n    //! Interface for accessing file sets.\r\n    FileSetInterface* fileSetInterface_;\r\n\r\n    //! The editable file sets.\r\n    QSharedPointer<QList<QSharedPointer<FileSet> > > availableFileSets_;\r\n};\r\n\r\n#endif // FILESETSEDITOR_H\r\n"
  },
  {
    "path": "editors/ComponentEditor/fileSet/filesetsmodel.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: filesetsmodel.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 25.5.2012\r\n//\r\n// Description:\r\n// The model class to manage the objects for FileSetsEditor.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"filesetsmodel.h\"\r\n#include \"FileSetColumns.h\"\r\n\r\n#include <editors/ComponentEditor/memoryMaps/memoryMapsExpressionCalculators/ReferenceCalculator.h>\r\n#include <KactusAPI/include/FileSetInterface.h>\r\n\r\n#include <IPXACTmodels/Component/Component.h>\r\n#include <IPXACTmodels/Component/FileSet.h>\r\n\r\n#include <common/KactusColors.h>\r\n\r\n\r\n#include <QStringList>\r\n#include <QString>\r\n#include <QRegularExpression>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileSetsModel::FileSetsModel()\r\n//-----------------------------------------------------------------------------\r\nFileSetsModel::FileSetsModel(FileSetInterface* fileSetInterface, QSharedPointer<ParameterFinder> parameterFinder,\r\n    QObject *parent):\r\nQAbstractTableModel(parent),\r\nparameterFinder_(parameterFinder),\r\nfileSetInterface_(fileSetInterface)\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileSetsModel::rowCount()\r\n//-----------------------------------------------------------------------------\r\nint FileSetsModel::rowCount(QModelIndex const& parent /*= QModelIndex()*/ ) const\r\n{\r\n\tif (parent.isValid())\r\n    {\r\n\t\treturn 0;\r\n\t}\r\n    \r\n    return fileSetInterface_->itemCount();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileSetsModel::columnCount()\r\n//-----------------------------------------------------------------------------\r\nint FileSetsModel::columnCount(QModelIndex const& parent /*= QModelIndex()*/ ) const\r\n{\r\n\tif (parent.isValid())\r\n    {\r\n\t\treturn 0;\r\n\t}\r\n\treturn FileSetColumns::COLUMN_COUNT;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileSetsModel::flags()\r\n//-----------------------------------------------------------------------------\r\nQt::ItemFlags FileSetsModel::flags(QModelIndex const& index ) const\r\n{\r\n\tif (!index.isValid())\r\n    {\r\n\t\treturn Qt::NoItemFlags;\r\n\t}\r\n\r\n\treturn Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsEditable;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileSetsModel::headerData()\r\n//-----------------------------------------------------------------------------\r\nQVariant FileSetsModel::headerData(int section, Qt::Orientation orientation, int role) const\r\n{\r\n\tif (orientation != Qt::Horizontal)\r\n    {\r\n\t\treturn QVariant();\r\n\t}\r\n\r\n\tif (Qt::DisplayRole == role)\r\n    {\r\n        if (section == FileSetColumns::NAME_COLUMN)\r\n        {\r\n            return tr(\"Name\");\r\n        }\r\n        else if (section == FileSetColumns::GROUP_COLUMN)\r\n        {\r\n            return tr(\"Group identifiers\");\r\n        }\r\n        else if (section == FileSetColumns::DESCRIPTION)\r\n        {\r\n            return tr(\"Description\");\r\n        }\r\n\t}\r\n    return QVariant();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileSetsModel::data()\r\n//-----------------------------------------------------------------------------\r\nQVariant FileSetsModel::data(QModelIndex const& index, int role) const\r\n{\r\n    if (!index.isValid() || index.row() < 0 || index.row() >= fileSetInterface_->itemCount())\r\n    {\r\n\t\treturn QVariant();\r\n\t}\r\n\r\n    std::string fileSetName = fileSetInterface_->getIndexedItemName(index.row());\r\n\r\n    if (index.column() == FileSetColumns::DESCRIPTION && (role == Qt::EditRole || role == Qt::ToolTipRole))\r\n    {\r\n        return QString::fromStdString(fileSetInterface_->getDescription(fileSetName));\r\n    }\r\n    else if (role == Qt::DisplayRole || role == Qt::EditRole)\r\n    {\r\n        if (index.column() == FileSetColumns::NAME_COLUMN)\r\n        {\r\n            return QString::fromStdString(fileSetName);\r\n        }\r\n        else if (index.column() == FileSetColumns::DESCRIPTION)\r\n        {\r\n            QString fileSetDescription = QString::fromStdString(fileSetInterface_->getDescription(fileSetName));\r\n\r\n            return fileSetDescription.replace(\r\n                QRegularExpression(\"\\n.*$\", QRegularExpression::DotMatchesEverythingOption), \"...\");\r\n        }\r\n        else if (index.column() == FileSetColumns::GROUP_COLUMN)\r\n        {\r\n            std::vector<std::string> fileSetGroups = fileSetInterface_->getGroups(fileSetName);\r\n\r\n            std::string combinedGroups;\r\n            for (size_t i = 0; i < fileSetGroups.size(); ++i)\r\n            {\r\n                auto const& singleGroup = fileSetGroups.at(i);\r\n\r\n                if (i > 0)\r\n                {\r\n                    combinedGroups += \" \";\r\n                }\r\n\r\n                combinedGroups += singleGroup;\r\n            }\r\n\r\n            return QString::fromStdString(combinedGroups);\r\n        }\r\n        else\r\n        {\r\n            return QVariant();\r\n        }\r\n    }\r\n\telse if (Qt::BackgroundRole == role)\r\n    {\r\n        if (index.column() == FileSetColumns::NAME_COLUMN)\r\n        {\r\n            return KactusColors::MANDATORY_FIELD;\r\n        }\r\n        else\r\n        {\r\n            return KactusColors::REGULAR_FIELD;\r\n\t\t}\r\n\t}\r\n\telse\r\n    {\r\n\t\treturn QVariant();\r\n\t}\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileSetsModel::setData()\r\n//-----------------------------------------------------------------------------\r\nbool FileSetsModel::setData(const QModelIndex& index, const QVariant& value, int role)\r\n{\r\n    if (!index.isValid() || index.row() < 0 || index.row() >= fileSetInterface_->itemCount())\r\n    {\r\n\t\treturn false;\r\n\t}\r\n\r\n    std::string fileSetName = fileSetInterface_->getIndexedItemName(index.row());\r\n\r\n    if (Qt::EditRole == role)\r\n    {\r\n        if (index.column() == FileSetColumns::NAME_COLUMN)\r\n        {\r\n            fileSetInterface_->setName(fileSetName, value.toString().toStdString());\r\n        }\r\n        else if (index.column() == FileSetColumns::DESCRIPTION)\r\n        {\r\n            fileSetInterface_->setDescription(fileSetName, value.toString().toStdString());\r\n        }\r\n        else if(index.column() == FileSetColumns::GROUP_COLUMN)\r\n        {\r\n            QString str = value.toString();\r\n            QStringList groupNames = str.split(' ', Qt::SkipEmptyParts);\r\n\r\n            std::vector<std::string> newGroups;\r\n            for (auto singleGroup : groupNames)\r\n            {\r\n                newGroups.push_back(singleGroup.toStdString());\r\n            }\r\n\r\n            fileSetInterface_->setGroups(fileSetName, newGroups);\r\n        }\r\n        else\r\n        {\r\n            return false;\r\n        }\r\n\r\n\t\temit dataChanged(index, index);\r\n\t\temit contentChanged();\r\n\t\treturn true;\r\n\t}\r\n\telse\r\n    {\r\n\t\treturn false;\r\n\t}\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileSetsModel::onAddItem()\r\n//-----------------------------------------------------------------------------\r\nvoid FileSetsModel::onAddItem(QModelIndex const& index)\r\n{\r\n    int row = fileSetInterface_->itemCount();\r\n\r\n\t// if the index is valid then add the item to the correct position\r\n\tif (index.isValid())\r\n    {\r\n\t\trow = index.row();\r\n\t}\r\n\r\n\tbeginInsertRows(QModelIndex(), row, row);\r\n\r\n    fileSetInterface_->addFileSet(row);\r\n\r\n\tendInsertRows();\r\n\r\n\t// inform navigation tree that file set is added\r\n\temit fileSetAdded(row);\r\n\r\n\t// tell also parent widget that contents have been changed\r\n\temit contentChanged();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileSetsModel::onRemoveItem()\r\n//-----------------------------------------------------------------------------\r\nvoid FileSetsModel::onRemoveItem(QModelIndex const& index)\r\n{\r\n\t// don't remove anything if index is invalid\r\n    if (!index.isValid() || index.row() < 0 || index.row() >= fileSetInterface_->itemCount())\r\n    {\r\n\t\treturn;\r\n\t}\r\n\r\n\t// remove the specified item\r\n\tbeginRemoveRows(QModelIndex(), index.row(), index.row());\r\n\r\n    std::string removedName = fileSetInterface_->getIndexedItemName(index.row());\r\n\r\n    decreaseReferencesWithRemovedFileSet(removedName);\r\n\r\n    fileSetInterface_->removeFileSet(removedName);\r\n\r\n    endRemoveRows();\r\n\r\n\t// inform navigation tree that file set has been removed\r\n\temit fileSetRemoved(index.row());\r\n\r\n\t// tell also parent widget that contents have been changed\r\n\temit contentChanged();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: filesetsmodel::decreaseReferencesWithRemovedFileSet()\r\n//-----------------------------------------------------------------------------\r\nvoid FileSetsModel::decreaseReferencesWithRemovedFileSet(std::string const& fileSetName)\r\n{\r\n    QStringList expressionList;\r\n    std::vector<std::string> selectedFileSetNames;\r\n    selectedFileSetNames.push_back(fileSetName);\r\n\r\n    for (auto expression : fileSetInterface_->getExpressionsInSelectedFileSets(selectedFileSetNames))\r\n    {\r\n        expressionList.append(QString::fromStdString(expression));\r\n    }\r\n\r\n    ReferenceCalculator referenceCalculator(parameterFinder_);\r\n    QMap<QString, int> referencedParameters = referenceCalculator.getReferencedParameters(expressionList);\r\n    foreach (QString referencedID, referencedParameters.keys())\r\n    {\r\n        for (int i = 0; i < referencedParameters.value(referencedID); ++i)\r\n        {\r\n            emit decreaseReferences(referencedID);\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileSetsModel::refresh()\r\n//-----------------------------------------------------------------------------\r\nvoid FileSetsModel::refresh()\r\n{\r\n    beginResetModel();\r\n    endResetModel();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileSetsModel::onFileSetAdded()\r\n//-----------------------------------------------------------------------------\r\nvoid FileSetsModel::onFileSetAdded(FileSet* fileSet)\r\n{\r\n    beginResetModel();\r\n    endResetModel();\r\n\r\n    // Find out the corresponding index and signal fileSetAdded().\r\n    int fileSetIndex = fileSetInterface_->getItemIndex(fileSet->name().toStdString());\r\n    if (fileSetIndex >= 0)\r\n    {\r\n        emit fileSetAdded(fileSetIndex);\r\n        emit contentChanged();\r\n    }\r\n}\r\n"
  },
  {
    "path": "editors/ComponentEditor/fileSet/filesetsmodel.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: filesetsmodel.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 25.5.2012\r\n//\r\n// Description:\r\n// The model class to manage the objects for FileSetsEditor.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef FILESETSMODEL_H\r\n#define FILESETSMODEL_H\r\n\r\n#include <QAbstractTableModel>\r\n#include <QList>\r\n#include <QSharedPointer>\r\n\r\nclass FileSet;\r\nclass Component;\r\nclass ParameterFinder;\r\nclass FileSetInterface;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! The model class to manage the objects for FileSetsEditor.\r\n//-----------------------------------------------------------------------------\r\nclass FileSetsModel : public QAbstractTableModel\r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\r\n\t/*!\r\n     *  The constructor\r\n\t *\r\n\t *    @param [in] fileSetInterface    Interface for accessing file sets.\r\n     *    @param [in] parameterFinder     Finder used to identify parameters.\r\n\t *    @param [in] parent              The owner of this model.\r\n\t */\r\n    FileSetsModel(FileSetInterface* fileSetInterface,\r\n        QSharedPointer<ParameterFinder> parameterFinder,\r\n        QObject *parent);\r\n\r\n\t/*!\r\n     *  The destructor\r\n     */\r\n\t~FileSetsModel() = default;\r\n\r\n    /*!\r\n     *  Refreshes the model.\r\n     */\r\n    void refresh();\r\n\r\n\t/*! Get the number of rows an item contains.\r\n\t *\r\n\t *    @param [in] parent  Identifies the parent that's row count is requested.\r\n\t *\r\n\t *    @return Number of rows the item has.\r\n\t*/\r\n\tvirtual int rowCount(const QModelIndex& parent = QModelIndex()) const;\r\n\r\n\t/*! Get the number of columns the item has to be displayed.\r\n\t *\r\n\t *    @param [in] parent  Identifies the parent that's column count is requested.\r\n\t *\r\n\t *    @return The number of columns to be displayed.\r\n\t*/\r\n\tvirtual int columnCount(const QModelIndex& parent = QModelIndex()) const;\r\n\r\n\t/*! Get the data for specified item.\r\n\t *\r\n\t *    @param [in] index   Specifies the item that's data is requested.\r\n\t *    @param [in] role    The role that defines what kind of data is requested.\r\n\t *\r\n\t *    @return QVariant Contains the data for the item.\r\n\t*/\r\n\tvirtual QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const;\r\n\r\n\t/*! Get the header data for specified header.\r\n\t *\r\n\t *    @param [in] section         The section specifies the row/column number for the header.\r\n\t *    @param [in] orientation     Specified if horizontal or vertical header is wanted.\r\n\t *    @param [in] role            Specifies the type of the requested data.\r\n\t *\r\n\t *    @return QVariant Contains the requested data.\r\n\t*/\r\n\tvirtual QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;\r\n\r\n\t/*! Save the data to the model for specified item\r\n\t *\r\n\t *    @param [in] index   The model index of the item that's data is to be saved.\r\n\t *    @param [in] value   The data that is to be saved.\r\n\t *    @param [in] role    The role specifies what kind of data should be saved.\r\n\t *\r\n\t *    @return True if saving happened successfully.\r\n\t*/\r\n\tbool setData(const QModelIndex& index, const QVariant& value, int role = Qt::EditRole);\r\n\r\n\t/*! Get the item flags that defines the possible operations for the item.\r\n\t *\r\n\t *    @param [in] index   Model index that identifies the item.\r\n\t *\r\n\t *    @return Flags specify the possible operations for the item.\r\n\t*/\r\n\tQt::ItemFlags flags(const QModelIndex& index) const;\r\n\r\npublic slots:\r\n\r\n\t/*! Add a new item to the given index.\r\n\t *\r\n\t *    @param [in] index   The index identifying the position for new item.\r\n\t *\r\n\t*/\r\n\tvirtual void onAddItem(const QModelIndex& index);\r\n\r\n\t/*! Remove the item in the given index.\r\n\t *\r\n\t *    @param [in] index   The index identifying the item to remove.\r\n\t *\r\n\t*/\r\n\tvirtual void onRemoveItem(const QModelIndex& index);\r\n\r\n    /*!\r\n     *  Updates the model when a file set has been added from outside the model.\r\n     *\r\n     *    @param [in] fileSet     The file set that was added.\r\n     */\r\n    void onFileSetAdded(FileSet* fileSet);\r\n\r\nsignals:\r\n\r\n\t//! Emitted when the contents of the model change.\r\n\tvoid contentChanged();\r\n\r\n\t/*! Emitted when a new file set is added to the model.\r\n\t *\r\n\t *    @param [in] index   The index of the added file set.\r\n\t *\r\n\t*/\r\n\tvoid fileSetAdded(int index);\r\n\r\n\t/*! Emitted when a file set is removed from the model.\r\n\t *\r\n\t *    @param [in] index   The index of the removed file set.\r\n\t *\r\n\t*/\r\n\tvoid fileSetRemoved(int index);\r\n    \r\n    /*!\r\n     *  Decrease the amount of references to the selected parameter.\r\n     *\r\n     *    @param [in] valueId   The id of the referenced parameter.\r\n     */\r\n    void decreaseReferences(QString valueId) const;\r\n\r\nprivate:\r\n\t//! No copying\r\n\tFileSetsModel(const FileSetsModel& other);\r\n\tFileSetsModel& operator=(const FileSetsModel& other);\r\n\r\n    /*!\r\n     *  Remove the references from the selected file set.\r\n     *\r\n     *    @param [in] fileSetName     Name of the selected file set.\r\n     */\r\n    void decreaseReferencesWithRemovedFileSet(std::string const& fileSetName);\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! Finder used to locate parameter ids.\r\n    QSharedPointer<ParameterFinder> parameterFinder_;\r\n\r\n    //! Interface for accessing file sets.\r\n    FileSetInterface* fileSetInterface_;\r\n};\r\n\r\n#endif // FILESETSMODEL_H\r\n"
  },
  {
    "path": "editors/ComponentEditor/fileSet/groupmanager.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: groupmanager.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 04.02.2011\r\n//\r\n// Description:\r\n// GroupManager is a widget to manage group names within FileSet.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"groupmanager.h\"\r\n\r\n#include \"groupmanagerdelegate.h\"\r\n\r\n#include <common/dialogs/comboSelector/comboselector.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: GroupManager::GroupManager()\r\n//-----------------------------------------------------------------------------\r\nGroupManager::GroupManager(QString const& title, QWidget* parent):\r\nListManager(title, parent)\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: GroupManager::~GroupManager()\r\n//-----------------------------------------------------------------------------\r\nGroupManager::~GroupManager()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: GroupManager::initialize()\r\n//-----------------------------------------------------------------------------\r\nvoid GroupManager::initialize(QStringList const& items)\r\n{\r\n\tListManager::initialize(items);\r\n\r\n\tview_->setItemDelegate(new GroupManagerDelegate(this));\r\n}\r\n"
  },
  {
    "path": "editors/ComponentEditor/fileSet/groupmanager.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: groupmanager.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 04.02.2011\r\n//\r\n// Description:\r\n// GroupManager is a widget to manage group names within FileSet.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef GROUPMANAGER_H\r\n#define GROUPMANAGER_H\r\n\r\n#include <common/widgets/listManager/listmanager.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n//! GroupManager is a widget to manage group names within FileSet.\r\n//-----------------------------------------------------------------------------\r\nclass GroupManager : public ListManager\r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\r\n\t/*! The constructor.\r\n\t *\r\n\t *    @param [in] title   The title for the QGroupBox.\r\n\t *    @param [in] parent  The owner of this widget.\r\n\t */\r\n\tGroupManager(QString const& title = tr(\"Group identifiers\"), QWidget* parent = 0);\r\n\r\n\t//! The destructor\r\n\tvirtual ~GroupManager();\r\n\r\n\t/*! Initialize the group manager.\r\n\t *\r\n\t * This function must be called after creating the group manager and before using it.\r\n\t * \r\n\t *    @param [in] items   The items to add to the widget.\r\n\t*/\r\n\tvirtual void initialize(QStringList const& items = QStringList());\r\n\r\nprivate:\r\n\r\n\t//! No copying\r\n\tGroupManager(const GroupManager& other);\r\n\tGroupManager& operator=(const GroupManager& other);\r\n\t\r\n};\r\n\r\n#endif // GROUPMANAGER_H\r\n"
  },
  {
    "path": "editors/ComponentEditor/fileSet/groupmanagerdelegate.cpp",
    "content": "/* \r\n *  \tCreated on: 9.12.2011\r\n *      Author: Antti Kamppi\r\n * \t\tfilename: groupmanagerdelegate.cpp\r\n *\t\tProject: Kactus2\r\n */\r\n\r\n#include \"groupmanagerdelegate.h\"\r\n\r\n#include <common/widgets/assistedLineEdit/AssistedLineEdit.h>\r\n#include <common/widgets/assistedLineEdit/BasicLineContentMatcher.h>\r\n\r\n#include <QComboBox>\r\n#include <QStringList>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: GroupManagerDelegate::GroupManagerDelegate()\r\n//-----------------------------------------------------------------------------\r\nGroupManagerDelegate::GroupManagerDelegate(QObject *parent):\r\nQStyledItemDelegate(parent),\r\n    matcher_(new BasicLineContentMatcher())\r\n{\r\n    QStringList suggestedItems;\r\n    suggestedItems.append(tr(\"diagnostics\"));\r\n    suggestedItems.append(tr(\"documentation\"));\r\n    suggestedItems.append(tr(\"generatedFiles\"));\r\n    suggestedItems.append(tr(\"projectFiles\"));\r\n    suggestedItems.append(tr(\"simulation\"));\r\n    suggestedItems.append(tr(\"sourceFiles\"));\r\n\r\n    matcher_->setItems(suggestedItems);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: GroupManagerDelegate::~GroupManagerDelegate()\r\n//-----------------------------------------------------------------------------\r\nGroupManagerDelegate::~GroupManagerDelegate() \r\n{\r\n    delete matcher_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: GroupManagerDelegate::createEditor()\r\n//-----------------------------------------------------------------------------\r\nQWidget* GroupManagerDelegate::createEditor(QWidget* parent, QStyleOptionViewItem const& /*option*/,\r\n    QModelIndex const& /*index*/) const\r\n{\r\n    AssistedLineEdit* editor = new AssistedLineEdit(parent->window(), parent);\r\n    editor->setContentMatcher(matcher_);\r\n\r\n    return editor;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: GroupManagerDelegate::setEditorData()\r\n//-----------------------------------------------------------------------------\r\nvoid GroupManagerDelegate::setEditorData(QWidget* editor, QModelIndex const& index) const\r\n{\r\n    QString text = index.model()->data(index, Qt::EditRole).toString();\r\n\r\n    AssistedLineEdit* assistedEditor = qobject_cast<AssistedLineEdit*>(editor);\r\n    Q_ASSERT(assistedEditor);\r\n\r\n    assistedEditor->setText(text);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: GroupManagerDelegate::setModelData()\r\n//-----------------------------------------------------------------------------\r\nvoid GroupManagerDelegate::setModelData(QWidget* editor, QAbstractItemModel* model, QModelIndex const& index) const\r\n{\r\n    AssistedLineEdit* assistedEditor = qobject_cast<AssistedLineEdit*>(editor);\r\n    Q_ASSERT(assistedEditor);\r\n\r\n    model->setData(index, assistedEditor->text(), Qt::EditRole);\r\n}\r\n"
  },
  {
    "path": "editors/ComponentEditor/fileSet/groupmanagerdelegate.h",
    "content": "/* \r\n *  \tCreated on: 9.12.2011\r\n *      Author: Antti Kamppi\r\n * \t\tfilename: groupmanagerdelegate.h\r\n *\t\tProject: Kactus2\r\n */\r\n\r\n#ifndef GROUPMANAGERDELEGATE_H\r\n#define GROUPMANAGERDELEGATE_H\r\n\r\n#include <common/delegates/ComboDelegate/combodelegate.h>\r\n\r\nclass BasicLineContentMatcher;\r\n\r\n/*! Provides editor to select a group for a file set.\r\n *\r\n */\r\nclass GroupManagerDelegate : public QStyledItemDelegate {\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\r\n\t/*! The constructor\r\n\t *\r\n\t *    @param [in] parent The owner of the delegate.\r\n\t*/\r\n\tGroupManagerDelegate(QObject *parent);\r\n\t\r\n\t//! The destructor\r\n\tvirtual ~GroupManagerDelegate();\r\n\r\n\t/*! Create a new editor for the given item\r\n\t *\r\n\t *    @param [in] parent  Owner for the editor.\r\n\t *    @param [in] option  Contains options for the editor.\r\n\t *    @param [in] index   Model index identifying the item.\r\n\t *\r\n\t *    @return The editor to be used to edit the item.\r\n\t*/\r\n\tvirtual QWidget* createEditor(QWidget* parent, QStyleOptionViewItem const& option, \r\n        QModelIndex const& index) const;\r\n\r\n    virtual void setEditorData(QWidget* editor, QModelIndex const& index) const;\r\n\r\n    virtual void setModelData(QWidget* editor, QAbstractItemModel* model, QModelIndex const& index) const;\r\n\r\nprivate:\r\n\t//! No copying\r\n\tGroupManagerDelegate(const GroupManagerDelegate& other);\r\n\tGroupManagerDelegate& operator=(const GroupManagerDelegate& other);\r\n\r\n    BasicLineContentMatcher* matcher_;\r\n};\r\n\r\n#endif // GROUPMANAGERDELEGATE_H\r\n"
  },
  {
    "path": "editors/ComponentEditor/general/generaleditor.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: generaleditor.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Joni-Matti Maatta\r\n// Date: 7.2.2011\r\n//\r\n// Description:\r\n// General editor for editing the component's general data.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"generaleditor.h\"\r\n\r\n#include <IPXACTmodels/common/TagData.h>\r\n\r\n#include <common/widgets/summaryLabel/summarylabel.h>\r\n#include <common/widgets/kactusAttributeEditor/KactusAttributeEditor.h>\r\n\r\n#include <KactusAPI/include/LibraryInterface.h>\r\n#include <KactusAPI/include/ParameterCache.h>\r\n#include <KactusAPI/include/IPXactSystemVerilogParser.h>\r\n#include <KactusAPI/include/ModeConditionParserInterface.h>\r\n\r\n#include <IPXACTmodels/Component/validators/ComponentValidator.h>\r\n\r\n#include <IPXACTmodels/Component/Component.h>\r\n\r\n#include <QGroupBox>\r\n#include <QHBoxLayout>\r\n#include <QHeaderView>\r\n#include <QLineEdit>\r\n#include <QSplitter>\r\n#include <QStringList>\r\n#include <QVBoxLayout>\r\n#include <QFormLayout>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: GeneralEditor::GeneralEditor()\r\n//-----------------------------------------------------------------------------\r\nGeneralEditor::GeneralEditor(LibraryInterface* libHandler, QSharedPointer<Component> component, QWidget* parent) :\r\n    ItemEditor(component, libHandler, parent),\r\n    nameGroupEditor_(new DocumentNameGroupEditor(this)),\r\n    attributeEditor_(new KactusAttributeEditor(this)),\r\n    authorEditor_(new QLineEdit(this)),\r\n    licenseEditor_(new QLineEdit(this)),\r\n    headerEditor_(new QPlainTextEdit(this)),\r\n    finder_(new ParameterCache(component)),\r\n    parser_(new IPXactSystemVerilogParser(finder_)),\r\n    modeConditionParserInterface_(new ModeConditionParserInterface(finder_)),\r\n    validator_(new ComponentValidator(parser_, modeConditionParserInterface_, libHandler, component->getRevision())),\r\n    library_(libHandler)\r\n{\r\n    Q_ASSERT(libHandler != 0);\r\n    Q_ASSERT(component != 0);\r\n\r\n    const QString xmlPath = libHandler->getPath(component->getVlnv());\r\n    nameGroupEditor_->setTitle(tr(\"Component VLNV and location\"));\r\n\r\n    validityIcon_->setFixedSize(24, 24);\r\n\r\n    errorView_->setModel(errorModel_);\r\n    errorView_->hideColumn(2);\r\n    errorView_->horizontalHeader()->hide();\r\n    errorView_->setShowGrid(false);\r\n\r\n    setupLayout();\r\n\r\n    connect(nameGroupEditor_, SIGNAL(contentChanged()), this, SIGNAL(contentChanged()), Qt::UniqueConnection);\r\n    connect(attributeEditor_, SIGNAL(contentChanged()), this, SLOT(onAttributesChange()), Qt::UniqueConnection);\r\n    connect(headerEditor_, SIGNAL(textChanged()), this, SLOT(onHeaderChange()), Qt::UniqueConnection);\r\n    connect(authorEditor_, SIGNAL(textChanged(const QString &)),\r\n        this, SLOT(onAuthorChange()), Qt::UniqueConnection);\r\n    connect(licenseEditor_, SIGNAL(textChanged(const QString &)),\r\n        this, SLOT(onLicenseChange()), Qt::UniqueConnection);\r\n\r\n    GeneralEditor::refresh();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: GeneralEditor::isValid()\r\n//-----------------------------------------------------------------------------\r\nbool GeneralEditor::isValid() const\r\n{\r\n    return true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: GeneralEditor::refresh()\r\n//-----------------------------------------------------------------------------\r\nvoid GeneralEditor::refresh()\r\n{\r\n    disconnect(nameGroupEditor_, SIGNAL(contentChanged()), this, SIGNAL(contentChanged()));\r\n    nameGroupEditor_->setDocumentNameGroup(component(), library_->getPath(component()->getVlnv()));\r\n    connect(nameGroupEditor_, SIGNAL(contentChanged()), this, SIGNAL(contentChanged()), Qt::UniqueConnection);\r\n\r\n\tdisconnect(attributeEditor_, SIGNAL(contentChanged()), this, SLOT(onAttributesChange()));\r\n\r\n    if (component()->getImplementation() == KactusAttribute::HW)\r\n\t{\r\n        KactusAttribute::ProductHierarchy prodHier = component()->getHierarchy();\r\n        KactusAttribute::Firmness firmness = component()->getFirmness();\r\n        QVector<TagData> tags = component()->getTags();\r\n\t\tattributeEditor_->setAttributes(prodHier, firmness, tags);\r\n\t}\r\n\telse\r\n\t{\r\n\t\tattributeEditor_->hideAttributes();\r\n\t}\r\n\r\n    attributeEditor_->setImplementation(component()->getImplementation());\r\n\tconnect(attributeEditor_, SIGNAL(contentChanged()), this, SLOT(onAttributesChange()), Qt::UniqueConnection);\r\n\r\n\tdisconnect(authorEditor_, SIGNAL(textChanged(const QString &)), this, SLOT(onAuthorChange()));\r\n\tauthorEditor_->setText(component()->getAuthor());\r\n\tconnect(authorEditor_, SIGNAL(textChanged(const QString &)),\r\n        this, SLOT(onAuthorChange()), Qt::UniqueConnection);\r\n\r\n    disconnect(licenseEditor_, SIGNAL(textChanged(const QString &)), this, SLOT(onAuthorChange()));\r\n    licenseEditor_->setText(component()->getLicense());\r\n    connect(licenseEditor_, SIGNAL(textChanged(const QString &)),\r\n        this, SLOT(onLicenseChange()), Qt::UniqueConnection);\r\n\r\n\tdisconnect(headerEditor_, SIGNAL(textChanged()), this, SLOT(onHeaderChange()));\r\n\tQString comment = component()->getTopComments().join(\"\\n\");\r\n\theaderEditor_->setPlainText(comment);\r\n\tconnect(headerEditor_, SIGNAL(textChanged()), this, SLOT(onHeaderChange()), Qt::UniqueConnection);\r\n\r\n    auto errors = QStringList();\r\n    validator_->findErrorsIn(errors, component());\r\n    \r\n    errorModel_->clear();\r\n\r\n    bool hasErrors = errors.empty() == false;\r\n    errorView_->setVisible(hasErrors);\r\n\r\n    if (hasErrors)\r\n    {\r\n        errorModel_->addErrors(errors, QString());\r\n        errorView_->resizeColumnsToContents();\r\n\r\n        validityIcon_->setPixmap(QPixmap(\":icons/common/graphics/exclamation--frame.png\").scaled(24, 24));\r\n        validityStatus_->setText(tr(\"%1 error(s) found:\").arg(QString::number(errors.count())));\r\n    }\r\n    else\r\n    {\r\n        validityIcon_->setPixmap(QPixmap(\":icons/common/graphics/checkMark.png\"));\r\n        validityStatus_->setText(tr(\"Complete\"));\r\n    }\r\n\r\n    changeExtensionsEditorItem();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: GeneralEditor::onAttributesChange()\r\n//-----------------------------------------------------------------------------\r\nvoid GeneralEditor::onAttributesChange()\r\n{\r\n    if (component()->getImplementation() == KactusAttribute::HW)\r\n\t{\r\n        component()->setHierarchy(attributeEditor_->getProductHierarchy());\r\n        component()->setFirmness(attributeEditor_->getFirmness());\r\n        component()->setTags(attributeEditor_->getTags());\r\n\t}\r\n\temit contentChanged();\r\n\r\n\tQSettings settings;\r\n\temit hierarchyChanged(settings);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: GeneralEditor::showEvent()\r\n//-----------------------------------------------------------------------------\r\nvoid GeneralEditor::showEvent( QShowEvent* event )\r\n{\r\n\tQWidget::showEvent(event);\r\n\r\n    if (component()->getRevision() == Document::Revision::Std22)\r\n    {\r\n        emit helpUrlRequested(\"componenteditor/general2022.html\");\r\n    }\r\n    else\r\n    {\r\n        emit helpUrlRequested(\"componenteditor/general.html\");\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: GeneralEditor::onHeaderChange()\r\n//-----------------------------------------------------------------------------\r\nvoid GeneralEditor::onHeaderChange()\r\n{\r\n\tcomponent()->setTopComments(headerEditor_->toPlainText());\r\n\temit contentChanged();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: GeneralEditor::onAuthorChange()\r\n//-----------------------------------------------------------------------------\r\nvoid GeneralEditor::onAuthorChange()\r\n{\r\n    component()->setAuthor(authorEditor_->text());\r\n    emit contentChanged();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: GeneralEditor::onLicenseChange()\r\n//-----------------------------------------------------------------------------\r\nvoid GeneralEditor::onLicenseChange()\r\n{\r\n    component()->setLicense(licenseEditor_->text());\r\n    emit contentChanged();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: GeneralEditor::setupLayout()\r\n//-----------------------------------------------------------------------------\r\nvoid GeneralEditor::setupLayout()\r\n{\r\n    nameGroupEditor_->setFlat(true);\r\n\r\n    auto layout = new QGridLayout(this);\r\n    layout->setContentsMargins(0, 0, 0, 0);\r\n\r\n    auto commentBox = new QGroupBox(\"XML header\", this);\r\n    commentBox->setFlat(true);\r\n\r\n    auto commentLayout = new QVBoxLayout(commentBox);\r\n    commentLayout->addWidget(headerEditor_);\r\n\r\n    auto authorBox = new QGroupBox(\"Copyright information\", this);\r\n    authorBox->setFlat(true);\r\n\r\n    auto copyrightLayout = new QFormLayout(authorBox);\r\n    copyrightLayout->addRow(tr(\"Author:\"), authorEditor_);\r\n    copyrightLayout->addRow(tr(\"License:\"), licenseEditor_);\r\n\r\n    auto errorBox = new QGroupBox(\"Validation\", this);\r\n    errorBox->setFlat(true);\r\n\r\n    auto labelLayout = new QHBoxLayout();\r\n    labelLayout->addWidget(validityIcon_);\r\n    labelLayout->addWidget(validityStatus_);\r\n    labelLayout->addStretch();\r\n\r\n    auto errorLayout = new QVBoxLayout(errorBox);\r\n    errorLayout->addLayout(labelLayout);\r\n    errorLayout->addWidget(errorView_);\r\n\r\n    layout->addWidget(new SummaryLabel(tr(\"Component summary\"), this), 0, 0, 1, 2, Qt::AlignCenter);\r\n    layout->addWidget(nameGroupEditor_, 1, 0, 1, 2);\r\n    layout->addWidget(attributeEditor_, 2, 0, 1, 1);\r\n    layout->addWidget(authorBox, 2, 1, 1, 1);    \r\n    layout->addWidget(commentBox, 3, 0, 1, 2);\r\n    layout->addWidget(errorBox, 4, 0, 1, 2);\r\n\r\n    layout->setColumnStretch(0, 1);\r\n    layout->setColumnStretch(1, 1);\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: generaleditor::changeExtensionsEditorItem()\r\n//-----------------------------------------------------------------------------\r\nvoid GeneralEditor::changeExtensionsEditorItem()\r\n{\r\n    QSharedPointer<Component> editedComponent = component();\r\n\r\n    QString extensionID = QLatin1String(\"Component: \") + editedComponent->getVlnv().toString();\r\n    emit changeVendorExtensions(extensionID, editedComponent);\r\n}\r\n"
  },
  {
    "path": "editors/ComponentEditor/general/generaleditor.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: generaleditor.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Joni-Matti Maatta\r\n// Date: 7.2.2011\r\n//\r\n// Description:\r\n// General editor for editing the component's general data.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef GENERALEDITOR_H\r\n#define GENERALEDITOR_H\r\n\r\n#include <editors/ComponentEditor/itemeditor.h>\r\n\r\n#include <editors/common/DocumentNameGroupEditor.h>\r\n\r\n#include <KactusAPI/include/ExpressionParser.h>\r\n#include <KactusAPI/include/ParameterFinder.h>\r\n\r\n#include <IPXACTmodels/Component/validators/ComponentValidator.h>\r\n\r\n#include <library/LibraryErrorModel.h>\r\n\r\n#include <QSharedPointer>\r\n#include <QLineEdit>\r\n#include <QSettings>\r\n#include <QPlainTextEdit>\r\n#include <QTableView>\r\n\r\nclass Component;\r\nclass LibraryInterface;\r\nclass Document;\r\nclass KactusAttributeEditor;\r\nclass ModeConditionParserInterface;\r\n\r\n\r\n//-----------------------------------------------------------------------------\r\n//! GeneralEditor class.\r\n//-----------------------------------------------------------------------------\r\nclass GeneralEditor : public ItemEditor\r\n{\r\n    Q_OBJECT\r\n       \r\npublic:\r\n    /*!\r\n     *  Constructor.\r\n     *\r\n     *    @param [in] libHandler The library handler.\r\n     *    @param [in] component  The component model to edit.\r\n     *    @param [in] parent     The parent widget.\r\n\t */\r\n\tGeneralEditor(LibraryInterface* libHandler, QSharedPointer<Component> component, QWidget *parent = 0);\r\n\r\n    /*!\r\n     *  Destructor.\r\n     */\r\n    ~GeneralEditor() final = default;\r\n\r\n    // Disable copying.\r\n    GeneralEditor(const GeneralEditor& other) = delete;\r\n    GeneralEditor& operator=(const GeneralEditor& other) = delete;\r\n\r\n    /*!\r\n     *  Check for the validity of the edited item.\r\n     *\r\n     *    @return True is item is valid.\r\n     */\r\n    virtual bool isValid() const;\r\n\r\n\t/*!\r\n     *  Reload the information from the model to the editor.\r\n\t */\r\n\tvirtual void refresh();\r\n\r\nsignals:\r\n\r\n\t/*!\r\n\t *  Signaled when the product hierarchy has changed.\r\n\t */\r\n\tvoid hierarchyChanged(QSettings& settings);\r\n\r\nprotected:\r\n\r\n\t//! Handler for widget's show event.\r\n\tvirtual void showEvent(QShowEvent* event);\r\n\r\nprivate slots:\r\n\r\n\t//! Handler for changes in attribute editor.\r\n\tvoid onAttributesChange();\r\n\r\n\t//! Handler for changes in XML header.\r\n\tvoid onHeaderChange();\r\n\r\n    //! Handler for changes in author field.\r\n    void onAuthorChange();\r\n\r\n    //! Handler for changes in license field.\r\n    void onLicenseChange();\r\n\r\nprivate:\r\n\r\n\r\n    //! Sets the widget layout.\r\n    void setupLayout();\r\n\r\n    /*!\r\n     *  Change the extendable item in the vendor extensions editor to edited component.\r\n     */\r\n    void changeExtensionsEditorItem();\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! The VLNV displayer.\r\n    DocumentNameGroupEditor* nameGroupEditor_;\r\n\r\n    //! Kactus attribute editor.\r\n    KactusAttributeEditor* attributeEditor_;\r\n\r\n    //! The author editor.\r\n    QLineEdit* authorEditor_;\r\n\r\n    //! Editor for component license.\r\n    QLineEdit* licenseEditor_;\r\n\r\n\t//! The editor to view/edit the header of the XML-file.\r\n\tQPlainTextEdit* headerEditor_;\r\n\r\n    //! Icon for displaying validity status.\r\n    QLabel* validityIcon_ = new QLabel(this);\r\n\r\n    //! Textual summary of validity status.\r\n    QLabel* validityStatus_ = new QLabel(this);\r\n\r\n    //! View for validity error listing.\r\n    QTableView* errorView_ = new QTableView(this);\r\n\r\n    //! Model for validity errors.\r\n    LibraryErrorModel* errorModel_ = new LibraryErrorModel(this);\r\n\r\n    //! Parameter finder for expressin parser.\r\n    QSharedPointer<ParameterFinder> finder_;\r\n\r\n    //! Expression parser for validator.\r\n    QSharedPointer<ExpressionParser> parser_;\r\n\r\n    //! The mode condition parser factory to use in the component validator.\r\n    QSharedPointer<ModeConditionParserInterface> modeConditionParserInterface_;\r\n\r\n    //! Validator for checking the component compliance.\r\n    QSharedPointer<ComponentValidator> validator_;\r\n\r\n    //! The available library.\r\n    LibraryInterface* library_ = nullptr;\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n\r\n#endif // GENERALEDITOR_H\r\n"
  },
  {
    "path": "editors/ComponentEditor/indirectInterfaces/IndirectInterfaceColumns.h",
    "content": "//-----------------------------------------------------------------------------\n// File: IndirectInterfaceColumns.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Esko Pekkarinen\n// Date: 03.08.2017\n//\n// Description:\n// Common declarations for editing indirect interfaces table columns.\n//-----------------------------------------------------------------------------\n\n#ifndef INDIRECT_INTERFACE_COLUMNS_H\n#define INDIRECT_INTERFACE_COLUMNS_H\n\nnamespace IndirectInterfaceColumns\n{\n    //! Defines the columns for the indirect interfaces table.\n    enum Column {\n        NAME = 0,\n        DISPLAY_NAME,\n        INDIRECT_ADDRESS_REF,\n        INDIRECT_DATA_REF,\n        MEMORY_MAP_REF,\n        TRANSPARENT_BRIDGES,\n        DESCRIPTION,\n        COLUMN_COUNT\n    };\n}\n\n#endif //INDIRECT_INTERFACE_COLUMNS_H"
  },
  {
    "path": "editors/ComponentEditor/indirectInterfaces/IndirectInterfacesDelegate.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: IndirectInterfacesDelegate.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Esko Pekkarinen\n// Date: 03.08.2017\n//\n// Description:\n// Delegate class for Indirect interfaces table of a component.\n//-----------------------------------------------------------------------------\n\n#include \"IndirectInterfacesDelegate.h\"\n\n#include \"IndirectInterfaceColumns.h\"\n\n#include <editors/ComponentEditor/common/ReferenceSelector/ReferenceSelector.h>\n\n#include <QComboBox>\n#include <QLineEdit>\n\n#include <IPXACTmodels/Component/AddressBlock.h>\n#include <IPXACTmodels/Component/MemoryBlockBase.h>\n#include <IPXACTmodels/Component/MemoryMapBase.h>\n#include <IPXACTmodels/Component/MemoryMap.h>\n#include <IPXACTmodels/Component/Register.h>\n#include <IPXACTmodels/Component/RegisterBase.h>\n#include <IPXACTmodels/Component/Field.h>\n\n//-----------------------------------------------------------------------------\n// Function: IndirectInterfacesDelegate::IndirectInterfacesDelegate()\n//-----------------------------------------------------------------------------\nIndirectInterfacesDelegate::IndirectInterfacesDelegate(QSharedPointer<Component> component,\n    QObject *parent):\nMultilineDescriptionDelegate(parent),\n    component_(component)\n{\n}\n\n//-----------------------------------------------------------------------------\n// Function: IndirectInterfacesDelegate::~IndirectInterfacesDelegate()\n//-----------------------------------------------------------------------------\nIndirectInterfacesDelegate::~IndirectInterfacesDelegate()\n{\n}\n\n//-----------------------------------------------------------------------------\n// Function: IndirectInterfacesDelegate::createEditor()\n//-----------------------------------------------------------------------------\nQWidget* IndirectInterfacesDelegate::createEditor(QWidget* parent, const QStyleOptionViewItem& option, \n    QModelIndex const& index) const\n{\n    if (index.column() == IndirectInterfaceColumns::NAME ||\n        index.column() == IndirectInterfaceColumns::DISPLAY_NAME)\n    {\n        QLineEdit* lineEditor = new QLineEdit(parent);\n        connect(lineEditor, SIGNAL(editingFinished()), this, SLOT(commitAndCloseEditor()), Qt::UniqueConnection);\n\n        return lineEditor;\n    }\n    else if (index.column() == IndirectInterfaceColumns::INDIRECT_ADDRESS_REF ||\n        index.column() == IndirectInterfaceColumns::INDIRECT_DATA_REF)\n    {\n        ReferenceSelector* referenceSelector = new ReferenceSelector(parent);\n\n        referenceSelector->refresh(findAvailableReferences());\n\n        connect(referenceSelector, SIGNAL(currentIndexChanged(int)),\n            this, SLOT(commitAndCloseEditor()), Qt::UniqueConnection);\n\n        return referenceSelector;\n    }\n    else if (index.column() == IndirectInterfaceColumns::MEMORY_MAP_REF)\n    {\n        ReferenceSelector* memoryMapSelector = new ReferenceSelector(parent);\n\n        memoryMapSelector->refresh(component_->getMemoryMapNames());\n\n        connect(memoryMapSelector, SIGNAL(currentIndexChanged(int)),\n            this, SLOT(commitAndCloseEditor()), Qt::UniqueConnection);\n\n        return memoryMapSelector;\n    }\n    else\n    {\n        return MultilineDescriptionDelegate::createEditor(parent, option, index);\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: IndirectInterfacesDelegate::setEditorData()\n//-----------------------------------------------------------------------------\nvoid IndirectInterfacesDelegate::setEditorData(QWidget* editor, QModelIndex const& index) const\n{\n    if (index.column() == IndirectInterfaceColumns::NAME ||\n        index.column() == IndirectInterfaceColumns::DISPLAY_NAME)\n    {\n        QLineEdit* lineEditor = qobject_cast<QLineEdit*>(editor);\n        lineEditor->setText(index.data(Qt::DisplayRole).toString());\n    }\n    else if (index.column() == IndirectInterfaceColumns::INDIRECT_ADDRESS_REF ||\n        index.column() == IndirectInterfaceColumns::INDIRECT_DATA_REF ||\n        index.column() == IndirectInterfaceColumns::MEMORY_MAP_REF)\n    {\n          ReferenceSelector* selector = qobject_cast<ReferenceSelector*>(editor);\n          selector->selectItem(index.data(Qt::DisplayRole).toString());\n    }\n    else\n    {\n        MultilineDescriptionDelegate::setEditorData(editor, index);\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: IndirectInterfacesDelegate::setModelData()\n//-----------------------------------------------------------------------------\nvoid IndirectInterfacesDelegate::setModelData(QWidget* editor, QAbstractItemModel* model, \n    QModelIndex const& index) const\n{\n    if (index.column() == IndirectInterfaceColumns::NAME ||\n        index.column() == IndirectInterfaceColumns::DISPLAY_NAME)\n    {\n        QLineEdit* lineEditor = qobject_cast<QLineEdit*>(editor);\n        model->setData(index, lineEditor->text(), Qt::EditRole);\n    }\n    else if (index.column() == IndirectInterfaceColumns::INDIRECT_ADDRESS_REF ||\n        index.column() == IndirectInterfaceColumns::INDIRECT_DATA_REF ||\n        index.column() == IndirectInterfaceColumns::MEMORY_MAP_REF)\n    {\n        QComboBox* selector = qobject_cast<QComboBox*>(editor);\n        model->setData(index, selector->currentText(), Qt::EditRole);\n    }\n    else\n    {\n        MultilineDescriptionDelegate::setModelData(editor, model, index);\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: IndirectInterfacesDelegate::descriptionColumn()\n//-----------------------------------------------------------------------------\nint IndirectInterfacesDelegate::descriptionColumn() const\n{\n    return IndirectInterfaceColumns::DESCRIPTION;\n}\n\n//-----------------------------------------------------------------------------\n// Function: IndirectInterfacesDelegate::commitAndCloseEditor()\n//-----------------------------------------------------------------------------\nvoid IndirectInterfacesDelegate::commitAndCloseEditor()\n{\n\tQWidget* edit = qobject_cast<QWidget*>(sender());\n\tQ_ASSERT(edit);\n\n\tQComboBox* combo = qobject_cast<QComboBox*>(edit);\n\n\tif (combo)\n    {\n\t\temit commitData(combo);\n\t}\n\telse\n    {\n\t\temit commitData(edit);\n\t\temit closeEditor(edit);\n\t}\n}\n\n//-----------------------------------------------------------------------------\n// Function: IndirectInterfacesDelegate::findAvailableReferences()\n//-----------------------------------------------------------------------------\nQStringList IndirectInterfacesDelegate::findAvailableReferences() const\n{\n    QStringList fields;\n    foreach (QSharedPointer<MemoryMap> map, *component_->getMemoryMaps())\n    {\n        foreach (QSharedPointer<MemoryBlockBase> block, *map->getMemoryBlocks())\n        {\n            QSharedPointer<AddressBlock> addressBlock = block.dynamicCast<AddressBlock>();\n            if (addressBlock)\n            {\n                foreach (QSharedPointer<RegisterBase> registerBase, *addressBlock->getRegisterData())\n                {\n                    QSharedPointer<Register> reg = registerBase.dynamicCast<Register>();\n                    if (reg)\n                    {\n                        foreach (QSharedPointer<Field> field, *reg->getFields())\n                        {\n                            if (!field->getId().isEmpty())\n                            {\n                                fields.append(field->getId());\n                            }\n                        }\n                    }\n                }\n            }\n        }\n    }\n\n    return fields;\n}\n\n"
  },
  {
    "path": "editors/ComponentEditor/indirectInterfaces/IndirectInterfacesDelegate.h",
    "content": "//-----------------------------------------------------------------------------\n// File: IndirectInterfacesDelegate.h\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Esko Pekkarinen\n// Date: 03.08.2017\n//\n// Description:\n// Delegate class for Indirect interfaces table of a component.\n//-----------------------------------------------------------------------------\n\n#ifndef INDIRECT_INTERFACES_DELEGATE_H\n#define INDIRECT_INTERFACES_DELEGATE_H\n\n#include <editors/ComponentEditor/common/MultilineDescriptionDelegate.h>\n\n#include <IPXACTmodels/Component/Component.h>\n\n//-----------------------------------------------------------------------------\n//! The delegate that provides editors for bus interfaces.\n//-----------------------------------------------------------------------------\nclass IndirectInterfacesDelegate : public MultilineDescriptionDelegate\n{\n\tQ_OBJECT\n\npublic:\n\n\t/*! The constructor\n\t *\n     *    @param [in] component   The component containing the edited indirect interfaces.\n\t *    @param [in] parent      The owner of the delegate.\n\t*/\n\tIndirectInterfacesDelegate(QSharedPointer<Component> component, QObject *parent);\n\t\n\t//! The destructor\n\tvirtual ~IndirectInterfacesDelegate();\n\n\t/*! Create a new editor for the given item\n\t *\n\t *    @param [in] parent Owner for the editor.\n\t *    @param [in] option Contains options for the editor.\n\t *    @param [in] index Model index identifying the item.\n\t *\n\t *    @return The editor to be used to edit the item.\n\t*/\n\tvirtual QWidget* createEditor(QWidget* parent, const QStyleOptionViewItem& option, \n        QModelIndex const& index) const;\n    \n\n\t/*! Set the data for the editor.\n\t *\n\t *    @param [in] editor The editor where the data is to be set.\n\t *    @param [in] index Model index identifying the item that's data is to be set.\n\t *\n\t*/\n\tvirtual void setEditorData(QWidget* editor, QModelIndex const& index) const;\n\n\t/*! Save the data from the editor to the model.\n\t *\n\t *    @param [in] editor The editor that contains the data to store.\n\t *    @param [in] model Model that contains the data structure where data is to be saved to.\n\t *    @param [in] index Model index identifying the item that's data is to be saved.\n\t *\n\t*/\n\tvirtual void setModelData(QWidget* editor, QAbstractItemModel* model, QModelIndex const& index) const;\n\nprotected:\n\n    virtual int descriptionColumn() const;\n\nprivate slots:\n\n\t/*! Commit the data from the sending editor and close the editor.\n\t *\n\t*/\n\tvoid commitAndCloseEditor();\n\nprivate:\n\t\n\t//! No copying\n\tIndirectInterfacesDelegate(const IndirectInterfacesDelegate& other);\n\tIndirectInterfacesDelegate& operator=(const IndirectInterfacesDelegate& other);\n\n    QStringList findAvailableReferences() const;\n\n    //! The component containing the edited indirect interfaces.\n    QSharedPointer<Component> component_;\n};\n\n#endif // INDIRECT_INTERFACES_DELEGATE_H\n"
  },
  {
    "path": "editors/ComponentEditor/indirectInterfaces/IndirectInterfacesEditor.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: IndirectInterfacesEditor.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Esko Pekkarinen\n// Date: 03.08.2017\n//\n// Description:\n// Editor for component Indirect Interfaces.\n//-----------------------------------------------------------------------------\n\n#include \"IndirectInterfacesEditor.h\"\n\n#include \"IndirectInterfacesDelegate.h\"\n\n#include <common/widgets/summaryLabel/summarylabel.h>\n\n#include <KactusAPI/include/LibraryInterface.h>\n\n#include <IPXACTmodels/Component/Component.h>\n\n#include <QVBoxLayout>\n\n//-----------------------------------------------------------------------------\n// Function: IndirectInterfacesEditor::IndirectInterfacesEditor()\n//-----------------------------------------------------------------------------\nIndirectInterfacesEditor::IndirectInterfacesEditor(LibraryInterface* handler,\n    QSharedPointer<Component> component,\n    QSharedPointer<IndirectInterfaceValidator> validator,\n    QWidget* parent):\nItemEditor(component, handler, parent),\n    view_(this),\n    proxy_(this),\n    model_(component, validator, this)\n{\n\tSummaryLabel* summaryLabel = new SummaryLabel(tr(\"Indirect interfaces summary\"), this);\n\n\tQVBoxLayout* layout = new QVBoxLayout(this);\n\tlayout->addWidget(summaryLabel, 0, Qt::AlignCenter);\n\tlayout->addWidget(&view_);\n\tlayout->setContentsMargins(0, 0, 0, 0);\n\n\tproxy_.setSourceModel(&model_);\n\tview_.setModel(&proxy_);\n\n\tconst QString componentPath = handler->getDirectoryPath(component->getVlnv());\n\tQString defaultPath = QString(\"%1/indirectIfListing.csv\").arg(componentPath);\n\tview_.setDefaultImportExportPath(defaultPath);\n\tview_.setAllowImportExport(true);\n\n    view_.setItemDelegate(new IndirectInterfacesDelegate(component, this));    \n    \n\tconnect(&model_, SIGNAL(contentChanged()), this, SIGNAL(contentChanged()), Qt::UniqueConnection);\n\tconnect(&model_, SIGNAL(interfaceAdded(int)), this, SIGNAL(childAdded(int)), Qt::UniqueConnection);\n\tconnect(&model_, SIGNAL(interfaceRemoved(int)),\tthis, SIGNAL(childRemoved(int)), Qt::UniqueConnection);\n\n\tconnect(&view_, SIGNAL(addItem(const QModelIndex&)),\n        &model_, SLOT(onAddItem(const QModelIndex&)), Qt::UniqueConnection);\n\tconnect(&view_, SIGNAL(removeItem(const QModelIndex&)),\n\t\t&model_, SLOT(onRemoveItem(const QModelIndex&)), Qt::UniqueConnection);\n}\n\n//-----------------------------------------------------------------------------\n// Function: IndirectInterfacesEditor::~IndirectInterfacesEditor()\n//-----------------------------------------------------------------------------\nIndirectInterfacesEditor::~IndirectInterfacesEditor()\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: IndirectInterfacesEditor::refresh()\n//-----------------------------------------------------------------------------\nvoid IndirectInterfacesEditor::refresh()\n{\n\tview_.setModel(&model_);\n}\n\n//-----------------------------------------------------------------------------\n// Function: IndirectInterfacesEditor::showEvent()\n//-----------------------------------------------------------------------------\nvoid IndirectInterfacesEditor::showEvent(QShowEvent* event)\n{\n\tQWidget::showEvent(event);\n\temit helpUrlRequested(\"componenteditor/indirectInterfaces.html\");\n}\n"
  },
  {
    "path": "editors/ComponentEditor/indirectInterfaces/IndirectInterfacesEditor.h",
    "content": "//-----------------------------------------------------------------------------\n// File: IndirectInterfacesEditor.h\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Esko Pekkarinen\n// Date: 03.08.2017\n//\n// Description:\n// Editor for component Indirect Interfaces.\n//-----------------------------------------------------------------------------\n\n#ifndef INDIRECT_INTERFACES_EDITOR_H\n#define INDIRECT_INTERFACES_EDITOR_H\n\n#include \"IndirectInterfacesModel.h\"\n\n#include <common/views/EditableTableView/editabletableview.h>\n\n#include <editors/ComponentEditor/itemeditor.h>\n\n#include <QSortFilterProxyModel>\n#include <QSharedPointer>\n\nclass IndirectInterfaceValidator;\nclass Component;\nclass LibraryInterface;\nclass ParameterFinder;\n\n//-----------------------------------------------------------------------------\n//! Editor to add/remove/edit the bus interfaces of a component.\n//-----------------------------------------------------------------------------\nclass IndirectInterfacesEditor : public ItemEditor\n{\n\tQ_OBJECT\n\npublic:\n\n\t/*!\n\t *  The constructor.\n\t *\n\t *    @param [in] library             The IP library.\n\t *    @param [in] component           The component being edited.\n\t *    @param [in] validator\t\t\tThe validator for indirect interfaces.\n\t *    @param [in] parent              The owner of this editor.\n\t */\n\tIndirectInterfacesEditor(LibraryInterface* library, QSharedPointer<Component> component,\n        QSharedPointer<IndirectInterfaceValidator> validator,\n\t\tQWidget* parent = 0);\n\t\n\t//! The destructor\n\tvirtual ~IndirectInterfacesEditor();\n\n\t/*! Reload the information from the model to the editor.\n\t*/\n\tvirtual void refresh();\n\nprotected:\n\n\t//! Handler for widget's show event\n\tvirtual void showEvent(QShowEvent* event);\n\nprivate:\n\n\t//! No copying\n\tIndirectInterfacesEditor(const IndirectInterfacesEditor& other);\n\tIndirectInterfacesEditor& operator=(const IndirectInterfacesEditor& other);\n\n\t//! The view that displays the summary of the indirect interfaces.\n\tEditableTableView view_;\n\n\t//! The model that does the sorting of items.\n\tQSortFilterProxyModel proxy_;\n\n\t//! The model that manages the indirect interfaces being displayed.\n\tIndirectInterfacesModel model_;\n};\n\n#endif // INDIRECT_INTERFACES_EDITOR_H\n"
  },
  {
    "path": "editors/ComponentEditor/indirectInterfaces/IndirectInterfacesModel.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: IndirectInterfacesModel.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Esko Pekkarinen\n// Date: 03.08.2017\n//\n// Description:\n// Data model for component indirect interfaces.\n//-----------------------------------------------------------------------------\n\n#include \"IndirectInterfacesModel.h\"\n\n#include \"IndirectInterfaceColumns.h\"\n\n#include <IPXACTmodels/Component/IndirectInterface.h>\n#include <IPXACTmodels/Component/Component.h>\n#include <IPXACTmodels/Component/TransparentBridge.h>\n\n#include <IPXACTmodels/Component/validators/IndirectInterfaceValidator.h>\n\n#include <common/KactusColors.h>\n\n#include <QCoreApplication>\n#include <QMap>\n#include <QMessageBox>\n#include <QRegularExpression>\n#include <QString>\n#include <QVariant>\n\n//-----------------------------------------------------------------------------\n// Function: IndirectInterfacesModel::IndirectInterfacesModel()\n//-----------------------------------------------------------------------------\nIndirectInterfacesModel::IndirectInterfacesModel(QSharedPointer<Component> component,\n    QSharedPointer<IndirectInterfaceValidator> validator,\n    QObject *parent):\nQAbstractTableModel(parent),\n    component_(component),\n    indirectInterfaces_(component->getIndirectInterfaces()),\n    validator_(validator)\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: IndirectInterfacesModel::rowCount()\n//-----------------------------------------------------------------------------\nint IndirectInterfacesModel::rowCount(QModelIndex const& parent) const\n{\n\tif (parent.isValid())\n    {\n\t\treturn 0;\n\t}\n\n\treturn indirectInterfaces_->size();\n}\n\n//-----------------------------------------------------------------------------\n// Function: IndirectInterfacesModel::columnCount()\n//-----------------------------------------------------------------------------\nint IndirectInterfacesModel::columnCount(QModelIndex const& parent) const\n{\n\tif (parent.isValid())\n    {\n\t\treturn 0;\n\t}\n\n\treturn IndirectInterfaceColumns::COLUMN_COUNT;\n}\n\n//-----------------------------------------------------------------------------\n// Function: IndirectInterfacesModel::flags()\n//-----------------------------------------------------------------------------\nQt::ItemFlags IndirectInterfacesModel::flags(QModelIndex const& index) const\n{\n\tif (!index.isValid())\n    {\n\t\treturn Qt::NoItemFlags;\n\t}\n\n    if (index.column() == IndirectInterfaceColumns::TRANSPARENT_BRIDGES)\n    {\n        return Qt::ItemIsSelectable | Qt::ItemIsEnabled;\n    }\n\n    if (index.column() == IndirectInterfaceColumns::MEMORY_MAP_REF &&\n        indirectInterfaces_->at(index.row())->getTransparentBridges()->isEmpty() == false)\n    {\n        return Qt::ItemIsSelectable | Qt::ItemIsEnabled;\n    }\n\n\treturn Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsEditable;\n}\n\n//-----------------------------------------------------------------------------\n// Function: IndirectInterfacesModel::headerData()\n//-----------------------------------------------------------------------------\nQVariant IndirectInterfacesModel::headerData(int section, Qt::Orientation orientation, int role) const\n{\n\tif (orientation != Qt::Horizontal || role != Qt::DisplayRole)\n    {\n\t\treturn QVariant();\n    }\n\n    if (section == IndirectInterfaceColumns::NAME)\n    {\n        return tr(\"Name\");\n    }\n    else if (section == IndirectInterfaceColumns::DISPLAY_NAME)\n    {\n        return tr(\"Display\\nname\");\n    }\n    else if (section == IndirectInterfaceColumns::INDIRECT_ADDRESS_REF)\n    {\n        return tr(\"Indirect address\\nfield\");\n    }\n    else if (section == IndirectInterfaceColumns::INDIRECT_DATA_REF)\n    {\n        return tr(\"Indirect data\\nfield\");\n    }\n    else if (section == IndirectInterfaceColumns::MEMORY_MAP_REF)\n    {\n        return tr(\"Memory map\");\n    }\n    else if (section == IndirectInterfaceColumns::TRANSPARENT_BRIDGES)\n    {\n        return tr(\"Transparent\\nbridges\");\n    }\n    else if (section == IndirectInterfaceColumns::DESCRIPTION)\n    {\n        return tr(\"Description\");\n    }\n    else\n    {\n        return QVariant();\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: IndirectInterfacesModel::data()\n//-----------------------------------------------------------------------------\nQVariant IndirectInterfacesModel::data(QModelIndex const& index, int role) const\n{\n\tif (!index.isValid() || index.row() < 0 || index.row() >= indirectInterfaces_->size())\n    {\n\t\treturn QVariant();\n\t}\n\n    QSharedPointer<IndirectInterface> indirectInterface = indirectInterfaces_->at(index.row());\n\tif (role == Qt::DisplayRole)\n    {\n        if (index.column() == IndirectInterfaceColumns::NAME)\n        {\n            return indirectInterface->name();\n        }\n        else if (index.column() == IndirectInterfaceColumns::DISPLAY_NAME)\n        {\n            return indirectInterface->displayName();\n        }\n        else if (index.column() == IndirectInterfaceColumns::INDIRECT_ADDRESS_REF)\n        {\n            return indirectInterface->getIndirectAddressRef();\n        }\n        else if (index.column() == IndirectInterfaceColumns::INDIRECT_DATA_REF)\n        {\n            return indirectInterface->getIndirectDataRef();\n        }\n        else if (index.column() == IndirectInterfaceColumns::MEMORY_MAP_REF)\n        {\n            return indirectInterface->getMemoryMapRef();\n        }\n        else if (index.column() == IndirectInterfaceColumns::TRANSPARENT_BRIDGES)\n        {\n            QStringList initiatorRefs;\n            for (QSharedPointer<TransparentBridge> bridge : *indirectInterface->getTransparentBridges())\n            {\n                initiatorRefs.append(bridge->getInitiatorRef());\n            }\n            return initiatorRefs.join(\", \");\n        }\n        else if (index.column() == IndirectInterfaceColumns::DESCRIPTION)\n        {\n            return indirectInterface->description().replace(QRegularExpression(\"\\n.*$\", \n                QRegularExpression::DotMatchesEverythingOption), \"...\");\n        }\n        else\n        {\n            return QVariant();\n        }\n\t}\n    else if ((role == Qt::EditRole || role == Qt::ToolTipRole) && \n        index.column() == IndirectInterfaceColumns::DESCRIPTION)\n    {\n        return indirectInterface->description();\n    }\n\telse if (role == Qt::ForegroundRole)\n    {\n        if (index.column() == IndirectInterfaceColumns::NAME &&\n            validator_->hasValidName(indirectInterface))\n        {\n            return KactusColors::REGULAR_TEXT;     \n        }\n        else if (index.column() == IndirectInterfaceColumns::DISPLAY_NAME)\n        {\n            return KactusColors::REGULAR_TEXT;   \n        }\n        else if (index.column() == IndirectInterfaceColumns::INDIRECT_ADDRESS_REF && \n            validator_->hasValidAddressReference(indirectInterface))\n        {\n            return KactusColors::REGULAR_TEXT;  \n        }\n        else if (index.column() == IndirectInterfaceColumns::INDIRECT_DATA_REF && \n            validator_->hasValidDataReference(indirectInterface))\n        {\n            return KactusColors::REGULAR_TEXT;  \n        }\n        else if (index.column() == IndirectInterfaceColumns::MEMORY_MAP_REF && \n            validator_->hasValidMemoryMapReference(indirectInterface))\n        {\n            return KactusColors::REGULAR_TEXT;  \n        }\n        else if (index.column() == IndirectInterfaceColumns::TRANSPARENT_BRIDGES &&\n            validator_->hasValidTransparentBridges(indirectInterface->getTransparentBridges()))\n        {\n            return KactusColors::DISABLED_TEXT;  \n        }\n        else if (index.column() == IndirectInterfaceColumns::DESCRIPTION)\n        {\n            return KactusColors::REGULAR_TEXT;\n        }\n        else\n        {\n            return KactusColors::ERROR;\n        }\n\t}\n\telse if (role == Qt::BackgroundRole)\n    {\n        if (index.column() == IndirectInterfaceColumns::NAME ||\n            index.column() == IndirectInterfaceColumns::INDIRECT_ADDRESS_REF ||\n            index.column() == IndirectInterfaceColumns::INDIRECT_DATA_REF)\n        {\n            return KactusColors::MANDATORY_FIELD;\n        }\n        else\n        {\n            return KactusColors::REGULAR_FIELD;\n        }\n\t}\n\telse \n    {\n\t\treturn QVariant();\n\t}\n}\n\n//-----------------------------------------------------------------------------\n// Function: IndirectInterfacesModel::setData()\n//-----------------------------------------------------------------------------\nbool IndirectInterfacesModel::setData(QModelIndex const& index, const QVariant& value, int role)\n{\n\tif (!index.isValid() || index.row() < 0 || index.row() >= indirectInterfaces_->size())\n    {\n\t\treturn false;\n\t}\n\n    QSharedPointer<IndirectInterface> IndirectInterface = indirectInterfaces_->at(index.row());\n\tif (role == Qt::EditRole)\n    {\n        if (index.column() == IndirectInterfaceColumns::NAME)\n        {\n            IndirectInterface->setName(value.toString());\n        }\n        else if (index.column() == IndirectInterfaceColumns::DISPLAY_NAME)\n        {\n            IndirectInterface->setDisplayName(value.toString());\n        }\n        else if (index.column() == IndirectInterfaceColumns::INDIRECT_ADDRESS_REF)\n        {\n            IndirectInterface->setIndirectAddressRef(value.toString());\n        }\n        else if (index.column() == IndirectInterfaceColumns::INDIRECT_DATA_REF)\n        {\n            IndirectInterface->setIndirectDataRef(value.toString());\n        }\n        else if (index.column() == IndirectInterfaceColumns::MEMORY_MAP_REF)\n        {\n            IndirectInterface->setMemoryMapRef(value.toString());\n        }\n        else if (index.column() == IndirectInterfaceColumns::DESCRIPTION)\n        {\n            IndirectInterface->setDescription(value.toString());\n        }\n        else\n        {\n            return false;\n        }\n    \n\t\temit dataChanged(index, index);\n\t\temit contentChanged();\n\t\treturn true;\n\t}\n\telse\n    {\n\t\treturn false;\n\t}\n}\n\n//-----------------------------------------------------------------------------\n// Function: IndirectInterfacesModel::onAddItem()\n//-----------------------------------------------------------------------------\nvoid IndirectInterfacesModel::onAddItem(QModelIndex const& index)\n{\n\tint row = indirectInterfaces_->size();\n\n\t// if the index is valid then add the item to the correct position\n\tif (index.isValid())\n    {\n\t\trow = index.row();\n\t}\n\n\tbeginInsertRows(QModelIndex(), row, row);\n    QSharedPointer<IndirectInterface> indirectInterface(new IndirectInterface());\n    indirectInterfaces_->insert(row, indirectInterface);\n\tendInsertRows();\n\n\temit interfaceAdded(row);\n\n\t// tell also parent widget that contents have been changed\n\temit contentChanged();\n}\n\n//-----------------------------------------------------------------------------\n// Function: IndirectInterfacesModel::onRemoveItem()\n//-----------------------------------------------------------------------------\nvoid IndirectInterfacesModel::onRemoveItem(QModelIndex const& index)\n{\n\t// don't remove anything if index is invalid\n\tif (!index.isValid() || index.row() < 0 || index.row() >= indirectInterfaces_->size())\n    {\n\t\treturn;\n\t}\n\n\t// remove the specified item\n\tbeginRemoveRows(QModelIndex(), index.row(), index.row());\n\tindirectInterfaces_->removeAt(index.row());\n\tendRemoveRows();\n\n\t// inform navigation tree that file set has been removed\n\temit interfaceRemoved(index.row());\n\n\t// tell also parent widget that contents have been changed\n\temit contentChanged();\n}\n"
  },
  {
    "path": "editors/ComponentEditor/indirectInterfaces/IndirectInterfacesModel.h",
    "content": "//-----------------------------------------------------------------------------\n// File: IndirectInterfacesModel.h\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Esko Pekkarinen\n// Date: 03.08.2017\n//\n// Description:\n// Data model for component indirect interfaces.\n//-----------------------------------------------------------------------------\n\n#ifndef INDIRECT_INTERFACES_MODEL_H\n#define INDIRECT_INTERFACES_MODEL_H\n\n#include <QAbstractTableModel>\n\n#include <QSharedPointer>\n#include <QList>\n\nclass IndirectInterface;\nclass IndirectInterfaceValidator;\nclass Component;\nclass ParameterFinder;\nclass Parameter;\n\n//-----------------------------------------------------------------------------\n//! Data model for component indirect interfaces.\n//-----------------------------------------------------------------------------\nclass IndirectInterfacesModel : public QAbstractTableModel\n{\n\tQ_OBJECT\n\npublic:\n\n    /*!\n\t *  The constructor.\n\t *\n\t *    @param [in] component           The component being edited.\n\t *    @param [in] validator\t\t\tThe validator for items.\n\t *    @param [in] parent              The owner of this model.\n\t */\n\tIndirectInterfacesModel(QSharedPointer<Component> component,\n        QSharedPointer<IndirectInterfaceValidator> validator,\n        QObject *parent);\n\t\n    //! No copying\n    IndirectInterfacesModel(const IndirectInterfacesModel& other) = delete;\n    IndirectInterfacesModel& operator=(const IndirectInterfacesModel& other) = delete;\n\n\t//! The destructor\n\tvirtual ~IndirectInterfacesModel() = default;\n\n\t/*! Get the number of rows an item contains.\n\t *\n\t *    @param [in] parent Identifies the parent that's row count is requested.\n\t *\n\t *    @return Number of rows the item has.\n\t*/\n\tvirtual int rowCount(QModelIndex const& parent = QModelIndex()) const;\n\n\t/*! Get the number of columns the item has to be displayed.\n\t *\n\t *    @param [in] parent Identifies the parent that's column count is requested.\n\t *\n\t *    @return The number of columns to be displayed.\n\t*/\n\tvirtual int columnCount(QModelIndex const& parent = QModelIndex()) const;\n\n\t/*! Get the item flags that defines the possible operations for the item.\n\t *\n\t *    @param [in] index Model index that identifies the item.\n\t *\n\t *    @return Qt::ItemFlags specify the possible operations for the item.\n\t*/\n\tQt::ItemFlags flags(QModelIndex const& index) const;\n\n\t/*! Get the header data for specified header.\n\t *\n\t *    @param [in] section The section specifies the row/column number for the header.\n\t *    @param [in] orientation Specified if horizontal or vertical header is wanted.\n\t *    @param [in] role Specifies the type of the requested data.\n\t *\n\t *    @return QVariant Contains the requested data.\n\t*/\n\tvirtual QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;\n\n\t/*! Get the data for specified item.\n\t *\n\t *    @param [in] index Specifies the item that's data is requested.\n\t *    @param [in] role The role that defines what kind of data is requested.\n\t *\n\t *    @return QVariant Contains the data for the item.\n\t*/\n\tvirtual QVariant data(QModelIndex const& index, int role = Qt::DisplayRole) const;\n\n\t/*! Save the data to the model for specified item\n\t *\n\t *    @param [in] index The model index of the item that's data is to be saved.\n\t *    @param [in] value The data that is to be saved.\n\t *    @param [in] role The role specifies what kind of data should be saved.\n\t *\n\t *    @return True if saving happened successfully.\n\t*/\n\tbool setData(QModelIndex const& index, const QVariant& value, int role = Qt::EditRole);\n\npublic slots:\n\n\t/*! Add a new item to the given index.\n\t *\n\t *    @param [in] index The index identifying the position for new item.\n\t *\n\t*/\n\tvoid onAddItem(QModelIndex const& index);\n\n\t/*! Remove the item in the given index.\n\t *\n\t *    @param [in] index The index identifying the item to remove.\n\t *\n\t*/\n\tvoid onRemoveItem(QModelIndex const& index);\n\nsignals:\n\n\t//! Emitted when the contents of the model change.\n\tvoid contentChanged();\n\n\t/*! Emitted when a new bus interface is added to the model.\n\t *\n\t *    @param [in] index The index of the added bus interface.\n\t *\n\t*/\n\tvoid interfaceAdded(int index);\n\n\t/*! Emitted when a bus interface is removed from the model.\n\t *\n\t *    @param [in] index The index of the bus interface to remove.\n\t *\n\t*/\n\tvoid interfaceRemoved(int index);\n\n    /*!\n     *  Increase the number of references made to the specified parameter.\n     *\n     *    @param [in] id  Id of the parameter whose reference count is increased.\n     */\n    void increaseReferences(QString id);\n\n    /*!\n     *  Decrease the number of references made to the specified parameter.\n     *\n     *    @param [in] id  Id of the parameter whose reference count is decreased.\n     */\n    void decreaseReferences(QString id);\n\nprivate:\n\n    //-----------------------------------------------------------------------------\n    // Data.\n    //-----------------------------------------------------------------------------\n\n\t//! The component being edited.\n\tQSharedPointer<Component> component_;\n\n    //! The indirect interfaces being edited.\n    QSharedPointer<QList<QSharedPointer<IndirectInterface> > > indirectInterfaces_;\n\n\t//! The validator to use.\n    QSharedPointer<IndirectInterfaceValidator> validator_;\n\n};\n\n#endif // INDIRECT_INTERFACES_MODEL_H\n"
  },
  {
    "path": "editors/ComponentEditor/indirectInterfaces/SingleIndirectInterfaceEditor.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: SingleIndirectInterfaceEditor.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Esko Pekkarinen\n// Date: 03.08.2017\n//\n// Description:\n// Editor for a single indirect interface within a component.\n//-----------------------------------------------------------------------------\n\n#include \"SingleIndirectInterfaceEditor.h\"\n\n#include <common/KactusColors.h>\n#include <common/widgets/ParameterGroupBox/parametergroupbox.h>\n\n#include <editors/ComponentEditor/common/ReferenceSelector/ReferenceSelector.h>\n#include <editors/ComponentEditor/common/ExpressionEditor.h>\n#include <editors/ComponentEditor/busInterfaces/general/bridgeseditor.h>\n\n#include <QGroupBox>\n#include <QGridLayout>\n#include <QFormLayout>\n#include <QScrollArea>\n#include <QLabel>\n\n#include <IPXACTmodels/Component/Component.h>\n#include <IPXACTmodels/Component/AddressBlock.h>\n#include <IPXACTmodels/Component/MemoryBlockBase.h>\n#include <IPXACTmodels/Component/MemoryMapBase.h>\n#include <IPXACTmodels/Component/MemoryMap.h>\n#include <IPXACTmodels/Component/Register.h>\n#include <IPXACTmodels/Component/RegisterBase.h>\n#include <IPXACTmodels/Component/Field.h>\n#include <IPXACTmodels/Component/IndirectInterface.h>\n\n#include <IPXACTmodels/Component/validators/IndirectInterfaceValidator.h>\n\n//-----------------------------------------------------------------------------\n// Function: SingleIndirectInterfaceEditor::SingleIndirectInterfaceEditor()\n//-----------------------------------------------------------------------------\nSingleIndirectInterfaceEditor::SingleIndirectInterfaceEditor(QSharedPointer<IndirectInterface> indirectInterface,\n    QSharedPointer<IndirectInterfaceValidator> validator, QSharedPointer<Component> component,\n    LibraryInterface* library, QSharedPointer<ParameterFinder> finder,\n    QSharedPointer<ExpressionFormatter> formatter, BusInterfaceInterface* busInterface, QWidget* parent):\nParameterItemEditor(component, library, parent),\nindirectInterface_(indirectInterface),\nvalidator_(validator),\ncomponent_(component),\nnameEditor_(new NameGroupEditor(indirectInterface, component->getRevision(), this, tr(\"Indirect interface name and description\"))),\naddressSelector_(new ReferenceSelector(this)),\ndataSelector_(new ReferenceSelector(this)),\nbitsInLauEditor_(new QLineEdit(this)),\nendiannessSelector_(new QComboBox(this)),\nmemoryMapSelection_(new QCheckBox(tr(\"Memory map\"), this)),\nbridgeSelection_(new QCheckBox(tr(\"Transparent bridge\"), this)),\nmemoryMapSelector_(new ReferenceSelector(this)),\ntransparentBridgesEditor_(new BridgesEditor(busInterface, indirectInterface->getTransparentBridges(), component->getRevision(), this)),\nparametersEditor_(new ParameterGroupBox(indirectInterface_->getParameters(), component->getChoices(), finder,\n    formatter, component->getRevision(), this))\n{\n    addressSelector_->setProperty(\"mandatoryField\", true);\n    dataSelector_->setProperty(\"mandatoryField\", true);\n\n    endiannessSelector_->addItem(QString(\"little\"));\n    endiannessSelector_->addItem(QString(\"big\"));\n    endiannessSelector_->addItem(QString(\"\"));\n\n    transparentBridgesEditor_->setHidden(true);\n    memoryMapSelector_->setHidden(true);\n\n    setupLayout();\n\n    connect(addressSelector_, SIGNAL(itemSelected(QString const&)), this, SLOT(onIndirectAddressChanged()));\n    connect(dataSelector_, SIGNAL(itemSelected(QString const&)), this, SLOT(onIndirectDataChanged()));\n    connect(bitsInLauEditor_, SIGNAL(editingFinished()), this, SLOT(onBitsInLauChanged()));\n    connect(endiannessSelector_, SIGNAL(currentTextChanged(QString const&)), this, SLOT(onEndiannessChanged()));\n    connect(memoryMapSelector_, SIGNAL(itemSelected(QString const&)), this, SLOT(onMemoryMapChanged()));\n \n    connect(memoryMapSelection_, SIGNAL(clicked(bool)), this, SLOT(onMemoryMapSelected(bool)));\n    connect(memoryMapSelection_, SIGNAL(toggled(bool)), memoryMapSelector_, SLOT(setVisible(bool)));\n    connect(bridgeSelection_, SIGNAL(clicked(bool)), this, SLOT(onTransparentBridgeSelected(bool)));\n    connect(bridgeSelection_, SIGNAL(toggled(bool)), transparentBridgesEditor_, SLOT(setVisible(bool)));\n\n    connect(nameEditor_, SIGNAL(contentChanged()), this, SIGNAL(contentChanged()));   \n    connect(transparentBridgesEditor_, SIGNAL(contentChanged()), this, SIGNAL(contentChanged()));\n    connect(parametersEditor_, SIGNAL(contentChanged()), this, SIGNAL(contentChanged()));\n\n    connect(parametersEditor_, SIGNAL(increaseReferences(QString)),\n        this, SIGNAL(increaseReferences(QString)), Qt::UniqueConnection);\n    connect(parametersEditor_, SIGNAL(decreaseReferences(QString)),\n        this, SIGNAL(decreaseReferences(QString)), Qt::UniqueConnection);\n    connect(parametersEditor_, SIGNAL(openReferenceTree(QString const&, QString const&)),\n        this, SIGNAL(openReferenceTree(QString const&, QString const&)), Qt::UniqueConnection);\n\n    connect(parametersEditor_,\n        SIGNAL(recalculateReferencesToParameters(QVector<QString> const&, AbstractParameterInterface*)),\n        this,\n        SIGNAL(recalculateReferencesToParameters(QVector<QString> const&, AbstractParameterInterface*)),\n        Qt::UniqueConnection);\n}\n\n//-----------------------------------------------------------------------------\n// Function: SingleIndirectInterfaceEditor::~SingleIndirectInterfaceEditor()\n//-----------------------------------------------------------------------------\nSingleIndirectInterfaceEditor::~SingleIndirectInterfaceEditor()\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: SingleIndirectInterfaceEditor::refresh()\n//-----------------------------------------------------------------------------\nvoid SingleIndirectInterfaceEditor::refresh()\n{\n    nameEditor_->refresh();\n\n    QStringList referenceList = findAvailableReferences();\n\n    addressSelector_->refresh(referenceList);\n    addressSelector_->selectItem(indirectInterface_->getIndirectAddressRef());\n    setAddressReferenceColorByValidity();\n\n    dataSelector_->refresh(referenceList);\n    dataSelector_->selectItem(indirectInterface_->getIndirectDataRef());\n    setDataReferenceColorByValidity();\n\n    bitsInLauEditor_->setText(indirectInterface_->getBitsInLau());\n    \n    endiannessSelector_->setCurrentIndex(endiannessSelector_->findText(indirectInterface_->getEndianness()));\n\n    memoryMapSelection_->setChecked(!indirectInterface_->getMemoryMapRef().isEmpty());\n    memoryMapSelector_->refresh(component_->getMemoryMapNames());\n    memoryMapSelector_->selectItem(indirectInterface_->getMemoryMapRef());\n    memoryMapSelector_->setVisible(memoryMapSelection_->isChecked());\n\n    bridgeSelection_->setChecked(!indirectInterface_->getTransparentBridges()->isEmpty());\n    transparentBridgesEditor_->refresh();\n    transparentBridgesEditor_->setVisible(bridgeSelection_->isChecked());\n}\n\n//-----------------------------------------------------------------------------\n// Function: SingleIndirectInterfaceEditor::showEvent()\n//-----------------------------------------------------------------------------\nvoid SingleIndirectInterfaceEditor::showEvent(QShowEvent* event)\n{\n    QWidget::showEvent(event);\n    if (component_->getRevision() == Document::Revision::Std22)\n    {\n        emit helpUrlRequested(\"componenteditor/indirectInterface2022.html\");\n    }\n    else\n    {\n        emit helpUrlRequested(\"componenteditor/indirectInterface.html\");\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: SingleIndirectInterfaceEditor::onIndirectAddressChanged()\n//-----------------------------------------------------------------------------\nvoid SingleIndirectInterfaceEditor::onIndirectAddressChanged()\n{\n    indirectInterface_->setIndirectAddressRef(addressSelector_->currentText());\n    setAddressReferenceColorByValidity();\n\n    emit contentChanged();\n}\n\n//-----------------------------------------------------------------------------\n// Function: SingleIndirectInterfaceEditor::onIndirectDataChanged()\n//-----------------------------------------------------------------------------\nvoid SingleIndirectInterfaceEditor::onIndirectDataChanged()\n{\n    indirectInterface_->setIndirectDataRef(dataSelector_->currentText());\n    setDataReferenceColorByValidity();\n\n    emit contentChanged();\n}\n\n//-----------------------------------------------------------------------------\n// Function: SingleIndirectInterfaceEditor::onBitsInLauChanged()\n//-----------------------------------------------------------------------------\nvoid SingleIndirectInterfaceEditor::onBitsInLauChanged()\n{\n    indirectInterface_->setBitsInLau(bitsInLauEditor_->text());\n    emit contentChanged();\n}\n\n//-----------------------------------------------------------------------------\n// Function: SingleIndirectInterfaceEditor::onEndiannessChanged()\n//-----------------------------------------------------------------------------\nvoid SingleIndirectInterfaceEditor::onEndiannessChanged()\n{\n    indirectInterface_->setEndianness(endiannessSelector_->currentText());\n    emit contentChanged();\n}\n\n//-----------------------------------------------------------------------------\n// Function: SingleIndirectInterfaceEditor::onMemoryMapChanged()\n//-----------------------------------------------------------------------------\nvoid SingleIndirectInterfaceEditor::onMemoryMapChanged()\n{\n    indirectInterface_->setMemoryMapRef(memoryMapSelector_->currentText());\n    setMemoryMapColorByValidity();\n\n    emit contentChanged();\n}\n\n//-----------------------------------------------------------------------------\n// Function: SingleIndirectInterfaceEditor::onMemorySelectionChanged()\n//-----------------------------------------------------------------------------\nvoid SingleIndirectInterfaceEditor::onMemoryMapSelected(bool checked)\n{\n    bool canChange = indirectInterface_->getTransparentBridges()->isEmpty();\n    if (canChange)\n    {\n        bridgeSelection_->setChecked(false);\n    }\n    else\n    {\n        memoryMapSelection_->setChecked(!checked);\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: SingleIndirectInterfaceEditor::onTransparentBridgeSelected()\n//-----------------------------------------------------------------------------\nvoid SingleIndirectInterfaceEditor::onTransparentBridgeSelected(bool checked)\n{\n    bool canChange = indirectInterface_->getMemoryMapRef().isEmpty();\n    if (canChange)\n    {\n        memoryMapSelection_->setChecked(false);\n    }\n    else\n    {\n        bridgeSelection_->setChecked(!checked);\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: SingleIndirectInterfaceEditor::setAddressReferenceColorByValidity()\n//-----------------------------------------------------------------------------\nvoid SingleIndirectInterfaceEditor::setAddressReferenceColorByValidity()\n{\n    if (validator_->hasValidAddressReference(indirectInterface_))\n    {\n        addressSelector_->setTextColor(KactusColors::REGULAR_TEXT);\n    }\n    else\n    {\n        addressSelector_->setTextColor(KactusColors::ERROR);\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: SingleIndirectInterfaceEditor::setDataReferenceColorByValidity()\n//-----------------------------------------------------------------------------\nvoid SingleIndirectInterfaceEditor::setDataReferenceColorByValidity()\n{\n    if (validator_->hasValidDataReference(indirectInterface_))\n    {\n        dataSelector_->setTextColor(KactusColors::REGULAR_TEXT);\n    }\n    else\n    {\n        dataSelector_->setTextColor(KactusColors::ERROR);\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: SingleIndirectInterfaceEditor::setMemoryMapColorByValidity()\n//-----------------------------------------------------------------------------\nvoid SingleIndirectInterfaceEditor::setMemoryMapColorByValidity()\n{\n    if (validator_->hasValidMemoryMapReference(indirectInterface_))\n    {\n        memoryMapSelector_->setTextColor(KactusColors::REGULAR_TEXT);\n    }\n    else\n    {\n        memoryMapSelector_->setTextColor(KactusColors::ERROR);\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: SingleIndirectInterfaceEditor::findAvailableReferences()\n//-----------------------------------------------------------------------------\nQStringList SingleIndirectInterfaceEditor::findAvailableReferences() const\n{\n    QStringList fields;\n    for (QSharedPointer<MemoryMap> map : *component_->getMemoryMaps())\n    {\n        for (QSharedPointer<MemoryBlockBase> block : *map->getMemoryBlocks())\n        {\n            QSharedPointer<AddressBlock> addressBlock = block.dynamicCast<AddressBlock>();\n            if (addressBlock)\n            {\n                for (QSharedPointer<RegisterBase> registerBase : *addressBlock->getRegisterData())\n                {\n                    QSharedPointer<Register> reg = registerBase.dynamicCast<Register>();\n                    if (reg)\n                    {\n                        for (QSharedPointer<Field> field : *reg->getFields())\n                        {\n                            if (!field->getId().isEmpty())\n                            {\n                                fields.append(field->getId());\n                            }\n                        }\n                    }\n                }\n            }\n        }\n    }\n\n    return fields;\n}\n\n//-----------------------------------------------------------------------------\n// Function: SingleIndirectInterfaceEditor::setupLayout()\n//-----------------------------------------------------------------------------\nvoid SingleIndirectInterfaceEditor::setupLayout()\n{\n    QScrollArea* scrollArea = new QScrollArea(this);\n    scrollArea->setWidgetResizable(true);\n    scrollArea->setFrameShape(QFrame::NoFrame);\n\n    QHBoxLayout* scrollLayout = new QHBoxLayout(this);\n    scrollLayout->addWidget(scrollArea);\n    scrollLayout->setContentsMargins(0, 0, 0, 0);\n\n    QWidget* topWidget = new QWidget(this);\n\n    QGroupBox* detailsGroup = new QGroupBox(tr(\"General\"), this);\n\n    QFormLayout* detailsLayout = new QFormLayout(detailsGroup);\n    detailsLayout->addRow(tr(\"Indirect address field:\"), addressSelector_);\n    detailsLayout->addRow(tr(\"Indirect data field:\"), dataSelector_);\n    detailsLayout->addRow(tr(\"Bits in Lau:\"), bitsInLauEditor_);\n    detailsLayout->addRow(tr(\"Endianness:\"), endiannessSelector_);\n\n    QGroupBox* memoryBox = new QGroupBox(tr(\"Indirect access target\"), this);\n    memoryBox->setFlat(true);\n\n    auto selectionLayout = new QHBoxLayout();\n    selectionLayout->addWidget(memoryMapSelection_);\n    selectionLayout->addWidget(bridgeSelection_);\n    selectionLayout->addStretch();\n\n    auto memoryLayout = new QVBoxLayout(memoryBox);\n    memoryLayout->addLayout(selectionLayout);\n    memoryLayout->addWidget(memoryMapSelector_);\n    memoryLayout->addWidget(transparentBridgesEditor_);\n    memoryLayout->addStretch();\n\n    QGridLayout* topLayout = new QGridLayout(topWidget);    \n    topLayout->addWidget(nameEditor_, 0, 0, 1, 1);\n    topLayout->addWidget(detailsGroup, 1, 0, 1, 1);\n    topLayout->addWidget(memoryBox, 0, 1, 2, 1);\n    topLayout->addWidget(parametersEditor_, 2, 0, 1, 2);\n    topLayout->setRowStretch(2, 10);\n\n    scrollArea->setWidget(topWidget);\n}\n"
  },
  {
    "path": "editors/ComponentEditor/indirectInterfaces/SingleIndirectInterfaceEditor.h",
    "content": "//-----------------------------------------------------------------------------\n// File: SingleIndrectInterfaceEditor.h\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Esko Pekkarinen\n// Date: 03.08.2017\n//\n// Description:\n// Editor for a single indirect interface within a component.\n//-----------------------------------------------------------------------------\n\n#ifndef SINGLEINDRECTINTERFACEEDITOR_H\n#define SINGLEINDRECTINTERFACEEDITOR_H\n\n#include <editors/ComponentEditor/ParameterItemEditor.h>\n\n#include <common/widgets/nameGroupEditor/namegroupeditor.h>\n\n#include <QCheckBox>\n#include <QComboBox>\n#include <QWidget>\n\nclass BridgesEditor;\nclass Component;\nclass ExpressionFormatter;\nclass LibraryInterface;\nclass IndirectInterface;\nclass IndirectInterfaceValidator;\nclass ReferenceSelector;\nclass ParameterGroupBox;\nclass ParameterFinder;\nclass BusInterfaceInterface;\n\n//-----------------------------------------------------------------------------\n//! Editor for a single indirect interface within a component.\n//-----------------------------------------------------------------------------\nclass SingleIndirectInterfaceEditor : public ParameterItemEditor\n{\n    Q_OBJECT\npublic:\n\n    /*!\n     *  The constructor..\n     *\n     *    @param [in] indirectInterface   The indirect interface to edit.\n     *    @param [in] validator           Validator for the indirect interface.\n     *    @param [in] component           The component containing the indirect interface.\n     *    @param [in] library             The available IP-XACT library.\n     *    @param [in] finder              Finder for available parameters for the indirect interface.\n     *    @param [in] formatter           Formatter for expressions.\n     *    @param [in] parent              The parent widget.\n     */\n    SingleIndirectInterfaceEditor(QSharedPointer<IndirectInterface> indirectInterface,\n        QSharedPointer<IndirectInterfaceValidator> validator,\n        QSharedPointer<Component> component,\n        LibraryInterface* library,\n        QSharedPointer<ParameterFinder> finder,\n        QSharedPointer<ExpressionFormatter> formatter,\n        BusInterfaceInterface* busInterface,\n        QWidget* parent);\n\n\t/*!\n     *  The destructor.\n     */\n\tvirtual ~SingleIndirectInterfaceEditor();\n\n    /*!\n     *  Refreshes the information in the editor.\n     */\n    virtual void refresh();\n    \nprotected:\n\n    /*!\n     *  Called when the editor is shown.\n     */\n    void showEvent(QShowEvent* event);\n\nprivate slots:\n\n    /*!\n     *  Called when the indirect address reference has changed.\n     */\n    void onIndirectAddressChanged();\n\n    /*!\n     *  Called when the indirect ddatareference has changed.\n     */\n    void onIndirectDataChanged();\n\n    /*!\n     *  Called when the bits in lau has changed.\n     */\n    void onBitsInLauChanged();\n\n    /*!\n     *  Called when the endianness has changed.\n     */\n    void onEndiannessChanged();\n\n    /*!\n     *  Called when the indirect memory map has changed.\n     */\n    void onMemoryMapChanged();\n\n    /*!\n     *  Handle the selection of memory map.\n     *\n     *    @param [in] checked     Flag for enabling memory map.\n     */\n    void onMemoryMapSelected(bool checked);\n\n    /*!\n     *  Handle the selection of transparent bridges.\n     *\n     *    @param [in] checked     Flag for enabling transparent bridges.\n     */\n    void onTransparentBridgeSelected(bool checked);\nprivate:\n\n\t// Disable copying.\n\tSingleIndirectInterfaceEditor(SingleIndirectInterfaceEditor const& rhs);    \n    SingleIndirectInterfaceEditor& operator=(SingleIndirectInterfaceEditor const& rhs);\n\n    //! Changes the address reference editor text color to red when invalid and black when valid.\n    void setAddressReferenceColorByValidity();\n\n    //! Changes the data reference editor text color to red when invalid and black when valid.\n    void setDataReferenceColorByValidity();\n\n    //! Changes the memory map reference editor text color to red when invalid and black when valid.\n    void setMemoryMapColorByValidity();\n\n    /*!\n     *  Finds all the available field references.\n     *\n     *    @return The available field references in the current component.\n     */\n    QStringList findAvailableReferences() const;\n\n    //! Sets the editor layout.\n    void setupLayout();\n\n    //-----------------------------------------------------------------------------\n    // Data.\n    //-----------------------------------------------------------------------------\n\n    //! The indirect interface being edited.\n    QSharedPointer<IndirectInterface> indirectInterface_;\n    \n    //! The validator for the indirect interface.\n    QSharedPointer<IndirectInterfaceValidator> validator_;\n\n    //! The component containing the indirect interface.\n    QSharedPointer<Component> component_;\n\n    //! Editor for indirect interface name group.\n    NameGroupEditor* nameEditor_;\n\n    //! Selection editor for address reference.\n    ReferenceSelector* addressSelector_;\n\n    //! Selection editor for data reference.\n    ReferenceSelector* dataSelector_;\n\n    //! Editor for indirect interface bits in lau.\n    QLineEdit*  bitsInLauEditor_;\n\n    //! Selection editor for endianness.\n    QComboBox* endiannessSelector_;\n\n    QCheckBox* memoryMapSelection_;\n\n    QCheckBox* bridgeSelection_;\n\n    //! Selection editor for memory map reference.\n    ReferenceSelector* memoryMapSelector_;\n\n    //! Editor for transparent bridges.\n    BridgesEditor* transparentBridgesEditor_;\n\n    //! Editor for indirect interface parameters.\n    ParameterGroupBox* parametersEditor_;\n};\n\n#endif // SINGLEINDRECTINTERFACEEDITOR_H\n"
  },
  {
    "path": "editors/ComponentEditor/instantiations/ComponentInstantiationDisplayer.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ComponentInstantiationDisplayer.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Esko Pekkarinen\r\n// Date: 26.01.2016\r\n//\r\n// Description:\r\n// Display widget for component instantiations.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"ComponentInstantiationDisplayer.h\"\r\n\r\n#include <IPXACTmodels/Component/ComponentInstantiation.h>\r\n\r\n#include <QFormLayout>\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentInstantiationDisplayer::ComponentInstantiationDisplayer()\r\n//-----------------------------------------------------------------------------\r\nComponentInstantiationDisplayer::ComponentInstantiationDisplayer(QWidget* parent):\r\nQGroupBox(tr(\"Implementation details\"), parent), \r\n    instantiation_(QSharedPointer<ComponentInstantiation>()),\r\n    languageLabel_(new QLabel(this)),\r\n    libraryLabel_(new QLabel(this)),\r\n    packageLabel_(new QLabel(this)),\r\n    moduleNameLabel_(new QLabel(this)),\r\n    architectureLabel_(new QLabel(this)),\r\n    configurationLabel_(new QLabel(this)),\r\n    filesetsLabel_(new QLabel(this))\r\n{\r\n    setupLayout();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentInstantiationDisplayer::~ComponentInstantiationDisplayer()\r\n//-----------------------------------------------------------------------------\r\nComponentInstantiationDisplayer::~ComponentInstantiationDisplayer()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentInstantiationDisplayer::refresh()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentInstantiationDisplayer::refresh()\r\n{    \r\n    if (instantiation_)\r\n    {\r\n        QString language = instantiation_->getLanguage();\r\n        if (instantiation_->isLanguageStrict())\r\n        {\r\n            language.append(\" (strict)\");\r\n        }\r\n\r\n        languageLabel_->setText(language);\r\n        libraryLabel_->setText(instantiation_->getLibraryName());\r\n        packageLabel_->setText(instantiation_->getPackageName());\r\n        moduleNameLabel_->setText(instantiation_->getModuleName());\r\n        architectureLabel_->setText(instantiation_->getArchitectureName());\r\n        configurationLabel_->setText(instantiation_->getConfigurationName());\r\n        \r\n        auto fileSetRefs = instantiation_->getFileSetReferenceStrings();\r\n        filesetsLabel_->setText(fileSetRefs.join(\", \"));\r\n    }\r\n\r\n    setVisible(instantiation_.isNull() == false);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentInstantiationDisplayer::setInstantiation()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentInstantiationDisplayer::setInstantiation(QSharedPointer<ComponentInstantiation> instantiation)\r\n{\r\n    instantiation_ = instantiation;\r\n    refresh();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentInstantiationDisplayer::setupLayout()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentInstantiationDisplayer::setupLayout()\r\n{\r\n    QFormLayout* implementationLayout = new QFormLayout(this);\r\n\r\n    implementationLayout->addRow(tr(\"Language:\"), languageLabel_);\r\n    implementationLayout->addRow(tr(\"Library:\"), libraryLabel_);\r\n    implementationLayout->addRow(tr(\"Package:\"), packageLabel_);\r\n    implementationLayout->addRow(tr(\"Module name:\"), moduleNameLabel_);\r\n    implementationLayout->addRow(tr(\"Architecture:\"), architectureLabel_);\r\n    implementationLayout->addRow(tr(\"Configuration:\"), configurationLabel_);\r\n    implementationLayout->addRow(tr(\"File sets:\"), filesetsLabel_);\r\n}\r\n"
  },
  {
    "path": "editors/ComponentEditor/instantiations/ComponentInstantiationDisplayer.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ComponentInstantiationDisplayer.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Esko Pekkarinen\r\n// Date: 26.01.2016\r\n//\r\n// Description:\r\n// Display widget for component instantiations.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef COMPONENTINSTANTIATIONDISPLAYER_H\r\n#define COMPONENTINSTANTIATIONDISPLAYER_H\r\n\r\n#include <QLabel>\r\n#include <QGroupBox>\r\n\r\nclass ComponentInstantiation;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Display widget for component instantiations.\r\n//-----------------------------------------------------------------------------\r\nclass ComponentInstantiationDisplayer : public QGroupBox\r\n{\r\n\r\npublic:\r\n\r\n    /*!\r\n     *  Constructor.\r\n     *\r\n     *    @param [in] parent          The parent widget.\r\n     */\r\n\tComponentInstantiationDisplayer(QWidget* parent);\r\n\r\n    //! Destructor.\r\n    virtual ~ComponentInstantiationDisplayer();\r\n\r\n\t//! Reload the information from the model to the editor.\r\n\tvirtual void refresh();\r\n\r\n    //! Sets the instantiation whose information to display.\r\n    void setInstantiation(QSharedPointer<ComponentInstantiation> instantiation);\r\n\r\nprivate:\r\n    // Disable copying.\r\n    ComponentInstantiationDisplayer(ComponentInstantiationDisplayer const& rhs);\r\n    ComponentInstantiationDisplayer& operator=(ComponentInstantiationDisplayer const& rhs);\r\n\r\n    //! Setup the layout.\r\n    void setupLayout();\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! The design instantiation being edited.\r\n    QSharedPointer<ComponentInstantiation> instantiation_;\r\n\r\n    //! Text field for instantiation language.\r\n    QLabel* languageLabel_;\r\n\r\n    //! Text field for instantiation library.\r\n    QLabel* libraryLabel_;\r\n\r\n    //! Text field for instantiation package.\r\n    QLabel* packageLabel_;\r\n\r\n    //! Text field for instantiation module name.\r\n    QLabel* moduleNameLabel_;\r\n\r\n    //! Text field for instantiation architecture name.\r\n    QLabel* architectureLabel_;\r\n\r\n    //! Text field for instantiation configuration name.\r\n    QLabel* configurationLabel_;\r\n\r\n    //! Text field for instantiation file set references.\r\n    QLabel* filesetsLabel_;\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n\r\n#endif // COMPONENTINSTANTIATIONDISPLAYER_H\r\n"
  },
  {
    "path": "editors/ComponentEditor/instantiations/ComponentInstantiationEditor.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ComponentInstantiationEditor.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Mikko Teuho\r\n// Date: 26.10.2015\r\n//\r\n// Description:\r\n// Contains the GUI items to edit the settings of a view component instance.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"ComponentInstantiationEditor.h\"\r\n\r\n#include <IPXACTmodels/Component/Component.h>\r\n#include <IPXACTmodels/Component/View.h>\r\n#include <IPXACTmodels/Component/ComponentInstantiation.h>\r\n\r\n#include <KactusAPI/include/ComponentInstantiationInterface.h>\r\n\r\n#include <QGridLayout>\r\n#include <QFormLayout>\r\n#include <QLabel>\r\n#include <QScrollArea>\r\n#include <QStringList>\r\n#include <QVBoxLayout>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentInstantiationEditor::ComponentInstantiationEditor()\r\n//-----------------------------------------------------------------------------\r\nComponentInstantiationEditor::ComponentInstantiationEditor(QSharedPointer<Component> component,\r\n    LibraryInterface* library, QSharedPointer<ComponentInstantiation> componentInstantiation,\r\n    QSharedPointer<ParameterFinder> parameterFinder, QSharedPointer<ExpressionParser> expressionParser,\r\n    QSharedPointer<ExpressionFormatter> expressionFormatter,\r\n    ComponentInstantiationInterface* instantiationInterface, QWidget *parent):\r\nParameterItemEditor(component, library, parent),\r\ncomponent_(component),\r\nnameGroupEditor_(componentInstantiation, component->getRevision(), this, tr(\"Component instance name and description\")),\r\nlanguageEditor_(this), \r\nlanguageStrict_(tr(\"strict\"), this),\r\nlibraryEditor_(this),\r\npackageEditor_(this),\r\nmodulelNameEditor_(this),\r\narchitectureEditor_(this),\r\nconfigurationEditor_(this),\r\nfileSetRefs_(instantiationInterface->getFileSetInterface(), tr(\"File set references\"), this),\r\nfileBuilders_(instantiationInterface->getFileBuilderInterface(), parameterFinder, expressionParser,\r\n              expressionFormatter, componentInstantiation->getDefaultFileBuilders(), this),\r\nmoduleParameters_(componentInstantiation, component->getChoices(), parameterFinder, expressionFormatter,\r\n    instantiationInterface->getModuleParameterInterface(), component->getRevision(), this),\r\nparameters_(componentInstantiation->getParameters(), component->getChoices(), parameterFinder, expressionFormatter, component->getRevision(),\r\n    this),\r\ninstantiationInterface_(instantiationInterface),\r\navailableInstantiations_(component->getComponentInstantiations())\r\n{\r\n    instantiationInterface_->setComponentInstantiations(availableInstantiations_);\r\n\r\n    fileSetRefs_.initialize();\r\n\r\n    connect(&nameGroupEditor_, SIGNAL(contentChanged()), this, SIGNAL(contentChanged()), Qt::UniqueConnection);\r\n\r\n\tconnect(&languageEditor_, SIGNAL(textEdited(const QString&)), \r\n        this, SLOT(onLanguageChange()), Qt::UniqueConnection);\r\n\tconnect(&languageStrict_, SIGNAL(toggled(bool)),\r\n        this, SLOT(onLanguageChange()), Qt::UniqueConnection);\r\n\r\n    connect(&libraryEditor_, SIGNAL(textEdited(const QString&)), \r\n        this, SLOT(onLibraryChange()), Qt::UniqueConnection);\r\n\r\n    connect(&packageEditor_, SIGNAL(textEdited(const QString&)), \r\n        this, SLOT(onPackageChange()), Qt::UniqueConnection);\r\n\r\n\tconnect(&modulelNameEditor_, SIGNAL(textEdited(const QString&)), \r\n        this, SLOT(onModelNameChange()), Qt::UniqueConnection);\r\n\r\n    connect(&architectureEditor_, SIGNAL(textEdited(const QString&)), \r\n        this, SLOT(onArchitectureChange()), Qt::UniqueConnection);\r\n\r\n    connect(&configurationEditor_, SIGNAL(textEdited(const QString&)), \r\n        this, SLOT(onConfigurationChange()), Qt::UniqueConnection);\r\n\r\n\tconnect(&fileSetRefs_, SIGNAL(contentChanged()), this, SLOT(onFileSetRefChange()), Qt::UniqueConnection);\r\n\r\n    connect(&fileBuilders_, SIGNAL(contentChanged()), this, SIGNAL(contentChanged()), Qt::UniqueConnection);\r\n\r\n    connect(&fileBuilders_, SIGNAL(increaseReferences(QString)),\r\n        this, SIGNAL(increaseReferences(QString)), Qt::UniqueConnection);\r\n    connect(&fileBuilders_, SIGNAL(decreaseReferences(QString)),\r\n        this, SIGNAL(decreaseReferences(QString)), Qt::UniqueConnection);\r\n\r\n    connect(&moduleParameters_, SIGNAL(contentChanged()), this, SIGNAL(contentChanged()), Qt::UniqueConnection);\r\n    connect(&moduleParameters_, SIGNAL(increaseReferences(QString)),\r\n        this, SIGNAL(increaseReferences(QString)), Qt::UniqueConnection);\r\n    connect(&moduleParameters_, SIGNAL(decreaseReferences(QString)),\r\n        this, SIGNAL(decreaseReferences(QString)), Qt::UniqueConnection);\r\n    connect(&moduleParameters_, SIGNAL(openReferenceTree(QString const&, QString const&)),\r\n        this, SIGNAL(openReferenceTree(QString const&, QString const&)), Qt::UniqueConnection);\r\n\r\n    connect(&moduleParameters_,\r\n        SIGNAL(recalculateReferencesToParameters(QVector<QString> const&, AbstractParameterInterface*)),\r\n        this,\r\n        SIGNAL(recalculateReferencesToParameters(QVector<QString> const&, AbstractParameterInterface*)),\r\n        Qt::UniqueConnection);\r\n\r\n    connect(&parameters_, SIGNAL(contentChanged()), this, SIGNAL(contentChanged()), Qt::UniqueConnection);\r\n    connect(&parameters_, SIGNAL(increaseReferences(QString)),\r\n        this, SIGNAL(increaseReferences(QString)), Qt::UniqueConnection);\r\n    connect(&parameters_, SIGNAL(decreaseReferences(QString)),\r\n        this, SIGNAL(decreaseReferences(QString)), Qt::UniqueConnection);\r\n    connect(&parameters_, SIGNAL(openReferenceTree(QString const&, QString const&)),\r\n        this, SIGNAL(openReferenceTree(QString const&, QString const&)), Qt::UniqueConnection);\r\n\r\n    connect(&parameters_,\r\n        SIGNAL(recalculateReferencesToParameters(QVector<QString> const&, AbstractParameterInterface*)),\r\n        this,\r\n        SIGNAL(recalculateReferencesToParameters(QVector<QString> const&, AbstractParameterInterface*)),\r\n        Qt::UniqueConnection);\r\n\r\n    setupLayout();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentInstantiationEditor::refresh()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentInstantiationEditor::refresh()\r\n{\r\n    instantiationInterface_->setComponentInstantiations(availableInstantiations_);\r\n\r\n    blockSignals(true);\r\n\r\n    nameGroupEditor_.refresh();\r\n    std::string instantiationName = nameGroupEditor_.name().toStdString();\r\n\r\n    languageEditor_.setText(QString::fromStdString(instantiationInterface_->getLanguage(instantiationName)));\r\n    languageStrict_.setChecked(instantiationInterface_->isLanguageStrict(instantiationName));\r\n\r\n    libraryEditor_.setText(QString::fromStdString(instantiationInterface_->getLibraryName(instantiationName)));\r\n\r\n    packageEditor_.setText(QString::fromStdString(instantiationInterface_->getPackageName(instantiationName)));\r\n\r\n    modulelNameEditor_.setText(QString::fromStdString(instantiationInterface_->getModuleName(instantiationName)));\r\n\r\n    architectureEditor_.setText(\r\n        QString::fromStdString(instantiationInterface_->getArchitectureName(instantiationName)));\r\n\r\n    configurationEditor_.setText(\r\n        QString::fromStdString(instantiationInterface_->getConfigurationName(instantiationName)));\r\n\r\n    QStringList fileSetReferences;\r\n    for (auto fileReference : instantiationInterface_->getFileSetReferences(instantiationName))\r\n    {\r\n        fileSetReferences.append(QString::fromStdString(fileReference));\r\n    }\r\n    fileSetRefs_.setItems(fileSetReferences);\r\n\r\n    fileBuilders_.refresh();\r\n\r\n    moduleParameters_.refresh();\r\n\r\n    parameters_.refresh();\r\n\r\n    blockSignals(false);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentInstantiationEditor::onLanguageChange()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentInstantiationEditor::onLanguageChange()\r\n{\r\n    std::string instantiationName = nameGroupEditor_.name().toStdString();\r\n\r\n    instantiationInterface_->setLanguage(instantiationName, languageEditor_.text().toStdString());\r\n    instantiationInterface_->setLanguageStrictness(instantiationName, languageStrict_.isChecked());\r\n    emit contentChanged();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentInstantiationEditor::onLibraryChange()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentInstantiationEditor::onLibraryChange()\r\n{\r\n    instantiationInterface_->setLibraryName(nameGroupEditor_.name().toStdString(),\r\n        libraryEditor_.text().toStdString());\r\n    emit contentChanged();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentInstantiationEditor::onPackageChange()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentInstantiationEditor::onPackageChange()\r\n{\r\n    instantiationInterface_->setPackageName(nameGroupEditor_.name().toStdString(),\r\n        packageEditor_.text().toStdString());\r\n    emit contentChanged();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentInstantiationEditor::onModelNameChange()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentInstantiationEditor::onModelNameChange()\r\n{\r\n    instantiationInterface_->setModuleName(nameGroupEditor_.name().toStdString(),\r\n        modulelNameEditor_.text().toStdString());\r\n    emit contentChanged();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentInstantiationEditor::onArchitectureChange()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentInstantiationEditor::onArchitectureChange()\r\n{\r\n    instantiationInterface_->setArchitectureName(nameGroupEditor_.name().toStdString(),\r\n        architectureEditor_.text().toStdString());\r\n    emit contentChanged();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentInstantiationEditor::onConfigurationChange()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentInstantiationEditor::onConfigurationChange()\r\n{\r\n    instantiationInterface_->setConfigurationName(nameGroupEditor_.name().toStdString(),\r\n        configurationEditor_.text().toStdString());\r\n    emit contentChanged();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentInstantiationEditor::onFileSetRefChange()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentInstantiationEditor::onFileSetRefChange()\r\n{\r\n    std::vector<std::string> newReferences;\r\n    for (auto setReference : fileSetRefs_.items())\r\n    {\r\n        newReferences.push_back(setReference.toStdString());\r\n    }\r\n    instantiationInterface_->setFileSetReferences(nameGroupEditor_.name().toStdString(), newReferences);\r\n\r\n\temit contentChanged();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentInstantiationEditor::showEvent()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentInstantiationEditor::showEvent(QShowEvent* event)\r\n{\r\n\tQWidget::showEvent(event);\r\n\temit helpUrlRequested(\"componenteditor/componentInstantiation.html\");\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentInstantiationEditor::setupLayout()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentInstantiationEditor::setupLayout()\r\n{\r\n    nameGroupEditor_.setMaximumHeight(QWIDGETSIZE_MAX);\r\n\r\n    QScrollArea* scrollArea = new QScrollArea(this);\r\n    scrollArea->setWidgetResizable(true);\r\n    scrollArea->setFrameShape(QFrame::NoFrame);\r\n\r\n    QVBoxLayout* scrollLayout = new QVBoxLayout(this);\r\n    scrollLayout->addWidget(scrollArea);\r\n    scrollLayout->setContentsMargins(0, 0, 0, 0);\r\n\r\n    QWidget* topWidget = new QWidget(scrollArea);\r\n    topWidget->setContentsMargins(0, 0, 0, 0);\r\n\r\n    QGroupBox* implementationGroup = new QGroupBox(tr(\"Implementation details\"), this);\r\n\r\n    QGridLayout* implementationLayout = new QGridLayout(implementationGroup);\r\n    implementationLayout->addWidget(new QLabel(tr(\"Language:\"), this), 0, 0, 1, 1);\r\n    implementationLayout->addWidget(&languageEditor_, 0, 1, 1, 1);\r\n    implementationLayout->addWidget(&languageStrict_, 0, 2, 1, 1);\r\n\r\n    implementationLayout->addWidget(new QLabel(tr(\"Library:\"), this), 1, 0, 1, 1);\r\n    implementationLayout->addWidget(&libraryEditor_, 1, 1, 1, 2);\r\n    \r\n    implementationLayout->addWidget(new QLabel(tr(\"Package:\"), this), 2, 0, 1, 1);\r\n    implementationLayout->addWidget(&packageEditor_, 2, 1, 1, 2);\r\n\r\n    implementationLayout->addWidget(new QLabel(tr(\"Module name:\"), this), 3, 0, 1, 1);\r\n    implementationLayout->addWidget(&modulelNameEditor_, 3, 1, 1, 2);\r\n\r\n    implementationLayout->addWidget(new QLabel(tr(\"Architecture:\"), this), 4, 0, 1, 1);\r\n    implementationLayout->addWidget(&architectureEditor_, 4, 1, 1, 2);\r\n\r\n    implementationLayout->addWidget(new QLabel(tr(\"Configuration:\"), this), 5, 0, 1, 1);\r\n    implementationLayout->addWidget(&configurationEditor_, 5, 1, 1, 2);\r\n\r\n    QGridLayout* topLayout = new QGridLayout(topWidget);\r\n    topLayout->addWidget(&nameGroupEditor_, 0, 0, 1, 1);\r\n    topLayout->addWidget(implementationGroup, 0, 1, 1, 1);\r\n    topLayout->addWidget(&fileSetRefs_, 1, 0, 1, 1);\r\n    topLayout->addWidget(&fileBuilders_, 1, 1, 1, 1);\r\n    topLayout->addWidget(&moduleParameters_, 2, 0, 1, 2);\r\n    topLayout->addWidget(&parameters_, 3, 0, 1, 2);\r\n    topLayout->setContentsMargins(0, 0, 0, 0);\r\n\r\n    topLayout->setRowStretch(0, 1);\r\n    topLayout->setRowStretch(1, 2);\r\n    topLayout->setRowStretch(2, 5);\r\n\r\n    scrollArea->setWidget(topWidget);\r\n}\r\n"
  },
  {
    "path": "editors/ComponentEditor/instantiations/ComponentInstantiationEditor.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ComponentInstantiationEditor.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Mikko Teuho\r\n// Date: 26.10.2015\r\n//\r\n// Description:\r\n// Contains the GUI items to edit the settings of a view component instance.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef FLATVIEWGENERALTAB_H\r\n#define FLATVIEWGENERALTAB_H\r\n\r\n#include \"filesetrefeditor.h\"\r\n#include \"ModuleParameterEditor.h\"\r\n\r\n#include <common/widgets/nameGroupEditor/namegroupeditor.h>\r\n#include <common/widgets/ParameterGroupBox/parametergroupbox.h>\r\n\r\n#include <editors/ComponentEditor/ParameterItemEditor.h>\r\n#include <editors/ComponentEditor/fileBuilders/filebuilderseditor.h>\r\n\r\n#include <QWidget>\r\n#include <QLineEdit>\r\n#include <QSharedPointer>\r\n#include <QCheckBox>\r\n\r\nclass Component;\r\nclass View;\r\nclass ComponentInstantiation;\r\nclass ExpressionFormatter;\r\nclass ParameterFinder;\r\nclass ExpressionParser;\r\nclass FileBuilderInterface;\r\nclass ComponentInstantiationInterface;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Contains the GUI items to edit the general settings of non-hierarchical view.\r\n//-----------------------------------------------------------------------------\r\nclass ComponentInstantiationEditor : public ParameterItemEditor\r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\r\n\t/*!\r\n     *  The constructor.\r\n\t *\r\n\t *    @param [in] component               The component that contains the view.\r\n\t *    @param [in] view                    The view being edited.\r\n     *    @param [in] parameterFinder         Parameter finder for view parameter expressions.\r\n     *    @param [in] parameterFinder         Finder used to identify parameters.\r\n     *    @param [in] expressionParser        Parser used to calculate expressions.\r\n     *    @param [in] expressionFormatter     Formatter for view parameter expressions.\r\n     *    @param [in] instantiationInterface  Interface for accessing component instantiations.\r\n\t *    @param [in] parent                  The owner of this widget.\r\n\t */\r\n\tComponentInstantiationEditor(QSharedPointer<Component> component,\r\n        LibraryInterface* library,\r\n        QSharedPointer<ComponentInstantiation> componentInstantiation,\r\n        QSharedPointer<ParameterFinder> parameterFinder,\r\n        QSharedPointer<ExpressionParser> expressionParser,\r\n        QSharedPointer<ExpressionFormatter> expressionFormatter,\r\n        ComponentInstantiationInterface* instantiationInterface,\r\n        QWidget *parent);\r\n\t\r\n\t/*!\r\n     *  The destructor.\r\n     */\r\n\tvirtual ~ComponentInstantiationEditor() = default;\r\n\r\n\t/*!\r\n     *  Restore the settings from the model to this editor.\r\n     */\r\n\tvoid refresh();\r\n\r\nprotected:\r\n\r\n\t/*!\r\n     *  Handler for widget's show event\r\n     */\r\n\tvirtual void showEvent(QShowEvent* event);\r\n\r\nprivate slots:\r\n\r\n\t/*!\r\n     *  Handler for changes in language setting.\r\n     */\r\n\tvoid onLanguageChange();\r\n\r\n    /*!\r\n     *  Handler for changes in library setting.\r\n     */\r\n    void onLibraryChange();\r\n\r\n    /*!\r\n     *  Handler for changes in package setting.\r\n     */\r\n    void onPackageChange();\r\n\r\n\t/*!\r\n     *  Handler for changes in model name.\r\n     */\r\n\tvoid onModelNameChange();\r\n\r\n    /*!\r\n     *  Handler for changes in package setting.\r\n     */\r\n    void onArchitectureChange();\r\n\r\n    /*!\r\n     *  Handler for changes in package setting.\r\n     */\r\n    void onConfigurationChange();\r\n\r\n\t/*!\r\n     *  Handler for changes in file set references.\r\n     */\r\n\tvoid onFileSetRefChange();\r\n\r\nprivate:\r\n\t\r\n\t//! No copying.\tNo assignment. No regret.\r\n\tComponentInstantiationEditor(const ComponentInstantiationEditor& other);\r\n\tComponentInstantiationEditor& operator=(const ComponentInstantiationEditor& other);\r\n\r\n    //! Sets the widget layout.\r\n    void setupLayout();\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n\t//! Pointer to the component being edited.\r\n\tQSharedPointer<Component> component_;\r\n\r\n    //! Editor for component instantiation name group.\r\n    NameGroupEditor nameGroupEditor_;\r\n\r\n\t//! Editor to set the hardware description language.\r\n\tQLineEdit languageEditor_;\r\n\r\n    //! Set the strict definition to the language.\r\n    QCheckBox languageStrict_;\r\n\r\n    //! Editor to set the compilation library.\r\n    QLineEdit libraryEditor_;\r\n\r\n    //! Editor to set the VHDL package for the model.\r\n    QLineEdit packageEditor_;\r\n\r\n\t//! Editor to set the model name element value.\r\n\tQLineEdit modulelNameEditor_;\r\n\r\n    //! Editor to set the VHDL architecture name.\r\n    QLineEdit architectureEditor_;\r\n\r\n    //! Editor to set the configuration name.\r\n    QLineEdit configurationEditor_;\r\n\r\n\t//! Editor to set the file set references.\r\n\tFileSetRefEditor fileSetRefs_;\r\n\r\n    //! Editor to set the default file builders.\r\n    FileBuildersEditor fileBuilders_;\r\n\r\n    //! Editor to set the module parameters\r\n    ModuleParameterEditor moduleParameters_;\r\n\r\n    //! Contains the parameters editor.\r\n    ParameterGroupBox parameters_;\r\n\r\n    //! Interface for accessing component instantiations.\r\n    ComponentInstantiationInterface* instantiationInterface_;\r\n\r\n    //! List of available component instantiations.\r\n    QSharedPointer<QList<QSharedPointer<ComponentInstantiation> > > availableInstantiations_;\r\n};\r\n\r\n#endif // FLATVIEWGENERALTAB_H\r\n"
  },
  {
    "path": "editors/ComponentEditor/instantiations/ComponentInstantiationsColumns.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ComponentInstantiationsColumns.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Esko Pekkarinen\r\n// Date: 28.01.2016\r\n//\r\n// Description:\r\n// Common declarations for columns editing component instantiations.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef COMPONENTINSTANTIATIONSCOLUMNS_H\r\n#define COMPONENTINSTANTIATIONSCOLUMNS_H\r\n\r\nnamespace ComponentInstantiationsColumns\r\n{\r\n    //! Defines the columns for the component instantiations table.\r\n    enum Column\r\n    {\r\n        NAME = 0,\r\n        DISPLAY_NAME,\r\n        LANGUAGE,\r\n        DESCRIPTION,\r\n        COLUMN_COUNT\r\n    };\r\n}\r\n\r\n#endif // COMPONENTINSTANTIATIONSCOLUMNS_H"
  },
  {
    "path": "editors/ComponentEditor/instantiations/ComponentInstantiationsEditor.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ComponentInstantiationsEditor.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Esko Pekkarinen\r\n// Date: 28.01.2016\r\n//\r\n// Description:\r\n// Editor for component instantiations.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"ComponentInstantiationsEditor.h\"\r\n\r\n#include \"ComponentInstantiationsColumns.h\"\r\n\r\n#include <common/views/EditableTableView/editabletableview.h>\r\n#include <common/widgets/summaryLabel/summarylabel.h>\r\n#include <common/delegates/LineEditDelegate/lineeditdelegate.h>\r\n\r\n#include <KactusAPI/include/ComponentInstantiationInterface.h>\r\n\r\n#include <KactusAPI/include/LibraryInterface.h>\r\n\r\n#include <QVBoxLayout>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentInstantiationsEditor::ComponentInstantiationsEditor()\r\n//-----------------------------------------------------------------------------\r\nComponentInstantiationsEditor::ComponentInstantiationsEditor(QSharedPointer<Component> component,\r\n    LibraryInterface* handler, QSharedPointer<ParameterFinder> parameterFinder,\r\n    ComponentInstantiationInterface* instantiationInterface, QWidget* parent):\r\nItemEditor(component, handler, parent),\r\nview_(new EditableTableView(this)),\r\nproxy_(new QSortFilterProxyModel(this)),\r\nmodel_(0),\r\ninstantiationInterface_(instantiationInterface),\r\navailableInstantiations_(component->getComponentInstantiations())\r\n{\r\n    instantiationInterface_->setComponentInstantiations(availableInstantiations_);\r\n\r\n    model_ = new ComponentInstantiationsModel(parameterFinder, instantiationInterface_, this);\r\n\r\n\tproxy_->setSourceModel(model_);\r\n    proxy_->setDynamicSortFilter(false);\r\n\r\n\tview_->setModel(proxy_);    \r\n    view_->setSortingEnabled(true);\r\n    view_->sortByColumn(ComponentInstantiationsColumns::NAME, Qt::AscendingOrder);\r\n\r\n\t// items can not be dragged\r\n\tview_->setItemsDraggable(false);\r\n\r\n\tconnect(model_, SIGNAL(contentChanged()), this, SIGNAL(contentChanged()), Qt::UniqueConnection);   \r\n\tconnect(model_, SIGNAL(componentInstantiationAdded(int)), \r\n        this, SIGNAL(childAdded(int)), Qt::UniqueConnection);\r\n\tconnect(model_, SIGNAL(componentInstantiationRemoved(int)),\r\n        this, SIGNAL(childRemoved(int)), Qt::UniqueConnection);\r\n\r\n\tconnect(view_, SIGNAL(addItem(const QModelIndex&)),\r\n        model_, SLOT(onAddItem(const QModelIndex&)), Qt::UniqueConnection);\r\n\tconnect(view_, SIGNAL(removeItem(const QModelIndex&)),\r\n\t\tmodel_, SLOT(onRemoveItem(const QModelIndex&)), Qt::UniqueConnection);\r\n\r\n    connect(model_, SIGNAL(decreaseReferences(QString)), this,\r\n        SIGNAL(decreaseReferences(QString)), Qt::UniqueConnection);\r\n\r\n    SummaryLabel* summaryLabel = new SummaryLabel(tr(\"Component instantiations summary\"), this);\r\n\r\n    QVBoxLayout* layout = new QVBoxLayout(this);\r\n    layout->addWidget(summaryLabel, 0, Qt::AlignCenter);\r\n    layout->addWidget(view_);\r\n    layout->setContentsMargins(0, 0, 0, 0);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentInstantiationsEditor::refresh()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentInstantiationsEditor::refresh()\r\n{\r\n    proxy_->invalidate();\r\n    view_->update();\r\n\r\n    instantiationInterface_->setComponentInstantiations(availableInstantiations_);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentInstantiationsEditor::showEvent()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentInstantiationsEditor::showEvent(QShowEvent* event)\r\n{\r\n    proxy_->invalidate();\r\n\r\n\tQWidget::showEvent(event);\r\n\temit helpUrlRequested(\"componenteditor/componentInstantiations.html\");\r\n}\r\n"
  },
  {
    "path": "editors/ComponentEditor/instantiations/ComponentInstantiationsEditor.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ComponentInstantiationsEditor.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Esko Pekkarinen\r\n// Date: 28.01.2016\r\n//\r\n// Description:\r\n// Editor for component instantiations.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef COMPONENTINSTANTIATIONSEDITOR_H\r\n#define COMPONENTINSTANTIATIONSEDITOR_H\r\n\r\n#include \"ComponentInstantiationsModel.h\"\r\n\r\n#include <editors/ComponentEditor/itemeditor.h>\r\n\r\n#include <QSortFilterProxyModel>\r\n\r\nclass EditableTableView;\r\nclass LibraryInterface;\r\nclass InstantiationsValidator;\r\nclass ParameterFinder;\r\nclass ComponentInstantiationInterface;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Editor for component instantiations.\r\n//-----------------------------------------------------------------------------\r\nclass ComponentInstantiationsEditor : public ItemEditor\r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\r\n\t/*!\r\n     *  The constructor.\r\n\t *\r\n\t *    @param [in] component               The component being edited.\r\n\t *    @param [in] handler                 The instance managing the library.\r\n     *    @param [in] parameterFinder         Finder used to identify parameters.\r\n     *    @param [in] instantiationInterface  Interface for accessing component instantiations.\r\n\t *    @param [in] parent                  The parent of this editor.\r\n\t */\r\n    ComponentInstantiationsEditor(QSharedPointer<Component> component,\r\n        LibraryInterface* handler,\r\n        QSharedPointer<ParameterFinder> parameterFinder,\r\n        ComponentInstantiationInterface* instantiationInterface,\r\n        QWidget* parent = 0);\r\n\r\n\t//! The destructor.\r\n\tvirtual ~ComponentInstantiationsEditor() = default;\r\n\r\n    //! No copying.\r\n    ComponentInstantiationsEditor(const ComponentInstantiationsEditor& other) = delete;\r\n    ComponentInstantiationsEditor& operator=(const ComponentInstantiationsEditor& other) = delete;\r\n\r\n\t//! Reload the information from the model to the editor.\r\n\tvirtual void refresh();\r\n\r\nprotected:\r\n\r\n\t//! Handler for widget's show event.\r\n\tvirtual void showEvent(QShowEvent* event);\r\n\r\nprivate:\r\n\r\n\t//! The view to display the view info.\r\n\tEditableTableView* view_;\r\n\r\n\t//! The proxy that does the sorting.\r\n\tQSortFilterProxyModel* proxy_;\r\n\r\n\t//! The model to manage the component instantiations summary.\r\n    ComponentInstantiationsModel* model_;\r\n\r\n    //! Interface for accessing component instantiations.\r\n    ComponentInstantiationInterface* instantiationInterface_;\r\n\r\n    //! The currently available component instantiations.\r\n    QSharedPointer<QList<QSharedPointer<ComponentInstantiation> > > availableInstantiations_;\r\n};\r\n\r\n#endif // COMPONENTINSTANTIATIONSEDITOR_H\r\n"
  },
  {
    "path": "editors/ComponentEditor/instantiations/ComponentInstantiationsModel.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ComponentInstantiationsModel.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Esko Pekkarinen\r\n// Date: 28.01.2016\r\n//\r\n// Description:\r\n// Model for component instantiations summary.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"ComponentInstantiationsModel.h\"\r\n#include \"ComponentInstantiationsColumns.h\"\r\n\r\n#include <IPXACTmodels/Component/validators/InstantiationsValidator.h>\r\n\r\n#include <common/KactusColors.h>\r\n\r\n#include <editors/ComponentEditor/memoryMaps/memoryMapsExpressionCalculators/ReferenceCalculator.h>\r\n#include <KactusAPI/include/ComponentInstantiationInterface.h>\r\n\r\n#include <QStringList>\r\n#include <QRegularExpression>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentInstantiationsModel::ComponentInstantiationsModel()\r\n//-----------------------------------------------------------------------------\r\nComponentInstantiationsModel::ComponentInstantiationsModel(QSharedPointer<ParameterFinder> finder,\r\n    ComponentInstantiationInterface* instantiationInterface, QObject* parent):\r\nQAbstractTableModel(parent),\r\nparameterFinder_(finder),\r\ninstantiationInterface_(instantiationInterface)\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentInstantiationsModel::~ComponentInstantiationsModel()\r\n//-----------------------------------------------------------------------------\r\nComponentInstantiationsModel::~ComponentInstantiationsModel()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentInstantiationsModel::rowCount()\r\n//-----------------------------------------------------------------------------\r\nint ComponentInstantiationsModel::rowCount(QModelIndex const& parent) const\r\n{\r\n\tif (parent.isValid())\r\n    {\r\n\t\treturn 0;\r\n\t}\r\n    return instantiationInterface_->itemCount();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentInstantiationsModel::columnCount()\r\n//-----------------------------------------------------------------------------\r\nint ComponentInstantiationsModel::columnCount(QModelIndex const& parent) const\r\n{\r\n\tif (parent.isValid())\r\n    {\r\n\t\treturn 0;\r\n\t}\r\n\r\n    return ComponentInstantiationsColumns::COLUMN_COUNT;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentInstantiationsModel::flags()\r\n//-----------------------------------------------------------------------------\r\nQt::ItemFlags ComponentInstantiationsModel::flags(QModelIndex const& index) const\r\n{\r\n\tif (!index.isValid())\r\n    {\r\n\t\treturn Qt::NoItemFlags;\r\n\t}\r\n\r\n\t// Other columns can be edited.\r\n\treturn Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsEditable;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentInstantiationsModel::headerData()\r\n//-----------------------------------------------------------------------------\r\nQVariant ComponentInstantiationsModel::headerData(int section, Qt::Orientation orientation, int role) const\r\n{\r\n\tif (orientation != Qt::Horizontal)\r\n    {\r\n\t\treturn QVariant();\r\n    }\r\n\r\n    if (Qt::DisplayRole == role)\r\n    {\r\n        if (section == ComponentInstantiationsColumns::NAME)\r\n        {\r\n            return tr(\"Name\");\r\n        }\r\n        else if (section == ComponentInstantiationsColumns::DISPLAY_NAME)\r\n        {\r\n            return tr(\"Display name\");\r\n        }\r\n        else if (section == ComponentInstantiationsColumns::LANGUAGE)\r\n        {\r\n            return tr(\"Language\");\r\n        }\r\n        else if (section == ComponentInstantiationsColumns::DESCRIPTION)\r\n        {\r\n            return tr(\"Description\");\r\n        }\r\n        else\r\n        {\r\n            return QVariant();\r\n        }\r\n    }\r\n    else\r\n    {\r\n        return QVariant();\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentInstantiationsModel::data()\r\n//-----------------------------------------------------------------------------\r\nQVariant ComponentInstantiationsModel::data(QModelIndex const& index, int role) const\r\n{\r\n    if (!index.isValid() || index.row() < 0 || index.row() >= instantiationInterface_->itemCount())\r\n    {\r\n        return QVariant();\r\n    }\r\n\r\n    std::string instantiationName = instantiationInterface_->getIndexedItemName(index.row());\r\n\r\n    if (role == Qt::EditRole && index.column() == ComponentInstantiationsColumns::DESCRIPTION)\r\n    {\r\n        return QString::fromStdString(instantiationInterface_->getDescription(instantiationName));\r\n    }\r\n    else if (role == Qt::DisplayRole || role == Qt::EditRole)\r\n    {\r\n        if (index.column() == ComponentInstantiationsColumns::NAME)\r\n        {\r\n            if (!instantiationName.empty())\r\n            {\r\n                return QString::fromStdString(instantiationName);\r\n            }\r\n            else\r\n            {\r\n                return \"unnamed\";\r\n            }\r\n        }\r\n        else if (index.column() == ComponentInstantiationsColumns::DISPLAY_NAME)\r\n        {\r\n            return QString::fromStdString(instantiationInterface_->getDisplayName(instantiationName));\r\n        }\r\n        else if (index.column() == ComponentInstantiationsColumns::LANGUAGE)\r\n        {\r\n            return QString::fromStdString(instantiationInterface_->getLanguage(instantiationName));\r\n        }\r\n        else if (index.column() == ComponentInstantiationsColumns::DESCRIPTION)\r\n        {\r\n            QString instantiationDescription =\r\n                QString::fromStdString(instantiationInterface_->getDescription(instantiationName));\r\n            return instantiationDescription.replace(\r\n                QRegularExpression(\"\\n.*$\", QRegularExpression::DotMatchesEverythingOption), \"...\");\r\n        }\r\n        else\r\n        {\r\n            return QVariant();\r\n        }\r\n\t}\r\n\telse if (role == Qt::ForegroundRole)\r\n    {\r\n        if (index.column() == ComponentInstantiationsColumns::NAME &&\r\n            !instantiationInterface_->itemHasValidName(instantiationName))\r\n        {\r\n            return KactusColors::ERROR;\r\n        }\r\n        else\r\n        {\r\n            return KactusColors::REGULAR_TEXT;\r\n        }\r\n\t}\r\n\telse if (role == Qt::BackgroundRole)\r\n    {\r\n        if (index.column() == ComponentInstantiationsColumns::NAME)\r\n        {\r\n            return KactusColors::MANDATORY_FIELD;\r\n        }\r\n        else\r\n        {\r\n            return KactusColors::REGULAR_FIELD;\r\n        }\r\n    }\r\n    else \r\n    {\r\n\t\treturn QVariant();\r\n\t}\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentInstantiationsModel::setData()\r\n//-----------------------------------------------------------------------------\r\nbool ComponentInstantiationsModel::setData(QModelIndex const& index, const QVariant& value, int role)\r\n{\r\n    if (!index.isValid() || index.row() < 0 || index.row() >= instantiationInterface_->itemCount())\r\n    {\r\n\t\treturn false;\r\n\t}\r\n\r\n    std::string instantiationName = instantiationInterface_->getIndexedItemName(index.row());\r\n\r\n\tif (role == Qt::EditRole)\r\n    {\r\n        std::string newValue = value.toString().toStdString();\r\n\r\n        if (index.column() == ComponentInstantiationsColumns::NAME)\r\n        {\r\n            instantiationInterface_->setName(instantiationName, newValue);\r\n        }\r\n        else if (index.column() == ComponentInstantiationsColumns::DISPLAY_NAME)\r\n        {\r\n            instantiationInterface_->setDisplayName(instantiationName, newValue);\r\n        }\r\n        else if (index.column() == ComponentInstantiationsColumns::LANGUAGE)\r\n        {\r\n            instantiationInterface_->setLanguage(instantiationName, newValue);\r\n        }\r\n        else if (index.column() == ComponentInstantiationsColumns::DESCRIPTION)\r\n        {\r\n            instantiationInterface_->setDescription(instantiationName, newValue);\r\n        }\r\n        else\r\n        {\r\n            return false;\r\n        }\r\n\r\n\t\temit dataChanged(index, index);\r\n\t\temit contentChanged();\r\n\t\treturn true;\r\n\t}\r\n\telse \r\n    {\r\n\t\treturn false;\r\n\t}\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentInstantiationsModel::onAddItem()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentInstantiationsModel::onAddItem(QModelIndex const& index)\r\n{\r\n    int row = instantiationInterface_->itemCount();\r\n\r\n\t// if the index is valid then add the item to the correct position\r\n\tif (index.isValid())\r\n    {\r\n\t\trow = index.row();\r\n\t}\r\n\r\n\tbeginInsertRows(QModelIndex(), row, row);\r\n\r\n    instantiationInterface_->addComponentInstantiation(row);\r\n\r\n\tendInsertRows();\r\n\t\r\n\temit componentInstantiationAdded(row);\r\n\temit contentChanged();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentInstantiationsModel::onRemoveItem()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentInstantiationsModel::onRemoveItem(QModelIndex const& index)\r\n{\r\n\t// don't remove anything if index is invalid\r\n    if (!index.isValid() || index.row() < 0 || index.row() >= instantiationInterface_->itemCount())\r\n    {\r\n\t\treturn;\r\n\t}\r\n\r\n    std::string instantiationName = instantiationInterface_->getIndexedItemName(index.row());\r\n\r\n\t// remove the specified item\r\n\tbeginRemoveRows(QModelIndex(), index.row(), index.row());\r\n\r\n    decreaseReferencesInRemovedComponentInstantiation(instantiationName);\r\n    instantiationInterface_->removeComponentInstantiation(instantiationName);\r\n\r\n    endRemoveRows();\r\n\r\n\temit componentInstantiationRemoved(index.row());\r\n\temit contentChanged();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentInstantiationsModel::decreaseReferencesInRemovedComponentInstantiation()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentInstantiationsModel::decreaseReferencesInRemovedComponentInstantiation(\r\n    std::string const& instantiationName)\r\n{\r\n    QStringList expressionList;\r\n\r\n    std::vector<std::string> names;\r\n    names.push_back(instantiationName);\r\n\r\n    for (auto expression : instantiationInterface_->getExpressionsInSelectedItems(names))\r\n    {\r\n        expressionList.append(QString::fromStdString(expression));\r\n    }\r\n\r\n    ReferenceCalculator referenceCalculator(parameterFinder_);\r\n    QMap<QString, int> referencedParameters = referenceCalculator.getReferencedParameters(expressionList);\r\n    foreach (QString referencedID, referencedParameters.keys())\r\n    {\r\n        for (int i = 0; i < referencedParameters.value(referencedID); ++i)\r\n        {\r\n            emit decreaseReferences(referencedID);\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentInstantiationsModel::getAllReferencableValuesFromParameter()\r\n//-----------------------------------------------------------------------------\r\nQStringList ComponentInstantiationsModel::getAllReferencableValuesFromParameter(\r\n    QSharedPointer<Parameter> selectedParameter) const\r\n{\r\n    QStringList referenceList;\r\n\r\n    referenceList.append(selectedParameter->getValue());\r\n    referenceList.append(selectedParameter->getVectorLeft());\r\n    referenceList.append(selectedParameter->getVectorRight());\r\n    referenceList.append(selectedParameter->getAttribute(\"kactus2:arrayLeft\"));\r\n    referenceList.append(selectedParameter->getAttribute(\"kactus2:arrayRight\"));\r\n\r\n    return referenceList;\r\n}\r\n"
  },
  {
    "path": "editors/ComponentEditor/instantiations/ComponentInstantiationsModel.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ComponentInstantiationsModel.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Esko Pekkarinen\r\n// Date: 28.01.2016\r\n//\r\n// Description:\r\n// Model for component instantiations summary.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef COMPONENTINSTANTIATIONSMODEL_H\r\n#define COMPONENTINSTANTIATIONSMODEL_H\r\n\r\n#include <IPXACTmodels/Component/Component.h>\r\n\r\n#include <QAbstractTableModel>\r\n#include <QList>\r\n#include <QSharedPointer>\r\n\r\nclass InstantiationsValidator;\r\nclass ParameterFinder;\r\nclass Parameter;\r\nclass ComponentInstantiationInterface;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Model for component instantiations summary.\r\n//-----------------------------------------------------------------------------\r\nclass ComponentInstantiationsModel : public QAbstractTableModel\r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\r\n\t/*!\r\n     *  The constructor.\r\n\t *\r\n     *    @param [in] finder                  Finder used to identify parameters.\r\n     *    @param [in] instantiationInterface  Interface for accessing component instantiations.\r\n\t *    @param [in] parent                  Pointer to the owner of the model.\r\n\t */\r\n    ComponentInstantiationsModel(QSharedPointer<ParameterFinder> finder,\r\n        ComponentInstantiationInterface* instantiationInterface,\r\n        QObject* parent);\r\n\r\n\t/*!\r\n     *  The destructor.\r\n     */\r\n\tvirtual ~ComponentInstantiationsModel();\r\n\r\n\t/*!\r\n     *  Get the number of rows an item contains.\r\n\t *\r\n\t *    @param [in] parent  Identifies the parent that's row count is requested.\r\n\t *\r\n\t *    @return Number of rows the item has.\r\n\t */\r\n\tvirtual int rowCount(QModelIndex const& parent = QModelIndex()) const;\r\n\r\n\t/*!\r\n     *  Get the number of columns the item has to be displayed.\r\n\t *\r\n\t *    @param [in] parent  Identifies the parent that's column count is requested.\r\n\t *\r\n\t *    @return The number of columns to be displayed.\r\n\t */\r\n\tvirtual int columnCount(QModelIndex const& parent = QModelIndex()) const;\r\n\r\n\t/*!\r\n     *  Get the item flags that defines the possible operations for the item.\r\n\t *\r\n\t *    @param [in] index   Model index that identifies the item.\r\n\t *\r\n\t *    @return Qt::ItemFlags specify the possible operations for the item.\r\n\t */\r\n\tQt::ItemFlags flags(QModelIndex const& index) const;\r\n\r\n\t/*!\r\n     *  Get the header data for specified header.\r\n\t *\r\n\t *    @param [in] section         The section specifies the row/column number for the header.\r\n\t *    @param [in] orientation     Specified if horizontal or vertical header is wanted.\r\n\t *    @param [in] role            Specifies the type of the requested data.\r\n\t *\r\n\t *    @return The requested data.\r\n\t */\r\n\tvirtual QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;\r\n\r\n\t/*!\r\n     *  Get the data for specified item.\r\n\t *\r\n\t *    @param [in] index   Specifies the item that's data is requested.\r\n\t *    @param [in] role    The role that defines what kind of data is requested.\r\n\t *\r\n\t *    @return The data for the item.\r\n\t */\r\n\tvirtual QVariant data(QModelIndex const& index, int role = Qt::DisplayRole) const;\r\n\r\n\t/*!\r\n     *  Save the data to the model for specified item.\r\n\t *\r\n\t *    @param [in] index   The model index of the item that's data is to be saved.\r\n\t *    @param [in] value   The data that is to be saved.\r\n\t *    @param [in] role    The role specifies what kind of data should be saved.\r\n\t *\r\n\t *    @return True, if saving happened successfully, otherwise false.\r\n\t */\r\n\tbool setData(QModelIndex const& index, const QVariant& value, int role = Qt::EditRole);\r\n\r\npublic slots:\r\n\r\n\t/*!\r\n     *  Add a new item to the given index.\r\n\t *\r\n\t *    @param [in] index   The index identifying the position for new item.\r\n\t */\r\n\tvirtual void onAddItem(QModelIndex const& index);\r\n\r\n\t/*!\r\n     *  Remove the item in the given index.\r\n\t *\r\n\t *    @param [in] index   The index identifying the item to remove.\r\n\t */\r\n\tvirtual void onRemoveItem(QModelIndex const& index);\r\n\r\nsignals:\r\n\r\n\t//! Emitted when the contents of the model change.\r\n\tvoid contentChanged();\r\n\r\n\t//! Emitted when a new component instantiation is added to the given index.\r\n\tvoid componentInstantiationAdded(int index);\r\n\r\n\t//! Emitted when a component instantiation is removed from the given index.\r\n\tvoid componentInstantiationRemoved(int index);\r\n    \r\n    /*!\r\n     *  Decrease the amount of references to the selected parameter.\r\n     *\r\n     *    @param [in] valueId   The id of the referenced parameter.\r\n     */\r\n    void decreaseReferences(QString valueId) const;\r\n\r\nprivate:\r\n\t//! No copying.\r\n\tComponentInstantiationsModel(const ComponentInstantiationsModel& other);\r\n\tComponentInstantiationsModel& operator=(const ComponentInstantiationsModel& other);\r\n\r\n    /*!\r\n     *  Remove references made in the selected component instantiation.\r\n     *\r\n     *    @param [in] instantiationName   Name of the selected component instantiation.\r\n     */\r\n    void decreaseReferencesInRemovedComponentInstantiation(std::string const& instantiationName);\r\n\r\n    /*!\r\n     *  Get all the referable values form a given parameter.\r\n     *\r\n     *    @param [in] selectedParameter   The selected parameter.\r\n     *\r\n     *    @return A list of values with possible references to parameters.\r\n     */\r\n    QStringList getAllReferencableValuesFromParameter(QSharedPointer<Parameter> selectedParameter) const;\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! The component being edited.\r\n\tQSharedPointer<Component> component_;\r\n\r\n    //! Finder for identifying parameters.\r\n    QSharedPointer<ParameterFinder> parameterFinder_;\r\n\r\n    //! Interface for accessing component instantiations.\r\n    ComponentInstantiationInterface* instantiationInterface_;\r\n};\r\n\r\n#endif // COMPONENTINSTANTIATIONSMODEL_H\r\n"
  },
  {
    "path": "editors/ComponentEditor/instantiations/DesignConfigurationInstantiationEditor.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: DesignConfigurationInstantiationEditor.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Esko Pekkarinen\r\n// Date: 26.01.2016\r\n//\r\n// Description:\r\n// Editor for design configuration instantiations.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"DesignConfigurationInstantiationEditor.h\"\r\n\r\n#include <common/widgets/nameGroupEditor/namegroupeditor.h>\r\n#include <common/widgets/vlnvEditor/vlnveditor.h>\r\n\r\n#include <KactusAPI/include/ParameterFinder.h>\r\n#include <KactusAPI/include/ExpressionFormatter.h>\r\n#include <KactusAPI/include/ListParameterFinder.h>\r\n#include <KactusAPI/include/MultipleParameterFinder.h>\r\n#include <KactusAPI/include/LibraryInterface.h>\r\n#include <KactusAPI/include/ParameterConfigurableElementFinder.h>\r\n#include <editors/ComponentEditor/common/ConfigurableElementFinder.h>\r\n#include <KactusAPI/include/IPXactSystemVerilogParser.h>\r\n#include <editors/ComponentEditor/common/InstantiationConfigurableElementEditor.h>\r\n#include <editors/ComponentEditor/parameters/ComponentParameterModel.h>\r\n\r\n#include <IPXACTmodels/DesignConfiguration/DesignConfiguration.h>\r\n#include <IPXACTmodels/Component/Component.h>\r\n\r\n#include <QApplication>\r\n#include <QMainWindow>\r\n#include <QScrollArea>\r\n#include <QHBoxLayout>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignConfigurationInstantiationEditor::DesignConfigurationInstantiationEditor()\r\n//-----------------------------------------------------------------------------\r\nDesignConfigurationInstantiationEditor::DesignConfigurationInstantiationEditor(QSharedPointer<Component> component,\r\n    QSharedPointer<DesignConfigurationInstantiation> instantiation,\r\n    QSharedPointer<ParameterFinder> parameterFinder, QSharedPointer<ExpressionFormatter> expressionFormatter,\r\n    LibraryInterface* libHandler, QWidget* parent):\r\nParameterItemEditor(component, libHandler, parent), \r\ninstantiation_(instantiation),\r\nnameGroupEditor_(new NameGroupEditor(instantiation, component->getRevision(), this,\r\n    tr(\"Design configuration instance name and description\"))),\r\ndesignConfigurationEditor_(0),\r\nparameters_(instantiation->getParameters(), component->getChoices(), parameterFinder, expressionFormatter, component->getRevision(), this),\r\nelementEditor_(0),\r\ndesignConfigurationParameterFinder_(new ListParameterFinder())\r\n{\r\n    createConfigurableElementEditor(parameterFinder);\r\n\r\n    designConfigurationEditor_ = new VLNVEditor(VLNV::DESIGNCONFIGURATION, libHandler, this, this);\r\n    designConfigurationEditor_->setRevisionFilter(true, component->getRevision());\r\n    designConfigurationEditor_->setTitle(tr(\"Design configuration reference\"));\r\n    designConfigurationEditor_->setMandatory(true);\r\n    designConfigurationEditor_->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);\r\n\r\n    connect(&parameters_, SIGNAL(increaseReferences(QString)),\r\n        this, SIGNAL(increaseReferences(QString)), Qt::UniqueConnection);\r\n    connect(&parameters_, SIGNAL(decreaseReferences(QString)),\r\n        this, SIGNAL(decreaseReferences(QString)), Qt::UniqueConnection);\r\n    connect(&parameters_, SIGNAL(openReferenceTree(QString const&, QString const&)),\r\n        this, SIGNAL(openReferenceTree(QString const&, QString const&)), Qt::UniqueConnection);\r\n\r\n    connect(&parameters_,\r\n        SIGNAL(recalculateReferencesToParameters(QVector<QString> const&, AbstractParameterInterface*)),\r\n        this,\r\n        SIGNAL(recalculateReferencesToParameters(QVector<QString> const&, AbstractParameterInterface*)),\r\n        Qt::UniqueConnection);\r\n\r\n    connect(&parameters_, SIGNAL(contentChanged()), this, SIGNAL(contentChanged()), Qt::UniqueConnection);\r\n\r\n    connect(nameGroupEditor_, SIGNAL(contentChanged()), this, SIGNAL(contentChanged()), Qt::UniqueConnection);\r\n    connect(designConfigurationEditor_, SIGNAL(vlnvEdited()), this, SLOT(onHierRefChange()), Qt::UniqueConnection);\r\n   \r\n    connect(elementEditor_, SIGNAL(contentChanged()), this, SIGNAL(contentChanged()), Qt::UniqueConnection);\r\n    connect(elementEditor_, SIGNAL(increaseReferences(QString)),\r\n        this, SIGNAL(increaseReferences(QString)), Qt::UniqueConnection);\r\n    connect(elementEditor_, SIGNAL(decreaseReferences(QString)),\r\n        this, SIGNAL(decreaseReferences(QString)), Qt::UniqueConnection);\r\n\r\n    refresh();\r\n\r\n    setupLayout();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignConfigurationInstantiationEditor::createConfigurableElementEditor()\r\n//-----------------------------------------------------------------------------\r\nvoid DesignConfigurationInstantiationEditor::createConfigurableElementEditor(\r\n    QSharedPointer<ParameterFinder> parameterFinder)\r\n{\r\n\tQSharedPointer<ParameterConfigurableElementFinder> elementFinder(new ParameterConfigurableElementFinder());\r\n\r\n    QSharedPointer<MultipleParameterFinder> cevElementFinder(new MultipleParameterFinder());\r\n    cevElementFinder->addFinder(elementFinder);\r\n    cevElementFinder->addFinder(parameterFinder);\r\n\r\n    QSharedPointer<IPXactSystemVerilogParser> cevElementParser(new IPXactSystemVerilogParser(cevElementFinder));\r\n\tQSharedPointer<IPXactSystemVerilogParser> defaultElementParser(\r\n\t\tnew IPXactSystemVerilogParser(designConfigurationParameterFinder_));\r\n\r\n\tauto completionModel = new ComponentParameterModel(cevElementFinder, this);\r\n\tcompletionModel->setExpressionParser(cevElementParser);\r\n\r\n    ExpressionSet cevElementExpressions({ cevElementFinder , cevElementParser,\r\n        QSharedPointer<ExpressionFormatter>(new ExpressionFormatter(cevElementFinder)) });\r\n    ExpressionSet defaultElementExpressions({ designConfigurationParameterFinder_,defaultElementParser,\r\n        QSharedPointer<ExpressionFormatter>(new ExpressionFormatter(designConfigurationParameterFinder_)) });\r\n\r\n    elementEditor_ = new InstantiationConfigurableElementEditor(elementFinder, \r\n        cevElementExpressions, defaultElementExpressions, completionModel, this);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignConfigurationInstantiationEditor::refresh()\r\n//-----------------------------------------------------------------------------\r\nvoid DesignConfigurationInstantiationEditor::refresh()\r\n{\r\n\tnameGroupEditor_->refresh();\r\n    designConfigurationEditor_->setVLNV(*instantiation_->getDesignConfigurationReference());\r\n    parameters_.refresh();\r\n\r\n    setupParametersAsConfigurableElements();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignConfigurationInstantiationEditor::onHierRefChange()\r\n//-----------------------------------------------------------------------------\r\nvoid DesignConfigurationInstantiationEditor::onHierRefChange()\r\n{\r\n\tinstantiation_->getDesignConfigurationReference()->setVLNV(designConfigurationEditor_->getVLNV());\r\n    setupParametersAsConfigurableElements();\r\n\r\n\temit contentChanged();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignConfigurationInstantiationEditor::setupParametersAsConfigurableElements()\r\n//-----------------------------------------------------------------------------\r\nvoid DesignConfigurationInstantiationEditor::setupParametersAsConfigurableElements()\r\n{\r\n    QSharedPointer<QList<QSharedPointer<Parameter> > > newParameters;\r\n    QSharedPointer<QList<QSharedPointer<ConfigurableElementValue> > > newElements;\r\n\r\n    QSharedPointer<const Document> configurationDocument = handler()->getModelReadOnly(\r\n        designConfigurationEditor_->getVLNV());\r\n    QSharedPointer<const DesignConfiguration> designConfiguration(0);\r\n    if (configurationDocument)\r\n    {\r\n        designConfiguration = configurationDocument.staticCast<const DesignConfiguration>();\r\n        if (designConfiguration)\r\n        {\r\n            newParameters = designConfiguration->getParameters();\r\n        }\r\n    }\r\n\r\n    if (instantiation_->getDesignConfigurationReference())\r\n    {\r\n        newElements = instantiation_->getDesignConfigurationReference()->getConfigurableElementValues();\r\n    }\r\n\r\n    designConfigurationParameterFinder_->setParameterList(newParameters);\r\n\r\n    if (designConfiguration && instantiation_->getDesignConfigurationReference())\r\n    {\r\n        elementEditor_->setParameters(designConfiguration->getVlnv().toString(), newParameters, \r\n            designConfiguration->getRevision(), newElements);\r\n    }\r\n    else\r\n    {\r\n        elementEditor_->clear();\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignConfigurationInstantiationEditor::showEvent()\r\n//-----------------------------------------------------------------------------\r\nvoid DesignConfigurationInstantiationEditor::showEvent(QShowEvent* event)\r\n{\r\n\tQWidget::showEvent(event);\r\n\temit helpUrlRequested(\"componenteditor/designConfigurationInstantiation.html\");\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignConfigurationInstantiationEditor::setupLayout()\r\n//-----------------------------------------------------------------------------\r\nvoid DesignConfigurationInstantiationEditor::setupLayout()\r\n{\r\n    QScrollArea* scrollArea = new QScrollArea(this);\r\n    scrollArea->setWidgetResizable(true);\r\n    scrollArea->setFrameShape(QFrame::NoFrame);\r\n\r\n    QHBoxLayout* scrollLayout = new QHBoxLayout(this);\r\n    scrollLayout->addWidget(scrollArea);\r\n    scrollLayout->setContentsMargins(0, 0, 0, 0);\r\n\r\n    QWidget* topWidget = new QWidget(scrollArea);\r\n    topWidget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);\r\n    scrollArea->setWidget(topWidget);\r\n\r\n    QGridLayout* topLayout = new QGridLayout(topWidget);\r\n    topLayout->setContentsMargins(0, 0, 0, 0);\r\n    topLayout->addWidget(nameGroupEditor_, 0, 0, 1, 1, Qt::AlignTop);\r\n    topLayout->addWidget(designConfigurationEditor_, 0, 1, 1, 1, Qt::AlignTop);\r\n    topLayout->addWidget(elementEditor_, 1, 0, 1, 1);\r\n    topLayout->addWidget(&parameters_, 2, 0, 2, 2);\r\n    topLayout->setRowStretch(2, 3);\r\n}\r\n"
  },
  {
    "path": "editors/ComponentEditor/instantiations/DesignConfigurationInstantiationEditor.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: DesignConfigurationInstantiationEditor.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Esko Pekkarinen\r\n// Date: 26.01.2016\r\n//\r\n// Description:\r\n// Editor for design configuration instantiations.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef DESIGNCONFIGURATIONINSTANTIATIONEDITOR_H\r\n#define DESIGNCONFIGURATIONINSTANTIATIONEDITOR_H\r\n\r\n#include <editors/ComponentEditor/ParameterItemEditor.h>\r\n#include <common/widgets/ParameterGroupBox/parametergroupbox.h>\r\n\r\nclass VLNVEditor;\r\nclass NameGroupEditor;\r\nclass ParameterFinder;\r\nclass ExpressionFormatter;\r\nclass ListParameterFinder;\r\nclass DesignConfigurationInstantiation;\r\nclass InstantiationConfigurableElementEditor;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Editor for design configuration instantiations.\r\n//-----------------------------------------------------------------------------\r\nclass DesignConfigurationInstantiationEditor : public ParameterItemEditor\r\n{\r\n    Q_OBJECT\r\n\r\npublic:\r\n    /*!\r\n     *  Constructor.\r\n     *\r\n     *    @param [in] component               The component being edited.\r\n     *    @param [in] instantiation\t        The instantiation being edited.\t\r\n     *    @param [in] libHandler              The available IP-XACT library.\r\n     *    @param [in] parameterFinder         Pointer to the parameter finder.\r\n     *    @param [in] expressionFormatter     Pointer to the expression formatter.\r\n     *    @param [in] parent                  The parent widget.\r\n     */\r\n\tDesignConfigurationInstantiationEditor(QSharedPointer<Component> component, \r\n        QSharedPointer<DesignConfigurationInstantiation> instantiation,\r\n        QSharedPointer<ParameterFinder> parameterFinder,\r\n        QSharedPointer<ExpressionFormatter> expressionFormatter,\r\n\t\tLibraryInterface* libHandler,\r\n        QWidget* parent);\r\n    \r\n    // Disable copying.\r\n    DesignConfigurationInstantiationEditor(DesignConfigurationInstantiationEditor const& rhs) = delete;\r\n    DesignConfigurationInstantiationEditor& operator=(DesignConfigurationInstantiationEditor const& rhs) = delete;\r\n\r\n    //! Destructor.\r\n    virtual ~DesignConfigurationInstantiationEditor() = default;\r\n\r\n\t//! Reload the information from the model to the editor.\r\n\tvirtual void refresh() override;\r\n\r\nprotected:\r\n\r\n\t//! Handler for widget's show event.\r\n\tvirtual void showEvent(QShowEvent* event) override;\r\n\r\nprivate slots:\r\n\r\n\t//! Handler for changes in design configuration reference.\r\n\tvoid onHierRefChange();\r\n\r\nprivate:\r\n\r\n    //! Setup the layout.\r\n    void setupLayout();\r\n\r\n    /*!\r\n     *  Setup the design configuration parameters as configurable element values.\r\n     */\r\n    void setupParametersAsConfigurableElements();\r\n\r\n    /*!\r\n     *  Create configurable element editor.\r\n     *\r\n     *    @param [in] parameterFinder     The component parameter finder.\r\n     */\r\n    void createConfigurableElementEditor(QSharedPointer<ParameterFinder> parameterFinder);\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! The design configuration instantiation being edited.\r\n    QSharedPointer<DesignConfigurationInstantiation> instantiation_;\r\n\r\n    //! Editor to set the name, display name and description of the design configuration instantiation.\r\n    NameGroupEditor* nameGroupEditor_;\r\n\r\n    //! VLNV editor for the design configuration reference.\r\n    VLNVEditor* designConfigurationEditor_;\r\n\r\n    //! Contains the parameters editor.\r\n    ParameterGroupBox parameters_;\r\n\r\n    //! Contains the configurable element values editor.\r\n    InstantiationConfigurableElementEditor* elementEditor_;\r\n\r\n    //! Parameter finder for the referenced design configuration.\r\n    QSharedPointer<ListParameterFinder> designConfigurationParameterFinder_;\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n\r\n#endif // DESIGNCONFIGURATIONINSTANTIATIONEDITOR_H\r\n"
  },
  {
    "path": "editors/ComponentEditor/instantiations/DesignConfigurationInstantiationsEditor.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: DesignConfigurationInstantiationsEditor.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Esko Pekkarinen\r\n// Date: 29.01.2016\r\n//\r\n// Description:\r\n// Editor for DesignConfiguration instantiations.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"DesignConfigurationInstantiationsEditor.h\"\r\n\r\n#include \"ComponentInstantiationsColumns.h\"\r\n#include \"DesignInstantiationsDelegate.h\"\r\n\r\n#include <common/views/EditableTableView/editabletableview.h>\r\n#include <common/widgets/summaryLabel/summarylabel.h>\r\n#include <common/delegates/LineEditDelegate/lineeditdelegate.h>\r\n\r\n#include <KactusAPI/include/LibraryInterface.h>\r\n\r\n#include <QVBoxLayout>\r\n#include <QMessageBox>\r\n#include <QCoreApplication>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignConfigurationInstantiationsEditor::DesignConfigurationInstantiationsEditor()\r\n//-----------------------------------------------------------------------------\r\nDesignConfigurationInstantiationsEditor::DesignConfigurationInstantiationsEditor(\r\n    QSharedPointer<Component> component, \r\n    LibraryInterface* handler, QSharedPointer<InstantiationsValidator> validator, QWidget* parent):\r\nItemEditor(component, handler, parent),\r\n    view_(new EditableTableView(this)),\r\n    proxy_(new QSortFilterProxyModel(this)),\r\n    model_(component->getDesignConfigurationInstantiations(), validator, component, handler, this)\r\n{\r\n\tproxy_->setSourceModel(&model_);\t\r\n    proxy_->setDynamicSortFilter(false);\r\n\r\n\tview_->setModel(proxy_);    \r\n    view_->setSortingEnabled(true);\r\n    view_->sortByColumn(ComponentInstantiationsColumns::NAME, Qt::AscendingOrder);\r\n\r\n\t// items can not be dragged\r\n\tview_->setItemsDraggable(false);\r\n    view_->setDropIndicatorShown(true);   \r\n    view_->setDragDropMode(QAbstractItemView::DropOnly);\r\n\r\n    view_->setItemDelegate(new DesignInstantiationsDelegate(this));\r\n\r\n\tconnect(&model_, SIGNAL(contentChanged()), this, SIGNAL(contentChanged()), Qt::UniqueConnection);    \r\n\tconnect(&model_, SIGNAL(designConfigurationInstantiationAdded(int)), \r\n        this, SIGNAL(childAdded(int)), Qt::UniqueConnection);\r\n\tconnect(&model_, SIGNAL(designConfigurationInstantiationRemoved(int)),\r\n        this, SIGNAL(childRemoved(int)), Qt::UniqueConnection);\r\n    connect(&model_, SIGNAL(stdRevisionMismatch()), this, SLOT(stdRevisionMismatchWarning()), Qt::UniqueConnection);\r\n\r\n\tconnect(view_, SIGNAL(addItem(const QModelIndex&)),\r\n        &model_, SLOT(onAddItem(const QModelIndex&)), Qt::UniqueConnection);\r\n\tconnect(view_, SIGNAL(removeItem(const QModelIndex&)),\r\n\t\t&model_, SLOT(onRemoveItem(const QModelIndex&)), Qt::UniqueConnection);\r\n\r\n    SummaryLabel* summaryLabel = new SummaryLabel(tr(\"Design configuration instantiations summary\"), this);\r\n\r\n    QVBoxLayout* layout = new QVBoxLayout(this);\r\n    layout->addWidget(summaryLabel, 0, Qt::AlignCenter);\r\n    layout->addWidget(view_);\r\n    layout->setContentsMargins(0, 0, 0, 0);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignConfigurationInstantiationsEditor::~DesignConfigurationInstantiationsEditor()\r\n//-----------------------------------------------------------------------------\r\nDesignConfigurationInstantiationsEditor::~DesignConfigurationInstantiationsEditor()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignConfigurationInstantiationsEditor::refresh()\r\n//-----------------------------------------------------------------------------\r\nvoid DesignConfigurationInstantiationsEditor::refresh()\r\n{    \r\n    proxy_->invalidate();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignConfigurationInstantiationsEditor::stdRevisionMismatchWarning()\r\n//-----------------------------------------------------------------------------\r\nvoid DesignConfigurationInstantiationsEditor::stdRevisionMismatchWarning()\r\n{\r\n    QMessageBox::warning(this, QCoreApplication::applicationName(),\r\n        tr(\"Dropped item cannot use different IP-XACT standard revision than the item being edited.\"),\r\n        QMessageBox::Close, QMessageBox::Close);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignConfigurationInstantiationsEditor::showEvent()\r\n//-----------------------------------------------------------------------------\r\nvoid DesignConfigurationInstantiationsEditor::showEvent(QShowEvent* event)\r\n{\r\n    proxy_->invalidate();\r\n\r\n\tQWidget::showEvent(event);\r\n\temit helpUrlRequested(\"componenteditor/designConfigurationInstantiations.html\");\r\n}\r\n"
  },
  {
    "path": "editors/ComponentEditor/instantiations/DesignConfigurationInstantiationsEditor.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: DesignConfigurationInstantiationsEditor.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Esko Pekkarinen\r\n// Date: 29.01.2016\r\n//\r\n// Description:\r\n// Editor for DesignConfiguration instantiations.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef DESIGNCONFIGURATIONINSTANTIATIONSEDITOR_H\r\n#define DESIGNCONFIGURATIONINSTANTIATIONSEDITOR_H\r\n\r\n#include \"DesignConfigurationInstantiationsModel.h\"\r\n\r\n#include <editors/ComponentEditor/itemeditor.h>\r\n\r\n#include <QSortFilterProxyModel>\r\n\r\nclass EditableTableView;\r\nclass LibraryInterface;\r\nclass InstantiationsValidator;\r\n//-----------------------------------------------------------------------------\r\n//! Editor for DesignConfiguration instantiations.\r\n//-----------------------------------------------------------------------------\r\nclass DesignConfigurationInstantiationsEditor : public ItemEditor\r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\r\n\t/*!\r\n     *  The constructor.\r\n\t *\r\n\t *    @param [in] component       The component being edited.\r\n\t *    @param [in] handler         The instance managing the library.\r\n     *    @param [in] validator       The validator used for design configuration instantiations.\r\n\t *    @param [in] parent          The parent of this editor.\r\n\t */\r\n\tDesignConfigurationInstantiationsEditor(QSharedPointer<Component> component, LibraryInterface* handler,\r\n        QSharedPointer<InstantiationsValidator> validator, QWidget* parent = 0);\r\n\t\r\n\t//! The destructor.\r\n\tvirtual ~DesignConfigurationInstantiationsEditor();\r\n\r\n\t//! Reload the information from the model to the editor.\r\n\tvirtual void refresh();\r\n\r\npublic slots:\r\n\r\n\t/*!\r\n\t *  Displays warning message when trying to drag and drop a busDef or absDef using different standard revision\r\n\t *  than the containing component.\r\n\t */\r\n\tvoid stdRevisionMismatchWarning();\r\n\r\nprotected:\r\n\r\n\t//! Handler for widget's show event.\r\n\tvirtual void showEvent(QShowEvent* event);\r\n\r\nprivate:\r\n\r\n\t//! No copying.\r\n\tDesignConfigurationInstantiationsEditor(const DesignConfigurationInstantiationsEditor& other);\r\n\tDesignConfigurationInstantiationsEditor& operator=(const DesignConfigurationInstantiationsEditor& other);\r\n\r\n\t//! The view to display the view info.\r\n\tEditableTableView* view_;\r\n\r\n\t//! The proxy that does the sorting.\r\n\tQSortFilterProxyModel* proxy_;\r\n\r\n\t//! The model to manage the design configuration instantiations summary.\r\n\tDesignConfigurationInstantiationsModel model_;\r\n};\r\n\r\n#endif // DESIGNCONFIGURATIONINSTANTIATIONSEDITOR_H\r\n"
  },
  {
    "path": "editors/ComponentEditor/instantiations/DesignConfigurationInstantiationsModel.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: DesignConfigurationInstantiationsModel.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Esko Pekkarinen\r\n// Date: 28.01.2016\r\n//\r\n// Description:\r\n// Model for design configuration instantiations of a component.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"DesignConfigurationInstantiationsModel.h\"\r\n#include \"DesignInstantiationColumns.h\"\r\n\r\n#include <QStringList>\r\n\r\n#include <QMimeData>\r\n#include <QRegularExpression>\r\n\r\n#include <IPXACTmodels/Component/validators/InstantiationsValidator.h>\r\n#include <IPXACTmodels/common/DocumentUtils.h>\r\n\r\n#include <common/KactusColors.h>\r\n\r\n#include <KactusAPI/include/LibraryInterface.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignConfigurationInstantiationsModel::DesignConfigurationInstantiationsModel()\r\n//-----------------------------------------------------------------------------\r\nDesignConfigurationInstantiationsModel::DesignConfigurationInstantiationsModel(\r\n    QSharedPointer<QList<QSharedPointer<DesignConfigurationInstantiation> > > instantiations,\r\n    QSharedPointer<InstantiationsValidator> validator, QSharedPointer<Component> component,\r\n    LibraryInterface* library, QObject* parent) :\r\nQAbstractTableModel(parent),\r\ninstantiations_(instantiations),\r\nvalidator_(validator),\r\ncontainingComponent_(component),\r\nlibrary_(library)\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignConfigurationInstantiationsModel::~DesignConfigurationInstantiationsModel()\r\n//-----------------------------------------------------------------------------\r\nDesignConfigurationInstantiationsModel::~DesignConfigurationInstantiationsModel()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignConfigurationInstantiationsModel::rowCount()\r\n//-----------------------------------------------------------------------------\r\nint DesignConfigurationInstantiationsModel::rowCount(QModelIndex const& parent) const\r\n{\r\n\tif (parent.isValid())\r\n    {\r\n\t\treturn 0;\r\n\t}\r\n    return instantiations_->size();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignConfigurationInstantiationsModel::columnCount()\r\n//-----------------------------------------------------------------------------\r\nint DesignConfigurationInstantiationsModel::columnCount(QModelIndex const& parent) const\r\n{\r\n\tif (parent.isValid())\r\n    {\r\n\t\treturn 0;\r\n\t}\r\n    return DesignInstantiationsColumns::COLUMN_COUNT;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignConfigurationInstantiationsModel::flags()\r\n//-----------------------------------------------------------------------------\r\nQt::ItemFlags DesignConfigurationInstantiationsModel::flags(QModelIndex const& index) const\r\n{\r\n\tif (!index.isValid())\r\n    {\r\n\t\treturn Qt::NoItemFlags;\r\n\t}\r\n\r\n    if (index.column() == DesignInstantiationsColumns::VLNV_REFERENCE)\r\n    {\r\n        return Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsDropEnabled;\r\n    }\r\n\r\n\t// other columns can be edited\r\n\treturn Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsEditable;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignConfigurationInstantiationsModel::headerData()\r\n//-----------------------------------------------------------------------------\r\nQVariant DesignConfigurationInstantiationsModel::headerData(int section, Qt::Orientation orientation, int role) const\r\n{\r\n\tif (orientation != Qt::Horizontal)\r\n    {\r\n\t\treturn QVariant();\r\n    }\r\n\r\n    if (Qt::DisplayRole == role)\r\n    {\r\n        if (section == DesignInstantiationsColumns::NAME)\r\n        {\r\n            return tr(\"Name\");\r\n        }\r\n        else if (section == DesignInstantiationsColumns::DISPLAY_NAME)\r\n        {\r\n            return tr(\"Display name\");\r\n        }\r\n        else if (section == DesignInstantiationsColumns::VLNV_REFERENCE)\r\n        {\r\n            return tr(\"Design configuration reference\");\r\n        }\r\n        else if (section == DesignInstantiationsColumns::DESCRIPTION)\r\n        {\r\n            return tr(\"Description\");\r\n        }\r\n        else\r\n        {\r\n            return QVariant();\r\n        }\r\n    }\r\n    else\r\n    {\r\n        return QVariant();\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignConfigurationInstantiationsModel::data()\r\n//-----------------------------------------------------------------------------\r\nQVariant DesignConfigurationInstantiationsModel::data(QModelIndex const& index, int role) const\r\n{\r\n\tif (!index.isValid() || index.row() < 0 || index.row() >= instantiations_->size())\r\n    {\r\n        return QVariant();\r\n    }\r\n\r\n    QSharedPointer<DesignConfigurationInstantiation> instantiation = instantiations_->at(index.row());\r\n\r\n    if (role == Qt::EditRole && index.column() == DesignInstantiationsColumns::DESCRIPTION)\r\n    {\r\n        return instantiation->description();\r\n    }\r\n    if (role == Qt::DisplayRole || role == Qt::EditRole)\r\n    {\r\n        if (index.column() == DesignInstantiationsColumns::NAME)\r\n        {\r\n            if (!instantiation->name().isEmpty())\r\n            {\r\n                return instantiation->name();\r\n            }\r\n            else\r\n            {\r\n                return \"unnamed\";\r\n            }\r\n        }\r\n        else if (index.column() == DesignInstantiationsColumns::DISPLAY_NAME)\r\n        {\r\n            return instantiation->displayName();\r\n        }\r\n        else if (index.column() == DesignInstantiationsColumns::VLNV_REFERENCE)\r\n        {\r\n            return instantiation->getDesignConfigurationReference()->toString();\r\n        }\r\n        else if (index.column() == DesignInstantiationsColumns::DESCRIPTION)\r\n        {\r\n            return instantiation->description().replace(QRegularExpression(\"\\n.*$\", \r\n                QRegularExpression::DotMatchesEverythingOption), \"...\");\r\n        }\r\n        else\r\n        {\r\n            return QVariant();\r\n        }\r\n\t}\r\n\telse if (role == Qt::ForegroundRole)\r\n    {\r\n        if (index.column() == DesignInstantiationsColumns::NAME && \r\n            !validator_->hasValidName(instantiation->name()))\r\n        {\r\n            return KactusColors::ERROR;\r\n        }\r\n        else\r\n        {\r\n            return KactusColors::REGULAR_TEXT;\r\n        }\r\n\t}\r\n\telse if (role == Qt::BackgroundRole)\r\n    {\r\n        if (index.column() == DesignInstantiationsColumns::NAME ||\r\n            index.column() == DesignInstantiationsColumns::VLNV_REFERENCE)\r\n        {\r\n            return KactusColors::MANDATORY_FIELD;\r\n        }\r\n        else\r\n        {\r\n            return KactusColors::REGULAR_FIELD;\r\n        }\r\n    }\r\n    else \r\n    {\r\n\t\treturn QVariant();\r\n\t}\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignConfigurationInstantiationsModel::setData()\r\n//-----------------------------------------------------------------------------\r\nbool DesignConfigurationInstantiationsModel::setData(QModelIndex const& index, const QVariant& value, int role)\r\n{\r\n\tif (!index.isValid() || index.row() < 0 || index.row() >= instantiations_->size())\r\n    {\r\n\t\treturn false;\r\n\t}\r\n\r\n    QSharedPointer<DesignConfigurationInstantiation> instantiation = instantiations_->at(index.row());\r\n\r\n\tif (role == Qt::EditRole)\r\n    {\r\n        if (index.column() == DesignInstantiationsColumns::NAME)\r\n        {\r\n            instantiation->setName(value.toString());\r\n        }\r\n        else if (index.column() == DesignInstantiationsColumns::DISPLAY_NAME)\r\n        {\r\n            instantiation->setDisplayName(value.toString());\r\n        }\r\n        else if (index.column() == DesignInstantiationsColumns::VLNV_REFERENCE)\r\n        {\r\n            VLNV designConfigurationReference = VLNV(VLNV::DESIGNCONFIGURATION, value.toString());\r\n            instantiation->getDesignConfigurationReference()->setVLNV(designConfigurationReference);\r\n        }\r\n        else if (index.column() == DesignInstantiationsColumns::DESCRIPTION)\r\n        {\r\n            instantiation->setDescription(value.toString());\r\n        }\r\n        else\r\n        {\r\n            return false;\r\n        }\r\n\r\n\t\temit dataChanged(index, index);\r\n\t\temit contentChanged();\r\n\t\treturn true;\r\n\t}\r\n\telse \r\n    {\r\n\t\treturn false;\r\n\t}\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignConfigurationInstantiationsModel::supportedDropActions()\r\n//-----------------------------------------------------------------------------\r\nQt::DropActions DesignConfigurationInstantiationsModel::supportedDropActions() const\r\n{\r\n    return Qt::CopyAction | Qt::MoveAction;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignConfigurationInstantiationsModel::mimeTypes()\r\n//-----------------------------------------------------------------------------\r\nQStringList DesignConfigurationInstantiationsModel::mimeTypes() const\r\n{\r\n    QStringList types(QAbstractTableModel::mimeTypes());\r\n    types << \"application/x-qt-image\";\r\n    return types;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignConfigurationInstantiationsModel::dropMimeData()\r\n//-----------------------------------------------------------------------------\r\nbool DesignConfigurationInstantiationsModel::dropMimeData(QMimeData const* data, Qt::DropAction action, int row, \r\n    int column, QModelIndex const& parent)\r\n{\r\n    if (action == Qt::IgnoreAction)\r\n    {\r\n        return true;\r\n    }\r\n\r\n    // Dropped data must be directly on parent.\r\n    if (row != -1 || column != -1 || !parent.isValid() || row > rowCount())\r\n    {\r\n        return false;\r\n    }\r\n\r\n    QVariant variant = data->imageData();\r\n\r\n    if (!variant.canConvert<VLNV>())\r\n    {\r\n        return false;\r\n    }\r\n\r\n    VLNV vlnv = variant.value<VLNV>();\r\n    if (parent.column() == DesignInstantiationsColumns::VLNV_REFERENCE)\r\n    {\r\n        // Check std revision compatibility.\r\n        if (!DocumentUtils::documentsHaveMatchingStdRevisions(vlnv, containingComponent_->getVlnv(), library_))\r\n        {\r\n            emit stdRevisionMismatch();\r\n            return false;\r\n        }\r\n\r\n        if (vlnv.getType() == VLNV::DESIGNCONFIGURATION)\r\n        {\r\n            setData(index(parent.row(), parent.column()), vlnv.toString(\":\"));\r\n            emit contentChanged();\r\n        }\r\n        else\r\n        {\r\n            return false;\r\n        }\r\n    }\r\n\r\n    return true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignConfigurationInstantiationsModel::onAddItem()\r\n//-----------------------------------------------------------------------------\r\nvoid DesignConfigurationInstantiationsModel::onAddItem(QModelIndex const& index)\r\n{\r\n\tint row = instantiations_->size();\r\n\r\n\t// if the index is valid then add the item to the correct position\r\n\tif (index.isValid())\r\n    {\r\n\t\trow = index.row();\r\n\t}\r\n\r\n\tbeginInsertRows(QModelIndex(), row, row);\r\n\tinstantiations_->insert(row, \r\n        QSharedPointer<DesignConfigurationInstantiation>(new DesignConfigurationInstantiation()));\r\n\tendInsertRows();\r\n\r\n\temit designConfigurationInstantiationAdded(row);\r\n\temit contentChanged();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignConfigurationInstantiationsModel::onRemoveItem()\r\n//-----------------------------------------------------------------------------\r\nvoid DesignConfigurationInstantiationsModel::onRemoveItem(QModelIndex const& index)\r\n{\r\n\t// don't remove anything if index is invalid\r\n\tif (!index.isValid() || index.row() < 0 || index.row() >= instantiations_->size())\r\n    {\r\n\t\treturn;\r\n\t}\r\n\r\n\t// remove the specified item\r\n\tbeginRemoveRows(QModelIndex(), index.row(), index.row());\r\n\tinstantiations_->removeAt(index.row());\r\n\tendRemoveRows();\r\n\r\n\temit designConfigurationInstantiationRemoved(index.row());\r\n\temit contentChanged();\r\n}\r\n"
  },
  {
    "path": "editors/ComponentEditor/instantiations/DesignConfigurationInstantiationsModel.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: DesignConfigurationInstantiationsModel.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Esko Pekkarinen\r\n// Date: 28.01.2016\r\n//\r\n// Description:\r\n// Model for design configuration instantiations of a component.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef DesignConfigurationINSTANTIATIONSMODEL_H\r\n#define DesignConfigurationINSTANTIATIONSMODEL_H\r\n\r\n#include <IPXACTmodels/Component/Component.h>\r\n\r\n#include <QAbstractTableModel>\r\n#include <QList>\r\n#include <QSharedPointer>\r\n\r\nclass InstantiationsValidator;\r\nclass LibraryInterface;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Model for design configuration instantiations of a component.\r\n//-----------------------------------------------------------------------------\r\nclass DesignConfigurationInstantiationsModel : public QAbstractTableModel\r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\r\n\t/*!\r\n     *  The constructor.\r\n\t *\r\n     *    @param [in] instantiations\tThe design configuration instantiations.\r\n     *    @param [in] validator       The validator used for design configuration instantiations.\r\n\t *    @param [in] component       The component being edited.\r\n     *    @param [in] library\t\t\tThe library interface.\r\n\t *    @param [in] parent          The owner of the model.\r\n\t */\r\n\tDesignConfigurationInstantiationsModel(\r\n        QSharedPointer<QList<QSharedPointer<DesignConfigurationInstantiation> > > instantiations,\r\n        QSharedPointer<InstantiationsValidator> validator, QSharedPointer<Component> component, \r\n\t\tLibraryInterface* library, QObject* parent);\r\n\t\r\n\t//! The destructor.\r\n\tvirtual ~DesignConfigurationInstantiationsModel();\r\n\r\n\t/*!\r\n     *  Get the number of rows an item contains.\r\n\t *\r\n\t *    @param [in] parent  Identifies the parent that's row count is requested.\r\n\t *\r\n\t *    @return Number of rows the item has.\r\n\t */\r\n\tvirtual int rowCount(QModelIndex const& parent = QModelIndex()) const;\r\n\r\n\t/*!\r\n     *  Get the number of columns the item has to be displayed.\r\n\t *\r\n\t *    @param [in] parent  Identifies the parent that's column count is requested.\r\n\t *\r\n\t *    @return The number of columns to be displayed.\r\n\t */\r\n\tvirtual int columnCount(QModelIndex const& parent = QModelIndex()) const;\r\n\r\n\t/*!\r\n     *  Get the item flags that defines the possible operations for the item.\r\n\t *\r\n\t *    @param [in] index   Model index that identifies the item.\r\n\t *\r\n\t *    @return Qt::ItemFlags specify the possible operations for the item.\r\n\t */\r\n\tvirtual Qt::ItemFlags flags(QModelIndex const& index) const;\r\n\r\n\t/*!\r\n     *  Get the header data for specified header.\r\n\t *\r\n\t *    @param [in] section         The section specifies the row/column number for the header.\r\n\t *    @param [in] orientation     Specified if horizontal or vertical header is wanted.\r\n\t *    @param [in] role            Specifies the type of the requested data.\r\n\t *\r\n\t *    @return QVariant Contains the requested data.\r\n\t */\r\n\tvirtual QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;\r\n\r\n\t/*!\r\n     *  Get the data for specified item.\r\n\t *\r\n\t *    @param [in] index   Specifies the item that's data is requested.\r\n\t *    @param [in] role    The role that defines what kind of data is requested.\r\n\t *\r\n\t *    @return QVariant Contains the data for the item.\r\n\t */\r\n\tvirtual QVariant data(QModelIndex const& index, int role = Qt::DisplayRole) const;\r\n\r\n\t/*!\r\n     *  Save the data to the model for specified item.\r\n\t *\r\n\t *    @param [in] index   The model index of the item that's data is to be saved.\r\n\t *    @param [in] value   The data that is to be saved.\r\n\t *    @param [in] role    The role specifies what kind of data should be saved.\r\n\t *\r\n\t *    @return True if saving happened successfully.\r\n\t */\r\n\tvirtual bool setData(QModelIndex const& index, const QVariant& value, int role = Qt::EditRole);\r\n\r\n     /*!\r\n     *  Returns the supported actions of a drop.\r\n     *\r\n     *    @return The drop actions supported by the model.\r\n     */\r\n    virtual Qt::DropActions supportedDropActions() const;\r\n\r\n    /*!\r\n     *  Returns a list of supported MIME data types.\r\n     *\r\n     *    @return The supported MIME types.\r\n     */\r\n    virtual QStringList mimeTypes() const;\r\n\r\n    /*!\r\n     *  Handler for the dropped MIME data.\r\n     *\r\n     *    @param [in] data   The data associated to the drop.\r\n     *    @param [in] action The drop action.  \r\n     *    @param [in] row    The row beneath the drop position.\r\n     *    @param [in] column The column beneath the drop position.\r\n     *    @param [in] parent The parent index of the drop position.\r\n     *\r\n     *    @return True, if the model could handle the data, otherwise false.\r\n     */\r\n    virtual bool dropMimeData(QMimeData const* data, Qt::DropAction action, int row, int column, \r\n        QModelIndex const& parent);\r\n\r\npublic slots:\r\n\r\n\t/*!\r\n     *  Add a new item to the given index.\r\n\t *\r\n\t *    @param [in] index   The index identifying the position for new item.\r\n\t */\r\n\tvirtual void onAddItem(QModelIndex const& index);\r\n\r\n\t/*!\r\n     *  Remove the item in the given index.\r\n\t *\r\n\t *    @param [in] index   The index identifying the item to remove.\r\n\t */\r\n\tvirtual void onRemoveItem(QModelIndex const& index);\r\n\r\nsignals:\r\n\r\n\t//! Emitted when the contents of the model change.\r\n\tvoid contentChanged();\r\n\r\n\t//! Emitted when a new design configuration instantiation is added to the given index.\r\n\tvoid designConfigurationInstantiationAdded(int index);\r\n\r\n\t//! Emitted when a design configuration instantiation is removed from the given index.\r\n\tvoid designConfigurationInstantiationRemoved(int index);\r\n\r\n\t/*!\r\n     *  Emitted when a design config with different std revision is dropped in a design config reference cell in \r\n\t *  the editor.\r\n     */\r\n\tvoid stdRevisionMismatch() const;\r\n\r\nprivate:\r\n\t//! No copying.\r\n\tDesignConfigurationInstantiationsModel(const DesignConfigurationInstantiationsModel& other);\r\n\tDesignConfigurationInstantiationsModel& operator=(const DesignConfigurationInstantiationsModel& other);\r\n\r\n\t//! Contains the instantiations to edit.\r\n    QSharedPointer<QList<QSharedPointer<DesignConfigurationInstantiation> > > instantiations_;\r\n\r\n    //! The validator used for design configurations.\r\n    QSharedPointer<InstantiationsValidator> validator_;\r\n\r\n\t//! The containing component.\r\n\tQSharedPointer<Component> containingComponent_;\r\n\r\n\t//! The library handler.\r\n\tLibraryInterface* library_;\r\n};\r\n\r\n#endif // DesignConfigurationINSTANTIATIONSMODEL_H\r\n"
  },
  {
    "path": "editors/ComponentEditor/instantiations/DesignInstantiationColumns.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: DesignInstantiationsColumns.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Esko Pekkarinen\r\n// Date: 28.01.2016\r\n//\r\n// Description:\r\n// Common declarations for columns editing design (configurations) instantiations.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef DESIGNINSTANTIATIONSCOLUMNS_H\r\n#define DESIGNINSTANTIATIONSCOLUMNS_H\r\n\r\nnamespace DesignInstantiationsColumns\r\n{\r\n    //! Defines the columns for the component design (configuration) table.\r\n    enum Column\r\n    {\r\n        NAME = 0,\r\n        DISPLAY_NAME,\r\n        VLNV_REFERENCE,\r\n        DESCRIPTION,\r\n        COLUMN_COUNT\r\n    };\r\n}\r\n\r\n#endif //DESIGNINSTANTIATIONSCOLUMNS_H"
  },
  {
    "path": "editors/ComponentEditor/instantiations/DesignInstantiationEditor.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: DesignInstantiationEditor.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Esko Pekkarinen\r\n// Date: 26.01.2016\r\n//\r\n// Description:\r\n// Editor for design configuration instantiation.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"DesignInstantiationEditor.h\"\r\n\r\n#include <common/widgets/nameGroupEditor/namegroupeditor.h>\r\n\r\n#include <KactusAPI/include/ComponentParameterFinder.h>\r\n#include <KactusAPI/include/MultipleParameterFinder.h>\r\n#include <KactusAPI/include/IPXactSystemVerilogParser.h>\r\n#include <KactusAPI/include/ListParameterFinder.h>\r\n#include <KactusAPI/include/ParameterConfigurableElementFinder.h>\r\n\r\n#include <editors/ComponentEditor/common/InstantiationConfigurableElementEditor.h>\r\n#include <editors/ComponentEditor/common/ConfigurableElementFinder.h>\r\n#include <editors/ComponentEditor/parameters/ComponentParameterModel.h>\r\n\r\n#include <KactusAPI/include/LibraryInterface.h>\r\n\r\n#include <IPXACTmodels/Component/Component.h>\r\n#include <IPXACTmodels/Design/Design.h>\r\n#include <IPXACTmodels/Component/DesignInstantiation.h>\r\n\r\n#include <QApplication>\r\n#include <QMainWindow>\r\n#include <QScrollArea>\r\n#include <QHBoxLayout>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignInstantiationEditor::DesignInstantiationEditor()\r\n//-----------------------------------------------------------------------------\r\nDesignInstantiationEditor::DesignInstantiationEditor(QSharedPointer<Component> component,\r\n    QSharedPointer<DesignInstantiation> instantiation, LibraryInterface* libHandler,\r\n    QSharedPointer<ParameterFinder> componentParameterFinder, QWidget* parent):\r\nItemEditor(component, libHandler, parent),\r\ninstantiation_(instantiation),\r\nnameGroupEditor_(new NameGroupEditor(instantiation, component->getRevision(), this, tr(\"Design instance name and description\"))),\r\ndesignEditor_(0),\r\nelementEditor_(0),\r\ndesignParameterFinder_(new ListParameterFinder())\r\n{\r\n\r\n\tQSharedPointer<ParameterConfigurableElementFinder> elementFinder(new ParameterConfigurableElementFinder());\r\n\r\n    QSharedPointer<MultipleParameterFinder> multiFinder(new MultipleParameterFinder());\r\n    multiFinder->addFinder(componentParameterFinder);\r\n    multiFinder->addFinder(elementFinder);\r\n\r\n    QSharedPointer<IPXactSystemVerilogParser> cevElementParser(new IPXactSystemVerilogParser(multiFinder));\r\n    QSharedPointer<IPXactSystemVerilogParser> designParameterParser(\r\n        new IPXactSystemVerilogParser(designParameterFinder_));\r\n\r\n\tComponentParameterModel* designParametersModel = new ComponentParameterModel(multiFinder, this);\r\n\tdesignParametersModel->setExpressionParser(cevElementParser);\r\n\r\n\tExpressionSet cevElementExpressions ({ multiFinder , cevElementParser,\r\n\t\tQSharedPointer<ExpressionFormatter>(new ExpressionFormatter(multiFinder)) });\r\n\tExpressionSet designExpressions({ designParameterFinder_, designParameterParser,\r\n\t\tQSharedPointer<ExpressionFormatter>(new ExpressionFormatter(designParameterFinder_)) });\r\n\r\n\telementEditor_ = new InstantiationConfigurableElementEditor(elementFinder,\r\n\t\tcevElementExpressions, designExpressions,\r\n\t\tdesignParametersModel, this);\r\n\r\n    designEditor_ = new VLNVEditor(VLNV::DESIGN, libHandler, this, this);\r\n    designEditor_->setTitle(tr(\"Design reference\"));\r\n    designEditor_->setMandatory(true);\r\n    designEditor_->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);\r\n    designEditor_->setRevisionFilter(true, component->getRevision());\r\n\r\n    connect(nameGroupEditor_, SIGNAL(contentChanged()), this, SIGNAL(contentChanged()), Qt::UniqueConnection);\r\n    connect(designEditor_, SIGNAL(vlnvEdited()), this, SLOT(onHierRefChange()), Qt::UniqueConnection);\r\n   \r\n    connect(elementEditor_, SIGNAL(contentChanged()), this, SIGNAL(contentChanged()), Qt::UniqueConnection);\r\n    connect(elementEditor_, SIGNAL(increaseReferences(QString)),\r\n        this, SIGNAL(increaseReferences(QString)), Qt::UniqueConnection);\r\n    connect(elementEditor_, SIGNAL(decreaseReferences(QString)),\r\n        this, SIGNAL(decreaseReferences(QString)), Qt::UniqueConnection);\r\n\r\n    refresh();\r\n    setupLayout();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignInstantiationEditor::~DesignInstantiationEditor()\r\n//-----------------------------------------------------------------------------\r\nDesignInstantiationEditor::~DesignInstantiationEditor()\r\n{\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignInstantiationEditor::refresh()\r\n//-----------------------------------------------------------------------------\r\nvoid DesignInstantiationEditor::refresh()\r\n{\r\n\tnameGroupEditor_->refresh();\r\n\tdesignEditor_->setVLNV(*instantiation_->getDesignReference());\r\n    setupParametersAsConfigurableElements();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignInstantiationEditor::onHierRefChange()\r\n//-----------------------------------------------------------------------------\r\nvoid DesignInstantiationEditor::onHierRefChange()\r\n{\r\n\tinstantiation_->getDesignReference()->setVLNV(designEditor_->getVLNV());\r\n    setupParametersAsConfigurableElements();\r\n\r\n    emit contentChanged();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignInstantiationEditor::setupParametersAsConfigurableElements()\r\n//-----------------------------------------------------------------------------\r\nvoid DesignInstantiationEditor::setupParametersAsConfigurableElements()\r\n{\r\n    QSharedPointer<QList<QSharedPointer<Parameter> > > newParameters;\r\n    QSharedPointer<QList<QSharedPointer<ConfigurableElementValue> > > newElements;\r\n\r\n    QSharedPointer<const Design> currentDesign;\r\n    QSharedPointer<const Document> designDocument = handler()->getModel(designEditor_->getVLNV());\r\n    if (designDocument)\r\n    {\r\n        currentDesign = designDocument.staticCast<const Design>();\r\n        if (currentDesign)\r\n        {\r\n            newParameters = currentDesign->getParameters();\r\n        }\r\n    }\r\n    if (instantiation_->getDesignReference())\r\n    {\r\n        newElements = instantiation_->getDesignReference()->getConfigurableElementValues();\r\n    }\r\n\r\n    designParameterFinder_->setParameterList(newParameters);\r\n\r\n    if (currentDesign && instantiation_->getDesignReference())\r\n    {\r\n        elementEditor_->setParameters(currentDesign->getVlnv().toString(), newParameters, \r\n            designDocument->getRevision(), newElements);\r\n    }\r\n    else\r\n    {\r\n        elementEditor_->clear();\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignInstantiationEditor::showEvent()\r\n//-----------------------------------------------------------------------------\r\nvoid DesignInstantiationEditor::showEvent(QShowEvent* event)\r\n{\r\n\tQWidget::showEvent(event);\r\n\temit helpUrlRequested(\"componenteditor/designInstantiation.html\");\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignInstantiationEditor::setupLayout()\r\n//-----------------------------------------------------------------------------\r\nvoid DesignInstantiationEditor::setupLayout()\r\n{\r\n    QScrollArea* scrollArea = new QScrollArea(this);\r\n    scrollArea->setWidgetResizable(true);\r\n    scrollArea->setFrameShape(QFrame::NoFrame);\r\n\r\n    QHBoxLayout* scrollLayout = new QHBoxLayout(this);\r\n    scrollLayout->addWidget(scrollArea);\r\n    scrollLayout->setContentsMargins(0, 0, 0, 0);\r\n\r\n    QWidget* topWidget = new QWidget(scrollArea);\r\n    topWidget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);\r\n    scrollArea->setWidget(topWidget);\r\n\r\n    QGridLayout* topLayout = new QGridLayout(topWidget);\r\n    topLayout->setContentsMargins(0, 0, 0, 0);\r\n    topLayout->addWidget(nameGroupEditor_, 0, 0, 1, 1, Qt::AlignTop);\r\n    topLayout->addWidget(designEditor_, 0, 1, 1, 1, Qt::AlignTop);\r\n    topLayout->addWidget(elementEditor_, 1, 0, 2, 1);\r\n    topLayout->setRowStretch(1, 3);\r\n}\r\n"
  },
  {
    "path": "editors/ComponentEditor/instantiations/DesignInstantiationEditor.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: DesignInstantiationEditor.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Esko Pekkarinen\r\n// Date: 26.01.2016\r\n//\r\n// Description:\r\n// Editor for design configuration instantiation.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef DESIGNINSTANTIATIONEDITOR_H\r\n#define DESIGNINSTANTIATIONEDITOR_H\r\n\r\n#include <editors/ComponentEditor/itemeditor.h>\r\n\r\n#include <common/widgets/vlnvEditor/vlnveditor.h>\r\n\r\nclass NameGroupEditor;\r\nclass ParameterFinder;\r\nclass ExpressionParser;\r\nclass DesignInstantiation;\r\nclass ListParameterFinder;\r\nclass ExpressionFormatter;\r\nclass DesignCompletionModel;\r\nclass InstantiationConfigurableElementEditor;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Editor for design configuration instantiation.\r\n//-----------------------------------------------------------------------------\r\nclass DesignInstantiationEditor : public ItemEditor\r\n{\r\n    Q_OBJECT\r\n\r\npublic:\r\n\r\n    /*!\r\n     *  Constructor.\r\n     *\r\n     *    @param [in] component                   The component being edited.\r\n     *    @param [in] instantiation\t            The instantiation being edited.\t\r\n     *    @param [in] libHandler                  The available IP-XACT library.\r\n     *    @param [in] componentParameterFinder    Finds the parameters contained within the component.\r\n     *    @param [in] parent                      The parent widget.\r\n     */\r\n\tDesignInstantiationEditor(QSharedPointer<Component> component,\r\n        QSharedPointer<DesignInstantiation> instantiation, LibraryInterface* libHandler,\r\n        QSharedPointer<ParameterFinder> componentParameterFinder, QWidget* parent);\r\n\r\n    //! Destructor.\r\n    virtual ~DesignInstantiationEditor();\r\n\r\n\t//! Reload the information from the model to the editor.\r\n\tvirtual void refresh();\r\n\r\nprotected:\r\n\r\n\t//! Handler for widget's show event.\r\n\tvirtual void showEvent(QShowEvent* event);\r\n\r\nprivate slots:\r\n\r\n\t//! Handler for changes in design configuration reference.\r\n\tvoid onHierRefChange();\r\n\r\nprivate:\r\n    // Disable copying.\r\n    DesignInstantiationEditor(DesignInstantiationEditor const& rhs);\r\n    DesignInstantiationEditor& operator=(DesignInstantiationEditor const& rhs);\r\n\r\n    //! Setup the layout.\r\n    void setupLayout();\r\n\r\n    /*!\r\n     *  Setup the parameters as configurable element values.\r\n     */\r\n    void setupParametersAsConfigurableElements();\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! The design instantiation being edited.\r\n    QSharedPointer<DesignInstantiation> instantiation_;\r\n\r\n    //! Editor to set the name, display name and description of the view.\r\n    NameGroupEditor* nameGroupEditor_;\r\n\r\n    //! VLNV editor for the hierarchy reference.\r\n    VLNVEditor* designEditor_;\r\n\r\n    //! The configurable element value editor.\r\n    InstantiationConfigurableElementEditor* elementEditor_;\r\n\r\n    //! Finder for design parameters.\r\n    QSharedPointer<ListParameterFinder> designParameterFinder_;\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n\r\n#endif // DESIGNINSTANTIATIONEDITOR_H\r\n"
  },
  {
    "path": "editors/ComponentEditor/instantiations/DesignInstantiationsDelegate.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: DesignInstantiationsDelegate.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Esko Pekkarinen\r\n// Date: 29.01.2016\r\n//\r\n// Description:\r\n// The delegate that provides editors to edit the design instantiations summary.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"DesignInstantiationsDelegate.h\"\r\n#include \"DesignInstantiationColumns.h\"\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignInstantiationsDelegate::DesignInstantiationsDelegate()\r\n//-----------------------------------------------------------------------------\r\nDesignInstantiationsDelegate::DesignInstantiationsDelegate(QObject* parent): MultilineDescriptionDelegate(parent)\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignInstantiationsDelegate::~DesignInstantiationsDelegate()\r\n//-----------------------------------------------------------------------------\r\nDesignInstantiationsDelegate::~DesignInstantiationsDelegate()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignInstantiationsDelegate::descriptionColumn()\r\n//-----------------------------------------------------------------------------\r\nint DesignInstantiationsDelegate::descriptionColumn() const\r\n{\r\n    return DesignInstantiationsColumns::DESCRIPTION;\r\n}\r\n"
  },
  {
    "path": "editors/ComponentEditor/instantiations/DesignInstantiationsDelegate.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: DesignInstantiationsDelegate.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Esko Pekkarinen\r\n// Date: 29.01.2016\r\n//\r\n// Description:\r\n// The delegate that provides editors to edit the design instantiations summary.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef DESIGNINSTANTIATIONSDELEGATE_H\r\n#define DESIGNINSTANTIATIONSDELEGATE_H\r\n\r\n#include <editors/ComponentEditor/common/MultilineDescriptionDelegate.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n//! The delegate that provides editors to edit the design instantiations summary.\r\n//-----------------------------------------------------------------------------\r\nclass DesignInstantiationsDelegate : public MultilineDescriptionDelegate \r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\r\n    /*!\r\n     *  The constructor.\r\n     *\r\n     *    @param [in] parent      The parent object.\r\n     */\r\n\tDesignInstantiationsDelegate(QObject* parent);\r\n\t\r\n\t//! The destructor\r\n\tvirtual ~DesignInstantiationsDelegate();\r\n\r\nprotected:\r\n\r\n    // Gets the column for description.\r\n    virtual int descriptionColumn() const;\r\n\r\nprivate:\r\n\t//! No copying\r\n\tDesignInstantiationsDelegate(const DesignInstantiationsDelegate& other);\r\n\tDesignInstantiationsDelegate& operator=(const DesignInstantiationsDelegate& other);\r\n\r\n};\r\n\r\n#endif // DESIGNINSTANTIATIONSDELEGATE_H\r\n"
  },
  {
    "path": "editors/ComponentEditor/instantiations/DesignInstantiationsEditor.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: DesignInstantiationsEditor.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Esko Pekkarinen\r\n// Date: 28.01.2016\r\n//\r\n// Description:\r\n// Editor for design instantiations.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"DesignInstantiationsEditor.h\"\r\n\r\n#include \"ComponentInstantiationsColumns.h\"\r\n#include \"DesignInstantiationsDelegate.h\"\r\n\r\n#include <common/views/EditableTableView/editabletableview.h>\r\n#include <common/widgets/summaryLabel/summarylabel.h>\r\n#include <common/delegates/LineEditDelegate/lineeditdelegate.h>\r\n\r\n#include <KactusAPI/include/LibraryInterface.h>\r\n\r\n#include <QVBoxLayout>\r\n#include <QMessageBox>\r\n#include <QCoreApplication>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignInstantiationsEditor::DesignInstantiationsEditor()\r\n//-----------------------------------------------------------------------------\r\nDesignInstantiationsEditor::DesignInstantiationsEditor(QSharedPointer<Component> component, \r\n    LibraryInterface* handler, QSharedPointer<InstantiationsValidator> validator, QWidget* parent):\r\nItemEditor(component, handler, parent),\r\n    view_(new EditableTableView(this)),\r\n    proxy_(new QSortFilterProxyModel(this)),\r\n    model_(component->getDesignInstantiations(), validator, component, handler, this)\r\n{\r\n\tproxy_->setSourceModel(&model_);\t\r\n    proxy_->setDynamicSortFilter(false);\r\n\r\n\tview_->setModel(proxy_);    \r\n    view_->setSortingEnabled(true);\r\n    view_->sortByColumn(ComponentInstantiationsColumns::NAME, Qt::AscendingOrder);\r\n\r\n\t// items can not be dragged\r\n\tview_->setItemsDraggable(false);\r\n    view_->setDropIndicatorShown(true);   \r\n    view_->setDragDropMode(QAbstractItemView::DropOnly);\r\n    \r\n    view_->setItemDelegate(new DesignInstantiationsDelegate(this));\r\n\r\n\tconnect(&model_, SIGNAL(contentChanged()), this, SIGNAL(contentChanged()), Qt::UniqueConnection);\r\n\tconnect(&model_, SIGNAL(designInstantiationAdded(int)), this, SIGNAL(childAdded(int)), Qt::UniqueConnection);\r\n\tconnect(&model_, SIGNAL(designInstantiationRemoved(int)), this, SIGNAL(childRemoved(int)), Qt::UniqueConnection);\r\n\tconnect(&model_, SIGNAL(stdRevisionMismatch()), this, SLOT(stdRevisionMismatchWarning()), Qt::UniqueConnection);\r\n\r\n\tconnect(view_, SIGNAL(addItem(const QModelIndex&)),\r\n        &model_, SLOT(onAddItem(const QModelIndex&)), Qt::UniqueConnection);\r\n\tconnect(view_, SIGNAL(removeItem(const QModelIndex&)),\r\n\t\t&model_, SLOT(onRemoveItem(const QModelIndex&)), Qt::UniqueConnection);\r\n\r\n    SummaryLabel* summaryLabel = new SummaryLabel(tr(\"Design instantiations summary\"), this);\r\n\r\n    QVBoxLayout* layout = new QVBoxLayout(this);\r\n    layout->addWidget(summaryLabel, 0, Qt::AlignCenter);\r\n    layout->addWidget(view_);\r\n    layout->setContentsMargins(0, 0, 0, 0);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignInstantiationsEditor::~DesignInstantiationsEditor()\r\n//-----------------------------------------------------------------------------\r\nDesignInstantiationsEditor::~DesignInstantiationsEditor()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignInstantiationsEditor::refresh()\r\n//-----------------------------------------------------------------------------\r\nvoid DesignInstantiationsEditor::refresh()\r\n{    \r\n    proxy_->invalidate();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignInstantiationsEditor::stdRevisionMismatchWarning()\r\n//-----------------------------------------------------------------------------\r\nvoid DesignInstantiationsEditor::stdRevisionMismatchWarning()\r\n{\r\n    QMessageBox::warning(this, QCoreApplication::applicationName(),\r\n        tr(\"Dropped item cannot use different IP-XACT standard revision than the item being edited.\"),\r\n        QMessageBox::Close, QMessageBox::Close);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignInstantiationsEditor::showEvent()\r\n//-----------------------------------------------------------------------------\r\nvoid DesignInstantiationsEditor::showEvent(QShowEvent* event)\r\n{\r\n    proxy_->invalidate();\r\n\r\n\tQWidget::showEvent(event);\r\n\temit helpUrlRequested(\"componenteditor/designInstantiations.html\");\r\n}\r\n"
  },
  {
    "path": "editors/ComponentEditor/instantiations/DesignInstantiationsEditor.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: DesignInstantiationsEditor.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Esko Pekkarinen\r\n// Date: 28.01.2016\r\n//\r\n// Description:\r\n// Editor for design instantiations.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef DESIGNINSTANTIATIONSEDITOR_H\r\n#define DESIGNINSTANTIATIONSEDITOR_H\r\n\r\n#include \"DesignInstantiationsModel.h\"\r\n\r\n#include <editors/ComponentEditor/itemeditor.h>\r\n\r\n#include <QSortFilterProxyModel>\r\n\r\nclass EditableTableView;\r\nclass LibraryInterface;\r\nclass InstantiationsValidator;\r\n//-----------------------------------------------------------------------------\r\n//! Editor for design instantiations.\r\n//-----------------------------------------------------------------------------\r\nclass DesignInstantiationsEditor : public ItemEditor\r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\r\n\t/*!\r\n     *  The constructor.\r\n\t *\r\n\t *    @param [in] component       The component being edited.\r\n\t *    @param [in] handler         The instance managing the library.\r\n     *    @param [in] validator       The validator used for design instantiations.\r\n\t *    @param [in] parent          The parent of this editor.\r\n\t */\r\n\tDesignInstantiationsEditor(QSharedPointer<Component> component, LibraryInterface* handler,\r\n        QSharedPointer<InstantiationsValidator> validator, QWidget* parent = 0);\r\n\t\r\n\t//! The destructor.\r\n\tvirtual ~DesignInstantiationsEditor();\r\n\r\n\t//! Reload the information from the model to the editor.\r\n\tvirtual void refresh();\r\n\r\npublic slots:\r\n\r\n\t/*!\r\n\t *  Displays warning message when trying to drag and drop a busDef or absDef using different standard revision\r\n\t *  than the containing component.\r\n\t */\r\n\tvoid stdRevisionMismatchWarning();\r\n\r\nprotected:\r\n\r\n\t//! Handler for widget's show event.\r\n\tvirtual void showEvent(QShowEvent* event);\r\n\r\nprivate:\r\n\r\n\t//! No copying.\r\n\tDesignInstantiationsEditor(const DesignInstantiationsEditor& other);\r\n\tDesignInstantiationsEditor& operator=(const DesignInstantiationsEditor& other);\r\n\r\n\t//! The view to display the view info.\r\n\tEditableTableView* view_;\r\n\r\n\t//! The proxy that does the sorting.\r\n\tQSortFilterProxyModel* proxy_;\r\n\r\n\t//! The model to manage the design instantiations summary.\r\n\tDesignInstantiationsModel model_;\r\n};\r\n\r\n#endif // DESIGNINSTANTIATIONSEDITOR_H\r\n"
  },
  {
    "path": "editors/ComponentEditor/instantiations/DesignInstantiationsModel.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: DesignInstantiationsModel.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Esko Pekkarinen\r\n// Date: 28.01.2016\r\n//\r\n// Description:\r\n// Model for desing instantiations of a component.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"DesignInstantiationsModel.h\"\r\n#include \"DesignInstantiationColumns.h\"\r\n\r\n#include <QStringList>\r\n\r\n#include <QRegularExpression>\r\n\r\n#include <common/KactusColors.h>\r\n\r\n#include <IPXACTmodels/Component/validators/InstantiationsValidator.h>\r\n#include <IPXACTmodels/common/DocumentUtils.h>\r\n\r\n#include <KactusAPI/include/LibraryInterface.h>\r\n\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignInstantiationsModel::DesignInstantiationsModel()\r\n//-----------------------------------------------------------------------------\r\nDesignInstantiationsModel::DesignInstantiationsModel(\r\n    QSharedPointer<QList<QSharedPointer<DesignInstantiation> > > instantiations, \r\n    QSharedPointer<InstantiationsValidator> validator,\r\n    QSharedPointer<Component> component,\r\n    LibraryInterface* library,\r\n    QObject* parent) :\r\nQAbstractTableModel(parent),\r\n    instantiations_(instantiations),\r\n    validator_(validator),\r\n    containingComponent_(component),\r\n    library_(library)\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignInstantiationsModel::~DesignInstantiationsModel()\r\n//-----------------------------------------------------------------------------\r\nDesignInstantiationsModel::~DesignInstantiationsModel()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignInstantiationsModel::rowCount()\r\n//-----------------------------------------------------------------------------\r\nint DesignInstantiationsModel::rowCount(QModelIndex const& parent) const\r\n{\r\n\tif (parent.isValid())\r\n    {\r\n\t\treturn 0;\r\n\t}\r\n    return instantiations_->size();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignInstantiationsModel::columnCount()\r\n//-----------------------------------------------------------------------------\r\nint DesignInstantiationsModel::columnCount(QModelIndex const& parent) const\r\n{\r\n\tif (parent.isValid())\r\n    {\r\n\t\treturn 0;\r\n\t}\r\n    return DesignInstantiationsColumns::COLUMN_COUNT;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignInstantiationsModel::flags()\r\n//-----------------------------------------------------------------------------\r\nQt::ItemFlags DesignInstantiationsModel::flags(QModelIndex const& index) const\r\n{\r\n\tif (!index.isValid())\r\n    {\r\n\t\treturn Qt::NoItemFlags;\r\n\t}\r\n\r\n    if (index.column() == DesignInstantiationsColumns::VLNV_REFERENCE)\r\n    {\r\n        return Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsDropEnabled;\r\n    }\r\n\r\n\t// other columns can be edited\r\n\treturn Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsEditable;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignInstantiationsModel::headerData()\r\n//-----------------------------------------------------------------------------\r\nQVariant DesignInstantiationsModel::headerData(int section, Qt::Orientation orientation, int role) const\r\n{\r\n\tif (orientation != Qt::Horizontal)\r\n    {\r\n\t\treturn QVariant();\r\n    }\r\n\r\n    if (Qt::DisplayRole == role)\r\n    {\r\n        if (section == DesignInstantiationsColumns::NAME)\r\n        {\r\n            return tr(\"Name\");\r\n        }\r\n        else if (section == DesignInstantiationsColumns::DISPLAY_NAME)\r\n        {\r\n            return tr(\"Display name\");\r\n        }\r\n        else if (section == DesignInstantiationsColumns::VLNV_REFERENCE)\r\n        {\r\n            return tr(\"Design reference\");\r\n        }\r\n        else if (section == DesignInstantiationsColumns::DESCRIPTION)\r\n        {\r\n            return tr(\"Description\");\r\n        }\r\n        else\r\n        {\r\n            return QVariant();\r\n        }\r\n    }\r\n    else\r\n    {\r\n        return QVariant();\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignInstantiationsModel::data()\r\n//-----------------------------------------------------------------------------\r\nQVariant DesignInstantiationsModel::data(QModelIndex const& index, int role) const\r\n{\r\n\tif (!index.isValid() || index.row() < 0 || index.row() >= instantiations_->size())\r\n    {\r\n        return QVariant();\r\n    }\r\n\r\n    QSharedPointer<DesignInstantiation> instantiation = instantiations_->at(index.row());\r\n\r\n    if (role == Qt::EditRole && index.column() == DesignInstantiationsColumns::DESCRIPTION)\r\n    {\r\n        return instantiation->description();\r\n    }\r\n    else if (role == Qt::DisplayRole || role == Qt::EditRole)\r\n    {\r\n        if (index.column() == DesignInstantiationsColumns::NAME)\r\n        {\r\n            if (!instantiation->name().isEmpty())\r\n            {\r\n                return instantiation->name();\r\n            }\r\n            else\r\n            {\r\n                return \"unnamed\";\r\n            }\r\n        }\r\n        else if (index.column() == DesignInstantiationsColumns::DISPLAY_NAME)\r\n        {\r\n            return instantiation->displayName();\r\n        }\r\n        else if (index.column() == DesignInstantiationsColumns::VLNV_REFERENCE)\r\n        {\r\n            return instantiation->getDesignReference()->toString();\r\n        }\r\n        else if (index.column() == DesignInstantiationsColumns::DESCRIPTION)\r\n        {\r\n            return instantiation->description().replace(QRegularExpression(\"\\n.*$\", \r\n                QRegularExpression::DotMatchesEverythingOption), \"...\");\r\n        }\r\n        else\r\n        {\r\n            return QVariant();\r\n        }\r\n\t}\r\n\telse if (role == Qt::ForegroundRole)\r\n    {\r\n        if (index.column() == DesignInstantiationsColumns::NAME && \r\n            !validator_->hasValidName(instantiation->name()))\r\n        {\r\n            return KactusColors::ERROR;\r\n        }\r\n        else\r\n        {\r\n            return KactusColors::REGULAR_TEXT;\r\n        }\r\n\t}\r\n\telse if (role == Qt::BackgroundRole)\r\n    {\r\n        if (index.column() == DesignInstantiationsColumns::NAME ||\r\n            index.column() == DesignInstantiationsColumns::VLNV_REFERENCE)\r\n        {\r\n            return KactusColors::MANDATORY_FIELD;\r\n        }\r\n        else\r\n        {\r\n            return KactusColors::REGULAR_FIELD;\r\n        }\r\n    }\r\n    else \r\n    {\r\n\t\treturn QVariant();\r\n\t}\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignInstantiationsModel::setData()\r\n//-----------------------------------------------------------------------------\r\nbool DesignInstantiationsModel::setData(QModelIndex const& index, const QVariant& value, int role)\r\n{\r\n\tif (!index.isValid() || index.row() < 0 || index.row() >= instantiations_->size())\r\n    {\r\n\t\treturn false;\r\n\t}\r\n\r\n    QSharedPointer<DesignInstantiation> instantiation = instantiations_->at(index.row());\r\n\r\n\tif (role == Qt::EditRole)\r\n    {\r\n        if (index.column() == DesignInstantiationsColumns::NAME)\r\n        {\r\n            instantiation->setName(value.toString());\r\n        }\r\n        else if (index.column() == DesignInstantiationsColumns::DISPLAY_NAME)\r\n        {\r\n            instantiation->setDisplayName(value.toString());\r\n        }\r\n        else if (index.column() == DesignInstantiationsColumns::VLNV_REFERENCE)\r\n        {\r\n            VLNV designReference = VLNV(VLNV::DESIGN, value.toString());\r\n            instantiation->getDesignReference()->setVLNV(designReference);\r\n        }\r\n        else if (index.column() == DesignInstantiationsColumns::DESCRIPTION)\r\n        {\r\n            instantiation->setDescription(value.toString());\r\n        }\r\n        else\r\n        {\r\n            return false;\r\n        }\r\n\r\n\t\temit dataChanged(index, index);\r\n\t\temit contentChanged();\r\n\t\treturn true;\r\n\t}\r\n\telse \r\n    {\r\n\t\treturn false;\r\n\t}\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignInstantiationsModel::supportedDropActions()\r\n//-----------------------------------------------------------------------------\r\nQt::DropActions DesignInstantiationsModel::supportedDropActions() const\r\n{\r\n    return Qt::CopyAction | Qt::MoveAction;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignInstantiationsModel::mimeTypes()\r\n//-----------------------------------------------------------------------------\r\nQStringList DesignInstantiationsModel::mimeTypes() const\r\n{\r\n    QStringList types(QAbstractTableModel::mimeTypes());\r\n    types << \"application/x-qt-image\";\r\n    return types;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignInstantiationsModel::dropMimeData()\r\n//-----------------------------------------------------------------------------\r\nbool DesignInstantiationsModel::dropMimeData(QMimeData const* data, Qt::DropAction action, int row, \r\n    int column, QModelIndex const& parent)\r\n{\r\n    if (action == Qt::IgnoreAction)\r\n    {\r\n        return true;\r\n    }\r\n\r\n    // Dropped data must be directly on parent.\r\n    if (row != -1 || column != -1 || !parent.isValid() || row > rowCount())\r\n    {\r\n        return false;\r\n    }\r\n\r\n    QVariant variant = data->imageData();\r\n\r\n    if (!variant.canConvert<VLNV>())\r\n    {\r\n        return false;\r\n    }\r\n    VLNV vlnv = variant.value<VLNV>();\r\n    \r\n    if (parent.column() == DesignInstantiationsColumns::VLNV_REFERENCE &&\r\n        vlnv.getType() == VLNV::DESIGN)\r\n    {\r\n        if (DocumentUtils::documentsHaveMatchingStdRevisions(vlnv, containingComponent_->getVlnv(), library_))\r\n        {\r\n            setData(index(parent.row(), parent.column()), vlnv.toString(\":\"));\r\n            emit contentChanged();\r\n        }\r\n        else\r\n        {\r\n            emit stdRevisionMismatch();\r\n            return false;\r\n        }\r\n    }\r\n\r\n    return true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignInstantiationsModel::onAddItem()\r\n//-----------------------------------------------------------------------------\r\nvoid DesignInstantiationsModel::onAddItem(QModelIndex const& index)\r\n{\r\n\tint row = instantiations_->size();\r\n\r\n\t// if the index is valid then add the item to the correct position\r\n\tif (index.isValid())\r\n    {\r\n\t\trow = index.row();\r\n\t}\r\n\r\n\tbeginInsertRows(QModelIndex(), row, row);\r\n\tinstantiations_->insert(row, QSharedPointer<DesignInstantiation>(new DesignInstantiation()));\r\n\tendInsertRows();\r\n\r\n\temit designInstantiationAdded(row);\r\n\temit contentChanged();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignInstantiationsModel::onRemoveItem()\r\n//-----------------------------------------------------------------------------\r\nvoid DesignInstantiationsModel::onRemoveItem(QModelIndex const& index)\r\n{\r\n\t// don't remove anything if index is invalid\r\n\tif (!index.isValid() || index.row() < 0 || index.row() >= instantiations_->size())\r\n    {\r\n\t\treturn;\r\n\t}\r\n\r\n\t// remove the specified item\r\n\tbeginRemoveRows(QModelIndex(), index.row(), index.row());\r\n\tinstantiations_->removeAt(index.row());\r\n\tendRemoveRows();\r\n\r\n\temit designInstantiationRemoved(index.row());\r\n\temit contentChanged();\r\n}\r\n"
  },
  {
    "path": "editors/ComponentEditor/instantiations/DesignInstantiationsModel.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: DesignInstantiationsModel.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Esko Pekkarinen\r\n// Date: 28.01.2016\r\n//\r\n// Description:\r\n// Model for desing instantiations of a component.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef DESIGNINSTANTIATIONSMODEL_H\r\n#define DESIGNINSTANTIATIONSMODEL_H\r\n\r\n#include <IPXACTmodels/Component/Component.h>\r\n\r\n#include <QAbstractTableModel>\r\n#include <QList>\r\n#include <QSharedPointer>\r\n#include <QMimeData>\r\n\r\nclass InstantiationsValidator;\r\nclass LibraryInterface;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Model for desing instantiations of a component.\r\n//-----------------------------------------------------------------------------\r\nclass DesignInstantiationsModel : public QAbstractTableModel\r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\r\n\t/*!\r\n     *  The constructor.\r\n\t *\r\n     *    @param [in] instantiations\tThe design instantiations.\r\n     *    @param [in] validator\t\tThe instantiations validator.\r\n\t *    @param [in] component       Pointer to the component being edited.\r\n\t *    @param [in] library\t\t\tThe library interface.\r\n\t *    @param [in] parent          Pointer to the owner of the model.\r\n\t */\r\n\tDesignInstantiationsModel(QSharedPointer<QList<QSharedPointer<DesignInstantiation> > > instantiations, \r\n\t\tQSharedPointer<InstantiationsValidator> validator, QSharedPointer<Component> component, \r\n\t\tLibraryInterface* library, QObject* parent);\r\n\t\r\n\t//! The destructor.\r\n\tvirtual ~DesignInstantiationsModel();\r\n\r\n\t/*!\r\n     *  Get the number of rows an item contains.\r\n\t *\r\n\t *    @param [in] parent  Identifies the parent that's row count is requested.\r\n\t *\r\n\t *    @return Number of rows the item has.\r\n\t */\r\n\tvirtual int rowCount(QModelIndex const& parent = QModelIndex()) const;\r\n\r\n\t/*!\r\n     *  Get the number of columns the item has to be displayed.\r\n\t *\r\n\t *    @param [in] parent  Identifies the parent that's column count is requested.\r\n\t *\r\n\t *    @return The number of columns to be displayed.\r\n\t */\r\n\tvirtual int columnCount(QModelIndex const& parent = QModelIndex()) const;\r\n\r\n\t/*!\r\n     *  Get the item flags that defines the possible operations for the item.\r\n\t *\r\n\t *    @param [in] index   Model index that identifies the item.\r\n\t *\r\n\t *    @return Qt::ItemFlags specify the possible operations for the item.\r\n\t */\r\n\tQt::ItemFlags flags(QModelIndex const& index) const;\r\n\r\n\t/*!\r\n     *  Get the header data for specified header.\r\n\t *\r\n\t *    @param [in] section         The section specifies the row/column number for the header.\r\n\t *    @param [in] orientation     Specified if horizontal or vertical header is wanted.\r\n\t *    @param [in] role            Specifies the type of the requested data.\r\n\t *\r\n\t *    @return QVariant Contains the requested data.\r\n\t */\r\n\tvirtual QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;\r\n\r\n\t/*!\r\n     *  Get the data for specified item.\r\n\t *\r\n\t *    @param [in] index   Specifies the item that's data is requested.\r\n\t *    @param [in] role    The role that defines what kind of data is requested.\r\n\t *\r\n\t *    @return QVariant Contains the data for the item.\r\n\t */\r\n\tvirtual QVariant data(QModelIndex const& index, int role = Qt::DisplayRole) const;\r\n\r\n\t/*!\r\n     *  Save the data to the model for specified item.\r\n\t *\r\n\t *    @param [in] index   The model index of the item that's data is to be saved.\r\n\t *    @param [in] value   The data that is to be saved.\r\n\t *    @param [in] role    The role specifies what kind of data should be saved.\r\n\t *\r\n\t *    @return True if saving happened successfully.\r\n\t */\r\n\tbool setData(QModelIndex const& index, const QVariant& value, int role = Qt::EditRole);\r\n\r\n  /*!\r\n     *  Returns the supported actions of a drop.\r\n     *\r\n     *    @return The drop actions supported by the model.\r\n     */\r\n    virtual Qt::DropActions supportedDropActions() const;\r\n\r\n    /*!\r\n     *  Returns a list of supported MIME data types.\r\n     *\r\n     *    @return The supported MIME types.\r\n     */\r\n    virtual QStringList mimeTypes() const;\r\n\r\n    /*!\r\n     *  Handler for the dropped MIME data.\r\n     *\r\n     *    @param [in] data   The data associated to the drop.\r\n     *    @param [in] action The drop action.  \r\n     *    @param [in] row    The row beneath the drop position.\r\n     *    @param [in] column The column beneath the drop position.\r\n     *    @param [in] parent The parent index of the drop position.\r\n     *\r\n     *    @return True, if the model could handle the data, otherwise false.\r\n     */\r\n    virtual bool dropMimeData(QMimeData const* data, Qt::DropAction action, int row, int column, \r\n        QModelIndex const& parent);\r\n\r\npublic slots:\r\n\r\n\t/*!\r\n     *  Add a new item to the given index.\r\n\t *\r\n\t *    @param [in] index   The index identifying the position for new item.\r\n\t */\r\n\tvirtual void onAddItem(QModelIndex const& index);\r\n\r\n\t/*!\r\n     *  Remove the item in the given index.\r\n\t *\r\n\t *    @param [in] index   The index identifying the item to remove.\r\n\t */\r\n\tvirtual void onRemoveItem(QModelIndex const& index);\r\n\r\nsignals:\r\n\r\n\t//! Emitted when the contents of the model change.\r\n\tvoid contentChanged();\r\n\r\n\t//! Emitted when a new design instantiation is added to the given index.\r\n\tvoid designInstantiationAdded(int index);\r\n\r\n\t//! Emitted when a design instantiation is removed from the given index.\r\n\tvoid designInstantiationRemoved(int index);\r\n\r\n\t//! Emitted when a design with different std revision is dropped in the design ref cell of the table.\r\n\tvoid stdRevisionMismatch();\r\n\r\nprivate:\r\n\t//! No copying.\r\n\tDesignInstantiationsModel(const DesignInstantiationsModel& other);\r\n\tDesignInstantiationsModel& operator=(const DesignInstantiationsModel& other);\r\n\r\n\t//! Contains the design instantiations to edit.\r\n    QSharedPointer<QList<QSharedPointer<DesignInstantiation> > > instantiations_;\r\n\r\n    //! The validator used for design instantiations.\r\n    QSharedPointer<InstantiationsValidator> validator_;\r\n\r\n\t//! The containing component.\r\n\tQSharedPointer<Component> containingComponent_;\r\n\r\n\t//! The library handler.\r\n\tLibraryInterface* library_;\r\n};\r\n\r\n#endif // DESIGNINSTANTIATIONSMODEL_H\r\n"
  },
  {
    "path": "editors/ComponentEditor/instantiations/InstantiationsEditor.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: InstantiationsEditor.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Esko Pekkarinen\r\n// Date: 29.01.2016\r\n//\r\n// Description:\r\n// Editor for component, design and design configuration instantiations.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"InstantiationsEditor.h\"\r\n\r\n#include \"ComponentInstantiationsEditor.h\"\r\n#include \"DesignConfigurationInstantiationsEditor.h\"\r\n#include \"DesignInstantiationsEditor.h\"\r\n\r\n#include <common/widgets/summaryLabel/summarylabel.h>\r\n#include <common/delegates/LineEditDelegate/lineeditdelegate.h>\r\n#include <KactusAPI/include/LibraryInterface.h>\r\n\r\n#include <QVBoxLayout>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: InstantiationsEditor::InstantiationsEditor()\r\n//-----------------------------------------------------------------------------\r\nInstantiationsEditor::InstantiationsEditor(QSharedPointer<Component> component,\r\n    QSharedPointer<ParameterFinder> parameterFinder, LibraryInterface* handler,\r\n    QSharedPointer<InstantiationsValidator> validator,\r\n    ComponentInstantiationInterface* componentInstantiationInterface, QWidget* parent):\r\nItemEditor(component, handler, parent),\r\ncomponentInstantiationsEditor_(new ComponentInstantiationsEditor(\r\n    component, handler, parameterFinder, componentInstantiationInterface, this)),\r\ndesignConfigurationInstantiationsEditor_(new DesignConfigurationInstantiationsEditor(component, handler, validator,\r\n                                                                                     this)),\r\ndesignInstantiationsEditor_(new DesignInstantiationsEditor(component, handler, validator, this))\r\n{\r\n\tQVBoxLayout* layout = new QVBoxLayout(this);\r\n\tlayout->addWidget(componentInstantiationsEditor_);\r\n    layout->addWidget(designConfigurationInstantiationsEditor_);\r\n    layout->addWidget(designInstantiationsEditor_);\r\n\tlayout->setContentsMargins(0, 0, 0, 0);\r\n\r\n    connect(componentInstantiationsEditor_, SIGNAL(contentChanged()), \r\n        this, SIGNAL(contentChanged()), Qt::UniqueConnection);\r\n    connect(componentInstantiationsEditor_, SIGNAL(childAdded(int)), \r\n        this, SIGNAL(componentInstanceAdded(int)), Qt::UniqueConnection);\r\n    connect(componentInstantiationsEditor_, SIGNAL(childRemoved(int)), \r\n        this, SIGNAL(componentInstanceRemoved(int)), Qt::UniqueConnection);\r\n\r\n    connect(designConfigurationInstantiationsEditor_, SIGNAL(contentChanged()), \r\n        this, SIGNAL(contentChanged()), Qt::UniqueConnection);\r\n    connect(designConfigurationInstantiationsEditor_, SIGNAL(childAdded(int)), \r\n        this, SIGNAL(designConfigurationInstanceAdded(int)), Qt::UniqueConnection);\r\n    connect(designConfigurationInstantiationsEditor_, SIGNAL(childRemoved(int)), \r\n        this, SIGNAL(designConfigurationInstanceRemoved(int)), Qt::UniqueConnection);\r\n\r\n    connect(designInstantiationsEditor_, SIGNAL(contentChanged()), \r\n        this, SIGNAL(contentChanged()), Qt::UniqueConnection);\r\n    connect(designInstantiationsEditor_, SIGNAL(childAdded(int)), \r\n        this, SIGNAL(designInstanceAdded(int)), Qt::UniqueConnection);\r\n    connect(designInstantiationsEditor_, SIGNAL(childRemoved(int)), \r\n        this, SIGNAL(designInstanceRemoved(int)), Qt::UniqueConnection);\r\n\r\n    connect(componentInstantiationsEditor_, SIGNAL(decreaseReferences(QString)), this,\r\n        SIGNAL(decreaseReferences(QString)), Qt::UniqueConnection);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: InstantiationsEditor::~InstantiationsEditor()\r\n//-----------------------------------------------------------------------------\r\nInstantiationsEditor::~InstantiationsEditor()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: InstantiationsEditor::refresh()\r\n//-----------------------------------------------------------------------------\r\nvoid InstantiationsEditor::refresh()\r\n{    \r\n    componentInstantiationsEditor_->refresh();\r\n    designConfigurationInstantiationsEditor_->refresh();\r\n    designInstantiationsEditor_->refresh();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: InstantiationsEditor::showEvent()\r\n//-----------------------------------------------------------------------------\r\nvoid InstantiationsEditor::showEvent(QShowEvent* event)\r\n{\r\n\tQWidget::showEvent(event);\r\n\temit helpUrlRequested(\"componenteditor/instantiations.html\");\r\n}\r\n"
  },
  {
    "path": "editors/ComponentEditor/instantiations/InstantiationsEditor.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: InstantiationsEditor.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Esko Pekkarinen\r\n// Date: 29.01.2016\r\n//\r\n// Description:\r\n// Editor for component, design and design configuration instantiations.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef INSTANTIATIONSEDITOR_H\r\n#define INSTANTIATIONSEDITOR_H\r\n\r\n#include \"ComponentInstantiationsEditor.h\"\r\n\r\n#include <editors/ComponentEditor/itemeditor.h>\r\n\r\n#include <QSortFilterProxyModel>\r\n\r\nclass DesignConfigurationInstantiationsEditor;\r\nclass DesignInstantiationsEditor;\r\nclass LibraryInterface;\r\nclass InstantiationsValidator;\r\nclass ComponentInstantiationInterface;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Editor for component, design and design configuration instantiations. \r\n//-----------------------------------------------------------------------------\r\nclass InstantiationsEditor : public ItemEditor\r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\r\n\t/*!\r\n     *  The constructor.\r\n\t *\r\n\t *    @param [in] component                           The component being edited.\r\n     *    @param [in] parameterFinder                     Finder used to identify parameters.\r\n\t *    @param [in] handler                             The instance managing the library.\r\n     *    @param [in] validator                           The validator used for instantiations.\r\n     *    @param [in] componentInstantiationInterface     Interface for accessing component instantiations.\r\n\t *    @param [in] parent                              The parent of this editor.\r\n\t */\r\n    InstantiationsEditor(QSharedPointer<Component> component,\r\n        QSharedPointer<ParameterFinder> parameterFinder,\r\n        LibraryInterface* handler,\r\n        QSharedPointer<InstantiationsValidator> validator,\r\n        ComponentInstantiationInterface* componentInstantiationInterface,\r\n        QWidget* parent = 0);\r\n\r\n\t/*!\r\n     *  The destructor.\r\n     */\r\n\tvirtual ~InstantiationsEditor();\r\n\r\n\t/*!\r\n     *  Reload the information from the model to the editor.\r\n\t */\r\n\tvirtual void refresh();\r\n\r\nsignals:\r\n\r\n    //! Emitted when a new component instantiation is added.\r\n    void componentInstanceAdded(int);\r\n    \r\n    //! Emitted when a component instantiation is removed.\r\n    void componentInstanceRemoved(int);\r\n\r\n    //! Emitted when a new design configuration instantiation is added.\r\n    void designConfigurationInstanceAdded(int);\r\n\r\n    //! Emitted when a design configuration instantiation is removed.\r\n    void designConfigurationInstanceRemoved(int);\r\n\r\n    //! Emitted when a new design instantiation is added.\r\n    void designInstanceAdded(int);\r\n\r\n     //! Emitted when a new design instantiation is removed.   \r\n    void designInstanceRemoved(int);\r\n\r\nprotected:\r\n\r\n\t//! Handler for widget's show event.\r\n\tvirtual void showEvent(QShowEvent* event);\r\n\r\nprivate:\r\n\r\n\t//! No copying.\r\n\tInstantiationsEditor(const InstantiationsEditor& other);\r\n\r\n\t//! No assignment.\r\n\tInstantiationsEditor& operator=(const InstantiationsEditor& other);\r\n\r\n    //! Editor for component instantiations.\r\n\tComponentInstantiationsEditor* componentInstantiationsEditor_;\r\n\r\n    //! Editor for design configuration instantiations.\r\n    DesignConfigurationInstantiationsEditor* designConfigurationInstantiationsEditor_;\r\n\r\n    //! Editor for design instantiations.\r\n    DesignInstantiationsEditor* designInstantiationsEditor_;\r\n\r\n};\r\n\r\n#endif // INSTANTIATIONSEDITOR_H\r\n"
  },
  {
    "path": "editors/ComponentEditor/instantiations/ModuleParameterColumns.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ModuleParameterColumns.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Esko Pekkarinen\r\n// Date: 06.11.2014\r\n//\r\n// Description:\r\n// Common declarations for editing module parameters.\r\n//-----------------------------------------------------------------------------\r\n\r\nnamespace ModuleParameterColumns\r\n{\r\n    //! The editable columns in the module parameter editor.\r\n    enum columns\r\n    {\r\n        NAME = 0,\r\n        DISPLAY_NAME,\r\n        DESCRIPTION,\r\n        ID,\r\n        DATA_TYPE,\r\n        TYPE,\r\n        VALUE,\r\n        CHOICE,\r\n        MINIMUM,\r\n        MAXIMUM,\r\n        USAGE_TYPE,\r\n        RESOLVE,\r\n        BITWIDTH_LEFT,\r\n        BITWIDTH_RIGHT,\r\n        ARRAY_LEFT,\r\n        ARRAY_RIGHT,\r\n        USAGE_COUNT,\r\n        COLUMN_COUNT,\r\n    };\r\n}\r\n"
  },
  {
    "path": "editors/ComponentEditor/instantiations/ModuleParameterDelegate.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ModuleParameterDelegate.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 31.3.2011\r\n//\r\n// Description:\r\n// Delegate that provides widgets for editing model parameters.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"ModuleParameterDelegate.h\"\r\n\r\n#include \"ModuleParameterColumns.h\"\r\n\r\n#include <QComboBox>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ModuleParameterDelegate::ModuleParameterDelegate()\r\n//-----------------------------------------------------------------------------\r\nModuleParameterDelegate::ModuleParameterDelegate(QSharedPointer<QList<QSharedPointer<Choice> > > choices, \r\n    QAbstractItemModel* completionModel, QSharedPointer<ParameterFinder> parameterFinder,\r\n    QSharedPointer<ExpressionFormatter> expressionFormatter, Document::Revision docRevision, QObject* parent):\r\nParameterDelegate(choices, completionModel, parameterFinder, expressionFormatter, parent),\r\ndocRevision_(docRevision)\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ModuleParameterDelegate::~ModuleParameterDelegate()\r\n//-----------------------------------------------------------------------------\r\nModuleParameterDelegate::~ModuleParameterDelegate()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ModuleParameterDelegate::createEditor()\r\n//-----------------------------------------------------------------------------\r\nQWidget* ModuleParameterDelegate::createEditor(QWidget* parent, QStyleOptionViewItem const& option, \r\n    QModelIndex const& index ) const\r\n{\r\n\tif (index.column() == ModuleParameterColumns::USAGE_TYPE) \r\n    {\r\n\t\tQComboBox* combo = new QComboBox(parent);\r\n\t\tcombo->addItem(QStringLiteral(\"typed\"));\r\n\t\tcombo->addItem(QStringLiteral(\"nontyped\"));\r\n        if (docRevision_ == Document::Revision::Std22)\r\n        {\r\n            combo->addItem(QStringLiteral(\"runtime\"));\r\n        }\r\n\r\n\t\treturn combo;\r\n\t}\r\n    else\r\n    {\r\n        return ParameterDelegate::createEditor(parent, option, index);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ModuleParameterDelegate::nameColumn()\r\n//-----------------------------------------------------------------------------\r\nint ModuleParameterDelegate::nameColumn() const\r\n{\r\n    return ModuleParameterColumns::NAME;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ModuleParameterDelegate::choiceColumn()\r\n//-----------------------------------------------------------------------------\r\nint ModuleParameterDelegate::choiceColumn() const\r\n{\r\n    return ModuleParameterColumns::CHOICE;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ModuleParameterDelegate::formatColumn()\r\n//-----------------------------------------------------------------------------\r\nint ModuleParameterDelegate::formatColumn() const\r\n{\r\n    return ModuleParameterColumns::TYPE;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ModuleParameterDelegate::bitWidthLeftColumn()\r\n//-----------------------------------------------------------------------------\r\nint ModuleParameterDelegate::bitWidthLeftColumn() const\r\n{\r\n    return ModuleParameterColumns::BITWIDTH_LEFT;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ModuleParameterDelegate::bitWidthRightColumn()\r\n//-----------------------------------------------------------------------------\r\nint ModuleParameterDelegate::bitWidthRightColumn() const\r\n{\r\n    return ModuleParameterColumns::BITWIDTH_RIGHT;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ModuleParameterDelegate::minimumColumn()\r\n//-----------------------------------------------------------------------------\r\nint ModuleParameterDelegate::minimumColumn() const\r\n{\r\n    return ModuleParameterColumns::MINIMUM;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ModuleParameterDelegate::maximumColumn()\r\n//-----------------------------------------------------------------------------\r\nint ModuleParameterDelegate::maximumColumn() const\r\n{\r\n    return ModuleParameterColumns::MAXIMUM;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ModuleParameterDelegate::valueColumn()\r\n//-----------------------------------------------------------------------------\r\nint ModuleParameterDelegate::valueColumn() const\r\n{\r\n    return ModuleParameterColumns::VALUE;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ModuleParameterDelegate::resolveColumn()\r\n//-----------------------------------------------------------------------------\r\nint ModuleParameterDelegate::resolveColumn() const\r\n{\r\n    return ModuleParameterColumns::RESOLVE;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ModuleParameterDelegate::descriptionColumn()\r\n//-----------------------------------------------------------------------------\r\nint ModuleParameterDelegate::descriptionColumn() const\r\n{\r\n    return ModuleParameterColumns::DESCRIPTION;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ModuleParameterDelegate::arrayLeftColumn()\r\n//-----------------------------------------------------------------------------\r\nint ModuleParameterDelegate::arrayLeftColumn() const\r\n{\r\n    return ModuleParameterColumns::ARRAY_LEFT;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ModuleParameterDelegate::arrayRightColumn()\r\n//-----------------------------------------------------------------------------\r\nint ModuleParameterDelegate::arrayRightColumn() const\r\n{\r\n    return ModuleParameterColumns::ARRAY_RIGHT;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ModuleParameterDelegate::usageCountColumn()\r\n//-----------------------------------------------------------------------------\r\nint ModuleParameterDelegate::usageCountColumn() const\r\n{\r\n    return ModuleParameterColumns::USAGE_COUNT;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ModuleParameterDelegate::idColumn()\r\n//-----------------------------------------------------------------------------\r\nint ModuleParameterDelegate::idColumn() const\r\n{\r\n    return ModuleParameterColumns::ID;\r\n}\r\n"
  },
  {
    "path": "editors/ComponentEditor/instantiations/ModuleParameterDelegate.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ModuleParameterDelegate.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 31.3.2011\r\n//\r\n// Description:\r\n// Delegate that provides widgets for editing model parameters.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef ModuleParameterDelegate_H\r\n#define ModuleParameterDelegate_H\r\n\r\n#include <IPXACTmodels/common/Document.h>\r\n\r\n#include <QStyledItemDelegate>\r\n\r\n#include <editors/ComponentEditor/parameters/ParameterDelegate.h>\r\n\r\nclass Choice;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Delegate that provides widgets for editing model parameters.\r\n//-----------------------------------------------------------------------------\r\nclass ModuleParameterDelegate : public ParameterDelegate\r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\r\n\t/*! The constructor\r\n\t *\r\n\t *    @param [in] choices              The choices available for model parameter value.\r\n     *    @param [in] completionModel     Model containing the completions used in expression editor.\r\n     *    @param [in] parameterFinder      The parameter finder.\r\n     *    @param [in] expressionFormatter  The expression formatter.\r\n     *    @param [in] docRevision          The IP-XACT standard revision in use.\r\n\t *    @param [in] parent               The parent object\r\n\t*/\r\n\tModuleParameterDelegate(QSharedPointer<QList<QSharedPointer<Choice> > > choices,\r\n        QAbstractItemModel* completionModel,\r\n        QSharedPointer<ParameterFinder> parameterFinder,\r\n        QSharedPointer<ExpressionFormatter> expressionFormatter,\r\n        Document::Revision docRevision,\r\n        QObject *parent = 0);\r\n\r\n\t//! The destructor.\r\n\tvirtual ~ModuleParameterDelegate();\r\n\r\n\t/*!\r\n     *  Create a new editor for the given item\r\n\t *\r\n\t *    @param [in] parent   Owner for the editor.\r\n\t *    @param [in] option   Contains options for the editor.\r\n\t *    @param [in] index    Model index identifying the item.\r\n\t *\r\n\t *    @return Pointer to the editor to be used to edit the item.\r\n\t */\r\n\tvirtual QWidget* createEditor(QWidget* parent, QStyleOptionViewItem const& option, QModelIndex const& index)\r\n        const;\r\n\r\nprotected:\r\n\r\n    /*!\r\n     *  Gets the column for name.\r\n     *\r\n     *    @return The column index for editing name.\r\n     */\r\n    virtual int nameColumn() const;\r\n\r\n    /*!\r\n     *  Gets the column for choices.\r\n     *\r\n     *    @return The column for editing choice selection.\r\n     */\r\n    virtual int choiceColumn() const;\r\n    \r\n    /*!\r\n     *  Gets the column for value format.\r\n     *\r\n     *    @return The column for editing format selection.\r\n     */\r\n    virtual int formatColumn() const;\r\n\r\n    /*!\r\n    *  Gets the column for the left value of bit width vector.\r\n    *\r\n    *    @return The column for editing the left value of the bit width vector.\r\n    */\r\n    virtual int bitWidthLeftColumn() const;\r\n\r\n    /*!\r\n    *  Gets the column for the right value of bit width vector.\r\n    *\r\n    *    @return The column for editing the right value of the bit width vector.\r\n    */\r\n    virtual int bitWidthRightColumn() const;\r\n\r\n    /*!\r\n     *  Gets the column for minimum value.\r\n     *\r\n     *    @return The column for editing the minimum value.\r\n     */\r\n    virtual int minimumColumn() const;\r\n        \r\n    /*!\r\n     *  Gets the column for maximum value.\r\n     *\r\n     *    @return The column for editing the maximum value.\r\n     */\r\n    virtual int maximumColumn() const;\r\n\r\n    /*!\r\n     *  Gets the column for values.\r\n     *\r\n     *    @return The column for editing value selection.\r\n     */\r\n    virtual int valueColumn() const;\r\n    \r\n    /*!\r\n     *  Gets the column for resolve.\r\n     *\r\n     *    @return The column for resolve selection.\r\n     */\r\n    virtual int resolveColumn() const;\r\n\r\n    /*!\r\n     *  Gets the column index for description.\r\n     *\r\n     *    @return     The column index for description section.\r\n     */\r\n    virtual int descriptionColumn() const;\r\n    \r\n    /*!\r\n     *  Gets the column index for array left.\r\n     *\r\n     *    @return     The column index for array left side.\r\n     */\r\n    virtual int arrayLeftColumn() const;\r\n\r\n    /*!\r\n     *  Gets the column index for array right.\r\n     *\r\n     *    @return     The column index for array right side.\r\n     */\r\n    virtual int arrayRightColumn() const;\r\n\r\n    /*!\r\n     *  Gets the column index for usage count.\r\n     *\r\n     *    @return     The column index for usage count.\r\n     */\r\n    virtual int usageCountColumn() const;\r\n\r\n    /*!\r\n     *  Gets the column index for the id of the model parameter.\r\n     *\r\n     *    @return     The column index for model parameter id.\r\n     */\r\n    virtual int idColumn() const;\r\n\r\nprivate:\r\n\r\n\t//! No copying\r\n\tModuleParameterDelegate(const ModuleParameterDelegate& other);\r\n\r\n\t//! No assignment\r\n\tModuleParameterDelegate& operator=(const ModuleParameterDelegate& other);\r\n\r\n    //! The IP-XACT standard revision in use.\r\n    Document::Revision docRevision_;\r\n};\r\n\r\n#endif // ModuleParameterDelegate_H\r\n"
  },
  {
    "path": "editors/ComponentEditor/instantiations/ModuleParameterEditor.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ModuleParameterEditor.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Esko Pekkarinen\r\n// Date: 19.02.2015\r\n//\r\n// Description:\r\n// Editor for module parameters.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"ModuleParameterEditor.h\"\r\n\r\n#include \"ModuleParameterModel.h\"\r\n#include \"ModuleParameterDelegate.h\"\r\n#include \"ModuleParameterHeaderView.h\"\r\n#include \"ModuleParameterColumns.h\"\r\n#include \"ModuleParameterHeaderView.h\"\r\n\r\n#include <KactusAPI/include/ComponentParameterFinder.h>\r\n#include <KactusAPI/include/ExpressionFormatter.h>\r\n#include <KactusAPI/include/IPXactSystemVerilogParser.h>\r\n#include <KactusAPI/include/ParameterFinder.h>\r\n#include <editors/ComponentEditor/parameters/ParametersView.h>\r\n#include <editors/ComponentEditor/parameters/ComponentParameterModel.h>\r\n#include <KactusAPI/include/ModuleParameterInterface.h>\r\n\r\n#include <IPXACTmodels/common/validators/ParameterValidator.h>\r\n\r\n#include <QCompleter>\r\n#include <QSortFilterProxyModel>\r\n#include <QVBoxLayout>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ModuleParameterEditor::ModuleParameterEditor()\r\n//-----------------------------------------------------------------------------\r\nModuleParameterEditor::ModuleParameterEditor(QSharedPointer<ComponentInstantiation> instantiation,\r\n    QSharedPointer<QList<QSharedPointer<Choice>>> componentChoices,\r\n    QSharedPointer<ParameterFinder> parameterFinder, QSharedPointer<ExpressionFormatter> expressionFormatter,\r\n    ModuleParameterInterface* parameterInterface, Document::Revision docRevision, QWidget* parent):\r\nQGroupBox(tr(\"Module parameters\"), parent),\r\nproxy_(new QSortFilterProxyModel(this)),\r\nmodel_(0),\r\nmoduleParameterInterface_(parameterInterface),\r\nview_(0),\r\ninstantiation_(instantiation)\r\n{\r\n    QSharedPointer<IPXactSystemVerilogParser> expressionParser(new IPXactSystemVerilogParser(parameterFinder));\r\n\r\n    model_ = new ModuleParameterModel(moduleParameterInterface_, expressionParser, parameterFinder, this);\r\n\r\n    view_ = new ParametersView(this);\r\n\r\n    ModuleParameterHeaderView* horizontalHeader = new ModuleParameterHeaderView(Qt::Horizontal, view_);\r\n    view_->setHorizontalHeader(horizontalHeader);\r\n\r\n    view_->verticalHeader()->setMaximumWidth(300);\r\n    view_->verticalHeader()->setMinimumWidth(horizontalHeader->fontMetrics().horizontalAdvance(tr(\"Name\"))*2);\r\n    view_->verticalHeader()->setSectionResizeMode(QHeaderView::Fixed);\r\n    view_->verticalHeader()->show();\r\n  \r\n    ComponentParameterModel* parameterModel = new ComponentParameterModel(parameterFinder, this);\r\n    parameterModel->setExpressionParser(expressionParser);\r\n\r\n    view_->setItemDelegate(new ModuleParameterDelegate(componentChoices, parameterModel, parameterFinder,\r\n        expressionFormatter, docRevision, this));\r\n\r\n    connect(model_, SIGNAL(contentChanged()), this, SIGNAL(contentChanged()), Qt::UniqueConnection);\r\n    connect(model_, SIGNAL(dataChanged(const QModelIndex&, const QModelIndex&)),\r\n        this, SIGNAL(contentChanged()), Qt::UniqueConnection);\r\n    connect(model_, SIGNAL(errorMessage(const QString&)),\r\n        this, SIGNAL(errorMessage(const QString&)), Qt::UniqueConnection);\r\n    connect(model_, SIGNAL(noticeMessage(const QString&)),\r\n        this, SIGNAL(noticeMessage(const QString&)), Qt::UniqueConnection);\r\n\r\n    connect(view_, SIGNAL(addItem(const QModelIndex&)), \r\n        model_, SLOT(onAddItem(const QModelIndex&)), Qt::UniqueConnection);\r\n    connect(view_, SIGNAL(removeItem(const QModelIndex&)),\r\n        model_, SLOT(onRemoveItem(const QModelIndex&)), Qt::UniqueConnection);\r\n    connect(view_->itemDelegate(), SIGNAL(increaseReferences(QString)), \r\n        this, SIGNAL(increaseReferences(QString)), Qt::UniqueConnection);\r\n    connect(view_->itemDelegate(), SIGNAL(decreaseReferences(QString)),\r\n        this, SIGNAL(decreaseReferences(QString)), Qt::UniqueConnection);\r\n\r\n    connect(model_, SIGNAL(decreaseReferences(QString)),\r\n        this, SIGNAL(decreaseReferences(QString)), Qt::UniqueConnection);\r\n\r\n    connect(view_->itemDelegate(), SIGNAL(openReferenceTree(QString const&, QString const&)),\r\n        this, SIGNAL(openReferenceTree(QString const&, QString const&)), Qt::UniqueConnection);\r\n\r\n    connect(view_, SIGNAL(recalculateReferenceToIndexes(QModelIndexList)),\r\n        model_, SLOT(onGetParametersMachingIndexes(QModelIndexList)), Qt::UniqueConnection);\r\n    connect(model_,\r\n        SIGNAL(recalculateReferencesToParameters(QVector<QString> const&, AbstractParameterInterface*)),\r\n        this,\r\n        SIGNAL(recalculateReferencesToParameters(QVector<QString> const&, AbstractParameterInterface*)),\r\n        Qt::UniqueConnection);\r\n\r\n    view_->setSortingEnabled(true);\r\n    view_->setItemsDraggable(false);\r\n\r\n    proxy_->setSourceModel(model_);\r\n    view_->setModel(proxy_);\r\n\r\n    view_->sortByColumn(0, Qt::AscendingOrder);\r\n    \r\n    view_->setColumnHidden(ModuleParameterColumns::ID, true);\r\n\r\n    QVBoxLayout* layout = new QVBoxLayout(this);\r\n    layout->addWidget(view_);\r\n\r\n    setModuleParameters(instantiation_);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ModuleParameterEditor::~ModuleParameterEditor()\r\n//-----------------------------------------------------------------------------\r\nModuleParameterEditor::~ModuleParameterEditor()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ModuleParameterEditor::refresh()\r\n//-----------------------------------------------------------------------------\r\nvoid ModuleParameterEditor::refresh()\r\n{\r\n    setModuleParameters(instantiation_);\r\n\r\n    proxy_->invalidate();\r\n\r\n    if (!view_->isColumnHidden(ModuleParameterColumns::ID))\r\n    {\r\n        view_->setColumnHidden(ModuleParameterColumns::ID, true);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ModuleParameterEditor::enableEditing()\r\n//-----------------------------------------------------------------------------\r\nvoid ModuleParameterEditor::enableEditing()\r\n{\r\n    model_->enableEditing();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ModuleParameterEditor::disableEditing()\r\n//-----------------------------------------------------------------------------\r\nvoid ModuleParameterEditor::disableEditing()\r\n{\r\n    model_->disableEditing();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ModuleParameterEditor::setModuleParameters()\r\n//-----------------------------------------------------------------------------\r\nvoid ModuleParameterEditor::setModuleParameters(QSharedPointer<ComponentInstantiation> containingInstantiation)\r\n{\r\n    instantiation_ = containingInstantiation;\r\n    moduleParameterInterface_->setModuleParameters(instantiation_);\r\n\r\n    model_->resetModelItems();\r\n}\r\n"
  },
  {
    "path": "editors/ComponentEditor/instantiations/ModuleParameterEditor.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ModuleParameterEditor.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Esko Pekkarinen\r\n// Date: 19.02.2015\r\n//\r\n// Description:\r\n// Editor for module parameters.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef MODULEPARAMETEREDITOR_H\r\n#define MODULEPARAMETEREDITOR_H\r\n\r\n#include <IPXACTmodels/common/Document.h>\r\n\r\n#include <QGroupBox>\r\n#include <QSortFilterProxyModel>\r\n\r\nclass Choice;\r\nclass ModuleParameterModel;\r\nclass ParameterFinder;\r\nclass ExpressionFormatter;\r\nclass Parameter;\r\nclass AbstractParameterInterface;\r\nclass ModuleParameterInterface;\r\nclass ParametersView;\r\nclass ComponentInstantiation;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Editor for module parameters.\r\n//-----------------------------------------------------------------------------\r\nclass ModuleParameterEditor : public QGroupBox\r\n{\r\n    Q_OBJECT\r\npublic:\r\n\r\n    /*!\r\n     *  The constructor.\r\n     *\r\n     *    @param [in] instantiation           Component instantiation containing the selected module parameters.\r\n     *    @param [in] componentChoices        The component choices.\r\n     *    @param [in] parameterFinder         The selected parameter finder.\r\n     *    @param [in] expressionFormatter     The selected expression formatter.\r\n     *    @param [in] parameterInterface      Interface for accessing module parameters.\r\n     *    @param [in] docRevision             The IP-XACT standard revision in use.\r\n     *    @param [in] parent                  The owner of this editor.\r\n     */\r\n    ModuleParameterEditor(\r\n        QSharedPointer<ComponentInstantiation> instantiation,\r\n        QSharedPointer<QList<QSharedPointer<Choice> > > componentChoices,\r\n        QSharedPointer<ParameterFinder> parameterFinder,\r\n        QSharedPointer<ExpressionFormatter> expressionFormatter,\r\n        ModuleParameterInterface* parameterInterface,\r\n        Document::Revision docRevision,\r\n        QWidget* parent);\r\n\r\n\t/*!\r\n     *  The destructor.\r\n     */\r\n\t~ModuleParameterEditor();\r\n\r\n    /*!\r\n     *  Refresh the contents of the editor.\r\n     */\r\n    void refresh();\r\n\r\n    /*!\r\n     *  Enables the editing of module parameters.\r\n     */\r\n    void enableEditing();\r\n\r\n    /*!\r\n     *  Disables the editing of module parameters.\r\n     */\r\n    void disableEditing();\r\n\r\n    /*!\r\n     *  Sets the module parameters to edit.\r\n     *\r\n     *    @param [in] containingInstantiation     Component instantiation containing the module parameters.\r\n     */\r\n    void setModuleParameters(QSharedPointer<ComponentInstantiation> containingInstantiation);\r\n\r\nsignals:\r\n    //! Emitted when contents of the editor change.\r\n\tvoid contentChanged();\r\n\r\n\t//! Prints an error message to the user.\r\n\tvoid errorMessage(QString const& msg) const;\r\n\r\n\t//! Prints a notification to user.\r\n\tvoid noticeMessage(QString const& msg) const;\r\n\r\n    /*!\r\n     *  Increase the amount of references to the parameter corresponding to the id.\r\n     *\r\n     *    @param [in] id      The id of the parameter being searched for.\r\n     */\r\n    void increaseReferences(QString id);\r\n\r\n    /*!\r\n     *  Decrease the amount of references to the parameter corresponding to the id.\r\n     *\r\n     *    @param [in] id      The id of the parameter being searched for.\r\n     */\r\n    void decreaseReferences(QString id);\r\n\r\n    /*!\r\n     *  Open the reference tree of the parameter with the ID.\r\n     *\r\n     *    @param [in] id              The ID of the parameter.\r\n     *    @param [in] parameterName   Name of the selected parameter.\r\n     */\r\n    void openReferenceTree(QString const& id, QString const& parameterName) const;\r\n\r\n    /*!\r\n     *  Recalculate references made to the selected parameters.\r\n     *\r\n     *    @param [in] parameterList       The selected parameters.\r\n     *    @param [in] parameterInterface  Interface for accessing parameters.\r\n     */\r\n    void recalculateReferencesToParameters(QVector<QString> const& parameterList,\r\n        AbstractParameterInterface* parameterInterface);\r\n\r\nprivate:\r\n\r\n\t// Disable copying.\r\n\tModuleParameterEditor(ModuleParameterEditor const& rhs);\r\n\tModuleParameterEditor& operator=(ModuleParameterEditor const& rhs);\r\n\r\n    //! The used sort filter proxy.\r\n    QSortFilterProxyModel* proxy_;\r\n\r\n    //! Used for editing model parameters.\r\n    ModuleParameterModel* model_;\r\n\r\n    //! Interface for accessing module parameters.\r\n    ModuleParameterInterface* moduleParameterInterface_;\r\n\r\n    //! The parameters view.\r\n    ParametersView* view_;\r\n\r\n    //! Component instantiation containing the module parameters.\r\n    QSharedPointer<ComponentInstantiation> instantiation_;\r\n};\r\n\r\n#endif // MODULEPARAMETEREDITOR_H"
  },
  {
    "path": "editors/ComponentEditor/instantiations/ModuleParameterHeaderView.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ModuleParameterHeaderView.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Mikko Teuho\r\n// Date: 12.12.2014\r\n//\r\n// Description:\r\n// Header view for module parameter editor.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"ModuleParameterHeaderView.h\"\r\n\r\n#include \"ModuleParameterColumns.h\"\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ModelParameterEditorHeaderView::ModelParameterEditorHeaderView()\r\n//-----------------------------------------------------------------------------\r\nModuleParameterHeaderView::ModuleParameterHeaderView(Qt::Orientation orientation, QWidget* parent /* = 0 */):\r\nParameterEditorHeaderView(orientation, parent)\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ModelParameterEditorHeaderView::~ModelParameterEditorHeaderView()\r\n//-----------------------------------------------------------------------------\r\nModuleParameterHeaderView::~ModuleParameterHeaderView()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ParameterEditorHeaderView::descriptionColumn()\r\n//-----------------------------------------------------------------------------\r\nint ModuleParameterHeaderView::descriptionColumn() const\r\n{\r\n    return ModuleParameterColumns::DESCRIPTION;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ModelParameterEditorHeaderView::valueColumn()\r\n//-----------------------------------------------------------------------------\r\nint ModuleParameterHeaderView::valueColumn() const\r\n{\r\n    return ModuleParameterColumns::VALUE;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ParameterEditorHeaderView::maximumColumn()\r\n//-----------------------------------------------------------------------------\r\nint ModuleParameterHeaderView::maximumColumn() const\r\n{\r\n    return ModuleParameterColumns::MAXIMUM;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ModelParameterEditorHeaderView::arrayRightColumn()\r\n//-----------------------------------------------------------------------------\r\nint ModuleParameterHeaderView::arrayRightColumn() const\r\n{\r\n    return ModuleParameterColumns::ARRAY_RIGHT;\r\n}\r\n"
  },
  {
    "path": "editors/ComponentEditor/instantiations/ModuleParameterHeaderView.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ModuleParameterHeaderView.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Mikko Teuho\r\n// Date: 12.12.2014\r\n//\r\n// Description:\r\n// Header view for module parameter editor.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef MODELPARAMETEREDITORHEADERVIEW_H\r\n#define MODELPARAMETEREDITORHEADERVIEW_H\r\n\r\n#include \"editors/ComponentEditor/parameters/ParameterEditorHeaderView.h\"\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Header view used to drawing the header.\r\n//-----------------------------------------------------------------------------\r\nclass ModuleParameterHeaderView : public ParameterEditorHeaderView\r\n{\r\n\r\npublic:\r\n    /*!\r\n     *  The constructor for the header.\r\n     *\r\n     *    @param [in] orientation     The headers orientation.\r\n     *    @param [in] parent          The parent of the header.\r\n     */\r\n    ModuleParameterHeaderView(Qt::Orientation orientation, QWidget* parent = 0);\r\n\r\n    virtual ~ModuleParameterHeaderView();\r\n\r\nprotected:\r\n    \r\n    /*!\r\n     *  Gets the description column index.\r\n     *\r\n     *    @return     The description column index.\r\n     */\r\n    virtual int descriptionColumn() const;\r\n\r\n    /*!\r\n     *  Gets the value column index.\r\n     *\r\n     *    @return     The value column index.\r\n     */\r\n    virtual int valueColumn() const;\r\n\r\n    /*!\r\n     *  Gets the maximum column index.\r\n     *\r\n     *    @return     The maximum column index.\r\n     */\r\n    virtual int maximumColumn() const;\r\n\r\n    /*!\r\n     *  Gets the index of array right column.\r\n     *\r\n     *    @return     The array right column index.\r\n     */\r\n    virtual int arrayRightColumn() const;\r\n\r\nprivate:\r\n\r\n    //! Disable copying and assignment\r\n    ModuleParameterHeaderView(const ParameterEditorHeaderView& other);\r\n    ModuleParameterHeaderView& operator=(const ParameterEditorHeaderView& other);\r\n};\r\n\r\n#endif // MODELPARAMETEREDITORHEADERVIEW_H"
  },
  {
    "path": "editors/ComponentEditor/instantiations/ModuleParameterModel.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ModuleParameterModel.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 29.3.2011\r\n//\r\n// Description:\r\n// This model can be used to edit and update a list of module parameters.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"ModuleParameterModel.h\"\r\n#include \"ModuleParameterColumns.h\"\r\n\r\n#include <IPXACTmodels/common/ModuleParameter.h>\r\n#include <IPXACTmodels/common/validators/ParameterValidator.h>\r\n\r\n#include <KactusAPI/include/ParametersInterface.h>\r\n\r\n#include <common/KactusColors.h>\r\n\r\n#include <QPersistentModelIndex>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ModuleParameterModel::ModuleParameterModel()\r\n//-----------------------------------------------------------------------------\r\nModuleParameterModel::ModuleParameterModel(ModuleParameterInterface* moduleParameterInterface,\r\n    QSharedPointer<ExpressionParser> expressionParser, QSharedPointer<ParameterFinder> parameterFinder,\r\n    QObject *parent):\r\nAbstractParameterModel(moduleParameterInterface, expressionParser, parameterFinder, parent),\r\neditingDisabled_(false)\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ModuleParameterModel::columnCount()\r\n//-----------------------------------------------------------------------------\r\nint ModuleParameterModel::columnCount(QModelIndex const& parent /*= QModelIndex() */ ) const\r\n{\r\n\t// not hierarchical model\r\n\tif (parent.isValid())\r\n    {\r\n\t\treturn 0;\r\n    }\r\n\r\n\treturn ModuleParameterColumns::COLUMN_COUNT;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ModuleParameterModel::data()\r\n//-----------------------------------------------------------------------------\r\nQVariant ModuleParameterModel::data(QModelIndex const& index, int role) const\r\n{\r\n\tif (!index.isValid() || index.row() < 0 || index.row() >= rowCount())\r\n    {\r\n\t\treturn QVariant();\r\n    }\r\n\r\n    std::string parameterName = getInterface()->getIndexedItemName(index.row());\r\n\r\n    if (role == Qt::DisplayRole || role == Qt::ToolTipRole || role == Qt::EditRole)\r\n    {\r\n        ModuleParameterInterface* moduleInterface = dynamic_cast<ModuleParameterInterface*>(getInterface());\r\n\r\n        if (moduleInterface)\r\n        {\r\n            if (index.column() == ModuleParameterColumns::DATA_TYPE)\r\n            {\r\n                return QString::fromStdString(moduleInterface->getDataType(parameterName));\r\n            }\r\n            else if (index.column() == ModuleParameterColumns::USAGE_TYPE)\r\n            {\r\n                return QString::fromStdString(moduleInterface->getUsageType(parameterName));\r\n            }\r\n        }\r\n    }\r\n\r\n    else if (Qt::ForegroundRole == role)\r\n    {\r\n        if (!validateIndex(index))\r\n        {\r\n             return KactusColors::ERROR;\r\n        }\r\n        else if (editingDisabled_)\r\n        {\r\n            return KactusColors::DISABLED_TEXT;\r\n        }\r\n    }\r\n\r\n    return AbstractParameterModel::data(index, role);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ModuleParameterModel::headerData()\r\n//-----------------------------------------------------------------------------\r\nQVariant ModuleParameterModel::headerData(int section, Qt::Orientation orientation, int role) const\r\n{\r\n\tif (orientation == Qt::Horizontal && role == Qt::DisplayRole) \r\n    {\t\r\n\t\tif (section ==  ModuleParameterColumns::DATA_TYPE)\r\n        {\r\n            return tr(\"Data\\ntype\");\r\n        }\r\n        else if (section == ModuleParameterColumns::USAGE_TYPE)\r\n        {\r\n            return tr(\"OO usage\");\r\n        }\r\n\t}\r\n\t\r\n    return AbstractParameterModel::headerData(section, orientation, role);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ModuleParameterModel::setData()\r\n//-----------------------------------------------------------------------------\r\nbool ModuleParameterModel::setData(QModelIndex const& index, QVariant const& value, int role)\r\n{\r\n\tif (!index.isValid() || index.row() < 0 || index.row() >= rowCount() || editingDisabled_)\r\n    {\r\n\t\treturn false;\r\n    }\r\n\r\n\tif (role == Qt::EditRole)\r\n    {\r\n        std::string parameterName = getInterface()->getIndexedItemName(index.row());\r\n\r\n        if (index.column() == ModuleParameterColumns::DATA_TYPE ||\r\n            index.column() == ModuleParameterColumns::USAGE_TYPE)\r\n        {\r\n            ModuleParameterInterface* moduleInterface = dynamic_cast<ModuleParameterInterface*>(getInterface());\r\n\r\n            if (moduleInterface)\r\n            {\r\n                if (index.column() == ModuleParameterColumns::DATA_TYPE)\r\n                {\r\n                    moduleInterface->setDataType(parameterName, value.toString().toStdString());\r\n                }\r\n                else if (index.column() == ModuleParameterColumns::USAGE_TYPE)\r\n                {\r\n                    moduleInterface->setUsageType(parameterName, value.toString().toStdString());\r\n                }\r\n\r\n                emit dataChanged(index, index);\r\n                return true;\r\n            }\r\n        }\r\n        else\r\n        {\r\n            return AbstractParameterModel::setData(index, value, role);\r\n        }\r\n\t}\r\n    \r\n    return false;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ModuleParameterModel::flags()\r\n//-----------------------------------------------------------------------------\r\nQt::ItemFlags ModuleParameterModel::flags(QModelIndex const& index) const\r\n{\r\n    if (!index.isValid())\r\n    {\r\n        return Qt::NoItemFlags;\r\n    }\r\n\r\n    if (editingDisabled_)\r\n    {\r\n        return Qt::ItemIsSelectable | Qt::ItemIsEnabled;\r\n    }\r\n\r\n    return AbstractParameterModel::flags(index);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ModuleParameterModel::onAddItem()\r\n//-----------------------------------------------------------------------------\r\nvoid ModuleParameterModel::onAddItem(QModelIndex const& index)\r\n{\r\n    if (editingDisabled_)\r\n    {\r\n        return;\r\n    }\r\n\r\n    int row = rowCount();\r\n\r\n    // if the index is valid then add the item to the correct position\r\n    if (index.isValid())\r\n    {\r\n        row = index.row();\r\n    }\r\n\r\n    ModuleParameterInterface* moduleInterface = dynamic_cast<ModuleParameterInterface*>(getInterface());\r\n    if (moduleInterface)\r\n    {\r\n        beginInsertRows(QModelIndex(), row, row);\r\n        moduleInterface->addModuleParameter(row);\r\n        endInsertRows();\r\n    }\r\n\r\n    // tell also parent widget that contents have been changed\r\n    emit contentChanged();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ModuleParameterModel::onRemoveItem()\r\n//-----------------------------------------------------------------------------\r\nvoid ModuleParameterModel::onRemoveItem(QModelIndex const& index)\r\n{\r\n    int indexRow = index.row();\r\n\r\n\t// don't remove anything if index is invalid\r\n    if (!index.isValid() || indexRow < 0 || indexRow >= rowCount() || editingDisabled_)\r\n    {\r\n\t\treturn;\r\n\t}\r\n\r\n    if (canRemoveRow(indexRow))\r\n    {\r\n        ModuleParameterInterface* moduleInterface = dynamic_cast<ModuleParameterInterface*>(getInterface());\r\n        if (moduleInterface)\r\n        {\r\n            std::string parameterName = getInterface()->getIndexedItemName(indexRow);\r\n\r\n            // remove the specified item\r\n            beginRemoveRows(QModelIndex(), indexRow, indexRow);\r\n            moduleInterface->removeModuleParameter(parameterName);\r\n            endRemoveRows();\r\n\r\n            // tell also parent widget that contents have been changed\r\n            emit contentChanged();\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ModuleParameterModel::nameColumn()\r\n//-----------------------------------------------------------------------------\r\nint ModuleParameterModel::nameColumn() const\r\n{\r\n    return ModuleParameterColumns::NAME;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ModuleParameterModel::displayNameColumn()\r\n//-----------------------------------------------------------------------------\r\nint ModuleParameterModel::displayNameColumn() const\r\n{\r\n    return ModuleParameterColumns::DISPLAY_NAME;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ModuleParameterModel::formatColumn()\r\n//-----------------------------------------------------------------------------\r\nint ModuleParameterModel::typeColumn() const\r\n{\r\n    return ModuleParameterColumns::TYPE;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ModuleParameterModel::bitWidthLeftColumn()\r\n//-----------------------------------------------------------------------------\r\nint ModuleParameterModel::bitWidthLeftColumn() const\r\n{\r\n    return ModuleParameterColumns::BITWIDTH_LEFT;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ModuleParameterModel::bitWidthRightColumn()\r\n//-----------------------------------------------------------------------------\r\nint ModuleParameterModel::bitWidthRightColumn() const\r\n{\r\n    return ModuleParameterColumns::BITWIDTH_RIGHT;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ModuleParameterModel::minimumColumn()\r\n//-----------------------------------------------------------------------------\r\nint ModuleParameterModel::minimumColumn() const\r\n{\r\n    return ModuleParameterColumns::MINIMUM;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ModuleParameterModel::maximumColumn()\r\n//-----------------------------------------------------------------------------\r\nint ModuleParameterModel::maximumColumn() const\r\n{\r\n    return ModuleParameterColumns::MAXIMUM;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ModuleParameterModel::choiceColumn()\r\n//-----------------------------------------------------------------------------\r\nint ModuleParameterModel::choiceColumn() const\r\n{\r\n    return ModuleParameterColumns::CHOICE;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ModuleParameterModel::valueColumn()\r\n//-----------------------------------------------------------------------------\r\nint ModuleParameterModel::valueColumn() const\r\n{\r\n    return ModuleParameterColumns::VALUE;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ModuleParameterModel::resolveColumn()\r\n//-----------------------------------------------------------------------------\r\nint ModuleParameterModel::resolveColumn() const\r\n{\r\n    return ModuleParameterColumns::RESOLVE;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ModuleParameterModel::arrayLeftColumn()\r\n//-----------------------------------------------------------------------------\r\nint ModuleParameterModel::arrayLeftColumn() const\r\n{\r\n    return ModuleParameterColumns::ARRAY_LEFT;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ModuleParameterModel::arrayRightColumn()\r\n//-----------------------------------------------------------------------------\r\nint ModuleParameterModel::arrayRightColumn() const\r\n{\r\n    return ModuleParameterColumns::ARRAY_RIGHT;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ModuleParameterModel::descriptionColumn()\r\n//-----------------------------------------------------------------------------\r\nint ModuleParameterModel::descriptionColumn() const\r\n{\r\n    return ModuleParameterColumns::DESCRIPTION;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ModuleParameterModel::idColumn()\r\n//-----------------------------------------------------------------------------\r\nint ModuleParameterModel::idColumn() const\r\n{\r\n    return ModuleParameterColumns::ID;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ModuleParameterModel::usageCountColumn()\r\n//-----------------------------------------------------------------------------\r\nint ModuleParameterModel::usageCountColumn() const\r\n{\r\n    return ModuleParameterColumns::USAGE_COUNT;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ModuleParameterModel::resetModelItems()\r\n//-----------------------------------------------------------------------------\r\nvoid ModuleParameterModel::resetModelItems()\r\n{\r\n    beginResetModel();\r\n    endResetModel();\r\n\r\n    emit contentChanged();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ModuleParameterModel::enableEditing()\r\n//-----------------------------------------------------------------------------\r\nvoid ModuleParameterModel::enableEditing()\r\n{\r\n    editingDisabled_ = false;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ModuleParameterModel::disableEditing()\r\n//-----------------------------------------------------------------------------\r\nvoid ModuleParameterModel::disableEditing()\r\n{\r\n    editingDisabled_ = true;\r\n}\r\n"
  },
  {
    "path": "editors/ComponentEditor/instantiations/ModuleParameterModel.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ModuleParameterModel.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 29.3.2011\r\n//\r\n// Description:\r\n// This model can be used to edit and update a list of module parameters.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef MODULEPARAMETERMODEL_H\r\n#define MODULEPARAMETERMODEL_H\r\n\r\n#include <editors/ComponentEditor/common/AbstractParameterModel.h>\r\n#include <KactusAPI/include/ExpressionFormatter.h>\r\n#include <KactusAPI/include/ParameterFinder.h>\r\n#include <KactusAPI/include/ModuleParameterInterface.h>\r\n\r\n#include <QSharedPointer>\r\n#include <QString>\r\n\r\nclass Component;\r\nclass ExpressionParser;\r\nclass ModuleParameter;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! This model can be used to edit and update a list of module parameters.\r\n//-----------------------------------------------------------------------------\r\nclass ModuleParameterModel : public AbstractParameterModel\r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\r\n\t/*!\r\n     *  The constructor.\r\n\t *\r\n     *    @param [in] moduleParameterInterface    Interface for accessing module parameters.\r\n     *    @param [in] expressionParser            Expression parser for configurable elements.\r\n     *    @param [in] parameterFinder             The parameter finder.\r\n\t *    @param [in] parent                      The owner of this model.\r\n     */\r\n    ModuleParameterModel(ModuleParameterInterface* moduleParameterInterface,\r\n        QSharedPointer<ExpressionParser> expressionParser,\r\n        QSharedPointer<ParameterFinder> parameterFinder,\r\n        QObject *parent);\r\n\r\n\t/*!\r\n     *  The destructor.\r\n     */\r\n\tvirtual ~ModuleParameterModel() = default;\r\n\r\n\t/*!\r\n     *  Get the number of columns in the model\r\n\t *\r\n\t *    @param [in]  parent Model index of the parent of the item.\r\n\t *\r\n\t *    @return  Number of columns currently in the model.\r\n\t */\r\n\tvirtual int columnCount(const QModelIndex& parent = QModelIndex() ) const;\r\n\r\n\t/*!\r\n     *  Get the data for the specified item for specified role.\r\n\t *\r\n\t *    @param [in]  index  Identifies the item that's data is wanted.\r\n\t *    @param [in]  role   Specifies what kind of data is wanted.\r\n\t *\r\n\t *    @return  The data for the given index.\r\n\t */\r\n\tvirtual QVariant data(QModelIndex const& index, int role = Qt::DisplayRole) const;\r\n\r\n\t/*!\r\n     *  Get the data for the headers.\r\n\t *\r\n\t *    @param [in]  section        The column that's header is wanted.\r\n\t *    @param [in]  orientation    The orientation of the header data.\r\n\t *    @param [in]  role           Specified the type of data that is wanted.\r\n\t *\r\n\t *    @return  The header data for the given section.\r\n\t */\r\n\tvirtual QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole ) const;\r\n\r\n\t/*!\r\n     *  Get information on how specified item can be handled.\r\n\t *\r\n\t *    @param [in]  index Specifies the item that's flags are wanted.\r\n\t *\r\n\t *    @return  Qt::ItemFlags that define how object can be handled.\r\n\t */\r\n\tvirtual Qt::ItemFlags flags(QModelIndex const& index) const;\r\n\r\n\t/*!\r\n     *  Set the data for specified item.\r\n\t *\r\n\t *    @param [in]  index  Specifies the item that's data is modified\r\n\t *    @param [in]  value  The value to be set.\r\n\t *    @param [in]  role   The role that is trying to modify the data. Only Qt::EditRole is supported.\r\n\t *\r\n\t *    @return  True, if data was successfully set, otherwise false.\r\n\t */\r\n\tvirtual bool setData(QModelIndex const& index, const QVariant& value, int role = Qt::EditRole);\r\n\r\n    /*!\r\n     *  Reset the model.\r\n     */\r\n    void resetModelItems();\r\n\r\n    /*!\r\n     *  Enables the editing of module parameters in the model.\r\n     */\r\n    void enableEditing();\r\n\r\n    /*!\r\n     *  Disables the editing of module parameters in the model.\r\n     */\r\n    void disableEditing();\r\n\r\npublic slots:\r\n\r\n\t/*!\r\n     *  A new item should be added to given index.\r\n\t *\r\n\t *    @param [in]  index The position where new item should be added at.\r\n\t */\r\n\tvirtual void onAddItem(const QModelIndex& index);\r\n\r\n\t/*!\r\n     *  An item should be removed from the model.\r\n\t * \r\n\t *    @param [in]  index Identifies the item that should be removed.\r\n\t */\r\n\tvirtual void onRemoveItem(const QModelIndex& index);\r\n\r\nprotected:\r\n\r\n    /*!\r\n     *  Gets the column for value format.\r\n     *\r\n     *    @return The column for editing format selection.\r\n     */\r\n    virtual int nameColumn() const;\r\n        \r\n    /*!\r\n     *  Gets the column for value format.\r\n     *\r\n     *    @return The column for editing format selection.\r\n     */\r\n    virtual int displayNameColumn() const;\r\n\r\n    /*!\r\n     *  Gets the column for value format.\r\n     *\r\n     *    @return The column for editing format selection.\r\n     */\r\n    virtual int typeColumn() const;\r\n\r\n    /*!\r\n     *  Gets the column for the left value of bit width vector.\r\n     *\r\n     *    @return The column for editing the left value of the bit width vector.\r\n     */\r\n    virtual int bitWidthLeftColumn() const;\r\n\r\n    /*!\r\n     *  Gets the column for the right value of bit width vector.\r\n     *\r\n     *    @return The column for editing the right value of the bit width vector.\r\n     */\r\n    virtual int bitWidthRightColumn() const;\r\n\r\n    /*!\r\n     *  Gets the column for minimum value.\r\n     *\r\n     *    @return The column for editing the minimum value.\r\n     */\r\n    virtual int minimumColumn() const;\r\n        \r\n    /*!\r\n     *  Gets the column for maximum value.\r\n     *\r\n     *    @return The column for editing the maximum value.\r\n     */\r\n    virtual int maximumColumn() const;\r\n        \r\n    /*!\r\n     *  Gets the column for choices.\r\n     *\r\n     *    @return The column for editing choice selection.\r\n     */\r\n    virtual int choiceColumn() const;\r\n\r\n    /*!\r\n     *  Gets the column for values.\r\n     *\r\n     *    @return The column for editing value selection.\r\n     */\r\n    virtual int valueColumn() const;\r\n    \r\n    /*!\r\n     *  Gets the column for resolve.\r\n     *\r\n     *    @return The column for editing value selection.\r\n     */\r\n    virtual int resolveColumn() const;\r\n    \r\n    /*!\r\n     *  Gets the column for array left.\r\n     *\r\n     *    @return The column for editing array left.\r\n     */\r\n    virtual int arrayLeftColumn() const;\r\n\r\n    /*!\r\n     *  Gets the column for array right.\r\n     *\r\n     *    @return The column for editing array right.\r\n     */\r\n    virtual int arrayRightColumn() const;\r\n\r\n    /*!\r\n     *  Gets the column for description.\r\n     *\r\n     *    @return The column for editing description.\r\n     */\r\n    virtual int descriptionColumn() const;\r\n\r\n    /*!\r\n     *  Gets the column index for model parameter id.\r\n     *\r\n     *    @return     The column index for the model parameter id.\r\n     */\r\n    virtual int idColumn() const;\r\n\r\n    /*!\r\n     *  Gets the column index for usage count.\r\n     *\r\n     *    @return     The column index for usage count.\r\n     */\r\n    virtual int usageCountColumn() const;\r\n\r\nprivate:\r\n\r\n\t//! No copying.\r\n\tModuleParameterModel(const ModuleParameterModel& other);\r\n\r\n\t//! No assignment.\r\n\tModuleParameterModel& operator=(const ModuleParameterModel& other);\r\n    \r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! Disable for editing of module parameters.\r\n    bool editingDisabled_;\r\n};\r\n\r\n#endif // MODULEPARAMETERMODEL_H\r\n"
  },
  {
    "path": "editors/ComponentEditor/instantiations/filesetrefeditor.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: filesetrefeditor.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 15.4.2011\r\n//\r\n// Description:\r\n// Editor to set the file set references of a view.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"filesetrefeditor.h\"\r\n\r\n#include \"filesetrefeditordelegate.h\"\r\n#include \"filesetrefmodel.h\"\r\n\r\n#include <IPXACTmodels/Component/Component.h>\r\n\r\n#include <QHBoxLayout>\r\n#include <QLayout>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: filesetrefeditor::FileSetRefEditor()\r\n//-----------------------------------------------------------------------------\r\nFileSetRefEditor::FileSetRefEditor(FileSetInterface* fileSetInterface, const QString title, QWidget *parent):\r\nListManager(title, parent),\r\nfileSetInterface_(fileSetInterface)\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: filesetrefeditor::~FileSetRefEditor()\r\n//-----------------------------------------------------------------------------\r\nFileSetRefEditor::~FileSetRefEditor()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: filesetrefeditor::initialize()\r\n//-----------------------------------------------------------------------------\r\nvoid FileSetRefEditor::initialize( QStringList const& items)\r\n{\r\n\t// remove the previous model and view if there are one\r\n\tif (model_)\r\n    {\r\n\t\tdelete model_;\r\n\t\tmodel_ = 0;\r\n\t}\r\n\tif (view_)\r\n    {\r\n\t\tdelete view_;\r\n\t\tview_ = 0;\r\n\t}\r\n\r\n\t// create new model and view\r\n    model_ = new FileSetRefModel(this, fileSetInterface_, items);\r\n\r\n\tview_ = new EditableListView(this);\r\n\r\n\t// the signals from the view\r\n\tconnect(view_, SIGNAL(removeItem(const QModelIndex&)),\r\n        model_, SLOT(remove(const QModelIndex&)), Qt::UniqueConnection);\r\n\r\n\tconnect(view_, SIGNAL(addItem(const QModelIndex&)),\r\n\t\tmodel_, SLOT(addItem(const QModelIndex&)), Qt::UniqueConnection);\r\n\r\n\tconnect(view_, SIGNAL(moveItem(const QModelIndex&, const QModelIndex&)),\r\n\t\tmodel_, SLOT(moveItem(const QModelIndex&, const QModelIndex&)), Qt::UniqueConnection);\r\n\r\n\t// the signals from the model\r\n\tconnect(model_, SIGNAL(contentChanged()), this, SIGNAL(contentChanged()), Qt::UniqueConnection);\r\n\r\n\tconnect(model_, SIGNAL(dataChanged(const QModelIndex&, const QModelIndex&)),\r\n\t\tthis, SIGNAL(contentChanged()), Qt::UniqueConnection);\r\n\r\n\tQLayout* topLayout = layout();\r\n\tif (!topLayout)\r\n    {\r\n\t\ttopLayout = new QHBoxLayout(this);\r\n\t}\r\n\r\n\t// add the view on the left side\r\n\ttopLayout->addWidget(view_);\r\n\r\n\tview_->setModel(model_);\r\n    view_->setItemDelegate(new FileSetRefEditorDelegate(this, fileSetInterface_));\r\n}\r\n"
  },
  {
    "path": "editors/ComponentEditor/instantiations/filesetrefeditor.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: filesetrefeditor.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 15.4.2011\r\n//\r\n// Description:\r\n// Editor to set the file set references of a view.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef FILESETREFEDITOR_H\r\n#define FILESETREFEDITOR_H\r\n\r\n#include <common/widgets/listManager/listmanager.h>\r\n\r\n#include <QSharedPointer>\r\n\r\nclass Component;\r\nclass FileSetInterface;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Editor to set the file set references of a view.\r\n//-----------------------------------------------------------------------------\r\nclass FileSetRefEditor : public ListManager\r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\r\n\t/*!\r\n     *  The constructor.\r\n\t *\r\n\t *    @param [in] fileSetInterface    Interface for accessing file sets.\r\n\t *    @param [in] title               Title for the QGroupBox.\r\n\t *    @param [in] parent              The owner of this editor.\r\n\t */\r\n    FileSetRefEditor(FileSetInterface* fileSetInterface, const QString title = tr(\"List\"), QWidget *parent = 0);\r\n\r\n\t/*!\r\n     *  The destructor.\r\n     */\r\n\tvirtual ~FileSetRefEditor();\r\n\r\n\t/*!\r\n     *  Initialize the file set reference editor.\r\n\t *\r\n\t *    @param [in] items   QStringList that contains the items to add to the widget.\r\n\t */\r\n\tvirtual void initialize(QStringList const& items = QStringList());\r\n\r\nprivate:\r\n\r\n\t//! No copying.\r\n\tFileSetRefEditor(const FileSetRefEditor& other);\r\n\r\n\t//! No assignment.\r\n\tFileSetRefEditor& operator=(const FileSetRefEditor& other);\r\n\r\n\t//! The component being edited.\r\n    FileSetInterface* fileSetInterface_;\r\n};\r\n\r\n#endif // FILESETREFEDITOR_H\r\n"
  },
  {
    "path": "editors/ComponentEditor/instantiations/filesetrefeditordelegate.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: filesetrefeditordelegate.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 09.12.2011\r\n//\r\n// Description:\r\n// Delegate that manages the editors to select a file set in a component.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"filesetrefeditordelegate.h\"\r\n\r\n#include <IPXACTmodels/Component/Component.h>\r\n\r\n#include <KactusAPI/include/FileSetInterface.h>\r\n\r\n#include <QComboBox>\r\n#include <QLineEdit>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: filesetrefeditordelegate::FileSetRefEditorDelegate()\r\n//-----------------------------------------------------------------------------\r\nFileSetRefEditorDelegate::FileSetRefEditorDelegate(QObject *parent, FileSetInterface* fileSetInterface):\r\nComboDelegate(parent),\r\nfileSetInterface_(fileSetInterface)\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: filesetrefeditordelegate::~FileSetRefEditorDelegate()\r\n//-----------------------------------------------------------------------------\r\nFileSetRefEditorDelegate::~FileSetRefEditorDelegate()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: filesetrefeditordelegate::createEditor()\r\n//-----------------------------------------------------------------------------\r\nQWidget* FileSetRefEditorDelegate::createEditor( QWidget* parent, const QStyleOptionViewItem& option,\r\n    const QModelIndex& index) const\r\n{\r\n\tQComboBox* combo = qobject_cast<QComboBox*>(ComboDelegate::createEditor(parent, option, index));\r\n\tQ_ASSERT(combo);\r\n\r\n    QStringList filesetNames;\r\n    for (auto setName : fileSetInterface_->getItemNames())\r\n    {\r\n        filesetNames.append(QString::fromStdString(setName));\r\n    }\r\n\r\n    combo->addItems(filesetNames);\r\n\treturn combo;\r\n}\r\n"
  },
  {
    "path": "editors/ComponentEditor/instantiations/filesetrefeditordelegate.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: filesetrefeditordelegate.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 09.12.2011\r\n//\r\n// Description:\r\n// Delegate that manages the editors to select a file set in a component.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef FILESETREFEDITORDELEGATE_H\r\n#define FILESETREFEDITORDELEGATE_H\r\n\r\n#include <common/delegates/ComboDelegate/combodelegate.h>\r\n\r\n#include <QSharedPointer>\r\n\r\nclass Component;\r\nclass FileSetInterface;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Delegate that manages the editors to select a file set in a component.\r\n//-----------------------------------------------------------------------------\r\nclass FileSetRefEditorDelegate : public ComboDelegate\r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\r\n\t/*!\r\n     *  The constructor.\r\n\t *\r\n\t *    @param [in] parent              The pointer to the owner of this delegate.\r\n\t *    @param [in] fileSetInterface    Interface for accessing file sets.\r\n\t */\r\n    FileSetRefEditorDelegate(QObject *parent, FileSetInterface* fileSetInterface);\r\n\r\n\t//! The destructor.\r\n\tvirtual ~FileSetRefEditorDelegate();\r\n\r\n\t/*!\r\n     *  Create a new editor for the given item.\r\n\t *\r\n\t *    @param [in] parent  Owner for the editor.\r\n\t *    @param [in] option  Contains options for the editor.\r\n\t *    @param [in] index   Model index identifying the item.\r\n\t *\r\n\t *    @return Pointer to the editor to be used to edit the item.\r\n\t */\r\n\tvirtual QWidget* createEditor(QWidget* parent, const QStyleOptionViewItem& option, const QModelIndex& index)\r\n        const;\r\n\r\nprivate:\r\n\r\n    //! No copying. No assignment.\r\n\tFileSetRefEditorDelegate(const FileSetRefEditorDelegate& other);\r\n\tFileSetRefEditorDelegate& operator=(const FileSetRefEditorDelegate& other);\r\n\r\n\t//! Interface for accessing file sets.\r\n    FileSetInterface* fileSetInterface_;\r\n};\r\n\r\n#endif // FILESETREFEDITORDELEGATE_H\r\n"
  },
  {
    "path": "editors/ComponentEditor/instantiations/filesetrefmodel.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: filesetrefmodel.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 07.02.2012\r\n//\r\n// Description:\r\n// Model class to manage a list of file set references.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"filesetrefmodel.h\"\r\n\r\n#include <IPXACTmodels/Component/Component.h>\r\n\r\n#include <common/KactusColors.h>\r\n\r\n#include <KactusAPI/include/FileSetInterface.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: filesetrefmodel::FileSetRefModel()\r\n//-----------------------------------------------------------------------------\r\nFileSetRefModel::FileSetRefModel(QObject *parent, FileSetInterface* fileSetInterface, const QStringList& items):\r\nListManagerModel(items, parent),\r\nfileSetInterface_(fileSetInterface)\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: filesetrefmodel::~FileSetRefModel()\r\n//-----------------------------------------------------------------------------\r\nFileSetRefModel::~FileSetRefModel()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: filesetrefmodel::data()\r\n//-----------------------------------------------------------------------------\r\nQVariant FileSetRefModel::data( const QModelIndex& index, int role /*= Qt::DisplayRole*/ ) const\r\n{\r\n    // nothing for invalid indexes\r\n    if (!index.isValid())\r\n    {\r\n        return QVariant();\r\n    }\r\n\r\n    // if there are no real items then display the help text\r\n    else if (index.row() == 0 && items_.isEmpty())\r\n    {\r\n        if (role == Qt::DisplayRole)\r\n        {\r\n            return tr(\"Double click to add new item.\");\r\n        }\r\n        else if (role == Qt::ForegroundRole)\r\n        {\r\n            return KactusColors::DISABLED_TEXT;\r\n        }\r\n        else\r\n        {\r\n            return QVariant();\r\n        }\r\n    }\r\n\r\n    // if index.row() is invalid\r\n    else if (index.row() < 0 || index.row() >= items_.size())\r\n    {\r\n        return QVariant();\r\n    }\r\n\r\n    // return data for display role\r\n    if (role == Qt::DisplayRole)\r\n    {\r\n        return items_.at(index.row());\r\n    }\r\n    else if (role == Qt::ForegroundRole)\r\n    {\r\n        // if component contains the named file set.\r\n        if (fileSetInterface_->fileSetExists(items_.at(index.row()).toStdString()))\r\n        {\r\n            return KactusColors::REGULAR_TEXT;\r\n        }\r\n\r\n        // if the file set does not exist.\r\n        else\r\n        {\r\n            return KactusColors::ERROR;\r\n        }\r\n    }\r\n    // if unsupported role\r\n    else\r\n    {\r\n        return QVariant();\r\n    }\r\n}\r\n"
  },
  {
    "path": "editors/ComponentEditor/instantiations/filesetrefmodel.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: filesetrefmodel.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 07.02.2012\r\n//\r\n// Description:\r\n// Model class to manage a list of file set references.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef FILESETREFMODEL_H\r\n#define FILESETREFMODEL_H\r\n\r\n#include <common/widgets/listManager/listmanagermodel.h>\r\n\r\n#include <QSharedPointer>\r\n\r\nclass FileSetInterface;\r\nclass Component;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Model class to manage a list of file set references.\r\n//-----------------------------------------------------------------------------\r\nclass FileSetRefModel : public ListManagerModel\r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\r\n\t/*!\r\n     *  The constructor.\r\n\t *\r\n\t *    @param [in] parent              Pointer to the owner of this model.\r\n\t *    @param [in] fileSetInterface    Interface for accessing file sets.\r\n\t *    @param [in] items               QStringList that contains the items to add.\r\n\t */\r\n    FileSetRefModel(QObject *parent, FileSetInterface* fileSetInterface, const QStringList& items = QStringList());\r\n\r\n\t/*!\r\n     *  The destructor.\r\n     */\r\n\tvirtual ~FileSetRefModel();\r\n\r\n\t/*!\r\n     *  Get the data stored for the specified item.\r\n\t *\r\n\t *    @param [in] index   ModelIndex of the wanted item.\r\n\t *    @param [in] role    Specifies what kind of data is requested.\r\n\t */\r\n\tvirtual QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const;\r\n\r\nprivate:\r\n\r\n    //! No copying. //! No assignment.\r\n\tFileSetRefModel(const FileSetRefModel& other);\r\n\tFileSetRefModel& operator=(const FileSetRefModel& other);\r\n\r\n    //! Interface for accessing file sets.\r\n    FileSetInterface* fileSetInterface_;\r\n};\r\n\r\n#endif // FILESETREFMODEL_H\r\n"
  },
  {
    "path": "editors/ComponentEditor/itemeditor.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: itemeditor.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 02.02.2011\r\n//\r\n// Description:\r\n// ItemEditor is a base class for editors in Component Editor module..\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"itemeditor.h\"\r\n\r\n#include <IPXACTmodels/Component/Component.h>\r\n\r\n#include <KactusAPI/include/LibraryInterface.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: itemeditor::ItemEditor()\r\n//-----------------------------------------------------------------------------\r\nItemEditor::ItemEditor( QSharedPointer<Component> component, LibraryInterface* handler, QWidget *parent): \r\nQWidget(parent), \r\ncomponent_(component),\r\nhandler_(handler)\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: itemeditor::~ItemEditor()\r\n//-----------------------------------------------------------------------------\r\nItemEditor::~ItemEditor()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: itemeditor::component()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<Component> ItemEditor::component() const\r\n{\r\n    return component_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: confirmEditorChange()\r\n//-----------------------------------------------------------------------------\r\nbool ItemEditor::confirmEditorChange()\r\n{\r\n    // By default, we always allow the editor to be changed.\r\n    return true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ItemEditor::setProtection()\r\n//-----------------------------------------------------------------------------\r\nvoid ItemEditor::setProtection(bool locked)\r\n{\r\n    setDisabled(locked);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: itemeditor::handler()\r\n//-----------------------------------------------------------------------------\r\nLibraryInterface* ItemEditor::handler() const\r\n{\r\n    return handler_;\r\n}\r\n"
  },
  {
    "path": "editors/ComponentEditor/itemeditor.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: itemeditor.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 02.02.2011\r\n//\r\n// Description:\r\n// ItemEditor is a base class for editors in Component Editor module..\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef ITEMEDITOR_H\r\n#define ITEMEDITOR_H\r\n\r\n#include <QWidget>\r\n\r\nclass LibraryInterface;\r\nclass Component;\r\nclass Extendable;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! ItemEditor is a base class for editors in Component Editor module..\r\n// \r\n// This class should be used as a base class when implementing an element-specific editor.\r\n// This base class provides means to communicate with ComponentTreeNavigator.\r\n//-----------------------------------------------------------------------------\r\nclass ItemEditor : public QWidget\r\n{\r\n    Q_OBJECT\r\n\r\npublic:\r\n\r\n    /*!\r\n     *  The constructor.\r\n     *\r\n     *    @param [in] component   Pointer to the component instance that is being edited.\r\n     *    @param [in] handler     Pointer to the instance that manages the library.\r\n     *    @param [in] parent      Pointer to the owner of this widget.\r\n     */\r\n    ItemEditor(QSharedPointer<Component> component, LibraryInterface* handler, QWidget *parent = 0);\r\n\r\n    //! The destructor.\r\n    virtual ~ItemEditor();\r\n\r\n    /*!\r\n     *  Allows/disallows the editor change.\r\n     *\r\n     *    @return True, if this editor can be hidden without consequences. Otherwise false.\r\n     */\r\n    virtual bool confirmEditorChange();\r\n\r\n    /*!\r\n     *  Reload the information from the model to the editor.\r\n     */\r\n    virtual void refresh() = 0;\r\n\r\n    /*!\r\n     *  Sets the protection state of the editor.\r\n     *\r\n     *  The base class implementation enables/disables the editor widget. Override to e.g. enable/disable\r\n     *  individual editor tabs.\r\n     *\r\n     *    @param [in] locked  True for locked state; false for unlocked.\r\n     */\r\n    virtual void setProtection(bool locked);\r\n\r\n    //! No copying. No Assignment.\r\n    ItemEditor(const ItemEditor& other) = delete;\r\n    ItemEditor& operator=(const ItemEditor& other) = delete;\r\n\r\n\r\nsignals:\r\n\r\n    /*!\r\n     *  Emitted when the contents of the widget change.\r\n      *\r\n     *    @param [in] change  This is set just for convenience so this signal can be connected directly to\r\n     *                          a widget to set it enabled. This should always be set to true.\r\n     */\r\n    void contentChanged();\r\n\r\n    /*!\r\n     *  Informs of the necessity to redraw the visualizer.\r\n     */\r\n    void graphicsChanged();\r\n\r\n    //! Prints an error message to the user.\r\n    void errorMessage(const QString& msg) const;\r\n\r\n    //! Prints a notification to the user.\r\n    void noticeMessage(const QString& msg) const;\r\n\r\n    //! Emitted when a help page should be changed in the context help window.\r\n    void helpUrlRequested(QString const& url);\r\n\r\n    /*! \r\n     *  Emitted when the editor adds a new item that should be shown in navigation tree.\r\n     *\r\n     *    @param [in] index   The index of the added item.\r\n     */\r\n    void childAdded(int index);\r\n\r\n    /*!\r\n     *  Emitted when the editor removes a child that should also be removed from navigation tree.\r\n     *\r\n     *    @param [in] index   The index of the removed item.\r\n     */\r\n    void childRemoved(int index);\r\n\r\n    /*!\r\n     *  Emitted when the editor moves child from one position to another.\r\n     *\r\n     *    @param [in] source  The index of the moved item.\r\n     *    @param [in] target  The index to move the child to.\r\n     */\r\n    void childMoved(int source, int target);\r\n\r\n    /*!\r\n     *  Increase the amount of references to a parameter with a matching id.\r\n     *\r\n     *    @param [in] id      Id of the parameter, whose references are being increased.\r\n     */\r\n    void increaseReferences(QString id);\r\n\r\n    /*!\r\n     *  Decrease the amount of references to a parameter with a matching id.\r\n     *\r\n     *    @param [in] id      Id of the parameter, whose references are being increased.\r\n     */\r\n    void decreaseReferences(QString id);\r\n\r\n    /*!\r\n     *  Change the vendor extensions of the vendor extensions editor.\r\n     *\r\n     *    @param [in] containingID    ID for the vendor extensions editor.\r\n     *    @param [in] extensionItem   The item containing the selected vendor extensions.\r\n     */\r\n    void changeVendorExtensions(QString const& containingID, QSharedPointer<Extendable> extensionItem);\r\n\r\nprotected:\r\n\r\n    /*!\r\n     *  Get the the component pointer from the base-class.\r\n     *\r\n     *    @return Pointer to the component model that is being edited\r\n     */\r\n    QSharedPointer<Component> component() const;\r\n\r\n\r\n    /*!\r\n     *  Get pointer to the instance managing the library.\r\n     *\r\n     *    @return Pointer to the instance managing the library.\r\n     */\r\n    LibraryInterface* handler() const;\r\n\r\nprivate:\r\n\r\n    //! A pointer to the component that's element is being edited.\r\n    QSharedPointer<Component> component_;\r\n\r\n    //! Pointer to the instance that manages the library.\r\n    LibraryInterface* handler_;\r\n    \r\n};\r\n\r\n#endif // ITEMEDITOR_H\r\n"
  },
  {
    "path": "editors/ComponentEditor/itemvisualizer.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: itemvisualizer.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 22.05.2012\r\n//\r\n// Description:\r\n// The base class for all IP-Xact visualizer classes.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"itemvisualizer.h\"\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: itemvisualizer::ItemVisualizer()\r\n//-----------------------------------------------------------------------------\r\nItemVisualizer::ItemVisualizer(QWidget *parent):\r\nQWidget(parent) \r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: itemvisualizer::~ItemVisualizer()\r\n//-----------------------------------------------------------------------------\r\nItemVisualizer::~ItemVisualizer()\r\n{\r\n\r\n}\r\n"
  },
  {
    "path": "editors/ComponentEditor/itemvisualizer.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: itemvisualizer.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 22.05.2012\r\n//\r\n// Description:\r\n// The base class for all IP-Xact visualizer classes.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef ITEMVISUALIZER_H\r\n#define ITEMVISUALIZER_H\r\n\r\n#include <QWidget>\r\n#include <QSharedPointer>\r\n\r\n//-----------------------------------------------------------------------------\r\n//! The base class for all IP-Xact visualizer classes.\r\n//-----------------------------------------------------------------------------\r\nclass ItemVisualizer : public QWidget\r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\r\n\t/*! The constructor\r\n\t *\r\n\t *    @param [in] parent  The parent widget of the visualizer. \r\n\t*/\r\n\tItemVisualizer(QWidget* parent = 0);\r\n\t\r\n\t//! The destructor\r\n\tvirtual ~ItemVisualizer();\r\n\r\nsignals:\r\n\r\n    //! Emitted when the visualizer is shown.\r\n    void displayed();\r\n\r\nprivate:\r\n\t//! No copying. No assignment. No regret.\r\n\tItemVisualizer(const ItemVisualizer& other);\r\n\tItemVisualizer& operator=(const ItemVisualizer& other);\r\n};\r\n\r\n#endif // ITEMVISUALIZER_H\r\n"
  },
  {
    "path": "editors/ComponentEditor/memoryMaps/AccessPoliciesDelegate.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: AccessPoliciesDelegate.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Anton Hagqvist\n// Date: 28.8.2023\n//\n// Description:\n// Provides editors for access policies.\n//-----------------------------------------------------------------------------\n\n#include \"AccessPoliciesDelegate.h\"\n#include \"FieldAccessPolicyColumns.h\"\n\n#include <common/widgets/accessComboBox/accesscombobox.h>\n\n#include <editors/ComponentEditor/common/FloatingModeReferenceEditor.h>\n\n#include <KactusAPI/include/ModeReferenceInterface.h>\n\n#include <IPXACTmodels/Component/ModeReference.h>\n\nusing ModeRefsList = std::vector<std::pair<unsigned int, std::string> >;\n\n//-----------------------------------------------------------------------------\n// Function: AccessPoliciesDelegate::AccessPoliciesDelegate()\n//-----------------------------------------------------------------------------\nAccessPoliciesDelegate::AccessPoliciesDelegate(ModeReferenceInterface* modeReferenceInterface, QWidget* parent) :\n    QStyledItemDelegate(parent),\n    modeRefInterface_(modeReferenceInterface)\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: AccessPoliciesDelegate::createEditor()\n//-----------------------------------------------------------------------------\nQWidget* AccessPoliciesDelegate::createEditor(QWidget* parent, const QStyleOptionViewItem& option, const QModelIndex& index) const\n{\n    if (index.column() == 0)\n    {\n        // Update the mode reference interface with the mode references of the currently selected access policy\n        // by copying mode references over to interface to be able to abort editing in floating mode ref editor.\n        auto modeReferencesVariant = index.data(Qt::UserRole);\n\n        auto [currentModeRefs, otherModeRefsInUse] =\n            modeReferencesVariant.value<QPair<ModeRefsList, ModeRefsList> >();\n\n        // Set the mode references of the currently selected access policy to the mode reference interface.\n        modeRefInterface_->setModeReferences(currentModeRefs);\n\n        // Set the othcer mode references in use for validation purposes.\n        modeRefInterface_->setContainingElementModeReferences(otherModeRefsInUse);\n\n        modeRefInterface_->setContainingElementIsRemap(false);\n\n        FloatingModeReferenceEditor* modeRefEditor = new FloatingModeReferenceEditor(modeRefInterface_, parent);\n\n        connect(modeRefEditor, SIGNAL(finishEditing()), this, SLOT(commitAndCloseEditor()), Qt::UniqueConnection);\n        connect(modeRefEditor, SIGNAL(cancelEditing()), this, SLOT(onEditingCanceled()), Qt::UniqueConnection);\n        return modeRefEditor;\n    }\n    else if (index.column() == 1)\n    {\n        AccessComboBox* accessEditor = new AccessComboBox(parent);\n\n        connect(accessEditor, SIGNAL(destroyed()), this, SLOT(commitAndCloseEditor()), Qt::UniqueConnection);\n        return accessEditor;\n    }\n    else\n    {\n        return QStyledItemDelegate::createEditor(parent, option, index);\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: AccessPoliciesDelegate::setEditorData()\n//-----------------------------------------------------------------------------\nvoid AccessPoliciesDelegate::setEditorData(QWidget* editor, const QModelIndex& index) const\n{\n    if (index.column() == 1)\n    {\n        auto castEditor = qobject_cast<AccessComboBox*>(editor);\n\n        if (castEditor)\n        {\n            castEditor->setCurrentValue(AccessTypes::str2Access(\n                index.data(Qt::DisplayRole).toString(), AccessTypes::ACCESS_COUNT));\n        }\n    }\n    else\n    {\n        QStyledItemDelegate::setEditorData(editor, index);\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: AccessPoliciesDelegate::setModelData()\n//-----------------------------------------------------------------------------\nvoid AccessPoliciesDelegate::setModelData(QWidget* editor, QAbstractItemModel* model, const QModelIndex& index) const\n{\n    if (index.column() == 0)\n    {\n        // Get the modified mode references from interface and send to access policy.\n        auto updatedModeRefs = modeRefInterface_->getModeReferences();\n\n        QVariant modeRefsVariant = QVariant::fromValue(updatedModeRefs);\n        model->setData(index, modeRefsVariant);\n    }\n\n    else if (index.column() == 1)\n    {\n        auto accessEditor = qobject_cast<AccessComboBox*>(editor);\n\n        if (accessEditor)\n        {\n            model->setData(index, accessEditor->currentText(), Qt::EditRole);\n        }\n    }\n    else\n    {\n        QStyledItemDelegate::setModelData(editor, model, index);\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: AccessPoliciesDelegate::updateEditorGeometry()\n//-----------------------------------------------------------------------------\nvoid AccessPoliciesDelegate::updateEditorGeometry(QWidget* editor, const QStyleOptionViewItem& option, const QModelIndex& index) const\n{\n    if (index.column() == 0)\n    {\n        auto modeRefEditor = qobject_cast<FloatingModeReferenceEditor*>(editor);\n        int editorMinimumHeight = modeRefEditor->sizeHint().height();\n\n        auto modeRefTableMargins = modeRefEditor->getTableMargins();\n\n        int editorWidth = modeRefEditor->getTableSizeHint().width() + modeRefTableMargins.left()\n            + modeRefTableMargins.right() + 2;\n\n        if (editorWidth < 250)\n        {\n            editorWidth = 250;\n        }\n        else if (editorWidth > 300)\n        {\n            editorWidth = 300;\n        }\n\n        if (editorMinimumHeight < 250)\n        {\n            editorMinimumHeight = 250;\n        }\n\n        editor->setFixedWidth(editorWidth);\n\n        const int PARENT_HEIGHT = editor->parentWidget()->height();\n        const int AVAILABLE_HEIGHT_BELOW = PARENT_HEIGHT - option.rect.top();\n\n        if (AVAILABLE_HEIGHT_BELOW > editorMinimumHeight)\n        {\n            editor->move(option.rect.topLeft());\n        }\n        else\n        {\n            int editorNewY = PARENT_HEIGHT - editorMinimumHeight;\n            if (editorNewY <= 0)\n            {\n                editorNewY = 0;\n            }\n\n            editor->move(option.rect.left(), editorNewY);\n        }\n\n        if (editorMinimumHeight > PARENT_HEIGHT)\n        {\n            editor->setFixedHeight(PARENT_HEIGHT);\n        }\n        else\n        {\n            editor->setFixedHeight(editorMinimumHeight);\n        }\n    }\n    else\n    {\n        QStyledItemDelegate::updateEditorGeometry(editor, option, index);\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: AccessPoliciesDelegate::commitAndCloseEditor()\n//-----------------------------------------------------------------------------\nvoid AccessPoliciesDelegate::commitAndCloseEditor()\n{\n    auto editor = qobject_cast<QWidget*>(sender());\n\n    if (editor)\n    {\n        emit commitData(editor);\n        emit closeEditor(editor);\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: AccessPoliciesDelegate::onEditingCanceled()\n//-----------------------------------------------------------------------------\nvoid AccessPoliciesDelegate::onEditingCanceled()\n{\n    auto editor = qobject_cast<QWidget*>(sender());\n    if (editor)\n    {\n        emit closeEditor(editor);\n    }\n}\n"
  },
  {
    "path": "editors/ComponentEditor/memoryMaps/AccessPoliciesDelegate.h",
    "content": "//-----------------------------------------------------------------------------\n// File: AccessPoliciesDelegate.h\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Anton Hagqvist\n// Date: 28.8.2023\n//\n// Description:\n// Provides editors for access policies.\n//-----------------------------------------------------------------------------\n\n#ifndef ACCESSPOLICIESDELEGATE_H\n#define ACCESSPOLICIESDELEGATE_H\n\n#include <QStyledItemDelegate>\n\nclass ModeReferenceInterface;\n\nclass AccessPoliciesDelegate : public QStyledItemDelegate\n{\n    Q_OBJECT\n\npublic:\n\n    AccessPoliciesDelegate(ModeReferenceInterface* modeReferenceInterface, QWidget* parent);\n\n    AccessPoliciesDelegate(AccessPoliciesDelegate const& other) = delete;\n    AccessPoliciesDelegate& operator=(AccessPoliciesDelegate const& other) = delete;\n\n    /*!\n     *  Create a new editor for the given item\n     *\n     *    @param [in] parent  Owner for the editor.\n     *    @param [in] option  Contains options for the editor.\n     *    @param [in] index   Model index identifying the item.\n     *\n     *    @return The editor to be used to edit the item.\n     */\n    virtual QWidget* createEditor(QWidget* parent, const QStyleOptionViewItem& option, const QModelIndex& index) const override;\n\n    /*!\n     *  Set the data for the editor.\n     *\n     *    @param [in] editor  The editor where the data is to be set.\n     *    @param [in] index   Model index identifying the item that's data is to be set.\n     */\n    virtual void setEditorData(QWidget* editor, const QModelIndex& index) const override;\n\n    /*!\n     *  Save the data from the editor to the model.\n     *\n     *    @param [in] editor The editor that contains the data to store.\n     *    @param [in] model  Model that contains the data structure where data is to be saved to.\n     *    @param [in] index  Model index identifying the item that's data is to be saved.\n     */\n    virtual void setModelData(QWidget* editor, QAbstractItemModel* model, const QModelIndex& index) const override;\n\n    /*!\n     *  Updates the editor geometry for a given index.\n     *\n     *    @param [in] editor  The editor being updated.\n     *    @param [in] option  The options used to update the editor.\n     *    @param [in] index   The model index being edited.\n     */\n    virtual void updateEditorGeometry(QWidget* editor, const QStyleOptionViewItem& option, const QModelIndex& index) const override;\n\nprivate slots:\n\n    /*!\n     *  Commit the data from the sending editor and close the editor.\n     */\n    void commitAndCloseEditor();\n\n    /*!\n     *  Handle canceling editing.\n     */\n    void onEditingCanceled();\n\nprivate:\n    \n    //! Mode reference interface to pass onto mode ref editor.\n    ModeReferenceInterface* modeRefInterface_;\n    \n};\n\n#endif // ACCESSPOLICIESDELEGATE_H\n\n\n\n"
  },
  {
    "path": "editors/ComponentEditor/memoryMaps/AccessPoliciesEditor.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: AccessPoliciesEditor.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Anton Hagqvist\n// Date: 28.8.2023\n//\n// Description:\n// Editor for access policies found in address blocks, registers, register files etc.\n//-----------------------------------------------------------------------------\n\n#include \"AccessPoliciesEditor.h\"\n#include \"AccessPoliciesDelegate.h\"\n#include \"AccessPoliciesModel.h\"\n\n#include <KactusAPI/include/AccessPolicyInterface.h>\n\n#include <IPXACTmodels/Component/AccessPolicy.h>\n\n#include <common/views/EditableTableView/editabletableview.h>\n\n#include <QVBoxLayout>\n#include <QSortFilterProxyModel>\n\n//-----------------------------------------------------------------------------\n// Function: AccessPoliciesEditor::AccessPoliciesEditor()\n//-----------------------------------------------------------------------------\nAccessPoliciesEditor::AccessPoliciesEditor(QSharedPointer<QList<QSharedPointer<AccessPolicy> > > accessPolicies, \n    AccessPolicyInterface* accessPolicyInterface, QWidget* parent) :\n    QGroupBox(tr(\"Access policies\"), parent),\n    accessPolicies_(accessPolicies),\n    view_(new EditableTableView(this)),\n    interface_(accessPolicyInterface)\n{\n    interface_->setAccessPolicies(accessPolicies);\n\n    auto topLayout = new QVBoxLayout(this);\n    topLayout->addWidget(view_);\n\n    auto model = new AccessPoliciesModel(accessPolicyInterface, this);\n    auto delegate = new AccessPoliciesDelegate(accessPolicyInterface->getModeReferenceInterface(), this);\n    proxy_ = new QSortFilterProxyModel(this);\n\n    proxy_->setSourceModel(model);\n    view_->setModel(proxy_);\n    view_->setItemDelegate(delegate);\n    view_->setSortingEnabled(true);\n    view_->setItemsDraggable(false);\n\n    connect(model, SIGNAL(dataChanged(const QModelIndex&, const QModelIndex&)),\n        this, SIGNAL(contentChanged()), Qt::UniqueConnection);\n    connect(model, SIGNAL(contentChanged()), this, SIGNAL(contentChanged()), Qt::UniqueConnection);\n    connect(model, SIGNAL(invalidateFilter()), proxy_, SLOT(invalidate()), Qt::UniqueConnection);\n\n    connect(view_, SIGNAL(addItem(QModelIndex const&)),\n        model, SLOT(onAddRow(QModelIndex const&)), Qt::UniqueConnection);\n    connect(view_, SIGNAL(removeItem(QModelIndex const&)),\n        model, SLOT(onRemoveItem(QModelIndex const&)), Qt::UniqueConnection);\n}\n\n//-----------------------------------------------------------------------------\n// Function: AccessPoliciesEditor::refresh()\n//-----------------------------------------------------------------------------\nvoid AccessPoliciesEditor::refresh()\n{\n    view_->update();\n    interface_->setAccessPolicies(accessPolicies_);\n    \n    // Invalidate filter to force table refresh (access values can be changed in upper level editor).\n    proxy_->invalidate();\n}\n"
  },
  {
    "path": "editors/ComponentEditor/memoryMaps/AccessPoliciesEditor.h",
    "content": "//-----------------------------------------------------------------------------\n// File: AccessPoliciesEditor.h\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Anton Hagqvist\n// Date: 28.8.2023\n//\n// Description:\n// Editor for access policies found in address blocks, registers, register files etc.\n//-----------------------------------------------------------------------------\n\n#ifndef ACCESSPOLICIESEDITOR_H\n#define ACCESSPOLICIESEDITOR_H\n\n#include <QGroupBox>\n\nclass AccessPolicyInterface;\nclass AccessPolicy;\nclass EditableTableView;\nclass QSortFilterProxyModel;\n\n//-----------------------------------------------------------------------------\n//! Editor for access policies found in address blocks, registers, register files etc.\n//-----------------------------------------------------------------------------\nclass AccessPoliciesEditor : public QGroupBox\n{\n    Q_OBJECT\n\npublic:\n\n    AccessPoliciesEditor(QSharedPointer<QList<QSharedPointer<AccessPolicy> > > accessPolicies, \n        AccessPolicyInterface* accessPolicyInterface, QWidget* parent);\n\n    virtual ~AccessPoliciesEditor() = default;\n\n    AccessPoliciesEditor(AccessPoliciesEditor const& other) = delete;\n    AccessPoliciesEditor& operator=(AccessPoliciesEditor const& other) = delete;\n\n    /*!\n     *  Reload the information from the model to the editor.\n     */\n    void refresh();\n\nsignals:\n\n    /*!\n     *\tEmitted whenever an access policy has been edited.\n     */\n    void contentChanged();\n\nprivate:\n\n    //! The available access policies.\n    QSharedPointer<QList<QSharedPointer<AccessPolicy> > > accessPolicies_;\n\n    //! The access policy table view.\n    EditableTableView* view_;\n\n    //! The sort filter proxy.\n    QSortFilterProxyModel* proxy_;\n\n    //! Interface for accessing access policies.\n    AccessPolicyInterface* interface_;\n};\n\n#endif // ACCESSPOLICIESEDITOR_H\n"
  },
  {
    "path": "editors/ComponentEditor/memoryMaps/AccessPoliciesModel.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: AccessPoliciesModel.h\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Anton Hagqvist\n// Date: 28.8.2023\n//\n// Description:\n// Model describing the access policies of an address block, register or register file.\n//-----------------------------------------------------------------------------\n\n#include \"AccessPoliciesModel.h\"\n\n#include <KactusAPI/include/RegisterInterface.h>\n#include <KactusAPI/include/AccessPolicyInterface.h>\n\n#include <common/KactusColors.h>\n\nusing ModeRefList = std::vector<std::pair<unsigned int, std::string> >;\n\n//-----------------------------------------------------------------------------\n// Function: AccessPoliciesModel::AccessPoliciesModel()\n//-----------------------------------------------------------------------------\nAccessPoliciesModel::AccessPoliciesModel(AccessPolicyInterface* accessPolicyInterface, QObject* parent) :\n    QAbstractTableModel(parent),\n    interface_(accessPolicyInterface)\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: AccessPoliciesModel::rowCount()\n//-----------------------------------------------------------------------------\nint AccessPoliciesModel::rowCount(const QModelIndex& parent /*= QModelIndex()*/) const\n{\n    if (parent.isValid())\n    {\n        return 0;\n    }\n\n    return interface_->getAccessPolicyCount();\n}\n\n//-----------------------------------------------------------------------------\n// Function: AccessPoliciesModel::columnCount()\n//-----------------------------------------------------------------------------\nint AccessPoliciesModel::columnCount(const QModelIndex& parent /*= QModelIndex()*/) const\n{\n    if (parent.isValid())\n    {\n        return 0;\n    }\n\n    return 2; // mode references and access\n}\n\n//-----------------------------------------------------------------------------\n// Function: AccessPoliciesModel::flags()\n//-----------------------------------------------------------------------------\nQt::ItemFlags AccessPoliciesModel::flags(const QModelIndex& index) const\n{\n    if (!index.isValid())\n    {\n        return Qt::NoItemFlags;\n    }\n\n    return Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsEditable;\n}\n\n//-----------------------------------------------------------------------------\n// Function: AccessPoliciesModel::headerData()\n//-----------------------------------------------------------------------------\nQVariant AccessPoliciesModel::headerData(int section, Qt::Orientation orientation, int role /*= Qt::DisplayRole*/) const\n{\n    if (orientation != Qt::Horizontal)\n    {\n        return QVariant();\n    }\n    if (role == Qt::DisplayRole)\n    {\n        if (section == 0)\n        {\n            return QStringLiteral(\"Mode(s)\");\n        }\n\n        else if (section == 1)\n        {\n            return QStringLiteral(\"Access\");\n        }\n    }\n\n    return QVariant();\n}\n\n//-----------------------------------------------------------------------------\n// Function: AccessPoliciesModel::data()\n//-----------------------------------------------------------------------------\nQVariant AccessPoliciesModel::data(const QModelIndex& index, int role /*= Qt::DisplayRole*/) const\n{\n    if (role == Qt::DisplayRole || role == Qt::EditRole)\n    {\n        return valueForIndex(index);\n    }\n\n    else if (role == Qt::BackgroundRole)\n    {\n        if (index.flags() == Qt::NoItemFlags)\n        {\n            return KactusColors::DISABLED_FIELD;\n        }\n\n        return KactusColors::REGULAR_FIELD;\n    }\n\n    else if (role == Qt::ToolTipRole)\n    {\n        return valueForIndex(index);\n    }\n\n    else if (role == Qt::ForegroundRole)\n    {\n        if (validateIndex(index))\n        {\n            return KactusColors::REGULAR_TEXT;\n        }\n        \n        return KactusColors::ERROR;\n    }\n\n    else if (role == Qt::UserRole)\n    {\n        if (index.column() == 0)\n        {\n            QVariant modeRefsVariant;\n\n            // Mode references for current index and all other mode refs.\n            QPair<ModeRefList, ModeRefList> modeRefs;\n\n            auto currentModeRefs = interface_->getAccesPolicyModeReferences(index.row());\n            auto otherModeRefsInUse = interface_->getModeReferencesInUse(index.row());\n\n            modeRefs.first = currentModeRefs;\n            modeRefs.second = otherModeRefsInUse;\n\n            modeRefsVariant.setValue(modeRefs);\n\n            return modeRefsVariant;\n        }\n    }\n\n    return QVariant();\n}\n\n//-----------------------------------------------------------------------------\n// Function: AccessPoliciesModel::setData()\n//-----------------------------------------------------------------------------\nbool AccessPoliciesModel::setData(const QModelIndex& index, const QVariant& value, int role /*= Qt::EditRole*/)\n{\n    if (!index.isValid() || index.row() < 0 ||\n        index.row() >= interface_->getAccessPolicyCount() ||\n        !(flags(index) & Qt::ItemIsEditable) || role != Qt::EditRole)\n    {\n        return false;\n    }\n\n    if (role == Qt::EditRole)\n    {\n        // Set modified mode reference data to access policy.\n        if (index.column() == 0)\n        {\n            ModeRefList updatedModeRefs = value.value<ModeRefList>();\n\n            interface_->setAccessPolicyModeReferences(index.row(), updatedModeRefs);\n        }\n        else if (index.column() == 1)\n        {\n            interface_->setAccess(value.toString().toStdString(), index.row());\n        }\n    }\n\n    emit dataChanged(index, index);\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: AccessPoliciesModel::onAddRow()\n//-----------------------------------------------------------------------------\nvoid AccessPoliciesModel::onAddRow(QModelIndex const& index)\n{\n    int row = interface_->getAccessPolicyCount();\n\n    // if the index is valid then add the item to the correct position\n    if (index.isValid())\n    {\n        row = index.row();\n    }\n\n    beginInsertRows(QModelIndex(), row, row);\n    interface_->addAccessPolicy(row);\n    endInsertRows();\n\n    emit invalidateFilter();\n    emit contentChanged();\n}\n\n//-----------------------------------------------------------------------------\n// Function: AccessPoliciesModel::onRemoveItem()\n//-----------------------------------------------------------------------------\nvoid AccessPoliciesModel::onRemoveItem(QModelIndex const& index)\n{\n    if (!index.isValid() || index.row() < 0 ||\n        index.row() >= interface_->getAccessPolicyCount())\n    {\n        return;\n    }\n\n    beginRemoveRows(QModelIndex(), index.row(), index.row());\n    interface_->removeAccessPolicy(index.row());\n    endRemoveRows();\n\n    emit contentChanged();\n}\n\n//-----------------------------------------------------------------------------\n// Function: AccessPoliciesModel::valueForIndex()\n//-----------------------------------------------------------------------------\nQVariant AccessPoliciesModel::valueForIndex(QModelIndex const& index) const\n{\n    if (index.column() == 0) // Mode ref display values\n    {\n        auto modeRefsList = interface_->getAccesPolicyModeReferences(index.row());\n\n        QStringList valueList;\n        for (auto const& [priority, reference] : modeRefsList)\n        {\n            valueList.append(QString::fromStdString(reference));\n        }\n\n        return valueList.join(\", \");\n    }\n\n    else if (index.column() == 1) // Access display values\n    {\n        return QString::fromStdString(interface_->getAccessString(index.row()));\n    }\n\n    return QVariant();\n}\n\n//-----------------------------------------------------------------------------\n// Function: AccessPoliciesModel::validateIndex()\n//-----------------------------------------------------------------------------\nbool AccessPoliciesModel::validateIndex(QModelIndex const& index) const\n{\n    if (index.column() == 0)\n    {\n        return interface_->accessPolicyHasValidModeReferences(index.row());\n    }\n\n    return true;\n}\n"
  },
  {
    "path": "editors/ComponentEditor/memoryMaps/AccessPoliciesModel.h",
    "content": "//-----------------------------------------------------------------------------\n// File: AccessPoliciesModel.h\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Anton Hagqvist\n// Date: 28.8.2023\n//\n// Description:\n// Model describing the access policies of an address block, register or register file.\n//-----------------------------------------------------------------------------\n\n#ifndef ACCESSPOLICIESMODEL_H\n#define ACCESSPOLICIESMODEL_H\n\n#include <QAbstractTableModel>\n\nclass AccessPolicyInterface;\n\nclass AccessPoliciesModel : public QAbstractTableModel\n{\n    Q_OBJECT\n\npublic:\n\n    AccessPoliciesModel(AccessPolicyInterface* accessPolicyInterface, QObject* parent);\n\n    virtual ~AccessPoliciesModel() = default;\n\n    //! No copying.\n    AccessPoliciesModel(AccessPoliciesModel const& other) = delete;\n    AccessPoliciesModel& operator=(AccessPoliciesModel const& other) = delete;\n\n    /*!\n     *  Get the number of access policies the model contains.\n     *\n     *    @param [in] parent  Identifies the parent whose row count is requested.\n     *\n     *    @return Number of rows the model has.\n     */\n    int rowCount(const QModelIndex& parent = QModelIndex()) const;\n\n    /*!\n     *  Get the number of columns the model has to be displayed.\n     *\n     *    @param [in] parent  Identifies the parent whose column count is requested.\n     *\n     *    @return The number of columns to be displayed.\n     */\n    int columnCount(const QModelIndex& parent = QModelIndex()) const;\n\n    /*!\n     *  Get the item flags that defines the possible operations for the item.\n     *\n     *    @param [in] index   Model index that identifies the item.\n     *\n     *    @return Qt::ItemFlags specifying the possible operations for the item.\n     */\n    Qt::ItemFlags flags(const QModelIndex& index) const;\n\n    /*!\n     *  Get the header data for specified header.\n     *\n     *    @param [in] section         The section specifies the row/column number for the header.\n     *    @param [in] orientation     Specified if horizontal or vertical header is wanted.\n     *    @param [in] role            Specifies the type of the requested data.\n     *\n     *    @return QVariant containing the requested data.\n     */\n    QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;\n\n    /*!\n     *  Get the data for specified item.\n     *\n     *    @param [in] index   Specifies the item that's data is requested.\n     *    @param [in] role    The role that defines what kind of data is requested.\n     *\n     *    @return QVariant containing the data for the item.\n     */\n    QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const;\n\n    /*!\n     *  Save the data to the model for specified item.\n     *\n     *    @param [in] index   The model index of the item that's data is to be saved.\n     *    @param [in] value   The data that is to be saved.\n     *    @param [in] role    The role specifies what kind of data should be saved.\n     *\n     *    @return True if saving happened successfully.\n     */\n    bool setData(const QModelIndex& index, const QVariant& value, int role = Qt::EditRole);\n\nsignals:\n\n    /*!\n     *\tEmitted whenever an access policy has been edited.\n     */\n    void contentChanged();\n\n    /*!\n     *\tEmitted when there has been a change in the number of rows.\n     */\n    void invalidateFilter();\n\npublic slots:\n\n    /*!\n     *\tHandler for adding a new field access policy.\n     *\n     *    @param [in] index     The model index of the item that was selected.\n     */\n    void onAddRow(QModelIndex const& index);\n\n    /*!\n     *\tHandler for removing a field access policy.\n     *\n     *    @param [in] index     The model index for the item/row to be removed.\n     */\n    void onRemoveItem(QModelIndex const& index);\n\nprivate:\n\n    /*!\n     *  Gets the value for the given index.\n     *\n     *    @param [in] index   The index of target data.\n     *\n     *    @return     The data in the given index.\n     */\n    QVariant valueForIndex(QModelIndex const& index) const;\n\n    /*!\n     *  Validates the data in the index.\n     *\n     *    @param [in] index   The index being validated.\n     *\n     *    @return     True, if the data is valid, otherwise false.\n     */\n    bool validateIndex(QModelIndex const& index) const;\n\n    //! The interface.\n    AccessPolicyInterface* interface_;\n    \n    //! The name of the register being edited.\n    std::string registerName_;\n\n};\n\n#endif // ACCESSPOLICIESMODEL_H\n"
  },
  {
    "path": "editors/ComponentEditor/memoryMaps/AddressBlockColumns.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: AddressBlockColumns.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Esko Pekkarinen\r\n// Date: 27.01.2015\r\n//\r\n// Description:\r\n// Common declarations for editing address block table columns.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef ADDRESS_BLOCK_COLUMNS_H\r\n#define ADDRESS_BLOCK_COLUMNS_H\r\n\r\nnamespace AddressBlockColumns\r\n{\r\n    //! Defines the columns for the address block table.\r\n    enum Column\r\n    {\r\n        NAME = 0,\r\n        REGISTER_OFFSET,\r\n        REGISTER_SIZE,\r\n        REGISTER_DIMENSION,\r\n        VOLATILE,\r\n        REGISTER_ACCESS,\r\n        IS_PRESENT,\r\n        DESCRIPTION,\r\n        COLUMN_COUNT\r\n    };\r\n}\r\n\r\n#endif //ADDRESS_BLOCK_COLUMNS_H\r\n"
  },
  {
    "path": "editors/ComponentEditor/memoryMaps/EnumeratedValueColumns.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: EnumeratedValueColumns.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Mikko Teuho\r\n// Date: 10.07.2015\r\n//\r\n// Description:\r\n// Common declarations for editing enumeration values of register fields.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef ENUMERATEDVALUECOLUMNS_H\r\n#define ENUMERATEDVALUECOLUMNS_H\r\n\r\nnamespace EnumeratedValueColumns\r\n{\r\n    enum columns\r\n    {\r\n        NAME_COLUMN = 0,\r\n        DISPLAY_NAME,\r\n        VALUE_COLUMN,\r\n        USAGE_COLUMN,\r\n        DESCRIPTION,\r\n        COLUMN_COUNT\r\n    };\r\n}\r\n\r\n#endif // ENUMERATEDVALUECOLUMNS_H"
  },
  {
    "path": "editors/ComponentEditor/memoryMaps/ExpressionProxyModel.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ExpressionProxyModel.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Esko Pekkarinen\r\n// Date: 09.06.2015\r\n//\r\n// Description:\r\n// Filter model for sorting items by expression value.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"ExpressionProxyModel.h\"\r\n\r\n#include <KactusAPI/include/ExpressionParser.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ExpressionProxyModel::ExpressionProxyModel()\r\n//-----------------------------------------------------------------------------\r\nExpressionProxyModel::ExpressionProxyModel(QSharedPointer<ExpressionParser> expressionParser, QObject *parent):\r\nQSortFilterProxyModel(parent), expressionParser_(expressionParser), expressionColumns_()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ExpressionProxyModel::~ExpressionProxyModel()\r\n//-----------------------------------------------------------------------------\r\nExpressionProxyModel::~ExpressionProxyModel()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ExpressionProxyModel::setColumnToAcceptExpressions()\r\n//-----------------------------------------------------------------------------\r\nvoid ExpressionProxyModel::setColumnToAcceptExpressions(int column)\r\n{\r\n    if (!expressionColumns_.contains(column))\r\n    {\r\n        expressionColumns_.append(column);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ExpressionProxyModel::lessThan()\r\n//-----------------------------------------------------------------------------\r\nbool ExpressionProxyModel::lessThan(QModelIndex const& left, QModelIndex const& right ) const\r\n{\r\n    Q_ASSERT(left.column() == right.column());\r\n\r\n    if (expressionColumns_.contains(left.column()))\r\n    {\r\n        // convert the data on left index into number\r\n        QString leftExpression = left.data(Qt::EditRole).toString();\r\n        quint64 leftValue = expressionParser_->parseExpression(leftExpression).toUInt();\r\n\r\n        // convert data on right index into number\r\n        QString rightExpression = right.data(Qt::EditRole).toString();\r\n        quint64 rightValue = expressionParser_->parseExpression(rightExpression).toUInt();\r\n\r\n        return leftValue < rightValue;\r\n    }\r\n    else\r\n    {\r\n        return QSortFilterProxyModel::lessThan(left, right);\r\n    }\r\n}\r\n"
  },
  {
    "path": "editors/ComponentEditor/memoryMaps/ExpressionProxyModel.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ExpressionProxyModel.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Esko Pekkarinen\r\n// Date: 09.06.2015\r\n//\r\n// Description:\r\n// Filter model for sorting items by expression value.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef EXPRESSIONPROXYMODEL_H\r\n#define EXPRESSIONPROXYMODEL_H\r\n\r\n#include <QSortFilterProxyModel>\r\n#include <QSharedPointer>\r\n\r\nclass ExpressionParser;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Filter model for sorting items by expression value.\r\n//-----------------------------------------------------------------------------\r\nclass ExpressionProxyModel : public QSortFilterProxyModel\r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\r\n\t/*! The constructor\r\n\t *\r\n\t *    @param [in] parent  The parent object.\r\n\t*/\r\n\tExpressionProxyModel(QSharedPointer<ExpressionParser> expressionParser, QObject *parent);\r\n\t\r\n\t//! The destructor\r\n\tvirtual ~ExpressionProxyModel();\r\n\r\n    /*!\r\n     *  Sets a column to accept expressions and to be compared by the expression value.\r\n     *\r\n     *    @param [in] column   The column to set as expression column.\r\n     */\r\n    void setColumnToAcceptExpressions(int column);\r\n\r\nprotected:\r\n\r\n\t/*! Compares two items by value.\r\n\t *\r\n\t *    @param left [in]    Index identifying the left item.\r\n\t *    @param right [in]   Index identifying the right item.\r\n\t *\r\n\t *    @return True, if left < right, otherwise false.\r\n\t*/\r\n\tvirtual bool lessThan(QModelIndex const& left, QModelIndex const& right) const;\r\n\r\nprivate:\r\n\t\r\n\t//! No copying\r\n\tExpressionProxyModel(const ExpressionProxyModel& other);\r\n\tExpressionProxyModel& operator=(const ExpressionProxyModel& other);\r\n\r\n    //! Parser for solving expressions.\r\n    QSharedPointer<ExpressionParser> expressionParser_;\r\n\r\n    //! The columns accepting expressions.\r\n    QList<int> expressionColumns_;\r\n};\r\n\r\n#endif // EXPRESSIONPROXYMODEL_H\r\n"
  },
  {
    "path": "editors/ComponentEditor/memoryMaps/FieldAccessPoliciesDelegate.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: FieldAccessPoliciesDelegate.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Anton Hagqvist\n// Date: 8.8.2023\n//\n// Description:\n// Delegate for field access policies.\n//-----------------------------------------------------------------------------\n\n#include \"FieldAccessPoliciesDelegate.h\"\n#include \"FieldAccessPolicyColumns.h\"\n\n#include <IPXACTmodels/Component/WriteValueConstraint.h>\n#include <IPXACTmodels/Component/ModeReference.h>\n\n#include <editors/ComponentEditor/common/FloatingModeReferenceEditor.h>\n#include <editors/ComponentEditor/common/ModeReferenceModel.h>\n\n#include <common/widgets/accessComboBox/accesscombobox.h>\n#include <common/widgets/modWriteComboBox/modwritecombobox.h>\n#include <common/widgets/readActionComboBox/readactioncombobox.h>\n#include <common/widgets/booleanComboBox/booleancombobox.h>\n#include <common/widgets/testConstraintComboBox/testconstraintcombobox.h>\n\n#include <KactusAPI/include/ModeReferenceInterface.h>\n\n#include <QCompleter>\n#include <QLineEdit>\n#include <QSortFilterProxyModel>\n\nusing ModeRefsList = std::vector<std::pair<unsigned int, std::string> >;\n\n//-----------------------------------------------------------------------------\n// Function: FieldAccessPoliciesDelegate::FieldAccessPoliciesDelegate()\n//-----------------------------------------------------------------------------\nFieldAccessPoliciesDelegate::FieldAccessPoliciesDelegate(QAbstractItemModel* completionModel,\n    QSharedPointer<ParameterFinder> parameterFinder, ModeReferenceInterface* modeRefInterface, QWidget* parent) :\nExpressionDelegate(completionModel, parameterFinder, parent),\nmodeRefInterface_(modeRefInterface)\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: FieldAccessPoliciesDelegate::createEditor()\n//-----------------------------------------------------------------------------\nQWidget* FieldAccessPoliciesDelegate::createEditor(QWidget* parent, const QStyleOptionViewItem& option,\n    const QModelIndex& index) const\n{\n    if (index.column() == FieldAccessPolicyColumns::MODE)\n    {\n        // Update the mode reference interface with the mode references of the current access policy\n        // by copying mode references over to interface to be able to abort editing in floating mode ref editor.\n        auto modeReferencesVariant = index.data(Qt::UserRole);\n\n        auto [currentModeRefs, otherModeRefsInUse] = modeReferencesVariant.value<QPair<ModeRefsList, ModeRefsList> >();\n\n        // Set the mode references of the currently selected field access policy to the mode reference interface.\n        modeRefInterface_->setModeReferences(currentModeRefs);\n\n        // Set the othcer mode references in use for validation purposes.\n        modeRefInterface_->setContainingElementModeReferences(otherModeRefsInUse);\n\n        modeRefInterface_->setContainingElementIsRemap(false);\n\n        FloatingModeReferenceEditor* modeRefEditor = new FloatingModeReferenceEditor(modeRefInterface_, parent);\n        connect(modeRefEditor, SIGNAL(finishEditing()), this, SLOT(commitAndCloseEditor()), Qt::UniqueConnection);\n        connect(modeRefEditor, SIGNAL(cancelEditing()), this, SLOT(onEditingCanceled()), Qt::UniqueConnection);\n        return modeRefEditor;\n    }\n\n    else if (index.column() == FieldAccessPolicyColumns::ACCESS)\n    {\n        AccessComboBox* accessEditor = new AccessComboBox(parent);\n\n        connect(accessEditor, SIGNAL(destroyed()), this, SLOT(commitAndCloseEditor()), Qt::UniqueConnection);\n        return accessEditor;\n    }\n\n    else if (index.column() == FieldAccessPolicyColumns::MODIFIED_WRITE)\n    {\n        ModWriteComboBox* modifiedWriteEditor = new ModWriteComboBox(parent);\n\n        connect(modifiedWriteEditor, SIGNAL(destroyed()), this, SLOT(commitAndCloseEditor()), Qt::UniqueConnection);\n        return modifiedWriteEditor;\n    }\n\n    else if (index.column() == FieldAccessPolicyColumns::READ_ACTION)\n    {\n        ReadActionComboBox* readActionEditor = new ReadActionComboBox(parent);\n\n        connect(readActionEditor, SIGNAL(destroyed()), this, SLOT(commitAndCloseEditor()), Qt::UniqueConnection);\n        return readActionEditor;\n    }\n\n    else if (index.column() == FieldAccessPolicyColumns::TESTABLE)\n    {\n        BooleanComboBox* testableEditor = new BooleanComboBox(parent);\n\n        connect(testableEditor, SIGNAL(destroyed()), this, SLOT(commitAndCloseEditor()), Qt::UniqueConnection);\n        return testableEditor;\n    }\n\n    else if (index.column() == FieldAccessPolicyColumns::TEST_CONSTRAINT)\n    {\n        TestConstraintComboBox* testConstraintEditor = new TestConstraintComboBox(parent);\n\n        connect(testConstraintEditor, SIGNAL(destroyed()), this, SLOT(commitAndCloseEditor()), Qt::UniqueConnection);\n        return testConstraintEditor;\n    }\n\n    else if (index.column() == FieldAccessPolicyColumns::WRITE_VALUE_CONSTRAINT)\n    {\n        QComboBox* writeConstraintEditor = new QComboBox(parent);\n\n        writeConstraintEditor->addItems(WriteValueConversions::getConstraintTypes());\n\n        connect(writeConstraintEditor, SIGNAL(destroyed()), this, SLOT(commitAndCloseEditor()), Qt::UniqueConnection);\n        return writeConstraintEditor;\n    }\n\n    else\n    {\n        return ExpressionDelegate::createEditor(parent, option, index);\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: FieldAccessPoliciesDelegate::setEditorData()\n//-----------------------------------------------------------------------------\nvoid FieldAccessPoliciesDelegate::setEditorData(QWidget* editor, const QModelIndex& index) const\n{\n    if (index.column() == FieldAccessPolicyColumns::ACCESS)\n    {\n        if (auto castEditor = qobject_cast<AccessComboBox*>(editor))\n        {\n            castEditor->setCurrentValue(AccessTypes::str2Access(\n                index.data(Qt::DisplayRole).toString(), AccessTypes::ACCESS_COUNT));\n        }\n    }\n\n    else if (index.column() == FieldAccessPolicyColumns::MODIFIED_WRITE)\n    {\n        if (auto modfiedWriteEditor = qobject_cast<ModWriteComboBox*>(editor))\n        {\n            modfiedWriteEditor->setCurrentValue(General::str2ModifiedWrite(index.data(Qt::DisplayRole).toString()));\n        }\n    }\n\n    else if (index.column() == FieldAccessPolicyColumns::READ_ACTION)\n    {\n        if (auto readActionEditor = qobject_cast<ReadActionComboBox*>(editor))\n        {\n            readActionEditor->setCurrentValue(General::str2ReadAction(index.data(Qt::DisplayRole).toString()));\n        }\n    }\n    \n    else if (index.column() == FieldAccessPolicyColumns::TESTABLE)\n    {\n        if (auto testableEditor = qobject_cast<BooleanComboBox*>(editor))\n        {\n            testableEditor->setCurrentValue(index.data(Qt::DisplayRole).toString());\n        }\n    }\n\n    else if (index.column() == FieldAccessPolicyColumns::TEST_CONSTRAINT)\n    {\n        if (auto testConstraintEditor = qobject_cast<TestConstraintComboBox*>(editor))\n        {\n            testConstraintEditor->setCurrentValue(General::str2TestConstraint(index.data(Qt::DisplayRole).toString()));\n        }\n    }\n\n    else if (index.column() == FieldAccessPolicyColumns::WRITE_VALUE_CONSTRAINT)\n    {\n        if (auto writeConstraintEditor = qobject_cast<QComboBox*>(editor))\n        {\n            writeConstraintEditor->setCurrentIndex(\n                WriteValueConversions::stringToType(index.data(Qt::DisplayRole).toString()));\n        }\n    }\n\n    else\n    {\n        ExpressionDelegate::setEditorData(editor, index);\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: FieldAccessPoliciesDelegate::setModelData()\n//-----------------------------------------------------------------------------\nvoid FieldAccessPoliciesDelegate::setModelData(QWidget* editor, QAbstractItemModel* model, const QModelIndex& index) const\n{\n    if (index.column() == FieldAccessPolicyColumns::MODE)\n    {\n        // Get the modified mode references from interface and send to access policy.\n        auto updatedModeRefs = modeRefInterface_->getModeReferences();\n\n        QVariant modeRefsVariant = QVariant::fromValue(updatedModeRefs);\n        model->setData(index, modeRefsVariant);\n    }\n\n    else if (index.column() == FieldAccessPolicyColumns::ACCESS)\n    {\n        if (auto accessEditor = qobject_cast<AccessComboBox*>(editor))\n        {\n            model->setData(index, accessEditor->currentText(), Qt::EditRole);\n        }\n    }\n\n    else if (index.column() == FieldAccessPolicyColumns::MODIFIED_WRITE)\n    {\n        if (auto modifiedWriteEditor = qobject_cast<ModWriteComboBox*>(editor))\n        {\n            model->setData(index, modifiedWriteEditor->currentText(), Qt::EditRole);\n        }\n    }\n\n    else if (index.column() == FieldAccessPolicyColumns::READ_ACTION)\n    {\n        if (auto readActionEditor = qobject_cast<ReadActionComboBox*>(editor))\n        {\n            model->setData(index, readActionEditor->currentText(), Qt::EditRole);\n        }\n    }\n\n    else if (index.column() == FieldAccessPolicyColumns::TESTABLE)\n    {\n        if (auto testableEditor = qobject_cast<BooleanComboBox*>(editor))\n        {\n            model->setData(index, testableEditor->currentText(), Qt::EditRole);\n        }\n    }\n\n    else if (index.column() == FieldAccessPolicyColumns::TEST_CONSTRAINT)\n    {\n        if (auto testConstraintEditor = qobject_cast<TestConstraintComboBox*>(editor))\n        {\n            model->setData(index, testConstraintEditor->currentText(), Qt::EditRole);\n        }\n    }\n\n    else if (index.column() == FieldAccessPolicyColumns::WRITE_VALUE_CONSTRAINT)\n    {\n        if (auto writeConstraintEditor = qobject_cast<QComboBox*>(editor))\n        {\n            model->setData(index, writeConstraintEditor->currentText(), Qt::EditRole);\n        }\n    }\n\n    else\n    {\n        ExpressionDelegate::setModelData(editor, model, index);\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: FieldAccessPoliciesDelegate::updateEditorGeometry()\n//-----------------------------------------------------------------------------\nvoid FieldAccessPoliciesDelegate::updateEditorGeometry(QWidget* editor, const QStyleOptionViewItem& option, const QModelIndex& index) const\n{\n    if (index.column() == FieldAccessPolicyColumns::MODE)\n    {\n        auto modeRefEditor = qobject_cast<FloatingModeReferenceEditor*>(editor);\n        int editorMinimumHeight = modeRefEditor->sizeHint().height();\n\n        auto modeRefTableMargins = modeRefEditor->getTableMargins();\n\n        int editorWidth = modeRefEditor->getTableSizeHint().width() + modeRefTableMargins.left()\n            + modeRefTableMargins.right() + 2;\n\n        if (editorWidth < 250)\n        {\n            editorWidth = 250;\n        }\n        else if (editorWidth > 300)\n        {\n            editorWidth = 300;\n        }\n\n        if (editorMinimumHeight < 250)\n        {\n            editorMinimumHeight = 250;\n        }\n\n        modeRefEditor->setFixedWidth(editorWidth);\n\n        const int PARENT_HEIGHT = editor->parentWidget()->height();\n        const int AVAILABLE_HEIGHT_BELOW = PARENT_HEIGHT - option.rect.top();\n\n        if (AVAILABLE_HEIGHT_BELOW > editorMinimumHeight)\n        {\n            editor->move(option.rect.topLeft());\n        }\n        else\n        {\n            int editorNewY = PARENT_HEIGHT - editorMinimumHeight;\n            if (editorNewY <= 0)\n            {\n                editorNewY = 0;\n            }\n\n            editor->move(option.rect.left(), editorNewY);\n        }\n\n        if (editorMinimumHeight > PARENT_HEIGHT)\n        {\n            editor->setFixedHeight(PARENT_HEIGHT);\n        }\n        else\n        {\n            editor->setFixedHeight(editorMinimumHeight);\n        }\n    }\n    else \n    {\n        ExpressionDelegate::updateEditorGeometry(editor, option, index);\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: FieldAccessPoliciesDelegate::commitAndCloseEditor()\n//-----------------------------------------------------------------------------\nvoid FieldAccessPoliciesDelegate::commitAndCloseEditor()\n{\n    if (auto editor = qobject_cast<QWidget*>(sender()))\n    {\n        emit commitData(editor);\n        emit closeEditor(editor);\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: FieldAccessPoliciesDelegate::columnAcceptsExpression()\n//-----------------------------------------------------------------------------\nbool FieldAccessPoliciesDelegate::columnAcceptsExpression(int column) const\n{\n    return column == FieldAccessPolicyColumns::READ_RESPONSE ||\n        column == FieldAccessPolicyColumns::RESERVED ||\n        column == FieldAccessPolicyColumns::WRITE_CONSTRAINT_MAXIMUM ||\n        column == FieldAccessPolicyColumns::WRITE_CONSTRAINT_MINIMUM;\n}\n\n//-----------------------------------------------------------------------------\n// Function: FieldAccessPoliciesDelegate::descriptionColumn()\n//-----------------------------------------------------------------------------\nint FieldAccessPoliciesDelegate::descriptionColumn() const\n{\n    return FieldAccessPolicyColumns::COUNT;\n}\n\n//-----------------------------------------------------------------------------\n// Function: FieldAccessPoliciesDelegate::onEditingCanceled()\n//-----------------------------------------------------------------------------\nvoid FieldAccessPoliciesDelegate::onEditingCanceled()\n{\n    if (auto editor = qobject_cast<QWidget*>(sender()))\n    {\n        emit closeEditor(editor);\n    }\n}\n"
  },
  {
    "path": "editors/ComponentEditor/memoryMaps/FieldAccessPoliciesDelegate.h",
    "content": "//-----------------------------------------------------------------------------\n// File: FieldAccessPoliciesDelegate.h\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Anton Hagqvist\n// Date: 8.8.2023\n//\n// Description:\n// Delegate for field access policies.\n//-----------------------------------------------------------------------------\n\n#ifndef FIELDACCESSPOLICIESDELEGATE_H\n#define FIELDACCESSPOLICIESDELEGATE_H\n\n#include <editors/ComponentEditor/common/ExpressionDelegate.h>\n\n#include <QStyledItemDelegate>\n\nclass ModeReferenceInterface;\n\nclass FieldAccessPoliciesDelegate : public ExpressionDelegate\n{\n    Q_OBJECT\n\npublic:\n\n    /*!\n     *  The constructor.\n     *\n     *    @param [in] completionModel     Model containing the completions used in expression editor.\n     *    @param [in] parameterFinder     The parameter finder to use for for expression editor.\n     *    @param [in] modeRefInterface    The interface to access mode references.\n     *    @param [in] parent              The parent object.\n     */\n    FieldAccessPoliciesDelegate(QAbstractItemModel* completionModel, \n        QSharedPointer<ParameterFinder> parameterFinder, ModeReferenceInterface* modeRefInterface, \n        QWidget* parent);\n\n    virtual ~FieldAccessPoliciesDelegate() = default;\n\n    FieldAccessPoliciesDelegate(FieldAccessPoliciesDelegate& other) = delete;\n    FieldAccessPoliciesDelegate& operator=(FieldAccessPoliciesDelegate& other) = delete;\n\n    /*!\n     *  Create a new editor for the given item\n     *\n     *    @param [in] parent  Owner for the editor.\n     *    @param [in] option  Contains options for the editor.\n     *    @param [in] index   Model index identifying the item.\n     *\n     *    @return The editor to be used to edit the item.\n     */\n    virtual QWidget* createEditor(QWidget* parent, const QStyleOptionViewItem& option, const QModelIndex& index) const override;\n\n    /*!\n     *  Set the data for the editor.\n     *\n     *    @param [in] editor  The editor where the data is to be set.\n     *    @param [in] index   Model index identifying the item that's data is to be set.\n     */\n    virtual void setEditorData(QWidget* editor, const QModelIndex& index) const override;\n\n    /*!\n     *  Save the data from the editor to the model.\n     *\n     *    @param [in] editor The editor that contains the data to store.\n     *    @param [in] model  Model that contains the data structure where data is to be saved to.\n     *    @param [in] index  Model index identifying the item that's data is to be saved.\n     */\n    virtual void setModelData(QWidget* editor, QAbstractItemModel* model, const QModelIndex& index) const override;\n\n    /*!\n     *  Updates the editor geometry for a given index.\n     *\n     *    @param [in] editor  The editor being updated.\n     *    @param [in] option  The options used to update the editor.\n     *    @param [in] index   The model index being edited.\n     */\n    virtual void updateEditorGeometry(QWidget* editor, const QStyleOptionViewItem& option, const QModelIndex& index) const override;\n\nprotected slots:\n\n    /*!\n     *  Commit the data from the sending editor and close the editor.\n     */\n    void commitAndCloseEditor();\n\nprotected:\n\n    /*!\n     *  Checks if the given column supports expressions in the editor.\n     *\n     *    @param [in] column   The column to check.\n     *\n     *    @return True, if the cells in the column allow expressions, otherwise false.\n     */\n    bool columnAcceptsExpression(int column) const override;\n\n    /*!\n     *  Gets the column that contains the description cells. In this case there is no such column.\n     */\n    int descriptionColumn() const override;\n\nprivate slots:\n\n    void onEditingCanceled();\n\n\nprivate:\n\n    //! Interface for accessing mode references. Used by mode reference editor.\n    ModeReferenceInterface* modeRefInterface_;\n};\n\n#endif // FIELDACCESSPOLICIESDELEGATE_H\n"
  },
  {
    "path": "editors/ComponentEditor/memoryMaps/FieldAccessPoliciesEditor.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: FieldAccessPoliciesEditor.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Anton Hagqvist\n// Date: 8.8.2023\n//\n// Description:\n// Editor for field access policies.\n//-----------------------------------------------------------------------------\n\n#include \"FieldAccessPoliciesEditor.h\"\n#include \"FieldAccessPolicyColumns.h\"\n#include \"FieldAccessPoliciesDelegate.h\"\n#include \"FieldAccessPoliciesModel.h\"\n\n#include <editors/ComponentEditor/parameters/ComponentParameterModel.h>\n\n#include <QCompleter>\n#include <QVBoxLayout>\n#include <QSortFilterProxyModel>\n#include <QHeaderView>\n\n//-----------------------------------------------------------------------------\n// Function: FieldAccessPoliciesEditor::FieldAccessPoliciesEditor()\n//-----------------------------------------------------------------------------\nFieldAccessPoliciesEditor::FieldAccessPoliciesEditor(QString const& fieldName, FieldInterface* fieldInterface, \n    QSharedPointer<ParameterFinder> parameterFinder, QSharedPointer<ExpressionParser> expressionParser,\n    QWidget* parent):\nQGroupBox(QStringLiteral(\"Access policies\"), parent),\nview_(new EditableTableView(this)),\nproxy_(new QSortFilterProxyModel(this))\n{\n    QVBoxLayout* topLayout = new QVBoxLayout(this);\n    topLayout->addWidget(view_);\n\n    auto model = new FieldAccessPoliciesModel(fieldName, parameterFinder, fieldInterface, expressionParser, this);\n    proxy_ = new QSortFilterProxyModel(this);\n\n    ComponentParameterModel* componentParameterModel = new ComponentParameterModel(parameterFinder, this);\n    componentParameterModel->setExpressionParser(expressionParser);\n\n    auto delegate = new FieldAccessPoliciesDelegate(componentParameterModel, parameterFinder, \n        fieldInterface->getModeReferenceInterface(), this);\n\n    view_->setSortingEnabled(true);\n    proxy_->setSourceModel(model);\n    view_->setModel(proxy_);\n    view_->setItemDelegate(delegate);\n    view_->horizontalHeader()->setStretchLastSection(false);\n    view_->setAllowElementCopying(true);\n    view_->setItemsDraggable(false);\n\n    // Hide type defs until they are implemented\n    view_->hideColumn(FieldAccessPolicyColumns::TYPE_DEFINITION);\n\n    connect(view_, SIGNAL(addItem(QModelIndex const&)),\n        model, SLOT(onAddRow(QModelIndex const&)), Qt::UniqueConnection);\n    connect(view_, SIGNAL(removeItem(QModelIndex const&)),\n        model, SLOT(onRemoveItem(QModelIndex const&)), Qt::UniqueConnection);\n    connect(view_, SIGNAL(copyRows(QModelIndexList)),\n        model, SLOT(onCopyRows(QModelIndexList)), Qt::UniqueConnection);\n    connect(view_, SIGNAL(pasteRows()), model, SLOT(onPasteRows()), Qt::UniqueConnection);\n\n    connect(model, SIGNAL(invalidateFilter()), proxy_, SLOT(invalidate()), Qt::UniqueConnection);\n    connect(model, SIGNAL(contentChanged()), this, SIGNAL(contentChanged()), Qt::UniqueConnection);\n    connect(model, SIGNAL(dataChanged(const QModelIndex&, const QModelIndex&)),\n        this, SIGNAL(contentChanged()), Qt::UniqueConnection);\n\n    connect(model, SIGNAL(increaseReferences(QString const&)),\n        this, SIGNAL(increaseReferences(QString const&)), Qt::UniqueConnection);\n    connect(model, SIGNAL(decreaseReferences(QString const&)),\n        this, SIGNAL(decreaseReferences(QString)), Qt::UniqueConnection);\n    connect(delegate, SIGNAL(increaseReferences(QString const&)),\n        this, SIGNAL(increaseReferences(QString const&)), Qt::UniqueConnection);\n    connect(delegate, SIGNAL(decreaseReferences(QString const&)),\n        this, SIGNAL(decreaseReferences(QString const&)), Qt::UniqueConnection);\n}\n\n//-----------------------------------------------------------------------------\n// Function: FieldAccessPoliciesEditor::refresh()\n//-----------------------------------------------------------------------------\nvoid FieldAccessPoliciesEditor::refresh()\n{\n    view_->update();\n    proxy_->invalidate();\n}\n"
  },
  {
    "path": "editors/ComponentEditor/memoryMaps/FieldAccessPoliciesEditor.h",
    "content": "//-----------------------------------------------------------------------------\n// File: FieldAccessPoliciesEditor.h\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Anton Hagqvist\n// Date: 8.8.2023\n//\n// Description:\n// Editor for field access policies.\n//-----------------------------------------------------------------------------\n\n#ifndef FIELDACCESSPOLICIESEDITOR_H\n#define FIELDACCESSPOLICIESEDITOR_H\n\n#include <common/views/EditableTableView/editabletableview.h>\n\n#include <QGroupBox>\n\nclass FieldInterface;\nclass ParameterFinder;\nclass ExpressionParser;\nclass QSortFilterProxyModel;\n\nclass FieldAccessPoliciesEditor : public QGroupBox\n{\n    Q_OBJECT\n\npublic:\n\n    FieldAccessPoliciesEditor(QString const& fieldName, FieldInterface* fieldInterface, \n        QSharedPointer<ParameterFinder> parameterFinder, QSharedPointer<ExpressionParser> expressionParser,\n        QWidget* parent);\n\n    virtual ~FieldAccessPoliciesEditor() = default;\n\n    FieldAccessPoliciesEditor(FieldAccessPoliciesEditor& other) = delete;\n    FieldAccessPoliciesEditor& operator=(FieldAccessPoliciesEditor& other) = delete;\n\n    void refresh();\n\nsignals:\n\n    /*!\n     *\tEmitted whenever a field access policy has been edited.\n     */\n    void contentChanged();\n\n\n    /*!\n     *  Increase the amount of references to a parameter with a matching id.\n     *\n     *    @param [in] id      Id of the parameter, whose references are being increased.\n     */\n    void increaseReferences(QString const& id);\n\n    /*!\n     *  Decrease the amount of references to a parameter with a matching id.\n     *\n     *    @param [in] id      Id of the parameter, whose references are being increased.\n     */\n    void decreaseReferences(QString const& id);\n\n\nprivate:\n\n    //! The table view to display the field access policies.\n    EditableTableView* view_;\n\n    //! Proxy to sort field access policies.\n    QSortFilterProxyModel* proxy_;\n};\n\n#endif // FIELDACCESSPOLICIESEDITOR_H"
  },
  {
    "path": "editors/ComponentEditor/memoryMaps/FieldAccessPoliciesModel.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: FieldAccessPoliciesModel.h\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Anton Hagqvist\n// Date: 8.8.2023\n//\n// Description:\n// Model to manage the field access policies of a field.\n//-----------------------------------------------------------------------------\n\n#include \"FieldAccessPoliciesModel.h\"\n#include \"FieldAccessPolicyColumns.h\"\n\n#include <common/KactusColors.h>\n\nusing ModeRefList = std::vector<std::pair<unsigned int, std::string> >;\n\n//-----------------------------------------------------------------------------\n// Function: FieldAccessPoliciesModel::FieldAccessPoliciesModel()\n//-----------------------------------------------------------------------------\nFieldAccessPoliciesModel::FieldAccessPoliciesModel(QString const& fieldName, \n    QSharedPointer<ParameterFinder> parameterFinder, FieldInterface* fieldInterface, \n    QSharedPointer<ExpressionParser> expressionParser, QObject* parent) :\nReferencingTableModel(parameterFinder, parent),\nParameterizableTable(parameterFinder),\nfieldInterface_(fieldInterface),\nfieldName_(fieldName.toStdString())\n{\n    setExpressionParser(expressionParser);\n}\n\n//-----------------------------------------------------------------------------\n// Function: FieldAccessPoliciesModel::rowCount()\n//-----------------------------------------------------------------------------\nint FieldAccessPoliciesModel::rowCount(const QModelIndex& parent /*= QModelIndex()*/) const\n{\n    if (parent.isValid())\n    {\n        return 0;\n    }\n\n    return fieldInterface_->getAccessPolicyCount(fieldName_);\n}\n\n//-----------------------------------------------------------------------------\n// Function: FieldAccessPoliciesModel::columnCount()\n//-----------------------------------------------------------------------------\nint FieldAccessPoliciesModel::columnCount(const QModelIndex& parent /*= QModelIndex()*/) const\n{\n    if (parent.isValid())\n    {\n        return 0;\n    }\n\n    return FieldAccessPolicyColumns::COUNT;\n}\n\n//-----------------------------------------------------------------------------\n// Function: FieldAccessPoliciesModel::flags()\n//-----------------------------------------------------------------------------\nQt::ItemFlags FieldAccessPoliciesModel::flags(const QModelIndex& index) const\n{\n    if (!index.isValid())\n    {\n        return Qt::NoItemFlags;\n    }\n\n    // Disable editing until editor is made.\n    else if (index.column() == FieldAccessPolicyColumns::TYPE_DEFINITION)\n    {\n        return Qt::ItemIsEnabled | Qt::ItemIsSelectable;\n    }\n\n    // Disable write constraint min/max, when that option is not set.\n    else if ((index.column() == FieldAccessPolicyColumns::WRITE_CONSTRAINT_MAXIMUM ||\n        index.column() == FieldAccessPolicyColumns::WRITE_CONSTRAINT_MINIMUM) &&\n        QString::fromStdString(fieldInterface_->getWriteConstraint(\n            fieldName_, index.row())) != QStringLiteral(\"Set minimum and maximum limits\"))\n    {\n        return Qt::ItemIsEnabled | Qt::ItemIsSelectable;\n    }\n\n    else if (index.column() == FieldAccessPolicyColumns::TEST_CONSTRAINT &&\n        fieldInterface_->getTestableBool(fieldName_, index.row()) == false)\n    {\n        return Qt::ItemIsEnabled | Qt::ItemIsSelectable;\n    }\n\n    return Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsEditable;\n}\n\n//-----------------------------------------------------------------------------\n// Function: FieldAccessPoliciesModel::headerData()\n//-----------------------------------------------------------------------------\nQVariant FieldAccessPoliciesModel::headerData(int section, Qt::Orientation orientation, int role /*= Qt::DisplayRole*/) const\n{\n    if (orientation != Qt::Horizontal)\n    {\n        return QVariant();\n    }\n    if (Qt::DisplayRole == role)\n    {\n        if (section == FieldAccessPolicyColumns::MODE)\n        {\n            return QStringLiteral(\"Mode(s)\");\n        }\n        else if (section == FieldAccessPolicyColumns::TYPE_DEFINITION)\n        {\n            return QStringLiteral(\"Type definition\");\n        }\n        else if (section == FieldAccessPolicyColumns::ACCESS)\n        {\n            return QStringLiteral(\"Access\");\n        }\n        else if (section == FieldAccessPolicyColumns::MODIFIED_WRITE)\n        {\n            return QStringLiteral(\"Modified write\\nvalue\");\n        }\n        else if (section == FieldAccessPolicyColumns::WRITE_VALUE_CONSTRAINT)\n        {\n            return QStringLiteral(\"Write value\\nconstraint\");\n        }\n        else if (section == FieldAccessPolicyColumns::READ_ACTION)\n        {\n            return QStringLiteral(\"Read action\");\n        }\n        else if (section == FieldAccessPolicyColumns::READ_RESPONSE)\n        {\n            return QStringLiteral(\"Read response\") + getExpressionSymbol();\n        }\n        else if (section == FieldAccessPolicyColumns::TESTABLE)\n        {\n            return QStringLiteral(\"Testable\");\n        }\n        else if (section == FieldAccessPolicyColumns::TEST_CONSTRAINT)\n        {\n            return QStringLiteral(\"Test constraint\");\n        }\n        else if (section == FieldAccessPolicyColumns::RESERVED)\n        {\n            return QStringLiteral(\"Reserved\") + getExpressionSymbol();\n        }\n        else if (section == FieldAccessPolicyColumns::WRITE_CONSTRAINT_MINIMUM)\n        {\n            return QStringLiteral(\"Write constraint\\nminimum\") + getExpressionSymbol();\n        }\n        else if (section == FieldAccessPolicyColumns::WRITE_CONSTRAINT_MAXIMUM)\n        {\n            return QStringLiteral(\"Write constraint\\nmaximum\") + getExpressionSymbol();\n        }\n    }\n\n    return QVariant();\n}\n\n//-----------------------------------------------------------------------------\n// Function: FieldAccessPoliciesModel::data()\n//-----------------------------------------------------------------------------\nQVariant FieldAccessPoliciesModel::data(const QModelIndex& index, int role /*= Qt::DisplayRole*/) const\n{\n    if (role == Qt::DisplayRole)\n    {\n        if (isValidExpressionColumn(index))\n        {\n            return formattedExpressionForIndex(index);\n        }\n        \n        return valueForIndex(index);\n    }\n\n    else if (role == Qt::BackgroundRole)\n    {\n        if (index.flags() == (Qt::ItemIsEnabled | Qt::ItemIsSelectable))\n        {\n            return KactusColors::DISABLED_FIELD;\n        }\n\n        return KactusColors::REGULAR_FIELD;\n    }\n\n    else if (role == Qt::ToolTipRole)\n    {\n        return valueForIndex(index);\n    }\n\n    else if (role == Qt::ForegroundRole)\n    {\n        return blackForValidOrRedForInvalidIndex(index);\n    }\n\n    else if (role == Qt::EditRole)\n    {\n        if (isValidExpressionColumn(index))\n        {\n            return expressionForIndex(index);\n        }\n    }\n\n    else if (role == Qt::UserRole)\n    {\n        // Data for mode ref editor.\n        if (index.column() == FieldAccessPolicyColumns::MODE)\n        {\n            QVariant modeRefsVariant;\n\n            // Mode references for current index and all other mode refs.\n            QPair<ModeRefList, ModeRefList> modeRefs;\n\n            auto currentModeRefs = fieldInterface_->getModeReferences(fieldName_, index.row());\n            auto otherModeRefsInUse = fieldInterface_->getModeReferencesInUse(fieldName_, index.row());\n\n            modeRefs.first = currentModeRefs;\n            modeRefs.second = otherModeRefsInUse;\n            \n            modeRefsVariant.setValue(modeRefs);\n\n            return modeRefsVariant;\n        }\n    }\n    else if (role == Qt::FontRole)\n    {\n        return italicForEvaluatedValue(index);\n    }\n\n    return QVariant();\n}\n\n//-----------------------------------------------------------------------------\n// Function: FieldAccessPoliciesModel::setData()\n//-----------------------------------------------------------------------------\nbool FieldAccessPoliciesModel::setData(const QModelIndex& index, const QVariant& value, int role /*= Qt::EditRole*/)\n{\n    if (!index.isValid() || index.row() < 0 || \n        index.row() >= fieldInterface_->getAccessPolicyCount(fieldName_) ||\n        !(flags(index) & Qt::ItemIsEditable) || role != Qt::EditRole)\n    {\n        return false;\n    }\n\n    if (index.column() == FieldAccessPolicyColumns::MODE)\n    {\n        ModeRefList updatedModeRefs = value.value<ModeRefList>();\n\n        fieldInterface_->setModeReferences(fieldName_, index.row(), updatedModeRefs);\n    }\n\n    else if (index.column() == FieldAccessPolicyColumns::ACCESS)\n    {\n        fieldInterface_->setAccess(fieldName_, value.toString().toStdString(), index.row());\n    }\n\n    else if (index.column() == FieldAccessPolicyColumns::MODIFIED_WRITE)\n    {\n        fieldInterface_->setModifiedWrite(fieldName_, value.toString().toStdString(), index.row());\n    }\n\n    else if (index.column() == FieldAccessPolicyColumns::READ_ACTION)\n    {\n        fieldInterface_->setReadAction(fieldName_, value.toString().toStdString(), index.row());\n    }\n\n    else if (index.column() == FieldAccessPolicyColumns::READ_RESPONSE)\n    {\n        fieldInterface_->setReadResponse(fieldName_, index.row(), value.toString().toStdString());\n    }\n\n    else if (index.column() == FieldAccessPolicyColumns::TESTABLE)\n    {\n        fieldInterface_->setTestable(fieldName_, value.toString().toStdString(), index.row());\n    }\n\n    else if (index.column() == FieldAccessPolicyColumns::TEST_CONSTRAINT)\n    {\n        fieldInterface_->setTestConstraint(fieldName_, value.toString().toStdString(), index.row());\n    }\n\n    else if (index.column() == FieldAccessPolicyColumns::RESERVED)\n    {\n        fieldInterface_->setReserved(fieldName_, value.toString().toStdString(), index.row());\n    }\n\n    else if (index.column() == FieldAccessPolicyColumns::WRITE_VALUE_CONSTRAINT)\n    {\n        auto oldValue = fieldInterface_->getWriteConstraint(fieldName_, index.row());\n        auto newValue = value.toString().toStdString();\n\n        // To prevent clearing the min/max fields after clicking out of editor, even when selection isn't changed.\n        if (oldValue != newValue)\n        {\n            fieldInterface_->setWriteConstraint(fieldName_, value.toString().toStdString(), index.row());\n        }\n    }\n\n    else if (index.column() == FieldAccessPolicyColumns::WRITE_CONSTRAINT_MINIMUM)\n    {\n        fieldInterface_->setWriteConstraintMinimum(fieldName_, value.toString().toStdString(), index.row());\n    }\n\n    else if (index.column() == FieldAccessPolicyColumns::WRITE_CONSTRAINT_MAXIMUM)\n    {\n        fieldInterface_->setWriteConstraintMaximum(fieldName_, value.toString().toStdString(), index.row());\n    }\n    \n    emit dataChanged(index, index);\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: FieldAccessPoliciesModel::mimeTypes()\n//-----------------------------------------------------------------------------\nQStringList FieldAccessPoliciesModel::mimeTypes() const\n{\n    QStringList types(QAbstractItemModel::mimeTypes());\n\n    types << \"text/xml/ipxact:fieldAccessPolicy\";\n\n    return types;\n}\n\n//-----------------------------------------------------------------------------\n// Function: FieldAccessPoliciesModel::onAddRow()\n//-----------------------------------------------------------------------------\nvoid FieldAccessPoliciesModel::onAddRow(QModelIndex const& index)\n{\n    int row = fieldInterface_->getAccessPolicyCount(fieldName_);\n\n    // if the index is valid then add the item to the correct position\n    if (index.isValid())\n    {\n        row = index.row();\n    }\n\n    beginInsertRows(QModelIndex(), row, row);\n    fieldInterface_->addFieldAccessPolicy(fieldName_);\n    endInsertRows();\n\n    emit invalidateFilter();\n    emit contentChanged();\n}\n\n//-----------------------------------------------------------------------------\n// Function: FieldAccessPoliciesModel::onRemoveItem()\n//-----------------------------------------------------------------------------\nvoid FieldAccessPoliciesModel::onRemoveItem(QModelIndex const& index)\n{\n    if (!index.isValid() || index.row() < 0 ||\n        index.row() >= fieldInterface_->getAccessPolicyCount(fieldName_))\n    {\n        return;\n    }\n\n    beginRemoveRows(QModelIndex(), index.row(), index.row());\n    removeReferencesInItemOnRow(index.row());\n    fieldInterface_->removeFieldAccessPolicy(fieldName_, index.row());\n    endRemoveRows();\n\n    emit contentChanged();\n}\n\n//-----------------------------------------------------------------------------\n// Function: FieldAccessPoliciesModel::onCopyRows()\n//-----------------------------------------------------------------------------\nvoid FieldAccessPoliciesModel::onCopyRows(QModelIndexList const& indices)\n{\n    \n    std::vector<int> rowsToCopy;\n    for (auto const& index : indices)\n    {\n        rowsToCopy.push_back(index.row());\n    }\n\n    fieldInterface_->copyFieldAccessPolicies(fieldName_, rowsToCopy);\n}\n\n//-----------------------------------------------------------------------------\n// Function: FieldAccessPoliciesModel::onPasteRows()\n//-----------------------------------------------------------------------------\nvoid FieldAccessPoliciesModel::onPasteRows()\n{\n    int accessPolicyRowBegin = fieldInterface_->getAccessPolicyCount(fieldName_);\n    int pastedAccessPoliciesCount = fieldInterface_->pasteFieldaccessPolicies(fieldName_);\n\n    if (pastedAccessPoliciesCount < 1)\n    {\n        return;\n    }\n\n    int rowEnd = accessPolicyRowBegin + pastedAccessPoliciesCount - 1;\n\n    beginInsertRows(QModelIndex(), accessPolicyRowBegin, rowEnd);\n\n    // Update the counts of any referenced parameter in the pasted access policies.\n    for (int i = 0; i < pastedAccessPoliciesCount; ++i)\n    {\n        increaseReferencesInFieldAccessPolicy(accessPolicyRowBegin + i);\n    }\n\n    endInsertRows();\n\n    emit contentChanged();\n}\n\n//-----------------------------------------------------------------------------\n// Function: FieldAccessPoliciesModel::getAllReferencesToIdInItemOnRow()\n//-----------------------------------------------------------------------------\nint FieldAccessPoliciesModel::getAllReferencesToIdInItemOnRow(const int& row, QString const& valueID) const\n{\n    return fieldInterface_->getAllReferencesToIdInFieldAccessPolicy(fieldName_, row, valueID.toStdString());\n}\n\n//-----------------------------------------------------------------------------\n// Function: FieldAccessPoliciesModel::isValidExpressionColumn()\n//-----------------------------------------------------------------------------\nbool FieldAccessPoliciesModel::isValidExpressionColumn(QModelIndex const& index) const\n{\n    int column = index.column();\n    return column == FieldAccessPolicyColumns::READ_RESPONSE ||\n        column == FieldAccessPolicyColumns::RESERVED ||\n        column == FieldAccessPolicyColumns::WRITE_CONSTRAINT_MAXIMUM ||\n        column == FieldAccessPolicyColumns::WRITE_CONSTRAINT_MINIMUM;\n}\n\n//-----------------------------------------------------------------------------\n// Function: FieldAccessPoliciesModel::expressionOrValueForIndex()\n//-----------------------------------------------------------------------------\nQVariant FieldAccessPoliciesModel::expressionOrValueForIndex(QModelIndex const& index) const\n{\n    if (isValidExpressionColumn(index))\n    {\n        return expressionForIndex(index);\n    }\n\n    return valueForIndex(index);\n}\n\n//-----------------------------------------------------------------------------\n// Function: FieldAccessPoliciesModel::validateIndex()\n//-----------------------------------------------------------------------------\nbool FieldAccessPoliciesModel::validateIndex(QModelIndex const& index) const\n{\n    if (int column = index.column(); \n        column == FieldAccessPolicyColumns::MODE)\n    {\n        return fieldInterface_->hasValidAccessPolicyModeRefs(fieldName_, index.row());\n    }\n    \n    else if (column == FieldAccessPolicyColumns::ACCESS)\n    {\n        return fieldInterface_->hasValidAccess(fieldName_, index.row());\n    }\n    \n    else if (column == FieldAccessPolicyColumns::READ_RESPONSE)\n    {\n        return fieldInterface_->hasValidReadResponse(fieldName_, index.row());\n    }\n    \n    else if (column == FieldAccessPolicyColumns::RESERVED)\n    {\n        return fieldInterface_->hasValidReserved(fieldName_, index.row());\n    }\n\n    else if (column == FieldAccessPolicyColumns::WRITE_VALUE_CONSTRAINT ||\n        column == FieldAccessPolicyColumns::WRITE_CONSTRAINT_MINIMUM ||\n        column == FieldAccessPolicyColumns::WRITE_CONSTRAINT_MAXIMUM)\n    {\n        return fieldInterface_->hasValidWriteValueConstraint(fieldName_, index.row());\n    }\n\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: FieldAccessPoliciesModel::valueForIndex()\n//-----------------------------------------------------------------------------\nQVariant FieldAccessPoliciesModel::valueForIndex(QModelIndex const& index) const\n{\n    if (index.column() == FieldAccessPolicyColumns::ACCESS)\n    {\n        return QString::fromStdString(fieldInterface_->getAccessString(fieldName_, index.row()));\n    }\n\n    else if (index.column() == FieldAccessPolicyColumns::MODE)\n    {\n        auto const& modeRefsList = fieldInterface_->getModeRefs(fieldName_, index.row());\n        QStringList list;\n        for (auto const& [reference, priority] : modeRefsList)\n        {\n            list.append(QString::fromStdString(reference));\n        }\n\n        return list.join(\", \");\n    }\n\n    else if (index.column() == FieldAccessPolicyColumns::MODIFIED_WRITE)\n    {\n        return QString::fromStdString(fieldInterface_->getModifiedWriteString(fieldName_, index.row()));\n    }\n\n    else if (index.column() == FieldAccessPolicyColumns::READ_ACTION)\n    {\n        return QString::fromStdString(fieldInterface_->getReadActionString(fieldName_, index.row()));\n    }\n\n    else if (index.column() == FieldAccessPolicyColumns::READ_RESPONSE)\n    {\n        return QString::fromStdString(fieldInterface_->getReadResponseValue(fieldName_, index.row()));\n    }\n\n    else if (index.column() == FieldAccessPolicyColumns::TESTABLE)\n    {\n        return QString::fromStdString(fieldInterface_->getTestableValue(fieldName_, index.row()));\n    }\n\n    else if (index.column() == FieldAccessPolicyColumns::TEST_CONSTRAINT)\n    {\n        return QString::fromStdString(fieldInterface_->getTestConstraintString(fieldName_, index.row()));\n    }\n\n    else if (index.column() == FieldAccessPolicyColumns::RESERVED)\n    {\n        return QString::fromStdString(fieldInterface_->getReservedValue(fieldName_, index.row()));\n    }\n\n    else if (index.column() == FieldAccessPolicyColumns::WRITE_VALUE_CONSTRAINT)\n    {\n        return QString::fromStdString(fieldInterface_->getWriteConstraint(fieldName_, index.row()));\n    }\n\n    else if (index.column() == FieldAccessPolicyColumns::WRITE_CONSTRAINT_MINIMUM)\n    {\n        return QString::fromStdString(fieldInterface_->getWriteConstraintMinimumValue(fieldName_, index.row()));\n    }\n\n    else if (index.column() == FieldAccessPolicyColumns::WRITE_CONSTRAINT_MAXIMUM)\n    {\n        return QString::fromStdString(fieldInterface_->getWriteConstraintMaximumValue(fieldName_, index.row()));\n    }\n\n    return QVariant();\n}\n\n//-----------------------------------------------------------------------------\n// Function: FieldAccessPoliciesModel::expressionForIndex()\n//-----------------------------------------------------------------------------\nQVariant FieldAccessPoliciesModel::expressionForIndex(QModelIndex const& index) const\n{\n    if (index.column() == FieldAccessPolicyColumns::READ_RESPONSE)\n    {\n        return QString::fromStdString(fieldInterface_->getReadResponseExpression(fieldName_, index.row()));\n    }\n\n    else if (index.column() == FieldAccessPolicyColumns::RESERVED)\n    {\n        return QString::fromStdString(fieldInterface_->getReservedExpression(fieldName_, index.row()));\n    }\n    \n    else if (index.column() == FieldAccessPolicyColumns::WRITE_CONSTRAINT_MAXIMUM)\n    {\n        return QString::fromStdString(fieldInterface_->getWriteConstraintMaximumExpression(fieldName_, index.row()));\n    }\n\n    else if (index.column() == FieldAccessPolicyColumns::WRITE_CONSTRAINT_MINIMUM)\n    {\n        return QString::fromStdString(fieldInterface_->getWriteConstraintMinimumExpression(fieldName_, index.row()));\n    }\n\n    return QVariant();\n}\n\n//-----------------------------------------------------------------------------\n// Function: FieldAccessPoliciesModel::formattedExpressionForIndex()\n//-----------------------------------------------------------------------------\nQVariant FieldAccessPoliciesModel::formattedExpressionForIndex(QModelIndex const& index) const\n{\n    if (index.column() == FieldAccessPolicyColumns::READ_RESPONSE)\n    {\n        return QString::fromStdString(fieldInterface_->getReadResponseFormattedExpression(fieldName_, index.row()));\n    }\n\n    else if (index.column() == FieldAccessPolicyColumns::RESERVED)\n    {\n        return QString::fromStdString(fieldInterface_->getReservedFormattedExpression(fieldName_, index.row()));\n    }\n\n    else if (index.column() == FieldAccessPolicyColumns::WRITE_CONSTRAINT_MAXIMUM)\n    {\n        return QString::fromStdString(fieldInterface_->getWriteConstraintMaximumFormattedExpression(fieldName_, index.row()));\n    }\n\n    else if (index.column() == FieldAccessPolicyColumns::WRITE_CONSTRAINT_MINIMUM)\n    {\n        return QString::fromStdString(fieldInterface_->getWriteConstraintMinimumFormattedExpression(fieldName_, index.row()));\n    }\n\n    return QVariant();\n}\n\n//-----------------------------------------------------------------------------\n// Function: FieldAccessPoliciesModel::increaseReferencesInFieldAccessPolicy()\n//-----------------------------------------------------------------------------\nvoid FieldAccessPoliciesModel::increaseReferencesInFieldAccessPolicy(int const& row)\n{\n    for (auto const& parameter : getParameterFinder()->getAllParameterIds())\n    {\n        int referencesToParam = getAllReferencesToIdInItemOnRow(row, parameter);\n\n        for (int i = 0; i < referencesToParam; ++i)\n        {\n            emit increaseReferences(parameter);\n        }\n    }\n}\n"
  },
  {
    "path": "editors/ComponentEditor/memoryMaps/FieldAccessPoliciesModel.h",
    "content": "//-----------------------------------------------------------------------------\n// File: FieldAccessPoliciesModel.h\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Anton Hagqvist\n// Date: 8.8.2023\n//\n// Description:\n// Model to manage the field access policies of a field.\n//-----------------------------------------------------------------------------\n\n#ifndef FIELDACCESSPOLICIESMODEL_H\n#define FIELDACCESSPOLICIESMODEL_H\n\n#include <KactusAPI/include/FieldInterface.h>\n\n#include <editors/ComponentEditor/common/ParameterizableTable.h>\n#include <editors/ComponentEditor/common/ReferencingTableModel.h>\n\nclass FieldAccessPoliciesModel : public ReferencingTableModel, public ParameterizableTable\n{\n    Q_OBJECT\n\npublic:\n        \n    /*!\n     *\tThe constructor.\n     *  \n     *    @param [in] fieldName           The name of the field being edited.\n     *    @param [in] parameterFinder     Parameter finder to use.\n     *    @param [in] fieldInterface      Field interface to access field data.\n     *    @param [in] expressionParser    Expression parser to use.\n     *    @param [in] parent              Parent object.\n     */\n    FieldAccessPoliciesModel(QString const& fieldName, QSharedPointer<ParameterFinder> parameterFinder, \n        FieldInterface* fieldInterface, QSharedPointer<ExpressionParser> expressionParser, QObject* parent);\n\n    virtual ~FieldAccessPoliciesModel() = default;\n\n    FieldAccessPoliciesModel(FieldAccessPoliciesModel& other) = delete;\n    FieldAccessPoliciesModel& operator=(FieldAccessPoliciesModel& other) = delete;\n\n    /*!\n     *  Get the number of access policies the model contains.\n     *\n     *    @param [in] parent  Identifies the parent whose row count is requested.\n     *\n     *    @return Number of rows the model has.\n     */\n    int rowCount(const QModelIndex& parent = QModelIndex()) const;\n\n    /*!\n     *  Get the number of columns the model has to be displayed.\n     *\n     *    @param [in] parent  Identifies the parent whose column count is requested.\n     *\n     *    @return The number of columns to be displayed.\n     */\n    int columnCount(const QModelIndex& parent = QModelIndex()) const;\n\n    /*!\n     *  Get the item flags that defines the possible operations for the item.\n     *\n     *    @param [in] index   Model index that identifies the item.\n     *\n     *    @return Qt::ItemFlags specifying the possible operations for the item.\n     */\n    Qt::ItemFlags flags(const QModelIndex& index) const;\n\n    /*!\n     *  Get the header data for specified header.\n     *\n     *    @param [in] section         The section specifies the row/column number for the header.\n     *    @param [in] orientation     Specified if horizontal or vertical header is wanted.\n     *    @param [in] role            Specifies the type of the requested data.\n     *\n     *    @return QVariant containing the requested data.\n     */\n    QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;\n\n    /*!\n     *  Get the data for specified item.\n     *\n     *    @param [in] index   Specifies the item that's data is requested.\n     *    @param [in] role    The role that defines what kind of data is requested.\n     *\n     *    @return QVariant containing the data for the item.\n     */\n    QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const;\n\n    /*!\n     *  Save the data to the model for specified item.\n     *\n     *    @param [in] index   The model index of the item that's data is to be saved.\n     *    @param [in] value   The data that is to be saved.\n     *    @param [in] role    The role specifies what kind of data should be saved.\n     *\n     *    @return True if saving happened successfully.\n     */\n    bool setData(const QModelIndex& index, const QVariant& value, int role = Qt::EditRole);\n\n    /*!\n     *  Get the list of acceptable mime types.\n     *\n     *    @return The list of acceptable mime types.\n     */\n    virtual QStringList mimeTypes() const;\n\npublic slots:\n\n    /*!\n     *\tHandler for adding a new field access policy.\n     *  \n     *    @param [in] index     The model index of the item that was selected.\n     */\n    void onAddRow(QModelIndex const& index);\n\n    /*!\n     *\tHandler for removing a field access policy.\n     *  \n     *    @param [in] index     The model index for the item/row to be removed.\n     */\n    void onRemoveItem(QModelIndex const& index);\n\n    /*!\n     *  Copy the items in the selected rows.\n     *\n     *    @param [in] indices   List of indexes pointing to the selected rows.\n     */\n    void onCopyRows(QModelIndexList const& indices);\n\n    /*!\n     *  Paste the copied items.\n     */\n    void onPasteRows();\n\nsignals:\n\n    /*!\n     *\tEmitted when there has been a change in the number of rows.\n     */\n    void invalidateFilter();\n\n    /*!\n     *\tEmitted whenever a field access policy has been edited.\n     */\n    void contentChanged();\n\nprotected:\n\n    /*!\n     *  Get all the references made to the selected parameter from the selected row.\n     *\n     *    @param [in] row         The selected row.\n     *    @param [in] valueID     The target parameter.\n     *\n     *    @return Number of references made to the selected id from the selected row.\n     */\n    int getAllReferencesToIdInItemOnRow(const int& row, QString const& valueID) const final;\n\n    /*!\n     *  Check if the column index is valid for containing expressions.\n     *\n     *    @param [in] index   The index being evaluated.\n     *\n     *      return True, if column can have expressions, false otherwise.\n     */\n    bool isValidExpressionColumn(QModelIndex const& index) const final;\n\n    /*!\n     *  Gets the expression for the given index, or plain value if there is no expression.\n     *\n     *    @param [in] index   The index of target data.\n     *\n     *      return      Expression in the given index, or plain value.\n     */\n    QVariant expressionOrValueForIndex(QModelIndex const& index) const final;\n\n    /*!\n     *  Validates the data in the cell given by the column.\n     *\n     *    @param [in] index   The index being validated.\n     *\n     *      return      True, if the data in the parameter is valid, false otherwise.\n     */\n    bool validateIndex(QModelIndex const& index) const override;\n\nprivate:\n\n    QVariant valueForIndex(QModelIndex const& index) const;\n\n    QVariant expressionForIndex(QModelIndex const& index) const;\n\n    /*!\n     *  Get the formatted value of an expression in the selected index.\n     *\n     *    @param [in] index   The selected index.\n     *\n     *    @return The formatted value of an expression in the selected index.\n     */\n    QVariant formattedExpressionForIndex(QModelIndex const& index) const;\n\n    /*!\n     *\tIncrease the references of the parameters in a field access policy given by row, when copy pasting a\n     *  the field access policy.\n     *  \n     *    @param [in] row     Description\n     */\n    void increaseReferencesInFieldAccessPolicy(int const& row);\n\n    //! The field interface to use.\n    FieldInterface* fieldInterface_;\n\n    //! The name of the current field.\n    std::string fieldName_;\n};\n\n\n#endif // FIELDACCESSPOLICIESMODEL_H\n"
  },
  {
    "path": "editors/ComponentEditor/memoryMaps/FieldAccessPolicyColumns.h",
    "content": "//-----------------------------------------------------------------------------\n// File: FieldAccessPolicyColumns.h\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Anton Hagqvist\n// Date: 8.8.2023\n//\n// Description:\n// Definitions for field access policies table.\n//-----------------------------------------------------------------------------\n\n#ifndef FIELDACCESSPOLICYCOLUMNS_H\n#define FIELDACCESSPOLICYCOLUMNS_H\n\nnamespace FieldAccessPolicyColumns\n{\n    //! Enumeration for columns in field access policies table.\n    enum Columns\n    {\n        MODE = 0,\n        TYPE_DEFINITION,\n        ACCESS,\n        READ_ACTION,\n        READ_RESPONSE,\n        TESTABLE,\n        TEST_CONSTRAINT,\n        RESERVED,\n        MODIFIED_WRITE,\n        WRITE_VALUE_CONSTRAINT,\n        WRITE_CONSTRAINT_MINIMUM,\n        WRITE_CONSTRAINT_MAXIMUM,\n        COUNT\n    };\n}\n\n#endif // FIELDACCESSPOLICYCOLUMNS_H\n\n\n\n"
  },
  {
    "path": "editors/ComponentEditor/memoryMaps/MemoryBlockDelegate.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: MemoryBlockDelegate.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 14.02.2022\n//\n// Description:\n// The delegate that provides editors to add/remove/edit details of memory blocks.\n//-----------------------------------------------------------------------------\n\n#include \"MemoryBlockDelegate.h\"\n\n#include <common/widgets/booleanComboBox/booleancombobox.h>\n\n#include <IPXACTmodels/common/validators/namevalidator.h>\n\n#include <QLineEdit>\n\n//-----------------------------------------------------------------------------\n// Function: MemoryBlockDelegate::MemoryBlockDelegate()\n//-----------------------------------------------------------------------------\nMemoryBlockDelegate::MemoryBlockDelegate(QAbstractItemModel* completionModel,\n                                     QSharedPointer<ParameterFinder> parameterFinder, QObject *parent):\nExpressionDelegate(completionModel, parameterFinder, parent)\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: MemoryBlockDelegate::createEditor()\n//-----------------------------------------------------------------------------\nQWidget* MemoryBlockDelegate::createEditor(QWidget* parent, QStyleOptionViewItem const& option,\n    QModelIndex const& index) const \n{\n    if (index.column() == nameColumn())\n    {\n        return createNameEditor(parent, option, index);\n    }\n    else\n    {\n        return ExpressionDelegate::createEditor(parent, option, index);\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: MemoryBlockDelegate::columnAcceptsExpression()\n//-----------------------------------------------------------------------------\nbool MemoryBlockDelegate::columnAcceptsExpression(int column) const\n{\n    return column == baseAddressColumn() || column == isPresentColumn();\n}\n\n\n//-----------------------------------------------------------------------------\n// Function: MemoryBlockDelegate::commitAndCloseEditor()\n//-----------------------------------------------------------------------------\nvoid MemoryBlockDelegate::commitAndCloseEditor()\n{\n\tQWidget* editor = qobject_cast<QWidget*>(sender());\n\tQ_ASSERT(editor);\n\n\temit commitData(editor);\n\temit closeEditor(editor);\n}\n\n//-----------------------------------------------------------------------------\n// Function: MemoryBlockDelegate::createNameEditor()\n//-----------------------------------------------------------------------------\nQWidget* MemoryBlockDelegate::createNameEditor(QWidget* parent, QStyleOptionViewItem const& option, \n    QModelIndex const& index) const\n{\n    QWidget* nameEditor = QStyledItemDelegate::createEditor(parent, option, index);\n\n    QLineEdit* lineEditor = qobject_cast<QLineEdit*>(nameEditor);\n    if (lineEditor)\n    {\n        lineEditor->setValidator(new NameValidator(lineEditor));\n    }\n\n    connect(nameEditor, SIGNAL(editingFinished()), this, SLOT(commitAndCloseEditor()), Qt::UniqueConnection);\n    return nameEditor;\n}\n"
  },
  {
    "path": "editors/ComponentEditor/memoryMaps/MemoryBlockDelegate.h",
    "content": "//-----------------------------------------------------------------------------\n// File: MemoryBlockDelegate.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 14.02.2022\n//\n// Description:\n// The delegate that provides editors to add/remove/edit details of memory blocks.\n//-----------------------------------------------------------------------------\n\n#ifndef MEMORYBLOCKDELEGATE_H\n#define MEMORYBLOCKDELEGATE_H\n\n#include <KactusAPI/include/ParameterFinder.h>\n#include <editors/ComponentEditor/common/ExpressionDelegate.h>\n\n//-----------------------------------------------------------------------------\n//! The delegate that provides editors to add/remove/edit details of memory blocks.\n//-----------------------------------------------------------------------------\nclass MemoryBlockDelegate : public ExpressionDelegate\n{\n\tQ_OBJECT\n\npublic:\n\t\n\t/*!\n\t *  The constructor.\n\t *\n     *    @param [in] completionModel         Model containing the completions used in expression editor.\n\t *    @param [in] parameterFinder         The parameter finder for expression editor.\n\t *    @param [in] parent                  Pointer to the owner of the delegate.\n\t */\n\tMemoryBlockDelegate(QAbstractItemModel* completionModel, QSharedPointer<ParameterFinder> parameterFinder,\n        QObject *parent);\n\t\n\t/*!\n     *  The destructor.\n     */\n    virtual ~MemoryBlockDelegate() = default;\n\n\t/*!\n     *  Create a new editor for the given item\n\t *\n\t *    @param [in] parent Owner for the editor.\n\t *    @param [in] option Contains options for the editor.\n\t *    @param [in] index Model index identifying the item.\n\t *\n\t *    @return Pointer to the editor to be used to edit the item.\n\t */\n\tvirtual QWidget* createEditor(QWidget* parent, const QStyleOptionViewItem& option, QModelIndex const& index)\n        const;\n\nprotected:\n\n    /*!\n     *  Checks if the given column supports expressions in the editor.\n     *\n     *    @param [in] column  The column to check.\n     *\n     *    @return True if the cells in the column allow expressions, otherwise false.\n     */\n    virtual bool columnAcceptsExpression(int column) const;\n\nprivate slots:\n\n\t/*!\n     *  Commit the data from the sending editor and close the editor.\n\t */\n\tvoid commitAndCloseEditor();\n\nprivate:\n\t\n    //! No copying.\tNo assignment.\n\tMemoryBlockDelegate(const MemoryBlockDelegate& other);\n    MemoryBlockDelegate& operator=(const MemoryBlockDelegate& other);\n\n    /*!\n     *  Get the column for block name.\n     *\n     *    @return Index of the name column.\n     */\n    virtual int nameColumn() const = 0;\n\n    /*!\n     *  Get the column for block base address.\n     *\n     *    @return Index of the base address column.\n     */\n    virtual int baseAddressColumn() const = 0;\n\n    /*!\n     *  Get the column for block is present.\n     *\n     *    @return Index of the is present column.\n     */\n    virtual int isPresentColumn() const = 0;\n\n    /*!\n     *  Creates an editor for name.\n     *\n     *    @param [in] parent   The parent widget for the editor.\n     *    @param [in] option   The style options for the editor.\n     *    @param [in] index    The index for which the editor is created.\n     *\n     *    @return Editor for editing name.\n     */\n    QWidget* createNameEditor(QWidget* parent, QStyleOptionViewItem const& option, QModelIndex const& index) const;\n};\n\n#endif // MEMORYBLOCKDELEGATE_H\n"
  },
  {
    "path": "editors/ComponentEditor/memoryMaps/MemoryBlockFilter.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: MemoryBlockFilter.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 15.02.2022\n//\n// Description:\n// Sorting proxy model for memory blocks.\n//-----------------------------------------------------------------------------\n\n#include \"MemoryBlockFilter.h\"\n\n#include <KactusAPI/include/MemoryBlockInterface.h>\n\n//-----------------------------------------------------------------------------\n// Function: PortsFilter::PortsFilter()\n//-----------------------------------------------------------------------------\nMemoryBlockFilter::MemoryBlockFilter(QSharedPointer<ExpressionParser> parser, MemoryBlockInterface* blockInterface,\n    QObject* parent):\nExpressionProxyModel(parser, parent),\nblockInterface_(blockInterface)\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: MemoryBlockFilter::filterAcceptsRow()\n//-----------------------------------------------------------------------------\nbool MemoryBlockFilter::filterAcceptsRow(int source_row, const QModelIndex& source_parent) const\n{\n    std::string blockName = blockInterface_->getIndexedItemName(source_row);\n    if (!blockInterface_->acceptBlock(blockName))\n    {\n        return false;\n    }\n\n    return QSortFilterProxyModel::filterAcceptsRow(source_row, source_parent);\n}\n"
  },
  {
    "path": "editors/ComponentEditor/memoryMaps/MemoryBlockFilter.h",
    "content": "//-----------------------------------------------------------------------------\n// File: MemoryBlockFilter.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 15.02.2022\n//\n// Description:\n// Sorting proxy model for memory blocks.\n//-----------------------------------------------------------------------------\n\n#ifndef MEMORYBLOCKFILTER_H\n#define MEMORYBLOCKFILTER_H\n\n#include <editors/ComponentEditor/memoryMaps/ExpressionProxyModel.h>\n\n#include <QSortFilterProxyModel>\n#include <QSharedPointer>\n\nclass MemoryBlockInterface;\nclass ExpressionParser;\n\n//-----------------------------------------------------------------------------\n//! Sorting proxy model for ports.\n//-----------------------------------------------------------------------------\nclass MemoryBlockFilter : public ExpressionProxyModel\n{\n    Q_OBJECT\n\npublic:\n\n    /*!\n     *  Constructor.\n     *\n     *    @param [in] parser          The expression parser.\n     *    @param [in] blockInterface  Interface for accessing memory blocks.\n     *    @param [in] parent          The parent object.\n     */\n    MemoryBlockFilter(QSharedPointer<ExpressionParser> parser, MemoryBlockInterface* blockInterface,\n        QObject* parent = 0);\n\n\t /*!\n      *  Destructor.\n      */\n    virtual ~MemoryBlockFilter() = default;\n\n    // No copying. No assignments.\n    MemoryBlockFilter(MemoryBlockFilter const& rhs) = delete;\n    MemoryBlockFilter& operator=(MemoryBlockFilter const& rhs) = delete;\n\nprotected:\n\n    /*!\n\t *  Implementation of the row filtering.\n\t *\n\t *    @param [in] source_row      The row to check for filtering.\n     *    @param [in] source_parent   The parent index of the row.\n     *\n     *    @return True, if the row passes the filters, otherwise false.\n\t */\n    virtual bool filterAcceptsRow(int source_row, const QModelIndex & source_parent) const override;\n\nprivate:\n\n    //-----------------------------------------------------------------------------\n    // Data.\n    //-----------------------------------------------------------------------------\n\n    //! Interface for accessing the memory blocks.\n    MemoryBlockInterface* blockInterface_;\n};\n\n#endif // MEMORYBLOCKFILTER_H\n"
  },
  {
    "path": "editors/ComponentEditor/memoryMaps/MemoryBlockModel.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: MemoryBlockModel.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 09.02.2022\n//\n// Description:\n// The parent model for editing memory blocks.\n//-----------------------------------------------------------------------------\n\n#include \"MemoryBlockModel.h\"\n\n#include <editors/ComponentEditor/memoryMaps/memoryMapsExpressionCalculators/ReferenceCalculator.h>\n#include <KactusAPI/include/MemoryBlockInterface.h>\n\n#include <common/KactusColors.h>\n\n#include <QRegularExpression>\n\n//-----------------------------------------------------------------------------\n// Function: MemoryBlockModel::MemoryBlockModel()\n//-----------------------------------------------------------------------------\nMemoryBlockModel::MemoryBlockModel(MemoryBlockInterface* blockInterface,\n    QSharedPointer<ExpressionParser> expressionParser, QSharedPointer<ParameterFinder> parameterFinder,\n    Document::Revision docRevision, QObject *parent):\nReferencingTableModel(parameterFinder, parent),\nParameterizableTable(parameterFinder),\ndocRevision_(docRevision),\nblockInterface_(blockInterface)\n{\n    setExpressionParser(expressionParser);\n}\n\n//-----------------------------------------------------------------------------\n// Function: MemoryBlockModel::rowCount()\n//-----------------------------------------------------------------------------\nint MemoryBlockModel::rowCount(QModelIndex const& parent) const\n{\n\tif (parent.isValid())\n    {\n\t\treturn 0;\n\t}\n\n    return blockInterface_->itemCount();\n}\n\n//-----------------------------------------------------------------------------\n// Function: MemoryBlockModel::flags()\n//-----------------------------------------------------------------------------\nQt::ItemFlags MemoryBlockModel::flags(QModelIndex const& index) const\n{\n\tif (!index.isValid())\n    {\n\t\treturn Qt::NoItemFlags;\n\t}\n\treturn Qt::ItemIsEnabled | Qt::ItemIsEditable | Qt::ItemIsSelectable;\n}\n\n//-----------------------------------------------------------------------------\n// Function: MemoryBlockModel::headerData()\n//-----------------------------------------------------------------------------\nQVariant MemoryBlockModel::headerData(int section, Qt::Orientation orientation, int role) const \n{\n\tif (orientation != Qt::Horizontal)\n    {\n\t\treturn QVariant();\n\t}\n\n\tif (Qt::DisplayRole == role)\n    {\n        if (section == nameColumn())\n        {\n            return tr(\"Name\");\n        }\n        else if (section == baseAddressColumn())\n        {\n            QString baseAddress = tr(\"Base address\\n [AUB]\") + getExpressionSymbol();\n            return baseAddress;\n        }\n        else if (section == isPresentColumn())\n        {\n            return tr(\"Is present\") + getExpressionSymbol();\n        }\n        else if (section == descriptionColumn())\n        {\n            return tr(\"Description\");\n        }\n\t}\n    \n    return QVariant();\n}\n\n//-----------------------------------------------------------------------------\n// Function: MemoryBlockModel::data()\n//-----------------------------------------------------------------------------\nQVariant MemoryBlockModel::data(QModelIndex const& index, int role) const\n{\n    if (!index.isValid() || index.row() < 0 || index.row() >= blockInterface_->itemCount())\n    {\n\t\treturn QVariant();\n\t}\n\n    std::string blockName = blockInterface_->getIndexedItemName(index.row());\n\n    if (role == Qt::DisplayRole || role == Qt::ToolTipRole)\n    {\n        if (isValidExpressionColumn(index) && role == Qt::DisplayRole)\n        {\n            return formattedExpressionForIndex(index);\n        }\n        else if (role == Qt::DisplayRole && index.column() == descriptionColumn())\n        {\n            return valueForIndex(index).toString().replace(QRegularExpression(\"\\n.*$\",\n                QRegularExpression::DotMatchesEverythingOption), \"...\");\n        }\n\n        return valueForIndex(index);\n    }\n\n    else if (role == Qt::EditRole)\n    {\n        return expressionOrValueForIndex(index);\n    }\n\n\telse if (role == Qt::ForegroundRole)\n    {\n        std::string blockPresence = blockInterface_->getIsPresentExpression(blockName);\n        qint64 blockPresenceValue =\n            QString::fromStdString(blockInterface_->getIsPresentValue(blockName, 10)).toLongLong();\n\n        if (index.column() != isPresentColumn() && (!blockPresence.empty() && blockPresenceValue != 1))\n        {\n            return KactusColors::DISABLED_TEXT;\n        }\n\n        return blackForValidOrRedForInvalidIndex(index);\n    }\n    else if (role == Qt::BackgroundRole)\n    {\n        if (index.column() == nameColumn() || index.column() == baseAddressColumn())\n        {\n            return KactusColors::MANDATORY_FIELD;\n        }\n        else if (index.flags() == (Qt::ItemIsSelectable | Qt::ItemIsEnabled))\n        {\n            return KactusColors::DISABLED_FIELD;\n        }\n        else \n        {\n            return KactusColors::REGULAR_FIELD;\n        }\n    }\n    else if (role == Qt::FontRole)\n    {\n        return italicForEvaluatedValue(index);\n    }\n    else \n    {\n        return QVariant();\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: MemoryBlockModel::setData()\n//-----------------------------------------------------------------------------\nbool MemoryBlockModel::setData(QModelIndex const& index, QVariant const& value, int role)\n{\n    if (!index.isValid() || index.row() < 0 || index.row() >= blockInterface_->itemCount())\n    {\n\t\treturn false;\n\t}\n\n    if (Qt::EditRole == role)\n    {\n        std::string blockName = blockInterface_->getIndexedItemName(index.row());\n\n        if (index.column() == nameColumn())\n        {\n            blockInterface_->setName(blockName, value.toString().toStdString());\n\n            QString oldName = QString::fromStdString(blockName);\n            QString newName = QString::fromStdString(blockInterface_->getIndexedItemName(index.row()));\n\n            emit blockNameChanged(oldName, newName);\n        }\n        else if (index.column() == baseAddressColumn())\n        {\n            if (!value.isValid())\n            {\n                removeReferencesFromSingleExpression(\n                    QString::fromStdString(blockInterface_->getBaseAddressExpression(blockName)));\n            }\n\n            blockInterface_->setBaseAddress(blockName, value.toString().toStdString());\n        }\n        else if (index.column() == isPresentColumn())\n        {\n            blockInterface_->setIsPresent(blockName, value.toString().toStdString());\n        }\n        else if (index.column() == descriptionColumn())\n        {\n            blockInterface_->setDescription(blockName, value.toString().toStdString());\n        }\n        else \n        {\n            return false;\n        }\n\n        if (index.column() == nameColumn() || index.column() == baseAddressColumn() ||\n            index.column() == isPresentColumn())\n        {\n            emit graphicsChanged(index.row());\n        }\n\n        if (index.column() == baseAddressColumn() || index.column() == isPresentColumn())\n        {\n            emit childAddressingChanged(index.row());\n        }\n\n        emit dataChanged(index, index);\n        emit contentChanged();\n        return true;\n    }\n    else \n    {\n        return false;\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: MemoryBlockModel::addressUnitBitsUpdated()\n//-----------------------------------------------------------------------------\nvoid MemoryBlockModel::addressUnitBitsUpdated(QString const& newAddressUnitBits)\n{\n    blockInterface_->setAddressUnitBits(newAddressUnitBits.toStdString());\n}\n\n//-----------------------------------------------------------------------------\n// Function: MemoryBlockModel::onAddItem()\n//-----------------------------------------------------------------------------\nvoid MemoryBlockModel::onAddItem( QModelIndex const& index )\n{\n    int row = blockInterface_->itemCount();\n\n\t// if the index is valid then add the item to the correct position\n\tif (index.isValid())\n    {\n\t\trow = index.row();\n\t}\n\n\tbeginInsertRows(QModelIndex(), row, row);\n    blockInterface_->addBlock(row);\n\tendInsertRows();\n\n\t// inform navigation tree that file set is added\n\n\temit itemAdded(row);\n\n    emit invalidateOtherFilter();\n\temit contentChanged();\n}\n\n//-----------------------------------------------------------------------------\n// Function: MemoryBlockModel::onRemoveItem()\n//-----------------------------------------------------------------------------\nvoid MemoryBlockModel::onRemoveItem( QModelIndex const& index )\n{\n\t// don't remove anything if index is invalid\n    if (!index.isValid() || index.row() < 0 || index.row() >= blockInterface_->itemCount())\n    {\n\t\treturn;\n\t}\n\n\t// remove the specified item\n\tbeginRemoveRows(QModelIndex(), index.row(), index.row());\n    removeReferencesInItemOnRow(index.row());\n    blockInterface_->removeBlock(blockInterface_->getIndexedItemName(index.row()));\n\tendRemoveRows();\n\n\t// inform navigation tree that file set has been removed\n\temit itemRemoved(index.row());\n\n    emit invalidateOtherFilter();\n\temit contentChanged();\n}\n\n//-----------------------------------------------------------------------------\n// Function: MemoryBlockModel::expressionOrValueForIndex()\n//-----------------------------------------------------------------------------\nQVariant MemoryBlockModel::expressionOrValueForIndex(QModelIndex const& index) const\n{\n    if (isValidExpressionColumn(index))\n    {\n        return expressionForIndex(index);\n    }\n    else\n    {\n        return valueForIndex(index);\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: MemoryBlockModel::validateIndex()\n//-----------------------------------------------------------------------------\nbool MemoryBlockModel::validateIndex(QModelIndex const& index) const\n{\n    std::string blockName = blockInterface_->getIndexedItemName(index.row());\n    if (blockName.empty())\n    {\n        return false;\n    }\n\n    if (index.column() == nameColumn())\n    {\n        return blockInterface_->itemHasValidName(blockName);\n    }\n    else if (index.column() == baseAddressColumn())\n    {\n        return blockInterface_->hasValidBaseAddress(blockName);\n    }\n    else if (index.column() == isPresentColumn())\n    {\n        return blockInterface_->hasValidIsPresent(blockName);\n    }\n\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: MemoryBlockModel::getAllReferencesToIdInItemOnRow()\n//-----------------------------------------------------------------------------\nint MemoryBlockModel::getAllReferencesToIdInItemOnRow(const int& row, QString const& valueID) const\n{\n    return blockInterface_->getAllReferencesToIdInItem(\n        blockInterface_->getIndexedItemName(row), valueID.toStdString());\n}\n\n//-----------------------------------------------------------------------------\n// Function: MemoryBlockModel::formattedExpressionForIndex()\n//-----------------------------------------------------------------------------\nQVariant MemoryBlockModel::formattedExpressionForIndex(QModelIndex const& index) const\n{\n    std::string blockName = blockInterface_->getIndexedItemName(index.row());\n    if (index.column() == baseAddressColumn())\n    {\n        return QString::fromStdString(blockInterface_->getBaseAddressFormattedExpression(blockName));\n    }\n    else if (index.column() == isPresentColumn())\n    {\n        return QString::fromStdString(blockInterface_->getIsPresentFormattedExpression(blockName));\n    }\n\n    return valueForIndex(index);\n}\n\n//-----------------------------------------------------------------------------\n// Function: MemoryBlockModel::expressionForIndex()\n//-----------------------------------------------------------------------------\nQVariant MemoryBlockModel::expressionForIndex(QModelIndex const& index) const\n{\n    std::string blockName = blockInterface_->getIndexedItemName(index.row());\n    if (index.column() == baseAddressColumn())\n    {\n        return QString::fromStdString(blockInterface_->getBaseAddressExpression(blockName));\n    }\n    else if (index.column() == isPresentColumn())\n    {\n        return QString::fromStdString(blockInterface_->getIsPresentExpression(blockName));\n    }\n\n    return valueForIndex(index);\n}\n\n//-----------------------------------------------------------------------------\n// Function: MemoryBlockModel::valueForIndex()\n//-----------------------------------------------------------------------------\nQVariant MemoryBlockModel::valueForIndex(QModelIndex const& index) const\n{\n    std::string blockName = blockInterface_->getIndexedItemName(index.row());\n    if (index.column() == nameColumn())\n    {\n        return QString::fromStdString(blockName);\n    }\n    else if (index.column() == descriptionColumn())\n    {\n        return QString::fromStdString(blockInterface_->getDescription(blockName));\n    }\n    else if (index.column() == baseAddressColumn())\n    {\n        return QString::fromStdString(blockInterface_->getBaseAddressValue(blockName));\n    }\n    else if (index.column() == isPresentColumn())\n    {\n        return QString::fromStdString(blockInterface_->getIsPresentValue(blockName));\n    }\n    \n    return QVariant();\n}\n\n//-----------------------------------------------------------------------------\n// Function: MemoryBlockModel::onCopyRows()\n//-----------------------------------------------------------------------------\nvoid MemoryBlockModel::onCopyRows(QModelIndexList indexList)\n{\n    std::vector<int> registerIndexes;\n    for (auto index : indexList)\n    {\n        registerIndexes.push_back(index.row());\n    }\n\n    blockInterface_->copyRows(registerIndexes);\n}\n\n//-----------------------------------------------------------------------------\n// Function: MemoryBlockModel::onPasteRows()\n//-----------------------------------------------------------------------------\nvoid MemoryBlockModel::onPasteRows()\n{\n    int rowBegin = blockInterface_->itemCount();\n\n    std::vector<std::string> pastedBlockNames = blockInterface_->pasteRows();\n    int pasteCount = static_cast<int>(pastedBlockNames.size());\n    if (pasteCount == 0)\n    {\n        return;\n    }\n\n    int rowEnd = rowBegin + pasteCount - 1;\n\n    beginInsertRows(QModelIndex(), rowBegin, rowEnd);\n\n    for (int i = rowBegin; i <= rowEnd; ++i)\n    {\n        emit itemAdded(i);\n    }\n\n    endInsertRows();\n\n    QStringList pastedExpressions;\n    for (auto expression : blockInterface_->getExpressionsInSelectedItems(pastedBlockNames))\n    {\n        pastedExpressions.append(QString::fromStdString(expression));\n    }\n    increaseReferencesInPastedExpressions(pastedExpressions);\n\n    emit contentChanged();\n}\n\n//-----------------------------------------------------------------------------\n// Function: MemoryBlockModel::increaseReferencesInPastedField()\n//-----------------------------------------------------------------------------\nvoid MemoryBlockModel::increaseReferencesInPastedExpressions(QStringList const& expressionList)\n{\n    ReferenceCalculator referenceCalculator(getParameterFinder());\n\n    QMap<QString, int> referencedParameters = referenceCalculator.getReferencedParameters(expressionList);\n\n    QMapIterator<QString, int> refParameterIterator(referencedParameters);\n    while (refParameterIterator.hasNext())\n    {\n        refParameterIterator.next();\n        for (int i = 0; i < refParameterIterator.value(); ++i)\n        {\n            emit increaseReferences(refParameterIterator.key());\n        }\n    }\n}\n"
  },
  {
    "path": "editors/ComponentEditor/memoryMaps/MemoryBlockModel.h",
    "content": "//-----------------------------------------------------------------------------\n// File: MemoryBlockModel.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 09.02.2022\n//\n// Description:\n// The parent model for editing memory blocks.\n//-----------------------------------------------------------------------------\n\n#ifndef MEMORYBLOCKMODEL_H\n#define MEMORYBLOCKMODEL_H\n\n#include <editors/ComponentEditor/common/ParameterizableTable.h>\n#include <editors/ComponentEditor/common/ReferencingTableModel.h>\n#include <KactusAPI/include/ParameterFinder.h>\n\n#include <IPXACTmodels/common/Document.h>\n\n#include <QAbstractTableModel>\n#include <QSharedPointer>\n#include <QList>\n\nclass MemoryBlockInterface;\n\n//-----------------------------------------------------------------------------\n//! The parent model for editing memory blocks.\n//-----------------------------------------------------------------------------\nclass MemoryBlockModel : public ReferencingTableModel, public ParameterizableTable\n{\n\tQ_OBJECT\n\npublic:\n\t\n\t/*!\n\t *  The constructor.\n\t *\n     *    @param [in] blockInterface      Interface for memory blocks;\n\t *    @param [in] expressionParser    Pointer to the expression parser.\n\t *    @param [in] parameterFinder     Pointer to the parameter finder.\n\t *    @param [in] docRevision         The IP-XACT standard revision in use.\n\t *    @param [in] parent              Pointer to the owner of this model.\n\t */\n    MemoryBlockModel(MemoryBlockInterface* blockInterface,\n        QSharedPointer <ExpressionParser> expressionParser,\n        QSharedPointer <ParameterFinder> parameterFinder,\n        Document::Revision docRevision,\n        QObject *parent);\n\n\t/*!\n     *  The destructor.\n     */\n    virtual ~MemoryBlockModel() = default;\n\n    //! No copying.\tNo assignment.\n    MemoryBlockModel(const MemoryBlockModel& other) = delete;\n    MemoryBlockModel& operator=(const MemoryBlockModel& other) = delete;\n\n\n\t/*!\n     *  Get the number of rows an item contains.\n\t *\n\t *    @param [in] parent  Identifies the parent that's row count is requested.\n\t *\n\t *    @return Number of rows the item has.\n\t */\n\tvirtual int rowCount(QModelIndex const& parent = QModelIndex()) const override final;\n\n\t/*!\n     *  Get the number of columns the item has to be displayed.\n\t *\n\t *    @param [in] parent  Identifies the parent that's column count is requested.\n\t *\n\t *    @return The number of columns to be displayed.\n\t */\n\tvirtual int columnCount(QModelIndex const& parent = QModelIndex()) const = 0;\n\n\t/*!\n     *  Get the item flags that defines the possible operations for the item.\n\t *\n\t *    @param [in] index   Model index that identifies the item.\n\t *\n\t *    @return Qt::ItemFlags specify the possible operations for the item.\n\t */\n\tvirtual Qt::ItemFlags flags(QModelIndex const& index) const;\n\n\t/*!\n     *  Get the header data for specified header.\n\t *\n\t *    @param [in] section         The section specifies the row/column number for the header.\n\t *    @param [in] orientation     Specified if horizontal or vertical header is wanted.\n\t *    @param [in] role            Specifies the type of the requested data.\n\t *\n\t *    @return QVariant Contains the requested data.\n\t */\n\tvirtual QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;\n\n\t/*!\n     *  Get the data for specified item.\n\t *\n\t *    @param [in] index   Specifies the item that's data is requested.\n\t *    @param [in] role    The role that defines what kind of data is requested.\n\t *\n\t *    @return QVariant Contains the data for the item.\n\t */\n\tvirtual QVariant data(QModelIndex const& index, int role = Qt::DisplayRole) const;\n\n\t/*!\n     *  Save the data to the model for specified item.\n\t *\n\t *    @param [in] index   The model index of the item that's data is to be saved.\n\t *    @param [in] value   The data that is to be saved.\n\t *    @param [in] role    The role specifies what kind of data should be saved.\n\t *\n\t *    @return True if saving happened successfully.\n\t */\n\tvirtual bool setData(QModelIndex const& index, const QVariant& value, int role = Qt::EditRole);\n    \n    /*!\n     *  Get the list of acceptable mime types.\n     *\n     *    @return The list of acceptable mime types.\n     */\n    virtual QStringList mimeTypes() const = 0;\n\n\npublic slots:\n\n\t/*!\n     *  Add a new item to the given index.\n\t *\n\t *    @param [in] index   The index identifying the position for new item.\n\t */\n\tvoid onAddItem(QModelIndex const& index);\n\n\t/*!\n     *  Remove the item in the given index.\n\t *\n\t *    @param [in] index   The index identifying the item to remove.\n\t */\n\tvoid onRemoveItem(QModelIndex const& index);\n\n    /*!\n     *  Change the current address unit bits.\n     *\n     *    @param [in] newAddressUnitBits  The new address unit bits.\n     */\n    void addressUnitBitsUpdated(QString const& newAddressUnitBits);\n\n    /*!\n     *  Copy the items in the selected rows.\n     *\n     *    @param [in] indexList   List of indexes pointing to the selected rows.\n     */\n    void onCopyRows(QModelIndexList indexList);\n\n    /*!\n     *  Paste the copied items.\n     */\n    void onPasteRows();\n\nprotected:\n\n    /*!\n     *  Gets the expression for the given index, or plain value if there is no expression.\n     *\n     *    @param [in] index   The index of the target data.\n     *\n     *    @return Expression or plain value in the given index.\n     */\n    virtual QVariant expressionOrValueForIndex(QModelIndex const& index) const;\n\n    /*!\n     *  validates the data in the column.\n     *\n     *    @param [in] index   The index being validated.\n     *\n     *    @return True, if the data is valid, otherwise false.\n     */\n    virtual bool validateIndex(QModelIndex const& index) const;\n\n    /*!\n     *  Gets the number of all the references made on the selected row to the selected parameter.\n     *\n     *    @param [in] row         The row of the selected item.\n     *    @param [in] valueID     The referenced parameter.\n     *\n     *    @return The number of references made to the parameter on the selected row.\n     */\n    virtual int getAllReferencesToIdInItemOnRow(const int& row, QString const& valueID) const;\n\n    /*!\n     *  Get the formatted value of an expression in the selected index.\n     *\n     *    @param [in] index   The selected index.\n     *\n     *    @return The formatted value of an expression in the selected index.\n     */\n    virtual QVariant formattedExpressionForIndex(QModelIndex const& index) const;\n\n    /*!\n     *  Get the expression of the selected index.\n     *\n     *    @param [in] index   The selected index.\n     *\n     *    @return The expression of the selected index.\n     */\n    virtual QVariant expressionForIndex(QModelIndex const& index) const;\n\n    /*!\n     *  Gets the value for the given index.\n     *\n     *    @param [in] index   The index of the target data.\n     *\n     *    @return The data in the given index.\n     */\n    virtual QVariant valueForIndex(QModelIndex const& index) const;\n\n    //-----------------------------------------------------------------------------\n    // Data.\n    //-----------------------------------------------------------------------------\n\n    //! The IP-XACT standard revision in use.\n    Document::Revision docRevision_;\n\nsignals:\n\n\t/*!\n     *  Emitted when the contents of the model change.\n     */\n\tvoid contentChanged();\n\n    /*!\n     *  Informs of a need to redraw the visualization.\n     *\n     *    @param [in] index   Index of the memory block graphics item.\n     */\n    void graphicsChanged(int index);\n\n\t/*!\n     *  Emitted when a new memory map item is added to the given index.\n     *\n     *    @param [in] index   Index of the new memory block item.\n     */\n\tvoid itemAdded(int index);\n\n\t/*!\n     *  Emitted when a memory map item is removed from the given index.\n     *\n     *    @param [in] index   Index of the removed memory block item.\n     */\n\tvoid itemRemoved(int index);\n\n    /*\n     *  Informs of memory block name change.\n     *\n     *    @param [in] oldName     The old name.\n     *    @param [in] newName     The new name.\n     */\n    void blockNameChanged(QString const& oldName, QString const& newName);\n\n    /*!\n     *  Invalidate the other memory block models.\n     */\n    void invalidateOtherFilter();\n\n    /*!\n     *  Informs of addressing changes in child items.\n     *\n     *    @param [in]     Index of the selected address block.\n     */\n    void childAddressingChanged(int);\n\nprivate:\n\n    /*!\n     *  Get the index of the name column.\n     *\n     *    @return Index of the name column.\n     */\n    virtual int nameColumn() const = 0;\n\n    /*!\n     *  Get the index of the base address column.\n     *\n     *    @return Index of the base address column.\n     */\n    virtual int baseAddressColumn() const = 0;\n\n    /*!\n     *  Get the index of the is present column.\n     *\n     *    @return Index of the is present column.\n     */\n    virtual int isPresentColumn() const = 0;\n\n    /*!\n     *  Get the index of the description column.\n     *\n     *    @return Index of the description column.\n     */\n    virtual int descriptionColumn() const = 0;\n\n    /*!\n     *  Increase the number of references made in the selected expressions.\n     *\n     *    @param [in] expressionList  List of expressions.\n     */\n    void increaseReferencesInPastedExpressions(QStringList const& expressionList);\n\n    //-----------------------------------------------------------------------------\n    // Data.\n    //-----------------------------------------------------------------------------\n\n    //! Interface for address blocks.\n    MemoryBlockInterface* blockInterface_;\n\n};\n\n#endif // MEMORYBLOCKMODEL_H\n"
  },
  {
    "path": "editors/ComponentEditor/memoryMaps/MemoryMapColumns.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: MemoryMapColumns.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Esko Pekkarinen\r\n// Date: 26.02.2015\r\n//\r\n// Description:\r\n// Common declarations for editing memory map table columns.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef MEMORYMAP_COLUMNS_H\r\n#define MEMORYMAP_COLUMNS_H\r\n\r\nnamespace MemoryMapColumns\r\n{\r\n    //! Defines the columns for the memory map table.\r\n    enum Column\r\n    {\r\n        NAME_COLUMN = 0,\r\n        BASE_COLUMN,\r\n        RANGE_COLUMN,\r\n        WIDTH_COLUMN,\r\n        USAGE_COLUMN,\r\n        ACCESS_COLUMN,\r\n        VOLATILE_COLUMN,\r\n        IS_PRESENT,\r\n        DESCRIPTION_COLUMN,\r\n        COLUMN_COUNT\r\n    };\r\n}\r\n\r\n#endif //MEMORYMAP_COLUMNS_H"
  },
  {
    "path": "editors/ComponentEditor/memoryMaps/MemoryMapsColumns.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: MemoryMapsColumns.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Mikko Teuho\r\n// Date: 17.04.2015\r\n//\r\n// Description:\r\n// Common declarations for columns in memory maps editor.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef MEMORYMAPS_COLUMNS_H\r\n#define MEMORYMAPS_COLUMNS_H\r\n\r\nnamespace MemoryMapsColumns\r\n{\r\n    //! Defines the columns for the memory map table.\r\n    enum Column\r\n    {\r\n        NAME_COLUMN = 0,\r\n        AUB_COLUMN,\r\n        INTERFACE_COLUMN,\r\n        REMAPSTATE_COLUMN,\r\n        IS_PRESENT,       \r\n        DESCRIPTION_COLUMN,\r\n        COLUMN_COUNT\r\n    };\r\n}\r\n\r\n#endif // MEMORYMAPS_COLUMNS_H"
  },
  {
    "path": "editors/ComponentEditor/memoryMaps/MemoryMapsView.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: MemoryMapsView.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Mikko Teuho\r\n// Date: 17.04.2015\r\n//\r\n// Description:\r\n// View for memory maps editor.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"MemoryMapsView.h\"\r\n#include \"MemoryMapsColumns.h\"\r\n\r\n#include <QMenu>\r\n#include <QKeySequence>\r\n#include <QClipboard>\r\n#include <QMessageBox>\r\n#include <QTextStream>\r\n#include <QFileDialog>\r\n#include <QSortFilterProxyModel>\r\n#include <QApplication>\r\n#include <QPainter>\r\n#include <QPen>\r\n#include <QMimeData>\r\n#include <QHeaderView>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryMapsView::MemoryMapsView()\r\n//-----------------------------------------------------------------------------\r\nMemoryMapsView::MemoryMapsView(QWidget* parent):\r\nEditableTreeView(true, QString(tr(\"Add memory map\")), QString(tr(\"Add memory remap\")), QString(tr(\"Remove row\")),\r\n    QString(tr(\"Remove all memory remaps\")), parent),\r\n    defaultImportExportPath_(), \r\n    pressedPoint_(),\r\n    copyAction_(tr(\"Copy\"), this),\r\n    pasteAction_(tr(\"Paste\"), this),\r\n    importAction_(tr(\"Import csv-file\"), this),\r\n    exportAction_(tr(\"Export csv-file\"), this),\r\n    copyRowsAction_(tr(\"Copy elements\"), this),\r\n    pasteRowsAction_(tr(\"Paste elements\"), this),\r\n    importExportable_(false)\r\n{\r\n    setAlternatingRowColors(false);\r\n\r\n    setSelectionMode(QAbstractItemView::ContiguousSelection);\r\n\r\n    setEditTriggers(QAbstractItemView::DoubleClicked | QAbstractItemView::SelectedClicked |\r\n        QAbstractItemView::EditKeyPressed | QAbstractItemView::AnyKeyPressed);\r\n\r\n    setToolTip(\"Double click to add a new memory map.\");\r\n\r\n    setupActions();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryMapsView::setAllowImportExport()\r\n//-----------------------------------------------------------------------------\r\nvoid MemoryMapsView::setAllowImportExport(bool allow)\r\n{\r\n    importExportable_ = allow;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryMapsView::setDefaultImportExportPath()\r\n//-----------------------------------------------------------------------------\r\nvoid MemoryMapsView::setDefaultImportExportPath(const QString& path)\r\n{\r\n    defaultImportExportPath_ = path;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryMapsView::keyPressEvent()\r\n//-----------------------------------------------------------------------------\r\nvoid MemoryMapsView::keyPressEvent(QKeyEvent* event)\r\n{\r\n    QTreeView::keyPressEvent(event);\r\n\r\n    if (event->matches(QKeySequence::Copy))\r\n    {\r\n        onCopyAction();\r\n    }\r\n    if (event->matches(QKeySequence::Paste))\r\n    {\r\n        onPasteAction();\r\n    }\r\n    if (event->matches(QKeySequence::InsertLineSeparator))\r\n    {\r\n        onAddItem();\r\n    }\r\n    if (event->matches(QKeySequence::Cut))\r\n    {\r\n        onCopyAction();\r\n        onRemoveSelectedItems();\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryMapsView::contextMenuEvent()\r\n//-----------------------------------------------------------------------------\r\nvoid MemoryMapsView::contextMenuEvent(QContextMenuEvent* event)\r\n{\r\n    pressedPoint_ = event->pos();\r\n\r\n    QModelIndex index = indexAt(pressedPoint_);\r\n\r\n    QMenu menu(this);\r\n\r\n    menu.addAction(getAddItemAction());\r\n    if (!index.parent().isValid() && index.isValid())\r\n    {\r\n        menu.addAction(getAddSubItemAction());\r\n    }\r\n\r\n    menu.addSeparator();\r\n\r\n    if (index.isValid())\r\n    {\r\n        menu.addAction(getRemoveAction());\r\n        if (!index.parent().isValid())\r\n        {\r\n            menu.addAction(getRemoveAllSubItemsAction());\r\n        }\r\n\r\n        menu.addSeparator();\r\n    }\r\n\r\n    menu.addAction(&pasteAction_);\r\n\r\n    if (index.isValid())\r\n    {\r\n        menu.addAction(getClearAction());\r\n        menu.addAction(&copyAction_);\r\n    }\r\n\r\n    bool validIndex = index.isValid();\r\n    bool containsCorrectMimeData = false;\r\n\r\n    const QMimeData* clipMime = QApplication::clipboard()->mimeData();\r\n    QStringList modelMimes = model()->mimeTypes();\r\n    QString remapMime = modelMimes.last();\r\n    QString mapMime = modelMimes.at(modelMimes.size() - 2);\r\n\r\n    if (clipMime->hasImage())\r\n    {\r\n        if ((index.isValid() && (clipMime->hasFormat(remapMime) || clipMime->hasFormat(mapMime))) ||\r\n            (!index.isValid() && clipMime->hasFormat(mapMime)))\r\n        {\r\n            containsCorrectMimeData = true;\r\n        }\r\n    }\r\n\r\n    if (validIndex || containsCorrectMimeData)\r\n    {\r\n        menu.addSeparator();\r\n        if (validIndex)\r\n        {\r\n            menu.addAction(&copyRowsAction_);\r\n        }\r\n        if (containsCorrectMimeData)\r\n        {\r\n            menu.addAction(&pasteRowsAction_);\r\n        }\r\n    }\r\n\r\n    if (importExportable_)\r\n    {\r\n        menu.addSeparator();\r\n        menu.addAction(&importAction_);\r\n        menu.addAction(&exportAction_);\r\n        menu.addSeparator();\r\n    }\r\n\r\n    menu.addAction(getExpandAllAction());\r\n    menu.addAction(getCollapseAllAction());\r\n\r\n    menu.exec(event->globalPos());\r\n    event->accept();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryMapsView::setupActions()\r\n//-----------------------------------------------------------------------------\r\nvoid MemoryMapsView::setupActions()\r\n{\r\n    getAddItemAction()->setToolTip(tr(\"Add a new row to the table.\"));\r\n    getAddItemAction()->setStatusTip(tr(\"Add a new row to the table.\"));\r\n\r\n    getAddSubItemAction()->setToolTip(tr(\"Add a new memory remap to the selected memory map.\"));\r\n    getAddSubItemAction()->setStatusTip(tr(\"Add a new memory remap to the selected memory map.\"));\r\n\r\n    copyAction_.setToolTip(tr(\"Copy the contents of a cell from the table.\"));\r\n    copyAction_.setStatusTip(tr(\"Copy the contents of a cell from the table.\"));\r\n    connect(&copyAction_, SIGNAL(triggered()), this, SLOT(onCopyAction()), Qt::UniqueConnection);\r\n\r\n    pasteAction_.setToolTip(tr(\"Paste the contents of a cell to the table.\"));\r\n    pasteAction_.setStatusTip(tr(\"Paste the contents of a cell to the table.\"));\r\n    connect(&pasteAction_, SIGNAL(triggered()), this, SLOT(onPasteAction()), Qt::UniqueConnection);\r\n\r\n    importAction_.setToolTip(tr(\"Import a csv-file to the table.\"));\r\n    importAction_.setStatusTip(tr(\"Import a csv-file to the table.\"));\r\n    connect(&importAction_, SIGNAL(triggered()), this, SLOT(onCSVImport()), Qt::UniqueConnection);\r\n\r\n    exportAction_.setToolTip(tr(\"Export table to a csv-file.\"));\r\n    exportAction_.setStatusTip(tr(\"Export table to a csv-file.\"));\r\n    connect(&exportAction_, SIGNAL(triggered()), this, SLOT(onCSVExport()), Qt::UniqueConnection);\r\n\r\n    copyRowsAction_.setToolTip(tr(\"Copy a row from the table\"));\r\n    copyRowsAction_.setStatusTip(tr(\"Copy a row from the table\"));\r\n    connect(&copyRowsAction_, SIGNAL(triggered()), this, SLOT(onCopyRowsAction()), Qt::UniqueConnection);\r\n\r\n    pasteRowsAction_.setToolTip(tr(\"Paste a row from the table\"));\r\n    pasteRowsAction_.setStatusTip(tr(\"Paste a row from the table\"));\r\n    connect(&pasteRowsAction_, SIGNAL(triggered()), this, SLOT(onPasteRowsAction()), Qt::UniqueConnection);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryMapsView::onCopyAction()\r\n//-----------------------------------------------------------------------------\r\nvoid MemoryMapsView::onCopyAction()\r\n{\r\n    if (currentIndex().isValid())\r\n    {\r\n        QApplication::setOverrideCursor(Qt::WaitCursor);\r\n\r\n        QModelIndexList indexes = selectedIndexes();\r\n        std::sort(indexes.begin(), indexes.end());\r\n\r\n        QString copyText;\r\n\r\n        for (int row = indexes.first().row(); row <= indexes.last().row(); ++row)\r\n        {\r\n            for (int column = indexes.first().column(); column <= indexes.last().column(); ++column)\r\n            {\r\n                QModelIndex itemToAdd = model()->index(row, column, QModelIndex());\r\n\r\n                copyText.append(model()->data(itemToAdd, Qt::DisplayRole).toString());\r\n\r\n                if (column < indexes.last().column())\r\n                {\r\n                    copyText.append(\"\\t\");\r\n                }\r\n                else\r\n                {\r\n                    copyText.append(\"\\n\");\r\n                }\r\n            }\r\n        }\r\n\r\n        QClipboard* clipBoard = QApplication::clipboard();\r\n        clipBoard->setText(copyText);\r\n        QApplication::restoreOverrideCursor();\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryMapsView::onPasteAction()\r\n//-----------------------------------------------------------------------------\r\nvoid MemoryMapsView::onPasteAction()\r\n{\r\n    QApplication::setOverrideCursor(Qt::WaitCursor);\r\n\r\n    // find the highest row to start adding to\r\n    QModelIndexList indexes = selectedIndexes();\r\n    QModelIndex posToPaste;\r\n    if (!indexes.isEmpty())\r\n    {\r\n        std::sort(indexes.begin(), indexes.end());\r\n        posToPaste = indexes.first();\r\n    }\r\n\r\n    int startRow = posToPaste.row();\r\n    int startCol = posToPaste.column();\r\n\r\n    QClipboard* clipBoard = QApplication::clipboard();\r\n    QString subtype(\"plain\");\r\n    QString pasteText = clipBoard->text(subtype);\r\n\r\n    // split the string from clip board into rows\r\n    QStringList rowsToAdd = pasteText.split(\"\\n\");\r\n\r\n    // the model containing the actual data\r\n    QAbstractItemModel* origModel = NULL;\r\n\r\n    QSortFilterProxyModel* proxyModel = qobject_cast<QSortFilterProxyModel*>(model());\r\n\r\n    // if view is connected to proxy model\r\n    if (proxyModel)\r\n    {\r\n        origModel = qobject_cast<QAbstractItemModel*>(proxyModel->sourceModel());\r\n    }\r\n    // if view is connected directly to actual model\r\n    else\r\n    {\r\n        origModel = qobject_cast<QAbstractItemModel*>(model());\r\n    }\r\n    Q_ASSERT(origModel);\r\n\r\n    foreach (QString row, rowsToAdd)\r\n    {\r\n        if (row.isEmpty())\r\n        {\r\n            continue;\r\n        }\r\n\r\n        // new row starts always on same column\r\n        int columnCounter = qMax(0, startCol);\r\n\r\n        onAddItem();\r\n\r\n        // split the row into columns\r\n        QStringList columnsToAdd = row.split(\"\\t\");\r\n        foreach (QString column, columnsToAdd)\r\n        {\r\n            QModelIndex itemToSet = origModel->index(startRow, columnCounter, QModelIndex());\r\n            // if the index is not valid then the data is written to last item\r\n            if (!itemToSet.isValid())\r\n            {\r\n                int lastRow = origModel->rowCount(QModelIndex()) - 1;\r\n\r\n                itemToSet = origModel->index(lastRow, columnCounter, QModelIndex());\r\n            }\r\n\r\n            // Check for name conflicts.\r\n            if ( columnCounter == MemoryMapsColumns::NAME_COLUMN && column.size() > 0 )\r\n            {\r\n                column = getUniqueName(column, origModel);\r\n            }\r\n\r\n            origModel->setData(itemToSet, column, Qt::EditRole);\r\n            ++columnCounter;\r\n        }\r\n\r\n        if (startRow >= 0)\r\n        {\r\n            // when row is done then increase the row counter\r\n            ++startRow;\r\n        }\r\n    }\r\n\r\n    QApplication::restoreOverrideCursor();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryMapsView::onCSVImport()\r\n//-----------------------------------------------------------------------------\r\nvoid MemoryMapsView::onCSVImport(const QString& filePath /* = QString() */)\r\n{\r\n    QString target(filePath);\r\n\r\n    if (filePath.isEmpty())\r\n    {\r\n        target = QFileDialog::getOpenFileName(this, tr(\"Open file\"), defaultImportExportPath_,\r\n            tr(\"csv-files (*.csv)\"));\r\n    }\r\n\r\n    if (target.isEmpty())\r\n    {\r\n        return;\r\n    }\r\n\r\n    QFile file(target);\r\n\r\n    // if file can not be opened \r\n    if (!file.open(QIODevice::ReadOnly | QIODevice::Text))\r\n    {\r\n        QMessageBox::critical(this, tr(\"Error opening file\"), tr(\"Could not open file %1 for reading\").arg(target));\r\n        return;\r\n    }\r\n\r\n    QApplication::setOverrideCursor(Qt::WaitCursor);\r\n\r\n    // create a stream to read from\r\n    QTextStream stream(&file);\r\n\r\n    // read the headers from the file\r\n    QString headers = stream.readLine();\r\n\r\n    // the model containing the actual data\r\n    QAbstractTableModel* origModel = NULL;\r\n\r\n    QSortFilterProxyModel* proxyModel = qobject_cast<QSortFilterProxyModel*>(model());\r\n\r\n    // if view is connected to proxy model\r\n    if (proxyModel)\r\n    {\r\n        origModel = qobject_cast<QAbstractTableModel*>(proxyModel->sourceModel());\r\n    }\r\n    // if view is connected directly to actual model\r\n    else\r\n    {\r\n        origModel = qobject_cast<QAbstractTableModel*>(model());\r\n    }\r\n    Q_ASSERT(origModel);\r\n\r\n    int columnCount = origModel->columnCount(QModelIndex());\r\n\r\n    while (!stream.atEnd())\r\n    {\r\n        QString line = stream.readLine();\r\n        QStringList columns = line.split(\";\");\r\n\r\n        // add a new empty row\r\n        onAddItem();\r\n\r\n        // data is always added to the last row\r\n        int rowCount = origModel->rowCount(QModelIndex());\r\n\r\n        for (int col = 0; col < columnCount && col < columns.size(); ++col)\r\n        {\r\n            QModelIndex index = origModel->index(rowCount - 1, col, QModelIndex());\r\n            origModel->setData(index, columns.at(col), Qt::EditRole);\r\n        }\r\n    }\r\n\r\n    file.close();\r\n\r\n    QApplication::restoreOverrideCursor();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryMapsView::onCSVExport()\r\n//-----------------------------------------------------------------------------\r\nvoid MemoryMapsView::onCSVExport(const QString& filePath /* = QString() */)\r\n{\r\n    QString target(filePath);\r\n\r\n    if (filePath.isEmpty())\r\n    {\r\n        target = QFileDialog::getSaveFileName(this, tr(\"Set name and location for csv-file\"),\r\n            defaultImportExportPath_, tr(\"csv-files (*.csv)\"));\r\n    }\r\n\r\n    if (target.isEmpty())\r\n    {\r\n        return;\r\n    }\r\n\r\n    QFile file(target);\r\n\r\n    // if file can not be opened \r\n    if (!file.open(QIODevice::Truncate | QIODevice::WriteOnly))\r\n    {\r\n        QMessageBox::critical(this, tr(\"Error opening file\"), tr(\"Could not open file %1 for writing\").arg(target));\r\n        return;\r\n    }\r\n\r\n    QApplication::setOverrideCursor(Qt::WaitCursor);\r\n\r\n    int columnCount = model()->columnCount(QModelIndex());\r\n    int rowCount = model()->rowCount(QModelIndex());\r\n\r\n    // create a stream to write into\r\n    QTextStream stream(&file);\r\n\r\n    // write the headers\r\n    for (int i = 0; i < columnCount; ++i)\r\n    {\r\n        stream << model()->headerData(i, Qt::Horizontal, Qt::DisplayRole).toString().simplified();\r\n        stream << \";\";\r\n    }\r\n    stream << Qt::endl;\r\n\r\n    // write each row\r\n    for (int row = 0; row < rowCount; ++row)\r\n    {\r\n        // write each column\r\n        for (int col = 0; col < columnCount; ++col)\r\n        {\r\n            QModelIndex index = model()->index(row, col, QModelIndex());\r\n            stream << model()->data(index, Qt::DisplayRole).toString();\r\n            stream << \";\";\r\n        }\r\n        stream << Qt::endl;\r\n    }\r\n    file.close();\r\n\r\n    QApplication::restoreOverrideCursor();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryMapsView::onCopyRowsAction()\r\n//-----------------------------------------------------------------------------\r\nvoid MemoryMapsView::onCopyRowsAction()\r\n{\r\n    // if nothing was selected then don't copy anything\r\n    if (!currentIndex().isValid())\r\n    {\r\n        return;\r\n    }\r\n\r\n    QApplication::setOverrideCursor(Qt::WaitCursor);\r\n\r\n    QModelIndexList indexList = selectedIndexes();\r\n    std::sort(indexList.begin(), indexList.end());\r\n\r\n    QSortFilterProxyModel* sortProxy = dynamic_cast<QSortFilterProxyModel*>(model());\r\n\r\n    QModelIndexList singleRowIndexList;\r\n    for (int i = 0; i < indexList.size(); i++)\r\n    {\r\n        QModelIndex index = indexList.at(i);\r\n\r\n        if (sortProxy != 0)\r\n        {\r\n            index = sortProxy->mapToSource(index);\r\n        }\r\n\r\n        singleRowIndexList.append(index);\r\n    }\r\n\r\n    emit copyRows(singleRowIndexList);\r\n\r\n    QApplication::restoreOverrideCursor();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryMapsView::onPasteRowsAction()\r\n//-----------------------------------------------------------------------------\r\nvoid MemoryMapsView::onPasteRowsAction()\r\n{\r\n    QModelIndex pasteTarget = indexAt(pressedPoint_);\r\n\r\n    QSortFilterProxyModel* sortProxy = dynamic_cast<QSortFilterProxyModel*>(model());\r\n    if (sortProxy != 0)\r\n    {\r\n        pasteTarget = sortProxy->mapToSource(pasteTarget);\r\n    }\r\n\r\n    if (pasteTarget.parent().isValid())\r\n    {\r\n        pasteTarget = pasteTarget.parent();\r\n    }\r\n\r\n    emit pasteRows(pasteTarget);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryMapsView::getUniqueName()\r\n//-----------------------------------------------------------------------------\r\nQString MemoryMapsView::getUniqueName(QString const& original, QAbstractItemModel* model)\r\n{\r\n    QString name = original;    \r\n    int trailingNumber = 1;\r\n    bool match =  true;\r\n    while ( match )\r\n    {\r\n        match = false;\r\n        for(int row = 0; row < model->rowCount(); row++ )\r\n        {\r\n            QModelIndex index = model->index(row, MemoryMapsColumns::NAME_COLUMN);\r\n            if ( name == model->data(index ,Qt::DisplayRole ).toString() )\r\n            {\r\n                match = true;\r\n                name = original + \"_\" + QString::number(trailingNumber);\r\n                trailingNumber++;\r\n                break;\r\n            }\r\n        }       \r\n    }\r\n\r\n    return name;\r\n}"
  },
  {
    "path": "editors/ComponentEditor/memoryMaps/MemoryMapsView.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: MemoryMapsView.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Mikko Teuho\r\n// Date: 17.04.2015\r\n//\r\n// Description:\r\n// View for memory maps editor.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef MEMORYMAPSVIEW_H\r\n#define MEMORYMAPSVIEW_H\r\n\r\n#include <common/views/EditableTreeView/EditableTreeView.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n//! View for memory maps editor.\r\n//-----------------------------------------------------------------------------\r\nclass MemoryMapsView : public EditableTreeView\r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\r\n    /*!\r\n\t *  The constructor.\r\n\t *\r\n\t *    @param [in] parent  Pointer to the owner of this view.\r\n\t */\r\n\tMemoryMapsView(QWidget* parent);\r\n\r\n    //! No copying. No assignment.\r\n    MemoryMapsView(const MemoryMapsView& other) = delete;\r\n    MemoryMapsView& operator=(const MemoryMapsView& other) = delete;\r\n\r\n    /*!\r\n     *  The destructor.\r\n     */\r\n    virtual ~MemoryMapsView() = default;\r\n\r\n    /*!\r\n\t *  Enable/disable the import/export csv-file functionality.\r\n\t *\r\n\t *    @param [in] allow   If true, then import/export is enabled.\r\n\t */\r\n\tvoid setAllowImportExport(bool allow);\r\n\r\npublic slots:\r\n\r\n\t/*!\r\n\t *  Create a csv-file of the editor contents.\r\n\t *\r\n\t *    @param [in] filePath    Contains an absolute file path to the file to create.\r\n\t */\r\n\tvoid onCSVExport(const QString& filePath = QString());\r\n\r\n    /*!\r\n\t *  Import contents of a csv-file to the editor.\r\n\t *\r\n\t *    @param [in] filePath    The path to the csv-file to import.\r\n\t */\r\n\tvoid onCSVImport(const QString& filePath = QString());\r\n\r\n    /*!\r\n\t *  Set the default path to use for import/export csv.\r\n\t *\r\n\t *    @param [in] path    The path to tuse ad default.\r\n\t */\r\n\tvoid setDefaultImportExportPath(const QString& path);\r\n\r\nsignals:\r\n\r\n    /*!\r\n     *  Copy the selected rows.\r\n     *\r\n     *    @param [in] indexList   List of selected indexes containing the copied rows.\r\n     */\r\n    void copyRows(QModelIndexList indexList);\r\n\r\n    /*!\r\n     *  Paste the copied rows.\r\n     *\r\n     *    @param [in] targetIndex     The target of the paste action.\r\n     */\r\n    void pasteRows(QModelIndex targetIndex);\r\n\r\nprotected:\r\n\r\n    /*!\r\n\t *  Handles keypress events for copy, paste, cut, delete and line separator insertion.\r\n\t *\r\n\t *    @param [in] event   The key event.\r\n\t */\r\n\tvirtual void keyPressEvent(QKeyEvent* event) override final;\r\n\r\n\t/*!\r\n\t *  Creates a context menu for adding/removing/editing items in the editor.\r\n\t *\r\n\t *    @param [in] event   The context menu event.\r\n\t */\r\n\tvirtual void contextMenuEvent(QContextMenuEvent* event) override final;\r\n\r\nprivate slots:\r\n\r\n\t/*!\r\n\t *  Copies the text contained in the item.\r\n\t */\r\n\tvoid onCopyAction();\r\n\r\n\t/*!\r\n\t *  Pastes the text from clipboard to the item.\r\n\t */\r\n\tvoid onPasteAction();\r\n\r\n    /*!\r\n     *  Handler for element copy action.\r\n     */\r\n    void onCopyRowsAction();\r\n\r\n    /*!\r\n     *  Handler for element paste action.\r\n     */\r\n    void onPasteRowsAction();\r\n\r\nprivate:\r\n\r\n\t/*!\r\n\t *  Set up the actions for the context menu.\r\n\t */\r\n\tvoid setupActions();\r\n\r\n    /*!\r\n    *  Generates a unique name within the table for the item.\r\n    *\r\n    *    @param [in] original     The original name of the item.\r\n    *    @param [in] model        The model of this view.\r\n    *\r\n    *    @return Unique name for the item.\r\n    */\r\n    QString getUniqueName(QString const& original, QAbstractItemModel* model);\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n\t//! The default path to use for import/export csv\r\n\tQString defaultImportExportPath_;\r\n\r\n    //! The point where mouse was clicked\r\n    QPoint pressedPoint_;\r\n\r\n    //! Action for copying item texts.\r\n    QAction copyAction_;\r\n\r\n    //! Action for pasting item texts.\r\n    QAction pasteAction_;\r\n\r\n    //! Action for importing a csv-file.\r\n    QAction importAction_;\r\n\r\n    //! Action for exporting a csv-file.\r\n    QAction exportAction_;\r\n\r\n    //! The action to copy an element.\r\n    QAction copyRowsAction_;\r\n\r\n    //! The action to paste an element.\r\n    QAction pasteRowsAction_;\r\n\r\n    //! Specifies if the items can be imported/exported to a csv file..\r\n    bool importExportable_;\r\n};\r\n\r\n#endif // MEMORYMAPSVIEW_H\r\n"
  },
  {
    "path": "editors/ComponentEditor/memoryMaps/RegisterColumns.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: RegisterColumns.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Mikko Teuho\r\n// Date: 09.02.2015\r\n//\r\n// Description:\r\n// Common declarations for editing register table columns.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef REGISTER_COLUMNS_H\r\n#define REGISTER_COLUMNS_H\r\n\r\nnamespace RegisterColumns\r\n{\r\n    //! Defines the columns for the register table.\r\n    enum Column\r\n    {\r\n        NAME_COLUMN = 0,\r\n        OFFSET_COLUMN,\r\n        WIDTH_COLUMN,\r\n        RESETS_COLUMN,\r\n        VOLATILE_COLUMN,\r\n        ACCESS_COLUMN,\r\n        MOD_WRITE_COLUMN,\r\n        READ_ACTION_COLUMN,\r\n        TESTABLE_COLUMN,\r\n        TEST_CONSTR_COLUMN,\r\n        IS_PRESENT_COLUMN,\r\n        DESCRIPTION_COLUMN,\r\n        COLUMN_COUNT\r\n    };\r\n}\r\n\r\n#endif //REGISTER_COLUMNS_H"
  },
  {
    "path": "editors/ComponentEditor/memoryMaps/RegisterFileColumns.h",
    "content": "//-----------------------------------------------------------------------------\n// File: RegisterFileColumns.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Esko Pekkarinen\n// Date: 12.10.2018\n//\n// Description:\n// Common declarations for editing register files table columns.\n//-----------------------------------------------------------------------------\n\n#ifndef REGISTER_FILE_COLUMNS_H\n#define REGISTER_FILE_COLUMNS_H\n\nnamespace RegisterFileColumns\n{\n    //! Defines the columns for the register files table.\n    enum Column\n    {\n        NAME = 0,\n        ADDRESS_OFFSET,\n        RANGE,\n        DIMENSION,\n        IS_PRESENT,\n        DESCRIPTION,\n        COLUMN_COUNT\n    };\n}\n\n#endif //REGISTER_FILE_COLUMNS_H\n"
  },
  {
    "path": "editors/ComponentEditor/memoryMaps/RemapModeReferenceEditor.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: RemapModeReferenceEditor.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Anton Hagqvist\n// Date: 17.10.2023\n//\n// Description:\n// Editor for remap mode references.\n//-----------------------------------------------------------------------------\n\n#include \"RemapModeReferenceEditor.h\"\n\n#include <editors/ComponentEditor/common/ModeReferenceEditor.h>\n#include <KactusAPI/include/ModeReferenceInterface.h>\n\n#include <QVBoxLayout>\n\n//-----------------------------------------------------------------------------\n// Function: RemapModeReferenceEditor::RemapModeReferenceEditor()\n//-----------------------------------------------------------------------------\nRemapModeReferenceEditor::RemapModeReferenceEditor(ModeReferenceInterface* modeRefInterface, QWidget* parent, bool isRemap):\n    GroupBoxWithAlertSign(tr(\"Mode references\"), parent),\n    modeReferencesEditor_(new ModeReferenceEditor(modeRefInterface, parent)),\n\tmodeRefInterface_(modeRefInterface)\n{\n    auto topLayout = new QVBoxLayout(this);\n    topLayout->addWidget(modeReferencesEditor_);\n\n    modeReferencesEditor_->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);\n\n    connect(modeReferencesEditor_, SIGNAL(contentChanged()), this, SIGNAL(contentChanged()), Qt::UniqueConnection);\n    if (isRemap)\n    {\n        connect(modeReferencesEditor_, SIGNAL(contentChanged()), this, SLOT(checkForAlert()), Qt::UniqueConnection);\n        checkForAlert();\n    }\n}\n\nvoid RemapModeReferenceEditor::checkForAlert()\n{\n    if (modeRefInterface_->areAllModeReferencesValid())\n    {        \n        removeAlertIcon();\n    }\n    else \n    {\n        setAlertIcon();\n    }\n}"
  },
  {
    "path": "editors/ComponentEditor/memoryMaps/RemapModeReferenceEditor.h",
    "content": "//-----------------------------------------------------------------------------\n// File: RemapModeReferenceEditor.h\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Anton Hagqvist\n// Date: 17.10.2023\n//\n// Description:\n// Editor for remap mode references.\n//-----------------------------------------------------------------------------\n\n#ifndef REMAPMODEREFERENCEEDITOR_H\n#define REMAPMODEREFERENCEEDITOR_H\n\n#include <KactusAPI/include/MemoryMapInterface.h>\n#include <common/widgets/GroupBoxWithAlertSign/GroupBoxWithAlertSign.h>\n\n#include <QGroupBox>\n\nclass ModeReferenceEditor;\nclass MemoryRemapModeReferenceModel;\n\n\nclass RemapModeReferenceEditor : public GroupBoxWithAlertSign\n{\n    Q_OBJECT\n\npublic:\n\n    /*!\n     *\tThe constructor.\n     *  \n     *    @param [in] modeRefInterface    The mode reference interface to use.\n     *    @param [in] parent              The parent widget.\n     */\n    RemapModeReferenceEditor(ModeReferenceInterface* modeRefInterface, QWidget* parent, bool isRemap);\n\n    virtual ~RemapModeReferenceEditor() = default;\n\n    //! No copying.\n    RemapModeReferenceEditor(RemapModeReferenceEditor& other) = delete;\n    RemapModeReferenceEditor& operator=(RemapModeReferenceEditor& other) = delete;\n\nsignals:\n\n    /*!\n     *\tEmitted whenever a mode reference has been edited.\n     */\n    void contentChanged();\nprivate slots:\n\n    /*!\n     *\tChecks if it is needed to display alert sign in GroupBoxWithAlertSign\n     */\n    void checkForAlert();\n\nprivate:\n\n    //! The mode reference table editor.\n    ModeReferenceEditor* modeReferencesEditor_;\n\n    //! The mode reference interface.\n    ModeReferenceInterface* modeRefInterface_;\n};\n\n#endif // REMAPMODEREFERENCEEDITOR_H\n"
  },
  {
    "path": "editors/ComponentEditor/memoryMaps/ResetColumns.h",
    "content": "//-----------------------------------------------------------------------------\n// File: ResetColumns.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 11.01.2019\n//\n// Description:\n// Common declarations for editing resets of register fields.\n//-----------------------------------------------------------------------------\n\n#ifndef RESETCOLUMNS_H\n#define RESETCOLUMNS_H\n\nnamespace ResetColumns\n{\n    //! Defines the columns for the field resets.\n    enum columns\n    {\n        RESETTYPEREFERENCE_COLUMN = 0,\n        RESETVALUE_COLUMN,\n        RESETMASK_COLUMN,\n        COLUMN_COUNT\n    };\n}\n\n#endif // RESETCOLUMNS_H"
  },
  {
    "path": "editors/ComponentEditor/memoryMaps/ResetsDelegate.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: ResetsDelegate.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 11.01.2019\n//\n// Description:\n// The delegate to provide editors to add/remove/edit the resets of a field.\n//-----------------------------------------------------------------------------\n\n#include \"ResetsDelegate.h\"\n\n#include <IPXACTmodels/Component/ResetType.h>\n\n#include <editors/ComponentEditor/memoryMaps/ResetColumns.h>\n\n#include <QComboBox>\n\n//-----------------------------------------------------------------------------\n// Function: ResetsDelegate::ResetsDelegate()\n//-----------------------------------------------------------------------------\nResetsDelegate::ResetsDelegate(QAbstractItemModel* completionModel, QSharedPointer<ParameterFinder> parameterFinder,\n    QSharedPointer<QList<QSharedPointer<ResetType>>> resetTypes, QObject *parent):\nExpressionDelegate(completionModel, parameterFinder, parent),\nresetTypes_(resetTypes)\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: ResetsDelegate::~ResetsDelegate()\n//-----------------------------------------------------------------------------\nResetsDelegate::~ResetsDelegate()\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: ResetsDelegate::createEditor()\n//-----------------------------------------------------------------------------\nQWidget* ResetsDelegate::createEditor( QWidget* parent, const QStyleOptionViewItem& option,\n    const QModelIndex& index ) const \n{\n    if (index.column() == ResetColumns::RESETTYPEREFERENCE_COLUMN)\n    {\n        return createResetTypeCombo(parent);\n    }\n    else\n    {\n        return ExpressionDelegate::createEditor(parent, option, index);\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: ResetsDelegate::createResetTypeCombo()\n//-----------------------------------------------------------------------------\nQComboBox* ResetsDelegate::createResetTypeCombo(QWidget* parent) const\n{\n    QComboBox* resetTypeCombo = new QComboBox(parent);\n    resetTypeCombo->addItem(\"\");\n\n    for (auto resetType : *resetTypes_)\n    {\n        resetTypeCombo->addItem(resetType->name());\n    }\n\n    return resetTypeCombo;\n}\n\n//-----------------------------------------------------------------------------\n// Function: ResetsDelegate::setEditorData()\n//-----------------------------------------------------------------------------\nvoid ResetsDelegate::setEditorData( QWidget* editor, const QModelIndex& index ) const\n{\n    if (index.column() == ResetColumns::RESETTYPEREFERENCE_COLUMN)\n    {\n        QComboBox* resetTypeCombo = qobject_cast<QComboBox*>(editor);\n\n        QString value = index.model()->data(index, Qt::DisplayRole).toString();\n        resetTypeCombo->setCurrentText(value);\n    }\n    else\n    {\n        ExpressionDelegate::setEditorData(editor, index);\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: ResetsDelegate::setModelData()\n//-----------------------------------------------------------------------------\nvoid ResetsDelegate::setModelData( QWidget* editor, QAbstractItemModel* model, const QModelIndex& index ) const \n{\n    if (index.column() == ResetColumns::RESETTYPEREFERENCE_COLUMN)\n    {\n        QComboBox* resetTypeCombo = qobject_cast<QComboBox*>(editor);\n\n        QString newResetType = resetTypeCombo->currentText();\n        model->setData(index, newResetType, Qt::EditRole);\n    }\n    else\n    {\n        ExpressionDelegate::setModelData(editor, model, index);\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: ResetsDelegate::columnAcceptsExpression()\n//-----------------------------------------------------------------------------\nbool ResetsDelegate::columnAcceptsExpression(int column) const\n{\n    return column == ResetColumns::RESETVALUE_COLUMN || column == ResetColumns::RESETMASK_COLUMN;\n}\n\n//-----------------------------------------------------------------------------\n// Function: ResetsDelegate::descriptionColumn()\n//-----------------------------------------------------------------------------\nint ResetsDelegate::descriptionColumn() const\n{\n    return ResetColumns::COLUMN_COUNT;\n}\n\n//-----------------------------------------------------------------------------\n// Function: ResetsDelegate::commitAndCloseEditor()\n//-----------------------------------------------------------------------------\nvoid ResetsDelegate::commitAndCloseEditor()\n{\n\tQWidget* edit = qobject_cast<QWidget*>(sender());\n\tQ_ASSERT(edit);\n\n\temit commitData(edit);\n\temit closeEditor(edit);\n}\n"
  },
  {
    "path": "editors/ComponentEditor/memoryMaps/ResetsDelegate.h",
    "content": "//-----------------------------------------------------------------------------\n// File: ResetsDelegate.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 11.01.2019\n//\n// Description:\n// The delegate to provide editors to add/remove/edit the resets of a field.\n//-----------------------------------------------------------------------------\n\n#ifndef RESETSDELEGATE_H\n#define RESETSDELEGATE_H\n\n#include <QStyledItemDelegate>\n#include <QEvent>\n\n#include <KactusAPI/include/ParameterFinder.h>\n#include <editors/ComponentEditor/common/ExpressionDelegate.h>\n\nclass ResetType;\nclass QComboBox;\n\n//-----------------------------------------------------------------------------\n//! The delegate to provide editors to add/remove/edit the resets of a field.\n//-----------------------------------------------------------------------------\nclass ResetsDelegate : public ExpressionDelegate\n{\n    Q_OBJECT\n\npublic:\n\n\t/*!\n\t *  The constructor.\n\t *\n     *    @param [in] completionModel         Model containing the completions used in expression editor.\n\t *    @param [in] parameterFinder         The parameter finder to use for expression editor.\n     *    @param [in] resetTypes              The reset types of the containing component.\n\t *    @param [in] parent                  Pointer to the owner of the delegate.\n\t */\n    ResetsDelegate(QAbstractItemModel* completionModel, QSharedPointer<ParameterFinder> parameterFinder,\n        QSharedPointer<QList<QSharedPointer<ResetType> > > resetTypes, QObject *parent);\n\t\n\t/*!\n     *  The destructor.\n     */\n    virtual ~ResetsDelegate();\n\n\t/*!\n     *  Create a new editor for the given item.\n\t *\n\t *    @param [in] parent  Owner for the editor.\n\t *    @param [in] option  Contains options for the editor.\n\t *    @param [in] index   Model index identifying the item.\n\t *\n\t *    @return Pointer to the editor to be used to edit the item.\n\t */\n\tvirtual QWidget* createEditor(QWidget* parent, \tconst QStyleOptionViewItem& option, QModelIndex const& index)\n        const;\n\n\t/*!\n     *  Set the data for the editor.\n\t *\n\t *    @param [in] editor  Pointer to the editor where the data is to be set.\n\t *    @param [in] index   Model index identifying the item that's data is to be set.\n\t */\n\tvirtual void setEditorData(QWidget* editor, const QModelIndex& index) const;\n\n\t/*!\n     *  Save the data from the editor to the model.\n\t *\n\t *    @param [in] editor  Pointer to the editor that contains the data to store.\n\t *    @param [in] model   Model that contains the data structure where data is to be saved to.\n\t *    @param [in] index   Model index identifying the item that's data is to be saved.\n\t */\n\tvirtual void setModelData(QWidget* editor, QAbstractItemModel* model, const QModelIndex& index) const;\n\nprotected:\n\n    /*!\n     *  Checks if the given column supports expressions in the editor.\n     *\n     *    @param [in] column  The column to check.\n     *\n     *    @return True if the cells in the column allow expressions, otherwise false.\n     */\n    virtual bool columnAcceptsExpression(int column) const;\n\n    /*!\n     *  Gets the description column (Mandatory for expression delegate, returns columncount).\n     */\n    virtual int descriptionColumn() const;\n\nprivate slots:\n\n\t/*!\n     *  Commit the data from the sending editor and close the editor.\n\t */\n\tvoid commitAndCloseEditor();\n\nprivate:\n\t\n\t//! No copying. No assignment.\n\tResetsDelegate(const ResetsDelegate& other);\n    ResetsDelegate& operator=(const ResetsDelegate& other);\n\n    /*!\n     *  Create the combo box for reset type reference editor.\n     *\n     *    @param [in] parent  Parent for the editor.\n     *\n     *    @return Pointer to the created reset type reference editor.\n     */\n    QComboBox* createResetTypeCombo(QWidget* parent) const;\n\n    //-----------------------------------------------------------------------------\n    // Data.\n    //-----------------------------------------------------------------------------\n\n    //! The reset types of the containing component.\n    QSharedPointer<QList<QSharedPointer<ResetType> > > resetTypes_;\n};\n\n#endif // RESETSDELEGATE_H\n"
  },
  {
    "path": "editors/ComponentEditor/memoryMaps/ResetsEditor.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: ResetsEditor.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 11.01.2019\n//\n// Description:\n// Editor for editing the resets of a field.\n//-----------------------------------------------------------------------------\n\n#include \"ResetsEditor.h\"\n\n#include <common/views/EditableTableView/editabletableview.h>\n\n#include <editors/ComponentEditor/parameters/ComponentParameterModel.h>\n#include <editors/ComponentEditor/memoryMaps/ResetsModel.h>\n#include <editors/ComponentEditor/memoryMaps/ResetsDelegate.h>\n#include <KactusAPI/include/ResetInterface.h>\n\n#include <QCompleter>\n#include <QVBoxLayout>\n\n//-----------------------------------------------------------------------------\n// Function: ResetsEditor::ResetsEditor()\n//-----------------------------------------------------------------------------\nResetsEditor::ResetsEditor(ResetInterface* resetInterface,\n    QSharedPointer<QList<QSharedPointer<ResetType>>> resetTypes, QSharedPointer<ExpressionParser> expressionParser,\n    QSharedPointer<ParameterFinder> parameterFinder, QSharedPointer<Field> containingField, QWidget* parent):\nQGroupBox(tr(\"Resets\"), parent),\nresetsView_(new EditableTableView(this)),\nresetsProxy_(new QSortFilterProxyModel(this)),\nresetsModel_(new ResetsModel(resetInterface, expressionParser, parameterFinder, this)),\ncontainingField_(containingField),\ninterface_(resetInterface)\n{\n    interface_->setResets(containingField_);\n\n\tQVBoxLayout* layout = new QVBoxLayout(this);\n    layout->addWidget(resetsView_, 0);\n\n    resetsProxy_->setSourceModel(resetsModel_);\n\tresetsView_->setModel(resetsProxy_);\n\n\tresetsView_->setItemsDraggable(false);\n\tresetsView_->setSortingEnabled(true);\n\n    ComponentParameterModel* parametersModel = new ComponentParameterModel(parameterFinder, this);\n    parametersModel->setExpressionParser(expressionParser);\n\n    resetsView_->setItemDelegate(new ResetsDelegate(parametersModel, parameterFinder, resetTypes, this));\n\n\tconnect(resetsModel_, SIGNAL(contentChanged()), this, SIGNAL(contentChanged()), Qt::UniqueConnection);\n\tconnect(resetsView_, SIGNAL(addItem(const QModelIndex&)),\n\t\tresetsModel_, SLOT(onAddItem(const QModelIndex&)), Qt::UniqueConnection);\n\tconnect(resetsView_, SIGNAL(removeItem(const QModelIndex&)),\n        resetsModel_, SLOT(onRemoveItem(const QModelIndex&)), Qt::UniqueConnection);\n\n    connect(resetsView_->itemDelegate(), SIGNAL(increaseReferences(QString)),\n        this, SIGNAL(increaseReferences(QString)), Qt::UniqueConnection);\n    connect(resetsView_->itemDelegate(), SIGNAL(decreaseReferences(QString)),\n        this, SIGNAL(decreaseReferences(QString)), Qt::UniqueConnection);\n\n    connect(resetsModel_, SIGNAL(decreaseReferences(QString)),\n        this, SIGNAL(decreaseReferences(QString)), Qt::UniqueConnection);\n    connect(resetsModel_, SIGNAL(increaseReferences(QString)),\n        this, SIGNAL(increaseReferences(QString)), Qt::UniqueConnection);\n}\n\n//-----------------------------------------------------------------------------\n// Function: ResetsEditor::~ResetsEditor()\n//-----------------------------------------------------------------------------\nResetsEditor::~ResetsEditor()\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: ResetsEditor::refresh()\n//-----------------------------------------------------------------------------\nvoid ResetsEditor::refresh()\n{\n\tresetsView_->update();\n\n    interface_->setResets(containingField_);\n}\n"
  },
  {
    "path": "editors/ComponentEditor/memoryMaps/ResetsEditor.h",
    "content": "//-----------------------------------------------------------------------------\n// File: ResetsEditor.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 11.01.2019\n//\n// Description:\n// Editor for editing the resets of a field.\n//-----------------------------------------------------------------------------\n\n#ifndef RESETSEDITOR_H\n#define RESETSEDITOR_H\n\n#include <QSharedPointer>\n#include <QSortFilterProxyModel>\n#include <QGroupBox>\n\nclass ExpressionParser;\nclass ParameterFinder;\nclass ExpressionFormatter;\n\nclass EditableTableView;\nclass ResetsModel;\n\nclass FieldReset;\nclass FieldValidator;\nclass ResetType;\n\nclass ResetInterface;\n\nclass Field;\n\n//-----------------------------------------------------------------------------\n//! Editor for editing the resets of a field.\n//-----------------------------------------------------------------------------\nclass ResetsEditor : public QGroupBox\n{\n\tQ_OBJECT\n\npublic:\n\n\t/*!\n\t *  The constructor.\n\t *\n     *    @param [in] resetInterface      Interface for resets.\n     *    @param [in] resetTypes          List of reset types within the containing component.\n     *    @param [in] expressionParser    The expression parser.\n     *    @param [in] parameterFinder     Component parameter finder.\n     *    @param [in] containingField     Field containing the resets.\n\t *    @param [in] parent              Pointer to the parent of this editor.\n\t */\n    ResetsEditor(ResetInterface* resetInterface, QSharedPointer<QList<QSharedPointer<ResetType> > > resetTypes,\n        QSharedPointer<ExpressionParser> expressionParser, QSharedPointer<ParameterFinder> parameterFinder,\n        QSharedPointer<Field> containingField, QWidget* parent = 0);\n\n\t/*!\n\t *  The destructor.\n\t */\n    virtual ~ResetsEditor();\n\n\t/*!\n\t *  Reload the information from the model to the editor.\n\t */\n\tvirtual void refresh();\n\nsignals:\n\n    /*!\n     *  Informs of changes to the component editor tree.\n     */\n    void contentChanged();\n\n    /*!\n     *  Increase the number of references made to the selected parameter.\n     *\n     *    @param [in] id  ID of the selected parameter.\n     */\n    void increaseReferences(QString const& id);\n\n    /*!\n     *  Decrease the number of references made to the selected parameter.\n     *\n     *    @param [in] id  ID of the selected parameter.\n     */\n    void decreaseReferences(QString const& id);\n\nprivate:\n\t\n\t//! No copying. No assignment.\n\tResetsEditor(const ResetsEditor& other);\n    ResetsEditor& operator=(const ResetsEditor& other);\n\n\t//! The view to display the resets.\n\tEditableTableView* resetsView_;\n\n\t//! The proxy that does the sorting of resets.\n\tQSortFilterProxyModel* resetsProxy_;\n\n\t//! The model that manages the resets.\n    ResetsModel* resetsModel_;\n\n    //! Field containing the resets.\n    QSharedPointer<Field> containingField_;\n\n    //! Interface for accessing resets.\n    ResetInterface* interface_;\n};\n\n#endif // RESETSEDITOR_H\n"
  },
  {
    "path": "editors/ComponentEditor/memoryMaps/ResetsModel.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: ResetsModel.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 11.01.2019\n//\n// Description:\n// The model to manage the resets of a field.\n//-----------------------------------------------------------------------------\n\n#include \"ResetsModel.h\"\n\n#include <editors/ComponentEditor/memoryMaps/ResetColumns.h>\n#include <KactusAPI/include/ResetInterface.h>\n\n#include <common/KactusColors.h>\n\n//-----------------------------------------------------------------------------\n// Function: ResetsModel::ResetsModel()\n//-----------------------------------------------------------------------------\nResetsModel::ResetsModel(ResetInterface* resetInterface, QSharedPointer<ExpressionParser> expressionParser,\n    QSharedPointer<ParameterFinder> parameterFinder, QObject *parent):\nReferencingTableModel(parameterFinder, parent),\nParameterizableTable(parameterFinder),\nresetInterface_(resetInterface)\n{\n    setExpressionParser(expressionParser);\n}\n\n//-----------------------------------------------------------------------------\n// Function: ResetsModel::~ResetsModel()\n//-----------------------------------------------------------------------------\nResetsModel::~ResetsModel()\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: ResetsModel::rowCount()\n//-----------------------------------------------------------------------------\nint ResetsModel::rowCount(const QModelIndex& parent) const\n{\n    if (parent.isValid())\n    {\n        return 0;\n    }\n    return resetInterface_->itemCount();\n}\n\n//-----------------------------------------------------------------------------\n// Function: ResetsModel::columnCount()\n//-----------------------------------------------------------------------------\nint ResetsModel::columnCount(const QModelIndex& parent) const\n{\n    if (parent.isValid())\n    {\n        return 0;\n    }\n\n    return ResetColumns::COLUMN_COUNT;\n}\n\n//-----------------------------------------------------------------------------\n// Function: ResetsModel::flags()\n//-----------------------------------------------------------------------------\nQt::ItemFlags ResetsModel::flags(const QModelIndex& index) const\n{\n    if (!index.isValid())\n    {\n        return Qt::NoItemFlags;\n    }\n    else\n    {\n        return Qt::ItemIsEnabled | Qt::ItemIsEditable | Qt::ItemIsSelectable;\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: ResetsModel::headerData()\n//-----------------------------------------------------------------------------\nQVariant ResetsModel::headerData(int section, Qt::Orientation orientation, int role) const\n{\n    if (orientation == Qt::Horizontal && role == Qt::DisplayRole)\n    {\n        if (section == ResetColumns::RESETTYPEREFERENCE_COLUMN)\n        {\n            return tr(\"Reset type\\nreference\");\n        }\n        else if (section == ResetColumns::RESETVALUE_COLUMN)\n        {\n            return tr(\"Reset\\nvalue\") + getExpressionSymbol();\n        }\n        else if (section == ResetColumns::RESETMASK_COLUMN)\n        {\n            return tr(\"Reset\\nmask\") + getExpressionSymbol();\n        }\n    }\n\n    return QVariant();\n}\n\n//-----------------------------------------------------------------------------\n// Function: ResetsModel::data()\n//-----------------------------------------------------------------------------\nQVariant ResetsModel::data(const QModelIndex& index, int role) const\n{\n    if (!index.isValid())\n    {\n        return QVariant();\n    }\n    else if (index.row() < 0 || index.row() >= resetInterface_->itemCount())\n    {\n        return QVariant();\n    }\n\n    if (Qt::DisplayRole == role)\n    {\n        if (isValidExpressionColumn(index))\n        {\n            return formattedExpressionForIndex(index);\n        }\n        else\n        {\n            return valueForIndex(index);\n        }\n    }\n    else if (role == Qt::EditRole)\n    {\n        return expressionOrValueForIndex(index);\n    }\n    else if (role == Qt::ToolTipRole)\n    {\n        return valueForIndex(index);\n    }\n    else if (Qt::ForegroundRole == role)\n    {\n        if (validateIndex(index))\n        {\n            return KactusColors::REGULAR_TEXT;\n        }\n        else\n        {\n            return KactusColors::ERROR;\n        }\n    }\n    else if (Qt::BackgroundRole == role)\n    {\n        if (index.column() == ResetColumns::RESETVALUE_COLUMN)\n        {\n            return KactusColors::MANDATORY_FIELD;\n        }\n        else\n        {\n            return KactusColors::REGULAR_FIELD;\n        }\n    }\n    else\n    {\n        return QVariant();\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: ResetsModel::formattedExpressionForIndex()\n//-----------------------------------------------------------------------------\nQVariant ResetsModel::formattedExpressionForIndex(QModelIndex const& index) const\n{\n    if (index.column() == ResetColumns::RESETVALUE_COLUMN)\n    {\n        return QString::fromStdString(resetInterface_->getResetValueFormattedExpression(index.row()));\n    }\n    else if (index.column() == ResetColumns::RESETMASK_COLUMN)\n    {\n        return QString::fromStdString(resetInterface_->getResetMaskFormattedExpression(index.row()));\n    }\n\n    return QVariant();\n}\n\n//-----------------------------------------------------------------------------\n// Function: ResetsModel::expressionForIndex()\n//-----------------------------------------------------------------------------\nQVariant ResetsModel::expressionForIndex(QModelIndex const& index) const\n{\n    if (index.column() == ResetColumns::RESETVALUE_COLUMN)\n    {\n        return QString::fromStdString(resetInterface_->getResetValueExpression(index.row()));\n    }\n    else if (index.column() == ResetColumns::RESETMASK_COLUMN)\n    {\n        return QString::fromStdString(resetInterface_->getResetMaskExpression(index.row()));\n    }\n\n    return QVariant();\n}\n\n//-----------------------------------------------------------------------------\n// Function: ResetsModel::valueForIndex()\n//-----------------------------------------------------------------------------\nQVariant ResetsModel::valueForIndex(QModelIndex const& index) const\n{\n    if (index.column() == ResetColumns::RESETTYPEREFERENCE_COLUMN)\n    {\n        std::string resetType = resetInterface_->getResetTypeReference(index.row());\n        return QString::fromStdString(resetType);\n    }\n    else if (index.column() == ResetColumns::RESETVALUE_COLUMN)\n    {\n        return QString::fromStdString(resetInterface_->getResetValue(index.row()));\n    }\n    else if (index.column() == ResetColumns::RESETMASK_COLUMN)\n    {\n        return QString::fromStdString(resetInterface_->getResetMaskValue(index.row()));\n    }\n    else\n    {\n        return QVariant();\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: ResetsModel::setData()\n//-----------------------------------------------------------------------------\nbool ResetsModel::setData(QModelIndex const& index, QVariant const& value, int role)\n{\n    if (!index.isValid() || index.row() < 0 || index.row() >= resetInterface_->itemCount())\n    {\n        return false;\n    }\n\n    if (role == Qt::EditRole)\n    {\n        int indexRow = index.row();\n        std::string newValue = value.toString().toStdString();\n\n        if (index.column() == ResetColumns::RESETTYPEREFERENCE_COLUMN)\n        {\n            resetInterface_->setResetTypeReference(indexRow, newValue);\n        }\n        else if (index.column() == ResetColumns::RESETVALUE_COLUMN)\n        {\n            if (!value.isValid())\n            {\n                removeReferencesFromSingleExpression(\n                    QString::fromStdString(resetInterface_->getResetValueExpression(indexRow)));\n            }\n\n            resetInterface_->setResetValue(indexRow, newValue);\n        }\n        else if (index.column() == ResetColumns::RESETMASK_COLUMN)\n        {\n            if (!value.isValid())\n            {\n                removeReferencesFromSingleExpression(\n                    QString::fromStdString(resetInterface_->getResetMaskExpression(indexRow)));\n            }\n\n            resetInterface_->setResetMask(indexRow, newValue);\n        }\n        else\n        {\n            return false;\n        }\n\n        emit dataChanged(index, index);\n        emit contentChanged();\n        return true;\n    }\n    else\n    {\n        return false;\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: ResetsModel::isValidExpressionColumn()\n//-----------------------------------------------------------------------------\nbool ResetsModel::isValidExpressionColumn(QModelIndex const& index) const\n{\n    if (index.column() == ResetColumns::RESETVALUE_COLUMN || index.column() == ResetColumns::RESETMASK_COLUMN)\n    {\n        return true;\n    }\n    else\n    {\n        return false;\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: ResetsModel::expressionOrValueForIndex()\n//-----------------------------------------------------------------------------\nQVariant ResetsModel::expressionOrValueForIndex(QModelIndex const& index) const\n{\n    if (isValidExpressionColumn(index))\n    {\n        return expressionForIndex(index);\n    }\n    else\n    {\n        return valueForIndex(index).toString();\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: ResetsModel::validateIndex()\n//-----------------------------------------------------------------------------\nbool ResetsModel::validateIndex(QModelIndex const& index) const\n{\n    if (index.column() == ResetColumns::RESETTYPEREFERENCE_COLUMN)\n    {\n        return resetInterface_->hasValidResetType(index.row());\n    }\n    else if (index.column() == ResetColumns::RESETVALUE_COLUMN)\n    {\n        return resetInterface_->hasValidResetValue(index.row());\n    }\n    else if (index.column() == ResetColumns::RESETMASK_COLUMN)\n    {\n        return resetInterface_->hasValidResetMask(index.row());\n    }\n\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: ResetsModel::getAllReferencesToIdInItemOnRow()\n//-----------------------------------------------------------------------------\nint ResetsModel::getAllReferencesToIdInItemOnRow(const int& row, QString const& valueID) const\n{\n    return resetInterface_->getAllReferencesToIdInItem(\n        resetInterface_->getResetTypeReference(row), valueID.toStdString());\n}\n\n//-----------------------------------------------------------------------------\n// Function: ResetsModel::onAddItem()\n//-----------------------------------------------------------------------------\nvoid ResetsModel::onAddItem(const QModelIndex& index)\n{\n    int row = resetInterface_->itemCount();\n\n    if (index.isValid())\n    {\n        row = index.row();\n    }\n\n    beginInsertRows(QModelIndex(), row, row);\n    resetInterface_->addReset(row);\n    endInsertRows();\n\n    emit contentChanged();\n}\n\n//-----------------------------------------------------------------------------\n// Function: ResetsModel::onRemoveItem()\n//-----------------------------------------------------------------------------\nvoid ResetsModel::onRemoveItem(const QModelIndex& index)\n{\n    if (!index.isValid())\n    {\n        return;\n    }\n    else if (index.row() < 0 || index.row() >= resetInterface_->itemCount())\n    {\n        return;\n    }\n\n    beginRemoveRows(QModelIndex(), index.row(), index.row());\n\n    removeReferencesInItemOnRow(index.row());\n    resetInterface_->removeReset(index.row());\n    endRemoveRows();\n\n    emit contentChanged();\n}\n"
  },
  {
    "path": "editors/ComponentEditor/memoryMaps/ResetsModel.h",
    "content": "//-----------------------------------------------------------------------------\n// File: ResetsModel.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 11.01.2019\n//\n// Description:\n// The model to manage the resets of a field.\n//-----------------------------------------------------------------------------\n\n#ifndef RESETSMODEL_H\n#define RESETSMODEL_H\n\n#include <editors/ComponentEditor/common/ParameterizableTable.h>\n#include <editors/ComponentEditor/common/ReferencingTableModel.h>\n#include <KactusAPI/include/ParameterFinder.h>\n#include <KactusAPI/include/ExpressionFormatter.h>\n\n#include <QSharedPointer>\n#include <QList>\n\nclass ResetInterface;\n\n//-----------------------------------------------------------------------------\n//! The model to manage the resets of a field.\n//-----------------------------------------------------------------------------\nclass ResetsModel : public ReferencingTableModel, public ParameterizableTable\n{\n    Q_OBJECT\n\npublic:\n\n    /*!\n     *  The constructor.\n     *\n     *    @param [in] resetInterface      Interface for resets.\n     *    @param [in] expressionParser    Pointer to the expression parser.\n     *    @param [in] parameterFinder     Pointer to the parameter finder.\n     *    @param [in] parent              Pointer to the owner of the model.\n     */\n    ResetsModel(ResetInterface* resetInterface, QSharedPointer <ExpressionParser> expressionParser,\n        QSharedPointer <ParameterFinder> parameterFinder, QObject *parent);\n\n    /*!\n     *  The destructor.\n     */\n    virtual ~ResetsModel();\n\n    /*!\n     *  Get the number of rows an item contains.\n     *\n     *    @param [in] parent  Identifies the parent that's row count is requested.\n     *\n     *    @return Number of rows the item has.\n     */\n    virtual int rowCount(const QModelIndex& parent = QModelIndex()) const;\n\n    /*!\n     *  Get the number of columns the item has to be displayed.\n     *\n     *    @param [in] parent  Identifies the parent that's column count is requested.\n     *\n     *    @return The number of columns to be displayed.\n     */\n    virtual int columnCount(const QModelIndex& parent = QModelIndex()) const;\n\n    /*!\n     *  Get the item flags that defines the possible operations for the item.\n     *\n     *    @param [in] index   Model index that identifies the item.\n     *\n     *    @return Qt::ItemFlags specify the possible operations for the item.\n     */\n    Qt::ItemFlags flags(const QModelIndex& index) const;\n\n    /*!\n     *  Get the header data for specified header.\n     *\n     *    @param [in] section         The section specifies the row/column number for the header.\n     *    @param [in] orientation     Specified if horizontal or vertical header is wanted.\n     *    @param [in] role            Specifies the type of the requested data.\n     *\n     *    @return QVariant Contains the requested data.\n     */\n    virtual QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;\n\n    /*!\n     *  Get the data for specified item.\n     *\n     *    @param [in] index   Specifies the item that's data is requested.\n     *    @param [in] role    The role that defines what kind of data is requested.\n     *\n     *    @return QVariant Contains the data for the item.\n     */\n    virtual QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const;\n\n    /*!\n     *  Save the data to the model for specified item.\n     *\n     *    @param [in] index   The model index of the item that's data is to be saved.\n     *    @param [in] value   The data that is to be saved.\n     *    @param [in] role    The role specifies what kind of data should be saved.\n     *\n     *    @return True if saving happened successfully.\n     */\n    bool setData(const QModelIndex& index, const QVariant& value, int role = Qt::EditRole);\n\nprotected:\n\n    /*!\n     *  Check if the column index is valid for expressions.\n     *\n     *    @param [in] index   The index being evaluated.\n     *\n     *    @return     True, if column can have expressions, otherwise false.\n     */\n    virtual bool isValidExpressionColumn(QModelIndex const& index) const;\n\n    /*!\n     *  Gets the expression for the given index, or plain value if there is no expression.\n     *\n     *    @param [in] index   The index of target data.\n     *\n     *    @return     Expression or plain value in the given index.\n     */\n    virtual QVariant expressionOrValueForIndex(QModelIndex const& index) const;\n\n    /*!\n     *  Validates the data in the column.\n     *\n     *    @param [in] index   The index being validated.\n     *\n     *    @return     True, if the data is valid, otherwise false.\n     */\n    virtual bool validateIndex(QModelIndex const& index) const;\n\n    /*!\n     *  Gets the number of all the references made on the selected row to the selected parameter.\n     *\n     *    @param [in] row         The row of the selected item.\n     *    @param [in] valueID     The selected parameter.\n     *\n     *    @return The amount of references made on the selected row to the selected parameter.\n     */\n    virtual int getAllReferencesToIdInItemOnRow(const int& row, QString const& valueID) const;\n\n    public slots:\n\n    /*!\n     *  Add a new item to the given index.\n     *\n     *    @param [in] index   The index identifying the position for new item.\n     */\n    virtual void onAddItem(const QModelIndex& index);\n\n    /*!\n     *  Remove the item in the given index.\n     *\n     *    @param [in] index   The index identifying the item to remove.\n     */\n    virtual void onRemoveItem(const QModelIndex& index);\n\nsignals:\n\n    /*!\n     *  Emitted when the contents of the model change.\n     */\n    void contentChanged();\n\nprivate:\n\n    //! No copying. No assignment.\n    ResetsModel(const ResetsModel& other);\n    ResetsModel& operator=(const ResetsModel& other);\n    \n    /*!\n     *  Get the formatted value of an expression in the selected index.\n     *\n     *    @param [in] index   The selected index.\n     *\n     *    @return The formatted value of an expression in the selected index.\n     */\n    virtual QVariant formattedExpressionForIndex(QModelIndex const& index) const;\n\n    /*!\n     *  Get the expression of the selected index.\n     *\n     *    @param [in] index   The selected index.\n     *\n     *    @return The expression of the selected index.\n     */\n    virtual QVariant expressionForIndex(QModelIndex const& index) const;\n\n    /*!\n     *  Gets the value for the given index.\n     *\n     *    @param [in] index   The index of target data.\n     *\n     *    @return     The data in the given index.\n     */\n    QVariant valueForIndex(QModelIndex const& index) const;\n\n    //-----------------------------------------------------------------------------\n    // Data.\n    //-----------------------------------------------------------------------------\n\n    //! Interface for resets.\n    ResetInterface* resetInterface_;\n};\n\n#endif // RESETSMODEL_H\n"
  },
  {
    "path": "editors/ComponentEditor/memoryMaps/SingleAddressBlockEditor.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: SingleAddressBlockEditor.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Mikko Teuho\r\n// Date: 23.04.2015\r\n//\r\n// Description:\r\n// Editor for editing the details of a single address block.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"SingleAddressBlockEditor.h\"\r\n\r\n#include \"registerfileeditor.h\"\r\n\r\n#include <common/widgets/usageComboBox/usagecombobox.h>\r\n#include <common/widgets/accessComboBox/accesscombobox.h>\r\n#include <common/widgets/booleanComboBox/booleancombobox.h>\r\n\r\n#include <editors/ComponentEditor/common/ExpressionEditor.h>\r\n#include <KactusAPI/include/ExpressionFormatter.h>\r\n#include <KactusAPI/include/ExpressionParser.h>\r\n#include <editors/ComponentEditor/parameters/ComponentParameterModel.h>\r\n#include <editors/ComponentEditor/memoryMaps/AccessPoliciesEditor.h>\r\n#include <KactusAPI/include/AddressBlockInterface.h>\r\n#include <KactusAPI/include/RegisterInterface.h>\r\n\r\n#include <IPXACTmodels/Component/MemoryMapBase.h>\r\n#include <IPXACTmodels/Component/validators/AddressBlockValidator.h>\r\n#include <IPXACTmodels/Component/validators/RegisterFileValidator.h>\r\n\r\n#include <QFormLayout>\r\n#include <QScrollArea>\r\n#include <QSplitter>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SingleAddressBlockEditor::SingleAddressBlockEditor()\r\n//-----------------------------------------------------------------------------\r\nSingleAddressBlockEditor::SingleAddressBlockEditor(AddressBlockInterface* blockInterface,\r\n    QSharedPointer<AddressBlock> addressBlock,\r\n    QSharedPointer<MemoryMapBase> containingMap,\r\n    QSharedPointer<Component> component, LibraryInterface* handler,\r\n    QSharedPointer<ParameterFinder> parameterFinder, QSharedPointer<ExpressionFormatter> expressionFormatter,\r\n    QSharedPointer<ExpressionParser> expressionParser, QSharedPointer<AddressBlockValidator> addressBlockValidator,\r\n    QWidget* parent):\r\nItemEditor(component, handler, parent),\r\nnameEditor_(addressBlock, component->getRevision(), this, tr(\"Address block name and description\")),\r\nusageEditor_(),\r\nbaseAddressEditor_(new ExpressionEditor(parameterFinder, this)),\r\nrangeEditor_(new ExpressionEditor(parameterFinder, this)),\r\nwidthEditor_(new ExpressionEditor(parameterFinder, this)),\r\nisPresentEditor_(new ExpressionEditor(parameterFinder, this)),\r\naccessEditor_(),\r\nvolatileEditor_(),\r\nregistersEditor_(new AddressBlockEditor(addressBlock->getRegisterData(), blockInterface->getSubInterface(),\r\n    component, handler, parameterFinder, this)),\r\nregisterFilesEditor_(new RegisterFileEditor(addressBlock->getRegisterData(), component, handler,\r\n    parameterFinder, expressionFormatter, addressBlockValidator->getRegisterFileValidator(), this)),\r\nblockName_(addressBlock->name().toStdString()),\r\nblockInterface_(blockInterface),\r\ncontainingMap_(containingMap),\r\nexpressionParser_(expressionParser),\r\naccessPoliciesEditor_(new AccessPoliciesEditor(addressBlock->getAccessPolicies(), \r\n    blockInterface->getSubInterface()->getAccessPolicyInterface(), this))\r\n{\r\n    blockInterface_->setMemoryBlocks(containingMap_->getMemoryBlocks());\r\n\r\n    baseAddressEditor_->setFixedHeight(ExpressionEditor::DEFAULT_HEIGHT);\r\n    rangeEditor_->setFixedHeight(ExpressionEditor::DEFAULT_HEIGHT);\r\n    widthEditor_->setFixedHeight(ExpressionEditor::DEFAULT_HEIGHT);\r\n    isPresentEditor_->setFixedHeight(ExpressionEditor::DEFAULT_HEIGHT);\r\n\r\n    ComponentParameterModel* componentParametersModel = new ComponentParameterModel(parameterFinder, this);\r\n    componentParametersModel->setExpressionParser(expressionParser_);\r\n\r\n    auto baseAddressEditorCompleter = new QCompleter(this);\r\n    baseAddressEditorCompleter->setModel(componentParametersModel);\r\n\r\n    auto rangeEditorCompleter = new QCompleter(this);\r\n    rangeEditorCompleter->setModel(componentParametersModel);\r\n\r\n    auto widthEditorCompleter = new QCompleter(this);\r\n    widthEditorCompleter->setModel(componentParametersModel);\r\n    \r\n    auto isPresentEditorCompleter = new QCompleter(this);\r\n    isPresentEditorCompleter->setModel(componentParametersModel);\r\n\r\n    baseAddressEditor_->setAppendingCompleter(baseAddressEditorCompleter);\r\n    rangeEditor_->setAppendingCompleter(rangeEditorCompleter);\r\n    widthEditor_->setAppendingCompleter(widthEditorCompleter);\r\n    isPresentEditor_->setAppendingCompleter(isPresentEditorCompleter);\r\n\r\n    setupLayout();\r\n\r\n    connectSignals();\r\n\r\n    baseAddressEditor_->setProperty(\"mandatoryField\", true);\r\n    rangeEditor_->setProperty(\"mandatoryField\", true);\r\n    widthEditor_->setProperty(\"mandatoryField\", true);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SingleAddressBlockEditor::showEvent()\r\n//-----------------------------------------------------------------------------\r\nvoid SingleAddressBlockEditor::showEvent(QShowEvent* event)\r\n{\r\n    QWidget::showEvent(event);\r\n\r\n    if (component()->getRevision() == Document::Revision::Std22)\r\n    {\r\n        emit helpUrlRequested(\"componenteditor/addressblock2022.html\");\r\n    }\r\n    else\r\n    {\r\n        emit helpUrlRequested(\"componenteditor/addressblock.html\");\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SingleAddressBlockEditor::refresh()\r\n//-----------------------------------------------------------------------------\r\nvoid SingleAddressBlockEditor::refresh()\r\n{\r\n    blockInterface_->setMemoryBlocks(containingMap_->getMemoryBlocks());\r\n\r\n    nameEditor_.refresh();\r\n    registersEditor_->refresh();\r\n\r\n    accessPoliciesEditor_->refresh();\r\n\r\n    General::Usage usage = blockInterface_->getUsage(blockName_);\r\n    registersEditor_->setEnabled(blockInterface_->hasRegisters(blockName_) || (usage != General::RESERVED));\r\n    registerFilesEditor_->setEnabled(blockInterface_->hasRegisters(blockName_) || (usage != General::RESERVED));\r\n\r\n    // Block signals from here for the duration of refreshing editors.\r\n    blockSignals(true);\r\n\r\n    usageEditor_->setCurrentValue(usage);\r\n\r\n    changeExpressionEditorSignalBlockStatus(true);\r\n\r\n    baseAddressEditor_->setExpression(\r\n        QString::fromStdString(blockInterface_->getBaseAddressExpression(blockName_)));\r\n    baseAddressEditor_->setToolTip(\r\n        QString::fromStdString(blockInterface_->getBaseAddressValue(blockName_)));\r\n\r\n    rangeEditor_->setExpression(QString::fromStdString(blockInterface_->getRangeExpression(blockName_)));\r\n    rangeEditor_->setToolTip(QString::fromStdString(blockInterface_->getRangeValue(blockName_)));\r\n\r\n    widthEditor_->setExpression(QString::fromStdString(blockInterface_->getWidthExpression(blockName_)));\r\n    widthEditor_->setToolTip(QString::fromStdString(blockInterface_->getWidthValue(blockName_)));\r\n\r\n    isPresentEditor_->setExpression(QString::fromStdString(blockInterface_->getIsPresentExpression(blockName_)));\r\n    isPresentEditor_->setToolTip(QString::fromStdString(blockInterface_->getIsPresentValue(blockName_)));\r\n\r\n    changeExpressionEditorSignalBlockStatus(false);\r\n\r\n    accessEditor_->setCurrentValue(blockInterface_->getAccess(blockName_));\r\n    volatileEditor_->setCurrentValue(QString::fromStdString(blockInterface_->getVolatile(blockName_)));\r\n\r\n    blockSignals(false);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SingleAddressBlockEditor::onBaseAddressChanged()\r\n//-----------------------------------------------------------------------------\r\nvoid SingleAddressBlockEditor::onBaseAddressChanged()\r\n{\r\n    baseAddressEditor_->finishEditingCurrentWord();\r\n\r\n    blockInterface_->setBaseAddress(blockName_, baseAddressEditor_->getExpression().toStdString());\r\n    baseAddressEditor_->setToolTip(QString::fromStdString(blockInterface_->getBaseAddressValue(blockName_)));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SingleAddressBlockEditor::onRangeChanged()\r\n//-----------------------------------------------------------------------------\r\nvoid SingleAddressBlockEditor::onRangeChanged()\r\n{\r\n    rangeEditor_->finishEditingCurrentWord();\r\n\r\n    blockInterface_->setRange(blockName_, rangeEditor_->getExpression().toStdString());\r\n    rangeEditor_->setToolTip(QString::fromStdString(blockInterface_->getRangeValue(blockName_)));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SingleAddressBlockEditor::onWidthChanged()\r\n//-----------------------------------------------------------------------------\r\nvoid SingleAddressBlockEditor::onWidthChanged()\r\n{\r\n    widthEditor_->finishEditingCurrentWord();\r\n\r\n    blockInterface_->setWidth(blockName_, widthEditor_->getExpression().toStdString());\r\n    widthEditor_->setToolTip(QString::fromStdString(blockInterface_->getWidthValue(blockName_)));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SingleRegisterEditor::onIsPresentEdited()\r\n//-----------------------------------------------------------------------------\r\nvoid SingleAddressBlockEditor::onIsPresentEdited()\r\n{\r\n    isPresentEditor_->finishEditingCurrentWord();\r\n\r\n    blockInterface_->setIsPresent(blockName_, isPresentEditor_->getExpression().toStdString());\r\n    isPresentEditor_->setToolTip(\r\n        QString::fromStdString(blockInterface_->getIsPresentValue(blockName_)));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SingleAddressBlockEditor::formattedValueFor()\r\n//-----------------------------------------------------------------------------\r\nQString SingleAddressBlockEditor::formattedValueFor(QString const& expression) const\r\n{\r\n    return ExpressionFormatter::format(expression, expressionParser_);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SingleAddressBlockEditor::onUsageSelected()\r\n//-----------------------------------------------------------------------------\r\nvoid SingleAddressBlockEditor::onUsageSelected(QString const& newUsage)\r\n{\r\n    General::Usage usage = General::str2Usage(newUsage, General::USAGE_COUNT);\r\n\r\n    blockInterface_->setUsage(blockName_, newUsage.toStdString());\r\n    registersEditor_->setEnabled(blockInterface_->hasRegisters(blockName_) || (usage != General::RESERVED));\r\n    registerFilesEditor_->setEnabled(blockInterface_->hasRegisters(blockName_) || (usage != General::RESERVED));\r\n\r\n    emit contentChanged();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SingleAddressBlockEditor::onAccessSelected()\r\n//-----------------------------------------------------------------------------\r\nvoid SingleAddressBlockEditor::onAccessSelected(QString const& newAccess)\r\n{\r\n    blockInterface_->setAccess(blockName_, newAccess.toStdString());\r\n\r\n    emit contentChanged();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SingleAddressBlockEditor::onVolatileSelected()\r\n//-----------------------------------------------------------------------------\r\nvoid SingleAddressBlockEditor::onVolatileSelected(QString const& newVolatileValue)\r\n{\r\n    blockInterface_->setVolatile(blockName_, newVolatileValue.toStdString());\r\n\r\n    emit contentChanged();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SingleAddressBlockEditor::setupLayout()\r\n//-----------------------------------------------------------------------------\r\nvoid SingleAddressBlockEditor::setupLayout()\r\n{\r\n    QScrollArea* scrollArea = new QScrollArea(this);\r\n    scrollArea->setWidgetResizable(true);\r\n    scrollArea->setFrameShape(QFrame::NoFrame);\r\n\r\n    QHBoxLayout* scrollLayout = new QHBoxLayout(this);\r\n    scrollLayout->addWidget(scrollArea);\r\n    scrollLayout->setContentsMargins(0, 0, 0, 0);\r\n\r\n    QGroupBox* addressBlockDefinitionGroup = new QGroupBox(tr(\"Address block definition\"));\r\n\r\n    QFormLayout* addressBlockDefinitionLayout = new QFormLayout(addressBlockDefinitionGroup);\r\n\r\n    addressBlockDefinitionLayout->addRow(tr(\"Base Address [AUB], f(x):\"), baseAddressEditor_);\r\n    addressBlockDefinitionLayout->addRow(tr(\"Range [AUB], f(x):\"), rangeEditor_);\r\n    addressBlockDefinitionLayout->addRow(tr(\"Width [bits], f(x):\"), widthEditor_);\r\n    \r\n    volatileEditor_ = new BooleanComboBox(addressBlockDefinitionGroup);\r\n    usageEditor_ = new UsageComboBox(addressBlockDefinitionGroup);\r\n    accessEditor_ = new AccessComboBox(addressBlockDefinitionGroup);\r\n\r\n    if (component()->getRevision() == Document::Revision::Std14)\r\n    {\r\n        addressBlockDefinitionLayout->addRow(tr(\"Is present, f(x):\"), isPresentEditor_);\r\n        addressBlockDefinitionLayout->addRow(tr(\"Volatile:\"), volatileEditor_);\r\n        addressBlockDefinitionLayout->addRow(tr(\"Usage:\"), usageEditor_);\r\n        addressBlockDefinitionLayout->addRow(tr(\"Access:\"), accessEditor_);\r\n    }\r\n    else\r\n    {\r\n        addressBlockDefinitionLayout->addRow(tr(\"Usage:\"), usageEditor_);\r\n        addressBlockDefinitionLayout->addRow(tr(\"Volatile:\"), volatileEditor_);\r\n\r\n        auto spacer = new QWidget();\r\n        spacer->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Expanding);\r\n        addressBlockDefinitionLayout->addRow(spacer);\r\n\r\n        isPresentEditor_->setVisible(false);\r\n        accessEditor_->setVisible(false);\r\n    }\r\n    \r\n    QLayout* topOfPageLayout;\r\n\r\n    if (component()->getRevision() == Document::Revision::Std14)\r\n    {\r\n        QHBoxLayout* oldStdLayout = new QHBoxLayout();\r\n        oldStdLayout->addWidget(&nameEditor_, 0);\r\n        oldStdLayout->addWidget(addressBlockDefinitionGroup, 0);\r\n        topOfPageLayout = oldStdLayout;\r\n    }\r\n    else //if (component()->getRevision() == Document::Revision::Std22)\r\n    {\r\n        QGridLayout* newStdLayout = new QGridLayout();\r\n\r\n        newStdLayout->addWidget(&nameEditor_, 0, 0, 2, 1);\r\n        newStdLayout->addWidget(addressBlockDefinitionGroup, 0, 1);\r\n        newStdLayout->addWidget(accessPoliciesEditor_, 1, 1);\r\n\r\n        newStdLayout->setRowStretch(0, 1);\r\n        newStdLayout->setRowStretch(1, 2);\r\n\r\n        topOfPageLayout = newStdLayout;\r\n    }\r\n\r\n    QWidget* topOfPageWidget = new QWidget();\r\n    topOfPageWidget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);\r\n    topOfPageWidget->setLayout(topOfPageLayout);\r\n    topOfPageWidget->setContentsMargins(0, 0, 0, 0);\r\n\r\n    QSplitter* verticalSplitter = new QSplitter(Qt::Vertical, scrollArea);\r\n    verticalSplitter->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);\r\n    verticalSplitter->addWidget(topOfPageWidget);\r\n    verticalSplitter->addWidget(registersEditor_);\r\n    verticalSplitter->addWidget(registerFilesEditor_);\r\n    verticalSplitter->setStretchFactor(0, 4);\r\n    verticalSplitter->setStretchFactor(1, 5);\r\n    verticalSplitter->setStretchFactor(2, 5);\r\n\r\n    for (int i = 1; i <= 2; ++i)\r\n    {\r\n        QSplitterHandle* handle = verticalSplitter->handle(i);\r\n        QVBoxLayout* handleLayout = new QVBoxLayout(handle);\r\n        handleLayout->setSpacing(0);\r\n        handleLayout->setContentsMargins(0, 0, 0, 0);\r\n\r\n        QFrame* line = new QFrame(handle);\r\n        line->setLineWidth(2);\r\n        line->setMidLineWidth(2);\r\n        line->setFrameShape(QFrame::HLine);\r\n        line->setFrameShadow(QFrame::Sunken);\r\n        handleLayout->addWidget(line);\r\n    }\r\n\r\n    verticalSplitter->setHandleWidth(10);\r\n\r\n    scrollArea->setWidget(verticalSplitter);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SingleAddressBlockEditor::connectSignals()\r\n//-----------------------------------------------------------------------------\r\nvoid SingleAddressBlockEditor::connectSignals() const\r\n{\r\n    connect(registersEditor_, SIGNAL(childAdded(int)), this, SIGNAL(childAdded(int)), Qt::UniqueConnection);\r\n    connect(registersEditor_, SIGNAL(childRemoved(int)), this, SIGNAL(childRemoved(int)), Qt::UniqueConnection);\r\n    connect(registersEditor_, SIGNAL(increaseReferences(QString)),\r\n        this, SIGNAL(increaseReferences(QString)), Qt::UniqueConnection);\r\n    connect(registersEditor_, SIGNAL(decreaseReferences(QString)),\r\n        this, SIGNAL(decreaseReferences(QString)), Qt::UniqueConnection);\r\n\r\n    connect(registersEditor_, SIGNAL(registerNameChanged(QString const&, QString const&)),\r\n        this, SIGNAL(registerNameChanged(QString const&, QString const&)), Qt::UniqueConnection);\r\n\r\n    connect(registerFilesEditor_, SIGNAL(childAdded(int)), this, SIGNAL(childAdded(int)), Qt::UniqueConnection);\r\n    connect(registerFilesEditor_, SIGNAL(childRemoved(int)), this, SIGNAL(childRemoved(int)), Qt::UniqueConnection);\r\n    connect(registerFilesEditor_, SIGNAL(increaseReferences(QString)),\r\n        this, SIGNAL(increaseReferences(QString)), Qt::UniqueConnection);\r\n    connect(registerFilesEditor_, SIGNAL(decreaseReferences(QString)),\r\n        this, SIGNAL(decreaseReferences(QString)), Qt::UniqueConnection);\r\n\r\n    connect(baseAddressEditor_, SIGNAL(increaseReference(QString)),\r\n        this, SIGNAL(increaseReferences(QString)), Qt::UniqueConnection);\r\n    connect(baseAddressEditor_, SIGNAL(decreaseReference(QString)),\r\n        this, SIGNAL(decreaseReferences(QString)), Qt::UniqueConnection);\r\n    connect(rangeEditor_, SIGNAL(increaseReference(QString)),\r\n        this, SIGNAL(increaseReferences(QString)), Qt::UniqueConnection);\r\n    connect(rangeEditor_, SIGNAL(decreaseReference(QString)),\r\n        this, SIGNAL(decreaseReferences(QString)), Qt::UniqueConnection);\r\n    connect(widthEditor_, SIGNAL(increaseReference(QString)),\r\n        this, SIGNAL(increaseReferences(QString)), Qt::UniqueConnection);\r\n    connect(widthEditor_, SIGNAL(decreaseReference(QString)),\r\n        this, SIGNAL(decreaseReferences(QString)), Qt::UniqueConnection);\r\n    connect(isPresentEditor_, SIGNAL(increaseReference(QString)),\r\n        this, SIGNAL(increaseReferences(QString)), Qt::UniqueConnection);\r\n    connect(isPresentEditor_, SIGNAL(decreaseReference(QString)),\r\n        this, SIGNAL(decreaseReferences(QString)), Qt::UniqueConnection);\r\n\r\n    connect(baseAddressEditor_, SIGNAL(editingFinished()), this, SLOT(onBaseAddressChanged()), Qt::UniqueConnection);    \r\n    connect(rangeEditor_, SIGNAL(editingFinished()), this, SLOT(onRangeChanged()), Qt::UniqueConnection);\r\n    connect(widthEditor_, SIGNAL(editingFinished()), this, SLOT(onWidthChanged()), Qt::UniqueConnection);\r\n\r\n    connect(&nameEditor_, SIGNAL(contentChanged()), this, SIGNAL(contentChanged()), Qt::UniqueConnection);\r\n    connect(registersEditor_, SIGNAL(contentChanged()), this, SIGNAL(contentChanged()), Qt::UniqueConnection);\r\n    connect(registerFilesEditor_, SIGNAL(contentChanged()), this, SIGNAL(contentChanged()), Qt::UniqueConnection);\r\n    connect(baseAddressEditor_, SIGNAL(editingFinished()), this, SIGNAL(contentChanged()), Qt::UniqueConnection);\r\n    connect(rangeEditor_, SIGNAL(editingFinished()), this, SIGNAL(contentChanged()), Qt::UniqueConnection);\r\n    connect(widthEditor_, SIGNAL(editingFinished()), this, SIGNAL(contentChanged()), Qt::UniqueConnection);\r\n\r\n    connect(&nameEditor_, SIGNAL(nameChanged()), this, SIGNAL(graphicsChanged()), Qt::UniqueConnection);\r\n    connect(registersEditor_, SIGNAL(graphicsChanged(int)), this, SIGNAL(childGraphicsChanged(int)), Qt::UniqueConnection);\r\n    connect(registersEditor_, SIGNAL(childAddressingChanged(int)), this, SIGNAL(childAddressingChanged(int)), Qt::UniqueConnection);    \r\n\r\n    connect(registerFilesEditor_, SIGNAL(graphicsChanged(int)), this, SIGNAL(childGraphicsChanged(int)), Qt::UniqueConnection);\r\n    connect(registerFilesEditor_, SIGNAL(childAddressingChanged(int)), this, SIGNAL(childAddressingChanged(int)), Qt::UniqueConnection);\r\n\r\n    connect(baseAddressEditor_, SIGNAL(editingFinished()), this, SIGNAL(graphicsChanged()), Qt::UniqueConnection);\r\n    connect(baseAddressEditor_, SIGNAL(editingFinished()), this, SIGNAL(addressingChanged()), Qt::UniqueConnection);\r\n    \r\n    connect(rangeEditor_, SIGNAL(editingFinished()), this, SIGNAL(graphicsChanged()), Qt::UniqueConnection);\r\n    connect(rangeEditor_, SIGNAL(editingFinished()), this, SIGNAL(addressingChanged()), Qt::UniqueConnection);\r\n\r\n    connect(widthEditor_, SIGNAL(editingFinished()), this, SIGNAL(graphicsChanged()), Qt::UniqueConnection);\r\n    connect(widthEditor_, SIGNAL(editingFinished()), this, SIGNAL(addressingChanged()), Qt::UniqueConnection);\r\n\r\n    connect(isPresentEditor_, SIGNAL(editingFinished()), this, SLOT(onIsPresentEdited()), Qt::UniqueConnection);\r\n    connect(isPresentEditor_, SIGNAL(editingFinished()), this, SIGNAL(contentChanged()), Qt::UniqueConnection);\r\n    connect(isPresentEditor_, SIGNAL(editingFinished()), this, SIGNAL(addressingChanged()), Qt::UniqueConnection);\r\n\r\n    connect(&nameEditor_, SIGNAL(nameChanged()), this, SLOT(onAddressBlockNameChanged()), Qt::UniqueConnection);\r\n\r\n    connect(this, SIGNAL(addressUnitBitsChanged(int)),\r\n        registersEditor_, SIGNAL(addressUnitBitsChanged(int)), Qt::UniqueConnection);\r\n    connect(this, SIGNAL(addressUnitBitsChanged(int)),\r\n        registerFilesEditor_, SIGNAL(addressUnitBitsChanged(int)), Qt::UniqueConnection);\r\n    connect(registerFilesEditor_, SIGNAL(childAddressingChanged(int)), this, SIGNAL(childAddressingChanged(int)), Qt::UniqueConnection);\r\n\r\n    connect(usageEditor_, SIGNAL(currentTextChanged(QString const&)),\r\n        this, SLOT(onUsageSelected(QString const&)), Qt::UniqueConnection);\r\n\r\n    connect(accessEditor_, SIGNAL(currentTextChanged(QString const&)),\r\n        this, SLOT(onAccessSelected(QString const&)), Qt::UniqueConnection);\r\n\r\n    connect(volatileEditor_, SIGNAL(currentTextChanged(QString const&)),\r\n        this, SLOT(onVolatileSelected(QString const&)), Qt::UniqueConnection);\r\n\r\n    connect(accessPoliciesEditor_, SIGNAL(contentChanged()), this, SIGNAL(contentChanged()), Qt::UniqueConnection);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SingleAddressBlockEditor::changeExpressionEditorSignalBlocks()\r\n//-----------------------------------------------------------------------------\r\nvoid SingleAddressBlockEditor::changeExpressionEditorSignalBlockStatus(bool blockStatus)\r\n{\r\n    baseAddressEditor_->blockSignals(blockStatus);\r\n    rangeEditor_->blockSignals(blockStatus);\r\n    widthEditor_->blockSignals(blockStatus);\r\n    isPresentEditor_->blockSignals(blockStatus);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SingleAddressBlockEditor::onAddressBlockNameChanged()\r\n//-----------------------------------------------------------------------------\r\nvoid SingleAddressBlockEditor::onAddressBlockNameChanged(QString const& oldName, QString const& newName)\r\n{\r\n    if (oldName == QString::fromStdString(blockName_))\r\n    {\r\n        blockName_ = newName.toStdString();\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SingleAddressBlockEditor::onAddressBlockNameChanged()\r\n//-----------------------------------------------------------------------------\r\nvoid SingleAddressBlockEditor::onAddressBlockNameChanged()\r\n{\r\n    blockName_ = nameEditor_.name().toStdString();\r\n}\r\n"
  },
  {
    "path": "editors/ComponentEditor/memoryMaps/SingleAddressBlockEditor.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: SingleAddressBlockEditor.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Mikko Teuho\r\n// Date: 23.04.2015\r\n//\r\n// Description:\r\n// Editor for editing the details of a single address block.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef SINGLEADDRESSBLOCKEDITOR_H\r\n#define SINGLEADDRESSBLOCKEDITOR_H\r\n\r\n#include \"addressblockeditor.h\"\r\n\r\n#include <editors/ComponentEditor/itemeditor.h>\r\n\r\n#include <common/widgets/nameGroupEditor/namegroupeditor.h>\r\n\r\n#include <IPXACTmodels/Component/Component.h>\r\n#include <IPXACTmodels/Component/AddressBlock.h>\r\n\r\n#include <QSharedPointer>\r\n\r\nclass ExpressionFormatter;\r\nclass ExpressionEditor;\r\nclass ExpressionParser;\r\nclass LibraryInterface;\r\nclass ParameterFinder;\r\nclass UsageComboBox;\r\nclass AccessComboBox;\r\nclass BooleanComboBox;\r\nclass RegisterFileEditor;\r\nclass AddressBlockValidator;\r\nclass AddressBlockInterface;\r\nclass MemoryMapBase;\r\nclass AccessPoliciesEditor;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Editor for editing the details of a single address block.\r\n//-----------------------------------------------------------------------------\r\nclass SingleAddressBlockEditor : public ItemEditor\r\n{\r\n    Q_OBJECT\r\n\r\npublic:\r\n\r\n\t/*!\r\n\t *  The constructor.\r\n\t *\r\n     *    @param [in] blockInterface          Interface for address blocks.\r\n\t *    @param [in] addressBlock            The address block being edited.\r\n     *    @param [in] containingMap           Memory map item containing the edited address block.\r\n\t *    @param [in] component               The component being edited.\r\n\t *    @param [in] handler                 The instance managing the library.\r\n\t *    @param [in] parameterFinder         The parameter finder.\r\n\t *    @param [in] expressionFormatter     The expression formatter.\r\n     *    @param [in] expressionParser        The expression parser.\r\n     *    @param [in] addressBlockValidator   Validator used for address blocks.\r\n\t *    @param [in] parent                  The parent of this editor.\r\n\t */\r\n    SingleAddressBlockEditor(AddressBlockInterface* blockInterface,\r\n        QSharedPointer<AddressBlock> addressBlock,\r\n        QSharedPointer<MemoryMapBase> containingMap,\r\n        QSharedPointer<Component> component,\r\n        LibraryInterface* handler,\r\n        QSharedPointer<ParameterFinder> parameterFinder,\r\n        QSharedPointer<ExpressionFormatter> expressionFormatter,\r\n        QSharedPointer<ExpressionParser> expressionParser,\r\n        QSharedPointer<AddressBlockValidator> addressBlockValidator,\r\n        QWidget* parent = 0);\r\n\r\n\r\n\t//! The destructor\r\n    virtual ~SingleAddressBlockEditor() = default;\r\n\r\n    //! No copying.\r\n    SingleAddressBlockEditor(const SingleAddressBlockEditor& other) = delete;\r\n\r\n    //! No assignment.\r\n    SingleAddressBlockEditor& operator=(const SingleAddressBlockEditor& other) = delete;\r\n\r\n\r\n\t/*!\r\n\t *  Reload all the contained editors.\r\n\t */\r\n\tvirtual void refresh() override final;\r\n\r\npublic slots:\r\n\r\n    /*\r\n     *  Handles addressblock name change from memory map editor.\r\n     *\r\n     *    @param [in] oldName     The old name.\r\n     *    @param [in] newName     The new name.\r\n     */\r\n    void onAddressBlockNameChanged(QString const& oldName, QString const& newName);\r\n\r\n    /*\r\n     *  Handles addressblock name change from name editor.\r\n     */\r\n    void onAddressBlockNameChanged();\r\n\r\nsignals:\r\n\r\n    /*!\r\n     *  Change the value for address unit bits in the model.\r\n     *\r\n     *    @param [in] newAddressUnitBits  The new address unit bits value.\r\n     */\r\n    void addressUnitBitsChanged(int newAddressUnitBits);\r\n\r\n    /*\r\n     *  Informs of register name change.\r\n     *\r\n     *    @param [in] oldName     The old name.\r\n     *    @param [in] newName     The new name.\r\n     */\r\n    void registerNameChanged(QString const& oldName, QString const& newName);\r\n\r\n    void addressingChanged();\r\n\r\n    void childAddressingChanged(int index);\r\n\r\n    void childGraphicsChanged(int index);    \r\n\r\nprotected:\r\n\r\n    /*!\r\n\t *  Shows the widget and informs of the required help document.\r\n\t *\r\n\t *    @param [in] event   The show event.\r\n\t */\r\n\tvirtual void showEvent(QShowEvent* event) override final;\r\n\r\nprivate slots:\r\n    \r\n    /*!\r\n     *  Sets the value in the base address editor.\r\n     */\r\n    void onBaseAddressChanged();\r\n\r\n    /*!\r\n     *  Sets the value in the range editor.\r\n     */\r\n    void onRangeChanged();\r\n\r\n    /*!\r\n     *  Sets the value in the width editor.\r\n     */\r\n    void onWidthChanged();\r\n\r\n    //! Called when isPresent is changed.\r\n    void onIsPresentEdited();\r\n\r\n    /*!\r\n     *  Sets the value in the usage editor.\r\n     *\r\n     *    @param [in] newUsage    The selected usage.\r\n     */\r\n    void onUsageSelected(QString const& newUsage);\r\n\r\n    /*!\r\n     *  Sets the value in the access editor.\r\n     *\r\n     *    @param [in] newAccess   The selected access.\r\n     */\r\n    void onAccessSelected(QString const& newAccess);\r\n\r\n    /*!\r\n     *  Sets the value in the volatile editor.\r\n     *\r\n     *    @param [in] newVolatileValue    The selected volatile status.\r\n     */\r\n    void onVolatileSelected(QString const& newVolatileValue);\r\n\r\nprivate:\r\n\r\n    /*!\r\n     *  Sets the layout for the editor.\r\n     */\r\n    void setupLayout();\r\n\r\n    /*!\r\n     *  Connects all the signals of the editors.\r\n     */\r\n    void connectSignals() const;\r\n\r\n    /*!\r\n     *  Change the status of signal blocking in all the expression editors.\r\n     *\r\n     *    @param [in] blockStatus     The new signal blocking status.\r\n     */\r\n    void changeExpressionEditorSignalBlockStatus(bool blockStatus);\r\n\r\n    /*!\r\n     *  Calculates the value of an expression.\r\n     *\r\n     *    @param [in] expression  The expression, whose value is to be calculated.\r\n     *\r\n     *    @return The calculated value of the given expression.\r\n     */\r\n    QString formattedValueFor(QString const& expression) const;\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! Editor for containing the name group information of the address block.\r\n    NameGroupEditor nameEditor_;\r\n\r\n    //! Editor for selecting the usage of the address block.\r\n    UsageComboBox* usageEditor_;\r\n\r\n    //! Editor for the base address of the address block.\r\n    ExpressionEditor* baseAddressEditor_;\r\n\r\n    //! Editor for the range of the address block.\r\n    ExpressionEditor* rangeEditor_;\r\n\r\n    //! Editor for the width of the address block-\r\n    ExpressionEditor* widthEditor_;\r\n\r\n    //! Editor for the is present of the address block-\r\n    ExpressionEditor* isPresentEditor_;\r\n\r\n    //! Editor for selecting the access of the address block.\r\n    AccessComboBox* accessEditor_;\r\n\r\n    //! Editor for selecting the volatility of the address block.\r\n    BooleanComboBox* volatileEditor_;\r\n\r\n    //! Editor for containing the registers of the address block.\r\n    AddressBlockEditor* registersEditor_;\r\n\r\n    //! Editor for containing the register files of the address block.\r\n    RegisterFileEditor* registerFilesEditor_;\r\n\r\n    //! Name of the current address block.\r\n    std::string blockName_;\r\n\r\n    //! Interface for address blocks.\r\n    AddressBlockInterface* blockInterface_;\r\n\r\n    //! Memory map item containing the address block.\r\n    QSharedPointer<MemoryMapBase> containingMap_;\r\n\r\n    //! The expression parser.\r\n    QSharedPointer<ExpressionParser> expressionParser_;\r\n\r\n    //! Editor for access policies.\r\n    AccessPoliciesEditor* accessPoliciesEditor_;\r\n};\r\n\r\n#endif // SINGLEADDRESSBLOCKEDITOR_H\r\n"
  },
  {
    "path": "editors/ComponentEditor/memoryMaps/SingleFieldEditor.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: SingleFieldEditor.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Mikko Teuho\r\n// Date: 27.04.2015\r\n//\r\n// Description:\r\n// Editor for editing the details of a single field.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"SingleFieldEditor.h\"\r\n#include \"FieldAccessPoliciesEditor.h\"\r\n\r\n#include <KactusAPI/include/LibraryInterface.h>\r\n\r\n#include <editors/ComponentEditor/memoryMaps/WriteValueConstraintComboBox.h>\r\n#include <editors/ComponentEditor/memoryMaps/fieldeditor.h>\r\n#include <editors/ComponentEditor/memoryMaps/ResetsEditor.h>\r\n#include <KactusAPI/include/FieldInterface.h>\r\n\r\n#include <editors/ComponentEditor/common/ExpressionEditor.h>\r\n#include <KactusAPI/include/ExpressionFormatter.h>\r\n#include <KactusAPI/include/ExpressionParser.h>\r\n\r\n#include <editors/ComponentEditor/parameters/ComponentParameterModel.h>\r\n\r\n#include <common/widgets/accessComboBox/accesscombobox.h>\r\n#include <common/widgets/booleanComboBox/booleancombobox.h>\r\n#include <common/widgets/modWriteComboBox/modwritecombobox.h>\r\n#include <common/widgets/testConstraintComboBox/testconstraintcombobox.h>\r\n#include <common/widgets/readActionComboBox/readactioncombobox.h>\r\n\r\n#include <IPXACTmodels/Component/Component.h>\r\n#include <IPXACTmodels/Component/Field.h>\r\n#include <IPXACTmodels/Component/WriteValueConstraint.h>\r\n#include <IPXACTmodels/Component/ResetType.h>\r\n#include <IPXACTmodels/Component/Register.h>\r\n\r\n#include <IPXACTmodels/Component/validators/EnumeratedValueValidator.h>\r\n#include <IPXACTmodels/Component/validators/FieldValidator.h>\r\n\r\n#include <QComboBox>\r\n#include <QCompleter>\r\n#include <QFormLayout>\r\n#include <QScrollArea>\r\n#include <QSplitter>\r\n#include <QGridLayout>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SingleFieldEditor::SingleFieldEditor()\r\n//-----------------------------------------------------------------------------\r\nSingleFieldEditor::SingleFieldEditor(QSharedPointer<Field> fieldItem, QSharedPointer<Component> component,\r\n    LibraryInterface* handler, QSharedPointer<ParameterFinder> parameterFinder,\r\n    QSharedPointer<ExpressionParser> expressionParser, QSharedPointer<FieldValidator> fieldValidator,\r\n    FieldInterface* fieldInterface, QSharedPointer<Register> containingRegister, QWidget* parent):\r\nItemEditor(component, handler, parent),\r\nnameEditor_(fieldItem, component->getRevision(), this, tr(\"Field name and description\")),\r\nresetsEditor_(new ResetsEditor(fieldInterface->getSubInterface(), component->getResetTypes(), expressionParser,\r\n    parameterFinder, fieldItem, this)),\r\nenumerationsEditor_(new FieldEditor(fieldItem->getEnumeratedValues(),\r\n    fieldValidator->getEnumeratedValueValidator(), component, handler, this)),\r\noffsetEditor_(new ExpressionEditor(parameterFinder, this)),\r\nwidthEditor_(new ExpressionEditor(parameterFinder, this)),\r\nvolatileEditor_(),\r\naccessEditor_(),\r\nmodifiedWriteValueEditor_(),\r\nreadActionEditor_(),\r\ntestableEditor_(),\r\ntestConstrainedEditor_(),\r\nisPresentEditor_(new ExpressionEditor(parameterFinder, this)),\r\nreservedEditor_(new ExpressionEditor(parameterFinder, this)),\r\nfieldIdEditor_(new QLineEdit(this)),\r\nexpressionParser_(expressionParser),\r\nwriteConstraintEditor_(new QComboBox(this)),\r\nwriteConstraintMinLimit_(new ExpressionEditor(parameterFinder, this)),\r\nwriteConstraintMaxLimit_(new ExpressionEditor(parameterFinder, this)),\r\nfieldName_(fieldItem->name().toStdString()),\r\nfieldValidator_(fieldValidator),\r\nfieldInterface_(fieldInterface),\r\ncontainingRegister_(containingRegister)\r\n{\r\n    fieldInterface_->setFields(containingRegister_->getFields());\r\n\r\n    offsetEditor_->setFixedHeight(ExpressionEditor::DEFAULT_HEIGHT);\r\n    widthEditor_->setFixedHeight(ExpressionEditor::DEFAULT_HEIGHT);\r\n    isPresentEditor_->setFixedHeight(ExpressionEditor::DEFAULT_HEIGHT);\r\n    reservedEditor_->setFixedHeight(ExpressionEditor::DEFAULT_HEIGHT);\r\n    writeConstraintMinLimit_->setFixedHeight(ExpressionEditor::DEFAULT_HEIGHT);\r\n    writeConstraintMaxLimit_->setFixedHeight(ExpressionEditor::DEFAULT_HEIGHT);\r\n\r\n    ComponentParameterModel* componentParametersModel = new ComponentParameterModel(parameterFinder, this);\r\n    componentParametersModel->setExpressionParser(expressionParser_);\r\n\r\n    auto offsetCompleter = new QCompleter(this);\r\n    offsetCompleter->setModel(componentParametersModel);\r\n\r\n    auto widthCompleter = new QCompleter(this);\r\n    widthCompleter->setModel(componentParametersModel);\r\n\r\n    auto isPresentCompleter = new QCompleter(this);\r\n    isPresentCompleter->setModel(componentParametersModel);\r\n\r\n    auto reservedCompleter = new QCompleter(this);\r\n    reservedCompleter->setModel(componentParametersModel);\r\n\r\n    auto writeValueMinCompleter = new QCompleter(this);\r\n    writeValueMinCompleter->setModel(componentParametersModel);\r\n\r\n    auto writeValueMaxCompleter = new QCompleter(this);\r\n    writeValueMaxCompleter->setModel(componentParametersModel);\r\n\r\n    auto resetValueCompleter = new QCompleter(this);\r\n    resetValueCompleter->setModel(componentParametersModel);\r\n\r\n    auto resetMaskCompleter = new QCompleter(this);\r\n    resetMaskCompleter->setModel(componentParametersModel);\r\n\r\n    offsetEditor_->setAppendingCompleter(offsetCompleter);\r\n    widthEditor_->setAppendingCompleter(widthCompleter);\r\n    isPresentEditor_->setAppendingCompleter(isPresentCompleter);\r\n    reservedEditor_->setAppendingCompleter(reservedCompleter);\r\n    writeConstraintMinLimit_->setAppendingCompleter(writeValueMinCompleter);\r\n    writeConstraintMaxLimit_->setAppendingCompleter(writeValueMaxCompleter);\r\n\r\n    writeConstraintEditor_->setEditable(false);\r\n    writeConstraintEditor_->addItems(WriteValueConversions::getConstraintTypes());\r\n\r\n    writeConstraintEditor_->setCurrentText(\r\n        QString::fromStdString(fieldInterface_->getWriteConstraint(fieldName_)));\r\n\r\n    setWriteMinMaxConstraintEnableStatus(writeConstraintEditor_->currentIndex());\r\n\r\n    accessPoliciesEditor_ = new FieldAccessPoliciesEditor(fieldItem->name(), fieldInterface_, \r\n        parameterFinder, expressionParser, this);\r\n\r\n    setupLayout();\r\n    connectSignals();\r\n\r\n    offsetEditor_->setProperty(\"mandatoryField\", true);\r\n    widthEditor_->setProperty(\"mandatoryField\", true);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SingleFieldEditor::onFieldNameChanged()\r\n//-----------------------------------------------------------------------------\r\nvoid SingleFieldEditor::onFieldNameChanged(QString const& oldName, QString const& newName)\r\n{\r\n    if (oldName == QString::fromStdString(fieldName_))\r\n    {\r\n        fieldName_ = newName.toStdString();\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SingleFieldEditor::onFieldNameChanged()\r\n//-----------------------------------------------------------------------------\r\nvoid SingleFieldEditor::onFieldNameChanged()\r\n{\r\n    fieldName_ = nameEditor_.name().toStdString();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SingleFieldEditor::refresh()\r\n//-----------------------------------------------------------------------------\r\nvoid SingleFieldEditor::refresh()\r\n{\r\n    fieldInterface_->setFields(containingRegister_->getFields());\r\n\r\n    nameEditor_.refresh();\r\n    resetsEditor_->refresh();\r\n    enumerationsEditor_->refresh();\r\n    accessPoliciesEditor_->refresh();\r\n\r\n    // Block signals from here for the duration of refreshing editors.\r\n    blockSignals(true);\r\n\r\n    changeExpressionEditorSignalBlockStatus(true);\r\n\r\n    offsetEditor_->setExpression(QString::fromStdString(fieldInterface_->getOffsetExpression(fieldName_)));\r\n    offsetEditor_->setToolTip(QString::fromStdString(fieldInterface_->getOffsetValue(fieldName_)));\r\n\r\n    widthEditor_->setExpression(QString::fromStdString(fieldInterface_->getWidthExpression(fieldName_)));\r\n    widthEditor_->setToolTip(QString::fromStdString(fieldInterface_->getWidthValue(fieldName_)));\r\n\r\n    isPresentEditor_->setExpression(QString::fromStdString(fieldInterface_->getIsPresentExpression(fieldName_)));\r\n    isPresentEditor_->setToolTip(QString::fromStdString(fieldInterface_->getIsPresentValue(fieldName_)));\r\n\r\n    reservedEditor_->setExpression(QString::fromStdString(fieldInterface_->getReservedExpression(fieldName_)));\r\n    reservedEditor_->setToolTip(QString::fromStdString(fieldInterface_->getReservedValue(fieldName_)));\r\n\r\n    fieldIdEditor_->setText(QString::fromStdString(fieldInterface_->getID(fieldName_)));\r\n\r\n    if (fieldInterface_->hasWriteConstraint(fieldName_))\r\n    {\r\n        writeConstraintMinLimit_->setExpression(\r\n            QString::fromStdString(fieldInterface_->getWriteConstraintMinimumExpression(fieldName_)));\r\n        writeConstraintMinLimit_->setToolTip(\r\n            QString::fromStdString(fieldInterface_->getWriteConstraintMinimumValue(fieldName_)));\r\n\r\n        writeConstraintMaxLimit_->setExpression(\r\n            QString::fromStdString(fieldInterface_->getWriteConstraintMaximumExpression(fieldName_)));\r\n        writeConstraintMaxLimit_->setToolTip(\r\n            QString::fromStdString(fieldInterface_->getWriteConstraintMaximumValue(fieldName_)));\r\n    }\r\n\r\n    fieldValidator_->componentChange(component());\r\n\r\n    changeExpressionEditorSignalBlockStatus(false);\r\n\r\n\r\n    volatileEditor_->setCurrentValue(QString::fromStdString(fieldInterface_->getVolatile(fieldName_)));\r\n    \r\n    if (component()->getRevision() == Document::Revision::Std14)\r\n    {\r\n        accessEditor_->setCurrentValue(fieldInterface_->getAccessType(fieldName_));\r\n        modifiedWriteValueEditor_->setCurrentValue(fieldInterface_->getModifiedWriteValue(fieldName_));\r\n        readActionEditor_->setCurrentValue(fieldInterface_->getReadAction(fieldName_));\r\n        testableEditor_->setCurrentValue(QString::fromStdString(fieldInterface_->getTestableValue(fieldName_)));\r\n        testConstrainedEditor_->setCurrentValue(fieldInterface_->getTestConstraint(fieldName_));\r\n    }\r\n\r\n    if (fieldInterface_->hasWriteConstraint(fieldName_))\r\n    {\r\n        setWriteMinMaxConstraintEnableStatus(writeConstraintEditor_->currentIndex());\r\n    }\r\n\r\n    blockSignals(false);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SingleFieldEditor::showEvent()\r\n//-----------------------------------------------------------------------------\r\nvoid SingleFieldEditor::showEvent(QShowEvent* event)\r\n{\r\n    QWidget::showEvent(event);\r\n\r\n    if (component()->getRevision() == Document::Revision::Std22)\r\n    {\r\n        emit helpUrlRequested(\"componenteditor/field2022.html\");\r\n    }\r\n    else\r\n    {\r\n        emit helpUrlRequested(\"componenteditor/field.html\");\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SingleFieldEditor::changeExpressionEditorSignalBlockStatus()\r\n//-----------------------------------------------------------------------------\r\nvoid SingleFieldEditor::changeExpressionEditorSignalBlockStatus(bool blockStatus) const\r\n{\r\n    offsetEditor_->blockSignals(blockStatus);\r\n    widthEditor_->blockSignals(blockStatus);\r\n    isPresentEditor_->blockSignals(blockStatus);\r\n    reservedEditor_->blockSignals(blockStatus);\r\n    writeConstraintMinLimit_->blockSignals(blockStatus);\r\n    writeConstraintMaxLimit_->blockSignals(blockStatus);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SingleFieldEditor::formattedValueFor()\r\n//-----------------------------------------------------------------------------\r\nQString SingleFieldEditor::formattedValueFor(QString const& expression) const\r\n{\r\n    return ExpressionFormatter::format(expression, expressionParser_);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SingleFieldEditor::onOffsetEdited()\r\n//-----------------------------------------------------------------------------\r\nvoid SingleFieldEditor::onOffsetEdited()\r\n{\r\n    offsetEditor_->finishEditingCurrentWord();\r\n    QString newBitOffset = offsetEditor_->getExpression();\r\n\r\n    fieldInterface_->setOffset(fieldName_, newBitOffset.toStdString());\r\n    offsetEditor_->setToolTip(formattedValueFor(newBitOffset));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SingleFieldEditor::onWidthEdited()\r\n//-----------------------------------------------------------------------------\r\nvoid SingleFieldEditor::onWidthEdited()\r\n{\r\n    widthEditor_->finishEditingCurrentWord();\r\n    QString newBitWidth = widthEditor_->getExpression();\r\n\r\n    fieldInterface_->setWidth(fieldName_, newBitWidth.toStdString());\r\n    widthEditor_->setToolTip(formattedValueFor(newBitWidth));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SingleFieldEditor::onVolatileSelected()\r\n//-----------------------------------------------------------------------------\r\nvoid SingleFieldEditor::onVolatileSelected(QString const& newVolatileValue)\r\n{\r\n    fieldInterface_->setVolatile(fieldName_, newVolatileValue.toStdString());\r\n\r\n    emit contentChanged();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SingleFieldEditor::onAccessSelected()\r\n//-----------------------------------------------------------------------------\r\nvoid SingleFieldEditor::onAccessSelected(QString const& newAccessValue)\r\n{\r\n    fieldInterface_->setAccess(fieldName_, newAccessValue.toStdString(), -1);\r\n\r\n    emit contentChanged();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SingleFieldEditor::onModifiedWriteSelected()\r\n//-----------------------------------------------------------------------------\r\nvoid SingleFieldEditor::onModifiedWriteSelected(QString const& newModWriteValue)\r\n{\r\n    fieldInterface_->setModifiedWrite(fieldName_, newModWriteValue.toStdString());\r\n\r\n    emit contentChanged();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SingleFieldEditor::onReadActionSelected()\r\n//-----------------------------------------------------------------------------\r\nvoid SingleFieldEditor::onReadActionSelected(QString const& newReadActionValue)\r\n{\r\n    fieldInterface_->setReadAction(fieldName_, newReadActionValue.toStdString());\r\n\r\n    emit contentChanged();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SingleFieldEditor::onTestableSelected()\r\n//-----------------------------------------------------------------------------\r\nvoid SingleFieldEditor::onTestableSelected(QString const& newTestableValue)\r\n{\r\n    fieldInterface_->setTestable(fieldName_, newTestableValue.toStdString());\r\n\r\n    emit contentChanged();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SingleFieldEditor::onTestConstrainedSelected()\r\n//-----------------------------------------------------------------------------\r\nvoid SingleFieldEditor::onTestConstrainedSelected(QString const& newTestConstrainedValue)\r\n{\r\n    fieldInterface_->setTestConstraint(fieldName_, newTestConstrainedValue.toStdString());\r\n\r\n    emit contentChanged();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SingleFieldEditor::onIsPresentEdited()\r\n//-----------------------------------------------------------------------------\r\nvoid SingleFieldEditor::onIsPresentEdited()\r\n{\r\n    isPresentEditor_->finishEditingCurrentWord();\r\n    QString newIsPresent = isPresentEditor_->getExpression();\r\n\r\n    fieldInterface_->setIsPresent(fieldName_, newIsPresent.toStdString());\r\n    isPresentEditor_->setToolTip(formattedValueFor(newIsPresent));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SingleFieldEditor::onReservedEdited()\r\n//-----------------------------------------------------------------------------\r\nvoid SingleFieldEditor::onReservedEdited()\r\n{\r\n    reservedEditor_->finishEditingCurrentWord();\r\n    QString newReserved = reservedEditor_->getExpression();\r\n\r\n    fieldInterface_->setReserved(fieldName_, newReserved.toStdString());\r\n    reservedEditor_->setToolTip(formattedValueFor(newReserved));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SingleFieldEditor::onFieldIdChanged()\r\n//-----------------------------------------------------------------------------\r\nvoid SingleFieldEditor::onFieldIdChanged()\r\n{\r\n    fieldInterface_->setID(fieldName_, fieldIdEditor_->text().toStdString());\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SingleFieldEditor::setWriteMinMaxConstraintEnableStatus()\r\n//-----------------------------------------------------------------------------\r\nvoid SingleFieldEditor::setWriteMinMaxConstraintEnableStatus(int writeConstraintIndex) const\r\n{\r\n    if (writeConstraintIndex == WriteValueConstraint::MIN_MAX)\r\n    {\r\n        writeConstraintMinLimit_->setEnabled(true);\r\n        writeConstraintMaxLimit_->setEnabled(true);\r\n    }\r\n    else\r\n    {\r\n        writeConstraintMinLimit_->setEnabled(false);\r\n        writeConstraintMaxLimit_->setEnabled(false);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SingleFieldEditor::onWriteConstraintSelected()\r\n//-----------------------------------------------------------------------------\r\nvoid SingleFieldEditor::onWriteConstraintSelected(int newIndex)\r\n{\r\n    QString writeConstaintText = writeConstraintEditor_->currentText();\r\n    fieldInterface_->setWriteConstraint(fieldName_, writeConstaintText.toStdString());\r\n\r\n    setWriteMinMaxConstraintEnableStatus(newIndex);\r\n    emit contentChanged();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SingleFieldEditor::onWriteConstraintMinimumEdited()\r\n//-----------------------------------------------------------------------------\r\nvoid SingleFieldEditor::onWriteConstraintMinimumEdited()\r\n{\r\n    writeConstraintMinLimit_->finishEditingCurrentWord();\r\n    QString newMinimumLimit = writeConstraintMinLimit_->getExpression();\r\n\r\n    fieldInterface_->setWriteConstraintMinimum(fieldName_, newMinimumLimit.toStdString());\r\n    writeConstraintMinLimit_->setToolTip(formattedValueFor(newMinimumLimit));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SingleFieldEditor::onWriteConstraintMaximumEdited()\r\n//-----------------------------------------------------------------------------\r\nvoid SingleFieldEditor::onWriteConstraintMaximumEdited()\r\n{\r\n\r\n    writeConstraintMaxLimit_->finishEditingCurrentWord();\r\n    QString newMaximumLimit = writeConstraintMaxLimit_->getExpression();\r\n\r\n    fieldInterface_->setWriteConstraintMaximum(fieldName_, newMaximumLimit.toStdString());\r\n    writeConstraintMaxLimit_->setToolTip(formattedValueFor(newMaximumLimit));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SingleFieldEditor::connectSignals()\r\n//-----------------------------------------------------------------------------\r\nvoid SingleFieldEditor::connectSignals()\r\n{\r\n    connect(offsetEditor_, SIGNAL(increaseReference(QString const&)),\r\n        this, SIGNAL(increaseReferences(QString const&)), Qt::UniqueConnection);\r\n    connect(offsetEditor_, SIGNAL(decreaseReference(QString const&)),\r\n        this, SIGNAL(decreaseReferences(QString const&)), Qt::UniqueConnection);\r\n    connect(widthEditor_, SIGNAL(increaseReference(QString const&)),\r\n        this, SIGNAL(increaseReferences(QString const&)), Qt::UniqueConnection);\r\n    connect(widthEditor_, SIGNAL(decreaseReference(QString const&)),\r\n        this, SIGNAL(decreaseReferences(QString const&)), Qt::UniqueConnection);\r\n    connect(isPresentEditor_, SIGNAL(increaseReference(QString const&)),\r\n        this, SIGNAL(increaseReferences(QString const&)), Qt::UniqueConnection);\r\n    connect(isPresentEditor_, SIGNAL(decreaseReference(QString const&)),\r\n        this, SIGNAL(decreaseReferences(QString const&)), Qt::UniqueConnection);\r\n    connect(reservedEditor_, SIGNAL(increaseReference(QString const&)),\r\n        this, SIGNAL(increaseReferences(QString const&)), Qt::UniqueConnection);\r\n    connect(reservedEditor_, SIGNAL(decreaseReference(QString const&)),\r\n        this, SIGNAL(decreaseReferences(QString const&)), Qt::UniqueConnection);\r\n    connect(writeConstraintMinLimit_, SIGNAL(increaseReference(QString const&)),\r\n        this, SIGNAL(increaseReferences(QString const&)), Qt::UniqueConnection);\r\n    connect(writeConstraintMinLimit_, SIGNAL(decreaseReference(QString const&)),\r\n        this, SIGNAL(decreaseReferences(QString const&)), Qt::UniqueConnection);\r\n    connect(writeConstraintMaxLimit_, SIGNAL(increaseReference(QString const&)),\r\n        this, SIGNAL(increaseReferences(QString const&)), Qt::UniqueConnection);\r\n    connect(writeConstraintMaxLimit_, SIGNAL(decreaseReference(QString const&)),\r\n        this, SIGNAL(decreaseReferences(QString const&)), Qt::UniqueConnection);\r\n    connect(resetsEditor_, SIGNAL(increaseReferences(QString const&)),\r\n        this, SIGNAL(increaseReferences(QString const&)), Qt::UniqueConnection);\r\n    connect(resetsEditor_, SIGNAL(decreaseReferences(QString const&)),\r\n        this, SIGNAL(decreaseReferences(QString const&)), Qt::UniqueConnection);\r\n\r\n    connect(offsetEditor_, SIGNAL(editingFinished()), this, SLOT(onOffsetEdited()), Qt::UniqueConnection);\r\n    connect(widthEditor_, SIGNAL(editingFinished()), this, SLOT(onWidthEdited()), Qt::UniqueConnection);\r\n    connect(isPresentEditor_, SIGNAL(editingFinished()), this, SLOT(onIsPresentEdited()), Qt::UniqueConnection);\r\n    connect(reservedEditor_, SIGNAL(editingFinished()), this, SLOT(onReservedEdited()), Qt::UniqueConnection);\r\n    connect(fieldIdEditor_, SIGNAL(editingFinished()), this, SLOT(onFieldIdChanged()), Qt::UniqueConnection);\r\n    connect(writeConstraintMinLimit_, SIGNAL(editingFinished()), this, SLOT(onWriteConstraintMinimumEdited()), Qt::UniqueConnection);\r\n    connect(writeConstraintMaxLimit_, SIGNAL(editingFinished()), this, SLOT(onWriteConstraintMaximumEdited()), Qt::UniqueConnection);\r\n\r\n    connect(&nameEditor_, SIGNAL(contentChanged()), this, SIGNAL(contentChanged()), Qt::UniqueConnection);\r\n    connect(resetsEditor_, SIGNAL(contentChanged()), this, SIGNAL(contentChanged()), Qt::UniqueConnection);\r\n    connect(enumerationsEditor_, SIGNAL(contentChanged()), this, SIGNAL(contentChanged()), Qt::UniqueConnection);\r\n    connect(offsetEditor_, SIGNAL(editingFinished()), this, SIGNAL(contentChanged()), Qt::UniqueConnection);\r\n    connect(widthEditor_, SIGNAL(editingFinished()), this, SIGNAL(contentChanged()), Qt::UniqueConnection);\r\n    connect(isPresentEditor_, SIGNAL(editingFinished()), this, SIGNAL(contentChanged()), Qt::UniqueConnection);\r\n    connect(reservedEditor_, SIGNAL(editingFinished()), this, SIGNAL(contentChanged()), Qt::UniqueConnection);\r\n    connect(fieldIdEditor_, SIGNAL(editingFinished()), this, SIGNAL(contentChanged()), Qt::UniqueConnection);\r\n\r\n    connect(writeConstraintMinLimit_, SIGNAL(editingFinished()),this, SIGNAL(contentChanged()), Qt::UniqueConnection);\r\n    connect(writeConstraintMaxLimit_, SIGNAL(editingFinished()),this, SIGNAL(contentChanged()), Qt::UniqueConnection);\r\n\r\n    connect(&nameEditor_, SIGNAL(nameChanged()), this, SIGNAL(graphicsChanged()), Qt::UniqueConnection);\r\n    connect(&nameEditor_, SIGNAL(nameChanged()), this, SLOT(onFieldNameChanged()), Qt::UniqueConnection);\r\n    connect(offsetEditor_, SIGNAL(editingFinished()), this, SIGNAL(graphicsChanged()), Qt::UniqueConnection);\r\n    connect(offsetEditor_, SIGNAL(editingFinished()), this, SIGNAL(addressingChanged()), Qt::UniqueConnection);\r\n    \r\n    connect(widthEditor_, SIGNAL(editingFinished()), this, SIGNAL(graphicsChanged()), Qt::UniqueConnection);\r\n    connect(widthEditor_, SIGNAL(editingFinished()), this, SIGNAL(addressingChanged()), Qt::UniqueConnection);\r\n    \r\n    connect(isPresentEditor_, SIGNAL(editingFinished()), this, SIGNAL(graphicsChanged()), Qt::UniqueConnection);\r\n    connect(isPresentEditor_, SIGNAL(editingFinished()), this, SIGNAL(addressingChanged()), Qt::UniqueConnection);\r\n\r\n\r\n    connect(writeConstraintEditor_, SIGNAL(activated(int)),this, SLOT(onWriteConstraintSelected(int)), Qt::UniqueConnection);\r\n\r\n    connect(accessPoliciesEditor_, SIGNAL(contentChanged()), this, SIGNAL(contentChanged()), Qt::UniqueConnection);\r\n    connect(accessPoliciesEditor_, SIGNAL(increaseReferences(QString const&)), this, SIGNAL(increaseReferences(QString const&)), Qt::UniqueConnection);\r\n    connect(accessPoliciesEditor_, SIGNAL(decreaseReferences(QString const&)), this, SIGNAL(decreaseReferences(QString const&)), Qt::UniqueConnection);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SingleFieldEditor::setupLayout()\r\n//-----------------------------------------------------------------------------\r\nvoid SingleFieldEditor::setupLayout()\r\n{\r\n    bool showStd14 = component()->getRevision() == Document::Revision::Std14;\r\n\r\n    QScrollArea* scrollArea = new QScrollArea(this);\r\n    scrollArea->setWidgetResizable(true);\r\n    scrollArea->setFrameShape(QFrame::NoFrame);\r\n\r\n    QHBoxLayout* scrollLayout = new QHBoxLayout(this);\r\n    scrollLayout->addWidget(scrollArea);\r\n    scrollLayout->setContentsMargins(0, 0, 0, 0);\r\n\r\n    QGroupBox* fieldConstraintGroup = new QGroupBox(tr(\"Field constraints\"), this);\r\n    QFormLayout* fieldConstraintLayout = new QFormLayout(fieldConstraintGroup);\r\n    \r\n    QGroupBox* fieldDefinitionGroup = new QGroupBox(tr(\"Field definition\"));\r\n    QFormLayout* fieldDefinitionLayout = new QFormLayout(fieldDefinitionGroup);\r\n    fieldDefinitionLayout->setAlignment(Qt::AlignTop);\r\n    fieldDefinitionLayout->setFormAlignment(Qt::AlignTop);\r\n    fieldDefinitionLayout->setLabelAlignment(Qt::AlignTop);\r\n    \r\n    fieldDefinitionLayout->addRow(tr(\"Offset [bits], f(x):\"), offsetEditor_);\r\n    fieldDefinitionLayout->addRow(tr(\"Width [bits], f(x):\"), widthEditor_);\r\n\r\n    QGridLayout* topOfPageLayout = new QGridLayout();\r\n    topOfPageLayout->addWidget(&nameEditor_, 0, 0);\r\n    topOfPageLayout->setRowStretch(0, 1);\r\n    topOfPageLayout->setRowStretch(1, 2);\r\n\r\n    if (showStd14)\r\n    {\r\n        fieldDefinitionLayout->addRow(tr(\"Is present, f(x):\"), isPresentEditor_);\r\n        fieldDefinitionLayout->addRow(tr(\"Reserved, f(x):\"), reservedEditor_);\r\n        fieldDefinitionLayout->addRow(tr(\"Field ID:\"), fieldIdEditor_);\r\n\r\n        volatileEditor_ = new BooleanComboBox(fieldConstraintGroup);\r\n        fieldConstraintLayout->addRow(tr(\"Volatile:\"), volatileEditor_);\r\n        connect(volatileEditor_, SIGNAL(currentTextChanged(QString const&)),\r\n            this, SLOT(onVolatileSelected(QString const&)), Qt::UniqueConnection);\r\n\r\n        accessEditor_ = new AccessComboBox(fieldConstraintGroup);\r\n        fieldConstraintLayout->addRow(tr(\"Access:\"), accessEditor_);\r\n        connect(accessEditor_, SIGNAL(currentTextChanged(QString const&)),\r\n            this, SLOT(onAccessSelected(QString const&)), Qt::UniqueConnection);\r\n\r\n        modifiedWriteValueEditor_ = new ModWriteComboBox(fieldConstraintGroup);\r\n        fieldConstraintLayout->addRow(tr(\"Modified write value:\"), modifiedWriteValueEditor_);\r\n        connect(modifiedWriteValueEditor_, SIGNAL(currentTextChanged(QString const&)),\r\n            this, SLOT(onModifiedWriteSelected(QString const&)), Qt::UniqueConnection);\r\n\r\n        readActionEditor_ = new ReadActionComboBox(fieldConstraintGroup);\r\n        fieldConstraintLayout->addRow(tr(\"Read action:\"), readActionEditor_);\r\n        connect(readActionEditor_, SIGNAL(currentTextChanged(QString const&)),\r\n            this, SLOT(onReadActionSelected(QString const&)), Qt::UniqueConnection);\r\n\r\n        testableEditor_ = new BooleanComboBox(fieldConstraintGroup);\r\n        fieldConstraintLayout->addRow(tr(\"Testable:\"), testableEditor_);\r\n        connect(testableEditor_, SIGNAL(currentTextChanged(QString const&)),\r\n            this, SLOT(onTestableSelected(QString const&)), Qt::UniqueConnection);\r\n\r\n        testConstrainedEditor_ = new TestConstraintComboBox(fieldConstraintGroup);\r\n        fieldConstraintLayout->addRow(tr(\"Test constraint:\"), testConstrainedEditor_);\r\n        connect(testConstrainedEditor_, SIGNAL(currentTextChanged(QString const&)),\r\n            this, SLOT(onTestConstrainedSelected(QString const&)), Qt::UniqueConnection);\r\n\r\n        fieldConstraintLayout->addRow(tr(\"Write value constraint:\"), writeConstraintEditor_);\r\n        fieldConstraintLayout->addRow(tr(\"Write constraint minimum, f(x):\"), writeConstraintMinLimit_);\r\n        fieldConstraintLayout->addRow(tr(\"Write constraint maximum, f(x):\"), writeConstraintMaxLimit_);\r\n\r\n        topOfPageLayout->addWidget(fieldConstraintGroup, 0, 1);\r\n        topOfPageLayout->addWidget(resetsEditor_, 1, 1);\r\n        topOfPageLayout->addWidget(fieldDefinitionGroup, 1, 0);\r\n    }\r\n    else\r\n    {\r\n        fieldConstraintGroup->setVisible(showStd14);\r\n\r\n        volatileEditor_ = new BooleanComboBox(fieldConstraintGroup);\r\n        fieldDefinitionLayout->addRow(tr(\"Volatile:\"), volatileEditor_);\r\n        connect(volatileEditor_, SIGNAL(currentTextChanged(QString const&)),\r\n            this, SLOT(onVolatileSelected(QString const&)), Qt::UniqueConnection);\r\n\r\n        auto spacer = new QWidget();\r\n        spacer->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Expanding);\r\n        fieldDefinitionLayout->addRow(spacer);\r\n\r\n        topOfPageLayout->addWidget(enumerationsEditor_, 1, 1);\r\n        topOfPageLayout->addWidget(fieldDefinitionGroup, 0, 1);\r\n        topOfPageLayout->addWidget(resetsEditor_, 1, 0);\r\n    }\r\n    \r\n    QWidget* topOfPageWidget = new QWidget();\r\n    topOfPageWidget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);\r\n    topOfPageWidget->setLayout(topOfPageLayout);\r\n    topOfPageWidget->setContentsMargins(0, 0, 0, 0);\r\n\r\n    QSplitter* verticalSplitter = new QSplitter(Qt::Vertical, scrollArea);\r\n    verticalSplitter->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);\r\n    verticalSplitter->addWidget(topOfPageWidget);\r\n\r\n    if (showStd14)\r\n    {\r\n        verticalSplitter->addWidget(enumerationsEditor_);\r\n    }\r\n    else\r\n    {\r\n        verticalSplitter->addWidget(accessPoliciesEditor_);\r\n    }\r\n\r\n    verticalSplitter->setStretchFactor(1, 1);\r\n\r\n    QSplitterHandle* handle = verticalSplitter->handle(1);\r\n    QVBoxLayout* handleLayout = new QVBoxLayout(handle);\r\n    handleLayout->setSpacing(0);\r\n    handleLayout->setContentsMargins(0, 0, 0, 0);\r\n\r\n    QFrame* line = new QFrame(handle);\r\n    line->setLineWidth(2);\r\n    line->setMidLineWidth(2);\r\n    line->setFrameShape(QFrame::HLine);\r\n    line->setFrameShadow(QFrame::Sunken);\r\n    handleLayout->addWidget(line);\r\n\r\n    verticalSplitter->setHandleWidth(10);\r\n\r\n    scrollArea->setWidget(verticalSplitter);\r\n}\r\n"
  },
  {
    "path": "editors/ComponentEditor/memoryMaps/SingleFieldEditor.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: SingleFieldEditor.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Mikko Teuho\r\n// Date: 27.04.2015\r\n//\r\n// Description:\r\n// Editor for editing the details of a single field.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef SINGLEFIELDEDITOR_H\r\n#define SINGLEFIELDEDITOR_H\r\n\r\n#include <editors/ComponentEditor/itemeditor.h>\r\n\r\n#include <common/widgets/nameGroupEditor/namegroupeditor.h>\r\n\r\n#include <QSharedPointer>\r\n\r\nclass ResetsEditor;\r\nclass FieldEditor;\r\nclass ExpressionEditor;\r\nclass BooleanComboBox;\r\nclass AccessComboBox;\r\nclass ModWriteComboBox;\r\nclass ReadActionComboBox;\r\nclass TestConstraintComboBox;\r\nclass ParameterFinder;\r\nclass ExpressionParser;\r\n\r\nclass Register;\r\nclass Field;\r\nclass Component;\r\nclass FieldValidator;\r\nclass FieldInterface;\r\nclass FieldAccessPoliciesEditor;\r\n\r\n#include <QComboBox>\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Editor for editing the details of a single register.\r\n//-----------------------------------------------------------------------------\r\nclass SingleFieldEditor : public ItemEditor\r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\r\n    /*!\r\n\t *  The constructor.\r\n\t *\r\n\t *    @param [in] fieldItem           The field being edited.\r\n\t *    @param [in] component           The component being edited.\r\n\t *    @param [in] handler             The instance managing the library.\r\n     *    @param [in] parameterFinder     The instance for finding parameter references.\r\n     *    @param [in] expressionParser    The expression parser to use.\r\n     *    @param [in] fieldValidator      The used field validator.\r\n     *    @param [in] fieldInterface      Interface for fields.\r\n     *    @param [in] containingRegister  Register containing the edited field.\r\n\t *    @param [in] parent              The parent of this editor.\r\n\t */\r\n    SingleFieldEditor(QSharedPointer<Field> fieldItem,\r\n        QSharedPointer<Component> component,\r\n        LibraryInterface* handler,\r\n        QSharedPointer<ParameterFinder> parameterFinder,\r\n        QSharedPointer<ExpressionParser> expressionParser,\r\n        QSharedPointer<FieldValidator> fieldValidator,\r\n        FieldInterface* fieldInterface,\r\n        QSharedPointer<Register> containingRegister,\r\n        QWidget* parent = 0);\r\n\r\n    /*!\r\n     *  The destructor.\r\n     */\r\n    virtual ~SingleFieldEditor() = default;\r\n\r\n    /*!\r\n\t *  Reload the information from the model to the editor.\r\n\t */\r\n\tvirtual void refresh();\r\n\r\nsignals:\r\n    void addressingChanged();\r\n\r\npublic slots:\r\n\r\n    /*\r\n     *  Handles field name change from register editor.\r\n     *\r\n     *    @param [in] oldName     The old name.\r\n     *    @param [in] newName     The new name.\r\n     */\r\n    void onFieldNameChanged(QString const& oldName, QString const& newName);\r\n\r\n    /*\r\n     *  Handles field name change from name editor.\r\n     */\r\n    void onFieldNameChanged();\r\n\r\nprotected:\r\n\r\n    /*!\r\n\t *  informs of the required help document.\r\n\t *\r\n\t *    @param [in] event   The show event.\r\n\t */\r\n\tvirtual void showEvent(QShowEvent* event);\r\n\r\nprivate slots:\r\n\r\n    /*!\r\n     *  Sets the edited offset value for the field.\r\n     */\r\n    void onOffsetEdited();\r\n\r\n    /*!\r\n     *  Sets the edited width value for the field.\r\n     */\r\n    void onWidthEdited();\r\n\r\n    /*!\r\n     *  Sets the selected volatile value for the field.\r\n     *\r\n     *    @param [in] newVolatileValue    The selected volatile value.\r\n     */\r\n    void onVolatileSelected(QString const& newVolatileValue);\r\n\r\n    /*!\r\n     *  Sets the selected access value for the field.\r\n     *\r\n     *    @param [in] newAccessValue      The selected access value.\r\n     */\r\n    void onAccessSelected(QString const& newAccessValue);\r\n\r\n    /*!\r\n     *  Sets the selected modified write value for the field.\r\n     *\r\n     *    @param [in] newModWriteValue    The selected modified write value.\r\n     */\r\n    void onModifiedWriteSelected(QString const& newModWriteValue);\r\n\r\n    /*!\r\n     *  Sets the selected read action value for the field.\r\n     *\r\n     *    @param [in] newReadActionValue  The selected read action value.\r\n     */\r\n    void onReadActionSelected(QString const& newReadActionValue);\r\n\r\n    /*!\r\n     *  Sets the selected testable value for the field.\r\n     *\r\n     *    @param [in] newTestableValue    The selected testable value.\r\n     */\r\n    void onTestableSelected(QString const& newTestableValue);\r\n\r\n    /*!\r\n     *  Sets the selected test constrained value for the field.\r\n     *\r\n     *    @param [in] newTestConstrainedValue     The selected test constrained value.\r\n     */\r\n    void onTestConstrainedSelected(QString const& newTestConstrainedValue);\r\n\r\n    /*!\r\n     *  Sets the edited is present value for the field.\r\n     */\r\n    void onIsPresentEdited();\r\n\r\n    /*!\r\n     *  Sets the edited reserved value for the field.\r\n     */\r\n    void onReservedEdited();\r\n\r\n    /*!\r\n     *  Sets the edited field ID value for the field.\r\n     */\r\n    void onFieldIdChanged();\r\n\r\n    /*!\r\n     *  Sets the selected write constraint value for the field.\r\n     *\r\n     *    @param [in] newIndex    The index of the selected write constraint value.\r\n     */\r\n    void onWriteConstraintSelected(int newIndex);\r\n\r\n    /*!\r\n     *  Sets the edited write constraint minimum value for the field.\r\n     *\r\n     *    @param [in] newWriteConstraintMin   The edited write constraint minimum value.\r\n     */\r\n    void onWriteConstraintMinimumEdited();\r\n\r\n    /*!\r\n     *  Sets the edited write constraint maximum value for the field.\r\n     *\r\n     *    @param [in] newWriteConstraintMax   The edited write constraint maximum value.\r\n     */\r\n    void onWriteConstraintMaximumEdited();\r\n\r\nprivate:\r\n\t\r\n\t//! No copying. No assignment.\r\n    SingleFieldEditor(const SingleFieldEditor& other);\r\n    SingleFieldEditor& operator=(const SingleFieldEditor& other);\r\n\r\n    /*!\r\n     *  Change the signal blocking status of the expression editors in this editor.\r\n     *\r\n     *    @param [in] blockStatus     The new signal blocking status for the expression editors.\r\n     */\r\n    void changeExpressionEditorSignalBlockStatus(bool blockStatus) const;\r\n\r\n    /*!\r\n     *  Calculates the value of an expression.\r\n     *\r\n     *    @param [in] expression  The expression to be calculated.\r\n     *\r\n     *    @return The calculated value of an expression.\r\n     */\r\n    QString formattedValueFor(QString const& expression) const;\r\n\r\n    /*!\r\n     *  Set the status of  write constraint minimum and maximum editors.\r\n     *\r\n     *    @param [in] writeConstraintIndex    The index of the write constraint value.\r\n     */\r\n    void setWriteMinMaxConstraintEnableStatus(int writeConstraintIndex) const;\r\n    \r\n    /*!\r\n     *  Connect the signals of the different editors in this editor.\r\n     */\r\n    void connectSignals();\r\n\r\n    /*!\r\n     *  Sets the layout for this editor.\r\n     */\r\n    void setupLayout();\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! The name group editor.\r\n    NameGroupEditor nameEditor_;\r\n\r\n    //! The resets editor.\r\n    ResetsEditor* resetsEditor_;\r\n\r\n    //! The enumerations editor.\r\n    FieldEditor* enumerationsEditor_;\r\n\r\n    //! The offset editor, accepts expressions.\r\n    ExpressionEditor* offsetEditor_;\r\n\r\n    //! The width editor, accepts expressions..\r\n    ExpressionEditor* widthEditor_;\r\n\r\n    //! The volatility selector.\r\n    BooleanComboBox* volatileEditor_;\r\n\r\n    //! The access selector.\r\n    AccessComboBox* accessEditor_;\r\n\r\n    //! The modified write value selector.\r\n    ModWriteComboBox* modifiedWriteValueEditor_;\r\n\r\n    //! The read action selector.\r\n    ReadActionComboBox* readActionEditor_;\r\n\r\n    //! The testable value selector.\r\n    BooleanComboBox* testableEditor_;\r\n\r\n    //! The test constrained value selector.\r\n    TestConstraintComboBox* testConstrainedEditor_;\r\n\r\n    //! The presence editor.\r\n    ExpressionEditor* isPresentEditor_;\r\n\r\n    //! The reserved editor.\r\n    ExpressionEditor* reservedEditor_;\r\n\r\n    //! The editor for fieldID.\r\n    QLineEdit* fieldIdEditor_;\r\n\r\n    //! The expression parser.\r\n    QSharedPointer<ExpressionParser> expressionParser_;\r\n\r\n    //! The write constraint selector.\r\n    QComboBox* writeConstraintEditor_;\r\n\r\n    //! The write constraint minimum value editor.\r\n    ExpressionEditor* writeConstraintMinLimit_;\r\n\r\n    //! The write constraint maximum value editor.\r\n    ExpressionEditor* writeConstraintMaxLimit_;\r\n\r\n    //! Name of the edited field.\r\n    std::string fieldName_;\r\n\r\n    //! The used field validator.\r\n    QSharedPointer<FieldValidator> fieldValidator_;\r\n\r\n    //! Interface for fields.\r\n    FieldInterface* fieldInterface_;\r\n\r\n    //! Register containing the edited field.\r\n    QSharedPointer<Register> containingRegister_;\r\n\r\n    //! The editor for field access policies.\r\n    FieldAccessPoliciesEditor* accessPoliciesEditor_;\r\n};\r\n\r\n#endif // SINGLEFIELDEDITOR_H\r\n"
  },
  {
    "path": "editors/ComponentEditor/memoryMaps/SingleMemoryMapEditor.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: SingleMemoryMapEditor.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Mikko Teuho\r\n// Date: 15.04.2015\r\n//\r\n// Description:\r\n// Editor for editing the details of a single memory map.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"SingleMemoryMapEditor.h\"\r\n\r\n#include <QScrollArea>\r\n#include <QLabel>\r\n\r\n#include <editors/ComponentEditor/common/ExpressionEditor.h>\r\n#include <editors/ComponentEditor/memoryMaps/RemapModeReferenceEditor.h>\r\n#include <editors/ComponentEditor/memoryMaps/SubspaceMapsEditor.h>\r\n#include <editors/ComponentEditor/parameters/ComponentParameterModel.h>\r\n#include <KactusAPI/include/MemoryMapInterface.h>\r\n#include <KactusAPI/include/ModeReferenceInterface.h>\r\n\r\n#include <IPXACTmodels/Component/Component.h>\r\n#include <IPXACTmodels/Component/MemoryMapBase.h>\r\n#include <IPXACTmodels/Component/MemoryMap.h>\r\n#include <IPXACTmodels/Component/MemoryRemap.h>\r\n#include <IPXACTmodels/Component/RemapState.h>\r\n\r\n#include <QFormLayout>\r\n#include <QSplitter>\r\n\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SingleMemoryMapEditor::SingleMemoryMapEditor()\r\n//-----------------------------------------------------------------------------\r\nSingleMemoryMapEditor::SingleMemoryMapEditor(QSharedPointer<Component> component,\r\n    QSharedPointer<MemoryMapBase> memoryRemap, QString const& parentMapName, LibraryInterface* libHandler,\r\n    QSharedPointer<ParameterFinder> parameterFinder, QSharedPointer<ExpressionParser> expressionParser,\r\n    MemoryMapInterface* mapInterface, bool isMemoryRemap, QWidget* parent):\r\nItemEditor(component, libHandler, parent),\r\nnameEditor_(memoryRemap, component->getRevision(), this),\r\naddressBlockEditor_(new MemoryMapEditor(component, libHandler, parameterFinder, expressionParser,\r\n    mapInterface->getAddressBlockInterface(), memoryRemap->getMemoryBlocks(), this)),\r\nsubspaceMapEditor_(new SubspaceMapsEditor(component, parameterFinder, expressionParser,\r\n    mapInterface->getSubspaceMapInterface() , memoryRemap->getMemoryBlocks(), this)),\r\naddressUnitBitsEditor_(new ExpressionEditor(parameterFinder, this)),\r\nisPresentEditor_(new ExpressionEditor(parameterFinder, this)),\r\ntargetInterfaceLabel_(new QLabel(this)),\r\nremapStateSelector_(new ReferenceSelector(this)),\r\nremapName_(memoryRemap->name().toStdString()),\r\nparentMapName_(parentMapName.toStdString()),\r\nmapInterface_(mapInterface),\r\nisMemoryRemap_(isMemoryRemap)\r\n{\r\n    QString nameEditorTitle;\r\n    if (!isMemoryRemap_)\r\n    {\r\n        remapName_ = \"\";\r\n        nameEditorTitle = \"Memory map name and description\";\r\n    }\r\n    else \r\n    {\r\n        nameEditorTitle = \"Memory remap name and description\";\r\n    }\r\n    nameEditor_.setTitle(nameEditorTitle);\r\n\r\n    mapInterface_->setMemoryMaps(component);\r\n\r\n    auto componentParametersModel = new ComponentParameterModel(parameterFinder, this);\r\n    componentParametersModel->setExpressionParser(expressionParser);\r\n\r\n    // Different parameter completers for different editors to avoid clashes.\r\n    auto isPresentParameterCompleter = new QCompleter(this);\r\n    isPresentParameterCompleter->setModel(componentParametersModel);\r\n\r\n    auto aubParameterCompleter = new QCompleter(this);\r\n    aubParameterCompleter->setModel(componentParametersModel);\r\n\r\n    isPresentEditor_->setFixedHeight(ExpressionEditor::DEFAULT_HEIGHT);\r\n    isPresentEditor_->setAppendingCompleter(isPresentParameterCompleter);\r\n\r\n    addressUnitBitsEditor_->setFixedHeight(ExpressionEditor::DEFAULT_HEIGHT);\r\n    addressUnitBitsEditor_->setAppendingCompleter(aubParameterCompleter);\r\n\r\n    remapStateSelector_->setProperty(\"mandatoryField\", true);\r\n\r\n    modeRefInterface_ = mapInterface_->getModeReferenceInterface();\r\n    modeRefInterface_->setContainingElementIsRemap(isMemoryRemap);\r\n\r\n    if (isMemoryRemap_)\r\n    {\r\n        addressUnitBitsEditor_->setEnabled(false);\r\n\r\n        currentRemap_ = memoryRemap.dynamicCast<MemoryRemap>();\r\n        modeRefInterface_->setModeReferences(mapInterface_->getRemapModeReferences(parentMapName_, remapName_));\r\n\r\n        auto containingModeRefs = mapInterface_->getRemapModeReferencesExcludingRemap(parentMapName_, remapName_);\r\n        modeRefInterface_->setContainingElementModeReferences(containingModeRefs);\r\n        modeRefInterface_->setContainingElementIsRemap(true);\r\n    }\r\n    else\r\n    {\r\n        // Clear the current mode refs, if user was first editing remap, then moves to default remap editor. If not done, \r\n        // ghost cells will appear in the mode ref table.\r\n        if (auto currentModeRefs = modeRefInterface_->getModeReferences(); !currentModeRefs.empty())\r\n        {\r\n            modeRefInterface_->setModeReferences(std::vector<std::pair<unsigned int, std::string> >());\r\n        }\r\n    }\r\n\r\n    modeReferenceEditor_ = new RemapModeReferenceEditor(modeRefInterface_, this, isMemoryRemap_);\r\n\r\n    connectSignals();\r\n    setupLayout();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SingleMemoryMapEditor::connectSignals()\r\n//-----------------------------------------------------------------------------\r\nvoid SingleMemoryMapEditor::connectSignals()\r\n{\r\n    connect(addressBlockEditor_, SIGNAL(contentChanged()), this, SIGNAL(contentChanged()), Qt::UniqueConnection);\r\n    connect(addressBlockEditor_, SIGNAL(increaseReferences(QString)),\r\n        this, SIGNAL(increaseReferences(QString)), Qt::UniqueConnection);\r\n    connect(addressBlockEditor_, SIGNAL(decreaseReferences(QString)),\r\n        this, SIGNAL(decreaseReferences(QString)), Qt::UniqueConnection);\r\n    connect(addressBlockEditor_, SIGNAL(childAdded(int)), this, SIGNAL(childAdded(int)), Qt::UniqueConnection);\r\n    connect(addressBlockEditor_, SIGNAL(childRemoved(int)), this, SIGNAL(childRemoved(int)), Qt::UniqueConnection);\r\n    connect(addressBlockEditor_, SIGNAL(childAddressingChanged(int)),\r\n        this, SIGNAL(childAddressingChanged(int)), Qt::UniqueConnection);\r\n\r\n    connect(addressBlockEditor_, SIGNAL(graphicsChanged(int)), this, SIGNAL(childGraphicsChanged(int)), Qt::UniqueConnection);\r\n\r\n    connect(this, SIGNAL(assignNewAddressUnitBits(QString const&)),\r\n        addressBlockEditor_, SIGNAL(assignNewAddressUnitBits(QString const&)), Qt::UniqueConnection);\r\n\r\n    connect(addressBlockEditor_, SIGNAL(addressBlockNameChanged(QString const&, QString const&)),\r\n        this, SIGNAL(addressBlockNameChanged(QString const&, QString const&)), Qt::UniqueConnection);\r\n\r\n    connect(subspaceMapEditor_, SIGNAL(childAdded(int)), this, SIGNAL(childAdded(int)), Qt::UniqueConnection);\r\n    connect(subspaceMapEditor_, SIGNAL(childRemoved(int)), this, SIGNAL(childRemoved(int)), Qt::UniqueConnection);\r\n\r\n    connect(subspaceMapEditor_, SIGNAL(contentChanged()), this, SIGNAL(contentChanged()), Qt::UniqueConnection);\r\n    connect(subspaceMapEditor_, SIGNAL(increaseReferences(QString)),\r\n        this, SIGNAL(increaseReferences(QString)), Qt::UniqueConnection);\r\n    connect(subspaceMapEditor_, SIGNAL(decreaseReferences(QString)),\r\n        this, SIGNAL(decreaseReferences(QString)), Qt::UniqueConnection);\r\n\r\n    connect(subspaceMapEditor_, SIGNAL(childAddressingChanged(int)),\r\n        this, SIGNAL(childAddressingChanged(int)), Qt::UniqueConnection);\r\n    connect(subspaceMapEditor_, SIGNAL(graphicsChanged(int)),\r\n        this, SIGNAL(childGraphicsChanged(int)), Qt::UniqueConnection);\r\n\r\n    connect(this, SIGNAL(assignNewAddressUnitBits(QString const&)),\r\n        subspaceMapEditor_, SIGNAL(assignNewAddressUnitBits(QString const&)), Qt::UniqueConnection);\r\n\r\n    connect(subspaceMapEditor_, SIGNAL(subspaceMapNameChanged(QString const&, QString const&)),\r\n        this, SIGNAL(subspaceMapNameChanged(QString const&, QString const&)), Qt::UniqueConnection);\r\n\r\n    connect(subspaceMapEditor_, SIGNAL(invalidateOtherFilter()),\r\n        addressBlockEditor_, SIGNAL(invalidateThisFilter()), Qt::UniqueConnection);\r\n    connect(addressBlockEditor_, SIGNAL(invalidateOtherFilter()),\r\n        subspaceMapEditor_, SIGNAL(invalidateThisFilter()), Qt::UniqueConnection);\r\n\r\n    connect(&nameEditor_, SIGNAL(contentChanged()), this, SLOT(refreshTargetBinding()), Qt::UniqueConnection);\r\n    connect(&nameEditor_, SIGNAL(contentChanged()), this, SIGNAL(contentChanged()), Qt::UniqueConnection);\r\n    connect(&nameEditor_, SIGNAL(nameChanged()), this, SIGNAL(graphicsChanged()), Qt::UniqueConnection);\r\n\r\n    connect(addressUnitBitsEditor_, SIGNAL(editingFinished()),\r\n        this, SLOT(updateAddressUnitBits()), Qt::UniqueConnection);\r\n    connect(addressUnitBitsEditor_, SIGNAL(increaseReference(QString const&)),\r\n        this, SIGNAL(increaseReferences(QString const&)), Qt::UniqueConnection);\r\n    connect(addressUnitBitsEditor_, SIGNAL(decreaseReference(QString const&)),\r\n        this, SIGNAL(decreaseReferences(QString const&)), Qt::UniqueConnection);\r\n    connect(addressUnitBitsEditor_, SIGNAL(editingFinished()), this, SIGNAL(contentChanged()), Qt::UniqueConnection);\r\n    connect(addressUnitBitsEditor_, SIGNAL(editingFinished()), this, SIGNAL(graphicsChanged()), Qt::UniqueConnection);\r\n\r\n    connect(isPresentEditor_, SIGNAL(increaseReference(QString const&)),\r\n        this, SIGNAL(increaseReferences(QString const&)), Qt::UniqueConnection);\r\n    connect(isPresentEditor_, SIGNAL(decreaseReference(QString const&)),\r\n        this, SIGNAL(decreaseReferences(QString const&)), Qt::UniqueConnection);\r\n\r\n    connect(isPresentEditor_, SIGNAL(editingFinished()), this, SLOT(onIsPresentEdited()), Qt::UniqueConnection);\r\n    connect(isPresentEditor_, SIGNAL(editingFinished()), this, SIGNAL(contentChanged()), Qt::UniqueConnection);\r\n    connect(isPresentEditor_, SIGNAL(editingFinished()), this, SIGNAL(graphicsChanged()), Qt::UniqueConnection);\r\n\r\n    connect(&nameEditor_, SIGNAL(nameChanged()), this, SLOT(onNameChange()), Qt::UniqueConnection);\r\n\r\n    connect(modeReferenceEditor_, SIGNAL(contentChanged()), this, SIGNAL(contentChanged()), Qt::UniqueConnection);\r\n    connect(modeReferenceEditor_, SIGNAL(contentChanged()), this, SLOT(onRemapModeReferencesEdited()), Qt::UniqueConnection);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SingleMemoryMapEditor::refresh()\r\n//-----------------------------------------------------------------------------\r\nvoid SingleMemoryMapEditor::refresh()\r\n{\r\n    mapInterface_->setMemoryMaps(component());\r\n\r\n    nameEditor_.refresh();\r\n    addressBlockEditor_->refresh();\r\n    subspaceMapEditor_->refresh();\r\n\r\n    refreshTargetBinding();\r\n    addressUnitBitsEditor_->setExpression(QString::fromStdString(mapInterface_->getAddressUnitBitsExpression(parentMapName_)));\r\n    addressUnitBitsEditor_->setToolTip(QString::fromStdString(mapInterface_->getAddressUnitBitsValue(parentMapName_)));\r\n\r\n    if (component()->getRevision() != Document::Revision::Std22)\r\n    {\r\n        if (!isMemoryRemap_)\r\n        {\r\n            remapStateSelector_->setEnabled(false);\r\n            QStringList defaultList;\r\n            defaultList.append(\"Default\");\r\n            remapStateSelector_->refresh(defaultList);\r\n            remapStateSelector_->selectItem(\"Default\");\r\n        }\r\n        else\r\n        {\r\n            refreshRemapStateSelector();\r\n        }\r\n    }\r\n    else\r\n    {\r\n        // Refresh mode references for use in current editor.\r\n        if (isMemoryRemap_)\r\n        {\r\n            modeRefInterface_->setModeReferences(mapInterface_->getRemapModeReferences(parentMapName_, remapName_));\r\n            modeRefInterface_->setContainingElementIsRemap(true);\r\n\r\n            auto containingModeRefs = mapInterface_->getRemapModeReferencesExcludingRemap(parentMapName_, remapName_);\r\n            modeRefInterface_->setContainingElementModeReferences(containingModeRefs);\r\n        }\r\n        // Clear mode references from interface, \r\n        else\r\n        {\r\n            if (auto currentModeRefs = modeRefInterface_->getModeReferences(); !currentModeRefs.empty())\r\n            {\r\n                modeRefInterface_->setModeReferences(std::vector<std::pair<unsigned int, std::string> >());\r\n            }\r\n        }\r\n    }\r\n\r\n    isPresentEditor_->setExpression(\r\n        QString::fromStdString(mapInterface_->getIsPresentExpression(parentMapName_, remapName_)));\r\n    isPresentEditor_->setToolTip(\r\n        QString::fromStdString(mapInterface_->getIsPresentValue(parentMapName_, remapName_)));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SingleMemoryMapEditor::setupLayout()\r\n//-----------------------------------------------------------------------------\r\nvoid SingleMemoryMapEditor::setupLayout()\r\n{\r\n    QScrollArea* scrollArea = new QScrollArea(this);\r\n    scrollArea->setWidgetResizable(true);\r\n    scrollArea->setFrameShape(QFrame::NoFrame);\r\n\r\n    QHBoxLayout* scrollLayot = new QHBoxLayout(this);\r\n    scrollLayot->addWidget(scrollArea);\r\n    scrollLayot->setContentsMargins(0, 0, 0, 0);\r\n\r\n    QGroupBox* memoryMapDefinitionGroup = new QGroupBox(tr(\"Memory map definition\"));\r\n\r\n    QFormLayout* memoryMapDefinitionGroupLayout = new QFormLayout(memoryMapDefinitionGroup);\r\n\r\n    QLayout* topOfPageLayout;\r\n    if (Document::Revision revision = component()->getRevision(); \r\n        revision == Document::Revision::Std14)\r\n    {\r\n        memoryMapDefinitionGroupLayout->addRow(tr(\"Address Unit Bits [AUB]:\"), addressUnitBitsEditor_);\r\n        memoryMapDefinitionGroupLayout->addRow(tr(\"Is present, f(x):\"), isPresentEditor_);\r\n        memoryMapDefinitionGroupLayout->addRow(tr(\"Remap state:\"), remapStateSelector_);\r\n        memoryMapDefinitionGroupLayout->addRow(tr(\"Slave interface binding:\"), targetInterfaceLabel_);\r\n        connect(remapStateSelector_, SIGNAL(itemSelected(QString const&)),\r\n            this, SLOT(onRemapStateSelected(QString const&)), Qt::UniqueConnection);\r\n\r\n        QHBoxLayout* layout = new QHBoxLayout();\r\n        layout->addWidget(&nameEditor_, 0);\r\n        layout->addWidget(memoryMapDefinitionGroup, 0);\r\n        topOfPageLayout = layout;\r\n        modeReferenceEditor_->setVisible(false);\r\n    }\r\n    else if (revision == Document::Revision::Std22)\r\n    {\r\n        memoryMapDefinitionGroup->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Maximum);\r\n        memoryMapDefinitionGroupLayout->addRow(tr(\"Address Unit Bits [AUB], f(x):\"), addressUnitBitsEditor_);\r\n        memoryMapDefinitionGroupLayout->addRow(tr(\"Target interface binding:\"), targetInterfaceLabel_);    \r\n\r\n        QGridLayout* layout = new QGridLayout();\r\n        layout->addWidget(&nameEditor_, 0, 0, 4, 1);\r\n        layout->addWidget(memoryMapDefinitionGroup, 0, 1, 1, 1);\r\n        layout->addWidget(modeReferenceEditor_, 1, 1, 3, 1);\r\n\r\n        if (!isMemoryRemap_)\r\n        {\r\n            modeReferenceEditor_->setEnabled(false);\r\n        }\r\n\r\n        topOfPageLayout = layout;\r\n    }\r\n\r\n    QWidget* topOfPageWidget = new QWidget();\r\n    topOfPageWidget->setSizeIncrement(QSizePolicy::Expanding, QSizePolicy::Maximum);\r\n    topOfPageWidget->setLayout(topOfPageLayout);\r\n    topOfPageWidget->setContentsMargins(0, 0, 0, 0);\r\n\r\n    QSplitter* verticalSplitter = new QSplitter(Qt::Vertical, scrollArea);\r\n    verticalSplitter->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);\r\n    verticalSplitter->addWidget(topOfPageWidget);\r\n    verticalSplitter->addWidget(addressBlockEditor_);\r\n    verticalSplitter->addWidget(subspaceMapEditor_);\r\n\r\n    verticalSplitter->setStretchFactor(1,1);\r\n\r\n    for (int i = 1; i <= verticalSplitter->count(); ++i)\r\n    {\r\n        QSplitterHandle* handle = verticalSplitter->handle(i);\r\n\r\n        QVBoxLayout* handleLayout = new QVBoxLayout(handle);\r\n        handleLayout->setSpacing(0);\r\n        handleLayout->setContentsMargins(0, 0, 0, 0);\r\n\r\n        QFrame* line = new QFrame(handle);\r\n        line->setLineWidth(2);\r\n        line->setMidLineWidth(2);\r\n        line->setFrameShape(QFrame::HLine);\r\n        line->setFrameShadow(QFrame::Sunken);\r\n        handleLayout->addWidget(line);\r\n    }\r\n\r\n    verticalSplitter->setHandleWidth(10);\r\n\r\n    scrollArea->setWidget(verticalSplitter);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SingleMemoryMapEditor::showEvent()\r\n//-----------------------------------------------------------------------------\r\nvoid SingleMemoryMapEditor::showEvent(QShowEvent* event)\r\n{\r\n    QWidget::showEvent(event);\r\n\r\n    if (component()->getRevision() == Document::Revision::Std22)\r\n    {\r\n        emit helpUrlRequested(\"componenteditor/memorymap2022.html\");\r\n    }\r\n    else\r\n    {\r\n        emit helpUrlRequested(\"componenteditor/memorymap.html\");\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SingleMemoryMapEditor::refreshSlaveBinding()\r\n//-----------------------------------------------------------------------------\r\nvoid SingleMemoryMapEditor::refreshTargetBinding()\r\n{\r\n    QString targetInterfaceText (\"No binding\");\r\n\r\n    QStringList interfaceNames = component()->getTargetInterfaces(QString::fromStdString(parentMapName_));\r\n    if (!interfaceNames.isEmpty())\r\n    {\r\n        targetInterfaceText = interfaceNames.join(\", \");\r\n    }\r\n    targetInterfaceLabel_->setText(targetInterfaceText);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SingleMemoryMapEditor::updateAddressUnitBits()\r\n//-----------------------------------------------------------------------------\r\nvoid SingleMemoryMapEditor::updateAddressUnitBits()\r\n{\r\n    addressUnitBitsEditor_->finishEditingCurrentWord();\r\n\r\n    mapInterface_->setAddressUnitBits(parentMapName_, addressUnitBitsEditor_->getExpression().toStdString());\r\n    addressUnitBitsEditor_->setToolTip(QString::fromStdString(mapInterface_->getAddressUnitBitsValue(parentMapName_)));\r\n\r\n    emit addressUnitBitsChanged();\r\n    emit contentChanged();\r\n\r\n    emit assignNewAddressUnitBits(addressUnitBitsEditor_->getExpression());\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SingleMemoryMapEditor::onIsPresentEdited()\r\n//-----------------------------------------------------------------------------\r\nvoid SingleMemoryMapEditor::onIsPresentEdited()\r\n{\r\n    isPresentEditor_->finishEditingCurrentWord();\r\n\r\n    QString newIsPresent = isPresentEditor_->getExpression();\r\n\r\n    mapInterface_->setIsPresent(parentMapName_, newIsPresent.toStdString(), remapName_);\r\n    isPresentEditor_->setToolTip(\r\n        QString::fromStdString(mapInterface_->getIsPresentValue(parentMapName_, remapName_)));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SingleMemoryMapEditor::refreshRemapStateSelector()\r\n//-----------------------------------------------------------------------------\r\nvoid SingleMemoryMapEditor::refreshRemapStateSelector()\r\n{\r\n    QStringList remapStateNames;\r\n\r\n    for (QSharedPointer<RemapState> remapState : *component()->getRemapStates())\r\n    {\r\n        remapStateNames.append(remapState->name());\r\n    }\r\n\r\n    remapStateSelector_->refresh(remapStateNames);\r\n\r\n    if (isMemoryRemap_)\r\n    {\r\n        QString remapState = QString::fromStdString(mapInterface_->getRemapState(parentMapName_, remapName_));\r\n        if (remapState.isEmpty())\r\n        {\r\n            remapStateSelector_->selectItem(QString(\"No remap state selected.\"));\r\n        }\r\n        else\r\n        {\r\n            remapStateSelector_->selectItem(remapState);\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SingleMemoryMapEditor::onRemapStateSelected()\r\n//-----------------------------------------------------------------------------\r\nvoid SingleMemoryMapEditor::onRemapStateSelected(QString const& newRemapState)\r\n{\r\n    if (isMemoryRemap_)\r\n    {\r\n        mapInterface_->setRemapState(parentMapName_, remapName_, newRemapState.toStdString());\r\n        emit contentChanged();\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SingleMemoryMapEditor::onRemapModeReferencesEdited()\r\n//-----------------------------------------------------------------------------\r\nvoid SingleMemoryMapEditor::onRemapModeReferencesEdited()\r\n{\r\n    auto newRemapModes = modeRefInterface_->getModeReferences();\r\n\r\n    mapInterface_->setRemapModeReferences(parentMapName_, remapName_, newRemapModes);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SingleMemoryMapEditor::onMemoryMapNameChanged()\r\n//-----------------------------------------------------------------------------\r\nvoid SingleMemoryMapEditor::onMemoryMapNameChanged(QString const& oldName, QString const& newName)\r\n{\r\n    if (remapName_.empty() && oldName == QString::fromStdString(parentMapName_))\r\n    {\r\n        parentMapName_ = newName.toStdString();\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SingleMemoryMapEditor::onMemoryRemapNameChanged()\r\n//-----------------------------------------------------------------------------\r\nvoid SingleMemoryMapEditor::onMemoryRemapNameChanged(QString const& parentName, QString const& oldName,\r\n    QString const& newName)\r\n{\r\n    if (parentName == QString::fromStdString(parentMapName_) &&  oldName == QString::fromStdString(remapName_))\r\n    {\r\n        remapName_ = newName.toStdString();\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SingleMemoryMapEditor::onNameChange()\r\n//-----------------------------------------------------------------------------\r\nvoid SingleMemoryMapEditor::onNameChange()\r\n{\r\n    if (remapName_.empty())\r\n    {\r\n        parentMapName_ = nameEditor_.name().toStdString();\r\n    }\r\n    else\r\n    {\r\n        remapName_ = nameEditor_.name().toStdString();\r\n    }\r\n}\r\n"
  },
  {
    "path": "editors/ComponentEditor/memoryMaps/SingleMemoryMapEditor.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: SingleMemoryMapEditor.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Mikko Teuho\r\n// Date: 15.04.2015\r\n//\r\n// Description:\r\n// Editor for editing the details of a single memory map.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef SINGLEMEMORYMAPEDITOR_H\r\n#define SINGLEMEMORYMAPEDITOR_H\r\n\r\n#include \"memorymapeditor.h\"\r\n\r\n#include <editors/ComponentEditor/itemeditor.h>\r\n#include <editors/ComponentEditor/common/ReferenceSelector/ReferenceSelector.h>\r\n\r\n#include <common/widgets/nameGroupEditor/namegroupeditor.h>\r\n\r\n#include <QLineEdit>\r\n#include <QLabel>\r\n\r\nclass Component;\r\nclass MemoryMap;\r\nclass MemoryRemap;\r\nclass MemoryMapBase;\r\nclass ExpressionEditor;\r\nclass ExpressionParser;\r\nclass MemoryMapInterface;\r\nclass SubspaceMapsEditor;\r\nclass RemapModeReferenceEditor;\r\nclass ModeReferenceInterface;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Editor for editing the details of a single memory map.\r\n//-----------------------------------------------------------------------------\r\nclass SingleMemoryMapEditor : public ItemEditor\r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\r\n    /*!\r\n     *  The constructor.\r\n     *\r\n     *    @param [in] component           The component that contains the editor.\r\n     *    @param [in] memoryRemap         The memory remap being edited.\r\n     *    @param [in] parentMapName       Name of the parent of the memory remap being edited.\r\n     *    @param [in] libHandler          The instance that manages the library.\r\n     *    @param [in] parameterFinder     The finder for the parameter references.\r\n     *    @param [in] expressionParser    The expression parser.\r\n     *    @param [in] mapInterface        Interface for memory maps.\r\n     *    @param [in] isMemoryRemap       Flag for informing if the edited item is a memory map or a remap.\r\n     *    @param [in] parent              The owner of this editor.\r\n     */\r\n    SingleMemoryMapEditor(QSharedPointer<Component> component,\r\n        QSharedPointer<MemoryMapBase> memoryRemap,\r\n        QString const& parentMapName,\r\n        LibraryInterface* libHandler,\r\n        QSharedPointer<ParameterFinder> parameterFinder,\r\n        QSharedPointer<ExpressionParser> expressionParser,\r\n        MemoryMapInterface* mapInterface,\r\n        bool isMemoryRemap,\r\n        QWidget* parent = 0);\r\n\r\n    /*!\r\n     *  The destructor.\r\n     */\r\n    virtual ~SingleMemoryMapEditor() = default;\r\n\r\n\t/*!\r\n\t *  Reload the information from the model to the editor.\r\n\t */\r\n\tvirtual void refresh();\r\n\r\npublic slots:\r\n    \r\n    /*\r\n     *  Handles memory map name change from memory maps editor.\r\n     *\r\n     *    @param [in] oldName     The old name.\r\n     *    @param [in] newName     The new name.\r\n     */\r\n    void onMemoryMapNameChanged(QString const& oldName, QString const& newName);\r\n\r\n    /*\r\n     *  Handles of memory remap name change from memory maps editor.\r\n     *\r\n     *    @param [in] parentName  Name of the containing memory map.\r\n     *    @param [in] oldName     The old name.\r\n     *    @param [in] newName     The new name.\r\n     */\r\n    void onMemoryRemapNameChanged(QString const& parentName, QString const& oldName, QString const& newName);\r\n\r\n    /*\r\n     *  Handles memory item name change from memory name editor.\r\n     */\r\n    void onNameChange();\r\n\r\nprotected:\r\n    \r\n    /*!\r\n     *  The show event for this editor.\r\n     *\r\n     *    @param [in] event   The show event.\r\n     */\r\n    virtual void showEvent(QShowEvent * event);\r\n\r\nprivate slots:\r\n\r\n    /*!\r\n     *  Updates the name of the current target interface binding.\r\n     */\r\n    void refreshTargetBinding();\r\n\r\n    /*!\r\n     *  Updates the address unit bits [AUB].\r\n     */\r\n    void updateAddressUnitBits();\r\n    \r\n    //! Called when isPresent has been edited.\r\n    void onIsPresentEdited();\r\n\r\n    /*!\r\n     *  Sets the new remap state to the memory remap.\r\n     *\r\n     *    @param [in] newRemapState   The name of the selected remap state.\r\n     */\r\n    void onRemapStateSelected(QString const& newRemapState);\r\n\r\n    /*!\r\n     *\tGets updated remap mode references from mode reference interface, and saves to remap.\r\n     */\r\n    void onRemapModeReferencesEdited();\r\n\r\nsignals:\r\n    \r\n    /*!\r\n     *  Informs contents of the change in address unit bits.\r\n     */\r\n    void addressUnitBitsChanged();\r\n\r\n    /*!\r\n     *  Emitted when address unit bits are changed for memory map.\r\n     *\r\n     *    @param [in] newAddressUnitBits  The new address unit bits.\r\n     */\r\n    void assignNewAddressUnitBits(QString const& newAddressUnitBits);\r\n\r\n    /*\r\n     *  Informs of address block name change.\r\n     *\r\n     *    @param [in] oldName     The old name.\r\n     *    @param [in] newName     The new name.\r\n     */\r\n    void addressBlockNameChanged(QString const& oldName, QString const& newName);\r\n\r\n    /*!\r\n     *  Informs of subspace map name change.\r\n     *\r\n     *    @param [in] oldName     The old name.\r\n     *    @param [in] newName     The new name.\r\n     */\r\n    void subspaceMapNameChanged(QString const& oldName, QString const& newName);\r\n\r\n    /*!\r\n     *  Informs change in child addressing.\r\n     *\r\n     *    @param [in]\r\n     */\r\n    void childAddressingChanged(int);\r\n\r\n    /*!\r\n     *  Informs change in child graphics.\r\n     *\r\n     *    @param [in]\r\n     */\r\n    void childGraphicsChanged(int);\r\n\r\nprivate:\r\n\r\n    //! No copying. No assignment.\r\n    SingleMemoryMapEditor(const SingleMemoryMapEditor& other);\r\n    SingleMemoryMapEditor& operator=(const SingleMemoryMapEditor& other);\r\n\r\n    /*!\r\n     *  Connect the editor signals.\r\n     */\r\n    void connectSignals();\r\n\r\n\t/*!\r\n\t *  Set up the layout for the editor.\r\n\t */\r\n\tvoid setupLayout();\r\n\r\n    /*!\r\n     *  Updates the remap state selector.\r\n     */\r\n    void refreshRemapStateSelector();\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n\t//! Editor to set the name, display name and description of the memory remap.\r\n\tNameGroupEditor nameEditor_;\r\n\r\n    //! The editor for the address blocks.\r\n    MemoryMapEditor* addressBlockEditor_;\r\n\r\n    //! Editor for subspace maps.\r\n    SubspaceMapsEditor* subspaceMapEditor_;\r\n\r\n    //! The editor for the memory maps address unit bits [AUB].\r\n    ExpressionEditor* addressUnitBitsEditor_;\r\n\r\n    //! The editor for isPresent-property.\r\n    ExpressionEditor* isPresentEditor_;\r\n\r\n    //! The label for the target interface binding.\r\n    QLabel* targetInterfaceLabel_;\r\n    \r\n    //! The remap state selector.\r\n    ReferenceSelector* remapStateSelector_;\r\n\r\n    //! Name of the memory remap being edited.\r\n    std::string remapName_;\r\n\r\n    //! Name of the parent of the memory remap.\r\n    std::string parentMapName_;\r\n\r\n    //! Interface for memory maps.\r\n    MemoryMapInterface* mapInterface_;\r\n\r\n    //! Flag for identifying memory maps and remaps.\r\n    bool isMemoryRemap_;\r\n\r\n    //! Editor for remap mode references.\r\n    RemapModeReferenceEditor* modeReferenceEditor_;\r\n\r\n    //! The current remap used by this instance of the editor. Set if the editor is used for a remap.\r\n    QSharedPointer<MemoryRemap> currentRemap_;\r\n\r\n    //! Interface for accessing remap mode references.\r\n    ModeReferenceInterface* modeRefInterface_;\r\n};\r\n\r\n#endif // SINGLEMEMORYMAPEDITOR_H\r\n"
  },
  {
    "path": "editors/ComponentEditor/memoryMaps/SingleRegisterEditor.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: SingleRegisterEditor.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Mikko Teuho\r\n// Date: 24.04.2015\r\n//\r\n// Description:\r\n// Editor for editing the details of a single register.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"SingleRegisterEditor.h\"\r\n#include \"AccessPoliciesEditor.h\"\r\n\r\n#include <common/widgets/accessComboBox/accesscombobox.h>\r\n#include <common/widgets/booleanComboBox/booleancombobox.h>\r\n\r\n#include <KactusAPI/include/LibraryInterface.h>\r\n\r\n#include <editors/ComponentEditor/common/ExpressionEditor.h>\r\n#include <KactusAPI/include/ExpressionFormatter.h>\r\n#include <KactusAPI/include/ExpressionParser.h>\r\n#include <editors/ComponentEditor/parameters/ComponentParameterModel.h>\r\n#include <KactusAPI/include/RegisterInterface.h>\r\n#include <KactusAPI/include/AccessPolicyInterface.h>\r\n\r\n#include <IPXACTmodels/Component/Register.h>\r\n#include <IPXACTmodels/Component/AddressBlock.h>\r\n#include <IPXACTmodels/Component/validators/RegisterValidator.h>\r\n\r\n#include <QCompleter>\r\n#include <QFormLayout>\r\n#include <QScrollArea>\r\n#include <QSplitter>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SingleRegisterEditor::SingleRegisterEditor()\r\n//-----------------------------------------------------------------------------\r\nSingleRegisterEditor::SingleRegisterEditor(QSharedPointer<Register> selectedRegister,\r\n    QSharedPointer<Component> component, LibraryInterface* handler,\r\n    QSharedPointer<ParameterFinder> parameterFinder, QSharedPointer<ExpressionParser> expressionParser,\r\n    RegisterInterface* registerInterface,\r\n    QSharedPointer<QList<QSharedPointer<RegisterBase>>> containingRegisterData, QWidget* parent):\r\nItemEditor(component, handler, parent),\r\nregisterName_(selectedRegister->name().toStdString()),\r\nnameEditor_(selectedRegister, component->getRevision(), this, tr(\"Register name and description\")),\r\nfieldsEditor_(new RegisterEditor(selectedRegister->getFields(), component, handler, parameterFinder,\r\n    registerInterface->getSubInterface(), this)),\r\noffsetEditor_(new ExpressionEditor(parameterFinder, this)),\r\nsizeEditor_(new ExpressionEditor(parameterFinder, this)),\r\ndimensionEditor_(new ExpressionEditor(parameterFinder, this)),\r\nisPresentEditor_(new ExpressionEditor(parameterFinder, this)),\r\nvolatileEditor_(new BooleanComboBox(this)),\r\naccessEditor_(new AccessComboBox(this)),\r\nexpressionParser_(expressionParser),\r\ncontainingRegisterData_(containingRegisterData),\r\nregisterInterface_(registerInterface),\r\naccessPoliciesEditor_(new AccessPoliciesEditor(selectedRegister->getAccessPolicies(), \r\n    registerInterface->getAccessPolicyInterface(), this))\r\n{\r\n    registerInterface_->setRegisters(containingRegisterData_);\r\n\r\n    offsetEditor_->setFixedHeight(ExpressionEditor::DEFAULT_HEIGHT);\r\n    sizeEditor_->setFixedHeight(ExpressionEditor::DEFAULT_HEIGHT);\r\n    dimensionEditor_->setFixedHeight(ExpressionEditor::DEFAULT_HEIGHT);\r\n    isPresentEditor_->setFixedHeight(ExpressionEditor::DEFAULT_HEIGHT);\r\n\r\n    ComponentParameterModel* componentParametersModel = new ComponentParameterModel(parameterFinder, this);\r\n    componentParametersModel->setExpressionParser(expressionParser_);\r\n\r\n    auto offsetParameterCompleter = new QCompleter(this);\r\n    offsetParameterCompleter->setModel(componentParametersModel);\r\n\r\n    auto sizeParameterCompleter = new QCompleter(this);\r\n    sizeParameterCompleter->setModel(componentParametersModel);\r\n\r\n    auto dimensionParameterCompleter = new QCompleter(this);\r\n    dimensionParameterCompleter->setModel(componentParametersModel);\r\n\r\n    auto isPresentCompleter = new QCompleter(this);\r\n    isPresentCompleter->setModel(componentParametersModel);\r\n\r\n    offsetEditor_->setAppendingCompleter(offsetParameterCompleter);\r\n    sizeEditor_->setAppendingCompleter(sizeParameterCompleter);\r\n    dimensionEditor_->setAppendingCompleter(dimensionParameterCompleter);\r\n    isPresentEditor_->setAppendingCompleter(isPresentCompleter);\r\n\r\n    setupLayout();\r\n\r\n    connectSignals();\r\n\r\n    offsetEditor_->setProperty(\"mandatoryField\", true);\r\n    sizeEditor_->setProperty(\"mandatoryField\", true);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SingleRegisterEditor::setupLayout()\r\n//-----------------------------------------------------------------------------\r\nvoid SingleRegisterEditor::setupLayout()\r\n{\r\n    QScrollArea* scrollArea = new QScrollArea(this);\r\n    scrollArea->setWidgetResizable(true);\r\n    scrollArea->setFrameShape(QFrame::NoFrame);\r\n\r\n    QHBoxLayout* scrollLayout = new QHBoxLayout(this);\r\n    scrollLayout->addWidget(scrollArea);\r\n    scrollLayout->setContentsMargins(0, 0, 0, 0);\r\n\r\n    QGroupBox* registerDefinitionGroup = new QGroupBox(tr(\"Register definition\"));\r\n\r\n    QFormLayout* registerDefinitionLayout = new QFormLayout(registerDefinitionGroup);\r\n    registerDefinitionLayout->addRow(tr(\"Offset [AUB], f(x):\"), offsetEditor_);\r\n    registerDefinitionLayout->addRow(tr(\"Size [bits], f(x):\"), sizeEditor_);\r\n    registerDefinitionLayout->addRow(tr(\"Dimension, f(x):\"), dimensionEditor_);\r\n\r\n    QLayout* topOfPageLayout;\r\n    if (component()->getRevision() == Document::Revision::Std14)\r\n    {\r\n        registerDefinitionLayout->addRow(tr(\"Is present, f(x):\"), isPresentEditor_);\r\n        registerDefinitionLayout->addRow(tr(\"Volatile:\"), volatileEditor_);\r\n        registerDefinitionLayout->addRow(tr(\"Access:\"), accessEditor_);\r\n\r\n        connect(accessEditor_, SIGNAL(currentTextChanged(QString const&)),\r\n            this, SLOT(onAccessSelected(QString const&)), Qt::UniqueConnection);\r\n\r\n        QHBoxLayout* layout = new QHBoxLayout();\r\n        layout->addWidget(&nameEditor_, 0);\r\n        layout->addWidget(registerDefinitionGroup, 0);\r\n        topOfPageLayout = layout;\r\n    }\r\n    else if (component()->getRevision() == Document::Revision::Std22)\r\n    {\r\n        registerDefinitionLayout->addRow(tr(\"Volatile:\"), volatileEditor_);\r\n\r\n        QGridLayout* layout = new QGridLayout();\r\n        layout->addWidget(&nameEditor_, 0, 0, 2, 1);\r\n        layout->addWidget(registerDefinitionGroup, 0, 1);\r\n        layout->addWidget(accessPoliciesEditor_, 1, 1);\r\n        topOfPageLayout = layout;\r\n    }\r\n\r\n    connect(volatileEditor_, SIGNAL(currentTextChanged(QString const&)),\r\n        this, SLOT(onVolatileSelected(QString const&)), Qt::UniqueConnection);\r\n    \r\n    QWidget* topOfPageWidget = new QWidget();\r\n    topOfPageWidget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);\r\n    topOfPageWidget->setLayout(topOfPageLayout);\r\n    topOfPageWidget->setContentsMargins(0, 0, 0, 0);\r\n\r\n    QSplitter* verticalSplitter = new QSplitter(Qt::Vertical, scrollArea);\r\n    verticalSplitter->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);\r\n    verticalSplitter->addWidget(topOfPageWidget);\r\n    verticalSplitter->addWidget(fieldsEditor_);\r\n    verticalSplitter->setStretchFactor(1, 1);\r\n\r\n    QSplitterHandle* handle = verticalSplitter->handle(1);\r\n    QVBoxLayout* handleLayout = new QVBoxLayout(handle);\r\n    handleLayout->setSpacing(0);\r\n    handleLayout->setContentsMargins(0, 0, 0, 0);\r\n\r\n    QFrame* line = new QFrame(handle);\r\n    line->setLineWidth(2);\r\n    line->setMidLineWidth(2);\r\n    line->setFrameShape(QFrame::HLine);\r\n    line->setFrameShadow(QFrame::Sunken);\r\n    handleLayout->addWidget(line);\r\n\r\n    verticalSplitter->setHandleWidth(10);\r\n\r\n    scrollArea->setWidget(verticalSplitter);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SingleRegisterEditor::refresh()\r\n//-----------------------------------------------------------------------------\r\nvoid SingleRegisterEditor::refresh()\r\n{\r\n    registerInterface_->setRegisters(containingRegisterData_);\r\n\r\n    nameEditor_.refresh();\r\n    fieldsEditor_->refresh();\r\n    accessPoliciesEditor_->refresh();\r\n\r\n    // Block signals from here for the duration of refreshing editors.\r\n    blockSignals(true);\r\n\r\n    changeExpressionEditorsSignalBlockStatus(true);\r\n    \r\n    offsetEditor_->setExpression(QString::fromStdString(registerInterface_->getOffsetExpression(registerName_)));\r\n    offsetEditor_->setToolTip(\r\n        QString::fromStdString(registerInterface_->getOffsetValue(registerName_)));\r\n\r\n    sizeEditor_->setExpression(QString::fromStdString(registerInterface_->getSizeExpression(registerName_)));\r\n    sizeEditor_->setToolTip(QString::fromStdString(registerInterface_->getSizeValue(registerName_)));\r\n\r\n    dimensionEditor_->setExpression(\r\n        QString::fromStdString(registerInterface_->getDimensionExpression(registerName_)));\r\n    dimensionEditor_->setToolTip(\r\n        QString::fromStdString(registerInterface_->getDimensionValue(registerName_)));\r\n\r\n    isPresentEditor_->setExpression(\r\n        QString::fromStdString(registerInterface_->getIsPresentExpression(registerName_)));\r\n    isPresentEditor_->setToolTip(\r\n        QString::fromStdString(registerInterface_->getIsPresentValue(registerName_)));\r\n\r\n    changeExpressionEditorsSignalBlockStatus(false);\r\n\r\n    accessEditor_->setCurrentValue(registerInterface_->getAccess(registerName_));\r\n    volatileEditor_->setCurrentValue(QString::fromStdString(registerInterface_->getVolatile(registerName_)));\r\n\r\n    blockSignals(false);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SingleRegisterEditor::connectSignals()\r\n//-----------------------------------------------------------------------------\r\nvoid SingleRegisterEditor::connectSignals()\r\n{\r\n    connect(fieldsEditor_, SIGNAL(childAdded(int)), this, SIGNAL(childAdded(int)), Qt::UniqueConnection);\r\n    connect(fieldsEditor_, SIGNAL(childRemoved(int)), this, SIGNAL(childRemoved(int)), Qt::UniqueConnection);\r\n    connect(fieldsEditor_, SIGNAL(increaseReferences(QString const&)),\r\n        this, SIGNAL(increaseReferences(QString const&)), Qt::UniqueConnection);\r\n    connect(fieldsEditor_, SIGNAL(decreaseReferences(QString const&)),\r\n        this, SIGNAL(decreaseReferences(QString const&)), Qt::UniqueConnection);\r\n\r\n    connect(offsetEditor_, SIGNAL(increaseReference(QString const&)),\r\n        this, SIGNAL(increaseReferences(QString const&)), Qt::UniqueConnection);\r\n    connect(offsetEditor_, SIGNAL(decreaseReference(QString const&)),\r\n        this, SIGNAL(decreaseReferences(QString const&)), Qt::UniqueConnection);\r\n    connect(sizeEditor_, SIGNAL(increaseReference(QString const&)),\r\n        this, SIGNAL(increaseReferences(QString const&)), Qt::UniqueConnection);\r\n    connect(sizeEditor_, SIGNAL(decreaseReference(QString const&)),\r\n        this, SIGNAL(decreaseReferences(QString const&)), Qt::UniqueConnection);\r\n    connect(dimensionEditor_, SIGNAL(increaseReference(QString const&)),\r\n        this, SIGNAL(increaseReferences(QString const&)), Qt::UniqueConnection);\r\n    connect(dimensionEditor_, SIGNAL(decreaseReference(QString const&)),\r\n        this, SIGNAL(decreaseReferences(QString const&)), Qt::UniqueConnection);\r\n    connect(isPresentEditor_, SIGNAL(increaseReference(QString const&)),\r\n        this, SIGNAL(increaseReferences(QString const&)), Qt::UniqueConnection);\r\n    connect(isPresentEditor_, SIGNAL(decreaseReference(QString const&)),\r\n        this, SIGNAL(decreaseReferences(QString const&)), Qt::UniqueConnection);\r\n\r\n    connect(offsetEditor_, SIGNAL(editingFinished()), this, SLOT(onOffsetEdited()), Qt::UniqueConnection);\r\n    connect(sizeEditor_, SIGNAL(editingFinished()), this, SLOT(onSizeEdited()), Qt::UniqueConnection);\r\n    connect(dimensionEditor_, SIGNAL(editingFinished()), this, SLOT(onDimensionEdited()), Qt::UniqueConnection);\r\n    connect(isPresentEditor_, SIGNAL(editingFinished()), this, SLOT(onIsPresentEdited()), Qt::UniqueConnection);\r\n\r\n    connect(&nameEditor_, SIGNAL(contentChanged()), this, SIGNAL(contentChanged()), Qt::UniqueConnection);\r\n    connect(offsetEditor_, SIGNAL(editingFinished()), this, SIGNAL(contentChanged()), Qt::UniqueConnection);\r\n    connect(sizeEditor_, SIGNAL(editingFinished()), this, SIGNAL(contentChanged()), Qt::UniqueConnection);\r\n    connect(dimensionEditor_, SIGNAL(editingFinished()), this, SIGNAL(contentChanged()), Qt::UniqueConnection);\r\n    connect(isPresentEditor_, SIGNAL(editingFinished()), this, SIGNAL(contentChanged()), Qt::UniqueConnection);\r\n    connect(fieldsEditor_, SIGNAL(contentChanged()), this, SIGNAL(contentChanged()), Qt::UniqueConnection);\r\n\r\n    connect(&nameEditor_, SIGNAL(nameChanged()), this, SIGNAL(graphicsChanged()), Qt::UniqueConnection);\r\n    connect(offsetEditor_, SIGNAL(editingFinished()), this, SIGNAL(graphicsChanged()), Qt::UniqueConnection);\r\n    connect(offsetEditor_, SIGNAL(editingFinished()), this, SIGNAL(addressingChanged()), Qt::UniqueConnection);\r\n    \r\n    connect(sizeEditor_, SIGNAL(editingFinished()), this, SIGNAL(graphicsChanged()), Qt::UniqueConnection);\r\n    connect(sizeEditor_, SIGNAL(editingFinished()), this, SIGNAL(addressingChanged()), Qt::UniqueConnection);\r\n\r\n    connect(dimensionEditor_, SIGNAL(editingFinished()), this, SIGNAL(graphicsChanged()), Qt::UniqueConnection);\r\n    connect(dimensionEditor_, SIGNAL(editingFinished()), this, SIGNAL(addressingChanged()), Qt::UniqueConnection);\r\n\r\n    //connect(isPresentEditor_, SIGNAL(editingFinished()), this, SIGNAL(graphicsChanged()), Qt::UniqueConnection);\r\n    connect(isPresentEditor_, SIGNAL(editingFinished()), this, SIGNAL(addressingChanged()), Qt::UniqueConnection);\r\n\r\n    connect(fieldsEditor_, SIGNAL(graphicsChanged(int)), \r\n        this, SIGNAL(childGraphicsChanged(int)), Qt::UniqueConnection);\r\n    connect(fieldsEditor_, SIGNAL(addressingChanged(int)), \r\n        this, SIGNAL(childAddressingChanged(int)), Qt::UniqueConnection);\r\n\r\n    connect(&nameEditor_, SIGNAL(nameChanged()), this, SLOT(onRegisterNameChanged()), Qt::UniqueConnection);\r\n\r\n    connect(fieldsEditor_, SIGNAL(fieldNameChanged(QString const&, QString const&)),\r\n        this, SIGNAL(fieldNameChanged(QString const&, QString const&)), Qt::UniqueConnection);\r\n\r\n    connect(accessPoliciesEditor_, SIGNAL(contentChanged()), this, SIGNAL(contentChanged()), Qt::UniqueConnection);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SingleRegisterEditor::formattedValueFor()\r\n//-----------------------------------------------------------------------------\r\nQString SingleRegisterEditor::formattedValueFor(QString const& expression) const\r\n{\r\n    return ExpressionFormatter::format(expression, expressionParser_);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SingleRegisterEditor::changeExpressionEditorsSignalBlockStatus()\r\n//-----------------------------------------------------------------------------\r\nvoid SingleRegisterEditor::changeExpressionEditorsSignalBlockStatus(bool blockStatus) const\r\n{\r\n    offsetEditor_->blockSignals(blockStatus);\r\n    sizeEditor_->blockSignals(blockStatus);\r\n    dimensionEditor_->blockSignals(blockStatus);\r\n    isPresentEditor_->blockSignals(blockStatus);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SingleRegisterEditor::onOffsetEdited()\r\n//-----------------------------------------------------------------------------\r\nvoid SingleRegisterEditor::onOffsetEdited()\r\n{\r\n    offsetEditor_->finishEditingCurrentWord();\r\n    QString newAddressOffset = offsetEditor_->getExpression();\r\n\r\n    registerInterface_->setOffset(registerName_, newAddressOffset.toStdString());\r\n    offsetEditor_->setToolTip(formattedValueFor(newAddressOffset));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SingleRegisterEditor::onSizeEdited()\r\n//-----------------------------------------------------------------------------\r\nvoid SingleRegisterEditor::onSizeEdited()\r\n{\r\n    sizeEditor_->finishEditingCurrentWord();\r\n    QString newSize = sizeEditor_->getExpression();\r\n\r\n    registerInterface_->setSize(registerName_, newSize.toStdString());\r\n    sizeEditor_->setToolTip(formattedValueFor(newSize));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SingleRegisterEditor::onDimensionEdited()\r\n//-----------------------------------------------------------------------------\r\nvoid SingleRegisterEditor::onDimensionEdited()\r\n{\r\n    dimensionEditor_->finishEditingCurrentWord();\r\n    QString newDimension = dimensionEditor_->getExpression();\r\n\r\n    registerInterface_->setDimension(registerName_, newDimension.toStdString());\r\n    dimensionEditor_->setToolTip(formattedValueFor(newDimension));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SingleRegisterEditor::onIsPresentEdited()\r\n//-----------------------------------------------------------------------------\r\nvoid SingleRegisterEditor::onIsPresentEdited()\r\n{\r\n    isPresentEditor_->finishEditingCurrentWord();\r\n    QString newIsPresent = isPresentEditor_->getExpression();\r\n\r\n    registerInterface_->setIsPresent(registerName_, newIsPresent.toStdString());\r\n    isPresentEditor_->setToolTip(formattedValueFor(newIsPresent));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SingleRegisterEditor::onVolatileSelected()\r\n//-----------------------------------------------------------------------------\r\nvoid SingleRegisterEditor::onVolatileSelected(QString const& newVolatileValue)\r\n{\r\n    registerInterface_->setVolatile(registerName_, newVolatileValue.toStdString());\r\n\r\n    emit contentChanged();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SingleRegisterEditor::onAccessSelected()\r\n//-----------------------------------------------------------------------------\r\nvoid SingleRegisterEditor::onAccessSelected(QString const& newAccessValue)\r\n{\r\n    registerInterface_->setAccess(registerName_, newAccessValue.toStdString());\r\n\r\n    emit contentChanged();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SingleRegisterEditor::showEvent()\r\n//-----------------------------------------------------------------------------\r\nvoid SingleRegisterEditor::showEvent(QShowEvent* event)\r\n{\r\n    QWidget::showEvent(event);\r\n    if (component()->getRevision() == Document::Revision::Std22)\r\n    {\r\n        emit helpUrlRequested(\"componenteditor/register2022.html\");\r\n    }\r\n    else\r\n    {\r\n        emit helpUrlRequested(\"componenteditor/register.html\");\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SingleRegisterEditor::onRegisterNameChanged()\r\n//-----------------------------------------------------------------------------\r\nvoid SingleRegisterEditor::onRegisterNameChanged(QString const& oldName, QString const& newName)\r\n{\r\n    if (oldName == QString::fromStdString(registerName_))\r\n    {\r\n        registerName_ = newName.toStdString();\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SingleRegisterEditor::onRegisterNameChanged()\r\n//-----------------------------------------------------------------------------\r\nvoid SingleRegisterEditor::onRegisterNameChanged()\r\n{\r\n    registerName_ = nameEditor_.name().toStdString();\r\n}\r\n"
  },
  {
    "path": "editors/ComponentEditor/memoryMaps/SingleRegisterEditor.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: SingleRegisterEditor.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Mikko Teuho\r\n// Date: 24.04.2015\r\n//\r\n// Description:\r\n// Editor for editing the details of a single register.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef SINGLEREGISTEREDITOR_H\r\n#define SINGLEREGISTEREDITOR_H\r\n\r\n#include \"registereditor.h\"\r\n\r\n#include <editors/ComponentEditor/itemeditor.h>\r\n\r\n#include <common/widgets/nameGroupEditor/namegroupeditor.h>\r\n\r\n#include <QSharedPointer>\r\n#include <QSortFilterProxyModel>\r\n#include <QLineEdit>\r\n\r\nclass LibraryInterface;\r\nclass ParameterFinder;\r\nclass AccessComboBox;\r\nclass BooleanComboBox;\r\nclass ExpressionEditor;\r\nclass ExpressionParser;\r\nclass Register;\r\nclass RegisterValidator;\r\nclass RegisterInterface;\r\nclass AddressBlock;\r\nclass RegisterBase;\r\nclass AccessPoliciesEditor;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Editor for editing the details of a single register.\r\n//-----------------------------------------------------------------------------\r\nclass SingleRegisterEditor : public ItemEditor\r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\r\n\t/*!\r\n\t *  The constructor.\r\n\t *\r\n\t *    @param [in] selectedRegister        The register being edited.\r\n\t *    @param [in] component               The component being edited.\r\n\t *    @param [in] handler                 The instance that manages the library.\r\n\t *    @param [in] parameterFinder         The parameter finder.\r\n     *    @param [in] expressionParser        The expression parser to use.\r\n     *    @param [in] registerInterface       Interface for registers.\r\n     *    @param [in] containingRegisterData  Register data containing the edited register.\r\n\t *    @param [in] parent                  The parent of this editor.\r\n\t */\r\n    SingleRegisterEditor(QSharedPointer<Register> selectedRegister,\r\n        QSharedPointer<Component> component,\r\n        LibraryInterface* handler,\r\n        QSharedPointer<ParameterFinder> parameterFinder,\r\n        QSharedPointer<ExpressionParser> expressionParser,\r\n        RegisterInterface* registerInterface,\r\n        QSharedPointer<QList<QSharedPointer<RegisterBase> > > containingRegisterData,\r\n        QWidget* parent = 0);\r\n\r\n    /*!\r\n     *  The destructor.\r\n     */\r\n    virtual ~SingleRegisterEditor() = default;\r\n\r\n    //! No copying\r\n    SingleRegisterEditor(const SingleRegisterEditor& other) = delete;\r\n\r\n    //! No assignment\r\n    SingleRegisterEditor& operator=(const SingleRegisterEditor& other) = delete;\r\n\r\n    /*!\r\n\t *  Reload the information from the model to the editor.\r\n\t */\r\n\tvirtual void refresh();\r\n\r\nsignals:\r\n    void childGraphicsChanged(int);\r\n\r\n    void addressingChanged();\r\n\r\n    void childAddressingChanged(int);\r\n\r\n    /*\r\n     *  Informs of field name change.\r\n     *\r\n     *    @param [in] oldName     The old name.\r\n     *    @param [in] newName     The new name.\r\n     */\r\n    void fieldNameChanged(QString const& oldName, QString const& newName);\r\n\r\n\r\npublic slots:\r\n\r\n    /*\r\n     *  Handles register name change from address block editor.\r\n     *\r\n     *    @param [in] oldName     The old name.\r\n     *    @param [in] newName     The new name.\r\n     */\r\n    void onRegisterNameChanged(QString const& oldName, QString const& newName);\r\n\r\n    /*\r\n     *  Handles register name change from name editor.\r\n     */\r\n    void onRegisterNameChanged();\r\n\r\nprotected:\r\n\r\n\t/*!\r\n\t *  After a show event, fetches the help file for the editor.\r\n\t *\r\n\t *    @param [in] event   The show event.\r\n\t */\r\n\tvirtual void showEvent(QShowEvent* event);\r\n\r\nprivate slots:\r\n    \r\n    /*!\r\n     *  Save the edited offset to the register.\r\n     */\r\n    void onOffsetEdited();\r\n\r\n    /*!\r\n     *  Save the edited size to the register.\r\n     */\r\n    void onSizeEdited();\r\n\r\n    /*!\r\n     *  Save the edited dimension to the register.\r\n     */\r\n    void onDimensionEdited();\r\n    \r\n    /*!\r\n     *  Save the edited is present to the register.\r\n     */\r\n    void onIsPresentEdited();\r\n\r\n    /*!\r\n     *  Save the selected volatile value to the register.\r\n     *\r\n     *    @param [in] newVolatileValue    The new volatile value.\r\n     */\r\n    void onVolatileSelected(QString const& newVolatileValue);\r\n\r\n    /*!\r\n     *  Save the selected access value to the register.\r\n     *\r\n     *    @param [in] newAccessValue  The new access value.\r\n     */\r\n    void onAccessSelected(QString const& newAccessValue);\r\n\r\nprivate:\r\n\r\n    /*!\r\n     *  Setup the layout for this editor.\r\n     */\r\n    void setupLayout();\r\n\r\n    /*!\r\n     *  Connect the signals for this editor.\r\n     */\r\n    void connectSignals();\r\n\r\n    /*!\r\n     *  Calculate the value for the expression.\r\n     *\r\n     *    @param [in] expression  The expression to be calculated.\r\n     *\r\n     *    @return The calculated value of the expression.\r\n     */\r\n    QString formattedValueFor(QString const& expression) const;\r\n\r\n    /*!\r\n     *  Change the signal blocking status of the expression editors.\r\n     *\r\n     *    @param [in] blockStatus     The new status of signal blocking.\r\n     */\r\n    void changeExpressionEditorsSignalBlockStatus(bool blockStatus) const;\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! Name of the selected register.\r\n    std::string registerName_;\r\n\r\n    //! The name editor.\r\n    NameGroupEditor nameEditor_;\r\n\r\n    //! The editor for the registers fields.\r\n    RegisterEditor* fieldsEditor_;\r\n\r\n    //! The offset editor.\r\n    ExpressionEditor* offsetEditor_;\r\n\r\n    //! The size editor.\r\n    ExpressionEditor* sizeEditor_;\r\n\r\n    //! The dimension editor.\r\n    ExpressionEditor* dimensionEditor_;\r\n\r\n    //! The is present editor, accepts expressions.\r\n    ExpressionEditor* isPresentEditor_;\r\n\r\n    //! The volatility selector.\r\n    BooleanComboBox* volatileEditor_;\r\n\r\n    //! The access selector.\r\n    AccessComboBox* accessEditor_;\r\n\r\n    //! The expression parser.\r\n    QSharedPointer<ExpressionParser> expressionParser_;\r\n\r\n    //! The used register validator.\r\n    QSharedPointer<RegisterValidator> registerValidator_;\r\n\r\n    //! Register data containing the edited register.\r\n    QSharedPointer<QList<QSharedPointer<RegisterBase> > > containingRegisterData_;\r\n\r\n    //! Interface for registers.\r\n    RegisterInterface* registerInterface_;\r\n\r\n    //! The editor for access policies.\r\n    AccessPoliciesEditor* accessPoliciesEditor_;\r\n};\r\n\r\n#endif // SINGLEREGISTEREDITOR_H\r\n"
  },
  {
    "path": "editors/ComponentEditor/memoryMaps/SingleRegisterFileEditor.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: SingleRegisterFileEditor.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Dan Chianucci\n// Date: 19.06.2018\n//\n// Description:\n// Editor for a single register file item in component editor tree.\n//-----------------------------------------------------------------------------\n\n#include \"SingleRegisterFileEditor.h\"\n\n#include <editors/ComponentEditor/common/ExpressionEditor.h>\n#include <KactusAPI/include/ExpressionFormatter.h>\n#include <editors/ComponentEditor/parameters/ComponentParameterModel.h>\n#include <editors/ComponentEditor/memoryMaps/addressblockeditor.h>\n#include <editors/ComponentEditor/memoryMaps/AccessPoliciesEditor.h>\n\n#include <KactusAPI/include/RegisterInterface.h>\n\n#include <QCompleter>\n#include <QFormLayout>\n#include <QScrollArea>\n#include <QSplitter>\n\n//-----------------------------------------------------------------------------\n// Function: SingleRegisterFileEditor::SingleRegisterFileEditor()\n//-----------------------------------------------------------------------------\nSingleRegisterFileEditor::SingleRegisterFileEditor(RegisterInterface* registerInterface,\n    QSharedPointer<RegisterFile> registerFile, QSharedPointer<Component> component, LibraryInterface* handler,\n    QSharedPointer<ParameterFinder> parameterFinder, QSharedPointer<ExpressionFormatter> expressionFormatter,\n    QSharedPointer<ExpressionParser> expressionParser, QSharedPointer<RegisterFileValidator> registerFileValidator,\n    QWidget* parent) :\n    ItemEditor(component, handler, parent),\n    registerFile_(registerFile),\n    nameEditor_(registerFile, component->getRevision(), this, tr(\"Register file name and description\")),\nregistersEditor_(new AddressBlockEditor(\n    registerFile->getRegisterData(), registerInterface, component, handler, parameterFinder, this)),\nregisterFileEditor_(new RegisterFileEditor(registerFile_->getRegisterData(), component, handler,\n    parameterFinder, expressionFormatter, registerFileValidator, this)),\naccessPoliciesEditor_(new AccessPoliciesEditor(registerFile->getAccessPolicies(), \n    registerInterface->getAccessPolicyInterface(), this)),\noffsetEditor_(new ExpressionEditor(parameterFinder, this)),\nrangeEditor_(new ExpressionEditor(parameterFinder, this)),\ndimensionEditor_(new ExpressionEditor(parameterFinder, this)),\nisPresentEditor_(new ExpressionEditor(parameterFinder, this)),\nexpressionParser_(expressionParser),\nregisterFileValidator_(registerFileValidator)\n{\n    offsetEditor_->setFixedHeight(ExpressionEditor::DEFAULT_HEIGHT);\n    rangeEditor_->setFixedHeight(ExpressionEditor::DEFAULT_HEIGHT);\n    dimensionEditor_->setFixedHeight(ExpressionEditor::DEFAULT_HEIGHT);\n    isPresentEditor_->setFixedHeight(ExpressionEditor::DEFAULT_HEIGHT);\n\n    ComponentParameterModel* componentParametersModel = new ComponentParameterModel(parameterFinder, this);\n    componentParametersModel->setExpressionParser(expressionParser_);\n\n    auto offsetParameterCompleter = new QCompleter(this);\n    offsetParameterCompleter->setModel(componentParametersModel);\n\n    auto rangeParameterCompleter = new QCompleter(this);\n    rangeParameterCompleter->setModel(componentParametersModel);\n\n    auto dimensionParameterCompleter = new QCompleter(this);\n    dimensionParameterCompleter->setModel(componentParametersModel);\n\n    auto isPresentCompleter = new QCompleter(this);\n    isPresentCompleter->setModel(componentParametersModel);\n\n    offsetEditor_->setAppendingCompleter(offsetParameterCompleter);\n    rangeEditor_->setAppendingCompleter(rangeParameterCompleter);\n    dimensionEditor_->setAppendingCompleter(dimensionParameterCompleter);\n    isPresentEditor_->setAppendingCompleter(isPresentCompleter);\n\n    setupLayout();\n\n    connectSignals();\n\n    offsetEditor_->setProperty(\"mandatoryField\", true);\n    rangeEditor_->setProperty(\"mandatoryField\", true);\n}\n\n//-----------------------------------------------------------------------------\n// Function: SingleRegisterFileEditor::showEvent()\n//-----------------------------------------------------------------------------\nvoid SingleRegisterFileEditor::showEvent(QShowEvent* event)\n{\n    QWidget::showEvent(event);\n\n    if (component()->getRevision() == Document::Revision::Std22)\n    {\n        emit helpUrlRequested(\"componenteditor/registerFile2022.html\");\n    }\n    else\n    {\n        emit helpUrlRequested(\"componenteditor/registerFile.html\");\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: SingleRegisterFileEditor::refresh()\n//-----------------------------------------------------------------------------\nvoid SingleRegisterFileEditor::refresh()\n{\n    nameEditor_.refresh();\n    registerFileEditor_->refresh();\n\n    registersEditor_->refresh();\n    registerFileEditor_->refresh();\n\n    accessPoliciesEditor_->refresh();\n\n    changeExpressionEditorsSignalBlockStatus(true);\n\n    offsetEditor_->setExpression(registerFile_->getAddressOffset());\n    offsetEditor_->setToolTip(formattedValueFor(registerFile_->getAddressOffset()));\n\n    rangeEditor_->setExpression(registerFile_->getRange());\n    rangeEditor_->setToolTip(formattedValueFor(registerFile_->getRange()));\n\n    dimensionEditor_->setExpression(registerFile_->getDimension());\n    dimensionEditor_->setToolTip(formattedValueFor(registerFile_->getDimension()));\n\n    isPresentEditor_->setExpression(registerFile_->getIsPresent());\n    isPresentEditor_->setToolTip(formattedValueFor(registerFile_->getIsPresent()));\n\n    changeExpressionEditorsSignalBlockStatus(false);\n}\n\n//-----------------------------------------------------------------------------\n// Function: SingleRegisterFileEditor::onRangeChanged()\n//-----------------------------------------------------------------------------\nvoid SingleRegisterFileEditor::onRangeEdited()\n{\n    rangeEditor_->finishEditingCurrentWord();\n    registerFile_->setRange(rangeEditor_->getExpression());\n\n    rangeEditor_->setToolTip(formattedValueFor(registerFile_->getRange()));\n}\n\n//-----------------------------------------------------------------------------\n// Function: SingleRegisterFileEditor::onDimensionEdited()\n//-----------------------------------------------------------------------------\nvoid SingleRegisterFileEditor::onDimensionEdited()\n{\n    dimensionEditor_->finishEditingCurrentWord();\n\n    QString newDimension = dimensionEditor_->getExpression();\n    registerFile_->setDimension(newDimension);\n\n    dimensionEditor_->setToolTip(formattedValueFor(newDimension));\n}\n\n//-----------------------------------------------------------------------------\n// Function: SingleRegisterFileEditor::onOffsetEdited()\n//-----------------------------------------------------------------------------\nvoid SingleRegisterFileEditor::onOffsetEdited()\n{\n    offsetEditor_->finishEditingCurrentWord();\n    registerFile_->setAddressOffset(offsetEditor_->getExpression());\n\n    QString formattedAddressOffset = formattedValueFor(registerFile_->getAddressOffset());\n    offsetEditor_->setToolTip(formattedAddressOffset);\n}\n\n//-----------------------------------------------------------------------------\n// Function: SingleRegisterEditor::onIsPresentEdited()\n//-----------------------------------------------------------------------------\nvoid SingleRegisterFileEditor::onIsPresentEdited()\n{\n    isPresentEditor_->finishEditingCurrentWord();\n\n    QString newIsPresent = isPresentEditor_->getExpression();\n    registerFile_->setIsPresent(newIsPresent);\n\n    isPresentEditor_->setToolTip(formattedValueFor(newIsPresent));\n}\n\n//-----------------------------------------------------------------------------\n// Function: SingleRegisterFileEditor::formattedValueFor()\n//-----------------------------------------------------------------------------\nQString SingleRegisterFileEditor::formattedValueFor(QString const& expression) const\n{\n    return ExpressionFormatter::format(expression, expressionParser_);\n}\n\n//-----------------------------------------------------------------------------\n// Function: SingleRegisterFileEditor::setupLayout()\n//-----------------------------------------------------------------------------\nvoid SingleRegisterFileEditor::setupLayout()\n{\n    QScrollArea* scrollArea = new QScrollArea(this);\n    scrollArea->setWidgetResizable(true);\n    scrollArea->setFrameShape(QFrame::NoFrame);\n\n    QHBoxLayout* scrollLayout = new QHBoxLayout(this);\n    scrollLayout->addWidget(scrollArea);\n    scrollLayout->setContentsMargins(0, 0, 0, 0);\n\n    QGroupBox* registerDefinitionGroup = new QGroupBox(tr(\"Register file definition\"));\n\n    QFormLayout* registerDefinitionLayout = new QFormLayout(registerDefinitionGroup);\n    \n    QLayout* topOfPageLayout;\n    if (component()->getRevision() == Document::Revision::Std14)\n    {\n        registerDefinitionLayout->addRow(tr(\"Offset [AUB], f(x):\"), offsetEditor_);\n        registerDefinitionLayout->addRow(tr(\"Range [AUB], f(x):\"), rangeEditor_);\n        registerDefinitionLayout->addRow(tr(\"Dimension, f(x):\"), dimensionEditor_);\n        registerDefinitionLayout->addRow(tr(\"Is present, f(x):\"), isPresentEditor_);\n\n        QHBoxLayout* newTopOfPageLayout = new QHBoxLayout();\n        newTopOfPageLayout->addWidget(&nameEditor_, 0);\n        newTopOfPageLayout->addWidget(registerDefinitionGroup, 0);\n        topOfPageLayout = newTopOfPageLayout;\n    }\n    else //if (component()->getRevision() == Document::Revision::Std22)\n    {\n        registerDefinitionLayout->addRow(tr(\"Offset [AUB], f(x):\"), offsetEditor_);\n        registerDefinitionLayout->addRow(tr(\"Range [AUB], f(x):\"), rangeEditor_);\n        registerDefinitionLayout->addRow(tr(\"Dimension, f(x):\"), dimensionEditor_);\n\n        auto spacer = new QWidget();\n        spacer->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Expanding);\n        registerDefinitionLayout->addRow(spacer);\n\n        QGridLayout* newTopOfPageLayout = new QGridLayout();\n        newTopOfPageLayout->addWidget(&nameEditor_, 0, 0, 2, 1);\n        newTopOfPageLayout->addWidget(registerDefinitionGroup, 0, 1);\n        newTopOfPageLayout->addWidget(accessPoliciesEditor_, 1, 1);\n\n        newTopOfPageLayout->setRowStretch(0, 1);\n        newTopOfPageLayout->setRowStretch(1, 3);\n\n        topOfPageLayout = newTopOfPageLayout;\n    }\n\n    QWidget* topOfPageWidget = new QWidget();\n    topOfPageWidget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);\n    topOfPageWidget->setLayout(topOfPageLayout);\n    topOfPageWidget->setContentsMargins(0, 0, 0, 0);\n\n    QSplitter* verticalSplitter = new QSplitter(Qt::Vertical, scrollArea);\n    verticalSplitter->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);\n    verticalSplitter->addWidget(topOfPageWidget);\n    verticalSplitter->addWidget(registersEditor_);\n    verticalSplitter->addWidget(registerFileEditor_);\n\n    if (component()->getRevision() == Document::Revision::Std14)\n    {\n        verticalSplitter->setStretchFactor(0, 1);\n        verticalSplitter->setStretchFactor(1, 2);\n        verticalSplitter->setStretchFactor(2, 2);\n    }\n    else if (component()->getRevision() == Document::Revision::Std22)\n    {\n        verticalSplitter->setStretchFactor(0, 2);\n        verticalSplitter->setStretchFactor(1, 3);\n        verticalSplitter->setStretchFactor(2, 3);\n    }\n\n    for (int i = 1; i < 3; ++i)\n    {\n        QSplitterHandle* handle = verticalSplitter->handle(i);\n        QVBoxLayout* handleLayout = new QVBoxLayout(handle);\n        handleLayout->setSpacing(0);\n        handleLayout->setContentsMargins(0, 0, 0, 0);\n\n        QFrame* line = new QFrame(handle);\n        line->setLineWidth(2);\n        line->setMidLineWidth(2);\n        line->setFrameShape(QFrame::HLine);\n        line->setFrameShadow(QFrame::Sunken);\n        handleLayout->addWidget(line);\n    }\n\n    verticalSplitter->setHandleWidth(10);\n\n    scrollArea->setWidget(verticalSplitter);\n}\n\n//-----------------------------------------------------------------------------\n// Function: SingleRegisterFileEditor::connectSignals()\n//-----------------------------------------------------------------------------\nvoid SingleRegisterFileEditor::connectSignals()\n{\n    connect(registersEditor_, SIGNAL(childAdded(int)), this, SIGNAL(childAdded(int)), Qt::UniqueConnection);\n    connect(registersEditor_, SIGNAL(childRemoved(int)), this, SIGNAL(childRemoved(int)), Qt::UniqueConnection);\n    connect(registersEditor_, SIGNAL(increaseReferences(QString const&)),\n        this, SIGNAL(increaseReferences(QString const&)), Qt::UniqueConnection);\n    connect(registersEditor_, SIGNAL(decreaseReferences(QString const&)),\n        this, SIGNAL(decreaseReferences(QString const&)), Qt::UniqueConnection);\n\n    connect(registerFileEditor_, SIGNAL(childAdded(int)), this, SIGNAL(childAdded(int)), Qt::UniqueConnection);\n    connect(registerFileEditor_, SIGNAL(childRemoved(int)), this, SIGNAL(childRemoved(int)), Qt::UniqueConnection);\n    connect(registerFileEditor_, SIGNAL(increaseReferences(QString const&)),\n        this, SIGNAL(increaseReferences(QString const&)), Qt::UniqueConnection);\n    connect(registerFileEditor_, SIGNAL(decreaseReferences(QString const&)),\n        this, SIGNAL(decreaseReferences(QString const&)), Qt::UniqueConnection);\n\n    connect(offsetEditor_, SIGNAL(increaseReference(QString const&)),\n        this, SIGNAL(increaseReferences(QString const&)), Qt::UniqueConnection);\n    connect(offsetEditor_, SIGNAL(decreaseReference(QString const&)),\n        this, SIGNAL(decreaseReferences(QString const&)), Qt::UniqueConnection);\n    connect(rangeEditor_, SIGNAL(increaseReference(QString const&)),\n        this, SIGNAL(increaseReferences(QString const&)), Qt::UniqueConnection);\n    connect(rangeEditor_, SIGNAL(decreaseReference(QString const&)),\n        this, SIGNAL(decreaseReferences(QString const&)), Qt::UniqueConnection);\n    connect(dimensionEditor_, SIGNAL(increaseReference(QString const&)),\n        this, SIGNAL(increaseReferences(QString const&)), Qt::UniqueConnection);\n    connect(dimensionEditor_, SIGNAL(decreaseReference(QString const&)),\n        this, SIGNAL(decreaseReferences(QString const&)), Qt::UniqueConnection);\n    connect(isPresentEditor_, SIGNAL(increaseReference(QString const&)),\n        this, SIGNAL(increaseReferences(QString const&)), Qt::UniqueConnection);\n    connect(isPresentEditor_, SIGNAL(decreaseReference(QString const&)),\n        this, SIGNAL(decreaseReferences(QString const&)), Qt::UniqueConnection);\n\n    connect(offsetEditor_, SIGNAL(editingFinished()), this, SLOT(onOffsetEdited()), Qt::UniqueConnection);\n    connect(rangeEditor_, SIGNAL(editingFinished()), this, SLOT(onRangeEdited()), Qt::UniqueConnection);\n    connect(dimensionEditor_, SIGNAL(editingFinished()), this, SLOT(onDimensionEdited()), Qt::UniqueConnection);\n    connect(isPresentEditor_, SIGNAL(editingFinished()), this, SLOT(onIsPresentEdited()), Qt::UniqueConnection);\n\n    connect(&nameEditor_, SIGNAL(contentChanged()), this, SIGNAL(contentChanged()), Qt::UniqueConnection);\n    connect(offsetEditor_, SIGNAL(editingFinished()), this, SIGNAL(contentChanged()), Qt::UniqueConnection);\n    connect(rangeEditor_, SIGNAL(editingFinished()), this, SIGNAL(contentChanged()), Qt::UniqueConnection);\n    connect(dimensionEditor_, SIGNAL(editingFinished()), this, SIGNAL(contentChanged()), Qt::UniqueConnection);\n    connect(isPresentEditor_, SIGNAL(editingFinished()), this, SIGNAL(contentChanged()), Qt::UniqueConnection);\n    connect(registersEditor_, SIGNAL(contentChanged()), this, SIGNAL(contentChanged()), Qt::UniqueConnection);\n    connect(registerFileEditor_, SIGNAL(contentChanged()), this, SIGNAL(contentChanged()), Qt::UniqueConnection);\n\n    connect(&nameEditor_, SIGNAL(nameChanged()), this, SIGNAL(graphicsChanged()), Qt::UniqueConnection);\n    connect(offsetEditor_, SIGNAL(editingFinished()), this, SIGNAL(graphicsChanged()), Qt::UniqueConnection);\n    connect(rangeEditor_, SIGNAL(editingFinished()), this, SIGNAL(graphicsChanged()), Qt::UniqueConnection);\n    connect(dimensionEditor_, SIGNAL(editingFinished()), this, SIGNAL(graphicsChanged()), Qt::UniqueConnection);\n    connect(isPresentEditor_, SIGNAL(editingFinished()), this, SIGNAL(graphicsChanged()), Qt::UniqueConnection);\n    connect(registersEditor_, SIGNAL(graphicsChanged(int)), this, SIGNAL(childGraphicsChanged(int)), Qt::UniqueConnection);\n    connect(registerFileEditor_, SIGNAL(graphicsChanged(int)), this, SIGNAL(childGraphicsChanged(int)), Qt::UniqueConnection);\n\n    connect(offsetEditor_, SIGNAL(editingFinished()), this, SIGNAL(addressingChanged()), Qt::UniqueConnection);\n    connect(rangeEditor_, SIGNAL(editingFinished()), this, SIGNAL(addressingChanged()), Qt::UniqueConnection);\n    connect(dimensionEditor_, SIGNAL(editingFinished()), this, SIGNAL(addressingChanged()), Qt::UniqueConnection);\n    connect(isPresentEditor_, SIGNAL(editingFinished()), this, SIGNAL(addressingChanged()), Qt::UniqueConnection);\n    \n    connect(registersEditor_, SIGNAL(childAddressingChanged(int)),\n        this, SIGNAL(childAddressingChanged(int)), Qt::UniqueConnection);\n    connect(registerFileEditor_, SIGNAL(childAddressingChanged(int)),\n        this, SIGNAL(childAddressingChanged(int)), Qt::UniqueConnection);\n\n    connect(registersEditor_, SIGNAL(registerNameChanged(QString const&, QString const&)),\n        this, SIGNAL(registerNameChanged(QString const&, QString const&)), Qt::UniqueConnection);\n\n    connect(accessPoliciesEditor_, SIGNAL(contentChanged()), this, SIGNAL(contentChanged()), Qt::UniqueConnection);\n}\n\n//-----------------------------------------------------------------------------\n// Function: SingleRegisterFileEditor::changeExpressionEditorSignalBlocks()\n//-----------------------------------------------------------------------------\nvoid SingleRegisterFileEditor::changeExpressionEditorsSignalBlockStatus(bool blockStatus) const\n{\n    offsetEditor_->blockSignals(blockStatus);\n    rangeEditor_->blockSignals(blockStatus);\n    dimensionEditor_->blockSignals(blockStatus);\n    isPresentEditor_->blockSignals(blockStatus);\n}\n"
  },
  {
    "path": "editors/ComponentEditor/memoryMaps/SingleRegisterFileEditor.h",
    "content": "//-----------------------------------------------------------------------------\n// File: SingleRegisterFileEditor.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Dan Chianucci\n// Date: 19.06.2018\n//\n// Description:\n// Editor for a single register file item in component editor tree.\n//-----------------------------------------------------------------------------\n#ifndef SINGLEREGISTERFILEEDITOR_H\n#define SINGLEREGISTERFILEEDITOR_H\n\n#include \"registerfileeditor.h\"\n\n#include <editors/ComponentEditor/itemeditor.h>\n#include <common/widgets/nameGroupEditor/namegroupeditor.h>\n\n#include <IPXACTmodels/Component/Component.h>\n#include <IPXACTmodels/Component/RegisterFile.h>\n\nclass AddressBlockEditor; \nclass LibraryInterface;\nclass ParameterFinder;\nclass ExpressionFormatter;\nclass ExpressionEditor;\nclass ExpressionParser;\nclass RegisterFileValidator;\nclass RegisterInterface;\nclass AccessPoliciesEditor;\n\n//-----------------------------------------------------------------------------\n//! Editor for a single register file item in component editor tree.\n//-----------------------------------------------------------------------------\nclass SingleRegisterFileEditor : public ItemEditor\n{\n    Q_OBJECT\n\npublic:\n\n    /*!\n     * The constructor.\n     *\n     *    @param [in] registerInterface       Interface for registers.\n     *    @param [in] registerFile            The register file to edit.\n     *    @param [in] component               The component containing the register file.\n     *    @param [in] handler                 The available IP-XACT library.\n     *    @param [in] parameterFinder         Finder for parameters.\n     *    @param [in] expressionFormatter     Formatter for expressions.\n     *    @param [in] registerFileValidator   Validator for register files.\n     *    @param [in] parent                  The parent widget.\n    */\n    SingleRegisterFileEditor(RegisterInterface* registerInterface,\n        QSharedPointer<RegisterFile> registerFile,\n        QSharedPointer<Component> component,\n        LibraryInterface* handler,\n        QSharedPointer<ParameterFinder> parameterFinder,\n        QSharedPointer<ExpressionFormatter> expressionFormatter,\n        QSharedPointer<ExpressionParser> expressionParser,\n        QSharedPointer<RegisterFileValidator> registerFileValidator,\n        QWidget* parent = 0);\n\n    //! The destructor.\n    virtual ~SingleRegisterFileEditor() = default;\n\n    //! No copying.\n    SingleRegisterFileEditor(const SingleRegisterFileEditor& other) = delete;\n    SingleRegisterFileEditor& operator=(const SingleRegisterFileEditor& other) = delete;\n\n    //! Refresh the editor.\n    virtual void refresh() override final;\n\nsignals:\n    \n    void addressingChanged();\n\n    void childAddressingChanged(int index);\n\n    void childGraphicsChanged(int index);\n\nsignals:\n\n    /*\n     *  Informs of register name change.\n     *\n     *    @param [in] oldName     The old name.\n     *    @param [in] newName     The new name.\n     */\n    void registerNameChanged(QString const& oldName, QString const& newName);\n\nprotected:\n\n    virtual void showEvent(QShowEvent* event);\n\nprivate slots:\n\n    //! Called when offset is changed.\n    void onOffsetEdited();\n\n    //! Called when range is changed.\n    void onRangeEdited();\n\n    //! Called when dimension is changed.\n    void onDimensionEdited();\n\n    //! Called when isPresent is changed.\n    void onIsPresentEdited();\n\nprivate:\n\n    //! Set the editor layout.\n    void setupLayout();\n\n    //! Connect the editor signals.\n    void connectSignals();\n\n    \n    /*!\n     * Get the formatted value of a given expression.\n     *\n     *    @param [in] expression  The expression to format.\n     *\n     *    @return The formatted value.\n     */\n    QString formattedValueFor(QString const& expression) const;\n\n    /*!\n     * Block/unblock signals from expression editor.\n     *\n     *    @param [in] blockStatus  If true, signals are blocked, otherwise signals are enabled.\n     */\n     void changeExpressionEditorsSignalBlockStatus(bool blockStatus) const;\n\n    //-----------------------------------------------------------------------------\n    // Data.\n    //-----------------------------------------------------------------------------\n\n    //! The register file edited in the editor.\n    QSharedPointer<RegisterFile> registerFile_;\n\n    //! The name editor.\n    NameGroupEditor nameEditor_;\n\n    //! The editor for registers.\n    AddressBlockEditor* registersEditor_;\n\n    //! The editor for the register files.\n    RegisterFileEditor* registerFileEditor_;\n\n    //! The editor for access policies.\n    AccessPoliciesEditor* accessPoliciesEditor_;\n\n    //! The editor for register file offset.\n    ExpressionEditor* offsetEditor_;\n    \n    //! The editor for register file range.\n    ExpressionEditor* rangeEditor_;\n\n    //! The editor for register file dimension.\n    ExpressionEditor* dimensionEditor_;\n\n    //! The editor for register file isPresent property.\n    ExpressionEditor* isPresentEditor_;\n\n    //! Parser for expression.\n    QSharedPointer<ExpressionParser> expressionParser_;\n\n    //! Validator for register files.\n    QSharedPointer<RegisterFileValidator> registerFileValidator_;\n};\n\n#endif // SINGLEREGISTERFILEEDITOR_H\n"
  },
  {
    "path": "editors/ComponentEditor/memoryMaps/SingleSubspaceMapEditor.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: SingleSubspaceMapEditor.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 24.02.2022\n//\n// Description:\n// Editor for editing the details of a single subspace map.\n//-----------------------------------------------------------------------------\n\n#include \"SingleSubspaceMapEditor.h\"\n\n#include <common/widgets/busReferenceComboBox/BusReferenceComboBox.h>\n#include <common/widgets/segmentComboBox/SegmentComboBox.h>\n\n#include <KactusAPI/include/BusInterfaceInterface.h>\n#include <editors/ComponentEditor/common/ExpressionEditor.h>\n#include <KactusAPI/include/ExpressionFormatter.h>\n#include <KactusAPI/include/ExpressionParser.h>\n#include <KactusAPI/include/SubspaceMapInterface.h>\n#include <editors/ComponentEditor/parameters/ComponentParameterModel.h>\n\n#include <IPXACTmodels/Component/MemoryMapBase.h>\n#include <IPXACTmodels/Component/Component.h>\n#include <IPXACTmodels/Component/AddressSpace.h>\n\n#include <QCompleter>\n#include <QFormLayout>\n#include <QScrollArea>\n#include <QSplitter>\n\n//-----------------------------------------------------------------------------\n// Function: SingleSubspaceMapEditor::SingleSubspaceMapEditor()\n//-----------------------------------------------------------------------------\nSingleSubspaceMapEditor::SingleSubspaceMapEditor(SubspaceMapInterface* subspaceInterface,\n    QSharedPointer<SubSpaceMap> subspaceMap, QSharedPointer<MemoryMapBase> containingMap,\n    QSharedPointer<Component> component, LibraryInterface* handler,\n    QSharedPointer<ParameterFinder> parameterFinder,\n    QSharedPointer<ExpressionParser> expressionParser, QWidget* parent /* = 0 */):\nItemEditor(component, handler, parent),\nnameEditor_(subspaceMap, component->getRevision(), this, tr(\"Subspace map name and description\")),\nbaseAddressEditor_(new ExpressionEditor(parameterFinder, this)),\nisPresentEditor_(new ExpressionEditor(parameterFinder, this)),\ninitiatorSelector_(),\nsegmentSelector_(),\nsubspaceName_(subspaceMap->name().toStdString()),\nsubspaceInterface_(subspaceInterface),\ncontainingMap_(containingMap),\nexpressionParser_(expressionParser)\n{\n    subspaceInterface_->setMemoryBlocks(containingMap_->getMemoryBlocks());\n    subspaceInterface_->setupSubInterfaces(component);\n\n    constructComboBoxes();\n\n    baseAddressEditor_->setFixedHeight(ExpressionEditor::DEFAULT_HEIGHT);\n    isPresentEditor_->setFixedHeight(ExpressionEditor::DEFAULT_HEIGHT);\n\n    ComponentParameterModel* componentParametersModel = new ComponentParameterModel(parameterFinder, this);\n    componentParametersModel->setExpressionParser(expressionParser_);\n\n    auto baseAddressEditorCompleter = new QCompleter(this);\n    baseAddressEditorCompleter->setModel(componentParametersModel);\n    \n    auto isPresentEditorCompleter = new QCompleter(this);\n    isPresentEditorCompleter->setModel(componentParametersModel);\n\n    baseAddressEditor_->setAppendingCompleter(baseAddressEditorCompleter);\n    isPresentEditor_->setAppendingCompleter(isPresentEditorCompleter);\n\n    setupLayout();\n\n    connectSignals();\n\n    baseAddressEditor_->setProperty(\"mandatoryField\", true);\n    initiatorSelector_->setProperty(\"mandatoryField\", true);\n}\n\n//-----------------------------------------------------------------------------\n// Function: SingleSubspaceMapEditor::constructComboBoxes()\n//-----------------------------------------------------------------------------\nvoid SingleSubspaceMapEditor::constructComboBoxes()\n{\n    QString initiatorReference = QString::fromStdString(subspaceInterface_->getInitiatorReference(subspaceName_));\n\n    initiatorSelector_ = new BusReferenceComboBox(subspaceInterface_->getBusInterface(), this);\n\n    General::InterfaceMode initiatorMode = component()->getRevision() == Document::Revision::Std22\n        ? General::INITIATOR\n        : General::MASTER;\n\n    initiatorSelector_->setupSelection(initiatorReference, initiatorMode);\n\n    segmentSelector_ = new SegmentComboBox(this);\n\n    QSharedPointer<AddressSpace> space = getSpace(initiatorReference);\n    if (space)\n    {\n        QString segmentReference = QString::fromStdString(subspaceInterface_->getSegmentReference(subspaceName_));\n        segmentSelector_->setupSelection(space, initiatorReference);\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: SingleSubspaceMapEditor::getSpace()\n//-----------------------------------------------------------------------------\nQSharedPointer<AddressSpace> SingleSubspaceMapEditor::getSpace(QString const& busReference)\n{\n    BusInterfaceInterface* busInterface = subspaceInterface_->getBusInterface();\n\n    QString spaceReference =\n        QString::fromStdString(busInterface->getAddressSpaceReference(busReference.toStdString()));\n    if (!spaceReference.isEmpty())\n    {\n        for (auto space : *component()->getAddressSpaces())\n        {\n            if (space->name() == spaceReference)\n            {\n                return space;\n            }\n        }\n    }\n\n    return QSharedPointer<AddressSpace>();\n}\n\n//-----------------------------------------------------------------------------\n// Function: SingleSubspaceMapEditor::showEvent()\n//-----------------------------------------------------------------------------\nvoid SingleSubspaceMapEditor::showEvent(QShowEvent* event)\n{\n    QWidget::showEvent(event);\n\n    if (component()->getRevision() == Document::Revision::Std22)\n    {\n        emit helpUrlRequested(\"componenteditor/subspacemap2022.html\");\n    }\n    else\n    {\n        emit helpUrlRequested(\"componenteditor/subspacemap.html\");\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: SingleSubspaceMapEditor::refresh()\n//-----------------------------------------------------------------------------\nvoid SingleSubspaceMapEditor::refresh()\n{\n    subspaceInterface_->setMemoryBlocks(containingMap_->getMemoryBlocks());\n    subspaceInterface_->setupSubInterfaces(component());\n\n    nameEditor_.refresh();\n\n    changeExpressionEditorSignalBlockStatus(true);\n\n    baseAddressEditor_->setExpression(\n        QString::fromStdString(subspaceInterface_->getBaseAddressExpression(subspaceName_)));\n    baseAddressEditor_->setToolTip(\n        QString::fromStdString(subspaceInterface_->getBaseAddressValue(subspaceName_)));\n\n    isPresentEditor_->setExpression(\n        QString::fromStdString(subspaceInterface_->getIsPresentExpression(subspaceName_)));\n    isPresentEditor_->setToolTip(QString::fromStdString(subspaceInterface_->getIsPresentValue(subspaceName_)));\n\n    changeExpressionEditorSignalBlockStatus(false);\n\n    QString busReference = QString::fromStdString(subspaceInterface_->getInitiatorReference(subspaceName_));\n    QString segmentReference = QString::fromStdString(subspaceInterface_->getSegmentReference(subspaceName_));\n    QSharedPointer<AddressSpace> space = getSpace(busReference);\n\n    General::InterfaceMode initiatorMode = component()->getRevision() == Document::Revision::Std22\n        ? General::INITIATOR\n        : General::MASTER;\n\n    initiatorSelector_->setupSelection(busReference, initiatorMode);\n    segmentSelector_->setupSelection(space, segmentReference);\n}\n\n//-----------------------------------------------------------------------------\n// Function: SingleSubspaceMapEditor::onBaseAddressChanged()\n//-----------------------------------------------------------------------------\nvoid SingleSubspaceMapEditor::onBaseAddressChanged()\n{\n    baseAddressEditor_->finishEditingCurrentWord();\n\n    subspaceInterface_->setBaseAddress(subspaceName_, baseAddressEditor_->getExpression().toStdString());\n    baseAddressEditor_->setToolTip(QString::fromStdString(subspaceInterface_->getBaseAddressValue(subspaceName_)));\n}\n\n//-----------------------------------------------------------------------------\n// Function: SingleSubspaceMapEditor::onIsPresentEdited()\n//-----------------------------------------------------------------------------\nvoid SingleSubspaceMapEditor::onIsPresentEdited()\n{\n    isPresentEditor_->finishEditingCurrentWord();\n\n    subspaceInterface_->setIsPresent(subspaceName_, isPresentEditor_->getExpression().toStdString());\n    isPresentEditor_->setToolTip(QString::fromStdString(subspaceInterface_->getIsPresentValue(subspaceName_)));\n\n    emit contentChanged();\n    emit graphicsChanged();\n    emit addressingChanged();\n}\n\n//-----------------------------------------------------------------------------\n// Function: SingleSubspaceMapEditor::setupLayout()\n//-----------------------------------------------------------------------------\nvoid SingleSubspaceMapEditor::setupLayout()\n{\n    QScrollArea* scrollArea = new QScrollArea(this);\n    scrollArea->setWidgetResizable(true);\n    scrollArea->setFrameShape(QFrame::NoFrame);\n\n    QHBoxLayout* scrollLayout = new QHBoxLayout(this);\n    scrollLayout->addWidget(scrollArea);\n    scrollLayout->setContentsMargins(0, 0, 0, 0);\n\n    QGroupBox* subspaceDefinitionGroup = new QGroupBox(tr(\"Subspace map definition\"));\n    QFormLayout* subspaceDefinitionLayout = new QFormLayout(subspaceDefinitionGroup);\n\n    subspaceDefinitionLayout->addRow(tr(\"Base Address [AUB], f(x):\"), baseAddressEditor_);\n    if (auto rev = component()->getRevision(); rev == Document::Revision::Std14)\n    {\n        subspaceDefinitionLayout->addRow(tr(\"Master bus interface reference:\"), initiatorSelector_);\n        subspaceDefinitionLayout->addRow(tr(\"Segment reference:\"), segmentSelector_);\n        subspaceDefinitionLayout->addRow(tr(\"Is present, f(x):\"), isPresentEditor_);\n    }\n    else if (rev == Document::Revision::Std22)\n    {\n        subspaceDefinitionLayout->addRow(tr(\"Initiator bus interface reference:\"), initiatorSelector_);\n        subspaceDefinitionLayout->addRow(tr(\"Segment reference:\"), segmentSelector_);\n    }\n\n    QWidget* spacer = new QWidget();\n    spacer->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Expanding);\n    subspaceDefinitionLayout->addRow(spacer);\n\n    QGridLayout* topOfPageLayout = new QGridLayout();\n    topOfPageLayout->addWidget(&nameEditor_, 0, 0, 1, 1);\n    topOfPageLayout->addWidget(subspaceDefinitionGroup, 0, 1, 1, 1);    \n    topOfPageLayout->setRowStretch(1, 1);\n\n    QWidget* topOfPageWidget = new QWidget(scrollArea);\n    topOfPageWidget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);\n    topOfPageWidget->setLayout(topOfPageLayout);\n    topOfPageWidget->setContentsMargins(0, 0, 0, 0);\n\n    scrollArea->setWidget(topOfPageWidget);\n}\n\n//-----------------------------------------------------------------------------\n// Function: SingleSubspaceMapEditor::connectSignals()\n//-----------------------------------------------------------------------------\nvoid SingleSubspaceMapEditor::connectSignals() const\n{\n    connect(initiatorSelector_, SIGNAL(currentTextChanged(QString const&)),\n        this, SLOT(onMasterSelected(QString const&)), Qt::UniqueConnection);\n    connect(segmentSelector_, SIGNAL(currentTextChanged(QString const&)),\n        this, SLOT(onSegmentSelected(QString const&)), Qt::UniqueConnection);\n\n    connect(baseAddressEditor_, SIGNAL(increaseReference(QString)),\n        this, SIGNAL(increaseReferences(QString)), Qt::UniqueConnection);\n    connect(baseAddressEditor_, SIGNAL(decreaseReference(QString)),\n        this, SIGNAL(decreaseReferences(QString)), Qt::UniqueConnection);\n    connect(isPresentEditor_, SIGNAL(increaseReference(QString)),\n        this, SIGNAL(increaseReferences(QString)), Qt::UniqueConnection);\n    connect(isPresentEditor_, SIGNAL(decreaseReference(QString)),\n        this, SIGNAL(decreaseReferences(QString)), Qt::UniqueConnection);\n\n    connect(baseAddressEditor_, SIGNAL(editingFinished()), this, SLOT(onBaseAddressChanged()), Qt::UniqueConnection);    \n\n    connect(&nameEditor_, SIGNAL(contentChanged()), this, SIGNAL(contentChanged()), Qt::UniqueConnection);\n    connect(baseAddressEditor_, SIGNAL(editingFinished()), this, SIGNAL(contentChanged()), Qt::UniqueConnection);\n\n    connect(&nameEditor_, SIGNAL(nameChanged()), this, SIGNAL(graphicsChanged()), Qt::UniqueConnection);\n\n    connect(baseAddressEditor_, SIGNAL(editingFinished()), this, SIGNAL(graphicsChanged()), Qt::UniqueConnection);\n    connect(baseAddressEditor_, SIGNAL(editingFinished()), this, SIGNAL(addressingChanged()), Qt::UniqueConnection);\n\n    connect(isPresentEditor_, SIGNAL(editingFinished()), this, SLOT(onIsPresentEdited()), Qt::UniqueConnection);\n\n    connect(&nameEditor_, SIGNAL(nameChanged()), this, SLOT(onSubspaceNameChanged()), Qt::UniqueConnection);\n}\n\n//-----------------------------------------------------------------------------\n// Function: SingleSubspaceMapEditor::changeExpressionEditorSignalBlocks()\n//-----------------------------------------------------------------------------\nvoid SingleSubspaceMapEditor::changeExpressionEditorSignalBlockStatus(bool blockStatus)\n{\n    baseAddressEditor_->blockSignals(blockStatus);\n    isPresentEditor_->blockSignals(blockStatus);\n}\n\n//-----------------------------------------------------------------------------\n// Function: SingleSubspaceMapEditor::onSubspaceNameChanged()\n//-----------------------------------------------------------------------------\nvoid SingleSubspaceMapEditor::onSubspaceNameChanged(QString const& oldName, QString const& newName)\n{\n    if (oldName == QString::fromStdString(subspaceName_))\n    {\n        subspaceName_ = newName.toStdString();\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: SingleSubspaceMapEditor::onSubspaceNameChanged()\n//-----------------------------------------------------------------------------\nvoid SingleSubspaceMapEditor::onSubspaceNameChanged()\n{\n    QString oldName = QString::fromStdString(subspaceName_);\n    subspaceName_ = nameEditor_.name().toStdString();\n\n    emit thisEditorNameChange(oldName, QString::fromStdString(subspaceName_));\n}\n\n//-----------------------------------------------------------------------------\n// Function: SingleSubspaceMapEditor::onMasterSelected()\n//-----------------------------------------------------------------------------\nvoid SingleSubspaceMapEditor::onMasterSelected(QString const& newMasterReference)\n{\n    subspaceInterface_->setMasterReference(subspaceName_, newMasterReference.toStdString());\n\n    QSharedPointer<AddressSpace> space = getSpace(newMasterReference);\n    if (space)\n    {\n        QString segmentReference = QString::fromStdString(subspaceInterface_->getSegmentReference(subspaceName_));\n        segmentSelector_->setupSelection(space, segmentReference);\n    }\n\n    emit contentChanged();\n    emit graphicsChanged();\n    emit addressingChanged();\n}\n\n//-----------------------------------------------------------------------------\n// Function: SingleSubspaceMapEditor::onSegmentSelected()\n//-----------------------------------------------------------------------------\nvoid SingleSubspaceMapEditor::onSegmentSelected(QString const& newSegment)\n{\n    subspaceInterface_->setSegmentReference(subspaceName_, newSegment.toStdString());\n\n    emit contentChanged();\n    emit graphicsChanged();\n    emit addressingChanged();\n}\n"
  },
  {
    "path": "editors/ComponentEditor/memoryMaps/SingleSubspaceMapEditor.h",
    "content": "//-----------------------------------------------------------------------------\n// File: SingleSubspaceMapEditor.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 24.02.2022\n//\n// Description:\n// Editor for editing the details of a single subspace map.\n//-----------------------------------------------------------------------------\n\n#ifndef SINGLESUBSPACEMAPEDITOR_H\n#define SINGLESUBSPACEMAPEDITOR_H\n\n#include <common/widgets/nameGroupEditor/namegroupeditor.h>\n\n#include <editors/ComponentEditor/itemeditor.h>\n\n#include <IPXACTmodels/Component/Component.h>\n#include <IPXACTmodels/Component/SubSpaceMap.h>\n\n#include <QComboBox>\n#include <QSharedPointer>\n\nclass ExpressionFormatter;\nclass ExpressionEditor;\nclass ExpressionParser;\nclass LibraryInterface;\nclass ParameterFinder;\nclass MemoryMapBase;\nclass SubspaceMapInterface;\nclass SubspaceMapValidator;\nclass BusReferenceComboBox;\nclass SegmentComboBox;\n\n//-----------------------------------------------------------------------------\n//! Editor for editing the details of a single subspace map.\n//-----------------------------------------------------------------------------\nclass SingleSubspaceMapEditor : public ItemEditor\n{\n    Q_OBJECT\n\npublic:\n\n\t/*!\n\t *  The constructor.\n\t *\n     *    @param [in] subspaceInterface       Interface for accessing subspace maps.\n\t *    @param [in] subspaceMap             The subspace map being edited.\n     *    @param [in] containingMap           Memory map containing the edited address block.\n\t *    @param [in] component               The component being edited.\n\t *    @param [in] handler                 The instance managing the library.\n\t *    @param [in] parameterFinder         The parameter finder.\n     *    @param [in] expressionParser        The expression parser.\n\t *    @param [in] parent                  The parent of this editor.\n\t */\n    SingleSubspaceMapEditor(SubspaceMapInterface* subspaceInterface,\n        QSharedPointer<SubSpaceMap> subspaceMap,\n        QSharedPointer<MemoryMapBase> containingMap,\n        QSharedPointer<Component> component,\n        LibraryInterface* handler,\n        QSharedPointer<ParameterFinder> parameterFinder,\n        QSharedPointer<ExpressionParser> expressionParser,\n        QWidget* parent = 0);\n\n\t/*!\n     *  The destructor.\n     */\n    virtual ~SingleSubspaceMapEditor() = default;\n\n    //! No copying. No assignment.\n    SingleSubspaceMapEditor(const SingleSubspaceMapEditor& other) = delete;\n    SingleSubspaceMapEditor& operator=(const SingleSubspaceMapEditor& other) = delete;\n\n\t/*!\n\t *  Reload all the contained editors.\n\t */\n\tvirtual void refresh() override final;\n\npublic slots:\n\n    /*\n     *  Handles subspace map name change from memory map editor.\n     *\n     *    @param [in] oldName     The old name.\n     *    @param [in] newName     The new name.\n     */\n    void onSubspaceNameChanged(QString const& oldName, QString const& newName);\n\n    /*\n     *  Handles subspace map name change from name editor.\n     */\n    void onSubspaceNameChanged();\n\nsignals:\n\n    /*!\n     *  Inform of a change in subspace map addressing.\n     */\n    void addressingChanged();\n\n    /*!\n     *  Inform of a change in subspace map name.\n     */\n    void thisEditorNameChange(QString const& oldName, QString const& newName);\n\nprotected:\n\n    /*!\n\t *  Shows the widget and informs of the required help document.\n\t *\n\t *    @param [in] event   The show event.\n\t */\n\tvirtual void showEvent(QShowEvent* event) override final;\n\nprivate slots:\n    \n    /*!\n     *  Sets the value in the base address editor.\n     */\n    void onBaseAddressChanged();\n\n    /*!\n     *  Called when isPresent is changed.\n     */\n    void onIsPresentEdited();\n\n    /*!\n     *  Handle the change in master bus interface reference.\n     *\n     *    @param [in] newMasterReference  The new master bus interface reference.\n     */\n    void onMasterSelected(QString const& newMasterReference);\n\n    /*!\n     *  Handle the change in segment reference.\n     *\n     *    @param [in] newSegment  The new segment reference.\n     */\n    void onSegmentSelected(QString const& newSegment);\n\nprivate:\n\n    /*!\n     *  Construct the combo boxes for master bus interface reference and segment reference.\n     */\n    void constructComboBoxes();\n\n    /*!\n     *  Get the address space of the selected bus interface.\n     *\n     *    @param [in] busReference    Name of the selected bus interface.\n     *\n     *    @return Address space of the selected bus interface.\n     */\n    QSharedPointer<AddressSpace> getSpace(QString const& busReference);\n\n    /*!\n     *  Sets the layout for the editor.\n     */\n    void setupLayout();\n\n    /*!\n     *  Connects all the signals of the editors.\n     */\n    void connectSignals() const;\n\n    /*!\n     *  Change the status of signal blocking in all the expression editors.\n     *\n     *    @param [in] blockStatus     The new signal blocking status.\n     */\n    void changeExpressionEditorSignalBlockStatus(bool blockStatus);\n\n    /*!\n     *  Calculates the value of an expression.\n     *\n     *    @param [in] expression  The expression, whose value is to be calculated.\n     *\n     *    @return The calculated value of the given expression.\n     */\n    QString formattedValueFor(QString const& expression) const;\n\n    //-----------------------------------------------------------------------------\n    // Data.\n    //-----------------------------------------------------------------------------\n\n    //! Editor for containing the name group information of the address block.\n    NameGroupEditor nameEditor_;\n\n    //! Editor for the base address of the address block.\n    ExpressionEditor* baseAddressEditor_;\n\n    //! Editor for the is present of the address block-\n    ExpressionEditor* isPresentEditor_;\n\n    //! Selector for initiator bus interface reference.\n    BusReferenceComboBox* initiatorSelector_;\n\n    //! Selector for segment reference.\n    SegmentComboBox* segmentSelector_;\n\n    //! Name of the current address block.\n    std::string subspaceName_;\n\n    //! Interface for address blocks.\n    SubspaceMapInterface* subspaceInterface_;\n\n    //! Memory map item containing the address block.\n    QSharedPointer<MemoryMapBase> containingMap_;\n\n    //! The expression parser.\n    QSharedPointer<ExpressionParser> expressionParser_;\n};\n\n#endif // SINGLESUBSPACEMAPEDITOR_H\n"
  },
  {
    "path": "editors/ComponentEditor/memoryMaps/SubspaceMapColumns.h",
    "content": "//-----------------------------------------------------------------------------\n// File: SubspaceMapColumns.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 09.02.2022\n//\n// Description:\n// Common declarations for subspace map columns.\n//-----------------------------------------------------------------------------\n\n#ifndef SUBSPACEMAP_COLUMNS_H\n#define SUBSPACEMAP_COLUMNS_H\n\nnamespace SubspaceMapColumns\n{\n    //! Defines the columns for the subspace maps table.\n    enum Column\n    {\n        NAME = 0,\n        BASE,\n        INITIATORREFERENCE,\n        SEGMENTREFERENCE,\n        IS_PRESENT,\n        DESCRIPTION_COLUMN,\n        COLUMN_COUNT\n    };\n}\n\n#endif //SUBSPACEMAP_COLUMNS_H"
  },
  {
    "path": "editors/ComponentEditor/memoryMaps/SubspaceMapDelegate.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: SubspaceMapDelegate.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 14.02.2022\n//\n// Description:\n// The delegate that provides editors to add/remove/edit details of subspace maps.\n//-----------------------------------------------------------------------------\n\n#include \"SubspaceMapDelegate.h\"\n\n#include <editors/ComponentEditor/memoryMaps/SubspaceMapColumns.h>\n#include <KactusAPI/include/SubspaceMapInterface.h>\n#include <KactusAPI/include/BusInterfaceInterface.h>\n\n#include <IPXACTmodels/Component/AddressSpace.h>\n#include <IPXACTmodels/Component/Segment.h>\n#include <IPXACTmodels/generaldeclarations.h>\n\n#include <QLineEdit>\n#include <QComboBox>\n\n//-----------------------------------------------------------------------------\n// Function: SubspaceMapDelegate::SubspaceMapDelegate()\n//-----------------------------------------------------------------------------\nSubspaceMapDelegate::SubspaceMapDelegate(QAbstractItemModel* completionModel,\n    QSharedPointer<ParameterFinder> parameterFinder, SubspaceMapInterface* subspaceInterface,\n    QSharedPointer<QList<QSharedPointer<AddressSpace> > > addressSpaces, Document::Revision docRevision, QObject *parent) :\nMemoryBlockDelegate(completionModel, parameterFinder, parent),\nsubspaceInterface_(subspaceInterface),\nbusInterface_(subspaceInterface_->getBusInterface()),\naddressSpaces_(addressSpaces),\ndocRevision_(docRevision)\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: SubspaceMapDelegate::createEditor()\n//-----------------------------------------------------------------------------\nQWidget* SubspaceMapDelegate::createEditor(QWidget* parent, QStyleOptionViewItem const& option,\n    QModelIndex const& index) const \n{\n    if (index.column() == SubspaceMapColumns::INITIATORREFERENCE ||\n        index.column() == SubspaceMapColumns::SEGMENTREFERENCE)\n    {\n        QComboBox* comboBox = new QComboBox(parent);\n        comboBox->addItem(\"\");\n\n        if (index.column() == SubspaceMapColumns::INITIATORREFERENCE)\n        {\n            comboBox->addItems(getInitiatorInterfaceNames());\n        }\n        else if (index.column() == SubspaceMapColumns::SEGMENTREFERENCE)\n        {\n            comboBox->addItems(getSegmentNames(index));\n        }\n        \n        return comboBox;\n    }\n    else\n    {\n        return MemoryBlockDelegate::createEditor(parent, option, index);\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: SubspaceMapDelegate::getInitiatorInterfaceNames()\n//-----------------------------------------------------------------------------\nQStringList SubspaceMapDelegate::getInitiatorInterfaceNames() const\n{\n    QStringList interfaceNames;\n\n    auto initiatorMode = docRevision_ == Document::Revision::Std22 ? General::INITIATOR : General::MASTER;\n\n    for (auto interfaceName : busInterface_->getItemNames())\n    {\n        if (busInterface_->getMode(interfaceName) == initiatorMode)\n        {\n            interfaceNames.append(QString::fromStdString(interfaceName));\n        }\n    }\n\n    return interfaceNames;\n}\n\n//-----------------------------------------------------------------------------\n// Function: SubspaceMapDelegate::getSegmentNames()\n//-----------------------------------------------------------------------------\nQStringList SubspaceMapDelegate::getSegmentNames(QModelIndex const& index) const\n{\n    QStringList segmentNames;\n\n    QModelIndex masterIndex = index.sibling(index.row(), SubspaceMapColumns::INITIATORREFERENCE);\n    QString initiatorReference = masterIndex.data().toString();\n    if (!initiatorReference.isEmpty())\n    {\n        QSharedPointer<AddressSpace> space = getAddressSpace(initiatorReference);\n        if (space)\n        {\n            for (auto segment : *space->getSegments())\n            {\n                segmentNames.append(segment->name());\n            }\n        }\n    }\n\n    return segmentNames;\n}\n\n//-----------------------------------------------------------------------------\n// Function: SubspaceMapDelegate::getAddressSpace()\n//-----------------------------------------------------------------------------\nQSharedPointer<AddressSpace> SubspaceMapDelegate::getAddressSpace(QString const& busName) const\n{\n    QString spaceReference =\n        QString::fromStdString(busInterface_->getAddressSpaceReference(busName.toStdString()));\n    if (!spaceReference.isEmpty())\n    {\n        for (auto space : *addressSpaces_)\n        {\n            if (space->name() == spaceReference)\n            {\n                return space;\n            }\n        }\n    }\n\n    return QSharedPointer<AddressSpace>();\n}\n\n//-----------------------------------------------------------------------------\n// Function: SubspaceMapDelegate::setEditorData()\n//-----------------------------------------------------------------------------\nvoid SubspaceMapDelegate::setEditorData(QWidget* editor, QModelIndex const& index) const\n{\n    if (index.column() == SubspaceMapColumns::INITIATORREFERENCE ||\n        index.column() == SubspaceMapColumns::SEGMENTREFERENCE)\n    {\n        QString currentValue = index.model()->data(index).toString();\n\n        QComboBox* combo = qobject_cast<QComboBox*>(editor);\n        if (combo)\n        {\n            int valueIndex = combo->findText(currentValue);\n            if (valueIndex < 0)\n            {\n                combo->addItem(currentValue);\n                valueIndex = combo->findText(currentValue);\n            }\n\n            combo->setCurrentIndex(valueIndex);\n        }\n    }\n    else\n    {\n        MemoryBlockDelegate::setEditorData(editor, index);\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: SubspaceMapDelegate::setModelData()\n//-----------------------------------------------------------------------------\nvoid SubspaceMapDelegate::setModelData(QWidget* editor, QAbstractItemModel* model, QModelIndex const& index) const\n{\n    QComboBox* combo = qobject_cast<QComboBox*>(editor);\n    if (combo)\n    {\n        QString text = combo->currentText();\n        model->setData(index, text, Qt::EditRole);\n    }\n    else \n    {\n        MemoryBlockDelegate::setModelData(editor, model, index);\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: SubspaceMapDelegate::descriptionColumn()\n//-----------------------------------------------------------------------------\nint SubspaceMapDelegate::descriptionColumn() const\n{\n    return SubspaceMapColumns::DESCRIPTION_COLUMN;\n}\n\n//-----------------------------------------------------------------------------\n// Function: SubspaceMapDelegate::nameColumn()\n//-----------------------------------------------------------------------------\nint SubspaceMapDelegate::nameColumn() const\n{\n    return SubspaceMapColumns::NAME;\n}\n\n//-----------------------------------------------------------------------------\n// Function: SubspaceMapDelegate::baseAddressColumn()\n//-----------------------------------------------------------------------------\nint SubspaceMapDelegate::baseAddressColumn() const\n{\n    return SubspaceMapColumns::BASE;\n}\n\n//-----------------------------------------------------------------------------\n// Function: SubspaceMapDelegate::isPresentColumn()\n//-----------------------------------------------------------------------------\nint SubspaceMapDelegate::isPresentColumn() const\n{\n    return SubspaceMapColumns::IS_PRESENT;\n}\n"
  },
  {
    "path": "editors/ComponentEditor/memoryMaps/SubspaceMapDelegate.h",
    "content": "//-----------------------------------------------------------------------------\n// File: SubspaceMapDelegate.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 14.02.2022\n//\n// Description:\n// The delegate that provides editors to add/remove/edit details of subspace maps.\n//-----------------------------------------------------------------------------\n\n#ifndef SUBSPACEMAPDELEGATE_H\n#define SUBSPACEMAPDELEGATE_H\n\n#include <editors/ComponentEditor/memoryMaps/MemoryBlockDelegate.h>\n\n#include <IPXACTmodels/common/Document.h>\n\nclass SubspaceMapInterface;\nclass BusInterfaceInterface;\nclass AddressSpace;\n\n#include <QSharedPointer>\n\n//-----------------------------------------------------------------------------\n//! The delegate that provides editors to add/remove/edit details of subspace maps.\n//-----------------------------------------------------------------------------\nclass SubspaceMapDelegate : public MemoryBlockDelegate\n{\n\tQ_OBJECT\n\npublic:\n\t\n\t/*!\n\t *  The constructor.\n\t *\n     *    @param [in] completionModel         Model containing the completions used in expression editor.\n\t *    @param [in] parameterFinder         The parameter finder for expression editor.\n     *    @param [in] subspaceInterface       Interface for accessing subspace maps.\n     *    @param [in] docRevision             The IP-XACT standard revision to comply to.\n\t *    @param [in] parent                  Pointer to the owner of the delegate.\n\t */\n\tSubspaceMapDelegate(QAbstractItemModel* completionModel, QSharedPointer<ParameterFinder> parameterFinder, \n        SubspaceMapInterface* subspaceInterface, QSharedPointer<QList<QSharedPointer<AddressSpace> > > addressSpaces,\n        Document::Revision docRevision, QObject *parent);\n\t\n\t/*!\n     *  The destructor.\n     */\n    virtual ~SubspaceMapDelegate() = default;\n\n    //! No copying.\tNo assignment.\n    SubspaceMapDelegate(const SubspaceMapDelegate& other) = delete;\n    SubspaceMapDelegate& operator=(const SubspaceMapDelegate& other) = delete;\n\n\t/*!\n     *  Create a new editor for the given item\n\t *\n\t *    @param [in] parent Owner for the editor.\n\t *    @param [in] option Contains options for the editor.\n\t *    @param [in] index Model index identifying the item.\n\t *\n\t *    @return Pointer to the editor to be used to edit the item.\n\t */\n\tvirtual QWidget* createEditor(QWidget* parent, const QStyleOptionViewItem& option, QModelIndex const& index)\n        const;\n\n\t/*!\n     *  Set the data for the editor.\n\t *\n\t *    @param [in] editor Pointer to the editor where the data is to be set.\n\t *    @param [in] index Model index identifying the item that's data is to be set.\n\t */\n\tvirtual void setEditorData(QWidget* editor, QModelIndex const& index) const;\n\n\t/*!\n     *  Save the data from the editor to the model.\n\t *\n\t *    @param [in] editor Pointer to the editor that contains the data to store.\n\t *    @param [in] model Model that contains the data structure where data is to be saved to.\n\t *    @param [in] index Model index identifying the item that's data is to be saved.\n\t */\n\tvirtual void setModelData(QWidget* editor, QAbstractItemModel* model, QModelIndex const& index) const;\n\nprotected:\n\n    /*!\n     *  Gets the description column.\n     */\n    virtual int descriptionColumn() const;\n\nprivate:\n\n    /*!\n     *  Get the available initiator/master bus interface names.\n     *\n     *    @return List of initiator/master bus interface names.\n     */\n    QStringList getInitiatorInterfaceNames() const;\n\n    /*!\n     *  Get the list of available segments.\n     *\n     *    @param [in] index   Index of the selected subspace map.\n     *\n     *    @return List of available segments.\n     */\n    QStringList getSegmentNames(QModelIndex const& index) const;\n\n    /*!\n     *  Get the address space of the selected bus interface.\n     *\n     *    @param [in] busName     Name of the selected bus interface.\n     *\n     *    @return Address of the selected bus interface.\n     */\n    QSharedPointer<AddressSpace> getAddressSpace(QString const& busName) const;\n\n    /*!\n     *  Get the column for block name.\n     *\n     *    @return Index of the name column.\n     */\n    virtual int nameColumn() const override final;\n\n    /*!\n     *  Get the column for block base address.\n     *\n     *    @return Index of the base address column.\n     */\n    virtual int baseAddressColumn() const override final;\n\n    /*!\n     *  Get the column for block is present.\n     *\n     *    @return Index of the is present column.\n     */\n    virtual int isPresentColumn() const override final;\n\n    //-----------------------------------------------------------------------------\n    // Data.\n    //-----------------------------------------------------------------------------\n\n    //! Interface for accessing subspace maps.\n    SubspaceMapInterface* subspaceInterface_;\n\n    //! Interface for accessing bus interfaces.\n    BusInterfaceInterface* busInterface_;\n\n    //! List of available address spaces.\n    QSharedPointer<QList<QSharedPointer<AddressSpace> > > addressSpaces_;\n\n    //! The IP-XACT standard revision to comply to.\n    Document::Revision docRevision_;\n};\n\n#endif // SUBSPACEMAPDELEGATE_H\n"
  },
  {
    "path": "editors/ComponentEditor/memoryMaps/SubspaceMapModel.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: SubspaceMapModel.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 11.02.2022\n//\n// Description:\n// The model to manage the subspace maps of a single memory map.\n//-----------------------------------------------------------------------------\n\n#include \"SubspaceMapModel.h\"\n\n#include <editors/ComponentEditor/memoryMaps/SubspaceMapColumns.h>\n#include <KactusAPI/include/SubspaceMapInterface.h>\n\n#include <common/KactusColors.h>\n\n#include <QRegularExpression>\n#include <QApplication>\n#include <QClipboard>\n#include <QMimeData>\n\n//-----------------------------------------------------------------------------\n// Function: SubspaceMapModel::SubspaceMapModel()\n//-----------------------------------------------------------------------------\nSubspaceMapModel::SubspaceMapModel(SubspaceMapInterface* subspaceInterface,\n    QSharedPointer<ExpressionParser> expressionParser, QSharedPointer<ParameterFinder> parameterFinder,\n    Document::Revision docRevision, QObject *parent):\nMemoryBlockModel(subspaceInterface, expressionParser, parameterFinder, docRevision, parent),\nsubspaceInterface_(subspaceInterface)\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: SubspaceMapModel::columnCount()\n//-----------------------------------------------------------------------------\nint SubspaceMapModel::columnCount(QModelIndex const& parent) const\n{\n    if (parent.isValid())\n    {\n        return 0;\n    }\n    return SubspaceMapColumns::COLUMN_COUNT;\n}\n\n//-----------------------------------------------------------------------------\n// Function: SubspaceMapModel::flags()\n//-----------------------------------------------------------------------------\nQt::ItemFlags SubspaceMapModel::flags(QModelIndex const& index) const\n{\n    if (!index.isValid())\n    {\n        return Qt::NoItemFlags;\n    }\n\n    if (index.column() == SubspaceMapColumns::SEGMENTREFERENCE)\n    {\n        std::string subspaceName = subspaceInterface_->getIndexedItemName(index.row());\n        if (!subspaceName.empty())\n        {\n            std::string masterReference = subspaceInterface_->getInitiatorReference(subspaceName);\n            std::string segmentReference = subspaceInterface_->getSegmentReference(subspaceName);\n            if (masterReference.empty() && segmentReference.empty())\n            {\n                return Qt::ItemIsEnabled;\n            }\n        }\n    }\n\n    return MemoryBlockModel::flags(index);\n}\n\n//-----------------------------------------------------------------------------\n// Function: SubspaceMapModel::headerData()\n//-----------------------------------------------------------------------------\nQVariant SubspaceMapModel::headerData(int section, Qt::Orientation orientation, int role) const\n{\n    if (orientation != Qt::Horizontal)\n    {\n        return QVariant();\n    }\n\n    if (Qt::DisplayRole == role)\n    {\n        if (section == SubspaceMapColumns::INITIATORREFERENCE)\n        {\n            QString initiatorHeader = docRevision_ == Document::Revision::Std22 \n                ? tr(\"Initiator\\ninterface\") : tr(\"Master\\ninterface\");\n\n            return initiatorHeader;\n        }\n        else if (section == SubspaceMapColumns::SEGMENTREFERENCE)\n        {\n            QString segmentHeader = tr(\"Segment\");\n            return segmentHeader;\n        }\n    }\n\n    return MemoryBlockModel::headerData(section, orientation, role);\n}\n\n//-----------------------------------------------------------------------------\n// Function: SubspaceMapModel::data()\n//-----------------------------------------------------------------------------\nQVariant SubspaceMapModel::data(QModelIndex const& index, int role) const\n{\n    if (!index.isValid() || index.row() < 0 || index.row() >= subspaceInterface_->itemCount())\n    {\n        return QVariant();\n    }\n\n    std::string blockName = subspaceInterface_->getIndexedItemName(index.row());\n\n    if (role == Qt::BackgroundRole && index.column() == SubspaceMapColumns::INITIATORREFERENCE)\n    {\n        return KactusColors::MANDATORY_FIELD;\n    }\n\n    return MemoryBlockModel::data(index, role);\n}\n\n//-----------------------------------------------------------------------------\n// Function: SubspaceMapModel::setData()\n//-----------------------------------------------------------------------------\nbool SubspaceMapModel::setData(QModelIndex const& index, QVariant const& value, int role)\n{\n    if (!index.isValid() || index.row() < 0 || index.row() >= subspaceInterface_->itemCount())\n    {\n        return false;\n    }\n\n    if (Qt::EditRole == role)\n    {\n        std::string blockName = subspaceInterface_->getIndexedItemName(index.row());\n\n        if (index.column() == SubspaceMapColumns::INITIATORREFERENCE)\n        {\n            if (!subspaceInterface_->setMasterReference(blockName, value.toString().toStdString()))\n            {\n                return false;\n            }\n        }\n        else if (index.column() == SubspaceMapColumns::SEGMENTREFERENCE)\n        {\n            if (!subspaceInterface_->setSegmentReference(blockName, value.toString().toStdString()))\n            {\n                return false;\n            }\n        }\n        else\n        {\n            return MemoryBlockModel::setData(index, value, role);\n        }\n\n        if (index.column() == SubspaceMapColumns::INITIATORREFERENCE ||\n            index.column() == SubspaceMapColumns::SEGMENTREFERENCE)\n        {\n            emit childAddressingChanged(index.row());\n        }\n\n        emit dataChanged(index, index);\n        emit contentChanged();\n        return true;\n    }\n    else\n    {\n        return false;\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: SubspaceMapModel::validateIndex()\n//-----------------------------------------------------------------------------\nbool SubspaceMapModel::validateIndex(QModelIndex const& index) const\n{\n    std::string blockName = subspaceInterface_->getIndexedItemName(index.row());\n    if (index.column() == SubspaceMapColumns::INITIATORREFERENCE)\n    {\n        return subspaceInterface_->hasValidMasterReference(blockName);\n    }\n    else if (index.column() == SubspaceMapColumns::SEGMENTREFERENCE)\n    {\n        return subspaceInterface_->hasValidSegmentReference(blockName);\n    }\n\n    return MemoryBlockModel::validateIndex(index);\n}\n\n//-----------------------------------------------------------------------------\n// Function: SubspaceMapModel::valueForIndex()\n//-----------------------------------------------------------------------------\nQVariant SubspaceMapModel::valueForIndex(QModelIndex const& index) const\n{\n    std::string blockName = subspaceInterface_->getIndexedItemName(index.row());\n\n    if (index.column() == SubspaceMapColumns::INITIATORREFERENCE)\n    {\n        return QString::fromStdString(subspaceInterface_->getInitiatorReference(blockName));\n    }\n    else if (index.column() == SubspaceMapColumns::SEGMENTREFERENCE)\n    {\n        return QString::fromStdString(subspaceInterface_->getSegmentReference(blockName));\n    }\n\n    return MemoryBlockModel::valueForIndex(index);\n}\n\n//-----------------------------------------------------------------------------\n// Function: SubspaceMapModel::isValidExpressionColumn()\n//-----------------------------------------------------------------------------\nbool SubspaceMapModel::isValidExpressionColumn(QModelIndex const& index) const\n{\n    int column = index.column();\n    return column == SubspaceMapColumns::BASE || column == SubspaceMapColumns::IS_PRESENT;\n}\n\n//-----------------------------------------------------------------------------\n// Function: SubspaceMapModel::mimeTypes()\n//-----------------------------------------------------------------------------\nQStringList SubspaceMapModel::mimeTypes() const\n{\n    QStringList types(QAbstractItemModel::mimeTypes());\n\n    types << \"text/xml/ipxact:subspaceMap\";\n\n    return types;\n}\n\n//-----------------------------------------------------------------------------\n// Function: SubspaceMapModel::nameColumn()\n//-----------------------------------------------------------------------------\nint SubspaceMapModel::nameColumn() const\n{\n    return SubspaceMapColumns::NAME;\n}\n\n//-----------------------------------------------------------------------------\n// Function: SubspaceMapModel::baseAddressColumn()\n//-----------------------------------------------------------------------------\nint SubspaceMapModel::baseAddressColumn() const\n{\n    return SubspaceMapColumns::BASE;\n}\n\n//-----------------------------------------------------------------------------\n// Function: SubspaceMapModel::isPresentColumn()\n//-----------------------------------------------------------------------------\nint SubspaceMapModel::isPresentColumn() const\n{\n    return SubspaceMapColumns::IS_PRESENT;\n}\n\n//-----------------------------------------------------------------------------\n// Function: SubspaceMapModel::descriptionColumn()\n//-----------------------------------------------------------------------------\nint SubspaceMapModel::descriptionColumn() const\n{\n    return SubspaceMapColumns::DESCRIPTION_COLUMN;\n}\n"
  },
  {
    "path": "editors/ComponentEditor/memoryMaps/SubspaceMapModel.h",
    "content": "//-----------------------------------------------------------------------------\n// File: SubspaceMapModel.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 11.02.2022\n//\n// Description:\n// The model to manage the subspace maps of a single memory map.\n//-----------------------------------------------------------------------------\n\n#ifndef SUBSPACEMAPMODEL_H\n#define SUBSPACEMAPMODEL_H\n\n#include <KactusAPI/include/ParameterFinder.h>\n#include <editors/ComponentEditor/memoryMaps/MemoryBlockModel.h>\n\n#include <QAbstractTableModel>\n#include <QSharedPointer>\n#include <QList>\n\nclass SubspaceMapInterface;\n\n//-----------------------------------------------------------------------------\n// The model to manage the subspace maps of a single memory map.\n//-----------------------------------------------------------------------------\nclass SubspaceMapModel : public MemoryBlockModel\n{\n    Q_OBJECT\n\npublic:\n\n    /*!\n     *  The constructor.\n     *\n     *    @param [in] subspaceInterface   Interface for accessing subspace maps;\n     *    @param [in] expressionParser    Pointer to the expression parser.\n     *    @param [in] parameterFinder     Pointer to the parameter finder.\n     *    @param [in] docRevision         The IP-XACT standard revision in use.\n     *    @param [in] parent              Pointer to the owner of this model.\n     */\n    SubspaceMapModel(SubspaceMapInterface* subspaceInterface,\n        QSharedPointer <ExpressionParser> expressionParser,\n        QSharedPointer <ParameterFinder> parameterFinder,\n        Document::Revision docRevision,\n        QObject *parent);\n\n    /*!\n     *  The destructor.\n     */\n    virtual ~SubspaceMapModel() = default;\n\n    //! No copying.\tNo assignment.\n    SubspaceMapModel(const SubspaceMapModel& other) = delete;\n    SubspaceMapModel& operator=(const SubspaceMapModel& other) = delete;\n\n    /*!\n     *  Get the number of columns the item has to be displayed.\n     *\n     *    @param [in] parent  Identifies the parent that's column count is requested.\n     *\n     *    @return The number of columns to be displayed.\n     */\n    virtual int columnCount(QModelIndex const& parent = QModelIndex()) const;\n\n    /*!\n     *  Get the item flags that defines the possible operations for the item.\n     *\n     *    @param [in] index   Model index that identifies the item.\n     *\n     *    @return Qt::ItemFlags specify the possible operations for the item.\n     */\n    virtual Qt::ItemFlags flags(QModelIndex const& index) const override final;\n    \n    /*!\n     *  Get the header data for specified header.\n     *\n     *    @param [in] section         The section specifies the row/column number for the header.\n     *    @param [in] orientation     Specified if horizontal or vertical header is wanted.\n     *    @param [in] role            Specifies the type of the requested data.\n     *\n     *    @return QVariant Contains the requested data.\n     */\n    virtual QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;\n\n    /*!\n     *  Get the data for specified item.\n     *\n     *    @param [in] index   Specifies the item that's data is requested.\n     *    @param [in] role    The role that defines what kind of data is requested.\n     *\n     *    @return QVariant Contains the data for the item.\n     */\n    virtual QVariant data(QModelIndex const& index, int role = Qt::DisplayRole) const;\n\n    /*!\n     *  Save the data to the model for specified item.\n     *\n     *    @param [in] index   The model index of the item that's data is to be saved.\n     *    @param [in] value   The data that is to be saved.\n     *    @param [in] role    The role specifies what kind of data should be saved.\n     *\n     *    @return True if saving happened successfully.\n     */\n    bool setData(QModelIndex const& index, const QVariant& value, int role = Qt::EditRole);\n\n    /*!\n     *  Get the list of acceptable mime types.\n     *\n     *    @return The list of acceptable mime types.\n     */\n    virtual QStringList mimeTypes() const override final;\n\nprotected:\n    \n    /*!\n     *  validates the data in the selected index.\n     *\n     *    @param [in] index   The index being validated.\n     *\n     *    @return True, if the data is valid, otherwise false.\n     */\n    virtual bool validateIndex(QModelIndex const& index) const override final;\n\n    /*!\n     *  Gets the value for the given index.\n     *\n     *    @param [in] index   The index of the target data.\n     *\n     *    @return The data in the given index.\n     */\n    virtual QVariant valueForIndex(QModelIndex const& index) const override final;\n    \n    /*!\n     *  Checks if the column index is valid for expressions.\n     *\n     *    @param [in] index   The index being evaluated.\n     *\n     *    @return True, if the column can have expressions, otherwise false.\n     */\n    bool isValidExpressionColumn(QModelIndex const& index) const final;\n\nprivate:\n\n    /*!\n     *  Get the index of the name column.\n     *\n     *    @return Index of the name column.\n     */\n    virtual int nameColumn() const override final;\n\n    /*!\n     *  Get the index of the base address column.\n     *\n     *    @return Index of the base address column.\n     */\n    virtual int baseAddressColumn() const override final;\n\n    /*!\n     *  Get the index of the is present column.\n     *\n     *    @return Index of the is present column.\n     */\n    virtual int isPresentColumn() const override final;\n\n    /*!\n     *  Get the index of the description column.\n     *\n     *    @return Index of the description column.\n     */\n    virtual int descriptionColumn() const override final;\n\n    //-----------------------------------------------------------------------------\n    // Data.\n    //-----------------------------------------------------------------------------\n\n    //! Interface for accessing subspace maps.\n    SubspaceMapInterface* subspaceInterface_;\n};\n\n#endif // SUBSPACEMAPMODEL_H\n"
  },
  {
    "path": "editors/ComponentEditor/memoryMaps/SubspaceMapsEditor.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: SubspaceMapsEditor.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 25.01.2022\n//\n// Description:\n// The editor to edit the subspace maps of a single memory map.\n//-----------------------------------------------------------------------------\n\n#include \"SubspaceMapsEditor.h\"\n\n#include <common/views/EditableTableView/editabletableview.h>\n\n#include <editors/ComponentEditor/memoryMaps/MemoryBlockFilter.h>\n#include <editors/ComponentEditor/memoryMaps/SubspaceMapColumns.h>\n#include <editors/ComponentEditor/memoryMaps/SubspaceMapModel.h>\n#include <editors/ComponentEditor/memoryMaps/SubspaceMapDelegate.h>\n#include <KactusAPI/include/SubspaceMapInterface.h>\n#include <editors/ComponentEditor/parameters/ComponentParameterModel.h>\n\n#include <IPXACTmodels/Component/Component.h>\n\n#include <QCompleter>\n#include <QVBoxLayout>\n\n//-----------------------------------------------------------------------------\n// Function: MemoryMapEditor::MemoryMapEditor()\n//-----------------------------------------------------------------------------\nSubspaceMapsEditor::SubspaceMapsEditor(QSharedPointer<Component> component,\n    QSharedPointer<ParameterFinder> parameterFinder, QSharedPointer<ExpressionParser> expressionParser,\n    SubspaceMapInterface* subspaceMapInterface, QSharedPointer<QList<QSharedPointer<MemoryBlockBase>>> blocks,\n    QWidget* parent):\nQGroupBox(tr(\"Subspace maps summary\"), parent),\nview_(new EditableTableView(this)),\nmodel_(new SubspaceMapModel(subspaceMapInterface, expressionParser, parameterFinder, component->getRevision(), this)),\ninterface_(subspaceMapInterface),\nblocks_(blocks),\ncomponent_(component)\n{\n    interface_->setMemoryBlocks(blocks_);\n    interface_->setupSubInterfaces(component_);\n\n    ComponentParameterModel* componentParameterModel = new ComponentParameterModel(parameterFinder, this);\n    componentParameterModel->setExpressionParser(expressionParser);\n\n\tQVBoxLayout* layout = new QVBoxLayout(this);\n\tlayout->addWidget(view_);\n\n    MemoryBlockFilter* proxy = new MemoryBlockFilter(expressionParser, subspaceMapInterface, this);\n    proxy->setColumnToAcceptExpressions(SubspaceMapColumns::BASE);\n    proxy->setColumnToAcceptExpressions(SubspaceMapColumns::IS_PRESENT);\n\n\tproxy->setSourceModel(model_);\n\tview_->setModel(proxy);\n    view_->setAllowElementCopying(true);\n\tview_->setItemsDraggable(false);\n\tview_->setSortingEnabled(true);\n\n    view_->setItemDelegate(new SubspaceMapDelegate(componentParameterModel, parameterFinder, interface_,\n        component->getAddressSpaces(), component->getRevision(), this));\n    view_->sortByColumn(SubspaceMapColumns::BASE, Qt::AscendingOrder);\n\n    if (component->getRevision() == Document::Revision::Std22)\n    {\n        view_->hideColumn(SubspaceMapColumns::IS_PRESENT);\n    }\n\n\tconnect(model_, SIGNAL(contentChanged()), this, SIGNAL(contentChanged()), Qt::UniqueConnection);\n    connect(model_, SIGNAL(graphicsChanged(int)), this, SIGNAL(graphicsChanged(int)), Qt::UniqueConnection);\n    \n\tconnect(model_, SIGNAL(itemAdded(int)),\tthis, SIGNAL(childAdded(int)), Qt::UniqueConnection);\n\tconnect(model_, SIGNAL(itemRemoved(int)), this, SIGNAL(childRemoved(int)), Qt::UniqueConnection);\n\n\tconnect(view_, SIGNAL(addItem(const QModelIndex&)),\n        model_, SLOT(onAddItem(const QModelIndex&)), Qt::UniqueConnection);\n\tconnect(view_, SIGNAL(removeItem(const QModelIndex&)),\n\t\tmodel_, SLOT(onRemoveItem(const QModelIndex&)), Qt::UniqueConnection);\n\n    connect(view_->itemDelegate(), SIGNAL(increaseReferences(QString)),\n        this, SIGNAL(increaseReferences(QString)), Qt::UniqueConnection);\n    connect(view_->itemDelegate(), SIGNAL(decreaseReferences(QString)),\n        this, SIGNAL(decreaseReferences(QString)), Qt::UniqueConnection);\n\n    connect(model_, SIGNAL(decreaseReferences(QString)),\n        this, SIGNAL(decreaseReferences(QString)), Qt::UniqueConnection);\n\n    connect(model_, SIGNAL(increaseReferences(QString)),\n        this, SIGNAL(increaseReferences(QString)), Qt::UniqueConnection);\n\n    connect(view_, SIGNAL(copyRows(QModelIndexList)),\n        model_, SLOT(onCopyRows(QModelIndexList)), Qt::UniqueConnection);\n    connect(view_, SIGNAL(pasteRows()), model_, SLOT(onPasteRows()), Qt::UniqueConnection);\n\n    connect(this, SIGNAL(assignNewAddressUnitBits(QString const&)),\n        model_, SLOT(addressUnitBitsUpdated(QString const&)), Qt::UniqueConnection);\n\n    connect(model_, SIGNAL(blockNameChanged(QString const&, QString const&)),\n        this, SIGNAL(subspaceMapNameChanged(QString const&, QString const&)), Qt::UniqueConnection);\n\n    connect(model_, SIGNAL(invalidateOtherFilter()), this, SIGNAL(invalidateOtherFilter()), Qt::UniqueConnection);\n\n    connect(model_, SIGNAL(childAddressingChanged(int)),\n        this, SIGNAL(childAddressingChanged(int)), Qt::UniqueConnection);\n\n    connect(this, SIGNAL(invalidateThisFilter()), proxy, SLOT(invalidate()), Qt::UniqueConnection);\n}\n\n//-----------------------------------------------------------------------------\n// Function: SubspaceMapsEditor::refresh()\n//-----------------------------------------------------------------------------\nvoid SubspaceMapsEditor::refresh()\n{\n    view_->update();\n\n    interface_->setMemoryBlocks(blocks_);\n    interface_->setupSubInterfaces(component_);\n}\n\n"
  },
  {
    "path": "editors/ComponentEditor/memoryMaps/SubspaceMapsEditor.h",
    "content": "//-----------------------------------------------------------------------------\n// File: SubspaceMapsEditor.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 25.01.2022\n//\n// Description:\n// The editor to edit the subspace maps of a single memory map.\n//-----------------------------------------------------------------------------\n\n#ifndef SUBSPACEMAPEDITOR_H\n#define SUBSPACEMAPEDITOR_H\n\n#include <KactusAPI/include/ParameterFinder.h>\n\n#include <IPXACTmodels/Component/MemoryMapBase.h>\n\n#include <QSortFilterProxyModel>\n#include <QSharedPointer>\n#include <QGroupBox>\n\nclass EditableTableView;\nclass LibraryInterface;\nclass ExpressionParser;\nclass Component;\nclass SubspaceMapModel;\nclass SubspaceMapInterface;\n\n//-----------------------------------------------------------------------------\n//! The editor to edit the subspace maps of a single memory map.\n//-----------------------------------------------------------------------------\nclass SubspaceMapsEditor : public QGroupBox\n{\n\tQ_OBJECT\n\npublic:\n\n    /*!\n\t *  The constructor.\n\t *\n\t *    @param [in] component               The component being edited.\n\t *    @param [in] parameterFinder         The parameter finder for component.\n     *    @param [in] expressionParser        The expression parser.\n     *    @param [in] subspaceMapInterface    Interface for accessing subspace maps.\n     *    @param [in] blocks                  Pointer to the available memory blocks.\n\t *    @param [in] parent                  The parent of this editor.\n\t */\n    SubspaceMapsEditor(QSharedPointer<Component> component,\n        QSharedPointer<ParameterFinder> parameterFinder,\n        QSharedPointer<ExpressionParser> expressionParser,\n        SubspaceMapInterface* subspaceMapInterface,\n        QSharedPointer<QList<QSharedPointer<MemoryBlockBase> > > blocks,\n        QWidget* parent = 0);\n\n\t/*!\n     *  The destructor.\n     */\n    virtual ~SubspaceMapsEditor() = default;\n\n\t/*!\n     *  Reload the information from the model to the editor.\n\t */\n\tvirtual void refresh();\n\nsignals:\n    \n    /*!\n     *  Emitted when the contents of the widget change.\n     */\n    void contentChanged();\n\n    /*!\n     *  Informs of a need to redraw the visualization.\n     */\n    void graphicsChanged(int);\n\n    /*!\n     *  Emits an error message for the user.\n     *\n     *    @param [in] msg     The error message.\n     */\n    void errorMessage(const QString& msg) const;\n\n    /*!\n     *  Emits a notice message for the user.\n     *\n     *    @param [in] msg   [Description].\n     */\n    void noticeMessage(const QString& msg) const;\n\n    /*!\n     *  Increases the number of references to the given parameter.\n     *\n     *    @param [in] id  The target parameter.\n     */\n    void increaseReferences(QString id);\n\n    /*!\n     *  Decreases the number of references to the given parameter.\n     *\n     *    @param [in] id  The target parameter.\n     */\n    void decreaseReferences(QString id);\n\n    /*!\n     *  Assign new address unit bits for address blocks.\n     *\n     *    @param [in] newAddressUnitBits  The new address unit bits.\n     */\n    void assignNewAddressUnitBits(QString const& newAddressUnitBits);\n\n    /*\n     *  Informs of address block name change.\n     *\n     *    @param [in] oldName     The old name.\n     *    @param [in] newName     The new name.\n     */\n    void subspaceMapNameChanged(QString const& oldName, QString const& newName);\n\n    /*!\n     *  Inform the other memory block editor to invalidate the filter.\n     */\n    void invalidateOtherFilter();\n\n    /*!\n     *  Inform this editor to invalidate the filter.\n     */\n    void invalidateThisFilter();\n    \n    /*!\n     *  Informs of an added child.\n     *\n     *    @param [in] index   The index of the new child.\n     */\n    void childAdded(int index);\n\n    /*!\n     *  Informs of a removed child.\n     *\n     *    @param [in] index   The index of the removed child.\n     */\n    void childRemoved(int index);\n\n    /*!\n     *  Informs of a change in item addressing.\n     *\n     *    @param [in] index   Index of the item whose addressing is changed.\n     */\n    void childAddressingChanged(int index);\n\nprivate:\n\t\n    //! No copying.\tNo assignment.\n    SubspaceMapsEditor(const SubspaceMapsEditor& other);\n    SubspaceMapsEditor& operator=(const SubspaceMapsEditor& other);\n\n\t//! The view to show the details of a memory map.\n\tEditableTableView* view_;\n\n\t//! The model that manages the items.\n    SubspaceMapModel* model_;\n\n    //! Interface for accessing address blocks.\n    SubspaceMapInterface* interface_;\n\n    //! Pointer to the available address blocks.\n    QSharedPointer<QList<QSharedPointer<MemoryBlockBase> > > blocks_;\n\n    //! The containing component.\n    QSharedPointer<Component> component_;\n};\n\n#endif // SUBSPACEMAPEDITOR_H\n"
  },
  {
    "path": "editors/ComponentEditor/memoryMaps/WriteValueConstraintComboBox.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: WriteValueConstraintComboBox.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Mikko Teuho\r\n// Date: 28.04.2015\r\n//\r\n// Description:\r\n// Combo box for the write value constraint of a field.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"WriteValueConstraintComboBox.h\"\r\n\r\n#include <IPXACTmodels/Component/WriteValueConstraint.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: WriteValueConstraintComboBox::WriteValueConstraintComboBox()\r\n//-----------------------------------------------------------------------------\r\nWriteValueConstraintComboBox::WriteValueConstraintComboBox(QSharedPointer<WriteValueConstraint> writeConstraint,\r\n    QWidget* parent):\r\nQComboBox(parent),\r\nwriteConstraint_(writeConstraint)\r\n{\r\n    setEditable(false);\r\n\r\n    addItem(tr(\"Write as read\"));\r\n    addItem(tr(\"Use enumerated values\"));\r\n    addItem(tr(\"Set minimum and maximum limits\"));\r\n    addItem(tr(\"No constraints\"));\r\n\r\n    if (writeConstraint)\r\n    {\r\n        setCurrentIndex(writeConstraint->getType());\r\n    }\r\n\r\n    connect(this, SIGNAL(activated(int)), this, SLOT(onIndexChanged(int)), Qt::UniqueConnection);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: WriteValueConstraintComboBox::~WriteValueConstraintComboBox()\r\n//-----------------------------------------------------------------------------\r\nWriteValueConstraintComboBox::~WriteValueConstraintComboBox()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: WriteValueConstraintComboBox::setWriteValueConstraint()\r\n//-----------------------------------------------------------------------------\r\nvoid WriteValueConstraintComboBox::setWriteValueConstraint(QSharedPointer<WriteValueConstraint> constraint)\r\n{\r\n    writeConstraint_ = constraint;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: WriteValueConstraintComboBox::onIndexChanged()\r\n//-----------------------------------------------------------------------------\r\nvoid WriteValueConstraintComboBox::onIndexChanged(int newIndex)\r\n{\r\n    if (writeConstraint_)\r\n    {\r\n        writeConstraint_->setType(static_cast<WriteValueConstraint::Type>(newIndex));\r\n    }\r\n}\r\n"
  },
  {
    "path": "editors/ComponentEditor/memoryMaps/WriteValueConstraintComboBox.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: WriteValueConstraintComboBox.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Mikko Teuho\r\n// Date: 28.04.2015\r\n//\r\n// Description:\r\n// Combo box for the write value constraint of a field.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef WRITEVALUECONSTRAINTCOMBOBOX_H\r\n#define WRITEVALUECONSTRAINTCOMBOBOX_H\r\n\r\n#include <QSharedPointer>\r\n#include <QComboBox>\r\n\r\nclass WriteValueConstraint;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Combo box for the write value constraint of a field.\r\n//-----------------------------------------------------------------------------\r\nclass WriteValueConstraintComboBox : public QComboBox\r\n{\r\n    Q_OBJECT\r\n\r\npublic:\r\n\r\n    /*!\r\n\t *  The constructor.\r\n\t *\r\n\t *    @param [in] writeConstraint     Pointer to the write constraint being edited.\r\n\t *    @param [in] parent              Pointer to the owner of the group box.\r\n\t */\r\n\tWriteValueConstraintComboBox(QSharedPointer<WriteValueConstraint> writeConstraint, QWidget* parent);\r\n\r\n    /*!\r\n     *  The destructor.\r\n     */\r\n    virtual ~WriteValueConstraintComboBox();\r\n\r\n    void setWriteValueConstraint(QSharedPointer<WriteValueConstraint> constraint);\r\n   \r\n    private slots:\r\n\r\n    /*!\r\n     *  Sets the type for the write constraint.\r\n     *\r\n     *    @param [in] newIndex    The index of the selected write constraint type.\r\n     */\r\n    void onIndexChanged(int newIndex);\r\n\r\nprivate:\r\n\t\r\n\t//! No copying.\r\n    WriteValueConstraintComboBox(const WriteValueConstraintComboBox& other);\r\n\r\n\t//! No assignment.\r\n    WriteValueConstraintComboBox& operator=(const WriteValueConstraintComboBox& other);\r\n\r\n\t//! Pointer to the write constraint being edited.\r\n\tQSharedPointer<WriteValueConstraint> writeConstraint_;\r\n};\r\n\r\n#endif // WRITEVALUECONSTRAINTCOMBOBOX_H\r\n"
  },
  {
    "path": "editors/ComponentEditor/memoryMaps/addressblockdelegate.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: addressblockdelegate.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 24.08.2012\r\n//\r\n// Description:\r\n// The delegate that provides editors to add/remove/edit the details of address block.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"addressblockdelegate.h\"\r\n\r\n#include <common/widgets/booleanComboBox/booleancombobox.h>\r\n#include <common/widgets/accessComboBox/accesscombobox.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressBlockDelegate::AddressBlockDelegate()\r\n//-----------------------------------------------------------------------------\r\nAddressBlockDelegate::AddressBlockDelegate(QAbstractItemModel* completionModel,\r\n    QSharedPointer<ParameterFinder> parameterFinder, QObject *parent):\r\nExpressionDelegate(completionModel, parameterFinder, parent) \r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressBlockDelegate::~AddressBlockDelegate()\r\n//-----------------------------------------------------------------------------\r\nAddressBlockDelegate::~AddressBlockDelegate()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressBlockDelegate::createEditor()\r\n//-----------------------------------------------------------------------------\r\nQWidget* AddressBlockDelegate::createEditor(QWidget* parent, QStyleOptionViewItem const& option, \r\n    QModelIndex const& index ) const\r\n{\r\n    if (index.column() == AddressBlockColumns::VOLATILE)\r\n    {\r\n        return new BooleanComboBox(parent);\r\n    }\r\n    else if (index.column() == AddressBlockColumns::REGISTER_ACCESS)\r\n    {\r\n        return new AccessComboBox(parent);\r\n    }\r\n    else\r\n    {\r\n        return ExpressionDelegate::createEditor(parent, option, index);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressBlockDelegate::setEditorData()\r\n//-----------------------------------------------------------------------------\r\nvoid AddressBlockDelegate::setEditorData(QWidget* editor, QModelIndex const& index) const\r\n{\r\n    if (index.column() == AddressBlockColumns::VOLATILE)\r\n    {\r\n        BooleanComboBox* boolBox = qobject_cast<BooleanComboBox*>(editor);\r\n        Q_ASSERT(boolBox);\r\n\r\n        QString value = index.model()->data(index, Qt::DisplayRole).toString();\r\n        boolBox->setCurrentValue(value);\r\n    }\r\n    else if (index.column() == AddressBlockColumns::REGISTER_ACCESS)\r\n    {\r\n        AccessComboBox* accessBox = qobject_cast<AccessComboBox*>(editor);\r\n        Q_ASSERT(accessBox);\r\n\r\n        AccessTypes::Access access = AccessTypes::str2Access(\r\n            index.model()->data(index, Qt::DisplayRole).toString(), AccessTypes::ACCESS_COUNT);\r\n        accessBox->setCurrentValue(access);\r\n    }\r\n    else\r\n    {\r\n        ExpressionDelegate::setEditorData(editor, index);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressBlockDelegate::setModelData()\r\n//-----------------------------------------------------------------------------\r\nvoid AddressBlockDelegate::setModelData(QWidget* editor, QAbstractItemModel* model, QModelIndex const& index) const\r\n{\r\n    if (index.column() == AddressBlockColumns::VOLATILE)\r\n    {\r\n        BooleanComboBox* boolBox = qobject_cast<BooleanComboBox*>(editor);\r\n        Q_ASSERT(boolBox);\r\n\r\n        QString value = boolBox->getCurrentValue();\r\n        model->setData(index, value, Qt::EditRole);\r\n    }\r\n    else if (index.column() == AddressBlockColumns::REGISTER_ACCESS)\r\n    {\r\n        AccessComboBox* accessBox = qobject_cast<AccessComboBox*>(editor);\r\n        Q_ASSERT(accessBox);\r\n\r\n        AccessTypes::Access access = accessBox->getCurrentValue();\r\n        model->setData(index, AccessTypes::access2Str(access), Qt::EditRole);\r\n    }\r\n    else \r\n    {\r\n        ExpressionDelegate::setModelData(editor, model, index);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressBlockDelegate::descriptionColumn()\r\n//-----------------------------------------------------------------------------\r\nint AddressBlockDelegate::descriptionColumn() const\r\n{\r\n    return AddressBlockColumns::DESCRIPTION;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressBlockDelegate::columnAcceptsExpression()\r\n//-----------------------------------------------------------------------------\r\nbool AddressBlockDelegate::columnAcceptsExpression(int column) const\r\n{\r\n    return column == AddressBlockColumns::REGISTER_DIMENSION ||\r\n        column == AddressBlockColumns::REGISTER_SIZE ||\r\n        column == AddressBlockColumns::REGISTER_OFFSET ||\r\n        column == AddressBlockColumns::IS_PRESENT;\r\n}\r\n"
  },
  {
    "path": "editors/ComponentEditor/memoryMaps/addressblockdelegate.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: addressblockdelegate.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 24.08.2012\r\n//\r\n// Description:\r\n// The delegate that provides editors to add/remove/edit the details of address block.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef ADDRESSBLOCKDELEGATE_H\r\n#define ADDRESSBLOCKDELEGATE_H\r\n\r\n#include \"AddressBlockColumns.h\"\r\n\r\n#include <editors/ComponentEditor/common/ExpressionDelegate.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n//! The delegate that provides editors to add/remove/edit the details of address block.\r\n//-----------------------------------------------------------------------------\r\nclass AddressBlockDelegate : public ExpressionDelegate\r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\t\r\n\t/*!\r\n     *  The constructor\r\n\t *\r\n\t *    @param [in] completionModel     Model containing the completions used in expression editor.\r\n     *    @param [in] parameterFinder     The parameter finder to use for for expression editor.\r\n\t *    @param [in] parent              Pointer to the owner of this delegate.\r\n\t */\r\n\tAddressBlockDelegate(QAbstractItemModel* completionModel, QSharedPointer<ParameterFinder> parameterFinder,\r\n        QObject *parent);\r\n\t\r\n\t//! The destructor.\r\n\tvirtual ~AddressBlockDelegate();\r\n\r\n\t/*!\r\n     *  Create a new editor for the given item\r\n\t *\r\n\t *    @param [in] parent  Owner for the editor.\r\n\t *    @param [in] option  Contains options for the editor.\r\n\t *    @param [in] index   Model index identifying the item.\r\n\t *\r\n\t *    @return Pointer to the editor to be used to edit the item.\r\n\t */\r\n\tvirtual QWidget* createEditor(QWidget* parent, QStyleOptionViewItem const& option, QModelIndex const& index)\r\n        const;\r\n\r\n\t/*!\r\n     *  Set the data for the editor.\r\n\t *\r\n\t *    @param [in] editor  The editor where the data is to be set.\r\n\t *    @param [in] index   Model index identifying the item that's data is to be set.\r\n\t */\r\n\tvirtual void setEditorData(QWidget* editor, QModelIndex const& index) const;\r\n\r\n\t/*!\r\n     *  Save the data from the editor to the model.\r\n\t *\r\n\t *    @param [in] editor  The editor that contains the data to store.\r\n\t *    @param [in] model   Model that contains the data structure where data is to be saved to.\r\n\t *    @param [in] index   Model index identifying the item that's data is to be saved.\r\n\t */\r\n\tvirtual void setModelData(QWidget* editor, QAbstractItemModel* model, QModelIndex const& index) const;\r\n\r\nprotected:\r\n    \r\n    /*!\r\n     *  Checks if the given column supports expressions in the editor.\r\n     *\r\n     *    @param [in] column   The column to check.\r\n     *\r\n     *    @return True, if the cells in the column allow expressions, otherwise false.\r\n     */\r\n    virtual bool columnAcceptsExpression(int column) const;\r\n\r\n    //! Gets the description column.\r\n    virtual int descriptionColumn() const;\r\n\r\nprivate:\r\n\t\r\n\t//! No copying\r\n\tAddressBlockDelegate(const AddressBlockDelegate& other);\r\n\tAddressBlockDelegate& operator=(const AddressBlockDelegate& other);\r\n};\r\n\r\n#endif // ADDRESSBLOCKDELEGATE_H\r\n"
  },
  {
    "path": "editors/ComponentEditor/memoryMaps/addressblockeditor.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: addressblockeditor.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 24.08.2012\r\n//\r\n// Description:\r\n// Editor for editing the details of registers in an address block.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"addressblockeditor.h\"\r\n\r\n#include \"addressblockdelegate.h\"\r\n#include \"addressblockmodel.h\"\r\n#include \"ExpressionProxyModel.h\"\r\n#include \"AddressBlockColumns.h\"\r\n\r\n#include <KactusAPI/include/IPXactSystemVerilogParser.h>\r\n#include <editors/ComponentEditor/parameters/ComponentParameterModel.h>\r\n#include <KactusAPI/include/RegisterInterface.h>\r\n\r\n#include <common/views/EditableTableView/editabletableview.h>\r\n\r\n#include <KactusAPI/include/LibraryInterface.h>\r\n\r\n#include <QCompleter>\r\n#include <QVBoxLayout>\r\n#include <QHeaderView>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressBlockEditor::AddressBlockEditor()\r\n//-----------------------------------------------------------------------------\r\nAddressBlockEditor::AddressBlockEditor(QSharedPointer<QList<QSharedPointer<RegisterBase>>> registers,\r\n    RegisterInterface* registerInterface, QSharedPointer<Component> component, LibraryInterface* handler,\r\n    QSharedPointer<ParameterFinder> parameterFinder, QWidget* parent):\r\nQGroupBox(tr(\"Registers summary\"), parent),\r\nview_(new EditableTableView(this)),\r\nmodel_(0),\r\ninterface_(registerInterface),\r\nregisters_(registers)\r\n{\r\n    interface_->setRegisters(registers_);\r\n\r\n    view_->verticalHeader()->show();\r\n    view_->verticalHeader()->setMaximumWidth(300);\r\n    view_->verticalHeader()->setMinimumWidth(view_->horizontalHeader()->fontMetrics().horizontalAdvance(tr(\"Name\"))*2);\r\n    view_->verticalHeader()->setSectionResizeMode(QHeaderView::Fixed);\r\n\r\n    QSharedPointer<IPXactSystemVerilogParser> expressionParser(new IPXactSystemVerilogParser(parameterFinder));\r\n\r\n    model_ = new AddressBlockModel(registerInterface, expressionParser, parameterFinder, component->getRevision(), this);\r\n\r\n    ComponentParameterModel* componentParametersModel = new ComponentParameterModel(parameterFinder, this);\r\n    componentParametersModel->setExpressionParser(expressionParser);\r\n\r\n\r\n    ExpressionProxyModel* proxy = new ExpressionProxyModel(expressionParser, this);\r\n\r\n    proxy->setColumnToAcceptExpressions(AddressBlockColumns::REGISTER_OFFSET);\r\n    proxy->setColumnToAcceptExpressions(AddressBlockColumns::REGISTER_SIZE);\r\n    proxy->setColumnToAcceptExpressions(AddressBlockColumns::REGISTER_DIMENSION);\r\n    proxy->setColumnToAcceptExpressions(AddressBlockColumns::IS_PRESENT);\r\n\r\n    proxy->setSourceModel(model_);\r\n\tview_->setModel(proxy);\r\n\r\n\t//! Enable import/export csv file\r\n\tconst QString compPath = handler->getDirectoryPath(component->getVlnv());\r\n\tQString defPath = QString(\"%1/registerList.csv\").arg(compPath);\r\n\tview_->setDefaultImportExportPath(defPath);\r\n\tview_->setAllowImportExport(true);\r\n    view_->setAllowElementCopying(true);\r\n\tview_->setItemsDraggable(false);\r\n\tview_->setSortingEnabled(true);\r\n\r\n    view_->setItemDelegate(new AddressBlockDelegate(componentParametersModel, parameterFinder, this));\r\n\r\n    if (component->getRevision() == Document::Revision::Std22)\r\n    {\r\n        view_->hideColumn(AddressBlockColumns::IS_PRESENT);\r\n    }\r\n\r\n    connect(view_->itemDelegate(), SIGNAL(increaseReferences(QString)),\r\n        this, SIGNAL(increaseReferences(QString)), Qt::UniqueConnection);\r\n    connect(view_->itemDelegate(), SIGNAL(increaseReferences(QString)),\r\n        this, SIGNAL(increaseReferences(QString)), Qt::UniqueConnection);\r\n\r\n\tview_->sortByColumn(AddressBlockColumns::REGISTER_OFFSET, Qt::AscendingOrder);\r\n\r\n    QVBoxLayout* layout = new QVBoxLayout(this);\r\n    layout->addWidget(view_);\r\n\r\n    connect(this, SIGNAL(addressUnitBitsChanged(int)),\r\n        model_, SLOT(addressUnitBitsChanged(int)), Qt::UniqueConnection);\r\n\r\n\tconnect(model_, SIGNAL(contentChanged()), this, SIGNAL(contentChanged()), Qt::UniqueConnection);\r\n    connect(model_, SIGNAL(graphicsChanged(int)), this, SIGNAL(graphicsChanged(int)), Qt::UniqueConnection);\r\n    connect(model_, SIGNAL(childAddressingChanged(int)), \r\n        this, SIGNAL(childAddressingChanged(int)), Qt::UniqueConnection);\r\n    connect(model_, SIGNAL(errorMessage(const QString&)),\r\n        this, SIGNAL(errorMessage(const QString&)), Qt::UniqueConnection);\r\n\tconnect(model_, SIGNAL(itemAdded(int)), this, SIGNAL(childAdded(int)), Qt::UniqueConnection);\r\n\tconnect(model_, SIGNAL(itemRemoved(int)), this, SIGNAL(childRemoved(int)), Qt::UniqueConnection);\r\n\r\n    connect(model_, SIGNAL(registerNameChanged(QString const&, QString const&)),\r\n        this, SIGNAL(registerNameChanged(QString const&, QString const&)), Qt::UniqueConnection);\r\n\r\n    connect(view_, SIGNAL(addItem(const QModelIndex&)),\r\n        model_, SLOT(onAddItem(const QModelIndex&)), Qt::UniqueConnection);\r\n   \r\n\tconnect(view_, SIGNAL(removeItem(const QModelIndex&)),\r\n        model_, SLOT(onRemoveItem(const QModelIndex&)), Qt::UniqueConnection);\r\n\r\n    connect(view_->itemDelegate(), SIGNAL(increaseReferences(QString)),\r\n        this, SIGNAL(increaseReferences(QString)), Qt::UniqueConnection);\r\n    connect(view_->itemDelegate(), SIGNAL(decreaseReferences(QString)),\r\n        this, SIGNAL(decreaseReferences(QString)), Qt::UniqueConnection);\r\n\r\n    connect(model_, SIGNAL(decreaseReferences(QString)),\r\n        this, SIGNAL(decreaseReferences(QString)), Qt::UniqueConnection);\r\n\r\n    connect(model_, SIGNAL(increaseReferences(QString)),\r\n        this, SIGNAL(increaseReferences(QString)), Qt::UniqueConnection);\r\n\r\n    connect(view_, SIGNAL(copyRows(QModelIndexList)),\r\n        model_, SLOT(onCopyRows(QModelIndexList)), Qt::UniqueConnection);\r\n    connect(view_, SIGNAL(pasteRows()), model_, SLOT(onPasteRows()), Qt::UniqueConnection);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressBlockEditor::refresh()\r\n//-----------------------------------------------------------------------------\r\nvoid AddressBlockEditor::refresh()\r\n{\r\n\tview_->update();\r\n\r\n    interface_->setRegisters(registers_);\r\n}\r\n"
  },
  {
    "path": "editors/ComponentEditor/memoryMaps/addressblockeditor.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: addressblockeditor.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 24.08.2012\r\n//\r\n// Description:\r\n// Editor for editing the details of registers in an address block.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef ADDRESSBLOCKEDITOR_H\r\n#define ADDRESSBLOCKEDITOR_H\r\n\r\n#include <IPXACTmodels/Component/Component.h>\r\n#include <IPXACTmodels/Component/AddressBlock.h>\r\n\r\n#include <QSharedPointer>\r\n#include <QGroupBox>\r\n\r\nclass AddressBlockModel;\r\nclass EditableTableView;\r\nclass ExpressionFormatter;\r\nclass LibraryInterface;\r\nclass ParameterFinder;\r\nclass RegisterInterface;\r\nclass RegisterBase;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Editor for editing the details of registers in an address block.\r\n//-----------------------------------------------------------------------------\r\nclass AddressBlockEditor : public QGroupBox\r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\r\n\t/*!\r\n\t *  The constructor.\r\n\t *\r\n     *    @param [in] registers           Registers for the interface.\r\n     *    @param [in] registerInterface   Interface for registers.\r\n\t *    @param [in] component           The component being edited.\r\n\t *    @param [in] handler             The instance managing the library.\r\n\t *    @param [in] parameterFinder     The parameter finder.\r\n\t *    @param [in] parent              The parent of this editor.\r\n\t */\r\n    AddressBlockEditor(QSharedPointer<QList<QSharedPointer<RegisterBase> > > registers,\r\n        RegisterInterface* registerInterface, QSharedPointer<Component> component,\r\n        LibraryInterface* handler, QSharedPointer<ParameterFinder> parameterFinder, QWidget* parent = 0);\r\n\r\n\t//! The destructor.\r\n\tvirtual ~AddressBlockEditor() = default;\r\n\r\n    //! No copying.\r\n    AddressBlockEditor(const AddressBlockEditor& other) = delete;\r\n\r\n    //! No assignment.\r\n    AddressBlockEditor& operator=(const AddressBlockEditor& other) = delete;\r\n\r\n\t/*!\r\n     *  Reload the information from the model to the editor.\r\n\t */\r\n\tvirtual void refresh();\r\n\r\nsignals:\r\n\r\n    /*\r\n     *  Informs of register name change.\r\n     *\r\n     *    @param [in] oldName     The old name.\r\n     *    @param [in] newName     The new name.\r\n     */\r\n    void registerNameChanged(QString const& oldName, QString const& newName);\r\n\r\n    /*!\r\n     *  Change the value for address unit bits in the model.\r\n     *\r\n     *    @param [in] newAddressUnitBits  The new address unit bits value.\r\n     */\r\n    void addressUnitBitsChanged(int newAddressUnitBits);\r\n\r\n    /*!\r\n     *  Informs that the contents of the editor have changed.\r\n     */\r\n    void contentChanged();\r\n\r\n    /*!\r\n     *  Informs of a need to redraw the visualizer.\r\n     */\r\n    void graphicsChanged(int);\r\n\r\n    /*!\r\n     *  Sends an error message forward.\r\n     *\r\n     *    @param [in] msg     The error message.\r\n     */\r\n    void errorMessage(const QString& msg) const;\r\n\r\n    /*!\r\n     *  Sends a notification message forward.\r\n     *\r\n     *    @param [in] msg     The notification message.\r\n     */\r\n    void noticeMessage(const QString& msg) const;\r\n\r\n    /*!\r\n     *  Increase the amount of references made to the given parameter.\r\n     *\r\n     *    @param [in] id  The id of the given parameter.\r\n     */\r\n    void increaseReferences(QString id) const;\r\n\r\n    /*!\r\n     *  Decrease the amount of references made to the given parameter.\r\n     *\r\n     *    @param [in] id  The id the given parameter.\r\n     */\r\n    void decreaseReferences(QString id) const;\r\n\r\n    /*!\r\n     *  Informs that a new item has been created.\r\n     *\r\n     *    @param [in] index   The index of the new item.\r\n     */\r\n    void childAdded(int index);\r\n\r\n    /*!\r\n     *  Informs that an item has been removed.\r\n     *\r\n     *    @param [in] index   The index of the removed item.\r\n     */\r\n    void childRemoved(int index);\r\n\r\n    /*!\r\n     *  Informs of a change in item addressing.\r\n     *\r\n     *    @param [in] index   Index of the item whose addressing is changed.\r\n     */\r\n    void childAddressingChanged(int index);\r\n\r\nprivate:\r\n\t\r\n\r\n\t//! The view to display the items.\r\n    EditableTableView* view_;\r\n\r\n\t//! The model that manages the details of address block.\r\n\tAddressBlockModel* model_;\r\n\r\n    //! Interface for accessing registers.\r\n    RegisterInterface* interface_;\r\n\r\n    //! Pointer to the registers for the interface.\r\n    QSharedPointer<QList<QSharedPointer<RegisterBase> > > registers_;\r\n};\r\n\r\n#endif // ADDRESSBLOCKEDITOR_H\r\n"
  },
  {
    "path": "editors/ComponentEditor/memoryMaps/addressblockmodel.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: addressblockmodel.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 24.08.2012\r\n//\r\n// Description:\r\n// The model to manage the registers of a single address block or register file.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"addressblockmodel.h\"\r\n\r\n#include <editors/ComponentEditor/memoryMaps/AddressBlockColumns.h>\r\n#include <KactusAPI/include/RegisterInterface.h>\r\n#include <editors/ComponentEditor/memoryMaps/memoryMapsExpressionCalculators/ReferenceCalculator.h>\r\n\r\n#include <common/KactusColors.h>\r\n\r\n#include <QRegularExpression>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressBlockModel::AddressBlockModel()\r\n//-----------------------------------------------------------------------------\r\nAddressBlockModel::AddressBlockModel(RegisterInterface* registerInterface,\r\n    QSharedPointer<ExpressionParser> expressionParser, QSharedPointer<ParameterFinder> parameterFinder,\r\n    Document::Revision docRevision, QObject *parent):\r\nReferencingTableModel(parameterFinder, parent),\r\nParameterizableTable(parameterFinder),\r\nregisterInterface_(registerInterface),\r\naccessPolicyInterface_(registerInterface->getAccessPolicyInterface()),\r\ndocRevision_(docRevision)\r\n{\r\n    setExpressionParser(expressionParser);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressBlockModel::rowCount()\r\n//-----------------------------------------------------------------------------\r\nint AddressBlockModel::rowCount(QModelIndex const& parent) const\r\n{\r\n    if (parent.isValid())\r\n    {\r\n        return 0;\r\n    }\r\n\r\n    return registerInterface_->itemCount();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressBlockModel::columnCount()\r\n//-----------------------------------------------------------------------------\r\nint AddressBlockModel::columnCount(QModelIndex const& parent) const\r\n{\r\n    if (parent.isValid())\r\n    {\r\n        return 0;\r\n    }\r\n\r\n    return AddressBlockColumns::COLUMN_COUNT;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressBlockModel::flags()\r\n//-----------------------------------------------------------------------------\r\nQt::ItemFlags AddressBlockModel::flags(QModelIndex const& index) const\r\n{\r\n    if (!index.isValid())\r\n    {\r\n        return Qt::NoItemFlags;\r\n    }\r\n\r\n    // Indicate that cell can be colored gray if register has multiple access policies\r\n    if (index.column() == AddressBlockColumns::REGISTER_ACCESS &&\r\n        registerInterface_->getAccessPolicyCount(\r\n            registerInterface_->getIndexedItemName(index.row())) > 1)\r\n    {\r\n        return Qt::ItemIsSelectable | Qt::ItemIsEnabled;\r\n    }\r\n\r\n    return Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsEditable;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: addressblockmodel::headerData()\r\n//-----------------------------------------------------------------------------\r\nQVariant AddressBlockModel::headerData( int section, Qt::Orientation orientation, int role) const\r\n{\r\n    if (orientation == Qt::Vertical && role == Qt::DisplayRole)\r\n    {\r\n        return QString::fromStdString(registerInterface_->getIndexedItemName(section));\r\n    }\r\n\r\n    else if (orientation == Qt::Horizontal && role == Qt::DisplayRole)\r\n    {\r\n        if (section == AddressBlockColumns::NAME)\r\n        {\r\n            return tr(\"Register\\nname\");\r\n        }\r\n        else if (section == AddressBlockColumns::REGISTER_OFFSET)\r\n        {\r\n            return tr(\"Offset\\n[AUB]\") + getExpressionSymbol();\r\n        }\r\n        else if (section == AddressBlockColumns::REGISTER_SIZE)\r\n        {\r\n            return tr(\"Size\\n[bits]\") + getExpressionSymbol();\r\n        }\r\n        else if (section == AddressBlockColumns::REGISTER_DIMENSION)\r\n        {\r\n            return tr(\"Dimension\") + getExpressionSymbol();\r\n        }\r\n        else if (section == AddressBlockColumns::DESCRIPTION)\r\n        {\r\n            return tr(\"Description\");\r\n        }\r\n        else if (section == AddressBlockColumns::VOLATILE)\r\n        {\r\n            return tr(\"Volatile\");\r\n        }\r\n        else if (section == AddressBlockColumns::REGISTER_ACCESS)\r\n        {\r\n            return tr(\"Access\");\r\n        }\r\n        else if (section == AddressBlockColumns::IS_PRESENT)\r\n        {\r\n            return tr(\"Is present\") + getExpressionSymbol();\r\n        }\r\n        else\r\n        {\r\n            return QVariant();\r\n        }\r\n    }\r\n\r\n    return QVariant();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: addressblockmodel::data()\r\n//-----------------------------------------------------------------------------\r\nQVariant AddressBlockModel::data(QModelIndex const& index, int role) const\r\n{\r\n    if (!index.isValid() || index.row() < 0 || index.row() >= registerInterface_->itemCount())\r\n    {\r\n        return QVariant();\r\n    }\r\n\r\n    std::string registerName = registerInterface_->getIndexedItemName(index.row());\r\n\r\n    if (role == Qt::DisplayRole)\r\n    {\r\n        if (isValidExpressionColumn(index))\r\n        {\r\n            return formattedExpressionForIndex(index);\r\n        }\r\n        else if (index.column() == AddressBlockColumns::DESCRIPTION)\r\n        {\r\n            return valueForIndex(index).toString().replace(QRegularExpression(\"\\n.*$\",\r\n                QRegularExpression::DotMatchesEverythingOption), \"...\");\r\n        }\r\n        else\r\n        {\r\n            return valueForIndex(index);\r\n        }\r\n    }\r\n\r\n    else if (role == Qt::EditRole)\r\n    {\r\n        return expressionOrValueForIndex(index);\r\n    }\r\n\r\n    else if (role == Qt::ToolTipRole)\r\n    {\r\n        return valueForIndex(index);\r\n    }\r\n    else if (role == Qt::ForegroundRole)\r\n    {\r\n        if (validateIndex(index))\r\n        {\r\n            std::string registerPresence = registerInterface_->getIsPresentExpression(registerName);\r\n            qint64 registerPresenceValue =\r\n                QString::fromStdString(registerInterface_->getIsPresentValue(registerName, 10)).toLongLong();\r\n\r\n            if (index.column() != AddressBlockColumns::IS_PRESENT && \r\n                (!registerPresence.empty() && registerPresenceValue == 0))\r\n            {\r\n                return KactusColors::DISABLED_TEXT;\r\n            }\r\n            else\r\n            {\r\n                return KactusColors::REGULAR_TEXT;\r\n            }\r\n        }\r\n        else\r\n        {\r\n            return KactusColors::ERROR;\r\n        }\r\n    }\r\n    else if (role == Qt::BackgroundRole)\r\n    {\r\n        if (index.flags() == (Qt::ItemIsEnabled | Qt::ItemIsSelectable) &&\r\n            index.column() == AddressBlockColumns::REGISTER_ACCESS)\r\n        {\r\n            return KactusColors::DISABLED_FIELD;\r\n        }\r\n\r\n        if (index.column() == AddressBlockColumns::NAME ||\r\n            index.column() == AddressBlockColumns::REGISTER_OFFSET ||\r\n            index.column() == AddressBlockColumns::REGISTER_SIZE)\r\n        {\r\n            return KactusColors::MANDATORY_FIELD;\r\n        }\r\n        else\r\n        {\r\n            return KactusColors::REGULAR_FIELD;\r\n        }\r\n    }\r\n    else if (role == Qt::FontRole)\r\n    {\r\n        return italicForEvaluatedValue(index);\r\n    }\r\n\r\n    return QVariant();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: addressblockmodel::formattedExpressionForIndex()\r\n//-----------------------------------------------------------------------------\r\nQVariant AddressBlockModel::formattedExpressionForIndex(QModelIndex const& index) const\r\n{\r\n    std::string registerName = registerInterface_->getIndexedItemName(index.row());\r\n    if (index.column() == AddressBlockColumns::REGISTER_OFFSET)\r\n    {\r\n        return QString::fromStdString(registerInterface_->getOffsetFormattedExpression(registerName));\r\n    }\r\n    else if (index.column() == AddressBlockColumns::REGISTER_DIMENSION)\r\n    {\r\n        return QString::fromStdString(registerInterface_->getDimensionFormattedExpression(registerName));\r\n    }\r\n    else if (index.column() == AddressBlockColumns::IS_PRESENT)\r\n    {\r\n        return QString::fromStdString(registerInterface_->getIsPresentFormattedExpression(registerName));\r\n    }\r\n    else if (index.column() == AddressBlockColumns::REGISTER_SIZE)\r\n    {\r\n        return QString::fromStdString(registerInterface_->getSizeFormattedExpression(registerName));\r\n    }\r\n\r\n    return QVariant();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: addressblockmodel::expressionForIndex()\r\n//-----------------------------------------------------------------------------\r\nQVariant AddressBlockModel::expressionForIndex(QModelIndex const& index) const\r\n{\r\n    std::string registerName = registerInterface_->getIndexedItemName(index.row());\r\n    if (index.column() == AddressBlockColumns::REGISTER_OFFSET)\r\n    {\r\n        return QString::fromStdString(registerInterface_->getOffsetExpression(registerName));\r\n    }\r\n    else if (index.column() == AddressBlockColumns::REGISTER_DIMENSION)\r\n    {\r\n        return QString::fromStdString(registerInterface_->getDimensionExpression(registerName));\r\n    }\r\n    else if (index.column() == AddressBlockColumns::IS_PRESENT)\r\n    {\r\n        return QString::fromStdString(registerInterface_->getIsPresentExpression(registerName));\r\n    }\r\n    else if (index.column() == AddressBlockColumns::REGISTER_SIZE)\r\n    {\r\n        return QString::fromStdString(registerInterface_->getSizeExpression(registerName));\r\n    }\r\n\r\n    return QVariant();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: addressblockmodel::valueForIndex()\r\n//-----------------------------------------------------------------------------\r\nQVariant AddressBlockModel::valueForIndex(QModelIndex const& index) const\r\n{\r\n    std::string registerName = registerInterface_->getIndexedItemName(index.row());\r\n\r\n    if (index.column() == AddressBlockColumns::NAME)\r\n    {\r\n        return QString::fromStdString(registerName);\r\n    }\r\n    else if (index.column() == AddressBlockColumns::REGISTER_OFFSET)\r\n    {\r\n        return QString::fromStdString(registerInterface_->getOffsetValue(registerName));\r\n    }\r\n    else if (index.column() == AddressBlockColumns::REGISTER_DIMENSION)\r\n    {\r\n        return QString::fromStdString(registerInterface_->getDimensionValue(registerName));\r\n    }\r\n    else if (index.column() == AddressBlockColumns::DESCRIPTION)\r\n    {\r\n        return QString::fromStdString(registerInterface_->getDescription(registerName));\r\n    }\r\n    else if (index.column() == AddressBlockColumns::IS_PRESENT)\r\n    {\r\n        return QString::fromStdString(registerInterface_->getIsPresentValue(registerName));\r\n    }\r\n    else if (index.column() == AddressBlockColumns::REGISTER_SIZE)\r\n    {\r\n        return QString::fromStdString(registerInterface_->getSizeValue(registerName));\r\n    }\r\n    else if (index.column() == AddressBlockColumns::VOLATILE)\r\n    {\r\n        return QString::fromStdString(registerInterface_->getVolatile(registerName));\r\n    }\r\n    else if (index.column() == AddressBlockColumns::REGISTER_ACCESS)\r\n    {\r\n        if (docRevision_ == Document::Revision::Std22)\r\n        {\r\n            if (index.flags() == (Qt::ItemIsEnabled | Qt::ItemIsSelectable))\r\n            {\r\n                return QStringLiteral(\"[multiple]\");\r\n            }\r\n\r\n            return QString::fromStdString(registerInterface_->getAccessString(registerName, true));\r\n        }\r\n\r\n        return QString::fromStdString(registerInterface_->getAccessString(registerName));\r\n    }\r\n\r\n    return QVariant();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressBlockModel::expressionOrValueForIndex()\r\n//-----------------------------------------------------------------------------\r\nQVariant AddressBlockModel::expressionOrValueForIndex(QModelIndex const& index) const\r\n{\r\n    if (isValidExpressionColumn(index))\r\n    {\r\n        return expressionForIndex(index);\r\n    }\r\n    else\r\n    {\r\n        return valueForIndex(index);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: addressblockmodel::setData()\r\n//-----------------------------------------------------------------------------\r\nbool AddressBlockModel::setData(QModelIndex const& index, QVariant const& value, int role)\r\n{\r\n    if (!index.isValid() || index.row() < 0 || index.row() >= registerInterface_->itemCount())\r\n    {\r\n        return false;\r\n    }\r\n\r\n    if (role == Qt::EditRole)\r\n    {\r\n        bool changed = true;\r\n\r\n        std::string registerName = registerInterface_->getIndexedItemName(index.row());\r\n        if (index.column() == AddressBlockColumns::NAME)\r\n        {\r\n            registerInterface_->setName(registerName, value.toString().toStdString());\r\n\r\n            QString oldName = QString::fromStdString(registerName);\r\n            QString newName = QString::fromStdString(registerInterface_->getIndexedItemName(index.row()));\r\n\r\n            emit registerNameChanged(oldName, newName);\r\n\r\n            emit headerDataChanged(Qt::Vertical, index.row(), index.row());\r\n        }\r\n        else if (index.column() == AddressBlockColumns::REGISTER_OFFSET)\r\n        {\r\n            if (!value.isValid())\r\n            {\r\n                removeReferencesFromSingleExpression(\r\n                    QString::fromStdString(registerInterface_->getOffsetExpression(registerName)));\r\n            }\r\n\r\n            registerInterface_->setOffset(registerName, value.toString().toStdString());\r\n        }\r\n        else if (index.column() == AddressBlockColumns::REGISTER_DIMENSION)\r\n        {\r\n            if (!value.isValid())\r\n            {\r\n                removeReferencesFromSingleExpression(\r\n                    QString::fromStdString(registerInterface_->getDimensionExpression(registerName)));\r\n            }\r\n\r\n            registerInterface_->setDimension(registerName, value.toString().toStdString());\r\n        }\r\n        else if (index.column() == AddressBlockColumns::DESCRIPTION)\r\n        {\r\n            registerInterface_->setDescription(registerName, value.toString().toStdString());\r\n        }\r\n        else if (index.column() == AddressBlockColumns::IS_PRESENT)\r\n        {\r\n            if (!value.isValid())\r\n            {\r\n                removeReferencesFromSingleExpression(\r\n                    QString::fromStdString(registerInterface_->getIsPresentExpression(registerName)));\r\n            }\r\n\r\n            registerInterface_->setIsPresent(registerName, value.toString().toStdString());\r\n        }\r\n        else if (index.column() == AddressBlockColumns::REGISTER_SIZE)\r\n        {\r\n            if (!value.isValid())\r\n            {\r\n                removeReferencesFromSingleExpression(\r\n                    QString::fromStdString(registerInterface_->getSizeExpression(registerName)));\r\n            }\r\n\r\n            registerInterface_->setSize(registerName, value.toString().toStdString());\r\n        }\r\n        else if (index.column() == AddressBlockColumns::VOLATILE)\r\n        {\r\n            registerInterface_->setVolatile(registerName, value.toString().toStdString());\r\n        }\r\n        else if (index.column() == AddressBlockColumns::REGISTER_ACCESS)\r\n        {\r\n            // Modify the access of the register block by default.\r\n            bool setAccessPolicyAccess = false;\r\n\r\n            if (docRevision_ == Document::Revision::Std22)\r\n            {\r\n                // Create access policy first, if one doesn't exist.\r\n                if (registerInterface_->getAccessPolicyCount(registerName) == 0 &&\r\n                    value.toString().isEmpty() == false)\r\n                {\r\n                    registerInterface_->addAccessPolicy(registerName);\r\n                }\r\n\r\n                // Modify first access policy, if std22.\r\n                setAccessPolicyAccess = true;\r\n            }\r\n\r\n            registerInterface_->setAccess(registerName, value.toString().toStdString(), setAccessPolicyAccess);\r\n        }\r\n        else\r\n        {\r\n            changed = false;\r\n        }\r\n\r\n        if (changed)\r\n        {\r\n            if (index.column() == AddressBlockColumns::NAME ||\r\n                index.column() == AddressBlockColumns::REGISTER_OFFSET ||\r\n                index.column() == AddressBlockColumns::REGISTER_SIZE ||\r\n                index.column() == AddressBlockColumns::REGISTER_DIMENSION ||\r\n                index.column() == AddressBlockColumns::IS_PRESENT)\r\n            {\r\n                emit graphicsChanged(index.row());\r\n                if (index.column() != AddressBlockColumns::NAME)\r\n                {\r\n                    emit childAddressingChanged(index.row());\r\n                }\r\n            }\r\n\r\n            emit dataChanged(index, index);\r\n            emit contentChanged();\r\n            return true;\r\n        }\r\n    }\r\n\r\n    return false;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressBlockModel::mimeTypes()\r\n//-----------------------------------------------------------------------------\r\nQStringList AddressBlockModel::mimeTypes() const\r\n{\r\n    QStringList types(QAbstractItemModel::mimeTypes());\r\n\r\n    types << \"text/xml/ipxact:register\";\r\n\r\n    return types;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressBlockModel::isValidExpressionColumn()\r\n//-----------------------------------------------------------------------------\r\nbool AddressBlockModel::isValidExpressionColumn(QModelIndex const& index) const\r\n{\r\n    return index.column() == AddressBlockColumns::REGISTER_DIMENSION ||\r\n        index.column() == AddressBlockColumns::REGISTER_SIZE ||\r\n        index.column() == AddressBlockColumns::REGISTER_OFFSET ||\r\n        index.column() == AddressBlockColumns::IS_PRESENT;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressBlockModel::validateIndex()\r\n//-----------------------------------------------------------------------------\r\nbool AddressBlockModel::validateIndex(QModelIndex const& index) const\r\n{\r\n    std::string registerName = registerInterface_->getIndexedItemName(index.row());\r\n\r\n    if (index.column() == AddressBlockColumns::NAME)\r\n    {\r\n        return registerInterface_->itemHasValidName(registerName);\r\n    }\r\n    else if (index.column() == AddressBlockColumns::REGISTER_DIMENSION)\r\n    {\r\n        return registerInterface_->hasValidDimension(registerName);\r\n    }\r\n\r\n    else if (index.column() == AddressBlockColumns::REGISTER_OFFSET)\r\n    {\r\n        return registerInterface_->hasValidOffset(registerName);\r\n    }\r\n\r\n    else if (index.column() == AddressBlockColumns::IS_PRESENT)\r\n    {\r\n        return registerInterface_->hasValidIsPresent(registerName);\r\n    }\r\n\r\n    else if (index.column() == AddressBlockColumns::REGISTER_SIZE)\r\n    {\r\n        return registerInterface_->hasValidSize(registerName);\r\n    }\r\n\r\n    return true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressBlockModel::getAllReferencesToIdInItemOnRow()\r\n//-----------------------------------------------------------------------------\r\nint AddressBlockModel::getAllReferencesToIdInItemOnRow(const int& row, QString const& valueID) const\r\n{\r\n    return registerInterface_->getAllReferencesToIdInItem(\r\n        registerInterface_->getIndexedItemName(row), valueID.toStdString());\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressBlockModel::onAddItem()\r\n//-----------------------------------------------------------------------------\r\nvoid AddressBlockModel::onAddItem(QModelIndex const& index)\r\n{\r\n    int row = registerInterface_->itemCount();\r\n    if (index.isValid())\r\n    {\r\n        row = index.row();\r\n    }\r\n\r\n    int dataIndex = registerInterface_->indexInRegisterData(row);\r\n\r\n    beginInsertRows(QModelIndex(), row, row);\r\n\r\n    registerInterface_->addRegister(row, dataIndex);\r\n\r\n\r\n    endInsertRows();\r\n\r\n    // inform navigation tree that file set is added\r\n    emit itemAdded(dataIndex);\r\n\r\n    // tell also parent widget that contents have been changed\r\n    emit contentChanged();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressBlockModel::onRemoveItem()\r\n//-----------------------------------------------------------------------------\r\nvoid AddressBlockModel::onRemoveItem(QModelIndex const& index )\r\n{\r\n    // don't remove anything if index is invalid\r\n    int dataIndex = registerInterface_->indexInRegisterData(index.row());\r\n    if (!index.isValid() || index.row() < 0 || index.row() >= registerInterface_->itemCount() || dataIndex < 0)\r\n    {\r\n        return;\r\n    }\r\n\r\n    std::string removedRegisterName = registerInterface_->getIndexedItemName(index.row());\r\n\r\n    // remove the specified item\r\n    beginRemoveRows(QModelIndex(), index.row(), index.row());\r\n\r\n    decreaseReferencesWithRemovedRegister(QString::fromStdString(removedRegisterName));\r\n    registerInterface_->removeRegister(removedRegisterName, dataIndex);\r\n\r\n    endRemoveRows();\r\n\r\n    // inform navigation tree that file set has been removed\r\n    emit itemRemoved(dataIndex);\r\n\r\n    // tell also parent widget that contents have been changed\r\n    emit contentChanged();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressBlockModel::decreaseReferencesWithRemovedRegister()\r\n//-----------------------------------------------------------------------------\r\nvoid AddressBlockModel::decreaseReferencesWithRemovedRegister(QString const& registerName)\r\n{\r\n    QMap<QString, int> referencedParameters = getReferencedParameters(registerName);\r\n\r\n    foreach(QString referencedId, referencedParameters.keys())\r\n    {\r\n        for (int i = 0; i < referencedParameters.value(referencedId); ++i)\r\n        {\r\n            emit decreaseReferences(referencedId);\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressBlockModel::getReferencedParameters()\r\n//-----------------------------------------------------------------------------\r\nQMap<QString, int> AddressBlockModel::getReferencedParameters(QString const& registerName) const\r\n{\r\n    std::vector<std::string> registerNameList;\r\n    registerNameList.push_back(registerName.toStdString());\r\n\r\n    auto expressionList = registerInterface_->getExpressionsInSelectedRegisters(registerNameList);\r\n    QStringList expressionListQT;\r\n    for (auto expression : expressionList)\r\n    {\r\n        expressionListQT.append(QString::fromStdString(expression));\r\n    }\r\n\r\n    ReferenceCalculator refCalculator(getParameterFinder());\r\n\r\n    return refCalculator.getReferencedParameters(expressionListQT);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressBlockModel::addressUnitBitsChanged()\r\n//-----------------------------------------------------------------------------\r\nvoid AddressBlockModel::addressUnitBitsChanged(int newAddressUnitbits)\r\n{\r\n    registerInterface_->setAddressUnitBits(newAddressUnitbits);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressBlockModel::onCopyRows()\r\n//-----------------------------------------------------------------------------\r\nvoid AddressBlockModel::onCopyRows(QModelIndexList indexList)\r\n{\r\n    std::vector<int> registerIndexes;\r\n    for (auto index : indexList)\r\n    {\r\n        registerIndexes.push_back(index.row());\r\n    }\r\n\r\n    registerInterface_->copyRows(registerIndexes);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressBlockModel::onPasteRows()\r\n//-----------------------------------------------------------------------------\r\nvoid AddressBlockModel::onPasteRows()\r\n{\r\n    int pastedRegisterCount = registerInterface_->getPasteRowCount();\r\n    if (pastedRegisterCount == 0)\r\n    {\r\n        return;\r\n    }\r\n\r\n    int rowBegin = registerInterface_->itemCount();\r\n    int rowEnd = rowBegin + pastedRegisterCount - 1;\r\n    \r\n    beginInsertRows(QModelIndex(), rowBegin, rowEnd);\r\n\r\n    registerInterface_->pasteRows();\r\n\r\n    for (int i = rowBegin; i <= rowEnd; ++i)\r\n    {\r\n        emit itemAdded(i);\r\n        increaseReferencesInPastedRegister(QString::fromStdString(registerInterface_->getIndexedItemName(i)));\r\n    }\r\n\r\n    endInsertRows();\r\n\r\n    emit contentChanged();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressBlockModel::increaseReferencesInPastedRegister()\r\n//-----------------------------------------------------------------------------\r\nvoid AddressBlockModel::increaseReferencesInPastedRegister(QString const& registerName)\r\n{\r\n    QMap<QString, int> referencedParameters = getReferencedParameters(registerName);\r\n\r\n    QMapIterator<QString, int> refParameterIterator(referencedParameters);\r\n    while (refParameterIterator.hasNext())\r\n    {\r\n        refParameterIterator.next();\r\n        for (int i = 0; i < refParameterIterator.value(); ++i)\r\n        {\r\n            emit increaseReferences(refParameterIterator.key());\r\n        }\r\n    }\r\n}\r\n"
  },
  {
    "path": "editors/ComponentEditor/memoryMaps/addressblockmodel.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: addressblockmodel.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 24.08.2012\r\n//\r\n// Description:\r\n// The model to manage the registers of a single address block or register file.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef ADDRESSBLOCKMODEL_H\r\n#define ADDRESSBLOCKMODEL_H\r\n\r\n#include <IPXACTmodels/Component/AddressBlock.h>\r\n#include <IPXACTmodels/common/Document.h>\r\n\r\n#include <editors/ComponentEditor/common/ParameterizableTable.h>\r\n#include <editors/ComponentEditor/common/ReferencingTableModel.h>\r\n#include <KactusAPI/include/ParameterFinder.h>\r\n\r\n#include <QSharedPointer>\r\n\r\nclass RegisterInterface;\r\nclass AccessPolicyInterface;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! The model to manage the registers of a single address block or register file.\r\n//-----------------------------------------------------------------------------\r\nclass AddressBlockModel : public ReferencingTableModel, public ParameterizableTable\r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\r\n\t/*!\r\n\t *  The constructor.\r\n     *\r\n     *    @param [in] registerInterface   Interface for registers.\r\n\t *    @param [in] expressionParser    The expression parser.\r\n     *    @param [in] parameterFinder     The parameter finder.\r\n\t *    @param [in] parent              The owner of the model.\r\n\t */\r\n    AddressBlockModel(RegisterInterface* registerInterface,\r\n        QSharedPointer<ExpressionParser> expressionParser,\r\n        QSharedPointer<ParameterFinder> parameterFinder,\r\n        Document::Revision docRevision,\r\n        QObject *parent);\r\n\r\n\t/*!\r\n     *  The destructor.\r\n     */\r\n\tvirtual ~AddressBlockModel() = default;\r\n\r\n\t/*!\r\n     *  Get the number of rows an item contains.\r\n\t *\r\n\t *    @param [in] parent  Identifies the parent that's row count is requested.\r\n\t *\r\n\t *    @return Number of rows the item has.\r\n\t */\r\n\tvirtual int rowCount(const QModelIndex& parent = QModelIndex()) const;\r\n\r\n\t/*!\r\n     *  Get the number of displayed columns.\r\n\t *\r\n\t *    @param [in] parent  Identifies the parent that's column count is requested.\r\n\t *\r\n\t *    @return The number of columns to be displayed.\r\n\t */\r\n\tvirtual int columnCount(const QModelIndex& parent = QModelIndex()) const;\r\n\r\n\t/*!\r\n     *  Get the item flags that defines the possible operations for the item.\r\n\t *\r\n\t *    @param [in] index   Model index that identifies the item.\r\n\t *\r\n\t *    @return Qt::ItemFlags specify the possible operations for the item.\r\n\t */\r\n\tQt::ItemFlags flags(const QModelIndex& index) const;\r\n\r\n\t/*!\r\n     *  Get the header data for specified header.\r\n\t *\r\n\t *    @param [in] section         The section specifies the row/column number for the header.\r\n\t *    @param [in] orientation     Specified if horizontal or vertical header is wanted.\r\n\t *    @param [in] role            Specifies the type of the requested data.\r\n\t *\r\n\t *    @return QVariant Contains the requested data.\r\n\t */\r\n\tvirtual QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;\r\n\r\n\t/*!\r\n     *  Get the data for specified item.\r\n\t *\r\n\t *    @param [in] index   Specifies the item that's data is requested.\r\n\t *    @param [in] role    The role that defines what kind of data is requested.\r\n\t *\r\n\t *    @return QVariant Contains the data for the item.\r\n\t */\r\n\tvirtual QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const;\r\n\r\n\t/*!\r\n     *  Save the data to the model for specified item.\r\n\t *\r\n\t *    @param [in] index   The model index of the item that's data is to be saved.\r\n\t *    @param [in] value   The data that is to be saved.\r\n\t *    @param [in] role    The role specifies what kind of data should be saved.\r\n\t *\r\n\t *    @return True if saving happened successfully.\r\n\t */\r\n\tbool setData(const QModelIndex& index, const QVariant& value, int role = Qt::EditRole);\r\n\r\n    /*!\r\n     *  Get the list of acceptable mime types.\r\n     *\r\n     *    @return The list of acceptable mime types.\r\n     */\r\n    virtual QStringList mimeTypes() const;\r\n\r\nprotected:\r\n\r\n    /*!\r\n     *  Check if the column is valid for containing expressions.\r\n     *\r\n     *    @param [in] index   The index of the column.\r\n     *\r\n     *    @return     True, if the column is valid for expressions, otherwise false.\r\n     */\r\n    virtual bool isValidExpressionColumn(QModelIndex const& index) const;\r\n\r\n    /*!\r\n     *  Gets the expression for the given index, or plain value if there is no expression.\r\n     *\r\n     *    @param [in] index   The index of target data.\r\n     *\r\n     *    @return     Expression or plain value for the given index.\r\n     */\r\n    virtual QVariant expressionOrValueForIndex(QModelIndex const& index) const;\r\n\r\n    /*!\r\n     *  Validates the data in the index.\r\n     *\r\n     *    @param [in] index   The index of target data.\r\n     *\r\n     *    @return     True, if the data is valid, otherwise false.\r\n     */\r\n    virtual bool validateIndex(QModelIndex const& index) const;\r\n\r\n    /*!\r\n     *  Gets all the references to the selected id from the selected register.\r\n     *\r\n     *    @param [in] row         The row of the selected register.\r\n     *    @param [in] valueID     The id of the referenced parameter.\r\n     *\r\n     *    @return The amount of references made to the target parameter.\r\n     */\r\n    virtual int getAllReferencesToIdInItemOnRow(const int& row, QString const& valueID) const;\r\n\r\npublic slots:\r\n\r\n\t/*!\r\n     *  Add a new item to the given index.\r\n\t *\r\n\t *    @param [in] index   The index identifying the position for new item.\r\n\t */\r\n    virtual void onAddItem(const QModelIndex& index);\r\n\r\n\t/*!\r\n     *  Remove the item in the given index.\r\n\t *\r\n\t *    @param [in] index   The index identifying the item to remove.\r\n\t */\r\n\tvirtual void onRemoveItem(const QModelIndex& index);\r\n\r\n    /*!\r\n     *  Change the value for address unit bits.\r\n     *\r\n     *    @param [in] newAddressUnitbits  The new value for address unit bits.\r\n     */\r\n    void addressUnitBitsChanged(int newAddressUnitbits);\r\n\r\n    /*!\r\n     *  Copy the items in the selected rows.\r\n     *\r\n     *    @param [in] indexList   List of indexes pointing to the selected rows.\r\n     */\r\n    void onCopyRows(QModelIndexList indexList);\r\n\r\n    /*!\r\n     *  Paste the copied items.\r\n     */\r\n    void onPasteRows();\r\n\r\nsignals:\r\n\r\n\t//! Emitted when the contents of the model change.\r\n\tvoid contentChanged();\r\n\r\n    /*!\r\n     *  Informs of a need to redraw the visualizer.\r\n     */\r\n    void graphicsChanged(int index);\r\n\r\n    void childAddressingChanged(int index);\r\n\r\n    //! Prints an error message to the user.\r\n    void errorMessage(const QString& msg) const;\r\n\r\n\t//! Emitted when a new register item is added to the given index.\r\n\tvoid itemAdded(int index);\r\n\r\n\t//! Emitted when a register item is removed from the given index.\r\n\tvoid itemRemoved(int index);\r\n\r\n    /*\r\n     *  Informs of register name change.\r\n     *\r\n     *    @param [in] oldName     The old name.\r\n     *    @param [in] newName     The new name.\r\n     */\r\n    void registerNameChanged(QString const& oldName, QString const& newName);\r\n\r\nprivate:\r\n\r\n\t//! No copying.\r\n\tAddressBlockModel(const AddressBlockModel& other);\r\n\r\n\t//! No assignment.\r\n\tAddressBlockModel& operator=(const AddressBlockModel& other);\r\n\r\n    /*!\r\n     *  Add a register.\r\n     *\r\n     *    @param [in] regItem     The new register.\r\n     *    @param [in] index       Index of the new register.\r\n     */\r\n    void onAddItem(QSharedPointer<RegisterBase> regItem, QModelIndex const& index);\r\n\r\n    /*!\r\n     *  Get the formatted value of an expression in the selected index.\r\n     *\r\n     *    @param [in] index   The selected index.\r\n     *\r\n     *    @return The formatted value of an expression in the selected index.\r\n     */\r\n    virtual QVariant formattedExpressionForIndex(QModelIndex const& index) const;\r\n\r\n    /*!\r\n     *  Get the expression of the selected index.\r\n     *\r\n     *    @param [in] index   The selected index.\r\n     *\r\n     *    @return The expression of the selected index.\r\n     */\r\n    virtual QVariant expressionForIndex(QModelIndex const& index) const;\r\n\r\n    /*!\r\n     *  Get the value for the corresponding index.\r\n     *\r\n     *    @param [in] index   The index whose value is being searched for.\r\n     */\r\n    QVariant valueForIndex(const QModelIndex& index) const;\r\n\r\n    /*!\r\n     *  Decrease the number of references when removing a register.\r\n     *\r\n     *    @param [in] registerName    Name of the removed register.\r\n     */\r\n    void decreaseReferencesWithRemovedRegister(QString const& registerName);\r\n\r\n    /*!\r\n     *  Increase the number of references made in the selected register.\r\n     *\r\n     *    @param [in] registerName    Name of the selected register.\r\n     */\r\n    void increaseReferencesInPastedRegister(QString const& registerName);\r\n\r\n    /*!\r\n     *  Calculates the parameters used in the selected register.\r\n     *\r\n     *    @param [in] registerName    Name of the selected register.\r\n     *\r\n     *    @return A map containing pairs of referenced ids and the number of references made to them.\r\n     */\r\n    QMap<QString, int> getReferencedParameters(QString const& registerName) const;\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! Interface for registers.\r\n    RegisterInterface* registerInterface_;\r\n\r\n    //! Interface for register access policies.\r\n    AccessPolicyInterface* accessPolicyInterface_;\r\n\r\n    Document::Revision docRevision_;\r\n};\r\n\r\n#endif // ADDRESSBLOCKMODEL_H\r\n"
  },
  {
    "path": "editors/ComponentEditor/memoryMaps/enumeratedvaluedelegate.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: enumeratedvaluedelegate.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 28.08.2012\r\n//\r\n// Description:\r\n// The delegate that provides editors to add/remove/edit the enumerated values of field.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"enumeratedvaluedelegate.h\"\r\n#include \"EnumeratedValueColumns.h\"\r\n\r\n#include <QLineEdit>\r\n#include <QComboBox>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: enumeratedvaluedelegate::EnumeratedValueDelegate()\r\n//-----------------------------------------------------------------------------\r\nEnumeratedValueDelegate::EnumeratedValueDelegate(QObject *parent):\r\nQStyledItemDelegate(parent)\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: enumeratedvaluedelegate::~EnumeratedValueDelegate()\r\n//-----------------------------------------------------------------------------\r\nEnumeratedValueDelegate::~EnumeratedValueDelegate()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: enumeratedvaluedelegate::createEditor()\r\n//-----------------------------------------------------------------------------\r\nQWidget* EnumeratedValueDelegate::createEditor( QWidget* parent, const QStyleOptionViewItem& option,\r\n    const QModelIndex& index ) const\r\n{\r\n    if (index.column() == EnumeratedValueColumns::USAGE_COLUMN)\r\n    {\r\n        QComboBox* combo = new QComboBox(parent);\r\n        combo->addItem(tr(\"read-write\"));\r\n        combo->addItem(tr(\"read\"));\r\n        combo->addItem(tr(\"write\"));\r\n        combo->addItem(QString(\"\"));\r\n        return combo;\r\n    }\r\n\r\n    else\r\n    {\r\n        return QStyledItemDelegate::createEditor(parent, option, index);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: enumeratedvaluedelegate::setEditorData()\r\n//-----------------------------------------------------------------------------\r\nvoid EnumeratedValueDelegate::setEditorData( QWidget* editor, const QModelIndex& index ) const\r\n{\r\n    if (index.column() == EnumeratedValueColumns::USAGE_COLUMN)\r\n    {\r\n        QComboBox* combo = qobject_cast<QComboBox*>(editor);\r\n        Q_ASSERT(combo);\r\n\r\n        QString text = index.model()->data(index, Qt::DisplayRole).toString();\r\n        int comboIndex = combo->findText(text);\r\n        combo->setCurrentIndex(comboIndex);\r\n    }\r\n    else\r\n    {\r\n        QStyledItemDelegate::setEditorData(editor, index);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: enumeratedvaluedelegate::setModelData()\r\n//-----------------------------------------------------------------------------\r\nvoid EnumeratedValueDelegate::setModelData( QWidget* editor, QAbstractItemModel* model, const QModelIndex& index )\r\n    const\r\n{\r\n    if (index.column() == EnumeratedValueColumns::USAGE_COLUMN)\r\n    {\r\n        QComboBox* combo = qobject_cast<QComboBox*>(editor);\r\n        Q_ASSERT(combo);\r\n\r\n        QString text = combo->currentText();\r\n        model->setData(index, text, Qt::EditRole);\r\n    }\r\n    else\r\n    {\r\n        QStyledItemDelegate::setModelData(editor, model, index);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: enumeratedvaluedelegate::commitAndCloseEditor()\r\n//-----------------------------------------------------------------------------\r\nvoid EnumeratedValueDelegate::commitAndCloseEditor()\r\n{\r\n\tQWidget* edit = qobject_cast<QWidget*>(sender());\r\n\tQ_ASSERT(edit);\r\n\r\n\temit commitData(edit);\r\n\temit closeEditor(edit);\r\n}\r\n"
  },
  {
    "path": "editors/ComponentEditor/memoryMaps/enumeratedvaluedelegate.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: enumeratedvaluedelegate.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 28.08.2012\r\n//\r\n// Description:\r\n// The delegate that provides editors to add/remove/edit the enumerated values of field.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef ENUMERATEDVALUEDELEGATE_H\r\n#define ENUMERATEDVALUEDELEGATE_H\r\n\r\n#include <QStyledItemDelegate>\r\n\r\n//-----------------------------------------------------------------------------\r\n//! The delegate that provides editors to add/remove/edit the enumerated values of field.\r\n//-----------------------------------------------------------------------------\r\nclass EnumeratedValueDelegate : public QStyledItemDelegate\r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\r\n\t/*!\r\n     *  The constructor.\r\n\t *\r\n\t *    @param [in] parent  Pointer to the owner of the delegate.\r\n\t */\r\n\tEnumeratedValueDelegate(QObject *parent);\t\r\n\r\n\t//! The destructor.\r\n\tvirtual ~EnumeratedValueDelegate();\r\n\r\n\t/*!\r\n     *  Create a new editor for the given item.\r\n\t *\r\n\t *    @param [in] parent  Owner for the editor.\r\n\t *    @param [in] option  Contains options for the editor.\r\n\t *    @param [in] index   Model index identifying the item.\r\n\t *\r\n\t *    @return Pointer to the editor to be used to edit the item.\r\n\t */\r\n\tvirtual QWidget* createEditor(QWidget* parent, const QStyleOptionViewItem& option, const QModelIndex& index)\r\n        const;\r\n\r\n\t/*!\r\n     *  Set the data for the editor.\r\n\t *\r\n\t *    @param [in] editor  Pointer to the editor where the data is to be set.\r\n\t *    @param [in] index   Model index identifying the item that's data is to be set.\r\n\t */\r\n\tvirtual void setEditorData(QWidget* editor, const QModelIndex& index) const;\r\n\r\n\t/*!\r\n     *  Save the data from the editor to the model.\r\n\t *\r\n\t *    @param [in] editor  Pointer to the editor that contains the data to store.\r\n\t *    @param [in] model   Model that contains the data structure where data is to be saved to.\r\n\t *    @param [in] index   Model index identifying the item that's data is to be saved.\r\n\t */\r\n\tvirtual void setModelData(QWidget* editor, QAbstractItemModel* model, const QModelIndex& index) const;\r\n\r\nprivate slots:\r\n\r\n\t/*!\r\n     *  Commit the data from the sending editor and close the editor.\r\n\t */\r\n\tvoid commitAndCloseEditor();\r\n\r\nprivate:\r\n\t\r\n\t//! No copying.\r\n\tEnumeratedValueDelegate(const EnumeratedValueDelegate& other);\r\n\r\n\t//! No assignment.\r\n\tEnumeratedValueDelegate& operator=(const EnumeratedValueDelegate& other);\r\n};\r\n\r\n#endif // ENUMERATEDVALUEDELEGATE_H\r\n"
  },
  {
    "path": "editors/ComponentEditor/memoryMaps/enumeratedvaluemodel.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: enumeratedvaluemodel.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 28.08.2012\r\n//\r\n// Description:\r\n// The model to manage the enumerated values of a field.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"enumeratedvaluemodel.h\"\r\n#include \"EnumeratedValueColumns.h\"\r\n\r\n#include <IPXACTmodels/Component/EnumeratedValue.h>\r\n#include <IPXACTmodels/Component/validators/EnumeratedValueValidator.h>\r\n\r\n#include <common/KactusColors.h>\r\n\r\n\r\n#include <QApplication>\r\n#include <QClipboard>\r\n#include <QMimeData>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: enumeratedvaluemodel::EnumeratedValueModel()\r\n//-----------------------------------------------------------------------------\r\nEnumeratedValueModel::EnumeratedValueModel(\r\n    QSharedPointer<QList<QSharedPointer<EnumeratedValue> > > enumeratedValues,\r\n    QSharedPointer<EnumeratedValueValidator> enumeratedValueValidator, QObject *parent):\r\nQAbstractTableModel(parent),\r\n    enumValues_(enumeratedValues),\r\n    enumeratedValueValidator_(enumeratedValueValidator)\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: enumeratedvaluemodel::~EnumeratedValueModel()\r\n//-----------------------------------------------------------------------------\r\nEnumeratedValueModel::~EnumeratedValueModel()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: enumeratedvaluemodel::rowCount()\r\n//-----------------------------------------------------------------------------\r\nint EnumeratedValueModel::rowCount( const QModelIndex& parent /*= QModelIndex()*/ ) const\r\n{\r\n\tif (parent.isValid())\r\n    {\r\n\t\treturn 0;\r\n\t}\r\n\treturn enumValues_->size();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: enumeratedvaluemodel::columnCount()\r\n//-----------------------------------------------------------------------------\r\nint EnumeratedValueModel::columnCount( const QModelIndex& parent /*= QModelIndex()*/ ) const\r\n{\r\n\tif (parent.isValid())\r\n    {\r\n\t\treturn 0;\r\n\t}\r\n    return EnumeratedValueColumns::COLUMN_COUNT;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: enumeratedvaluemodel::flags()\r\n//-----------------------------------------------------------------------------\r\nQt::ItemFlags EnumeratedValueModel::flags( const QModelIndex& index ) const\r\n{\r\n\tif (!index.isValid())\r\n    {\r\n\t\treturn Qt::NoItemFlags;\r\n\t}\r\n\treturn Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsEditable;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: enumeratedvaluemodel::headerData()\r\n//-----------------------------------------------------------------------------\r\nQVariant EnumeratedValueModel::headerData( int section, Qt::Orientation orientation,\r\n    int role /*= Qt::DisplayRole*/ ) const\r\n{\r\n\tif (orientation != Qt::Horizontal)\r\n    {\r\n\t\treturn QVariant();\r\n\t}\r\n\tif (Qt::DisplayRole == role)\r\n    {\r\n        if (section == EnumeratedValueColumns::NAME_COLUMN)\r\n        {\r\n            return tr(\"Enumeration name\");\r\n        }\r\n        else if (section == EnumeratedValueColumns::DISPLAY_NAME)\r\n        {\r\n            return tr(\"Display name\");\r\n        }\r\n        else if (section == EnumeratedValueColumns::VALUE_COLUMN)\r\n        {\r\n            return tr(\"Value\");\r\n        }\r\n        else if (section == EnumeratedValueColumns::USAGE_COLUMN)\r\n        {\r\n            return tr(\"Usage\");\r\n        }\r\n        else if (section == EnumeratedValueColumns::DESCRIPTION)\r\n        {\r\n            return tr(\"Description\");\r\n        }\r\n\t}\r\n\r\n    return QVariant();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: enumeratedvaluemodel::data()\r\n//-----------------------------------------------------------------------------\r\nQVariant EnumeratedValueModel::data( const QModelIndex& index, int role /*= Qt::DisplayRole*/ ) const\r\n{\r\n\tif (!index.isValid())\r\n    {\r\n\t\treturn QVariant();\r\n\t}\r\n\telse if (index.row() < 0 || index.row() >= enumValues_->size())\r\n    {\r\n\t\treturn QVariant();\r\n\t}\r\n\r\n\tif (role == Qt::DisplayRole || role == Qt::EditRole || role == Qt::ToolTipRole)\r\n    {\r\n        return valueForIndex(index);\r\n\t}\r\n\r\n\telse if (Qt::ForegroundRole == role)\r\n    {\r\n        if (enumeratedValueValidator_->validate(enumValues_->at(index.row())))\r\n        {\r\n            return KactusColors::REGULAR_TEXT;\r\n        }\r\n        else\r\n        {\r\n            return KactusColors::ERROR;\r\n        }\r\n\t}\r\n\r\n\telse if (Qt::BackgroundRole == role)\r\n    {\r\n        if (index.column() == EnumeratedValueColumns::NAME_COLUMN ||\r\n            index.column() == EnumeratedValueColumns::VALUE_COLUMN)\r\n        {\r\n            return KactusColors::MANDATORY_FIELD;\r\n        }\r\n        else\r\n        {\r\n            return KactusColors::REGULAR_FIELD;\r\n        }\r\n\t}\r\n\telse\r\n    {\r\n\t\treturn QVariant();\r\n\t}\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: enumeratedvaluemodel::setData()\r\n//-----------------------------------------------------------------------------\r\nbool EnumeratedValueModel::setData( const QModelIndex& index, const QVariant& value, int role /*= Qt::EditRole*/ )\r\n{\r\n\tif (!index.isValid())\r\n    {\r\n\t\treturn false;\r\n\t}\r\n\telse if (index.row() < 0 || index.row() >= enumValues_->size())\r\n    {\r\n\t\treturn false;\r\n\t}\r\n\r\n\tif (Qt::EditRole == role)\r\n    {\r\n        if (index.column() == EnumeratedValueColumns::NAME_COLUMN)\r\n        {\r\n            enumValues_->at(index.row())->setName(value.toString());\r\n        }\r\n        else if (index.column() == EnumeratedValueColumns::DISPLAY_NAME)\r\n        {\r\n            enumValues_->at(index.row())->setDisplayName(value.toString());\r\n        }\r\n        else if (index.column() == EnumeratedValueColumns::VALUE_COLUMN)\r\n        {\r\n            enumValues_->at(index.row())->setValue(value.toString());\r\n        }\r\n        else if (index.column() == EnumeratedValueColumns::USAGE_COLUMN)\r\n        {\r\n            enumValues_->at(index.row())->setUsage\r\n                (EnumeratedValue::str2Usage(value.toString(), EnumeratedValue::UNKNOWNUSAGE));\r\n        }\r\n        else if (index.column() == EnumeratedValueColumns::DESCRIPTION)\r\n        {\r\n            enumValues_->at(index.row())->setDescription(value.toString());\r\n        }\r\n        else\r\n        {\r\n            return false;\r\n        }\r\n\r\n\t\temit dataChanged(index, index);\r\n\t\temit contentChanged();\r\n\t\treturn true;\r\n\t}\r\n\telse\r\n    {\r\n\t\treturn false;\r\n\t}\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: enumeratedvaluemodel::onAddItem()\r\n//-----------------------------------------------------------------------------\r\nvoid EnumeratedValueModel::onAddItem( const QModelIndex& index )\r\n{\r\n\tint row = enumValues_->size();\r\n\r\n\t// if the index is valid then add the item to the correct position\r\n\tif (index.isValid())\r\n    {\r\n\t\trow = index.row();\r\n\t}\r\n\r\n\tbeginInsertRows(QModelIndex(), row, row);\r\n\tenumValues_->insert(row, QSharedPointer<EnumeratedValue>(new EnumeratedValue()));\r\n\tendInsertRows();\r\n\r\n\t// inform navigation tree that file set is added\r\n\temit enumAdded(row);\r\n\r\n\t// tell also parent widget that contents have been changed\r\n\temit contentChanged();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: enumeratedvaluemodel::onRemoveItem()\r\n//-----------------------------------------------------------------------------\r\nvoid EnumeratedValueModel::onRemoveItem( const QModelIndex& index )\r\n{\r\n\t// don't remove anything if index is invalid\r\n\tif (!index.isValid())\r\n    {\r\n\t\treturn;\r\n\t}\r\n\t// make sure the row number if valid\r\n\telse if (index.row() < 0 || index.row() >= enumValues_->size())\r\n    {\r\n\t\treturn;\r\n\t}\r\n\r\n\t// remove the specified item\r\n\tbeginRemoveRows(QModelIndex(), index.row(), index.row());\r\n\tenumValues_->removeAt(index.row());\r\n\tendRemoveRows();\r\n\r\n\t// inform navigation tree that file set has been removed\r\n\temit enumRemoved(index.row());\r\n\r\n\t// tell also parent widget that contents have been changed\r\n\temit contentChanged();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: enumeratedvaluemodel::valueForIndex()\r\n//-----------------------------------------------------------------------------\r\nQVariant EnumeratedValueModel::valueForIndex(QModelIndex const& index) const\r\n{\r\n    if (index.column() == EnumeratedValueColumns::NAME_COLUMN)\r\n    {\r\n        return enumValues_->at(index.row())->name();\r\n    }\r\n    else if (index.column() == EnumeratedValueColumns::DISPLAY_NAME)\r\n    {\r\n        return enumValues_->at(index.row())->displayName();\r\n    }\r\n    else if (index.column() == EnumeratedValueColumns::VALUE_COLUMN)\r\n    {\r\n        return enumValues_->at(index.row())->getValue();\r\n    }\r\n    else if (index.column() == EnumeratedValueColumns::USAGE_COLUMN)\r\n    {\r\n        return EnumeratedValue::usage2Str(enumValues_->at(index.row())->getUsage());\r\n    }\r\n    else if (index.column() == EnumeratedValueColumns::DESCRIPTION)\r\n    {\r\n        return enumValues_->at(index.row())->description();\r\n    }\r\n    else\r\n    {\r\n        return QVariant();\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: enumeratedvaluemodel::onCopyRows()\r\n//-----------------------------------------------------------------------------\r\nvoid EnumeratedValueModel::onCopyRows(QModelIndexList indexList)\r\n{\r\n    QList<QSharedPointer<EnumeratedValue> > copiedEnumeratedValues;\r\n    foreach (QModelIndex index, indexList)\r\n    {\r\n        QSharedPointer<EnumeratedValue> enumValue = enumValues_->at(index.row());\r\n        copiedEnumeratedValues.append(enumValue);\r\n    }\r\n\r\n    QVariant enumValueVariant;\r\n    enumValueVariant.setValue(copiedEnumeratedValues);\r\n    \r\n    QMimeData* newMimeData = new QMimeData();\r\n    \r\n    newMimeData->setData(\"text/xml/ipxact:enumeratedValue\", QByteArray());\r\n    newMimeData->setImageData(enumValueVariant);\r\n\r\n    QApplication::clipboard()->setMimeData(newMimeData);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: enumeratedvaluemodel::onPasteRows()\r\n//-----------------------------------------------------------------------------\r\nvoid EnumeratedValueModel::onPasteRows()\r\n{\r\n    const QMimeData* pasteData = QApplication::clipboard()->mimeData();\r\n\r\n    if (pasteData->hasImage())\r\n    {\r\n        QVariant pasteVariant = pasteData->imageData();\r\n        if (pasteVariant.canConvert<QList<QSharedPointer<EnumeratedValue> > >())\r\n        {\r\n            QList<QSharedPointer<EnumeratedValue> > newEnumeratedValeus =\r\n                pasteVariant.value<QList<QSharedPointer<EnumeratedValue> > >();\r\n\r\n            int rowBegin = enumValues_->size();\r\n            int rowEnd = rowBegin + newEnumeratedValeus.size() - 1;\r\n\r\n            beginInsertRows(QModelIndex(), rowBegin, rowEnd);\r\n\r\n            foreach(QSharedPointer<EnumeratedValue> copiedEnumValue, newEnumeratedValeus)\r\n            {\r\n                QSharedPointer<EnumeratedValue> newEnumValue (new EnumeratedValue(*copiedEnumValue.data()));\r\n                newEnumValue->setName(getUniqueName(newEnumValue->name()));\r\n\r\n                enumValues_->append(newEnumValue);\r\n\r\n                emit enumAdded(enumValues_->size() - 1);\r\n            }\r\n\r\n            endInsertRows();\r\n\r\n            emit contentChanged();\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: enumeratedvaluemodel::getUniqueName()\r\n//-----------------------------------------------------------------------------\r\nQString EnumeratedValueModel::getUniqueName(QString const& originalName)\r\n{\r\n    QString name = originalName;\r\n    int trailingNumber = 1;\r\n\r\n    bool match =  true;\r\n    while (match)\r\n    {\r\n        match = false;        \r\n        for(int row = 0; row < enumValues_->size(); row++)\r\n        {\r\n            if (name.compare(enumValues_->at(row)->name()) == 0)\r\n            {\r\n                match = true;\r\n                name = originalName + \"_\" + QString::number(trailingNumber);\r\n                trailingNumber++;\r\n            }\r\n        }\r\n    }\r\n\r\n    return name;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: enumeratedvaluemodel::mimeTypes()\r\n//-----------------------------------------------------------------------------\r\nQStringList EnumeratedValueModel::mimeTypes() const\r\n{\r\n    QStringList types(QAbstractItemModel::mimeTypes());\r\n\r\n    types << \"text/xml/ipxact:enumeratedValue\";\r\n\r\n    return types;\r\n}\r\n"
  },
  {
    "path": "editors/ComponentEditor/memoryMaps/enumeratedvaluemodel.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: enumeratedvaluemodel.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 28.08.2012\r\n//\r\n// Description:\r\n// The model to manage the enumerated values of a field.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef ENUMERATEDVALUEMODEL_H\r\n#define ENUMERATEDVALUEMODEL_H\r\n\r\n#include <QAbstractTableModel>\r\n#include <QSharedPointer>\r\n\r\nclass EnumeratedValue;\r\nclass EnumeratedValueValidator;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! The model to manage the enumerated values of a field.\r\n//-----------------------------------------------------------------------------\r\nclass EnumeratedValueModel : public QAbstractTableModel\r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\r\n\t/*!\r\n     *  The constructor.\r\n\t *\r\n\t *    @param [in] enumeratedValues            The enumerated values being edited.\r\n     *    @param [in] enumeratedValueValidator    The validator used for enumerated values.\r\n\t *    @param [in] parent                      Pointer to the owner of the model.\r\n\t */\r\n    EnumeratedValueModel(QSharedPointer<QList<QSharedPointer<EnumeratedValue> > > enumeratedValues,\r\n        QSharedPointer<EnumeratedValueValidator> enumeratedValueValidator, QObject *parent);\r\n\t\r\n\t//! The destructor.\r\n\tvirtual ~EnumeratedValueModel();\r\n\t\r\n\t/*!\r\n     *  Get the number of rows an item contains.\r\n\t *\r\n\t *    @param [in] parent  Identifies the parent that's row count is requested.\r\n\t *\r\n\t *    @return Number of rows the item has.\r\n\t */\r\n\tvirtual int rowCount(const QModelIndex& parent = QModelIndex()) const;\r\n\r\n\t/*!\r\n     *  Get the number of columns the item has to be displayed.\r\n\t *\r\n\t *    @param [in] parent  Identifies the parent that's column count is requested.\r\n\t *\r\n\t *    @return The number of columns to be displayed.\r\n\t */\r\n\tvirtual int columnCount(const QModelIndex& parent = QModelIndex()) const;\r\n\r\n\t/*!\r\n     *  Get the item flags that defines the possible operations for the item.\r\n\t *\r\n\t *    @param [in] index   Model index that identifies the item.\r\n\t *\r\n\t *    @return Qt::ItemFlags specify the possible operations for the item.\r\n\t */\r\n\tQt::ItemFlags flags(const QModelIndex& index) const;\r\n\r\n\t/*!\r\n     *  Get the header data for specified header.\r\n\t *\r\n\t *    @param [in] section         The section specifies the row/column number for the header.\r\n\t *    @param [in] orientation     Specified if horizontal or vertical header is wanted.\r\n\t *    @param [in] role            Specifies the type of the requested data.\r\n\t *\r\n\t *    @return QVariant Contains the requested data.\r\n\t */\r\n\tvirtual QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;\r\n\r\n\t/*!\r\n     *  Get the data for specified item.\r\n\t *\r\n\t *    @param [in] index   Specifies the item that's data is requested.\r\n\t *    @param [in] role    The role that defines what kind of data is requested.\r\n\t *\r\n\t *    @return QVariant Contains the data for the item.\r\n\t */\r\n\tvirtual QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const;\r\n\r\n\t/*!\r\n     *  Save the data to the model for specified item.\r\n\t *\r\n\t *    @param [in] index   The model index of the item that's data is to be saved.\r\n\t *    @param [in] value   The data that is to be saved.\r\n\t *    @param [in] role    The role specifies what kind of data should be saved.\r\n\t *\r\n\t *    @return True if saving happened successfully.\r\n\t */\r\n\tbool setData(const QModelIndex& index, const QVariant& value, int role = Qt::EditRole);\r\n    \r\n    /*!\r\n     *  Get the list of acceptable mime types.\r\n     *\r\n     *    @return The list of acceptable mime types.\r\n     */\r\n    virtual QStringList mimeTypes() const;\r\n\r\npublic slots:\r\n\r\n\t/*!\r\n     *  Add a new item to the given index.\r\n\t *\r\n\t *    @param [in] index   The index identifying the position for new item.\r\n\t */\r\n\tvirtual void onAddItem(const QModelIndex& index);\r\n\r\n\t/*!\r\n     *  Remove the item in the given index.\r\n\t *\r\n\t *    @param [in] index   The index identifying the item to remove.\r\n\t */\r\n\tvirtual void onRemoveItem(const QModelIndex& index);\r\n\r\n    /*!\r\n     *  Copy the items in the selected rows.\r\n     *\r\n     *    @param [in] indexList   List of indexes pointing to the selected rows.\r\n     */\r\n    void onCopyRows(QModelIndexList indexList);\r\n\r\n    /*!\r\n     *  Paste the copied items.\r\n     */\r\n    void onPasteRows();\r\n\r\nsignals:\r\n\r\n\t//! Emitted when the contents of the model change.\r\n\tvoid contentChanged();\r\n\r\n\t//! Emitted when a new enumeration value is added to the given index.\r\n\tvoid enumAdded(int index);\r\n\r\n\t//! Emitted when an enumeration value is removed from the given index.\r\n\tvoid enumRemoved(int index);\r\n\r\nprivate:\r\n\t\r\n\t//! No copying.\r\n\tEnumeratedValueModel(const EnumeratedValueModel& other);\r\n\r\n\t//! No assignment.\r\n\tEnumeratedValueModel& operator=(const EnumeratedValueModel& other);\r\n\r\n    /*!\r\n     *  Gets the value for the given index.\r\n     *\r\n     *    @param [in] index   The index of the target data.\r\n     *\r\n     *    @return The data in the given index.\r\n     */\r\n    QVariant valueForIndex(QModelIndex const& index) const;\r\n\r\n    /*!\r\n     *  Get a unique name for the selected name.\r\n     *\r\n     *    @param [in] originalName    The selected name.\r\n     *\r\n     *    @return A unique name created from the selected name.\r\n     */\r\n    QString getUniqueName(QString const& originalName);\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! Contains the enumerated values being edited.\r\n    QSharedPointer<QList<QSharedPointer<EnumeratedValue> > > enumValues_;\r\n\r\n    //! The validator for enumerated values.\r\n    QSharedPointer<EnumeratedValueValidator> enumeratedValueValidator_;\r\n};\r\n\r\n#endif // ENUMERATEDVALUEMODEL_H\r\n"
  },
  {
    "path": "editors/ComponentEditor/memoryMaps/fieldeditor.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: WriteValueConstraintComboBox.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 28.08.2012\r\n//\r\n// Description:\r\n// Editor for editing the enumerated values of a field.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"fieldeditor.h\"\r\n#include \"enumeratedvaluemodel.h\"\r\n#include \"enumeratedvaluedelegate.h\"\r\n\r\n#include <common/views/EditableTableView/editabletableview.h>\r\n\r\n#include <KactusAPI/include/LibraryInterface.h>\r\n\r\n#include <IPXACTmodels/Component/Component.h>\r\n\r\n#include <QVBoxLayout>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: fieldeditor::FieldEditor()\r\n//-----------------------------------------------------------------------------\r\nFieldEditor::FieldEditor(QSharedPointer<QList<QSharedPointer<EnumeratedValue> > > enumeratedValues,\r\n    QSharedPointer<EnumeratedValueValidator> enumeratedValueValidator, QSharedPointer<Component> component,\r\n    LibraryInterface* handler, QWidget* parent /* = 0 */):\r\nQGroupBox(tr(\"Enumerated values\"), parent),\r\nenumView_(new EditableTableView(this)),\r\nenumProxy_(new QSortFilterProxyModel(this)),\r\nenumModel_(new EnumeratedValueModel(enumeratedValues, enumeratedValueValidator, this))\r\n{\r\n\tQVBoxLayout* layout = new QVBoxLayout(this);\r\n    layout->addWidget(enumView_, 0);\r\n\r\n\tenumProxy_->setSourceModel(enumModel_);\r\n\tenumView_->setModel(enumProxy_);\r\n\r\n    const QString compPath = handler->getDirectoryPath(component->getVlnv());\r\n\tQString defPath = QString(\"%1/enumListing.csv\").arg(compPath);\r\n\tenumView_->setDefaultImportExportPath(defPath);\r\n\tenumView_->setAllowImportExport(true);\r\n\r\n\t// items can not be dragged\r\n\tenumView_->setItemsDraggable(false);\r\n\tenumView_->setSortingEnabled(true);\r\n    enumView_->setAllowElementCopying(true);\r\n\tenumView_->setItemDelegate(new EnumeratedValueDelegate(this));\r\n\r\n\tconnect(enumModel_, SIGNAL(contentChanged()), this, SIGNAL(contentChanged()), Qt::UniqueConnection);\r\n\tconnect(enumView_, SIGNAL(addItem(const QModelIndex&)),\r\n\t\tenumModel_, SLOT(onAddItem(const QModelIndex&)), Qt::UniqueConnection);\r\n\tconnect(enumView_, SIGNAL(removeItem(const QModelIndex&)),\r\n        enumModel_, SLOT(onRemoveItem(const QModelIndex&)), Qt::UniqueConnection);\r\n\r\n    connect(enumView_, SIGNAL(copyRows(QModelIndexList)),\r\n        enumModel_, SLOT(onCopyRows(QModelIndexList)), Qt::UniqueConnection);\r\n    connect(enumView_, SIGNAL(pasteRows()), enumModel_, SLOT(onPasteRows()), Qt::UniqueConnection);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: fieldeditor::~FieldEditor()\r\n//-----------------------------------------------------------------------------\r\nFieldEditor::~FieldEditor()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: fieldeditor::refresh()\r\n//-----------------------------------------------------------------------------\r\nvoid FieldEditor::refresh()\r\n{\r\n\tenumView_->update();\r\n}\r\n"
  },
  {
    "path": "editors/ComponentEditor/memoryMaps/fieldeditor.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: WriteValueConstraintComboBox.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 28.08.2012\r\n//\r\n// Description:\r\n// Editor for editing the enumerated values of a field.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef FIELDEDITOR_H\r\n#define FIELDEDITOR_H\r\n\r\n#include <editors/ComponentEditor/itemeditor.h>\r\n\r\n#include <QSharedPointer>\r\n#include <QSortFilterProxyModel>\r\n#include <QGroupBox>\r\n\r\nclass EditableTableView;\r\nclass EnumeratedValueModel;\r\nclass LibraryInterface;\r\nclass EnumeratedValue;\r\nclass EnumeratedValueValidator;\r\nclass Component;\r\n//-----------------------------------------------------------------------------\r\n//! Editor for editing the enumerated values of a field.\r\n//-----------------------------------------------------------------------------\r\nclass FieldEditor : public QGroupBox\r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\r\n\t/*!\r\n\t *  The constructor.\r\n\t *\r\n\t *    @param [in] enumeratedValues            List of enumerated values being edited.\r\n     *    @param [in] enumeratedValueValidator    The validator for enumerated values.\r\n\t *    @param [in] component                   Pointer to the component being edited.\r\n\t *    @param [in] handler                     Pointer to the instance managing the library.\r\n\t *    @param [in] parent                      Pointer to the parent of this editor.\r\n\t */\r\n\tFieldEditor(QSharedPointer<QList<QSharedPointer<EnumeratedValue> > > enumeratedValues,\r\n        QSharedPointer<EnumeratedValueValidator> enumeratedValueValidator, QSharedPointer<Component> component,\r\n        LibraryInterface* handler, QWidget* parent = 0);\r\n\r\n\t/*!\r\n\t *  The destructor.\r\n\t */\r\n\tvirtual ~FieldEditor();\r\n\r\n\t/*!\r\n\t *  Reload the information from the model to the editor.\r\n\t */\r\n\tvirtual void refresh();\r\n\r\nsignals:\r\n\r\n    /*!\r\n     *  Informs of changes to the component editor tree.\r\n     */\r\n    void contentChanged();\r\n\r\nprivate:\r\n\t\r\n\t//! No copying\r\n\tFieldEditor(const FieldEditor& other);\r\n\r\n\t//! No assignment\r\n\tFieldEditor& operator=(const FieldEditor& other);\r\n\r\n\t//! The view to display the enumerated values.\r\n\tEditableTableView* enumView_;\r\n\r\n\t//! The proxy that does the sorting of enumerated values.\r\n\tQSortFilterProxyModel* enumProxy_;\r\n\r\n\t//! The model that manages the enumerated values.\r\n\tEnumeratedValueModel* enumModel_;\r\n};\r\n\r\n#endif // FIELDEDITOR_H\r\n"
  },
  {
    "path": "editors/ComponentEditor/memoryMaps/memoryMapsExpressionCalculators/ReferenceCalculator.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ReferenceCalculator.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Mikko Teuho\r\n// Date: 29.04.2015\r\n//\r\n// Description:\r\n// Calculates the usage of parameters in a given list of expressions.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"ReferenceCalculator.h\"\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ReferenceCalculator::ReferenceCalculator()\r\n//-----------------------------------------------------------------------------\r\nReferenceCalculator::ReferenceCalculator(QSharedPointer<ParameterFinder> parameterFinder):\r\nparameterFinder_(parameterFinder)\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ReferenceCalculator::~ReferenceCalculator()\r\n//-----------------------------------------------------------------------------\r\nReferenceCalculator::~ReferenceCalculator()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ReferenceCalculator::getReferencedParameters()\r\n//-----------------------------------------------------------------------------\r\nQMap<QString, int> ReferenceCalculator::getReferencedParameters(QStringList listOfPossibleReferences) const\r\n{\r\n    QMap<QString, int> referencedParameters;\r\n\r\n    QStringList componentParameterIds = parameterFinder_->getAllParameterIds();\r\n    QString joinedPossibleReferences = listOfPossibleReferences.join(\" \");\r\n\r\n    foreach (QString parameterId, componentParameterIds)\r\n    {\r\n        int numberOfFound = joinedPossibleReferences.count(parameterId);\r\n        if (numberOfFound > 0)\r\n        {\r\n            referencedParameters.insert(parameterId, numberOfFound);\r\n        }\r\n    }\r\n\r\n    return referencedParameters;\r\n}\r\n"
  },
  {
    "path": "editors/ComponentEditor/memoryMaps/memoryMapsExpressionCalculators/ReferenceCalculator.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ReferenceCalculator.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Mikko Teuho\r\n// Date: 29.04.2015\r\n//\r\n// Description:\r\n// Calculates the usage of parameters in a given list of expressions.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef REFERENCECALCULATOR_H\r\n#define REFERENCECALCULATOR_H\r\n\r\n#include <KactusAPI/include/ParameterFinder.h>\r\n\r\n#include <QStringList>\r\n#include <QMap>\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Calculates the usage of parameters in a given list of expressions.\r\n//-----------------------------------------------------------------------------\r\nclass ReferenceCalculator\r\n{\r\n\r\npublic:\r\n\r\n    /*!\r\n     *  The constructor.\r\n     *\r\n     *    @param [in] parameterFinder     Pointer to the instance for finding component parameters.\r\n     */\r\n    ReferenceCalculator(QSharedPointer<ParameterFinder> parameterFinder);\r\n\r\n    /*!\r\n     *  The destructor.\r\n     */\r\n    virtual ~ReferenceCalculator();\r\n\r\n    /*!\r\n     *  Calculates the parameters used in a given list of expressions.\r\n     *\r\n     *    @param [in] listOfPossibleReferences    A list of expressions with possible references.\r\n     *\r\n     *    @return A map containing pairs of referenced ids and the number of references made to them.\r\n     */\r\n    QMap<QString, int> getReferencedParameters(QStringList listOfPossibleReferences) const;\r\n\r\nprivate:\r\n\t\r\n\t//! No copying\r\n    ReferenceCalculator(const ReferenceCalculator& other);\r\n\r\n\t//! No assignment\r\n    ReferenceCalculator& operator=(const ReferenceCalculator& other);\r\n\r\n    //! The parameter finder.\r\n    QSharedPointer<ParameterFinder> parameterFinder_;\r\n};\r\n\r\n#endif // REFERENCECALCULATOR_H\r\n"
  },
  {
    "path": "editors/ComponentEditor/memoryMaps/memoryMapsVisualizer/MemoryBlockGraphItem.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: MemoryBlockGraphItem.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 02.03.2022\n//\n// Description:\n// The graphical item that represents one memory block.\n//-----------------------------------------------------------------------------\n\n#include \"MemoryBlockGraphItem.h\"\n\n#include <KactusAPI/include/ExpressionParser.h>\n\n#include <QStringBuilder>\n#include <QBrush>\n\n//-----------------------------------------------------------------------------\n// Function: MemoryBlockGraphItem::MemoryBlockGraphItem()\n//-----------------------------------------------------------------------------\nMemoryBlockGraphItem::MemoryBlockGraphItem(QSharedPointer<ExpressionParser> expressionParser,\n    QGraphicsItem *parent):\nMemoryVisualizationItem(expressionParser, parent),\naddressableUnitBits_(0)\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: MemoryBlockGraphItem::updateDisplay()\n//-----------------------------------------------------------------------------\nvoid MemoryBlockGraphItem::updateDisplay()\n{\n    setName(getName());\n\n    quint64 offset = getOffset();\n    quint64 lastAddress = getLastAddress();\n\n    setDisplayOffset(offset);\n    setDisplayLastAddress(lastAddress);\n\n    const int BIT_WIDTH = getBitWidth();\n    setToolTip(\"<b>Name: </b>\" % getName() % \"<br>\" %\n        \"<b>Offset: </b>\" % toHexString(offset, BIT_WIDTH) % \"<br>\" %\n        \"<b>Last address: </b>\" % toHexString(lastAddress, BIT_WIDTH) % \"<br>\" %\n        \"<b>Size [AUB]: </b>\" % QString::number(getRange()));\n}\n\n//-----------------------------------------------------------------------------\n// Function: MemoryBlockGraphItem::setAddressableUnitBits()\n//-----------------------------------------------------------------------------\nvoid MemoryBlockGraphItem::setAddressableUnitBits(int addressableUnitBits)\n{\n    addressableUnitBits_ = addressableUnitBits;\n}\n\n//-----------------------------------------------------------------------------\n// Function: MemoryBlockGraphItem::getAddressUnitSize()\n//-----------------------------------------------------------------------------\nunsigned int MemoryBlockGraphItem::getAddressUnitSize() const\n{\n    return addressableUnitBits_;\n}\n\n//-----------------------------------------------------------------------------\n// Function: MemoryBlockGraphItem::getLastAddress()\n//-----------------------------------------------------------------------------\nquint64 MemoryBlockGraphItem::getLastAddress() const\n{\n    quint64 base = getOffset();\n    quint64 range = getRange();\n\n    quint64 lastAddr = base + range;\n\n    if (lastAddr == 0) \n    {\n        return 0;\n    }\n\n    return lastAddr -1;\n}\n"
  },
  {
    "path": "editors/ComponentEditor/memoryMaps/memoryMapsVisualizer/MemoryBlockGraphItem.h",
    "content": "//-----------------------------------------------------------------------------\n// File: MemoryBlockGraphItem.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 02.03.2022\n//\n// Description:\n// The graphical item that represents one memory block.\n//-----------------------------------------------------------------------------\n\n#ifndef MEMORYBLOCKGRAPHITEM_H\n#define MEMORYBLOCKGRAPHITEM_H\n\n#include <editors/ComponentEditor/visualization/memoryvisualizationitem.h>\n\n#include <QColor>\n\nclass ExpressionParser;\n\n//-----------------------------------------------------------------------------\n//! The graphical item that represents one memory block.\n//-----------------------------------------------------------------------------\nclass MemoryBlockGraphItem : public MemoryVisualizationItem\n{\n\tQ_OBJECT\n\npublic:\n\n\t/*!\n     *  The constructor\n\t *\n     *    @param [in] expressionParser    The used expression parser.\n     *    @param [in] parent              The parent graph item.\n\t */\n    MemoryBlockGraphItem(QSharedPointer<ExpressionParser> expressionParser,\n\t\tQGraphicsItem *parent);\n\t\n\t/*!\n     *  The destructor.\n     */\n    virtual ~MemoryBlockGraphItem() = default;\n\n    //! No copying. No assignment.\n    MemoryBlockGraphItem(const MemoryBlockGraphItem& other) = delete;\n    MemoryBlockGraphItem& operator=(const MemoryBlockGraphItem& other) = delete;\n\n    /*!\n     *  Updates the labels and tooltip for the item.\n     */\n    virtual void updateDisplay() override final;\n\n\t/*!\n     *  Get the last address contained in the item.\n\t *\n\t *    @return The last address.\n\t */\n\tvirtual quint64 getLastAddress() const override final;\n\n    /*!\n     *  Sets the addressable unit size.\n     *\n     *    @param [in] addressableUnitBits   The number of bits per address unit.\n     */\n    void setAddressableUnitBits(int addressableUnitBits);\n\n\t/*!\n     *  Get number of bits the addressable unit contains.\n\t *\n\t *    @return The size of least addressable unit.\n\t */\n\tvirtual unsigned int getAddressUnitSize() const override final;\n\nprivate:\n\n    /*!\n     *  Get the name of the memory block.\n     *\n     *    @return Name of the memory block.\n     */\n    virtual QString getName() const = 0;\n\n    /*!\n     *  Get the range of the memory block.\n     *\n     *    @return Range of the memory block.\n     */\n    virtual quint64 getRange() const = 0;\n\n    //-----------------------------------------------------------------------------\n    // Data.\n    //-----------------------------------------------------------------------------\n\n    //! The number of bits in an address unit.\n    int addressableUnitBits_;\n};\n\n#endif // MEMORYBLOCKGRAPHITEM_H\n"
  },
  {
    "path": "editors/ComponentEditor/memoryMaps/memoryMapsVisualizer/SubspaceMapGraphItem.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: SubspaceMapGraphItem.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 01.03.2022\n//\n// Description:\n// The graphical item that represents one subspace map.\n//-----------------------------------------------------------------------------\n\n#include \"SubspaceMapGraphItem.h\"\n\n#include <KactusAPI/include/ExpressionParser.h>\n\n#include <common/KactusColors.h>\n\n#include <QStringBuilder>\n#include <QBrush>\n\n//-----------------------------------------------------------------------------\n// Function: AddressBlockGraphItem::AddressBlockGraphItem()\n//-----------------------------------------------------------------------------\nSubspaceMapGraphItem::SubspaceMapGraphItem(SubspaceMapInterface* submapInterface, QString const& subspaceName,\n    QSharedPointer<ExpressionParser> expressionParser, QGraphicsItem *parent):\nMemoryBlockGraphItem(expressionParser, parent),\nsubmapInterface_(submapInterface),\nsubspaceName_(subspaceName.toStdString())\n{\n    setDefaultBrush(QBrush(KactusColors::MIRROREDSYSTEM_INTERFACE));\n    updateDisplay();\n}\n\n//-----------------------------------------------------------------------------\n// Function: SubspaceMapGraphItem::getOffset()\n//-----------------------------------------------------------------------------\nquint64 SubspaceMapGraphItem::getOffset() const\n{\n    quint64 offset = QString::fromStdString(submapInterface_->getBaseAddressValue(subspaceName_, 10)).toULongLong();\n    return offset;\n}\n\n//-----------------------------------------------------------------------------\n// Function: SubspaceMapGraphItem::getBitWidth()\n//-----------------------------------------------------------------------------\nint SubspaceMapGraphItem::getBitWidth() const\n{\n    quint64 bitWidth = QString::fromStdString(submapInterface_->getWidthValue(subspaceName_, 10)).toULongLong();\n    return bitWidth;\n}\n\n//-----------------------------------------------------------------------------\n// Function: SubspaceMapGraphItem::isPresent()\n//-----------------------------------------------------------------------------\nbool SubspaceMapGraphItem::isPresent() const\n{\n    QString isPresentValue = QString::fromStdString(submapInterface_->getIsPresentValue(subspaceName_));\n\n    return isPresentValue.isEmpty() || isPresentValue.toULongLong() == 1;\n}\n\n//-----------------------------------------------------------------------------\n// Function: SubspaceMapGraphItem::onNameChanged()\n//-----------------------------------------------------------------------------\nvoid SubspaceMapGraphItem::onNameChanged(QString const& oldName, QString const& newName)\n{\n    if (subspaceName_ == oldName.toStdString())\n    {\n        subspaceName_ = newName.toStdString();\n        updateDisplay();\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: SubspaceMapGraphItem::getName()\n//-----------------------------------------------------------------------------\nQString SubspaceMapGraphItem::getName() const\n{\n    return QString::fromStdString(subspaceName_);\n}\n\n//-----------------------------------------------------------------------------\n// Function: SubspaceMapGraphItem::getRange()\n//-----------------------------------------------------------------------------\nquint64 SubspaceMapGraphItem::getRange() const\n{\n    quint64 range = QString::fromStdString(submapInterface_->getRangeValue(subspaceName_)).toULongLong();\n    return range;\n}\n"
  },
  {
    "path": "editors/ComponentEditor/memoryMaps/memoryMapsVisualizer/SubspaceMapGraphItem.h",
    "content": "//-----------------------------------------------------------------------------\n// File: SubspaceMapGraphItem.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 01.03.2022\n//\n// Description:\n// The graphical item that represents one subspace map.\n//-----------------------------------------------------------------------------\n\n#ifndef SUBSPACEMAPGRAPHITEM_H\n#define SUBSPACEMAPGRAPHITEM_H\n\n#include <editors/ComponentEditor/memoryMaps/memoryMapsVisualizer/MemoryBlockGraphItem.h>\n#include <KactusAPI/include/SubspaceMapInterface.h>\n\n#include <QGraphicsItem>\n#include <QSharedPointer>\n\n#include <QColor>\n\nclass ExpressionParser;\n\n//-----------------------------------------------------------------------------\n//! The graphical item that represents one subspace map.\n//-----------------------------------------------------------------------------\nclass SubspaceMapGraphItem : public MemoryBlockGraphItem\n{\n\tQ_OBJECT\n\npublic:\n\n\t/*!\n     *  The constructor\n\t *\n     *    @param [in] submapInterface     Interface for accessing subspace maps.\n     *    @param [in] subspaceName        Name of the represented subspace map.\n     *    @param [in] expressionParser    The used expression parser.\n     *    @param [in] parent              The parent graph item.\n\t */\n    SubspaceMapGraphItem(SubspaceMapInterface* submapInterface,\n        QString const& subspaceName,\n        QSharedPointer<ExpressionParser> expressionParser,\n\t\tQGraphicsItem *parent);\n\t\n\t/*!\n     *  The destructor.\n     */\n    virtual ~SubspaceMapGraphItem() = default;\n\n    //! No copying. No assignment.\n    SubspaceMapGraphItem(const SubspaceMapGraphItem& other) = delete;\n    SubspaceMapGraphItem& operator=(const SubspaceMapGraphItem& other) = delete;\n\n\t/*!\n     *  Get the offset of the item. \n\t *\n\t *    @return int The offset of the item from the parent item's base address.\n\t */\n\tvirtual quint64 getOffset() const override final;\n\n\t/*!\n     *  Get the bit width of the item.\n\t * \n\t *    @return The bit width of the item.\n\t */\n\tvirtual int getBitWidth() const override final;\n           \n    /*!\n     *  Checks if the item is to be used in the visualization.\n     *\n     *    @return True, if the item should be used, otherwise false.\n     */\n    virtual bool isPresent() const override final;\n\npublic slots:\n\n    /*!\n     *  Handle the name change.\n     *\n     *    @param [in] oldName     The old name.\n     *    @param [in] newName     The new name.\n     */\n    void onNameChanged(QString const& oldName, QString const& newName);\n\nprivate:\n\n    /*!\n     *  Get the name of the memory block.\n     *\n     *    @return Name of the memory block.\n     */\n    virtual QString getName() const override final;\n\n    /*!\n     *  Get the range of the memory block.\n     *\n     *    @return Range of the memory block.\n     */\n    virtual quint64 getRange() const override final;\n\n    //-----------------------------------------------------------------------------\n    // Data.\n    //-----------------------------------------------------------------------------\n\n    //! Interface for accessing subspace maps.\n    SubspaceMapInterface* submapInterface_;\n    \n    //! Name of the represented subspace map.\n    std::string subspaceName_;\n};\n\n#endif // SUBSPACEMAPGRAPHITEM_H\n"
  },
  {
    "path": "editors/ComponentEditor/memoryMaps/memoryMapsVisualizer/addressblockgraphitem.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: addressblockgraphitem.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 18.4.2012\r\n//\r\n// Description:\r\n// The graphical item that represents one address block.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"addressblockgraphitem.h\"\r\n\r\n#include <KactusAPI/include/ExpressionParser.h>\r\n\r\n#include <common/KactusColors.h>\r\n\r\n#include <QStringBuilder>\r\n#include <QBrush>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressBlockGraphItem::AddressBlockGraphItem()\r\n//-----------------------------------------------------------------------------\r\nAddressBlockGraphItem::AddressBlockGraphItem(QSharedPointer<AddressBlock> addrBlock,\r\n    QSharedPointer<ExpressionParser> expressionParser, QGraphicsItem *parent ):\r\nMemoryBlockGraphItem(expressionParser, parent),\r\naddrBlock_(addrBlock)\r\n{\r\n\tQ_ASSERT(addrBlock_);\r\n\t\r\n\tsetDefaultBrush(QBrush(KactusColors::ADDR_BLOCK_COLOR));\r\n    updateDisplay();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressBlockGraphItem::getOffset()\r\n//-----------------------------------------------------------------------------\r\nquint64 AddressBlockGraphItem::getOffset() const\r\n{\r\n    return parseExpression(addrBlock_->getBaseAddress());\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressBlockGraphItem::getBitWidth()\r\n//-----------------------------------------------------------------------------\r\nint AddressBlockGraphItem::getBitWidth() const\r\n{\r\n    return parseExpression(addrBlock_->getWidth());\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressBlockGraphItem::isPresent()\r\n//-----------------------------------------------------------------------------\r\nbool AddressBlockGraphItem::isPresent() const\r\n{\r\n    return addrBlock_->getIsPresent().isEmpty() || parseExpression(addrBlock_->getIsPresent()) == 1;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: addressblockgraphitem::getName()\r\n//-----------------------------------------------------------------------------\r\nQString AddressBlockGraphItem::getName() const\r\n{\r\n    return addrBlock_->name();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: addressblockgraphitem::getRange()\r\n//-----------------------------------------------------------------------------\r\nquint64 AddressBlockGraphItem::getRange() const\r\n{\r\n    return parseExpression(addrBlock_->getRange());\r\n}\r\n"
  },
  {
    "path": "editors/ComponentEditor/memoryMaps/memoryMapsVisualizer/addressblockgraphitem.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: addressblockgraphitem.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 18.4.2012\r\n//\r\n// Description:\r\n// The graphical item that represents one address block.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef ADDRESSBLOCKGRAPHITEM_H\r\n#define ADDRESSBLOCKGRAPHITEM_H\r\n\r\n#include <editors/ComponentEditor/memoryMaps/memoryMapsVisualizer/MemoryBlockGraphItem.h>\r\n\r\n#include <IPXACTmodels/Component/AddressBlock.h>\r\n\r\n#include <QGraphicsItem>\r\n#include <QSharedPointer>\r\n#include <QColor>\r\n\r\nclass ExpressionParser;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! The graphical item that represents one address block.\r\n//-----------------------------------------------------------------------------\r\nclass AddressBlockGraphItem : public MemoryBlockGraphItem\r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\r\n\t/*!\r\n     *  The constructor\r\n\t *\r\n     *    @param [in] addrBlock           The address block to visualize.\r\n     *    @param [in] expressionParser    The used expression parser.\r\n     *    @param [in] parent              The parent graph item.\r\n\t */\r\n\tAddressBlockGraphItem(QSharedPointer<AddressBlock> addrBlock, \r\n        QSharedPointer<ExpressionParser> expressionParser,\r\n\t\tQGraphicsItem *parent);\r\n\t\r\n\t//! The destructor\r\n\tvirtual ~AddressBlockGraphItem() = default;\r\n\r\n    //! No copying. No assignment.\r\n    AddressBlockGraphItem(const AddressBlockGraphItem& other) = delete;\r\n    AddressBlockGraphItem& operator=(const AddressBlockGraphItem& other) = delete;\r\n\r\n\t/*!\r\n     *  Get the offset of the item. \r\n\t *\r\n\t *    @return int The offset of the item from the parent item's base address.\r\n\t */\r\n\tvirtual quint64 getOffset() const override final;\r\n\r\n\t/*!\r\n     *  Get the bit width of the item.\r\n\t * \r\n\t *    @return The bit width of the item.\r\n\t */\r\n\tvirtual int getBitWidth() const override final;\r\n           \r\n    /*!\r\n     *  Checks if the item is to be used in the visualization.\r\n     *\r\n     *    @return True, if the item should be used, otherwise false.\r\n     */\r\n    virtual bool isPresent() const override final;\r\n\r\nprivate:\r\n\r\n    /*!\r\n     *  Get the name of the memory block.\r\n     *\r\n     *    @return Name of the memory block.\r\n     */\r\n    virtual QString getName() const override final;\r\n\r\n    /*!\r\n     *  Get the range of the memory block.\r\n     *\r\n     *    @return Range of the memory block.\r\n     */\r\n    virtual quint64 getRange() const override final;\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n\t//! Pointer to the address block being displayed.\r\n\tQSharedPointer<AddressBlock> addrBlock_;\r\n};\r\n\r\n#endif // ADDRESSBLOCKGRAPHITEM_H\r\n"
  },
  {
    "path": "editors/ComponentEditor/memoryMaps/memoryMapsVisualizer/fieldgraphitem.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: fieldgraphitem.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 25.4.2012\r\n//\r\n// Description:\r\n// The graphical item that represents a bit field within a register.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"fieldgraphitem.h\"\r\n\r\n#include <common/KactusColors.h>\r\n\r\n#include <KactusAPI/include/ExpressionParser.h>\r\n\r\n#include <QStringBuilder>\r\n#include <QBrush>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FieldGraphItem::FieldGraphItem()\r\n//-----------------------------------------------------------------------------\r\nFieldGraphItem::FieldGraphItem( QSharedPointer<Field> field, QSharedPointer<ExpressionParser> expressionParser,\r\n    QGraphicsItem* parent):\r\nMemoryVisualizationItem(expressionParser, parent),\r\nfield_(field)\r\n{\r\n\tQ_ASSERT(field_);\r\n\r\n    setFlag(QGraphicsItem::ItemIgnoresParentOpacity);\r\n\t\r\n\tVisualizerItem::setDefaultBrush(QBrush(KactusColors::FIELD_COLOR));\r\n\r\n    setLayoutType(VisualizerItem::LABELS_TOP);\r\n    setClipText(true);\r\n\r\n\tsetShowExpandableItem(false);\r\n\tsetExpansionRectVisible(false);\r\n\r\n    updateDisplay();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FieldGraphItem::updateDisplay()\r\n//-----------------------------------------------------------------------------\r\nvoid FieldGraphItem::updateDisplay()\r\n{\r\n    setName(field_->name());\r\n\r\n    quint64 leftBound = getLastAddress();\r\n    quint64 rightBound = getOffset();\r\n\r\n    setDisplayOffset(leftBound);\r\n    setDisplayLastAddress(rightBound);\r\n    setToolTip(\"<b>\" % name() % \"</b> [\" % QString::number(leftBound) % \"..\" % QString::number(rightBound) % \"]\");\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FieldGraphItem::getOffset()\r\n//-----------------------------------------------------------------------------\r\nquint64 FieldGraphItem::getOffset() const\r\n{\r\n    return parseExpression(field_->getBitOffset());\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FieldGraphItem::getBitWidth()\r\n//-----------------------------------------------------------------------------\r\nint FieldGraphItem::getBitWidth() const\r\n{\r\n    return parseExpression(field_->getBitWidth());\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FieldGraphItem::getAddressUnitSize()\r\n//-----------------------------------------------------------------------------\r\nunsigned int FieldGraphItem::getAddressUnitSize() const\r\n{\r\n    return 0;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FieldGraphItem::setWidth()\r\n//-----------------------------------------------------------------------------\r\nvoid FieldGraphItem::setWidth(qreal width)\r\n{\r\n    VisualizerItem::setWidth(width);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FieldGraphItem::getLastAddress()\r\n//-----------------------------------------------------------------------------\r\nquint64 FieldGraphItem::getLastAddress() const\r\n{\r\n    const int MSB = getOffset() + getBitWidth();\r\n    return qMax(0, MSB - 1);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FieldGraphItem::setDisplayOffset()\r\n//-----------------------------------------------------------------------------\r\nvoid FieldGraphItem::setDisplayOffset(quint64 const& address)\r\n{\r\n    // Fields show decimal number offsets.\r\n    firstAddress_ = address;\r\n    VisualizerItem::setTopLabelText(QString::number(firstAddress_));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FieldGraphItem::setDisplayLastAddress()\r\n//-----------------------------------------------------------------------------\r\nvoid FieldGraphItem::setDisplayLastAddress(quint64 const& address)\r\n{\r\n    // Fields show decimal number offsets.\r\n    lastAddress_ = address;\r\n    VisualizerItem::setBottomLabelText(QString::number(lastAddress_));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: RegisterGraphItem::setConflicted()\r\n//-----------------------------------------------------------------------------\r\nvoid FieldGraphItem::setConflicted(bool conflicted)\r\n{\r\n    MemoryVisualizationItem::setConflicted(conflicted);\r\n    if (conflicted)\r\n    {\r\n        setOpacity(0.5);\r\n    }\r\n    else\r\n    {\r\n        setOpacity(1);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FieldGraphItem::isPresent()\r\n//-----------------------------------------------------------------------------\r\nbool FieldGraphItem::isPresent() const\r\n{\r\n    return field_->getIsPresent().isEmpty() || parseExpression(field_->getIsPresent()) == 1;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FieldGraphItem::redoChildLayout()\r\n//-----------------------------------------------------------------------------\r\nvoid FieldGraphItem::redoChildLayout()\r\n{\r\n    // Do nothing.\r\n}\r\n"
  },
  {
    "path": "editors/ComponentEditor/memoryMaps/memoryMapsVisualizer/fieldgraphitem.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: fieldgraphitem.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 25.4.2012\r\n//\r\n// Description:\r\n// The graphical item that represents a bit field within a register.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef FIELDGRAPHITEM_H\r\n#define FIELDGRAPHITEM_H\r\n\r\n#include <editors/ComponentEditor/visualization/memoryvisualizationitem.h>\r\n\r\n#include <IPXACTmodels/Component/Field.h>\r\n\r\n#include <QSharedPointer>\r\n\r\nclass ExpressionParser;\r\n//-----------------------------------------------------------------------------\r\n//! The graphical item that represents a bit field within a register.\r\n//-----------------------------------------------------------------------------\r\nclass FieldGraphItem : public MemoryVisualizationItem\r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\r\n\t/*!\r\n     *  The constructor.\r\n\t *\r\n\t *    @param [in] field               The field to visualize.\r\n     *    @param [in] expressionParser    Parser for expressions in fields.\r\n\t *    @param [in] parent              The parent graph item.\r\n\t */\r\n\tFieldGraphItem(QSharedPointer<Field> field, QSharedPointer<ExpressionParser> expressionParser,\r\n        QGraphicsItem* parent);\r\n\r\n\t//! The destructor\r\n\tvirtual ~FieldGraphItem() = default;\r\n\r\n    //! No copying\r\n    FieldGraphItem(const FieldGraphItem& other) = delete;\r\n    FieldGraphItem& operator=(const FieldGraphItem& other) = delete;\r\n\r\n    //! Updates the labels and tooltip for the item.\r\n    virtual void updateDisplay() override final;\r\n\r\n\t/*!\r\n     *  Get the offset of the item. \r\n\t *\r\n\t *    @return int The offset of the item from the parent item's base address.\r\n\t */\r\n\tvirtual quint64 getOffset() const override final;\r\n\r\n\t/*!\r\n     *  Get the last bit contained in the field.\r\n\t *\r\n\t *    @return The last bit.\r\n\t */\r\n\tvirtual quint64 getLastAddress() const override final;\r\n\r\n\t/*!\r\n     *  Get the bit width of the item.\r\n\t * \r\n\t *    @return The bit width of the item.\r\n\t */\r\n\tvirtual int getBitWidth() const override final;\r\n\r\n\t/*!\r\n     *  Get number of bits the addressable unit contains.\r\n\t *\r\n\t *    @return The size of least addressable unit.\r\n\t */\r\n\tvirtual unsigned int getAddressUnitSize() const override final;\r\n \r\n\t/*!\r\n     *  Set the width for the item.\r\n\t *\r\n\t *    @param [in] width The new width of the item.\r\n\t */\r\n    virtual void setWidth(qreal width) override final;\r\n\r\n\t/*!\r\n     *  Sets the first non-overlapping address to display.\r\n\t *\r\n\t *    @param [in] The first address to set.\r\n\t */\r\n    virtual void setDisplayOffset(quint64 const& address) override final;\r\n\r\n\r\n    /*!\r\n     *  Sets the last non-overlapping address to display.\r\n     *\r\n     *    @param [in] The last address to set.\r\n     */\r\n    virtual void setDisplayLastAddress(quint64 const& address) override final;\r\n    \r\n    /*!\r\n     *  Checks if the item is to be used in the visualization.\r\n     *\r\n     *    @return True, if the item should be used, otherwise false.\r\n     */\r\n    virtual bool isPresent() const override final;\r\n\r\n    //! Re-layouts the child items.\r\n    virtual void redoChildLayout() override;\r\n\r\nprotected:\r\n     \r\n    //! Set the item into conflicted (overlapping memory) state.\r\n     virtual void setConflicted(bool conflicted) final;\r\n\r\nprivate:\r\n\r\n\t//! The field being visualized.\r\n\tQSharedPointer<Field> field_;\r\n};\r\n\r\n#endif // FIELDGRAPHITEM_H\r\n"
  },
  {
    "path": "editors/ComponentEditor/memoryMaps/memoryMapsVisualizer/memorymapgraphitem.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: memorymapgraphitem.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 17.12.2012\r\n//\r\n// Description:\r\n// The graph item that visualizes a local memory map within address space.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"memorymapgraphitem.h\"\r\n\r\n#include <editors/ComponentEditor/visualization/memorygapitem.h>\r\n\r\n#include <IPXACTmodels/Component/MemoryBlockBase.h>\r\n#include <IPXACTmodels/Component/AddressBlock.h>\r\n\r\n#include <common/KactusColors.h>\r\n\r\n#include <QBrush>\r\n#include <QStringBuilder>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryMapGraphItem::MemoryMapGraphItem()\r\n//-----------------------------------------------------------------------------\r\nMemoryMapGraphItem::MemoryMapGraphItem(QSharedPointer<MemoryMap> parentMemoryMap,\r\n    QSharedPointer<MemoryMapBase> memoryRemap,\r\n    QSharedPointer<ExpressionParser> expressionParser,\r\n    QGraphicsItem* parent):\r\nMemoryVisualizationItem(expressionParser, parent),\r\n    memoryMap_(memoryRemap),\r\n    parentMemoryMap_(parentMemoryMap)\r\n{\r\n    Q_ASSERT(memoryMap_);\r\n\r\n    updateDisplay();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryMapGraphItem::updateDisplay()\r\n//-----------------------------------------------------------------------------\r\nvoid MemoryMapGraphItem::updateDisplay()\r\n{\r\n    setName(memoryMap_->name());\r\n\r\n    quint64 offset = getOffset();\r\n    quint64 lastAddress = getLastAddress();\r\n\r\n    setDisplayOffset(offset);\r\n    setDisplayLastAddress(lastAddress);\r\n  \r\n    if (isPresent())\r\n    {\r\n        QBrush defaultBrush(KactusColors::MEM_MAP_COLOR);\r\n        setDefaultBrush(defaultBrush);\r\n    }\r\n    else\r\n    {\r\n        QBrush nonPresentBrush(Qt::lightGray);\r\n        setDefaultBrush(nonPresentBrush);\r\n    }\r\n\r\n    // Set tooltip to show addresses in hexadecimals.\r\n    const int BIT_WIDTH = getBitWidth();\r\n    setToolTip(\"<b>Name: </b>\" % memoryMap_->name() % \"<br>\" %\r\n        \"<b>AUB: </b>\" % QString::number(getAddressUnitSize()) % \"<br>\" %\r\n        \"<b>First address: </b>\" % toHexString(offset, BIT_WIDTH) % \"<br>\" %\r\n        \"<b>Last address: </b>\" % toHexString(lastAddress, BIT_WIDTH));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryMapGraphItem::getOffset()\r\n//-----------------------------------------------------------------------------\r\nquint64 MemoryMapGraphItem::getOffset() const \r\n{\r\n    if (childItems_.isEmpty())\r\n    {\r\n        return 0;\r\n    }\r\n\r\n    quint64 offset = childItems_.last()->getOffset();\r\n    for (auto const& child : childItems_)\r\n    {\r\n        if (dynamic_cast<MemoryGapItem const*>(child) == nullptr)\r\n        {\r\n            offset = qMin(child->getOffset(), offset);  \r\n        }\r\n    }\r\n\r\n    return offset;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryMapGraphItem::getBitWidth()\r\n//-----------------------------------------------------------------------------\r\nint MemoryMapGraphItem::getBitWidth() const \r\n{\r\n    int width = 0;\r\n    for (auto const& child : childItems_)\r\n    {\r\n        if (dynamic_cast<MemoryGapItem const*>(child) == nullptr)\r\n        {\r\n            width = qMax(child->getBitWidth(), width);  \r\n        }\r\n    }\r\n    return width;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryMapGraphItem::getAddressUnitSize()\r\n//-----------------------------------------------------------------------------\r\nunsigned int MemoryMapGraphItem::getAddressUnitSize() const \r\n{\r\n    return parseExpression(parentMemoryMap_->getAddressUnitBits());\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryMapGraphItem::getLastAddress()\r\n//-----------------------------------------------------------------------------\r\nquint64 MemoryMapGraphItem::getLastAddress() const \r\n{\r\n    quint64 lastAddress = 0;\r\n    for (auto const& child : childItems_)\r\n    {\r\n        if (dynamic_cast<MemoryGapItem const*>(child) == 0)\r\n        {\r\n            lastAddress = qMax(child->getLastAddress(), lastAddress);  \r\n        }\r\n    }\r\n\r\n    return lastAddress;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryMapGraphItem::itemTotalWidth()\r\n//-----------------------------------------------------------------------------\r\nqreal MemoryMapGraphItem::itemTotalWidth() const \r\n{\r\n    return VisualizerItem::DEFAULT_WIDTH;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryMapGraphItem::isPresent()\r\n//-----------------------------------------------------------------------------\r\nbool MemoryMapGraphItem::isPresent() const\r\n{\r\n    return memoryMap_->getIsPresent().isEmpty() || parseExpression(memoryMap_->getIsPresent()) == 1;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: memorymapgraphitem::getMemoryMap()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<MemoryMapBase> MemoryMapGraphItem::getMemoryMap() const\r\n{\r\n    return memoryMap_;\r\n}\r\n"
  },
  {
    "path": "editors/ComponentEditor/memoryMaps/memoryMapsVisualizer/memorymapgraphitem.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: memorymapgraphitem.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 17.04.2012\r\n//\r\n// Description:\r\n// The graphical item that represents one memory map.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef MEMORYMAPGRAPHITEM_H\r\n#define MEMORYMAPGRAPHITEM_H\r\n\r\n#include <editors/ComponentEditor/visualization/memoryvisualizationitem.h>\r\n\r\n#include <IPXACTmodels/Component/MemoryMap.h>\r\n#include <IPXACTmodels/Component/MemoryMapBase.h>\r\n\r\n#include <QSharedPointer>\r\n#include <QGraphicsItem>\r\n\r\nclass ExpressionParser;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! The graphical item that represents one memory map.\r\n//-----------------------------------------------------------------------------\r\nclass MemoryMapGraphItem : public MemoryVisualizationItem\r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\r\n    /*!\r\n\t *  The constructor.\r\n\t *\r\n\t *    @param [in] parentMemoryMap     The parent memory map of the memory remap.\r\n\t *    @param [in] memoryRemap         The memory remap to be visualized.\r\n\t *    @param [in] parent              Pointer to the owner of this graphics item.\r\n\t */\r\n\tMemoryMapGraphItem(QSharedPointer<MemoryMap> parentMemoryMap,\r\n        QSharedPointer<MemoryMapBase> memoryRemap,\r\n        QSharedPointer<ExpressionParser> expressionParser,\r\n        QGraphicsItem* parent = 0);\r\n\r\n\t//! The destructor.\r\n\tvirtual ~MemoryMapGraphItem() = default;\r\n\r\n    //! No copying.\r\n    MemoryMapGraphItem(const MemoryMapGraphItem& other) = delete;\r\n\r\n    //! No assignment.\r\n    MemoryMapGraphItem& operator=(const MemoryMapGraphItem& other) = delete;\r\n        \r\n    //! Updates the labels and tooltip for the item.\r\n    virtual void updateDisplay() override final;\r\n\r\n\t/*!\r\n     *  Get the offset of the item. \r\n\t *\r\n\t *    @return int The offset of the item from the parent item's base address.\r\n\t */\r\n\tvirtual quint64 getOffset() const override final;\r\n\r\n\t/*!\r\n     *  Get the last address contained in the item.\r\n\t *\r\n\t *    @return The last address.\r\n\t */\r\n\tvirtual quint64 getLastAddress() const override final;\r\n\r\n\t/*!\r\n     *  Get the bit width of the item.\r\n\t * \r\n\t *    @return The bit width of the item.\r\n\t */\r\n\tvirtual int getBitWidth() const override final;\r\n\r\n\t/*!\r\n     *  Get number of bits the addressable unit contains.\r\n\t *\r\n\t *    @return The size of least addressable unit.\r\n\t */\r\n\tvirtual unsigned int getAddressUnitSize() const override;\r\n\r\n\t/*!\r\n     *  Get the width of the item.\r\n\t *\r\n\t * This width is affected by the item's children so if children grow this width grows accordingly.\r\n\t *\r\n\t *    @return The width of the item and it's sub-items.\r\n\t */\r\n\tvirtual qreal itemTotalWidth() const override final;\r\n       \r\n    /*!\r\n     *  Checks if the item is to be used in the visualization.\r\n     *\r\n     *    @return True, if the item should be used, otherwise false.\r\n     */\r\n    virtual bool isPresent() const override final;\r\n\r\n\r\nprotected:\r\n\r\n    /*!\r\n     *  Get the displayed memory remap.\r\n     *\r\n     *    @return The displayed memory remap.\r\n     */\r\n    QSharedPointer<MemoryMapBase> getMemoryMap() const;\r\n\r\nprivate:\r\n\r\n\t//! Pointer to the memory remap that is shown\r\n    QSharedPointer<MemoryMapBase> memoryMap_;\r\n\r\n    //! Pointer to the parent of the shown memory remap.\r\n    QSharedPointer<MemoryMap> parentMemoryMap_;\r\n\r\n};\r\n\r\n#endif // MEMORYMAPGRAPHITEM_H\r\n"
  },
  {
    "path": "editors/ComponentEditor/memoryMaps/memoryMapsVisualizer/memorymapscene.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: memorymapscene.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 17.04.2012\r\n//\r\n// Description:\r\n// The graphics scene that contains the memory map graphics items.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"memorymapscene.h\"\r\n#include \"memorymapgraphitem.h\"\r\n\r\n#include <editors/ComponentEditor/memoryMaps/memoryMapsVisualizer/memorymapgraphitem.h>\r\n\r\n#include <QRectF>\r\n\r\n#include <QDebug>\r\n\r\nnamespace\r\n{\r\n    const unsigned int ITEM_SPACING = 10;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryMapScene::MemoryMapScene()\r\n//-----------------------------------------------------------------------------\r\nMemoryMapScene::MemoryMapScene(QObject *parent):\r\nQGraphicsScene(parent),\r\nmemGraphItems_(),\r\nwidth_(VisualizerItem::DEFAULT_WIDTH)\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryMapScene::addMemGraphItem()\r\n//-----------------------------------------------------------------------------\r\nvoid MemoryMapScene::addMemGraphItem( MemoryMapGraphItem* memGraphItem )\r\n{\r\n\tQ_ASSERT(memGraphItem);\r\n\r\n    qreal yCoordinate = 0;\r\n\r\n    bool isFirstItem = memGraphItems_.isEmpty();\r\n    if (isFirstItem == false)\r\n    {   \r\n        auto lastItem = memGraphItems_.last();\r\n        yCoordinate = lastItem->mapToScene(lastItem->itemTotalRect().bottomLeft()).y() + ITEM_SPACING;\r\n    }\r\n\r\n    memGraphItem->setPos(0, yCoordinate);\r\n    memGraphItem->setWidth(width_);\r\n\r\n    addItem(memGraphItem);\r\n    memGraphItems_.append(memGraphItem);\r\n\r\n    connect(memGraphItem, SIGNAL(expandStateChanged()), this, SLOT(rePosition()), Qt::UniqueConnection);\r\n\r\n    // Update scene rect height.   \r\n    QRectF sceneArea = sceneRect();\r\n\r\n    if (isFirstItem)\r\n    {\r\n        sceneArea = itemsBoundingRect();\r\n    }\r\n\r\n    sceneArea.setBottom(memGraphItem->rect().bottom());\r\n\r\n    setSceneRect(sceneArea);\r\n    invalidate();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryMapScene::removeMemGraphItem()\r\n//-----------------------------------------------------------------------------\r\nvoid MemoryMapScene::removeMemGraphItem( MemoryMapGraphItem* memGraphItem )\r\n{\r\n\tQ_ASSERT(memGraphItem);\r\n        \r\n    removeItem(memGraphItem);\r\n    memGraphItems_.removeAll(memGraphItem);\r\n\r\n    disconnect(memGraphItem, SIGNAL(expandStateChanged()), this, SLOT(rePosition()));\r\n\r\n    rePosition();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryMapScene::rePosition()\r\n//-----------------------------------------------------------------------------\r\nvoid MemoryMapScene::rePosition()\r\n{\r\n\tqreal yCoordinate = 0;\r\n\r\n\tfor (auto memMap : memGraphItems_)\r\n    {        \r\n\t\tmemMap->setPos(0, yCoordinate);\r\n        yCoordinate += memMap->itemTotalRect().bottom() + ITEM_SPACING;\r\n\t}\r\n\r\n\t// Update scene rect height.   \r\n    QRectF sceneArea = sceneRect();\r\n    sceneArea.setBottom(yCoordinate);\r\n\r\n    setSceneRect(sceneArea);\r\n\tinvalidate();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryMapScene::setWidth()\r\n//-----------------------------------------------------------------------------\r\nvoid MemoryMapScene::setWidth(int width)\r\n{\r\n    int newWidth = width - MemoryVisualizationItem::CHILD_INDENTATION;\r\n\r\n    if (width <= VisualizerItem::DEFAULT_WIDTH || width_ == newWidth)\r\n    {\r\n        return;\r\n    }\r\n\r\n    width_ = newWidth;\r\n\r\n    for (auto memMap : memGraphItems_)\r\n    {\r\n        memMap->setWidth(width_);\r\n    }\r\n\r\n    // Update scene rect width.\r\n    QRectF sceneArea = sceneRect();\r\n    sceneArea.setWidth(width);\r\n    setSceneRect(sceneArea);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryMapScene::wheelEvent()\r\n//-----------------------------------------------------------------------------\r\nvoid MemoryMapScene::wheelEvent(QGraphicsSceneWheelEvent * wheelEvent)\r\n{   \r\n    if (wheelEvent->modifiers() & Qt::ControlModifier)\r\n    {\r\n        //! Scrolling sensitivity. Bigger value results in smaller steps.\r\n        const int WHEEL_SENSITIVITY = 6;\r\n\r\n        int width = sceneRect().width() + wheelEvent->delta() / WHEEL_SENSITIVITY;\r\n        setWidth(width);    \r\n        wheelEvent->accept();\r\n    }\r\n    else\r\n    {\r\n        QGraphicsScene::wheelEvent(wheelEvent);\r\n    }\r\n}\r\n"
  },
  {
    "path": "editors/ComponentEditor/memoryMaps/memoryMapsVisualizer/memorymapscene.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: memorymapscene.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 17.04.2012\r\n//\r\n// Description:\r\n// The graphics scene that contains the memory map graphics items.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef MEMORYMAPSCENE_H\r\n#define MEMORYMAPSCENE_H\r\n\r\n#include <IPXACTmodels/Component/MemoryMap.h>\r\n\r\n#include <QGraphicsScene>\r\n#include <QVector>\r\n#include <QSharedPointer>\r\n\r\nclass MemoryMapGraphItem;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! The graphics scene that contains the memory map graphics items.\r\n//-----------------------------------------------------------------------------\r\nclass MemoryMapScene : public QGraphicsScene\r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\r\n\t/*!\r\n     *  The constructor.\r\n\t *\r\n\t *    @param [in] parent  Pointer to the owner of the graphics scene.\r\n\t */\r\n\texplicit MemoryMapScene(QObject *parent);\r\n\t\r\n\t//! The destructor.\r\n\tvirtual ~MemoryMapScene() = default;\r\n\r\n    //! No copying.\r\n    MemoryMapScene(const MemoryMapScene& other) = delete;\r\n\r\n    //! No assignment.\r\n    MemoryMapScene& operator=(const MemoryMapScene& other) = delete;\r\n\r\n\t/*!\r\n     *  Add a new memory map graph item to the scene.\r\n\t *\r\n\t *    @param [in] memGraphItem    Pointer to the item.\r\n\t */\r\n\tvoid addMemGraphItem(MemoryMapGraphItem* memGraphItem);\r\n\r\n\t/*!\r\n     *  Remove a memory map graph item from the scene.\r\n\t *\r\n\t *    @param [in] memGraphItem    Pointer to the item to remove.\r\n\t */\r\n\tvoid removeMemGraphItem(MemoryMapGraphItem* memGraphItem);\r\n\r\n\t/*!\r\n     *  Set the scene width.\r\n\t *\r\n     *    @param [in] width   Width to set.\r\n\t */\r\n    void setWidth(int width);\r\n\r\npublic slots:\r\n\r\n    /*!\r\n     *  Reposition the memory map graphs items in the scene.\r\n\t */\r\n\tvoid rePosition();\r\n\r\nprotected:\r\n    \r\n    //! Resizes memory map when user turns the mouse wheel.\r\n    virtual void wheelEvent(QGraphicsSceneWheelEvent * wheelEvent) override final;\r\n\r\nprivate:\t\r\n\r\n\t//! Contains the graph items for memory maps.\r\n\tQVector<MemoryMapGraphItem*> memGraphItems_;\r\n\r\n    //! Width of top (memory map) items.\r\n    int width_;\r\n};\r\n\r\n#endif // MEMORYMAPSCENE_H\r\n"
  },
  {
    "path": "editors/ComponentEditor/memoryMaps/memoryMapsVisualizer/memorymapsvisualizer.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: memorymapsvisualizer.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 17.04.2012\r\n//\r\n// Description:\r\n// A widget to visualize a set of memory maps.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"memorymapsvisualizer.h\"\r\n#include <editors/ComponentEditor/memoryMaps/memoryMapsVisualizer/memorymapview.h>\r\n#include <editors/ComponentEditor/memoryMaps/memoryMapsVisualizer/memorymapscene.h>\r\n#include <editors/ComponentEditor/memoryMaps/memoryMapsVisualizer/memorymapgraphitem.h>\r\n\r\n#include <common/graphicsItems/visualizeritem.h>\r\n\r\n#include <common/widgets/summaryLabel/summarylabel.h>\r\n\r\n#include <QVBoxLayout>\r\n#include <QPointF>\r\n#include <QApplication>\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryMapsVisualizer::MemoryMapsVisualizer()\r\n//-----------------------------------------------------------------------------\r\nMemoryMapsVisualizer::MemoryMapsVisualizer(QWidget *parent):\r\nItemVisualizer(parent),\r\nview_(new MemoryMapView(this)),\r\nscene_(new MemoryMapScene(this)),\r\nmemGraphItems_()\r\n{\r\n\t// display a label on top the table\r\n\tSummaryLabel* visualizationLabel = new SummaryLabel(tr(\"Memory maps visualization\"), this);\r\n\r\n\tQVBoxLayout* layout = new QVBoxLayout(this);\r\n\tlayout->addWidget(visualizationLabel, 0, Qt::AlignCenter);\r\n\tlayout->addWidget(view_);\r\n\tlayout->setContentsMargins(0, 0, 0, 0);\r\n\r\n\tview_->setAlignment(Qt::AlignLeft | Qt::AlignTop);\r\n\tview_->setScene(scene_);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryMapsVisualizer::addMemoryMapItem()\r\n//-----------------------------------------------------------------------------\r\nvoid MemoryMapsVisualizer::addMemoryMapItem( MemoryMapGraphItem* memMapItem ) \r\n{\r\n    memGraphItems_.append(memMapItem);\r\n\r\n\tscene_->addMemGraphItem(memMapItem);\r\n\r\n\tQPointF position = memMapItem->pos();\r\n\tview_->centerOn(position.x() - MemoryVisualizationItem::CHILD_INDENTATION, position.y());\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryMapsVisualizer::removeMemoryMapItem()\r\n//-----------------------------------------------------------------------------\r\nvoid MemoryMapsVisualizer::removeMemoryMapItem( MemoryMapGraphItem* memMapItem )\r\n{\r\n    memGraphItems_.removeAll(memMapItem);\r\n\r\n\tscene_->removeMemGraphItem(memMapItem);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryMapsVisualizer::minimumSizeHint()\r\n//-----------------------------------------------------------------------------\r\nQSize MemoryMapsVisualizer::minimumSizeHint() const\r\n{\r\n\treturn QSize(VisualizerItem::DEFAULT_WIDTH + 80, VisualizerItem::DEFAULT_HEIGHT * 2);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryMapsVisualizer::sizeHint()\r\n//-----------------------------------------------------------------------------\r\nQSize MemoryMapsVisualizer::sizeHint() const\r\n{\r\n\treturn minimumSizeHint();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryMapsVisualizer::redoLayout()\r\n//-----------------------------------------------------------------------------\r\nvoid MemoryMapsVisualizer::redoLayout()\r\n{\r\n    scene_->rePosition();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryMapsVisualizer::showEvent()\r\n//-----------------------------------------------------------------------------\r\nvoid MemoryMapsVisualizer::showEvent(QShowEvent* event)\r\n{\r\n    QWidget::showEvent(event);\r\n    \r\n    QApplication::setOverrideCursor(Qt::WaitCursor);\r\n\r\n    emit displayed();\r\n\r\n    for (MemoryMapGraphItem* memoryMap : memGraphItems_)\r\n    {\r\n        if (memoryMap->isPresent())\r\n        {\r\n            memoryMap->updateDisplay();\r\n        }\r\n    }\r\n    \r\n    redoLayout();\r\n\r\n    QApplication::restoreOverrideCursor();\r\n}\r\n"
  },
  {
    "path": "editors/ComponentEditor/memoryMaps/memoryMapsVisualizer/memorymapsvisualizer.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: memorymapsvisualizer.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 17.04.2012\r\n//\r\n// Description:\r\n// A widget to visualize a set of memory maps.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef MEMORYMAPSVISUALIZER_H\r\n#define MEMORYMAPSVISUALIZER_H\r\n\r\n#include <editors/ComponentEditor/itemvisualizer.h>\r\n\r\n#include <IPXACTmodels/Component/Component.h>\r\n#include <IPXACTmodels/Component/MemoryMap.h>\r\n\r\n#include <QWidget>\r\n#include <QList>\r\n#include <QSharedPointer>\r\n#include <QSize>\r\n\r\nclass MemoryMapView;\r\nclass MemoryMapScene;\r\nclass MemoryMapGraphItem;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! The widget to visualize a set of memory maps.\r\n//-----------------------------------------------------------------------------\r\nclass MemoryMapsVisualizer : public ItemVisualizer\r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\r\n\t/*! The constructor\r\n\t *\r\n\t *    @param [in] parent    Pointer to the owner of the visualizer widget.\r\n\t *\r\n\t*/\r\n\texplicit MemoryMapsVisualizer(QWidget *parent = 0);\r\n\t\r\n\t//! The destructor\r\n\tvirtual ~MemoryMapsVisualizer() = default;\r\n\r\n    //! No copying\r\n    MemoryMapsVisualizer(const MemoryMapsVisualizer& other) = delete;\r\n\r\n    //! No assignment\r\n    MemoryMapsVisualizer& operator=(const MemoryMapsVisualizer& other) = delete;\r\n\r\n\t/*! Add a new memory map graphics item to the scene.\r\n\t *\r\n\t *    @param [in] memMapItem    Pointer to the graphics item.\r\n\t*/\r\n\tvoid addMemoryMapItem(MemoryMapGraphItem* memMapItem);\r\n\r\n\t/*! Remove a memory map graphics item from the scene.\r\n\t *\r\n\t *    @param [in] memMapItem    Pointer to the graphics item.\r\n\t*/\r\n\tvoid removeMemoryMapItem(MemoryMapGraphItem* memMapItem);\r\n\r\n\t/*! The minimum size hint for the visualizer.\r\n\t *\r\n\t *    @return  The minimum size hint.\r\n\t*/\r\n\tvirtual QSize minimumSizeHint() const;\r\n\r\n\t/*! The size hint for the visualizer.\r\n\t *\r\n\t *    @return The size hint.\r\n\t*/\r\n\tvirtual QSize sizeHint() const;\r\n\r\npublic slots:\r\n\r\n    //! Handler for events requiring a redo of the layout.\r\n    void redoLayout();\r\n\r\nprotected:\r\n\r\n    //! Handler for events when the widget is shown.\r\n    virtual void showEvent(QShowEvent* event);\r\n\r\nprivate:\r\n\t\r\n\r\n\t//! The view to display the items.\r\n\tMemoryMapView* view_;\r\n\r\n\t//! The scene that contains the memory map items.\r\n\tMemoryMapScene* scene_;\r\n\r\n    //! Contains the graph items for memory maps.\r\n    QList<MemoryMapGraphItem*> memGraphItems_;\r\n};\r\n\r\n#endif // MEMORYMAPSVISUALIZER_H\r\n"
  },
  {
    "path": "editors/ComponentEditor/memoryMaps/memoryMapsVisualizer/memorymapview.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: memorymapview.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 17.04.2012\r\n//\r\n// Description:\r\n// The graphics view that displays the memory map graphics items.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"memorymapview.h\"\r\n#include \"memorymapscene.h\"\r\n#include <common/graphicsItems/visualizeritem.h>\r\n\r\n#include <QMouseEvent>\r\n#include <QRect>\r\n#include <QResizeEvent>\r\n#include <QScrollBar>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryMapView()\r\n//-----------------------------------------------------------------------------\r\nMemoryMapView::MemoryMapView(QWidget *parent):\r\nQGraphicsView(parent)\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ~MemoryMapView()\r\n//-----------------------------------------------------------------------------\r\nMemoryMapView::~MemoryMapView()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: resizeEvent()\r\n//-----------------------------------------------------------------------------\r\nvoid MemoryMapView::resizeEvent(QResizeEvent *event)\r\n{\r\n    QGraphicsView::resizeEvent(event);\r\n   \r\n    if (event->size().width() != event->oldSize().width())\r\n    {\r\n        MemoryMapScene* memoryscene = dynamic_cast<MemoryMapScene*>(scene());\r\n        Q_ASSERT(memoryscene);\r\n        memoryscene->setWidth(event->size().width());\r\n        event->accept();\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: mousePressEvent()\r\n//-----------------------------------------------------------------------------\r\nvoid MemoryMapView::mousePressEvent(QMouseEvent* mouseEvent)\r\n{\r\n    // Scrolling to left with side button.\r\n    if (mouseEvent->button() == Qt::XButton1)        \r\n    {\r\n        if (horizontalScrollBar() != 0)\r\n        {\r\n            int sliderPosition = horizontalScrollBar()->value();\r\n            int step = -horizontalScrollBar()->singleStep();\r\n            horizontalScrollBar()->setSliderPosition(sliderPosition + step);\r\n        }\r\n    }\r\n\r\n    // Scrolling to right with side button.\r\n    else if (mouseEvent->button() == Qt::XButton2)\r\n    {\r\n        if (horizontalScrollBar() != 0)\r\n        {\r\n            int sliderPosition = horizontalScrollBar()->value();\r\n            int step = horizontalScrollBar()->singleStep();\r\n            horizontalScrollBar()->setSliderPosition(sliderPosition + step);\r\n        }\r\n    }\r\n\r\n    // Normal operation.\r\n    else\r\n    {\r\n        QGraphicsView::mousePressEvent(mouseEvent);\r\n    }\r\n}"
  },
  {
    "path": "editors/ComponentEditor/memoryMaps/memoryMapsVisualizer/memorymapview.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: memorymapview.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 17.04.2012\r\n//\r\n// Description:\r\n// The graphics view that displays the memory map graphics items.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef MEMORYMAPVIEW_H\r\n#define MEMORYMAPVIEW_H\r\n\r\n#include <QGraphicsView>\r\n\r\n//-----------------------------------------------------------------------------\r\n//! The graphics view that displays the memory map graphics items.\r\n//-----------------------------------------------------------------------------\r\nclass MemoryMapView : public QGraphicsView\r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\r\n\t/*!\r\n     *  The constructor.\r\n\t *\r\n\t *    @param [in] parent  The pointer to the owner of the graphics view.\r\n\t */\r\n\tMemoryMapView(QWidget *parent);\r\n\t\r\n\t//! The destructor.\r\n\tvirtual ~MemoryMapView();\r\n\r\nprotected:\r\n\r\n    //! Event handler for resizing.\r\n    virtual void resizeEvent(QResizeEvent* event);\r\n\r\n    //! Handler for mouse press events.\r\n    void mousePressEvent(QMouseEvent* mouseEvent);\r\n\r\nprivate:\r\n\t\r\n\t//! No copying.\r\n\tMemoryMapView(const MemoryMapView& other);\r\n\r\n\t//! No assignment.\r\n\tMemoryMapView& operator=(const MemoryMapView& other);\r\n};\r\n\r\n#endif // MEMORYMAPVIEW_H\r\n"
  },
  {
    "path": "editors/ComponentEditor/memoryMaps/memoryMapsVisualizer/registerfilegraphitem.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: registerfilegraphitem.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Dan Chianucci\n// Date: 19.06.2018\n//\n// Description:\n// Graphical item to represent register file in visualization.\n//-----------------------------------------------------------------------------\n#include \"registerfilegraphitem.h\"\n\n#include <KactusAPI/include/ExpressionParser.h>\n#include <editors/ComponentEditor/visualization/memorygapitem.h>\n\n#include <common/KactusColors.h>\n\n#include <QStringBuilder>\n#include <QBrush>\n\n//-----------------------------------------------------------------------------\n// Function: RegisterFileGraphItem::RegisterFileGraphItem()\n//-----------------------------------------------------------------------------\nRegisterFileGraphItem::RegisterFileGraphItem(QSharedPointer<RegisterFile> regFile,\n    QSharedPointer<ExpressionParser> expressionParser,\n    QGraphicsItem *parent) :\n    MemoryVisualizationItem(expressionParser, parent),\n    regFile_(regFile)\n{\n    Q_ASSERT(regFile_);    \n\n    setDefaultBrush(QBrush(KactusColors::REGISTER_FILE_COLOR));\n\n    updateDisplay();\n}\n\n//-----------------------------------------------------------------------------\n// Function: RegisterFileGraphItem::updateDisplay()\n//-----------------------------------------------------------------------------\nvoid RegisterFileGraphItem::updateDisplay()\n{\n    QString name = regFile_->name();\n    \n    int dimension = parseExpression(regFile_->getDimension());\n    if (dimension > 0)\n    {\n        name.append(\"[\" % QString::number(dimension - 1) % \":0]\");\n    }\n\n    quint64 offset = getOffset();\n    quint64 lastAddress = getLastAddress();\n\n    setName(name);\n    setDisplayOffset(offset);\n    setDisplayLastAddress(lastAddress);\n\n\n    const int BIT_WIDTH = getBitWidth();\n    // Set tooltip to show addresses in hexadecimals.\n    setToolTip(\"<b>Name: </b>\" % regFile_->name() % \"<br>\" %\n        \"<b>AUB: </b>\" % QString::number(getAddressUnitSize()) % \"<br>\" %\n        \"<b>First address: </b>\" % toHexString(offset, BIT_WIDTH) % \"<br>\" %\n        \"<b>Last address: </b>\" % toHexString(lastAddress, BIT_WIDTH));\n}\n\n//-----------------------------------------------------------------------------\n// Function: RegisterFileGraphItem::getOffset()\n//-----------------------------------------------------------------------------\nquint64 RegisterFileGraphItem::getOffset() const\n{    \n    // the address block's offset\n    auto parent = static_cast<MemoryVisualizationItem*>(parentItem());\n    Q_ASSERT(parent);\n    quint64 parentOffset = parent->getOffset();\n    \n    // the register offset from the address block\n    quint64 regFileOffset = parseExpression(regFile_->getAddressOffset());\n\n    // the total offset is the address block's offset added with register's offset\n    return parentOffset + regFileOffset;\n}\n\n//-----------------------------------------------------------------------------\n// Function: RegisterFileGraphItem::getLastAddress()\n//-----------------------------------------------------------------------------\nquint64 RegisterFileGraphItem::getLastAddress() const\n{\n    quint64 base = getOffset();\n    quint64 range = parseExpression(regFile_->getRange());\n    quint64 dimension = qMax(quint64(1), parseExpression(regFile_->getDimension()));\n\n    quint64 lastAddr = base + range * dimension;\n\n    if (lastAddr == 0)\n    {\n        return 0;\n    }\n\n    return lastAddr - 1;\n}\n\n//-----------------------------------------------------------------------------\n// Function: RegisterFileGraphItem::getBitWidth()\n//-----------------------------------------------------------------------------\nint RegisterFileGraphItem::getBitWidth() const\n{\n    auto parent = static_cast<MemoryVisualizationItem*>(parentItem());\n    return parent->getBitWidth();\n}\n\n//-----------------------------------------------------------------------------\n// Function: RegisterFileGraphItem::getAddressUnitSize()\n//-----------------------------------------------------------------------------\nunsigned int RegisterFileGraphItem::getAddressUnitSize() const\n{\n    auto parent = static_cast<MemoryVisualizationItem*>(parentItem());\n    Q_ASSERT(parent);\n    return parent->getAddressUnitSize();\n}\n\n//-----------------------------------------------------------------------------\n// Function: RegisterFileGraphItem::isPresent()\n//-----------------------------------------------------------------------------\nbool RegisterFileGraphItem::isPresent() const\n{\n    return regFile_->getIsPresent().isEmpty() || parseExpression(regFile_->getIsPresent()) == 1;\n}\n"
  },
  {
    "path": "editors/ComponentEditor/memoryMaps/memoryMapsVisualizer/registerfilegraphitem.h",
    "content": "//-----------------------------------------------------------------------------\n// File: registerfilegraphitem.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Dan Chianucci\n// Date: 19.06.2018\n//\n// Description:\n// Graphical item to represent register file in visualization.\n//-----------------------------------------------------------------------------\n#ifndef REGISTERFILEGRAPHITEM_H\n#define REGISTERFILEGRAPHITEM_H\n\n#include <editors/ComponentEditor/visualization/memoryvisualizationitem.h>\n\n#include <IPXACTmodels/Component/RegisterFile.h>\n\n#include <QGraphicsItem>\n#include <QSharedPointer>\n\nclass MemoryVisualizationItem;\nclass ExpressionParser;\n\n\n//-----------------------------------------------------------------------------\n//! Graphical item to represent register file in visualization.\n//-----------------------------------------------------------------------------\nclass RegisterFileGraphItem : public MemoryVisualizationItem\n{\npublic:\n\n    /*!\n     * The constructor.\n     *\n     *    @param [in] regFile              The register file represented by the item.\n     *    @param [in] expressionParser     Parser for expressions.\n     *    @param [in] parent               The parent item.\n     */\n    RegisterFileGraphItem(QSharedPointer<RegisterFile> regFile,\n        QSharedPointer<ExpressionParser> expressionParser,\n        QGraphicsItem *parent);\n\n    //! The destructor.\n    virtual ~RegisterFileGraphItem() = default;\n\n    //! Disable copying.\n    RegisterFileGraphItem(const RegisterFileGraphItem& other) = delete;\n    RegisterFileGraphItem& operator=(const RegisterFileGraphItem& other) = delete;\n\n    //! Updates the labels and tooltip for the item.\n    virtual void updateDisplay() override final;\n\n    /*!\n    *  Get the offset of the item.\n    *\n    *    @return int The offset of the item from the parent item's base address.\n    */\n    virtual quint64 getOffset() const override final;\n\n    /*!\n    *  Get the last bit contained in the field.\n    *\n    *    @return The last bit.\n    */\n    virtual quint64 getLastAddress() const override final;\n\n    /*!\n    *  Get the bit width of the item.\n    *\n    *    @return The bit width of the item.\n    */\n    virtual int getBitWidth() const override final;\n\n    /*!\n    *  Get number of bits the addressable unit contains.\n    *\n    *    @return The size of least addressable unit.\n    */\n    virtual unsigned int getAddressUnitSize() const override final;\n\n    /*!\n    *  Checks if the item is to be used in the visualization.\n    *\n    *    @return True, if the item should be used, otherwise false.\n    */\n    virtual bool isPresent() const override final;\n\nprivate:\n\n    //! The register file being visualized.\n    QSharedPointer<RegisterFile> regFile_;\n\n};\n\n#endif // REGISTERFILEGRAPHITEM_H\n"
  },
  {
    "path": "editors/ComponentEditor/memoryMaps/memoryMapsVisualizer/registergraphitem.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: registergraphitem.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 24.04.2012\r\n//\r\n// Description:\r\n// The graphical item that represents one register.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"registergraphitem.h\"\r\n#include \"fieldgraphitem.h\"\r\n\r\n#include <editors/ComponentEditor/visualization/memoryvisualizationitem.h>\r\n#include <editors/ComponentEditor/visualization/fieldgapitem.h>\r\n\r\n#include <KactusAPI/include/ExpressionParser.h>\r\n\r\n#include <common/KactusColors.h>\r\n#include <common/graphicsItems/visualizeritem.h>\r\n\r\n#include <QBrush>\r\n#include <QStringBuilder>\r\n#include <QMapIterator>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: RegisterGraphItem::RegisterGraphItem()\r\n//-----------------------------------------------------------------------------\r\nRegisterGraphItem::RegisterGraphItem(QSharedPointer<Register> reg,\r\n    QSharedPointer<ExpressionParser> expressionParser, QGraphicsItem* parent):\r\nMemoryVisualizationItem(expressionParser, parent),\r\nregister_(reg)\r\n{\r\n\tQ_ASSERT(register_);\r\n\r\n\tsetDefaultBrush(QBrush(KactusColors::REGISTER_COLOR));\r\n\r\n    updateDisplay();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: RegisterGraphItem::updateDisplay()\r\n//-----------------------------------------------------------------------------\r\nvoid RegisterGraphItem::updateDisplay()\r\n{\r\n    QString name = register_->name();\r\n\r\n    int dimension = parseExpression(register_->getDimension());\r\n    if (dimension > 0)\r\n    {\r\n        name.append(\"[\" % QString::number(dimension - 1) % \":0]\");\r\n    }\r\n\r\n    quint64 offset = getOffset();\r\n    quint64 lastAddress = getLastAddress();\r\n\r\n    setName(name);\r\n    setDisplayOffset(offset);\r\n    setDisplayLastAddress(lastAddress);\r\n\r\n    // Set tooltip to show addresses in hexadecimals.\r\n    const int BIT_WIDTH = getBitWidth();\r\n    setToolTip(\"<b>Name: </b>\" % register_->name() % \"<br>\" %\r\n        \"<b>First address: </b>\" % toHexString(offset, BIT_WIDTH) % \"<br>\" %\r\n        \"<b>Last address: </b>\" % toHexString(lastAddress, BIT_WIDTH) % \"<br>\" %\r\n        \"<b>Size [bits]: </b>\" % QString::number(getBitWidth()));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: RegisterGraphItem::addChild()\r\n//-----------------------------------------------------------------------------\r\nvoid RegisterGraphItem::addChild(MemoryVisualizationItem* childItem)\r\n{\r\n    childItems_.insert(childItem->getOffset(), childItem);\r\n\r\n    childItem->setParentItem(this);    \r\n    childItem->setVisible(isExpanded());\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: RegisterGraphItem::removeChild()\r\n//-----------------------------------------------------------------------------\r\nvoid RegisterGraphItem::removeChild( MemoryVisualizationItem* childItem )\r\n{\r\n    quint64 offset = childItems_.key(childItem);\r\n\r\n    Q_ASSERT(childItems_.contains(offset));\r\n    childItems_.remove(offset, childItem);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: RegisterGraphItem::getOffset()\r\n//-----------------------------------------------------------------------------\r\nquint64 RegisterGraphItem::getOffset() const\r\n{\t\r\n\tMemoryVisualizationItem const* blockItem = static_cast<MemoryVisualizationItem const*>(parentItem());\r\n\tQ_ASSERT(blockItem);\r\n\tquint64 blockOffset = blockItem->getOffset();\r\n\r\n    quint64 regOffset = parseExpression(register_->getAddressOffset());\r\n\r\n\t// the total offset is the address block's offset added with register's offset\r\n\treturn blockOffset + regOffset;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: RegisterGraphItem::getLastAddress()\r\n//-----------------------------------------------------------------------------\r\nquint64 RegisterGraphItem::getLastAddress() const\r\n{\r\n    quint64 size = getSizeInAUB();\r\n\r\n    if (size == 0)\r\n    {\r\n        return 0;\r\n    }\r\n\r\n    // the last address contained in the register    \r\n    return getOffset() + size - 1;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: RegisterGraphItem::getBitWidth()\r\n//-----------------------------------------------------------------------------\r\nint RegisterGraphItem::getBitWidth() const\r\n{\r\n    return parseExpression(register_->getSize());\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: RegisterGraphItem::getAddressUnitSize()\r\n//-----------------------------------------------------------------------------\r\nunsigned int RegisterGraphItem::getAddressUnitSize() const \r\n{\r\n\tMemoryVisualizationItem const* addrBlock = static_cast<MemoryVisualizationItem const*>(parentItem());\r\n\tQ_ASSERT(addrBlock);\r\n\treturn addrBlock->getAddressUnitSize();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: RegisterGraphItem::setWidth()\r\n//-----------------------------------------------------------------------------\r\nvoid RegisterGraphItem::setWidth(qreal width)\r\n{\r\n    VisualizerItem::setWidth(width);\r\n\r\n    // Child width is adjusted according to width and number of bits.\r\n    repositionChildren();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: RegisterGraphItem::isPresent()\r\n//-----------------------------------------------------------------------------\r\nbool RegisterGraphItem::isPresent() const\r\n{\r\n    return register_->getIsPresent().isEmpty() || parseExpression(register_->getIsPresent()) == 1;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: RegisterGraphItem::repositionChildren()\r\n//-----------------------------------------------------------------------------\r\nvoid RegisterGraphItem::repositionChildren()\r\n{\r\n    unsigned int highestBitInUse = findHighestReservedBit();\r\n    const unsigned int BIT_WIDTH = highestBitInUse + 1;\r\n    const qreal PIXELS_PER_BIT = rect().width() / BIT_WIDTH;\r\n\r\n    for (auto current : childItems_)\r\n    {\r\n        bool present = current->isPresent();\r\n        current->setVisible(present && isExpanded());\r\n\r\n        if (present)\r\n        {\r\n            quint64 availableBits = BIT_WIDTH - current->getOffset();\r\n            quint64 childBitWidth = qMin(quint64(current->getBitWidth()), availableBits);\r\n\r\n            qreal width = qMax(1.0, PIXELS_PER_BIT * childBitWidth);\r\n            current->setWidth(width);\r\n\r\n            quint64 highestChildBit = current->getLastAddress();\r\n            qreal xPos = (highestBitInUse - highestChildBit) * PIXELS_PER_BIT;\r\n\r\n            current->setPos(QPointF(xPos, rect().bottom()));\r\n        }\r\n    }\r\n\r\n    resizeToContent();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: RegisterGraphItem::getSizeInAUB()\r\n//-----------------------------------------------------------------------------\r\nquint64 RegisterGraphItem::getSizeInAUB() const\r\n{\r\n    // how many bits one address unit takes\r\n    unsigned int addrUnit = getAddressUnitSize();\r\n\r\n    // prevent division by zero\r\n    if (addrUnit == 0)\r\n    {\r\n        addrUnit = 1;\r\n    }\r\n\r\n    // how many address unit are contained in the register\r\n    unsigned int bitSize = parseExpression(register_->getSize());\r\n    unsigned int size = bitSize / addrUnit;\r\n    if (size*addrUnit < bitSize) \r\n    {\r\n        ++size; //Round truncated number upwards\r\n    }\r\n\r\n    quint64 dimension = qMax(quint64(1), parseExpression(register_->getDimension()));\r\n\r\n    return dimension * size;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: RegisterGraphItem::getRegisterMSB()\r\n//-----------------------------------------------------------------------------\r\nunsigned int RegisterGraphItem::getRegisterMSB() const\r\n{\r\n    unsigned int registerMSB = 0;\r\n    \r\n    if (unsigned int registerSize = getBitWidth(); \r\n        registerSize != 0)\r\n    {\r\n        registerMSB = registerSize -1;\r\n    }\r\n\r\n    return registerMSB;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: RegisterGraphItem::findHighestReservedBit()\r\n//-----------------------------------------------------------------------------\r\nunsigned int RegisterGraphItem::findHighestReservedBit() const\r\n{\r\n    unsigned int highestBit = getRegisterMSB();\r\n\r\n    if (!childItems_.isEmpty())\r\n    {\r\n        for (MemoryVisualizationItem const* current: childItems_)\r\n        {\r\n            if (current->getLastAddress() > highestBit && current->isPresent())\r\n            {\r\n                highestBit = current->getLastAddress();\r\n            }\r\n        }\r\n    }\r\n\r\n    return highestBit;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: RegisterGraphItem::removeGapsAndSortChildren()\r\n//-----------------------------------------------------------------------------\r\nvoid RegisterGraphItem::removeGapsAndSortChildren()\r\n{\r\n    QMultiMap<quint64, MemoryVisualizationItem*> sortedMap;\r\n    for (auto item = childItems_.cbegin(); item != childItems_.cend(); ++item)\r\n    {\r\n        MemoryGapItem* gap = dynamic_cast<MemoryGapItem*>(*item);\r\n        if (gap)\r\n        {\r\n            delete gap;\r\n        }\r\n        else\r\n        {\r\n            sortedMap.insert((*item)->getOffset(), *item);\r\n        }\r\n    }\r\n\r\n    childItems_ = sortedMap;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: RegisterGraphItem::fillGapsBetweenChildren()\r\n//-----------------------------------------------------------------------------\r\nvoid RegisterGraphItem::fillGapsBetweenChildren()\r\n{\r\n    if (childItems_.isEmpty())\r\n    {\r\n        return;\r\n    }\r\n\r\n    auto parentMSB = getRegisterMSB();\r\n    quint64 highestBitHandled = 0;\r\n\r\n    // QMap sorts children by ascending offsets.\r\n    for (auto i = childItems_.begin(); i != childItems_.end(); ++i)\r\n    {\r\n        auto currentChild = i.value();\r\n        auto currentOffset = currentChild->getOffset();\r\n\r\n        if (currentChild->isPresent())\r\n        {\r\n            // Insert gap between fields only if they are not overlapping with a third field.\r\n            if (highestBitHandled < currentOffset)\r\n            {        \r\n                i = addMemoryGap(highestBitHandled, currentOffset - 1);\r\n                highestBitHandled = currentOffset;\r\n            }\r\n            else\r\n            {\r\n                highestBitHandled = qMax(highestBitHandled, currentChild->getLastAddress() + 1);\r\n            }\r\n        }\r\n    }\r\n\r\n    // Insert gap between the MSB of the register and the left-most item if needed.\r\n    if (highestBitHandled <= parentMSB)\r\n    {\r\n        addMemoryGap(highestBitHandled, parentMSB);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: RegisterGraphItem::emptySpaceBeforeChild()\r\n//-----------------------------------------------------------------------------\r\nbool RegisterGraphItem::emptySpaceBeforeChild(MemoryVisualizationItem const* current,\r\n    quint64 lastBitIndexInUse) const\r\n{\r\n    return current->getLastAddress() + 1 < lastBitIndexInUse;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: RegisterGraphItem::addMemoryGap()\r\n//-----------------------------------------------------------------------------\r\nQMultiMap<quint64, MemoryVisualizationItem*>::iterator RegisterGraphItem::addMemoryGap(quint64 startAddress,\r\n    quint64 endAddress)\r\n{\r\n    FieldGapItem* gap = new FieldGapItem(tr(\"Reserved\"), getExpressionParser(), this);\r\n    gap->setDisplayOffset(startAddress);\r\n    gap->setDisplayLastAddress(endAddress);\r\n    gap->updateDisplay();\r\n\r\n    return childItems_.insert(gap->getLastAddress(), gap);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: RegisterGraphItem::markConflictingChildren()\r\n//-----------------------------------------------------------------------------\r\nvoid RegisterGraphItem::markConflictingChildren()\r\n{\r\n    if (childItems_.isEmpty())\r\n    {\r\n        return;\r\n    }\r\n\r\n    auto registerMSB = getRegisterMSB();\r\n    quint64 highestBitHandled = 0;\r\n\r\n    // QMap sorts children by ascending offsets.\r\n    for (auto i = childItems_.begin(); i != childItems_.end(); ++i)\r\n    {\r\n        auto currentChild = i.value();\r\n        auto currentOffset = currentChild->getOffset();\r\n\r\n        if (!currentChild->isPresent())\r\n        {\r\n            continue;\r\n        }\r\n\r\n        bool overlaps = currentOffset < highestBitHandled;\r\n        bool isOutsideRegister = currentOffset > registerMSB ||\r\n            currentChild->getLastAddress() > registerMSB;\r\n\r\n        currentChild->setConflicted(overlaps || isOutsideRegister);\r\n\r\n        if (overlaps && i != childItems_.begin())\r\n        {\r\n            // Walk in the opposite direction and mark any overlapping items conflicted.\r\n            for (auto previous = std::prev(i); previous != childItems_.begin(); --previous)\r\n            {\r\n                if ((*previous)->getLastAddress() >= currentOffset)\r\n                {\r\n                    (*previous)->setConflicted(true);\r\n                }\r\n            }\r\n\r\n            // Check first item separately to avoid undefined iterator behavior.\r\n            if (childItems_.first()->getLastAddress() >= currentOffset)\r\n            {\r\n                childItems_.first()->setConflicted(true);\r\n            }\r\n        }\r\n\r\n        highestBitHandled = qMax(highestBitHandled, currentChild->getLastAddress() + 1);\r\n    }\r\n}\r\n"
  },
  {
    "path": "editors/ComponentEditor/memoryMaps/memoryMapsVisualizer/registergraphitem.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: registergraphitem.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 24.04.2012\r\n//\r\n// Description:\r\n// The graphical item that represents one register.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef REGISTERGRAPHITEM_H\r\n#define REGISTERGRAPHITEM_H\r\n\r\n#include <editors/ComponentEditor/visualization/memoryvisualizationitem.h>\r\n\r\n#include <IPXACTmodels/Component/Register.h>\r\n\r\n#include <QSharedPointer>\r\n\r\nclass ExpressionParser;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! The graphical item that represents one register.\r\n//-----------------------------------------------------------------------------\r\nclass RegisterGraphItem : public MemoryVisualizationItem\r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\r\n\t/*!\r\n     *  The constructor.\r\n\t *\r\n\t *    @param [in] reg                 The register that this graph item visualizes.\r\n     *    @param [in] expressionParser    Parser for expressions in register fields.\r\n\t *    @param [in] parent              The parent of this graph item.\r\n\t */\r\n\tRegisterGraphItem(QSharedPointer<Register> reg, QSharedPointer<ExpressionParser> expressionParser,\r\n        QGraphicsItem* parent);\r\n\t\r\n\t//! The destructor.\r\n\tvirtual ~RegisterGraphItem() = default;\r\n\r\n    //! No copying\r\n    RegisterGraphItem(const RegisterGraphItem& other) = delete;\r\n    RegisterGraphItem& operator=(const RegisterGraphItem& other) = delete;\r\n\r\n    //! Updates the labels and tooltip for the item.\r\n    virtual  void updateDisplay() override final;\r\n\r\n    //! Add child item.\r\n    virtual void addChild(MemoryVisualizationItem* childItem) override final;\r\n\r\n\t//! Remove the item.\r\n    virtual void removeChild(MemoryVisualizationItem* childItem ) override final;\r\n\r\n\t/*!\r\n     *  Get the offset of the item. \r\n\t *\r\n\t *    @return The offset of the item from the parent item's base address.\r\n\t */\r\n\tvirtual quint64 getOffset() const override final;\r\n\r\n\t/*!\r\n     *  Get the last address contained in the item.\r\n\t *\r\n\t *    @return The last address.\r\n\t */\r\n\tvirtual quint64 getLastAddress() const override final;\r\n\r\n\t/*!\r\n     *  Get the bit width of the item.\r\n\t * \r\n\t *    @return The bit width of the item.\r\n\t */\r\n\tvirtual int getBitWidth() const override final;\r\n\r\n\t/*!\r\n     *  Get number of bits the addressable unit contains.\r\n\t *\r\n\t *    @return The size of least addressable unit.\r\n\t */\r\n\tvirtual unsigned int getAddressUnitSize() const override final;\r\n\r\n    /*!\r\n     *  Set the width for the item.\r\n\t *\r\n\t *    @param [in] width The new width of the item.\r\n\t */\r\n    virtual void setWidth(qreal width) override final;\r\n\r\n    /*!\r\n     *  Checks if the item is to be used in the visualization.\r\n     *\r\n     *    @return True, if the item should be used, otherwise false.\r\n     */\r\n    virtual bool isPresent() const override final;\r\n\r\n\r\nprotected:\r\n\r\n    /*!\r\n     *  Repositions the child items and fills the empty gaps between them.\r\n     */\r\n    virtual void repositionChildren() override final;\r\n\r\n    //! Removes current gaps between field items and re-sorts fields by offset.\r\n    virtual void removeGapsAndSortChildren() override final;\r\n\r\n    /*!\r\n     * Fills the gaps between fields with gap items.\r\n     */\r\n    virtual void fillGapsBetweenChildren() override final;\r\n\r\n    //! Mark all invalid fields outside register boundaries.\r\n    virtual void markConflictingChildren() override final;\r\n\r\nprivate:\r\n\t\t\r\n    /*!\r\n     *  Gets the register size in AUB units.\r\n     *\r\n     *    @return The size of the register in AUBs.\r\n     */\r\n    quint64 getSizeInAUB() const;\r\n\r\n    /*!\r\n     *  Gets the MSB of the register.\r\n     *\r\n     *    @return The MSB of the register.\r\n     */\r\n    unsigned int getRegisterMSB() const;\r\n\r\n    /*!\r\n     * Finds the highest bit reserved by the register i.e. MSB or highest bit found in fields.\r\n     *\r\n     *    @return The highest bit index in the register.\r\n     */\r\n    unsigned int findHighestReservedBit() const;\r\n\r\n\r\n    /*!\r\n     *  Checks if there is empty memory space between the given child and the last known used bit index.\r\n     *\r\n     *    @param [in] current             The currently iterated child.\r\n     *    @param [in] lastBitIndexInUse   The last known used bit index.\r\n     *\r\n     *    @return True, if there is empty space, otherwise false.\r\n     */\r\n    bool emptySpaceBeforeChild(MemoryVisualizationItem const* current, quint64 lastBitIndexInUse) const;\r\n\r\n    /*!\r\n     *  Creates a new child for representing a free memory slot.\r\n     *\r\n     *    @param [in] startAddress    The offset of the free memory slot.\r\n     *    @param [in] lastAddress     The last address of the free memory slot.\r\n     */\r\n    QMultiMap<quint64, MemoryVisualizationItem*>::iterator addMemoryGap(quint64 startAddress, quint64 endAddress);\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! Pointer to the register being visualized.\r\n\tQSharedPointer<Register> register_;\r\n\r\n};\r\n\r\n#endif // REGISTERGRAPHITEM_H\r\n"
  },
  {
    "path": "editors/ComponentEditor/memoryMaps/memorymapdelegate.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: memorymapdelegate.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 22.08.2012\r\n//\r\n// Description:\r\n// The delegate that provides editors to add/remove/edit details of a single memory map.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"memorymapdelegate.h\"\r\n\r\n#include \"MemoryMapColumns.h\"\r\n\r\n#include <common/widgets/booleanComboBox/booleancombobox.h>\r\n#include <common/widgets/usageComboBox/usagecombobox.h>\r\n#include <common/widgets/accessComboBox/accesscombobox.h>\r\n\r\n#include <IPXACTmodels/common/validators/namevalidator.h>\r\n\r\n#include <QLineEdit>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryMapDelegate::MemoryMapDelegate()\r\n//-----------------------------------------------------------------------------\r\nMemoryMapDelegate::MemoryMapDelegate(QAbstractItemModel* completionModel,\r\n                                     QSharedPointer<ParameterFinder> parameterFinder, QObject *parent):\r\nMemoryBlockDelegate(completionModel, parameterFinder, parent)\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryMapDelegate::createEditor()\r\n//-----------------------------------------------------------------------------\r\nQWidget* MemoryMapDelegate::createEditor(QWidget* parent, QStyleOptionViewItem const& option,\r\n    QModelIndex const& index) const \r\n{\r\n    if (index.column() == MemoryMapColumns::USAGE_COLUMN)\r\n    {\r\n        UsageComboBox* usageBox = new UsageComboBox(parent);\r\n        return usageBox;\r\n    }\r\n    else if (index.column() == MemoryMapColumns::ACCESS_COLUMN)\r\n    {\r\n        AccessComboBox* accessBox = new AccessComboBox(parent);\r\n        return accessBox;\r\n    }\r\n    else if (index.column() == MemoryMapColumns::VOLATILE_COLUMN)\r\n    {\r\n        BooleanComboBox* boolBox = new BooleanComboBox(parent);\r\n        return boolBox;\r\n    }\r\n    else\r\n    {\r\n        return MemoryBlockDelegate::createEditor(parent, option, index);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryMapDelegate::setEditorData()\r\n//-----------------------------------------------------------------------------\r\nvoid MemoryMapDelegate::setEditorData(QWidget* editor, QModelIndex const& index) const\r\n{\r\n    if (index.column() == MemoryMapColumns::USAGE_COLUMN)\r\n    {\r\n        UsageComboBox* usageBox = qobject_cast<UsageComboBox*>(editor);\r\n        Q_ASSERT(usageBox);\r\n\r\n        General::Usage usage = General::str2Usage(index.model()->data(index).toString(), General::USAGE_COUNT);\r\n        usageBox->setCurrentValue(usage);\r\n    }\r\n    else if (index.column() == MemoryMapColumns::ACCESS_COLUMN)\r\n    {\r\n        AccessComboBox* accessBox = qobject_cast<AccessComboBox*>(editor);\r\n        Q_ASSERT(accessBox);\r\n\r\n        AccessTypes::Access access =\r\n            AccessTypes::str2Access(index.model()->data(index).toString(), AccessTypes::ACCESS_COUNT);\r\n        accessBox->setCurrentValue(access);\r\n    }\r\n    else if (index.column() == MemoryMapColumns::VOLATILE_COLUMN)\r\n    {\r\n        BooleanComboBox* boolBox = qobject_cast<BooleanComboBox*>(editor);\r\n        Q_ASSERT(boolBox);\r\n\r\n        QString value = index.model()->data(index).toString();\r\n        boolBox->setCurrentValue(value);\r\n    }\r\n    else\r\n    {\r\n        MemoryBlockDelegate::setEditorData(editor, index);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryMapDelegate::setModelData()\r\n//-----------------------------------------------------------------------------\r\nvoid MemoryMapDelegate::setModelData(QWidget* editor, QAbstractItemModel* model, QModelIndex const& index) const\r\n{\r\n    if (index.column() ==  MemoryMapColumns::USAGE_COLUMN)\r\n    {\r\n        UsageComboBox* usageBox = qobject_cast<UsageComboBox*>(editor);\r\n        Q_ASSERT(usageBox);\r\n\r\n        General::Usage usage = usageBox->getCurrentValue();\r\n        model->setData(index, General::usage2Str(usage), Qt::EditRole);\r\n    }\r\n    else if (index.column() ==  MemoryMapColumns::ACCESS_COLUMN)\r\n    {\r\n        AccessComboBox* accessBox = qobject_cast<AccessComboBox*>(editor);\r\n        Q_ASSERT(accessBox);\r\n\r\n        AccessTypes::Access access = accessBox->getCurrentValue();\r\n        model->setData(index, AccessTypes::access2Str(access), Qt::EditRole);\r\n    }\r\n    else if (index.column() ==  MemoryMapColumns::VOLATILE_COLUMN)\r\n    {\r\n        BooleanComboBox* boolBox = qobject_cast<BooleanComboBox*>(editor);\r\n        Q_ASSERT(boolBox);\r\n\r\n        QString value = boolBox->getCurrentValue();\r\n        model->setData(index, value, Qt::EditRole);\r\n    }\r\n    else \r\n    {\r\n        MemoryBlockDelegate::setModelData(editor, model, index);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: memorymapdelegate::columnAcceptsExpression()\r\n//-----------------------------------------------------------------------------\r\nbool MemoryMapDelegate::columnAcceptsExpression(int column) const\r\n{\r\n    return MemoryBlockDelegate::columnAcceptsExpression(column) ||\r\n        column == MemoryMapColumns::RANGE_COLUMN || column == MemoryMapColumns::WIDTH_COLUMN;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryMapDelegate::descriptionColumn()\r\n//-----------------------------------------------------------------------------\r\nint MemoryMapDelegate::descriptionColumn() const\r\n{\r\n    return MemoryMapColumns::DESCRIPTION_COLUMN;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: memorymapdelegate::nameColumn()\r\n//-----------------------------------------------------------------------------\r\nint MemoryMapDelegate::nameColumn() const\r\n{\r\n    return MemoryMapColumns::NAME_COLUMN;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: memorymapdelegate::baseAddressColumn()\r\n//-----------------------------------------------------------------------------\r\nint MemoryMapDelegate::baseAddressColumn() const\r\n{\r\n    return MemoryMapColumns::BASE_COLUMN;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: memorymapdelegate::isPresentColumn()\r\n//-----------------------------------------------------------------------------\r\nint MemoryMapDelegate::isPresentColumn() const\r\n{\r\n    return MemoryMapColumns::IS_PRESENT;\r\n}\r\n"
  },
  {
    "path": "editors/ComponentEditor/memoryMaps/memorymapdelegate.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: memorymapdelegate.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 22.08.2012\r\n//\r\n// Description:\r\n// The delegate that provides editors to add/remove/edit details of a single memory map.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef MEMORYMAPDELEGATE_H\r\n#define MEMORYMAPDELEGATE_H\r\n\r\n#include <editors/ComponentEditor/memoryMaps/MemoryBlockDelegate.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n//! The delegate that provides editors to add/remove/edit details of a single memory map.\r\n//-----------------------------------------------------------------------------\r\nclass MemoryMapDelegate : public MemoryBlockDelegate\r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\t\r\n\t/*!\r\n\t *  The constructor.\r\n\t *\r\n     *    @param [in] completionModel     Model containing the completions used in expression editor.\r\n\t *    @param [in] parameterFinder     The parameter finder for expression editor.\r\n\t *    @param [in] parent              Pointer to the owner of the delegate.\r\n\t */\r\n\tMemoryMapDelegate(QAbstractItemModel* completionModel, QSharedPointer<ParameterFinder> parameterFinder,\r\n        QObject *parent);\r\n\t\r\n\t/*!\r\n     *  The destructor.\r\n     */\r\n\tvirtual ~MemoryMapDelegate() = default;\r\n\r\n\t/*!\r\n     *  Create a new editor for the given item\r\n\t *\r\n\t *    @param [in] parent Owner for the editor.\r\n\t *    @param [in] option Contains options for the editor.\r\n\t *    @param [in] index Model index identifying the item.\r\n\t *\r\n\t *    @return Pointer to the editor to be used to edit the item.\r\n\t */\r\n\tvirtual QWidget* createEditor(QWidget* parent, const QStyleOptionViewItem& option, QModelIndex const& index)\r\n        const;\r\n\r\n\t/*!\r\n     *  Set the data for the editor.\r\n\t *\r\n\t *    @param [in] editor Pointer to the editor where the data is to be set.\r\n\t *    @param [in] index Model index identifying the item that's data is to be set.\r\n\t */\r\n\tvirtual void setEditorData(QWidget* editor, QModelIndex const& index) const;\r\n\r\n\t/*!\r\n     *  Save the data from the editor to the model.\r\n\t *\r\n\t *    @param [in] editor Pointer to the editor that contains the data to store.\r\n\t *    @param [in] model Model that contains the data structure where data is to be saved to.\r\n\t *    @param [in] index Model index identifying the item that's data is to be saved.\r\n\t */\r\n\tvirtual void setModelData(QWidget* editor, QAbstractItemModel* model, QModelIndex const& index) const;\r\n\r\nprotected:\r\n\r\n    /*!\r\n     *  Checks if the given column supports expressions in the editor.\r\n     *\r\n     *    @param [in] column  The column to check.\r\n     *\r\n     *    @return True if the cells in the column allow expressions, otherwise false.\r\n     */\r\n    virtual bool columnAcceptsExpression(int column) const;\r\n\r\n    /*!\r\n     *  Gets the description column.\r\n     */\r\n    virtual int descriptionColumn() const;\r\n\r\nprivate:\r\n\t\r\n    //! No copying.\tNo assignment.\r\n\tMemoryMapDelegate(const MemoryMapDelegate& other);\r\n\tMemoryMapDelegate& operator=(const MemoryMapDelegate& other);\r\n\r\n    /*!\r\n     *  Get the column for block name.\r\n     *\r\n     *    @return Index of the name column.\r\n     */\r\n    virtual int nameColumn() const override final;\r\n\r\n    /*!\r\n     *  Get the column for block base address.\r\n     *\r\n     *    @return Index of the base address column.\r\n     */\r\n    virtual int baseAddressColumn() const override final;\r\n\r\n    /*!\r\n     *  Get the column for block is present.\r\n     *\r\n     *    @return Index of the is present column.\r\n     */\r\n    virtual int isPresentColumn() const override final;\r\n};\r\n\r\n#endif // MEMORYMAPDELEGATE_H\r\n"
  },
  {
    "path": "editors/ComponentEditor/memoryMaps/memorymapeditor.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: Component.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 22.08.2012\r\n//\r\n// Description:\r\n// The editor to edit the address blocks of a single memory map.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"memorymapeditor.h\"\r\n\r\n#include \"memorymapmodel.h\"\r\n#include \"memorymapdelegate.h\"\r\n#include \"MemoryMapColumns.h\"\r\n\r\n#include <common/views/EditableTableView/editabletableview.h>\r\n#include <common/widgets/summaryLabel/summarylabel.h>\r\n\r\n#include <editors/ComponentEditor/parameters/ComponentParameterModel.h>\r\n#include <editors/ComponentEditor/memoryMaps/MemoryBlockFilter.h>\r\n#include <KactusAPI/include/AddressBlockInterface.h>\r\n\r\n#include <KactusAPI/include/LibraryInterface.h>\r\n\r\n#include <IPXACTmodels/Component/Component.h>\r\n\r\n#include <QCompleter>\r\n#include <QVBoxLayout>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryMapEditor::MemoryMapEditor()\r\n//-----------------------------------------------------------------------------\r\nMemoryMapEditor::MemoryMapEditor(QSharedPointer<Component> component, LibraryInterface* handler,\r\n    QSharedPointer<ParameterFinder> parameterFinder, QSharedPointer<ExpressionParser> expressionParser,\r\n    AddressBlockInterface* blockInterface, QSharedPointer<QList<QSharedPointer<MemoryBlockBase>>> blocks,\r\n    QWidget* parent):\r\nQGroupBox(tr(\"Address blocks summary\"), parent),\r\nview_(new EditableTableView(this)),\r\nmodel_(new MemoryMapModel(blockInterface, expressionParser, parameterFinder, component->getRevision(), this)),\r\ninterface_(blockInterface),\r\nblocks_(blocks),\r\ncomponent_(component),\r\nproxy_()\r\n{\r\n    interface_->setMemoryBlocks(blocks_);\r\n    interface_->setupSubInterfaces(component_);\r\n\r\n    ComponentParameterModel* componentParameterModel = new ComponentParameterModel(parameterFinder, this);\r\n    componentParameterModel->setExpressionParser(expressionParser);\r\n\r\n\tQVBoxLayout* layout = new QVBoxLayout(this);\r\n\tlayout->addWidget(view_);\r\n\r\n    proxy_ = new MemoryBlockFilter(expressionParser, blockInterface, this);\r\n    proxy_->setColumnToAcceptExpressions(MemoryMapColumns::BASE_COLUMN);\r\n    proxy_->setColumnToAcceptExpressions(MemoryMapColumns::RANGE_COLUMN);\r\n    proxy_->setColumnToAcceptExpressions(MemoryMapColumns::WIDTH_COLUMN);\r\n    proxy_->setColumnToAcceptExpressions(MemoryMapColumns::IS_PRESENT);\r\n\r\n\tproxy_->setSourceModel(model_);\r\n\tview_->setModel(proxy_);\r\n\r\n    if (component_->getRevision() == Document::Revision::Std22)\r\n    {\r\n        view_->hideColumn(MemoryMapColumns::IS_PRESENT);\r\n    }\r\n\r\n\t//! Enable import/export csv file\r\n    const QString compPath = handler->getDirectoryPath(component->getVlnv());\r\n\tQString defPath = QString(\"%1/addrBlockList.csv\").arg(compPath);\r\n\tview_->setDefaultImportExportPath(defPath);\r\n\tview_->setAllowImportExport(true);\r\n    view_->setAllowElementCopying(true);\r\n\r\n\tview_->setItemsDraggable(false);\r\n\tview_->setSortingEnabled(true);\r\n\r\n    view_->setItemDelegate(new MemoryMapDelegate(componentParameterModel, parameterFinder, this));\r\n\r\n\tview_->sortByColumn(MemoryMapColumns::BASE_COLUMN, Qt::AscendingOrder);\r\n\r\n\tconnect(model_, SIGNAL(contentChanged()), this, SIGNAL(contentChanged()), Qt::UniqueConnection);\r\n    connect(model_, SIGNAL(graphicsChanged(int)), this, SIGNAL(graphicsChanged(int)), Qt::UniqueConnection);\r\n    \r\n    connect(model_, SIGNAL(childAddressingChanged(int)), \r\n        this, SIGNAL(childAddressingChanged(int)), Qt::UniqueConnection);\r\n\tconnect(model_, SIGNAL(itemAdded(int)),\tthis, SIGNAL(childAdded(int)), Qt::UniqueConnection);\r\n\tconnect(model_, SIGNAL(itemRemoved(int)), this, SIGNAL(childRemoved(int)), Qt::UniqueConnection);\r\n\r\n\tconnect(view_, SIGNAL(addItem(const QModelIndex&)),\r\n        model_, SLOT(onAddItem(const QModelIndex&)), Qt::UniqueConnection);\r\n\tconnect(view_, SIGNAL(removeItem(const QModelIndex&)),\r\n\t\tmodel_, SLOT(onRemoveItem(const QModelIndex&)), Qt::UniqueConnection);\r\n\r\n    connect(view_->itemDelegate(), SIGNAL(increaseReferences(QString)),\r\n        this, SIGNAL(increaseReferences(QString)), Qt::UniqueConnection);\r\n    connect(view_->itemDelegate(), SIGNAL(decreaseReferences(QString)),\r\n        this, SIGNAL(decreaseReferences(QString)), Qt::UniqueConnection);\r\n\r\n    connect(model_, SIGNAL(decreaseReferences(QString)),\r\n        this, SIGNAL(decreaseReferences(QString)), Qt::UniqueConnection);\r\n\r\n    connect(model_, SIGNAL(increaseReferences(QString)),\r\n        this, SIGNAL(increaseReferences(QString)), Qt::UniqueConnection);\r\n\r\n    connect(view_, SIGNAL(copyRows(QModelIndexList)),\r\n        model_, SLOT(onCopyRows(QModelIndexList)), Qt::UniqueConnection);\r\n    connect(view_, SIGNAL(pasteRows()), model_, SLOT(onPasteRows()), Qt::UniqueConnection);\r\n\r\n    connect(this, SIGNAL(assignNewAddressUnitBits(QString const&)),\r\n        model_, SLOT(addressUnitBitsUpdated(QString const&)), Qt::UniqueConnection);\r\n\r\n    connect(model_, SIGNAL(blockNameChanged(QString const&, QString const&)),\r\n        this, SIGNAL(addressBlockNameChanged(QString const&, QString const&)), Qt::UniqueConnection);\r\n\r\n    connect(model_, SIGNAL(invalidateOtherFilter()), this, SIGNAL(invalidateOtherFilter()), Qt::UniqueConnection);\r\n\r\n    connect(this, SIGNAL(invalidateThisFilter()), proxy_, SLOT(invalidate()), Qt::UniqueConnection);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryMapEditor::~MemoryMapEditor()\r\n//-----------------------------------------------------------------------------\r\nMemoryMapEditor::~MemoryMapEditor()\r\n{\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryMapEditor::refresh()\r\n//-----------------------------------------------------------------------------\r\nvoid MemoryMapEditor::refresh()\r\n{\r\n\tview_->update();\r\n\r\n    interface_->setMemoryBlocks(blocks_);\r\n    interface_->setupSubInterfaces(component_);\r\n}\r\n"
  },
  {
    "path": "editors/ComponentEditor/memoryMaps/memorymapeditor.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: Component.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 22.08.2012\r\n//\r\n// Description:\r\n// The editor to edit the address blocks of a single memory map.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef MEMORYMAPEDITOR_H\r\n#define MEMORYMAPEDITOR_H\r\n\r\n#include <editors/ComponentEditor/itemeditor.h>\r\n#include <KactusAPI/include/ParameterFinder.h>\r\n\r\n#include <IPXACTmodels/Component/MemoryMapBase.h>\r\n\r\n#include <QSortFilterProxyModel>\r\n#include <QSharedPointer>\r\n#include <QGroupBox>\r\n\r\nclass EditableTableView;\r\nclass MemoryMapModel;\r\nclass MemoryMapProxy;\r\nclass LibraryInterface;\r\nclass ExpressionParser;\r\nclass Component;\r\nclass AddressBlockInterface;\r\nclass AddressBlock;\r\nclass MemoryBlockFilter;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! The editor to edit the address blocks of a single memory map.\r\n//-----------------------------------------------------------------------------\r\nclass MemoryMapEditor : public QGroupBox\r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\r\n    /*!\r\n\t *  The constructor.\r\n\t *\r\n\t *    @param [in] component           The component being edited.\r\n\t *    @param [in] handler             The instance managing the library.\r\n\t *    @param [in] parameterFinder     The parameter finder for component.\r\n     *    @param [in] expressionParser    The expression parser.\r\n     *    @param [in] blockInterface      Interface for address blocks.\r\n     *    @param [in] blocks              Pointer to the available address blocks.\r\n\t *    @param [in] parent              The parent of this editor.\r\n\t */\r\n    MemoryMapEditor(QSharedPointer<Component> component,\r\n        LibraryInterface* handler,\r\n        QSharedPointer<ParameterFinder> parameterFinder,\r\n        QSharedPointer<ExpressionParser> expressionParser,\r\n        AddressBlockInterface* blockInterface,\r\n        QSharedPointer<QList<QSharedPointer<MemoryBlockBase> > > blocks,\r\n        QWidget* parent = 0);\r\n\r\n\t//! The destructor.\r\n\tvirtual ~MemoryMapEditor();\r\n\r\n\t/*!\r\n     *  Reload the information from the model to the editor.\r\n\t */\r\n\tvirtual void refresh();\r\n\r\nsignals:\r\n    \r\n    /*!\r\n     *  Emitted when the contents of the widget change.\r\n     */\r\n    void contentChanged();\r\n\r\n    /*!\r\n     *  Informs of a need to redraw the visualization.\r\n     */\r\n    void graphicsChanged(int);\r\n\r\n    void childAddressingChanged(int);\r\n\r\n    /*!\r\n     *  Emits an error message for the user.\r\n     *\r\n     *    @param [in] msg     The error message.\r\n     */\r\n    void errorMessage(const QString& msg) const;\r\n\r\n    /*!\r\n     *  Emits a notice message for the user.\r\n     *\r\n     *    @param [in] msg   [Description].\r\n     */\r\n    void noticeMessage(const QString& msg) const;\r\n\r\n    /*!\r\n     *  Increases the number of references to the given parameter.\r\n     *\r\n     *    @param [in] id  The target parameter.\r\n     */\r\n    void increaseReferences(QString id);\r\n\r\n    /*!\r\n     *  Decreases the number of references to the given parameter.\r\n     *\r\n     *    @param [in] id  The target parameter.\r\n     */\r\n    void decreaseReferences(QString id);\r\n\r\n    /*!\r\n     *  Informs of an added child.\r\n     *\r\n     *    @param [in] index   The index of the new child.\r\n     */\r\n    void childAdded(int index);\r\n\r\n    /*!\r\n     *  Informs of a removed child.\r\n     *\r\n     *    @param [in] index   The index of the removed child.\r\n     */\r\n    void childRemoved(int index);\r\n\r\n    /*!\r\n     *  Assign new address unit bits for address blocks.\r\n     *\r\n     *    @param [in] newAddressUnitBits  The new address unit bits.\r\n     */\r\n    void assignNewAddressUnitBits(QString const& newAddressUnitBits);\r\n\r\n    /*\r\n     *  Informs of address block name change.\r\n     *\r\n     *    @param [in] oldName     The old name.\r\n     *    @param [in] newName     The new name.\r\n     */\r\n    void addressBlockNameChanged(QString const& oldName, QString const& newName);\r\n\r\n    /*!\r\n     *  Inform the other memory block editor to invalidate the filter.\r\n     */\r\n    void invalidateOtherFilter();\r\n\r\n    /*!\r\n     *  Inform this editor to invalidate the filter.\r\n     */\r\n    void invalidateThisFilter();\r\n\r\n\r\nprivate:\r\n\t\r\n    //! No copying.\tNo assignment.\r\n\tMemoryMapEditor(const MemoryMapEditor& other);\r\n\tMemoryMapEditor& operator=(const MemoryMapEditor& other);\r\n\r\n\t//! The view to show the details of a memory map.\r\n\tEditableTableView* view_;\r\n\r\n\t//! The model that manages the items.\r\n\tMemoryMapModel* model_;\r\n\r\n    //! Interface for accessing address blocks.\r\n    AddressBlockInterface* interface_;\r\n\r\n    //! Pointer to the available address blocks.\r\n    QSharedPointer<QList<QSharedPointer<MemoryBlockBase> > > blocks_;\r\n\r\n    //! The containing component.\r\n    QSharedPointer<Component> component_;\r\n\r\n    //! Filter fro address blocks.\r\n    MemoryBlockFilter* proxy_;\r\n};\r\n\r\n#endif // MEMORYMAPEDITOR_H\r\n"
  },
  {
    "path": "editors/ComponentEditor/memoryMaps/memorymapmodel.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: memorymapmodel.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 22.08.2012\r\n//\r\n// Description:\r\n// The model to manage the address blocks of a single memory map.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"memorymapmodel.h\"\r\n\r\n#include \"MemoryMapColumns.h\"\r\n\r\n#include <KactusAPI/include/AddressBlockInterface.h>\r\n#include <editors/ComponentEditor/memoryMaps/memoryMapsExpressionCalculators/ReferenceCalculator.h>\r\n\r\n#include <common/KactusColors.h>\r\n\r\n#include <QRegularExpression>\r\n#include <QApplication>\r\n#include <QClipboard>\r\n#include <QMimeData>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryMapModel::MemoryMapModel()\r\n//-----------------------------------------------------------------------------\r\nMemoryMapModel::MemoryMapModel(AddressBlockInterface* blockInterface,\r\n    QSharedPointer <ExpressionParser> expressionParser, QSharedPointer <ParameterFinder> parameterFinder, \r\n    Document::Revision docRevision, QObject *parent) :\r\nMemoryBlockModel(blockInterface, expressionParser, parameterFinder, docRevision, parent),\r\nlocalBlockInterface_(blockInterface)\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryMapModel::columnCount()\r\n//-----------------------------------------------------------------------------\r\nint MemoryMapModel::columnCount(QModelIndex const& parent) const\r\n{\r\n\tif (parent.isValid())\r\n    {\r\n\t\treturn 0;\r\n\t}\r\n\treturn MemoryMapColumns::COLUMN_COUNT;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryMapModel::flags()\r\n//-----------------------------------------------------------------------------\r\nQt::ItemFlags MemoryMapModel::flags(QModelIndex const& index) const\r\n{\r\n    if (!index.isValid())\r\n    {\r\n        return Qt::NoItemFlags;\r\n    }\r\n\r\n    std::string addressBlockName = localBlockInterface_->getIndexedItemName(index.row());\r\n\r\n    // Disable access field if there is more than one access policy for that address block.\r\n    if (index.column() == MemoryMapColumns::ACCESS_COLUMN && docRevision_ == Document::Revision::Std22)\r\n    {\r\n        if (localBlockInterface_->getAccessPolicyCount(addressBlockName) > 1)\r\n        {\r\n            return Qt::ItemIsEnabled | Qt::ItemIsSelectable;\r\n        }\r\n    }\r\n\r\n    return MemoryBlockModel::flags(index);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryMapModel::headerData()\r\n//-----------------------------------------------------------------------------\r\nQVariant MemoryMapModel::headerData(int section, Qt::Orientation orientation, int role) const \r\n{\r\n\tif (orientation != Qt::Horizontal)\r\n    {\r\n\t\treturn QVariant();\r\n\t}\r\n\r\n\tif (Qt::DisplayRole == role)\r\n    {\r\n        if (section == MemoryMapColumns::USAGE_COLUMN)\r\n        {\r\n            return tr(\"Usage\");\r\n        }\r\n        else if (section == MemoryMapColumns::RANGE_COLUMN)\r\n        {\r\n            QString range = tr(\"Range\\n [AUB]\") + getExpressionSymbol();\r\n            return range;\r\n        }\r\n        else if (section == MemoryMapColumns::WIDTH_COLUMN)\r\n        {\r\n            QString widthHeader = tr(\"Width\\n [bits]\") + getExpressionSymbol();\r\n            return widthHeader;\r\n        }\r\n\r\n        else if (section == MemoryMapColumns::ACCESS_COLUMN)\r\n        {\r\n            return tr(\"Access\");\r\n        }\r\n        else if (section == MemoryMapColumns::VOLATILE_COLUMN)\r\n        {\r\n            return tr(\"Volatile\");\r\n        }\r\n\t}\r\n\r\n    return MemoryBlockModel::headerData(section, orientation, role);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryMapModel::data()\r\n//-----------------------------------------------------------------------------\r\nQVariant MemoryMapModel::data(QModelIndex const& index, int role) const\r\n{\r\n    if (!index.isValid() || index.row() < 0 || index.row() >= localBlockInterface_->itemCount())\r\n    {\r\n\t\treturn QVariant();\r\n\t}\r\n\r\n    std::string blockName = localBlockInterface_->getIndexedItemName(index.row());\r\n\r\n    if (role == Qt::BackgroundRole &&\r\n        (index.column() == MemoryMapColumns::RANGE_COLUMN || index.column() == MemoryMapColumns::WIDTH_COLUMN))\r\n    {\r\n        return KactusColors::MANDATORY_FIELD;\r\n    }\r\n\r\n    return MemoryBlockModel::data(index, role);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryMapModel::setData()\r\n//-----------------------------------------------------------------------------\r\nbool MemoryMapModel::setData(QModelIndex const& index, QVariant const& value, int role)\r\n{\r\n    if (!index.isValid() || index.row() < 0 || index.row() >= localBlockInterface_->itemCount())\r\n    {\r\n\t\treturn false;\r\n\t}\r\n\r\n    if (Qt::EditRole == role)\r\n    {\r\n        std::string blockName = localBlockInterface_->getIndexedItemName(index.row());\r\n\r\n        if (index.column() == MemoryMapColumns::USAGE_COLUMN)\r\n        {\r\n            if (!localBlockInterface_->setUsage(blockName, value.toString().toStdString()))\r\n            {\r\n                return false;\r\n            }\r\n        }\r\n        else if (index.column() == MemoryMapColumns::RANGE_COLUMN)\r\n        {\r\n            std::string oldValue = localBlockInterface_->getRangeExpression(blockName);\r\n            if (localBlockInterface_->setRange(blockName, value.toString().toStdString()))\r\n            {\r\n                removeReferencesFromSingleExpression(QString::fromStdString(oldValue));\r\n            }\r\n            else\r\n            {\r\n                return false;\r\n            }\r\n        }\r\n        else if (index.column() == MemoryMapColumns::WIDTH_COLUMN)\r\n        {\r\n            std::string oldValue = localBlockInterface_->getWidthExpression(blockName);\r\n            if (localBlockInterface_->setWidth(blockName, value.toString().toStdString()))\r\n            {\r\n                removeReferencesFromSingleExpression(QString::fromStdString(oldValue));\r\n            }\r\n            else\r\n            {\r\n                return false;\r\n            }\r\n        }\r\n        else if (index.column() == MemoryMapColumns::ACCESS_COLUMN)\r\n        {\r\n            // Modify the access of the address block by default.\r\n            bool setAccessPolicyAccess = false;\r\n\r\n            if (docRevision_ == Document::Revision::Std22)\r\n            {\r\n                // Create access policy first, if one doesn't exist.\r\n                if (localBlockInterface_->getAccessPolicyCount(blockName) == 0 &&\r\n                    value.toString().isEmpty() == false)\r\n                {\r\n                    localBlockInterface_->addAccessPolicy(blockName);\r\n                }\r\n\r\n                // Modify first access policy, if std22.\r\n                setAccessPolicyAccess = true;\r\n            }\r\n\r\n            if (!localBlockInterface_->setAccess(blockName, value.toString().toStdString(), setAccessPolicyAccess))\r\n            {\r\n                return false;\r\n            }\r\n        }\r\n        else if (index.column() == MemoryMapColumns::VOLATILE_COLUMN)\r\n        {\r\n            if (!localBlockInterface_->setVolatile(blockName, value.toString().toStdString()))\r\n            {\r\n                return false;\r\n            }\r\n        }\r\n        else \r\n        {\r\n            return MemoryBlockModel::setData(index, value, role);\r\n        }\r\n\r\n        if (index.column() == MemoryMapColumns::RANGE_COLUMN || index.column() == MemoryMapColumns::WIDTH_COLUMN)\r\n        {\r\n            emit graphicsChanged(index.row());\r\n        }\r\n\r\n        if (index.column() == MemoryMapColumns::RANGE_COLUMN)\r\n        {\r\n            emit childAddressingChanged(index.row());\r\n        }\r\n\r\n        emit dataChanged(index, index);\r\n        emit contentChanged();\r\n        return true;\r\n    }\r\n    else \r\n    {\r\n        return false;\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: memorymapmodel::isValidExpressionColumn()\r\n//-----------------------------------------------------------------------------\r\nbool MemoryMapModel::isValidExpressionColumn(QModelIndex const& index) const\r\n{\r\n    int column = index.column();\r\n\r\n    return column == MemoryMapColumns::WIDTH_COLUMN || column == MemoryMapColumns::IS_PRESENT ||\r\n        column == MemoryMapColumns::BASE_COLUMN || column == MemoryMapColumns::RANGE_COLUMN;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: memorymapmodel::validateIndex()\r\n//-----------------------------------------------------------------------------\r\nbool MemoryMapModel::validateIndex(QModelIndex const& index) const\r\n{\r\n    std::string blockName = localBlockInterface_->getIndexedItemName(index.row());\r\n    if (index.column() == MemoryMapColumns::RANGE_COLUMN)\r\n    {\r\n        return localBlockInterface_->hasValidRange(blockName);\r\n    }\r\n    else if (index.column() == MemoryMapColumns::WIDTH_COLUMN)\r\n    {\r\n        return localBlockInterface_->hasValidWidth(blockName);\r\n    }\r\n    else if (index.column() == MemoryMapColumns::USAGE_COLUMN)\r\n    {\r\n        return localBlockInterface_->hasValidUsage(blockName);\r\n    }\r\n\r\n    return MemoryBlockModel::validateIndex(index);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: memorymapmodel::formattedExpressionForIndex()\r\n//-----------------------------------------------------------------------------\r\nQVariant MemoryMapModel::formattedExpressionForIndex(QModelIndex const& index) const\r\n{\r\n    std::string blockName = localBlockInterface_->getIndexedItemName(index.row());\r\n    if (index.column() == MemoryMapColumns::RANGE_COLUMN)\r\n    {\r\n        return QString::fromStdString(localBlockInterface_->getRangeFormattedExpression(blockName));\r\n    }\r\n    else if (index.column() == MemoryMapColumns::WIDTH_COLUMN)\r\n    {\r\n        return QString::fromStdString(localBlockInterface_->getWidthFormattedExpression(blockName));\r\n    }\r\n\r\n    return MemoryBlockModel::formattedExpressionForIndex(index);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: memorymapmodel::expressionForIndex()\r\n//-----------------------------------------------------------------------------\r\nQVariant MemoryMapModel::expressionForIndex(QModelIndex const& index) const\r\n{\r\n    std::string blockName = localBlockInterface_->getIndexedItemName(index.row());\r\n    if (index.column() == MemoryMapColumns::RANGE_COLUMN)\r\n    {\r\n        return QString::fromStdString(localBlockInterface_->getRangeExpression(blockName));\r\n    }\r\n    else if (index.column() == MemoryMapColumns::WIDTH_COLUMN)\r\n    {\r\n        return QString::fromStdString(localBlockInterface_->getWidthExpression(blockName));\r\n    }\r\n\r\n    return MemoryBlockModel::expressionForIndex(index);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: memorymapmodel::valueForIndex()\r\n//-----------------------------------------------------------------------------\r\nQVariant MemoryMapModel::valueForIndex(QModelIndex const& index) const\r\n{\r\n    std::string blockName = localBlockInterface_->getIndexedItemName(index.row());\r\n\r\n    if (index.column() == MemoryMapColumns::USAGE_COLUMN)\r\n    {\r\n        return QString::fromStdString(localBlockInterface_->getUsageString(blockName));\r\n    }\r\n    else if (index.column() == MemoryMapColumns::RANGE_COLUMN)\r\n    {\r\n        return QString::fromStdString(localBlockInterface_->getRangeValue(blockName));\r\n    }\r\n    else if (index.column() == MemoryMapColumns::WIDTH_COLUMN)\r\n    {\r\n        return QString::fromStdString(localBlockInterface_->getWidthValue(blockName));\r\n    }\r\n    else if (index.column() == MemoryMapColumns::ACCESS_COLUMN)\r\n    {\r\n        if (docRevision_ == Document::Revision::Std22)\r\n        {\r\n            if (index.flags() == (Qt::ItemIsEnabled | Qt::ItemIsSelectable))\r\n            {\r\n                return QStringLiteral(\"[multiple]\");\r\n            }\r\n\r\n            return QString::fromStdString(localBlockInterface_->getAccessString(blockName, true));\r\n        }\r\n\r\n        return QString::fromStdString(localBlockInterface_->getAccessString(blockName));\r\n    }\r\n    else if (index.column() == MemoryMapColumns::VOLATILE_COLUMN)\r\n    {\r\n        return QString::fromStdString(localBlockInterface_->getVolatile(blockName));\r\n    }\r\n    \r\n    return MemoryBlockModel::valueForIndex(index);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryMapModel::mimeTypes()\r\n//-----------------------------------------------------------------------------\r\nQStringList MemoryMapModel::mimeTypes() const\r\n{\r\n    QStringList types(QAbstractItemModel::mimeTypes());\r\n\r\n    types << \"text/xml/ipxact:addressBlock\";\r\n\r\n    return types;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryMapModel::nameColumn()\r\n//-----------------------------------------------------------------------------\r\nint MemoryMapModel::nameColumn() const\r\n{\r\n    return MemoryMapColumns::NAME_COLUMN;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryMapModel::baseAddressColumn()\r\n//-----------------------------------------------------------------------------\r\nint MemoryMapModel::baseAddressColumn() const\r\n{\r\n    return MemoryMapColumns::BASE_COLUMN;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryMapModel::isPresentColumn()\r\n//-----------------------------------------------------------------------------\r\nint MemoryMapModel::isPresentColumn() const\r\n{\r\n    return MemoryMapColumns::IS_PRESENT;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: memorymapmodel::descriptionColumn()\r\n//-----------------------------------------------------------------------------\r\nint MemoryMapModel::descriptionColumn() const\r\n{\r\n    return MemoryMapColumns::DESCRIPTION_COLUMN;\r\n}\r\n"
  },
  {
    "path": "editors/ComponentEditor/memoryMaps/memorymapmodel.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: memorymapmodel.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 22.08.2012\r\n//\r\n// Description:\r\n// The model to manage the address blocks of a single memory map.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef MEMORYMAPMODEL_H\r\n#define MEMORYMAPMODEL_H\r\n\r\n#include <KactusAPI/include/ParameterFinder.h>\r\n#include <editors/ComponentEditor/memoryMaps/MemoryBlockModel.h>\r\n\r\n#include <QAbstractTableModel>\r\n#include <QSharedPointer>\r\n#include <QList>\r\n\r\nclass AddressBlockInterface;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! The model to manage the details of a single memory map.\r\n//-----------------------------------------------------------------------------\r\nclass MemoryMapModel : public MemoryBlockModel\r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\t\r\n\t/*!\r\n\t *  The constructor.\r\n\t *\r\n     *    @param [in] blockInterface      Interface for address blocks;\r\n\t *    @param [in] expressionParser    Pointer to the expression parser.\r\n\t *    @param [in] parameterFinder     Pointer to the parameter finder.\r\n\t *    @param [in] docRevision         The IP-XACT standard revision in use.\r\n\t *    @param [in] parent              Pointer to the owner of this model.\r\n\t */\r\n    MemoryMapModel(AddressBlockInterface* blockInterface, QSharedPointer <ExpressionParser> expressionParser,\r\n        QSharedPointer <ParameterFinder> parameterFinder, Document::Revision docRevision, QObject *parent);\r\n\r\n\t/*!\r\n     *  The destructor.\r\n     */\r\n\tvirtual ~MemoryMapModel() = default;\r\n\r\n\t/*!\r\n     *  Get the number of columns the item has to be displayed.\r\n\t *\r\n\t *    @param [in] parent  Identifies the parent that's column count is requested.\r\n\t *\r\n\t *    @return The number of columns to be displayed.\r\n\t */\r\n\tvirtual int columnCount(QModelIndex const& parent = QModelIndex()) const;\r\n\r\n    /*!\r\n     *  Get the item flags that defines the possible operations for the item.\r\n     *\r\n     *    @param [in] index   Model index that identifies the item.\r\n     *\r\n     *    @return Qt::ItemFlags specify the possible operations for the item.\r\n     */\r\n    virtual Qt::ItemFlags flags(QModelIndex const& index) const override;\r\n\r\n\t/*!\r\n     *  Get the header data for specified header.\r\n\t *\r\n\t *    @param [in] section         The section specifies the row/column number for the header.\r\n\t *    @param [in] orientation     Specified if horizontal or vertical header is wanted.\r\n\t *    @param [in] role            Specifies the type of the requested data.\r\n\t *\r\n\t *    @return QVariant Contains the requested data.\r\n\t */\r\n\tvirtual QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;\r\n\r\n\t/*!\r\n     *  Get the data for specified item.\r\n\t *\r\n\t *    @param [in] index   Specifies the item that's data is requested.\r\n\t *    @param [in] role    The role that defines what kind of data is requested.\r\n\t *\r\n\t *    @return QVariant Contains the data for the item.\r\n\t */\r\n\tvirtual QVariant data(QModelIndex const& index, int role = Qt::DisplayRole) const;\r\n\r\n\t/*!\r\n     *  Save the data to the model for specified item.\r\n\t *\r\n\t *    @param [in] index   The model index of the item that's data is to be saved.\r\n\t *    @param [in] value   The data that is to be saved.\r\n\t *    @param [in] role    The role specifies what kind of data should be saved.\r\n\t *\r\n\t *    @return True if saving happened successfully.\r\n\t */\r\n\tbool setData(QModelIndex const& index, const QVariant& value, int role = Qt::EditRole);\r\n    \r\n    /*!\r\n     *  Get the list of acceptable mime types.\r\n     *\r\n     *    @return The list of acceptable mime types.\r\n     */\r\n    virtual QStringList mimeTypes() const override final;\r\n\r\nprotected:\r\n\r\n    /*!\r\n     *  Checks if the column index is valid for expressions.\r\n     *\r\n     *    @param [in] index   The index being evaluated.\r\n     *\r\n     *    @return True, if the column can have expressions, otherwise false.\r\n     */\r\n    bool isValidExpressionColumn(QModelIndex const& index) const final;\r\n\r\n    /*!\r\n     *  validates the data in the column.\r\n     *\r\n     *    @param [in] index   The index being validated.\r\n     *\r\n     *    @return True, if the data is valid, otherwise false.\r\n     */\r\n    virtual bool validateIndex(QModelIndex const& index) const override final;\r\n\r\n    /*!\r\n     *  Get the formatted value of an expression in the selected index.\r\n     *\r\n     *    @param [in] index   The selected index.\r\n     *\r\n     *    @return The formatted value of an expression in the selected index.\r\n     */\r\n    virtual QVariant formattedExpressionForIndex(QModelIndex const& index) const override final;\r\n\r\n    /*!\r\n     *  Get the expression of the selected index.\r\n     *\r\n     *    @param [in] index   The selected index.\r\n     *\r\n     *    @return The expression of the selected index.\r\n     */\r\n    virtual QVariant expressionForIndex(QModelIndex const& index) const override final;\r\n\r\n    /*!\r\n     *  Gets the value for the given index.\r\n     *\r\n     *    @param [in] index   The index of the target data.\r\n     *\r\n     *    @return The data in the given index.\r\n     */\r\n    virtual QVariant valueForIndex(QModelIndex const& index) const override final;\r\n\r\nprivate:\r\n\t\r\n    //! No copying.\tNo assignment.\r\n\tMemoryMapModel(const MemoryMapModel& other);\r\n\tMemoryMapModel& operator=(const MemoryMapModel& other);\r\n\r\n    /*!\r\n     *  Get the index of the name column.\r\n     *\r\n     *    @return Index of the name column.\r\n     */\r\n    virtual int nameColumn() const override final;\r\n\r\n    /*!\r\n     *  Get the index of the base address column.\r\n     *\r\n     *    @return Index of the base address column.\r\n     */\r\n    virtual int baseAddressColumn() const override final;\r\n\r\n    /*!\r\n     *  Get the index of the is present column.\r\n     *\r\n     *    @return Index of the is present column.\r\n     */\r\n    virtual int isPresentColumn() const override final;\r\n\r\n    /*!\r\n     *  Get the index of the description column.\r\n     *\r\n     *    @return Index of the description column.\r\n     */\r\n    virtual int descriptionColumn() const override final;\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! Interface for address blocks.\r\n    AddressBlockInterface* localBlockInterface_;\r\n};\r\n\r\n#endif // MEMORYMAPMODEL_H\r\n"
  },
  {
    "path": "editors/ComponentEditor/memoryMaps/memorymapsdelegate.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: memorymapsdelegate.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 22.08.2012\r\n//\r\n// Description:\r\n// The delegate to provide editor for adding/removing/editing the memory maps of a component.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"memorymapsdelegate.h\"\r\n\r\n#include <editors/ComponentEditor/memoryMaps/MemoryMapsColumns.h>\r\n#include <editors/ComponentEditor/common/ReferenceSelector/ReferenceSelector.h>\r\n\r\n#include <QLineEdit>\r\n#include <QPainter>\r\n#include <QPen>\r\n#include <QRegularExpression>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: memorymapsdelegate::MemoryMapsDelegate()\r\n//-----------------------------------------------------------------------------\r\nMemoryMapsDelegate::MemoryMapsDelegate(QAbstractItemModel* completionModel,\r\n    QSharedPointer<ParameterFinder> parameterFinder,\r\n    QStringList remapStateNames, QObject *parent):\r\nExpressionDelegate(completionModel, parameterFinder, parent),\r\n    remapStateNames_(remapStateNames)\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: memorymapsdelegate::~MemoryMapsDelegate()\r\n//-----------------------------------------------------------------------------\r\nMemoryMapsDelegate::~MemoryMapsDelegate()\r\n{\r\n    \r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: memorymapsdelegate::createEditor()\r\n//-----------------------------------------------------------------------------\r\nQWidget* MemoryMapsDelegate::createEditor( QWidget* parent, const QStyleOptionViewItem& option,\r\n    const QModelIndex& index ) const\r\n{\r\n    if (index.column() == MemoryMapsColumns::NAME_COLUMN)\r\n    {\r\n        QLineEdit* edit = new QLineEdit(parent);\r\n        connect(edit, SIGNAL(editingFinished()), this, SLOT(commitAndCloseEditor()), Qt::UniqueConnection);\r\n        return edit;\r\n    }\r\n    else if (index.column() == MemoryMapsColumns::REMAPSTATE_COLUMN)\r\n    {\r\n        ReferenceSelector* referenceSelector = new ReferenceSelector(parent);\r\n\r\n        referenceSelector->refresh(remapStateNames_);\r\n        return referenceSelector;\r\n    }\r\n    else\r\n    {\r\n        return ExpressionDelegate::createEditor(parent, option, index);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: memorymapsdelegate::setEditorData()\r\n//-----------------------------------------------------------------------------\r\nvoid MemoryMapsDelegate::setEditorData( QWidget* editor, const QModelIndex& index ) const\r\n{\r\n    if (index.column() == MemoryMapsColumns::NAME_COLUMN)\r\n    {\r\n        QLineEdit* edit = qobject_cast<QLineEdit*>(editor);\r\n        Q_ASSERT(edit);\r\n\r\n        const QString text = index.data(Qt::DisplayRole).toString();\r\n        edit->setText(text);\r\n    }\r\n    else if (index.column() == MemoryMapsColumns::REMAPSTATE_COLUMN)\r\n    {\r\n        QString text = index.model()->data(index, Qt::DisplayRole).toString();\r\n        \r\n        if (text == tr(\"No remap state selected.\"))\r\n        {\r\n            text = \"\";\r\n        }\r\n\r\n        ReferenceSelector* referenceSelector = qobject_cast<ReferenceSelector*>(editor);\r\n\r\n        referenceSelector->selectItem(text);\r\n    }\r\n    else\r\n    {\r\n        ExpressionDelegate::setEditorData(editor, index);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: memorymapsdelegate::setModelData()\r\n//-----------------------------------------------------------------------------\r\nvoid MemoryMapsDelegate::setModelData( QWidget* editor, QAbstractItemModel* model, const QModelIndex& index ) const\r\n{\r\n    if (index.column() == MemoryMapsColumns::NAME_COLUMN)\r\n    {\r\n        QLineEdit* edit = qobject_cast<QLineEdit*>(editor);\r\n        Q_ASSERT(edit);\r\n\r\n        QString text = edit->text();\r\n        model->setData(index, text, Qt::EditRole);\r\n    }\r\n    else if (index.column() == MemoryMapsColumns::REMAPSTATE_COLUMN)\r\n    {\r\n        ReferenceSelector* referenceSelector = qobject_cast<ReferenceSelector*>(editor);\r\n        QString text = referenceSelector->currentText();\r\n        model->setData(index, text, Qt::EditRole);\r\n    }\r\n    else\r\n    {\r\n        ExpressionDelegate::setModelData(editor, model, index);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryMapsDelegate::descriptionColumn()\r\n//-----------------------------------------------------------------------------\r\nint MemoryMapsDelegate::descriptionColumn() const\r\n{\r\n    return MemoryMapsColumns::DESCRIPTION_COLUMN;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: memorymapsdelegate::paint()\r\n//-----------------------------------------------------------------------------\r\nvoid MemoryMapsDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const\r\n{\r\n    QStyledItemDelegate::paint(painter, option, index);\r\n\r\n    QPen oldPen = painter->pen();\r\n    QPen newPen(Qt::lightGray);\r\n    newPen.setWidth(1);\r\n    painter->setPen(newPen);\r\n\r\n    painter->drawLine(option.rect.topRight(), option.rect.bottomRight());\r\n\r\n    painter->setPen(oldPen);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryMapsDelegate::columnAcceptsExpression()\r\n//-----------------------------------------------------------------------------\r\nbool MemoryMapsDelegate::columnAcceptsExpression(int column) const\r\n{\r\n    return column == MemoryMapsColumns::IS_PRESENT || column == MemoryMapsColumns::AUB_COLUMN;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: memorymapsdelegate::commitAndCloseEditor()\r\n//-----------------------------------------------------------------------------\r\nvoid MemoryMapsDelegate::commitAndCloseEditor()\r\n{\r\n\tQWidget* edit = qobject_cast<QWidget*>(sender());\r\n\tQ_ASSERT(edit);\r\n\r\n\temit commitData(edit);\r\n\temit closeEditor(edit);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: memorymapsdelegate::updateRemapStateNames()\r\n//-----------------------------------------------------------------------------\r\nvoid MemoryMapsDelegate::updateRemapStateNames(QStringList newRemapStateNames)\r\n{\r\n    remapStateNames_ = newRemapStateNames;\r\n}"
  },
  {
    "path": "editors/ComponentEditor/memoryMaps/memorymapsdelegate.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: memorymapsdelegate.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 22.08.2012\r\n//\r\n// Description:\r\n// The delegate to provide editor for adding/removing/editing the memory maps of a component.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef MEMORYMAPSDELEGATE_H\r\n#define MEMORYMAPSDELEGATE_H\r\n\r\n#include <editors/ComponentEditor/common/MultilineDescriptionDelegate.h>\r\n#include <editors/ComponentEditor/common/ExpressionDelegate.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n//! The delegate to provide editor for adding/removing/editing the memory maps of a component.\r\n//-----------------------------------------------------------------------------\r\nclass MemoryMapsDelegate : public ExpressionDelegate\r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\r\n    /*!\r\n\t *  The constructor.\r\n     *\r\n     *    @param [in] completionModel         Model containing the completions used in expression editor.\r\n     *    @param [in] parameterFinder         The parameter finder for expression editor.\r\n\t *    @param [in] remapStateNames         A list of names of the component remap states.\r\n\t *    @param [in] parent                  Pointer to the owner of the delegate.\r\n\t */\r\n    MemoryMapsDelegate(QAbstractItemModel* completionModel, QSharedPointer<ParameterFinder> parameterFinder,\r\n        QStringList remapStateNames, QObject *parent);\r\n\t\r\n\t//! The destructor.\r\n\tvirtual ~MemoryMapsDelegate();\r\n\r\n    /*!\r\n\t *  Create a new editor for the given item.\r\n\t *\r\n\t *    @param [in] parent  Owner for the editor.\r\n\t *    @param [in] option  Contains options for the editor.\r\n\t *    @param [in] index   Model index identifying the item.\r\n     *\r\n     *    @return Pointer to the editor to be used to edit the item.\r\n\t */\r\n\tvirtual QWidget* createEditor(QWidget* parent, const QStyleOptionViewItem& option, const QModelIndex& index)\r\n        const;\r\n\r\n    /*!\r\n\t *  Set the data for the editor.\r\n\t *\r\n\t *    @param [in] editor  Pointer to the editor where the data is to be set.\r\n\t *    @param [in] index   The index of the item that's data is to be set.\r\n\t */\r\n\tvirtual void setEditorData(QWidget* editor, const QModelIndex& index) const;\r\n\r\n    /*!\r\n\t *  Save the data from the editor to the model.\r\n\t *\r\n\t *    @param [in] editor  Pointer to the editor that contains the data to store.\r\n\t *    @param [in] model   Model that contains the data structure where data is to be saved to.\r\n\t *    @param [in] index   The inex of the item that's data is to be saved.\r\n\t */\r\n\tvirtual void setModelData(QWidget* editor, QAbstractItemModel* model, const QModelIndex& index) const;\r\n\r\n    /*!\r\n     *  Update the list of remap state names.\r\n     *\r\n     *    @param [in] newRemapStateNames  The new list of remap state names.\r\n     */\r\n    void updateRemapStateNames(QStringList newRemapStateNames);\r\n\r\n    /*!\r\n     *  Paint the memory maps.\r\n     *\r\n     *    @param [in] painter     The used painter.\r\n     *    @param [in] option      Available style options.\r\n     *    @param [in] index       The current index.\r\n     */\r\n    virtual void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const;\r\n\r\nprotected:\r\n\r\n    //! Gets the description column.\r\n    virtual int descriptionColumn() const;\r\n    \r\n    /*!\r\n     *  Checks if the given column supports expressions in the editor.\r\n     *\r\n     *    @param [in] column  The column to check.\r\n     *\r\n     *    @return True if the cells in the column allow expressions, otherwise false.\r\n     */\r\n    virtual bool columnAcceptsExpression(int column) const;\r\n\r\nprivate slots:\r\n\r\n    /*!\r\n\t *  Commit the data from the sending editor and close the editor.\r\n\t */\r\n\tvoid commitAndCloseEditor();\r\n\r\nprivate:\r\n\t\r\n\t//! No copying.\r\n\tMemoryMapsDelegate(const MemoryMapsDelegate& other);\r\n\r\n\t//! No assignment.\r\n\tMemoryMapsDelegate& operator=(const MemoryMapsDelegate& other);\r\n\r\n    //! A list of the components remap state names.\r\n    QStringList remapStateNames_;\r\n};\r\n\r\n#endif // MEMORYMAPSDELEGATE_H\r\n"
  },
  {
    "path": "editors/ComponentEditor/memoryMaps/memorymapseditor.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: memorymapseditor.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 11.04.2012\r\n//\r\n// Description:\r\n// Editor for editing the memory maps of a component.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"memorymapseditor.h\"\r\n#include \"memorymapsmodel.h\"\r\n#include \"MemoryMapsColumns.h\"\r\n#include \"MemoryMapsView.h\"\r\n\r\n#include <common/widgets/summaryLabel/summarylabel.h>\r\n#include <common/views/EditableTreeView/EditableTreeSortFilter.h>\r\n\r\n#include <editors/ComponentEditor/parameters/ComponentParameterModel.h>\r\n#include <KactusAPI/include/MemoryMapInterface.h>\r\n\r\n#include <KactusAPI/include/LibraryInterface.h>\r\n\r\n#include <IPXACTmodels/Component/Component.h>\r\n#include <IPXACTmodels/Component/MemoryMap.h>\r\n#include <IPXACTmodels/Component/RemapState.h>\r\n\r\n#include <QCompleter>\r\n#include <QVBoxLayout>\r\n#include <QHeaderView>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: memorymapseditor::MemoryMapsEditor()\r\n//-----------------------------------------------------------------------------\r\nMemoryMapsEditor::MemoryMapsEditor(MemoryMapInterface* mapInterface, QSharedPointer<Component> component,\r\n    QSharedPointer<ParameterFinder> parameterFinder, QSharedPointer<ExpressionParser> expressionParser,\r\n    LibraryInterface* handler, QWidget *parent):\r\nItemEditor(component, handler, parent),\r\nview_(new MemoryMapsView(this)),\r\nproxy_(new EditableTreeSortFilter(this)),\r\nmodel_(new MemoryMapsModel(parameterFinder, expressionParser, mapInterface, component->getRevision(),\r\n    fontMetrics().height() + 8, this)),\r\ndelegate_(),\r\ninterface_(mapInterface),\r\ncomponent_(component)\r\n{\r\n    view_->setUniformRowHeights(true);\r\n\r\n    mapInterface->setMemoryMaps(component);\r\n\r\n    // display a label on top the table\r\n    SummaryLabel* summaryLabel = new SummaryLabel(tr(\"Memory maps summary\"), this);\r\n\r\n    QVBoxLayout* layout = new QVBoxLayout(this);\r\n    layout->addWidget(summaryLabel, 0, Qt::AlignCenter);\r\n\tlayout->addWidget(view_);\r\n\tlayout->setContentsMargins(0, 0, 0, 0);\r\n\r\n\tproxy_->setSourceModel(model_);\r\n\tview_->setModel(proxy_);\r\n\r\n    // Set case-insensitive sorting.\r\n    proxy_->setSortCaseSensitivity(Qt::CaseInsensitive);\r\n\r\n\tconst QString compPath = ItemEditor::handler()->getDirectoryPath(ItemEditor::component()->getVlnv());\r\n\tQString defPath = QString(\"%1/memMapsList.csv\").arg(compPath);\r\n\tview_->setDefaultImportExportPath(defPath);\r\n\tview_->setAllowImportExport(true);\r\n\tview_->setSortingEnabled(true);\r\n\r\n    ComponentParameterModel* componentParametersModel = new ComponentParameterModel(parameterFinder, this);\r\n    componentParametersModel->setExpressionParser(expressionParser);\r\n\r\n    delegate_ = new MemoryMapsDelegate(componentParametersModel, parameterFinder, getRemapStateNames(), this);\r\n    view_->setItemDelegate(delegate_);\r\n\r\n    QHeaderView* header = new QHeaderView(Qt::Horizontal, this);\r\n    header->setStretchLastSection(true);\r\n    view_->setHeader(header);\r\n\r\n    if (component->getRevision() == Document::Revision::Std22)\r\n    {\r\n        view_->hideColumn(MemoryMapsColumns::IS_PRESENT);\r\n    }\r\n\r\n    connectSignals();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: memorymapseditor::~MemoryMapsEditor()\r\n//-----------------------------------------------------------------------------\r\nMemoryMapsEditor::~MemoryMapsEditor()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: memorymapseditor::connectSignals()\r\n//-----------------------------------------------------------------------------\r\nvoid MemoryMapsEditor::connectSignals()\r\n{\r\n    connect(model_, SIGNAL(contentChanged()), this, SIGNAL(contentChanged()), Qt::UniqueConnection);\r\n    connect(model_, SIGNAL(graphicsChanged()), this, SIGNAL(graphicsChanged()), Qt::UniqueConnection);\r\n    connect(model_, SIGNAL(memoryMapAdded(int)), this, SIGNAL(childAdded(int)), Qt::UniqueConnection);\r\n    connect(model_, SIGNAL(memoryMapRemoved(int)), this, SIGNAL(childRemoved(int)), Qt::UniqueConnection);\r\n\r\n    connect(model_, SIGNAL(increaseReferences(QString)),\r\n        this, SIGNAL(increaseReferences(QString)), Qt::UniqueConnection);\r\n    connect(model_, SIGNAL(decreaseReferences(QString)),\r\n        this, SIGNAL(decreaseReferences(QString)), Qt::UniqueConnection);\r\n\r\n    connect(view_->itemDelegate(), SIGNAL(increaseReferences(QString)),\r\n        this, SIGNAL(increaseReferences(QString)), Qt::UniqueConnection);\r\n    connect(view_->itemDelegate(), SIGNAL(decreaseReferences(QString)),\r\n        this, SIGNAL(decreaseReferences(QString)), Qt::UniqueConnection);\r\n\r\n    connect(model_, SIGNAL(memoryRemapAdded(int, QString const&)),\r\n        this, SIGNAL(memoryRemapAdded(int, QString const&)), Qt::UniqueConnection);\r\n    connect(model_, SIGNAL(memoryRemapRemoved(int, QString const&)),\r\n        this, SIGNAL(memoryRemapRemoved(int, QString const&)), Qt::UniqueConnection);\r\n\r\n    connect(model_, SIGNAL(aubChangedOnRow(int)), \r\n        this, SIGNAL(changeInAddressUnitBitsOnRow(int)), Qt::UniqueConnection);\r\n\r\n    connect(view_, SIGNAL(addItems(QModelIndexList const&)),\r\n        proxy_, SLOT(onAddItem(QModelIndexList const&)), Qt::UniqueConnection);\r\n    connect(proxy_, SIGNAL(addItem(QModelIndex const&)),\r\n        model_, SLOT(onAddItem(QModelIndex const&)), Qt::UniqueConnection);\r\n\r\n    connect(view_, SIGNAL(addSubItem(QModelIndexList const&)), \r\n        proxy_, SLOT(onAddSubItem(QModelIndexList const&)), Qt::UniqueConnection);\r\n    connect(proxy_, SIGNAL(addSubItem(QModelIndex const&)),\r\n        model_, SLOT(onAddMemoryRemap(const QModelIndex&)), Qt::UniqueConnection);\r\n\r\n    connect(view_, SIGNAL(removeSelectedItems(QModelIndexList const&)),\r\n        proxy_, SLOT(onRemoveSelectedRows(QModelIndexList const&)), Qt::UniqueConnection);\r\n    connect(proxy_, SIGNAL(removeItem(QModelIndex const&)),\r\n        model_, SLOT(onRemoveItem(QModelIndex const&)), Qt::UniqueConnection);\r\n\r\n    connect(view_, SIGNAL(removeAllSubItems(QModelIndexList const&)),\r\n        proxy_, SLOT(onRemoveAllSubItemsFromIndexes(QModelIndexList const&)), Qt::UniqueConnection);\r\n    connect(proxy_, SIGNAL(removeAllSubItemsFromIndex(QModelIndex const&)),\r\n        model_, SLOT(onRemoveAllChildItemsFrom(QModelIndex const&)), Qt::UniqueConnection);\r\n\r\n    connect(view_, SIGNAL(doubleClicked(const QModelIndex&)),\r\n        this, SLOT(onDoubleClick(const QModelIndex&)), Qt::UniqueConnection);\r\n\r\n    connect(view_, SIGNAL(copyRows(QModelIndexList)),\r\n        model_, SLOT(onCopyRows(QModelIndexList)), Qt::UniqueConnection);\r\n    connect(view_, SIGNAL(pasteRows(QModelIndex)), model_, SLOT(onPasteRows(QModelIndex)), Qt::UniqueConnection);\r\n\r\n    connect(model_, SIGNAL(memoryMapNameChanged(QString const&, QString const&)),\r\n        this, SIGNAL(memoryMapNameChanged(QString const&, QString const&)), Qt::UniqueConnection);\r\n    connect(model_, SIGNAL(memoryRemapNameChanged(QString const&, QString const&, QString const&)), this,\r\n        SIGNAL(memoryRemapNameChanged(QString const&, QString const&, QString const&)), Qt::UniqueConnection);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: memorymapseditor::refresh()\r\n//-----------------------------------------------------------------------------\r\nvoid MemoryMapsEditor::refresh()\r\n{\r\n    delegate_->updateRemapStateNames(getRemapStateNames());\r\n\tview_->update();\r\n    view_->expandAll();\r\n\r\n    interface_->setMemoryMaps(component_);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: memorymapseditor::getRemapStateNames()\r\n//-----------------------------------------------------------------------------\r\nQStringList MemoryMapsEditor::getRemapStateNames() const\r\n{\r\n    QStringList remapStateNames;\r\n    for (auto const& remapState : *component()->getRemapStates())\r\n    {\r\n        remapStateNames.append(remapState->name());\r\n    }\r\n\r\n    return remapStateNames;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: memorymapseditor::showEvent()\r\n//-----------------------------------------------------------------------------\r\nvoid MemoryMapsEditor::showEvent( QShowEvent* event )\r\n{\r\n\tQWidget::showEvent(event);\r\n\r\n    if (component()->getRevision() == Document::Revision::Std22)\r\n    {\r\n        emit helpUrlRequested(\"componenteditor/memorymaps2022.html\");\r\n    }\r\n    else\r\n    {\r\n\t    emit helpUrlRequested(\"componenteditor/memorymaps.html\");\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: memorymapseditor::onDoubleClick()\r\n//-----------------------------------------------------------------------------\r\nvoid MemoryMapsEditor::onDoubleClick( const QModelIndex& index )\r\n{\r\n\tQModelIndex origIndex = proxy_->mapToSource(index);\r\n\t\r\n\t// index must be valid\r\n\tif (!origIndex.isValid())\r\n    {\r\n\t\treturn;\r\n\t}\r\n\r\n\t// if the column is for interface references\r\n    if (origIndex.column() == MemoryMapsColumns::INTERFACE_COLUMN)\r\n    {\r\n\t\t// get the names of the interface that refer to selected memory map\r\n\t\tQStringList busIfNames = model_->data(origIndex, Qt::UserRole).toStringList();\r\n\r\n\t\t// if there are no bus interfaces or there are many\r\n\t\tif (busIfNames.size() != 1)\r\n        {\r\n\t\t\treturn;\r\n\t\t}\r\n\t\t\r\n\t\t// inform component editor that bus interface editor should be selected\r\n\t\temit selectBusInterface(busIfNames.first());\r\n\t}\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: memorymapseditor::sizeHint()\r\n//-----------------------------------------------------------------------------\r\nQSize MemoryMapsEditor::sizeHint() const\r\n{\r\n\treturn QSize(MemoryMapsEditor::WIDTH, MemoryMapsEditor::HEIGHT);\r\n}\r\n"
  },
  {
    "path": "editors/ComponentEditor/memoryMaps/memorymapseditor.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: memorymapseditor.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 11.04.2012\r\n//\r\n// Description:\r\n// Editor for editing the memory maps of a component.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef MEMORYMAPSEDITOR_H\r\n#define MEMORYMAPSEDITOR_H\r\n\r\n#include \"memorymapsdelegate.h\"\r\n\r\n#include <editors/ComponentEditor/itemeditor.h>\r\n#include <KactusAPI/include/ParameterFinder.h>\r\n\r\n#include <QWidget>\r\n#include <QSharedPointer>\r\n#include <QSortFilterProxyModel>\r\n\r\nclass LibraryInterface;\r\nclass MemoryMapsView;\r\nclass MemoryMapsModel;\r\nclass Component;\r\nclass MemoryMap;\r\nclass ExpressionFormatter;\r\nclass ExpressionParser;\r\nclass MemoryMapValidator;\r\nclass EditableTreeSortFilter;\r\nclass MemoryMapInterface;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Editor for editing the memory maps of a component.\r\n//-----------------------------------------------------------------------------\r\nclass MemoryMapsEditor : public ItemEditor\r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\r\n\t//! The default height and width of the editor.\r\n\tenum Sizes\r\n    {\r\n\t\tHEIGHT = 300,\r\n\t\tWIDTH = 700\r\n\t};\r\n\r\n\t/*!\r\n\t *  The constructor.\r\n\t *\r\n     *    @param [in] mapInterface        Interface for memory maps.\r\n\t *    @param [in] component           The component being edited.\r\n\t *    @param [in] parameterFinder     The parameter finder.\r\n     *    @param [in] expressionParser    The used expression parser.\r\n\t *    @param [in] handler             The instance managing the library.\r\n\t *    @param [in] parent              The owner of this editor.\r\n\t */\r\n\tMemoryMapsEditor(MemoryMapInterface* mapInterface,\r\n        QSharedPointer<Component> component,\r\n        QSharedPointer<ParameterFinder> parameterFinder,\r\n        QSharedPointer<ExpressionParser> expressionParser,\r\n\t\tLibraryInterface* handler,\r\n        QWidget *parent = 0);\r\n\t\r\n\t//! The destructor.\r\n\tvirtual ~MemoryMapsEditor();\r\n\r\n\t/*!\r\n     *  Reload the information from the model to the editor.\r\n\t */\r\n\tvirtual void refresh();\r\n\r\n\t/*!\r\n     *  The size hint for the editor.\r\n\t *\r\n\t *    @return QSize contains the size hint.\r\n\t */\r\n\tvirtual QSize sizeHint() const;\r\n\r\nsignals:\r\n\r\n\t//! Emitted when a bus interface editor should be opened.\r\n\tvoid selectBusInterface(const QString& interfaceName);\r\n\r\n    /*!\r\n     *  Emitted when address unit bits are changed.\r\n     *\r\n     *    @param [in] memoryMapIndex   The index of the changed memory map.\r\n     */\r\n    void changeInAddressUnitBitsOnRow(int memoryMapIndex);\r\n\r\n    /*!\r\n     *  Inform of the added memory remap.\r\n     *\r\n     *    @param [in] memoryRemapIndex        The index of the new memory remap.\r\n     *    @param [in] parentMemoryMapName     Name of the owner of the new memory remap.\r\n     */\r\n    void memoryRemapAdded(int memoryRemapIndex, QString const& parentMemoryMapName);\r\n\r\n    /*!\r\n     *  Inform of the removed memory remap.\r\n     *\r\n     *    @param [in] memoryRemapIndex        The index of the removed memory remap.\r\n     *    @param [in] parentMemoryMapName     Name of the owner of the removed memory remap.\r\n     */\r\n    void memoryRemapRemoved(int memoryRemapIndex, QString const& parentMemoryMapName);\r\n    \r\n    /*\r\n     *  Informs of memory map name change.\r\n     *\r\n     *    @param [in] oldName     The old name.\r\n     *    @param [in] newName     The new name.\r\n     */\r\n    void memoryMapNameChanged(QString const& oldName, QString const& newName);\r\n\r\n    /*\r\n     *  Informs of memory remap name change.\r\n     *\r\n     *    @param [in] parentName  Name of the containing memory map.\r\n     *    @param [in] oldName     The old name.\r\n     *    @param [in] newName     The new name.\r\n     */\r\n    void memoryRemapNameChanged(QString const& parentName, QString const& oldName, QString const& newName);\r\n\r\nprotected:\r\n\r\n\t//! Handler for widget's show event.\r\n\tvirtual void showEvent(QShowEvent* event);\r\n\r\nprivate slots:\r\n\r\n\t//! Handler for view's doubleClicked-signal.\r\n\tvirtual void onDoubleClick(const QModelIndex& index);\r\n\r\nprivate:\r\n\t\r\n\t//! No copying.\r\n\tMemoryMapsEditor(const MemoryMapsEditor& other);\r\n\r\n\t//! No assignment.\r\n\tMemoryMapsEditor& operator=(const MemoryMapsEditor& other);\r\n\r\n    /*!\r\n     *  Gets the names of the components remap states.\r\n     *\r\n     *    @return A list containing all the names of the remap states.\r\n     */\r\n    QStringList getRemapStateNames() const;\r\n\r\n    /*!\r\n     *  Connect signals.\r\n     */\r\n    void connectSignals();\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n\t//! The view to display the table.\r\n    MemoryMapsView* view_;\r\n\r\n\t//! The proxy that does the sorting of items.\r\n    EditableTreeSortFilter* proxy_;\r\n\r\n\t//! The model that manages the memory maps.\r\n\tMemoryMapsModel* model_;\r\n\r\n    //! The delegate of the view.\r\n    MemoryMapsDelegate* delegate_;\r\n\r\n    //! Interface for memory maps.\r\n    MemoryMapInterface* interface_;\r\n\r\n    //! Component containing the memory maps.\r\n    QSharedPointer<Component> component_;\r\n};\r\n\r\n#endif // MEMORYMAPSEDITOR_H\r\n"
  },
  {
    "path": "editors/ComponentEditor/memoryMaps/memorymapsmodel.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: memorymapsmodel.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 21.08.2012\r\n//\r\n// Description:\r\n// The model to manage the memory maps summary.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"memorymapsmodel.h\"\r\n\r\n#include \"MemoryMapsColumns.h\"\r\n\r\n#include <KactusAPI/include/ExpressionFormatter.h>\r\n#include <KactusAPI/include/MemoryMapInterface.h>\r\n#include <KactusAPI/include/MemoryMapExpressionsGatherer.h>\r\n#include <KactusAPI/include//MemoryRemapExpressionGatherer.h>\r\n#include <editors/ComponentEditor/memoryMaps/memoryMapsExpressionCalculators/ReferenceCalculator.h>\r\n\r\n#include <IPXACTmodels/Component/Component.h>\r\n#include <IPXACTmodels/Component/MemoryMapBase.h>\r\n#include <IPXACTmodels/Component/MemoryMap.h>\r\n#include <IPXACTmodels/Component/MemoryRemap.h>\r\n#include <IPXACTmodels/Component/MemoryBlockBase.h>\r\n#include <IPXACTmodels/Component/validators/MemoryMapValidator.h>\r\n\r\n#include <common/KactusColors.h>\r\n\r\n#include <QRegularExpression>\r\n#include <QApplication>\r\n#include <QClipboard>\r\n#include <QMimeData>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: memorymapsmodel::MemoryMapsModel()\r\n//-----------------------------------------------------------------------------\r\nMemoryMapsModel::MemoryMapsModel(QSharedPointer<ParameterFinder> parameterFinder,\r\n    QSharedPointer<ExpressionParser> expressionParser, MemoryMapInterface* mapInterface,\r\n    Document::Revision docRevision, const int ROWHEIGHT, QObject *parent):\r\nQAbstractItemModel(parent),\r\nParameterizableTable(parameterFinder),\r\nmapInterface_(mapInterface),\r\ndocRevision_(docRevision),\r\nROWHEIGHT_(ROWHEIGHT)\r\n{\r\n    setExpressionParser(expressionParser);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: memorymapsmodel::rowCount()\r\n//-----------------------------------------------------------------------------\r\nint MemoryMapsModel::rowCount( const QModelIndex& parent /*= QModelIndex()*/ ) const\r\n{\r\n    if (!parent.isValid())\r\n    {\r\n        return mapInterface_->itemCount();\r\n    }\r\n\r\n    else if (!parent.parent().isValid())\r\n    {\r\n        return mapInterface_->remapCount(mapInterface_->getIndexedItemName(parent.row()));\r\n    }\r\n\r\n    else\r\n    {\r\n        return 0;\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: memorymapsmodel::columnCount()\r\n//-----------------------------------------------------------------------------\r\nint MemoryMapsModel::columnCount(QModelIndex const& /*parent*/) const\r\n{\r\n    return MemoryMapsColumns::COLUMN_COUNT;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: memorymapsmodel::flags()\r\n//-----------------------------------------------------------------------------\r\nQt::ItemFlags MemoryMapsModel::flags(QModelIndex const& index) const\r\n{\r\n    if (!index.isValid())\r\n    {\r\n        return Qt::NoItemFlags;\r\n    }\r\n\r\n\t// interface references are made in bus interface editor\r\n    if (index.column() == MemoryMapsColumns::INTERFACE_COLUMN)\r\n    {\r\n\t\treturn Qt::ItemIsEnabled | Qt::ItemIsSelectable;\r\n\t}\r\n\r\n    if (docRevision_ == Document::Revision::Std22)\r\n    {\r\n        if (index.column() == MemoryMapsColumns::REMAPSTATE_COLUMN)\r\n        {\r\n            return Qt::ItemIsEnabled | Qt::ItemIsSelectable;\r\n        }\r\n\r\n        if (index.parent().isValid() && index.column() == MemoryMapsColumns::AUB_COLUMN)\r\n        {\r\n            return Qt::ItemIsEnabled | Qt::ItemIsSelectable;\r\n        }\r\n    }\r\n    else\r\n    {\r\n        if ((!index.parent().isValid() && index.column() == MemoryMapsColumns::REMAPSTATE_COLUMN) ||\r\n            (index.parent().isValid() && index.column() == MemoryMapsColumns::AUB_COLUMN))\r\n        {\r\n            return Qt::ItemIsEnabled | Qt::ItemIsSelectable;\r\n        }\r\n    }\r\n\r\n\treturn Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsEditable;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: memorymapsmodel::headerData()\r\n//-----------------------------------------------------------------------------\r\nQVariant MemoryMapsModel::headerData(int section, Qt::Orientation orientation, int role)\r\n    const\r\n{\r\n\tif (orientation != Qt::Horizontal)\r\n    {\r\n\t\treturn QVariant();\r\n\t}\r\n\tif (role == Qt::DisplayRole)\r\n    {\r\n        if (section == MemoryMapsColumns::NAME_COLUMN)\r\n        {\r\n            return tr(\"Memory map\\nname\");\r\n        }\r\n        else if (section == MemoryMapsColumns::REMAPSTATE_COLUMN)\r\n        {\r\n            return docRevision_ == Document::Revision::Std22 ? tr(\"Mode reference\") : tr(\"Remap state\");\r\n        }\r\n        else if (section == MemoryMapsColumns::AUB_COLUMN)\r\n        {\r\n            return tr(\"Address unit\\nbits (AUB)\") + getExpressionSymbol();\r\n        }\r\n        else if (section == MemoryMapsColumns::INTERFACE_COLUMN)\r\n        {\r\n            if (docRevision_ == Document::Revision::Std22)\r\n            {\r\n                return tr(\"Target interface\\nbinding\");\r\n            }\r\n            return tr(\"Slave interface\\nbinding\");\r\n        }\r\n        else if (section == MemoryMapsColumns::IS_PRESENT)\r\n        {\r\n            return tr(\"Is present\") + getExpressionSymbol();\r\n        }\r\n        else if (section == MemoryMapsColumns::DESCRIPTION_COLUMN)\r\n        {\r\n            return tr(\"Description\");\r\n        }\r\n\t}\r\n\r\n    return QVariant();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: memorymapsmodel::data()\r\n//-----------------------------------------------------------------------------\r\nQVariant MemoryMapsModel::data(QModelIndex const& index, int role) const\r\n{\r\n\tif (!index.isValid() || !isIndexValid(index))\r\n    {\r\n\t\treturn QVariant();\r\n\t}\r\n\r\n    if (role == Qt::DisplayRole) \r\n    {\r\n        if (isValidExpressionColumn(index))\r\n        {\r\n            return formattedExpressionForIndex(index);\r\n        }\r\n        else if (index.column() == MemoryMapsColumns::DESCRIPTION_COLUMN)\r\n        {\r\n            return valueForIndex(index).toString().replace(QRegularExpression(\"\\n.*$\", \r\n                QRegularExpression::DotMatchesEverythingOption), \"...\");\r\n        }\r\n        else\r\n        {\r\n            return valueForIndex(index);\r\n        }\r\n    }\r\n    else if (role == Qt::EditRole)\r\n    {\r\n        return expressionOrValueForIndex(index);\r\n    }\r\n    else if (role == Qt::ToolTipRole)\r\n    {\r\n        return valueForIndex(index);\r\n    }\r\n\telse if (role == Qt::UserRole)\r\n    {\r\n        QPair<QString, QString> mapRemapNames = getIndexedMapRemapNames(index);\r\n        QString mapName = mapRemapNames.first;\r\n\r\n        QStringList slaves;\r\n        for (auto associatedSlave : mapInterface_->getAssociatedSlaveInterfaces(mapName.toStdString()))\r\n        {\r\n            slaves.append(QString::fromStdString(associatedSlave));\r\n        }\r\n\r\n        return slaves;\r\n    }\r\n\telse if (role == Qt::ForegroundRole)\r\n    {\r\n        if (index.column() == MemoryMapsColumns::INTERFACE_COLUMN ||\r\n            (!index.parent().isValid() && index.column() == MemoryMapsColumns::REMAPSTATE_COLUMN) ||\r\n            (index.parent().isValid() && index.column() == MemoryMapsColumns::AUB_COLUMN))\r\n        {\r\n            return KactusColors::DISABLED_TEXT;\r\n        }\r\n\r\n        if (docRevision_ == Document::Revision::Std22 && index.column() == MemoryMapsColumns::REMAPSTATE_COLUMN)\r\n        {\r\n            if (index.data(Qt::DisplayRole).toString() == \"None\")\r\n            {\r\n                return KactusColors::ERROR;\r\n            }\r\n\r\n            return KactusColors::DISABLED_TEXT;\r\n        }\r\n\r\n        return blackForValidOrRedForInvalidIndex(index);\r\n\t}\r\n\telse if (role == Qt::BackgroundRole)\r\n    {\r\n        if (docRevision_ == Document::Revision::Std22)\r\n        {\r\n            if (index.column() == MemoryMapsColumns::NAME_COLUMN)\r\n            {\r\n                return KactusColors::MANDATORY_FIELD;\r\n            }\r\n            else if (index.column() == MemoryMapsColumns::REMAPSTATE_COLUMN)\r\n            {\r\n                return KactusColors::DISABLED_FIELD;\r\n            }\r\n            else\r\n            {\r\n                return KactusColors::REGULAR_FIELD;\r\n            }\r\n        }\r\n\r\n        if (index.column() == MemoryMapsColumns::NAME_COLUMN ||\r\n            index.column() == MemoryMapsColumns::REMAPSTATE_COLUMN)\r\n        {\r\n            return KactusColors::MANDATORY_FIELD;\r\n        }\r\n        else\r\n        {\r\n            return KactusColors::REGULAR_FIELD;\r\n        }\r\n\t}\r\n    else if (index.column() == MemoryMapsColumns::NAME_COLUMN && role == Qt::SizeHintRole)\r\n    {\r\n        return QSize(40, ROWHEIGHT_);\r\n    }\r\n    else if (role == Qt::FontRole)\r\n    {\r\n        return italicForEvaluatedValue(index);\r\n    }\r\n\r\n    return QVariant();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: memorymapsmodel::getIndexedMapRemapNames()\r\n//-----------------------------------------------------------------------------\r\nQPair<QString, QString> MemoryMapsModel::getIndexedMapRemapNames(QModelIndex const& index) const\r\n{\r\n    std::string mapName = \"\";\r\n    std::string remapName = \"\";\r\n    if (index.parent().isValid())\r\n    {\r\n        mapName = mapInterface_->getIndexedItemName(index.parent().row());\r\n        remapName = mapInterface_->getIndexedRemapName(mapName, index.row());\r\n    }\r\n    else\r\n    {\r\n        mapName = mapInterface_->getIndexedItemName(index.row());\r\n    }\r\n\r\n    QPair<QString, QString> itemNames;\r\n    itemNames.first = QString::fromStdString(mapName);\r\n    itemNames.second = QString::fromStdString(remapName);\r\n\r\n    return itemNames;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: memorymapsmodel::setData()\r\n//-----------------------------------------------------------------------------\r\nbool MemoryMapsModel::setData( const QModelIndex& index, const QVariant& value, int role /*= Qt::EditRole*/ )\r\n{\r\n\tif (!index.isValid() || !isIndexValid(index))\r\n    {\r\n\t\treturn false;\r\n\t}\r\n\r\n    bool itemIsMemoryMap = !index.parent().isValid();\r\n\r\n    QPair<QString, QString> itemNames = getIndexedMapRemapNames(index);\r\n    std::string mapName = itemNames.first.toStdString();\r\n    std::string remapName = itemNames.second.toStdString();\r\n\r\n\tif (role == Qt::EditRole)\r\n    {\r\n        if (index.column() == MemoryMapsColumns::NAME_COLUMN)\r\n        {\r\n            QString parentMapName = QString::fromStdString(mapName);\r\n\r\n            if (itemIsMemoryMap)\r\n            {\r\n                mapInterface_->setName(mapName, value.toString().toStdString());\r\n\r\n                QString newName = QString::fromStdString(mapInterface_->getIndexedItemName(index.row()));\r\n\r\n                emit memoryMapNameChanged(parentMapName, newName);\r\n            }\r\n            else\r\n            {\r\n                mapInterface_->setRemapName(mapName, remapName, value.toString().toStdString());\r\n\r\n                QString oldName = QString::fromStdString(remapName);\r\n                QString newName = QString::fromStdString(mapInterface_->getIndexedRemapName(mapName, index.row()));\r\n\r\n                emit memoryRemapNameChanged(parentMapName, oldName, newName);\r\n            }\r\n\r\n            emit graphicsChanged();\r\n        }\r\n        else if (index.column() == MemoryMapsColumns::AUB_COLUMN && itemIsMemoryMap)\r\n        {\r\n            mapInterface_->setAddressUnitBits(mapName, value.toString().toStdString());\r\n            emit aubChangedOnRow(index.row());\r\n        }\r\n        else if (index.column() == MemoryMapsColumns::DESCRIPTION_COLUMN)\r\n        {\r\n            if (itemIsMemoryMap)\r\n            {\r\n                mapInterface_->setDescription(mapName, value.toString().toStdString());\r\n            }\r\n            else\r\n            {\r\n                mapInterface_->setRemapDescription(mapName, remapName, value.toString().toStdString());\r\n            }\r\n        }\r\n        else if (index.column() == MemoryMapsColumns::REMAPSTATE_COLUMN)\r\n        {\r\n            if (!itemIsMemoryMap)\r\n            {\r\n                mapInterface_->setRemapState(mapName, remapName, value.toString().toStdString());\r\n            }\r\n        }\r\n        else if (index.column() == MemoryMapsColumns::IS_PRESENT)\r\n        {\r\n            if (itemIsMemoryMap)\r\n            {\r\n                mapInterface_->setIsPresent(mapName, value.toString().toStdString());\r\n            }\r\n            else\r\n            {\r\n                mapInterface_->setIsPresent(mapName, value.toString().toStdString(), remapName);\r\n            }\r\n\r\n            emit graphicsChanged();\r\n        }\r\n\r\n\t\temit dataChanged(index, index);\r\n\t\temit contentChanged();\r\n\t\treturn true;\r\n\t}\r\n\r\n    return false;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: memorymapsmodel::onAddItem()\r\n//-----------------------------------------------------------------------------\r\nvoid MemoryMapsModel::onAddItem( const QModelIndex& index )\r\n{\r\n    int row = mapInterface_->itemCount();\r\n\r\n\tif (index.isValid())\r\n    {\r\n        if (index.parent().isValid())\r\n        {\r\n            row = index.parent().row();\r\n        }\r\n        else\r\n        {\r\n            row = index.row();\r\n        }\r\n\t}\r\n\r\n\tbeginInsertRows(QModelIndex(), row, row);\r\n    mapInterface_->addMemoryMap(row);\r\n\tendInsertRows();\r\n\r\n\t// inform navigation tree that file set is added\r\n\temit memoryMapAdded(row);\r\n\r\n\t// tell also parent widget that contents have been changed\r\n\temit contentChanged();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: memorymapsmodel::onRemoveItem()\r\n//-----------------------------------------------------------------------------\r\nvoid MemoryMapsModel::onRemoveItem( const QModelIndex& index )\r\n{\r\n\tif (!index.isValid() || !isIndexValid(index))\r\n    {\r\n\t\treturn;\r\n\t}\r\n    QPair<QString, QString> itemNames = getIndexedMapRemapNames(index);\r\n    QString mapName = itemNames.first;\r\n    QString remapName = itemNames.second;\r\n\r\n    if (!index.parent().isValid())\r\n    {\r\n        decreaseReferencesWithRemovedMemoryMap(mapName, \"\");\r\n\r\n        beginRemoveRows(QModelIndex(), index.row(), index.row());\r\n        mapInterface_->removeMap(mapName.toStdString());\r\n        endRemoveRows();\r\n\r\n        // inform navigation tree that file set has been removed\r\n        emit memoryMapRemoved(index.row());\r\n\r\n        // tell also parent widget that contents have been changed\r\n    }\r\n    else\r\n    {\r\n        decreaseReferencesWithRemovedMemoryMap(mapName, remapName);\r\n\r\n        beginRemoveRows(index.parent(), index.row(), index.row());\r\n        mapInterface_->removeRemap(mapName.toStdString(), remapName.toStdString());\r\n        endRemoveRows();\r\n\r\n        emit memoryRemapRemoved(index.row(), mapName);\r\n    }\r\n\r\n    emit contentChanged();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: memorymapsmodel::decreaseReferencesWithRemovedMemoryMap()\r\n//-----------------------------------------------------------------------------\r\nvoid MemoryMapsModel::decreaseReferencesWithRemovedMemoryMap(QString const& mapName, QString const& remapName)\r\n{\r\n    auto expressionList = mapInterface_->getMapExpressions(mapName.toStdString(), remapName.toStdString());\r\n    QStringList expressionListQT;\r\n    for (auto const& expression : expressionList)\r\n    {\r\n        expressionListQT.append(QString::fromStdString(expression));\r\n    }\r\n\r\n    ReferenceCalculator memoryMapReferenceCalculator(getParameterFinder());\r\n    QMap<QString, int> referencedParameters =\r\n        memoryMapReferenceCalculator.getReferencedParameters(expressionListQT);\r\n\r\n    for (auto const& referencedId : referencedParameters.keys())\r\n    {\r\n        for (int i = 0; i < referencedParameters.value(referencedId); ++i)\r\n        {\r\n            emit decreaseReferences(referencedId);\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: memorymapsmodel::onAddMemoryRemap()\r\n//-----------------------------------------------------------------------------\r\nvoid MemoryMapsModel::onAddMemoryRemap(const QModelIndex& index)\r\n{\r\n    if (!index.isValid() || !isIndexValid(index) || index.parent().isValid())\r\n    {\r\n        return;\r\n    }\r\n\r\n    std::string parentMapName = mapInterface_->getIndexedItemName(index.row());\r\n    int rowOfNewItem = mapInterface_->remapCount(parentMapName);\r\n\r\n    increaseReferencesWithNewRemap(QString::fromStdString(parentMapName));\r\n\r\n    beginInsertRows(index, rowOfNewItem, rowOfNewItem);\r\n    mapInterface_->addMemoryRemap(parentMapName);\r\n    endInsertRows();\r\n\r\n    emit memoryRemapAdded(rowOfNewItem, QString::fromStdString(parentMapName));\r\n    emit contentChanged();\r\n}\r\n\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: memorymapsmodel::increaseReferencesWithNewRemap()\r\n//-----------------------------------------------------------------------------\r\nvoid MemoryMapsModel::increaseReferencesWithNewRemap(QString const& memoryMapName)\r\n{\r\n    auto expressionList = mapInterface_->getMapExpressions(memoryMapName.toStdString(), \"\");\r\n    QStringList expressionListQT;\r\n    for (auto const& expression : expressionList)\r\n    {\r\n        expressionListQT.append(QString::fromStdString(expression));\r\n    }\r\n\r\n    ReferenceCalculator memoryMapReferenceCalculator(getParameterFinder());\r\n    QMap<QString, int> referencedParameters =\r\n        memoryMapReferenceCalculator.getReferencedParameters(expressionListQT);\r\n\r\n    for (auto const& referencedId : referencedParameters.keys())\r\n    {\r\n        for (int i = 0; i < referencedParameters.value(referencedId); ++i)\r\n        {\r\n            emit increaseReferences(referencedId);\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: memorymapsmodel::index()\r\n//-----------------------------------------------------------------------------\r\nQModelIndex MemoryMapsModel::index(int row, int column, const QModelIndex &parent /* = QModelIndex() */ ) const\r\n{\r\n    if (!parent.isValid() && 0 <= row && row < mapInterface_->itemCount())\r\n    {\r\n        std::string mapName = mapInterface_->getIndexedItemName(row);\r\n        return createIndex(row, column, mapInterface_->getMapPointer(mapName));\r\n    }\r\n    else\r\n    {\r\n        std::string mapName = mapInterface_->getIndexedItemName(parent.row());\r\n        std::string remapName = mapInterface_->getIndexedRemapName(mapName, row);\r\n\r\n        return createIndex(row, column, mapInterface_->getRemapPointer(mapName, remapName));\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: memorymapsmodel::parent()\r\n//-----------------------------------------------------------------------------\r\nQModelIndex MemoryMapsModel::parent(const QModelIndex &child) const\r\n{\r\n    if (!child.isValid())\r\n    {\r\n        return QModelIndex();\r\n    }\r\n\r\n    for (auto mapName : mapInterface_->getItemNames())\r\n    {\r\n        MemoryMap* mapPointer = mapInterface_->getMapPointer(mapName);\r\n        if (mapPointer && mapPointer == child.internalPointer())\r\n        {\r\n            return QModelIndex();\r\n        }\r\n    }\r\n\r\n    MemoryRemap* childItem = static_cast<MemoryRemap*>(child.internalPointer());\r\n    if (childItem)\r\n    {\r\n        return createParentIndexForMemoryRemap(childItem);\r\n    }\r\n    else\r\n    {\r\n        return QModelIndex();\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: memorymapsmodel::createParentIndexForChildItem()\r\n//-----------------------------------------------------------------------------\r\nQModelIndex MemoryMapsModel::createParentIndexForMemoryRemap(MemoryRemap* childItem) const\r\n{\r\n    std::string remapName = childItem->name().toStdString();\r\n    for (int i = 0; i < mapInterface_->itemCount(); ++i)\r\n    {\r\n        std::string mapName = mapInterface_->getIndexedItemName(i);\r\n        MemoryRemap* remapPointer = mapInterface_->getRemapPointer(mapName, remapName);\r\n        if (remapPointer == childItem)\r\n        {\r\n            MemoryMap* mapPointer = mapInterface_->getMapPointer(mapName);\r\n            return createIndex(i, 0, mapPointer);\r\n        }\r\n    }\r\n\r\n    //! This should not be reached.\r\n    return QModelIndex();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: memorymapsmodel::isIndexValid()\r\n//-----------------------------------------------------------------------------\r\nbool MemoryMapsModel::isIndexValid(QModelIndex const& index) const\r\n{\r\n    if (!index.parent().isValid())\r\n    {\r\n        if (index.row() < 0 || index.row() >= mapInterface_->itemCount())\r\n        {\r\n            return false;\r\n        }\r\n        else\r\n        {\r\n            return true;\r\n        }\r\n    }\r\n\r\n    else\r\n    {\r\n        std::string mapName = mapInterface_->getIndexedItemName(index.parent().row());\r\n        if (index.row() < 0 || index.row() >= mapInterface_->remapCount(mapName))\r\n        {\r\n            return false;\r\n        }\r\n        else\r\n        {\r\n            return true;\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: memorymapsmodel::onCopyRows()\r\n//-----------------------------------------------------------------------------\r\nvoid MemoryMapsModel::onCopyRows(QModelIndexList const& indexList)\r\n{\r\n    std::vector<std::string> copiedRows;\r\n    for (auto const& index : indexList)\r\n    {\r\n        QString row = QString::number(index.row());\r\n        if (index.parent().isValid())\r\n        {\r\n            row = QString::number(index.parent().row()) + \"_\" + QString::number(index.row());\r\n        }\r\n\r\n        copiedRows.push_back(row.toStdString());\r\n    }\r\n\r\n    mapInterface_->copyRows(copiedRows);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: memorymapsmodel::onPasteRows()\r\n//-----------------------------------------------------------------------------\r\nvoid MemoryMapsModel::onPasteRows(QModelIndex const& index)\r\n{\r\n    std::string mapName = \"\";\r\n    QModelIndex parentIndex = index;\r\n    if (index.isValid())\r\n    {\r\n        if (!index.parent().isValid() && index.row() >= 0 && index.row() < mapInterface_->itemCount())\r\n        {\r\n            mapName = mapInterface_->getIndexedItemName(index.row());\r\n        }\r\n        else if (index.parent().isValid() && index.parent().row() >= 0 && index.parent().row())\r\n        {\r\n            mapName = mapInterface_->getIndexedItemName(index.parent().row());\r\n            parentIndex = index.parent();\r\n        }\r\n    }\r\n\r\n    int mapRowBegin = mapInterface_->itemCount();\r\n    int remapRowBegin = mapInterface_->remapCount(mapName);\r\n\r\n    std::vector<std::string> pastedMapNames = mapInterface_->pasteMemoryMaps();\r\n    std::vector<std::string> pastedRemapNames = mapInterface_->pasteMemoryRemaps(mapName);\r\n\r\n    int mapCount = static_cast<int>(pastedMapNames.size());\r\n    int remapCount = static_cast<int>(pastedRemapNames.size());\r\n\r\n    if (mapCount == 0 && remapCount == 0)\r\n    {\r\n        return;\r\n    }\r\n\r\n    ReferenceCalculator referenceCalculator(getParameterFinder());\r\n    if (mapCount > 0)\r\n    {\r\n        int rowEnd = mapRowBegin + mapCount - 1;\r\n\r\n        beginInsertRows(QModelIndex(), mapRowBegin, rowEnd);\r\n\r\n        for (int i = mapRowBegin; i <= rowEnd; ++i)\r\n        {\r\n            std::string copyName = mapInterface_->getIndexedItemName(i);\r\n\r\n            QStringList expressionList;\r\n            for (auto const& expression : mapInterface_->getMapExpressions(copyName, \"\"))\r\n            {\r\n                expressionList.append(QString::fromStdString(expression));\r\n            }\r\n\r\n            increaseReferencesInPastedMap(expressionList, referenceCalculator);\r\n\r\n            emit memoryMapAdded(i);\r\n            emit aubChangedOnRow(i);\r\n        }\r\n\r\n        endInsertRows();\r\n    }\r\n    if (remapCount > 0)\r\n    {\r\n        int rowEnd = remapRowBegin + remapCount - 1;\r\n\r\n        beginInsertRows(parentIndex, remapRowBegin, rowEnd);\r\n\r\n        for (int i = remapRowBegin; i <= rowEnd; ++i)\r\n        {\r\n            std::string remapName = mapInterface_->getIndexedRemapName(mapName, i);\r\n            QStringList expressionList;\r\n            for (auto const& expression : mapInterface_->getMapExpressions(mapName, remapName))\r\n            {\r\n                expressionList.append(QString::fromStdString(expression));\r\n            }\r\n            increaseReferencesInPastedMap(expressionList, referenceCalculator);\r\n\r\n            emit memoryRemapAdded(i, QString::fromStdString(mapName));\r\n        }\r\n\r\n        endInsertRows();\r\n    }\r\n\r\n    emit contentChanged();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: memorymapsmodel::increaseReferencesInPastedMemoryMap()\r\n//-----------------------------------------------------------------------------\r\nvoid MemoryMapsModel::increaseReferencesInPastedMap(QStringList mapExpressions,\r\n    ReferenceCalculator& referenceCalculator)\r\n{\r\n    QMap<QString, int> referencedParameters = referenceCalculator.getReferencedParameters(mapExpressions);\r\n\r\n    QMapIterator<QString, int> refParameterIterator (referencedParameters);\r\n    while (refParameterIterator.hasNext())\r\n    {\r\n        refParameterIterator.next();\r\n        for (int i = 0; i < refParameterIterator.value(); ++i)\r\n        {\r\n            emit increaseReferences(refParameterIterator.key());\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryMapsModel::isValidExpressionColumn()\r\n//-----------------------------------------------------------------------------\r\nbool MemoryMapsModel::isValidExpressionColumn(QModelIndex const& index) const\r\n{\r\n    return index.column() == MemoryMapsColumns::IS_PRESENT || index.column() == MemoryMapsColumns::AUB_COLUMN;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryMapsModel::expressionOrValueForIndex()\r\n//-----------------------------------------------------------------------------\r\nQVariant MemoryMapsModel::expressionOrValueForIndex(QModelIndex const& index) const\r\n{\r\n    if (isValidExpressionColumn(index))\r\n    {\r\n        return expressionForIndex(index);\r\n    }\r\n    else\r\n    {\r\n        return valueForIndex(index);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryMapsModel::validateIndex()\r\n//-----------------------------------------------------------------------------\r\nbool MemoryMapsModel::validateIndex(QModelIndex const& index) const\r\n{\r\n    int columnIndex = index.column();\r\n\r\n    QPair<QString, QString> mapRemapNames = getIndexedMapRemapNames(index);\r\n    std::string mapName = mapRemapNames.first.toStdString();\r\n    std::string remapName = mapRemapNames.second.toStdString();\r\n\r\n    if (index.parent().isValid())\r\n    {\r\n        if (columnIndex == MemoryMapsColumns::NAME_COLUMN)\r\n        {\r\n            return mapInterface_->remapHasValidName(mapName, remapName);\r\n        }\r\n        else if (columnIndex == MemoryMapsColumns::REMAPSTATE_COLUMN)\r\n        {\r\n            if (docRevision_ == Document::Revision::Std14)\r\n            {\r\n                return mapInterface_->remapHasValidRemapState(mapName, remapName);\r\n            }\r\n        }\r\n        else if (columnIndex == MemoryMapsColumns::IS_PRESENT)\r\n        {\r\n            return mapInterface_->itemHasValidIsPresent(mapName, remapName);\r\n        }\r\n    }\r\n\r\n    else if (!index.parent().isValid())\r\n    {\r\n        if (columnIndex == MemoryMapsColumns::NAME_COLUMN)           \r\n        {\r\n            return mapInterface_->itemHasValidName(mapName);\r\n        }\r\n        else if (columnIndex == MemoryMapsColumns::AUB_COLUMN)\r\n        {\r\n            return mapInterface_->memoryMapHasValidAddressUnitBits(mapName);\r\n        }\r\n        else if (columnIndex == MemoryMapsColumns::IS_PRESENT)\r\n        {\r\n            return mapInterface_->itemHasValidIsPresent(mapName);\r\n        }\r\n    }\r\n\r\n    return true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: memorymapsmodel::formattedExpressionForIndex()\r\n//-----------------------------------------------------------------------------\r\nQVariant MemoryMapsModel::formattedExpressionForIndex(QModelIndex const& index) const\r\n{\r\n    QPair<QString, QString> mapRemapNames = getIndexedMapRemapNames(index);\r\n    std::string mapName = mapRemapNames.first.toStdString();\r\n    std::string remapName = mapRemapNames.second.toStdString();\r\n\r\n    if (index.column() == MemoryMapsColumns::IS_PRESENT)\r\n    {\r\n        return QString::fromStdString(mapInterface_->getIsPresentFormattedExpression(mapName, remapName));\r\n    }\r\n    else if (index.column() == MemoryMapsColumns::AUB_COLUMN)\r\n    {\r\n        return QString::fromStdString(mapInterface_->getAddressUnitBitsFormattedExpression(mapName));\r\n    }\r\n\r\n    return valueForIndex(index);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: memorymapsmodel::expressionForIndex()\r\n//-----------------------------------------------------------------------------\r\nQVariant MemoryMapsModel::expressionForIndex(QModelIndex const& index) const\r\n{\r\n    QPair<QString, QString> mapRemapNames = getIndexedMapRemapNames(index);\r\n    std::string mapName = mapRemapNames.first.toStdString();\r\n    std::string remapName = mapRemapNames.second.toStdString();\r\n\r\n    if (index.column() == MemoryMapsColumns::IS_PRESENT)\r\n    {\r\n        return QString::fromStdString(mapInterface_->getIsPresentExpression(mapName, remapName));\r\n    }\r\n    else if (index.column() == MemoryMapsColumns::AUB_COLUMN)\r\n    {\r\n        return QString::fromStdString(mapInterface_->getAddressUnitBitsExpression(mapName));\r\n    }\r\n\r\n    return valueForIndex(index);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryMapsModel::valueForIndex()\r\n//-----------------------------------------------------------------------------\r\nQVariant MemoryMapsModel::valueForIndex(QModelIndex const& index) const\r\n{\r\n    if (!index.isValid())\r\n    {\r\n        return QVariant();\r\n    }\r\n\r\n    bool itemIsMemoryMap = !index.parent().isValid();\r\n    QPair<QString, QString> mapRemapNames = getIndexedMapRemapNames(index);\r\n    std::string mapName = mapRemapNames.first.toStdString();\r\n    std::string remapName = mapRemapNames.second.toStdString();\r\n\r\n    if (index.column() == MemoryMapsColumns::NAME_COLUMN)\r\n    {\r\n        std::string itemName = mapName;\r\n        if (!itemIsMemoryMap)\r\n        {\r\n            itemName = remapName;\r\n        }\r\n        return QString::fromStdString(itemName);\r\n    }\r\n    else if (index.column() == MemoryMapsColumns::AUB_COLUMN)\r\n    {\r\n        return QString::fromStdString(mapInterface_->getAddressUnitBitsValue(mapName));\r\n    }\r\n    else if (index.column() == MemoryMapsColumns::INTERFACE_COLUMN)\r\n    {\r\n        return QString::fromStdString(mapInterface_->getInterfaceBinding(mapName));\r\n    }\r\n    else if (index.column() == MemoryMapsColumns::REMAPSTATE_COLUMN)\r\n    {\r\n        if (docRevision_ == Document::Revision::Std22)\r\n        {\r\n            return QString::fromStdString(mapInterface_->getRemapModeReferenceString(mapName, remapName));\r\n        }\r\n\r\n        return QString::fromStdString(mapInterface_->getRemapState(mapName, remapName));\r\n    }\r\n    else if (index.column() == MemoryMapsColumns::IS_PRESENT)\r\n    {\r\n        return QString::fromStdString(mapInterface_->getIsPresentValue(mapName, remapName));\r\n    }\r\n    else if (index.column() == MemoryMapsColumns::DESCRIPTION_COLUMN)\r\n    {\r\n        if (itemIsMemoryMap)\r\n        {\r\n            return QString::fromStdString(mapInterface_->getDescription(mapName));\r\n        }\r\n        else\r\n        {\r\n            return QString::fromStdString(mapInterface_->getRemapDescription(mapName, remapName));\r\n        }\r\n    }\r\n\r\n    return QVariant();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: memorymapsmodel::mimeTypes()\r\n//-----------------------------------------------------------------------------\r\nQStringList MemoryMapsModel::mimeTypes() const\r\n{\r\n    QStringList types(QAbstractItemModel::mimeTypes());\r\n\r\n    types << \"text/xml/ipxact:memoryMap\";\r\n    types << \"text/xml/ipxact:memoryRemap\";\r\n\r\n    return types;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryMapsModel::onRemoveAllChildItemsFrom()\r\n//-----------------------------------------------------------------------------\r\nvoid MemoryMapsModel::onRemoveAllChildItemsFrom(QModelIndex const& itemIndex)\r\n{\r\n    if (isIndexValid(itemIndex) && !itemIndex.parent().isValid())\r\n    {\r\n        std::string mapName = mapInterface_->getIndexedItemName(itemIndex.row());\r\n\r\n        int remapCount = mapInterface_->remapCount(mapName);\r\n        if (remapCount > 0)\r\n        {\r\n            int lastRemapIndex = remapCount - 1;\r\n            beginRemoveRows(itemIndex, 0, lastRemapIndex);\r\n\r\n            for (int i = 0; i < remapCount; ++i)\r\n            {\r\n                std::string remapName = mapInterface_->getIndexedRemapName(mapName, 0);\r\n                decreaseReferencesWithRemovedMemoryMap(QString::fromStdString(mapName),\r\n                    QString::fromStdString(remapName));\r\n\r\n                emit memoryRemapRemoved(0, QString::fromStdString(mapName));\r\n\r\n                mapInterface_->removeRemap(mapName, remapName);\r\n            }\r\n\r\n            endRemoveRows();\r\n\r\n            emit contentChanged();\r\n        }\r\n    }\r\n}\r\n"
  },
  {
    "path": "editors/ComponentEditor/memoryMaps/memorymapsmodel.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: memorymapsmodel.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 21.08.2012\r\n//\r\n// Description:\r\n// The model to manage the memory maps summary.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef MEMORYMAPSMODEL_H\r\n#define MEMORYMAPSMODEL_H\r\n\r\n#include <IPXACTmodels/common/Document.h>\r\n\r\n#include <editors/ComponentEditor/common/ParameterizableTable.h>\r\n\r\n#include <KactusAPI/include/ParameterFinder.h>\r\n\r\n#include <QAbstractItemModel>\r\n#include <QSharedPointer>\r\n\r\n#include <QMap>\r\n\r\nclass Component;\r\nclass ExpressionFormatter;\r\nclass MemoryMapBase;\r\nclass MemoryMap;\r\nclass MemoryRemap;\r\nclass MemoryMapValidator;\r\nclass MemoryMapExpressionGatherer;\r\nclass MemoryRemapExpressionGatherer;\r\nclass ReferenceCalculator;\r\nclass MemoryMapInterface;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! The model to manage the memory maps summary.\r\n//-----------------------------------------------------------------------------\r\nclass MemoryMapsModel : public QAbstractItemModel, public ParameterizableTable\r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\r\n\t/*!\r\n\t *  The constructor.\r\n\t *\r\n     *    @param [in] parameterFinder     The instance used to find parameters.\r\n     *    @param [in] expressionParser    The used expression parser.\r\n     *    @param [in] mapInterface        Interface for memory maps.\r\n     *    @param [in] docRevision         The IP-XACT standard revision to use.\r\n     *    @param [in] ROWHEIGHT           Height for rows.\r\n\t *    @param [in] parent              The owner of the model.\r\n\t */\r\n\tMemoryMapsModel( QSharedPointer<ParameterFinder> parameterFinder, \r\n        QSharedPointer<ExpressionParser> expressionParser, MemoryMapInterface* mapInterface, \r\n        Document::Revision docRevision, const int ROWHEIGHT, QObject *parent);\r\n\r\n    //! No copying\r\n    MemoryMapsModel(const MemoryMapsModel& other) = delete;\r\n\r\n    //! No assignment\r\n    MemoryMapsModel& operator=(const MemoryMapsModel& other) = delete;\r\n\r\n\t/*!\r\n\t *  The destructor.\r\n\t */\r\n\tvirtual ~MemoryMapsModel() = default;\r\n\r\n    /*!\r\n\t *  Get the number of rows an item contains.\r\n\t *\r\n\t *    @param [in] parent  Identifies the parent of the index that's row count is requested.\r\n     *\r\n     *    @return The number of rows an item has.\r\n\t */\r\n\tvirtual int rowCount(const QModelIndex& parent = QModelIndex()) const;\r\n\r\n    /*!\r\n\t *  Get the number of columns the item has.\r\n\t *\r\n\t *    @param [in] parent  Identifies the parent of the index that's column count is requested.\r\n     *\r\n     *    @return The number of columns an item has.\r\n\t */\r\n\tvirtual int columnCount(const QModelIndex& parent = QModelIndex()) const;\r\n\r\n\t/*!\r\n\t *  Get the item flags that defines the possible operations for the item.\r\n\t *\r\n\t *    @param [in] index   The item's model index.\r\n     *\r\n     *    @return The possible operations for the item.\r\n\t */\r\n\tQt::ItemFlags flags(const QModelIndex& index) const;\r\n\r\n    /*!\r\n\t *  Get the header data for the specified header.\r\n\t *\r\n\t *    @param [in] section         The row / column number of the header.\r\n\t *    @param [in] orientation     Specifies the orientation of the header.\r\n\t *    @param [in] role            The type of the requested data.\r\n     *\r\n     *    @return The requested data.\r\n\t */\r\n\tvirtual QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;\r\n\t\r\n    /*!\r\n\t *  Get the data for the specified item.\r\n\t *\r\n\t *    @param [in] index   Specifies the item that's data is requested.\r\n\t *    @param [in] role    The role that defines what kind of data is requested.\r\n     *\r\n     *    @return The data for the item.\r\n\t */\r\n\tvirtual QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const;\r\n\r\n    /*!\r\n\t *  Save the data to the model for the specified item.\r\n\t *\r\n\t *    @param [in] index   The index of the item that's data is to be saved.\r\n\t *    @param [in] value   The data that is to be saved.\r\n\t *    @param [in] role    Specifies what kind of data should be saved.\r\n     *\r\n     *    @return True, if saving was successful, false otherwise.\r\n\t */\r\n\tbool setData(const QModelIndex& index, const QVariant& value, int role = Qt::EditRole);\r\n\r\n    /*!\r\n     *  Get the model index of the specified object.\r\n     *\r\n     *    @param [in] row     Row number of the object.\r\n     *    @param [in] column  Column number of the object.\r\n     *    @param [in] parent  Model index of the parent of the object.\r\n     *\r\n     *    @return QModelIndex that identifies the object.\r\n     */\r\n    virtual QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex() ) const;\r\n\r\n    /*!\r\n     *  Get the model index of the parent of the object.\r\n     *\r\n     *    @param [in] child   Model index that identifies the child of the object.\r\n     *\r\n     *    @return QModelindex that identifies the parent of the given object.\r\n     */\r\n    virtual QModelIndex parent(const QModelIndex &child) const;\r\n    \r\n    /*!\r\n     *  Get the list of acceptable mime types.\r\n     *\r\n     *    @return The list of acceptable mime types.\r\n     */\r\n    virtual QStringList mimeTypes() const;\r\n\r\npublic slots:\r\n\r\n    /*!\r\n\t *  Add a new item to the given index.\r\n\t *\r\n\t *    @param [in] index   The index identifying the position for the new item.\r\n\t */\r\n\tvirtual void onAddItem(const QModelIndex& index);\r\n\r\n    /*!\r\n\t *  Remove the item in the given index.\r\n\t *\r\n\t *    @param [in] index   The index identifying the item to be removed.\r\n\t */\r\n\tvirtual void onRemoveItem(const QModelIndex& index);\r\n\r\n    /*!\r\n     *  Add a new memory remap item.\r\n     *\r\n     *    @param [in] index   The parent index of the new memory remap item.\r\n     */\r\n    virtual void onAddMemoryRemap(const QModelIndex& index);\r\n\r\n    /*!\r\n     *  Copy the selected items matching the selected indexes.\r\n     *\r\n     *    @param [in] indexList   A list of the selected indexes.\r\n     */\r\n    void onCopyRows(QModelIndexList const& indexList);\r\n\r\n    /*!\r\n     *  Paste the selected items.\r\n     *\r\n     *    @param [in] index   The owner of the pasted memory remap items.\r\n     */\r\n    void onPasteRows(QModelIndex const& index);\r\n\r\n    /*!\r\n     *  Remove all memory remaps from the selected memory map.\r\n     *\r\n     *    @param [in] itemIndex   Index of the selected memory map.\r\n     */\r\n    void onRemoveAllChildItemsFrom(QModelIndex const& itemIndex);\r\n\r\nsignals:\r\n\r\n\t//! Emitted when the contents of the model change.\r\n\tvoid contentChanged();\r\n\r\n    /*!\r\n     *  Informs of a need to redraw the visualization.\r\n     */\r\n    void graphicsChanged();\r\n\r\n\t//! Emitted when a new memory map is added to the given index.\r\n\tvoid memoryMapAdded(int index);\r\n\r\n\t//! Emitted when a memory map is removed from the given index.\r\n\tvoid memoryMapRemoved(int index);\r\n\r\n    //! Emitted when address unit bits are changed.\r\n    void aubChangedOnRow(int memoryMapIndex);\r\n    \r\n    //! Emitted when a new memory remap is added to the given memory map.\r\n    void memoryRemapAdded(int index, QString const& parentMemoryMapName);\r\n\r\n    //! Emitted when a memory remap is removed from the given index.\r\n    void memoryRemapRemoved(int index, QString const& parentMemoryMapName);\r\n\r\n    /*!\r\n     *  Informs of an increase in references for a given parameter.\r\n     *\r\n     *    @param [in] id  The id of the given parameter.\r\n     */\r\n    void increaseReferences(QString const& id);\r\n\r\n    /*!\r\n     *  Informs of a decrease in references for a given parameter.\r\n     *\r\n     *    @param [in] id  The id of the given parameter.\r\n     */\r\n    void decreaseReferences(QString const& id);\r\n\r\n    /*\r\n     *  Informs of memory map name change.\r\n     *\r\n     *    @param [in] oldName     The old name.\r\n     *    @param [in] newName     The new name.\r\n     */\r\n    void memoryMapNameChanged(QString const& oldName, QString const& newName);\r\n\r\n    /*\r\n     *  Informs of memory remap name change.\r\n     *\r\n     *    @param [in] parentName  Name of the containing memory map.\r\n     *    @param [in] oldName     The old name.\r\n     *    @param [in] newName     The new name.\r\n     */\r\n    void memoryRemapNameChanged(QString const& parentName, QString const& oldName, QString const& newName);\r\n\r\nprotected:\r\n    \r\n    /*!\r\n     *  Check if the column index is valid for containing expressions.\r\n     *\r\n     *    @param [in] index   The index being evaluated.\r\n     *\r\n     *    @return     True, if column can have expressions, false otherwise.\r\n     */\r\n    virtual bool isValidExpressionColumn(QModelIndex const& index) const;\r\n\r\n    /*!\r\n     *  Gets the expression for the given index or the plain value if expression is not available.\r\n     *\r\n     *    @param [in] index   The index whose expression to get.\r\n     *\r\n     *    @return The expression for the index if available, otherwise the value for the given index.\r\n     */\r\n    virtual QVariant expressionOrValueForIndex(QModelIndex const& index) const;\r\n\r\n    /*!\r\n     *  Validates the data in an index.\r\n     *\r\n     *    @param [in] index   The index whose data to validate\r\n     *\r\n     *    @return True, if the data in the index is valid, otherwise false.\r\n     */\r\n    virtual bool validateIndex(QModelIndex const& index) const;\r\n\r\nprivate:\r\n    \r\n    /*!\r\n     *  Get the formatted value of an expression in the selected index.\r\n     *\r\n     *    @param [in] index   The selected index.\r\n     *\r\n     *    @return The formatted value of an expression in the selected index.\r\n     */\r\n    virtual QVariant formattedExpressionForIndex(QModelIndex const& index) const;\r\n\r\n    /*!\r\n     *  Get the expression of the selected index.\r\n     *\r\n     *    @param [in] index   The selected index.\r\n     *\r\n     *    @return The expression of the selected index.\r\n     */\r\n    virtual QVariant expressionForIndex(QModelIndex const& index) const;\r\n\r\n    /*!\r\n     *  Gets the value for the given index.\r\n     *\r\n     *    @param [in] index   The index of target data.\r\n     *\r\n     *    @return     The data in the given index.\r\n     */\r\n    QVariant valueForIndex(QModelIndex const& index) const;\r\n\r\n    /*!\r\n     *  Increaser the number of references when creating a new memory remap.\r\n     *\r\n     *    @param [in] memoryMapName   Name of the memory map.\r\n     */\r\n    void increaseReferencesWithNewRemap(QString const& memoryMapName);\r\n\r\n    /*!\r\n     *  Decrease the number of references when removing a memory remap.\r\n     *\r\n     *    @param [in] mapName     Name of the memory map containing the selected memory remap.\r\n     *    @param [in] remapName   Name of the removed memory remap.\r\n     */\r\n    void decreaseReferencesWithRemovedMemoryMap(QString const& mapName, QString const& remapName);\r\n\r\n    /*!\r\n     *  Create a parent index for the index of a memory remap.\r\n     *\r\n     *    @param [in] childItem   The memory remap.\r\n     *\r\n     *    @return The parent index of the memory remap child item.\r\n     */\r\n    QModelIndex createParentIndexForMemoryRemap(MemoryRemap* childItem) const;\r\n\r\n    /*!\r\n     *  Check if the index is valid in the model.\r\n     *\r\n     *    @param [in] index   The index whose validity is being checked.\r\n     *\r\n     *    @return True, if the index is valid, false otherwise.\r\n     */\r\n    bool isIndexValid(QModelIndex const& index) const;\r\n\r\n    /*!\r\n     *  Increase the number of references in the referenced parameters.\r\n     *\r\n     *    @param [in] mapExpressions          List of expressions contained within the selected map.\r\n     *    @param [in] referenceCalculator     The used reference calculator.\r\n     */\r\n    void increaseReferencesInPastedMap(QStringList mapExpressions, ReferenceCalculator& referenceCalculator);\r\n\r\n    /*!\r\n     *  Get the memory map and remap names associated with the selected index.\r\n     *\r\n     *    @param [in] index   The selected index.\r\n     *\r\n     *    @return Pair containing the memory map and memory remap names.\r\n     */\r\n    QPair<QString, QString> getIndexedMapRemapNames(QModelIndex const& index) const;\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! Interface for accessing memory maps.\r\n    MemoryMapInterface* mapInterface_;\r\n\r\n    //! The IP-XACT standard revision to use.\r\n    Document::Revision docRevision_;\r\n\r\n    //! Height for rows.\r\n    const int ROWHEIGHT_;\r\n};\r\n\r\n#endif // MEMORYMAPSMODEL_H\r\n"
  },
  {
    "path": "editors/ComponentEditor/memoryMaps/registerdelegate.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: registerdelegate.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 25.08.2012\r\n//\r\n// Description:\r\n// The delegate to provide editors to add/remove/edit the fields of register.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"registerdelegate.h\"\r\n#include \"RegisterColumns.h\"\r\n\r\n#include <common/widgets/booleanComboBox/booleancombobox.h>\r\n#include <common/widgets/accessComboBox/accesscombobox.h>\r\n#include <common/widgets/modWriteComboBox/modwritecombobox.h>\r\n#include <common/widgets/readActionComboBox/readactioncombobox.h>\r\n#include <common/widgets/testConstraintComboBox/testconstraintcombobox.h>\r\n\r\n#include <QLineEdit>\r\n#include <QKeyEvent>\r\n#include <QSpinBox>\r\n#include <QTextEdit>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: RegisterDelegate::RegisterDelegate()\r\n//-----------------------------------------------------------------------------\r\nRegisterDelegate::RegisterDelegate(QAbstractItemModel* completionModel,\r\n                                   QSharedPointer<ParameterFinder> parameterFinder, QObject *parent):\r\nExpressionDelegate(completionModel, parameterFinder, parent)\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: RegisterDelegate::~RegisterDelegate()\r\n//-----------------------------------------------------------------------------\r\nRegisterDelegate::~RegisterDelegate() \r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: RegisterDelegate::createEditor()\r\n//-----------------------------------------------------------------------------\r\nQWidget* RegisterDelegate::createEditor( QWidget* parent, const QStyleOptionViewItem& option, \r\n    const QModelIndex& index ) const \r\n{\r\n    if (index.column() == RegisterColumns::VOLATILE_COLUMN || index.column() == RegisterColumns::TESTABLE_COLUMN)\r\n    {\r\n        BooleanComboBox* boolBox = new BooleanComboBox(parent);\r\n        return boolBox;\r\n    }\r\n    else if (index.column() == RegisterColumns::ACCESS_COLUMN)\r\n    {\r\n        AccessComboBox* accessBox = new AccessComboBox(parent);\r\n        return accessBox;\r\n    }\r\n    else if (index.column() == RegisterColumns::MOD_WRITE_COLUMN)\r\n    {\r\n        ModWriteComboBox* modBox = new ModWriteComboBox(parent);\r\n        return modBox;\r\n    }\r\n    else if (index.column() == RegisterColumns::READ_ACTION_COLUMN)\r\n    {\r\n        ReadActionComboBox* readBox = new ReadActionComboBox(parent);\r\n        return readBox;\r\n    }\r\n    else if (index.column() == RegisterColumns::TEST_CONSTR_COLUMN)\r\n    {\r\n        TestConstraintComboBox* testBox = new TestConstraintComboBox(parent);\r\n        return testBox;\r\n    }\r\n    else\r\n    {\r\n        return ExpressionDelegate::createEditor(parent, option, index);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: RegisterDelegate::setEditorData()\r\n//-----------------------------------------------------------------------------\r\nvoid RegisterDelegate::setEditorData( QWidget* editor, const QModelIndex& index ) const\r\n{\r\n    if (index.column() == RegisterColumns::VOLATILE_COLUMN || index.column() == RegisterColumns::TESTABLE_COLUMN)\r\n    {\r\n        BooleanComboBox* boolBox = qobject_cast<BooleanComboBox*>(editor);\r\n        Q_ASSERT(boolBox);\r\n\r\n        QString value = index.model()->data(index, Qt::DisplayRole).toString();\r\n        boolBox->setCurrentValue(value);\r\n    }\r\n    else if (index.column() == RegisterColumns::ACCESS_COLUMN)\r\n    {\r\n        AccessComboBox* accessBox = qobject_cast<AccessComboBox*>(editor);\r\n        Q_ASSERT(accessBox);\r\n\r\n        AccessTypes::Access access = AccessTypes::str2Access(index.model()->data(\r\n            index, Qt::DisplayRole).toString(), AccessTypes::ACCESS_COUNT);\r\n        accessBox->setCurrentValue(access);\r\n    }\r\n    else if (index.column() == RegisterColumns::MOD_WRITE_COLUMN)\r\n    {\r\n        ModWriteComboBox* modBox = qobject_cast<ModWriteComboBox*>(editor);\r\n        Q_ASSERT(modBox);\r\n\r\n        General::ModifiedWrite modWrite = General::str2ModifiedWrite(\r\n            index.model()->data(index, Qt::DisplayRole).toString());\r\n        modBox->setCurrentValue(modWrite);\r\n    }\r\n    else if (index.column() == RegisterColumns::READ_ACTION_COLUMN)\r\n    {\r\n        ReadActionComboBox* readBox = qobject_cast<ReadActionComboBox*>(editor);\r\n        Q_ASSERT(readBox);\r\n\r\n        General::ReadAction readAction = General::str2ReadAction(\r\n            index.model()->data(index, Qt::DisplayRole).toString());\r\n        readBox->setCurrentValue(readAction);\r\n    }\r\n    else if (index.column() == RegisterColumns::TEST_CONSTR_COLUMN)\r\n    {\r\n        TestConstraintComboBox* testBox = qobject_cast<TestConstraintComboBox*>(editor);\r\n        Q_ASSERT(testBox);\r\n\r\n        General::TestConstraint testConstr = General::str2TestConstraint(\r\n            index.model()->data(index, Qt::DisplayRole).toString());\r\n        testBox->setCurrentValue(testConstr);\r\n    }\r\n    else\r\n    {\r\n        ExpressionDelegate::setEditorData(editor, index);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: RegisterDelegate::setModelData()\r\n//-----------------------------------------------------------------------------\r\nvoid RegisterDelegate::setModelData( QWidget* editor, QAbstractItemModel* model, const QModelIndex& index ) const \r\n{\r\n    if (index.column() == RegisterColumns::VOLATILE_COLUMN || index.column() == RegisterColumns::TESTABLE_COLUMN)\r\n    {\r\n        BooleanComboBox* boolBox = qobject_cast<BooleanComboBox*>(editor);\r\n        Q_ASSERT(boolBox);\r\n\r\n        QString value = boolBox->getCurrentValue();\r\n        model->setData(index, value, Qt::EditRole);\r\n    }\r\n    else if (index.column() == RegisterColumns::ACCESS_COLUMN)\r\n    {\r\n        AccessComboBox* accessBox = qobject_cast<AccessComboBox*>(editor);\r\n        Q_ASSERT(accessBox);\r\n\r\n        AccessTypes::Access access = accessBox->getCurrentValue();\r\n        model->setData(index, AccessTypes::access2Str(access), Qt::EditRole);\r\n    }\r\n    else if (index.column() == RegisterColumns::MOD_WRITE_COLUMN)\r\n    {\r\n        ModWriteComboBox* modBox = qobject_cast<ModWriteComboBox*>(editor);\r\n        Q_ASSERT(modBox);\r\n\r\n        General::ModifiedWrite modWrite = modBox->getCurrentValue();\r\n        model->setData(index, General::modifiedWrite2Str(modWrite), Qt::EditRole);\r\n    }\r\n    else if (index.column() == RegisterColumns::READ_ACTION_COLUMN)\r\n    {\r\n        ReadActionComboBox* readBox = qobject_cast<ReadActionComboBox*>(editor);\r\n        Q_ASSERT(readBox);\r\n\r\n        General::ReadAction readAction = readBox->getCurrentValue();\r\n        model->setData(index, General::readAction2Str(readAction), Qt::EditRole);\r\n    }\r\n    else if (index.column() == RegisterColumns::TEST_CONSTR_COLUMN)\r\n    {\r\n        TestConstraintComboBox* testBox = qobject_cast<TestConstraintComboBox*>(editor);\r\n        Q_ASSERT(testBox);\r\n\r\n        General::TestConstraint testConstr = testBox->getCurrentValue();\r\n        model->setData(index, General::testConstraint2Str(testConstr), Qt::EditRole);\r\n    }\r\n    else\r\n    {\r\n        ExpressionDelegate::setModelData(editor, model, index);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: RegisterDelegate::columnAcceptsExpression()\r\n//-----------------------------------------------------------------------------\r\nbool RegisterDelegate::columnAcceptsExpression(int column) const\r\n{\r\n    return column == RegisterColumns::WIDTH_COLUMN || column == RegisterColumns::OFFSET_COLUMN ||\r\n        column == RegisterColumns::IS_PRESENT_COLUMN;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: RegisterDelegate::descriptionColumn()\r\n//-----------------------------------------------------------------------------\r\nint RegisterDelegate::descriptionColumn() const\r\n{\r\n    return RegisterColumns::DESCRIPTION_COLUMN;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: RegisterDelegate::commitAndCloseEditor()\r\n//-----------------------------------------------------------------------------\r\nvoid RegisterDelegate::commitAndCloseEditor()\r\n{\r\n\tQWidget* edit = qobject_cast<QWidget*>(sender());\r\n\tQ_ASSERT(edit);\r\n\r\n\temit commitData(edit);\r\n\temit closeEditor(edit);\r\n}\r\n"
  },
  {
    "path": "editors/ComponentEditor/memoryMaps/registerdelegate.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: registerdelegate.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 25.08.2012\r\n//\r\n// Description:\r\n// The delegate to provide editors to add/remove/edit the fields of register.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef REGISTERDELEGATE_H\r\n#define REGISTERDELEGATE_H\r\n\r\n#include <QStyledItemDelegate>\r\n#include <QEvent>\r\n\r\n#include <KactusAPI/include/ParameterFinder.h>\r\n#include <editors/ComponentEditor/common/ExpressionDelegate.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n//! The delegate to provide editors to add/remove/edit the details of register.\r\n//-----------------------------------------------------------------------------\r\nclass RegisterDelegate : public ExpressionDelegate\r\n{\r\n    Q_OBJECT\r\n\r\npublic:\r\n\r\n\t/*!\r\n\t *  The constructor.\r\n\t *\r\n\t *    @param [in] completionModel\t\t\tModel containing the completions used in expression editor.\r\n\t *    @param [in] parameterFinder         The parameter finder to use for expression editor.\r\n\t *    @param [in] parent                  Pointer to the owner of the delegate.\r\n\t */\r\n\tRegisterDelegate(QAbstractItemModel* completionModel, QSharedPointer<ParameterFinder> parameterFinder,\r\n        QObject *parent);\r\n\t\r\n\t//! The destructor.\r\n\tvirtual ~RegisterDelegate();\r\n\r\n\t/*!\r\n     *  Create a new editor for the given item.\r\n\t *\r\n\t *    @param [in] parent  Owner for the editor.\r\n\t *    @param [in] option  Contains options for the editor.\r\n\t *    @param [in] index   Model index identifying the item.\r\n\t *\r\n\t *    @return Pointer to the editor to be used to edit the item.\r\n\t */\r\n\tvirtual QWidget* createEditor(QWidget* parent, \tconst QStyleOptionViewItem& option, QModelIndex const& index)\r\n        const;\r\n\r\n\t/*!\r\n     *  Set the data for the editor.\r\n\t *\r\n\t *    @param [in] editor  Pointer to the editor where the data is to be set.\r\n\t *    @param [in] index   Model index identifying the item that's data is to be set.\r\n\t */\r\n\tvirtual void setEditorData(QWidget* editor, const QModelIndex& index) const;\r\n\r\n\t/*!\r\n     *  Save the data from the editor to the model.\r\n\t *\r\n\t *    @param [in] editor  Pointer to the editor that contains the data to store.\r\n\t *    @param [in] model   Model that contains the data structure where data is to be saved to.\r\n\t *    @param [in] index   Model index identifying the item that's data is to be saved.\r\n\t */\r\n\tvirtual void setModelData(QWidget* editor, QAbstractItemModel* model, const QModelIndex& index) const;\r\n\r\nprotected:\r\n\r\n    /*!\r\n     *  Checks if the given column supports expressions in the editor.\r\n     *\r\n     *    @param [in] column  The column to check.\r\n     *\r\n     *    @return True if the cells in the column allow expressions, otherwise false.\r\n     */\r\n    virtual bool columnAcceptsExpression(int column) const;\r\n\r\n    //! Gets the description column.\r\n    virtual int descriptionColumn() const;\r\n\r\nprivate slots:\r\n\r\n\t/*!\r\n     *  Commit the data from the sending editor and close the editor.\r\n\t */\r\n\tvoid commitAndCloseEditor();\r\n\r\nprivate:\r\n\t\r\n\t//! No copying.\r\n\tRegisterDelegate(const RegisterDelegate& other);\r\n\r\n\t//! No assignment.\r\n\tRegisterDelegate& operator=(const RegisterDelegate& other);\r\n};\r\n\r\n#endif // REGISTERDELEGATE_H\r\n"
  },
  {
    "path": "editors/ComponentEditor/memoryMaps/registereditor.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: registereditor.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 24.08.2012\r\n//\r\n// Description:\r\n// Editor for editing the details of fields in a register.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"registereditor.h\"\r\n\r\n#include \"ExpressionProxyModel.h\"\r\n#include \"registertablemodel.h\"\r\n#include \"registerdelegate.h\"\r\n#include \"RegisterColumns.h\"\r\n\r\n#include <common/views/EditableTableView/editabletableview.h>\r\n\r\n#include <KactusAPI/include/LibraryInterface.h>\r\n\r\n#include <KactusAPI/include/IPXactSystemVerilogParser.h>\r\n#include <editors/ComponentEditor/parameters/ComponentParameterModel.h>\r\n#include <KactusAPI/include/FieldInterface.h>\r\n\r\n#include <QCompleter>\r\n#include <QVBoxLayout>\r\n#include <QHeaderView>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: registereditor::RegisterEditor()\r\n//-----------------------------------------------------------------------------\r\nRegisterEditor::RegisterEditor(QSharedPointer<QList<QSharedPointer<Field>>> fields,\r\n    QSharedPointer<Component> component, LibraryInterface* handler,\r\n    QSharedPointer<ParameterFinder> parameterFinder, FieldInterface* fieldInterface, QWidget* parent):\r\nQGroupBox(tr(\"Fields summary\"), parent),\r\nview_(new EditableTableView(this)),\r\nmodel_(0),\r\ninterface_(fieldInterface),\r\nfields_(fields)\r\n{\r\n    interface_->setFields(fields_);\r\n\r\n    QSharedPointer<IPXactSystemVerilogParser> expressionParser(new IPXactSystemVerilogParser(parameterFinder));\r\n    view_->verticalHeader()->show();\r\n    view_->verticalHeader()->setMaximumWidth(300);\r\n    view_->verticalHeader()->setMinimumWidth(view_->horizontalHeader()->fontMetrics().horizontalAdvance(tr(\"Name\"))*2);\r\n    view_->verticalHeader()->setSectionResizeMode(QHeaderView::Fixed);\r\n\r\n    model_ = new RegisterTableModel(fieldInterface, expressionParser, parameterFinder, component->getRevision(), this);\r\n\r\n    ComponentParameterModel* componentParametersModel = new ComponentParameterModel(parameterFinder, this);\r\n    componentParametersModel->setExpressionParser(expressionParser);\r\n\r\n\tQVBoxLayout* layout = new QVBoxLayout(this);\r\n\tlayout->addWidget(view_);\r\n\r\n    ExpressionProxyModel* proxy = new ExpressionProxyModel(expressionParser, this);\r\n    proxy->setColumnToAcceptExpressions(RegisterColumns::OFFSET_COLUMN);\r\n    proxy->setColumnToAcceptExpressions(RegisterColumns::WIDTH_COLUMN);\r\n    proxy->setColumnToAcceptExpressions(RegisterColumns::IS_PRESENT_COLUMN);\r\n\r\n\tproxy->setSourceModel(model_);\r\n\tview_->setModel(proxy);\r\n\r\n\t//! \\brief Enable import/export csv file\r\n    const QString compPath = handler->getDirectoryPath(component->getVlnv());\r\n\tQString defPath = QString(\"%1/fieldListing.csv\").arg(compPath);\r\n    view_->setDefaultImportExportPath(defPath);\r\n\t\r\n    view_->setAllowImportExport(true);\r\n\tview_->setItemsDraggable(false);\r\n\tview_->setSortingEnabled(true);\r\n    view_->setAllowElementCopying(true);\r\n\r\n    view_->setItemDelegate(new RegisterDelegate(componentParametersModel, parameterFinder, this));\r\n\r\n    view_->sortByColumn(RegisterColumns::OFFSET_COLUMN, Qt::AscendingOrder);\r\n\r\n    if (component->getRevision() == Document::Revision::Std22)\r\n    {\r\n        view_->hideColumn(RegisterColumns::MOD_WRITE_COLUMN);\r\n        view_->hideColumn(RegisterColumns::READ_ACTION_COLUMN);\r\n        view_->hideColumn(RegisterColumns::TESTABLE_COLUMN);\r\n        view_->hideColumn(RegisterColumns::TEST_CONSTR_COLUMN);\r\n        view_->hideColumn(RegisterColumns::IS_PRESENT_COLUMN);\r\n    }\r\n\r\n    connect(model_, SIGNAL(graphicsChanged(int)), this, SIGNAL(graphicsChanged(int)), Qt::UniqueConnection);\r\n    connect(model_, SIGNAL(addressingChanged(int)), this, SIGNAL(addressingChanged(int)), Qt::UniqueConnection);\r\n\tconnect(model_, SIGNAL(contentChanged()), this, SIGNAL(contentChanged()), Qt::UniqueConnection);\r\n\tconnect(model_, SIGNAL(fieldAdded(int)), this, SIGNAL(childAdded(int)), Qt::UniqueConnection);\r\n\tconnect(model_, SIGNAL(fieldRemoved(int)), this, SIGNAL(childRemoved(int)), Qt::UniqueConnection);\r\n\r\n    connect(model_, SIGNAL(fieldNameChanged(QString const&, QString const&)),\r\n        this, SIGNAL(fieldNameChanged(QString const&, QString const&)), Qt::UniqueConnection);\r\n\r\n    connect(model_, SIGNAL(dataChanged(const QModelIndex&, const QModelIndex&)),\r\n        this, SIGNAL(contentChanged()), Qt::UniqueConnection);\r\n\r\n    connect(view_->itemDelegate(), SIGNAL(increaseReferences(QString)),\r\n        this, SIGNAL(increaseReferences(QString)), Qt::UniqueConnection);\r\n    connect(view_->itemDelegate(), SIGNAL(decreaseReferences(QString)),\r\n        this, SIGNAL(decreaseReferences(QString)), Qt::UniqueConnection);\r\n\r\n\tconnect(view_, SIGNAL(addItem(const QModelIndex&)),\r\n        model_, SLOT(onAddItem(const QModelIndex&)), Qt::UniqueConnection);\r\n\tconnect(view_, SIGNAL(removeItem(const QModelIndex&)),\r\n\t\tmodel_, SLOT(onRemoveItem(const QModelIndex&)), Qt::UniqueConnection);\r\n\r\n    connect(model_, SIGNAL(decreaseReferences(QString)),\r\n        this, SIGNAL(decreaseReferences(QString)), Qt::UniqueConnection);\r\n    connect(model_, SIGNAL(increaseReferences(QString)),\r\n        this, SIGNAL(increaseReferences(QString)), Qt::UniqueConnection);\r\n\r\n    connect(view_, SIGNAL(copyRows(QModelIndexList)),\r\n        model_, SLOT(onCopyRows(QModelIndexList)), Qt::UniqueConnection);\r\n    connect(view_, SIGNAL(pasteRows()), model_, SLOT(onPasteRows()), Qt::UniqueConnection);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: registereditor::refresh()\r\n//-----------------------------------------------------------------------------\r\nvoid RegisterEditor::refresh()\r\n{\r\n\tview_->update();\r\n\r\n    interface_->setFields(fields_);\r\n}\r\n"
  },
  {
    "path": "editors/ComponentEditor/memoryMaps/registereditor.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: registereditor.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 24.08.2012\r\n//\r\n// Description:\r\n// Editor for editing the details of fields in a register.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef REGISTEREDITOR_H\r\n#define REGISTEREDITOR_H\r\n\r\n#include <IPXACTmodels/Component/Component.h>\r\n\r\n#include <QSharedPointer>\r\n#include <QGroupBox>\r\n\r\nclass RegisterTableModel;\r\nclass LibraryInterface;\r\nclass ParameterFinder;\r\nclass EditableTableView;\r\nclass ExpressionFormatter;\r\nclass FieldValidator;\r\nclass FieldInterface;\r\nclass Field;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Editor for editing the details of fields in a register.\r\n//-----------------------------------------------------------------------------\r\nclass RegisterEditor : public QGroupBox\r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\r\n\t/*!\r\n\t *  The constructor.\r\n\t *\r\n     *    @param [in] fields              Pointer to the available fields.\r\n\t *    @param [in] component           Pointer to the component being edited.\r\n\t *    @param [in] handler             Pointer to the instance that manages the library.\r\n\t *    @param [in] parameterFinder     Pointer to the parameter finder.\r\n     *    @param [in] fieldInterface      Interface for fields.\r\n\t *    @param [in] parent              Pointer to the parent of this editor.\r\n\t */\r\n    RegisterEditor(QSharedPointer<QList<QSharedPointer<Field> > > fields,\r\n        QSharedPointer<Component> component,\r\n        LibraryInterface* handler,\r\n        QSharedPointer<ParameterFinder> parameterFinder,\r\n        FieldInterface* fieldInterface,\r\n        QWidget* parent = 0);\r\n\r\n\t/*!\r\n     *  The destructor.\r\n     */\r\n\tvirtual ~RegisterEditor() = default;\r\n\r\n\t/*!\r\n     *  Reload the information from the model to the editor.\r\n\t */\r\n\tvirtual void refresh();\r\n\r\nsignals:\r\n    \r\n    /*\r\n     *  Informs of field name change.\r\n     *\r\n     *    @param [in] oldName     The old name.\r\n     *    @param [in] newName     The new name.\r\n     */\r\n    void fieldNameChanged(QString const& oldName, QString const& newName);\r\n\r\n    /*!\r\n     *  Informs of changes to the component editor tree.\r\n     */\r\n    void contentChanged();\r\n\r\n    /*!\r\n     *  Informs of a need to redraw the visualization.\r\n     */\r\n    void graphicsChanged(int index);\r\n\r\n    void addressingChanged(int);\r\n\r\n    /*!\r\n     *  Sends an error message forward.\r\n     *\r\n     *    @param [in] message     The error message.\r\n     */\r\n    void errorMessage(QString const& message) const;\r\n\r\n    /*!\r\n     *  Sends a notification forward.\r\n     *\r\n     *    @param [in] message     The notification.\r\n     */\r\n    void noticeMessage(QString const& message) const;\r\n\r\n    /*!\r\n     *  Increase the amount of references made to the given parameter.\r\n     *\r\n     *    @param [in] id  The id of the given parameter.\r\n     */\r\n    void increaseReferences(QString const& id) const;\r\n\r\n    /*!\r\n     *  Decrease the amount of references made to the given parameter.\r\n     *\r\n     *    @param [in] id  The id of the given parameter.\r\n     */\r\n    void decreaseReferences(QString const& id) const;\r\n\r\n    /*!\r\n     *  Informs that a new item has been created.\r\n     *\r\n     *    @param [in] index   The index of the new item.\r\n     */\r\n    void childAdded(int index);\r\n\r\n    /*!\r\n     *  Informs that an item has been removed.\r\n     *\r\n     *    @param [in] index   The index of the removed item.\r\n     */\r\n    void childRemoved(int index);\r\n\r\nprivate:\r\n\r\n\t//! No copying.\r\n\tRegisterEditor(const RegisterEditor& other);\r\n\r\n\t//! No assignment.\r\n\tRegisterEditor& operator=(const RegisterEditor& other);\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n\t//! Pointer to the view that displays the items.\r\n    EditableTableView* view_;\r\n\r\n\t//! Pointer to the model that manages the details of items.\r\n\tRegisterTableModel* model_;\r\n\r\n    //! Interface for accessing fields.\r\n    FieldInterface* interface_;\r\n\r\n    //! Pointer to the available fields.\r\n    QSharedPointer<QList<QSharedPointer<Field> > > fields_;\r\n};\r\n\r\n#endif // REGISTEREDITOR_H\r\n"
  },
  {
    "path": "editors/ComponentEditor/memoryMaps/registerfiledelegate.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: registerfiledelegate.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Dan Chianucci\n// Date: 19.06.2018\n//\n// Description:\n// The delegate that provides editors to add/remove/edit the details of register file\n//-----------------------------------------------------------------------------\n\n#include \"registerfiledelegate.h\"\n\n#include \"RegisterFileColumns.h\"\n\n#include <common/widgets/booleanComboBox/booleancombobox.h>\n#include <common/widgets/accessComboBox/accesscombobox.h>\n\n//-----------------------------------------------------------------------------\n// Function: RegisterFileDelegate::RegisterFileDelegate()\n//-----------------------------------------------------------------------------\nRegisterFileDelegate::RegisterFileDelegate(QAbstractItemModel* completionModel,\n    QSharedPointer<ParameterFinder> parameterFinder,\n    QObject *parent) :\n    ExpressionDelegate(completionModel, parameterFinder, parent)\n{\n\n}\n\n\n//-----------------------------------------------------------------------------\n// Function: RegisterFileDelegate::descriptionColumn()\n//-----------------------------------------------------------------------------\nint RegisterFileDelegate::descriptionColumn() const\n{\n    return RegisterFileColumns::DESCRIPTION;\n}\n\n//-----------------------------------------------------------------------------\n// Function: RegisterFileDelegate::columnAcceptsExpression()\n//-----------------------------------------------------------------------------\nbool RegisterFileDelegate::columnAcceptsExpression(int column) const\n{\n    return column == RegisterFileColumns::DIMENSION ||\n        column == RegisterFileColumns::RANGE ||\n        column == RegisterFileColumns::ADDRESS_OFFSET ||\n        column == RegisterFileColumns::IS_PRESENT;\n}\n"
  },
  {
    "path": "editors/ComponentEditor/memoryMaps/registerfiledelegate.h",
    "content": "//-----------------------------------------------------------------------------\n// File: registerfiledelegate.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Dan Chianucci\n// Date: 19.06.2018\n//\n// Description:\n// The delegate that provides editors to add/remove/edit the details of register file\n//-----------------------------------------------------------------------------\n#ifndef REGISTERFILEDELEGATE_H\n#define REGISTERFILEDELEGATE_H\n\n#include <editors/ComponentEditor/common/ExpressionDelegate.h>\n\n//-----------------------------------------------------------------------------\n//! The delegate that provides editors to add/remove/edit the details of register file\n//-----------------------------------------------------------------------------\nclass RegisterFileDelegate: public ExpressionDelegate\n{\n  Q_OBJECT\n\npublic:\n\n  /*!\n   *  The constructor\n   *\n   *    @param [in] completionModel     Model containing the completions used in expression editor.\n   *    @param [in] parameterFinder     The parameter finder to use for for expression editor.\n   *    @param [in] parent              Pointer to the owner of this delegate.\n   */\n  RegisterFileDelegate(QAbstractItemModel* completionModel, QSharedPointer<ParameterFinder> parameterFinder,\n        QObject *parent);\n\n  //! The destructor.\n  virtual ~RegisterFileDelegate() = default;\n\n  //! No copying\n  RegisterFileDelegate(const RegisterFileDelegate& other) = delete;\n  RegisterFileDelegate& operator=(const RegisterFileDelegate& other) = delete;\n\n\nprotected:\n\n    /*!\n     *  Checks if the given column supports expressions in the editor.\n     *\n     *    @param [in] column   The column to check.\n     *\n     *    @return True, if the cells in the column allow expressions, otherwise false.\n     */\n    virtual bool columnAcceptsExpression(int column) const;\n\n    //! Gets the description column.\n    virtual int descriptionColumn() const;\n\n};\n\n#endif // REGISTERFILEDELEGATE_H\n"
  },
  {
    "path": "editors/ComponentEditor/memoryMaps/registerfileeditor.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: registerfileeditor.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Dan Chianucci\n// Date: 19.06.2018\n//\n// Description:\n// Editor for register files.\n//-----------------------------------------------------------------------------\n\n#include \"registerfileeditor.h\"\n\n#include \"registerfiledelegate.h\"\n#include \"registerfilemodel.h\"\n#include \"ExpressionProxyModel.h\"\n#include \"RegisterFileColumns.h\"\n\n#include <common/views/EditableTableView/editabletableview.h>\n\n#include <KactusAPI/include/IPXactSystemVerilogParser.h>\n#include <editors/ComponentEditor/parameters/ComponentParameterModel.h>\n\n#include <KactusAPI/include/LibraryInterface.h>\n\n#include <IPXACTmodels/Component/Component.h>\n#include <IPXACTmodels/Component/RegisterBase.h>\n\n#include <QCompleter>\n#include <QVBoxLayout>\n#include <QHeaderView>\n\n//-----------------------------------------------------------------------------\n// Function: RegisterFileEditor::RegisterFileEditor()\n//-----------------------------------------------------------------------------\nRegisterFileEditor::RegisterFileEditor(QSharedPointer<QList<QSharedPointer<RegisterBase> > >  registerFile,\n    QSharedPointer<Component> component, LibraryInterface *handler,\n    QSharedPointer<ParameterFinder> parameterFinder,\n    QSharedPointer<ExpressionFormatter> expressionFormatter,\n    QSharedPointer<RegisterFileValidator> registerFileValidator,\n    QWidget *parent) :\n    QGroupBox(tr(\"Register files summary\"), parent),\n    view_(new EditableTableView(this)),\n    model_(0)\n{\n    view_->verticalHeader()->show();\n    view_->verticalHeader()->setMaximumWidth(300);\n    view_->verticalHeader()->setMinimumWidth(\n        view_->horizontalHeader()->fontMetrics().horizontalAdvance(tr(\"Name\")) * 2);\n    view_->verticalHeader()->setSectionResizeMode(QHeaderView::Fixed);\n\n    QSharedPointer<IPXactSystemVerilogParser> expressionParser(\n        new IPXactSystemVerilogParser(parameterFinder));\n\n    model_ = new RegisterFileModel(registerFile, expressionParser, parameterFinder,\n            expressionFormatter, registerFileValidator, this);\n\n    ComponentParameterModel *componentParametersModel =\n        new ComponentParameterModel(parameterFinder, this);\n    componentParametersModel->setExpressionParser(expressionParser);\n\n\n    ExpressionProxyModel *proxy =\n        new ExpressionProxyModel(expressionParser, this);\n    proxy->setColumnToAcceptExpressions(RegisterFileColumns::ADDRESS_OFFSET);\n    proxy->setColumnToAcceptExpressions(RegisterFileColumns::RANGE);\n    proxy->setColumnToAcceptExpressions(RegisterFileColumns::DIMENSION);\n    proxy->setColumnToAcceptExpressions(RegisterFileColumns::IS_PRESENT);\n\n    proxy->setSourceModel(model_);\n    view_->setModel(proxy);\n\n    if (component->getRevision() == Document::Revision::Std22)\n    {\n        view_->hideColumn(RegisterFileColumns::IS_PRESENT);\n    }\n\n    //! Enable import/export csv file\n    const QString compPath = handler->getDirectoryPath(component->getVlnv());\n    QString defPath = QString(\"%1/registerList.csv\").arg(compPath);\n    view_->setDefaultImportExportPath(defPath);\n    view_->setAllowImportExport(true);\n    view_->setAllowElementCopying(true);\n    view_->setItemsDraggable(false);\n    view_->setSortingEnabled(true);\n\n    view_->setItemDelegate(\n        new RegisterFileDelegate(componentParametersModel, parameterFinder, this));\n\n    connect(view_->itemDelegate(), SIGNAL(increaseReferences(QString)), this,\n        SIGNAL(increaseReferences(QString)), Qt::UniqueConnection);\n    connect(view_->itemDelegate(), SIGNAL(increaseReferences(QString)), this,\n        SIGNAL(increaseReferences(QString)), Qt::UniqueConnection);\n\n    view_->sortByColumn(RegisterFileColumns::ADDRESS_OFFSET, Qt::AscendingOrder);\n\n    QVBoxLayout *layout = new QVBoxLayout(this);\n    layout->addWidget(view_);\n\n    connect(model_, SIGNAL(contentChanged()), this, SIGNAL(contentChanged()),\n        Qt::UniqueConnection);\n    connect(model_, SIGNAL(graphicsChanged(int)), this, SIGNAL(graphicsChanged(int)),\n        Qt::UniqueConnection);\n    connect(model_, SIGNAL(childAddressingChanged(int)), this, SIGNAL(childAddressingChanged(int)),\n        Qt::UniqueConnection);\n    connect(model_, SIGNAL(errorMessage(const QString &)), this,\n        SIGNAL(errorMessage(const QString &)), Qt::UniqueConnection);\n    connect(model_, SIGNAL(itemAdded(int)), this, SIGNAL(childAdded(int)),\n        Qt::UniqueConnection);\n    connect(model_, SIGNAL(itemRemoved(int)), this, SIGNAL(childRemoved(int)),\n        Qt::UniqueConnection);\n\n    connect(view_, SIGNAL(addItem(const QModelIndex &)), model_,\n        SLOT(onAddItem(const QModelIndex &)), Qt::UniqueConnection);\n\n    connect(view_, SIGNAL(removeItem(const QModelIndex &)), model_,\n        SLOT(onRemoveItem(const QModelIndex &)), Qt::UniqueConnection);\n\n    connect(view_->itemDelegate(), SIGNAL(increaseReferences(QString)), this,\n        SIGNAL(increaseReferences(QString)), Qt::UniqueConnection);\n    connect(view_->itemDelegate(), SIGNAL(decreaseReferences(QString)), this,\n        SIGNAL(decreaseReferences(QString)), Qt::UniqueConnection);\n\n    connect(model_, SIGNAL(decreaseReferences(QString)), this,\n        SIGNAL(decreaseReferences(QString)), Qt::UniqueConnection);\n\n    connect(model_, SIGNAL(increaseReferences(QString)), this,\n        SIGNAL(increaseReferences(QString)), Qt::UniqueConnection);\n\n    connect(view_, SIGNAL(copyRows(QModelIndexList)), model_,\n        SLOT(onCopyRows(QModelIndexList)), Qt::UniqueConnection);\n    connect(view_, SIGNAL(pasteRows()), model_, SLOT(onPasteRows()),\n        Qt::UniqueConnection);\n\n    connect(this, SIGNAL(addressUnitBitsChanged(int)),\n        model_, SLOT(addressUnitBitsChanged(int)), Qt::UniqueConnection);\n}\n\n//-----------------------------------------------------------------------------\n// Function: RegisterFileEditor::refresh()\n//-----------------------------------------------------------------------------\nvoid RegisterFileEditor::refresh()\n{\n    view_->update();\n}\n"
  },
  {
    "path": "editors/ComponentEditor/memoryMaps/registerfileeditor.h",
    "content": "//-----------------------------------------------------------------------------\n// File: registerfileeditor.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Dan Chianucci\n// Date: 19.06.2018\n//\n// Description:\n// Editor for register files.\n//-----------------------------------------------------------------------------\n\n#ifndef REGISTERFILEEDITOR_H\n#define REGISTERFILEEDITOR_H\n\n#include <QSharedPointer>\n#include <QGroupBox>\n\nclass RegisterBase;\nclass Component;\nclass LibraryInterface;\nclass ParameterFinder;\nclass ExpressionFormatter;\nclass RegisterFileValidator;\nclass EditableTableView;\nclass RegisterFileModel;\n\n//-----------------------------------------------------------------------------\n//! Editor for register files.\n//-----------------------------------------------------------------------------\nclass RegisterFileEditor : public QGroupBox\n{\n    Q_OBJECT\n\npublic:\n\n    /*!\n     * The constructor.\n     *\n     *    @param [in] registerFile             The register file to edit.\n     *    @param [in] component                The component containing the register file.\n     *    @param [in] handler                  The available IP-XACT library.\n     *    @param [in] parameterFinder          Finder for parameters.\n     *    @param [in] expressionFormatter      Formatter for expressions.\n     *    @param [in] registerFileValidator    Validator for register files.\n     *    @param [in] parent                   The parent widget.\n     */\n     RegisterFileEditor(QSharedPointer<QList<QSharedPointer<RegisterBase> > >  registerFile,\n        QSharedPointer<Component> component,\n        LibraryInterface* handler,\n        QSharedPointer<ParameterFinder> parameterFinder,\n        QSharedPointer<ExpressionFormatter> expressionFormatter,\n        QSharedPointer<RegisterFileValidator> registerFileValidator,\n        QWidget* parent = 0);\n\n    //! The destructor.\n    virtual ~RegisterFileEditor() = default;\n\n    //! No copying.\n    RegisterFileEditor(const RegisterFileEditor& other) = delete;\n\n    //! No assignment.\n    RegisterFileEditor& operator=(const RegisterFileEditor& other) = delete;\n\n    //! Refresh the editor content.\n    void refresh();\n\nsignals:\n    /*!\n     *  Informs that the contents of the editor have changed.\n     */\n    void contentChanged();\n\n    /*!\n     *  Informs of a need to redraw the visualizer.\n     */\n    void graphicsChanged(int index);\n\n    /*!\n     *  Sends an error message forward.\n     *\n     *    @param [in] msg     The error message.\n     */\n    void errorMessage(const QString& msg) const;\n\n    /*!\n     *  Sends a notification message forward.\n     *\n     *    @param [in] msg     The notification message.\n     */\n    void noticeMessage(const QString& msg) const;\n\n    /*!\n     *  Increase the amount of references made to the given parameter.\n     *\n     *    @param [in] id  The id of the given parameter.\n     */\n    void increaseReferences(QString id) const;\n\n    /*!\n     *  Decrease the amount of references made to the given parameter.\n     *\n     *    @param [in] id  The id the given parameter.\n     */\n    void decreaseReferences(QString id) const;\n\n    /*!\n     *  Informs that a new item has been created.\n     *\n     *    @param [in] index   The index of the new item.\n     */\n    void childAdded(int index);\n\n    /*!\n     *  Informs that an item has been removed.\n     *\n     *    @param [in] index   The index of the removed item.\n     */\n    void childRemoved(int index);\n\n    void addressUnitBitsChanged(int);\n\n    void childAddressingChanged(int index);\n\nprivate:\n\n    //! The view to display the items.\n    EditableTableView* view_;\n\n    //! Pointer to the model that manages the details of address block.\n    RegisterFileModel* model_;\n};\n\n#endif // REGISTERFILEEDITOR_H\n"
  },
  {
    "path": "editors/ComponentEditor/memoryMaps/registerfilemodel.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: registerfilemodel.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Dan Chianucci\n// Date: 19.06.2018\n//\n// Description:\n// The model to manage the register files of a single address block or another register file.\n//-----------------------------------------------------------------------------\n\n#include \"registerfilemodel.h\"\n\n#include \"RegisterFileColumns.h\"\n#include <KactusAPI/include/RegisterFileExpressionsGatherer.h>\n#include <KactusAPI/include//RegisterExpressionsGatherer.h>\n#include <editors/ComponentEditor/memoryMaps/memoryMapsExpressionCalculators/ReferenceCalculator.h>\n\n#include <IPXACTmodels/Component/Register.h>\n#include <IPXACTmodels/Component/RegisterFile.h>\n#include <IPXACTmodels/Component/validators/RegisterValidator.h>\n#include <IPXACTmodels/Component/validators/RegisterFileValidator.h>\n#include <IPXACTmodels/generaldeclarations.h>\n#include <IPXACTmodels/common/AccessTypes.h>\n#include <IPXACTmodels/common/Choice.h>\n\n#include <common/KactusColors.h>\n\n#include <QRegularExpression>\n#include <QApplication>\n#include <QClipboard>\n#include <QMimeData>\n#include <QIcon>\n\n//-----------------------------------------------------------------------------\n// Function: RegisterFileModel::RegisterFileModel()\n//-----------------------------------------------------------------------------\nRegisterFileModel::RegisterFileModel(QSharedPointer<QList<QSharedPointer<RegisterBase> > > registerData,\n    QSharedPointer<ExpressionParser> expressionParser, \n    QSharedPointer<ParameterFinder> parameterFinder,\n    QSharedPointer<ExpressionFormatter> expressionFormatter,\n    QSharedPointer<RegisterFileValidator> registerFileValidator,\n    QObject *parent):\nReferencingTableModel(parameterFinder, parent),\nParameterizableTable(parameterFinder),\nregisterData_(registerData),\nitems_(),\naddressUnitBits_(0),\nparameterFinder_(parameterFinder),\nexpressionFormatter_(expressionFormatter),\nregisterFileValidator_(registerFileValidator)\n{\n    for (auto item : *registerData_)\n    {\n        QSharedPointer<RegisterFile> registerFile = item.dynamicCast<RegisterFile>();\n        if (registerFile)\n        {\n            items_.append(registerFile);\n        }\n    }\n\n    setExpressionParser(expressionParser);\n}\n\n//-----------------------------------------------------------------------------\n// Function: RegisterFileModel::rowCount()\n//-----------------------------------------------------------------------------\nint RegisterFileModel::rowCount(QModelIndex const& parent) const\n{\n\tif (parent.isValid())\n    {\n\t\treturn 0;\n\t}    \n\n    return items_.size();    \n}\n\n//-----------------------------------------------------------------------------\n// Function: RegisterFileModel::columnCount()\n//-----------------------------------------------------------------------------\nint RegisterFileModel::columnCount(QModelIndex const& parent) const\n{\n\tif (parent.isValid())\n    {\n\t\treturn 0;\n\t}\n\treturn RegisterFileColumns::COLUMN_COUNT;\n}\n\n//-----------------------------------------------------------------------------\n// Function: RegisterFileModel::flags()\n//-----------------------------------------------------------------------------\nQt::ItemFlags RegisterFileModel::flags(QModelIndex const& index) const\n{\n    if (!index.isValid())\n    {\n        return Qt::NoItemFlags;\n    }\n\n    return Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsEditable;\n}\n\n//-----------------------------------------------------------------------------\n// Function: RegisterFileModel::headerData()\n//-----------------------------------------------------------------------------\nQVariant RegisterFileModel::headerData( int section, Qt::Orientation orientation, int role) const\n{\n    if (orientation == Qt::Vertical && role == Qt::DisplayRole)\n    {\n        return items_.at(section)->name();\n    }\n\n    else if (orientation == Qt::Horizontal && role == Qt::DisplayRole)\n    {\n        if (section == RegisterFileColumns::NAME)\n        {\n            return tr(\"Register file\\nname\");\n        }\n        else if (section == RegisterFileColumns::ADDRESS_OFFSET)\n        {\n            return tr(\"Offset\\n[AUB]\") + getExpressionSymbol();\n        }\n        else if (section == RegisterFileColumns::RANGE)\n        {\n            return tr(\"Range\\n[AUB]\") + getExpressionSymbol();\n        }\n        else if (section == RegisterFileColumns::DIMENSION)\n        {\n            return tr(\"Dimension\") + getExpressionSymbol();\n        }\n        else if (section == RegisterFileColumns::DESCRIPTION)\n        {\n            return tr(\"Description\");\n        }\n        else if (section == RegisterFileColumns::IS_PRESENT)\n        {\n            return tr(\"Is present\") + getExpressionSymbol();\n        }\n    }\n\n    return QVariant();\n}\n\n//-----------------------------------------------------------------------------\n// Function: RegisterFileModel::data()\n//-----------------------------------------------------------------------------\nQVariant RegisterFileModel::data(QModelIndex const& index, int role) const\n{\n    if (!index.isValid() || index.row() < 0 || index.row() >= items_.size())\n    {\n        return QVariant();\n    }\n\n    if (role == Qt::DisplayRole)\n    {\n        if (isValidExpressionColumn(index))\n        {\n            return expressionFormatter_->formatReferringExpression(valueForIndex(index).toString());\n        }\n        else if (index.column() == RegisterFileColumns::DESCRIPTION)\n        {\n            return valueForIndex(index).toString().replace(QRegularExpression(\"\\n.*$\",\n                QRegularExpression::DotMatchesEverythingOption), \"...\");\n        }\n        else\n        {\n            return valueForIndex(index);\n        }\n    }\n\n    else if (role == Qt::EditRole)\n    {\n        if (index.column() == RegisterFileColumns::DESCRIPTION)\n        {\n            return valueForIndex(index);\n        }\n\n        return expressionOrValueForIndex(index);\n    }\n\n    else if (role == Qt::ToolTipRole)\n    {\n        if (isValidExpressionColumn(index))\n        {\n            return formattedValueFor(valueForIndex(index).toString());\n        }\n        else\n        {\n            return valueForIndex(index).toString();\n        }\n    }\n    else if (role == Qt::ForegroundRole)\n    {\n        if (validateIndex(index))\n        {\n            QSharedPointer<RegisterFile> regFile = items_.at(index.row());\n\n            if (index.column() != RegisterFileColumns::IS_PRESENT &&\n                (!regFile->getIsPresent().isEmpty() && \n                    parseExpressionToDecimal(regFile->getIsPresent()).toInt() != 1))\n            {\n                return KactusColors::DISABLED_TEXT;\n            }\n            else\n            {\n                return KactusColors::REGULAR_TEXT;\n            }            \n        }\n        else\n        {\n            return KactusColors::ERROR;\n        }\n    }\n    else if (role == Qt::BackgroundRole)\n    {\n        if (index.column() == RegisterFileColumns::NAME ||\n            index.column() == RegisterFileColumns::ADDRESS_OFFSET ||\n            index.column() == RegisterFileColumns::RANGE)\n        {\n            return KactusColors::MANDATORY_FIELD;\n        }\n        else\n        {\n            return KactusColors::REGULAR_FIELD;\n        }\n    }\n\n    return QVariant();\n}\n\n//-----------------------------------------------------------------------------\n// Function: RegisterFileModel::valueForIndex()\n//-----------------------------------------------------------------------------\nQVariant RegisterFileModel::valueForIndex(QModelIndex const& index) const\n{\n    QSharedPointer<RegisterFile> const& regFile = items_.at(index.row());\n\n    if (index.column() == RegisterFileColumns::NAME)\n    {\n        return regFile->name();\n    }\n    else if (index.column() == RegisterFileColumns::ADDRESS_OFFSET)\n    {\n        return regFile->getAddressOffset();\n    }\n    else if (index.column() == RegisterFileColumns::RANGE)\n    {\n        return regFile->getRange();\n    }\n    else if (index.column() == RegisterFileColumns::DIMENSION)\n    {\n        return regFile->getDimension();\n    }\n    else if (index.column() == RegisterFileColumns::DESCRIPTION)\n    {\n        return regFile->description();\n    }\n    else if (index.column() == RegisterFileColumns::IS_PRESENT)\n    {\n        return regFile->getIsPresent();\n    }\n\n    return QVariant();\n}\n\n//-----------------------------------------------------------------------------\n// Function: RegisterFileModel::expressionOrValueForIndex()\n//-----------------------------------------------------------------------------\nQVariant RegisterFileModel::expressionOrValueForIndex(QModelIndex const& index) const\n{\n    QSharedPointer<RegisterFile> const& regFile = items_.at(index.row());\n    if (index.column() == RegisterFileColumns::DIMENSION)\n    {\n        return regFile->getDimension();\n    }\n    else if (index.column() == RegisterFileColumns::ADDRESS_OFFSET)\n    {\n        return regFile->getAddressOffset();\n    }\n    else if (index.column() == RegisterFileColumns::IS_PRESENT)\n    {\n        return regFile->getIsPresent();\n    }\n    else if(index.column() == RegisterFileColumns::RANGE)\n    {\n        return regFile->getRange();\n    }\n  \n    return data(index, Qt::DisplayRole);\n}\n\n//-----------------------------------------------------------------------------\n// Function: registerfilemodel::setData()\n//-----------------------------------------------------------------------------\nbool RegisterFileModel::setData(QModelIndex const& index, QVariant const& value, int role)\n{\n\tif (!index.isValid() || index.row() < 0 || index.row() >= items_.size())\n    {\n        return false;\n    }\n\n    if (role == Qt::EditRole)\n    {\n        QSharedPointer<RegisterFile> const& regFile = items_.at(index.row());\n\n        bool changed = true;\n        if (index.column() == RegisterFileColumns::NAME)\n        {\n            regFile->setName(value.toString());\n            emit headerDataChanged(Qt::Vertical, index.row(), index.row());\n        }\n        else if (index.column() == RegisterFileColumns::ADDRESS_OFFSET)\n        {\n            if (!value.isValid())\n            {\n                removeReferencesFromSingleExpression(regFile->getAddressOffset());\n            }\n\n            regFile->setAddressOffset(value.toString());\n        }\n        else if (index.column() == RegisterFileColumns::DIMENSION)\n        {\n            if (!value.isValid())\n            {\n                removeReferencesFromSingleExpression(regFile->getDimension());\n            }\n\n            regFile->setDimension(value.toString());\n        }\n        else if (index.column() == RegisterFileColumns::DESCRIPTION)\n        {\n            regFile->setDescription(value.toString());\n        }\n        else if (index.column() == RegisterFileColumns::IS_PRESENT)\n        {\n            if (!value.isValid())\n            {\n                removeReferencesFromSingleExpression(regFile->getIsPresent());\n            }\n\n            regFile->setIsPresent(value.toString());\n        }\n        else if (index.column() == RegisterFileColumns::RANGE)\n        {\n            if (!value.isValid())\n            {\n                removeReferencesFromSingleExpression(regFile->getRange());\n            }\n\n            regFile->setRange(value.toString());\n            changed = true;\n        }\n        else\n        {\n            changed = false;\n        }\n\n        if (changed)\n        {\n            if (index.column() == RegisterFileColumns::NAME ||\n                index.column() == RegisterFileColumns::ADDRESS_OFFSET ||\n                index.column() == RegisterFileColumns::RANGE ||\n                index.column() == RegisterFileColumns::DIMENSION ||\n                index.column() == RegisterFileColumns::IS_PRESENT)\n            {\n                emit graphicsChanged(registerData_->indexOf(regFile));\n\n                if (index.column() != RegisterFileColumns::NAME)\n                {\n                    emit childAddressingChanged(registerData_->indexOf(regFile));\n                }\n            }\n\n            emit dataChanged(index, index);\n            emit contentChanged();\n            return true;\n        }\n    }\n\n    return false;\n}\n\n//-----------------------------------------------------------------------------\n// Function: RegisterFileModel::mimeTypes()\n//-----------------------------------------------------------------------------\nQStringList RegisterFileModel::mimeTypes() const\n{\n    QStringList types(QAbstractItemModel::mimeTypes());\n    types << \"text/xml/ipxact:registerFile\";\n\n    return types;\n}\n\n//-----------------------------------------------------------------------------\n// Function: RegisterFileModel::isValidExpressionColumn()\n//-----------------------------------------------------------------------------\nbool RegisterFileModel::isValidExpressionColumn(QModelIndex const& index) const\n{\n    return index.column() == RegisterFileColumns::DIMENSION||\n           index.column() == RegisterFileColumns::RANGE ||\n           index.column() == RegisterFileColumns::ADDRESS_OFFSET ||\n           index.column() == RegisterFileColumns::IS_PRESENT;\n}\n\n//-----------------------------------------------------------------------------\n// Function: RegisterFileModel::validateIndex()\n//-----------------------------------------------------------------------------\nbool RegisterFileModel::validateIndex(QModelIndex const& index) const\n{\n    QSharedPointer<RegisterFile> regFile = items_.at(index.row());\n\n    if (index.column() == RegisterFileColumns::NAME)\n    {\n        QStringList registerNames;\n        foreach (QSharedPointer<RegisterFile> registerItem, items_)\n        {\n            registerNames.append(registerItem->name());\n        }\n\n        return registerNames.count(regFile->name()) == 1 && registerFileValidator_->hasValidName(regFile);\n    }\n    else if (index.column() == RegisterFileColumns::DIMENSION)\n    {\n        return registerFileValidator_->hasValidDimensions(regFile);\n    }\n\n    else if (index.column() == RegisterFileColumns::ADDRESS_OFFSET)\n    {\n        return registerFileValidator_->hasValidAddressOffset(regFile);\n    }\n\n    else if (index.column() == RegisterFileColumns::IS_PRESENT)\n    {\n        return registerFileValidator_->hasValidIsPresent(regFile);\n    }\n\n    if (regFile && index.column() == RegisterFileColumns::RANGE)\n    {\n        return registerFileValidator_->hasValidRange(regFile);\n    }\n\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: RegisterFileModel::getAllReferencesToIdInItemOnRow()\n//-----------------------------------------------------------------------------\nint RegisterFileModel::getAllReferencesToIdInItemOnRow(const int& row, QString const& valueID) const\n{    \n    QSharedPointer<RegisterFile> const& regFile = items_.at(row);\n\n    int count = 0;\n    count += regFile->getAddressOffset().count(valueID);\n    count += regFile->getDimension().count(valueID);\n    count += regFile->getIsPresent().count(valueID);\n    count += regFile->getRange().count(valueID);\n\n    return count;\n}\n\n//-----------------------------------------------------------------------------\n// Function: RegisterFileModel::onAddItem()\n//-----------------------------------------------------------------------------\nvoid RegisterFileModel::onAddItem(QModelIndex const& index)\n{\n    // Find last register/registerFile by address offset.\n    auto lastRegister = std::max_element(registerData_->cbegin(), registerData_->cend(),\n        [this](QSharedPointer<RegisterBase> const& a, QSharedPointer<RegisterBase> const& b)\n    {\n        return parseExpressionToDecimal(a->getAddressOffset()).toInt() < \n            parseExpressionToDecimal(b->getAddressOffset()).toInt();\n    });\n\n    quint64 lastRegAddress = 0;\n    quint64 lastRegDimension = 0;\n    quint64 lastRegRange = 0;\n\n    if (lastRegister != registerData_->cend())\n    {\n        lastRegAddress = parseExpressionToDecimal((*lastRegister)->getAddressOffset()).toInt();\n        lastRegDimension = parseExpressionToDecimal((*lastRegister)->getDimension()).toInt();\n\n        QSharedPointer<Register> reg = lastRegister->dynamicCast<Register>();\n        QSharedPointer<RegisterFile> regFile = lastRegister->dynamicCast<RegisterFile>();\n        if (reg)\n        {\n            lastRegRange = parseExpressionToDecimal(reg->getSize()).toInt() / qMax(addressUnitBits_, 1u);\n        }\n        else if (regFile)\n        {\n            lastRegRange = parseExpressionToDecimal(regFile->getRange()).toInt();\n        }\n    }\n   \n    qreal offsetIncrease = qMax(quint64(1), lastRegRange * qMax(quint64(1), lastRegDimension));\n\n    // convert the address to hexadecimal form\n    quint64 itemAddress = lastRegAddress + offsetIncrease;\n\tQString offset = QStringLiteral(\"'h\") + QString::number(itemAddress, 16);\n\n    // if the index is valid then add the item to the correct position\n    int row = items_.size();\n    if (index.isValid())\n    {\n        row = index.row();\n    }\n\n    int dataIndex = registerData_->size();\n    if (row < items_.size() - 1)\n    {\n        dataIndex = registerData_->indexOf(items_.at(row + 1));\n    }\n\n\tbeginInsertRows(QModelIndex(), row, row);\n    QSharedPointer<RegisterFile> regItem(new RegisterFile());    \n    regItem->setAddressOffset(offset);\n    regItem->setRange(QString::number(1));\n    items_.insert(row, regItem);\n    registerData_->insert(dataIndex, regItem);\n    endInsertRows();\n\n\t// inform navigation tree that file set is added\n\temit itemAdded(dataIndex);\n\n\t// tell also parent widget that contents have been changed\n\temit contentChanged();\n}\n\n//-----------------------------------------------------------------------------\n// Function: RegisterFileModel::onRemoveItem()\n//-----------------------------------------------------------------------------\nvoid RegisterFileModel::onRemoveItem(QModelIndex const& index )\n{\n\t// don't remove anything if index is invalid\n    if (!index.isValid() || index.row() < 0 || index.row() >= items_.size())\n    {\n\t\treturn;\n\t}\n\n\n\t// remove the specified item\n\tbeginRemoveRows(QModelIndex(), index.row(), index.row());\n\n    QSharedPointer<RegisterBase> removedRegister = items_.at(index.row());\n    if (removedRegister)\n    {\n        decreaseReferencesWithRemovedRegister(removedRegister);\n    }\n\n    int itemRow = registerData_->indexOf(removedRegister);\n\n\titems_.removeAt(index.row());\n    registerData_->removeAt(itemRow);\n\tendRemoveRows();\n\n\t// inform navigation tree that file set has been removed\n\temit itemRemoved(itemRow);\n\n\t// tell also parent widget that contents have been changed\n\temit contentChanged();\n}\n\n//-----------------------------------------------------------------------------\n// Function: RegisterFileModel::decreaserReferencesWithRemovedRegisters()\n//-----------------------------------------------------------------------------\nvoid RegisterFileModel::decreaseReferencesWithRemovedRegister(QSharedPointer<RegisterBase> removedRegister)\n{\n    QStringList expressionList;\n\n    QSharedPointer<RegisterFile> regFile = removedRegister.dynamicCast<RegisterFile>();\n    \n    if(regFile)\n    {\n      RegisterFileExpressionsGatherer regFileGatherer;\n      expressionList << regFileGatherer.getExpressions(regFile);\n    }\n\n    ReferenceCalculator referenceCalculator(getParameterFinder());\n    QMap<QString, int> referencedParameters = referenceCalculator.getReferencedParameters(expressionList);\n\n    foreach (QString referencedID, referencedParameters.keys())\n    {\n        for (int i = 0; i < referencedParameters.value(referencedID); ++i)\n        {\n            emit decreaseReferences(referencedID);\n        }\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: RegisterFileModel::increaseReferencesInPastedRegisterFile()\n//-----------------------------------------------------------------------------\nvoid RegisterFileModel::increaseReferencesInPastedRegisterFile(QSharedPointer<RegisterFile> pastedRegisterFile,\n    RegisterFileExpressionsGatherer& gatherer,\n    ReferenceCalculator& referenceCalculator)\n{\n    QStringList registerExpressions = gatherer.getExpressions(pastedRegisterFile);\n\n    QMap<QString, int> referencedParameters = referenceCalculator.getReferencedParameters(registerExpressions);\n\n    QMapIterator<QString, int> refParameterIterator(referencedParameters);\n    while (refParameterIterator.hasNext())\n    {\n        refParameterIterator.next();\n        for (int i = 0; i < refParameterIterator.value(); ++i)\n        {\n            emit increaseReferences(refParameterIterator.key());\n        }\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: RegisterFileModel::addressUnitBitsChanged()\n//-----------------------------------------------------------------------------\nvoid RegisterFileModel::addressUnitBitsChanged(int newAddressUnitbits)\n{\n    addressUnitBits_ = newAddressUnitbits;\n}\n\n//-----------------------------------------------------------------------------\n// Function: RegisterFileModel::onCopyRows()\n//-----------------------------------------------------------------------------\nvoid RegisterFileModel::onCopyRows(QModelIndexList indexList)\n{\n    QList<QSharedPointer<RegisterFile> > copiedRegisters;\n    for (QModelIndex index : indexList)\n    {\n        copiedRegisters.append(items_.at(index.row()));\n    }\n\n    QVariant registerVariant;\n    registerVariant.setValue(copiedRegisters);\n\n    QMimeData* newMimeData = new QMimeData();\n    newMimeData->setData(\"text/xml/ipxact:registerFile\", QByteArray());\n    newMimeData->setImageData(registerVariant);\n\n    QApplication::clipboard()->setMimeData(newMimeData);\n}\n\n//-----------------------------------------------------------------------------\n// Function: RegisterFileModel::onPasteRows()\n//-----------------------------------------------------------------------------\nvoid RegisterFileModel::onPasteRows()\n{\n    const QMimeData* pasteData = QApplication::clipboard()->mimeData();\n\n    if (pasteData->hasImage())\n    {\n        QVariant pasteVariant = pasteData->imageData();\n        if (pasteVariant.canConvert<QList<QSharedPointer<RegisterFile> > >())\n        {            \n            RegisterFileExpressionsGatherer gatherer;\n            ReferenceCalculator referenceCalculator(getParameterFinder());\n\n            QList<QSharedPointer<RegisterFile> > newRegisters =\n                pasteVariant.value<QList<QSharedPointer<RegisterFile> > >();\n\n            int rowBegin = items_.size();\n            int rowEnd = rowBegin + newRegisters.size() - 1;\n\n            beginInsertRows(QModelIndex(), rowBegin, rowEnd);\n\n            for (QSharedPointer<RegisterFile> copiedRegister : newRegisters)\n            {                \n\n                    QSharedPointer<RegisterFile> newRegFile (new RegisterFile(*copiedRegister));\n                    newRegFile->setName(getUniqueName(newRegFile->name(), getAllNames()));\n\n                    registerData_->append(newRegFile);\n                    items_.append(newRegFile);\n\n                    increaseReferencesInPastedRegisterFile(newRegFile, gatherer, referenceCalculator);\n\n                    emit itemAdded(registerData_->size() - 1);                \n            }\n\n            endInsertRows();\n\n            emit contentChanged();\n        }\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: registerfilemodel::getAllNames()\n//-----------------------------------------------------------------------------\nQStringList RegisterFileModel::getAllNames() const\n{\n    QStringList names;\n    for (QSharedPointer<RegisterFile> registerItem : items_)\n    {\n        names.append(registerItem->name());\n    }\n\n    return names;\n}\n"
  },
  {
    "path": "editors/ComponentEditor/memoryMaps/registerfilemodel.h",
    "content": "//-----------------------------------------------------------------------------\n// File: registerfilemodel.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Dan Chianucci\n// Date: 19.06.2018\n//\n// Description:\n// The model to manage the register files of a single address block or another register file.\n//-----------------------------------------------------------------------------\n\n#ifndef REGISTERFILEMODEL_H\n#define REGISTERFILEMODEL_H\n\n#include <IPXACTmodels/Component/RegisterFile.h>\n#include <IPXACTmodels/Component/RegisterBase.h>\n\n#include <editors/ComponentEditor/common/ParameterizableTable.h>\n#include <editors/ComponentEditor/common/ReferencingTableModel.h>\n#include <KactusAPI/include/ExpressionFormatter.h>\n#include <KactusAPI/include/ParameterFinder.h>\n\n#include <QSharedPointer>\n\nclass Choice;\nclass Register;\nclass RegisterFile;\nclass RegisterValidator;\nclass RegisterFileValidator;\nclass RegisterExpressionsGatherer;\nclass RegisterFileExpressionsGatherer;\nclass ReferenceCalculator;\n\n//-----------------------------------------------------------------------------\n//! The model to manage the register files of a single address block or another register file.\n//-----------------------------------------------------------------------------\nclass RegisterFileModel : public ReferencingTableModel, public ParameterizableTable\n{\n\tQ_OBJECT\n\npublic:\n\n\t/*!\n\t *  The constructor.\n\t *\n\t *    @param [in] registerData            The register data containing the register files to edit.\n\t *    @param [in] expressionParser        The expression parser.\n     *    @param [in] parameterFinder         The parameter finder.\n\t *    @param [in] expressionFormatter     The expression formatter.\n     *    @param [in] registerValidator       Validator for registers.\n\t *    @param [in] parent                  The owner of the model.\n\t */\n\tRegisterFileModel(QSharedPointer<QList<QSharedPointer<RegisterBase> > >  registerData,\n        QSharedPointer<ExpressionParser> expressionParser,\n        QSharedPointer<ParameterFinder> parameterFinder,\n        QSharedPointer<ExpressionFormatter> expressionFormatter,\n        QSharedPointer<RegisterFileValidator> registerFileValidator,\n\t\tQObject *parent);\n\n\t//! The destructor.\n\tvirtual ~RegisterFileModel() = default;\n\n    //! No copying.\n    RegisterFileModel(const RegisterFileModel& other) = delete;\n\n    //! No assignment.\n    RegisterFileModel& operator=(const RegisterFileModel& other) = delete;\n\n\t/*!\n     *  Get the number of rows an item contains.\n\t *\n\t *    @param [in] parent  Identifies the parent that's row count is requested.\n\t *\n\t *    @return Number of rows the item has.\n\t */\n\tvirtual int rowCount(const QModelIndex& parent = QModelIndex()) const;\n\n\t/*!\n     *  Get the number of displayed columns.\n\t *\n\t *    @param [in] parent  Identifies the parent that's column count is requested.\n\t *\n\t *    @return The number of columns to be displayed.\n\t */\n\tvirtual int columnCount(const QModelIndex& parent = QModelIndex()) const;\n\n\t/*!\n     *  Get the item flags that defines the possible operations for the item.\n\t *\n\t *    @param [in] index   Model index that identifies the item.\n\t *\n\t *    @return Qt::ItemFlags specify the possible operations for the item.\n\t */\n\tQt::ItemFlags flags(const QModelIndex& index) const;\n\n\t/*!\n     *  Get the header data for specified header.\n\t *\n\t *    @param [in] section         The section specifies the row/column number for the header.\n\t *    @param [in] orientation     Specified if horizontal or vertical header is wanted.\n\t *    @param [in] role            Specifies the type of the requested data.\n\t *\n\t *    @return QVariant Contains the requested data.\n\t */\n\tvirtual QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;\n\n\t/*!\n     *  Get the data for specified item.\n\t *\n\t *    @param [in] index   Specifies the item that's data is requested.\n\t *    @param [in] role    The role that defines what kind of data is requested.\n\t *\n\t *    @return QVariant Contains the data for the item.\n\t */\n\tvirtual QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const;\n\n\t/*!\n     *  Save the data to the model for specified item.\n\t *\n\t *    @param [in] index   The model index of the item that's data is to be saved.\n\t *    @param [in] value   The data that is to be saved.\n\t *    @param [in] role    The role specifies what kind of data should be saved.\n\t *\n\t *    @return True if saving happened successfully.\n\t */\n\tbool setData(const QModelIndex& index, const QVariant& value, int role = Qt::EditRole);\n\n    /*!\n     *  Get the list of acceptable mime types.\n     *\n     *    @return The list of acceptable mime types.\n     */\n    virtual QStringList mimeTypes() const;\n\nprotected:\n\n    /*!\n     *  Check if the column is valid for containing expressions.\n     *\n     *    @param [in] index   The index of the column.\n     *\n     *    @return     True, if the column is valid for expressions, otherwise false.\n     */\n    virtual bool isValidExpressionColumn(QModelIndex const& index) const;\n\n    /*!\n     *  Gets the expression for the given index, or plain value if there is no expression.\n     *\n     *    @param [in] index   The index of target data.\n     *\n     *    @return     Expression or plain value for the given index.\n     */\n    virtual QVariant expressionOrValueForIndex(QModelIndex const& index) const;\n\n    /*!\n     *  Validates the data in the index.\n     *\n     *    @param [in] index   The index of target data.\n     *\n     *    @return     True, if the data is valid, otherwise false.\n     */\n    virtual bool validateIndex(QModelIndex const& index) const;\n\n    /*!\n     *  Gets all the references to the selected id from the selected register.\n     *\n     *    @param [in] row         The row of the selected register.\n     *    @param [in] valueID     The id of the referenced parameter.\n     *\n     *    @return The amount of references made to the target parameter.\n     */\n    virtual int getAllReferencesToIdInItemOnRow(const int& row, QString const& valueID) const;\n\npublic slots:\n\n\t/*!\n     *  Add a new item to the given index.\n\t *\n\t *    @param [in] index   The index identifying the position for new item.\n\t */\n    void onAddItem(QModelIndex const& index);\n\n\t/*!\n     *  Remove the item in the given index.\n\t *\n\t *    @param [in] index   The index identifying the item to remove.\n\t */\n\tvirtual void onRemoveItem(const QModelIndex& index);\n\n    /*!\n     *  Change the value for address unit bits.\n     *\n     *    @param [in] newAddressUnitbits  The new value for address unit bits.\n     */\n    void addressUnitBitsChanged(int newAddressUnitbits);\n\n    /*!\n     *  Copy the items in the selected rows.\n     *\n     *    @param [in] indexList   List of indexes pointing to the selected rows.\n     */\n    void onCopyRows(QModelIndexList indexList);\n\n    /*!\n     *  Paste the copied items.\n     */\n    void onPasteRows();\n\nsignals:\n\n    //! Emitted when the contents of the model change.\n    void contentChanged();\n\n    /*!\n     *  Informs of a need to redraw the visualizer.\n     */\n    void graphicsChanged(int index);\n\n    //! Prints an error message to the user.\n    void errorMessage(const QString& msg) const;\n\n    //! Emitted when a new register item is added to the given index.\n    void itemAdded(int index);\n\n    //! Emitted when a register item is removed from the given index.\n    void itemRemoved(int index);\n\n    void childAddressingChanged(int index);\n\nprivate:\n\n    /*!\n     *  Get the value for the corresponding index.\n     *\n     *    @param [in] index   The index whose value is being searched for.\n     */\n    QVariant valueForIndex(const QModelIndex& index) const;\n\n    /*!\n     *  Decrease the number of references made from a removed register.\n     *\n     *    @param [in] removedRegister     The removed register.\n     */\n    void decreaseReferencesWithRemovedRegister(QSharedPointer<RegisterBase> removedRegister);\n\n    /*!\n     *  Get all the names of the registers and register files in register data.\n     *\n     *    @return The names of the registers and register files.\n     */\n    QStringList getAllNames() const;\n\n    /*!\n     *  Increase the number of references made in the copied register.\n     *\n     *    @param [in] pastedRegisterFile      The copied register file.\n     *    @param [in] gatherer                Register expressions gatherer.\n     *    @param [in] referenceCalculator     The reference calculator.\n     */\n    void increaseReferencesInPastedRegisterFile(QSharedPointer<RegisterFile> pastedRegisterFile,\n        RegisterFileExpressionsGatherer& gatherer, ReferenceCalculator& referenceCalculator);\n\n    //-----------------------------------------------------------------------------\n    // Data.\n    //-----------------------------------------------------------------------------\n\n    //! Contains all registers and register files.\n    QSharedPointer<QList<QSharedPointer<RegisterBase> > > registerData_;\n\n\t//! Contains the register file items to display in this model.\n    QList<QSharedPointer<RegisterFile> >  items_;\n\n    //! The address unit bits of the memory map.\n    unsigned int addressUnitBits_;\n\n    //! The parameter finder.\n    QSharedPointer<ParameterFinder> parameterFinder_;\n\n    //! Expression formatter, formats the referencing expressions to show parameter names.\n    QSharedPointer<ExpressionFormatter> expressionFormatter_;\n\n    //! The validator used for registers.\n    QSharedPointer<RegisterFileValidator> registerFileValidator_;\n\n};\n\n#endif // REGISTERFILEMODEL_H\n"
  },
  {
    "path": "editors/ComponentEditor/memoryMaps/registertablemodel.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: registertablemodel.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 25.08.2012\r\n//\r\n// Description:\r\n// The model to manage the details of a single register.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"registertablemodel.h\"\r\n#include \"RegisterColumns.h\"\r\n\r\n#include <IPXACTmodels/Component/validators/FieldValidator.h>\r\n\r\n#include <KactusAPI/include//FieldExpressionsGatherer.h>\r\n#include <editors/ComponentEditor/memoryMaps/memoryMapsExpressionCalculators/ReferenceCalculator.h>\r\n#include <KactusAPI/include/FieldInterface.h>\r\n\r\n#include <common/KactusColors.h>\r\n\r\n#include <QRegularExpression>\r\n#include <QApplication>\r\n#include <QClipboard>\r\n#include <QMimeData>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: registertablemodel::RegisterTableModel()\r\n//-----------------------------------------------------------------------------\r\nRegisterTableModel::RegisterTableModel(FieldInterface* fieldInterface,\r\n    QSharedPointer <ExpressionParser> expressionParser, QSharedPointer <ParameterFinder> parameterFinder,\r\n    Document::Revision docRevision,\r\n    QObject *parent) :\r\nReferencingTableModel(parameterFinder, parent),\r\nParameterizableTable(parameterFinder),\r\nfieldInterface_(fieldInterface),\r\ndocRevision_(docRevision)\r\n{\r\n    setExpressionParser(expressionParser);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: registertablemodel::rowCount()\r\n//-----------------------------------------------------------------------------\r\nint RegisterTableModel::rowCount( const QModelIndex& /*parent = QModelIndex()*/ ) const \r\n{\r\n    return fieldInterface_->itemCount();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: registertablemodel::columnCount()\r\n//-----------------------------------------------------------------------------\r\nint RegisterTableModel::columnCount( const QModelIndex& parent /*= QModelIndex()*/ ) const \r\n{\r\n\tif (parent.isValid()) \r\n    {\r\n\t\treturn 0;\r\n\t}\r\n    return RegisterColumns::COLUMN_COUNT;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: registertablemodel::flags()\r\n//-----------------------------------------------------------------------------\r\nQt::ItemFlags RegisterTableModel::flags( const QModelIndex& index ) const \r\n{\r\n\tif (!index.isValid())\r\n    {\r\n\t\treturn Qt::NoItemFlags;\r\n\t}\r\n\r\n    std::string fieldName = fieldInterface_->getIndexedItemName(index.row());\r\n\r\n    // Lock resets column\r\n    if (index.column() == RegisterColumns::RESETS_COLUMN)\r\n    {\r\n        return Qt::ItemIsEnabled | Qt::ItemIsSelectable;\r\n    }\r\n\r\n    // Lock std14 columns (values located in field access policy for std22), if there are multiple field access \r\n    // policies defined for the field.\r\n    if (isStd14Column(index) && docRevision_ == Document::Revision::Std22 &&\r\n        fieldInterface_->getAccessPolicyCount(fieldName) > 1)\r\n    {\r\n        return Qt::ItemIsEnabled | Qt::ItemIsSelectable;\r\n    }\r\n\r\n\t// if the field is not testable then the test constraint can not be set\r\n    if (int accessPolicyIndex = docRevision_ == Document::Revision::Std22 ? 0 : -1;\r\n        index.column() == RegisterColumns::TEST_CONSTR_COLUMN && \r\n        !fieldInterface_->getTestableBool(fieldName, accessPolicyIndex))\r\n    {\r\n        return Qt::ItemIsEnabled | Qt::ItemIsSelectable;\r\n\t}\r\n\r\n\treturn Qt::ItemIsEnabled | Qt::ItemIsEditable | Qt::ItemIsSelectable;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: registertablemodel::headerData()\r\n//-----------------------------------------------------------------------------\r\nQVariant RegisterTableModel::headerData( int section, Qt::Orientation orientation, \r\n    int role /*= Qt::DisplayRole*/ ) const \r\n{\r\n    if (orientation == Qt::Vertical && role == Qt::DisplayRole) \r\n    {\r\n        return QString::fromStdString(fieldInterface_->getIndexedItemName(section));\r\n    }\r\n\r\n    if (orientation == Qt::Horizontal && role == Qt::DisplayRole) \r\n    {\r\n        if (section == RegisterColumns::NAME_COLUMN)\r\n        {\r\n            return tr(\"Field\\nname\");\r\n        }\r\n        else if (section == RegisterColumns::DESCRIPTION_COLUMN)\r\n        {\r\n            return tr(\"Description\");\r\n        }\r\n        else if (section == RegisterColumns::OFFSET_COLUMN)\r\n        {\r\n            QString bitOffset = tr(\"Offset \\n[bits]\") + getExpressionSymbol();\r\n            return bitOffset;\r\n        }\r\n        else if (section == RegisterColumns::WIDTH_COLUMN)\r\n        {\r\n            QString bitWidth = tr(\"Width \\n[bits]\") + getExpressionSymbol();\r\n            return bitWidth;\r\n        }\r\n        else if (section == RegisterColumns::RESETS_COLUMN)\r\n        {\r\n            return tr(\"Resets\");\r\n        }\r\n        else if (section == RegisterColumns::VOLATILE_COLUMN)\r\n        {\r\n            return tr(\"Volatile\");\r\n        }\r\n        else if (section == RegisterColumns::ACCESS_COLUMN)\r\n        {\r\n            return tr(\"Access\");\r\n        }\r\n        else if (section == RegisterColumns::MOD_WRITE_COLUMN)\r\n        {\r\n            return tr(\"Modified\\nwrite value\");\r\n        }\r\n        else if (section == RegisterColumns::READ_ACTION_COLUMN)\r\n        {\r\n            return tr(\"Read\\naction\");\r\n        }\r\n        else if (section == RegisterColumns::TESTABLE_COLUMN)\r\n        {\r\n            return tr(\"Testable\");\r\n        }\r\n        else if (section == RegisterColumns::TEST_CONSTR_COLUMN)\r\n        {\r\n            return tr(\"Test\\nconstraint\");\r\n        }\r\n        else if (section == RegisterColumns::IS_PRESENT_COLUMN)\r\n        {\r\n            return tr(\"Is present\") + getExpressionSymbol();\r\n        }\r\n        else\r\n        {\r\n            return QVariant();\r\n        }\r\n\t}\r\n\telse \r\n    {\r\n\t\treturn QVariant();\r\n\t}\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: registertablemodel::data()\r\n//-----------------------------------------------------------------------------\r\nQVariant RegisterTableModel::data( const QModelIndex& index, int role /*= Qt::DisplayRole*/ ) const \r\n{\r\n\tif (!index.isValid()) \r\n    {\r\n\t\treturn QVariant();\r\n\t}\r\n    else if (index.row() < 0 || index.row() >= fieldInterface_->itemCount()) \r\n    {\r\n\t\treturn QVariant();\r\n\t}\r\n\r\n    std::string fieldName = fieldInterface_->getIndexedItemName(index.row());\r\n\r\n\tif (Qt::DisplayRole == role) \r\n    {\r\n        return getIndexValueByStdRevision(index);\r\n\t}\r\n\r\n    else if (role == Qt::EditRole)\r\n    {\r\n        return expressionOrValueForIndex(index);\r\n    }\r\n\r\n    else if (role == Qt::ToolTipRole)\r\n    {\r\n        if (index.column() == RegisterColumns::RESETS_COLUMN)\r\n        {\r\n            return QString::fromStdString(fieldInterface_->getResetsToolTip(fieldName));\r\n        }\r\n        else\r\n        {\r\n            return valueForIndex(index);\r\n        }\r\n    }\r\n\r\n\telse if (Qt::ForegroundRole == role) \r\n    {\r\n        if (validateIndex(index))\r\n        {\r\n            std::string fieldPresence = fieldInterface_->getIsPresentExpression(fieldName);\r\n            qint64 fieldPresenceValue =\r\n                QString::fromStdString(fieldInterface_->getIsPresentValue(fieldName, 10)).toLongLong();\r\n\r\n            if (index.column() != RegisterColumns::IS_PRESENT_COLUMN &&\r\n                (!fieldPresence.empty() && fieldPresenceValue != 1))\r\n            {\r\n                return KactusColors::DISABLED_TEXT;\r\n            }\r\n            else\r\n            {\r\n                return KactusColors::REGULAR_TEXT;\r\n            }\r\n        }\r\n        else\r\n        {\r\n            return KactusColors::ERROR;\r\n        }\r\n\t}\r\n\telse if (Qt::BackgroundRole == role) \r\n    {\r\n        if (index.column() == RegisterColumns::NAME_COLUMN || index.column() == RegisterColumns::OFFSET_COLUMN ||\r\n            index.column() == RegisterColumns::WIDTH_COLUMN)\r\n        {\r\n            return KactusColors::MANDATORY_FIELD;\r\n        }\r\n        else if (index.column() == RegisterColumns::RESETS_COLUMN ||\r\n            index.flags() == (Qt::ItemIsEnabled | Qt::ItemIsSelectable))\r\n        {\r\n            return KactusColors::DISABLED_FIELD;\r\n        }\r\n        else\r\n        {\r\n            return KactusColors::REGULAR_FIELD;\r\n\t\t}\r\n\t}\r\n    else if (role == Qt::FontRole)\r\n    {\r\n        return italicForEvaluatedValue(index);\r\n    }\r\n\telse \r\n    {\r\n\t\treturn QVariant();\r\n\t}\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: registertablemodel::formattedExpressionForIndex()\r\n//-----------------------------------------------------------------------------\r\nQVariant RegisterTableModel::formattedExpressionForIndex(QModelIndex const& index) const\r\n{\r\n    std::string fieldName = fieldInterface_->getIndexedItemName(index.row());\r\n\r\n    if (index.column() == RegisterColumns::OFFSET_COLUMN)\r\n    {\r\n        return QString::fromStdString(fieldInterface_->getOffsetFormattedExpression(fieldName));\r\n    }\r\n    else if (index.column() == RegisterColumns::WIDTH_COLUMN)\r\n    {\r\n        return QString::fromStdString(fieldInterface_->getWidthFormattedExpression(fieldName));\r\n    }\r\n    else if (index.column() == RegisterColumns::IS_PRESENT_COLUMN)\r\n    {\r\n        return QString::fromStdString(fieldInterface_->getIsPresentFormattedExpression(fieldName));\r\n    }\r\n\r\n    return QVariant();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: registertablemodel::expressionForIndex()\r\n//-----------------------------------------------------------------------------\r\nQVariant RegisterTableModel::expressionForIndex(QModelIndex const& index) const\r\n{\r\n    std::string fieldName = fieldInterface_->getIndexedItemName(index.row());\r\n\r\n    if (index.column() == RegisterColumns::OFFSET_COLUMN)\r\n    {\r\n        return QString::fromStdString(fieldInterface_->getOffsetExpression(fieldName));\r\n    }\r\n    else if (index.column() == RegisterColumns::WIDTH_COLUMN)\r\n    {\r\n        return QString::fromStdString(fieldInterface_->getWidthExpression(fieldName));\r\n    }\r\n    else if (index.column() == RegisterColumns::IS_PRESENT_COLUMN)\r\n    {\r\n        return QString::fromStdString(fieldInterface_->getIsPresentExpression(fieldName));\r\n    }\r\n    else\r\n    {\r\n        return QVariant();\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: registertablemodel::valueForIndex()\r\n//-----------------------------------------------------------------------------\r\nQVariant RegisterTableModel::valueForIndex(QModelIndex const& index) const\r\n{\r\n    std::string fieldName = fieldInterface_->getIndexedItemName(index.row());\r\n\r\n    // Get the value from first field access policy if std22 is used, and there are zero or one field\r\n    // access policies defined for the field. Get the value from the field if using std14.\r\n    int accessPolicyIndex = docRevision_ == Document::Revision::Std22 ? 0 : -1;\r\n\r\n    if (index.column() == RegisterColumns::NAME_COLUMN)\r\n    {\r\n        return QString::fromStdString(fieldName);\r\n    }\r\n    else if (index.column() == RegisterColumns::DESCRIPTION_COLUMN)\r\n    {\r\n        return QString::fromStdString(fieldInterface_->getDescription(fieldName));\r\n    }\r\n    else if (index.column() == RegisterColumns::OFFSET_COLUMN)\r\n    {\r\n        return QString::fromStdString(fieldInterface_->getOffsetValue(fieldName));\r\n    }\r\n    else if (index.column() == RegisterColumns::WIDTH_COLUMN)\r\n    {\r\n        return QString::fromStdString(fieldInterface_->getWidthValue(fieldName));\r\n    }\r\n    else if (index.column() == RegisterColumns::RESETS_COLUMN)\r\n    {\r\n        return QString::fromStdString(fieldInterface_->getResets(fieldName));\r\n    }\r\n    else if (index.column() == RegisterColumns::VOLATILE_COLUMN)\r\n    {\r\n        return QString::fromStdString(fieldInterface_->getVolatile(fieldName));\r\n    }\r\n    else if (index.column() == RegisterColumns::ACCESS_COLUMN)\r\n    {\r\n        return QString::fromStdString(fieldInterface_->getAccessString(fieldName, accessPolicyIndex));\r\n    }\r\n    else if (index.column() == RegisterColumns::MOD_WRITE_COLUMN)\r\n    {\r\n        return QString::fromStdString(fieldInterface_->getModifiedWriteString(fieldName, accessPolicyIndex));\r\n    }\r\n    else if (index.column() == RegisterColumns::READ_ACTION_COLUMN)\r\n    {\r\n        return QString::fromStdString(fieldInterface_->getReadActionString(fieldName, accessPolicyIndex));\r\n    }\r\n    else if (index.column() == RegisterColumns::TESTABLE_COLUMN)\r\n    {\r\n        return QString::fromStdString(fieldInterface_->getTestableValue(fieldName, accessPolicyIndex));\r\n    }\r\n    else if (index.column() == RegisterColumns::TEST_CONSTR_COLUMN)\r\n    {\r\n        return QString::fromStdString(fieldInterface_->getTestConstraintString(fieldName, accessPolicyIndex));\r\n    }\r\n    else if (index.column() == RegisterColumns::IS_PRESENT_COLUMN)\r\n    {\r\n        return QString::fromStdString(fieldInterface_->getIsPresentValue(fieldName));\r\n    }\r\n    else\r\n    {\r\n        return QVariant();\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: registertablemodel::setData()\r\n//-----------------------------------------------------------------------------\r\nbool RegisterTableModel::setData(QModelIndex const& index, QVariant const& value, int role) \r\n{\r\n    if (!index.isValid() || index.row() < 0 || index.row() >= fieldInterface_->itemCount()) \r\n    {\r\n\t\treturn false;\r\n\t}\r\n\r\n    std::string fieldName = fieldInterface_->getIndexedItemName(index.row());\r\n\r\n\tif (role == Qt::EditRole) \r\n    {\r\n        if (index.column() == RegisterColumns::NAME_COLUMN)\r\n        {\r\n            fieldInterface_->setName(fieldName, value.toString().toStdString());\r\n\r\n            QString oldName = QString::fromStdString(fieldName);\r\n            QString newName = QString::fromStdString(fieldInterface_->getIndexedItemName(index.row()));\r\n\r\n            emit fieldNameChanged(oldName, newName);\r\n\r\n            emit headerDataChanged(Qt::Vertical, index.row(), index.row());\r\n            emit graphicsChanged(index.row());\r\n        }\r\n        else if (index.column() == RegisterColumns::DESCRIPTION_COLUMN)\r\n        {\r\n            fieldInterface_->setDescription(fieldName, value.toString().toStdString());\r\n        }\r\n        else if (index.column() == RegisterColumns::OFFSET_COLUMN)\r\n        {\r\n            if (!value.isValid())\r\n            {\r\n                removeReferencesFromSingleExpression(\r\n                    QString::fromStdString(fieldInterface_->getOffsetExpression(fieldName)));\r\n            }\r\n\r\n            fieldInterface_->setOffset(fieldName, value.toString().toStdString());\r\n\r\n            emit graphicsChanged(index.row());\r\n            emit addressingChanged(index.row());\r\n        }\r\n        else if (index.column() == RegisterColumns::WIDTH_COLUMN)\r\n        {\r\n            if (!value.isValid())\r\n            {\r\n                removeReferencesFromSingleExpression(\r\n                    QString::fromStdString(fieldInterface_->getWidthExpression(fieldName)));\r\n            }\r\n\r\n            fieldInterface_->setWidth(fieldName, value.toString().toStdString());\r\n\r\n            emit graphicsChanged(index.row());\r\n            emit addressingChanged(index.row());\r\n        }\r\n        else if (index.column() == RegisterColumns::VOLATILE_COLUMN)\r\n        {\r\n            fieldInterface_->setVolatile(fieldName, value.toString().toStdString());\r\n        }\r\n        else if (index.column() == RegisterColumns::IS_PRESENT_COLUMN)\r\n        {\r\n            if (!value.isValid())\r\n            {\r\n                removeReferencesFromSingleExpression(\r\n                    QString::fromStdString(fieldInterface_->getIsPresentExpression(fieldName)));\r\n            }\r\n\r\n            fieldInterface_->setIsPresent(fieldName, value.toString().toStdString());\r\n\r\n            emit graphicsChanged(index.row());\r\n            emit addressingChanged(index.row());\r\n        }\r\n        else if (isStd14Column(index))\r\n        {\r\n            if (!setStd14ColumnData(index, value, fieldName))\r\n            {\r\n                return false;\r\n            }\r\n        }\r\n        else\r\n        {\r\n            return false;\r\n\t\t}\r\n\r\n        emit dataChanged(index, index);\r\n\t\temit contentChanged();\r\n\t\treturn true;\r\n\t}\r\n\telse \r\n    {\r\n\t\treturn false;\r\n\t}\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: registertablemodel::isValidExpressionColumn()\r\n//-----------------------------------------------------------------------------\r\nbool RegisterTableModel::isValidExpressionColumn(QModelIndex const& index) const\r\n{\r\n    if (index.column() == RegisterColumns::OFFSET_COLUMN || index.column() == RegisterColumns::WIDTH_COLUMN ||\r\n        index.column() == RegisterColumns::IS_PRESENT_COLUMN || index.column() == RegisterColumns::RESETS_COLUMN)\r\n    {\r\n        return true;\r\n    }\r\n    else\r\n    {\r\n        return false;\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: registertablemodel::expressionOrValueForIndex()\r\n//-----------------------------------------------------------------------------\r\nQVariant RegisterTableModel::expressionOrValueForIndex(QModelIndex const& index) const\r\n{\r\n    if (index.column() == RegisterColumns::OFFSET_COLUMN || index.column() == RegisterColumns::WIDTH_COLUMN ||\r\n        index.column() == RegisterColumns::IS_PRESENT_COLUMN)\r\n    {\r\n        return expressionForIndex(index);\r\n    }\r\n    else\r\n    {\r\n        return valueForIndex(index);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: registertablemodel::validateIndex()\r\n//-----------------------------------------------------------------------------\r\nbool RegisterTableModel:: validateIndex(QModelIndex const& index) const\r\n{\r\n    std::string fieldName = fieldInterface_->getIndexedItemName(index.row());\r\n\r\n    int accessPolicyIndex = docRevision_ == Document::Revision::Std22 ? 0 : -1;\r\n\r\n    if (index.column() == RegisterColumns::NAME_COLUMN)\r\n    {\r\n        return fieldInterface_->itemHasValidName(fieldName);\r\n    }\r\n    else if (index.column() == RegisterColumns::OFFSET_COLUMN)\r\n    {\r\n        return fieldInterface_->hasValidOffset(fieldName);\r\n    }\r\n    else if (index.column() == RegisterColumns::WIDTH_COLUMN)\r\n    {\r\n        return fieldInterface_->hasValidWidth(fieldName);\r\n    }\r\n    else if (index.column() == RegisterColumns::RESETS_COLUMN)\r\n    {\r\n        return fieldInterface_->hasValidResets(fieldName);\r\n    }\r\n    else if (index.column() == RegisterColumns::IS_PRESENT_COLUMN)\r\n    {\r\n        return fieldInterface_->hasValidIsPresent(fieldName);\r\n    }\r\n    else if (index.column() == RegisterColumns::ACCESS_COLUMN)\r\n    {\r\n        return fieldInterface_->hasValidAccess(fieldName, accessPolicyIndex);\r\n    }\r\n\r\n    return true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: registertablemodel::getAllReferencesToIdInItemOnRow()\r\n//-----------------------------------------------------------------------------\r\nint RegisterTableModel::getAllReferencesToIdInItemOnRow(const int& row, QString const& valueID) const\r\n{\r\n    return fieldInterface_->getAllReferencesToIdInItem(\r\n        fieldInterface_->getIndexedItemName(row), valueID.toStdString());\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: registertablemodel::onAddItem()\r\n//-----------------------------------------------------------------------------\r\nvoid RegisterTableModel::onAddItem( const QModelIndex& index )\r\n{\r\n    int row = fieldInterface_->itemCount();\r\n\r\n\t// if the index is valid then add the item to the correct position\r\n\tif (index.isValid())\r\n    {\r\n\t\trow = index.row();\r\n\t}\r\n\r\n\tbeginInsertRows(QModelIndex(), row, row);\r\n\r\n    fieldInterface_->addField(row);\r\n\r\n\tendInsertRows();\r\n\r\n\t// inform navigation tree that file set is added\r\n\temit fieldAdded(row);\r\n\r\n\t// tell also parent widget that contents have been changed\r\n\temit contentChanged();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: registertablemodel::onRemoveItem()\r\n//-----------------------------------------------------------------------------\r\nvoid RegisterTableModel::onRemoveItem( const QModelIndex& index )\r\n{\r\n\t// don't remove anything if index is invalid\r\n\tif (!index.isValid())\r\n    {\r\n\t\treturn;\r\n\t}\r\n\r\n    int itemRow = index.row();\r\n\r\n\t// make sure the row number if valid\r\n    if (itemRow < 0 || itemRow >= fieldInterface_->itemCount())\r\n    {\r\n\t\treturn;\r\n\t}\r\n\r\n    std::string fieldName = fieldInterface_->getIndexedItemName(itemRow);\r\n\r\n\t// remove the specified item\r\n    beginRemoveRows(QModelIndex(), itemRow, itemRow);\r\n\r\n    decreaseReferencesWithRemovedField(QString::fromStdString(fieldName));\r\n    fieldInterface_->removeField(fieldName);\r\n\r\n    endRemoveRows();\r\n\r\n\t// inform navigation tree that file set has been removed\r\n\temit fieldRemoved(index.row());\r\n\r\n\t// tell also parent widget that contents have been changed\r\n\temit contentChanged();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: registertablemodel::decreaseReferencesWithRemovedField()\r\n//-----------------------------------------------------------------------------\r\nvoid RegisterTableModel::decreaseReferencesWithRemovedField(QString const& fieldName)\r\n{\r\n    QMap<QString, int> referencedParameters = getReferencedParameters(fieldName);\r\n\r\n    foreach(QString referencedId, referencedParameters.keys())\r\n    {\r\n        for (int i = 0; i < referencedParameters.value(referencedId); ++i)\r\n        {\r\n            emit decreaseReferences(referencedId);\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: registertablemodel::increaseReferencesInPastedField()\r\n//-----------------------------------------------------------------------------\r\nvoid RegisterTableModel::increaseReferencesInPastedField(QString const& fieldName)\r\n{\r\n    QMap<QString, int> referencedParameters = getReferencedParameters(fieldName);\r\n\r\n    foreach(QString referencedId, referencedParameters.keys())\r\n    {\r\n        for (int i = 0; i < referencedParameters.value(referencedId); ++i)\r\n        {\r\n            emit increaseReferences(referencedId);\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: registertablemodel::getReferencedParameters()\r\n//-----------------------------------------------------------------------------\r\nQMap<QString, int> RegisterTableModel::getReferencedParameters(QString const& fieldName) const\r\n{\r\n    std::vector<std::string> fieldNameList;\r\n    fieldNameList.push_back(fieldName.toStdString());\r\n\r\n    auto expressionList = fieldInterface_->getExpressionsInSelectedFields(fieldNameList);\r\n    QStringList expressionListQT;\r\n    for (auto expression : expressionList)\r\n    {\r\n        expressionListQT.append(QString::fromStdString(expression));\r\n    }\r\n\r\n    ReferenceCalculator memoryMapReferenceCalculator(getParameterFinder());\r\n\r\n    return memoryMapReferenceCalculator.getReferencedParameters(expressionListQT);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: RegisterTableModel::isStd14Column()\r\n//-----------------------------------------------------------------------------\r\nbool RegisterTableModel::isStd14Column(QModelIndex const& index) const\r\n{\r\n    int col = index.column();\r\n    return col == RegisterColumns::ACCESS_COLUMN ||\r\n        col == RegisterColumns::MOD_WRITE_COLUMN ||\r\n        col == RegisterColumns::READ_ACTION_COLUMN ||\r\n        col == RegisterColumns::TESTABLE_COLUMN ||\r\n        col == RegisterColumns::TEST_CONSTR_COLUMN;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: RegisterTableModel::getIndexValueByStdRevision()\r\n//-----------------------------------------------------------------------------\r\nQVariant RegisterTableModel::getIndexValueByStdRevision(QModelIndex const& index) const\r\n{\r\n    if (isStd14Column(index) && docRevision_ == Document::Revision::Std22)\r\n    {\r\n        // Item is not editable, if there is more than one field access policy.\r\n        if (index.flags() == (Qt::ItemIsEnabled | Qt::ItemIsSelectable))\r\n        {\r\n            // Indicate multiple access policies.\r\n            if (index.column() == RegisterColumns::ACCESS_COLUMN)\r\n            {\r\n                return QStringLiteral(\"[multiple]\");\r\n            }\r\n\r\n            return QVariant();\r\n        }\r\n\r\n        // Return the index value of the first and only field access policy.\r\n        return valueForIndex(index);\r\n    }\r\n    else\r\n    {\r\n        if (isValidExpressionColumn(index))\r\n        {\r\n            return formattedExpressionForIndex(index);\r\n        }\r\n        else if (index.column() == RegisterColumns::TEST_CONSTR_COLUMN &&\r\n            index.flags() == (Qt::ItemIsEnabled | Qt::ItemIsSelectable))\r\n        {\r\n            // Unset test constraint, if testable is false or not set.\r\n            return QVariant();\r\n        }\r\n        else if (index.column() == RegisterColumns::DESCRIPTION_COLUMN)\r\n        {\r\n            return valueForIndex(index).toString().replace(QRegularExpression(\"\\n.*$\",\r\n                QRegularExpression::DotMatchesEverythingOption), \"...\");\r\n        }\r\n        else\r\n        {\r\n            return valueForIndex(index);\r\n        }\r\n    }\r\n\r\n    return QVariant();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: RegisterTableModel::setStd14ColumnData()\r\n//-----------------------------------------------------------------------------\r\nbool RegisterTableModel::setStd14ColumnData(QModelIndex const& index, QVariant const& value, std::string const& fieldName)\r\n{\r\n    // Set either directly the field's values, or the values of the first field access policy, depending on\r\n    // std revision.\r\n\r\n    // Modify field values directly.\r\n    int fieldAccessPolicyIndex = -1;\r\n\r\n    if (docRevision_ == Document::Revision::Std22)\r\n    {\r\n        // Add a new field access policy, if there are none AND if the new index value is not empty.\r\n        if (fieldInterface_->getAccessPolicyCount(fieldName) == 0 && value.toString().isEmpty() == false)\r\n        {\r\n            fieldInterface_->addFieldAccessPolicy(fieldName);\r\n        }\r\n\r\n        // Modify first field access policy.\r\n        fieldAccessPolicyIndex = 0;\r\n    }\r\n\r\n    if (index.column() == RegisterColumns::ACCESS_COLUMN)\r\n    {\r\n        fieldInterface_->setAccess(fieldName, value.toString().toStdString(), fieldAccessPolicyIndex);\r\n\r\n        // Remove field access policy, if new access is empty.\r\n        if (value.toString().isEmpty())\r\n        {\r\n            fieldInterface_->removeFieldAccessPolicy(fieldName, 0);\r\n        }\r\n    }\r\n    else if (index.column() == RegisterColumns::MOD_WRITE_COLUMN)\r\n    {\r\n        fieldInterface_->setModifiedWrite(fieldName, value.toString().toStdString(), fieldAccessPolicyIndex);\r\n    }\r\n    else if (index.column() == RegisterColumns::READ_ACTION_COLUMN)\r\n    {\r\n        fieldInterface_->setReadAction(fieldName, value.toString().toStdString(), fieldAccessPolicyIndex);\r\n    }\r\n    else if (index.column() == RegisterColumns::TESTABLE_COLUMN)\r\n    {\r\n        fieldInterface_->setTestable(fieldName, value.toString().toStdString(), fieldAccessPolicyIndex);\r\n        if (value.toString() == QLatin1String(\"false\"))\r\n        {\r\n            QModelIndex constrIndex = createIndex(index.row(), index.column() + 1, index.internalPointer());\r\n            emit dataChanged(constrIndex, constrIndex);\r\n        }\r\n    }\r\n    else if (index.column() == RegisterColumns::TEST_CONSTR_COLUMN)\r\n    {\r\n        fieldInterface_->setTestConstraint(fieldName, value.toString().toStdString(), fieldAccessPolicyIndex);\r\n    }\r\n    else\r\n    {\r\n        return false;\r\n    }\r\n\r\n    return true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: RegisterTableModel::onCopyRows()\r\n//-----------------------------------------------------------------------------\r\nvoid RegisterTableModel::onCopyRows(QModelIndexList indexList)\r\n{\r\n    std::vector<int> fieldIndexes;\r\n    for (auto index : indexList)\r\n    {\r\n        fieldIndexes.push_back(index.row());\r\n    }\r\n\r\n    fieldInterface_->copyRows(fieldIndexes);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: RegisterTableModel::onPasteRows()\r\n//-----------------------------------------------------------------------------\r\nvoid RegisterTableModel::onPasteRows()\r\n{\r\n    int fieldRowBegin = fieldInterface_->itemCount();\r\n\r\n    std::vector<std::string> pastedFieldNames = fieldInterface_->pasteRows();\r\n\r\n    int fieldCount = static_cast<int>(pastedFieldNames.size());\r\n    if (fieldCount == 0)\r\n    {\r\n        return;\r\n    }\r\n\r\n    if (fieldCount > 0)\r\n    {\r\n        int rowEnd = fieldRowBegin + fieldCount - 1;\r\n\r\n        beginInsertRows(QModelIndex(), fieldRowBegin, rowEnd);\r\n\r\n        for (int i = fieldRowBegin; i <= rowEnd; ++i)\r\n        {\r\n            std::string copyName = fieldInterface_->getIndexedItemName(i);\r\n            increaseReferencesInPastedField(QString::fromStdString(copyName));\r\n\r\n            emit fieldAdded(i);\r\n        }\r\n\r\n        endInsertRows();\r\n    }\r\n\r\n    emit contentChanged();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: RegisterTableModel::mimeTypes()\r\n//-----------------------------------------------------------------------------\r\nQStringList RegisterTableModel::mimeTypes() const\r\n{\r\n    QStringList types(QAbstractItemModel::mimeTypes());\r\n\r\n    types << \"text/xml/ipxact:field\";\r\n\r\n    return types;\r\n}\r\n"
  },
  {
    "path": "editors/ComponentEditor/memoryMaps/registertablemodel.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: registertablemodel.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 25.08.2012\r\n//\r\n// Description:\r\n// The model to manage the details of a single register.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef REGISTERTABLEMODEL_H\r\n#define REGISTERTABLEMODEL_H\r\n\r\n#include <IPXACTmodels/Component/Register.h>\r\n#include <IPXACTmodels/Component/Field.h>\r\n#include <IPXACTmodels/common/Document.h>\r\n\r\n#include <QAbstractTableModel>\r\n#include <QSharedPointer>\r\n#include <QList>\r\n\r\n#include <editors/ComponentEditor/common/ParameterizableTable.h>\r\n#include <editors/ComponentEditor/common/ReferencingTableModel.h>\r\n#include <KactusAPI/include/ParameterFinder.h>\r\n#include <KactusAPI/include/ExpressionFormatter.h>\r\n\r\nclass FieldValidator;\r\nclass FieldExpressionsGatherer;\r\nclass ReferenceCalculator;\r\nclass FieldInterface;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! The model to manage the details of a single register.\r\n//-----------------------------------------------------------------------------\r\nclass RegisterTableModel : public ReferencingTableModel, public ParameterizableTable\r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\r\n\t/*!\r\n\t *  The constructor.\r\n\t *\r\n\t *    @param [in] fieldInterface      Interface for fields.\r\n\t *    @param [in] expressionParser    Pointer to the expression parser.\r\n\t *    @param [in] parameterFinder     Pointer to the parameter finder.\r\n\t *    @param [in] docRevision         The IP-XACT standard revision in use.\r\n\t *    @param [in] parent              Pointer to the owner of the model.\r\n\t */\r\n    RegisterTableModel(FieldInterface* fieldInterface, QSharedPointer <ExpressionParser> expressionParser, \r\n        QSharedPointer <ParameterFinder> parameterFinder, Document::Revision docRevision, QObject *parent);\r\n\r\n\r\n\t/*!\r\n     *  The destructor.\r\n     */\r\n\tvirtual ~RegisterTableModel() = default;\r\n\r\n\t/*!\r\n     *  Get the number of rows an item contains.\r\n\t *\r\n\t *    @param [in] parent  Identifies the parent that's row count is requested.\r\n\t *\r\n\t *    @return Number of rows the item has.\r\n\t */\r\n\tvirtual int rowCount(const QModelIndex& parent = QModelIndex()) const;\r\n\r\n\t/*!\r\n     *  Get the number of columns the item has to be displayed.\r\n\t *\r\n\t *    @param [in] parent  Identifies the parent that's column count is requested.\r\n\t *\r\n\t *    @return The number of columns to be displayed.\r\n\t */\r\n\tvirtual int columnCount(const QModelIndex& parent = QModelIndex()) const;\r\n\r\n\t/*!\r\n     *  Get the item flags that defines the possible operations for the item.\r\n\t *\r\n\t *    @param [in] index   Model index that identifies the item.\r\n\t *\r\n\t *    @return Qt::ItemFlags specify the possible operations for the item.\r\n\t */\r\n\tQt::ItemFlags flags(const QModelIndex& index) const;\r\n\r\n\t/*!\r\n     *  Get the header data for specified header.\r\n\t *\r\n\t *    @param [in] section         The section specifies the row/column number for the header.\r\n\t *    @param [in] orientation     Specified if horizontal or vertical header is wanted.\r\n\t *    @param [in] role            Specifies the type of the requested data.\r\n\t *\r\n\t *    @return QVariant Contains the requested data.\r\n\t */\r\n\tvirtual QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;\r\n\r\n\t/*!\r\n     *  Get the data for specified item.\r\n\t *\r\n\t *    @param [in] index   Specifies the item that's data is requested.\r\n\t *    @param [in] role    The role that defines what kind of data is requested.\r\n\t *\r\n\t *    @return QVariant Contains the data for the item.\r\n\t */\r\n\tvirtual QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const;\r\n\r\n\t/*!\r\n     *  Save the data to the model for specified item.\r\n\t *\r\n\t *    @param [in] index   The model index of the item that's data is to be saved.\r\n\t *    @param [in] value   The data that is to be saved.\r\n\t *    @param [in] role    The role specifies what kind of data should be saved.\r\n\t *\r\n\t *    @return True if saving happened successfully.\r\n\t */\r\n\tbool setData(const QModelIndex& index, const QVariant& value, int role = Qt::EditRole);\r\n    \r\n    /*!\r\n     *  Get the list of acceptable mime types.\r\n     *\r\n     *    @return The list of acceptable mime types.\r\n     */\r\n    virtual QStringList mimeTypes() const;\r\n\r\nprotected:\r\n\r\n    /*!\r\n     *  Check if the column index is valid for expressions.\r\n     *\r\n     *    @param [in] index   The index being evaluated.\r\n     *\r\n     *    @return     True, if column can have expressions, otherwise false.\r\n     */\r\n    virtual bool isValidExpressionColumn(QModelIndex const& index) const;\r\n\r\n    /*!\r\n     *  Gets the expression for the given index, or plain value if there is no expression.\r\n     *\r\n     *    @param [in] index   The index of target data.\r\n     *\r\n     *    @return     Expression or plain value in the given index.\r\n     */\r\n    virtual QVariant expressionOrValueForIndex(QModelIndex const& index) const;\r\n\r\n    /*!\r\n     *  Validates the data in the column.\r\n     *\r\n     *    @param [in] index   The index being validated.\r\n     *\r\n     *    @return     True, if the data is valid, otherwise false.\r\n     */\r\n    virtual bool validateIndex(QModelIndex const& index) const;\r\n\r\n    /*!\r\n     *  Gets the number of all the references made on the selected row to the selected parameter.\r\n     *\r\n     *    @param [in] row         The row of the selected item.\r\n     *    @param [in] valueID     The selected parameter.\r\n     *\r\n     *    @return The amount of references made on the selected row to the selected parameter.\r\n     */\r\n    virtual int getAllReferencesToIdInItemOnRow(const int& row, QString const& valueID) const;\r\n\r\npublic slots:\r\n\r\n\t/*!\r\n     *  Add a new item to the given index.\r\n\t *\r\n\t *    @param [in] index   The index identifying the position for new item.\r\n\t */\r\n\tvirtual void onAddItem(const QModelIndex& index);\r\n\r\n\t/*!\r\n     *  Remove the item in the given index.\r\n\t *\r\n\t *    @param [in] index   The index identifying the item to remove.\r\n\t */\r\n\tvirtual void onRemoveItem(const QModelIndex& index);\r\n\r\n    /*!\r\n     *  Copy the items in the selected rows.\r\n     *\r\n     *    @param [in] indexList   List of indexes pointing to the selected rows.\r\n     */\r\n    void onCopyRows(QModelIndexList indexList);\r\n\r\n    /*!\r\n     *  Paste the copied items.\r\n     */\r\n    void onPasteRows();\r\n\r\nsignals:\r\n\r\n\t//! Emitted when the contents of the model change.\r\n\tvoid contentChanged();\r\n\r\n    /*!\r\n     *  Informs of a need to redraw the visualization.\r\n     */\r\n    void graphicsChanged(int index);\r\n\r\n    void addressingChanged(int index);\r\n\r\n\r\n    /*\r\n     *  Informs of field name change.\r\n     *\r\n     *    @param [in] oldName     The old name.\r\n     *    @param [in] newName     The new name.\r\n     */\r\n    void fieldNameChanged(QString const& oldName, QString const& newName);\r\n\r\n\t//! Emitted when a new field is added to the given index.\r\n\tvoid fieldAdded(int index);\r\n\r\n\t//! Emitted when a field is removed from the given index.\r\n\tvoid fieldRemoved(int index);\r\n\r\nprivate:\r\n\t\r\n\t//! No copying. No assignment.\r\n\tRegisterTableModel(const RegisterTableModel& other);\r\n\tRegisterTableModel& operator=(const RegisterTableModel& other);\r\n\r\n    /*!\r\n     *  Get the formatted value of an expression in the selected index.\r\n     *\r\n     *    @param [in] index   The selected index.\r\n     *\r\n     *    @return The formatted value of an expression in the selected index.\r\n     */\r\n    virtual QVariant formattedExpressionForIndex(QModelIndex const& index) const;\r\n\r\n    /*!\r\n     *  Get the expression of the selected index.\r\n     *\r\n     *    @param [in] index   The selected index.\r\n     *\r\n     *    @return The expression of the selected index.\r\n     */\r\n    virtual QVariant expressionForIndex(QModelIndex const& index) const;\r\n\r\n    /*!\r\n     *  Gets the value for the given index.\r\n     *\r\n     *    @param [in] index   The index of target data.\r\n     *\r\n     *    @return     The data in the given index.\r\n     */\r\n    QVariant valueForIndex(QModelIndex const& index) const;\r\n\r\n    /*!\r\n     *  Decrease the number of references when removing a field.\r\n     *\r\n     *    @param [in] fieldName   Name of the selected field.\r\n     */\r\n    void decreaseReferencesWithRemovedField(QString const& fieldName);\r\n\r\n    /*!\r\n     *  Increase the number of references made in the selected field.\r\n     *\r\n     *    @param [in] fieldName   Name of the selected field.\r\n     */\r\n    void increaseReferencesInPastedField(QString const& fieldName);\r\n\r\n    /*!\r\n     *  Calculates the parameters used in the selected field.\r\n     *\r\n     *    @param [in] fieldName   Name of the selected field.\r\n     *\r\n     *    @return A map containing pairs of referenced ids and the number of references made to them.\r\n     */\r\n    QMap<QString, int> getReferencedParameters(QString const& fieldName) const;\r\n\r\n    /*!\r\n     *\tCheck if the column of a given index is displaying values stored directly in the field according \r\n     *  to the 2014 IP-XACT standard revision.\r\n     *  \r\n     *    @param [in] index     Description\r\n     *\t    \r\n     * \t    @return True, if the column is a std14 column, otherwise false.\r\n     */\r\n    bool isStd14Column(QModelIndex const& index) const;\r\n\r\n    /*!\r\n     *\tGet the right index value to display according to which IP-XACT standard is in use. The values for access,\r\n     *  modified write, read action testable and test constraint should be retrieved from the field, if std2014 is\r\n     *  in use. For std2022, the value is none (except for access displaying '[multiple]') if the field has\r\n     *  multiple field access policies. If the field has one field access policy, the values displayed will be \r\n     *  the values of that field access policy. The values are empty if the field has no field access policies.\r\n     *  \r\n     *    @param [in] index     The index to get the value of.\r\n     *\t    \r\n     * \t    @return The index value.\r\n     */\r\n    QVariant getIndexValueByStdRevision(QModelIndex const& index) const;\r\n\r\n    /*!\r\n     *\tSet the index data for columns where the data is stored directly in the field when using std 2014, and in \r\n     *  field access policies when using std 2022. Set the data for either the first field access policy of the \r\n     *  if using std22 or the field itself if using std14.\r\n     *  \r\n     *    @param [in] index       The model index of the item that's data is to be saved.\r\n     *    @param [in] value       The data that is to be saved.\r\n     *    @param [in] fieldName   The name of the field.\r\n     *\t    \r\n     * \t    @return True, if the setting the data succeeded, otherwise false.\r\n     */\r\n    bool setStd14ColumnData(QModelIndex const& index, QVariant const& value, std::string const& fieldName);\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! Interface for fields.\r\n    FieldInterface* fieldInterface_;\r\n\r\n    //! The IP-XACT standard revision in use.\r\n    Document::Revision docRevision_;\r\n};\r\n\r\n#endif // REGISTERTABLEMODEL_H\r\n"
  },
  {
    "path": "editors/ComponentEditor/modes/FieldSliceColumns.h",
    "content": "//-----------------------------------------------------------------------------\n// File: FieldSliceColumns.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Esko Pekkarinen\n// Date: 18.08.2023\n//\n// Description:\n// Common declarations for editing FieldSlices in mode.\n//-----------------------------------------------------------------------------\n\nnamespace FieldSliceColumns\n{\n    //! Contains the columns for FieldSlice properties.\n    enum Column\n    {\n        NAME = 0,\n        FIELD_REF,\n        RANGE_LEFT,\n        RANGE_RIGHT,\n        DESCRIPTION,\n        COLUMN_COUNT\n    };\n\n}\n"
  },
  {
    "path": "editors/ComponentEditor/modes/FieldSliceDelegate.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: FieldSliceDelegate.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Esko Pekkarinen\n// Date: 01.09.2023\n//\n// Description:\n// Delegate that provides widgets for editing field slices in mode.\n//-----------------------------------------------------------------------------\n\n#include \"FieldSliceDelegate.h\"\n\n#include \"FieldSliceColumns.h\"\n\n#include <common/widgets/TreeItemSelector/FramedTreeItemEditor.h>\n\n//-----------------------------------------------------------------------------\n// Function: FieldSliceDelegate::FieldSliceDelegate()\n//-----------------------------------------------------------------------------\nFieldSliceDelegate::FieldSliceDelegate(QSharedPointer<QList<QSharedPointer<MemoryMap> > > memoryMaps,\n    QSharedPointer<QList<QSharedPointer<AddressSpace> > > addressSpaces,\n    QAbstractItemModel* completionModel,\n    QSharedPointer<ParameterFinder> parameterFinder,\n    QObject* parent):\n    ExpressionDelegate(completionModel, parameterFinder, parent),\nmemoryMaps_(memoryMaps),\naddressSpaces_(addressSpaces)\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: FieldSliceDelegate::createEditor()\n//-----------------------------------------------------------------------------\nQWidget* FieldSliceDelegate::createEditor(QWidget* parent, QStyleOptionViewItem const& option,\n    QModelIndex const& index) const\n{\n    if (index.column() == FieldSliceColumns::FIELD_REF)\n    {\n        auto factory =  MemoryTreeFactory(memoryMaps_, addressSpaces_);\n        auto referenceSelector = new FramedTreeItemEditor(&factory, parent);\n\n\n        connect(referenceSelector, SIGNAL(finishEditing()), this, SLOT(commitAndCloseEditor()), Qt::UniqueConnection);\n        connect(referenceSelector, SIGNAL(cancelEditing()), this, SLOT(onEditorCancel()), Qt::UniqueConnection);\n\n        return referenceSelector;\n    }\n    else\n    {\n        return ExpressionDelegate::createEditor(parent, option, index);\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: FieldSliceDelegate::setEditorData()\n//-----------------------------------------------------------------------------\nvoid FieldSliceDelegate::setEditorData(QWidget* editor, QModelIndex const& index) const\n{\n    if (index.column() == FieldSliceColumns::FIELD_REF)\n    {\n        auto path = index.model()->data(index, Qt::EditRole).toStringList();\n        auto referenceSelector = qobject_cast<FramedTreeItemEditor*>(editor);\n\n        referenceSelector->selectPath(path);\n    }\n    else\n    {\n        ExpressionDelegate::setEditorData(editor, index);\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: FieldSliceDelegate::setModelData()\n//-----------------------------------------------------------------------------\nvoid FieldSliceDelegate::setModelData(QWidget* editor, QAbstractItemModel* model, QModelIndex const& index)\n    const\n{\n    if (index.column() == FieldSliceColumns::FIELD_REF)\n    {\n        auto referenceSelector = qobject_cast<FramedTreeItemEditor*>(editor);\n        auto path = referenceSelector->selectedPath();\n\n        model->setData(index, path, Qt::EditRole);\n    }\n    else\n    {\n        ExpressionDelegate::setModelData(editor, model, index);\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: FieldSliceDelegate::updateEditorGeometry()\n//-----------------------------------------------------------------------------\nvoid FieldSliceDelegate::updateEditorGeometry(QWidget* editor, const QStyleOptionViewItem& option, const QModelIndex& index) const\n{\n    if (index.column() == FieldSliceColumns::FIELD_REF)\n    {\n        int editorMinimumHeight = editor->sizeHint().height();\n\n        const int PARENT_HEIGHT = editor->parentWidget()->height();\n        const int AVAILABLE_HEIGHT_BELOW = PARENT_HEIGHT - option.rect.top();\n\n        if (AVAILABLE_HEIGHT_BELOW > editorMinimumHeight)\n        {\n            editor->move(option.rect.topLeft());\n        }\n        else\n        {\n            int repositionY = PARENT_HEIGHT - editorMinimumHeight;\n            if (repositionY <= 0)\n            {\n                repositionY = 0;\n            }\n\n            editor->move(option.rect.left(), repositionY);\n        }\n\n        editor->setFixedHeight(qMin(editorMinimumHeight, PARENT_HEIGHT));\n        editor->setFixedWidth(qMax(editor->sizeHint().width() + 8, option.rect.width()));\n    }\n    else\n    {\n        ExpressionDelegate::updateEditorGeometry(editor, option, index);\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: FieldSliceDelegate::descriptionColumn()\n//-----------------------------------------------------------------------------\nint FieldSliceDelegate::descriptionColumn() const\n{\n    return FieldSliceColumns::DESCRIPTION;\n}\n\n//-----------------------------------------------------------------------------\n// Function: FieldSliceDelegate::columnAcceptsExpression()\n//-----------------------------------------------------------------------------\nbool FieldSliceDelegate::columnAcceptsExpression(int column) const\n{\n    return column == FieldSliceColumns::RANGE_LEFT || column == FieldSliceColumns::RANGE_RIGHT;\n}\n\n//-----------------------------------------------------------------------------\n// Function: FieldSliceDelegate::commitAndCloseEditor()\n//-----------------------------------------------------------------------------\nvoid FieldSliceDelegate::commitAndCloseEditor()\n{\n    QWidget* edit = qobject_cast<QWidget*>(sender());\n    Q_ASSERT(edit);\n\n    emit commitData(edit);\n    emit closeEditor(edit);\n}\n\n//-----------------------------------------------------------------------------\n// Function: FieldSliceDelegate::onEditorCancel()\n//-----------------------------------------------------------------------------\nvoid FieldSliceDelegate::onEditorCancel()\n{\n    QWidget* edit = qobject_cast<QWidget*>(sender());\n    if (edit)\n    {\n        emit closeEditor(edit);\n    }\n}"
  },
  {
    "path": "editors/ComponentEditor/modes/FieldSliceDelegate.h",
    "content": "//-----------------------------------------------------------------------------\n// File: FieldSliceDelegate.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Esko Pekkarinen\n// Date: 01.09.2023\n//\n// Description:\n// Delegate that provides widgets for editing field slices in mode.\n//-----------------------------------------------------------------------------\n\n#ifndef FIELDSLICE_DELEGATE_H\n#define FIELDSLICE_DELEGATE_H\n\n#include <IPXACTmodels/Component/AddressSpace.h>\n#include <IPXACTmodels/Component/MemoryMap.h>\n\n#include <editors/ComponentEditor/common/ExpressionDelegate.h>\n\n#include <QSharedPointer>\n\n#include <QStyledItemDelegate>\n\n//-----------------------------------------------------------------------------\n//! Delegate that provides widgets for editing remap condition.\n//-----------------------------------------------------------------------------\nclass FieldSliceDelegate : public ExpressionDelegate\n{\n\tQ_OBJECT\n\npublic:\n\n    /*!\n     *  The constructor.\n     *\n     *    @param [in] portNameList            The list of available port names.\n     *    @param [in] completionModel         Model containing the completions used in expression editor.\n     *    @param [in] expressions             The collection of objects for expression handling.\n     *    @param [in] parent                  The parent of the object.\n     */\n    FieldSliceDelegate(QSharedPointer<QList<QSharedPointer<MemoryMap> > > memoryMaps, \n\t\tQSharedPointer<QList<QSharedPointer<AddressSpace> > > addressSpaces,\n        QAbstractItemModel* completionModel,\n        QSharedPointer<ParameterFinder> parameterFinder,\n\t\tQObject* parent = nullptr);\n\n\t//! The destructor\n    virtual ~FieldSliceDelegate() = default;\n\n    //! No copying\n    FieldSliceDelegate(const FieldSliceDelegate& other) = delete;\n\n    //! No assignment\n    FieldSliceDelegate& operator=(const FieldSliceDelegate& other) = delete;\n\n\t/*! Create a new editor for the given item\n\t *\n\t *    @param [in] parent   Owner for the editor.\n\t *    @param [in] option   Contains options for the editor.\n\t *    @param [in] index    Model index identifying the item.\n\t *\n\t *    @return Pointer to the editor to be used to edit the item.\n\t*/\n\tvirtual QWidget* createEditor(QWidget* parent, QStyleOptionViewItem const& option, \n        QModelIndex const& index) const final;\n\n\t/*! Set the data for the editor.\n\t *\n\t *    @param [in] editor  Pointer to the editor where the data is to be set.\n\t *    @param [in] index   Model index identifying the item that's data is to be set.\n\t*/\n\tvirtual void setEditorData(QWidget* editor, QModelIndex const& index) const final;\n\n\t/*! Save the data from the editor to the model.\n\t *\n\t *    @param [in] editor   Pointer to the editor that contains the data to store.\n\t *    @param [in] model    Model that contains the data structure where data is to be saved to.\n\t *    @param [in] index    Model index identifying the item that's data is to be saved.\n\t *\n\t*/\n\tvirtual void setModelData(QWidget* editor, QAbstractItemModel* model, QModelIndex const& index) const final;\n\n\n\n\n\tvoid updateEditorGeometry(QWidget* editor, QStyleOptionViewItem const& option, QModelIndex const& index) const override;\n\n\nsignals:\n\n    //! Emitted when the values of the array change.\n    void contentChanged();\nprotected:\n    int descriptionColumn() const override;\n\n\n\tbool columnAcceptsExpression(int column) const override;\n\nprivate slots:\n\n\tvoid commitAndCloseEditor();\n\n\tvoid onEditorCancel();\n\nprivate:\n\n    //-----------------------------------------------------------------------------\n    // Data.\n    //-----------------------------------------------------------------------------\n\n\n    QSharedPointer<QList<QSharedPointer<MemoryMap> > > memoryMaps_;\n\n\tQSharedPointer<QList<QSharedPointer<AddressSpace> > > addressSpaces_;\n\n};\n\n#endif // FIELDSLICE_DELEGATE_H\n"
  },
  {
    "path": "editors/ComponentEditor/modes/FieldSliceEditor.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: FieldSliceEditor.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Esko Pekkarinen\n// Date: 09.08.2023\n//\n// Description:\n// Editor to add/remove/edit the mode-elements of a component.\n//-----------------------------------------------------------------------------\n\n#include \"FieldSliceEditor.h\"\n#include \"FieldSliceColumns.h\"\n\n#include <common/widgets/summaryLabel/summarylabel.h>\n#include <KactusAPI/include/LibraryInterface.h>\n\n#include <editors/ComponentEditor/parameters/ComponentParameterModel.h>\n\n\n#include <editors/common/ExpressionSet.h>\n\n#include <IPXACTmodels/Component/Component.h>\n\n#include \"FieldSliceDelegate.h\"\n\n#include <QVBoxLayout>\n#include <QHeaderView>\n\n//-----------------------------------------------------------------------------\n// Function: FieldSliceEditor::FieldSliceEditor()\n//-----------------------------------------------------------------------------\nFieldSliceEditor::FieldSliceEditor(QSharedPointer<Component> component, \n\tQSharedPointer<Mode> mode, \n\tQSharedPointer<FieldSliceValidator> validator,\n\tExpressionSet expressions,\n\tLibraryInterface* handler, \n\tQWidget* parent) :\nQWidget(parent),\n\tcomponent_(component),\n    view_(this),\n    proxy_(this),\n    model_(mode, validator, expressions, this)\n{\n\n\tQVBoxLayout* layout = new QVBoxLayout(this);\n\tlayout->addWidget(&view_);\n\tlayout->setContentsMargins(0, 0, 0, 0);\n\n\tproxy_.setSourceModel(&model_);\n\tview_.setModel(&proxy_);\n\n\tconst QString compPath = handler->getDirectoryPath(component->getVlnv());\n\tQString defPath = QString(\"%1/FieldSliceListing.csv\").arg(compPath);\n\tview_.setDefaultImportExportPath(defPath);\n\tview_.setAllowImportExport(true);\n\tview_.setItemsDraggable(false);\n\tview_.setSortingEnabled(true);\n\n    ComponentParameterModel* parameterModel = new ComponentParameterModel(expressions.finder, this);\n    parameterModel->setExpressionParser(expressions.parser);\n\n\tauto delegate = new FieldSliceDelegate(component->getMemoryMaps(), component->getAddressSpaces(),\n\t\tparameterModel, expressions.finder, this);\n\n\tview_.setItemDelegate(delegate);\n\n\tconnect(&model_, SIGNAL(contentChanged()), this, SIGNAL(contentChanged()), Qt::UniqueConnection);\n\n\tconnect(&view_, SIGNAL(addItem(const QModelIndex&)),\n        &model_, SLOT(onAddItem(const QModelIndex&)), Qt::UniqueConnection);\n\tconnect(&view_, SIGNAL(removeItem(const QModelIndex&)),\n\t\t&model_, SLOT(onRemoveItem(const QModelIndex&)), Qt::UniqueConnection);\n\n    connect(delegate, SIGNAL(increaseReferences(QString const&)),\n        this, SIGNAL(increaseReferences(QString const&)), Qt::UniqueConnection);\n    connect(delegate, SIGNAL(decreaseReferences(QString const&)),\n        this, SIGNAL(decreaseReferences(QString const&)), Qt::UniqueConnection);\n}\n\n//-----------------------------------------------------------------------------\n// Function: FieldSliceEditor::refresh()\n//-----------------------------------------------------------------------------\nvoid FieldSliceEditor::refresh()\n{\n\tview_.update();\n}\n"
  },
  {
    "path": "editors/ComponentEditor/modes/FieldSliceEditor.h",
    "content": "//-----------------------------------------------------------------------------\n// File: FieldSliceEditor.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Esko Pekkarinen\n// Date: 08.08.2023\n//\n// Description:\n// Editor to add/remove/edit the mode-elements of a component.\n//-----------------------------------------------------------------------------\n\n#ifndef FIELDSLICE_EDITOR_H\n#define FIELDSLICE_EDITOR_H\n\n#include <common/views/EditableTableView/editabletableview.h>\n\n#include <editors/ComponentEditor/itemeditor.h>\n\n#include \"FieldSliceModel.h\"\n//#include \"FieldSliceDelegate.h\"\n\n#include <QSortFilterProxyModel>\n#include <QSharedPointer>\n\nclass Component;\nclass ModeValidator;\nclass LibraryInterface;\n\n//-----------------------------------------------------------------------------\n//! Editor to add/remove/edit the Mode-elements of a component.\n//-----------------------------------------------------------------------------\nclass FieldSliceEditor : public QWidget\n{\n\tQ_OBJECT\n\npublic:\n\n\t/*! The constructor\n\t *\n\t *    @param [in] component   The component being edited.\n\t *\t\t@param [in] mode\t\tThe mode being edited.\n     *    @param [in] validator   The validator for FieldSlice.\n     *    @param [in] expressions\tThe collection of objects for expression handling.\n\t *    @param [in] handler     The instance managing the library.\n\t *    @param [in] parent      The parent of this editor.\n\t*/\n\tFieldSliceEditor(QSharedPointer<Component> component, \n        QSharedPointer<Mode> mode,\n        QSharedPointer<FieldSliceValidator> validator,\n\t\tExpressionSet expressions,\n\t\tLibraryInterface* handler,\n\t\tQWidget* parent = nullptr);\n\t\n\t//! The destructor\n\tvirtual ~FieldSliceEditor() = default;\n\n    //! No copying\n    FieldSliceEditor(const FieldSliceEditor& other) = delete;\n    FieldSliceEditor& operator=(const FieldSliceEditor& other) = delete;\n\n\t//! Reload the information from the model to the editor.\t\n\tvoid refresh();\n\nsignals:\n\t\n\t/*!\n\t *  Increase the amount of references to a parameter corresponding to the id.\n\t *\n\t *    @param [in] parameterId     The id of the parameter being referenced.\n\t */\n\tvoid increaseReferences(QString const& parameterId);\n\n\t/*!\n\t *  Decrease the amount of references to a parameter corresponding to the id.\n\t *\n\t *    @param [in] parameterId     The id of the parameter being referenced.\n\t */\n\tvoid decreaseReferences(QString const& parameterId);\n\n\t/*!\n\t *  Emitted when the contents of the model change.\n\t */\n\tvoid contentChanged();\n\nprivate:\n\n\t//! The component containing the modes.\n\tQSharedPointer<Component> component_;\n\n\t//! The view to display the FieldSlice\n\tEditableTableView view_;\n\n\t//! The delegate for the view.\n\t//FieldSliceDelegate* delegate_ = nullptr;\n\n\t//! The model that does the sorting.\n\tQSortFilterProxyModel proxy_;\n\n\t//! The model that manages the FieldSlice of the editor.\n\tFieldSliceModel model_;\n};\n\n#endif // FIELDSLICE_EDITOR_H\n"
  },
  {
    "path": "editors/ComponentEditor/modes/FieldSliceModel.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: FieldSliceModel.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Esko Pekkarinen\n// Date: 09.08.2023\n//\n// Description:\n// Model for Mode elements within a component.\n//-----------------------------------------------------------------------------\n\n#include \"FieldSliceModel.h\"\n\n#include \"FieldSliceColumns.h\"\n\n#include <IPXACTmodels/Component/Component.h>\n#include <IPXACTmodels/Component/Mode.h>\n\n#include <QStringList>\n#include <QRegularExpression>\n\n#include <common/KactusColors.h>\n\n//-----------------------------------------------------------------------------\n// Function: FieldSliceModel::FieldSliceModel()\n//-----------------------------------------------------------------------------\nFieldSliceModel::FieldSliceModel(QSharedPointer <Mode> mode,\n    QSharedPointer<FieldSliceValidator> validator,\n    ExpressionSet expressions,\n    QObject* parent): \n    ReferencingTableModel(expressions.finder, parent),\n    ParameterizableTable(expressions.finder),\n    validator_(validator),\n    fieldSlices_(mode->getFieldSlices()),\n    expressionFormatter_(expressions.formatter)\n{\n    setExpressionParser(expressions.parser);\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: FieldSliceModel::rowCount()\n//-----------------------------------------------------------------------------\nint FieldSliceModel::rowCount(QModelIndex const& parent) const\n{\n\tif (parent.isValid())\n    {\n\t\treturn 0;\n\t}\n\n\treturn fieldSlices_->count();\n}\n\n//-----------------------------------------------------------------------------\n// Function: FieldSliceModel::columnCount()\n//-----------------------------------------------------------------------------\nint FieldSliceModel::columnCount(QModelIndex const& parent) const\n{\n\tif (parent.isValid())\n    {\n\t\treturn 0;\n\t}\n\n\treturn FieldSliceColumns::COLUMN_COUNT;\n}\n\n//-----------------------------------------------------------------------------\n// Function: FieldSliceModel::flags()\n//-----------------------------------------------------------------------------\nQt::ItemFlags FieldSliceModel::flags(QModelIndex const& index) const\n{\n\tif (!index.isValid())\n    {\n\t\treturn Qt::NoItemFlags;\n\t}\n\n\treturn Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsEditable;\n}\n\n//-----------------------------------------------------------------------------\n// Function: FieldSliceModel::headerData()\n//-----------------------------------------------------------------------------\nQVariant FieldSliceModel::headerData(int section, Qt::Orientation orientation, int role) const\n{\n\tif (orientation != Qt::Horizontal || role != Qt::DisplayRole)\n    {\n        return QVariant();\n    }\n\n    if (section == FieldSliceColumns::NAME)\n    {\n        return tr(\"Name\");\n    }\n    else if (section == FieldSliceColumns::FIELD_REF)\n    {\n        return tr(\"Field\");\n    }\n    else if (section == FieldSliceColumns::RANGE_LEFT)\n    {\n        return tr(\"Leftmost bit\") + getExpressionSymbol();\n    }\n    else if (section == FieldSliceColumns::RANGE_RIGHT)\n    {\n        return tr(\"Rightmost bit\") + getExpressionSymbol();\n    }\n    else if (section == FieldSliceColumns::DESCRIPTION)\n    {\n        return tr(\"Description\");\n    }\n    else\n    {\n        return QVariant();\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: FieldSliceModel::data()\n//-----------------------------------------------------------------------------\nQVariant FieldSliceModel::data(QModelIndex const& index, int role) const\n{\n    if (!index.isValid() || index.row() < 0 || index.row() >= fieldSlices_->size())\n    {\n        return QVariant();\n    }\n\n    QSharedPointer<FieldSlice> slice = fieldSlices_->at(index.row());\n    const int column = index.column(); \n\n    if (role == Qt::DisplayRole)\n    {\n        if (isValidExpressionColumn(index))\n        {\n            return expressionFormatter_->formatReferringExpression(valueForIndex(index).toString());\n        }\n        else\n        {\n            return valueForIndex(index).toString();\n        }\n    }\n\n    else if (role == Qt::EditRole)\n    {\n        if (column == FieldSliceColumns::FIELD_REF)\n        {\n            return getFieldRefPath(slice);\n        }\n        else\n        {\n            return valueForIndex(index);\n        }\n    }\n\n    else if (role == Qt::ToolTipRole)\n    {\n        if (isValidExpressionColumn(index))\n        {\n            return formattedValueFor(valueForIndex(index).toString());\n        }\n        else\n        {\n            return expressionOrValueForIndex(index);\n        }\n    }\n\n    else if (role == Qt::ForegroundRole)\n    {\n        return blackForValidOrRedForInvalidIndex(index);\n    }\n     \n    else if (role == Qt::BackgroundRole)\n    {\n        if (column == FieldSliceColumns::NAME || column == FieldSliceColumns::FIELD_REF)\n        {\n            return KactusColors::MANDATORY_FIELD;\n        }\n    }\n\n    return QVariant();\n}\n\n//-----------------------------------------------------------------------------\n// Function: FieldSliceModel::setData()\n//-----------------------------------------------------------------------------\nbool FieldSliceModel::setData(QModelIndex const& index, QVariant const& value, int role)\n{\n\tif (!index.isValid() || index.row() < 0 || index.row() >= fieldSlices_->size() || role != Qt::EditRole)\n    {\n        return false;\n    }\n\n    QSharedPointer<FieldSlice> slice = fieldSlices_->at(index.row());\n    const int column = index.column();\n\n    if (column == FieldSliceColumns::NAME)\n    {\n        slice->setName(value.toString());\n    }\n    else if (column == FieldSliceColumns::FIELD_REF)\n    {\n        setFieldRef(slice, value.toStringList());\n    }\n    else if (column == FieldSliceColumns::RANGE_LEFT)\n    {\n        slice->setLeft(value.toString());\n    }\n    else if (column == FieldSliceColumns::RANGE_RIGHT)\n    {\n        slice->setRight(value.toString());\n    }\n    else if (column == FieldSliceColumns::DESCRIPTION)\n    {\n        fieldSlices_->at(index.row())->setDescription(value.toString());\n    }\n    else\n    {\n        return false;\n    }\n\n    emit dataChanged(index, index);\n    emit contentChanged();\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: FieldSliceModel::onAddItem()\n//-----------------------------------------------------------------------------\nvoid FieldSliceModel::onAddItem(QModelIndex const& index)\n{\n\tint row = fieldSlices_->size();\n\n\t// if the index is valid then add the item to the correct position\n\tif (index.isValid())\n    {\n\t\trow = index.row();\n\t}\n\n\tbeginInsertRows(QModelIndex(), row, row);\n\tfieldSlices_->insert(row, QSharedPointer<FieldSlice>(new FieldSlice()));\n\tendInsertRows();\n\n\n\t// tell also parent widget that contents have been changed\n\temit contentChanged();\n}\n\n//-----------------------------------------------------------------------------\n// Function: FieldSliceModel::onRemoveItem()\n//-----------------------------------------------------------------------------\nvoid FieldSliceModel::onRemoveItem(QModelIndex const& index)\n{\n\t// don't remove anything if index is invalid\n\tif (!index.isValid() || index.row() < 0 || index.row() >= fieldSlices_->size())\n    {\n\t\treturn;\n\t}\n\n\t// remove the specified item\n\tbeginRemoveRows(QModelIndex(), index.row(), index.row());\n\tfieldSlices_->removeAt(index.row());\n\tendRemoveRows();\n\n\t// tell also parent widget that contents have been changed\n\temit contentChanged();\n}\n\n\n//-----------------------------------------------------------------------------\n// Function: FieldSliceModel::validateIndex()\n//-----------------------------------------------------------------------------\nbool FieldSliceModel::validateIndex(QModelIndex const& index) const\n{\n    const int column = index.column();\n    auto fieldSlice = fieldSlices_->at(index.row());\n\n    if (column == FieldSliceColumns::NAME)\n    {\n        return validator_->hasValidName(fieldSlice->name());\n    }\n    else if (column == FieldSliceColumns::FIELD_REF)\n    {\n        return validator_->hasValidFieldReference(fieldSlice);\n    }\n    else if (column == FieldSliceColumns::RANGE_LEFT)\n    {\n        return validator_->hasValidLeftRange(fieldSlice);\n    }\n    else if (column == FieldSliceColumns::RANGE_RIGHT)\n    {\n        return validator_->hasValidRightRange(fieldSlice);\n    }\n\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: FieldSliceModel::getAllReferencesToIdInItemOnRow()\n//-----------------------------------------------------------------------------\nint FieldSliceModel::getAllReferencesToIdInItemOnRow(const int& row, QString const& valueID) const\n{\n    auto fieldSlice = fieldSlices_->at(row);\n\n    int referencesInLeft = fieldSlice->getLeft().count(valueID);\n    int referencesInRight = fieldSlice->getRight().count(valueID);\n\n    return referencesInLeft + referencesInRight;\n}\n\n//-----------------------------------------------------------------------------\n// Function: FieldSliceModel::isValidExpressionColumn()\n//-----------------------------------------------------------------------------\nbool FieldSliceModel::isValidExpressionColumn(QModelIndex const& index) const\n{\n    return index.column() == FieldSliceColumns::RANGE_LEFT || index.column() == FieldSliceColumns::RANGE_RIGHT;\n}\n\n//-----------------------------------------------------------------------------\n// Function: FieldSliceModel::expressionOrValueForIndex()\n//-----------------------------------------------------------------------------\nQVariant FieldSliceModel::expressionOrValueForIndex(QModelIndex const& index) const\n{\n    return valueForIndex(index);\n}\n\n//-----------------------------------------------------------------------------\n// Function: FieldSliceModel::valueForIndex()\n//-----------------------------------------------------------------------------\nQVariant FieldSliceModel::valueForIndex(QModelIndex const& index) const\n{\n    const int column = index.column();\n\n    QSharedPointer<FieldSlice> slice = fieldSlices_->at(index.row());\n\n    if (column == FieldSliceColumns::NAME)\n    {\n        return slice->name();\n    }\n    else if (column == FieldSliceColumns::FIELD_REF)\n    {\n        auto ref = slice->getReference(FieldReference::FIELD);\n        if (ref.isNull() == false)\n        {\n            return ref->reference_;\n        }\n    }\n    else if (column == FieldSliceColumns::RANGE_LEFT)\n    {\n        return slice->getLeft();\n    }\n    else if (column == FieldSliceColumns::RANGE_RIGHT)\n    {\n        return slice->getRight();\n    }\n    else if (column == FieldSliceColumns::DESCRIPTION)\n    {\n        return slice->description();\n    }\n\n    return QVariant();\n}\n\n//-----------------------------------------------------------------------------\n// Function: FieldSliceModel::getFieldRefPath()\n//-----------------------------------------------------------------------------\nQStringList FieldSliceModel::getFieldRefPath(QSharedPointer<FieldSlice> slice) const\n{\n    QStringList path;\n\n    auto ref = slice->getReference(FieldReference::MEMORY_MAP);\n    if (ref)\n    {\n        path.append(\"Memory map/\" + ref->reference_);\n    }\n\n    ref = slice->getReference(FieldReference::ADDRESS_SPACE);\n    if (ref)\n    {\n        path.append(\"Address space/\" + ref->reference_);\n    }\n\n    ref = slice->getReference(FieldReference::ADDRESS_BLOCK);\n    if (ref)\n    {\n        path.append(\"Address block/\" + ref->reference_);\n    }\n\n    auto registerFiles = slice->getMultipleReference(FieldReference::REGISTER_FILE);\n    if (registerFiles)\n    {\n        for (auto registerFile : *registerFiles)\n        {\n            path.append(\"Register file/\" + registerFile->reference_);\n        }\n    }\n\n    ref = slice->getReference(FieldReference::REGISTER);\n    if (ref)\n    {\n        path.append(\"Register/\" + ref->reference_);\n    }\n\n    ref = slice->getReference(FieldReference::FIELD);\n    if (ref)\n    {\n        path.append(\"Field/\" + ref->reference_);\n    }\n\n    return path;\n}\n\n//-----------------------------------------------------------------------------\n// Function: FieldSliceModel::setFieldRef()\n//-----------------------------------------------------------------------------\nvoid FieldSliceModel::setFieldRef(QSharedPointer<FieldSlice> slice, QStringList const& fieldPath)\n{\n    QMap<QString, FieldReference::Type> refMap({\n        { QStringLiteral(\"Address space\"), FieldReference::ADDRESS_SPACE },\n        { QStringLiteral(\"Memory map\"), FieldReference::MEMORY_MAP },\n        { QStringLiteral(\"Address block\"), FieldReference::ADDRESS_BLOCK },\n        { QStringLiteral(\"Register file\"), FieldReference::REGISTER_FILE },\n        { QStringLiteral(\"Register\"), FieldReference::REGISTER },\n        { QStringLiteral(\"Field\"), FieldReference::FIELD }\n     });\n\n    slice->clearReference(FieldReference::MEMORY_MAP);\n    slice->clearReference(FieldReference::ADDRESS_SPACE);\n    slice->clearReference(FieldReference::ADDRESS_BLOCK);\n    slice->clearReference(FieldReference::REGISTER_FILE);\n    slice->clearReference(FieldReference::REGISTER);\n    slice->clearReference(FieldReference::FIELD);\n\n    for (auto const& step : fieldPath)\n    {\n        auto parts = step.split(\"/\", Qt::SkipEmptyParts);\n\n        auto ref = QSharedPointer<FieldReference::IndexedReference>(new FieldReference::IndexedReference());\n        ref->reference_ = parts.last();\n        \n        slice->setReference(ref, refMap[parts.first()]);\n    }\n}\n"
  },
  {
    "path": "editors/ComponentEditor/modes/FieldSliceModel.h",
    "content": "//-----------------------------------------------------------------------------\n// File: FieldSliceModel.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Esko Pekkarinen\n// Date: 09.08.2023\n//\n// Description:\n// Model for Mode elements within a component.\n//-----------------------------------------------------------------------------\n\n#ifndef FIELDSLICEMODEL_H\n#define FIELDSLICEMODEL_H\n\n#include <editors/common/ExpressionSet.h>\n\n#include <editors/ComponentEditor/common/ReferencingTableModel.h>\n#include <editors/ComponentEditor/common/ParameterizableTable.h>\n\n#include <IPXACTmodels/Component/FieldSlice.h>\n#include <IPXACTmodels/Component/validators/FieldSliceValidator.h>\n\n#include <KactusAPI/include/ExpressionFormatter.h>\n\n#include <QAbstractTableModel>\n#include <QSharedPointer>\n#include <QList>\n\nclass Component;\nclass Mode;\nclass ModeValidator;\n\n//-----------------------------------------------------------------------------\n//! Model for Mode elements within a component.\n//-----------------------------------------------------------------------------\nclass FieldSliceModel : public ReferencingTableModel, public ParameterizableTable\n{\n\tQ_OBJECT\n\npublic:\n\n\t/*! The constructor\n\t *\n\t *\t\t@param [in] mode        The mode being edited.\n\t *\t\t@param [in] validator   The validator for the Field slices in the mode.\n\t *    @param [in] parent      The owner of this model.\n\t*/\n\tFieldSliceModel(QSharedPointer<Mode> mode, \n\t\tQSharedPointer<FieldSliceValidator> validator,\n\t\tExpressionSet expressions,\n        QObject* parent);\n\t\n\t//! The destructor\n\tvirtual ~FieldSliceModel() = default;\n\n    //! No copying\n    FieldSliceModel(const FieldSliceModel& other) = delete;\n    FieldSliceModel& operator=(const FieldSliceModel& other) = delete;\n\n\t/*! Get the number of rows an item contains.\n\t *\n\t *    @param [in] parent Identifies the parent that's row count is requested.\n\t *\n\t *    @return Number of rows the item has.\n\t*/\n\tint rowCount(const QModelIndex& parent = QModelIndex()) const final;\n\n\t/*! Get the number of columns the item has to be displayed.\n\t *\n\t *    @param [in] parent Identifies the parent that's column count is requested.\n\t *\n\t *    @return The number of columns to be displayed.\n\t*/\n\tint columnCount(const QModelIndex& parent = QModelIndex()) const final;\n\n\t/*! Get the item flags that defines the possible operations for the item.\n\t *\n\t *    @param [in] index Model index that identifies the item.\n\t *\n\t *    @return Qt::ItemFlags specify the possible operations for the item.\n\t*/\n\tQt::ItemFlags flags(const QModelIndex& index) const final;\n\n\t/*! Get the header data for specified header.\n\t *\n\t *    @param [in] section The section specifies the row/column number for the header.\n\t *    @param [in] orientation Specified if horizontal or vertical header is wanted.\n\t *    @param [in] role Specifies the type of the requested data.\n\t *\n\t *    @return QVariant Contains the requested data.\n\t*/\n\tQVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const final;\n\n\t/*! Get the data for specified item.\n\t *\n\t *    @param [in] index Specifies the item that's data is requested.\n\t *    @param [in] role The role that defines what kind of data is requested.\n\t *\n\t *    @return QVariant Contains the data for the item.\n\t*/\n\tQVariant data(QModelIndex const& index, int role = Qt::DisplayRole) const final;\n\n\t/*! Save the data to the model for specified item\n\t *\n\t *    @param [in] index The model index of the item that's data is to be saved.\n\t *    @param [in] value The data that is to be saved.\n\t *    @param [in] role The role specifies what kind of data should be saved.\n\t *\n\t *    @return True if saving was successful.\n\t*/\n\tbool setData(QModelIndex const& index, QVariant const& value, int role = Qt::EditRole) final;\n\n\npublic slots:\n\n\t/*! Add a new item to the given index.\n\t *\n\t *    @param [in] index The index identifying the position for new item.\n\t*/\n\tvirtual void onAddItem(const QModelIndex& index);\n\n\t/*! Remove the item in the given index.\n\t *\n\t *    @param [in] index The index identifying the item to remove.\n\t*/\n\tvirtual void onRemoveItem(const QModelIndex& index);\n\nsignals:\n\n\t//! Emitted when the contents of the model change.\n\tvoid contentChanged();\n\nprotected:\n\t  \n\n\t/*!\n\t *  Validates the data for the column.\n\t *\n\t *    @param [in] index   The column of the item to validate.\n\t *\n\t *    @return True, if the data of the item is valid for the column, false otherwise.\n\t */\n\tvirtual bool validateIndex(QModelIndex const& index) const final;\n\n\n\tint getAllReferencesToIdInItemOnRow(const int& row, QString const& valueID) const override;\n\n\n\tbool isValidExpressionColumn(QModelIndex const& index) const override;\n\n\n\tQVariant expressionOrValueForIndex(QModelIndex const& index) const override;\n\nprivate:\n\n\t//! Gets the value of the cell in index.\n    QVariant valueForIndex(QModelIndex const& index) const;\n\n    void setFieldRef(QSharedPointer<FieldSlice> slice, QStringList const& fieldPath);\n    \n\tQStringList getFieldRefPath(QSharedPointer<FieldSlice> slice) const;\n\n\t//! The validator for the Field slices.\n\tQSharedPointer<FieldSliceValidator> validator_;\n\n\t//! Contains the FieldSlice being edited.\n\tQSharedPointer<QList<QSharedPointer<FieldSlice> > > fieldSlices_;\n\n\t//! Formatter to use for expressions.\n\tQSharedPointer<ExpressionFormatter> expressionFormatter_;\n};\n\n#endif // FIELDSLICEMODEL_H\n"
  },
  {
    "path": "editors/ComponentEditor/modes/ModeColumns.h",
    "content": "//-----------------------------------------------------------------------------\n// File: ModeColumns.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Esko Pekkarinen\n// Date: 08.08.2023\n//\n// Description:\n// Common declarations for editing modes.\n//-----------------------------------------------------------------------------\n\nnamespace ModeColumns\n{\n    //! Contains the columns for Mode properties.\n    enum Column\n    {\n        NAME = 0,\n        DISPLAY_NAME,\n        SHORT_DESCRIPTION,\n        DESCRIPTION,\n        COLUMN_COUNT\n    };\n\n}\n"
  },
  {
    "path": "editors/ComponentEditor/modes/ModesEditor.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: ModesEditor.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Esko Pekkarinen\n// Date: 08.08.2023\n//\n// Description:\n// Editor to add/remove/edit the mode-elements of a component.\n//-----------------------------------------------------------------------------\n\n#include \"ModesEditor.h\"\n#include \"ModeColumns.h\"\n\n#include <common/widgets/summaryLabel/summarylabel.h>\n#include <KactusAPI/include/LibraryInterface.h>\n\n#include <editors/ComponentEditor/parameters/ComponentParameterModel.h>\n\n#include <editors/common/ExpressionSet.h>\n\n#include <IPXACTmodels/Component/Component.h>\n\n#include <QCompleter>\n#include <QVBoxLayout>\n#include <QHeaderView>\n\n//-----------------------------------------------------------------------------\n// Function: ModesEditor::ModesEditor()\n//-----------------------------------------------------------------------------\nModesEditor::ModesEditor(QSharedPointer<Component> component, LibraryInterface* handler, \n\tQWidget* parent) :\nItemEditor(component, handler, parent),\n    view_(this),\n    proxy_(this),\n    model_(component, this)\n{\n    // display a label on top the table\n    SummaryLabel* summaryLabel = new SummaryLabel(tr(\"Modes summary\"), this);\n\n\tQVBoxLayout* layout = new QVBoxLayout(this);\n\tlayout->addWidget(summaryLabel, 0, Qt::AlignCenter);\n\tlayout->addWidget(&view_);\n\tlayout->setContentsMargins(0, 0, 0, 0);\n\n\tproxy_.setSourceModel(&model_);\n\tview_.setModel(&proxy_);\n\n\tconst QString compPath = handler->getDirectoryPath(component->getVlnv());\n\tQString defPath = QString(\"%1/ModesListing.csv\").arg(compPath);\n\tview_.setDefaultImportExportPath(defPath);\n\tview_.setAllowImportExport(true);\n\tview_.setItemsDraggable(false);\n\tview_.setSortingEnabled(true);\n\n\tconnect(&model_, SIGNAL(contentChanged()), this, SIGNAL(contentChanged()), Qt::UniqueConnection);\n\tconnect(&model_, SIGNAL(modeAdded(int)),\tthis, SIGNAL(childAdded(int)), Qt::UniqueConnection);\n\tconnect(&model_, SIGNAL(modeRemoved(int)), this, SIGNAL(childRemoved(int)), Qt::UniqueConnection);\n\n\tconnect(&view_, SIGNAL(addItem(const QModelIndex&)),\n        &model_, SLOT(onAddItem(const QModelIndex&)), Qt::UniqueConnection);\n\tconnect(&view_, SIGNAL(removeItem(const QModelIndex&)),\n\t\t&model_, SLOT(onRemoveItem(const QModelIndex&)), Qt::UniqueConnection);\n}\n\n//-----------------------------------------------------------------------------\n// Function: ModesEditor::refresh()\n//-----------------------------------------------------------------------------\nvoid ModesEditor::refresh()\n{\n\tview_.update();\n}\n\n//-----------------------------------------------------------------------------\n// Function: ModesEditor::showEvent()\n//-----------------------------------------------------------------------------\nvoid ModesEditor::showEvent(QShowEvent* event)\n{\n\tQWidget::showEvent(event);\n\t\n    emit helpUrlRequested(\"componenteditor/modes2022.html\");\n}\n"
  },
  {
    "path": "editors/ComponentEditor/modes/ModesEditor.h",
    "content": "//-----------------------------------------------------------------------------\n// File: Modeseditor.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Esko Pekkarinen\n// Date: 08.08.2023\n//\n// Description:\n// Editor to add/remove/edit the mode-elements of a component.\n//-----------------------------------------------------------------------------\n\n#ifndef MODESEDITOR_H\n#define MODESEDITOR_H\n\n#include <common/views/EditableTableView/editabletableview.h>\n\n#include <editors/ComponentEditor/itemeditor.h>\n\n#include \"ModesModel.h\"\n\n#include <QSortFilterProxyModel>\n#include <QSharedPointer>\n\nclass Component;\nclass ModeValidator;\nclass LibraryInterface;\n\n//-----------------------------------------------------------------------------\n//! Editor to add/remove/edit the Mode-elements of a component.\n//-----------------------------------------------------------------------------\nclass ModesEditor : public ItemEditor\n{\n\tQ_OBJECT\n\npublic:\n\n\t/*! The constructor\n\t *\n\t *    @param [in] component   The component being edited.\n\t *    @param [in] handler     The instance managing the library.\n     *    @param [in] validator   The validator for Modes.\n\t *    @param [in] parent      The parent of this editor.\n\t*/\n\tModesEditor(QSharedPointer<Component> component, LibraryInterface* handler, \n\t\tQWidget* parent = 0);\n\t\n\t//! The destructor\n\tvirtual ~ModesEditor() = default;\n\n    //! No copying\n    ModesEditor(const ModesEditor& other) = delete;\n    ModesEditor& operator=(const ModesEditor& other) = delete;\n\n\t//! Reload the information from the model to the editor.\t\n\tvoid refresh() final;\n\nprotected:\n\n\t//! Handler for widget's show event\n\tvoid showEvent(QShowEvent* event) final;\n\nprivate:\n\n\t//! The view to display the Modes\n\tEditableTableView view_;\n\n\t//! The model that does the sorting.\n\tQSortFilterProxyModel proxy_;\n\n\t//! The model that manages the Modes of the editor.\n\tModesModel model_;\n};\n\n#endif // MODESEDITOR_H\n"
  },
  {
    "path": "editors/ComponentEditor/modes/ModesModel.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: ModesModel.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Esko Pekkarinen\n// Date: 08.08.2023\n//\n// Description:\n// Model for Mode elements within a component.\n//-----------------------------------------------------------------------------\n\n#include \"ModesModel.h\"\n\n#include \"ModeColumns.h\"\n\n#include <IPXACTmodels/Component/Component.h>\n#include <IPXACTmodels/Component/Mode.h>\n\n#include <QStringList>\n#include <QRegularExpression>\n\n#include <common/KactusColors.h>\n\n//-----------------------------------------------------------------------------\n// Function: ModesModel::ModesModel()\n//-----------------------------------------------------------------------------\nModesModel::ModesModel(QSharedPointer<Component> component, \n    QObject* parent): \n    QAbstractTableModel(parent),\n    modes_(component->getModes())\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: ModesModel::rowCount()\n//-----------------------------------------------------------------------------\nint ModesModel::rowCount(QModelIndex const& parent) const\n{\n\tif (parent.isValid())\n    {\n\t\treturn 0;\n\t}\n\n\treturn modes_->count();\n}\n\n//-----------------------------------------------------------------------------\n// Function: ModesModel::columnCount()\n//-----------------------------------------------------------------------------\nint ModesModel::columnCount(QModelIndex const& parent) const\n{\n\tif (parent.isValid())\n    {\n\t\treturn 0;\n\t}\n\n\treturn ModeColumns::COLUMN_COUNT;\n}\n\n//-----------------------------------------------------------------------------\n// Function: ModesModel::flags()\n//-----------------------------------------------------------------------------\nQt::ItemFlags ModesModel::flags(QModelIndex const& index) const\n{\n\tif (!index.isValid())\n    {\n\t\treturn Qt::NoItemFlags;\n\t}\n\n\treturn Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsEditable;\n}\n\n//-----------------------------------------------------------------------------\n// Function: ModesModel::headerData()\n//-----------------------------------------------------------------------------\nQVariant ModesModel::headerData(int section, Qt::Orientation orientation, int role) const\n{\n\tif (orientation != Qt::Horizontal || role != Qt::DisplayRole)\n    {\n        return QVariant();\n    }\n\n    if (section == ModeColumns::NAME)\n    {\n        return tr(\"Name\");\n    }\n    else if (section == ModeColumns::DISPLAY_NAME)\n    {\n        return tr(\"Display\\nname\");\n    }\n    else if (section == ModeColumns::SHORT_DESCRIPTION)\n    {\n        return tr(\"Short\\ndescription\");\n    }\n    else if (section == ModeColumns::DESCRIPTION)\n    {\n        return tr(\"Description\");\n    }\n    else\n    {\n        return QVariant();\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: ModesModel::data()\n//-----------------------------------------------------------------------------\nQVariant ModesModel::data(QModelIndex const& index, int role) const\n{\n    if (!index.isValid() || index.row() < 0 || index.row() >= modes_->size())\n    {\n        return QVariant();\n    }\n\n    QSharedPointer<Mode> mode = modes_->at(index.row());\n    const int column = index.column(); \n\n    if (role == Qt::DisplayRole || role == Qt::EditRole)\n    {\n        if (column == ModeColumns::NAME)\n        {\n            return mode->name();\n        }\n        else if (column == ModeColumns::DISPLAY_NAME)\n        {\n            return mode->displayName();\n        }\n        else if (column == ModeColumns::SHORT_DESCRIPTION)\n        {\n            return mode->shortDescription();\n        }\n        else if (column == ModeColumns::DESCRIPTION)\n        {\n            return mode->description();\n        }\n    }\n    else if (role == Qt::BackgroundRole)\n    {\n        if (column == ModeColumns::NAME)\n        {\n            return KactusColors::MANDATORY_FIELD;\n        }\n    }\n\n    // if unsupported role\n    return QVariant();\n}\n\n//-----------------------------------------------------------------------------\n// Function: ModesModel::setData()\n//-----------------------------------------------------------------------------\nbool ModesModel::setData(QModelIndex const& index, QVariant const& value, int role)\n{\n\tif (!index.isValid() || index.row() < 0 || index.row() >= modes_->size() || role != Qt::EditRole)\n    {\n        return false;\n    }\n\n    QSharedPointer<Mode> Mode = modes_->at(index.row());\n    const int column = index.column();\n\n    if (column == ModeColumns::NAME)\n    {\n        Mode->setName(value.toString());\n    }\n    else if (column == ModeColumns::DISPLAY_NAME)\n    {\n        Mode->setDisplayName(value.toString());\n    }\n    else if (column == ModeColumns::SHORT_DESCRIPTION)\n    {\n        Mode->setShortDescription(value.toString());\n    }\n    else if (column == ModeColumns::DESCRIPTION)\n    {\n        modes_->at(index.row())->setDescription(value.toString());\n    }\n    else\n    {\n        return false;\n    }\n\n    emit dataChanged(index, index);\n    emit contentChanged();\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: ModesModel::onAddItem()\n//-----------------------------------------------------------------------------\nvoid ModesModel::onAddItem(QModelIndex const& index)\n{\n\tint row = modes_->size();\n\n\t// if the index is valid then add the item to the correct position\n\tif (index.isValid())\n    {\n\t\trow = index.row();\n\t}\n\n\tbeginInsertRows(QModelIndex(), row, row);\n\tmodes_->insert(row, QSharedPointer<Mode>(new Mode()));\n\tendInsertRows();\n\n\t// inform navigation tree that file set is added\n\temit modeAdded(row);\n\n\t// tell also parent widget that contents have been changed\n\temit contentChanged();\n}\n\n//-----------------------------------------------------------------------------\n// Function: ModesModel::onRemoveItem()\n//-----------------------------------------------------------------------------\nvoid ModesModel::onRemoveItem(QModelIndex const& index)\n{\n\t// don't remove anything if index is invalid\n\tif (!index.isValid() || index.row() < 0 || index.row() >= modes_->size())\n    {\n\t\treturn;\n\t}\n\n\t// remove the specified item\n\tbeginRemoveRows(QModelIndex(), index.row(), index.row());\n\tmodes_->removeAt(index.row());\n\tendRemoveRows();\n\n\t// inform navigation tree that file set has been removed\n\temit modeRemoved(index.row());\n\n\t// tell also parent widget that contents have been changed\n\temit contentChanged();\n}\n"
  },
  {
    "path": "editors/ComponentEditor/modes/ModesModel.h",
    "content": "//-----------------------------------------------------------------------------\n// File: Modesmodel.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Esko Pekkarinen\n// Date: 08.08.2023\n//\n// Description:\n// Model for Mode elements within a component.\n//-----------------------------------------------------------------------------\n\n#ifndef MODESMODEL_H\n#define MODESMODEL_H\n\n\n#include <editors/common/ExpressionSet.h>\n\n#include <KactusAPI/include/ExpressionFormatter.h>\n\n#include <QAbstractTableModel>\n#include <QSharedPointer>\n#include <QList>\n\nclass Component;\nclass Mode;\nclass ModeValidator;\n\n//-----------------------------------------------------------------------------\n//! Model for Mode elements within a component.\n//-----------------------------------------------------------------------------\nclass ModesModel : public QAbstractTableModel\n{\n\tQ_OBJECT\n\npublic:\n\n\t/*! The constructor\n\t *\n     *    @param [in] component   The component being edited.\n\t *    @param [in] parent      The owner of this model.\n\t*/\n\tModesModel(QSharedPointer<Component> component, \n        QObject* parent);\n\t\n\t//! The destructor\n\tvirtual ~ModesModel() = default;\n\n    //! No copying\n    ModesModel(const ModesModel& other) = delete;\n    ModesModel& operator=(const ModesModel& other) = delete;\n\n\t/*! Get the number of rows an item contains.\n\t *\n\t *    @param [in] parent Identifies the parent that's row count is requested.\n\t *\n\t *    @return Number of rows the item has.\n\t*/\n\tint rowCount(const QModelIndex& parent = QModelIndex()) const final;\n\n\t/*! Get the number of columns the item has to be displayed.\n\t *\n\t *    @param [in] parent Identifies the parent that's column count is requested.\n\t *\n\t *    @return The number of columns to be displayed.\n\t*/\n\tint columnCount(const QModelIndex& parent = QModelIndex()) const final;\n\n\t/*! Get the item flags that defines the possible operations for the item.\n\t *\n\t *    @param [in] index Model index that identifies the item.\n\t *\n\t *    @return Qt::ItemFlags specify the possible operations for the item.\n\t*/\n\tQt::ItemFlags flags(const QModelIndex& index) const final;\n\n\t/*! Get the header data for specified header.\n\t *\n\t *    @param [in] section The section specifies the row/column number for the header.\n\t *    @param [in] orientation Specified if horizontal or vertical header is wanted.\n\t *    @param [in] role Specifies the type of the requested data.\n\t *\n\t *    @return QVariant Contains the requested data.\n\t*/\n\tQVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const final;\n\n\t/*! Get the data for specified item.\n\t *\n\t *    @param [in] index Specifies the item that's data is requested.\n\t *    @param [in] role The role that defines what kind of data is requested.\n\t *\n\t *    @return QVariant Contains the data for the item.\n\t*/\n\tQVariant data(QModelIndex const& index, int role = Qt::DisplayRole) const final;\n\n\t/*! Save the data to the model for specified item\n\t *\n\t *    @param [in] index The model index of the item that's data is to be saved.\n\t *    @param [in] value The data that is to be saved.\n\t *    @param [in] role The role specifies what kind of data should be saved.\n\t *\n\t *    @return True if saving was successful.\n\t*/\n\tbool setData(QModelIndex const& index, QVariant const& value, int role = Qt::EditRole) final;\n\n\npublic slots:\n\n\t/*! Add a new item to the given index.\n\t *\n\t *    @param [in] index The index identifying the position for new item.\n\t*/\n\tvirtual void onAddItem(const QModelIndex& index);\n\n\t/*! Remove the item in the given index.\n\t *\n\t *    @param [in] index The index identifying the item to remove.\n\t*/\n\tvirtual void onRemoveItem(const QModelIndex& index);\n\nsignals:\n\n\t//! Emitted when the contents of the model change.\n\tvoid contentChanged();\n\n\t/*! Emitted when a new Mode is added to the model.\n\t *\n\t *    @param [in] index The index of the added Mode.\n\t*/\n\tvoid modeAdded(int index);\n\n\t/*! Emitted when a Mode is removed from the model.\n\t *\n\t *    @param [in] index The index of the removed Mode.\n\t*/\n\tvoid modeRemoved(int index);\n\nprivate:\n\n\t//! Gets the value of the cell in index.\n    QVariant valueForIndex(QModelIndex const& index) const;\n\n\t//! The component being edited.\n\tQSharedPointer<Component> component_;\n\n\t//! Contains the Modes being edited.\n\tQSharedPointer<QList<QSharedPointer<Mode> > > modes_;\n\n\t//! Formatter to use for expressions.\n\tQSharedPointer<ExpressionFormatter> expressionFormatter_;\n};\n\n#endif // ModeSMODEL_H\n"
  },
  {
    "path": "editors/ComponentEditor/modes/PortSliceColumns.h",
    "content": "//-----------------------------------------------------------------------------\n// File: PortSliceColumns.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Esko Pekkarinen\n// Date: 09.08.2023\n//\n// Description:\n// Common declarations for editing PortSlices in mode.\n//-----------------------------------------------------------------------------\n\nnamespace PortSliceColumns\n{\n    //! Contains the columns for PortSlice properties.\n    enum Column\n    {\n        NAME = 0,\n        PORT_REF,\n        SUB_PORT,\n        LEFT_BOUND,\n        RIGHT_BOUND,\n        DESCRIPTION,\n        COLUMN_COUNT\n    };\n\n}\n"
  },
  {
    "path": "editors/ComponentEditor/modes/PortSliceDelegate.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: PortSliceDelegate.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Esko Pekkarinen\n// Date: 14.08.2023\n//\n// Description:\n// Delegate that provides widgets for editing port slices in mode.\n//-----------------------------------------------------------------------------\n\n#include \"PortSliceDelegate.h\"\n\n#include \"PortSliceColumns.h\"\n\n#include <KactusAPI/include/ParameterFinder.h>\n#include <KactusAPI/include/IPXactSystemVerilogParser.h>\n\n#include <editors/ComponentEditor/common/ReferenceSelector/ReferenceSelector.h>\n\n#include <IPXACTmodels/common/Choice.h>\n\n#include <QCompleter>\n#include <QScrollArea>\n\n\n//-----------------------------------------------------------------------------\n// Function: PortSliceDelegate::PortSliceDelegate()\n//-----------------------------------------------------------------------------\nPortSliceDelegate::PortSliceDelegate(QStringList const& portNameList, QAbstractItemModel* completionModel,\n                        ExpressionSet expressions, QObject* parent):\nExpressionDelegate(completionModel, expressions.finder, parent),\nexpressionFormatter_(expressions.formatter),\nexpressionParser_(expressions.parser),\navailablePortNames_(portNameList)\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortSliceDelegate::createEditor()\n//-----------------------------------------------------------------------------\nQWidget* PortSliceDelegate::createEditor(QWidget* parent, QStyleOptionViewItem const& option,\n    QModelIndex const& index) const\n{\n    if (index.column() == PortSliceColumns::PORT_REF)\n    {\n        ReferenceSelector* referenceSelector = new ReferenceSelector(parent);\n\n        QStringList visiblePortNames = availablePortNames_;\n        QString selectedName = index.model()->data(index, Qt::DisplayRole).toString();\n        if (componentPortNames_.contains(selectedName))\n        {\n            visiblePortNames.append(selectedName);\n        }\n\n        referenceSelector->refresh(visiblePortNames);\n\n        return referenceSelector;\n    }\n    else\n    {\n        return ExpressionDelegate::createEditor(parent, option, index);\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortSliceDelegate::setEditorData()\n//-----------------------------------------------------------------------------\nvoid PortSliceDelegate::setEditorData(QWidget* editor, QModelIndex const& index) const\n{\n    if (index.column() == PortSliceColumns::PORT_REF)\n    {\n        QString text = index.model()->data(index, Qt::DisplayRole).toString();\n        ReferenceSelector* referenceSelector = qobject_cast<ReferenceSelector*>(editor);\n\n        referenceSelector->selectItem(text);\n    }\n    else\n    {\n        ExpressionDelegate::setEditorData(editor, index);\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortSliceDelegate::setModelData()\n//-----------------------------------------------------------------------------\nvoid PortSliceDelegate::setModelData(QWidget* editor, QAbstractItemModel* model, QModelIndex const& index)\n    const\n{\n    if (index.column() == PortSliceColumns::PORT_REF)\n    {\n        auto referenceSelector = qobject_cast<ReferenceSelector*>(editor);\n        QString text = referenceSelector->currentText();\n        model->setData(index, text, Qt::EditRole);\n    }\n    else\n    {\n        ExpressionDelegate::setModelData(editor, model, index);\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortSliceDelegate::columnAcceptsExpression()\n//-----------------------------------------------------------------------------\nbool PortSliceDelegate::columnAcceptsExpression(int column) const\n{\n    return column == PortSliceColumns::LEFT_BOUND || column == PortSliceColumns::RIGHT_BOUND;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortSliceDelegate::descriptionColumn()\n//-----------------------------------------------------------------------------\nint PortSliceDelegate::descriptionColumn() const\n{\n    return PortSliceColumns::DESCRIPTION;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortSliceDelegate::setNewPortNames()\n//-----------------------------------------------------------------------------\nvoid PortSliceDelegate::setNewPortNames(QStringList const& newPorts)\n{\n    availablePortNames_ = newPorts;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortSliceDelegate::setComponentPorts()\n//-----------------------------------------------------------------------------\nvoid PortSliceDelegate::setComponentPorts(QStringList const& componentPorts)\n{\n    componentPortNames_ = componentPorts;\n}\n"
  },
  {
    "path": "editors/ComponentEditor/modes/PortSliceDelegate.h",
    "content": "//-----------------------------------------------------------------------------\n// File: PortSliceDelegate.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Esko Pekkarinen\n// Date: 14.08.2023\n//\n// Description:\n// Delegate that provides widgets for editing port slices in mode.\n//-----------------------------------------------------------------------------\n\n#ifndef PORTSLICE_DELEGATE_H\n#define PORTSLICE_DELEGATE_H\n\n#include <editors/ComponentEditor/common/ExpressionDelegate.h>\n#include <KactusAPI/include/ExpressionFormatter.h>\n\n#include <editors/common/ExpressionSet.h>\n\n#include <QCompleter>\n\nclass ExpressionParser;\n\n//-----------------------------------------------------------------------------\n//! Delegate that provides widgets for editing remap condition.\n//-----------------------------------------------------------------------------\nclass PortSliceDelegate : public ExpressionDelegate\n{\n\tQ_OBJECT\n\npublic:\n\n    /*!\n     *  The constructor.\n     *\n     *    @param [in] portNameList            The list of available port names.\n     *    @param [in] completionModel         Model containing the completions used in expression editor.\n     *    @param [in] expressions             The collection of objects for expression handling.\n     *    @param [in] parent                  The parent of the object.\n     */\n    PortSliceDelegate(QStringList const& portNameList,\n        QAbstractItemModel* completionModel,\n        ExpressionSet expressions,\n        QObject* parent = 0);\n\n\t//! The destructor\n    virtual ~PortSliceDelegate() = default;\n\n    //! No copying\n    PortSliceDelegate(const PortSliceDelegate& other) = delete;\n\n    //! No assignment\n    PortSliceDelegate& operator=(const PortSliceDelegate& other) = delete;\n\n\t/*! Create a new editor for the given item\n\t *\n\t *    @param [in] parent   Owner for the editor.\n\t *    @param [in] option   Contains options for the editor.\n\t *    @param [in] index    Model index identifying the item.\n\t *\n\t *    @return Pointer to the editor to be used to edit the item.\n\t*/\n\tvirtual QWidget* createEditor(QWidget* parent, QStyleOptionViewItem const& option, \n        QModelIndex const& index) const final;\n\n\t/*! Set the data for the editor.\n\t *\n\t *    @param [in] editor  Pointer to the editor where the data is to be set.\n\t *    @param [in] index   Model index identifying the item that's data is to be set.\n\t*/\n\tvirtual void setEditorData(QWidget* editor, QModelIndex const& index) const final;\n\n\t/*! Save the data from the editor to the model.\n\t *\n\t *    @param [in] editor   Pointer to the editor that contains the data to store.\n\t *    @param [in] model    Model that contains the data structure where data is to be saved to.\n\t *    @param [in] index    Model index identifying the item that's data is to be saved.\n\t *\n\t*/\n\tvirtual void setModelData(QWidget* editor, QAbstractItemModel* model, QModelIndex const& index) const final;\n\n\n    /*!\n     *  Set the component ports.\n     *\n     *    @param [in] componentPorts  All the ports of the component.\n     */\n    void setComponentPorts(QStringList const& componentPorts);\n\npublic slots:\n    \n    /*!\n     *  Set the currently available port names.\n     *\n     *    @param [in] newPorts    The currently available port names.\n     */\n    void setNewPortNames(QStringList const& newPorts);\n\nsignals:\n\n    //! Emitted when the values of the array change.\n    void contentChanged();\n\nprotected:\n\n    /*!\n     *  Checks if the cells in given column accept expression as an input value.\n     *\n     *    @param [in] column   The column to check.\n     *\n     *    @return True, if the cells accept expressions, otherwise false.\n     */\n    virtual bool columnAcceptsExpression(int column) const;\n\n    //! Gets the description column.\n    virtual int descriptionColumn() const;\n\nprivate:\n\n    //-----------------------------------------------------------------------------\n    // Data.\n    //-----------------------------------------------------------------------------\n\n    //! The expression formatter used to change parameter uuids in references to parameter names.\n    QSharedPointer<ExpressionFormatter> expressionFormatter_;\n\n    //! The expression parser.\n    QSharedPointer<ExpressionParser> expressionParser_;\n\n    //! The list of ports usable as remap ports.\n    QStringList availablePortNames_;\n\n    //! The list of port names within the component.\n    QStringList componentPortNames_;\n};\n\n#endif // PORTSLICE_DELEGATE_H\n"
  },
  {
    "path": "editors/ComponentEditor/modes/PortSliceEditor.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: PortSliceEditor.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Esko Pekkarinen\n// Date: 09.08.2023\n//\n// Description:\n// Editor to add/remove/edit the mode-elements of a component.\n//-----------------------------------------------------------------------------\n\n#include \"PortSliceEditor.h\"\n#include \"PortSliceColumns.h\"\n\n#include <common/widgets/summaryLabel/summarylabel.h>\n#include <KactusAPI/include/LibraryInterface.h>\n\n#include <editors/ComponentEditor/parameters/ComponentParameterModel.h>\n\n#include <editors/common/ExpressionSet.h>\n\n#include <IPXACTmodels/Component/Component.h>\n\n#include \"PortSliceDelegate.h\"\n\n#include <QCompleter>\n#include <QVBoxLayout>\n#include <QHeaderView>\n\n//-----------------------------------------------------------------------------\n// Function: PortSliceEditor::PortSliceEditor()\n//-----------------------------------------------------------------------------\nPortSliceEditor::PortSliceEditor(QSharedPointer<Component> component, \n\tQSharedPointer<Mode> mode, \n\tQSharedPointer<PortSliceValidator> validator,\n\tLibraryInterface* handler, \n    ExpressionSet expressions,\n\tQWidget* parent) :\nQWidget(parent),\n\tcomponent_(component),\n    view_(this),\n    proxy_(this),\n    model_(mode, validator, expressions, this)\n{\n\n\tQVBoxLayout* layout = new QVBoxLayout(this);\n\tlayout->addWidget(&view_);\n\tlayout->setContentsMargins(0, 0, 0, 0);\n\n\tproxy_.setSourceModel(&model_);\n\tview_.setModel(&proxy_);\n\n\tconst QString compPath = handler->getDirectoryPath(component->getVlnv());\n\tQString defPath = QString(\"%1/PortSliceListing.csv\").arg(compPath);\n\tview_.setDefaultImportExportPath(defPath);\n\tview_.setAllowImportExport(true);\n\tview_.setItemsDraggable(false);\n    view_.setSortingEnabled(true);\n    view_.hideColumn(PortSliceColumns::SUB_PORT);\n\n    ComponentParameterModel* parameterModel = new ComponentParameterModel(expressions.finder, this);\n    parameterModel->setExpressionParser(expressions.parser);\n\n\tdelegate_ = new PortSliceDelegate(component->getPortNames(), parameterModel, expressions, this);\n\n\tview_.setItemDelegate(delegate_);\n\n\tconnect(&model_, SIGNAL(contentChanged()), this, SIGNAL(contentChanged()), Qt::UniqueConnection);\n\n\tconnect(&view_, SIGNAL(addItem(const QModelIndex&)),\n        &model_, SLOT(onAddItem(const QModelIndex&)), Qt::UniqueConnection);\n\tconnect(&view_, SIGNAL(removeItem(const QModelIndex&)),\n\t\t&model_, SLOT(onRemoveItem(const QModelIndex&)), Qt::UniqueConnection);\n\n    connect(delegate_, SIGNAL(increaseReferences(QString const&)),\n        this, SIGNAL(increaseReferences(QString const&)), Qt::UniqueConnection);\n    connect(delegate_, SIGNAL(decreaseReferences(QString const&)),\n        this, SIGNAL(decreaseReferences(QString const&)), Qt::UniqueConnection);\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortSliceEditor::refresh()\n//-----------------------------------------------------------------------------\nvoid PortSliceEditor::refresh()\n{\n\tdelegate_->setNewPortNames(component_->getPortNames());\n\n\tview_.update();\n}\n"
  },
  {
    "path": "editors/ComponentEditor/modes/PortSliceEditor.h",
    "content": "//-----------------------------------------------------------------------------\n// File: PortSliceEditor.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Esko Pekkarinen\n// Date: 08.08.2023\n//\n// Description:\n// Editor to add/remove/edit the mode-elements of a component.\n//-----------------------------------------------------------------------------\n\n#ifndef PORTSLICE_EDITOR_H\n#define PORTSLICE_EDITOR_H\n\n#include <common/views/EditableTableView/editabletableview.h>\n\n#include <editors/ComponentEditor/itemeditor.h>\n\n#include \"PortSliceModel.h\"\n#include \"PortSliceDelegate.h\"\n\n#include <QSortFilterProxyModel>\n#include <QSharedPointer>\n\nclass Component;\nclass ModeValidator;\nclass LibraryInterface;\n\n//-----------------------------------------------------------------------------\n//! Editor to add/remove/edit the Mode-elements of a component.\n//-----------------------------------------------------------------------------\nclass PortSliceEditor : public QWidget\n{\n\tQ_OBJECT\n\npublic:\n\n\t/*! The constructor\n\t *\n\t *    @param [in] component   The component being edited.\n\t *    @param [in] handler     The instance managing the library.\n     *    @param [in] validator   The validator for PortSlice.\n     *    @param [in] expressions\tThe collection of objects for expression handling.\n\t *    @param [in] parent      The parent of this editor.\n\t*/\n\tPortSliceEditor(QSharedPointer<Component> component, \n        QSharedPointer<Mode> mode,\n        QSharedPointer<PortSliceValidator> validator,\n\t\tLibraryInterface* handler,\n\t\tExpressionSet expressions,\n\t\tQWidget* parent = 0);\n\t\n\t//! The destructor\n\tvirtual ~PortSliceEditor() = default;\n\n    //! No copying\n    PortSliceEditor(const PortSliceEditor& other) = delete;\n    PortSliceEditor& operator=(const PortSliceEditor& other) = delete;\n\n\t//! Reload the information from the model to the editor.\t\n\tvoid refresh();\n\nsignals:\n\n\t/*!\n\t *  Emitted when the contents of the model change.\n\t */\n\tvoid contentChanged();\n\n\t/*!\n\t *  Increase the amount of references to a parameter with a matching id.\n\t *\n\t *    @param [in] id      Id of the parameter, whose references are being increased.\n\t */\n\tvoid increaseReferences(QString const& id);\n\n\t/*!\n\t *  Decrease the amount of references to a parameter with a matching id.\n\t *\n\t *    @param [in] id      Id of the parameter, whose references are being increased.\n\t */\n\tvoid decreaseReferences(QString const& id);\n\nprivate:\n\n\t//! The component containing the modes.\n\tQSharedPointer<Component> component_;\n\n\t//! The view to display the PortSlice\n\tEditableTableView view_;\n\n\t//! The delegate for the view.\n\tPortSliceDelegate* delegate_ = nullptr;\n\n\t//! The model that does the sorting.\n\tQSortFilterProxyModel proxy_;\n\n\t//! The model that manages the PortSlice of the editor.\n\tPortSliceModel model_;\n};\n\n#endif // PORTSLICE_EDITOR_H\n"
  },
  {
    "path": "editors/ComponentEditor/modes/PortSliceModel.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: PortSliceModel.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Esko Pekkarinen\n// Date: 09.08.2023\n//\n// Description:\n// Model for Mode elements within a component.\n//-----------------------------------------------------------------------------\n\n#include \"PortSliceModel.h\"\n\n#include \"PortSliceColumns.h\"\n\n#include <IPXACTmodels/Component/Component.h>\n#include <IPXACTmodels/Component/Mode.h>\n\n#include <QStringList>\n#include <QRegularExpression>\n\n#include <common/KactusColors.h>\n\n//-----------------------------------------------------------------------------\n// Function: PortSliceModel::PortSliceModel()\n//-----------------------------------------------------------------------------\nPortSliceModel::PortSliceModel(QSharedPointer <Mode> mode,\n    QSharedPointer<PortSliceValidator> validator,\n    ExpressionSet expressions,\n    QObject* parent): \n    ReferencingTableModel(expressions.finder, parent),\n    ParameterizableTable(expressions.finder),\n    validator_(validator),\n    portSlices_(mode->getPortSlices()),\n    expressionFormatter_(expressions.formatter)\n{\n    \n    setExpressionParser(expressions.parser);\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortSliceModel::rowCount()\n//-----------------------------------------------------------------------------\nint PortSliceModel::rowCount(QModelIndex const& parent) const\n{\n\tif (parent.isValid())\n    {\n\t\treturn 0;\n\t}\n\n\treturn portSlices_->count();\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortSliceModel::columnCount()\n//-----------------------------------------------------------------------------\nint PortSliceModel::columnCount(QModelIndex const& parent) const\n{\n\tif (parent.isValid())\n    {\n\t\treturn 0;\n\t}\n\n\treturn PortSliceColumns::COLUMN_COUNT;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortSliceModel::flags()\n//-----------------------------------------------------------------------------\nQt::ItemFlags PortSliceModel::flags(QModelIndex const& index) const\n{\n\tif (!index.isValid())\n    {\n\t\treturn Qt::NoItemFlags;\n\t}\n\n\treturn Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsEditable;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortSliceModel::headerData()\n//-----------------------------------------------------------------------------\nQVariant PortSliceModel::headerData(int section, Qt::Orientation orientation, int role) const\n{\n\tif (orientation != Qt::Horizontal || role != Qt::DisplayRole)\n    {\n        return QVariant();\n    }\n\n    if (section == PortSliceColumns::NAME)\n    {\n        return tr(\"Name\");\n    }\n    else if (section == PortSliceColumns::PORT_REF)\n    {\n        return tr(\"Physical port\");\n    }\n    else if (section == PortSliceColumns::SUB_PORT)\n    {\n        return tr(\"Sub-port\");\n    }\n    else if (section == PortSliceColumns::LEFT_BOUND)\n    {\n        return tr(\"Left bound\") + getExpressionSymbol();\n    }\n    else if (section == PortSliceColumns::RIGHT_BOUND)\n    {\n        return tr(\"Right bound\") + getExpressionSymbol();\n    }\n    else if (section == PortSliceColumns::DESCRIPTION)\n    {\n        return tr(\"Description\");\n    }\n    else\n    {\n        return QVariant();\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortSliceModel::data()\n//-----------------------------------------------------------------------------\nQVariant PortSliceModel::data(QModelIndex const& index, int role) const\n{\n    if (!index.isValid() || index.row() < 0 || index.row() >= portSlices_->size())\n    {\n        return QVariant();\n    }\n\n    QSharedPointer<PortSlice> slice = portSlices_->at(index.row());\n    const int column = index.column(); \n\n    if (role == Qt::DisplayRole)\n    {\n        if (isValidExpressionColumn(index))\n        {\n            return expressionFormatter_->formatReferringExpression(valueForIndex(index).toString());\n        }\n        else\n        {\n            return valueForIndex(index).toString();\n        }\n    }\n\n    else if (role == Qt::EditRole)\n    {\n        return expressionOrValueForIndex(index);\n    }\n\n    else if (role == Qt::ToolTipRole)\n    {\n        if (isValidExpressionColumn(index))\n        {\n            return formattedValueFor(valueForIndex(index).toString());\n        }\n        else\n        {\n            return expressionOrValueForIndex(index);\n        }\n    }\n\n    else if (role == Qt::ForegroundRole)\n    {\n            return blackForValidOrRedForInvalidIndex(index);\n    }\n\n    else if (role == Qt::BackgroundRole)\n    {\n        if (column == PortSliceColumns::NAME ||\n            column == PortSliceColumns::PORT_REF)\n        {\n            return KactusColors::MANDATORY_FIELD;\n        }\n    }\n\n\n    return QVariant();\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortSliceModel::setData()\n//-----------------------------------------------------------------------------\nbool PortSliceModel::setData(QModelIndex const& index, QVariant const& value, int role)\n{\n\tif (!index.isValid() || index.row() < 0 || index.row() >= portSlices_->size() || role != Qt::EditRole)\n    {\n        return false;\n    }\n\n    QSharedPointer<PortSlice> slice = portSlices_->at(index.row());\n    const int column = index.column();\n\n    if (column == PortSliceColumns::NAME)\n    {\n        slice->setName(value.toString());\n    }\n    else if (column == PortSliceColumns::PORT_REF)\n    {\n        slice->setPortRef(value.toString());\n    }\n    else if (column == PortSliceColumns::LEFT_BOUND)\n    {\n        slice->setLeftRange(value.toString());\n    }\n    else if (column == PortSliceColumns::RIGHT_BOUND)\n    {\n        slice->setRightRange(value.toString());\n    }\n    else if (column == PortSliceColumns::DESCRIPTION)\n    {\n        portSlices_->at(index.row())->setDescription(value.toString());\n    }\n    else\n    {\n        return false;\n    }\n\n    emit dataChanged(index, index);\n    emit contentChanged();\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortSliceModel::onAddItem()\n//-----------------------------------------------------------------------------\nvoid PortSliceModel::onAddItem(QModelIndex const& index)\n{\n\tint row = portSlices_->size();\n\n\t// if the index is valid then add the item to the correct position\n\tif (index.isValid())\n    {\n\t\trow = index.row();\n\t}\n\n\tbeginInsertRows(QModelIndex(), row, row);\n\tportSlices_->insert(row, QSharedPointer<PortSlice>(new PortSlice()));\n\tendInsertRows();\n\n\n\t// tell also parent widget that contents have been changed\n\temit contentChanged();\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortSliceModel::onRemoveItem()\n//-----------------------------------------------------------------------------\nvoid PortSliceModel::onRemoveItem(QModelIndex const& index)\n{\n\t// don't remove anything if index is invalid\n\tif (!index.isValid() || index.row() < 0 || index.row() >= portSlices_->size())\n    {\n\t\treturn;\n\t}\n\n\t// remove the specified item\n\tbeginRemoveRows(QModelIndex(), index.row(), index.row());\n\tportSlices_->removeAt(index.row());\n\tendRemoveRows();\n\n\t// tell also parent widget that contents have been changed\n\temit contentChanged();\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortSliceModel::getAllReferencesToIdInItemOnRow()\n//-----------------------------------------------------------------------------\nint PortSliceModel::getAllReferencesToIdInItemOnRow(const int& row, QString const& valueID) const\n{\n    int referencesInLeft = portSlices_->at(row)->getLeftRange().count(valueID);\n    int referencesInRight = portSlices_->at(row)->getRightRange().count(valueID);\n\n    return referencesInLeft + referencesInRight;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortSliceModel::isValidExpressionColumn()\n//-----------------------------------------------------------------------------\nbool PortSliceModel::isValidExpressionColumn(QModelIndex const& index) const\n{\n    return index.column() == PortSliceColumns::LEFT_BOUND || index.column() == PortSliceColumns::RIGHT_BOUND;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortSliceModel::expressionOrValueForIndex()\n//-----------------------------------------------------------------------------\nQVariant PortSliceModel::expressionOrValueForIndex(QModelIndex const& index) const\n{\n    return valueForIndex(index);\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortSliceModel::validateIndex()\n//-----------------------------------------------------------------------------\nbool PortSliceModel::validateIndex(QModelIndex const& index) const\n{\n    const int column = index.column();\n    auto portSlice = portSlices_->at(index.row());\n\n    if (column == PortSliceColumns::NAME)\n    {\n        return validator_->hasValidName(portSlice->name());\n    }\n    else if (column == PortSliceColumns::PORT_REF)\n    {\n        return validator_->hasValidPortReference(portSlice);\n    }\n    else if (column == PortSliceColumns::LEFT_BOUND)\n    {\n        return validator_->hasValidLeftRange(portSlice);\n    }\n    else if (column == PortSliceColumns::RIGHT_BOUND)\n    {\n        return validator_->hasValidRightRange(portSlice);\n    }\n\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortSliceModel::valueForIndex()\n//-----------------------------------------------------------------------------\nQVariant PortSliceModel::valueForIndex(QModelIndex const& index) const\n{\n    const int column = index.column();\n\n    QSharedPointer<PortSlice> slice = portSlices_->at(index.row());\n\n    if (column == PortSliceColumns::NAME)\n    {\n        return slice->name();\n    }\n    else if (column == PortSliceColumns::PORT_REF)\n    {\n        return slice->getPortRef();\n    }\n    else if (column == PortSliceColumns::LEFT_BOUND)\n    {\n        return slice->getLeftRange();\n    }\n    else if (column == PortSliceColumns::RIGHT_BOUND)\n    {\n        return slice->getRightRange();\n    }\n    else if (column == PortSliceColumns::DESCRIPTION)\n    {\n        return slice->description();\n    }\n\n    return QVariant();\n}\n"
  },
  {
    "path": "editors/ComponentEditor/modes/PortSliceModel.h",
    "content": "//-----------------------------------------------------------------------------\n// File: PortSliceModel.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Esko Pekkarinen\n// Date: 09.08.2023\n//\n// Description:\n// Model for Mode elements within a component.\n//-----------------------------------------------------------------------------\n\n#ifndef PORTSLICEMODEL_H\n#define PORTSLICEMODEL_H\n\n#include <editors/common/ExpressionSet.h>\n\n#include <editors/ComponentEditor/common/ReferencingTableModel.h>\n#include <editors/ComponentEditor/common/ParameterizableTable.h>\n\n#include <IPXACTmodels/Component/PortSlice.h>\n#include <IPXACTmodels/Component/validators/PortSliceValidator.h>\n\n#include <KactusAPI/include/ExpressionFormatter.h>\n\n#include <QAbstractTableModel>\n#include <QSharedPointer>\n#include <QList>\n\nclass Component;\nclass Mode;\nclass ModeValidator;\n\n//-----------------------------------------------------------------------------\n//! Model for Mode elements within a component.\n//-----------------------------------------------------------------------------\nclass PortSliceModel : public ReferencingTableModel, public ParameterizableTable\n{\n\tQ_OBJECT\n\npublic:\n\n\t/*! The constructor\n\t *\n\t *\t\t@param [in] mode        The mode being edited.\n\t *\t\t@param [in] validator   The validator for the port slices in the mode.\n     *    @param [in] expressions The collection of objects for expression handling.\n\t *    @param [in] parent      The owner of this model.\n\t*/\n\tPortSliceModel(QSharedPointer<Mode> mode, \n\t\tQSharedPointer<PortSliceValidator> validator,\n\t\tExpressionSet expressions,\n        QObject* parent);\n\t\n\t//! The destructor\n\tvirtual ~PortSliceModel() = default;\n\n    //! No copying\n    PortSliceModel(const PortSliceModel& other) = delete;\n    PortSliceModel& operator=(const PortSliceModel& other) = delete;\n\n\t/*! Get the number of rows an item contains.\n\t *\n\t *    @param [in] parent Identifies the parent that's row count is requested.\n\t *\n\t *    @return Number of rows the item has.\n\t*/\n\tint rowCount(const QModelIndex& parent = QModelIndex()) const final;\n\n\t/*! Get the number of columns the item has to be displayed.\n\t *\n\t *    @param [in] parent Identifies the parent that's column count is requested.\n\t *\n\t *    @return The number of columns to be displayed.\n\t*/\n\tint columnCount(const QModelIndex& parent = QModelIndex()) const final;\n\n\t/*! Get the item flags that defines the possible operations for the item.\n\t *\n\t *    @param [in] index Model index that identifies the item.\n\t *\n\t *    @return Qt::ItemFlags specify the possible operations for the item.\n\t*/\n\tQt::ItemFlags flags(const QModelIndex& index) const final;\n\n\t/*! Get the header data for specified header.\n\t *\n\t *    @param [in] section The section specifies the row/column number for the header.\n\t *    @param [in] orientation Specified if horizontal or vertical header is wanted.\n\t *    @param [in] role Specifies the type of the requested data.\n\t *\n\t *    @return QVariant Contains the requested data.\n\t*/\n\tQVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const final;\n\n\t/*! Get the data for specified item.\n\t *\n\t *    @param [in] index Specifies the item that's data is requested.\n\t *    @param [in] role The role that defines what kind of data is requested.\n\t *\n\t *    @return QVariant Contains the data for the item.\n\t*/\n\tQVariant data(QModelIndex const& index, int role = Qt::DisplayRole) const final;\n\n\t/*! Save the data to the model for specified item\n\t *\n\t *    @param [in] index The model index of the item that's data is to be saved.\n\t *    @param [in] value The data that is to be saved.\n\t *    @param [in] role The role specifies what kind of data should be saved.\n\t *\n\t *    @return True if saving was successful.\n\t*/\n\tbool setData(QModelIndex const& index, QVariant const& value, int role = Qt::EditRole) final;\n\n\npublic slots:\n\n\t/*! Add a new item to the given index.\n\t *\n\t *    @param [in] index The index identifying the position for new item.\n\t*/\n\tvirtual void onAddItem(const QModelIndex& index);\n\n\t/*! Remove the item in the given index.\n\t *\n\t *    @param [in] index The index identifying the item to remove.\n\t*/\n\tvirtual void onRemoveItem(const QModelIndex& index);\n\nsignals:\n\n\t//! Emitted when the contents of the model change.\n\tvoid contentChanged();\n\nprotected:\n\t    \n\t/*!\n     *  Gets the number of all the references made to a selected id on the selected row.\n     *\n     *    @param [in] row         The row of the selected item.\n     *    @param [in] valueID     The id of the referenced parameter.\n     *\n     *    @return The amount of references made to the selected id on the selected row.\n     */\n    virtual int getAllReferencesToIdInItemOnRow(const int& row, QString const& valueID) const final;\n\n\t/*!\n\t *  Check if the column index is valid for containing expressions.\n\t *\n\t *    @param [in] index   The index being evaluated.\n\t *\n\t *    @return True, if the column can accept expressions, false otherwise.\n\t */\n\tvirtual bool isValidExpressionColumn(QModelIndex const& index) const final;\n\n\t/*!\n     *  Gets the expression for the index, or the plain value, if an expression is not available.\n     *\n     *    @param [in] index   The index of the item.\n     *\n     *    @return The expression for the index if available, otherwise the value for the given index.\n     */\n\tvirtual QVariant expressionOrValueForIndex(QModelIndex const& index) const final;\n\n\t/*!\n\t *  Validates the data for the column.\n\t *\n\t *    @param [in] index   The column of the item to validate.\n\t *\n\t *    @return True, if the data of the item is valid for the column, false otherwise.\n\t */\n\tvirtual bool validateIndex(QModelIndex const& index) const final;\n\nprivate:\n\n\t//! Gets the value of the cell in index.\n    QVariant valueForIndex(QModelIndex const& index) const;\n\t\n\t//! The validator for the port slices.\n\tQSharedPointer<PortSliceValidator> validator_;\n\n\t//! Contains the PortSlice being edited.\n\tQSharedPointer<QList<QSharedPointer<PortSlice> > > portSlices_;\n\n\t//! Formatter to use for expressions.\n\tQSharedPointer<ExpressionFormatter> expressionFormatter_;\n};\n\n#endif // PORTSLICEMODEL_H\n"
  },
  {
    "path": "editors/ComponentEditor/modes/SingleModeEditor.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: SingleModeEditor.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Esko Pekkarinen\n// Date: 08.08.2023\n//\n// Description:\n// Editor to edit a single mode in a component.\n//-----------------------------------------------------------------------------\n\n#include \"SingleModeEditor.h\"\n\n#include <IPXACTmodels/Component/Component.h>\n#include <IPXACTmodels/Component/Mode.h>\n\n#include <KactusAPI/include/LibraryInterface.h>\n#include <KactusAPI/include/ModeConditionParser.h>\n\n#include <editors/ComponentEditor/memoryMaps/ExpressionProxyModel.h>\n#include <editors/ComponentEditor/parameters/ComponentParameterModel.h>\n\n#include <QCompleter>\n#include <QScrollArea>\n#include <QHBoxLayout>\n#include <QVBoxLayout>\n#include <QLabel>\n\n//-----------------------------------------------------------------------------\n// Function: SingleModeEditor::SingleModeEditor()\n//-----------------------------------------------------------------------------\nSingleModeEditor::SingleModeEditor(QSharedPointer<Component> component,\n    QSharedPointer<Mode> mode,\n    QSharedPointer<ModeValidator> validator,\n    LibraryInterface* libHandler,\n    ExpressionSet expressions,\n    QWidget* parent) :\n    ItemEditor(component, libHandler, parent),\n    mode_(mode),\n    validator_(validator),\n    nameEditor_(mode, component->getRevision(), this, tr(\"Mode name and description\")),\n    conditionEditor_(expressions.finder, this),\n    conditionStatus_(this),\n    portSliceEditor_(component, mode, validator->getPortSliceValidator(), libHandler, expressions, this),\n    fieldSliceEditor_(component, mode, validator->getFieldSliceValidator(), expressions, libHandler, this)\n{\n    auto parameterModel = new ComponentParameterModel(expressions.finder, this);\n    parameterModel->setExpressionParser(expressions.parser);\n\n    auto parameterCompleter = new QCompleter(this);\n    parameterCompleter->setModel(parameterModel);\n\n    conditionEditor_.setAppendingCompleter(parameterCompleter);\n\n    conditionStatus_.setPixmap(QPixmap(QStringLiteral(\":/icons/common/graphics/exclamation.png\")));\n    conditionStatus_.setToolTip(tr(\"Invalid expression\"));\n    \n    connect(&nameEditor_, SIGNAL(contentChanged()), this, SIGNAL(contentChanged()), Qt::UniqueConnection);\n    connect(&portSliceEditor_, SIGNAL(contentChanged()), this, SIGNAL(contentChanged()), Qt::UniqueConnection);\n    connect(&fieldSliceEditor_, SIGNAL(contentChanged()), this, SIGNAL(contentChanged()), Qt::UniqueConnection);\n\n    connect(&conditionEditor_, SIGNAL(editingFinished()), this, SLOT(onConditionChanged()), Qt::UniqueConnection);\n    \n    connect(&conditionEditor_, SIGNAL(increaseReference(QString const&)),\n        this, SIGNAL(increaseReferences(QString const&)), Qt::UniqueConnection);\n    connect(&conditionEditor_, SIGNAL(decreaseReference(QString const&)),\n        this, SIGNAL(decreaseReferences(QString const&)), Qt::UniqueConnection);\n\n    connect(&portSliceEditor_, SIGNAL(increaseReferences(QString const&)),\n        this, SIGNAL(increaseReferences(QString const&)), Qt::UniqueConnection);\n    connect(&portSliceEditor_, SIGNAL(decreaseReferences(QString const&)),\n        this, SIGNAL(decreaseReferences(QString)), Qt::UniqueConnection);\n\n    connect(&fieldSliceEditor_, SIGNAL(increaseReferences(QString const&)),\n        this, SIGNAL(increaseReferences(QString const&)), Qt::UniqueConnection);\n    connect(&fieldSliceEditor_, SIGNAL(decreaseReferences(QString const&)),\n        this, SIGNAL(decreaseReferences(QString)), Qt::UniqueConnection);\n\n    setupLayout();\n}\n\n//-----------------------------------------------------------------------------\n// Function: SingleModeEditor::refresh()\n//-----------------------------------------------------------------------------\nvoid SingleModeEditor::refresh()\n{\n    nameEditor_.refresh();\n\n    conditionEditor_.blockSignals(true);\n    conditionEditor_.setExpression(mode_->getCondition());\n    conditionEditor_.blockSignals(false);\n\n    conditionStatus_.setHidden(validator_->hasValidCondition(mode_));\n\n    portSliceEditor_.refresh();\n    fieldSliceEditor_.refresh();\n}\n\n//-----------------------------------------------------------------------------\n// Function: SingleModeEditor::showEvent()\n//-----------------------------------------------------------------------------\nvoid SingleModeEditor::showEvent(QShowEvent * event)\n{\n    QWidget::showEvent(event);\n\n    emit helpUrlRequested(QStringLiteral(\"componenteditor/mode2022.html\"));\n}\n\n//-----------------------------------------------------------------------------\n// Function: SingleModeEditor::onConditionChanged()\n//-----------------------------------------------------------------------------\nvoid SingleModeEditor::onConditionChanged()\n{\n    conditionEditor_.finishEditingCurrentWord();\n    auto prevCondition = mode_->getCondition();\n    auto newCondition = conditionEditor_.getExpression();\n\n    if (newCondition != prevCondition)\n    {\n        mode_->setCondition(newCondition);\n\n        auto parser = validator_->getConditionParser();\n        auto parserCast = parser.dynamicCast<ModeConditionParser>();\n\n        Q_ASSERT_X(parserCast, \"SingleModeEditor::onConditionChanged()\", \"Could not cast mode condition parser\");\n        if (!parserCast)\n        {\n            return;\n        }\n\n        parserCast->setFieldSlices(mode_->getFieldSlices());\n        parserCast->setPortSlices(mode_->getPortSlices());\n\n        conditionStatus_.setHidden(validator_->hasValidCondition(mode_));\n        emit contentChanged();\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: SingleModeEditor::setupLayout()\n//-----------------------------------------------------------------------------\nvoid SingleModeEditor::setupLayout()\n{\n    auto scrollArea = new QScrollArea(this);\n    scrollArea->setWidgetResizable(true);\n    scrollArea->setFrameShape(QFrame::NoFrame);\n\n    auto scrollLayout = new QHBoxLayout(this);\n    scrollLayout->addWidget(scrollArea);\n    scrollLayout->setContentsMargins(0, 0, 0, 0);\n\n    auto topWidget = new QWidget(scrollArea);\n    topWidget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);\n    scrollArea->setWidget(topWidget);\n\n    auto conditionGroup = new QGroupBox(tr(\"Mode condition\"), this);\n    conditionGroup->setFlat(true);\n\n    auto conditionLayout = new QHBoxLayout(conditionGroup);\n    conditionLayout->addWidget(new QLabel(tr(\"Condition, f(x):\"), this));\n    conditionLayout->addWidget(&conditionEditor_, 1);\n    conditionLayout->addWidget(&conditionStatus_);\n\n    auto portsGroup = new QGroupBox(tr(\"Condition ports\"), this);\n    portsGroup->setFlat(true);\n\n    auto portLayout = new QHBoxLayout(portsGroup);\n    portLayout->addWidget(&portSliceEditor_);\n\n    auto fieldsGroup = new QGroupBox(tr(\"Condition fields\"), this);\n    fieldsGroup->setFlat(true);\n\n    auto fieldLayout = new QHBoxLayout(fieldsGroup);\n    fieldLayout->addWidget(&fieldSliceEditor_);\n\n    auto topLayout = new QGridLayout(topWidget);\n    topLayout->addWidget(&nameEditor_, 0, 0, 1, 1);\n    topLayout->addWidget(conditionGroup, 1, 0, 1, 1);\n    topLayout->addWidget(portsGroup, 2, 0, 1, 1);\n    topLayout->addWidget(fieldsGroup, 3, 0, 1, 1);\n}\n"
  },
  {
    "path": "editors/ComponentEditor/modes/SingleModeEditor.h",
    "content": "//-----------------------------------------------------------------------------\n// File: SingleModeEditor.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Esko Pekkarinen\n// Date: 08.08.2023\n//\n// Description:\n// Editor to edit a single mode in a component.\n//-----------------------------------------------------------------------------\n\n#ifndef SINGLE_MODE_EDITOR_H\n#define SINGLE_MODE_EDITOR_H\n\n#include <editors/ComponentEditor/itemeditor.h>\n\n#include <common/widgets/nameGroupEditor/namegroupeditor.h>\n\n#include <editors/common/ExpressionSet.h>\n#include <editors/ComponentEditor/common/ExpressionLineEditor.h>\n\n#include <IPXACTmodels/Component/validators/ModeValidator.h>\n\n#include \"PortSliceEditor.h\"\n#include \"FieldSliceEditor.h\"\n\n#include <QLabel>\n\nclass Mode;\nclass ExpressionParser;\nclass ParameterFinder;\n\n//-----------------------------------------------------------------------------\n//! Editor to edit a single Mode in a component.\n//-----------------------------------------------------------------------------\nclass SingleModeEditor : public ItemEditor\n{\n\tQ_OBJECT\n\npublic:\n\n\t/*!\n\t *  The constructor.\n\t *\n\t *    @param [in] component               The component that contains the view.\n     *    @param [in] Mode                     The remap state being edited.\n\t *    @param [in] libHandler              The instance that manages the library.\n     *    @param [in] expressions             Changes the referenced ids to parameter names.\n\t *    @param [in] parent                  The owner of this editor.\n\t */\n    SingleModeEditor(QSharedPointer<Component> component,\n        QSharedPointer<Mode> mode,\n        QSharedPointer<ModeValidator> validator,\n        LibraryInterface* libHandler,\n        ExpressionSet expressions,\n        QWidget* parent = nullptr);\n\n\t//! The destructor\n    virtual ~SingleModeEditor() = default;\n\n    //! No copying\n    SingleModeEditor(const SingleModeEditor& other) = delete;\n\n    //! No assignment\n    SingleModeEditor& operator=(const SingleModeEditor& other) = delete;\n\n\t/*!\n\t *  Reload the information from the model to the editor.\n\t */\n\tvoid refresh() final;\n\nprotected:\n    \n    /*!\n     *  The show event for this editor.\n     *\n     *    @param [in] event   The show event.\n     */\n    void showEvent(QShowEvent * event) final;\n\nprivate slots:\n\n    //! Handler for changes in condition expression.\n    void onConditionChanged(); \n\nprivate:\n\n\t/*!\n\t *  Set up the layout for the editor.\n\t */\n\tvoid setupLayout();\n\n    //-----------------------------------------------------------------------------\n    // Data.\n    //-----------------------------------------------------------------------------\n    \n    //! The remap state being edited.\n    QSharedPointer<Mode> mode_;\n\n    //! The validator for the mode.\n    QSharedPointer<ModeValidator> validator_;\n\n\t//! Editor to set the name, display name and description of the view.\n\tNameGroupEditor nameEditor_;\n\n    //! Editor for condition expression.\n    ExpressionLineEditor conditionEditor_;\n\n    QLabel conditionStatus_;\n\n    //! Editor for port slices.\n    PortSliceEditor portSliceEditor_;\n\n    //! Editor for field slices.\n    FieldSliceEditor fieldSliceEditor_;\n};\n\n#endif // SINGLE_Mode_EDITOR_H\n"
  },
  {
    "path": "editors/ComponentEditor/otherClockDrivers/OtherClockDriverColumns.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: OtherClockDriverColumns.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Esko Pekkarinen\r\n// Date: 16.10.2015\r\n//\r\n// Description:\r\n// Common declarations for editing otherClockDrivers.\r\n//-----------------------------------------------------------------------------\r\n\r\nnamespace OtherClockDriverColumns\r\n{\r\n    //! The columns for otherClockDriver table.\r\n    enum Columns\r\n    {\r\n        NAME = 0,\r\n        CLOCK_SOURCE,\r\n        CLOCK_PERIOD,\r\n        CLOCK_PERIOD_UNIT,\r\n        PULSE_OFFSET,\r\n        PULSE_OFFSET_UNIT,\r\n        PULSE_VALUE,\r\n        PULSE_DURATION,\r\n        PULSE_DURATION_UNIT,\r\n        COLUMN_COUNT\r\n    };\r\n}\r\n"
  },
  {
    "path": "editors/ComponentEditor/otherClockDrivers/clockdriversdelegate.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: clockdriversdelegate.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 04.04.2011\r\n//\r\n// Description:\r\n// Delegate class to select editors used to edit otherClockDrivers of component.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"clockdriversdelegate.h\"\r\n\r\n#include \"OtherClockDriverColumns.h\"\r\n\r\n#include <QLineEdit>\r\n#include <QSpinBox>\r\n#include <QDoubleSpinBox>\r\n#include <QComboBox>\r\n\r\nnamespace\r\n{\r\n    const QRegularExpression CLOCKREGULAREXPRESSION = QRegularExpression(\"[0-9]+([.][0-9]+)?\");\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ClockDriversDelegate::ClockDriversDelegate()\r\n//-----------------------------------------------------------------------------\r\nClockDriversDelegate::ClockDriversDelegate(QObject *parent): QStyledItemDelegate(parent)\r\n{\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ClockDriversDelegate::~ClockDriversDelegate()\r\n//-----------------------------------------------------------------------------\r\nClockDriversDelegate::~ClockDriversDelegate()\r\n{\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ClockDriversDelegate::createEditor()\r\n//-----------------------------------------------------------------------------\r\nQWidget* ClockDriversDelegate::createEditor(QWidget* parent, QStyleOptionViewItem const& option, \r\n    QModelIndex const& index ) const\r\n{\r\n    if (index.column() == OtherClockDriverColumns::NAME ||\r\n        index.column() == OtherClockDriverColumns::CLOCK_SOURCE ||\r\n        index.column() == OtherClockDriverColumns::CLOCK_PERIOD ||\r\n        index.column() == OtherClockDriverColumns::PULSE_OFFSET ||\r\n        index.column() == OtherClockDriverColumns::PULSE_DURATION)\r\n    {\r\n\t\tQLineEdit* editor = new QLineEdit(parent);\r\n\t\tconnect(editor, SIGNAL(editingFinished()), this, SLOT(commitAndCloseEditor()), Qt::UniqueConnection);\r\n\r\n        if (index.column() == OtherClockDriverColumns::CLOCK_PERIOD ||\r\n            index.column() == OtherClockDriverColumns::PULSE_OFFSET ||\r\n            index.column() == OtherClockDriverColumns::PULSE_DURATION)\r\n        {\r\n            auto clockValidator = new QRegularExpressionValidator(CLOCKREGULAREXPRESSION, parent);\r\n            editor->setValidator(clockValidator);\r\n        }\r\n\r\n\t\treturn editor;\r\n\t}\r\n\telse if (index.column() == OtherClockDriverColumns::PULSE_VALUE)\r\n    {\r\n        QComboBox* editor = new QComboBox(parent);\r\n        editor->addItem(QLatin1String(\"0\"));\r\n        editor->addItem(QLatin1String(\"1\"));\r\n\r\n        return editor;\r\n\t}\r\n\telse if (index.column() == OtherClockDriverColumns::CLOCK_PERIOD_UNIT ||\r\n        index.column() == OtherClockDriverColumns::PULSE_OFFSET_UNIT ||\r\n        index.column() == OtherClockDriverColumns::PULSE_DURATION_UNIT)\r\n    {\r\n\t\tQComboBox* editor = new QComboBox(parent);\r\n\t\teditor->addItem(QString(\"ns\"));\r\n\t\teditor->addItem(QString(\"ps\"));\r\n\r\n\t\tconnect(editor, SIGNAL(currentIndexChanged(int)), this, SLOT(commitAndCloseEditor()), Qt::UniqueConnection);\r\n\t\treturn editor;\r\n\t}\r\n\telse\r\n    {\r\n\t\treturn QStyledItemDelegate::createEditor(parent, option, index);\r\n\t}\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ClockDriversDelegate::setEditorData()\r\n//-----------------------------------------------------------------------------\r\nvoid ClockDriversDelegate::setEditorData(QWidget* editor, QModelIndex const& index) const\r\n{\r\n    if (index.column() == OtherClockDriverColumns::NAME ||\r\n        index.column() == OtherClockDriverColumns::CLOCK_SOURCE ||\r\n        index.column() == OtherClockDriverColumns::CLOCK_PERIOD ||\r\n        index.column() == OtherClockDriverColumns::PULSE_OFFSET ||\r\n        index.column() == OtherClockDriverColumns::PULSE_DURATION)\r\n    {\r\n\t\tQLineEdit* lineEditor = qobject_cast<QLineEdit*>(editor);\r\n\t\tQString text = index.data(Qt::DisplayRole).toString();\r\n\t\tlineEditor->setText(text);\r\n\t}\r\n\telse if (index.column() == OtherClockDriverColumns::PULSE_VALUE)\r\n    {\r\n        QComboBox* pulseEditor = qobject_cast<QComboBox*>(editor);\r\n        QString value = index.data(Qt::DisplayRole).toString();\r\n\r\n        pulseEditor->setCurrentIndex(pulseEditor->findText(value));\r\n\t}\r\n    else if (index.column() == OtherClockDriverColumns::CLOCK_PERIOD_UNIT ||\r\n        index.column() == OtherClockDriverColumns::PULSE_OFFSET_UNIT ||\r\n        index.column() == OtherClockDriverColumns::PULSE_DURATION_UNIT)\r\n    {\r\n\r\n\t\tQComboBox* comboEditor = qobject_cast<QComboBox*>(editor);\r\n\t\tQString value = index.data(Qt::DisplayRole).toString();\r\n\t\tint index = comboEditor->findText(value);\r\n\t\tcomboEditor->setCurrentIndex(index);\r\n\t}\r\n\telse\r\n    {\r\n\t\tQStyledItemDelegate::setEditorData(editor, index);\r\n\t}\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ClockDriversDelegate::setModelData()\r\n//-----------------------------------------------------------------------------\r\nvoid ClockDriversDelegate::setModelData(QWidget* editor, QAbstractItemModel* model, QModelIndex const& index) const\r\n{\r\n    if (index.column() == OtherClockDriverColumns::NAME ||\r\n        index.column() == OtherClockDriverColumns::CLOCK_SOURCE ||\r\n        index.column() == OtherClockDriverColumns::CLOCK_PERIOD ||\r\n        index.column() == OtherClockDriverColumns::PULSE_OFFSET ||\r\n        index.column() == OtherClockDriverColumns::PULSE_DURATION)\r\n    {\r\n        QLineEdit* lineEditor = qobject_cast<QLineEdit*>(editor);\r\n\t\tQString text = lineEditor->text();\r\n\t\tmodel->setData(index, text, Qt::EditRole);\r\n\t}\r\n\telse if (index.column() == OtherClockDriverColumns::PULSE_VALUE)\r\n    {\r\n        QComboBox* pulseEditor = qobject_cast<QComboBox*>(editor);\r\n        QString value = pulseEditor->currentText();\r\n\r\n        model->setData(index, value, Qt::EditRole);\r\n\t}\r\n    else if (index.column() == OtherClockDriverColumns::CLOCK_PERIOD_UNIT ||\r\n        index.column() == OtherClockDriverColumns::PULSE_OFFSET_UNIT ||\r\n        index.column() == OtherClockDriverColumns::PULSE_DURATION_UNIT)\r\n    {\r\n\t\tQComboBox* comboEditor = qobject_cast<QComboBox*>(editor);\r\n\t\tQString value = comboEditor->currentText();\r\n\t\tmodel->setData(index, value, Qt::EditRole);\r\n\t}\r\n\telse\r\n    {\r\n\t\tQStyledItemDelegate::setModelData(editor, model, index);\r\n\t}\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ClockDriversDelegate::commitAndCloseEditor()\r\n//-----------------------------------------------------------------------------\r\nvoid ClockDriversDelegate::commitAndCloseEditor()\r\n{\r\n\tQSpinBox* spinBox = qobject_cast<QSpinBox*>(sender());\r\n\tQDoubleSpinBox* doubleSpin = qobject_cast<QDoubleSpinBox*>(sender());\r\n\tQComboBox* comboBox = qobject_cast<QComboBox*>(sender());\r\n\tQLineEdit* lineEdit = qobject_cast<QLineEdit*>(sender());\r\n\tQWidget* widget = qobject_cast<QWidget*>(sender());\r\n\r\n\tif (comboBox)\r\n    {\r\n\t\temit commitData(comboBox);\r\n\t\temit closeEditor(comboBox);\r\n\t}\r\n\telse if (doubleSpin)\r\n    {\r\n\t\temit commitData(doubleSpin);\r\n\t\temit closeEditor(doubleSpin);\r\n\t}\r\n\telse if (spinBox)\r\n    {\r\n\t\temit commitData(spinBox);\r\n\t\temit closeEditor(spinBox);\r\n\t}\r\n\telse if (lineEdit)\r\n    {\r\n\t\temit commitData(lineEdit);\r\n\t\temit closeEditor(lineEdit);\r\n\t}\r\n\telse if (widget)\r\n    {\r\n\t\temit commitData(widget);\r\n\t\temit closeEditor(widget);\r\n\t}\r\n}\r\n"
  },
  {
    "path": "editors/ComponentEditor/otherClockDrivers/clockdriversdelegate.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: clockdriversdelegate.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 04.04.2011\r\n//\r\n// Description:\r\n// Delegate class to select editors used to edit otherClockDrivers of component.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef CLOCKDRIVERSDELEGATE_H\r\n#define CLOCKDRIVERSDELEGATE_H\r\n\r\n#include <QStyledItemDelegate>\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Delegate class to select editors used to edit otherClockDrivers of component.\r\n//-----------------------------------------------------------------------------\r\nclass ClockDriversDelegate : public QStyledItemDelegate\r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\r\n\t/*! The constructor\r\n\t *\r\n\t *    @param [in] parent The owner of this instance.\r\n\t*/\r\n\tClockDriversDelegate(QObject *parent);\r\n\t\r\n\t//! The destructor\r\n\tvirtual ~ClockDriversDelegate();\r\n\r\n\t/*! Create a new editor for the given item\r\n\t *\r\n\t *    @param [in] parent  Owner for the editor.\r\n\t *    @param [in] option  Contains options for the editor.\r\n\t *    @param [in] index   Model index identifying the item.\r\n\t *\r\n\t *    @return The editor to be used to edit the item.\r\n\t*/\r\n\tvirtual QWidget* createEditor(QWidget* parent, QStyleOptionViewItem const& option, \r\n        QModelIndex const& index) const;\r\n\r\n\t/*! Set the data for the editor.\r\n\t *\r\n\t *    @param [in] editor The editor where the data is to be set.\r\n\t *    @param [in] index Model index identifying the item that's data is to be set.\r\n\t*/\r\n\tvirtual void setEditorData(QWidget* editor, const QModelIndex& index) const;\r\n\r\n\t/*! Save the data from the editor to the model.\r\n\t *\r\n\t *    @param [in] editor The editor that contains the data to store.\r\n\t *    @param [in] model Model that contains the data structure where data is to be saved to.\r\n\t *    @param [in] index Model index identifying the item that's data is to be saved.\r\n\t*/\r\n\tvirtual void setModelData(QWidget* editor, QAbstractItemModel* model, QModelIndex const& index) const;\r\n\r\nprivate slots:\r\n\r\n\t//! Commit the data from the sending editor and close the editor.\r\n\tvoid commitAndCloseEditor();\r\n\r\nprivate:\r\n\r\n\t//! No copying\r\n\tClockDriversDelegate(const ClockDriversDelegate& other);\r\n\tClockDriversDelegate& operator=(const ClockDriversDelegate& other);\r\n\t\r\n};\r\n\r\n#endif // CLOCKDRIVERSDELEGATE_H\r\n"
  },
  {
    "path": "editors/ComponentEditor/otherClockDrivers/otherclockdriverseditor.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: otherclockdriverseditor.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 04.04.2011\r\n//\r\n// Description:\r\n// Editor for otherClockDrivers of a component.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"otherclockdriverseditor.h\"\r\n\r\n#include \"clockdriversdelegate.h\"\r\n\r\n#include <common/widgets/summaryLabel/summarylabel.h>\r\n\r\n#include <KactusAPI/include/LibraryInterface.h>\r\n\r\n#include <IPXACTmodels/Component/Component.h>\r\n\r\n#include <QVBoxLayout>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: OtherClockDriversEditor::OtherClockDriversEditor()\r\n//-----------------------------------------------------------------------------\r\nOtherClockDriversEditor::OtherClockDriversEditor(QSharedPointer<Component> component, LibraryInterface* handler,\r\n    QSharedPointer<OtherClockDriverValidator> clockValidator, QWidget *parent /* = 0 */):\r\nItemEditor(component, handler, parent),\r\nview_(this),\r\nmodel_(component, clockValidator, this)\r\n{\r\n    connect(&model_, SIGNAL(contentChanged()), this, SIGNAL(contentChanged()), Qt::UniqueConnection);\r\n    connect(&model_, SIGNAL(dataChanged(const QModelIndex&, const QModelIndex&)),\r\n        this, SIGNAL(contentChanged()), Qt::UniqueConnection);\r\n    connect(&model_, SIGNAL(errorMessage(const QString&)),\r\n        this, SIGNAL(errorMessage(const QString&)), Qt::UniqueConnection);\r\n\tconnect(&model_, SIGNAL(noticeMessage(const QString&)),\r\n        this, SIGNAL(noticeMessage(const QString&)), Qt::UniqueConnection);\r\n\tconnect(&view_, SIGNAL(addItem(const QModelIndex&)),\r\n\t\t&model_, SLOT(onAddItem(const QModelIndex&)), Qt::UniqueConnection);\r\n\tconnect(&view_, SIGNAL(removeItem(const QModelIndex&)),\r\n\t\t&model_, SLOT(onRemoveItem(const QModelIndex&)), Qt::UniqueConnection);\r\n\r\n\tconst QString componentPath = handler->getDirectoryPath(component->getVlnv());\r\n\tQString defaultPath = QString(\"%1/otherClocksListing.csv\").arg(componentPath);\r\n\tview_.setDefaultImportExportPath(defaultPath);\r\n\tview_.setAllowImportExport(true);\r\n\r\n\tview_.setSortingEnabled(true);\r\n\tview_.setItemsDraggable(false);\r\n\tview_.setItemDelegate(new ClockDriversDelegate(this));\r\n\r\n\t// Set proxy to do the sorting automatically.\r\n\tproxy_ = new QSortFilterProxyModel(this);\t\r\n\tproxy_->setSourceModel(&model_);\r\n\tview_.setModel(proxy_);\r\n\r\n    // Set case-insensitive sorting.\r\n    proxy_->setSortCaseSensitivity(Qt::CaseInsensitive);\r\n\r\n\t// sort the view\r\n\tview_.sortByColumn(0, Qt::AscendingOrder);\r\n\r\n\t// display a label on top the table\r\n\tSummaryLabel* summaryLabel = new SummaryLabel(tr(\"Other clock drivers\"), this);\r\n\r\n\t// create the layout, add widgets to it\r\n\tQVBoxLayout* layout = new QVBoxLayout(this);\r\n\tlayout->addWidget(summaryLabel, 0, Qt::AlignCenter);\r\n\tlayout->addWidget(&view_);\r\n\tlayout->setContentsMargins(0, 0, 0, 0);\r\n\r\n\trefresh();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: OtherClockDriversEditor::~OtherClockDriversEditor()\r\n//-----------------------------------------------------------------------------\r\nOtherClockDriversEditor::~OtherClockDriversEditor()\r\n{\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: OtherClockDriversEditor::refresh()\r\n//-----------------------------------------------------------------------------\r\nvoid OtherClockDriversEditor::refresh()\r\n{\r\n\tview_.update();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: OtherClockDriversEditor::showEvent()\r\n//-----------------------------------------------------------------------------\r\nvoid OtherClockDriversEditor::showEvent(QShowEvent* event)\r\n{\r\n\tQWidget::showEvent(event);\r\n\temit helpUrlRequested(\"componenteditor/otherclockdrivers.html\");\r\n}\r\n"
  },
  {
    "path": "editors/ComponentEditor/otherClockDrivers/otherclockdriverseditor.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: otherclockdriverseditor.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 04.04.2011\r\n//\r\n// Description:\r\n// Editor for otherClockDrivers of a component.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef OTHERCLOCKDRIVERSEDITOR_H\r\n#define OTHERCLOCKDRIVERSEDITOR_H\r\n\r\n#include <editors/ComponentEditor/itemeditor.h>\r\n\r\n#include <common/views/EditableTableView/editabletableview.h>\r\n\r\n#include \"otherclockdriversmodel.h\"\r\n\r\n#include <QSortFilterProxyModel>\r\n#include <QSharedPointer>\r\n\r\nclass Component;\r\nclass LibraryInterface;\r\nclass OtherClockDriverValidator;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Editor for otherClockDrivers of a component.\r\n//-----------------------------------------------------------------------------\r\n\r\nclass OtherClockDriversEditor : public ItemEditor\r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\r\n\t/*!\r\n     *  The constructor\r\n\t *\r\n\t *    @param [in] component       The component being edited.\r\n\t *    @param [in] handler         The instance managing the library.\r\n     *    @param [in] clockValidator  Validator used for other clock drivers.\r\n\t *    @param [in] parent          The owner of this widget.\r\n\t *\r\n\t */\r\n\tOtherClockDriversEditor(QSharedPointer<Component> component, LibraryInterface* handler,\r\n        QSharedPointer<OtherClockDriverValidator> clockValidator, QWidget *parent = 0);\r\n\t\r\n\t//! The destructor.\r\n\tvirtual ~OtherClockDriversEditor();\r\n\r\n\t/*!\r\n     *  Reload the information from the model to the editor.\r\n\t */\r\n\tvirtual void refresh();\r\n\r\nprotected:\r\n\r\n\t//! Handler for widget's show event.\r\n\tvirtual void showEvent(QShowEvent* event);\r\n\r\nprivate:\r\n\t\r\n\t//! No copying.\r\n\tOtherClockDriversEditor(const OtherClockDriversEditor& other);\r\n\tOtherClockDriversEditor& operator=(const OtherClockDriversEditor& other);\r\n\r\n\t//! The view that displays the parameters.\r\n\tEditableTableView view_;\r\n\r\n\t//! The model that holds the data to be displayed to the user\r\n\tOtherClockDriversModel model_;\r\n\r\n\t//! The proxy that is used to sort the view\r\n\tQSortFilterProxyModel* proxy_;\r\n};\r\n\r\n#endif // OTHERCLOCKDRIVERSEDITOR_H\r\n"
  },
  {
    "path": "editors/ComponentEditor/otherClockDrivers/otherclockdriversmodel.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: otherclockdriversmodel.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 04.04.2011\r\n//\r\n// Description:\r\n// Table model that contains the items to edit otherClockDrivers of a component.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"otherclockdriversmodel.h\"\r\n\r\n#include \"OtherClockDriverColumns.h\"\r\n\r\n#include <IPXACTmodels/generaldeclarations.h>\r\n\r\n#include <IPXACTmodels/Component/Component.h>\r\n#include <IPXACTmodels/Component/OtherClockDriver.h>\r\n\r\n#include <IPXACTmodels/Component/validators/OtherClockDriverValidator.h>\r\n\r\n\r\n\r\n#include <common/KactusColors.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: OtherClockDriversModel::OtherClockDriversModel()\r\n//-----------------------------------------------------------------------------\r\nOtherClockDriversModel::OtherClockDriversModel(QSharedPointer<Component> component,\r\n    QSharedPointer<OtherClockDriverValidator> clockValidator, QObject *parent):\r\nQAbstractTableModel(parent),\r\ncomponent_(component), \r\ntable_(component->getOtherClockDrivers()),\r\nclockValidator_(clockValidator)\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: OtherClockDriversModel::~OtherClockDriversModel()\r\n//-----------------------------------------------------------------------------\r\nOtherClockDriversModel::~OtherClockDriversModel()\r\n{\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: OtherClockDriversModel::rowCount()\r\n//-----------------------------------------------------------------------------\r\nint OtherClockDriversModel::rowCount(QModelIndex const&  parent) const\r\n{\r\n\tif (parent.isValid())\r\n    {\r\n\t\treturn 0;\r\n    }\r\n\r\n\treturn table_->size();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: OtherClockDriversModel::columnCount()\r\n//-----------------------------------------------------------------------------\r\nint OtherClockDriversModel::columnCount(QModelIndex const&  parent) const\r\n{\r\n\tif (parent.isValid())\r\n    {\r\n\t\treturn 0;\r\n    }\r\n\r\n\treturn OtherClockDriverColumns::COLUMN_COUNT;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: OtherClockDriversModel::data()\r\n//-----------------------------------------------------------------------------\r\nQVariant OtherClockDriversModel::data(QModelIndex const&  index, int role) const\r\n{\r\n\tif (!index.isValid() || index.row() < 0 || index.row() >= table_->size())\r\n    {\r\n\t\treturn QVariant();\r\n    }\r\n\r\n\tif (role == Qt::DisplayRole || role == Qt::ToolTipRole)\r\n    {\r\n        if (index.column() == OtherClockDriverColumns::NAME)\r\n        {\r\n            return table_->at(index.row())->getClockName();\r\n        }\r\n        else if (index.column() == OtherClockDriverColumns::CLOCK_SOURCE)\r\n        {\r\n            return table_->at(index.row())->getClockSource();\r\n        }\r\n        else if (index.column() == OtherClockDriverColumns::CLOCK_PERIOD)\r\n        {\r\n            return table_->at(index.row())->getClockPeriod()->getValue();\r\n        }\r\n        else if (index.column() == OtherClockDriverColumns::CLOCK_PERIOD_UNIT)\r\n        {\r\n            return table_->at(index.row())->getClockPeriod()->timeUnitToString();\r\n        }\r\n        else if (index.column() == OtherClockDriverColumns::PULSE_OFFSET)\r\n        {\r\n            return table_->at(index.row())->getClockPulseOffset()->getValue();\r\n        }\r\n        else if (index.column() == OtherClockDriverColumns::PULSE_OFFSET_UNIT)\r\n        {\r\n            return table_->at(index.row())->getClockPulseOffset()->timeUnitToString();\r\n        }\r\n        else if (index.column() == OtherClockDriverColumns::PULSE_VALUE)\r\n        {\r\n            return table_->at(index.row())->getClockPulseValue();\r\n        }\r\n        else if (index.column() == OtherClockDriverColumns::PULSE_DURATION)\r\n        {\r\n            return table_->at(index.row())->getClockPulseDuration()->getValue();\r\n        }\r\n        else if (index.column() == OtherClockDriverColumns::PULSE_DURATION_UNIT)\r\n        {\r\n            return table_->at(index.row())->getClockPulseDuration()->timeUnitToString();\r\n        }\r\n        else\r\n        {\r\n            return QVariant();\r\n        }\r\n    }\r\n    else if (role == Qt::BackgroundRole)\r\n    {\r\n        if (index.column() == OtherClockDriverColumns::NAME ||\r\n            index.column() == OtherClockDriverColumns::CLOCK_PERIOD ||\r\n            index.column() == OtherClockDriverColumns::PULSE_OFFSET ||\r\n            index.column() == OtherClockDriverColumns::PULSE_VALUE ||\r\n            index.column() == OtherClockDriverColumns::PULSE_DURATION)\r\n        {\r\n            return KactusColors::MANDATORY_FIELD;\r\n        }\r\n        else\r\n            return KactusColors::REGULAR_FIELD;\r\n    }\r\n\r\n    else if (role == Qt::ForegroundRole)\r\n    {\r\n        if (validateIndex(index))\r\n        {\r\n            return KactusColors::REGULAR_TEXT;\r\n\t\t}\r\n\t\telse\r\n        {\r\n\t\t\treturn KactusColors::ERROR;\r\n\t\t}\r\n\t}\r\n\r\n\telse\r\n    {\r\n\t\treturn QVariant();\r\n\t}\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: OtherClockDriversModel::headerData()\r\n//-----------------------------------------------------------------------------\r\nQVariant OtherClockDriversModel::headerData(int section, Qt::Orientation orientation, int role) const\r\n{\t\r\n\tif (orientation != Qt::Horizontal || role != Qt::DisplayRole)\r\n    {\r\n\t\treturn QVariant();\r\n    }\r\n\r\n    if (section == OtherClockDriverColumns::NAME)\r\n    {\r\n        return tr(\"Clock\\nname\");\r\n    }\r\n    else if (section == OtherClockDriverColumns::CLOCK_SOURCE)\r\n    {\r\n        return tr(\"Clock\\nsource\");\r\n    }\r\n    else if (section == OtherClockDriverColumns::CLOCK_PERIOD)\r\n    {\r\n        return tr(\"Clock\\nperiod\");\r\n    }\r\n    else if (section == OtherClockDriverColumns::CLOCK_PERIOD_UNIT)\r\n    {\r\n        return tr(\"Period\\nunit\");\r\n    }\r\n    else if (section == OtherClockDriverColumns::PULSE_OFFSET)\r\n    {\r\n        return tr(\"Pulse\\noffset\");\r\n    }\r\n    else if (section == OtherClockDriverColumns::PULSE_OFFSET_UNIT)\r\n    {\r\n        return tr(\"Offset\\nunit\");\r\n    }\r\n    else if (section == OtherClockDriverColumns::PULSE_VALUE)\r\n    {\r\n        return tr(\"Pulse\\nvalue\");\r\n    }\r\n    else if (section == OtherClockDriverColumns::PULSE_DURATION)\r\n    {\r\n        return tr(\"Pulse\\nduration\");\r\n    }\r\n    else if (section == OtherClockDriverColumns::PULSE_DURATION_UNIT)\r\n    {\r\n        return tr(\"Duration\\nunit\");\r\n    }\r\n    else\r\n    {\r\n        return QVariant();\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: OtherClockDriversModel::setData()\r\n//-----------------------------------------------------------------------------\r\nbool OtherClockDriversModel::setData(QModelIndex const& index, QVariant const& value, int role)\r\n{\r\n    if (!index.isValid() || index.row() < 0 || index.row() >= table_->size() || role != Qt::EditRole)\r\n    {\r\n        return false;\r\n    }\r\n\r\n    if (index.column() == OtherClockDriverColumns::NAME)\r\n    {\r\n        table_->value(index.row())->setClockName(value.toString());\r\n    }\r\n    else if (index.column() == OtherClockDriverColumns::CLOCK_SOURCE)\r\n    {\r\n        table_->value(index.row())->setClockSource(value.toString());\r\n    }\r\n    else if (index.column() == OtherClockDriverColumns::CLOCK_PERIOD)\r\n    {\r\n        table_->value(index.row())->getClockPeriod()->setValue(value.toString());\r\n    }\r\n    else if (index.column() == OtherClockDriverColumns::CLOCK_PERIOD_UNIT)\r\n    {\r\n        table_->value(index.row())->getClockPeriod()->setTimeUnit(value.toString());\r\n    }\r\n    else if (index.column() == OtherClockDriverColumns::PULSE_OFFSET)\r\n    {\r\n        table_->value(index.row())->getClockPulseOffset()->setValue(value.toString());        \r\n    }\r\n    else if (index.column() == OtherClockDriverColumns::PULSE_OFFSET_UNIT)\r\n    {\r\n        table_->value(index.row())->getClockPulseOffset()->setTimeUnit(value.toString());\r\n    }\r\n    else if (index.column() == OtherClockDriverColumns::PULSE_VALUE)\r\n    {\r\n        table_->value(index.row())->setClockPulseValue(value.toString());\r\n    }\r\n    else if (index.column() == OtherClockDriverColumns::PULSE_DURATION)\r\n    {\r\n        table_->value(index.row())->getClockPulseDuration()->setValue(value.toString());\r\n    }\r\n    else if (index.column() == OtherClockDriverColumns::PULSE_DURATION_UNIT)\r\n    {\r\n        table_->value(index.row())->getClockPulseDuration()->setTimeUnit(value.toString());\r\n    }\r\n    else\r\n    {\r\n        return false;\r\n    }\r\n\r\n    emit dataChanged(index, index);\r\n    emit contentChanged();\r\n    return true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: OtherClockDriversModel::flags()\r\n//-----------------------------------------------------------------------------\r\nQt::ItemFlags OtherClockDriversModel::flags(QModelIndex const&  index) const\r\n{\r\n\tif (!index.isValid())\r\n    {\r\n\t\treturn Qt::NoItemFlags;\r\n    }\r\n\r\n\treturn Qt::ItemIsEditable | Qt::ItemIsEnabled | Qt::ItemIsSelectable;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: OtherClockDriversModel::onRemoveRow()\r\n//-----------------------------------------------------------------------------\r\nvoid OtherClockDriversModel::onRemoveRow(int row)\r\n{\r\n\t// if row is invalid\r\n\tif (row < 0 || row >= table_->size())\r\n    {\r\n\t\treturn;\r\n    }\r\n\r\n\tbeginRemoveRows(QModelIndex(), row, row);\r\n\r\n\t// remove the object from the map\r\n\ttable_->removeAt(row);\r\n\r\n\tendRemoveRows();\r\n\r\n\t// tell also parent widget that contents have been changed\r\n\temit contentChanged();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: OtherClockDriversModel::onRemoveItem()\r\n//-----------------------------------------------------------------------------\r\nvoid OtherClockDriversModel::onRemoveItem(QModelIndex const&  index)\r\n{\r\n\t// don't remove anything if index is invalid\r\n\tif (!index.isValid() || index.row() < 0 || index.row() >= table_->size())\r\n    {\r\n\t\treturn;\r\n    }\r\n\r\n\t// remove the specified item\r\n\tbeginRemoveRows(QModelIndex(), index.row(), index.row());\r\n\ttable_->removeAt(index.row());\r\n\tendRemoveRows();\r\n\r\n\t// tell also parent widget that contents have been changed\r\n\temit contentChanged();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: OtherClockDriversModel::onAddRow()\r\n//-----------------------------------------------------------------------------\r\nvoid OtherClockDriversModel::onAddRow()\r\n{\r\n\tbeginInsertRows(QModelIndex(), table_->size(), table_->size());\r\n\ttable_->append(QSharedPointer<OtherClockDriver>(new OtherClockDriver()));\r\n\tendInsertRows();\r\n\r\n\t// tell also parent widget that contents have been changed\r\n\temit contentChanged();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: OtherClockDriversModel::onAddItem()\r\n//-----------------------------------------------------------------------------\r\nvoid OtherClockDriversModel::onAddItem(QModelIndex const& index)\r\n{\r\n\tint row = table_->size();\r\n\r\n\t// if the index is valid then add the item to the correct position\r\n\tif (index.isValid())\r\n    {\r\n\t\trow = index.row();\r\n\t}\r\n\r\n\tbeginInsertRows(QModelIndex(), row, row);\r\n\ttable_->insert(row, QSharedPointer<OtherClockDriver>(new OtherClockDriver()));\r\n\tendInsertRows();\r\n\r\n\t// tell also parent widget that contents have been changed\r\n\temit contentChanged();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: otherclockdriversmodel::validateIndex()\r\n//-----------------------------------------------------------------------------\r\nbool OtherClockDriversModel::validateIndex(QModelIndex const& index) const\r\n{\r\n    QSharedPointer<OtherClockDriver> currentClockDriver = table_->at(index.row());\r\n\r\n    if (index.column() == OtherClockDriverColumns::NAME)\r\n    {\r\n        return clockValidator_->hasValidName(currentClockDriver->getClockName());\r\n    }\r\n    else if (index.column() == OtherClockDriverColumns::CLOCK_PERIOD)\r\n    {\r\n        return clockValidator_->hasValidClockValue(currentClockDriver->getClockPeriod());\r\n    }\r\n    else if (index.column() == OtherClockDriverColumns::PULSE_OFFSET)\r\n    {\r\n        return clockValidator_->hasValidClockValue(currentClockDriver->getClockPulseOffset());\r\n    }\r\n    else if (index.column() == OtherClockDriverColumns::PULSE_VALUE)\r\n    {\r\n        return clockValidator_->hasValidClockPulseValue(currentClockDriver);\r\n    }\r\n    else if (index.column() == OtherClockDriverColumns::PULSE_DURATION)\r\n    {\r\n        return clockValidator_->hasValidClockValue(currentClockDriver->getClockPulseDuration());\r\n    }\r\n\r\n    return true;\r\n}\r\n"
  },
  {
    "path": "editors/ComponentEditor/otherClockDrivers/otherclockdriversmodel.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: otherclockdriversmodel.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 04.04.2011\r\n//\r\n// Description:\r\n// Table model that contains the items to edit otherClockDrivers of a component.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef OTHERCLOCKDRIVERSMODEL_H\r\n#define OTHERCLOCKDRIVERSMODEL_H\r\n\r\n#include <QAbstractTableModel>\r\n\r\n#include <QList>\r\n#include <QSharedPointer>\r\n\r\nclass Component;\r\nclass OtherClockDriver;\r\nclass OtherClockDriverValidator;\r\n//-----------------------------------------------------------------------------\r\n//! Table model that contains the items to edit otherClockDrivers of a component.\r\n//-----------------------------------------------------------------------------\r\nclass OtherClockDriversModel : public QAbstractTableModel\r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\r\n\t/*!\r\n     *  The constructor\r\n\t *\r\n\t *    @param [in] component       The component being edited.\r\n     *    @param [in] clockValidator  Validator used for other clock drivers.\r\n\t *    @param [in] parent          The owner of this model\r\n\t */\r\n\tOtherClockDriversModel(QSharedPointer<Component> component,\r\n        QSharedPointer<OtherClockDriverValidator> clockValidator, QObject *parent);\r\n\t\r\n\t//! The destructor.\r\n\t~OtherClockDriversModel();\r\n\r\n\t/*!\r\n     *  Get the number of rows in the model.\r\n\t *\r\n\t *    @param [in] parent  Model index of the parent of the item. Must be invalid because this is not \r\n     *                          hierarchical model.\r\n\t *\r\n\t *    @return Number of rows currently in the model.\r\n\t */\r\n\tvirtual int rowCount(QModelIndex const&  parent = QModelIndex()) const;\r\n\r\n\t/*!\r\n     *  Get the number of columns in the model\r\n\t *\r\n\t *    @param [in] parent  Model index of the parent of the item. Must be invalid because this is not \r\n     *                          hierarchical model.\r\n\t *\r\n\t *    @return Always returns 9\r\n\t */\r\n\tvirtual int columnCount(QModelIndex const&  parent = QModelIndex()) const;\r\n\r\n\t/*!\r\n     *  Get the data for the specified item for specified role.\r\n\t *\r\n\t *    @param [in] index Identifies the item that's data is wanted.\r\n\t *    @param [in] role Specifies what kind of data is wanted\r\n\t *\r\n\t *    @return QVariant containing the data\r\n\t */\r\n\tvirtual QVariant data(QModelIndex const&  index, int role = Qt::DisplayRole) const;\r\n\r\n\t/*!\r\n     *  Get the data for the headers\r\n\t *\r\n\t *    @param [in] section The column that's header is wanted\r\n\t *    @param [in] orientation Only Qt::Horizontal is supported\r\n\t *    @param [in] role Specified the type of data that is wanted.\r\n\t *\r\n\t *    @return QVariant containing the data to be displayed\r\n\t */\r\n\tvirtual QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;\r\n\r\n\t/*!\r\n     *  Set the data for specified item.\r\n\t *\r\n\t *    @param [in] index Specifies the item that's data is modified\r\n\t *    @param [in] value The value to be set.\r\n\t *    @param [in] role The role that is trying to modify the data. Only Qt::EditRole is supported.\r\n\t *\r\n\t *    @return True if data was successfully set.\r\n\t */\r\n\tvirtual bool setData(QModelIndex const&  index, const QVariant& value, int role = Qt::EditRole);\r\n\r\n\t/*!\r\n     *  Get information on how specified item can be handled.\r\n\t *\r\n\t *    @param [in] index Specifies the item that's flags are wanted.\r\n\t *\r\n\t *    @return Qt::ItemFlags that define how object can be handled.\r\n\t */\r\n\tvirtual Qt::ItemFlags flags(QModelIndex const&  index) const;\r\n\r\npublic slots:\r\n\r\n\t/*!\r\n     *  Remove a row from the model\r\n\t *\r\n\t *    @param [in] row Specifies the row to remove\r\n\t */\r\n\tvoid onRemoveRow(int row);\r\n\r\n\t/*!\r\n     *  Add a new empty row to the model\r\n\t */\r\n\tvoid onAddRow();\r\n\r\n\t/*!\r\n     *  A new item should be added to given index.\r\n\t *\r\n\t *    @param [in] index The position where new item should be added at.\r\n\t */\r\n\tvoid onAddItem(QModelIndex const&  index);\r\n\r\n\t/*!\r\n     *  An item should be removed from the model.\r\n\t * \r\n\t *    @param [in] index Identifies the item that should be removed.\r\n\t */\r\n\tvoid onRemoveItem(QModelIndex const&  index);\r\n\r\nsignals:\r\n\r\n\t//! Emitted when contents of the model change.\r\n\tvoid contentChanged();\r\n\r\n\t//! Prints an error message to the user.\r\n\tvoid errorMessage(const QString& msg) const;\r\n\t\r\n\t//! Prints a notification to user.\r\n\tvoid noticeMessage(const QString& msg) const;\r\n\r\nprivate:\r\n\r\n\t//! No copying.\r\n\tOtherClockDriversModel(const OtherClockDriversModel& other);\r\n\r\n\t//! No assignment.\r\n\tOtherClockDriversModel& operator=(const OtherClockDriversModel& other);\r\n\t\r\n    /*!\r\n     *  Validate the data contained within a given index.\r\n     *\r\n     *    @param [in] index   The index of the data being validated.\r\n     *\r\n     *    @return True, if the data is valid, otherwise false.\r\n     */\r\n    bool validateIndex(QModelIndex const& index) const;\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n\t//! The component being edited.\r\n\tQSharedPointer<Component> component_;\r\n\r\n\t//! Contains the current items in the editor.\r\n\tQSharedPointer<QList<QSharedPointer<OtherClockDriver> > > table_;\r\n\r\n    //! The validator used for other clock drivers.\r\n    QSharedPointer<OtherClockDriverValidator> clockValidator_;\r\n};\r\n\r\n#endif // OTHERCLOCKDRIVERSMODEL_H\r\n"
  },
  {
    "path": "editors/ComponentEditor/parameterReferenceTree/ComponentParameterReferenceTree.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: ComponentParameterReferenceTree.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 28.09.2018\n//\n// Description:\n// Tree widget for displaying references to a parameter within a component.\n//-----------------------------------------------------------------------------\n\n#include \"ComponentParameterReferenceTree.h\"\n\n#include <editors/ComponentEditor/referenceCounter/ComponentParameterReferenceCounter.h>\n\n#include <IPXACTmodels/common/ModuleParameter.h>\n#include <IPXACTmodels/common/FileBuilder.h>\n\n#include <IPXACTmodels/Component/Component.h>\n#include <IPXACTmodels/Component/Cpu.h>\n#include <IPXACTmodels/Component/FileSet.h>\n#include <IPXACTmodels/Component/File.h>\n#include <IPXACTmodels/Component/BuildCommand.h>\n#include <IPXACTmodels/Component/AddressSpace.h>\n#include <IPXACTmodels/Component/Segment.h>\n#include <IPXACTmodels/Component/ComponentInstantiation.h>\n#include <IPXACTmodels/Component/DesignConfigurationInstantiation.h>\n#include <IPXACTmodels/Component/DesignInstantiation.h>\n#include <IPXACTmodels/Component/Port.h>\n#include <IPXACTmodels/Component/PowerDomain.h>\n#include <IPXACTmodels/Component/MemoryMapBase.h>\n#include <IPXACTmodels/Component/MemoryMap.h>\n#include <IPXACTmodels/Component/MemoryRemap.h>\n#include <IPXACTmodels/Component/Mode.h>\n#include <IPXACTmodels/Component/AddressBlock.h>\n#include <IPXACTmodels/Component/Region.h>\n#include <IPXACTmodels/Component/RegisterBase.h>\n#include <IPXACTmodels/Component/Register.h>\n#include <IPXACTmodels/Component/RegisterFile.h>\n#include <IPXACTmodels/Component/Field.h>\n#include <IPXACTmodels/Component/WriteValueConstraint.h>\n#include <IPXACTmodels/Component/BusInterface.h>\n#include <IPXACTmodels/Component/MirroredTargetInterface.h>\n#include <IPXACTmodels/Component/InitiatorInterface.h>\n#include <IPXACTmodels/Component/RemapState.h>\n#include <IPXACTmodels/Component/RemapPort.h>\n#include <IPXACTmodels/Component/IndirectInterface.h>\n\n//-----------------------------------------------------------------------------\n// Function: ComponentParameterReferenceTree::ComponentParameterReferenceTree()\n//-----------------------------------------------------------------------------\nComponentParameterReferenceTree::ComponentParameterReferenceTree(QSharedPointer<Component> component,\n    QSharedPointer<ExpressionFormatter> expressionFormatter,\n    QSharedPointer<ComponentParameterReferenceCounter> referenceCounter, QWidget *parent):\nParameterReferenceTree(expressionFormatter, parent),\ncomponent_(component),\nreferenceCounter_(referenceCounter)\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: ComponentParameterReferenceTree::setComponent()\n//-----------------------------------------------------------------------------\nvoid ComponentParameterReferenceTree::setComponent(QSharedPointer<Component> newComponent)\n{\n    component_ = newComponent;\n}\n\n//-----------------------------------------------------------------------------\n// Function: ComponentParameterReferenceTree::setupTree()\n//-----------------------------------------------------------------------------\nvoid ComponentParameterReferenceTree::setupTree()\n{\n    if (!component_.isNull())\n    {\n        if (referenceCounter_->countReferencesInFileSets(getTargetID()) > 0)\n        {\n            createReferencesForFileSets();\n        }\n\n        if (referenceCounter_->countReferencesInParameters(getTargetID(), component_->getParameters()) > 0)\n        {\n            QTreeWidgetItem* topParametersItem = createTopItem(\"Parameters\");\n            createParameterReferences(component_->getParameters(), topParametersItem);\n        }\n\n        if (referenceCounter_->countReferencesInMemoryMaps(getTargetID()) > 0)\n        {\n            createReferencesForMemoryMaps();\n        }\n\n        if (referenceCounter_->countReferencesInAddressSpaces(getTargetID()) > 0)\n        {\n            createReferencesForAddressSpaces();\n        }\n\n        if (referenceCounter_->countReferencesInInstantiations(getTargetID()) > 0)\n        {\n            createReferencesForInstantiations();\n        }\n\n        if (referenceCounter_->countReferencesInPorts(getTargetID()) > 0)\n        {\n            createReferencesForPorts();\n        }\n\n        if (referenceCounter_->countReferencesInBusInterfaces(getTargetID()) > 0)\n        {\n            createReferencesForBusInterfaces();\n        }\n\n        if (referenceCounter_->countReferencesInRemapStates(getTargetID()) > 0)\n        {\n            createReferencesForRemapStates();\n        }\n\n        if (referenceCounter_->countReferencesInModes(getTargetID()) > 0)\n        {\n            createReferencesForModes();\n        }\n\n        if (referenceCounter_->countReferencesInIndirectInterfaces(getTargetID()) > 0)\n        {\n            createReferencesForIndirectInterfaces();\n        }\n\n        if (referenceCounter_->countReferencesInCpus(getTargetID()) > 0)\n        {\n            createReferencesForCpus();\n        }\n\n        if (referenceCounter_->countReferencesInPowerDomains(getTargetID()) > 0)\n        {\n            createReferencesForPowerDomains();\n        }\n\n        if (topLevelItemCount() == 0)\n        {\n            createTopItem(\"No references found.\");\n        }\n    }\n    else\n    {\n        createTopItem(\"Component does not exist.\");\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: ComponentParameterReferenceTree::getReferenceCounter()\n//-----------------------------------------------------------------------------\nQSharedPointer<ParameterReferenceCounter> ComponentParameterReferenceTree::getReferenceCounter() const\n{\n    return referenceCounter_;\n}\n\n//-----------------------------------------------------------------------------\n// Function: ComponentParameterReferenceTree::createReferencesForFileSets()\n//-----------------------------------------------------------------------------\nvoid ComponentParameterReferenceTree::createReferencesForFileSets()\n{\n    QTreeWidgetItem* topFileSetsItem = createTopItem(\"File sets\");\n\n    QString targetID = getTargetID();\n\n    for (QSharedPointer<FileSet> fileSet : *component_->getFileSets())\n    {\n        if (referenceCounter_->countReferencesInSingleFileSet(targetID, fileSet) > 0)\n        {\n            QTreeWidgetItem* fileSetItem = createMiddleItem(fileSet->name(), topFileSetsItem);\n\n            if (referenceCounter_->countReferencesInFileBuilders(targetID, fileSet->getDefaultFileBuilders()) > 0)\n            {\n                createReferencesForFileBuilders(fileSet->getDefaultFileBuilders(), fileSetItem);\n            }\n\n            if (referenceCounter_->countReferencesInFiles(targetID, fileSet->getFiles()) > 0)\n            {\n                createReferencesForFiles(fileSet->getFiles(), fileSetItem);\n            }\n        }\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: ComponentParameterReferenceTree::createReferencesForFileBuilders()\n//-----------------------------------------------------------------------------\nvoid ComponentParameterReferenceTree::createReferencesForFileBuilders(\n    QSharedPointer<QList<QSharedPointer<FileBuilder> > > fileBuilders, QTreeWidgetItem* parentItem)\n{\n    QTreeWidgetItem* buildCommandsItem = createMiddleItem(\"Default file build commands\", parentItem);\n    colourItemGrey(buildCommandsItem);\n\n    for (QSharedPointer<FileBuilder> builder : *fileBuilders)\n    {\n        if (referenceCounter_->countReferencesInSingleFileBuilder(getTargetID(), builder) > 0)\n        {\n            createReferencesForSingleFileBuilder(builder, buildCommandsItem);\n        }\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: ComponentParameterReferenceTree::createReferencesForSingleFileBuilder()\n//-----------------------------------------------------------------------------\nvoid ComponentParameterReferenceTree::createReferencesForSingleFileBuilder(QSharedPointer<FileBuilder> fileBuilder,\n    QTreeWidgetItem* parentItem)\n{\n    QString fileType = fileBuilder->getFileType().type_;\n\n    QString fileTypeIdentifier = QObject::tr(\"File type: %1\").arg(fileType);\n\n    QTreeWidgetItem* builderItem = createMiddleItem(fileTypeIdentifier, parentItem);\n\n    createItem(QLatin1String(\"Replace default flags\"), fileBuilder->getReplaceDefaultFlags(), builderItem);\n}\n\n//-----------------------------------------------------------------------------\n// Function: ComponentParameterReferenceTree::createReferencesForFiles()\n//-----------------------------------------------------------------------------\nvoid ComponentParameterReferenceTree::createReferencesForFiles(QSharedPointer<QList<QSharedPointer<File> > > fileList,\n    QTreeWidgetItem* parentItem)\n{\n    QTreeWidgetItem* filesItem = createMiddleItem(\"Files\", parentItem);\n    colourItemGrey(filesItem);\n\n    for (QSharedPointer<File> currentFile : *fileList)\n    {\n        if (referenceCounter_->countReferencesInSingleFile(getTargetID(), currentFile) > 0)\n        {\n            createReferencesForSingleFile(currentFile, filesItem);\n        }\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: ComponentParameterReferenceTree::createReferencesForSingleFile()\n//-----------------------------------------------------------------------------\nvoid ComponentParameterReferenceTree::createReferencesForSingleFile(QSharedPointer<File> selectedFile,\n    QTreeWidgetItem* parentItem)\n{\n    QTreeWidgetItem* fileItem = createMiddleItem(selectedFile->name(), parentItem);\n\n    QSharedPointer<BuildCommand> buildCommand = selectedFile->getBuildCommand();\n\n    if (buildCommand && referenceCounter_->countReferencesInBuildCommand(getTargetID(), buildCommand) > 0)\n    {\n        QTreeWidgetItem* buildCommandItem = createMiddleItem(\"Build command\", fileItem);\n\n        createItem(\"Replace default flags\", buildCommand->getReplaceDefaultFlags(), buildCommandItem);\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: ComponentParameterReferenceTree::createReferencesForModuleParameters()\n//-----------------------------------------------------------------------------\nvoid ComponentParameterReferenceTree::createReferencesForModuleParameters(\n    QSharedPointer<QList<QSharedPointer<ModuleParameter> > > parameters, QTreeWidgetItem* parentItem)\n{\n    for (QSharedPointer<ModuleParameter> moduleParameter : *parameters)\n    {\n        if (referenceCounter_->countReferencesInSingleParameter(getTargetID(), moduleParameter) > 0)\n        {\n            QTreeWidgetItem* moduleParameterItem = createMiddleItem(moduleParameter->name(), parentItem);\n            createItemsForParameter(moduleParameter, moduleParameterItem);\n        }\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: ComponentParameterReferenceTree::createReferencesForInstantiations()\n//-----------------------------------------------------------------------------\nvoid ComponentParameterReferenceTree::createReferencesForInstantiations()\n{\n    QTreeWidgetItem* topInstantiationsItem = createTopItem(\"Instantiations\");\n    QString targetID = getTargetID();\n\n    if (referenceCounter_->countReferencesInComponentInstantiations(\n        targetID, component_->getComponentInstantiations()) > 0)\n    {\n        createReferencesForComponentInstantiations(topInstantiationsItem);\n    }\n    if (referenceCounter_->countReferencesInDesignConfigurationInstantiations(\n        targetID, component_->getDesignConfigurationInstantiations()) > 0)\n    {\n        createReferencesForDesignConfigurationInstantiations(topInstantiationsItem);\n    }\n    if (referenceCounter_->countReferencesInDesignInstantiations(targetID) > 0)\n    {\n        createReferencesForDesignInstantiations(topInstantiationsItem);\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: ComponentParameterReferenceTree::createReferencesForComponentInstantiations()\n//-----------------------------------------------------------------------------\nvoid ComponentParameterReferenceTree::createReferencesForComponentInstantiations(QTreeWidgetItem* topInstantiationsItem)\n{\n    QTreeWidgetItem* componentInstantiationsItem =\n        createMiddleItem(\"Component instantiations\", topInstantiationsItem);\n\n    QString targetID = getTargetID();\n\n    for (QSharedPointer<ComponentInstantiation> instantiation : *component_->getComponentInstantiations())\n    {\n        if (referenceCounter_->countReferencesInSingleComponentInstantiation(targetID, instantiation) > 0)\n        {\n            QTreeWidgetItem* instantiationItem =\n                createMiddleItem(instantiation->name(), componentInstantiationsItem);\n\n            if (referenceCounter_->countReferencesInParameters(targetID, instantiation->getParameters()) > 0)\n            {\n                QTreeWidgetItem* parametersItem = createMiddleItem(QLatin1String(\"Parameters\"), instantiationItem);\n                colourItemGrey(parametersItem);\n                createParameterReferences(instantiation->getParameters(), parametersItem);\n            }\n\n            if (referenceCounter_->countReferencesInModuleParameters(\n                targetID, instantiation->getModuleParameters()) > 0)\n            {\n                QTreeWidgetItem* moduleParametersItem =\n                    createMiddleItem(QLatin1String(\"Module Parameters\"), instantiationItem);\n                colourItemGrey(moduleParametersItem);\n                createReferencesForModuleParameters(instantiation->getModuleParameters(), moduleParametersItem);\n            }\n\n            if (referenceCounter_->countReferencesInFileBuilders(\n                targetID, instantiation->getDefaultFileBuilders()) > 0)\n            {\n                createReferencesForFileBuilders(instantiation->getDefaultFileBuilders(), instantiationItem);\n            }\n        }\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: ComponentParameterReferenceTree::createReferencesForDesignConfigurationInstantiations()\n//-----------------------------------------------------------------------------\nvoid ComponentParameterReferenceTree::createReferencesForDesignConfigurationInstantiations(\n    QTreeWidgetItem* topInstantiationsItem)\n{\n    QTreeWidgetItem* designConfigurationInstantiationsItem =\n        createMiddleItem(\"Design Configuration Instantiations\", topInstantiationsItem);\n\n    QString targetID = getTargetID();\n\n    for (QSharedPointer<DesignConfigurationInstantiation> instantiation :\n        *component_->getDesignConfigurationInstantiations())\n    {\n        if (referenceCounter_->countReferencesInSingleDesignConfigurationInstantiation(\n            targetID, instantiation) > 0)\n        {\n            QTreeWidgetItem* instantiationItem = createMiddleItem(instantiation->name(),\n                designConfigurationInstantiationsItem);\n            if (referenceCounter_->countReferencesInParameters(targetID, instantiation->getParameters()) > 0)\n            {\n                QTreeWidgetItem* parametersItem = createMiddleItem(QLatin1String(\"Parameters\"), instantiationItem);\n                colourItemGrey(parametersItem);\n                createParameterReferences(instantiation->getParameters(), parametersItem);\n            }\n\n            QSharedPointer<QList<QSharedPointer<ConfigurableElementValue> > > elements =\n                instantiation->getDesignConfigurationReference()->getConfigurableElementValues();\n            if (referenceCounter_->countReferencesInConfigurableElementValues(targetID, elements) > 0)\n            {\n                createReferencesForConfigurableElementValues(elements, instantiationItem);\n            }\n        }\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: ComponentParameterReferenceTree::createReferencesForDesignInstantiations()\n//-----------------------------------------------------------------------------\nvoid ComponentParameterReferenceTree::createReferencesForDesignInstantiations(QTreeWidgetItem* topInstantiationsItem)\n{\n    QTreeWidgetItem* designInstantiationsItem = createMiddleItem(\"Design instantiations\", topInstantiationsItem);\n    QString targetID = getTargetID();\n\n    for (QSharedPointer<DesignInstantiation> instantiation : *component_->getDesignInstantiations())\n    {\n        if (referenceCounter_->countReferencesInSingleDesigninstantiation(targetID, instantiation) > 0)\n        {\n            QTreeWidgetItem* instantiationItem = createMiddleItem(instantiation->name(), designInstantiationsItem);\n\n            QSharedPointer<QList<QSharedPointer<ConfigurableElementValue> > > elements =\n                instantiation->getDesignReference()->getConfigurableElementValues();\n            if (referenceCounter_->countReferencesInConfigurableElementValues(targetID, elements) > 0)\n            {\n                createReferencesForConfigurableElementValues(elements, instantiationItem);\n            }\n        }\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: ComponentParameterReferenceTree::createReferencesForPorts()\n//-----------------------------------------------------------------------------\nvoid ComponentParameterReferenceTree::createReferencesForPorts()\n{\n    QTreeWidgetItem* topPortsItem = createTopItem(\"Ports\");\n\n    for (QSharedPointer<Port> port : *component_->getPorts())\n    {\n        if (referenceCounter_->countReferencesInSinglePort(getTargetID(), port) > 0)\n        {\n            QTreeWidgetItem* portItem = createMiddleItem(port->name(), topPortsItem);\n            createItemsForPort(port, portItem);\n        }\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: ComponentParameterReferenceTree::createReferencesForAddressSpaces()\n//-----------------------------------------------------------------------------\nvoid ComponentParameterReferenceTree::createReferencesForAddressSpaces()\n{\n    QTreeWidgetItem* topAddressSpaceItem = createTopItem(\"Address Spaces\");\n    QString targetID = getTargetID();\n\n    for (QSharedPointer<AddressSpace> addressSpace : *component_->getAddressSpaces())\n    {\n        if (referenceCounter_->countReferencesInSingleAddressSpace(targetID, addressSpace) > 0)\n        {\n            QTreeWidgetItem* addressSpaceItem = createMiddleItem(addressSpace->name(), topAddressSpaceItem);\n\n            if (referenceCounter_->countReferencesInSingleAddressSpaceItems(targetID, addressSpace) > 0)\n            {\n                createItemsForAddressSpace(addressSpace, addressSpaceItem);\n            }\n\n            if (referenceCounter_->countReferencesInSegments(targetID, addressSpace->getSegments()) > 0)\n            {\n                QTreeWidgetItem* segmentsItem = createMiddleItem(\"Segments\", addressSpaceItem);\n                colourItemGrey(segmentsItem);\n\n                createReferencesForSegments(addressSpace, segmentsItem);\n            }\n\n            if (addressSpace->hasLocalMemoryMap() &&\n                referenceCounter_->countReferencesInBaseMemoryMap(targetID, addressSpace->getLocalMemoryMap()) > 0)\n            {\n                QSharedPointer <MemoryMapBase> localMemoryMap = addressSpace->getLocalMemoryMap();\n                QTreeWidgetItem* memoryMapItem = createMiddleItem(localMemoryMap->name(), addressSpaceItem);\n                createReferencesForSingleMemoryMap(localMemoryMap, memoryMapItem);\n            }\n        }\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: ComponentParameterReferenceTree::createItemsForAddressSpace()\n//-----------------------------------------------------------------------------\nvoid ComponentParameterReferenceTree::createItemsForAddressSpace(QSharedPointer<AddressSpace> addressSpace,\n    QTreeWidgetItem* parent)\n{\n    if (addressSpace->getWidth().contains(getTargetID()))\n    {\n        createItem(QLatin1String(\"Width\"), addressSpace->getWidth(), parent);\n    }\n\n    if (addressSpace->getRange().contains(getTargetID()))\n    {\n        createItem(QLatin1String(\"Range\"), addressSpace->getRange(), parent);\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: ComponentParameterReferenceTree::createReferencesForSegments()\n//-----------------------------------------------------------------------------\nvoid ComponentParameterReferenceTree::createReferencesForSegments(QSharedPointer<AddressSpace> addressSpace,\n    QTreeWidgetItem* parent)\n{\n    for (QSharedPointer<Segment> segment : *addressSpace->getSegments())\n    {\n        if (referenceCounter_->countReferencesInSingleSegment(getTargetID(), segment) > 0)\n        {\n            createItemsForSegment(segment, parent);\n        }\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: ComponentParameterReferenceTree::createItemsForSegment()\n//-----------------------------------------------------------------------------\nvoid ComponentParameterReferenceTree::createItemsForSegment(QSharedPointer<Segment> segment,\n    QTreeWidgetItem* parent)\n{\n    QTreeWidgetItem* segmentItem = createMiddleItem(segment->name(), parent);\n\n    if (segment->getAddressOffset().contains(getTargetID()))\n    {\n        createItem(\"Offset\", segment->getAddressOffset(), segmentItem);\n    }\n\n    if (segment->getRange().contains(getTargetID()))\n    {\n        createItem(\"Range\", segment->getRange(), segmentItem);\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: ComponentParameterReferenceTree::createReferencesForMemoryMaps()\n//-----------------------------------------------------------------------------\nvoid ComponentParameterReferenceTree::createReferencesForMemoryMaps()\n{\n    QTreeWidgetItem* topMemoryMapItem = createTopItem(\"Memory maps\");\n    QString targetID = getTargetID();\n\n    for (QSharedPointer<MemoryMap> memoryMap : *component_->getMemoryMaps())\n    {\n        if (referenceCounter_->countReferencesInSingleMemoryMap(targetID, memoryMap) > 0)\n        {\n            QTreeWidgetItem* memoryMapTreeItem = createMiddleItem(memoryMap->name(), topMemoryMapItem);\n\n            QTreeWidgetItem* memoryRemapsTreeItem = createMiddleItem(\"Memory remaps\", memoryMapTreeItem);\n            colourItemGrey(memoryRemapsTreeItem);\n\n            if (referenceCounter_->countReferencesInBaseMemoryMap(targetID, memoryMap) > 0)\n            {\n                QTreeWidgetItem* defaultMemoryRemapItem = createMiddleItem(\"Default\", memoryRemapsTreeItem);\n                createReferencesForSingleMemoryMap(memoryMap, defaultMemoryRemapItem);\n            }\n\n            for (QSharedPointer<MemoryRemap> memoryRemap : *memoryMap->getMemoryRemaps())\n            {\n                if (referenceCounter_->countReferencesInBaseMemoryMap(targetID, memoryRemap) > 0)\n                {\n                    QTreeWidgetItem* memoryRemapItem = createMiddleItem(memoryRemap->name(), memoryRemapsTreeItem);\n                    createReferencesForSingleMemoryMap(memoryRemap, memoryRemapItem);\n                }\n            }\n        }\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: ComponentParameterReferenceTree::createReferencesForSingleMemoryMap()\n//-----------------------------------------------------------------------------\nvoid ComponentParameterReferenceTree::createReferencesForSingleMemoryMap(QSharedPointer<MemoryMapBase> memoryMap,\n    QTreeWidgetItem* memoryRemapItem)\n{\n    QString targetID = getTargetID();\n    if (referenceCounter_->countReferencesInMemoryMapValues(targetID, memoryMap) > 0)\n    {\n        createItemsForMemoryMap(memoryMap, memoryRemapItem);\n    }\n\n    QTreeWidgetItem* middleAddressBlocksItem = createMiddleItem(\"Address blocks\", memoryRemapItem);\n\n    colourItemGrey(middleAddressBlocksItem);\n\n    for (QSharedPointer<MemoryBlockBase> memoryBlock : *memoryMap->getMemoryBlocks())\n    {\n        QSharedPointer<AddressBlock> addressBlock = memoryBlock.dynamicCast<AddressBlock>();\n\n        if (addressBlock)\n        {\n            if (referenceCounter_->countReferenceInAddressBlock(getTargetID(), addressBlock) > 0)\n            {\n                createReferencesForSingleAddressBlock(addressBlock, middleAddressBlocksItem);\n\n            }\n        }\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: ComponentParameterReferenceTree::createReferencesForSingleAddressBlock()\n//-----------------------------------------------------------------------------\nvoid ComponentParameterReferenceTree::createReferencesForSingleAddressBlock(\n    QSharedPointer<AddressBlock> addressBlock, QTreeWidgetItem* middleAddressBlocksItem)\n{\n    QTreeWidgetItem* addressBlockItem = createMiddleItem(addressBlock->name(),\n        middleAddressBlocksItem);\n    QString targetID = getTargetID();\n\n    if (referenceCounter_->countReferencesInAddressBlockValues(targetID, addressBlock) > 0)\n    {\n        createItemsForAddressBlock(addressBlock, addressBlockItem);\n    }\n\n    if (referenceCounter_->countReferencesInRegisters(targetID, addressBlock->getRegisterData()) > 0)\n    {\n        createReferencesForRegisters(targetID, addressBlock->getRegisterData(), addressBlockItem);\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: ComponentParameterReferenceTree::createReferencesForRegisters()\n//-----------------------------------------------------------------------------\nvoid ComponentParameterReferenceTree::createReferencesForRegisters(QString const& targetID,\n    QSharedPointer<QList<QSharedPointer<RegisterBase>>> registerData, QTreeWidgetItem* parentItem)\n{\n    if (referenceCounter_->countReferencesInRegisters(targetID, registerData) > 0)\n    {\n        QTreeWidgetItem* registersItem = createMiddleItem(\"Registers\", parentItem);\n        colourItemGrey(registersItem);\n\n        for (auto baseRegister : *registerData)\n        {\n            QSharedPointer<Register> targetRegister = baseRegister.dynamicCast<Register>();\n            if (targetRegister && referenceCounter_->countReferencesInSingleRegister(targetID, targetRegister) > 0)\n            {\n                createReferencesForSingleRegister(targetRegister, registersItem);\n            }\n        }\n    }\n    if (referenceCounter_->countReferencesInRegisterFiles(targetID, registerData) > 0)\n    {\n        QTreeWidgetItem* registerFileItem = createMiddleItem(\"Register Files\", parentItem);\n        colourItemGrey(registerFileItem);\n        for (auto baseRegister : *registerData)\n        {\n            QSharedPointer<RegisterFile> targetFile = baseRegister.dynamicCast<RegisterFile>();\n            if (targetFile && referenceCounter_->countReferencesInSingleRegisterFile(targetID, targetFile) > 0)\n            {\n                createReferencesForSingleRegisterFile(targetFile, registerFileItem);\n            }\n        }\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: ComponentParameterReferenceTree::createReferencesForSingleRegister()\n//-----------------------------------------------------------------------------\nvoid ComponentParameterReferenceTree::createReferencesForSingleRegister(QSharedPointer<Register> targetRegister,\n    QTreeWidgetItem* parentItem)\n{\n    QTreeWidgetItem* registerItem = createMiddleItem(targetRegister->name(), parentItem);\n    QString targetID = getTargetID();\n\n    createItemsForRegister(targetRegister, registerItem);\n\n    if (referenceCounter_->countReferencesInFields(targetID, targetRegister->getFields()) > 0)\n    {\n        QTreeWidgetItem* fieldsItem = createMiddleItem(\"Fields\", registerItem);\n        colourItemGrey(fieldsItem);\n\n        for (QSharedPointer<Field> registerField : *targetRegister->getFields())\n        {\n            if (referenceCounter_->countReferencesInSingleField(targetID, registerField) > 0)\n            {\n                QTreeWidgetItem* singleFieldItem = createMiddleItem(registerField->name(), fieldsItem);\n                createItemsForField(registerField, singleFieldItem);\n            }\n        }\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: ComponentParameterReferenceTree::createReferencesForSingleRegisterFile()\n//-----------------------------------------------------------------------------\nvoid ComponentParameterReferenceTree::createReferencesForSingleRegisterFile(\n    QSharedPointer<RegisterFile> targetFile, QTreeWidgetItem* parentItem)\n{\n    QTreeWidgetItem* fileItem = createMiddleItem(targetFile->name(), parentItem);\n    QString targetID = getTargetID();\n\n    createItemsForRegisterFile(targetFile, fileItem);\n\n    createReferencesForRegisters(targetID, targetFile->getRegisterData(), fileItem);\n}\n\n//-----------------------------------------------------------------------------\n// Function: ComponentParameterReferenceTree::createReferencesForBusInterfaces()\n//-----------------------------------------------------------------------------\nvoid ComponentParameterReferenceTree::createReferencesForBusInterfaces()\n{\n    QTreeWidgetItem* topBusInterfaceItem = createTopItem(\"Bus Interfaces\");\n    QString targetID = getTargetID();\n\n    for (QSharedPointer<BusInterface> busInterface : *component_->getBusInterfaces())\n    {\n        if (referenceCounter_->countReferencesInSingleBusInterface(targetID, busInterface) > 0)\n        {\n            QTreeWidgetItem* busInterfaceItem = createMiddleItem(busInterface->name(), topBusInterfaceItem);\n\n            if (busInterface->getMirroredSlave())\n            {\n                QSharedPointer<MirroredTargetInterface> mirrorSlave(busInterface->getMirroredSlave());\n\n                if (referenceCounter_->countReferencesInMirroredSlaveInterface(targetID, mirrorSlave) > 0)\n                {\n                    QTreeWidgetItem* mirroredInterfaceItem =\n                        createMiddleItem(\"Mirrored Slave Interface\", busInterfaceItem);\n                    colourItemGrey(mirroredInterfaceItem);\n\n                    for (QSharedPointer<MirroredTargetInterface::RemapAddress> remapAddress :\n                        *mirrorSlave->getRemapAddresses())\n                    {\n                        if (referenceCounter_->countReferencesInRemapAddress(targetID, remapAddress) > 0)\n                        {\n                            createItem(\"Remap Address\", remapAddress->remapAddress_, mirroredInterfaceItem);\n                        }\n                    }\n\n                    if (mirrorSlave->getRange().contains(targetID))\n                    {\n                        createItem(\"Range\", mirrorSlave->getRange(), mirroredInterfaceItem);\n                    }\n                }\n            }\n\n            if (busInterface->getMaster())\n            {\n                QSharedPointer<InitiatorInterface> master(busInterface->getMaster());\n\n                if (referenceCounter_->countReferencesInMasterInterface(targetID, master) > 0)\n                {\n                    if (busInterface->getInterfaceMode() == General::MASTER)\n                    {\n                        QTreeWidgetItem* masterInterfaceItem = createMiddleItem(\n                            \"Master Interface\", busInterfaceItem);\n                        colourItemGrey(masterInterfaceItem);\n\n                        createItem(\"Base Address\", master->getBaseAddress(), masterInterfaceItem);\n                    }\n                    else\n                    {\n                        QTreeWidgetItem* masterInterfaceItem = createMiddleItem(\n                            \"Mirrored Master Interface\", busInterfaceItem);\n                        colourItemGrey(masterInterfaceItem);\n\n                        createItem(\"Base Address\", master->getBaseAddress(), masterInterfaceItem);\n                    }\n                }\n            }\n\n            if (referenceCounter_->countReferencesInParameters(targetID, busInterface->getParameters()) > 0)\n            {\n                QTreeWidgetItem* parametersItem = createMiddleItem(QString(\"Parameters\"), busInterfaceItem);\n                colourItemGrey(parametersItem);\n                createParameterReferences(busInterface->getParameters(), parametersItem);\n            }\n        }\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: ComponentParameterReferenceTree::createReferencesForRemapStates()\n//-----------------------------------------------------------------------------\nvoid ComponentParameterReferenceTree::createReferencesForRemapStates()\n{\n    QTreeWidgetItem* topRemapStatesItem = createTopItem(\"Remap States\");\n    QString targetID = getTargetID();\n\n    for (QSharedPointer<RemapState> remapState : *component_->getRemapStates())\n    {\n        if (referenceCounter_->countReferencesInSingleRemapState(targetID, remapState) > 0)\n        {\n            QTreeWidgetItem* remapStateItem = createMiddleItem(remapState->name(), topRemapStatesItem);\n\n            QTreeWidgetItem* remapPortsItem = createMiddleItem(\"Remap Ports\", remapStateItem);\n            colourItemGrey(remapPortsItem);\n\n            for (QSharedPointer<RemapPort> remapPort : *remapState->getRemapPorts())\n            {\n                if (referenceCounter_->countReferencesInSingleRemapPort(targetID, remapPort) > 0)\n                {\n                    QString itemName = remapPort->getPortNameRef();\n\n                    if (!remapPort->getPortIndex().isEmpty())\n                    {\n                        itemName.append(\"[\" + remapPort->getPortIndex() + \"]\");\n                    }\n                    createItem(itemName, remapPort->getValue(), remapPortsItem);\n                }\n            }\n        }\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: ComponentParameterReferenceTree::createReferencesForModes()\n//-----------------------------------------------------------------------------\nvoid ComponentParameterReferenceTree::createReferencesForModes()\n{\n    QTreeWidgetItem* topModesItem = createTopItem(\"Modes\");\n    QString targetID = getTargetID();\n\n    for (auto const& mode : *component_->getModes())\n    {\n        if (referenceCounter_->countReferencesInSingleMode(targetID, mode) > 0)\n        {\n            QTreeWidgetItem* modeItem = createMiddleItem(mode->name(), topModesItem);\n\n            if (referenceCounter_->countReferencesInModeCondition(targetID, mode->getCondition()) > 0)\n            {\n                createItem(QStringLiteral(\"Condition\"), mode->getCondition(), modeItem);\n            }\n\n            createPortSliceItems(targetID, mode, modeItem);\n\n            createFieldSliceItems(targetID, mode, modeItem);\n        }\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: ComponentParameterReferenceTree::createPortSliceItems()\n//-----------------------------------------------------------------------------\nvoid ComponentParameterReferenceTree::createPortSliceItems(QString const& targetID,\n    QSharedPointer<Mode> mode, QTreeWidgetItem* parentItem)\n{\n    if (referenceCounter_->countReferencesInPortSlices(targetID, mode) == 0)\n    {\n        return;\n    }\n\n    QTreeWidgetItem* portsItem = createMiddleItem(QStringLiteral(\"Condition Ports\"), parentItem);\n    colourItemGrey(portsItem);\n\n    for (auto const& portSlice : *mode->getPortSlices())\n    {\n        if (referenceCounter_->countReferencesInSinglePortSlice(targetID, portSlice) > 0)\n        {\n            QTreeWidgetItem* sliceItem = createMiddleItem(portSlice->name(), parentItem);\n\n            if (portSlice->getLeftRange().contains(targetID))\n            {\n                createItem(QStringLiteral(\"Left bound\"), portSlice->getLeftRange(), sliceItem);\n            }\n\n            if (portSlice->getRightRange().contains(targetID))\n            {\n                createItem(QStringLiteral(\"Right bound\"), portSlice->getRightRange(), sliceItem);\n            }\n        }\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: ComponentParameterReferenceTree::createFieldSliceItems()\n//-----------------------------------------------------------------------------\nvoid ComponentParameterReferenceTree::createFieldSliceItems(QString const& targetID,\n    QSharedPointer<Mode> mode, QTreeWidgetItem* parentItem)\n{\n    if (referenceCounter_->countReferencesInFieldSlices(targetID, mode) == 0)\n    {\n        return;\n    }\n\n    QTreeWidgetItem* fieldsItem = createMiddleItem(QStringLiteral(\"Condition Fields\"), parentItem);\n    colourItemGrey(fieldsItem);\n\n    for (auto const& fieldSlice : *mode->getFieldSlices())\n    {\n        if (referenceCounter_->countReferencesInSingleFieldSlice(targetID, fieldSlice) > 0)\n        {\n            QTreeWidgetItem* sliceItem = createMiddleItem(fieldSlice->name(), parentItem);\n\n            if (fieldSlice->getLeft().contains(targetID))\n            {\n                createItem(QStringLiteral(\"Leftmost bit\"), fieldSlice->getLeft(), sliceItem);\n            }\n\n            if (fieldSlice->getRight().contains(targetID))\n            {\n                createItem(QStringLiteral(\"Rightmost bit\"), fieldSlice->getRight(), sliceItem);\n            }\n        }\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: ComponentParameterReferenceTree::createReferencesForIndirectInterfaces()\n//-----------------------------------------------------------------------------\nvoid ComponentParameterReferenceTree::createReferencesForIndirectInterfaces()\n{\n    QTreeWidgetItem* topIndirectInterfacesItem = createTopItem(\"Indirect Interfaces\");\n    QString targetID = getTargetID();\n\n    for (auto indirectInterface : *component_->getIndirectInterfaces())\n    {\n        if (referenceCounter_->countRefrencesInSingleIndirectInterface(targetID, indirectInterface) > 0)\n        {\n            QTreeWidgetItem* interfaceItem = createMiddleItem(indirectInterface->name(), topIndirectInterfacesItem);\n\n            QTreeWidgetItem* parametersItem = createMiddleItem(QLatin1String(\"Parameters\"), interfaceItem);\n            colourItemGrey(parametersItem);\n            createParameterReferences(indirectInterface->getParameters(), parametersItem);\n        }\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: ComponentParameterReferenceTree::createReferencesForCpus()\n//-----------------------------------------------------------------------------\nvoid ComponentParameterReferenceTree::createReferencesForCpus()\n{\n    QTreeWidgetItem* topCpusItem = createTopItem(\"CPUs\");\n    QString targetID = getTargetID();\n\n    for (auto cpu : *component_->getCpus())\n    {\n        if (referenceCounter_->countReferencesInSingleCpu(targetID, cpu) > 0)\n        {\n            QTreeWidgetItem* cpuItem = createMiddleItem(cpu->name(), topCpusItem);\n\n            if (cpu->getWidth().contains(targetID))\n            {\n                createItem(\"Width\", cpu->getWidth(), cpuItem);\n            }\n            if (cpu->getRange().contains(targetID))\n            {\n                createItem(\"Range\", cpu->getRange(), cpuItem);\n            }\n            if (cpu->getAddressUnitBits().contains(targetID))\n            {\n                createItem(\"Address unit bits\", cpu->getAddressUnitBits(), cpuItem);\n            }\n\n            if (referenceCounter_->countReferencesInRegions(targetID, cpu->getRegions()) > 0)\n            {\n                QTreeWidgetItem* regionsItem = createMiddleItem(QStringLiteral(\"Regions\"), cpuItem);\n                colourItemGrey(regionsItem);\n\n                for (auto const& region : *cpu->getRegions())\n                {\n                    if (referenceCounter_->countReferencesInSingleRegion(targetID, region) > 0)\n                    {\n                        createItemsForRegion(region, regionsItem);\n                    }\n                }\n            }\n        }\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: ComponentParameterReferenceTree::createItemsForRegion()\n//-----------------------------------------------------------------------------\nvoid ComponentParameterReferenceTree::createItemsForRegion(QSharedPointer<Region> region, QTreeWidgetItem* parent)\n{\n    QString targetID = getTargetID();\n\n    QTreeWidgetItem* regionItem = createMiddleItem(region->name(), parent);\n\n    if (region->getAddressOffset().contains(targetID))\n    {\n        createItem(\"Offset\", region->getAddressOffset(), regionItem);\n    }\n    if (region->getRange().contains(targetID))\n    {\n        createItem(\"Range\", region->getRange(), regionItem);\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: ComponentParameterReferenceTree::createReferencesForPowerDomains()\n//-----------------------------------------------------------------------------\nvoid ComponentParameterReferenceTree::createReferencesForPowerDomains()\n{\n    auto topPowerDomainsItem = createTopItem(\"Power domains\");\n    auto targetID = getTargetID();\n\n    for (auto domain : *component_->getPowerDomains())\n    {\n        if (referenceCounter_->countReferencesInSinglePowerDomain(targetID, domain) > 0)\n        {\n            QTreeWidgetItem* domainItem = createMiddleItem(domain->name(), topPowerDomainsItem);\n\n            createItem(\"Always on\", domain->getAlwaysOn(), domainItem);\n        }\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: ComponentParameterReferenceTree::createItemsForPort()\n//-----------------------------------------------------------------------------\nvoid ComponentParameterReferenceTree::createItemsForPort(QSharedPointer<Port> port, QTreeWidgetItem* parent)\n{\n    QString targetID = getTargetID();\n\n    if (port->getLeftBound().contains(targetID))\n    {\n        createItem(\"Left Bound\", port->getLeftBound(), parent);\n    }\n    if (port->getRightBound().contains(targetID))\n    {\n        createItem(\"Right Bound\", port->getRightBound(), parent);\n    }\n    if (port->getDefaultValue().contains(targetID))\n    {\n        createItem(\"Default Value\", port->getDefaultValue(), parent);\n    }\n    if (port->getArrayLeft().contains(targetID))\n    {\n        createItem(\"Array Left\", port->getArrayLeft(), parent);\n    }\n    if (port->getArrayRight().contains(targetID))\n    {\n        createItem(\"Array Right\", port->getArrayRight(), parent);\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: ComponentParameterReferenceTree::createItemsForRegister()\n//-----------------------------------------------------------------------------\nvoid ComponentParameterReferenceTree::createItemsForRegister(QSharedPointer<Register> targetRegister,\n    QTreeWidgetItem* parent)\n{\n    QString targetID = getTargetID();\n\n    createItemsForBaseRegister(targetRegister, parent);\n    if (targetRegister->getSize().contains(targetID))\n    {\n        createItem(\"Size\", targetRegister->getSize(), parent);\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: ComponentParameterReferenceTree::createItemsForBaseRegister()\n//-----------------------------------------------------------------------------\nvoid ComponentParameterReferenceTree::createItemsForBaseRegister(QSharedPointer<RegisterBase> baseRegister,\n    QTreeWidgetItem* parent)\n{\n    QString targetID = getTargetID();\n\n    if (baseRegister->getAddressOffset().contains(targetID))\n    {\n        createItem(\"Offset\", baseRegister->getAddressOffset(), parent);\n    }\n    if (baseRegister->getDimension().contains(targetID))\n    {\n        createItem(\"Dimension\", baseRegister->getDimension(), parent);\n    }\n    if (baseRegister->getIsPresent().contains(targetID))\n    {\n        createItem(\"Is present\", baseRegister->getIsPresent(), parent);\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: ComponentParameterReferenceTree::createItemsForRegisterFile()\n//-----------------------------------------------------------------------------\nvoid ComponentParameterReferenceTree::createItemsForRegisterFile(QSharedPointer<RegisterFile> targetFile,\n    QTreeWidgetItem* parent)\n{\n    QString targetID = getTargetID();\n\n    createItemsForBaseRegister(targetFile, parent);\n    if (targetFile->getRange().contains(targetID))\n    {\n        createItem(\"Range\", targetFile->getRange(), parent);\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: ComponentParameterReferenceTree::createItemsForMemoryMap()\n//-----------------------------------------------------------------------------\nvoid ComponentParameterReferenceTree::createItemsForMemoryMap(QSharedPointer<MemoryMapBase> targetMap,\n    QTreeWidgetItem* parent)\n{\n    QString targetID = getTargetID();\n\n    if (targetMap->getIsPresent().contains(targetID))\n    {\n        createItem(\"Is Present\", targetMap->getIsPresent(), parent);\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: ComponentParameterReferenceTree::createItemsForAddressBlock()\n//-----------------------------------------------------------------------------\nvoid ComponentParameterReferenceTree::createItemsForAddressBlock(QSharedPointer<AddressBlock> targetAddressBlock,\n    QTreeWidgetItem* parent)\n{\n    QString targetID = getTargetID();\n\n    if (targetAddressBlock->getBaseAddress().contains(targetID))\n    {\n        createItem(\"Base Address\", targetAddressBlock->getBaseAddress(), parent);\n    }\n    if (targetAddressBlock->getRange().contains(targetID))\n    {\n        createItem(\"Range\", targetAddressBlock->getRange(), parent);\n    }\n    if (targetAddressBlock->getWidth().contains(targetID))\n    {\n        createItem(\"Width\", targetAddressBlock->getWidth(), parent);\n    }\n    if (targetAddressBlock->getIsPresent().contains(targetID))\n    {\n        createItem(\"Is Present\", targetAddressBlock->getIsPresent(), parent);\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: ComponentParameterReferenceTree::createItemsForField()\n//-----------------------------------------------------------------------------\nvoid ComponentParameterReferenceTree::createItemsForField(QSharedPointer<Field> targetField, QTreeWidgetItem* parent)\n{\n    QString targetID = getTargetID();\n\n    if (targetField->getBitOffset().contains(targetID))\n    {\n        createItem(\"Offset\", targetField->getBitOffset(), parent);\n    }\n    if (targetField->getBitWidth().contains(targetID))\n    {\n        createItem(\"Width\", targetField->getBitWidth(), parent);\n    }\n    if (targetField->getIsPresent().contains(targetID))\n    {\n        createItem(\"Is Present\", targetField->getIsPresent(), parent);\n    }\n    if (referenceCounter_->countReferencesInFieldResets(targetID, targetField->getResets()) > 0)\n    {\n        createItemsForFieldResets(targetID, targetField->getResets(), parent);\n    }\n\n    if (targetField->getWriteConstraint())\n    {\n        if (targetField->getWriteConstraint()->getMinimum().contains(targetID))\n        {\n            createItem(\"Write constraint minimum\", targetField->getWriteConstraint()->getMinimum(), parent);\n        }\n        if (targetField->getWriteConstraint()->getMaximum().contains(targetID))\n        {\n            createItem(\"Write constraint maximum\", targetField->getWriteConstraint()->getMaximum(), parent);\n        }\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: ComponentParameterReferenceTree::createItemsForFieldResets()\n//-----------------------------------------------------------------------------\nvoid ComponentParameterReferenceTree::createItemsForFieldResets(QString const& targetID,\n    QSharedPointer<QList<QSharedPointer<FieldReset>>> fieldResets, QTreeWidgetItem* fieldItem)\n{\n    QTreeWidgetItem* resetsItem = createMiddleItem(\"Resets\", fieldItem);\n    colourItemGrey(resetsItem);\n\n    for (auto singleReset : *fieldResets)\n    {\n        if (referenceCounter_->countReferencesInSingleFieldReset(targetID, singleReset) > 0)\n        {\n            QString resetType = singleReset->getResetTypeReference();\n            if (resetType.isEmpty())\n            {\n                resetType = QLatin1String(\"HARD\");\n            }\n\n            QTreeWidgetItem* singleResetItem = createMiddleItem(resetType, resetsItem);\n\n            if (singleReset->getResetValue().contains(targetID))\n            {\n                createItem(\"Reset value\", singleReset->getResetValue(), singleResetItem);\n            }\n            if (singleReset->getResetMask().contains(targetID))\n            {\n                createItem(\"Reset mask\", singleReset->getResetMask(), singleResetItem);\n            }\n        }\n    }\n}\n"
  },
  {
    "path": "editors/ComponentEditor/parameterReferenceTree/ComponentParameterReferenceTree.h",
    "content": "//-----------------------------------------------------------------------------\n// File: ComponentParameterReferenceTree.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 28.09.2018\n//\n// Description:\n// Tree widget for displaying references to a parameter within a component.\n//-----------------------------------------------------------------------------\n\n#ifndef COMPONENTPARAMETERREFERENCETREE_H\n#define COMPONENTPARAMETERREFERENCETREE_H\n\n#include <KactusAPI/include/ExpressionFormatter.h>\n#include <editors/ComponentEditor/parameterReferenceTree/ParameterReferenceTree.h>\n\n#include <QSharedPointer>\n\nclass Component;\nclass ModuleParameter;\nclass FileSet;\nclass FileBuilder;\nclass File;\nclass BuildCommand;\nclass AddressSpace;\nclass Segment;\nclass ComponentInstantiation;\nclass DesignConfigurationInstantiation;\nclass DesignInstantiation;\nclass Port;\nclass MemoryMapBase;\nclass MemoryMap;\nclass MemoryRemap;\nclass Region;\nclass AddressBlock;\nclass RegisterBase;\nclass Register;\nclass RegisterFile;\nclass Field;\nclass FieldReset;\nclass BusInterface;\nclass MirroredSlaveInterface;\nclass MasterInterface;\nclass Mode;\nclass RemapState;\nclass RemapPort;\nclass ComponentParameterReferenceCounter;\n\n//-----------------------------------------------------------------------------\n//! Tree widget for displaying references to a parameter within a component.\n//-----------------------------------------------------------------------------\nclass ComponentParameterReferenceTree : public ParameterReferenceTree\n{\n    Q_OBJECT\npublic:\n\n    /*!\n     *   The constructor.\n     *\n     *    @param [in] component               The component whose references to display.\n     *    @param [in] expressionFormatter     Formatter for expressions.\n     *    @param [in] referenceCounter        Calculator for parameter references.\n     *    @param [in] parent                  The parent widget.\n     */\n    ComponentParameterReferenceTree(QSharedPointer<Component> component,\n        QSharedPointer<ExpressionFormatter> expressionFormatter,\n        QSharedPointer<ComponentParameterReferenceCounter> referenceCounter, QWidget *parent = 0);\n\n\t/*!\n     *  The destructor.\n     */\n    virtual ~ComponentParameterReferenceTree() = default;\n\n    // Disable copying.\n    ComponentParameterReferenceTree(ComponentParameterReferenceTree const& rhs) = delete;\n    ComponentParameterReferenceTree& operator=(ComponentParameterReferenceTree const& rhs) = delete;\n\n    /*!\n     *  Set a new component.\n     *\n     *    @param [in] newComponent    The selected component.\n     */\n    void setComponent(QSharedPointer<Component> newComponent);\n\nprivate:\n\n    /*!\n     *  Setup the reference tree.\n     */\n    void setupTree();\n\n    /*!\n     *  Get the parameter reference calculator.\n     */\n    QSharedPointer<ParameterReferenceCounter> getReferenceCounter() const;\n\n    /*!\n     *  Create references for file sets.\n     */\n    void createReferencesForFileSets();\n\n    /*!\n     *  Create references for file builders.\n     *\n     *    @param [in] fileBuilders    The selected file builders.\n     *    @param [in] parentItem      The parent item of the file builders item.\n     */\n    void createReferencesForFileBuilders(QSharedPointer<QList<QSharedPointer<FileBuilder> > > fileBuilders,\n        QTreeWidgetItem* parentItem);\n\n    /*!\n     *  Create references for a single file builder.\n     *\n     *    @param [in] fileBuilder     The selected file builder.\n     *    @param [in] parentItem      The parent item.\n     */\n    void createReferencesForSingleFileBuilder(QSharedPointer<FileBuilder> fileBuilder, QTreeWidgetItem* parentItem);\n\n    /*!\n     *  Create references from the selected files.\n     *\n     *    @param [in] fileList    A list of files with possible references.\n     *    @param [in] parentItem  The parent item.\n     */\n    void createReferencesForFiles(QSharedPointer<QList<QSharedPointer<File> > > fileList,\n        QTreeWidgetItem* parentItem);\n\n    /*!\n     *  Create references for a single file.\n     *\n     *    @param [in] selectedFile    The selected file.\n     *    @param [in] parentItem      The parent item.\n     */\n    void createReferencesForSingleFile(QSharedPointer<File> selectedFile, QTreeWidgetItem* parentItem);\n\n    /*!\n     *  Create the references for model parameters.\n     *\n     *    @param [in] parameters  The model parameters to create references for.\n     *    @param [in] parentItem  The parent item for references.\n     */\n    void createReferencesForModuleParameters(QSharedPointer<QList<QSharedPointer<ModuleParameter> > > parameters,\n        QTreeWidgetItem* parentItem);\n\n    /*!\n     *  Create references for instantiations.\n     */\n    void createReferencesForInstantiations();\n\n    /*!\n     *  Create references for component instantiations.\n     *\n     *    @param [in] topInstantiationsItem   The parent tree item.\n     */\n    void createReferencesForComponentInstantiations(QTreeWidgetItem* topInstantiationsItem);\n\n    /*!\n     *  Create references for design configuration instantiations.\n     *\n     *    @param [in] topInstantiationsItem   The parent tree item.\n     */\n    void createReferencesForDesignConfigurationInstantiations(QTreeWidgetItem* topInstantiationsItem);\n\n    /*!\n     *  Create references for design instantiations.\n     *\n     *    @param [in] topInstantiationsItem   The parent tree item.\n     */\n    void createReferencesForDesignInstantiations(QTreeWidgetItem* topInstantiationsItem);\n\n    /*!\n     *  Create the references for ports.\n     */\n    void createReferencesForPorts();\n\n    /*!\n     *  Create the references for address spaces.\n     */\n    void createReferencesForAddressSpaces();\n\n    /*!\n     *  Create the references for a single address space.\n     *\n     *    @param [in] addressSpace    The address space to create references for.\n     *    @param [in] parent          The parent tree item of the new address space item.\n     */\n    void createItemsForAddressSpace(QSharedPointer<AddressSpace> addressSpace, QTreeWidgetItem* parent);\n    \n    /*!\n     *  Create the references for segments within an address space.\n     *\n     *    @param [in] addressSpace    The address space to create references for.\n     *    @param [in] parent          The parent tree item of the new segment items.\n     */\n    void createReferencesForSegments(QSharedPointer<AddressSpace> addressSpace, QTreeWidgetItem* parent);\n        \n    /*!\n     *  Create the references a segment within an address space.\n     *\n     *    @param [in] segment    The segment to create references for.\n     *    @param [in] parent     The parent tree item of the segment items.\n     */\n    void createItemsForSegment(QSharedPointer<Segment> segment, QTreeWidgetItem* parent);\n\n    /*!\n     *  Create the references for memory maps.\n     */\n    void createReferencesForMemoryMaps();\n\n    /*!\n     *  Create the references for a single abstract memory map.\n     *\n     *    @param [in] memoryMap           The memory map / memory remap.\n     *    @param [in] topMemoryMapItem    The parent tree item of the new memory map tree item.\n     */\n    void createReferencesForSingleMemoryMap(QSharedPointer<MemoryMapBase> memoryMap,\n        QTreeWidgetItem* memoryRemapItem);\n\n    /*!\n     *  Create the references for a single address block.\n     *\n     *    @param [in] addressBlock                The address block.\n     *    @param [in] middleAddressBlocksItem     The parent tree item of the new address block tree item.\n     */\n    void createReferencesForSingleAddressBlock(QSharedPointer<AddressBlock> addressBlock,\n        QTreeWidgetItem* middleAddressBlocksItem);\n\n    /*!\n     *  Create the references for registers.\n     *\n     *    @param [in] targetID        The selected parameter ID.\n     *    @param [in] registerData    Selected register data.\n     *    @param [in] parentItem      Parent tree item of the new register items.\n     */\n    void createReferencesForRegisters(QString const& targetID,\n        QSharedPointer<QList<QSharedPointer<RegisterBase> > > registerData, QTreeWidgetItem* parentItem);\n\n    /*!\n     *  Create the references for a single register.\n     *\n     *    @param [in] targetRegister  The register.\n     *    @param [in] parentItem      The parent tree item of the new register tree item.\n     */\n    void createReferencesForSingleRegister(QSharedPointer<Register> targetRegister, QTreeWidgetItem* parentItem);\n\n    /*!\n     *  Create the references for a single register file\n     *\n     *    @param [in] targetFile  The selected register file.\n     *    @param [in] parentItem  Parent tree item of the new register file tree item.\n     */\n    void createReferencesForSingleRegisterFile(QSharedPointer<RegisterFile> targetFile,\n        QTreeWidgetItem* parentItem);\n\n    /*!\n     *  Create references for bus interfaces.\n     */\n    void createReferencesForBusInterfaces();\n\n    /*!\n     *  Create references for remap states.\n     */\n    void createReferencesForRemapStates();\n\n    /*!\n     *  Create references for modes.\n     */\n    void createReferencesForModes();\n\n    /*!\n     *  Create references for mode port slices.\n     */\n    void createPortSliceItems(QString const& targetID, QSharedPointer<Mode> mode, QTreeWidgetItem* parentItem);\n\n    /*!\n     *  Create references for mode field slices.\n     */\n    void createFieldSliceItems(QString const& targetID, QSharedPointer<Mode> mode,\n        QTreeWidgetItem* parentItem);\n\n    /*!\n     *  Create references for indirect interfaces.\n     */\n    void createReferencesForIndirectInterfaces();\n\n    /*!\n     *  Create references for CPUs.\n     */\n    void createReferencesForCpus();\n\n    /*!\n     *  Create tree items for a region that is referencing this parameter.\n     *\n     *    @param [in] region      The referencing region.\n     *    @param [in] parent      The parent of the upcoming item.\n     */\n    void createItemsForRegion(QSharedPointer<Region> region, QTreeWidgetItem* parent);\n        \n    /*!\n     *  Create references for power domains.\n     */\n    void createReferencesForPowerDomains();\n\n    /*!\n     *  Create tree items for a port that is referencing this parameter.\n     *\n     *    @param [in] port        The referencing port.\n     *    @param [in] parent      The parent of the upcoming item.\n     */\n    void createItemsForPort(QSharedPointer<Port> port, QTreeWidgetItem* parent);\n\n    /*!\n     *  Create tree items for a memory map that is referencing this parameter.\n     *\n     *    @param [in] targetMap   The referencing memory map.\n     *    @param [in] parent      The parent of the upcoming item.\n     */\n    void createItemsForMemoryMap(QSharedPointer<MemoryMapBase> targetMap, QTreeWidgetItem* parent);\n\n    /*!\n     *  Create tree items for an address block that is referencing this parameter.\n     *\n     *    @param [in] targetAddressBlock  The referencing address block.\n     *    @param [in] parent              The parent for the upcoming item.\n     */\n    void createItemsForAddressBlock(QSharedPointer<AddressBlock> targetAddressBlock, QTreeWidgetItem* parent);\n\n    /*!\n     *  Create tree items for a register that is referencing this parameter.\n     *\n     *    @param [in] targetRegister  The referencing register.\n     *    @param [in] parent          The parent of the upcoming item.\n     */\n    void createItemsForRegister(QSharedPointer<Register> targetRegister, QTreeWidgetItem* parent);\n\n    /*!\n     *  Create tree items for a base register that is referencing this parameter.\n     *\n     *    @param [in] baseRegister    The referencing base register.\n     *    @param [in] parent          The parent of the upcoming item.\n     */\n    void createItemsForBaseRegister(QSharedPointer<RegisterBase> baseRegister, QTreeWidgetItem* parent);\n\n    /*!\n     *  Create tree items for a register file that is referencing this parameter.\n     *\n     *    @param [in] targetFile  The referencing register file.\n     *    @param [in] parent      The parent of the upcoming item.\n     */\n    void createItemsForRegisterFile(QSharedPointer<RegisterFile> targetFile, QTreeWidgetItem* parent);\n\n    /*!\n     *  Create tree items for a register field that is referencing this parameter.\n     *\n     *    @param [in] targetField     The referencing register field.\n     *    @param [in] parent          The parent of the new item.\n     */\n    void createItemsForField(QSharedPointer<Field> targetField, QTreeWidgetItem* parent);\n\n    /*!\n     *  Create tree items for field resets that is referencing the selected parameter.\n     *\n     *    @param [in] targetID        ID of the selected parameter.\n     *    @param [in] fieldResets     Reset values of the selected field.\n     *    @param [in] fieldItem       The parent field item for the reset items.\n     */\n    void createItemsForFieldResets(QString const& targetID,\n        QSharedPointer<QList<QSharedPointer<FieldReset> > > fieldResets, QTreeWidgetItem* fieldItem);\n\n    //-----------------------------------------------------------------------------\n    // Data.\n    //-----------------------------------------------------------------------------\n\n    //! The component in which this id is situated.\n    QSharedPointer<Component> component_;\n\n    //! Reference calculator for component parameters.\n    QSharedPointer<ComponentParameterReferenceCounter> referenceCounter_;\n};\n\n#endif // COMPONENTPARAMETERREFERENCETREE_H\n"
  },
  {
    "path": "editors/ComponentEditor/parameterReferenceTree/ParameterReferenceTree.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ParameterReferenceTree.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Mikko Teuho\r\n// Date: 20.01.2015\r\n//\r\n// Description:\r\n// Tree widget for displaying references to a parameter.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"ParameterReferenceTree.h\"\r\n\r\n#include <common/KactusColors.h>\r\n\r\n#include <editors/ComponentEditor/referenceCounter/ParameterReferenceCounter.h>\r\n\r\n#include <IPXACTmodels/common/ConfigurableElementValue.h>\r\n#include <IPXACTmodels/common/Parameter.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ParameterReferenceTree::ParameterReferenceTree()\r\n//-----------------------------------------------------------------------------\r\nParameterReferenceTree::ParameterReferenceTree(QSharedPointer<ExpressionFormatter> formatter, QWidget* parent):\r\nQTreeWidget(parent),\r\ntargetID_(\"\"),\r\nexpressionFormatter_(formatter)\r\n{\r\n    QStringList labels;\r\n    labels << QStringList(\"Referencing elements\") << QString(\"Referencing expression\");\r\n    setHeaderLabels(labels);\r\n\r\n    setColumnCount(COLUMN_COUNT);\r\n    setColumnWidth(ITEM_NAME, 240);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ParameterReferenceTree::~ParameterReferenceTree()\r\n//-----------------------------------------------------------------------------\r\nParameterReferenceTree::~ParameterReferenceTree()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ParameterReferenceTree::getTargetID()\r\n//-----------------------------------------------------------------------------\r\nQString ParameterReferenceTree::getTargetID() const\r\n{\r\n    return targetID_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ParameterReferenceTree::openReferenceTree()\r\n//-----------------------------------------------------------------------------\r\nvoid ParameterReferenceTree::openReferenceTree(QString const& parameterID)\r\n{\r\n    targetID_ = parameterID;\r\n\r\n    clear();\r\n    setupTree();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ParameterReferenceTree::createParameterReferences()\r\n//-----------------------------------------------------------------------------\r\nvoid ParameterReferenceTree::createParameterReferences(\r\n    QSharedPointer<QList<QSharedPointer<Parameter> > > parameters, QTreeWidgetItem* parentItem)\r\n{\r\n    for (QSharedPointer<Parameter> parameter : *parameters)\r\n    {\r\n        if (getReferenceCounter()->countReferencesInSingleParameter(targetID_, parameter) > 0)\r\n        {\r\n            QTreeWidgetItem* parameterItem = createMiddleItem(parameter->name(), parentItem);\r\n            createItemsForParameter(parameter, parameterItem);\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ParameterReferenceTree::createReferencesForConfigurableElementValues()\r\n//-----------------------------------------------------------------------------\r\nvoid ParameterReferenceTree::createReferencesForConfigurableElementValues(\r\n    QSharedPointer<QList<QSharedPointer<ConfigurableElementValue> > > elements, QTreeWidgetItem* parent)\r\n{\r\n    QTreeWidgetItem* elementsItem = createMiddleItem(\"Configurable Element Values\", parent);\r\n    colourItemGrey(elementsItem);\r\n\r\n    for (QSharedPointer<ConfigurableElementValue> element : *elements)\r\n    {\r\n        if (getReferenceCounter()->countReferencesInSingleConfigurableElementValue(targetID_, element) > 0)\r\n        {\r\n            createItem(QString(\"Configurable Element\"), element->getConfigurableValue(), elementsItem);\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ParameterReferenceTree::createTopItem()\r\n//-----------------------------------------------------------------------------\r\nQTreeWidgetItem* ParameterReferenceTree::createTopItem(QString const& itemName)\r\n{\r\n    QTreeWidgetItem* newItem = new QTreeWidgetItem();\r\n    newItem->setText(ITEM_NAME, itemName);\r\n\r\n    addTopLevelItem(newItem);\r\n\r\n    colourItemGrey(newItem);\r\n\r\n    return newItem;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ParameterReferenceTree::createMiddleItem()\r\n//-----------------------------------------------------------------------------\r\nQTreeWidgetItem* ParameterReferenceTree::createMiddleItem(QString const& itemnName, QTreeWidgetItem* parent)\r\n{\r\n    QTreeWidgetItem* newItem = new QTreeWidgetItem(parent);\r\n    newItem->setText(ITEM_NAME, itemnName);\r\n\r\n    return newItem;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ParameterReferenceTree::createItemsForParameter()\r\n//-----------------------------------------------------------------------------\r\nvoid ParameterReferenceTree::createItemsForParameter(QSharedPointer<Parameter> parameter, QTreeWidgetItem* parent)\r\n{\r\n    if (parameter->getValue().contains(targetID_))\r\n    {\r\n        createItem(\"Value\", parameter->getValue(), parent);\r\n    }\r\n    if (parameter->getVectorLeft().contains(targetID_))\r\n    {\r\n        createItem(\"Bit Width Left\", parameter->getVectorLeft(), parent);\r\n    }\r\n    if (parameter->getVectorRight().contains(targetID_))\r\n    {\r\n        createItem(\"Bit Width Right\", parameter->getVectorRight(), parent);\r\n    }\r\n    if (parameter->getAttribute(\"kactus2:arrayLeft\").contains(targetID_))\r\n    {\r\n        createItem(\"Array Left\", parameter->getAttribute(\"kactus2:arrayLeft\"), parent);\r\n    }\r\n    if (parameter->getAttribute(\"kactus2:arrayRight\").contains(targetID_))\r\n    {\r\n        createItem(\"Array Right\", parameter->getAttribute(\"kactus2:arrayRight\"), parent);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ParameterReferenceTree::createItem()\r\n//-----------------------------------------------------------------------------\r\nvoid ParameterReferenceTree::createItem\r\n    (QString const& itemName, QString const& expression, QTreeWidgetItem* parent)\r\n{\r\n    QTreeWidgetItem* newItem = new QTreeWidgetItem(parent);\r\n    newItem->setText(ITEM_NAME, itemName);\r\n    newItem->setText(ITEM_EXPRESSION, expressionFormatter_->formatReferringExpression(expression));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ParameterReferenceTree::colourItemGrey()\r\n//-----------------------------------------------------------------------------\r\nvoid ParameterReferenceTree::colourItemGrey(QTreeWidgetItem* item)\r\n{\r\n    for (int columnIndex = 0; columnIndex < COLUMN_COUNT; ++columnIndex)\r\n    {\r\n        item->setBackground(columnIndex, KactusColors::STRONG_FIELD);\r\n    }\r\n}\r\n"
  },
  {
    "path": "editors/ComponentEditor/parameterReferenceTree/ParameterReferenceTree.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ParameterReferenceTree.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Mikko Teuho\r\n// Date: 20.01.2015\r\n//\r\n// Description:\r\n// Tree widget for displaying references to a parameter.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef PARAMETERREFERENCETREE_H\r\n#define PARAMETERREFERENCETREE_H\r\n\r\n#include <KactusAPI/include/ExpressionFormatter.h>\r\n\r\n#include <QTreeWidget>\r\n#include <QSharedPointer>\r\n\r\nclass Parameter;\r\nclass ConfigurableElementValue;\r\nclass ParameterReferenceCounter;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Tree widget for displaying references to a parameter.\r\n//-----------------------------------------------------------------------------\r\nclass ParameterReferenceTree : public QTreeWidget \r\n{\r\n    Q_OBJECT\r\npublic:\r\n\r\n    //! Enumeration of the columns.\r\n    enum COLUMNS\r\n    {\r\n        ITEM_NAME = 0,\r\n        ITEM_EXPRESSION,\r\n        COLUMN_COUNT\r\n    };\r\n    \r\n    /*!\r\n     *   The constructor.\r\n     *\r\n     *    @param [in] expressionFormatter     Formatter for expressions.\r\n     *    @param [in] parent                  The parent widget.\r\n     */\r\n    ParameterReferenceTree(QSharedPointer<ExpressionFormatter> formatter, QWidget* parent = 0);\r\n\r\n\t/*!\r\n     *  The destructor.\r\n     */\r\n    ~ParameterReferenceTree();\r\n\r\n    /*!\r\n     *  Setup the parameter reference tree for the selected parameter.\r\n     *\r\n     *    @param [in] parameterID     ID of the selected parameter.\r\n     */\r\n    void openReferenceTree(QString const& parameterID);\r\n\r\nprotected:\r\n\r\n    /*!\r\n     *  Get the ID of the selected parameter.\r\n     *\r\n     *    @return ID of the selected parameter.\r\n     */\r\n    QString getTargetID() const;\r\n\r\n    /*!\r\n     *  Create the references for parameters.\r\n     *\r\n     *    @param [in] parameters      List of parameters containing a reference.\r\n     *    @param [in] parentItem      The parent item for references.\r\n     */\r\n    void createParameterReferences(QSharedPointer<QList<QSharedPointer<Parameter> > > parameters,\r\n        QTreeWidgetItem* parentItem);\r\n\r\n    /*!\r\n     *  Create references for configurable element values.\r\n     *\r\n     *    @param [in] elements    List of the configurable element values.\r\n     *    @param [in] parent      The parent tree item.\r\n     */\r\n    void createReferencesForConfigurableElementValues(\r\n        QSharedPointer<QList<QSharedPointer<ConfigurableElementValue> > > elements, QTreeWidgetItem* parent);\r\n\r\n    /*!\r\n     *  Create a tree widget item to the top of the tree.\r\n     *\r\n     *    @param [in] itemName    The name of the upcoming item.\r\n     *\r\n     *    @return A pointer to the new tree item.\r\n     */\r\n    QTreeWidgetItem* createTopItem(QString const& itemName);\r\n\r\n    /*!\r\n     *  Create a tree item between two items.\r\n     *\r\n     *    @param [in] itemnName   The name of the upcoming item.\r\n     *    @param [in] parent      The parent of the upcoming item.\r\n     *\r\n     *    @return A pointer to the new tree item.\r\n     */\r\n    QTreeWidgetItem* createMiddleItem(QString const& itemnName, QTreeWidgetItem* parent);\r\n\r\n    /*!\r\n     *  Create tree items for a parameter that is referencing this parameter.\r\n     *\r\n     *    @param [in] parameter   The referencing parameter.\r\n     *    @param [in] parent      The parent of the upcoming item.\r\n     */\r\n    void createItemsForParameter(QSharedPointer<Parameter> parameter, QTreeWidgetItem* parent);\r\n\r\n    /*!\r\n     *  Create a referencing tree item.\r\n     *\r\n     *    @param [in] itemName        The name of the upcoming tree item.\r\n     *    @param [in] expression      The expression where the upcoming tree item references this parameter.\r\n     *    @param [in] parent          The parent of the upcoming item.\r\n     */\r\n    void createItem(QString const& itemName, QString const& expression, QTreeWidgetItem* parent);\r\n\r\n    /*!\r\n     *  Colour the background of the selected item grey.\r\n     *\r\n     *    @param [in] item    The selected item.\r\n     */\r\n    void colourItemGrey(QTreeWidgetItem* item);\r\n\r\nprivate:\r\n    \r\n\t// Disable copying.\r\n    ParameterReferenceTree(ParameterReferenceTree const& rhs);\r\n    ParameterReferenceTree& operator=(ParameterReferenceTree const& rhs);\r\n\r\n    /*!\r\n     *  Setup the reference tree.\r\n     */\r\n    virtual void setupTree() = 0;\r\n\r\n    /*!\r\n     *  Get the parameter reference calculator.\r\n     */\r\n    virtual QSharedPointer<ParameterReferenceCounter> getReferenceCounter() const = 0;\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! The parameter whose references are being searched for.\r\n    QString targetID_;\r\n\r\n    //! The formatter for the expressions.\r\n    QSharedPointer<ExpressionFormatter> expressionFormatter_;\r\n};\r\n\r\n#endif // PARAMETERREFERENCETREE_H\r\n"
  },
  {
    "path": "editors/ComponentEditor/parameterReferenceTree/ParameterReferenceTreeWindow.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: ParameterReferenceTreeWindow.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 29.09.2018\n//\n// Description:\n// Constructor for the window containing the parameter reference tree.\n//-----------------------------------------------------------------------------\n\n#include \"ParameterReferenceTreeWindow.h\"\n\n#include <KactusAPI/include/ExpressionFormatter.h>\n#include <editors/ComponentEditor/parameterReferenceTree/ParameterReferenceTree.h>\n\n#include <IPXACTmodels/Component/Component.h>\n\n#include <QHBoxLayout>\n#include <QVBoxLayout>\n\n//-----------------------------------------------------------------------------\n// Function: ParameterReferenceTreeConstructor::ParameterReferenceTreeConstructor()\n//-----------------------------------------------------------------------------\nParameterReferenceTreeWindow::ParameterReferenceTreeWindow(ParameterReferenceTree* parameterReferenceTree,\n    QWidget* parent):\nQDialog(parent),\nreferenceTree_(parameterReferenceTree),\nexpandAllButton_(new QPushButton(QString(tr(\"Expand All\")), this)),\ncollapseAllButton_(new QPushButton(QString(tr(\"Collapse All\")), this)),\ncloseButton_(new QPushButton(QString(tr(\"Close\")), this))\n{\n    setMinimumWidth(600);\n    setMinimumHeight(400);\n\n    setupLayout();\n    connectItems();\n\n    setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);\n\n    resize(width(), height());\n\n    hide();\n}\n\n//-----------------------------------------------------------------------------\n// Function: ParameterReferenceTreeWindow::~ParameterReferenceTreeWindow()\n//-----------------------------------------------------------------------------\nParameterReferenceTreeWindow::~ParameterReferenceTreeWindow()\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: ParameterReferenceTreeWindow::setupLayout()\n//-----------------------------------------------------------------------------\nvoid ParameterReferenceTreeWindow::setupLayout()\n{\n    QHBoxLayout* buttonLayout(new QHBoxLayout());\n    buttonLayout->addStretch(1);\n    buttonLayout->addWidget(expandAllButton_, 0, Qt::AlignRight);\n    buttonLayout->addWidget(collapseAllButton_, 0, Qt::AlignRight);\n    buttonLayout->addWidget(closeButton_, 0, Qt::AlignRight);\n\n    QVBoxLayout* overallLayout(new QVBoxLayout());\n    overallLayout->addWidget(referenceTree_);\n    overallLayout->addLayout(buttonLayout);\n    setLayout(overallLayout);\n}\n\n//-----------------------------------------------------------------------------\n// Function: ParameterReferenceTreeWindow::connectItems()\n//-----------------------------------------------------------------------------\nvoid ParameterReferenceTreeWindow::connectItems()\n{\n    connect(expandAllButton_, SIGNAL(clicked()), this, SLOT(onExpandAll()), Qt::UniqueConnection);\n    connect(collapseAllButton_, SIGNAL(clicked()), this, SLOT(onCollapseAll()), Qt::UniqueConnection);\n    connect(closeButton_, SIGNAL(clicked()), this, SLOT(close()), Qt::UniqueConnection);\n}\n\n//-----------------------------------------------------------------------------\n// Function: ParameterReferenceTreeWindow::openReferenceTree()\n//-----------------------------------------------------------------------------\nvoid ParameterReferenceTreeWindow::openReferenceTree(QString const& parameterID, QString const& parameterName)\n{\n    setWindowTitle(QString(tr(\"References to \")) + parameterName);\n\n    referenceTree_->openReferenceTree(parameterID);\n\n    show();\n}\n\n//-----------------------------------------------------------------------------\n// Function: ParameterReferenceTreeWindow::onExpandAll()\n//-----------------------------------------------------------------------------\nvoid ParameterReferenceTreeWindow::onExpandAll()\n{\n    referenceTree_->expandAll();\n}\n\n//-----------------------------------------------------------------------------\n// Function: ParameterReferenceTreeWindow::onCollapseAll()\n//-----------------------------------------------------------------------------\nvoid ParameterReferenceTreeWindow::onCollapseAll()\n{\n    referenceTree_->collapseAll();\n}\n"
  },
  {
    "path": "editors/ComponentEditor/parameterReferenceTree/ParameterReferenceTreeWindow.h",
    "content": "//-----------------------------------------------------------------------------\n// File: ParameterReferenceTreeWindow.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 29.09.2018\n//\n// Description:\n// The window containing the parameter reference tree.\n//-----------------------------------------------------------------------------\n\n#ifndef PARAMETERREFERENCETREEWINDOW_H\n#define PARAMETERREFERENCETREEWINDOW_H\n\n#include <QDialog>\n#include <QPushButton>\n\nclass ExpressionFormatter;\nclass ParameterReferenceTree;\n\n//-----------------------------------------------------------------------------\n//! The window containing the parameter reference tree.\n//-----------------------------------------------------------------------------\nclass ParameterReferenceTreeWindow : public QDialog\n{\n    Q_OBJECT\n\npublic:\n\n    /*!\n     *  The constructor.\n     *\n     *    @param [in] parameterReferenceTree  Tree containing the references made to the selected parameter.\n     *    @param [in] parent                  Parent widget.\n     */\n    ParameterReferenceTreeWindow(ParameterReferenceTree* parameterReferenceTree, QWidget* parent = 0);\n\n\t/*!\n     *  The destructor.\n     */\n    ~ParameterReferenceTreeWindow();\n\npublic slots:\n\n    /*!\n     *  Handles the creation and opening of the parameter reference tree.\n     *\n     *    @param [in] parameterID     ID of the selected parameter.\n     *    @param [in] parameterName   Name of the selected parameter.\n     */\n    void openReferenceTree(QString const& parameterID, QString const& parameterName);\n\nprivate slots:\n\n    /*!\n     *  Handles the expansion of all the items contained within the reference tree.\n     */\n    void onExpandAll();\n\n    /*!\n     *  Handles the collapsing of all the items contained within the reference tree.\n     */\n    void onCollapseAll();\n\nprivate:\n    \n\t// Disable copying.\n    ParameterReferenceTreeWindow(ParameterReferenceTreeWindow const& rhs);\n    ParameterReferenceTreeWindow& operator=(ParameterReferenceTreeWindow const& rhs);\n\n    /*!\n     *  Setup the layout.\n     */\n    void setupLayout();\n\n    /*!\n     *  Connect the necessary signals to slots.\n     */\n    void connectItems();\n\n    //-----------------------------------------------------------------------------\n    // Data.\n    //-----------------------------------------------------------------------------\n\n    //! The tree containing the references to the selected parameter.\n    ParameterReferenceTree* referenceTree_;\n\n    //! Button for expanding all the items in the tree.\n    QPushButton* expandAllButton_;\n\n    //! Button for collapsing all the items in the tree.\n    QPushButton* collapseAllButton_;\n\n    //! Button for closing the tree window.\n    QPushButton* closeButton_;\n};\n\n#endif // PARAMETERREFERENCETREEWINDOW_H\n"
  },
  {
    "path": "editors/ComponentEditor/parameters/Array/ArrayColumns.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ArrayColumns.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Mikko Teuho\r\n// Date: 12.03.2015\r\n//\r\n// Description:\r\n// Common declarations for editing arrays.\r\n//-----------------------------------------------------------------------------\r\n\r\nnamespace ArrayColumns\r\n{\r\n    //! The editable columns in the parameter editor.\r\n    enum columns\r\n    {\r\n        ARRAY_INDEX = 0,\r\n        VALUE,\r\n        COLUMN_COUNT,\r\n    };\r\n}\r\n"
  },
  {
    "path": "editors/ComponentEditor/parameters/Array/ArrayDelegate.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ArrayDelegate.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Mikko Teuho\r\n// Date: 12.03.2015\r\n//\r\n// Description:\r\n// Delegate that provides widgets for editing arrays.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"ArrayDelegate.h\"\r\n#include \"ArrayColumns.h\"\r\n\r\n#include <IPXACTmodels/common/Choice.h>\r\n\r\n#include <QComboBox>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ArrayDelegate::ArrayDelegate()\r\n//-----------------------------------------------------------------------------\r\nArrayDelegate::ArrayDelegate(QAbstractItemModel* completionModel, QSharedPointer<ParameterFinder> finder,\r\n    QSharedPointer<Choice> selectedChoice, QObject* parent):\r\nChoiceCreatorDelegate(completionModel, finder, parent),\r\nselectedChoice_(selectedChoice)\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ArrayDelegate::~ArrayDelegate()\r\n//-----------------------------------------------------------------------------\r\nArrayDelegate::~ArrayDelegate()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ArrayDelegate::columnAcceptsExpression()\r\n//-----------------------------------------------------------------------------\r\nbool ArrayDelegate::columnAcceptsExpression(int column) const\r\n{\r\n    return column == ArrayColumns::VALUE;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ArrayDelegate::valueColumn()\r\n//-----------------------------------------------------------------------------\r\nint ArrayDelegate::valueColumn() const\r\n{\r\n    return ArrayColumns::VALUE;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ArrayDelegate::choiceNameOnRow()\r\n//-----------------------------------------------------------------------------\r\nQString ArrayDelegate::choiceNameOnRow(QModelIndex const& /*index*/) const\r\n{\r\n    return selectedChoice_->name();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ArrayDelegate::findChoice()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<Choice> ArrayDelegate::findChoice(QModelIndex const& /*index*/) const\r\n{\r\n    return selectedChoice_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ArrayDelegate::descriptionColumn()\r\n//-----------------------------------------------------------------------------\r\nint ArrayDelegate::descriptionColumn() const\r\n{\r\n    return -1;\r\n}\r\n"
  },
  {
    "path": "editors/ComponentEditor/parameters/Array/ArrayDelegate.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ArrayDelegate.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Mikko Teuho\r\n// Date: 12.03.2015\r\n//\r\n// Description:\r\n// Delegate that provides widgets for editing arrays.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef ARRAYDELEGATE_H\r\n#define ARRAYDELEGATE_H\r\n\r\n#include <editors/ComponentEditor/parameters/ChoiceCreatorDelegate.h>\r\n\r\n#include <QCompleter>\r\n\r\nclass Choice;\r\n//-----------------------------------------------------------------------------\r\n//! Delegate that provides widgets for editing arrays.\r\n//-----------------------------------------------------------------------------\r\nclass ArrayDelegate : public ChoiceCreatorDelegate\r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\r\n    /*!\r\n     *  The constructor.\r\n     *\r\n     *    @param [in] completionModel     Model containing the completions used in expression editor.\r\n     *    @param [in] finder              The parameter finder to search for the parameters.\r\n     *    @param [in] selectedChoice      The currently active choice.\r\n     *    @param [in] parent              The parent object.\r\n     */\r\n    ArrayDelegate(QAbstractItemModel* completionModel,\r\n        QSharedPointer<ParameterFinder> finder,\r\n        QSharedPointer<Choice> selectedChoice,\r\n        QObject* parent = 0);\r\n\r\n\t//! The destructor\r\n    virtual ~ArrayDelegate();\r\n\r\nsignals:\r\n\r\n    //! Emitted when the values of the array change.\r\n    void contentChanged();\r\n\r\nprotected:\r\n\r\n    /*!\r\n     *  Checks if the cells in given column accept expression as an input value.\r\n     *\r\n     *    @param [in] column   The column to check.\r\n     *\r\n     *    @return True, if the cells accept expressions, otherwise false.\r\n     */\r\n    virtual bool columnAcceptsExpression(int column) const;\r\n\r\n    /*!\r\n     *  Gets the name of the currently selected choice.\r\n     *\r\n     *    @param [in] index   The index of the currently selected row.\r\n     *\r\n     *    @return The name of the selected choice.\r\n     */\r\n    virtual QString choiceNameOnRow(QModelIndex const& index) const;\r\n\r\n    /*!\r\n     *  Gets the column number for the value column.\r\n     *\r\n     *    @return The number of the column for value.\r\n     */\r\n    virtual int valueColumn() const;\r\n\r\n    /*!\r\n     *  Gets the currently selected choice.\r\n     *\r\n     *    @param [in] index   The index of the currently selected row.\r\n     */\r\n    virtual QSharedPointer<Choice> findChoice(QModelIndex const& index) const;\r\n\r\n    //! Gets the description column.\r\n    virtual int descriptionColumn() const;\r\n\r\nprivate:\r\n\r\n\t//! No copying.\r\n    ArrayDelegate(const ArrayDelegate& other);\r\n\r\n\t//! No assignment.\r\n    ArrayDelegate& operator=(const ArrayDelegate& other);\r\n\r\n\r\n    //! The currently selected choice.\r\n    QSharedPointer<Choice> selectedChoice_;\r\n};\r\n\r\n#endif // ARRAYDELEGATE_H\r\n"
  },
  {
    "path": "editors/ComponentEditor/parameters/Array/ArrayView.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ArrayView.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Mikko Teuho\r\n// Date: 12.03.2015\r\n//\r\n// Description:\r\n// Editor for changing values in arrays.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"ArrayView.h\"\r\n\r\n#include <QHeaderView>\r\n#include <QEvent>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ArrayView::ArrayView()\r\n//-----------------------------------------------------------------------------\r\nArrayView::ArrayView(QWidget* parent):\r\nQTableView(parent)\r\n{\r\n    setAlternatingRowColors(false);\r\n    verticalHeader()->setDefaultSectionSize(fontMetrics().height() + 8);\r\n    verticalHeader()->hide();\r\n    horizontalHeader()->setStretchLastSection(true);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ArrayView::~ArrayView()\r\n//-----------------------------------------------------------------------------\r\nArrayView::~ArrayView()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ArrayView::keyboardSearch()\r\n//-----------------------------------------------------------------------------\r\nvoid ArrayView::keyboardSearch(QString const& /*search*/)\r\n{\r\n    return;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ArrayView::eventFilter()\r\n//-----------------------------------------------------------------------------\r\nbool ArrayView::eventFilter(QObject* /*filterObject*/, QEvent *filterEvent)\r\n{\r\n    if (filterEvent->type() == QEvent::KeyPress)\r\n    {\r\n        return true;\r\n    }\r\n\r\n    return false;\r\n}\r\n"
  },
  {
    "path": "editors/ComponentEditor/parameters/Array/ArrayView.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ArrayView.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Mikko Teuho\r\n// Date: 12.03.2015\r\n//\r\n// Description:\r\n// Editor for changing values in arrays.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef ARRAYVIEW_H\r\n#define ARRAYVIEW_H\r\n\r\n#include <QTableView>\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Editor for changing values in arrays.\r\n//-----------------------------------------------------------------------------\r\nclass ArrayView : public QTableView\r\n{\r\n    Q_OBJECT\r\npublic:\r\n\r\n    /*!\r\n     *  The constructor.\r\n     *\r\n     *    @param [in] parent  The parent of this view.\r\n     */\r\n    ArrayView(QWidget* parent);\r\n\r\n    /*!\r\n     *  The destructor.\r\n     */\r\n    virtual ~ArrayView();\r\n\r\n    /*!\r\n     *  Reimplemented to do nothing when keyboard search is initiated.\r\n     *\r\n     *    @param [in] search  The found item should be the best match for this string.\r\n     */\r\n    virtual void keyboardSearch(const QString &search);\r\n\r\n    /*!\r\n     *  The event filter for this view.\r\n     *\r\n     *    @param [in] filterObject    The object to be filtered.\r\n     *    @param [in] filterEvent     The event to be filtered.\r\n     */\r\n    virtual bool eventFilter(QObject *filterObject, QEvent *filterEvent);\r\n\r\nprivate:\r\n    //! Disable copying and assignment.\r\n    ArrayView(const ArrayView& other);\r\n    ArrayView& operator=(const ArrayView& other);\r\n};\r\n\r\n#endif // ARRAYVIEW_H"
  },
  {
    "path": "editors/ComponentEditor/parameters/Array/ParameterArrayModel.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ParameterArrayModel.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Mikko Teuho\r\n// Date: 10.03.2015\r\n//\r\n// Description:\r\n// Model for editing an array within parameter value.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"ParameterArrayModel.h\"\r\n#include \"ArrayColumns.h\"\r\n\r\n#include <IPXACTmodels/common/Enumeration.h>\r\n\r\n#include <common/KactusColors.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ParameterArrayModel::ParameterArrayModel()\r\n//-----------------------------------------------------------------------------\r\nParameterArrayModel::ParameterArrayModel(int sizeOfArray, QSharedPointer<ExpressionParser> expressionParser,\r\n    QSharedPointer<ParameterFinder> parameterFinder, QSharedPointer<ExpressionFormatter> expressionFormatter,\r\n    QSharedPointer<Choice> selectedChoice, QColor valueBackGroundColor, int arrayStartIndex,\r\n    Document::Revision docRevision, QObject* parent):\r\nReferencingTableModel(parameterFinder, parent),\r\nParameterizableTable(parameterFinder),\r\nsizeOfArray_(sizeOfArray),\r\nexpressionformatter_(expressionFormatter),\r\narrayValues_(),\r\nselectedChoice_(selectedChoice),\r\nvalidator_(),\r\nparameterType_(),\r\nvalueBackGroundColor_(valueBackGroundColor),\r\narrayStartIndex_(arrayStartIndex)\r\n{\r\n    QSharedPointer<QList<QSharedPointer<Choice> > > choices(new QList<QSharedPointer<Choice> >());\r\n    choices->append(selectedChoice);\r\n\r\n    validator_ = new ParameterValidator(expressionParser, choices, docRevision);\r\n\r\n    QString repeater = \",\";\r\n    QString newArray = repeater.repeated(sizeOfArray_ - 1);\r\n    arrayValues_ = newArray.split(repeater);\r\n\r\n    QString arrayValue;\r\n    setExpressionParser(expressionParser);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ParameterArrayModel::~ParameterArrayModel()\r\n//-----------------------------------------------------------------------------\r\nParameterArrayModel::~ParameterArrayModel()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ParameterArrayModel::columnCount()\r\n//-----------------------------------------------------------------------------\r\nint ParameterArrayModel::columnCount(const QModelIndex& parent) const\r\n{\r\n    if (parent.isValid())\r\n    {\r\n        return 0;\r\n    }\r\n\r\n    return ArrayColumns::COLUMN_COUNT;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ParameterArrayModel::rowCount()\r\n//-----------------------------------------------------------------------------\r\nint ParameterArrayModel::rowCount(const QModelIndex &parent /* = QModelIndex() */) const\r\n{\r\n    if (parent.isValid())\r\n    {\r\n        return 0;\r\n    }\r\n\r\n    return sizeOfArray_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ParameterArrayModel::headerData()\r\n//-----------------------------------------------------------------------------\r\nQVariant ParameterArrayModel::headerData(int section, Qt::Orientation orientation, int role) const\r\n{\r\n    if (orientation == Qt::Horizontal && role == Qt::DisplayRole)\r\n    {\r\n        if (section == ArrayColumns::ARRAY_INDEX)\r\n        {\r\n            return tr(\"Index\");\r\n        }\r\n        else if (section == ArrayColumns::VALUE)\r\n        {\r\n            return tr(\"Value\") + getExpressionSymbol();\r\n        }\r\n    }\r\n\r\n    return QVariant();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ParameterArrayModel::data()\r\n//-----------------------------------------------------------------------------\r\nQVariant ParameterArrayModel::data(const QModelIndex &index, int role) const\r\n{\r\n    if (indexIsNotValid(index))\r\n    {\r\n        return QVariant();\r\n    }\r\n\r\n    if (role == Qt::DisplayRole)\r\n    {\r\n        if (index.column() == ArrayColumns::VALUE)\r\n        {\r\n            return expressionformatter_->formatReferringExpression(valueForIndex(index).toString());\r\n        }\r\n        else\r\n        {\r\n            return valueForIndex(index);\r\n        }\r\n    }\r\n\r\n    else if (role == Qt::UserRole)\r\n    {\r\n        if (index.row() == sizeOfArray_ - 1)\r\n        {\r\n            return true;\r\n        }\r\n        else\r\n        {\r\n            return false;\r\n        }\r\n    }\r\n\r\n    else if (role == Qt::EditRole)\r\n    {\r\n        return expressionOrValueForIndex(index);\r\n    }\r\n\r\n    else if (role == Qt::ToolTipRole)\r\n    {\r\n        if (index.column() == ArrayColumns::VALUE)\r\n        {\r\n            if (!selectedChoice_->name().isEmpty())\r\n            {\r\n                return expressionOrValueForIndex(index);\r\n            }\r\n            else\r\n            {\r\n                return formattedValueFor(valueForIndex(index).toString());\r\n            }\r\n        }\r\n        else\r\n        {\r\n            return valueForIndex(index);\r\n        }\r\n    }\r\n\r\n    else if (role == Qt::BackgroundRole)\r\n    {\r\n        if (index.column() == ArrayColumns::VALUE)\r\n        {\r\n            return valueBackGroundColor_;\r\n        }\r\n        else\r\n        {\r\n            return KactusColors::REGULAR_FIELD;\r\n        }\r\n    }\r\n\r\n    else if (role == Qt::ForegroundRole)\r\n    {\r\n        if (isValidExpressionColumn(index))\r\n        {\r\n            return blackForValidOrRedForInvalidIndex(index);\r\n        }\r\n\r\n        return QVariant();\r\n    }\r\n\r\n    else if (role == Qt::TextAlignmentRole)\r\n    {\r\n        if (index.column() == ArrayColumns::ARRAY_INDEX)\r\n        {\r\n            //return Qt::AlignRight | Qt::AlignVCenter;\r\n            return Qt::AlignCenter;\r\n        }\r\n\r\n        else return QVariant();\r\n    }\r\n\r\n    else\r\n    {\r\n        return QVariant();\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ParameterArrayModel::setData()\r\n//-----------------------------------------------------------------------------\r\nbool ParameterArrayModel::setData(const QModelIndex &index, const QVariant &value, int role /* = Qt::EditRole */)\r\n{\r\n    if (indexIsNotValid(index))\r\n    {\r\n        return false;\r\n    }\r\n\r\n    if (role == Qt::EditRole)\r\n    {\r\n        if (index.column() == ArrayColumns::ARRAY_INDEX)\r\n        {\r\n            return false;\r\n        }\r\n        else if (index.column() == ArrayColumns::VALUE)\r\n        {\r\n            arrayValues_.replace(index.row(), value.toString());\r\n        }\r\n    }\r\n\r\n    emit dataChanged(index, index);\r\n    return true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ParameterArrayModel::flags()\r\n//-----------------------------------------------------------------------------\r\nQt::ItemFlags ParameterArrayModel::flags(QModelIndex const& index) const\r\n{\r\n    if (indexIsNotValid(index) || index.column() == ArrayColumns::ARRAY_INDEX)\r\n    {\r\n        return Qt::NoItemFlags;\r\n    }\r\n\r\n    return Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsEditable;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ParameterArrayModel::isNotValidIndex()\r\n//-----------------------------------------------------------------------------\r\nbool ParameterArrayModel::indexIsNotValid(QModelIndex const& index) const\r\n{\r\n    return !index.isValid() || index.row() > sizeOfArray_ || index.column() >= ArrayColumns::COLUMN_COUNT;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ParameterArrayModel::()\r\n//-----------------------------------------------------------------------------\r\nbool ParameterArrayModel::isValidExpressionColumn(QModelIndex const& index) const\r\n{\r\n    return index.column() == ArrayColumns::VALUE;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ParameterArrayModel::expressionOrValueForIndex()\r\n//-----------------------------------------------------------------------------\r\nQVariant ParameterArrayModel::expressionOrValueForIndex(QModelIndex const& index) const\r\n{\r\n    if (index.column() == ArrayColumns::VALUE)\r\n    {\r\n        return arrayValues_.at(index.row());\r\n    }\r\n    else\r\n    {\r\n        return data(index, Qt::DisplayRole);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ParameterArrayModel::getAllReferencesToIdInItemOnRow()\r\n//-----------------------------------------------------------------------------\r\nint ParameterArrayModel::getAllReferencesToIdInItemOnRow(const int& row, QString const& valueID) const\r\n{\r\n    return arrayValues_.at(row).count(valueID);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ParameterArrayModel::validateIndex()\r\n//-----------------------------------------------------------------------------\r\nbool ParameterArrayModel::validateIndex(QModelIndex const& index) const\r\n{\r\n    if (index.column() == ArrayColumns::VALUE)\r\n    {\r\n        return validator_->hasValidValueForType(arrayValues_.at(index.row()), parameterType_);\r\n    }\r\n\r\n    return true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ParameterArrayModel::valueForIndex()\r\n//-----------------------------------------------------------------------------\r\nQVariant ParameterArrayModel::valueForIndex(QModelIndex const& index) const\r\n{\r\n    if (index.column() == ArrayColumns::ARRAY_INDEX)\r\n    {\r\n        return index.row() + arrayStartIndex_;\r\n    }\r\n    else if (index.column() == ArrayColumns::VALUE)\r\n    {\r\n        return evaluateValueWithChoice(index.row());\r\n    }\r\n    else\r\n    {\r\n        return QVariant();\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ParameterArrayModel::evaluateValueWithChoice()\r\n//-----------------------------------------------------------------------------\r\nQString ParameterArrayModel::evaluateValueWithChoice(const int& row) const\r\n{\r\n    if (!selectedChoice_->name().isEmpty())\r\n    {\r\n        foreach (QSharedPointer<Enumeration> enumeration, *selectedChoice_->enumerations())\r\n        {\r\n            if (enumeration->getValue() == arrayValues_.at(row) && !enumeration->getText().isEmpty())\r\n            {\r\n                return enumeration->getText();\r\n            }\r\n        }\r\n    }\r\n\r\n    return arrayValues_.at(row);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ParameterArrayModel::setArrayData()\r\n//-----------------------------------------------------------------------------\r\nvoid ParameterArrayModel::setArrayData(QString const& arrayData)\r\n{\r\n    if (arrayData.contains('{') && arrayData.contains('}'))\r\n    {\r\n        QStringList newArrayData = arrayData.split(',');\r\n        newArrayData.first().remove('{');\r\n        newArrayData.last().remove('}');\r\n\r\n        int arraySize = arrayValues_.size();\r\n        if (newArrayData.size() < arrayValues_.size())\r\n        {\r\n            arraySize = newArrayData.size();\r\n        }\r\n\r\n        for (int i = 0; i < arraySize; ++i)\r\n        {\r\n            arrayValues_[i] = newArrayData.at(i);\r\n        }\r\n    }\r\n\r\n    else\r\n    {\r\n        arrayValues_.first() = arrayData;\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ParameterArrayModel::getArrayData()\r\n//-----------------------------------------------------------------------------\r\nQString ParameterArrayModel::getArrayData()\r\n{\r\n    arrayValues_.first().prepend('{');\r\n    arrayValues_.last().append('}');\r\n    QString newValue = arrayValues_.join(',');\r\n\r\n    return newValue;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ParameterArrayModel::getArrayDataAsList()\r\n//-----------------------------------------------------------------------------\r\nQStringList ParameterArrayModel::getArrayDataAsList()\r\n{\r\n    return arrayValues_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ParameterArrayModel::setParameterType()\r\n//-----------------------------------------------------------------------------\r\nvoid ParameterArrayModel::setParameterType(QString const& parameterType)\r\n{\r\n    parameterType_ = parameterType;\r\n}"
  },
  {
    "path": "editors/ComponentEditor/parameters/Array/ParameterArrayModel.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ParameterArrayModel.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Mikko Teuho\r\n// Date: 10.03.2015\r\n//\r\n// Description:\r\n// Model for editing an array within parameter value.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef PARAMETERARRAYMODEL_H\r\n#define PARAMETERARRAYMODEL_H\r\n\r\n#include <editors/ComponentEditor/common/ParameterizableTable.h>\r\n#include <editors/ComponentEditor/common/ReferencingTableModel.h>\r\n#include <KactusAPI/include/ParameterFinder.h>\r\n#include <KactusAPI/include/ExpressionFormatter.h>\r\n\r\n#include <IPXACTmodels/common/validators/ParameterValidator.h>\r\n\r\n#include <IPXACTmodels/common/Choice.h>\r\n\r\n#include <QSharedPointer>\r\n#include <QList>\r\n#include <QStringList>\r\n\r\n#include <QColor>\r\n\r\n//-----------------------------------------------------------------------------\r\n// class ParameterArrayModel.\r\n//-----------------------------------------------------------------------------\r\nclass ParameterArrayModel : public ReferencingTableModel, public ParameterizableTable\r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\r\n    /*!\r\n     *  The constructor.\r\n     *\r\n     *    @param [in] sizeOfArray             Size of the array to be constructed.\r\n     *    @param [in] expressionParser        Pointer to the expression parser.\r\n     *    @param [in] parameterFinder         Pointer to parameter finder.\r\n     *    @param [in] expressionFormatter     Pointer to the expression formatter.\r\n     *    @param [in] selectedChoice          The currently active choice.\r\n     *    @param [in] valueBackgroundColor    The colour for the background of value column.\r\n     *    @param [in] arrayStartIndex         The starting index of the array.\r\n     *    @param [in] parent                  The parent of this model.\r\n     */\r\n    ParameterArrayModel(int sizeOfArray,\r\n        QSharedPointer<ExpressionParser> expressionParser,\r\n        QSharedPointer<ParameterFinder> parameterFinder,\r\n        QSharedPointer<ExpressionFormatter> expressionFormatter,\r\n        QSharedPointer<Choice> selectedChoice,\r\n        QColor valueBackGroundColor,\r\n        int arrayStartIndex,\r\n        Document::Revision docRevision,\r\n        QObject* parent = 0);\r\n\r\n    /*!\r\n     *  The destructor.\r\n     */\r\n    ~ParameterArrayModel();\r\n\r\n    /*!\r\n     *  Returns the amount of columns in the model.\r\n     *\r\n     *    @param [in] parent  If given, the column count of the children of the given parent is returned.\r\n     *\r\n     *    @return The amount of columns.\r\n     */\r\n    int columnCount(const QModelIndex &parent = QModelIndex()) const;\r\n\r\n    /*!\r\n     *  Returns the amount of rows in the model.\r\n     *\r\n     *    @param [in] parent  If given, the row count of the children of the given parent is returned.\r\n     *\r\n     *    @return The amount of rows.\r\n     */\r\n    int rowCount(const QModelIndex &parent = QModelIndex()) const;\r\n\r\n    /*!\r\n     *  Retrieves the header data for the given column (row headers are not supported in this model).\r\n     *\r\n     *    @param [in] section         The column from which the index is retrieved.\r\n     *    @param [in] orientation     Whether the header is horizontal or vertical.\r\n     *    @param [in] role            The role for which the header is retrieved.\r\n     *\r\n     *    @return The header data.\r\n     */\r\n    QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;\r\n\r\n    /*!\r\n     *  Retrieves the data for the appropriate role at the given index.\r\n     *\r\n     *    @param [in] index   The index of data to be returned.\r\n     *    @param [in] role    The role for which data is returned.\r\n     *\r\n     *    @return The requested data.\r\n     */\r\n    QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;\r\n\r\n    /*!\r\n     *  Sets the data at the given index.\r\n     *\r\n     *    @param [in] index   The index at which the data is set.\r\n     *    @param [in] value   The new value to being set.\r\n     *    @param [in] role    The role for which the data is set.\r\n     *\r\n     *    @return True, if data was set successfully, otherwise false.\r\n     */\r\n    bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole);\r\n\r\n    /*!\r\n     *  Returns the flags for an object at the given index.\r\n     *\r\n     *    @param [in] index   The index of the object queried.\r\n     *\r\n     *    @return The relevant flags.\r\n     */\r\n    Qt::ItemFlags flags(QModelIndex const& index) const;\r\n\r\n    /*!\r\n     *  Set the data for the array.\r\n     *\r\n     *    @param [in] arrayData   The data to be set for the array.\r\n     */\r\n    void setArrayData(QString const& arrayData);\r\n\r\n    /*!\r\n     *  Gets the data of the array.\r\n     *\r\n     *    @return The data in the array in one string separated by ',' and in between {}.\r\n     */\r\n    QString getArrayData();\r\n\r\n    /*!\r\n     *  Get the data of the array as a list of items.\r\n     *\r\n     *    @return The data in the array in a list of items.\r\n     */\r\n    QStringList getArrayDataAsList();\r\n\r\n    /*!\r\n     *  Set the type for the values in the array.\r\n     *\r\n     *    @param [in] parameterType   The new type for the parameters.\r\n     */\r\n    void setParameterType(QString const& parameterType);\r\n\r\nsignals:\r\n    //! Emitted when the model content has changed.\r\n    void contentChanged();\r\n\r\nprotected:\r\n\r\n    /*!\r\n     *  Checks if the column is valid for expressions.\r\n     *\r\n     *    @param [in] index   The index being evaluated.\r\n     *\r\n     *    @return True, if the column is valid for expressions, otherwise false.\r\n     */\r\n    virtual bool isValidExpressionColumn(QModelIndex const& index) const;\r\n\r\n    /*!\r\n     *  Gets the expression for the given index or the plain value if expression is not available.\r\n     *\r\n     *    @param [in] index   The index of the value to get.\r\n     *\r\n     *    @return The expression for the index if available, otherwise the value for the given index.\r\n     */\r\n    virtual QVariant expressionOrValueForIndex(QModelIndex const& index) const;\r\n\r\n    /*!\r\n     *  Gets all the references to an id from the selected array index.\r\n     *\r\n     *    @param [in] row         The index of the selected array value.\r\n     *    @param [in] valueID     The parameter whose references are being searched for.\r\n     *\r\n     *    @return The amount of references made to the selected parameter.\r\n     */\r\n    virtual int getAllReferencesToIdInItemOnRow(const int& row, QString const& valueID) const;\r\n\r\n    /*!\r\n     *  Validates the data in the array at index corresponding to the given column.\r\n     *\r\n     *    @param [in] index   The index of the array value.\r\n     *\r\n     *    @return True, if the value is valid for the column.\r\n     */\r\n    virtual bool validateIndex(QModelIndex const& index) const;\r\n\r\nprivate:\r\n\t// Disable copying.\r\n    ParameterArrayModel(ParameterArrayModel const& rhs);\r\n\r\n\t// Disable assignment.\r\n    ParameterArrayModel& operator=(ParameterArrayModel const& rhs);\r\n\r\n    /*!\r\n     *  Check if the index is valid.\r\n     *\r\n     *    @param [in] index   The index being checked.\r\n     *\r\n     *    @return True if the index is not valid, otherwise false.\r\n     */\r\n    bool indexIsNotValid(QModelIndex const& index) const;\r\n\r\n    /*!\r\n     *  Gets the value of the array in the given index.\r\n     *\r\n     *    @param [in] index   The index of the value.\r\n     *\r\n     *    @return The data in the given index.\r\n     */\r\n    QVariant valueForIndex(QModelIndex const& index) const;\r\n\r\n    /*!\r\n     *  Make the values in the array match the values of the choice.\r\n     *\r\n     *    @param [in] row     The index of the value to be matched to choice.\r\n     *\r\n     *    @return The value of the choice corresponding to the given value.\r\n     */\r\n    QString evaluateValueWithChoice(const int& row) const;\r\n\r\n    //! Size of the array.\r\n    int sizeOfArray_;\r\n\r\n    //! The expression formatter.\r\n    QSharedPointer<ExpressionFormatter> expressionformatter_;\r\n\r\n    //! The values of the array.\r\n    QStringList arrayValues_;\r\n\r\n    //! The currently active choice.\r\n    QSharedPointer<Choice> selectedChoice_;\r\n\r\n    //! The validator for the array values.\r\n    ParameterValidator* validator_;\r\n\r\n    //! The parameter type.\r\n    QString parameterType_;\r\n\r\n    //! The colour for the background of the value column.\r\n    QColor valueBackGroundColor_;\r\n\r\n    //! The starting index of the array.\r\n    int arrayStartIndex_;\r\n};\r\n#endif // PARAMETERARRAYMODEL_H\r\n"
  },
  {
    "path": "editors/ComponentEditor/parameters/ChoiceCreatorDelegate.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ChoiceCreatorDelegate.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Mikko Teuho\r\n// Date: 20.03.2015\r\n//\r\n// Description:\r\n// Delegate for providing functionality for choices inside parameters.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"ChoiceCreatorDelegate.h\"\r\n\r\n#include <IPXACTmodels/common/Choice.h>\r\n#include <IPXACTmodels/common/Enumeration.h>\r\n\r\n#include <QComboBox>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ChoiceCreatorDelegate::ChoiceCreatorDelegate()\r\n//-----------------------------------------------------------------------------\r\nChoiceCreatorDelegate::ChoiceCreatorDelegate(QAbstractItemModel* completionModel,\r\n    QSharedPointer<ParameterFinder> finder, QObject* parent):\r\nExpressionDelegate(completionModel, finder, parent),\r\n    choices_(new QList<QSharedPointer<Choice> > ())\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ChoiceCreatorDelegate::~ChoiceCreatorDelegate()\r\n//-----------------------------------------------------------------------------\r\nChoiceCreatorDelegate::~ChoiceCreatorDelegate()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ChoiceCreatorDelegate::setChoices()\r\n//-----------------------------------------------------------------------------\r\nvoid ChoiceCreatorDelegate::setChoices(QSharedPointer<QList<QSharedPointer<Choice> > > choices)\r\n{\r\n    choices_ = choices;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ChoiceCreatorDelegate::getChoices()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<QList<QSharedPointer<Choice> > > ChoiceCreatorDelegate::getChoices() const\r\n{\r\n    return choices_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ChoiceCreatorDelegate::findChoice()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<Choice> ChoiceCreatorDelegate::findChoice(QModelIndex const& index) const\r\n{\r\n    QString choiceName = choiceNameOnRow(index);\r\n    foreach (QSharedPointer<Choice> currentChoice, *choices_)\r\n    {\r\n        if (currentChoice->name() == choiceName)\r\n        {\r\n            return currentChoice;\r\n        }\r\n    }\r\n\r\n    return QSharedPointer<Choice>(new Choice());\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ChoiceCreatorDelegate::getChoiceComboItems()\r\n//-----------------------------------------------------------------------------\r\nQStringList ChoiceCreatorDelegate::getChoiceComboItems(QModelIndex const& index) const\r\n{\r\n    QStringList comboItems;\r\n\r\n    QSharedPointer<Choice> indexedChoice = findChoice(index);\r\n    for (auto enumeration : *indexedChoice->enumerations())\r\n    {\r\n        QString enumerationText = enumeration->getValue();\r\n        if (!enumeration->getText().isEmpty())\r\n        {\r\n            enumerationText.append(\":\" + enumeration->getText());\r\n        }\r\n\r\n        comboItems.append(enumerationText);\r\n    }\r\n\r\n    return comboItems;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ChoiceCreatorDelegate::findEnumerationText()\r\n//-----------------------------------------------------------------------------\r\nQString ChoiceCreatorDelegate::findEnumerationText(QModelIndex const& index, QString const& enumerationValue) const\r\n{\r\n    QSharedPointer<Choice> indexedChoice = findChoice(index);\r\n    for (auto enumeration : *indexedChoice->enumerations())\r\n    {\r\n        if (enumeration->getValue() == enumerationValue)\r\n        {\r\n            return enumeration->getText();\r\n        }\r\n    }\r\n\r\n    return QString(\"\");\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ChoiceCreatorDelegate::findEnumerationValue()\r\n//-----------------------------------------------------------------------------\r\nQString ChoiceCreatorDelegate::findEnumerationValue(QModelIndex const& index, QString const& enumerationText) const\r\n{\r\n    QSharedPointer<Choice> indexedChoice = findChoice(index);\r\n    for (auto enumeration : *indexedChoice->enumerations())\r\n    {\r\n        if (enumeration->getText() == enumerationText)\r\n        {\r\n            return enumeration->getValue();\r\n        }\r\n    }\r\n\r\n    return QString(\"\");\r\n}\r\n"
  },
  {
    "path": "editors/ComponentEditor/parameters/ChoiceCreatorDelegate.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ChoiceCreatorDelegate.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Mikko Teuho\r\n// Date: 20.03.2015\r\n//\r\n// Description:\r\n// Delegate for providing functionality for choices inside parameters.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef CHOICECREATORDELEGATE_H\r\n#define CHOICECREATORDELEGATE_H\r\n\r\n#include <editors/ComponentEditor/common/ExpressionDelegate.h>\r\n\r\n#include <QCompleter>\r\n\r\nclass Choice;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Delegate for providing functionality for choices inside parameters.\r\n//-----------------------------------------------------------------------------\r\nclass ChoiceCreatorDelegate : public ExpressionDelegate\r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\r\n    /*!\r\n     *  The constructor.\r\n     *\r\n     *    @param [in] completionModel     Model containing the completions used in expression editor.\r\n     *    @param [in] finder              Pointer to the parameter finder, used in expression editor.\r\n     *    @param [in] parent              Pointer to the owner of this delegate.\r\n     */\r\n    ChoiceCreatorDelegate(QAbstractItemModel* completionModel, QSharedPointer<ParameterFinder> finder,\r\n        QObject* parent = 0);\r\n\r\n    /*!\r\n     *  The destructor.\r\n     */\r\n    virtual ~ChoiceCreatorDelegate();\r\n    \r\nprotected:\r\n\r\n    /*!\r\n     *  Set the choices for this delegate.\r\n     *\r\n     *    @param [in] choices     The currently available choices.\r\n     */\r\n    void setChoices(QSharedPointer<QList<QSharedPointer<Choice> > > choices);\r\n\r\n    /*!\r\n     *  Gets the currently available choices.\r\n     *\r\n     *    @return The currently available choices.\r\n     */\r\n    QSharedPointer<QList<QSharedPointer<Choice> > > getChoices() const;\r\n\r\n    /*!\r\n     *  Checks if the given column supports expressions in the editor.\r\n     *\r\n     *    @param [in] column  The column to check.\r\n     *\r\n     *    @return True, if cells in the column accept expressions, otherwise false.\r\n     */\r\n    bool columnAcceptsExpression(int column) const = 0;\r\n\r\n    /*!\r\n     *  Finds the name of the choice corresponding to the given index.\r\n     *\r\n     *    @param [in] index   The index of the row to get the choice name from.\r\n     *\r\n     *    @return The name of the choice on the row.\r\n     */\r\n    virtual QString choiceNameOnRow(QModelIndex const& index) const = 0;\r\n\r\n    /*!\r\n     *  Gets the choice used on the row identified by the given index.\r\n     *\r\n     *    @param [in] index   The index of the row to find the choice from.\r\n     *\r\n     *    @return The choice of the given row.\r\n     */\r\n    virtual QSharedPointer<Choice> findChoice(QModelIndex const& index) const;\r\n\r\n    /*!\r\n     *  Get the choice items for the combo editor.\r\n     *\r\n     *    @param [in] index   Index of the edited item.\r\n     *\r\n     *    @return List of choice items for the combo editor.\r\n     */\r\n    QStringList getChoiceComboItems(QModelIndex const& index) const;\r\n\r\n    /*!\r\n     *  Get the enumeration text for the enumeration value.\r\n     *\r\n     *    @param [in] index               Index of the edited item.\r\n     *    @param [in] enumerationValue    The selected enumeration value.\r\n     *\r\n     *    @return The selected enumeration text.\r\n     */\r\n    QString findEnumerationText(QModelIndex const& index, QString const& enumerationValue) const;\r\n\r\n    /*!\r\n     *  Get the enumeration value for the enumeration text.\r\n     *\r\n     *    @param [in] index               Index of the edited item.\r\n     *    @param [in] enumerationText     The selected enumeration text.\r\n     *\r\n     *    @return The selected enumeration value.\r\n     */\r\n    QString findEnumerationValue(QModelIndex const& index, QString const& enumerationText) const;\r\n\r\n    /*!\r\n     *  Get the column of the possible place for enumeration selector.\r\n     *\r\n     *    @return The column number for the column that's value can be given as an enumeration.\r\n     */\r\n    virtual int valueColumn() const = 0;\r\n\r\nprivate:\r\n\r\n\t//! No copying\r\n    ChoiceCreatorDelegate(const ChoiceCreatorDelegate& other);\r\n\r\n\t//! No assignment\r\n    ChoiceCreatorDelegate& operator=(const ChoiceCreatorDelegate& other);\r\n\r\n    //! The currently available choices.\r\n    QSharedPointer<QList<QSharedPointer<Choice> > > choices_;\r\n};\r\n\r\n#endif // CHOICECREATORDELEGATE_H\r\n"
  },
  {
    "path": "editors/ComponentEditor/parameters/ComponentParameterColumns.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ComponentParameterColumns.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Esko Pekkarinen\r\n// Date: 19.01.2015\r\n//\r\n// Description:\r\n// Columns in the ComponentParameterModel.\r\n//-----------------------------------------------------------------------------\r\n\r\nnamespace ComponentParameterColumns\r\n{\r\n    enum Columns\r\n    {\r\n        NAME = 0,\r\n        ID,\r\n        COLUMN_COUNT\r\n    };\r\n}"
  },
  {
    "path": "editors/ComponentEditor/parameters/ComponentParameterModel.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ComponentParameterModel.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Esko Pekkarinen\r\n// Date: 13.01.2015\r\n//\r\n// Description:\r\n// Model for all parameter completions within a single component.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"ComponentParameterModel.h\"\r\n#include \"ComponentParameterColumns.h\"\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentParameterModel::ComponentParameterModel()\r\n//-----------------------------------------------------------------------------\r\nComponentParameterModel::ComponentParameterModel(QSharedPointer<ParameterFinder> parameterFinder, QObject *parent):\r\n    ReferencingTableModel(parameterFinder, parent),\r\n    ParameterizableTable(parameterFinder),\r\n    parameterFinder_(parameterFinder)\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentParameterModel::~ComponentParameterModel()\r\n//-----------------------------------------------------------------------------\r\nComponentParameterModel::~ComponentParameterModel()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentParameterModel::rowCount()\r\n//-----------------------------------------------------------------------------\r\nint ComponentParameterModel::rowCount(QModelIndex const& /*parent= QModelIndex() */) const\r\n{\r\n    return parameterFinder_->getNumberOfParameters();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentParameterModel::columnCount()\r\n//-----------------------------------------------------------------------------\r\nint ComponentParameterModel::columnCount(QModelIndex const& /*parent = QModelIndex() */) const\r\n{\r\n    return ComponentParameterColumns::COLUMN_COUNT;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentParameterModel::flags()\r\n//-----------------------------------------------------------------------------\r\nQt::ItemFlags ComponentParameterModel::flags(QModelIndex const& index) const\r\n{\r\n    if (index.isValid())\r\n    {\r\n        return Qt::ItemIsSelectable | Qt::ItemIsEnabled;\r\n    }\r\n    \r\n    return Qt::NoItemFlags;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentParameterModel::parent()\r\n//-----------------------------------------------------------------------------\r\nQModelIndex ComponentParameterModel::parent(QModelIndex const& /*child*/) const\r\n{\r\n    return QModelIndex();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentParameterModel::data()\r\n//-----------------------------------------------------------------------------\r\nQVariant ComponentParameterModel::data(QModelIndex const& index, int role) const\r\n{\r\n    if (!index.isValid())\r\n    {\r\n        return QVariant();\r\n    }\r\n\r\n    if (role == Qt::DisplayRole || role == Qt::EditRole)\r\n    {\r\n        QStringList parameterIds = parameterFinder_->getAllParameterIds();\r\n\r\n        if (index.row() > parameterIds.size())\r\n        {\r\n            return QVariant();\r\n        }\r\n        else if (index.column() == ComponentParameterColumns::NAME)\r\n        {\r\n            return parameterFinder_->nameForId(parameterIds.at(index.row()));\r\n        }\r\n        else if (index.column() == ComponentParameterColumns::ID)\r\n        {\r\n            return parameterIds.at(index.row());\r\n        }\r\n    }\r\n\r\n    return QVariant();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentParameterModel::isValidExpressionColumn()\r\n//-----------------------------------------------------------------------------\r\nbool ComponentParameterModel::isValidExpressionColumn(QModelIndex const& /*index*/) const\r\n{\r\n    return false;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentParameterModel::expressionOrValueForIndex()\r\n//-----------------------------------------------------------------------------\r\nQVariant ComponentParameterModel::expressionOrValueForIndex(QModelIndex const& index) const\r\n{\r\n    return data(index);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentParameterModel::validateIndex()\r\n//-----------------------------------------------------------------------------\r\nbool ComponentParameterModel::validateIndex(QModelIndex const& index) const\r\n{\r\n   if (index.column() == ComponentParameterColumns::NAME || index.column() == ComponentParameterColumns::ID)\r\n   {\r\n       return !data(index).toString().isEmpty();\r\n   }\r\n\r\n   return false;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentParameterModel::getAllReferencesToIdInItemOnRow()\r\n//-----------------------------------------------------------------------------\r\nint ComponentParameterModel::getAllReferencesToIdInItemOnRow(const int& row, QString const& valueID) const\r\n{\r\n    QStringList parameterIDs = parameterFinder_->getAllParameterIds();\r\n\r\n    int referencesInValue = parameterFinder_->valueForId(parameterIDs.at(row)).count(valueID);\r\n\r\n    return referencesInValue;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentParameterModel::resetParameters()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentParameterModel::resetParameterModel()\r\n{\r\n    beginResetModel();\r\n    endResetModel();\r\n}\r\n"
  },
  {
    "path": "editors/ComponentEditor/parameters/ComponentParameterModel.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ComponentParameterModel.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Esko Pekkarinen\r\n// Date: 13.01.2015\r\n//\r\n// Description:\r\n// Model for all parameter completions within a single component.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef COMPONENTPARAMETERMODEL_H\r\n#define COMPONENTPARAMETERMODEL_H\r\n\r\n#include <QAbstractItemModel>\r\n#include <QSharedPointer>\r\n\r\n#include <editors/ComponentEditor/common/ParameterizableTable.h>\r\n#include <editors/ComponentEditor/common/ReferencingTableModel.h>\r\n#include <KactusAPI/include/ParameterFinder.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Model for all parameter completions within a single component.\r\n//-----------------------------------------------------------------------------\r\nclass ComponentParameterModel : public ReferencingTableModel, public ParameterizableTable\r\n{\r\n    Q_OBJECT\r\n\r\npublic:\r\n\r\n\t/*!\r\n\t *  The constructor.\r\n\t *\r\n     *    @param [in] parameterFinder     The parameter finder.\r\n\t *    @param [in] parent              The owner of this model.\r\n\t */\r\n\tComponentParameterModel(QSharedPointer<ParameterFinder> parameterFinder, QObject *parent);\r\n\r\n\t//! The destructor.\r\n\tvirtual ~ComponentParameterModel();\r\n\r\n    /*!\r\n     *  Finds the number of rows in the model.\r\n     *\r\n     *    @param [in] parent   The parent index whose row count to find.\r\n     *\r\n     *    @return The number of rows in the model.\r\n     */\r\n    virtual int rowCount(QModelIndex const& parent = QModelIndex()) const;\r\n\r\n    /*!\r\n     *  Finds the number of columns in the model.\r\n     *\r\n     *    @param [in] parent   The parent index whose column count to find.\r\n     *\r\n     *    @return The number of columns in the model.\r\n     */\r\n    virtual int columnCount(QModelIndex const& parent = QModelIndex()) const;\r\n\r\n    /*!\r\n     *  Finds the flags for the given index.\r\n     *\r\n     *    @param [in] index   The index whose flags to find.\r\n     *\r\n     *    @return Flags describing allowed actions for the index.\r\n     */\r\n    virtual Qt::ItemFlags flags(QModelIndex const& index) const;\r\n\r\n    /*!\r\n     *  Finds the parent index for the given child.\r\n     *\r\n     *    @param [in] child   The index whose parent index to find.\r\n     *\r\n     *    @return The index for the parent.\r\n     */\r\n    virtual QModelIndex parent(QModelIndex const& child) const;\r\n\r\n    /*!\r\n     *  Finds the data in the model for the given index.\r\n     *\r\n     *    @param [in] index   The index whose data to find.\r\n     *    @param [in] role    The role describing which aspect of the data to find.\r\n     *\r\n     *    @return The data in the given index.\r\n     */\r\n    virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;\r\n\r\npublic slots:\r\n\r\n    /*!\r\n     *  Reset the model to show the correct parameters.\r\n     */\r\n    void resetParameterModel();\r\n\r\nprotected:\r\n       \r\n    /*!\r\n     *  Check if the column index is valid for containing expressions.\r\n     *\r\n     *    @param [in] index   The index being evaluated.\r\n     *\r\n     *    @return     True, if column can have expressions, false otherwise.\r\n     */\r\n    virtual bool isValidExpressionColumn(QModelIndex const& index) const;\r\n\r\n    /*!\r\n     *  Gets the expression for the given index or the plain value if expression is not available.\r\n     *\r\n     *    @param [in] index   The index whose expression to get.\r\n     *\r\n     *    @return The expression for the index if available, otherwise the value for the given index.\r\n     */\r\n    virtual QVariant expressionOrValueForIndex(QModelIndex const& index) const;\r\n    \r\n    /*!\r\n     *  Validates the data in a parameter corresponding to a given column.\r\n     *\r\n     *    @param [in] index   The index whose data to validate\r\n     *\r\n     *    @return True, if the data in the parameter is valid, otherwise false.\r\n     */\r\n    virtual bool validateIndex(QModelIndex const& index) const;\r\n\r\n    /*!\r\n     *  Get all the references to the selected parameter from the selected row.\r\n     *\r\n     *    @param [in] row         The selected row.\r\n     *    @param [in] valueID     The id of the referenced parameter.\r\n     *\r\n     *    @return The amount of references to the selected parameter.\r\n     */\r\n    virtual int getAllReferencesToIdInItemOnRow(const int& row, QString const& valueID) const;\r\n\r\nprivate:\r\n\r\n\t// Disable copying.\r\n\tComponentParameterModel(ComponentParameterModel const& rhs);\r\n\tComponentParameterModel& operator=(ComponentParameterModel const& rhs);\r\n\r\n    //! The parameter finder for searching all the parameters.\r\n    QSharedPointer<ParameterFinder> parameterFinder_;\r\n};\r\n\r\n#endif // COMPONENTPARAMETERMODEL_H\r\n"
  },
  {
    "path": "editors/ComponentEditor/parameters/LockableParametersModel.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: LockableParametersModel.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Anton Hagqvist\n// Date: 10.11.2025\n//\n// Description:\n// Implementation of parameters model that allows locking editing of parameters\n//-----------------------------------------------------------------------------\n\n\n#include \"LockableParametersModel.h\"\n#include <KactusAPI/include/ParametersInterface.h>\n\n#include <common/KactusColors.h>\n\n//-----------------------------------------------------------------------------\n// Function: LockableParametersModel::LockableParametersModel()\n//-----------------------------------------------------------------------------\nLockableParametersModel::LockableParametersModel(ParametersInterface* parameterInterface,\n    QSharedPointer<ExpressionParser> expressionParser,\n    QSharedPointer<ParameterFinder> parameterFinder,\n    QObject* parent) :\n    ParametersModel(parameterInterface, expressionParser, parameterFinder, parent)\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: LockableParametersModel::data()\n//-----------------------------------------------------------------------------\nQVariant LockableParametersModel::data(QModelIndex const& index, int role /*= Qt::DisplayRole*/) const\n{\n    if (role == Qt::BackgroundRole)\n    {\n        auto colsToLock = indicesToLock_.value(index.row());\n\n        if (colsToLock.contains(static_cast<ParameterColumns::columns>(index.column())))\n        {\n            return KactusColors::DISABLED_FIELD;\n        }\n    }\n\n    return ParametersModel::data(index, role);\n}\n\n//-----------------------------------------------------------------------------\n// Function: LockableParametersModel::flags()\n//-----------------------------------------------------------------------------\nQt::ItemFlags LockableParametersModel::flags(QModelIndex const& index) const\n{\n    if (indicesToLock_.contains(index.row()) && \n        indicesToLock_.value(index.row())\n            .contains(static_cast<ParameterColumns::columns>(index.column())))\n    {\n        return Qt::ItemIsEnabled | Qt::ItemIsSelectable;\n    }\n\n    return ParametersModel::flags(index);\n}\n\n//-----------------------------------------------------------------------------\n// Function: LockableParametersModel::lockParameterColumn()\n//-----------------------------------------------------------------------------\nvoid LockableParametersModel::lockParameterColumn(QString const& parameterName, ParameterColumns::columns column)\n{\n    auto paramIdx = getInterface()->getItemIndex(parameterName.toStdString());\n    \n    if (indicesToLock_.contains(paramIdx))\n    {\n        indicesToLock_[paramIdx].insert(column);\n    }\n    else\n    {\n        indicesToLock_.insert(paramIdx, QSet<ParameterColumns::columns>({column}));\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: LockableParametersModel::onRemoveItem()\n//-----------------------------------------------------------------------------\nvoid LockableParametersModel::onRemoveItem(QModelIndex const& index)\n{\n    // don't remove anything if index is invalid\n    if (!index.isValid() || index.row() < 0 || index.row() >= rowCount())\n    {\n        return;\n    }\n\n    // Locked parameters cannot be removed\n    if (indicesToLock_.contains(index.row()))\n    {\n        return;\n    }\n\n    ParametersModel::onRemoveItem(index);\n}\n\n//-----------------------------------------------------------------------------\n// Function: LockableParametersModel::resetModelItems()\n//-----------------------------------------------------------------------------\nvoid LockableParametersModel::resetModelItems()\n{\n    indicesToLock_.clear();\n    ParametersModel::resetModelItems();\n}\n"
  },
  {
    "path": "editors/ComponentEditor/parameters/LockableParametersModel.h",
    "content": "//-----------------------------------------------------------------------------\n// File: LockableParametersModel.h\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Anton Hagqvist\n// Date: 10.11.2025\n//\n// Description:\n// Implementation of parameters model that allows locking editing of parameters\n//-----------------------------------------------------------------------------\n\n#ifndef LOCKABLEPARAMETERSMODEL_H\n#define LOCKABLEPARAMETERSMODEL_H\n\n#include \"parametersmodel.h\"\n#include \"ParameterColumns.h\"\n\nclass LockableParametersModel : public ParametersModel\n{\n    Q_OBJECT\npublic:\n\n    /*!\n     *  The constructor\n     *\n     *    @param [in] parameterInterface  Interface for accessing parameters.\n     *    @param [in] expressionParser    Expression parser for configurable elements.\n     *    @param [in] parameterFinder     The parameter finder.\n     *    @param [in] parent              The owner of this model.\n     */\n    LockableParametersModel(ParametersInterface* parameterInterface,\n        QSharedPointer<ExpressionParser> expressionParser,\n        QSharedPointer<ParameterFinder> parameterFinder,\n        QObject* parent);\n\n\t~LockableParametersModel() final = default;\n\n    /*!\n     *  Get the data for the specified item for specified role.\n     *  Overrides background color for locked parameters.\n     *\n     *    @param [in]  index  Identifies the item that's data is wanted.\n     *    @param [in]  role   Specifies what kind of data is wanted.\n     *\n     *    @return  The data for the given index.\n     */\n    QVariant data(QModelIndex const& index, int role = Qt::DisplayRole) const override;\n\n    /*!\n     *  Get information on how specified item can be handled. Disable editing of indices in indicesToLock_.\n     *\n     *    @param [in]  index Specifies the item that's flags are wanted.\n     *\n     *    @return  Qt::ItemFlags that define how object can be handled.\n     */\n    Qt::ItemFlags flags(QModelIndex const& index) const override;\n\n    /*!\n     *\tLock editing of a given column/cell/index of a given parameter.\n     *  \n     *    @param [in] parameterName     Parameter whose cell to lock.\n     *    @param [in] column            The column to lock.\n     */\n    void lockParameterColumn(QString const& parameterName, ParameterColumns::columns column);\n\n    /*!\n     *  Reset the model. Also clears the indices to lock.\n     */\n    void resetModelItems() override;\n\npublic slots:\n\n    /*!\n     *  An item should be removed from the model.\n     *\n     *    @param [in]  index Identifies the item that should be removed.\n     */\n    virtual void onRemoveItem(QModelIndex const& index) override;\n\n\nprivate:\n\n    //! Stores the indices of the model that should be locked.\n    QHash<int, QSet<ParameterColumns::columns> > indicesToLock_;\n\n};\n\n\n#endif // LOCKABLEPARAMETERSMODEL_H\n"
  },
  {
    "path": "editors/ComponentEditor/parameters/ParameterColumns.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ParameterColumns.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Esko Pekkarinen\r\n// Date: 10.11.2014\r\n//\r\n// Description:\r\n// Common declarations for editing parameters.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef PARAMETERCOLUMNS\r\n#define PARAMETERCOLUMNS\r\n\r\nnamespace ParameterColumns\r\n{\r\n    //! The editable columns in the parameter editor.\r\n    enum columns\r\n    {\r\n        NAME = 0,\r\n        DISPLAY_NAME,\r\n        DESCRIPTION,\r\n        TYPE,\r\n        VALUE,\r\n        CHOICE,\r\n        MINIMUM,\r\n        MAXIMUM,\r\n        RESOLVE,\r\n        BITWIDTH_LEFT,\r\n        BITWIDTH_RIGHT,\r\n        ARRAY_LEFT,\r\n        ARRAY_RIGHT,\r\n        USAGE_COUNT,\r\n        ID,\r\n        COLUMN_COUNT\r\n    };\r\n}\r\n\r\n#endif"
  },
  {
    "path": "editors/ComponentEditor/parameters/ParameterDelegate.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ParameterDelegate.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Esko Pekkarinen\r\n// Date: 10.11.2014\r\n//\r\n// Description:\r\n// Delegate that provides widgets for editing parameters.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"ParameterDelegate.h\"\r\n\r\n#include \"ParameterColumns.h\"\r\n\r\n#include <IPXACTmodels/common/validators/namevalidator.h>\r\n#include <IPXACTmodels/common/Choice.h>\r\n\r\n#include <KactusAPI/include/ParameterFinder.h>\r\n#include <KactusAPI/include/IPXactSystemVerilogParser.h>\r\n\r\n#include <editors/ComponentEditor/common/ExpressionLineEditor.h>\r\n#include <editors/ComponentEditor/common/ExpressionEditor.h>\r\n\r\n#include <editors/ComponentEditor/parameters/Array/ParameterArrayModel.h>\r\n#include <editors/ComponentEditor/parameters/Array/ArrayDelegate.h>\r\n#include <editors/ComponentEditor/parameters/Array/ArrayView.h>\r\n\r\n#include <common/KactusColors.h>\r\n\r\n#include <QComboBox>\r\n#include <QCompleter>\r\n#include <QLineEdit>\r\n#include <QPainter>\r\n#include <QScrollArea>\r\n#include <QSortFilterProxyModel>\r\n#include <QComboBox>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ParameterDelegate::ParameterDelegate()\r\n//-----------------------------------------------------------------------------\r\nParameterDelegate::ParameterDelegate(QSharedPointer<QList<QSharedPointer<Choice> > > choices, \r\n    QAbstractItemModel* completionModel, QSharedPointer<ParameterFinder> finder,\r\n    QSharedPointer<ExpressionFormatter> expressionFormatter, QObject* parent /*= 0*/) :\r\nChoiceCreatorDelegate(completionModel, finder, parent),\r\nexpressionFormatter_(expressionFormatter)\r\n{\r\n    setChoices(choices);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ParameterDelegate::~ParameterDelegate()\r\n//-----------------------------------------------------------------------------\r\nParameterDelegate::~ParameterDelegate()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ParameterDelegate::createEditor()\r\n//-----------------------------------------------------------------------------\r\nQWidget* ParameterDelegate::createEditor(QWidget* parent, QStyleOptionViewItem const& option, \r\n    QModelIndex const& index ) const\r\n{\r\n    if (index.column() == nameColumn())\r\n    {\r\n        QWidget* editor = QStyledItemDelegate::createEditor(parent, option, index);\r\n        \r\n        QLineEdit* lineEditor = qobject_cast<QLineEdit*>(editor);\r\n\r\n        if (lineEditor)\r\n        {\r\n            lineEditor->setValidator(new NameValidator(lineEditor));\r\n        }\r\n\r\n        return editor;\r\n    }\r\n\r\n    if (index.column() == choiceColumn()) \r\n    {\r\n        return createChoiceSelector(parent);\r\n    }\r\n    else if (index.column() == formatColumn()) \r\n    {\r\n        return createFormatSelector(parent);\r\n    }\r\n    else if (index.column() == resolveColumn())\r\n    {\r\n        return createResolveSelector(parent);\r\n    }\r\n    else if (index.column() == usageCountColumn())\r\n    {\r\n        QModelIndex valueIdIndex = index.sibling(index.row(), idColumn());\r\n        QModelIndex nameIndex = index.sibling(index.row(), nameColumn());\r\n        QString targetId = valueIdIndex.data(Qt::DisplayRole).toString();\r\n        QString parameterName = nameIndex.data(Qt::DisplayRole).toString();\r\n        emit(openReferenceTree(targetId, parameterName));\r\n\r\n        return 0;\r\n    }\r\n    else if (index.column() == valueColumn() && !choiceNameOnRow(index).isEmpty())\r\n    {\r\n        QComboBox* newCombo(new QComboBox(parent));\r\n        newCombo->setEditable(true);\r\n     \r\n        newCombo->addItem(\"<none>\");\r\n        newCombo->addItems(getChoiceComboItems(index));\r\n\r\n        ExpressionLineEditor* expressionEditor = createExpressionLineEditor(parent);\r\n        newCombo->setLineEdit(expressionEditor);\r\n\r\n        return newCombo;\r\n    }\r\n    else if (index.column() == valueColumn() && valueIsArray(index))\r\n    {\r\n        ArrayView* editor = new ArrayView(parent);\r\n\r\n        QScrollArea* scrollingWidget = new QScrollArea(parent);\r\n        scrollingWidget->setWidgetResizable(true);\r\n        scrollingWidget->setWidget(editor);\r\n\r\n        scrollingWidget->parent()->installEventFilter(editor);\r\n\r\n        return scrollingWidget;\r\n    }\r\n\r\n    else if (index.column() == descriptionColumn())\r\n    {\r\n        QTextEdit* editor = new QTextEdit(parent);\r\n        editor->setMinimumHeight(120);\r\n        return editor;\r\n    }\r\n    else\r\n    {\r\n        return ChoiceCreatorDelegate::createEditor(parent, option, index);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ParameterDelegate::setEditorData()\r\n//-----------------------------------------------------------------------------\r\nvoid ParameterDelegate::setEditorData(QWidget* editor, QModelIndex const& index) const \r\n{\r\n    if (index.column() == valueColumn() && valueIsArray(index))\r\n    {\r\n        ArrayView* view = dynamic_cast<ArrayView*>(dynamic_cast<QScrollArea*>(editor)->widget());\r\n\r\n        QModelIndex arrayLeftIndex = index.sibling(index.row(), arrayLeftColumn());\r\n        int arrayLeftValue = arrayLeftIndex.data(Qt::ToolTipRole).toInt();\r\n\r\n        QModelIndex arrayRightIndex = index.sibling(index.row(), arrayRightColumn());\r\n        int arrayRightValue = arrayRightIndex.data(Qt::ToolTipRole).toInt();\r\n\r\n        int arraySize = getArraySize(arrayLeftValue, arrayRightValue);\r\n\r\n        int arrayStartIndex = arrayLeftValue;\r\n        if (arrayRightValue < arrayLeftValue)\r\n        {\r\n            arrayStartIndex = arrayRightValue;\r\n        }\r\n\r\n        QSharedPointer<IPXactSystemVerilogParser> expressionParser(new IPXactSystemVerilogParser(\r\n            getParameterFinder()));\r\n\r\n        QSharedPointer<Choice> selectedChoice = findChoice(index);\r\n\r\n        ParameterArrayModel* model = new ParameterArrayModel(arraySize, expressionParser, getParameterFinder(),\r\n            expressionFormatter_, selectedChoice, KactusColors::MANDATORY_FIELD, arrayStartIndex, docRevision_, view);\r\n\r\n        QModelIndex valueIndex = index.sibling(index.row(), valueColumn());\r\n        QString parameterValue = valueIndex.data(Qt::EditRole).toString();\r\n        model->setArrayData(parameterValue);\r\n\r\n        QModelIndex typeIndex = index.sibling(index.row(), formatColumn());\r\n        QString parameterType = typeIndex.data(Qt::EditRole).toString();\r\n        model->setParameterType(parameterType);\r\n\r\n        view->setItemDelegate(new ArrayDelegate(completionModel_, getParameterFinder(), selectedChoice,\r\n            this->parent()));\r\n\r\n        view->setModel(model);\r\n        view->setSortingEnabled(false);\r\n        view->resizeColumnsToContents();\r\n\r\n        connect(model, SIGNAL(contentChanged()), this, SIGNAL(contentChanged()), Qt::UniqueConnection);\r\n        connect(model, SIGNAL(dataChanged(const QModelIndex&, const QModelIndex&)),\r\n            this, SIGNAL(contentChanged()), Qt::UniqueConnection);\r\n\r\n        connect(view->itemDelegate(), SIGNAL(increaseReferences(QString)),\r\n            this, SIGNAL(increaseReferences(QString)), Qt::UniqueConnection);\r\n        connect(view->itemDelegate(), SIGNAL(decreaseReferences(QString)),\r\n            this, SIGNAL(decreaseReferences(QString)), Qt::UniqueConnection);\r\n    }\r\n    else if (qobject_cast<QComboBox*>(editor))\r\n    {\r\n        QString text = index.data(Qt::DisplayRole).toString();\r\n        QComboBox* combo = qobject_cast<QComboBox*>(editor);\r\n\r\n        if (index.column() == valueColumn())\r\n        {\r\n            if (text.isEmpty())\r\n            {\r\n                text = \"<none>\";\r\n            }\r\n            else\r\n            {\r\n                QString enumerationValue = findEnumerationValue(index, text);\r\n                if (!enumerationValue.isEmpty())\r\n                {\r\n                    text = text.prepend(enumerationValue + \":\");\r\n                }\r\n            }\r\n        }\r\n\r\n        if (combo->isEditable())\r\n        {\r\n            ExpressionLineEditor* expressionEditor = qobject_cast<ExpressionLineEditor*>(combo->lineEdit());\r\n            if (expressionEditor)\r\n            {\r\n                QString dataText = index.data(Qt::EditRole).toString();\r\n                expressionEditor->setExpression(index.data(Qt::EditRole).toString());\r\n            }\r\n        }\r\n\r\n        int comboIndex = combo->findText(text);\r\n        if (comboIndex < 0)\r\n        {\r\n            combo->addItem(text);\r\n            comboIndex = combo->findText(text);\r\n        }\r\n\r\n        combo->setCurrentIndex(comboIndex);\r\n\r\n    }\r\n\telse if (index.column() == usageCountColumn())\r\n    {\r\n        // Do nothing.\r\n\t}\r\n    else if (index.column() == descriptionColumn())\r\n    {\r\n        QString text = index.data(Qt::EditRole).toString();\r\n        QTextEdit* textEdit = qobject_cast<QTextEdit*>(editor);\r\n\r\n        textEdit->setText(text);\r\n    }\r\n    else\r\n    {\r\n        ChoiceCreatorDelegate::setEditorData(editor, index);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ParameterDelegate::setModelData()\r\n//-----------------------------------------------------------------------------\r\nvoid ParameterDelegate::setModelData(QWidget* editor, QAbstractItemModel* model, \r\n    QModelIndex const& index) const \r\n{\r\n    if (index.column() == valueColumn() && valueIsArray(index))\r\n    {\r\n        QScrollArea* scrollWidget = qobject_cast<QScrollArea*>(editor);\r\n        ArrayView* arrayTable = qobject_cast<ArrayView*>(scrollWidget->widget());\r\n        ParameterArrayModel* arrayModel = qobject_cast<ParameterArrayModel*>(arrayTable->model());\r\n\r\n        QString arrayValue = arrayModel->getArrayData();\r\n        model->setData(index, arrayValue, Qt::EditRole);\r\n    }\r\n    else if (qobject_cast<QComboBox*>(editor))\r\n    {\r\n        QComboBox* combo = qobject_cast<QComboBox*>(editor);\r\n        QString text = combo->currentText();\r\n        \r\n        if (text == \"<none>\")\r\n        {\r\n            text = \"\";\r\n        }\r\n        else if (index.column() == valueColumn() && text.contains(\":\"))\r\n        {\r\n            text = text.left(text.indexOf(\":\"));\r\n        }\r\n        else if (combo->isEditable())\r\n        {\r\n            ExpressionLineEditor* expressionEditor = qobject_cast<ExpressionLineEditor*>(combo->lineEdit());\r\n            if (expressionEditor)\r\n            {\r\n                expressionEditor->finishEditingCurrentWord();\r\n\r\n                text = expressionEditor->getExpression();\r\n            }\r\n        }\r\n\r\n        model->setData(index, text, Qt::EditRole);\r\n    }\r\n    else if (index.column() == descriptionColumn())\r\n    {\r\n        QTextEdit* textEdit = qobject_cast<QTextEdit*>(editor);\r\n\r\n        model->setData(index, textEdit->toPlainText(), Qt::EditRole);\r\n    }\r\n\telse \r\n    {\r\n        ChoiceCreatorDelegate::setModelData(editor, model, index);\r\n\t}\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ParameterDelegate::paint()\r\n//-----------------------------------------------------------------------------\r\nvoid ParameterDelegate::paint(QPainter *painter, QStyleOptionViewItem const& option, \r\n    QModelIndex const& index) const\r\n{\r\n    ChoiceCreatorDelegate::paint(painter, option, index);\r\n\r\n    if (index.column() == maximumColumn() || index.column() == valueColumn() || \r\n        index.column() == arrayRightColumn())\r\n    {\r\n        QPen oldPen = painter->pen();\r\n        QPen newPen(Qt::lightGray);\r\n        newPen.setWidth(2);\r\n        painter->setPen(newPen);\r\n        painter->drawLine(option.rect.topRight() + QPoint(1,1), option.rect.bottomRight() + QPoint(1,1));\r\n        painter->setPen(oldPen);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ParameterDelegate::nameColumn()\r\n//-----------------------------------------------------------------------------\r\nint ParameterDelegate::nameColumn() const\r\n{\r\n    return ParameterColumns::NAME;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ParameterDelegate::choiceColumn()\r\n//-----------------------------------------------------------------------------\r\nint ParameterDelegate::choiceColumn() const\r\n{\r\n    return ParameterColumns::CHOICE;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ParameterDelegate::formatColumn()\r\n//-----------------------------------------------------------------------------\r\nint ParameterDelegate::formatColumn() const\r\n{\r\n    return ParameterColumns::TYPE;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ParameterDelegate::bitWidthLeftColumn()\r\n//-----------------------------------------------------------------------------\r\nint ParameterDelegate::bitWidthLeftColumn() const\r\n{\r\n    return ParameterColumns::BITWIDTH_LEFT;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ParameterDelegate::bitWidthRightColumn()\r\n//-----------------------------------------------------------------------------\r\nint ParameterDelegate::bitWidthRightColumn() const\r\n{\r\n    return ParameterColumns::BITWIDTH_RIGHT;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ParameterDelegate::minimumColumn()\r\n//-----------------------------------------------------------------------------\r\nint ParameterDelegate::minimumColumn() const\r\n{\r\n    return ParameterColumns::MINIMUM;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ParameterDelegate::maximumColumn()\r\n//-----------------------------------------------------------------------------\r\nint ParameterDelegate::maximumColumn() const\r\n{\r\n    return ParameterColumns::MAXIMUM;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ParameterDelegate::valueColumn()\r\n//-----------------------------------------------------------------------------\r\nint ParameterDelegate::valueColumn() const\r\n{\r\n    return ParameterColumns::VALUE;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ParameterDelegate::resolveColumn()\r\n//-----------------------------------------------------------------------------\r\nint ParameterDelegate::resolveColumn() const\r\n{\r\n    return ParameterColumns::RESOLVE;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ParameterDelegate::descriptionColumn()\r\n//-----------------------------------------------------------------------------\r\nint ParameterDelegate::descriptionColumn() const\r\n{\r\n    return ParameterColumns::DESCRIPTION;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ParameterDelegate::arrayLeftColumn()\r\n//-----------------------------------------------------------------------------\r\nint ParameterDelegate::arrayLeftColumn() const\r\n{\r\n    return ParameterColumns::ARRAY_LEFT;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ParameterDelegate::arrayRightColumn()\r\n//-----------------------------------------------------------------------------\r\nint ParameterDelegate::arrayRightColumn() const\r\n{\r\n    return ParameterColumns::ARRAY_RIGHT;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ParameterDelegate::usageCountColumn()\r\n//-----------------------------------------------------------------------------\r\nint ParameterDelegate::usageCountColumn() const\r\n{\r\n    return ParameterColumns::USAGE_COUNT;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ParameterDelegate::valueIdColumn()\r\n//-----------------------------------------------------------------------------\r\nint ParameterDelegate::idColumn() const\r\n{\r\n    return ParameterColumns::ID;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ParameterDelegate::columnAcceptsExpression()\r\n//-----------------------------------------------------------------------------\r\nbool ParameterDelegate::columnAcceptsExpression(int column) const\r\n{\r\n    return column == valueColumn() || column == bitWidthLeftColumn() || column == bitWidthRightColumn() ||\r\n        column == arrayLeftColumn() || column == arrayRightColumn();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ParameterDelegate::choiceNameOnRow()\r\n//-----------------------------------------------------------------------------\r\nQString ParameterDelegate::choiceNameOnRow(QModelIndex const& index) const\r\n{\r\n    return index.sibling(index.row(), choiceColumn()).data().toString();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ParameterDelegate::createFormatEditor()\r\n//-----------------------------------------------------------------------------\r\nQWidget* ParameterDelegate::createFormatSelector(QWidget* parent) const\r\n{\r\n    QComboBox* combo = new QComboBox(parent);\r\n    combo->addItem(QString(\"\"));\r\n    combo->addItem(QString(\"bit\"));\r\n    combo->addItem(QString(\"byte\"));\r\n    combo->addItem(QString(\"shortint\"));\r\n    combo->addItem(QString(\"int\"));\r\n    combo->addItem(QString(\"longint\"));\r\n    combo->addItem(QString(\"shortreal\"));\r\n    combo->addItem(QString(\"real\"));\r\n    combo->addItem(QString(\"string\"));\r\n    return combo;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ParameterDelegate::createChoiceSelector()\r\n//-----------------------------------------------------------------------------\r\nQWidget* ParameterDelegate::createChoiceSelector(QWidget* parent) const\r\n{\r\n    QComboBox* combo = new QComboBox(parent);\r\n    combo->addItem(QString(\"<none>\"));\r\n\r\n    QSharedPointer<QList<QSharedPointer<Choice> > > choices = getChoices();\r\n    if (choices)\r\n    {\r\n        foreach (QSharedPointer<Choice> choice, *getChoices())\r\n        {\r\n            combo->addItem(choice->name());\r\n        }\r\n    }\r\n\r\n    return combo;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ParameterDelegate::createResolveSelector()\r\n//-----------------------------------------------------------------------------\r\nQWidget* ParameterDelegate::createResolveSelector(QWidget* parent) const\r\n{\r\n    QComboBox* combo = new QComboBox(parent);\r\n    combo->addItem(QString(\"immediate\"));\r\n    combo->addItem(QString(\"user\"));\r\n    combo->addItem(QString(\"generated\"));\r\n    combo->addItem(QString());\r\n    return combo;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ParameterDelegate::setStdRevision()\r\n//-----------------------------------------------------------------------------\r\nvoid ParameterDelegate::setStdRevision(Document::Revision docRevision)\r\n{\r\n    docRevision_ = docRevision;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ParameterDelegate::valueIsArray()\r\n//-----------------------------------------------------------------------------\r\nbool ParameterDelegate::valueIsArray(QModelIndex const& index) const\r\n{\r\n    QModelIndex arrayLeftIndex = index.sibling(index.row(), arrayLeftColumn());\r\n    bool arrayLeftIsOk = true;\r\n    int arrayLeftValue = arrayLeftIndex.data(Qt::ToolTipRole).toInt(&arrayLeftIsOk);\r\n    \r\n    QModelIndex arrayRightIndex = index.sibling(index.row(), arrayRightColumn());\r\n    bool arrayRightIsOk = true;\r\n    int arrayRightValue = arrayRightIndex.data(Qt::ToolTipRole).toInt(&arrayRightIsOk);\r\n\r\n    int arraySize = getArraySize(arrayLeftValue, arrayRightValue);\r\n\r\n    return arrayLeftIsOk && arrayRightIsOk && arraySize > 0;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ParameterDelegate::updateEditorGeometry()\r\n//-----------------------------------------------------------------------------\r\nvoid ParameterDelegate::updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option,\r\n    const QModelIndex &index) const\r\n{\r\n    ExpressionDelegate::updateEditorGeometry(editor, option, index);\r\n\r\n    if (index.column() == valueColumn() && valueIsArray(index))\r\n    {\r\n        repositionAndResizeEditor(editor, option, index);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ParameterDelegate::repositionAndResizeEditor()\r\n//-----------------------------------------------------------------------------\r\nvoid ParameterDelegate::repositionAndResizeEditor(QWidget* editor, QStyleOptionViewItem const& option,\r\n    QModelIndex const& index) const\r\n{   \r\n    QModelIndex arrayLeftIndex = index.sibling(index.row(), arrayLeftColumn());\r\n    int arrayLeftValue = arrayLeftIndex.data(Qt::ToolTipRole).toInt();\r\n\r\n    QModelIndex arrayRightIndex = index.sibling(index.row(), arrayRightColumn());\r\n    int arrayRightValue = arrayRightIndex.data(Qt::ToolTipRole).toInt();\r\n\r\n    int arraySize = getArraySize(arrayLeftValue, arrayRightValue);\r\n\r\n    int editorMinimumSize = 24 * (arraySize + 1);\r\n\r\n    editor->setFixedWidth(300);\r\n\r\n    const int PARENT_HEIGHT = editor->parentWidget()->height();\r\n    const int AVAILABLE_HEIGHT_BELOW = PARENT_HEIGHT - option.rect.top();\r\n\r\n    if (AVAILABLE_HEIGHT_BELOW > editorMinimumSize)\r\n    {\r\n        editor->move(option.rect.topLeft());\r\n    }\r\n    else\r\n    {\r\n        int editorNewY = PARENT_HEIGHT-editorMinimumSize;\r\n        if (editorNewY <= 0)\r\n        {\r\n            editorNewY = 0;\r\n        }\r\n\r\n        editor->move(option.rect.left(), editorNewY);\r\n    }\r\n\r\n    if (editorMinimumSize > PARENT_HEIGHT)\r\n    {\r\n        editor->setFixedHeight(PARENT_HEIGHT);\r\n    }\r\n    else\r\n    {\r\n        editor->setFixedHeight(editorMinimumSize);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ParameterDelegate::getArraySize()\r\n//-----------------------------------------------------------------------------\r\nint ParameterDelegate::getArraySize(int arrayLeftValue, int arrayRightValue) const\r\n{\r\n    return abs(arrayLeftValue - arrayRightValue) + 1;\r\n}\r\n"
  },
  {
    "path": "editors/ComponentEditor/parameters/ParameterDelegate.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ParameterDelegate.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Esko Pekkarinen\r\n// Date: 10.11.2014\r\n//\r\n// Description:\r\n// Delegate that provides widgets for editing parameters.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef PARAMETERDELEGATE_H\r\n#define PARAMETERDELEGATE_H\r\n\r\n#include <IPXACTmodels/common/Document.h>\r\n\r\n#include <editors/ComponentEditor/parameters/ChoiceCreatorDelegate.h>\r\n#include <KactusAPI/include/ExpressionFormatter.h>\r\n\r\n#include <QCompleter>\r\n\r\nclass ParameterFinder;\r\nclass Choice;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Delegate that provides widgets for editing parameters.\r\n//-----------------------------------------------------------------------------\r\nclass ParameterDelegate : public ChoiceCreatorDelegate\r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\r\n\t/*!\r\n\t *  The constructor.\r\n\t *\r\n\t *    @param [in] choices                 The choices available for model parameter value.\r\n     *    @param [in] completionModel         Model containing the completions used in expression editor.\r\n\t *    @param [in] finder                  The parameter finder to user for expression editors.\r\n\t *    @param [in] expressionFormatter     The expression formatter for changing ids to parameter names.\r\n\t *    @param [in] parent                  The parent of the object.\r\n\t */\r\n\tParameterDelegate(QSharedPointer<QList<QSharedPointer<Choice> > > choices, \r\n        QAbstractItemModel* completionModel, QSharedPointer<ParameterFinder> finder, \r\n        QSharedPointer<ExpressionFormatter> expressionFormatter, QObject* parent = 0);\r\n\r\n\t//! The destructor\r\n\tvirtual ~ParameterDelegate();\r\n\r\n\t/*! Create a new editor for the given item\r\n\t *\r\n\t *    @param [in] parent   Owner for the editor.\r\n\t *    @param [in] option   Contains options for the editor.\r\n\t *    @param [in] index    Model index identifying the item.\r\n\t *\r\n\t *    @return Pointer to the editor to be used to edit the item.\r\n\t*/\r\n\tvirtual QWidget* createEditor(QWidget* parent, QStyleOptionViewItem const& option, \r\n        QModelIndex const& index) const;\r\n\r\n\t/*! Set the data for the editor.\r\n\t *\r\n\t *    @param [in] editor  Pointer to the editor where the data is to be set.\r\n\t *    @param [in] index   Model index identifying the item that's data is to be set.\r\n\t*/\r\n\tvirtual void setEditorData(QWidget* editor, QModelIndex const& index) const;\r\n\r\n\t/*! Save the data from the editor to the model.\r\n\t *\r\n\t *    @param [in] editor   Pointer to the editor that contains the data to store.\r\n\t *    @param [in] model    Model that contains the data structure where data is to be saved to.\r\n\t *    @param [in] index    Model index identifying the item that's data is to be saved.\r\n\t *\r\n\t*/\r\n\tvirtual void setModelData(QWidget* editor, QAbstractItemModel* model, QModelIndex const& index) const;\r\n\r\n    /*!\r\n     *  Paint the delegate.\r\n     *\r\n     *    @param [in] painter     The painter used.\r\n     *    @param [in] option      Style option in use.\r\n     *    @param [in] index       Index of model.\r\n     */\r\n    virtual void paint(QPainter *painter, QStyleOptionViewItem const& option, QModelIndex const& index) const;\r\n\r\n    /*!\r\n     *  Updates the editor geometry.\r\n     *\r\n     *    @param [in] editor  The editor being updated.\r\n     *    @param [in] option  The options used to update the editor.\r\n     *    @param [in] index   The model index being edited.\r\n     */\r\n    virtual void updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option,\r\n        const QModelIndex &index) const;\r\n\r\n    void setStdRevision(Document::Revision docRevision);\r\n\r\nsignals:\r\n\r\n    /*!\r\n     *  Open the reference tree of the selected parameter.\r\n     *\r\n     *    @param [in] id      The ID of the selected parameter.\r\n     *    @param [in] name    Name of the selected parameter.\r\n     */\r\n    void openReferenceTree(QString const& id, QString const& name) const;\r\n\r\n    //! Emitted when the values of the array change.\r\n    void contentChanged();\r\n\r\nprotected:\r\n\r\n    /*!\r\n     *  Gets the column for name.\r\n     *\r\n     *    @return The column index for editing name.\r\n     */\r\n    virtual int nameColumn() const;\r\n\r\n    /*!\r\n     *  Gets the column for choices.\r\n     *\r\n     *    @return The column for editing choice selection.\r\n     */\r\n    virtual int choiceColumn() const;\r\n\r\n    /*!\r\n     *  Gets the column for value format.\r\n     *\r\n     *    @return The column for editing format selection.\r\n     */\r\n    virtual int formatColumn() const;\r\n    \r\n    /*!\r\n    *  Gets the column for the left value of bit width vector.\r\n    *\r\n    *    @return The column for editing the left value of the bit width vector.\r\n    */\r\n    virtual int bitWidthLeftColumn() const;\r\n\r\n    /*!\r\n    *  Gets the column for the right value of bit width vector.\r\n    *\r\n    *    @return The column for editing the right value of the bit width vector.\r\n    */\r\n    virtual int bitWidthRightColumn() const;\r\n\r\n    /*!\r\n     *  Gets the column for minimum value.\r\n     *\r\n     *    @return The column for editing the minimum value.\r\n     */\r\n    virtual int minimumColumn() const;\r\n    \r\n    /*!\r\n     *  Gets the column for maximum value.\r\n     *\r\n     *    @return The column for editing the maximum value.\r\n     */\r\n    virtual int maximumColumn() const;\r\n\r\n    /*!\r\n     *  Gets the column for values.\r\n     *\r\n     *    @return The column for editing value selection.\r\n     */\r\n    virtual int valueColumn() const;\r\n\r\n    /*!\r\n     *  Gets the column for resolve.\r\n     *\r\n     *    @return The column for editing value selection.\r\n     */\r\n    virtual int resolveColumn() const;\r\n\r\n    /*!\r\n     *  Gets the column for description.\r\n     *\r\n     *    @return     The column for description.\r\n     */\r\n    virtual int descriptionColumn() const;\r\n\r\n    /*!\r\n     *  Gets the column for array left.\r\n     *\r\n     *    @return     The column index for array left.\r\n     */\r\n    virtual int arrayLeftColumn() const;\r\n\r\n    /*!\r\n     *  Gets the column for array right.\r\n     *\r\n     *    @return     The column index for array right.\r\n     */\r\n    virtual int arrayRightColumn() const;\r\n\r\n    /*!\r\n     *  Gets the column for usage count.\r\n     *\r\n     *    @return     The column index for usage count.\r\n     */\r\n    virtual int usageCountColumn() const;\r\n\r\n    /*!\r\n     *  Gets the column index for the id of the parameter.\r\n     *\r\n     *    @return     The column index for the parameter id.\r\n     */\r\n    virtual int idColumn() const;\r\n\r\n    /*!\r\n     *  Checks if the cells in given column accept expression as an input value.\r\n     *\r\n     *    @param [in] column   The column to check.\r\n     *\r\n     *    @return True, if the cells accept expressions, otherwise false.\r\n     */\r\n    virtual bool columnAcceptsExpression(int column) const;\r\n\r\n    /*!\r\n     *  Finds the name of the choice on the row identified by the given index.\r\n     *\r\n     *    @param [in] index   The index on whose row to find the choice name.\r\n     *\r\n     *    @return The name of the choice on the row.\r\n     */\r\n    QString choiceNameOnRow(QModelIndex const& index) const;\r\n\r\n    /*!\r\n     *  Creates an editor for selecting a choice.\r\n     *\r\n     *    @param [in] parent   The parent widget for the editor.\r\n     *\r\n     *    @return An editor for selecting a choice.\r\n     */\r\n    QWidget* createChoiceSelector(QWidget* parent) const;\r\n    \r\n    /*!\r\n     *  Creates an editor for selecting a format for parameter value.\r\n     *\r\n     *    @param [in] parent   The parent widget for the editor.\r\n     *\r\n     *    @return An editor for selecting a format.\r\n     */\r\n    QWidget* createFormatSelector(QWidget* parent) const;\r\n        \r\n    /*!\r\n     *  Creates an editor for selecting resolve attribute of a parameter.\r\n     *\r\n     *    @param [in] parent   The parent widget for the editor.\r\n     *\r\n     *    @return An editor for selecting resolve attribute.\r\n     */\r\n    QWidget* createResolveSelector(QWidget* parent) const;\r\n\r\nprivate:\r\n\r\n\t//! No copying\r\n\tParameterDelegate(const ParameterDelegate& other);\r\n\r\n\t//! No assignment\r\n\tParameterDelegate& operator=(const ParameterDelegate& other);\r\n\r\n    /*!\r\n     *  Check if the value should be an array.\r\n     *\r\n     *    @param [in] index   The index of the current value.\r\n     *\r\n     *    @return True, if the value is an array, otherwise false.\r\n     */\r\n    bool valueIsArray(QModelIndex const& index) const;\r\n\r\n    /*!\r\n     *  Repositions the editor if there is not enough space under the default position. The editor is then resized\r\n     *  to use the available space.\r\n     *\r\n     *    @param [in] editor  The editor to reposition.\r\n     *    @param [in] option  The style options for the editor.\r\n     *    @param [in] index   The current index.\r\n     */\r\n    void repositionAndResizeEditor(QWidget* editor, QStyleOptionViewItem const& option, QModelIndex const& index)\r\n        const;\r\n\r\n    /*!\r\n     *  Gets the size of the array.\r\n     *\r\n     *    @param [in] arrayLeftValue      The left value of the array.\r\n     *    @param [in] arrayRightValue     The right value of the array.\r\n     */\r\n    int getArraySize(int arrayLeftValue, int arrayRightValue) const;\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! The expression formatter used to change parameter uuids in references to parameter names.\r\n    QSharedPointer<ExpressionFormatter> expressionFormatter_;\r\n\r\n    //! The IP-XACT standard revision in use.\r\n    Document::Revision docRevision_ = Document::Revision::Std14;\r\n};\r\n\r\n#endif // ParameterDelegate_H\r\n"
  },
  {
    "path": "editors/ComponentEditor/parameters/ParameterEditorHeaderView.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ParameterEditorHeaderView.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Mikko Teuho\r\n// Date: 11.12.2014\r\n//\r\n// Description:\r\n// Header view for parameter editor.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"ParameterEditorHeaderView.h\"\r\n#include \"ParameterColumns.h\"\r\n\r\n#include <QPainter>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ParameterEditorHeaderView::ParameterEditorHeaderView()\r\n//-----------------------------------------------------------------------------\r\nParameterEditorHeaderView::ParameterEditorHeaderView(Qt::Orientation orientation, QWidget* parent /* = 0 */):\r\nQHeaderView(orientation, parent)\r\n{\r\n    setHighlightSections(true);\r\n    setSectionsClickable(true);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ParameterEditorHeaderView::~ParameterEditorHeaderView()\r\n//-----------------------------------------------------------------------------\r\nParameterEditorHeaderView::~ParameterEditorHeaderView()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ParameterEditorHeaderView::paintSection()\r\n//-----------------------------------------------------------------------------\r\nvoid ParameterEditorHeaderView::paintSection(QPainter *painter, const QRect &rect, int logicalIndex) const\r\n{\r\n    painter->save();\r\n    QHeaderView::paintSection(painter, rect, logicalIndex);\r\n    painter->restore();\r\n\r\n    if ( logicalIndex == maximumColumn() || logicalIndex == valueColumn() || logicalIndex == arrayRightColumn() )\r\n    {\r\n        QPen oldPen = painter->pen();\r\n        QPen newPen(Qt::lightGray);\r\n        newPen.setWidth(2);\r\n\r\n        painter->setPen(newPen);\r\n        painter->drawLine(rect.topRight(), rect.bottomRight());\r\n        painter->setPen(oldPen);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ParameterEditorHeaderView::descriptionColumn()\r\n//-----------------------------------------------------------------------------\r\nint ParameterEditorHeaderView::descriptionColumn() const\r\n{\r\n    return ParameterColumns::DESCRIPTION;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ParameterEditorHeaderView::valueColumn()\r\n//-----------------------------------------------------------------------------\r\nint ParameterEditorHeaderView::valueColumn() const\r\n{\r\n    return ParameterColumns::VALUE;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ParameterEditorHeaderView::maximumColumn()\r\n//-----------------------------------------------------------------------------\r\nint ParameterEditorHeaderView::maximumColumn() const\r\n{\r\n    return ParameterColumns::MAXIMUM;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ParameterEditorHeaderView::arrayRightColumn()\r\n//-----------------------------------------------------------------------------\r\nint ParameterEditorHeaderView::arrayRightColumn() const\r\n{\r\n    return ParameterColumns::ARRAY_RIGHT;\r\n}\r\n"
  },
  {
    "path": "editors/ComponentEditor/parameters/ParameterEditorHeaderView.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ParameterEditorHeaderView.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Mikko Teuho\r\n// Date: 11.12.2014\r\n//\r\n// Description:\r\n// Header view for parameter editor.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef PARAMETEREDITORHEADERVIEW_H\r\n#define PARAMETEREDITORHEADERVIEW_H\r\n\r\n#include <QHeaderView>\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Header view used to drawing the header.\r\n//-----------------------------------------------------------------------------\r\nclass ParameterEditorHeaderView : public QHeaderView\r\n{\r\n\r\npublic:\r\n    /*!\r\n     *  The constructor for the header.\r\n     *\r\n     *    @param [in] orientation     The headers orientation.\r\n     *    @param [in] parent          The parent of the header.\r\n     */\r\n    ParameterEditorHeaderView(Qt::Orientation orientation, QWidget* parent = 0);\r\n\r\n    virtual ~ParameterEditorHeaderView();\r\n\r\nprotected:\r\n    \r\n    /*!\r\n     *  The re-implemented paint section.\r\n     *\r\n     *    @param [in] painter         The given painter.\r\n     *    @param [in] rect            The given rectangle.\r\n     *    @param [in] logicalIndex    Specifies the section.\r\n     */\r\n    virtual void paintSection(QPainter *painter, const QRect &rect, int logicalIndex) const;\r\n\r\n    /*!\r\n     *  Gets the description column.\r\n     *\r\n     *    @return     The index of description column.\r\n     */\r\n    virtual int descriptionColumn() const;\r\n\r\n    /*!\r\n     *  Gets the value column.\r\n     *\r\n     *    @return     The index of value column.\r\n     */\r\n    virtual int valueColumn() const;\r\n\r\n    /*!\r\n     *  Gets the maximum value column.\r\n     *\r\n     *    @return     The index of maximum value column.\r\n     */\r\n    virtual int maximumColumn() const;\r\n\r\n    /*!\r\n     *  Gets the column index for array right.\r\n     *\r\n     *    @return     The index of array right column.\r\n     */\r\n    virtual int arrayRightColumn() const;\r\n\r\nprivate:\r\n\r\n    //! Disable copying and assignment\r\n    ParameterEditorHeaderView(const ParameterEditorHeaderView& other);\r\n    ParameterEditorHeaderView& operator=(const ParameterEditorHeaderView& other);\r\n};\r\n\r\n#endif // PARAMETEREDITORHEADERVIEW_H"
  },
  {
    "path": "editors/ComponentEditor/parameters/ParametersView.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: ParametersView.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Mikko Teuho\n// Date: 04.10.2017\n//\n// Description:\n// View used to display parameters.\n//-----------------------------------------------------------------------------\n\n#include \"ParametersView.h\"\n\n#include <editors/ComponentEditor/parameters/ParameterColumns.h>\n\n#include <QMenu>\n#include <QSortFilterProxyModel>\n\n//-----------------------------------------------------------------------------\n// Function: ParametersView::ParametersView()\n//-----------------------------------------------------------------------------\nParametersView::ParametersView(QWidget* parent):\nEditableTableView(parent),\nrecalculateReferencesAction_(tr(\"Recalculate references\"), this),\nopenReferenceTreeAction_(tr(\"Open reference tree\"), this)\n{\n    setupActions();\n}\n\n//-----------------------------------------------------------------------------\n// Function: ParametersView::~ParametersView()\n//-----------------------------------------------------------------------------\nParametersView::~ParametersView()\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: ParametersView::contextMenuEvent()\n//-----------------------------------------------------------------------------\nvoid ParametersView::contextMenuEvent(QContextMenuEvent* event)\n{\n\tpressedPoint_ = event->pos();\n\n\tQModelIndex index = indexAt(pressedPoint_);\n\n\tQMenu menu(this);\n\n    addBasicActionsForContextMenu(menu, index);\n    addElementCopyActionForContextMenu(menu, index);\n    addRecalculateReferencesActionForContextMenu(menu);\n    addOpenReferenceTreeActionForContextMenu(menu);\n    addImportExportActionsForContextMenu(menu);\n\n\tmenu.exec(event->globalPos());\n\n\tevent->accept();\n}\n\n//-----------------------------------------------------------------------------\n// Function: ParametersView::addRecalculateReferencesActionForContextMenu()\n//-----------------------------------------------------------------------------\nvoid ParametersView::addRecalculateReferencesActionForContextMenu(QMenu& menu)\n{\n    QModelIndexList indexList = selectedIndexes();\n    for (QModelIndex const& currentIndex : indexList)\n    {\n        if (!currentIndex.isValid())\n        {\n            return;\n        }\n    }\n\n    menu.addSeparator();\n    menu.addAction(&recalculateReferencesAction_);\n}\n\n//-----------------------------------------------------------------------------\n// Function: ParametersView::addOpenReferenceTreeActionForContextMenu()\n//-----------------------------------------------------------------------------\nvoid ParametersView::addOpenReferenceTreeActionForContextMenu(QMenu& menu)\n{\n    QModelIndexList indexList = selectedIndexes();\n\n    // Context menu action should be shown only when at least one index is selected.\n    if (indexList.isEmpty())\n    {\n        return;\n    }\n\n    for (QModelIndex const& currentIndex : indexList)\n    {\n        if (!currentIndex.isValid())\n        {\n            return;\n        }\n    }\n\n    menu.addSeparator();\n    menu.addAction(&openReferenceTreeAction_);\n}\n\n//-----------------------------------------------------------------------------\n// Function: ParametersView::setupActions()\n//-----------------------------------------------------------------------------\nvoid ParametersView::setupActions()\n{\n    EditableTableView::setupActions();\n\n    addAction(&recalculateReferencesAction_);\n    recalculateReferencesAction_.setToolTip(tr(\"Recalculate the references made to the parameter\"));\n    recalculateReferencesAction_.setStatusTip(tr(\"Recalculate the references made to the parameter\"));\n    connect(&recalculateReferencesAction_, SIGNAL(triggered()),\n        this, SLOT(onRecalculateReferencesAction()), Qt::UniqueConnection);\n\n    addAction(&openReferenceTreeAction_);\n    openReferenceTreeAction_.setToolTip(tr(\"Display references to selected parameters\"));\n    openReferenceTreeAction_.setStatusTip(tr(\"Display references to selected parameters\"));\n    connect(&openReferenceTreeAction_, SIGNAL(triggered()),\n        this, SLOT(onOpenReferenceTreeAction()), Qt::UniqueConnection);\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: ParametersView::onRecalculateReferencesAction()\n//-----------------------------------------------------------------------------\nvoid ParametersView::onRecalculateReferencesAction()\n{\n    QModelIndexList indexes = selectedIndexes();\n    QModelIndexList sortedIndexes;\n    QSortFilterProxyModel* sortProxy = dynamic_cast<QSortFilterProxyModel*>(model());\n\n    for (int i = 0; i < indexes.size(); ++i)\n    {\n        QModelIndex newIndex = sortProxy->mapToSource(indexes.at(i));\n        sortedIndexes.append(newIndex);\n    }\n    \n    // Do recalculation for all parameters, if none were selected.\n    if (sortedIndexes.isEmpty())\n    {\n        for (int i = 0; i < model()->rowCount(); ++i)\n        {\n            QModelIndex currentIndex = model()->index(i, ParameterColumns::USAGE_COUNT);\n            sortedIndexes.append(currentIndex);\n        }\n    }\n\n    emit(recalculateReferenceToIndexes(sortedIndexes));\n}\n\n//-----------------------------------------------------------------------------\n// Function: ParametersView::onOpenReferenceTreeAction()\n//-----------------------------------------------------------------------------\nvoid ParametersView::onOpenReferenceTreeAction()\n{\n    QModelIndex index = currentIndex();\n    QModelIndex valueIdIndex = index.sibling(index.row(), ParameterColumns::ID);\n    QModelIndex nameIndex = index.sibling(index.row(), ParameterColumns::NAME);\n    QString targetId = valueIdIndex.data(Qt::DisplayRole).toString();\n    QString parameterName = nameIndex.data(Qt::DisplayRole).toString();\n\n    emit(openReferenceTree(targetId, parameterName));\n}\n"
  },
  {
    "path": "editors/ComponentEditor/parameters/ParametersView.h",
    "content": "//-----------------------------------------------------------------------------\n// File: ParametersView.h\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Mikko Teuho\n// Date: 04.10.2017\n//\n// Description:\n// View used to display parameters.\n//-----------------------------------------------------------------------------\n\n#ifndef PARAMETERSVIEW_H\n#define PARAMETERSVIEW_H\n\n#include <common/views/EditableTableView/editabletableview.h>\n\n//-----------------------------------------------------------------------------\n//! View used to display parameters.\n//-----------------------------------------------------------------------------\nclass ParametersView : public EditableTableView\n{\n\tQ_OBJECT\n\npublic:\n\n\t/*!\n     *  The constructor.\n\t *\n     *    @param [in] parent  Pointer to the owner of this view.\n\t */\n\tParametersView(QWidget* parent);\n\n\t/*!\n     *  The destructor.\n     */\n    virtual ~ParametersView();\n\nsignals:\n\n    /*!\n     *  Recalculate references made to the parameters contained in the selected indexes.\n     *\n     *    @param [in] selectedIndexes     The selected indexes.\n     */\n    void recalculateReferenceToIndexes(QModelIndexList selectedIndexes);\n\n    /*!\n     *  Open the reference tree of the selected parameter.\n     *\n     *    @param [in] id      The ID of the selected parameter.\n     *    @param [in] name    Name of the selected parameter.\n     */\n    void openReferenceTree(QString const& id, QString const& name);\n\nprotected:\n\n\t/*!\n     *  Handler for context menu events\n     */\n\tvirtual void contextMenuEvent(QContextMenuEvent* event);\n\n    /*!\n     *  Set up the actions for the context menu\n     */\n    virtual void setupActions();\n\nprivate slots:\n\n    /*!\n     *  Handles the action for recalculating the parameter references.\n     */\n    void onRecalculateReferencesAction();\n\n    /*!\n     *  Handles the action for opening the reference tree of the selected parameter.\n     */\n    void onOpenReferenceTreeAction();\nprivate:\n\n\t//! No copying. No assignment.\n\tParametersView(const ParametersView& other);\n\tParametersView& operator=(const ParametersView& other);\n\n    /*!\n     *  Add the recalculate references action to the context menu.\n     *\n     *    @param [in] menu    The context menu for the actions.\n     */\n    void addRecalculateReferencesActionForContextMenu(QMenu& menu);\n\n    /*!\n     *  Add the open reference tree to the context menu.\n     *\n     *    @param [in] menu    The context menu for the actions.\n     */\n    void addOpenReferenceTreeActionForContextMenu(QMenu& menu);\n\n    //-----------------------------------------------------------------------------\n    // Data.\n    //-----------------------------------------------------------------------------\n\n    //! Action for recalculating references made to the selected parameter.\n    QAction recalculateReferencesAction_;\n\n    //! Action for opening the reference tree of the selected parameter.\n    QAction openReferenceTreeAction_;\n};\n\n#endif // PARAMETERSVIEW_H\n"
  },
  {
    "path": "editors/ComponentEditor/parameters/parameterseditor.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: parameterseditor.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 04.04.2011\r\n//\r\n// Description:\r\n// The editor to add/remove/edit parameters.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"parameterseditor.h\"\r\n\r\n#include \"ParameterColumns.h\"\r\n#include \"ParameterDelegate.h\"\r\n#include \"ParameterEditorHeaderView.h\"\r\n\r\n#include <common/widgets/summaryLabel/summarylabel.h>\r\n\r\n#include <KactusAPI/include/IPXactSystemVerilogParser.h>\r\n#include <editors/ComponentEditor/parameters/ComponentParameterModel.h>\r\n#include <editors/ComponentEditor/parameters/ParametersView.h>\r\n#include <KactusAPI/include/ParametersInterface.h>\r\n\r\n#include <IPXACTmodels/Component/Component.h>\r\n\r\n#include <KactusAPI/include/LibraryInterface.h>\r\n\r\n#include <QCompleter>\r\n#include <QVBoxLayout>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ParametersEditor::ParametersEditor()\r\n//-----------------------------------------------------------------------------\r\nParametersEditor::ParametersEditor(QSharedPointer<Component> component, LibraryInterface* handler,\r\n    QSharedPointer<ParameterFinder> parameterFinder,\r\n    QSharedPointer<ExpressionParser> expressionParser, QSharedPointer<ExpressionFormatter> expressionFormatter,\r\n    ParametersInterface* parameterInterface, QWidget *parent):\r\nParameterItemEditor(component, handler, parent),\r\nview_(new ParametersView(this)),\r\nmodel_(0),\r\nparameterInterface_(parameterInterface)\r\n{\r\n    view_->verticalHeader()->show();\r\n    view_->verticalHeader()->setMaximumWidth(300);\r\n    view_->verticalHeader()->setMinimumWidth(view_->horizontalHeader()->fontMetrics().horizontalAdvance(tr(\"Name\"))*2);\r\n    view_->verticalHeader()->setSectionResizeMode(QHeaderView::Fixed);\r\n\r\n    model_ = new ParametersModel(parameterInterface, expressionParser, parameterFinder, this);\r\n\r\n    ComponentParameterModel* componentParametersModel = new ComponentParameterModel(parameterFinder, this);\r\n    componentParametersModel->setExpressionParser(expressionParser);\r\n\r\n\r\n\tconnect(model_, SIGNAL(contentChanged()), this, SIGNAL(contentChanged()), Qt::UniqueConnection);\r\n\tconnect(model_, SIGNAL(dataChanged(const QModelIndex&, const QModelIndex&)),\r\n\t\tthis, SIGNAL(contentChanged()), Qt::UniqueConnection);\r\n\tconnect(model_, SIGNAL(errorMessage(const QString&)),\r\n        this, SIGNAL(errorMessage(const QString&)), Qt::UniqueConnection);\r\n\tconnect(model_, SIGNAL(noticeMessage(const QString&)),\r\n\t\tthis, SIGNAL(noticeMessage(const QString&)), Qt::UniqueConnection);\r\n\r\n    connect(view_, SIGNAL(addItem(const QModelIndex&)),\r\n        model_, SLOT(onAddItem(const QModelIndex&)), Qt::UniqueConnection);\r\n    connect(view_, SIGNAL(removeItem(const QModelIndex&)),\r\n        model_, SLOT(onRemoveItem(const QModelIndex&)), Qt::UniqueConnection);\r\n\r\n\tconst QString compPath = ItemEditor::handler()->getDirectoryPath(ItemEditor::component()->getVlnv());\r\n\tQString defPath = QString(\"%1/parameterList.csv\").arg(compPath);\r\n\r\n    ParameterEditorHeaderView* parameterHorizontalHeader = new ParameterEditorHeaderView(Qt::Horizontal, this);\r\n    view_->setHorizontalHeader(parameterHorizontalHeader);\r\n\r\n    view_->horizontalHeader()->setSectionsClickable(true);\r\n    view_->horizontalHeader()->setStretchLastSection(true);\r\n\r\n    view_->setDefaultImportExportPath(defPath);\r\n    view_->setAllowImportExport(true);\r\n\r\n    view_->setSortingEnabled(true);\r\n    view_->setItemsDraggable(false);\r\n\r\n    view_->setItemDelegate(new ParameterDelegate(component->getChoices(), componentParametersModel, parameterFinder,\r\n        expressionFormatter, this));\r\n\r\n    connect(view_->itemDelegate(), SIGNAL(increaseReferences(QString)),\r\n        this, SIGNAL(increaseReferences(QString)), Qt::UniqueConnection);\r\n    connect(view_->itemDelegate(), SIGNAL(decreaseReferences(QString)),\r\n        this, SIGNAL(decreaseReferences(QString)), Qt::UniqueConnection);\r\n\r\n    connect(model_, SIGNAL(decreaseReferences(QString)),\r\n        this, SIGNAL(decreaseReferences(QString)), Qt::UniqueConnection);\r\n\r\n    connect(view_->itemDelegate(), SIGNAL(openReferenceTree(QString const&, QString const&)),\r\n        this, SIGNAL(openReferenceTree(QString const&, QString const&)), Qt::UniqueConnection);\r\n\r\n    connect(view_, SIGNAL(openReferenceTree(QString const&, QString const&)),\r\n        this, SIGNAL(openReferenceTree(QString const&, QString const&)), Qt::UniqueConnection);\r\n\r\n\t// set proxy to do the sorting automatically\r\n\tQSortFilterProxyModel* sortingProxy = new QSortFilterProxyModel(this);\r\n\r\n\t// set source model for proxy\r\n\tsortingProxy->setSourceModel(model_);\r\n\t// set proxy to be the source for the view\r\n    view_->setModel(sortingProxy);\r\n\r\n    view_->resizeColumnsToContents();\r\n\r\n    sortingProxy->setSortCaseSensitivity(Qt::CaseInsensitive);\r\n\r\n    view_->sortByColumn(0, Qt::AscendingOrder);\r\n\r\n    // display a label on top the table\r\n\tSummaryLabel* summaryLabel = new SummaryLabel(tr(\"Parameters\"), this);\r\n\r\n\t// create the layout, add widgets to it\r\n\tQVBoxLayout* layout = new QVBoxLayout(this);\r\n    layout->addWidget(summaryLabel, 0, Qt::AlignCenter);\r\n    layout->addWidget(view_);\r\n\tlayout->setContentsMargins(0, 0, 0, 0);\r\n\r\n    connect(view_, SIGNAL(recalculateReferenceToIndexes(QModelIndexList)),\r\n        model_, SLOT(onGetParametersMachingIndexes(QModelIndexList)), Qt::UniqueConnection);\r\n    connect(model_,\r\n        SIGNAL(recalculateReferencesToParameters(QVector<QString> const&, AbstractParameterInterface*)),\r\n        this,\r\n        SIGNAL(recalculateReferencesToParameters(QVector<QString> const&, AbstractParameterInterface*)),\r\n        Qt::UniqueConnection);\r\n\r\n    parameterInterface_->setParameters(component->getParameters());\r\n\r\n\trefresh();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ParametersEditor::refresh()\r\n//-----------------------------------------------------------------------------\r\nvoid ParametersEditor::refresh()\r\n{\r\n    view_->update();\r\n\r\n    if (!view_->isColumnHidden(ParameterColumns::ID))\r\n    {\r\n        view_->setColumnHidden(ParameterColumns::ID, true);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ParametersEditor::showEvent()\r\n//-----------------------------------------------------------------------------\r\nvoid ParametersEditor::showEvent( QShowEvent* event )\r\n{\r\n\tQWidget::showEvent(event);\r\n\temit helpUrlRequested(\"componenteditor/params.html\");\r\n}\r\n"
  },
  {
    "path": "editors/ComponentEditor/parameters/parameterseditor.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: parameterseditor.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 04.04.2011\r\n//\r\n// Description:\r\n// The editor to add/remove/edit parameters.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef PARAMETERSEDITOR_H\r\n#define PARAMETERSEDITOR_H\r\n\r\n#include <editors/ComponentEditor/ParameterItemEditor.h>\r\n#include <editors/ComponentEditor/parameters/parametersmodel.h>\r\n#include <KactusAPI/include/ExpressionFormatter.h>\r\n#include <KactusAPI/include/ParameterFinder.h>\r\n\r\n#include <QSortFilterProxyModel>\r\n#include <QSharedPointer>\r\n\r\nclass LibraryInterface;\r\nclass Component;\r\nclass ParametersView;\r\nclass ParameterValidator;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Editor to add/edit/remove parameters of a component.\r\n//-----------------------------------------------------------------------------\r\nclass ParametersEditor : public ParameterItemEditor\r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\r\n\t/*!\r\n\t *  The constructor.\r\n\t *\r\n\t *    @param [in] component               Pointer to the component being edited.\r\n\t *    @param [in] handler                 Pointer to the instance managing the library.\r\n     *    @param [in] parameterFinder         Pointer to the instance searching for parameters.\r\n     *    @param [in] expressionParser        Expression parser for configurable elements.\r\n\t *    @param [in] expressionFormatter     Pointer to the instance formatting the expressions.\r\n     *    @param [in] parameterInterface      Interface for accessing parameters.\r\n     *    @param [in] parent                  Pointer to the owner of this widget.\r\n\t */\r\n    ParametersEditor(QSharedPointer<Component> component,\r\n        LibraryInterface* handler,\r\n        QSharedPointer<ParameterFinder> parameterFinder,\r\n        QSharedPointer<ExpressionParser> expressionParser,\r\n        QSharedPointer<ExpressionFormatter> expressionFormatter,\r\n        ParametersInterface* parameterInterface,\r\n        QWidget *parent = 0);\r\n\r\n\t/*!\r\n     *  The destructor.\r\n     */\r\n\tvirtual ~ParametersEditor() = default;\r\n\r\n\t/*!\r\n     *  Reload the information from the model to the editor.\r\n\t */\r\n\tvirtual void refresh();\r\n\r\nprotected:\r\n\r\n\t/*!\r\n     *  Handler for widget's show event.\r\n     */\r\n\tvirtual void showEvent(QShowEvent* event);\r\n\r\nprivate:\r\n\r\n\t//! No copying.\r\n\tParametersEditor(const ParametersEditor& other);\r\n\r\n\t//! No assignment.\r\n\tParametersEditor& operator=(const ParametersEditor& other);\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! The view that displays the parameters.\r\n    ParametersView* view_;\r\n\r\n\t//! The model that holds the data to be displayed to the user\r\n\tParametersModel* model_;\r\n\r\n    //! Interface for accessing parameters.\r\n    ParametersInterface* parameterInterface_;\r\n};\r\n\r\n#endif // PARAMETERSEDITOR_H\r\n"
  },
  {
    "path": "editors/ComponentEditor/parameters/parametersmodel.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: parametersmodel.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 4.4.2011\r\n//\r\n// Description:\r\n// Table model that can be used to display parameters to be edited.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"parametersmodel.h\"\r\n#include \"ParameterColumns.h\"\r\n\r\n#include <IPXACTmodels/common/Choice.h>\r\n\r\n#include <KactusAPI/include/ParametersInterface.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ParametersModel::ParametersModel()\r\n//-----------------------------------------------------------------------------\r\nParametersModel::ParametersModel(ParametersInterface* parameterInterface,\r\n    QSharedPointer<ExpressionParser> expressionParser,\r\n    QSharedPointer<ParameterFinder> parameterFinder, QObject *parent) :\r\nAbstractParameterModel(parameterInterface, expressionParser, parameterFinder, parent)\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ParametersModel::columnCount()\r\n//-----------------------------------------------------------------------------\r\nint ParametersModel::columnCount(QModelIndex const& parent) const\r\n{\r\n\tif (parent.isValid())\r\n    {\r\n\t\treturn 0;\r\n\t}\r\n\r\n\treturn ParameterColumns::COLUMN_COUNT;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: parametersmodel::resetModel()\r\n//-----------------------------------------------------------------------------\r\nvoid ParametersModel::resetModelItems()\r\n{\r\n    beginResetModel();\r\n    endResetModel();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ParametersModel::addParameterManually()\r\n//-----------------------------------------------------------------------------\r\nvoid ParametersModel::addParameterManually(QString const& parameterName)\r\n{\r\n\r\n    ParametersInterface* parameterInterface = dynamic_cast<ParametersInterface*>(getInterface());\r\n    if (parameterInterface)\r\n    {\r\n        int row = parameterInterface->itemCount();\r\n        beginInsertRows(QModelIndex(), row, row);\r\n        parameterInterface->addParameter(row, parameterName.toStdString());\r\n        endInsertRows();\r\n\r\n        // tell also parent widget that contents have been changed\r\n        emit contentChanged();\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ParametersModel::onAddItem()\r\n//-----------------------------------------------------------------------------\r\nvoid ParametersModel::onAddItem(QModelIndex const& index)\r\n{\r\n    int row = getInterface()->itemCount();\r\n\r\n    // if the index is valid then add the item to the correct position\r\n    if (index.isValid())\r\n    {\r\n        row = index.row();\r\n    }\r\n\r\n    ParametersInterface* parameterInterface = dynamic_cast<ParametersInterface*>(getInterface());\r\n    if (parameterInterface)\r\n    {\r\n        beginInsertRows(QModelIndex(), row, row);\r\n        parameterInterface->addParameter(row);\r\n        endInsertRows();\r\n\r\n        // tell also parent widget that contents have been changed\r\n        emit contentChanged();\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ParametersModel::onRemoveItem()\r\n//-----------------------------------------------------------------------------\r\nvoid ParametersModel::onRemoveItem(QModelIndex const& index ) \r\n{\r\n\t// don't remove anything if index is invalid\r\n \tif (!index.isValid() || index.row() < 0 || index.row() >= rowCount()) \r\n    {\r\n\t\treturn;\r\n\t}\r\n\r\n    if (canRemoveRow(index.row()))\r\n    {\r\n        ParametersInterface* parameterInterface = dynamic_cast<ParametersInterface*>(getInterface());\r\n        if (parameterInterface)\r\n        {\r\n            std::string parameterName = getInterface()->getIndexedItemName(index.row());\r\n\r\n            // remove the specified item\r\n            beginRemoveRows(QModelIndex(), index.row(), index.row());\r\n            parameterInterface->removeParameter(parameterName);\r\n            endRemoveRows();\r\n\r\n            // tell also parent widget that contents have been changed\r\n            emit contentChanged();\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ParametersModel::nameColumn()\r\n//-----------------------------------------------------------------------------\r\nint ParametersModel::nameColumn() const\r\n{\r\n    return ParameterColumns::NAME;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ParametersModel::displayNameColumn()\r\n//-----------------------------------------------------------------------------\r\nint ParametersModel::displayNameColumn() const\r\n{\r\n    return ParameterColumns::DISPLAY_NAME;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ParameterDelegate::choiceColumn()\r\n//-----------------------------------------------------------------------------\r\nint ParametersModel::choiceColumn() const\r\n{\r\n    return ParameterColumns::CHOICE;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ParameterDelegate::formatColumn()\r\n//-----------------------------------------------------------------------------\r\nint ParametersModel::typeColumn() const\r\n{\r\n    return ParameterColumns::TYPE;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: parametersmodel::bitWidthLeftColumn()\r\n//-----------------------------------------------------------------------------\r\nint ParametersModel::bitWidthLeftColumn() const\r\n{\r\n    return ParameterColumns::BITWIDTH_LEFT;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: parametersmodel::bitWidthRightColumn()\r\n//-----------------------------------------------------------------------------\r\nint ParametersModel::bitWidthRightColumn() const\r\n{\r\n    return ParameterColumns::BITWIDTH_RIGHT;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ParameterDelegate::minimumColumn()\r\n//-----------------------------------------------------------------------------\r\nint ParametersModel::minimumColumn() const\r\n{\r\n    return ParameterColumns::MINIMUM;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ParameterDelegate::maximumColumn()\r\n//-----------------------------------------------------------------------------\r\nint ParametersModel::maximumColumn() const\r\n{\r\n    return ParameterColumns::MAXIMUM;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ParameterDelegate::valueColumn()\r\n//-----------------------------------------------------------------------------\r\nint ParametersModel::valueColumn() const\r\n{\r\n    return ParameterColumns::VALUE;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ParameterDelegate::resolveColumn()\r\n//-----------------------------------------------------------------------------\r\nint ParametersModel::resolveColumn() const\r\n{\r\n    return ParameterColumns::RESOLVE;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: parametersmodel::arrayLeftColumn()\r\n//-----------------------------------------------------------------------------\r\nint ParametersModel::arrayLeftColumn() const\r\n{\r\n    return ParameterColumns::ARRAY_LEFT;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: parametersmodel::arrayRightColumn()\r\n//-----------------------------------------------------------------------------\r\nint ParametersModel::arrayRightColumn() const\r\n{\r\n    return ParameterColumns::ARRAY_RIGHT;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ParametersModel::descriptionColumn()\r\n//-----------------------------------------------------------------------------\r\nint ParametersModel::descriptionColumn() const\r\n{\r\n    return ParameterColumns::DESCRIPTION;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: parametersmodel::idColumn()\r\n//-----------------------------------------------------------------------------\r\nint ParametersModel::idColumn() const\r\n{\r\n    return ParameterColumns::ID;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: parametersmodel::usageCountColumn()\r\n//-----------------------------------------------------------------------------\r\nint ParametersModel::usageCountColumn() const\r\n{\r\n    return ParameterColumns::USAGE_COUNT;\r\n}\r\n"
  },
  {
    "path": "editors/ComponentEditor/parameters/parametersmodel.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: parametersmodel.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 04.04.2011\r\n//\r\n// Description:\r\n// Table model that can be used to display parameters to be edited.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef PARAMETERSMODEL_H\r\n#define PARAMETERSMODEL_H\r\n\r\n#include <IPXACTmodels/common/Parameter.h>\r\n\r\n#include <editors/ComponentEditor/common/AbstractParameterModel.h>\r\n#include <KactusAPI/include/ExpressionFormatter.h>\r\n#include <KactusAPI/include/ParameterFinder.h>\r\n\r\n#include <QAbstractTableModel>\r\n\r\n#include <QSharedPointer>\r\n#include <QList>\r\n\r\nclass Choice;\r\nclass Component;\r\nclass ParametersInterface;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Table model that can be used to display parameters to be edited.\r\n//-----------------------------------------------------------------------------\r\nclass ParametersModel : public AbstractParameterModel\r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\r\n\t/*!\r\n     *  The constructor\r\n\t *\r\n     *    @param [in] parameterInterface  Interface for accessing parameters.\r\n     *    @param [in] expressionParser    Expression parser for configurable elements.\r\n     *    @param [in] parameterFinder     The parameter finder.\r\n\t *    @param [in] parent              The owner of this model.\r\n     */\r\n    ParametersModel(ParametersInterface* parameterInterface,\r\n        QSharedPointer<ExpressionParser> expressionParser,\r\n        QSharedPointer<ParameterFinder> parameterFinder,\r\n        QObject *parent);\r\n\r\n\t/*!\r\n     *  The destructor.\r\n     */\r\n\tvirtual ~ParametersModel() = default;\r\n\r\n\t/*!\r\n     *  Get the number of columns in the model.\r\n\t *\r\n\t *    @param [in] parent  Model index of the parent of the item.\r\n\t *\r\n\t *    @return  Number of columns currently in the model.\r\n     */\r\n\tvirtual int columnCount(QModelIndex const& parent = QModelIndex()) const;\r\n\r\n    /*!\r\n     *  Reset the model.\r\n     */\r\n    virtual void resetModelItems();\r\n\r\n    void addParameterManually(QString const& parameterName);\r\n\r\npublic slots:\r\n\r\n\t/*!\r\n     *  A new item should be added to given index.\r\n\t *\r\n\t *    @param [in]  index The position where new item should be added at.\r\n     */\r\n\tvirtual void onAddItem(QModelIndex const& index);\r\n\r\n\t/*!\r\n     *  An item should be removed from the model.\r\n\t * \r\n\t *    @param [in]  index Identifies the item that should be removed.\r\n     */\r\n\tvirtual void onRemoveItem(QModelIndex const& index);\r\n\r\nprotected:\r\n\r\n    /*!\r\n     *  Gets the column for value format.\r\n     *\r\n     *    @return The column for editing format selection.\r\n     */\r\n    virtual int nameColumn() const;\r\n        \r\n    /*!\r\n     *  Gets the column for value format.\r\n     *\r\n     *    @return The column for editing format selection.\r\n     */\r\n    virtual int displayNameColumn() const;\r\n\r\n    /*!\r\n     *  Gets the column for value format.\r\n     *\r\n     *    @return The column for editing format selection.\r\n     */\r\n    virtual int typeColumn() const;\r\n\r\n    /*!\r\n    *  Gets the column for the left value of bit width vector.\r\n    *\r\n    *    @return The column for editing the left value of the bit width vector.\r\n    */\r\n    virtual int bitWidthLeftColumn() const;\r\n\r\n    /*!\r\n    *  Gets the column for the right value of bit width vector.\r\n    *\r\n    *    @return The column for editing the right value of the bit width vector.\r\n    */\r\n    virtual int bitWidthRightColumn() const;\r\n\r\n    /*!\r\n     *  Gets the column for minimum value.\r\n     *\r\n     *    @return The column for editing the minimum value.\r\n     */\r\n    virtual int minimumColumn() const;\r\n        \r\n    /*!\r\n     *  Gets the column for maximum value.\r\n     *\r\n     *    @return The column for editing the maximum value.\r\n     */\r\n    virtual int maximumColumn() const;\r\n        \r\n    /*!\r\n     *  Gets the column for choices.\r\n     *\r\n     *    @return The column for editing choice selection.\r\n     */\r\n    virtual int choiceColumn() const;\r\n\r\n    /*!\r\n     *  Gets the column for values.\r\n     *\r\n     *    @return The column for editing value selection.\r\n     */\r\n    virtual int valueColumn() const;\r\n    \r\n    /*!\r\n     *  Gets the column for resolve.\r\n     *\r\n     *    @return The column for editing value selection.\r\n     */\r\n    virtual int resolveColumn() const;\r\n    \r\n    /*!\r\n     *  Gets the column for array left.\r\n     *\r\n     *    @return The column for editing array left.\r\n     */\r\n    virtual int arrayLeftColumn() const;\r\n\r\n    /*!\r\n     *  Gets the column for array right.\r\n     *\r\n     *    @return The column for editing array right.\r\n     */\r\n    virtual int arrayRightColumn() const;\r\n\r\n    /*!\r\n     *  Gets the column for description.\r\n     *\r\n     *    @return The column for editing description.\r\n     */\r\n    virtual int descriptionColumn() const;\r\n\r\n    /*!\r\n     *  Gets the column index for parameter ids.\r\n     *\r\n     *    @return     The column index for parameter ids.\r\n     */\r\n    virtual int idColumn() const;\r\n\r\n    /*!\r\n     *  Gets the column index for usage count.\r\n     *\r\n     *    @return     The column index for usage count.\r\n     */\r\n    virtual int usageCountColumn() const;\r\n\r\nprivate:\r\n\r\n\t//! No copying\r\n\tParametersModel(const ParametersModel& other);\r\n\r\n\t//! No assignment\r\n\tParametersModel& operator=(const ParametersModel& other);\r\n};\r\n\r\n#endif // PARAMETERSMODEL_H\r\n"
  },
  {
    "path": "editors/ComponentEditor/ports/MasterPortsEditor.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: MasterPortsEditor.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 29.04.2019\n//\n// Description:\n// Master editor for component ports.\n//-----------------------------------------------------------------------------\n\n#include \"MasterPortsEditor.h\"\n\n#include <KactusAPI/include/BusInterfaceInterface.h>\n#include <editors/ComponentEditor/ports/portsdelegate.h>\n#include <editors/ComponentEditor/ports/portsmodel.h>\n#include <editors/ComponentEditor/ports/PortsView.h>\n#include <editors/ComponentEditor/ports/PortsFilter.h>\n#include <editors/ComponentEditor/ports/PortsEditorFactory.h>\n#include <KactusAPI/include/PortsInterface.h>\n\n#include <common/widgets/summaryLabel/summarylabel.h>\n\n#include <KactusAPI/include/LibraryInterface.h>\n\n#include <IPXACTmodels/AbstractionDefinition/AbstractionDefinition.h>\n#include <IPXACTmodels/Component/Component.h>\n#include <IPXACTmodels/Component/validators/PortValidator.h>\n\n#include <QCompleter>\n#include <QVBoxLayout>\n\n//-----------------------------------------------------------------------------\n// Function: MasterPortsEditor::MasterPortsEditor()\n//-----------------------------------------------------------------------------\nMasterPortsEditor::MasterPortsEditor(QSharedPointer<Component> component, LibraryInterface* handler,\n    QSharedPointer<PortsInterface> portsInterface,\n    PortsEditorFactory const* editorConstructor, \n    BusInterfaceInterface* busInterface, QWidget *parent):\nItemEditor(component, handler, parent),\nview_(editorConstructor->createView(this)),\nproxy_(editorConstructor->createFilter(this)),\nmodel_(editorConstructor->createModel(this)),\ndelegate_(editorConstructor->createDelegate(this)),\nportInterface_(portsInterface),\nbusInterface_(busInterface)\n{\n\n    view_->setItemDelegate(delegate_);\n\n    proxy_->setSourceModel(model_);\n    view_->setModel(proxy_);\n\n    view_->resizeColumnsToContents();\n\n    proxy_->setSortCaseSensitivity(Qt::CaseInsensitive);\n\n    connectSignals();\n\n    auto layout = new QVBoxLayout(this);\n    layout->addWidget(view_, 1);\n    layout->setContentsMargins(0, 0, 0, 0);\n}\n\n//-----------------------------------------------------------------------------\n// Function: MasterPortsEditor::connectSignals()\n//-----------------------------------------------------------------------------\nvoid MasterPortsEditor::connectSignals()\n{\n    connect(model_, SIGNAL(contentChanged()), this, SIGNAL(contentChanged()), Qt::UniqueConnection);\n    connect(model_, SIGNAL(dataChanged(const QModelIndex&, const QModelIndex&)),\n        this, SIGNAL(contentChanged()), Qt::UniqueConnection);\n    connect(model_, SIGNAL(errorMessage(const QString&)),\n        this, SIGNAL(errorMessage(const QString&)), Qt::UniqueConnection);\n    connect(model_, SIGNAL(noticeMessage(const QString&)),\n        this, SIGNAL(noticeMessage(const QString&)), Qt::UniqueConnection);\n\n    connect(view_, SIGNAL(addItem(const QModelIndex&)),\n        model_, SLOT(onAddItem(const QModelIndex&)), Qt::UniqueConnection);\n    connect(view_, SIGNAL(removeItem(const QModelIndex&)),\n        model_, SLOT(onRemoveItem(const QModelIndex&)), Qt::UniqueConnection);\n\n    connect(view_, SIGNAL(createBus(QStringList const&)),\n        this, SIGNAL(createNewInteface(QStringList const&)), Qt::UniqueConnection);\n    connect(view_, SIGNAL(createExistingBus(QStringList const&)),\n        this, SIGNAL(createInterface(QStringList const&)), Qt::UniqueConnection);\n\n    connect(view_->itemDelegate(), SIGNAL(increaseReferences(QString)),\n        this, SIGNAL(increaseReferences(QString)), Qt::UniqueConnection);\n    connect(view_->itemDelegate(), SIGNAL(decreaseReferences(QString)),\n        this, SIGNAL(decreaseReferences(QString)), Qt::UniqueConnection);\n\n    connect(model_, SIGNAL(decreaseReferences(QString)),\n        this, SIGNAL(decreaseReferences(QString)), Qt::UniqueConnection);\n\n    connect(delegate_, SIGNAL(contentChanged()), this, SIGNAL(contentChanged()), Qt::UniqueConnection);\n\n    connect(view_, SIGNAL(changeExtensionsEditorItem(QModelIndex const&)),\n        proxy_, SLOT(onHandleExtensionsEditorItemChange(QModelIndex const&)), Qt::UniqueConnection);\n    connect(proxy_, SIGNAL(changeExtensionsEditorItem(QModelIndex const&)),\n        this, SIGNAL(changeExtensionsEditorItem(QModelIndex const&)), Qt::UniqueConnection);\n\n    connect(model_, SIGNAL(portExtensionDataChanged(QModelIndex const&)),\n        this, SIGNAL(changeExtensionsEditorItem(QModelIndex const&)), Qt::UniqueConnection);\n\n    connect(model_, SIGNAL(invalidateOtherFilter()), this, SIGNAL(invalidateOtherFilter()), Qt::UniqueConnection);\n    connect(this, SIGNAL(ivalidateThisFilter()), proxy_, SLOT(invalidate()), Qt::UniqueConnection);\n\n    connect(model_, SIGNAL(portCountChanged()), this, SIGNAL(portCountChanged()), Qt::UniqueConnection);\n\n    connect(view_, SIGNAL(createPortsFromAbstraction(std::string const&, QString const&)),\n        this, SLOT(onCreatePortsFromAbstraction(std::string const&, QString const&)), Qt::UniqueConnection);\n}\n\n//-----------------------------------------------------------------------------\n// Function: MasterPortsEditor::getAmountOfPorts()\n//-----------------------------------------------------------------------------\nint MasterPortsEditor::getAmountOfPorts() const\n{\n    return proxy_->rowCount();\n}\n\n//-----------------------------------------------------------------------------\n// Function: MasterPortsEditor::isValid()\n//-----------------------------------------------------------------------------\nbool MasterPortsEditor::isValid() const\n{\n\treturn model_->isValid();\n}\n\n//-----------------------------------------------------------------------------\n// Function: MasterPortsEditor::refresh()\n//-----------------------------------------------------------------------------\nvoid MasterPortsEditor::refresh()\n{\n    proxy_->invalidate();\n}\n\n//-----------------------------------------------------------------------------\n// Function: MasterPortsEditor::setAllowImportExport()\n//-----------------------------------------------------------------------------\nvoid MasterPortsEditor::setAllowImportExport(bool allow)\n{\n\tview_->setAllowImportExport(allow);\n}\n\n//-----------------------------------------------------------------------------\n// Function: MasterPortsEditor::setComponent()\n//-----------------------------------------------------------------------------\nvoid MasterPortsEditor::setComponent(QSharedPointer<Component> component)\n{\n    model_->resetModelAndLockCurrentPorts();\n    delegate_->setComponent(component);\n}\n\n//-----------------------------------------------------------------------------\n// Function: MasterPortsEditor::getIndexedPort()\n//-----------------------------------------------------------------------------\nQSharedPointer<Port> MasterPortsEditor::getIndexedPort(QModelIndex const& portIndex) const\n{\n    return portInterface_->getPort(portInterface_->getIndexedItemName(portIndex.row()));\n}\n\n//-----------------------------------------------------------------------------\n// Function: MasterPortsEditor::onCreatePortsFromAbstraction()\n//-----------------------------------------------------------------------------\nvoid MasterPortsEditor::onCreatePortsFromAbstraction(std::string const& busName, QString const& abstractionString)\n{\n    const VLNV abstractionVLNV(VLNV::ABSTRACTIONDEFINITION, abstractionString);\n    QSharedPointer<const Document> vlnvDocument = handler()->getModelReadOnly(abstractionVLNV);\n    if (vlnvDocument)\n    {\n        QSharedPointer<const AbstractionDefinition> abstraction =\n            vlnvDocument.dynamicCast<const AbstractionDefinition>();\n        if (abstraction)\n        {\n            General::InterfaceMode busMode = busInterface_->getMode(busName);\n            General::InterfaceMode busMonitorMode = busInterface_->getMonitorMode(busName);\n            QString systemGroup = QString::fromStdString(busInterface_->getSystemGroup(busName));\n\n            model_->onCreatePortsFromAbstraction(abstraction, busMode, busMonitorMode, systemGroup);\n        }\n    }\n}\n"
  },
  {
    "path": "editors/ComponentEditor/ports/MasterPortsEditor.h",
    "content": "//-----------------------------------------------------------------------------\n// File: MasterPortsEditor.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 29.04.2019\n//\n// Description:\n// Master editor for component ports.\n//-----------------------------------------------------------------------------\n\n#ifndef MASTERPORTSEDITOR_H\n#define MASTERPORTSEDITOR_H\n\n#include <editors/ComponentEditor/itemeditor.h>\n\n#include <QAbstractItemModel>\n#include <QSharedPointer>\n#include <QWidget>\n\nclass ExpressionParser;\nclass ParameterFinder;\nclass ExpressionFormatter;\nclass LibraryInterface;\nclass Component;\nclass Port;\nclass PortsModel;\nclass PortsView;\nclass PortValidator;\nclass PortsDelegate;\nclass PortsFilter;\nclass PortsEditorFactory;\nclass PortsInterface;\nclass BusInterfaceInterface;\nclass PortAbstractionInterface;\n\n//-----------------------------------------------------------------------------\n//! Master editor for component ports.\n//-----------------------------------------------------------------------------\nclass MasterPortsEditor : public ItemEditor\n{\n\tQ_OBJECT\n\npublic:\n\n\t/*!\n\t *  The constructor.\n\t *\n\t *    @param [in] component           The component being edited.\n\t *    @param [in] handler             The instance that manages the library.\n     *    @param [in] portsInterface      Interface for accessing the component ports.\n     *    @param [in] editorConstructor   Constructor for required modules.\n     *    @param [in] completionModel     Model containing the completions used in expression editor.\n     *    @param [in] busInterface        Interface for accessing bus interfaces.\n\t *    @param [in] parent              The owner of this widget.\n\t */\n    MasterPortsEditor(QSharedPointer<Component> component,\n        LibraryInterface* handler,\n        QSharedPointer<PortsInterface> portsInterface,\n        PortsEditorFactory const* editorConstructor,\n        BusInterfaceInterface* busInterface,\n        QWidget *parent = 0);\n\n\t/*!\n     *  The destructor.\n     */\n    virtual ~MasterPortsEditor() = default;\n\n\t/*!\n     *  Check for the validity of the edited ports.\n     *\n     *    @return True if all ports are in valid state.\n     */\n\tvirtual bool isValid() const;\n\n\t/*!\n     *  Reload the information from the model to the editor.\n\t */\n\tvirtual void refresh();\n\n\t/*!\n     *  Enable/disable the import/export csv functionality for the view.\n\t *\n\t *    @param [in] allow   If true then import/export is enabled.\n\t */\n\tvoid setAllowImportExport(bool allow);\n\n    /*!\n     *  Sets the edited component.\n     *\n     *    @param [in] component   The component whose ports to edit.\n     */\n    void setComponent(QSharedPointer<Component> component);\n\n    /*!\n     *  Get the port for the selected index.\n     *\n     *    @param [in] portIndex   The selected index.\n     *\n     *    @return Port from the selected index.\n     */\n    QSharedPointer<Port> getIndexedPort(QModelIndex const& portIndex) const;\n\n    /*!\n     *  Get the current amount of visible ports in the editor.\n     *\n     *    @return The amount of visible ports.\n     */\n    int getAmountOfPorts() const;\n\n    //! No copying.\n    MasterPortsEditor(const MasterPortsEditor& other) = delete;\n    MasterPortsEditor& operator=(const MasterPortsEditor& other) = delete;\n\nsignals:\n\n    /*!\n     *  Handler for new interface creation for new bus definition.\n     *\n     *    @param [in] selectedPorts   Ports to be mapped in the interface.\n     */\n    void createNewInteface(QStringList const& selectedPorts);\n\n    /*!\n     *  Handler for new interface creation for existing bus definition.\n     *\n     *    @param [in] selectedPorts   Ports to be mapped in the interface.\n     */\n    void createInterface(QStringList const& selectedPorts);\n\n    /*!\n     *  Change the vendor extensions of the vendor extensions editor.\n     *\n     *    @param [in] itemIndex   Index of the selected port.\n     */\n    void changeExtensionsEditorItem(QModelIndex const& itemIndex);\n\n    /*!\n     *  Invalidate the filter from the other ports editor.\n     */\n    void invalidateOtherFilter();\n\n    /*!\n     *  Invalidate the filter from this editor.\n     */\n    void ivalidateThisFilter();\n\n    /*!\n     *  Inform that the port count has changed.\n     */\n    void portCountChanged();\n\nprivate slots:\n\n    /*!\n     *  Handle port creation from the selected abstraction definition of a bus interface.\n     *\n     *    @param [in] busName             Name of the selected bus interface.\n     *    @param [in] abstractionString   VLNV string of the abstraction definition.\n     */\n    void onCreatePortsFromAbstraction(std::string const& busName, QString const& abstractionString);\n\nprivate:\n\n    /*!\n     *  Connect the editor signals.\n     */\n    void connectSignals();\n\n    //-----------------------------------------------------------------------------\n    // Data.\n    //-----------------------------------------------------------------------------\n\n\t//! The view that displays the ports.\n\tPortsView* view_;\n\n\t//! The proxy that is used to sort the view.\n\tPortsFilter* proxy_;\n\n    //! The model that holds the data to be displayed to the user.\n    PortsModel* model_;\n\n    //! The delegate for ports.\n    PortsDelegate* delegate_;\n\n    //! Interface for accessing ports.\n    QSharedPointer<PortsInterface> portInterface_;\n\n    //! Interface for accessing bus interfaces.\n    BusInterfaceInterface* busInterface_;\n};\n\n#endif // MASTERPORTSEDITOR_H\n"
  },
  {
    "path": "editors/ComponentEditor/ports/PortSummaryColumns.h",
    "content": "//-----------------------------------------------------------------------------\n// File: PortSummaryColumns.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Esko Pekkarinen\n// Date: 27.11.2023\n//\n// Description:\n// \n//-----------------------------------------------------------------------------\n\n#ifndef PORT_SUMMARY_COLUMNS_H\n#define PORT_SUMMARY_COLUMNS_H\n\nnamespace PortSummaryColumns\n{\n    //-----------------------------------------------------------------------------\n    // Constants defining which column represents what kind of information.\n    //-----------------------------------------------------------------------------\n    enum Columns\n    {\n        ROW_NUMBER = 0,         //!< Column for the row number.\n        NAME = 1,               //!< Column for the port name.\n        TYPE = 2,               //!< Column for the port type: wire/transactional/structured.\n        TAG_GROUP = 3,          //!< Column for tagging a port.\n        ADHOC_VISIBILITY = 4,   //!< Column for toggling ad-hoc visibility on/off.\n        DESCRIPTION = 5,        //!< Column for adding a description for the port.\n        ARRAY_LEFT = -1,        //!< Column for setting the left side of the array. Disabled.\n        ARRAY_RIGHT = -1,       //!< Column for setting the right side of the array. Disabled.\n        TYPE_NAME = -1,         //!< Column for the port typename. Disabled.\n    };\n\n    constexpr static auto COLUMN_COUNT = 6;\n}\n\n#endif // PORT_SUMMARY_COLUMNS_H"
  },
  {
    "path": "editors/ComponentEditor/ports/PortSummaryDelegate.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: PortSummaryDelegate.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Esko Pekkarinen\n// Date: 28.11.2023\n//\n// Description:\n// Delegate for port summary model.\n//-----------------------------------------------------------------------------\n\n#include \"PortSummaryDelegate.h\"\n#include \"PortSummaryColumns.h\"\n\n//-----------------------------------------------------------------------------\n// Function: PortSummaryDelegate::columnAcceptsExpression()\n//-----------------------------------------------------------------------------\nbool PortSummaryDelegate::columnAcceptsExpression(int column) const\n{\n    return PortsDelegate::columnAcceptsExpression(column);\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortSummaryDelegate::descriptionColumn()\n//-----------------------------------------------------------------------------\nint PortSummaryDelegate::descriptionColumn() const\n{\n    return PortSummaryColumns::DESCRIPTION;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortSummaryDelegate::nameColumn()\n//-----------------------------------------------------------------------------\nint PortSummaryDelegate::nameColumn() const\n{\n    return PortSummaryColumns::NAME;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortSummaryDelegate::typeColumn()\n//-----------------------------------------------------------------------------\nint PortSummaryDelegate::typeColumn() const\n{\n    return PortSummaryColumns::TYPE_NAME;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortSummaryDelegate::tagColumn()\n//-----------------------------------------------------------------------------\nint PortSummaryDelegate::tagColumn() const\n{\n    return PortSummaryColumns::TAG_GROUP;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortSummaryDelegate::adHocColumn()\n//-----------------------------------------------------------------------------\nint PortSummaryDelegate::adHocColumn() const\n{\n    return PortSummaryColumns::ADHOC_VISIBILITY;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortSummaryDelegate::arrayLeftColumn()\n//-----------------------------------------------------------------------------\nint PortSummaryDelegate::arrayLeftColumn() const\n{\n    return PortSummaryColumns::ARRAY_LEFT;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortSummaryDelegate::arrayRightColumn()\n//-----------------------------------------------------------------------------\nint PortSummaryDelegate::arrayRightColumn() const\n{\n    return PortSummaryColumns::ARRAY_RIGHT;\n}\n"
  },
  {
    "path": "editors/ComponentEditor/ports/PortSummaryDelegate.h",
    "content": "//-----------------------------------------------------------------------------\n// File: PortSummaryDelegate.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Esko Pekkarinen\n// Date: 28.11.2023\n//\n// Description:\n// Delegate for port summary model.\n//-----------------------------------------------------------------------------\n\n#ifndef PORT_SUMMARY_DELEGATE_H\n#define PORT_SUMMARY_DELEGATE_H\n\n#include <editors/ComponentEditor/ports/portsdelegate.h>\n\n#include <QCompleter>\n\nclass ParameterFinder;\nclass Component;\nclass PortTypeValidator;\n\n//-----------------------------------------------------------------------------\n//! Delegate for port summary model.\n//-----------------------------------------------------------------------------\nclass PortSummaryDelegate : public PortsDelegate\n{\n\tQ_OBJECT\n\npublic:\n\n    /*!\n     *  The constructor.\n     *\n     *    @param [in] component           Component containing the edited ports.\n     *    @param [in] completionModel     Model containing the completions used in expression editor.\n     *    @param [in] parameterFinder     The parameter finder to use for for expression editor.\n     *    @param [in] typeValidator       Validator for port type definitions.\n     *    @param [in] parent              The parent object.\n     */\n    using PortsDelegate::PortsDelegate;\n\t\n\t/*!\n     *  The destructor.\n     */\n    ~PortSummaryDelegate() = default;\n\nprotected:\n    \n    /*!\n     *  Checks if the given column supports expressions in the editor.\n     *\n     *    @param [in] column   The column to check.\n     *\n     *    @return True, if the cells in the column allow expressions, otherwise false.\n     */\n    bool columnAcceptsExpression(int column) const final;\n\n    /*!\n     *  Gets the description column.\n     *\n     *    @return Column number for description.\n     */\n    int descriptionColumn() const final;\n\nprivate:\n\n    /*!\n     *  Gets the name column.\n     *\n     *    @return Column number for name.\n     */\n    int nameColumn() const final;\n\n    /*!\n     *  Gets the type definitions column.\n     *\n     *    @return Column number for type definitions.\n     */\n     int typeColumn() const final;\n\n    /*!\n     *  Gets the tag group column.\n     *\n     *    @return Column number for tag group.\n     */\n    int tagColumn() const final;\n\n    /*!\n     *  Gets the ad hoc column.\n     *\n     *    @return Column number for ad hoc.\n     */\n    int adHocColumn() const final;\n\n    /*!\n     *  Gets the array left column.\n     *\n     *    @return Column number for left value of the array.\n     */\n    int arrayLeftColumn() const final;\n\n    /*!\n     *  Gets the array right column.\n     *\n     *    @return Column number for right value of the array.\n     */\n    int arrayRightColumn() const final;\n\n};\n\n#endif // PORT_SUMMARY_DELEGATE_H\n"
  },
  {
    "path": "editors/ComponentEditor/ports/PortSummaryEditorFactory.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: PortSummaryEditorFactory.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Esko Pekkarinen\n// Date: 28.11.2023\n//\n// Description:\n// Creates the components of port summary editor.\n//-----------------------------------------------------------------------------\n\n#include \"PortSummaryEditorFactory.h\"\n\n#include \"PortSummaryView.h\"\n#include \"PortSummaryColumns.h\"\n#include \"PortSummaryFilter.h\"\n#include \"PortSummaryDelegate.h\"\n#include \"PortSummaryModel.h\"\n\n#include <editors/ComponentEditor/parameters/ComponentParameterModel.h>\n\n#include <IPXACTmodels/Component/Component.h>\n#include <IPXACTmodels/Component/validators/PortValidator.h>\n\n#include <QCompleter>\n\n//-----------------------------------------------------------------------------\n// Function: PortSummaryEditorFactory::createModel()\n//-----------------------------------------------------------------------------\nPortsModel* PortSummaryEditorFactory::createModel(QObject* parent) const\n{\n    return new PortSummaryModel(expressions_.finder, portsInterface_, signalInterface_, parent);\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortSummaryEditorFactory::constructFilter()\n//-----------------------------------------------------------------------------\nPortsFilter* PortSummaryEditorFactory::createFilter(QObject* parent) const\n{\n    return new PortSummaryFilter(portsInterface_, parent);\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortSummaryEditorFactory::constructView()\n//-----------------------------------------------------------------------------\nPortsView* PortSummaryEditorFactory::createView(QWidget* parent) const\n{\n    auto view = new PortSummaryView(PortSummaryColumns::NAME, busInterface_, parent);\n\n    view->setDefaultImportExportPath(defaultPath_);\n    view->setAllowImportExport(false);\n    view->setAlternatingRowColors(false);\n    view->setSortingEnabled(true);\n    view->setItemsDraggable(false);\n    view->setFitColumnsToContent(false);\n\n    return view;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortSummaryEditorFactory::createDelegate()\n//-----------------------------------------------------------------------------\nPortsDelegate* PortSummaryEditorFactory::createDelegate(QObject* parent) const\n{\n    auto componentParametersModel = new ComponentParameterModel(expressions_.finder, parent);\n    componentParametersModel->setExpressionParser(expressions_.parser);\n\n    return new PortSummaryDelegate(\n        component_, componentParametersModel, expressions_.finder, portValidator_->getTypeValidator(), parent);\n}\n"
  },
  {
    "path": "editors/ComponentEditor/ports/PortSummaryEditorFactory.h",
    "content": "//-----------------------------------------------------------------------------\n// File: PortSummaryEditorFactory.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Esko Pekkarinen\n// Date: 28.11.2023\n//\n// Description:\n// Creates the components of port summary editor.\n//-----------------------------------------------------------------------------\n\n#ifndef PORT_SUMMARY_EDITOR_FACTORY_H\n#define PORT_SUMMARY_EDITOR_FACTORY_H\n\n#include <editors/ComponentEditor/ports/PortsEditorFactory.h>\n\n#include <QSortFilterProxyModel>\n#include <QSharedPointer>\n#include <QWidget>\n#include <QAbstractItemModel>\n\nclass Component;\nclass PortsModel;\nclass PortsView;\nclass PortValidator;\nclass PortsDelegate;\nclass ExpressionParser;\n\n//-----------------------------------------------------------------------------\n//! Creates the components of port summary editor.\n//-----------------------------------------------------------------------------\nclass PortSummaryEditorFactory : public PortsEditorFactory\n{\npublic:\n\n    using PortsEditorFactory::PortsEditorFactory;\n\n    /*!\n     *  The destructor.\n     */\n    ~PortSummaryEditorFactory() = default;\n\n    /*!\n     *  Construct a ports model.\n     *\n    *    @param [in] parent              The owner of the constructed model.\n     *\n     *    @return The created ports model.\n     */\n    PortsModel* createModel(QObject* parent) const  final;\n\n    /*!\n     *  Construct a filter.\n     *\n     *    @param [in] parent          Owner of the filter.\n     *\n     *    @return The created ports filter.\n     */\n    PortsFilter* createFilter(QObject* parent) const final;\n\n    /*!\n     *  Construct a view.\n     *\n     *    @param [in] parent          Owner of the view.\n     *\n     *    @return The created view.\n     */\n    PortsView* createView(QWidget* parent) const final;\n\n    /*!\n     *  Construct a delegate.\n     *\n     *    @param [in] parent              The owner of the delegate.\n     *\n     *    @return The created delegate.\n     */\n    PortsDelegate* createDelegate(QObject* parent) const final;\n\n};\n\n#endif // PORT_SUMMARY_EDITOR_FACTORY_H\n"
  },
  {
    "path": "editors/ComponentEditor/ports/PortSummaryFilter.h",
    "content": "//-----------------------------------------------------------------------------\n// File: PortSummaryFilter.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Esko Pekkarinen\n// Date: 28.11.2023\n//\n// Description:\n// \n//-----------------------------------------------------------------------------\n\n#ifndef PORT_SUMMARY_FILTER_H\n#define PORT_SUMMARY_FILTER_H\n\n#include \"PortSummaryColumns.h\"\n#include \"PortsFilter.h\"\n\n//-----------------------------------------------------------------------------\n//! Sorting proxy model for wire ports.\n//-----------------------------------------------------------------------------\nclass PortSummaryFilter : public PortsFilter\n{\n    Q_OBJECT\n\npublic:\n\n\t /*!\n      *  Constructor.\n      *\n      *    @param [in] portsInterface     Interface for accessing the component ports.\n      *    @param [in] parent             The parent object.\n      */\n    using PortsFilter::PortsFilter;\n\n\t /*!\n      *  Destructor.\n      */\n    ~PortSummaryFilter() = default;\n\nprivate:\n\n    /*!\n     *  Get the index of the name column.\n     *\n     *    @return Index of the name column.\n     */\n    int nameColumn() const final \n    {\n        return PortSummaryColumns::NAME;\n    }\n\n    /*!\n     *  Check if a port is filtered.\n     *\n     *    @param [in] portName    Name of the selected port.\n     *\n     *    @return True, if the port is accepted, false otherwise.\n     */\n    bool portIsAccepted(QString const& /*portName*/) const final\n    {\n        return true;\n    }\n\n};\n\n#endif // PORT_SUMMARY_FILTER_H"
  },
  {
    "path": "editors/ComponentEditor/ports/PortSummaryModel.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: PortSummaryModel.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 06.05.2019\n//\n// Description:\n// Table model for wire ports.\n//-----------------------------------------------------------------------------\n\n#include \"PortSummaryModel.h\"\n\n#include \"PortSummaryColumns.h\"\n\n#include <KactusAPI/include/PortsInterface.h>\n\n#include <IPXACTmodels/common/DirectionTypes.h>\n\n#include <QIcon>\n\n//-----------------------------------------------------------------------------\n// Function: PortSummaryModel::PortSummaryModel()\n//-----------------------------------------------------------------------------\nPortSummaryModel::PortSummaryModel(QSharedPointer<ParameterFinder> parameterFinder,\n    QSharedPointer<PortsInterface> portsInterface, QSharedPointer<PortAbstractionInterface> signalInterface,\n    QObject *parent):\nPortsModel(parameterFinder, portsInterface, signalInterface, parent)\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortSummaryModel::columnCount()\n//-----------------------------------------------------------------------------\nint PortSummaryModel::columnCount(QModelIndex const& parent) const\n{\n\tif (parent.isValid())\n    {\n\t\treturn 0;\n    }\n\n \treturn PortSummaryColumns::COLUMN_COUNT;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortSummaryModel::headerData()\n//-----------------------------------------------------------------------------\nQVariant PortSummaryModel::headerData(int section, Qt::Orientation orientation, int role) const\n{\n    if (orientation == Qt::Horizontal && section == PortSummaryColumns::TYPE && role == Qt::DisplayRole)\n    {\n        return tr(\"Type\");\n    }\n\n    return PortsModel::headerData(section, orientation, role);\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortSummaryModel::data()\n//-----------------------------------------------------------------------------\nQVariant PortSummaryModel::data(QModelIndex const& index, int role) const\n{\n    if (!index.isValid() || index.row() < 0 || index.row() >= getInterface()->itemCount())\n    {\n        return QVariant();\n    }\n\n    return PortsModel::data(index, role);\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortSummaryModel::setData()\n//-----------------------------------------------------------------------------\nbool PortSummaryModel::setData(QModelIndex const& index, QVariant const& value, int role)\n{\n    if (PortsModel::setData(index, value, role))\n    {\n        return true;\n    }\n    else if (!index.isValid() || index.row() < 0 || index.row() >= rowCount())\n    {\n\t\treturn false;\n    }\n\n    std::string portName = getInterface()->getIndexedItemName(index.row());\n\n\tif (role == Qt::EditRole)\n    {\n        if (isLocked(index))\n        {\n            return false;\n        }\n\n    }\n    // unsupported role\n    else\n    {\n        return false;\n    }\n\n    return false;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortSummaryModel::onAddWire()\n//-----------------------------------------------------------------------------\nvoid PortSummaryModel::onAddWire()\n{\n    auto const row = rowCount();\n\n    beginInsertRows(QModelIndex(), row, row);\n    getInterface()->addWirePort();\n    endInsertRows();\n\n    emit invalidateOtherFilter();\n    emit portCountChanged();\n\n    // tell also parent widget that contents have been changed\n    emit contentChanged();\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortSummaryModel::onAddTransactional()\n//-----------------------------------------------------------------------------\nvoid PortSummaryModel::onAddTransactional()\n{\n    auto const row = rowCount();\n\n    beginInsertRows(QModelIndex(), row, row);\n    getInterface()->addTransactionalPort();\n    endInsertRows();\n\n    emit invalidateOtherFilter();\n    emit portCountChanged();\n\n    // tell also parent widget that contents have been changed\n    emit contentChanged();\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortSummaryModel::valueForIndex()\n//-----------------------------------------------------------------------------\nQVariant PortSummaryModel::valueForIndex(QModelIndex const& index) const\n{\n    if (index.column() == PortSummaryColumns::TYPE)\n    {\n        const auto ports = getInterface();\n        std::string portName = ports->getIndexedItemName(index.row());\n\n        if (ports->portIsWire(portName))\n        {\n            return tr(\"wire\");\n        }\n        else if (ports->portIsTransactional(portName))\n        {\n            return tr(\"transactional\");\n        }\n        else\n        {\n            return tr(\"unknown\");\n        }\n       \n    }\n    \n    return PortsModel::valueForIndex(index);\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortSummaryModel::isValidExpressionColumn()\n//-----------------------------------------------------------------------------\nbool PortSummaryModel::isValidExpressionColumn(QModelIndex const& /*index*/) const\n{\n    return false;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortSummaryModel::isPortTypeColumn()\n//-----------------------------------------------------------------------------\nbool PortSummaryModel::isPortTypeColumn(QModelIndex const& /*index*/) const\n{\n    return false;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortSummaryModel::formattedExpressionForIndex()\n//-----------------------------------------------------------------------------\nQVariant PortSummaryModel::formattedExpressionForIndex(QModelIndex const& index) const\n{\n  \n        return PortsModel::formattedExpressionForIndex(index);\n    \n}\n\n//-----------------------------------------------------------------------------\n// Function: PortSummaryModel::expressionOrValueForIndex()\n//-----------------------------------------------------------------------------\nQVariant PortSummaryModel::expressionOrValueForIndex(QModelIndex const& index) const\n{\n    if (isValidExpressionColumn(index))\n    {\n        return expressionForIndex(index);\n    }\n    else\n    {\n        return valueForIndex(index);\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortSummaryModel::rowNumberColumn()\n//-----------------------------------------------------------------------------\nint PortSummaryModel::rowNumberColumn() const\n{\n    return PortSummaryColumns::ROW_NUMBER;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortSummaryModel::nameColumn()\n//-----------------------------------------------------------------------------\nint PortSummaryModel::nameColumn() const\n{\n    return PortSummaryColumns::NAME;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortSummaryModel::typeColumn()\n//-----------------------------------------------------------------------------\nint PortSummaryModel::typeColumn() const\n{\n    return PortSummaryColumns::TYPE_NAME;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortSummaryModel::arrayLeftColumn()\n//-----------------------------------------------------------------------------\nint PortSummaryModel::arrayLeftColumn() const\n{\n    return PortSummaryColumns::ARRAY_LEFT;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortSummaryModel::arrayRightColum()\n//-----------------------------------------------------------------------------\nint PortSummaryModel::arrayRightColum() const\n{\n    return PortSummaryColumns::ARRAY_RIGHT;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortSummaryModel::tagColumn()\n//-----------------------------------------------------------------------------\nint PortSummaryModel::tagColumn() const\n{\n    return PortSummaryColumns::TAG_GROUP;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortSummaryModel::adHocColumn()\n//-----------------------------------------------------------------------------\nint PortSummaryModel::adHocColumn() const\n{\n    return PortSummaryColumns::ADHOC_VISIBILITY;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortSummaryModel::descriptionColumn()\n//-----------------------------------------------------------------------------\nint PortSummaryModel::descriptionColumn() const\n{\n    return PortSummaryColumns::DESCRIPTION;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortSummaryModel::indexedItemIsDisabled()\n//-----------------------------------------------------------------------------\nbool PortSummaryModel::indexedItemIsDisabled(QModelIndex const& index) const\n{\n    return index.column() == PortSummaryColumns::ROW_NUMBER || \n        index.column() == PortSummaryColumns::TYPE;\n }\n\n//-----------------------------------------------------------------------------\n// Function: PortSummaryModel::indexedItemIsMandatory()\n//-----------------------------------------------------------------------------\nbool PortSummaryModel::indexedItemIsMandatory(QModelIndex const& index) const\n{\n    return index.column() == PortSummaryColumns::NAME;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortSummaryModel::indexedItemIsLocked()\n//-----------------------------------------------------------------------------\nbool PortSummaryModel::indexedItemIsLocked(QModelIndex const& index) const\n{\n    return index.column() == PortSummaryColumns::ROW_NUMBER || \n        index.column() == PortSummaryColumns::TYPE;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortSummaryModel::getLockedPortIndexes()\n//-----------------------------------------------------------------------------\nQModelIndexList PortSummaryModel::getLockedPortIndexes(QModelIndex const& portIndex) const\n{\n\tQModelIndexList lockedIndexes;\n\n\tQModelIndex nameIndex = portIndex.sibling(portIndex.row(), PortSummaryColumns::NAME);\n\tQModelIndex typeIndex = portIndex.sibling(portIndex.row(), PortSummaryColumns::TYPE);\n\n\tlockedIndexes.append(nameIndex);\n\tlockedIndexes.append(typeIndex);\n\n\treturn lockedIndexes;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortSummaryModel::addNewPort()\n//-----------------------------------------------------------------------------\nvoid PortSummaryModel::addNewPort()\n{\n\n}\n\n"
  },
  {
    "path": "editors/ComponentEditor/ports/PortSummaryModel.h",
    "content": "//-----------------------------------------------------------------------------\n// File: PortSummaryModel.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Esko Pekkarinen\n// Date: 27.11.2023\n//\n// Description:\n// \n//-----------------------------------------------------------------------------\n\n#ifndef PORT_SUMMARY_MODEL_H\n#define PORT_SUMMARY_MODEL_H\n\n#include <editors/ComponentEditor/ports/portsmodel.h>\n\n//-----------------------------------------------------------------------------\n//! Table model for wire ports.\n//-----------------------------------------------------------------------------\nclass PortSummaryModel : public PortsModel\n{\n\tQ_OBJECT\n\npublic:\n\n    /*!\n     *  The constructor.\n     *\n     *    @param [in] parameterFinder     Pointer to the parameter finder.\n     *    @param [in] portsInterface      Interface for accessing the component ports.\n     *    @param [in] signalInterface     Interface for accessing abstraction signals.\n     *    @param [in] parent              Pointer to the owner of this model.\n     */\n    PortSummaryModel(QSharedPointer <ParameterFinder> parameterFinder,\n        QSharedPointer<PortsInterface> portsInterface,\n        QSharedPointer<PortAbstractionInterface> signalInterface,\n        QObject *parent);\n\n\t/*!\n     *  The destructor.\n     */\n    ~PortSummaryModel() = default;\n\n\t/*!\n     *  Get the number of columns in the model.\n\t *\n\t *    @param [in] parent      Model index of the parent of the item. Must be invalid\n     *\n\t *    @return Always returns 9.\n     */\n\tint columnCount(const QModelIndex& parent = QModelIndex() ) const final;\n    \t\n    /*!\n     *  Get the data for the headers.\n\t *\n\t *    @param [in] section         The column that's header is wanted\n\t *    @param [in] orientation     Only Qt::Horizontal is supported\n\t *    @param [in] role            Specified the type of data that is wanted.\n\t *\n\t *    @return QVariant containing the data to be displayed.\n\t */\n    QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const final;\n\n    /*!\n     *  Get the data for the specified item for specified role.\n\t *\n\t *    @param [in] index   Identifies the item that's data is wanted.\n\t *    @param [in] role    Specifies what kind of data is wanted\n\t *\n\t *    @return QVariant containing the data\n     */\n\tQVariant data(const QModelIndex& index, int role = Qt::DisplayRole ) const final;\n\n\t/*!\n     *  Set the data for specified item.\n\t *\n\t *    @param [in] index   Specifies the item that's data is modified\n\t *    @param [in] value   The value to be set.\n\t *    @param [in] role    The role that is trying to modify the data. Only Qt::EditRole is supported.\n\t *\n\t *    @return True if data was successfully set.\n\t */\n\tbool setData(QModelIndex const& index, QVariant const& value, int role = Qt::EditRole) final;\n\npublic slots:\n\n    void onAddWire();\n\n    void onAddTransactional();\n\nprotected:\n\n    /*!\n     *  Check if the column index is valid for containing expressions.\n     *\n     *    @param [in] index   The index being evaluated.\n     *\n     *      return True, if column can have expressions, false otherwise.\n     */\n    bool isValidExpressionColumn(QModelIndex const& index) const final;\n\n    bool isPortTypeColumn(QModelIndex const& index) const final;\n\n    /*!\n     *  Gets the expression for the given index, or plain value if there is no expression.\n     *\n     *    @param [in] index   The index of target data.\n     *\n     *      return Expression in the given index, or plain value.\n     */\n    QVariant expressionOrValueForIndex(QModelIndex const& index) const final;\n\n    /*!\n     *  Get the formatted value of an expression in the selected index.\n     *\n     *    @param [in] index   The selected index.\n     *\n     *    @return The formatted value of an expression in the selected index.\n     */\n    QVariant formattedExpressionForIndex(QModelIndex const& index) const final;\n\n    /*!\n     *  Gets the value for the given index.\n     *\n     *    @param [in] index   The index of target data.\n     *\n     *      return The data in the given index.\n     */\n    QVariant valueForIndex(QModelIndex const& index) const final;\n\n\nprivate:\n\n    /*!\n     *  Get the column for row number.\n     *\n     *    @return Row number column.\n     */\n    int rowNumberColumn() const final;\n\n    /*!\n     *  Get the column for name.\n     *\n     *    @return Name column.\n     */\n    int nameColumn() const final;\n\n    /*!\n     *  Get the column for type definitions.\n     *\n     *    @return Type definitions column.\n     */\n    int typeColumn() const final;\n\n    /*!\n     *  Get the column for array left.\n     *\n     *    @return Array left column.\n     */\n    int arrayLeftColumn() const final;\n\n    /*!\n     *  Get the column for array right.\n     *\n     *    @return Array right column.\n     */\n    int arrayRightColum() const final;\n\n    /*!\n     *  Get the column for tags.\n     *\n     *    @return Tags column.\n     */\n    int tagColumn() const final;\n\n    /*!\n     *  Get the column for ad hoc visibility.\n     *\n     *    @return Ad hoc visibility column.\n     */\n    int adHocColumn() const final;\n\n    /*!\n     *  Get the column for description.\n     *\n     *    @return Description column.\n     */\n    int descriptionColumn() const final;\n\n    /*!\n     *  Check if the selected item is disabled.\n     *\n     *    @param [in] index           Index of the selected item.\n     *\n     *    @return True, if the indexed item is disabled, false otherwise.\n     */\n    bool indexedItemIsDisabled(QModelIndex const& index) const final;\n\n    /*!\n     *  Check if the selected item is mandatory.\n     *\n     *    @param [in] index   Index of the selected item.\n     *\n     *    @return True, if the indexed item is mandatory, false otherwise.\n     */\n    bool indexedItemIsMandatory(QModelIndex const& index) const final;\n\n    /*!\n     *  Check if the selected item is locked.\n     *\n     *    @param [in] index   Index of the selected item.\n     *\n     *    @return True, if the indexed item is locked, false otherwise.\n     */\n    bool indexedItemIsLocked(QModelIndex const& index) const final;\n\n    /*!\n     *  Get a list of the locked port indexes from the selected index.\n     *\n     *    @param [in] portIndex   Index of the selected item.\n     *\n     *    @return List of the locked port indexes.\n     */\n    virtual QModelIndexList getLockedPortIndexes(QModelIndex const& portIndex) const final;\n\n\n    void addNewPort() override;\n\n};\n\n#endif // PORT_SUMMARY_MODEL_H\n"
  },
  {
    "path": "editors/ComponentEditor/ports/PortSummaryView.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: PortSummaryView.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Esko Pekkarinen\n// Date: 29.11.2023\n//\n// Description:\n// View for a summary of all ports in a component.\n//-----------------------------------------------------------------------------\n\n#include \"PortSummaryView.h\"\n\n#include <QMenu>\n\n//-----------------------------------------------------------------------------\n// Function: PortSummaryView::PortSummaryView()\n//-----------------------------------------------------------------------------\nPortSummaryView::PortSummaryView(int nameColumn, BusInterfaceInterface* busInterface, QWidget *parent):\n    PortsView(nameColumn, busInterface, parent)\n{\n    addAction_.setDisabled(true);\n\n    connect(&wireAction_, SIGNAL(triggered(bool)), this, SIGNAL(addWire()), Qt::UniqueConnection);\n    connect(&transactionalAction_, SIGNAL(triggered(bool)), this, SIGNAL(addTransactional()), Qt::UniqueConnection);\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortSummaryView::contextMenuEvent()\n//-----------------------------------------------------------------------------\nvoid PortSummaryView::contextMenuEvent(QContextMenuEvent* event)\n{\n    pressedPoint_ = event->pos();\n\n    QModelIndex index = indexAt(pressedPoint_);\n\n    QMenu menu(this);\n    menu.addAction(&wireAction_);\n    menu.addAction(&transactionalAction_);\n\n    if (index.isValid())\n    {\n        menu.addAction(&removeAction_);\n        menu.addAction(&clearAction_);\n        menu.addAction(&cutAction_);\n        menu.addAction(&copyAction_);\n        menu.addAction(&pasteAction_);\n    }\n\n    menu.exec(event->globalPos());\n\n    event->accept();\n}\n"
  },
  {
    "path": "editors/ComponentEditor/ports/PortSummaryView.h",
    "content": "//-----------------------------------------------------------------------------\n// File: PortSummaryView.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Esko Pekkarinen\n// Date: 29.11.2023\n//\n// Description:\n// View for a summary of all ports in a component.\n//-----------------------------------------------------------------------------\n\n#ifndef PORT_SUMMARY_VIEW_H\n#define PORT_SUMMARY_VIEW_H\n\n#include \"PortsView.h\"\n\n#include <QAction>\n\nclass BusInterfaceInterface;\n\n//-----------------------------------------------------------------------------\n// View for a summary of all ports in a component.\n//-----------------------------------------------------------------------------\nclass PortSummaryView : public PortsView\n{\n\tQ_OBJECT\npublic:\n\n\n\t/*!\n\t *  The constructor.\n\t *\n     *    @param [in] nameColumn      Name column index of.\n     *    @param [in] busInterface    Interface for accessing bus interfaces.\n\t *    @param [in] parent          The parent widget.\n\t */\n    PortSummaryView(int nameColumn, BusInterfaceInterface* busInterface, QWidget *parent);\n\n\t//! The destructor.\n\t~PortSummaryView() = default;\n\t\nsignals:\n\n\t//! Emitted when a new wire should be created.\n    void addWire();\n\n    //! Emitted when a new transactional should be created.\n\tvoid addTransactional();\n\nprotected:\n\n    //! Handler for context menu events.\n\tvoid contextMenuEvent(QContextMenuEvent* event) override;\n\nprivate:\n\n\t//! Action for adding new wire ports.\n\tQAction wireAction_{ tr(\"Add wire\") };\n\n    //! Action for adding new transactional ports.\n\tQAction transactionalAction_{ tr(\"Add transactional\") };\n\n\n};\n\n#endif // PORT_SUMMARY_VIEW_H\n"
  },
  {
    "path": "editors/ComponentEditor/ports/PortTagEditorDelegate.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: PortTagEditorDelegate.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Mikko Teuho\r\n// Date: 20.07.2015\r\n//\r\n// Description:\r\n// Delegate for selecting and creating tags for ports.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"PortTagEditorDelegate.h\"\r\n\r\n#include <QComboBox>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PortTagEditorDelegate::PortTagEditorDelegate()\r\n//-----------------------------------------------------------------------------\r\nPortTagEditorDelegate::PortTagEditorDelegate(QStringList existingPortTags, QObject* parent):\r\nQStyledItemDelegate(parent),\r\nexistingTags_(existingPortTags)\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PortTagEditorDelegate::~PortTagEditorDelegate()\r\n//-----------------------------------------------------------------------------\r\nPortTagEditorDelegate::~PortTagEditorDelegate()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PortTagEditorDelegate::createEditor()\r\n//-----------------------------------------------------------------------------\r\nQWidget* PortTagEditorDelegate::createEditor(QWidget* parent, const QStyleOptionViewItem& /*option*/,\r\n    QModelIndex const& /*index*/) const\r\n{\r\n    QComboBox* tagCombo = new QComboBox(parent);\r\n    tagCombo->setEditable(true);\r\n    tagCombo->addItems(existingTags_);\r\n\r\n    return tagCombo;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PortTagEditorDelegate::setEditorData()\r\n//-----------------------------------------------------------------------------\r\nvoid PortTagEditorDelegate::setEditorData(QWidget* editor, const QModelIndex& index) const\r\n{\r\n    QString text = index.model()->data(index, Qt::DisplayRole).toString();\r\n\r\n    QComboBox* tagCombo = qobject_cast<QComboBox*>(editor);\r\n\r\n    if (text != QLatin1String(\"Double click to add new item.\"))\r\n    {\r\n        tagCombo->setCurrentText(text);\r\n    }\r\n    else\r\n    {\r\n        tagCombo->setCurrentText(QString());\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PortTagEditorDelegate::setModelData()\r\n//-----------------------------------------------------------------------------\r\nvoid PortTagEditorDelegate::setModelData(QWidget* editor, QAbstractItemModel* model, const QModelIndex& index) const\r\n{\r\n    QComboBox* tagCombo = qobject_cast<QComboBox*>(editor);\r\n    QString text = tagCombo->currentText();\r\n    model->setData(index, text, Qt::EditRole);\r\n}\r\n"
  },
  {
    "path": "editors/ComponentEditor/ports/PortTagEditorDelegate.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: PortTagEditorDelegate.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Mikko Teuho\r\n// Date: 20.07.2015\r\n//\r\n// Description:\r\n// Delegate for selecting and creating tags for ports.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef PORTTAGEDITORDELEGATE_H\r\n#define PORTTAGEDITORDELEGATE_H\r\n\r\n#include <QStyledItemDelegate>\r\n\r\n//-----------------------------------------------------------------------------\r\n//! The delegate for selecting and creating port tags.\r\n//-----------------------------------------------------------------------------\r\nclass PortTagEditorDelegate : public QStyledItemDelegate\r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\r\n    /*!\r\n\t *  The constructor.\r\n\t *\r\n\t *    @param [in] existingPortTags    The port tags that have been given in other ports.\r\n\t *    @param [in] parent              The owner of this delegate.\r\n\t */\r\n\tPortTagEditorDelegate(QStringList existingPortTags, QObject* parent);\r\n\r\n    /*!\r\n     *  The destructor.\r\n     */\r\n    virtual ~PortTagEditorDelegate();\r\n\r\n    /*!\r\n     *  Create a new editor for the given item.\r\n     *\r\n     *    @param [in] parent  Owner of the editor.\r\n     *    @param [in] option  Contains options for the editor.\r\n     *    @param [in] index   Model index identifying the item.\r\n     *\r\n     *    @return The editor to be used to edit the item.\r\n     */\r\n    virtual QWidget* createEditor(QWidget* parent, const QStyleOptionViewItem& option, const QModelIndex& index)\r\n        const;\r\n\r\n    /*!\r\n     *  Set the data for the editor.\r\n     *\r\n     *    @param [in] editor  The editor where the data is to be set.\r\n     *    @param [in] index   Model index identifying the item that's data is to be set.\r\n     */\r\n    virtual void setEditorData(QWidget* editor, const QModelIndex& index) const;\r\n\r\n    /*!\r\n     *  Save the data from the editor to the model.\r\n     *\r\n     *    @param [in] editor  The editor that contains the data to store.\r\n     *    @param [in] model   Model that contains the data structure where data is to be saved into.\r\n     *    @param [in] index   Model index identifying the item that's data is to be saved.\r\n     */\r\n    virtual void setModelData(QWidget* editor, QAbstractItemModel* model, const QModelIndex& index) const;\r\n\r\nprivate:\r\n\t//! No copying\r\n    PortTagEditorDelegate(const PortTagEditorDelegate& other);\r\n\r\n\t//! No assignment\r\n    PortTagEditorDelegate& operator=(const PortTagEditorDelegate& other);\r\n\r\n    //! A list of existing port tags.\r\n    QStringList existingTags_;\r\n};\r\n\r\n#endif // PORTTAGEDITORDELEGATE_H\r\n"
  },
  {
    "path": "editors/ComponentEditor/ports/PortTypeDefinitionDelegate.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: PortTypeDefinitionDelegate.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 24.11.2017\n//\n// Description:\n// The delegate providing editors for port type definition.\n//-----------------------------------------------------------------------------\n\n#include \"PortTypeDefinitionDelegate.h\"\n\n#include <common/widgets/assistedLineEdit/AssistedLineEdit.h>\n#include <common/widgets/assistedLineEdit/BasicLineContentMatcher.h>\n\n//-----------------------------------------------------------------------------\n// Function: PortTypeDefinitionDelegate::PortTypeDefinitionDelegate()\n//-----------------------------------------------------------------------------\nPortTypeDefinitionDelegate::PortTypeDefinitionDelegate(QObject* parent):\nQStyledItemDelegate(parent),\nmatcher_(new BasicLineContentMatcher())\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortTypeDefinitionDelegate::~PortTypeDefinitionDelegate()\n//-----------------------------------------------------------------------------\nPortTypeDefinitionDelegate::~PortTypeDefinitionDelegate()\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortTypeDefinitionDelegate::createEditor()\n//-----------------------------------------------------------------------------\nQWidget* PortTypeDefinitionDelegate::createEditor(QWidget* parent, QStyleOptionViewItem const&, QModelIndex const&)\n    const\n{\n    QStringList suggestedDefinitions;\n    suggestedDefinitions.append(QString(\"IEEE.std_logic_1164.all\"));\n    suggestedDefinitions.append(QString(\"IEEE.numeric_std.all\"));\n    matcher_->setItems(suggestedDefinitions);\n\n    AssistedLineEdit* editor = new AssistedLineEdit(parent->window(), parent);\n    editor->setContentMatcher(matcher_);\n\n    return editor;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortTypeDefinitionDelegate::setEditorData()\n//-----------------------------------------------------------------------------\nvoid PortTypeDefinitionDelegate::setEditorData(QWidget* editor, QModelIndex const& index) const\n{\n    AssistedLineEdit* lineEditor = qobject_cast<AssistedLineEdit*>(editor);\n    if (lineEditor)\n    {\n        QString text = index.data(Qt::DisplayRole).toString();\n        lineEditor->setText(text);\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortTypeDefinitionDelegate::setModelData()\n//-----------------------------------------------------------------------------\nvoid PortTypeDefinitionDelegate::setModelData(QWidget* editor, QAbstractItemModel* model, QModelIndex const& index)\n    const\n{\n    AssistedLineEdit* assistedEditor = qobject_cast<AssistedLineEdit*>(editor);\n    if (assistedEditor)\n    {\n        model->setData(index, assistedEditor->text(), Qt::EditRole);\n    }\n}\n"
  },
  {
    "path": "editors/ComponentEditor/ports/PortTypeDefinitionDelegate.h",
    "content": "//-----------------------------------------------------------------------------\n// File: PortTypeDefinitionDelegate.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 24.11.2017\n//\n// Description:\n// The delegate providing editors for port type definition.\n//-----------------------------------------------------------------------------\n\n#ifndef PORTTYPEDEFINITIONDELEGATE_H\n#define PORTTYPEDEFINITIONDELEGATE_H\n\n#include <QStyledItemDelegate>\n\nclass BasicLineContentMatcher;\n\n//-----------------------------------------------------------------------------\n//! The delegate providing editors for port type definition.\n//-----------------------------------------------------------------------------\nclass PortTypeDefinitionDelegate : public QStyledItemDelegate\n{\n\npublic:\n\n    /*!\n     *  The constructor.\n     *\n     *    @param [in] parent  The parent object.\n     */\n    explicit PortTypeDefinitionDelegate(QObject* parent = 0);\n\t\n\t/*!\n     *  The destructor.\n     */\n    virtual ~PortTypeDefinitionDelegate();\n\n\t/*!\n     *  Create a new editor for the given item\n\t *\n\t *    @param [in] parent  Owner of the editor.\n\t *    @param [in] option  Contains options for the editor.\n\t *    @param [in] index   Model index identifying the item.\n\t *\n\t *    @return The editor to be used to edit the item.\n     */\n\tvirtual QWidget* createEditor(QWidget* parent, QStyleOptionViewItem const& option, QModelIndex const& index)\n        const;\n\n\t/*!\n     *  Set the data for the editor.\n\t *\n\t *    @param [in] editor  The editor where the data is to be set.\n\t *    @param [in] index   Model index identifying the item that's data is to be set.\n\t */\n\tvirtual void setEditorData(QWidget* editor, QModelIndex const& index) const;\n\n\t/*!\n     *  Save the data from the editor to the model.\n\t *\n\t *    @param [in] editor  The editor that contains the data to store.\n\t *    @param [in] model   Model that contains the data structure where data is to be saved to.\n\t *    @param [in] index   Model index identifying the item that's data is to be saved.\n\t */\n\tvirtual void setModelData(QWidget* editor, QAbstractItemModel* model, QModelIndex const& index) const;\n\nprivate:\n\n    // No copying. No assignment.\n    PortTypeDefinitionDelegate(PortTypeDefinitionDelegate const& rhs);\n    PortTypeDefinitionDelegate& operator=(PortTypeDefinitionDelegate const& rhs);\n\n    //-----------------------------------------------------------------------------\n    // Data.\n    //-----------------------------------------------------------------------------\n\n    //! The content matcher for type definitions.\n    BasicLineContentMatcher* matcher_;\n};\n\n#endif // PORTTYPEDEFINITIONDELEGATE_H\n"
  },
  {
    "path": "editors/ComponentEditor/ports/PortTypeDefinitionEditor.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: PortTypeDefinitionEditor.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 02.01.2018\n//\n// Description:\n// Editor for a list of port type definitions.\n//-----------------------------------------------------------------------------\n\n#include \"PortTypeDefinitionEditor.h\"\n\n#include <editors/ComponentEditor/ports/PortTypeDefinitionDelegate.h>\n\n//-----------------------------------------------------------------------------\n// Function: PortTypeDefinitionEditor::PortTypeDefinitionEditor()\n//-----------------------------------------------------------------------------\nPortTypeDefinitionEditor::PortTypeDefinitionEditor(QModelIndex const& indexedRow, QWidget* parent):\nListEditor(parent),\nindexedRow_(indexedRow)\n{\n    setItemDelegate(new PortTypeDefinitionDelegate(parent));\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortTypeDefinitionEditor::~PortTypeDefinitionEditor()\n//-----------------------------------------------------------------------------\nPortTypeDefinitionEditor::~PortTypeDefinitionEditor()\n{\n    emit closingEditor(indexedRow_);\n}\n"
  },
  {
    "path": "editors/ComponentEditor/ports/PortTypeDefinitionEditor.h",
    "content": "//-----------------------------------------------------------------------------\n// File: PortTypeDefinitionEditor.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 02.01.2018\n//\n// Description:\n// Editor for a list of port type definitions.\n//-----------------------------------------------------------------------------\n\n#ifndef PORTTYPEDEFINITIONEDITOR_H\n#define PORTTYPEDEFINITIONEDITOR_H\n\n#include <common/widgets/listManager/listeditor.h>\n\n#include <QModelIndex>\n\n//-----------------------------------------------------------------------------\n//! Editor for a list of port type definitions.\n//-----------------------------------------------------------------------------\nclass PortTypeDefinitionEditor : public ListEditor\n{\n\tQ_OBJECT\n\npublic:\n\n\t/*!\n     *  The constructor.\n\t *\n     *    @param [in] indexedRow  Index of the type for which this editor belongs to.\n\t *    @param [in] parent      Pointer to the owner of this editor.\n\t */\n    PortTypeDefinitionEditor(QModelIndex const& indexedRow, QWidget* parent);\n\t\n\t/*!\n     *  The destructor.\n     */\n    virtual ~PortTypeDefinitionEditor();\n\nsignals:\n\n    /*!\n     *  Informs of the closing of this editor.\n     *\n     *    @param [in] indexedRow  Index of the containing type.\n     */\n    void closingEditor(QModelIndex const& indexedRow);\n\nprivate:\n\t\n\t//! No copying. No assignment.\n    PortTypeDefinitionEditor(const PortTypeDefinitionEditor& other);\n    PortTypeDefinitionEditor& operator=(const PortTypeDefinitionEditor& other);\n\n    //-----------------------------------------------------------------------------\n    // Data.\n    //-----------------------------------------------------------------------------\n\n    //! The index of the containing type.\n    QModelIndex indexedRow_;\n};\n\n#endif // PORTTYPEDEFINITIONEDITOR_H\n"
  },
  {
    "path": "editors/ComponentEditor/ports/PortWireTypeColumns.h",
    "content": "//-----------------------------------------------------------------------------\n// File: PortWireTypeColumns.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 24.11.2017\n//\n// Description:\n// Common declarations for editing port wire type definitions.\n//-----------------------------------------------------------------------------\n\n#ifndef PORTWIRETYPECOLUMNS_H\n#define PORTWIRETYPECOLUMNS_H\n\nnamespace PortWireTypeColumns\n{\n    //-----------------------------------------------------------------------------\n    // Constants defining which column represents what kind of information.\n    //-----------------------------------------------------------------------------\n    enum Columns\n    {\n        TYPE = 0,           //!< Column for the port type name and view references.\n        TYPE_DEFINITIONS ,  //!< Column for the type definitions.\n        COLUMN_COUNT\n    };\n}\n\n#endif // PORTWIRETYPECOLUMNS_H"
  },
  {
    "path": "editors/ComponentEditor/ports/PortWireTypeDelegate.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: PortWireTypeDelegate.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 24.11.2017\n//\n// Description:\n// The delegate that provides editors to edit port wire type definition.\n//-----------------------------------------------------------------------------\n\n#include \"PortWireTypeDelegate.h\"\n\n#include <editors/ComponentEditor/ports/PortWireTypeColumns.h>\n#include <editors/ComponentEditor/ports/PortTypeDefinitionDelegate.h>\n#include <editors/ComponentEditor/ports/PortTypeDefinitionEditor.h>\n\n#include <IPXACTmodels/Component/Component.h>\n#include <IPXACTmodels/Component/View.h>\n\n#include <QLineEdit>\n#include <QCompleter>\n#include <QComboBox>\n#include <QPen>\n#include <QPainter>\n\nnamespace PortWireTypeConstants\n{\n    QString const DEFINITIONSEPARATOR = \"; \";\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortWireTypeDelegate::PortWireTypeDelegate()\n//-----------------------------------------------------------------------------\nPortWireTypeDelegate::PortWireTypeDelegate(QSharedPointer<Component> component, QObject* parent):\nQStyledItemDelegate(parent),\navailableViews_(component->getViews()),\ncontainedModel_()\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortWireTypeDelegate::~PortWireTypeDelegate()\n//-----------------------------------------------------------------------------\nPortWireTypeDelegate::~PortWireTypeDelegate()\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortWireTypeDelegate::setNewModel()\n//-----------------------------------------------------------------------------\nvoid PortWireTypeDelegate::setNewModel(QAbstractItemModel* newModel)\n{\n    containedModel_ = newModel;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortWireTypeDelegate::createEditor()\n//-----------------------------------------------------------------------------\nQWidget* PortWireTypeDelegate::createEditor(QWidget* parent, QStyleOptionViewItem const& option, \n    QModelIndex const& index) const\n{\n    if (index.isValid())\n    {\n        if (index.column() == PortWireTypeColumns::TYPE)\n        {\n            if (!index.parent().isValid())\n            {\n                return createSelectorWithCommonTypes(parent);\n            }\n            else\n            {\n                return createViewSelector(parent);\n            }\n        }\n        else if (!index.parent().isValid() && index.column() == PortWireTypeColumns::TYPE_DEFINITIONS)\n        {\n            return createDefinitionEditor(parent, index);\n        }\n    }\n\n    return QStyledItemDelegate::createEditor(parent, option, index);\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortWireTypeDelegate::setEditorData()\n//-----------------------------------------------------------------------------\nvoid PortWireTypeDelegate::setEditorData(QWidget* editor, QModelIndex const& index) const\n{\n    if (index.column() == PortWireTypeColumns::TYPE_DEFINITIONS)\n    {\n        ListEditor* definitionEditor = qobject_cast<ListEditor*>(editor);\n        if (definitionEditor)\n        {\n            QString combinedDefinition = index.data(Qt::DisplayRole).toString();\n            QStringList definitions;\n            if (!combinedDefinition.isEmpty())\n            {\n                definitions = combinedDefinition.split(PortWireTypeConstants::DEFINITIONSEPARATOR);\n            }\n            definitionEditor->setItems(definitions);\n        }\n    }\n    else\n    {\n        QStyledItemDelegate::setEditorData(editor, index);\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortWireTypeDelegate::setModelData()\n//-----------------------------------------------------------------------------\nvoid PortWireTypeDelegate::setModelData(QWidget* editor, QAbstractItemModel* model, QModelIndex const& index )\n    const\n{\n    if (index.column() == PortWireTypeColumns::TYPE_DEFINITIONS)\n    {\n        ListEditor* definitionEditor = qobject_cast<ListEditor*>(editor);\n\n        QStringList definitionList = definitionEditor->items();\n        model->setData(index, definitionList.join(PortWireTypeConstants::DEFINITIONSEPARATOR), Qt::EditRole);\n    }\n    else\n    {\n        QStyledItemDelegate::setModelData(editor, model, index);\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortWireTypeDelegate::createSelectorWithCommonTypes()\n//-----------------------------------------------------------------------------\nQWidget* PortWireTypeDelegate::createSelectorWithCommonTypes(QWidget* parent) const\n{\n    QLineEdit* typeEditor = new QLineEdit(parent);\n\n    QStringList types;\n    types.append(\"bit\");\n    types.append(\"bit_vector\");\n    types.append(\"boolean\");\n    types.append(\"character\");\n    types.append(\"integer\");\n    types.append(\"natural\");\n    types.append(\"positive\");\n    types.append(\"real\");\n    types.append(\"signed\");\n    types.append(\"std_logic\");\n    types.append(\"std_logic_vector\");\n    types.append(\"std_ulogic\");\n    types.append(\"std_ulogic_vector\");\n    types.append(\"string\");\n    types.append(\"time\");\n    types.append(\"unsigned\");\n    types.append(\"reg\");\n    types.append(\"wire\");\n\n    types.sort(Qt::CaseInsensitive);\n\n    QCompleter* typeCompleter = new QCompleter(types, parent);\n    typeCompleter->setCaseSensitivity(Qt::CaseInsensitive);\n    typeEditor->setCompleter(typeCompleter);\n\n    return typeEditor;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortWireTypeDelegate::createViewSelector()\n//-----------------------------------------------------------------------------\nQWidget* PortWireTypeDelegate::createViewSelector(QWidget* parent) const\n{\n    QComboBox* combo = new QComboBox(parent);\n    combo->setSizeAdjustPolicy(QComboBox::AdjustToContents);\n    combo->addItem(QString(\"\"));\n\n    foreach (QSharedPointer<View> view, *availableViews_)\n    {\n        combo->addItem(view->name());\n    }\n\n    return combo;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortWireTypeDelegate::createDefinitionEditor()\n//-----------------------------------------------------------------------------\nQWidget* PortWireTypeDelegate::createDefinitionEditor(QWidget* parent, QModelIndex const& index) const\n{\n    PortTypeDefinitionEditor* definitionEditor = new PortTypeDefinitionEditor(index, parent);\n\n    connect(definitionEditor, SIGNAL(closingEditor(QModelIndex const&)),\n        this, SLOT(onDefinitionEditorClosed(QModelIndex const&)), Qt::UniqueConnection);\n    connect(definitionEditor, SIGNAL(contentChanged()), this, SIGNAL(contentChanged()), Qt::UniqueConnection);\n\n    return definitionEditor;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortWireTypeDelegate::onDefinitionEditorClosed()\n//-----------------------------------------------------------------------------\nvoid PortWireTypeDelegate::onDefinitionEditorClosed(QModelIndex const& editorIndex)\n{\n    PortTypeDefinitionEditor* definitionEditor = qobject_cast<PortTypeDefinitionEditor*>(sender());\n    if (definitionEditor)\n    {\n        QStringList currentDefinitions = definitionEditor->items();\n\n        setModelData(definitionEditor, containedModel_, editorIndex);\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortWireTypeDelegate::setComponent()\n//-----------------------------------------------------------------------------\nvoid PortWireTypeDelegate::setComponent(QSharedPointer<Component> newComponent)\n{\n    availableViews_ = newComponent->getViews();\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortWireTypeDelegate::sizeHint()\n//-----------------------------------------------------------------------------\nQSize PortWireTypeDelegate::sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const\n{\n    QSize givenSize = QStyledItemDelegate::sizeHint(option, index);\n\n    QSize newSize (givenSize.width(), 20);\n    return newSize;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortWireTypeDelegate::paint()\n//-----------------------------------------------------------------------------\nvoid PortWireTypeDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index)\n    const\n{\n    QStyledItemDelegate::paint(painter, option, index);\n\n    QPen oldPen = painter->pen();\n    QPen newPen(Qt::lightGray);\n    newPen.setWidth(1);\n    painter->setPen(newPen);\n\n    painter->drawLine(option.rect.topRight(), option.rect.bottomRight());\n\n    painter->setPen(oldPen);\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortWireTypeDelegate::updateEditorGeometry()\n//-----------------------------------------------------------------------------\nvoid PortWireTypeDelegate::updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option,\n    const QModelIndex &index) const\n{\n    QStyledItemDelegate::updateEditorGeometry(editor, option, index);\n\n    if (!index.parent().isValid() && index.column() == PortWireTypeColumns::TYPE_DEFINITIONS)\n    {\n        repositionAndResizeEditor(editor, option);\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortWireTypeDelegate::repositionAndResizeEditor()\n//-----------------------------------------------------------------------------\nvoid PortWireTypeDelegate::repositionAndResizeEditor(QWidget* editor, QStyleOptionViewItem const& option) const\n{\n    int editorMinimumSize = 120;\n\n    const int PARENT_HEIGHT = editor->parentWidget()->height();\n    const int AVAILABLE_HEIGHT_BELOW = PARENT_HEIGHT - option.rect.top();\n\n    if (AVAILABLE_HEIGHT_BELOW > editorMinimumSize)\n    {\n        editor->move(option.rect.topLeft());\n    }\n    else\n    {\n        int editorNewY = PARENT_HEIGHT-editorMinimumSize;\n        if (editorNewY <= 0)\n        {\n            editorNewY = 0;\n        }\n\n        editor->move(option.rect.left(), editorNewY);\n    }\n\n    if (editorMinimumSize > PARENT_HEIGHT)\n    {\n        editor->setFixedHeight(PARENT_HEIGHT);\n    }\n    else\n    {\n        editor->setFixedHeight(editorMinimumSize);\n    }\n}\n"
  },
  {
    "path": "editors/ComponentEditor/ports/PortWireTypeDelegate.h",
    "content": "//-----------------------------------------------------------------------------\n// File: PortWireTypeDelegate.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 24.11.2017\n//\n// Description:\n// The delegate that provides editors to edit port wire type definition.\n//-----------------------------------------------------------------------------\n\n#ifndef PORTWIRETYPEDELEGATE_H\n#define PORTWIRETYPEDELEGATE_H\n\n#include <QStyledItemDelegate>\n#include <QAbstractItemModel>\n\nclass Component;\nclass View;\n\n//-----------------------------------------------------------------------------\n//! The delegate that provides editors to edit port wire type definition.\n//-----------------------------------------------------------------------------\nclass PortWireTypeDelegate : public QStyledItemDelegate\n{\n    Q_OBJECT\n\npublic:\n\n    /*!\n     *  The constructor.\n     *\n     *    @param [in] component   Component containing the edited ports.\n     *    @param [in] parent      The parent object.\n     */\n\tPortWireTypeDelegate(QSharedPointer<Component> component, QObject* parent = 0);\n\t\n\t/*!\n     *  The destructor.\n     */\n    virtual ~PortWireTypeDelegate();\n\n    /*!\n     *  Set a new model for types.\n     *\n     *    @param [in] newModel    The new type model.\n     */\n    void setNewModel(QAbstractItemModel* newModel);\n\n\t/*!\n     *  Create a new editor for the given item\n\t *\n\t *    @param [in] parent  Owner for the editor.\n\t *    @param [in] option  Contains options for the editor.\n\t *    @param [in] index   Model index identifying the item.\n\t *\n\t *    @return The editor to be used to edit the item.\n     */\n\tvirtual QWidget* createEditor(QWidget* parent, QStyleOptionViewItem const& option, QModelIndex const& index)\n        const;\n\n\t/*!\n     *  Set the data for the editor.\n\t *\n\t *    @param [in] editor  The editor where the data is to be set.\n\t *    @param [in] index   Model index identifying the item that's data is to be set.\n\t */\n\tvirtual void setEditorData(QWidget* editor, QModelIndex const& index) const;\n\n\t/*!\n     *  Save the data from the editor to the model.\n\t *\n\t *    @param [in] editor  The editor that contains the data to store.\n\t *    @param [in] model   Model that contains the data structure where data is to be saved to.\n\t *    @param [in] index   Model index identifying the item that's data is to be saved.\n\t */\n\tvirtual void setModelData(QWidget* editor, QAbstractItemModel* model, QModelIndex const& index) const;\n\n    /*!\n     *  Set a new component.\n     *\n     *    @param [in] newComponent    The new component.\n     */\n    void setComponent(QSharedPointer<Component> newComponent);\n\n    /*!\n     *  Get the size requirement for the editor.\n     *\n     *    @param [in] option  Style options for the editor.\n     *    @param [in] index   Index of the selected editor.\n     */\n    virtual QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const;\n\n    /*!\n     *  Paint the indexed area.\n     *\n     *    @param [in] painter     The painter.\n     *    @param [in] option      Style options of the area.\n     *    @param [in] index       The selected index.\n     */\n    virtual void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const;\n\n    /*!\n     *  Update the geometry of the editor in the selected index.\n     *\n     *    @param [in] editor  The contained editor.\n     *    @param [in] option  Style options for the area containing the editor.\n     *    @param [in] index   The selected index.\n     */\n    virtual void updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option,\n        const QModelIndex &index) const;\n\nsignals:\n\n    /*!\n     *  Set the new type definitions for the selected type.\n     *\n     *    @param [in] typeIndex       Index of the selected type.\n     *    @param [in] newDefinitions  The new type definitions.\n     */\n    void setNewDefinitions(QModelIndex const& typeIndex, QStringList newDefinitions);\n\n    /*!\n     *  Transmits changes in the content of the port types.\n     */\n    void contentChanged();\n\nprivate slots:\n\n    /*!\n     *  Handles the closing of the type definition editor.\n     *\n     *    @param [in] editorIndex     Index of the edited type.\n     */\n    void onDefinitionEditorClosed(QModelIndex const& editorIndex);\n\nprivate:\n\n    // No copying. No assignment.\n    PortWireTypeDelegate(PortWireTypeDelegate const& rhs);\n    PortWireTypeDelegate& operator=(PortWireTypeDelegate const& rhs);\n\n    /*!\n     *  Creates a selector for port type with common VHDL and Verilog types as options.\n     *\n     *    @param [in] parent   The parent widget for the selector.\n     *\n     *    @return The selector for port type.\n     */\n    QWidget* createSelectorWithCommonTypes(QWidget* parent) const;\n  \n    /*!\n     *  Creates a selector for view reference with the components views as options.\n     *\n     *    @param [in] parent   The parent widget for the selector.\n     *\n     *    @return The selector for view reference.\n     */\n    QWidget* createViewSelector(QWidget* parent) const;\n\n    /*!\n     *  Creates an editor for port typedef with VHDL standard libraries as options.\n     *\n     *    @param [in] parent  The parent widget for the selector.\n     *    @param [in] index   Index of the created definition editor.\n     *\n     *    @return The editor for port typedef.\n     */  \n    QWidget* createDefinitionEditor(QWidget* parent, QModelIndex const& index) const;\n\n    /*!\n     *  Reposition and resize the selected editor.\n     *\n     *    @param [in] editor  The selected editor.\n     *    @param [in] option  Style options for the area containing the selected editor.\n     */\n    void repositionAndResizeEditor(QWidget* editor, QStyleOptionViewItem const& option) const;\n\n    //-----------------------------------------------------------------------------\n    // Data.\n    //-----------------------------------------------------------------------------\n\n    //! List of all the referable views.\n    QSharedPointer<QList<QSharedPointer<View> > > availableViews_;\n\n    //! Model containing the type data.\n    QAbstractItemModel* containedModel_;\n};\n\n#endif // PORTSDELEGATE_H\n"
  },
  {
    "path": "editors/ComponentEditor/ports/PortWireTypeEditor.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: PortWireTypeEditor.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 24.11.2017\n//\n// Description:\n// Editor for the port wire type definitions.\n//-----------------------------------------------------------------------------\n\n#include \"PortWireTypeEditor.h\"\n\n#include <editors/ComponentEditor/ports/PortWireTypeView.h>\n#include <editors/ComponentEditor/ports/PortWireTypeModel.h>\n#include <editors/ComponentEditor/ports/PortWireTypeDelegate.h>\n\n#include <QSortFilterProxyModel>\n#include <QVBoxLayout>\n\n//-----------------------------------------------------------------------------\n// Function: PortWireTypeEditor::PortWireTypeEditor()\n//-----------------------------------------------------------------------------\nPortWireTypeEditor::PortWireTypeEditor(QSharedPointer<Component> component,\n    QSharedPointer<PortTypeValidator> typeValidator, QWidget* parent):\nQScrollArea(parent),\ntypeDefinitionView_(new PortWireTypeView(this)),\ntypeDefinitionModel_(new PortWireTypeModel(typeValidator, this)),\ntypeDefinitionDelegate_(new PortWireTypeDelegate(component, this))\n{\n    setWidgetResizable(true);\n\n    typeDefinitionView_->setItemDelegate(typeDefinitionDelegate_);\n    typeDefinitionView_->setAlternatingRowColors(false);\n\n    typeDefinitionDelegate_->setNewModel(typeDefinitionModel_);\n    typeDefinitionView_->setModel(typeDefinitionModel_);\n    typeDefinitionView_->setSortingEnabled(false);\n\n    connectSignals();\n    setWidget(typeDefinitionView_);\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortWireTypeEditor::~PortWireTypeEditor()\n//-----------------------------------------------------------------------------\nPortWireTypeEditor::~PortWireTypeEditor()\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortWireTypeEditor::connectSignals()\n//-----------------------------------------------------------------------------\nvoid PortWireTypeEditor::connectSignals()\n{\n    connect(typeDefinitionModel_, SIGNAL(contentChanged()), this, SIGNAL(contentChanged()), Qt::UniqueConnection);\n    connect(typeDefinitionModel_, SIGNAL(dataChanged(QModelIndex const&, QModelIndex const&)),\n        this, SIGNAL(contentChanged()), Qt::UniqueConnection);\n\n    connect(typeDefinitionView_, SIGNAL(addItems(QModelIndexList const&)),\n        typeDefinitionModel_, SLOT(onAddItems(const QModelIndexList&)), Qt::UniqueConnection);\n    connect(typeDefinitionView_, SIGNAL(addSubItem(QModelIndexList const&)),\n        typeDefinitionModel_, SLOT(onAddViewReferences(QModelIndexList const&)), Qt::UniqueConnection);\n    connect(typeDefinitionView_, SIGNAL(removeSelectedItems(QModelIndexList const&)),\n        typeDefinitionModel_, SLOT(onRemoveSelectedItems(QModelIndexList const&)), Qt::UniqueConnection);\n    connect(typeDefinitionView_, SIGNAL(removeAllSubItems(QModelIndexList const&)), typeDefinitionModel_,\n        SLOT(onRemoveAllViewsFromSelectedTypes(QModelIndexList const&)), Qt::UniqueConnection);\n\n    connect(typeDefinitionDelegate_, SIGNAL(contentChanged()),\n        this, SIGNAL(contentChanged()), Qt::UniqueConnection);\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortWireTypeEditor::setComponent()\n//-----------------------------------------------------------------------------\nvoid PortWireTypeEditor::setComponent(QSharedPointer<Component> newComponent)\n{\n    typeDefinitionDelegate_->setComponent(newComponent);\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortWireTypeEditor::setPortForModel()\n//-----------------------------------------------------------------------------\nvoid PortWireTypeEditor::setPortForModel(QSharedPointer<Port> newPort)\n{\n    typeDefinitionModel_->onChangePortSelection(newPort);\n    typeDefinitionView_->expandAll();\n}\n"
  },
  {
    "path": "editors/ComponentEditor/ports/PortWireTypeEditor.h",
    "content": "//-----------------------------------------------------------------------------\n// File: PortWireTypeEditor.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 24.11.2017\n//\n// Description:\n// Editor for the port wire type definitions.\n//-----------------------------------------------------------------------------\n\n#ifndef PORTWIRETYPEEDITOR_H\n#define PORTWIRETYPEEDITOR_H\n\n#include <QScrollArea>\n\nclass Port;\nclass Component;\n\nclass PortTypeValidator;\n\nclass PortWireTypeModel;\nclass PortWireTypeDelegate;\nclass PortWireTypeView;\n\n//-----------------------------------------------------------------------------\n//! Editor for the port wire type definitions.\n//-----------------------------------------------------------------------------\nclass PortWireTypeEditor : public QScrollArea\n{\n\tQ_OBJECT\n\npublic:\n\n\t/*!\n     *  The constructor.\n\t *\n     *    @param [in] component       Component containing the edited port.\n     *    @param [in] typeValidator   Validator for the port type definitions.\n\t *    @param [in] parent          The owner of the editor.\n\t */\n    PortWireTypeEditor(QSharedPointer<Component> component, QSharedPointer<PortTypeValidator> typeValidator,\n        QWidget* parent);\n\t\n\t/*!\n     *  The destructor.\n     */\n    virtual ~PortWireTypeEditor();\n\n    /*!\n     *  Set a new component.\n     *\n     *    @param [in] newComponent    The selected component.\n     */\n    void setComponent(QSharedPointer<Component> newComponent);\n\n    /*!\n     *  Set a new port for the port wire type model.\n     *\n     *    @param [in] newPort     The selected port.\n     */\n    void setPortForModel(QSharedPointer<Port> newPort);\n\nsignals:\n\n    /*!\n     *  Signal for informing changes in content.\n     */\n    void contentChanged();\n\nprivate:\n\t//! No copying. No assignment.\n\tPortWireTypeEditor(const PortWireTypeEditor& other);\n\tPortWireTypeEditor& operator=(const PortWireTypeEditor& other);\n\n    /*!\n     *  Connect the signals.\n     */\n    void connectSignals();\n\n    //-----------------------------------------------------------------------------\n    // Data.\n    //-----------------------------------------------------------------------------\n\n    //! View for the port type.\n    PortWireTypeView* typeDefinitionView_;\n\n    //! Model for the port type.\n    PortWireTypeModel* typeDefinitionModel_;\n\n    //! Delegate for the port type.\n    PortWireTypeDelegate* typeDefinitionDelegate_;\n};\n\n#endif // PORTWIRETYPEEDITOR_H\n"
  },
  {
    "path": "editors/ComponentEditor/ports/PortWireTypeModel.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: PortWireTypeModel.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 24.11.2017\n//\n// Description:\n// Table model that can be used to display port wire type definitions.\n//-----------------------------------------------------------------------------\n\n#include \"PortWireTypeModel.h\"\n\n#include <editors/ComponentEditor/ports/PortWireTypeColumns.h>\n\n#include <common/KactusColors.h>\n\n#include <IPXACTmodels/Component/Port.h>\n#include <IPXACTmodels/Component/Wire.h>\n#include <IPXACTmodels/Component/WireTypeDef.h>\n\n#include <IPXACTmodels/Component/validators/PortTypeValidator.h>\n\n#include <QFont>\n\nnamespace PortWireConstants\n{\n    QString const DEFINITIONSEPARATOR = \"; \";\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortWireTypeModel::PortWireTypeModel()\n//-----------------------------------------------------------------------------\nPortWireTypeModel::PortWireTypeModel(QSharedPointer<PortTypeValidator> typeValidator, QObject *parent):\nQAbstractItemModel(parent),\nwireTypeDefinitions_(),\ntypeValidator_(typeValidator)\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortWireTypeModel::~PortWireTypeModel()\n//-----------------------------------------------------------------------------\nPortWireTypeModel::~PortWireTypeModel()\n{\n\n}\n\n\n//-----------------------------------------------------------------------------\n// Function: PortWireTypeModel::index()\n//-----------------------------------------------------------------------------\nQModelIndex PortWireTypeModel::index(int row, int column, const QModelIndex &parent) const\n{\n    if (wireTypeDefinitions_)\n    {\n        if (!parent.isValid() && 0 <= row && row < wireTypeDefinitions_->size())\n        {\n            return createIndex(row, column, wireTypeDefinitions_->at(row).data());\n        }\n        else\n        {\n            QSharedPointer<WireTypeDef> wireTypeDefinition = getIndexedWireTypeDefinition(parent);\n            if (0 <= row && row < wireTypeDefinition->getViewRefs()->size())\n            {\n                return createIndex(row, column, &(*wireTypeDefinition->getViewRefs())[row]);\n            }\n        }\n    }\n\n    return QModelIndex();\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortWireTypeModel::parent()\n//-----------------------------------------------------------------------------\nQModelIndex PortWireTypeModel::parent(const QModelIndex &child) const\n{\n    if (!child.isValid())\n    {\n        return QModelIndex();\n    }\n\n    if (wireTypeDefinitions_)\n    {\n        foreach (QSharedPointer<WireTypeDef> wireType, *wireTypeDefinitions_)\n        {\n            if (child.internalPointer() == wireType.data())\n            {\n                return QModelIndex();\n            }\n        }\n    }\n\n    QString* childItem = static_cast<QString*>(child.internalPointer());\n    if (childItem)\n    {\n        for (int i = 0; i < wireTypeDefinitions_->size(); ++i)\n        {\n            QSharedPointer<WireTypeDef> wireDefinition = wireTypeDefinitions_->at(i);\n            for (int j = 0; j < wireDefinition->getViewRefs()->count(); ++j)\n            {\n                QString* viewReference = &(*wireDefinition->getViewRefs())[j];\n                if (childItem == viewReference)\n                {\n                    return createIndex(i, 0, wireDefinition.data());\n                }\n            }\n        }\n    }\n\n    //! This should not be reached.\n    return QModelIndex();\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortWireTypeModel::rowCount()\n//-----------------------------------------------------------------------------\nint PortWireTypeModel::rowCount(const QModelIndex& parent) const\n{\n    if (wireTypeDefinitions_)\n    {\n        if (!parent.isValid())\n        {\n            return wireTypeDefinitions_->count();\n        }\n        else if (!parent.parent().isValid())\n        {\n            QSharedPointer<QStringList> viewsForType = getViewsForType(parent);\n            if (viewsForType)\n            {\n                return viewsForType->count();\n            }\n        }\n    }\n\n    return 0;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortWireTypeModel::getViewsForType()\n//-----------------------------------------------------------------------------\nQSharedPointer<QStringList> PortWireTypeModel::getViewsForType(QModelIndex const& typeIndex) const\n{\n    QString typeName = wireTypeDefinitions_->at(typeIndex.row())->getTypeName();\n    QSharedPointer<QStringList> definitionList = getTypeDefinitionsForType(typeIndex);\n\n    foreach (QSharedPointer<WireTypeDef> wireType, *wireTypeDefinitions_)\n    {\n        if (wireType->getTypeName() == typeName && wireType->getTypeDefinitions() == definitionList)\n        {\n            return wireType->getViewRefs();\n        }\n    }\n\n    return QSharedPointer<QStringList>();\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortWireTypeModel::getTypeDefinitionsForType()\n//-----------------------------------------------------------------------------\nQSharedPointer<QStringList> PortWireTypeModel::getTypeDefinitionsForType(QModelIndex const& typeIndex) const\n{\n    return wireTypeDefinitions_->at(typeIndex.row())->getTypeDefinitions();\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortWireTypeModel::columnCount()\n//-----------------------------------------------------------------------------\nint PortWireTypeModel::columnCount(const QModelIndex& /*parent*/) const\n{\n    return PortWireTypeColumns::COLUMN_COUNT;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortWireTypeModel::headerData()\n//-----------------------------------------------------------------------------\nQVariant PortWireTypeModel::headerData(int section, Qt::Orientation orientation, int role) const\n{\n    if (role == Qt::DisplayRole && orientation == Qt::Horizontal)\n    {\n        if (section == PortWireTypeColumns::TYPE)\n        {\n            return tr(\"Type name / View\");\n        }\n        else if (section == PortWireTypeColumns::TYPE_DEFINITIONS)\n        {\n            return tr(\"Type definitions\");\n        }\n    }\n\n    return QVariant();\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortWireTypeModel::data()\n//-----------------------------------------------------------------------------\nQVariant PortWireTypeModel::data(QModelIndex const& index, int role) const\n{\n    if (!index.isValid() || index.row() < 0)\n    {\n\t\treturn QVariant();\n\t}\n\n    QSharedPointer<WireTypeDef> typeDefinition = getIndexedWireTypeDefinition(index);\n\n    if (typeDefinition)\n    {\n        if (role == Qt::DisplayRole || role == Qt::EditRole || role == Qt::ToolTipRole)\n        {\n            if (index.column() == PortWireTypeColumns::TYPE)\n            {\n                if (!index.parent().isValid())\n                {\n                    return typeDefinition->getTypeName();\n                }\n                else\n                {\n                    return typeDefinition->getViewRefs()->at(index.row());\n                }\n            }\n            else if (!index.parent().isValid() && index.column() == PortWireTypeColumns::TYPE_DEFINITIONS)\n            {\n                return typeDefinition->getTypeDefinitions()->join(PortWireConstants::DEFINITIONSEPARATOR);\n            }\n        }\n        else if (Qt::ForegroundRole == role)\n        {\n            return blackForValidRedForInvalid(index, typeDefinition);\n        }\n        else if (!index.parent().isValid() && index.column() == PortWireTypeColumns::TYPE && role == Qt::FontRole)\n        {\n            QFont font;\n            font.setBold(true);\n            return font;\n        }\n    }\n    \n    return QVariant();\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortWireTypeModel::setData()\n//-----------------------------------------------------------------------------\nbool PortWireTypeModel::setData(QModelIndex const& index, QVariant const& value, int role)\n{\n    if (!index.isValid() || index.row() < 0)\n    {\n\t\treturn false;\n    }\n    else if (data(index, Qt::DisplayRole) == value)\n    {\n        return true;\n    }\n\n    QSharedPointer<WireTypeDef> singleWireTypeDefinition = getIndexedWireTypeDefinition(index);\n\n\tif (role == Qt::EditRole)\n    {\n        if (index.column() == PortWireTypeColumns::TYPE)\n        {\n            if (!index.parent().isValid())\n            {\n                singleWireTypeDefinition->setTypeName(value.toString());\n            }\n            else\n            {\n                QSharedPointer<QStringList> viewReferences = singleWireTypeDefinition->getViewRefs();\n                viewReferences->replace(index.row(), value.toString());\n            }\n        }\n        else if (index.column() == PortWireTypeColumns::TYPE_DEFINITIONS)\n        {\n            QString typeDefinitionString = value.toString();\n            QSharedPointer<QStringList> newTypeDefinitions(new QStringList(\n                typeDefinitionString.split(PortWireConstants::DEFINITIONSEPARATOR)));\n            singleWireTypeDefinition->setTypeDefinitions(newTypeDefinitions);\n        }\n\n        emit dataChanged(index, index);\n        return true;\n    }\n\n    return false;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortWireTypeModel::getIndexedWireTypeDefinition()\n//-----------------------------------------------------------------------------\nQSharedPointer<WireTypeDef> PortWireTypeModel::getIndexedWireTypeDefinition(QModelIndex index) const\n{\n    if (index.isValid())\n    {\n        if (!index.parent().isValid())\n        {\n            return wireTypeDefinitions_->at(index.row());\n        }\n        else\n        {\n            QModelIndex typeNameIndex = index.parent().sibling(index.parent().row(), PortWireTypeColumns::TYPE);\n            QString typeName = wireTypeDefinitions_->at(typeNameIndex.row())->getTypeName();\n            QSharedPointer<QStringList> definitionList =\n                wireTypeDefinitions_->at(typeNameIndex.row())->getTypeDefinitions();\n\n            foreach (QSharedPointer<WireTypeDef> typeDefinition, *wireTypeDefinitions_)\n            {\n                if (typeDefinition->getTypeName() == typeName &&\n                    typeDefinition->getTypeDefinitions() == definitionList)\n                {\n                    return typeDefinition;\n                }\n            }\n        }\n    }\n\n    return QSharedPointer<WireTypeDef>();\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortWireTypeModel::onAddItems()\n//-----------------------------------------------------------------------------\nvoid PortWireTypeModel::onAddItems(QModelIndexList const& indexList)\n{\n    int typeAdditions = 1;\n\n    if (!indexList.isEmpty())\n    {\n        int previousRow = indexList.first().row();\n        foreach (QModelIndex singleIndex, indexList)\n        {\n            if (singleIndex.isValid() && singleIndex.row() != previousRow)\n            {\n                ++typeAdditions;\n            }\n\n            previousRow = singleIndex.row();\n        }\n    }\n\n    int typeCount = wireTypeDefinitions_->count();\n\n    beginInsertRows(QModelIndex(), typeCount, typeCount + typeAdditions);\n\n    for (int i = 0; i < typeAdditions; ++i)\n    {\n        wireTypeDefinitions_->insert(typeCount, QSharedPointer<WireTypeDef>(new WireTypeDef()));\n    }\n\n    endInsertRows();\n\n    emit contentChanged();\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortWireTypeModel::onAddViewReferences()\n//-----------------------------------------------------------------------------\nvoid PortWireTypeModel::onAddViewReferences(QModelIndexList const& indexList)\n{\n    bool viewReferenceCreated = false;\n\n    foreach (QModelIndex singleIndex, indexList)\n    {\n        if (singleIndex.isValid() && !singleIndex.parent().isValid())\n        {\n            QSharedPointer<WireTypeDef> typeDefinition = getIndexedWireTypeDefinition(singleIndex);\n            int newViewReferenceRow = typeDefinition->getViewRefs()->count();\n\n            beginInsertRows(singleIndex, newViewReferenceRow, newViewReferenceRow);\n            typeDefinition->getViewRefs()->append(QString(\"\"));\n            endInsertRows();\n\n            viewReferenceCreated = true;\n        }\n    }\n\n    if (viewReferenceCreated)\n    {\n        emit contentChanged();\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortWireTypeModel::onRemoveSelectedItems()\n//-----------------------------------------------------------------------------\nvoid PortWireTypeModel::onRemoveSelectedItems(QModelIndexList const& indexList)\n{\n    QModelIndexList childIndexList;\n    QModelIndexList parentIndexList;\n\n    foreach (QModelIndex singleIndex, indexList)\n    {\n        if (singleIndex.isValid())\n        {\n            if (singleIndex.parent().isValid())\n            {\n                childIndexList.append(singleIndex);\n            }\n            else\n            {\n                parentIndexList.append(singleIndex);\n            }\n        }\n    }\n\n    if (childIndexList.isEmpty() && parentIndexList.isEmpty())\n    {\n        return;\n    }\n\n    for (int i = childIndexList.size() - 1; i >= 0; i--)\n    {\n        QModelIndex childIndex = childIndexList.at(i);\n        QSharedPointer<WireTypeDef> parentTypeDefinition = wireTypeDefinitions_->at(childIndex.parent().row());\n        beginRemoveRows(childIndex.parent(), childIndex.row(), childIndex.row());\n        parentTypeDefinition->getViewRefs()->removeAt(childIndex.row());\n        endRemoveRows();\n    }\n\n    for (int i = parentIndexList.size() - 1; i >= 0; i--)\n    {\n        QModelIndex parentIndex = parentIndexList.at(i);\n        beginRemoveRows(QModelIndex(), parentIndex.row(), parentIndex.row());\n        wireTypeDefinitions_->removeAt(parentIndex.row());\n        endRemoveRows();\n    }\n\n    emit contentChanged();\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortWireTypeModel::onRemoveAllViewsFromSelectedTypes()\n//-----------------------------------------------------------------------------\nvoid PortWireTypeModel::onRemoveAllViewsFromSelectedTypes(QModelIndexList const& indexList)\n{\n    bool changeInContent = false;\n\n    beginResetModel();\n\n    foreach (QModelIndex parentIndex, indexList)\n    {\n        if (parentIndex.isValid() && !parentIndex.parent().isValid())\n        {\n            QSharedPointer<WireTypeDef> typeDefinition = getIndexedWireTypeDefinition(parentIndex);\n            typeDefinition->getViewRefs()->clear();\n\n            changeInContent = true;\n        }\n    }\n\n    endResetModel();\n\n    if (changeInContent)\n    {\n        emit contentChanged();\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortWireTypeModel::onChangePortSelection()\n//-----------------------------------------------------------------------------\nvoid PortWireTypeModel::onChangePortSelection(QSharedPointer<Port> newPort)\n{\n    beginResetModel();\n\n    if (wireTypeDefinitions_)\n    {\n        wireTypeDefinitions_ = QSharedPointer<QList<QSharedPointer<WireTypeDef> > >();\n    }\n\n    if (newPort)\n    {\n        if (newPort->getWire())\n        {\n            wireTypeDefinitions_ = newPort->getWire()->getWireTypeDefs();\n        }\n        else if (newPort->getTransactional())\n        {\n            wireTypeDefinitions_ = newPort->getTransactional()->getTransTypeDef();\n        }\n    }\n\n    endResetModel();\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortWireTypeModel::flags()\n//-----------------------------------------------------------------------------\nQt::ItemFlags PortWireTypeModel::flags(const QModelIndex& index) const\n{\n    if (!index.isValid() ||\n        (index.isValid() && index.parent().isValid() && index.column() == PortWireTypeColumns::TYPE_DEFINITIONS))\n    {\n        return Qt::NoItemFlags;\n    }\n\n\treturn Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsEditable;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortWireTypeModel::blackForValidRedForInvalid()\n//-----------------------------------------------------------------------------\nQVariant PortWireTypeModel::blackForValidRedForInvalid(QModelIndex const& index,\n    QSharedPointer<WireTypeDef> typeDefinition) const\n{\n    if (validateIndex(index, typeDefinition))\n    {\n        return KactusColors::REGULAR_TEXT;\n    }\n    else\n    {\n        return KactusColors::ERROR;\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortWireTypeModel::validateIndex()\n//-----------------------------------------------------------------------------\nbool PortWireTypeModel::validateIndex(QModelIndex const& index, QSharedPointer<WireTypeDef> typeDefinition) const\n{\n    if (index.column() == PortWireTypeColumns::TYPE)\n    {\n        if (!index.parent().isValid())\n        {\n            return typeValidator_->validate(typeDefinition, wireTypeDefinitions_);\n        }\n        else\n        {            \n            return typeValidator_->hasValidView(typeDefinition->getViewRefs()->at(index.row()), wireTypeDefinitions_);\n        }\n    }\n\n    return true;\n}\n"
  },
  {
    "path": "editors/ComponentEditor/ports/PortWireTypeModel.h",
    "content": "//-----------------------------------------------------------------------------\n// File: PortWireTypeModel.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 24.11.2017\n//\n// Description:\n// Table model that can be used to display port wire type definitions.\n//-----------------------------------------------------------------------------\n\n#ifndef PORTWIRETYPEMODEL_H\n#define PORTWIRETYPEMODEL_H\n\n#include <QAbstractItemModel>\n#include <QSharedPointer>\n\nclass WireTypeDef;\nclass Port;\n\nclass PortTypeValidator;\n\n//-----------------------------------------------------------------------------\n//! Table model that can be used to display port wire type definitions.\n//-----------------------------------------------------------------------------\nclass PortWireTypeModel : public QAbstractItemModel\n{\n    Q_OBJECT\n\npublic:\n\n\t/*!\n     *  The constructor.\n\t *\n     *    @param [in] typeValidator   Validator for port type definitions.\n\t *    @param [in] parent          Pointer to the owner of this model.\n     */\n\tPortWireTypeModel(QSharedPointer<PortTypeValidator> typeValidator, QObject *parent);\n\t\n\t/*!\n     *  The destructor.\n     */\n    virtual ~PortWireTypeModel();\n\n\t/*!\n     *  Get the number of rows in the model.\n\t *\n\t *    @param [in] parent  Model index of the parent of the item.\n\t *\n\t *    @return Number of rows currently in the model.\n     */\n\tvirtual int rowCount(const QModelIndex& parent = QModelIndex() ) const;\n\n\t/*!\n     *  Get the number of columns in the model.\n\t *\n\t *    @param [in] parent  Model index of the parent of the item.\n\t *\n\t *    @return Always returns 2.\n     */\n\tvirtual int columnCount(const QModelIndex& parent = QModelIndex() ) const;\n\n    /*!\n     *  Get the data for the headers.\n\t *\n\t *    @param [in] section         The column that's header is wanted.\n\t *    @param [in] orientation     Only Qt::Horizontal is supported.\n\t *    @param [in] role            Specified the type of data that is wanted.\n\t *\n\t *    @return QVariant containing the data to be displayed.\n\t */\n\tvirtual QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole ) const;\n\n\t/*!\n     *  Get the data for the specified item for specified role.\n\t *\n\t *    @param [in] index   Identifies the item that's data is wanted.\n\t *    @param [in] role    Specifies what kind of data is wanted.\n\t *\n\t *    @return QVariant containing the data.\n     */\n\tvirtual QVariant data(const QModelIndex& index, int role = Qt::DisplayRole ) const;\n\n\t/*!\n     *  Set the data for specified item.\n\t *\n\t *    @param [in] index   Specifies the item that's data is modified.\n\t *    @param [in] value   The value to be set.\n\t *    @param [in] role    The role that is trying to modify the data. Only Qt::EditRole is supported.\n\t *\n\t *    @return True if data was successfully set.\n\t */\n\tvirtual bool setData(QModelIndex const& index, QVariant const& value, int role = Qt::EditRole);\n\n\t/*!\n     *  Create an index for the identified item.\n\t *\n     *    @param [in] row     Row of the item.\n\t *    @param [in] column  Column of the item.\n     *    @param [in] parent  Parent index of the item.\n\t *\n\t *    @return The created model index.\n     */\n    QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex() ) const;\n\n    /*!\n     *  Create a parent index for the selected item.\n     *\n     *    @param [in] child   The selected item.\n     */\n    QModelIndex parent(const QModelIndex &child) const;\n    \n    /*!\n     *  Get information on how specified item can be handled.\n\t *\n\t *    @param [in] index   Specifies the item that's flags are wanted.\n\t *\n\t *    @return Qt::ItemFlags that define how object can be handled.\n     */\n\tvirtual Qt::ItemFlags flags(const QModelIndex& index) const;\n\n    /*!\n     *  Change the currently edited port.\n     *\n     *    @param [in] newPort     The new port.\n     */\n    void onChangePortSelection(QSharedPointer<Port> newPort);\n\npublic slots:\n\n\t/*!\n     *  Handles the addition of new port types.\n\t *\n\t *    @param [in] indexList   List of type indexes for creating new types.\n     */\n    void onAddItems(QModelIndexList const& indexList);\n\n\t/*!\n     *  Handles the addition of new port type view references.\n\t *\n\t *    @param [in] indexList   List of type indexes to contain the new view references.\n     */\n    void onAddViewReferences(QModelIndexList const& indexList);\n\n\t/*!\n     *  Handles the removal of items from the model.\n\t * \n\t *    @param [in] indexList   Identifies the items that should be removed.\n     */\n    void onRemoveSelectedItems(QModelIndexList const& indexList);\n\n\t/*!\n\t *  Handles the removal of all the view references from the selected types.\n\t *\n\t *    @param [in] indexList   Identifies the type containing the removed view references.\n\t */\n    void onRemoveAllViewsFromSelectedTypes(QModelIndexList const& indexList);\n\nsignals:\n\n\t/*!\n     *  Emitted when contents of the model change\n     */\n\tvoid contentChanged();\n\n\t/*!\n     *  Prints an error message to the user.\n     */\n\tvoid errorMessage(const QString& msg) const;\n\t\n\t/*!\n     *  Prints a notification to user.\n     */\n\tvoid noticeMessage(const QString& msg) const;\n\nprivate:\n\t\n\t//! No copying. No assignment.\n\tPortWireTypeModel(const PortWireTypeModel& other);\n\tPortWireTypeModel& operator=(const PortWireTypeModel& other);\n\n    /*!\n     *  Get the view references of the selected port type.\n     *\n     *    @param [in] typeIndex   Index of the selected type.\n     *\n     *    @return The list of view references of the selected port type.\n     */\n    QSharedPointer<QStringList> getViewsForType(QModelIndex const& typeIndex) const;\n\n    /*!\n     *  Get the type definitions of the selected port type.\n     *\n     *    @param [in] typeIndex   Index of the selected type.\n     *\n     *    @return The list of type definitions of the selected port type.\n     */\n    QSharedPointer<QStringList> getTypeDefinitionsForType(QModelIndex const& typeIndex) const;\n\n    /*!\n     *  Get the selected wire type definition.\n     *\n     *    @param [in] index   Index of the selected wire type definition.\n     */\n    QSharedPointer<WireTypeDef> getIndexedWireTypeDefinition(QModelIndex index) const;\n\n    /*!\n     *  Get the color for valid and invalid indexes.\n     *\n     *    @param [in] index           The selected index.\n     *    @param [in] typeDefinition  The indexed type definition.\n     *\n     *    @return Black color for valid indexes, red for invalid.\n     */\n    QVariant blackForValidRedForInvalid(QModelIndex const& index, QSharedPointer<WireTypeDef> typeDefinition)\n        const;\n\n    /*!\n     *  Validate the selected index.\n     *\n     *    @param [in] index           The selected index.\n     *    @param [in] typeDefinition  The indexed type definition.\n     */\n    bool validateIndex(QModelIndex const& index, QSharedPointer<WireTypeDef> typeDefinition) const;\n\n    //-----------------------------------------------------------------------------\n    // Data.\n    //-----------------------------------------------------------------------------\n\n    //! The contained wire type definitions.\n    QSharedPointer<QList<QSharedPointer<WireTypeDef> > > wireTypeDefinitions_;\n\n    //! The validator for type definitions.\n    QSharedPointer<PortTypeValidator> typeValidator_;\n};\n\n#endif // PORTWIRETYPEMODEL_H\n"
  },
  {
    "path": "editors/ComponentEditor/ports/PortWireTypeView.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: PortWireTypeView.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 30.11.2017\n//\n// Description:\n// View for port wire type definitions.\n//-----------------------------------------------------------------------------\n\n#include \"PortWireTypeView.h\"\n\n#include <editors/ComponentEditor/ports/PortWireTypeColumns.h>\n\n#include <QMenu>\n\n//-----------------------------------------------------------------------------\n// Function: PortWireTypeView::PortWireTypeView()\n//-----------------------------------------------------------------------------\nPortWireTypeView::PortWireTypeView(QWidget* parent):\nEditableTreeView(true, QString(tr(\"Add type\")), QString(tr(\"Add view reference\")), QString(tr(\"Remove row\")),\n    QString(tr(\"Remove all view references\")), parent)\n{\n    setSelectionMode(QAbstractItemView::ContiguousSelection);\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortWireTypeView::~PortWireTypeView()\n//-----------------------------------------------------------------------------\nPortWireTypeView::~PortWireTypeView()\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortWireTypeView::contextMenuEvent()\n//-----------------------------------------------------------------------------\nvoid PortWireTypeView::contextMenuEvent(QContextMenuEvent* event)\n{\n    QMenu contextMenu;\n    contextMenu.addAction(getAddItemAction());\n\n    QModelIndex contextMenuIndex = indexAt(event->pos());\n    if (contextMenuIndex.isValid())\n    {\n        if (!contextMenuIndex.parent().isValid())\n        {\n            contextMenu.addAction(getAddSubItemAction());\n        }\n\n        contextMenu.addSeparator();\n\n        contextMenu.addAction(getClearAction());\n        contextMenu.addAction(getRemoveAction());\n\n        if (!contextMenuIndex.parent().isValid())\n        {\n            contextMenu.addAction(getRemoveAllSubItemsAction());\n        }\n    }\n\n    contextMenu.exec(event->globalPos());\n    event->accept();\n}\n"
  },
  {
    "path": "editors/ComponentEditor/ports/PortWireTypeView.h",
    "content": "//-----------------------------------------------------------------------------\n// File: PortWireTypeView.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 30.11.2017\n//\n// Description:\n// View for port wire type definitions.\n//-----------------------------------------------------------------------------\n\n#ifndef PORTWIRETYPEVIEW_H\n#define PORTWIRETYPEVIEW_H\n\n#include <common/views/EditableTreeView/EditableTreeView.h>\n\n//-----------------------------------------------------------------------------\n//! View for port wire type definitions.\n//-----------------------------------------------------------------------------\nclass PortWireTypeView : public EditableTreeView\n{\n    Q_OBJECT\n\npublic:\n\n\t/*!\n     *  The constructor.\n\t *\n\t *    @param [in] parent  Pointer to the owner of this view.\n     */\n\tPortWireTypeView(QWidget* parent);\n\t\n\t/*!\n     *  The destructor.\n     */\n    virtual ~PortWireTypeView();\n\nsignals:\n\n    /*!\n     *  Close and commit any open type definition editors.\n     */\n    void closeOpenTypeDefinitionEditor();\n\nprotected:\n\n    /*!\n     *  Handles the context menu events.\n     *\n     *    @param [in] event   The context menu event.\n     */\n    virtual void contextMenuEvent(QContextMenuEvent* event);\n\nprivate:\n\t\n\t//! No copying. No assignment.\n\tPortWireTypeView(const PortWireTypeView& other);\n\tPortWireTypeView& operator=(const PortWireTypeView& other);\n\n};\n\n#endif // PORTWIRETYPEMODEL_H\n"
  },
  {
    "path": "editors/ComponentEditor/ports/PortsEditorFactory.h",
    "content": "//-----------------------------------------------------------------------------\n// File: PortsEditorConstructor.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 29.04.2019\n//\n// Description:\n// Constructs ports editor items.\n//-----------------------------------------------------------------------------\n\n#ifndef PORTSEDITOR_FACTORY_H\n#define PORTSEDITOR_FACTORY_H\n\n#include <editors/common/ExpressionSet.h>\n\n#include <QSortFilterProxyModel>\n#include <QSharedPointer>\n#include <QWidget>\n\n#include <QCompleter>\n\nclass ParameterFinder;\nclass ExpressionFormatter;\nclass ExpressionParser;\nclass Component;\nclass PortsModel;\nclass PortsView;\nclass PortValidator;\nclass PortsDelegate;\nclass PortsFilter;\nclass PortsInterface;\nclass BusInterfaceInterface;\nclass PortAbstractionInterface;\n\n//-----------------------------------------------------------------------------\n//! Constructs ports editor items.\n//-----------------------------------------------------------------------------\nclass PortsEditorFactory\n{\npublic:\n\n    PortsEditorFactory(QSharedPointer<Component> component,\n        ExpressionSet expressions,\n        QSharedPointer<PortValidator> portValidator, \n        QSharedPointer<PortsInterface> portsInterface,\n        QSharedPointer<PortAbstractionInterface> signalInterface,\n        BusInterfaceInterface* busInterface,\n        QString const& defaultPath):\n        component_(component),\n        expressions_(expressions),\n        portValidator_(portValidator),\n        portsInterface_(portsInterface),\n        signalInterface_(signalInterface),\n        busInterface_(busInterface),\n        defaultPath_(defaultPath)\n    {\n    }\n\n    /*!\n     *  The destructor.\n     */\n    ~PortsEditorFactory() = default;\n\n    //! No copying.\n    PortsEditorFactory(const PortsEditorFactory& other) = delete;\n    PortsEditorFactory& operator=(const PortsEditorFactory& other) = delete;\n\n    /*!\n     *  Construct a ports model.\n     *\n     *    @param [in] parent              The owner of the constructed model.\n     *\n     *    @return The created ports model.\n     */\n    virtual PortsModel* createModel(QObject* parent = 0) const = 0;\n\n    /*!\n     *  Construct a filter.\n     *\n     *    @param [in] parent              Owner of the filter.\n     *\n     *    @return The created ports filter.\n     */\n    virtual PortsFilter* createFilter(QObject* parent) const = 0;\n\n    /*!\n     *  Construct a view.\n     *\n     *    @param [in] parent          Owner of the view.\n     *\n     *    @return The created view.\n     */\n    virtual PortsView* createView(QWidget* parent) const = 0;\n\n    /*!\n     *  Construct a delegate.\n     *\n\t *    @param [in] parent              The owner of the delegate.\n     *\n     *    @return The created delegate.\n     */\n    virtual PortsDelegate* createDelegate(QObject* parent) const = 0;\n\nprotected:\n\n    QSharedPointer<Component> component_;\n    ExpressionSet expressions_;\n    QSharedPointer<PortValidator> portValidator_;\n    QSharedPointer<PortsInterface> portsInterface_;\n    QSharedPointer<PortAbstractionInterface> signalInterface_;\n    BusInterfaceInterface* busInterface_;\n    QString defaultPath_;\n\n};\n\n#endif // PORTSEDITOR_FACTORY_H\n"
  },
  {
    "path": "editors/ComponentEditor/ports/PortsFilter.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: PortsFilter.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 10.05.2019\n//\n// Description:\n// Sorting proxy model for ports.\n//-----------------------------------------------------------------------------\n\n#include \"PortsFilter.h\"\n\n#include <editors/ComponentEditor/ports/portsmodel.h>\n#include <KactusAPI/include/PortsInterface.h>\n\n#include <IPXACTmodels/Component/Port.h>\n\n//-----------------------------------------------------------------------------\n// Function: PortsFilter::PortsFilter()\n//-----------------------------------------------------------------------------\nPortsFilter::PortsFilter(QSharedPointer<PortsInterface> portInterface, QObject* parent):\nQSortFilterProxyModel(parent),\nportInterface_(portInterface)\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortsFilter::data()\n//-----------------------------------------------------------------------------\nQVariant PortsFilter::data(const QModelIndex& index, int role) const\n{\n    if (index.column() == 0)\n    {\n        if (role == Qt::DisplayRole)\n        {\n            return index.row();\n        }\n        return QVariant();\n    }\n\n    return QSortFilterProxyModel::data(index, role);\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortsFilter::filterAcceptsRow()\n//-----------------------------------------------------------------------------\nbool PortsFilter::filterAcceptsRow(int source_row, const QModelIndex& source_parent) const\n{\n    if (QModelIndex portNameIndex = sourceModel()->index(source_row, nameColumn(), source_parent);\n        portIsAccepted(portNameIndex.data(Qt::DisplayRole).toString()) == false)\n    {\n        return false;\n    }\n\n    return QSortFilterProxyModel::filterAcceptsRow(source_row, source_parent);\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortsFilter::onHandleExtensionsEditorItemChange()\n//-----------------------------------------------------------------------------\nvoid PortsFilter::onHandleExtensionsEditorItemChange(QModelIndex const& index)\n{\n    QModelIndex filteredIndex = mapToSource(index);\n    emit changeExtensionsEditorItem(filteredIndex);\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortsFilter::getInterface()\n//-----------------------------------------------------------------------------\nQSharedPointer<PortsInterface> PortsFilter::getInterface() const\n{\n    return portInterface_;\n}\n"
  },
  {
    "path": "editors/ComponentEditor/ports/PortsFilter.h",
    "content": "//-----------------------------------------------------------------------------\n// File: PortsFilter.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 10.05.2019\n//\n// Description:\n// Sorting proxy model for ports.\n//-----------------------------------------------------------------------------\n\n#ifndef PORTSFILTER_H\n#define PORTSFILTER_H\n\n#include <QSortFilterProxyModel>\n#include <QSharedPointer>\n\nclass PortsInterface;\n\n//-----------------------------------------------------------------------------\n//! Sorting proxy model for ports.\n//-----------------------------------------------------------------------------\nclass PortsFilter : public QSortFilterProxyModel\n{\n    Q_OBJECT\n\npublic:\n\n\t /*!\n      *  Constructor.\n      *\n      *    @param [in] portsInterface     Interface for accessing the component ports.\n      *    @param [in] parent             The parent object.\n      */\n    PortsFilter(QSharedPointer<PortsInterface> portInterface, QObject* parent = 0);\n\n\t /*!\n      *  Destructor.\n      */\n    virtual ~PortsFilter() = default;\n\n\n    QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override;\n\n    // No copying. No assignments.\n    PortsFilter(PortsFilter const& rhs) = delete;\n    PortsFilter& operator=(PortsFilter const& rhs) = delete;\n\npublic slots:\n\n    /*!\n     *  Handle the item change for the extensions editor.\n     *\n     *    @param [in] index   Index of the selected item.\n     */\n    void onHandleExtensionsEditorItemChange(QModelIndex const& index);\n\nsignals:\n\n    /*!\n     *  Change the item in the extensions editor.\n     *\n     *    @param [in] index   Index of the selected item.\n     */\n    void changeExtensionsEditorItem(QModelIndex const& index);\n\nprotected:\n\n    /*!\n\t *  Implementation of the row filtering.\n\t *\n\t *    @param [in] source_row      The row to check for filtering.\n     *    @param [in] source_parent   The parent index of the row.\n     *\n     *    @return True, if the row passes the filters, otherwise false.\n\t */\n    bool filterAcceptsRow(int source_row, const QModelIndex & source_parent) const override;\n\n    /*!\n     *  Get the interface for accessing the component ports.\n     *\n     *    @return Interface for accessing the component ports.\n     */\n    QSharedPointer<PortsInterface> getInterface() const;\n\nprivate:\n\n    /*!\n     *  Get the name column.\n     *\n     *    @return Index of the name column.\n     */\n    virtual int nameColumn() const = 0;\n\n    /*!\n     *  Check if a port is filtered.\n     *\n     *    @param [in] portName    Name of the selected port.\n     *\n     *    @return True, if the port is accepted, false otherwise.\n     */\n    virtual bool portIsAccepted(QString const& portName) const = 0;\n\n    //! Interface for accessing the component ports.\n    QSharedPointer<PortsInterface> portInterface_;\n};\n\n#endif // PORTSFILTER_H"
  },
  {
    "path": "editors/ComponentEditor/ports/PortsImportSummaryEditor.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: PortsImportSummaryEditor.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 07.10.2025\n//\n// Description:\n// Editor for displaying a summary of ports in import.\n//-----------------------------------------------------------------------------\n\n#include \"PortsImportSummaryEditor.h\"\n\n#include <editors/ComponentEditor/ports/portsmodel.h>\n\n#include <IPXACTmodels/Component/Component.h>\n\n//-----------------------------------------------------------------------------\n// Function: PortsImportSummaryEditor::PortsImportSummaryEditor()\n//-----------------------------------------------------------------------------\nPortsImportSummaryEditor::PortsImportSummaryEditor(QSharedPointer<Component> component, LibraryInterface* handler,\n    ExpressionSet expressions,\n    QSharedPointer<PortValidator> portValidator,\n    QSharedPointer<PortsInterface> portsInterface,\n    BusInterfaceInterface* busInterface,\n    QWidget *parent):\nPortsEditor(component, handler, expressions, portValidator, portsInterface, busInterface, parent),\noriginalComponent_(component)\n{\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortsImportSummaryEditor::setComponent()\n//-----------------------------------------------------------------------------\nvoid PortsImportSummaryEditor::setComponent(QSharedPointer<Component> component)\n{\n    PortsEditor::setComponent(component);\n\n    getModel()->resetModel();\n}\n"
  },
  {
    "path": "editors/ComponentEditor/ports/PortsImportSummaryEditor.h",
    "content": "//-----------------------------------------------------------------------------\n// File: PortsImportSummaryEditor.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 07.10.2025\n//\n// Description:\n// Editor for displaying a summary of ports in import.\n//-----------------------------------------------------------------------------\n\n#ifndef PORTSIMPORTSUMMARYEDITOR_H\n#define PORTSIMPORTSUMMARYEDITOR_H\n\n#include <editors/ComponentEditor/ports/portseditor.h>\n\n//-----------------------------------------------------------------------------\n//! Editor for displaying a summary of ports in import.\n//-----------------------------------------------------------------------------\nclass PortsImportSummaryEditor : public PortsEditor\n{\n\tQ_OBJECT\n\npublic:\n\n\t/*!\n\t *  The constructor.\n\t *\n\t *    @param [in] component         The component being edited.\n\t *    @param [in] handler           The instance that manages the library.\n\t *    @param [in] expressions       Expression handling utilities.\n     *    @param [in] portValidator     Validator used for ports.\n     *    @param [in] portsInterface    Interface for accessing ports.\n     *    @param [in] busInterface      Interface for accessing bus interfaces.\n\t *    @param [in] parent            The owner of this widget.\n\t */\n    PortsImportSummaryEditor(QSharedPointer<Component> component,\n        LibraryInterface* handler,\n        ExpressionSet expressions,\n        QSharedPointer<PortValidator> portValidator,\n        QSharedPointer<PortsInterface> portsInterface,\n        BusInterfaceInterface* busInterface,\n        QWidget *parent = 0);\n\n\t/*!\n     *  The destructor.\n     */\n    virtual ~PortsImportSummaryEditor() = default;\n\n    /*!\n     *  Sets the edited component.\n     *\n     *    @param [in] component   The component whose ports to edit.\n     */\n    virtual void setComponent(QSharedPointer<Component> component);\n\n    //! No copying.\n    PortsImportSummaryEditor(const PortsImportSummaryEditor& other) = delete;\n    PortsImportSummaryEditor& operator=(const PortsImportSummaryEditor& other) = delete;\n\nprivate:\n\n    //-----------------------------------------------------------------------------\n    // Data.\n    //-----------------------------------------------------------------------------\n\n\n    //! The original component.\n    QSharedPointer<Component> originalComponent_ = { nullptr };\n\n};\n\n#endif // PORTSIMPORTSUMMARYEDITOR_H\n"
  },
  {
    "path": "editors/ComponentEditor/ports/PortsView.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: PortsView.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Esko Pekkarinen\r\n// Date: 2.12.2013\r\n//\r\n// Description:\r\n// View for port editor.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"PortsView.h\"\r\n\r\n#include <QMenu>\r\n#include <QHeaderView>\r\n\r\n#include <KactusAPI/include/BusInterfaceInterface.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PortsView::PortsView()\r\n//-----------------------------------------------------------------------------\r\nPortsView::PortsView(int nameColumn, BusInterfaceInterface* busInterface, QWidget *parent):\r\nEditableTableView(parent),\r\ncreateBus_(tr(\"Create new bus definition\"), this),\r\ncreateExistingBus_(tr(\"Use existing bus definition\"), this),\r\nnameColumn_(nameColumn),\r\nbusInterface_(busInterface)\r\n{\r\n    verticalHeader()->show();\r\n    verticalHeader()->setMaximumWidth(300);\r\n    verticalHeader()->setMinimumWidth(horizontalHeader()->fontMetrics().horizontalAdvance(tr(\"Name\"))*2);\r\n    verticalHeader()->setSectionResizeMode(QHeaderView::Fixed);\r\n\r\n    connect(&createBus_, SIGNAL(triggered()), this, SLOT(onCreateNewBus()), Qt::UniqueConnection);\r\n\r\n    connect(&createExistingBus_, SIGNAL(triggered()), this, SLOT(onCreateExistingBus()), Qt::UniqueConnection);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PortsView::onCreateBus()\r\n//-----------------------------------------------------------------------------\r\nvoid PortsView::onCreateNewBus()\r\n{\r\n    QStringList selectedPorts;\r\n    for (QModelIndex const& portIndex : selectedIndexes())\r\n    {   \r\n        QString portName = portIndex.sibling(portIndex.row(), nameColumn_).data().toString();\r\n        if (!selectedPorts.contains(portName))\r\n        {\r\n            selectedPorts.append(portName);\r\n        }\r\n    }\r\n\r\n    emit createBus(selectedPorts);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PortsView::onCreateExistingBus()\r\n//-----------------------------------------------------------------------------\r\nvoid PortsView::onCreateExistingBus()\r\n{\r\n    QStringList selectedPorts;\r\n    for (QModelIndex const& portIndex : selectedIndexes())\r\n    {   \r\n        QString portName = portIndex.sibling(portIndex.row(), nameColumn_).data().toString();\r\n        if (!selectedPorts.contains(portName))\r\n        {\r\n            selectedPorts.append(portName);\r\n        }\r\n    }\r\n\r\n    emit createExistingBus(selectedPorts);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PortsView::contextMenuEvent()\r\n//-----------------------------------------------------------------------------\r\nvoid PortsView::contextMenuEvent(QContextMenuEvent* event)\r\n{\r\n    pressedPoint_ = event->pos();\r\n\r\n    QModelIndex index = indexAt(pressedPoint_);\r\n\r\n    QMenu menu(this);\r\n    menu.addAction(&addAction_);\r\n\r\n    // if at least one valid item is selected\r\n    if (index.isValid())\r\n    {\r\n        menu.addAction(&removeAction_);\r\n        menu.addAction(&clearAction_);\r\n        menu.addAction(&cutAction_);\r\n        menu.addAction(&copyAction_);\r\n        menu.addAction(&pasteAction_);\r\n    }\r\n    \r\n    if (index.isValid())\r\n    {\r\n        menu.addSeparator();\r\n        QMenu* createMenu = menu.addMenu(tr(\"New bus interface\"));\r\n        createMenu->addAction(&createBus_);    \r\n        createMenu->addAction(&createExistingBus_);           \r\n    }\r\n\r\n    if (busInterface_->itemCount() > 0)\r\n    {\r\n        menu.addSeparator();\r\n\r\n        QMenu* portsFromBusMenu = menu.addMenu(tr(\"Create ports from...\"));\r\n        for (auto const& name : busInterface_->getItemNames())\r\n        {\r\n            QString busName = QString::fromStdString(name);\r\n            std::vector<std::string> busAbstractions =\r\n                busInterface_->getAbstractionReferences(busName.toStdString());\r\n            if (busAbstractions.empty() || busAbstractions.size() == 1)\r\n            {\r\n                QAction* busAction(new QAction(busName, this));\r\n                portsFromBusMenu->addAction(busAction);\r\n\r\n                connect(busAction, SIGNAL(triggered()), this, SLOT(onCreatePortsFromBus()), Qt::UniqueConnection);\r\n            }\r\n            else\r\n            {\r\n                QMenu* selectAbstractionMenu = portsFromBusMenu->addMenu(busName);\r\n                for (auto const& abstraction : busAbstractions)\r\n                {\r\n                    QAction* abstractionAction(new QAction(QString::fromStdString(abstraction), this));\r\n                    abstractionAction->setData(QVariant(busName));\r\n\r\n                    selectAbstractionMenu->addAction(abstractionAction);\r\n                    connect(abstractionAction, SIGNAL(triggered()),\r\n                        this, SLOT(onCreatePortsFromAbstraction()), Qt::UniqueConnection);\r\n                }\r\n            }\r\n        }\r\n    }\r\n\r\n    if (importExportAllowed())\r\n    {\r\n        menu.addSeparator();\r\n        menu.addAction(&importAction_);\r\n        menu.addAction(&exportAction_);\r\n    }\r\n\r\n    menu.exec(event->globalPos());\r\n\r\n    event->accept();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PortsView::onCreatePortsFromBus()\r\n//-----------------------------------------------------------------------------\r\nvoid PortsView::onCreatePortsFromBus()\r\n{\r\n    if (auto senderAction = dynamic_cast<QAction*>(QObject::sender()))\r\n    {\r\n        std::string busName = senderAction->text().toStdString();\r\n        QString abstractionVLNV =\r\n            QString::fromStdString(busInterface_->getAbstractionReferenceString(busName));\r\n\r\n        emit createPortsFromAbstraction(busName, abstractionVLNV);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PortsView::onCreatePortsFromAbstraction()\r\n//-----------------------------------------------------------------------------\r\nvoid PortsView::onCreatePortsFromAbstraction()\r\n{\r\n    if (auto senderAction = dynamic_cast<QAction*>(QObject::sender()))\r\n    {\r\n        std::string busName = senderAction->data().toString().toStdString();\r\n        QString abstractionVLNV = senderAction->text();\r\n\r\n        emit createPortsFromAbstraction(busName, abstractionVLNV);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PortsView::mousePressEvent()\r\n//-----------------------------------------------------------------------------\r\nvoid PortsView::mousePressEvent(QMouseEvent* event)\r\n{\r\n    EditableTableView::mousePressEvent(event);\r\n\r\n    QModelIndex currentIndex = indexAt(pressedPoint_);\r\n    if (!currentIndex.isValid())\r\n    {\r\n        emit(changeExtensionsEditorItem(currentIndex));\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PortsView::currentChanged()\r\n//-----------------------------------------------------------------------------\r\nvoid PortsView::currentChanged(const QModelIndex &current, const QModelIndex &previous)\r\n{\r\n    emit(changeExtensionsEditorItem(current));\r\n\r\n    EditableTableView::currentChanged(current, previous);\r\n}\r\n"
  },
  {
    "path": "editors/ComponentEditor/ports/PortsView.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: PortsView.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Esko Pekkarinen\r\n// Date: 2.12.2013\r\n//\r\n// Description:\r\n// View for port editor.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef PORTSVIEW_H\r\n#define PORTSVIEW_H\r\n\r\n#include <common/views/EditableTableView/editabletableview.h>\r\n\r\n#include <IPXACTmodels/generaldeclarations.h>\r\n\r\n#include <QAction>\r\n\r\nclass BusInterfaceInterface;\r\n\r\n//-----------------------------------------------------------------------------\r\n// View for port editor.\r\n//-----------------------------------------------------------------------------\r\nclass PortsView : public EditableTableView\r\n{\r\n    Q_OBJECT\r\npublic:\r\n\r\n\r\n\t/*!\r\n\t *  The constructor.\r\n\t *\r\n     *    @param [in] nameColumn      Name column index of.\r\n     *    @param [in] busInterface    Interface for accessing bus interfaces.\r\n\t *    @param [in] parent          The parent widget.\r\n\t */\r\n    PortsView(int nameColumn, BusInterfaceInterface* busInterface, QWidget *parent);\r\n\r\n\t//! The destructor.\r\n\tvirtual ~PortsView() = default;\r\n\r\nsignals:\r\n\r\n    //! Emitted when new bus interface is selected from the context menu and a new bus definition must be created.\r\n    void createBus(QStringList const& portNames);\r\n\r\n    //! Emitted when new bus interface is selected from the context menu.\r\n    void createExistingBus(QStringList const& portNames);\r\n\r\n    /*!\r\n     *  Change the vendor extensions of the vendor extensions editor.\r\n     *\r\n     *    @param [in] itemIndex   Index of the selected port.\r\n     */\r\n    void changeExtensionsEditorItem(QModelIndex const& itemIndex);\r\n\r\n    /*!\r\n     *  Create ports from the signals of the selected abstraction definition.\r\n     *\r\n     *    @param [in] busName             Name of the bus interface containing the abstraction definition.\r\n     *    @param [in] abstractionVLNV     VLNV string of the selected abstraction definition.\r\n     */\r\n    void createPortsFromAbstraction(std::string const& busName, QString const& abstractionVLNV);\r\n\r\nprivate slots:\r\n\r\n    //! Handler for new bus definition and interface creation.     \r\n    virtual void onCreateNewBus();\r\n\r\n    //! Handler for new bus interface creation.\r\n    virtual void onCreateExistingBus();\r\n\r\n    /*!\r\n     *  Handle the creation of ports from the selected bus interface.\r\n     */\r\n    void onCreatePortsFromBus();\r\n\r\n    /*!\r\n     *  Handle the creation of ports from the selected abstraction definition.\r\n     */\r\n    void onCreatePortsFromAbstraction();\r\n\r\nprotected:\r\n\r\n    //! Handler for context menu events.\r\n    void contextMenuEvent(QContextMenuEvent* event) override;\r\n\r\n    /*!\r\n     *  Handler for mouse press events.\r\n     */\r\n    void mousePressEvent(QMouseEvent* event) final;\r\n\r\n    /*!\r\n     *  Handler for index change events.\r\n     *\r\n     *    @param [in] current     The current index.\r\n     *    @param [in] previous    The previous index.\r\n     */\r\n    virtual void currentChanged(const QModelIndex &current, const QModelIndex &previous);\r\n\r\n\r\nprivate:\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! Action for creating a new bus definition and interface.\r\n    QAction createBus_;\r\n\r\n    //! Action for creating a new bus interface.\r\n    QAction createExistingBus_;\r\n\r\n    //! Name column index.\r\n    int nameColumn_;\r\n\r\n    //! Interface for accessing bus interfaces.\r\n    BusInterfaceInterface* busInterface_;\r\n};\r\n\r\n#endif // PORTSVIEW_H\r\n"
  },
  {
    "path": "editors/ComponentEditor/ports/TransactionalPortColumns.h",
    "content": "//-----------------------------------------------------------------------------\n// File: TransactionalPortColumns.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 29.04.2019\n//\n// Description:\n// Common declarations for editing transactional ports.\n//-----------------------------------------------------------------------------\n\n#ifndef TRANSACTIONAL_PORT_COLUMNS_H\n#define TRANSACTIONAL_PORT_COLUMNS_H\n\nnamespace TransactionalPortColumns\n{\n    //-----------------------------------------------------------------------------\n    // Constants defining which column represents what kind of information.\n    //-----------------------------------------------------------------------------\n    enum Columns\n    {\n        ROW_NUMBER = 0,     //!< Column for the row number.\n        NAME ,              //!< Column for the port name.\n        WIDTH,              //!< Column for the port width.\n        INITIATIVE,         //!< Column for the transactional initiative.\n        KIND,               //!< Column for the transactional kind.\n        PROTOCOL,           //!< Column for the transactional protocol.\n        TYPE_NAME,          //!< Column for the port typename.\n        ARRAY_LEFT,         //!< Column for setting the left side of the array.\n        ARRAY_RIGHT,        //!< Column for setting the right side of the array.\n        TAG_GROUP,          //!< Column for tagging a port.\n        MAX_CONNECTIONS,    //!< Column for setting the maximum number of connections.\n        MIN_CONNECTIONS,    //!< Column for setting the minimum number of connections.\n        ADHOC_VISIBILITY,   //!< Column for toggling ad-hoc visibility on/off.\n        DESCRIPTION,        //!< Column for adding a description for the port.\n        COLUMN_COUNT\n    };\n}\n\n#endif // TRANSACTIONAL_PORT_COLUMNS_H"
  },
  {
    "path": "editors/ComponentEditor/ports/TransactionalPortsDelegate.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: TransactionalPortsDelegate.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 09.05.2019\n//\n// Description:\n// The delegate that provides editors to edit transactional ports of a component.\n//-----------------------------------------------------------------------------\n\n#include \"TransactionalPortsDelegate.h\"\n\n#include <editors/ComponentEditor/ports/TransactionalPortColumns.h>\n\n#include <IPXACTmodels/common/TransactionalTypes.h>\n#include <IPXACTmodels/Component/Component.h>\n\n#include <QComboBox>\n\n//-----------------------------------------------------------------------------\n// Function: TransactionalPortsDelegate::TransactionalPortsDelegate()\n//-----------------------------------------------------------------------------\nTransactionalPortsDelegate::TransactionalPortsDelegate(QSharedPointer<Component> component,\n    QAbstractItemModel* completionModel, QSharedPointer<ParameterFinder> parameterFinder,\n    QSharedPointer<PortTypeValidator> typeValidator, QObject* parent):\nPortsDelegate(component, completionModel, parameterFinder, typeValidator, parent)\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: TransactionalPortsDelegate::createEditor()\n//-----------------------------------------------------------------------------\nQWidget* TransactionalPortsDelegate::createEditor(QWidget* parent, QStyleOptionViewItem const& option,\n    QModelIndex const& index) const\n{\n    if (index.column() == TransactionalPortColumns::INITIATIVE)\n    {\n        return createSelectorForInitiative(parent);\n    }\n    else if (index.column() == TransactionalPortColumns::KIND)\n    {\n        return createSelectorForKind(parent);\n    }\n    else\n    {\n        return PortsDelegate::createEditor(parent, option, index);\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: TransactionalPortsDelegate::createSelectorForInitiative()\n//-----------------------------------------------------------------------------\nQWidget* TransactionalPortsDelegate::createSelectorForInitiative(QWidget* parent) const\n{\n    QComboBox* initiativeSelector = new QComboBox(parent);\n\n    for (auto initiative : TransactionalTypes::INITIATIVE_TYPES)\n    {\n        QString newInitiative = initiative;\n        if (newInitiative.compare(TransactionalTypes::INITIATIVE_BOTH, Qt::CaseInsensitive) == 0)\n        {\n            newInitiative = TransactionalTypes::INITIATIVE_REQUIRES_PROVIDES;\n        }\n\n        initiativeSelector->addItem(newInitiative);\n    }\n\n    return initiativeSelector;\n}\n\n//-----------------------------------------------------------------------------\n// Function: TransactionalPortsDelegate::createSelectorForKind()\n//-----------------------------------------------------------------------------\nQWidget* TransactionalPortsDelegate::createSelectorForKind(QWidget* parent) const\n{\n    QComboBox* kindSelector = new QComboBox(parent);\n\n    for (auto const& kind : TransactionalTypes::KIND_TYPES)\n    {\n        if (kind.compare(\"custom\", Qt::CaseInsensitive) != 0)\n        {\n            kindSelector->addItem(kind);\n        }\n    }\n\n    kindSelector->setEditable(true);\n    return kindSelector;\n}\n\n//-----------------------------------------------------------------------------\n// Function: TransactionalPortsDelegate::setEditorData()\n//-----------------------------------------------------------------------------\nvoid TransactionalPortsDelegate::setEditorData(QWidget* editor, QModelIndex const& index) const\n{\n    if (index.column() == TransactionalPortColumns::INITIATIVE || index.column() == TransactionalPortColumns::KIND)\n    {\n        QString text = index.data(Qt::DisplayRole).toString();\n        QComboBox* combo = qobject_cast<QComboBox*>(editor);\n\n        int comboIndex = combo->findText(text);\n        combo->setCurrentIndex(comboIndex);\n    }\n    else\n    {\n        PortsDelegate::setEditorData(editor, index);\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: TransactionalPortsDelegate::setModelData()\n//-----------------------------------------------------------------------------\nvoid TransactionalPortsDelegate::setModelData(QWidget* editor, QAbstractItemModel* model, QModelIndex const& index)\n    const\n{\n    if (index.column() == TransactionalPortColumns::INITIATIVE || index.column() == TransactionalPortColumns::KIND)\n    {\n        QComboBox* combo = qobject_cast<QComboBox*>(editor);\n        QString text = combo->currentText();\n        model->setData(index, text, Qt::EditRole);\n    }\n    else\n    {\n        PortsDelegate::setModelData(editor, model, index);\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: TransactionalPortsDelegate::columnAcceptsExpression()\n//-----------------------------------------------------------------------------\nbool TransactionalPortsDelegate::columnAcceptsExpression(int column) const\n{\n    return PortsDelegate::columnAcceptsExpression(column) || column == TransactionalPortColumns::WIDTH||\n        column == TransactionalPortColumns::MAX_CONNECTIONS || column == TransactionalPortColumns::MIN_CONNECTIONS;\n}\n\n//-----------------------------------------------------------------------------\n// Function: TransactionalPortsDelegate::descriptionColumn()\n//-----------------------------------------------------------------------------\nint TransactionalPortsDelegate::descriptionColumn() const\n{\n    return TransactionalPortColumns::DESCRIPTION;\n}\n\n//-----------------------------------------------------------------------------\n// Function: TransactionalPortsDelegate::nameColumn()\n//-----------------------------------------------------------------------------\nint TransactionalPortsDelegate::nameColumn() const\n{\n    return TransactionalPortColumns::NAME;\n}\n\n//-----------------------------------------------------------------------------\n// Function: TransactionalPortsDelegate::typeColumn()\n//-----------------------------------------------------------------------------\nint TransactionalPortsDelegate::typeColumn() const\n{\n    return TransactionalPortColumns::TYPE_NAME;\n}\n\n//-----------------------------------------------------------------------------\n// Function: TransactionalPortsDelegate::tagColumn()\n//-----------------------------------------------------------------------------\nint TransactionalPortsDelegate::tagColumn() const\n{\n    return TransactionalPortColumns::TAG_GROUP;\n}\n\n//-----------------------------------------------------------------------------\n// Function: TransactionalPortsDelegate::adHocColumn()\n//-----------------------------------------------------------------------------\nint TransactionalPortsDelegate::adHocColumn() const\n{\n    return TransactionalPortColumns::ADHOC_VISIBILITY;\n}\n\n//-----------------------------------------------------------------------------\n// Function: TransactionalPortsDelegate::arrayLeftColumn()\n//-----------------------------------------------------------------------------\nint TransactionalPortsDelegate::arrayLeftColumn() const\n{\n    return TransactionalPortColumns::ARRAY_LEFT;\n}\n\n//-----------------------------------------------------------------------------\n// Function: TransactionalPortsDelegate::arrayRightColumn()\n//-----------------------------------------------------------------------------\nint TransactionalPortsDelegate::arrayRightColumn() const\n{\n    return TransactionalPortColumns::ARRAY_RIGHT;\n}\n"
  },
  {
    "path": "editors/ComponentEditor/ports/TransactionalPortsDelegate.h",
    "content": "//-----------------------------------------------------------------------------\n// File: TransactionalPortsDelegate.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 09.05.2019\n//\n// Description:\n// The delegate that provides editors to edit transactional ports of a component.\n//-----------------------------------------------------------------------------\n\n#ifndef TRANSACTIONALPORTSDELEGATE_H\n#define TRANSACTIONALPORTSDELEGATE_H\n\n#include <editors/ComponentEditor/ports/portsdelegate.h>\n\n#include <QCompleter>\n\nclass ParameterFinder;\nclass Component;\nclass PortTypeValidator;\n\n//-----------------------------------------------------------------------------\n//! The delegate that provides editors to edit transactional ports of a component.\n//-----------------------------------------------------------------------------\nclass TransactionalPortsDelegate : public PortsDelegate\n{\n\tQ_OBJECT\n\npublic:\n\n    /*!\n     *  The constructor.\n     *\n     *    @param [in] component           Component containing the edited ports.\n     *    @param [in] completionModel     Model containing the completions used in expression editor.\n     *    @param [in] parameterFinder     The parameter finder to use for for expression editor.\n     *    @param [in] typeValidator       Validator for port type definitions.\n     *    @param [in] parent              The parent object.\n     */\n\tTransactionalPortsDelegate(QSharedPointer<Component> component, QAbstractItemModel* completionModel,\n        QSharedPointer<ParameterFinder> parameterFinder, QSharedPointer<PortTypeValidator> typeValidator,\n        QObject* parent = 0);\n\t\n\t/*!\n     *  The destructor.\n     */\n    virtual ~TransactionalPortsDelegate() = default;\n\n\t/*!\n     *  Create a new editor for the given item.\n\t *\n\t *    @param [in] parent   Owner for the editor.\n\t *    @param [in] option   Contains options for the editor.\n\t *    @param [in] index    Model index identifying the item.\n\t *\n\t *    @return The editor to be used to edit the item.\n     */\n\tvirtual QWidget* createEditor(QWidget* parent, QStyleOptionViewItem const& option, QModelIndex const& index)\n        const;\n\n\t/*!\n     *  Set the data for the editor.\n\t *\n\t *    @param [in] editor  The editor where the data is to be set.\n     *    @param [in] index   Model index identifying the item that's data is to be set.\n     */\n\tvirtual void setEditorData(QWidget* editor, QModelIndex const& index) const;\n\n\t/*!\n     *  Save the data from the editor to the model.\n\t *\n\t *    @param [in] editor  The editor that contains the data to store.\n     *    @param [in] model   Model that contains the data structure where data is to be saved to.\n     *    @param [in] index   Model index identifying the item that's data is to be saved.\n\t */\n\tvirtual void setModelData(QWidget* editor, QAbstractItemModel* model, QModelIndex const& index) const;\n\n    // Disable copying.\n    TransactionalPortsDelegate(TransactionalPortsDelegate const& rhs) = delete;\n    TransactionalPortsDelegate& operator=(TransactionalPortsDelegate const& rhs) = delete;\n\nprotected:\n    \n    /*!\n     *  Checks if the given column supports expressions in the editor.\n     *\n     *    @param [in] column   The column to check.\n     *\n     *    @return True, if the cells in the column allow expressions, otherwise false.\n     */\n    virtual bool columnAcceptsExpression(int column) const;\n\n    /*!\n     *  Gets the description column.\n     *\n     *    @return Column number for description.\n     */\n    virtual int descriptionColumn() const;\n\nprivate:\n\n    /*!\n     *  Gets the name column.\n     *\n     *    @return Column number for name.\n     */\n    virtual int nameColumn() const;\n\n    /*!\n     *  Gets the type definitions column.\n     *\n     *    @return Column number for type definitions.\n     */\n    virtual int typeColumn() const;\n\n    /*!\n     *  Gets the tag group column.\n     *\n     *    @return Column number for tag group.\n     */\n    virtual int tagColumn() const;\n\n    /*!\n     *  Gets the ad hoc column.\n     *\n     *    @return Column number for ad hoc.\n     */\n    virtual int adHocColumn() const;\n\n    /*!\n     *  Gets the array left column.\n     *\n     *    @return Column number for left value of the array.\n     */\n    virtual int arrayLeftColumn() const;\n\n    /*!\n     *  Gets the array right column.\n     *\n     *    @return Column number for right value of the array.\n     */\n    virtual int arrayRightColumn() const;\n\n    /*!\n     *  Creates a selector for port initiative.\n     *\n     *    @param [in] parent   The parent widget for the selector.\n     *\n     *    @return The selector for port initiative.\n     */\n    QWidget* createSelectorForInitiative(QWidget* parent) const;\n\n    /*!\n     *  Creates a selector for port kind.\n     *\n     *    @param [in] parent   The parent widget for the selector.\n     *\n     *    @return The selector for port kind.\n     */\n    QWidget* createSelectorForKind(QWidget* parent) const;\n\n    /*!\n     *  Creates an editor for port protocol.\n     *\n     *    @param [in] parent   The parent widget for the editor.\n     *\n     *    @return The editor for port protocol.\n     */\n    QWidget* createProtocolEditor(QWidget* parent) const;\n};\n\n#endif // TRANSACTIONALPORTSDELEGATE_H\n"
  },
  {
    "path": "editors/ComponentEditor/ports/TransactionalPortsEditorFactory.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: TransactionalPortsEditorFactory.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 29.04.2019\n//\n// Description:\n// Constructs transactional ports editor items.\n//-----------------------------------------------------------------------------\n\n#include \"TransactionalPortsEditorFactory.h\"\n\n#include <editors/ComponentEditor/ports/TypedPortsView.h>\n#include <editors/ComponentEditor/ports/TransactionalPortColumns.h>\n#include <editors/ComponentEditor/ports/TransactionalPortsFilter.h>\n#include <editors/ComponentEditor/ports/TransactionalPortsDelegate.h>\n#include <editors/ComponentEditor/ports/TransactionalPortsModel.h>\n#include <editors/ComponentEditor/parameters/ComponentParameterModel.h>\n\n#include <IPXACTmodels/Component/Component.h>\n#include <IPXACTmodels/Component/validators/PortValidator.h>\n\n#include <QCompleter>\n\n//-----------------------------------------------------------------------------\n// Function: TransactionalPortsEditorFactory::constructModel()\n//-----------------------------------------------------------------------------\nPortsModel* TransactionalPortsEditorFactory::createModel(QObject* parent) const\n{\n    return new TransactionalPortsModel(expressions_.finder, portsInterface_, signalInterface_, parent);\n}\n\n//-----------------------------------------------------------------------------\n// Function: TransactionalPortsEditorFactory::constructFilter()\n//-----------------------------------------------------------------------------\nPortsFilter* TransactionalPortsEditorFactory::createFilter(QObject* parent) const\n{\n    return new TransactionalPortsFilter(portsInterface_, parent);\n}\n\n//-----------------------------------------------------------------------------\n// Function: TransactionalPortsEditorFactory::constructView()\n//-----------------------------------------------------------------------------\nPortsView* TransactionalPortsEditorFactory::createView(QWidget* parent) const\n{\n    auto view = new TypedPortsView(TransactionalPortColumns::TYPE_NAME, TransactionalPortColumns::NAME, \n        busInterface_, parent);\n\n    view->setDefaultImportExportPath(defaultPath_);\n    view->setAllowImportExport(true);\n    view->setAlternatingRowColors(false);\n    view->setSortingEnabled(true);\n    view->setItemsDraggable(false);\n    view->setFitColumnsToContent(false);\n\n    return view;\n}\n\n//-----------------------------------------------------------------------------\n// Function: TransactionalPortsEditorFactory::createDelegate()\n//-----------------------------------------------------------------------------\nPortsDelegate* TransactionalPortsEditorFactory::createDelegate(QObject* parent) const\n{\n    auto componentParametersModel = new ComponentParameterModel(expressions_.finder, parent);\n    componentParametersModel->setExpressionParser(expressions_.parser);\n\n    return new TransactionalPortsDelegate(\n        component_, componentParametersModel, expressions_.finder, portValidator_->getTypeValidator(), parent);\n}\n"
  },
  {
    "path": "editors/ComponentEditor/ports/TransactionalPortsEditorFactory.h",
    "content": "//-----------------------------------------------------------------------------\n// File: TransactionalPortsEditorFactory.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 29.04.2019\n//\n// Description:\n// Constructs transactional ports editor items.\n//-----------------------------------------------------------------------------\n\n#ifndef TRANSACTIONAL_PORTS_EDITOR_FACTORY_H\n#define TRANSACTIONAL_PORTS_EDITOR_FACTORY_H\n\n#include <editors/ComponentEditor/ports/PortsEditorFactory.h>\n\n#include <QSortFilterProxyModel>\n#include <QSharedPointer>\n#include <QWidget>\n#include <QAbstractItemModel>\n\nclass Component;\nclass PortsModel;\nclass PortsView;\nclass PortValidator;\nclass PortsDelegate;\nclass ExpressionParser;\n\n//-----------------------------------------------------------------------------\n//! Constructs transactional ports editor items.\n//-----------------------------------------------------------------------------\nclass TransactionalPortsEditorFactory : public PortsEditorFactory\n{\npublic:\n\n    using PortsEditorFactory::PortsEditorFactory;\n\n    /*!\n     *  The destructor.\n     */\n    ~TransactionalPortsEditorFactory() = default;\n\n    /*!\n     *  Construct a ports model.\n     *\n    *    @param [in] parent              The owner of the constructed model.\n     *\n     *    @return The created ports model.\n     */\n    PortsModel* createModel(QObject* parent = 0) const  final;\n\n    /*!\n     *  Construct a filter.\n     *\n     *    @param [in] parent          Owner of the filter.\n     *\n     *    @return The created ports filter.\n     */\n    PortsFilter* createFilter(QObject* parent = 0) const final;\n\n    /*!\n     *  Construct a view.\n     *\n     *    @param [in] parent          Owner of the view.\n     *\n     *    @return The created view.\n     */\n    PortsView* createView(QWidget* parent) const final;\n\n    /*!\n     *  Construct a delegate.\n     *\n     *    @param [in] parent              The owner of the delegate.\n     *\n     *    @return The created delegate.\n     */\n    PortsDelegate* createDelegate(QObject* parent) const final;\n\n};\n\n#endif // TRANSACTIONAL_PORTS_EDITOR_FACTORY_H\n"
  },
  {
    "path": "editors/ComponentEditor/ports/TransactionalPortsFilter.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: TransactionalPortsFilter.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 08.05.2019\n//\n// Description:\n// Sorting proxy model for transactional ports.\n//-----------------------------------------------------------------------------\n\n#include \"TransactionalPortsFilter.h\"\n\n#include <IPXACTmodels/Component/Port.h>\n\n#include <editors/ComponentEditor/ports/TransactionalPortColumns.h>\n#include <KactusAPI/include/PortsInterface.h>\n\n//-----------------------------------------------------------------------------\n// Function: TransactionalPortsFilter::TransactionalPortsFilter()\n//-----------------------------------------------------------------------------\nTransactionalPortsFilter::TransactionalPortsFilter(QSharedPointer<PortsInterface> portInterface, QObject* parent):\nPortsFilter(portInterface, parent)\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: TransactionalPortsFilter::nameColumn()\n//-----------------------------------------------------------------------------\nint TransactionalPortsFilter::nameColumn() const\n{\n    return TransactionalPortColumns::NAME;\n}\n\n//-----------------------------------------------------------------------------\n// Function: TransactionalPortsFilter::portIsAccepted()\n//-----------------------------------------------------------------------------\nbool TransactionalPortsFilter::portIsAccepted(QString const& portName) const\n{\n    return getInterface()->portIsTransactional(portName.toStdString());\n}\n"
  },
  {
    "path": "editors/ComponentEditor/ports/TransactionalPortsFilter.h",
    "content": "//-----------------------------------------------------------------------------\n// File: TransactionalPortsFilter.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 08.05.2019\n//\n// Description:\n// Sorting proxy model for transactional ports.\n//-----------------------------------------------------------------------------\n\n#ifndef TRANSACTIONALPORTSFILTER_H\n#define TRANSACTIONALPORTSFILTER_H\n\n#include <editors/ComponentEditor/ports/PortsFilter.h>\n\n//-----------------------------------------------------------------------------\n//! Sorting proxy model for transactional ports.\n//-----------------------------------------------------------------------------\nclass TransactionalPortsFilter : public PortsFilter\n{\n    Q_OBJECT\n\npublic:\n\n\t /*!\n      *  Constructor.\n      *\n      *    @param [in] portsInterface     Interface for accessing the component ports.\n      *    @param [in] parent             The parent object.\n      */\n    TransactionalPortsFilter(QSharedPointer<PortsInterface> portInterface, QObject* parent = 0);\n\n\t /*!\n      *  Destructor.\n      */\n    virtual ~TransactionalPortsFilter() = default;\n\n    // No copying. No assignments.\n    TransactionalPortsFilter(TransactionalPortsFilter const& rhs) = delete;\n    TransactionalPortsFilter& operator=(TransactionalPortsFilter const& rhs) = delete;\n\nprivate:\n\n    /*!\n     *  Get the index of the name column.\n     *\n     *    @return Index of the name column.\n     */\n    virtual int nameColumn() const override final;\n\n    /*!\n     *  Check if a port is filtered.\n     *\n     *    @param [in] portName    Name of the selected port.\n     *\n     *    @return True, if the port is accepted, false otherwise.\n     */\n    virtual bool portIsAccepted(QString const& portName) const override final;\n};\n\n#endif // TRANSACTIONALPORTSFILTER_H"
  },
  {
    "path": "editors/ComponentEditor/ports/TransactionalPortsModel.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: TransactionalPortsModel.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 07.05.2019\n//\n// Description:\n// Table model for transactional ports.\n//-----------------------------------------------------------------------------\n\n#include \"TransactionalPortsModel.h\"\n\n#include <KactusAPI/include/PortsInterface.h>\n#include <editors/ComponentEditor/ports/TransactionalPortColumns.h>\n\n#include <IPXACTmodels/common/TransactionalTypes.h>\n\n#include <QIcon>\n\nusing namespace std;\n\n//-----------------------------------------------------------------------------\n// Function: TransactionalPortsModel::TransactionalPortsModel()\n//-----------------------------------------------------------------------------\nTransactionalPortsModel::TransactionalPortsModel(QSharedPointer<ParameterFinder> parameterFinder,\n    QSharedPointer<PortsInterface> portsInterface, QSharedPointer<PortAbstractionInterface> signalInterface,\n    QObject *parent):\nPortsModel(parameterFinder, portsInterface, signalInterface, parent)\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: TransactionalPortsModel::columnCount()\n//-----------------------------------------------------------------------------\nint TransactionalPortsModel::columnCount(QModelIndex const& parent) const\n{\n\tif (parent.isValid())\n    {\n\t\treturn 0;\n    }\n\n \treturn TransactionalPortColumns::COLUMN_COUNT;\n}\n\n//-----------------------------------------------------------------------------\n// Function: TransactionalPortsModel::headerData()\n//-----------------------------------------------------------------------------\nQVariant TransactionalPortsModel::headerData(int section, Qt::Orientation orientation, int role) const\n{\n    if (role == Qt::DisplayRole && orientation == Qt::Horizontal)\n    {\n        if (section == TransactionalPortColumns::WIDTH)\n        {\n            QString widthHeader = tr(\"Width\") + getExpressionSymbol();\n            return widthHeader;\n        }\n        else if (section == TransactionalPortColumns::INITIATIVE)\n        {\n            return tr(\"Initiative\");\n        }\n        else if (section == TransactionalPortColumns::KIND)\n        {\n            return tr(\"Kind\");\n        }\n        else if (section == TransactionalPortColumns::PROTOCOL)\n        {\n            return tr(\"Protocol\");\n        }\n        else if (section == TransactionalPortColumns::MAX_CONNECTIONS)\n        {\n            QString maxConnectionsHeader = tr(\"Max\\nconnections\") + getExpressionSymbol();\n            return maxConnectionsHeader;\n        }\n        else if (section == TransactionalPortColumns::MIN_CONNECTIONS)\n        {\n            QString minConnectionsHeader = tr(\"Min\\nconnections\") + getExpressionSymbol();\n            return minConnectionsHeader;\n        }\n    }\n\n    return PortsModel::headerData(section, orientation, role);\n}\n\n//-----------------------------------------------------------------------------\n// Function: TransactionalPortsModel::data()\n//-----------------------------------------------------------------------------\nQVariant TransactionalPortsModel::data(QModelIndex const& index, int role) const\n{\n    if (!index.isValid() || index.row() < 0 || index.row() >= getInterface()->itemCount())\n    {\n        return QVariant();\n    }\n\n    if (role == Qt::DecorationRole && index.column() == TransactionalPortColumns::INITIATIVE)\n    {\n        return QIcon(getIconPath(index.row()));\n    }\n\n    return PortsModel::data(index, role);\n}\n\n//-----------------------------------------------------------------------------\n// Function: TransactionalPortsModel::setData()\n//-----------------------------------------------------------------------------\nbool TransactionalPortsModel::setData(QModelIndex const& index, QVariant const& value, int role)\n{\n    if (PortsModel::setData(index, value, role))\n    {\n        return true;\n    }\n    else if (!index.isValid() || index.row() < 0 || index.row() >= rowCount())\n    {\n\t\treturn false;\n    }\n\n    std::string portName = getInterface()->getIndexedItemName(index.row());\n\n\tif (role == Qt::EditRole)\n    {\n        if (isLocked(index))\n        {\n            return false;\n        }\n        else if (index.column() == TransactionalPortColumns::WIDTH)\n        {\n            if (!value.isValid())\n            {\n                removeReferencesFromSingleExpression(\n                    QString::fromStdString(getInterface()->getBusWidthExpression(portName)));\n            }\n\n            getInterface()->setBusWidth(portName, value.toString().toStdString());\n        }\n        else if (index.column() == TransactionalPortColumns::INITIATIVE)\n        {\n            QString newInitiative = value.toString();\n            if (newInitiative.compare(TransactionalTypes::INITIATIVE_REQUIRES_PROVIDES, Qt::CaseInsensitive) == 0)\n            {\n                newInitiative = TransactionalTypes::INITIATIVE_BOTH;\n            }\n\n            getInterface()->setInitiative(portName, newInitiative.toStdString());\n        }\n        else if (index.column() == TransactionalPortColumns::KIND)\n        {\n            getInterface()->setKind(portName, value.toString().toStdString());\n        }\n        else if (index.column() == TransactionalPortColumns::MAX_CONNECTIONS)\n        {\n            if (!value.isValid())\n            {\n                removeReferencesFromSingleExpression(\n                    QString::fromStdString(getInterface()->getMaxConnectionsExpression(portName)));\n            }\n\n            getInterface()->setMaxConnections(portName, value.toString().toStdString());\n        }\n        else if (index.column() == TransactionalPortColumns::MIN_CONNECTIONS)\n        {\n            if (!value.isValid())\n            {\n                removeReferencesFromSingleExpression(\n                    QString::fromStdString(getInterface()->getMinConnectionsExpression(portName)));\n            }\n\n            getInterface()->setMinConnections(portName, value.toString().toStdString());\n        }\n        else\n        {\n            return false;\n        }\n\n        emit dataChanged(index, index);\n        return true;\n    }\n    else\n    {\n        return false;\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: TransactionalPortsModel::valueForIndex()\n//-----------------------------------------------------------------------------\nQVariant TransactionalPortsModel::valueForIndex(QModelIndex const& index) const\n{\n    std::string portName = getInterface()->getIndexedItemName(index.row());\n\n    if (index.column() == TransactionalPortColumns::WIDTH)\n    {\n        return QString::fromStdString(getInterface()->getBusWidthValue(portName));\n    }\n    else if (index.column() == TransactionalPortColumns::INITIATIVE)\n    {\n        QString initiative = QString::fromStdString(getInterface()->getInitiative(portName));\n        if (initiative.compare(TransactionalTypes::INITIATIVE_BOTH, Qt::CaseInsensitive) == 0)\n        {\n            initiative = TransactionalTypes::INITIATIVE_REQUIRES_PROVIDES;\n        }\n\n        return initiative;\n    }\n    else if (index.column() == TransactionalPortColumns::KIND)\n    {\n        return QString::fromStdString(getInterface()->getKind(portName));\n    }\n    else if (index.column() == TransactionalPortColumns::PROTOCOL)\n    {\n        return QString::fromStdString(getInterface()->getProtocolType(portName));\n    }\n    else if (index.column() == TransactionalPortColumns::MAX_CONNECTIONS)\n    {\n        return QString::fromStdString(getInterface()->getMaxConnectionsValue(portName));\n    }\n    else if (index.column() == TransactionalPortColumns::MIN_CONNECTIONS)\n    {\n        return QString::fromStdString(getInterface()->getMinConnectionsValue(portName));\n    }\n    \n    return PortsModel::valueForIndex(index);\n}\n\n//-----------------------------------------------------------------------------\n// Function: TransactionalPortsModel::formattedExpressionForIndex()\n//-----------------------------------------------------------------------------\nQVariant TransactionalPortsModel::formattedExpressionForIndex(QModelIndex const& index) const\n{\n    std::string portName = getInterface()->getIndexedItemName(index.row());\n\n    if (index.column() == TransactionalPortColumns::WIDTH)\n    {\n        return QString::fromStdString(getInterface()->getBusWidthFormattedExpression(portName));\n    }\n    else if (index.column() == TransactionalPortColumns::MAX_CONNECTIONS)\n    {\n        return QString::fromStdString(getInterface()->getMaxConnectionsFormattedExpression(portName));\n    }\n    else if (index.column() == TransactionalPortColumns::MIN_CONNECTIONS)\n    {\n        return QString::fromStdString(getInterface()->getMinConnectionsFormattedExpression(portName));\n    }\n    else\n    {\n        return PortsModel::formattedExpressionForIndex(index);\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: TransactionalPortsModel::expressionForIndex()\n//-----------------------------------------------------------------------------\nQVariant TransactionalPortsModel::expressionForIndex(QModelIndex const& index) const\n{\n    string portName = getInterface()->getIndexedItemName(index.row());\n\n    if (index.column() == TransactionalPortColumns::WIDTH)\n    {\n        return QString::fromStdString(getInterface()->getBusWidthExpression(portName));\n    }\n    else if (index.column() == TransactionalPortColumns::MAX_CONNECTIONS)\n    {\n        return QString::fromStdString(getInterface()->getMaxConnectionsExpression(portName));\n    }\n    else if (index.column() == TransactionalPortColumns::MIN_CONNECTIONS)\n    {\n        return QString::fromStdString(getInterface()->getMinConnectionsExpression(portName));\n    }\n    else\n    {\n        return PortsModel::expressionForIndex(index);\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: TransactionalPortsModel::isValidExpressionColumn()\n//-----------------------------------------------------------------------------\nbool TransactionalPortsModel::isValidExpressionColumn(QModelIndex const& index) const\n{\n    return index.column() == TransactionalPortColumns::WIDTH ||\n        index.column() == TransactionalPortColumns::MAX_CONNECTIONS ||\n        index.column() == TransactionalPortColumns::MIN_CONNECTIONS ||\n        index.column() == TransactionalPortColumns::ARRAY_LEFT ||\n        index.column() == TransactionalPortColumns::ARRAY_RIGHT;\n}\n\n//-----------------------------------------------------------------------------\n// Function: TransactionalPortsModel::isPortTypeColumn()\n//-----------------------------------------------------------------------------\nbool TransactionalPortsModel::isPortTypeColumn(QModelIndex const& index) const\n{\n    return index.column() == TransactionalPortColumns::TYPE_NAME;\n}\n\n//-----------------------------------------------------------------------------\n// Function: TransactionalPortsModel::expressionOrValueForIndex()\n//-----------------------------------------------------------------------------\nQVariant TransactionalPortsModel::expressionOrValueForIndex(QModelIndex const& index) const\n{\n    if (isValidExpressionColumn(index))\n    {\n        return expressionForIndex(index);\n    }\n    else\n    {\n        return valueForIndex(index);\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: TransactionalPortsModel::validateIndex()\n//-----------------------------------------------------------------------------\nbool TransactionalPortsModel::validateIndex(QModelIndex const& index) const\n{\n    std::string portName = getInterface()->getIndexedItemName(index.row());\n\n    if (index.column() == TransactionalPortColumns::WIDTH)\n    {\n        return getInterface()->portHasValidBusWidth(portName);\n    }\n    else if (index.column() == TransactionalPortColumns::INITIATIVE)\n\t{\n        return getInterface()->portHasValidInitiative(portName);\n    }\n    else if (index.column() == TransactionalPortColumns::KIND)\n    {\n        return getInterface()->portHasValidKind(portName);\n    }\n    else if (index.column() == TransactionalPortColumns::PROTOCOL)\n    {\n        return getInterface()->portHasValidProtocol(portName);\n    }\n    else if (index.column() == TransactionalPortColumns::MAX_CONNECTIONS)\n    {\n        return getInterface()->portHasValidMaxConnections(portName);\n    }\n    else if (index.column() == TransactionalPortColumns::MIN_CONNECTIONS)\n    {\n        return getInterface()->portHasValidMinConnections(portName);\n    }\n    else\n    {\n        return PortsModel::validateIndex(index);\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: TransactionalPortsModel::rowNumberColumn()\n//-----------------------------------------------------------------------------\nint TransactionalPortsModel::rowNumberColumn() const\n{\n    return TransactionalPortColumns::ROW_NUMBER;\n}\n\n//-----------------------------------------------------------------------------\n// Function: TransactionalPortsModel::nameColumn()\n//-----------------------------------------------------------------------------\nint TransactionalPortsModel::nameColumn() const\n{\n    return TransactionalPortColumns::NAME;\n}\n\n//-----------------------------------------------------------------------------\n// Function: TransactionalPortsModel::typeColumn()\n//-----------------------------------------------------------------------------\nint TransactionalPortsModel::typeColumn() const\n{\n    return TransactionalPortColumns::TYPE_NAME;\n}\n\n//-----------------------------------------------------------------------------\n// Function: TransactionalPortsModel::arrayLeftColumn()\n//-----------------------------------------------------------------------------\nint TransactionalPortsModel::arrayLeftColumn() const\n{\n    return TransactionalPortColumns::ARRAY_LEFT;\n}\n\n//-----------------------------------------------------------------------------\n// Function: TransactionalPortsModel::arrayRightColum()\n//-----------------------------------------------------------------------------\nint TransactionalPortsModel::arrayRightColum() const\n{\n    return TransactionalPortColumns::ARRAY_RIGHT;\n}\n\n//-----------------------------------------------------------------------------\n// Function: TransactionalPortsModel::tagColumn()\n//-----------------------------------------------------------------------------\nint TransactionalPortsModel::tagColumn() const\n{\n    return TransactionalPortColumns::TAG_GROUP;\n}\n\n//-----------------------------------------------------------------------------\n// Function: TransactionalPortsModel::adHocColumn()\n//-----------------------------------------------------------------------------\nint TransactionalPortsModel::adHocColumn() const\n{\n    return TransactionalPortColumns::ADHOC_VISIBILITY;\n}\n\n//-----------------------------------------------------------------------------\n// Function: WirePortsModel::descriptionColumn()\n//-----------------------------------------------------------------------------\nint TransactionalPortsModel::descriptionColumn() const\n{\n    return TransactionalPortColumns::DESCRIPTION;\n}\n\n//-----------------------------------------------------------------------------\n// Function: TransactionalPortsModel::indexedItemIsDisabled()\n//-----------------------------------------------------------------------------\nbool TransactionalPortsModel::indexedItemIsDisabled(QModelIndex const& index) const\n{\n    return index.column() == TransactionalPortColumns::ROW_NUMBER ||\n        index.column() == TransactionalPortColumns::PROTOCOL;\n}\n\n//-----------------------------------------------------------------------------\n// Function: TransactionalPortsModel::indexedItemIsMandatory()\n//-----------------------------------------------------------------------------\nbool TransactionalPortsModel::indexedItemIsMandatory(QModelIndex const& index) const\n{\n    return index.column() == TransactionalPortColumns::NAME ||\n        index.column() == TransactionalPortColumns::INITIATIVE;\n}\n\n//-----------------------------------------------------------------------------\n// Function: TransactionalPortsModel::indexedItemIsLocked()\n//-----------------------------------------------------------------------------\nbool TransactionalPortsModel::indexedItemIsLocked(QModelIndex const& index) const\n{\n    return index.column() == TransactionalPortColumns::PROTOCOL;\n}\n\n//-----------------------------------------------------------------------------\n// Function: WirePortsModel::getLockedPortIndexes()\n//-----------------------------------------------------------------------------\nQModelIndexList TransactionalPortsModel::getLockedPortIndexes(QModelIndex const& /*portIndex*/) const\n{\n    return QModelIndexList();\n}\n\n//-----------------------------------------------------------------------------\n// Function: TransactionalPortsModel::addNewPort()\n//-----------------------------------------------------------------------------\nvoid TransactionalPortsModel::addNewPort()\n{\n    getInterface()->addTransactionalPort();\n}\n"
  },
  {
    "path": "editors/ComponentEditor/ports/TransactionalPortsModel.h",
    "content": "//-----------------------------------------------------------------------------\n// File: TransactionalPortsModel.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 07.05.2019\n//\n// Description:\n// Table model for transactional ports.\n//-----------------------------------------------------------------------------\n\n#ifndef TRANSACTIONALPORTSMODEL_H\n#define TRANSACTIONALPORTSMODEL_H\n\n#include <editors/ComponentEditor/ports/portsmodel.h>\n\n//-----------------------------------------------------------------------------\n//! Table model for transactional ports.\n//-----------------------------------------------------------------------------\nclass TransactionalPortsModel : public PortsModel\n{\n\tQ_OBJECT\n\npublic:\n\n\t/*!\n     *  The constructor.\n\t *\n     *    @param [in] parameterFinder     Pointer to the parameter finder.\n     *    @param [in] portsInterface      Interface for accessing the component ports.\n     *    @param [in] signalInterface     Interface for accessing abstraction signals.\n\t *    @param [in] parent              Pointer to the owner of this model.\n     */\n    TransactionalPortsModel(QSharedPointer <ParameterFinder> parameterFinder,\n        QSharedPointer<PortsInterface> portsInterface,\n        QSharedPointer<PortAbstractionInterface> signalInterface,\n        QObject *parent);\n\n\t/*!\n     *  The destructor.\n     */\n    virtual ~TransactionalPortsModel() = default;\n\n\t/*!\n     *  Get the number of columns in the model.\n\t *\n\t *    @param [in] parent      Model index of the parent of the item. Must be invalid\n     *\n\t *    @return Always returns 9.\n     */\n\tvirtual int columnCount(const QModelIndex& parent = QModelIndex() ) const;\n\n\t/*!\n     *  Get the data for the headers.\n\t *\n\t *    @param [in] section         The column that's header is wanted\n\t *    @param [in] orientation     Only Qt::Horizontal is supported\n\t *    @param [in] role            Specified the type of data that is wanted.\n\t *\n\t *    @return QVariant containing the data to be displayed.\n\t */\n\tvirtual QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole ) const;\n\n    /*!\n     *  Get the data for the specified item for specified role.\n\t *\n\t *    @param [in] index   Identifies the item that's data is wanted.\n\t *    @param [in] role    Specifies what kind of data is wanted\n\t *\n\t *    @return QVariant containing the data\n     */\n\tvirtual QVariant data(const QModelIndex& index, int role = Qt::DisplayRole ) const;\n\n\t/*!\n     *  Set the data for specified item.\n\t *\n\t *    @param [in] index   Specifies the item that's data is modified\n\t *    @param [in] value   The value to be set.\n\t *    @param [in] role    The role that is trying to modify the data. Only Qt::EditRole is supported.\n\t *\n\t *    @return True if data was successfully set.\n\t */\n\tvirtual bool setData(QModelIndex const& index, QVariant const& value, int role = Qt::EditRole);\n\n    //! No copying. No assignment.\n    TransactionalPortsModel(const TransactionalPortsModel& other) = delete;\n    TransactionalPortsModel& operator=(const TransactionalPortsModel& other) = delete;\n\nprotected:\n\n    /*!\n     *  Check if the column index is valid for containing expressions.\n     *\n     *    @param [in] index   The index being evaluated.\n     *\n     *      return True, if column can have expressions, false otherwise.\n     */\n    virtual bool isValidExpressionColumn(QModelIndex const& index) const override final;\n\n    bool isPortTypeColumn(QModelIndex const& index) const final;\n\n    /*!\n     *  Gets the expression for the given index, or plain value if there is no expression.\n     *\n     *    @param [in] index   The index of target data.\n     *\n     *      return Expression in the given index, or plain value.\n     */\n    virtual QVariant expressionOrValueForIndex(QModelIndex const& index) const override final;\n\n    /*!\n     *  Get the formatted value of an expression in the selected index.\n     *\n     *    @param [in] index   The selected index.\n     *\n     *    @return The formatted value of an expression in the selected index.\n     */\n    virtual QVariant formattedExpressionForIndex(QModelIndex const& index) const override final;\n\n    /*!\n     *  Get the expression of the selected index.\n     *\n     *    @param [in] index   The selected index.\n     *\n     *    @return The expression of the selected index.\n     */\n    virtual QVariant expressionForIndex(QModelIndex const& index) const override final;\n\n    /*!\n     *  Gets the value for the given index.\n     *\n     *    @param [in] index   The index of target data.\n     *\n     *      return The data in the given index.\n     */\n    virtual QVariant valueForIndex(QModelIndex const& index) const override final;\n\n    /*!\n     *  Validates the data in the cell given by the column.\n     *\n     *    @param [in] index   The index being validated.\n     *\n     *      return True, if the data in the parameter is valid, false otherwise.\n     */\n    virtual bool validateIndex(QModelIndex const& index) const override final;\n\nprivate:\n\n    /*!\n     *  Get the column for row number.\n     *\n     *    @return Row number column.\n     */\n    virtual int rowNumberColumn() const override final;\n\n    /*!\n     *  Get the column for name.\n     *\n     *    @return Name column.\n     */\n    virtual int nameColumn() const override final;\n\n    /*!\n     *  Get the column for type definitions.\n     *\n     *    @return Type definitions column.\n     */\n    virtual int typeColumn() const override final;\n\n    /*!\n     *  Get the column for array left.\n     *\n     *    @return Array left column.\n     */\n    virtual int arrayLeftColumn() const override final;\n\n    /*!\n     *  Get the column for array right.\n     *\n     *    @return Array right column.\n     */\n    virtual int arrayRightColum() const override final;\n\n    /*!\n     *  Get the column for tags.\n     *\n     *    @return Tags column.\n     */\n    virtual int tagColumn() const override final;\n\n    /*!\n     *  Get the column for ad hoc visibility.\n     *\n     *    @return Ad hoc visibility column.\n     */\n    virtual int adHocColumn() const override final;\n\n    /*!\n     *  Get the column for description.\n     *\n     *    @return Description column.\n     */\n    virtual int descriptionColumn() const override final;\n\n    /*!\n     *  Check if the selected item is disabled.\n     *\n     *    @param [in] index           Index of the selected item.\n     *\n     *    @return True, if the indexed item is disabled, false otherwise.\n     */\n    virtual bool indexedItemIsDisabled(QModelIndex const& index) const override final;\n\n    /*!\n     *  Check if the selected item is mandatory.\n     *\n     *    @param [in] index   Index of the selected item.\n     *\n     *    @return True, if the indexed item is mandatory, false otherwise.\n     */\n    virtual bool indexedItemIsMandatory(QModelIndex const& index) const override final;\n\n    /*!\n     *  Check if the selected item is locked.\n     *\n     *    @param [in] index   Index of the selected item.\n     *\n     *    @return True, if the indexed item is locked, false otherwise.\n     */\n    virtual bool indexedItemIsLocked(QModelIndex const& index) const override final;\n\n    /*!\n     *  Get a list of the locked port indexes from the selected index.\n     *\n     *    @param [in] portIndex   Index of the selected item.\n     *\n     *    @return List of the locked port indexes.\n     */\n    virtual QModelIndexList getLockedPortIndexes(QModelIndex const& portIndex) const override final;\n\n    /*!\n     *  Add a new transactional port.\n     */\n    virtual void addNewPort() override final;\n};\n\n#endif // TRANSACTIONALPORTSMODEL_H\n"
  },
  {
    "path": "editors/ComponentEditor/ports/TypedPortEditor.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: WirePortEditor.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Esko Pekkarinen\n// Date: 23.11.2023\n//\n// Description:\n// Editor for wire/transactional/structured ports.\n//-----------------------------------------------------------------------------\n\n#include \"TypedPortEditor.h\"\n\n#include <KactusAPI/include/PortAbstractionInterface.h>\n#include <KactusAPI/include/BusInterfaceInterface.h>\n#include <KactusAPI/include/IPXactSystemVerilogParser.h>\n#include <KactusAPI/include/ComponentParameterFinder.h>\n#include <KactusAPI/include/PortsInterface.h>\n#include <editors/common/ExpressionSet.h>\n\n#include <common/dialogs/NewBusDialog/NewBusDialog.h>\n#include <common/widgets/summaryLabel/summarylabel.h>\n\n#include <KactusAPI/include/LibraryInterface.h>\n\n#include <wizards/BusInterfaceWizard/BusInterfaceWizard.h>\n\n#include <IPXACTmodels/AbstractionDefinition/AbstractionDefinition.h>\n#include <IPXACTmodels/Component/Component.h>\n#include <IPXACTmodels/Component/BusInterface.h>\n#include <IPXACTmodels/common/VLNV.h>\n\n#include <QVBoxLayout>\n\n//-----------------------------------------------------------------------------\n// Function: TypedPortEditor::TypedPortEditor()\n//-----------------------------------------------------------------------------\nTypedPortEditor::TypedPortEditor(QSharedPointer<Component> component, \n    LibraryInterface* handler,\n    PortsEditorFactory const* editorFactory,\n    QString const& portType,\n    QSharedPointer<PortsInterface> portsInterface,\n    BusInterfaceInterface* busInterface,\n    QWidget *parent):\nItemEditor(component, handler, parent),\n    busInterface_(busInterface),\n    portEditor_(component, handler, portsInterface, editorFactory, busInterface, this),\n    portType_(portType)\n{\n    connect(&portEditor_, SIGNAL(contentChanged()), this, SIGNAL(contentChanged()), Qt::UniqueConnection);\n    connect(&portEditor_, SIGNAL(errorMessage(const QString&)),\n        this, SIGNAL(errorMessage(const QString&)), Qt::UniqueConnection);\n    connect(&portEditor_, SIGNAL(noticeMessage(const QString&)),\n        this, SIGNAL(noticeMessage(const QString&)), Qt::UniqueConnection);\n\n    connect(&portEditor_, SIGNAL(createNewInteface(QStringList const&)),\n        this, SLOT(onCreateNewInteface(QStringList const&)), Qt::UniqueConnection);\n    connect(&portEditor_, SIGNAL(createInterface(QStringList const&)),\n        this, SLOT(onCreateInterface(QStringList const&)), Qt::UniqueConnection);\n\n    connect(&portEditor_, SIGNAL(increaseReferences(QString)),\n        this, SIGNAL(increaseReferences(QString)), Qt::UniqueConnection);\n    connect(&portEditor_, SIGNAL(decreaseReferences(QString)),\n        this, SIGNAL(decreaseReferences(QString)), Qt::UniqueConnection);\n\n    connect(&portEditor_, SIGNAL(changeExtensionsEditorItem(QModelIndex const&)),\n        this, SLOT(changeExtensionsEditorItem(QModelIndex const&)), Qt::UniqueConnection);\n\n    setupLayout();\n}\n\n//-----------------------------------------------------------------------------\n// Function: TypedPortEditor::isValid()\n//-----------------------------------------------------------------------------\nbool TypedPortEditor::isValid() const\n{\n    return portEditor_.isValid();\n}\n\n//-----------------------------------------------------------------------------\n// Function: TypedPortEditor::refresh()\n//-----------------------------------------------------------------------------\nvoid TypedPortEditor::refresh()\n{\n    portEditor_.refresh();\n    busInterface_->setBusInterfaces(component());\n}\n\n//-----------------------------------------------------------------------------\n// Function: TypedPortEditor::showEvent()\n//-----------------------------------------------------------------------------\nvoid TypedPortEditor::showEvent(QShowEvent* event)\n{\n    ItemEditor::showEvent(event);\n\n    emit helpUrlRequested(QString(\"componenteditor/%1Ports.html\").arg(portType_));\n}\n\n//-----------------------------------------------------------------------------\n// Function: TypedPortEditor::setAllowImportExport()\n//-----------------------------------------------------------------------------\nvoid TypedPortEditor::setAllowImportExport(bool allow)\n{\n    portEditor_.setAllowImportExport(allow);\n}\n\n//-----------------------------------------------------------------------------\n// Function: TypedPortEditor::onCreateNewInteface()\n//-----------------------------------------------------------------------------\nvoid TypedPortEditor::onCreateNewInteface(QStringList const& selectedPorts)\n{\n    // Ask user for new bus definition VLNV.\n    NewBusDialog dialog(handler(), this);\n    if (dialog.exec() == QDialog::Rejected)\n    {\n        return;\n    }\n\n    // create the vlnvs that identify the bus definition and abstraction definition\n    VLNV busVLNV = dialog.getVLNV();\n    busVLNV.setType(VLNV::BUSDEFINITION);\n    \n    // remove the possible .busDef from the end of the name field\n    VLNV absVLNV = busVLNV;\n    QString absDefName = busVLNV.getName();\n    absDefName = absDefName.remove(\".busDef\", Qt::CaseInsensitive);\n    absVLNV.setName(absDefName + \".absDef\");\n    absVLNV.setType(VLNV::ABSTRACTIONDEFINITION);\n\n    // by default the abs def and bus def are saved to same directory\n    QString absDirectory = dialog.getPath();\n\n    if (handler()->contains(absVLNV))\n    {\n        VLNV newAbsDefVLNV;\n\n        if (!NewObjectDialog::saveAsDialog(this, handler(), absVLNV, newAbsDefVLNV, absDirectory,\n            QStringLiteral(\"Set VLNV for abstraction definition\")))\n        {\n                return; // if user canceled\n        }\n        // save the created abstraction definition vlnv\n        absVLNV = newAbsDefVLNV;\n    }\n\n    // Create a bus definition.\n    QSharedPointer<BusDefinition> busDef(new BusDefinition(busVLNV, component()->getRevision()));\n\n    // Create the file for the bus definition.\n    if (!handler()->writeModelToFile(absDirectory, busDef))\n    {\n        emit errorMessage(tr(\"Could not write model to %1\").arg(absDirectory));\n        return;\n    }\n\n    // create an abstraction definition\n    QSharedPointer<AbstractionDefinition> absDef(new AbstractionDefinition(absVLNV, component()->getRevision()));\n    \n    // set reference from abstraction definition to bus definition\n    absDef->setBusType(busVLNV);\n\n    // create the file for the abstraction definition\n    if (!handler()->writeModelToFile(absDirectory, absDef))\n    {\n        emit errorMessage(tr(\"Could not write model to %1\").arg(absDirectory));\n        return;\n    }\n\n    // Create interface with unique name within the component.\n    QSharedPointer<BusInterface> busIf(new BusInterface());\n    QString ifName = busVLNV.getName();\n    int id = 1;\n    while(component()->hasInterface(ifName))\n    {\n        ifName = busVLNV.getName() + \"_\" + QString::number(id);\n        id++;\n    }\n\n    busIf->setName(ifName);\n    QSharedPointer<AbstractionType> abstractionVLNV(new AbstractionType());\n    abstractionVLNV->setAbstractionRef(QSharedPointer<ConfigurableVLNVReference>(\n        new ConfigurableVLNVReference(absVLNV)));\n    busIf->getAbstractionTypes()->append(abstractionVLNV);\n    busIf->setBusType(busVLNV);\n\n    // Open the bus interface wizard.\n    BusInterfaceWizard wizard(component(), busIf, handler(), selectedPorts, this, absVLNV,\n        dialog.getSignalSelection() == NewBusDialog::USE_DESCRIPTION);\n\n    openBusInterfaceWizard(busIf, wizard);\n}\n\n//-----------------------------------------------------------------------------\n// Function: TypedPortEditor::onCreateInterface()\n//-----------------------------------------------------------------------------\nvoid TypedPortEditor::onCreateInterface(QStringList const& selectedPorts)\n{\n    QSharedPointer<BusInterface> busIf(new BusInterface());\n    \n    // Open the bus interface wizard.\n    BusInterfaceWizard wizard(component(), busIf, handler(), selectedPorts, this);\n\n    openBusInterfaceWizard(busIf, wizard);\n}\n\n//-----------------------------------------------------------------------------\n// Function: TypedPortEditor::connectBusInterfaceWizard()\n//-----------------------------------------------------------------------------\nvoid TypedPortEditor::openBusInterfaceWizard(QSharedPointer<BusInterface> busIf, BusInterfaceWizard& wizard)\n{\n    component()->getBusInterfaces()->append(busIf);\n\n    connect(&wizard, SIGNAL(increaseReferences(QString)),\n        this, SIGNAL(increaseReferences(QString)), Qt::UniqueConnection);\n    connect(&wizard, SIGNAL(decreaseReferences(QString)),\n        this, SIGNAL(decreaseReferences(QString)), Qt::UniqueConnection);\n\n    if (wizard.exec() == QWizard::Accepted)\n    {\n        emit createInterface();\n        emit contentChanged();\n    }\n    else\n    {\n        component()->getBusInterfaces()->removeAll(busIf);\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: TypedPortEditor::changeExtensionsEditorItem()\n//-----------------------------------------------------------------------------\nvoid TypedPortEditor::changeExtensionsEditorItem(QModelIndex const& itemIndex)\n{\n    if (!itemIndex.isValid())\n    {\n        emit changeVendorExtensions(QStringLiteral(\"Component: \") + component()->getVlnv().toString(), component());\n    }\n    else if (QSharedPointer<Port> selectedPort = portEditor_.getIndexedPort(itemIndex))\n    {\n        emit changeVendorExtensions(QStringLiteral(\"Port: \") + selectedPort->name(), selectedPort);\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: TypedPortEditor::setupLayout()\n//-----------------------------------------------------------------------------\nvoid TypedPortEditor::setupLayout()\n{\n    QString labelText = portType_ + \" ports\";\n    labelText.replace(0, 1, portType_.front().toUpper());\n\n    auto layout = new QVBoxLayout(this);\n    layout->addWidget(new SummaryLabel(labelText, this), 0, Qt::AlignCenter);\n    layout->addWidget(&portEditor_);\n    layout->setContentsMargins(0, 0, 0, 0);\n}"
  },
  {
    "path": "editors/ComponentEditor/ports/TypedPortEditor.h",
    "content": "//-----------------------------------------------------------------------------\n// File: TypedPortEditor.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Esko Pekkarinen\n// Date: 23.11.2023\n//\n// Description:\n// Editor for wire/transactional/structured ports.\n//-----------------------------------------------------------------------------\n\n#ifndef TYPED_PORT_EDITOR_H\n#define TYPED_PORT_EDITOR_H\n\n#include <KactusAPI/include/ParameterFinder.h>\n#include <KactusAPI/include/ExpressionFormatter.h>\n\n#include <editors/ComponentEditor/itemeditor.h>\n#include <editors/common/ExpressionSet.h>\n#include <editors/ComponentEditor/ports/MasterPortsEditor.h>\n\n#include <QTabWidget>\n\nclass BusInterface;\nclass BusInterfaceWizard;\nclass Component;\nclass LibraryInterface;\nclass PortValidator;\nclass MasterPortsEditor;\nclass PortsInterface;\nclass BusInterfaceInterface;\nclass IPXactSystemVerilogParser;\nclass PortsEditorFactory;\n\n//-----------------------------------------------------------------------------\n//! Editor for wire/transactional/structured ports.\n//-----------------------------------------------------------------------------\nclass TypedPortEditor : public ItemEditor\n{\n\tQ_OBJECT\n\npublic:\n\n\t/*!\n\t *  The constructor.\n\t *\n\t *    @param [in] component               The component being edited.\n\t *    @param [in] handler                 The instance that manages the library.\n\t *    @param [in] editorFactory           The factory for creating editor content.\n     *    @param [in] portType                Type of the edited ports: wire/transactional/structured.\n     *    @param [in] portsInterface          Interface for accessing ports.\n     *    @param [in] busInterface            Interface for accessing bus interfaces.\n\t *    @param [in] parent                  The owner of this widget.\n\t */\n\tTypedPortEditor(QSharedPointer<Component> component,\n        LibraryInterface* handler,\n        PortsEditorFactory const* editorFactory,\n        QString const& portType,\n        QSharedPointer<PortsInterface> portsInterface,\n        BusInterfaceInterface* busInterface,\n        QWidget *parent = 0);\n\n\t/*!\n     *  The destructor.\n     */\n\t~TypedPortEditor() = default;\n\n\t/*!\n     *  Check for the validity of the edited ports.\n     *\n     *    @return True if all ports are in valid state.\n     */\n\tbool isValid() const;\n\n\t/*!\n     *  Reload the information from the model to the editor.\n\t */\n\tvoid refresh() final;\n\n\t/*!\n     *  Enable/disable the import/export csv functionality for the view.\n\t *\n\t *    @param [in] allow If true then import/export is enabled.\n\t */\n\tvoid setAllowImportExport(bool allow);\n\nsignals:\n\n    /*!\n     *  Emitted when a new interface should be added to the component editor tree view.\n     */\n    void createInterface();\n\nprotected:\n\n    /*!\n     *  Called when the editor is shown.\n     */\n    void showEvent(QShowEvent* event) final;\n\nprivate slots:\n\n    /*!\n     *  Handler for new interface creation for new bus definition.\n     *\n     *    @param [in] selectedPorts   Ports to be mapped in the interface.\n     */\n    void onCreateNewInteface(QStringList const& selectedPorts);\n\n    /*!\n     *  Handler for new interface creation for existing bus definition.\n     *\n     *    @param [in] selectedPorts   Ports to be mapped in the interface.\n     */\n    void onCreateInterface(QStringList const& selectedPorts);\n\n    /*!\n     *  Change the vendor extensions of the vendor extensions editor.\n     *\n     *    @param [in] itemIndex   Index of the selected port.\n     */\n    void changeExtensionsEditorItem(QModelIndex const& itemIndex);\n\n\nprivate:\n\n    /*!\n     *  Open the bus interface wizard.\n     *\n     *    @param [in] busIf   The new bus interface.\n     *    @param [in] wizard  The selected interface wizard.\n     */\n    void openBusInterfaceWizard(QSharedPointer<BusInterface> busIf, BusInterfaceWizard& wizard);\n\n    /*!\n     *  Setup the editor layout.\n     */\n    void setupLayout();\n\n\n    //-----------------------------------------------------------------------------\n    // Data.\n    //-----------------------------------------------------------------------------\n\n    //! Interface for accessing bus interfaces.\n    BusInterfaceInterface* busInterface_{ nullptr };\n\n    //! Editor for the ports.\n    MasterPortsEditor portEditor_;\n\n    //! Type of the edited ports: wire/transactional/structured.\n    QString portType_;\n};\n\n#endif // TYPED_PORT_EDITOR_H\n"
  },
  {
    "path": "editors/ComponentEditor/ports/TypedPortsView.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: TypedPortsView.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Anton Hagqvist\n// Date: 16.02.2024\n//\n// Description:\n// View for typed ports editors.\n//-----------------------------------------------------------------------------\n\n#include \"TypedPortsView.h\"\n\n#include <QApplication>\n#include <QClipboard>\n#include <QMimeData>\n\n//-----------------------------------------------------------------------------\n// Function: TypedPortsView::TypedPortsView()\n//-----------------------------------------------------------------------------\nTypedPortsView::TypedPortsView(int typeColumn, int nameColumn, BusInterfaceInterface* busInterface, QWidget* parent) :\n    PortsView(nameColumn, busInterface, parent),\n    typeColumn_(typeColumn)\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: TypedPortsView::onCopyAction()\n//-----------------------------------------------------------------------------\nvoid TypedPortsView::onCopyAction()\n{\n    if (!currentIndex().isValid() || currentIndex().column() != typeColumn_ ||\n        selectedIndexes().size() != 1)\n    {\n        PortsView::onCopyAction();\n        return;\n    }\n\n    QMimeData* mimeData = new QMimeData();\n    mimeData->setImageData(currentIndex().data(Qt::EditRole));\n\n    QApplication::clipboard()->setMimeData(mimeData);\n}\n\n//-----------------------------------------------------------------------------\n// Function: TypedPortsView::onPasteAction()\n//-----------------------------------------------------------------------------\nvoid TypedPortsView::onPasteAction()\n{\n    if (!currentIndex().isValid() || currentIndex().column() != typeColumn_ ||\n        selectedIndexes().size() != 1)\n    {\n        PortsView::onPasteAction();\n        return;\n    }\n\n    auto pasteData = QApplication::clipboard()->mimeData()->imageData();\n    model()->setData(currentIndex(), pasteData, Qt::EditRole);\n}\n"
  },
  {
    "path": "editors/ComponentEditor/ports/TypedPortsView.h",
    "content": "//-----------------------------------------------------------------------------\n// File: TypedPortsView.h\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Anton Hagqvist\n// Date: 16.02.2024\n//\n// Description:\n// View for typed ports editors.\n//-----------------------------------------------------------------------------\n\n#ifndef TYPEDPORTSVIEW_H\n#define TYPEDPORTSVIEW_H\n\n#include \"PortsView.h\"\n\nclass BusInterfaceInterface;\n\nclass TypedPortsView : public PortsView\n{\n    Q_OBJECT\npublic:\n\n    // Use base class constructor.\n    TypedPortsView(int typeColumn, int nameColumn, BusInterfaceInterface* busInterface, QWidget* parent);\n\n    virtual ~TypedPortsView() = default;\n\nprivate slots:\n\n    //! Handler for copy action.\n    virtual void onCopyAction() override;\n\n    //! Handler for paste action\n    virtual void onPasteAction() override;\n\nprivate:\n\n    //! The number of the column containing the type definitions information.\n    int typeColumn_;\n};\n\n#endif // TYPEDPORTSVIEW_H\n\n"
  },
  {
    "path": "editors/ComponentEditor/ports/WirePortColumns.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: WirePortColumns.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Esko Pekkarinen\r\n// Date: 26.01.2015\r\n//\r\n// Description:\r\n// Common declarations for editing wire ports.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef WIRE_PORT_COLUMNS_H\r\n#define WIRE_PORT_COLUMNS_H\r\n\r\nnamespace WirePortColumns\r\n{\r\n    //-----------------------------------------------------------------------------\r\n    // Constants defining which column represents what kind of information.\r\n    //-----------------------------------------------------------------------------\r\n    enum Columns\r\n    {\r\n        ROW_NUMBER = 0,     //!< Column for the row number.\r\n        NAME ,              //!< Column for the port name.\r\n        DIRECTION,          //!< Column for the port direction.\r\n        LEFT_BOUND,         //!< Column for specifying the left bound of the port.\r\n        RIGHT_BOUND,        //!< Column for specifying the right bound of the port.\r\n        WIDTH,              //!< Column for the port width.\r\n        TYPE_NAME,          //!< Column for the port typename.\r\n        DEFAULT_VALUE,      //!< Column for setting the default value for the port.\r\n        ARRAY_LEFT,         //!< Column for setting the left side of the array.\r\n        ARRAY_RIGHT,        //!< Column for setting the right side of the array.\r\n        TAG_GROUP,          //!< Column for tagging a port.\r\n        ADHOC_VISIBILITY,   //!< Column for toggling ad-hoc visibility on/off.\r\n        DESCRIPTION,        //!< Column for adding a description for the port.\r\n        COLUMN_COUNT\r\n    };\r\n}\r\n\r\n#endif // WIRE_PORT_COLUMNS_H"
  },
  {
    "path": "editors/ComponentEditor/ports/WirePortsDelegate.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: WirePortsDelegate.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 09.05.2019\n//\n// Description:\n// The delegate that provides editors to edit wire ports of a component.\n//-----------------------------------------------------------------------------\n\n#include \"WirePortsDelegate.h\"\n\n#include <editors/ComponentEditor/ports/WirePortColumns.h>\n#include <editors/ComponentEditor/ports/PortWireTypeEditor.h>\n\n#include <QComboBox>\n\n//-----------------------------------------------------------------------------\n// Function: WirePortsDelegate::WirePortsDelegate()\n//-----------------------------------------------------------------------------\nWirePortsDelegate::WirePortsDelegate(QSharedPointer<Component> component, QAbstractItemModel* completionModel,\n    QSharedPointer<ParameterFinder> parameterFinder, QSharedPointer<PortTypeValidator> typeValidator,\n    QObject* parent):\nPortsDelegate(component, completionModel, parameterFinder, typeValidator, parent)\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: WirePortsDelegate::createEditor()\n//-----------------------------------------------------------------------------\nQWidget* WirePortsDelegate::createEditor(QWidget* parent, QStyleOptionViewItem const& option, \n    QModelIndex const& index) const\n{\n    if (index.column() == WirePortColumns::DIRECTION)\n    {\n        return createSelectorForDirection(parent);\n    }\n    else\n    {\n        return PortsDelegate::createEditor(parent, option, index);\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: WirePortsDelegate::setEditorData()\n//-----------------------------------------------------------------------------\nvoid WirePortsDelegate::setEditorData(QWidget* editor, QModelIndex const& index) const\n{\n    if (index.column() == WirePortColumns::DIRECTION)\n    {\n        QString text = index.data(Qt::DisplayRole).toString();\n        QComboBox* combo = qobject_cast<QComboBox*>(editor);\n\n        int comboIndex = combo->findText(text);\n        combo->setCurrentIndex(comboIndex);\n    }\n    else\n    {\n        PortsDelegate::setEditorData(editor, index);\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: WirePortsDelegate::setModelData()\n//-----------------------------------------------------------------------------\nvoid WirePortsDelegate::setModelData(QWidget* editor, QAbstractItemModel* model, QModelIndex const& index ) const\n{\n    if (index.column() == WirePortColumns::DIRECTION)\n    {\n        QComboBox* combo = qobject_cast<QComboBox*>(editor);\n        QString text = combo->currentText();\n        model->setData(index, text, Qt::EditRole);\n    }\n    else\n    {\n        PortsDelegate::setModelData(editor, model, index);\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: WirePortsDelegate::columnAcceptsExpression()\n//-----------------------------------------------------------------------------\nbool WirePortsDelegate::columnAcceptsExpression(int column) const\n{\n    return PortsDelegate::columnAcceptsExpression(column) || column == WirePortColumns::DEFAULT_VALUE ||\n        column == WirePortColumns::LEFT_BOUND || column == WirePortColumns::RIGHT_BOUND;\n}\n\n//-----------------------------------------------------------------------------\n// Function: WirePortsDelegate::descriptionColumn()\n//-----------------------------------------------------------------------------\nint WirePortsDelegate::descriptionColumn() const\n{\n    return WirePortColumns::DESCRIPTION;\n}\n\n//-----------------------------------------------------------------------------\n// Function: WirePortsDelegate::nameColumn()\n//-----------------------------------------------------------------------------\nint WirePortsDelegate::nameColumn() const\n{\n    return WirePortColumns::NAME;\n}\n\n//-----------------------------------------------------------------------------\n// Function: WirePortsDelegate::typeColumn()\n//-----------------------------------------------------------------------------\nint WirePortsDelegate::typeColumn() const\n{\n    return WirePortColumns::TYPE_NAME;\n}\n\n//-----------------------------------------------------------------------------\n// Function: WirePortsDelegate::tagColumn()\n//-----------------------------------------------------------------------------\nint WirePortsDelegate::tagColumn() const\n{\n    return WirePortColumns::TAG_GROUP;\n}\n\n//-----------------------------------------------------------------------------\n// Function: WirePortsDelegate::adHocColumn()\n//-----------------------------------------------------------------------------\nint WirePortsDelegate::adHocColumn() const\n{\n    return WirePortColumns::ADHOC_VISIBILITY;\n}\n\n//-----------------------------------------------------------------------------\n// Function: WirePortsDelegate::arrayLeftColumn()\n//-----------------------------------------------------------------------------\nint WirePortsDelegate::arrayLeftColumn() const\n{\n    return WirePortColumns::ARRAY_LEFT;\n}\n\n//-----------------------------------------------------------------------------\n// Function: WirePortsDelegate::arrayRightColumn()\n//-----------------------------------------------------------------------------\nint WirePortsDelegate::arrayRightColumn() const\n{\n    return WirePortColumns::ARRAY_RIGHT;\n}\n\n//-----------------------------------------------------------------------------\n// Function: WirePortsDelegate::createSelectorForDirection()\n//-----------------------------------------------------------------------------\nQWidget* WirePortsDelegate::createSelectorForDirection(QWidget* parent) const\n{\n    QComboBox* directionSelector = new QComboBox(parent);\n    directionSelector->addItem(\"in\");\n    directionSelector->addItem(\"out\");\n    directionSelector->addItem(\"inout\");\n    directionSelector->addItem(\"phantom\");\n\n    return directionSelector;\n}\n"
  },
  {
    "path": "editors/ComponentEditor/ports/WirePortsDelegate.h",
    "content": "//-----------------------------------------------------------------------------\n// File: WirePortsDelegate.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 09.05.2019\n//\n// Description:\n// The delegate that provides editors to edit wire ports of a component.\n//-----------------------------------------------------------------------------\n\n#ifndef WIREPORTSDELEGATE_H\n#define WIREPORTSDELEGATE_H\n\n#include <editors/ComponentEditor/ports/portsdelegate.h>\n\n#include <QCompleter>\n\nclass ParameterFinder;\nclass Component;\nclass PortTypeValidator;\n\n//-----------------------------------------------------------------------------\n//! The delegate that provides editors to edit wire ports of a component.\n//-----------------------------------------------------------------------------\nclass WirePortsDelegate : public PortsDelegate\n{\n\tQ_OBJECT\n\npublic:\n\n    /*!\n     *  The constructor.\n     *\n     *    @param [in] component           Component containing the edited ports.\n     *    @param [in] completionModel     Model containing the completions used in expression editor.\n     *    @param [in] parameterFinder     The parameter finder to use for for expression editor.\n     *    @param [in] typeValidator       Validator for port type definitions.\n     *    @param [in] parent              The parent object.\n     */\n\tWirePortsDelegate(QSharedPointer<Component> component, QAbstractItemModel* completionModel,\n        QSharedPointer<ParameterFinder> parameterFinder, QSharedPointer<PortTypeValidator> typeValidator,\n        QObject* parent = 0);\n\t\n\t/*!\n     *  The destructor.\n     */\n    virtual ~WirePortsDelegate() = default;\n\n\t/*!\n     *  Create a new editor for the given item.\n\t *\n\t *    @param [in] parent  Owner for the editor.\n\t *    @param [in] option  Contains options for the editor.\n\t *    @param [in] index   Model index identifying the item.\n\t *\n\t *    @return The editor to be used to edit the item.\n     */\n\tvirtual QWidget* createEditor(QWidget* parent, QStyleOptionViewItem const& option, QModelIndex const& index)\n        const;\n\n\t/*!\n     *  Set the data for the editor.\n\t *\n\t *    @param [in] editor  The editor where the data is to be set.\n\t *    @param [in] index   Model index identifying the item that's data is to be set.\n     */\n\tvirtual void setEditorData(QWidget* editor, QModelIndex const& index) const;\n\n\t/*!\n     *  Save the data from the editor to the model.\n\t *\n\t *    @param [in] editor  The editor that contains the data to store.\n\t *    @param [in] model   Model that contains the data structure where data is to be saved to.\n     *    @param [in] index   sModel index identifying the item that's data is to be saved.\n     */\n\tvirtual void setModelData(QWidget* editor, QAbstractItemModel* model, QModelIndex const& index) const;\n\n    // Disable copying.\n    WirePortsDelegate(WirePortsDelegate const& rhs) = delete;\n    WirePortsDelegate& operator=(WirePortsDelegate const& rhs) = delete;\n\nprotected:\n    \n    /*!\n     *  Checks if the given column supports expressions in the editor.\n     *\n     *    @param [in] column   The column to check.\n     *\n     *    @return True, if the cells in the column allow expressions, otherwise false.\n     */\n    virtual bool columnAcceptsExpression(int column) const;\n\n    /*!\n     *  Gets the description column.\n     *\n     *    @return Column number for description.\n     */\n    virtual int descriptionColumn() const;\n\nprivate:\n\n    /*!\n     *  Gets the name column.\n     *\n     *    @return Column number for name.\n     */\n    virtual int nameColumn() const;\n\n    /*!\n     *  Gets the type definitions column.\n     *\n     *    @return Column number for type definitions.\n     */\n    virtual int typeColumn() const;\n\n    /*!\n     *  Gets the tag group column.\n     *\n     *    @return Column number for tag group.\n     */\n    virtual int tagColumn() const;\n\n    /*!\n     *  Gets the ad hoc column.\n     *\n     *    @return Column number for ad hoc.\n     */\n    virtual int adHocColumn() const;\n\n    /*!\n     *  Gets the array left column.\n     *\n     *    @return Column number for left value of the array.\n     */\n    virtual int arrayLeftColumn() const;\n\n    /*!\n     *  Gets the array right column.\n     *\n     *    @return Column number for right value of the array.\n     */\n    virtual int arrayRightColumn() const;\n\n    /*!\n     *  Creates a selector for port direction.\n     *\n     *    @param [in] parent   The parent widget for the selector.\n     *\n     *    @return The selector for port direction.\n     */\n     QWidget* createSelectorForDirection(QWidget* parent) const;\n};\n\n#endif // WIREPORTSDELEGATE_H\n"
  },
  {
    "path": "editors/ComponentEditor/ports/WirePortsEditorFactory.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: WirePortsEditorFactory.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 29.04.2019\n//\n// Description:\n// Constructs wire ports editor items.\n//-----------------------------------------------------------------------------\n\n#include \"WirePortsEditorFactory.h\"\n\n#include <editors/ComponentEditor/ports/TypedPortsView.h>\n#include <editors/ComponentEditor/ports/WirePortsModel.h>\n#include <editors/ComponentEditor/ports/WirePortColumns.h>\n#include <editors/ComponentEditor/ports/WirePortsFilter.h>\n#include <editors/ComponentEditor/ports/WirePortsDelegate.h>\n#include <editors/ComponentEditor/parameters/ComponentParameterModel.h>\n\n#include <IPXACTmodels/Component/Component.h>\n#include <IPXACTmodels/Component/validators/PortValidator.h>\n\n#include <QCompleter>\n#include <QVBoxLayout>\n\n//-----------------------------------------------------------------------------\n// Function: WirePortsEditorFactory::constructModel()\n//-----------------------------------------------------------------------------\nPortsModel* WirePortsEditorFactory::createModel(QObject* parent) const\n{\n    return new WirePortsModel(expressions_.finder, portsInterface_, signalInterface_, parent);\n}\n\n//-----------------------------------------------------------------------------\n// Function: WirePortsEditorFactory::constructFilter()\n//-----------------------------------------------------------------------------\nPortsFilter* WirePortsEditorFactory::createFilter(QObject* parent) const\n{\n    return new WirePortsFilter(portsInterface_, parent);\n}\n\n//-----------------------------------------------------------------------------\n// Function: WirePortsEditorFactory::constructView()\n//-----------------------------------------------------------------------------\nPortsView* WirePortsEditorFactory::createView(QWidget* parent) const\n{\n    auto view = new TypedPortsView(WirePortColumns::TYPE_NAME, WirePortColumns::NAME, busInterface_, parent);\n\n    view->setDefaultImportExportPath(defaultPath_);\n    view->setAllowImportExport(true);\n    view->setAlternatingRowColors(false);\n    view->setSortingEnabled(true);\n    view->setItemsDraggable(false);\n    view->setFitColumnsToContent(false);\n\n    return view;\n}\n\n//-----------------------------------------------------------------------------\n// Function: WirePortsEditorFactory::createDelegate()\n//-----------------------------------------------------------------------------\nPortsDelegate* WirePortsEditorFactory::createDelegate(QObject* parent) const\n{\n    auto componentParametersModel = new ComponentParameterModel(expressions_.finder, parent);\n    componentParametersModel->setExpressionParser(expressions_.parser);\n\n    return new WirePortsDelegate(component_, componentParametersModel, expressions_.finder, \n        portValidator_->getTypeValidator(), parent);\n}\n"
  },
  {
    "path": "editors/ComponentEditor/ports/WirePortsEditorFactory.h",
    "content": "//-----------------------------------------------------------------------------\n// File: WirePortsEditorFactory.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 29.04.2019\n//\n// Description:\n// Constructs wire ports editor items.\n//-----------------------------------------------------------------------------\n\n#ifndef WIREPORTSEDITORCONSTRUCTOR_H\n#define WIREPORTSEDITORCONSTRUCTOR_H\n\n#include <editors/ComponentEditor/ports/PortsEditorFactory.h>\n\n#include <QSortFilterProxyModel>\n#include <QSharedPointer>\n#include <QWidget>\n#include <QAbstractItemModel>\n\nclass Component;\nclass PortsModel;\nclass PortsView;\nclass PortValidator;\nclass PortsDelegate;\nclass ExpressionParser;\nclass PortsInterface;\n\n//-----------------------------------------------------------------------------\n//! Constructs wire ports editor items.\n//-----------------------------------------------------------------------------\nclass WirePortsEditorFactory : public PortsEditorFactory\n{\npublic:\n\n    using PortsEditorFactory::PortsEditorFactory;\n\n    /*!\n     *  The destructor.\n     */\n    ~WirePortsEditorFactory() = default;\n\n    /*!\n     *  Construct a ports model.\n     *\n     *    @param [in] parent              The owner of the constructed model.\n     *\n     *    @return The created ports model.\n     */\n    PortsModel* createModel(QObject* parent = 0) const final;\n\n    /*!\n     *  Construct a filter.\n     *\n     *    @param [in] parent          Owner of the filter.\n     *\n     *    @return The created ports filter.\n     */\n    PortsFilter* createFilter(QObject* parent) const final;\n\n    /*!\n     *  Construct a view.\n     *\n     *    @param [in] parent          Owner of the view.\n     *\n     *    @return The created view.\n     */\n    PortsView* createView(QWidget* parent) const final;\n\n    /*!\n     *  Construct a delegate.\n     *\n     *    @param [in] parent              The owner of the delegate.\n     *\n     *    @return The created delegate.\n     */\n    PortsDelegate* createDelegate(QObject* parent) const  final;\n};\n\n#endif // WIREPORTSEDITORCONSTRUCTOR_H\n"
  },
  {
    "path": "editors/ComponentEditor/ports/WirePortsFilter.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: WirePortsFilter.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 08.05.2019\n//\n// Description:\n// Sorting proxy model for wire ports.\n//-----------------------------------------------------------------------------\n\n#include \"WirePortsFilter.h\"\n\n#include <IPXACTmodels/Component/Port.h>\n\n#include <editors/ComponentEditor/ports/WirePortColumns.h>\n#include <KactusAPI/include/PortsInterface.h>\n\n//-----------------------------------------------------------------------------\n// Function: WirePortsFilter::WirePortsFilter()\n//-----------------------------------------------------------------------------\nWirePortsFilter::WirePortsFilter(QSharedPointer<PortsInterface> portInterface, QObject* parent):\nPortsFilter(portInterface, parent)\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: WirePortsFilter::nameColumn()\n//-----------------------------------------------------------------------------\nint WirePortsFilter::nameColumn() const\n{\n    return WirePortColumns::NAME;\n}\n\n//-----------------------------------------------------------------------------\n// Function: WirePortsFilter::portIsAccepted()\n//-----------------------------------------------------------------------------\nbool WirePortsFilter::portIsAccepted(QString const& portName) const\n{\n    return getInterface()->portIsWire(portName.toStdString());\n}\n"
  },
  {
    "path": "editors/ComponentEditor/ports/WirePortsFilter.h",
    "content": "//-----------------------------------------------------------------------------\n// File: WirePortsFilter.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 08.05.2019\n//\n// Description:\n// Sorting proxy model for wire ports.\n//-----------------------------------------------------------------------------\n\n#ifndef WIREPORTSFILTER_H\n#define WIREPORTSFILTER_H\n\n#include <editors/ComponentEditor/ports/PortsFilter.h>\n\n//-----------------------------------------------------------------------------\n//! Sorting proxy model for wire ports.\n//-----------------------------------------------------------------------------\nclass WirePortsFilter : public PortsFilter\n{\n    Q_OBJECT\n\npublic:\n\n\t /*!\n      *  Constructor.\n      *\n      *    @param [in] portsInterface     Interface for accessing the component ports.\n      *    @param [in] parent             The parent object.\n      */\n    WirePortsFilter(QSharedPointer<PortsInterface> portInterface, QObject* parent = 0);\n\n\t /*!\n      *  Destructor.\n      */\n    virtual ~WirePortsFilter() = default;\n\n    // No copying. No assignments.\n    WirePortsFilter(WirePortsFilter const& rhs) = delete;\n    WirePortsFilter& operator=(WirePortsFilter const& rhs) = delete;\n\nprivate:\n\n    /*!\n     *  Get the index of the name column.\n     *\n     *    @return Index of the name column.\n     */\n    virtual int nameColumn() const override final;\n\n    /*!\n     *  Check if a port is filtered.\n     *\n     *    @param [in] portName    Name of the selected port.\n     *\n     *    @return True, if the port is accepted, false otherwise.\n     */\n    virtual bool portIsAccepted(QString const& portName) const override final;\n};\n\n#endif // WIREPORTSFILTER_H"
  },
  {
    "path": "editors/ComponentEditor/ports/WirePortsModel.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: WirePortsModel.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 06.05.2019\n//\n// Description:\n// Table model for wire ports.\n//-----------------------------------------------------------------------------\n\n#include \"WirePortsModel.h\"\n\n#include <KactusAPI/include/PortsInterface.h>\n#include <editors/ComponentEditor/ports/WirePortColumns.h>\n\n#include <IPXACTmodels/common/DirectionTypes.h>\n\n#include <QIcon>\n\nusing namespace std;\n\n//-----------------------------------------------------------------------------\n// Function: WirePortsModel::WirePortsModel()\n//-----------------------------------------------------------------------------\nWirePortsModel::WirePortsModel(QSharedPointer<ParameterFinder> parameterFinder,\n    QSharedPointer<PortsInterface> portsInterface, QSharedPointer<PortAbstractionInterface> signalInterface,\n    QObject *parent):\nPortsModel(parameterFinder, portsInterface, signalInterface, parent)\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: WirePortsModel::columnCount()\n//-----------------------------------------------------------------------------\nint WirePortsModel::columnCount(QModelIndex const& parent) const\n{\n\tif (parent.isValid())\n    {\n\t\treturn 0;\n    }\n\n \treturn WirePortColumns::COLUMN_COUNT;\n}\n\n//-----------------------------------------------------------------------------\n// Function: WirePortsModel::headerData()\n//-----------------------------------------------------------------------------\nQVariant WirePortsModel::headerData(int section, Qt::Orientation orientation, int role) const\n{\n    if (role == Qt::DisplayRole && orientation == Qt::Horizontal)\n    {\n        if (section == WirePortColumns::DIRECTION)\n        {\n            return tr(\"Direction\");\n        }\n        else if (section == WirePortColumns::WIDTH)\n        {\n            return tr(\"Width\");\n        }\n        else if (section == WirePortColumns::LEFT_BOUND)\n        {\n            QString leftBoundHeader = tr(\"Left (higher)\\nbound\") + getExpressionSymbol();\n            return leftBoundHeader;\n        }\n        else if (section == WirePortColumns::RIGHT_BOUND)\n        {\n            QString rightBoundHeader = tr(\"Right (lower)\\nbound\") + getExpressionSymbol();\n            return rightBoundHeader;\n        }\n        else if (section == WirePortColumns::DEFAULT_VALUE)\n        {\n            QString defaultHeader = tr(\"Default\\nvalue\") + getExpressionSymbol();\n            return defaultHeader;\n        }\n    }\n\n    return PortsModel::headerData(section, orientation, role);\n}\n\n//-----------------------------------------------------------------------------\n// Function: WirePortsModel::data()\n//-----------------------------------------------------------------------------\nQVariant WirePortsModel::data(QModelIndex const& index, int role) const\n{\n    if (!index.isValid() || index.row() < 0 || index.row() >= getInterface()->itemCount())\n    {\n        return QVariant();\n    }\n\n    if (role == Qt::DecorationRole && index.column() == WirePortColumns::DIRECTION)\n    {\n        return QIcon(getIconPath(index.row()));\n    }\n    \n    return PortsModel::data(index, role);\n}\n\n//-----------------------------------------------------------------------------\n// Function: WirePortsModel::setData()\n//-----------------------------------------------------------------------------\nbool WirePortsModel::setData(QModelIndex const& index, QVariant const& value, int role)\n{\n    if (PortsModel::setData(index, value, role))\n    {\n        return true;\n    }\n    else if (!index.isValid() || index.row() < 0 || index.row() >= rowCount())\n    {\n\t\treturn false;\n    }\n\n    std::string portName = getInterface()->getIndexedItemName(index.row());\n\n\tif (role == Qt::EditRole)\n    {\n        if (isLocked(index))\n        {\n            return false;\n        }\n\n        else if (index.column() == WirePortColumns::DIRECTION)\n        {\n            getInterface()->setDirection(portName, value.toString().toStdString());\n        }\n        else if (index.column() == WirePortColumns::WIDTH)\n        {\n            bool success = getInterface()->setWidth(portName, value.toString().toStdString());\n            if (success == false)\n            {\n                return false;\n            }\n        }\n        else if (index.column() == WirePortColumns::LEFT_BOUND)\n        {\n            if (!value.isValid())\n            {\n                removeReferencesFromSingleExpression(\n                    QString::fromStdString(getInterface()->getLeftBoundExpression(portName)));\n            }\n\n            getInterface()->setLeftBound(portName, value.toString().toStdString());\n\n        }\n        else if (index.column() == WirePortColumns::RIGHT_BOUND)\n        {\n            if (!value.isValid())\n            {\n                removeReferencesFromSingleExpression(\n                    QString::fromStdString(getInterface()->getRightBoundExpression(portName)));\n            }\n\n            getInterface()->setRightBound(portName, value.toString().toStdString());\n        }\n        else if (index.column() == WirePortColumns::DEFAULT_VALUE)\n        {\n            if (!value.isValid())\n            {\n                removeReferencesFromSingleExpression(\n                    QString::fromStdString(getInterface()->getDefaultValueExpression(portName)));\n            }\n\n            getInterface()->setDefaultValue(portName, value.toString().toStdString());\n        }\n        else\n        {\n            return false;\n        }\n\n        emit dataChanged(index, index);\n        return true;\n    }\n    // unsupported role\n    else\n    {\n        return false;\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: WirePortsModel::valueForIndex()\n//-----------------------------------------------------------------------------\nQVariant WirePortsModel::valueForIndex(QModelIndex const& index) const\n{\n    string portName = getInterface()->getIndexedItemName(index.row());\n    if (index.column() == WirePortColumns::DIRECTION)\n    {\n        return QString::fromStdString(getInterface()->getDirection(portName));\n    }\n    else if (index.column() == WirePortColumns::WIDTH)\n    {\n        return QString::fromStdString(getInterface()->getWidth(portName));\n    }\n    else if (index.column() == WirePortColumns::LEFT_BOUND)\n    {\n        return QString::fromStdString(getInterface()->getLeftBoundValue(portName));\n    }\n    else if (index.column() == WirePortColumns::RIGHT_BOUND)\n    {\n        return QString::fromStdString(getInterface()->getRightBoundValue(portName));\n    }\n    else if (index.column() == WirePortColumns::DEFAULT_VALUE)\n    {\n        return QString::fromStdString(getInterface()->getDefaultValue(portName));\n    }\n    \n    return PortsModel::valueForIndex(index);\n}\n\n//-----------------------------------------------------------------------------\n// Function: WirePortsModel::isValidExpressionColumn()\n//-----------------------------------------------------------------------------\nbool WirePortsModel::isValidExpressionColumn(QModelIndex const& index) const\n{\n    return index.column() == WirePortColumns::LEFT_BOUND || index.column() == WirePortColumns::RIGHT_BOUND ||\n        index.column() == WirePortColumns::DEFAULT_VALUE || index.column() == WirePortColumns::ARRAY_LEFT ||\n        index.column() == WirePortColumns::ARRAY_RIGHT;\n}\n\n//-----------------------------------------------------------------------------\n// Function: WirePortsModel::isPortTypeColumn()\n//-----------------------------------------------------------------------------\nbool WirePortsModel::isPortTypeColumn(QModelIndex const& index) const\n{\n    return index.column() == WirePortColumns::TYPE_NAME;\n}\n\n//-----------------------------------------------------------------------------\n// Function: WirePortsModel::formattedExpressionForIndex()\n//-----------------------------------------------------------------------------\nQVariant WirePortsModel::formattedExpressionForIndex(QModelIndex const& index) const\n{\n    string portName = getInterface()->getIndexedItemName(index.row());\n\n    if (index.column() == WirePortColumns::LEFT_BOUND)\n    {\n        return QString::fromStdString(getInterface()->getLeftBoundFormattedExpression(portName));\n    }\n    else if (index.column() == WirePortColumns::RIGHT_BOUND)\n    {\n        return QString::fromStdString(getInterface()->getRightBoundFormattedExpression(portName));\n    }\n    else if (index.column() == WirePortColumns::DEFAULT_VALUE)\n    {\n        return QString::fromStdString(getInterface()->getDefaultValueFormattedExpression(portName));\n    }\n    else\n    {\n        return PortsModel::formattedExpressionForIndex(index);\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: WirePortsModel::expressionForIndex()\n//-----------------------------------------------------------------------------\nQVariant WirePortsModel::expressionForIndex(QModelIndex const& index) const\n{\n    std::string portName = getInterface()->getIndexedItemName(index.row());\n\n    if (index.column() == WirePortColumns::LEFT_BOUND)\n    {\n        return QString::fromStdString(getInterface()->getLeftBoundExpression(portName));\n    }\n    else if (index.column() == WirePortColumns::RIGHT_BOUND)\n    {\n        return QString::fromStdString(getInterface()->getRightBoundExpression(portName));\n    }\n    else if (index.column() == WirePortColumns::DEFAULT_VALUE)\n    {\n        return QString::fromStdString(getInterface()->getDefaultValueExpression(portName));\n    }\n    else\n    {\n        return PortsModel::expressionForIndex(index);\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: WirePortsModel::expressionOrValueForIndex()\n//-----------------------------------------------------------------------------\nQVariant WirePortsModel::expressionOrValueForIndex(QModelIndex const& index) const\n{\n    if (isValidExpressionColumn(index))\n    {\n        return expressionForIndex(index);\n    }\n    else\n    {\n        return valueForIndex(index);\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: WirePortsModel::validateIndex()\n//-----------------------------------------------------------------------------\nbool WirePortsModel::validateIndex(QModelIndex const& index) const\n{\n    std::string portName = getInterface()->getIndexedItemName(index.row());\n\n    if (index.column() == WirePortColumns::LEFT_BOUND)\n    {\n        return getInterface()->portHasValidLeftBound(portName);\n    }\n    else if (index.column() == WirePortColumns::RIGHT_BOUND)\n\t{\n        return getInterface()->portHasValidRightBound(portName);\n    }\n    else if (index.column() == WirePortColumns::DEFAULT_VALUE)\n    {\n        return getInterface()->portHasValidDefaultValue(portName);\n    }\n    else\n    {\n        return PortsModel::validateIndex(index);\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: WirePortsModel::rowNumberColumn()\n//-----------------------------------------------------------------------------\nint WirePortsModel::rowNumberColumn() const\n{\n    return WirePortColumns::ROW_NUMBER;\n}\n\n//-----------------------------------------------------------------------------\n// Function: WirePortsModel::nameColumn()\n//-----------------------------------------------------------------------------\nint WirePortsModel::nameColumn() const\n{\n    return WirePortColumns::NAME;\n}\n\n//-----------------------------------------------------------------------------\n// Function: WirePortsModel::typeColumn()\n//-----------------------------------------------------------------------------\nint WirePortsModel::typeColumn() const\n{\n    return WirePortColumns::TYPE_NAME;\n}\n\n//-----------------------------------------------------------------------------\n// Function: WirePortsModel::arrayLeftColumn()\n//-----------------------------------------------------------------------------\nint WirePortsModel::arrayLeftColumn() const\n{\n    return WirePortColumns::ARRAY_LEFT;\n}\n\n//-----------------------------------------------------------------------------\n// Function: WirePortsModel::arrayRightColum()\n//-----------------------------------------------------------------------------\nint WirePortsModel::arrayRightColum() const\n{\n    return WirePortColumns::ARRAY_RIGHT;\n}\n\n//-----------------------------------------------------------------------------\n// Function: WirePortsModel::tagColumn()\n//-----------------------------------------------------------------------------\nint WirePortsModel::tagColumn() const\n{\n    return WirePortColumns::TAG_GROUP;\n}\n\n//-----------------------------------------------------------------------------\n// Function: WirePortsModel::adHocColumn()\n//-----------------------------------------------------------------------------\nint WirePortsModel::adHocColumn() const\n{\n    return WirePortColumns::ADHOC_VISIBILITY;\n}\n\n//-----------------------------------------------------------------------------\n// Function: WirePortsModel::descriptionColumn()\n//-----------------------------------------------------------------------------\nint WirePortsModel::descriptionColumn() const\n{\n    return WirePortColumns::DESCRIPTION;\n}\n\n//-----------------------------------------------------------------------------\n// Function: WirePortsModel::indexedItemIsDisabled()\n//-----------------------------------------------------------------------------\nbool WirePortsModel::indexedItemIsDisabled(QModelIndex const& index) const\n{\n    std::string portName = getInterface()->getIndexedItemName(index.row());\n\n    return (index.column() == WirePortColumns::ROW_NUMBER ||\n        (index.column() == WirePortColumns::DEFAULT_VALUE &&\n        (DirectionTypes::str2Direction(getInterface()->getDirection(portName)) != DirectionTypes::IN && \n            DirectionTypes::str2Direction(getInterface()->getDirection(portName)) != DirectionTypes::INOUT)) ||\n        (index.column() == WirePortColumns::WIDTH && getInterface()->hasExpressionInLeftOrRightBound(portName)));\n}\n\n//-----------------------------------------------------------------------------\n// Function: WirePortsModel::indexedItemIsMandatory()\n//-----------------------------------------------------------------------------\nbool WirePortsModel::indexedItemIsMandatory(QModelIndex const& index) const\n{\n    return index.column() == WirePortColumns::NAME || index.column() == WirePortColumns::DIRECTION ||\n        index.column() == WirePortColumns::WIDTH;\n}\n\n//-----------------------------------------------------------------------------\n// Function: WirePortsModel::indexedItemIsLocked()\n//-----------------------------------------------------------------------------\nbool WirePortsModel::indexedItemIsLocked(QModelIndex const& index) const\n{\n    return index.column() == WirePortColumns::WIDTH &&\n        getInterface()->hasExpressionInLeftOrRightBound(getInterface()->getIndexedItemName(index.row()));\n}\n\n//-----------------------------------------------------------------------------\n// Function: WirePortsModel::getLockedPortIndexes()\n//-----------------------------------------------------------------------------\nQModelIndexList WirePortsModel::getLockedPortIndexes(QModelIndex const& portIndex) const\n{\n    QModelIndexList lockedIndexes;\n\n    QModelIndex nameIndex = portIndex.sibling(portIndex.row(), WirePortColumns::NAME);\n    QModelIndex directionIndex = portIndex.sibling(portIndex.row(), WirePortColumns::DIRECTION);\n    QModelIndex typeIndex = portIndex.sibling(portIndex.row(), WirePortColumns::TYPE_NAME);\n\n    lockedIndexes.append(nameIndex);\n    lockedIndexes.append(directionIndex);\n    lockedIndexes.append(typeIndex);\n\n    return lockedIndexes;\n}\n\n//-----------------------------------------------------------------------------\n// Function: WirePortsModel::addNewPort()\n//-----------------------------------------------------------------------------\nvoid WirePortsModel::addNewPort()\n{\n    getInterface()->addWirePort();\n}\n"
  },
  {
    "path": "editors/ComponentEditor/ports/WirePortsModel.h",
    "content": "//-----------------------------------------------------------------------------\n// File: WirePortsModel.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 06.05.2019\n//\n// Description:\n// Table model for wire ports.\n//-----------------------------------------------------------------------------\n\n#ifndef WIREPORTSMODEL_H\n#define WIREPORTSMODEL_H\n\n#include <editors/ComponentEditor/ports/portsmodel.h>\n\n//-----------------------------------------------------------------------------\n//! Table model for wire ports.\n//-----------------------------------------------------------------------------\nclass WirePortsModel : public PortsModel\n{\n\tQ_OBJECT\n\npublic:\n\n    /*!\n     *  The constructor.\n     *\n     *    @param [in] parameterFinder     Pointer to the parameter finder.\n     *    @param [in] portsInterface      Interface for accessing the component ports.\n     *    @param [in] signalInterface     Interface for accessing abstraction signals.\n     *    @param [in] parent              Pointer to the owner of this model.\n     */\n    WirePortsModel(QSharedPointer <ParameterFinder> parameterFinder,\n        QSharedPointer<PortsInterface> portsInterface,\n        QSharedPointer<PortAbstractionInterface> signalInterface,\n        QObject *parent);\n\n\t/*!\n     *  The destructor.\n     */\n    virtual ~WirePortsModel() = default;\n\n\t/*!\n     *  Get the number of columns in the model.\n\t *\n\t *    @param [in] parent      Model index of the parent of the item. Must be invalid\n     *\n\t *    @return Always returns 9.\n     */\n\tvirtual int columnCount(const QModelIndex& parent = QModelIndex() ) const;\n\n    /*!\n     *  Get the data for the specified item for specified role.\n\t *\n\t *    @param [in] index   Identifies the item that's data is wanted.\n\t *    @param [in] role    Specifies what kind of data is wanted\n\t *\n\t *    @return QVariant containing the data\n     */\n\tvirtual QVariant data(const QModelIndex& index, int role = Qt::DisplayRole ) const;\n\n\t/*!\n     *  Get the data for the headers.\n\t *\n\t *    @param [in] section         The column that's header is wanted\n\t *    @param [in] orientation     Only Qt::Horizontal is supported\n\t *    @param [in] role            Specified the type of data that is wanted.\n\t *\n\t *    @return QVariant containing the data to be displayed.\n\t */\n\tvirtual QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole ) const;\n\n\t/*!\n     *  Set the data for specified item.\n\t *\n\t *    @param [in] index   Specifies the item that's data is modified\n\t *    @param [in] value   The value to be set.\n\t *    @param [in] role    The role that is trying to modify the data. Only Qt::EditRole is supported.\n\t *\n\t *    @return True if data was successfully set.\n\t */\n\tvirtual bool setData(QModelIndex const& index, QVariant const& value, int role = Qt::EditRole);\n\n    //! No copying. No assignment.\n    WirePortsModel(const WirePortsModel& other) = delete;\n    WirePortsModel& operator=(const WirePortsModel& other) = delete;\n\nprotected:\n\n    /*!\n     *  Check if the column index is valid for containing expressions.\n     *\n     *    @param [in] index   The index being evaluated.\n     *\n     *      return True, if column can have expressions, false otherwise.\n     */\n    virtual bool isValidExpressionColumn(QModelIndex const& index) const override final;\n\n    bool isPortTypeColumn(QModelIndex const& index) const final;\n\n    /*!\n     *  Gets the expression for the given index, or plain value if there is no expression.\n     *\n     *    @param [in] index   The index of target data.\n     *\n     *      return Expression in the given index, or plain value.\n     */\n    virtual QVariant expressionOrValueForIndex(QModelIndex const& index) const override final;\n\n    /*!\n     *  Get the formatted value of an expression in the selected index.\n     *\n     *    @param [in] index   The selected index.\n     *\n     *    @return The formatted value of an expression in the selected index.\n     */\n    virtual QVariant formattedExpressionForIndex(QModelIndex const& index) const override final;\n\n    /*!\n     *  Get the expression of the selected index.\n     *\n     *    @param [in] index   The selected index.\n     *\n     *    @return The expression of the selected index.\n     */\n    virtual QVariant expressionForIndex(QModelIndex const& index) const override final;\n\n    /*!\n     *  Gets the value for the given index.\n     *\n     *    @param [in] index   The index of target data.\n     *\n     *      return The data in the given index.\n     */\n    virtual QVariant valueForIndex(QModelIndex const& index) const override final;\n\n    /*!\n     *  Validates the data in the cell given by the column.\n     *\n     *    @param [in] index   The index being validated.\n     *\n     *      return True, if the data in the parameter is valid, false otherwise.\n     */\n    virtual bool validateIndex(QModelIndex const& index) const override final;\n\nprivate:\n\n    /*!\n     *  Get the column for row number.\n     *\n     *    @return Row number column.\n     */\n    virtual int rowNumberColumn() const override final;\n\n    /*!\n     *  Get the column for name.\n     *\n     *    @return Name column.\n     */\n    virtual int nameColumn() const override final;\n\n    /*!\n     *  Get the column for type definitions.\n     *\n     *    @return Type definitions column.\n     */\n    virtual int typeColumn() const override final;\n\n    /*!\n     *  Get the column for array left.\n     *\n     *    @return Array left column.\n     */\n    virtual int arrayLeftColumn() const override final;\n\n    /*!\n     *  Get the column for array right.\n     *\n     *    @return Array right column.\n     */\n    virtual int arrayRightColum() const override final;\n\n    /*!\n     *  Get the column for tags.\n     *\n     *    @return Tags column.\n     */\n    virtual int tagColumn() const override final;\n\n    /*!\n     *  Get the column for ad hoc visibility.\n     *\n     *    @return Ad hoc visibility column.\n     */\n    virtual int adHocColumn() const override final;\n\n    /*!\n     *  Get the column for description.\n     *\n     *    @return Description column.\n     */\n    virtual int descriptionColumn() const override final;\n\n    /*!\n     *  Check if the selected item is disabled.\n     *\n     *    @param [in] index           Index of the selected item.\n     *\n     *    @return True, if the indexed item is disabled, false otherwise.\n     */\n    virtual bool indexedItemIsDisabled(QModelIndex const& index) const override final;\n\n    /*!\n     *  Check if the selected item is mandatory.\n     *\n     *    @param [in] index   Index of the selected item.\n     *\n     *    @return True, if the indexed item is mandatory, false otherwise.\n     */\n    virtual bool indexedItemIsMandatory(QModelIndex const& index) const override final;\n\n    /*!\n     *  Check if the selected item is locked.\n     *\n     *    @param [in] index   Index of the selected item.\n     *\n     *    @return True, if the indexed item is locked, false otherwise.\n     */\n    virtual bool indexedItemIsLocked(QModelIndex const& index) const override final;\n\n    /*!\n     *  Get a list of the locked port indexes from the selected index.\n     *\n     *    @param [in] portIndex   Index of the selected item.\n     *\n     *    @return List of the locked port indexes.\n     */\n    virtual QModelIndexList getLockedPortIndexes(QModelIndex const& portIndex) const override final;\n\n    /*!\n     *  Add a new wire port.\n     */\n    virtual void addNewPort() override final;\n};\n\n#endif // WIREPORTSMODEL_H\n"
  },
  {
    "path": "editors/ComponentEditor/ports/portsdelegate.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: portsdelegate.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 01.04.2011\r\n//\r\n// Description:\r\n// The delegate that provides editors to edit ports of a component.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"portsdelegate.h\"\r\n\r\n#include <common/widgets/listManager/listeditor.h>\r\n\r\n#include <editors/ComponentEditor/ports/PortTagEditorDelegate.h>\r\n#include <editors/ComponentEditor/ports/PortWireTypeEditor.h>\r\n\r\n#include <IPXACTmodels/Component/Component.h>\r\n\r\n#include <QApplication>\r\n#include <QMouseEvent>\r\n#include <QPainter>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PortsDelegate::PortsDelegate()\r\n//-----------------------------------------------------------------------------\r\nPortsDelegate::PortsDelegate(QSharedPointer<Component> component, QAbstractItemModel* completionModel,\r\n    QSharedPointer<ParameterFinder> parameterFinder, QSharedPointer<PortTypeValidator> typeValidator,\r\n    QObject* parent):\r\nExpressionDelegate(completionModel, parameterFinder, parent),\r\ncomponent_(component),\r\nadhocGroupModify_(false),\r\nadhocGroupState_(Qt::Unchecked),\r\ntypeValidator_(typeValidator)\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PortsDelegate::createEditor()\r\n//-----------------------------------------------------------------------------\r\nQWidget* PortsDelegate::createEditor(QWidget* parent, QStyleOptionViewItem const& option, \r\n    QModelIndex const& index) const\r\n{\r\n    if (index.column() == typeColumn())\r\n    {\r\n        return createTypeEditor(parent);\r\n    }\r\n    else if (index.column() == tagColumn())\r\n    {\r\n        return createListEditorForPortTags(index, parent);\r\n    }\r\n    else\r\n    {\r\n        return ExpressionDelegate::createEditor(parent, option, index);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: portsdelegate::createTypeEditor()\r\n//-----------------------------------------------------------------------------\r\nQWidget* PortsDelegate::createTypeEditor(QWidget* parent) const\r\n{\r\n    PortWireTypeEditor* editor = new PortWireTypeEditor(component_, typeValidator_, parent);\r\n\r\n    connect(editor, SIGNAL(contentChanged()), this, SIGNAL(contentChanged()), Qt::UniqueConnection);\r\n\r\n    return editor;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PortsDelegate::setEditorData()\r\n//-----------------------------------------------------------------------------\r\nvoid PortsDelegate::setEditorData(QWidget* editor, QModelIndex const& index) const\r\n{\r\n    if (index.column() == typeColumn())\r\n    {\r\n        PortWireTypeEditor* typeEditor = dynamic_cast<PortWireTypeEditor*>(editor);\r\n        if (typeEditor)\r\n        {\r\n            QModelIndex portNameIndex = index.sibling(index.row(), nameColumn());\r\n            QString portName = portNameIndex.data(Qt::DisplayRole).toString();\r\n            QSharedPointer<Port> currentPort = component_->getPort(portName);\r\n\r\n            typeEditor->setPortForModel(currentPort);\r\n        }\r\n    }\r\n    else if (index.column() == tagColumn())\r\n    {\r\n        ListEditor* tagEditor = qobject_cast<ListEditor*>(editor);\r\n        Q_ASSERT(tagEditor);\r\n\r\n        QString portTagGroup = index.model()->data(index, Qt::DisplayRole).toString();\r\n\r\n        if (!portTagGroup.isEmpty())\r\n        {\r\n            QStringList portTags = portTagGroup.split(\", \");\r\n            tagEditor->setItems(portTags);\r\n        }\r\n    }\r\n    else\r\n    {\r\n        ExpressionDelegate::setEditorData(editor, index);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PortsDelegate::setModelData()\r\n//-----------------------------------------------------------------------------\r\nvoid PortsDelegate::setModelData(QWidget* editor, QAbstractItemModel* model, QModelIndex const& index ) const\r\n{\r\n    if (index.column() == typeColumn())\r\n    {\r\n        return;\r\n    }\r\n    else if (index.column() == tagColumn())\r\n    {\r\n        ListEditor* tagEditor = qobject_cast<ListEditor*>(editor);\r\n        Q_ASSERT(tagEditor);\r\n\r\n        QStringList tagGroup = tagEditor->items();\r\n        tagGroup.removeDuplicates();\r\n        tagGroup.removeAll(\"\");\r\n\r\n        QString portTags = tagGroup.join(\", \");\r\n\r\n        model->setData(index, portTags);\r\n    }\r\n    else\r\n    {\r\n        ExpressionDelegate::setModelData(editor, model, index);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PortsDelegate::editorEvent()\r\n//-----------------------------------------------------------------------------\r\nbool PortsDelegate::editorEvent(QEvent *event, QAbstractItemModel* model, \r\n    QStyleOptionViewItem const& option, QModelIndex const& index)\r\n{\r\n    Q_ASSERT(event);\r\n    Q_ASSERT(model);\r\n\r\n    // Always reset the ad-hoc group modify flag.\r\n    if (event->type() == QEvent::MouseButtonRelease)\r\n    {\r\n        adhocGroupModify_ = false;\r\n    }\r\n\r\n    // Make sure that the item is checkable.\r\n    Qt::ItemFlags flags = model->flags(index);\r\n\r\n    if (!(flags & Qt::ItemIsUserCheckable) || !(flags & Qt::ItemIsEnabled))\r\n    {\r\n        return false;\r\n    }\r\n\r\n    // Make sure that we have a check state.\r\n    QVariant value = index.data(Qt::CheckStateRole);\r\n\r\n    if (!value.isValid())\r\n    {\r\n        return false;\r\n    }\r\n\r\n    Qt::CheckState newState = static_cast<Qt::CheckState>(value.toInt());\r\n\r\n    // Handle the mouse button events.\r\n    if (event->type() == QEvent::MouseButtonPress)\r\n    {\r\n        const int textMargin = QApplication::style()->pixelMetric(QStyle::PM_FocusFrameHMargin) + 1;\r\n\r\n        QRect checkRect = QStyle::alignedRect(option.direction, Qt::AlignCenter,\r\n            option.decorationSize,\r\n            QRect(option.rect.x() + (2 * textMargin), option.rect.y(),\r\n            option.rect.width() - (2 * textMargin),\r\n            option.rect.height()));\r\n\r\n        if (!checkRect.contains(static_cast<QMouseEvent*>(event)->pos()))\r\n        {\r\n            return false;\r\n        }\r\n\r\n        newState = (static_cast<Qt::CheckState>(value.toInt()) == Qt::Checked ? Qt::Unchecked : Qt::Checked);\r\n        adhocGroupModify_ = true;\r\n        adhocGroupState_ = newState;\r\n    }\r\n    else if (event->type() == QEvent::MouseMove)\r\n    {\r\n        if (!adhocGroupModify_ || static_cast<Qt::CheckState>(value.toInt()) == adhocGroupState_)\r\n        {\r\n            return false;\r\n        }\r\n\r\n        const int textMargin = QApplication::style()->pixelMetric(QStyle::PM_FocusFrameHMargin) + 1;\r\n\r\n        QRect checkRect = QStyle::alignedRect(option.direction, Qt::AlignCenter,\r\n            option.decorationSize,\r\n            QRect(option.rect.x() + (2 * textMargin), option.rect.y(),\r\n            option.rect.width() - (2 * textMargin),\r\n            option.rect.height()));\r\n\r\n        if (!checkRect.contains(static_cast<QMouseEvent*>(event)->pos()))\r\n        {\r\n            return false;\r\n        }\r\n        \r\n        newState = adhocGroupState_;\r\n    }\r\n    else if (event->type() == QEvent::KeyPress)\r\n    {\r\n        if (static_cast<QKeyEvent*>(event)->key() != Qt::Key_Space &&\r\n            static_cast<QKeyEvent*>(event)->key() != Qt::Key_Select)\r\n        {\r\n            return false;\r\n        }\r\n    }\r\n    else\r\n    {\r\n        return false;\r\n    }\r\n\r\n    return model->setData(index, newState, Qt::CheckStateRole);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PortsDelegate::paint()\r\n//-----------------------------------------------------------------------------\r\nvoid PortsDelegate::paint(QPainter* painter, QStyleOptionViewItem const& option, QModelIndex const& index) const\r\n{\r\n\tQStyleOptionViewItem viewItemOption(option);\r\n\r\n    if (index.column() == adHocColumn())\r\n    {\r\n        painter->fillRect(option.rect, Qt::white);\r\n\r\n        const int textMargin = QApplication::style()->pixelMetric(QStyle::PM_FocusFrameHMargin) + 1;\r\n\r\n        QRect newRect = QStyle::alignedRect(option.direction, Qt::AlignCenter,\r\n                                            QSize(option.decorationSize.width() + 5, option.decorationSize.height()),\r\n                                            QRect(option.rect.x() + textMargin, option.rect.y(),\r\n                                                  option.rect.width() - (2 * textMargin), option.rect.height()));\r\n        viewItemOption.rect = newRect;\r\n    }\r\n\r\n    QStyledItemDelegate::paint(painter, viewItemOption, index);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PortsDelegate::columnAcceptsExpression()\r\n//-----------------------------------------------------------------------------\r\nbool PortsDelegate::columnAcceptsExpression(int column) const\r\n{\r\n    return column == arrayLeftColumn() || column == arrayRightColumn();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: portsdelegate::createListEditorForPortTags()\r\n//-----------------------------------------------------------------------------\r\nQWidget* PortsDelegate::createListEditorForPortTags(const QModelIndex& currentIndex, QWidget* parent) const\r\n{\r\n    auto tagEditor = new ListEditor(parent);\r\n    tagEditor->setMinimumHeight(100);\r\n\r\n    QStringList existingTags;\r\n\r\n    int portCount = currentIndex.model()->rowCount();\r\n    for (int i = 0; i < portCount; ++i)\r\n    {\r\n        QModelIndex portIndex = currentIndex.sibling(i, tagColumn());\r\n        QString portTags = portIndex.data(Qt::ToolTipRole).toString();\r\n\r\n        if (!portTags.isEmpty())\r\n        {\r\n            QStringList newTags = portTags.split(\", \");\r\n            existingTags.append(newTags);\r\n        }\r\n    }\r\n    existingTags.removeDuplicates();\r\n\r\n    tagEditor->setItemDelegate(new PortTagEditorDelegate(existingTags, parent));\r\n    return tagEditor;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: portsdelegate::updateEditorGeometry()\r\n//-----------------------------------------------------------------------------\r\nvoid PortsDelegate::updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option,\r\n    const QModelIndex &index) const\r\n{\r\n    ExpressionDelegate::updateEditorGeometry(editor, option, index);\r\n\r\n    if (index.column() == typeColumn())\r\n    {\r\n        repositionAndResizeEditor(editor, option, index);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: portsdelegate::repositionAndResizeEditor()\r\n//-----------------------------------------------------------------------------\r\nvoid PortsDelegate::repositionAndResizeEditor(QWidget* editor, QStyleOptionViewItem const& option,\r\n    QModelIndex const& index) const\r\n{\r\n    int editorMinimumSize = 30 * (getRowCountForPortTypes(index) + 5);\r\n    editor->setFixedWidth(300);\r\n\r\n    const int PARENT_HEIGHT = editor->parentWidget()->height();\r\n    const int AVAILABLE_HEIGHT_BELOW = PARENT_HEIGHT - option.rect.top();\r\n\r\n    if (AVAILABLE_HEIGHT_BELOW > editorMinimumSize)\r\n    {\r\n        editor->move(option.rect.topLeft());\r\n    }\r\n    else\r\n    {\r\n        int editorNewY = PARENT_HEIGHT-editorMinimumSize;\r\n        if (editorNewY <= 0)\r\n        {\r\n            editorNewY = 0;\r\n        }\r\n\r\n        editor->move(option.rect.left(), editorNewY);\r\n    }\r\n\r\n    if (editorMinimumSize > PARENT_HEIGHT)\r\n    {\r\n        editor->setFixedHeight(PARENT_HEIGHT);\r\n    }\r\n    else\r\n    {\r\n        editor->setFixedHeight(editorMinimumSize);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: portsdelegate::getRowCountForPortTypes()\r\n//-----------------------------------------------------------------------------\r\nint PortsDelegate::getRowCountForPortTypes(QModelIndex const& index) const\r\n{\r\n    QModelIndex portNameIndex = index.sibling(index.row(), nameColumn());\r\n    QString portName = portNameIndex.data(Qt::DisplayRole).toString();\r\n    QSharedPointer<Port> currentPort = component_->getPort(portName);\r\n\r\n    QSharedPointer<QList<QSharedPointer<WireTypeDef> > > typeDefinitions;\r\n    if (currentPort->getWire() && currentPort->getWire()->getWireTypeDefs())\r\n    {\r\n        typeDefinitions = currentPort->getWire()->getWireTypeDefs();\r\n    }\r\n    else if (currentPort->getTransactional() && currentPort->getTransactional()->getTransTypeDef())\r\n    {\r\n        typeDefinitions = currentPort->getTransactional()->getTransTypeDef();\r\n    }\r\n\r\n    int portTypeRowCount = 0;\r\n    for (QSharedPointer<WireTypeDef> singleTypeDefinition : *typeDefinitions)\r\n    {\r\n        portTypeRowCount += singleTypeDefinition->getViewRefs()->count() + 1;\r\n    }\r\n\r\n    return portTypeRowCount;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: portsdelegate::setComponent()\r\n//-----------------------------------------------------------------------------\r\nvoid PortsDelegate::setComponent(QSharedPointer<Component> newComponent)\r\n{\r\n    component_ = newComponent;\r\n}\r\n"
  },
  {
    "path": "editors/ComponentEditor/ports/portsdelegate.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: portsdelegate.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 01.04.2011\r\n//\r\n// Description:\r\n// The delegate that provides editors to edit ports of a component.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef PORTSDELEGATE_H\r\n#define PORTSDELEGATE_H\r\n\r\n#include <editors/ComponentEditor/common/ExpressionDelegate.h>\r\n\r\n#include <QCompleter>\r\n\r\nclass ParameterFinder;\r\nclass Component;\r\n\r\nclass PortTypeValidator;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! The delegate that provides editors to edit ports of a component.\r\n//-----------------------------------------------------------------------------\r\nclass PortsDelegate : public ExpressionDelegate\r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\r\n    /*!\r\n     *  The constructor.\r\n     *\r\n     *    @param [in] component           Component containing the edited ports.\r\n     *    @param [in] completionModel     Model containing the completions used in expression editor.\r\n     *    @param [in] parameterFinder     The parameter finder to use for for expression editor.\r\n     *    @param [in] typeValidator       Validator for port type definitions.\r\n     *    @param [in] parent              The parent object.\r\n     */\r\n\tPortsDelegate(QSharedPointer<Component> component, QAbstractItemModel* completionModel,\r\n        QSharedPointer<ParameterFinder> parameterFinder, QSharedPointer<PortTypeValidator> typeValidator,\r\n        QObject* parent = 0);\r\n\t\r\n\t/*!\r\n     *  The destructor.\r\n     */\r\n\tvirtual ~PortsDelegate() = default;\r\n\r\n\t/*!\r\n     *  Create a new editor for the given item\r\n\t *\r\n\t *    @param [in] parent  Owner for the editor.\r\n\t *    @param [in] option  Contains options for the editor.\r\n\t *    @param [in] index   Model index identifying the item.\r\n\t *\r\n\t *    @return The editor to be used to edit the item.\r\n     */\r\n\tvirtual QWidget* createEditor(QWidget* parent, QStyleOptionViewItem const& option, QModelIndex const& index)\r\n        const;\r\n\r\n\t/*!\r\n     *  Set the data for the editor.\r\n\t *\r\n\t *    @param [in] editor  The editor where the data is to be set.\r\n\t *    @param [in] index   Model index identifying the item that's data is to be set.\r\n     */\r\n\tvirtual void setEditorData(QWidget* editor, QModelIndex const& index) const;\r\n\r\n\t/*!\r\n     *  Save the data from the editor to the model.\r\n\t *\r\n\t *    @param [in] editor  The editor that contains the data to store.\r\n\t *    @param [in] model   Model that contains the data structure where data is to be saved to.\r\n\t *    @param [in] index   Model index identifying the item that's data is to be saved.\r\n     */\r\n\tvirtual void setModelData(QWidget* editor, QAbstractItemModel* model, \r\n\t\tQModelIndex const& index) const;\r\n\r\n\t/*!\r\n\t *  Renders an item in the given index.\r\n\t *\r\n\t *    @param [in] painter     The painter to use for rendering.\r\n\t *    @param [in] option      The style options for the rendering.\r\n\t *    @param [in] index       The index to the data being rendered.\r\n\t */\r\n\tvirtual void paint(QPainter* painter, QStyleOptionViewItem const& option, QModelIndex const& index) const;\r\n    \r\n    /*!\r\n     *  Updates the editor geometry.\r\n     *\r\n     *    @param [in] editor  The editor being updated.\r\n     *    @param [in] option  The options used to update the editor.\r\n     *    @param [in] index   The model index being edited.\r\n     */\r\n    virtual void updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option,\r\n        const QModelIndex &index) const;\r\n\r\n    /*!\r\n     *  Set a new component.\r\n     *\r\n     *    @param [in] newComponent    The new component.\r\n     */\r\n    void setComponent(QSharedPointer<Component> newComponent);\r\n\r\n    // Disable copying.\r\n    PortsDelegate(PortsDelegate const& rhs) = delete;\r\n    PortsDelegate& operator=(PortsDelegate const& rhs) = delete;\r\n\r\nsignals:\r\n\r\n    /*!\r\n     *  Transmits changes in the content.\r\n     */\r\n    void contentChanged();\r\n\r\nprotected:\r\n    \r\n    /*!\r\n     *  Handler for preprocessing events that starts editing.\r\n     *\r\n     *    @param [in] event   The event that triggered the editing.\r\n     *    @param [in] model   The underlying model to edit.\r\n     *    @param [in] option  Style options for rendering the item.\r\n     *    @param [in] index   The index being edited.\r\n     *\r\n     *    @return True, if the delegate handles the event, otherwise false.\r\n     */\r\n    virtual bool editorEvent(QEvent* event, QAbstractItemModel* model, QStyleOptionViewItem const& option, \r\n        QModelIndex const& index);\r\n    \r\n    /*!\r\n     *  Checks if the given column supports expressions in the editor.\r\n     *\r\n     *    @param [in] column   The column to check.\r\n     *\r\n     *    @return True, if the cells in the column allow expressions, otherwise false.\r\n     */\r\n    virtual bool columnAcceptsExpression(int column) const;\r\n\r\n    /*!\r\n     *  Gets the description column.\r\n     *\r\n     *    @return Description column index.\r\n     */\r\n    virtual int descriptionColumn() const = 0;\r\n\r\nprivate:\r\n\r\n    /*!\r\n     *  Get the name column index.\r\n     *\r\n     *    @return Name column index.\r\n     */\r\n    virtual int nameColumn() const = 0;\r\n\r\n    /*!\r\n     *  Get the type definition column index.\r\n     *\r\n     *    @return Type definition column index.\r\n     */\r\n    virtual int typeColumn() const = 0;\r\n\r\n    /*!\r\n     *  Get the tag group column index.\r\n     *\r\n     *    @return Tag group column index.\r\n     */\r\n    virtual int tagColumn() const = 0;\r\n\r\n    /*!\r\n     *  Get the adhoc column index.\r\n     *\r\n     *    @return Adhoc column index.\r\n     */\r\n    virtual int adHocColumn() const = 0;\r\n\r\n    /*!\r\n     *  Get the array left column index.\r\n     *\r\n     *    @return Array left column index.\r\n     */\r\n    virtual int arrayLeftColumn() const = 0;\r\n\r\n    /*!\r\n     *  Get the array right column index.\r\n     *\r\n     *    @return Array right column index.\r\n     */\r\n    virtual int arrayRightColumn() const = 0;\r\n\r\n    /*!\r\n     *  Creates a port type editor.\r\n     *\r\n     *    @param [in] parent  Parent widget for the editor.\r\n     *\r\n     *    @return The editor for port types.\r\n     */\r\n    QWidget* createTypeEditor(QWidget* parent) const;\r\n\r\n    /*!\r\n     *  Create a list editor used in defining tags for the ports.\r\n     *\r\n     *    @param [in] currentIndex    The currently selected index.\r\n     *    @param [in] parent          The owner of the new editor.\r\n     *\r\n     *    @return The list editor for port tags.\r\n     */\r\n    QWidget* createListEditorForPortTags(const QModelIndex& currentIndex, QWidget* parent) const;\r\n\r\n    /*!\r\n     *  Reposition and resize the selected editor.\r\n     *\r\n     *    @param [in] editor  The selected editor.\r\n     *    @param [in] option  Style options for the area containing the editor.\r\n     *    @param [in] index   Index of the editor.\r\n     */\r\n    void repositionAndResizeEditor(QWidget* editor, QStyleOptionViewItem const& option, QModelIndex const& index)\r\n        const;\r\n\r\n    /*!\r\n     *  Get the row count for the port type editor.\r\n     *\r\n     *    @param [in] index   Index of the selected port.\r\n     */\r\n    int getRowCountForPortTypes(QModelIndex const& index) const;\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! Component containing the ports.\r\n    QSharedPointer<Component> component_;\r\n\r\n    //! Boolean for ad-hoc group modify.\r\n    bool adhocGroupModify_;\r\n\r\n    //! The new state for the group modify.\r\n    Qt::CheckState adhocGroupState_;\r\n\r\n    //! Validator for the port type definitions.\r\n    QSharedPointer<PortTypeValidator> typeValidator_;\r\n};\r\n\r\n#endif // PORTSDELEGATE_H\r\n"
  },
  {
    "path": "editors/ComponentEditor/ports/portseditor.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: portseditor.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 31.03.2011\r\n//\r\n// Description:\r\n// Editor to edit the ports of a component.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"portseditor.h\"\r\n\r\n#include <KactusAPI/include/PortAbstractionInterface.h>\r\n#include <KactusAPI/include/BusInterfaceInterface.h>\r\n#include <KactusAPI/include/IPXactSystemVerilogParser.h>\r\n#include <KactusAPI/include/ComponentParameterFinder.h>\r\n#include <KactusAPI/include/PortsInterface.h>\r\n\r\n#include <editors/ComponentEditor/parameters/ComponentParameterModel.h>\r\n#include <editors/ComponentEditor/ports/MasterPortsEditor.h>\r\n#include <editors/ComponentEditor/ports/WirePortsEditorFactory.h>\r\n#include <editors/ComponentEditor/ports/TransactionalPortsEditorFactory.h>\r\n#include <editors/ComponentEditor/ports/PortSummaryModel.h>\r\n#include <editors/ComponentEditor/ports/PortsView.h>\r\n#include <editors/ComponentEditor/ports/PortSummaryFilter.h>\r\n#include <editors/ComponentEditor/ports/PortSummaryDelegate.h>\r\n\r\n#include \"PortSummaryEditorFactory.h\"\r\n\r\n#include <common/dialogs/NewBusDialog/NewBusDialog.h>\r\n#include <common/widgets/summaryLabel/summarylabel.h>\r\n\r\n#include <KactusAPI/include/LibraryInterface.h>\r\n\r\n#include <wizards/BusInterfaceWizard/BusInterfaceWizard.h>\r\n\r\n#include <IPXACTmodels/AbstractionDefinition/AbstractionDefinition.h>\r\n#include <IPXACTmodels/Component/Component.h>\r\n#include <IPXACTmodels/Component/BusInterface.h>\r\n#include <IPXACTmodels/common/VLNV.h>\r\n#include <IPXACTmodels/Component/validators/PortValidator.h>\r\n\r\n#include <QCompleter>\r\n#include <QVBoxLayout>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PortsEditor::PortsEditor()\r\n//-----------------------------------------------------------------------------\r\nPortsEditor::PortsEditor(QSharedPointer<Component> component, LibraryInterface* handler,\r\n    ExpressionSet expressions,\r\n    QSharedPointer<PortValidator> portValidator,\r\n    QSharedPointer<PortsInterface> portsInterface,\r\n    BusInterfaceInterface* busInterface,\r\n    QWidget *parent):\r\nItemEditor(component, handler, parent),\r\n    component_(component),\r\n    handler_(handler),\r\n    portsInterface_(portsInterface),\r\n    busInterface_(busInterface)\r\n{\r\n\r\n    PortSummaryEditorFactory factory(component_, \r\n        expressions, \r\n        portValidator,\r\n        portsInterface_, \r\n        QSharedPointer<PortAbstractionInterface>(new PortAbstractionInterface(expressions.parser, expressions.formatter)),\r\n        busInterface,\r\n        QString());\r\n\r\n    model_ = factory.createModel(this);\r\n\r\n    filter_ = factory.createFilter(this);\r\n    \r\n    filter_->setSourceModel(model_);\r\n\r\n    auto view = factory.createView(this);\r\n    view->setModel(filter_);\r\n\r\n    view->setItemDelegate(factory.createDelegate(this));\r\n\r\n\r\n\r\n    connect(model_, SIGNAL(contentChanged()), this, SIGNAL(contentChanged()), Qt::UniqueConnection);\r\n    connect(model_, SIGNAL(dataChanged(const QModelIndex&, const QModelIndex&)),\r\n        this, SIGNAL(contentChanged()), Qt::UniqueConnection);\r\n    connect(model_, SIGNAL(errorMessage(const QString&)),\r\n        this, SIGNAL(errorMessage(const QString&)), Qt::UniqueConnection);\r\n    connect(model_, SIGNAL(noticeMessage(const QString&)),\r\n        this, SIGNAL(noticeMessage(const QString&)), Qt::UniqueConnection);\r\n\r\n    connect(view, SIGNAL(addWire()), model_, SLOT(onAddWire()), Qt::UniqueConnection);\r\n    connect(view, SIGNAL(addTransactional()), model_, SLOT(onAddTransactional()), Qt::UniqueConnection);\r\n    connect(view, SIGNAL(removeItem(const QModelIndex&)), model_, SLOT(onRemoveItem(const QModelIndex&)), Qt::UniqueConnection);\r\n\r\n    connect(view->itemDelegate(), SIGNAL(increaseReferences(QString)),\r\n        this, SIGNAL(increaseReferences(QString)), Qt::UniqueConnection);\r\n    connect(view->itemDelegate(), SIGNAL(decreaseReferences(QString)),\r\n        this, SIGNAL(decreaseReferences(QString)), Qt::UniqueConnection);\r\n\r\n    connect(model_, SIGNAL(decreaseReferences(QString)), this, SIGNAL(decreaseReferences(QString)), Qt::UniqueConnection);\r\n\r\n    //connect(delegate_, SIGNAL(contentChanged()), this, SIGNAL(contentChanged()), Qt::UniqueConnection);\r\n\r\n    connect(view, SIGNAL(changeExtensionsEditorItem(QModelIndex const&)),\r\n        filter_, SLOT(onHandleExtensionsEditorItemChange(QModelIndex const&)), Qt::UniqueConnection);\r\n    connect(filter_, SIGNAL(changeExtensionsEditorItem(QModelIndex const&)),\r\n        this, SLOT(changeExtensionsEditorItem(QModelIndex const&)), Qt::UniqueConnection);\r\n\r\n    connect(model_, SIGNAL(portExtensionDataChanged(QModelIndex const&)),\r\n        this, SLOT(changeExtensionsEditorItem(QModelIndex const&)), Qt::UniqueConnection);\r\n\r\n\tauto summaryLabel = new SummaryLabel(tr(\"Ports summary\"), this);\r\n\r\n\t// create the layout, add widgets to it\r\n\tauto layout = new QVBoxLayout(this);\r\n \tlayout->addWidget(summaryLabel, 0, Qt::AlignCenter);\r\n    layout->addWidget(view, 1);\r\n\tlayout->setContentsMargins(0, 0, 0, 0);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PortsEditor::isValid()\r\n//-----------------------------------------------------------------------------\r\nbool PortsEditor::isValid() const\r\n{\r\n    return true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PortsEditor::refresh()\r\n//-----------------------------------------------------------------------------\r\nvoid PortsEditor::refresh()\r\n{\r\n    filter_->invalidate();\r\n    busInterface_->setBusInterfaces(component_);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PortsEditor::showEvent()\r\n//-----------------------------------------------------------------------------\r\nvoid PortsEditor::showEvent(QShowEvent* event)\r\n{\r\n    ItemEditor::showEvent(event);\r\n    emit helpUrlRequested(\"componenteditor/ports.html\");\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: portseditor::getModel()\r\n//-----------------------------------------------------------------------------\r\nPortsModel* PortsEditor::getModel() const\r\n{\r\n    return model_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PortsEditor::setComponent()\r\n//-----------------------------------------------------------------------------\r\nvoid PortsEditor::setComponent(QSharedPointer<Component> component)\r\n{\r\n    component_ = component;\r\n\r\n    portsInterface_->setPorts(component_->getPorts());\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PortsEditor::changeExtensionsEditorItem()\r\n//-----------------------------------------------------------------------------\r\nvoid PortsEditor::changeExtensionsEditorItem(QModelIndex const& itemIndex)\r\n{\r\n    if (!itemIndex.isValid())\r\n    {\r\n        emit changeVendorExtensions(QStringLiteral(\"Component: \") + component()->getVlnv().toString(), component());\r\n    }\r\n    else if (QSharedPointer<Port> selectedPort = \r\n        portsInterface_->getPort(portsInterface_->getIndexedItemName(itemIndex.row())))\r\n    {\r\n        emit changeVendorExtensions(QStringLiteral(\"Port: \") + selectedPort->name(), selectedPort);\r\n    }\r\n}\r\n"
  },
  {
    "path": "editors/ComponentEditor/ports/portseditor.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: portseditor.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 31.03.2011\r\n//\r\n// Description:\r\n// Editor to edit the ports of a component.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef PORTSEDITOR_H\r\n#define PORTSEDITOR_H\r\n\r\n#include <KactusAPI/include/ParameterFinder.h>\r\n#include <KactusAPI/include/ExpressionFormatter.h>\r\n#include <editors/ComponentEditor/itemeditor.h>\r\n#include <editors/common/ExpressionSet.h>\r\n\r\n#include <QTabWidget>\r\n\r\nclass BusInterface;\r\nclass BusInterfaceWizard;\r\nclass Component;\r\nclass LibraryInterface;\r\nclass PortValidator;\r\nclass MasterPortsEditor;\r\nclass PortsInterface;\r\nclass BusInterfaceInterface;\r\nclass PortsFilter;\r\nclass PortsModel;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Editor to edit the ports of a component.\r\n//-----------------------------------------------------------------------------\r\nclass PortsEditor : public ItemEditor\r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\r\n\t/*!\r\n\t *  The constructor.\r\n\t *\r\n\t *    @param [in] component               The component being edited.\r\n\t *    @param [in] handler                 The instance that manages the library.\r\n\t *    @param [in] parameterFinder         The parameter finder.\r\n\t *    @param [in] expressionFormatter     The expression formatter.\r\n     *    @param [in] portValidator           Validator used for ports.\r\n     *    @param [in] busInterface            Interface for accessing bus interfaces.\r\n\t *    @param [in] parent                  The owner of this widget.\r\n\t */\r\n\tPortsEditor(QSharedPointer<Component> component,\r\n        LibraryInterface* handler,\r\n        ExpressionSet expressions,\r\n        QSharedPointer<PortValidator> portValidator,\r\n        QSharedPointer<PortsInterface> portsInterface,\r\n        BusInterfaceInterface* busInterface,\r\n        QWidget *parent = 0);\r\n\r\n\t/*!\r\n     *  The destructor.\r\n     */\r\n\tvirtual ~PortsEditor() = default;\r\n\r\n\t/*!\r\n     *  Check for the validity of the edited ports.\r\n     *\r\n     *    @return True if all ports are in valid state.\r\n     */\r\n\tbool isValid() const;\r\n\r\n\t/*!\r\n     *  Reload the information from the model to the editor.\r\n\t */\r\n\tvoid refresh() final;\r\n\r\n    /*!\r\n     *  Sets the edited component.\r\n     *\r\n     *    @param [in] component   The component whose ports to edit.\r\n     */\r\n    virtual void setComponent(QSharedPointer<Component> component);\r\n\r\n    //! No copying.\r\n    PortsEditor(const PortsEditor& other) = delete;\r\n    PortsEditor& operator=(const PortsEditor& other) = delete;\r\n\r\n\r\nprotected:\r\n\r\n    /*!\r\n     *  Called when the editor is shown.\r\n     */\r\n    virtual void showEvent(QShowEvent* event);\r\n\r\n    /*!\r\n     *  Get the associated ports model.\r\n     *\r\n     *    @return The ports model.\r\n     */\r\n    PortsModel* getModel() const;\r\n\r\nprivate slots:\r\n\r\n   \r\n\r\n    /*!\r\n     *  Change the vendor extensions of the vendor extensions editor.\r\n     *\r\n     *    @param [in] itemIndex   Index of the selected port.\r\n     */\r\n    void changeExtensionsEditorItem(QModelIndex const& itemIndex);\r\n\r\n\r\nprivate:\r\n\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! The component whose ports are being edited.\r\n    QSharedPointer<Component> component_{ nullptr };\r\n\r\n\t//! The instance that manages the library.\r\n\tLibraryInterface* handler_{ nullptr };\r\n\r\n    QSharedPointer<PortsInterface> portsInterface_{ nullptr };\r\n\r\n    //! Interface for accessing bus interfaces.\r\n    BusInterfaceInterface* busInterface_{ nullptr };\r\n\r\n    //! The ports model.\r\n    PortsModel* model_{ nullptr };\r\n\r\n    //! Filter for ports.\r\n    PortsFilter* filter_{ nullptr };\r\n};\r\n\r\n#endif // PORTSEDITOR_H\r\n"
  },
  {
    "path": "editors/ComponentEditor/ports/portsmodel.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: portsmodel.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 31.3.2011\r\n//\r\n// Description:\r\n// Table model that can be used to display ports to be edited.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"portsmodel.h\"\r\n\r\n#include <common/KactusColors.h>\r\n\r\n#include <KactusAPI/include/PortAbstractionInterface.h>\r\n#include <KactusAPI/include/PortsInterface.h>\r\n\r\n#include <IPXACTmodels/common/DirectionTypes.h>\r\n#include <IPXACTmodels/common/TransactionalTypes.h>\r\n\r\n#include <QString>\r\n#include <QStringList>\r\n#include <QRegularExpression>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PortsModel::PortsModel()\r\n//-----------------------------------------------------------------------------\r\nPortsModel::PortsModel(QSharedPointer<ParameterFinder> parameterFinder,\r\n    QSharedPointer<PortsInterface> portInterface, QSharedPointer<PortAbstractionInterface> signalInterface,\r\n    QObject *parent):\r\nReferencingTableModel(parameterFinder, parent),\r\nParameterizableTable(parameterFinder),\r\nportsInterface_(portInterface),\r\nsignalInterface_(signalInterface)\r\n{\r\n    Q_ASSERT(portInterface);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PortsModel::rowCount()\r\n//-----------------------------------------------------------------------------\r\nint PortsModel::rowCount(QModelIndex const& parent) const\r\n{\r\n\tif (parent.isValid())\r\n    {\r\n\t\treturn 0;\r\n    }\r\n\r\n    return portsInterface_->itemCount();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PortsModel::data()\r\n//-----------------------------------------------------------------------------\r\nQVariant PortsModel::data(QModelIndex const& index, int role) const\r\n{\r\n    if (!index.isValid() || index.row() < 0 || index.row() >= portsInterface_->itemCount())\r\n    {\r\n\t\treturn QVariant();\r\n\t}\r\n\r\n    if (role == Qt::DisplayRole) \r\n    {\r\n        if (isValidExpressionColumn(index))\r\n        {\r\n            return formattedExpressionForIndex(index);\r\n        }\r\n        else if (index.column() == descriptionColumn())\r\n        {\r\n            return valueForIndex(index).toString().replace(QRegularExpression(\"\\n.*$\", \r\n                QRegularExpression::DotMatchesEverythingOption), \"...\");\r\n        }\r\n        else\r\n        {\r\n            return valueForIndex(index);\r\n        }\r\n    }\r\n    else if (role == Qt::EditRole)\r\n    {\r\n        if (isValidExpressionColumn(index))\r\n        {\r\n            return expressionForIndex(index);\r\n        }\r\n        // For copy pasting type defs.\r\n        else if (isPortTypeColumn(index))\r\n        {\r\n            std::string portName = portsInterface_->getIndexedItemName(index.row());\r\n            using TypeDefList = std::vector<std::pair<std::string, std::vector<std::string> > >;\r\n\r\n            auto typeViews = portsInterface_->getTypeNameViews(portName);\r\n            auto typeDefs = portsInterface_->getTypeDefinitions(portName);\r\n\r\n            auto typeDefData = QPair<TypeDefList,TypeDefList>({ typeViews, typeDefs });\r\n\r\n            QVariant copyData;\r\n            copyData.setValue(typeDefData);\r\n\r\n            return copyData;\r\n        }\r\n        else\r\n        {\r\n            return valueForIndex(index);\r\n        }\r\n    }\r\n    else if (role == Qt::ToolTipRole)\r\n    {\r\n        return valueForIndex(index);\r\n    }\r\n    else if (role == Qt::ForegroundRole)\r\n    {\r\n        if (isLocked(index))\r\n        {\r\n            return KactusColors::DISABLED_TEXT;\r\n        }\r\n        else\r\n        {\r\n            return blackForValidOrRedForInvalidIndex(index);\r\n        }\r\n    }\r\n\telse if (role == Qt::BackgroundRole)\r\n    {\r\n        if (indexedItemIsDisabled(index))\r\n        {\r\n            return KactusColors::DISABLED_FIELD;\r\n        }\r\n        else if (indexedItemIsMandatory(index))\r\n        {\r\n            return KactusColors::MANDATORY_FIELD;\r\n        }\r\n        else\r\n        {\r\n            return KactusColors::REGULAR_FIELD;\r\n        }\r\n    }\r\n    else if (Qt::CheckStateRole == role)\r\n    {\r\n        if (index.column() == adHocColumn())\r\n        {\r\n            std::string portName = portsInterface_->getIndexedItemName(index.row());\r\n            if (portsInterface_->isAdHoc(portName))\r\n            {\r\n                return Qt::Checked;\r\n            }\r\n            else\r\n            {\r\n                return Qt::Unchecked;\r\n            }\r\n        }\r\n        else\r\n        {\r\n            return QVariant();\r\n        }\r\n    }\r\n    else if (role == Qt::TextAlignmentRole && index.column() == rowNumberColumn())\r\n    {\r\n        return int(Qt::AlignRight | Qt::AlignVCenter);\r\n    }\r\n\r\n\t// if unsupported role\r\n    return QVariant();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PortsModel::headerData()\r\n//-----------------------------------------------------------------------------\r\nQVariant PortsModel::headerData(int section, Qt::Orientation orientation, int role) const\r\n{\r\n    if (role == Qt::DisplayRole && section >= 0)\r\n    {\r\n        if (orientation == Qt::Vertical)\r\n        {\r\n            return QString::fromStdString(portsInterface_->getIndexedItemName(section));\r\n        }\r\n\r\n        else if (orientation == Qt::Horizontal)\r\n        {\r\n            if (section == rowNumberColumn())\r\n            {\r\n                return tr(\"#\");\r\n            }\r\n            else if (section == nameColumn())\r\n            {\r\n                return tr(\"Name\");\r\n            }\r\n            else if (section == typeColumn())\r\n            {\r\n                return tr(\"Type\");\r\n            }\r\n            else if (section == arrayLeftColumn())\r\n            {\r\n                QString arrayLeftHeader = tr(\"Array\\nleft\") + getExpressionSymbol();\r\n                return arrayLeftHeader;\r\n            }\r\n            else if (section == arrayRightColum())\r\n            {\r\n                QString arrayRightHeader = tr(\"Array\\nright\") + getExpressionSymbol();\r\n                return arrayRightHeader;\r\n            }\r\n            else if (section == tagColumn())\r\n            {\r\n                return tr(\"Port\\ntags\");\r\n            }\r\n            else if (section == adHocColumn())\r\n            {\r\n                return tr(\"Ad-hoc\");\r\n            }\r\n            else if (section == descriptionColumn())\r\n            {\r\n                return tr(\"Description\");\r\n            }\r\n            else\r\n            {\r\n                return QVariant();\r\n            }\r\n        } \r\n    }\r\n\r\n    // if unsupported role\r\n    return QVariant();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PortsModel::setData()\r\n//-----------------------------------------------------------------------------\r\nbool PortsModel::setData(QModelIndex const& index, QVariant const& value, int role)\r\n{\t\r\n    if (!index.isValid() || index.row() < 0 || index.row() >= portsInterface_->itemCount())\r\n    {\r\n\t\treturn false;\r\n    }\r\n\r\n    std::string portName = portsInterface_->getIndexedItemName(index.row());\r\n    if (role == Qt::EditRole)\r\n    {\r\n        if (isLocked(index))\r\n        {\r\n            return false;\r\n        }\r\n\r\n        if (index.column() == rowNumberColumn())\r\n        {\r\n            return false;\r\n        }\r\n        else if (index.column() == nameColumn())\r\n        {\r\n            portsInterface_->setName(portName, value.toString().toStdString());\r\n            emit headerDataChanged(Qt::Vertical, index.row(), index.row());\r\n            emit portExtensionDataChanged(index);\r\n        }\r\n        // Copy pasting type definitions\r\n        else if (index.column() == typeColumn())\r\n        {\r\n            using TypeDefList = std::vector<std::pair<std::string, std::vector<std::string> > >;\r\n\r\n            if (!value.canConvert<QPair<TypeDefList, TypeDefList>>())\r\n            {\r\n                return false;\r\n            }\r\n\r\n            auto [typeNameViews, typeDefinitions] = value.value<QPair<TypeDefList, TypeDefList>>();\r\n            \r\n            // Overwrite values on paste, if some type defs are defined\r\n            if (!index.data(Qt::EditRole).value<QPair<TypeDefList, TypeDefList>>().first.empty())\r\n            {\r\n                portsInterface_->clearTypeDefinitions(portName);\r\n            }\r\n\r\n            portsInterface_->setTypeDefViewRefs(portName, typeNameViews);\r\n            portsInterface_->setTypeDefDefinitions(portName, typeDefinitions);\r\n        }\r\n        else if (index.column() == arrayLeftColumn())\r\n        {\r\n            if (!value.isValid())\r\n            {\r\n                removeReferencesFromSingleExpression(\r\n                    QString::fromStdString(portsInterface_->getArrayLeftExpression(portName)));\r\n            }\r\n\r\n            portsInterface_->setArrayLeft(portName, value.toString().toStdString());\r\n\r\n            if (value.isValid() && portsInterface_->getArrayRightExpression(portName).empty() &&\r\n                !portsInterface_->getArrayLeftExpression(portName).empty())\r\n            {\r\n                portsInterface_->setArrayRight(portName, QString::number(0).toStdString());\r\n            }\r\n        }\r\n        else if (index.column() == arrayRightColum())\r\n        {\r\n            if (!value.isValid())\r\n            {\r\n                removeReferencesFromSingleExpression(\r\n                    QString::fromStdString(portsInterface_->getArrayRightExpression(portName)));\r\n            }\r\n\r\n            portsInterface_->setArrayRight(portName, value.toString().toStdString());\r\n\r\n            if (value.isValid() && portsInterface_->getArrayLeftExpression(portName).empty() &&\r\n                !portsInterface_->getArrayRightExpression(portName).empty())\r\n            {\r\n                portsInterface_->setArrayLeft(portName, std::to_string(0));\r\n            }\r\n        }\r\n        else if (index.column() == tagColumn())\r\n        {\r\n            portsInterface_->setTags(portName, value.toString().toStdString());\r\n\r\n            emit portExtensionDataChanged(index);\r\n        }\r\n        else if (index.column() == adHocColumn())\r\n        {\r\n            portsInterface_->setAdHoc(portName, value.toBool());\r\n        }\r\n        else if (index.column() == descriptionColumn())\r\n        {\r\n            portsInterface_->setDescription(portName, value.toString().toStdString());\r\n        }\r\n        else\r\n        {\r\n            return false;\r\n        }\r\n\r\n        emit dataChanged(index, index);\r\n        return true;\r\n    }\r\n    else if (role == Qt::CheckStateRole)\r\n    {\r\n        portsInterface_->setAdHoc(portName, value == Qt::Checked);\r\n        emit dataChanged(index, index);\r\n        return true;\r\n    }\r\n    // unsupported role\r\n    else\r\n    {\r\n        return false;\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PortsModel::flags()\r\n//-----------------------------------------------------------------------------\r\nQt::ItemFlags PortsModel::flags(QModelIndex const& index) const\r\n{\r\n    if (!index.isValid() || index.column() == rowNumberColumn())\r\n    {\r\n\t\treturn Qt::NoItemFlags;\r\n    }\r\n\r\n    Qt::ItemFlags flags = Qt::ItemIsEnabled | Qt::ItemIsSelectable;\r\n\r\n    if (isLocked(index) || indexedItemIsLocked(index))\r\n    {\r\n        return flags;\r\n    }\r\n    else if (index.column() == adHocColumn())\r\n    {\r\n        flags |= Qt::ItemIsUserCheckable;\r\n    }\r\n    else\r\n    {\r\n        flags |= Qt::ItemIsEditable;\r\n    }\r\n\r\n    return flags;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PortsModel::isValid()\r\n//-----------------------------------------------------------------------------\r\nbool PortsModel::isValid() const\r\n{\t\r\n\t// check all ports in the table\r\n    return portsInterface_->validateItems();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PortsModel::onRemoveRow()\r\n//-----------------------------------------------------------------------------\r\nvoid PortsModel::onRemoveRow(int row)\r\n{\r\n\t// if row is invalid\r\n    if (row < 0 || row >= portsInterface_->itemCount() || rowIsLocked(row))\r\n    {\r\n\t\treturn;\r\n    }\r\n\r\n    std::string portName(portsInterface_->getIndexedItemName(row));\r\n\r\n    beginRemoveRows(QModelIndex(), row, row);\r\n    portsInterface_->removePort(portName);\r\n\r\n\tendRemoveRows();\r\n\r\n    emit invalidateOtherFilter();\r\n    emit portCountChanged();\r\n\r\n\t// tell also parent widget that contents have been changed\r\n\temit contentChanged();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PortsModel::onRemoveItem()\r\n//-----------------------------------------------------------------------------\r\nvoid PortsModel::onRemoveItem(QModelIndex const& index)\r\n{\r\n\t// don't remove anything if index is invalid\r\n    if (!index.isValid() || index.row() < 0 || index.row() >= portsInterface_->itemCount() ||\r\n        rowIsLocked(index.row()))\r\n    {\r\n\t\treturn;\r\n\t}\r\n\r\n    int portRow = index.row();\r\n    std::string portName(portsInterface_->getIndexedItemName(portRow));\r\n\r\n    beginRemoveRows(QModelIndex(), portRow, portRow);\r\n\r\n    removeReferencesInItemOnRow(portRow);\r\n    portsInterface_->removePort(portName);\r\n\r\n\tendRemoveRows();\r\n\r\n    emit invalidateOtherFilter();\r\n    emit portCountChanged();\r\n\r\n\t// tell also parent widget that contents have been changed\r\n\temit contentChanged();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PortsModel::onAddRow()\r\n//-----------------------------------------------------------------------------\r\nvoid PortsModel::onAddRow()\r\n{\r\n    int lastRow = portsInterface_->itemCount();\r\n\r\n \tbeginInsertRows(QModelIndex(), lastRow, lastRow);\r\n\r\n    addNewPort();\r\n\r\n\tendInsertRows();\r\n\r\n    emit invalidateOtherFilter();\r\n    emit portCountChanged();\r\n\r\n\t// tell also parent widget that contents have been changed\r\n\temit contentChanged();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PortsModel::onAddItem()\r\n//-----------------------------------------------------------------------------\r\nvoid PortsModel::onAddItem(QModelIndex const& index)\r\n{\r\n    int row = portsInterface_->itemCount();\r\n\r\n\t// if the index is valid then add the item to the correct position\r\n\tif (index.isValid())\r\n    {\r\n\t\trow = index.row();\r\n\t}\r\n\r\n\tbeginInsertRows(QModelIndex(), row, row);\r\n    addNewPort();\r\n    endInsertRows();\r\n\r\n    emit invalidateOtherFilter();\r\n    emit portCountChanged();\r\n\r\n\t// tell also parent widget that contents have been changed\r\n\temit contentChanged();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PortsModel::index()\r\n//-----------------------------------------------------------------------------\r\nQModelIndex PortsModel::index(QString const& portName) const\r\n{\r\n\t// find the correct row\r\n    int row = portsInterface_->getItemIndex(portName.toStdString());\r\n\r\n\t// if the named port is not found\r\n\tif (row < 0)\r\n    {\r\n\t\treturn QModelIndex();\r\n\t}\r\n\r\n\t// the base class creates the index for the row\r\n\treturn QAbstractTableModel::index(row, 0, QModelIndex());\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PortsModel::resetModel()\r\n//-----------------------------------------------------------------------------\r\nvoid PortsModel::resetModel()\r\n{\r\n    beginResetModel();\r\n    lockedIndexes_.clear();\r\n    endResetModel();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: portsmodel::resetModelAndLockCurrentPorts()\r\n//-----------------------------------------------------------------------------\r\nvoid PortsModel::resetModelAndLockCurrentPorts()\r\n{\r\n    beginResetModel();\r\n\r\n    lockedIndexes_.clear();\r\n\r\n    endResetModel();\r\n\r\n    for (auto const& portName : getInterface()->getItemNames())\r\n    {\r\n\t\tDirectionTypes::Direction portDirection = DirectionTypes::str2Direction(QString::fromStdString(\r\n\t\t\tportsInterface_->getDirection(portName)), DirectionTypes::DIRECTION_INVALID);\r\n        if (portDirection != DirectionTypes::DIRECTION_PHANTOM)\r\n        {\r\n            lockPort(QString::fromStdString(portName));\r\n        }\r\n    }\r\n\r\n    emit contentChanged();\r\n    emit portCountChanged();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: lockPort()\r\n//-----------------------------------------------------------------------------\r\nvoid PortsModel::lockPort(QString const& portName)\r\n{\r\n    QModelIndex portIndex = index(portName);\r\n    QModelIndexList lockedPortIndexes = getLockedPortIndexes(portIndex);\r\n\r\n    for (auto const& index : lockedPortIndexes)\r\n    {\r\n        if (index.isValid())\r\n        {\r\n            lockIndex(index);\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: unlockPort()\r\n//-----------------------------------------------------------------------------\r\nvoid PortsModel::unlockPort(QString const& portName)\r\n{\r\n    QModelIndex portIndex = index(portName);\r\n    QModelIndexList lockedPortIndexes = getLockedPortIndexes(portIndex);\r\n    for (auto const& index : lockedPortIndexes)\r\n    {\r\n        if (index.isValid())\r\n        {\r\n            unlockIndex(index);\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: lockIndex()\r\n//-----------------------------------------------------------------------------\r\nvoid PortsModel::lockIndex(QModelIndex const& index)\r\n{\r\n    if(!isLocked(index))\r\n    {\r\n        lockedIndexes_.append(QPersistentModelIndex(index));\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: unlockIndex()\r\n//-----------------------------------------------------------------------------\r\nvoid PortsModel::unlockIndex(QModelIndex const& index)\r\n{\r\n    lockedIndexes_.removeAll(QPersistentModelIndex(index));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: isLocked()\r\n//-----------------------------------------------------------------------------\r\nbool PortsModel::isLocked(QModelIndex const& index) const\r\n{\r\n    return lockedIndexes_.contains(QPersistentModelIndex(index));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PortsModel::rowIsLocked()\r\n//-----------------------------------------------------------------------------\r\nbool PortsModel::rowIsLocked(int row) const\r\n{\r\n    QModelIndex nameIndex = QAbstractTableModel::index(row, nameColumn(), QModelIndex());\r\n    return nameIndex.isValid() && isLocked(nameIndex);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: portsmodel::formattedExpressionForIndex()\r\n//-----------------------------------------------------------------------------\r\nQVariant PortsModel::formattedExpressionForIndex(QModelIndex const& index) const\r\n{\r\n    std::string portName(portsInterface_->getIndexedItemName(index.row()));\r\n\r\n    if (index.column() == arrayLeftColumn())\r\n    {\r\n        return QString::fromStdString(portsInterface_->getArrayLeftFormattedExpression(portName));\r\n    }\r\n    else if (index.column() == arrayRightColum())\r\n    {\r\n        return QString::fromStdString(portsInterface_->getArrayRightFormattedExpression(portName));\r\n    }\r\n    else\r\n    {\r\n        return QVariant();\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: portsmodel::expressionForIndex()\r\n//-----------------------------------------------------------------------------\r\nQVariant PortsModel::expressionForIndex(QModelIndex const& index) const\r\n{\r\n    std::string portName(portsInterface_->getIndexedItemName(index.row()));\r\n\r\n    if (index.column() == arrayLeftColumn())\r\n    {\r\n        return QString::fromStdString(portsInterface_->getArrayLeftExpression(portName));\r\n    }\r\n    else if (index.column() == arrayRightColum())\r\n    {\r\n        return QString::fromStdString(portsInterface_->getArrayRightExpression(portName));\r\n    }\r\n    else\r\n    {\r\n        return QVariant();\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: portsmodel::valueForIndex()\r\n//-----------------------------------------------------------------------------\r\nQVariant PortsModel::valueForIndex(QModelIndex const& index) const\r\n{\r\n    std::string portName = portsInterface_->getIndexedItemName(index.row());\r\n\r\n    if (index.column() == nameColumn())\r\n    {\r\n        return QString::fromStdString(portName);\r\n    }\r\n    else if (index.column() == typeColumn())\r\n    {\r\n         return QString::fromStdString(portsInterface_->getTypeName(portName));\r\n    }\r\n    else if (index.column() == arrayLeftColumn())\r\n    {\r\n        return QString::fromStdString(portsInterface_->getArrayLeftValue(portName));\r\n    }\r\n    else if (index.column() == arrayRightColum())\r\n    {\r\n        return QString::fromStdString(portsInterface_->getArrayRightValue(portName));\r\n    }\r\n    else if (index.column() == tagColumn())\r\n    {\r\n        return QString::fromStdString(portsInterface_->getTags(portName));\r\n    }\r\n    else if (index.column() == adHocColumn())\r\n    {\r\n        return portsInterface_->isAdHoc(portName);\r\n    }\r\n    else if (index.column() == descriptionColumn())\r\n    {\r\n        return QString::fromStdString(portsInterface_->getDescription(portName));\r\n    }\r\n    else\r\n    {\r\n        return QVariant();\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: portsmodel::expressionOrValueForIndex()\r\n//-----------------------------------------------------------------------------\r\nQVariant PortsModel::expressionOrValueForIndex(QModelIndex const& index) const\r\n{\r\n    if (index.column() == arrayLeftColumn() || index.column() == arrayRightColum())\r\n    {\r\n        return expressionForIndex(index);\r\n    }\r\n    else\r\n    {\r\n        return valueForIndex(index);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: portsmodel::validateIndex()\r\n//-----------------------------------------------------------------------------\r\nbool PortsModel::validateIndex(QModelIndex const& index) const\r\n{\r\n    std::string portName(portsInterface_->getIndexedItemName(index.row()));\r\n\r\n    if (index.column() == nameColumn())\r\n    {\r\n        return portsInterface_->itemHasValidName(portName);\r\n    }\r\n    else if (index.column() == arrayLeftColumn())\r\n    {\r\n        return portsInterface_->portLeftArrayValueIsValid(portName);\r\n    }\r\n    else if (index.column() == arrayRightColum())\r\n    {\r\n        return portsInterface_->portRightArrayValueIsValid(portName);\r\n    }\r\n    else if (index.column() == typeColumn())\r\n    {\r\n        return portsInterface_->portHasValidTypes(portName);\r\n    }\r\n    else\r\n    {\r\n        return true;\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: portsmodel::getAllReferencesToIdInItemOnRow()\r\n//-----------------------------------------------------------------------------\r\nint PortsModel::getAllReferencesToIdInItemOnRow(const int& row, QString const& valueID) const\r\n{\r\n    return portsInterface_->getAllReferencesToIdInItem(\r\n        portsInterface_->getIndexedItemName(row), valueID.toStdString());\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: portsmodel::getInterface()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<PortsInterface> PortsModel::getInterface() const\r\n{\r\n    return portsInterface_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: portsmodel::getIconPath()\r\n//-----------------------------------------------------------------------------\r\nQString PortsModel::getIconPath(int const& portIndex) const\r\n{\r\n    std::string portName(getInterface()->getIndexedItemName(portIndex));\r\n    std::string iconPath(getInterface()->getIconPathForPort(portName));\r\n    return QString::fromStdString(iconPath);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: portsmodel::onCreatePortsFromAbstraction()\r\n//-----------------------------------------------------------------------------\r\nvoid PortsModel::onCreatePortsFromAbstraction(QSharedPointer<const AbstractionDefinition> abstraction,\r\n    General::InterfaceMode const& busMode, General::InterfaceMode const& busMonitorMode,\r\n    QString const& systemGroup)\r\n{\r\n    beginResetModel();\r\n\r\n    signalInterface_->setAbsDef(abstraction);\r\n    General::InterfaceMode busInterfaceMode = busMode;\r\n    if (busInterfaceMode == General::MONITOR)\r\n    {\r\n        busInterfaceMode = busMonitorMode;\r\n    }\r\n\r\n    for (int signalIndex = 0; signalIndex < signalInterface_->itemCount(); ++signalIndex)\r\n    {\r\n        if (modesMatch(busInterfaceMode, systemGroup, signalInterface_->getMode(signalIndex),\r\n            QString::fromStdString(signalInterface_->getSystemGroup(signalIndex))))\r\n        {\r\n            std::string portName = signalInterface_->getIndexedItemName(signalIndex);\r\n\r\n            if (signalInterface_->portIsWire(portName))\r\n            {\r\n                portsInterface_->addWirePort(portName);\r\n\r\n                int portIndex = portsInterface_->itemCount() - 1;\r\n                portName = portsInterface_->getIndexedItemName(portIndex);\r\n\r\n                portsInterface_->setDirection(portName, DirectionTypes::direction2Str(getDirectionFromSignal(\r\n                    busInterfaceMode, signalInterface_->getDirection(signalIndex))).toStdString());\r\n\r\n                quint64 leftBound = 0;\r\n                bool signalIntegerOk = false;\r\n                quint64 signalWidth =\r\n                    QString::fromStdString(signalInterface_->getWidthValue(signalIndex)).toULongLong(&signalIntegerOk);\r\n                if (signalIntegerOk == true && signalWidth > 0)\r\n                {\r\n                    leftBound = signalWidth - 1;\r\n                }\r\n\r\n                portsInterface_->setLeftBound(portName, QString::number(leftBound).toStdString());\r\n                portsInterface_->setRightBound(portName, \"0\");\r\n\r\n                portsInterface_->setDefaultValue(portName, signalInterface_->getDefaultValueExpression(signalIndex));\r\n            }\r\n            else if (signalInterface_->portIsTransactional(portName))\r\n            {\r\n                portsInterface_->addTransactionalPort(portName);\r\n\r\n                int portIndex = portsInterface_->itemCount() - 1;\r\n                portName = portsInterface_->getIndexedItemName(portIndex);\r\n\r\n                portsInterface_->setInitiative(portName, getInitiativeFromSignal(busInterfaceMode,\r\n                    QString::fromStdString(signalInterface_->getInitiative(signalIndex))).toStdString());\r\n                portsInterface_->setKind(portName, signalInterface_->getKind(signalIndex));\r\n                portsInterface_->setBusWidth(portName, signalInterface_->getBusWidthExpression(signalIndex));\r\n            }\r\n\r\n            portsInterface_->setDescription(portName, signalInterface_->getDescription(portName));\r\n        }\r\n    }\r\n\r\n    endResetModel();\r\n\r\n    emit invalidateOtherFilter();\r\n    emit portCountChanged();\r\n    emit contentChanged();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: portsmodel::modesMatch()\r\n//-----------------------------------------------------------------------------\r\nbool PortsModel::modesMatch(General::InterfaceMode const& busMode, QString const& busSystemGroup,\r\n    General::InterfaceMode const& signalMode, QString const& signalSystemGroup) const\r\n{\r\n    return ((busMode == General::MASTER || busMode == General::MIRRORED_MASTER) && signalMode == General::MASTER) ||\r\n        ((busMode == General::INITIATOR || busMode == General::MIRRORED_INITIATOR) && signalMode == General::INITIATOR) ||\r\n        ((busMode == General::SLAVE || busMode == General::MIRRORED_SLAVE) && signalMode == General::SLAVE) ||\r\n        ((busMode == General::TARGET || busMode == General::MIRRORED_TARGET) && signalMode == General::TARGET) ||\r\n        ((busMode == General::SYSTEM || busMode == General::MIRRORED_SYSTEM) && signalMode == General::SYSTEM &&\r\n            busSystemGroup == signalSystemGroup);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: portsmodel::getSignalDirection()\r\n//-----------------------------------------------------------------------------\r\nDirectionTypes::Direction PortsModel::getDirectionFromSignal(General::InterfaceMode const& busMode,\r\n    DirectionTypes::Direction const& signalDirection) const\r\n{\r\n    if (busMode == General::MIRRORED_MASTER || busMode == General::MIRRORED_SLAVE ||\r\n        busMode == General::MIRRORED_SYSTEM)\r\n    {\r\n        return DirectionTypes::convert2Mirrored(signalDirection);\r\n    }\r\n    else\r\n    {\r\n        return signalDirection;\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: portsmodel::getInitiativeFromSignal()\r\n//-----------------------------------------------------------------------------\r\nQString PortsModel::getInitiativeFromSignal(General::InterfaceMode const& busMode, QString const& signalInitiative)\r\nconst\r\n{\r\n    if (busMode == General::MIRRORED_MASTER || busMode == General::MIRRORED_SLAVE ||\r\n        busMode == General::MIRRORED_SYSTEM)\r\n    {\r\n        return TransactionalTypes::initiativeToString(TransactionalTypes::convertToMirrored(signalInitiative));\r\n    }\r\n    else\r\n    {\r\n        return signalInitiative;\r\n    }\r\n}\r\n"
  },
  {
    "path": "editors/ComponentEditor/ports/portsmodel.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: portsmodel.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 31.3.2011\r\n//\r\n// Description:\r\n// Table model that can be used to display ports to be edited.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef PORTSMODEL_H\r\n#define PORTSMODEL_H\r\n\r\n#include <QSharedPointer>\r\n#include <QString>\r\n#include <QList>\r\n\r\n#include <editors/ComponentEditor/common/ParameterizableTable.h>\r\n#include <editors/ComponentEditor/common/ReferencingTableModel.h>\r\n\r\n#include <IPXACTmodels/generaldeclarations.h>\r\n#include <IPXACTmodels/common/DirectionTypes.h>\r\n\r\n#include <QSortFilterProxyModel>\r\n\r\nclass AbstractionDefinition;\r\nclass PortAbstractionInterface;\r\nclass PortsInterface;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Table model that can be used to display ports to be edited.\r\n//-----------------------------------------------------------------------------\r\nclass PortsModel : public ReferencingTableModel, public ParameterizableTable\r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\r\n\t/*!\r\n     *  The constructor.\r\n\t *\r\n     *    @param [in] parameterFinder     Pointer to the parameter finder.\r\n     *    @param [in] portInterface       Interface for accessing the component ports.\r\n     *    @param [in] signalInterface     Interface for accessing abstraction signals.\r\n\t *    @param [in] parent              Pointer to the owner of this model.\r\n     */\r\n    PortsModel(QSharedPointer<ParameterFinder> parameterFinder,\r\n        QSharedPointer<PortsInterface> portInterface,\r\n        QSharedPointer<PortAbstractionInterface> signalInterface,\r\n        QObject *parent);\r\n\r\n\t/*!\r\n     *  The destructor.\r\n     */\r\n\tvirtual ~PortsModel() = default;\r\n\r\n\t/*!\r\n     *  Get the number of rows in the model.\r\n\t *\r\n\t *    @param [in] parent      Model index of the parent of the item. Must be invalid.\r\n\t *\r\n\t *    @return Number of rows currently in the model.\r\n     */\r\n\tvirtual int rowCount(const QModelIndex& parent = QModelIndex() ) const;\r\n\r\n\t/*!\r\n     *  Get the data for the specified item for specified role.\r\n\t *\r\n\t *    @param [in] index   Identifies the item that's data is wanted.\r\n\t *    @param [in] role    Specifies what kind of data is wanted\r\n\t *\r\n\t *    @return QVariant containing the data\r\n     */\r\n\tvirtual QVariant data(const QModelIndex& index, int role = Qt::DisplayRole ) const;\r\n\r\n\t/*!\r\n     *  Get the data for the headers.\r\n\t *\r\n\t *    @param [in] section         The column that's header is wanted\r\n\t *    @param [in] orientation     Only Qt::Horizontal is supported\r\n\t *    @param [in] role            Specified the type of data that is wanted.\r\n\t *\r\n\t *    @return QVariant containing the data to be displayed.\r\n\t */\r\n\tvirtual QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole ) const;\r\n\r\n\t/*!\r\n     *  Set the data for specified item.\r\n\t *\r\n\t *    @param [in] index   Specifies the item that's data is modified\r\n\t *    @param [in] value   The value to be set.\r\n\t *    @param [in] role    The role that is trying to modify the data. Only Qt::EditRole is supported.\r\n\t *\r\n\t *    @return True if data was successfully set.\r\n\t */\r\n\tvirtual bool setData(QModelIndex const& index, QVariant const& value, int role = Qt::EditRole);\r\n\r\n\t/*!\r\n     *  Get information on how specified item can be handled.\r\n\t *\r\n\t *    @param [in]     index Specifies the item that's flags are wanted.\r\n\t *\r\n\t *    @return Qt::ItemFlags that define how object can be handled.\r\n\t*/\r\n\tvirtual Qt::ItemFlags flags(const QModelIndex& index) const;\r\n\r\n\t/*!\r\n     *  Check if the model is in valid state or not.\r\n\t *\r\n\t *    @return True if all items in model are valid.\r\n     */\r\n\tbool isValid() const;\r\n\r\n\t/*!\r\n     *  Get the index of the identified port.\r\n\t *\r\n\t *    @param [in] portName    Name of the identified port.\r\n\t *\r\n\t *    @return QModelIndex of first column of the specified port. Invalid index if named port is not found.\r\n     */\r\n    virtual QModelIndex index(QString const& portName) const;\r\n\r\n    /*!\r\n     *  Reset the model.\r\n     */\r\n    void resetModel();\r\n\r\n    /*!\r\n     *  Sets the edited model and locks all current ports.\r\n     */\r\n    void resetModelAndLockCurrentPorts();\r\n\r\n    /*!\r\n     *  Handle port creation from abstraction definition signals.\r\n     *\r\n     *    @param [in] abstraction     The selected abstraction definition.\r\n     *    @param [in] busMode         Interface mode of the selected bus interface.\r\n     *    @param [in] busMonitorMode  Monitored bus interface of the selected bus interface.\r\n     *    @param [in] systemGroup     System group of the selected bus interface.\r\n     */\r\n    void onCreatePortsFromAbstraction(QSharedPointer<const AbstractionDefinition> abstraction,\r\n        General::InterfaceMode const& busMode,\r\n        General::InterfaceMode const& busMonitorMode,\r\n        QString const& systemGroup);\r\n\r\n    //! No copying. No assignment.\r\n    PortsModel(const PortsModel& other) = delete;\r\n    PortsModel& operator=(const PortsModel& other) = delete;\r\n\r\nprotected:\r\n\r\n    /*!\r\n     *  Get the used port interface.\r\n     *\r\n     *    @return The port interface.\r\n     */\r\n    QSharedPointer<PortsInterface> getInterface() const;\r\n\r\n    /*!\r\n     *  Check if the column index is valid for containing expressions.\r\n     *\r\n     *    @param [in] index   The index being evaluated.\r\n     *\r\n     *      return      True, if column can have expressions, false otherwise.\r\n     */\r\n    virtual bool isValidExpressionColumn(QModelIndex const& index) const override = 0;\r\n\r\n    virtual bool isPortTypeColumn(QModelIndex const& index) const = 0;\r\n\r\n    /*!\r\n     *  Gets the expression for the given index, or plain value if there is no expression.\r\n     *\r\n     *    @param [in] index   The index of target data.\r\n     *\r\n     *      return      Expression in the given index, or plain value.\r\n     */\r\n    virtual QVariant expressionOrValueForIndex(QModelIndex const& index) const override;\r\n\r\n    /*!\r\n     *  Get the formatted value of an expression in the selected index.\r\n     *\r\n     *    @param [in] index   The selected index.\r\n     *\r\n     *    @return The formatted value of an expression in the selected index.\r\n     */\r\n    virtual QVariant formattedExpressionForIndex(QModelIndex const& index) const = 0;\r\n\r\n    /*!\r\n     *  Get the expression of the selected index.\r\n     *\r\n     *    @param [in] index   The selected index.\r\n     *\r\n     *    @return The expression of the selected index.\r\n     */\r\n    virtual QVariant expressionForIndex(QModelIndex const& index) const;\r\n\r\n    /*!\r\n     *  Gets the value for the given index.\r\n     *\r\n     *    @param [in] index   The index of target data.\r\n     *\r\n     *      return      The data in the given index.\r\n     */\r\n    virtual QVariant valueForIndex(QModelIndex const& index) const;\r\n\r\n    /*!\r\n     *  Validates the data in the cell given by the column.\r\n     *\r\n     *    @param [in] index   The index being validated.\r\n     *\r\n     *      return      True, if the data in the parameter is valid, false otherwise.\r\n     */\r\n    virtual bool validateIndex(QModelIndex const& index) const override;\r\n\r\n    /*!\r\n     *  Get all the references made to the selected parameter from the selected row.\r\n     *\r\n     *    @param [in] row         The selected row.\r\n     *    @param [in] valueID     The target parameter.\r\n     *\r\n     *    @return Number of references made to the selected id from the selected row.\r\n     */\r\n    virtual int getAllReferencesToIdInItemOnRow(const int& row, QString const&  valueID) const override;\r\n\r\n    /*!\r\n     *   Checks if given index is locked.\r\n     *\r\n     *    @param [in] index   The index to check.\r\n     *\r\n     *    @return True if the index is locked, otherwise false.\r\n     */\r\n    bool isLocked(QModelIndex const& index) const;\r\n\r\n    /*!\r\n     *  Get the icon path of the selected index.\r\n     *\r\n     *    @param [in] portIndex   The selected index.\r\n     *\r\n     *    @return The icon path for the selected index.\r\n     */\r\n    QString getIconPath(int const& portIndex) const;\r\n\r\npublic slots:\r\n\r\n\t/*!\r\n     *  Remove a row from the model.\r\n\t *\r\n\t *    @param [in] row Specifies the row to remove\r\n     */\r\n\tvoid onRemoveRow(int row);\r\n    \r\n\r\n\t/*!\r\n     *  Add a new empty row to the model\r\n     */\r\n\tvoid onAddRow();\r\n\r\n\t/*!\r\n     *  A new item should be added to given index.\r\n\t *\r\n\t *    @param [in] index   The position where new item should be added at.\r\n     */\r\n\tvoid onAddItem(const QModelIndex& index);\r\n\r\n\t/*!\r\n     *  An item should be removed from the model.\r\n\t * \r\n\t *    @param [in] index   Identifies the item that should be removed.\r\n     */\r\n\tvoid onRemoveItem(const QModelIndex& index);\r\n\r\nsignals:\r\n\r\n\t/*!\r\n     *  Emitted when contents of the model change\r\n     */\r\n\tvoid contentChanged();\r\n\r\n\t/*!\r\n     *  Prints an error message to the user.\r\n     */\r\n\tvoid errorMessage(const QString& msg) const;\r\n\t\r\n\t/*!\r\n     *  Prints a notification to user.\r\n     */\r\n\tvoid noticeMessage(const QString& msg) const;\r\n\r\n    /*!\r\n     *  Change the vendor extensions editor data.\r\n     *\r\n     *    @param [in] index   Index of the selected port.\r\n     */\r\n    void portExtensionDataChanged(QModelIndex const& index);\r\n\r\n    /*!\r\n     *  Invalidate the filter in the other ports model.\r\n     */\r\n    void invalidateOtherFilter();\r\n\r\n    /*!\r\n     *  Inform of a change in the amount of editable ports.\r\n     */\r\n    void portCountChanged();\r\n\r\nprivate:\r\n\r\n    /*!\r\n     *  Get the column for row number.\r\n     *\r\n     *    @return Row number column.\r\n     */\r\n    virtual int rowNumberColumn() const = 0;\r\n\r\n    /*!\r\n     *  Get the column for name.\r\n     *\r\n     *    @return Name column.\r\n     */\r\n    virtual int nameColumn() const = 0;\r\n\r\n    /*!\r\n     *  Get the column for type definitions.\r\n     *\r\n     *    @return Type definitions column.\r\n     */\r\n    virtual int typeColumn() const = 0;\r\n\r\n    /*!\r\n     *  Get the column for array left.\r\n     *\r\n     *    @return Array left column.\r\n     */\r\n    virtual int arrayLeftColumn() const = 0;\r\n\r\n    /*!\r\n     *  Get the column for array right.\r\n     *\r\n     *    @return Array right column.\r\n     */\r\n    virtual int arrayRightColum() const = 0;\r\n\r\n    /*!\r\n     *  Get the column for tags.\r\n     *\r\n     *    @return Tags column.\r\n     */\r\n    virtual int tagColumn() const = 0;\r\n\r\n    /*!\r\n     *  Get the column for ad hoc visibility.\r\n     *\r\n     *    @return Ad hoc visibility column.\r\n     */\r\n    virtual int adHocColumn() const = 0;\r\n\r\n    /*!\r\n     *  Get the column for description.\r\n     *\r\n     *    @return Description column.\r\n     */\r\n    virtual int descriptionColumn() const = 0;\r\n\r\n    /*!\r\n     *  Check if the selected item is disabled.\r\n     *\r\n     *    @param [in] index           Index of the selected item.\r\n     *\r\n     *    @return True, if the indexed item is disabled, false otherwise.\r\n     */\r\n    virtual bool indexedItemIsDisabled(QModelIndex const& index) const = 0;\r\n\r\n    /*!\r\n     *  Check if the selected item is mandatory.\r\n     *\r\n     *    @param [in] index   Index of the selected item.\r\n     *\r\n     *    @return True, if the indexed item is mandatory, false otherwise.\r\n     */\r\n    virtual bool indexedItemIsMandatory(QModelIndex const& index) const = 0;\r\n\r\n    /*!\r\n     *  Check if the selected item is locked.\r\n     *\r\n     *    @param [in] index   Index of the selected item.\r\n     *\r\n     *    @return True, if the indexed item is locked, false otherwise.\r\n     */\r\n    virtual bool indexedItemIsLocked(QModelIndex const& index) const = 0;\r\n\r\n    /*!\r\n     *  Get a list of the locked port indexes from the selected index.\r\n     *\r\n     *    @param [in] portIndex   Index of the selected item.\r\n     *\r\n     *    @return List of the locked port indexes.\r\n     */\r\n    virtual QModelIndexList getLockedPortIndexes(QModelIndex const& portIndex) const = 0;\r\n\r\n    /*!\r\n     *  Add a new wire or transactional port.\r\n     *\r\n     *    @param [in] port    The selected port.\r\n     */\r\n    virtual void addNewPort() = 0;\r\n\r\n    /*!\r\n     *   Locks the name, direction  and type columns of a port.\r\n     *\r\n     *    @param [in] portName    Name of the selected port.\r\n     */\r\n    void lockPort(QString const& portName);\r\n\r\n    /*!\r\n     *   Unlocks the name, direction and type columns of a port.\r\n     *\r\n     *    @param [in] portName    Name of the selected port.\r\n     */\r\n    void unlockPort(QString const& portName);\r\n\r\n    /*!\r\n     *   Locks the given index disabling editing.\r\n     *\r\n     *    @param [in] index   The index to lock.\r\n     */\r\n    void lockIndex(QModelIndex const& index);\r\n    \r\n    /*!\r\n     *   Unlocks the given index disabling editing.\r\n     *\r\n     *    @param [in] index   The index to unlock.\r\n     */\r\n    void unlockIndex(QModelIndex const& index);\r\n\r\n    /*!\r\n     *   Checks if given row is locked.\r\n     *\r\n     *    @param [in] row   The row to check.\r\n\t *\r\n\t *    @return True if the row is locked, otherwise false.\r\n     */\r\n    bool rowIsLocked(int row) const;\r\n\r\n    /*!\r\n     *  Check if the selected interface modes match.\r\n     *\r\n     *    @param [in] busMode             Interface mode of the selected bus interface.\r\n     *    @param [in] busSystemGroup      System group of the selected bus interface.\r\n     *    @param [in] signalMode          Interface mode of the selected signal.\r\n     *    @param [in] signalSystemGroup   System group of the selected signal.\r\n     *\r\n     *    @return True, if the interface modes match, false otherwise.\r\n     */\r\n    bool modesMatch(General::InterfaceMode const& busMode, QString const& busSystemGroup,\r\n        General::InterfaceMode const& signalMode, QString const& signalSystemGroup) const;\r\n\r\n    /*!\r\n     *  Get the direction for a port created from a signal.\r\n     *\r\n     *    @param [in] busMode             Interface mode of the selected bus interface.\r\n     *    @param [in] signalDirection     Direction of the selected signal.\r\n     *\r\n     *    @return Direction for the port created from the selected signal.\r\n     */\r\n    DirectionTypes::Direction getDirectionFromSignal(General::InterfaceMode const& busMode,\r\n        DirectionTypes::Direction const& signalDirection) const;\r\n\r\n    /*!\r\n     *  Get the initiative for a port created from a signal.\r\n     *\r\n     *    @param [in] busMode             Interface mode of the selected bus interface.\r\n     *    @param [in] signalInitiative    Initiative of the selected signal.\r\n     *\r\n     *    @return Initiative for the port created from the selected signal.\r\n     */\r\n    QString getInitiativeFromSignal(General::InterfaceMode const& busMode, QString const& signalInitiative) const;\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! Interface for accessing the component ports.\r\n    QSharedPointer<PortsInterface> portsInterface_;\r\n\r\n    //! Interface for accessing abstraction signals.\r\n    QSharedPointer<PortAbstractionInterface> signalInterface_;\r\n\r\n    //! The locked indexes that cannot be edited.\r\n    QList<QPersistentModelIndex> lockedIndexes_;\r\n};\r\n\r\n#endif // PORTSMODEL_H\r\n"
  },
  {
    "path": "editors/ComponentEditor/powerDomains/PowerDomainColumns.h",
    "content": "//-----------------------------------------------------------------------------\n// File: OtherClockDriverColumns.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Esko Pekkarinen\n// Date: 16.10.2015\n//\n// Description:\n// Common declarations for editing otherClockDrivers.\n//-----------------------------------------------------------------------------\n\nnamespace PowerDomainColumns\n{\n    //! The columns for otherClockDriver table.\n    enum Columns\n    {\n        NAME = 0,\n        DISPLAY_NAME,\n        ALWAYS_ON,\n        SUBDOMAIN,\n        SHORT_DESCRIPTION,\n        DESCRIPTION,\n        COLUMN_COUNT\n    };\n}\n"
  },
  {
    "path": "editors/ComponentEditor/powerDomains/PowerDomainsDelegate.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: PowerDomainsDelegate.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Esko Pekkarinen\n// Date: 5.10.2023\n//\n// Description:\n// The delegate that provides editors to edit PowerDomains of a component.\n//-----------------------------------------------------------------------------\n\n#include \"PowerDomainsDelegate.h\"\n\n#include \"PowerDomainColumns.h\"\n\n#include <editors/ComponentEditor/common/ReferenceSelector/ReferenceSelector.h>\n\n#include <IPXACTmodels/Component/PowerDomain.h>\n\n#include <QApplication>\n#include <QMouseEvent>\n#include <QPainter>\n\n//-----------------------------------------------------------------------------\n// Function: PowerDomainsDelegate::PowerDomainsDelegate()\n//-----------------------------------------------------------------------------\nPowerDomainsDelegate::PowerDomainsDelegate(QSharedPointer<QList<QSharedPointer<PowerDomain> > > powerDomains,\n    QAbstractItemModel* completionModel,\n    QSharedPointer<ParameterFinder> parameterFinder,\n    QObject* parent):\nExpressionDelegate(completionModel, parameterFinder, parent),\npowerDomains_(powerDomains)\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: PowerDomainsDelegate::createEditor()\n//-----------------------------------------------------------------------------\nQWidget* PowerDomainsDelegate::createEditor(QWidget * parent, QStyleOptionViewItem const& option,\n    QModelIndex const& index) const\n{\n    if (index.column() == PowerDomainColumns::SUBDOMAIN)\n    {\n        auto editor = new ReferenceSelector(parent);\n\n        QStringList domainNames;\n        for (auto const& domain : *powerDomains_)\n        {\n            domainNames.append(domain->name());\n        }\n        \n        domainNames.removeAll(index.siblingAtColumn(PowerDomainColumns::NAME).data().toString());\n\n        editor->addItem(QString());\n        editor->addItems(domainNames);\n\n\n        return editor;\n    }\n\n    return ExpressionDelegate::createEditor(parent, option, index);\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: PowerDomainsDelegate::setEditorData()\n//-----------------------------------------------------------------------------\nvoid PowerDomainsDelegate::setEditorData(QWidget * editor, QModelIndex const& index) const\n{\n    if (index.column() == PowerDomainColumns::SUBDOMAIN)\n    {\n        auto domainEditor = qobject_cast<ReferenceSelector*>(editor);\n        domainEditor->setCurrentText(index.data().toString());\n    }\n    else\n    {\n        ExpressionDelegate::setEditorData(editor, index);\n    }\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: PowerDomainsDelegate::setModelData()\n//-----------------------------------------------------------------------------\nvoid PowerDomainsDelegate::setModelData(QWidget* editor, QAbstractItemModel * model, QModelIndex const& index) const\n{\n    if (index.column() == PowerDomainColumns::SUBDOMAIN)\n    {\n        auto domainEditor = qobject_cast<ReferenceSelector*>(editor);\n        model->setData(index, domainEditor->currentText(), Qt::EditRole);\n    }\n    else\n    {\n        ExpressionDelegate::setModelData(editor, model, index);\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: PowerDomainsDelegate::columnAcceptsExpression()\n//-----------------------------------------------------------------------------\nbool PowerDomainsDelegate::columnAcceptsExpression(int column) const\n{\n    return column == PowerDomainColumns::ALWAYS_ON;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PowerDomainsDelegate::descriptionColumn()\n//-----------------------------------------------------------------------------\nint PowerDomainsDelegate::descriptionColumn() const\n{\n    return PowerDomainColumns::DESCRIPTION;\n}\n"
  },
  {
    "path": "editors/ComponentEditor/powerDomains/PowerDomainsDelegate.h",
    "content": "//-----------------------------------------------------------------------------\n// File: PowerDomainsDelegate.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Esko Pekkarinen\n// Date: 5.10.2023\n//\n// Description:\n// The delegate that provides editors to edit PowerDomains of a component.\n//-----------------------------------------------------------------------------\n\n#ifndef POWERDOMAINSDELEGATE_H\n#define POWERDOMAINSDELEGATE_H\n\n#include <editors/ComponentEditor/common/ExpressionDelegate.h>\n\n#include <IPXACTmodels/Component/PowerDomain.h>\n\n\n//-----------------------------------------------------------------------------\n//! The delegate that provides editors to edit PowerDomains of a component.\n//-----------------------------------------------------------------------------\nclass PowerDomainsDelegate : public ExpressionDelegate\n{\n\tQ_OBJECT\n\npublic:\n\n    /*!\n     *  The constructor.\n     *\n     *    @param [in] component           Component containing the edited PowerDomains.\n     *    @param [in] completionModel     Model containing the completions used in expression editor.\n     *    @param [in] parameterFinder     The parameter finder to use for for expression editor.\n     *    @param [in] parent              The parent object.\n     */\n\tPowerDomainsDelegate(QSharedPointer<QList<QSharedPointer<PowerDomain> > > powerDomains, \n        QAbstractItemModel* completionModel,\n        QSharedPointer<ParameterFinder> parameterFinder,\n        QObject* parent = nullptr);\n\t\n\t/*!\n     *  The destructor.\n     */\n\tvirtual ~PowerDomainsDelegate() = default;\n\n    // Disable copying.\n    PowerDomainsDelegate(PowerDomainsDelegate const& rhs) = delete;\n    PowerDomainsDelegate& operator=(PowerDomainsDelegate const& rhs) = delete;\n\n\t/*!\n     *  Create a new editor for the given item\n\t *\n\t *    @param [in] parent  Owner for the editor.\n\t *    @param [in] option  Contains options for the editor.\n\t *    @param [in] index   Model index identifying the item.\n\t *\n\t *    @return The editor to be used to edit the item.\n     */\n\tvirtual QWidget* createEditor(QWidget* parent, QStyleOptionViewItem const& option, QModelIndex const& index)\n        const;\n\n\t/*!\n     *  Set the data for the editor.\n\t *\n\t *    @param [in] editor  The editor where the data is to be set.\n\t *    @param [in] index   Model index identifying the item that's data is to be set.\n     */\n\tvirtual void setEditorData(QWidget* editor, QModelIndex const& index) const;\n\n\t/*!\n     *  Save the data from the editor to the model.\n\t *\n\t *    @param [in] editor  The editor that contains the data to store.\n\t *    @param [in] model   Model that contains the data structure where data is to be saved to.\n\t *    @param [in] index   Model index identifying the item that's data is to be saved.\n     */\n\tvirtual void setModelData(QWidget* editor, QAbstractItemModel* model, \n\t\tQModelIndex const& index) const;\n\n\nsignals:\n\n    /*!\n     *  Transmits changes in the content.\n     */\n    void contentChanged();\n\nprotected:\n    \n\n    \n    /*!\n     *  Checks if the given column supPowerDomains expressions in the editor.\n     *\n     *    @param [in] column   The column to check.\n     *\n     *    @return True, if the cells in the column allow expressions, otherwise false.\n     */\n    virtual bool columnAcceptsExpression(int column) const;\n\n    /*!\n     *  Gets the description column.\n     *\n     *    @return Description column index.\n     */\n    virtual int descriptionColumn() const;\n\nprivate:\n\n\n\n    //-----------------------------------------------------------------------------\n    // Data.\n    //-----------------------------------------------------------------------------\n\n    //! Component containing the PowerDomains.\n    QSharedPointer<QList<QSharedPointer<PowerDomain> > > powerDomains_ = nullptr;\n\n};\n\n#endif // POWERDOMAINSDELEGATE_H\n"
  },
  {
    "path": "editors/ComponentEditor/powerDomains/PowerDomainsEditor.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: PowerDomainsEditor.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Esko Pekkarinen\n// Date: 5.10.2023\n//\n// Description:\n// Editor for power domains of a component.\n//-----------------------------------------------------------------------------\n\n#include \"PowerDomainsEditor.h\"\n\n#include \"PowerDomainsDelegate.h\"\n\n#include <editors/ComponentEditor/parameters/ComponentParameterModel.h>\n\n#include <common/widgets/summaryLabel/summarylabel.h>\n\n#include <KactusAPI/include/LibraryInterface.h>\n\n#include <IPXACTmodels/Component/Component.h>\n\n#include <QVBoxLayout>\n\n//-----------------------------------------------------------------------------\n// Function: PowerDomainsEditor::PowerDomainsEditor()\n//-----------------------------------------------------------------------------\nPowerDomainsEditor::PowerDomainsEditor(QSharedPointer<Component> component, LibraryInterface* handler,\n    QSharedPointer<PowerDomainValidator > validator,\n\tExpressionSet expressions,\n\tQWidget *parent):\nItemEditor(component, handler, parent),\nview_(this),\nmodel_(component, validator, expressions, this)\n{\n    connect(&model_, SIGNAL(contentChanged()), this, SIGNAL(contentChanged()), Qt::UniqueConnection);\n    connect(&model_, SIGNAL(dataChanged(const QModelIndex&, const QModelIndex&)),\n        this, SIGNAL(contentChanged()), Qt::UniqueConnection);\n    connect(&model_, SIGNAL(errorMessage(const QString&)),\n        this, SIGNAL(errorMessage(const QString&)), Qt::UniqueConnection);\n\tconnect(&model_, SIGNAL(noticeMessage(const QString&)),\n        this, SIGNAL(noticeMessage(const QString&)), Qt::UniqueConnection);\n\tconnect(&view_, SIGNAL(addItem(const QModelIndex&)),\n\t\t&model_, SLOT(onAddItem(const QModelIndex&)), Qt::UniqueConnection);\n\tconnect(&view_, SIGNAL(removeItem(const QModelIndex&)),\n\t\t&model_, SLOT(onRemoveItem(const QModelIndex&)), Qt::UniqueConnection);\n\n\tconst QString componentPath = handler->getDirectoryPath(component->getVlnv());\n\tQString defaultPath = QString(\"%1/powerDomainsListing.csv\").arg(componentPath);\n\tview_.setDefaultImportExportPath(defaultPath);\n\tview_.setAllowImportExport(true);\n\n\n    auto completionModel = new ComponentParameterModel(expressions.finder, this);\n    completionModel->setExpressionParser(expressions.parser);\n\n\tview_.setSortingEnabled(true);\n\tview_.setItemsDraggable(false);\n\n    auto delegate = new PowerDomainsDelegate(component->getPowerDomains(), completionModel, expressions.finder,\n        this);\n\tview_.setItemDelegate(delegate);\n\n\t// Set proxy to do the sorting automatically.\n\tproxy_ = new QSortFilterProxyModel(this);\t\n\tproxy_->setSourceModel(&model_);\n\tview_.setModel(proxy_);\n\n    // Set case-insensitive sorting.\n    proxy_->setSortCaseSensitivity(Qt::CaseInsensitive);\n\n\t// sort the view\n\tview_.sortByColumn(0, Qt::AscendingOrder);\n\n    connect(delegate, SIGNAL(increaseReferences(QString const&)),\n        this, SIGNAL(increaseReferences(QString const&)), Qt::UniqueConnection);\n    connect(delegate, SIGNAL(decreaseReferences(QString const&)),\n        this, SIGNAL(decreaseReferences(QString const&)), Qt::UniqueConnection);;\n\n    connect(&model_, SIGNAL(decreaseReferences(QString)),\n        this, SIGNAL(decreaseReferences(QString)), Qt::UniqueConnection);\n    connect(&model_, SIGNAL(increaseReferences(QString)),\n        this, SIGNAL(increaseReferences(QString)), Qt::UniqueConnection);\n\n\tsetupLayout();\n\n\tPowerDomainsEditor::refresh();\n}\n\n//-----------------------------------------------------------------------------\n// Function: PowerDomainsEditor::refresh()\n//-----------------------------------------------------------------------------\nvoid PowerDomainsEditor::refresh()\n{\n\tview_.update();\n}\n\n//-----------------------------------------------------------------------------\n// Function: PowerDomainsEditor::showEvent()\n//-----------------------------------------------------------------------------\nvoid PowerDomainsEditor::showEvent(QShowEvent* event)\n{\n\tQWidget::showEvent(event);\n\temit helpUrlRequested(\"componenteditor/powerdomains2022.html\");\n}\n\n//-----------------------------------------------------------------------------\n// Function: PowerDomainsEditor::setupLayout()\n//-----------------------------------------------------------------------------\nvoid PowerDomainsEditor::setupLayout()\n{\n    // Display a label on top the table.\n    auto summaryLabel = new SummaryLabel(tr(\"Power domains\"), this);\n\n    auto layout = new QVBoxLayout(this);\n    layout->addWidget(summaryLabel, 0, Qt::AlignCenter);\n    layout->addWidget(&view_);\n    layout->setContentsMargins(0, 0, 0, 0);\n}\n"
  },
  {
    "path": "editors/ComponentEditor/powerDomains/PowerDomainsEditor.h",
    "content": "//-----------------------------------------------------------------------------\n// File: PowerDomainsEditor.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Esko Pekkarinen\n// Date: 5.10.2023\n//\n// Description:\n// Editor for power domains of a component.\n//-----------------------------------------------------------------------------\n\n#ifndef POWERDOMAINSEDITOR_H\n#define POWERDOMAINSEDITOR_H\n\n#include <editors/ComponentEditor/itemeditor.h>\n#include <editors/common/ExpressionSet.h>\n\n#include <common/views/EditableTableView/editabletableview.h>\n\n#include \"PowerDomainsModel.h\"\n\n#include <QSortFilterProxyModel>\n#include <QSharedPointer>\n\nclass Component;\nclass LibraryInterface;\nclass OtherClockDriverValidator;\n\n//-----------------------------------------------------------------------------\n//! Editor for power domains of a component.\n//-----------------------------------------------------------------------------\nclass PowerDomainsEditor : public ItemEditor\n{\n\tQ_OBJECT\n\npublic:\n\n\t/*!\n     *  The constructor\n\t *\n\t *    @param [in] component       The component being edited.\n\t *    @param [in] handler         The instance managing the library.\n     *    @param [in] validator\t\tThe validator used for power domains.\n     *    @param [in] expressions\t\tThe collection of objects for expression handling.\n\t *    @param [in] parent          The owner of this widget.\n\t *\n\t */\n\tPowerDomainsEditor(QSharedPointer<Component> component, LibraryInterface* handler,\n\t\tQSharedPointer<PowerDomainValidator > validator,\n\t\tExpressionSet expressions,\n\t\tQWidget *parent = nullptr);\n\t\n\t//! The destructor.\n\tvirtual ~PowerDomainsEditor() = default;\n\n    //! No copying.\n    PowerDomainsEditor(const PowerDomainsEditor& other) = delete;\n\tPowerDomainsEditor& operator=(const PowerDomainsEditor& other) = delete;\n\n\t/*!\n     *  Reload the information from the model to the editor.\n\t */\n\tvirtual void refresh();\n\n\nprotected:\n\n\t//! Handler for widget's show event.\n\tvirtual void showEvent(QShowEvent* event);\n\nprivate:\n\t\n\t//! Setup the widget layout.\n    void setupLayout();\n\n\t//! The view that displays the parameters.\n\tEditableTableView view_;\n\n\t//! The model that holds the data to be displayed to the user\n\tPowerDomainsModel model_;\n\n\t//! The proxy that is used to sort the view\n\tQSortFilterProxyModel* proxy_;\n};\n\n#endif // POWERDOMAINSEDITOR_H\n"
  },
  {
    "path": "editors/ComponentEditor/powerDomains/PowerDomainsModel.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: PowerDomainsModel.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Esko Pekkarinen\n// Date: 05.10.2023\n//\n// Description:\n// Table model that contains the items to edit PowerDomains of a component.\n//-----------------------------------------------------------------------------\n\n#include \"PowerDomainsModel.h\"\n\n#include \"PowerDomainColumns.h\"\n\n#include <IPXACTmodels/Component/Component.h>\n#include <IPXACTmodels/Component/PowerDomain.h>\n\n#include <IPXACTmodels/Component/validators/PowerDomainValidator.h>\n\n#include <common/KactusColors.h>\n\n//-----------------------------------------------------------------------------\n// Function: PowerDomainsModel::PowerDomainsModel()\n//-----------------------------------------------------------------------------\nPowerDomainsModel::PowerDomainsModel(QSharedPointer<Component> component,\n    QSharedPointer<PowerDomainValidator > validator,\n    ExpressionSet expressions,\n    QObject* parent) : \nReferencingTableModel(expressions.finder, parent),\n    ParameterizableTable(expressions.finder),\ncomponent_(component), \ntable_(component->getPowerDomains()),\nexpressionFormatter_(expressions.formatter),\nvalidator_(validator)\n{\n    setExpressionParser(expressions.parser);\n}\n\n\n//-----------------------------------------------------------------------------\n// Function: PowerDomainsModel::rowCount()\n//-----------------------------------------------------------------------------\nint PowerDomainsModel::rowCount(QModelIndex const&  parent) const\n{\n\tif (parent.isValid())\n    {\n\t\treturn 0;\n    }\n\n\treturn table_->size();\n}\n\n\n//-----------------------------------------------------------------------------\n// Function: PowerDomainsModel::columnCount()\n//-----------------------------------------------------------------------------\nint PowerDomainsModel::columnCount(QModelIndex const&  parent) const\n{\n\tif (parent.isValid())\n    {\n\t\treturn 0;\n    }\n\n\treturn PowerDomainColumns::COLUMN_COUNT;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PowerDomainsModel::data()\n//-----------------------------------------------------------------------------\nQVariant PowerDomainsModel::data(QModelIndex const&  index, int role) const\n{\n\tif (!index.isValid() || index.row() < 0 || index.row() >= table_->size())\n    {\n\t\treturn QVariant();\n    }\n\n\tif (role == Qt::DisplayRole )\n    {\n        if (isValidExpressionColumn(index))\n        {\n            return expressionFormatter_->formatReferringExpression(expressionOrValueForIndex(index).toString());\n        }\n\n        return expressionOrValueForIndex(index);\n\n    }\n    else if (role == Qt::EditRole)\n    {\n        return expressionOrValueForIndex(index);\n    }\n    else if (role == Qt::ToolTipRole)\n    {\n        if (isValidExpressionColumn(index))\n        {\n            return formattedValueFor(expressionOrValueForIndex(index).toString());\n        }\n\n        return expressionOrValueForIndex(index);\n    }\n    else if (role == Qt::BackgroundRole)\n    {\n        if (index.column() == PowerDomainColumns::NAME)\n        {\n            return KactusColors::MANDATORY_FIELD;\n        }\n\n        return KactusColors::REGULAR_FIELD;\n    }\n\n    else if (role == Qt::ForegroundRole)\n    {\n        return blackForValidOrRedForInvalidIndex(index);\n    }\n\n    return QVariant();\n}\n\n//-----------------------------------------------------------------------------\n// Function: PowerDomainsModel::headerData()\n//-----------------------------------------------------------------------------\nQVariant PowerDomainsModel::headerData(int section, Qt::Orientation orientation, int role) const\n{\t\n\tif (orientation != Qt::Horizontal || role != Qt::DisplayRole)\n    {\n\t\treturn QVariant();\n    }\n\n    if (section == PowerDomainColumns::NAME)\n    {\n        return tr(\"Name\");\n    }\n    else if (section == PowerDomainColumns::DISPLAY_NAME)\n    {\n        return tr(\"Display name\");\n    }\n    else if (section == PowerDomainColumns::ALWAYS_ON)\n    {\n        return tr(\"Always on\") + getExpressionSymbol();\n    }\n    else if (section == PowerDomainColumns::SUBDOMAIN)\n    {\n        return tr(\"Subdomain of\");\n    }\n    else if (section == PowerDomainColumns::SHORT_DESCRIPTION)\n    {\n        return tr(\"Short description\");\n    }\n    else if (section == PowerDomainColumns::DESCRIPTION)\n    {\n        return tr(\"Description\");\n    }\n    else\n    {\n        return QVariant();\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: PowerDomainsModel::setData()\n//-----------------------------------------------------------------------------\nbool PowerDomainsModel::setData(QModelIndex const& index, QVariant const& value, int role)\n{\n    if (!index.isValid() || index.row() < 0 || index.row() >= table_->size() || role != Qt::EditRole)\n    {\n        return false;\n    }\n\n    if (index.column() == PowerDomainColumns::NAME)\n    {\n        table_->value(index.row())->setName(value.toString());\n    }\n    else if (index.column() == PowerDomainColumns::DISPLAY_NAME)\n    {\n        table_->value(index.row())->setDisplayName(value.toString());\n    }\n    else if (index.column() == PowerDomainColumns::ALWAYS_ON)\n    {\n         table_->value(index.row())->setAlwaysOn(value.toString());\n    }\n    else if (index.column() == PowerDomainColumns::SUBDOMAIN)\n    {\n        table_->value(index.row())->setSubDomainOf(value.toString());\n    }\n    else if (index.column() == PowerDomainColumns::SHORT_DESCRIPTION)\n    {\n        table_->value(index.row())->setShortDescription(value.toString());\n    }\n    else if (index.column() == PowerDomainColumns::DESCRIPTION)\n    {\n        table_->value(index.row())->setDescription(value.toString());\n    }\n    else\n    {\n        return false;\n    }\n\n    emit dataChanged(index, index);\n    emit contentChanged();\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PowerDomainsModel::flags()\n//-----------------------------------------------------------------------------\nQt::ItemFlags PowerDomainsModel::flags(QModelIndex const&  index) const\n{\n\tif (!index.isValid())\n    {\n\t\treturn Qt::NoItemFlags;\n    }\n\n\treturn Qt::ItemIsEditable | Qt::ItemIsEnabled | Qt::ItemIsSelectable;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PowerDomainsModel::onRemoveRow()\n//-----------------------------------------------------------------------------\nvoid PowerDomainsModel::onRemoveRow(int row)\n{\n\t// if row is invalid\n\tif (row < 0 || row >= table_->size())\n    {\n\t\treturn;\n    }\n\n\tbeginRemoveRows(QModelIndex(), row, row);\n\n    removeReferencesInItemOnRow(row);\n\ttable_->removeAt(row);\n\n\tendRemoveRows();\n\n\temit contentChanged();\n}\n\n//-----------------------------------------------------------------------------\n// Function: PowerDomainsModel::onRemoveItem()\n//-----------------------------------------------------------------------------\nvoid PowerDomainsModel::onRemoveItem(QModelIndex const&  index)\n{\n\tif (!index.isValid() || index.row() < 0 || index.row() >= table_->size())\n    {\n\t\treturn;\n    }\n\n\tbeginRemoveRows(QModelIndex(), index.row(), index.row());\n    removeReferencesInItemOnRow(index.row());\n\ttable_->removeAt(index.row());\n\tendRemoveRows();\n\n\temit contentChanged();\n}\n\n//-----------------------------------------------------------------------------\n// Function: PowerDomainsModel::onAddRow()\n//-----------------------------------------------------------------------------\nvoid PowerDomainsModel::onAddRow()\n{\n\tbeginInsertRows(QModelIndex(), table_->size(), table_->size());\n\ttable_->append(QSharedPointer<PowerDomain>(new PowerDomain()));\n\tendInsertRows();\n\n\temit contentChanged();\n}\n\n//-----------------------------------------------------------------------------\n// Function: PowerDomainsModel::onAddItem()\n//-----------------------------------------------------------------------------\nvoid PowerDomainsModel::onAddItem(QModelIndex const& index)\n{\n\tint row = table_->size();\n\n\t// if the index is valid then add the item to the correct position\n\tif (index.isValid())\n    {\n\t\trow = index.row();\n\t}\n\n\tbeginInsertRows(QModelIndex(), row, row);\n\ttable_->insert(row, QSharedPointer<PowerDomain>(new PowerDomain()));\n\tendInsertRows();\n\n\t// tell also parent widget that contents have been changed\n\temit contentChanged();\n}\n\n//-----------------------------------------------------------------------------\n// Function: PowerDomainsmodel::validateIndex()\n//-----------------------------------------------------------------------------\nbool PowerDomainsModel::validateIndex(QModelIndex const& index) const\n{\n    QSharedPointer<PowerDomain> domain = table_->at(index.row());\n\n    if (index.column() == PowerDomainColumns::NAME)\n    {\n        return validator_->hasValidName(domain->name());\n    }\n    else if (index.column() == PowerDomainColumns::ALWAYS_ON)\n    {\n        return validator_->hasValidAlwaysOn(domain);\n    }\n    else if (index.column() == PowerDomainColumns::SUBDOMAIN)\n    {\n        return validator_->hasValidSubDomainOf(domain);\n    }\n\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PowerDomainsModel::getAllReferencesToIdInItemOnRow()\n//-----------------------------------------------------------------------------\nint PowerDomainsModel::getAllReferencesToIdInItemOnRow(const int& row, QString const& valueID) const\n{\n    return table_->at(row)->getAlwaysOn().count(valueID);\n}\n\n//-----------------------------------------------------------------------------\n// Function: PowerDomainsModel::isValidExpressionColumn()\n//-----------------------------------------------------------------------------\nbool PowerDomainsModel::isValidExpressionColumn(QModelIndex const& index) const\n{\n    return index.column() == PowerDomainColumns::ALWAYS_ON;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PowerDomainsModel::expressionOrValueForIndex()\n//-----------------------------------------------------------------------------\nQVariant PowerDomainsModel::expressionOrValueForIndex(QModelIndex const& index) const\n{\n    if (index.column() == PowerDomainColumns::NAME)\n    {\n        return table_->at(index.row())->name();\n    }\n    else if (index.column() == PowerDomainColumns::DISPLAY_NAME)\n    {\n        return table_->at(index.row())->displayName();\n    }\n    else if (index.column() == PowerDomainColumns::ALWAYS_ON)\n    {\n        return table_->at(index.row())->getAlwaysOn();\n    }\n    else if (index.column() == PowerDomainColumns::SUBDOMAIN)\n    {\n        return table_->at(index.row())->getSubDomainOf();\n    }\n    else if (index.column() == PowerDomainColumns::SHORT_DESCRIPTION)\n    {\n        return table_->at(index.row())->shortDescription();\n    }\n    else if (index.column() == PowerDomainColumns::DESCRIPTION)\n    {\n        return table_->at(index.row())->description();\n    }\n    else\n    {\n        return QVariant();\n    }\n}\n"
  },
  {
    "path": "editors/ComponentEditor/powerDomains/PowerDomainsModel.h",
    "content": "//-----------------------------------------------------------------------------\n// File: PowerDomainsModel.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Esko Pekkarinen\n// Date: 05.10.2023\n//\n// Description:\n// Table model that contains the items to edit PowerDomains of a component.\n//-----------------------------------------------------------------------------\n\n#ifndef POWERDOMAINSMODEL_H\n#define POWERDOMAINSMODEL_H\n\n#include <editors/ComponentEditor/common/ParameterizableTable.h>\n#include <editors/ComponentEditor/common/ReferencingTableModel.h>\n\n#include <editors/common/ExpressionSet.h>\n\n#include <QList>\n#include <QSharedPointer>\n\nclass Component;\nclass PowerDomain;\nclass PowerDomainValidator;\n//-----------------------------------------------------------------------------\n//! Table model that contains the items to edit PowerDomains of a component.\n//-----------------------------------------------------------------------------\nclass PowerDomainsModel : public ReferencingTableModel, public ParameterizableTable\n{\n\tQ_OBJECT\n\npublic:\n\n\t/*!\n     *  The constructor\n\t *\n\t *    @param [in] component       The component being edited.\n     *    @param [in] validator\t\tThe validator used for power domains.\n     *    @param [in] expressions\t\tThe collection of objects for expression handling.\n\t *    @param [in] parent          The owner of this model\n\t */\n\tPowerDomainsModel(QSharedPointer<Component> component, \n\t\tQSharedPointer<PowerDomainValidator > validator, \n\t\tExpressionSet expressions,\n\t\tQObject *parent);\n\t\n\t//! The destructor.\n\tvirtual ~PowerDomainsModel() = default;\n\n    //! No copying.\n    PowerDomainsModel(const PowerDomainsModel& other) = delete;\n\n    //! No assignment.\n    PowerDomainsModel& operator=(const PowerDomainsModel& other) = delete;\n\n\t/*!\n     *  Get the number of rows in the model.\n\t *\n\t *    @param [in] parent  Model index of the parent of the item. Must be invalid because this is not \n     *                          hierarchical model.\n\t *\n\t *    @return Number of rows currently in the model.\n\t */\n\tint rowCount(QModelIndex const&  parent = QModelIndex()) const final;\n\n\t/*!\n     *  Get the number of columns in the model\n\t *\n\t *    @param [in] parent  Model index of the parent of the item. Must be invalid because this is not \n     *                          hierarchical model.\n\t *\n\t *    @return The number of columns in the model.\n\t */\n\tint columnCount(QModelIndex const&  parent = QModelIndex()) const final;\n\n\t/*!\n     *  Get the data for the specified item for specified role.\n\t *\n\t *    @param [in] index Identifies the item that's data is wanted.\n\t *    @param [in] role Specifies what kind of data is wanted\n\t *\n\t *    @return QVariant containing the data\n\t */\n\tQVariant data(QModelIndex const&  index, int role = Qt::DisplayRole) const final;\n\n\t/*!\n     *  Get the data for the headers\n\t *\n\t *    @param [in] section The column that's header is wanted\n\t *    @param [in] orientation Only Qt::Horizontal is supported\n\t *    @param [in] role Specified the type of data that is wanted.\n\t *\n\t *    @return QVariant containing the data to be displayed\n\t */\n\tQVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const final;\n\n\t/*!\n     *  Set the data for specified item.\n\t *\n\t *    @param [in] index Specifies the item that's data is modified\n\t *    @param [in] value The value to be set.\n\t *    @param [in] role The role that is trying to modify the data. Only Qt::EditRole is supported.\n\t *\n\t *    @return True if data was successfully set.\n\t */\n\tbool setData(QModelIndex const&  index, const QVariant& value, int role = Qt::EditRole) final;\n\n\t/*!\n     *  Get information on how specified item can be handled.\n\t *\n\t *    @param [in] index Specifies the item that's flags are wanted.\n\t *\n\t *    @return Qt::ItemFlags that define how object can be handled.\n\t */\n\tQt::ItemFlags flags(QModelIndex const&  index) const final;\n\n\npublic slots:\n\n\t/*!\n     *  Remove a row from the model\n\t *\n\t *    @param [in] row Specifies the row to remove\n\t */\n\tvoid onRemoveRow(int row);\n\n\t/*!\n     *  Add a new empty row to the model\n\t */\n\tvoid onAddRow();\n\n\t/*!\n     *  A new item should be added to given index.\n\t *\n\t *    @param [in] index The position where new item should be added at.\n\t */\n\tvoid onAddItem(QModelIndex const&  index);\n\n\t/*!\n     *  An item should be removed from the model.\n\t * \n\t *    @param [in] index Identifies the item that should be removed.\n\t */\n\tvoid onRemoveItem(QModelIndex const&  index);\n\nsignals:\n\n\t//! Emitted when contents of the model change.\n\tvoid contentChanged();\n\n\t//! Prints an error message to the user.\n\tvoid errorMessage(const QString& msg) const;\n\t\n\t//! Prints a notification to user.\n\tvoid noticeMessage(const QString& msg) const;\n\nprotected:\n\n\t/*!\n\t *  Gets the number of all the references made to a selected id on the selected row.\n\t *\n\t *    @param [in] row         The row of the selected item.\n\t *    @param [in] valueID     The id of the referenced parameter.\n\t *\n\t *    @return The amount of references made to the selected id on the selected row.\n\t */\n    int getAllReferencesToIdInItemOnRow(const int& row, QString const& valueID) const final;\n\n\t/*!\n     *  Check if the column index is valid for containing expressions.\n     *\n     *    @param [in] index   The index being evaluated.\n     *\n     *    @return True, if column can have expressions, false otherwise.\n     */\n    bool isValidExpressionColumn(QModelIndex const& index) const final;\n\n\t/*!\n     *  Gets the expression for the given index or the plain value if expression is not available.\n     *\n     *    @param [in] index   The index whose expression to get.\n     *\n     *    @return The expression for the index if available, otherwise the value for the given index.\n     */\n    QVariant expressionOrValueForIndex(QModelIndex const& index) const final;\n\n\nprivate:\n\n    /*!\n     *  Validate the data contained within a given index.\n     *\n     *    @param [in] index   The index of the data being validated.\n     *\n     *    @return True, if the data is valid, otherwise false.\n     */\n    bool validateIndex(QModelIndex const& index) const;\n\n    //-----------------------------------------------------------------------------\n    // Data.\n    //-----------------------------------------------------------------------------\n\n\t//! The component being edited.\n\tQSharedPointer<Component> component_;\n\n\t//! Contains the current items in the editor.\n\tQSharedPointer<QList<QSharedPointer<PowerDomain> > > table_;\n\n\t//! Formatter for expressions.\n\tQSharedPointer<ExpressionFormatter> expressionFormatter_;\n\n    //! The validator used for power domains.\n\tQSharedPointer<PowerDomainValidator > validator_;\n\n};\n\n#endif // POWERDOMAINSMODEL_H\n"
  },
  {
    "path": "editors/ComponentEditor/referenceCounter/ComponentParameterReferenceCounter.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: ComponentParameterReferenceCounter.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 04.10.2017\n//\n// Description:\n// Calculates the amount of references made to component parameters.\n//-----------------------------------------------------------------------------\n\n#include \"ComponentParameterReferenceCounter.h\"\n\n#include <IPXACTmodels/common/ModuleParameter.h>\n#include <IPXACTmodels/common/Parameter.h>\n\n#include <IPXACTmodels/Component/Component.h>\n#include <IPXACTmodels/Component/Cpu.h>\n#include <IPXACTmodels/Component/FileSet.h>\n#include <IPXACTmodels/Component/File.h>\n#include <IPXACTmodels/Component/BuildCommand.h>\n#include <IPXACTmodels/Component/MemoryMap.h>\n#include <IPXACTmodels/Component/MemoryRemap.h>\n#include <IPXACTmodels/Component/Mode.h>\n#include <IPXACTmodels/Component/AddressBlock.h>\n#include <IPXACTmodels/Component/PowerDomain.h>\n#include <IPXACTmodels/Component/Region.h>\n#include <IPXACTmodels/Component/RegisterBase.h>\n#include <IPXACTmodels/Component/Register.h>\n#include <IPXACTmodels/Component/RegisterFile.h>\n#include <IPXACTmodels/Component/Field.h>\n#include <IPXACTmodels/Component/FieldAccessPolicy.h>\n#include <IPXACTmodels/Component/FieldSlice.h>\n#include <IPXACTmodels/Component/WriteValueConstraint.h>\n#include <IPXACTmodels/Component/AddressSpace.h>\n#include <IPXACTmodels/Component/BusInterface.h>\n#include <IPXACTmodels/Component/MirroredTargetInterface.h>\n#include <IPXACTmodels/Component/InitiatorInterface.h>\n#include <IPXACTmodels/Component/PortSlice.h>\n#include <IPXACTmodels/Component/RemapState.h>\n#include <IPXACTmodels/Component/RemapPort.h>\n#include <IPXACTmodels/Component/IndirectInterface.h>\n\n#include <KactusAPI/include/AbstractParameterInterface.h>\n\n//-----------------------------------------------------------------------------\n// Function: ComponentParameterReferenceCounter::ComponentParameterReferenceCounter()\n//-----------------------------------------------------------------------------\nComponentParameterReferenceCounter::ComponentParameterReferenceCounter(\n    QSharedPointer<ParameterFinder> parameterFinder, QSharedPointer<Component> component):\nParameterReferenceCounter(parameterFinder),\ncomponent_(component)\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: ComponentParameterReferenceCounter::setComponent()\n//-----------------------------------------------------------------------------\nvoid ComponentParameterReferenceCounter::setComponent(QSharedPointer<Component> newComponent)\n{\n    component_ = newComponent;\n}\n\n//-----------------------------------------------------------------------------\n// Function: ComponentParameterReferenceCounter::recalculateReferencesToParameters()\n//-----------------------------------------------------------------------------\nvoid ComponentParameterReferenceCounter::recalculateReferencesToParameters(QVector<QString> const& parameterList,\n    AbstractParameterInterface* parameterInterface)\n{\n    for (auto parameterName : parameterList)\n    {\n        int referenceCount = 0;\n        QString parameterID = QString::fromStdString(parameterInterface->getID(parameterName.toStdString()));\n        if (!parameterID.isEmpty())\n        {\n            referenceCount += countReferencesInFileSets(parameterID);\n            referenceCount += countReferencesInParameters(parameterID, component_->getParameters());\n            referenceCount += countReferencesInMemoryMaps(parameterID);\n            referenceCount += countReferencesInAddressSpaces(parameterID);\n            referenceCount += countReferencesInInstantiations(parameterID);\n            referenceCount += countReferencesInPorts(parameterID);\n            referenceCount += countReferencesInBusInterfaces(parameterID);\n            referenceCount += countReferencesInRemapStates(parameterID);\n            referenceCount += countReferencesInModes(parameterID);\n            referenceCount += countReferencesInIndirectInterfaces(parameterID);\n            referenceCount += countReferencesInCpus(parameterID);\n            referenceCount += countReferencesInPowerDomains(parameterID);\n\n            parameterInterface->setUsageCount(parameterName.toStdString(), referenceCount);\n        }\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: ComponentParameterReferenceCounter::countReferencesInFileSets()\n//-----------------------------------------------------------------------------\nint ComponentParameterReferenceCounter::countReferencesInFileSets(QString const& parameterID) const\n{\n    int referenceCount = 0;\n\n    for (QSharedPointer<FileSet> fileSet : *component_->getFileSets())\n    {\n        referenceCount += countReferencesInSingleFileSet(parameterID, fileSet);\n    }\n\n    return referenceCount;\n}\n\n//-----------------------------------------------------------------------------\n// Function: ComponentParameterReferenceCounter::countReferencesInSingleFileSet()\n//-----------------------------------------------------------------------------\nint ComponentParameterReferenceCounter::countReferencesInSingleFileSet(QString const& parameterID,\n    QSharedPointer<FileSet> fileSet) const\n{\n    int referenceCount = 0;\n\n    referenceCount += countReferencesInFileBuilders(parameterID, fileSet->getDefaultFileBuilders());\n    referenceCount += countReferencesInFiles(parameterID, fileSet->getFiles());\n\n    return referenceCount;\n}\n\n//-----------------------------------------------------------------------------\n// Function: ComponentParameterReferenceCounter::countReferencesInFileBuilders()\n//-----------------------------------------------------------------------------\nint ComponentParameterReferenceCounter::countReferencesInFileBuilders(QString const& parameterID,\n    QSharedPointer<QList<QSharedPointer<FileBuilder> > > builders) const\n{\n    int referenceCount = 0;\n\n    for (QSharedPointer<FileBuilder> fileBuilder : *builders)\n    {\n        referenceCount += countReferencesInSingleFileBuilder(parameterID, fileBuilder);\n    }\n\n    return referenceCount;\n}\n\n//-----------------------------------------------------------------------------\n// Function: ComponentParameterReferenceCounter::countReferencesInSingleFileBuilder()\n//-----------------------------------------------------------------------------\nint ComponentParameterReferenceCounter::countReferencesInSingleFileBuilder(QString const& parameterID,\n    QSharedPointer<FileBuilder> builder) const\n{\n    return countReferencesInExpression(parameterID, builder->getReplaceDefaultFlags());\n}\n\n//-----------------------------------------------------------------------------\n// Function: ComponentParameterReferenceCounter::countReferencesInFiles()\n//-----------------------------------------------------------------------------\nint ComponentParameterReferenceCounter::countReferencesInFiles(QString const& parameterID,\n    QSharedPointer<QList<QSharedPointer<File> > > files) const\n{\n    int referenceCount = 0;\n\n    for (QSharedPointer<File> singleFile : *files)\n    {\n        referenceCount += countReferencesInSingleFile(parameterID, singleFile);\n    }\n\n    return referenceCount;\n}\n\n//-----------------------------------------------------------------------------\n// Function: ComponentParameterReferenceCounter::countReferencesInSingleFile()\n//-----------------------------------------------------------------------------\nint ComponentParameterReferenceCounter::countReferencesInSingleFile(QString const& parameterID,\n    QSharedPointer<File> file) const\n{\n    if (file->getBuildCommand())\n    {\n        return countReferencesInBuildCommand(parameterID, file->getBuildCommand());\n    }\n    else\n    {\n        return 0;\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: ComponentParameterReferenceCounter::countReferencesInBuildCommand()\n//-----------------------------------------------------------------------------\nint ComponentParameterReferenceCounter::countReferencesInBuildCommand(QString const& parameterID,\n    QSharedPointer<BuildCommand> buildCommand) const\n{\n    return countReferencesInExpression(parameterID, buildCommand->getReplaceDefaultFlags());\n}\n\n//-----------------------------------------------------------------------------\n// Function: ComponentParameterReferenceCounter::countReferencesInMemoryMaps()\n//-----------------------------------------------------------------------------\nint ComponentParameterReferenceCounter::countReferencesInMemoryMaps(QString const& parameterID) const\n{\n    int referenceCount = 0;\n\n    for (QSharedPointer<MemoryMap> memoryMap : *component_->getMemoryMaps())\n    {\n        referenceCount += countReferencesInSingleMemoryMap(parameterID, memoryMap);\n    }\n\n    return referenceCount;\n}\n\n//-----------------------------------------------------------------------------\n// Function: ComponentParameterReferenceCounter::countReferencesInSingleMemoryMap()\n//-----------------------------------------------------------------------------\nint ComponentParameterReferenceCounter::countReferencesInSingleMemoryMap(QString const& parameterID,\n    QSharedPointer<MemoryMap> memoryMap) const\n{\n    int referenceCount = 0;\n    \n    referenceCount += countReferencesInBaseMemoryMap(parameterID, memoryMap);\n\n    for (QSharedPointer<MemoryRemap> remap : *memoryMap->getMemoryRemaps())\n    {\n        referenceCount += countReferencesInBaseMemoryMap(parameterID, remap);\n    }\n\n    return referenceCount;\n}\n\n//-----------------------------------------------------------------------------\n// Function: ComponentParameterReferenceCounter::countReferencesInBaseMemoryMap()\n//-----------------------------------------------------------------------------\nint ComponentParameterReferenceCounter::countReferencesInBaseMemoryMap(QString const& parameterID,\n    QSharedPointer<MemoryMapBase> memoryMap) const\n{\n    int referenceCount = 0;\n    referenceCount += countReferencesInMemoryMapValues(parameterID, memoryMap);\n\n    for (QSharedPointer<MemoryBlockBase> memoryBlock : *memoryMap->getMemoryBlocks())\n    {\n        QSharedPointer<AddressBlock> addressBlock = memoryBlock.dynamicCast<AddressBlock>();\n        if (addressBlock)\n        {\n            referenceCount += countReferenceInAddressBlock(parameterID, addressBlock);\n        }\n    }\n\n    return referenceCount;\n}\n\n//-----------------------------------------------------------------------------\n// Function: ComponentParameterReferenceCounter::countReferencesInMemoryMapValues()\n//-----------------------------------------------------------------------------\nint ComponentParameterReferenceCounter::countReferencesInMemoryMapValues(QString const& parameterID,\n    QSharedPointer<MemoryMapBase> memoryMap) const\n{\n    int referenceCount = 0;\n\n    referenceCount += countReferencesInExpression(parameterID, memoryMap->getIsPresent());\n\n    return referenceCount;\n}\n\n//-----------------------------------------------------------------------------\n// Function: ComponentParameterReferenceCounter::countReferenceInAddressBlock()\n//-----------------------------------------------------------------------------\nint ComponentParameterReferenceCounter::countReferenceInAddressBlock(QString const& parameterID,\n    QSharedPointer<AddressBlock> addressBlock) const\n{\n    int referenceCount = 0;\n\n    referenceCount += countReferencesInAddressBlockValues(parameterID, addressBlock);\n    referenceCount += countReferencesInRegisters(parameterID, addressBlock->getRegisterData());\n    referenceCount += countReferencesInRegisterFiles(parameterID, addressBlock->getRegisterData());\n\n    return referenceCount;\n}\n\n//-----------------------------------------------------------------------------\n// Function: ComponentParameterReferenceCounter::countReferencesInAddressBlockValues()\n//-----------------------------------------------------------------------------\nint ComponentParameterReferenceCounter::countReferencesInAddressBlockValues(QString const& parameterID,\n    QSharedPointer<AddressBlock> addressBlock) const\n{\n    int referenceCount = 0;\n\n    referenceCount += countReferencesInExpression(parameterID, addressBlock->getBaseAddress());\n    referenceCount += countReferencesInExpression(parameterID, addressBlock->getRange());\n    referenceCount += countReferencesInExpression(parameterID, addressBlock->getWidth());\n    referenceCount += countReferencesInExpression(parameterID, addressBlock->getIsPresent());\n\n    return referenceCount;\n}\n\n//-----------------------------------------------------------------------------\n// Function: ComponentParameterReferenceCounter::countReferencesInRegisters()\n//-----------------------------------------------------------------------------\nint ComponentParameterReferenceCounter::countReferencesInRegisters(QString const& parameterID,\n    QSharedPointer<QList<QSharedPointer<RegisterBase>>> registers) const\n{\n    int referenceCounter = 0;\n\n    for (QSharedPointer<RegisterBase> registerItem : *registers)\n    {\n        QSharedPointer<Register> targetRegister = registerItem.dynamicCast<Register>();\n        if (targetRegister)\n        {\n            referenceCounter += countReferencesInSingleRegister(parameterID, targetRegister);\n        }\n    }\n\n    return referenceCounter;\n}\n\n//-----------------------------------------------------------------------------\n// Function: ComponentParameterReferenceCounter::countReferencesInRegisterFiles()\n//-----------------------------------------------------------------------------\nint ComponentParameterReferenceCounter::countReferencesInRegisterFiles(QString const& parameterID,\n    QSharedPointer<QList<QSharedPointer<RegisterBase>>> const& files) const\n{\n    int referenceCounter = 0;\n    for (auto registerData : *files)\n    {\n        QSharedPointer<RegisterFile> targetFile = registerData.dynamicCast<RegisterFile>();\n        if (targetFile)\n        {\n            referenceCounter += countReferencesInSingleRegisterFile(parameterID, targetFile);\n        }\n    }\n\n    return referenceCounter;\n}\n\n//-----------------------------------------------------------------------------\n// Function: ComponentParameterReferenceCounter::countReferencesInSingleRegister()\n//-----------------------------------------------------------------------------\nint ComponentParameterReferenceCounter::countReferencesInSingleRegister(QString const& parameterID,\n    QSharedPointer<Register> targetRegister) const\n{\n    int referenceCount = 0;\n\n    referenceCount += countReferencesInSingleBaseRegister(parameterID, targetRegister);\n    referenceCount += countReferencesInExpression(parameterID, targetRegister->getSize());\n    referenceCount += countReferencesInFields(parameterID, targetRegister->getFields());\n\n    return referenceCount;\n}\n\n//-----------------------------------------------------------------------------\n// Function: ComponentParameterReferenceCounter::countReferencesInSingleBaseRegister()\n//-----------------------------------------------------------------------------\nint ComponentParameterReferenceCounter::countReferencesInSingleBaseRegister(QString const& parameterID,\n    QSharedPointer<RegisterBase> baseRegister) const\n{\n    int referenceCount = 0;\n\n    referenceCount += countReferencesInExpression(parameterID, baseRegister->getAddressOffset());\n    referenceCount += countReferencesInExpression(parameterID, baseRegister->getDimension());\n    referenceCount += countReferencesInExpression(parameterID, baseRegister->getIsPresent());\n\n    return referenceCount;\n}\n\n//-----------------------------------------------------------------------------\n// Function: ComponentParameterReferenceCounter::countReferencesInSingleRegisterFile()\n//-----------------------------------------------------------------------------\nint ComponentParameterReferenceCounter::countReferencesInSingleRegisterFile(QString const& parameterID,\n    QSharedPointer<RegisterFile> targetFile) const\n{\n    int referenceCount = 0;\n\n    referenceCount += countReferencesInSingleBaseRegister(parameterID, targetFile);\n    referenceCount += countReferencesInExpression(parameterID, targetFile->getRange());\n    referenceCount += countReferencesInRegisters(parameterID, targetFile->getRegisterData());\n    referenceCount += countReferencesInRegisterFiles(parameterID, targetFile->getRegisterData());\n\n    return referenceCount;\n}\n\n//-----------------------------------------------------------------------------\n// Function: ComponentParameterReferenceCounter::countReferencesInFields()\n//-----------------------------------------------------------------------------\nint ComponentParameterReferenceCounter::countReferencesInFields(QString const& parameterID,\n    QSharedPointer<QList<QSharedPointer<Field> > > fields) const\n{\n    int referenceCount = 0;\n\n    for (QSharedPointer<Field> registerField : *fields)\n    {\n        referenceCount += countReferencesInSingleField(parameterID, registerField);\n    }\n\n    return referenceCount;\n}\n\n//-----------------------------------------------------------------------------\n// Function: ComponentParameterReferenceCounter::countReferencesInField()\n//-----------------------------------------------------------------------------\nint ComponentParameterReferenceCounter::countReferencesInSingleField(QString const& parameterID,\n    QSharedPointer<Field> registerField) const\n{\n    int referenceCount = 0;\n\n    referenceCount += countReferencesInExpression(parameterID, registerField->getBitOffset());\n    referenceCount += countReferencesInExpression(parameterID, registerField->getBitWidth());\n    referenceCount += countReferencesInExpression(parameterID, registerField->getIsPresent());\n    referenceCount += countReferencesInFieldResets(parameterID, registerField->getResets());\n    referenceCount += countReferencesInWriteConstraint(parameterID, registerField->getWriteConstraint());\n    referenceCount += countReferencesInFieldAccessPolicies(parameterID, registerField->getFieldAccessPolicies());\n\n    return referenceCount;\n}\n\n//-----------------------------------------------------------------------------\n// Function: ComponentParameterReferenceCounter::countReferencesInFieldResets()\n//-----------------------------------------------------------------------------\nint ComponentParameterReferenceCounter::countReferencesInFieldResets(QString const& parameterID,\n    QSharedPointer<QList<QSharedPointer<FieldReset> > > resets) const\n{\n    int referenceCount = 0;\n\n    for (auto fieldReset : *resets)\n    {\n        referenceCount += countReferencesInSingleFieldReset(parameterID, fieldReset);\n    }\n\n    return referenceCount;\n}\n\n//-----------------------------------------------------------------------------\n// Function: ComponentParameterReferenceCounter::countReferencesInSingleFieldReset()\n//-----------------------------------------------------------------------------\nint ComponentParameterReferenceCounter::countReferencesInSingleFieldReset(QString const& parameterID,\n    QSharedPointer<FieldReset> fieldReset) const\n{\n    int referenceCount = 0;\n\n    referenceCount += countReferencesInExpression(parameterID, fieldReset->getResetValue());\n    referenceCount += countReferencesInExpression(parameterID, fieldReset->getResetMask());\n\n    return referenceCount;\n}\n\n//-----------------------------------------------------------------------------\n// Function: ComponentParameterReferenceCounter::countReferencesInFieldAccessPolicies()\n//-----------------------------------------------------------------------------\nint ComponentParameterReferenceCounter::countReferencesInFieldAccessPolicies(QString const& parameterID,\n    QSharedPointer<QList<QSharedPointer<FieldAccessPolicy> > > accessPolicies) const\n{\n    int referenceCount = 0;\n\n    for (auto const& accessPolicy : *accessPolicies)\n    {\n        referenceCount += countReferencesInExpression(parameterID, accessPolicy->getReadResponse());\n        referenceCount += countReferencesInExpression(parameterID, accessPolicy->getReserved());\n\n        if (auto writeValueConstraint = accessPolicy->getWriteValueConstraint();\n            writeValueConstraint)\n        {\n            referenceCount += countReferencesInExpression(parameterID, writeValueConstraint->getMinimum());\n            referenceCount += countReferencesInExpression(parameterID, writeValueConstraint->getMaximum());\n        }\n    }\n\n    return referenceCount;\n}\n\n//-----------------------------------------------------------------------------\n// Function: ComponentParameterReferenceCounter::countReferencesInWriteConstraint()\n//-----------------------------------------------------------------------------\nint ComponentParameterReferenceCounter::countReferencesInWriteConstraint(QString const& parameterID,\n    QSharedPointer<WriteValueConstraint> writeConstraint) const\n{\n    int referenceCount = 0;\n\n    if (writeConstraint)\n    {\n        referenceCount += countReferencesInExpression(parameterID, writeConstraint->getMinimum());\n        referenceCount += countReferencesInExpression(parameterID, writeConstraint->getMaximum());\n    }\n\n    return referenceCount;\n}\n\n//-----------------------------------------------------------------------------\n// Function: ComponentParameterReferenceCounter::countReferencesInModes()\n//-----------------------------------------------------------------------------\nint ComponentParameterReferenceCounter::countReferencesInModes(QString const& parameterID) const\n{\n    int referenceCount = 0;\n\n    for (auto const& mode : *component_->getModes())\n    {\n        referenceCount += countReferencesInSingleMode(parameterID, mode);\n    }\n\n    return referenceCount;\n}\n\n//-----------------------------------------------------------------------------\n// Function: ComponentParameterReferenceCounter::countReferencesInSingleMode()\n//-----------------------------------------------------------------------------\nint ComponentParameterReferenceCounter::countReferencesInSingleMode(QString const& parameterID,\n    QSharedPointer<Mode> mode) const\n{\n    int referenceCount = 0;\n\n    referenceCount += countReferencesInModeCondition(parameterID, mode->getCondition());\n    referenceCount += countReferencesInPortSlices(parameterID, mode);\n\n\n\n    return referenceCount;\n}\n\n//-----------------------------------------------------------------------------\n// Function: ComponentParameterReferenceCounter::countReferencesInModeCondition()\n//-----------------------------------------------------------------------------\nint ComponentParameterReferenceCounter::countReferencesInModeCondition(QString const& parameterID,\n    QString const& condition) const\n{\n    return condition.count(parameterID);\n}\n\n//-----------------------------------------------------------------------------\n// Function: ComponentParameterReferenceCounter::countReferencesInPortSlices()\n//-----------------------------------------------------------------------------\nint ComponentParameterReferenceCounter::countReferencesInPortSlices(QString const& parameterID, \n    QSharedPointer<Mode> mode) const\n{\n    int referenceCount = 0;\n    for (auto const& slice : *mode->getPortSlices())\n    {\n        referenceCount += countReferencesInSinglePortSlice(parameterID, slice);\n    }\n\n    return referenceCount;\n}\n\n//-----------------------------------------------------------------------------\n// Function: ComponentParameterReferenceCounter::countReferencesInFieldSlices()\n//-----------------------------------------------------------------------------\nint ComponentParameterReferenceCounter::countReferencesInFieldSlices(QString const& parameterID, \n    QSharedPointer<Mode> mode) const\n{\n    int referenceCount = 0;\n    for (auto const& slice : *mode->getFieldSlices())\n    {\n        referenceCount += countReferencesInSingleFieldSlice(parameterID, slice);\n    }\n    return referenceCount;\n}\n\n//-----------------------------------------------------------------------------\n// Function: ComponentParameterReferenceCounter::countReferencesInSinglePortSlice()\n//-----------------------------------------------------------------------------\nint ComponentParameterReferenceCounter::countReferencesInSinglePortSlice(QString const& parameterID, \n    QSharedPointer<PortSlice> portSlice) const\n{\n    int referenceCount = 0;\n    referenceCount += portSlice->getLeftRange().count(parameterID);\n    referenceCount += portSlice->getRightRange().count(parameterID);\n    return referenceCount;\n}\n\n//-----------------------------------------------------------------------------\n// Function: ComponentParameterReferenceCounter::countReferencesInSingleFieldSlice()\n//-----------------------------------------------------------------------------\nint ComponentParameterReferenceCounter::countReferencesInSingleFieldSlice(QString const& parameterID,\n    QSharedPointer<FieldSlice> fieldSlice) const\n{\n    int referenceCount = 0;\n    referenceCount += fieldSlice->getLeft().count(parameterID);\n    referenceCount += fieldSlice->getRight().count(parameterID);\n    return referenceCount;\n}\n\n//-----------------------------------------------------------------------------\n// Function: ComponentParameterReferenceCounter::countReferencesInAddressSpaces()\n//-----------------------------------------------------------------------------\nint ComponentParameterReferenceCounter::countReferencesInAddressSpaces(QString const& parameterID) const\n{\n    int referenceCount = 0;\n\n    for (QSharedPointer<AddressSpace> space : *component_->getAddressSpaces())\n    {\n        referenceCount += countReferencesInSingleAddressSpace(parameterID, space);\n    }\n\n    return referenceCount;\n}\n\n//-----------------------------------------------------------------------------\n// Function: ComponentParameterReferenceCounter::countReferencesInSingleAddressSpace()\n//-----------------------------------------------------------------------------\nint ComponentParameterReferenceCounter::countReferencesInSingleAddressSpace(QString const& parameterID,\n    QSharedPointer<AddressSpace> space) const\n{\n    int referenceCount = 0;\n\n    referenceCount += countReferencesInSingleAddressSpaceItems(parameterID, space);\n    if (space->getLocalMemoryMap())\n    {\n        referenceCount += countReferencesInBaseMemoryMap(parameterID, space->getLocalMemoryMap());\n    }\n\n    referenceCount += countReferencesInSegments(parameterID, space->getSegments());\n\n    return referenceCount;\n}\n\n//-----------------------------------------------------------------------------\n// Function: ComponentParameterReferenceCounter::countReferencesInSingleAddressSpaceItems()\n//-----------------------------------------------------------------------------\nint ComponentParameterReferenceCounter::countReferencesInSingleAddressSpaceItems(QString const& parameterID,\n    QSharedPointer<AddressSpace> space) const\n{\n    int referenceCount = 0;\n\n    referenceCount += countReferencesInExpression(parameterID, space->getWidth());\n    referenceCount += countReferencesInExpression(parameterID, space->getRange());\n\n    return referenceCount;\n}\n\n//-----------------------------------------------------------------------------\n// Function: ComponentParameterReferenceCounter::countReferencesInSegments()\n//-----------------------------------------------------------------------------\nint ComponentParameterReferenceCounter::countReferencesInSegments(QString const& parameterID,\n    QSharedPointer<QList<QSharedPointer<Segment> > > segments) const\n{\n    int referenceCount = 0;\n\n    for (QSharedPointer<Segment> segment : *segments)\n    {\n        referenceCount += countReferencesInSingleSegment(parameterID, segment);\n    }\n\n    return referenceCount;\n}\n\n//-----------------------------------------------------------------------------\n// Function: ComponentParameterReferenceCounter::countReferencesInSegment()\n//-----------------------------------------------------------------------------\nint ComponentParameterReferenceCounter::countReferencesInSingleSegment(QString const& parameterID,\n    QSharedPointer<Segment> segment) const\n{\n    int referenceCounter = 0;\n\n    referenceCounter += countReferencesInExpression(parameterID, segment->getAddressOffset());\n    referenceCounter += countReferencesInExpression(parameterID, segment->getRange());\n\n    return referenceCounter;\n}\n\n//-----------------------------------------------------------------------------\n// Function: ComponentParameterReferenceCounter::countReferencesInInstantiations()\n//-----------------------------------------------------------------------------\nint ComponentParameterReferenceCounter::countReferencesInInstantiations(QString const& parameterID) const\n{\n    int referenceCounter = 0;\n\n    referenceCounter +=\n        countReferencesInComponentInstantiations(parameterID, component_->getComponentInstantiations());\n    referenceCounter += countReferencesInDesignConfigurationInstantiations(\n        parameterID, component_->getDesignConfigurationInstantiations());\n    referenceCounter += countReferencesInDesignInstantiations(parameterID);\n\n    return referenceCounter;\n}\n\n//-----------------------------------------------------------------------------\n// Function: ComponentParameterReferenceCounter::countReferencesInComponentInstantiations()\n//-----------------------------------------------------------------------------\nint ComponentParameterReferenceCounter::countReferencesInComponentInstantiations(QString const& parameterID,\n    QSharedPointer<QList<QSharedPointer<ComponentInstantiation> > > instantiations) const\n{\n    int referenceCounter = 0;\n\n    for (QSharedPointer<ComponentInstantiation> singleInstantiation : *instantiations)\n    {\n        referenceCounter += countReferencesInSingleComponentInstantiation(parameterID, singleInstantiation);\n    }\n\n    return referenceCounter;\n}\n\n//-----------------------------------------------------------------------------\n// Function: ComponentParameterReferenceCounter::countReferencesInSingleComponentInstantiation()\n//-----------------------------------------------------------------------------\nint ComponentParameterReferenceCounter::countReferencesInSingleComponentInstantiation(QString const& parameterID,\n    QSharedPointer<ComponentInstantiation> instantiation) const\n{\n    int referenceCounter = 0;\n\n    referenceCounter += countReferencesInModuleParameters(parameterID, instantiation->getModuleParameters());\n    referenceCounter += countReferencesInParameters(parameterID, instantiation->getParameters());\n    referenceCounter += countReferencesInFileBuilders(parameterID, instantiation->getDefaultFileBuilders());\n\n    return referenceCounter;\n}\n\n//-----------------------------------------------------------------------------\n// Function: ComponentParameterReferenceCounter::countReferencesInModuleParameters()\n//-----------------------------------------------------------------------------\nint ComponentParameterReferenceCounter::countReferencesInModuleParameters(QString const& parameterID,\n    QSharedPointer<QList<QSharedPointer<ModuleParameter> > > moduleParameters) const\n{\n    int referenceCounter = 0;\n\n    for (QSharedPointer<ModuleParameter> parameter : *moduleParameters)\n    {\n        referenceCounter += countReferencesInSingleParameter(parameterID, parameter);\n    }\n\n    return referenceCounter;\n}\n\n//-----------------------------------------------------------------------------\n// Function: ComponentParameterReferenceCounter::countReferencesInDesignConfigurationInstantiations()\n//-----------------------------------------------------------------------------\nint ComponentParameterReferenceCounter::countReferencesInDesignConfigurationInstantiations(\n    QString const& parameterID,\n    QSharedPointer<QList<QSharedPointer<DesignConfigurationInstantiation> > > instantiations) const\n{\n    int referenceCounter = 0;\n\n    for (QSharedPointer<DesignConfigurationInstantiation> configurationInstantiation : *instantiations)\n    {\n        referenceCounter +=\n            countReferencesInSingleDesignConfigurationInstantiation(parameterID, configurationInstantiation);\n    }\n\n    return referenceCounter;\n}\n\n//-----------------------------------------------------------------------------\n// Function: ComponentParameterReferenceCounter::countReferencesInDesignConfigurationInstantiation()\n//-----------------------------------------------------------------------------\nint ComponentParameterReferenceCounter::countReferencesInSingleDesignConfigurationInstantiation(\n    QString const& parameterID, QSharedPointer<DesignConfigurationInstantiation> instantiation) const\n{\n    int refererenceCounter = 0;\n\n    refererenceCounter += countReferencesInParameters(parameterID, instantiation->getParameters());\n    \n    QSharedPointer<ConfigurableVLNVReference> configurationReference =\n        instantiation->getDesignConfigurationReference();\n    if (configurationReference && configurationReference->isValid())\n    {\n        refererenceCounter += countReferencesInConfigurableElementValues(\n            parameterID, configurationReference->getConfigurableElementValues());\n    }\n\n    return refererenceCounter;\n}\n\n//-----------------------------------------------------------------------------\n// Function: ComponentParameterReferenceCounter::countReferencesInDesignInstantiations()\n//-----------------------------------------------------------------------------\nint ComponentParameterReferenceCounter::countReferencesInDesignInstantiations(QString const& parameterID) const\n{\n    int referenceCounter = 0;\n\n    for (QSharedPointer<DesignInstantiation> instantiation : *component_->getDesignInstantiations())\n    {\n        referenceCounter += countReferencesInSingleDesigninstantiation(parameterID, instantiation);\n    }\n\n    return referenceCounter;\n}\n\n//-----------------------------------------------------------------------------\n// Function: ComponentParameterReferenceCounter::countReferencesInDesigninstantiation()\n//-----------------------------------------------------------------------------\nint ComponentParameterReferenceCounter::countReferencesInSingleDesigninstantiation(QString const& parameterID,\n    QSharedPointer<DesignInstantiation> instantiation) const\n{\n    int referenceCounter = 0;\n\n    QSharedPointer<ConfigurableVLNVReference> designReference = instantiation->getDesignReference();\n    if (designReference && designReference->isValid())\n    {\n        referenceCounter += countReferencesInConfigurableElementValues(\n            parameterID, designReference->getConfigurableElementValues());\n    }\n\n    return referenceCounter;\n}\n\n//-----------------------------------------------------------------------------\n// Function: ComponentParameterReferenceCounter::countReferencesInPorts()\n//-----------------------------------------------------------------------------\nint ComponentParameterReferenceCounter::countReferencesInPorts(QString const& parameterID) const\n{\n    int referenceCounter = 0;\n\n    for (QSharedPointer<Port> port : *component_->getPorts())\n    {\n        referenceCounter += countReferencesInSinglePort(parameterID, port);\n    }\n\n    return referenceCounter;\n}\n\n//-----------------------------------------------------------------------------\n// Function: ComponentParameterReferenceCounter::countReferencesInSinglePort()\n//-----------------------------------------------------------------------------\nint ComponentParameterReferenceCounter::countReferencesInSinglePort(QString const& parameterID,\n    QSharedPointer<Port> port) const\n{\n    int referenceCounter = 0;\n\n    referenceCounter += countReferencesInExpression(parameterID, port->getLeftBound());\n    referenceCounter += countReferencesInExpression(parameterID, port->getRightBound());\n    referenceCounter += countReferencesInExpression(parameterID, port->getArrayLeft());\n    referenceCounter += countReferencesInExpression(parameterID, port->getArrayRight());\n    referenceCounter += countReferencesInExpression(parameterID, port->getDefaultValue());\n\n    return referenceCounter;\n}\n\n//-----------------------------------------------------------------------------\n// Function: ComponentParameterReferenceCounter::countReferencesInBusInterfaces()\n//-----------------------------------------------------------------------------\nint ComponentParameterReferenceCounter::countReferencesInBusInterfaces(QString const& parameterID) const\n{\n    int referenceCounter = 0;\n\n    for (QSharedPointer<BusInterface> busInterface : *component_->getBusInterfaces())\n    {\n        referenceCounter += countReferencesInSingleBusInterface(parameterID, busInterface);\n    }\n\n    return referenceCounter;\n}\n\n//-----------------------------------------------------------------------------\n// Function: ComponentParameterReferenceCounter::countReferencesInSingleBusInterface()\n//-----------------------------------------------------------------------------\nint ComponentParameterReferenceCounter::countReferencesInSingleBusInterface(QString const& parameterID,\n    QSharedPointer<BusInterface> busInterface) const\n{\n    int referenceCounter = 0;\n\n    referenceCounter += countReferencesInParameters(parameterID, busInterface->getParameters());\n\n    if (busInterface->getMirroredSlave())\n    {\n        referenceCounter +=\n            countReferencesInMirroredSlaveInterface(parameterID, busInterface->getMirroredSlave());\n    }\n    if (busInterface->getMaster())\n    {\n        referenceCounter += countReferencesInMasterInterface(parameterID, busInterface->getMaster());\n    }\n\n    return referenceCounter;\n}\n\n//-----------------------------------------------------------------------------\n// Function: ComponentParameterReferenceCounter::countReferencesInMirroredSlaveInterface()\n//-----------------------------------------------------------------------------\nint ComponentParameterReferenceCounter::countReferencesInMirroredSlaveInterface(QString const& parameterID,\n    QSharedPointer<MirroredTargetInterface> mirroredSlave) const\n{\n    int referenceCounter = 0;\n\n    referenceCounter += countReferencesInExpression(parameterID, mirroredSlave->getRange());\n    \n    for (QSharedPointer<MirroredTargetInterface::RemapAddress> remapAddress :\n        *mirroredSlave->getRemapAddresses())\n    {\n        referenceCounter += countReferencesInRemapAddress(parameterID, remapAddress);\n    }\n\n    return referenceCounter;\n}\n\n//-----------------------------------------------------------------------------\n// Function: ComponentParameterReferenceCounter::countReferencesInRemapAddress()\n//-----------------------------------------------------------------------------\nint ComponentParameterReferenceCounter::countReferencesInRemapAddress(QString const& parameterID,\n    QSharedPointer<MirroredTargetInterface::RemapAddress> remapAddress) const\n{\n    return countReferencesInExpression(parameterID, remapAddress->remapAddress_);\n}\n\n//-----------------------------------------------------------------------------\n// Function: ComponentParameterReferenceCounter::countReferencesInMasterInterface()\n//-----------------------------------------------------------------------------\nint ComponentParameterReferenceCounter::countReferencesInMasterInterface(QString const& parameterID,\n    QSharedPointer<InitiatorInterface> master) const\n{\n    return countReferencesInExpression(parameterID, master->getBaseAddress());\n}\n\n//-----------------------------------------------------------------------------\n// Function: ComponentParameterReferenceCounter::countReferencesInRemapStates()\n//-----------------------------------------------------------------------------\nint ComponentParameterReferenceCounter::countReferencesInRemapStates(QString const& parameterID) const\n{\n    int referenceCount = 0;\n\n    for (QSharedPointer<RemapState> remap : *component_->getRemapStates())\n    {\n        referenceCount += countReferencesInSingleRemapState(parameterID, remap);\n    }\n\n    return referenceCount;\n}\n\n//-----------------------------------------------------------------------------\n// Function: ComponentParameterReferenceCounter::countReferencesInSingleRemapState()\n//-----------------------------------------------------------------------------\nint ComponentParameterReferenceCounter::countReferencesInSingleRemapState(QString const& parameterID,\n    QSharedPointer<RemapState> remapState) const\n{\n    int referenceCounter = 0;\n\n    for (QSharedPointer<RemapPort> port : *remapState->getRemapPorts())\n    {\n        referenceCounter += countReferencesInSingleRemapPort(parameterID, port);\n    }\n\n    return referenceCounter;\n}\n\n//-----------------------------------------------------------------------------\n// Function: ComponentParameterReferenceCounter::countReferencesInSingleRemapPort()\n//-----------------------------------------------------------------------------\nint ComponentParameterReferenceCounter::countReferencesInSingleRemapPort(QString const& parameterID,\n    QSharedPointer<RemapPort> port) const\n{\n    return countReferencesInExpression(parameterID, port->getValue());\n}\n\n//-----------------------------------------------------------------------------\n// Function: ComponentParameterReferenceCounter::countReferencesInIndirectInterfaces()\n//-----------------------------------------------------------------------------\nint ComponentParameterReferenceCounter::countReferencesInIndirectInterfaces(QString const& parameterID) const\n{\n    int referenceCounter = 0;\n\n    for (auto const& singleInterface : *component_->getIndirectInterfaces())\n    {\n        referenceCounter += countRefrencesInSingleIndirectInterface(parameterID, singleInterface);\n    }\n\n    return referenceCounter;\n}\n\n//-----------------------------------------------------------------------------\n// Function: ComponentParameterReferenceCounter::countRefrencesInSingleIndirectInterface()\n//-----------------------------------------------------------------------------\nint ComponentParameterReferenceCounter::countRefrencesInSingleIndirectInterface(QString const& parameterID,\n    QSharedPointer<IndirectInterface> indirectInterface) const\n{\n    return countReferencesInParameters(parameterID, indirectInterface->getParameters());\n}\n\n//-----------------------------------------------------------------------------\n// Function: ComponentParameterReferenceCounter::countReferencesInCpus()\n//-----------------------------------------------------------------------------\nint ComponentParameterReferenceCounter::countReferencesInCpus(QString const& parameterID) const\n{\n    int referenceCounter = 0;\n\n    for (auto const& singleCpu : *component_->getCpus())\n    {\n        referenceCounter += countReferencesInSingleCpu(parameterID, singleCpu);\n    }\n\n    return referenceCounter;\n}\n\n\n//-----------------------------------------------------------------------------\n// Function: ComponentParameterReferenceCounter::countReferencesInSingleCpu()\n//-----------------------------------------------------------------------------\nint ComponentParameterReferenceCounter::countReferencesInSingleCpu(QString const& parameterID,\n    QSharedPointer<Cpu> cpu) const\n{\n    int referenceCounter = 0;\n\n    referenceCounter += countReferencesInExpression(parameterID, cpu->getRange());\n    referenceCounter += countReferencesInExpression(parameterID, cpu->getWidth());\n    referenceCounter += countReferencesInExpression(parameterID, cpu->getAddressUnitBits());\n\n    referenceCounter += countReferencesInRegions(parameterID, cpu->getRegions());\n\n    return referenceCounter;\n}\n\n//-----------------------------------------------------------------------------\n// Function: ComponentParameterReferenceCounter::countReferencesInRegions()\n//-----------------------------------------------------------------------------\nint ComponentParameterReferenceCounter::countReferencesInRegions(QString const& parameterID,\n    QSharedPointer<QList<QSharedPointer<Region> > > regions) const\n{\n    int referenceCounter = 0;\n\n    for (auto const& region : *regions)\n    {\n        referenceCounter += countReferencesInSingleRegion(parameterID, region);\n    }\n\n    return referenceCounter;\n}\n\n//-----------------------------------------------------------------------------\n// Function: ComponentParameterReferenceCounter::countReferencesInSingleRegion()\n//-----------------------------------------------------------------------------\nint ComponentParameterReferenceCounter::countReferencesInSingleRegion(QString const& parameterID,\n    QSharedPointer<Region> region) const\n{\n    int referenceCounter = 0;\n\n    referenceCounter += countReferencesInExpression(parameterID, region->getAddressOffset());\n    referenceCounter += countReferencesInExpression(parameterID, region->getRange());\n\n    return referenceCounter;\n}\n\n\n//-----------------------------------------------------------------------------\n// Function: ComponentParameterReferenceCounter::countReferencesInPowerDomains()\n//-----------------------------------------------------------------------------\nint ComponentParameterReferenceCounter::countReferencesInPowerDomains(QString const& parameterID) const\n{\n    int referenceCount = 0;\n\n    for (auto domain : *component_->getPowerDomains())\n    {\n        referenceCount += countReferencesInSinglePowerDomain(parameterID, domain);\n    }\n\n    return referenceCount;\n}\n\n//-----------------------------------------------------------------------------\n// Function: ComponentParameterReferenceCounter::countReferencesInSinglePowerDomain()\n//-----------------------------------------------------------------------------\nint ComponentParameterReferenceCounter::countReferencesInSinglePowerDomain(QString const& parameterID,\n    QSharedPointer<PowerDomain> powerDomain) const\n{\n    return countReferencesInExpression(parameterID, powerDomain->getAlwaysOn());\n}\n"
  },
  {
    "path": "editors/ComponentEditor/referenceCounter/ComponentParameterReferenceCounter.h",
    "content": "//-----------------------------------------------------------------------------\n// File: ComponentParameterReferenceCounter.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 04.10.2017\n//\n// Description:\n// Calculates the amount of references made to component parameters.\n//-----------------------------------------------------------------------------\n\n#ifndef COMPONENTPARAMETERREFERENCECOUNTER_H\n#define COMPONENTPARAMETERREFERENCECOUNTER_H\n\n#include <editors/ComponentEditor/referenceCounter/ParameterReferenceCounter.h>\n\n#include <IPXACTmodels/Component/MirroredTargetInterface.h>\n\nclass Component;\nclass Cpu;\nclass FileBuilder;\nclass FileSet;\nclass File;\nclass BuildCommand;\nclass MemoryMap;\nclass MemoryMapBase;\nclass AddressBlock;\nclass Register;\nclass RegisterFile;\nclass Field;\nclass FieldAccessPolicy;\nclass FieldSlice;\nclass FieldReset;\nclass WriteValueConstraint;\nclass Segment;\nclass ComponentInstantiation;\nclass DesignInstantiation;\nclass DesignConfigurationInstantiation;\nclass InitiatorInterface;\nclass ModuleParameter;\nclass Port;\nclass PowerDomain;\nclass AddressSpace;\nclass RegisterBase;\nclass BusInterface;\nclass Region;\nclass RemapState;\nclass RemapPort;\nclass AbstractParameterInterface;\nclass IndirectInterface;\nclass Mode;\nclass PortSlice;\n\n//-----------------------------------------------------------------------------\n//! Calculates the amount of references made to component parameters.\n//-----------------------------------------------------------------------------\nclass ComponentParameterReferenceCounter : public ParameterReferenceCounter\n{\n    Q_OBJECT\n\npublic:\n\n    /*!\n     *  The constructor.\n     *\n     *    @param [in] parameterFinder     Locator for component parameters.\n     *    @param [in] component           The containing component.\n     */\n    ComponentParameterReferenceCounter(QSharedPointer<ParameterFinder> parameterFinder,\n        QSharedPointer<Component> component);\n\n    /*!\n     *  The destructor.\n     */\n    virtual ~ComponentParameterReferenceCounter() = default;\n\n    //! No copying. No assignment.\n    ComponentParameterReferenceCounter(const ComponentParameterReferenceCounter& other) = delete;\n    ComponentParameterReferenceCounter& operator=(const ComponentParameterReferenceCounter& other) = delete;\n\n    /*!\n     *  Set a new component.\n     *\n     *    @param [in] newComponent    The selected component.\n     */\n    void setComponent(QSharedPointer<Component> newComponent);\n\n    /*!\n     *  Count the references made to the selected parameter in the file sets.\n     *\n     *    @param [in] parameterID     ID of the selected parameter.\n     *\n     *    @return The amount of references made to the selected parameter in the file sets.\n     */\n    int countReferencesInFileSets(QString const& parameterID) const;\n\n    /*!\n     *  Count the references made to the selected parameter in the selected file set.\n     *\n     *    @param [in] parameterID     ID of the selected parameter.\n     *    @param [in] fileSet         The selected file set.\n     *\n     *    @return The amount of references made to the selected parameter in the selected file set.\n     */\n    int countReferencesInSingleFileSet(QString const& parameterID, QSharedPointer<FileSet> fileSet) const;\n\n    /*!\n     *  Count the references made to the selected parameter in the selected file builders.\n     *\n     *    @param [in] parameterID     ID of the selected parameter.\n     *    @param [in] builders        The selected file builders.\n     *\n     *    @return The amount of references made to the selected parameter in the selected file builders.\n     */\n    int countReferencesInFileBuilders(QString const& parameterID,\n        QSharedPointer<QList<QSharedPointer<FileBuilder> > > builders) const;\n\n    /*!\n     *  Count the references made to the selected parameter in the selected file builder.\n     *\n     *    @param [in] parameterID     ID of the selected parameter.\n     *    @param [in] builder         The selected file builder.\n     *\n     *    @return The amount of references made to the selected parameter in the selected file builder.\n     */\n    int countReferencesInSingleFileBuilder(QString const& parameterID, QSharedPointer<FileBuilder> builder) const;\n\n    /*!\n     *  Count the references made to the selected parameter in the selected files.\n     *\n     *    @param [in] parameterID     ID of the selected parameter.\n     *    @param [in] files           The selected files.\n     *\n     *    @return The amount of references made to the selected parameter in the selected files.\n     */\n    int countReferencesInFiles(QString const& parameterID, QSharedPointer<QList<QSharedPointer<File> > > files)\n        const;\n\n    /*!\n     *  Count the references made to the selected parameter in the selected file.\n     *\n     *    @param [in] parameterID     ID of the selected parameter.\n     *    @param [in] file            The selected file.\n     *\n     *    @return The amount of references made to the selected parameter in the selected file.\n     */\n    int countReferencesInSingleFile(QString const& parameterID, QSharedPointer<File> file) const;\n\n    /*!\n     *  Count the references made to the selected parameter in the selected build command.\n     *\n     *    @param [in] parameterID     ID of the selected parameter.\n     *    @param [in] buildCommand    The selected build command.\n     *\n     *    @return The amount of references made to the selected parameter in the selected build command.\n     */\n    int countReferencesInBuildCommand(QString const& parameterID, QSharedPointer<BuildCommand> buildCommand)\n        const;\n\n    /*!\n     *  Count the references made to the selected parameter in the contained memory maps.\n     *\n     *    @param [in] parameterID     ID of the selected parameter.\n     *\n     *    @return The amount of references made to the selected parameter in the contained memory maps.\n     */\n    int countReferencesInMemoryMaps(QString const& parameterID) const;\n\n    /*!\n     *  Count the references made to the selected parameter in the selected memory map.\n     *\n     *    @param [in] parameterID     ID of the selected parameter.\n     *    @param [in] memoryMap       The selected memory map.\n     *\n     *    @return The amount of references made to the selected parameter in the selected memory map.\n     */\n    int countReferencesInSingleMemoryMap(QString const& parameterID, QSharedPointer<MemoryMap> memoryMap) const;\n\n    /*!\n     *  Count the references made to the selected parameter in the selected base memory map.\n     *\n     *    @param [in] parameterID     ID of the selected parameter.\n     *    @param [in] memoryMap       The selected base memory map.\n     *\n     *    @return The amount of references made to the selected parameter in the selected base memory map.\n     */\n    int countReferencesInBaseMemoryMap(QString const& parameterID, QSharedPointer<MemoryMapBase> memoryMap) const;\n\n    /*!\n     *  Count the references made to the selected parameter in the values of the selected memory base.\n     *\n     *    @param [in] parameterID     ID of the selected parameter.\n     *    @param [in] memoryMap       The selected memory base.\n     *\n     *    @return The amount of references made to the selected parameter in the selected memory base.\n     */\n    int countReferencesInMemoryMapValues(QString const& parameterID, QSharedPointer<MemoryMapBase> memoryMap) const;\n\n    /*!\n     *  Count the references made to the selected parameter in the selected address blocks.\n     *\n     *    @param [in] parameterID     ID of the selected parameter.\n     *    @param [in] addressBlock    The selected address block.\n     *\n     *    @return The amount of references made to the selected parameter in the selected address block.\n     */\n    int countReferenceInAddressBlock(QString const& parameterID, QSharedPointer<AddressBlock> addressBlock) const;\n\n    /*!\n     *  Count the references made to the selected parameter in the values of the selected address block.\n     *\n     *    @param [in] parameterID     ID of the selected parameter.\n     *    @param [in] addressBlock    The selected address block.\n     *\n     *    @return The amount of references made to the selected parameter in the values of the selected address\n     *              block.\n     */\n    int countReferencesInAddressBlockValues(QString const& parameterID, QSharedPointer<AddressBlock> addressBlock)\n        const;\n\n    /*!\n     *  Count the references made to the selected parameter in the selected registers.\n     *\n     *    @param [in] parameterID     ID of the selected parameter.\n     *    @param [in] registers       The selected registers.\n     *\n     *    @return The amount of references made to the selected parameter in the selected registers.\n     */\n    int countReferencesInRegisters(QString const& parameterID,\n        QSharedPointer<QList<QSharedPointer<RegisterBase> > > registers) const;\n\n    /*!\n     *  Count the references made to the selected parameter in the selected register files.\n     *\n     *    @param [in] parameterID     ID of the selected parameter.\n     *    @param [in] files           The selected register files.\n     *\n     *    @return The amount of references made to the selected parameter in the selected register files.\n     */\n    int countReferencesInRegisterFiles(QString const& parameterID,\n        QSharedPointer<QList<QSharedPointer<RegisterBase> > > const& files) const;\n\n    /*!\n     *  Count the references made to the selected parameter in the selected register.\n     *\n     *    @param [in] parameterID         ID of the selected parameter.\n     *    @param [in] targetRegistesr     The selected registers.\n     *\n     *    @return The amount of references made to the selected parameter in the selected register.\n     */\n    int countReferencesInSingleRegister(QString const& parameterID, QSharedPointer<Register> targetRegister) const;\n\n    /*!\n     *  Count the references made to the selected parameter in the selected register file.\n     *\n     *    @param [in] parameterID     ID of the selected parameter.\n     *    @param [in] targetFile      The selected register file.\n     *\n     *    @return The amount of references made to the selected parameter in the selected register file.\n     */\n    int countReferencesInSingleRegisterFile(QString const& parameterID, QSharedPointer<RegisterFile> targetFile)\n        const;\n\n    /*!\n     *  Count the references made to the selected parameter in the selected base register.\n     *\n     *    @param [in] parameterID     ID of the selected parameter.\n     *    @param [in] baseRegister    The selected base register.\n     *\n     *    @return The amount of references made to the selected parameter in the selected base register.\n     */\n    int countReferencesInSingleBaseRegister(QString const& parameterID, QSharedPointer<RegisterBase> baseRegister)\n        const;\n\n    /*!\n     *  Count the references made to the selected parameter in the selected fields.\n     *\n     *    @param [in] parameterID     ID of the selected parameter.\n     *    @param [in] fields          The selected fields.\n     *\n     *    @return The amount of references made to the selected parameter in the selected fields.\n     */\n    int countReferencesInFields(QString const& parameterID, QSharedPointer<QList<QSharedPointer<Field> > > fields)\n        const;\n\n    /*!\n     *  Count the references made to the selected parameter in the selected field.\n     *\n     *    @param [in] parameterID     ID of the selected parameter.\n     *    @param [in] registerField   The selected field.\n     *\n     *    @return The amount of references made to the selected parameter in the selected field.\n     */\n    int countReferencesInSingleField(QString const& parameterID, QSharedPointer<Field> registerField) const;\n\n    /*!\n     *  Count the references made to the selected parameter in the resets of the selected field.\n     *\n     *    @param [in] parameterID     ID of the selected parameter.\n     *    @param [in] resets          Reset values of the selected field.\n     *\n     *    @return The amount of references made to the selected parameter in the resets of the selected field.\n     */\n    int countReferencesInFieldResets(QString const& parameterID,\n        QSharedPointer<QList<QSharedPointer<FieldReset> > >  resets) const;\n\n    /*!\n     *  Count the references made to the selected parameter in the selected field reset.\n     *\n     *    @param [in] parameterID     ID of the selected parameter.\n     *    @param [in] fieldReset      The selected field reset.\n     *\n     *    @return The amount of references made to the selected parameter in the selected field reset.\n     */\n    int countReferencesInSingleFieldReset(QString const& parameterID, QSharedPointer<FieldReset> fieldReset) const;\n\n    /*!\n     *\tCount the references made to the selected parameter in the field access policies in the selected field.\n     *  \n     *    @param [in] parameterID        ID of the selected parameter\n     *    @param [in] accessPolicies     Field access policies of the selected field.\n     *\t    \n     * \t    @return The number of references made to the selected parameters in the field access policies.\n     */\n    int countReferencesInFieldAccessPolicies(QString const& parameterID, \n        QSharedPointer<QList<QSharedPointer<FieldAccessPolicy> > > accessPolicies) const;\n\n    /*!\n     *  Count the references made to the selected parameter in the contained address spaces.\n     *\n     *    @param [in] parameterID     ID of the selected parameter.\n     *\n     *    @return The amount of references made to the selected parameter in the contained address spaces.\n     */\n    int countReferencesInAddressSpaces(QString const& parameterID) const;\n\n    /*!\n     *  Count the references made to the selected parameter in the selected address space.\n     *\n     *    @param [in] parameterID     ID of the selected parameter.\n     *    @param [in] space           The selected address space.\n     *\n     *    @return The amount of references made to the selected parameter in the selected address space.\n     */\n    int countReferencesInSingleAddressSpace(QString const& parameterID, QSharedPointer<AddressSpace> space) const;\n\n    /*!\n     *  Count the references made to the selected parameter in the selected address space values.\n     *\n     *    @param [in] parameterID     ID of the selected parameter.\n     *    @param [in] space           The selected address space.\n     *\n     *    @return The amount of references made to the selected parameter in the selected address space values.\n     */\n    int countReferencesInSingleAddressSpaceItems(QString const& parameterID, QSharedPointer<AddressSpace> space)\n        const;\n\n    /*!\n     *  Count the references made to the selected parameter in the selected segments.\n     *\n     *    @param [in] parameterID     ID of the selected parameter.\n     *    @param [in] segments        The selected segments.\n     *\n     *    @return The amount of references made to the selected parameter in the selected segments.\n     */\n    int countReferencesInSegments(QString const& parameterID,\n        QSharedPointer<QList<QSharedPointer<Segment> > > segments) const;\n\n    /*!\n     *  Count the references made to the selected parameter in the selected segment.\n     *\n     *    @param [in] parameterID     ID of the selected parameter.\n     *    @param [in] segment         The selected segment.\n     *\n     *    @return The amount of references made to the selected parameter in the selected segment.\n     */\n    int countReferencesInSingleSegment(QString const& parameterID, QSharedPointer<Segment> segment) const;\n\n    /*!\n     *  Count the references made to the selected parameter in the contained instantiations.\n     *\n     *    @param [in] parameterID     ID of the selected parameter.\n     *\n     *    @return The amount of references made to the selected parameter in the contained instantiations.\n     */\n    int countReferencesInInstantiations(QString const& parameterID) const;\n\n    /*!\n     *  Count the references made to the selected parameter in the selected component instantiations.\n     *\n     *    @param [in] parameterID     ID of the selected parameter.\n     *    @param [in] instantiations  The selected component instantiations.\n     *\n     *    @return The amount of references made to the selected parameter in the selected component\n     *              instantiations.\n     */\n    int countReferencesInComponentInstantiations(QString const& parameterID,\n        QSharedPointer<QList<QSharedPointer<ComponentInstantiation> > > instantiations) const;\n\n    /*!\n     *  Count the references made to the selected parameter in the selected component instantiation.\n     *\n     *    @param [in] parameterID     ID of the selected parameter.\n     *    @param [in] instantiation   The selected component instantiation.\n     *\n     *    @return The amount of references made to the selected parameter in the selected component\n     *              instantiation.\n     */\n    int countReferencesInSingleComponentInstantiation(QString const& parameterID,\n        QSharedPointer<ComponentInstantiation> instantiation) const;\n\n    /*!\n     *  Count the references made to the selected parameter in the selected module parameters.\n     *\n     *    @param [in] parameterID         ID of the selected parameter.\n     *    @param [in] moduleParameters    The selected module parameters.\n     *\n     *    @return The amount of references made to the selected parameter in the selected module parameters.\n     */\n    int countReferencesInModuleParameters(QString const& parameterID,\n        QSharedPointer<QList<QSharedPointer<ModuleParameter> > > moduleParameters) const;\n\n    /*!\n     *  Count the references made to the selected parameter in the selected design configuration instantiations.\n     *\n     *    @param [in] parameterID     ID of the selected parameter.\n     *    @param [in] instantiations  The selected design configuration instantiations.\n     *\n     *    @return The amount of references made to the selected parameter in the selected design configuration\n     *              instantiations.\n     */\n    int countReferencesInDesignConfigurationInstantiations(QString const& parameterID,\n        QSharedPointer<QList<QSharedPointer<DesignConfigurationInstantiation> > > instantiations) const;\n\n    /*!\n     *  Count the references made to the selected parameter in the selected design configuration instantiation.\n     *\n     *    @param [in] parameterID     ID of the selected parameter.\n     *    @param [in] instantiation   The selected design configuration instantiation.\n     *\n     *    @return The amount of references made to the selected parameter in the selected design configuration\n     *              instantiation.\n     */\n    int countReferencesInSingleDesignConfigurationInstantiation(QString const& parameterID,\n        QSharedPointer<DesignConfigurationInstantiation> instantiation) const;\n\n    /*!\n     *  Count the references made to the selected parameter in the selected design instantiations.\n     *\n     *    @param [in] parameterID     ID of the selected parameter.\n     *\n     *    @return The amount of references made to the selected parameter in the selected design instantiations.\n     */\n    int countReferencesInDesignInstantiations(QString const& parameterID) const;\n\n    /*!\n     *  Count the references made to the selected parameter in the selected design instantiation.\n     *\n     *    @param [in] parameterID     ID of the selected parameter.\n     *    @param [in] instantiation   The selected design instantiation.\n     *\n     *    @return The amount of references made to the selected parameter in the selected design instantiation.\n     */\n    int countReferencesInSingleDesigninstantiation(QString const& parameterID,\n        QSharedPointer<DesignInstantiation> instantiation) const;\n\n    /*!\n     *  Count the references made to the selected parameter in the contained ports.\n     *\n     *    @param [in] parameterID     ID of the selected parameter.\n     *\n     *    @return The amount of references made to the selected parameter in the contained ports.\n     */\n    int countReferencesInPorts(QString const& parameterID) const;\n\n    /*!\n     *  Count the references made to the selected parameter in the selected port.\n     *\n     *    @param [in] parameterID     ID of the selected parameter.\n     *    @param [in] port            The selected port.\n     *\n     *    @return The amount of references made to the selected parameter in the selected port.\n     */\n    int countReferencesInSinglePort(QString const& parameterID, QSharedPointer<Port> port) const;\n\n    /*!\n     *  Count the references made to the selected parameter in the contained bus interfaces.\n     *\n     *    @param [in] parameterID     ID of the selected parameter.\n     *\n     *    @return The amount of references made to the selected parameter in the contained bus interfaces.\n     */\n    int countReferencesInBusInterfaces(QString const& parameterID) const;\n\n    /*!\n     *  Count the references made to the selected parameter in the selected bus interface.\n     *\n     *    @param [in] parameterID     ID of the selected parameter.\n     *    @param [in] busInterface    The selected bus interface.\n     *\n     *    @return The amount of references made to the selected parameter in the selected bus interface.\n     */\n    int countReferencesInSingleBusInterface(QString const& parameterID, QSharedPointer<BusInterface> busInterface)\n        const;\n\n    /*!\n     *  Count the references made to the selected parameter in the selected mirrored slave bus interface.\n     *\n     *    @param [in] parameterID     ID of the selected parameter.\n     *    @param [in] mirroredSlave   The selected mirrored slave bus interface.\n     *\n     *    @return The amount of references made to the selected parameter in the selected mirrored slave bus\n     *              interface.\n     */\n    int countReferencesInMirroredSlaveInterface(QString const& parameterID,\n        QSharedPointer<MirroredTargetInterface> mirroredSlave) const;\n\n    /*!\n     *  Count the references made to the selected parameter in the selected master bus interface.\n     *\n     *    @param [in] parameterID     ID of the selected parameter.\n     *    @param [in] master          The selected master bus interface.\n     *\n     *    @return The amount of references made to the selected parameter in the selected master bus interface.\n     */\n    int countReferencesInMasterInterface(QString const& parameterID, QSharedPointer<InitiatorInterface> master) const;\n\n    /*!\n     *  Count the references made to the selected parameter in the selected mirrored slave remap address.\n     *\n     *    @param [in] parameterID     ID of the selected parameter.\n     *    @param [in] remapAddress    The selected mirrored slave remap address.\n     *\n     *    @return The amount of references made to the selected parameter in the selected mirrored slave remap\n     *              address.\n     */\n    int countReferencesInRemapAddress(QString const& parameterID,\n        QSharedPointer<MirroredTargetInterface::RemapAddress> remapAddress) const;\n\n    /*!\n     *  Count the references made to the selected parameter in the contained remap states.\n     *\n     *    @param [in] parameterID     ID of the selected parameter.\n     *\n     *    @return The amount of references made to the selected parameter in the contained remap states.\n     */\n    int countReferencesInRemapStates(QString const& parameterID) const;\n\n    /*!\n     *  Count the references made to the selected parameter in the selected remap state.\n     *\n     *    @param [in] parameterID     ID of the selected parameter.\n     *    @param [in] remapState      The selected remap state.\n     *\n     *    @return The amount of references made to the selected parameter in the selected remap state.\n     */\n    int countReferencesInSingleRemapState(QString const& parameterID, QSharedPointer<RemapState> remapState) const;\n\n    /*!\n     *  Count the references made to the selected parameter in the selected remap port.\n     *\n     *    @param [in] parameterID     ID of the selected parameter.\n     *    @param [in] port            The selected remap port.\n     *\n     *    @return The amount of references made to the selected parameter in the selected remap port.\n     */\n    int countReferencesInSingleRemapPort(QString const& parameterID, QSharedPointer<RemapPort> port) const;\n\n    /*!\n     *  Count the references made to the selected parameter in the contained modes.\n     *\n     *    @param [in] parameterID     ID of the selected parameter.\n     *\n     *    @return The amount of references made to the selected parameter in the contained modes.\n     */\n    int countReferencesInModes(QString const& parameterID) const;\n\n    /*!\n     *  Count the references made to the selected parameter in the selected mode.\n     *\n     *    @param [in] parameterID     ID of the selected parameter.\n     *    @param [in] mode            The selected mode.\n     *\n     *    @return The amount of references made to the selected parameter in the selected mode.\n     */\n    int countReferencesInSingleMode(QString const& parameterID, QSharedPointer<Mode> mode) const;\n\n    /*!\n     *  Count the references made to the selected parameter in the selected mode condition.\n     *\n     *    @param [in] parameterID     ID of the selected parameter.\n     *    @param [in] condition       The selected condition expression.\n     *\n     *    @return The amount of references made to the selected parameter in the selected expression.\n     */\n    int countReferencesInModeCondition(QString const& parameterID, QString const& condition) const;\n\n    /*!\n     *  Count the references made to the selected parameter in the port slices of the selected mode.\n     *\n     *    @param [in] parameterID     ID of the selected parameter.\n     *    @param [in] mode            The selected mode.\n     *\n     *    @return The amount of references made to the selected parameter in the port slices.\n     */\n    int countReferencesInPortSlices(QString const& parameterID, QSharedPointer<Mode> mode) const;\n\n     /*!\n      *  Count the references made to the selected parameter in the field slices of the selected mode.\n      *\n      *    @param [in] parameterID    ID of the selected parameter.\n      *    @param [in] mode           The selected mode.\n      *\n      *    @return The amount of references made to the selected parameter in the selected field slice.\n      */\n    int countReferencesInFieldSlices(QString const& parameterID, QSharedPointer<Mode> mode) const;\n\n    /*!\n     *  Count the references made to the selected parameter in the selected port slice.\n     *\n     *    @param [in] parameterID     ID of the selected parameter.\n     *    @param [in] portSlice       The selected port slice.\n     *\n     *    @return The amount of references made to the selected parameter in the port slice.\n     */\n    int countReferencesInSinglePortSlice(QString const& targetID, QSharedPointer<PortSlice> portSlice) const;\n        \n    /*!\n     *  Count the references made to the selected parameter in the selected field slice.\n     *\n     *    @param [in] parameterID     ID of the selected parameter.\n     *    @param [in] fieldSlice      The selected field slice.\n     *\n     *    @return The amount of references made to the selected parameter in the field slice.\n     */\n    int countReferencesInSingleFieldSlice(QString const& parameterID, QSharedPointer<FieldSlice> fieldSlice) const;\n\n    /*!\n     *  Count the references made to the selected parameter in indirect interfaces.\n     *\n     *    @param [in] parameterID     ID of the selected parameter.\n     *\n     *    @return The amount of references made to the selected parameter in the indirect interfaces.\n     */\n    int countReferencesInIndirectInterfaces(QString const& parameterID) const;\n\n    /*!\n     *  Count the references made to the selected parameter in the selected indirect interface.\n     *\n     *    @param [in] parameterID         ID of the selected parameter.\n     *    @param [in] indirectInterface   The selected indirect interface.\n     *\n     *    @return The amount of references made to the selected parameter in the selected indirect interface.\n     */\n    int countRefrencesInSingleIndirectInterface(QString const& parameterID,\n        QSharedPointer<IndirectInterface> indirectInterface) const;\n\n    /*!\n     *  Count the references made to the selected parameter in CPUs.\n     *\n     *    @param [in] parameterID     ID of the selected parameter.\n     *\n     *    @return The amount of references made to the selected parameter in the CPUs.\n     */\n    int countReferencesInCpus(QString const& parameterID) const;\n\n    /*!\n     *  Count the references made to the selected parameter in the selected CPU.\n     *\n     *    @param [in] parameterID         ID of the selected parameter.\n     *    @param [in] cpu                 The selected CPU.\n     *\n     *    @return The amount of references made to the selected parameter in the selected CPU.\n     */\n    int countReferencesInSingleCpu(QString const& parameterID, QSharedPointer<Cpu> cpu) const;\n\n    /*!\n     *  Count the references made to the selected parameter in CPU regions interfaces.\n     *\n     *    @param [in] parameterID     ID of the selected parameter.\n     *    @param [in] regions         The selected CPU regions.\n     *\n     *    @return The amount of references made to the selected parameter in the CPU regions.\n     */\n    int countReferencesInRegions(QString const& parameterID, \n        QSharedPointer<QList<QSharedPointer<Region> > > regions) const;\n    \n    /*!\n     *  Count the references made to the selected parameter in the selected CPU region.\n     *\n     *    @param [in] parameterID         ID of the selected parameter.\n     *    @param [in] region              The selected CPU region.\n     *\n     *    @return The amount of references made to the selected parameter in the selected CPU region.\n     */\n    int countReferencesInSingleRegion(QString const& parameterID, QSharedPointer<Region> region) const;\n\n\n    /*!\n     *  Count the references made to the selected parameter in power domains.\n     *\n     *    @param [in] parameterID     ID of the selected parameter.\n     *\n     *    @return The amount of references made to the selected parameter in the power domains.\n     */\n    int countReferencesInPowerDomains(QString const& parameterID) const;\n        \n    /*!\n     *  Count the references made to the selected parameter in the selected power domain.\n     *\n     *    @param [in] parameterID         ID of the selected parameter.\n     *    @param [in] powerDomain         The selected power domain.\n     *\n     *    @return The amount of references made to the selected parameter in the selected power domain.\n     */\n    int countReferencesInSinglePowerDomain(QString const& parameterID, \n        QSharedPointer<PowerDomain> powerDomain) const;\n\npublic slots:\n\n    /*!\n     *  Recalculate references made to the selected parameters.\n     *\n     *    @param [in] parameterList       The selected parameters.\n     *    @param [in] parameterInterface  Interface for accessing parameters.\n     */\n    virtual void recalculateReferencesToParameters(QVector<QString> const& parameterList,\n        AbstractParameterInterface* parameterInterface) override final;\n\nprivate:\n\n    /*!\n     *  Count the references made to the selected parameter in the selected write constraint.\n     *\n     *    @param [in] parameterID         ID of the selected parameter.\n     *    @param [in] writeConstraint     The selected write constraint.\n     *\n     *    @return The amount of references made to the selected parameter in the selected write constraint.\n     */\n    int countReferencesInWriteConstraint(QString const& parameterID,\n        QSharedPointer<WriteValueConstraint> writeConstraint) const;\n\n    //-----------------------------------------------------------------------------\n    // Data.\n    //-----------------------------------------------------------------------------\n\n    //! The containing component.\n    QSharedPointer<Component> component_;\n\n};\n\n#endif // COMPONENTPARAMETERREFERENCECOUNTER_H\n"
  },
  {
    "path": "editors/ComponentEditor/referenceCounter/ParameterReferenceCounter.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ParameterReferenceCounter.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Mikko Teuho\r\n// Date: 14.01.2015\r\n//\r\n// Description:\r\n// Calculates the amount of references made to parameters and gives this data to the parameters.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"ParameterReferenceCounter.h\"\r\n\r\n#include <IPXACTmodels/common/Parameter.h>\r\n#include <IPXACTmodels/common/ConfigurableElementValue.h>\r\n\r\n#include <KactusAPI/include/AbstractParameterInterface.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ParameterReferenceCounter::ParameterReferenceCounter()\r\n//-----------------------------------------------------------------------------\r\nParameterReferenceCounter::ParameterReferenceCounter(QSharedPointer<ParameterFinder> parameterFinder):\r\nparameterFinder_(parameterFinder)\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ParameterReferenceCounter::increaseReferenceCount()\r\n//-----------------------------------------------------------------------------\r\nvoid ParameterReferenceCounter::increaseReferenceCount(QString const& id)\r\n{\r\n    QSharedPointer<Parameter> targetParameter = parameterFinder_->getParameterWithID(id);\r\n\r\n    if (targetParameter)\r\n    {\r\n        targetParameter->increaseUsageCount();\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ParameterReferenceCounter::decreaseReferenceCount()\r\n//-----------------------------------------------------------------------------\r\nvoid ParameterReferenceCounter::decreaseReferenceCount(QString const& id)\r\n{\r\n    QSharedPointer<Parameter> targetParameter = parameterFinder_->getParameterWithID(id);\r\n\r\n    if (targetParameter)\r\n    {\r\n        targetParameter->decreaseUsageCount();\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ParameterReferenceCounter::countReferencesInParameters()\r\n//-----------------------------------------------------------------------------\r\nint ParameterReferenceCounter::countReferencesInParameters(QString const& parameterID,\r\n    QSharedPointer<QList<QSharedPointer<Parameter> > > parameters) const\r\n{\r\n    int referenceCount = 0;\r\n\r\n    foreach (QSharedPointer<Parameter> singleParameter, *parameters)\r\n    {\r\n        referenceCount += countReferencesInSingleParameter(parameterID, singleParameter);\r\n    }\r\n\r\n    return referenceCount;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ParameterReferenceCounter::countReferencesInSingleParameter()\r\n//-----------------------------------------------------------------------------\r\nint ParameterReferenceCounter::countReferencesInSingleParameter(QString const& parameterID,\r\n    QSharedPointer<Parameter> parameter) const\r\n{\r\n    int referenceCount = 0;\r\n\r\n    referenceCount += countReferencesInExpression(parameterID, parameter->getValue());\r\n    referenceCount += countReferencesInExpression(parameterID, parameter->getVectorLeft());\r\n    referenceCount += countReferencesInExpression(parameterID, parameter->getVectorRight());\r\n    referenceCount +=\r\n        countReferencesInExpression(parameterID, parameter->getAttribute(QLatin1String(\"kactus2:arrayLeft\")));\r\n    referenceCount +=\r\n        countReferencesInExpression(parameterID, parameter->getAttribute(QLatin1String(\"kactus2:arrayRight\")));\r\n\r\n    return referenceCount;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ParameterReferenceCounter::countReferencesInConfigurableElementValues()\r\n//-----------------------------------------------------------------------------\r\nint ParameterReferenceCounter::countReferencesInConfigurableElementValues(QString const& parameterId,\r\n    QSharedPointer<QList<QSharedPointer<ConfigurableElementValue> > > configurableElements) const\r\n{\r\n    int referenceCount = 0;\r\n\r\n    foreach (QSharedPointer<ConfigurableElementValue> element, *configurableElements)\r\n    {\r\n        referenceCount += countReferencesInSingleConfigurableElementValue(parameterId, element);\r\n    }\r\n\r\n    return referenceCount;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ParameterReferenceCounter::countReferencesInSingleConfigurableElementValue()\r\n//-----------------------------------------------------------------------------\r\nint ParameterReferenceCounter::countReferencesInSingleConfigurableElementValue(QString const& parameterID,\r\n    QSharedPointer<ConfigurableElementValue> element) const\r\n{\r\n    return countReferencesInExpression(parameterID, element->getConfigurableValue());\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ParameterReferenceCounter::countReferencesInExpression()\r\n//-----------------------------------------------------------------------------\r\nint ParameterReferenceCounter::countReferencesInExpression(QString const& parameterID,\r\n    QString const& expression) const\r\n{\r\n    return expression.count(parameterID);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ParameterReferenceCounter::recalculateReferencesToParameters()\r\n//-----------------------------------------------------------------------------\r\nvoid ParameterReferenceCounter::recalculateReferencesToParameters(QVector<QString> const& parameterList,\r\n    AbstractParameterInterface* parameterInterface)\r\n{\r\n    for (auto parameterName : parameterList)\r\n    {\r\n        QString parameterID = QString::fromStdString(parameterInterface->getID(parameterName.toStdString()));\r\n        if (!parameterID.isEmpty())\r\n        {\r\n            int referenceCount = countReferencesInInterfacedParameters(parameterID, parameterInterface);\r\n\r\n            parameterInterface->setUsageCount(parameterName.toStdString(), referenceCount);\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ParameterReferenceCounter::countReferencesInInterfacedParameters()\r\n//-----------------------------------------------------------------------------\r\nint ParameterReferenceCounter::countReferencesInInterfacedParameters(QString const& parameterID,\r\n    AbstractParameterInterface* parameterInterface) const\r\n{\r\n    int referenceCount = 0;\r\n\r\n    for (auto parameter : parameterInterface->getItemNames())\r\n    {\r\n        referenceCount += countReferencesInExpression(\r\n            parameterID, QString::fromStdString(parameterInterface->getValueExpression(parameter)));\r\n        referenceCount += countReferencesInExpression(\r\n            parameterID, QString::fromStdString(parameterInterface->getBitWidthLeftExpression(parameter)));\r\n        referenceCount += countReferencesInExpression(\r\n            parameterID, QString::fromStdString(parameterInterface->getBitWidthRightExpression(parameter)));\r\n        referenceCount += countReferencesInExpression(\r\n            parameterID, QString::fromStdString(parameterInterface->getArrayLeftExpression(parameter)));\r\n        referenceCount += countReferencesInExpression(\r\n            parameterID, QString::fromStdString(parameterInterface->getArrayRightExpression(parameter)));\r\n    }\r\n\r\n    return referenceCount;\r\n}\r\n"
  },
  {
    "path": "editors/ComponentEditor/referenceCounter/ParameterReferenceCounter.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ParameterReferenceCounter.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Mikko Teuho\r\n// Date: 14.01.2015\r\n//\r\n// Description:\r\n// Calculates the amount of references made to parameters and gives this data to the parameters.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef PARAMETERREFERENCECOUNTER_H\r\n#define PARAMETERREFERENCECOUNTER_H\r\n\r\n#include \"ReferenceCounter.h\"\r\n\r\n#include <KactusAPI/include/ComponentParameterFinder.h>\r\n#include <KactusAPI/include/ParameterFinder.h>\r\n\r\nclass ConfigurableElementValue;\r\nclass AbstractParameterInterface;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! ParameterReferenceCounter class. \r\n//-----------------------------------------------------------------------------\r\nclass ParameterReferenceCounter : public ReferenceCounter\r\n{\r\n    Q_OBJECT\r\n\r\npublic:\r\n\r\n    /*!\r\n     *  The constructor.\r\n     *\r\n     *    @param [in] parameterFinder     The parameter finder.\r\n     */\r\n    explicit ParameterReferenceCounter(QSharedPointer<ParameterFinder> parameterFinder);\r\n\r\n    //! No copying.\r\n    ParameterReferenceCounter(const ParameterReferenceCounter& other) = delete;\r\n\r\n    //! No assignment.\r\n    ParameterReferenceCounter& operator=(const ParameterReferenceCounter& other) = delete;\r\n\r\n    /*!\r\n     *  The destructor.\r\n     */\r\n    virtual ~ParameterReferenceCounter() = default;\r\n\r\n    /*!\r\n     *  Count the references made to the selected parameter in the selected parameters.\r\n     *\r\n     *    @param [in] parameterID     ID of the selected parameter.\r\n     *    @param [in] parameters      The selected parameters.\r\n     *\r\n     *    @return The amount of references made to the selected parameter in the selected parameters.\r\n     */\r\n    virtual int countReferencesInParameters(QString const& parameterID,\r\n        QSharedPointer<QList<QSharedPointer<Parameter> > > parameters) const;\r\n\r\n    /*!\r\n     *  Count the references made to the selected parameter in the selected parameter.\r\n     *\r\n     *    @param [in] parameterID     ID of the selected parameter.\r\n     *    @param [in] parameter       The selected parameter.\r\n     *\r\n     *    @return The amount of references made to the selected parameter in the selected parameter.\r\n     */\r\n    int countReferencesInSingleParameter(QString const& parameterID, QSharedPointer<Parameter> parameter) const;\r\n\r\n    /*!\r\n     *  Count the references made to the selected parameter in the selected configurable element values.\r\n     *\r\n     *    @param [in] parameterID             ID of the selected parameter.\r\n     *    @param [in] configurableElements    The selected configurable element values.\r\n     *\r\n     *    @return The amount of references made to the selected parameter in the selected configurable element\r\n     *              values.\r\n     */\r\n    int countReferencesInConfigurableElementValues(QString const& parameterId,\r\n        QSharedPointer<QList<QSharedPointer<ConfigurableElementValue> > > configurableElements) const;\r\n\r\n    /*!\r\n     *  Count the references made to the selected parameter in the selected configurable element value.\r\n     *\r\n     *    @param [in] parameterID     ID of the selected parameter.\r\n     *    @param [in] element         The selected configurable element value.\r\n     *\r\n     *    @return The amount of references made to the selected parameter in the selected configurable element\r\n     *              value.\r\n     */\r\n    int countReferencesInSingleConfigurableElementValue(QString const& parameterID,\r\n        QSharedPointer<ConfigurableElementValue> element) const;\r\n    \r\n    /*!\r\n     *  Count the references made to the selected parameter in the selected expression.\r\n     *\r\n     *    @param [in] parameterID     ID of the selected parameter.\r\n     *    @param [in] expression      The selected expression.\r\n     *\r\n     *    @return The amount of references made to the selected parameter in the selected expression.\r\n     */\r\n    int countReferencesInExpression(QString const& parameterID, QString const& expression) const;\r\n\r\npublic slots:\r\n\r\n    /*!\r\n     *  Increase the reference count of the parameter matching the id.\r\n     *\r\n     *    @param [in] id      The id of the parameter which is being referenced.\r\n     */\r\n    virtual void increaseReferenceCount(QString const& id) override;\r\n    \r\n    /*!\r\n     *  Decrease the reference count of the parameter matching the id.\r\n     *\r\n     *    @param [in] id      The id of the parameter which was referenced.\r\n     */\r\n    virtual void decreaseReferenceCount(QString const& id) override;\r\n\r\n    /*!\r\n     *  Recalculate references made to the selected parameters.\r\n     *\r\n     *    @param [in] parameterList       The selected parameters.\r\n     *    @param [in] parameterInterface  Interface for accessing parameters.\r\n     */\r\n    virtual void recalculateReferencesToParameters(QVector<QString> const& parameterList,\r\n        AbstractParameterInterface* parameterInterface) override;\r\n\r\nprivate:\r\n\r\n    /*!\r\n     *  Count references made in the selected parameter interface to the selected ID.\r\n     *\r\n     *    @param [in] parameterID         The selected parameter ID.\r\n     *    @param [in] parameterInterface  Interface for accessing parameters.\r\n     *\r\n     *    @return The number of references made.\r\n     */\r\n    int countReferencesInInterfacedParameters(QString const& parameterID,\r\n        AbstractParameterInterface* parameterInterface) const;\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! Object for finding parameters with the correct id.\r\n    QSharedPointer<ParameterFinder> parameterFinder_;\r\n};\r\n\r\n#endif // PARAMETERREFERENCECOUNTER_H\r\n"
  },
  {
    "path": "editors/ComponentEditor/referenceCounter/ReferenceCounter.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ReferenceCounter.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Mikko Teuho\r\n// Date: 14.01.2015\r\n//\r\n// Description:\r\n// The interface for reference counters.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef REFERENCECOUNTER_H\r\n#define REFERENCECOUNTER_H\r\n\r\n#include <QObject>\r\n#include <QSharedPointer>\r\n\r\nclass AbstractParameterInterface;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! ParameterCounter interface. \r\n//-----------------------------------------------------------------------------\r\nclass ReferenceCounter : public QObject\r\n{\r\n    Q_OBJECT\r\n\r\npublic:\r\n\r\n    virtual ~ReferenceCounter() = default;\r\n\r\npublic slots:\r\n\r\n    /*!\r\n     *  Increase the reference count of the parameter matching the id.\r\n     *\r\n     *    @param [in] id      The id of the parameter which is being referenced.\r\n     */\r\n    virtual void increaseReferenceCount(QString const& id) = 0;\r\n\r\n    /*!\r\n     *  Decrease the reference count of the parameter matching the id.\r\n     *\r\n     *    @param [in] id      The id of the parameter which was referenced.\r\n     */\r\n    virtual void decreaseReferenceCount(QString const& id) = 0;\r\n\r\n    /*!\r\n     *  Recalculate references made to the selected parameters.\r\n     *\r\n     *    @param [in] parameterList       The selected parameters.\r\n     *    @param [in] parameterInterface  Interface for accessing parameters.\r\n     */\r\n    virtual void recalculateReferencesToParameters(QVector<QString> const& parameterList,\r\n        AbstractParameterInterface* parameterInterface) = 0;\r\n};\r\n\r\n#endif // REFERENCECOUNTER_H\r\n"
  },
  {
    "path": "editors/ComponentEditor/remapStates/RemapConditionColumns.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: RemapConditionColumns.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Mikko Teuho\r\n// Date: 09.04.2015\r\n//\r\n// Description:\r\n// Common declarations for editing remap conditions\r\n//-----------------------------------------------------------------------------\r\n\r\nnamespace RemapConditionColumns\r\n{\r\n    //! The editable columns in the remap condition editor.\r\n    enum columns\r\n    {\r\n        NAME_COLUMN = 0,    //!< Column for the name of the remap condition.\r\n        LEFT_COLUMN,        //!< Column for the left bound of the remap port.\r\n        RIGHT_COLUMN,       //!< Column for the right bound of the remap port.\r\n        VALUE_COLUMN,       //!< Column for the value of the remap port.\r\n        COLUMN_COUNT\r\n    };\r\n}\r\n"
  },
  {
    "path": "editors/ComponentEditor/remapStates/RemapConditionDelegate.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: RemapConditionDelegate.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Mikko Teuho\r\n// Date: 09.04.2015\r\n//\r\n// Description:\r\n// Delegate that provides widgets for editing remap condition.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"RemapConditionDelegate.h\"\r\n\r\n#include \"RemapConditionColumns.h\"\r\n\r\n#include <KactusAPI/include/ParameterFinder.h>\r\n#include <KactusAPI/include/IPXactSystemVerilogParser.h>\r\n\r\n#include <editors/ComponentEditor/common/ReferenceSelector/ReferenceSelector.h>\r\n\r\n#include <editors/ComponentEditor/remapStates/ValueOrIndexedValueEditor.h>\r\n\r\n#include <IPXACTmodels/common/Choice.h>\r\n\r\n#include <QCompleter>\r\n#include <QScrollArea>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: RemapConditionDelegate::RemapConditionDelegate()\r\n//-----------------------------------------------------------------------------\r\nRemapConditionDelegate::RemapConditionDelegate(QStringList const& portNameList, QAbstractItemModel* completionModel,\r\n                        QSharedPointer<ParameterFinder> finder, QSharedPointer<ExpressionParser> expressionParser,\r\n                        QSharedPointer<ExpressionFormatter> expressionFormatter, Document::Revision docRevision, \r\n                        QObject* parent /*= 0*/) :\r\nExpressionDelegate(completionModel, finder, parent),\r\nexpressionFormatter_(expressionFormatter),\r\nexpressionParser_(expressionParser),\r\navailablePortNames_(portNameList),\r\ndocRevision_(docRevision)\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: RemapConditionDelegate::~RemapConditionDelegate()\r\n//-----------------------------------------------------------------------------\r\nRemapConditionDelegate::~RemapConditionDelegate()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: RemapConditionDelegate::createEditor()\r\n//-----------------------------------------------------------------------------\r\nQWidget* RemapConditionDelegate::createEditor(QWidget* parent, QStyleOptionViewItem const& option,\r\n    QModelIndex const& index) const\r\n{\r\n    if (index.column() == RemapConditionColumns::NAME_COLUMN)\r\n    {\r\n        ReferenceSelector* referenceSelector = new ReferenceSelector(parent);\r\n\r\n        QStringList visiblePortNames = availablePortNames_;\r\n        QString selectedName = index.model()->data(index, Qt::DisplayRole).toString();\r\n        if (componentPortNames_.contains(selectedName))\r\n        {\r\n            visiblePortNames.append(selectedName);\r\n        }\r\n\r\n        referenceSelector->refresh(visiblePortNames);\r\n\r\n        return referenceSelector;\r\n    }\r\n\r\n    else if (index.column() == RemapConditionColumns::VALUE_COLUMN && valueIsArray(index))\r\n    {\r\n        ValueOrIndexedValueEditor* editor =\r\n            new ValueOrIndexedValueEditor(getParameterFinder(), expressionParser_, expressionFormatter_, docRevision_, parent);\r\n\r\n        parent->installEventFilter(editor);\r\n\r\n        connect(editor, SIGNAL(increaseReferences(QString)),\r\n            this, SIGNAL(increaseReferences(QString)), Qt::UniqueConnection);\r\n        connect(editor, SIGNAL(decreaseReferences(QString)),\r\n            this, SIGNAL(decreaseReferences(QString)), Qt::UniqueConnection);\r\n\r\n        return editor;\r\n    }\r\n\r\n    else\r\n    {\r\n        return ExpressionDelegate::createEditor(parent, option, index);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: RemapConditionDelegate::setEditorData()\r\n//-----------------------------------------------------------------------------\r\nvoid RemapConditionDelegate::setEditorData(QWidget* editor, QModelIndex const& index) const\r\n{\r\n    if (index.column() == RemapConditionColumns::NAME_COLUMN)\r\n    {\r\n        QString text = index.model()->data(index, Qt::DisplayRole).toString();\r\n        ReferenceSelector* referenceSelector = qobject_cast<ReferenceSelector*>(editor);\r\n\r\n        referenceSelector->selectItem(text);\r\n    }\r\n    else if (index.column() == RemapConditionColumns::VALUE_COLUMN && valueIsArray(index))\r\n    {\r\n        setValueAndArrayEditor(editor, index);\r\n    }\r\n    else\r\n    {\r\n        ExpressionDelegate::setEditorData(editor, index);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: RemapConditionDelegate::setValueAndArrayEditor()\r\n//-----------------------------------------------------------------------------\r\nvoid RemapConditionDelegate::setValueAndArrayEditor(QWidget* editor, QModelIndex const& index) const\r\n{\r\n    QModelIndex portLeftIndex = index.sibling(index.row(), RemapConditionColumns::LEFT_COLUMN);\r\n    int portLeft = portLeftIndex.data(Qt::ToolTipRole).toInt();\r\n\r\n    QModelIndex portRightIndex = index.sibling(index.row(), RemapConditionColumns::RIGHT_COLUMN);\r\n    int portRight = portRightIndex.data(Qt::ToolTipRole).toInt();\r\n\r\n    QModelIndex valueIndex = index.sibling(index.row(), RemapConditionColumns::VALUE_COLUMN);\r\n    QString portValue = valueIndex.data(Qt::EditRole).toString();\r\n\r\n    ValueOrIndexedValueEditor* valueEditor = qobject_cast<ValueOrIndexedValueEditor*>(editor);\r\n    if (valueEditor)\r\n    {\r\n        valueEditor->setupArrayEditor(portValue, portLeft, portRight);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: RemapConditionDelegate::setModelData()\r\n//-----------------------------------------------------------------------------\r\nvoid RemapConditionDelegate::setModelData(QWidget* editor, QAbstractItemModel* model, QModelIndex const& index)\r\n    const\r\n{\r\n    if (index.column() == RemapConditionColumns::NAME_COLUMN)\r\n    {\r\n        ReferenceSelector* referenceSelector = qobject_cast<ReferenceSelector*>(editor);\r\n        QString text = referenceSelector->currentText();\r\n        model->setData(index, text, Qt::EditRole);\r\n    }\r\n    else if (index.column() == RemapConditionColumns::VALUE_COLUMN && valueIsArray(index))\r\n    {\r\n        ValueOrIndexedValueEditor* valueEditor = qobject_cast<ValueOrIndexedValueEditor*>(editor);\r\n        if (valueEditor)\r\n        {\r\n            QString arrayValue = valueEditor->getValueData();\r\n\r\n            model->setData(index, arrayValue, Qt::EditRole);\r\n        }\r\n    }\r\n    else\r\n    {\r\n        ExpressionDelegate::setModelData(editor, model, index);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: RemapConditionDelegate::columnAcceptsExpression()\r\n//-----------------------------------------------------------------------------\r\nbool RemapConditionDelegate::columnAcceptsExpression(int column) const\r\n{\r\n    return column == RemapConditionColumns::VALUE_COLUMN;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: RemapConditionDelegate::descriptionColumn()\r\n//-----------------------------------------------------------------------------\r\nint RemapConditionDelegate::descriptionColumn() const\r\n{\r\n    return -1;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: RemapConditionDelegate::valueIsArray()\r\n//-----------------------------------------------------------------------------\r\nbool RemapConditionDelegate::valueIsArray(QModelIndex const& index) const\r\n{\r\n    QModelIndex portLeftIndex = index.sibling(index.row(), RemapConditionColumns::LEFT_COLUMN);\r\n    bool portLeftIsOk = true;\r\n    portLeftIndex.data(Qt::ToolTipRole).toInt(&portLeftIsOk);\r\n\r\n    QModelIndex portRightIndex = index.sibling(index.row(), RemapConditionColumns::RIGHT_COLUMN);\r\n    bool portRightIsOk = true;\r\n    portRightIndex.data(Qt::ToolTipRole).toInt(&portRightIsOk);\r\n\r\n    int portWidth = getPortWidth(index);\r\n\r\n    return portLeftIsOk && portRightIsOk && portWidth > 1;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: RemapConditionDelegate::getPortWidth()\r\n//-----------------------------------------------------------------------------\r\nint RemapConditionDelegate::getPortWidth(QModelIndex const& index) const\r\n{\r\n    QModelIndex portLeftIndex = index.sibling(index.row(), RemapConditionColumns::LEFT_COLUMN);\r\n    int portLeft = portLeftIndex.data(Qt::ToolTipRole).toInt();\r\n\r\n    QModelIndex portRightIndex = index.sibling(index.row(), RemapConditionColumns::RIGHT_COLUMN);\r\n    int portRight = portRightIndex.data(Qt::ToolTipRole).toInt();\r\n\r\n    return abs(portLeft - portRight) + 1;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: RemapConditionDelegate::updateEditorGeometry()\r\n//-----------------------------------------------------------------------------\r\nvoid RemapConditionDelegate::updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option,\r\n    const QModelIndex &index) const\r\n{\r\n    ExpressionDelegate::updateEditorGeometry(editor, option, index);\r\n\r\n    if (index.column() == RemapConditionColumns::VALUE_COLUMN && valueIsArray(index))\r\n    {\r\n        repositionAndResizeEditor(editor, option, index);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: RemapConditionDelegate::repositionAndResizeEditor()\r\n//-----------------------------------------------------------------------------\r\nvoid RemapConditionDelegate::repositionAndResizeEditor(QWidget* editor, QStyleOptionViewItem const& option,\r\n    QModelIndex const& index) const\r\n{\r\n    int portWidth = getPortWidth(index);\r\n\r\n    const int ROWHEIGHT = 23;\r\n\r\n    int editorMinimumSize = ROWHEIGHT * (portWidth + 4);\r\n\r\n    const int PARENT_HEIGHT = editor->parentWidget()->height();\r\n    const int AVAILABLE_HEIGHT_BELOW = PARENT_HEIGHT - option.rect.top();\r\n\r\n    if (AVAILABLE_HEIGHT_BELOW > editorMinimumSize)\r\n    {\r\n        int movementY = option.rect.topLeft().y() - 20;\r\n\r\n        if (movementY <= 0)\r\n        {\r\n            movementY = 0;\r\n        }\r\n\r\n        QPoint targetPoint (option.rect.topLeft().x(), movementY);\r\n\r\n        editor->move(targetPoint);\r\n    }\r\n    else\r\n    {\r\n        int editorNewY = PARENT_HEIGHT - editorMinimumSize;\r\n\r\n        if (editorNewY <= 0)\r\n        {\r\n            editorNewY = 0;\r\n        }\r\n        editor->move(option.rect.left(), editorNewY);\r\n    }\r\n\r\n    if (editorMinimumSize > PARENT_HEIGHT)\r\n    {\r\n        editor->setFixedHeight(PARENT_HEIGHT);\r\n    }\r\n    else\r\n    {\r\n        editor->setFixedHeight(editorMinimumSize);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: RemapConditionDelegate::setNewPortNames()\r\n//-----------------------------------------------------------------------------\r\nvoid RemapConditionDelegate::setNewPortNames(QStringList const& newPorts)\r\n{\r\n    availablePortNames_ = newPorts;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: RemapConditionDelegate::setComponentPorts()\r\n//-----------------------------------------------------------------------------\r\nvoid RemapConditionDelegate::setComponentPorts(QStringList const& componentPorts)\r\n{\r\n    componentPortNames_ = componentPorts;\r\n}\r\n"
  },
  {
    "path": "editors/ComponentEditor/remapStates/RemapConditionDelegate.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: RemapConditionDelegate.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Mikko Teuho\r\n// Date: 09.04.2015\r\n//\r\n// Description:\r\n// Delegate that provides widgets for editing remap condition.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef REMAPCONDITIONDELEGATE_H\r\n#define REMAPCONDITIONDELEGATE_H\r\n\r\n#include <IPXACTmodels/common/Document.h>\r\n\r\n#include <editors/ComponentEditor/common/ExpressionDelegate.h>\r\n#include <KactusAPI/include/ExpressionFormatter.h>\r\n\r\n#include <QCompleter>\r\n\r\nclass ExpressionParser;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Delegate that provides widgets for editing remap condition.\r\n//-----------------------------------------------------------------------------\r\nclass RemapConditionDelegate : public ExpressionDelegate\r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\r\n    /*!\r\n     *  The constructor.\r\n     *\r\n     *    @param [in] portNameList            The list of available port names.\r\n     *    @param [in] completionModel         Model containing the completions used in expression editor.\r\n     *    @param [in] finder                  The parameter finder to use for expression editors.\r\n     *    @param [in] expressionParser        The expression parser used for calculating expressions.\r\n     *    @param [in] expressionFormatter     The expression formatter for changing ids to parameter names.\r\n     *    @param [in] parent                  The parent of the object.\r\n     */\r\n    RemapConditionDelegate(QStringList const& portNameList, QAbstractItemModel* completionModel, \r\n        QSharedPointer<ParameterFinder> finder, QSharedPointer<ExpressionParser> expressionParser, \r\n        QSharedPointer<ExpressionFormatter> expressionFormatter, Document::Revision docRevision, \r\n        QObject* parent = 0);\r\n\r\n\t//! The destructor\r\n    virtual ~RemapConditionDelegate();\r\n\r\n\t/*! Create a new editor for the given item\r\n\t *\r\n\t *    @param [in] parent   Owner for the editor.\r\n\t *    @param [in] option   Contains options for the editor.\r\n\t *    @param [in] index    Model index identifying the item.\r\n\t *\r\n\t *    @return Pointer to the editor to be used to edit the item.\r\n\t*/\r\n\tvirtual QWidget* createEditor(QWidget* parent, QStyleOptionViewItem const& option, \r\n        QModelIndex const& index) const;\r\n\r\n\t/*! Set the data for the editor.\r\n\t *\r\n\t *    @param [in] editor  Pointer to the editor where the data is to be set.\r\n\t *    @param [in] index   Model index identifying the item that's data is to be set.\r\n\t*/\r\n\tvirtual void setEditorData(QWidget* editor, QModelIndex const& index) const;\r\n\r\n\t/*! Save the data from the editor to the model.\r\n\t *\r\n\t *    @param [in] editor   Pointer to the editor that contains the data to store.\r\n\t *    @param [in] model    Model that contains the data structure where data is to be saved to.\r\n\t *    @param [in] index    Model index identifying the item that's data is to be saved.\r\n\t *\r\n\t*/\r\n\tvirtual void setModelData(QWidget* editor, QAbstractItemModel* model, QModelIndex const& index) const;\r\n\r\n    /*!\r\n     *  Updates the editor geometry.\r\n     *\r\n     *    @param [in] editor  The editor being updated.\r\n     *    @param [in] option  The options used to update the editor.\r\n     *    @param [in] index   The model index being edited.\r\n     */\r\n    virtual void updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option,\r\n        const QModelIndex &index) const;\r\n\r\n    /*!\r\n     *  Set the component ports.\r\n     *\r\n     *    @param [in] componentPorts  All the ports of the component.\r\n     */\r\n    void setComponentPorts(QStringList const& componentPorts);\r\n\r\npublic slots:\r\n    \r\n    /*!\r\n     *  Set the currently available port names.\r\n     *\r\n     *    @param [in] newPorts    The currently available port names.\r\n     */\r\n    void setNewPortNames(QStringList const& newPorts);\r\n\r\nsignals:\r\n\r\n    //! Emitted when the values of the array change.\r\n    void contentChanged();\r\n\r\nprotected:\r\n\r\n    /*!\r\n     *  Checks if the cells in given column accept expression as an input value.\r\n     *\r\n     *    @param [in] column   The column to check.\r\n     *\r\n     *    @return True, if the cells accept expressions, otherwise false.\r\n     */\r\n    virtual bool columnAcceptsExpression(int column) const;\r\n\r\n    //! Gets the description column.\r\n    virtual int descriptionColumn() const;\r\n\r\nprivate:\r\n\r\n\t//! No copying\r\n    RemapConditionDelegate(const RemapConditionDelegate& other);\r\n\r\n\t//! No assignment\r\n    RemapConditionDelegate& operator=(const RemapConditionDelegate& other);\r\n\r\n    /*!\r\n     *  Setup the data for the condition value editor.\r\n     *\r\n     *    @param [in] editor  The selected editor.\r\n     *    @param [in] index   Index of the editor containing port.\r\n     */\r\n    void setValueAndArrayEditor(QWidget* editor, QModelIndex const& index) const;\r\n\r\n    /*!\r\n     *  Check if the value should be an array.\r\n     *\r\n     *    @param [in] index   The index of the current value.\r\n     *\r\n     *    @return True, if the value is an array, otherwise false.\r\n     */\r\n    bool valueIsArray(QModelIndex const& index) const;\r\n\r\n    /*!\r\n     *  Get the width of the remap port.\r\n     *\r\n     *    @param [in] index   The index of the current remap port.\r\n     */\r\n    int getPortWidth(QModelIndex const& index) const;\r\n\r\n    /*!\r\n     *  Repositions the editor if there is not enough space under the default position. The editor is then resized\r\n     *  to use the available space.\r\n     *\r\n     *    @param [in] editor  The editor to reposition.\r\n     *    @param [in] option  The style options for the editor.\r\n     *    @param [in] index   The current index.\r\n     */\r\n    void repositionAndResizeEditor(QWidget* editor, QStyleOptionViewItem const& option, QModelIndex const& index)\r\n        const;\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! The expression formatter used to change parameter uuids in references to parameter names.\r\n    QSharedPointer<ExpressionFormatter> expressionFormatter_;\r\n\r\n    //! The expression parser.\r\n    QSharedPointer<ExpressionParser> expressionParser_;\r\n\r\n    //! The list of ports usable as remap ports.\r\n    QStringList availablePortNames_;\r\n\r\n    //! The list of port names within the component.\r\n    QStringList componentPortNames_;\r\n\r\n    //! The IP-XACT standard revision in use.\r\n    Document::Revision docRevision_;\r\n};\r\n\r\n#endif // REMAPCONDITIONDELEGATE_H\r\n"
  },
  {
    "path": "editors/ComponentEditor/remapStates/RemapConditionEditor.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: RemapConditionEditor.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Mikko Teuho\r\n// Date: 09.04.2015\r\n//\r\n// Description:\r\n// Editor used to edit the details of remap conditions in a remap state.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"RemapConditionEditor.h\"\r\n#include \"RemapConditionColumns.h\"\r\n#include \"RemapConditionDelegate.h\"\r\n\r\n#include <common/delegates/LineEditDelegate/lineeditdelegate.h>\r\n\r\n#include <editors/ComponentEditor/parameters/ComponentParameterModel.h>\r\n#include <KactusAPI/include/IPXactSystemVerilogParser.h>\r\n\r\n#include <QCompleter>\r\n#include <QVBoxLayout>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: RemapConditionEditor::RemapConditionEditor()\r\n//-----------------------------------------------------------------------------\r\nRemapConditionEditor::RemapConditionEditor(QSharedPointer<QList<QSharedPointer<RemapPort> > > remapPorts,\r\n    QSharedPointer<Component> component, QSharedPointer<ParameterFinder> parameterFinder,\r\n    QSharedPointer<ExpressionFormatter> expressionFormatter, QWidget* parent):\r\nQGroupBox(tr(\"Remap State Condition\"), parent),\r\nview_(new EditableTableView(this)),\r\nmodel_(0),\r\ndelegate_(0),\r\nproxy_(new QSortFilterProxyModel(this)),\r\ncomponent_(component)\r\n{\r\n    proxy_->setDynamicSortFilter(true);\r\n\r\n    QSharedPointer<IPXactSystemVerilogParser> expressionParser(new IPXactSystemVerilogParser(parameterFinder));\r\n    model_ = new RemapConditionModel(remapPorts, component->getPorts(), expressionParser, parameterFinder,\r\n        expressionFormatter, parent);\r\n\r\n    connect(model_, SIGNAL(contentChanged()), this, SIGNAL(contentChanged()), Qt::UniqueConnection);\r\n    connect(model_, SIGNAL(dataChanged(const QModelIndex&, const QModelIndex&)),\r\n        this, SIGNAL(contentChanged()), Qt::UniqueConnection);\r\n    connect(model_, SIGNAL(errorMessage(const QString&)),\r\n        this, SIGNAL(errorMessage(const QString&)), Qt::UniqueConnection);\r\n    connect(model_, SIGNAL(noticeMessage(const QString&)),\r\n        this, SIGNAL(noticeMessage(const QString&)), Qt::UniqueConnection);\r\n\r\n    connect(view_, SIGNAL(addItem(const QModelIndex&)),\r\n        model_, SLOT(onAddItem(const QModelIndex&)), Qt::UniqueConnection);\r\n    connect(view_, SIGNAL(removeItem(const QModelIndex&)),\r\n        model_, SLOT(onRemoveItem(const QModelIndex&)), Qt::UniqueConnection);\r\n\r\n    connect(model_, SIGNAL(decreaseReferences(QString)),\r\n        this, SIGNAL(decreaseReferences(QString)), Qt::UniqueConnection);\r\n\r\n    view_->setSortingEnabled(true);\r\n    view_->setItemsDraggable(false);\r\n\r\n    ComponentParameterModel* parameterModel = new ComponentParameterModel(parameterFinder, this);\r\n    parameterModel->setExpressionParser(expressionParser);\r\n\r\n    delegate_ = new RemapConditionDelegate(component->getPortNames(), parameterModel, parameterFinder,\r\n        expressionParser, expressionFormatter, component->getRevision(), this);\r\n\r\n    view_->setItemDelegate(delegate_);\r\n\r\n    connect(delegate_, SIGNAL(increaseReferences(QString)),\r\n        this, SIGNAL(increaseReferences(QString)), Qt::UniqueConnection);\r\n    connect(delegate_, SIGNAL(decreaseReferences(QString)),\r\n        this, SIGNAL(decreaseReferences(QString)), Qt::UniqueConnection);\r\n\r\n    connect(model_, SIGNAL(newAvailablePorts(QStringList)),\r\n        delegate_, SLOT(setNewPortNames(QStringList)), Qt::UniqueConnection);\r\n\r\n    proxy_->setSourceModel(model_);\r\n    view_->setModel(proxy_);\r\n\r\n    view_->sortByColumn(RemapConditionColumns::NAME_COLUMN, Qt::AscendingOrder);\r\n    view_->setAlternatingRowColors(false);\r\n\r\n    QVBoxLayout* layout = new QVBoxLayout(this);\r\n    layout->addWidget(view_);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: RemapConditionEditor::~RemapConditionEditor()\r\n//-----------------------------------------------------------------------------\r\nRemapConditionEditor::~RemapConditionEditor()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: RemapConditionEditor::refresh()\r\n//-----------------------------------------------------------------------------\r\nvoid RemapConditionEditor::refresh()\r\n{\r\n    delegate_->setComponentPorts(component_->getPortNames());\r\n    model_->updatePorts(component_->getPorts());\r\n    proxy_->invalidate();\r\n    view_->update();\r\n}\r\n"
  },
  {
    "path": "editors/ComponentEditor/remapStates/RemapConditionEditor.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: RemapConditionEditor.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Mikko Teuho\r\n// Date: 09.04.2015\r\n//\r\n// Description:\r\n// Editor used to edit the details of remap conditions in a remap state.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef REMAPCONDITIONEDITOR_H\r\n#define REMAPCONDITIONEDITOR_H\r\n\r\n#include \"RemapConditionModel.h\"\r\n#include \"RemapConditionDelegate.h\"\r\n\r\n#include <common/views/EditableTableView/editabletableview.h>\r\n\r\n#include <KactusAPI/include/ExpressionFormatter.h>\r\n#include <KactusAPI/include/ParameterFinder.h>\r\n\r\n#include <IPXACTmodels/Component/Component.h>\r\n#include <IPXACTmodels/Component/RemapPort.h>\r\n\r\n#include <QGroupBox>\r\n#include <QSharedPointer>\r\n#include <QSortFilterProxyModel>\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Editor used to edit the details of remap conditions in a remap state.\r\n//-----------------------------------------------------------------------------\r\nclass RemapConditionEditor : public QGroupBox \r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\r\n    /*!\r\n     *  The constructor.\r\n     *\r\n     *    @param [in] remapPorts              The list containing the remap ports of this remap state.\r\n     *    @param [in] component               The component whose remap state is being edited.\r\n     *    @param [in] parameterFinder         The parameter finder used to search the components parameters.\r\n     *    @param [in] expressionFormatter     Changes the parameter ids to names in references.\r\n     *    @param [in] parent                  Pointer to the owner of this editor.\r\n     */\r\n    RemapConditionEditor(QSharedPointer<QList<QSharedPointer<RemapPort> > > remapPorts,\r\n        QSharedPointer<Component> component,\r\n        QSharedPointer<ParameterFinder> parameterFinder,\r\n        QSharedPointer<ExpressionFormatter> expressionFormatter,\r\n        QWidget* parent);\r\n\r\n    /*!\r\n     *  The destructor.\r\n     */\r\n    virtual ~RemapConditionEditor();\r\n\r\n\t/*!\r\n\t *  Restore the changes made in the editor.\r\n\t */\r\n\tvirtual void refresh();\r\n\r\nsignals:\r\n\r\n\t/*!\r\n\t *  Emitted when contents of the editor change.\r\n\t */\r\n\tvoid contentChanged();\r\n\r\n\t/*!\r\n\t *  Prints an error message to the user.\r\n\t *\r\n\t *    @param [in] msg     The error message.\r\n\t */\r\n\tvoid errorMessage(const QString& msg) const;\r\n\r\n\t/*!\r\n\t *  Prints a notification to the user.\r\n\t *\r\n\t *    @param [in] msg     The notification message.\r\n\t */\r\n\tvoid noticeMessage(const QString& msg) const;\r\n\r\n    /*!\r\n     *  Increase the amount of references to the parameter corresponding to the id.\r\n     *\r\n     *    @param [in] id      The id of the parameter being searched for.\r\n     */\r\n    void increaseReferences(QString id);\r\n\r\n    /*!\r\n     *  Decrease the amount of references to the parameter corresponding to the id.\r\n     *\r\n     *    @param [in] id      The id of the parameter being searched for.\r\n     */\r\n    void decreaseReferences(QString id);\r\n\r\nprivate:\r\n\t//! No copying\r\n    RemapConditionEditor(const RemapConditionEditor& other);\r\n\r\n\t//! No assignment\r\n    RemapConditionEditor& operator=(const RemapConditionEditor& other);\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! The view that displays the conditions.\r\n    EditableTableView* view_;\r\n\r\n    //! The model that holds the data to be displayed to the user.\r\n    RemapConditionModel* model_;\r\n\r\n    //! The delegate for the view.\r\n    RemapConditionDelegate* delegate_;\r\n\r\n    //! The sort filter for the model.\r\n    QSortFilterProxyModel* proxy_;\r\n\r\n    //! Pointer to the component.\r\n    QSharedPointer<Component> component_;\r\n};\r\n\r\n#endif // REMAPCONDITIONEDITOR_H\r\n"
  },
  {
    "path": "editors/ComponentEditor/remapStates/RemapConditionModel.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: RemapConditionModel.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Mikko Teuho\r\n// Date: 09.04.2015\r\n//\r\n// Description:\r\n// Table model that can be used to display remap conditions to be edited.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"RemapConditionModel.h\"\r\n#include \"RemapConditionColumns.h\"\r\n\r\n\r\n\r\n#include <common/KactusColors.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: RemapConditionModel::RemapConditionModel()\r\n//-----------------------------------------------------------------------------\r\nRemapConditionModel::RemapConditionModel(QSharedPointer<QList<QSharedPointer<RemapPort> > > remapPorts,\r\n    QSharedPointer<QList<QSharedPointer<Port> > > componentPorts, QSharedPointer<ExpressionParser> expressionParser,\r\n    QSharedPointer<ParameterFinder> parameterFinder, QSharedPointer<ExpressionFormatter> expressionFormatter,\r\n    QObject* parent):\r\nReferencingTableModel(parameterFinder, parent),\r\nParameterizableTable(parameterFinder),\r\nremapPortsOfRemapState_(new QList<QSharedPointer<RemapPort> > ()),\r\nremapPortsVisibleInModel_(new QList<QSharedPointer<RemapPort> > ()),\r\nexpressionFormatter_(expressionFormatter),\r\ncomponentPorts_(componentPorts)\r\n{\r\n    remapPortsOfRemapState_ = remapPorts;\r\n\r\n    setExpressionParser(expressionParser);\r\n\r\n    setupVisibleRemapPorts();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: RemapConditionModel::~RemapConditionModel()\r\n//-----------------------------------------------------------------------------\r\nRemapConditionModel::~RemapConditionModel()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: RemapConditionModel::rowCount()\r\n//-----------------------------------------------------------------------------\r\nint RemapConditionModel::rowCount(QModelIndex const& parent) const\r\n{\r\n    if (parent.isValid())\r\n    {\r\n        return 0;\r\n    }\r\n\r\n    return remapPortsVisibleInModel_->size();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: RemapConditionModel::columnCount()\r\n//-----------------------------------------------------------------------------\r\nint RemapConditionModel::columnCount(QModelIndex const& parent) const\r\n{\r\n    if (parent.isValid())\r\n    {\r\n        return 0;\r\n    }\r\n\r\n    return RemapConditionColumns::COLUMN_COUNT;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: RemapConditionModel::data()\r\n//-----------------------------------------------------------------------------\r\nQVariant RemapConditionModel::data(QModelIndex const& index, int role) const\r\n{\r\n    if (!index.isValid() || index.row() < 0 || index.row() >= rowCount())\r\n    {\r\n        return QVariant();\r\n    }\r\n\r\n    if (role == Qt::DisplayRole)\r\n    {\r\n        if (isValidExpressionColumn(index))\r\n        {\r\n            return expressionFormatter_->formatReferringExpression(valueForIndex(index).toString());\r\n        }\r\n        else\r\n        {\r\n            return valueForIndex(index).toString();\r\n        }\r\n    }\r\n\r\n    else if (role == Qt::EditRole)\r\n    {\r\n        return expressionOrValueForIndex(index);\r\n    }\r\n\r\n    else if (role == Qt::ToolTipRole)\r\n    {\r\n        if (isValidExpressionColumn(index))\r\n        {\r\n            return formattedValueFor(valueForIndex(index).toString());\r\n        }\r\n        else\r\n        {\r\n            return expressionOrValueForIndex(index);\r\n        }\r\n    }\r\n\r\n    else if (role == Qt::ForegroundRole)\r\n    {\r\n        if (index.column() == RemapConditionColumns::LEFT_COLUMN ||\r\n            index.column() == RemapConditionColumns::RIGHT_COLUMN)\r\n        {\r\n            return QColor(KactusColors::DISABLED_TEXT);\r\n        }\r\n        else\r\n        {\r\n            return blackForValidOrRedForInvalidIndex(index);\r\n        }\r\n    }\r\n\r\n    else if (role == Qt::BackgroundRole)\r\n    {\r\n        if (index.column() == RemapConditionColumns::NAME_COLUMN ||\r\n            index.column() == RemapConditionColumns::VALUE_COLUMN)\r\n        {\r\n            return KactusColors::MANDATORY_FIELD;\r\n        }\r\n    }\r\n\r\n    return QVariant();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: RemapConditionModel::isValidExpressionColumn()\r\n//-----------------------------------------------------------------------------\r\nbool RemapConditionModel::isValidExpressionColumn(QModelIndex const& index) const\r\n{\r\n    if (index.column() == RemapConditionColumns::LEFT_COLUMN ||\r\n        index.column() == RemapConditionColumns::RIGHT_COLUMN ||\r\n        index.column() == RemapConditionColumns::VALUE_COLUMN)\r\n    {\r\n        return true;\r\n    }\r\n    else\r\n    {\r\n        return false;\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: RemapConditionModel::valueForIndex()\r\n//-----------------------------------------------------------------------------\r\nQVariant RemapConditionModel::valueForIndex(QModelIndex const& index) const\r\n{\r\n    QSharedPointer<RemapPort> remapPort = remapPortsVisibleInModel_->at(index.row());\r\n\r\n    if (index.column() == RemapConditionColumns::NAME_COLUMN)\r\n    {\r\n        return remapPort->getPortNameRef();\r\n    }\r\n    else if (index.column() == RemapConditionColumns::LEFT_COLUMN)\r\n    {\r\n        if (!remapPort->getPortNameRef().isEmpty())\r\n        {\r\n            foreach (QSharedPointer<Port> targetPort, *componentPorts_)\r\n            {\r\n                if (targetPort->name() == remapPort->getPortNameRef())\r\n                {\r\n                    return(targetPort->getLeftBound());\r\n                }\r\n            }\r\n        }\r\n    }\r\n    else if (index.column() == RemapConditionColumns::RIGHT_COLUMN)\r\n    {\r\n        if (!remapPort->getPortNameRef().isEmpty())\r\n        {\r\n            foreach (QSharedPointer<Port> targetPort, *componentPorts_)\r\n            {\r\n                if (targetPort->name() == remapPort->getPortNameRef())\r\n                {\r\n                    return targetPort->getRightBound();\r\n                }\r\n            }\r\n        }\r\n    }\r\n    else if (index.column() == RemapConditionColumns::VALUE_COLUMN)\r\n    {\r\n        QString remapValue = remapPort->getValue();\r\n        if (remapValue.contains('{') && remapValue.contains('}'))\r\n        {\r\n            QStringList remapData = remapValue.split(',');\r\n            remapData.first().remove('{');\r\n            remapData.last().remove('}');\r\n\r\n            QStringList remapInLSB;\r\n\r\n            for (int i = 0; i < remapData.size(); i++)\r\n            {\r\n                remapInLSB.prepend(remapData.at(i));\r\n            }\r\n\r\n            remapInLSB.first().prepend('{');\r\n            remapInLSB.last().append('}');\r\n\r\n            remapValue = remapInLSB.join(',');\r\n        }\r\n        return remapValue;\r\n    }\r\n\r\n    return QVariant();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: RemapConditionModel::expressionOrValueForIndex()\r\n//-----------------------------------------------------------------------------\r\nQVariant RemapConditionModel::expressionOrValueForIndex(QModelIndex const& index) const\r\n{\r\n    if (index.column() == RemapConditionColumns::VALUE_COLUMN)\r\n    {\r\n        QSharedPointer<RemapPort> remapPort = remapPortsVisibleInModel_->at(index.row());\r\n\r\n        return remapPort->getValue();\r\n    }\r\n    else\r\n    {\r\n        return valueForIndex(index);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: RemapConditionModel::headerData()\r\n//-----------------------------------------------------------------------------\r\nQVariant RemapConditionModel::headerData(int section, Qt::Orientation orientation, int role) const\r\n{\r\n    if (orientation == Qt::Horizontal && role == Qt::DisplayRole)\r\n    {\r\n        if (section == RemapConditionColumns::NAME_COLUMN)\r\n        {\r\n            return tr(\"Port\");\r\n        }\r\n        else if (section == RemapConditionColumns::LEFT_COLUMN)\r\n        {\r\n            return tr(\"Left bound\");\r\n        }\r\n        else if (section == RemapConditionColumns::RIGHT_COLUMN)\r\n        {\r\n            return tr(\"Right bound\");\r\n        }\r\n        else if (section == RemapConditionColumns::VALUE_COLUMN)\r\n        {\r\n            QString valueHeader = tr(\"Value\") + getExpressionSymbol();\r\n            return valueHeader;\r\n        }\r\n    }\r\n\r\n    return QVariant();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: RemapConditionModel::setData()\r\n//-----------------------------------------------------------------------------\r\nbool RemapConditionModel::setData(const QModelIndex &index, const QVariant &value, int role /* = Qt::EditRole */)\r\n{\r\n    if (!index.isValid() || index.row() < 0 || index.row() >= rowCount())\r\n    {\r\n        return false;\r\n    }\r\n\r\n    if (role == Qt::EditRole)\r\n    {\r\n        QSharedPointer<RemapPort> remapPort = remapPortsVisibleInModel_->at(index.row());\r\n\r\n        if (index.column() == RemapConditionColumns::NAME_COLUMN)\r\n        {\r\n            remapPort->setPortNameRef(value.toString());\r\n            emit(newAvailablePorts(getAvailablePorts()));\r\n        }\r\n\r\n        else if (index.column() == RemapConditionColumns::VALUE_COLUMN)\r\n        {\r\n            if (!value.isValid())\r\n            {\r\n                removeReferencesFromSingleExpression(remapPort->getValue());\r\n            }\r\n\r\n            remapPort->setValue(value.toString());\r\n        }\r\n\r\n        else\r\n        {\r\n            return false;\r\n        }\r\n\r\n        save();\r\n        emit dataChanged(index, index);\r\n        emit contentChanged();\r\n        return true;\r\n    }\r\n\r\n    else\r\n    {\r\n        return false;\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: RemapConditionModel::flags()\r\n//-----------------------------------------------------------------------------\r\nQt::ItemFlags RemapConditionModel::flags(const QModelIndex &index) const\r\n{\r\n    if (!index.isValid())\r\n    {\r\n        return Qt::NoItemFlags;\r\n    }\r\n\r\n    else if (index.column() == RemapConditionColumns::LEFT_COLUMN ||\r\n        index.column() == RemapConditionColumns::RIGHT_COLUMN)\r\n    {\r\n        return Qt::ItemIsSelectable | Qt::ItemIsEnabled;\r\n    }\r\n\r\n    else\r\n    {\r\n        return Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsEditable;\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: RemapConditionModel::isValid()\r\n//-----------------------------------------------------------------------------\r\nbool RemapConditionModel::isValid() const\r\n{\r\n    foreach (QSharedPointer<RemapPort> remapPort, *remapPortsOfRemapState_)\r\n    {\r\n        if (remapPort->getValue().isEmpty() || remapPort->getPortNameRef().isEmpty())\r\n        {\r\n            return false;\r\n        }\r\n    }\r\n\r\n    return true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: RemapConditionModel::onAddItem()\r\n//-----------------------------------------------------------------------------\r\nvoid RemapConditionModel::onAddItem(QModelIndex const& index)\r\n{\r\n    int row = remapPortsVisibleInModel_->size();\r\n    if (index.isValid())\r\n    {\r\n        row = index.row();\r\n    }\r\n\r\n    beginInsertRows(QModelIndex(), row, row);\r\n    remapPortsVisibleInModel_->insert(row, QSharedPointer<RemapPort>(new RemapPort()));\r\n    endInsertRows();\r\n\r\n    save();\r\n\r\n    emit contentChanged();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: RemapConditionModel::onRemoveItem()\r\n//-----------------------------------------------------------------------------\r\nvoid RemapConditionModel::onRemoveItem(QModelIndex const& index)\r\n{\r\n    if (!index.isValid() || index.row() <0 || index.row() >= rowCount())\r\n    {\r\n        return;\r\n    }\r\n\r\n    beginRemoveRows(QModelIndex(), index.row(), index.row());\r\n\r\n    removeReferencesInItemOnRow(index.row());\r\n\r\n    remapPortsVisibleInModel_->removeAt(index.row());\r\n    endRemoveRows();\r\n\r\n    save();\r\n\r\n    emit contentChanged();\r\n    emit newAvailablePorts(getAvailablePorts());\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: RemapConditionModel::save()\r\n//-----------------------------------------------------------------------------\r\nvoid RemapConditionModel::save()\r\n{\r\n    remapPortsOfRemapState_->clear();\r\n\r\n    foreach (QSharedPointer<RemapPort> visibleRemapPort, *remapPortsVisibleInModel_)\r\n    {\r\n        if (visibleRemapPort->getValue().contains('{') && visibleRemapPort->getValue().contains('}'))\r\n        {\r\n            QStringList portValues = visibleRemapPort->getValue().split(',');\r\n            portValues.first().remove('{');\r\n            portValues.last().remove('}');\r\n\r\n            int arrayStartIndex = getArrayStartIndex(visibleRemapPort->getPortNameRef());\r\n\r\n            for (int i = 0; i < portValues.size(); ++i)\r\n            {\r\n                if (!portValues.at(i).isEmpty())\r\n                {\r\n                    QSharedPointer<RemapPort> newRemapPort (new RemapPort());\r\n                    newRemapPort->setPortNameRef(visibleRemapPort->getPortNameRef());\r\n                    newRemapPort->setValue(portValues.at(i));\r\n                    newRemapPort->setPortIndex(QString::number(i + arrayStartIndex));\r\n\r\n                    remapPortsOfRemapState_->append(newRemapPort);\r\n                }\r\n            }\r\n        }\r\n        else\r\n        {\r\n            QSharedPointer<RemapPort> newRemapPort (new RemapPort());\r\n            newRemapPort->setPortNameRef(visibleRemapPort->getPortNameRef());\r\n            newRemapPort->setValue(visibleRemapPort->getValue());\r\n\r\n            remapPortsOfRemapState_->append(newRemapPort);\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: RemapConditionModel::getAllReferencesToIdInItemOnRow()\r\n//-----------------------------------------------------------------------------\r\nint RemapConditionModel::getAllReferencesToIdInItemOnRow(const int& row, QString const& valueID) const\r\n{\r\n    int referencesInValue = remapPortsVisibleInModel_->at(row)->getValue().count(valueID);\r\n\r\n    return referencesInValue;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: RemapConditionModel::validateIndex()\r\n//-----------------------------------------------------------------------------\r\nbool RemapConditionModel::validateIndex(QModelIndex const& index) const\r\n{\r\n    QSharedPointer<RemapPort> targetRemapPort = remapPortsVisibleInModel_->at(index.row());\r\n\r\n    if (index.column() == RemapConditionColumns::NAME_COLUMN)\r\n    {\r\n        foreach (QSharedPointer<Port> targetPort, *componentPorts_)\r\n        {\r\n            if (targetPort->name() == targetRemapPort->getPortNameRef())\r\n            {\r\n                return true;\r\n            }\r\n        }\r\n\r\n        return false;\r\n    }\r\n\r\n    else if (index.column() == RemapConditionColumns::VALUE_COLUMN)\r\n    {\r\n        QString targetValue = targetRemapPort->getValue();\r\n\r\n        if (targetValue.contains('{') || targetValue.contains('}'))\r\n        {\r\n            QModelIndex portLeftIndex = index.sibling(index.row(), RemapConditionColumns::LEFT_COLUMN);\r\n            int portLeft = portLeftIndex.data(Qt::ToolTipRole).toInt();\r\n\r\n            QModelIndex portRightIndex = index.sibling(index.row(), RemapConditionColumns::RIGHT_COLUMN);\r\n            int portRight = portRightIndex.data(Qt::ToolTipRole).toInt();\r\n\r\n            int width = abs(portLeft - portRight) + 1;\r\n\r\n            if (width != targetValue.count(',') + 1)\r\n            {\r\n                return false;\r\n            }\r\n\r\n            QStringList listOfValues = targetValue.split(',');\r\n            listOfValues.first().remove('{');\r\n            listOfValues.last().remove('}');\r\n\r\n            foreach(QString const& value, listOfValues)\r\n            {\r\n                if (!isValidExpression(value))\r\n                {\r\n                    return false;\r\n                }\r\n            }\r\n        }\r\n\r\n        else if (!isValidExpression(targetValue))\r\n        {\r\n            return false;\r\n        }\r\n    }\r\n\r\n    return true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: RemapConditionModel::updatePorts()\r\n//-----------------------------------------------------------------------------\r\nvoid RemapConditionModel::updatePorts(QSharedPointer<QList<QSharedPointer<Port> > > newPorts)\r\n{\r\n    componentPorts_ = newPorts;\r\n\r\n    emit(newAvailablePorts(getAvailablePorts()));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: RemapConditionModel::getAvailablePorts()\r\n//-----------------------------------------------------------------------------\r\nQStringList RemapConditionModel::getAvailablePorts()\r\n{\r\n    QStringList usedPorts;\r\n\r\n    foreach (QSharedPointer<RemapPort> visibleRemapPort, *remapPortsVisibleInModel_)\r\n    {\r\n        usedPorts.append(visibleRemapPort->getPortNameRef());\r\n    }\r\n\r\n    QStringList availablePorts;\r\n\r\n    foreach (QSharedPointer<Port> targetPort, *componentPorts_)\r\n    {\r\n        if (!usedPorts.contains(targetPort->name()))\r\n        {\r\n            availablePorts.append(targetPort->name());\r\n        }\r\n    }\r\n\r\n    return availablePorts;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: RemapConditionModel::setupVisibleRemapPorts()\r\n//-----------------------------------------------------------------------------\r\nvoid RemapConditionModel::setupVisibleRemapPorts()\r\n{\r\n    foreach (QSharedPointer<RemapPort> remapStatePortPointer, *remapPortsOfRemapState_)\r\n    {\r\n        int arrayIndex = getArrayStartIndex(remapStatePortPointer->getPortNameRef());\r\n\r\n        if (remapStatePortPointer->getPortIndex().isEmpty())\r\n        {\r\n            arrayIndex = -1;\r\n        }\r\n        else\r\n        {\r\n            arrayIndex = remapStatePortPointer->getPortIndex().toInt() - arrayIndex; \r\n        }\r\n\r\n        if (!remapPortIsAlreadyVisible(remapStatePortPointer, arrayIndex))\r\n        {\r\n            QSharedPointer<RemapPort> newRemapPort (new RemapPort(*(remapStatePortPointer)));\r\n\r\n            if (arrayIndex > -1)\r\n            {\r\n                QString newValue = newRemapPort->getValue();\r\n\r\n                for (int i = 0; i < arrayIndex; ++i)\r\n                {\r\n                    newValue.prepend(',');\r\n                }\r\n\r\n                newValue.prepend('{');\r\n                newValue.append(getEndOfArray(newRemapPort->getPortNameRef(), arrayIndex));\r\n\r\n                newRemapPort->setValue(newValue);\r\n            }\r\n\r\n            remapPortsVisibleInModel_->append(newRemapPort);\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: RemapConditionModel::remapPortIsAlreadyVisible()\r\n//-----------------------------------------------------------------------------\r\nbool RemapConditionModel::remapPortIsAlreadyVisible(QSharedPointer<RemapPort> remapStateRemapPort, int arrayIndex)\r\n{\r\n    foreach (QSharedPointer<RemapPort> modelPortPointer, *remapPortsVisibleInModel_)\r\n    {\r\n        if (modelPortPointer->getPortNameRef() == remapStateRemapPort->getPortNameRef())\r\n        {\r\n            QStringList remapPortValueList = modelPortPointer->getValue().split(',');\r\n            remapPortValueList.first() = remapPortValueList.first().remove('{');\r\n            remapPortValueList.last() = remapPortValueList.last().remove('}');\r\n            remapPortValueList[arrayIndex] = remapStateRemapPort->getValue();\r\n\r\n            QString newValue = remapPortValueList.join(',');\r\n            newValue.prepend('{');\r\n            newValue.append('}');\r\n\r\n            modelPortPointer->setValue(newValue);\r\n\r\n            return true;\r\n        }\r\n    }\r\n\r\n    return false;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: RemapConditionModel::getEndOfArray()\r\n//-----------------------------------------------------------------------------\r\nQString RemapConditionModel::getEndOfArray(QString const& remapPortName, int newPortIndex)\r\n{\r\n    foreach (QSharedPointer<Port> targetPort, *componentPorts_)\r\n    {\r\n        if (targetPort->name() == remapPortName)\r\n        {\r\n            QString leftBound = parseExpressionToDecimal(targetPort->getLeftBound());\r\n            QString rightBound = parseExpressionToDecimal(targetPort->getRightBound());\r\n\r\n            int portWidth = abs(leftBound.toInt() - rightBound.toInt()) + 1;\r\n            int commasLeft = portWidth - newPortIndex - 1;\r\n\r\n            QString endOfArray('}');\r\n            for (int i = 0; i < commasLeft; ++i)\r\n            {\r\n                endOfArray.prepend(',');\r\n            }\r\n\r\n            return endOfArray;\r\n        }\r\n    }\r\n\r\n    return QString('}');\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: RemapConditionModel::getArrayStartIndex()\r\n//-----------------------------------------------------------------------------\r\nint RemapConditionModel::getArrayStartIndex(QString const& remapPortName)\r\n{\r\n    foreach (QSharedPointer<Port> targetPort, *componentPorts_)\r\n    {\r\n        if (targetPort->name() == remapPortName)\r\n        {\r\n            int arrayLeft = formattedValueFor(targetPort->getLeftBound()).toInt();\r\n            int arrayRight = formattedValueFor(targetPort->getRightBound()).toInt();\r\n\r\n            if (arrayLeft < arrayRight)\r\n            {\r\n                return arrayLeft;\r\n            }\r\n            else\r\n            {\r\n                return arrayRight;\r\n            }\r\n        }\r\n    }\r\n\r\n    return -1;\r\n}\r\n"
  },
  {
    "path": "editors/ComponentEditor/remapStates/RemapConditionModel.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: RemapConditionModel.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Mikko Teuho\r\n// Date: 09.04.2015\r\n//\r\n// Description:\r\n// Table model that displays editable remap conditions.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef REMAPCONDITIONMODEL_H\r\n#define REMAPCONDITIONMODEL_H\r\n\r\n\r\n#include <KactusAPI/include/ExpressionFormatter.h>\r\n#include <KactusAPI/include/ParameterFinder.h>\r\n\r\n#include <editors/ComponentEditor/common/ReferencingTableModel.h>\r\n#include <editors/ComponentEditor/common/ParameterizableTable.h>\r\n\r\n#include <IPXACTmodels/Component/Port.h>\r\n#include <IPXACTmodels/Component/RemapPort.h>\r\n\r\n#include <QAbstractTableModel>\r\n#include <QList>\r\n#include <QSharedPointer>\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Table model that displays editable remap conditions.\r\n//-----------------------------------------------------------------------------\r\nclass RemapConditionModel : public ReferencingTableModel, public ParameterizableTable\r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\r\n    /*!\r\n     *  The constructor.\r\n     *\r\n     *    @param [in] remapPorts              The remap ports of the remap state.\r\n     *    @param [in] componentPorts          The ports of the component.\r\n     *    @param [in] expressionParser        Expression parse for configurable elements.\r\n     *    @param [in] parameterFinder         The parameter finder.\r\n     *    @param [in] expressionFormatter     Changes the referenced ids to names.\r\n     *    @param [in] parent                  The owner of this model.\r\n     */\r\n    RemapConditionModel(QSharedPointer<QList<QSharedPointer<RemapPort> > > remapPorts,\r\n        QSharedPointer<QList<QSharedPointer<Port> > > componentPorts,\r\n        QSharedPointer<ExpressionParser> expressionParser,\r\n        QSharedPointer<ParameterFinder> parameterFinder,\r\n        QSharedPointer<ExpressionFormatter> expressionFormatter,\r\n        QObject* parent);\r\n\r\n    /*!\r\n     *  The destructor.\r\n     */\r\n    virtual ~RemapConditionModel();\r\n\r\n  \t/*!\r\n\t *  Get the number of rows in the model.\r\n\t *\r\n\t *    @param [in] parent  Index of the parent of the item.\r\n     *\r\n     *    @return Number of rows currently in the model.\r\n\t */\r\n\tvirtual int rowCount(QModelIndex const& parent = QModelIndex()) const;\r\n\r\n\t/*! Get the number of columns in the model\r\n\t *\r\n\t *    @param [in] parent  Index of the parent of the item.\r\n\t *\r\n\t *    @return Number of columns currently in the model.\r\n\t */\r\n\tvirtual int columnCount(QModelIndex const& parent = QModelIndex()) const;\r\n\r\n    /*!\r\n     *  Get the data for the specified item for the specified role.\r\n     *\r\n     *    @param [in] index   The index of the item.\r\n     *    @param [in] role    Specifies what kind of data is wanted.\r\n     *\r\n     *    @return The data for the given index.\r\n     */\r\n    virtual QVariant data(QModelIndex const& index, int role = Qt::DisplayRole) const;\r\n\r\n    /*!\r\n     *  Get the data for the headers.\r\n     *\r\n     *    @param [in] section         The column of the header.\r\n     *    @param [in] orientation     The orientation of the header data.\r\n     *    @param [in] role            Specifies the wanted data role.\r\n     *\r\n     *    @return The header data for the given section.\r\n     */\r\n    virtual QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;\r\n\r\n    /*!\r\n     *  Sets the data for the given index.\r\n     *\r\n     *    @param [in] index   The index of the item being modified.\r\n     *    @param [in] value   The new value for the item.\r\n     *    @param [in] role    The role for editing the data.\r\n     *\r\n     *    @return True, if data was successfully set, false otherwise.\r\n     */\r\n    virtual bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole);\r\n\r\n    /*!\r\n     *  Get information on how specified item can be handled.\r\n     *\r\n     *    @param [in] index   The index of the item.\r\n     *\r\n     *    @return Qt::ItemFlags determining the handling information of the item.\r\n     */\r\n    virtual Qt::ItemFlags flags(const QModelIndex &index) const;\r\n\r\n    /*!\r\n     *  Check if the model is in a valid state.\r\n     *\r\n     *    @return True, if the model is valid, false otherwise.\r\n     */\r\n    virtual bool isValid() const;\r\n\r\n    /*!\r\n     *  Update the ports of the model.\r\n     *\r\n     *    @param [in] newPorts    The new ports for the model.\r\n     */\r\n    void updatePorts(QSharedPointer<QList<QSharedPointer<Port> > > newPorts);\r\n\r\n    /*!\r\n     *  Get the currently available, non-selected ports.\r\n     *\r\n     *    @return A list of port names.\r\n     */\r\n    QStringList getAvailablePorts();\r\n\r\npublic slots:\r\n\r\n\t/*! A new item should be added to given index.\r\n\t *\r\n\t *    @param [in] index   The position where new item should be added at.\r\n\t */\r\n\tvirtual void onAddItem(QModelIndex const& index);\r\n\r\n\t/*! An item should be removed from the model.\r\n\t * \r\n\t *    @param [in] index   Identifies the item that should be removed.\r\n     */\r\n\tvirtual void onRemoveItem(QModelIndex const& index);\r\n\r\nsignals:\r\n\r\n    /*!\r\n     *  Emitted when the contents of the model change.\r\n     */\r\n    void contentChanged();\r\n\r\n    /*!\r\n     *  Passes an error message to the user.\r\n     *\r\n     *    @param [in] msg     The error message.\r\n     */\r\n    void errorMessage(const QString& msg) const;\r\n\r\n    /*!\r\n     *  Passes a notification message to the user.\r\n     *\r\n     *    @param [in] msg     The notification message.\r\n     */\r\n    void noticeMessage(const QString& msg) const;\r\n\r\n    /*!\r\n     *  Emitted when the list of available ports changes.\r\n     *\r\n     *    @param [in] availablePorts  The new list of available ports.\r\n     */\r\n    void newAvailablePorts(QStringList availablePorts) const;\r\n\r\nprotected:\r\n    \r\n    /*!\r\n     *  Check if the column index is valid for containing expressions.\r\n     *\r\n     *    @param [in] index   The index being evaluated.\r\n     *\r\n     *    @return True, if the column can accept expressions, false otherwise.\r\n     */\r\n    virtual bool isValidExpressionColumn(QModelIndex const& index) const;\r\n\r\n    /*!\r\n     *  Gets the expression for the index, or the plain value, if an expression is not available.\r\n     *\r\n     *    @param [in] index   The index of the item.\r\n     *\r\n     *    @return The expression for the index if available, otherwise the value for the given index.\r\n     */\r\n    virtual QVariant expressionOrValueForIndex(QModelIndex const& index) const;\r\n\r\n    /*!\r\n     *  Validates the data for the column.\r\n     *\r\n     *    @param [in] index   The column of the item to validate.\r\n     *\r\n     *    @return True, if the data of the item is valid for the column, false otherwise.\r\n     */\r\n    virtual bool validateIndex(QModelIndex const& index) const;\r\n\r\n    /*!\r\n     *  Gets the number of all the references made to a selected id on the selected row.\r\n     *\r\n     *    @param [in] row         The row of the selected item.\r\n     *    @param [in] valueID     The id of the referenced parameter.\r\n     *\r\n     *    @return The amount of references made to the selected id on the selected row.\r\n     */\r\n    virtual int getAllReferencesToIdInItemOnRow(const int& row, QString const& valueID) const;\r\n\r\nprivate:\r\n\r\n\t//! No copying\r\n    RemapConditionModel(const RemapConditionModel& other);\r\n\r\n\t//! No assignment\r\n   RemapConditionModel& operator=(const RemapConditionModel& other);\r\n\r\n   /*!\r\n    *  Setup the remap ports in the remap state to show as visible remap ports.\r\n    */\r\n   void setupVisibleRemapPorts();\r\n\r\n   /*!\r\n    *  Check if the remap port is already in the visible remap ports.\r\n    *\r\n    *    @param [in] remapStateRemapPort  The remap port.\r\n    *    @param [in] arrayIndex           The index of the array.\r\n    *\r\n    *    @return True, if the remap port is already visible, false otherwise.\r\n    */\r\n   bool remapPortIsAlreadyVisible(QSharedPointer<RemapPort> remapStateRemapPort, int arrayIndex);\r\n\r\n   /*!\r\n    *  Get the end of the array.\r\n    *\r\n    *    @param [in] remapPortName    The name of the remap port.\r\n    *    @param [in] newPortIndex     The index of the remap port.\r\n    *\r\n    *    @return The end of the array value.\r\n    */\r\n   QString getEndOfArray(QString const& remapPortName, int newPortIndex);\r\n\r\n   /*!\r\n    *  Gets the value for the given index.\r\n    *\r\n    *    @param [in] index    The index of the data.\r\n    *\r\n    *    @return The data in the given index.\r\n    */\r\n   QVariant valueForIndex(QModelIndex const& index) const;\r\n\r\n   /*!\r\n    *  Save the visible remap ports to the remap state remap ports.\r\n    */\r\n   void save();\r\n\r\n   /*!\r\n    *  Get the starting index of the array.\r\n    *\r\n    *    @param [in] remapPortName    The name of the remap port.\r\n    *\r\n    *    @return The starting index of the array.\r\n    */\r\n   int getArrayStartIndex(QString const& remapPortName);\r\n\r\n   //-----------------------------------------------------------------------------\r\n   // Data.\r\n   //-----------------------------------------------------------------------------\r\n\r\n   //! A list of remap ports belonging to the remap state.\r\n   QSharedPointer<QList<QSharedPointer<RemapPort> > > remapPortsOfRemapState_;\r\n\r\n   //! A list of remap ports modified to be visible in the model\r\n   QSharedPointer<QList<QSharedPointer<RemapPort> > > remapPortsVisibleInModel_;\r\n\r\n   //! The expression formatter.\r\n   QSharedPointer<ExpressionFormatter> expressionFormatter_;\r\n\r\n   //! A list of ports in the component.\r\n   QSharedPointer<QList<QSharedPointer<Port> > > componentPorts_;\r\n};\r\n\r\n#endif // REMAPCONDITIONMODEL_H\r\n"
  },
  {
    "path": "editors/ComponentEditor/remapStates/RemapStatesEditor.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: RemapStatesEditor.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Mikko Teuho\r\n// Date: 08.04.2015\r\n//\r\n// Description:\r\n// The editor to add / remove / edit remap states of a component.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"RemapStatesEditor.h\"\r\n\r\n#include <common/widgets/summaryLabel/summarylabel.h>\r\n#include <common/delegates/LineEditDelegate/lineeditdelegate.h>\r\n\r\n#include <IPXACTmodels/Component/Component.h>\r\n\r\n#include <QVBoxLayout>\r\n#include <QSortFilterProxyModel>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: RemapStatesEditor::RemapStatesEditor()\r\n//-----------------------------------------------------------------------------\r\nRemapStatesEditor::RemapStatesEditor(QSharedPointer<Component> component, LibraryInterface* handler,\r\n                                     QSharedPointer<ParameterFinder> parameterFinder, QWidget* parent):\r\nItemEditor(component, handler, parent),\r\nview_(this),\r\nmodel_(component->getRemapStates(), parameterFinder, this)\r\n{\r\n    auto proxy(new QSortFilterProxyModel(this));\r\n    proxy->setSourceModel(&model_);\r\n    proxy->setDynamicSortFilter(true);\r\n\r\n    view_.setModel(proxy);\r\n    view_.sortByColumn(RemapStatesModel::NAME_COLUMN, Qt::AscendingOrder);\r\n    view_.setItemsDraggable(false);\r\n    view_.setAlternatingRowColors(false);\r\n\r\n    view_.setItemDelegate(new LineEditDelegate(this));\r\n\r\n    connect(&model_, SIGNAL(contentChanged()), this, SIGNAL(contentChanged()), Qt::UniqueConnection);\r\n    connect(&model_, SIGNAL(contentChanged()), this, SLOT(onItemChanged()), Qt::UniqueConnection);\r\n    connect(&model_, SIGNAL(remapStateAdded(int)), this, SIGNAL(childAdded(int)), Qt::UniqueConnection);\r\n    connect(&model_, SIGNAL(remapStateRemoved(int)), this, SIGNAL(childRemoved(int)), Qt::UniqueConnection);\r\n\r\n    connect(&view_, SIGNAL(addItem(const QModelIndex&)),\r\n        &model_, SLOT(onAddItem(const QModelIndex&)), Qt::UniqueConnection);\r\n    connect(&view_, SIGNAL(removeItem(const QModelIndex&)),\r\n        &model_, SLOT(onRemoveItem(const QModelIndex&)), Qt::UniqueConnection);\r\n\r\n    connect(&model_, SIGNAL(decreaseReferences(QString)), this,\r\n        SIGNAL(decreaseReferences(QString)), Qt::UniqueConnection);\r\n\r\n    setupLayout();\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: RemapStatesEditor::refresh()\r\n//-----------------------------------------------------------------------------\r\nvoid RemapStatesEditor::refresh()\r\n{\r\n    onItemChanged();\r\n    view_.update();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: RemapStatesEditor::onItemChanged()\r\n//-----------------------------------------------------------------------------\r\nvoid RemapStatesEditor::onItemChanged()\r\n{\r\n    view_.sortByColumn(RemapStatesModel::NAME_COLUMN, Qt::AscendingOrder);\r\n    view_.update();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: RemapStatesEditor::showEvent()\r\n//-----------------------------------------------------------------------------\r\nvoid RemapStatesEditor::showEvent(QShowEvent* event)\r\n{\r\n    QWidget::showEvent(event);\r\n    emit helpUrlRequested(\"componenteditor/remapStates.html\");\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: RemapStatesEditor::setupLayout()\r\n//-----------------------------------------------------------------------------\r\nvoid RemapStatesEditor::setupLayout()\r\n{\r\n    auto summaryLabel = new SummaryLabel(tr(\"Remap states summary\"), this);\r\n\r\n    auto layout = new QVBoxLayout(this);\r\n    layout->addWidget(summaryLabel, 0, Qt::AlignCenter);\r\n    layout->addWidget(&view_);\r\n    layout->setContentsMargins(0, 0, 0, 0);\r\n}\r\n"
  },
  {
    "path": "editors/ComponentEditor/remapStates/RemapStatesEditor.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: RemapStatesEditor.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Mikko Teuho\r\n// Date: 08.04.2015\r\n//\r\n// Description:\r\n// The editor to add / remove / edit remap states of a component.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef REMAPSTATESEDITOR_H\r\n#define REMAPSTATESEDITOR_H\r\n\r\n#include \"RemapStatesModel.h\"\r\n\r\n#include <common/views/EditableTableView/editabletableview.h>\r\n\r\n#include <editors/ComponentEditor/itemeditor.h>\r\n\r\nclass LibraryInterface;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! The editor used to add / remove / edit remap states of a component.\r\n//-----------------------------------------------------------------------------\r\nclass RemapStatesEditor : public ItemEditor\r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\r\n    /*!\r\n     *  The constructor.\r\n     *\r\n     *    @param [in] component           Pointer to the component being edited.\r\n     *    @param [in] handler             Pointer to the instance managing the library.\r\n     *    @param [in] parameterFinder     Finder used to locate parameter ids.\r\n     *    @param [in] parent              Pointer to the parent of this editor.\r\n     */\r\n    RemapStatesEditor(QSharedPointer<Component> component, LibraryInterface* handler,\r\n        QSharedPointer<ParameterFinder> parameterFinder, QWidget* parent = 0);\r\n\t\r\n\t/*!\r\n\t *  The destructor.\r\n\t */\r\n\tvirtual ~RemapStatesEditor() = default;\r\n\r\n    //! No copying\r\n    RemapStatesEditor(const RemapStatesEditor& other) = delete;\r\n    //! No assignment\r\n    RemapStatesEditor& operator=(const RemapStatesEditor& other) = delete;\r\n\r\n    /*!\r\n\t *  Reload the information from the model to the editor.\r\n\t */\r\n\tvirtual void refresh();\r\n\r\npublic slots:\r\n\r\n    /*!\r\n     *  Called to update the view sorting when the model changes.\r\n     */\r\n    virtual void onItemChanged();\r\n\r\nprotected:\r\n\r\n    /*!\r\n\t *  Handler for widget's show event.\r\n\t *\r\n\t *    @param [in] event   The given show event.\r\n\t */\r\n\tvirtual void showEvent(QShowEvent* event);\r\n\r\nprivate:\r\n\r\n    //! Setup the widget layout.\r\n    void setupLayout();\r\n\r\n\t//! The view to display the remap states.\r\n\tEditableTableView view_;\r\n\r\n    //! The model for managing the views summary.\r\n    RemapStatesModel model_;\r\n};\r\n\r\n#endif // REMAPSTATESEDITOR_H\r\n"
  },
  {
    "path": "editors/ComponentEditor/remapStates/RemapStatesModel.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: RemapStatesModel.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Mikko Teuho\r\n// Date: 08.04.2015\r\n//\r\n// Description:\r\n// The model to manage the remap states summary.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"RemapStatesModel.h\"\r\n\r\n#include <editors/ComponentEditor/memoryMaps/memoryMapsExpressionCalculators/ReferenceCalculator.h>\r\n\r\n#include <IPXACTmodels/Component/RemapState.h>\r\n#include <IPXACTmodels/Component/RemapPort.h>\r\n\r\n#include <common/KactusColors.h>\r\n\r\n\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: RemapStatesModel::RemapStatesModel()\r\n//-----------------------------------------------------------------------------\r\nRemapStatesModel::RemapStatesModel(QSharedPointer<QList<QSharedPointer<RemapState> > > remapStates,\r\n                                   QSharedPointer<ParameterFinder> parameterFinder, QObject* parent):\r\nQAbstractTableModel(parent),\r\nremapStates_(remapStates),\r\nparameterFinder_(parameterFinder)\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: RemapStatesModel::~RemapStatesModel()\r\n//-----------------------------------------------------------------------------\r\nRemapStatesModel::~RemapStatesModel()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: RemapStatesModel::rowCount()\r\n//-----------------------------------------------------------------------------\r\nint RemapStatesModel::rowCount(const QModelIndex& parent /* = QModelIndex() */) const\r\n{\r\n    if (parent.isValid())\r\n    {\r\n        return 0;\r\n    }\r\n\r\n    return remapStates_->count();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: RemapStatesModel::columnCount()\r\n//-----------------------------------------------------------------------------\r\nint RemapStatesModel::columnCount(const QModelIndex& parent /* = QModelIndex() */) const\r\n{\r\n    if (parent.isValid())\r\n    {\r\n        return 0;\r\n    }\r\n\r\n    return RemapStatesModel::COLUMN_COUNT;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: RemapStatesModel::flags()\r\n//-----------------------------------------------------------------------------\r\nQt::ItemFlags RemapStatesModel::flags(const QModelIndex& index) const\r\n{\r\n    if (!index.isValid())\r\n    {\r\n        return Qt::NoItemFlags;\r\n    }\r\n    else\r\n    {\r\n        return Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsEditable;\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: RemapStatesModel::headerData()\r\n//-----------------------------------------------------------------------------\r\nQVariant RemapStatesModel::headerData(int section, Qt::Orientation orientation, int role /* = Qt::DisplayRole */)\r\n    const\r\n{\r\n    if (orientation != Qt::Horizontal)\r\n    {\r\n        return QVariant();\r\n    }\r\n\r\n    if (role == Qt::DisplayRole)\r\n    {\r\n        if (section == RemapStatesModel::NAME_COLUMN)\r\n        {\r\n            return tr(\"Name\");\r\n        }\r\n        else if (section == RemapStatesModel::DISPLAY_NAME_COLUMN)\r\n        {\r\n            return tr(\"Display name\");\r\n        }\r\n        else if (section == RemapStatesModel::DESCRIPTION_COLUMN)\r\n        {\r\n            return tr(\"Description\");\r\n        }\r\n    }\r\n\r\n    return QVariant();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: RemapStatesModel::data()\r\n//-----------------------------------------------------------------------------\r\nQVariant RemapStatesModel::data(const QModelIndex& index, int role /* = Qt::DisplayRole */) const\r\n{\r\n    if (!index.isValid() || index.row() < 0 || index.row() >= remapStates_->size())\r\n    {\r\n        return QVariant();\r\n    }\r\n\r\n    if (role == Qt::DisplayRole)\r\n    {\r\n        if (index.column() == RemapStatesModel::NAME_COLUMN)\r\n        {\r\n            return remapStates_->at(index.row())->name();\r\n        }\r\n        else if (index.column() == RemapStatesModel::DISPLAY_NAME_COLUMN)\r\n        {\r\n            return remapStates_->at(index.row())->displayName();\r\n        }\r\n        else if (index.column() == RemapStatesModel::DESCRIPTION_COLUMN)\r\n        {\r\n            return remapStates_->at(index.row())->description();\r\n        }\r\n    }\r\n\r\n    else if (role == Qt::BackgroundRole)\r\n    {\r\n        if (index.column() == RemapStatesModel::NAME_COLUMN)\r\n        {\r\n            return KactusColors::MANDATORY_FIELD;\r\n        }\r\n        else\r\n        {\r\n            return KactusColors::REGULAR_FIELD;\r\n        }\r\n    }\r\n\r\n    return QVariant();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: RemapStatesModel::setData()\r\n//-----------------------------------------------------------------------------\r\nbool RemapStatesModel::setData(const QModelIndex& index, const QVariant& value, int role)\r\n{\r\n    if (!index.isValid() || index.row() < 0 || index.row() >= remapStates_->size() || role != Qt::EditRole)\r\n    {\r\n        return false;\r\n    }\r\n\r\n    if (index.column() == RemapStatesModel::NAME_COLUMN)\r\n    {\r\n        remapStates_->at(index.row())->setName(value.toString());\r\n    }\r\n    else if (index.column() == RemapStatesModel::DISPLAY_NAME_COLUMN)\r\n    {\r\n        remapStates_->at(index.row())->setDisplayName(value.toString());\r\n    }\r\n    else if (index.column() == RemapStatesModel::DESCRIPTION_COLUMN)\r\n    {\r\n        remapStates_->at(index.row())->setDescription(value.toString());\r\n    }\r\n    else\r\n    {\r\n        return false;\r\n    }\r\n\r\n    emit dataChanged(index, index);\r\n    emit contentChanged();\r\n    return true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: RemapStatesModel::onAddItem()\r\n//-----------------------------------------------------------------------------\r\nvoid RemapStatesModel::onAddItem(const QModelIndex& index)\r\n{\r\n    int row = remapStates_->size();\r\n\r\n    if (index.isValid())\r\n    {\r\n        row = index.row();\r\n    }\r\n\r\n    beginInsertRows(QModelIndex(), row, row);\r\n    \r\n    remapStates_->insert(row, QSharedPointer<RemapState>(new RemapState()));\r\n    \r\n    endInsertRows();\r\n\r\n    emit remapStateAdded(row);\r\n    emit contentChanged();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: RemapStatesModel::onRemoveItem()\r\n//-----------------------------------------------------------------------------\r\nvoid RemapStatesModel::onRemoveItem(const QModelIndex& index)\r\n{\r\n    if (!index.isValid() || index.row() < 0 || index.row() >= remapStates_->size())\r\n    {\r\n        return;\r\n    }\r\n\r\n    beginRemoveRows(QModelIndex(), index.row(), index.row());\r\n\r\n    removeReferencesFromRemapState(remapStates_->at(index.row()));\r\n\r\n    remapStates_->removeAt(index.row());\r\n    endRemoveRows();\r\n\r\n    emit remapStateRemoved(index.row());\r\n    emit contentChanged();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: RemapStatesModel::removeReferencesFromRemapState()\r\n//-----------------------------------------------------------------------------\r\nvoid RemapStatesModel::removeReferencesFromRemapState(QSharedPointer<RemapState> remapState)\r\n{\r\n    QStringList expressions;\r\n\r\n    foreach (QSharedPointer<RemapPort> remapPort, *remapState->getRemapPorts())\r\n    {\r\n        expressions.append(remapPort->getValue());\r\n    }\r\n\r\n    ReferenceCalculator referenceCalculator(parameterFinder_);\r\n    QMap<QString, int> referencedParameters = referenceCalculator.getReferencedParameters(expressions);\r\n\r\n    foreach (QString referencedId, referencedParameters.keys())\r\n    {\r\n        for (int i = 0; i < referencedParameters.value(referencedId); ++i)\r\n        {\r\n            emit decreaseReferences(referencedId);\r\n        }\r\n    }\r\n}\r\n"
  },
  {
    "path": "editors/ComponentEditor/remapStates/RemapStatesModel.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: RemapStatesModel.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Mikko Teuho\r\n// Date: 08.04.2015\r\n//\r\n// Description:\r\n// The model to manage the remap states summary.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef REMAPSTATESMODEL_H\r\n#define REMAPSTATESMODEL_H\r\n\r\n#include <QAbstractTableModel>\r\n#include <QList>\r\n#include <QSharedPointer>\r\n\r\nclass RemapState;\r\nclass ParameterFinder;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! The model to manage the remap states summary.\r\n//-----------------------------------------------------------------------------\r\nclass RemapStatesModel : public QAbstractTableModel\r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\r\n\t//! Contains the column numbers for columns.\r\n\tenum Column {\r\n\t\tNAME_COLUMN = 0,\r\n        DISPLAY_NAME_COLUMN,\r\n\t\tDESCRIPTION_COLUMN,\r\n\t\tCOLUMN_COUNT\r\n\t};\r\n\r\n    /*!\r\n     *  The constructor.\r\n     *\r\n     *    @param [in] remapStates         The remap states of the component.\r\n     *    @param [in] parameterFinder     Finder used to locate parameter ids.\r\n     *    @param [in] parent              Pointer to the owner of the model.\r\n     */\r\n    RemapStatesModel(QSharedPointer<QList<QSharedPointer<RemapState> > > remapStates,\r\n        QSharedPointer<ParameterFinder> parameterFinder, QObject* parent);\r\n\r\n    /*!\r\n     *  The destructor.\r\n     */\r\n    virtual ~RemapStatesModel();\r\n\r\n\t/*!\r\n\t *  Get the number of rows an item contains.\r\n\t *\r\n\t *    @param [in] parent  Identifies the parent that's row count is requested.\r\n     *\r\n     *    @return The number of rows the item has.\r\n\t */\r\n\tvirtual int rowCount(const QModelIndex& parent = QModelIndex()) const;\r\n\r\n\t/*!\r\n\t *  Get the number of displayable columns the item has.\r\n\t *\r\n\t *    @param [in] parent  Identifies the parent that's column count is requested.\r\n     *\r\n     *    @return The number of columns to be displayed\r\n\t */\r\n\tvirtual int columnCount(const QModelIndex& parent = QModelIndex()) const;\r\n\r\n    /*!\r\n\t *  Get the item flags that define the possible operations for the item.\r\n\t *\r\n\t *    @param [in] index   Model index that identifies the item.\r\n     *\r\n     *    @return The possible operations for the item as Qt::ItemFlags.\r\n\t */\r\n\tQt::ItemFlags flags(const QModelIndex& index) const;\r\n\r\n\t/*!\r\n\t *  Get the header data for specified header.\r\n\t *\r\n\t *    @param [in] section         The section for the header.\r\n\t *    @param [in] orientation     Specifies if the header is horizontal or vertical.\r\n\t *    @param [in] role            Specifies the type of the requested data.\r\n     *\r\n     *    @return The requested data.\r\n\t */\r\n\tvirtual QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;\r\n\r\n    /*!\r\n\t *  Get the data for the specified item.\r\n\t *\r\n\t *    @param [in] index   The index of the item that's data is requested.\r\n\t *    @param [in] role    The role that defines what kind of data is requested.\r\n     *\r\n     *    @return The data for the item.\r\n\t */\r\n\tvirtual QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const;\r\n\r\n\t/*!\r\n\t *  Save the data to the model for specified item.\r\n\t *\r\n\t *    @param [in] index   The index of the item used to store the data.\r\n\t *    @param [in] value   The data to be saved.\r\n\t *    @param [in] role    What kind of data should be saved.\r\n\t */\r\n\tbool setData(const QModelIndex& index, const QVariant& value, int role = Qt::EditRole);\r\n\r\npublic slots:\r\n\r\n    /*!\r\n\t *  Add a new item to the given index.\r\n\t *\r\n\t *    @param [in] index   The index identifying the position of the new item.\r\n\t */\r\n\tvirtual void onAddItem(const QModelIndex& index);\r\n\r\n\t/*!\r\n\t *  Remove the item in the given index.\r\n\t *\r\n\t *    @param [in] index   The index identifying the position of the item to be removed.\r\n\t */\r\n\tvirtual void onRemoveItem(const QModelIndex& index);\r\n\r\nsignals:\r\n\r\n\t/*!\r\n\t *  Emitted when the contents of the model change.\r\n\t */\r\n\tvoid contentChanged();\r\n\r\n    /*!\r\n     *  Emitted when a new remap state is added.\r\n     *\r\n     *    @param [in] index   The index of the new remap state.\r\n     */\r\n    void remapStateAdded(int index);\r\n\r\n    /*!\r\n     *  Emitted when a remap state is removed.\r\n     *\r\n     *    @param [in] index   The index of the remap state being removed.\r\n     */\r\n    void remapStateRemoved(int index);\r\n\r\n    /*!\r\n     *  Decrease the number of references to the selected parameter.\r\n     *\r\n     *    @param [in] id  ID of the selected parameter.\r\n     */\r\n    void decreaseReferences(QString id);\r\n\r\nprivate:\r\n\t//! No copying\r\n    RemapStatesModel(const RemapStatesModel& other);\r\n\r\n\t//! No assignment\r\n    RemapStatesModel& operator=(const RemapStatesModel& other);\r\n\r\n    /*!\r\n     *  Remove references from a selected remap state.\r\n     *\r\n     *    @param [in] remapState  The selected remap state.\r\n     */\r\n    void removeReferencesFromRemapState(QSharedPointer<RemapState> remapState);\r\n    \r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! Pointer to the list of remap states of the component.\r\n    QSharedPointer<QList<QSharedPointer<RemapState> > > remapStates_;\r\n\r\n    //! The used parameter finder.\r\n    QSharedPointer<ParameterFinder> parameterFinder_;\r\n};\r\n\r\n#endif // REMAPSTATESMODEL_H\r\n"
  },
  {
    "path": "editors/ComponentEditor/remapStates/SingleRemapStateEditor.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: SingleRemapStateEditor.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Mikko Teuho\r\n// Date: 08.04.2015\r\n//\r\n// Description:\r\n// Editor to edit a remap state within a component.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"SingleRemapStateEditor.h\"\r\n\r\n#include <IPXACTmodels/Component/RemapState.h>\r\n\r\n#include <QScrollArea>\r\n#include <QHBoxLayout>\r\n#include <QVBoxLayout>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SingleRemapStateEditor::SingleRemapStateEditor()\r\n//-----------------------------------------------------------------------------\r\nSingleRemapStateEditor::SingleRemapStateEditor(QSharedPointer<Component> component,\r\n    QSharedPointer<RemapState> remapState, LibraryInterface* libHandler,\r\n    QSharedPointer<ParameterFinder> parameterFinder, QSharedPointer<ExpressionFormatter> expressionFormatter,\r\n    QWidget* parent /* = 0 */):\r\nItemEditor(component, libHandler, parent),\r\nremapState_(remapState),\r\nnameEditor_(remapState_, component->getRevision(), this, tr(\"Remap state name and description\")),\r\nremapConditionEditor_(new RemapConditionEditor(remapState->getRemapPorts(), component, parameterFinder,\r\nexpressionFormatter, this))\r\n{\r\n    connect(remapConditionEditor_, SIGNAL(contentChanged()), this, SIGNAL(contentChanged()), Qt::UniqueConnection);\r\n    connect(&nameEditor_, SIGNAL(contentChanged()), this, SIGNAL(contentChanged()), Qt::UniqueConnection);\r\n\r\n    connect(remapConditionEditor_, SIGNAL(increaseReferences(QString)),\r\n        this, SIGNAL(increaseReferences(QString)), Qt::UniqueConnection);\r\n    connect(remapConditionEditor_, SIGNAL(decreaseReferences(QString)),\r\n        this, SIGNAL(decreaseReferences(QString)), Qt::UniqueConnection);\r\n\r\n    setupLayout();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SingleRemapStateEditor::refresh()\r\n//-----------------------------------------------------------------------------\r\nvoid SingleRemapStateEditor::refresh()\r\n{\r\n    nameEditor_.refresh();\r\n    remapConditionEditor_->refresh();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SingleRemapStateEditor::showEvent()\r\n//-----------------------------------------------------------------------------\r\nvoid SingleRemapStateEditor::showEvent(QShowEvent * event)\r\n{\r\n    QWidget::showEvent(event);\r\n    emit helpUrlRequested(\"componenteditor/singleRemapState.html\");\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SingleRemapStateEditor::setupLayout()\r\n//-----------------------------------------------------------------------------\r\nvoid SingleRemapStateEditor::setupLayout()\r\n{\r\n    auto scrollArea = new QScrollArea(this);\r\n    scrollArea->setWidgetResizable(true);\r\n    scrollArea->setFrameShape(QFrame::NoFrame);\r\n\r\n    auto scrollLayout = new QHBoxLayout(this);\r\n    scrollLayout->addWidget(scrollArea);\r\n    scrollLayout->setContentsMargins(0, 0, 0, 0);\r\n\r\n    auto nameLayout = new QVBoxLayout();\r\n    nameLayout->addWidget(&nameEditor_, 0, Qt::AlignTop);\r\n\r\n    auto remapConditionLayout = new QVBoxLayout();\r\n    remapConditionLayout->addWidget(remapConditionEditor_, 0);\r\n\r\n    auto topWidget = new QWidget(scrollArea);\r\n    topWidget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);\r\n    scrollArea->setWidget(topWidget);\r\n\r\n    auto topLayout = new QVBoxLayout(topWidget);\r\n    topLayout->addLayout(nameLayout);\r\n    topLayout->addLayout(remapConditionLayout);\r\n    topLayout->setContentsMargins(0,0,0,0);\r\n}\r\n"
  },
  {
    "path": "editors/ComponentEditor/remapStates/SingleRemapStateEditor.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: SingleRemapStateEditor.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Mikko Teuho\r\n// Date: 08.04.2015\r\n//\r\n// Description:\r\n// Editor to edit a remap state within a component.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef SINGLEREMAPSTATEEDITOR_H\r\n#define SINGLEREMAPSTATEEDITOR_H\r\n\r\n#include <editors/ComponentEditor/itemeditor.h>\r\n#include <editors/ComponentEditor/remapStates/RemapConditionEditor.h>\r\n\r\n#include <common/widgets/nameGroupEditor/namegroupeditor.h>\r\n\r\nclass RemapState;\r\n//-----------------------------------------------------------------------------\r\n//! Editor to edit a remap state within a component.\r\n//-----------------------------------------------------------------------------\r\nclass SingleRemapStateEditor : public ItemEditor\r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\r\n\t/*!\r\n\t *  The constructor.\r\n\t *\r\n\t *    @param [in] component               Pointer to the component that contains the view.\r\n\t *    @param [in] remapState              Pointer to the remap state being edited.\r\n\t *    @param [in] libHandler              Pointer to the instance that manages the library.\r\n     *    @param [in] parameterFinder         The finder for the parameter references.\r\n     *    @param [in] expressionFormatter     Changes the referenced ids to parameter names.\r\n\t *    @param [in] parent                  Pointer to the owner of this editor.\r\n\t */\r\n    SingleRemapStateEditor(QSharedPointer<Component> component,\r\n        QSharedPointer<RemapState> remapState,\r\n        LibraryInterface* libHandler,\r\n        QSharedPointer<ParameterFinder> parameterFinder,\r\n        QSharedPointer<ExpressionFormatter> expressionFormatter,\r\n        QWidget* parent = 0);\r\n\r\n\t//! The destructor\r\n    virtual ~SingleRemapStateEditor() = default;\r\n\r\n    //! No copying\r\n    SingleRemapStateEditor(const SingleRemapStateEditor& other) = delete;\r\n\r\n    //! No assignment\r\n    SingleRemapStateEditor& operator=(const SingleRemapStateEditor& other) = delete;\r\n\r\n\t/*!\r\n\t *  Reload the information from the model to the editor.\r\n\t */\r\n\tvirtual void refresh();\r\n\r\nprotected:\r\n    \r\n    /*!\r\n     *  The show event for this editor.\r\n     *\r\n     *    @param [in] event   The show event.\r\n     */\r\n    virtual void showEvent(QShowEvent * event);\r\n\r\nprivate:\r\n\r\n\t/*!\r\n\t *  Set up the layout for the editor.\r\n\t */\r\n\tvoid setupLayout();\r\n\r\n    //! Pointer to the remap state being edited.\r\n    QSharedPointer<RemapState> remapState_;\r\n\r\n\t//! Editor to set the name, display name and description of the view.\r\n\tNameGroupEditor nameEditor_;\r\n\r\n    //! The editor for the remap condition.\r\n    RemapConditionEditor* remapConditionEditor_;\r\n};\r\n\r\n#endif // SINGLEREMAPSTATEEDITOR_H\r\n"
  },
  {
    "path": "editors/ComponentEditor/remapStates/ValueOrIndexedValueEditor.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ValueOrIndexedValueEditor.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Mikko Teuho\r\n// Date: 20.04.2016\r\n//\r\n// Description:\r\n// Editor for changing values in items that can be given as a single value or array.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"ValueOrIndexedValueEditor.h\"\r\n\r\n\r\n#include <editors/ComponentEditor/common/ExpressionEditor.h>\r\n#include <KactusAPI/include/ComponentParameterFinder.h>\r\n#include <KactusAPI/include/ExpressionParser.h>\r\n\r\n#include <editors/ComponentEditor/parameters/ComponentParameterModel.h>\r\n#include <editors/ComponentEditor/parameters/Array/ArrayView.h>\r\n#include <editors/ComponentEditor/parameters/Array/ArrayDelegate.h>\r\n#include <editors/ComponentEditor/parameters/Array/ParameterArrayModel.h>\r\n\r\n#include <IPXACTmodels/common/validators/ValueFormatter.h>\r\n\r\n#include <common/KactusColors.h>\r\n\r\n#include <QCompleter>\r\n#include <QHeaderView>\r\n#include <QEvent>\r\n#include <QLabel>\r\n#include <QScrollArea>\r\n#include <QHBoxLayout>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ValueOrIndexedValueEditor::ValueOrIndexedValueEditor()\r\n//-----------------------------------------------------------------------------\r\nValueOrIndexedValueEditor::ValueOrIndexedValueEditor(QSharedPointer<ParameterFinder> finder,\r\n    QSharedPointer<ExpressionParser> parser, QSharedPointer<ExpressionFormatter> formatter, Document::Revision docRevision, QWidget* parent) :\r\nQTableView(parent),\r\nsingleValueEditor_(new ExpressionEditor(finder)),\r\narrayView_(new ArrayView(this)),\r\nexpressionParser_(parser),\r\nparameterFinder_(finder),\r\nexpressionFormatter_(formatter),\r\nparameterModel_(new ComponentParameterModel(finder, this)),\r\ndocRevision_(docRevision)\r\n{\r\n    parameterModel_->setExpressionParser(parser);\r\n\r\n    setupSingleValueEditor();\r\n\r\n    setupLayout();\r\n\r\n    setFocusProxy(singleValueEditor_);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ValueOrIndexedValueEditor::~ValueOrIndexedValueEditor()\r\n//-----------------------------------------------------------------------------\r\nValueOrIndexedValueEditor::~ValueOrIndexedValueEditor()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ValueOrIndexedValueEditor::setupSingleValueEditor()\r\n//-----------------------------------------------------------------------------\r\nvoid ValueOrIndexedValueEditor::setupSingleValueEditor()\r\n{\r\n    singleValueEditor_->setFixedHeight(ExpressionEditor::DEFAULT_HEIGHT);\r\n\r\n    QCompleter* singleCompleter = createParameterNameCompleter(singleValueEditor_);\r\n    singleValueEditor_->setAppendingCompleter(singleCompleter);\r\n\r\n    connect(singleValueEditor_, SIGNAL(increaseReference(QString const&)),\r\n        this, SIGNAL(increaseReferences(QString const&)), Qt::UniqueConnection);\r\n    connect(singleValueEditor_, SIGNAL(decreaseReference(QString const&)),\r\n        this, SIGNAL(decreaseReferences(QString const&)), Qt::UniqueConnection);\r\n    \r\n    connect(singleValueEditor_, SIGNAL(editingFinished()), this, SIGNAL(contentChanged()), Qt::UniqueConnection);\r\n    connect(singleValueEditor_, SIGNAL(editingFinished()), this, SLOT(onSingleValueEdited()), Qt::UniqueConnection);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ValueOrIndexedValueEditor::onSingleValueEdited()\r\n//-----------------------------------------------------------------------------\r\nvoid ValueOrIndexedValueEditor::onSingleValueEdited()\r\n{\r\n    singleValueEditor_->finishEditingCurrentWord();\r\n\r\n    QString newSingleValue = singleValueEditor_->getExpression();\r\n\r\n    singleValueEditor_->setToolTip(formattedValueFor(newSingleValue));\r\n\r\n    if (newSingleValue.isEmpty())\r\n    {\r\n        arrayView_->setDisabled(false);\r\n    }\r\n    else\r\n    {\r\n        arrayView_->setDisabled(true);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ValueOrIndexedValueEditor::createParameterNameCompleter()\r\n//-----------------------------------------------------------------------------\r\nQCompleter* ValueOrIndexedValueEditor::createParameterNameCompleter(QObject* completerParent) const\r\n{\r\n    auto expressionCompleter = new QCompleter(completerParent);\r\n    expressionCompleter->setModel(parameterModel_);\r\n\r\n    return expressionCompleter;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ValueOrIndexedValueEditor::setupLayout()\r\n//-----------------------------------------------------------------------------\r\nvoid ValueOrIndexedValueEditor::setupLayout()\r\n{\r\n    QVBoxLayout* editorLayout = new QVBoxLayout(this);\r\n\r\n    editorLayout->setContentsMargins(0, 0, 0, 0);\r\n    editorLayout->setContentsMargins(0,0,0,0);\r\n\r\n    QString singleExplanation = tr(\"Set the value for the whole port\");\r\n    QLabel* singleEditorLabel = new QLabel(singleExplanation, this);\r\n\r\n    editorLayout->addWidget(singleEditorLabel);\r\n    editorLayout->addWidget(singleValueEditor_);\r\n\r\n    QScrollArea* arrayScroller = new QScrollArea(this);\r\n    arrayScroller->setWidgetResizable(true);\r\n    arrayScroller->parent()->installEventFilter(arrayView_);\r\n    arrayScroller->setWidget(arrayView_);\r\n\r\n    QString arrayExplanation = tr(\"Or set the values for one or more bits of the port\");\r\n    QLabel* arrayLabel = new QLabel(arrayExplanation, this);\r\n\r\n    editorLayout->addWidget(arrayLabel);\r\n    editorLayout->addWidget(arrayScroller);\r\n\r\n    singleValueEditor_->installEventFilter(this);\r\n    arrayView_->installEventFilter(this);\r\n    singleEditorLabel->installEventFilter(this);\r\n    arrayLabel->installEventFilter(this);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ValueOrIndexedValueEditor::setupArrayEditor()\r\n//-----------------------------------------------------------------------------\r\nvoid ValueOrIndexedValueEditor::setupArrayEditor(QString const& value, int const& leftBound, int const& rightBound)\r\n{\r\n    int arraySize = abs(leftBound - rightBound) + 1;\r\n\r\n    int arrayStart = qMin(leftBound, rightBound);\r\n\r\n    QSharedPointer<Choice> newChoice(new Choice());\r\n\r\n    ParameterArrayModel* arrayModel = new ParameterArrayModel(arraySize, expressionParser_, parameterFinder_,\r\n        expressionFormatter_, newChoice, KactusColors::REGULAR_FIELD, arrayStart, docRevision_, arrayView_);\r\n\r\n    if (value.contains('{') && value.contains('}'))\r\n    {\r\n        arrayModel->setArrayData(value);\r\n\r\n        singleValueEditor_->setDisabled(true);\r\n    }\r\n    else if (!value.isEmpty())\r\n    {\r\n        setValueToSingleEditor(value);\r\n\r\n        arrayView_->setDisabled(true);\r\n    }\r\n\r\n\r\n    arrayView_->setItemDelegate(new ArrayDelegate(parameterModel_, parameterFinder_, newChoice, this->parent()));\r\n    arrayView_->setModel(arrayModel);\r\n    arrayView_->resizeColumnsToContents();\r\n\r\n    connect(arrayModel, SIGNAL(dataChanged(const QModelIndex&, const QModelIndex&)),\r\n        this, SLOT(onDataChangeInArrayView()), Qt::UniqueConnection);\r\n    connect(arrayModel, SIGNAL(contentChanged()), this, SIGNAL(contentChanged()), Qt::UniqueConnection);\r\n\r\n    connect(arrayView_->itemDelegate(), SIGNAL(increaseReferences(QString)),\r\n        this, SIGNAL(increaseReferences(QString)), Qt::UniqueConnection);\r\n    connect(arrayView_->itemDelegate(), SIGNAL(decreaseReferences(QString)),\r\n        this, SIGNAL(decreaseReferences(QString)), Qt::UniqueConnection);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ValueOrIndexedValueEditor::onDataChangeInArrayView()\r\n//-----------------------------------------------------------------------------\r\nvoid ValueOrIndexedValueEditor::onDataChangeInArrayView()\r\n{\r\n    ParameterArrayModel* arrayModel = dynamic_cast<ParameterArrayModel*>(arrayView_->model());\r\n\r\n    QStringList arrayData = arrayModel->getArrayDataAsList();\r\n\r\n    foreach (QString singleBit, arrayData)\r\n    {\r\n        if (!singleBit.isEmpty())\r\n        {\r\n            singleValueEditor_->setDisabled(true);\r\n            return;\r\n        }\r\n    }\r\n\r\n    singleValueEditor_->setDisabled(false);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ValueOrIndexedValueEditor::setValueToSingleEditor()\r\n//-----------------------------------------------------------------------------\r\nvoid ValueOrIndexedValueEditor::setValueToSingleEditor(QString const& value)\r\n{\r\n    singleValueEditor_->blockSignals(true);\r\n\r\n    singleValueEditor_->setExpression(value);\r\n    singleValueEditor_->setToolTip(formattedValueFor(value));\r\n\r\n    singleValueEditor_->blockSignals(false);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ValueOrIndexedValueEditor::formattedValueFor()\r\n//-----------------------------------------------------------------------------\r\nQString ValueOrIndexedValueEditor::formattedValueFor(QString const& expression) const\r\n{\r\n    return ExpressionFormatter::format(expression, expressionParser_);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ValueOrIndexedValueEditor::getValueData()\r\n//-----------------------------------------------------------------------------\r\nQString ValueOrIndexedValueEditor::getValueData() const\r\n{\r\n    QString singleValue = singleValueEditor_->getExpression();\r\n\r\n    QString arrayData;\r\n\r\n    ParameterArrayModel* arrayModel = dynamic_cast<ParameterArrayModel*>(arrayView_->model());\r\n    if (arrayModel)\r\n    {\r\n        arrayData = arrayModel->getArrayData();\r\n    }\r\n\r\n    QString returnValue (\"\");\r\n\r\n    if (arrayContainsValues(arrayData))\r\n    {\r\n        returnValue = arrayData;\r\n    }\r\n    else if (!singleValue.isEmpty())\r\n    {\r\n        returnValue = singleValue;\r\n    }\r\n\r\n    return returnValue;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ValueOrIndexedValueEditor::arrayContainsValues()\r\n//-----------------------------------------------------------------------------\r\nbool ValueOrIndexedValueEditor::arrayContainsValues(QString const& arrayContents) const\r\n{\r\n    QStringList arrayData = arrayContents.split(',');\r\n    arrayData.first().remove('{');\r\n    arrayData.last().remove('}');\r\n\r\n    foreach (QString singleBit, arrayData)\r\n    {\r\n        if (!singleBit.isEmpty())\r\n        {\r\n            return true;\r\n        }\r\n    }\r\n\r\n    return false;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ValueOrIndexedValueEditor::eventFilter()\r\n//-----------------------------------------------------------------------------\r\nbool ValueOrIndexedValueEditor::eventFilter(QObject* filterObject, QEvent* filterEvent)\r\n{\r\n    QLabel* explanationLabel = qobject_cast<QLabel*>(filterObject);\r\n    if ((explanationLabel || filterObject == singleValueEditor_ || filterObject == arrayView_ ) &&\r\n        filterEvent->type() == QEvent::MouseButtonPress)\r\n    {\r\n        return true;\r\n    }\r\n\r\n    return QTableView::eventFilter(filterObject, filterEvent);\r\n}\r\n"
  },
  {
    "path": "editors/ComponentEditor/remapStates/ValueOrIndexedValueEditor.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ValueOrIndexedValueEditor.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Mikko Teuho\r\n// Date: 20.04.2016\r\n//\r\n// Description:\r\n// Editor for changing values in items that can be given as a single value or array.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef VALUEORINDEXEDVALUEEDITOR_H\r\n#define VALUEORINDEXEDVALUEEDITOR_H\r\n\r\n#include <IPXACTmodels/common/Document.h>\r\n\r\n#include <QTableView>\r\n#include <QCompleter>\r\n\r\nclass ArrayView;\r\nclass ExpressionEditor;\r\nclass ParameterFinder;\r\nclass ExpressionParser;\r\nclass ExpressionFormatter;\r\nclass ComponentParameterModel;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Editor for changing values in items that can be given as a single value or array.\r\n//-----------------------------------------------------------------------------\r\nclass ValueOrIndexedValueEditor : public QTableView\r\n{\r\n    Q_OBJECT\r\npublic:\r\n\r\n    /*!\r\n     *  The constructor.\r\n     *\r\n     *    @param [in] finder      The used parameter finder.\r\n     *    @param [in] parser      The used expression parser.\r\n     *    @param [in] formatter   The used expression formatter.\r\n     *    @param [in] parent      The parent widget of this table.\r\n     */\r\n    ValueOrIndexedValueEditor(QSharedPointer<ParameterFinder> finder, QSharedPointer<ExpressionParser> parser, QSharedPointer<ExpressionFormatter> formatter, Document::Revision docRevision, QWidget* parent);\r\n\r\n    /*!\r\n     *  The destructor.\r\n     */\r\n    ~ValueOrIndexedValueEditor();\r\n\r\n    /*!\r\n     *  Setup the array editor.\r\n     *\r\n     *    @param [in] value       The current value of the remap condition.\r\n     *    @param [in] leftBound   The left bound of the array.\r\n     *    @param [in] rightBound  The right bound of the array.\r\n     */\r\n    void setupArrayEditor(QString const& value, int const& leftBound, int const& rightBound);\r\n\r\n    /*!\r\n     *  Get the value of the editor.\r\n     *\r\n     *    @return A single value, if the single editor was edited. An array if the array was edited.\r\n     */\r\n    QString getValueData() const;\r\n    \r\n    /*!\r\n     *  The event filter for this widget.\r\n     *\r\n     *    @param [in] filterObject    The object to be filtered.\r\n     *    @param [in] filterEvent     The event to be filtered.\r\n     */\r\n    virtual bool eventFilter(QObject* filterObject, QEvent* filterEvent);\r\n\r\nsignals:\r\n    \r\n    /*!\r\n     *  Increase the amount of references to a parameter corresponding to the id.\r\n     *\r\n     *    @param [in] id      The id of the parameter being searched for.\r\n     */\r\n    void increaseReferences(QString id);\r\n\r\n    /*!\r\n     *  Decrease the amount of references to a parameter corresponding to the id.\r\n     *\r\n     *    @param [in] id      The id of the parameter being searched for.\r\n     */\r\n    void decreaseReferences(QString id);\r\n\r\n    /*!\r\n     *  Content has been changed in the editor.\r\n     */\r\n    void contentChanged();\r\n\r\nprivate slots:\r\n\r\n    /*!\r\n     *  Handler for editing the single value of a remap condition.\r\n     */\r\n    void onSingleValueEdited();\r\n\r\n    /*!\r\n     *  Handler for editing the array values of a remap condition.\r\n     */\r\n    void onDataChangeInArrayView();\r\n\r\nprivate:\r\n    //! Disable copying and assignment.\r\n    ValueOrIndexedValueEditor(const ValueOrIndexedValueEditor& other);\r\n    ValueOrIndexedValueEditor& operator=(const ValueOrIndexedValueEditor& other);\r\n\r\n    /*!\r\n     *  Setup the single value editor.\r\n     */\r\n    void setupSingleValueEditor();\r\n\r\n    /*!\r\n     *  Create a parameter name completer.\r\n     *\r\n     *    @param [in] completerParent     The parent for the completer.\r\n     *\r\n     *    @return The created parameter name completer.\r\n     */\r\n    QCompleter* createParameterNameCompleter(QObject* completerParent) const;\r\n\r\n    /*!\r\n     *  Setup the layout for this widget.\r\n     */\r\n    void setupLayout();\r\n\r\n    /*!\r\n     *  Calculate the formatted value for the selected expression.\r\n     *\r\n     *    @param [in] expression  The selected expression.\r\n     *\r\n     *    @return The formatted value of the selected expression.\r\n     */\r\n    QString formattedValueFor(QString const& expression) const;\r\n\r\n    /*!\r\n     *  Set the value for the single value editor.\r\n     *\r\n     *    @param [in] value   The new value.\r\n     */\r\n    void setValueToSingleEditor(QString const& value);\r\n\r\n    /*!\r\n     *  Check if the array contains values.\r\n     *\r\n     *    @param [in] arrayContents   The contents of the array.\r\n     *\r\n     *    @return True, if the array contains any values, false otherwise.\r\n     */\r\n    bool arrayContainsValues(QString const& arrayContents) const;\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! The single remap condition value editor.\r\n    ExpressionEditor* singleValueEditor_;\r\n\r\n    //! The array editor for bit-by-bit remap condition.\r\n    ArrayView* arrayView_;\r\n\r\n    //! The used expression parser.\r\n    QSharedPointer<ExpressionParser> expressionParser_;\r\n\r\n    //! The used parameter finder.\r\n    QSharedPointer<ParameterFinder> parameterFinder_;\r\n\r\n    //! The used expression formatter.\r\n    QSharedPointer<ExpressionFormatter> expressionFormatter_;\r\n\r\n    //! The parameter model for the expression editors.\r\n    ComponentParameterModel* parameterModel_;\r\n\r\n    //! The IP-XACT standard revision in use.\r\n    Document::Revision docRevision_;\r\n};\r\n\r\n#endif // VALUEORINDEXEDVALUEEDITOR_H"
  },
  {
    "path": "editors/ComponentEditor/resetTypes/ResetTypeColumns.h",
    "content": "//-----------------------------------------------------------------------------\n// File: ResetTypeColumns.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 04.01.2019\n//\n// Description:\n// Common declarations for editing reset types.\n//-----------------------------------------------------------------------------\n\nnamespace ResetTypeColumns\n{\n    //! Contains the columns for reset type properties.\n    enum Column\n    {\n        NAME_COLUMN = 0,\n        DISPLAY_NAME_COLUMN,\n        SHORT_DESCRIPTION_COLUMN,\n        DESCRIPTION_COLUMN,\n        COLUMN_COUNT\n    };\n}\n"
  },
  {
    "path": "editors/ComponentEditor/resetTypes/ResetTypesDelegate.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: ResetTypesDelegate.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 04.01.2019\n//\n// Description:\n// The delegate to provide editors to add/remove/edit the reset types of a component.\n//-----------------------------------------------------------------------------\n\n#include \"ResetTypesDelegate.h\"\n\n#include <editors/ComponentEditor/resetTypes/ResetTypeColumns.h>\n\n#include <QLineEdit>\n#include <QStringList>\n#include <QString>\n\n//-----------------------------------------------------------------------------\n// Function: ResetTypesDelegate::ResetTypesDelegate()\n//-----------------------------------------------------------------------------\nResetTypesDelegate::ResetTypesDelegate(QObject* parent):\nQStyledItemDelegate(parent)\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: ResetTypesDelegate::~ResetTypesDelegate()\n//-----------------------------------------------------------------------------\nResetTypesDelegate::~ResetTypesDelegate()\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: ResetTypesDelegate::createEditor()\n//-----------------------------------------------------------------------------\nQWidget* ResetTypesDelegate::createEditor(QWidget* parent, QStyleOptionViewItem const& option,\n    QModelIndex const& index) const\n{\n    if (index.column() == ResetTypeColumns::NAME_COLUMN ||\n        index.column() == ResetTypeColumns::DISPLAY_NAME_COLUMN ||\n        index.column() == ResetTypeColumns::DESCRIPTION_COLUMN)\n    {\n        QLineEdit* lineEdit = new QLineEdit(parent);\n        connect(lineEdit, SIGNAL(editingFinished()), this, SLOT(commitAndCloseEditor()), Qt::UniqueConnection);\n        return lineEdit;\n    }\n    else\n    {\n        return QStyledItemDelegate::createEditor(parent, option, index);\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: ResetTypesDelegate::setEditorData()\n//-----------------------------------------------------------------------------\nvoid ResetTypesDelegate::setEditorData(QWidget* editor, QModelIndex const& index) const\n{\n    if (index.column() == ResetTypeColumns::NAME_COLUMN ||\n        index.column() == ResetTypeColumns::DISPLAY_NAME_COLUMN ||\n        index.column() == ResetTypeColumns::DESCRIPTION_COLUMN)\n    {\n        QLineEdit* edit = qobject_cast<QLineEdit*>(editor);\n        Q_ASSERT(edit);\n\n        const QString text = index.data(Qt::DisplayRole).toString();\n        edit->setText(text);\n    }\n    else\n    {\n        QStyledItemDelegate::setEditorData(editor, index);\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: ResetTypesDelegate::setModelData()\n//-----------------------------------------------------------------------------\nvoid ResetTypesDelegate::setModelData(QWidget* editor, QAbstractItemModel* model, QModelIndex const& index) const\n{\n    if (index.column() == ResetTypeColumns::NAME_COLUMN ||\n        index.column() == ResetTypeColumns::DISPLAY_NAME_COLUMN ||\n        index.column() == ResetTypeColumns::DESCRIPTION_COLUMN)\n    {\n        QLineEdit* edit = qobject_cast<QLineEdit*>(editor);\n        Q_ASSERT(edit);\n\n        QString text = edit->text();\n        model->setData(index, text, Qt::EditRole);\n    }\n    else\n    {\n        QStyledItemDelegate::setModelData(editor, model, index);\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: ResetTypesDelegate::commitAndCloseEditor()\n//-----------------------------------------------------------------------------\nvoid ResetTypesDelegate::commitAndCloseEditor()\n{\n\tQWidget* edit = qobject_cast<QWidget*>(sender());\n\tQ_ASSERT(edit);\n\n\temit commitData(edit);\n\temit closeEditor(edit);\n}\n"
  },
  {
    "path": "editors/ComponentEditor/resetTypes/ResetTypesDelegate.h",
    "content": "//-----------------------------------------------------------------------------\n// File: ResetTypesDelegate.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 04.01.2019\n//\n// Description:\n// The delegate to provide editors to add/remove/edit the reset types of a component.\n//-----------------------------------------------------------------------------\n\n#ifndef RESETTYPESDELEGATE_H\n#define RESETTYPESDELEGATE_H\n\n#include <QStyledItemDelegate>\n#include <QSharedPointer>\n\n//-----------------------------------------------------------------------------\n//! The delegate to provide editors to add/remove/edit the reset types of a component.\n//-----------------------------------------------------------------------------\nclass ResetTypesDelegate: public QStyledItemDelegate\n{\n\tQ_OBJECT\n\npublic:\n\n\t/*!\n     *  The constructor\n\t *\n\t *    @param [in] parent      The owner of the delegate.\n\t */\n    ResetTypesDelegate(QObject *parent);\n\t\n\t/*!\n     *  The destructor.\n     */\n    virtual ~ResetTypesDelegate();\n\n\t/*!\n     *  Create a new editor for the given item\n\t *\n\t *    @param [in] parent  Owner for the editor.\n\t *    @param [in] option  Contains options for the editor.\n\t *    @param [in] index   Model index identifying the item.\n\t *\n\t *    @return The editor to be used to edit the item.\n     */\n\tvirtual QWidget* createEditor(QWidget* parent, QStyleOptionViewItem const& option, QModelIndex const& index)\n        const;\n\n\t/*!\n     *  Set the data for the editor.\n\t *\n\t *    @param [in] editor  The editor where the data is to be set.\n\t *    @param [in] index   Model index identifying the item that's data is to be set.\n     */\n\tvirtual void setEditorData(QWidget* editor, QModelIndex const& index) const;\n\n\t/*!\n     *  Save the data from the editor to the model.\n\t *\n\t *    @param [in] editor  The editor that contains the data to store.\n\t *    @param [in] model   Model that contains the data structure where data is to be saved to.\n\t *    @param [in] index   Model index identifying the item that's data is to be saved.\n     */\n\tvirtual void setModelData(QWidget* editor, QAbstractItemModel* model, QModelIndex const& index) const;\n\nprivate slots:\n\n\t/*!\n     *  Commit the data from the sending editor and close the editor.\n     */\n\tvoid commitAndCloseEditor();\n\nprivate:\n\t\n\t//! No copying.\n\tResetTypesDelegate(const ResetTypesDelegate& other);\n    ResetTypesDelegate& operator=(const ResetTypesDelegate& other);\n};\n\n#endif // RESETTYPESDELEGATE_H\n"
  },
  {
    "path": "editors/ComponentEditor/resetTypes/ResetTypesEditor.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: ResetTypesEditor.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 04.01.2019\n//\n// Description:\n// Editor to add/remove/edit the reset types-elements of a component.\n//-----------------------------------------------------------------------------\n\n#include \"ResetTypesEditor.h\"\n#include \"ResetTypeColumns.h\"\n\n#include <IPXACTmodels/Component/Component.h>\n\n#include <common/widgets/summaryLabel/summarylabel.h>\n\n#include <editors/ComponentEditor/resetTypes/ResetTypesDelegate.h>\n\n#include <KactusAPI/include/LibraryInterface.h>\n\n#include <QVBoxLayout>\n\n//-----------------------------------------------------------------------------\n// Function: ResetTypesEditor::ResetTypesEditor()\n//-----------------------------------------------------------------------------\nResetTypesEditor::ResetTypesEditor(QSharedPointer<Component> component, LibraryInterface* handler,\n    QSharedPointer<ComponentValidator> validator, QWidget* parent):\nItemEditor(component, handler, parent),\nview_(this),\nproxy_(this),\nmodel_(component, validator, this)\n{\n    SummaryLabel* summaryLabel = new SummaryLabel(tr(\"Reset types\"), this);\n\n    QVBoxLayout* layout = new QVBoxLayout(this);\n    layout->addWidget(summaryLabel, 0, Qt::AlignCenter);\n    layout->addWidget(&view_);\n    layout->setContentsMargins(0, 0, 0, 0);\n\n    proxy_.setSourceModel(&model_);\n    proxy_.setSortCaseSensitivity(Qt::CaseInsensitive);\n\n    view_.setModel(&proxy_);\n    view_.resizeColumnsToContents();\n    view_.setSortingEnabled(true);\n    view_.sortByColumn(0, Qt::AscendingOrder);\n\n    view_.setItemsDraggable(false);\n    view_.setItemDelegate(new ResetTypesDelegate(this));\n\n    if (component->getRevision() == Document::Revision::Std14)\n    {\n        view_.hideColumn(ResetTypeColumns::SHORT_DESCRIPTION_COLUMN);\n    }\n\n    connect(&model_, SIGNAL(contentChanged()), this, SIGNAL(contentChanged()), Qt::UniqueConnection);\n\n    connect(&view_, SIGNAL(addItem(const QModelIndex&)),\n        &model_, SLOT(onAddItem(const QModelIndex&)), Qt::UniqueConnection);\n    connect(&view_, SIGNAL(removeItem(const QModelIndex&)),\n        &model_, SLOT(onRemoveItem(const QModelIndex&)), Qt::UniqueConnection);\n}\n\n//-----------------------------------------------------------------------------\n// Function: ResetTypesEditor::refresh()\n//-----------------------------------------------------------------------------\nvoid ResetTypesEditor::refresh()\n{\n\tview_.update();\n}\n\n//-----------------------------------------------------------------------------\n// Function: ResetTypesEditor::showEvent()\n//-----------------------------------------------------------------------------\nvoid ResetTypesEditor::showEvent(QShowEvent* event)\n{\n\tQWidget::showEvent(event);\n\n    if (component()->getRevision() == Document::Revision::Std22)\n    {\n        emit helpUrlRequested(\"componenteditor/resetTypes2022.html\");\n    }\n    else\n    {\n        emit helpUrlRequested(\"componenteditor/resetTypes.html\");\n    }\n}\n"
  },
  {
    "path": "editors/ComponentEditor/resetTypes/ResetTypesEditor.h",
    "content": "//-----------------------------------------------------------------------------\n// File: ResetTypesEditor.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 04.01.2019\n//\n// Description:\n// Editor to add/remove/edit the reset types-elements of a component.\n//-----------------------------------------------------------------------------\n\n#ifndef RESETTYPESEDITOR_H\n#define RESETTYPESEDITOR_H\n\n#include <common/views/EditableTableView/editabletableview.h>\n\n#include <editors/ComponentEditor/itemeditor.h>\n#include <editors/ComponentEditor/resetTypes/ResetTypesModel.h>\n\n#include <QSortFilterProxyModel>\n#include <QSharedPointer>\n\nclass Component;\nclass ComponentValidator;\nclass LibraryInterface;\n\n//-----------------------------------------------------------------------------\n//! Editor to add/remove/edit the reset types-elements of a component.\n//-----------------------------------------------------------------------------\nclass ResetTypesEditor : public ItemEditor\n{\n\tQ_OBJECT\n\npublic:\n\n\t/*!\n     *  The constructor\n\t *\n\t *    @param [in] component   The component being edited.\n\t *    @param [in] handler     The instance managing the library.\n     *    @param [in] validator   The validator for components.\n\t *    @param [in] parent      The parent of this editor.\n     */\n\tResetTypesEditor(QSharedPointer<Component> component, LibraryInterface* handler, \n        QSharedPointer<ComponentValidator> validator, QWidget* parent = 0);\n\t\n\t/*!\n     *  The destructor.\n     */\n\tvirtual ~ResetTypesEditor() = default;\n\n    //! No copying\n    ResetTypesEditor(const ResetTypesEditor& other) = delete;\n    ResetTypesEditor& operator=(const ResetTypesEditor& other) = delete;\n\n\t/*!\n     *  Reload the information from the model to the editor.\n     */\n\tvoid refresh() final;\n\nprotected:\n\n\t/*!\n     *  Handler for widget's show event.\n     */\n\tvirtual void showEvent(QShowEvent* event);\n\nprivate:\n\n\t//! The view to display the reset types.\n\tEditableTableView view_;\n\n\t//! The model that does the sorting.\n\tQSortFilterProxyModel proxy_;\n\n\t//! The model that manages the reset types of the editor.\n    ResetTypesModel model_;\n};\n\n#endif // RESETTYPESEDITOR_H\n"
  },
  {
    "path": "editors/ComponentEditor/resetTypes/ResetTypesModel.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: ResetTypesModel.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 04.01.2019\n//\n// Description:\n//! Model for reset type elements within a component.\n//-----------------------------------------------------------------------------\n\n#include \"ResetTypesModel.h\"\n#include \"ResetTypeColumns.h\"\n\n#include <IPXACTmodels/Component/Component.h>\n#include <IPXACTmodels/Component/ResetType.h>\n#include <IPXACTmodels/Component/validators/ComponentValidator.h>\n\n#include <common/KactusColors.h>\n\n#include <QStringList>\n\n//-----------------------------------------------------------------------------\n// Function: ResetTypesModel::ResetTypesModel()\n//-----------------------------------------------------------------------------\nResetTypesModel::ResetTypesModel(QSharedPointer<Component> component, QSharedPointer<ComponentValidator> validator,\n    QObject* parent):\nQAbstractTableModel(parent),\ncomponent_(component),\nresetTypes_(component_->getResetTypes()),\nvalidator_(validator)\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: ResetTypesModel::rowCount()\n//-----------------------------------------------------------------------------\nint ResetTypesModel::rowCount(QModelIndex const& parent) const\n{\n\tif (parent.isValid())\n    {\n\t\treturn 0;\n\t}\n\n    return resetTypes_->count();\n}\n\n//-----------------------------------------------------------------------------\n// Function: ResetTypesModel::ResetTypesModel()\n//-----------------------------------------------------------------------------\nint ResetTypesModel::columnCount(QModelIndex const& parent) const\n{\n\tif (parent.isValid())\n    {\n\t\treturn 0;\n\t}\n\n\treturn ResetTypeColumns::COLUMN_COUNT;\n}\n\n//-----------------------------------------------------------------------------\n// Function: ResetTypesModel::flags()\n//-----------------------------------------------------------------------------\nQt::ItemFlags ResetTypesModel::flags(QModelIndex const& index) const\n{\n\tif (!index.isValid())\n    {\n\t\treturn Qt::NoItemFlags;\n\t}\n\n\treturn Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsEditable;\n}\n\n//-----------------------------------------------------------------------------\n// Function: ResetTypesModel::headerData()\n//-----------------------------------------------------------------------------\nQVariant ResetTypesModel::headerData(int section, Qt::Orientation orientation, int role) const\n{\n\tif (orientation != Qt::Horizontal || role != Qt::DisplayRole)\n    {\n        return QVariant();\n    }\n\n    if (section == ResetTypeColumns::NAME_COLUMN)\n    {\n        return tr(\"Name\");\n    }\n    else if (section == ResetTypeColumns::DISPLAY_NAME_COLUMN)\n    {\n        return tr(\"Display\\nname\");\n    }\n    else if (section == ResetTypeColumns::SHORT_DESCRIPTION_COLUMN)\n    {\n        return tr(\"Short\\ndescription\");\n    }\n    else if (section == ResetTypeColumns::DESCRIPTION_COLUMN)\n    {\n        return tr(\"Description\");\n    }\n    else\n    {\n        return QVariant();\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: ResetTypesModel::data()\n//-----------------------------------------------------------------------------\nQVariant ResetTypesModel::data(QModelIndex const& index, int role) const\n{\n\tif (!index.isValid() || index.row() < 0 || index.row() >= resetTypes_->size())\n    {\n\t\treturn QVariant();\n\t}\n    \n    QSharedPointer<ResetType> resetType = resetTypes_->at(index.row());\n\n\tif (role == Qt::DisplayRole)\n    {\n        if (index.column() == ResetTypeColumns::NAME_COLUMN)\n        {\n            return resetType->name();\n        }\n        else if (index.column() == ResetTypeColumns::DISPLAY_NAME_COLUMN)\n        {\n            return resetType->displayName();\n        }\n        else if (index.column() == ResetTypeColumns::SHORT_DESCRIPTION_COLUMN)\n        {\n            return resetType->shortDescription();\n        }\n        else if (index.column() == ResetTypeColumns::DESCRIPTION_COLUMN)\n        {\n            return resetType->description();\n        }\n        else\n        {\n            return QVariant();\n        }\n\t}\n    else if (role == Qt::ForegroundRole)\n    {\n        if (index.column() == ResetTypeColumns::NAME_COLUMN &&\n            !validator_->singleResetTypeIsValid(resetType, resetTypes_))\n        {\n            return KactusColors::ERROR;\n        }\n        else\n        {\n           return KactusColors::REGULAR_TEXT;\n        }\n    }\n    else if (role == Qt::BackgroundRole)\n    {\n        if (index.column() == ResetTypeColumns::NAME_COLUMN)\n        {\n            return KactusColors::MANDATORY_FIELD;\n        }\n        else\n        {\n            return KactusColors::REGULAR_FIELD;\n        }\n    }\n    else\n    {\n        return QVariant();\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: ResetTypesModel::setData()\n//-----------------------------------------------------------------------------\nbool ResetTypesModel::setData(QModelIndex const& index, QVariant const& value, int role)\n{\n\tif (!index.isValid() || index.row() < 0 || index.row() >= resetTypes_->size())\n    {\n\t\treturn false;\n\t}\n\n    QSharedPointer<ResetType> resetType = resetTypes_->at(index.row());\n\n    if (role == Qt::EditRole)\n    {\n        if (index.column() == ResetTypeColumns::NAME_COLUMN)\n        {\n            resetType->setName(value.toString());\n        }\n        else if (index.column() == ResetTypeColumns::DISPLAY_NAME_COLUMN)\n        {\n            resetType->setDisplayName(value.toString());\n        }\n        else if (index.column() == ResetTypeColumns::SHORT_DESCRIPTION_COLUMN)\n        {\n            resetType->setShortDescription(value.toString());\n        }\n        else if (index.column() == ResetTypeColumns::DESCRIPTION_COLUMN)\n        {\n            resetType->setDescription(value.toString());\n        }\n        else\n        {\n            return false;\n        }\n\n\t\temit dataChanged(index, index);\n\t\temit contentChanged();\n\t\treturn true;\n\t}\n    else\n    {\n\t\treturn false;\n\t}\n}\n\n//-----------------------------------------------------------------------------\n// Function: ResetTypesModel::onAddItem()\n//-----------------------------------------------------------------------------\nvoid ResetTypesModel::onAddItem(QModelIndex const& index)\n{\n\tint row = resetTypes_->size();\n\n\tif (index.isValid())\n    {\n\t\trow = index.row();\n\t}\n\n\tbeginInsertRows(QModelIndex(), row, row);\n\tresetTypes_->insert(row, QSharedPointer<ResetType>(new ResetType()));\n\tendInsertRows();\n\n\temit contentChanged();\n}\n\n//-----------------------------------------------------------------------------\n// Function: ResetTypesModel::onRemoveItem()\n//-----------------------------------------------------------------------------\nvoid ResetTypesModel::onRemoveItem(QModelIndex const& index)\n{\n\tif (!index.isValid() || index.row() < 0 || index.row() >= resetTypes_->size())\n    {\n\t\treturn;\n\t}\n\n\t// remove the specified item\n\tbeginRemoveRows(QModelIndex(), index.row(), index.row());\n\tresetTypes_->removeAt(index.row());\n\tendRemoveRows();\n\n    emit contentChanged();\n}\n"
  },
  {
    "path": "editors/ComponentEditor/resetTypes/ResetTypesModel.h",
    "content": "//-----------------------------------------------------------------------------\n// File: ResetTypesModel.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 04.01.2019\n//\n// Description:\n//! Model for reset type elements within a component.\n//-----------------------------------------------------------------------------\n\n#ifndef RESETTYPESMODEL_H\n#define RESETTYPESMODEL_H\n\n#include <QAbstractTableModel>\n#include <QSharedPointer>\n#include <QList>\n\nclass Component;\nclass ComponentValidator;\nclass ResetType;\n\n//-----------------------------------------------------------------------------\n//! Model for reset type elements within a component.\n//-----------------------------------------------------------------------------\nclass ResetTypesModel : public QAbstractTableModel\n{\n\tQ_OBJECT\n\npublic:\n\n\t/*!\n     *  The constructor\n\t *\n\t *    @param [in] component   The component being edited.\n     *    @param [in] validator   The validator for cpus.\n\t *    @param [in] parent      The owner of this model.\n\t */\n\tResetTypesModel(QSharedPointer<Component> component, QSharedPointer<ComponentValidator> validator, QObject* parent);\n\t\n\t/*!\n     *  The destructor.\n     */\n    virtual ~ResetTypesModel() = default;\n\n    //! No copying\n    ResetTypesModel(const ResetTypesModel& other) = delete;\n    ResetTypesModel& operator=(const ResetTypesModel& other) = delete;\n\n\t/*!\n     *  Get the number of rows an item contains.\n\t *\n\t *    @param [in] parent  Identifies the parent that's row count is requested.\n\t *\n\t *    @return Number of rows the item has.\n     */\n\tint rowCount(const QModelIndex& parent = QModelIndex()) const final;\n\n\t/*!\n     *  Get the number of columns the item has to be displayed.\n\t *\n\t *    @param [in] parent  Identifies the parent that's column count is requested.\n\t *\n\t *    @return The number of columns to be displayed.\n     */\n\tint columnCount(const QModelIndex& parent = QModelIndex()) const final;\n\n\t/*!\n     *  Get the item flags that defines the possible operations for the item.\n\t *\n\t *    @param [in] index   Model index that identifies the item.\n\t *\n\t *    @return Qt::ItemFlags specify the possible operations for the item.\n     */\n\tQt::ItemFlags flags(const QModelIndex& index) const final;\n\n\t/*!\n     *  Get the header data for specified header.\n\t *\n\t *    @param [in] section         The section specifies the row/column number for the header.\n\t *    @param [in] orientation     Specified if horizontal or vertical header is wanted.\n\t *    @param [in] role Specifies  the type of the requested data.\n\t *\n\t *    @return QVariant Contains the requested data.\n     */\n\tQVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const final;\n\n\t/*!\n     *  Get the data for specified item.\n\t *\n\t *    @param [in] index   Specifies the item that's data is requested.\n\t *    @param [in] role    The role that defines what kind of data is requested.\n\t *\n\t *    @return QVariant Contains the data for the item.\n     */\n\tQVariant data(QModelIndex const& index, int role = Qt::DisplayRole) const final;\n\n\t/*!\n     *  Save the data to the model for specified item\n\t *\n\t *    @param [in] index   The model index of the item that's data is to be saved.\n\t *    @param [in] value   The data that is to be saved.\n\t *    @param [in] role    The role specifies what kind of data should be saved.\n\t *\n\t *    @return True if saving was successful.\n     */\n\tbool setData(QModelIndex const& index, QVariant const& value, int role = Qt::EditRole) final;\n\npublic slots:\n\n\t/*!\n     *  Add a new item to the given index.\n\t *\n\t *    @param [in] index The index identifying the position for new item.\n     */\n\tvirtual void onAddItem(const QModelIndex& index);\n\n\t/*!\n     *  Remove the item in the given index.\n\t *\n\t *    @param [in] index The index identifying the item to remove.\n     */\n\tvirtual void onRemoveItem(const QModelIndex& index);\n\nsignals:\n\n\t/*!\n     *  Emitted when the contents of the model change.\n     */\n\tvoid contentChanged();\n\nprivate:\n\n\t//! The component being edited.\n\tQSharedPointer<Component> component_;\n\n\t//! Contains the reset types being edited.\n    QSharedPointer<QList<QSharedPointer<ResetType> > > resetTypes_;\n\n    //! Validator for component items.\n    QSharedPointer<ComponentValidator> validator_;\n};\n\n#endif // RESETTYPESMODEL_H\n"
  },
  {
    "path": "editors/ComponentEditor/software/PropertyValueDelegate.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: PropertyValueDelegate.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Joni-Matti Maatta\r\n// Date: 16.4.2012\r\n//\r\n// Description:\r\n// Delegate for property values.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"PropertyValueDelegate.h\"\r\n\r\n#include <IPXACTmodels/kactusExtensions/ComProperty.h>\r\n\r\n#include <QComboBox>\r\n#include <QLineEdit>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PropertyValueDelegate::PropertyValueDelegate()\r\n//-----------------------------------------------------------------------------\r\nPropertyValueDelegate::PropertyValueDelegate(QObject* parent):\r\nQStyledItemDelegate(parent),\r\nallowedProperties_()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PropertyValueDelegate::~PropertyValueDelegate()\r\n//-----------------------------------------------------------------------------\r\nPropertyValueDelegate::~PropertyValueDelegate()\r\n{\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PropertyValueDelegate::setAllowedProperties()\r\n//-----------------------------------------------------------------------------\r\nvoid PropertyValueDelegate::setAllowedProperties(QList< QSharedPointer<ComProperty> > properties)\r\n{\r\n    allowedProperties_ = properties;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PropertyValueDelegate::createEditor()\r\n//-----------------------------------------------------------------------------\r\nQWidget* PropertyValueDelegate::createEditor(QWidget* parent, QStyleOptionViewItem const& option,\r\n    QModelIndex const& index) const\r\n{\r\n    if (index.column() == 0)\r\n    {\r\n        QComboBox* box = new QComboBox(parent);\r\n\r\n        foreach (QSharedPointer<ComProperty const> comProperty, allowedProperties_)\r\n        {\r\n            if (!comProperty->isRequired())\r\n            {\r\n                box->addItem(comProperty->name());\r\n            }\r\n        }\r\n\r\n        return box;\r\n    }\r\n\r\n    else if (index.column() == 1)\r\n    {\r\n        QLineEdit* line = new QLineEdit(parent);\r\n        connect(line, SIGNAL(editingFinished()), this, SLOT(commitAndCloseEditor()), Qt::UniqueConnection);\r\n        return line;\r\n    }\r\n\r\n    else\r\n    {\r\n        return QStyledItemDelegate::createEditor(parent, option, index);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PropertyValueDelegate::setEditorData()\r\n//-----------------------------------------------------------------------------\r\nvoid PropertyValueDelegate::setEditorData(QWidget* editor, QModelIndex const& index) const\r\n{\r\n    if (index.column() == 0)\r\n    {\r\n        QComboBox* box = qobject_cast<QComboBox*>(editor);\r\n        Q_ASSERT_X(box, \"PropertyValueDelegate::setEditorData\", \"Type conversion failed for QComboBox\");\r\n\r\n        QString text = index.data(Qt::DisplayRole).toString();\r\n        box->setCurrentIndex(box->findText(text));\r\n        return;\r\n    }\r\n\r\n    else if (index.column() == 1)\r\n    {\r\n        QLineEdit* line = qobject_cast<QLineEdit*>(editor);\r\n        Q_ASSERT_X(line, \"PropertyValueDelegate::setEditorData\", \"Type conversion failed for QLineEdit\");\r\n\r\n        QString text = index.data(Qt::DisplayRole).toString();\r\n        line->setText(text);\r\n        return;\r\n    }\r\n\r\n    else\r\n    {\r\n        QStyledItemDelegate::setEditorData(editor, index);\r\n        return;\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PropertyValueDelegate::setModelData()\r\n//-----------------------------------------------------------------------------\r\nvoid PropertyValueDelegate::setModelData(QWidget* editor, QAbstractItemModel* model, \r\n    QModelIndex const& index) const\r\n{\r\n    if (index.column() == 0)\r\n    {\r\n        QComboBox* box = qobject_cast<QComboBox*>(editor);\r\n        Q_ASSERT_X(box, \"PropertyValueDelegate::setEditorData\", \"Type conversion failed for QComboBox\");\r\n\r\n        QString text = box->currentText();\r\n        model->setData(index, text, Qt::EditRole);\r\n    }\r\n    else if (index.column() == 1)\r\n    {\r\n        QLineEdit* line = qobject_cast<QLineEdit*>(editor);\r\n        Q_ASSERT_X(line, \"PropertyValueDelegate::setEditorData\", \"Type conversion failed for QLineEdit\");\r\n\r\n        QString text = line->text();\r\n        model->setData(index, text, Qt::EditRole);\r\n    }\r\n    else\r\n    {\r\n        QStyledItemDelegate::setModelData(editor, model, index);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PropertyValueDelegate::commitAndCloseEditor()\r\n//-----------------------------------------------------------------------------\r\nvoid PropertyValueDelegate::commitAndCloseEditor()\r\n{\r\n    QLineEdit* lineEdit = qobject_cast<QLineEdit*>(sender());\r\n\r\n    if (lineEdit != 0)\r\n    {\r\n        emit commitData(lineEdit);\r\n        emit closeEditor(lineEdit);\r\n    }\r\n}\r\n"
  },
  {
    "path": "editors/ComponentEditor/software/PropertyValueDelegate.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: PropertyValueDelegate.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Joni-Matti Maatta\r\n// Date: 16.4.2012\r\n//\r\n// Description:\r\n// Delegate for property values.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef PROPERTYVALUEDELEGATE_H\r\n#define PROPERTYVALUEDELEGATE_H\r\n\r\n#include <QStyledItemDelegate>\r\n#include <QList>\r\n#include <QSharedPointer>\r\n\r\nclass ComProperty;\r\n\r\n//-----------------------------------------------------------------------------\r\n// Delegate for property values.\r\n//-----------------------------------------------------------------------------\r\nclass PropertyValueDelegate : public QStyledItemDelegate\r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\t/*!\r\n     *  Constructor.\r\n     *\r\n     *    @param [in] parent The parent object.\r\n     */\r\n\tPropertyValueDelegate(QObject* parent = 0);\r\n\r\n\t/*!\r\n     *  Destructor.\r\n     */\r\n\tvirtual ~PropertyValueDelegate();\r\n\r\n    /*!\r\n     *  Sets the allowed properties.\r\n     *\r\n     *    @param [in] properties The list of allowed properties.\r\n     */\r\n    void setAllowedProperties(QList< QSharedPointer<ComProperty> > properties);\r\n\r\n\t/*!\r\n     *  Creates a new editor for the given item.\r\n\t *\r\n\t *    @param [in] parent  The parent widget.\r\n     *    @param [in] option  Contains options for the editor.\r\n     *    @param [in] index   Model index identifying the item.\r\n\t *\r\n\t *    @return Pointer to the editor to be used to edit the item.\r\n\t */\r\n\tvirtual QWidget* createEditor(QWidget* parent, QStyleOptionViewItem const& option, \r\n\t\t                          QModelIndex const& index) const;\r\n\r\n\t/*!\r\n     *  Sets the data for the editor.\r\n\t *\r\n\t *    @param [in] editor  Pointer to the editor where the data is to be set.\r\n\t *    @param [in] index   Model index identifying the item that's data is to be set.\r\n\t */\r\n\tvirtual void setEditorData(QWidget* editor, QModelIndex const& index) const;\r\n\r\n\t/*!\r\n     *  Saves the data from the editor to the model.\r\n\t *\r\n\t *    @param [in] editor  Pointer to the editor that contains the data to store.\r\n\t *    @param [in] model   Model that contains the data structure where data is to be saved to.\r\n\t *    @param [in] index   Model index identifying the item that's data is to be saved.\r\n\t */\r\n\tvirtual void setModelData(QWidget* editor, QAbstractItemModel* model, \r\n\t\t                      QModelIndex const& index) const;\r\n\r\nprivate slots:\r\n\t/*! \r\n     *  Commits the data from the sending editor and close the editor.\r\n\t */\r\n\tvoid commitAndCloseEditor();\r\n\r\nprivate:\r\n    // Disable copying.\r\n    PropertyValueDelegate(PropertyValueDelegate const& rhs);\r\n    PropertyValueDelegate& operator=(PropertyValueDelegate const& rhs);\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! The allowed properties.\r\n    QList< QSharedPointer<ComProperty> > allowedProperties_;\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n\r\n#endif // PROPERTYVALUEDELEGATE_H\r\n"
  },
  {
    "path": "editors/ComponentEditor/software/PropertyValueEditor.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: PropertyValueEditor.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Joni-Matti Maatta\r\n// Date: 16.4.2012\r\n//\r\n// Description:\r\n// Editor for property values.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"PropertyValueEditor.h\"\r\n\r\n#include <QHBoxLayout>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PropertyValueEditor::PropertyValueEditor()\r\n//-----------------------------------------------------------------------------\r\nPropertyValueEditor::PropertyValueEditor(QWidget* parent)\r\n    : QGroupBox(tr(\"Property values\"), parent),\r\n      view_(this),\r\n      delegate_(this),\r\n      filter_(this),\r\n      model_(this)\r\n{\r\n\r\n    // Set the model source and other options for the view.\r\n    filter_.setSourceModel(&model_);\r\n\r\n    view_.setModel(&filter_);\r\n    view_.setSortingEnabled(true);\r\n    view_.setItemsDraggable(false);\r\n    view_.setItemDelegate(&delegate_);\r\n\r\n    setFlat(true);\r\n\r\n    QHBoxLayout* layout = new QHBoxLayout(this);\r\n    layout->addWidget(&view_);\r\n\r\n    connect(&model_, SIGNAL(contentChanged()), this, SIGNAL(contentChanged()), Qt::UniqueConnection);\r\n    connect(&view_, SIGNAL(addItem(const QModelIndex&)),\r\n            &model_, SLOT(onAddItem(const QModelIndex&)), Qt::UniqueConnection);\r\n    connect(&view_, SIGNAL(removeItem(const QModelIndex&)),\r\n            &model_, SLOT(onRemoveItem(const QModelIndex&)), Qt::UniqueConnection);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PropertyValueEditor::~PropertyValueEditor()\r\n//-----------------------------------------------------------------------------\r\nPropertyValueEditor::~PropertyValueEditor()\r\n{\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PropertyValueEditor::setAllowedProperties()\r\n//-----------------------------------------------------------------------------\r\nvoid PropertyValueEditor::setAllowedProperties(QList< QSharedPointer<ComProperty> > const& properties)\r\n{\r\n    delegate_.setAllowedProperties(properties);\r\n    model_.setAllowedProperties(properties);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PropertyValueEditor::setData()\r\n//-----------------------------------------------------------------------------\r\nvoid PropertyValueEditor::setData(QMap<QString, QString> const& propertyValues)\r\n{\r\n    model_.setData(propertyValues);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PropertyValueEditor::getData()\r\n//-----------------------------------------------------------------------------\r\nQMap<QString, QString> PropertyValueEditor::getData() const\r\n{\r\n    return model_.getData();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PropertyValueEditor::setLock()\r\n//-----------------------------------------------------------------------------\r\nvoid PropertyValueEditor::setLock(bool locked)\r\n{\r\n    model_.setLock(locked);\r\n}\r\n"
  },
  {
    "path": "editors/ComponentEditor/software/PropertyValueEditor.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: PropertyValueEditor.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Joni-Matti Maatta\r\n// Date: 16.4.2012\r\n//\r\n// Description:\r\n// Editor for property values.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef PROPERTYVALUEEDITOR_H\r\n#define PROPERTYVALUEEDITOR_H\r\n\r\n#include \"PropertyValueModel.h\"\r\n\r\n#include \"PropertyValueDelegate.h\"\r\n\r\n#include <common/views/EditableTableView/editabletableview.h>\r\n\r\n#include <QGroupBox>\r\n#include <QSortFilterProxyModel>\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Property value editor.\r\n//-----------------------------------------------------------------------------\r\nclass PropertyValueEditor : public QGroupBox\r\n{\r\n    Q_OBJECT\r\n\r\npublic:\r\n    /*!\r\n     *  Constructor.\r\n     *\r\n     *    @param [in] parent The parent widget.\r\n     */\r\n    PropertyValueEditor(QWidget* parent);\r\n\r\n    /*!\r\n     *  Destructor.\r\n     */\r\n    ~PropertyValueEditor();\r\n\r\n    /*!\r\n     *  Sets the allowed properties.\r\n     *\r\n     *    @param [in] properties The list of allowed properties.\r\n     */\r\n    void setAllowedProperties(QList< QSharedPointer<ComProperty> > const& properties);\r\n\r\n    /*!\r\n     *  Returns the edited data.\r\n     */\r\n    QMap<QString, QString> getData() const;\r\n\r\n    //! Disables editing while still enabling scrolling.\r\n    void setLock(bool locked);\r\n\r\npublic slots:\r\n    /*!\r\n     *  Sets the data for editing.\r\n     *\r\n     *    @param [in] propertyValue The property values.\r\n     */\r\n    void setData(QMap<QString, QString> const& propertyValues);\r\n\r\nsignals:\r\n    //! Emitted when contents of the editor changes.\r\n    void contentChanged();\r\n\r\nprivate:\r\n    // Disable copying.\r\n    PropertyValueEditor(PropertyValueEditor const& rhs);\r\n    PropertyValueEditor& operator=(PropertyValueEditor const& rhs);\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! The table view widget.\r\n    EditableTableView view_;\r\n\r\n    //! The item delegate.\r\n    PropertyValueDelegate delegate_;\r\n\r\n    //! \\brief The filter to do the sorting of items to display.\r\n    QSortFilterProxyModel filter_;\r\n\r\n    //! \\brief The model to edit the configurable elements of a component instance.\r\n    PropertyValueModel model_;\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n\r\n#endif // PROPERTYVALUEEDITOR_H\r\n"
  },
  {
    "path": "editors/ComponentEditor/software/PropertyValueModel.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: PropertyValueModel.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Joni-Matti Maatta\r\n// Date: 16.4.2012\r\n//\r\n// Description:\r\n// Model for property values.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"PropertyValueModel.h\"\r\n\r\n#include <IPXACTmodels/kactusExtensions/ComProperty.h>\r\n\r\n#include <common/KactusColors.h>\r\n\r\n#include <QFont>\r\n#include <QRegularExpression>\r\n\r\nQString const PropertyValueModel::IP_ADDRESS_REGEX(\"^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\\\.\"\r\n    \"(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\\\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\\\.\"\r\n    \"(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$\");\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PropertyValueModel::PropertyValueModel()\r\n//-----------------------------------------------------------------------------\r\nPropertyValueModel::PropertyValueModel(QObject *parent): QAbstractTableModel(parent)\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PropertyValueModel::setAllowedProperties()\r\n//-----------------------------------------------------------------------------\r\nvoid PropertyValueModel::setAllowedProperties(QList< QSharedPointer<ComProperty> > properties)\r\n{\r\n    beginResetModel();\r\n\r\n    allowedProperties_ = properties;\r\n\r\n    // Check that at least all required properties are found in the values.\r\n    for (QSharedPointer<ComProperty const> comProperty : properties)\r\n    {\r\n        if (comProperty->isRequired())\r\n        {\r\n            bool foundInTable = false;\r\n\r\n            for (int i = 0; i < table_.size() && !foundInTable; i++)\r\n            {\r\n                if (table_.at(i).first.compare(comProperty->name()) == 0)\r\n                {\r\n                    foundInTable = true;\r\n                }\r\n            }\r\n\r\n            if (!foundInTable)\r\n            {\r\n                table_.append(NameValuePair(comProperty->name(), comProperty->getDefaultValue()));\r\n            }\r\n        }\r\n    }\r\n\r\n    endResetModel();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PropertyValueModel::setData()\r\n//-----------------------------------------------------------------------------\r\nvoid PropertyValueModel::setData(QMap<QString, QString> const& propertyValues)\r\n{\r\n    beginResetModel();\r\n\r\n    table_.clear();\r\n\r\n    QMapIterator<QString, QString> iter(propertyValues);\r\n    while (iter.hasNext())\r\n    {\r\n        iter.next();\r\n        table_.append(NameValuePair(iter.key(), iter.value()));\r\n    }\r\n\r\n    endResetModel();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PropertyValueModel::getData()\r\n//-----------------------------------------------------------------------------\r\nQMap<QString, QString> PropertyValueModel::getData() const\r\n{\r\n    QMap<QString, QString> values;\r\n\r\n    for (NameValuePair const& pair : table_)\r\n    {\r\n        values[pair.first] = pair.second;\r\n    }\r\n\r\n    return values;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PropertyValueModel::setLock()\r\n//-----------------------------------------------------------------------------\r\nvoid PropertyValueModel::setLock(bool locked)\r\n{\r\n    locked_ = locked;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PropertyValueModel::rowCount()\r\n//-----------------------------------------------------------------------------\r\nint PropertyValueModel::rowCount(QModelIndex const& parent) const\r\n{\r\n    if (parent.isValid())\r\n    {\r\n        return 0;\r\n    }\r\n\r\n    return table_.size();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PropertyValueModel::columnCount()\r\n//-----------------------------------------------------------------------------\r\nint PropertyValueModel::columnCount(QModelIndex const& parent) const\r\n{\r\n    if (parent.isValid())\r\n    {\r\n        return 0;\r\n    }\r\n\r\n    return 2;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PropertyValueModel::data()\r\n//-----------------------------------------------------------------------------\r\nQVariant PropertyValueModel::data(QModelIndex const& index, int role) const\r\n{\r\n    if (!index.isValid() || index.row() < 0 || index.row() >= table_.size())\r\n    {\r\n        return QVariant();\r\n    }\r\n\r\n    if (role == Qt::DisplayRole)\r\n    {\r\n        if (index.column() ==  0)\r\n        {\r\n            return table_.at(index.row()).first;\r\n        }\r\n        else if (index.column() == 1)\r\n        {\r\n            return table_.at(index.row()).second;\r\n        }\r\n        else\r\n        {\r\n            return QVariant();\r\n        }\r\n    }\r\n\r\n    else if (role == Qt::FontRole && index.column() == 0)\r\n    {\r\n        for (QSharedPointer<ComProperty const> comProperty : allowedProperties_)\r\n        {\r\n            if (comProperty->name() == table_.at(index.row()).first && comProperty->isRequired())\r\n            {\r\n                QFont font;\r\n                font.setBold(true);\r\n                return font;\r\n            }\r\n        }\r\n\r\n        return QVariant();\r\n    }\r\n\r\n    else if (role == Qt::ForegroundRole)\r\n    {\r\n        if (index.column() == 0)\r\n        {\r\n            // Check if the property value is found from the list of allowed properties.\r\n            for (QSharedPointer<ComProperty const> comProperty : allowedProperties_)\r\n            {\r\n                if (comProperty->name() == table_.at(index.row()).first)\r\n                {\r\n                    return KactusColors::REGULAR_TEXT;\r\n                }\r\n            }\r\n\r\n            // Use red to indicate property values that are not found in the allowed properties.\r\n            return KactusColors::ERROR;\r\n        }\r\n\r\n        else if (index.column() == 1)\r\n        {\r\n            // Validate the property value against the data type defined in the property definition.\r\n            for (QSharedPointer<ComProperty const> comProperty : allowedProperties_)\r\n            {\r\n                // Check if we found a match.\r\n                if (comProperty->name() == table_.at(index.row()).first)\r\n                {\r\n                    QString const& value = table_.at(index.row()).second;\r\n                    bool ok = true;\r\n\r\n                    if (comProperty->getType() == QLatin1String(\"integer\"))\r\n                    {\r\n                        value.toInt(&ok);\r\n                    }\r\n                    else if (comProperty->getType() == QLatin1String(\"ip_address\"))\r\n                    {\r\n                        ok = value.contains(QRegularExpression(IP_ADDRESS_REGEX));\r\n                    }\r\n\r\n                    if (ok)\r\n                    {\r\n                        return KactusColors::REGULAR_TEXT;\r\n                    }\r\n                    else\r\n                    {\r\n                        return KactusColors::ERROR;\r\n                    }\r\n                }\r\n            }\r\n\r\n            return KactusColors::REGULAR_TEXT;\r\n        }\r\n        else\r\n        {\r\n            return KactusColors::REGULAR_TEXT;\r\n        }\r\n    }\r\n\r\n    else\r\n    {\r\n        return QVariant();\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PropertyValueModel::headerData()\r\n//-----------------------------------------------------------------------------\r\nQVariant PropertyValueModel::headerData(int section, Qt::Orientation orientation, int role) const\r\n{\r\n    if (orientation == Qt::Horizontal && role == Qt::DisplayRole)\r\n    {\r\n        if (section == 0)\r\n        {\r\n            return tr(\"Name\");\r\n        }\r\n        else if (section == 1)\r\n        {\r\n            return tr(\"Value\");\r\n        }\r\n    }\r\n       \r\n    return QVariant();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PropertyValueModel::flags()\r\n//-----------------------------------------------------------------------------\r\nQt::ItemFlags PropertyValueModel::flags(QModelIndex const& index) const\r\n{\r\n    if (!index.isValid())\r\n    {\r\n        return Qt::NoItemFlags;\r\n    }\r\n\r\n    if (index.column() == 0)\r\n    {\r\n        QString const& propertyName = table_.at(index.row()).first;\r\n\r\n        for (QSharedPointer<ComProperty const> comProperty : allowedProperties_)\r\n        {\r\n            if (comProperty->name().compare(propertyName) == 0 && comProperty->isRequired())\r\n            {\r\n                return Qt::ItemIsSelectable | Qt::ItemIsEnabled;\r\n            }\r\n        }\r\n    }\r\n\r\n    Qt::ItemFlags indexFlags = Qt::ItemIsSelectable | Qt::ItemIsEnabled;\r\n    if (!locked_)\r\n    {\r\n        indexFlags |= Qt::ItemIsEditable;\r\n    }\r\n\r\n    return indexFlags;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PropertyValueModel::setData()\r\n//-----------------------------------------------------------------------------\r\nbool PropertyValueModel::setData(QModelIndex const& index, QVariant const& value, int role)\r\n{\r\n    if (locked_ || !index.isValid() || index.row() < 0 || index.row() >= table_.size() || role != Qt::EditRole)\r\n    {\r\n        return false;\r\n    }\r\n\r\n    if (index.column() == 0)\r\n    {\r\n        table_[index.row()].first = value.toString();\r\n    }\r\n    else if (index.column() == 1)\r\n    {\r\n        table_[index.row()].second = value.toString();\r\n    }\r\n    else \r\n    {\r\n        return false;\r\n    }\r\n\r\n    emit dataChanged(index, index);\r\n    emit contentChanged();\r\n    return true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PropertyValueModel::onAddItem()\r\n//-----------------------------------------------------------------------------\r\nvoid PropertyValueModel::onAddItem(QModelIndex const& index)\r\n{\r\n    int row = table_.size();\r\n\r\n    // if the index is valid then add the item to the correct position\r\n    if (index.isValid())\r\n    {\r\n        row = index.row();\r\n    }\r\n\r\n    NameValuePair element(QString(\"\"), QString(\"\"));\r\n\r\n    if (!table_.contains(element))\r\n    {\r\n        beginInsertRows(QModelIndex(), row, row);\r\n        table_.insert(row, element);\r\n        endInsertRows();\r\n\r\n        // tell also parent widget that contents have been changed\r\n        emit contentChanged();\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PropertyValueModel::onRemoveItem()\r\n//-----------------------------------------------------------------------------\r\nvoid PropertyValueModel::onRemoveItem(QModelIndex const& index)\r\n{\r\n    if (!index.isValid() || index.row() < 0 || index.row() >= table_.size())\r\n    {\r\n        return;\r\n    }\r\n\r\n    // Required property values cannot be deleted.\r\n    for (QSharedPointer<ComProperty const> comProperty : allowedProperties_)\r\n    {\r\n        if (comProperty->name() == table_.at(index.row()).first && comProperty->isRequired())\r\n        {\r\n            return;\r\n        }\r\n    }\r\n\r\n    // remove the indexed configurable element\r\n    beginRemoveRows(QModelIndex(), index.row(), index.row());\r\n    table_.removeAt(index.row());\r\n    endRemoveRows();\r\n\r\n    emit contentChanged();\r\n}\r\n"
  },
  {
    "path": "editors/ComponentEditor/software/PropertyValueModel.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: PropertyValueModel.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Joni-Matti Maatta\r\n// Date: 16.4.2012\r\n//\r\n// Description:\r\n// Model for property values.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef PROPERTYVALUEMODEL_H\r\n#define PROPERTYVALUEMODEL_H\r\n\r\n#include <QAbstractTableModel>\r\n#include <QMap>\r\n#include <QList>\r\n#include <QString>\r\n#include <QSharedPointer>\r\n\r\nclass ComProperty;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! PropertyValueModel class.\r\n//-----------------------------------------------------------------------------\r\nclass PropertyValueModel : public QAbstractTableModel\r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n    /*!\r\n     *  Constructor.\r\n     *\r\n     *    @param [in] parent The parent object.\r\n\t */\r\n\tPropertyValueModel(QObject *parent);\r\n\r\n\t/*!\r\n     *  Destructor.\r\n     */\r\n\tvirtual ~PropertyValueModel() = default;\r\n\r\n    // Disable copying.\r\n    PropertyValueModel(PropertyValueModel const& rhs) = delete;\r\n    PropertyValueModel& operator=(PropertyValueModel const& rhs) = delete;\r\n\r\n    /*!\r\n     *  Synchronizes the model to match with the given list of allowed properties.\r\n     *\r\n     *    @param [in] properties The list of allowed properties.\r\n     */\r\n    void setAllowedProperties(QList< QSharedPointer<ComProperty> > properties);\r\n\r\n    /*!\r\n     *  Sets the data for editing.\r\n     *\r\n     *    @param [in] propertyValue The property values.\r\n     */\r\n    void setData(QMap<QString, QString> const& propertyValues);\r\n\r\n    /*!\r\n     *  Returns the edited data.\r\n     */\r\n    QMap<QString, QString> getData() const;\r\n\r\n    /*!\r\n     *  Disables/enables editing.\r\n     *\r\n     *    @param [in] locked   True if model is locked i.e. disabled, otherwise false.\r\n     */\r\n    void setLock(bool locked);\r\n\r\n    /*!\r\n     *  Returns the number of rows in the model.\r\n\t *\r\n\t *    @param [in] parent Model index of the parent of the item. Must be invalid\r\n\t *                         because this is not hierarchical model.\r\n\t *\r\n\t *    @return Number of rows currently in the model.\r\n\t */\r\n\tint rowCount(QModelIndex const& parent = QModelIndex()) const final;\r\n\r\n\t/*! \r\n     *  Returns the number of columns in the model.\r\n\t *\r\n\t *    @param [in] parent Model index of the parent of the item. Must be invalid\r\n\t *                         because this is not hierarchical model.\r\n\t *\r\n\t *    @return Always returns 2.\r\n\t */\r\n\tint columnCount(QModelIndex const& parent = QModelIndex()) const final;\r\n\r\n\t/*!\r\n     *  Returns the data for the specified item for specified role.\r\n\t *\r\n\t *    @param [in] index  Identifies the item that's data is wanted.\r\n\t *    @param [in] role   Specifies what kind of data is wanted\r\n\t *\r\n\t *    @return QVariant containing the data.\r\n\t */\r\n\tQVariant data(QModelIndex const& index, int role = Qt::DisplayRole) const final;\r\n\r\n\t/*!\r\n     *  Returns the data for the headers.\r\n\t *\r\n\t *    @param [in] section      The column that's header is wanted\r\n\t *    @param [in] orientation  Only Qt::Horizontal is supported\r\n\t *    @param [in] role         Specified the type of data that is wanted.\r\n\t *\r\n\t *    @return QVariant containing the header data.\r\n\t */\r\n\tQVariant headerData(int section, Qt::Orientation orientation, \r\n\t\t                        int role = Qt::DisplayRole) const final;\r\n\r\n\t/*!\r\n     *  Returns information on how specified item can be handled.\r\n\t *\r\n\t *    @param [in] index Specifies the item that's flags are wanted.\r\n\t *\r\n\t *    @return Item flags that define how object can be handled.\r\n\t */\r\n\tQt::ItemFlags flags(QModelIndex const& index) const final;\r\n\r\n\t/*!\r\n     *  Returns the data for specified item.\r\n\t *\r\n\t *    @param [in] index  Specifies the item that's data is modified\r\n\t *    @param [in] value  The value to be set.\r\n\t *    @param [in] role   The role that is trying to modify the data. Only Qt::EditRole is supported.\r\n\t *\r\n\t *    @return True if data was successfully set.\r\n\t */\r\n\tbool setData(QModelIndex const& index, QVariant const& value, int role = Qt::EditRole) final;\r\n\r\npublic slots:\r\n    void onAddItem(QModelIndex const& index);\r\n    void onRemoveItem(QModelIndex const& index );\r\n\r\nsignals:\r\n\t//! Emitted when contents of the model change.\r\n\tvoid contentChanged();\r\n\r\n\t//! Prints an error message to the user.\r\n\tvoid errorMessage(const QString& msg) const;\r\n\t\r\n\t//! Prints a notification to user.\r\n\tvoid noticeMessage(const QString& msg) const;\r\n\r\nprivate:\r\n\r\n    //! NameValuePair type.\r\n    typedef QPair<QString, QString> NameValuePair;\r\n\r\n    //! IP address regular expression string.\r\n    static QString const IP_ADDRESS_REGEX;\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\t\r\n\t//! The table that is displayed to the user.\r\n\tQList<NameValuePair> table_;\r\n\r\n    //! The list of allowed properties.\r\n    QList< QSharedPointer<ComProperty> > allowedProperties_;\r\n\r\n    //! Lock for disabling editing.\r\n    bool locked_ = false;\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n\r\n#endif // PROPERTYVALUEMODEL_H\r\n"
  },
  {
    "path": "editors/ComponentEditor/software/SWPropertiesEditor.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: SWPropertiesEditor.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Joni-Matti Maatta\r\n// Date: 21.5.2012\r\n//\r\n// Description:\r\n// Editor for SW properties.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"SWPropertiesEditor.h\"\r\n\r\n#include <common/widgets/summaryLabel/summarylabel.h>\r\n\r\n#include <editors/ComDefinitionEditor/ComPropertyDelegate.h>\r\n\r\n#include <KactusAPI/include/LibraryInterface.h>\r\n\r\n#include <IPXACTmodels/Component/Component.h>\r\n#include <IPXACTmodels/kactusExtensions/ComProperty.h>\r\n\r\n#include <QVBoxLayout>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SWPropertiesEditor::SWPropertiesEditor()\r\n//-----------------------------------------------------------------------------\r\nSWPropertiesEditor::SWPropertiesEditor(QSharedPointer<Component> component, LibraryInterface* handler,\r\n    QWidget *parent): \r\nItemEditor(component, handler, parent),\r\n    view_(this),\r\n    filter_(this),\r\n    model_(this)\r\n{\r\n    // Set the model source and other options for the view.\r\n    filter_.setSourceModel(&model_);\r\n\r\n    view_.setModel(&filter_);\r\n\r\n    // Set case-insensitive sorting.\r\n    filter_.setSortCaseSensitivity(Qt::CaseInsensitive);\r\n\r\n\tconst QString componentPath = handler->getDirectoryPath(component->getVlnv());\r\n\tQString defaultPath = QString(\"%1/swPropertiesListing.csv\").arg(componentPath);\r\n\tview_.setDefaultImportExportPath(defaultPath);\r\n\tview_.setAllowImportExport(true);\r\n    view_.setSortingEnabled(true);\r\n    view_.setItemsDraggable(false);\r\n    view_.setItemDelegate(new ComPropertyDelegate(this));\r\n\r\n\t// display a label on top the table\r\n\tSummaryLabel* summaryLabel = new SummaryLabel(tr(\"Software properties\"), this, true);\r\n\r\n    QVBoxLayout* layout = new QVBoxLayout(this);\r\n\tlayout->addWidget(summaryLabel, 0, Qt::AlignCenter);\r\n    layout->addWidget(&view_);\r\n\tlayout->setContentsMargins(0, 0, 0, 0);\r\n\r\n    refresh();\r\n\r\n    connect(&model_, SIGNAL(contentChanged()), this, SLOT(onPropertyChange()), Qt::UniqueConnection);\r\n    connect(&view_, SIGNAL(addItem(const QModelIndex&)),\r\n            &model_, SLOT(onAddItem(const QModelIndex&)), Qt::UniqueConnection);\r\n    connect(&view_, SIGNAL(removeItem(const QModelIndex&)),\r\n            &model_, SLOT(onRemoveItem(const QModelIndex&)), Qt::UniqueConnection);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SWPropertiesEditor::~SWPropertiesEditor()\r\n//-----------------------------------------------------------------------------\r\nSWPropertiesEditor::~SWPropertiesEditor()\r\n{\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SWPropertiesEditor::isValid()\r\n//-----------------------------------------------------------------------------\r\nbool SWPropertiesEditor::isValid() const\r\n{\r\n    return model_.isValid();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SWPropertiesEditor::refresh()\r\n//-----------------------------------------------------------------------------\r\nvoid SWPropertiesEditor::refresh()\r\n{\r\n\t model_.setProperties(component()->getSWProperties());\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SWPropertiesEditor::onPropertyChange()\r\n//-----------------------------------------------------------------------------\r\nvoid SWPropertiesEditor::onPropertyChange()\r\n{\r\n\tQList< QSharedPointer<ComProperty> > properties;\r\n\r\n\tforeach (QSharedPointer<ComProperty> prop, model_.getProperties())\r\n\t{\r\n\t\tproperties.append(QSharedPointer<ComProperty>(new ComProperty(*prop.data())));\r\n\t}\r\n\r\n\tcomponent()->setSWProperties(properties);\r\n\temit contentChanged();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SWPropertiesEditor::showEvent()\r\n//-----------------------------------------------------------------------------\r\nvoid SWPropertiesEditor::showEvent(QShowEvent* event)\r\n{\r\n\tQWidget::showEvent(event);\r\n\temit helpUrlRequested(\"componenteditor/swproperties.html\");\r\n}\r\n"
  },
  {
    "path": "editors/ComponentEditor/software/SWPropertiesEditor.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: SWPropertiesEditor.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Joni-Matti Maatta\r\n// Date: 21.5.2012\r\n//\r\n// Description:\r\n// Editor for SW properties.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef SWPROPERTIESEDITOR_H\r\n#define SWPROPERTIESEDITOR_H\r\n\r\n#include <editors/ComponentEditor/itemeditor.h>\r\n\r\n#include <editors/ComDefinitionEditor/ComPropertyModel.h>\r\n\r\n#include <common/views/EditableTableView/editabletableview.h>\r\n\r\n#include <QSharedPointer>\r\n#include <QShowEvent>\r\n#include <QSortFilterProxyModel>\r\n#include <QString>\r\n\r\nclass Component;\r\nclass LibraryInterface;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Editor for SW properties.\r\n//-----------------------------------------------------------------------------\r\nclass SWPropertiesEditor : public ItemEditor\r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\t\r\n\t/*! The constructor\r\n\t *\r\n\t *    @param [in] component   The component being edited.\r\n\t *    @param [in] handler     The instance managing the library.\r\n\t *    @param [in] parent      The owner of the editor.\r\n\t*/\r\n\tSWPropertiesEditor(QSharedPointer<Component> component,\tLibraryInterface* handler, QWidget *parent = 0);\r\n\t\r\n\t/*!\r\n     *  Destructor.\r\n     */\r\n\tvirtual ~SWPropertiesEditor();\r\n\r\n\t/*!\r\n     *  Checks for the validity of the edited parameters.\r\n\t *\r\n\t *    @return True if all parameters are in valid state.\r\n\t */\r\n\tvirtual bool isValid() const;\r\n\r\n\t/*! Reload the information from the model to the editor.\r\n\t*/\r\n\tvirtual void refresh();\r\n\r\nprotected:\r\n\r\n\t//! Handler for widget's show event.\r\n\tvirtual void showEvent(QShowEvent* event);\r\n\r\nprivate slots:\r\n\r\n\t//! Handler for changes in properties.\r\n\tvoid onPropertyChange();\r\n\r\nprivate:\r\n\t// Disable copying.\r\n\tSWPropertiesEditor(SWPropertiesEditor const& rhs);\r\n\tSWPropertiesEditor& operator=(SWPropertiesEditor const& rhs);\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! The table view widget.\r\n    EditableTableView view_;\r\n\r\n    //! The filter to do the sorting of items to display.\r\n    QSortFilterProxyModel filter_;\r\n\r\n    //! The model to edit the properties.\r\n    ComPropertyModel model_;\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n\r\n#endif // SWPROPERTIESEDITOR_H\r\n"
  },
  {
    "path": "editors/ComponentEditor/software/apiInterface/ApiInterfaceColumns.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ApiInterfaceColumns.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Esko Pekkarinen\r\n// Date: 28.10.2015\r\n//\r\n// Description:\r\n// Common declarations for editing API interfaces.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef API_INTERFACE_COLUMNS_H\r\n#define API_INTERFACE_COLUMNS_H\r\n\r\nnamespace ApiInterfaceColumns\r\n{\r\n    //-----------------------------------------------------------------------------\r\n    // Constants defining which column represents what kind of information.\r\n    //-----------------------------------------------------------------------------\r\n    enum Columns\r\n    {\r\n        NAME = 0,\r\n        DISPLAY_NAME,\r\n        API_DEFINITION,\r\n        DEPENDENCY,\r\n        DESCRIPTION,\r\n        COLUMN_COUNT\r\n    };\r\n}\r\n\r\n#endif // API_INTERFACE_COLUMNS_H"
  },
  {
    "path": "editors/ComponentEditor/software/apiInterface/ApiInterfaceEditor.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ApiInterfaceEditor.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Joni-Matti Maatta\r\n// Date: 16.4.2012\r\n//\r\n// Description:\r\n// API interface editor for the component editor.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"ApiInterfaceEditor.h\"\r\n\r\n#include <KactusAPI/include/LibraryInterface.h>\r\n#include <IPXACTmodels/Component/Component.h>\r\n\r\n#include <IPXACTmodels/kactusExtensions/ApiInterface.h>\r\n\r\n#include <QApplication>\r\n#include <QGridLayout>\r\n#include <QHBoxLayout>\r\n#include <QMainWindow>\r\n#include <QLabel>\r\n#include <QScrollArea>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ApiInterfaceEditor::ApiInterfaceEditor()\r\n//-----------------------------------------------------------------------------\r\nApiInterfaceEditor::ApiInterfaceEditor(LibraryInterface* libHandler,\r\n    QSharedPointer<Component> component,\r\n    QSharedPointer<ApiInterface> APIInterface,\r\n    QWidget *parent):\r\nItemEditor(component, libHandler, parent),\r\n    libInterface_(libHandler),\r\n    apiIf_(APIInterface),\r\n    nameEditor_(APIInterface, component->getRevision(), this, tr(\"Name and description\")),\r\n    detailsGroup_(tr(\"Details\"), this),\r\n    dependencyCombo_(this)\r\n{\r\n    Q_ASSERT(APIInterface != 0);\r\n    Q_ASSERT(libHandler != 0);\r\n\r\n\t// find the main window for VLNV editor\r\n\tQWidget* parentWindow = nullptr;\r\n\tfor (QWidget* widget : QApplication::topLevelWidgets())\r\n    {\r\n\t\tauto mainWnd = dynamic_cast<QMainWindow*>(widget);\r\n\t\tif (mainWnd)\r\n        {\r\n\t\t\tparentWindow = mainWnd;\r\n\t\t\tbreak;\r\n\t\t}\r\n\t}\r\n\r\n\tapiType_ = new VLNVEditor(VLNV::APIDEFINITION, libHandler, parentWindow, this);\r\n    \r\n    // Set VLNV editor settings.\r\n    apiType_->setTitle(tr(\"API definition\"));\r\n    apiType_->setMandatory(false);\r\n\r\n\tsetupLayout();\r\n\r\n\r\n\tconnect(&nameEditor_, SIGNAL(contentChanged()),\r\n\t\tthis, SIGNAL(contentChanged()), Qt::UniqueConnection);\r\n\tconnect(apiType_, SIGNAL(vlnvEdited()),\r\n\t\tthis, SLOT(onAPITypeChange()), Qt::UniqueConnection);\r\n\tconnect(&dependencyCombo_, SIGNAL(currentIndexChanged(int)),\r\n\t\tthis, SLOT(onDependencyChange(int)), Qt::UniqueConnection);\r\n\r\n    refresh();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ApiInterfaceEditor::isValid()\r\n//-----------------------------------------------------------------------------\r\nbool ApiInterfaceEditor::isValid() const\r\n{\r\n    return (nameEditor_.isValid() &&\r\n            (apiType_->isEmpty() || (apiType_->isValid() && libInterface_->contains(apiType_->getVLNV()))));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ApiInterfaceEditor::refresh()\r\n//-----------------------------------------------------------------------------\r\nvoid ApiInterfaceEditor::refresh()\r\n{\r\n\tnameEditor_.refresh();\r\n\r\n\tapiType_->setVLNV(apiIf_->getApiType());\r\n\r\n\t// the signal must be disconnected for the duration of changing the selected index\r\n\tdisconnect(&dependencyCombo_, SIGNAL(currentIndexChanged(int)),\r\n\t\tthis, SLOT(onDependencyChange(int)));\r\n\tdependencyCombo_.setCurrentIndex(apiIf_->getDependencyDirection());\r\n\tconnect(&dependencyCombo_, SIGNAL(currentIndexChanged(int)),\r\n\t\tthis, SLOT(onDependencyChange(int)), Qt::UniqueConnection);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ApiInterfaceEditor::onAPITypeChange()\r\n//-----------------------------------------------------------------------------\r\nvoid ApiInterfaceEditor::onAPITypeChange()\r\n{\r\n\tapiIf_->setApiType(apiType_->getVLNV());\r\n\temit contentChanged();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ApiInterfaceEditor::onDependencyChange()\r\n//-----------------------------------------------------------------------------\r\nvoid ApiInterfaceEditor::onDependencyChange(int /*index*/)\r\n{\r\n\tapiIf_->setDependencyDirection(static_cast<DependencyDirection>(dependencyCombo_.currentIndex()));\r\n\temit contentChanged();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ApiInterfaceEditor::showEvent()\r\n//-----------------------------------------------------------------------------\r\nvoid ApiInterfaceEditor::showEvent(QShowEvent* event)\r\n{\r\n\tQWidget::showEvent(event);\r\n\temit helpUrlRequested(\"componenteditor/apiinterface.html\");\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ApiInterfaceEditor::ApiInterfaceEditor()\r\n//-----------------------------------------------------------------------------\r\nvoid ApiInterfaceEditor::setupLayout()\r\n{\r\n    // Initialize the details group.\r\n    auto directionLabel = new QLabel(tr(\"Dependency:\"), &detailsGroup_);\r\n    dependencyCombo_.addItem(tr(\"requester\"));\r\n    dependencyCombo_.addItem(tr(\"provider\"));\r\n    dependencyCombo_.setCurrentIndex(0);\r\n\r\n    detailsGroup_.setFlat(true);\r\n    auto detailsLayout = new QGridLayout(&detailsGroup_);\r\n    detailsLayout->addWidget(directionLabel, 0, 0, 1, 1);\r\n    detailsLayout->addWidget(&dependencyCombo_, 0, 1, 1, 1);\r\n    detailsLayout->setRowStretch(1, 1);\r\n\r\n    detailsLayout->setColumnMinimumWidth(1, 100);\r\n    detailsLayout->setColumnStretch(2, 1);\r\n\r\n    // Create the scroll area.\r\n    auto scrollArea = new QScrollArea(this);\r\n    scrollArea->setWidgetResizable(true);\r\n    scrollArea->setFrameShape(QFrame::NoFrame);\r\n\r\n    auto scrollLayout = new QHBoxLayout(this);\r\n    scrollLayout->addWidget(scrollArea);\r\n    scrollLayout->setContentsMargins(0, 0, 0, 0);\r\n\r\n    // Create the top widget and set it under the scroll area.\r\n    auto topWidget = new QWidget(scrollArea);\r\n    topWidget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);\r\n\r\n    // Create the layout for the actual editor.\r\n    auto layout = new QGridLayout(topWidget);\r\n    layout->addWidget(&nameEditor_, 0, 0, 2, 1);\r\n    layout->addWidget(apiType_, 0, 1, 1, 1, Qt::AlignTop);\r\n    layout->addWidget(&detailsGroup_, 1, 1, 1, 1);\r\n    layout->setRowStretch(2, 1);\r\n    layout->setContentsMargins(0, 0, 0, 0);\r\n\r\n    scrollArea->setWidget(topWidget);\r\n}"
  },
  {
    "path": "editors/ComponentEditor/software/apiInterface/ApiInterfaceEditor.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ApiInterfaceEditor.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Joni-Matti Maatta\r\n// Date: 16.4.2012\r\n//\r\n// Description:\r\n// API interface editor for the component editor.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef APIINTERFACEEDITOR_H\r\n#define APIINTERFACEEDITOR_H\r\n\r\n#include <editors/ComponentEditor/itemeditor.h>\r\n\r\n#include <common/widgets/vlnvEditor/vlnveditor.h>\r\n#include <common/widgets/nameGroupEditor/namegroupeditor.h>\r\n\r\n#include <QComboBox>\r\n#include <QGroupBox>\r\n\r\nclass Component;\r\nclass ApiInterface;\r\nclass LibraryInterface;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! API interface editor.\r\n//-----------------------------------------------------------------------------\r\nclass ApiInterfaceEditor : public ItemEditor\r\n{\r\n    Q_OBJECT\r\n\r\npublic:\r\n    /*!\r\n     *  Constructor.\r\n     *\r\n     *    @param [in] libHandler   The library handler.\r\n     *    @param [in] component    The component being edited.\r\n     *    @param [in] APIInterface The API interface being edited.\r\n     *    @param [in] parent       The parent widget.\r\n\t */\r\n\tApiInterfaceEditor(LibraryInterface* libHandler,\r\n\t\tQSharedPointer<Component> component, \r\n\t\tQSharedPointer<ApiInterface> APIInterface,\r\n\t\tQWidget *parent);\r\n\r\n    /*!\r\n     *  Destructor.\r\n     */\r\n    virtual ~ApiInterfaceEditor() = default;\r\n\r\n    // Disable copying.\r\n    ApiInterfaceEditor(ApiInterfaceEditor const& rhs) = delete;\r\n\r\n    //! Disable assignment.\r\n    ApiInterfaceEditor& operator=(ApiInterfaceEditor const& rhs) = delete;\r\n\r\n    /*!\r\n     *  Checks for the validity of the edited API interface.\r\n     *\r\n\t *    @return True if the API interface is in valid state.\r\n\t */\r\n\tbool isValid() const;\r\n\r\n\t/*! Reload the information from the model to the editor.\r\n\t*/\r\n\tvoid refresh() final;\r\n\r\nprivate slots:\r\n\r\n\t//! Handler for changes in api type.\r\n\tvoid onAPITypeChange();\r\n\r\n\t//! Handler for changes in dependency editor.\r\n\tvoid onDependencyChange(int index);\r\n\r\nprotected:\r\n\r\n\t//! Handler for widget's show event\r\n\tvirtual void showEvent(QShowEvent* event);\r\n\r\nprivate:\r\n\r\n    /*!\r\n     *  Restores changes made to the contents.\r\n     */\r\n    void restoreChanges();\r\n\r\n    //! Setup the widget layout.\r\n    void setupLayout();\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! The library handler.\r\n    LibraryInterface* libInterface_ = nullptr;\r\n\r\n    //! The bus interface being edited.\r\n    QSharedPointer<ApiInterface> apiIf_ = nullptr;\r\n\r\n    //! Contains the name, display name and description of the API interface.\r\n    NameGroupEditor nameEditor_;\r\n\r\n    //! Editor for setting the API definition.\r\n    VLNVEditor* apiType_ = nullptr;\r\n\r\n    //! Details group box.\r\n    QGroupBox detailsGroup_;\r\n\r\n    //! Dependency direction combo box.\r\n    QComboBox dependencyCombo_;\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n\r\n#endif // APIINTERFACEEDITOR_H\r\n"
  },
  {
    "path": "editors/ComponentEditor/software/apiInterface/apiinterfacesdelegate.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: apiinterfacesdelegate.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 27.06.2012\r\n//\r\n// Description:\r\n// The delegate that provides editors to edit the API definitions.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"apiinterfacesdelegate.h\"\r\n\r\n#include \"ApiInterfaceColumns.h\"\r\n\r\n#include <QLineEdit>\r\n#include <QComboBox>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ApiInterfacesDelegate::ApiInterfacesDelegate()\r\n//-----------------------------------------------------------------------------\r\nApiInterfacesDelegate::ApiInterfacesDelegate(QObject *parent): QStyledItemDelegate(parent)\r\n{\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ApiInterfacesDelegate::createEditor()\r\n//-----------------------------------------------------------------------------\r\nQWidget* ApiInterfacesDelegate::createEditor(QWidget* parent, const QStyleOptionViewItem& option, \r\n    QModelIndex const& index) const\r\n{\r\n    if (index.column() == ApiInterfaceColumns::NAME || index.column() == ApiInterfaceColumns::DISPLAY_NAME ||\r\n        index.column() == ApiInterfaceColumns::DESCRIPTION)\r\n    {\r\n        QLineEdit* edit = new QLineEdit(parent);\r\n        connect(edit, SIGNAL(editingFinished()), this, SLOT(commitAndCloseEditor()), Qt::UniqueConnection);\r\n        return edit;\r\n    }\r\n    else if (index.column() == ApiInterfaceColumns::API_DEFINITION)\r\n    {\r\n        Q_ASSERT(false);\r\n        return 0;\r\n    }\r\n    else if (index.column() == ApiInterfaceColumns::DEPENDENCY)\r\n    {\r\n        QComboBox* combo = new QComboBox(parent);\r\n        combo->addItem(tr(\"requester\"));\r\n        combo->addItem(tr(\"provider\"));\r\n        combo->setCurrentIndex(0);\r\n        combo->setEditable(false);\r\n        return combo;\r\n    }\r\n    else\r\n    {\r\n        return QStyledItemDelegate::createEditor(parent, option, index);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ApiInterfacesDelegate::setEditorData()\r\n//-----------------------------------------------------------------------------\r\nvoid ApiInterfacesDelegate::setEditorData(QWidget* editor, QModelIndex const& index) const\r\n{\r\n    if (index.column() == ApiInterfaceColumns::NAME || index.column() == ApiInterfaceColumns::DISPLAY_NAME ||\r\n        index.column() == ApiInterfaceColumns::DESCRIPTION)\r\n    {\r\n        QLineEdit* edit = qobject_cast<QLineEdit*>(editor);\r\n        Q_ASSERT(edit);\r\n\r\n        edit->setText(index.data(Qt::DisplayRole).toString());\t\t\t\r\n    }\r\n    else if (index.column() == ApiInterfaceColumns::API_DEFINITION)\r\n    {\r\n        Q_ASSERT(false);\r\n    }\r\n    else if (index.column() == ApiInterfaceColumns::DEPENDENCY)\r\n    {\r\n        QComboBox* combo = qobject_cast<QComboBox*>(editor);\r\n        Q_ASSERT(combo);\r\n\r\n        QString selectedText = index.data(Qt::DisplayRole).toString();\r\n        int indexToSelect = combo->findText(selectedText);\r\n        combo->setCurrentIndex(indexToSelect);\r\n    }\r\n    else\r\n    {\r\n        QStyledItemDelegate::setEditorData(editor, index);\t\t\t\t\t \r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ApiInterfacesDelegate::setModelData()\r\n//-----------------------------------------------------------------------------\r\nvoid ApiInterfacesDelegate::setModelData(QWidget* editor, QAbstractItemModel* model, \r\n    QModelIndex const& index) const\r\n{\r\n    if (index.column() == ApiInterfaceColumns::NAME || index.column() == ApiInterfaceColumns::DISPLAY_NAME ||\r\n        index.column() == ApiInterfaceColumns::DESCRIPTION)\r\n    {\r\n        QLineEdit* edit = qobject_cast<QLineEdit*>(editor);\r\n        Q_ASSERT(edit);\r\n\r\n        model->setData(index, edit->text(), Qt::EditRole);\r\n    }\r\n    else if (index.column() == ApiInterfaceColumns::API_DEFINITION)\r\n    {\r\n        Q_ASSERT(false);\r\n    }\r\n    else if (index.column() == ApiInterfaceColumns::DEPENDENCY)\r\n    {\r\n        QComboBox* combo = qobject_cast<QComboBox*>(editor);\r\n        Q_ASSERT(combo);\r\n\r\n        model->setData(index, combo->currentText(), Qt::EditRole);\r\n    }\r\n    else\r\n    {\r\n        QStyledItemDelegate::setModelData(editor, model, index);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ApiInterfacesDelegate::commitAndCloseEditor()\r\n//-----------------------------------------------------------------------------\r\nvoid ApiInterfacesDelegate::commitAndCloseEditor()\r\n{\r\n\tQWidget* edit = qobject_cast<QWidget*>(sender());\r\n\tQ_ASSERT(edit);\r\n\r\n\temit commitData(edit);\r\n\temit closeEditor(edit);\r\n}\r\n"
  },
  {
    "path": "editors/ComponentEditor/software/apiInterface/apiinterfacesdelegate.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: apiinterfacesdelegate.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 27.06.2012\r\n//\r\n// Description:\r\n// The delegate that provides editors to edit the API definitions.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef APIINTERFACESDELEGATE_H\r\n#define APIINTERFACESDELEGATE_H\r\n\r\n#include <QStyledItemDelegate>\r\n\r\n//-----------------------------------------------------------------------------\r\n//! The delegate that provides editors to edit the API definitions.\r\n//-----------------------------------------------------------------------------\r\nclass ApiInterfacesDelegate : public QStyledItemDelegate\r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\r\n\t/*! The constructor.\r\n\t *\r\n\t *    @param [in] parent The owner of the delegate.\r\n\t */\r\n\tApiInterfacesDelegate(QObject *parent);\r\n\t\r\n\t//! The destructor\r\n\tvirtual ~ApiInterfacesDelegate() = default;\r\n\r\n    //! No copying\r\n    ApiInterfacesDelegate(const ApiInterfacesDelegate& other) = delete;\r\n\r\n    //! No assignment\r\n    ApiInterfacesDelegate& operator=(const ApiInterfacesDelegate& other) = delete;\r\n\r\n\t/*! Create a new editor for the given item\r\n\t *\r\n\t *    @param [in] parent  Owner for the editor.\r\n\t *    @param [in] option  Contains options for the editor.\r\n\t *    @param [in] index   Model index identifying the item.\r\n\t *\r\n\t *    @return The editor to be used to edit the item.\r\n\t*/\r\n\tvirtual QWidget* createEditor(QWidget* parent, const QStyleOptionViewItem& option, \r\n        QModelIndex const& index) const;\r\n\r\n\t/*! Set the data for the editor.\r\n\t *\r\n\t *    @param [in] editor The editor where the data is to be set.\r\n\t *    @param [in] index Model index identifying the item that's data is to be set.\r\n\t*/\r\n\tvirtual void setEditorData(QWidget* editor, QModelIndex const& index) const;\r\n\r\n\t/*! Save the data from the editor to the model.\r\n\t *\r\n\t *    @param [in] editor  The editor that contains the data to store.\r\n\t *    @param [in] model   Model that contains the data structure where data is to be saved to.\r\n\t *    @param [in] index   Model index identifying the item that's data is to be saved.\r\n\t*/\r\n\tvirtual void setModelData(QWidget* editor, QAbstractItemModel* model, \r\n\t\tQModelIndex const& index) const;\r\n\r\nprivate slots:\r\n\r\n\t//! Commit the data from the sending editor and close the editor.\t \r\n\tvoid commitAndCloseEditor();\r\n\r\n};\r\n\r\n#endif // APIINTERFACESDELEGATE_H\r\n"
  },
  {
    "path": "editors/ComponentEditor/software/apiInterface/apiinterfaceseditor.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: apiinterfaceseditor.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 27.06.2012\r\n//\r\n// Description:\r\n// The editor to add/remove/edit the API interfaces of a component.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"apiinterfaceseditor.h\"\r\n#include \"apiinterfacesdelegate.h\"\r\n\r\n#include <common/widgets/summaryLabel/summarylabel.h>\r\n\r\n#include <KactusAPI/include/LibraryInterface.h>\r\n\r\n#include <IPXACTmodels/Component/Component.h>\r\n\r\n#include <QVBoxLayout>\r\n#include <QCoreApplication>\r\n#include <QMessageBox>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ApiInterfacesEditor::ApiInterfacesEditor()\r\n//-----------------------------------------------------------------------------\r\nApiInterfacesEditor::ApiInterfacesEditor(QSharedPointer<Component> component, \r\n    LibraryInterface* handler, QWidget* parent):\r\nItemEditor(component, handler, parent),\r\n    view_(this),\r\n    proxy_(this),\r\n    model_(component, handler, this)\r\n{\r\n\r\n    // display a label on top the table\r\n    SummaryLabel* summaryLabel = new SummaryLabel(tr(\"API interfaces summary\"), this, true);\r\n    \r\n    QVBoxLayout* layout = new QVBoxLayout(this);\r\n    layout->addWidget(summaryLabel, 0, Qt::AlignCenter);\r\n    layout->addWidget(&view_);\r\n    layout->setContentsMargins(0, 0, 0, 0);\r\n\r\n\tproxy_.setSourceModel(&model_);\r\n\tview_.setModel(&proxy_);\r\n\r\n\tconst QString componentPath = handler->getDirectoryPath(component->getVlnv());\r\n\tQString defaultPath = QString(\"%1/apiIfListing.csv\").arg(componentPath);\r\n\tview_.setDefaultImportExportPath(defaultPath);\r\n\tview_.setAllowImportExport(true);\r\n\r\n\t// items can not be dragged\r\n\tview_.setItemsDraggable(false);\r\n    view_.viewport()->setAcceptDrops(true); \r\n    view_.setDropIndicatorShown(true);   \r\n    view_.setDragDropMode(QAbstractItemView::DropOnly);\r\n\tview_.setItemDelegate(new ApiInterfacesDelegate(this));\r\n\r\n\tconnect(&model_, SIGNAL(contentChanged()), this, SIGNAL(contentChanged()), Qt::UniqueConnection);\r\n\tconnect(&model_, SIGNAL(apiAdded(int)),\tthis, SIGNAL(childAdded(int)), Qt::UniqueConnection);\r\n\tconnect(&model_, SIGNAL(apiRemoved(int)), this, SIGNAL(childRemoved(int)), Qt::UniqueConnection);\r\n\tconnect(&model_, SIGNAL(stdRevisionMismatch()), this, SLOT(showStdRevisionMismatchWarning()), Qt::UniqueConnection);\r\n\r\n\tconnect(&view_, SIGNAL(addItem(const QModelIndex&)),\r\n        &model_, SLOT(onAddItem(const QModelIndex&)), Qt::UniqueConnection);\r\n\tconnect(&view_, SIGNAL(removeItem(const QModelIndex&)),\r\n\t\t&model_, SLOT(onRemoveItem(const QModelIndex&)), Qt::UniqueConnection);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ApiInterfacesEditor::isValid()\r\n//-----------------------------------------------------------------------------\r\nbool ApiInterfacesEditor::isValid() const\r\n{\r\n\treturn model_.isValid();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ApiInterfacesEditor::refresh()\r\n//-----------------------------------------------------------------------------\r\nvoid ApiInterfacesEditor::refresh()\r\n{\r\n\tview_.update();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ApiInterfacesEditor::showStdRevisionMismatchWarning()\r\n//-----------------------------------------------------------------------------\r\nvoid ApiInterfacesEditor::showStdRevisionMismatchWarning()\r\n{\r\n    QMessageBox::warning(this, QCoreApplication::applicationName(),\r\n        tr(\"Dropped item cannot use different IP-XACT standard revision than the item being edited.\"),\r\n        QMessageBox::Close, QMessageBox::Close);\r\n}\t\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ApiInterfacesEditor::showEvent()\r\n//-----------------------------------------------------------------------------\r\nvoid ApiInterfacesEditor::showEvent(QShowEvent* event)\r\n{\r\n\tQWidget::showEvent(event);\r\n\temit helpUrlRequested(\"componenteditor/apiinterfaces.html\");\r\n}\r\n"
  },
  {
    "path": "editors/ComponentEditor/software/apiInterface/apiinterfaceseditor.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: apiinterfaceseditor.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 27.06.2012\r\n//\r\n// Description:\r\n// The editor to add/remove/edit the API interfaces of a component.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef APIINTERFACESEDITOR_H\r\n#define APIINTERFACESEDITOR_H\r\n\r\n#include <editors/ComponentEditor/itemeditor.h>\r\n\r\n#include \"apiinterfacesmodel.h\"\r\n\r\n#include <common/views/EditableTableView/editabletableview.h>\r\n\r\n#include <QSharedPointer>\r\n#include <QSortFilterProxyModel>\r\n\r\nclass Component;\r\nclass LibraryInterface;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! The editor to add/remove/edit the API interfaces of a component.\r\n//-----------------------------------------------------------------------------\r\nclass ApiInterfacesEditor : public ItemEditor\r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\r\n\t//! The width of the name column\r\n\tstatic const int NAME_COLUMN_WIDTH = 100;\r\n\r\n\t//! The width of the API definition column\r\n\tstatic const int API_DEF_COLUMN_WIDTH = 200;\r\n\r\n\t//! The width of the dependency column.\r\n\tstatic const int DEPENDENCY_COLUMN_WIDTH = 100;\r\n\r\n\t//! The width of the display name column.\r\n\tstatic const int DISPLAY_NAME_COLUMN_WIDTH = 100;\r\n\r\n\t/*! The constructor\r\n\t *\r\n\t *    @param [in] component   The component being edited.\r\n\t *    @param [in] handler     The instance managing the library.\r\n\t *    @param [in] parent  The parent of this editor.\r\n\t */\r\n\tApiInterfacesEditor(QSharedPointer<Component> component, LibraryInterface* handler,\tQWidget* parent = 0);\r\n\t\r\n\t//! The destructor\r\n\tvirtual ~ApiInterfacesEditor() = default;\r\n\r\n    //! No copying\r\n    ApiInterfacesEditor(const ApiInterfacesEditor& other) = delete;\r\n\r\n    //! No assignment\r\n    ApiInterfacesEditor& operator=(const ApiInterfacesEditor& other) = delete;\r\n\r\n\t/*! Check for the validity of the editor\r\n\t* \r\n\t*    @return True if the editor is in valid state.\r\n\t*/\r\n\tvirtual bool isValid() const;\r\n\r\n\t/*! Reload the information from the model to the editor.\r\n\t*/\r\n\tvirtual void refresh();\r\n\r\npublic slots:\r\n\r\n\t/*!\r\n\t *  Displays warning message when trying to drag and drop an IP-XACT file using different standard revision\r\n\t *  than the component.\r\n\t */\r\n\tvoid showStdRevisionMismatchWarning();\r\n\r\nprotected:\r\n\r\n\t//! Handler for widget's show event\r\n\tvirtual void showEvent(QShowEvent* event);\r\n\r\nprivate:\r\n\t\r\n\r\n\t//! The view to display the API interface info.\r\n\tEditableTableView view_;\r\n\r\n\t//! The model that does the sorting.\r\n\tQSortFilterProxyModel proxy_;\r\n\r\n\t//! The model that manages the API interfaces.\r\n\tApiInterfacesModel model_;\r\n};\r\n\r\n#endif // APIINTERFACESEDITOR_H\r\n"
  },
  {
    "path": "editors/ComponentEditor/software/apiInterface/apiinterfacesmodel.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: apiinterfacesmodel.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 27.6.2012\r\n//\r\n// Description:\r\n// The model that manages the API interfaces for API Interface editor.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"apiinterfacesmodel.h\"\r\n#include \"ApiInterfaceColumns.h\"\r\n\r\n#include <IPXACTmodels/Component/Component.h>\r\n#include <IPXACTmodels/kactusExtensions/ApiInterface.h>\r\n#include <IPXACTmodels/common/VLNV.h>\r\n#include <IPXACTmodels/common/DocumentUtils.h>\r\n\r\n#include <common/KactusColors.h>\r\n\r\n#include <KactusAPI/include/LibraryInterface.h>\r\n\r\n#include <QMimeData>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ApiInterfacesModel::ApiInterfacesModel()\r\n//-----------------------------------------------------------------------------\r\nApiInterfacesModel::ApiInterfacesModel(QSharedPointer<Component> component, LibraryInterface* library, QObject* parent) :\r\nQAbstractTableModel(parent),\r\n    component_(component),\r\n    apis_(component->getApiInterfaces()),\r\n    library_(library)\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ApiInterfacesModel::rowCount()\r\n//-----------------------------------------------------------------------------\r\nint ApiInterfacesModel::rowCount(QModelIndex const& parent) const\r\n{\r\n\tif (parent.isValid())\r\n    {\r\n\t\treturn 0;\r\n\t}\r\n\r\n\treturn apis_.size();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ApiInterfacesModel::columnCount()\r\n//-----------------------------------------------------------------------------\r\nint ApiInterfacesModel::columnCount(QModelIndex const& parent) const\r\n{\r\n\tif (parent.isValid())\r\n    {\r\n\t\treturn 0;\r\n\t}\r\n\r\n\treturn ApiInterfaceColumns::COLUMN_COUNT;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ApiInterfacesModel::flags()\r\n//-----------------------------------------------------------------------------\r\nQt::ItemFlags ApiInterfacesModel::flags(QModelIndex const& index) const\r\n{\r\n\tif (!index.isValid())\r\n    {\r\n\t\treturn Qt::NoItemFlags;\r\n\t}\r\n\r\n\t// API definition can only be dropped.\r\n\telse if (ApiInterfaceColumns::API_DEFINITION == index.column())\r\n    {\r\n\t\treturn Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsDropEnabled;\r\n\t}\r\n\r\n\treturn Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsEditable;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ApiInterfacesModel::headerData()\r\n//-----------------------------------------------------------------------------\r\nQVariant ApiInterfacesModel::headerData(int section, Qt::Orientation orientation, int role) const\r\n{\r\n\tif (orientation != Qt::Horizontal || role != Qt::DisplayRole)\r\n    {\r\n\t\treturn QVariant();\r\n\t}\r\n\t\r\n    if (section == ApiInterfaceColumns::NAME)\r\n    {\r\n        return tr(\"Name\");\r\n    }\r\n    else if (section == ApiInterfaceColumns::API_DEFINITION)\r\n    {\r\n        return tr(\"API definition\");\r\n    }\r\n    else if (section == ApiInterfaceColumns::DEPENDENCY)\r\n    {\r\n        return tr(\"Dependency\");\r\n    }\r\n    else if (section == ApiInterfaceColumns::DISPLAY_NAME) \r\n    {\r\n        return tr(\"Display name\");\r\n    }\r\n    else if (section == ApiInterfaceColumns::DESCRIPTION)\r\n    {\r\n        return tr(\"Description\");\r\n    }\r\n    else\r\n    {\r\n        return QVariant();\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ApiInterfacesModel::data()\r\n//-----------------------------------------------------------------------------\r\nQVariant ApiInterfacesModel::data(QModelIndex const& index, int role) const \r\n{\t\r\n    if (!index.isValid() || index.row() < 0 || index.row() >= apis_.size())\r\n    {\r\n\t\treturn QVariant();\r\n    }\r\n\r\n    if (role == Qt::DisplayRole)\r\n    {\r\n        if (index.column() == ApiInterfaceColumns::NAME)\r\n        {\r\n            return apis_.at(index.row())->name();\r\n        }\r\n        else if (index.column() == ApiInterfaceColumns::API_DEFINITION)\r\n        {\r\n            return apis_.at(index.row())->getApiType().toString(\":\");\r\n        }\r\n        else if (index.column() == ApiInterfaceColumns::DEPENDENCY)\r\n        {\r\n            return dependencyDirection2Str(apis_.at(index.row())->getDependencyDirection());\r\n        }\r\n        else if (index.column() == ApiInterfaceColumns::DISPLAY_NAME)\r\n        {\r\n            return apis_.at(index.row())->displayName();\r\n        }\r\n        else if (index.column() == ApiInterfaceColumns::DESCRIPTION)\r\n        {\r\n            return apis_.at(index.row())->description();\r\n        }\r\n        else\r\n        {\r\n            return QVariant();\r\n        }\r\n    }\r\n\r\n\telse if (role == Qt::ForegroundRole)\r\n    {\r\n\t\tif (apis_.at(index.row())->isValid())\r\n        {\r\n\t\t\treturn KactusColors::REGULAR_TEXT;\r\n\t\t}\r\n\t\telse {\r\n\t\t\treturn KactusColors::ERROR;\r\n\t\t}\r\n\t}\r\n\r\n\telse if (role == Qt::BackgroundRole)\r\n    {\r\n        if (index.column() == ApiInterfaceColumns::NAME)\r\n        {\r\n            return KactusColors::MANDATORY_FIELD;\r\n        }\r\n        else\r\n        {\r\n            return KactusColors::REGULAR_FIELD;\r\n        }\r\n    }\r\n\t\r\n    else\r\n    {\r\n\t\treturn QVariant();\r\n\t}\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ApiInterfacesModel::setData()\r\n//-----------------------------------------------------------------------------\r\nbool ApiInterfacesModel::setData(QModelIndex const& index, const QVariant& value, int role)\r\n{\r\n\tif (!index.isValid() || index.row() < 0 || index.row() >= apis_.size() || role != Qt::EditRole)\r\n    {\r\n\t\treturn false;\r\n\t}\r\n\r\n    if (index.column() == ApiInterfaceColumns::NAME)\r\n    {\r\n        apis_.at(index.row())->setName(value.toString());\r\n    }\r\n    else if (index.column() == ApiInterfaceColumns::API_DEFINITION)\r\n    {\r\n        VLNV apiDef = VLNV(VLNV::APIDEFINITION, value.toString(), \":\");\r\n        apis_.at(index.row())->setApiType(apiDef);\r\n    }\r\n    else if (index.column() == ApiInterfaceColumns::DEPENDENCY) \r\n    {\r\n        apis_.at(index.row())->setDependencyDirection(str2DependencyDirection(value.toString(),\r\n            DEPENDENCY_REQUESTER));\r\n    }\r\n    else if (index.column() == ApiInterfaceColumns::DISPLAY_NAME) \r\n    {\r\n        apis_.at(index.row())->setDisplayName(value.toString());\r\n    }\r\n    else if (index.column() == ApiInterfaceColumns::DESCRIPTION)\r\n    {\r\n        apis_.at(index.row())->setDescription(value.toString());\r\n    }\r\n    else\r\n    {\r\n        return false;\r\n    }\r\n\r\n    emit dataChanged(index, index);\r\n    emit contentChanged();\r\n    return true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ApiInterfacesModel::isValid()\r\n//-----------------------------------------------------------------------------\r\nbool ApiInterfacesModel::isValid() const\r\n{\t\r\n    return std::all_of(apis_.cbegin(), apis_.cend(), [](auto const& api) { return api->isValid(); });\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ApiInterfacesModel::supportedDropActions()\r\n//-----------------------------------------------------------------------------\r\nQt::DropActions ApiInterfacesModel::supportedDropActions() const\r\n{\r\n    return Qt::CopyAction | Qt::MoveAction;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ApiInterfacesModel::mimeTypes()\r\n//-----------------------------------------------------------------------------\r\nQStringList ApiInterfacesModel::mimeTypes() const\r\n{\r\n    QStringList types(QAbstractTableModel::mimeTypes());\r\n    types << \"application/x-qt-image\";\r\n    return types;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ApiInterfacesModel::dropMimeData()\r\n//-----------------------------------------------------------------------------\r\nbool ApiInterfacesModel::dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, \r\n    QModelIndex const& parent)\r\n{\r\n    if ( action == Qt::IgnoreAction)\r\n    {\r\n        return true;\r\n    }\r\n\r\n    // Dropped data must be directly on parent.\r\n    if ( row != -1 || column != -1 || !parent.isValid() )\r\n    {\r\n        return false;\r\n    }\r\n\r\n    if ( row > rowCount() )\r\n    {\r\n        return false;\r\n    }\r\n\r\n    QVariant variant = data->imageData();\r\n\r\n    if ( !variant.canConvert<VLNV>())\r\n    {\r\n        return false;\r\n    }\r\n\r\n    VLNV vlnv = variant.value<VLNV>();\r\n\r\n    if ( parent.column() == ApiInterfaceColumns::API_DEFINITION )\r\n    {\r\n        if ( vlnv.getType() != VLNV::APIDEFINITION )\r\n        {\r\n            return false;\r\n        }\r\n\r\n        if (!DocumentUtils::documentsHaveMatchingStdRevisions(vlnv, component_->getVlnv(), library_))\r\n        {\r\n            emit stdRevisionMismatch();\r\n            return false;\r\n        }\r\n\r\n        setData(index(parent.row(),parent.column()),vlnv.toString(\":\"));\r\n        emit contentChanged();\r\n    }\r\n\r\n    return true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ApiInterfacesModel::onAddItem()\r\n//-----------------------------------------------------------------------------\r\nvoid ApiInterfacesModel::onAddItem(QModelIndex const& index)\r\n{\r\n\tint row = apis_.size();\r\n\r\n\t// if the index is valid then add the item to the correct position\r\n\tif (index.isValid()) {\r\n\t\trow = index.row();\r\n\t}\r\n\r\n\tbeginInsertRows(QModelIndex(), row, row);\r\n\tapis_.insert(row, QSharedPointer<ApiInterface>(new ApiInterface()));\r\n    component_->setApiInterfaces(apis_);\r\n\tendInsertRows();\r\n\r\n\t// inform navigation tree that file set is added\r\n\temit apiAdded(row);\r\n\r\n\t// tell also parent widget that contents have been changed\r\n\temit contentChanged();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ApiInterfacesModel::onRemoveItem()\r\n//-----------------------------------------------------------------------------\r\nvoid ApiInterfacesModel::onRemoveItem(QModelIndex const& index)\r\n{\r\n\t// don't remove anything if index is invalid\r\n\tif (!index.isValid() || index.row() < 0 || index.row() >= apis_.size())\r\n    {\r\n\t\treturn;\r\n\t}\r\n\r\n\t// remove the specified item\r\n\tbeginRemoveRows(QModelIndex(), index.row(), index.row());\r\n\tapis_.removeAt(index.row());\r\n    component_->setApiInterfaces(apis_);\r\n\tendRemoveRows();\r\n\r\n\t// inform navigation tree that file set has been removed\r\n\temit apiRemoved(index.row());\r\n\r\n\t// tell also parent widget that contents have been changed\r\n\temit contentChanged();\r\n}\r\n"
  },
  {
    "path": "editors/ComponentEditor/software/apiInterface/apiinterfacesmodel.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: apiinterfacesmodel.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 27.6.2012\r\n//\r\n// Description:\r\n// The model that manages the API interfaces for API Interface editor.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef APIINTERFACESMODEL_H\r\n#define APIINTERFACESMODEL_H\r\n\r\n#include <QAbstractTableModel>\r\n#include <QSharedPointer>\r\n\r\nclass ApiInterface;\r\nclass Component;\r\nclass LibraryInterface;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! The model that manages the API interfaces for API Interface editor.\r\n//-----------------------------------------------------------------------------\r\nclass ApiInterfacesModel : public QAbstractTableModel\r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\r\n\t/*! The constructor\r\n\t *\r\n\t *    @param [in] component The component being edited.\r\n\t *    @param [in] library\t  The library interface.\r\n\t *    @param [in] parent\t  The owner of the model.\r\n\t */\r\n\tApiInterfacesModel(QSharedPointer<Component> component, LibraryInterface* library, QObject* parent);\r\n\t\r\n\t//! The destructor\r\n\tvirtual ~ApiInterfacesModel() = default;\r\n\r\n    //! No copying\r\n    ApiInterfacesModel(const ApiInterfacesModel& other) = delete;\r\n\r\n    //! No assignment\r\n    ApiInterfacesModel& operator=(const ApiInterfacesModel& other) = delete;\r\n\r\n\t/*! Get the number of rows an item contains.\r\n\t *\r\n\t *    @param [in] parent Identifies the parent that's row count is requested.\r\n\t *\r\n\t *    @return Number of rows the item has.\r\n\t*/\r\n\tvirtual int rowCount(QModelIndex const& parent = QModelIndex()) const;\r\n\r\n\t/*! Get the number of columns the item has to be displayed.\r\n\t *\r\n\t *    @param [in] parent Identifies the parent that's column count is requested.\r\n\t *\r\n\t *    @return The number of columns to be displayed.\r\n\t*/\r\n\tvirtual int columnCount(QModelIndex const& parent = QModelIndex()) const;\r\n\r\n\t/*! Get the item flags that defines the possible operations for the item.\r\n\t *\r\n\t *    @param [in] index Model index that identifies the item.\r\n\t *\r\n\t *    @return Qt::ItemFlags specify the possible operations for the item.\r\n\t*/\r\n\tQt::ItemFlags flags(QModelIndex const& index) const;\r\n\r\n\t/*! Get the header data for specified header.\r\n\t *\r\n\t *    @param [in] section         The section specifies the row/column number for the header.\r\n\t *    @param [in] orientation     Specified if horizontal or vertical header is wanted.\r\n\t *    @param [in] role            Specifies the type of the requested data.\r\n\t *\r\n\t *    @return QVariant Contains the requested data.\r\n\t*/\r\n\tvirtual QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;\r\n\r\n\t/*! Get the data for specified item.\r\n\t *\r\n\t *    @param [in] index   Specifies the item that's data is requested.\r\n\t *    @param [in] role    The role that defines what kind of data is requested.\r\n\t *\r\n\t *    @return QVariant Contains the data for the item.\r\n\t*/\r\n\tvirtual QVariant data(QModelIndex const& index, int role = Qt::DisplayRole) const;\r\n\r\n\t/*! Save the data to the model for specified item\r\n\t *\r\n\t *    @param [in] index   The model index of the item that's data is to be saved.\r\n\t *    @param [in] value   The data that is to be saved.\r\n\t *    @param [in] role    The role specifies what kind of data should be saved.\r\n\t *\r\n\t *    @return True if saving happened successfully.\r\n\t*/\r\n\tbool setData(QModelIndex const& index, const QVariant& value, int role = Qt::EditRole);\r\n\r\n\t/*! Check if the API interface model is in a valid state.\r\n\t *\r\n\t *    @return bool True if the state is valid and writing is possible.\r\n\t*/\r\n\tbool isValid() const;\r\n\r\n    /*!\r\n     *  Returns the supported actions of a drop.\r\n     *\r\n     *    @return The drop actions supported by the model.\r\n     */\r\n    Qt::DropActions supportedDropActions() const;\r\n\r\n    /*!\r\n     *  Returns a list of supported MIME data types.\r\n     *\r\n     *    @return The supported MIME types.\r\n     */\r\n    QStringList mimeTypes() const;\r\n\r\n    /*!\r\n     *  Handler for the dropped MIME data.\r\n     *\r\n     *    @param [in] data   The data associated to the drop.\r\n     *    @param [in] action The drop action.  \r\n     *    @param [in] row    The row beneath the drop position.\r\n     *    @param [in] column The column beneath the drop position.\r\n     *    @param [in] parent The parent index of the drop position.\r\n     *\r\n     *    @return True, if the model could handle the data, otherwise false.\r\n     */\r\n    bool dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, \r\n        QModelIndex const& parent);\r\n\r\npublic slots:\r\n\r\n\t/*! Add a new item to the given index.\r\n\t *\r\n\t *    @param [in] index The index identifying the position for new item.\r\n\t */\r\n\tvirtual void onAddItem(QModelIndex const& index);\r\n\r\n\t/*! Remove the item in the given index.\r\n\t *\r\n\t *    @param [in] index The index identifying the item to remove.\r\n\t */\r\n\tvirtual void onRemoveItem(QModelIndex const& index);\r\n\r\nsignals:\r\n\r\n\t//! Emitted when the contents of the model change.\r\n\tvoid contentChanged();\r\n\r\n\t/*! Emitted when a new api interface is added to the model.\r\n\t *\r\n\t *    @param [in] index The index of the added api interface.\r\n\t */\r\n\tvoid apiAdded(int index);\r\n\r\n\t/*! Emitted when an api interface is removed from the model.\r\n\t *\r\n\t *    @param [in] index The index of the api interface to remove.\r\n\t */\r\n\tvoid apiRemoved(int index);\r\n\r\n\t/*!\r\n\t *  Emitted when an api definition with different std revision than the component being edited\r\n\t *  is dropped in an api interface cell in the editor.\r\n\t */\r\n\tvoid stdRevisionMismatch() const;\r\n\r\nprivate:\r\n\t\r\n    QSharedPointer<Component> component_;\r\n\r\n\t//! Contains the api interfaces being edited.\r\n\tQList<QSharedPointer<ApiInterface> > apis_;\r\n\r\n\t//! The library handler.\r\n\tLibraryInterface* library_;\r\n};\r\n\r\n#endif // APIINTERFACESMODEL_H\r\n"
  },
  {
    "path": "editors/ComponentEditor/software/comInterface/ComInterfaceColumns.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: PortColumns.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Esko Pekkarinen\r\n// Date: 16.10.2015\r\n//\r\n// Description:\r\n// Common declarations for editing COM interfaces.\r\n//-----------------------------------------------------------------------------\r\n\r\nnamespace ComInterfaceColumns\r\n{\r\n    //! The user roles that can be used.\r\n    enum UserRole\r\n    {\r\n        TRANSFER_TYPE_OPTIONS = Qt::UserRole //<! Returns QStringList that contains the possible transfer types.\r\n    };\r\n\r\n    //! The column numbers for columns.\r\n    enum Column\r\n    {\r\n        NAME = 0,\r\n        DISPLAY_NAME,\r\n        COM_DEFINITION,\r\n        TRANSFER_TYPE,\r\n        DIRECTION,\r\n        DESCRIPTION,\r\n        COLUMN_COUNT\r\n    };\r\n}\r\n"
  },
  {
    "path": "editors/ComponentEditor/software/comInterface/ComInterfaceEditor.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ComInterfaceEditor.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Joni-Matti Maatta\r\n// Date: 16.4.2012\r\n//\r\n// Description:\r\n// COM interface editor for the component editor.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"ComInterfaceEditor.h\"\r\n\r\n#include <KactusAPI/include/LibraryInterface.h>\r\n\r\n#include <IPXACTmodels/Component/Component.h>\r\n#include <IPXACTmodels/kactusExtensions/ComInterface.h>\r\n#include <IPXACTmodels/kactusExtensions/ComDefinition.h>\r\n\r\n#include <IPXACTmodels/common/DirectionTypes.h>\r\n\r\n#include <QApplication>\r\n#include <QFormLayout>\r\n#include <QGridLayout>\r\n#include <QHBoxLayout>\r\n#include <QMainWindow>\r\n#include <QLabel>\r\n#include <QScrollArea>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComInterfaceEditor::ComInterfaceEditor()\r\n//-----------------------------------------------------------------------------\r\nComInterfaceEditor::ComInterfaceEditor(LibraryInterface* libHandler,\r\n    QSharedPointer<Component> component,\r\n    QSharedPointer<ComInterface> comInterface,\r\n    QWidget *parent):\r\nItemEditor(component, libHandler, parent),\r\nlibInterface_(libHandler),\r\ncomIf_(comInterface),\r\nnameEditor_(comInterface, component->getRevision(), this, tr(\"Name and description\")),\r\ncomTypeEditor_(0),\r\ndetailsGroup_(tr(\"Details\"), this),\r\ntransferTypeCombo_(this),\r\ndirectionCombo_(this),\r\npropertyValueEditor_(this),\r\ncomImplementation_(0)\r\n{\r\n    // find the main window for VLNV editor\r\n    QWidget* parentWindow = nullptr;\r\n    for (QWidget * widget : QApplication::topLevelWidgets())\r\n    {\r\n        QMainWindow* mainWnd = dynamic_cast<QMainWindow*>(widget);\r\n        if (mainWnd)\r\n        {\r\n            parentWindow = mainWnd;\r\n            break;\r\n        }\r\n    }\r\n\r\n\tcomTypeEditor_ = new VLNVEditor(VLNV::COMDEFINITION, libHandler, parentWindow, this);\r\n\r\n\t// Set VLNV editor settings.\r\n\tcomTypeEditor_->setTitle(tr(\"COM definition\"));\r\n\tcomTypeEditor_->setMandatory(false);\r\n\r\n\tcomImplementation_ = new VLNVEditor(VLNV::COMPONENT, libHandler, parentWindow, this);\r\n\tcomImplementation_->setTitle(tr(\"COM interface implementation reference\"));\r\n\tcomImplementation_->setMandatory(false);\r\n\tcomImplementation_->addContentType(VLNV::DESIGN);\r\n\tcomImplementation_->addContentType(VLNV::DESIGNCONFIGURATION);\r\n\r\n    // Initialize the details group.\r\n    transferTypeCombo_.addItem(\"\");\r\n    transferTypeCombo_.setInsertPolicy(QComboBox::InsertAlphabetically);\r\n\r\n    directionCombo_.addItem(tr(\"in\"));\r\n    directionCombo_.addItem(tr(\"out\"));\r\n    directionCombo_.addItem(tr(\"inout\"));\r\n    directionCombo_.setCurrentIndex(0);\r\n    directionCombo_.setProperty(\"mandatoryField\", true);\r\n\r\n    setupLayout();\r\n\r\n\tconnect(&nameEditor_, SIGNAL(contentChanged()),\tthis, SIGNAL(contentChanged()), Qt::UniqueConnection);\r\n\t\r\n\tconnect(&transferTypeCombo_, SIGNAL(currentIndexChanged(int)),\r\n\t\tthis, SLOT(onTransferTypeChange()), Qt::UniqueConnection);\r\n\r\n\tconnect(&directionCombo_, SIGNAL(currentIndexChanged(int)),\r\n\t\tthis, SLOT(onDirectionChange(int)), Qt::UniqueConnection);\r\n\r\n\tconnect(&propertyValueEditor_, SIGNAL(contentChanged()),\r\n\t\tthis, SLOT(onPropertiesChange()), Qt::UniqueConnection);\r\n\r\n\tconnect(comTypeEditor_, SIGNAL(vlnvEdited()),\tthis, SLOT(onComDefinitionChanged()), Qt::UniqueConnection);\r\n\t\r\n\tconnect(comImplementation_, SIGNAL(vlnvEdited()), \r\n        this, SLOT(onComImplementationChange()), Qt::UniqueConnection);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComInterfaceEditor::isValid()\r\n//-----------------------------------------------------------------------------\r\nbool ComInterfaceEditor::isValid() const\r\n{\r\n    return (nameEditor_.isValid() &&\r\n        (comTypeEditor_->isEmpty() || (comTypeEditor_->isValid() && libInterface_->contains(comTypeEditor_->getVLNV()))) &&\r\n        (comImplementation_->isEmpty() || comImplementation_->isValid()));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComInterfaceEditor::onComDefinitionChanged()\r\n//-----------------------------------------------------------------------------\r\nvoid ComInterfaceEditor::onComDefinitionChanged()\r\n{\r\n    VLNV comDefinitionVLNV = comTypeEditor_->getVLNV();\r\n\r\n\tcomIf_->setComType(comDefinitionVLNV);\r\n\r\n\tdisconnect(&transferTypeCombo_, SIGNAL(currentIndexChanged(int)), this, SLOT(onTransferTypeChange()));\r\n\r\n    if (comDefinitionVLNV.isValid())\r\n    {\r\n        updateEditorsForComDefinition(comDefinitionVLNV);        \r\n    }\r\n    else if (comDefinitionVLNV.isEmpty())\r\n    {\r\n        clearEditors();\r\n    }\r\n\r\n\tconnect(&transferTypeCombo_, SIGNAL(currentIndexChanged(int)), \r\n        this, SLOT(onTransferTypeChange()), Qt::UniqueConnection);\r\n\r\n\temit contentChanged();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComInterfaceEditor::refresh()\r\n//-----------------------------------------------------------------------------\r\nvoid ComInterfaceEditor::refresh()\r\n{\r\n\tnameEditor_.refresh();\r\n\r\n\tVLNV comVLNV = comIf_->getComType();\r\n\t\r\n\tcomTypeEditor_->setVLNV(comVLNV);\r\n\tpropertyValueEditor_.setData(comIf_->getPropertyValues());\r\n\r\n\tcomImplementation_->setVLNV(comIf_->getComImplementation());\r\n\r\n\tdisconnect(&directionCombo_, SIGNAL(currentIndexChanged(int)), this, SLOT(onDirectionChange(int)));\r\n\tdirectionCombo_.setCurrentIndex(comIf_->getDirection());\r\n\tconnect(&directionCombo_, SIGNAL(currentIndexChanged(int)),\r\n\t\t\tthis, SLOT(onDirectionChange(int)), Qt::UniqueConnection);\r\n\r\n\tdisconnect(&transferTypeCombo_, SIGNAL(currentIndexChanged(int)), this, SLOT(onTransferTypeChange()));\r\n\r\n\tif (comVLNV.isValid())\r\n\t{\r\n\t\tupdateEditorsForComDefinition(comVLNV);\r\n\t}\r\n\telse if (comVLNV.isEmpty())\r\n\t{\r\n        clearEditors();\r\n\t}\r\n\r\n\tconnect(&transferTypeCombo_, SIGNAL(currentIndexChanged(int)),\r\n\t\tthis, SLOT(onTransferTypeChange()), Qt::UniqueConnection);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComInterfaceEditor::onTransferTypeChange()\r\n//-----------------------------------------------------------------------------\r\nvoid ComInterfaceEditor::onTransferTypeChange()\r\n{\r\n\tcomIf_->setTransferType(transferTypeCombo_.currentText());\r\n\temit contentChanged();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComInterfaceEditor::onDirectionChange()\r\n//-----------------------------------------------------------------------------\r\nvoid ComInterfaceEditor::onDirectionChange(int index)\r\n{\r\n\t comIf_->setDirection(static_cast<DirectionTypes::Direction>(index));\r\n\t emit contentChanged();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComInterfaceEditor::onPropertiesChange()\r\n//-----------------------------------------------------------------------------\r\nvoid ComInterfaceEditor::onPropertiesChange()\r\n{\r\n\tQMap<QString, QString> propertyValues = propertyValueEditor_.getData();\r\n\tcomIf_->setPropertyValues(propertyValues);\r\n\temit contentChanged();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComInterfaceEditor::onComImplementationChange()\r\n//-----------------------------------------------------------------------------\r\nvoid ComInterfaceEditor::onComImplementationChange()\r\n{\r\n    comIf_->setComImplementation(comImplementation_->getVLNV());\r\n    emit contentChanged();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComInterfaceEditor::showEvent()\r\n//-----------------------------------------------------------------------------\r\nvoid ComInterfaceEditor::showEvent(QShowEvent* event)\r\n{\r\n    QWidget::showEvent(event);\r\n    emit helpUrlRequested(\"componenteditor/cominterface.html\");\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComInterfaceEditor::setComDefinition()\r\n//-----------------------------------------------------------------------------\r\nvoid ComInterfaceEditor::updateEditorsForComDefinition(VLNV const& comDefinitionVLNV)\r\n{\r\n    // Retrieve the COM definition from the library.\r\n    QSharedPointer<Document const> libComp = libInterface_->getModelReadOnly(comDefinitionVLNV);\r\n    QSharedPointer<ComDefinition const> comDef = libComp.dynamicCast<ComDefinition const>();\r\n\r\n    if (comDef == 0)\r\n    {\r\n        emit errorMessage(\"COM definition with the given VLNV does not exist\");\r\n        return;\r\n    }\r\n\r\n    propertyValueEditor_.setAllowedProperties(comDef->getProperties());\r\n\r\n    QString type = comIf_->getTransferType();\r\n\r\n    transferTypeCombo_.clear();\r\n    transferTypeCombo_.addItem(\"\");\r\n    transferTypeCombo_.addItems(*comDef->getTransferTypes());\r\n\r\n    if (comDef->getTransferTypes()->contains(type))\r\n    {\r\n        transferTypeCombo_.setCurrentIndex(transferTypeCombo_.findText(type));\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComInterfaceEditor::clearComDefinition()\r\n//-----------------------------------------------------------------------------\r\nvoid ComInterfaceEditor::clearEditors()\r\n{\r\n    // Clear the allowed properties.\r\n    propertyValueEditor_.setAllowedProperties(QList<QSharedPointer<ComProperty> >());\r\n\r\n    // Clear the data type combo.\r\n    transferTypeCombo_.clear();\r\n    transferTypeCombo_.addItem(\"\");\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComInterfaceEditor::setupLayout()\r\n//-----------------------------------------------------------------------------\r\nvoid ComInterfaceEditor::setupLayout()\r\n{\r\n    QFormLayout* detailsLayout = new QFormLayout(&detailsGroup_);\r\n    detailsLayout->addRow(tr(\"Transfer type:\"), &transferTypeCombo_);\r\n    detailsLayout->addRow(tr(\"Direction:\"), &directionCombo_);\r\n\r\n    // Create the scroll area.\r\n    QScrollArea* scrollArea = new QScrollArea(this);\r\n    scrollArea->setWidgetResizable(true);\r\n    scrollArea->setFrameShape(QFrame::NoFrame);\r\n\r\n    QHBoxLayout* scrollLayout = new QHBoxLayout(this);\r\n    scrollLayout->addWidget(scrollArea);\r\n    scrollLayout->setContentsMargins(0, 0, 0, 0);\r\n\r\n    // Create the top widget and set it under the scroll area.\r\n    QWidget* topWidget = new QWidget(scrollArea);\r\n    topWidget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);\r\n\r\n    // Create the layout for the actual editor.\r\n    QGridLayout* layout = new QGridLayout(topWidget);\r\n    layout->addWidget(&nameEditor_, 0, 0, 2, 1);\r\n    layout->addWidget(comTypeEditor_, 0, 1, 1, 1);\r\n    layout->addWidget(comImplementation_, 1, 1, 1, 1);\r\n    layout->addWidget(&detailsGroup_, 2, 0, 1, 1);\r\n    layout->addWidget(&propertyValueEditor_, 3, 0, 1, 2);\r\n    layout->setContentsMargins(0, 0, 0, 0);\r\n\r\n    scrollArea->setWidget(topWidget);\r\n}\r\n"
  },
  {
    "path": "editors/ComponentEditor/software/comInterface/ComInterfaceEditor.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ComInterfaceEditor.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Joni-Matti Maatta\r\n// Date: 16.4.2012\r\n//\r\n// Description:\r\n// COM interface editor for the component editor.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef COMINTERFACEEDITOR_H\r\n#define COMINTERFACEEDITOR_H\r\n\r\n#include <editors/ComponentEditor/itemeditor.h>\r\n\r\n#include <common/widgets/vlnvEditor/vlnveditor.h>\r\n#include <common/widgets/nameGroupEditor/namegroupeditor.h>\r\n\r\n#include <editors/ComponentEditor/software/PropertyValueEditor.h>\r\n\r\n#include <QComboBox>\r\n#include <QGroupBox>\r\n#include <QSharedPointer>\r\n\r\nclass ComInterface;\r\nclass Component;\r\nclass LibraryInterface;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! COM interface editor.\r\n//-----------------------------------------------------------------------------\r\nclass ComInterfaceEditor : public ItemEditor\r\n{\r\n    Q_OBJECT\r\n\r\npublic:\r\n\r\n\t/*! The constructor\r\n\t *\r\n\t *    @param [in] libHandler      The instance that manages the library.\r\n\t *    @param [in] component       The component being edited.\r\n\t *    @param [in] comInterface    The COM interface being edited.\r\n\t *    @param [in] parent          The parent widget.\r\n\t *\r\n\t*/\r\n\tComInterfaceEditor(LibraryInterface* libHandler, QSharedPointer<Component> component, \r\n\t\tQSharedPointer<ComInterface> comInterface, QWidget *parent = 0);\r\n\r\n    /*!\r\n     *  Destructor.\r\n     */\r\n    virtual ~ComInterfaceEditor() = default;\r\n\r\n    // Disable copying.\r\n    ComInterfaceEditor(ComInterfaceEditor const& rhs) = delete;\r\n    ComInterfaceEditor& operator=(ComInterfaceEditor const& rhs) = delete;\r\n\r\n    /*!\r\n     *  Checks for the validity of the edited COM interface.\r\n     *\r\n\t *    @return True if the COM interface is in valid state.\r\n\t */\r\n\tbool isValid() const;\r\n\r\n\t/*! Reload the information from the model to the editor.\r\n\t*/\r\n\tvirtual void refresh();\r\n\r\nprotected:\r\n\r\n\t//! Handler for widget's show event\r\n\tvirtual void showEvent(QShowEvent* event);\r\n    \r\nprivate slots:\r\n\r\n    /*!\r\n     *  Called when the COM definition has been changed.\r\n     */\r\n    void onComDefinitionChanged();\r\n\r\n\t//! Handler for changes in transfer type.\r\n\tvoid onTransferTypeChange();\r\n\r\n\t//! Handler for changes in direction.\r\n\tvoid onDirectionChange(int index);\r\n\r\n\t//! Handler for changes in properties editor.\r\n\tvoid onPropertiesChange();\r\n\r\n\t//! Handler for changes in COM implementation reference.\r\n\tvoid onComImplementationChange();\r\n\r\nprivate:\r\n    \r\n    /*!\r\n     *  Updates the editors for showing values associated with the given COM definition.\r\n     *\r\n     *    @param [in] comDefinitionVLNV   The COM definition to update the editors for.\r\n     */\r\n    void updateEditorsForComDefinition(VLNV const& comDefinitionVLNV);\r\n    \r\n    //! Clears the editors when no COM definition has been set.\r\n    void clearEditors();\r\n\r\n    //! Sets the editor layout.\r\n    void setupLayout();\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! The library handler.\r\n    LibraryInterface* libInterface_;\r\n\r\n    //! The COM interface being edited.\r\n    QSharedPointer<ComInterface> comIf_;\r\n\r\n    //! Contains the name, display name and description of the COM interface.\r\n    NameGroupEditor nameEditor_;\r\n\r\n    //! Editor for setting the COM definition.\r\n    VLNVEditor* comTypeEditor_;\r\n\r\n    //! Details group box.\r\n    QGroupBox detailsGroup_;\r\n\r\n    //! Data type combo box.\r\n    QComboBox transferTypeCombo_;\r\n\r\n    //! Direction combo box.\r\n    QComboBox directionCombo_;\r\n\r\n    //! The property value editor.\r\n    PropertyValueEditor propertyValueEditor_;\r\n\r\n\t//! Editor to set the COM implementation reference.\r\n\t VLNVEditor* comImplementation_;\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n\r\n#endif // COMINTERFACEEDITOR_H\r\n"
  },
  {
    "path": "editors/ComponentEditor/software/comInterface/cominterfacesdelegate.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: cominterfacesdelegate.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 28.06.2012\r\n//\r\n// Description:\r\n// Delegate class for component COM interfaces.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"cominterfacesdelegate.h\"\r\n\r\n#include \"ComInterfaceColumns.h\"\r\n\r\n#include <QLineEdit>\r\n#include <QComboBox>\r\n#include <QStringList>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComInterfacesDelegate::ComInterfacesDelegate()\r\n//-----------------------------------------------------------------------------\r\nComInterfacesDelegate::ComInterfacesDelegate(QObject *parent):\r\nQStyledItemDelegate(parent)\r\n{\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComInterfacesDelegate::~ComInterfacesDelegate()\r\n//-----------------------------------------------------------------------------\r\nComInterfacesDelegate::~ComInterfacesDelegate()\r\n{\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComInterfacesDelegate::createEditor()\r\n//-----------------------------------------------------------------------------\r\nQWidget* ComInterfacesDelegate::createEditor(QWidget* parent, QStyleOptionViewItem const& option,\r\n    QModelIndex const& index) const\r\n{\r\n    if (index.column() == ComInterfaceColumns::NAME ||\r\n        index.column() == ComInterfaceColumns::DESCRIPTION)\r\n    {\r\n        QLineEdit* edit = new QLineEdit(parent);\r\n        connect(edit, SIGNAL(editingFinished()), this, SLOT(commitAndCloseEditor()), Qt::UniqueConnection);\r\n        return edit;\r\n    }\r\n    else if (index.column() == ComInterfaceColumns::COM_DEFINITION)\r\n    {\r\n        Q_ASSERT(false);\r\n        return 0;\r\n    }\r\n    else if (index.column() == ComInterfaceColumns::TRANSFER_TYPE)\r\n    {\r\n        QComboBox* combo = new QComboBox(parent);\r\n        return combo;\r\n    }\r\n    else if (index.column() == ComInterfaceColumns::DIRECTION)\r\n    {\r\n        QComboBox* combo = new QComboBox(parent);\r\n        combo->addItem(tr(\"in\"));\r\n        combo->addItem(tr(\"out\"));\r\n        combo->addItem(tr(\"inout\"));\r\n        combo->setCurrentIndex(0);\r\n        return combo;\r\n    }\r\n    else\r\n    {\r\n        return QStyledItemDelegate::createEditor(parent, option, index);\r\n    }\t\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComInterfacesDelegate::setEditorData()\r\n//-----------------------------------------------------------------------------\r\nvoid ComInterfacesDelegate::setEditorData(QWidget* editor, QModelIndex const& index) const\r\n{\r\n    if (index.column() == ComInterfaceColumns::NAME ||\r\n        index.column() == ComInterfaceColumns::DESCRIPTION)\r\n    {\r\n        QLineEdit* edit = qobject_cast<QLineEdit*>(editor);\r\n        Q_ASSERT(edit);\r\n\r\n        const QString text = index.data(Qt::DisplayRole).toString();\r\n        edit->setText(text);\r\n    }\r\n    else if (index.column() == ComInterfaceColumns::COM_DEFINITION)\r\n    {\r\n        Q_ASSERT(false);\r\n\r\n    }\r\n    else if (index.column() == ComInterfaceColumns::TRANSFER_TYPE)\r\n    {\r\n        QComboBox* combo = qobject_cast<QComboBox*>(editor);\r\n        Q_ASSERT(combo);\r\n\r\n        // remove the previous items\r\n        combo->clear();\r\n\r\n        // add the possible options for transfer types.\r\n        QStringList types = index.data(ComInterfaceColumns::TRANSFER_TYPE_OPTIONS).toStringList();\r\n        combo->addItem(\"\");\r\n        combo->addItems(types);\r\n\r\n        // select the right option\r\n        QString selected = index.data(Qt::DisplayRole).toString();\r\n        combo->setCurrentIndex(combo->findText(selected));\r\n    }\r\n    else if (index.column() == ComInterfaceColumns::DIRECTION)\r\n    {\r\n        QComboBox* combo = qobject_cast<QComboBox*>(editor);\r\n        Q_ASSERT(combo);\r\n\r\n        QString direction = index.data(Qt::DisplayRole).toString();\r\n        combo->setCurrentIndex(combo->findText(direction));\r\n    }\r\n    else\r\n    {\r\n        QStyledItemDelegate::setEditorData(editor, index);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComInterfacesDelegate::setModelData()\r\n//-----------------------------------------------------------------------------\r\nvoid ComInterfacesDelegate::setModelData( QWidget* editor, QAbstractItemModel* model, \r\n    QModelIndex const& index ) const\r\n{\r\n    if (index.column() == ComInterfaceColumns::NAME ||\r\n        index.column() == ComInterfaceColumns::DESCRIPTION)\r\n    {\r\n        QLineEdit* edit = qobject_cast<QLineEdit*>(editor);\r\n        Q_ASSERT(edit);\r\n\r\n        QString text = edit->text();\r\n        model->setData(index, text, Qt::EditRole);\r\n    }\r\n    else if (index.column() == ComInterfaceColumns::COM_DEFINITION)\r\n    {\r\n        Q_ASSERT(false);\r\n    }\r\n    else if (index.column() == ComInterfaceColumns::TRANSFER_TYPE)\r\n    {\r\n        QComboBox* combo = qobject_cast<QComboBox*>(editor);\r\n        Q_ASSERT(combo);\r\n\r\n        QString type = combo->currentText();\r\n        model->setData(index, type, Qt::EditRole);\r\n    }\r\n    else if (index.column() == ComInterfaceColumns::DIRECTION)\r\n    {\r\n        QComboBox* combo = qobject_cast<QComboBox*>(editor);\r\n        Q_ASSERT(combo);\r\n\r\n        QString dir = combo->currentText();\r\n        model->setData(index, dir, Qt::EditRole);\r\n    }\r\n    else\r\n    {\r\n        QStyledItemDelegate::setModelData(editor, model, index);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComInterfacesDelegate::commitAndCloseEditor()\r\n//-----------------------------------------------------------------------------\r\nvoid ComInterfacesDelegate::commitAndCloseEditor()\r\n{\r\n\tQWidget* edit = qobject_cast<QWidget*>(sender());\r\n\tQ_ASSERT(edit);\r\n\r\n\temit commitData(edit);\r\n\temit closeEditor(edit);\r\n}\r\n"
  },
  {
    "path": "editors/ComponentEditor/software/comInterface/cominterfacesdelegate.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: cominterfacesdelegate.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 28.06.2012\r\n//\r\n// Description:\r\n// Delegate class for component COM interfaces.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef COMINTERFACESDELEGATE_H\r\n#define COMINTERFACESDELEGATE_H\r\n\r\n#include <QStyledItemDelegate>\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Delegate class for component COM interfaces.\r\n//-----------------------------------------------------------------------------\r\nclass ComInterfacesDelegate : public QStyledItemDelegate\r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\r\n\t/*! The constructor.\r\n\t *\r\n\t *    @param [in] parent The owner of this delegate.\r\n\t*/\r\n\tComInterfacesDelegate(QObject *parent);\r\n\t\r\n\t//! The destructor\r\n\tvirtual ~ComInterfacesDelegate();\r\n\r\n\t/*! Create a new editor for the given item\r\n\t *\r\n\t *    @param [in] parent  Owner for the editor.\r\n\t *    @param [in] option  Contains options for the editor.\r\n\t *    @param [in] index   Model index identifying the item.\r\n\t *\r\n\t *    @return The editor to be used to edit the item.\r\n\t*/\r\n\tvirtual QWidget* createEditor(QWidget* parent, QStyleOptionViewItem const& option, \r\n        QModelIndex const& index) const;\r\n\r\n\t/*! Set the data for the editor.\r\n\t *\r\n\t *    @param [in] editor  The editor where the data is to be set.\r\n\t *    @param [in] index   Model index identifying the item that's data is to be set.\r\n\t*/\r\n\tvirtual void setEditorData(QWidget* editor, const QModelIndex& index) const;\r\n\r\n\t/*! Save the data from the editor to the model.\r\n\t *\r\n\t *    @param [in] editor  The editor that contains the data to store.\r\n\t *    @param [in] model   Model that contains the data structure where data is to be saved to.\r\n\t *    @param [in] index   Model index identifying the item that's data is to be saved.\r\n\t*/\r\n\tvirtual void setModelData(QWidget* editor, QAbstractItemModel* model, \r\n\t\tconst QModelIndex& index) const;\r\n\r\nprivate slots:\r\n\r\n\t//! Commit the data from the sending editor and close the editor.\r\n\tvoid commitAndCloseEditor();\r\n\r\nprivate:\r\n\t\r\n\t//! No copying\r\n\tComInterfacesDelegate(const ComInterfacesDelegate& other);\r\n\tComInterfacesDelegate& operator=(const ComInterfacesDelegate& other);\r\n};\r\n\r\n#endif // COMINTERFACESDELEGATE_H\r\n"
  },
  {
    "path": "editors/ComponentEditor/software/comInterface/cominterfaceseditor.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: cominterfaceseditor.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 28.06.2012\r\n//\r\n// Description:\r\n// The editor to add/remove/edit the COM interfaces of a component.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"cominterfaceseditor.h\"\r\n\r\n#include \"cominterfacesdelegate.h\"\r\n\r\n#include <common/widgets/summaryLabel/summarylabel.h>\r\n\r\n#include <KactusAPI/include/LibraryInterface.h>\r\n\r\n#include <IPXACTmodels/Component/Component.h>\r\n\r\n#include <QVBoxLayout>\r\n#include <QCoreApplication>\r\n#include <QMessageBox>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComInterfacesEditor::ComInterfacesEditor()\r\n//-----------------------------------------------------------------------------\r\nComInterfacesEditor::ComInterfacesEditor(LibraryInterface* libHandler, QSharedPointer<Component> component,\r\n    QWidget* parent):\r\nItemEditor(component, libHandler, parent),\r\n    view_(this),\r\n    proxy_(this),\r\n    model_(libHandler, component, this)\r\n{\r\n    // display a label on top the table\r\n    SummaryLabel* summaryLabel = new SummaryLabel(tr(\"COM interfaces summary\"), this, true);\r\n\r\n\tQVBoxLayout* layout = new QVBoxLayout(this);\r\n\tlayout->addWidget(summaryLabel, 0, Qt::AlignCenter);\r\n\tlayout->addWidget(&view_);\r\n\tlayout->setContentsMargins(0, 0, 0, 0);\r\n\r\n\tproxy_.setSourceModel(&model_);\r\n\tview_.setModel(&proxy_);\r\n\r\n\tconst QString componentPath = libHandler->getDirectoryPath(component->getVlnv());\r\n\tQString defaultPath = QString(\"%1/comIfListing.csv\").arg(componentPath);\r\n\tview_.setDefaultImportExportPath(defaultPath);\r\n\tview_.setAllowImportExport(true);\r\n\r\n\t// items can not be dragged\r\n\tview_.setItemsDraggable(false);\r\n    view_.viewport()->setAcceptDrops(true); \r\n    view_.setDropIndicatorShown(true);   \r\n    view_.setDragDropMode(QAbstractItemView::DropOnly);\r\n\tview_.setItemDelegate(new ComInterfacesDelegate(this));\r\n\r\n\tconnect(&model_, SIGNAL(contentChanged()), this, SIGNAL(contentChanged()), Qt::UniqueConnection);\r\n\tconnect(&model_, SIGNAL(comIfAdded(int)), this, SIGNAL(childAdded(int)), Qt::UniqueConnection);\r\n\tconnect(&model_, SIGNAL(comIfRemoved(int)), this, SIGNAL(childRemoved(int)), Qt::UniqueConnection);\r\n\tconnect(&model_, SIGNAL(stdRevisionMismatch()), this, SLOT(showStdRevisionMismatchWarning()), Qt::UniqueConnection);\r\n\r\n\tconnect(&view_, SIGNAL(addItem(const QModelIndex&)), \r\n        &model_, SLOT(onAddItem(const QModelIndex&)), Qt::UniqueConnection);\r\n\tconnect(&view_, SIGNAL(removeItem(const QModelIndex&)),\r\n\t\t&model_, SLOT(onRemoveItem(const QModelIndex&)), Qt::UniqueConnection);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComInterfacesEditor::~ComInterfacesEditor()\r\n//-----------------------------------------------------------------------------\r\nComInterfacesEditor::~ComInterfacesEditor()\r\n{\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComInterfacesEditor::isValid()\r\n//-----------------------------------------------------------------------------\r\nbool ComInterfacesEditor::isValid() const\r\n{\r\n\treturn model_.isValid();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComInterfacesEditor::refresh()\r\n//-----------------------------------------------------------------------------\r\nvoid ComInterfacesEditor::refresh()\r\n{\r\n\tview_.update();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComInterfacesEditor::showStdRevisionMismatchWarning()\r\n//-----------------------------------------------------------------------------\r\nvoid ComInterfacesEditor::showStdRevisionMismatchWarning()\r\n{\r\n    QMessageBox::warning(this, QCoreApplication::applicationName(),\r\n        tr(\"Dropped item cannot use different IP-XACT standard revision than the item being edited.\"),\r\n        QMessageBox::Close, QMessageBox::Close);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComInterfacesEditor::showEvent()\r\n//-----------------------------------------------------------------------------\r\nvoid ComInterfacesEditor::showEvent(QShowEvent* event)\r\n{\r\n\tQWidget::showEvent(event);\r\n\temit helpUrlRequested(\"componenteditor/cominterfaces.html\");\r\n}\r\n"
  },
  {
    "path": "editors/ComponentEditor/software/comInterface/cominterfaceseditor.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: cominterfaceseditor.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 28.06.2012\r\n//\r\n// Description:\r\n// The editor to add/remove/edit the COM interfaces of a component.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef COMINTERFACESEDITOR_H\r\n#define COMINTERFACESEDITOR_H\r\n\r\n#include \"cominterfacesmodel.h\"\r\n\r\n#include <editors/ComponentEditor/itemeditor.h>\r\n\r\n#include <common/views/EditableTableView/editabletableview.h>\r\n\r\n#include <QSharedPointer>\r\n#include <QSortFilterProxyModel>\r\n\r\nclass Component;\r\nclass LibraryInterface;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! The editor to add/remove/edit the COM interfaces of a component.\r\n//-----------------------------------------------------------------------------\r\nclass ComInterfacesEditor : public ItemEditor\r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\r\n\t//! The width of the name column.\r\n\tstatic const int NAME_COLUMN_WIDTH = 100;\r\n\r\n\t//! The width of the com definition column.\r\n\tstatic const int COM_DEF_COLUMN_WIDTH = 200;\r\n\r\n\t//! The width of the transfer type column.\r\n\tstatic const int TRANSFER_COLUMN_WIDTH = 100;\r\n\r\n\t//! The width of the direction column.\r\n\tstatic const int DIRECTION_COLUMN_WIDTH = 100;\r\n\r\n\t/*! The constructor\r\n\t *\r\n\t *    @param [in] libHandler The instance that manages the library.\r\n\t *    @param [in] component   The component being edited.\r\n\t *    @param [in] parent      The parent of this editor.\r\n\t *\r\n\t*/\r\n\tComInterfacesEditor(LibraryInterface* libHandler, QSharedPointer<Component> component, QWidget* parent = 0);\r\n\t\r\n\t//! The destructor\r\n\tvirtual ~ComInterfacesEditor();\r\n\r\n\t/*! Check for the validity of the editor\r\n\t* \r\n\t*    @return True if the editor is in valid state.\r\n\t*/\r\n\tvirtual bool isValid() const;\r\n\r\n\t/*! Reload the information from the model to the editor.\r\n\t*/\r\n\tvirtual void refresh();\r\n\r\npublic slots:\r\n\r\n\t/*!\r\n\t *  Displays warning message when trying to drag and drop an IP-XACT file using different standard revision\r\n\t *  than the component.\r\n\t */\r\n\tvoid showStdRevisionMismatchWarning();\r\n\r\nprotected:\r\n\r\n\t//! Handler for widget's show event\r\n\tvirtual void showEvent(QShowEvent* event);\r\n\r\nprivate:\r\n\t\r\n\t//! No copying\r\n\tComInterfacesEditor(const ComInterfacesEditor& other);\r\n\r\n\t//! No assignment\r\n\tComInterfacesEditor& operator=(const ComInterfacesEditor& other);\r\n\r\n\t//! The view to display the COM interfaces.\r\n\tEditableTableView view_;\r\n\r\n\t//! The model that does the sorting.\r\n\tQSortFilterProxyModel proxy_;\r\n\r\n\t//! The model that manages the COM interfaces.\r\n\tComInterfacesModel model_;\r\n};\r\n\r\n#endif // COMINTERFACESEDITOR_H\r\n"
  },
  {
    "path": "editors/ComponentEditor/software/comInterface/cominterfacesmodel.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: cominterfacesmodel.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 28.06.2012\r\n//\r\n// Description:\r\n// The model that manages the COM interfaces.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"cominterfacesmodel.h\"\r\n\r\n#include \"ComInterfaceColumns.h\"\r\n\r\n#include <KactusAPI/include/LibraryInterface.h>\r\n\r\n#include <IPXACTmodels/common/DirectionTypes.h>\r\n\r\n#include <IPXACTmodels/Component/Component.h>\r\n\r\n#include <IPXACTmodels/kactusExtensions/ComDefinition.h>\r\n#include <IPXACTmodels/kactusExtensions/ComInterface.h>\r\n#include <IPXACTmodels/common/VLNV.h>\r\n#include <IPXACTmodels/common/DocumentUtils.h>\r\n\r\n#include <common/KactusColors.h>\r\n\r\n\r\n#include <QMimeData>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComInterfacesModel::ComInterfacesModel()\r\n//-----------------------------------------------------------------------------\r\nComInterfacesModel::ComInterfacesModel(LibraryInterface* libHandler, QSharedPointer<Component> component,\r\n    QObject *parent):\r\nQAbstractTableModel(parent),\r\n    libHandler_(libHandler),\r\n    component_(component),\r\n    comIfs_(component->getComInterfaces())\r\n{\r\n    Q_ASSERT(component);\r\n    Q_ASSERT(libHandler_);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComInterfacesModel::rowCount()\r\n//-----------------------------------------------------------------------------\r\nint ComInterfacesModel::rowCount(QModelIndex const& parent) const\r\n{\r\n\tif (parent.isValid())\r\n    {\r\n\t\treturn 0;\r\n\t}\r\n\r\n\treturn comIfs_.size();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComInterfacesModel::columnCount()\r\n//-----------------------------------------------------------------------------\r\nint ComInterfacesModel::columnCount(QModelIndex const& parent) const\r\n{\r\n\tif (parent.isValid())\r\n    {\r\n\t\treturn 0;\r\n\t}\r\n\r\n\treturn ComInterfaceColumns::COLUMN_COUNT;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComInterfacesModel::flags()\r\n//-----------------------------------------------------------------------------\r\nQt::ItemFlags ComInterfacesModel::flags(QModelIndex const& index) const\r\n{\r\n\tif (!index.isValid())\r\n    {\r\n\t\treturn Qt::NoItemFlags;\r\n\t}\r\n\r\n\t// Com definition column can only be dropped..\r\n\tif (ComInterfaceColumns::COM_DEFINITION == index.column())\r\n    {\r\n\t\treturn Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsDropEnabled;\r\n\t}\r\n\r\n\treturn Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsEditable;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComInterfacesModel::headerData()\r\n//-----------------------------------------------------------------------------\r\nQVariant ComInterfacesModel::headerData( int section, Qt::Orientation orientation, int role) const\r\n{\r\n    if (orientation != Qt::Horizontal || role != Qt::DisplayRole) \r\n    {\r\n        return QVariant();\r\n    }\r\n\r\n    if (section == ComInterfaceColumns::NAME)\r\n    {\r\n        return tr(\"Name\");\r\n    }\r\n    else if (section == ComInterfaceColumns::DISPLAY_NAME)\r\n    {\r\n        return tr(\"Display name\");\r\n    }\r\n    else if (section == ComInterfaceColumns::COM_DEFINITION)\r\n    {\r\n        return tr(\"COM definition\");\r\n    }\r\n    else if (section == ComInterfaceColumns::TRANSFER_TYPE)\r\n    {\r\n        return tr(\"Transfer type\");\r\n    }\r\n    else if (section == ComInterfaceColumns::DIRECTION)\r\n    {\r\n        return tr(\"Direction\");\r\n    }\r\n    else if (section == ComInterfaceColumns::DESCRIPTION)\r\n    {\r\n        return tr(\"Description\");\r\n    }\r\n    else\r\n    {\r\n        return QVariant();\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComInterfacesModel::data()\r\n//-----------------------------------------------------------------------------\r\nQVariant ComInterfacesModel::data(QModelIndex const& index, int role) const\r\n{\r\n\tif (!index.isValid() || index.row() < 0 || index.row() >= comIfs_.size())\r\n    {\r\n\t\treturn QVariant();\r\n\t}\r\n\r\n\tif (role == Qt::DisplayRole)\r\n    {\r\n        if (index.column() == ComInterfaceColumns::NAME)\r\n        {\r\n            return comIfs_.at(index.row())->name();\r\n        }\r\n        else if (index.column() == ComInterfaceColumns::DISPLAY_NAME)\r\n        {\r\n            return comIfs_.at(index.row())->displayName();\r\n        }\r\n        else if (index.column() == ComInterfaceColumns::COM_DEFINITION)\r\n        {\r\n            return comIfs_.at(index.row())->getComType().toString(\":\");\r\n        }\r\n        else if (index.column() == ComInterfaceColumns::TRANSFER_TYPE)\r\n        {\r\n            return comIfs_.at(index.row())->getTransferType();\r\n        }\r\n        else if (index.column() == ComInterfaceColumns::DIRECTION)\r\n        {\r\n            return DirectionTypes::direction2Str(comIfs_.at(index.row())->getDirection());\r\n        }\r\n        else if (index.column() == ComInterfaceColumns::DESCRIPTION)\r\n        {\r\n            return comIfs_.at(index.row())->description();\r\n        }\r\n        else\r\n        {\r\n            return QVariant();\r\n        }\r\n\r\n    }\r\n    else if (role == ComInterfaceColumns::TRANSFER_TYPE_OPTIONS)\r\n    {\r\n        // find the vlnv of the com interface\r\n        VLNV comDefVLNV = comIfs_.at(index.row())->getComType();\r\n\r\n        // if the com def is not defined\r\n        if (!comDefVLNV.isValid() || !libHandler_->contains(comDefVLNV) || \r\n            libHandler_->getDocumentType(comDefVLNV) != VLNV::COMDEFINITION)\r\n        {\r\n            return QStringList();\r\n        }\r\n\r\n        // parse the com definition\r\n        QSharedPointer<Document const> libComp = libHandler_->getModelReadOnly(comDefVLNV);\r\n        const QSharedPointer<ComDefinition const> comDef = libComp.staticCast<ComDefinition const>();\r\n\r\n        // and return the transfer types specified in the com definition\r\n        return *comDef->getTransferTypes();\r\n    }\r\n    else if (role == Qt::ForegroundRole)\r\n    {\r\n        if (comIfs_.at(index.row())->isValid())\r\n        {\r\n            return KactusColors::REGULAR_TEXT;\r\n        }\r\n        else\r\n        {\r\n            return KactusColors::ERROR;\r\n        }\r\n    }\r\n    else if (role == Qt::BackgroundRole)\r\n    {\r\n        if (index.column() == ComInterfaceColumns::NAME ||\r\n            index.column() == ComInterfaceColumns::DIRECTION)\r\n        {\r\n            return KactusColors::MANDATORY_FIELD;\r\n        }\r\n        else\r\n        {\r\n            return KactusColors::REGULAR_FIELD;\r\n        }\r\n    }\r\n    else\r\n    {\r\n        return QVariant();\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComInterfacesModel::setData()\r\n//-----------------------------------------------------------------------------\r\nbool ComInterfacesModel::setData(QModelIndex const& index, const QVariant& value, int role)\r\n{\r\n\tif (!index.isValid() || index.row() < 0 || index.row() >= comIfs_.size() || role != Qt::EditRole)\r\n    {\r\n\t\treturn false;\r\n\t}\r\n\r\n    if (index.column() == ComInterfaceColumns::NAME)\r\n    {\r\n        comIfs_[index.row()]->setName(value.toString());\r\n    }\r\n    if (index.column() == ComInterfaceColumns::DISPLAY_NAME)\r\n    {\r\n        comIfs_[index.row()]->setDisplayName(value.toString());\r\n    }\r\n    else if (index.column() == ComInterfaceColumns::COM_DEFINITION)\r\n    {\r\n        VLNV comDef = VLNV(VLNV::COMDEFINITION, value.toString(), \":\");\r\n        comIfs_[index.row()]->setComType(comDef);\r\n    }\r\n    else if (index.column() == ComInterfaceColumns::TRANSFER_TYPE)\r\n    {\r\n        comIfs_[index.row()]->setTransferType(value.toString());\r\n    }\r\n    else if (index.column() == ComInterfaceColumns::DIRECTION)\r\n    {\r\n        comIfs_[index.row()]->setDirection(DirectionTypes::str2Direction(value.toString(), DirectionTypes::IN));\r\n    }\r\n    else if (index.column() == ComInterfaceColumns::DESCRIPTION)\r\n    {\r\n        comIfs_[index.row()]->setDescription(value.toString());\r\n    }\r\n    else\r\n    {\r\n        return false;\r\n    }\r\n\r\n    emit dataChanged(index, index);\r\n    emit contentChanged();\r\n    return true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComInterfacesModel::isValid()\r\n//-----------------------------------------------------------------------------\r\nbool ComInterfacesModel::isValid() const\r\n{\r\n\tforeach (QSharedPointer<ComInterface> comIf, comIfs_)\r\n    {\r\n\t\tif (!comIf->isValid())\r\n        {\r\n\t\t\treturn false;\r\n\t\t}\r\n\t}\r\n\r\n\treturn true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComInterfacesModel::supportedDropActions()\r\n//-----------------------------------------------------------------------------\r\nQt::DropActions ComInterfacesModel::supportedDropActions() const\r\n{\r\n    return Qt::CopyAction | Qt::MoveAction;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComInterfacesModel::mimeTypes()\r\n//-----------------------------------------------------------------------------\r\nQStringList ComInterfacesModel::mimeTypes() const\r\n{\r\n    QStringList types(QAbstractTableModel::mimeTypes());\r\n    types << \"application/x-qt-image\";\r\n    return types;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComInterfacesModel::dropMimeData()\r\n//-----------------------------------------------------------------------------\r\nbool ComInterfacesModel::dropMimeData(QMimeData const* data, Qt::DropAction action, int row, int column, \r\n    QModelIndex const& parent)\r\n{\r\n    if (action == Qt::IgnoreAction)\r\n    {\r\n        return true;\r\n    }\r\n\r\n    // Dropped data must be directly on parent.\r\n    if ( row != -1 || column != -1 || !parent.isValid() || row > rowCount())\r\n    {\r\n        return false;\r\n    }\r\n\r\n    QVariant variant = data->imageData();\r\n    if (!variant.canConvert<VLNV>())\r\n    {\r\n        return false;\r\n    }\r\n\r\n    VLNV vlnv = variant.value<VLNV>();\r\n\r\n    if (parent.column() == ComInterfaceColumns::COM_DEFINITION)\r\n    {\r\n        if (vlnv.getType() != VLNV::COMDEFINITION)\r\n        {\r\n            return false;\r\n        }\r\n\r\n        if (!DocumentUtils::documentsHaveMatchingStdRevisions(vlnv, component_->getVlnv(), libHandler_))\r\n        {\r\n            emit stdRevisionMismatch();\r\n            return false;\r\n        }\r\n\r\n        setData(index(parent.row(),parent.column()),vlnv.toString(\":\"));\r\n        emit contentChanged();\r\n    }\r\n\r\n    return true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComInterfacesModel::onAddItem()\r\n//-----------------------------------------------------------------------------\r\nvoid ComInterfacesModel::onAddItem(QModelIndex const& index)\r\n{\r\n\tint row = comIfs_.size();\r\n\r\n\t// if the index is valid then add the item to the correct position\r\n\tif (index.isValid())\r\n    {\r\n\t\trow = index.row();\r\n\t}\r\n\r\n\tbeginInsertRows(QModelIndex(), row, row);\r\n\tcomIfs_.insert(row, QSharedPointer<ComInterface>(new ComInterface()));\r\n    component_->setComInterfaces(comIfs_);\r\n\tendInsertRows();\r\n\r\n\t// inform navigation tree that COM interface is added\r\n\temit comIfAdded(row);\r\n\r\n\t// tell also parent widget that contents have been changed\r\n\temit contentChanged();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComInterfacesModel::onRemoveItem()\r\n//-----------------------------------------------------------------------------\r\nvoid ComInterfacesModel::onRemoveItem(QModelIndex const& index)\r\n{\r\n\t// don't remove anything if index is invalid\r\n\tif (!index.isValid() || index.row() < 0 || index.row() >= comIfs_.size())\r\n    {\r\n\t\treturn;\r\n\t}\r\n\r\n\t// remove the specified item\r\n\tbeginRemoveRows(QModelIndex(), index.row(), index.row());\r\n\tcomIfs_.removeAt(index.row());\r\n    component_->setComInterfaces(comIfs_);\r\n\tendRemoveRows();\r\n\r\n\t// inform navigation tree that COM interface has been removed\r\n\temit comIfRemoved(index.row());\r\n\r\n\t// tell also parent widget that contents have been changed\r\n\temit contentChanged();\r\n}\r\n"
  },
  {
    "path": "editors/ComponentEditor/software/comInterface/cominterfacesmodel.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: cominterfacesmodel.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 28.06.2012\r\n//\r\n// Description:\r\n// The model that manages the COM interfaces.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef COMINTERFACESMODEL_H\r\n#define COMINTERFACESMODEL_H\r\n\r\n#include <QAbstractTableModel>\r\n#include <QSharedPointer>\r\n#include <QList>\r\n\r\nclass ComInterface;\r\nclass Component;\r\nclass LibraryInterface;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! The model that manages the COM interfaces.\r\n//-----------------------------------------------------------------------------\r\nclass ComInterfacesModel : public QAbstractTableModel\r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\r\n\t/*! The constructor.\r\n\t *\r\n\t *    @param [in] libHandler  The instance that manages the library.\r\n\t *    @param [in] component   The component being edited.\r\n\t *    @param [in] parent      The owner of this model.\r\n\t *\r\n\t*/\r\n\tComInterfacesModel(LibraryInterface* libHandler, QSharedPointer<Component> component, QObject *parent);\r\n\t\r\n\t//! The destructor\r\n\tvirtual ~ComInterfacesModel() = default;\r\n\r\n    //! No copying\r\n    ComInterfacesModel(const ComInterfacesModel& other) = delete;\r\n\r\n    //! No assignment\r\n    ComInterfacesModel& operator=(const ComInterfacesModel& other) = delete;\r\n\r\n\t/*! Get the number of rows an item contains.\r\n\t *\r\n\t *    @param [in] parent Identifies the parent that's row count is requested.\r\n\t *\r\n\t *    @return Number of rows the item has.\r\n\t*/\r\n\tvirtual int rowCount(QModelIndex const& parent = QModelIndex()) const;\r\n\r\n\t/*! Get the number of columns the item has to be displayed.\r\n\t *\r\n\t *    @param [in] parent Identifies the parent that's column count is requested.\r\n\t *\r\n\t *    @return The number of columns to be displayed.\r\n\t*/\r\n\tvirtual int columnCount(QModelIndex const& parent = QModelIndex()) const;\r\n\r\n\t/*! Get the item flags that defines the possible operations for the item.\r\n\t *\r\n\t *    @param [in] index Model index that identifies the item.\r\n\t *\r\n\t *    @return Qt::ItemFlags specify the possible operations for the item.\r\n\t*/\r\n\tQt::ItemFlags flags(QModelIndex const& index) const;\r\n\r\n\t/*! Get the header data for specified header.\r\n\t *\r\n\t *    @param [in] section The section specifies the row/column number for the header.\r\n\t *    @param [in] orientation Specified if horizontal or vertical header is wanted.\r\n\t *    @param [in] role Specifies the type of the requested data.\r\n\t *\r\n\t *    @return QVariant Contains the requested data.\r\n\t*/\r\n\tvirtual QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;\r\n\r\n\t/*! Get the data for specified item.\r\n\t *\r\n\t *    @param [in] index Specifies the item that's data is requested.\r\n\t *    @param [in] role The role that defines what kind of data is requested.\r\n\t *\r\n\t *    @return QVariant Contains the data for the item.\r\n\t*/\r\n\tvirtual QVariant data(QModelIndex const& index, int role = Qt::DisplayRole) const;\r\n\r\n\t/*! Save the data to the model for specified item\r\n\t *\r\n\t *    @param [in] index The model index of the item that's data is to be saved.\r\n\t *    @param [in] value The data that is to be saved.\r\n\t *    @param [in] role The role specifies what kind of data should be saved.\r\n\t *\r\n\t *    @return True if saving happened successfully.\r\n\t*/\r\n\tbool setData(QModelIndex const& index, const QVariant& value, int role = Qt::EditRole);\r\n\r\n\t/*! Check if the COM interfaces model is in a valid state.\r\n\t *\r\n\t *    @return bool True if the state is valid and writing is possible.\r\n\t*/\r\n\tbool isValid() const;\r\n\r\n    /*!\r\n     *  Returns the supported actions of a drop.\r\n     *\r\n     *    @return The drop actions supported by the model.\r\n     */\r\n    Qt::DropActions supportedDropActions() const;\r\n\r\n    /*!\r\n     *  Returns a list of supported MIME data types.\r\n     *\r\n     *    @return The supported MIME types.\r\n     */\r\n    QStringList mimeTypes() const;\r\n\r\n    /*!\r\n     *  Handler for the dropped MIME data.\r\n     *\r\n     *    @param [in] data   The data associated to the drop.\r\n     *    @param [in] action The drop action.  \r\n     *    @param [in] row    The row beneath the drop position.\r\n     *    @param [in] column The column beneath the drop position.\r\n     *    @param [in] parent The parent index of the drop position.\r\n     *\r\n     *    @return True, if the model could handle the data, otherwise false.\r\n     */\r\n    bool dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, \r\n        const QModelIndex &parent);\r\n\r\npublic slots:\r\n\r\n\t/*! Add a new item to the given index.\r\n\t *\r\n\t *    @param [in] index The index identifying the position for new item.\r\n\t *\r\n\t*/\r\n\tvirtual void onAddItem(QModelIndex const& index);\r\n\r\n\t/*! Remove the item in the given index.\r\n\t *\r\n\t *    @param [in] index The index identifying the item to remove.\r\n\t *\r\n\t*/\r\n\tvirtual void onRemoveItem(QModelIndex const& index);\r\n\r\nsignals:\r\n\r\n\t//! Emitted when the contents of the model change.\r\n\tvoid contentChanged();\r\n\r\n\t/*! Emitted when a new COM interface is added to the model.\r\n\t *\r\n\t *    @param [in] index The index of the added COM interface.\r\n\t *\r\n\t*/\r\n\tvoid comIfAdded(int index);\r\n\r\n\t/*! Emitted when a COM interface is removed from the model.\r\n\t *\r\n\t *    @param [in] index The index of the COM interface to remove.\r\n\t *\r\n\t*/\r\n\tvoid comIfRemoved(int index);\r\n\r\n\t/*!\r\n\t *  Emitted when a com definition with different std revision than the component being edited\r\n\t *  is dropped in an com interface cell in the editor.\r\n\t */\r\n\tvoid stdRevisionMismatch() const;\r\n\r\nprivate:\r\n\r\n\t//! The instance that manages the library.\r\n\tLibraryInterface* libHandler_ = nullptr;\r\n\r\n    QSharedPointer<Component> component_ = nullptr;\r\n\r\n\t//! Contains the COM interfaces to edit.\r\n\tQList<QSharedPointer<ComInterface> > comIfs_;\r\n};\r\n\r\n#endif // COMINTERFACESMODEL_H\r\n"
  },
  {
    "path": "editors/ComponentEditor/software/systemView/SystemViewEditor.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: SystemViewEditor.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Joni-Matti Maatta\r\n// Date: 22.5.2012\r\n//\r\n// Description:\r\n// System view editor.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"SystemViewEditor.h\"\r\n\r\n#include <common/widgets/viewSelector/viewselector.h>\r\n\r\n#include <IPXACTmodels/kactusExtensions/SystemView.h>\r\n\r\n#include <QApplication>\r\n#include <QGroupBox>\r\n#include <QLabel>\r\n#include <QMainWindow>\r\n#include <QHBoxLayout>\r\n#include <QVBoxLayout>\r\n#include <QScrollArea>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SystemViewEditor::SystemViewEditor()\r\n//-----------------------------------------------------------------------------\r\nSystemViewEditor::SystemViewEditor(FileSetInterface* fileSetInterface, QSharedPointer<Component> component,\r\n    QSharedPointer<SystemView> systemView, LibraryInterface* libHandler, QWidget* parent):\r\nItemEditor(component, libHandler, parent), \r\n    view_(systemView.data()),\r\n    nameEditor_(systemView, component->getRevision(), this, tr(\"Name and description\")),\r\n    hierRefEditor_(NULL),\r\n    HWViewRefEditor_(NULL),\r\n    fileSetRefEditor_(NULL)\r\n{\r\n    // find the main window for VLNV editor\r\n    QWidget* parentWindow = nullptr;\r\n    for (QWidget * widget : QApplication::topLevelWidgets())\r\n    {\r\n        QMainWindow* mainWnd = dynamic_cast<QMainWindow*>(widget);\r\n        if (mainWnd)\r\n        {\r\n            parentWindow = mainWnd;\r\n            break;\r\n        }\r\n    }\r\n\r\n\thierRefEditor_ = new VLNVEditor(VLNV::DESIGNCONFIGURATION, libHandler, parentWindow, this);\r\n\thierRefEditor_->setTitle(tr(\"Hierarchy reference\"));\r\n    hierRefEditor_->setRevisionFilter(true, component->getRevision());\r\n\r\n    fileSetRefEditor_ = new FileSetRefEditor(fileSetInterface, tr(\"File set references\"), this);\r\n    fileSetRefEditor_->initialize();\r\n\r\n\tHWViewRefEditor_ = new ViewSelector(ViewSelector::BOTH_HW_VIEWS, component, this);\t\r\n\r\n    connect(&nameEditor_, SIGNAL(contentChanged()), this, SIGNAL(contentChanged()), Qt::UniqueConnection);\r\n    connect(hierRefEditor_, SIGNAL(vlnvEdited()), this, SLOT(onHierRefChange()), Qt::UniqueConnection);\r\n    connect(fileSetRefEditor_, SIGNAL(contentChanged()), this, SLOT(onFileSetRefChange()), Qt::UniqueConnection);\r\n    connect(HWViewRefEditor_, SIGNAL(viewSelected(QString const&)),\r\n        this, SLOT(onHWViewChange(QString const&)), Qt::UniqueConnection);\r\n     \r\n     refresh();\r\n\r\n     setupLayout();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SystemViewEditor::~SystemViewEditor()\r\n//-----------------------------------------------------------------------------\r\nSystemViewEditor::~SystemViewEditor()\r\n{\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SystemViewEditor::isValid()\r\n//-----------------------------------------------------------------------------\r\nbool SystemViewEditor::isValid() const\r\n{\r\n    if (!nameEditor_.isValid() || !hierRefEditor_->isValid())\r\n    {\r\n        return false;\r\n    }\r\n\r\n    // check the file set references that they are to valid file sets.\r\n    for (QString const& ref : fileSetRefEditor_->items())\r\n    {\r\n        // if the component does not contain the referenced file set.\r\n        if (!component()->hasFileSet(ref))\r\n        {\r\n            return false;\r\n        }\r\n    }\r\n\r\n    // if there is a HW view selected\r\n    QString selectedHWView = HWViewRefEditor_->currentText();\r\n    if (!selectedHWView.isEmpty())\r\n    {\r\n        // if the component does not contain the referenced view.\r\n        if (!component()->hasView(selectedHWView))\r\n        {\r\n            return false;\r\n        }\r\n    }\r\n\r\n    return true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SystemViewEditor::refresh()\r\n//-----------------------------------------------------------------------------\r\nvoid SystemViewEditor::refresh()\r\n{\r\n    nameEditor_.refresh();\r\n    hierRefEditor_->setVLNV(view_->getHierarchyRef());\r\n    HWViewRefEditor_->refresh();\r\n    HWViewRefEditor_->selectView(view_->getHWViewRef());\r\n    fileSetRefEditor_->setItems(view_->getFileSetRefs());\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SystemViewEditor::onHierRefChange()\r\n//-----------------------------------------------------------------------------\r\nvoid SystemViewEditor::onHierRefChange()\r\n{\r\n    view_->setHierarchyRef(hierRefEditor_->getVLNV());\r\n    emit contentChanged();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SystemViewEditor::showEvent()\r\n//-----------------------------------------------------------------------------\r\nvoid SystemViewEditor::showEvent(QShowEvent* event)\r\n{\r\n\tQWidget::showEvent(event);\r\n\temit helpUrlRequested(\"componenteditor/systemview.html\");\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SystemViewEditor::onFileSetRefChange()\r\n//-----------------------------------------------------------------------------\r\nvoid SystemViewEditor::onFileSetRefChange()\r\n{\r\n\tview_->setFileSetRefs(fileSetRefEditor_->items());\r\n\temit contentChanged();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SystemViewEditor::onHWViewChange()\r\n//-----------------------------------------------------------------------------\r\nvoid SystemViewEditor::onHWViewChange(QString const& /*viewName*/)\r\n{\r\n\tview_->setHWViewRef(HWViewRefEditor_->currentText());\r\n\temit contentChanged();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SystemViewEditor::setupLayout()\r\n//-----------------------------------------------------------------------------\r\nvoid SystemViewEditor::setupLayout()\r\n{\r\n    auto scrollArea = new QScrollArea(this);\r\n    scrollArea->setWidgetResizable(true);\r\n    scrollArea->setFrameShape(QFrame::NoFrame);\r\n\r\n    auto scrollLayout = new QHBoxLayout(this);\r\n    scrollLayout->addWidget(scrollArea);\r\n    scrollLayout->setContentsMargins(0, 0, 0, 0);\r\n\r\n    auto HWViewGroup = new QGroupBox(tr(\"HW View\"));\r\n    auto HWViewLabel = new QLabel(tr(\"Used HW view\"), HWViewGroup);\r\n    HWViewGroup->setFlat(true);\r\n\r\n    auto groupLayout = new QHBoxLayout(HWViewGroup);\r\n    groupLayout->addWidget(HWViewLabel, 0, Qt::AlignTop);\r\n    groupLayout->addWidget(HWViewRefEditor_, 0, Qt::AlignTop);\r\n    groupLayout->addStretch();\r\n    hierRefEditor_->setFlat(true);\r\n\r\n    auto topWidget = new QWidget(scrollArea);\r\n    topWidget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);\r\n    scrollArea->setWidget(topWidget);\r\n\r\n    auto topLayout = new QGridLayout(topWidget);\r\n    topLayout->addWidget(&nameEditor_, 0, 0, 2, 1);\r\n    topLayout->addWidget(hierRefEditor_, 0, 1, 1, 1, Qt::AlignTop);\r\n    topLayout->addWidget(HWViewGroup, 1, 1, 1, 1);\r\n    topLayout->addWidget(fileSetRefEditor_, 2, 0, 1, 1);\r\n    topLayout->setContentsMargins(0, 0, 0, 0);\r\n}\r\n"
  },
  {
    "path": "editors/ComponentEditor/software/systemView/SystemViewEditor.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: SystemViewEditor.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Joni-Matti Maatta\r\n// Date: 22.5.2012\r\n//\r\n// Description:\r\n// System view editor.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef SYSTEMVIEWEDITOR_H\r\n#define SYSTEMVIEWEDITOR_H\r\n\r\n#include <editors/ComponentEditor/itemeditor.h>\r\n#include <editors/ComponentEditor/instantiations/filesetrefeditor.h>\r\n\r\n#include <common/widgets/nameGroupEditor/namegroupeditor.h>\r\n#include <common/widgets/vlnvEditor/vlnveditor.h>\r\n\r\nclass SystemView;\r\nclass ViewSelector;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! System view editor.\r\n//-----------------------------------------------------------------------------\r\nclass SystemViewEditor : public ItemEditor\r\n{\r\n    Q_OBJECT\r\n\r\npublic:\r\n    /*!\r\n     *  Constructor.\r\n     *\r\n     *    @param [in] fileSetInterface    Interface for accessing file sets.\r\n     *    @param [in] component           The component being edited.\r\n     *    @param [in] systemView\t        The system view being edited.\r\n     *    @param [in] libHandler          The library handler.\r\n     *    @param [in] parent              The parent widget.\r\n     */\r\n\tSystemViewEditor(FileSetInterface* fileSetInterface, QSharedPointer<Component> component,\r\n        QSharedPointer<SystemView> systemView, LibraryInterface* libHandler, QWidget* parent);\r\n\r\n    //! The destructor.\r\n    virtual ~SystemViewEditor();\r\n\r\n    /*!\r\n     *  Checks for the validity of the edited API interface.\r\n     *\r\n\t *    @return True if the API interface is in valid state.\r\n\t */\r\n\tbool isValid() const;\r\n\r\n\t/*! Reload the information from the model to the editor.\r\n\t*/\r\n\tvirtual void refresh();\r\n\r\nprotected:\r\n\r\n\t//! Handler for widget's show event\r\n\tvirtual void showEvent(QShowEvent* event);\r\n\r\nprivate slots:\r\n\r\n\t//! Handler for changes in hierarchy reference.\r\n\tvoid onHierRefChange();\r\n\r\n\t//! Handler for changes in file set references.\r\n\tvoid onFileSetRefChange();\r\n\r\n\t//! Handler for changes in HW view.\r\n\tvoid onHWViewChange(const QString& viewName);\r\n\r\nprivate:\r\n    // Disable copying.\r\n    SystemViewEditor(SystemViewEditor const& rhs);\r\n    SystemViewEditor& operator=(SystemViewEditor const& rhs);\r\n\r\n    /*!\r\n     *  Setup the layout.\r\n     */\r\n    void setupLayout();\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! Pointer to the instance that manages the library.\r\n    LibraryInterface* libHandler_;\r\n\r\n    //! Pointer to the view being edited.\r\n    SystemView* view_;\r\n\r\n    //! Editor to set the name, display name and description of the view.\r\n    NameGroupEditor nameEditor_;\r\n\r\n    //! VLNV editor for the hierarchy reference.\r\n    VLNVEditor* hierRefEditor_;\r\n\r\n\t//! Editor to select the HW view.\r\n\t ViewSelector* HWViewRefEditor_;\r\n\r\n\t //! Editor to set the file set references of the system view.\r\n\t FileSetRefEditor* fileSetRefEditor_;\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n\r\n#endif // SYSTEMVIEWEDITOR_H\r\n"
  },
  {
    "path": "editors/ComponentEditor/software/systemView/SystemViewsDelegate.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: SystemViewsDelegate.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Joni-Matti Mtt\r\n// Date: 13.7.2012\r\n//\r\n// Description:\r\n// The delegate class that provides editors for editing system views.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"SystemViewsDelegate.h\"\r\n\r\n#include <QLineEdit>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SystemViewsDelegate::SystemViewsDelegate()\r\n//-----------------------------------------------------------------------------\r\nSystemViewsDelegate::SystemViewsDelegate(QObject *parent):\r\nQStyledItemDelegate(parent) \r\n{\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SystemViewsDelegate::~SystemViewsDelegate()\r\n//-----------------------------------------------------------------------------\r\nSystemViewsDelegate::~SystemViewsDelegate()\r\n{\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SystemViewsDelegate::createEditor()\r\n//-----------------------------------------------------------------------------\r\nQWidget* SystemViewsDelegate::createEditor(QWidget* parent, QStyleOptionViewItem const& option, \r\n    QModelIndex const& index) const\r\n{\r\n    if (index.column() == NAME_COLUMN || index.column() == DISPLAY_NAME_COLUMN ||\r\n        index.column() == DESCRIPTION_COLUMN)\r\n    {\r\n        QLineEdit* edit = new QLineEdit(parent);\r\n        connect(edit, SIGNAL(editingFinished()), this, SLOT(commitAndCloseEditor()), Qt::UniqueConnection);\r\n        return edit;\r\n    }\r\n    else if (index.column() == HIER_REF_COLUMN)\r\n    {\r\n        Q_ASSERT(false);\r\n        return 0;\r\n    }\r\n    else\r\n    {\r\n        return QStyledItemDelegate::createEditor(parent, option, index);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SystemViewsDelegate::setEditorData()\r\n//-----------------------------------------------------------------------------\r\nvoid SystemViewsDelegate::setEditorData(QWidget* editor, QModelIndex const& index) const\r\n{\r\n    if (index.column() == NAME_COLUMN || index.column() == DISPLAY_NAME_COLUMN ||\r\n        index.column() == DESCRIPTION_COLUMN)\r\n    {\r\n        QLineEdit* lineEditor = qobject_cast<QLineEdit*>(editor);\r\n        Q_ASSERT(lineEditor);\r\n\r\n        lineEditor->setText(index.data(Qt::DisplayRole).toString());\r\n    }\r\n    else if (index.column() == HIER_REF_COLUMN)\r\n    {\r\n        Q_ASSERT(false);\r\n    }\r\n    else\r\n    {\r\n        QStyledItemDelegate::setEditorData(editor, index);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SystemViewsDelegate::setModelData()\r\n//-----------------------------------------------------------------------------\r\nvoid SystemViewsDelegate::setModelData(QWidget* editor, QAbstractItemModel* model, QModelIndex const& index) const\r\n{\r\n    if (index.column() == NAME_COLUMN || index.column() == DISPLAY_NAME_COLUMN ||\r\n        index.column() == DESCRIPTION_COLUMN)\r\n    {\r\n        QLineEdit* lineEditor = qobject_cast<QLineEdit*>(editor);\r\n        Q_ASSERT(lineEditor);\r\n\r\n        model->setData(index, lineEditor->text(), Qt::EditRole);\r\n    }\r\n    else if (index.column() == HIER_REF_COLUMN)\r\n    {\r\n        Q_ASSERT(false);\r\n    }\r\n    else\r\n    {\r\n        QStyledItemDelegate::setModelData(editor, model, index);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SystemViewsDelegate::commitAndCloseEditor()\r\n//-----------------------------------------------------------------------------\r\nvoid SystemViewsDelegate::commitAndCloseEditor()\r\n{\r\n\tQWidget* edit = qobject_cast<QWidget*>(sender());\r\n\tQ_ASSERT(edit);\r\n\r\n\temit commitData(edit);\r\n\temit closeEditor(edit);\r\n}\r\n"
  },
  {
    "path": "editors/ComponentEditor/software/systemView/SystemViewsDelegate.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: SystemViewsDelegate.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Joni-Matti Mtt\r\n// Date: 13.7.2012\r\n//\r\n// Description:\r\n// The delegate class that provides editors for editing system views.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef SYSTEMVIEWSDELEGATE_H\r\n#define SYSTEMVIEWSDELEGATE_H\r\n\r\n#include <QStyledItemDelegate>\r\n\r\n//-----------------------------------------------------------------------------\r\n//! The delegate class that provides editors for editing system views.\r\n//-----------------------------------------------------------------------------\r\nclass SystemViewsDelegate : public QStyledItemDelegate\r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\r\n\t//! The column numbers for columns\r\n\tenum Column\r\n    {\r\n        NAME_COLUMN = 0,\r\n        DISPLAY_NAME_COLUMN,\r\n\t\tHIER_REF_COLUMN,\r\n\t\tDESCRIPTION_COLUMN,\r\n\t\tCOLUMN_COUNT\r\n\t};\r\n\r\n\t/*! The constructor.\r\n\t *\r\n\t *    @param [in] parent The owner of the delegate.\r\n\t*/\r\n\tSystemViewsDelegate(QObject *parent);\r\n\t\r\n\t//! The destructor.\r\n\tvirtual ~SystemViewsDelegate();\r\n\r\n\t/*! Create a new editor for the given item\r\n\t *\r\n\t *    @param [in] parent  Owner for the editor.\r\n\t *    @param [in] option  Contains options for the editor.\r\n\t *    @param [in] index   Model index identifying the item.\r\n\t *\r\n\t *    @return The editor to be used to edit the item.\r\n\t*/\r\n\tvirtual QWidget* createEditor(QWidget* parent, QStyleOptionViewItem const& option, \r\n\t\tQModelIndex const& index) const;\r\n\r\n\t/*! Set the data for the editor.\r\n\t *\r\n\t *    @param [in] editor  The editor where the data is to be set.\r\n\t *    @param [in] index    Model index identifying the item that's data is to be set.\r\n\t *\r\n\t*/\r\n\tvirtual void setEditorData(QWidget* editor, QModelIndex const& index) const;\r\n\r\n\t/*! Save the data from the editor to the model.\r\n\t *\r\n\t *    @param [in] editor  The editor that contains the data to store.\r\n\t *    @param [in] model   Model that contains the data structure where data is to be saved to.\r\n\t *    @param [in] index   Model index identifying the item that's data is to be saved.\r\n\t*/\r\n\tvirtual void setModelData(QWidget* editor, QAbstractItemModel* model, QModelIndex const& index) const;\r\n\r\nprivate slots:\r\n\r\n\t//! Commit the data from the sending editor and close the editor.\r\n\tvoid commitAndCloseEditor();\r\n\r\nprivate:\r\n\t\r\n\t//! No copying\r\n\tSystemViewsDelegate(const SystemViewsDelegate& other);\r\n\r\n\t//! No assignment\r\n\tSystemViewsDelegate& operator=(const SystemViewsDelegate& other);\r\n};\r\n\r\n#endif // SYSTEMVIEWSDELEGATE_H\r\n"
  },
  {
    "path": "editors/ComponentEditor/software/systemView/SystemViewsEditor.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: SystemViewsEditor.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Joni-Matti Maatta\r\n// Date: 13.7.2012\r\n//\r\n// Description:\r\n// The editor to add/remove/edit the system views of a component.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"SystemViewsEditor.h\"\r\n\r\n#include <KactusAPI/include/LibraryInterface.h>\r\n\r\n#include <common/widgets/summaryLabel/summarylabel.h>\r\n\r\n#include <IPXACTmodels/Component/Component.h>\r\n\r\n#include <QVBoxLayout>\r\n#include <QCoreApplication>\r\n#include <QMessageBox>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SystemViewsEditor::SystemViewsEditor()\r\n//-----------------------------------------------------------------------------\r\nSystemViewsEditor::SystemViewsEditor(QSharedPointer<Component> component, LibraryInterface* handler, \r\n    QWidget* parent):\r\nItemEditor(component, handler, parent),\r\n    view_(this),\r\n    proxy_(this),\r\n    model_(component, handler, this)\r\n{\r\n    // display a label on top the table\r\n\tSummaryLabel* summaryLabel = new SummaryLabel(tr(\"System views summary\"), this, true);\r\n\r\n\tQVBoxLayout* layout = new QVBoxLayout(this);\r\n\tlayout->addWidget(summaryLabel, 0, Qt::AlignCenter);\r\n\tlayout->addWidget(&view_);\r\n\tlayout->setContentsMargins(0, 0, 0, 0);\r\n\r\n\tproxy_.setSourceModel(&model_);\r\n\tview_.setModel(&proxy_);\r\n\r\n\tconst QString componentPath = handler->getDirectoryPath(component->getVlnv());\r\n\tQString defaultPath = QString(\"%1/sysViewListing.csv\").arg(componentPath);\r\n\tview_.setDefaultImportExportPath(defaultPath);\r\n\tview_.setAllowImportExport(true);\r\n\r\n\t// items can not be dragged\r\n\tview_.setItemsDraggable(false);\r\n    view_.viewport()->setAcceptDrops(true); \r\n    view_.setDropIndicatorShown(true);   \r\n    view_.setDragDropMode(QAbstractItemView::DropOnly);\r\n\r\n\tconnect(&model_, SIGNAL(contentChanged()), this, SIGNAL(contentChanged()), Qt::UniqueConnection);\r\n\tconnect(&model_, SIGNAL(viewAdded(int)), this, SIGNAL(childAdded(int)), Qt::UniqueConnection);\r\n\tconnect(&model_, SIGNAL(viewRemoved(int)), this, SIGNAL(childRemoved(int)), Qt::UniqueConnection);\r\n\tconnect(&model_, SIGNAL(stdRevisionMismatch()), this, SLOT(showStdRevisionMismatchWarning()), Qt::UniqueConnection);\r\n\r\n\tconnect(&view_, SIGNAL(addItem(const QModelIndex&)),\r\n\t\t&model_, SLOT(onAddItem(const QModelIndex&)), Qt::UniqueConnection);\r\n\tconnect(&view_, SIGNAL(removeItem(const QModelIndex&)),\r\n\t\t&model_, SLOT(onRemoveItem(const QModelIndex&)), Qt::UniqueConnection);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SystemViewsEditor::~SystemViewsEditor()\r\n//-----------------------------------------------------------------------------\r\nSystemViewsEditor::~SystemViewsEditor()\r\n{\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SystemViewsEditor::isValid()\r\n//-----------------------------------------------------------------------------\r\nbool SystemViewsEditor::isValid() const\r\n{\r\n\treturn model_.isValid();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SystemViewsEditor::refresh()\r\n//-----------------------------------------------------------------------------\r\nvoid SystemViewsEditor::refresh()\r\n{\r\n\tview_.update();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SystemViewsEditor::showStdRevisionMismatchWarning()\r\n//-----------------------------------------------------------------------------\r\nvoid SystemViewsEditor::showStdRevisionMismatchWarning()\r\n{\r\n    QMessageBox::warning(this, QCoreApplication::applicationName(),\r\n        tr(\"Dropped item cannot use different IP-XACT standard revision than the item being edited.\"),\r\n        QMessageBox::Close, QMessageBox::Close);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SystemViewsEditor::showEvent()\r\n//-----------------------------------------------------------------------------\r\nvoid SystemViewsEditor::showEvent(QShowEvent* event)\r\n{\r\n\tQWidget::showEvent(event);\r\n\temit helpUrlRequested(\"componenteditor/systemviews.html\");\r\n}\r\n"
  },
  {
    "path": "editors/ComponentEditor/software/systemView/SystemViewsEditor.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: SystemViewsEditor.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Joni-Matti Maatta\r\n// Date: 13.7.2012\r\n//\r\n// Description:\r\n// The editor to add/remove/edit the system views of a component.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef SYSTEMVIEWSEDITOR_H\r\n#define SYSTEMVIEWSEDITOR_H\r\n\r\n#include \"SystemViewsModel.h\"\r\n\r\n#include <common/views/EditableTableView/editabletableview.h>\r\n#include <editors/ComponentEditor/itemeditor.h>\r\n\r\n#include <QSortFilterProxyModel>\r\n\r\nclass LibraryInterface;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! The editor to add/remove/edit the system views of a component.\r\n//-----------------------------------------------------------------------------\r\nclass SystemViewsEditor : public ItemEditor\r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\r\n\t//! The width of the name column\r\n\tstatic const int NAME_COLUMN_WIDTH = 100;\r\n\r\n\t//! The width of the bus definition column.\r\n\tstatic const int HIER_REF_COLUMN_WIDTH = 200;\r\n\r\n\t/*! The constructor\r\n\t *\r\n\t *    @param [in] component The component being edited.\r\n\t *    @param [in] handler The instance managing library.\r\n\t *    @param [in] parent The parent of this editor.\r\n\t*/\r\n\tSystemViewsEditor(QSharedPointer<Component> component, LibraryInterface* handler, QWidget* parent = 0);\r\n\t\r\n\t//! The destructor\r\n\tvirtual ~SystemViewsEditor();\r\n\r\n\t/*! Check for the validity of the editor\r\n\t* \r\n\t*    @return True if the editor is in valid state.\r\n\t*/\r\n\tvirtual bool isValid() const;\r\n\r\n\t/*! Reload the information from the model to the editor.\r\n\t*/\r\n\tvirtual void refresh();\r\n\r\npublic slots:\r\n\r\n\t/*!\r\n\t *  Displays warning message when trying to drag and drop a hierarchy reference using different standard revision\r\n\t *  than the system design being edited.\r\n\t */\r\n\tvoid showStdRevisionMismatchWarning();\r\n\r\nprotected:\r\n\r\n\t//! Handler for widget's show event\r\n\tvirtual void showEvent(QShowEvent* event);\r\n\r\nprivate:\r\n\t\r\n\t//! No copying\r\n\tSystemViewsEditor(const SystemViewsEditor& other);\r\n\r\n\t//! No assignment\r\n\tSystemViewsEditor& operator=(const SystemViewsEditor& other);\r\n\r\n\t//! The view that displays the summary of the bus interfaces.\r\n\tEditableTableView view_;\r\n\r\n\t//! The model that does the sorting of items.\r\n\tQSortFilterProxyModel proxy_;\r\n\r\n\t//! The model that manages the system views.\r\n\tSystemViewsModel model_;\r\n};\r\n\r\n#endif // SYSTEMVIEWSEDITOR_H\r\n"
  },
  {
    "path": "editors/ComponentEditor/software/systemView/SystemViewsModel.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: SystemViewsModel.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Joni-Matti Maatta\r\n// Date: 13.7.2012\r\n//\r\n// Description:\r\n// The model to manage system views for a table view.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"SystemViewsModel.h\"\r\n#include \"SystemViewsDelegate.h\"\r\n\r\n#include <IPXACTmodels/Component/Component.h>\r\n#include <IPXACTmodels/common/VLNV.h>\r\n#include <IPXACTmodels/common/DocumentUtils.h>\r\n\r\n#include <IPXACTmodels/kactusExtensions/SystemView.h>\r\n\r\n#include <KactusAPI/include/LibraryInterface.h>\r\n\r\n#include <common/KactusColors.h>\r\n\r\n\r\n#include <QMimeData>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SystemViewsModel::SystemViewsModel()\r\n//-----------------------------------------------------------------------------\r\nSystemViewsModel::SystemViewsModel(QSharedPointer<Component> component, LibraryInterface* library, QObject* parent) :\r\nQAbstractTableModel(parent),\r\n    views_(component->getSystemViews()),\r\n    component_(component),\r\n    library_(library)\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SystemViewsModel::~SystemViewsModel()\r\n//-----------------------------------------------------------------------------\r\nSystemViewsModel::~SystemViewsModel()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SystemViewsModel::SystemViewsModel()\r\n//-----------------------------------------------------------------------------\r\nint SystemViewsModel::rowCount(QModelIndex const& parent) const\r\n{\r\n\tif (parent.isValid()) \r\n    {\r\n\t\treturn 0;\r\n\t}\r\n\r\n\treturn views_.size();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SystemViewsModel::columnCount()\r\n//-----------------------------------------------------------------------------\r\nint SystemViewsModel::columnCount(QModelIndex const& parent) const\r\n{\r\n\tif (parent.isValid())\r\n    {\r\n\t\treturn 0;\r\n\t}\r\n\r\n\treturn SystemViewsDelegate::COLUMN_COUNT;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SystemViewsModel::columnCount()\r\n//-----------------------------------------------------------------------------\r\nQt::ItemFlags SystemViewsModel::flags(QModelIndex const& index) const\r\n{\r\n\tif (!index.isValid())\r\n    {\r\n\t\treturn Qt::NoItemFlags;\r\n\t}\r\n\t// hierarchy reference can only be dropped.\r\n\telse if (index.column() == SystemViewsDelegate::HIER_REF_COLUMN)\r\n    {\r\n\t\treturn Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsDropEnabled;\r\n\t}\r\n\r\n\treturn Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsEditable;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SystemViewsModel::headerData()\r\n//-----------------------------------------------------------------------------\r\nQVariant SystemViewsModel::headerData(int section, Qt::Orientation orientation, int role) const\r\n{\r\n\tif (orientation != Qt::Horizontal || role != Qt::DisplayRole)\r\n    {\r\n\t\treturn QVariant();\r\n\t}\r\n\r\n    if (section == SystemViewsDelegate::NAME_COLUMN)\r\n    {\r\n        return tr(\"Name\");\r\n    }\r\n    else if (section == SystemViewsDelegate::HIER_REF_COLUMN)\r\n    {\r\n        return tr(\"Hierarchy reference\");\r\n    }\r\n    else if (section == SystemViewsDelegate::DISPLAY_NAME_COLUMN)\r\n    {\r\n        return tr(\"Display name\");\r\n    }\r\n    else if (section == SystemViewsDelegate::DESCRIPTION_COLUMN)\r\n    {\r\n        return tr(\"Description\");\r\n    }\r\n    else\r\n    {\r\n        return QVariant();\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SystemViewsModel::data()\r\n//-----------------------------------------------------------------------------\r\nQVariant SystemViewsModel::data(QModelIndex const& index, int role) const\r\n{\r\n\tif (!index.isValid() || index.row() < 0 || index.row() >= views_.size())\r\n    {\r\n\t\treturn QVariant();\r\n\t}\r\n\t\r\n\tif (role == Qt::DisplayRole || role == Qt::EditRole)\r\n    {\r\n        if (index.column() == SystemViewsDelegate::NAME_COLUMN)\r\n        {\r\n            return views_.at(index.row())->name();\r\n        }\r\n        else if (index.column() == SystemViewsDelegate::HIER_REF_COLUMN)\r\n        {\r\n            return views_.at(index.row())->getHierarchyRef().toString(\":\");\r\n        }\r\n        else if (index.column() == SystemViewsDelegate::DISPLAY_NAME_COLUMN)\r\n        {\r\n            return views_.at(index.row())->displayName();\r\n        }\r\n        else if (index.column() == SystemViewsDelegate::DESCRIPTION_COLUMN)\r\n        {\r\n            return views_.at(index.row())->description();\r\n        }\r\n        else\r\n        {\r\n            return QVariant();\r\n        }\r\n    }\r\n\r\n    else if (role == Qt::ForegroundRole)\r\n    {\r\n        QStringList fileSetNames = component_->getFileSetNames();\r\n\t\tQStringList viewNames = component_->getViewNames();\r\n\r\n\t\tif (views_.at(index.row())->isValid(fileSetNames, viewNames))\r\n        {\r\n\t\t\treturn KactusColors::REGULAR_TEXT;\r\n\t\t}\r\n\t\telse\r\n        {\r\n\t\t\treturn KactusColors::ERROR;\r\n\t\t}\r\n\t}\r\n\r\n    else if (role == Qt::BackgroundRole)\r\n    {\r\n        if (index.column() == SystemViewsDelegate::NAME_COLUMN || \r\n            index.column() == SystemViewsDelegate::HIER_REF_COLUMN)\r\n        {\r\n            return KactusColors::MANDATORY_FIELD;\r\n        }\r\n        else\r\n        {\r\n            return KactusColors::REGULAR_FIELD;\r\n        }\r\n    }\r\n    else\r\n    {\r\n        return QVariant();\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SystemViewsModel::setData()\r\n//-----------------------------------------------------------------------------\r\nbool SystemViewsModel::setData(QModelIndex const& index, const QVariant& value, int role)\r\n{\r\n\tif (!index.isValid() || index.row() < 0 || index.row() >= views_.size())\r\n    {\r\n\t\treturn false;\r\n\t}\r\n\r\n    if (role == Qt::EditRole)\r\n    {\r\n        QSharedPointer<SystemView> targetSystemView = views_.at(index.row());\r\n\r\n        if (index.column() == SystemViewsDelegate::NAME_COLUMN)\r\n        {\r\n            targetSystemView->setName(value.toString());\r\n        }\r\n        else if (index.column() == SystemViewsDelegate::HIER_REF_COLUMN)\r\n        {\r\n            VLNV hierRef = VLNV(VLNV::DESIGNCONFIGURATION, value.toString(), \":\");\r\n            targetSystemView->setHierarchyRef(hierRef);\r\n        }\r\n        else if (index.column() == SystemViewsDelegate::DISPLAY_NAME_COLUMN)\r\n        {\r\n            targetSystemView->setDisplayName(value.toString());\r\n        }\r\n        else if (index.column() == SystemViewsDelegate::DESCRIPTION_COLUMN)\r\n        {\r\n            targetSystemView->setDescription(value.toString());\r\n        }\r\n        else\r\n        {\r\n            return false;\r\n        }\r\n\r\n        emit dataChanged(index, index);\r\n        emit contentChanged();\r\n        return true;\r\n    }\r\n    else\r\n    {\r\n        return false;\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SystemViewsModel::isValid()\r\n//-----------------------------------------------------------------------------\r\nbool SystemViewsModel::isValid() const\r\n{\r\n\tQStringList fileSetNames = component_->getFileSetNames();\r\n\tQStringList viewNames = component_->getViewNames();\r\n\r\n\t// check that each software view is valid\r\n\tforeach (QSharedPointer<SystemView> swView, views_)\r\n    {\r\n\t\tif (!swView->isValid(fileSetNames, viewNames))\r\n        {\r\n\t\t\treturn false;\r\n\t\t}\r\n\t}\r\n\treturn true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SystemViewsModel::supportedDropActions()\r\n//-----------------------------------------------------------------------------\r\nQt::DropActions SystemViewsModel::supportedDropActions() const\r\n{\r\n    return Qt::CopyAction | Qt::MoveAction;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SystemViewsModel::mimeTypes()\r\n//-----------------------------------------------------------------------------\r\nQStringList SystemViewsModel::mimeTypes() const\r\n{\r\n    QStringList types(QAbstractTableModel::mimeTypes());\r\n    types << \"application/x-qt-image\";\r\n    return types;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SystemViewsModel::dropMimeData()\r\n//-----------------------------------------------------------------------------\r\nbool SystemViewsModel::dropMimeData(QMimeData const* data, Qt::DropAction action, int row, int column, \r\n    QModelIndex const& parent)\r\n{\r\n    if (action == Qt::IgnoreAction)\r\n    {\r\n        return true;\r\n    }\r\n\r\n    // Dropped data must be directly on parent.\r\n    if (row != -1 || column != -1 || !parent.isValid() || row > rowCount())\r\n    {\r\n        return false;\r\n    }\r\n\r\n    QVariant variant = data->imageData();\r\n    if (!variant.canConvert<VLNV>())\r\n    {\r\n        return false;\r\n    }\r\n\r\n    VLNV vlnv = variant.value<VLNV>();\r\n\r\n    if (parent.column() == SystemViewsDelegate::HIER_REF_COLUMN)\r\n    {\r\n        if (vlnv.getType() != VLNV::DESIGNCONFIGURATION)\r\n        {\r\n            return false;\r\n        }\r\n\r\n        if (!DocumentUtils::documentsHaveMatchingStdRevisions(vlnv, component_->getVlnv(), library_))\r\n        {\r\n            emit stdRevisionMismatch();\r\n            return false;\r\n        }\r\n\r\n        setData(index(parent.row(),parent.column()),vlnv.toString(\":\"));\r\n        emit contentChanged();\r\n    }\r\n\r\n    return true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SystemViewsModel::onAddItem()\r\n//-----------------------------------------------------------------------------\r\nvoid SystemViewsModel::onAddItem(QModelIndex const& index)\r\n{\r\n\tint row = views_.size();\r\n\r\n\t// if the index is valid then add the item to the correct position\r\n\tif (index.isValid())\r\n    {\r\n\t\trow = index.row();\r\n\t}\r\n\r\n\tbeginInsertRows(QModelIndex(), row, row);\r\n\tviews_.insert(row, QSharedPointer<SystemView>(new SystemView()));\r\n    component_->setSystemViews(views_);\r\n\tendInsertRows();\r\n\r\n\temit viewAdded(row);\r\n\temit contentChanged();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SystemViewsModel::onRemoveItem()\r\n//-----------------------------------------------------------------------------\r\nvoid SystemViewsModel::onRemoveItem(QModelIndex const& index)\r\n{\r\n\t// don't remove anything if index is invalid\r\n\tif (!index.isValid() || index.row() < 0 || index.row() >= views_.size())\r\n    {\r\n\t\treturn;\r\n\t}\r\n\r\n\t// remove the specified item\r\n\tbeginRemoveRows(QModelIndex(), index.row(), index.row());\r\n\tviews_.removeAt(index.row());\r\n    component_->setSystemViews(views_);\r\n\tendRemoveRows();\r\n\r\n\temit viewRemoved(index.row());\r\n\temit contentChanged();\r\n}\r\n"
  },
  {
    "path": "editors/ComponentEditor/software/systemView/SystemViewsModel.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: SystemViewsModel.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Joni-Matti Maatta\r\n// Date: 13.7.2012\r\n//\r\n// Description:\r\n// The model to manage system views for a table view.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef SYSTEMVIEWSMODEL_H\r\n#define SYSTEMVIEWSMODEL_H\r\n\r\n#include <QAbstractTableModel>\r\n#include <QSortFilterProxyModel>\r\n#include <QSharedPointer>\r\n\r\nclass Component;\r\nclass SystemView;\r\nclass LibraryInterface;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! The model to manage the system views for a table view\r\n//-----------------------------------------------------------------------------\r\nclass SystemViewsModel : public QAbstractTableModel\r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\r\n\t/*! The constructor\r\n\t *\r\n\t *    @param [in] component\tThe component being edited.\r\n\t *    @param [in] library\t\tThe library interface.\r\n\t *    @param [in] parent\t\tThe owner of the model.\r\n\t*/\r\n\tSystemViewsModel(QSharedPointer<Component> component, LibraryInterface* library, QObject* parent);\r\n\t\r\n\t//! The destructor\r\n\tvirtual ~SystemViewsModel();\r\n\r\n\t/*! Get the number of rows an item contains.\r\n\t *\r\n\t *    @param [in] parent Identifies the parent that's row count is requested.\r\n\t *\r\n\t *    @return Number of rows the item has.\r\n\t*/\r\n\tvirtual int rowCount(const QModelIndex& parent = QModelIndex()) const;\r\n\r\n\t/*! Get the number of columns the item has to be displayed.\r\n\t *\r\n\t *    @param [in] parent Identifies the parent that's column count is requested.\r\n\t *\r\n\t *    @return The number of columns to be displayed.\r\n\t*/\r\n\tvirtual int columnCount(const QModelIndex& parent = QModelIndex()) const;\r\n\r\n\t/*! Get the item flags that defines the possible operations for the item.\r\n\t *\r\n\t *    @param [in] index Model index that identifies the item.\r\n\t *\r\n\t *    @return Qt::ItemFlags specify the possible operations for the item.\r\n\t*/\r\n\tQt::ItemFlags flags(const QModelIndex& index) const;\r\n\r\n\t/*! Get the header data for specified header.\r\n\t *\r\n\t *    @param [in] section         The section specifies the row/column number for the header.\r\n\t *    @param [in] orientation     Specified if horizontal or vertical header is wanted.\r\n\t *    @param [in] role            Specifies the type of the requested data.\r\n\t *\r\n\t *    @return QVariant Contains the requested data.\r\n\t*/\r\n\tvirtual QVariant headerData(int section, Qt::Orientation orientation, \r\n\t\tint role = Qt::DisplayRole) const;\r\n\r\n\t/*! Get the data for specified item.\r\n\t *\r\n\t *    @param [in] index   Specifies the item that's data is requested.\r\n\t *    @param [in] role    The role that defines what kind of data is requested.\r\n\t *\r\n\t *    @return QVariant Contains the data for the item.\r\n\t*/\r\n\tvirtual QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const;\r\n\r\n\t/*! Save the data to the model for specified item\r\n\t *\r\n\t *    @param [in] index   The model index of the item that's data is to be saved.\r\n\t *    @param [in] value   The data that is to be saved.\r\n\t *    @param [in] role    The role specifies what kind of data should be saved.\r\n\t *\r\n\t *    @return True if saving happened successfully.\r\n\t*/\r\n\tbool setData(const QModelIndex& index, const QVariant& value, \r\n\t\tint role = Qt::EditRole);\r\n\r\n\t/*! Check if the software views model is in a valid state.\r\n\t *\r\n\t *    @return bool True if the state is valid and writing is possible.\r\n\t*/\r\n\tbool isValid() const;\r\n\r\n    /*!\r\n     *  Returns the supported actions of a drop.\r\n     *\r\n     *    @return The drop actions supported by the model.\r\n     */\r\n    Qt::DropActions supportedDropActions() const;\r\n\r\n    /*!\r\n     *  Returns a list of supported MIME data types.\r\n     *\r\n     *    @return The supported MIME types.\r\n     */\r\n    QStringList mimeTypes() const;\r\n\r\n    /*!\r\n     *  Handler for the dropped MIME data.\r\n     *\r\n     *    @param [in] data   The data associated to the drop.\r\n     *    @param [in] action The drop action.  \r\n     *    @param [in] row    The row beneath the drop position.\r\n     *    @param [in] column The column beneath the drop position.\r\n     *    @param [in] parent The parent index of the drop position.\r\n     *\r\n     *    @return True, if the model could handle the data, otherwise false.\r\n     */\r\n    bool dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, \r\n        const QModelIndex &parent);\r\n\r\npublic slots:\r\n\r\n\t/*! Add a new item to the given index.\r\n\t *\r\n\t *    @param [in] index The index identifying the position for new item.\r\n\t *\r\n\t*/\r\n\tvirtual void onAddItem(const QModelIndex& index);\r\n\r\n\t/*! Remove the item in the given index.\r\n\t *\r\n\t *    @param [in] index The index identifying the item to remove.\r\n\t *\r\n\t*/\r\n\tvirtual void onRemoveItem(const QModelIndex& index);\r\n\r\nsignals:\r\n\r\n\t//! Emitted when the contents of the model changes.\r\n\tvoid contentChanged();\r\n\r\n\t/*! Emitted when a new software view is added to the model.\r\n\t *\r\n\t *    @param [in] index The index of the added software view.\r\n\t *\r\n\t*/\r\n\tvoid viewAdded(int index);\r\n\r\n\t/*! Emitted when a view is removed from the model.\r\n\t *\r\n\t *    @param [in] index The index of the software view to remove.\r\n\t *\r\n\t*/\r\n\tvoid viewRemoved(int index);\r\n\r\n\t/*!\r\n\t *  Emitted when a system design config with different std revision than the system design component \r\n\t *  is dropped in a hierarchy reference cell in the editor.\r\n\t */\r\n\tvoid stdRevisionMismatch() const;\r\n\r\nprivate:\r\n\t\r\n\t//! No copying\r\n\tSystemViewsModel(const SystemViewsModel& other);\r\n\r\n\t//! No assignment\r\n\tSystemViewsModel& operator=(const SystemViewsModel& other);\r\n\r\n\t//! Contains the software views to edit.\r\n\tQList<QSharedPointer<SystemView> > views_;\r\n\r\n\t//! The component being edited.\r\n\tQSharedPointer<Component> component_;\r\n\r\n\t//! The library handler.\r\n\tLibraryInterface* library_;\r\n};\r\n\r\n#endif // SYSTEMVIEWSMODEL_H\r\n"
  },
  {
    "path": "editors/ComponentEditor/treeStructure/ComponentEditorChoicesItem.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ComponentEditorChoicesItem.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: \r\n// Date: \r\n//\r\n// Description:\r\n// The choices item in the component editor navigation tree.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"ComponentEditorChoicesItem.h\"\r\n\r\n#include <KactusAPI/include/ExpressionParser.h>\r\n#include <editors/ComponentEditor/choices/ChoicesEditor.h>\r\n\r\n#include <IPXACTmodels/Component/Component.h>\r\n#include <IPXACTmodels/common/Choice.h>\r\n#include <IPXACTmodels/common/validators/ChoiceValidator.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditorChoicesItem::ComponentEditorChoicesItem()\r\n//-----------------------------------------------------------------------------\r\nComponentEditorChoicesItem::ComponentEditorChoicesItem(ComponentEditorTreeModel* model,\r\n    LibraryInterface* libHandler, QSharedPointer<Component> component,\r\n    QSharedPointer<ExpressionParser> expressionParser, ComponentEditorItem* parent):\r\nComponentEditorItem(model, libHandler, component, parent),\r\nchoiceValidator_(new ChoiceValidator(expressionParser))\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditorChoicesItem::~()\r\n//-----------------------------------------------------------------------------\r\nComponentEditorChoicesItem::~ComponentEditorChoicesItem()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditorChoicesItem::getFont()\r\n//-----------------------------------------------------------------------------\r\nQFont ComponentEditorChoicesItem::getFont() const\r\n{\r\n    QFont font(ComponentEditorItem::getFont());\r\n    font.setBold(!component_->getChoices()->isEmpty());\r\n    return font;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditorChoicesItem::getTooltip()\r\n//-----------------------------------------------------------------------------\r\nQString ComponentEditorChoicesItem::getTooltip() const\r\n{\r\n    return tr(\"Contains the choices available in the component\");\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditorChoicesItem::text()\r\n//-----------------------------------------------------------------------------\r\nQString ComponentEditorChoicesItem::text() const\r\n{\r\n    return tr(\"Choices\");\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditorChoicesItem::isValid()\r\n//-----------------------------------------------------------------------------\r\nbool ComponentEditorChoicesItem::isValid() const\r\n{\r\n    QStringList choiceNames;\r\n    foreach (QSharedPointer<Choice> choice, *component_->getChoices())\r\n    {\r\n        if (choiceNames.contains(choice->name()) || !choiceValidator_->validate(choice))\r\n        {\r\n            return false;\r\n        }\r\n        else\r\n        {\r\n            choiceNames.append(choice->name());\r\n        }\r\n    }\r\n\r\n    return true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditorChoicesItem::editor()\r\n//-----------------------------------------------------------------------------\r\nItemEditor* ComponentEditorChoicesItem::editor()\r\n{\r\n    if (!editor_)\r\n    {\r\n        editor_ = new ChoicesEditor(component_, choiceValidator_);\r\n        editor_->setProtection(locked_);\r\n        connect(editor_, SIGNAL(contentChanged()), this, SLOT(onEditorChanged()), Qt::UniqueConnection);\r\n        connect(editor_, SIGNAL(helpUrlRequested(QString const&)),\r\n            this, SIGNAL(helpUrlRequested(QString const&)), Qt::UniqueConnection);\r\n    }\r\n\r\n    return editor_;\r\n}\r\n"
  },
  {
    "path": "editors/ComponentEditor/treeStructure/ComponentEditorChoicesItem.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ComponentEditorChoicesItem.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: \r\n// Date: \r\n//\r\n// Description:\r\n// The choices item in the component editor navigation tree.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef ComponentEditorChoicesItem_H\r\n#define ComponentEditorChoicesItem_H\r\n\r\n#include \"componenteditoritem.h\"\r\n\r\n#include <QList>\r\n\r\nclass ChoiceValidator;\r\nclass ExpressionParser;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! The choices item in the component editor navigation tree.\r\n//-----------------------------------------------------------------------------\r\nclass ComponentEditorChoicesItem : public ComponentEditorItem\r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\r\n\t/*!\r\n\t *  The constructor.\r\n\t *\r\n\t *    @param [in] model               Pointer to the model that owns the items.\r\n\t *    @param [in] libHandler          The library interface.\r\n\t *    @param [in] component           The currently active component.\r\n     *    @param [in] expressionParser    The selected expression parser.\r\n\t *    @param [in] parent              The owner of this item.\r\n\t */\r\n\tComponentEditorChoicesItem(ComponentEditorTreeModel* model, LibraryInterface* libHandler,\r\n        QSharedPointer<Component> component, QSharedPointer<ExpressionParser> expressionParser,\r\n        ComponentEditorItem* parent);\r\n\r\n\t//! The destructor.\r\n\tvirtual ~ComponentEditorChoicesItem();\r\n\r\n    /*!\r\n     *  Get the font to be used for text of this item.\r\n\t *\r\n\t *    @return QFont instance that defines the font to be used.\r\n\t */\r\n    virtual QFont getFont() const;\r\n\r\n\t/*!\r\n     *  Get the tool tip for the item.\r\n\t * \r\n\t *    @return The text for the tool tip to print to user.\r\n\t */\r\n    virtual QString getTooltip() const;\r\n\r\n\t/*!\r\n     *  Get the text to be displayed to user in the tree for this item.\r\n\t *\r\n\t *    @return QString Contains the text to display.\r\n\t */\r\n    virtual QString text() const;\r\n\r\n    /*!\r\n     *  Check whether this item is in a valid state.\r\n     *\r\n     *    @return True, if the item is valid, false otherwise.\r\n     */\r\n    virtual bool isValid() const;\r\n\r\n\t/*!\r\n     *  Get pointer to the editor of this item.\r\n\t *\r\n\t *    @return Pointer to the editor to use for this item.\r\n\t */\r\n    virtual ItemEditor* editor();\r\n\r\nprivate:\r\n\r\n    //! No copying. No assignment.\r\n\tComponentEditorChoicesItem(const ComponentEditorChoicesItem& other);\r\n\tComponentEditorChoicesItem& operator=(const ComponentEditorChoicesItem& other);\r\n\r\n    //! The choice validator.\r\n    QSharedPointer<ChoiceValidator> choiceValidator_;\r\n};\r\n\r\n#endif // ComponentEditorChoicesItem_H\r\n"
  },
  {
    "path": "editors/ComponentEditor/treeStructure/ComponentEditorIndirectInterfacesItem.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: ComponentEditorIndirectInterfacesItem.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Esko Pekkarinen\n// Date: 04.08.2017\n//\n// Description:\n// The Indirect interfaces -item in the component editor navigation tree.\n//-----------------------------------------------------------------------------\n\n#include \"ComponentEditorIndirectInterfacesItem.h\"\n#include \"SingleIndirectInterfaceItem.h\"\n\n#include <editors/ComponentEditor/indirectInterfaces/IndirectInterfacesEditor.h>\n\n#include <IPXACTmodels/Component/Component.h>\n#include <IPXACTmodels/Component/validators/IndirectInterfaceValidator.h>\n#include <IPXACTmodels/common/validators/ParameterValidator.h>\n#include <IPXACTmodels/Component/IndirectInterface.h>\n#include <IPXACTmodels/Component/validators/CollectionValidators.h>\n\n//-----------------------------------------------------------------------------\n// Function: componenteditorIndirectInterfacesitem::ComponentEditorIndirectInterfacesItem()\n//-----------------------------------------------------------------------------\nComponentEditorIndirectInterfacesItem::ComponentEditorIndirectInterfacesItem(ComponentEditorTreeModel* model,\n    LibraryInterface* libHandler, QSharedPointer<Component> component,\n    QSharedPointer<ReferenceCounter> referenceCounter, QSharedPointer<ParameterFinder> parameterFinder,\n    QSharedPointer<ExpressionFormatter> expressionFormatter, QSharedPointer<ExpressionParser> expressionParser,\n    BusInterfaceInterface* busInterface, ComponentEditorItem* parent, QWidget* parentWnd):\nComponentEditorItem(model, libHandler, component, parent),\nindirectInterfaces_(component->getIndirectInterfaces()),\nexpressionParser_(expressionParser),\nsingleIndirectInterfaceValidator_(new IndirectInterfaceValidator(component, expressionParser,\n    QSharedPointer<ParameterValidator>(new ParameterValidator(expressionParser, component->getChoices(), \n        component_->getRevision())))),\nindirectInterfacesValidator_(new IndirectInterfacesValidator(singleIndirectInterfaceValidator_)),\nparentWnd_(parentWnd),\nbusInterface_(busInterface)\n{\n    setParameterFinder(parameterFinder);\n    setExpressionFormatter(expressionFormatter);\n    setReferenceCounter(referenceCounter);\n\n    for (QSharedPointer<IndirectInterface> indirectInterface : *indirectInterfaces_)\n    {\n\t\tQSharedPointer<SingleIndirectInterfaceItem> interfaceItem(new SingleIndirectInterfaceItem(\n            indirectInterface, model, libHandler, component, referenceCounter_, parameterFinder_,\n            expressionFormatter_, expressionParser_, singleIndirectInterfaceValidator_, busInterface_, this, parentWnd));\n\n        connect(interfaceItem.data(), SIGNAL(openReferenceTree(QString const&, QString const&)),\n            this, SIGNAL(openReferenceTree(QString const&, QString const&)), Qt::UniqueConnection);\n\n\t\tchildItems_.append(interfaceItem);\n\t}\n}\n\n//-----------------------------------------------------------------------------\n// Function: componenteditorIndirectInterfacesitem::getFont()\n//-----------------------------------------------------------------------------\nQFont ComponentEditorIndirectInterfacesItem::getFont() const\n{\n    QFont font(ComponentEditorItem::getFont());\n    font.setBold(!component_->getIndirectInterfaces()->isEmpty());\n    return font;\n}\n\n//-----------------------------------------------------------------------------\n// Function: componenteditorIndirectInterfacesitem::text()\n//-----------------------------------------------------------------------------\nQString ComponentEditorIndirectInterfacesItem::text() const\n{\n\treturn tr(\"Indirect interfaces\");\n}\n\n//-----------------------------------------------------------------------------\n// Function: componenteditorIndirectInterfacesitem::editor()\n//-----------------------------------------------------------------------------\nItemEditor* ComponentEditorIndirectInterfacesItem::editor()\n{\n\tif (!editor_)\n    {\n\t\teditor_ = new IndirectInterfacesEditor(libHandler_, component_, singleIndirectInterfaceValidator_);\n\t\teditor_->setProtection(locked_);\n\t\tconnect(editor_, SIGNAL(contentChanged()), this, SLOT(onEditorChanged()), Qt::UniqueConnection);\n\t\tconnect(editor_, SIGNAL(childAdded(int)), this, SLOT(onAddChild(int)), Qt::UniqueConnection);\n\t\tconnect(editor_, SIGNAL(childRemoved(int)), this, SLOT(onRemoveChild(int)), Qt::UniqueConnection);\n        connect(editor_, SIGNAL(childMoved(int, int)), this, SLOT(onMoveChild(int, int)), Qt::UniqueConnection);\n\t\tconnect(editor_, SIGNAL(helpUrlRequested(QString const&)), this, SIGNAL(helpUrlRequested(QString const&)));\n\n        connectItemEditorToReferenceCounter();\n\t}\n\treturn editor_;\n}\n\n//-----------------------------------------------------------------------------\n// Function: componenteditorIndirectInterfacesitem::getTooltip()\n//-----------------------------------------------------------------------------\nQString ComponentEditorIndirectInterfacesItem::getTooltip() const\n{\n\treturn tr(\"Contains the indirect interfaces specified for a component\");\n}\n\n//-----------------------------------------------------------------------------\n// Function: componenteditorIndirectInterfacesitem::createChild()\n//-----------------------------------------------------------------------------\nvoid ComponentEditorIndirectInterfacesItem::createChild(int index)\n{\n\tQSharedPointer<SingleIndirectInterfaceItem> interfaceItem(new SingleIndirectInterfaceItem(\n        indirectInterfaces_->at(index), model_, libHandler_, component_, referenceCounter_, parameterFinder_,\n        expressionFormatter_, expressionParser_, singleIndirectInterfaceValidator_, busInterface_, this, parentWnd_));\n\tinterfaceItem->setLocked(locked_);\n\n    connect(interfaceItem.data(), SIGNAL(openReferenceTree(QString const&, QString const&)),\n        this, SIGNAL(openReferenceTree(QString const&, QString const&)), Qt::UniqueConnection);\n\n\tchildItems_.insert(index, interfaceItem);\n}\n\n//-----------------------------------------------------------------------------\n// Function: ComponentEditorIndirectInterfacesItem::isValid()\n//-----------------------------------------------------------------------------\nbool ComponentEditorIndirectInterfacesItem::isValid() const\n{\n    auto indirectInterfacesAsNameGroup = CollectionValidators::itemListToNameGroupList(indirectInterfaces_);\n    indirectInterfacesValidator_->childrenHaveUniqueNames(indirectInterfacesAsNameGroup);\n    return ComponentEditorItem::isValid();\n}\n"
  },
  {
    "path": "editors/ComponentEditor/treeStructure/ComponentEditorIndirectInterfacesItem.h",
    "content": "//-----------------------------------------------------------------------------\n// File: ComponentEditorIndirectInterfacesItem.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Esko Pekkarinen\n// Date: 04.08.2017\n//\n// Description:\n// The Indirect interfaces -item in the component editor navigation tree.\n//-----------------------------------------------------------------------------\n\n#ifndef COMPONENTEDITOR_INDIRECT_INTERFACES_ITEM_H\n#define COMPONENTEDITOR_INDIRECT_INTERFACES_ITEM_H\n\n#include \"componenteditoritem.h\"\n\nclass IndirectInterface;\nclass IndirectInterfaceValidator;\nclass IndirectInterfacesValidator;\nclass ExpressionParser;\nclass BusInterfaceInterface;\n\n//-----------------------------------------------------------------------------\n//! The Bus interfaces-item in the component editor's navigation tree.\n//-----------------------------------------------------------------------------\nclass ComponentEditorIndirectInterfacesItem : public ComponentEditorItem\n{\n\tQ_OBJECT\n\npublic:\n\n    /*!\n\t *  The constructor.\n\t *\n\t *    @param [in] model                   The model that owns the items.\n\t *    @param [in] libHandler              The instance that manages the library.\n\t *    @param [in] component               The component being edited.\n\t *    @param [in] referenceCounter        The reference counter.\n\t *    @param [in] parameterFinder         The parameter finder.\n\t *    @param [in] expressionFormatter     The expression formatter.\n\t *    @param [in] expressionParser        The expression parser.\n     *    @param [in] busInterface            Interface for accessing bus interfaces.\n\t *    @param [in] parent                  The owner of this item.\n\t *    @param [in] parentWnd               The parent window.\n\t */\n    ComponentEditorIndirectInterfacesItem(ComponentEditorTreeModel* model,\n        LibraryInterface* libHandler,\n        QSharedPointer<Component> component,\n        QSharedPointer<ReferenceCounter> referenceCounter,\n        QSharedPointer<ParameterFinder> parameterFinder,\n        QSharedPointer<ExpressionFormatter> expressionFormatter,\n        QSharedPointer<ExpressionParser> expressionParser,\n        BusInterfaceInterface* busInterface,\n        ComponentEditorItem* parent,\n        QWidget* parentWnd);\n\n    //! No copying. No assignment.\n    ComponentEditorIndirectInterfacesItem(const ComponentEditorIndirectInterfacesItem& other) = delete;\n    ComponentEditorIndirectInterfacesItem& operator=(const ComponentEditorIndirectInterfacesItem& other) = delete;\n\n\t//! The destructor\n\tvirtual ~ComponentEditorIndirectInterfacesItem() = default;\n\n\t/*! Get the font to be used for text of this item.\n\t*\n\t* The font is bold, if bus interfaces exist, otherwise not bold.\n\t*\n\t*    @return QFont instance that defines the font to be used.\n\t*/\n\tvirtual QFont getFont() const override;\n\n\t/*! Get the tool tip for the item.\n\t * \n\t *    @return The text for the tool tip to print to user.\n\t*/\n\tvirtual QString getTooltip() const override;\n\n\t/*! Get the text to be displayed to user in the tree for this item.\n\t *\n\t *    @return The text to display.\n\t*/\n\tvirtual QString text() const override;\n\n\t/*! Get The editor of this item.\n\t *\n\t *    @return The editor to use for this item.\n\t*/\n\tvirtual ItemEditor* editor() override;\n\n\t/*! Add a new child to the item.\n\t *\n\t *    @param [in] index The index to add the child into.\n\t*/\n\tvirtual void createChild(int index) override;\n\n\t/*!\n\t *  Check the validity of this item.\n\t *\n\t *    @return bool True if item is in valid state.\n\t */\n\tbool isValid() const override;\n\nprivate:\n\n    //-----------------------------------------------------------------------------\n    // Data.\n    //-----------------------------------------------------------------------------\n\n\t//! Contains the bus interfaces to edit.\n\tQSharedPointer<QList<QSharedPointer<IndirectInterface> > > indirectInterfaces_;\n\n    //! The expression parser used to define the results of expressions.\n    QSharedPointer<ExpressionParser> expressionParser_;\n\n    //! Validator for indirect interfaces.\n    QSharedPointer<IndirectInterfaceValidator> singleIndirectInterfaceValidator_;\n\n    //! Validator for validating indirect interfaces together.\n    QSharedPointer<IndirectInterfacesValidator> indirectInterfacesValidator_;\n\n    //! The parent window.\n    QWidget* parentWnd_;\n\n    //! Interface for accessing bus interfaces.\n    BusInterfaceInterface* busInterface_;\n};\n\n#endif // COMPONENTEDITOR_INDIRECT_INTERFACES_ITEM_H\n"
  },
  {
    "path": "editors/ComponentEditor/treeStructure/ComponentEditorSystemViewItem.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ComponentEditorSystemViewItem.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Joni-Matti Maatta\r\n// Date: 13.7.2012\r\n//\r\n// Description:\r\n// The item for a single software view in the component editor's navigation tree.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"ComponentEditorSystemViewItem.h\"\r\n\r\n#include <editors/ComponentEditor/software/systemView/SystemViewEditor.h>\r\n\r\n#include <KactusAPI/include/LibraryInterface.h>\r\n\r\n#include <IPXACTmodels/Component/Component.h>\r\n#include <IPXACTmodels/kactusExtensions/SystemView.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditorSystemViewItem::ComponentEditorSystemViewItem()\r\n//-----------------------------------------------------------------------------\r\nComponentEditorSystemViewItem::ComponentEditorSystemViewItem(QSharedPointer<SystemView> systemView,\r\n    ComponentEditorTreeModel* model, LibraryInterface* libHandler, QSharedPointer<Component> component,\r\n    FileSetInterface* fileSetInterface, ComponentEditorItem* parent):\r\nComponentEditorItem(model, libHandler, component, parent),\r\nsystemView_(systemView),\r\neditAction_(new QAction(tr(\"Edit\"), this)),\r\nfileSetInterface_(fileSetInterface)\r\n{\r\n    Q_ASSERT(systemView_);\r\n    connect(editAction_, SIGNAL(triggered(bool)), this, SLOT(openItem()), Qt::UniqueConnection);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditorSystemViewItem::getTooltip()\r\n//-----------------------------------------------------------------------------\r\nQString ComponentEditorSystemViewItem::getTooltip() const\r\n{\r\n\treturn tr(\"Contains the details of a software view\");\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditorSystemViewItem::text()\r\n//-----------------------------------------------------------------------------\r\nQString ComponentEditorSystemViewItem::text() const\r\n{\r\n\treturn systemView_->name();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditorSystemViewItem::isValid()\r\n//-----------------------------------------------------------------------------\r\nbool ComponentEditorSystemViewItem::isValid() const\r\n{\r\n\tQStringList fileSetNames = component_->getFileSetNames();\r\n\tQStringList viewNames = component_->getViewNames();\r\n\r\n\t// if system view is not valid\r\n\tif (!systemView_->isValid(fileSetNames, viewNames))\r\n    {\r\n\t\treturn false;\r\n\t}\r\n\r\n\t// check that the reference is found\r\n\tif (!libHandler_->contains(systemView_->getHierarchyRef()))\r\n    {\r\n\t\treturn false;\r\n\t}\r\n\r\n\t// system view was valid and reference was found\r\n\treturn true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditorSystemViewItem::editor()\r\n//-----------------------------------------------------------------------------\r\nItemEditor* ComponentEditorSystemViewItem::editor()\r\n{\r\n\tif (!editor_)\r\n    {\r\n\t\teditor_ = new SystemViewEditor(fileSetInterface_, component_, systemView_, libHandler_, NULL);\r\n\t\teditor_->setProtection(locked_);\r\n\t\tconnect(editor_, SIGNAL(contentChanged()), this, SLOT(onEditorChanged()), Qt::UniqueConnection);\r\n\t\tconnect(editor_, SIGNAL(helpUrlRequested(QString const&)), this, SIGNAL(helpUrlRequested(QString const&)));\r\n\t}\r\n\r\n\treturn editor_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditorSystemViewItem::canBeOpened()\r\n//-----------------------------------------------------------------------------\r\nbool ComponentEditorSystemViewItem::canBeOpened() const\r\n{\r\n\t// if the library does not contain the referenced object\r\n\tif (!libHandler_->contains(systemView_->getHierarchyRef()))\r\n    {\r\n\t\treturn false;\r\n\t}\r\n\r\n\t// check that the reference has not been changed\r\n\t// if it has then there is no way to open the design because the changes have not\r\n\t// been made to the library\r\n\tQSharedPointer<Document const> libComp = libHandler_->getModelReadOnly(component_->getVlnv());\r\n\tQSharedPointer<Component const> comp = libComp.staticCast<Component const>();\r\n\tVLNV originalRef = comp->getHierSystemRef(systemView_->name());\r\n\treturn originalRef == systemView_->getHierarchyRef();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditorSystemViewItem::actions()\r\n//-----------------------------------------------------------------------------\r\nQList<QAction*> ComponentEditorSystemViewItem::actions() const\r\n{\r\n    QList<QAction*> actionList;\r\n    actionList.append(editAction_);\r\n\r\n    return actionList;   \r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditorSystemViewItem::openItem()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentEditorSystemViewItem::openItem()\r\n{\r\n\t// if item can't be opened\r\n\tif (!canBeOpened())\r\n    {\r\n\t\temit errorMessage(tr(\"The changes to component must be saved before view can be opened.\"));\r\n\t\treturn;\r\n\t}\r\n\r\n\tQString viewName = systemView_->name();\r\n\tVLNV compVLNV = component_->getVlnv();\r\n\temit openSystemDesign(compVLNV, viewName);\r\n}\r\n"
  },
  {
    "path": "editors/ComponentEditor/treeStructure/ComponentEditorSystemViewItem.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ComponentEditorSystemViewItem.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Joni-Matti Maatta\r\n// Date: 13.7.2012\r\n//\r\n// Description:\r\n// The item for a single system view in the component editor's navigation tree.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef COMPONENTEDITORSYSTEMVIEWITEM_H\r\n#define COMPONENTEDITORSYSTEMVIEWITEM_H\r\n\r\n#include \"componenteditoritem.h\"\r\n\r\nclass SystemView;\r\nclass FileSetInterface;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! The item for a single system view in the component editor's navigation tree.\r\n//-----------------------------------------------------------------------------\r\nclass ComponentEditorSystemViewItem : public ComponentEditorItem\r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\r\n\t/*!\r\n     *  The constructor.\r\n\t * \r\n\t *    @param [in] systemView          The system view to edit.\r\n\t *    @param [in] model               The model that owns the items.\r\n\t *    @param [in] libHandler          The instance that manages the library.\r\n\t *    @param [in] component           The component being edited.\r\n     *    @param [in] fileSetInterface    Interface for accessing file sets.\r\n\t *    @param [in] parent              The parent item.\r\n     */\r\n\tComponentEditorSystemViewItem(QSharedPointer<SystemView> systemView,\r\n        ComponentEditorTreeModel* model,\r\n\t\tLibraryInterface* libHandler,\r\n        QSharedPointer<Component> component,\r\n        FileSetInterface* fileSetInterface,\r\n        ComponentEditorItem* parent);\r\n\r\n\t/*!\r\n     *  The destructor\r\n     */\r\n\tvirtual ~ComponentEditorSystemViewItem() = default;\r\n\r\n\t/*!\r\n     *  Get the tool tip for the item.\r\n\t * \r\n\t *    @return The text for the tool tip to print to user.\r\n     */\r\n\tvirtual QString getTooltip() const;\r\n\r\n\t/*!\r\n     *  Get the text to be displayed to user in the tree for this item.\r\n\t *\r\n\t *    @return QString Contains the text to display.\r\n     */\r\n\tvirtual QString text() const;\r\n\r\n\t/*!\r\n     *  Check the validity of this item and sub items.\r\n\t *\r\n\t *    @return bool True if item is in valid state.\r\n     */\r\n\tvirtual bool isValid() const;\r\n\r\n\t/*!\r\n     *  Get pointer to the editor of this item.\r\n\t *\r\n\t *    @return The editor to use for this item.\r\n     */\r\n\tvirtual ItemEditor* editor();\r\n\r\n\t/*!\r\n     *  Check if the item can be opened or not. If the view hasn't changed then it can be opened.\r\n     */\r\n\tvirtual bool canBeOpened() const;\r\n\r\n    /*!\r\n     *  Returns the possible actions for opening the item.\r\n     *\r\n     *    @return The actions to open the item.\r\n     */\r\n    virtual QList<QAction*> actions() const;\r\n\r\npublic slots:\r\n\t\r\n\t/*! Open the view in a design editor.\r\n\t * \r\n\t*/\r\n\tvirtual void openItem();\r\n\r\nprivate:\r\n    //! No copying. No assignment.\r\n\tComponentEditorSystemViewItem(const ComponentEditorSystemViewItem& other);\r\n\tComponentEditorSystemViewItem& operator=(const ComponentEditorSystemViewItem& other);\r\n   \r\n\t//! The view being edited.\r\n\tQSharedPointer<SystemView> systemView_;\r\n\r\n    //! Action to open the system view for editing.\r\n    QAction* editAction_;\r\n\r\n    //! Interface for accessing file sets.\r\n    FileSetInterface* fileSetInterface_;\r\n};\r\n\r\n#endif // COMPONENTEDITORSYSTEMVIEWITEM_H\r\n"
  },
  {
    "path": "editors/ComponentEditor/treeStructure/ComponentEditorSystemViewsItem.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ComponentEditorSystemViewsItem.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Joni-Matti Maatta\r\n// Date: 13.7.2012\r\n//\r\n// Description:\r\n// The System Views-item in the component editor's navigation tree.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"ComponentEditorSystemViewsItem.h\"\r\n\r\n#include \"ComponentEditorSystemViewItem.h\"\r\n\r\n#include <KactusAPI/include/FileInterface.h>\r\n#include <KactusAPI/include/FileBuilderInterface.h>\r\n#include <KactusAPI/include/FileSetInterface.h>\r\n#include <editors/ComponentEditor/software/systemView/SystemViewsEditor.h>\r\n\r\n#include <IPXACTmodels/kactusExtensions/SystemView.h>\r\n#include <IPXACTmodels/Component/Component.h>\r\n#include <IPXACTmodels/Component/validators/FileValidator.h>\r\n#include <IPXACTmodels/Component/validators/FileSetValidator.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditorSystemViewsItem::ComponentEditorSystemViewsItem()\r\n//-----------------------------------------------------------------------------\r\nComponentEditorSystemViewsItem::ComponentEditorSystemViewsItem(ComponentEditorTreeModel* model,\r\n    LibraryInterface* libHandler, QSharedPointer<Component> component,\r\n    QSharedPointer<ParameterFinder> parameterFinder, QSharedPointer<ExpressionParser> expressionParser,\r\n    QSharedPointer<ExpressionFormatter> expressionFormatter, ComponentEditorItem* parent):\r\nComponentEditorItem(model, libHandler, component, parent),\r\nfileSetInterface_()\r\n{\r\n    constructFileSetInterface(parameterFinder, expressionParser, expressionFormatter);\r\n\r\n\tforeach (QSharedPointer<SystemView> systemView, component->getSystemViews())\r\n    {\r\n\t\tQSharedPointer<ComponentEditorSystemViewItem> systemViewItem(\r\n\t\t\tnew ComponentEditorSystemViewItem(systemView, model, libHandler, component, fileSetInterface_, this)); \r\n\t\tchildItems_.append(systemViewItem);\r\n\t}\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditorSystemViewsItem::getFont()\r\n//-----------------------------------------------------------------------------\r\nQFont ComponentEditorSystemViewsItem::getFont() const\r\n{\r\n    QFont font(ComponentEditorItem::getFont());        \r\n    font.setBold(component_->hasSystemViews());    \r\n    return font;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditorSystemViewsItem::getTooltip()\r\n//-----------------------------------------------------------------------------\r\nQString ComponentEditorSystemViewsItem::getTooltip() const\r\n{\r\n\treturn tr(\"Contains the system views of the component\");\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditorSystemViewsItem::text()\r\n//-----------------------------------------------------------------------------\r\nQString ComponentEditorSystemViewsItem::text() const\r\n{\r\n\treturn tr(\"System views\");\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditorSystemViewsItem::editor()\r\n//-----------------------------------------------------------------------------\r\nItemEditor* ComponentEditorSystemViewsItem::editor()\r\n{\r\n\tif (!editor_)\r\n    {\r\n\t\teditor_ = new SystemViewsEditor(component_, libHandler_);\r\n\t\teditor_->setProtection(locked_);\r\n\t\tconnect(editor_, SIGNAL(contentChanged()), this, SLOT(onEditorChanged()), Qt::UniqueConnection);\r\n\t\tconnect(editor_, SIGNAL(childAdded(int)), this, SLOT(onAddChild(int)), Qt::UniqueConnection);\r\n\t\tconnect(editor_, SIGNAL(childRemoved(int)), this, SLOT(onRemoveChild(int)), Qt::UniqueConnection);\r\n\t\tconnect(editor_, SIGNAL(helpUrlRequested(QString const&)),\r\n\t\t\tthis, SIGNAL(helpUrlRequested(QString const&)));\r\n\t}\r\n\r\n\treturn editor_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditorSystemViewsItem::createChild()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentEditorSystemViewsItem::createChild(int index)\r\n{\r\n\tQSharedPointer<ComponentEditorSystemViewItem> systemViewItem(\r\n\t\tnew ComponentEditorSystemViewItem(\r\n            component_->getSystemViews().at(index), model_, libHandler_, component_, fileSetInterface_, this));\r\n\tsystemViewItem->setLocked(locked_);\r\n\tchildItems_.insert(index, systemViewItem);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditorFileSetsItem::constructFileSetInterface()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentEditorSystemViewsItem::constructFileSetInterface(QSharedPointer<ParameterFinder> parameterFinder,\r\n    QSharedPointer<ExpressionParser> expressionParser, QSharedPointer<ExpressionFormatter> expressionFormatter)\r\n{\r\n    QSharedPointer<FileValidator> fileValidator(new FileValidator(expressionParser));\r\n\r\n    FileInterface* fileInterface = new FileInterface(fileValidator, expressionParser, expressionFormatter);\r\n    FileBuilderInterface* fileBuilderInterface = new FileBuilderInterface(expressionParser, expressionFormatter);\r\n\r\n    QSharedPointer<FileSetValidator> fileSetValidator(new FileSetValidator(fileValidator, expressionParser));\r\n\r\n    fileSetInterface_ = new FileSetInterface(\r\n        fileSetValidator, expressionParser, expressionFormatter, fileInterface, fileBuilderInterface);\r\n\r\n    fileSetInterface_->setFileSets(component_->getFileSets());\r\n}\r\n"
  },
  {
    "path": "editors/ComponentEditor/treeStructure/ComponentEditorSystemViewsItem.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ComponentEditorSystemViewsItem.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Joni-Matti Maatta\r\n// Date: 13.7.2012\r\n//\r\n// Description:\r\n// The System Views-item in the component editor's navigation tree.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef COMPONENTEDITORSYSTEMVIEWSITEM_H\r\n#define COMPONENTEDITORSYSTEMVIEWSITEM_H\r\n\r\n#include \"componenteditoritem.h\"\r\n\r\nclass SystemView;\r\nclass FileSetInterface;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! The System Views-item in the component editor's navigation tree.\r\n//-----------------------------------------------------------------------------\r\nclass ComponentEditorSystemViewsItem : public ComponentEditorItem\r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\r\n\t/*!\r\n     *  The constructor\r\n\t *\r\n\t *    @param [in] model       The model that owns the items.\r\n\t *    @param [in] libHandler  The instance that manages the library.\r\n\t *    @param [in] component   The component being edited.\r\n     *    @param [in] parameterFinder         The parameter finder.\r\n     *    @param [in] expressionFormatter     Formatter for expressions.\r\n     *    @param [in] expressionParser        Parser for expressions.\r\n\t *    @param [in] parent      The parent item.\r\n     */\r\n\tComponentEditorSystemViewsItem(ComponentEditorTreeModel* model,\r\n        LibraryInterface* libHandler,\r\n\t\tQSharedPointer<Component> component,\r\n        QSharedPointer<ParameterFinder> parameterFinder,\r\n        QSharedPointer<ExpressionParser> expressionParser,\r\n        QSharedPointer<ExpressionFormatter> expressionFormatter,\r\n        ComponentEditorItem* parent);\r\n\r\n\t/*!\r\n     *  The destructor\r\n     */\r\n\tvirtual ~ComponentEditorSystemViewsItem() = default;\r\n\r\n\t/*!\r\n     *  Get the font to be used for text of this item. The font is bold, if system views exist, otherwise not bold.\r\n     *\r\n     *    @return QFont instance that defines the font to be used.\r\n     */\r\n\tvirtual QFont getFont() const;\r\n\r\n\t/*!\r\n     *  Get the tool tip for the item.\r\n\t * \r\n\t *    @return The text for the tool tip to print to user.\r\n\t */\r\n\tvirtual QString getTooltip() const;\r\n\r\n\t/*!\r\n     *  Get the text to be displayed to user in the tree for this item.\r\n\t *\r\n\t *    @return QString Contains the text to display.\r\n     */\r\n\tvirtual QString text() const;\r\n\r\n\t/*!\r\n     *  Get pointer to the editor of this item.\r\n\t *\r\n\t *    @return The editor to use for this item.\r\n     */\r\n\tvirtual ItemEditor* editor();\r\n\r\n\t/*!\r\n     *  Add a new child to the item.\r\n\t * \r\n\t *    @param [in] index The index to add the child into.\r\n     */\r\n\tvirtual void createChild(int index);\r\n\r\nprivate:\r\n    //! No copying. No assignment.\r\n\tComponentEditorSystemViewsItem(const ComponentEditorSystemViewsItem& other);\r\n\tComponentEditorSystemViewsItem& operator=(const ComponentEditorSystemViewsItem& other);\r\n\r\n    /*!\r\n     *  Construct the interface for accessing file sets.\r\n     *\r\n     *    @param [in] parameterFinder         The parameter finder.\r\n     *    @param [in] expressionFormatter     Formatter for expressions.\r\n     *    @param [in] expressionParser        Parser for expressions.\r\n     */\r\n    void constructFileSetInterface(QSharedPointer<ParameterFinder> parameterFinder,\r\n        QSharedPointer<ExpressionParser> expressionParser,\r\n        QSharedPointer<ExpressionFormatter> expressionFormatter);\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! Interface for accessing file sets.\r\n    FileSetInterface* fileSetInterface_;\r\n};\r\n\r\n#endif // COMPONENTEDITORSYSTEMVIEWSITEM_H\r\n"
  },
  {
    "path": "editors/ComponentEditor/treeStructure/ComponentEditorTreeDelegate.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: ComponentEditorTreeDelegate.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Esko Pekkarinen\n// Date: 23.05.2023\n//\n// Description:\n// Component editor navigation tree delegate for custom painting of items.\n//-----------------------------------------------------------------------------\n\n#include \"ComponentEditorTreeDelegate.h\"\n\n#include <QPainter>\n\n#include <QFontMetrics>\n\n//-----------------------------------------------------------------------------\n// Function: ComponentEditorTreeDelegate::ComponentEditorTreeDelegate()\n//-----------------------------------------------------------------------------\nComponentEditorTreeDelegate::ComponentEditorTreeDelegate(QObject* parent)\n    : QItemDelegate(parent)\n{\n}\n\n//-----------------------------------------------------------------------------\n// Function: ComponentEditorTreeDelegate::paint()\n//-----------------------------------------------------------------------------\nvoid ComponentEditorTreeDelegate::paint(QPainter* painter,QStyleOptionViewItem const& option, \n    QModelIndex const& index) const\n{\n    QStyleOptionViewItem optionOverride = option;\n    optionOverride.font = qvariant_cast<QFont>(index.data(Qt::FontRole));\n    optionOverride.palette.setColor(QPalette::Text, index.data(Qt::ForegroundRole).value<QColor>());\n    optionOverride.decorationSize = QSize(option.rect.height() - 2, option.rect.height() - 2);\n\n    bool hasIndicator = index.data(Qt::UserRole).toBool();\n    auto indicatorSize = QSize(10, 10);\n    QRect indicatorRect;\n    if (hasIndicator)\n    {\n        indicatorRect.setSize(indicatorSize);\n    }\n\n    QPixmap decoration = qvariant_cast<QIcon>(index.data(Qt::DecorationRole)).pixmap(optionOverride.decorationSize);\n    bool hasDecoration = decoration.isNull() == false;\n    QRect decorationRect;\n    if (hasDecoration)\n    {\n        decorationRect.setSize(optionOverride.decorationSize);\n    }\n\n    const int MARGIN = 4;\n\n    QString displayText = index.data(Qt::DisplayRole).toString();\n    auto metrics = QFontMetrics(optionOverride.font);\n    int textWidth = metrics.horizontalAdvance(displayText);\n\n    //! Render the items in the following order: display, decoration, indicator.\n    QRect displayRect;\n    displayRect.setX(option.rect.x() + MARGIN);\n    displayRect.setY(option.rect.y() + 2);\n    displayRect.setWidth(qMin(textWidth + 2 * MARGIN, option.rect.width() - indicatorRect.width() - decorationRect.width() - 4 * MARGIN));\n    displayRect.setHeight(option.rect.height() - 2);\n\n    decorationRect.moveTo(displayRect.right() + MARGIN/2, (option.rect.y() + (option.rect.height() - optionOverride.decorationSize.height()) / 2 + 1));\n    indicatorRect.moveTo(decorationRect.right() + MARGIN/2, (option.rect.y() + (option.rect.height() - indicatorSize.height()) / 2 + 1));\n\n    drawBackground(painter, optionOverride, index);\n\n    drawDisplay(painter, optionOverride, displayRect, displayText);\n\n    if (hasIndicator)\n    {\n        QPixmap indicator(\":icons/common/graphics/traffic-light_gray.png\");\n        indicator = indicator.scaled(indicatorSize);\n        drawDecoration(painter, optionOverride, indicatorRect, indicator);\n    }\n\n    if (hasDecoration)\n    {\n        drawDecoration(painter, optionOverride, decorationRect, decoration);\n    }\n    \n    drawFocus(painter, optionOverride, displayRect);\n}\n"
  },
  {
    "path": "editors/ComponentEditor/treeStructure/ComponentEditorTreeDelegate.h",
    "content": "//-----------------------------------------------------------------------------\n// File: ComponentEditorTreeDelegate.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Esko Pekkarinen\n// Date: 23.05.2023\n//\n// Description:\n// Component editor navigation tree delegate for custom painting of items.\n//-----------------------------------------------------------------------------\n\n#ifndef COMPONENTEDITOR_TREE_DELEGATE_H \n#define COMPONENTEDITOR_TREE_DELEGATE_H\n\n#include <QItemDelegate>\n\n//-----------------------------------------------------------------------------\n//! Component editor navigation tree delegate for custom painting of items.\n//-----------------------------------------------------------------------------\nclass ComponentEditorTreeDelegate : public QItemDelegate\n{\n    Q_OBJECT\n\npublic:\n\n    /*!\n     * The constructor.\n     *\n     *    @param [in] parent  <Description>\n     *\n     *    @return \n     */\n     ComponentEditorTreeDelegate(QObject* parent = nullptr);\n    \n    //! The destructor.\n    ~ComponentEditorTreeDelegate() final = default;\n    \n    //! No copying.\n    ComponentEditorTreeDelegate(const ComponentEditorTreeDelegate &other) = delete;\n\n    //! No assignment.\n    ComponentEditorTreeDelegate &operator=(const ComponentEditorTreeDelegate &other) = delete;\n\n    /*!\n     * Renders the item indicated by index.\n     *\n     *    @param [in] painter  The painter to use for rendering.\n     *    @param [in] option   Options to guide the rendering.\n     *    @param [in] index    The index of the item to render.\n     */\n     void paint(QPainter* painter, QStyleOptionViewItem const& option, QModelIndex const& index) const;\n\n};\n\n\n\n#endif // COMPONENTEDITOR_TREE_DELEGATE_H"
  },
  {
    "path": "editors/ComponentEditor/treeStructure/ComponentEditorTreeSortProxyModel.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ComponentEditorTreeSortProxyModel.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Esko Pekkarinen\r\n// Date: 05.08.2013\r\n//\r\n// Description:\r\n// Sorting proxy model for Component Editor tree structure.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"ComponentEditorTreeSortProxyModel.h\"\r\n#include \"componenteditorviewitem.h\"\r\n\r\n#include \"componenteditoritem.h\"\r\n\r\n#include <QModelIndex>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditorTreeProxyModel()\r\n//-----------------------------------------------------------------------------\r\nComponentEditorTreeProxyModel::ComponentEditorTreeProxyModel(QObject *parent) :\r\nQSortFilterProxyModel(parent)\r\n{\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ~ComponentEditorTreeProxyModel()\r\n//-----------------------------------------------------------------------------\r\nComponentEditorTreeProxyModel::~ComponentEditorTreeProxyModel()\r\n{\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditorTreeProxyModel::setRowVisibility()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentEditorTreeProxyModel::setRowVisibility(QStringList hiddenItemNames)\r\n{\r\n    hiddenItems_ = hiddenItemNames;\r\n    invalidateFilter();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: lessThan()\r\n//-----------------------------------------------------------------------------\r\nbool ComponentEditorTreeProxyModel::lessThan(QModelIndex const& left, QModelIndex const& right) const\r\n{\r\n    ComponentEditorItem* leftItem = static_cast<ComponentEditorItem*>(left.internalPointer());\r\n    ComponentEditorItem* rightItem = static_cast<ComponentEditorItem*>(right.internalPointer());\r\n\r\n    // View item sorting.\r\n    ComponentEditorViewItem* leftViewItem = dynamic_cast<ComponentEditorViewItem*>(leftItem);\r\n    ComponentEditorViewItem* rightViewItem = dynamic_cast<ComponentEditorViewItem*>(rightItem);\r\n    if (leftViewItem != 0 && rightViewItem != 0)\r\n    {\r\n        // Both hierarchical, sort alphabetically.\r\n        if (leftViewItem->isHierarchical() && rightViewItem->isHierarchical())\r\n        {\r\n            return left.data().toString() < right.data().toString();\r\n        }\r\n        // Only left is hierarchical, precedes right.\r\n        else if (leftViewItem->isHierarchical() )\r\n        {\r\n            return true;\r\n        }\r\n        // Only right is hierarchical, precedes left.\r\n        else if (rightViewItem->isHierarchical())\r\n        {\r\n            return false;\r\n        }\r\n        // Both non-hierarchical, sort alphabetically.\r\n        else\r\n        {\r\n            return left.data().toString() < right.data().toString();\r\n        }\r\n    }\r\n    else\r\n    {\r\n        return left < right;\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditorTreeProxyModel::filterAcceptsRow()\r\n//-----------------------------------------------------------------------------\r\nbool ComponentEditorTreeProxyModel::filterAcceptsRow(int sourceRow, QModelIndex const& sourceParent) const\r\n{\r\n\tQModelIndex itemIndex = sourceModel()->index(sourceRow, 0, sourceParent);\r\n\tQString itemName = sourceModel()->data(itemIndex).toString();\r\n\r\n\tif (itemIsValidAndCanBeHidden(itemIndex) && hiddenItems_.contains( itemName ))\r\n\t{\r\n\t\treturn false;\r\n\t}\r\n\r\n\treturn QSortFilterProxyModel::filterAcceptsRow(sourceRow, sourceParent);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditorTreeSortProxyModel::itemIsValidAndCanBeHidden()\r\n//-----------------------------------------------------------------------------\r\nbool ComponentEditorTreeProxyModel::itemIsValidAndCanBeHidden(QModelIndex const& index) const\r\n{\r\n\treturn !(index.isValid() && !static_cast<ComponentEditorItem*>(index.internalPointer())->isValid());\r\n}\r\n"
  },
  {
    "path": "editors/ComponentEditor/treeStructure/ComponentEditorTreeSortProxyModel.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ComponentEditorTreeSortProxyModel.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Esko Pekkarinen\r\n// Date: 05.08.2013\r\n//\r\n// Description:\r\n// Sorting proxy model for Component Editor tree structure.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef COMPONENTEDITORTREEPROXYMODEL_H\r\n#define COMPONENTEDITORTREEPROXYMODEL_H\r\n\r\n#include <QSortFilterProxyModel>\r\n#include <QStringList>\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Sorting proxy for Component Editor tree view. Only supports sorting of views.\r\n//-----------------------------------------------------------------------------\r\nclass ComponentEditorTreeProxyModel : public QSortFilterProxyModel\r\n{\r\n    Q_OBJECT\r\n\r\npublic:\r\n\t /*!\r\n\t *  Constructor.\r\n\t *\r\n\t *    @param [in] parent     The parent object.\r\n\t */\r\n    ComponentEditorTreeProxyModel(QObject *parent = 0);\r\n\r\n\t /*!\r\n\t *  Destructor.\r\n\t */\r\n    ~ComponentEditorTreeProxyModel();\r\n\r\n    /*!\r\n     *  Sets the items to be hidden.\r\n     *\r\n     *    @param [in] hiddenItemNames   The names of the items to hide.\r\n     */\r\n    void setRowVisibility(QStringList hiddenItemNames);\r\n\r\nprotected:\r\n\r\n    /*!\r\n     *  Compares two items to get their order in the sorting. Views are sorted hierarchical first\r\n     *  in alphabetical order followed by non-hierachical views in alphabetical order. All other \r\n     *  items will be sorted by their index i.e. creation order. \r\n     *\r\n     *  Note that the corresponding summary view may sort its content into other order.\r\n     *\r\n     *    @param [in] left        The left item in comparison left < right.\r\n     *    @param [in] right       The right item in comparison left < right.\r\n     *\r\n     *    @return True if left precedes right, otherwise false.\r\n     */\r\n    bool lessThan(QModelIndex const& left, QModelIndex const& right) const;\r\n\r\n\t/*!\r\n\t *  Filters the selected rows.\r\n\t *\r\n\t *    @param [in] source_row      The row to check for filtering.\r\n\t *    @param [in] source_parent   The parent index of the row.\r\n\t *\r\n\t *    @return True, if row passes filters, otherwise false.\r\n\t */\r\n    bool filterAcceptsRow(int sourceRow, QModelIndex const& sourceParent) const;\r\n\r\nprivate:\r\n    //! \\brief No copying\r\n    ComponentEditorTreeProxyModel(const ComponentEditorTreeProxyModel& other);\r\n    //! \\brief No assignment\r\n    ComponentEditorTreeProxyModel& operator=(const ComponentEditorTreeProxyModel& other);\r\n\r\n\t/*!\r\n\t *  Checks if item is valid. Invalid items should not be hidden.\r\n\t *\r\n\t *    @param [in] index   Index of item.\r\n\t */\r\n    bool itemIsValidAndCanBeHidden(QModelIndex const& index) const;\r\n\r\n\t//! A list of all the rows that will be hidden.\r\n\tQStringList hiddenItems_;\r\n};\r\n\r\n#endif // COMPONENTEDITORTREEPROXYMODEL_H\r\n"
  },
  {
    "path": "editors/ComponentEditor/treeStructure/ComponentInstantiationsItem.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ComponentInstantiationsItem.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Esko Pekkarinen\r\n// Date: 25.01.2016\r\n//\r\n// Description:\r\n// The component instantiations-item in the component editor's navigation tree.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"ComponentInstantiationsItem.h\"\r\n#include \"SingleComponentInstantiationItem.h\"\r\n\r\n#include <editors/ComponentEditor/instantiations/ComponentInstantiationsEditor.h>\r\n#include <KactusAPI/include/ComponentInstantiationParameterFinder.h>\r\n#include <KactusAPI/include/MultipleParameterFinder.h>\r\n#include <editors/ComponentEditor/referenceCounter/ParameterReferenceCounter.h>\r\n#include <KactusAPI/include/ExpressionFormatter.h>\r\n#include <KactusAPI/include/IPXactSystemVerilogParser.h>\r\n\r\n#include <IPXACTmodels/Component/Component.h>\r\n#include <IPXACTmodels/Component/validators/InstantiationsValidator.h>\r\n#include <IPXACTmodels/Component/validators/CollectionValidators.h>\r\n\r\n#include <IPXACTmodels/common/validators/ParameterValidator.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentInstantiationsItem::ComponentInstantiationsItem()\r\n//-----------------------------------------------------------------------------\r\nComponentInstantiationsItem::ComponentInstantiationsItem(ComponentEditorTreeModel* model,\r\n    LibraryInterface* libHandler, QSharedPointer<Component> component,\r\n    QSharedPointer<InstantiationsValidator> validator, QSharedPointer<AllInstantiationsValidator> allInstantiationsValidator, QSharedPointer<ReferenceCounter> referenceCounter,\r\n    QSharedPointer<ParameterFinder> parameterFinder, QSharedPointer<ExpressionFormatter> expressionFormatter,\r\n    QSharedPointer<ExpressionParser> expressionParser, ComponentInstantiationInterface* instantiationInterface,\r\n    ComponentEditorItem* parent) :\r\nComponentEditorItem(model, libHandler, component, parent),\r\nvalidator_(validator),\r\nallInstantiationsValidator_(allInstantiationsValidator),\r\nexpressionParser_(expressionParser),\r\ninstantiationInterface_(instantiationInterface)\r\n{\r\n    setParameterFinder(parameterFinder);\r\n    setExpressionFormatter(expressionFormatter);\r\n\r\n    setObjectName(tr(\"ComponentInstantiationsItem\"));\r\n\r\n    setReferenceCounter(referenceCounter);\r\n\r\n    for (QSharedPointer<ComponentInstantiation> instantiation : *component->getComponentInstantiations())\r\n    {\r\n        QSharedPointer<SingleComponentInstantiationItem> componentInstantiationItem =\r\n            createChildItem(instantiation);\r\n\r\n        childItems_.append(componentInstantiationItem);\r\n\r\n        connect(componentInstantiationItem.data(), SIGNAL(openReferenceTree(QString const&, QString const&)),\r\n            this, SIGNAL(openReferenceTree(QString const&, QString const&)), Qt::UniqueConnection);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentInstantiationsItem::~ComponentInstantiationsItem()\r\n//-----------------------------------------------------------------------------\r\nComponentInstantiationsItem::~ComponentInstantiationsItem()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentInstantiationsItem::getTooltip()\r\n//-----------------------------------------------------------------------------\r\nQString ComponentInstantiationsItem::getTooltip() const\r\n{\r\n    return tr(\"Contains the component instantiations of the component\");\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentInstantiationsItem::text()\r\n//-----------------------------------------------------------------------------\r\nQString ComponentInstantiationsItem::text() const\r\n{\r\n\treturn tr(\"Component instantiations\");\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentInstantiationsItem::editor()\r\n//-----------------------------------------------------------------------------\r\nItemEditor* ComponentInstantiationsItem::editor()\r\n{\r\n\tif (!editor_)\r\n    {\r\n        editor_ = new ComponentInstantiationsEditor(\r\n            component_, libHandler_, parameterFinder_, instantiationInterface_, 0);\r\n        editor_->setProtection(locked_);\r\n\r\n        connect(editor_, SIGNAL(contentChanged()), this, SLOT(onEditorChanged()), Qt::UniqueConnection);\r\n        connect(editor_, SIGNAL(childAdded(int)), this, SLOT(onAddChild(int)), Qt::UniqueConnection);\r\n        connect(editor_, SIGNAL(childRemoved(int)), this, SLOT(onRemoveChild(int)), Qt::UniqueConnection);\r\n        connect(editor_, SIGNAL(helpUrlRequested(QString const&)), this, SIGNAL(helpUrlRequested(QString const&)));\r\n\r\n        connectItemEditorToReferenceCounter();\r\n\t}\r\n\treturn editor_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentInstantiationsItem::createChild()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentInstantiationsItem::createChild( int index )\r\n{\r\n    QSharedPointer<ComponentInstantiation> instantiation = component_->getComponentInstantiations()->at(index);\r\n    \r\n    QSharedPointer<SingleComponentInstantiationItem> childItem = createChildItem(instantiation);\r\n\r\n    childItem->setLocked(locked_);\r\n\r\n    connect(childItem.data(), SIGNAL(openReferenceTree(QString const&, QString const&)),\r\n        this, SIGNAL(openReferenceTree(QString const&, QString const&)), Qt::UniqueConnection);\r\n\r\n    childItems_.append(childItem);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentInstantiationsItem::isValid()\r\n//-----------------------------------------------------------------------------\r\nbool ComponentInstantiationsItem::isValid() const\r\n{\r\n    // Validation for all instantiations only done once here (no need to do the same in design and design config instantiation)\r\n    auto instantiationsAsNameGroups = CollectionValidators::itemListToNameGroupList(component_->getComponentInstantiations());\r\n    instantiationsAsNameGroups->append(*CollectionValidators::itemListToNameGroupList(component_->getDesignInstantiations()));\r\n    instantiationsAsNameGroups->append(*CollectionValidators::itemListToNameGroupList(component_->getDesignConfigurationInstantiations()));\r\n    allInstantiationsValidator_->childrenHaveUniqueNames(instantiationsAsNameGroups);\r\n\r\n    return ComponentEditorItem::isValid();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentInstantiationsItem::createSingleComponentInstantiationItem()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<SingleComponentInstantiationItem> ComponentInstantiationsItem::createChildItem(\r\n    QSharedPointer<ComponentInstantiation> instantiation)\r\n{\r\n    QSharedPointer<MultipleParameterFinder> cimpFinder =\r\n        QSharedPointer<MultipleParameterFinder>(new MultipleParameterFinder);\r\n    cimpFinder->addFinder(parameterFinder_);\r\n    cimpFinder->addFinder(QSharedPointer<ComponentInstantiationParameterFinder>\r\n        (new ComponentInstantiationParameterFinder(instantiation)));\r\n\r\n    QSharedPointer<ParameterReferenceCounter> cimpCounter =\r\n        QSharedPointer<ParameterReferenceCounter>(new ParameterReferenceCounter(cimpFinder));\r\n    QSharedPointer<ExpressionFormatter> cimpFormatter =\r\n        QSharedPointer<ExpressionFormatter>(new ExpressionFormatter(cimpFinder));\r\n\r\n    QSharedPointer<IPXactSystemVerilogParser> cimpParser =\r\n        QSharedPointer<IPXactSystemVerilogParser>(new IPXactSystemVerilogParser(cimpFinder));\r\n\r\n    QSharedPointer<SingleComponentInstantiationItem> componentInstantiationItem(\r\n        new SingleComponentInstantiationItem(model_, libHandler_, component_, instantiation, validator_,\r\n            cimpCounter, cimpFinder, cimpFormatter, cimpParser, instantiationInterface_, this));\r\n\r\n    return componentInstantiationItem;\r\n}\r\n"
  },
  {
    "path": "editors/ComponentEditor/treeStructure/ComponentInstantiationsItem.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: InstantiationsItem.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Esko Pekkarinen\r\n// Date: 25.01.2016\r\n//\r\n// Description:\r\n// The component instantiations-item in the component editor's navigation tree.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef COMPONENTINSTANTIATIONSITEM_H\r\n#define COMPONENTINSTANTIATIONSITEM_H\r\n\r\n#include \"componenteditoritem.h\"\r\n\r\n#include <QSharedPointer>\r\n\r\nclass Component;\r\nclass ComponentInstantiation;\r\nclass ExpressionParser;\r\nclass InstantiationsValidator;\r\nclass ParametersInterface;\r\nclass SingleComponentInstantiationItem;\r\nclass FileBuilderInterface;\r\nclass ComponentInstantiationInterface;\r\nclass AllInstantiationsValidator;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! The component instantiations-item in the component editor's navigation tree.\r\n//-----------------------------------------------------------------------------\r\nclass ComponentInstantiationsItem : public ComponentEditorItem\r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\r\n\t/*!\r\n\t *  The constructor.\r\n\t *\r\n\t *    @param [in] model\t\t\t\t\t\tThe model that owns the items.\r\n\t *    @param [in] libHandler\t\t\t\t\tThe instance that manages the library.\r\n\t *    @param [in] validator\t\t\t\t\tThe single instantiation validator.\r\n\t *    @param [in] allInstantiationsValidator  The validator validating all instantiations together.\r\n\t *    @param [in] component\t\t\t\t\tThe component being edited.\r\n\t *    @param [in] referenceCounter\t\t\tThe reference counter.\r\n\t *    @param [in] parameterFinder\t\t\t\tThe parameter finder.\r\n\t *    @param [in] expressionFormatter\t\t\tThe expression formatter.\r\n     *    @param [in] expressionParser\t\t\tThe used expression parser.\r\n     *    @param [in] instantiationInterface\t\tInterface for accessing component instantiations.\r\n\t *    @param [in] parent\t\t\t\t\t\tThe parent item.\r\n\t */\r\n\tComponentInstantiationsItem(ComponentEditorTreeModel* model, LibraryInterface* libHandler,\r\n\t\tQSharedPointer<Component> component, QSharedPointer<InstantiationsValidator> validator,\r\n\t\tQSharedPointer<AllInstantiationsValidator> allInstantiationsValidator,\r\n\t\tQSharedPointer<ReferenceCounter> referenceCounter, QSharedPointer<ParameterFinder> parameterFinder,\r\n\t\tQSharedPointer<ExpressionFormatter> expressionFormatter,\r\n\t\tQSharedPointer<ExpressionParser> expressionParser,\r\n\t\tComponentInstantiationInterface* instantiationInterface,\r\n\t\tComponentEditorItem* parent);\r\n\r\n\t//! The destructor.\r\n\tvirtual ~ComponentInstantiationsItem();\r\n\r\n\t/*!\r\n     *  Get the tool tip for the item.\r\n\t * \r\n\t *    @return The text for the tool tip to print to user.\r\n\t */\r\n\tvirtual QString getTooltip() const;\r\n\r\n\t/*!\r\n     *  Get the text to be displayed to user in the tree for this item.\r\n\t *\r\n\t *    @return QString Contains the text to display.\r\n\t */\r\n\tvirtual QString text() const;\r\n\r\n\t/*!\r\n     *  Get The editor of this item.\r\n\t *\r\n\t *    @return The editor to use for this item.\r\n\t */\r\n\tvirtual ItemEditor* editor();\r\n\r\n\t/*!\r\n     *  Add a new child to the item.\r\n\t * \r\n\t *    @param [in] index   The index to add the child into.\r\n\t */\r\n\tvirtual void createChild(int index);\r\n\r\n\t/*!\r\n\t *  Check the validity of this item.\r\n\t *\r\n\t *    @return bool True if item is in valid state.\r\n\t */\r\n\tbool isValid() const override;\r\n\r\nprivate:\r\n\r\n\t//! No copying.\r\n\tComponentInstantiationsItem(const ComponentInstantiationsItem& other);\r\n\tComponentInstantiationsItem& operator=(const ComponentInstantiationsItem& other);\r\n\r\n    //! Create a child component instantiation item.\r\n    QSharedPointer<SingleComponentInstantiationItem> createChildItem(\r\n        QSharedPointer<ComponentInstantiation> instantiation);\r\n\r\n    //! Validator for child component instantiations.\r\n    QSharedPointer<InstantiationsValidator> validator_;\r\n    \r\n\t//! Validator for all instantiations together.\r\n\tQSharedPointer<AllInstantiationsValidator> allInstantiationsValidator_;\r\n\r\n    //! The used expression parser.\r\n    QSharedPointer<ExpressionParser> expressionParser_;\r\n\r\n    //! Interface for accessing component instantiations.\r\n    ComponentInstantiationInterface* instantiationInterface_;\r\n};\r\n\r\n#endif // COMPONENTINSTANTIATIONSITEM_H\r\n"
  },
  {
    "path": "editors/ComponentEditor/treeStructure/DesignConfigurationInstantiationsItem.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: DesignConfigurationInstantiationsItem.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Esko Pekkarinen\r\n// Date: 25.01.2016\r\n//\r\n// Description:\r\n// The Instantiations-item in the component editor's navigation tree.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"DesignConfigurationInstantiationsItem.h\"\r\n\r\n#include \"SingleDesignConfigurationInstantiationItem.h\"\r\n\r\n#include <editors/ComponentEditor/common/DesignConfigurationInstantiationParameterFinder.h>\r\n#include <KactusAPI/include/MultipleParameterFinder.h>\r\n#include <KactusAPI/include/ExpressionFormatter.h>\r\n#include <KactusAPI/include/IPXactSystemVerilogParser.h>\r\n#include <editors/ComponentEditor/instantiations/DesignConfigurationInstantiationsEditor.h>\r\n#include <editors/ComponentEditor/referenceCounter/ParameterReferenceCounter.h>\r\n\r\n#include <IPXACTmodels/common/validators/ParameterValidator.h>\r\n#include <IPXACTmodels/Component/Component.h>\r\n#include <IPXACTmodels/Component/validators/InstantiationsValidator.h>\r\n#include <IPXACTmodels/Component/validators/CollectionValidators.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignConfigurationInstantiationsItem::DesignConfigurationInstantiationsItem()\r\n//-----------------------------------------------------------------------------\r\nDesignConfigurationInstantiationsItem::DesignConfigurationInstantiationsItem(ComponentEditorTreeModel* model,\r\n    LibraryInterface* libHandler, QSharedPointer<Component> component,\r\n    QSharedPointer<AllInstantiationsValidator> allInstantiationsValidator,\r\n    QSharedPointer<InstantiationsValidator> validator, QSharedPointer<ParameterValidator> parameterValidator, \r\n    QSharedPointer<ReferenceCounter> referenceCounter,\r\n    QSharedPointer<ParameterFinder> parameterFinder, QSharedPointer<ExpressionFormatter> expressionFormatter,\r\n    QSharedPointer<ExpressionParser> expressionParser, ComponentEditorItem* parent) :\r\nComponentEditorItem(model, libHandler, component, parent),\r\nvalidator_(validator),\r\nparameterValidator_(parameterValidator),\r\nexpressionParser_(expressionParser),\r\nallInstantiationsValidator_(allInstantiationsValidator)\r\n{\r\n    setParameterFinder(parameterFinder);\r\n    setExpressionFormatter(expressionFormatter);\r\n\r\n    setObjectName(tr(\"DesignConfigurationInstantiationsItem\"));\r\n\r\n    setReferenceCounter(referenceCounter);\r\n\r\n    for (auto instantiation : *component->getDesignConfigurationInstantiations())\r\n    {\r\n        QSharedPointer<MultipleParameterFinder> instantiationMultiFinder =\r\n            QSharedPointer<MultipleParameterFinder>(new MultipleParameterFinder);\r\n        instantiationMultiFinder->addFinder(parameterFinder);\r\n        instantiationMultiFinder->addFinder(QSharedPointer<DesignConfigurationInstantiationParameterFinder>\r\n            (new DesignConfigurationInstantiationParameterFinder(instantiation)));\r\n\r\n        QSharedPointer<ParameterReferenceCounter> instantiationReferenceCounter =\r\n            QSharedPointer<ParameterReferenceCounter>(new ParameterReferenceCounter(instantiationMultiFinder));\r\n        QSharedPointer<ExpressionFormatter> instantiationFormatter =\r\n            QSharedPointer<ExpressionFormatter>(new ExpressionFormatter(instantiationMultiFinder));\r\n\r\n        QSharedPointer<ComponentEditorItem> childItem(new SingleDesignConfigurationInstantiationItem(model,\r\n            libHandler, component, instantiationReferenceCounter, instantiation, validator, parameterValidator,\r\n            instantiationMultiFinder, instantiationFormatter, expressionParser, this));\r\n        childItems_.append(childItem);\r\n\r\n        connect(childItem.data(), SIGNAL(openReferenceTree(QString const&, QString const&)),\r\n            this, SIGNAL(openReferenceTree(QString const&, QString const&)), Qt::UniqueConnection);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignConfigurationInstantiationsItem::~DesignConfigurationInstantiationsItem()\r\n//-----------------------------------------------------------------------------\r\nDesignConfigurationInstantiationsItem::~DesignConfigurationInstantiationsItem()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignConfigurationInstantiationsItem::getTooltip()\r\n//-----------------------------------------------------------------------------\r\nQString DesignConfigurationInstantiationsItem::getTooltip() const\r\n{\r\n    return tr(\"Contains the design configuration instantiations of the component\");\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignConfigurationInstantiationsItem::text()\r\n//-----------------------------------------------------------------------------\r\nQString DesignConfigurationInstantiationsItem::text() const\r\n{\r\n\treturn tr(\"Design configuration instantiations\");\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignConfigurationInstantiationsItem::editor()\r\n//-----------------------------------------------------------------------------\r\nItemEditor* DesignConfigurationInstantiationsItem::editor()\r\n{\r\n    if (!editor_)\r\n    {\r\n        editor_ = new DesignConfigurationInstantiationsEditor(component_, libHandler_, validator_, 0);\r\n        editor_->setProtection(locked_);\r\n\r\n        connect(editor_, SIGNAL(contentChanged()), this, SLOT(onEditorChanged()), Qt::UniqueConnection);\r\n        connect(editor_, SIGNAL(childAdded(int)), this, SLOT(onAddChild(int)), Qt::UniqueConnection);\r\n        connect(editor_, SIGNAL(childRemoved(int)), this, SLOT(onRemoveChild(int)), Qt::UniqueConnection);\r\n        connect(editor_, SIGNAL(helpUrlRequested(QString const&)), this, SIGNAL(helpUrlRequested(QString const&)));\r\n    }\r\n    return editor_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignConfigurationInstantiationsItem::createChild()\r\n//-----------------------------------------------------------------------------\r\nvoid DesignConfigurationInstantiationsItem::createChild(int index)\r\n{\r\n    QSharedPointer<DesignConfigurationInstantiation> instantiation = \r\n        component_->getDesignConfigurationInstantiations()->at(index);\r\n\r\n    QSharedPointer<MultipleParameterFinder> instantiationMultiFinder =\r\n        QSharedPointer<MultipleParameterFinder>(new MultipleParameterFinder);\r\n    instantiationMultiFinder->addFinder(parameterFinder_);\r\n    instantiationMultiFinder->addFinder(QSharedPointer<DesignConfigurationInstantiationParameterFinder>\r\n        (new DesignConfigurationInstantiationParameterFinder(instantiation)));\r\n\r\n    QSharedPointer<ParameterReferenceCounter> instantiationCounter =\r\n        QSharedPointer<ParameterReferenceCounter>(new ParameterReferenceCounter(instantiationMultiFinder));\r\n    QSharedPointer<ExpressionFormatter> instantiationFormatter =\r\n        QSharedPointer<ExpressionFormatter>(new ExpressionFormatter(instantiationMultiFinder));\r\n\r\n    QSharedPointer<SingleDesignConfigurationInstantiationItem> child(\r\n        QSharedPointer<SingleDesignConfigurationInstantiationItem>(new SingleDesignConfigurationInstantiationItem(\r\n        model_, libHandler_, component_, instantiationCounter, instantiation, validator_, parameterValidator_, \r\n            instantiationMultiFinder, instantiationFormatter, expressionParser_, this)));\r\n    child->setLocked(locked_);\r\n\r\n    connect(child.data(), SIGNAL(openReferenceTree(QString const&, QString const&)),\r\n        this, SIGNAL(openReferenceTree(QString const&, QString const&)), Qt::UniqueConnection);\r\n\r\n    childItems_.insert(index, child);\r\n}\r\n"
  },
  {
    "path": "editors/ComponentEditor/treeStructure/DesignConfigurationInstantiationsItem.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: InstantiationsItem.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Esko Pekkarinen\r\n// Date: 25.01.2016\r\n//\r\n// Description:\r\n// The design configuration instantiations-item in the component editor's navigation tree.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef DESIGNCONFIGURATIONINSTANTIATIONSITEM_H\r\n#define DESIGNCONFIGURATIONINSTANTIATIONSITEM_H\r\n\r\n#include \"componenteditoritem.h\"\r\n\r\n#include <QSharedPointer>\r\n\r\nclass Component;\r\nclass View;\r\n\r\nclass ExpressionParser;\r\nclass ViewValidator;\r\nclass InstantiationsValidator;\r\nclass ParameterValidator;\r\nclass AllInstantiationsValidator;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! The design configuration instantiations-item in the component editor's navigation tree.\r\n//-----------------------------------------------------------------------------\r\nclass DesignConfigurationInstantiationsItem : public ComponentEditorItem\r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\r\n\t/*!\r\n\t *  The constructor.\r\n\t *\r\n\t *    @param [in] model                   The model that owns the items.\r\n\t *    @param [in] libHandler              The instance that manages the library.\r\n\t *    @param [in] component               The component being edited.\r\n\t *    @param [in] validator\t\t\t\tThe instantiation validator to use.\r\n\t *    @param [in] parameterValidator\t\tThe parameter validator to use.\r\n\t *    @param [in] referenceCounter        The reference counter.\r\n\t *    @param [in] parameterFinder         The parameter finder.\r\n\t *    @param [in] expressionFormatter     The expression formatter.\r\n     *    @param [in] expressionParser        The used expression parser.\r\n\t *    @param [in] parent                  The parent item.\r\n\t */\r\n\tDesignConfigurationInstantiationsItem(ComponentEditorTreeModel* model, LibraryInterface* libHandler,\r\n\t\tQSharedPointer<Component> component, QSharedPointer<AllInstantiationsValidator> allInstantiationsValidator,\r\n\t\tQSharedPointer<InstantiationsValidator> validator,\r\n\t\tQSharedPointer<ParameterValidator> parameterValidator, QSharedPointer<ReferenceCounter> referenceCounter,\r\n\t\tQSharedPointer<ParameterFinder> parameterFinder, QSharedPointer<ExpressionFormatter> expressionFormatter,\r\n\t\tQSharedPointer<ExpressionParser> expressionParser, ComponentEditorItem* parent);\r\n\r\n\t//! The destructor.\r\n\tvirtual ~DesignConfigurationInstantiationsItem();\r\n\r\n\t/*!\r\n     *  Get the tool tip for the item.\r\n\t * \r\n\t *    @return The text for the tool tip to print to user.\r\n\t */\r\n\tvirtual QString getTooltip() const;\r\n\r\n\t/*!\r\n     *  Get the text to be displayed to user in the tree for this item.\r\n\t *\r\n\t *    @return QString Contains the text to display.\r\n\t */\r\n\tvirtual QString text() const;\r\n\r\n\t/*!\r\n     *  Get The editor of this item.\r\n\t *\r\n\t *    @return The editor to use for this item.\r\n\t */\r\n\tvirtual ItemEditor* editor();\r\n\r\n\t/*!\r\n     *  Add a new child to the item.\r\n\t * \r\n\t *    @param [in] index   The index to add the child into.\r\n\t */\r\n\tvirtual void createChild(int index);\r\n\r\nprivate:\r\n\r\n\t//! No copying.\r\n\tDesignConfigurationInstantiationsItem(const DesignConfigurationInstantiationsItem& other);\r\n\tDesignConfigurationInstantiationsItem& operator=(const DesignConfigurationInstantiationsItem& other);\r\n\r\n    //! The validator for design configuration instantiations.\r\n    QSharedPointer<InstantiationsValidator> validator_;\r\n\r\n    //! ParameterValidator to use.\r\n    QSharedPointer<ParameterValidator> parameterValidator_;\r\n\r\n\t//! Expression parser to use.\r\n    QSharedPointer<ExpressionParser> expressionParser_;\r\n\r\n\t//! Validator used to validate all instantiations together.\r\n\tQSharedPointer<AllInstantiationsValidator> allInstantiationsValidator_;\r\n\r\n};\r\n\r\n#endif // DESIGNCONFIGURATIONINSTANTIATIONSITEM_H\r\n"
  },
  {
    "path": "editors/ComponentEditor/treeStructure/DesignInstantiationsItem.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: DesignInstantiationsItem.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Esko Pekkarinen\r\n// Date: 25.01.2016\r\n//\r\n// Description:\r\n// The design instantiations-item in the component editor's navigation tree.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"DesignInstantiationsItem.h\"\r\n\r\n#include \"SingleDesignInstantiationItem.h\"\r\n\r\n#include <editors/ComponentEditor/instantiations/DesignInstantiationsEditor.h>\r\n#include <IPXACTmodels/Component/Component.h>\r\n#include <IPXACTmodels/common/validators/ParameterValidator.h>\r\n#include <IPXACTmodels/Component/validators/CollectionValidators.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignInstantiationsItem::DesignInstantiationsItem()\r\n//-----------------------------------------------------------------------------\r\nDesignInstantiationsItem::DesignInstantiationsItem(ComponentEditorTreeModel* model, LibraryInterface* libHandler,\r\n    QSharedPointer<Component> component, QSharedPointer<InstantiationsValidator> validator,\r\n    QSharedPointer<AllInstantiationsValidator> allInstantiationsValidator,\r\n    QSharedPointer<ParameterValidator> parameterValidator, QSharedPointer<ExpressionParser> expressionParser,\r\n    QSharedPointer<ParameterFinder> componentParameterFinder, QSharedPointer<ReferenceCounter> referenceCounter,\r\n    ComponentEditorItem* parent):\r\nComponentEditorItem(model, libHandler, component, parent),\r\nvalidator_(validator),\r\nparameterValidator_(parameterValidator),\r\nexpressionParser_(expressionParser),\r\ncomponentParameterFinder_(componentParameterFinder),\r\nallInstantiationsValidator_(allInstantiationsValidator)\r\n{\r\n    setObjectName(tr(\"DesignInstantiationsItem\"));\r\n    setReferenceCounter(referenceCounter);\r\n\r\n    for (QSharedPointer<DesignInstantiation> instantiation : *component->getDesignInstantiations())\r\n    {\r\n        childItems_.append(QSharedPointer<SingleDesignInstantiationItem>(new SingleDesignInstantiationItem(model,\r\n            libHandler, component, instantiation, validator, parameterValidator, expressionParser, \r\n            componentParameterFinder, referenceCounter, this)));\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignInstantiationsItem::~DesignInstantiationsItem()\r\n//-----------------------------------------------------------------------------\r\nDesignInstantiationsItem::~DesignInstantiationsItem()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignInstantiationsItem::getTooltip()\r\n//-----------------------------------------------------------------------------\r\nQString DesignInstantiationsItem::getTooltip() const\r\n{\r\n    return tr(\"Contains the design instantiations of the component\");\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignInstantiationsItem::text()\r\n//-----------------------------------------------------------------------------\r\nQString DesignInstantiationsItem::text() const\r\n{\r\n\treturn tr(\"Design instantiations\");\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignInstantiationsItem::editor()\r\n//-----------------------------------------------------------------------------\r\nItemEditor* DesignInstantiationsItem::editor()\r\n{\r\n\tif (!editor_)\r\n    {\r\n        editor_ = new DesignInstantiationsEditor(component_, libHandler_, validator_, 0);\r\n        editor_->setProtection(locked_);\r\n\r\n        connect(editor_, SIGNAL(contentChanged()), this, SLOT(onEditorChanged()), Qt::UniqueConnection);\r\n        connect(editor_, SIGNAL(childAdded(int)), this, SLOT(onAddChild(int)), Qt::UniqueConnection);\r\n        connect(editor_, SIGNAL(childRemoved(int)), this, SLOT(onRemoveChild(int)), Qt::UniqueConnection);\r\n        connect(editor_, SIGNAL(helpUrlRequested(QString const&)), this, SIGNAL(helpUrlRequested(QString const&)));\r\n\t}\r\n\treturn editor_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignInstantiationsItem::createChild()\r\n//-----------------------------------------------------------------------------\r\nvoid DesignInstantiationsItem::createChild(int index)\r\n{\r\n    QSharedPointer<DesignInstantiation> instantiation = component_->getDesignInstantiations()->at(index);\r\n\r\n    QSharedPointer<SingleDesignInstantiationItem> child(QSharedPointer<SingleDesignInstantiationItem>(\r\n        new SingleDesignInstantiationItem(model_, libHandler_, component_, instantiation, validator_, \r\n            parameterValidator_, expressionParser_, componentParameterFinder_, referenceCounter_, this)));\r\n    child->setLocked(locked_);\r\n\r\n    childItems_.insert(index, child);\r\n}\r\n"
  },
  {
    "path": "editors/ComponentEditor/treeStructure/DesignInstantiationsItem.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: InstantiationsItem.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Esko Pekkarinen\r\n// Date: 25.01.2016\r\n//\r\n// Description:\r\n// The design instantiations-item in the component editor's navigation tree.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef DESIGNINSTANTIATIONSITEM_H\r\n#define DESIGNINSTANTIATIONSITEM_H\r\n\r\n#include \"componenteditoritem.h\"\r\n\r\n#include <QSharedPointer>\r\n\r\nclass Component;\r\n\r\nclass ExpressionParser;\r\nclass InstantiationsValidator;\r\nclass ParameterValidator;\r\nclass AllInstantiationsValidator;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! The design instantiations-item in the component editor's navigation tree.\r\n//-----------------------------------------------------------------------------\r\nclass DesignInstantiationsItem : public ComponentEditorItem\r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\r\n\t/*!\r\n\t *  The constructor.\r\n\t *\r\n\t *    @param [in] model                       The model that owns the items.\r\n\t *    @param [in] libHandler                  The instance that manages the library.\r\n\t *    @param [in] component                   The component being edited.\r\n     *    @param [in] validator                   The validator for design instantiation.\r\n     *    @param [in] componentParameterFinder    Finder for component parameters.\r\n     *    @param [in] referenceCounter            Handles the usage count of parameters.\r\n\t *    @param [in] parent                      The parent item.\r\n\t */\r\n\tDesignInstantiationsItem(ComponentEditorTreeModel* model, LibraryInterface* libHandler,\r\n        QSharedPointer<Component> component, QSharedPointer<InstantiationsValidator> validator,\r\n\t\tQSharedPointer<AllInstantiationsValidator> allInstantiationsValidator, \r\n\t\tQSharedPointer<ParameterValidator> parameterValidator, QSharedPointer<ExpressionParser> expressionParser,\r\n        QSharedPointer<ParameterFinder> componentParameterFinder,\r\n        QSharedPointer<ReferenceCounter> referenceCounter, ComponentEditorItem* parent);\r\n\r\n\t//! The destructor.\r\n\tvirtual ~DesignInstantiationsItem();\r\n\r\n\t/*!\r\n     *  Get the tool tip for the item.\r\n\t * \r\n\t *    @return The text for the tool tip to print to user.\r\n\t */\r\n\tvirtual QString getTooltip() const;\r\n\r\n\t/*!\r\n     *  Get the text to be displayed to user in the tree for this item.\r\n\t *\r\n\t *    @return QString Contains the text to display.\r\n\t */\r\n\tvirtual QString text() const;\r\n\r\n\t/*!\r\n     *  Get The editor of this item.\r\n\t *\r\n\t *    @return The editor to use for this item.\r\n\t */\r\n\tvirtual ItemEditor* editor();\r\n\r\n\t/*!\r\n     *  Add a new child to the item.\r\n\t * \r\n\t *    @param [in] index   The index to add the child into.\r\n\t */\r\n\tvirtual void createChild(int index);\r\n\r\nprivate:\r\n\r\n\t//! No copying.\r\n\tDesignInstantiationsItem(const DesignInstantiationsItem& other);\r\n\tDesignInstantiationsItem& operator=(const DesignInstantiationsItem& other);\r\n\r\n    //! Validator for design instantiations.\r\n    QSharedPointer<InstantiationsValidator> validator_;\r\n\r\n    //! ParameterValidator to use.\r\n    QSharedPointer<ParameterValidator> parameterValidator_;\r\n\r\n\t//! Expression parser to use.\r\n    QSharedPointer<ExpressionParser> expressionParser_;\r\n\r\n    //! The finder for component parameters.\r\n    QSharedPointer<ParameterFinder> componentParameterFinder_;\r\n\r\n    //! Validator used to validate all instantiations together.\r\n\tQSharedPointer<AllInstantiationsValidator> allInstantiationsValidator_;\r\n};\r\n\r\n#endif // DESIGNINSTANTIATIONSITEM_H\r\n"
  },
  {
    "path": "editors/ComponentEditor/treeStructure/InstantiationsItem.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: InstantiationsItem.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Esko Pekkarinen\r\n// Date: 25.01.2016\r\n//\r\n// Description:\r\n// The Instantiations-item in the component editor's navigation tree.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"InstantiationsItem.h\"\r\n\r\n#include \"ComponentInstantiationsItem.h\"\r\n#include \"DesignInstantiationsItem.h\"\r\n#include \"DesignConfigurationInstantiationsItem.h\"\r\n\r\n#include <KactusAPI/include/IPXactSystemVerilogParser.h>\r\n#include <KactusAPI/include/MultipleParameterFinder.h>\r\n#include <KactusAPI/include/ComponentInstantiationParameterFinder.h>\r\n#include <KactusAPI/include/ParametersInterface.h>\r\n#include <KactusAPI/include/FileBuilderInterface.h>\r\n#include <KactusAPI/include/FileSetInterface.h>\r\n#include <KactusAPI/include/FileInterface.h>\r\n#include <editors/ComponentEditor/instantiations/InstantiationsEditor.h>\r\n#include <KactusAPI/include/ComponentInstantiationInterface.h>\r\n#include <KactusAPI/include/ModuleParameterInterface.h>\r\n\r\n#include <IPXACTmodels/common/validators/ParameterValidator.h>\r\n#include <IPXACTmodels/Component/Component.h>\r\n#include <IPXACTmodels/Component/validators/InstantiationsValidator.h>\r\n#include <IPXACTmodels/Component/validators/FileValidator.h>\r\n#include <IPXACTmodels/Component/validators/FileSetValidator.h>\r\n#include <IPXACTmodels/Component/validators/CollectionValidators.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: InstantiationsItem::InstantiationsItem()\r\n//-----------------------------------------------------------------------------\r\nInstantiationsItem::InstantiationsItem(ComponentEditorTreeModel* model, LibraryInterface* libHandler,\r\n    QSharedPointer<Component> component, QSharedPointer<ReferenceCounter> referenceCounter,\r\n    QSharedPointer<ParameterFinder> parameterFinder, QSharedPointer<ExpressionFormatter> expressionFormatter,\r\n    QSharedPointer<ExpressionParser> expressionParser, ComponentEditorItem* parent) :\r\nComponentEditorItem(model, libHandler, component, parent),\r\nexpressionParser_(expressionParser),\r\nparameterValidator_(new ParameterValidator(expressionParser, component->getChoices(),\r\n    component->getRevision())),\r\nvalidator_(new InstantiationsValidator(expressionParser, component->getFileSets(), parameterValidator_, libHandler)),\r\nallInstantiationsValidator_(new AllInstantiationsValidator(validator_)),\r\ncomponentInstantiationsItem_(0),\r\ndesignConfigurationInstantiationsItem_(\r\n    new DesignConfigurationInstantiationsItem(model, libHandler, component, allInstantiationsValidator_, validator_, parameterValidator_, referenceCounter,\r\n        parameterFinder, expressionFormatter, expressionParser, this)),\r\ndesignInstantiationsItem_(new DesignInstantiationsItem(model, libHandler, component, validator_, \r\n    allInstantiationsValidator_, parameterValidator_, expressionParser_, parameterFinder, referenceCounter, this)),\r\ncomponentInstantiationInterface_()\r\n{\r\n    setParameterFinder(parameterFinder);\r\n    setExpressionFormatter(expressionFormatter);\r\n\r\n    setObjectName(tr(\"InstantiationsItem\"));\r\n\r\n    setReferenceCounter(referenceCounter);\r\n\r\n    constructInterfaces();\r\n\r\n    componentInstantiationsItem_ = QSharedPointer<ComponentInstantiationsItem>(new ComponentInstantiationsItem(\r\n        model, libHandler, component, validator_, allInstantiationsValidator_, referenceCounter, parameterFinder,\r\n        expressionFormatter, expressionParser, componentInstantiationInterface_, this));\r\n\r\n    connect(componentInstantiationsItem_.data(), SIGNAL(openReferenceTree(QString const&, QString const&)),\r\n        this, SIGNAL(openReferenceTree(QString const&, QString const&)), Qt::UniqueConnection);\r\n\r\n    connect(designConfigurationInstantiationsItem_.data(), SIGNAL(openReferenceTree(QString const&, QString const&)),\r\n        this, SIGNAL(openReferenceTree(QString const&, QString const&)), Qt::UniqueConnection);\r\n\r\n    childItems_.append(componentInstantiationsItem_);\r\n    childItems_.append(designConfigurationInstantiationsItem_);\r\n    childItems_.append(designInstantiationsItem_);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: InstantiationsItem::~InstantiationsItem()\r\n//-----------------------------------------------------------------------------\r\nInstantiationsItem::~InstantiationsItem()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: InstantiationsItem::getTooltip()\r\n//-----------------------------------------------------------------------------\r\nQString InstantiationsItem::getTooltip() const\r\n{\r\n    return tr(\"Contains the instantiations of the component\");\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: InstantiationsItem::getFont()\r\n//-----------------------------------------------------------------------------\r\nQFont InstantiationsItem::getFont() const\r\n{\r\n    QFont font(ComponentEditorItem::getFont());\r\n    font.setBold(!component_->getComponentInstantiations()->isEmpty() || \r\n        !component_->getDesignConfigurationInstantiations()->isEmpty() ||\r\n        !component_->getDesignInstantiations()->isEmpty());\r\n    return font;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: InstantiationsItem::text()\r\n//-----------------------------------------------------------------------------\r\nQString InstantiationsItem::text() const\r\n{\r\n\treturn tr(\"Instantiations\");\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: InstantiationsItem::editor()\r\n//-----------------------------------------------------------------------------\r\nItemEditor* InstantiationsItem::editor()\r\n{\r\n\tif (!editor_)\r\n    {\r\n        editor_ = new InstantiationsEditor(\r\n            component_, parameterFinder_, libHandler_, validator_, componentInstantiationInterface_);\r\n        editor_->setProtection(locked_);\r\n \r\n \t\tconnect(editor_, SIGNAL(contentChanged()), this, SLOT(onEditorChanged()), Qt::UniqueConnection);\r\n  \t\tconnect(editor_, SIGNAL(helpUrlRequested(QString const&)), this, SIGNAL(helpUrlRequested(QString const&)));\r\n\r\n        connect(editor_, SIGNAL(componentInstanceAdded(int)), \r\n            componentInstantiationsItem_.data(), SLOT(onAddChild(int)));\r\n        connect(editor_, SIGNAL(componentInstanceRemoved(int)),\r\n            componentInstantiationsItem_.data(), SLOT(onRemoveChild(int)));\r\n\r\n        connect(editor_, SIGNAL(designConfigurationInstanceAdded(int)), \r\n            designConfigurationInstantiationsItem_.data(), SLOT(onAddChild(int)));\r\n        connect(editor_, SIGNAL(designConfigurationInstanceRemoved(int)),\r\n            designConfigurationInstantiationsItem_.data(), SLOT(onRemoveChild(int)));\r\n\r\n        connect(editor_, SIGNAL(designInstanceAdded(int)), designInstantiationsItem_.data(), \r\n            SLOT(onAddChild(int)));\r\n        connect(editor_, SIGNAL(designInstanceRemoved(int)), designInstantiationsItem_.data(), \r\n            SLOT(onRemoveChild(int)));\r\n\r\n        connectItemEditorToReferenceCounter();\r\n\t}\r\n\treturn editor_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: InstantiationsItem::createChild()\r\n//-----------------------------------------------------------------------------\r\nvoid InstantiationsItem::createChild(int)\r\n{\r\n    // No new children allowed.\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: InstantiationsItem::constructInterfaces()\r\n//-----------------------------------------------------------------------------\r\nvoid InstantiationsItem::constructInterfaces()\r\n{\r\n    QSharedPointer<ComponentInstantiationParameterFinder> instantiationParameterFinder(\r\n        new ComponentInstantiationParameterFinder(QSharedPointer<ComponentInstantiation>()));\r\n\r\n    QSharedPointer<MultipleParameterFinder> cimpFinder =\r\n        QSharedPointer<MultipleParameterFinder>(new MultipleParameterFinder);\r\n    cimpFinder->addFinder(parameterFinder_);\r\n    cimpFinder->addFinder(instantiationParameterFinder);\r\n\r\n    QSharedPointer<IPXactSystemVerilogParser> cimpParser =\r\n        QSharedPointer<IPXactSystemVerilogParser>(new IPXactSystemVerilogParser(cimpFinder));\r\n\r\n    QSharedPointer<ParameterValidator> validator(\r\n        new ParameterValidator(cimpParser, component_->getChoices(), component_->getRevision()));\r\n\r\n    QSharedPointer<ExpressionFormatter> moduleFormatter(new ExpressionFormatter(cimpFinder));\r\n\r\n    ParametersInterface* parameterInterface =\r\n        new ParametersInterface(validator, cimpParser, moduleFormatter);\r\n\r\n\r\n    ModuleParameterInterface* moduleParameterInterface =\r\n        new ModuleParameterInterface(validator, cimpParser, moduleFormatter, instantiationParameterFinder);\r\n\r\n    FileBuilderInterface* fileBuilderInterface = new FileBuilderInterface(cimpParser, moduleFormatter);\r\n\r\n    QSharedPointer<FileValidator> fileValidator(new FileValidator(expressionParser_));\r\n    FileInterface* fileInterface = new FileInterface(fileValidator, expressionParser_, moduleFormatter);\r\n\r\n    QSharedPointer<FileSetValidator> fileSetValidator(new FileSetValidator(fileValidator, expressionParser_));\r\n    FileSetInterface* fileSetInterface = new FileSetInterface(\r\n        fileSetValidator, expressionParser_, moduleFormatter, fileInterface, fileBuilderInterface);\r\n\r\n    fileSetInterface->setFileSets(component_->getFileSets());\r\n\r\n    componentInstantiationInterface_ = new ComponentInstantiationInterface(validator_, cimpParser,\r\n        moduleFormatter, parameterInterface, moduleParameterInterface, fileBuilderInterface, fileSetInterface);\r\n}\r\n"
  },
  {
    "path": "editors/ComponentEditor/treeStructure/InstantiationsItem.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: InstantiationsItem.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Esko Pekkarinen\r\n// Date: 25.01.2016\r\n//\r\n// Description:\r\n// The Instantiations-item in the component editor's navigation tree.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef INSTANTIATIONSITEM_H\r\n#define INSTANTIATIONSITEM_H\r\n\r\n#include \"componenteditoritem.h\"\r\n\r\n#include <QSharedPointer>\r\n\r\nclass Component;\r\nclass ExpressionParser;\r\nclass ViewValidator;\r\nclass InstantiationsValidator;\r\nclass ComponentInstantiationInterface;\r\nclass ParameterValidator;\r\nclass AllInstantiationsValidator;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! The Instantiations-item in the component editor's navigation tree.\r\n//-----------------------------------------------------------------------------\r\nclass InstantiationsItem : public ComponentEditorItem\r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\r\n\t/*!\r\n\t *  The constructor.\r\n\t *\r\n\t *    @param [in] model                   The model that owns the items.\r\n\t *    @param [in] libHandler              The instance that manages the library.\r\n\t *    @param [in] component               The component being edited.\r\n\t *    @param [in] referenceCounter        The reference counter.\r\n\t *    @param [in] parameterFinder         The parameter finder.\r\n\t *    @param [in] expressionFormatter     The expression formatter.\r\n     *    @param [in] expressionParser        The used expression parser.\r\n\t *    @param [in] parent                  The parent item.\r\n\t */\r\n    InstantiationsItem(ComponentEditorTreeModel* model, LibraryInterface* libHandler,\r\n        QSharedPointer<Component> component, QSharedPointer<ReferenceCounter> referenceCounter,\r\n        QSharedPointer<ParameterFinder> parameterFinder, QSharedPointer<ExpressionFormatter> expressionFormatter,\r\n        QSharedPointer<ExpressionParser> expressionParser, ComponentEditorItem* parent);\r\n\r\n\t//! The destructor.\r\n\tvirtual ~InstantiationsItem();\r\n\r\n\t/*!\r\n     *  Get the tool tip for the item.\r\n\t * \r\n\t *    @return The text for the tool tip to print to user.\r\n\t */\r\n\tvirtual QString getTooltip() const;\r\n\r\n\t/*!\r\n     *  Get the font to be used for text of this item.\r\n\t *\r\n\t *    @return QFont instance that defines the font to be used.\r\n\t */\r\n    virtual QFont getFont() const;\r\n\r\n\t/*!\r\n     *  Get the text to be displayed to user in the tree for this item.\r\n\t *\r\n\t *    @return QString Contains the text to display.\r\n\t */\r\n\tvirtual QString text() const;\r\n\r\n\t/*!\r\n     *  Get The editor of this item.\r\n\t *\r\n\t *    @return The editor to use for this item.\r\n\t */\r\n\tvirtual ItemEditor* editor();\r\n\r\n\t/*!\r\n     *  Add a new child to the item.\r\n\t * \r\n\t *    @param [in] index   The index to add the child into.\r\n\t */\r\n\tvirtual void createChild(int index);\r\n\r\nprivate:\r\n\r\n\t//! No copying.\r\n\tInstantiationsItem(const InstantiationsItem& other);\r\n\tInstantiationsItem& operator=(const InstantiationsItem& other);\r\n\r\n    /*!\r\n     *  Construct interfaces for instantiations.\r\n     */\r\n    void constructInterfaces();\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! The used expression parser.\r\n    QSharedPointer<ExpressionParser> expressionParser_;\r\n\t\r\n\t//! Validator for component parameters.\r\n\tQSharedPointer<ParameterValidator> parameterValidator_;\r\n\r\n    //! Validator for single instantiations.\r\n    QSharedPointer<InstantiationsValidator> validator_;\r\n\r\n    //! Validator for all instantiations together.\r\n    QSharedPointer<AllInstantiationsValidator> allInstantiationsValidator_;\r\n\r\n    //! Child item for component instantiations.\r\n    QSharedPointer<ComponentEditorItem> componentInstantiationsItem_;\r\n\r\n    //! Child item for design configuration instantiations.\r\n    QSharedPointer<ComponentEditorItem> designConfigurationInstantiationsItem_;\r\n\r\n    //! Child item for design instantiations.\r\n    QSharedPointer<ComponentEditorItem> designInstantiationsItem_;\r\n\r\n    //! Interface for accessing component instantiations.\r\n    ComponentInstantiationInterface* componentInstantiationInterface_;\r\n};\r\n\r\n#endif // INSTANTIATIONSITEM_H\r\n"
  },
  {
    "path": "editors/ComponentEditor/treeStructure/MemoryRemapItem.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: MemoryRemapItem.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Mikko Teuho\r\n// Date: 16.04.2015\r\n//\r\n// Description:\r\n// The item for a single memory remap in component editor's navigation tree.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"MemoryRemapItem.h\"\r\n#include \"componenteditoraddrblockitem.h\"\r\n\r\n#include <KactusAPI/include/ExpressionParser.h>\r\n#include <editors/ComponentEditor/memoryMaps/SingleMemoryMapEditor.h>\r\n#include <editors/ComponentEditor/memoryMaps/memoryMapsVisualizer/memorymapsvisualizer.h>\r\n#include <editors/ComponentEditor/memoryMaps/memoryMapsVisualizer/memorymapgraphitem.h>\r\n#include <KactusAPI/include/MemoryMapInterface.h>\r\n#include <editors/ComponentEditor/treeStructure/SubspaceMapItem.h>\r\n\r\n#include <IPXACTmodels/Component/MemoryMapBase.h>\r\n#include <IPXACTmodels/Component/MemoryMap.h>\r\n#include <IPXACTmodels/Component/MemoryRemap.h>\r\n#include <IPXACTmodels/Component/MemoryBlockBase.h>\r\n#include <IPXACTmodels/Component/AddressBlock.h>\r\n\r\n#include <IPXACTmodels/Component/validators/MemoryMapValidator.h>\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryRemapItem::MemoryRemapItem()\r\n//-----------------------------------------------------------------------------\r\nMemoryRemapItem::MemoryRemapItem(QSharedPointer<MemoryMapBase> memoryRemap,\r\n    QSharedPointer<MemoryMap> parentMemoryMap, ComponentEditorTreeModel* model, LibraryInterface* libHandler,\r\n    QSharedPointer<Component> component, QSharedPointer<ReferenceCounter> referenceCounter,\r\n    QSharedPointer<ParameterFinder> parameterFinder, QSharedPointer<ExpressionFormatter> expressionFormatter,\r\n    QSharedPointer<ExpressionParser> expressionParser, QSharedPointer<MemoryMapValidator> memoryMapValidator,\r\n    MemoryMapInterface* mapInterface, ComponentEditorItem* parent):\r\nComponentEditorItem(model, libHandler, component, parent),\r\nmemoryRemap_(memoryRemap),\r\nparentMemoryMap_(parentMemoryMap),\r\nmemoryBlocks_(memoryRemap->getMemoryBlocks()),\r\nexpressionParser_(expressionParser),\r\nmemoryMapValidator_(memoryMapValidator),\r\nmapInterface_(mapInterface)\r\n{\r\n    setReferenceCounter(referenceCounter);\r\n    setParameterFinder(parameterFinder);\r\n    setExpressionFormatter(expressionFormatter);\r\n\r\n\tsetObjectName(tr(\"ComponentEditorMemMapItem\"));\r\n\r\n    const int blockCount = memoryBlocks_->count();\r\n    for (int i = 0; i < blockCount; ++i)\r\n    {\r\n        createChild(i);\r\n    }\r\n\r\n\r\n    Q_ASSERT(memoryRemap_);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryRemapItem::~MemoryRemapItem()\r\n//-----------------------------------------------------------------------------\r\nMemoryRemapItem::~MemoryRemapItem()\r\n{\r\n    if (visualizer_)\r\n    {\r\n        delete visualizer_;\r\n        visualizer_ = nullptr;\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryRemapItem::text()\r\n//-----------------------------------------------------------------------------\r\nQString MemoryRemapItem::text() const\r\n{\r\n    QSharedPointer<MemoryMap> transFormedMemoryRemap = memoryRemap_.dynamicCast<MemoryMap>();\r\n    if (transFormedMemoryRemap && transFormedMemoryRemap == parentMemoryMap_)\r\n    {\r\n        return QString(\"Default\");\r\n    }\r\n    else\r\n    {\r\n        return memoryRemap_->name();\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryRemapItem::isValid()\r\n//-----------------------------------------------------------------------------\r\nbool MemoryRemapItem::isValid() const\r\n{\r\n    bool baseIsValid = memoryMapValidator_->MemoryMapBaseValidator::validate(\r\n        memoryRemap_, parentMemoryMap_->getAddressUnitBits());\r\n\r\n    QSharedPointer<MemoryRemap> transformedMemoryRemap = memoryRemap_.dynamicCast<MemoryRemap>();\r\n\r\n    if (transformedMemoryRemap)\r\n    {\r\n        return baseIsValid && memoryMapValidator_->hasValidRemapStateOrModeReferences(parentMemoryMap_, transformedMemoryRemap);\r\n    }\r\n    else\r\n    {\r\n        return baseIsValid && memoryMapValidator_->hasValidAddressUnitBits(parentMemoryMap_);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryRemapItem::editor()\r\n//-----------------------------------------------------------------------------\r\nItemEditor* MemoryRemapItem::editor()\r\n{\r\n    if (!editor_)\r\n    {\r\n        bool editorIsForMemoryRemap = true;\r\n        if (memoryRemap_ == parentMemoryMap_)\r\n        {\r\n            editorIsForMemoryRemap = false;\r\n        }\r\n\r\n        editor_ = new SingleMemoryMapEditor(component_, memoryRemap_, parentMemoryMap_->name(), libHandler_,\r\n            parameterFinder_, expressionParser_, mapInterface_, editorIsForMemoryRemap);\r\n        editor_->setProtection(locked_);\r\n        \r\n        connect(editor_, SIGNAL(contentChanged()), this, SLOT(onEditorChanged()), Qt::UniqueConnection);\r\n        connect(editor_, SIGNAL(graphicsChanged()), this, SLOT(onGraphicsChanged()), Qt::UniqueConnection);\r\n        connect(editor_, SIGNAL(childGraphicsChanged(int)), this, SLOT(onChildGraphicsChanged(int)), Qt::UniqueConnection);        \r\n        connect(editor_, SIGNAL(childAddressingChanged(int)),\r\n            this, SLOT(onChildAddressingChanged(int)), Qt::UniqueConnection);\r\n        connect(editor_, SIGNAL(childAdded(int)), this, SLOT(onAddChild(int)), Qt::UniqueConnection);\r\n        connect(editor_, SIGNAL(childRemoved(int)), this, SLOT(onRemoveChild(int)), Qt::UniqueConnection);\r\n        connect(editor_, SIGNAL(helpUrlRequested(QString const&)), this, SIGNAL(helpUrlRequested(QString const&)));\r\n        connect(editor_, SIGNAL(addressUnitBitsChanged()),\r\n            this, SLOT(changeAdressUnitBitsOnAddressBlocks()), Qt::UniqueConnection);\r\n\r\n        connect(editor_, SIGNAL(addressUnitBitsChanged()),\r\n            this, SIGNAL(addressUnitBitsChanged()), Qt::UniqueConnection);\r\n\r\n        connect(this, SIGNAL(assignNewAddressUnitBits(QString const&)),\r\n            editor_, SIGNAL(assignNewAddressUnitBits(QString const&)), Qt::UniqueConnection);\r\n\r\n        connect(editor_, SIGNAL(addressBlockNameChanged(QString const&, QString const&)),\r\n            this, SIGNAL(addressBlockNameChanged(QString const&, QString const&)), Qt::UniqueConnection);\r\n\r\n        connect(editor_, SIGNAL(subspaceMapNameChanged(QString const&, QString const&)),\r\n            this, SIGNAL(subspaceMapNameChanged(QString const&, QString const&)), Qt::UniqueConnection);\r\n\r\n        connect(this, SIGNAL(memoryMapNameChanged(QString const&, QString const&)),\r\n            editor_, SLOT(onMemoryMapNameChanged(QString const&, QString const&)), Qt::UniqueConnection);\r\n        connect(this, SIGNAL(memoryRemapNameChanged(QString const&, QString const&, QString const&)),\r\n            editor_, SLOT(onMemoryRemapNameChanged(QString const&, QString const&, QString const&)),\r\n            Qt::UniqueConnection);\r\n\r\n        connectItemEditorToReferenceCounter();\r\n    }\r\n\r\n    return editor_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryRemapItem::getTooltip()\r\n//-----------------------------------------------------------------------------\r\nQString MemoryRemapItem::getTooltip() const\r\n{\r\n    if (memoryRemap_->name() == parentMemoryMap_->name())\r\n    {\r\n        return tr(\"The default memory map of \") + parentMemoryMap_->name() + \".\";\r\n    }\r\n\r\n    return tr(\"Contains the details of a memory remap.\");\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryRemapItem::createChild()\r\n//-----------------------------------------------------------------------------\r\nvoid MemoryRemapItem::createChild( int index )\r\n{\r\n\tQSharedPointer<AddressBlock> addrBlock = memoryBlocks_->at(index).dynamicCast<AddressBlock>();\r\n\tif (addrBlock)\r\n    {\r\n        QSharedPointer<ComponentEditorAddrBlockItem> addrBlockItem(new ComponentEditorAddrBlockItem(\r\n            memoryRemap_, addrBlock, model_, libHandler_, component_, referenceCounter_, parameterFinder_,\r\n            expressionFormatter_, expressionParser_, memoryMapValidator_->getAddressBlockValidator(),\r\n            mapInterface_->getAddressBlockInterface(), this));\r\n\r\n        connect(this, SIGNAL(addressBlockNameChanged(QString const&, QString const&)),\r\n            addrBlockItem.data(), SIGNAL(addressBlockNameChanged(QString const&, QString const&)),\r\n            Qt::UniqueConnection);\r\n\r\n\t\taddrBlockItem->setLocked(locked_);\r\n\r\n        int addressUnitBits = expressionParser_->parseExpression(parentMemoryMap_->getAddressUnitBits()).toInt();\r\n        addrBlockItem->addressUnitBitsChanged(addressUnitBits);\r\n\r\n\t\tif (visualizer_)\r\n        {\r\n\t\t\taddrBlockItem->setVisualizer(visualizer_);\r\n\r\n            auto childItem = static_cast<MemoryVisualizationItem*>(addrBlockItem->getGraphicsItem());\r\n            Q_ASSERT(childItem);\r\n\r\n            graphItem_->addChild(childItem);\r\n            childItem->setParent(graphItem_);\r\n\r\n            onAddressingChanged();\r\n\t\t}\r\n\r\n        connect(addrBlockItem.data(), SIGNAL(addressingChanged()),\r\n            this, SLOT(onAddressingChanged()), Qt::UniqueConnection);\r\n\r\n\t\tchildItems_.insert(index, addrBlockItem);\r\n\t}\r\n    else\r\n    {\r\n        QSharedPointer<SubSpaceMap> subspace = memoryBlocks_->at(index).dynamicCast<SubSpaceMap>();\r\n        if (subspace)\r\n        {\r\n            QSharedPointer<SubspaceMapItem> subspaceItem(new SubspaceMapItem(memoryRemap_, subspace, model_,\r\n                libHandler_, component_, referenceCounter_, parameterFinder_, expressionFormatter_,\r\n                expressionParser_, memoryMapValidator_->getSubspaceValidator(),\r\n                mapInterface_->getSubspaceMapInterface(), this));\r\n\r\n            connect(this, SIGNAL(subspaceMapNameChanged(QString const&, QString const&)),\r\n                subspaceItem.data(), SIGNAL(subspaceNameChanged(QString const&, QString const&)),\r\n                Qt::UniqueConnection);\r\n\r\n            subspaceItem->setLocked(locked_);\r\n\r\n            int addressUnitBits = expressionParser_->parseExpression(parentMemoryMap_->getAddressUnitBits()).toInt();\r\n            subspaceItem->addressUnitBitsChanged(addressUnitBits);\r\n\r\n            if (visualizer_)\r\n            {\r\n                subspaceItem->setVisualizer(visualizer_);\r\n\r\n                auto childItem = dynamic_cast<MemoryVisualizationItem*>(subspaceItem->getGraphicsItem());\r\n                Q_ASSERT(childItem);\r\n\r\n                graphItem_->addChild(childItem);\r\n                childItem->setParent(graphItem_);\r\n\r\n                onAddressingChanged();\r\n            }\r\n\r\n            connect(subspaceItem.data(), SIGNAL(addressingChanged()),\r\n                this, SLOT(onAddressingChanged()), Qt::UniqueConnection);\r\n\r\n            childItems_.insert(index, subspaceItem);\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryRemapItem::removeChild()\r\n//-----------------------------------------------------------------------------\r\nvoid MemoryRemapItem::removeChild(int index)\r\n{\r\n    ComponentEditorItem::removeChild(index);\r\n\r\n    onAddressingChanged();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryRemapItem::visualizer()\r\n//-----------------------------------------------------------------------------\r\nItemVisualizer* MemoryRemapItem::visualizer()\r\n{\r\n    return visualizer_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryRemapItem::setVisualizer()\r\n//-----------------------------------------------------------------------------\r\nvoid MemoryRemapItem::setVisualizer( MemoryMapsVisualizer* visualizer )\r\n{\r\n\tvisualizer_ = visualizer;\r\n\r\n\tgraphItem_ = new MemoryMapGraphItem(parentMemoryMap_, memoryRemap_, expressionParser_);\r\n\tvisualizer_->addMemoryMapItem(graphItem_);\r\n\tgraphItem_->updateDisplay();\r\n\r\n    changeAdressUnitBitsOnAddressBlocks();\r\n\r\n\t// update the visualizers of address block items\r\n\tfor (auto item : childItems_)\r\n    {\r\n        auto addrItem = item.dynamicCast<ComponentEditorAddrBlockItem>();\r\n        if (addrItem)\r\n        {\r\n            addrItem->setVisualizer(visualizer_);\r\n\r\n            auto childGraphicItem = static_cast<MemoryVisualizationItem*>(addrItem->getGraphicsItem());\r\n            graphItem_->addChild(childGraphicItem);\r\n        }\r\n        else\r\n        {\r\n            auto subspaceItem = item.dynamicCast<SubspaceMapItem>();\r\n            if (subspaceItem)\r\n            {\r\n                subspaceItem->setVisualizer(visualizer_);\r\n\r\n                auto childGraphicItem = static_cast<MemoryVisualizationItem*>(subspaceItem->getGraphicsItem());\r\n                graphItem_->addChild(childGraphicItem);\r\n            }\r\n        }\r\n\t}\r\n\r\n    graphItem_->redoChildLayout();\r\n\r\n\tconnect(graphItem_, SIGNAL(selectEditor()),\tthis, SLOT(onSelectRequest()), Qt::UniqueConnection);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryRemapItem::getGraphicsItem()\r\n//-----------------------------------------------------------------------------\r\nQGraphicsItem* MemoryRemapItem::getGraphicsItem()\r\n{\r\n    return graphItem_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryRemapItem::updateGraphics()\r\n//-----------------------------------------------------------------------------\r\nvoid MemoryRemapItem::updateGraphics()\r\n{    \r\n    if (graphItem_)\r\n    {\r\n        graphItem_->updateDisplay();\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryRemapItem::removeGraphicsItem()\r\n//-----------------------------------------------------------------------------\r\nvoid MemoryRemapItem::removeGraphicsItem()\r\n{\r\n    if (graphItem_)\r\n    {\r\n        // remove the graph item from the scene\r\n        visualizer_->removeMemoryMapItem(graphItem_);\r\n\r\n        disconnect(graphItem_, SIGNAL(selectEditor()), this, SLOT(onSelectRequest()));\r\n        \r\n        graphItem_->setParent(nullptr);\r\n\r\n        // delete the graph item\r\n        delete graphItem_;\r\n        graphItem_ = nullptr;\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryRemapItem::onChildGraphicsChanged()\r\n//-----------------------------------------------------------------------------\r\nvoid MemoryRemapItem::onChildGraphicsChanged(int index)\r\n{\r\n    childItems_.at(index)->updateGraphics();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryRemapItem::onAddressingChanged()\r\n//-----------------------------------------------------------------------------\r\nvoid MemoryRemapItem::onAddressingChanged()\r\n{\r\n    if (graphItem_ != nullptr)\r\n    {\r\n        graphItem_->updateDisplay();\r\n        graphItem_->redoChildLayout();\r\n\r\n        emit addressingChanged();\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryRemapItem::onChildAddressingChanged()\r\n//-----------------------------------------------------------------------------\r\nvoid MemoryRemapItem::onChildAddressingChanged(int index)\r\n{\r\n    if (graphItem_ != nullptr)\r\n    {\r\n        auto childBlock = childItems_.at(index).dynamicCast<ComponentEditorAddrBlockItem>();\r\n\r\n        if (childBlock)\r\n        {\r\n            childBlock->updateGraphics();\r\n            childBlock->onAddressingChanged();\r\n        }\r\n        else\r\n        {\r\n            auto childSubspace = childItems_.at(index).dynamicCast<SubspaceMapItem>();\r\n\r\n            if (childSubspace)\r\n            {\r\n                childSubspace->updateGraphics();\r\n                childSubspace->onAddressingChanged();\r\n            }\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryRemapItem::changeAdressUnitBitsOnAddressBlocks()\r\n//-----------------------------------------------------------------------------\r\nvoid MemoryRemapItem::changeAdressUnitBitsOnAddressBlocks()\r\n{\r\n    QString addressUnitBits = parentMemoryMap_->getAddressUnitBits();\r\n\r\n    for (QSharedPointer<ComponentEditorItem> childItem : childItems_)\r\n    {\r\n        QSharedPointer<ComponentEditorAddrBlockItem> castChildItem = \r\n            qobject_cast<QSharedPointer<ComponentEditorAddrBlockItem> >(childItem);\r\n        if (castChildItem)\r\n        {\r\n            int newAddressUnitBits = expressionParser_->parseExpression(addressUnitBits).toInt();\r\n            castChildItem->addressUnitBitsChanged(newAddressUnitBits);\r\n        }\r\n        else\r\n        {\r\n            QSharedPointer<SubspaceMapItem> castSubspaceItem =\r\n                qobject_cast<QSharedPointer<SubspaceMapItem>>(childItem);\r\n            if (castSubspaceItem)\r\n            {\r\n                int newAddressUnitBits = expressionParser_->parseExpression(addressUnitBits).toInt();\r\n                castSubspaceItem->addressUnitBitsChanged(newAddressUnitBits);\r\n            }\r\n        }\r\n    }\r\n\r\n    if (editor_)\r\n    {\r\n        emit assignNewAddressUnitBits(addressUnitBits);\r\n    }\r\n}\r\n"
  },
  {
    "path": "editors/ComponentEditor/treeStructure/MemoryRemapItem.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: MemoryRemapItem.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Mikko Teuho\r\n// Date: 16.04.2015\r\n//\r\n// Description:\r\n// The item for a single memory remap in component editor's navigation tree.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef MEMORYREMAPITEM_H\r\n#define MEMORYREMAPITEM_H\r\n\r\n#include \"componenteditoritem.h\"\r\n\r\n#include <QSharedPointer>\r\n#include <QList>\r\n\r\nclass MemoryMapEditor;\r\nclass MemoryMapsVisualizer;\r\nclass MemoryMapGraphItem;\r\nclass ExpressionParser;\r\nclass MemoryMap;\r\nclass MemoryMapBase;\r\nclass MemoryBlockBase;\r\nclass MemoryMapValidator;\r\nclass MemoryMapInterface;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! The item for a single memory remap in component editor's navigation tree.\r\n//-----------------------------------------------------------------------------\r\nclass MemoryRemapItem : public ComponentEditorItem\r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\r\n    /*!\r\n     *  The constructor.\r\n     *\r\n     *    @param [in] memoryRemap             The memory remap being edited.\r\n     *    @param [in] parentMemoryMap         The parent memory map of the memory remap.\r\n     *    @param [in] model                   The model that owns the items.\r\n     *    @param [in] libHandler              The instance that manages the library.\r\n     *    @param [in] component               The component being edited.\r\n     *    @param [in] referenceCounter        The instance for counting references to parameters.\r\n     *    @param [in] parameterFinder         The parameter finder.\r\n     *    @param [in] expressionFormatter     The expression formatter.\r\n     *    @param [in] expressionParser        The expression parser to use.\r\n     *    @param [in] memoryMapValidator      Validator for memory maps.\r\n     *    @param [in] mapInterface            Interface for accessing memory maps.\r\n     *    @param [in] parent                  The parent item.\r\n     */\r\n    MemoryRemapItem(QSharedPointer<MemoryMapBase> memoryRemap,\r\n        QSharedPointer<MemoryMap> parentMemoryMap,\r\n        ComponentEditorTreeModel* model,\r\n        LibraryInterface* libHandler,\r\n        QSharedPointer<Component> component,\r\n        QSharedPointer<ReferenceCounter> referenceCounter,\r\n        QSharedPointer<ParameterFinder> parameterFinder,\r\n        QSharedPointer<ExpressionFormatter> expressionFormatter,\r\n        QSharedPointer<ExpressionParser> expressionParser,\r\n        QSharedPointer<MemoryMapValidator> memoryMapValidator,\r\n        MemoryMapInterface* mapInterface,\r\n        ComponentEditorItem* parent);\r\n\r\n    /*!\r\n     *  The destructor.\r\n     */\r\n    virtual ~MemoryRemapItem();\r\n\r\n    //! No copying\r\n    MemoryRemapItem(const MemoryRemapItem& other) = delete;\r\n\r\n    //! No assignment\r\n    MemoryRemapItem& operator=(const MemoryRemapItem& other) = delete;\r\n\r\n\t/*!\r\n\t *  Get the tool tip for this item.\r\n\t *\r\n     *    @return The text for the tool tip to print to user.\r\n\t */\r\n\tvirtual QString getTooltip() const;\r\n\r\n\t/*!\r\n\t *  Get the text to be displayed to user in the tree for this item.\r\n\t *\r\n     *    @return The text to display.\r\n\t */\r\n\tvirtual QString text() const;\r\n\r\n\t/*!\r\n\t *  Check the validity of this item and sub items.\r\n\t *\r\n     *    @return True, if the item is in a valid state, false otherwise.\r\n\t */\r\n\tvirtual bool isValid() const;\r\n\r\n\t/*!\r\n\t *  Get the The editor of this item.\r\n\t *\r\n     *    @return The editor to use for this item.\r\n\t */\r\n\tvirtual ItemEditor* editor();\r\n\r\n\t/*!\r\n\t *  Add a new child to the item.\r\n\t *\r\n\t *    @param [in] index   The index of the new child.\r\n\t */\r\n\tvirtual void createChild(int index) override final;\r\n\r\n    virtual void removeChild(int index) override final;\r\n\r\n\t/*!\r\n\t *  Get The visualizer of this item.\r\n\t *\r\n     *    @return The visualizer to user for this item.\r\n\t */\r\n\tvirtual ItemVisualizer* visualizer();\r\n\r\n\t/*!\r\n\t *  Set the visualizer for this item.\r\n\t *\r\n\t *    @param [in] visualizer  The visualizer.\r\n\t */\r\n\tvirtual void setVisualizer(MemoryMapsVisualizer* visualizer);\r\n\r\n\t/*!\r\n\t *  Get the visualizer graphics item for the memory remap.\r\n\t *\r\n     *    @return The graphics item.\r\n\t */\r\n\tvirtual QGraphicsItem* getGraphicsItem();\r\n\r\n\t/*!\r\n\t *  Update the graphics item of the memory map.\r\n\t */\r\n\tvirtual void updateGraphics();\r\n\r\n\t/*!\r\n\t *  Remove the graphics item of the memory map.\r\n\t */\r\n\tvirtual void removeGraphicsItem();\r\n\r\npublic slots:\r\n\r\n    void onChildGraphicsChanged(int index);\r\n\r\n    //! Handle the change in item's addressing data.\r\n    void onAddressingChanged();\r\n\r\n    //! Handle the change in child item's addressing data.\r\n    void onChildAddressingChanged(int index);\r\n\r\n    /*!\r\n     *  Change the address unit bits for the address blocks.\r\n     */\r\n    void changeAdressUnitBitsOnAddressBlocks();\r\n\r\nsignals:\r\n\r\n    /*!\r\n     *  Informs of a change in address unit bits.\r\n     */\r\n    void addressUnitBitsChanged();\r\n\r\n    /*!\r\n     *  Change the used address unit bits in the editor.\r\n     *\r\n     *    @param [in] newAddressUnitBits  The new address unit bits.\r\n     */\r\n    void assignNewAddressUnitBits(QString const& newAddressUnitBits);\r\n\r\n\r\n    //! Signals a change in the item's address data.\r\n    void addressingChanged();\r\n\r\n    /*\r\n     *  Informs of address block name change.\r\n     *\r\n     *    @param [in] oldName     The old name.\r\n     *    @param [in] newName     The new name.\r\n     */\r\n    void addressBlockNameChanged(QString const& oldName, QString const& newName);\r\n    \r\n    /*\r\n     *  Informs of subspace map name change.\r\n     *\r\n     *    @param [in] oldName     The old name.\r\n     *    @param [in] newName     The new name.\r\n     */\r\n    void subspaceMapNameChanged(QString const& oldName, QString const& newName);\r\n\r\n    /*\r\n     *  Informs of memory map name change.\r\n     *\r\n     *    @param [in] oldName     The old name.\r\n     *    @param [in] newName     The new name.\r\n     */\r\n    void memoryMapNameChanged(QString const& oldName, QString const& newName);\r\n\r\n    /*\r\n     *  Informs of memory remap name change.\r\n     *\r\n     *    @param [in] parentName  Name of the containing memory map.\r\n     *    @param [in] oldName     The old name.\r\n     *    @param [in] newName     The new name.\r\n     */\r\n    void memoryRemapNameChanged(QString const& parentName, QString const& oldName, QString const& newName);\r\n\r\nprivate:\r\n\r\n\t//! The memory remap being edited.\r\n    QSharedPointer<MemoryMapBase> memoryRemap_;\r\n\r\n    //! The parent memory map of this memory remap.\r\n    QSharedPointer<MemoryMap> parentMemoryMap_;\r\n\r\n\t//! Contains the address blocks that are children of this tree item.\r\n    QSharedPointer<QList<QSharedPointer<MemoryBlockBase> > > memoryBlocks_;\r\n\r\n\t//! The visualizer to display the memory maps\r\n\tMemoryMapsVisualizer* visualizer_ = nullptr;\r\n\r\n\t//! The graph item which visualizes this memory map.\r\n\tMemoryMapGraphItem* graphItem_ = nullptr;\r\n\r\n    //! The expression parser to use.\r\n    QSharedPointer<ExpressionParser> expressionParser_;\r\n\r\n    //! The used memory map validator.\r\n    QSharedPointer<MemoryMapValidator> memoryMapValidator_;\r\n\r\n    //! Interface for memory maps.\r\n    MemoryMapInterface* mapInterface_;\r\n};\r\n\r\n#endif // MEMORYREMAPITEM_H\r\n"
  },
  {
    "path": "editors/ComponentEditor/treeStructure/ModesItem.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: ModesItem.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Esko Pekkarinen\n// Date: 08.08.2023\n//\n// Description:\n// The Modes-item in the component editor navigation tree.\n//-----------------------------------------------------------------------------\n\n#include \"ModesItem.h\"\n#include \"SingleModeItem.h\"\n\n#include <editors/ComponentEditor/modes/ModesEditor.h>\n#include <editors/common/ExpressionSet.h>\n\n#include <IPXACTmodels/Component/Component.h>\n#include <IPXACTmodels/Component/Mode.h>\n#include <IPXACTmodels/Component/validators/ModeValidator.h>\n#include <IPXACTmodels/Component/validators/PortSliceValidator.h>\n#include <IPXACTmodels/common/validators/HierarchicalValidator.h>\n\n#include <KactusAPI/include/ModeConditionParser.h>\n\n//-----------------------------------------------------------------------------\n// Function: ModesItem::ModesItem()\n//-----------------------------------------------------------------------------\nModesItem::ModesItem(ComponentEditorTreeModel* model, LibraryInterface* libHandler,\n    QSharedPointer<Component> component, \n    QSharedPointer<ReferenceCounter> referenceCounter,\n    ExpressionSet expressions,\n    ComponentEditorItem* parent):\nComponentEditorItem(model, libHandler, component, parent),\nmodes_(component->getModes()),\nexpressions_(expressions),\nmodeValidator_(new ModeValidator(component, nullptr)),\nmodesValidator_(new HierarchicalValidator())\n{\n    setParameterFinder(expressions.finder);\n    setExpressionFormatter(expressions.formatter);\n    setReferenceCounter(referenceCounter);\n\n    modesValidator_->setChildValidator(modeValidator_);\n\n    const auto MODE_COUNT = modes_->count();\n    for (int i = 0; i < MODE_COUNT; ++i)\n    {\n        ModesItem::createChild(i);\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: ModesItem::getFont()\n//-----------------------------------------------------------------------------\nQFont ModesItem::getFont() const\n{\n    QFont font(ComponentEditorItem::getFont());\n    font.setBold(!childItems_.isEmpty());\n    return font;\n}\n\n//-----------------------------------------------------------------------------\n// Function: ModesItem::text()\n//-----------------------------------------------------------------------------\nQString ModesItem::text() const\n{\n    return tr(\"Modes\");\n}\n\n//-----------------------------------------------------------------------------\n// Function: ModesItem::editor()\n//-----------------------------------------------------------------------------\nItemEditor* ModesItem::editor()\n{\n    if (!editor_)\n    {\n        editor_ = new ModesEditor(component_, libHandler_);\n        editor_->setProtection(locked_);\n        \n        connect(editor_, SIGNAL(contentChanged()), this, SLOT(onEditorChanged()), Qt::UniqueConnection);\n        connect(editor_, SIGNAL(childAdded(int)), this, SLOT(onAddChild(int)), Qt::UniqueConnection);\n        connect(editor_, SIGNAL(childRemoved(int)), this, SLOT(onRemoveChild(int)), Qt::UniqueConnection);\n        connect(editor_, SIGNAL(helpUrlRequested(QString const&)),\n            this, SIGNAL(helpUrlRequested(QString const&)), Qt::UniqueConnection);\n\n        connectItemEditorToReferenceCounter();\n    }\n\n    return editor_;\n}\n\n//-----------------------------------------------------------------------------\n// Function: ModesItem::getTooltip()\n//-----------------------------------------------------------------------------\nQString ModesItem::getTooltip() const\n{\n    return tr(\"Contains the operation modes of the component\");\n}\n\n//-----------------------------------------------------------------------------\n// Function: ModesItem::createChild()\n//-----------------------------------------------------------------------------\nvoid ModesItem::createChild(int index)\n{\n    auto mode = modes_->at(index);\n\n    QSharedPointer<ModeConditionParser> parser(new ModeConditionParser(expressions_.finder,\n        mode->getPortSlices(), mode->getFieldSlices(), component_->getModes()));\n\n    QSharedPointer<SingleModeItem> modeItem(new SingleModeItem(mode, model_,\n        libHandler_, component_, referenceCounter_, expressions_, modeValidator_, parser, this));\n\n    modeItem->setLocked(locked_);\n\n    childItems_.insert(index, modeItem);\n}\n\n//-----------------------------------------------------------------------------\n// Function: ModesItem::isValid()\n//-----------------------------------------------------------------------------\nbool ModesItem::isValid() const\n{\n    auto modesAsNameGroup = CollectionValidators::itemListToNameGroupList(modes_);\n    modesValidator_->childrenHaveUniqueNames(modesAsNameGroup);\n    return ComponentEditorItem::isValid();\n}\n"
  },
  {
    "path": "editors/ComponentEditor/treeStructure/ModesItem.h",
    "content": "//-----------------------------------------------------------------------------\n// File: ModesItem.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Esko Pekkarinen\n// Date: 08.08.2023\n//\n// Description:\n// The Modes-item in the component editor navigation tree.\n//-----------------------------------------------------------------------------\n\n#ifndef MODESITEM_H\n#define MODESITEM_H\n\n#include \"componenteditoritem.h\"\n\n#include <editors/common/ExpressionSet.h>\n\nclass ExpressionParser;\nclass Mode;\nclass ModeValidator;\nclass HierarchicalValidator;\n\n//-----------------------------------------------------------------------------\n//! The Modes-item used in the component editor navigation tree.\n//-----------------------------------------------------------------------------\nclass ModesItem : public ComponentEditorItem\n{\n\tQ_OBJECT\n\npublic:\n\t\n\t/*!\n\t *  The constructor.\n\t *\n\t *    @param [in] model                   The model that owns the items.\n\t *    @param [in] libHandler              The instance that manages the library.\n\t *    @param [in] component               The component being edited.\n     *    @param [in] referenceCounter        The counter for the references.\n     *    @param [in] parameterFinder         Finds the referenced parameters.\n     *    @param [in] expressionFormatter     Changes the referenced ids to parameter names.\n     *    @param [in] expressionParser        Expression parser for remap states.\n\t *    @param [in] parent                  The parent item.\n\t */\n    ModesItem(ComponentEditorTreeModel* model,\n        LibraryInterface* libHandler,\n        QSharedPointer<Component> component,\n        QSharedPointer<ReferenceCounter> referenceCounter,\n        ExpressionSet expressions,\n        ComponentEditorItem* parent);\n\n    /*!\n     *  The destructor.\n     */\n    virtual ~ModesItem() = default;\n\n    /*!\n\t *  Get the font to be used for text of this item.\n\t *\n     *    @return The font to be used.\n\t */\n\tvirtual QFont getFont() const;\n\n    /*!\n\t *  Get the tool tip for the item.\n\t *\n     *    @return The text for the tool tip for the item.\n\t */\n\tvirtual QString getTooltip() const;\n\n    /*!\n\t *  Get the text to be displayed in the tree for this item.\n\t *\n     *    @return The text to be displayed.\n\t */\n\tvirtual QString text() const;\n\n    /*!\n\t *  Get the The editor of this item.\n\t *\n     *    @return The editor to use with this item.\n\t */\n\tvirtual ItemEditor* editor();\n\n    /*!\n     *  Create a child item.\n     *\n     *    @param [in] index   The index of the child item.\n     */\n    virtual void createChild(int index);\n\n    /*!\n     *  Check the validity of this item.\n     *\n     *    @return bool True if item is in valid state.\n     */\n    bool isValid() const override;\n\nprivate:\n\t//! No copying\n    ModesItem(const ModesItem& other);\n\n\t//! No assignment\n    ModesItem& operator=(const ModesItem& other);\n\n    //! The list containing the modes to edit.\n    QSharedPointer<QList<QSharedPointer<Mode> > > modes_;\n\n    ExpressionSet expressions_;\n\n    //! The mode validator to use.\n    QSharedPointer<ModeValidator> modeValidator_;\n\n    //! The validator to validate modes together.\n    QSharedPointer<HierarchicalValidator> modesValidator_;\n\n};\n\n#endif // MODESITEM_H\n"
  },
  {
    "path": "editors/ComponentEditor/treeStructure/ParameterizableItem.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: ParameterizableItem.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 06.10.2017\n//\n// Description:\n// Component editor item for handling parameter signals.\n//-----------------------------------------------------------------------------\n\n#include \"ParameterizableItem.h\"\n\n#include <editors/ComponentEditor/itemeditor.h>\n#include <KactusAPI/include/ParametersInterface.h>\n\n//-----------------------------------------------------------------------------\n// Function: ParameterizableItem::ParameterizableItem()\n//-----------------------------------------------------------------------------\nParameterizableItem::ParameterizableItem(ComponentEditorTreeModel* model, LibraryInterface* libHandler,\n    QSharedPointer<Component> component, ComponentEditorItem* parent):\nComponentEditorItem(model, libHandler, component, parent)\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: ParameterizableItem::ParameterizableItem()\n//-----------------------------------------------------------------------------\nParameterizableItem::ParameterizableItem(LibraryInterface* libHandler, QSharedPointer<Component> component,\n    ComponentEditorTreeModel* parent):\nComponentEditorItem(libHandler, component, parent)\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: ParameterizableItem::~ParameterizableItem()\n//-----------------------------------------------------------------------------\nParameterizableItem::~ParameterizableItem()\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: ParameterizableItem::connectItemEditorToReferenceCounter()\n//-----------------------------------------------------------------------------\nvoid ParameterizableItem::connectItemEditorToReferenceCounter()\n{\n    ComponentEditorItem::connectItemEditorToReferenceCounter();\n\n    void recalculateReferencesToParameters(std::vector<std::string> const& parameterList);\n\n    connect(editor_,\n        SIGNAL(recalculateReferencesToParameters(QVector<QString> const&, AbstractParameterInterface*)),\n        referenceCounter_.data(),\n        SLOT(recalculateReferencesToParameters(QVector<QString> const&, AbstractParameterInterface*)),\n        Qt::UniqueConnection);\n}\n\n//-----------------------------------------------------------------------------\n// Function: ParameterizableItem::connectReferenceTree()\n//-----------------------------------------------------------------------------\nvoid ParameterizableItem::connectReferenceTree()\n{\n    connect(editor_, SIGNAL(openReferenceTree(QString const&, QString const&)),\n        this, SIGNAL(openReferenceTree(QString const&, QString const&)), Qt::UniqueConnection);\n}\n"
  },
  {
    "path": "editors/ComponentEditor/treeStructure/ParameterizableItem.h",
    "content": "//-----------------------------------------------------------------------------\n// File: ParameterizableItem.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 06.10.2017\n//\n// Description:\n// Component editor item for handling parameter signals.\n//-----------------------------------------------------------------------------\n\n#ifndef PARAMETERIZABLEITEM_H\n#define PARAMETERIZABLEITEM_H\n\n#include <KactusAPI/include/ParameterFinder.h>\n#include <KactusAPI/include/ExpressionFormatter.h>\n#include <editors/ComponentEditor/referenceCounter/ReferenceCounter.h>\n#include <editors/ComponentEditor/treeStructure/componenteditoritem.h>\n\n#include <QObject>\n\nclass LibraryInterface;\nclass ComponentEditorTreeModel;\nclass Component;\n\n//-----------------------------------------------------------------------------\n//! Component editor item for handling parameter signals.\n//-----------------------------------------------------------------------------\nclass ParameterizableItem : public ComponentEditorItem\n{\n    Q_OBJECT\n\npublic:\n\n\t/*!\n     *  The constructor.\n\t *\n\t *    @param [in] model       Pointer to the model that owns the items.\n\t *    @param [in] libHandler  Pointer to the instance that manages the library.\n\t *    @param [in] component   Pointer to the component being edited.\n\t *    @param [in] parent      Pointer to the parent item.\n\t */\n\tParameterizableItem(ComponentEditorTreeModel* model, LibraryInterface* libHandler,\n        QSharedPointer<Component> component, ComponentEditorItem* parent);\n\t\n\t/*!\n     *  The constructor for root item.\n\t *\n\t *    @param [in] libHandler  Pointer to the instance that manages the library.\n\t *    @param [in] component   Pointer to the component being edited.\n\t *    @param [in] parent      Pointer to the parent object.\n\t */\n\tParameterizableItem(LibraryInterface* libHandler, QSharedPointer<Component> component,\n        ComponentEditorTreeModel* parent);\n\n\t/*!\n     *  The destructor.\n     */\n    virtual ~ParameterizableItem();\n\nprotected:\n\n    /*!\n     *  Connects this component editor items item editor to its reference counter.\n     */\n    virtual void connectItemEditorToReferenceCounter();\n\n    /*!\n     *  Connect the signals related to a reference tree.\n     */\n    void connectReferenceTree();\n\nprivate:\n\n\t//! No copying or assignment.\n\tParameterizableItem(const ParameterizableItem& other);\n\tParameterizableItem& operator=(const ParameterizableItem& other);\n};\n\n#endif // PARAMETERIZABLEITEM_H\n"
  },
  {
    "path": "editors/ComponentEditor/treeStructure/PowerDomainsItem.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: PowerDomainsItem.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Esko Pekkarinen\n// Date: 05.10.2023\n//\n// Description:\n// The Power domains-item in the component editor's navigation tree.\n//-----------------------------------------------------------------------------\n\n#include \"PowerDomainsItem.h\"\n\n#include <IPXACTmodels/Component/Component.h>\n#include <IPXACTmodels/Component/PowerDomain.h>\n#include <IPXACTmodels/common/validators/ParameterValidator.h>\n\n#include <editors/ComponentEditor/powerDomains/PowerDomainsEditor.h>\n\n//-----------------------------------------------------------------------------\n// Function: PowerDomainsItem::PowerDomainsItem()\n//-----------------------------------------------------------------------------\nPowerDomainsItem::PowerDomainsItem(ComponentEditorTreeModel* model, LibraryInterface* libHandler,\n    QSharedPointer<Component> component, QSharedPointer<ReferenceCounter> referenceCounter, \n    ExpressionSet expressions, ComponentEditorItem* parent) :\nComponentEditorItem(model, libHandler, component, parent),\n    validator_(new PowerDomainValidator(component->getPowerDomains(), expressions.parser,\n        QSharedPointer<ParameterValidator>(new ParameterValidator(expressions.parser, component->getChoices(),\n            component->getRevision())))),\n    expressions_(expressions)\n{\n\n    setReferenceCounter(referenceCounter);\n}\n\n\n//-----------------------------------------------------------------------------\n// Function: PowerDomainsItem::getFont()\n//-----------------------------------------------------------------------------\nQFont PowerDomainsItem::getFont() const\n{\n    QFont font(ComponentEditorItem::getFont());\n    font.setBold(!component_->getPowerDomains()->isEmpty());\n    return font;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PowerDomainsItem::text()\n//-----------------------------------------------------------------------------\nQString PowerDomainsItem::text() const\n{\n\treturn tr(\"Power domains\");\n}\n\n//-----------------------------------------------------------------------------\n// Function: PowerDomainsItem::editor()\n//-----------------------------------------------------------------------------\nItemEditor* PowerDomainsItem::editor()\n{\n\tif (!editor_)\n    {\n        editor_ = new PowerDomainsEditor(component_, libHandler_, validator_, expressions_);\n        editor_->setProtection(locked_);\n        connect(editor_, SIGNAL(contentChanged()), this, SLOT(onEditorChanged()), Qt::UniqueConnection);\n        connect(editor_, SIGNAL(helpUrlRequested(QString const&)), this, SIGNAL(helpUrlRequested(QString const&)));\n\n        connectItemEditorToReferenceCounter();\n\t}\n\n\treturn editor_;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PowerDomainsItem::getTooltip()\n//-----------------------------------------------------------------------------\nQString PowerDomainsItem::getTooltip() const\n{\n\treturn tr(\"Contains the power domains of the component\");\n}\n\n//-----------------------------------------------------------------------------\n// Function: PowerDomainsItem::isValid()\n//-----------------------------------------------------------------------------\nbool PowerDomainsItem::isValid() const\n{\n    QVector<QString> domainNames;\n\n    return std::all_of(component_->getPowerDomains()->cbegin(), component_->getPowerDomains()->cend(),\n        [this, &domainNames](auto const& domain)\n        { \n            if (domainNames.contains(domain->name()) || !validator_->validate(domain))\n            {\n                return false;\n            }\n\n            domainNames.append(domain->name());\n            return true;\n        });\n}\n"
  },
  {
    "path": "editors/ComponentEditor/treeStructure/PowerDomainsItem.h",
    "content": "//-----------------------------------------------------------------------------\n// File: PowerDomainsItem.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Esko Pekkarinen\n// Date: 05.10.2023\n//\n// Description:\n// The Power domains-item in the component editor's navigation tree.\n//-----------------------------------------------------------------------------\n\n#ifndef POWERDOMAINSITEM_H\n#define POWERDOMAINSITEM_H\n\n#include \"componenteditoritem.h\"\n\n#include <IPXACTmodels/Component/validators/PowerDomainValidator.h>\n\n#include <editors/common/ExpressionSet.h>\n\n//-----------------------------------------------------------------------------\n//! The Reset types-item in the component editor's navigation tree.\n//-----------------------------------------------------------------------------\nclass PowerDomainsItem: public ComponentEditorItem\n{\n\tQ_OBJECT\n\npublic:\n\n\t/*!\n     *  The constructor.\n\t *\n\t *    @param [in] model\t\t\t\tThe model that owns the items.\n\t *    @param [in] libHandler\t\t\tThe instance that manages the library.\n     *    @param [in] component\t\t\tThe component being edited.\n\t *    @param [in] referenceCounter\tThe counter for tracking parameter references.\n     *    @param [in] expressions\t\t\tThe collection of objects for expression handling.\n     *    @param [in] parent\t\t\t\tThe parent item.\n     */\n    PowerDomainsItem(ComponentEditorTreeModel* model, \n\t\tLibraryInterface* libHandler,\n        QSharedPointer<Component> component, \n\t\tQSharedPointer<ReferenceCounter> referenceCounter,\n\t\tExpressionSet expressions, \n\t\tComponentEditorItem* parent);\n\n\t/*!\n     *  The destructor.\n     */\n    virtual ~PowerDomainsItem() = default;\n\n    //! No copying.\n    PowerDomainsItem(const PowerDomainsItem& other) =  delete;\n    PowerDomainsItem& operator=(const PowerDomainsItem& other) = delete;\n\n\t/*!\n     *  Get the font to be used for text of this item.\n\t *\n\t *    @return QFont instance that defines the font to be used.\n\t */\n\tvirtual QFont getFont() const;\n\n\t/*!\n     *  Get the tool tip for the item.\n\t * \n\t *    @return The text for the tool tip to print to user.\n\t */\n\tvirtual QString getTooltip() const;\n\n\t/*!\n     *  Get the text to be displayed to user in the tree for this item.\n\t *\n\t *    @return The text to display.\n     */\n\tvirtual QString text() const;\n\n\t/*!\n     *  Get The editor of this item.\n\t *\n\t *    @return The editor to use for this item.\n     */\n\tvirtual ItemEditor* editor();\n\n\t/*!\n     *  Check the validity of this item and sub items.\n\t *\n\t *    @return True if item is in valid state.\n     */\n\tvirtual bool isValid() const;\n\nprivate:\n\n    //! Validator for power domain items.\n    QSharedPointer<PowerDomainValidator> validator_;\n\t\n\t//! The collection of objects for expression handling.\n\tExpressionSet expressions_;\n};\n\n#endif // POWERDOMAINSITEM_H\n"
  },
  {
    "path": "editors/ComponentEditor/treeStructure/RemapStatesItem.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: RemapStatesItem.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Mikko Teuho\r\n// Date: 07.04.2015\r\n//\r\n// Description:\r\n// The Remap states-item in the component editor navigation tree.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"RemapStatesItem.h\"\r\n#include \"SingleRemapStateItem.h\"\r\n\r\n#include <editors/ComponentEditor/remapStates/RemapStatesEditor.h>\r\n\r\n#include <IPXACTmodels/Component/Component.h>\r\n#include <IPXACTmodels/Component/RemapState.h>\r\n#include <IPXACTmodels/Component/validators/RemapStateValidator.h>\r\n//-----------------------------------------------------------------------------\r\n// Function: RemapStatesItem::RemapStatesItem()\r\n//-----------------------------------------------------------------------------\r\nRemapStatesItem::RemapStatesItem(ComponentEditorTreeModel* model, LibraryInterface* libHandler,\r\n    QSharedPointer<Component> component, \r\n    QSharedPointer<ReferenceCounter> referenceCounter,\r\n    QSharedPointer<ParameterFinder> parameterFinder, \r\n    QSharedPointer<ExpressionFormatter> expressionFormatter,\r\n    QSharedPointer<ExpressionParser> expressionParser,\r\n    ComponentEditorItem* parent):\r\nComponentEditorItem(model, libHandler, component, parent),\r\nremapStates_(component->getRemapStates()),\r\nvalidator_(new RemapStateValidator(expressionParser, component->getPorts()))\r\n{\r\n    setParameterFinder(parameterFinder);\r\n    setExpressionFormatter(expressionFormatter);\r\n    setReferenceCounter(referenceCounter);\r\n\r\n    for (QSharedPointer<RemapState> remapState : *remapStates_)\r\n    {\r\n        QSharedPointer<SingleRemapStateItem> singleRemapItem(new SingleRemapStateItem(remapState, model,\r\n            libHandler, component, referenceCounter, parameterFinder, expressionFormatter, validator_, this));\r\n\r\n        childItems_.append(singleRemapItem);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: RemapStatesItem::getFont()\r\n//-----------------------------------------------------------------------------\r\nQFont RemapStatesItem::getFont() const\r\n{\r\n    QFont font(ComponentEditorItem::getFont());\r\n    font.setBold(!childItems_.isEmpty());\r\n    return font;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: RemapStatesItem::text()\r\n//-----------------------------------------------------------------------------\r\nQString RemapStatesItem::text() const\r\n{\r\n    return tr(\"Remap states\");\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: RemapStatesItem::editor()\r\n//-----------------------------------------------------------------------------\r\nItemEditor* RemapStatesItem::editor()\r\n{\r\n    if (!editor_)\r\n    {\r\n        editor_ = new RemapStatesEditor(component_, libHandler_, parameterFinder_);\r\n        editor_->setProtection(locked_);\r\n        \r\n        connect(editor_, SIGNAL(contentChanged()), this, SLOT(onEditorChanged()), Qt::UniqueConnection);\r\n        connect(editor_, SIGNAL(childAdded(int)), this, SLOT(onAddChild(int)), Qt::UniqueConnection);\r\n        connect(editor_, SIGNAL(childRemoved(int)), this, SLOT(onRemoveChild(int)), Qt::UniqueConnection);\r\n        connect(editor_, SIGNAL(helpUrlRequested(QString const&)),\r\n            this, SIGNAL(helpUrlRequested(QString const&)), Qt::UniqueConnection);\r\n\r\n        connectItemEditorToReferenceCounter();\r\n    }\r\n\r\n    return editor_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: RemapStatesItem::getTooltip()\r\n//-----------------------------------------------------------------------------\r\nQString RemapStatesItem::getTooltip() const\r\n{\r\n    return tr(\"Contains the remap states of the component\");\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: RemapStatesItem::createChild()\r\n//-----------------------------------------------------------------------------\r\nvoid RemapStatesItem::createChild(int index)\r\n{\r\n    QSharedPointer<SingleRemapStateItem> remapItem(new SingleRemapStateItem(remapStates_->at(index), model_,\r\n        libHandler_, component_, referenceCounter_, parameterFinder_, expressionFormatter_, validator_, this));\r\n\r\n    remapItem->setLocked(locked_);\r\n\r\n    childItems_.insert(index, remapItem);\r\n}\r\n"
  },
  {
    "path": "editors/ComponentEditor/treeStructure/RemapStatesItem.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: RemapStatesItem.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Mikko Teuho\r\n// Date: 07.04.2015\r\n//\r\n// Description:\r\n// The Remap states-item in the component editor navigation tree.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef REMAPSTATESITEM_H\r\n#define REMAPSTATESITEM_H\r\n\r\n#include \"componenteditoritem.h\"\r\n\r\nclass ExpressionParser;\r\nclass RemapState;\r\nclass RemapStateValidator;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! The remap states-item used in the component editor navigation tree.\r\n//-----------------------------------------------------------------------------\r\nclass RemapStatesItem : public ComponentEditorItem\r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\t\r\n\t/*!\r\n\t *  The constructor.\r\n\t *\r\n\t *    @param [in] model                   The model that owns the items.\r\n\t *    @param [in] libHandler              The instance that manages the library.\r\n\t *    @param [in] component               The component being edited.\r\n     *    @param [in] referenceCounter        The counter for the references.\r\n     *    @param [in] parameterFinder         Finds the referenced parameters.\r\n     *    @param [in] expressionFormatter     Changes the referenced ids to parameter names.\r\n     *    @param [in] expressionParser        Expression parser for remap states.\r\n\t *    @param [in] parent                  The parent item.\r\n\t */\r\n    RemapStatesItem(ComponentEditorTreeModel* model,\r\n        LibraryInterface* libHandler,\r\n        QSharedPointer<Component> component,\r\n        QSharedPointer<ReferenceCounter> referenceCounter,\r\n        QSharedPointer<ParameterFinder> parameterFinder,\r\n        QSharedPointer<ExpressionFormatter> expressionFormatter,\r\n        QSharedPointer<ExpressionParser> expressionParser,\r\n        ComponentEditorItem* parent);\r\n\r\n    /*!\r\n     *  The destructor.\r\n     */\r\n    virtual ~RemapStatesItem() = default;\r\n\r\n    /*!\r\n\t *  Get the font to be used for text of this item.\r\n\t *\r\n     *    @return The font to be used.\r\n\t */\r\n\tvirtual QFont getFont() const;\r\n\r\n    /*!\r\n\t *  Get the tool tip for the item.\r\n\t *\r\n     *    @return The text for the tool tip for the item.\r\n\t */\r\n\tvirtual QString getTooltip() const;\r\n\r\n    /*!\r\n\t *  Get the text to be displayed in the tree for this item.\r\n\t *\r\n     *    @return The text to be displayed.\r\n\t */\r\n\tvirtual QString text() const;\r\n\r\n    /*!\r\n\t *  Get the The editor of this item.\r\n\t *\r\n     *    @return The editor to use with this item.\r\n\t */\r\n\tvirtual ItemEditor* editor();\r\n\r\n    /*!\r\n     *  Create a child item.\r\n     *\r\n     *    @param [in] index   The index of the child item.\r\n     */\r\n    virtual void createChild(int index);\r\n\r\nprivate:\r\n\t//! No copying\r\n    RemapStatesItem(const RemapStatesItem& other);\r\n\r\n\t//! No assignment\r\n    RemapStatesItem& operator=(const RemapStatesItem& other);\r\n\r\n    //! The list containing the remap states to edit.\r\n    QSharedPointer<QList<QSharedPointer<RemapState> > > remapStates_;\r\n\r\n    //! The validator for remap states.\r\n    QSharedPointer<RemapStateValidator> validator_;\r\n};\r\n\r\n#endif // REMAPSTATESITEM_H\r\n"
  },
  {
    "path": "editors/ComponentEditor/treeStructure/ResetTypesItem.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: ResetTypesItem.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 03.01.2019\n//\n// Description:\n// The Reset types-item in the component editor's navigation tree.\n//-----------------------------------------------------------------------------\n\n#include \"ResetTypesItem.h\"\n\n#include <IPXACTmodels/Component/Component.h>\n\n#include <editors/ComponentEditor/resetTypes/ResetTypesEditor.h>\n\n//-----------------------------------------------------------------------------\n// Function: ResetTypesItem::ResetTypesItem()\n//-----------------------------------------------------------------------------\nResetTypesItem::ResetTypesItem(ComponentEditorTreeModel* model, LibraryInterface* libHandler,\n    QSharedPointer<Component> component, QSharedPointer<ComponentValidator> validator, ComponentEditorItem* parent):\nComponentEditorItem(model, libHandler, component, parent),\ncomponentValidator_(validator)\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: ResetTypesItem::~ResetTypesItem()\n//-----------------------------------------------------------------------------\nResetTypesItem::~ResetTypesItem()\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: ResetTypesItem::getFont()\n//-----------------------------------------------------------------------------\nQFont ResetTypesItem::getFont() const\n{\n    QFont font(ComponentEditorItem::getFont());\n    font.setBold(!component_->getResetTypes()->isEmpty());\n    return font;\n}\n\n//-----------------------------------------------------------------------------\n// Function: ResetTypesItem::text()\n//-----------------------------------------------------------------------------\nQString ResetTypesItem::text() const\n{\n\treturn tr(\"Reset types\");\n}\n\n//-----------------------------------------------------------------------------\n// Function: ResetTypesItem::editor()\n//-----------------------------------------------------------------------------\nItemEditor* ResetTypesItem::editor()\n{\n\tif (!editor_)\n    {\n        editor_ = new ResetTypesEditor(component_, libHandler_, componentValidator_);\n        editor_->setProtection(locked_);\n        connect(editor_, SIGNAL(contentChanged()), this, SLOT(onEditorChanged()), Qt::UniqueConnection);\n        connect(editor_, SIGNAL(helpUrlRequested(QString const&)), this, SIGNAL(helpUrlRequested(QString const&)));\n\t}\n\n\treturn editor_;\n}\n\n//-----------------------------------------------------------------------------\n// Function: ResetTypesItem::getTooltip()\n//-----------------------------------------------------------------------------\nQString ResetTypesItem::getTooltip() const\n{\n\treturn tr(\"Contains the reset type elements of the component\");\n}\n\n//-----------------------------------------------------------------------------\n// Function: ResetTypesItem::isValid()\n//-----------------------------------------------------------------------------\nbool ResetTypesItem::isValid() const\n{\n    return componentValidator_->hasValidResetTypes(component_);\n}\n"
  },
  {
    "path": "editors/ComponentEditor/treeStructure/ResetTypesItem.h",
    "content": "//-----------------------------------------------------------------------------\n// File: ResetTypesItem.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 03.01.2019\n//\n// Description:\n// The Reset types-item in the component editor's navigation tree.\n//-----------------------------------------------------------------------------\n\n#ifndef RESETTYPESITEM_H\n#define RESETTYPESITEM_H\n\n#include \"componenteditoritem.h\"\n\n#include <IPXACTmodels/Component/validators/ComponentValidator.h>\n\n//-----------------------------------------------------------------------------\n//! The Reset types-item in the component editor's navigation tree.\n//-----------------------------------------------------------------------------\nclass ResetTypesItem: public ComponentEditorItem\n{\n\tQ_OBJECT\n\npublic:\n\n\t/*!\n     *  The constructor.\n\t *\n\t *    @param [in] model       The model that owns the items.\n\t *    @param [in] libHandler  The instance that manages the library.\n\t *    @param [in] component   The component being edited.\n     *    @param [in] validator   Validator for component items.\n     *    @param [in] parent      The parent item.\n     */\n    ResetTypesItem(ComponentEditorTreeModel* model, LibraryInterface* libHandler,\n        QSharedPointer<Component> component, QSharedPointer<ComponentValidator> validator, ComponentEditorItem* parent);\n\n\t/*!\n     *  The destructor.\n     */\n    virtual ~ResetTypesItem();\n\n\t/*!\n     *  Get the font to be used for text of this item.\n\t *\n\t *    @return QFont instance that defines the font to be used.\n\t */\n\tvirtual QFont getFont() const;\n\n\t/*!\n     *  Get the tool tip for the item.\n\t * \n\t *    @return The text for the tool tip to print to user.\n\t */\n\tvirtual QString getTooltip() const;\n\n\t/*!\n     *  Get the text to be displayed to user in the tree for this item.\n\t *\n\t *    @return The text to display.\n     */\n\tvirtual QString text() const;\n\n\t/*!\n     *  Get The editor of this item.\n\t *\n\t *    @return The editor to use for this item.\n     */\n\tvirtual ItemEditor* editor();\n\n\t/*!\n     *  Check the validity of this item and sub items.\n\t *\n\t *    @return True if item is in valid state.\n     */\n\tvirtual bool isValid() const;\n\nprivate:\n\t//! No copying.\n\tResetTypesItem(const ResetTypesItem& other);\n    ResetTypesItem& operator=(const ResetTypesItem& other);\n\n    //! Validator for component items.\n\tQSharedPointer<ComponentValidator> componentValidator_;\n};\n\n#endif // RESETTYPESITEM_H\n"
  },
  {
    "path": "editors/ComponentEditor/treeStructure/SingleComponentInstantiationItem.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ComponentInstantiationsItem.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Esko Pekkarinen\r\n// Date: 25.01.2016\r\n//\r\n// Description:\r\n// The Instantiations-item in the component editor's navigation tree.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"SingleComponentInstantiationItem.h\"\r\n\r\n#include <editors/ComponentEditor/instantiations/ComponentInstantiationEditor.h>\r\n\r\n#include <IPXACTmodels/Component/Component.h>\r\n#include <IPXACTmodels/Component/validators/InstantiationsValidator.h>\r\n#include <IPXACTmodels/common/validators/ParameterValidator.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentInstantiationsItem::ComponentInstantiationsItem()\r\n//-----------------------------------------------------------------------------\r\nSingleComponentInstantiationItem::SingleComponentInstantiationItem(ComponentEditorTreeModel* model,\r\n    LibraryInterface* libHandler, QSharedPointer<Component> component,\r\n    QSharedPointer<ComponentInstantiation> instantiation, QSharedPointer<InstantiationsValidator> validator,\r\n    QSharedPointer<ReferenceCounter> referenceCounter, QSharedPointer<ParameterFinder> parameterFinder,\r\n    QSharedPointer<ExpressionFormatter> expressionFormatter, QSharedPointer<ExpressionParser> expressionParser,\r\n    ComponentInstantiationInterface* instantiationInterface, ComponentEditorItem* parent):\r\nParameterizableItem(model, libHandler, component, parent),\r\ninstantiation_(instantiation),\r\nvalidator_(validator),\r\nparameterValidator_(new ParameterValidator(expressionParser, component_->getChoices(), component_->getRevision())),\r\nexpressionParser_(expressionParser),\r\ninstantiationInterface_(instantiationInterface)\r\n{\r\n    setParameterFinder(parameterFinder);\r\n    setExpressionFormatter(expressionFormatter);\r\n\r\n    setObjectName(tr(\"ComponentInstantiationsItem\"));\r\n\r\n    setReferenceCounter(referenceCounter);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentInstantiationsItem::~ComponentInstantiationsItem()\r\n//-----------------------------------------------------------------------------\r\nSingleComponentInstantiationItem::~SingleComponentInstantiationItem()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentInstantiationsItem::getTooltip()\r\n//-----------------------------------------------------------------------------\r\nQString SingleComponentInstantiationItem::getTooltip() const\r\n{\r\n    return tr(\"Contains the component instantiations of the component\");\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentInstantiationsItem::text()\r\n//-----------------------------------------------------------------------------\r\nQString SingleComponentInstantiationItem::text() const\r\n{\r\n\treturn instantiation_->name();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SingleComponentInstantiationItem::isValid()\r\n//-----------------------------------------------------------------------------\r\nbool SingleComponentInstantiationItem::isValid() const\r\n{    \r\n    // Component instantiation validation requires tailored parameter validator and expression parser.\r\n    validator_->setExpressionParser(expressionParser_);\r\n    validator_->setParameterValidator(parameterValidator_);\r\n\r\n    return validator_->validateComponentInstantiation(instantiation_, component_->getRevision());\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentInstantiationsItem::editor()\r\n//-----------------------------------------------------------------------------\r\nItemEditor* SingleComponentInstantiationItem::editor()\r\n{\r\n\tif (!editor_)\r\n    {\r\n        editor_ = new ComponentInstantiationEditor(component_, libHandler_, instantiation_, parameterFinder_,\r\n            expressionParser_, expressionFormatter_, instantiationInterface_, 0);\r\n        editor_->setProtection(locked_);\r\n \r\n \t\tconnect(editor_, SIGNAL(contentChanged()), this, SLOT(onEditorChanged()), Qt::UniqueConnection);\r\n \t\tconnect(editor_, SIGNAL(childAdded(int)), this, SLOT(onAddChild(int)), Qt::UniqueConnection);\r\n \t\tconnect(editor_, SIGNAL(childRemoved(int)), this, SLOT(onRemoveChild(int)), Qt::UniqueConnection);\r\n \t\tconnect(editor_, SIGNAL(helpUrlRequested(QString const&)), this, SIGNAL(helpUrlRequested(QString const&)));\r\n\r\n        connectItemEditorToReferenceCounter();\r\n        connectReferenceTree();\r\n\t}\r\n\treturn editor_;\r\n}\r\n"
  },
  {
    "path": "editors/ComponentEditor/treeStructure/SingleComponentInstantiationItem.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: InstantiationsItem.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Esko Pekkarinen\r\n// Date: 25.01.2016\r\n//\r\n// Description:\r\n// The item for one component instantiation in the component editor's navigation tree.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef SINGLECOMPONENTINSTANTIATIONITEM_H\r\n#define SINGLECOMPONENTINSTANTIATIONITEM_H\r\n\r\n#include <editors/ComponentEditor/treeStructure/ParameterizableItem.h>\r\n\r\n#include <QSharedPointer>\r\n\r\nclass Component;\r\nclass ComponentInstantiation;\r\nclass ExpressionParser;\r\nclass InstantiationsValidator;\r\nclass ComponentInstantiationInterface;\r\nclass ParameterValidator;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! The item for one component instantiation in the component editor's navigation tree.\r\n//-----------------------------------------------------------------------------\r\nclass SingleComponentInstantiationItem : public ParameterizableItem\r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\r\n\t/*!\r\n\t *  The constructor.\r\n\t *\r\n\t *    @param [in] model                   The model that owns the items.\r\n\t *    @param [in] libHandler              The instance that manages the library.\r\n\t *    @param [in] component               The component being edited.\r\n\t *    @param [in] referenceCounter        The reference counter.\r\n\t *    @param [in] parameterFinder         The parameter finder.\r\n\t *    @param [in] expressionFormatter     The expression formatter.\r\n     *    @param [in] expressionParser        The used expression parser.\r\n     *    @param [in] instantiationInterface  Interface for accessing component instantiations.\r\n\t *    @param [in] parent                  The parent item.\r\n\t */\r\n\tSingleComponentInstantiationItem(ComponentEditorTreeModel* model,\r\n        LibraryInterface* libHandler,\r\n        QSharedPointer<Component> component,\r\n        QSharedPointer<ComponentInstantiation> instantiation,\r\n        QSharedPointer<InstantiationsValidator> validator,\r\n        QSharedPointer<ReferenceCounter> referenceCounter,\r\n        QSharedPointer<ParameterFinder> parameterFinder,\r\n        QSharedPointer<ExpressionFormatter> expressionFormatter,\r\n        QSharedPointer<ExpressionParser> expressionParser,\r\n        ComponentInstantiationInterface* instantiationInterface,\r\n        ComponentEditorItem* parent);\r\n\r\n\t//! The destructor.\r\n\tvirtual ~SingleComponentInstantiationItem();\r\n\r\n\t/*!\r\n     *  Get the tool tip for the item.\r\n\t * \r\n\t *    @return The text for the tool tip to print to user.\r\n\t */\r\n\tvirtual QString getTooltip() const;\r\n\r\n\t/*!\r\n     *  Get the text to be displayed to user in the tree for this item.\r\n\t *\r\n\t *    @return QString Contains the text to display.\r\n\t */\r\n\tvirtual QString text() const;\r\n\r\n    //! Checks if the item represented by the item is valid.\r\n    virtual bool isValid() const;\r\n\r\n\t/*!\r\n     *  Get The editor of this item.\r\n\t *\r\n\t *    @return The editor to use for this item.\r\n\t */\r\n\tvirtual ItemEditor* editor();\r\n\r\nprivate:\r\n\r\n\t//! No copying.\r\n\tSingleComponentInstantiationItem(const SingleComponentInstantiationItem& other);\r\n\tSingleComponentInstantiationItem& operator=(const SingleComponentInstantiationItem& other);\r\n\r\n    //! The component instantiation represented by this item.\r\n    QSharedPointer<ComponentInstantiation> instantiation_;\r\n\r\n    //! Validator for component instantiations.\r\n    QSharedPointer<InstantiationsValidator> validator_;\r\n\r\n\t//! Parameter validator to be used by instantiation validator.\r\n\tQSharedPointer<ParameterValidator> parameterValidator_;\r\n\r\n    //! The used expression parser.\r\n    QSharedPointer<ExpressionParser> expressionParser_;\r\n\r\n    //! Interface for accessing component instantiations.\r\n    ComponentInstantiationInterface* instantiationInterface_;\r\n};\r\n\r\n#endif // SINGLECOMPONENTINSTANTIATIONITEM_H\r\n"
  },
  {
    "path": "editors/ComponentEditor/treeStructure/SingleCpuItem.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: SingleCpuItem.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Esko Pekkarinen\n// Date: 15.6.2023\n//\n// Description:\n// The single cpu item used in the component editor navigation tree.\n//-----------------------------------------------------------------------------\n\n#include \"SingleCpuItem.h\"\n\n\n#include <editors/ComponentEditor/cpus/SingleCpuEditor.h>\n#include <editors/common/ExpressionSet.h>\n\n#include <IPXACTmodels/Component/Cpu.h>\n#include <IPXACTmodels/Component/validators/CPUValidator.h>\n\n//-----------------------------------------------------------------------------\n// Function: SingleCpuItem::SingleCpuItem()\n//-----------------------------------------------------------------------------\nSingleCpuItem::SingleCpuItem(QSharedPointer<Cpu> cpu, ComponentEditorTreeModel* model,\n    LibraryInterface* libHandler, QSharedPointer<Component> component,\n    QSharedPointer<ReferenceCounter> referenceCounter, ExpressionSet expressions,\n    QSharedPointer<CPUValidator> validator,\n    ComponentEditorItem* parent) :\nComponentEditorItem(model, libHandler, component, parent),\n    cpu_(cpu),\n    validator_(validator),\n    expressions_(expressions)\n{\n    setParameterFinder(expressions_.finder);\n    setExpressionFormatter(expressions_.formatter);\n    setReferenceCounter(referenceCounter);\n\n    if (component->getRevision() == Document::Revision::Std22)\n    {\n        visualizer_ = new CpuVisualizer(cpu, component->getMemoryMaps(), expressions.parser, nullptr);\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: SingleCpuItem::getTooltip()\n//-----------------------------------------------------------------------------\nQString SingleCpuItem::getTooltip() const\n{\n    return tr(\"Specifies a CPU of the component\");\n}\n\n//-----------------------------------------------------------------------------\n// Function: SingleCpuItem::text()\n//-----------------------------------------------------------------------------\nQString SingleCpuItem::text() const\n{\n    return cpu_->name();\n}\n\n//-----------------------------------------------------------------------------\n// Function: SingleCpuItem::isValid()\n//-----------------------------------------------------------------------------\nbool SingleCpuItem::isValid() const\n{\n    return validator_->validate(cpu_);\n}\n\n//-----------------------------------------------------------------------------\n// Function: SingleCpuItem::editor()\n//-----------------------------------------------------------------------------\nItemEditor* SingleCpuItem::editor()\n{\n    if (!editor_)\n    {\n        editor_ = new SingleCpuEditor(component_, cpu_, validator_->getRegionValidator(), libHandler_, expressions_);\n        editor_->setProtection(locked_);\n\n        connect(editor_, SIGNAL(contentChanged()), this, SLOT(onEditorChanged()), Qt::UniqueConnection);\n        connect(editor_, SIGNAL(errorMessage(const QString&)),\n            this, SIGNAL(errorMessage(const QString&)), Qt::UniqueConnection);\n        connect(editor_, SIGNAL(helpUrlRequested(QString const&)),\n            this, SIGNAL(helpUrlRequested(QString const&)), Qt::UniqueConnection);\n\n        connect(editor_, SIGNAL(graphicsChanged()), this, SLOT(onGraphicsChanged()), Qt::UniqueConnection);\n\n        connectItemEditorToReferenceCounter();\n    }\n\n    return editor_;\n}\n\n//-----------------------------------------------------------------------------\n// Function: SingleCpuItem::visualizer()\n//-----------------------------------------------------------------------------\nItemVisualizer* SingleCpuItem::visualizer()\n{\n    return visualizer_;\n}\n\n//-----------------------------------------------------------------------------\n// Function: SingleCpuItem::onGraphicsChanged()\n//-----------------------------------------------------------------------------\nvoid SingleCpuItem::onGraphicsChanged()\n{\n    if (visualizer_)\n    {\n        visualizer_->refresh();\n    }\n}\n"
  },
  {
    "path": "editors/ComponentEditor/treeStructure/SingleCpuItem.h",
    "content": "//-----------------------------------------------------------------------------\n// File: SingleCpuItem.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Esko Pekkarinen\n// Date: 15.6.2023\n//\n// Description:\n// The single cpu item used in the component editor navigation tree.\n//-----------------------------------------------------------------------------\n\n#ifndef SINGLE_CPU_ITEM_H\n#define SINGLE_CPU_ITEM_H\n\n#include \"componenteditoritem.h\"\n\n#include <editors/ComponentEditor/cpus/CpuVisualizer.h>\n\n#include <editors/common/ExpressionSet.h>\n\nclass Cpu;\nclass CPUValidator;\n\n//-----------------------------------------------------------------------------\n//! The single cpu item used in the component editor navigation tree.\n//-----------------------------------------------------------------------------\nclass SingleCpuItem: public ComponentEditorItem\n{\n\tQ_OBJECT\n\npublic:\n\t\n    /*!\n     *  The constructor.\n     *\n     *    @param [in] cpu                     The selected cpu.\n     *    @param [in] model                   The model that owns the items.\n     *    @param [in] libHandler              The instance that manages the library.\n     *    @param [in] component               The component being edited.\n     *    @param [in] referenceCounter        The counter for parameter references.\n     *    @param [in] expressions\t\t\t\tThe collection of objects for expression handling.\n     *    @param [in] parent                  The parent item.\n     */\n    SingleCpuItem(QSharedPointer<Cpu> cpu,\n        ComponentEditorTreeModel* model,\n        LibraryInterface* libHandler,\n        QSharedPointer<Component> component,\n        QSharedPointer<ReferenceCounter> referenceCounter,\n        ExpressionSet expressions,\n        QSharedPointer<CPUValidator> validator,\n        ComponentEditorItem* parent);\n\n    /*!\n     *  The destructor.\n     */\n    virtual ~SingleCpuItem() = default;\n\n    //! No copying\n    SingleCpuItem(const SingleCpuItem& other) = delete;\n\n    //! No assignment\n    SingleCpuItem& operator=(const SingleCpuItem& other) = delete;\n\n\t/*!\n\t *  Get the tool tip for the item.\n\t *\n     *    @return The text for the tool tip to print to user.\n\t */\n\tQString getTooltip() const final;\n\n\t/*!\n\t *  Get the text to be displayed in the tree for this item.\n\t *\n     *    @return The text to display.\n\t */\n\tQString text() const final;\n\n    /*!\n\t *  Check the validity of this item and sub items.\n\t *\n     *    @return True, if the item is in a valid state, false otherwise.\n\t */\n\tbool isValid() const final;\n\n\t/*!\n\t *  Get the pointer to the editor of this item.\n\t *\n     *    @return Pointer to the editor to use for this item.\n\t */\n\tItemEditor* editor() final;\n\n\n    ItemVisualizer* visualizer() override;\n\nprivate:\n\n    QSharedPointer<ExpressionParser> expressionParser_;\n\n    QSharedPointer<Cpu> cpu_;\n\n    QSharedPointer<CPUValidator> validator_;\n\n    ExpressionSet expressions_;\n\n    CpuVisualizer* visualizer_ = nullptr;\nprotected:\n    void onGraphicsChanged() override;\n\n};\n\n#endif // SINGLE_CPU_ITEM_H\n"
  },
  {
    "path": "editors/ComponentEditor/treeStructure/SingleDesignConfigurationInstantiationItem.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: SingleDesignConfigurationInstantiationItem.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Esko Pekkarinen\r\n// Date: 25.01.2016\r\n//\r\n// Description:\r\n// The item for one design configuration instantiation-item in the component editor's navigation tree.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"SingleDesignConfigurationInstantiationItem.h\"\r\n\r\n#include <editors/ComponentEditor/instantiations/DesignConfigurationInstantiationEditor.h>\r\n\r\n#include <IPXACTmodels/Component/Component.h>\r\n#include <IPXACTmodels/Component/validators/InstantiationsValidator.h>\r\n#include <IPXACTmodels/common/validators/ParameterValidator.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentInstantiationsItem::ComponentInstantiationsItem()\r\n//-----------------------------------------------------------------------------\r\nSingleDesignConfigurationInstantiationItem::SingleDesignConfigurationInstantiationItem(\r\n    ComponentEditorTreeModel* model, LibraryInterface* libHandler, QSharedPointer<Component> component,\r\n    QSharedPointer<ReferenceCounter> referenceCounter,\r\n    QSharedPointer<DesignConfigurationInstantiation> instantiation,\r\n    QSharedPointer<InstantiationsValidator> validator, QSharedPointer<ParameterValidator> parameterValidator,\r\n    QSharedPointer<ParameterFinder> parameterFinder,\r\n    QSharedPointer<ExpressionFormatter> expressionFormatter, \r\n    QSharedPointer<ExpressionParser> expressionParser, ComponentEditorItem* parent) :\r\nParameterizableItem(model, libHandler, component, parent),\r\ninstantiation_(instantiation),\r\nvalidator_(validator),\r\nparameterValidator_(parameterValidator),\r\nparameterFinder_(parameterFinder),\r\nexpressionFormatter_(expressionFormatter),\r\nexpressionParser_(expressionParser)\r\n{\r\n    setObjectName(tr(\"ComponentInstantiationsItem\"));\r\n    setReferenceCounter(referenceCounter);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentInstantiationsItem::getTooltip()\r\n//-----------------------------------------------------------------------------\r\nQString SingleDesignConfigurationInstantiationItem::getTooltip() const\r\n{\r\n    return tr(\"Contains the component instantiations of the component\");\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentInstantiationsItem::text()\r\n//-----------------------------------------------------------------------------\r\nQString SingleDesignConfigurationInstantiationItem::text() const\r\n{\r\n\treturn instantiation_->name();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SingleDesignConfigurationInstantiationItem::isValid()\r\n//-----------------------------------------------------------------------------\r\nbool SingleDesignConfigurationInstantiationItem::isValid() const\r\n{\r\n    // Set the param validator and expression parser required for validating design config instantiations.\r\n    validator_->setParameterValidator(parameterValidator_);\r\n    validator_->setExpressionParser(expressionParser_);\r\n\r\n    return validator_->validateDesignConfigurationInstantiation(instantiation_);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentInstantiationsItem::editor()\r\n//-----------------------------------------------------------------------------\r\nItemEditor* SingleDesignConfigurationInstantiationItem::editor()\r\n{\r\n\tif (!editor_)\r\n    {\r\n \t\teditor_ = new DesignConfigurationInstantiationEditor(component_, instantiation_, parameterFinder_,\r\n            expressionFormatter_, libHandler_, 0);\r\n \t\teditor_->setProtection(locked_);\r\n \r\n \t\tconnect(editor_, SIGNAL(contentChanged()), this, SLOT(onEditorChanged()), Qt::UniqueConnection);\r\n        connect(editor_, SIGNAL(helpUrlRequested(QString const&)), this, SIGNAL(helpUrlRequested(QString const&)));\r\n\r\n        connectItemEditorToReferenceCounter();\r\n        connectReferenceTree();\r\n\t}\r\n\treturn editor_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentInstantiationsItem::createChild()\r\n//-----------------------------------------------------------------------------\r\nvoid SingleDesignConfigurationInstantiationItem::createChild(int)\r\n{\r\n    // No children allowed.\r\n}\r\n"
  },
  {
    "path": "editors/ComponentEditor/treeStructure/SingleDesignConfigurationInstantiationItem.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: SingleDesignConfigurationInstantiationItem.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Esko Pekkarinen\r\n// Date: 25.01.2016\r\n//\r\n// Description:\r\n// The item for one design configuration instantiation-item in the component editor's navigation tree.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef SINGLEDESIGNCONFIGURATIONINSTANTIATIONITEM_H\r\n#define SINGLEDESIGNCONFIGURATIONINSTANTIATIONITEM_H\r\n\r\n#include <editors/ComponentEditor/treeStructure/ParameterizableItem.h>\r\n\r\n#include <QSharedPointer>\r\n\r\nclass Component;\r\nclass DesignConfigurationInstantiation;\r\nclass ExpressionParser;\r\nclass InstantiationsValidator;\r\nclass ParameterValidator;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! The item for one design configuration instantiation-item in the component editor's navigation tree.\r\n//-----------------------------------------------------------------------------\r\nclass SingleDesignConfigurationInstantiationItem : public ParameterizableItem\r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\r\n\t/*!\r\n\t *  The constructor.\r\n\t *\r\n\t *    @param [in] model                   The model that owns the items.\r\n\t *    @param [in] libHandler              The instance that manages the library.\r\n     *    @param [in] component               The component being edited.\r\n     *    @param [in] referenceCounter        The reference counter.\r\n     *    @param [in] instantiation           The instantiation of the item.\r\n     *    @param [in] validator               Used to validate the instantiation.\r\n     *    @param [in] parameterValidator      Parameter validator to use.\r\n     *    @param [in] parameterFinder         Pointer to the parameter finder.\r\n     *    @param [in] expressionFormatter     Pointer to the expression formatter.\r\n\t *    @param [in] parent                  The parent item.\r\n\t */\r\n    SingleDesignConfigurationInstantiationItem(ComponentEditorTreeModel* model,\r\n\t\tLibraryInterface* libHandler, QSharedPointer<Component> component,\r\n\t\tQSharedPointer<ReferenceCounter> referenceCounter,\r\n\t\tQSharedPointer<DesignConfigurationInstantiation> instantiation,\r\n\t\tQSharedPointer<InstantiationsValidator> validator,\r\n\t\tQSharedPointer<ParameterValidator> parameterValidator,\r\n\t\tQSharedPointer<ParameterFinder> parameterFinder,\r\n\t\tQSharedPointer<ExpressionFormatter> expressionFormatter,\r\n\t\tQSharedPointer<ExpressionParser> expressionParser,\r\n\t\tComponentEditorItem* parent);\r\n\r\n\t/*!\r\n     *  The destructor.\r\n     */\r\n\tvirtual ~SingleDesignConfigurationInstantiationItem() = default;\r\n\r\n\t/*!\r\n     *  Get the tool tip for the item.\r\n\t * \r\n\t *    @return The text for the tool tip to print to user.\r\n\t */\r\n\tvirtual QString getTooltip() const;\r\n\r\n\t/*!\r\n     *  Get the text to be displayed to user in the tree for this item.\r\n\t *\r\n\t *    @return QString Contains the text to display.\r\n\t */\r\n\tvirtual QString text() const;\r\n\r\n    //! Checks if the item represented by the item is valid.\r\n    bool isValid() const;\r\n    \r\n    /*!\r\n     *  Get The editor of this item.\r\n\t *\r\n\t *    @return The editor to use for this item.\r\n\t */\r\n\tvirtual ItemEditor* editor();\r\n\r\n\t/*!\r\n     *  Add a new child to the item.\r\n\t * \r\n\t *    @param [in] index   The index to add the child into.\r\n\t */\r\n\tvirtual void createChild(int index);\r\n\r\nprivate:\r\n\r\n\t//! No copying.\r\n\tSingleDesignConfigurationInstantiationItem(const SingleDesignConfigurationInstantiationItem& other);\r\n\tSingleDesignConfigurationInstantiationItem& operator=(const SingleDesignConfigurationInstantiationItem& other);\r\n\r\n    //! The instantiation represented by the item.\r\n    QSharedPointer<DesignConfigurationInstantiation> instantiation_;\r\n\r\n    //! Validator for the instantiation.\r\n    QSharedPointer<InstantiationsValidator> validator_;\r\n\r\n\t//! ParameterValidator to use.\r\n\tQSharedPointer<ParameterValidator> parameterValidator_;\r\n\r\n    //! Parameter finder, finds the desired parameters.\r\n    QSharedPointer<ParameterFinder> parameterFinder_;\r\n\r\n    //! Expression formatter, formats the referencing expressions.\r\n    QSharedPointer<ExpressionFormatter> expressionFormatter_;\r\n\r\n\t//! Expression parser to use.\r\n\tQSharedPointer<ExpressionParser> expressionParser_;\r\n\r\n};\r\n\r\n#endif // SINGLEDESIGNCONFIGURATIONINSTANTIATIONITEM_H\r\n"
  },
  {
    "path": "editors/ComponentEditor/treeStructure/SingleDesignInstantiationItem.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ComponentInstantiationsItem.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Esko Pekkarinen\r\n// Date: 25.01.2016\r\n//\r\n// Description:\r\n// The item for one design instantiation-item in the component editor's navigation tree.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"SingleDesignInstantiationItem.h\"\r\n\r\n#include <editors/ComponentEditor/instantiations/DesignInstantiationEditor.h>\r\n\r\n#include <IPXACTmodels/Component/Component.h>\r\n#include <IPXACTmodels/Component/validators/InstantiationsValidator.h>\r\n#include <IPXACTmodels/common/validators/ParameterValidator.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SingleDesignInstantiationItem::SingleDesignInstantiationItem()\r\n//-----------------------------------------------------------------------------\r\nSingleDesignInstantiationItem::SingleDesignInstantiationItem(ComponentEditorTreeModel* model,\r\n    LibraryInterface* libHandler, QSharedPointer<Component> component,\r\n    QSharedPointer<DesignInstantiation> instantiation, QSharedPointer<InstantiationsValidator> validator,\r\n    QSharedPointer<ParameterValidator> parameterValidator, QSharedPointer<ExpressionParser> expressionParser,\r\n    QSharedPointer<ParameterFinder> componentParameterFinder, QSharedPointer<ReferenceCounter> referenceCounter,\r\n    ComponentEditorItem* parent):\r\nComponentEditorItem(model, libHandler, component, parent),\r\ninstantiation_(instantiation),\r\nvalidator_(validator),\r\ncomponentParameterFinder_(componentParameterFinder),\r\nparameterValidator_(parameterValidator),\r\nexpressionParser_(expressionParser)\r\n{\r\n    setObjectName(tr(\"ComponentInstantiationsItem\"));\r\n    setReferenceCounter(referenceCounter);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SingleDesignInstantiationItem::~SingleDesignInstantiationItem()\r\n//-----------------------------------------------------------------------------\r\nSingleDesignInstantiationItem::~SingleDesignInstantiationItem()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SingleDesignInstantiationItem::getTooltip()\r\n//-----------------------------------------------------------------------------\r\nQString SingleDesignInstantiationItem::getTooltip() const\r\n{\r\n    return tr(\"Contains the component instantiations of the component\");\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SingleDesignInstantiationItem::text()\r\n//-----------------------------------------------------------------------------\r\nQString SingleDesignInstantiationItem::text() const\r\n{\r\n\treturn instantiation_->name();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SingleDesignInstantiationItem::isValid()\r\n//-----------------------------------------------------------------------------\r\nbool SingleDesignInstantiationItem::isValid() const\r\n{\r\n    validator_->setExpressionParser(expressionParser_);\r\n    validator_->setParameterValidator(parameterValidator_);\r\n\r\n    return validator_->validateDesignInstantiation(instantiation_);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SingleDesignInstantiationItem::editor()\r\n//-----------------------------------------------------------------------------\r\nItemEditor* SingleDesignInstantiationItem::editor()\r\n{\r\n\tif (!editor_)\r\n    {\r\n        editor_ =\r\n            new DesignInstantiationEditor(component_, instantiation_, libHandler_, componentParameterFinder_, 0);\r\n \t\teditor_->setProtection(locked_);\r\n \r\n \t\tconnect(editor_, SIGNAL(contentChanged()), this, SLOT(onEditorChanged()), Qt::UniqueConnection);\r\n \t\tconnect(editor_, SIGNAL(helpUrlRequested(QString const&)), this, SIGNAL(helpUrlRequested(QString const&)));\r\n        connectItemEditorToReferenceCounter();\r\n\t}\r\n\treturn editor_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SingleDesignInstantiationItem::createChild()\r\n//-----------------------------------------------------------------------------\r\nvoid SingleDesignInstantiationItem::createChild(int)\r\n{\r\n    // No children allowed.\r\n}\r\n"
  },
  {
    "path": "editors/ComponentEditor/treeStructure/SingleDesignInstantiationItem.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: SingleDesignInstantiationItem.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Esko Pekkarinen\r\n// Date: 25.01.2016\r\n//\r\n// Description:\r\n// The item for one design instantiation-item in the component editor's navigation tree.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef SINGLEDESIGNINSTANTIATIONITEM_H\r\n#define SINGLEDESIGNINSTANTIATIONITEM_H\r\n\r\n#include \"componenteditoritem.h\"\r\n\r\n#include <QSharedPointer>\r\n\r\nclass Component;\r\nclass DesignInstantiation;\r\nclass ExpressionParser;\r\nclass InstantiationsValidator;\r\nclass ParameterValidator;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! The item for one design instantiation-item in the component editor's navigation tree.\r\n//-----------------------------------------------------------------------------\r\nclass SingleDesignInstantiationItem : public ComponentEditorItem\r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\r\n\t/*!\r\n\t *  The constructor.\r\n\t *\r\n\t *    @param [in] model                       The model that owns the items.\r\n\t *    @param [in] libHandler                  The instance that manages the library.\r\n\t *    @param [in] component                   The component being edited.\r\n     *    @param [in] instantiation               The instantiation of the item.\r\n     *    @param [in] validator                   Handles the validation of the design instantiation.\r\n     *    @param [in] componentParameterFinder    Finder for component parameters.\r\n     *    @param [in] referenceCounter            Handles the usage count of parameters.\r\n\t *    @param [in] parent                      The parent item.\r\n\t */\r\n\tSingleDesignInstantiationItem(ComponentEditorTreeModel* model, LibraryInterface* libHandler,\r\n        QSharedPointer<Component> component, QSharedPointer<DesignInstantiation> instantiation,\r\n        QSharedPointer<InstantiationsValidator> validator,\r\n\t\tQSharedPointer<ParameterValidator> parameterValidator, QSharedPointer<ExpressionParser> expressionParser,\r\n        QSharedPointer<ParameterFinder> componentParameterFinder,\r\n        QSharedPointer<ReferenceCounter> referenceCounter, ComponentEditorItem* parent);\r\n\r\n\t//! The destructor.\r\n\tvirtual ~SingleDesignInstantiationItem();\r\n\r\n\t/*!\r\n     *  Get the tool tip for the item.\r\n\t * \r\n\t *    @return The text for the tool tip to print to user.\r\n\t */\r\n\tvirtual QString getTooltip() const;\r\n\r\n\t/*!\r\n     *  Get the text to be displayed to user in the tree for this item.\r\n\t *\r\n\t *    @return QString Contains the text to display.\r\n\t */\r\n\tvirtual QString text() const;\r\n\r\n    //! Checks if the item represented by the item is valid.\r\n    bool isValid() const;\r\n\r\n    /*!\r\n     *  Get The editor of this item.\r\n\t *\r\n\t *    @return The editor to use for this item.\r\n\t */\r\n\tvirtual ItemEditor* editor();\r\n\r\n\t/*!\r\n     *  Add a new child to the item.\r\n\t * \r\n\t *    @param [in] index   The index to add the child into.\r\n\t */\r\n\tvirtual void createChild(int index);\r\n\r\nprivate:\r\n\r\n\t//! No copying.\r\n\tSingleDesignInstantiationItem(const SingleDesignInstantiationItem& other);\r\n\tSingleDesignInstantiationItem& operator=(const SingleDesignInstantiationItem& other);\r\n\r\n    //! The design instantiation represented by the item.\r\n    QSharedPointer<DesignInstantiation> instantiation_;\r\n\r\n    //! Validator for the instantiation.\r\n    QSharedPointer<InstantiationsValidator> validator_;\r\n\r\n    //! Finder for component parameters.\r\n    QSharedPointer<ParameterFinder> componentParameterFinder_;\r\n\r\n    //! ParameterValidator to use in validation.\r\n    QSharedPointer<ParameterValidator> parameterValidator_;\r\n\t\r\n\t//! Expression parser to use in validation.\r\n    QSharedPointer<ExpressionParser> expressionParser_;\r\n\r\n};\r\n\r\n#endif // SINGLEDESIGNINSTANTIATIONITEM_H\r\n"
  },
  {
    "path": "editors/ComponentEditor/treeStructure/SingleIndirectInterfaceItem.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: SingleIndirectInterfaceItem.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: \n// Date: \n//\n// Description:\n// The item for single bus interface in the component editor's navigation tree.\n//-----------------------------------------------------------------------------\n\n#include \"SingleIndirectInterfaceItem.h\"\n\n#include <KactusAPI/include/LibraryInterface.h>\n\n#include <editors/ComponentEditor/indirectInterfaces/SingleIndirectInterfaceEditor.h>\n#include <KactusAPI/include/ExpressionParser.h>\n\n#include <IPXACTmodels/Component/IndirectInterface.h>\n#include <IPXACTmodels/Component/Component.h>\n#include <IPXACTmodels/Component/PortMap.h>\n\n#include <IPXACTmodels/Component/validators/IndirectInterfaceValidator.h>\n\n//-----------------------------------------------------------------------------\n// Function: SingleIndirectInterfaceItem::SingleIndirectInterfaceItem()\n//-----------------------------------------------------------------------------\nSingleIndirectInterfaceItem::SingleIndirectInterfaceItem(QSharedPointer<IndirectInterface> busif,\n    ComponentEditorTreeModel* model, LibraryInterface* libHandler, QSharedPointer<Component> component,\n    QSharedPointer<ReferenceCounter> referenceCounter, QSharedPointer<ParameterFinder> parameterFinder,\n    QSharedPointer<ExpressionFormatter> expressionFormatter, QSharedPointer<ExpressionParser> expressionParser,\n    QSharedPointer<IndirectInterfaceValidator> validator, BusInterfaceInterface* busInterface,\n    ComponentEditorItem* parent, QWidget* parentWnd):\nParameterizableItem(model, libHandler, component, parent),\n    indirectInterface_(busif),\n    parentWnd_(parentWnd),\n    expressionParser_(expressionParser),\n    validator_(validator),\n    busInterface_(busInterface)\n{\n    setParameterFinder(parameterFinder);\n    setExpressionFormatter(expressionFormatter);\n    setReferenceCounter(referenceCounter);\n}\n\n//-----------------------------------------------------------------------------\n// Function: SingleIndirectInterfaceItem::~SingleIndirectInterfaceItem()\n//-----------------------------------------------------------------------------\nSingleIndirectInterfaceItem::~SingleIndirectInterfaceItem()\n{\n}\n\n//-----------------------------------------------------------------------------\n// Function: SingleIndirectInterfaceItem::text()\n//-----------------------------------------------------------------------------\nQString SingleIndirectInterfaceItem::text() const\n{\n\treturn indirectInterface_->name();\n}\n\n//-----------------------------------------------------------------------------\n// Function: SingleIndirectInterfaceItem::isValid()\n//-----------------------------------------------------------------------------\nbool SingleIndirectInterfaceItem::isValid() const\n{\n\treturn validator_->validate(indirectInterface_);\n}\n\n//-----------------------------------------------------------------------------\n// Function: SingleIndirectInterfaceItem::editor()\n//-----------------------------------------------------------------------------\nItemEditor* SingleIndirectInterfaceItem::editor()\n{\n\tif (!editor_)\n    {\n\t\teditor_ = new SingleIndirectInterfaceEditor(indirectInterface_, validator_, component_, libHandler_, \n            parameterFinder_, expressionFormatter_, busInterface_, parentWnd_);\n\t\teditor_->setProtection(locked_);\n\n\t\tconnect(editor_, SIGNAL(contentChanged()), this, SLOT(onEditorChanged()), Qt::UniqueConnection);\n        connect(editor_, SIGNAL(errorMessage(const QString&)),\n            this, SIGNAL(errorMessage(const QString&)),Qt::UniqueConnection);\n\t\tconnect(editor_, SIGNAL(helpUrlRequested(QString const&)), this, SIGNAL(helpUrlRequested(QString const&)));\n\n        connectItemEditorToReferenceCounter();\n\n        connectReferenceTree();\n\t}\n\n\treturn editor_;\n}\n\n//-----------------------------------------------------------------------------\n// Function: SingleIndirectInterfaceItem::getTooltip()\n//-----------------------------------------------------------------------------\nQString SingleIndirectInterfaceItem::getTooltip() const\n{\n\treturn tr(\"Defines properties of a specific indirect interface in a component\");\n}\n"
  },
  {
    "path": "editors/ComponentEditor/treeStructure/SingleIndirectInterfaceItem.h",
    "content": "//-----------------------------------------------------------------------------\n// File: SingleIndirectInterfaceItem.h\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: \n// Date: \n//\n// Description:\n// The item for single bus interface in the component editor's navigation tree.\n//-----------------------------------------------------------------------------\n\n#ifndef SingleIndirectInterfaceItem_H\n#define SingleIndirectInterfaceItem_H\n\n#include <editors/ComponentEditor/treeStructure/ParameterizableItem.h>\n\n#include <QSharedPointer>\n\nclass IndirectInterface;\nclass IndirectInterfaceValidator;\nclass ExpressionParser;\nclass BusInterfaceInterface;\n\n//-----------------------------------------------------------------------------\n//! The item for single bus interface in the component editor's navigation tree.\n//-----------------------------------------------------------------------------\nclass SingleIndirectInterfaceItem : public ParameterizableItem\n{\n\tQ_OBJECT\n\npublic:\n\n    /*!\n\t *  The constructor.\n\t *\n\t *    @param [in] busif                   The bus interface being edited.\n\t *    @param [in] model                   The model that owns the items.\n\t *    @param [in] libHandler              The instance that manages the library.\n\t *    @param [in] component               The component being edited.\n\t *    @param [in] referenceCounter        The reference counter.\n\t *    @param [in] parameterFinder         The parameter finder.\n\t *    @param [in] expressionFormatter     The expression formatter.\n\t *    @param [in] expressionParser        The expression parser.\n     *    @param [in] validator               The validator for bus interfaces.\n     *    @param [in] busInterface            Interface for accessing bus interfaces.\n\t *    @param [in] parent                  The owner of this item.\n\t *    @param [in] parentWnd               The parent window.\n\t */\n\tSingleIndirectInterfaceItem(QSharedPointer<IndirectInterface> busif,\n\t\tComponentEditorTreeModel* model,\n\t\tLibraryInterface* libHandler,\n\t\tQSharedPointer<Component> component,\n        QSharedPointer<ReferenceCounter> referenceCounter,\n        QSharedPointer<ParameterFinder> parameterFinder,\n        QSharedPointer<ExpressionFormatter> expressionFormatter,\n        QSharedPointer<ExpressionParser> expressionParser,\n        QSharedPointer<IndirectInterfaceValidator> validator,\n        BusInterfaceInterface* busInterface,\n        ComponentEditorItem* parent,\n        QWidget* parentWnd);\n\n\t//! The destructor\n\tvirtual ~SingleIndirectInterfaceItem();\n\n\t/*! Get the tool tip for the item.\n\t * \n\t *    @return The text for the tool tip to print to user.\n\t*/\n\tvirtual QString getTooltip() const;\n\n\t/*! Get the text to be displayed to user in the tree for this item.\n\t *\n\t *    @return QString Contains the text to display.\n\t*/\n\tvirtual QString text() const;\n\n\t/*! Check the validity of this item and sub items.\n\t *\n\t *    @return bool True if item is in valid state.\n\t*/\n\tvirtual bool isValid() const;\n\n\t/*! Get The editor of this item.\n\t *\n\t *    @return The editor to use for this item.\n\t*/\n\tvirtual ItemEditor* editor();\n\nprivate:\n\t//! No copying\n\tSingleIndirectInterfaceItem(const SingleIndirectInterfaceItem& other);\n\n\t//! No assignment\n\tSingleIndirectInterfaceItem& operator=(const SingleIndirectInterfaceItem& other);\n\n\t//! The bus interface being edited.\n\tQSharedPointer<IndirectInterface> indirectInterface_;\n\n\t//! The parent window.\n\tQWidget* parentWnd_;\n\n    //! The expression parse used to form the results of the expressions.\n    QSharedPointer<ExpressionParser> expressionParser_;\n\n    //! The validator for indirect interfaces.\n    QSharedPointer<IndirectInterfaceValidator> validator_;\n\n    //! Interface for accessing bus interfaces.\n    BusInterfaceInterface* busInterface_;\n};\n\n#endif // SingleIndirectInterfaceItem_H\n"
  },
  {
    "path": "editors/ComponentEditor/treeStructure/SingleModeItem.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: SingleModeItem.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Esko Pekkarinen\n// Date: 08.08.2023\n//\n// Description:\n// The single Mode item used in the component editor navigation tree.\n//-----------------------------------------------------------------------------\n\n#include \"SingleModeItem.h\"\n\n#include <editors/ComponentEditor/modes/SingleModeEditor.h>\n#include <editors/common/ExpressionSet.h>\n\n#include <IPXACTmodels/Component/Mode.h>\n#include <IPXACTmodels/Component/validators/ModeValidator.h>\n\n//-----------------------------------------------------------------------------\n// Function: SingleModeItem::SingleModeItem()\n//-----------------------------------------------------------------------------\nSingleModeItem::SingleModeItem(QSharedPointer<Mode> mode, ComponentEditorTreeModel* model,\n    LibraryInterface* libHandler, QSharedPointer<Component> component,\n    QSharedPointer<ReferenceCounter> referenceCounter, ExpressionSet expressions,\n    QSharedPointer<ModeValidator> validator, QSharedPointer<ExpressionParser> modeConditionParser,\n    ComponentEditorItem* parent) :\nComponentEditorItem(model, libHandler, component, parent),\nmode_(mode),\nvalidator_(validator),\nexpressions_(expressions),\nmodeConditionParser_(modeConditionParser)\n{\n    setParameterFinder(expressions_.finder);\n    setExpressionFormatter(expressions_.formatter);\n    setReferenceCounter(referenceCounter);\n}\n\n//-----------------------------------------------------------------------------\n// Function: SingleModeItem::getTooltip()\n//-----------------------------------------------------------------------------\nQString SingleModeItem::getTooltip() const\n{\n    return tr(\"Specifies a mode of the component\");\n}\n\n//-----------------------------------------------------------------------------\n// Function: SingleModeItem::text()\n//-----------------------------------------------------------------------------\nQString SingleModeItem::text() const\n{\n    return mode_->name();\n}\n\n//-----------------------------------------------------------------------------\n// Function: SingleModeItem::isValid()\n//-----------------------------------------------------------------------------\nbool SingleModeItem::isValid() const\n{\n    validator_->setConditionParser(modeConditionParser_); // Each mode item has its own condition parser.\n    return validator_->validate(mode_);\n}\n\n//-----------------------------------------------------------------------------\n// Function: SingleModeItem::editor()\n//-----------------------------------------------------------------------------\nItemEditor* SingleModeItem::editor()\n{\n    if (!editor_)\n    {\n        editor_ = new SingleModeEditor(component_, mode_, validator_, libHandler_, expressions_);\n        editor_->setProtection(locked_);\n\n        connect(editor_, SIGNAL(contentChanged()), this, SLOT(onEditorChanged()), Qt::UniqueConnection);\n        connect(editor_, SIGNAL(errorMessage(const QString&)),\n            this, SIGNAL(errorMessage(const QString&)), Qt::UniqueConnection);\n        connect(editor_, SIGNAL(helpUrlRequested(QString const&)),\n            this, SIGNAL(helpUrlRequested(QString const&)), Qt::UniqueConnection);\n\n        connectItemEditorToReferenceCounter();\n    }\n\n    validator_->setConditionParser(modeConditionParser_); // Update validator parser, every mode has own parser\n    return editor_;\n}\n"
  },
  {
    "path": "editors/ComponentEditor/treeStructure/SingleModeItem.h",
    "content": "//-----------------------------------------------------------------------------\n// File: SingleModeItem.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Esko Pekkarinen\n// Date: 08.08.2023\n//\n// Description:\n// The single Mode item used in the component editor navigation tree.\n//-----------------------------------------------------------------------------\n\n#ifndef SINGLE_MODE_ITEM_H\n#define SINGLE_MODE_ITEM_H\n\n#include \"componenteditoritem.h\"\n\n#include <editors/common/ExpressionSet.h>\n\nclass Mode;\nclass ModeValidator;\nclass ModeConditionParser;\n\n//-----------------------------------------------------------------------------\n//! The single Mode item used in the component editor navigation tree.\n//-----------------------------------------------------------------------------\nclass SingleModeItem: public ComponentEditorItem\n{\n\tQ_OBJECT\n\npublic:\n\t\n    /*!\n     *  The constructor.\n     *\n     *    @param [in] Mode                     The selected Mode.\n     *    @param [in] model                   The model that owns the items.\n     *    @param [in] libHandler              The instance that manages the library.\n     *    @param [in] component               The component being edited.\n     *    @param [in] referenceCounter        The counter for parameter references.\n     *    @param [in] expressions\t\t\t\tThe collection of objects for expression handling.\n     *    @param [in] modeConditionParser     The mode condition parser to use.\n     *    @param [in] parent                  The parent item.\n     */\n    SingleModeItem(QSharedPointer<Mode> mode, ComponentEditorTreeModel* model, \n        LibraryInterface* libHandler, QSharedPointer<Component> component, \n        QSharedPointer<ReferenceCounter> referenceCounter, ExpressionSet expressions, \n        QSharedPointer<ModeValidator> validator, QSharedPointer<ExpressionParser> modeConditionParser, \n        ComponentEditorItem* parent);\n\n    /*!\n     *  The destructor.\n     */\n    virtual ~SingleModeItem() = default;\n\n    //! No copying\n    SingleModeItem(const SingleModeItem& other) = delete;\n\n    //! No assignment\n    SingleModeItem& operator=(const SingleModeItem& other) = delete;\n\n\t/*!\n\t *  Get the tool tip for the item.\n\t *\n     *    @return The text for the tool tip to print to user.\n\t */\n\tQString getTooltip() const final;\n\n\t/*!\n\t *  Get the text to be displayed in the tree for this item.\n\t *\n     *    @return The text to display.\n\t */\n\tQString text() const final;\n\n    /*!\n\t *  Check the validity of this item and sub items.\n\t *\n     *    @return True, if the item is in a valid state, false otherwise.\n\t */\n\tbool isValid() const final;\n\n\t/*!\n\t *  Get the pointer to the editor of this item.\n\t *\n     *    @return Pointer to the editor to use for this item.\n\t */\n\tItemEditor* editor() final;\n\nprivate:\n\n    //! Pointer to the currently selected remap state.\n    QSharedPointer<Mode> mode_;\n\n    QSharedPointer<ModeValidator> validator_;\n\n    ExpressionSet expressions_;\n\n    //! The mode condition parser to use.\n    QSharedPointer<ExpressionParser> modeConditionParser_;\n\n};\n\n#endif // SINGLE_MODE_ITEM_H\n"
  },
  {
    "path": "editors/ComponentEditor/treeStructure/SingleRemapStateItem.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: SingleRemapStateItem.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Mikko Teuho\r\n// Date: 08.04.2015\r\n//\r\n// Description:\r\n// The single remap state item in the component editor navigation tree.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"SingleRemapStateItem.h\"\r\n\r\n#include <editors/ComponentEditor/remapStates/SingleRemapStateEditor.h>\r\n\r\n#include <IPXACTmodels/Component/RemapState.h>\r\n#include <IPXACTmodels/Component/RemapPort.h>\r\n#include <IPXACTmodels/Component/validators/RemapStateValidator.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SingleRemapStateItem::SingleRemapStateItem()\r\n//-----------------------------------------------------------------------------\r\nSingleRemapStateItem::SingleRemapStateItem(QSharedPointer<RemapState> remapState, ComponentEditorTreeModel* model,\r\n    LibraryInterface* libHandler, QSharedPointer<Component> component,\r\n    QSharedPointer<ReferenceCounter> referenceCounter, QSharedPointer<ParameterFinder> parameterFinder,\r\n    QSharedPointer<ExpressionFormatter> expressionFormatter,\r\n    QSharedPointer<RemapStateValidator> validator,\r\n    ComponentEditorItem* parent):\r\nComponentEditorItem(model, libHandler, component, parent),\r\nremapState_(remapState),\r\nvalidator_(validator)\r\n{\r\n    setParameterFinder(parameterFinder);\r\n    setExpressionFormatter(expressionFormatter);\r\n    setReferenceCounter(referenceCounter);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SingleRemapStateItem::getTooltip()\r\n//-----------------------------------------------------------------------------\r\nQString SingleRemapStateItem::getTooltip() const\r\n{\r\n    return tr(\"Specifies a remap state of the component\");\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SingleRemapStateItem::text()\r\n//-----------------------------------------------------------------------------\r\nQString SingleRemapStateItem::text() const\r\n{\r\n    return remapState_->name();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SingleRemapStateItem::isValid()\r\n//-----------------------------------------------------------------------------\r\nbool SingleRemapStateItem::isValid() const\r\n{\r\n    return validator_->validate(remapState_);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SingleRemapStateItem::editor()\r\n//-----------------------------------------------------------------------------\r\nItemEditor* SingleRemapStateItem::editor()\r\n{\r\n    if (!editor_)\r\n    {\r\n        editor_ = new SingleRemapStateEditor(component_, remapState_, libHandler_, parameterFinder_,\r\n            expressionFormatter_);\r\n        editor_->setProtection(locked_);\r\n\r\n        connect(editor_, SIGNAL(contentChanged()), this, SLOT(onEditorChanged()), Qt::UniqueConnection);\r\n        connect(editor_, SIGNAL(errorMessage(const QString&)),\r\n            this, SIGNAL(errorMessage(const QString&)), Qt::UniqueConnection);\r\n        connect(editor_, SIGNAL(helpUrlRequested(QString const&)),\r\n            this, SIGNAL(helpUrlRequested(QString const&)), Qt::UniqueConnection);\r\n        connectItemEditorToReferenceCounter();\r\n    }\r\n\r\n    return editor_;\r\n}\r\n"
  },
  {
    "path": "editors/ComponentEditor/treeStructure/SingleRemapStateItem.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: SingleRemapStateItem.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Mikko Teuho\r\n// Date: 08.04.2015\r\n//\r\n// Description:\r\n// The single remap state item in the component editor navigation tree.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef SINGLEREMAPSTATEITEM_H\r\n#define SINGLEREMAPSTATEITEM_H\r\n\r\n#include \"componenteditoritem.h\"\r\n\r\nclass RemapState;\r\nclass RemapStateValidator;\r\nclass RemapPort;\r\n//-----------------------------------------------------------------------------\r\n//! The single remap state item used in the component editor navigation tree.\r\n//-----------------------------------------------------------------------------\r\nclass SingleRemapStateItem: public ComponentEditorItem\r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\t\r\n    /*!\r\n     *  The constructor.\r\n     *\r\n     *    @param [in] remapState              Pointer to the selected remap state.\r\n     *    @param [in] model                   Pointer to the model that owns the items.\r\n     *    @param [in] libHandler              Pointer to the instance that manages the library.\r\n     *    @param [in] component               Pointer to the component being edited.\r\n     *    @param [in] referenceCounter        The counter for parameter references.\r\n     *    @param [in] parameterFinder         Finds the referenced parameter ids.\r\n     *    @param [in] expressionFormatter     Changes the referenced ids to parameter names.\r\n     *    @param [in] parent                  Pointer to the parent item.\r\n     */\r\n    SingleRemapStateItem(QSharedPointer<RemapState> remapState,\r\n        ComponentEditorTreeModel* model,\r\n        LibraryInterface* libHandler,\r\n        QSharedPointer<Component> component,\r\n        QSharedPointer<ReferenceCounter> referenceCounter,\r\n        QSharedPointer<ParameterFinder> parameterFinder,\r\n        QSharedPointer<ExpressionFormatter> expressionFormatter,\r\n        QSharedPointer<RemapStateValidator> validator,\r\n        ComponentEditorItem* parent);\r\n\r\n    /*!\r\n     *  The destructor.\r\n     */\r\n    virtual ~SingleRemapStateItem() = default;\r\n\r\n\t/*!\r\n\t *  Get the tool tip for the item.\r\n\t *\r\n     *    @return The text for the tool tip to print to user.\r\n\t */\r\n\tvirtual QString getTooltip() const;\r\n\r\n\t/*!\r\n\t *  Get the text to be displayed in the tree for this item.\r\n\t *\r\n     *    @return The text to display.\r\n\t */\r\n\tvirtual QString text() const;\r\n\r\n    /*!\r\n\t *  Check the validity of this item and sub items.\r\n\t *\r\n     *    @return True, if the item is in a valid state, false otherwise.\r\n\t */\r\n\tvirtual bool isValid() const;\r\n\r\n\t/*!\r\n\t *  Get the pointer to the editor of this item.\r\n\t *\r\n     *    @return Pointer to the editor to use for this item.\r\n\t */\r\n\tvirtual ItemEditor* editor();\r\n\r\nprivate:\r\n\t//! No copying\r\n    SingleRemapStateItem(const SingleRemapStateItem& other);\r\n\r\n\t//! No assignment\r\n    SingleRemapStateItem& operator=(const SingleRemapStateItem& other);\r\n\r\n    //! Pointer to the currently selected remap state.\r\n    QSharedPointer<RemapState> remapState_;\r\n\r\n    QSharedPointer<RemapStateValidator> validator_;\r\n};\r\n\r\n#endif // SINGLEREMAPSTATEITEM_H\r\n"
  },
  {
    "path": "editors/ComponentEditor/treeStructure/SubspaceMapItem.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: SubspaceMapItem.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 23.02.2022\n//\n// Description:\n// The item for a single subspace map in component editor's navigation tree.\n//-----------------------------------------------------------------------------\n\n#include \"SubspaceMapItem.h\"\n\n#include <editors/ComponentEditor/memoryMaps/memoryMapsVisualizer/memorymapsvisualizer.h>\n#include <editors/ComponentEditor/memoryMaps/SingleSubspaceMapEditor.h>\n#include <editors/ComponentEditor/visualization/memoryvisualizationitem.h>\n\n#include <IPXACTmodels/Component/SubSpaceMap.h>\n#include <IPXACTmodels/Component/validators/SubspaceMapValidator.h>\n\n//-----------------------------------------------------------------------------\n// Function: SubspaceMapItem::SubspaceMapItem()\n//-----------------------------------------------------------------------------\nSubspaceMapItem::SubspaceMapItem(QSharedPointer<MemoryMapBase> containingMap,\n    QSharedPointer<SubSpaceMap> subspace, ComponentEditorTreeModel* model, LibraryInterface* libHandler,\n    QSharedPointer<Component> component, QSharedPointer<ReferenceCounter> referenceCounter,\n    QSharedPointer<ParameterFinder> parameterFinder, QSharedPointer<ExpressionFormatter> expressionFormatter,\n    QSharedPointer<ExpressionParser> expressionParser, QSharedPointer<SubspaceMapValidator> subspaceValidator,\n    SubspaceMapInterface* subspaceInterface, ComponentEditorItem* parent) :\nComponentEditorItem(model, libHandler, component, parent),\ncontainingMap_(containingMap),\nsubspaceMap_(subspace),\nvisualizer_(NULL),\ngraphItem_(NULL),\nexpressionParser_(expressionParser),\naddressUnitBits_(0),\nsubspaceValidator_(subspaceValidator),\nsubspaceInterface_(subspaceInterface)\n{\n    subspaceInterface_->setMemoryBlocks(containingMap_->getMemoryBlocks());\n    subspaceInterface_->setupSubInterfaces(component_);\n\n    setReferenceCounter(referenceCounter);\n    setParameterFinder(parameterFinder);\n    setExpressionFormatter(expressionFormatter);\n\n\tsetObjectName(tr(\"SubspaceItem\"));\n}\n\n//-----------------------------------------------------------------------------\n// Function: SubspaceMapItem::getTooltip()\n//-----------------------------------------------------------------------------\nQString SubspaceMapItem::getTooltip() const\n{\n\treturn tr(\"Contains details of a single subspace map.\");\n}\n\n//-----------------------------------------------------------------------------\n// Function: SubspaceMapItem::text()\n//-----------------------------------------------------------------------------\nQString SubspaceMapItem::text() const\n{\n\treturn subspaceMap_->name();\n}\n\n//-----------------------------------------------------------------------------\n// Function: SubspaceMapItem::isValid()\n//-----------------------------------------------------------------------------\nbool SubspaceMapItem::isValid() const \n{\n    return subspaceValidator_->validate(subspaceMap_);\n}\n\n//-----------------------------------------------------------------------------\n// Function: SubspaceMapItem::editor()\n//-----------------------------------------------------------------------------\nItemEditor* SubspaceMapItem::editor()\n{\n\tif (!editor_)\n    {\n        editor_ = new SingleSubspaceMapEditor(subspaceInterface_, subspaceMap_, containingMap_, component_, \n            libHandler_, parameterFinder_, expressionParser_);\n\t\teditor_->setProtection(locked_);\n\t\tconnect(editor_, SIGNAL(contentChanged()), this, SLOT(onEditorChanged()), Qt::UniqueConnection);\n        connect(editor_, SIGNAL(graphicsChanged()), this, SLOT(onGraphicsChanged()), Qt::UniqueConnection);\n        connect(editor_, SIGNAL(addressingChanged()), this, SLOT(onAddressingChanged()), Qt::UniqueConnection);\n\n        connect(editor_, SIGNAL(errorMessage(const QString&)),\n            this, SIGNAL(errorMessage(const QString&)), Qt::UniqueConnection);\n\t\tconnect(editor_, SIGNAL(helpUrlRequested(QString const&)), this, SIGNAL(helpUrlRequested(QString const&)));\n        \n        connect(this, SIGNAL(subspaceNameChanged(QString const&, QString const&)),\n            editor_, SLOT(onSubspaceNameChanged(QString const&, QString const&)), Qt::UniqueConnection);\n\n        connect(editor_, SIGNAL(thisEditorNameChange(QString const&, QString const&)),\n            graphItem_, SLOT(onNameChanged(QString const&, QString const&)), Qt::UniqueConnection);\n\n        connectItemEditorToReferenceCounter();\n\t}\n\treturn editor_;\n}\n\n//-----------------------------------------------------------------------------\n// Function: SubspaceMapItem::onGraphicsChanged()\n//-----------------------------------------------------------------------------\nvoid SubspaceMapItem::onGraphicsChanged()\n{\n    if (graphItem_)\n    {\n        graphItem_->updateDisplay();\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: SubspaceMapItem::onAddressingChanged()\n//-----------------------------------------------------------------------------\nvoid SubspaceMapItem::onAddressingChanged()\n{\n    if (graphItem_ != nullptr)\n    {\n        emit addressingChanged();\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: SubspaceMapItem::visualizer()\n//-----------------------------------------------------------------------------\nItemVisualizer* SubspaceMapItem::visualizer()\n{\n\treturn visualizer_;\n}\n\n//-----------------------------------------------------------------------------\n// Function: SubspaceMapItem::setVisualizer()\n//-----------------------------------------------------------------------------\nvoid SubspaceMapItem::setVisualizer( MemoryMapsVisualizer* visualizer )\n{\n\tvisualizer_ = visualizer;\n\n\t// get the graphics item for the memory map\n\tauto parentItem = static_cast<MemoryVisualizationItem*>(parent()->getGraphicsItem());\n\tQ_ASSERT(parentItem);\n\n\t// create the graph item for the address block\n\n    graphItem_ = new SubspaceMapGraphItem(subspaceInterface_, subspaceMap_->name(), expressionParser_, parentItem);\n    graphItem_->setAddressableUnitBits(addressUnitBits_);\n\n\tconnect(graphItem_, SIGNAL(selectEditor()),\tthis, SLOT(onSelectRequest()), Qt::UniqueConnection);\n    connect(this, SIGNAL(subspaceNameChanged(QString const&, QString const&)),\n        graphItem_, SLOT(onNameChanged(QString const&, QString const&)), Qt::UniqueConnection);\n}\n\n//-----------------------------------------------------------------------------\n// Function: SubspaceMapItem::getGraphicsItem()\n//-----------------------------------------------------------------------------\nQGraphicsItem* SubspaceMapItem::getGraphicsItem()\n{\n    return graphItem_;\n}\n\n//-----------------------------------------------------------------------------\n// Function: SubspaceMapItem::updateGraphics()\n//-----------------------------------------------------------------------------\nvoid SubspaceMapItem::updateGraphics()\n{\n    subspaceInterface_->setMemoryBlocks(containingMap_->getMemoryBlocks());\n    subspaceInterface_->setupSubInterfaces(component_);\n\n\tif (graphItem_)\n    {\n\t\tgraphItem_->updateDisplay();\n\t}\n}\n\n//-----------------------------------------------------------------------------\n// Function: SubspaceMapItem::removeGraphicsItem()\n//-----------------------------------------------------------------------------\nvoid SubspaceMapItem::removeGraphicsItem()\n{\n\tif (graphItem_)\n    {\n\t\t// get the graphics item for the memory map\n\t\tauto parentItem = static_cast<MemoryVisualizationItem*>(parent()->getGraphicsItem());\n\t\tQ_ASSERT(parentItem);\n\n\t\t// unregister addr block graph item from the memory map graph item\n\t\tparentItem->removeChild(graphItem_);\n\n\t\t// take the child from the parent\n\t\tgraphItem_->setParent(nullptr);\n\n\t\tdisconnect(graphItem_, SIGNAL(selectEditor()), this, SLOT(onSelectRequest()));\n\n\t\t// delete the graph item\n\t\tdelete graphItem_;\n\t\tgraphItem_ = nullptr;\n\t}\n}\n\n//-----------------------------------------------------------------------------\n// Function: SubspaceMapItem::addressUnitBitsChanged()\n//-----------------------------------------------------------------------------\nvoid SubspaceMapItem::addressUnitBitsChanged(int newAddressUnitBits)\n{\n    addressUnitBits_ = newAddressUnitBits;\n\n    if (graphItem_)\n    {\n        graphItem_->setAddressableUnitBits(newAddressUnitBits);\n        graphItem_->updateDisplay();\n    }\n}\n"
  },
  {
    "path": "editors/ComponentEditor/treeStructure/SubspaceMapItem.h",
    "content": "//-----------------------------------------------------------------------------\n// File: SubspaceMapItem.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 23.02.2022\n//\n// Description:\n// The item for a single subspace map in component editor's navigation tree.\n//-----------------------------------------------------------------------------\n\n#ifndef SUBSPACEMAPITEM_H\n#define SUBSPACEMAPITEM_H\n\n#include <editors/ComponentEditor/treeStructure/componenteditoritem.h>\n\n#include <editors/ComponentEditor/memoryMaps/memoryMapsVisualizer/SubspaceMapGraphItem.h>\n\n#include <IPXACTmodels/Component/SubSpaceMap.h>\n\n#include <QFont>\n#include <QSharedPointer>\n\nclass MemoryMapsVisualizer;\nclass MemoryMapBase;\nclass SubspaceMapValidator;\nclass SubspaceMapInterface;\n\n//-----------------------------------------------------------------------------\n//! The item for a single subspace map in component editor's navigation tree.\n//-----------------------------------------------------------------------------\nclass SubspaceMapItem : public ComponentEditorItem\n{\n\tQ_OBJECT\n\npublic:\n\n\t/*!\n\t *  The constructor.\n\t *\n     *    @param [in] containingMap           Memory map containing the address block.\n\t *    @param [in] subspace                The subspace map being edited.\n\t *    @param [in] model                   The model that owns the items.\n\t *    @param [in] libHandler              The instance that manages the library.\n\t *    @param [in] component               The component being edited.\n     *    @param [in] referenceCounter        The instance for counting references to parameters.\n\t *    @param [in] parameterFinder         The parameter finder.\n\t *    @param [in] expressionFormatter     The expression formatter.\n\t *    @param [in] expressionParser        The expression formatter.\n     *    @param [in] addressBlockValidator   Validator used for address blocks.\n     *    @param [in] subspaceInterface       Interface for accessing subspace maps.\n\t *    @param [in] parent                  The parent item.\n\t */\n    SubspaceMapItem(QSharedPointer<MemoryMapBase> containingMap,\n        QSharedPointer<SubSpaceMap> subspace,\n        ComponentEditorTreeModel* model,\n        LibraryInterface* libHandler,\n        QSharedPointer<Component> component,\n        QSharedPointer<ReferenceCounter> referenceCounter,\n        QSharedPointer<ParameterFinder> parameterFinder,\n        QSharedPointer<ExpressionFormatter> expressionFormatter,\n        QSharedPointer<ExpressionParser> expressionParser,\n        QSharedPointer<SubspaceMapValidator> subspaceValidator,\n        SubspaceMapInterface* subspaceInterface,\n\t\tComponentEditorItem* parent);\n\n\t/*!\n     *  The destructor.\n     */\n    virtual ~SubspaceMapItem() = default;\n\n    //! No copying. No assignment.\n    SubspaceMapItem(const SubspaceMapItem& other) = delete;\n    SubspaceMapItem& operator=(const SubspaceMapItem& other) = delete;\n\n\t/*!\n     *  Get the tool tip for the item.\n\t * \n\t *    @return The text for the tool tip to print to user.\n\t */\n\tvirtual QString getTooltip() const override final;\n\n\t/*!\n     *  Get the text to be displayed to user in the tree for this item.\n\t *\n\t *    @return QString Contains the text to display.\n\t */\n\tvirtual QString text() const override final;\n\n\t/*!\n     *  Check the validity of this item and sub items.\n\t *\n\t *    @return bool True if item is in valid state.\n\t */\n\tvirtual bool isValid() const override final;\n\n\t/*!\n     *  Get pointer to the editor of this item.\n\t *\n\t *    @return The editor to use for this item.\n\t */\n\tvirtual ItemEditor* editor() override final;\n\n    /*!\n     *  Get pointer to the visualizer of this item.\n\t * \n\t *    @return The visualizer to use for this item.\n\t */\n\tvirtual ItemVisualizer* visualizer() override final;\n\n\t/*!\n     *  Set the visualizer for this item.\n\t *\n\t *    @param [in] visualizer The visualizer.\n\t */\n\tvoid setVisualizer(MemoryMapsVisualizer* visualizer);\n\n    /*!\n     *  Get the visualizer graphics item for the address block.\n\t *\n\t *    @return QGraphicsItem* The graphics item.\n\t */\n\tvirtual QGraphicsItem* getGraphicsItem() override final;\n\n\t/*!\n     *  Update the graphics item of the address block.\n\t */\n\tvirtual void updateGraphics() override final;\n\n\t/*!\n     *  Remove the graphics item of the address block.\n\t */\n\tvirtual void removeGraphicsItem() override final;\n\n    /*!\n     *  Change the address unit bits in component editor.\n     *\n     *    @param [in] newAddressUnitBits   The new value for address unit bits.\n     */\n    void addressUnitBitsChanged(int newAddressUnitBits);\n\npublic slots:\n\n    /*!\n     *  Handle the change in item's addressing data.\n     */\n    void onAddressingChanged();\n\nprotected slots:\n    \n    /*!\n     *  Handles the redrawing of the visualization of the item.\n     */\n    virtual void onGraphicsChanged();\n\nsignals:\n    \n    /*!\n     *  Signals a change in the item's address data.\n     */\n    void addressingChanged();\n\n    /*\n     *  Informs of subspace map name change.\n     *\n     *    @param [in] oldName     The old name.\n     *    @param [in] newName     The new name.\n     */\n    void subspaceNameChanged(QString const& oldName, QString const& newName);\n\nprivate:\n\t\n    //! Memory map containing the edited address block.\n    QSharedPointer<MemoryMapBase> containingMap_;\n\n\t//! The subspace map being edited.\n\tQSharedPointer<SubSpaceMap> subspaceMap_;\n\n\t//! The visualizer for memory maps.\n\tMemoryMapsVisualizer* visualizer_;\n\n\t//! The graph item which visualizes the address block.\n    SubspaceMapGraphItem* graphItem_;\n\n    //! The expression parser to use.\n    QSharedPointer<ExpressionParser> expressionParser_;\n\n    //! The number of addressable unit bits in the address block.\n    unsigned int addressUnitBits_;\n\n    //! The used subspace map validator.\n    QSharedPointer<SubspaceMapValidator> subspaceValidator_;\n\n    //! Interface for accessing subspace maps.\n    SubspaceMapInterface* subspaceInterface_;\n};\n\n#endif // SUBSPACEMAPITEM_H\n"
  },
  {
    "path": "editors/ComponentEditor/treeStructure/TransactionalPortsItem.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: TransactionalPortsItem.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Esko Pekkarinen\n// Date: 22.11.2023\n//\n// Description:\n// The Transactional ports-item in the component editor's navigation tree. \n//-----------------------------------------------------------------------------\n\n#include \"TransactionalPortsItem.h\"\n\n#include <editors/ComponentEditor/ports/TypedPortEditor.h>\n#include <editors/ComponentEditor/ports/TransactionalPortsEditorFactory.h>\n\n#include <KactusAPI/include/PortAbstractionInterface.h>\n#include <KactusAPI/include/PortsInterface.h>\n#include <KactusAPI/include/LibraryInterface.h>\n\n#include <KactusAPI/include/ExpressionParser.h>\n\n#include <IPXACTmodels/Component/Component.h>\n\n#include <IPXACTmodels/Component/validators/PortValidator.h>\n\n//-----------------------------------------------------------------------------\n// Function: TransactionalPortsItem::TransactionalPortsItem()\n//-----------------------------------------------------------------------------\nTransactionalPortsItem::TransactionalPortsItem(ComponentEditorTreeModel* model,\n    LibraryInterface* libHandler,\n    QSharedPointer<Component> component, \n    QSharedPointer<ReferenceCounter> refCounter,\n    ExpressionSet expressions,\n    QSharedPointer<PortsInterface> portsInterface,\n    BusInterfaceInterface* busInterface,\n    ComponentEditorItem* parent):\nComponentEditorItem(model, libHandler, component, parent),\n    expressions_(expressions),\n    portValidator_(new PortValidator(expressions.parser, component->getViews())),\n    portsInterface_(portsInterface),\n    busInterface_(busInterface)\n{\n    setReferenceCounter(refCounter);\n    setParameterFinder(expressions.finder);\n    setExpressionFormatter(expressions.formatter);\n}\n\n//-----------------------------------------------------------------------------\n// Function: TransactionalPortsItem::text()\n//-----------------------------------------------------------------------------\nQString TransactionalPortsItem::text() const\n{\n\treturn tr(\"Transactionals\");\n}\n\n//-----------------------------------------------------------------------------\n// Function: TransactionalPortsItem::isValid()\n//-----------------------------------------------------------------------------\nbool TransactionalPortsItem::isValid() const\n{\n    QStringList portNames;\n\tfor (QSharedPointer<Port> port : *component_->getPorts()) \n    {\n        if (port->getTransactional() && (portNames.contains(port->name()) || !portValidator_->validate(port)))\n        {\n\t\t\treturn false;\n\t\t}\n\n        portNames.append(port->name());\n\t}\n\n\treturn true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: TransactionalPortsItem::editor()\n//-----------------------------------------------------------------------------\nItemEditor* TransactionalPortsItem::editor()\n{\n\tif (!editor_)\n    {\n        QSharedPointer<PortAbstractionInterface> signalInterface(new PortAbstractionInterface(expressions_.parser, expressions_.formatter));\n\n        const QString defaultPath = QString(\"%1/transactionalList.csv\").arg(libHandler_->getDirectoryPath(component_->getVlnv()));\n\n        TransactionalPortsEditorFactory transactionalFactory(component_, expressions_, portValidator_,\n            portsInterface_, signalInterface, busInterface_, defaultPath);\n\n        editor_ = new TypedPortEditor(component_, libHandler_, &transactionalFactory, \n            QStringLiteral(\"transactional\"), portsInterface_, busInterface_);\n\t\teditor_->setProtection(locked_);\n\n\t\tconnect(editor_, SIGNAL(contentChanged()), this, SLOT(onEditorChanged()), Qt::UniqueConnection);\n\t\tconnect(editor_, SIGNAL(helpUrlRequested(QString const&)),\n\t\t\tthis, SIGNAL(helpUrlRequested(QString const&)), Qt::UniqueConnection);\n        connect(editor_, SIGNAL(createInterface()), \n            this, SIGNAL(createInterface()), Qt::UniqueConnection);\n\n        connectItemEditorToReferenceCounter();\n        connectItemEditorToVendorExtensionsEditor();\n\t}\n\treturn editor_;\n}\n\n//-----------------------------------------------------------------------------\n// Function: TransactionalPortsItem::getFont()\n//-----------------------------------------------------------------------------\nQFont TransactionalPortsItem::getFont() const\n{\n    QFont font(ComponentEditorItem::getFont());\n    font.setBold(component_->hasTransactionals());\n    return font;\n}\n\n//-----------------------------------------------------------------------------\n// Function: TransactionalPortsItem::getTooltip()\n//-----------------------------------------------------------------------------\nQString TransactionalPortsItem::getTooltip() const\n{\n\treturn tr(\"Contains the transactional ports of the component\");\n}\n"
  },
  {
    "path": "editors/ComponentEditor/treeStructure/TransactionalPortsItem.h",
    "content": "//-----------------------------------------------------------------------------\n// File: TransactionalPortsItem.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Esko Pekkarinen\n// Date: 22.11.2023\n//\n// Description:\n// The Transactional ports-item in the component editor's navigation tree. \n//-----------------------------------------------------------------------------\n\n#ifndef TRANSACTIONAL_PORTS_ITEM_H\n#define TRANSACTIONAL_PORTS_ITEM_H\n\n#include \"componenteditoritem.h\"\n#include <editors/common/ExpressionSet.h>\n\n#include <QList>\n\nclass Port;\nclass ExpressionParser;\nclass PortValidator;\nclass BusInterfaceInterface;\nclass PortsInterface;\n\n//-----------------------------------------------------------------------------\n//! The Transactional ports-item in the component editor's navigation tree.\n//-----------------------------------------------------------------------------\nclass TransactionalPortsItem : public ComponentEditorItem\n{\n\tQ_OBJECT\n\npublic:\n\n\t/*!\n\t *  The constructor.\n\t *\n\t *    @param [in] model                   The model that owns the items.\n\t *    @param [in] libHandler              The instance that manages the library.\n\t *    @param [in] component               The component being edited.\n\t *    @param [in] refCounter              The instance for counting references.\n\t *    @param [in] parameterFinder         The parameter finder.\n\t *    @param [in] expressionFormatter     The expression formatter.\n     *    @param [in] expressionParser        The expression parser.\n     *    @param [in] busInterface            Interface for accessing bus interfaces.\n\t *    @param [in] parent                  The parent item.\n\t */\n\tTransactionalPortsItem(ComponentEditorTreeModel* model,\n\t\tLibraryInterface* libHandler,\n\t\tQSharedPointer<Component> component,\n        QSharedPointer<ReferenceCounter> refCounter,\n\t\tExpressionSet expressions,\n\t\tQSharedPointer<PortsInterface> portsInterface,\n        BusInterfaceInterface* busInterface,\n\t\tComponentEditorItem* parent);\n\n\t//! The destructor\n\t~TransactionalPortsItem() = default;\n\n\t/*!\n     *  Get the tool tip for the item.\n\t * \n\t *    @return The text for the tool tip to print to user.\n\t */\n\tQString getTooltip() const final;\n\n\t/*!\n     *  Get the text to be displayed to user in the tree for this item.\n\t *\n\t *    @return QString Contains the text to display.\n\t */\n\tQString text() const final;\n\n\t/*!\n     *  Check the validity of this item and sub items.\n\t *\n\t *    @return bool True if item is in valid state.\n\t */\n\tbool isValid() const final;\n\n\t/*!\n     *  Get pointer to the editor of this item.\n\t *\n\t *    @return The editor to use for this item.\n\t */\n\tItemEditor* editor() final;\n   \n\t/*! \n\t *  Get the font to be used for text of this item.\n\t *\tThe font is bold, if transactional ports exist, otherwise regular.\n\t *\n\t *    @return QFont instance that defines the font to be used.\n\t */\n\tQFont getFont() const final;\n\nsignals:\n\n    //! Emitted when a new interface should be created in the component editor tree.\n    void createInterface();\n\nprivate:\n\n\tExpressionSet expressions_;\n\n    //! The used port validator.\n    QSharedPointer<PortValidator> portValidator_;\n\n\t//! Interface for accessing ports.\n\tQSharedPointer<PortsInterface> portsInterface_;\n\n    //! Interface for accessing bus interfaces.\n    BusInterfaceInterface* busInterface_;\n};\n\n#endif // TRANSACTIONAL_PORTS_ITEM_H\n"
  },
  {
    "path": "editors/ComponentEditor/treeStructure/TypeDefinitionsItem.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: TypeDefinitionsItem.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Esko Pekkarinen\n// Date: 13.10.2023\n//\n// Description:\n// The Type Definitions-item in the component editor navigation tree.\n//-----------------------------------------------------------------------------\n\n#include \"TypeDefinitionsItem.h\"\n\n#include <IPXACTmodels/Component/Component.h>\n\n//-----------------------------------------------------------------------------\n// Function: TypeDefinitionsItem::TypeDefinitionsItem()\n//-----------------------------------------------------------------------------\nTypeDefinitionsItem::TypeDefinitionsItem( ComponentEditorTreeModel* model,\n    LibraryInterface* libHandler, QSharedPointer<Component> component, ComponentEditorItem* parent ):\nComponentEditorItem(model, libHandler, component, parent)\n{\n  \n}\n\n//-----------------------------------------------------------------------------\n// Function: TypeDefinitionsItem::text()\n//-----------------------------------------------------------------------------\nQString TypeDefinitionsItem::text() const\n{\n\treturn tr(\"Type definitions\");\n}\n\n//-----------------------------------------------------------------------------\n// Function: TypeDefinitionsItem::getFont()\n//-----------------------------------------------------------------------------\nQFont TypeDefinitionsItem::getFont() const\n{\n    QFont font(ComponentEditorItem::getFont());\n    font.setBold(false);\n    return font;\n}\n\n//-----------------------------------------------------------------------------\n// Function: TypeDefinitionsItem::isValid()\n//-----------------------------------------------------------------------------\nbool TypeDefinitionsItem::isValid() const\n{\n\treturn true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: TypeDefinitionsItem::editor()\n//-----------------------------------------------------------------------------\nItemEditor* TypeDefinitionsItem::editor()\n{\n\treturn editor_;\n}\n\n\n//-----------------------------------------------------------------------------\n// Function: TypeDefinitionsItem::refreshEditor()\n//-----------------------------------------------------------------------------\nvoid TypeDefinitionsItem::refreshEditor()\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: TypeDefinitionsItem::getTooltip()\n//-----------------------------------------------------------------------------\nQString TypeDefinitionsItem::getTooltip() const\n{\n\treturn tr(\"Contains the type definitions of the component\");\n}\n"
  },
  {
    "path": "editors/ComponentEditor/treeStructure/TypeDefinitionsItem.h",
    "content": "//-----------------------------------------------------------------------------\n// File: TypeDefinitionsItem.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Esko Pekkarinen\n// Date: 13.10.2023\n//\n// Description:\n// The Type Definitions-item in the component editor navigation tree.\n//-----------------------------------------------------------------------------\n\n#ifndef TYPEDEFINITIONSITEM_H\n#define TYPEDEFINITIONSITEM_H\n\n#include \"componenteditoritem.h\"\n\n#include <QSharedPointer>\n#include <QString>\n\n//-----------------------------------------------------------------------------\n//! The Type Definitions-item  in the component editor navigation tree.\n//-----------------------------------------------------------------------------\nclass TypeDefinitionsItem : public ComponentEditorItem\n{\n\tQ_OBJECT\n\npublic:\n\n\t/*!\n     *  The constructor.\n\t *\n\t *    @param [in] model       Pointer to the model that owns the items.\n\t *    @param [in] libHandler  Pointer to the instance that manages the library.\n\t *    @param [in] component   Pointer to the component being edited.\n\t *    @param [in] parent      Pointer to the parent item.\n\t */\n\tTypeDefinitionsItem(ComponentEditorTreeModel* model, LibraryInterface* libHandler,\n        QSharedPointer<Component> component, ComponentEditorItem* parent);\n\n\t//! The destructor.\n\t~TypeDefinitionsItem() override = default;\n\n    //! No copying. No assignment. No mercy.\n    TypeDefinitionsItem(const TypeDefinitionsItem& other) = delete;\n    TypeDefinitionsItem& operator=(const TypeDefinitionsItem& other) = delete;\n\n\t/*!\n     *  Get the tool tip for the item.\n\t * \n\t *    @return The text for the tool tip to print to user.\n\t */\n\tvirtual QString getTooltip() const;\n\n\t/*!\n     *  Get the text to be displayed to user in the tree for this item.\n\t *\n\t *    @return QString Contains the text to display.\n\t */\n\tvirtual QString text() const;\n\n\t/*!\n     *  Get the font to be used for text of this item.\n\t *\n\t *    @return QFont instance that defines the font to be used.\n\t */\n    virtual QFont getFont() const;\n\n\t/*!\n     *  Check the validity of this item and sub items.\n\t *\n\t *    @return bool True if item is in valid state.\n\t */\n\tvirtual bool isValid() const;\n\n\t/*!\n     *  Get pointer to the editor of this item.\n\t *\n\t *    @return Pointer to the editor to use for this item.\n\t */\n\tvirtual ItemEditor* editor();\n\n\t/*!\n\t *  Refresh the contents of the editor associated with this item.\n\t */\n\tvoid refreshEditor() override;\n\n};\n\n#endif // TYPEDEFINITIONSITEM_H\n"
  },
  {
    "path": "editors/ComponentEditor/treeStructure/WirePortsItem.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: WirePortsItem.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Esko Pekkarinen\n// Date: 22.11.2023\n//\n// Description:\n// The Wire ports-item in the component editor's navigation tree. \n//-----------------------------------------------------------------------------\n\n\n#include \"WirePortsItem.h\"\n\n#include <editors/ComponentEditor/ports/TypedPortEditor.h>\n#include <editors/ComponentEditor/ports/WirePortsEditorFactory.h>\n\n#include <KactusAPI/include/PortAbstractionInterface.h>\n#include <KactusAPI/include/PortsInterface.h>\n#include <KactusAPI/include/LibraryInterface.h>\n\n#include <KactusAPI/include/ExpressionParser.h>\n\n#include <IPXACTmodels/Component/Component.h>\n\n#include <IPXACTmodels/Component/validators/PortValidator.h>\n\n//-----------------------------------------------------------------------------\n// Function: WirePortsItem::WirePortsItem()\n//-----------------------------------------------------------------------------\nWirePortsItem::WirePortsItem(ComponentEditorTreeModel* model, LibraryInterface* libHandler,\n    QSharedPointer<Component> component, QSharedPointer<ReferenceCounter> refCounter,\n    ExpressionSet expressions,\n    QSharedPointer<PortsInterface> portsInterface,\n    BusInterfaceInterface* busInterface,\n    ComponentEditorItem* parent):\nComponentEditorItem(model, libHandler, component, parent),\n    expressions_(expressions),\n    portValidator_(new PortValidator(expressions.parser, component->getViews())),\n    portsInterface_(portsInterface),\n    busInterface_(busInterface)\n{\n    setReferenceCounter(refCounter);\n    setParameterFinder(expressions.finder);\n    setExpressionFormatter(expressions.formatter);\n}\n\n//-----------------------------------------------------------------------------\n// Function: WirePortsItem::text()\n//-----------------------------------------------------------------------------\nQString WirePortsItem::text() const\n{\n\treturn tr(\"Wires\");\n}\n\n//-----------------------------------------------------------------------------\n// Function: WirePortsItem::isValid()\n//-----------------------------------------------------------------------------\nbool WirePortsItem::isValid() const\n{\n    QStringList portNames;\n\tfor (QSharedPointer<Port> port : *component_->getPorts()) \n    {\n        if (port->getWire() && (portNames.contains(port->name()) || !portValidator_->validate(port)))\n        {\n\t\t\treturn false;\n\t\t}\n\n        portNames.append(port->name());\n\t}\n\n\treturn true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: WirePortsItem::editor()\n//-----------------------------------------------------------------------------\nItemEditor* WirePortsItem::editor()\n{\n\tif (!editor_)\n    {\n        QSharedPointer<PortAbstractionInterface> signalInterface(new PortAbstractionInterface(expressions_.parser, expressions_.formatter));\n\n        const QString defaultPath = QString(\"%1/wireList.csv\").arg(libHandler_->getDirectoryPath(component_->getVlnv()));\n\n        WirePortsEditorFactory wireFactory(component_, expressions_, portValidator_,\n            portsInterface_, signalInterface, busInterface_, defaultPath);\n\n\t\teditor_ = new TypedPortEditor(component_, libHandler_, &wireFactory, QStringLiteral(\"wire\"),\n            portsInterface_, busInterface_);\n\t\teditor_->setProtection(locked_);\n\n\t\tconnect(editor_, SIGNAL(contentChanged()), this, SLOT(onEditorChanged()), Qt::UniqueConnection);\n\t\tconnect(editor_, SIGNAL(helpUrlRequested(QString const&)),\n\t\t\tthis, SIGNAL(helpUrlRequested(QString const&)), Qt::UniqueConnection);\n        connect(editor_, SIGNAL(createInterface()), \n            this, SIGNAL(createInterface()), Qt::UniqueConnection);\n\n        connectItemEditorToReferenceCounter();\n        connectItemEditorToVendorExtensionsEditor();\n\t}\n\treturn editor_;\n}\n\n//-----------------------------------------------------------------------------\n// Function: WirePortsItem::getFont()\n//-----------------------------------------------------------------------------\nQFont WirePortsItem::getFont() const\n{\n    QFont font(ComponentEditorItem::getFont());\n    font.setBold(component_->hasWires());\n    return font;\n}\n\n//-----------------------------------------------------------------------------\n// Function: WirePortsItem::getTooltip()\n//-----------------------------------------------------------------------------\nQString WirePortsItem::getTooltip() const\n{\n\treturn tr(\"Contains the wire ports of the component\");\n}\n"
  },
  {
    "path": "editors/ComponentEditor/treeStructure/WirePortsItem.h",
    "content": "//-----------------------------------------------------------------------------\n// File: WirePortsItem.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Esko Pekkarinen\n// Date: 22.11.2023\n//\n// Description:\n// The Wire ports-item in the component editor's navigation tree. \n//-----------------------------------------------------------------------------\n\n#ifndef WIRE_PORTS_ITEM_H\n#define WIRE_PORTS_ITEM_H\n\n#include \"componenteditoritem.h\"\n\n#include <editors/common/ExpressionSet.h>\n\n#include <QList>\n\nclass Port;\nclass ExpressionParser;\nclass PortValidator;\nclass PortsInterface;\nclass BusInterfaceInterface;\n\n//-----------------------------------------------------------------------------\n//! The Wire ports-item in the component editor's navigation tree.\n//-----------------------------------------------------------------------------\nclass WirePortsItem : public ComponentEditorItem\n{\n\tQ_OBJECT\n\npublic:\n\n\t/*!\n\t *  The constructor.\n\t *\n\t *    @param [in] model                   The model that owns the items.\n\t *    @param [in] libHandler              The instance that manages the library.\n\t *    @param [in] component               The component being edited.\n\t *    @param [in] refCounter              The instance for counting references.\n\t *    @param [in] parameterFinder         The parameter finder.\n\t *    @param [in] expressionFormatter     The expression formatter.\n     *    @param [in] expressionParser        The expression parser.\n     *    @param [in] busInterface            Interface for accessing bus interfaces.\n\t *    @param [in] parent                  The parent item.\n\t */\n\tWirePortsItem(ComponentEditorTreeModel* model,\n\t\tLibraryInterface* libHandler,\n\t\tQSharedPointer<Component> component,\n        QSharedPointer<ReferenceCounter> refCounter,\n        ExpressionSet expressions,\n        QSharedPointer<PortsInterface> portsInterface,\n        BusInterfaceInterface* busInterface,\n\t\tComponentEditorItem* parent);\n\n\t//! The destructor\n\t~WirePortsItem() = default;\n\n\t/*!\n     *  Get the tool tip for the item.\n\t * \n\t *    @return The text for the tool tip to print to user.\n\t */\n\tQString getTooltip() const final;\n\n\t/*!\n     *  Get the text to be displayed to user in the tree for this item.\n\t *\n\t *    @return QString Contains the text to display.\n\t */\n\tQString text() const final;\n\n\t/*!\n     *  Check the validity of this item and sub items.\n\t *\n\t *    @return bool True if item is in valid state.\n\t */\n\tbool isValid() const final;\n\n\t/*!\n     *  Get pointer to the editor of this item.\n\t *\n\t *    @return The editor to use for this item.\n\t */\n\tItemEditor* editor() final;\n\n\t/*! \n\t *  Get the font to be used for text of this item.\n\t *\tThe font is bold, if wire ports exist, otherwise regular.\n\t *\n\t *    @return QFont instance that defines the font to be used.\n\t */\n\tQFont getFont() const final;\n\nsignals:\n\n    //! Emitted when a new interface should be created in the component editor tree.\n    void createInterface();\n\nprivate:\n\n\n\tExpressionSet expressions_;\n\n    //! The used port validator.\n    QSharedPointer<PortValidator> portValidator_;\n\n\t//! Interface for accessing ports.\n\tQSharedPointer<PortsInterface> portsInterface_;\n\n    //! Interface for accessing bus interfaces.\n    BusInterfaceInterface* busInterface_;\n};\n\n#endif // WIRE_PORTS_ITEM_H\n"
  },
  {
    "path": "editors/ComponentEditor/treeStructure/componenteditoraddrblockitem.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: componenteditoraddrblockitem.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 23.08.2012\r\n//\r\n// Description:\r\n// The item for a single address block in component editor's navigation tree.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"componenteditoraddrblockitem.h\"\r\n#include \"componenteditorregisteritem.h\"\r\n#include \"componenteditorregisterfileitem.h\"\r\n\r\n#include <editors/ComponentEditor/memoryMaps/SingleAddressBlockEditor.h>\r\n#include <KactusAPI/include/RegisterInterface.h>\r\n#include <KactusAPI/include/AddressBlockInterface.h>\r\n#include <KactusAPI/include/FieldInterface.h>\r\n#include <editors/ComponentEditor/memoryMaps/memoryMapsVisualizer/memorymapsvisualizer.h>\r\n#include <editors/ComponentEditor/memoryMaps/memoryMapsVisualizer/addressblockgraphitem.h>\r\n#include <editors/ComponentEditor/visualization/memoryvisualizationitem.h>\r\n\r\n#include <IPXACTmodels/Component/RegisterBase.h>\r\n#include <IPXACTmodels/Component/Register.h>\r\n#include <IPXACTmodels/Component/RegisterFile.h>\r\n#include <IPXACTmodels/Component/Field.h>\r\n\r\n#include <IPXACTmodels/Component/validators/AddressBlockValidator.h>\r\n\r\n#include <QApplication>\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditorAddrBlockItem::ComponentEditorAddrBlockItem()\r\n//-----------------------------------------------------------------------------\r\nComponentEditorAddrBlockItem::ComponentEditorAddrBlockItem(QSharedPointer<MemoryMapBase> containingMap,\r\n    QSharedPointer<AddressBlock> addrBlock, ComponentEditorTreeModel* model, LibraryInterface* libHandler,\r\n    QSharedPointer<Component> component, QSharedPointer<ReferenceCounter> referenceCounter,\r\n    QSharedPointer<ParameterFinder> parameterFinder, QSharedPointer<ExpressionFormatter> expressionFormatter,\r\n    QSharedPointer<ExpressionParser> expressionParser, QSharedPointer<AddressBlockValidator> addressBlockValidator,\r\n    AddressBlockInterface* blockInterface, ComponentEditorItem* parent):\r\nComponentEditorItem(model, libHandler, component, parent),\r\ncontainingMap_(containingMap),\r\naddrBlock_(addrBlock),\r\nvisualizer_(NULL),\r\ngraphItem_(NULL),\r\nexpressionParser_(expressionParser),\r\naddressUnitBits_(0),\r\naddressBlockValidator_(addressBlockValidator),\r\nblockInterface_(blockInterface)\r\n{\r\n    setReferenceCounter(referenceCounter);\r\n    setParameterFinder(parameterFinder);\r\n    setExpressionFormatter(expressionFormatter);\r\n\r\n\tsetObjectName(tr(\"ComponentEditorAddrBlockItem\"));\r\n\r\n    const int registerCount = addrBlock_->getRegisterData()->count();\r\n    for (int i = 0; i < registerCount; ++i)\r\n    {\r\n        createChild(i);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditorAddrBlockItem::getTooltip()\r\n//-----------------------------------------------------------------------------\r\nQString ComponentEditorAddrBlockItem::getTooltip() const\r\n{\r\n\treturn tr(\"Contains details of a single address block.\");\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditorAddrBlockItem::text()\r\n//-----------------------------------------------------------------------------\r\nQString ComponentEditorAddrBlockItem::text() const\r\n{\r\n\treturn addrBlock_->name();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditorAddrBlockItem::isValid()\r\n//-----------------------------------------------------------------------------\r\nbool ComponentEditorAddrBlockItem::isValid() const \r\n{\r\n    return addressBlockValidator_->validate(addrBlock_, QString::number(addressUnitBits_));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditorAddrBlockItem::editor()\r\n//-----------------------------------------------------------------------------\r\nItemEditor* ComponentEditorAddrBlockItem::editor()\r\n{\r\n\tif (!editor_)\r\n    {\r\n        editor_ = new SingleAddressBlockEditor(blockInterface_, addrBlock_, containingMap_, component_,\r\n            libHandler_, parameterFinder_, expressionFormatter_, expressionParser_, addressBlockValidator_);\r\n\t\teditor_->setProtection(locked_);\r\n\t\tconnect(editor_, SIGNAL(contentChanged()), this, SLOT(onEditorChanged()), Qt::UniqueConnection);\r\n        connect(editor_, SIGNAL(graphicsChanged()), this, SLOT(onGraphicsChanged()), Qt::UniqueConnection);\r\n        connect(editor_, SIGNAL(childGraphicsChanged(int)), this, SLOT(onChildGraphicsChanged(int)), Qt::UniqueConnection);\r\n        connect(editor_, SIGNAL(addressingChanged()), this, SLOT(onAddressingChanged()), Qt::UniqueConnection);\r\n        connect(editor_, SIGNAL(childAddressingChanged(int)), \r\n            this, SLOT(onChildAddressingChanged(int)), Qt::UniqueConnection);\r\n\t\tconnect(editor_, SIGNAL(childAdded(int)), this, SLOT(onAddChild(int)), Qt::UniqueConnection);\r\n\t\tconnect(editor_, SIGNAL(childRemoved(int)), this, SLOT(onRemoveChild(int)), Qt::UniqueConnection);\r\n        connect(editor_, SIGNAL(errorMessage(const QString&)),\r\n            this, SIGNAL(errorMessage(const QString&)), Qt::UniqueConnection);\r\n\t\tconnect(editor_, SIGNAL(helpUrlRequested(QString const&)), this, SIGNAL(helpUrlRequested(QString const&)));\r\n        \r\n        connect(this, SIGNAL(changeInAddressUnitBits(int)),\r\n            editor_, SIGNAL(addressUnitBitsChanged(int)), Qt::UniqueConnection);\r\n\r\n        connect(editor_, SIGNAL(registerNameChanged(QString const&, QString const&)),\r\n            this, SIGNAL(registerNameChanged(QString const&, QString const&)), Qt::UniqueConnection);\r\n\r\n        connect(this, SIGNAL(addressBlockNameChanged(QString const&, QString const&)),\r\n            editor_, SLOT(onAddressBlockNameChanged(QString const&, QString const&)), Qt::UniqueConnection);\r\n\r\n        connectItemEditorToReferenceCounter();\r\n\r\n        emit changeInAddressUnitBits(addressUnitBits_);\r\n\t}\r\n\treturn editor_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditorAddrBlockItem::createChild()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentEditorAddrBlockItem::createChild( int index )\r\n{\r\n    QSharedPointer<RegisterBase> regmodel = addrBlock_->getRegisterData()->at(index);\r\n\tQSharedPointer<Register> reg = regmodel.dynamicCast<Register>();\r\n\tif (reg)\r\n    {\r\n        RegisterInterface* regInterface = blockInterface_->getSubInterface();\r\n\r\n        QSharedPointer<ComponentEditorRegisterItem> regItem(new ComponentEditorRegisterItem(reg,\r\n            addrBlock_->getRegisterData(), model_, libHandler_, component_, parameterFinder_, expressionFormatter_,\r\n            referenceCounter_, expressionParser_, addressBlockValidator_->getRegisterValidator(),\r\n            regInterface, this));\r\n\r\n        connect(this, SIGNAL(registerNameChanged(QString const&, QString const&)),\r\n            regItem.data(), SIGNAL(registerNameChanged(QString const&, QString const&)), Qt::UniqueConnection);\r\n\r\n\t\tregItem->setLocked(locked_);\r\n\t\t\r\n\t\tif (visualizer_)\r\n        {\r\n\t\t\tregItem->setVisualizer(visualizer_);\r\n\t\t}\r\n\r\n        if (reg->getFields()->isEmpty())\r\n        {\r\n            FieldInterface* fieldInterface = regInterface->getSubInterface();\r\n            fieldInterface->setFields(reg->getFields());\r\n            fieldInterface->addField(0);\r\n\r\n            regItem->createChild(0);\r\n        }\r\n\r\n        connect(regItem.data(), SIGNAL(addressingChanged()),\r\n            this, SLOT(onAddressingChanged()), Qt::UniqueConnection);\r\n\t\tchildItems_.insert(index, regItem);\r\n\t}\r\n\r\n    QSharedPointer<RegisterFile> regFile = regmodel.dynamicCast<RegisterFile>();\r\n    if (regFile)\r\n    {\r\n        QSharedPointer<ComponentEditorRegisterFileItem> regFileItem(new ComponentEditorRegisterFileItem(regFile,\r\n            model_, libHandler_, component_, parameterFinder_, expressionFormatter_, referenceCounter_,\r\n            expressionParser_, addressBlockValidator_->getRegisterFileValidator(),\r\n            blockInterface_->getSubInterface(), addrBlock_, addressUnitBits_, this));\r\n        regFileItem->setLocked(locked_);\r\n\r\n        if (visualizer_)\r\n        {\r\n            regFileItem->setVisualizer(visualizer_);\r\n        }\r\n\r\n        connect(regFileItem.data(), SIGNAL(addressingChanged()),\r\n            this, SLOT(onAddressingChanged()), Qt::UniqueConnection);\r\n        childItems_.insert(index, regFileItem);\r\n    }\r\n\r\n    if (visualizer_)\r\n    {\r\n        auto childItem = static_cast<MemoryVisualizationItem*>(childItems_.at(index)->getGraphicsItem());\r\n        Q_ASSERT(childItem);\r\n\r\n        graphItem_->addChild(childItem);\r\n        onAddressingChanged();\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditorAddrBlockItem::removeChild()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentEditorAddrBlockItem::removeChild(int index)\r\n{\r\n    if (visualizer_)\r\n    {\r\n        auto childItem = static_cast<MemoryVisualizationItem*>(childItems_.at(index)->getGraphicsItem());\r\n        Q_ASSERT(childItem);\r\n\r\n        graphItem_->removeChild(childItem);\r\n\r\n        onAddressingChanged();\r\n    }\r\n\r\n    ComponentEditorItem::removeChild(index);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditorAddrBlockItem::onGraphicsChanged()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentEditorAddrBlockItem::onGraphicsChanged()\r\n{\r\n    if (graphItem_)\r\n    {\r\n        graphItem_->updateDisplay();\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditorAddrBlockItem::onGraphicsChanged()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentEditorAddrBlockItem::onChildGraphicsChanged(int index)\r\n{\r\n    childItems_.at(index)->updateGraphics();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditorAddrBlockItem::onAddressingChanged()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentEditorAddrBlockItem::onAddressingChanged()\r\n{\r\n    if (graphItem_ != nullptr)\r\n    {\r\n        graphItem_->redoChildLayout();\r\n\r\n        for (auto child : childItems_)\r\n        {\r\n            child->updateGraphics();\r\n        }\r\n\r\n        emit addressingChanged();\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditorAddrBlockItem::onChildAddressingChanged()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentEditorAddrBlockItem::onChildAddressingChanged(int index)\r\n{\r\n    if (graphItem_ != nullptr)\r\n    {\r\n        auto childRegister = childItems_.at(index).dynamicCast<ComponentEditorRegisterItem>();\r\n\r\n        if (childRegister)\r\n        {\r\n            childRegister->updateGraphics();\r\n            childRegister->onAddressingChanged();\r\n            return;\r\n        }\r\n\r\n        auto childRegisterFile = childItems_.at(index).dynamicCast<ComponentEditorRegisterFileItem>();\r\n\r\n        if (childRegisterFile)\r\n        {\r\n            childRegisterFile->updateGraphics();\r\n            childRegisterFile->onAddressingChanged();\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditorAddrBlockItem::visualizer()\r\n//-----------------------------------------------------------------------------\r\nItemVisualizer* ComponentEditorAddrBlockItem::visualizer()\r\n{\r\n\treturn visualizer_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditorAddrBlockItem::setVisualizer()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentEditorAddrBlockItem::setVisualizer( MemoryMapsVisualizer* visualizer )\r\n{\r\n\tvisualizer_ = visualizer;\r\n\r\n\t// get the graphics item for the memory map\r\n\tauto parentItem = static_cast<MemoryVisualizationItem*>(parent()->getGraphicsItem());\r\n\tQ_ASSERT(parentItem);\r\n\r\n\t// create the graph item for the address block\r\n\tgraphItem_ = new AddressBlockGraphItem(addrBlock_, expressionParser_, parentItem);\r\n    graphItem_->setAddressableUnitBits(addressUnitBits_);\r\n\r\n\t// update the visualizers for register items\r\n\tfor (auto child : childItems_)\r\n    {        \r\n        auto regItem = child.dynamicCast<ComponentEditorRegisterItem>();\r\n        auto regFileItem = child.dynamicCast<ComponentEditorRegisterFileItem>();\r\n\r\n        if (regItem)\r\n        {\r\n          regItem->setVisualizer(visualizer_);\r\n        }\r\n        else if (regFileItem)\r\n        {\r\n          regFileItem->setVisualizer(visualizer_);\r\n        }\r\n   \r\n        auto childGraphicItem = static_cast<MemoryVisualizationItem*>(child->getGraphicsItem());\r\n        graphItem_->addChild(childGraphicItem);\r\n\t}\r\n\r\n    graphItem_->redoChildLayout();\r\n\r\n\tconnect(graphItem_, SIGNAL(selectEditor()),\tthis, SLOT(onSelectRequest()), Qt::UniqueConnection);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditorAddrBlockItem::getGraphicsItem()\r\n//-----------------------------------------------------------------------------\r\nQGraphicsItem* ComponentEditorAddrBlockItem::getGraphicsItem()\r\n{\r\n\treturn graphItem_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditorAddrBlockItem::updateGraphics()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentEditorAddrBlockItem::updateGraphics()\r\n{\r\n\tif (graphItem_)\r\n    {\r\n\t\tgraphItem_->updateDisplay();\r\n\t}\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditorAddrBlockItem::removeGraphicsItem()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentEditorAddrBlockItem::removeGraphicsItem()\r\n{\r\n\tif (graphItem_)\r\n    {\r\n\t\t// get the graphics item for the memory map\r\n\t\tauto parentItem = static_cast<MemoryVisualizationItem*>(parent()->getGraphicsItem());\r\n\t\tQ_ASSERT(parentItem);\r\n\r\n\t\t// unregister addr block graph item from the memory map graph item\r\n\t\tparentItem->removeChild(graphItem_);\r\n\r\n\t\t// take the child from the parent\r\n\t\tgraphItem_->setParent(nullptr);\r\n\r\n\t\tdisconnect(graphItem_, SIGNAL(selectEditor()), this, SLOT(onSelectRequest()));\r\n\r\n\t\t// delete the graph item\r\n\t\tdelete graphItem_;\r\n\t\tgraphItem_ = nullptr;\r\n\t}\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditorAddrBlockItem::addressUnitBitsChanged()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentEditorAddrBlockItem::addressUnitBitsChanged(int newAddressUnitBits)\r\n{\r\n    addressUnitBits_ = newAddressUnitBits;\r\n\r\n    for (auto const& child : childItems_)\r\n    {\r\n        if (auto regFileItem = child.dynamicCast<ComponentEditorRegisterFileItem>())\r\n        {\r\n            regFileItem->addressUnitBitsChanged(newAddressUnitBits);\r\n        }\r\n    }\r\n\r\n    if (graphItem_)\r\n    {\r\n        graphItem_->setAddressableUnitBits(newAddressUnitBits);\r\n        graphItem_->updateDisplay();\r\n        graphItem_->redoChildLayout();\r\n    }\r\n\r\n    emit changeInAddressUnitBits(newAddressUnitBits);\r\n}\r\n"
  },
  {
    "path": "editors/ComponentEditor/treeStructure/componenteditoraddrblockitem.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: componenteditoraddrblockitem.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 23.08.2012\r\n//\r\n// Description:\r\n// The item for a single address block in component editor's navigation tree.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef COMPONENTEDITORADDRBLOCKITEM_H\r\n#define COMPONENTEDITORADDRBLOCKITEM_H\r\n\r\n#include <editors/ComponentEditor/treeStructure/componenteditoritem.h>\r\n\r\n#include <IPXACTmodels/Component/AddressBlock.h>\r\n\r\n#include <QFont>\r\n#include <QSharedPointer>\r\n\r\nclass MemoryMapsVisualizer;\r\nclass AddressBlockGraphItem;\r\nclass ExpressionParser;\r\nclass AddressBlockValidator;\r\nclass RegisterInterface;\r\nclass AddressBlockInterface;\r\nclass MemoryMapBase;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! The item for a single address block in component editor's navigation tree.\r\n//-----------------------------------------------------------------------------\r\nclass ComponentEditorAddrBlockItem : public ComponentEditorItem\r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\r\n\t/*!\r\n\t *  The constructor.\r\n\t *\r\n     *    @param [in] containingMap           Memory map containing the address block.\r\n\t *    @param [in] addrBlock               The address block being edited.\r\n\t *    @param [in] model                   The model that owns the items.\r\n\t *    @param [in] libHandler              The instance that manages the library.\r\n\t *    @param [in] component               The component being edited.\r\n     *    @param [in] referenceCounter        The instance for counting references to parameters.\r\n\t *    @param [in] parameterFinder         The parameter finder.\r\n\t *    @param [in] expressionFormatter     The expression formatter.\r\n\t *    @param [in] expressionParser        The expression formatter.\r\n     *    @param [in] addressBlockValidator   Validator used for address blocks.\r\n     *    @param [in] blockInterface          Interface for accessing address blocks.\r\n\t *    @param [in] parent                  The parent item.\r\n\t */\r\n    ComponentEditorAddrBlockItem(QSharedPointer<MemoryMapBase> containingMap,\r\n        QSharedPointer<AddressBlock> addrBlock,\r\n        ComponentEditorTreeModel* model,\r\n        LibraryInterface* libHandler,\r\n        QSharedPointer<Component> component,\r\n        QSharedPointer<ReferenceCounter> referenceCounter,\r\n        QSharedPointer<ParameterFinder> parameterFinder,\r\n        QSharedPointer<ExpressionFormatter> expressionFormatter,\r\n        QSharedPointer<ExpressionParser> expressionParser,\r\n        QSharedPointer<AddressBlockValidator> addressBlockValidator,\r\n        AddressBlockInterface* blockInterface,\r\n\t\tComponentEditorItem* parent);\r\n\r\n\t//! The destructor.\r\n\tvirtual ~ComponentEditorAddrBlockItem() = default;\r\n\r\n\r\n    //! No copying. No assignment.\r\n    ComponentEditorAddrBlockItem(const ComponentEditorAddrBlockItem& other) = delete;\r\n    ComponentEditorAddrBlockItem& operator=(const ComponentEditorAddrBlockItem& other) = delete;\r\n\r\n\t/*!\r\n     *  Get the tool tip for the item.\r\n\t * \r\n\t *    @return The text for the tool tip to print to user.\r\n\t */\r\n\tvirtual QString getTooltip() const override final;\r\n\r\n\t/*!\r\n     *  Get the text to be displayed to user in the tree for this item.\r\n\t *\r\n\t *    @return QString Contains the text to display.\r\n\t */\r\n\tvirtual QString text() const override final;\r\n\r\n\t/*!\r\n     *  Check the validity of this item and sub items.\r\n\t *\r\n\t *    @return bool True if item is in valid state.\r\n\t */\r\n\tvirtual bool isValid() const override final;\r\n\r\n\t/*!\r\n     *  Get pointer to the editor of this item.\r\n\t *\r\n\t *    @return The editor to use for this item.\r\n\t */\r\n\tvirtual ItemEditor* editor() override final;\r\n\r\n\t/*!\r\n     *  Add a new child to the item.\r\n\t * \r\n\t *    @param [in] index The index to add the child into.\r\n\t */\r\n\tvirtual void createChild(int index) override final;\r\n\r\n    virtual void removeChild(int index) override final;\r\n\r\n    /*!\r\n     *  Get pointer to the visualizer of this item.\r\n\t * \r\n\t *    @return The visualizer to use for this item.\r\n\t */\r\n\tvirtual ItemVisualizer* visualizer() override final;\r\n\r\n\t/*!\r\n     *  Set the visualizer for this item.\r\n\t *\r\n\t *    @param [in] visualizer The visualizer.\r\n\t */\r\n\tvoid setVisualizer(MemoryMapsVisualizer* visualizer);\r\n\r\n\t/*!\r\n     *  Get the visualizer graphics item for the address block.\r\n\t *\r\n\t *    @return QGraphicsItem* The graphics item.\r\n\t */\r\n\tvirtual QGraphicsItem* getGraphicsItem() override final;\r\n\r\n\t/*!\r\n     *  Update the graphics item of the address block.\r\n\t */\r\n\tvirtual void updateGraphics() override final;\r\n\r\n\t/*!\r\n     *  Remove the graphics item of the address block.\r\n\t */\r\n\tvirtual void removeGraphicsItem() override final;\r\n\r\n    /*!\r\n     *  Change the address unit bits in component editor.\r\n     *\r\n     *    @param [in] newAddressUnitBits   The new value for address unit bits.\r\n     */\r\n    void addressUnitBitsChanged(int newAddressUnitBits);\r\n\r\npublic slots:\r\n\r\n    //! Handle the change in item's addressing data.\r\n    void onAddressingChanged();\r\n\r\n    //! Handle the change in child item's addressing data.\r\n    void onChildAddressingChanged(int index);\r\n\r\nprotected slots:\r\n    \r\n    /*!\r\n     *  Handles the redrawing of the visualization of the item.\r\n     */\r\n    virtual void onGraphicsChanged();\r\n\r\n    void onChildGraphicsChanged(int index);    \r\n\r\nsignals:\r\n    \r\n    /*!\r\n     *  Signals a change in the address unit bits.\r\n     *\r\n     *    @param [in] newAddressUnitBits  The new address unit bits.\r\n     */\r\n    void changeInAddressUnitBits(int newAddressUnitBits);\r\n\r\n\r\n    //! Signals a change in the item's address data.\r\n    void addressingChanged();\r\n\r\n    /*\r\n     *  Informs of register name change.\r\n     *\r\n     *    @param [in] oldName     The old name.\r\n     *    @param [in] newName     The new name.\r\n     */\r\n    void registerNameChanged(QString const& oldName, QString const& newName);\r\n\r\n    /*\r\n     *  Informs of address block name change.\r\n     *\r\n     *    @param [in] oldName     The old name.\r\n     *    @param [in] newName     The new name.\r\n     */\r\n    void addressBlockNameChanged(QString const& oldName, QString const& newName);\r\n\r\nprivate:\r\n\t\r\n    //! Memory map containing the edited address block.\r\n    QSharedPointer<MemoryMapBase> containingMap_;\r\n\r\n\t//! The address block being edited.\r\n\tQSharedPointer<AddressBlock> addrBlock_;\r\n\r\n\t//! The visualizer for memory maps.\r\n\tMemoryMapsVisualizer* visualizer_;\r\n\r\n\t//! The graph item which visualizes the address block.\r\n\tAddressBlockGraphItem* graphItem_;\r\n\r\n    //! The expression parser to use.\r\n    QSharedPointer<ExpressionParser> expressionParser_;\r\n\r\n    //! The number of addressable unit bits in the address block.\r\n    unsigned int addressUnitBits_;\r\n\r\n    //! The used address block validator.\r\n    QSharedPointer<AddressBlockValidator> addressBlockValidator_;    \r\n    \r\n\r\n    //! Interface for address blocks.\r\n    AddressBlockInterface* blockInterface_;\r\n};\r\n\r\n#endif // COMPONENTEDITORADDRBLOCKITEM_H\r\n"
  },
  {
    "path": "editors/ComponentEditor/treeStructure/componenteditoraddrspaceitem.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: componenteditoraddrspaceitem.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 10.05.2012\r\n//\r\n// Description:\r\n// The item for a single address space in the component editor's navigation tree.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"componenteditoraddrspaceitem.h\"\r\n#include \"componenteditoraddrblockitem.h\"\r\n\r\n#include <KactusAPI/include/ExpressionParser.h>\r\n#include <editors/ComponentEditor/addressSpaces/localMemoryMap/localmemorymapgraphitem.h>\r\n#include <editors/ComponentEditor/addressSpaces/addressSpaceVisualizer/addressspacevisualizer.h>\r\n#include <KactusAPI/include/AddressBlockInterface.h>\r\n#include <editors/ComponentEditor/memoryMaps/memoryMapsVisualizer/memorymapsvisualizer.h>\r\n\r\n#include <IPXACTmodels/Component/Component.h>\r\n#include <IPXACTmodels/Component/AddressSpace.h>\r\n#include <IPXACTmodels/Component/MemoryMapBase.h>\r\n#include <IPXACTmodels/Component/MemoryBlockBase.h>\r\n#include <IPXACTmodels/Component/AddressBlock.h>\r\n\r\n#include <IPXACTmodels/Component/validators/AddressSpaceValidator.h>\r\n#include <IPXACTmodels/Component/validators/MemoryMapBaseValidator.h>\r\n#include <IPXACTmodels/Component/validators/AddressBlockValidator.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditorAddrSpaceItem::ComponentEditorAddrSpaceItem()\r\n//-----------------------------------------------------------------------------\r\nComponentEditorAddrSpaceItem::ComponentEditorAddrSpaceItem(QSharedPointer<AddressSpace> addrSpace,\r\n    ComponentEditorTreeModel* model, LibraryInterface* libHandler, QSharedPointer<Component> component,\r\n    QSharedPointer<ReferenceCounter> referenceCounter, QSharedPointer<ParameterFinder> parameterFinder,\r\n    QSharedPointer<ExpressionFormatter> expressionFormatter, QSharedPointer<ExpressionParser> expressionParser,\r\n    QSharedPointer<AddressSpaceValidator> addressSpaceValidator, AddressBlockInterface* blockInterface,\r\n    ComponentEditorItem* parent):\r\nComponentEditorItem(model, libHandler, component, parent),\r\naddrSpace_(addrSpace),\r\nlocalMemMapVisualizer_(new MemoryMapsVisualizer()),\r\naddrSpaceVisualizer_(new AddressSpaceVisualizer(addrSpace, expressionParser)),\r\nexpressionParser_(expressionParser),\r\nspaceValidator_(addressSpaceValidator),\r\nblockInterface_(blockInterface)\r\n{\r\n    setReferenceCounter(referenceCounter);\r\n    setParameterFinder(parameterFinder);\r\n    setExpressionFormatter(expressionFormatter);\r\n\r\n\tsetObjectName(tr(\"ComponentEditorAddrSpaceItem\"));\r\n    \r\n    if (QSharedPointer<MemoryMapBase> localMap = addrSpace->getLocalMemoryMap(); localMap)\r\n    {\r\n        const auto BLOCK_COUNT = localMap->getMemoryBlocks()->count();\r\n        for (int i = 0; i < BLOCK_COUNT; ++i)\r\n        {\r\n            ComponentEditorAddrSpaceItem::createChild(i);\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditorAddrSpaceItem::~ComponentEditorAddrSpaceItem()\r\n//-----------------------------------------------------------------------------\r\nComponentEditorAddrSpaceItem::~ComponentEditorAddrSpaceItem()\r\n{\r\n    delete localMemMapVisualizer_;\r\n    localMemMapVisualizer_ = nullptr;\r\n\r\n    delete addrSpaceVisualizer_;\r\n    addrSpaceVisualizer_ = nullptr;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditorAddrSpaceItem::text()\r\n//-----------------------------------------------------------------------------\r\nQString ComponentEditorAddrSpaceItem::text() const\r\n{\r\n\treturn addrSpace_->name();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditorAddrSpaceItem::isValid()\r\n//-----------------------------------------------------------------------------\r\nbool ComponentEditorAddrSpaceItem::isValid() const\r\n{\r\n    return spaceValidator_->validate(addrSpace_);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditorAddrSpaceItem::editor()\r\n//-----------------------------------------------------------------------------\r\nItemEditor* ComponentEditorAddrSpaceItem::editor()\r\n{\r\n\tif (!editor_)\r\n    {\r\n        editor_ = new AddressSpaceEditor(component_, libHandler_, addrSpace_, parameterFinder_,\r\n            expressionFormatter_, expressionParser_, blockInterface_);\r\n        editor_->setProtection(locked_);\r\n\r\n\t\tconnect(editor_, SIGNAL(contentChanged()), this, SLOT(onEditorChanged()), Qt::UniqueConnection);\r\n        connect(editor_, SIGNAL(graphicsChanged()), this, SLOT(onGraphicsChanged()), Qt::UniqueConnection);\r\n        connect(editor_, SIGNAL(childGraphicsChanged(int)), this, SLOT(onChildGraphicsChanged(int)), Qt::UniqueConnection);\r\n        connect(editor_, SIGNAL(addressingChanged()), this, SLOT(onAddressingChanged()), Qt::UniqueConnection);\r\n        connect(editor_, SIGNAL(childAddressingChanged(int)), this, SLOT(onChildAddressingChanged(int)), Qt::UniqueConnection);\r\n\r\n        connect(editor_, SIGNAL(childAdded(int)), this, SLOT(onAddChild(int)), Qt::UniqueConnection);\r\n\t\tconnect(editor_, SIGNAL(childRemoved(int)),\tthis, SLOT(onRemoveChild(int)), Qt::UniqueConnection);\r\n        connect(editor_, SIGNAL(errorMessage(QString const&)), this, SIGNAL(errorMessage(QString const&)));\r\n\t\tconnect(editor_, SIGNAL(helpUrlRequested(QString const&)), this, SIGNAL(helpUrlRequested(QString const&)));\r\n\r\n        connect(this, SIGNAL(assignNewAddressUnitBits(QString const&)),\r\n            editor_, SIGNAL(assignNewAddressUnitBits(QString const&)), Qt::UniqueConnection);\r\n\r\n        connect(editor_, SIGNAL(newAddressUnitBitsForAddressSpaceChildItems()),\r\n            this, SLOT(changeAdressUnitBitsOnAddressBlocks()), Qt::UniqueConnection);\r\n\r\n        connectItemEditorToReferenceCounter();\r\n\t}\r\n\treturn editor_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditorAddrSpaceItem::getTooltip()\r\n//-----------------------------------------------------------------------------\r\nQString ComponentEditorAddrSpaceItem::getTooltip() const\r\n{\r\n\treturn tr(\"Address space defines a logical address space seen by a master bus interface\");\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditorAddrSpaceItem::createChild()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentEditorAddrSpaceItem::createChild(int index)\r\n{\r\n    QSharedPointer<MemoryMapBase> localMap = addrSpace_->getLocalMemoryMap();\r\n    if (!graphItem_)\r\n    {\r\n        graphItem_ = new LocalMemoryMapGraphItem(addrSpace_, localMap, expressionParser_);\r\n        localMemMapVisualizer_->addMemoryMapItem(graphItem_);\r\n        graphItem_->updateDisplay();\r\n    }\r\n\r\n    QSharedPointer<MemoryBlockBase> block = localMap->getMemoryBlocks()->at(index);\r\n    QSharedPointer<AddressBlock> addrBlock = block.dynamicCast<AddressBlock>();\r\n\tif (addrBlock)\r\n    {\r\n\t\tQSharedPointer<ComponentEditorAddrBlockItem> addressBlockItem(new ComponentEditorAddrBlockItem(localMap,\r\n            addrBlock, model_, libHandler_, component_, referenceCounter_, parameterFinder_, expressionFormatter_,\r\n            expressionParser_, spaceValidator_->getLocalMemoryMapValidator()->getAddressBlockValidator(),\r\n            blockInterface_, this));\r\n\t\taddressBlockItem->setLocked(locked_);\r\n\r\n        int addressUnitBits = expressionParser_->parseExpression(addrSpace_->getAddressUnitBits()).toInt();\r\n        addressBlockItem->addressUnitBitsChanged(addressUnitBits);\r\n\r\n\t\tif (localMemMapVisualizer_)\r\n        {\r\n            addressBlockItem->setVisualizer(localMemMapVisualizer_);\r\n            graphItem_->addChild(static_cast<MemoryVisualizationItem*>(addressBlockItem->getGraphicsItem()));\r\n            \r\n            onAddressingChanged();\r\n\t\t}\r\n\t\tchildItems_.insert(index, addressBlockItem);\r\n\r\n        connect(addressBlockItem.data(), SIGNAL(addressingChanged()), this, SLOT(onAddressingChanged()));\r\n\t}\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditorAddrSpaceItem::removeChild()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentEditorAddrSpaceItem::removeChild(int index)\r\n{\r\n    ComponentEditorItem::removeChild(index);\r\n    onAddressingChanged();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditorAddrSpaceItem::getGraphicsItem()\r\n//-----------------------------------------------------------------------------\r\nQGraphicsItem* ComponentEditorAddrSpaceItem::getGraphicsItem()\r\n{\r\n\treturn graphItem_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditorAddrSpaceItem::updateGraphics()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentEditorAddrSpaceItem::updateGraphics()\r\n{\r\n\tgraphItem_->updateDisplay();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditorAddrSpaceItem::removeGraphicsItem()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentEditorAddrSpaceItem::removeGraphicsItem()\r\n{\r\n    if (graphItem_)\r\n    {\r\n        // remove the graph item from the scene\r\n        localMemMapVisualizer_->removeMemoryMapItem(graphItem_);\r\n\r\n        disconnect(graphItem_, SIGNAL(selectEditor()), this, SLOT(onSelectRequest()));\r\n\r\n        // delete the graph item\r\n        delete graphItem_;\r\n        graphItem_ = NULL;\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditorAddrSpaceItem::visualizer()\r\n//-----------------------------------------------------------------------------\r\nItemVisualizer* ComponentEditorAddrSpaceItem::visualizer()\r\n{\r\n\treturn addrSpaceVisualizer_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditorAddrSpaceItem::onGraphicsChanged()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentEditorAddrSpaceItem::onGraphicsChanged()\r\n{\r\n\taddrSpaceVisualizer_->refresh();\r\n\r\n    if (graphItem_ != nullptr)\r\n    {\r\n        graphItem_->updateDisplay();\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditorAddrSpaceItem::onChildGraphicsChanged()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentEditorAddrSpaceItem::onChildGraphicsChanged(int index)\r\n{\r\n    if (graphItem_ != nullptr)\r\n    {\r\n        childItems_.at(index)->updateGraphics();\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditorAddrSpaceItem::onAddressingChanged()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentEditorAddrSpaceItem::onAddressingChanged()\r\n{\r\n    if (graphItem_ != nullptr)\r\n    {\r\n        graphItem_->updateDisplay();\r\n        graphItem_->redoChildLayout();\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditorAddrSpaceItem::onChildAddressingChanged()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentEditorAddrSpaceItem::onChildAddressingChanged(int index)\r\n{\r\n    if (graphItem_ != nullptr)\r\n    {\r\n        if (auto childBlock = childItems_.at(index).dynamicCast<ComponentEditorAddrBlockItem>();\r\n            childBlock)\r\n        {\r\n            childBlock->updateGraphics();\r\n            childBlock->onAddressingChanged();\r\n        }\r\n\r\n        graphItem_->redoChildLayout();\r\n    }\r\n\r\n    addrSpaceVisualizer_->refresh();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: componenteditoraddrspaceitem::changeAddressUnitBits()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentEditorAddrSpaceItem::changeAdressUnitBitsOnAddressBlocks()\r\n{\r\n    QString addressUnitBits = addrSpace_->getAddressUnitBits();\r\n\r\n    for (QSharedPointer<ComponentEditorItem> childItem : childItems_)\r\n    {\r\n        QSharedPointer<ComponentEditorAddrBlockItem> castChildItem = \r\n            qobject_cast<QSharedPointer<ComponentEditorAddrBlockItem> >(childItem);\r\n\r\n        int newAddressUnitBits = expressionParser_->parseExpression(addressUnitBits).toInt();\r\n        castChildItem->addressUnitBitsChanged(newAddressUnitBits);\r\n    }\r\n\r\n\r\n    emit assignNewAddressUnitBits(addressUnitBits);\r\n}\r\n"
  },
  {
    "path": "editors/ComponentEditor/treeStructure/componenteditoraddrspaceitem.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: componenteditoraddrspaceitem.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 10.05.2012\r\n//\r\n// Description:\r\n// The item for a single address space in the component editor's navigation tree.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef COMPONENTEDITORADDRSPACEITEM_H\r\n#define COMPONENTEDITORADDRSPACEITEM_H\r\n\r\n#include \"componenteditoritem.h\"\r\n\r\n#include <editors/ComponentEditor/addressSpaces/addressspaceeditor.h>\r\n#include <editors/ComponentEditor/addressSpaces/addressSpaceVisualizer/addressspacevisualizer.h>\r\n\r\nclass LocalMemoryMapGraphItem;\r\nclass MemoryMapsVisualizer;\r\nclass ExpressionParser;\r\nclass Component;\r\nclass AddressSpace;\r\nclass MemoryMapBase;\r\nclass MemoryBlockBase;\r\nclass AddressSpaceValidator;\r\nclass AddressBlockInterface;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! The item for a single address space in the component editor's navigation tree.\r\n//-----------------------------------------------------------------------------\r\nclass ComponentEditorAddrSpaceItem : public ComponentEditorItem\r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\r\n\t/*!\r\n\t *  The constructor.\r\n\t *\r\n\t *    @param [in] addrSpace               The address space being edited.\r\n\t *    @param [in] model                   The model that owns the items.\r\n\t *    @param [in] libHandler              The instance that manages the library.\r\n\t *    @param [in] component               The component being edited.\r\n     *    @param [in] referenceCounter        The instance for counting references to parameters.\r\n\t *    @param [in] parameterFinder         The parameter finder.\r\n\t *    @param [in] expressionFormatter     The expression formatter.\r\n\t *    @param [in] expressionParser        The expression parser to use.\r\n     *    @param [in] addressSpaceValidator   Validator for address spaces.\r\n     *    @param [in] blockInterface          Interface for accessing address blocks.\r\n\t *    @param [in] parent                  The parent item.\r\n\t */\r\n\tComponentEditorAddrSpaceItem(QSharedPointer<AddressSpace> addrSpace,\r\n\t\tComponentEditorTreeModel* model,\r\n\t\tLibraryInterface* libHandler,\r\n\t\tQSharedPointer<Component> component,\r\n        QSharedPointer<ReferenceCounter> referenceCounter,\r\n        QSharedPointer<ParameterFinder> parameterFinder,\r\n        QSharedPointer<ExpressionFormatter> expressionFormatter,\r\n        QSharedPointer<ExpressionParser> expressionParser,\r\n        QSharedPointer<AddressSpaceValidator> addressSpaceValidator,\r\n        AddressBlockInterface* blockInterface,\r\n\t\tComponentEditorItem* parent);\r\n\r\n\t//! The destructor.\r\n\tvirtual ~ComponentEditorAddrSpaceItem();\r\n\r\n    //! No copying.\r\n    ComponentEditorAddrSpaceItem(const ComponentEditorAddrSpaceItem& other) = delete;\r\n\r\n    //! No assignment.\r\n    ComponentEditorAddrSpaceItem& operator=(const ComponentEditorAddrSpaceItem& other) = delete;\r\n\r\n\t/*!\r\n     *  Get the tool tip for the item.\r\n\t * \r\n\t *    @return The text for the tool tip to print to user.\r\n\t */\r\n\tvirtual QString getTooltip() const;\r\n\r\n\t/*!\r\n     *  Get the text to be displayed to user in the tree for this item.\r\n\t *\r\n\t *    @return QString Contains the text to display.\r\n\t */\r\n\tvirtual QString text() const;\r\n\r\n\t/*!\r\n     *  Check the validity of this item and sub items.\r\n\t *\r\n\t *    @return bool True if item is in valid state.\r\n\t */\r\n\tvirtual bool isValid() const;\r\n\r\n\t/*!\r\n     *  Get pointer to the editor of this item.\r\n\t *\r\n\t *    @return The editor to use for this item.\r\n\t */\r\n\tvirtual ItemEditor* editor();\r\n\r\n\t/*!\r\n     *  Add a new child to the item.\r\n\t * \r\n\t *    @param [in] index The index to add the child into.\r\n\t */\r\n\tvirtual void createChild(int index);\r\n\r\n\t/*!\r\n\t *  Remove the child from the given index.\r\n\t *\r\n\t *    @param [in] index Identifies the child to remove.\r\n\t */\r\n    void removeChild(int index) final;\r\n\r\n\t/*!\r\n     *  Get the visualizer graphics item for the memory map.\r\n\t *\r\n\t *    @return QGraphicsItem* The graphics item.\r\n\t */\r\n\tvirtual QGraphicsItem* getGraphicsItem();\r\n\r\n\t/*!\r\n     *  Update the graphics item of the memory map.\r\n\t */\r\n\tvirtual void updateGraphics();\r\n\r\n\t/*!\r\n     *  Remove the graphics item of the memory map.\r\n\t */\r\n\tvirtual void removeGraphicsItem();\r\n\r\n\t/*!\r\n     *  Get pointer to the visualizer of this item.\r\n\t * \r\n\t *    @return The visualizer to use for this item.\r\n\t */\r\n\tvirtual ItemVisualizer* visualizer();\r\n\r\npublic slots:\r\n\r\n    /*!\r\n     *  Change the used address unit bits in the contained address blocks.\r\n     */\r\n    void changeAdressUnitBitsOnAddressBlocks();\r\n\r\nprotected slots:\r\n\r\n\t/*!\r\n     *  Handler for editor's contentChanged signal.\r\n\t */\r\n\tvirtual void onGraphicsChanged();\r\n\r\n    void onChildGraphicsChanged(int index);\r\n\r\n    void onAddressingChanged();\r\n\r\n    void onChildAddressingChanged(int index);\r\n\r\nsignals:\r\n\r\n    /*!\r\n     *  Assign new address unit bits to editor.\r\n     *\r\n     *    @param [in] newAddressUnitBits  The new address unit bits.\r\n     */\r\n    void assignNewAddressUnitBits(QString const& newAddressUnitBits);\r\n\r\n    void addressingChanged();\r\n\r\nprivate:\r\n\r\n\t//! The address space being edited.\r\n\tQSharedPointer<AddressSpace> addrSpace_;\r\n\r\n\t//! The graph item of the local memory map.\r\n\tLocalMemoryMapGraphItem* graphItem_ = nullptr;\r\n\r\n\t//! The visualizer for the local memory maps.\r\n\tMemoryMapsVisualizer* localMemMapVisualizer_;\r\n\r\n\t//! The visualizer of this tree item, visualizes the relation of segments and local memory map. \r\n\tAddressSpaceVisualizer* addrSpaceVisualizer_;\r\n\r\n    //! The expression parser to use.\r\n    QSharedPointer<ExpressionParser> expressionParser_;\r\n\r\n    //! The used address space validator.\r\n    QSharedPointer<AddressSpaceValidator> spaceValidator_;\r\n\r\n    //! Block interface for address blocks.\r\n    AddressBlockInterface* blockInterface_;\r\n};\r\n\r\n#endif // COMPONENTEDITORADDRSPACEITEM_H\r\n"
  },
  {
    "path": "editors/ComponentEditor/treeStructure/componenteditoraddrspacesitem.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: componenteditoraddrspacesitem.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 09.05.2012\r\n//\r\n// Description:\r\n// The Address spaces-item in the component editor navigation tree.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"componenteditoraddrspacesitem.h\"\r\n#include \"componenteditoraddrspaceitem.h\"\r\n\r\n#include <editors/ComponentEditor/treeStructure/componenteditortreemodel.h>\r\n#include <editors/ComponentEditor/addressSpaces/addressspaceseditor.h>\r\n\r\n#include <KactusAPI/include/ResetInterface.h>\r\n#include <KactusAPI/include/FieldInterface.h>\r\n#include <KactusAPI/include/RegisterInterface.h>\r\n#include <KactusAPI/include/AddressBlockInterface.h>\r\n#include <KactusAPI/include/BusInterfaceInterface.h>\r\n#include <KactusAPI/include/AccessPolicyInterface.h>\r\n#include <KactusAPI/include/ModeReferenceInterface.h>\r\n\r\n#include <KactusAPI/include/ParametersInterface.h>\r\n\r\n#include <IPXACTmodels/Component/Component.h>\r\n#include <IPXACTmodels/Component/AddressSpace.h>\r\n\r\n#include <IPXACTmodels/Component/validators/AddressSpaceValidator.h>\r\n#include <IPXACTmodels/Component/validators/CollectionValidators.h>\r\n#include <IPXACTmodels/Component/validators/MemoryMapBaseValidator.h>\r\n#include <IPXACTmodels/Component/validators/AddressBlockValidator.h>\r\n#include <IPXACTmodels/Component/validators/SubspaceMapValidator.h>\r\n#include <IPXACTmodels/Component/validators/RegisterValidator.h>\r\n#include <IPXACTmodels/Component/validators/RegisterFileValidator.h>\r\n#include <IPXACTmodels/Component/validators/FieldValidator.h>\r\n#include <IPXACTmodels/Component/validators/EnumeratedValueValidator.h>\r\n#include <IPXACTmodels/Component/validators/PortMapValidator.h>\r\n#include <IPXACTmodels/Component/validators/BusInterfaceValidator.h>\r\n#include <IPXACTmodels/common/validators/ParameterValidator.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditorAddrSpacesItem::ComponentEditorAddrSpacesItem()\r\n//-----------------------------------------------------------------------------\r\nComponentEditorAddrSpacesItem::ComponentEditorAddrSpacesItem(ComponentEditorTreeModel* model,\r\n    LibraryInterface* libHandler, QSharedPointer<Component> component,\r\n    QSharedPointer<ReferenceCounter> referenceCounter, QSharedPointer<ParameterFinder> parameterFinder,\r\n    QSharedPointer<ExpressionFormatter> expressionFormatter, \r\n    QSharedPointer<ExpressionParser> expressionParser, ComponentEditorItem* parent):\r\nComponentEditorItem(model, libHandler, component, parent),\r\naddressSpaces_(component->getAddressSpaces()),\r\nexpressionParser_(expressionParser),\r\nspaceValidator_(),\r\nblockInterface_()\r\n{\r\n    createAddressSpaceValidator();\r\n\r\n    setReferenceCounter(referenceCounter);\r\n    setParameterFinder(parameterFinder);\r\n    setExpressionFormatter(expressionFormatter);\r\n\r\n    createAddressBlockInterface();\r\n\r\n\tfor (QSharedPointer<AddressSpace> addrSpace : *addressSpaces_)\r\n    {\r\n\t\tQSharedPointer<ComponentEditorAddrSpaceItem> addrItem(\r\n\t\t\tnew ComponentEditorAddrSpaceItem(addrSpace, model, libHandler, component, referenceCounter_,\r\n            parameterFinder_, expressionFormatter_, expressionParser_, spaceValidator_, blockInterface_, this));\t\r\n\t\tchildItems_.append(addrItem);\r\n\t};\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditorAddrSpacesItem::~ComponentEditorAddrSpacesItem()\r\n//-----------------------------------------------------------------------------\r\nComponentEditorAddrSpacesItem::~ComponentEditorAddrSpacesItem()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditorAddrSpacesItem::getFont()\r\n//-----------------------------------------------------------------------------\r\nQFont ComponentEditorAddrSpacesItem::getFont() const\r\n{\r\n    QFont font(ComponentEditorItem::getFont());\r\n    font.setBold(!addressSpaces_->empty());\r\n    return font;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditorAddrSpacesItem::text()\r\n//-----------------------------------------------------------------------------\r\nQString ComponentEditorAddrSpacesItem::text() const\r\n{\r\n\treturn tr(\"Address spaces\");\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditorAddrSpacesItem::editor()\r\n//-----------------------------------------------------------------------------\r\nItemEditor* ComponentEditorAddrSpacesItem::editor()\r\n{\r\n\tif (!editor_)\r\n    {\r\n\t\teditor_ = new AddressSpacesEditor(component_, libHandler_, parameterFinder_, expressionFormatter_,\r\n            expressionParser_, spaceValidator_);\r\n\t\teditor_->setProtection(locked_);\r\n\r\n\t\tconnect(editor_, SIGNAL(contentChanged()), this, SLOT(onEditorChanged()), Qt::UniqueConnection);\r\n\t\tconnect(editor_, SIGNAL(childAdded(int)), this, SLOT(onAddChild(int)), Qt::UniqueConnection);\r\n\t\tconnect(editor_, SIGNAL(childRemoved(int)), this, SLOT(onRemoveChild(int)), Qt::UniqueConnection);\r\n\t\tconnect(editor_, SIGNAL(helpUrlRequested(QString const&)), this, SIGNAL(helpUrlRequested(QString const&)));\r\n\t\tconnect(editor_, SIGNAL(selectBusInterface(const QString&)),\r\n\t\t\tmodel_, SLOT(onSelectBusInterface(const QString&)), Qt::UniqueConnection);\r\n\r\n        connect(editor_, SIGNAL(aubChangedOnRow(int)),\r\n            this, SLOT(addressUnitBitsChangedInRow(int)), Qt::UniqueConnection);\r\n\r\n        connectItemEditorToReferenceCounter();\r\n\t}\r\n\treturn editor_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditorAddrSpacesItem::getTooltip()\r\n//-----------------------------------------------------------------------------\r\nQString ComponentEditorAddrSpacesItem::getTooltip() const\r\n{\r\n\treturn tr(\"Contains the address spaces specified for the component\");\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditorAddrSpacesItem::createChild()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentEditorAddrSpacesItem::createChild( int index )\r\n{\r\n\tQSharedPointer<ComponentEditorAddrSpaceItem> addrItem(new ComponentEditorAddrSpaceItem(\r\n        addressSpaces_->at(index), model_, libHandler_, component_, referenceCounter_, parameterFinder_,\r\n        expressionFormatter_, expressionParser_, spaceValidator_, blockInterface_, this));\r\n\taddrItem->setLocked(locked_);\r\n\tchildItems_.insert(index, addrItem);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditorAddrSpacesItem::isValid()\r\n//-----------------------------------------------------------------------------\r\nbool ComponentEditorAddrSpacesItem::isValid() const\r\n{\r\n    auto addressSpacesAsNameGroups = CollectionValidators::itemListToNameGroupList(addressSpaces_);\r\n    addressSpacesValidator_->childrenHaveUniqueNames(addressSpacesAsNameGroups);\r\n    return ComponentEditorItem::isValid();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: componenteditoraddrspacesitem::createAddressSpaceValidator()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentEditorAddrSpacesItem::createAddressSpaceValidator()\r\n{\r\n    QSharedPointer<ParameterValidator> parameterValidator (new ParameterValidator(expressionParser_,\r\n        component_->getChoices(), component_->getRevision()));\r\n    QSharedPointer<EnumeratedValueValidator> enumValidator (new EnumeratedValueValidator(expressionParser_));\r\n    QSharedPointer<FieldValidator> fieldValidator (\r\n        new FieldValidator(expressionParser_, enumValidator, parameterValidator));\r\n    QSharedPointer<RegisterValidator> registerValidator(\r\n        new RegisterValidator(expressionParser_, fieldValidator, parameterValidator));\r\n\r\n    QSharedPointer<RegisterFileValidator> registerFileValidator(\r\n        new RegisterFileValidator(expressionParser_, registerValidator, parameterValidator, component_->getRevision()));\r\n\r\n\r\n    QSharedPointer<AddressBlockValidator> blockValidator(\r\n        new AddressBlockValidator(expressionParser_, registerValidator,registerFileValidator, parameterValidator, \r\n            component_->getRevision()));\r\n    blockValidator->componentChange(component_);\r\n\r\n    QSharedPointer<SubspaceMapValidator> subspaceValidator(\r\n        new SubspaceMapValidator(expressionParser_, parameterValidator, component_->getRevision()));\r\n\r\n    QSharedPointer<MemoryMapBaseValidator> localMapValidator(\r\n        new MemoryMapBaseValidator(expressionParser_, blockValidator, subspaceValidator));\r\n\r\n    QSharedPointer<AddressSpaceValidator> addressSpaceValidator(\r\n        new AddressSpaceValidator(expressionParser_, localMapValidator, parameterValidator));\r\n\r\n    spaceValidator_ = addressSpaceValidator;\r\n\r\n    addressSpacesValidator_ = QSharedPointer<AddressSpacesValidator>(new AddressSpacesValidator(addressSpaceValidator));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: componenteditoraddrspacesitem::addressUnitBitsChangedInRow()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentEditorAddrSpacesItem::addressUnitBitsChangedInRow(int spaceIndex)\r\n{\r\n    QSharedPointer<ComponentEditorAddrSpaceItem> childSpace = \r\n        qobject_cast<QSharedPointer<ComponentEditorAddrSpaceItem> > ( child(spaceIndex) );\r\n\r\n    if (!childSpace.isNull())\r\n    {\r\n        childSpace->changeAdressUnitBitsOnAddressBlocks();\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: componenteditoraddrspacesitem::createAddressBlockInterface()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentEditorAddrSpacesItem::createAddressBlockInterface()\r\n{\r\n    QSharedPointer<AddressBlockValidator> blockValidator =\r\n        spaceValidator_->getLocalMemoryMapValidator()->getAddressBlockValidator();\r\n    QSharedPointer<RegisterValidator> registerValidator = blockValidator->getRegisterValidator();\r\n    QSharedPointer<FieldValidator> fieldValidator = registerValidator->getFieldValidator();\r\n\r\n    QSharedPointer<ParameterValidator> parameterValidator(new ParameterValidator(expressionParser_,\r\n        component_->getChoices(), component_->getRevision()));\r\n\r\n    ParametersInterface* parameterInterface(\r\n        new ParametersInterface(parameterValidator, expressionParser_, expressionFormatter_));\r\n\r\n    ResetInterface* resetInterface(new ResetInterface(fieldValidator, expressionParser_, expressionFormatter_));\r\n    FieldInterface* fieldInterface(\r\n        new FieldInterface(fieldValidator, expressionParser_, expressionFormatter_, resetInterface));\r\n\r\n    ModeReferenceInterface* modeRefInterface(new ModeReferenceInterface());\r\n    modeRefInterface->setComponentModes(component_->getModes());\r\n\r\n    AccessPolicyInterface* accessPolicyInterface(new AccessPolicyInterface(modeRefInterface));\r\n    accessPolicyInterface->setComponentModes(component_->getModes());\r\n\r\n    RegisterInterface* registerInterface(\r\n        new RegisterInterface(registerValidator, expressionParser_, expressionFormatter_, fieldInterface, accessPolicyInterface));\r\n\r\n    BusInterfaceInterface* busInterface = createInterfaceForBus(parameterValidator);\r\n\r\n    blockInterface_ = new AddressBlockInterface(blockValidator, expressionParser_, expressionFormatter_,\r\n        busInterface, registerInterface, parameterInterface);\r\n}\r\n\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditorAddrSpacesItem::createInterfaceForBus()\r\n//-----------------------------------------------------------------------------\r\nBusInterfaceInterface* ComponentEditorAddrSpacesItem::createInterfaceForBus(\r\n    QSharedPointer<ParameterValidator> parameterValidator)\r\n{\r\n    QSharedPointer<PortMapValidator> portMapValidator(\r\n        new PortMapValidator(expressionParser_, component_->getPorts(), libHandler_));\r\n    QSharedPointer<BusInterfaceValidator> busValidator(new BusInterfaceValidator(expressionParser_,\r\n        component_->getChoices(), component_->getViews(), component_->getPorts(), component_->getAddressSpaces(),\r\n        component_->getMemoryMaps(), component_->getBusInterfaces(), component_->getFileSets(),\r\n        component_->getRemapStates(), component_->getModes(), portMapValidator, parameterValidator, libHandler_));\r\n\r\n    BusInterfaceInterface* busInterface(\r\n        new BusInterfaceInterface(busValidator, expressionParser_, expressionFormatter_));\r\n\r\n    return busInterface;\r\n}\r\n"
  },
  {
    "path": "editors/ComponentEditor/treeStructure/componenteditoraddrspacesitem.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: componenteditoraddrspacesitem.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 09.05.2012\r\n//\r\n// Description:\r\n// The Address spaces-item in the component editor navigation tree.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef COMPONENTEDITORADDRSPACESITEM_H\r\n#define COMPONENTEDITORADDRSPACESITEM_H\r\n\r\n#include \"componenteditoritem.h\"\r\n\r\n#include <QList>\r\n\r\nclass ExpressionParser;\r\nclass Component;\r\nclass AddressSpace;\r\nclass AddressSpaceValidator;\r\nclass AddressSpacesValidator;\r\nclass AddressBlockInterface;\r\nclass BusInterfaceInterface;\r\nclass ParameterValidator;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! The Address spaces-item in the component editor navigation tree.\r\n//-----------------------------------------------------------------------------\r\nclass ComponentEditorAddrSpacesItem : public ComponentEditorItem\r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\r\n\t/*!\r\n\t *  The constructor.\r\n\t *\r\n\t *    @param [in] model                   The model that owns the items.\r\n\t *    @param [in] libHandler              The instance that manages the library.\r\n\t *    @param [in] component               The component being edited.\r\n     *    @param [in] referenceCounter        The instance for counting references to parameters.\r\n\t *    @param [in] parameterFinder         The parameter finder.\r\n\t *    @param [in] expressionFormatter     The expression formatter.\r\n     *    @param [in] expressionParser        The expression parser to use.\r\n\t *    @param [in] parent                  The parent item.\r\n\t */\r\n\tComponentEditorAddrSpacesItem(ComponentEditorTreeModel* model,\r\n\t\tLibraryInterface* libHandler,\r\n\t\tQSharedPointer<Component> component,\r\n        QSharedPointer<ReferenceCounter> referenceCounter,\r\n        QSharedPointer<ParameterFinder> parameterFinder,\r\n        QSharedPointer<ExpressionFormatter> expressionFormatter,\r\n        QSharedPointer<ExpressionParser> expressionParser,\r\n\t\tComponentEditorItem* parent);\r\n\r\n\t//! The destructor.\r\n\tvirtual ~ComponentEditorAddrSpacesItem();\r\n\r\n\t/*!\r\n     *  Get the font to be used for text of this item.\r\n\t *\r\n\t *    @return QFont instance that defines the font to be used.\r\n\t */\r\n\tvirtual QFont getFont() const;\r\n\r\n\t/*!\r\n     *  Get the tool tip for the item.\r\n\t * \r\n\t *    @return The text for the tool tip to print to user.\r\n\t */\r\n\tvirtual QString getTooltip() const;\r\n\r\n\t/*!\r\n     *  Get the text to be displayed to user in the tree for this item.\r\n\t *\r\n\t *    @return QString Contains the text to display.\r\n\t */\r\n\tvirtual QString text() const;\r\n\r\n\t/*!\r\n     *  Get pointer to the editor of this item.\r\n\t *\r\n\t *    @return The editor to use for this item.\r\n\t */\r\n\tvirtual ItemEditor* editor();\r\n\r\n\t/*!\r\n     *  Add a new child to the item.\r\n\t * \r\n\t *    @param [in] index The index to add the child into.\r\n\t */\r\n\tvirtual void createChild(int index);\r\n\r\n\t/*!\r\n\t *  Check the validity of this item.\r\n\t *\r\n\t *    @return bool True if item is in valid state.\r\n\t */\r\n\tbool isValid() const override;\r\n\r\nprivate slots:\r\n\r\n    /*!\r\n     *  Emitted when address unit bits change on an address space.\r\n     *\r\n     *    @param [in] spaceIndex  Index of the address space being changed.\r\n     */\r\n    void addressUnitBitsChangedInRow(int spaceIndex);\r\n\r\nprivate:\r\n\r\n\t//! No copying.\r\n\tComponentEditorAddrSpacesItem(const ComponentEditorAddrSpacesItem& other);\r\n\tComponentEditorAddrSpacesItem& operator=(const ComponentEditorAddrSpacesItem& other);\r\n\r\n    /*!\r\n     *  Create the necessary validators for address spaces.\r\n     */\r\n    void createAddressSpaceValidator();\r\n\r\n    /*!\r\n     *  Create the interface for address blocks.\r\n     */\r\n    void createAddressBlockInterface();\r\n\r\n    /*!\r\n     *  Create interface for accessing bus interfaces.\r\n     *\r\n     *    @param [in] parameterValidator  Validator for parameters.\r\n     *\r\n     *    @return Interface for accessing bus interfaces.\r\n     */\r\n    BusInterfaceInterface* createInterfaceForBus(QSharedPointer<ParameterValidator> parameterValidator);\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n\t//! The address spaces being edited.\r\n    QSharedPointer<QList<QSharedPointer<AddressSpace> > > addressSpaces_;\r\n\r\n    //! The expression parser to use.\r\n    QSharedPointer<ExpressionParser> expressionParser_;\r\n\r\n    //! The current address space validator.\r\n    QSharedPointer<AddressSpaceValidator> spaceValidator_;\r\n\r\n\t//! The validator validating all address spaces.\r\n\tQSharedPointer<AddressSpacesValidator> addressSpacesValidator_;\r\n\r\n    //! Interface for address blocks.\r\n    AddressBlockInterface* blockInterface_;\r\n};\r\n\r\n#endif // COMPONENTEDITORADDRSPACESITEM_H\r\n"
  },
  {
    "path": "editors/ComponentEditor/treeStructure/componenteditorapiinterfaceitem.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: componenteditorapiinterfaceitem.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 24.05.2012\r\n//\r\n// Description:\r\n// The item for single API-interface in component editor's navigation tree.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"componenteditorapiinterfaceitem.h\"\r\n\r\n#include <KactusAPI/include/LibraryInterface.h>\r\n\r\n#include <editors/ComponentEditor/software/apiInterface/ApiInterfaceEditor.h>\r\n\r\n#include <IPXACTmodels/kactusExtensions/ApiInterface.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditorAPIInterfaceItem::ComponentEditorAPIInterfaceItem()\r\n//-----------------------------------------------------------------------------\r\nComponentEditorAPIInterfaceItem::ComponentEditorAPIInterfaceItem(\r\n    QSharedPointer<ApiInterface> APIInterface,\r\n    ComponentEditorTreeModel* model,\r\n    LibraryInterface* libHandler,\r\n    QSharedPointer<Component> component,\r\n    ComponentEditorItem* parent):\r\nComponentEditorItem(model, libHandler, component, parent),\r\n    apiIf_(APIInterface)\r\n{\r\n    Q_ASSERT(apiIf_);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditorAPIInterfaceItem::~ComponentEditorAPIInterfaceItem()\r\n//-----------------------------------------------------------------------------\r\nComponentEditorAPIInterfaceItem::~ComponentEditorAPIInterfaceItem()\r\n{\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditorAPIInterfaceItem::getTooltip()\r\n//-----------------------------------------------------------------------------\r\nQString ComponentEditorAPIInterfaceItem::getTooltip() const\r\n{\r\n\treturn tr(\"Contains the details of an API interface in the component\");\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditorAPIInterfaceItem::text()\r\n//-----------------------------------------------------------------------------\r\nQString ComponentEditorAPIInterfaceItem::text() const\r\n{\r\n\treturn apiIf_->name();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditorAPIInterfaceItem::isValid()\r\n//-----------------------------------------------------------------------------\r\nbool ComponentEditorAPIInterfaceItem::isValid() const\r\n{\r\n\t// check that the API interface is valid\r\n\tif (!apiIf_->isValid())\r\n    {\r\n\t\treturn false;\r\n\t}\r\n\r\n\t// check that if API definition is specified it must exist\r\n\tif (apiIf_->getApiType().isValid() && !libHandler_->contains(apiIf_->getApiType()))\r\n    {\r\n\t\treturn false;\r\n\t}\r\n\r\n\treturn true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditorAPIInterfaceItem::editor()\r\n//-----------------------------------------------------------------------------\r\nItemEditor* ComponentEditorAPIInterfaceItem::editor()\r\n{\r\n\tif (!editor_)\r\n    {\r\n\t\teditor_ = new ApiInterfaceEditor(libHandler_, component_, apiIf_, NULL);\r\n\t\teditor_->setProtection(locked_);\r\n\r\n\t\tconnect(editor_, SIGNAL(contentChanged()), this, SLOT(onEditorChanged()), Qt::UniqueConnection);\r\n\t\tconnect(editor_, SIGNAL(helpUrlRequested(QString const&)), this, SIGNAL(helpUrlRequested(QString const&)));\r\n\t}\r\n\r\n\treturn editor_;\r\n}\r\n"
  },
  {
    "path": "editors/ComponentEditor/treeStructure/componenteditorapiinterfaceitem.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: componenteditorapiinterfaceitem.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 24.05.2012\r\n//\r\n// Description:\r\n// The item for single API-interface in component editor's navigation tree.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef COMPONENTEDITORAPIINTERFACEITEM_H\r\n#define COMPONENTEDITORAPIINTERFACEITEM_H\r\n\r\n#include \"componenteditoritem.h\"\r\n\r\nclass ApiInterface;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! The item for single API-interface in component editor's navigation tree.\r\n//-----------------------------------------------------------------------------\r\nclass ComponentEditorAPIInterfaceItem : public ComponentEditorItem\r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\r\n\t/*! The constructor\r\n\t *\r\n\t *    @param [in] APIInterface Pointer to the API interface to edit.\r\n\t *    @param [in] model Pointer to the model that owns the items.\r\n\t *    @param [in] libHandler Pointer to the instance that manages the library.\r\n\t *    @param [in] component Pointer to the component being edited.\r\n\t *    @param [in] parent Pointer to the parent item.\r\n\t */\r\n\tComponentEditorAPIInterfaceItem(QSharedPointer<ApiInterface> APIInterface,\r\n\t\tComponentEditorTreeModel* model,\r\n\t\tLibraryInterface* libHandler,\r\n\t\tQSharedPointer<Component> component,\r\n\t\tComponentEditorItem* parent);\r\n\r\n\t//! The destructor\r\n\tvirtual ~ComponentEditorAPIInterfaceItem();\r\n\r\n\t/*! Get the tool tip for the item.\r\n\t * \r\n\t *    @return The text for the tool tip to print to user.\r\n\t*/\r\n\tvirtual QString getTooltip() const;\r\n\r\n\t/*! Get the text to be displayed to user in the tree for this item.\r\n\t *\r\n\t *    @return QString Contains the text to display.\r\n\t*/\r\n\tvirtual QString text() const;\r\n\r\n\t/*! Check the validity of this item and sub items.\r\n\t *\r\n\t *    @return bool True if item is in valid state.\r\n\t*/\r\n\tvirtual bool isValid() const;\r\n\r\n\t/*! Get pointer to the editor of this item.\r\n\t *\r\n\t *    @return Pointer to the editor to use for this item.\r\n\t*/\r\n\tvirtual ItemEditor* editor();\r\n\r\nprivate:\r\n\t\r\n\t//! No copying\r\n\tComponentEditorAPIInterfaceItem(const ComponentEditorAPIInterfaceItem& other);\r\n\r\n\t//! No assignment\r\n\tComponentEditorAPIInterfaceItem& operator=(const ComponentEditorAPIInterfaceItem& other);\r\n\r\n\t//! Pointer to the interface being edited.\r\n\tQSharedPointer<ApiInterface> apiIf_;\r\n};\r\n\r\n#endif // COMPONENTEDITORAPIINTERFACEITEM_H\r\n"
  },
  {
    "path": "editors/ComponentEditor/treeStructure/componenteditorapiinterfacesitem.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: componenteditorapiinterfacesitem.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 24.5.2012\r\n//\r\n// Description:\r\n// The API interfaces-item in the component editor's navigation tree.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"componenteditorapiinterfacesitem.h\"\r\n#include \"componenteditorapiinterfaceitem.h\"\r\n\r\n#include <editors/ComponentEditor/software/apiInterface/apiinterfaceseditor.h>\r\n\r\n#include <IPXACTmodels/Component/Component.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditorAPIInterfacesItem::ComponentEditorAPIInterfacesItem()\r\n//-----------------------------------------------------------------------------\r\nComponentEditorAPIInterfacesItem::ComponentEditorAPIInterfacesItem(\r\n\tComponentEditorTreeModel* model,\r\n\tLibraryInterface* libHandler,\r\n\tQSharedPointer<Component> component,\r\n\tComponentEditorItem* parent):\r\nComponentEditorItem(model, libHandler, component, parent),\r\napiInterfaces_(component->getApiInterfaces())\r\n{\r\n\tforeach (QSharedPointer<ApiInterface> apiInterface, apiInterfaces_)\r\n    {\r\n\t\tQSharedPointer<ComponentEditorAPIInterfaceItem> apiItem(\r\n\t\t\tnew ComponentEditorAPIInterfaceItem(apiInterface, model, libHandler, component, this));\r\n\t\tchildItems_.append(apiItem);\r\n\t}\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditorAPIInterfacesItem::~ComponentEditorAPIInterfacesItem()\r\n//-----------------------------------------------------------------------------\r\nComponentEditorAPIInterfacesItem::~ComponentEditorAPIInterfacesItem()\r\n{\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditorAPIInterfacesItem::getFont()\r\n//-----------------------------------------------------------------------------\r\nQFont ComponentEditorAPIInterfacesItem::getFont() const\r\n{\r\n    QFont font(ComponentEditorItem::getFont());\r\n    font.setBold(!apiInterfaces_.empty());\r\n    return font;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditorAPIInterfacesItem::getTooltip()\r\n//-----------------------------------------------------------------------------\r\nQString ComponentEditorAPIInterfacesItem::getTooltip() const\r\n{\r\n\treturn tr(\"Contains the API interfaces of the component\");\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditorAPIInterfacesItem::text()\r\n//-----------------------------------------------------------------------------\r\nQString ComponentEditorAPIInterfacesItem::text() const\r\n{\r\n\treturn tr(\"API interfaces\");\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditorAPIInterfacesItem::editor()\r\n//-----------------------------------------------------------------------------\r\nItemEditor* ComponentEditorAPIInterfacesItem::editor()\r\n{\r\n\tif (!editor_)\r\n    {\r\n\t\teditor_ = new ApiInterfacesEditor(component_, libHandler_);\r\n\t\teditor_->setProtection(locked_);\r\n\r\n\t\tconnect(editor_, SIGNAL(contentChanged()), this, SLOT(onEditorChanged()), Qt::UniqueConnection);\r\n\t\tconnect(editor_, SIGNAL(childAdded(int)), this, SLOT(onAddChild(int)), Qt::UniqueConnection);\r\n\t\tconnect(editor_, SIGNAL(childRemoved(int)),\tthis, SLOT(onRemoveChild(int)), Qt::UniqueConnection);\r\n\t\tconnect(editor_, SIGNAL(helpUrlRequested(QString const&)), this, SIGNAL(helpUrlRequested(QString const&)));\r\n\t}\r\n\treturn editor_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditorAPIInterfacesItem::createChild()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentEditorAPIInterfacesItem::createChild(int index)\r\n{\r\n\tQSharedPointer<ComponentEditorAPIInterfaceItem> apiItem(\r\n\t\tnew ComponentEditorAPIInterfaceItem(component_->getApiInterfaces().at(index),\r\n        model_, libHandler_, component_, this));\r\n    apiItem->setLocked(locked_);\r\n\r\n\tchildItems_.insert(index, apiItem);\r\n}\r\n"
  },
  {
    "path": "editors/ComponentEditor/treeStructure/componenteditorapiinterfacesitem.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: componenteditorapiinterfacesitem.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 24.5.2012\r\n//\r\n// Description:\r\n// The API interfaces-item in the component editor's navigation tree.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef COMPONENTEDITORAPIINTERFACESITEM_H\r\n#define COMPONENTEDITORAPIINTERFACESITEM_H\r\n\r\n#include \"componenteditoritem.h\"\r\n\r\nclass ApiInterface;\r\n//-----------------------------------------------------------------------------\r\n//! The API interfaces-item in the component editor's navigation tree.\r\n//-----------------------------------------------------------------------------\r\nclass ComponentEditorAPIInterfacesItem : public ComponentEditorItem\r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\r\n\t/*! The constructor\r\n\t *\r\n\t *    @param [in] model       Pointer to the model that owns the items.\r\n\t *    @param [in] libHandler  Pointer to the instance that manages the library.\r\n\t *    @param [in] component   Pointer to the component being edited.\r\n\t *    @param [in] parent      Pointer to the parent item.\r\n\t */\r\n\tComponentEditorAPIInterfacesItem(ComponentEditorTreeModel* model,\r\n\t\tLibraryInterface* libHandler,\r\n\t\tQSharedPointer<Component> component,\r\n\t\tComponentEditorItem* parent);\r\n\r\n\t//! The destructor\r\n\tvirtual ~ComponentEditorAPIInterfacesItem();\r\n\r\n\t/*! Get the font to be used for text of this item.\r\n\t*\r\n\t* The font is bold, if API interfaces exist, otherwise not bold.\r\n\t*\r\n\t*    @return QFont instance that defines the font to be used.\r\n\t*/\r\n\tvirtual QFont getFont() const;\r\n\r\n\t/*! Get the tool tip for the item.\r\n\t * \r\n\t *    @return The text for the tool tip to print to user.\r\n\t */\r\n\tvirtual QString getTooltip() const;\r\n\r\n\t/*! Get the text to be displayed to user in the tree for this item.\r\n\t *\r\n\t *    @return QString Contains the text to display.\r\n\t */\r\n\tvirtual QString text() const;\r\n\r\n\t/*! Get pointer to the editor of this item.\r\n\t *\r\n\t *    @return Pointer to the editor to use for this item.\r\n\t */\r\n\tvirtual ItemEditor* editor();\r\n\r\n\t/*! Add a new child to the item.\r\n\t *\r\n\t *    @param [in] index The index to add the child into.\r\n\t *\r\n\t */\r\n\tvirtual void createChild(int index);\r\n\r\nprivate:\r\n\t//! No copying\r\n\tComponentEditorAPIInterfacesItem(const ComponentEditorAPIInterfacesItem& other);\r\n\r\n\t//! No assignment\r\n\tComponentEditorAPIInterfacesItem& operator=(const ComponentEditorAPIInterfacesItem& other);\r\n\r\n\t//! Contains the api interfaces to edit.\r\n\tQList<QSharedPointer<ApiInterface> > apiInterfaces_;\r\n};\r\n\r\n#endif // COMPONENTEDITORAPIINTERFACESITEM_H\r\n"
  },
  {
    "path": "editors/ComponentEditor/treeStructure/componenteditorbusinterfaceitem.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: componenteditorbusinterfaceitem.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 14.05.2012\r\n//\r\n// Description:\r\n// The item for single bus interface in the component editor's navigation tree.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"componenteditorbusinterfaceitem.h\"\r\n\r\n#include <KactusAPI/include/LibraryInterface.h>\r\n\r\n#include <editors/ComponentEditor/busInterfaces/businterfaceeditor.h>\r\n#include <KactusAPI/include/ExpressionParser.h>\r\n\r\n#include <IPXACTmodels/Component/BusInterface.h>\r\n#include <IPXACTmodels/Component/Component.h>\r\n#include <IPXACTmodels/Component/PortMap.h>\r\n#include <IPXACTmodels/Component/validators/BusInterfaceValidator.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditorBusInterfaceItem::ComponentEditorBusInterfaceItem()\r\n//-----------------------------------------------------------------------------\r\nComponentEditorBusInterfaceItem::ComponentEditorBusInterfaceItem(QSharedPointer<BusInterface> busif,\r\n    ComponentEditorTreeModel* model, LibraryInterface* libHandler, QSharedPointer<Component> component,\r\n    QSharedPointer<ReferenceCounter> referenceCounter, ExpressionSet expressions,\r\n    QSharedPointer<BusInterfaceValidator> validator, BusInterfaceInterface* busInterface,\r\n    PortMapInterface* portMapInterface, ComponentEditorItem* parent, QWidget* parentWnd) :\r\n    ParameterizableItem(model, libHandler, component, parent),\r\n    busIf_(busif),\r\n    parentWnd_(parentWnd),\r\n    editBusDefAction_(new QAction(tr(\"\"), this)),\r\n    expressions_(expressions),\r\n    validator_(validator),\r\n    busInterface_(busInterface),\r\n    portMapInterface_(portMapInterface)\r\n{\r\n    setParameterFinder(expressions.finder);\r\n    setExpressionFormatter(expressions.formatter);\r\n    setReferenceCounter(referenceCounter);\r\n\r\n    connect(editBusDefAction_, SIGNAL(triggered(bool)), this, SLOT(openBusSlot()), Qt::UniqueConnection);\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditorBusInterfaceItem::~ComponentEditorBusInterfaceItem()\r\n//-----------------------------------------------------------------------------\r\nComponentEditorBusInterfaceItem::~ComponentEditorBusInterfaceItem()\r\n{\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditorBusInterfaceItem::text()\r\n//-----------------------------------------------------------------------------\r\nQString ComponentEditorBusInterfaceItem::text() const\r\n{\r\n    return busIf_->name();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditorBusInterfaceItem::isValid()\r\n//-----------------------------------------------------------------------------\r\nbool ComponentEditorBusInterfaceItem::isValid() const\r\n{\r\n    if (!validator_->validate(busIf_, component_->getRevision()))\r\n    {\r\n        return false;\r\n    }\r\n\r\n    return true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditorBusInterfaceItem::editor()\r\n//-----------------------------------------------------------------------------\r\nItemEditor* ComponentEditorBusInterfaceItem::editor()\r\n{\r\n    if (!editor_)\r\n    {\r\n        editor_ = new BusInterfaceEditor(libHandler_, component_, busIf_, expressions_,\r\n            busInterface_, portMapInterface_, 0, parentWnd_);\r\n        editor_->setProtection(locked_);\r\n        connect(editor_, SIGNAL(contentChanged()), this, SLOT(onEditorChanged()), Qt::UniqueConnection);\r\n        connect(editor_, SIGNAL(errorMessage(const QString&)),\r\n            this, SIGNAL(errorMessage(const QString&)), Qt::UniqueConnection);\r\n        connect(editor_, SIGNAL(helpUrlRequested(QString const&)), this, SIGNAL(helpUrlRequested(QString const&)));\r\n\r\n        connectItemEditorToReferenceCounter();\r\n\r\n        connectReferenceTree();\r\n    }\r\n    return editor_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditorBusInterfaceItem::getTooltip()\r\n//-----------------------------------------------------------------------------\r\nQString ComponentEditorBusInterfaceItem::getTooltip() const\r\n{\r\n    return tr(\"Defines properties of a specific interface in a component\");\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditorBusInterfaceItem::actions()\r\n//-----------------------------------------------------------------------------\r\nQList<QAction*> ComponentEditorBusInterfaceItem::actions()\r\n{\r\n    QList<QAction*> actionList;\r\n    if (validator_->hasValidBusType(busIf_))\r\n    {\r\n        editBusDefAction_->setText(\"Edit \"+busIf_->getBusType().toString());\r\n        actionList.append(editBusDefAction_);\r\n    }\r\n\r\n    setAbstractionDefinitionActions(actionList);\r\n\r\n    return actionList;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditorBusInterfaceItem::openAbsDefSlot()\r\n//-----------------------------------------------------------------------------\r\nbool ComponentEditorBusInterfaceItem::openAbsDefSlot()\r\n{\r\n    // Checking if the function was called by action (from the drop down menu on right \r\n    // click on bus interface under Bus interface in Component editor tree).\r\n    QAction* action = qobject_cast<QAction*>(QObject::sender());\r\n    if (action && action->data().value<VLNV*>())\r\n    {\r\n        emit openAbsDef(*(action->data().value<VLNV*>()));\r\n        return true;\r\n    }\r\n\r\n    return false;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditorBusInterfaceItem::openBusDef()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentEditorBusInterfaceItem::openBusSlot()\r\n{\r\n    if (validator_->hasValidBusType(busIf_))\r\n    {\r\n        VLNV busdefVLNV = busIf_->getBusType();\r\n        emit openBus(busdefVLNV);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditorBusInterfaceItem::setAbstractionDefinitionActions()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentEditorBusInterfaceItem::setAbstractionDefinitionActions(QList<QAction*>& actionList)\r\n{\r\n    QSharedPointer<QList<QSharedPointer<AbstractionType>>> absDefs = busIf_->getAbstractionTypes();\r\n    if (absDefs)\r\n    {\r\n        for (const QSharedPointer<AbstractionType> absDef : *absDefs)\r\n        {\r\n            QSharedPointer<ConfigurableVLNVReference> abstractionRef = absDef->getAbstractionRef();\r\n            VLNV* absDefVLNV = dynamic_cast<VLNV*>(abstractionRef.data());\r\n            if (absDefVLNV && absDefVLNV->isValid())\r\n            {\r\n                QString actionName = \"Edit \" + absDefVLNV->toString();\r\n\r\n                QAction* openAbsDefAction = new QAction(actionName, this);\r\n                //editAbsDef->absRefVLNV = absDefVLNV;\r\n                QVariant v = QVariant::fromValue(absDefVLNV);\r\n                openAbsDefAction->setData(v);\r\n                actionList.append(openAbsDefAction);\r\n\r\n                connect(openAbsDefAction, SIGNAL(triggered(bool)), this, SLOT(openAbsDefSlot()), Qt::UniqueConnection);\r\n            }           \r\n        }\r\n    }\r\n}\r\n"
  },
  {
    "path": "editors/ComponentEditor/treeStructure/componenteditorbusinterfaceitem.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: componenteditorbusinterfaceitem.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 14.05.2012\r\n//\r\n// Description:\r\n// The item for single bus interface in the component editor's navigation tree.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef COMPONENTEDITORBUSINTERFACEITEM_H\r\n#define COMPONENTEDITORBUSINTERFACEITEM_H\r\n\r\n#include <editors/common/ExpressionSet.h>\r\n#include <editors/ComponentEditor/treeStructure/ParameterizableItem.h>\r\n\r\n#include <QSharedPointer>\r\n\r\n#include <IPXACTmodels/Component/BusInterface.h>\r\n\r\n\r\nclass BusInterface;\r\nclass BusInterfaceValidator;\r\nclass ExpressionParser;\r\nclass PortMapInterface;\r\nclass BusInterfaceInterface;\r\nclass PortMapInterface;\r\n\r\n\r\n\r\n//-----------------------------------------------------------------------------\r\n//! The item for single bus interface in the component editor's navigation tree.\r\n//-----------------------------------------------------------------------------\r\nclass ComponentEditorBusInterfaceItem : public ParameterizableItem\r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\r\n\t/*!\r\n\t *  The constructor.\r\n\t *\r\n\t *    @param [in] busif                   The bus interface being edited.\r\n\t *    @param [in] model                   The model that owns the items.\r\n\t *    @param [in] libHandler              The instance that manages the library.\r\n\t *    @param [in] component               The component being edited.\r\n\t *    @param [in] referenceCounter        The reference counter.\r\n\t *    @param [in] parameterFinder         The parameter finder.\r\n\t *    @param [in] expressionFormatter     The expression formatter.\r\n\t *    @param [in] expressionParser        The expression parser.\r\n\t *    @param [in] validator               The validator for bus interfaces.\r\n\t *    @param [in] busInterface            Interface for accessing bus interfaces.\r\n\t *    @param [in] portMapInterface        Interface for accessing port maps.\r\n\t *    @param [in] parent                  The owner of this item.\r\n\t *    @param [in] parentWnd               The parent window.\r\n\t */\r\n\tComponentEditorBusInterfaceItem(QSharedPointer<BusInterface> busif,\r\n\t\tComponentEditorTreeModel* model,\r\n\t\tLibraryInterface* libHandler,\r\n\t\tQSharedPointer<Component> component,\r\n\t\tQSharedPointer<ReferenceCounter> referenceCounter,\r\n\t\tExpressionSet expressions,\r\n\t\tQSharedPointer<BusInterfaceValidator> validator,\r\n\t\tBusInterfaceInterface* busInterface,\r\n\t\tPortMapInterface* portMapInterface,\r\n\t\tComponentEditorItem* parent,\r\n\t\tQWidget* parentWnd);\r\n\r\n\t//! The destructor\r\n\tvirtual ~ComponentEditorBusInterfaceItem();\r\n\r\n\t/*! Get the tool tip for the item.\r\n\t *\r\n\t *    @return The text for the tool tip to print to user.\r\n\t*/\r\n\tvirtual QString getTooltip() const;\r\n\r\n\t/*! Get the text to be displayed to user in the tree for this item.\r\n\t *\r\n\t *    @return QString Contains the text to display.\r\n\t*/\r\n\tvirtual QString text() const;\r\n\r\n\t/*! Check the validity of this item and sub items.\r\n\t *\r\n\t *    @return bool True if item is in valid state.\r\n\t*/\r\n\tvirtual bool isValid() const;\r\n\r\n\t/*! Get The editor of this item.\r\n\t *\r\n\t *    @return The editor to use for this item.\r\n\t*/\r\n\tvirtual ItemEditor* editor();\r\n\r\n\t/*!\r\n\t *  Returns the possible actions for opening the item.\r\n\t *\r\n\t *    @return The actions to open the item.\r\n\t */\r\n\tvirtual QList<QAction*> actions();\r\n\r\npublic slots:\r\n\r\n\t/*! Opens the abstraction definition; can be called from the drop down menu\r\n\t * and from openItem(), where it can open either the only abstraction deffinition in editor,\r\n\t * or open the dialog with a combo box of bus definition and the list of all abstraction definitions.\r\n\t * \r\n\t * @return bool True if there are no need to open Bus Deffinition, overwise bool False\r\n\t */\r\n\tvirtual bool openAbsDefSlot();\r\n\r\n\t/*! \r\n\t *  Opens and the Bus Definition by emmitting the signal openBus.\t\r\n\t */\r\n\tvirtual void openBusSlot();\r\n\r\n\r\nprivate:\r\n\t//! No copying\r\n\tComponentEditorBusInterfaceItem(const ComponentEditorBusInterfaceItem& other);\r\n\r\n\t//! No assignment\r\n\tComponentEditorBusInterfaceItem& operator=(const ComponentEditorBusInterfaceItem& other);\r\n\r\n\t/*! \r\n\t *  Sets the actions to Abstract Definitions in context menu.\r\n\t * \r\n\t *\t\t@param [in] actionList               The list of actions to be filled\r\n\t */\r\n\tvoid setAbstractionDefinitionActions(QList<QAction*>& actionList);\r\n\r\n\t//! The bus interface being edited.\r\n\tQSharedPointer<BusInterface> busIf_;\r\n\r\n\t//! The parent window.\r\n\tQWidget* parentWnd_;\r\n\r\n\t//! Action to open the bus interface for editing.\r\n\tQAction* editBusDefAction_;\r\n\r\n\t//! Expression handling tools.\r\n\tExpressionSet expressions_;\r\n\r\n\t//! Validator for bus interfaces.\r\n\tQSharedPointer<BusInterfaceValidator> validator_;\r\n\r\n\t//! Interface for accessing bus interfaces.\r\n\tBusInterfaceInterface* busInterface_;\r\n\r\n\t//! Interface for accessing port maps.\r\n\tPortMapInterface* portMapInterface_;\r\n};\r\n\r\n#endif // COMPONENTEDITORBUSINTERFACEITEM_H\r\n"
  },
  {
    "path": "editors/ComponentEditor/treeStructure/componenteditorbusinterfacesitem.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: componenteditorbusinterfacesitem.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 09.05.2012\r\n//\r\n// Description:\r\n// The Bus interfaces-item in the component editor's navigation tree.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"componenteditorbusinterfacesitem.h\"\r\n#include \"componenteditorbusinterfaceitem.h\"\r\n\r\n#include <editors/ComponentEditor/busInterfaces/businterfaceseditor.h>\r\n\r\n#include <KactusAPI/include/PortAbstractionInterface.h>\r\n#include <KactusAPI/include/PortsInterface.h>\r\n#include <KactusAPI/include/PortMapInterface.h>\r\n\r\n#include <IPXACTmodels/Component/Component.h>\r\n#include <IPXACTmodels/Component/validators/CollectionValidators.h>\r\n#include <IPXACTmodels/Component/validators/BusInterfaceValidator.h>\r\n#include <IPXACTmodels/Component/validators/AbstractionTypeValidator.h>\r\n#include <IPXACTmodels/Component/validators/PortMapValidator.h>\r\n#include <IPXACTmodels/Component/validators/PortValidator.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: componenteditorbusinterfacesitem::ComponentEditorBusInterfacesItem()\r\n//-----------------------------------------------------------------------------\r\nComponentEditorBusInterfacesItem::ComponentEditorBusInterfacesItem(BusInterfaceInterface* busInterface,\r\n    PortMapInterface* portMapInterface, ComponentEditorTreeModel* model, LibraryInterface* libHandler,\r\n    QSharedPointer<Component> component, QSharedPointer<ReferenceCounter> referenceCounter,\r\n    ExpressionSet expressions, ComponentEditorItem* parent, QWidget* parentWnd):\r\nComponentEditorItem(model, libHandler, component, parent),\r\nbusifs_(component->getBusInterfaces()),\r\nparentWnd_(parentWnd),\r\nexpressions_(expressions),\r\nbusInterface_(busInterface),\r\nportMapInterface_(portMapInterface)\r\n{\r\n    createBusInterfaceValidator();\r\n\r\n    setParameterFinder(expressions.finder);\r\n    setExpressionFormatter(expressions.formatter);\r\n    setReferenceCounter(referenceCounter);\r\n\r\n\tfor (QSharedPointer<BusInterface> busif : *busifs_)\r\n    {\r\n\t\tQSharedPointer<ComponentEditorBusInterfaceItem> busifItem(new ComponentEditorBusInterfaceItem(\r\n            busif, model, libHandler, component, referenceCounter_, expressions,\r\n            busInterfaceValidator_, busInterface_, portMapInterface_, this, parentWnd));\r\n\r\n        connect(busifItem.data(), SIGNAL(openReferenceTree(QString const&, QString const&)),\r\n            this, SIGNAL(openReferenceTree(QString const&, QString const&)), Qt::UniqueConnection);\r\n\r\n\t\tchildItems_.append(busifItem);\r\n\t}\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: componenteditorbusinterfacesitem::createBusInterfaceValidator()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentEditorBusInterfacesItem::createBusInterfaceValidator()\r\n{\r\n    QSharedPointer<PortMapValidator> portMapValidator(\r\n        new PortMapValidator(expressions_.parser, component_->getPorts(), libHandler_));\r\n\r\n    QSharedPointer<ParameterValidator> parameterValidator(\r\n        new ParameterValidator(expressions_.parser, component_->getChoices(), component_->getRevision()));\r\n\r\n    busInterfaceValidator_ = QSharedPointer<BusInterfaceValidator>(new BusInterfaceValidator(expressions_.parser,\r\n        component_->getChoices(), component_->getViews(), component_->getPorts(), component_->getAddressSpaces(),\r\n        component_->getMemoryMaps(), component_->getBusInterfaces(), component_->getFileSets(),\r\n        component_->getRemapStates(), component_->getModes(), portMapValidator, parameterValidator, libHandler_));\r\n    \r\n    busInterfacesValidator_ = QSharedPointer<BusInterfacesValidator>(new BusInterfacesValidator(busInterfaceValidator_));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: componenteditorbusinterfacesitem::getFont()\r\n//-----------------------------------------------------------------------------\r\nQFont ComponentEditorBusInterfacesItem::getFont() const\r\n{\r\n    QFont font(ComponentEditorItem::getFont());\r\n    font.setBold(component_->hasInterfaces());\r\n    return font;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: componenteditorbusinterfacesitem::text()\r\n//-----------------------------------------------------------------------------\r\nQString ComponentEditorBusInterfacesItem::text() const\r\n{\r\n\treturn tr(\"Bus interfaces\");\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: componenteditorbusinterfacesitem::editor()\r\n//-----------------------------------------------------------------------------\r\nItemEditor* ComponentEditorBusInterfacesItem::editor()\r\n{\r\n\tif (!editor_)\r\n    {\r\n\t\teditor_ = new BusInterfacesEditor(libHandler_, component_, busInterface_, parameterFinder_);\r\n\t\teditor_->setProtection(locked_);\r\n\t\tconnect(editor_, SIGNAL(contentChanged()), this, SLOT(onEditorChanged()), Qt::UniqueConnection);\r\n\t\tconnect(editor_, SIGNAL(childAdded(int)), this, SLOT(onAddChild(int)), Qt::UniqueConnection);\r\n\t\tconnect(editor_, SIGNAL(childRemoved(int)), this, SLOT(onRemoveChild(int)), Qt::UniqueConnection);\r\n        connect(editor_, SIGNAL(childMoved(int, int)), this, SLOT(onMoveChild(int, int)), Qt::UniqueConnection);\r\n\t\tconnect(editor_, SIGNAL(helpUrlRequested(QString const&)), this, SIGNAL(helpUrlRequested(QString const&)));\r\n\r\n        connectItemEditorToReferenceCounter();\r\n\t}\r\n\treturn editor_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: componenteditorbusinterfacesitem::getTooltip()\r\n//-----------------------------------------------------------------------------\r\nQString ComponentEditorBusInterfacesItem::getTooltip() const\r\n{\r\n\treturn tr(\"Contains the bus interfaces specified for a component\");\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: componenteditorbusinterfacesitem::createChild()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentEditorBusInterfacesItem::createChild(int index)\r\n{\r\n\tQSharedPointer<ComponentEditorBusInterfaceItem> busifItem(new ComponentEditorBusInterfaceItem(\r\n        busifs_->at(index), model_, libHandler_, component_, referenceCounter_, expressions_,\r\n        busInterfaceValidator_, busInterface_, portMapInterface_, this, parentWnd_));\r\n\tbusifItem->setLocked(locked_);\r\n\r\n    connect(busifItem.data(), SIGNAL(openReferenceTree(QString const&, QString const&)),\r\n        this, SIGNAL(openReferenceTree(QString const&, QString const&)), Qt::UniqueConnection);\r\n\r\n\tchildItems_.insert(index, busifItem);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: componenteditorbusinterfacesitem::createChild()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<ComponentEditorItem> ComponentEditorBusInterfacesItem::getBusInterfaceItem(\r\n    QString const& interfaceName) const\r\n{\r\n\tfor (auto const& child : childItems_)\r\n    {\t\t\r\n\t\t// if the bus interface name matches the searched interface name\r\n\t\tif (child->text() == interfaceName)\r\n        {\r\n\t\t\treturn child;\r\n\t\t}\r\n\t}\r\n\r\n\t// if child was not found\r\n\treturn QSharedPointer<ComponentEditorItem>();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditorBusInterfacesItem::isValid()\r\n//-----------------------------------------------------------------------------\r\nbool ComponentEditorBusInterfacesItem::isValid() const\r\n{\r\n    auto interfacesAsNameGroup = CollectionValidators::itemListToNameGroupList(busifs_);\r\n    busInterfacesValidator_->childrenHaveUniqueNames(interfacesAsNameGroup);\r\n    return ComponentEditorItem::isValid();\r\n}\r\n"
  },
  {
    "path": "editors/ComponentEditor/treeStructure/componenteditorbusinterfacesitem.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: componenteditorbusinterfacesitem.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 09.05.2012\r\n//\r\n// Description:\r\n// The Bus interfaces-item in the component editor's navigation tree.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef COMPONENTEDITORBUSINTERFACESITEM_H\r\n#define COMPONENTEDITORBUSINTERFACESITEM_H\r\n\r\n#include \"componenteditoritem.h\"\r\n\r\n#include <editors/common/ExpressionSet.h>\r\n\r\nclass BusInterface;\r\nclass BusInterfaceValidator;\r\nclass BusInterfacesValidator;\r\nclass ExpressionParser;\r\nclass PortMapInterface;\r\nclass BusInterfaceInterface;\r\nclass PortMapInterface;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! The Bus interfaces-item in the component editor's navigation tree.\r\n//-----------------------------------------------------------------------------\r\nclass ComponentEditorBusInterfacesItem : public ComponentEditorItem\r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\r\n    /*!\r\n\t *  The constructor.\r\n\t *\r\n     *    @param [in] busInterface            Interface for accessing bus interfaces.\r\n     *    @param [in] portMapInterface        Interface for accessing port maps.\r\n     *    @param [in] model                   The model that owns the items.\r\n\t *    @param [in] libHandler              The instance that manages the library.\r\n\t *    @param [in] component               The component being edited.\r\n\t *    @param [in] referenceCounter        The reference counter.\r\n\t *    @param [in] parameterFinder         The parameter finder.\r\n\t *    @param [in] expressionFormatter     The expression formatter.\r\n\t *    @param [in] expressionParser        The expression parser.\r\n\t *    @param [in] parent                  The owner of this item.\r\n\t *    @param [in] parentWnd               The parent window.\r\n\t */\r\n\tComponentEditorBusInterfacesItem(\r\n        BusInterfaceInterface* busInterface,\r\n        PortMapInterface* portMapInterface,\r\n        ComponentEditorTreeModel* model,\r\n        LibraryInterface* libHandler,\r\n\t\tQSharedPointer<Component> component,\r\n        QSharedPointer<ReferenceCounter> referenceCounter,\r\n\t\tExpressionSet expressions,\r\n        ComponentEditorItem* parent,\r\n        QWidget* parentWnd);\r\n\r\n\t/*!\r\n     *  The destructor\r\n     */\r\n\tvirtual ~ComponentEditorBusInterfacesItem() = default;\r\n\r\n\t/*! Get the font to be used for text of this item.\r\n\t*\r\n\t* The font is bold, if bus interfaces exist, otherwise not bold.\r\n\t*\r\n\t*    @return QFont instance that defines the font to be used.\r\n\t*/\r\n\tvirtual QFont getFont() const;\r\n\r\n\t/*! Get the tool tip for the item.\r\n\t * \r\n\t *    @return The text for the tool tip to print to user.\r\n\t*/\r\n\tvirtual QString getTooltip() const;\r\n\r\n\t/*! Get the text to be displayed to user in the tree for this item.\r\n\t *\r\n\t *    @return The text to display.\r\n\t*/\r\n\tvirtual QString text() const;\r\n\r\n\t/*! Get The editor of this item.\r\n\t *\r\n\t *    @return The editor to use for this item.\r\n\t*/\r\n\tvirtual ItemEditor* editor();\r\n\r\n\t/*! Add a new child to the item.\r\n\t *\r\n\t *    @param [in] index The index to add the child into.\r\n\t*/\r\n\tvirtual void createChild(int index);\r\n\r\n\t/*! Get the tree item that holds the editor for given bus interface.\r\n\t *\r\n\t *    @param [in] interfaceName The name of the bus interface to get the item for.\r\n\t *\r\n\t *    @return The tree item.\r\n\t*/\r\n\tQSharedPointer<ComponentEditorItem> getBusInterfaceItem(const QString& interfaceName) const;\r\n\r\n\t/*!\r\n\t *  Check the validity of this item.\r\n\t *\r\n\t *    @return bool True if item is in valid state.\r\n\t */\r\n\tbool isValid() const override;\r\n\r\nsignals:\r\n\tvoid openAbsDef(VLNV const& absDefVLNV);\r\n\r\nprivate:\r\n\t//! No copying\r\n\tComponentEditorBusInterfacesItem(const ComponentEditorBusInterfacesItem& other);\r\n\r\n\t//! No assignment\r\n\tComponentEditorBusInterfacesItem& operator=(const ComponentEditorBusInterfacesItem& other);\r\n\r\n    /*!\r\n     *  Create the validator for bus interfaces.\r\n     */\r\n    void createBusInterfaceValidator();\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n\t//! Contains the bus interfaces to edit.\r\n\tQSharedPointer<QList<QSharedPointer<BusInterface> > > busifs_;\r\n\r\n    //! The parent window.\r\n    QWidget* parentWnd_;\r\n\r\n\t//! Expression handling tools.\r\n\tExpressionSet expressions_;\r\n\r\n    //! Validator for bus interfaces.\r\n    QSharedPointer<BusInterfaceValidator> busInterfaceValidator_;\r\n\r\n\t//! Validator for bus interfaces together.\r\n    QSharedPointer<BusInterfacesValidator> busInterfacesValidator_;\r\n\r\n    //! Interface for accessing bus interfaces.\r\n    BusInterfaceInterface* busInterface_;\r\n\r\n    //! Interface for accessing port maps.\r\n    PortMapInterface* portMapInterface_;\r\n};\r\n\r\n#endif // COMPONENTEDITORBUSINTERFACESITEM_H\r\n"
  },
  {
    "path": "editors/ComponentEditor/treeStructure/componenteditorchannelsitem.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: componenteditorchannelsitem.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 09.05.2012\r\n//\r\n// Description:\r\n// The channels-item in the component editor's navigation tree.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"componenteditorchannelsitem.h\"\r\n\r\n#include <editors/ComponentEditor/channels/channelseditor.h>\r\n\r\n#include <IPXACTmodels/Component/Component.h>\r\n\r\n#include <IPXACTmodels/Component/validators/ChannelValidator.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditorChannelsItem::ComponentEditorChannelsItem()\r\n//-----------------------------------------------------------------------------\r\nComponentEditorChannelsItem::ComponentEditorChannelsItem(ComponentEditorTreeModel* model,\r\n    LibraryInterface* libHandler,\r\n    QSharedPointer<Component> component,\r\n    QSharedPointer<ExpressionParser> expressionParser,\r\n    ComponentEditorItem* parent):\r\nComponentEditorItem(model, libHandler, component, parent),\r\n    channels_(component->getChannels()),\r\n    validator_(new ChannelValidator(expressionParser, component->getBusInterfaces()))\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditorChannelsItem::~ComponentEditorChannelsItem()\r\n//-----------------------------------------------------------------------------\r\nComponentEditorChannelsItem::~ComponentEditorChannelsItem()\r\n{\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditorChannelsItem::getFont()\r\n//-----------------------------------------------------------------------------\r\nQFont ComponentEditorChannelsItem::getFont() const\r\n{\r\n    QFont font(ComponentEditorItem::getFont());\r\n    font.setBold(!channels_->isEmpty());\r\n    return font;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditorChannelsItem::text()\r\n//-----------------------------------------------------------------------------\r\nQString ComponentEditorChannelsItem::text() const\r\n{\r\n\treturn tr(\"Channels\");\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditorChannelsItem::editor()\r\n//-----------------------------------------------------------------------------\r\nItemEditor* ComponentEditorChannelsItem::editor()\r\n{\r\n\tif (!editor_)\r\n    {\r\n\t\teditor_ = new ChannelsEditor(component_, libHandler_, validator_);\r\n\t\teditor_->setProtection(locked_);\r\n\t\tconnect(editor_, SIGNAL(contentChanged()), this, SLOT(onEditorChanged()), Qt::UniqueConnection);\r\n\t\tconnect(editor_, SIGNAL(helpUrlRequested(QString const&)), this, SIGNAL(helpUrlRequested(QString const&)));\r\n\t}\r\n\r\n\treturn editor_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditorChannelsItem::getTooltip()\r\n//-----------------------------------------------------------------------------\r\nQString ComponentEditorChannelsItem::getTooltip() const\r\n{\r\n\treturn tr(\"Contains the channels specified for the component\");\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditorChannelsItem::isValid()\r\n//-----------------------------------------------------------------------------\r\nbool ComponentEditorChannelsItem::isValid() const \r\n{\r\n    if (!channels_->isEmpty())\r\n    {\r\n        QVector<QString> channelNames;\r\n        QVector<QString> interfaceNames;\r\n        for (QSharedPointer<Channel> channel : *channels_)\r\n        {\r\n            if (channelNames.contains(channel->name()) || !validator_->validate(channel))\r\n            {\r\n                return false;\r\n            }\r\n            else\r\n            {\r\n                channelNames.append(channel->name());\r\n                for (QString const& busInterface : channel->getInterfaceNames())\r\n                {\r\n                    if (interfaceNames.contains(busInterface))\r\n                    {\r\n                        return false;\r\n                    }\r\n\r\n                    interfaceNames.append(busInterface);\r\n                }\r\n            }\r\n        }\r\n    }\r\n\r\n    return true;\r\n}\r\n"
  },
  {
    "path": "editors/ComponentEditor/treeStructure/componenteditorchannelsitem.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: componenteditorchannelsitem.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 09.05.2012\r\n//\r\n// Description:\r\n// The channels-item in the component editor's navigation tree.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef COMPONENTEDITORCHANNELSITEM_H\r\n#define COMPONENTEDITORCHANNELSITEM_H\r\n\r\n#include \"componenteditoritem.h\"\r\n\r\nclass Channel;\r\nclass ChannelValidator;\r\nclass ExpressionParser;\r\n//-----------------------------------------------------------------------------\r\n//! The channels-item in the component editor's navigation tree.\r\n//-----------------------------------------------------------------------------\r\nclass ComponentEditorChannelsItem : public ComponentEditorItem\r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\r\n\t/*! The constructor\r\n\t *\r\n\t *    @param [in] model               The model that owns the items.\r\n\t *    @param [in] libHandler          The instance that manages the library.\r\n\t *    @param [in] component           The component being edited.\r\n     *    @param [in] expressionParser    The expression parser to use.\r\n\t *    @param [in] parent              The parent item.\r\n\t*/\r\n\tComponentEditorChannelsItem(ComponentEditorTreeModel* model, \r\n        LibraryInterface* libHandler,\r\n\t\tQSharedPointer<Component> component,\r\n        QSharedPointer<ExpressionParser> expressionParser,\r\n        ComponentEditorItem* parent);\r\n\r\n\t//! The destructor\r\n\tvirtual ~ComponentEditorChannelsItem();\r\n\r\n\t/*! Get the font to be used for text of this item.\r\n\t*\r\n\t* The font is bold, if channels exist, otherwise not bold.\r\n\t*\r\n\t*    @return QFont instance that defines the font to be used.\r\n\t*/\r\n\tvirtual QFont getFont() const;\r\n\r\n\t/*! Get the tool tip for the item.\r\n\t * \r\n\t *    @return The text for the tool tip to print to user.\r\n\t*/\r\n\tvirtual QString getTooltip() const;\r\n\r\n\t/*! Get the text to be displayed to user in the tree for this item.\r\n\t *\r\n\t *    @return QString Contains the text to display.\r\n\t*/\r\n\tvirtual QString text() const;\r\n\r\n\t/*! Get The editor of this item.\r\n\t *\r\n\t *    @return The editor to use for this item.\r\n\t*/\r\n\tvirtual ItemEditor* editor();\r\n\r\n\t/*! Check the validity of this item.\r\n\t *\r\n\t *    @return bool True if item is in valid state.\r\n\t*/\r\n\tvirtual bool isValid() const;\r\n\r\nprivate:\r\n\t//! No copying\r\n\tComponentEditorChannelsItem(const ComponentEditorChannelsItem& other);\r\n\tComponentEditorChannelsItem& operator=(const ComponentEditorChannelsItem& other);\r\n\r\n\t//! The channels being edited.\r\n\tQSharedPointer<QList<QSharedPointer<Channel> > > channels_;\r\n\r\n    //! Validator for channels.\r\n    QSharedPointer<ChannelValidator> validator_;\r\n};\r\n\r\n#endif // COMPONENTEDITORCHANNELSITEM_H\r\n"
  },
  {
    "path": "editors/ComponentEditor/treeStructure/componenteditorcominterfaceitem.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: componenteditorcominterfaceitem.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 16.5.2012\r\n//\r\n// Description:\r\n// The item for a single COM interface in component editor's navigation tree.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"componenteditorcominterfaceitem.h\"\r\n\r\n#include <KactusAPI/include/LibraryInterface.h>\r\n\r\n#include <editors/ComponentEditor/software/comInterface/ComInterfaceEditor.h>\r\n\r\n#include <IPXACTmodels/kactusExtensions/ComInterface.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditorComInterfaceItem::ComponentEditorComInterfaceItem()\r\n//-----------------------------------------------------------------------------\r\nComponentEditorComInterfaceItem::ComponentEditorComInterfaceItem(QSharedPointer<ComInterface> comInterface,\r\n    ComponentEditorTreeModel* model, LibraryInterface* libHandler,\r\n    QSharedPointer<Component> component, ComponentEditorItem* parent):\r\nComponentEditorItem(model, libHandler, component, parent),\r\n    interface_(comInterface),\r\n    editAction_(new QAction(tr(\"Edit\"), this))\r\n{\r\n    connect(editAction_, SIGNAL(triggered(bool)), this, SLOT(openItem()), Qt::UniqueConnection);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditorComInterfaceItem::~ComponentEditorComInterfaceItem()\r\n//-----------------------------------------------------------------------------\r\nComponentEditorComInterfaceItem::~ComponentEditorComInterfaceItem()\r\n{\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditorComInterfaceItem::text()\r\n//-----------------------------------------------------------------------------\r\nQString ComponentEditorComInterfaceItem::text() const\r\n{\r\n\treturn interface_->name();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditorComInterfaceItem::isValid()\r\n//-----------------------------------------------------------------------------\r\nbool ComponentEditorComInterfaceItem::isValid() const\r\n{\r\n\t// check that the COM interface is valid\r\n\tif (!interface_->isValid()) \r\n    {\r\n\t\treturn false;\r\n\t}\r\n\r\n\t// check that if there is a COM definition it is found\r\n\telse if (interface_->getComType().isValid())\r\n    {\r\n\t\tif (!libHandler_->contains(interface_->getComType()))\r\n        {\r\n\t\t\treturn false;\r\n\t\t}\r\n\t}\r\n\r\n\treturn true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditorComInterfaceItem::editor()\r\n//-----------------------------------------------------------------------------\r\nItemEditor* ComponentEditorComInterfaceItem::editor()\r\n{\r\n\tif (!editor_)\r\n    {\r\n\t\teditor_ = new ComInterfaceEditor(libHandler_, component_, interface_);\r\n\t\teditor_->setProtection(locked_);\r\n\t\tconnect(editor_, SIGNAL(contentChanged()), this, SLOT(onEditorChanged()), Qt::UniqueConnection);\r\n\t\tconnect(editor_, SIGNAL(helpUrlRequested(QString const&)), this, SIGNAL(helpUrlRequested(QString const&)));\r\n\t}\r\n\treturn editor_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditorComInterfaceItem::getTooltip()\r\n//-----------------------------------------------------------------------------\r\nQString ComponentEditorComInterfaceItem::getTooltip() const\r\n{\r\n\treturn tr(\"Specifies a virtual communication interface for the component\");\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditorComInterfaceItem::canBeOpened()\r\n//-----------------------------------------------------------------------------\r\nbool ComponentEditorComInterfaceItem::canBeOpened() const\r\n{\r\n    return interface_->getComType().isValid() && libHandler_->contains(interface_->getComType());\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditorComInterfaceItem::actions()\r\n//-----------------------------------------------------------------------------\r\nQList<QAction*> ComponentEditorComInterfaceItem::actions() const\r\n{\r\n    QList<QAction*> actionList;\r\n    actionList.append(editAction_);\r\n\r\n    return actionList;   \r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditorComInterfaceItem::openItem()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentEditorComInterfaceItem::openItem() \r\n{\r\n\tVLNV comdefVLNV = interface_->getComType();\r\n\temit openComDefinition(comdefVLNV);\r\n}\r\n"
  },
  {
    "path": "editors/ComponentEditor/treeStructure/componenteditorcominterfaceitem.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: componenteditorcominterfaceitem.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 16.5.2012\r\n//\r\n// Description:\r\n// The item for a single COM interface in component editor's navigation tree.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef COMPONENTEDITORCOMINTERFACEITEM_H\r\n#define COMPONENTEDITORCOMINTERFACEITEM_H\r\n\r\n#include \"componenteditoritem.h\"\r\n\r\nclass ComInterface;\r\n//-----------------------------------------------------------------------------\r\n//! The item for a single COM interface in component editor's navigation tree.\r\n//-----------------------------------------------------------------------------\r\nclass ComponentEditorComInterfaceItem : public ComponentEditorItem\r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\r\n\t/*! The constructor\r\n\t *\r\n\t *    @param [in] comInterface    The COM interface being edited.\r\n\t *    @param [in] model           The model that owns the items.\r\n\t *    @param [in] libHandler      The instance that manages the library.\r\n\t *    @param [in] component       The component being edited.\r\n\t *    @param [in] parent          The parent item.\r\n\t *\r\n\t*/\r\n\tComponentEditorComInterfaceItem(QSharedPointer<ComInterface> comInterface,\r\n\t\tComponentEditorTreeModel* model, LibraryInterface* libHandler,\r\n\t\tQSharedPointer<Component> component, ComponentEditorItem* parent);\r\n\r\n\t//! The destructor\r\n\tvirtual ~ComponentEditorComInterfaceItem();\r\n\r\n\t/*! Get the tool tip for the item.\r\n\t * \r\n\t *    @return The text for the tool tip to print to user.\r\n\t*/\r\n\tvirtual QString getTooltip() const;\r\n\r\n\t/*! Get the text to be displayed to user in the tree for this item.\r\n\t *\r\n\t *    @return QString Contains the text to display.\r\n\t*/\r\n\tvirtual QString text() const;\r\n\r\n\t/*! Check the validity of this item and sub items.\r\n\t *\r\n\t *    @return bool True if item is in valid state.\r\n\t*/\r\n\tvirtual bool isValid() const;\r\n\r\n\t/*! Get The editor of this item.\r\n\t *\r\n\t *    @return The editor to use for this item.\r\n\t*/\r\n\tvirtual ItemEditor* editor();\r\n\r\n\t/*! Tells if the item can be opened or not.\r\n\t * \r\n\t * If the com interface contains valid com definition reference then it can be opened.\r\n\t*/\r\n\tvirtual bool canBeOpened() const;\r\n\r\n    /*!\r\n     *  Returns the possible actions for opening the item.\r\n     *\r\n     *    @return The actions to open the item.\r\n     */\r\n    virtual QList<QAction*> actions() const;\r\n\r\npublic slots:\r\n\t\r\n\t/*! Open the COM definition in an editor.\r\n\t * \r\n\t*/\r\n\tvirtual void openItem();\r\n\r\nprivate:\r\n\t//! No copying\r\n\tComponentEditorComInterfaceItem(const ComponentEditorComInterfaceItem& other);\r\n\r\n\t//! No assignment\r\n\tComponentEditorComInterfaceItem& operator=(const ComponentEditorComInterfaceItem& other);\r\n\r\n\t//! The com interface being edited.\r\n\tQSharedPointer<ComInterface> interface_;\r\n\r\n    //! Action to open the COM interface for editing.\r\n    QAction* editAction_;\r\n};\r\n\r\n#endif // COMPONENTEDITORCOMINTERFACEITEM_H\r\n"
  },
  {
    "path": "editors/ComponentEditor/treeStructure/componenteditorcominterfacesitem.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: componenteditorcominterfacesitem.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 09.05.2012\r\n//\r\n// Description:\r\n// The COM interfaces-item in the component editor's navigation tree.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"componenteditorcominterfacesitem.h\"\r\n\r\n#include \"componenteditorcominterfaceitem.h\"\r\n\r\n#include <editors/ComponentEditor/software/comInterface/cominterfaceseditor.h>\r\n\r\n#include <IPXACTmodels/Component/Component.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditorComInterfacesItem::ComponentEditorComInterfacesItem()\r\n//-----------------------------------------------------------------------------\r\nComponentEditorComInterfacesItem::ComponentEditorComInterfacesItem(ComponentEditorTreeModel* model, \r\n    LibraryInterface* libHandler,\r\n    QSharedPointer<Component> component,\r\n    ComponentEditorItem* parent):\r\nComponentEditorItem(model, libHandler, component, parent)\r\n{\r\n    foreach (QSharedPointer<ComInterface> comInterface, component->getComInterfaces())\r\n    {\r\n        QSharedPointer<ComponentEditorComInterfaceItem> interfaceItem(new ComponentEditorComInterfaceItem(\r\n            comInterface, model, libHandler, component, this));\r\n        childItems_.append(interfaceItem);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditorComInterfacesItem::~ComponentEditorComInterfacesItem()\r\n//-----------------------------------------------------------------------------\r\nComponentEditorComInterfacesItem::~ComponentEditorComInterfacesItem()\r\n{\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditorComInterfacesItem::getFont()\r\n//-----------------------------------------------------------------------------\r\nQFont ComponentEditorComInterfacesItem::getFont() const\r\n{\r\n    QFont font(ComponentEditorItem::getFont());\r\n    font.setBold(!component_->getComInterfaces().isEmpty());\r\n    return font;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditorComInterfacesItem::text()\r\n//-----------------------------------------------------------------------------\r\nQString ComponentEditorComInterfacesItem::text() const\r\n{\r\n\treturn tr(\"COM interfaces\");\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditorComInterfacesItem::editor()\r\n//-----------------------------------------------------------------------------\r\nItemEditor* ComponentEditorComInterfacesItem::editor()\r\n{\r\n\tif (!editor_)\r\n    {\r\n\t\teditor_ = new ComInterfacesEditor(libHandler_, component_);\r\n\t\teditor_->setProtection(locked_);\r\n\t\tconnect(editor_, SIGNAL(contentChanged()), this, SLOT(onEditorChanged()), Qt::UniqueConnection);\r\n\t\tconnect(editor_, SIGNAL(childAdded(int)), this, SLOT(onAddChild(int)), Qt::UniqueConnection);\r\n\t\tconnect(editor_, SIGNAL(childRemoved(int)),\tthis, SLOT(onRemoveChild(int)), Qt::UniqueConnection);\r\n\t\tconnect(editor_, SIGNAL(helpUrlRequested(QString const&)), this, SIGNAL(helpUrlRequested(QString const&)));\r\n\t}\r\n\treturn editor_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditorComInterfacesItem::getTooltip()\r\n//-----------------------------------------------------------------------------\r\nQString ComponentEditorComInterfacesItem::getTooltip() const\r\n{\r\n\treturn tr(\"Contains the COM interfaces of a component\");\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditorComInterfacesItem::createChild()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentEditorComInterfacesItem::createChild(int index)\r\n{\r\n\tQSharedPointer<ComponentEditorComInterfaceItem> interfaceItem(new ComponentEditorComInterfaceItem(\r\n\t\tcomponent_->getComInterfaces().at(index), model_, libHandler_, component_, this));\r\n\tinterfaceItem->setLocked(locked_);\r\n\tchildItems_.insert(index, interfaceItem);\r\n}\r\n"
  },
  {
    "path": "editors/ComponentEditor/treeStructure/componenteditorcominterfacesitem.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: componenteditorcominterfacesitem.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 09.05.2012\r\n//\r\n// Description:\r\n// The COM interfaces-item in the component editor's navigation tree.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef COMPONENTEDITORCOMINTERFACESITEM_H\r\n#define COMPONENTEDITORCOMINTERFACESITEM_H\r\n\r\n#include \"componenteditoritem.h\"\r\n\r\nclass Component;\r\nclass ComInterface;\r\n//-----------------------------------------------------------------------------\r\n//! The COM interfaces-item in the component editor's navigation tree.\r\n//-----------------------------------------------------------------------------\r\nclass ComponentEditorComInterfacesItem : public ComponentEditorItem\r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\r\n\t/*! The constructor\r\n\t *\r\n\t *    @param [in] model       The model that owns the items.\r\n\t *    @param [in] libHandler  The instance that manages the library.\r\n\t *    @param [in] component   The component being edited.\r\n\t *    @param [in] parent      The parent item.\r\n\t *\r\n\t*/\r\n\tComponentEditorComInterfacesItem(ComponentEditorTreeModel* model,\r\n\t\tLibraryInterface* libHandler,\r\n\t\tQSharedPointer<Component> component,\r\n\t\tComponentEditorItem* parent);\r\n\r\n\t//! The destructor\r\n\tvirtual ~ComponentEditorComInterfacesItem();\r\n\r\n\t/*! Get the font to be used for text of this item.\r\n\t*\r\n\t* The font is bold, if COM interfaces exist, otherwise not bold.\r\n\t*\r\n\t*    @return QFont instance that defines the font to be used.\r\n\t*/\r\n\tvirtual QFont getFont() const;\r\n\r\n\t/*! Get the tool tip for the item.\r\n\t * \r\n\t *    @return The text for the tool tip to print to user.\r\n\t*/\r\n\tvirtual QString getTooltip() const;\r\n\r\n\t/*! Get the text to be displayed to user in the tree for this item.\r\n\t *\r\n\t *    @return QString Contains the text to display.\r\n\t*/\r\n\tvirtual QString text() const;\r\n\r\n\t/*! Get The editor of this item.\r\n\t *\r\n\t *    @return The editor to use for this item.\r\n\t*/\r\n\tvirtual ItemEditor* editor();\r\n\r\n\t/*! Add a new child to the item.\r\n\t * \r\n\t *    @param [in] index The index to add the child into.\r\n\t *\r\n\t*/\r\n\tvirtual void createChild(int index);\r\n\r\nprivate:\r\n\t//! No copying\r\n\tComponentEditorComInterfacesItem(const ComponentEditorComInterfacesItem& other);\r\n\r\n\t//! No assignment\r\n\tComponentEditorComInterfacesItem& operator=(const ComponentEditorComInterfacesItem& other);\r\n};\r\n\r\n#endif // COMPONENTEDITORCOMINTERFACESITEM_H\r\n"
  },
  {
    "path": "editors/ComponentEditor/treeStructure/componenteditorcpusitem.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: componenteditorcpusitem.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author:Antti Kamppi\r\n// Date: 09.05.2012\r\n//\r\n// Description:\r\n// The Cpus-item in the component editor's navigation tree.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"componenteditorcpusitem.h\"\r\n\r\n#include <editors/ComponentEditor/treeStructure/SingleCpuItem.h>\r\n#include <editors/ComponentEditor/cpus/cpuseditor.h>\r\n\r\n#include <IPXACTmodels/Component/Component.h>\r\n#include <IPXACTmodels/Component/Cpu.h>\r\n#include <IPXACTmodels/Component/validators/CPUValidator.h>\r\n#include <IPXACTmodels/Component/validators/CollectionValidators.h>\r\n\r\n#include <IPXACTmodels/common/validators/ParameterValidator.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditorCpusItem::ComponentEditorCpusItem()\r\n//-----------------------------------------------------------------------------\r\nComponentEditorCpusItem::ComponentEditorCpusItem(ComponentEditorTreeModel* model, \r\n    LibraryInterface* libHandler,\r\n    QSharedPointer<Component> component,\r\n    QSharedPointer<ReferenceCounter> referenceCounter,\r\n    ExpressionSet expressions,\r\n    ComponentEditorItem* parent ):\r\nComponentEditorItem(model, libHandler, component, parent),\r\n    cpus_(component->getCpus()),\r\n    singleCpuValidator_(new CPUValidator(\r\n        QSharedPointer<ParameterValidator>(new ParameterValidator(expressions.parser, component->getChoices(), component->getRevision())),\r\n        expressions.parser, component->getAddressSpaces(), component->getMemoryMaps(), component->getRevision())),\r\n    cpusValidator_(new CPUsValidator(singleCpuValidator_)),\r\n    expressions_(expressions)\r\n{\r\n    setParameterFinder(expressions.finder);\r\n    setExpressionFormatter(expressions.formatter);\r\n    setReferenceCounter(referenceCounter);\r\n\r\n    const int CHILD_COUNT = cpus_->count();\r\n    for (int i = 0; i < CHILD_COUNT; ++i)\r\n    {\r\n        createChild(i);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditorCpusItem::getFont()\r\n//-----------------------------------------------------------------------------\r\nQFont ComponentEditorCpusItem::getFont() const\r\n{\r\n    QFont font(ComponentEditorItem::getFont());\r\n    font.setBold(!cpus_->isEmpty());\r\n    return font;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditorCpusItem::text()\r\n//-----------------------------------------------------------------------------\r\nQString ComponentEditorCpusItem::text() const\r\n{\r\n\treturn tr(\"CPUs\");\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditorCpusItem::editor()\r\n//-----------------------------------------------------------------------------\r\nItemEditor* ComponentEditorCpusItem::editor()\r\n{\r\n\tif (!editor_)\r\n    {\r\n\t\teditor_ = new CpusEditor(component_, libHandler_, singleCpuValidator_, expressions_);\r\n        editor_->setProtection(locked_);\r\n        connect(editor_, SIGNAL(childAdded(int)), this, SLOT(onAddChild(int)), Qt::UniqueConnection);\r\n        connect(editor_, SIGNAL(childRemoved(int)), this, SLOT(onRemoveChild(int)), Qt::UniqueConnection);\r\n\t\tconnect(editor_, SIGNAL(contentChanged()), this, SLOT(onEditorChanged()), Qt::UniqueConnection);\r\n\t\tconnect(editor_, SIGNAL(helpUrlRequested(QString const&)), this, SIGNAL(helpUrlRequested(QString const&)));\r\n\r\n        connectItemEditorToReferenceCounter();\r\n\t}\r\n\r\n\treturn editor_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditorCpusItem::getTooltip()\r\n//-----------------------------------------------------------------------------\r\nQString ComponentEditorCpusItem::getTooltip() const\r\n{\r\n\treturn tr(\"Contains the programmable cores of the component\");\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditorCpusItem::isValid()\r\n//-----------------------------------------------------------------------------\r\nbool ComponentEditorCpusItem::isValid() const\r\n{\r\n    auto cpusNameGroup = CollectionValidators::itemListToNameGroupList(cpus_);\r\n    cpusValidator_->childrenHaveUniqueNames(cpusNameGroup);\r\n    return ComponentEditorItem::isValid();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditorCpusItem::createChild()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentEditorCpusItem::createChild(int index)\r\n{\r\n    QSharedPointer<SingleCpuItem> cpuItem(new SingleCpuItem(cpus_->at(index), model_, libHandler_,\r\n        component_, referenceCounter_, expressions_, singleCpuValidator_, this));\r\n\r\n    cpuItem->setLocked(locked_);\r\n\r\n    childItems_.insert(index, cpuItem);\r\n}\r\n"
  },
  {
    "path": "editors/ComponentEditor/treeStructure/componenteditorcpusitem.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: componenteditorcpusitem.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author:Antti Kamppi\r\n// Date: 09.05.2012\r\n//\r\n// Description:\r\n// The Cpus-item in the component editor's navigation tree.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef COMPONENTEDITORCPUSITEM_H\r\n#define COMPONENTEDITORCPUSITEM_H\r\n\r\n#include \"componenteditoritem.h\"\r\n\r\n#include <editors/common/ExpressionSet.h>\r\n\r\n#include <QList>\r\n\r\nclass Cpu;\r\nclass CPUValidator;\r\nclass CPUsValidator;\r\nclass ExpressionParser;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! The Cpus-item in the component editor's navigation tree.\r\n//-----------------------------------------------------------------------------\r\nclass ComponentEditorCpusItem : public ComponentEditorItem\r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\r\n\t/*! The constructor\r\n\t *\r\n\t *    @param [in] model               The model that owns the items.\r\n\t *    @param [in] libHandler          The instance that manages the library.\r\n\t *    @param [in] component           The component being edited.\r\n     *    @param [in] expressions\t\t\tParser for expressions in cpus.\r\n     *    @param [in] parent              The parent item.\r\n     */\r\n    ComponentEditorCpusItem(ComponentEditorTreeModel* model, LibraryInterface* libHandler,\r\n        QSharedPointer<Component> component, QSharedPointer<ReferenceCounter> referenceCounter,\r\n\t\tExpressionSet expressions,\r\n        ComponentEditorItem* parent);\r\n\r\n\t//! The destructor\r\n\tvirtual ~ComponentEditorCpusItem() = default;\r\n\r\n    //! No copying\r\n    ComponentEditorCpusItem(const ComponentEditorCpusItem& other) = delete;\r\n    ComponentEditorCpusItem& operator=(const ComponentEditorCpusItem& other) = delete;\r\n\r\n\t/*! Get the font to be used for text of this item.\r\n\t*\r\n\t* The font is bold, if cpus exist, otherwise not bold.\r\n\t*\r\n\t*    @return QFont instance that defines the font to be used.\r\n\t*/\r\n\tQFont getFont() const final;\r\n\r\n\t/*! Get the tool tip for the item.\r\n\t * \r\n\t *    @return The text for the tool tip to print to user.\r\n\t*/\r\n\tQString getTooltip() const final;\r\n\r\n\t/*! Get the text to be displayed to user in the tree for this item.\r\n\t *\r\n\t *    @return The text to display.\r\n\t*/\r\n\tQString text() const final;\r\n\r\n\t/*! Get The editor of this item.\r\n\t *\r\n\t *    @return The editor to use for this item.\r\n\t*/\r\n\tItemEditor* editor() final;\r\n\r\n\t/*! Check the validity of this item and sub items.\r\n\t *\r\n\t *    @return True if item is in valid state.\r\n\t*/\r\n\tbool isValid() const final;\r\n\r\n\t/*!\r\n     *  Add a new child to the item.\r\n\t *\r\n\t *    @param [in] index   The index to add the child into.\r\n\t */\r\n\tvoid createChild(int index) final;\r\n\r\n\r\nprivate:\r\n\r\n\t//! The cpus being edited\r\n\tQSharedPointer<QList<QSharedPointer<Cpu> > > cpus_;\r\n\r\n    //! Validator for cpu elements.\r\n    QSharedPointer<CPUValidator> singleCpuValidator_;\r\n\r\n\t//! Validator for validating cpus together.\r\n    QSharedPointer<CPUsValidator> cpusValidator_;\r\n\r\n\tExpressionSet expressions_;\r\n};\r\n\r\n#endif // COMPONENTEDITORCPUSITEM_H\r\n"
  },
  {
    "path": "editors/ComponentEditor/treeStructure/componenteditorfielditem.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: componenteditorfielditem.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 28.08.2012\r\n//\r\n// Description:\r\n// The item for single field in component editor's navigation tree\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"componenteditorfielditem.h\"\r\n\r\n#include <KactusAPI/include/ExpressionParser.h>\r\n\r\n#include <editors/ComponentEditor/memoryMaps/SingleFieldEditor.h>\r\n#include <editors/ComponentEditor/memoryMaps/memoryMapsVisualizer/memorymapsvisualizer.h>\r\n#include <editors/ComponentEditor/memoryMaps/memoryMapsVisualizer/fieldgraphitem.h>\r\n#include <KactusAPI/include/ResetInterface.h>\r\n#include <KactusAPI/include/FieldInterface.h>\r\n\r\n#include <editors/ComponentEditor/visualization/memoryvisualizationitem.h>\r\n\r\n#include <IPXACTmodels/Component/validators/FieldValidator.h>\r\n#include <IPXACTmodels/Component/Component.h>\r\n#include <IPXACTmodels/Component/Register.h>\r\n#include <IPXACTmodels/Component/Field.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditorFieldItem::ComponentEditorFieldItem()\r\n//-----------------------------------------------------------------------------\r\nComponentEditorFieldItem::ComponentEditorFieldItem(QSharedPointer<Register> reg, QSharedPointer<Field> field,\r\n    ComponentEditorTreeModel* model, LibraryInterface* libHandler, QSharedPointer<Component> component,\r\n    QSharedPointer<ParameterFinder> parameterFinder, QSharedPointer<ReferenceCounter> referenceCounter,\r\n    QSharedPointer<ExpressionParser> expressionParser, QSharedPointer<ExpressionFormatter> formatter,\r\n    QSharedPointer<FieldValidator> fieldValidator, FieldInterface* fieldInterface, ComponentEditorItem* parent):\r\nComponentEditorItem(model, libHandler, component, parent),\r\nreg_(reg),\r\nfield_(field),\r\nexpressionParser_(expressionParser),\r\nfieldValidator_(fieldValidator),\r\nfieldInterface_(fieldInterface)\r\n{\r\n\tQ_ASSERT(field_);\r\n\r\n    setParameterFinder(parameterFinder);\r\n    setReferenceCounter(referenceCounter);\r\n    setExpressionFormatter(formatter);\r\n\r\n\tsetObjectName(tr(\"ComponentEditorFieldItem\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: componenteditorfielditem::getTooltip()\r\n//-----------------------------------------------------------------------------\r\nQString ComponentEditorFieldItem::getTooltip() const\r\n{\r\n\treturn tr(\"Contains details of a single field within a register.\");\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditorFieldItem::text()\r\n//-----------------------------------------------------------------------------\r\nQString ComponentEditorFieldItem::text() const\r\n{\r\n\treturn field_->name();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditorFieldItem::isValid()\r\n//-----------------------------------------------------------------------------\r\nbool ComponentEditorFieldItem::isValid() const \r\n{\r\n    return fieldValidator_->validate(field_);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditorFieldItem::editor()\r\n//-----------------------------------------------------------------------------\r\nItemEditor* ComponentEditorFieldItem::editor()\r\n{\r\n\tif (!editor_)\r\n    {\r\n        editor_ = new SingleFieldEditor(field_, component_, libHandler_, parameterFinder_, expressionParser_,\r\n            fieldValidator_, fieldInterface_, reg_);\r\n        editor_->setProtection(locked_);\r\n\r\n\t\tconnect(editor_, SIGNAL(contentChanged()), this, SLOT(onEditorChanged()), Qt::UniqueConnection);\r\n        connect(editor_, SIGNAL(graphicsChanged()), this, SLOT(onGraphicsChanged()), Qt::UniqueConnection);\r\n        connect(editor_, SIGNAL(addressingChanged()), this, SIGNAL(addressingChanged()), Qt::UniqueConnection);\r\n\t\tconnect(editor_, SIGNAL(helpUrlRequested(QString const&)), this, SIGNAL(helpUrlRequested(QString const&)));\r\n\r\n        connect(this, SIGNAL(fieldNameChanged(QString const&, QString const&)),\r\n            editor_, SLOT(onFieldNameChanged(QString const&, QString const&)), Qt::UniqueConnection);\r\n\r\n        connectItemEditorToReferenceCounter();\r\n\t}\r\n\treturn editor_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditorFieldItem::visualizer()\r\n//-----------------------------------------------------------------------------\r\nItemVisualizer* ComponentEditorFieldItem::visualizer()\r\n{\r\n\treturn visualizer_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditorFieldItem::setVisualizer()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentEditorFieldItem::setVisualizer( MemoryMapsVisualizer* visualizer )\r\n{\r\n\tvisualizer_ = visualizer;\r\n\r\n\tgraphItem_ = new FieldGraphItem(field_, expressionParser_, nullptr);\r\n\r\n\tconnect(graphItem_, SIGNAL(selectEditor()), this, SLOT(onSelectRequest()), Qt::UniqueConnection);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditorFieldItem::getGraphicsItem()\r\n//-----------------------------------------------------------------------------\r\nQGraphicsItem* ComponentEditorFieldItem::getGraphicsItem()\r\n{\r\n\treturn graphItem_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditorFieldItem::removeGraphicsItem()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentEditorFieldItem::removeGraphicsItem()\r\n{\r\n\tif (graphItem_)\r\n    {\r\n\t\tdisconnect(graphItem_, SIGNAL(selectEditor()), this, SLOT(onSelectRequest()));\r\n\r\n\t\t// delete the graph item\r\n\t\tdelete graphItem_;\r\n\t\tgraphItem_ = NULL;\r\n\t}\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditorFieldItem::updateGraphics()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentEditorFieldItem::updateGraphics()\r\n{\r\n    onGraphicsChanged();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditorFieldItem::onEditorChanged()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentEditorFieldItem::onEditorChanged()\r\n{\r\n    emit contentChanged(this);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditorFieldItem::onGraphicsChanged()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentEditorFieldItem::onGraphicsChanged()\r\n{\r\n    if (graphItem_)\r\n    {\r\n        graphItem_->updateDisplay();\r\n    }\r\n}\r\n"
  },
  {
    "path": "editors/ComponentEditor/treeStructure/componenteditorfielditem.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: componenteditorfielditem.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 28.08.2012\r\n//\r\n// Description:\r\n// The item for single field in component editor's navigation tree\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef COMPONENTEDITORFIELDITEM_H\r\n#define COMPONENTEDITORFIELDITEM_H\r\n\r\n#include \"componenteditoritem.h\"\r\n\r\n#include <QFont>\r\n#include <QSharedPointer>\r\n\r\nclass MemoryMapsVisualizer;\r\nclass FieldGraphItem;\r\nclass ExpressionParser;\r\nclass Field;\r\nclass Register;\r\nclass Component;\r\nclass FieldValidator;\r\nclass FieldInterface;\r\nclass ResetInterface;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! The item for single field in component editor's navigation tree.\r\n//-----------------------------------------------------------------------------\r\nclass ComponentEditorFieldItem : public ComponentEditorItem\r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\r\n    /*!\r\n\t *  The constructor.\r\n\t *\r\n\t *    @param [in] reg                 The register which contains this field.\r\n\t *    @param [in] field               The field being edited.\r\n\t *    @param [in] model               The model that owns the items.\r\n\t *    @param [in] libHandler          The instance that manages the library.\r\n\t *    @param [in] component           The component being edited.\r\n\t *    @param [in] parameterFinder     The parameter finder.\r\n\t *    @param [in] referenceCounter    The instance for counting references made to the parameters.\r\n     *    @param [in] expressionParser    Expression parser to use.\r\n     *    @param [in] formatter           The expression formatter.\r\n     *    @param [in] fieldValidator      Validator used for fields.\r\n     *    @param [in] fieldInterface      Interface for accessing fields.\r\n     *    @param [in] parent              The parent item.\r\n\t */\r\n    ComponentEditorFieldItem(QSharedPointer<Register> reg,\r\n        QSharedPointer<Field> field,\r\n        ComponentEditorTreeModel* model,\r\n        LibraryInterface* libHandler,\r\n        QSharedPointer<Component> component,\r\n        QSharedPointer<ParameterFinder> parameterFinder,\r\n        QSharedPointer<ReferenceCounter> referenceCounter,\r\n        QSharedPointer<ExpressionParser> expressionParser,\r\n        QSharedPointer<ExpressionFormatter> formatter,\r\n        QSharedPointer<FieldValidator> fieldValidator,\r\n        FieldInterface* fieldInterface,\r\n        ComponentEditorItem* parent);\r\n\r\n\t/*!\r\n     *  The destructor.\r\n     */\r\n\tvirtual ~ComponentEditorFieldItem() = default;\r\n\r\n    //! No copying.\r\n    ComponentEditorFieldItem(const ComponentEditorFieldItem& other) = delete;\r\n\r\n    //! No assignment.\r\n    ComponentEditorFieldItem& operator=(const ComponentEditorFieldItem& other) = delete;\r\n\r\n\r\n\t/*!\r\n     *  Get the tool tip for the item.\r\n\t * \r\n\t *    @return The text for the tool tip to print to user.\r\n\t */\r\n\tvirtual QString getTooltip() const;\r\n\r\n\t/*!\r\n     *  Get the text to be displayed to user in the tree for this item.\r\n\t *\r\n\t *    @return QString Contains the text to display.\r\n\t */\r\n\tvirtual QString text() const;\r\n\r\n\t/*!\r\n     *  Check the validity of this item and sub items.\r\n\t *\r\n\t *    @return bool True if item is in valid state.\r\n\t */\r\n\tvirtual bool isValid() const;\r\n\r\n\t/*!\r\n     *  Get the editor of this item.\r\n\t *\r\n\t *    @return The editor to use for this item.\r\n\t */\r\n\tvirtual ItemEditor* editor();\r\n\r\n\t/*!\r\n     *  Get the visualizer of this item.\r\n\t * \r\n\t *    @return The visualizer to use for this item.\r\n\t */\r\n\tvirtual ItemVisualizer* visualizer();\r\n\r\n\t/*!\r\n     *  Set the visualizer for this item.\r\n\t *\r\n\t *    @param [in] visualizer The visualizer to set.\r\n\t */\r\n\tvirtual void setVisualizer(MemoryMapsVisualizer* visualizer);\r\n\r\n\t/*!\r\n     *  Get the visualizer graphics item for the field.\r\n\t *\r\n\t *    @return The graphics item.\r\n\t */\r\n\tvirtual QGraphicsItem* getGraphicsItem();\r\n\r\n\t/*!\r\n     *  Update the graphics item of the field.\r\n\t */\r\n    virtual void updateGraphics() override final;\r\n\r\n\t/*!\r\n     *  Remove the graphics item of the field.\r\n\t */\r\n\tvirtual void removeGraphicsItem();\r\n\r\n\r\nsignals:\r\n\r\n    /*!\r\n     *  Inform of the need to redraw the visualization.\r\n     */\r\n    //void graphicsChanged();\r\n\r\n    //! Inform that address information has changed.\r\n    void addressingChanged();\r\n\r\n\r\n    /*\r\n     *  Informs of field name change.\r\n     *\r\n     *    @param [in] oldName     The old name.\r\n     *    @param [in] newName     The new name.\r\n     */\r\n    void fieldNameChanged(QString const& oldName, QString const& newName);\r\n\r\nprotected slots:\r\n\r\n\t/*!\r\n     *  Handler for editor's contentChanged signal.\r\n\t */\r\n\tvirtual void onEditorChanged();\r\n\r\n    /*!\r\n     *  Handle the change in graphics.\r\n     */\r\n    virtual void onGraphicsChanged() override final;\r\n\r\nprivate:\r\n\r\n\t//! The register which contains this field.\r\n\tQSharedPointer<Register> reg_;\r\n\r\n\t//! The field being edited.\r\n\tQSharedPointer<Field> field_;\r\n\r\n\t//! The visualizer of memory maps.\r\n\tMemoryMapsVisualizer* visualizer_ = nullptr;\r\n\r\n\t//! The graph item that visualizes the field.\r\n    FieldGraphItem* graphItem_ = nullptr;\r\n\r\n    //! The expression parser to use.\r\n    QSharedPointer<ExpressionParser> expressionParser_;\r\n\r\n    //! The used field validator.\r\n    QSharedPointer<FieldValidator> fieldValidator_;\r\n\r\n    //! Interface for fields.\r\n    FieldInterface* fieldInterface_;\r\n};\r\n\r\n#endif // COMPONENTEDITORFIELDITEM_H\r\n"
  },
  {
    "path": "editors/ComponentEditor/treeStructure/componenteditorfileitem.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: componenteditorfileitem.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 16.05.2012\r\n//\r\n// Description:\r\n// The item for a single file in component editor's navigation tree.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"componenteditorfileitem.h\"\r\n\r\n#include <KactusAPI/include/FileHandler.h>\r\n\r\n#include <editors/ComponentEditor/fileSet/file/fileeditor.h>\r\n#include <KactusAPI/include/ParameterFinder.h>\r\n#include <KactusAPI/include/ExpressionParser.h>\r\n\r\n#include <KactusAPI/include/LibraryInterface.h>\r\n\r\n#include <IPXACTmodels/generaldeclarations.h>\r\n\r\n#include <IPXACTmodels/Component/File.h>\r\n#include <IPXACTmodels/Component/Component.h>\r\n\r\n#include <IPXACTmodels/Component/validators/FileValidator.h>\r\n\r\n#include <QApplication>\r\n#include <QDesktopServices>\r\n#include <QFileInfo>\r\n#include <QFileDialog>\r\n#include <QFont>\r\n#include <QProcess>\r\n#include <QSettings>\r\n#include <QStringList>\r\n#include <QUrl>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditorFileItem::ComponentEditorFileItem()\r\n//-----------------------------------------------------------------------------\r\nComponentEditorFileItem::ComponentEditorFileItem(QSharedPointer<File> file,\r\n    QSharedPointer<QList<QSharedPointer<File>>> availableFiles, FileInterface* fileInterface,\r\n    ComponentEditorTreeModel* model, LibraryInterface* libHandler, QSharedPointer<Component> component,\r\n    QSharedPointer<FileValidator> validator, QSharedPointer<ParameterFinder> parameterFinder,\r\n    QSharedPointer<ExpressionParser> expressionParser, QSharedPointer<ReferenceCounter> referenceCounter,\r\n    ComponentEditorItem* parent):\r\nComponentEditorItem(model, libHandler, component, parent),\r\nfile_(file),\r\nvalidator_(validator),\r\neditAction_(new QAction(tr(\"Edit\"), this)),\r\neditWithAction_(new QAction(tr(\"Edit/Run with...\"), this)),\r\nrunAction_(new QAction(tr(\"Run\"), this)),\r\nopenContainingFolderAction_(new QAction(tr(\"Open Containing Folder\"), this) ),\r\nexpressionParser_(expressionParser),\r\nfileInterface_(fileInterface),\r\navailableFiles_(availableFiles)\r\n{\r\n    setParameterFinder(parameterFinder);\r\n    setReferenceCounter(referenceCounter);\r\n\r\n    connect(editAction_, SIGNAL(triggered(bool)), this, SLOT(openItem()), Qt::UniqueConnection);\r\n    connect(editWithAction_, SIGNAL(triggered(bool)), this, SLOT(openWith()), Qt::UniqueConnection);\r\n    connect(runAction_, SIGNAL(triggered(bool)), this, SLOT(run()), Qt::UniqueConnection);\r\n    connect(openContainingFolderAction_, SIGNAL(triggered(bool)),\r\n        this, SLOT(onOpenContainingFolder()), Qt::UniqueConnection);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditorFileItem::~ComponentEditorFileItem()\r\n//-----------------------------------------------------------------------------\r\nComponentEditorFileItem::~ComponentEditorFileItem()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditorFileItem::text()\r\n//-----------------------------------------------------------------------------\r\nQString ComponentEditorFileItem::text() const\r\n{\r\n    return file_->getFileName();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditorFileItem::isValid()\r\n//-----------------------------------------------------------------------------\r\nbool ComponentEditorFileItem::isValid() const\r\n{\r\n    if (!validator_->validate(file_))\r\n    {\r\n        return false;\r\n    }\r\n\r\n    QString basePath = libHandler_->getPath(component_->getVlnv());\r\n\r\n    return FileHandler::isValidURI(basePath, file_->name());\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditorFileItem::editor()\r\n//-----------------------------------------------------------------------------\r\nItemEditor* ComponentEditorFileItem::editor()\r\n{\r\n\tif (!editor_)\r\n    {\r\n        editor_ = new FileEditor(libHandler_, component_, file_->name().toStdString(), parameterFinder_,\r\n            expressionParser_, fileInterface_, availableFiles_);\r\n        editor_->setProtection(locked_);\r\n\t\tconnect(editor_, SIGNAL(contentChanged()), this, SLOT(onEditorChanged()), Qt::UniqueConnection);\r\n\t\tconnect(editor_, SIGNAL(helpUrlRequested(QString const&)), this, SIGNAL(helpUrlRequested(QString const&)));\r\n        connect(editor_, SIGNAL(editFile()), this, SLOT(openItem()), Qt::UniqueConnection);\r\n        connect(editor_, SIGNAL(runFile()), this, SLOT(run()), Qt::UniqueConnection);\r\n        connect(editor_, SIGNAL(openContainingFolder()), this, SLOT(onOpenContainingFolder()), Qt::UniqueConnection);\r\n\r\n        connect(this, SIGNAL(fileRenamed(std::string const&, std::string const&)),\r\n            editor_, SLOT(fileRenamed(std::string const&, std::string const&)), Qt::UniqueConnection);\r\n\r\n        connectItemEditorToReferenceCounter();\r\n\t}\r\n\treturn editor_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditorFileItem::getTooltip()\r\n//-----------------------------------------------------------------------------\r\nQString ComponentEditorFileItem::getTooltip() const\r\n{\r\n\treturn tr(\"Specifies a single file associated with the file set\");\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditorFileItem::canBeOpened()\r\n//-----------------------------------------------------------------------------\r\nbool ComponentEditorFileItem::canBeOpened() const\r\n{\r\n\treturn true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditorFileItem::openItem()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentEditorFileItem::openItem()\r\n{\r\n    if (useKactusCSourceEditor())\r\n    {\r\n        emit openCSource(fileAbsolutePath(), component_);\r\n    }\r\n    else\r\n    {\r\n        QDesktopServices::openUrl(QUrl::fromLocalFile(fileAbsolutePath()));\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditorFileItem::openWith()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentEditorFileItem::openWith()\r\n{\r\n    QString applicationPath = QFileDialog::getOpenFileName(0, tr(\"Select Application\"));\r\n\r\n    if (QFileInfo(applicationPath).isExecutable())\r\n    {\r\n        runInApplication(applicationPath);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditorFileItem::run()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentEditorFileItem::run()\r\n{\r\n    if (runExecutableSet())\r\n    {\r\n        runInApplication(executablePath()); \r\n    }\r\n    else\r\n    {\r\n        emit errorMessage(tr(\"No executable set for file type(s).\"));\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditorFileItem::actions()\r\n//-----------------------------------------------------------------------------\r\nQList<QAction*> ComponentEditorFileItem::actions() const\r\n{\r\n    QList<QAction*> actionList;\r\n    actionList.append(editAction_);\r\n    actionList.append(editWithAction_);\r\n\tactionList.append(runAction_);\r\n\tactionList.append(openContainingFolderAction_);\r\n\r\n    runAction_->setEnabled(runExecutableSet());\r\n\r\n    return actionList;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditorFileItem::onEditorChanged()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentEditorFileItem::onEditorChanged()\r\n{\r\n\t// on file also the grand parent must be updated\r\n\tif (parent() && parent()->parent())\r\n    {\r\n\t\temit contentChanged(parent()->parent());\r\n\t}\r\n\r\n\t// call the base class to update this and parent\r\n\tComponentEditorItem::onEditorChanged();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditorFileItem::absolutePath()\r\n//-----------------------------------------------------------------------------\r\nQString ComponentEditorFileItem::fileAbsolutePath() const\r\n{\r\n    const QString relPath = file_->name();\r\n    const QString xmlPath = libHandler_->getPath(component_->getVlnv());\r\n\r\n    return General::getAbsolutePath(xmlPath, relPath);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditorFileItem::runInApplication()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentEditorFileItem::runInApplication(QString const& applicationPath)\r\n{\r\n    QApplication::setOverrideCursor(Qt::WaitCursor);\r\n\r\n    QStringList arguments(fileAbsolutePath());\r\n    QProcess::startDetached(applicationPath, arguments);\r\n\r\n    QApplication::restoreOverrideCursor();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditorFileItem::useKactusCSourceEditor()\r\n//-----------------------------------------------------------------------------\r\nbool ComponentEditorFileItem::useKactusCSourceEditor() const\r\n{\r\n\tQSettings settings;\r\n\r\n\tfor (auto const& fileType : *file_->getFileTypes())\r\n\t{\r\n\t\tQString key = \"FileTypes/\" + fileType.type_ + \"/EditInKactus\";\r\n\r\n\t\tif (settings.value(key).toBool())\r\n\t\t{\r\n\t\t\treturn true;\r\n\t\t}\r\n\t}\r\n\r\n\treturn false;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditorFileItem::runExecutableSet()\r\n//-----------------------------------------------------------------------------\r\nbool ComponentEditorFileItem::runExecutableSet() const\r\n{\r\n    return !executablePath().isEmpty();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditorFileItem::executablePath()\r\n//-----------------------------------------------------------------------------\r\nQString ComponentEditorFileItem::executablePath() const\r\n{\r\n    QSettings settings;\r\n\r\n    for (auto const& fileType : *file_->getFileTypes())\r\n    {\r\n        QString key = \"FileTypes/\" + fileType.type_ + \"/Executable\";\r\n        QString executableName = settings.value(key).toString();\r\n\r\n        executableName = resolveEnvironmentVariables(executableName);\r\n\r\n        if (QFileInfo(executableName).isExecutable())\r\n        {\r\n            return executableName;\r\n        }\r\n    }\r\n\r\n    return QString();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditorFileItem::resolveEnvironmentVariables()\r\n//-----------------------------------------------------------------------------\r\nQString ComponentEditorFileItem::resolveEnvironmentVariables(QString const& text) const\r\n{    \r\n    QSettings settings; \r\n    QString parsed = text;\r\n\r\n    QRegularExpression environmental(\"(\\\\$\\\\(?\\\\w+\\\\)?)\");\r\n    QRegularExpressionMatchIterator iter = environmental.globalMatch(text);\r\n   \r\n    while (iter.hasNext())\r\n    {\r\n        QRegularExpressionMatch match = iter.next();\r\n\r\n        const QString variable = match.captured();\r\n\r\n        QString variableName = variable;\r\n        variableName.remove(\"$\");\r\n        \r\n        // Remove enclosing parenthesis.\r\n        if (variableName.startsWith(\"(\"))\r\n        {\r\n            variableName = variableName.mid(1);\r\n            variableName.chop(1);\r\n        }\r\n\r\n        QString key = \"K2Variables/\" + variableName + \"/value\";\r\n        QString variableValue = settings.value(key).toString();\r\n\r\n        parsed.replace(variable, variableValue);\r\n    }\r\n\r\n    return parsed;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditorFileItem::onOpenContainingFolder()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentEditorFileItem::onOpenContainingFolder()\r\n{\r\n    QApplication::setOverrideCursor(Qt::WaitCursor);\r\n\tQString path = QFileInfo(fileAbsolutePath()).absolutePath();\r\n\r\n\t// Open the folder in the operating system's default file browser.\r\n\tQDesktopServices::openUrl(QUrl::fromLocalFile(path));\r\n    QApplication::restoreOverrideCursor();\r\n}\r\n"
  },
  {
    "path": "editors/ComponentEditor/treeStructure/componenteditorfileitem.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: componenteditorfileitem.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 16.05.2012\r\n//\r\n// Description:\r\n// The item for a single file in component editor's navigation tree.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef COMPONENTEDITORFILEITEM_H\r\n#define COMPONENTEDITORFILEITEM_H\r\n\r\n#include \"componenteditoritem.h\"\r\n\r\n#include <QRegularExpressionValidator>\r\n\r\nclass Component;\r\nclass ExpressionParser;\r\nclass File;\r\nclass FileValidator;\r\nclass LibraryInterface;\r\nclass ParameterFinder;\r\nclass FileInterface;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! The item for a single file in component editor's navigation tree.\r\n//-----------------------------------------------------------------------------\r\nclass ComponentEditorFileItem : public ComponentEditorItem\r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\r\n\t/*!\r\n     *  The constructor.\r\n\t *\r\n\t *    @param [in] file                The file being edited.\r\n     *    @param [in] availableFiles      The list of available files.\r\n     *    @param [in] fileInterface       Interface for accessing files.\r\n\t *    @param [in] model               The model that owns the items.\r\n\t *    @param [in] libHandler          The instance that manages the library.\r\n\t *    @param [in] component           The component being edited.\r\n     *    @param [in] validator           The validator for checking file validity.\r\n     *    @param [in] parameterFinder     The used parameter finder.\r\n     *    @param [in] expressionParser    Parser for calculating expressions.\r\n     *    @param [in] referenceCounter    The counter for parameter references.\r\n\t *    @param [in] parent              The parent item.\r\n\t */\r\n    ComponentEditorFileItem(QSharedPointer<File> file,\r\n        QSharedPointer<QList<QSharedPointer<File> > > availableFiles,\r\n        FileInterface* fileInterface,\r\n        ComponentEditorTreeModel* model,\r\n        LibraryInterface* libHandler,\r\n        QSharedPointer<Component> component,\r\n        QSharedPointer<FileValidator> validator,\r\n        QSharedPointer<ParameterFinder> parameterFinder,\r\n        QSharedPointer<ExpressionParser> expressionParser,\r\n        QSharedPointer<ReferenceCounter> referenceCounter,\r\n        ComponentEditorItem* parent);\r\n\r\n\t/*!\r\n     *  The destructor.\r\n     */\r\n\tvirtual ~ComponentEditorFileItem();\r\n\r\n\t/*!\r\n     *  Get the tool tip for the item.\r\n\t * \r\n\t *    @return The text for the tool tip to print to user.\r\n\t */\r\n\tvirtual QString getTooltip() const;\r\n\r\n\t/*!\r\n     *  Get the text to be displayed to user in the tree for this item.\r\n\t *\r\n\t *    @return QString Contains the text to display.\r\n\t */\r\n\tvirtual QString text() const;\r\n\r\n\t/*!\r\n     *  Check the validity of this item and sub items.\r\n\t *\r\n\t *    @return bool True if item is in valid state.\r\n\t */\r\n\tvirtual bool isValid() const;\r\n\r\n\t/*!\r\n     *  Get The editor of this item.\r\n\t *\r\n\t *    @return The editor to use for this item.\r\n\t */\r\n\tvirtual ItemEditor* editor();\r\n\r\n\t/*!\r\n     *  Tells if the item can be opened or not.\r\n\t * \r\n\t *    @return Files can always be opened and this function returns true.\r\n\t */\r\n\tvirtual bool canBeOpened() const;\r\n\r\n    /*!\r\n     *  Returns the possible actions for opening the item.\r\n     *\r\n     *    @return The actions to open the item.\r\n     */\r\n    virtual QList<QAction*> actions() const;\r\n\r\nsignals:\r\n\r\n    /*!\r\n     *  Handle the name change of a file.\r\n     *\r\n     *    @param [in] oldName     Old name of the selected file.\r\n     *    @param [in] newName     The new name for the selected file.\r\n     */\r\n    void fileRenamed(std::string const& oldName, std::string const& newName);\r\n\r\npublic slots:\r\n\t\r\n\t//! Called to open the item in a default editor.\r\n\tvirtual void openItem();\r\n\r\n    //! Called to let the user choose an editor to open the item.\r\n    virtual void openWith();\r\n\r\n    //! Called to run the file with the executable set for the file type.\r\n    virtual void run();\r\n\r\nprotected slots:\r\n\r\n\t/*!\r\n     *  Handler for editor's contentChanged signal.\r\n\t */\r\n\tvirtual void onEditorChanged();\r\n\r\n\t//! Opens the folder that contains the file.\r\n\tvoid onOpenContainingFolder();\r\n\r\nprivate:\r\n\t\r\n    //! No copying. No assignment.\r\n\tComponentEditorFileItem(const ComponentEditorFileItem& other);\r\n\tComponentEditorFileItem& operator=(const ComponentEditorFileItem& other);\r\n   \r\n    //! Finds the absolute path of the file represented by the item.\r\n    QString fileAbsolutePath() const;\r\n\r\n    /*!\r\n     *  Starts the selected application and runs the file with it.\r\n     *\r\n     *    @param [in] applicationPath   Absolute path to the application executable.     \r\n     */\r\n    void runInApplication(QString const& applicationPath);\r\n\r\n    /*!\r\n     *  Checks if the item should be opened in Katus2 CSource editor.\r\n     *\r\n     *    @return True if the item should be opened, false otherwise.\r\n     */\r\n    virtual bool useKactusCSourceEditor() const;\r\n\r\n    /*!\r\n     *  Checks if an executable has been set for the file type.\r\n     *\r\n     *    @return True, if valid executable has been set, otherwise false.\r\n     */\r\n    bool runExecutableSet() const;\r\n\r\n    /*!\r\n     *  Gets the absolute path to the executable set for the file type.\r\n     *\r\n     *    @return The path to executable.\r\n     */\r\n    QString executablePath() const;\r\n\r\n    /*!\r\n     *  Finds all the environmental variables in a text and replaces them with the variable value.\r\n     *\r\n\t *    @param [in] text    The text to search through.\r\n     *\r\n     *    @return A text where variables have been replaced with their values.\r\n     */\r\n\tQString resolveEnvironmentVariables(QString const& text) const;\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! The file being edited.\r\n\tQSharedPointer<File> file_;\r\n\r\n    //! The validator for checking file validity.\r\n    QSharedPointer<FileValidator> validator_;\r\n\r\n    //! Action to open the file for editing with default editor.\r\n    QAction* editAction_;\r\n\r\n    //! Action to open the file for editing with a chosen editor.\r\n    QAction* editWithAction_;\r\n\r\n    //! Action to run the file for editing with an application.\r\n\tQAction* runAction_;\r\n\r\n\t//! Action to open the containing folder.\r\n\tQAction* openContainingFolderAction_;\r\n\r\n    //! The used expression parser.\r\n    QSharedPointer<ExpressionParser> expressionParser_;\r\n\r\n    //! Interface for accessing files.\r\n    FileInterface* fileInterface_;\r\n\r\n    //! List of available files.\r\n    QSharedPointer<QList<QSharedPointer<File> > > availableFiles_;\r\n};\r\n\r\n#endif // COMPONENTEDITORFILEITEM_H\r\n"
  },
  {
    "path": "editors/ComponentEditor/treeStructure/componenteditorfilesetitem.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: fileseteditor.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 10.05.2012\r\n//\r\n// Description:\r\n// The item for a single file set in the component editor's navigation tree.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"componenteditorfilesetitem.h\"\r\n#include \"componenteditorfileitem.h\"\r\n#include \"componenteditortreemodel.h\"\r\n\r\n#include <editors/ComponentEditor/fileSet/fileseteditor.h>\r\n#include <KactusAPI/include/FileSetInterface.h>\r\n\r\n#include <KactusAPI/include/LibraryInterface.h>\r\n#include <KactusAPI/include/FileHandler.h>\r\n\r\n#include <IPXACTmodels/Component/Component.h>\r\n#include <IPXACTmodels/Component/FileSet.h>\r\n#include <IPXACTmodels/Component/File.h>\r\n\r\n#include <IPXACTmodels/Component/validators/FileSetValidator.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditorFileSetItem::ComponentEditorFileSetItem()\r\n//-----------------------------------------------------------------------------\r\nComponentEditorFileSetItem::ComponentEditorFileSetItem(QSharedPointer<FileSet> fileSet,\r\n    ComponentEditorTreeModel* model, LibraryInterface* libHandler, QSharedPointer<Component> component,\r\n    QSharedPointer<ReferenceCounter> referenceCounter, QSharedPointer<ParameterFinder> parameterFinder,\r\n    QSharedPointer<ExpressionParser> expressionParser, QSharedPointer<ExpressionFormatter> expressionFormatter,\r\n    QSharedPointer<FileSetValidator> validator, QSharedPointer<FileValidator> fileValidator,\r\n    FileSetInterface* fileSetInterface, ComponentEditorItem* parent):\r\nComponentEditorItem(model, libHandler, component, parent),\r\nfileSet_(fileSet),\r\nfiles_(fileSet->getFiles()),\r\nfilesetValidator_(validator),\r\nfileValidator_(fileValidator),\r\nexpressionParser_(expressionParser),\r\nfileSetInterface_(fileSetInterface)\r\n{\r\n    setReferenceCounter(referenceCounter);\r\n    setParameterFinder(parameterFinder);\r\n    setExpressionFormatter(expressionFormatter);\r\n\r\n    int const childCount = files_->count();\r\n    for (int i = 0; i < childCount; i++)\r\n    {\r\n        ComponentEditorFileSetItem::createChild(i);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditorFileSetItem::text()\r\n//-----------------------------------------------------------------------------\r\nQString ComponentEditorFileSetItem::text() const\r\n{\r\n\treturn fileSet_->name();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditorFileSetItem::isValid()\r\n//-----------------------------------------------------------------------------\r\nbool ComponentEditorFileSetItem::isValid() const\r\n{\r\n \tif (!filesetValidator_->validate(fileSet_))\r\n    {\r\n \t\treturn false;\r\n \t}\r\n\r\n\t// check that the dependent directories exist\r\n\tQString xmlPath = libHandler_->getPath(component_->getVlnv());\r\n\r\n\tfor (QString const& relDirPath : *fileSet_->getDependencies())\r\n    {\r\n\t\tif (FileHandler::isValidURI(xmlPath, relDirPath) == false)\r\n        {\r\n\t\t\treturn false;\r\n\t\t}\r\n\t}\r\n\r\n\treturn ComponentEditorItem::isValid();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditorFileSetItem::editor()\r\n//-----------------------------------------------------------------------------\r\nItemEditor* ComponentEditorFileSetItem::editor()\r\n{\r\n\tif (!editor_)\r\n    {\r\n        editor_ = new FileSetEditor(libHandler_, component_, fileSet_, parameterFinder_, expressionParser_,\r\n            expressionFormatter_, fileSetInterface_, nullptr);\r\n        editor_->setProtection(locked_);\r\n        connect(editor_, SIGNAL(contentChanged()), this, SLOT(onEditorChanged()), Qt::UniqueConnection);\r\n        connect(editor_, SIGNAL(childAdded(int)), this, SLOT(onAddChild(int)), Qt::UniqueConnection);\r\n        connect(editor_, SIGNAL(childRemoved(int)), this, SLOT(onRemoveChild(int)), Qt::UniqueConnection);\r\n        connect(editor_, SIGNAL(childMoved(int, int)), this, SLOT(onMoveChild(int, int)), Qt::UniqueConnection);\r\n        connect(editor_, SIGNAL(helpUrlRequested(QString const&)), this, SIGNAL(helpUrlRequested(QString const&)));\r\n        connect(editor_, SIGNAL(childRemoved(int)), this, SIGNAL(childRemoved(int)), Qt::UniqueConnection);\r\n        connect(editor_, SIGNAL(fileRenamed(std::string const&, std::string const&)),\r\n            this, SIGNAL(fileRenamed(std::string const&, std::string const&)), Qt::UniqueConnection);\r\n\r\n        connectItemEditorToReferenceCounter();\r\n\t}\r\n\r\n\treturn editor_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditorFileSetItem::getTooltip()\r\n//-----------------------------------------------------------------------------\r\nQString ComponentEditorFileSetItem::getTooltip() const\r\n{\r\n\treturn tr(\"Contains a list of files and their build commands\");\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditorFileSetItem::createChild()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentEditorFileSetItem::createChild(int index)\r\n{\r\n    QSharedPointer<ComponentEditorFileItem> fileItem(new ComponentEditorFileItem(\r\n        files_->at(index), files_, fileSetInterface_->getFileInterface(), model_, libHandler_, component_,\r\n        fileValidator_, parameterFinder_, expressionParser_, referenceCounter_, this));\r\n\r\n    connect(fileItem.data(), SIGNAL(openCSource(QString const&, QSharedPointer<Component>)),\r\n            model_, SIGNAL(openCSource(QString const&, QSharedPointer<Component>)), Qt::UniqueConnection);\r\n    connect(this, SIGNAL(fileRenamed(std::string const&, std::string const&)),\r\n        fileItem.data(), SIGNAL(fileRenamed(std::string const&, std::string const&)), Qt::UniqueConnection);\r\n\r\n\tfileItem->setLocked(locked_);\r\n\tchildItems_.insert(index, fileItem);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditorFileSetItem::onFileAdded()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentEditorFileSetItem::onFileAdded(File* file)\r\n{\r\n    if (files_->at(files_->count() - 1) != file)\r\n    {\r\n        Q_ASSERT(false);\r\n    }\r\n\r\n    onAddChild(files_->count() - 1);\r\n    emit contentChanged();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditorFileSetItem::getFileSet()\r\n//-----------------------------------------------------------------------------\r\nFileSet const* ComponentEditorFileSetItem::getFileSet() const\r\n{\r\n    return fileSet_.data();\r\n}\r\n"
  },
  {
    "path": "editors/ComponentEditor/treeStructure/componenteditorfilesetitem.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: fileseteditor.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 10.05.2012\r\n//\r\n// Description:\r\n// The item for a single file set in the component editor's navigation tree.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef COMPONENTEDITORFILESETITEM_H\r\n#define COMPONENTEDITORFILESETITEM_H\r\n\r\n#include \"componenteditoritem.h\"\r\n\r\n#include <QSharedPointer>\r\n\r\nclass File;\r\nclass FileValidator;\r\nclass FileSet;\r\nclass FileSetValidator;\r\nclass LibraryInterface;\r\nclass ParameterFinder;\r\nclass ExpressionParser;\r\nclass ExpressionFormatter;\r\nclass ReferenceCounter;\r\nclass FileSetInterface;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! The item for a single file set in the component editor's navigation tree.\r\n//-----------------------------------------------------------------------------\r\nclass ComponentEditorFileSetItem : public ComponentEditorItem\r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\r\n\t/*!\r\n     *  The constructor.\r\n\t *\r\n\t *    @param [in] fileSet                 The file set being edited.\r\n\t *    @param [in] model                   The model that owns the items.\r\n\t *    @param [in] libHandler              The instance that manages the library.\r\n\t *    @param [in] component               The component being edited.\r\n     *    @param [in] referenceCounter        The counter for parameter references.\r\n     *    @param [in] parameterFinder         Finder used to identify parameters.\r\n     *    @param [in] expressionParser        Parser used to calculate expressions.\r\n     *    @param [in] expressionFormatter     Formatter used to format expressions.\r\n     *    @param [in] validator               The validator for checking file set validity.\r\n     *    @param [in] fileValidator           The validator for checking child item (file) validity.\r\n     *    @param [in] fileSetInterface        Interface for accessing file sets.\r\n\t *    @param [in] parent                  The parent item.\r\n     */\r\n    ComponentEditorFileSetItem(QSharedPointer<FileSet> fileSet,\r\n        ComponentEditorTreeModel* model,\r\n        LibraryInterface* libHandler,\r\n        QSharedPointer<Component> component,\r\n        QSharedPointer<ReferenceCounter> referenceCounter,\r\n        QSharedPointer<ParameterFinder> parameterFinder,\r\n        QSharedPointer<ExpressionParser> expressionParser,\r\n        QSharedPointer<ExpressionFormatter> expressionFormatter,\r\n        QSharedPointer<FileSetValidator> validator,\r\n        QSharedPointer<FileValidator> fileValidator,\r\n        FileSetInterface* fileSetInterface,\r\n        ComponentEditorItem* parent);\r\n\r\n    //! The destructor.\r\n\tvirtual ~ComponentEditorFileSetItem() = default;\r\n\r\n    //! No copying. No assignment.\r\n    ComponentEditorFileSetItem(const ComponentEditorFileSetItem& other) = delete;\r\n    ComponentEditorFileSetItem& operator=(const ComponentEditorFileSetItem& other) = delete;\r\n\r\n\t/*!\r\n     *  Get the tool tip for the item.\r\n\t * \r\n\t *    @return The text for the tool tip to print to user.\r\n\t */\r\n\tQString getTooltip() const final;\r\n\r\n\t/*!\r\n     *  Get the text to be displayed to user in the tree for this item.\r\n\t *\r\n\t *    @return QString Contains the text to display.\r\n\t */\r\n\tQString text() const final;\r\n\r\n\t/*!\r\n     *  Check the validity of this item and sub items.\r\n\t *\r\n\t *    @return bool True if item is in valid state.\r\n\t */\r\n\tbool isValid() const final;\r\n\r\n\t/*!\r\n     *  Get The editor of this item.\r\n\t *\r\n\t *    @return The editor to use for this item.\r\n\t */\r\n\tItemEditor* editor() final;\r\n\r\n\t/*!\r\n     *  Add a new child to the item.\r\n\t *\r\n\t *    @param [in] index   The index to add the child into.\r\n\t */\r\n\tvoid createChild(int index) final;\r\n\r\n    /*!\r\n     *  Handles the addition of a file outside the editor.\r\n     */\r\n    void onFileAdded(File* file);\r\n\r\n    /*!\r\n     *  Returns the file set corresponding to this item.\r\n     */\r\n    FileSet const* getFileSet() const;\r\n\r\nsignals:\r\n    \r\n    /*!\r\n     *  Indicates the removal of an item.\r\n     *\r\n     *    @param [in] index   The index of the removed item.\r\n     */\r\n    void childRemoved(int index);\r\n\r\n    /*!\r\n     *  Handle the name change of a file.\r\n     *\r\n     *    @param [in] oldName     Old name of the selected file.\r\n     *    @param [in] newName     The new name for the selected file.\r\n     */\r\n    void fileRenamed(std::string const& oldName, std::string const& newName);\r\n\r\nprivate:\r\n    \r\n\t//! The file set being edited.\r\n\tQSharedPointer<FileSet> fileSet_;\r\n\r\n\t//! Contains the files of the file set.\r\n    QSharedPointer<QList<QSharedPointer<File> > > files_;\r\n\r\n    //! The validator for checking file set validity.\r\n    QSharedPointer<FileSetValidator> filesetValidator_;\r\n\r\n    //! The validator for checking child validity.\r\n    QSharedPointer<FileValidator> fileValidator_;\r\n\r\n    //! Formatter used to change parameter ids to parameter names.\r\n    QSharedPointer<ExpressionParser> expressionParser_;\r\n\r\n    //! Interface for accessing file sets.\r\n    FileSetInterface* fileSetInterface_;\r\n};\r\n\r\n#endif // COMPONENTEDITORFILESETITEM_H\r\n"
  },
  {
    "path": "editors/ComponentEditor/treeStructure/componenteditorfilesetsitem.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: componenteditorfilesetsitem.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 09.05.2012\r\n//\r\n// Description:\r\n// The file sets-item in the component editor navigation tree.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"componenteditorfilesetsitem.h\"\r\n#include \"componenteditorfilesetitem.h\"\r\n\r\n#include <KactusAPI/include/IPXactSystemVerilogParser.h>\r\n\r\n#include <editors/ComponentEditor/fileSet/filesetseditor.h>\r\n#include <KactusAPI/include/FileInterface.h>\r\n#include <KactusAPI/include/FileSetInterface.h>\r\n#include <KactusAPI/include/FileBuilderInterface.h>\r\n\r\n#include <IPXACTmodels/Component/Component.h>\r\n#include <IPXACTmodels/Component/FileSet.h>\r\n#include <IPXACTmodels/Component/File.h>\r\n\r\n#include <IPXACTmodels/Component/validators/FileValidator.h>\r\n#include <IPXACTmodels/Component/validators/FileSetValidator.h>\r\n#include <IPXACTmodels/Component/validators/CollectionValidators.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: componenteditorfilesetsitem::ComponentEditorFileSetsItem()\r\n//-----------------------------------------------------------------------------\r\nComponentEditorFileSetsItem::ComponentEditorFileSetsItem(ComponentEditorTreeModel* model,\r\n        LibraryInterface* libHandler, QSharedPointer<Component> component,\r\n        QSharedPointer<ReferenceCounter> referenceCounter, QSharedPointer<ParameterFinder> parameterFinder,\r\n        QSharedPointer<ExpressionParser> expressionParser, QSharedPointer<ExpressionFormatter> expressionFormatter,\r\n        ComponentEditorItem* parent):\r\nComponentEditorItem(model, libHandler, component, parent),\r\nfileSets_(component->getFileSets()),\r\nexpressionParser_(expressionParser),\r\nfileValidator_(new FileValidator(expressionParser_)),\r\nfileSetValidator_(new FileSetValidator(fileValidator_, expressionParser_)),\r\nfileSetsValidator_(new FileSetsValidator(fileSetValidator_)),\r\nfileSetInterface_(0)\r\n{\r\n    setReferenceCounter(referenceCounter);\r\n    setParameterFinder(parameterFinder);\r\n    setExpressionFormatter(expressionFormatter);\r\n\r\n    constructFileSetInterface();\r\n\r\n\tforeach (QSharedPointer<FileSet> fileSet, *fileSets_)\r\n    {\r\n        QSharedPointer<ComponentEditorFileSetItem> fileSetItem(new ComponentEditorFileSetItem(\r\n            fileSet, model, libHandler, component, referenceCounter, parameterFinder, expressionParser_,\r\n            expressionFormatter, fileSetValidator_, fileValidator_, fileSetInterface_, this));\r\n\r\n        connect(fileSetItem.data(), SIGNAL(childRemoved(int)),\r\n                this, SIGNAL(refreshDependencyModel()), Qt::UniqueConnection);\r\n\r\n\t\tchildItems_.append(fileSetItem);\r\n\t}\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: componenteditorfilesetsitem::~ComponentEditorFileSetsItem()\r\n//-----------------------------------------------------------------------------\r\nComponentEditorFileSetsItem::~ComponentEditorFileSetsItem()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: componenteditorfilesetsitem::getFont()\r\n//-----------------------------------------------------------------------------\r\nQFont ComponentEditorFileSetsItem::getFont() const\r\n{\r\n    QFont font(ComponentEditorItem::getFont());\r\n    font.setBold(!fileSets_->isEmpty());\r\n    return font;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: componenteditorfilesetsitem::text()\r\n//-----------------------------------------------------------------------------\r\nQString ComponentEditorFileSetsItem::text() const\r\n{ \r\n\treturn tr(\"File sets\");\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: componenteditorfilesetsitem::editor()\r\n//-----------------------------------------------------------------------------\r\nItemEditor* ComponentEditorFileSetsItem::editor()\r\n{\r\n\tif (!editor_)\r\n    {\r\n        editor_ = new FileSetsEditor(component_, libHandler_, parameterFinder_, fileSetInterface_);\r\n        editor_->setProtection(locked_);\r\n\t\tconnect(editor_, SIGNAL(fileAdded(File*)), this, SLOT(onFileAdded(File*)), Qt::UniqueConnection);\r\n\t\tconnect(editor_, SIGNAL(contentChanged()), this, SLOT(onEditorChanged()), Qt::UniqueConnection);\r\n        connect(editor_, SIGNAL(dependenciesChanged()), this, SIGNAL(contentChanged()), Qt::UniqueConnection);\r\n\t\tconnect(editor_, SIGNAL(childAdded(int)), this, SLOT(onAddChild(int)), Qt::UniqueConnection);\r\n\t\tconnect(editor_, SIGNAL(childRemoved(int)), this, SLOT(onRemoveChild(int)), Qt::UniqueConnection);\r\n\t\tconnect(editor_, SIGNAL(helpUrlRequested(QString const&)), this, SIGNAL(helpUrlRequested(QString const&)));\r\n\r\n        connect(this, SIGNAL(refreshDependencyModel()),\r\n            editor_, SLOT(refreshDependencyModel()), Qt::UniqueConnection);\r\n\r\n        connectItemEditorToReferenceCounter();\r\n\t}\r\n\treturn editor_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: componenteditorfilesetsitem::getTooltip()\r\n//-----------------------------------------------------------------------------\r\nQString ComponentEditorFileSetsItem::getTooltip() const\r\n{\r\n\treturn tr(\"Contains the file sets of the component\");\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: componenteditorfilesetsitem::createChild()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentEditorFileSetsItem::createChild(int index)\r\n{\r\n\tQSharedPointer<ComponentEditorFileSetItem> fileSetItem(new ComponentEditorFileSetItem(\r\n        fileSets_->at(index), model_, libHandler_, component_, referenceCounter_, parameterFinder_,\r\n        expressionParser_, expressionFormatter_, fileSetValidator_, fileValidator_, fileSetInterface_, this));\r\n\r\n    connect(fileSetItem.data(), SIGNAL(childRemoved(int)),\r\n        this, SIGNAL(refreshDependencyModel()), Qt::UniqueConnection);\r\n\r\n\tfileSetItem->setLocked(locked_);\r\n\tchildItems_.insert(index, fileSetItem);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditorFileSetsItem::isValid()\r\n//-----------------------------------------------------------------------------\r\nbool ComponentEditorFileSetsItem::isValid() const\r\n{\r\n    auto fileSetsAsNameGroups = CollectionValidators::itemListToNameGroupList(fileSets_);\r\n    fileSetsValidator_->childrenHaveUniqueNames(fileSetsAsNameGroups);\r\n    return ComponentEditorItem::isValid();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditorFileSetsItem::onFileAdded()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentEditorFileSetsItem::onFileAdded(File* file)\r\n{\r\n    for (QSharedPointer<ComponentEditorItem> item : childItems_)\r\n    {\r\n        QSharedPointer<ComponentEditorFileSetItem> fileSetItem = item.dynamicCast<ComponentEditorFileSetItem>();\r\n        Q_ASSERT(fileSetItem != 0);\r\n\r\n        if (isParentFileSet(file, fileSetItem->getFileSet()))\r\n        {\r\n            fileSetItem->onFileAdded(file);\r\n            break;\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: componenteditorfilesetsitem::isParentFileSet()\r\n//-----------------------------------------------------------------------------\r\nbool ComponentEditorFileSetsItem::isParentFileSet(File* file, const FileSet* fileset) const\r\n{\r\n    for (QSharedPointer<File> containedFile : *fileset->getFiles())\r\n    {\r\n        if (file == containedFile.data())\r\n        {\r\n            return true;\r\n        }\r\n    }\r\n\r\n    return false;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditorFileSetsItem::constructFileSetInterface()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentEditorFileSetsItem::constructFileSetInterface()\r\n{\r\n    FileInterface* fileInterface = new FileInterface(fileValidator_, expressionParser_, expressionFormatter_);\r\n    FileBuilderInterface* fileBuilderInterface = new FileBuilderInterface(expressionParser_, expressionFormatter_);\r\n\r\n    fileSetInterface_ = new FileSetInterface(\r\n        fileSetValidator_, expressionParser_, expressionFormatter_, fileInterface, fileBuilderInterface);\r\n}\r\n"
  },
  {
    "path": "editors/ComponentEditor/treeStructure/componenteditorfilesetsitem.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: componenteditorfilesetsitem.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 09.05.2012\r\n//\r\n// Description:\r\n// The file sets-item in the component editor navigation tree.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef COMPONENTEDITORFILESETSITEM_H\r\n#define COMPONENTEDITORFILESETSITEM_H\r\n\r\n#include \"componenteditoritem.h\"\r\n\r\n#include <QSharedPointer>\r\n\r\nclass Component;\r\nclass ExpressionParser;\r\nclass FileSet;\r\nclass File;\r\nclass FileValidator;\r\nclass FileSetValidator;\r\nclass FileSetsValidator;\r\nclass ParameterFinder;\r\nclass ReferenceCounter;\r\nclass ExpressionParser;\r\nclass ParameterFinder;\r\nclass ExpressionFormatter;\r\nclass FileSetInterface;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! The file sets-item in the component editor navigation tree.\r\n//-----------------------------------------------------------------------------\r\nclass ComponentEditorFileSetsItem : public ComponentEditorItem\r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\r\n\t/*!\r\n     *  The constructor.\r\n\t *\r\n\t *    @param [in] model                   The model that owns the items.\r\n\t *    @param [in] libHandler              The instance that manages the library.\r\n\t *    @param [in] component               The component being edited.\r\n     *    @param [in] referenceCounter        The counter for parameter references.\r\n     *    @param [in] parameterFinder         Finder used to identify parameters.\r\n     *    @param [in] expressionParser        Parser used to calculate expressions.\r\n     *    @param [in] expressionFormatter     Formatter used to format expressions.\r\n     *    @param [in] parameterFinder         The finder for component parameters.\r\n\t *    @param [in] parent                  The parent item.\r\n\t */\r\n    ComponentEditorFileSetsItem(ComponentEditorTreeModel* model, LibraryInterface* libHandler,\r\n        QSharedPointer<Component> component,\r\n        QSharedPointer<ReferenceCounter> referenceCounter, QSharedPointer<ParameterFinder> parameterFinder,\r\n        QSharedPointer<ExpressionParser> expressionParser, QSharedPointer<ExpressionFormatter> expressionFormatter,\r\n        ComponentEditorItem* parent);\r\n\r\n\t//! The destructor.\r\n\tvirtual ~ComponentEditorFileSetsItem();\r\n\r\n    /*!\r\n     *  Get the font to be used for text of this item.\r\n\t *\r\n\t *    @return QFont instance that defines the font to be used.\r\n\t */\r\n\tvirtual QFont getFont() const;\r\n\r\n\t/*!\r\n     *  Get the tool tip for the item.\r\n\t * \r\n\t *    @return The text for the tool tip to print to user.\r\n\t */\r\n\tvirtual QString getTooltip() const;\r\n\r\n\t/*!\r\n     *  Get the text to be displayed to user in the tree for this item.\r\n\t *\r\n\t *    @return QString Contains the text to display.\r\n\t */\r\n\tvirtual QString text() const;\r\n\r\n\t/*!\r\n     *  Get The editor of this item.\r\n\t *\r\n\t *    @return The editor to use for this item.\r\n\t */\r\n\tvirtual ItemEditor* editor();\r\n\r\n\t/*!\r\n     *  Add a new child to the item.\r\n\t *\r\n\t *    @param [in] index   The index to add the child into.\r\n\t */\r\n\tvirtual void createChild(int index);\r\n\r\n    /*!\r\n     *  Check the validity of this item.\r\n     *\r\n     *    @return bool True if item is in valid state.\r\n     */\r\n    bool isValid() const override;\r\n\r\nsignals:\r\n\r\n    //! Emitted when the dependency model should be refreshed.\r\n    void refreshDependencyModel();\r\n\r\nprivate slots:\r\n    /*!\r\n     *  Handles the addition of a file outside the file set editor.\r\n     */\r\n    void onFileAdded(File* file);\r\n\r\nprivate:\r\n\r\n    //! No copying. No assignment.\r\n    ComponentEditorFileSetsItem(const ComponentEditorFileSetsItem& other);\r\n    ComponentEditorFileSetsItem& operator=(const ComponentEditorFileSetsItem& other);\r\n\r\n    /*!\r\n     *  Check if the selected file set contains the selected file.\r\n     *\r\n     *    @param [in] file        The selected file.\r\n     *    @param [in] fileset     The selected file set.\r\n     *\r\n     *    @return True, if the file set contains the file, false otherwise.\r\n     */\r\n    bool isParentFileSet(File* file, const FileSet* fileset) const;\r\n\r\n    /*!\r\n     *  Construct the interfaces for the file sets.\r\n     */\r\n    void constructFileSetInterface();\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n\t//! The file sets to edit.\r\n    QSharedPointer<QList<QSharedPointer<FileSet> > > fileSets_;\r\n\r\n    //! Expression parser for filesets and files.\r\n    QSharedPointer<ExpressionParser> expressionParser_;\r\n\r\n    //! Validator for file items.\r\n    QSharedPointer<FileValidator> fileValidator_;\r\n\r\n    //! Validator for file set items.\r\n    QSharedPointer<FileSetValidator> fileSetValidator_;\r\n\r\n    //! Validator for all filesets of the component.\r\n    QSharedPointer<FileSetsValidator> fileSetsValidator_;\r\n\r\n    //! Interface for accessing file sets.\r\n    FileSetInterface* fileSetInterface_;\r\n};\r\n\r\n#endif // COMPONENTEDITORFILESETSITEM_H\r\n"
  },
  {
    "path": "editors/ComponentEditor/treeStructure/componenteditorgeneralitem.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: componenteditortreemodel.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 09.05.2012\r\n//\r\n// Description:\r\n// The general-item in the component editor navigation tree.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"componenteditorgeneralitem.h\"\r\n\r\n#include <editors/ComponentEditor/general/generaleditor.h>\r\n\r\n#include <common/widgets/componentPreviewBox/ComponentPreviewBox.h>\r\n\r\n#include <IPXACTmodels/Component/Component.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: componenteditorgeneralitem::ComponentEditorGeneralItem()\r\n//-----------------------------------------------------------------------------\r\nComponentEditorGeneralItem::ComponentEditorGeneralItem( ComponentEditorTreeModel* model,\r\n    LibraryInterface* libHandler, QSharedPointer<Component> component, ComponentEditorItem* parent ):\r\nComponentEditorItem(model, libHandler, component, parent),\r\npreviewBox_(new ComponentPreviewBox(libHandler, nullptr))\r\n{\r\n    previewBox_->setInteractive(true);\r\n    previewBox_->setComponent(component);\r\n\r\n    connect(previewBox_, SIGNAL(endpointsRearranged()), this, SLOT(onEditorChanged()), Qt::UniqueConnection);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: componenteditorgeneralitem::text()\r\n//-----------------------------------------------------------------------------\r\nQString ComponentEditorGeneralItem::text() const\r\n{\r\n\treturn tr(\"General\");\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditorGeneralItem::getFont()\r\n//-----------------------------------------------------------------------------\r\nQFont ComponentEditorGeneralItem::getFont() const\r\n{\r\n    QFont font(ComponentEditorItem::getFont());\r\n    font.setBold(true);\r\n    return font;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: componenteditorgeneralitem::isValid()\r\n//-----------------------------------------------------------------------------\r\nbool ComponentEditorGeneralItem::isValid() const\r\n{\r\n\t// general editor is always valid because it contains no mandatory elements\r\n\treturn true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: componenteditorgeneralitem::editor()\r\n//-----------------------------------------------------------------------------\r\nItemEditor* ComponentEditorGeneralItem::editor()\r\n{\r\n\tif (!editor_)\r\n    {\r\n\t\teditor_ = new GeneralEditor(libHandler_, component_);\r\n\t\teditor_->setProtection(locked_);\r\n\t\tconnect(editor_, SIGNAL(contentChanged()), this, SLOT(onEditorChanged()), Qt::UniqueConnection);\r\n\t\tconnect(editor_, SIGNAL(helpUrlRequested(QString const&)), this, SIGNAL(helpUrlRequested(QString const&)));\r\n\r\n        connectItemEditorToVendorExtensionsEditor();\r\n\t}\r\n\treturn editor_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: componenteditorgeneralitem::visualizer()\r\n//-----------------------------------------------------------------------------\r\nItemVisualizer* ComponentEditorGeneralItem::visualizer()\r\n{\r\n\treturn previewBox_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: componenteditorgeneralitem::refreshEditor()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentEditorGeneralItem::refreshEditor()\r\n{\r\n\tComponentEditorItem::refreshEditor();\r\n\tpreviewBox_->updatePreview();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: componenteditorgeneralitem::getTooltip()\r\n//-----------------------------------------------------------------------------\r\nQString ComponentEditorGeneralItem::getTooltip() const\r\n{\r\n\treturn tr(\"Contains the general settings of a component\");\r\n}\r\n"
  },
  {
    "path": "editors/ComponentEditor/treeStructure/componenteditorgeneralitem.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: componenteditortreemodel.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 09.05.2012\r\n//\r\n// Description:\r\n// The general-item in the component editor navigation tree.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef COMPONENTEDITORGENERALITEM_H\r\n#define COMPONENTEDITORGENERALITEM_H\r\n\r\n#include \"componenteditoritem.h\"\r\n\r\n#include <QSharedPointer>\r\n#include <QString>\r\n\r\nclass ComponentEditorTreeModel;\r\nclass ItemEditor;\r\nclass Component;\r\nclass ComponentPreviewBox;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! The general-item in the component editor navigation tree.\r\n//-----------------------------------------------------------------------------\r\nclass ComponentEditorGeneralItem : public ComponentEditorItem\r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\r\n\t/*!\r\n     *  The constructor.\r\n\t *\r\n\t *    @param [in] model       Pointer to the model that owns the items.\r\n\t *    @param [in] libHandler  Pointer to the instance that manages the library.\r\n\t *    @param [in] component   Pointer to the component being edited.\r\n\t *    @param [in] parent      Pointer to the parent item.\r\n\t */\r\n\tComponentEditorGeneralItem(ComponentEditorTreeModel* model, LibraryInterface* libHandler,\r\n        QSharedPointer<Component> component, ComponentEditorItem* parent);\r\n\r\n\t//! The destructor.\r\n\t~ComponentEditorGeneralItem() override = default;\r\n\r\n    //! No copying. No assignment. No mercy.\r\n    ComponentEditorGeneralItem(const ComponentEditorGeneralItem& other) = delete;\r\n    ComponentEditorGeneralItem& operator=(const ComponentEditorGeneralItem& other) = delete;\r\n\r\n\t/*!\r\n     *  Get the tool tip for the item.\r\n\t * \r\n\t *    @return The text for the tool tip to print to user.\r\n\t */\r\n\tvirtual QString getTooltip() const;\r\n\r\n\t/*!\r\n     *  Get the text to be displayed to user in the tree for this item.\r\n\t *\r\n\t *    @return QString Contains the text to display.\r\n\t */\r\n\tvirtual QString text() const;\r\n\r\n\t/*!\r\n     *  Get the font to be used for text of this item.\r\n\t *\r\n\t *    @return QFont instance that defines the font to be used.\r\n\t */\r\n    virtual QFont getFont() const;\r\n\r\n\t/*!\r\n     *  Check the validity of this item and sub items.\r\n\t *\r\n\t *    @return bool True if item is in valid state.\r\n\t */\r\n\tvirtual bool isValid() const;\r\n\r\n\t/*!\r\n     *  Get pointer to the editor of this item.\r\n\t *\r\n\t *    @return Pointer to the editor to use for this item.\r\n\t */\r\n\tvirtual ItemEditor* editor();\r\n\r\n\t/*!\r\n\t *  Get pointer to the visualizer of this item.\r\n\t *\r\n\t *    @return Pointer to the visualizer to use for this item.\r\n\t */\r\n\tItemVisualizer* visualizer() override;\r\n\r\n\t/*!\r\n\t *  Refresh the contents of the editor associated with this item.\r\n\t */\r\n\tvoid refreshEditor() override;\r\n\r\nprivate:\r\n\r\n\t//! Component preview for visualization.\r\n\tComponentPreviewBox* previewBox_;\r\n};\r\n\r\n#endif // COMPONENTEDITORGENERALITEM_H\r\n"
  },
  {
    "path": "editors/ComponentEditor/treeStructure/componenteditorgroupslot.cpp",
    "content": "/* \r\n *  \tCreated on: 21.5.2012\r\n *      Author: Antti Kamppi\r\n * \t\tfilename: componenteditorgroupslot.cpp\r\n *\t\tProject: Kactus2\r\n */\r\n\r\n#include \"componenteditorgroupslot.h\"\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditorGroupSlot::ComponentEditorGroupSlot()\r\n//-----------------------------------------------------------------------------\r\nComponentEditorGroupSlot::ComponentEditorGroupSlot(QWidget* parent):\r\nQWidget(parent),\r\nlayout_(this),\r\ncurrentWidget_(NULL)\r\n{\r\n\tlayout_.setContentsMargins(0, 0, 0, 0);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditorGroupSlot::~ComponentEditorGroupSlot()\r\n//-----------------------------------------------------------------------------\r\nComponentEditorGroupSlot::~ComponentEditorGroupSlot()\r\n{\r\n\tif (currentWidget_)\r\n    {\r\n\t\tcurrentWidget_->hide();\r\n\t\tlayout_.removeWidget(currentWidget_);\r\n\t\tcurrentWidget_->setParent(NULL);\r\n\t\tcurrentWidget_ = NULL;\r\n\t}\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditorGroupSlot::setWidget()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentEditorGroupSlot::setWidget(QWidget* widget)\r\n{\r\n    if (widget != currentWidget_)\r\n    {\r\n        // if there is a previous widget being displayed\r\n        if (currentWidget_) \r\n        {\r\n            // set the previous widget to hidden\r\n            currentWidget_->hide();\r\n\r\n            // remove this widget as the parent of the widget\r\n            currentWidget_->setParent(NULL);\r\n\r\n            // remove the previous because only one widget can be displayed at a time.\r\n            layout_.removeWidget(currentWidget_);\r\n        }\r\n\r\n        // update the current widget and display it\r\n        currentWidget_ = widget;\r\n\r\n        // TODO remove this and replace with Q_ASSERT(widget)\r\n        if (currentWidget_)\r\n        {\r\n            layout_.addWidget(currentWidget_);\r\n            currentWidget_->show();\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditorGroupSlot::getWidget()\r\n//-----------------------------------------------------------------------------\r\nQWidget* ComponentEditorGroupSlot::getWidget() const\r\n{\r\n\treturn currentWidget_;\r\n}\r\n"
  },
  {
    "path": "editors/ComponentEditor/treeStructure/componenteditorgroupslot.h",
    "content": "/* \r\n *  \tCreated on: 21.5.2012\r\n *      Author: Antti Kamppi\r\n * \t\tfilename: componenteditorgroupslot.h\r\n *\t\tProject: Kactus2\r\n */\r\n\r\n#ifndef COMPONENTEDITORGROUPSLOT_H\r\n#define COMPONENTEDITORGROUPSLOT_H\r\n\r\n#include <QWidget>\r\n#include <QHBoxLayout>\r\n\r\nclass ComponentEditorGroupSlot : public QWidget {\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\r\n\t/*! \\brief The constructor\r\n\t * \r\n\t * \\param parent Pointer to the owner of the group slot.\r\n\t * \\param title The title for the group box.\r\n\t *\r\n\t*/\r\n\tComponentEditorGroupSlot(QWidget *parent);\r\n\t\r\n\t//! \\brief The destructor\r\n\t~ComponentEditorGroupSlot();\r\n\r\n\t/*! \\brief Set the widget to be displayed inside the group slot.\r\n\t *\r\n\t * \\param widget Pointer to the widget to display.\r\n\t *\r\n\t*/\r\n\tvoid setWidget(QWidget* widget);\r\n\r\n\t/*! \\brief Get the widget currently displayed inside the group slot.\r\n\t *\r\n\t * \\return Pointer to the widget being displayed.\r\n\t*/\r\n\tQWidget* getWidget() const;\r\n\r\nprivate:\r\n\t\r\n\t//! \\brief No copying\r\n\tComponentEditorGroupSlot(const ComponentEditorGroupSlot& other);\r\n\r\n\t//! \\brief No assignment\r\n\tComponentEditorGroupSlot& operator=(const ComponentEditorGroupSlot& other);\r\n\r\n\t//! \\brief The layout for the group slot.\r\n\tQHBoxLayout layout_;\r\n\r\n\t//! \\brief The currently displayed widget.\r\n\tQWidget* currentWidget_;\r\n};\r\n\r\n#endif // COMPONENTEDITORGROUPSLOT_H\r\n"
  },
  {
    "path": "editors/ComponentEditor/treeStructure/componenteditoritem.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: componenteditoritem.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 07.05.2012\r\n//\r\n// Description:\r\n// ComponentEditorItem is one item in the navigation tree in component editor.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"componenteditoritem.h\"\r\n#include \"componenteditortreemodel.h\"\r\n\r\n#include <editors/ComponentEditor/itemeditor.h>\r\n#include <editors/ComponentEditor/itemvisualizer.h>\r\n\r\n#include <KactusAPI/include/LibraryInterface.h>\r\n\r\n#include <IPXACTmodels/Component/Component.h>\r\n#include <IPXACTmodels/Component/validators/CollectionValidators.h>\r\n\r\n#include <QApplication>\r\n#include <QIcon>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: componenteditoritem::ComponentEditorItem()\r\n//-----------------------------------------------------------------------------\r\nComponentEditorItem::ComponentEditorItem(ComponentEditorTreeModel* model,\r\n\tLibraryInterface* libHandler,\r\n\tQSharedPointer<Component> component,\r\n\tComponentEditorItem* parent) :\r\n\tQObject(parent),\r\n\tlibHandler_(libHandler),\r\n\tcomponent_(component),\r\n\tmodel_(model),\r\n\tparent_(parent)\r\n{\r\n\r\n\tconnect(this, SIGNAL(contentChanged(ComponentEditorItem*)),\r\n\t\tmodel, SLOT(onContentChanged(ComponentEditorItem*)), Qt::UniqueConnection);\r\n\tconnect(this, SIGNAL(contentChanged()),\r\n\t\tmodel, SIGNAL(contentChanged()), Qt::UniqueConnection);\r\n\r\n\tconnect(this, SIGNAL(createChild(ComponentEditorItem*, int)),\r\n\t\tmodel, SLOT(addItem(ComponentEditorItem*, int)), Qt::UniqueConnection);\r\n\tconnect(this, SIGNAL(removeChild(ComponentEditorItem*, int)),\r\n\t\tmodel, SLOT(removeItem(ComponentEditorItem*, int)), Qt::UniqueConnection);\r\n\tconnect(this, SIGNAL(moveChild(ComponentEditorItem*, int, int)),\r\n\t\tmodel, SLOT(moveItem(ComponentEditorItem*, int, int)), Qt::UniqueConnection);\r\n\r\n\tconnect(this, SIGNAL(selectItem(ComponentEditorItem*)),\r\n\t\tmodel, SLOT(onSelectItem(ComponentEditorItem*)), Qt::UniqueConnection);\r\n\r\n\tconnect(this, SIGNAL(helpUrlRequested(QString const&)),\r\n\t\tmodel, SIGNAL(helpUrlRequested(QString const&)), Qt::UniqueConnection);\r\n\tconnect(this, SIGNAL(errorMessage(const QString&)),\r\n\t\tmodel, SIGNAL(errorMessage(const QString&)), Qt::UniqueConnection);\r\n\r\n\tconnect(this, SIGNAL(openDesign(const VLNV&, const QString&)),\r\n\t\tmodel, SIGNAL(openDesign(const VLNV&, const QString&)), Qt::UniqueConnection);\r\n\tconnect(this, SIGNAL(openSWDesign(const VLNV&, const QString&)),\r\n\t\tmodel, SIGNAL(openSWDesign(const VLNV&, const QString&)), Qt::UniqueConnection);\r\n\tconnect(this, SIGNAL(openSystemDesign(const VLNV&, const QString&)),\r\n\t\tmodel, SIGNAL(openSystemDesign(const VLNV&, const QString&)), Qt::UniqueConnection);\r\n\tconnect(this, SIGNAL(openBus(const VLNV&)),\r\n\t\tmodel, SIGNAL(openBus(const VLNV&)), Qt::UniqueConnection);\r\n\tconnect(this, SIGNAL(openAbsDef(const VLNV&)),\r\n\t\tmodel, SIGNAL(openAbsDef(const VLNV&)), Qt::UniqueConnection);\r\n\tconnect(this, SIGNAL(openComDefinition(const VLNV&)),\r\n\t\tmodel, SIGNAL(openComDefinition(const VLNV&)), Qt::UniqueConnection);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: componenteditoritem::ComponentEditorItem()\r\n//-----------------------------------------------------------------------------\r\nComponentEditorItem::ComponentEditorItem(LibraryInterface* libHandler,\r\n\tQSharedPointer<Component> component,\r\n\tComponentEditorTreeModel* parent) :\r\n\tQObject(parent),\r\n\tlibHandler_(libHandler),\r\n\tcomponent_(component),\r\n\tmodel_(parent)\r\n{\r\n\tconnect(this, SIGNAL(contentChanged(ComponentEditorItem*)),\r\n\t\tparent, SLOT(onContentChanged(ComponentEditorItem*)), Qt::UniqueConnection);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: componenteditoritem::~ComponentEditorItem()\r\n//-----------------------------------------------------------------------------\r\nComponentEditorItem::~ComponentEditorItem()\r\n{\r\n\tif (editor_)\r\n\t{\r\n\t\teditor_->deleteLater();\r\n\t\teditor_ = nullptr;\r\n\t}\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: componenteditoritem::row()\r\n//-----------------------------------------------------------------------------\r\nint ComponentEditorItem::row() const\r\n{\r\n\tif (parent_)\r\n\t{\r\n\t\treturn parent_->getIndexOf(this);\r\n\t}\r\n\treturn -1;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: componenteditoritem::getIndexOf()\r\n//-----------------------------------------------------------------------------\r\nint ComponentEditorItem::getIndexOf(const ComponentEditorItem* child) const\r\n{\r\n\tfor (int i = 0; i < childItems_.size(); ++i)\r\n\t{\r\n\t\tif (childItems_.at(i).data() == child)\r\n\t\t{\r\n\t\t\treturn i;\r\n\t\t}\r\n\t}\r\n\treturn -1;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: componenteditoritem::rowCount()\r\n//-----------------------------------------------------------------------------\r\nint ComponentEditorItem::rowCount() const\r\n{\r\n\treturn childItems_.count();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: componenteditoritem::hasChildren()\r\n//-----------------------------------------------------------------------------\r\nbool ComponentEditorItem::hasChildren() const\r\n{\r\n\treturn !childItems_.isEmpty();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: componenteditoritem::child()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<ComponentEditorItem> ComponentEditorItem::child(const int index)\r\n{\r\n\tif (index < 0 || childItems_.count() < index)\r\n\t{\r\n\t\treturn QSharedPointer<ComponentEditorItem>();\r\n\t}\r\n\r\n\treturn childItems_.at(index);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: componenteditoritem::parent()\r\n//-----------------------------------------------------------------------------\r\nComponentEditorItem* ComponentEditorItem::parent()\r\n{\r\n\treturn parent_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: componenteditoritem::getFont()\r\n//-----------------------------------------------------------------------------\r\nQFont ComponentEditorItem::getFont() const\r\n{\r\n\treturn QApplication::font();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: componenteditoritem::isValid()\r\n//-----------------------------------------------------------------------------\r\nbool ComponentEditorItem::isValid() const\r\n{\r\n\t// if at least one child is not valid then this is not valid\r\n\treturn std::all_of(childItems_.cbegin(), childItems_.cend(),\r\n\t\t[](auto const& childItem) { return childItem->isValid(); });\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditorItem::isModified()\r\n//-----------------------------------------------------------------------------\r\nbool ComponentEditorItem::isModified() const\r\n{\r\n\treturn modified_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: componenteditoritem::clearModified()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentEditorItem::clearModified()\r\n{\r\n\tbool changed = modified_;\r\n\r\n\tmodified_ = false;\r\n\r\n\tfor (auto const& child : childItems_)\r\n\t{\r\n\t\tchild->clearModified();\r\n\t}\r\n\r\n\tif (changed)\r\n\t{\r\n\t\temit contentChanged(this);\r\n\t}\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: componenteditoritem::setModified()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentEditorItem::setModified()\r\n{\r\n\tmodified_ = true;\r\n\r\n\tif (parent_)\r\n\t{\r\n\t\tparent_->setModified();\r\n\t}\r\n}\r\n//-----------------------------------------------------------------------------\r\n// Function: componenteditoritem::visualizer()\r\n//-----------------------------------------------------------------------------\r\nItemVisualizer* ComponentEditorItem::visualizer()\r\n{\r\n\treturn nullptr;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditorItem::onEditorChanged()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentEditorItem::onEditorChanged()\r\n{\r\n\tsetModified();\r\n\r\n\t// if there is a valid parent then update it also\r\n\tif (parent_)\r\n\t{\r\n\t\temit contentChanged(parent_);\r\n\t}\r\n\r\n\t// update this item\r\n\temit contentChanged(this);\r\n\r\n\tfor (auto const& childItem : childItems_)\r\n\t{\r\n\t\temit contentChanged(childItem.data());\r\n\t}\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditorItem::onGraphicsChanged()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentEditorItem::onGraphicsChanged()\r\n{\r\n\tQApplication::setOverrideCursor(Qt::WaitCursor);\r\n\tfor (auto const& childItem : childItems_)\r\n\t{\r\n\t\tchildItem->updateGraphics();\r\n\t}\r\n\r\n\tupdateGraphics();\r\n\tQApplication::restoreOverrideCursor();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditorItem::setLocked()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentEditorItem::setLocked(bool locked)\r\n{\r\n\t// if this item contains an editor\r\n\tif (editor_)\r\n\t{\r\n\t\teditor_->setProtection(locked);\r\n\t}\r\n\r\n\t// also tell child items\r\n\tfor (auto const& childItem : childItems_)\r\n\t{\r\n\t\tchildItem->setLocked(locked);\r\n\t}\r\n\r\n\tlocked_ = locked;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: componenteditoritem::refreshEditor()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentEditorItem::refreshEditor()\r\n{\r\n\tif (editor_)\r\n\t{\r\n\t\teditor_->refresh();\r\n\t}\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: componenteditoritem::onAddChild()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentEditorItem::onAddChild(int index)\r\n{\r\n\temit createChild(this, index);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: componenteditoritem::onRemoveChild()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentEditorItem::onRemoveChild(int index)\r\n{\r\n\temit removeChild(this, index);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: componenteditoritem::onMoveChild()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentEditorItem::onMoveChild(int source, int target)\r\n{\r\n\temit moveChild(this, source, target);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: componenteditoritem::moveChild()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentEditorItem::moveChild(const int sourceIndex, int targetIndex)\r\n{\r\n\t// if the source index can not be used to identify an item\r\n\tif (sourceIndex < 0 || sourceIndex >= childItems_.count())\r\n\t{\r\n\t\treturn;\r\n\t}\r\n\r\n\t// Take the item from the list\r\n\tQSharedPointer<ComponentEditorItem> itemToMove = childItems_.takeAt(sourceIndex);\r\n\r\n\tchildItems_.insert(targetIndex, itemToMove);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: componenteditoritem::createChild()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentEditorItem::createChild(int /*index*/)\r\n{\r\n\t// This must be implemented in sub classes to create the correct type of child.\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: componenteditoritem::removeChild()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentEditorItem::removeChild(int index)\r\n{\r\n\tQ_ASSERT(index >= 0);\r\n\tQ_ASSERT(index < childItems_.size());\r\n\r\n\t// first tell the child to remove the graphics item\r\n\tchildItems_[index]->removeGraphicsItem();\r\n\r\n\t// then the child can be removed\r\n\tchildItems_.removeAt(index);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: componenteditoritem::canBeOpened()\r\n//-----------------------------------------------------------------------------\r\nbool ComponentEditorItem::canBeOpened() const\r\n{\r\n\t// Normally items can't be opened\r\n\treturn false;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: componenteditoritem::openItem()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentEditorItem::openItem()\r\n{\r\n\t// Normally items can't be opened\r\n\treturn;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditorItem::actions()\r\n//-----------------------------------------------------------------------------\r\nQList<QAction* > ComponentEditorItem::actions()\r\n{\r\n\treturn QList<QAction*>();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: componenteditoritem::getGraphicsItem()\r\n//-----------------------------------------------------------------------------\r\nQGraphicsItem* ComponentEditorItem::getGraphicsItem()\r\n{\r\n\treturn nullptr;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: componenteditoritem::updateGraphics()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentEditorItem::updateGraphics()\r\n{\r\n\treturn;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: componenteditoritem::removeGraphicsItem()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentEditorItem::removeGraphicsItem()\r\n{\r\n\treturn;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: componenteditoritem::hasIcon()\r\n//-----------------------------------------------------------------------------\r\nbool ComponentEditorItem::hasIcon() const\r\n{\r\n\t// Normally items have no icon.\r\n\treturn false;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: componenteditoritem::getIcon()\r\n//-----------------------------------------------------------------------------\r\nQIcon ComponentEditorItem::getIcon() const\r\n{\r\n\t// Normally items have no default icon.\r\n\treturn QIcon();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: componenteditoritem::onSelectRequest()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentEditorItem::onSelectRequest()\r\n{\r\n\temit selectItem(this);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: componenteditoritem::setReferenceCounter()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentEditorItem::setReferenceCounter(QSharedPointer<ReferenceCounter> newReferenceCounter)\r\n{\r\n\treferenceCounter_ = newReferenceCounter;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: componenteditoritem::setParameterFinder()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentEditorItem::setParameterFinder(QSharedPointer<ParameterFinder> parameterFinder)\r\n{\r\n\tparameterFinder_ = parameterFinder;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: componenteditoritem::setExpressionFormatter()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentEditorItem::setExpressionFormatter(QSharedPointer<ExpressionFormatter> expressionFormatter)\r\n{\r\n\texpressionFormatter_ = expressionFormatter;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: componenteditoritem::connectItemEditorToReferenceCounter()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentEditorItem::connectItemEditorToReferenceCounter()\r\n{\r\n\tconnect(editor_, SIGNAL(increaseReferences(QString)),\r\n\t\treferenceCounter_.data(), SLOT(increaseReferenceCount(QString)), Qt::UniqueConnection);\r\n\tconnect(editor_, SIGNAL(decreaseReferences(QString)),\r\n\t\treferenceCounter_.data(), SLOT(decreaseReferenceCount(QString)), Qt::UniqueConnection);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: componenteditoritem::connectItemEditorToVendorExtensionsEditor()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentEditorItem::connectItemEditorToVendorExtensionsEditor()\r\n{\r\n\tconnect(editor_, SIGNAL(changeVendorExtensions(QString const&, QSharedPointer<Extendable>)),\r\n\t\tthis, SIGNAL(changeVendorExtensions(QString const&, QSharedPointer<Extendable>)), Qt::UniqueConnection);\r\n}\r\n"
  },
  {
    "path": "editors/ComponentEditor/treeStructure/componenteditoritem.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: componenteditoritem.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 07.05.2012\r\n//\r\n// Description:\r\n// ComponentEditorItem is one item in the navigation tree in component editor.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef COMPONENTEDITORITEM_H\r\n#define COMPONENTEDITORITEM_H\r\n\r\n#include <editors/ComponentEditor/referenceCounter/ReferenceCounter.h>\r\n#include <KactusAPI/include/ParameterFinder.h>\r\n#include <KactusAPI/include/ExpressionFormatter.h>\r\n\r\n#include <QAction>\r\n#include <QObject>\r\n#include <QSharedPointer>\r\n#include <QFont>\r\n#include <QList>\r\n#include <QGraphicsItem>\r\n\r\nclass LibraryInterface;\r\nclass ComponentEditorTreeModel;\r\nclass ItemVisualizer;\r\nclass ItemEditor;\r\nclass Component;\r\nclass VLNV;\r\nclass Extendable;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! ComponentEditorItem is one item in the navigation tree in component editor.\r\n//-----------------------------------------------------------------------------\r\nclass ComponentEditorItem : public QObject\r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\r\n\t/*!\r\n\t *  The constructor.\r\n\t *\r\n\t *    @param [in] model       Pointer to the model that owns the items.\r\n\t *    @param [in] libHandler  Pointer to the instance that manages the library.\r\n\t *    @param [in] component   Pointer to the component being edited.\r\n\t *    @param [in] parent      Pointer to the parent item.\r\n\t */\r\n\tComponentEditorItem(ComponentEditorTreeModel* model,\r\n\t\tLibraryInterface* libHandler,\r\n\t\tQSharedPointer<Component> component,\r\n\t\tComponentEditorItem* parent);\r\n\r\n\t/*!\r\n\t *  The constructor for root item.\r\n\t *\r\n\t *    @param [in] libHandler  Pointer to the instance that manages the library.\r\n\t *    @param [in] component   Pointer to the component being edited.\r\n\t *    @param [in] parent      Pointer to the parent object.\r\n\t */\r\n\tComponentEditorItem(LibraryInterface* libHandler,\r\n\t\tQSharedPointer<Component> component,\r\n\t\tComponentEditorTreeModel* parent);\r\n\r\n\t//! The destructor.\r\n\tvirtual ~ComponentEditorItem();\r\n\r\n\t/*! \\brief Get the row of this item under the parent.\r\n\t *\r\n\t * \\return The row number of this item.\r\n\t*/\r\n\tint row() const;\r\n\r\n\t/*!\r\n\t *  Get the index of the child item under the parent.\r\n\t *\r\n\t *    @param [in] child   Pointer to the child that's row is wanted.\r\n\t *\r\n\t *    @return The index of the child item. Returns -1 if child is not found.\r\n\t */\r\n\tint getIndexOf(const ComponentEditorItem* child) const;\r\n\r\n\t/*!\r\n\t *  Get number of children the item contains.\r\n\t *\r\n\t *    @return The number of child items this item contains.\r\n\t */\r\n\tvirtual int rowCount() const;\r\n\r\n\t/*!\r\n\t *  Returns true if item contains child items.\r\n\t *\r\n\t *    @return True if child items exist.\r\n\t */\r\n\tbool hasChildren() const;\r\n\r\n\t/*!\r\n\t *  Get pointer to the child in given index.\r\n\t *\r\n\t *    @param [in] index   The index identifying the child.\r\n\t *\r\n\t *    @return Pointer to the indexed child. Null pointer is returned if index is invalid.\r\n\t */\r\n\tQSharedPointer<ComponentEditorItem> child(const int index);\r\n\r\n\t/*!\r\n\t *  Get pointer to the parent of this item.\r\n\t *\r\n\t *    @return Pointer to the parent item.\r\n\t */\r\n\tComponentEditorItem* parent();\r\n\r\n\t/*!\r\n\t *  Move child from source index to target index under the same parent.\r\n\t *\r\n\t *    @param [in] sourceIndex     The index identifying which item to move.\r\n\t *    @param [in] targetIndex     The index identifying the target to move to. If under 0 then item is\r\n\t *                                  prepended to the list. If greater than number of children then item is\r\n\t *                                  appended to the list.\r\n\t */\r\n\tvoid moveChild(const int sourceIndex, int targetIndex);\r\n\r\n\t/*!\r\n\t *  Get the font to be used for text of this item.\r\n\t *\r\n\t *    @return QFont instance that defines the font to be used.\r\n\t */\r\n\tvirtual QFont getFont() const;\r\n\r\n\t/*!\r\n\t *  Set the locked state of the editor and possible visualizer.\r\n\t *\r\n\t *    @param [in] locked  True to set the editor and visualizer in read only mode.\r\n\t */\r\n\tvirtual void setLocked(bool locked);\r\n\r\n\t/*!\r\n\t *  Add a new child to the item.\r\n\t *\r\n\t *    @param [in] index   The index to add the child into.\r\n\t */\r\n\tvirtual void createChild(int index);\r\n\r\n\t/*!\r\n\t *  Remove the child from the given index.\r\n\t *\r\n\t *    @param [in] index Identifies the child to remove.\r\n\t */\r\n\tvirtual void removeChild(int index);\r\n\r\n\t/*!\r\n\t *  Get the tool tip for the item.\r\n\t *\r\n\t *    @return The text for the tool tip to print to user.\r\n\t */\r\n\tvirtual QString getTooltip() const = 0;\r\n\r\n\t/*!\r\n\t *  Get the text to be displayed to user in the tree for this item.\r\n\t *\r\n\t *    @return QString Contains the text to display.\r\n\t */\r\n\tvirtual QString text() const = 0;\r\n\r\n\t/*!\r\n\t *  Check the validity of this item and sub items.\r\n\t *\r\n\t *    @return bool True if item is in valid state.\r\n\t */\r\n\tvirtual bool isValid() const;\r\n\r\n\r\n\tbool isModified() const;\r\n\r\n\tvoid clearModified();\r\n\r\n\t/*!\r\n\t *  Get pointer to the editor of this item.\r\n\t *\r\n\t *    @return Pointer to the editor to use for this item.\r\n\t */\r\n\tvirtual ItemEditor* editor() = 0;\r\n\r\n\t/*!\r\n\t *  Get pointer to the visualizer of this item.\r\n\t *\r\n\t *    @return Pointer to the visualizer to use for this item.\r\n\t */\r\n\tvirtual ItemVisualizer* visualizer();\r\n\r\n\t/*!\r\n\t *  Refresh the contents of the editor associated with this item.\r\n\t */\r\n\tvirtual void refreshEditor();\r\n\r\n\t/*!\r\n\t *  Tells if the item can be opened or not.\r\n\t *\r\n\t * The base class implementation always returns false.\r\n\t * Reimplement this if the item can be opened to some other editor.\r\n\t *\r\n\t * Note: If item can be opened then also reimplement actions() and openItem() to perform the opening.\r\n\t */\r\n\tvirtual bool canBeOpened() const;\r\n\r\n\t/*!\r\n\t *  Returns the possible actions for opening the item.\r\n\t *\r\n\t *    @return The actions to open the item.\r\n\t */\r\n\tvirtual QList<QAction* > actions();\r\n\r\n\t/*!\r\n\t *  Get the visualizer graphics item for the element.\r\n\t *\r\n\t * The default implementation returns a null pointer, reimplement this for\r\n\t * elements that contain a visualization element.\r\n\t *\r\n\t *    @return QGraphicsItem* Pointer to the graphics item.\r\n\t */\r\n\tvirtual QGraphicsItem* getGraphicsItem();\r\n\r\n\t/*!\r\n\t *  Update the graphics item of the element.\r\n\t *\r\n\t * The default implementation does nothing, reimplement for elements which\r\n\t * contain a graphics item.\r\n\t */\r\n\tvirtual void updateGraphics();\r\n\r\n\t/*!\r\n\t *  Remove the graphics item of the element.\r\n\t *\r\n\t * The default implementation does nothing, reimplement for elements which\r\n\t * contain a graphics item.\r\n\t */\r\n\tvirtual void removeGraphicsItem();\r\n\r\n\t/*!\r\n\t *  Tells if the item has a decoration icon or not.\r\n\t *\r\n\t *    @return True if the item has an icon, otherwise false (default).\r\n\t */\r\n\tvirtual bool hasIcon() const;\r\n\r\n\t/*!\r\n\t *  Gets the decoration icon for the item.\r\n\t */\r\n\tvirtual QIcon getIcon() const;\r\n\r\n\t/*!\r\n\t *  Set the reference counter for this item.\r\n\t *\r\n\t *    @param [in] newReferenceCounter   The counter for references.\r\n\t */\r\n\tvoid setReferenceCounter(QSharedPointer<ReferenceCounter> newReferenceCounter);\r\n\r\n\t/*!\r\n\t *  Set the parameter finder for this item.\r\n\t *\r\n\t *    @param [in] parameterFinder     The parameter finder.\r\n\t */\r\n\tvoid setParameterFinder(QSharedPointer<ParameterFinder> parameterFinder);\r\n\r\n\t/*!\r\n\t *  Set the expression formatter.\r\n\t *\r\n\t *    @param [in] expressionFormatter     The expression formatter.\r\n\t */\r\n\tvoid setExpressionFormatter(QSharedPointer<ExpressionFormatter> expressionFormatter);\r\n\r\npublic slots:\r\n\r\n\t/*!\r\n\t *  Open the item in an editor.\r\n\t *\r\n\t * The base class implementation does nothing.\r\n\t * Reimplement this in sub class to make it possible for item to be opened.\r\n\t *\r\n\t * Note: If item can be opened then also reimplement actions() and canBeOpened() to return true.\r\n\t */\r\n\tvirtual void openItem();\r\n\r\nsignals:\r\n\r\n\t//! Emitted when a help page should be changed in the context help window.\r\n\tvoid helpUrlRequested(QString const& url);\r\n\r\n\t//! This signal is emitted when the item should be updated in view.\r\n\tvoid contentChanged(ComponentEditorItem* item);\r\n\r\n\t//! Emitted when the component should be marked as modified.\r\n\tvoid contentChanged();\r\n\r\n\t//! Emitted when a error message should be shown to user.\r\n\tvoid errorMessage(const QString& msg);\r\n\r\n\t/*!\r\n\t *  Emitted when a child should be added to this item.\r\n\t *\r\n\t *    @param [in] item        Pointer to this item.\r\n\t *    @param [in] childIndex  The index the child should be added to.\r\n\t */\r\n\tvoid createChild(ComponentEditorItem* item, int childIndex);\r\n\r\n\t/*!\r\n\t *  Emitted when a child should be removed from the item.\r\n\t *\r\n\t *    @param [in] item        Pointer to this item.\r\n\t *    @param [in] childIndex  The index of the child that should be removed.\r\n\t */\r\n\tvoid removeChild(ComponentEditorItem* item, int childIndex);\r\n\r\n\t/*!\r\n\t *  Emitted when a child should be moved from one place to another.\r\n\t *\r\n\t *    @param [in] item            Pointer to this item.\r\n\t *    @param [in] sourceIndex     The index of the child item to move.\r\n\t *    @param [in] targetIndex     The index to move the child into.\r\n\t */\r\n\tvoid moveChild(ComponentEditorItem* item, int sourceIndex, int targetIndex);\r\n\r\n\t/*!\r\n\t *  Opens the specific C source file of the given component.\r\n\t *\r\n\t *    @param [in] filename   The name of the file to open.\r\n\t *    @param [in] component  The component containing the file.\r\n\t */\r\n\tvoid openCSource(QString const& filename, QSharedPointer<Component> component);\r\n\r\n\t//! Emitted when a design editor should be opened for given hierarchical view.\r\n\tvoid openDesign(const VLNV& componentVLNV, const QString& viewName);\r\n\r\n\t//! Emitted when a bus editor should be opened for given bus.\r\n\tvoid openBus(const VLNV& busdefVLNV);\r\n\r\n\t//! Emitted when a abstraction definition editor should be opened for given abstraction definition.\r\n\tvoid openAbsDef(const VLNV& absdefVLNV);\r\n\r\n\t//! Emitted when a COM definition should be opened in an editor.\r\n\tvoid openComDefinition(const VLNV& comdefVLNV);\r\n\r\n\t//! Emitted when a SW design should be opened in an editor.\r\n\tvoid openSWDesign(const VLNV& componentVLNV, const QString& viewName);\r\n\r\n\t//! Emitted when a system design should be opened in an editor.\r\n\tvoid openSystemDesign(const VLNV& componentVLNV, const QString& viewName);\r\n\r\n\t/*!\r\n\t *  Emitted when a tree item should be selected in component editor.\r\n\t *\r\n\t *    @param [in] item    Pointer to the item to select.\r\n\t */\r\n\tvoid selectItem(ComponentEditorItem* item);\r\n\r\n\t/*!\r\n\t *  Open the reference tree of the selected parameter.\r\n\t *\r\n\t *    @param [in] id              The ID of the parameter.\r\n\t *    @param [in] parameterName   Name of the selected parameter.\r\n\t */\r\n\tvoid openReferenceTree(QString const& id, QString const& parameterName) const;\r\n\r\n\t/*!\r\n\t *  Change the vendor extensions of the vendor extensions editor.\r\n\t *\r\n\t *    @param [in] containingID    ID for the vendor extensions editor.\r\n\t *    @param [in] extensionItem   The item containing the selected vendor extensions.\r\n\t */\r\n\tvoid changeVendorExtensions(QString const& containingID, QSharedPointer<Extendable> extensionItem);\r\n\r\nprotected:\r\n\r\n\t/*!\r\n\t *  Connects this component editor items item editor to its reference counter.\r\n\t */\r\n\tvirtual void connectItemEditorToReferenceCounter();\r\n\r\n\t/*!\r\n\t *  Connects this component editor items item editor to the vendor extensions editor.\r\n\t */\r\n\tvirtual void connectItemEditorToVendorExtensionsEditor();\r\n\r\n\t//! Sets the item as modified.\r\n\tvoid setModified();\r\n\r\n\t//! Pointer to the instance that manages the library.\r\n\tLibraryInterface* libHandler_ = nullptr;\r\n\r\n\t//! Pointer to the component being edited.\r\n\tQSharedPointer<Component> component_ = nullptr;\r\n\r\n\t//! Pointer to the model that owns this item.\r\n\tComponentEditorTreeModel* model_ = nullptr;\r\n\r\n\t//! Contains the children of this item.\r\n\tQList<QSharedPointer<ComponentEditorItem> > childItems_;\r\n\r\n\t//! The editor for the component editor item.\r\n\tItemEditor* editor_ = nullptr;\r\n\r\n\t//! Defines the lock-status for editors.\r\n\tbool locked_ = true;\r\n\r\n\t//! Flag for modification of the item.\r\n\tbool modified_ = false;\r\n\r\n\t//! Allows increasing and decreasing of parameter usage counts.\r\n\tQSharedPointer<ReferenceCounter> referenceCounter_ = nullptr;\r\n\r\n\t//! Parameter finder, finds the desired parameters.\r\n\tQSharedPointer<ParameterFinder> parameterFinder_ = nullptr;\r\n\r\n\t//! Expression formatter, formats the referencing expressions.\r\n\tQSharedPointer<ExpressionFormatter> expressionFormatter_ = nullptr;\r\n\r\nprotected slots:\r\n\r\n\t/*!\r\n\t *  Handler for editor's contentChanged signal.\r\n\t */\r\n\tvirtual void onEditorChanged();\r\n\r\n\t/*!\r\n\t *  Handles the redrawing of the visualization of the item.\r\n\t */\r\n\tvirtual void onGraphicsChanged();\r\n\r\n\t/*!\r\n\t *  Handler for ItemEditor's childAdded(int) signal.\r\n\t *\r\n\t *    @param [in] index   The index to add the child to.\r\n\t */\r\n\tvirtual void onAddChild(int index);\r\n\r\n\t/*!\r\n\t *  Handler for ItemEditor's childRemoved(int) signal.\r\n\t *\r\n\t *    @param [in] index   The index of the child to remove.\r\n\t */\r\n\tvirtual void onRemoveChild(int index);\r\n\r\n\t/*!\r\n\t *  Handler for ItemEditor's childMoved(int, int) signal.\r\n\t *\r\n\t *    @param [in] source  The index of the child to move.\r\n\t *    @param [in] target  The position to move the child into.\r\n\t */\r\n\tvirtual void onMoveChild(int source, int target);\r\n\r\n\r\nprivate slots:\r\n\r\n\t//! Slot for display requests of this item.\r\n\tvoid onSelectRequest();\r\n\r\nprivate:\r\n\r\n\t//! No copying or assignment.\r\n\tComponentEditorItem(const ComponentEditorItem& other);\r\n\tComponentEditorItem& operator=(const ComponentEditorItem& other);\r\n\r\n\t//! Pointer to the parent item.\r\n\tComponentEditorItem* parent_ = nullptr;\r\n};\r\n\r\n#endif // COMPONENTEDITORITEM_H\r\n"
  },
  {
    "path": "editors/ComponentEditor/treeStructure/componenteditormemmapitem.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: componenteditormemmapitem.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 16.05.2012\r\n//\r\n// Description:\r\n// The item for a single memory map in component editor's navigation tree.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"componenteditormemmapitem.h\"\r\n#include \"MemoryRemapItem.h\"\r\n\r\n#include <editors/ComponentEditor/memoryMaps/SingleMemoryMapEditor.h>\r\n#include <editors/ComponentEditor/memoryMaps/memoryMapsVisualizer/memorymapsvisualizer.h>\r\n\r\n#include <IPXACTmodels/Component/MemoryMap.h>\r\n#include <IPXACTmodels/Component/MemoryRemap.h>\r\n#include <IPXACTmodels/Component/MemoryBlockBase.h>\r\n#include <IPXACTmodels/Component/AddressBlock.h>\r\n\r\n#include <IPXACTmodels/Component/validators/MemoryMapValidator.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: componenteditormemmapitem::ComponentEditorMemMapItem()\r\n//-----------------------------------------------------------------------------\r\nComponentEditorMemMapItem::ComponentEditorMemMapItem(QSharedPointer<MemoryMap> memoryMap,\r\n    ComponentEditorTreeModel* model, LibraryInterface* libHandler, QSharedPointer<Component> component,\r\n    QSharedPointer<ReferenceCounter> referenceCounter, QSharedPointer<ParameterFinder> parameterFinder,\r\n    QSharedPointer<ExpressionFormatter> expressionFormatter, QSharedPointer<ExpressionParser> expressionParser,\r\n    QSharedPointer<MemoryMapValidator> memoryMapValidator, MemoryMapInterface* mapInterface,\r\n    ComponentEditorItem* parent):\r\nComponentEditorItem(model, libHandler, component, parent),\r\nmemoryMap_(memoryMap),\r\nexpressionParser_(expressionParser),\r\nmemoryMapValidator_(memoryMapValidator),\r\nmapInterface_(mapInterface)\r\n{\r\n    setReferenceCounter(referenceCounter);\r\n    setParameterFinder(parameterFinder);\r\n    setExpressionFormatter(expressionFormatter);\r\n\r\n\tsetObjectName(tr(\"ComponentEditorMemMapItem\"));\r\n\r\n    QSharedPointer<MemoryRemapItem> defaultRemapItem(new MemoryRemapItem(memoryMap_, memoryMap_, model, libHandler,\r\n        component, referenceCounter, parameterFinder, expressionFormatter, expressionParser_, memoryMapValidator_,\r\n        mapInterface_, this));\r\n    defaultRemapItem->setLocked(locked_);\r\n\r\n    MemoryMapsVisualizer* memoryRemapVisualizer = new MemoryMapsVisualizer();\r\n    defaultRemapItem->setVisualizer(memoryRemapVisualizer);\r\n\r\n    connect(this, SIGNAL(memoryMapNameChanged(QString const&, QString const&)),\r\n        defaultRemapItem.data(), SIGNAL(memoryMapNameChanged(QString const&, QString const&)),\r\n        Qt::UniqueConnection);\r\n\r\n    connect(defaultRemapItem.data(), SIGNAL(addressUnitBitsChanged()),\r\n        this, SLOT(changeAdressUnitBitsOnAddressBlocks()), Qt::UniqueConnection);\r\n\r\n    childItems_.append(defaultRemapItem);\r\n\r\n    const int childCount = memoryMap_->getMemoryRemaps()->count();\r\n    for (int i = 0; i < childCount; ++i)\r\n    {\r\n        ComponentEditorMemMapItem::createChild(i + 1);\r\n    }\r\n\r\n\tQ_ASSERT(memoryMap_);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: componenteditormemmapitem::text()\r\n//-----------------------------------------------------------------------------\r\nQString ComponentEditorMemMapItem::text() const\r\n{\r\n\treturn memoryMap_->name();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: componenteditormemmapitem::isValid()\r\n//-----------------------------------------------------------------------------\r\nbool ComponentEditorMemMapItem::isValid() const\r\n{\r\n    return memoryMapValidator_->validate(memoryMap_);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: componenteditormemmapitem::editor()\r\n//-----------------------------------------------------------------------------\r\nItemEditor* ComponentEditorMemMapItem::editor()\r\n{\r\n    return childItems_.at(0)->editor();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: componenteditormemmapitem::getTooltip()\r\n//-----------------------------------------------------------------------------\r\nQString ComponentEditorMemMapItem::getTooltip() const\r\n{\r\n\treturn tr(\"Contains the details of a single memory map that can be referenced\"\r\n        \" by containing component's slave interfaces\");\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: componenteditormemmapitem::createChild()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentEditorMemMapItem::createChild( int index )\r\n{\r\n    QSharedPointer<MemoryRemap> memoryRemap = memoryMap_->getMemoryRemaps()->at(index - 1);\r\n//     QSharedPointer<MemoryRemap> memoryRemap = memoryMap_->getMemoryRemaps()->at(index);\r\n\r\n    QSharedPointer<MemoryRemapItem> memoryRemapItem (new MemoryRemapItem(memoryRemap, memoryMap_, model_,\r\n        libHandler_, component_, referenceCounter_, parameterFinder_, expressionFormatter_, expressionParser_,\r\n        memoryMapValidator_, mapInterface_, this));\r\n    memoryRemapItem->setLocked(locked_);\r\n\r\n    MemoryMapsVisualizer* memoryRemapVisualizer = new MemoryMapsVisualizer();\r\n    memoryRemapItem->setVisualizer(memoryRemapVisualizer);\r\n\r\n    childItems_.append(memoryRemapItem);\r\n\r\n    connect(this, SIGNAL(memoryRemapNameChanged(QString const&, QString const&, QString const&)),\r\n        memoryRemapItem.data(), SIGNAL(memoryRemapNameChanged(QString const&, QString const&, QString const&)),\r\n        Qt::UniqueConnection);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: componenteditormemmapitem::visualizer()\r\n//-----------------------------------------------------------------------------\r\nItemVisualizer* ComponentEditorMemMapItem::visualizer()\r\n{\r\n    return childItems_.at(0)->visualizer();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: componenteditormemmapitem::setVisualizer()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentEditorMemMapItem::setVisualizer( MemoryMapsVisualizer* visualizer )\r\n{\r\n    QSharedPointer<ComponentEditorItem> item = childItems_.at(0);\r\n    QSharedPointer<MemoryRemapItem> memoryRemapItem = item.staticCast<MemoryRemapItem>();\r\n\r\n    if(memoryRemapItem)\r\n    {\r\n        memoryRemapItem->setVisualizer(visualizer);\r\n\r\n        connect(memoryRemapItem.data(), SIGNAL(addressingChanged()),\r\n            visualizer, SLOT(redoLayout()), Qt::UniqueConnection);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: componenteditormemmapitem::getGraphicsItem()\r\n//-----------------------------------------------------------------------------\r\nQGraphicsItem* ComponentEditorMemMapItem::getGraphicsItem()\r\n{\r\n    return childItems_.at(0)->getGraphicsItem();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: componenteditormemmapitem::updateGraphics()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentEditorMemMapItem::updateGraphics()\r\n{\r\n    childItems_.at(0)->updateGraphics();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: componenteditormemmapitem::removeGraphicsItem()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentEditorMemMapItem::removeGraphicsItem()\r\n{\r\n    childItems_.at(0)->removeGraphicsItem();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: componenteditormemmapitem::changeAdressUnitBitsOnAddressBlocks()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentEditorMemMapItem::changeAdressUnitBitsOnAddressBlocks()\r\n{\r\n    foreach (QSharedPointer<ComponentEditorItem> childItem, childItems_)\r\n    {\r\n        QSharedPointer<MemoryRemapItem> memoryRemap = qobject_cast<QSharedPointer<MemoryRemapItem> >(childItem);\r\n        memoryRemap->changeAdressUnitBitsOnAddressBlocks();\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: componenteditormemmapitem::onMemoryRemapAdded()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentEditorMemMapItem::onMemoryRemapAdded(int memoryRemapIndex, QString const& mapName)\r\n{\r\n    if (mapName == memoryMap_->name())\r\n    {\r\n        onAddChild(memoryRemapIndex + 1);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: componenteditormemmapitem::onMemoryRemapRemoved()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentEditorMemMapItem::onMemoryRemapRemoved(int memoryRemapIndex, QString const& mapName)\r\n{\r\n    if (mapName == memoryMap_->name())\r\n    {\r\n        onRemoveChild(memoryRemapIndex + 1);\r\n    }\r\n}"
  },
  {
    "path": "editors/ComponentEditor/treeStructure/componenteditormemmapitem.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: componenteditormemmapitem.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 16.05.2012\r\n//\r\n// Description:\r\n// The item for a single memory map in component editor's navigation tree.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef COMPONENTEDITORMEMMAPITEM_H\r\n#define COMPONENTEDITORMEMMAPITEM_H\r\n\r\n#include \"componenteditoritem.h\"\r\n\r\n#include <QSharedPointer>\r\n#include <QList>\r\n\r\nclass MemoryMapEditor;\r\nclass MemoryMapsVisualizer;\r\nclass MemoryMapGraphItem;\r\nclass ExpressionParser;\r\nclass MemoryMap;\r\nclass MemoryMapValidator;\r\nclass MemoryMapInterface;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! The item for a single memory map in component editor's navigation tree.\r\n//-----------------------------------------------------------------------------\r\nclass ComponentEditorMemMapItem : public ComponentEditorItem\r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\r\n\t/*!\r\n\t *  The constructor.\r\n\t *\r\n\t *    @param [in] memoryMap               The memory map being edited.\r\n\t *    @param [in] model                   The model that owns the items.\r\n\t *    @param [in] libHandler              The instance that manages the library.\r\n\t *    @param [in] component               The component being edited.\r\n     *    @param [in] referenceCounter        The instance for counting references to parameters.\r\n\t *    @param [in] parameterFinder         The parameter finder.\r\n\t *    @param [in] expressionFormatter     The expression formatter.\r\n     *    @param [in] expressionParser        The expression parser to use.\r\n     *    @param [in] memoryMapValidator      Validator used for memory maps.\r\n     *    @param [in] mapInterface            Interface for accessing memory maps.\r\n\t *    @param [in] parent                  The parent item.\r\n\t */\r\n\tComponentEditorMemMapItem(QSharedPointer<MemoryMap> memoryMap,\r\n\t\tComponentEditorTreeModel* model,\r\n\t\tLibraryInterface* libHandler,\r\n\t\tQSharedPointer<Component> component,\r\n        QSharedPointer<ReferenceCounter> referenceCounter,\r\n        QSharedPointer<ParameterFinder> parameterFinder,\r\n        QSharedPointer<ExpressionFormatter> expressionFormatter,\r\n        QSharedPointer<ExpressionParser> expressionParser,\r\n        QSharedPointer<MemoryMapValidator> memoryMapValidator,\r\n        MemoryMapInterface* mapInterface,\r\n\t\tComponentEditorItem* parent);\r\n\r\n\t//! The destructor.\r\n\tvirtual ~ComponentEditorMemMapItem() = default;\r\n\r\n    //! No copying. No assignment.\r\n    ComponentEditorMemMapItem(const ComponentEditorMemMapItem& other) = delete;\r\n    ComponentEditorMemMapItem& operator=(const ComponentEditorMemMapItem& other) = delete;\r\n\r\n\t/*!\r\n     *  Get the tool tip for the item.\r\n\t * \r\n\t *    @return The text for the tool tip to print to user.\r\n\t */\r\n\tvirtual QString getTooltip() const;\r\n\r\n\t/*!\r\n     *  Get the text to be displayed to user in the tree for this item.\r\n\t *\r\n\t *    @return QString Contains the text to display.\r\n\t */\r\n\tvirtual QString text() const;\r\n\r\n\t/*!\r\n     *  Check the validity of this item and sub items.\r\n\t *\r\n\t *    @return bool True if item is in valid state.\r\n\t */\r\n\tvirtual bool isValid() const;\r\n\r\n\t/*!\r\n     *  Get pointer to the editor of this item.\r\n\t *\r\n\t *    @return The editor to use for this item.\r\n\t */\r\n\tvirtual ItemEditor* editor();\r\n\r\n\t/*!\r\n     *  Add a new child to the item.\r\n\t * \r\n\t *    @param [in] index The index to add the child into.\r\n\t */\r\n\tvirtual void createChild(int index);\r\n\r\n\t/*!\r\n     *  Get pointer to the visualizer of this item.\r\n\t * \r\n\t *    @return The visualizer to use for this item.\r\n\t */\r\n\tvirtual ItemVisualizer* visualizer();\r\n\r\n\t/*!\r\n     *  Set the visualizer for this item.\r\n\t *\r\n\t *    @param [in] visualizer The visualizer.\r\n\t */\r\n\tvirtual void setVisualizer(MemoryMapsVisualizer* visualizer);\r\n\r\n\t/*!\r\n     *  Get the visualizer graphics item for the memory map.\r\n\t *\r\n\t *    @return QGraphicsItem* The graphics item.\r\n\t */\r\n\tvirtual QGraphicsItem* getGraphicsItem();\r\n\r\n\t/*!\r\n     *  Update the graphics item of the memory map.\r\n\t */\r\n\tvirtual void updateGraphics();\r\n\r\n\t/*!\r\n     *  Remove the graphics item of the memory map.\r\n\t */\r\n\tvirtual void removeGraphicsItem();\r\n\r\npublic slots:\r\n\r\n    /*!\r\n     *  Change the address unit bits for the address blocks.\r\n     */\r\n    void changeAdressUnitBitsOnAddressBlocks();\r\n\r\n    /*!\r\n     *  Add a memory remap item to the tree.\r\n     *\r\n     *    @param [in] memoryRemapIndex    The index of the new memory remap item.\r\n     *    @param [in] mapName             Name of the parent of the new memory remap item.\r\n     */\r\n    void onMemoryRemapAdded(int memoryRemapIndex, QString const& mapName);\r\n\r\n    /*!\r\n     *  Remove a memory remap item from the tree.\r\n     *\r\n     *    @param [in] memoryRemapIndex    The index of the removed memory remap item.\r\n     *    @param [in] mapName             Name of the parent of the removed memory remap item.\r\n     */\r\n    void onMemoryRemapRemoved(int memoryRemapIndex, QString const& mapName);\r\n\r\nsignals:\r\n    \r\n    /*\r\n     *  Informs of memory map name change.\r\n     *\r\n     *    @param [in] oldName     The old name.\r\n     *    @param [in] newName     The new name.\r\n     */\r\n    void memoryMapNameChanged(QString const& oldName, QString const& newName);\r\n\r\n    /*\r\n     *  Informs of memory remap name change.\r\n     *\r\n     *    @param [in] oldName     The old name.\r\n     *    @param [in] newName     The new name.\r\n     */\r\n    void memoryRemapNameChanged(QString const& parentName, QString const& oldName, QString const& newName);\r\n\r\nprivate:\r\n\r\n\t//! The memory map being edited.\r\n\tQSharedPointer<MemoryMap> memoryMap_;\r\n\r\n    //! The expression parser to use.\r\n    QSharedPointer<ExpressionParser> expressionParser_;\r\n\r\n    //! The validator used for memory maps.\r\n    QSharedPointer<MemoryMapValidator> memoryMapValidator_;\r\n\r\n    //! Interface for accessing memory maps.\r\n    MemoryMapInterface* mapInterface_;\r\n};\r\n\r\n#endif // COMPONENTEDITORMEMMAPITEM_H\r\n"
  },
  {
    "path": "editors/ComponentEditor/treeStructure/componenteditormemmapsitem.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: componenteditormemmapsitem.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 09.05.2012\r\n//\r\n// Description:\r\n// The Memory maps-item in the component navigation tree.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"componenteditormemmapsitem.h\"\r\n#include \"componenteditormemmapitem.h\"\r\n#include <editors/ComponentEditor/treeStructure/componenteditortreemodel.h>\r\n#include <editors/ComponentEditor/memoryMaps/memorymapseditor.h>\r\n#include <editors/ComponentEditor/memoryMaps/memoryMapsVisualizer/memorymapsvisualizer.h>\r\n\r\n#include <KactusAPI/include/ResetInterface.h>\r\n#include <KactusAPI/include/FieldInterface.h>\r\n#include <KactusAPI/include/RegisterInterface.h>\r\n#include <KactusAPI/include/AddressBlockInterface.h>\r\n#include <KactusAPI/include/MemoryMapInterface.h>\r\n#include <KactusAPI/include/SubspaceMapInterface.h>\r\n#include <KactusAPI/include/ParametersInterface.h>\r\n#include <KactusAPI/include/BusInterfaceInterface.h>\r\n#include <KactusAPI/include/AccessPolicyInterface.h>\r\n#include <KactusAPI/include/ModeReferenceInterface.h>\r\n\r\n#include <IPXACTmodels/Component/MemoryMap.h>\r\n#include <IPXACTmodels/Component/validators/BusInterfaceValidator.h>\r\n#include <IPXACTmodels/Component/validators/PortMapValidator.h>\r\n#include <IPXACTmodels/Component/validators/SubspaceMapValidator.h>\r\n#include <IPXACTmodels/Component/validators/MemoryMapValidator.h>\r\n#include <IPXACTmodels/Component/validators/CollectionValidators.h>\r\n#include <IPXACTmodels/Component/validators/AddressBlockValidator.h>\r\n#include <IPXACTmodels/Component/validators/RegisterValidator.h>\r\n#include <IPXACTmodels/Component/validators/RegisterFileValidator.h>\r\n#include <IPXACTmodels/Component/validators/FieldValidator.h>\r\n#include <IPXACTmodels/Component/validators/EnumeratedValueValidator.h>\r\n#include <IPXACTmodels/common/validators/ParameterValidator.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: componenteditormemmapsitem::ComponentEditorMemMapsItem()\r\n//-----------------------------------------------------------------------------\r\nComponentEditorMemMapsItem::ComponentEditorMemMapsItem(ComponentEditorTreeModel* model,\r\n    LibraryInterface* libHandler, QSharedPointer<Component> component,\r\n    QSharedPointer<ReferenceCounter> referenceCounter, QSharedPointer<ParameterFinder> parameterFinder,\r\n    QSharedPointer<ExpressionFormatter> expressionFormatter, QSharedPointer<ExpressionParser> expressionParser,\r\n    ComponentEditorItem* parent ):\r\nComponentEditorItem(model, libHandler, component, parent),\r\n    memoryMaps_(component->getMemoryMaps()),\r\n    visualizer_(nullptr),\r\n    expressionParser_(expressionParser),\r\n    memoryMapsValidator_(),\r\n    memoryMapValidator_(),\r\n    mapInterface_()\r\n{\r\n    createValidators();\r\n\r\n    setReferenceCounter(referenceCounter);\r\n    setParameterFinder(parameterFinder);\r\n    setExpressionFormatter(expressionFormatter);\r\n\r\n    createMemoryMapInterface();\r\n\r\n\tsetObjectName(tr(\"ComponentEditorMemMapsItem\"));\r\n\r\n    const int childCount = memoryMaps_->count();\r\n\tfor (int i = 0; i < childCount; ++i)\r\n    {\r\n        ComponentEditorMemMapsItem::createChild(i);\r\n\t}\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: componenteditormemmapsitem::getFont()\r\n//-----------------------------------------------------------------------------\r\nQFont ComponentEditorMemMapsItem::getFont() const\r\n{\r\n    QFont font(ComponentEditorItem::getFont());\r\n    font.setBold(!memoryMaps_->isEmpty());\r\n    return font;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: componenteditormemmapsitem::text()\r\n//-----------------------------------------------------------------------------\r\nQString ComponentEditorMemMapsItem::text() const\r\n{\r\n\treturn tr(\"Memory maps\");\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: componenteditormemmapsitem::editor()\r\n//-----------------------------------------------------------------------------\r\nItemEditor* ComponentEditorMemMapsItem::editor()\r\n{\r\n\tif (!editor_)\r\n    {\r\n        editor_ =\r\n            new MemoryMapsEditor(mapInterface_, component_, parameterFinder_, expressionParser_, libHandler_);\r\n        editor_->setProtection(locked_);\r\n\t\tconnect(editor_, SIGNAL(contentChanged()), this, SLOT(onEditorChanged()), Qt::UniqueConnection);\r\n        connect(editor_, SIGNAL(graphicsChanged()), this, SLOT(onGraphicsChanged()), Qt::UniqueConnection);\r\n\t\tconnect(editor_, SIGNAL(childAdded(int)), this, SLOT(onAddChild(int)), Qt::UniqueConnection);\r\n\t\tconnect(editor_, SIGNAL(childRemoved(int)), this, SLOT(onRemoveChild(int)), Qt::UniqueConnection);\r\n\t\tconnect(editor_, SIGNAL(helpUrlRequested(QString const&)), this, SIGNAL(helpUrlRequested(QString const&)));\r\n\t\tconnect(editor_, SIGNAL(selectBusInterface(const QString&)),\r\n            model_, SLOT(onSelectBusInterface(const QString&)), Qt::UniqueConnection);\r\n\r\n        connect(editor_, SIGNAL(changeInAddressUnitBitsOnRow(int)), \r\n            this, SLOT(addressUnitBitsChangedOnMemoryMap(int)), Qt::UniqueConnection);\r\n\r\n        connect(editor_, SIGNAL(memoryRemapAdded(int, QString const&)),\r\n            this, SIGNAL(memoryRemapAdded(int, QString const&)), Qt::UniqueConnection);\r\n\r\n        connect(editor_, SIGNAL(memoryRemapRemoved(int, QString const&)),\r\n            this, SIGNAL(memoryRemapRemoved(int, QString const&)), Qt::UniqueConnection);\r\n\r\n        connect(editor_, SIGNAL(memoryMapNameChanged(QString const&, QString const&)),\r\n            this, SIGNAL(memoryMapNameChanged(QString const&, QString const&)), Qt::UniqueConnection);\r\n        connect(editor_, SIGNAL(memoryRemapNameChanged(QString const&, QString const&, QString const&)),\r\n            this, SIGNAL(memoryRemapNameChanged(QString const&, QString const&, QString const&)),\r\n            Qt::UniqueConnection);\r\n\r\n        connectItemEditorToReferenceCounter();\r\n\t}\r\n\treturn editor_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: componenteditormemmapsitem::getTooltip()\r\n//-----------------------------------------------------------------------------\r\nQString ComponentEditorMemMapsItem::getTooltip() const\r\n{\r\n\treturn tr(\"Contains the memory maps of the component\");\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: componenteditormemmapsitem::createChild()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentEditorMemMapsItem::createChild( int index )\r\n{\r\n\tQSharedPointer<ComponentEditorMemMapItem> memoryMapItem(new ComponentEditorMemMapItem(memoryMaps_->at(index),\r\n        model_, libHandler_, component_, referenceCounter_, parameterFinder_, expressionFormatter_,\r\n        expressionParser_, memoryMapValidator_, mapInterface_, this));\r\n\tmemoryMapItem->setLocked(locked_);\r\n\tchildItems_.insert(index, memoryMapItem);\r\n\t\r\n    connect(this, SIGNAL(memoryRemapAdded(int, QString const&)),\r\n        memoryMapItem.data(), SLOT(onMemoryRemapAdded(int, QString const&)), Qt::UniqueConnection);\r\n\r\n    connect(this, SIGNAL(memoryRemapRemoved(int, QString const&)),\r\n        memoryMapItem.data(), SLOT(onMemoryRemapRemoved(int, QString const&)), Qt::UniqueConnection);\r\n\r\n    connect(this, SIGNAL(memoryMapNameChanged(QString const&, QString const&)),\r\n        memoryMapItem.data(), SIGNAL(memoryMapNameChanged(QString const&, QString const&)),\r\n        Qt::UniqueConnection);\r\n    connect(this, SIGNAL(memoryRemapNameChanged(QString const&, QString const&, QString const&)),\r\n        memoryMapItem.data(), SIGNAL(memoryRemapNameChanged(QString const&, QString const&, QString const&)),\r\n        Qt::UniqueConnection);\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: componenteditormemmapsitem::visualizer()\r\n//-----------------------------------------------------------------------------\r\nItemVisualizer* ComponentEditorMemMapsItem::visualizer()\r\n{\r\n    return nullptr;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: componenteditormemmapsitem::addressUnitBitsChangedOnMemoryMap()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentEditorMemMapsItem::addressUnitBitsChangedOnMemoryMap(int memoryMapIndex)\r\n{\r\n    QSharedPointer<ComponentEditorMemMapItem> childMemoryMap = \r\n        qobject_cast<QSharedPointer<ComponentEditorMemMapItem> > ( child(memoryMapIndex) );\r\n    \r\n    if (!childMemoryMap.isNull())\r\n    {\r\n        childMemoryMap->changeAdressUnitBitsOnAddressBlocks();\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditorMemMapsItem::isValid()\r\n//-----------------------------------------------------------------------------\r\nbool ComponentEditorMemMapsItem::isValid() const\r\n{\r\n    auto memoryMapsAsNameGroup = CollectionValidators::itemListToNameGroupList(memoryMaps_);\r\n    memoryMapsValidator_->childrenHaveUniqueNames(memoryMapsAsNameGroup);\r\n\r\n    return ComponentEditorItem::isValid();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: componenteditormemmapsitem::createMemoryMapValidator()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentEditorMemMapsItem::createValidators()\r\n{\r\n    QSharedPointer<ParameterValidator> parameterValidator (\r\n        new ParameterValidator(expressionParser_, component_->getChoices(), component_->getRevision()));\r\n    QSharedPointer<EnumeratedValueValidator> enumValidator (new EnumeratedValueValidator(expressionParser_));\r\n    QSharedPointer<FieldValidator> fieldValidator (\r\n        new FieldValidator(expressionParser_, enumValidator, parameterValidator));\r\n    QSharedPointer<RegisterValidator> registerValidator (\r\n        new RegisterValidator(expressionParser_, fieldValidator, parameterValidator));\r\n    QSharedPointer<RegisterFileValidator> registerFileValidator (\r\n        new RegisterFileValidator(expressionParser_, registerValidator, parameterValidator, component_->getRevision()));\r\n\r\n    QSharedPointer<AddressBlockValidator> addressBlockValidator (\r\n        new AddressBlockValidator(expressionParser_, registerValidator,registerFileValidator, parameterValidator, \r\n            component_->getRevision()));\r\n\r\n    QSharedPointer<SubspaceMapValidator> subspaceValidator(\r\n        new SubspaceMapValidator(expressionParser_, parameterValidator, component_->getRevision()));\r\n\r\n    QSharedPointer<MemoryMapValidator> memoryMapValidator(new MemoryMapValidator(\r\n        expressionParser_, addressBlockValidator, subspaceValidator, component_));\r\n\r\n    QSharedPointer<MemoryMapsValidator> memoryMapsValidator(new MemoryMapsValidator(memoryMapValidator));\r\n\r\n    memoryMapValidator_ = memoryMapValidator;\r\n\r\n    memoryMapsValidator_ = memoryMapsValidator;\r\n\r\n    memoryMapValidator_->componentChange(component_);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: componenteditormemmapsitem::createMemoryMapInterface()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentEditorMemMapsItem::createMemoryMapInterface()\r\n{\r\n    QSharedPointer<SubspaceMapValidator> subspaceValidator = memoryMapValidator_->getSubspaceValidator();\r\n    QSharedPointer<AddressBlockValidator> blockValidator = memoryMapValidator_->getAddressBlockValidator();\r\n    QSharedPointer<RegisterValidator> registerValidator = blockValidator->getRegisterValidator();\r\n    QSharedPointer<FieldValidator> fieldValidator = registerValidator->getFieldValidator();\r\n\r\n    QSharedPointer<ParameterValidator> parameterValidator(new ParameterValidator(expressionParser_,\r\n        component_->getChoices(), component_->getRevision()));\r\n\r\n    ParametersInterface* parameterInterface(\r\n        new ParametersInterface(parameterValidator, expressionParser_, expressionFormatter_));\r\n\r\n    ResetInterface* resetInterface(new ResetInterface(fieldValidator, expressionParser_, expressionFormatter_));\r\n    FieldInterface* fieldInterface(\r\n        new FieldInterface(fieldValidator, expressionParser_, expressionFormatter_, resetInterface));\r\n\r\n    ModeReferenceInterface* modeRefInterface(new ModeReferenceInterface());\r\n    modeRefInterface->setComponentModes(component_->getModes());\r\n\r\n    AccessPolicyInterface* accessPolicyInterface(new AccessPolicyInterface(modeRefInterface));\r\n    accessPolicyInterface->setComponentModes(component_->getModes());\r\n\r\n    RegisterInterface* registerInterface(\r\n        new RegisterInterface(registerValidator, expressionParser_, expressionFormatter_, fieldInterface, accessPolicyInterface));\r\n\r\n    BusInterfaceInterface* busInterface = createInterfaceForBus(parameterValidator);\r\n\r\n    AddressBlockInterface* blockInterface(new AddressBlockInterface(blockValidator, expressionParser_,\r\n        expressionFormatter_, busInterface, registerInterface, parameterInterface));\r\n    SubspaceMapInterface* subspaceInterface(new SubspaceMapInterface(\r\n        subspaceValidator, expressionParser_, expressionFormatter_, busInterface, parameterInterface));\r\n\r\n    mapInterface_ =\r\n        new MemoryMapInterface(memoryMapValidator_, expressionParser_, expressionFormatter_);\r\n    mapInterface_->setAddressBlockInterface(blockInterface);\r\n    mapInterface_->setSubspaceMapInterface(subspaceInterface);\r\n    mapInterface_->setModeReferenceInterface(modeRefInterface);\r\n\r\n    fieldInterface->setModeReferenceInterface(modeRefInterface);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: componenteditormemmapsitem::createInterfaceForBus()\r\n//-----------------------------------------------------------------------------\r\nBusInterfaceInterface* ComponentEditorMemMapsItem::createInterfaceForBus(\r\n    QSharedPointer<ParameterValidator> parameterValidator)\r\n{\r\n    QSharedPointer<PortMapValidator> portMapValidator(\r\n        new PortMapValidator(expressionParser_, component_->getPorts(), libHandler_));\r\n    QSharedPointer<BusInterfaceValidator> busValidator(new BusInterfaceValidator(expressionParser_,\r\n        component_->getChoices(), component_->getViews(), component_->getPorts(), component_->getAddressSpaces(),\r\n        memoryMaps_, component_->getBusInterfaces(), component_->getFileSets(), component_->getRemapStates(),\r\n        component_->getModes(),\r\n        portMapValidator, parameterValidator, libHandler_));\r\n\r\n    BusInterfaceInterface* busInterface(\r\n        new BusInterfaceInterface(busValidator, expressionParser_, expressionFormatter_));\r\n\r\n    return busInterface;\r\n}\r\n"
  },
  {
    "path": "editors/ComponentEditor/treeStructure/componenteditormemmapsitem.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: componenteditormemmapsitem.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 09.05.2012\r\n//\r\n// Description:\r\n// The Memory maps-item in the component navigation tree.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef COMPONENTEDITORMEMMAPSITEM_H\r\n#define COMPONENTEDITORMEMMAPSITEM_H\r\n\r\n#include \"componenteditoritem.h\"\r\n\r\n#include <QSharedPointer>\r\n\r\nclass ComponentEditorTreeModel;\r\nclass MemoryMapsVisualizer;\r\nclass ExpressionParser;\r\nclass MemoryMap;\r\nclass MemoryMapValidator;\r\nclass MemoryMapInterface;\r\nclass BusInterfaceInterface;\r\nclass ParameterValidator;\r\nclass MemoryMapsValidator;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! The Memory maps-item in the component navigation tree.\r\n//-----------------------------------------------------------------------------\r\nclass ComponentEditorMemMapsItem : public ComponentEditorItem\r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\r\n\t/*!\r\n\t *  The constructor.\r\n\t *\r\n\t *    @param [in] model                   The model that owns the items.\r\n\t *    @param [in] libHandler              The instance that manages the library.\r\n\t *    @param [in] component               The component being edited.\r\n     *    @param [in] referenceCounter        The instance for counting references to parameters.\r\n\t *    @param [in] parameterFinder         The parameter finder.\r\n\t *    @param [in] expressionFormatter     The expression formatter.\r\n     *    @param [in] expressionParser        The expression formatter.\r\n\t *    @param [in] parent                  The parent item.\r\n\t */\r\n\tComponentEditorMemMapsItem(ComponentEditorTreeModel* model,\r\n\t\tLibraryInterface* libHandler,\r\n\t\tQSharedPointer<Component> component,\r\n        QSharedPointer<ReferenceCounter> referenceCounter,\r\n        QSharedPointer<ParameterFinder> parameterFinder,\r\n        QSharedPointer<ExpressionFormatter> expressionFormatter,\r\n        QSharedPointer<ExpressionParser> expressionParser,\r\n\t\tComponentEditorItem* parent);\r\n\r\n\t//! The destructor.\r\n\tvirtual ~ComponentEditorMemMapsItem() = default;\r\n\r\n\t/*!\r\n     *  Get the font to be used for text of this item.\r\n\t *\r\n\t *    @return QFont instance that defines the font to be used.\r\n\t */\r\n\tvirtual QFont getFont() const;\r\n\r\n\t/*!\r\n     *  Get the tool tip for the item.\r\n\t * \r\n\t *    @return The text for the tool tip to print to user.\r\n\t */\r\n\tvirtual QString getTooltip() const;\r\n\r\n\t/*!\r\n     *  Get the text to be displayed to user in the tree for this item.\r\n\t *\r\n\t *    @return QString Contains the text to display.\r\n\t */\r\n\tvirtual QString text() const;\r\n\r\n\t/*!\r\n     *  Get The editor of this item.\r\n\t *\r\n\t *    @return The editor to use for this item.\r\n\t */\r\n\tvirtual ItemEditor* editor();\r\n\r\n\t/*!\r\n     *  Add a new child to the item.\r\n\t * \r\n\t *    @param [in] index The index to add the child into.\r\n\t */\r\n\tvirtual void createChild(int index);\r\n\r\n\t/*!\r\n     *  Get The visualizer of memory maps.\r\n\t * \r\n\t *    @return The visualizer to use for memory maps.\r\n\t */\r\n\tvirtual ItemVisualizer* visualizer();\r\n\r\npublic slots:\r\n\r\n    /*!\r\n     *  Give the selected memory map order to pass its address unit bits forward.\r\n     *\r\n     *    @param [in] memoryMapIndex   The index of the selected memory map.\r\n     */\r\n    void addressUnitBitsChangedOnMemoryMap(int memoryMapIndex);\r\n\r\nsignals:\r\n\r\n    /*!\r\n     *  Informs that a new memory remap item should be added.\r\n     *\r\n     *    @param [in] memoryRemapIndex        The index of the new memory remap item.\r\n     *    @param [in] parentMemoryMapName     Name of the parent memory map of the new memory remap.\r\n     */\r\n    void memoryRemapAdded(int memoryRemapIndex, QString const& parentMemoryMapName);\r\n\r\n    /*!\r\n     *  Informs that a memory remap item should be removed.\r\n     *\r\n     *    @param [in] memoryRemapIndex        The index of the removed memory remap item.\r\n     *    @param [in] parentMemoryMapName     Name of the parent memory map of the removed memory remap.\r\n     */\r\n    void memoryRemapRemoved(int memoryRemapIndex, QString const& parentMemoryMapName);\r\n\r\n    /*\r\n     *  Informs of memory map name change.\r\n     *\r\n     *    @param [in] oldName     The old name.\r\n     *    @param [in] newName     The new name.\r\n     */\r\n    void memoryMapNameChanged(QString const& oldName, QString const& newName);\r\n\r\n    /*\r\n     *  Informs of memory remap name change.\r\n     *\r\n     *    @param [in] oldName     The old name.\r\n     *    @param [in] newName     The new name.\r\n     */\r\n    void memoryRemapNameChanged(QString const& parentName, QString const& oldName, QString const& newName);\r\n\r\nprivate:\r\n\t//! No copying.\r\n\tComponentEditorMemMapsItem(const ComponentEditorMemMapsItem& other);\r\n\r\n\t//! No assignment.\r\n\tComponentEditorMemMapsItem& operator=(const ComponentEditorMemMapsItem& other);\r\n\r\n    /*!\r\n     *  Check the validity of this item.\r\n     *\r\n     *    @return bool True if item is in valid state.\r\n     */\r\n    virtual bool isValid() const override;\r\n\r\n    /*!\r\n     *  Create the necessary validators for memory maps.\r\n     */\r\n    void createValidators();\r\n\r\n    /*!\r\n     *  Create the interfaces for memory maps.\r\n     */\r\n    void createMemoryMapInterface();\r\n\r\n    /*!\r\n     *  Create the interface for accessing bus interfaces.\r\n     *\r\n     *    @param [in] parameterValidator  Validator for parameters.\r\n     *\r\n     *    @return The interface for accessing bus interfaces.\r\n     */\r\n    BusInterfaceInterface* createInterfaceForBus(QSharedPointer<ParameterValidator> parameterValidator);\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n\t//! Contains the memory maps being edited.\r\n    QSharedPointer<QList<QSharedPointer<MemoryMap> > > memoryMaps_;\r\n\r\n\t//! The visualizer to display the memory maps\r\n\tMemoryMapsVisualizer* visualizer_;\r\n\r\n    //! The expression parser to use.\r\n    QSharedPointer<ExpressionParser> expressionParser_;\r\n\r\n    //! The current memory maps validator\r\n    QSharedPointer<MemoryMapsValidator> memoryMapsValidator_;\r\n    \r\n    //! The current memory map validator.\r\n    QSharedPointer<MemoryMapValidator> memoryMapValidator_;\r\n\r\n    //! Interface for accessing memory maps.\r\n    MemoryMapInterface* mapInterface_;\r\n};\r\n\r\n#endif // COMPONENTEDITORMEMMAPSITEM_H\r\n"
  },
  {
    "path": "editors/ComponentEditor/treeStructure/componenteditormodelparamsitem.cpp",
    "content": "/* \r\n *  \tCreated on: 9.5.2012\r\n *      Author: Antti Kamppi\r\n * \t\tfilename: componenteditormodelparamsitem.cpp\r\n *\t\tProject: Kactus 2\r\n */\r\n\r\n#include \"componenteditormodelparamsitem.h\"\r\n\r\n#include <editors/ComponentEditor/modelParameters/modelparametereditor.h>\r\n\r\n#include <IPXACTmodels/choice.h>\r\n\r\nComponentEditorModelParamsItem::ComponentEditorModelParamsItem( ComponentEditorTreeModel* model,\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t   LibraryInterface* libHandler,\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t   QSharedPointer<Component> component,\r\n                                                               QSharedPointer<ReferenceCounter> refCounter,\r\n                                                               QSharedPointer<ParameterFinder> parameterFinder,\r\n                                                               QSharedPointer<ExpressionFormatter> expressionFormatter,\r\n                                                               ComponentEditorItem* parent):\r\nComponentEditorItem(model, libHandler, component, parent),\r\nmodelParams_(component->getModelParameters())\r\n{\r\n\tsetReferenceCounter(refCounter);\r\n    setParameterFinder(parameterFinder);\r\n    setExpressionFormatter(expressionFormatter);\r\n}\r\n\r\nComponentEditorModelParamsItem::~ComponentEditorModelParamsItem()\r\n{\r\n}\r\n\r\nQFont ComponentEditorModelParamsItem::getFont() const \r\n{\r\n    QFont font(ComponentEditorItem::getFont());\r\n    font.setBold(!modelParams_->empty());\r\n    return font;\r\n}\r\n\r\nQString ComponentEditorModelParamsItem::text() const \r\n{\r\n\treturn tr(\"Model parameters\");\r\n}\r\n\r\nbool ComponentEditorModelParamsItem::isValid() const \r\n{\r\n    // if one model parameter is invalid\r\n    foreach (QSharedPointer<ModelParameter> modelParam, *modelParams_) \r\n    {\r\n        if (!component_->validateParameter(modelParam))\r\n        {\r\n            return false;\r\n        }\r\n    }\r\n\r\n\treturn true;\r\n}\r\n\r\nItemEditor* ComponentEditorModelParamsItem::editor()\r\n{\r\n\tif (!editor_) {\r\n\t\teditor_ = new ModelParameterEditor(component_, libHandler_, parameterFinder_, expressionFormatter_);\r\n\t\teditor_->setProtection(locked_);\r\n\t\tconnect(editor_, SIGNAL(contentChanged()),\r\n\t\t\tthis, SLOT(onEditorChanged()), Qt::UniqueConnection);\r\n\t\tconnect(editor_, SIGNAL(helpUrlRequested(QString const&)),\r\n\t\t\tthis, SIGNAL(helpUrlRequested(QString const&)));\r\n\r\n        connectItemEditorToReferenceCounter();\r\n\r\n        connectReferenceTree();\r\n\t}\r\n\treturn editor_;\r\n}\r\n\r\nQString ComponentEditorModelParamsItem::getTooltip() const\r\n{\r\n\treturn tr(\"Contains the implementation parameters\");\r\n}\r\n"
  },
  {
    "path": "editors/ComponentEditor/treeStructure/componenteditormodelparamsitem.h",
    "content": "/* \r\n *  \tCreated on: 9.5.2012\r\n *      Author: Antti Kamppi\r\n * \t\tfilename: componenteditormodelparamsitem.h\r\n *\t\tProject: Kactus 2\r\n */\r\n\r\n#ifndef COMPONENTEDITORMODELPARAMSITEM_H\r\n#define COMPONENTEDITORMODELPARAMSITEM_H\r\n\r\n#include \"componenteditoritem.h\"\r\n\r\n#include <IPXACTmodels/modelparameter.h>\r\n\r\n#include <QString>\r\n#include <QList>\r\n#include <QSharedPointer>\r\n\r\n/*! \\brief The Model parameters-item in the component editor navigation tree.\r\n *\r\n */\r\nclass ComponentEditorModelParamsItem : public ComponentEditorItem {\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\r\n\t/*!\r\n\t *  The constructor.\r\n\t *\r\n\t *    @param [in] model                   Pointer to the model that owns the items.\r\n\t *    @param [in] libHandler              Pointer to the instance that manages the library.\r\n\t *    @param [in] component               Pointer to the component being edited.\r\n\t *    @param [in] refCounter              Pointer to the reference counter.\r\n\t *    @param [in] parameterFinder         Pointer to the parameter finder.\r\n\t *    @param [in] expressionFormatter     Pointer to the expression formatter.\r\n\t *    @param [in] parent                  Pointer to the parent item.\r\n\t */\r\n\tComponentEditorModelParamsItem(ComponentEditorTreeModel* model,\r\n        LibraryInterface* libHandler,\r\n        QSharedPointer<Component> component,\r\n        QSharedPointer<ReferenceCounter> refCounter,\r\n        QSharedPointer<ParameterFinder> parameterFinder,\r\n        QSharedPointer<ExpressionFormatter> expressionFormatter,\r\n        ComponentEditorItem* parent);\r\n\r\n\t//! \\brief The destructor\r\n\tvirtual ~ComponentEditorModelParamsItem();\r\n\r\n\t/*! \\brief Get the font to be used for text of this item.\r\n\t*\r\n\t* The font is bold, if model parameters exist, otherwise not bold.\r\n\t*\r\n\t* \\return QFont instance that defines the font to be used.\r\n\t*/\r\n\tvirtual QFont getFont() const;\r\n\r\n\t/*! \\brief Get the tool tip for the item.\r\n\t * \r\n\t * \\return The text for the tool tip to print to user.\r\n\t*/\r\n\tvirtual QString getTooltip() const;\r\n\r\n\t/*! \\brief Get the text to be displayed to user in the tree for this item.\r\n\t *\r\n\t * \\return QString Contains the text to display.\r\n\t*/\r\n\tvirtual QString text() const;\r\n\r\n\t/*! \\brief Check the validity of this item and sub items.\r\n\t *\r\n\t * \\return bool True if item is in valid state.\r\n\t*/\r\n\tvirtual bool isValid() const;\r\n\r\n\t/*! \\brief Get pointer to the editor of this item.\r\n\t *\r\n\t * \\return Pointer to the editor to use for this item.\r\n\t*/\r\n\tvirtual ItemEditor* editor();\r\n\r\nprivate:\r\n\t//! \\brief No copying\r\n\tComponentEditorModelParamsItem(const ComponentEditorModelParamsItem& other);\r\n\r\n\t//! \\brief No assignment\r\n\tComponentEditorModelParamsItem& operator=(const ComponentEditorModelParamsItem& other);\r\n\r\n\t//! \\brief The map that contains the model parameters.\r\n\tQSharedPointer<QList<QSharedPointer<ModelParameter> > > modelParams_;\r\n};\r\n\r\n#endif // COMPONENTEDITORMODELPARAMSITEM_H\r\n"
  },
  {
    "path": "editors/ComponentEditor/treeStructure/componenteditorotherclocksitem.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: componenteditorotherclocksitem.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 09.05.2012\r\n//\r\n// Description:\r\n// The Other clock drivers-item in the component editor's navigation tree.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"componenteditorotherclocksitem.h\"\r\n\r\n#include <editors/ComponentEditor/otherClockDrivers/otherclockdriverseditor.h>\r\n\r\n#include <IPXACTmodels/Component/Component.h>\r\n#include <IPXACTmodels/Component/OtherClockDriver.h>\r\n\r\n#include <IPXACTmodels/Component/validators/OtherClockDriverValidator.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditorOtherClocksItem::ComponentEditorOtherClocksItem()\r\n//-----------------------------------------------------------------------------\r\nComponentEditorOtherClocksItem::ComponentEditorOtherClocksItem(ComponentEditorTreeModel* model,\r\n    LibraryInterface* libHandler, QSharedPointer<Component> component,\r\n    QSharedPointer<ExpressionParser> expressionParser, ComponentEditorItem* parent):\r\nComponentEditorItem(model, libHandler, component, parent),\r\notherClocks_(component->getOtherClockDrivers()),\r\nclockValidator_(new OtherClockDriverValidator(expressionParser))\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditorOtherClocksItem::~ComponentEditorOtherClocksItem()\r\n//-----------------------------------------------------------------------------\r\nComponentEditorOtherClocksItem::~ComponentEditorOtherClocksItem()\r\n{\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditorOtherClocksItem::getFont()\r\n//-----------------------------------------------------------------------------\r\nQFont ComponentEditorOtherClocksItem::getFont() const\r\n{\r\n    QFont font(ComponentEditorItem::getFont());\r\n    font.setBold(!otherClocks_->isEmpty());\r\n    return font;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditorOtherClocksItem::text()\r\n//-----------------------------------------------------------------------------\r\nQString ComponentEditorOtherClocksItem::text() const\r\n{\r\n\treturn tr(\"Other clock drivers\");\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditorOtherClocksItem::isValid()\r\n//-----------------------------------------------------------------------------\r\nbool ComponentEditorOtherClocksItem::isValid() const\r\n{\r\n    QString clockNames;\r\n    foreach (QSharedPointer<OtherClockDriver> clockDriver, *otherClocks_)\r\n    {\r\n        if (clockNames.contains(clockDriver->getClockName()) || !clockValidator_->validate(clockDriver))\r\n        {\r\n            return false;\r\n        }\r\n        else\r\n        {\r\n            clockNames.append(clockDriver->getClockName());\r\n        }\r\n    }\r\n\r\n    return true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditorOtherClocksItem::editor()\r\n//-----------------------------------------------------------------------------\r\nItemEditor* ComponentEditorOtherClocksItem::editor()\r\n{\r\n\tif (!editor_)\r\n    {\r\n\t\teditor_ = new OtherClockDriversEditor(component_, libHandler_, clockValidator_);\r\n\t\teditor_->setProtection(locked_);\r\n\t\tconnect(editor_, SIGNAL(contentChanged()), this, SLOT(onEditorChanged()), Qt::UniqueConnection);\r\n\t\tconnect(editor_, SIGNAL(helpUrlRequested(QString const&)),\r\n\t\t\tthis, SIGNAL(helpUrlRequested(QString const&)));\r\n\t}\r\n\treturn editor_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditorOtherClocksItem::getTooltip()\r\n//-----------------------------------------------------------------------------\r\nQString ComponentEditorOtherClocksItem::getTooltip() const\r\n{\r\n\treturn tr(\"Contains the details that define clock waveforms\");\r\n}\r\n"
  },
  {
    "path": "editors/ComponentEditor/treeStructure/componenteditorotherclocksitem.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: componenteditorotherclocksitem.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 09.05.2012\r\n//\r\n// Description:\r\n// The Other clock drivers-item in the component editor's navigation tree.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef COMPONENTEDITOROTHERCLOCKSITEM_H\r\n#define COMPONENTEDITOROTHERCLOCKSITEM_H\r\n\r\n#include \"componenteditoritem.h\"\r\n\r\nclass Component;\r\nclass OtherClockDriver;\r\n\r\nclass ExpressionParser;\r\nclass OtherClockDriverValidator;\r\n//-----------------------------------------------------------------------------\r\n//! The Other clock drivers-item in the component editor's navigation tree.\r\n//-----------------------------------------------------------------------------\r\nclass ComponentEditorOtherClocksItem : public ComponentEditorItem\r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\r\n\t/*!\r\n     *  The constructor\r\n\t *\r\n\t *    @param [in] model               The model that owns the items.\r\n\t *    @param [in] libHandler          The instance that manages the library.\r\n\t *    @param [in] component           The component being edited.\r\n     *    @param [in] expressionParser    The used expression parser.\r\n\t *    @param [in] parent              The parent item.\r\n\t */\r\n\tComponentEditorOtherClocksItem(ComponentEditorTreeModel* model, LibraryInterface* libHandler,\r\n\t\tQSharedPointer<Component> component, QSharedPointer<ExpressionParser> expressionParser,\r\n        ComponentEditorItem* parent);\r\n\r\n\t//! The destructor.\r\n\tvirtual ~ComponentEditorOtherClocksItem();\r\n\r\n\t/*!\r\n     *  Get the font to be used for text of this item.\r\n\t *\r\n\t *  The font is bold, if other clock drivers exist, otherwise not bold.\r\n\t *\r\n\t *    @return The instance that defines the font to be used.\r\n\t */\r\n\tvirtual QFont getFont() const;\r\n\r\n\t/*!\r\n     *  Get the tool tip for the item.\r\n\t * \r\n\t *    @return The text for the tool tip to print to user.\r\n\t */\r\n\tvirtual QString getTooltip() const;\r\n\r\n\t/*!\r\n     *  Get the text to be displayed to user in the tree for this item.\r\n\t *\r\n\t *    @return The text to display.\r\n\t */\r\n\tvirtual QString text() const;\r\n\r\n\t/*!\r\n     *  Check the validity of this item and sub items.\r\n\t *\r\n\t *    @return True if item is in valid state.\r\n\t */\r\n\tvirtual bool isValid() const;\r\n\r\n\t/*!\r\n     *Get The editor of this item.\r\n\t *\r\n\t *    @return The editor to use for this item.\r\n\t */\r\n\tvirtual ItemEditor* editor();\r\n\r\nprivate:\r\n\r\n    //! No copying.\r\n\tComponentEditorOtherClocksItem(const ComponentEditorOtherClocksItem& other);\r\n\tComponentEditorOtherClocksItem& operator=(const ComponentEditorOtherClocksItem& other);\r\n\r\n\t//! The other clock drivers to edit.\r\n\tQSharedPointer<QList<QSharedPointer<OtherClockDriver> > > otherClocks_;\r\n\r\n    //! The validator used for other clock drivers.\r\n    QSharedPointer<OtherClockDriverValidator> clockValidator_;\r\n};\r\n\r\n#endif // COMPONENTEDITOROTHERCLOCKSITEM_H\r\n"
  },
  {
    "path": "editors/ComponentEditor/treeStructure/componenteditorparametersitem.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: componenteditorparametersitem.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 09.05.2012\r\n//\r\n// Description:\r\n// The parameters-item in the component editor navigation tree.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"componenteditorparametersitem.h\"\r\n\r\n#include <KactusAPI/include/IPXactSystemVerilogParser.h>\r\n#include <editors/ComponentEditor/parameters/parameterseditor.h>\r\n#include <KactusAPI/include/ParametersInterface.h>\r\n\r\n#include <IPXACTmodels/common/validators/ParameterValidator.h>\r\n#include <IPXACTmodels/Component/Component.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditorParametersItem::ComponentEditorParametersItem()\r\n//-----------------------------------------------------------------------------\r\nComponentEditorParametersItem::ComponentEditorParametersItem(ComponentEditorTreeModel* model,\r\n    LibraryInterface* libHandler, QSharedPointer<Component> component, QSharedPointer<ReferenceCounter> refCounter,\r\n    QSharedPointer<ParameterFinder> parameterFinder, QSharedPointer<ExpressionParser> expressionParser,\r\n    QSharedPointer<ExpressionFormatter> expressionFormatter, ComponentEditorItem* parent):\r\nParameterizableItem(model, libHandler, component, parent),\r\nexpressionParser_(expressionParser),\r\nvalidator_(new ParameterValidator(expressionParser, component->getChoices(), component->getRevision())),\r\nparameterInterface_(new ParametersInterface(validator_, expressionParser, expressionFormatter))\r\n{\r\n    parameterInterface_->setParameters(component->getParameters());\r\n    parameterInterface_->setChoices(component->getChoices());\r\n\r\n    setReferenceCounter(refCounter);\r\n    setParameterFinder(parameterFinder);\r\n    setExpressionFormatter(expressionFormatter);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditorParametersItem::getFont()\r\n//-----------------------------------------------------------------------------\r\nQFont ComponentEditorParametersItem::getFont() const\r\n{\r\n    QFont font(ComponentEditorItem::getFont());    \r\n    font.setBold(component_->hasParameters());    \r\n    return font;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditorParametersItem::text()\r\n//-----------------------------------------------------------------------------\r\nQString ComponentEditorParametersItem::text() const\r\n{\r\n\treturn tr(\"Parameters\");\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditorParametersItem::isValid()\r\n//-----------------------------------------------------------------------------\r\nbool ComponentEditorParametersItem::isValid() const\r\n{\r\n    return parameterInterface_->validateItems();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditorParametersItem::editor()\r\n//-----------------------------------------------------------------------------\r\nItemEditor* ComponentEditorParametersItem::editor()\r\n{\r\n\tif (!editor_)\r\n    {\r\n\t\teditor_ = new ParametersEditor(component_, libHandler_, parameterFinder_, expressionParser_,\r\n            expressionFormatter_, parameterInterface_);\r\n\t\teditor_->setProtection(locked_);\r\n\t\tconnect(editor_, SIGNAL(contentChanged()), this, SLOT(onEditorChanged()), Qt::UniqueConnection);\r\n\t\tconnect(editor_, SIGNAL(helpUrlRequested(QString const&)), this, SIGNAL(helpUrlRequested(QString const&)));\r\n\r\n        connectItemEditorToReferenceCounter();\r\n        connectReferenceTree();\r\n\t}\r\n\r\n\treturn editor_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditorParametersItem::getTooltip()\r\n//-----------------------------------------------------------------------------\r\nQString ComponentEditorParametersItem::getTooltip() const\r\n{\r\n\treturn tr(\"Contains the configurable elements of the component\");\r\n}\r\n"
  },
  {
    "path": "editors/ComponentEditor/treeStructure/componenteditorparametersitem.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: componenteditorparametersitem.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 09.05.2012\r\n//\r\n// Description:\r\n// The parameters-item in the component editor navigation tree.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef COMPONENTEDITORPARAMETERITEM_H\r\n#define COMPONENTEDITORPARAMETERITEM_H\r\n\r\n#include <editors/ComponentEditor/treeStructure/ParameterizableItem.h>\r\n\r\n#include <IPXACTmodels/common/Parameter.h>\r\n\r\nclass Component;\r\nclass Choice;\r\nclass ExpressionParser;\r\nclass ParameterValidator;\r\nclass ParametersInterface;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! The parameters-item in the component editor navigation tree.\r\n//-----------------------------------------------------------------------------\r\nclass ComponentEditorParametersItem : public ParameterizableItem\r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\t\r\n\t/*!\r\n\t *  The constructor.\r\n\t *\r\n\t *    @param [in] model                   The model that owns the items.\r\n\t *    @param [in] libHandler              The instance that manages the library.\r\n\t *    @param [in] component               The component being edited.\r\n\t *    @param [in] refCounter              The reference counter.\r\n\t *    @param [in] parameterFinder         The parameter finder.\r\n     *    @param [in] expressionParser        The expression parser.\r\n\t *    @param [in] expressionFormatter     The expression formatter.\r\n\t *    @param [in] parent                  The parent item.\r\n\t */\r\n\tComponentEditorParametersItem(ComponentEditorTreeModel* model,\r\n        LibraryInterface* libHandler,\r\n        QSharedPointer<Component> component,\r\n        QSharedPointer<ReferenceCounter> refCounter,\r\n        QSharedPointer<ParameterFinder> parameterFinder,\r\n        QSharedPointer<ExpressionParser> expressionParser,\r\n        QSharedPointer<ExpressionFormatter> expressionFormatter,\r\n        ComponentEditorItem* parent);\r\n\r\n\t//! The destructor.\r\n\tvirtual ~ComponentEditorParametersItem() = default;\r\n\r\n\t/*!\r\n     *  Get the font to be used for text of this item.\r\n\t *\r\n\t *    @return QFont instance that defines the font to be used.\r\n\t */\r\n\tvirtual QFont getFont() const;\r\n\r\n\t/*!\r\n     *  @Get the tool tip for the item.\r\n\t * \r\n\t *    @return The text for the tool tip to print to user.\r\n\t */\r\n\tvirtual QString getTooltip() const;\r\n\r\n\t/*!\r\n     *  Get the text to be displayed to user in the tree for this item.\r\n\t *\r\n\t *    @return QString Contains the text to display.\r\n\t */\r\n\tvirtual QString text() const;\r\n\r\n\t/*!\r\n     *  Check the validity of this item and sub items.\r\n\t *\r\n\t *    @return True if item is in valid state.\r\n\t */\r\n\tvirtual bool isValid() const;\r\n\r\n\t/*!\r\n     *  Get The editor of this item.\r\n\t *\r\n\t *    @return The editor to use for this item.\r\n\t */\r\n\tvirtual ItemEditor* editor();\r\n\r\nprivate:\r\n\r\n\t//! No copying. No assignment.\r\n\tComponentEditorParametersItem(const ComponentEditorParametersItem& other);\r\n\tComponentEditorParametersItem& operator=(const ComponentEditorParametersItem& other);\r\n\r\n    //! Expression parser for parameter values.\r\n    QSharedPointer<ExpressionParser> expressionParser_;\r\n\r\n    //! Validator for parameters.\r\n    QSharedPointer<ParameterValidator> validator_;\r\n\r\n    //! Interface for parameters.\r\n    ParametersInterface* parameterInterface_;\r\n};\r\n\r\n#endif // COMPONENTEDITORPARAMETERITEM_H\r\n"
  },
  {
    "path": "editors/ComponentEditor/treeStructure/componenteditorportsitem.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: componenteditorportsitem.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 09.05.2012\r\n//\r\n// Description:\r\n// The Ports-item in the component editor's navigation tree.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"componenteditorportsitem.h\"\r\n#include \"WirePortsItem.h\"\r\n#include \"TransactionalPortsItem.h\"\r\n\r\n#include <editors/ComponentEditor/ports/portseditor.h>\r\n\r\n#include <KactusAPI/include/ExpressionParser.h>\r\n#include <KactusAPI/include/PortsInterface.h>\r\n\r\n#include <IPXACTmodels/Component/Component.h>\r\n\r\n#include <IPXACTmodels/Component/validators/PortValidator.h>\r\n#include <IPXACTmodels/Component/validators/CollectionValidators.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditorPortsItem::ComponentEditorPortsItem()\r\n//-----------------------------------------------------------------------------\r\nComponentEditorPortsItem::ComponentEditorPortsItem(ComponentEditorTreeModel* model, LibraryInterface* libHandler,\r\n    QSharedPointer<Component> component, QSharedPointer<ReferenceCounter> refCounter,\r\n    ExpressionSet expressions,\r\n    BusInterfaceInterface* busInterface,\r\n    ComponentEditorItem* parent) :\r\n    ComponentEditorItem(model, libHandler, component, parent),\r\n    expressions_(expressions),\r\n    portValidator_(new PortValidator(expressions.parser, component->getViews())),\r\n    portsValidator_(new PortsValidator(portValidator_)),\r\n    portsInterface_(new PortsInterface(portValidator_, expressions.parser, expressions.formatter)),\r\n    busInterface_(busInterface)\r\n{\r\n    setReferenceCounter(refCounter);\r\n    setParameterFinder(expressions.finder);\r\n    setExpressionFormatter(expressions.formatter);\r\n\r\n    portsInterface_->setPorts(component->getPorts());\r\n\r\n    auto wiresItem = QSharedPointer<WirePortsItem>(new WirePortsItem(model,\r\n        libHandler, component, refCounter, expressions, portsInterface_, busInterface, this));\r\n    childItems_.append(wiresItem);\r\n\r\n    auto transactionalItem = QSharedPointer<TransactionalPortsItem>(new TransactionalPortsItem(model,\r\n        libHandler, component, refCounter, expressions, portsInterface_, busInterface, this));\r\n    childItems_.append(transactionalItem);\r\n\r\n    connect(wiresItem.data(), SIGNAL(changeVendorExtensions(QString const&, QSharedPointer<Extendable>)),\r\n        this, SIGNAL(changeVendorExtensions(QString const&, QSharedPointer<Extendable>)),\r\n        Qt::UniqueConnection);\r\n    connect(wiresItem.data(), SIGNAL(createInterface()), this, SIGNAL(createInterface()), Qt::UniqueConnection);\r\n\r\n    connect(transactionalItem.data(), SIGNAL(changeVendorExtensions(QString const&, QSharedPointer<Extendable>)),\r\n        this, SIGNAL(changeVendorExtensions(QString const&, QSharedPointer<Extendable>)),\r\n        Qt::UniqueConnection);\r\n    connect(transactionalItem.data(), SIGNAL(createInterface()), this, SIGNAL(createInterface()), Qt::UniqueConnection);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditorPortsItem::getFont()\r\n//-----------------------------------------------------------------------------\r\nQFont ComponentEditorPortsItem::getFont() const\r\n{\r\n    QFont font(ComponentEditorItem::getFont());\r\n    font.setBold(component_->hasPorts());\r\n    return font;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditorPortsItem::text()\r\n//-----------------------------------------------------------------------------\r\nQString ComponentEditorPortsItem::text() const\r\n{\r\n\treturn tr(\"Ports\");\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditorPortsItem::isValid()\r\n//-----------------------------------------------------------------------------\r\nbool ComponentEditorPortsItem::isValid() const\r\n{\r\n    auto portsAsNameGroup = CollectionValidators::itemListToNameGroupList(component_->getPorts());\r\n    portsValidator_->childrenHaveUniqueNames(portsAsNameGroup);\r\n    return ComponentEditorItem::isValid();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditorPortsItem::editor()\r\n//-----------------------------------------------------------------------------\r\nItemEditor* ComponentEditorPortsItem::editor()\r\n{\r\n\tif (!editor_)\r\n    {\r\n\t\teditor_ = new PortsEditor(\r\n            component_, libHandler_, expressions_, portValidator_, portsInterface_, busInterface_);\r\n\t\teditor_->setProtection(locked_);\r\n\r\n\t\tconnect(editor_, SIGNAL(contentChanged()), this, SLOT(onEditorChanged()), Qt::UniqueConnection);\r\n\t\tconnect(editor_, SIGNAL(helpUrlRequested(QString const&)),\r\n\t\t\tthis, SIGNAL(helpUrlRequested(QString const&)), Qt::UniqueConnection);\r\n\r\n        connectItemEditorToReferenceCounter();\r\n        connectItemEditorToVendorExtensionsEditor();\r\n\t}\r\n\treturn editor_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditorPortsItem::getTooltip()\r\n//-----------------------------------------------------------------------------\r\nQString ComponentEditorPortsItem::getTooltip() const\r\n{\r\n\treturn tr(\"Contains the external ports of the component\");\r\n}\r\n"
  },
  {
    "path": "editors/ComponentEditor/treeStructure/componenteditorportsitem.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: componenteditorportsitem.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 09.05.2012\r\n//\r\n// Description:\r\n// The Ports-item in the component editor's navigation tree.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef COMPONENTEDITORPORTSITEM_H\r\n#define COMPONENTEDITORPORTSITEM_H\r\n\r\n#include \"componenteditoritem.h\"\r\n#include <editors/common/ExpressionSet.h>\r\n\r\n#include <QList>\r\n\r\nclass Port;\r\nclass ExpressionParser;\r\nclass PortValidator;\r\nclass PortsValidator;\r\nclass PortsInterface;\r\nclass BusInterfaceInterface;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! The Ports-item in the component editor's navigation tree.\r\n//-----------------------------------------------------------------------------\r\nclass ComponentEditorPortsItem : public ComponentEditorItem\r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\r\n\t/*!\r\n\t *  The constructor.\r\n\t *\r\n\t *    @param [in] model                   The model that owns the items.\r\n\t *    @param [in] libHandler              The instance that manages the library.\r\n\t *    @param [in] component               The component being edited.\r\n\t *    @param [in] refCounter              The instance for counting references.\r\n\t *    @param [in] parameterFinder         The parameter finder.\r\n\t *    @param [in] expressionFormatter     The expression formatter.\r\n     *    @param [in] expressionParser        The expression parser.\r\n     *    @param [in] busInterface            Interface for accessing bus interfaces.\r\n\t *    @param [in] parent                  The parent item.\r\n\t */\r\n\tComponentEditorPortsItem(ComponentEditorTreeModel* model,\r\n\t\tLibraryInterface* libHandler,\r\n\t\tQSharedPointer<Component> component,\r\n        QSharedPointer<ReferenceCounter> refCounter, ExpressionSet expressions,\r\n        BusInterfaceInterface* busInterface,\r\n\t\tComponentEditorItem* parent);\r\n\r\n\t//! The destructor\r\n\t~ComponentEditorPortsItem() = default;\r\n\r\n    //! No copying\r\n    ComponentEditorPortsItem(const ComponentEditorPortsItem& other) = delete;\r\n\r\n    //! No assignment\r\n    ComponentEditorPortsItem& operator=(const ComponentEditorPortsItem& other) = delete;\r\n\r\n\t/*!\r\n     *  Get the font to be used for text of this item.\r\n\t *\r\n\t *  The font is bold, if ports exist, otherwise not bold.\r\n\t *\r\n\t *    @return QFont instance that defines the font to be used.\r\n\t */\r\n\tvirtual QFont getFont() const;\r\n\r\n\t/*!\r\n     *  Get the tool tip for the item.\r\n\t * \r\n\t *    @return The text for the tool tip to print to user.\r\n\t */\r\n\tvirtual QString getTooltip() const;\r\n\r\n\t/*!\r\n     *  Get the text to be displayed to user in the tree for this item.\r\n\t *\r\n\t *    @return QString Contains the text to display.\r\n\t */\r\n\tvirtual QString text() const;\r\n\r\n\t/*!\r\n     *  Check the validity of this item and sub items.\r\n\t *\r\n\t *    @return bool True if item is in valid state.\r\n\t */\r\n\tvirtual bool isValid() const;\r\n\r\n\t/*!\r\n     *  Get pointer to the editor of this item.\r\n\t *\r\n\t *    @return The editor to use for this item.\r\n\t */\r\n\tvirtual ItemEditor* editor();\r\n\r\nsignals:\r\n\r\n    //! Emitted when a new interface should be created in the component editor tree.\r\n    void createInterface();\r\n\r\nprivate:\r\n\r\n\tExpressionSet expressions_;\r\n\r\n    //! The used port validator.\r\n    QSharedPointer<PortValidator> portValidator_;\r\n\r\n\t//! The validator used to validate ports together.\r\n\tQSharedPointer<PortsValidator> portsValidator_;\r\n\r\n\t//! Interface for accessing ports.\r\n\tQSharedPointer<PortsInterface> portsInterface_;\r\n\r\n    //! Interface for accessing bus interfaces.\r\n    BusInterfaceInterface* busInterface_;\r\n};\r\n\r\n#endif // COMPONENTEDITORPORTSITEM_H\r\n"
  },
  {
    "path": "editors/ComponentEditor/treeStructure/componenteditorregisterfileitem.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: componenteditorregisterfileitem.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Dan Chianucci\n// Date: 19.06.2018\n//\n// Description:\n// Item representing a register file in the component editor browser tree.\n//-----------------------------------------------------------------------------\n\n#include \"componenteditorregisterfileitem.h\"\n\n#include \"componenteditorregisteritem.h\"\n\n#include <KactusAPI/include/ExpressionParser.h>\n\n#include <editors/ComponentEditor/memoryMaps/SingleRegisterFileEditor.h>\n#include <KactusAPI/include/RegisterInterface.h>\n#include <editors/ComponentEditor/memoryMaps/memoryMapsVisualizer/memorymapsvisualizer.h>\n#include <editors/ComponentEditor/memoryMaps/memoryMapsVisualizer/registerfilegraphitem.h>\n\n#include <editors/ComponentEditor/visualization/memoryvisualizationitem.h>\n\n#include <IPXACTmodels/Component/Register.h>\n#include <IPXACTmodels/Component/AddressBlock.h>\n#include <IPXACTmodels/Component/Field.h>\n#include <IPXACTmodels/Component/RegisterFile.h>\n#include <IPXACTmodels/Component/validators/RegisterFileValidator.h>\n\n#include <QApplication>\n\n//-----------------------------------------------------------------------------\n// Function: ComponentEditorRegisterFileItem::ComponentEditorRegisterFileItem()\n//-----------------------------------------------------------------------------\nComponentEditorRegisterFileItem::ComponentEditorRegisterFileItem(\n    QSharedPointer<RegisterFile> regFile,\n    ComponentEditorTreeModel* model,\n    LibraryInterface* libHandler,\n    QSharedPointer<Component> component,\n    QSharedPointer<ParameterFinder> parameterFinder,\n    QSharedPointer<ExpressionFormatter> expressionFormatter,\n    QSharedPointer<ReferenceCounter> referenceCounter,\n    QSharedPointer<ExpressionParser> expressionParser,\n    QSharedPointer<RegisterFileValidator> registerFileValidator,\n    RegisterInterface* registerInterface,\n    QSharedPointer<AddressBlock> containingBlock,\n    unsigned int addressUnitBits,\n    ComponentEditorItem* parent):\nComponentEditorItem(model, libHandler, component, parent),\nregisterFile_(regFile),\nvisualizer_(nullptr),\nregisterFileItem_(nullptr),\nexpressionParser_(expressionParser),\nregisterFileValidator_(registerFileValidator),\nregisterInterface_(registerInterface),\ncontainingBlock_(containingBlock),\naddressUnitBits_(addressUnitBits)\n{\n    setReferenceCounter(referenceCounter);\n    setParameterFinder(parameterFinder);\n    setExpressionFormatter(expressionFormatter);\n    setObjectName(tr(\"ComponentEditorRegFileItem\"));\n\n    const int registerCount = registerFile_->getRegisterData()->count();\n    for (int i = 0; i < registerCount; ++i)\n    {\n        createChild(i);\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: ComponentEditorRegisterFileItem::getTooltip()\n//-----------------------------------------------------------------------------\nQString ComponentEditorRegisterFileItem::getTooltip() const\n{\n    return tr(\"Contains details of a single register file.\");\n}\n\n//-----------------------------------------------------------------------------\n// Function: ComponentEditorRegisterFileItem::text()\n//-----------------------------------------------------------------------------\nQString ComponentEditorRegisterFileItem::text() const\n{\n    return registerFile_->name();\n}\n\n//-----------------------------------------------------------------------------\n// Function: ComponentEditorRegisterFileItem::isValid()\n//-----------------------------------------------------------------------------\nbool ComponentEditorRegisterFileItem::isValid() const\n{\n    return registerFileValidator_->validate(registerFile_, QString::number(addressUnitBits_), containingBlock_->getWidth());\n}\n\n//-----------------------------------------------------------------------------\n// Function: ComponentEditorAddrBlockItem::createChild()\n//-----------------------------------------------------------------------------\nvoid ComponentEditorRegisterFileItem::createChild( int index )\n{\n    QSharedPointer<RegisterBase> regmodel = registerFile_->getRegisterData()->at(index);\n\n    QSharedPointer<Register> reg = regmodel.dynamicCast<Register>();\n    if (reg)\n    {\n        QSharedPointer<ComponentEditorRegisterItem> regItem(new ComponentEditorRegisterItem(reg,\n            registerFile_->getRegisterData(), model_, libHandler_, component_, parameterFinder_,\n            expressionFormatter_, referenceCounter_, expressionParser_,\n            registerFileValidator_->getRegisterValidator(), registerInterface_, this));\n\n        connect(this, SIGNAL(registerNameChanged(QString const&, QString const&)),\n            regItem.data(), SIGNAL(registerNameChanged(QString const&, QString const&)), Qt::UniqueConnection);\n\n        regItem->setLocked(locked_);\n\n\n        if (reg->getFields()->isEmpty())\n        {\n            QSharedPointer<Field> newField (new Field());\n            reg->getFields()->append(newField);\n\n            regItem->createChild(0);\n        }\n        \n        if (visualizer_)\n        {\n            regItem->setVisualizer(visualizer_);\n        }\n\n        connect(regItem.data(), SIGNAL(addressingChanged()),\n            this, SLOT(onAddressingChanged()), Qt::UniqueConnection);\n        childItems_.insert(index, regItem);\n    }\n\n    QSharedPointer<RegisterFile> regFile = regmodel.dynamicCast<RegisterFile>();\n    if (regFile)\n    {\n        QSharedPointer<ComponentEditorRegisterFileItem> regFileItem(new ComponentEditorRegisterFileItem(regFile,\n            model_, libHandler_, component_, parameterFinder_, expressionFormatter_, referenceCounter_,\n            expressionParser_, registerFileValidator_, registerInterface_, containingBlock_, addressUnitBits_, this));\n        regFileItem->setLocked(locked_);\n     \n        if (visualizer_)\n        {\n            regFileItem->setVisualizer(visualizer_);\n        }\n\n        connect(regFileItem.data(), SIGNAL(addressingChanged()),\n            this, SLOT(onAddressingChanged()), Qt::UniqueConnection);\n        childItems_.insert(index, regFileItem);\n    }\n\n    if (visualizer_)\n    {\n        auto childItem = static_cast<MemoryVisualizationItem*>(childItems_.at(index)->getGraphicsItem());\n        Q_ASSERT(childItem);\n\n        registerFileItem_->addChild(childItem);\n        onAddressingChanged();\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: componenteditorregisteritem::removeChild()\n//-----------------------------------------------------------------------------\nvoid ComponentEditorRegisterFileItem::removeChild(int index)\n{\n    if (visualizer_)\n    {\n        auto childItem = static_cast<MemoryVisualizationItem*>(childItems_.at(index)->getGraphicsItem());\n        Q_ASSERT(childItem);\n\n        registerFileItem_->removeChild(childItem);\n        onAddressingChanged();\n    }\n\n    ComponentEditorItem::removeChild(index);\n}\n\n//-----------------------------------------------------------------------------\n\n// Function: ComponentEditorRegisterFileItem::editor()\n//-----------------------------------------------------------------------------\nItemEditor* ComponentEditorRegisterFileItem::editor()\n{\n    if (!editor_)\n    {\n        editor_ = new SingleRegisterFileEditor(registerInterface_, registerFile_, component_, libHandler_,\n            parameterFinder_, expressionFormatter_, expressionParser_, registerFileValidator_);\n        editor_->setProtection(locked_);\n        connect(editor_, SIGNAL(contentChanged()), this, SLOT(onEditorChanged()), Qt::UniqueConnection);\n        connect(editor_, SIGNAL(graphicsChanged()), this, SLOT(onGraphicsChanged()), Qt::UniqueConnection);\n        connect(editor_, SIGNAL(childGraphicsChanged(int)), this, SLOT(onChildGraphicsChanged(int)), Qt::UniqueConnection);\n        connect(editor_, SIGNAL(addressingChanged()), this, SLOT(onAddressingChanged()), Qt::UniqueConnection);\n        connect(editor_, SIGNAL(childAddressingChanged(int)),\n            this, SLOT(onChildAddressingChanged(int)), Qt::UniqueConnection);\n        connect(editor_, SIGNAL(childAdded(int)), this, SLOT(onAddChild(int)), Qt::UniqueConnection);\n        connect(editor_, SIGNAL(childRemoved(int)), this, SLOT(onRemoveChild(int)), Qt::UniqueConnection);\n        connect(editor_, SIGNAL(helpUrlRequested(QString const&)), this, SIGNAL(helpUrlRequested(QString const&)));\n\n        connect(editor_, SIGNAL(registerNameChanged(QString const&, QString const&)),\n            this, SIGNAL(registerNameChanged(QString const&, QString const&)), Qt::UniqueConnection);\n\n        connectItemEditorToReferenceCounter();\n    }\n\n    return editor_;\n}\n\n//-----------------------------------------------------------------------------\n// Function: ComponentEditorRegisterFileItem::visualizer()\n//-----------------------------------------------------------------------------\nItemVisualizer* ComponentEditorRegisterFileItem::visualizer()\n{\n    return visualizer_;\n}\n\n//-----------------------------------------------------------------------------\n// Function: ComponentEditorRegisterFileItem::setVisualizer()\n//-----------------------------------------------------------------------------\nvoid ComponentEditorRegisterFileItem::setVisualizer( MemoryMapsVisualizer* visualizer )\n{\n    visualizer_ = visualizer;\n\n    auto parentItem = static_cast<MemoryVisualizationItem*>(parent()->getGraphicsItem());\n    Q_ASSERT(parentItem);\n\n    registerFileItem_ = new RegisterFileGraphItem(registerFile_, expressionParser_, parentItem);    \n\n    connect(registerFileItem_, SIGNAL(selectEditor()), this, SLOT(onSelectRequest()), Qt::UniqueConnection);\n\n    // update the visualizers for field items\n    for (QSharedPointer<ComponentEditorItem> child : childItems_)\n    {\n        auto regItem = child.dynamicCast<ComponentEditorRegisterItem>();\n        auto regFileItem = child.dynamicCast<ComponentEditorRegisterFileItem>();\n\n        if (regItem)\n        {\n            regItem->setVisualizer(visualizer_);\n        }\n        else if (regFileItem)\n        {\n            regFileItem->setVisualizer(visualizer_);\n        }\n\n        auto childGraphicItem = static_cast<MemoryVisualizationItem*>(child->getGraphicsItem());\n        registerFileItem_->addChild(childGraphicItem);\n    }\n\n    registerFileItem_->redoChildLayout();\n}\n\n//-----------------------------------------------------------------------------\n// Function: ComponentEditorRegisterFileItem::addressUnitBitsChanged()\n//-----------------------------------------------------------------------------\nvoid ComponentEditorRegisterFileItem::addressUnitBitsChanged(int newAddressUnitBits)\n{\n    addressUnitBits_ = newAddressUnitBits;\n\n    for (auto const& child : childItems_)\n    {\n        if (auto regFileItem = child.dynamicCast<ComponentEditorRegisterFileItem>())\n        {\n            regFileItem->addressUnitBitsChanged(newAddressUnitBits);\n        }\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: ComponentEditorRegisterFileItem::getGraphicsItem()\n//-----------------------------------------------------------------------------\nQGraphicsItem* ComponentEditorRegisterFileItem::getGraphicsItem()\n{\n    return registerFileItem_;\n}\n\n//-----------------------------------------------------------------------------\n// Function: ComponentEditorRegisterFileItem::updateGraphics()\n//-----------------------------------------------------------------------------\nvoid ComponentEditorRegisterFileItem::updateGraphics()\n{\n    onGraphicsChanged();\n}\n\n//-----------------------------------------------------------------------------\n// Function: ComponentEditorRegisterFileItem::onGraphicsChanged()\n//-----------------------------------------------------------------------------\nvoid ComponentEditorRegisterFileItem::onGraphicsChanged()\n{\n    if (registerFileItem_ != nullptr)\n    {\n        registerFileItem_->updateDisplay();\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: ComponentEditorRegisterFileItem::onChildGraphicsChanged()\n//-----------------------------------------------------------------------------\nvoid ComponentEditorRegisterFileItem::onChildGraphicsChanged(int index)\n{\n    childItems_.at(index)->updateGraphics();\n}\n\n//-----------------------------------------------------------------------------\n// Function: ComponentEditorRegisterFileItem::onAddressingChanged()\n//-----------------------------------------------------------------------------\nvoid ComponentEditorRegisterFileItem::onAddressingChanged()\n{\n    if (registerFileItem_ != nullptr)\n    {\n        registerFileItem_->redoChildLayout();\n\n        emit addressingChanged();\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: ComponentEditorRegisterFileItem::onChildAddressingChanged()\n//-----------------------------------------------------------------------------\nvoid ComponentEditorRegisterFileItem::onChildAddressingChanged(int index)\n{\n    if (registerFileItem_ != nullptr)\n    {\n        childItems_.at(index)->updateGraphics();\n\n        auto childRegister = childItems_.at(index).dynamicCast<ComponentEditorRegisterItem>();\n        auto childRegisterFile = childItems_.at(index).dynamicCast<ComponentEditorRegisterFileItem>(); \n\n        if (childRegister)\n        {\n            childRegister->onChildAddressingChanged();\n        }\n        else if (childRegisterFile)\n        {\n            childRegisterFile->registerFileItem_->redoChildLayout();\n        }\n    }\n\n    onAddressingChanged();\n}\n\n\n//-----------------------------------------------------------------------------\n// Function: ComponentEditorRegisterFileItem::removeGraphicsItem()\n//-----------------------------------------------------------------------------\nvoid ComponentEditorRegisterFileItem::removeGraphicsItem()\n{\n    if (registerFileItem_)\n    {\n        // get the graphics item for the address block.\n        auto parentItem = static_cast<MemoryVisualizationItem*>(parent()->getGraphicsItem());\n        Q_ASSERT(parentItem);\n\n        //sparentItem->removeChild(registerFileItem_);\n        registerFileItem_->setParent(nullptr);\n\n        disconnect(registerFileItem_, SIGNAL(selectEditor()), this, SLOT(onSelectRequest()));\n\n        delete registerFileItem_;\n        registerFileItem_ = nullptr;\n    }\n}\n"
  },
  {
    "path": "editors/ComponentEditor/treeStructure/componenteditorregisterfileitem.h",
    "content": "//-----------------------------------------------------------------------------\n// File: componenteditorregisterfileitem.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Dan Chianucci\n// Date: 19.06.2018\n//\n// Description:\n// Item representing a register file in the component editor browser tree.\n//-----------------------------------------------------------------------------\n\n#ifndef COMPONENTEDITORREGISTERFILEITEM_H\n#define COMPONENTEDITORREGISTERFILEITEM_H\n\n#include \"componenteditoritem.h\"\n\n#include <IPXACTmodels/Component/RegisterFile.h>\n#include <QSharedPointer>\n\nclass MemoryVisualizationItem;\nclass MemoryMapsVisualizer;\nclass RegisterFileGraphItem;\nclass RegisterFileValidator;\nclass RegisterInterface;\nclass AddressBlock;\n\n//-----------------------------------------------------------------------------\n//! Item representing a register file in the component editor browser tree.\n//-----------------------------------------------------------------------------\nclass ComponentEditorRegisterFileItem : public ComponentEditorItem\n{\n    Q_OBJECT\n\npublic:\n    /*!\n     *  The constructor.\n     *\n     *    @param [in] regFile                   The register file being edited.\n     *    @param [in] model                     The model that owns the items.\n     *    @param [in] libHandler                The instance that manages the library.\n     *    @param [in] component                 The component being edited.\n     *    @param [in] referenceCounter          The instance for counting references to parameters.\n     *    @param [in] parameterFinder           The parameter finder.\n     *    @param [in] expressionFormatter       The expression formatter.\n     *    @param [in] expressionParser          The expression formatter.\n     *    @param [in] addressBlockValidator     Validator used for address blocks.\n     *    @param [in] registerInterface         Interface for accessing registers.\n     *    @param [in] containingBlock           Address block containing the edited register file.\n     *    @param [in] addressUnitBits           Address unit bits of the memory map.\n     *    @param [in] parent                    The parent item.\n     */\n    ComponentEditorRegisterFileItem(\n        QSharedPointer<RegisterFile> regFile,\n        ComponentEditorTreeModel* model,\n        LibraryInterface* libHandler,\n        QSharedPointer<Component> component,\n        QSharedPointer<ParameterFinder> parameterFinder,\n        QSharedPointer<ExpressionFormatter> expressionFormatter,\n        QSharedPointer<ReferenceCounter> referenceCounter,\n        QSharedPointer<ExpressionParser> expressionParser,\n        QSharedPointer<RegisterFileValidator> registerFileValidator,\n        RegisterInterface* registerInterface,\n        QSharedPointer<AddressBlock> containingBlock,\n        unsigned int addressUnitBits,\n        ComponentEditorItem* parent);\n\n    /*!\n     *  The destructor.\n     */\n    virtual ~ComponentEditorRegisterFileItem() = default;\n\n    //! No copying. No assignment.\n    ComponentEditorRegisterFileItem(const ComponentEditorRegisterFileItem& other) = delete;\n    ComponentEditorRegisterFileItem& operator=(const ComponentEditorRegisterFileItem& other) = delete;\n\n    /*!\n    *  Get the tool tip for the item.\n    *\n    *    @return The text for the tool tip to print to user.\n    */\n    virtual QString getTooltip() const override final;\n\n    /*!\n    *  Get the text to be displayed to user in the tree for this item.\n    *\n    *    @return QString Contains the text to display.\n    */\n    virtual QString text() const override final;\n\n    /*!\n    *  Check the validity of this item and sub items.\n    *\n    *    @return bool True if item is in valid state.\n    */\n    virtual bool isValid() const override final;\n\n    /*!\n    *  Get pointer to the editor of this item.\n    *\n    *    @return The editor to use for this item.\n    */\n    virtual ItemEditor* editor() override final;\n\n    /*!\n    *  Add a new child to the item.\n    *\n    *    @param [in] index The index to add the child into.\n    */\n    virtual void createChild(int index) override final;\n\n    virtual void removeChild(int index) override final;\n\n    /*!\n    *  Get the visualizer graphics item for the memory map.\n    *\n    *    @return QGraphicsItem* The graphics item.\n    */\n    virtual QGraphicsItem* getGraphicsItem() override final;\n\n    /*!\n    *  Remove the graphics item of the memory map.\n    */\n    virtual void removeGraphicsItem() override final;\n\n    /*!\n    *  Get pointer to the visualizer of this item.\n    *\n    *    @return The visualizer to use for this item.\n    */\n    virtual ItemVisualizer* visualizer() override final;\n\n    /*!\n    *  Update the graphics item of the memory map.\n    */\n    virtual void updateGraphics() override final;\n\n    void setVisualizer(MemoryMapsVisualizer* visualizer);\n\n\n    /*!\n     *\tUpdate the currently set address unit bits value.\n     *  \n     *    @param [in] newAddressUnitBits     The new address unit bits value to set.\n     */\n    void addressUnitBitsChanged(int newAddressUnitBits);\n\nsignals:\n\n    void addressingChanged();\n\n\n    /*\n     *  Informs of register name change.\n     *\n     *    @param [in] oldName     The old name.\n     *    @param [in] newName     The new name.\n     */\n    void registerNameChanged(QString const& oldName, QString const& newName);\n\n public slots:\n\n    void onAddressingChanged();\n\n    void onChildAddressingChanged(int index);\n\n\nprotected slots:\n\n\n    //!  Handler for editor's contentChanged signal.\n    virtual void onGraphicsChanged() override final;\n\n    void onChildGraphicsChanged(int index);\n\nprivate:\n\n    //! The register file being edited.\n    QSharedPointer<RegisterFile> registerFile_;\n\n    //! The visualizer for memory maps.\n    MemoryMapsVisualizer* visualizer_ = nullptr;\n\n    //! The graph item that visualizes the register file and its dimensions.\n    RegisterFileGraphItem* registerFileItem_ = nullptr;\n\n    //! The expression parser to use.\n    QSharedPointer<ExpressionParser> expressionParser_;\n\n    //! The used address block validator.\n    QSharedPointer<RegisterFileValidator> registerFileValidator_;\n\n    //! Interface for registers.\n    RegisterInterface* registerInterface_;\n\n    //! Address block containing the edited register file.\n    QSharedPointer<AddressBlock> containingBlock_;\n\n    //! The currently set address unit bits.\n    unsigned int addressUnitBits_;\n};\n\n#endif // COMPONENTEDITORREGISTERFILEITEM_H\n"
  },
  {
    "path": "editors/ComponentEditor/treeStructure/componenteditorregisteritem.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: componenteditorregisteritem.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 24.08.2012\r\n//\r\n// Description:\r\n// The item for single register in component editor's navigation tree.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"componenteditorregisteritem.h\"\r\n#include \"componenteditorfielditem.h\"\r\n\r\n#include <KactusAPI/include/ExpressionParser.h>\r\n\r\n#include <editors/ComponentEditor/memoryMaps/SingleRegisterEditor.h>\r\n#include <KactusAPI/include/FieldInterface.h>\r\n#include <KactusAPI/include/RegisterInterface.h>\r\n#include <editors/ComponentEditor/memoryMaps/memoryMapsVisualizer/memorymapsvisualizer.h>\r\n#include <editors/ComponentEditor/memoryMaps/memoryMapsVisualizer/registergraphitem.h>\r\n\r\n#include <editors/ComponentEditor/visualization/memoryvisualizationitem.h>\r\n\r\n#include <IPXACTmodels/Component/Component.h>\r\n#include <IPXACTmodels/Component/Register.h>\r\n#include <IPXACTmodels/Component/AddressBlock.h>\r\n#include <IPXACTmodels/Component/Field.h>\r\n\r\n#include <IPXACTmodels/Component/validators/RegisterValidator.h>\r\n\r\n#include <QApplication>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: componenteditorregisteritem::ComponentEditorRegisterItem()\r\n//-----------------------------------------------------------------------------\r\nComponentEditorRegisterItem::ComponentEditorRegisterItem(QSharedPointer<Register> reg,\r\n    QSharedPointer<QList<QSharedPointer<RegisterBase>>> containingRegisterData, ComponentEditorTreeModel* model,\r\n    LibraryInterface* libHandler, QSharedPointer<Component> component,\r\n    QSharedPointer<ParameterFinder> parameterFinder, QSharedPointer<ExpressionFormatter> expressionFormatter,\r\n    QSharedPointer<ReferenceCounter> referenceCounter, QSharedPointer<ExpressionParser> expressionParser,\r\n    QSharedPointer<RegisterValidator> registerValidator, RegisterInterface* registerInterface,\r\n    ComponentEditorItem* parent):\r\nComponentEditorItem(model, libHandler, component, parent),\r\nreg_(reg),\r\nexpressionParser_(expressionParser),\r\nregisterValidator_(registerValidator),\r\nregisterInterface_(registerInterface),\r\ncontainingRegisterData_(containingRegisterData)\r\n{\r\n    setReferenceCounter(referenceCounter);\r\n    setParameterFinder(parameterFinder);\r\n    setExpressionFormatter(expressionFormatter);\r\n\r\n\tsetObjectName(tr(\"ComponentEditorRegisterItem\"));\r\n\r\n    const int fieldCount = reg_->getFields()->count();\r\n\r\n\tfor (int i = 0; i < fieldCount; ++i)\r\n    {\r\n        createChild(i);\r\n    }\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: componenteditorregisteritem::getToolTip()\r\n//-----------------------------------------------------------------------------\r\nQString ComponentEditorRegisterItem::getTooltip() const\r\n{\r\n\treturn tr(\"Contains details of a single register.\");\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: componenteditorregisteritem::text()\r\n//-----------------------------------------------------------------------------\r\nQString ComponentEditorRegisterItem::text() const\r\n{\r\n\treturn reg_->name();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: componenteditorregisteritem::isValid()\r\n//-----------------------------------------------------------------------------\r\nbool ComponentEditorRegisterItem::isValid() const\r\n{\r\n    return registerValidator_->validate(reg_);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: componenteditorregisteritem::editor()\r\n//-----------------------------------------------------------------------------\r\nItemEditor* ComponentEditorRegisterItem::editor()\r\n{\r\n\tif (!editor_)\r\n    {\r\n        editor_ = new SingleRegisterEditor(reg_, component_, libHandler_, parameterFinder_, expressionParser_,\r\n            registerInterface_, containingRegisterData_);\r\n        editor_->setProtection(locked_);\r\n\t\tconnect(editor_, SIGNAL(contentChanged()), this, SLOT(onEditorChanged()), Qt::UniqueConnection);\r\n        connect(editor_, SIGNAL(graphicsChanged()), this, SLOT(onGraphicsChanged()), Qt::UniqueConnection);\r\n        connect(editor_, SIGNAL(addressingChanged()), this, SLOT(onAddressingChanged()), Qt::UniqueConnection);\r\n        connect(editor_, SIGNAL(addressingChanged()), this, SIGNAL(addressingChanged()), Qt::UniqueConnection);\r\n        connect(editor_, SIGNAL(childGraphicsChanged(int)), this, SLOT(onChildGraphicsChanged(int)), Qt::UniqueConnection);\r\n        connect(editor_, SIGNAL(childAddressingChanged(int)), this, SLOT(onChildAddressingChanged()), Qt::UniqueConnection);\r\n        \r\n\t\tconnect(editor_, SIGNAL(childAdded(int)), this, SLOT(onAddChild(int)), Qt::UniqueConnection);\r\n\t\tconnect(editor_, SIGNAL(childRemoved(int)), this, SLOT(onRemoveChild(int)), Qt::UniqueConnection);\r\n\t\tconnect(editor_, SIGNAL(helpUrlRequested(QString const&)), this, SIGNAL(helpUrlRequested(QString const&)));\r\n\r\n        connect(editor_, SIGNAL(fieldNameChanged(QString const&, QString const&)),\r\n            this, SIGNAL(fieldNameChanged(QString const&, QString const&)), Qt::UniqueConnection);\r\n\r\n        connect(this, SIGNAL(registerNameChanged(QString const&, QString const&)),\r\n            editor_, SLOT(onRegisterNameChanged(QString const&, QString const&)), Qt::UniqueConnection);\r\n\r\n        connectItemEditorToReferenceCounter();\r\n\t}\r\n\r\n\treturn editor_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: componenteditorregisteritem::createChild()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentEditorRegisterItem::createChild( int index )\r\n{\r\n\tQSharedPointer<ComponentEditorFieldItem> fieldItem(new ComponentEditorFieldItem(\r\n\t\treg_, reg_->getFields()->at(index), model_, libHandler_, component_, parameterFinder_, \r\n        referenceCounter_, expressionParser_, expressionFormatter_, registerValidator_->getFieldValidator(),\r\n        registerInterface_->getSubInterface(), this));\r\n\tfieldItem->setLocked(locked_);\r\n\t\r\n\tif (visualizer_)\r\n    {\r\n\t\tfieldItem->setVisualizer(visualizer_);\r\n\r\n        auto childItem = static_cast<MemoryVisualizationItem*>(fieldItem->getGraphicsItem());\r\n        Q_ASSERT(childItem);\r\n\r\n        registerItem_->addChild(childItem);\r\n        onChildAddressingChanged();\r\n\r\n    connect(this, SIGNAL(fieldNameChanged(QString const&, QString const&)),\r\n        fieldItem.data(), SIGNAL(fieldNameChanged(QString const&, QString const&)), Qt::UniqueConnection);\r\n\r\n        connect(fieldItem.data(), SIGNAL(addressingChanged()), this, SLOT(onChildAddressingChanged()));\r\n\t}\r\n\r\n\tchildItems_.insert(index, fieldItem);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: componenteditorregisteritem::removeChild()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentEditorRegisterItem::removeChild(int index)\r\n{\r\n    auto fieldItem = childItems_.at(index).dynamicCast<ComponentEditorFieldItem>();\r\n\r\n    if (visualizer_)\r\n    {\r\n        auto childItem = static_cast<MemoryVisualizationItem*>(fieldItem->getGraphicsItem());\r\n        Q_ASSERT(childItem);\r\n\r\n        registerItem_->removeChild(childItem);\r\n        onChildAddressingChanged();\r\n    }\r\n\r\n    ComponentEditorItem::removeChild(index);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: componenteditorregisteritem::visualizer()\r\n//-----------------------------------------------------------------------------\r\nItemVisualizer* ComponentEditorRegisterItem::visualizer()\r\n{\r\n\treturn visualizer_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: componenteditorregisteritem::setVisualizer()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentEditorRegisterItem::setVisualizer(MemoryMapsVisualizer* visualizer)\r\n{\r\n\tvisualizer_ = visualizer;\r\n\r\n    auto parentItem = static_cast<MemoryVisualizationItem*>(parent()->getGraphicsItem());\r\n    Q_ASSERT(parentItem);\r\n\r\n    registerItem_ = new RegisterGraphItem(reg_, expressionParser_, parentItem);\r\n    \r\n    connect(registerItem_, SIGNAL(selectEditor()), this, SLOT(onSelectRequest()), Qt::UniqueConnection);\r\n\r\n\t// update the visualizers for field items\r\n\tfor (auto& item : childItems_)\r\n    {\r\n\t\tauto fieldItem = item.staticCast<ComponentEditorFieldItem>();\r\n\t\tfieldItem->setVisualizer(visualizer_);\r\n\r\n        auto childItem = static_cast<MemoryVisualizationItem*>(fieldItem->getGraphicsItem());\r\n        Q_ASSERT(childItem);\r\n\r\n        registerItem_->addChild(childItem);\r\n\r\n        connect(item.data(), SIGNAL(addressingChanged()), this, SLOT(onChildAddressingChanged()));\r\n\t}\r\n\r\n    registerItem_->redoChildLayout();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: componenteditorregisteritem::getGraphicsItem()\r\n//-----------------------------------------------------------------------------\r\nQGraphicsItem* ComponentEditorRegisterItem::getGraphicsItem()\r\n{\r\n    return registerItem_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: componenteditorregisteritem::updateGraphics()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentEditorRegisterItem::updateGraphics()\r\n{\r\n    onGraphicsChanged();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditorRegisterItem::onGraphicsChanged()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentEditorRegisterItem::onGraphicsChanged()\r\n{\r\n    if (registerItem_ != nullptr)\r\n    {\r\n        registerItem_->updateDisplay();\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditorRegisterItem::onChildGraphicsChanged()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentEditorRegisterItem::onChildGraphicsChanged(int index)\r\n{\r\n    childItems_.at(index)->updateGraphics();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditorRegisterItem::onAddressingChanged()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentEditorRegisterItem::onAddressingChanged()\r\n{\r\n    if (registerItem_ != nullptr)\r\n    {\r\n        registerItem_->redoChildLayout();\r\n\r\n        emit addressingChanged();\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditorRegisterItem::onChildAddressingChanged()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentEditorRegisterItem::onChildAddressingChanged()\r\n{\r\n    if (registerItem_ != nullptr)\r\n    {\r\n        registerItem_->redoChildLayout();\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: componenteditorregisteritem::removeGraphicsItem()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentEditorRegisterItem::removeGraphicsItem()\r\n{\r\n    if (registerItem_)\r\n    {\r\n        // get the graphics item for the address block.\r\n        auto parentItem = static_cast<MemoryVisualizationItem*>(parent()->getGraphicsItem());\r\n        Q_ASSERT(parentItem);\r\n\r\n        registerItem_->setParent(nullptr);\r\n\r\n        disconnect(registerItem_, SIGNAL(selectEditor()), this, SLOT(onSelectRequest()));\r\n\r\n        delete registerItem_;\r\n        registerItem_ = nullptr;\r\n    }\r\n}\r\n"
  },
  {
    "path": "editors/ComponentEditor/treeStructure/componenteditorregisteritem.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: componenteditorregisteritem.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 24.08.2012\r\n//\r\n// Description:\r\n// The item for single register in component editor's navigation tree.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef COMPONENTEDITORREGISTERITEM_H\r\n#define COMPONENTEDITORREGISTERITEM_H\r\n\r\n#include \"componenteditoritem.h\"\r\n\r\n#include <KactusAPI/include/ParameterFinder.h>\r\n#include <KactusAPI/include/ExpressionFormatter.h>\r\n#include <editors/ComponentEditor/referenceCounter/ReferenceCounter.h>\r\n\r\n#include <QSharedPointer>\r\n#include <QList>\r\n\r\nclass MemoryMapsVisualizer;\r\nclass MemoryVisualizationItem;\r\nclass RegisterGraphItem;\r\nclass ExpressionParser;\r\nclass Component;\r\nclass Register;\r\nclass Field;\r\nclass RegisterValidator;\r\nclass FieldInterface;\r\nclass RegisterInterface;\r\nclass RegisterBase;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! The item for single register in component editor's navigation tree.\r\n//-----------------------------------------------------------------------------\r\nclass ComponentEditorRegisterItem : public ComponentEditorItem\r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\r\n\t/*!\r\n\t *  The constructor.\r\n\t *\r\n\t *    @param [in] reg                     The register being edited.\r\n     *    @param [in] containingRegisterData  Register data containing the edited register.\r\n\t *    @param [in] model                   The model that owns the items.\r\n\t *    @param [in] libHandler              The instance that manages the library.\r\n\t *    @param [in] component               The component being edited.\r\n\t *    @param [in] parameterFinder         The parameter finder.\r\n\t *    @param [in] expressionFormatter     The expression formatter.\r\n\t *    @param [in] referenceCounter        The instance counting references made to parameters.\r\n\t *    @param [in] expressionParser        The expression parser to use.\r\n     *    @param [in] registerValidator       Validator for registers.\r\n     *    @param [in] registerInterface       Interface for registers.\r\n\t *    @param [in] parent                  The parent item.\r\n\t */\r\n\tComponentEditorRegisterItem(QSharedPointer<Register> reg, \r\n        QSharedPointer<QList<QSharedPointer<RegisterBase> > > containingRegisterData,\r\n\t\tComponentEditorTreeModel* model,\r\n\t\tLibraryInterface* libHandler,\r\n\t\tQSharedPointer<Component> component,\r\n        QSharedPointer<ParameterFinder> parameterFinder,\r\n        QSharedPointer<ExpressionFormatter> expressionFormatter,\r\n        QSharedPointer<ReferenceCounter> referenceCounter,\r\n        QSharedPointer<ExpressionParser> expressionParser,\r\n        QSharedPointer<RegisterValidator> registerValidator,\r\n        RegisterInterface* registerInterface,\r\n\t\tComponentEditorItem* parent);\r\n\r\n\t/*!\r\n     *  The destructor.\r\n     */\r\n\tvirtual ~ComponentEditorRegisterItem() = default;\r\n\r\n    //! No copying. No assignment.\r\n    ComponentEditorRegisterItem(const ComponentEditorRegisterItem& other) = delete;\r\n    ComponentEditorRegisterItem& operator=(const ComponentEditorRegisterItem& other) = delete;\r\n\r\n\t/*! Get the tool tip for the item.\r\n\t * \r\n\t *    @return The text for the tool tip to print to user.\r\n\t */\r\n\tvirtual QString getTooltip() const;\r\n\r\n\t/*! Get the text to be displayed to user in the tree for this item.\r\n\t *\r\n\t *    @return QString Contains the text to display.\r\n\t */\r\n\tvirtual QString text() const;\r\n\r\n\t/*! Check the validity of this item and sub items.\r\n\t *\r\n\t *    @return bool True if item is in valid state.\r\n\t */\r\n\tvirtual bool isValid() const;\r\n\r\n\t/*! Get pointer to the editor of this item.\r\n\t *\r\n\t *    @return Pointer to the editor to use for this item.\r\n\t */\r\n\tvirtual ItemEditor* editor();\r\n\r\n\t/*! Add a new child to the item.\r\n\t * \r\n\t *    @param [in] index The index to add the child into.\r\n\t */\r\n\tvirtual void createChild(int index) override final;\r\n\r\n    /*! Remove a child from the item.\r\n     *\r\n     *    @param [in] index The index to remove the child from.\r\n     */\r\n    virtual void removeChild(int index) override final;\r\n\r\n\t/*! Get pointer to the visualizer of this item.\r\n\t * \r\n\t *    @return Pointer to the visualizer to use for this item.\r\n\t */\r\n\tvirtual ItemVisualizer* visualizer() override final;\r\n\r\n\t/*! Set the visualizer for this item.\r\n\t *\r\n\t *    @param [in] visualizer Pointer to the visualizer.\r\n\t */\r\n    void setVisualizer(MemoryMapsVisualizer* visualizer);\r\n\r\n\t/*! Get the visualizer graphics item for the register.\r\n\t *\r\n\t *    @return QGraphicsItem* Pointer to the graphics item.\r\n\t */\r\n\tvirtual QGraphicsItem* getGraphicsItem() override final;\r\n\r\n    //! Update the graphics item of the register.\r\n    virtual void updateGraphics() override final;\r\n\r\n\t//! Remove the graphics item of the register.\r\n\tvirtual void removeGraphicsItem() override final;\r\n\r\nsignals:\r\n\r\n    /*\r\n     *  Informs of field name change.\r\n     *\r\n     *    @param [in] oldName     The old name.\r\n     *    @param [in] newName     The new name.\r\n     */\r\n    void fieldNameChanged(QString const& oldName, QString const& newName);\r\n\r\n    /*\r\n     *  Informs of register name change.\r\n     *\r\n     *    @param [in] oldName     The old name.\r\n     *    @param [in] newName     The new name.\r\n     */\r\n    void registerNameChanged(QString const& oldName, QString const& newName);\r\n\r\n    //! Signals a change in the item's address data.\r\n    void addressingChanged();\r\n\r\n\r\n\r\npublic slots:\r\n\r\n    //! Handle the change in item's addressing data.\r\n    void onAddressingChanged();\r\n\r\n    //! Handle the change in child item's addressing data.\r\n    void onChildAddressingChanged();\r\n\r\nprotected slots:\r\n\r\n    /*!\r\n     *  Handle the change in graphics.\r\n     */\r\n    virtual void onGraphicsChanged();\r\n\r\n    //! Handle the change in child item's graphics.\r\n    void onChildGraphicsChanged(int index);\r\n   \r\nprivate:\r\n\t\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n\t//! The register being edited.\r\n\tQSharedPointer<Register> reg_;\r\n\r\n\t//! The visualizer of memory maps.\r\n\tMemoryMapsVisualizer* visualizer_ = nullptr;\r\n\r\n\t//! The graph item that visualizes the register and possible dimensions.\r\n\tRegisterGraphItem* registerItem_ = nullptr;\r\n\r\n    //! The expression parser to use.\r\n    QSharedPointer<ExpressionParser> expressionParser_;\r\n\r\n    //! The used register validator.\r\n    QSharedPointer<RegisterValidator> registerValidator_;\r\n\r\n    //! Interface for registers.\r\n    RegisterInterface* registerInterface_;\r\n\r\n    //! Register data containing the edited register.\r\n    QSharedPointer<QList<QSharedPointer<RegisterBase> > > containingRegisterData_;\r\n};\r\n\r\n#endif // COMPONENTEDITORREGISTERITEM_H\r\n"
  },
  {
    "path": "editors/ComponentEditor/treeStructure/componenteditorrootitem.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: componenteditorrootitem.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 9.5.2012\r\n//\r\n// Description:\r\n// The root item in the component editor's navigation tree.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"componenteditorrootitem.h\"\r\n\r\n#include \"componenteditorbusinterfacesitem.h\"\r\n#include \"componenteditortreemodel.h\"\r\n\r\n#include <IPXACTmodels/Component/Component.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditorRootItem::ComponentEditorRootItem()\r\n//-----------------------------------------------------------------------------\r\nComponentEditorRootItem::ComponentEditorRootItem(LibraryInterface* libHandler,\r\n\t\t\t\t\t\t\t\t\t\t\t\t QSharedPointer<Component> component,\r\n\t\t\t\t\t\t\t\t\t\t\t\t ComponentEditorTreeModel* parent):\r\nComponentEditorItem(libHandler, component, parent)\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditorRootItem::~ComponentEditorRootItem()\r\n//-----------------------------------------------------------------------------\r\nComponentEditorRootItem::~ComponentEditorRootItem()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditorRootItem::text()\r\n//-----------------------------------------------------------------------------\r\nQString ComponentEditorRootItem::text() const\r\n{\r\n\treturn tr(\"root\");\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditorRootItem::isValid()\r\n//-----------------------------------------------------------------------------\r\nbool ComponentEditorRootItem::isValid() const\r\n{\r\n\treturn true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditorRootItem::editor()\r\n//-----------------------------------------------------------------------------\r\nItemEditor* ComponentEditorRootItem::editor()\r\n{\r\n\treturn nullptr;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditorRootItem::editor()\r\n//-----------------------------------------------------------------------------\r\nconst ItemEditor* ComponentEditorRootItem::editor() const\r\n{\r\n\treturn nullptr;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditorRootItem::getTooltip()\r\n//-----------------------------------------------------------------------------\r\nQString ComponentEditorRootItem::getTooltip() const\r\n{\r\n\treturn tr(\"The root item of the navigation tree\");\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditorRootItem::addChildItem()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentEditorRootItem::addChildItem(QSharedPointer<ComponentEditorItem> childItem)\r\n{\r\n    childItems_.append(childItem);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditorRootItem::getBusInterfaceItem()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<ComponentEditorItem> ComponentEditorRootItem::getBusInterfaceItem(QString const& interfaceName) const\r\n{\r\n\t// check all children\r\n\tfor (auto const& item : childItems_)\r\n    {\r\n\t\t// if the child was for bus interfaces summary item\r\n\t\tif (auto busIfsItem = item.dynamicCast<ComponentEditorBusInterfacesItem>())\r\n        {\r\n\t\t\treturn busIfsItem->getBusInterfaceItem(interfaceName);\r\n\t\t}\r\n\t}\r\n\r\n\t// if there was no item for bus interfaces summary\r\n\treturn QSharedPointer<ComponentEditorItem>();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditorRootItem::onInterfaceAdded()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentEditorRootItem::onInterfaceAdded()\r\n{\r\n    for (auto const& item : childItems_)\r\n    {\r\n\r\n        // if the child was for bus interfaces summary item.\r\n        if (auto busIfsItem = item.dynamicCast<ComponentEditorBusInterfacesItem>())\r\n        {            \r\n            auto childIndex = busIfsItem->children().count();\r\n            model_->addItem(busIfsItem.data(), childIndex);\r\n            busIfsItem->refreshEditor();\r\n            return;\r\n        }\r\n    }\r\n}\r\n"
  },
  {
    "path": "editors/ComponentEditor/treeStructure/componenteditorrootitem.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: componenteditorrootitem.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 9.5.2012\r\n//\r\n// Description:\r\n// The root item in the component editor's navigation tree.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef COMPONENTEDITORROOTITEM_H\r\n#define COMPONENTEDITORROOTITEM_H\r\n\r\n#include \"componenteditoritem.h\"\r\n\r\n#include <QSharedPointer>\r\n#include <QString>\r\n#include <QWidget>\r\n\r\nclass Component;\r\nclass ItemEditor;\r\nclass ComponentEditorTreeModel;\r\nclass LibraryInterface;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! The root item in the component editor's navigation tree.\r\n//-----------------------------------------------------------------------------\r\nclass ComponentEditorRootItem : public ComponentEditorItem\r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\r\n\t/*! \\brief The constructor\r\n\t *\r\n\t * \\param libHandler Pointer to the instance that manages the library.\r\n\t * \\param component Pointer to the component being edited.\r\n\t * \\param parent Pointer to the owner model of this root item.\r\n\t *\r\n\t*/\r\n\tComponentEditorRootItem(LibraryInterface* libHandler,\r\n\t\tQSharedPointer<Component> component,\r\n\t\tComponentEditorTreeModel* parent);\r\n\t\r\n\t//! \\brief The destructor\r\n\tvirtual ~ComponentEditorRootItem();\r\n\r\n\t/*! \\brief Get the tool tip for the item.\r\n\t * \r\n\t * \\return The text for the tool tip to print to user.\r\n\t*/\r\n\tvirtual QString getTooltip() const;\r\n\r\n\t/*! \\brief Get the text to be displayed to user in the tree for this item.\r\n\t *\r\n\t * \\return QString Contains the text to display.\r\n\t*/\r\n\tvirtual QString text() const;\r\n\r\n\t/*! \\brief Check the validity of this item and sub items.\r\n\t *\r\n\t * \\return bool True if item is in valid state.\r\n\t*/\r\n\tvirtual bool isValid() const;\r\n\r\n\t/*! \\brief Get pointer to the editor of this item.\r\n\t *\r\n\t * \\return Pointer to the editor to use for this item.\r\n\t*/\r\n\tvirtual ItemEditor* editor();\r\n\r\n\t/*! \\brief Get pointer to the editor of this item.\r\n\t *\r\n\t * \\return Pointer to the editor to use for this item.\r\n\t*/\r\n\tvirtual const ItemEditor* editor() const;\r\n\r\n    /*!\r\n     *  Adds a child item for the root item.\r\n     *\r\n     *    @param [in] childItem   The child item to add.\r\n     */\r\n    void addChildItem(QSharedPointer<ComponentEditorItem> childItem);\r\n\r\n\t/*! \\brief Get the tree item that holds the editor for given bus interface.\r\n\t *\r\n\t * \\param interfaceName The name of the bus interface to get the item for.\r\n\t *\r\n\t * \\return Pointer to the tree item.\r\n\t*/\r\n\tQSharedPointer<ComponentEditorItem> getBusInterfaceItem(const QString& interfaceName) const;\r\n\r\npublic slots:\r\n\r\n    /*!\r\n     *  Called when new interface is created from a set of ports.\r\n     */\r\n    virtual void onInterfaceAdded();\r\n\r\nprivate:\r\n\t//! \\brief No copying\r\n\tComponentEditorRootItem(const ComponentEditorRootItem& other);\r\n\r\n\t//! \\brief No assignment\r\n\tComponentEditorRootItem& operator=(const ComponentEditorRootItem& other);\r\n\r\n};\r\n\r\n#endif // COMPONENTEDITORROOTITEM_H\r\n"
  },
  {
    "path": "editors/ComponentEditor/treeStructure/componenteditorswpropertiesitem.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: componenteditorswpropertiesitem.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 24.5.2012\r\n//\r\n// Description:\r\n// The Software Properties-item in the component editor's navigation tree.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"componenteditorswpropertiesitem.h\"\r\n\r\n#include <editors/ComponentEditor/software/SWPropertiesEditor.h>\r\n\r\n#include <IPXACTmodels/Component/Component.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditorSWPropertiesItem::ComponentEditorSWPropertiesItem()\r\n//-----------------------------------------------------------------------------\r\nComponentEditorSWPropertiesItem::ComponentEditorSWPropertiesItem(ComponentEditorTreeModel* model,\r\n    LibraryInterface* libHandler,\r\n    QSharedPointer<Component> component,\r\n    ComponentEditorItem* parent):\r\nComponentEditorItem(model, libHandler, component, parent)\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditorSWPropertiesItem::~ComponentEditorSWPropertiesItem()\r\n//-----------------------------------------------------------------------------\r\nComponentEditorSWPropertiesItem::~ComponentEditorSWPropertiesItem()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditorSWPropertiesItem::getFont()\r\n//-----------------------------------------------------------------------------\r\nQFont ComponentEditorSWPropertiesItem::getFont() const\r\n{\r\n    QFont font(ComponentEditorItem::getFont());\r\n    font.setBold(!component_->getSWProperties().isEmpty());\r\n    return font;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditorSWPropertiesItem::getTooltip()\r\n//-----------------------------------------------------------------------------\r\nQString ComponentEditorSWPropertiesItem::getTooltip() const\r\n{\r\n\treturn tr(\"Contains the software properties of the component\");\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditorSWPropertiesItem::text()\r\n//-----------------------------------------------------------------------------\r\nQString ComponentEditorSWPropertiesItem::text() const\r\n{\r\n\treturn tr(\"Software properties\");\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditorSWPropertiesItem::isValid()\r\n//-----------------------------------------------------------------------------\r\nbool ComponentEditorSWPropertiesItem::isValid() const\r\n{\r\n\tfor (QSharedPointer<ComProperty> property: component_->getSWProperties())\r\n    {\r\n\t\tif (!property->validate())\r\n        {\r\n\t\t\treturn false;\r\n\t\t}\r\n\t}\r\n\treturn true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditorSWPropertiesItem::editor()\r\n//-----------------------------------------------------------------------------\r\nItemEditor* ComponentEditorSWPropertiesItem::editor()\r\n{\r\n\tif (!editor_)\r\n    {\r\n\t\teditor_ = new SWPropertiesEditor(component_, libHandler_);\r\n\t\teditor_->setProtection(locked_);\r\n\t\tconnect(editor_, SIGNAL(contentChanged()), this, SLOT(onEditorChanged()), Qt::UniqueConnection);\r\n\t\tconnect(editor_, SIGNAL(helpUrlRequested(QString const&)), this, SIGNAL(helpUrlRequested(QString const&)));\r\n\t}\r\n\treturn editor_;\r\n}\r\n"
  },
  {
    "path": "editors/ComponentEditor/treeStructure/componenteditorswpropertiesitem.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: componenteditorswpropertiesitem.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 24.5.2012\r\n//\r\n// Description:\r\n// The Software Properties-item in the component editor's navigation tree.\r\n//-----------------------------------------------------------------------------\r\n\r\n\r\n#ifndef COMPONENTEDITORSWPROPERTIESITEM_H\r\n#define COMPONENTEDITORSWPROPERTIESITEM_H\r\n\r\n#include \"componenteditoritem.h\"\r\n\r\n#include <IPXACTmodels/kactusExtensions/ComProperty.h>\r\n\r\n#include <QSharedPointer>\r\n\r\n//-----------------------------------------------------------------------------\r\n//! The Software Properties-item in the component editor's navigation tree.\r\n//-----------------------------------------------------------------------------\r\nclass ComponentEditorSWPropertiesItem : public ComponentEditorItem\r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\r\n\t/*! The constructor\r\n\t *\r\n\t *    @param [in] model       The model that owns the items.\r\n\t *    @param [in] libHandler  The instance that manages the library.\r\n\t *    @param [in] component   The component being edited.\r\n\t *    @param [in] parent      The parent item.\r\n\t *\r\n\t*/\r\n\tComponentEditorSWPropertiesItem(ComponentEditorTreeModel* model, LibraryInterface* libHandler,\r\n\t\tQSharedPointer<Component> component, ComponentEditorItem* parent);\r\n\r\n\t//! The destructor\r\n\tvirtual ~ComponentEditorSWPropertiesItem();\r\n\r\n\t/*! Get the font to be used for text of this item.\r\n\t*\r\n\t* The font is bold, if other SW properties exist, otherwise not bold.\r\n\t*\r\n\t*    @return QFont instance that defines the font to be used.\r\n\t*/\r\n\tvirtual QFont getFont() const;\r\n\r\n\t/*! Get the tool tip for the item.\r\n\t * \r\n\t *    @return The text for the tool tip to print to user.\r\n\t*/\r\n\tvirtual QString getTooltip() const;\r\n\r\n\t/*! Get the text to be displayed to user in the tree for this item.\r\n\t *\r\n\t *    @return QString Contains the text to display.\r\n\t*/\r\n\tvirtual QString text() const;\r\n\r\n\t/*! Check the validity of this item and sub items.\r\n\t *\r\n\t *    @return bool True if item is in valid state.\r\n\t*/\r\n\tvirtual bool isValid() const;\r\n\r\n\t/*! Get The editor of this item.\r\n\t *\r\n\t *    @return The editor to use for this item.\r\n\t*/\r\n\tvirtual ItemEditor* editor();\r\n\r\nprivate:\r\n\t//! No copying\r\n\tComponentEditorSWPropertiesItem(const ComponentEditorSWPropertiesItem& other);\r\n\r\n\t//! No assignment\r\n\tComponentEditorSWPropertiesItem& operator=(const ComponentEditorSWPropertiesItem& other);\r\n\r\n};\r\n\r\n#endif // COMPONENTEDITORSWPROPERTIESITEM_H\r\n"
  },
  {
    "path": "editors/ComponentEditor/treeStructure/componenteditorswviewitem.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: componenteditorswviewitem.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Antti Kamppi\r\n// Date: 24.05.2012\r\n//\r\n// Description:\r\n// The item for a single software view in the component editor's navigation tree.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"componenteditorswviewitem.h\"\r\n\r\n#include <editors/ComponentEditor/software/swView/SWViewEditor.h>\r\n\r\n#include <library/LibraryInterface.h>\r\n\r\n#include <IPXACTmodels/Component/Component.h>\r\n#include <IPXACTmodels/kactusExtensions/SWView.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditorSWViewItem::ComponentEditorSWViewItem()\r\n//-----------------------------------------------------------------------------\r\nComponentEditorSWViewItem::ComponentEditorSWViewItem(\r\n    QSharedPointer<SWView> swView,\r\n    ComponentEditorTreeModel* model,\r\n    LibraryInterface* libHandler,\r\n    QSharedPointer<Component> component,\r\n    ComponentEditorItem* parent):\r\nComponentEditorItem(model, libHandler, component, parent),\r\n    swView_(swView),\r\n    editAction_(new QAction(tr(\"Edit\"), this))\r\n{\r\n    Q_ASSERT(swView_);\r\n    connect(editAction_, SIGNAL(triggered(bool)), this, SLOT(openItem()), Qt::UniqueConnection);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditorSWViewItem::~ComponentEditorSWViewItem()\r\n//-----------------------------------------------------------------------------\r\nComponentEditorSWViewItem::~ComponentEditorSWViewItem()\r\n{\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditorSWViewItem::getTooltip()\r\n//-----------------------------------------------------------------------------\r\nQString ComponentEditorSWViewItem::getTooltip() const\r\n{\r\n\treturn tr(\"Contains the details of a software view\");\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditorSWViewItem::text()\r\n//-----------------------------------------------------------------------------\r\nQString ComponentEditorSWViewItem::text() const\r\n{\r\n\treturn swView_->name();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditorSWViewItem::isValid()\r\n//-----------------------------------------------------------------------------\r\nbool ComponentEditorSWViewItem::isValid() const\r\n{\r\n\tQStringList fileSetNames = component_->getFileSetNames();\r\n\tQStringList cpuNames = component_->getCpuNames();\r\n\r\n\t// if sw view is not valid\r\n\tif (!swView_->isValid(fileSetNames, cpuNames))\r\n    {\r\n\t\treturn false;\r\n\t}\r\n\r\n\t// check that the reference is found if its been defined\r\n\tVLNV swHierRef = swView_->getHierarchyRef();\r\n\tif ( !swHierRef.isEmpty() && ( !swHierRef.isValid() || !libHandler_->contains(swHierRef) ) )\r\n    {\r\n\t\treturn false;\r\n\t}\r\n\r\n\t// sw view was valid and reference was found\r\n\treturn true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditorSWViewItem::editor()\r\n//-----------------------------------------------------------------------------\r\nItemEditor* ComponentEditorSWViewItem::editor()\r\n{\r\n\tif (!editor_)\r\n    {\r\n\t\teditor_ = new SWViewEditor(component_, swView_, libHandler_, NULL);\r\n\t\teditor_->setProtection(locked_);\r\n\r\n\t\tconnect(editor_, SIGNAL(contentChanged()), this, SLOT(onEditorChanged()), Qt::UniqueConnection);\r\n\t\tconnect(editor_, SIGNAL(helpUrlRequested(QString const&)), this, SIGNAL(helpUrlRequested(QString const&)));\r\n\t}\r\n\r\n\treturn editor_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditorSWViewItem::canBeOpened()\r\n//-----------------------------------------------------------------------------\r\nbool ComponentEditorSWViewItem::canBeOpened() const\r\n{\r\n\t// if the library does not contain the referenced object\r\n\tif (!libHandler_->contains(swView_->getHierarchyRef()))\r\n    {\r\n\t\treturn false;\r\n\t}\r\n\r\n\t// check that the reference has not been changed\r\n\t// if it has then there is no way to open the design because the changes have not\r\n\t// been made to the library\r\n\tQSharedPointer<Document const> libComp = libHandler_->getModelReadOnly(component_->getVlnv());\r\n\tQSharedPointer<Component const> comp = libComp.staticCast<Component const>();\r\n\tVLNV originalRef = comp->getHierRef(swView_->name());\r\n\treturn originalRef == swView_->getHierarchyRef();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditorSWViewItem::actions()\r\n//-----------------------------------------------------------------------------\r\nQList<QAction*> ComponentEditorSWViewItem::actions() const\r\n{\r\n    QList<QAction*> actionList;\r\n    actionList.append(editAction_);\r\n\r\n    return actionList;   \r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditorSWViewItem::openItem()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentEditorSWViewItem::openItem()\r\n{\r\n\t// if item can't be opened\r\n\tif (!canBeOpened())\r\n    {\r\n\t\temit errorMessage(tr(\"The changes to component must be saved before view can be opened.\"));\r\n\t\treturn;\r\n\t}\r\n\r\n\tQString viewName = swView_->name();\r\n\tVLNV compVLNV = component_->getVlnv();\r\n\temit openSWDesign(compVLNV, viewName);\r\n}\r\n"
  },
  {
    "path": "editors/ComponentEditor/treeStructure/componenteditorswviewitem.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: componenteditorswviewitem.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Antti Kamppi\r\n// Date: 24.05.2012\r\n//\r\n// Description:\r\n// The item for a single software view in the component editor's navigation tree.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef COMPONENTEDITORSWVIEWITEM_H\r\n#define COMPONENTEDITORSWVIEWITEM_H\r\n\r\n#include \"componenteditoritem.h\"\r\n\r\nclass SWView;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! The item for a single software view in the component editor's navigation tree.\r\n//-----------------------------------------------------------------------------\r\nclass ComponentEditorSWViewItem : public ComponentEditorItem {\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\r\n\t/*! The constructor\r\n\t * \r\n\t *    @param [in] swView      The software view to edit.\r\n\t *    @param [in] model       The model that owns the items.\r\n\t *    @param [in] libHandler  The instance that manages the library.\r\n\t *    @param [in] component   The component being edited.\r\n\t *    @param [in] parent      The parent item.\r\n\t */\r\n\tComponentEditorSWViewItem(QSharedPointer<SWView> swView, ComponentEditorTreeModel* model,\r\n\t\tLibraryInterface* libHandler, QSharedPointer<Component> component,\r\n\t\tComponentEditorItem* parent);\r\n\r\n\t//! The destructor\r\n\tvirtual ~ComponentEditorSWViewItem();\r\n\r\n\t/*! Get the tool tip for the item.\r\n\t * \r\n\t *    @return The text for the tool tip to print to user.\r\n\t*/\r\n\tvirtual QString getTooltip() const;\r\n\r\n\t/*! Get the text to be displayed to user in the tree for this item.\r\n\t *\r\n\t *    @return QString Contains the text to display.\r\n\t*/\r\n\tvirtual QString text() const;\r\n\r\n\t/*! Check the validity of this item and sub items.\r\n\t *\r\n\t *    @return bool True if item is in valid state.\r\n\t*/\r\n\tvirtual bool isValid() const;\r\n\r\n\t/*! Get pointer to the editor of this item.\r\n\t *\r\n\t *    @return The editor to use for this item.\r\n\t*/\r\n\tvirtual ItemEditor* editor();\r\n\r\n\t/*! Tells if the item can be opened or not.\r\n\t * \r\n\t * If the hasn't changed then it can be opened.\r\n\t*/\r\n\tvirtual bool canBeOpened() const;\r\n    \r\n    /*!\r\n     *  Returns the possible actions for opening the item.\r\n     *\r\n     *    @return The actions to open the item.\r\n     */\r\n    virtual QList<QAction*> actions() const;\r\n\r\npublic slots:\r\n\t\r\n\t/*! Open the view in a design editor.\r\n\t * \r\n\t*/\r\n\tvirtual void openItem();\r\n\r\nprivate:\r\n\t//! No copying\r\n\tComponentEditorSWViewItem(const ComponentEditorSWViewItem& other);\r\n\r\n\t//! No assignment\r\n\tComponentEditorSWViewItem& operator=(const ComponentEditorSWViewItem& other);\r\n   \r\n\t//! The view being edited.\r\n\tQSharedPointer<SWView> swView_;\r\n\r\n    //! Action to open the SW view for editing.\r\n    QAction* editAction_;\r\n};\r\n\r\n#endif // COMPONENTEDITORSWVIEWITEM_H\r\n"
  },
  {
    "path": "editors/ComponentEditor/treeStructure/componenteditorswviewsitem.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: componenteditorswviewsitem.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Antti Kamppi\r\n// Date: 24.05.2012\r\n//\r\n// Description:\r\n// The Software Views-item in the component editor's navigation tree.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"componenteditorswviewsitem.h\"\r\n\r\n#include \"componenteditorswviewitem.h\"\r\n\r\n#include <editors/ComponentEditor/software/swView/swviewseditor.h>\r\n\r\n#include <IPXACTmodels/Component/Component.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditorSWViewsItem::ComponentEditorSWViewsItem()\r\n//-----------------------------------------------------------------------------\r\nComponentEditorSWViewsItem::ComponentEditorSWViewsItem(\r\n\tComponentEditorTreeModel* model, \r\n\tLibraryInterface* libHandler,\r\n\tQSharedPointer<Component> component,\r\n\tComponentEditorItem* parent):\r\nComponentEditorItem(model, libHandler, component, parent)\r\n{\r\n\tforeach (QSharedPointer<SWView> swView, component->getSWViews())\r\n    {\r\n\t\tQSharedPointer<ComponentEditorSWViewItem> swViewItem(\r\n\t\t\tnew ComponentEditorSWViewItem(swView, model, libHandler, component, this)); \r\n\t\tchildItems_.append(swViewItem);\r\n\t}\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditorSWViewsItem::~ComponentEditorSWViewsItem()\r\n//-----------------------------------------------------------------------------\r\nComponentEditorSWViewsItem::~ComponentEditorSWViewsItem()\r\n{\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditorSWViewsItem::getFont()\r\n//-----------------------------------------------------------------------------\r\nQFont ComponentEditorSWViewsItem::getFont() const\r\n{\r\n    QFont font(ComponentEditorItem::getFont());\r\n    font.setBold(component_->hasSWViews());    \r\n    return font;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditorSWViewsItem::getTooltip()\r\n//-----------------------------------------------------------------------------\r\nQString ComponentEditorSWViewsItem::getTooltip() const\r\n{\r\n\treturn tr(\"Contains the software views of the component\");\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditorSWViewsItem::text()\r\n//-----------------------------------------------------------------------------\r\nQString ComponentEditorSWViewsItem::text() const\r\n{\r\n\treturn tr(\"Software views\");\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditorSWViewsItem::editor()\r\n//-----------------------------------------------------------------------------\r\nItemEditor* ComponentEditorSWViewsItem::editor()\r\n{\r\n\tif (!editor_)\r\n    {\r\n\t\teditor_ = new SWViewsEditor(component_, libHandler_);\r\n\t\teditor_->setProtection(locked_);\r\n\r\n\t\tconnect(editor_, SIGNAL(contentChanged()), this, SLOT(onEditorChanged()), Qt::UniqueConnection);\r\n\t\tconnect(editor_, SIGNAL(childAdded(int)), this, SLOT(onAddChild(int)), Qt::UniqueConnection);\r\n\t\tconnect(editor_, SIGNAL(childRemoved(int)),\tthis, SLOT(onRemoveChild(int)), Qt::UniqueConnection);\r\n\t\tconnect(editor_, SIGNAL(helpUrlRequested(QString const&)), this, SIGNAL(helpUrlRequested(QString const&)));\r\n\t}\r\n\r\n\treturn editor_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditorSWViewsItem::createChild()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentEditorSWViewsItem::createChild(int index)\r\n{\r\n\tQSharedPointer<ComponentEditorSWViewItem> swViewItem(\r\n\t\tnew ComponentEditorSWViewItem(component_->getSWViews().at(index), model_, libHandler_, component_, this));\r\n\tswViewItem->setLocked(locked_);\r\n\tchildItems_.insert(index, swViewItem);\r\n}\r\n"
  },
  {
    "path": "editors/ComponentEditor/treeStructure/componenteditorswviewsitem.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: componenteditorswviewsitem.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Antti Kamppi\r\n// Date: 24.05.2012\r\n//\r\n// Description:\r\n// The Software Views-item in the component editor's navigation tree.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef COMPONENTEDITORSWVIEWSITEM_H\r\n#define COMPONENTEDITORSWVIEWSITEM_H\r\n\r\n#include \"componenteditoritem.h\"\r\n\r\n//-----------------------------------------------------------------------------\r\n//! The Software Views-item in the component editor's navigation tree.\r\n//-----------------------------------------------------------------------------\r\nclass ComponentEditorSWViewsItem : public ComponentEditorItem\r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\r\n\t/*! The constructor\r\n\t *\r\n\t *    @param [in] model       The model that owns the items.\r\n\t *    @param [in] libHandler  The instance that manages the library.\r\n\t *    @param [in] component   The component being edited.\r\n\t *    @param [in] parent      The parent item.\r\n\t */\r\n\tComponentEditorSWViewsItem(ComponentEditorTreeModel* model,\tLibraryInterface* libHandler,\r\n\t\tQSharedPointer<Component> component, ComponentEditorItem* parent);\r\n\r\n\t//! The destructor\r\n\tvirtual ~ComponentEditorSWViewsItem();\r\n\r\n\t/*! Get the font to be used for text of this item.\r\n\t*\r\n\t* The font is bold, if sw views exist, otherwise not bold.\r\n\t*\r\n\t*    @return QFont instance that defines the font to be used.\r\n\t*/\r\n\tvirtual QFont getFont() const;\r\n\r\n\t/*! Get the tool tip for the item.\r\n\t * \r\n\t *    @return The text for the tool tip to print to user.\r\n\t*/\r\n\tvirtual QString getTooltip() const;\r\n\r\n\t/*! Get the text to be displayed to user in the tree for this item.\r\n\t *\r\n\t *    @return QString Contains the text to display.\r\n\t*/\r\n\tvirtual QString text() const;\r\n\r\n\t/*! Get pointer to the editor of this item.\r\n\t *\r\n\t *    @return The editor to use for this item.\r\n\t*/\r\n\tvirtual ItemEditor* editor();\r\n\r\n\t/*! Add a new child to the item.\r\n\t * \r\n\t *    @param [in] index The index to add the child into.\r\n\t *\r\n\t*/\r\n\tvirtual void createChild(int index);\r\n\r\nprivate:\r\n\t//! No copying\r\n\tComponentEditorSWViewsItem(const ComponentEditorSWViewsItem& other);\r\n\r\n\t//! No assignment\r\n\tComponentEditorSWViewsItem& operator=(const ComponentEditorSWViewsItem& other);\r\n\r\n};\r\n\r\n#endif // COMPONENTEDITORSWVIEWSITEM_H\r\n"
  },
  {
    "path": "editors/ComponentEditor/treeStructure/componenteditortreemodel.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: componenteditortreemodel.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 07.05.2012\r\n//\r\n// Description:\r\n// The tree model that manages the component editor's navigation tree.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"componenteditortreemodel.h\"\r\n\r\n#include <IPXACTmodels/Component/Component.h>\r\n\r\n#include <common/KactusColors.h>\r\n\r\n#include <QIcon>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: componenteditortreemodel::ComponentEditorTreeModel()\r\n//-----------------------------------------------------------------------------\r\nComponentEditorTreeModel::ComponentEditorTreeModel(QObject* parent) :\r\nQAbstractItemModel(parent)\r\n{\r\n\tsetObjectName(tr(\"ComponentEditorTreeModel\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: componenteditortreemodel::~ComponentEditorTreeModel()\r\n//-----------------------------------------------------------------------------\r\nComponentEditorTreeModel::~ComponentEditorTreeModel()\r\n{\r\n\trootItem_.clear();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: componenteditortreemodel::setRootItem()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentEditorTreeModel::setRootItem(QSharedPointer<ComponentEditorRootItem> root)\r\n{\r\n\tbeginResetModel();\r\n    rootItem_ = root;\r\n\tendResetModel();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: componenteditortreemodel::rowCount()\r\n//-----------------------------------------------------------------------------\r\nint ComponentEditorTreeModel::rowCount( const QModelIndex& parent /*= QModelIndex()*/ ) const\r\n{\r\n\t// only one column exists\r\n\tif (parent.column() > 0)\r\n    {\r\n\t\treturn 0;\r\n\t}\r\n\r\n\tComponentEditorItem* parentItem = 0;\r\n\r\n\t// if the given item is invalid, it is interpreted as root item\r\n\tif (!parent.isValid())\r\n    {\r\n\t\tparentItem = rootItem_.data();\r\n\t}\r\n\telse\r\n    {\r\n\t\tparentItem = static_cast<ComponentEditorItem*>(parent.internalPointer());\r\n\t}\r\n\r\n\t// return how many children the parent has\r\n\treturn parentItem->rowCount();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: componenteditortreemodel::hasChildren()\r\n//-----------------------------------------------------------------------------\r\nbool ComponentEditorTreeModel::hasChildren( const QModelIndex& parent /*= QModelIndex()*/ ) const\r\n{\r\n\tComponentEditorItem* parentItem = 0;\r\n\r\n\t// if the given item is invalid, it is interpreted as root item\r\n\tif (!parent.isValid())\r\n    {\r\n\t\tparentItem = rootItem_.data();\r\n\t}\r\n\telse\r\n    {\r\n\t\tparentItem = static_cast<ComponentEditorItem*>(parent.internalPointer());\r\n\t}\r\n\r\n\t// return how many children the parent has\r\n\treturn parentItem->hasChildren();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: componenteditortreemodel::columnCount()\r\n//-----------------------------------------------------------------------------\r\nint ComponentEditorTreeModel::columnCount( const QModelIndex&) const\r\n{\r\n\treturn 1;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: componenteditortreemodel::data()\r\n//-----------------------------------------------------------------------------\r\nQVariant ComponentEditorTreeModel::data( const QModelIndex& index, int role /*= Qt::DisplayRole*/ ) const\r\n{\r\n\tif (!index.isValid())\r\n    {\r\n\t\treturn QVariant();\r\n\t}\r\n\r\n\tComponentEditorItem* item = static_cast<ComponentEditorItem*>(index.internalPointer());\r\n\tQ_ASSERT(item);\r\n\r\n\tif (role == Qt::DisplayRole)\r\n    {\r\n\t\tQString text = item->text();\r\n\r\n\t\t// if the object has no name\r\n\t\tif (text.isEmpty())\r\n        {\r\n\t\t\ttext = tr(\"unnamed\");\r\n\t\t}\r\n\r\n\t\treturn text;\r\n\t}\r\n\telse if (role == Qt::FontRole)\r\n    {\r\n\t\treturn item->getFont();\r\n\t}\r\n\telse if (role == Qt::ForegroundRole)\r\n    {\r\n        if (item->parent() != rootItem_ && !item->isValid())\r\n        {\r\n            return KactusColors::ERROR;\r\n        }\r\n        else\r\n        {\r\n            return KactusColors::REGULAR_TEXT;\r\n        }\r\n\t}\r\n\telse if (role == Qt::ToolTipRole)\r\n    {\r\n\t\treturn item->getTooltip();\r\n\t}\r\n    else if (role == Qt::SizeHintRole)\r\n    {\r\n\t\tQSize size(80, 18);\r\n\t\tif (item->parent() == rootItem_)\r\n\t\t{\r\n\t\t\tsize.setHeight(26);\r\n\t\t}\r\n\t\treturn size;\r\n    }\r\n\telse if (role == Qt::DecorationRole)\r\n\t{\r\n\t\tif (item->parent() == rootItem_ && item->isValid() == false)\r\n\t\t{\r\n\t\t\treturn QIcon(\":icons/common/graphics/exclamation--frame.png\");\r\n\t\t}\r\n\t\treturn QVariant();\r\n\t}\r\n\telse if (role == Qt::UserRole)\r\n\t{\r\n\t\treturn item->isModified();\r\n\t}\r\n\t// not supported role\r\n\telse\r\n    {\r\n\t\treturn QVariant();\r\n\t}\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: componenteditortreemodel::flags()\r\n//-----------------------------------------------------------------------------\r\nQt::ItemFlags ComponentEditorTreeModel::flags( const QModelIndex& index ) const\r\n{\r\n\tif (!index.isValid())\r\n    {\r\n\t\treturn Qt::NoItemFlags;\r\n\t}\r\n\r\n\treturn Qt::ItemIsEnabled | Qt::ItemIsSelectable;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: componenteditortreemodel::onContentChanged()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentEditorTreeModel::onContentChanged(ComponentEditorItem* item )\r\n{\r\n\tQModelIndex index = ComponentEditorTreeModel::index(item);\r\n\temit dataChanged(index, index);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: componenteditortreemodel::index()\r\n//-----------------------------------------------------------------------------\r\nQModelIndex ComponentEditorTreeModel::index(int row, int column, const QModelIndex& parent /*= QModelIndex()*/ )\r\n    const\r\n{\r\n\tif (!hasIndex(row, column, parent))\r\n    {\r\n\t\treturn QModelIndex();\r\n\t}\r\n\r\n\tComponentEditorItem* parentItem = 0;\r\n\r\n\t// if parent is invalid the asked index is for the root item\r\n\tif (!parent.isValid())\r\n    {\r\n\t\tparentItem = rootItem_.data();\r\n\t}\r\n\telse\r\n    {\r\n\t\tparentItem = static_cast<ComponentEditorItem*>(parent.internalPointer());\r\n\t}\r\n\r\n\tQ_ASSERT(parentItem);\r\n\r\n\t// get pointer to specified child of the parent\r\n\tQSharedPointer<ComponentEditorItem> child = parentItem->child(row);\r\n\r\n\t// if the item was found\r\n\tif (child)\r\n    {\r\n\t\treturn createIndex(row, column, child.data());\r\n\t}\r\n\t// if child was not found\r\n\telse\r\n    {\r\n\t\treturn QModelIndex();\r\n\t}\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: componenteditortreemodel::index()\r\n//-----------------------------------------------------------------------------\r\nQModelIndex ComponentEditorTreeModel::index(ComponentEditorItem* item ) const\r\n{\r\n\tQ_ASSERT(item);\r\n\r\n\t// if the item is the root item then it's model index is invalid\r\n\tif (item == rootItem_.data())\r\n    {\r\n\t\treturn QModelIndex();\r\n\t}\r\n\telse\r\n    {\r\n\t\treturn createIndex(item->row(), 0, item);\r\n\t}\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: componenteditortreemodel::parent()\r\n//-----------------------------------------------------------------------------\r\nQModelIndex ComponentEditorTreeModel::parent( const QModelIndex& index ) const\r\n{\r\n\t// if the child parameter is invalid then there is no parent\r\n\tif (!index.isValid())\r\n    {\r\n\t\treturn QModelIndex();\r\n\t}\r\n\r\n\t// pointer to the child item\r\n\tComponentEditorItem* childItem = static_cast<ComponentEditorItem*>(index.internalPointer());\r\n\tComponentEditorItem* parent = childItem->parent();\r\n\r\n\t// if the parent does not exist then this item is root item\r\n\tif (!parent)\r\n    {\r\n\t\treturn QModelIndex();\r\n\t}\r\n\r\n\t// if row is invalid then the grandparent does not exist and parent is\r\n\t// a root item so we return an invalid QModelIndex\r\n\tint row = parent->row();\r\n\tif (row == -1)\r\n    {\r\n\t\treturn QModelIndex();\r\n\t}\r\n\r\n\t// create new index and return it\r\n\treturn createIndex(row, 0, parent);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: componenteditortreemodel::setLocked()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentEditorTreeModel::setLocked( bool locked )\r\n{\r\n\trootItem_->setLocked(locked);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: componenteditortreemodel::addItem()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentEditorTreeModel::addItem( ComponentEditorItem* parentItem, int childIndex )\r\n{\r\n\tQ_ASSERT(parentItem);\r\n\tQ_ASSERT(childIndex >= 0);\r\n\r\n\t// find the index of the parent item\r\n\tQModelIndex parentIndex = index(parentItem);\r\n\r\n\tbeginInsertRows(parentIndex, childIndex, childIndex);\r\n\tparentItem->createChild(childIndex);\r\n\tendInsertRows();\r\n\r\n\temit expandItem(parentIndex);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: componenteditortreemodel::removeItem()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentEditorTreeModel::removeItem( ComponentEditorItem* parentItem, int childIndex )\r\n{\r\n\tQ_ASSERT(parentItem);\r\n\tQ_ASSERT(childIndex >= 0);\r\n\r\n\t// find the index of the parent item\r\n\tQModelIndex parentIndex = index(parentItem);\r\n\r\n\tbeginRemoveRows(parentIndex, childIndex, childIndex);\r\n\tparentItem->removeChild(childIndex);\r\n\tendRemoveRows();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: componenteditortreemodel::moveItem()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentEditorTreeModel::moveItem( ComponentEditorItem* parentItem, int childSource, int childtarget )\r\n{\r\n\tQ_ASSERT(parentItem);\r\n\tQ_ASSERT(childSource >= 0);\r\n\tQ_ASSERT(childtarget >= 0);\r\n\r\n\t// if the location of the item does not change\r\n\tif (childSource == childtarget)\r\n    {\r\n\t\treturn;\r\n\t}\r\n\r\n\t// the index identifying the parent object\r\n\tQModelIndex parentIndex = index(parentItem);\r\n\r\n\t// target index is told to the parent item when moving\r\n\tint targetIndex = childtarget;\r\n\r\n\t// if item is moved down then the target must be incremented for abstract item's\r\n\t// way to inform view of row moves\r\n\tif (childtarget > childSource)\r\n    {\r\n\t\t++childtarget;\r\n\t}\r\n\r\n\t// make the moving of the item\r\n\tbeginMoveRows(parentIndex, childSource, childSource, parentIndex, childtarget);\r\n\tparentItem->moveChild(childSource, targetIndex);\r\n\tendMoveRows();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: componenteditortreemodel::onSelectBusInterface()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentEditorTreeModel::onSelectBusInterface( const QString& interfaceName )\r\n{\r\n\tconst QSharedPointer<ComponentEditorItem> busIfItem = rootItem_->getBusInterfaceItem(interfaceName);\r\n\tif (!busIfItem)\r\n    {\r\n\t\treturn;\r\n\t}\r\n\r\n\t// inform component editor to select the item\r\n\tQModelIndex busIfIndex = index(busIfItem.data());\r\n\temit selectItem(busIfIndex);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: componenteditortreemodel::onSelectItem()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentEditorTreeModel::onSelectItem( ComponentEditorItem* item )\r\n{\r\n\tQModelIndex itemIndex = index(item);\r\n\temit selectItem(itemIndex);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: componenteditortreemodel::getIndexOfItem()\r\n//-----------------------------------------------------------------------------\r\nQModelIndex ComponentEditorTreeModel::getIndexOfItem(QVector<QString> itemIdentifierChain) const\r\n{\r\n    QModelIndex itemIndex;\r\n\r\n    for (auto const& currentIdentifier : itemIdentifierChain)\r\n    {\r\n        itemIndex = findIndexByItemIdentifier(currentIdentifier, itemIndex);\r\n    }\r\n\r\n    return itemIndex;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: componenteditortreemodel::clearItemsModified()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentEditorTreeModel::clearItemsModified() const\r\n{\r\n\trootItem_->clearModified();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: componenteditortreemodel::findIndexByItemIdentifier()\r\n//-----------------------------------------------------------------------------\r\nQModelIndex ComponentEditorTreeModel::findIndexByItemIdentifier(QString const& identifier, QModelIndex parentIndex)\r\n    const\r\n{\r\n    int numberOfRows = rowCount(parentIndex);\r\n    int columnNumber = 0;\r\n\r\n    for (int rowIndex = 0; rowIndex < numberOfRows; ++rowIndex)\r\n    {\r\n        QModelIndex indexCandidate = index(rowIndex, columnNumber, parentIndex);\r\n        if (indexCandidate.isValid())\r\n        {\r\n            QString indexedItemName = indexCandidate.data(Qt::DisplayRole).toString();\r\n            if (indexedItemName.compare(identifier, Qt::CaseInsensitive) == 0)\r\n            {\r\n                return indexCandidate;\r\n            }\r\n        }\r\n    }\r\n\r\n    return parentIndex;\r\n}\r\n"
  },
  {
    "path": "editors/ComponentEditor/treeStructure/componenteditortreemodel.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: componenteditortreemodel.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 07.05.2012\r\n//\r\n// Description:\r\n// The tree model that manages the component editor's navigation tree.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef COMPONENTEDITORTREEMODEL_H\r\n#define COMPONENTEDITORTREEMODEL_H\r\n\r\n#include \"componenteditorrootitem.h\"\r\n\r\n#include <QAbstractItemModel>\r\n#include <QWidget>\r\n#include <QSharedPointer>\r\n\r\nclass LibraryInterface;\r\nclass PluginManager;\r\nclass Component;\r\nclass VLNV;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! The tree model that manages the component editor's navigation tree.\r\n//-----------------------------------------------------------------------------\r\nclass ComponentEditorTreeModel : public QAbstractItemModel\r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\r\n\t/*!\r\n\t *  The constructor.\r\n\t *\r\n\t *    @param [in] libHandler  Pointer to the instance that manages the library.\r\n\t *    @param [in] parent      Pointer to the instance that owns this model.\r\n\t */\r\n\tComponentEditorTreeModel(QObject* parent);\r\n\r\n\t//! The destructor.\r\n\tvirtual ~ComponentEditorTreeModel();\r\n\r\n\t/*!\r\n\t *  Set the root item.\r\n\t *\r\n\t *    @param [in] root    Pointer to the root item.\r\n\t */\r\n\tvoid setRootItem(QSharedPointer<ComponentEditorRootItem> root);\r\n\r\n\t/*!\r\n\t *  Get the number of rows an item contains.\r\n\t *\r\n\t *    @param [in] parent  Identifies the parent that's row count is requested.\r\n\t *\r\n\t *    @return Number of rows the item has.\r\n\t */\r\n\tvirtual int rowCount(const QModelIndex& parent = QModelIndex()) const;\r\n\r\n\t/*!\r\n\t *  Does the specified item have any child items.\r\n\t *\r\n\t *    @param [in] parent  Model index of the item.\r\n\t *\r\n\t *    @return True if the item has any child items.\r\n\t */\r\n\tvirtual bool hasChildren(const QModelIndex& parent = QModelIndex()) const;\r\n\r\n\t/*!\r\n\t *  Get the number of columns the item has to be displayed.\r\n\t *\r\n\t *    @param [in] parent  Identifies the parent that's column count is requested.\r\n\t *\r\n\t *    @return The number of columns to be displayed.\r\n\t */\r\n\tvirtual int columnCount(const QModelIndex& parent = QModelIndex()) const;\r\n\r\n\t/*!\r\n\t *  Get the data for specified item.\r\n\t *\r\n\t *    @param [in] index   Specifies the item that's data is requested.\r\n\t *    @param [in] role    The role that defines what kind of data is requested.\r\n\t *\r\n\t *    @return QVariant Contains the data for the item.\r\n\t */\r\n\tvirtual QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const;\r\n\r\n\t/*!\r\n\t *  Get the item flags that defines the possible operations for the item.\r\n\t *\r\n\t *    @param [in] index   Model index that identifies the item.\r\n\t *\r\n\t *    @return Qt::ItemFlags specify the possible operations for the item.\r\n\t */\r\n\tvirtual Qt::ItemFlags flags(const QModelIndex& index) const;\r\n\r\n\t/*!\r\n\t *  Get index that identifies the given item.\r\n\t *\r\n\t *    @param [in] row     The row of the item.\r\n\t *    @param [in] column  The column of the item.\r\n\t *    @param [in] parent  The parent index of the item.\r\n\t *\r\n\t *    @return QModelIndex The model index that identifies the item.\r\n\t */\r\n\tvirtual QModelIndex index(int row, int column, const QModelIndex& parent = QModelIndex()) const;\r\n\r\n\t/*!\r\n\t *  Get the index that identifies the given item.\r\n\t *\r\n\t *    @param [in] item    Pointer to the item that's index is wanted.\r\n\t *\r\n\t *    @return QModelIndex The model index that identifies the item.\r\n\t */\r\n\tvirtual QModelIndex index(ComponentEditorItem* item) const;\r\n\r\n\t/*!\r\n\t *  Get the index of the parent of given index.\r\n\t *\r\n\t *    @param [in] index   The index that identifies the item that's parent is wanted.\r\n\t *\r\n\t *    @return QModelIndex The model index that identifies the parent.\r\n\t */\r\n\tvirtual QModelIndex parent(const QModelIndex& index) const;\r\n\r\n\t/*!\r\n\t *  Get the model index of the selected item.\r\n\t *\r\n\t *    @param [in] itemIdentifierChain     List of strings identifying the selected item.\r\n\t *\r\n\t *    @return The model index of the selected item.\r\n\t */\r\n\tQModelIndex getIndexOfItem(QVector<QString> itemIdentifierChain) const;\r\n\r\n\tvoid clearItemsModified() const;\r\n\r\npublic slots:\r\n\r\n\t/*!\r\n\t *  Handler for component editor item's content changed signal.\r\n\t *\r\n\t *    @param [in] item    Pointer to the item that changed.\r\n\t */\r\n\tvoid onContentChanged(ComponentEditorItem* item);\r\n\r\n\t/*!\r\n\t *  Add a new item to the tree under parent item.\r\n\t *\r\n\t *    @param [in] parentItem  Pointer to the item to add the child into.\r\n\t *    @param [in] childIndex  The index to add the child to.\r\n\t */\r\n\tvoid addItem(ComponentEditorItem* parentItem, int childIndex);\r\n\r\n\t/*!\r\n\t *  Remove a child from parent item.\r\n\t *\r\n\t *    @param [in] parentItem  Pointer to the item to remove the child from.\r\n\t *    @param [in] childIndex  The index of the child to remove.\r\n\t */\r\n\tvoid removeItem(ComponentEditorItem* parentItem, int childIndex);\r\n\r\n\t/*!\r\n\t *  Move a child from one position to another.\r\n\t *\r\n\t *    @param [in] parentItem      Pointer to the item that owns the child.\r\n\t *    @param [in] childSource     The index of the child to move.\r\n\t *    @param [in] childtarget     The index to move the child into.\r\n\t */\r\n\tvoid moveItem(ComponentEditorItem* parentItem, int childSource, int childtarget);\r\n\r\n\t/*!\r\n\t *  Set the locked state of the editors and visualizers.\r\n\t *\r\n\t *    @param [in] locked  True to set the editor's to view only mode.\r\n\t */\r\n\tvoid setLocked(bool locked);\r\n\r\nsignals:\r\n\r\n\t//! Emitted when an error message should be shown to user.\r\n\tvoid errorMessage(const QString& msg);\r\n\r\n\t/*!\r\n\t *  Opens the specific C source file of the given component.\r\n\t *\r\n\t *    @param [in] filename   The name of the file to open.\r\n\t *    @param [in] component  The component containing the file.\r\n\t */\r\n\tvoid openCSource(QString const& filename, QSharedPointer<Component> component);\r\n\r\n\t//! Emitted when a help page should be changed in the context help window.\r\n\tvoid helpUrlRequested(QString const& url);\r\n\r\n\t//! Emitted when a tree item with given index should be selected.\r\n\tvoid selectItem(const QModelIndex& index);\r\n\r\n\t//! Emitted when an item should be expanded in the navigation view.\r\n\tvoid expandItem(const QModelIndex& index);\r\n\r\n\t//! Emitted when a design editor should be opened for given hierarchical view.\r\n\tvoid openDesign(const VLNV& componentVLNV, const QString& viewName);\r\n\t\r\n\t//! Emitted when a bus editor should be opened for given bus.\r\n\tvoid openBus(const VLNV& busdefVLNV);\r\n\r\n\t//! Emitted when an Abstraction Definition editor should be opened for given Abstraction Definition.\r\n\tvoid openAbsDef(const VLNV& absdefVLNV);\r\n\r\n\t//! Emitted when a COM definition should be opened in an editor.\r\n\tvoid openComDefinition(const VLNV& comdefVLNV);\r\n\r\n\t//! Emitted when a SW design should be opened in an editor.\r\n\tvoid openSWDesign(const VLNV& componentVLNV, const QString& viewName);\r\n\r\n\t//! Emitted when a system design should be opened in an editor.\r\n\tvoid openSystemDesign(const VLNV& componentVLNV, const QString& viewName);\r\n\r\n\t//! Emitted when content change.\r\n\tvoid contentChanged();\r\n\r\nprivate slots:\r\n\r\n\t/*!\r\n\t *  Open bus interface editor for named bus interface.\r\n\t *\r\n\t *    @param [in] interfaceName   The name of the bus interface to open.\r\n\t */\r\n\tvoid onSelectBusInterface(const QString& interfaceName);\r\n\r\n\t/*!\r\n\t *  Select the given item to be displayed.\r\n\t *\r\n\t *    @param [in] item    Pointer to the item which should be displayed.\r\n\t */\r\n\tvoid onSelectItem(ComponentEditorItem* item);\r\n\r\nprivate:\r\n\r\n\t//! No copying or assignment.\r\n\tComponentEditorTreeModel(const ComponentEditorTreeModel& other);\r\n\tComponentEditorTreeModel& operator=(const ComponentEditorTreeModel& other);\r\n\r\n\t/*!\r\n\t *  Find the model index using the name of the item.\r\n\t *\r\n\t *    @param [in] identifier      Identifies the selected item.\r\n\t *    @param [in] parentIndex     Parent index of the selected item.\r\n\t *\r\n\t *    @return The model index of the selected item.\r\n\t */\r\n\tQModelIndex findIndexByItemIdentifier(QString const& identifier, QModelIndex parentIndex = QModelIndex())\r\n\t\tconst;\r\n\r\n\t//-----------------------------------------------------------------------------\r\n\t// Data.\r\n\t//-----------------------------------------------------------------------------\r\n\r\n\t//! Pointer to the root item of the tree.\r\n\tQSharedPointer<ComponentEditorRootItem> rootItem_ = nullptr;\r\n};\r\n\r\n#endif // COMPONENTEDITORTREEMODEL_H\r\n"
  },
  {
    "path": "editors/ComponentEditor/treeStructure/componenteditorviewitem.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: componenteditorviewitem.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 14.05.2012\r\n//\r\n// Description:\r\n// The item for a single view in the component editor's navigation tree.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"componenteditorviewitem.h\"\r\n#include <editors/ComponentEditor/views/vieweditor.h>\r\n\r\n#include <KactusAPI/include/LibraryHandler.h>\r\n\r\n#include <IPXACTmodels/Component/Component.h>\r\n#include <IPXACTmodels/Component/View.h>\r\n#include <IPXACTmodels/Component/ComponentInstantiation.h>\r\n#include <IPXACTmodels/Component/DesignInstantiation.h>\r\n#include <IPXACTmodels/Component/DesignConfigurationInstantiation.h>\r\n\r\n#include <IPXACTmodels/Component/validators/ViewValidator.h>\r\n#include <IPXACTmodels/common/validators/ParameterValidator.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditorViewItem::ComponentEditorViewItem()\r\n//-----------------------------------------------------------------------------\r\nComponentEditorViewItem::ComponentEditorViewItem(QSharedPointer<View> view, ComponentEditorTreeModel* model,\r\n    LibraryInterface* libHandler, QSharedPointer<Component> component,\r\n    QSharedPointer<ParameterFinder> parameterFinder, QSharedPointer<ExpressionFormatter> expressionFormatter,\r\n    QSharedPointer<ExpressionParser> expressionParser, QSharedPointer<ViewValidator> viewValidator,\r\n    ModuleParameterInterface* moduleParameterInterface, ComponentEditorItem* parent):\r\nComponentEditorItem(model, libHandler, component, parent),\r\nview_(view),\r\neditAction_(new QAction(tr(\"Edit\"), this)),\r\nexpressionParser_(expressionParser),\r\nviewValidator_(viewValidator),\r\nmoduleParameterInterface_(moduleParameterInterface)\r\n{\r\n    setParameterFinder(parameterFinder);\r\n    setExpressionFormatter(expressionFormatter);\r\n\r\n\tQ_ASSERT(view_);\r\n\r\n\tsetObjectName(tr(\"ComponentEditorViewItem: %1\").arg(view->name()));\r\n\r\n    connect(editAction_, SIGNAL(triggered(bool)), this, SLOT(openItem()), Qt::UniqueConnection); \r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditorViewItem::text()\r\n//-----------------------------------------------------------------------------\r\nQString ComponentEditorViewItem::text() const\r\n{\r\n\treturn view_->name();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditorViewItem::isValid()\r\n//-----------------------------------------------------------------------------\r\nbool ComponentEditorViewItem::isValid() const\r\n{\r\n    return viewValidator_->validate(view_);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditorViewItem::editor()\r\n//-----------------------------------------------------------------------------\r\nItemEditor* ComponentEditorViewItem::editor()\r\n{\r\n\tif (!editor_)\r\n    {\r\n        editor_ = new ViewEditor(\r\n            component_, view_, libHandler_, parameterFinder_, expressionFormatter_, moduleParameterInterface_);\r\n\t\teditor_->setProtection(locked_);\r\n\t\tconnect(editor_, SIGNAL(contentChanged()), this, SLOT(onEditorChanged()), Qt::UniqueConnection);\r\n\t\tconnect(editor_, SIGNAL(helpUrlRequested(QString const&)), this, SIGNAL(helpUrlRequested(QString const&)));\r\n\t}\r\n\treturn editor_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditorViewItem::getTooltip()\r\n//-----------------------------------------------------------------------------\r\nQString ComponentEditorViewItem::getTooltip() const\r\n{\r\n\treturn tr(\"Specifies a representation level of the component\");\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditorViewItem::canBeOpened()\r\n//-----------------------------------------------------------------------------\r\nbool ComponentEditorViewItem::canBeOpened() const\r\n{\r\n    return ( !view_->getDesignInstantiationRef().isEmpty() &&\r\n\t\tviewValidator_->hasValidDesignInstantiationReference(view_) ) ||\r\n        ( !view_->getDesignConfigurationInstantiationRef().isEmpty() &&\r\n\t\tviewValidator_->hasValidDesignConfigurationInstantiationReference(view_) );\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditorViewItem::actions()\r\n//-----------------------------------------------------------------------------\r\nQList<QAction*> ComponentEditorViewItem::actions() const\r\n{\r\n    QList<QAction*> actionList;\r\n    actionList.append(editAction_);\r\n\r\n    return actionList;   \r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditorViewItem::openItem()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentEditorViewItem::openItem()\r\n{\r\n\tif (canBeOpened())\r\n    {\r\n        emit openDesign(component_->getVlnv(), view_->name());\r\n\t}\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditorViewItem::isHierarchical()\r\n//-----------------------------------------------------------------------------\r\nbool ComponentEditorViewItem::isHierarchical() const\r\n{\r\n    return view_->isHierarchical();       \r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditorViewItem::hasIcon()\r\n//-----------------------------------------------------------------------------\r\nbool ComponentEditorViewItem::hasIcon() const\r\n{\r\n    return view_->isHierarchical();       \r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditorViewItem::getIcon()\r\n//-----------------------------------------------------------------------------\r\nQIcon ComponentEditorViewItem::getIcon() const\r\n{\r\n    if (view_->isHierarchical())\r\n    {\r\n        return QIcon(\":/icons/common/graphics/hierarchy.png\");\r\n    }\r\n    else\r\n    {\r\n        return QIcon();\r\n    }\r\n}\r\n"
  },
  {
    "path": "editors/ComponentEditor/treeStructure/componenteditorviewitem.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: componenteditorviewitem.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 14.05.2012\r\n//\r\n// Description:\r\n// The item for a single view in the component editor's navigation tree.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef COMPONENTEDITORVIEWITEM_H\r\n#define COMPONENTEDITORVIEWITEM_H\r\n\r\n#include \"componenteditoritem.h\"\r\n\r\n#include <QSharedPointer>\r\n\r\nclass View;\r\n\r\nclass LibraryInterface;\r\nclass ComponentInstantiation;\r\nclass DesignInstantiation;\r\nclass DesignConfigurationInstantiation;\r\nclass ViewValidator;\r\nclass InstantiationsValidator;\r\nclass ExpressionParser;\r\nclass ModuleParameterInterface;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! The item for a single view in the component editor's navigation tree.\r\n//-----------------------------------------------------------------------------\r\nclass ComponentEditorViewItem : public ComponentEditorItem\r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\r\n\t/*!\r\n\t *  The constructor.\r\n\t *\r\n\t *    @param [in] view                        The view being edited.\r\n\t *    @param [in] model                       The model that owns the items.\r\n\t *    @param [in] libHandler                  The instance that manages the library.\r\n\t *    @param [in] component                   The component being edited.\r\n\t *    @param [in] parameterFinder             The parameter finder.\r\n     *    @param [in] expressionFormatter         The expression formatter.\r\n     *    @param [in] expressionParser            The used expression parser.\r\n     *    @param [in] viewValidator               Validator used for views.\r\n     *    @param [in] moduleParameterInterface    Interface for accessing module parameters.\r\n\t *    @param [in] parent                      The parent item.\r\n\t */\r\n\tComponentEditorViewItem(QSharedPointer<View> view,\r\n        ComponentEditorTreeModel* model,\r\n        LibraryInterface* libHandler,\r\n        QSharedPointer<Component> component,\r\n        QSharedPointer<ParameterFinder> parameterFinder,\r\n        QSharedPointer<ExpressionFormatter> expressionFormatter,\r\n        QSharedPointer<ExpressionParser> expressionParser,\r\n        QSharedPointer<ViewValidator> viewValidator,\r\n        ModuleParameterInterface* moduleParameterInterface,\r\n        ComponentEditorItem* parent);\r\n\r\n\t/*!\r\n     *  The destructor.\r\n     */\r\n\tvirtual ~ComponentEditorViewItem() = default;\r\n\r\n\t/*!\r\n     *  Get the tool tip for the item.\r\n\t * \r\n\t *    @return The text for the tool tip to print to user.\r\n\t */\r\n\tvirtual QString getTooltip() const;\r\n\r\n\t/*!\r\n     *  Get the text to be displayed to user in the tree for this item.\r\n\t *\r\n\t *    @return QString Contains the text to display.\r\n\t */\r\n\tvirtual QString text() const;\r\n\r\n\t/*!\r\n     *  Check the validity of this item and sub items.\r\n\t *\r\n\t *    @return bool True if item is in valid state.\r\n\t */\r\n\tvirtual bool isValid() const;\r\n\r\n\t/*!\r\n     *  Get The editor of this item.\r\n\t *\r\n\t *    @return The editor to use for this item.\r\n\t */\r\n\tvirtual ItemEditor* editor();\r\n\r\n\t/*!\r\n     *  Tells if the item can be opened or not.\r\n\t * \r\n\t *  If the view is hierarchical and reference hasn't changed then it can be opened.\r\n\t */\r\n\tvirtual bool canBeOpened() const;\r\n\r\n\t/*!\r\n     *  Tells if the view is hierarchical or not.\r\n\t * \r\n\t *  If the view is hierarchical, returns true, otherwise false.\r\n\t */\r\n    virtual bool isHierarchical() const;\r\n\r\n\t/*!\r\n     *  Tells if the view has a decoration icon or not.\r\n\t * \r\n\t *  If the view has an icon, returns true, otherwise false.\r\n\t */\r\n    virtual bool hasIcon() const;\r\n\r\n\t/*!\r\n     *  Gets the decoration icon for the view.\r\n\t * \r\n\t *  If the view is hierarchical, hierarchy icon is returned, otherwise a null icon.\r\n\t */\r\n    virtual QIcon getIcon() const;\r\n\r\n    /*!\r\n     *  Returns the possible actions for opening the item.\r\n     *\r\n     *    @return The actions to open the item.\r\n     */\r\n    virtual QList<QAction*> actions() const;\r\n\r\npublic slots:\r\n\t\r\n\t/*!\r\n     *  Open the view in a design editor.\r\n\t */\r\n\tvirtual void openItem();\r\n\r\nprivate:\r\n\r\n\r\n    //! No copying.\r\n\tComponentEditorViewItem(const ComponentEditorViewItem& other);\r\n\r\n\t//! No assignment.\r\n\tComponentEditorViewItem& operator=(const ComponentEditorViewItem& other);\r\n\r\n    /*!\r\n     *  Create the validator used for instantiations.\r\n     */\r\n    void createInstantiationsValidator();\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n\t//! The view being edited.\r\n\tQSharedPointer<View> view_;\r\n\r\n    //! Action to open the view for editing.\r\n    QAction* editAction_;\r\n\r\n    //! The used expression parser.\r\n    QSharedPointer<ExpressionParser> expressionParser_;\r\n\r\n    //! The used validator for views.\r\n    QSharedPointer<ViewValidator> viewValidator_;\r\n\r\n    //! Interface for accessing module parameters.\r\n    ModuleParameterInterface* moduleParameterInterface_;\r\n};\r\n\r\n#endif // COMPONENTEDITORVIEWITEM_H\r\n"
  },
  {
    "path": "editors/ComponentEditor/treeStructure/componenteditorviewsitem.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: componenteditorviewsitem.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 09.05.2012\r\n//\r\n// Description:\r\n// The Views-item in the component editor's navigation tree.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"componenteditorviewsitem.h\"\r\n#include \"componenteditorviewitem.h\"\r\n#include <editors/ComponentEditor/views/viewseditor.h>\r\n\r\n#include <IPXACTmodels/common/validators/ParameterValidator.h>\r\n#include <IPXACTmodels/Component/Component.h>\r\n#include <IPXACTmodels/Component/View.h>\r\n#include <IPXACTmodels/Component/validators/ViewValidator.h>\r\n#include <IPXACTmodels/Component/validators/CollectionValidators.h>\r\n\r\n#include <KactusAPI/include/ComponentInstantiationParameterFinder.h>\r\n#include <KactusAPI/include/MultipleParameterFinder.h>\r\n#include <KactusAPI/include/ModuleParameterInterface.h>\r\n\r\n#include <KactusAPI/include/IPXactSystemVerilogParser.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: componenteditorviewsitem::ComponentEditorViewsItem()\r\n//-----------------------------------------------------------------------------\r\nComponentEditorViewsItem::ComponentEditorViewsItem(ComponentEditorTreeModel* model, LibraryInterface* libHandler,\r\n    QSharedPointer<Component> component, QSharedPointer<ReferenceCounter> referenceCounter,\r\n    QSharedPointer<ParameterFinder> parameterFinder, QSharedPointer<ExpressionFormatter> expressionFormatter,\r\n    QSharedPointer<ExpressionParser> expressionParser, ComponentEditorItem* parent):\r\nComponentEditorItem(model, libHandler, component, parent),\r\nviews_(component->getViews()),\r\nexpressionParser_(expressionParser),\r\nviewValidator_(new ViewValidator(expressionParser, component->getModel())),\r\nviewsValidator_(new ViewsValidator(viewValidator_)),\r\nmoduleParameterInterface_(0)\r\n{\r\n    setParameterFinder(parameterFinder);\r\n    setExpressionFormatter(expressionFormatter);\r\n\r\n    createInterfaces();\r\n\r\n\tsetObjectName(tr(\"ComponentEditorViewsItem\"));\r\n\r\n    setReferenceCounter(referenceCounter);\r\n\r\n\tfor (QSharedPointer<View> view : *views_)\r\n    {\r\n\t\tQSharedPointer<ComponentEditorViewItem> viewItem(new ComponentEditorViewItem(view, model, libHandler,\r\n            component, parameterFinder_, expressionFormatter_, expressionParser, viewValidator_,\r\n            moduleParameterInterface_, this));\r\n\r\n        viewItem->setReferenceCounter(referenceCounter);\r\n\t\tchildItems_.append(viewItem);\r\n\t}\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: componenteditorviewsitem::getTooltip()\r\n//-----------------------------------------------------------------------------\r\nQString ComponentEditorViewsItem::getTooltip() const\r\n{\r\n    return tr(\"Contains the views of the component\");\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditorViewsItem::getFont()\r\n//-----------------------------------------------------------------------------\r\nQFont ComponentEditorViewsItem::getFont() const\r\n{\r\n    QFont font(ComponentEditorItem::getFont());\r\n    font.setBold(!views_->isEmpty());\r\n    return font;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: componenteditorviewsitem::text()\r\n//-----------------------------------------------------------------------------\r\nQString ComponentEditorViewsItem::text() const\r\n{\r\n\treturn tr(\"Views\");\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: componenteditorviewsitem::editor()\r\n//-----------------------------------------------------------------------------\r\nItemEditor* ComponentEditorViewsItem::editor()\r\n{\r\n\tif (!editor_)\r\n    {\r\n\t\teditor_ = new ViewsEditor(component_, libHandler_, viewValidator_);\r\n\t\teditor_->setProtection(locked_);\r\n\r\n\t\tconnect(editor_, SIGNAL(contentChanged()), this, SLOT(onEditorChanged()), Qt::UniqueConnection);\r\n\t\tconnect(editor_, SIGNAL(childAdded(int)), this, SLOT(onAddChild(int)), Qt::UniqueConnection);\r\n\t\tconnect(editor_, SIGNAL(childRemoved(int)), this, SLOT(onRemoveChild(int)), Qt::UniqueConnection);\r\n\t\tconnect(editor_, SIGNAL(helpUrlRequested(QString const&)), this, SIGNAL(helpUrlRequested(QString const&)));\r\n\t}\r\n\treturn editor_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: componenteditorviewsitem::createChild()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentEditorViewsItem::createChild( int index )\r\n{\r\n\tQSharedPointer<ComponentEditorViewItem> viewItem(\r\n        new ComponentEditorViewItem(views_->at(index), model_, libHandler_, component_, parameterFinder_,\r\n            expressionFormatter_, expressionParser_, viewValidator_, moduleParameterInterface_, this));\r\n\tviewItem->setLocked(locked_);\r\n\r\n    viewItem->setReferenceCounter(referenceCounter_);\r\n\tchildItems_.insert(index, viewItem);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditorViewsItem::isValid()\r\n//-----------------------------------------------------------------------------\r\nbool ComponentEditorViewsItem::isValid() const\r\n{\r\n    auto viewsAsNameGroups = CollectionValidators::itemListToNameGroupList(views_);\r\n    viewsValidator_->childrenHaveUniqueNames(viewsAsNameGroups);\r\n    return ComponentEditorItem::isValid();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: componenteditorviewsitem::createInterfaces()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentEditorViewsItem::createInterfaces()\r\n{\r\n    QSharedPointer<ParameterValidator> validator(\r\n        new ParameterValidator(expressionParser_, component_->getChoices(), component_->getRevision()));\r\n\r\n    QSharedPointer<ComponentInstantiationParameterFinder> instantiationParameterFinder(\r\n        new ComponentInstantiationParameterFinder(QSharedPointer<ComponentInstantiation>()));\r\n\r\n    QSharedPointer<MultipleParameterFinder> combinedInstantiationFinder =\r\n        QSharedPointer<MultipleParameterFinder>(new MultipleParameterFinder);\r\n    combinedInstantiationFinder->addFinder(parameterFinder_);\r\n    combinedInstantiationFinder->addFinder(instantiationParameterFinder);\r\n\r\n    QSharedPointer<IPXactSystemVerilogParser> instantiationParser(\r\n        new IPXactSystemVerilogParser(combinedInstantiationFinder));\r\n\r\n    QSharedPointer<ExpressionFormatter> instantiationFormatter(\r\n        new ExpressionFormatter(combinedInstantiationFinder));\r\n\r\n    moduleParameterInterface_ = new ModuleParameterInterface(\r\n        validator, instantiationParser, instantiationFormatter, instantiationParameterFinder);\r\n}\r\n"
  },
  {
    "path": "editors/ComponentEditor/treeStructure/componenteditorviewsitem.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: componenteditorviewsitem.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 09.05.2012\r\n//\r\n// Description:\r\n// The Views-item in the component editor's navigation tree.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef COMPONENTEDITORVIEWSITEM_H\r\n#define COMPONENTEDITORVIEWSITEM_H\r\n\r\n#include \"componenteditoritem.h\"\r\n\r\n#include <QSharedPointer>\r\n\r\nclass Component;\r\nclass View;\r\n\r\nclass ExpressionParser;\r\nclass ViewValidator;\r\nclass ViewsValidator;\r\nclass InstantiationsValidator;\r\nclass ModuleParameterInterface;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! The Views-item in the component editor's navigation tree.\r\n//-----------------------------------------------------------------------------\r\nclass ComponentEditorViewsItem : public ComponentEditorItem\r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\r\n\t/*!\r\n\t *  The constructor.\r\n\t *\r\n\t *    @param [in] model                   Pointer to the model that owns the items.\r\n\t *    @param [in] libHandler              Pointer to the instance that manages the library.\r\n\t *    @param [in] component               Pointer to the component being edited.\r\n\t *    @param [in] referenceCounter        Pointer to the reference counter.\r\n\t *    @param [in] parameterFinder         Pointer to the parameter finder.\r\n\t *    @param [in] expressionFormatter     Pointer to the expression formatter.\r\n     *    @param [in] expressionParser        The used expression parser.\r\n\t *    @param [in] parent                  Pointer to the parent item.\r\n\t */\r\n\tComponentEditorViewsItem(ComponentEditorTreeModel* model,\r\n        LibraryInterface* libHandler,\r\n        QSharedPointer<Component> component,\r\n        QSharedPointer<ReferenceCounter> referenceCounter,\r\n        QSharedPointer<ParameterFinder> parameterFinder,\r\n        QSharedPointer<ExpressionFormatter> expressionFormatter,\r\n        QSharedPointer<ExpressionParser> expressionParser,\r\n        ComponentEditorItem* parent);\r\n\r\n\t/*!\r\n     *  The destructor.\r\n     */\r\n\tvirtual ~ComponentEditorViewsItem() = default;\r\n\r\n\t/*!\r\n     *  Get the tool tip for the item.\r\n\t * \r\n\t *    @return The text for the tool tip to print to user.\r\n\t */\r\n\tvirtual QString getTooltip() const;\r\n\r\n\t/*!\r\n     *  Get the font to be used for text of this item.\r\n\t *\r\n\t *    @return QFont instance that defines the font to be used.\r\n\t */\r\n    virtual QFont getFont() const;\r\n\r\n\t/*!\r\n     *  Get the text to be displayed to user in the tree for this item.\r\n\t *\r\n\t *    @return QString Contains the text to display.\r\n\t */\r\n\tvirtual QString text() const;\r\n\r\n\t/*!\r\n     *  Get pointer to the editor of this item.\r\n\t *\r\n\t *    @return Pointer to the editor to use for this item.\r\n\t */\r\n\tvirtual ItemEditor* editor();\r\n\r\n\t/*!\r\n     *  Add a new child to the item.\r\n\t * \r\n\t *    @param [in] index   The index to add the child into.\r\n\t */\r\n\tvirtual void createChild(int index);\r\n\r\n\t/*!\r\n\t *  Check the validity of this item and sub items.\r\n\t *\r\n\t *    @return bool True if item is in valid state.\r\n\t */\r\n\tbool isValid() const override;\r\n\r\nprivate:\r\n\r\n\t//! No copying.\r\n\tComponentEditorViewsItem(const ComponentEditorViewsItem& other);\r\n\r\n\t//! No assignment.\r\n\tComponentEditorViewsItem& operator=(const ComponentEditorViewsItem& other);\r\n\r\n    /*!\r\n     *  Create interfaces for views.\r\n     */\r\n    void createInterfaces();\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n    \r\n    //! The views being edited.\r\n    QSharedPointer<QList<QSharedPointer<View> > > views_;\r\n\r\n    //! The used expression parser.\r\n    QSharedPointer<ExpressionParser> expressionParser_;\r\n\r\n    //! The validator used for views.\r\n    QSharedPointer<ViewValidator> viewValidator_;\r\n\r\n\t//! The validator used for validating views together.\r\n\tQSharedPointer<ViewsValidator> viewsValidator_;\r\n\r\n    //! Interface for accessing module parameters.\r\n    ModuleParameterInterface* moduleParameterInterface_;\r\n};\r\n\r\n#endif // COMPONENTEDITORVIEWSITEM_H\r\n"
  },
  {
    "path": "editors/ComponentEditor/treeStructure/componenttreeview.cpp",
    "content": "/* \r\n *\r\n *  Created on: 21.1.2011\r\n *      Author: Antti Kamppi\r\n */\r\n\r\n#include \"componenttreeview.h\"\r\n\r\n#include \"componenteditoritem.h\"\r\n\r\n#include <KactusAPI/include/LibraryInterface.h>\r\n#include <editors/ComponentEditor/treeStructure/ComponentEditorTreeSortProxyModel.h>\r\n\r\n#include <QEvent>\r\n#include <QCursor>\r\n#include <QMenu>\r\n#include <QUrl>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentTreeView::ComponentTreeView()\r\n//-----------------------------------------------------------------------------\r\nComponentTreeView::ComponentTreeView(LibraryInterface* handler,\r\n\t\t\t\t\t\t\t\t\t const VLNV& compVLNV,\r\n\t\t\t\t\t\t\t\t\t QWidget *parent):\r\nExpandingTreeView(parent),\r\npressedPoint_(),\r\nlocked_(true),\r\nhandler_(handler),\r\ncomponentVLNV_(compVLNV),\r\nexpandAllItemsAction_(new QAction(tr(\"Expand all\"), this)),\r\ncollapseAllItemsAction_(new QAction(tr(\"Collapse all\"), this)),\r\nitemExpandAction_(new QAction(\"Expand\", this)),\r\nitemCollapseAction_(new QAction(\"Collapse\", this))\r\n{\r\n\t// can be used in debugging to identify the object\r\n\tsetObjectName(tr(\"ComponentTreeView\"));\r\n\r\n\t// header is not shown \r\n\tsetHeaderHidden(true);\r\n\r\n\tsetIndentation(20);\r\n\r\n\tsetFrameShape(QFrame::NoFrame);\r\n\r\n\t// only one item can be selected at a time\r\n\tsetSelectionMode(QAbstractItemView::SingleSelection);\r\n\r\n\tsetSelectionBehavior(QAbstractItemView::SelectItems);\r\n\r\n    connect(expandAllItemsAction_, SIGNAL(triggered()), this, SLOT(expandAll()), Qt::UniqueConnection);\r\n    connect(collapseAllItemsAction_, SIGNAL(triggered()), this, SLOT(collapseAll()), Qt::UniqueConnection);\r\n\r\n    connect(itemExpandAction_, SIGNAL(triggered()), this, SLOT(onExpandItem()), Qt::UniqueConnection);\r\n    connect(itemCollapseAction_, SIGNAL(triggered()), this, SLOT(onCollapseItem()), Qt::UniqueConnection);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentTreeView::currentChanged()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentTreeView::currentChanged(const QModelIndex & current, \r\n\t\t\t\t\t\t\t\t\t   const QModelIndex & previous ) \r\n{\r\n\t// call the base class implementation\r\n\tQTreeView::currentChanged(current, previous);\r\n\r\n\t// inform that the current index has changed\r\n\temit activated(current);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentTreeView::mousePressEvent()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentTreeView::mousePressEvent( QMouseEvent* event )\r\n{\r\n\tpressedPoint_ = event->pos();\r\n\tQTreeView::mousePressEvent(event);\r\n\r\n    QModelIndex index = indexAt(pressedPoint_);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentTreeView::mouseReleaseEvent()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentTreeView::mouseReleaseEvent( QMouseEvent* event ) \r\n{\r\n\t// make sure widget is not locked\r\n\tif (!locked_) \r\n    {\r\n\t\tQModelIndex pressedIndex = indexAt(pressedPoint_);\r\n\r\n\t\tQModelIndex releaseIndex = indexAt(event->pos());\r\n\r\n\t\t// if either index is invalid or indexes are the same\r\n\t\tif (!releaseIndex.isValid() || !pressedIndex.isValid() || \r\n\t\t\t(releaseIndex == pressedIndex)) {\r\n\t\t\t\r\n\t\t\t// do the normal release event functionality\r\n\t\t\tQTreeView::mouseReleaseEvent(event);\r\n\r\n\t\t\t// restore the normal cursor\r\n\t\t\tsetCursor(QCursor(Qt::ArrowCursor));\r\n\t\t\treturn;\r\n\t\t}\r\n\r\n\t\tQModelIndex parent1 = pressedIndex.model()->parent(pressedIndex);\r\n\t\tQModelIndex parent2 = releaseIndex.model()->parent(releaseIndex);\r\n\r\n\t\tif (parent1.isValid() && parent1 == parent2) {\r\n\t\t\temit moveItem(pressedIndex, releaseIndex);\r\n\r\n\t\t\tQModelIndex newIndex = indexAt(event->pos());\r\n\t\t\tsetCurrentIndex(newIndex);\r\n\t\t\temit activated(newIndex);\r\n\t\t}\r\n\t}\r\n\r\n\t// restore the normal cursor\r\n\tsetCursor(QCursor(Qt::ArrowCursor));\r\n\r\n\tQTreeView::mouseReleaseEvent(event);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentTreeView::mouseMoveEvent()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentTreeView::mouseMoveEvent( QMouseEvent* event )\r\n{\r\n\t// if not dragging an item or item is locked\r\n\tif (event->buttons() == Qt::NoButton || locked_)\r\n    {\r\n\t\tQTreeView::mouseMoveEvent(event);\r\n\t}\r\n\t// if dragging item\r\n\telse \r\n    {\r\n\t\tQModelIndex startIndex = indexAt(pressedPoint_);\r\n\t\tQModelIndex thisIndex = indexAt(event->pos());\r\n\r\n\t\t// if either index is invalid then dragging is not possible\r\n\t\tif (!startIndex.isValid() || !thisIndex.isValid()) {\r\n\t\t\tsetCursor(QCursor(Qt::ForbiddenCursor));\r\n\t\t\treturn;\r\n\t\t}\r\n\r\n\t\tQModelIndex parent1 = startIndex.model()->parent(startIndex);\r\n\t\tQModelIndex parent2 = thisIndex.model()->parent(thisIndex);\r\n\r\n\t\t// if both have same parent\r\n\t\tif (parent1 == parent2) \r\n        {\r\n\t\t\tsetCursor(QCursor(Qt::ClosedHandCursor));\r\n\t\t}\r\n\t\telse\r\n        {\r\n\t\t\tsetCursor(QCursor(Qt::ForbiddenCursor));\r\n\t\t}\r\n\t}\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentTreeView::setLocked()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentTreeView::setLocked( bool locked )\r\n{\r\n\tlocked_ = locked;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentTreeView::selectItem()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentTreeView::selectItem( const QModelIndex& index )\r\n{\r\n\tselectionModel()->select(index, QItemSelectionModel::ClearAndSelect);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentTreeView::contextMenuEvent()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentTreeView::contextMenuEvent( QContextMenuEvent* event )\r\n{\r\n    menuIndex_ = indexAt(event->pos());\r\n\r\n\t// save the position where click occurred\r\n\tpressedPoint_ = event->pos();\r\n\t\r\n\t// if item can be opened then show the context menu\r\n    QMenu menu(this);\r\n\r\n    if (ComponentEditorItem* item = getPressedItem(); item)\r\n    {\r\n         menu.addActions(item->actions());\r\n\r\n        if (item->hasChildren())\r\n        {\r\n            menu.addAction(itemExpandAction_);\r\n            menu.addAction(itemCollapseAction_);\r\n\r\n            menu.addSeparator();\r\n        }\r\n    }\r\n\r\n    menu.addAction(expandAllItemsAction_);\r\n    menu.addAction(collapseAllItemsAction_);\r\n\r\n    menu.exec(event->globalPos());\r\n\r\n\tevent->accept();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentTreeView::onExpandItem()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentTreeView::onExpandItem()\r\n{\r\n    expand(menuIndex_);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentTreeView::onCollapseItem()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentTreeView::onCollapseItem()\r\n{\r\n    collapse(menuIndex_);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentTreeView::mouseDoubleClickEvent()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentTreeView::mouseDoubleClickEvent( QMouseEvent* event )\r\n{\r\n\tevent->accept();\r\n\r\n\tQModelIndex index = indexAt(event->pos());\r\n\r\n\tif (!index.isValid()) {\r\n\t\treturn;\r\n\t}\r\n\r\n\t// save the position where click occurred\r\n\tpressedPoint_ = event->pos();\r\n\t\r\n\tgetPressedItem()->openItem();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentTreeView::getPressedItem()\r\n//-----------------------------------------------------------------------------\r\nComponentEditorItem* ComponentTreeView::getPressedItem()\r\n{\r\n    // To get correct internal pointer, the index from source model must be used. Proxy performs the mapping.\r\n    ComponentEditorTreeProxyModel* proxy = dynamic_cast<ComponentEditorTreeProxyModel*>(model());\r\n    Q_ASSERT(proxy != 0);\r\n\r\n    QModelIndex index = indexAt(pressedPoint_);\r\n\r\n    return static_cast<ComponentEditorItem*>(proxy->mapToSource(index).internalPointer());    \r\n}\r\n"
  },
  {
    "path": "editors/ComponentEditor/treeStructure/componenttreeview.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ComponentEditorTreeView.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 21.01.2011\r\n//\r\n// Description:\r\n// brief ComponentTreeView is a widget to display the navigation tree.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef COMPONENTTREEVIEW_H\r\n#define COMPONENTTREEVIEW_H\r\n\r\n#include <common/views/ExpandingTreeView/ExpandingTreeView.h>\r\n\r\n#include <IPXACTmodels/common/VLNV.h>\r\n\r\n#include <QTreeView>\r\n#include <QModelIndex>\r\n#include <QMouseEvent>\r\n#include <QKeyEvent>\r\n#include <QContextMenuEvent>\r\n#include <QAction>\r\n\r\nclass LibraryInterface;\r\nclass ComponentEditorItem;\r\n/*! \\brief ComponentTreeView is a widget to display the navigation tree.\r\n * \r\n * This tree view displays a navigation tree in IPXactComponentEditor that\r\n * is used to navigate between IP-Xact elements.\r\n */\r\n\r\n//-----------------------------------------------------------------------------\r\n//! ComponentTreeView is a widget to display the navigation tree.\r\n//  This tree view displays a navigation tree in IPXactComponentEditor that\r\n//  is used to navigate between IP-Xact elements.\r\n//-----------------------------------------------------------------------------\r\nclass ComponentTreeView : public ExpandingTreeView\r\n{\r\n    Q_OBJECT\r\n\r\npublic:\r\n    \r\n\t//! The default width of the navigation tree.\r\n    enum\r\n    {\r\n        DEFAULT_WIDTH = 180\r\n    };\r\n\r\n    /*!\r\n     *  The constructor.\r\n     *\r\n     *    @param [in] handler     Pointer to the instance that manages the library.\r\n     *    @param [in] compVLNV    The VLNV of the component being edited.\r\n     *    @param [in] parent      Pointer to the owner of this widget\r\n     */\r\n    ComponentTreeView(LibraryInterface* handler,\r\n\t\tconst VLNV& compVLNV,\r\n\t\tQWidget *parent);\r\n\r\n\t/*!\r\n     *  The destructor.\r\n     */\r\n     ~ComponentTreeView() final = default;\r\n\r\n\t/*!\r\n     *  Set the locked state(enables / disables the dragging).\r\n     * \r\n     *    @param [in] locked  The new locked status.\r\n     */\r\n\tvoid setLocked(bool locked);\r\n\r\n\t/*!\r\n     *  Select the specified item and deselect all others.\r\n\t *\r\n\t *    @param [in] index   Identifies the item to select.\r\n     */\r\n\tvoid selectItem(const QModelIndex& index);\r\n\r\nsignals:\r\n\r\n\t/*!\r\n     *  Emitted when user wants to move item from one place to another.\r\n     */\r\n\tvoid moveItem(const QModelIndex& source, const QModelIndex& target);\r\n\r\nprotected:\r\n\r\n\t/*!\r\n     *  Called when a new item becomes the current item.\r\n\t *\r\n\t *  This is reimplemented function that calls the base class implementation \r\n\t *  and also emits activated() signal for the current model index.\r\n\t * \r\n\t *    @param [in] current     ModelIndex of the new item\r\n\t *    @param [in] previous    ModelIndex of the previous item\r\n     */\r\n\tvirtual void currentChanged(const QModelIndex & current, const QModelIndex & previous);\r\n\r\n\t/*!\r\n     *  Handler for mouse press events.\r\n     */\r\n\tvirtual void mousePressEvent(QMouseEvent* event);\r\n\r\n\t/*!\r\n     *  Handler for mouse release events.\r\n     */\r\n\tvirtual void mouseReleaseEvent(QMouseEvent* event);\r\n\r\n\t/*!\r\n     *  Handler for mouse move events.\r\n     */\r\n\tvirtual void mouseMoveEvent(QMouseEvent* event);\r\n\r\n\t/*!\r\n     *  The context menu event handler.\r\n     */\r\n\tvirtual void contextMenuEvent(QContextMenuEvent* event);\r\n\r\n\t/*!\r\n     *  The handler for mouse double clicks.\r\n     */\r\n\tvirtual void mouseDoubleClickEvent(QMouseEvent* event);\r\n\r\nprivate slots:\r\n\r\n    /*!\r\n     *  Handle the expand of the selected item.\r\n     */\r\n    void onExpandItem();\r\n\r\n    /*!\r\n     *  Handle the collapse of the selected item.\r\n     */\r\n    void onCollapseItem();\r\n\r\nprivate:\r\n\r\n\t//! No copying\r\n\tComponentTreeView(const ComponentTreeView& other);\r\n\r\n\t//! No assignment\r\n\tComponentTreeView& operator=(const ComponentTreeView& other);\r\n\r\n    /*!\r\n     *  Finds the clicked item.     \r\n     *\r\n     *    @return The clicked item.\r\n     */\r\n    ComponentEditorItem* getPressedItem();\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n    \r\n    //! The mouse position where the mouse was pressed.\r\n\tQPoint pressedPoint_;\r\n\r\n    //! The currently selected context menu index.\r\n    QModelIndex menuIndex_;\r\n\r\n\t//! The current locked state (enables/disables dragging)\r\n\tbool locked_;\r\n\r\n\t//! Pointer to the instance that manages the library.\r\n\tLibraryInterface* handler_;\r\n\r\n\t//! The vlnv of the component being edited.\r\n\tVLNV componentVLNV_;\r\n\r\n    //! Action for displaying all child items.\r\n    QAction* expandAllItemsAction_;\r\n\r\n    //! Action for hiding all child items.\r\n    QAction* collapseAllItemsAction_;\r\n\r\n    //! Action for displaying all the child items of the selected item.\r\n    QAction* itemExpandAction_;\r\n\r\n    //! Action for hiding all the child items of the selected item.\r\n    QAction* itemCollapseAction_;\r\n};\r\n\r\n#endif // COMPONENTTREEVIEW_H\r\n"
  },
  {
    "path": "editors/ComponentEditor/views/EnvIdentifiersColumns.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: EnvIdentifiersColumns.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Mikko Teuho\r\n// Date: 23.10.2015\r\n//\r\n// Description:\r\n// Common declarations for editing environment identifiers columns.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef ENVIDENTIFIERSCOLUMNS_H\r\n#define ENVIDENTIFIERSCOLUMNS_H\r\n\r\nnamespace EnvIdentifiersColumns\r\n{\r\n    //! Defines the columns for the environment identifiers table.\r\n    enum Column\r\n    {\r\n        LANGUAGE = 0,\r\n        TOOL,\r\n        VENDOR_SPECIFIC,\r\n        COLUMN_COUNT\r\n    };\r\n}\r\n\r\n#endif //ENVIDENTIFIERSCOLUMNS_H"
  },
  {
    "path": "editors/ComponentEditor/views/ViewColumns.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ViewColumns.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Mikko Teuho\r\n// Date: 26.10.2015\r\n//\r\n// Description:\r\n// Common declarations for columns editing views.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef VIEWCOLUMNS_H\r\n#define VIEWCOLUMNS_H\r\n\r\nnamespace ViewColumns\r\n{\r\n    //! Defines the columns for the views table.\r\n    enum Column\r\n    {\r\n        NAME_COLUMN = 0,\r\n        TYPE_COLUMN,\r\n        DESCRIPTION_COLUMN,\r\n        COLUMN_COUNT\r\n    };\r\n}\r\n\r\n#endif //VIEWCOLUMNS_H"
  },
  {
    "path": "editors/ComponentEditor/views/ViewsDelegate.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ViewsDelegate.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Esko Pekkarinen\r\n// Date: 27.07.2015\r\n//\r\n// Description:\r\n// The delegate that provides editors to edit the views summary.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"ViewsDelegate.h\"\r\n#include \"ViewColumns.h\"\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ViewsDelegate::ViewsDelegate()\r\n//-----------------------------------------------------------------------------\r\nViewsDelegate::ViewsDelegate(QObject* parent): MultilineDescriptionDelegate(parent)\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ViewsDelegate::~ViewsDelegate()\r\n//-----------------------------------------------------------------------------\r\nViewsDelegate::~ViewsDelegate()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ViewsDelegate::descriptionColumn()\r\n//-----------------------------------------------------------------------------\r\nint ViewsDelegate::descriptionColumn() const\r\n{\r\n    return ViewColumns::DESCRIPTION_COLUMN;\r\n}\r\n"
  },
  {
    "path": "editors/ComponentEditor/views/ViewsDelegate.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ViewsDelegate.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Esko Pekkarinen\r\n// Date: 27.07.2015\r\n//\r\n// Description:\r\n// The delegate that provides editors to edit the views summary.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef VIEWSDELEGATE_H\r\n#define VIEWSDELEGATE_H\r\n\r\n#include <editors/ComponentEditor/common/MultilineDescriptionDelegate.h>\r\n\r\n#include <QEvent>\r\n\r\n//-----------------------------------------------------------------------------\r\n//! The delegate that provides editors to edit the views summary.\r\n//-----------------------------------------------------------------------------\r\nclass ViewsDelegate : public MultilineDescriptionDelegate \r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\r\n    /*!\r\n     *  The constructor.\r\n     *\r\n     *    @param [in] parent      The parent object.\r\n     */\r\n\tViewsDelegate(QObject* parent);\r\n\t\r\n\t//! The destructor\r\n\tvirtual ~ViewsDelegate();\r\n\r\nprotected:\r\n\r\n    // Gets the column for description.\r\n    virtual int descriptionColumn() const;\r\n\r\nprivate:\r\n\t//! No copying\r\n\tViewsDelegate(const ViewsDelegate& other);\r\n\tViewsDelegate& operator=(const ViewsDelegate& other);\r\n\r\n};\r\n\r\n#endif // VIEWSDELEGATE_H\r\n"
  },
  {
    "path": "editors/ComponentEditor/views/envidentifiereditor.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: envidentifiereditor.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 15.04.2011\r\n//\r\n// Description:\r\n// Widget to edit the ipxact:envIdentifiers element within view.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"envidentifiereditor.h\"\r\n\r\n#include <IPXACTmodels/Component/View.h>\r\n\r\n#include <QVBoxLayout>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: EnvIdentifierEditor::EnvIdentifierEditor()\r\n//-----------------------------------------------------------------------------\r\nEnvIdentifierEditor::EnvIdentifierEditor(QSharedPointer<View> view, QWidget *parent): \r\nQGroupBox(tr(\"Environment identifiers\"), parent),\r\nview_(this),\r\nmodel_(view, this), \r\nproxy_(this) \r\n{\r\n\t// set view to be sortable\r\n\tview_.setSortingEnabled(true);\r\n\r\n\t// items can not be dragged\r\n\tview_.setItemsDraggable(false);\r\n\r\n\t// set source model for proxy\r\n\tproxy_.setSourceModel(&model_);\r\n\t// set proxy to be the source for the view\r\n\tview_.setModel(&proxy_);\r\n\r\n\t// sort the view\r\n\tview_.sortByColumn(0, Qt::AscendingOrder);\r\n\r\n\t// create the layout, add widgets to it\r\n\tQVBoxLayout* layout = new QVBoxLayout(this);\r\n\tlayout->addWidget(&view_);\r\n\r\n\tconnect(&model_, SIGNAL(contentChanged()), this, SIGNAL(contentChanged()), Qt::UniqueConnection);\r\n\tconnect(&model_, SIGNAL(dataChanged(const QModelIndex&, const QModelIndex&)),\r\n\t\tthis, SIGNAL(contentChanged()), Qt::UniqueConnection);\r\n\tconnect(&model_, SIGNAL(errorMessage(const QString&)),\r\n\t\tthis, SIGNAL(errorMessage(const QString&)), Qt::UniqueConnection);\r\n\tconnect(&model_, SIGNAL(noticeMessage(const QString&)),\r\n\t\tthis, SIGNAL(noticeMessage(const QString&)), Qt::UniqueConnection);\r\n\r\n\tconnect(&view_, SIGNAL(addItem(const QModelIndex&)),\r\n\t\t&model_, SLOT(onAddItem(const QModelIndex&)), Qt::UniqueConnection);\r\n\tconnect(&view_, SIGNAL(removeItem(const QModelIndex&)),\r\n\t\t&model_, SLOT(onRemoveItem(const QModelIndex&)), Qt::UniqueConnection);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: EnvIdentifierEditor::~EnvIdentifierEditor()\r\n//-----------------------------------------------------------------------------\r\nEnvIdentifierEditor::~EnvIdentifierEditor()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: EnvIdentifierEditor::refresh()\r\n//-----------------------------------------------------------------------------\r\nvoid EnvIdentifierEditor::refresh()\r\n{\r\n\tview_.update();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: EnvIdentifierEditor::isValid()\r\n//-----------------------------------------------------------------------------\r\nbool EnvIdentifierEditor::isValid() const\r\n{\r\n\treturn model_.isValid();\r\n}\r\n"
  },
  {
    "path": "editors/ComponentEditor/views/envidentifiereditor.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: envidentifiereditor.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 15.04.2011\r\n//\r\n// Description:\r\n// Widget to edit the ipxact:envIdentifiers element within view.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef ENVIDENTIFIEREDITOR_H\r\n#define ENVIDENTIFIEREDITOR_H\r\n\r\n#include \"envidentifiersmodel.h\"\r\n\r\n#include <common/views/EditableTableView/editabletableview.h>\r\n\r\n#include <QGroupBox>\r\n#include <QString>\r\n#include <QSortFilterProxyModel>\r\n#include <QSharedPointer>\r\n\r\nclass View;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Widget to edit the spirit:envIdentifiers element within view.\r\n//-----------------------------------------------------------------------------\r\nclass EnvIdentifierEditor : public QGroupBox\r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\r\n\t/*!\r\n     *  The constructor.\r\n\t *\r\n\t *    @param [in] view    The view being edited.\r\n\t *    @param [in] parent  The owner of this widget.\r\n\t */\r\n\tEnvIdentifierEditor(QSharedPointer<View> view, QWidget *parent);\r\n\t\r\n\t//! The destructor.\r\n\tvirtual ~EnvIdentifierEditor();\r\n\r\n\t/*!\r\n     *  Restore the changes made in the editor back to ones in the model.\r\n\t */\r\n\tvirtual void refresh();\r\n\r\n\t/*!\r\n     *  Check for the validity of the edited parameters.\r\n\t *\r\n\t *    @return True if all parameters are in valid state.\r\n\t */\r\n\tvirtual bool isValid() const;\r\n\r\nsignals:\r\n\r\n\t//! Signal to inform user that one element has been modified.\r\n\tvoid contentChanged();\r\n\r\n\t//! Prints an error message to the user.\r\n\tvoid errorMessage(const QString& msg) const;\r\n\r\n\t//! Prints a notification to user.\r\n\tvoid noticeMessage(const QString& msg) const;\r\n\r\nprivate:\r\n\r\n\t//! No copying.\r\n\tEnvIdentifierEditor(const EnvIdentifierEditor& other);\r\n\r\n\t//! No assignment\r\n\tEnvIdentifierEditor& operator=(const EnvIdentifierEditor& other);\r\n\r\n\t//! The view that displays the parameters.\r\n\tEditableTableView view_;\r\n\r\n\t//! The model that holds the data to be displayed to the user.\r\n\tEnvIdentifiersModel model_;\r\n\r\n\t//! The proxy that is used to sort the view.\r\n\tQSortFilterProxyModel proxy_;\r\n};\r\n\r\n#endif // ENVIDENTIFIEREDITOR_H\r\n"
  },
  {
    "path": "editors/ComponentEditor/views/envidentifiersmodel.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: envidentifiereditor.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 18.04.2011\r\n//\r\n// Description:\r\n// Model that contains the environment identifiers to be displayed to user.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"envidentifiersmodel.h\"\r\n#include \"EnvIdentifiersColumns.h\"\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: envidentifiersmodel::EnvIdentifiersModel()\r\n//-----------------------------------------------------------------------------\r\nEnvIdentifiersModel::EnvIdentifiersModel(QSharedPointer<View> view, QObject *parent ):\r\nQAbstractTableModel(parent), \r\nview_(view),\r\ntable_(view->getEnvIdentifiers())\r\n{\r\n\t\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: envidentifiersmodel::~EnvIdentifiersModel()\r\n//-----------------------------------------------------------------------------\r\nEnvIdentifiersModel::~EnvIdentifiersModel()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: envidentifiersmodel::rowCount()\r\n//-----------------------------------------------------------------------------\r\nint EnvIdentifiersModel::rowCount(QModelIndex const& parent) const\r\n{\r\n\tif (parent.isValid())\r\n    {\r\n\t\treturn 0;\r\n    }\r\n\r\n\treturn table_->size();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: envidentifiersmodel::columnCount()\r\n//-----------------------------------------------------------------------------\r\nint EnvIdentifiersModel::columnCount(QModelIndex const& parent) const\r\n{\r\n\tif (parent.isValid())\r\n    {\r\n\t\treturn 0;\r\n\t}\r\n\r\n    return EnvIdentifiersColumns::COLUMN_COUNT;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: envidentifiersmodel::data()\r\n//-----------------------------------------------------------------------------\r\nQVariant EnvIdentifiersModel::data(QModelIndex const& index, int role) const\r\n{\r\n\tif (!index.isValid() || index.row() < 0 || index.row() >= table_->size())\r\n    {\r\n\t\treturn QVariant();\r\n    }\r\n\telse if (role == Qt::DisplayRole || role == Qt::EditRole)\r\n\t{\r\n\t\tif ( index.column() == 0 )\r\n\t\t{\r\n\t\t\treturn table_->at(index.row())->language;\r\n\t\t}\r\n\t\telse if ( index.column() == 1 )\r\n\t\t{\r\n\t\t\treturn table_->at(index.row())->tool;\r\n\t\t}\r\n\t\telse if ( index.column() == 2 )\r\n\t\t{\r\n\t\t\treturn table_->at(index.row())->vendorSpecific;\r\n\t\t}\r\n\r\n\t\treturn \"\";\r\n\t}\r\n\t// if unsupported role\r\n\telse\r\n    {\r\n\t\treturn QVariant();\r\n\t}\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: envidentifiersmodel::headerData()\r\n//-----------------------------------------------------------------------------\r\nQVariant EnvIdentifiersModel::headerData(int section, Qt::Orientation orientation, int role) const\r\n{\r\n    if (orientation != Qt::Horizontal)\r\n    {\r\n        return QVariant();\r\n    }\r\n\r\n    if (role == Qt::DisplayRole)\r\n    {\r\n        if (section == EnvIdentifiersColumns::LANGUAGE)\r\n        {\r\n            return tr(\"Language\");\r\n        }\r\n        else if (section == EnvIdentifiersColumns::TOOL)\r\n        {\r\n            return tr(\"Tool\");\r\n        }\r\n        else if (section == EnvIdentifiersColumns::VENDOR_SPECIFIC)\r\n        {\r\n            return tr(\"Vendor specific\");\r\n        }\r\n    }\r\n    return QVariant();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: envidentifiersmodel::setData()\r\n//-----------------------------------------------------------------------------\r\nbool EnvIdentifiersModel::setData(QModelIndex const& index, const QVariant& value, int role)\r\n{\r\n\tif (!index.isValid() ||index.row() < 0 || index.row() >= table_->size())\r\n    {\r\n        return false;\r\n    }\r\n\telse if (role == Qt::EditRole)\r\n    {\r\n\t\tint row = index.row();\r\n\r\n\t\tQSharedPointer<View::EnvironmentIdentifier> envId = table_->at(row);\r\n\r\n\t\tif ( index.column() == 0 )\r\n\t\t{\r\n\t\t\tenvId->language = value.toString();\r\n\t\t}\r\n\t\telse if ( index.column() == 1 )\r\n\t\t{\r\n\t\t\tenvId->tool = value.toString();\r\n\t\t}\r\n\t\telse if ( index.column() == 2 )\r\n\t\t{\r\n\t\t\tenvId->vendorSpecific = value.toString();\r\n\t\t}\r\n\r\n\t\temit dataChanged(index, index);\r\n\t\temit contentChanged();\r\n\t\treturn true;\r\n\t}\r\n\t// if unsupported role\r\n\telse\r\n    {\r\n\t\treturn false;\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: envidentifiersmodel::flags()\r\n//-----------------------------------------------------------------------------\r\nQt::ItemFlags EnvIdentifiersModel::flags(QModelIndex const& index) const\r\n{\r\n\tif (!index.isValid())\r\n    {\r\n\t\treturn Qt::NoItemFlags;\r\n\t}\r\n\r\n\treturn Qt::ItemIsEditable | Qt::ItemIsEnabled | Qt::ItemIsSelectable;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: envidentifiersmodel::isValid()\r\n//-----------------------------------------------------------------------------\r\nbool EnvIdentifiersModel::isValid() const\r\n{\r\n\treturn true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: envidentifiersmodel::onRemoveItem()\r\n//-----------------------------------------------------------------------------\r\nvoid EnvIdentifiersModel::onRemoveItem( QModelIndex const& index )\r\n{\r\n\t// don't remove anything if index is invalid\r\n\tif (!index.isValid() || index.row() < 0 || index.row() >= table_->size())\r\n    {\r\n\t\treturn;\r\n\t}\r\n\r\n\t// remove the specified item\r\n\tbeginRemoveRows(QModelIndex(), index.row(), index.row());\r\n\ttable_->removeAt(index.row());\r\n\tendRemoveRows();\r\n\r\n\t// tell also parent widget that contents have been changed\r\n\temit contentChanged();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: envidentifiersmodel::onAddItem()\r\n//-----------------------------------------------------------------------------\r\nvoid EnvIdentifiersModel::onAddItem( QModelIndex const& index )\r\n{\r\n\tint row = table_->size();\r\n\r\n\t// if the index is valid then add the item to the correct position\r\n\tif (index.isValid())\r\n    {\r\n\t\trow = index.row();\r\n\t}\r\n\r\n\tbeginInsertRows(QModelIndex(), row, row);\r\n\tQSharedPointer<View::EnvironmentIdentifier> envId(new View::EnvironmentIdentifier);\r\n\ttable_->insert(row, envId);\r\n\tendInsertRows();\r\n\r\n\t// tell also parent widget that contents have been changed\r\n\temit contentChanged();\r\n}\r\n"
  },
  {
    "path": "editors/ComponentEditor/views/envidentifiersmodel.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: envidentifiereditor.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 18.04.2011\r\n//\r\n// Description:\r\n// Model that contains the environment identifiers to be displayed to user.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef ENVIDENTIFIERSMODEL_H\r\n#define ENVIDENTIFIERSMODEL_H\r\n\r\n#include <QAbstractTableModel>\r\n#include <QStringList>\r\n#include <QSharedPointer>\r\n\r\n#include <IPXACTmodels/Component/View.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Model that contains the environment identifiers to be displayed to user.\r\n//-----------------------------------------------------------------------------\r\nclass EnvIdentifiersModel : public QAbstractTableModel\r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\t\r\n\t/*!\r\n     *  The constructor.\r\n\t *\r\n\t *    @param [in] view    The view being edited.\r\n\t *    @param [in] parent  The owner of this model\r\n\t */\r\n\tEnvIdentifiersModel(QSharedPointer<View> view, QObject *parent);\r\n\t\r\n\t//! The destructor.\r\n\tvirtual ~EnvIdentifiersModel();\r\n\r\n\t/*!\r\n     *  Get the number of rows in the model.\r\n\t *\r\n\t *    @param [in] parent  Model index of the parent of the item.\r\n     *\r\n\t *    @return Number of rows currently in the model.\r\n\t */\r\n\tvirtual int rowCount(const QModelIndex& parent = QModelIndex() ) const;\r\n\r\n\t/*!\r\n     *  Get the number of columns in the model.\r\n\t *\r\n\t *    @param [in] parent  Model index of the parent of the item.\r\n\t *\r\n\t *    @return Always returns 3.\r\n\t */\r\n\tvirtual int columnCount(const QModelIndex& parent = QModelIndex() ) const;\r\n\r\n\t/*!\r\n     *  Get the data for the specified item for specified role.\r\n\t *\r\n\t *    @param [in] index   Identifies the item that's data is wanted.\r\n\t *    @param [in] role    Specifies what kind of data is wanted\r\n\t *\r\n\t *    @return QVariant containing the data\r\n\t */\r\n\tvirtual QVariant data(const QModelIndex& index, int role = Qt::DisplayRole ) const;\r\n\r\n\t/*!\r\n     *  Get the data for the headers.\r\n\t *\r\n\t *    @param [in] section         The column that's header is wanted\r\n\t *    @param [in] orientation     Only Qt::Horizontal is supported\r\n\t *    @param [in] role            Specified the type of data that is wanted.\r\n\t *\r\n\t *    @return QVariant containing the data to be displayed\r\n\t */\r\n\tvirtual QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole ) const;\r\n\r\n\t/*!\r\n     *  Set the data for specified item.\r\n\t *\r\n\t *    @param [in] index   Specifies the item that's data is modified\r\n\t *    @param [in] value   The value to be set.\r\n\t *    @param [in] role    The role that is trying to modify the data. Only Qt::EditRole is supported.\r\n\t *\r\n\t *    @return True if data was successfully set.\r\n\t */\r\n\tvirtual bool setData(const QModelIndex& index, const QVariant& value, int role = Qt::EditRole );\r\n\r\n\t/*!\r\n     *  Get information on how specified item can be handled.\r\n\t *\r\n\t *    @param [in] index   Specifies the item that's flags are wanted.\r\n\t *\r\n\t *    @return Qt::ItemFlags that define how object can be handled.\r\n\t */\r\n\tvirtual Qt::ItemFlags flags(const QModelIndex& index) const;\r\n\r\n\t/*!\r\n     *  Check if the model is in valid state or not.\r\n\t *\r\n\t *    @return True if all items in model are valid.\r\n\t */\r\n\tbool isValid() const;\r\n\r\npublic slots:\r\n\r\n\t/*!\r\n     *  A new item should be added to given index.\r\n\t *\r\n\t *    @param [in] index   The position where new item should be added at.\r\n\t */\r\n\tvoid onAddItem(const QModelIndex& index);\r\n\r\n\t/*!\r\n     *  An item should be removed from the model.\r\n\t * \r\n\t *    @param [in] index   Identifies the item that should be removed.\r\n\t */\r\n\tvoid onRemoveItem(const QModelIndex& index);\r\n\r\nsignals:\r\n\r\n\t//! Emitted when contents of the model change.\r\n\tvoid contentChanged();\r\n\r\n\t//! Prints an error message to the user.\r\n\tvoid errorMessage(const QString& msg) const;\r\n\t\r\n\t//! Prints a notification to user.\r\n\tvoid noticeMessage(const QString& msg) const;\r\n\r\nprivate:\r\n\t\r\n\t//! No copying.\r\n\tEnvIdentifiersModel(const EnvIdentifiersModel& other);\r\n\r\n\t//! No assignment.\r\n\tEnvIdentifiersModel& operator=(const EnvIdentifiersModel& other);\r\n\r\n\t//! The view being edited.\r\n\tQSharedPointer<View> view_;\r\n\r\n\t//! Contains the environment identifiers being edited.\r\n    QSharedPointer<QList<QSharedPointer<View::EnvironmentIdentifier> > > table_;\r\n};\r\n\r\n#endif // ENVIDENTIFIERSMODEL_H\r\n"
  },
  {
    "path": "editors/ComponentEditor/views/vieweditor.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: vieweditor.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 14.4.2011\r\n//\r\n// Description:\r\n// Editor to edit a view within a component.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"vieweditor.h\"\r\n\r\n#include \"envidentifiereditor.h\"\r\n\r\n#include <KactusAPI/include/LibraryInterface.h>\r\n\r\n#include <common/NameGenerationPolicy.h>\r\n\r\n#include <editors/ComponentEditor/common/ReferenceSelector/ReferenceSelector.h>\r\n#include <editors/ComponentEditor/instantiations/ComponentInstantiationDisplayer.h>\r\n#include <editors/ComponentEditor/instantiations/ModuleParameterEditor.h>\r\n\r\n#include <common/widgets/nameGroupEditor/namegroupeditor.h>\r\n#include <common/widgets/vlnvDisplayer/vlnvdisplayer.h>\r\n\r\n#include <IPXACTmodels/Component/Component.h>\r\n#include <IPXACTmodels/Component/ComponentInstantiation.h>\r\n#include <IPXACTmodels/Component/View.h>\r\n#include <IPXACTmodels/common/FileBuilder.h>\r\n\r\n#include <QVBoxLayout>\r\n#include <QFormLayout>\r\n#include <QHBoxLayout>\r\n#include <QSizePolicy>\r\n#include <QScrollArea>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ViewEditor::ViewEditor()\r\n//-----------------------------------------------------------------------------\r\nViewEditor::ViewEditor(QSharedPointer<Component> component, QSharedPointer<View> view,\r\n    LibraryInterface* libHandler, QSharedPointer<ParameterFinder> parameterFinder,\r\n    QSharedPointer<ExpressionFormatter> expressionFormatter, ModuleParameterInterface* parameterInterface,\r\n    QWidget *parent) :\r\nItemEditor(component, libHandler, parent),\r\nview_(view),\r\nnameEditor_(new NameGroupEditor(view, component->getRevision(), this, tr(\"View name and description\"))),\r\nenvIdentifier_(new EnvIdentifierEditor(view, this)),\r\ncomponentInstantiationSelector_(new ReferenceSelector(this)),\r\ndesignConfigurationInstantiationSelector_(new ReferenceSelector(this)),\r\ndesignInstantiationSelector_(new ReferenceSelector(this)),\r\ncomponentInstantiationDisplay_(new ComponentInstantiationDisplayer(this)),\r\nhierarchyGroup_(new QGroupBox(tr(\"Design and configuration\"), this)),\r\ndesignConfigurationDisplay_(new VLNVDisplayer(this, VLNV())),\r\ndesignDisplay_(new VLNVDisplayer(this, VLNV())),\r\nmoduleParameterEditor_(\r\n    new ModuleParameterEditor(QSharedPointer<ComponentInstantiation>(new ComponentInstantiation()),\r\n        component->getChoices(), parameterFinder, expressionFormatter, parameterInterface,\r\n        component->getRevision(), this))\r\n{\r\n    moduleParameterEditor_->disableEditing();\r\n\r\n    designConfigurationDisplay_->setTitle(tr(\"Design configuration\"));\r\n    designDisplay_->setTitle(tr(\"Design\"));\r\n\r\n    setupLayout();\r\n\r\n    refresh();\r\n\r\n    connect(nameEditor_, SIGNAL(contentChanged()),\tthis, SIGNAL(contentChanged()), Qt::UniqueConnection);\r\n\r\n    connect(envIdentifier_, SIGNAL(contentChanged()), this, SIGNAL(contentChanged()), Qt::UniqueConnection);\r\n\r\n    connect(componentInstantiationSelector_, SIGNAL(itemSelected(QString const&)),\r\n        this, SLOT(onComponentInstanceChanged(QString const&)), Qt::UniqueConnection);\r\n    connect(designConfigurationInstantiationSelector_, SIGNAL(itemSelected(QString const&)),\r\n        this, SLOT(onDesignConfigurationInstanceChanged(QString const&)), Qt::UniqueConnection);\r\n    connect(designInstantiationSelector_, SIGNAL(itemSelected(QString const&)),\r\n        this, SLOT(onDesignInstanceChanged(QString const&)), Qt::UniqueConnection);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ViewEditor::refresh()\r\n//-----------------------------------------------------------------------------\r\nvoid ViewEditor::refresh()\r\n{\r\n\tnameEditor_->refresh();\r\n\tenvIdentifier_->refresh();\r\n\r\n    QStringList componentInstantiationNames;\r\n    foreach(QSharedPointer<ComponentInstantiation> componentInstantiation, \r\n        *component()->getComponentInstantiations())\r\n    {\r\n        componentInstantiationNames.append(componentInstantiation->name());\r\n    }\r\n    componentInstantiationSelector_->refresh(componentInstantiationNames);\r\n    componentInstantiationSelector_->selectItem(view_->getComponentInstantiationRef());\r\n    onComponentInstanceChanged(view_->getComponentInstantiationRef());\r\n\r\n    QStringList designConfigurationInstantiationNames;\r\n    foreach(QSharedPointer<DesignConfigurationInstantiation> designConfigurationInstantiation, \r\n        *component()->getDesignConfigurationInstantiations())\r\n    {\r\n        designConfigurationInstantiationNames.append(designConfigurationInstantiation->name());\r\n        if (designConfigurationInstantiation->name() == view_->getDesignConfigurationInstantiationRef())\r\n        {\r\n            designConfigurationDisplay_->setVLNV(\r\n                *designConfigurationInstantiation->getDesignConfigurationReference());\r\n        }\r\n    }\r\n    designConfigurationInstantiationSelector_->refresh(designConfigurationInstantiationNames);\r\n    designConfigurationInstantiationSelector_->selectItem(view_->getDesignConfigurationInstantiationRef());\r\n    onDesignConfigurationInstanceChanged(view_->getDesignConfigurationInstantiationRef());\r\n\r\n    QStringList designInstantiationNames;\r\n    foreach(QSharedPointer<DesignInstantiation> designInstantiation, *component()->getDesignInstantiations())\r\n    {\r\n        designInstantiationNames.append(designInstantiation->name());\r\n        if (designInstantiation->name() == view_->getDesignInstantiationRef())\r\n        {\r\n            designDisplay_->setVLNV(*designInstantiation->getDesignReference());\r\n        }\r\n    }\r\n    designInstantiationSelector_->refresh(designInstantiationNames);\r\n    designInstantiationSelector_->selectItem(view_->getDesignInstantiationRef());\r\n    onDesignInstanceChanged(view_->getDesignInstantiationRef()); \r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ViewEditor::showEvent()\r\n//-----------------------------------------------------------------------------\r\nvoid ViewEditor::showEvent(QShowEvent* event)\r\n{\r\n    QWidget::showEvent(event);\r\n    emit helpUrlRequested(\"componenteditor/view.html\");\r\n    refresh();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ViewEditor::onComponentInstanceChanged()\r\n//-----------------------------------------------------------------------------\r\nvoid ViewEditor::onComponentInstanceChanged(QString const& instanceName)\r\n{\r\n    QString previousInstance = view_->getComponentInstantiationRef();\r\n\r\n    view_->setComponentInstantiationRef(instanceName);\r\n\r\n    QSharedPointer<ComponentInstantiation> instantiation = \r\n        component()->getModel()->findComponentInstantiation(instanceName);\r\n    componentInstantiationDisplay_->setInstantiation(instantiation);\r\n\r\n    if (instantiation)\r\n    {\r\n        moduleParameterEditor_->setModuleParameters(instantiation);\r\n    }\r\n    moduleParameterEditor_->setVisible(instantiation.isNull() == false);\r\n\r\n    if (previousInstance != instanceName)\r\n    {\r\n        emit contentChanged();\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ViewEditor::onDesignConfigurationInstanceChanged()\r\n//-----------------------------------------------------------------------------\r\nvoid ViewEditor::onDesignConfigurationInstanceChanged(QString const& instanceName)\r\n{    \r\n    QString previousInstance = view_->getDesignConfigurationInstantiationRef();\r\n\r\n    view_->setDesignConfigurationInstantiationRef(instanceName);\r\n\r\n    QSharedPointer<DesignConfigurationInstantiation> selectedInstantiation;\r\n\r\n    foreach(QSharedPointer<DesignConfigurationInstantiation> configurationInstantiation, \r\n        *component()->getDesignConfigurationInstantiations())\r\n    {\r\n        if (configurationInstantiation->name() == instanceName)\r\n        {\r\n            selectedInstantiation = configurationInstantiation;\r\n        }\r\n    }\r\n\r\n    VLNV selectedVLNV;\r\n    if (selectedInstantiation)\r\n    {\r\n        selectedVLNV = *selectedInstantiation->getDesignConfigurationReference();\r\n    }\r\n\r\n    hierarchyGroup_->setVisible(!instanceName.isEmpty() || !designInstantiationSelector_->currentText().isEmpty());\r\n    designConfigurationDisplay_->setVisible(selectedInstantiation.isNull() == false);\r\n    designConfigurationDisplay_->setVLNV(selectedVLNV);\r\n\r\n    if (previousInstance != instanceName)\r\n    {\r\n        emit contentChanged();\r\n    }    \r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ViewEditor::onDesignInstanceChanged()\r\n//-----------------------------------------------------------------------------\r\nvoid ViewEditor::onDesignInstanceChanged(QString const& instanceName)\r\n{    \r\n    QString previousInstance = view_->getDesignInstantiationRef();\r\n\r\n    view_->setDesignInstantiationRef(instanceName);\r\n\r\n    QSharedPointer<DesignInstantiation> selectedInstantiation;\r\n\r\n    foreach(QSharedPointer<DesignInstantiation> designInstantiation, *component()->getDesignInstantiations())\r\n    {\r\n        if (designInstantiation->name() == instanceName)\r\n        {\r\n            selectedInstantiation = designInstantiation;\r\n        }\r\n    }\r\n\r\n    VLNV selectedVLNV;\r\n    if (selectedInstantiation)\r\n    {\r\n        selectedVLNV = *selectedInstantiation->getDesignReference();\r\n    }\r\n\r\n    hierarchyGroup_->setVisible(!instanceName.isEmpty() || \r\n        !designConfigurationInstantiationSelector_->currentText().isEmpty());\r\n    designDisplay_->setVisible(selectedInstantiation.isNull() == false);\r\n    designDisplay_->setVLNV(selectedVLNV);\r\n\r\n    if (previousInstance != instanceName)\r\n    {\r\n        emit contentChanged();\r\n    }    \r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ViewEditor::setupLayout()\r\n//-----------------------------------------------------------------------------\r\nvoid ViewEditor::setupLayout()\r\n{\r\n    // create the scroll area\r\n    QScrollArea* scrollArea = new QScrollArea(this);\r\n    scrollArea->setWidgetResizable(true);\r\n    scrollArea->setFrameShape(QFrame::NoFrame);\r\n\r\n    QHBoxLayout* scrollLayout = new QHBoxLayout(this);\r\n    scrollLayout->addWidget(scrollArea);\r\n    scrollLayout->setContentsMargins(0, 0, 0, 0);\r\n\r\n    QGroupBox* instantiationsGroup = new QGroupBox(tr(\"Instantiations\"), this);\r\n    QFormLayout* instancesLayout = new QFormLayout(instantiationsGroup);\r\n    instancesLayout->addRow(tr(\"Component instantiation:\"), componentInstantiationSelector_);\r\n    instancesLayout->addRow(tr(\"Design configuration instantiation:\"), designConfigurationInstantiationSelector_);\r\n    instancesLayout->addRow(tr(\"Design instantiation:\"), designInstantiationSelector_);\r\n\r\n    QVBoxLayout* editorsLayout = new QVBoxLayout(hierarchyGroup_);\r\n    editorsLayout->addWidget(designConfigurationDisplay_, 0);\r\n    editorsLayout->addWidget(designDisplay_, 0);\r\n    editorsLayout->addStretch();\r\n\r\n    // create the top widget and set it under the scroll area\r\n    QWidget* topWidget = new QWidget(scrollArea);\r\n\r\n    // create the layout for the top widget\r\n    QGridLayout* topLayout = new QGridLayout(topWidget);\r\n    topLayout->addWidget(nameEditor_, 0, 0, 1, 1);\r\n    topLayout->addWidget(componentInstantiationDisplay_, 0, 1, 1, 1); \r\n    topLayout->addWidget(instantiationsGroup, 1, 0, 1, 1);\r\n    topLayout->addWidget(hierarchyGroup_, 1, 1, 2, 1);\r\n    \r\n    topLayout->addWidget(envIdentifier_, 2, 0, 1, 1);\r\n    topLayout->addWidget(moduleParameterEditor_, 3, 0, 1, 2);\r\n    topLayout->setRowStretch(0, 1);\r\n    topLayout->setRowStretch(1, 1);\r\n    topLayout->setRowStretch(2, 1);\r\n    topLayout->setRowStretch(3, 5);\r\n    topLayout->setColumnStretch(0, 1);\r\n    topLayout->setColumnStretch(1, 1);\r\n    topLayout->setContentsMargins(0, 0, 0, 0);\r\n\r\n    scrollArea->setWidget(topWidget);\r\n}\r\n"
  },
  {
    "path": "editors/ComponentEditor/views/vieweditor.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: vieweditor.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 14.4.2011\r\n//\r\n// Description:\r\n// Editor to edit a view within a component.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef VIEWEDITOR_H\r\n#define VIEWEDITOR_H\r\n\r\n#include <editors/ComponentEditor/itemeditor.h>\r\n\r\n#include <QSharedPointer>\r\n#include <QGroupBox>\r\n\r\nclass Component;\r\nclass ComponentInstantiation;\r\nclass ComponentInstantiationDisplayer;\r\nclass DesignInstantiation;\r\nclass DesignConfigurationInstantiation;\r\nclass EnvIdentifierEditor;\r\nclass ExpressionFormatter;\r\nclass LibraryInterface;\r\nclass NameGroupEditor;\r\nclass ModuleParameterEditor;\r\nclass ParameterFinder;\r\nclass ReferenceSelector;\r\nclass View;\r\nclass VLNVDisplayer;\r\nclass ModuleParameterInterface;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Editor to edit a view within a component.\r\n//-----------------------------------------------------------------------------\r\nclass ViewEditor : public ItemEditor\r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\r\n\t/*!\r\n\t *  The constructor.\r\n\t *\r\n\t *    @param [in] component               The component that contains the view.\r\n\t *    @param [in] view                    The view being edited.\r\n\t *    @param [in] libHandler              The instance that manages the library.\r\n\t *    @param [in] parameterFinder         The parameter finder.\r\n\t *    @param [in] expressionFormatter     The expression formatter.\r\n     *    @param [in] parameterInterface      Interface for accessing parameters.\r\n\t *    @param [in] parent                  The owner of this editor.\r\n\t */\r\n\tViewEditor(QSharedPointer<Component> component,\r\n        QSharedPointer<View> view,\r\n        LibraryInterface* libHandler,\r\n        QSharedPointer<ParameterFinder> parameterFinder,\r\n        QSharedPointer<ExpressionFormatter> expressionFormatter,\r\n        ModuleParameterInterface* parameterInterface,\r\n        QWidget *parent = 0);\r\n\t\r\n\t/*!\r\n     *  The destructor.\r\n     */\r\n\tvirtual ~ViewEditor() = default;\r\n\r\n\t/*!\r\n     *  Reload the information from the model to the editor.\r\n\t */\r\n\tvirtual void refresh();\r\n\r\nprotected:\r\n\r\n    //! Called when the widget is shown.\r\n    void showEvent(QShowEvent* event);\r\n\r\nprivate slots:\r\n\r\n    //! Called when a component instance is selected.\r\n    void onComponentInstanceChanged(QString const& instanceName);\r\n\r\n    //! Called when a design configuration instance is selected.\r\n    void onDesignConfigurationInstanceChanged(QString const& instanceName);\r\n\r\n    //! Called when a design instance is selected.\r\n    void onDesignInstanceChanged(QString const& instanceName);\r\n\r\nprivate:\r\n\r\n\t//! No copying.\r\n\tViewEditor(const ViewEditor& other);\r\n\r\n\t//! No assignment.\r\n\tViewEditor& operator=(const ViewEditor& other);\r\n\r\n\t//! Set up the layout for the editor.\r\n\tvoid setupLayout();\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n\t//! The instance that manages the library.\r\n\tLibraryInterface* libHandler_;\r\n\r\n\t//! The view being edited.\r\n\tQSharedPointer<View> view_;\r\n\t\r\n\t//! Editor to set the name, display name and description of the view.\r\n\tNameGroupEditor* nameEditor_;\r\n\r\n\t//! The editor to edit the envIdentifier element.\r\n\tEnvIdentifierEditor* envIdentifier_;\r\n\r\n    //! Selector for component instantiation reference.\r\n    ReferenceSelector* componentInstantiationSelector_;\r\n    \r\n    //! Selector for design configuration instantiation reference.\r\n    ReferenceSelector* designConfigurationInstantiationSelector_;\r\n    \r\n    //! Selector for design instantiation reference.\r\n    ReferenceSelector* designInstantiationSelector_;\r\n\r\n    //! Display widget for component instantiation details.\r\n    ComponentInstantiationDisplayer* componentInstantiationDisplay_;\r\n\r\n    //! Group box for design and design configuration VLNV references.\r\n    QGroupBox* hierarchyGroup_;\r\n\r\n    //! Display widget for design configuration instantiation VLNV.\r\n    VLNVDisplayer* designConfigurationDisplay_;\r\n\r\n    //! Display widget for design instantiation VLNV.\r\n    VLNVDisplayer* designDisplay_;\r\n\r\n    //! The display for module parameters of the component instance.\r\n    ModuleParameterEditor* moduleParameterEditor_;\r\n};\r\n\r\n#endif // VIEWEDITOR_H\r\n"
  },
  {
    "path": "editors/ComponentEditor/views/viewseditor.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: viewseditor.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 12.06.2012\r\n//\r\n// Description:\r\n// The editor to add/remove/edit views of a component.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"viewseditor.h\"\r\n\r\n#include \"ViewsDelegate.h\"\r\n#include \"ViewColumns.h\"\r\n\r\n#include <common/widgets/summaryLabel/summarylabel.h>\r\n#include <common/delegates/LineEditDelegate/lineeditdelegate.h>\r\n#include <KactusAPI/include/LibraryInterface.h>\r\n\r\n#include <QVBoxLayout>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ViewsEditor::ViewsEditor()\r\n//-----------------------------------------------------------------------------\r\nViewsEditor::ViewsEditor(QSharedPointer<Component> component, LibraryInterface* handler,\r\n                         QSharedPointer<ViewValidator> viewValidator, QWidget* parent /* = 0 */):\r\nItemEditor(component, handler, parent),\r\nview_(this),\r\nproxy_(this),\r\nmodel_(component, viewValidator, this)\r\n{\r\n\t// display a label on top the table\r\n\tSummaryLabel* summaryLabel = new SummaryLabel(tr(\"Views summary\"), this);\r\n\r\n\tQVBoxLayout* layout = new QVBoxLayout(this);\r\n\tlayout->addWidget(summaryLabel, 0, Qt::AlignCenter);\r\n\tlayout->addWidget(&view_);\r\n\tlayout->setContentsMargins(0, 0, 0, 0);\r\n\r\n\tproxy_.setSourceModel(&model_);\t\r\n    proxy_.setDynamicSortFilter(false);\r\n\r\n\tview_.setModel(&proxy_);    \r\n    view_.sortByColumn(ViewColumns::NAME_COLUMN, Qt::AscendingOrder);\r\n    view_.sortByColumn(ViewColumns::TYPE_COLUMN, Qt::AscendingOrder);\r\n\r\n\tconst QString compPath = ItemEditor::handler()->getDirectoryPath(ItemEditor::component()->getVlnv());\r\n\tQString defPath = QString(\"%1/viewListing.csv\").arg(compPath);\r\n\tview_.setDefaultImportExportPath(defPath);\r\n\tview_.setAllowImportExport(true);\r\n\r\n\t// items can not be dragged\r\n\tview_.setItemsDraggable(false);\r\n\r\n\tview_.setItemDelegate(new ViewsDelegate(this));\r\n\r\n\tconnect(&model_, SIGNAL(contentChanged()), this, SIGNAL(contentChanged()), Qt::UniqueConnection);\r\n    connect(&model_, SIGNAL(contentChanged()), this, SLOT(onItemChanged()), Qt::UniqueConnection);\r\n\tconnect(&model_, SIGNAL(viewAdded(int)), this, SIGNAL(childAdded(int)), Qt::UniqueConnection);\r\n\tconnect(&model_, SIGNAL(viewRemoved(int)), this, SIGNAL(childRemoved(int)), Qt::UniqueConnection);\r\n\r\n\tconnect(&view_, SIGNAL(addItem(const QModelIndex&)),\r\n        &model_, SLOT(onAddItem(const QModelIndex&)), Qt::UniqueConnection);\r\n\tconnect(&view_, SIGNAL(removeItem(const QModelIndex&)),\r\n\t\t&model_, SLOT(onRemoveItem(const QModelIndex&)), Qt::UniqueConnection);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ViewsEditor::~ViewsEditor()\r\n//-----------------------------------------------------------------------------\r\nViewsEditor::~ViewsEditor()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ViewsEditor::refresh()\r\n//-----------------------------------------------------------------------------\r\nvoid ViewsEditor::refresh()\r\n{    \r\n    onItemChanged();\r\n    view_.update();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ViewsEditor::onItemChanged()\r\n//-----------------------------------------------------------------------------\r\nvoid ViewsEditor::onItemChanged()\r\n{\r\n    view_.sortByColumn(ViewColumns::NAME_COLUMN, Qt::AscendingOrder);\r\n    view_.sortByColumn(ViewColumns::TYPE_COLUMN, Qt::AscendingOrder);\r\n    view_.update();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ViewsEditor::showEvent()\r\n//-----------------------------------------------------------------------------\r\nvoid ViewsEditor::showEvent(QShowEvent* event)\r\n{\r\n\tQWidget::showEvent(event);\r\n\temit helpUrlRequested(\"componenteditor/views.html\");\r\n}\r\n"
  },
  {
    "path": "editors/ComponentEditor/views/viewseditor.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: viewseditor.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 12.06.2012\r\n//\r\n// Description:\r\n// The editor to add/remove/edit views of a component.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef VIEWSEDITOR_H\r\n#define VIEWSEDITOR_H\r\n\r\n#include \"viewsmodel.h\"\r\n\r\n#include <common/views/EditableTableView/editabletableview.h>\r\n\r\n#include <editors/ComponentEditor/itemeditor.h>\r\n\r\n#include <QSortFilterProxyModel>\r\n\r\nclass LibraryInterface;\r\nclass ViewValidator;\r\n//-----------------------------------------------------------------------------\r\n//! The editor to add/remove/edit views of a component.\r\n//-----------------------------------------------------------------------------\r\nclass ViewsEditor : public ItemEditor\r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\r\n\t/*!\r\n     *  The constructor.\r\n\t *\r\n\t *    @param [in] component       Pointer to the component being edited.\r\n\t *    @param [in] handler         Pointer to the instance managing the library.\r\n     *    @param [in] viewValidator   The validator used for views.\r\n\t *    @param [in] parent          Pointer to the parent of this editor.\r\n\t */\r\n\tViewsEditor(QSharedPointer<Component> component, LibraryInterface* handler,\r\n        QSharedPointer<ViewValidator> viewValidator, QWidget* parent = 0);\r\n\t\r\n\t//! The destructor.\r\n\tvirtual ~ViewsEditor();\r\n\r\n\t/*!\r\n     *  Reload the information from the model to the editor.\r\n\t */\r\n\tvirtual void refresh();\r\n\r\npublic slots:\r\n\r\n\t//! Called to update the view sorting when the model changes.\r\n    virtual void onItemChanged();\r\n\r\nprotected:\r\n\r\n\t//! Handler for widget's show event.\r\n\tvirtual void showEvent(QShowEvent* event);\r\n\r\nprivate:\r\n\r\n\t//! No copying.\r\n\tViewsEditor(const ViewsEditor& other);\r\n\r\n\t//! No assignment.\r\n\tViewsEditor& operator=(const ViewsEditor& other);\r\n\r\n\t//! The view to display the view info.\r\n\tEditableTableView view_;\r\n\r\n\t//! The proxy that does the sorting.\r\n\tQSortFilterProxyModel proxy_;\r\n\r\n\t//! The model to manage the views summary.\r\n\tViewsModel model_;\r\n};\r\n\r\n#endif // VIEWSEDITOR_H\r\n"
  },
  {
    "path": "editors/ComponentEditor/views/viewsmodel.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: viewsmodel.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 12.6.2012\r\n//\r\n// Description:\r\n// The model to manage the views summary.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"viewsmodel.h\"\r\n#include \"ViewColumns.h\"\r\n\r\n#include <QStringList>\r\n\r\n#include <QRegularExpression>\r\n\r\n#include <IPXACTmodels/Component/validators/ViewValidator.h>\r\n\r\n#include <common/KactusColors.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ViewsModel::ViewsModel()\r\n//-----------------------------------------------------------------------------\r\nViewsModel::ViewsModel(QSharedPointer<Component> component, QSharedPointer<ViewValidator> viewValidator,\r\n    QObject* parent):\r\nQAbstractTableModel(parent),\r\ncomponent_(component),\r\nviews_(component->getViews()),\r\nviewValidator_(viewValidator)\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ViewsModel::~ViewsModel()\r\n//-----------------------------------------------------------------------------\r\nViewsModel::~ViewsModel()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ViewsModel::rowCount()\r\n//-----------------------------------------------------------------------------\r\nint ViewsModel::rowCount(QModelIndex const& parent) const\r\n{\r\n\tif (parent.isValid())\r\n    {\r\n\t\treturn 0;\r\n\t}\r\n    return views_->size();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ViewsModel::columnCount()\r\n//-----------------------------------------------------------------------------\r\nint ViewsModel::columnCount(QModelIndex const& parent) const\r\n{\r\n\tif (parent.isValid())\r\n    {\r\n\t\treturn 0;\r\n\t}\r\n    return ViewColumns::COLUMN_COUNT;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ViewsModel::flags()\r\n//-----------------------------------------------------------------------------\r\nQt::ItemFlags ViewsModel::flags(QModelIndex const& index) const\r\n{\r\n\tif (!index.isValid())\r\n    {\r\n\t\treturn Qt::NoItemFlags;\r\n\t}\r\n\t// the type only displays the type of the view, it can not be edited.\r\n\telse if (index.column() == ViewColumns::TYPE_COLUMN)\r\n    {\r\n\t\treturn Qt::ItemIsSelectable | Qt::ItemIsEnabled;\r\n\t}\r\n\r\n\t// other columns can be edited\r\n\treturn Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsEditable;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ViewsModel::headerData()\r\n//-----------------------------------------------------------------------------\r\nQVariant ViewsModel::headerData(int section, Qt::Orientation orientation, int role) const\r\n{\r\n\tif (orientation != Qt::Horizontal)\r\n    {\r\n\t\treturn QVariant();\r\n    }\r\n\r\n    if (Qt::DisplayRole == role)\r\n    {\r\n        if (section == ViewColumns::NAME_COLUMN)\r\n        {\r\n            return tr(\"Name\");\r\n        }\r\n        else if (section == ViewColumns::TYPE_COLUMN)\r\n        {\r\n            return tr(\"View type\");\r\n        }\r\n        else if (section == ViewColumns::DESCRIPTION_COLUMN)\r\n        {\r\n            return tr(\"Description\");\r\n        }\r\n        else\r\n        {\r\n            return QVariant();\r\n        }\r\n    }\r\n    else\r\n    {\r\n        return QVariant();\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ViewsModel::data()\r\n//-----------------------------------------------------------------------------\r\nQVariant ViewsModel::data(QModelIndex const& index, int role) const\r\n{\r\n\tif (!index.isValid() || index.row() < 0 || index.row() >= views_->size())\r\n    {\r\n        return QVariant();\r\n    }\r\n\r\n    QSharedPointer<View> view = views_->at(index.row());\r\n\r\n    if (role == Qt::EditRole && index.column() == ViewColumns::DESCRIPTION_COLUMN)\r\n    {\r\n        return view->description();\r\n    }\r\n    else if (role == Qt::DisplayRole || role == Qt::EditRole)\r\n    {\r\n        if (index.column() == ViewColumns::NAME_COLUMN)\r\n        {\r\n            if (!view->name().isEmpty())\r\n            {\r\n                return views_->at(index.row())->name();\r\n            }\r\n            else\r\n            {\r\n                return \"unnamed\";\r\n            }\r\n        }\r\n        else if (index.column() == ViewColumns::TYPE_COLUMN)\r\n        {\r\n            if (view->isHierarchical())\r\n            {\r\n                return tr(\"hierarchical\");\r\n            }\r\n            else\r\n            {\r\n                return tr(\"non-hierarchical\");\r\n            }\r\n        }\r\n        else if (index.column() == ViewColumns::DESCRIPTION_COLUMN)\r\n        {\r\n            return view->description().replace(QRegularExpression(\"\\n.*$\", \r\n                QRegularExpression::DotMatchesEverythingOption), \"...\");\r\n        }\r\n        else\r\n        {\r\n            return QVariant();\r\n        }\r\n\t}   \r\n\telse if (role == Qt::ForegroundRole)\r\n    {\r\n        if (index.column() == ViewColumns::TYPE_COLUMN)\r\n        {\r\n            return KactusColors::DISABLED_TEXT;\r\n        }\r\n        else if (index.column() == ViewColumns::NAME_COLUMN && !viewValidator_->hasValidName(view->name()))\r\n        {\r\n            return KactusColors::ERROR;\r\n        }\r\n        else\r\n        {\r\n            return KactusColors::REGULAR_TEXT;\r\n        }\r\n\t}\r\n\telse if (role == Qt::BackgroundRole)\r\n    {\r\n        if (index.column() == ViewColumns::NAME_COLUMN)\r\n        {\r\n            return KactusColors::MANDATORY_FIELD;\r\n        }\r\n        else\r\n        {\r\n            return KactusColors::REGULAR_FIELD;\r\n        }\r\n    }\r\n    else \r\n    {\r\n\t\treturn QVariant();\r\n\t}\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ViewsModel::setData()\r\n//-----------------------------------------------------------------------------\r\nbool ViewsModel::setData(QModelIndex const& index, const QVariant& value, int role)\r\n{\r\n\tif (!index.isValid() || index.row() < 0 || index.row() >= views_->size())\r\n    {\r\n\t\treturn false;\r\n\t}\r\n\r\n    QSharedPointer<View> view = views_->at(index.row());\r\n\r\n\tif (role == Qt::EditRole)\r\n    {\r\n        if (index.column() == ViewColumns::NAME_COLUMN)\r\n        {\r\n            view->setName(value.toString());\r\n        }\r\n        else if (index.column() == ViewColumns::DESCRIPTION_COLUMN)\r\n        {\r\n            view->setDescription(value.toString());\r\n        }\r\n        // type is not edited directly, it is only shown\r\n        else\r\n        {\r\n            return false;\r\n        }\r\n\r\n\t\temit dataChanged(index, index);\r\n\t\temit contentChanged();\r\n\t\treturn true;\r\n\t}\r\n\telse \r\n    {\r\n\t\treturn false;\r\n\t}\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ViewsModel::onAddItem()\r\n//-----------------------------------------------------------------------------\r\nvoid ViewsModel::onAddItem(QModelIndex const& index)\r\n{\r\n\tint row = views_->size();\r\n\r\n\t// if the index is valid then add the item to the correct position\r\n\tif (index.isValid())\r\n    {\r\n\t\trow = index.row();\r\n\t}\r\n\r\n\tbeginInsertRows(QModelIndex(), row, row);\r\n\tviews_->insert(row, QSharedPointer<View>(new View()));\r\n\tendInsertRows();\r\n\r\n\t// inform navigation tree that file set is added\r\n\temit viewAdded(row);\r\n\r\n\t// tell also parent widget that contents have been changed\r\n\temit contentChanged();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ViewsModel::onRemoveItem()\r\n//-----------------------------------------------------------------------------\r\nvoid ViewsModel::onRemoveItem(QModelIndex const& index)\r\n{\r\n\t// don't remove anything if index is invalid\r\n\tif (!index.isValid() || index.row() < 0 || index.row() >= views_->size())\r\n    {\r\n\t\treturn;\r\n\t}\r\n\r\n\t// remove the specified item\r\n\tbeginRemoveRows(QModelIndex(), index.row(), index.row());\r\n\tviews_->removeAt(index.row());\r\n\tendRemoveRows();\r\n\r\n\t// inform navigation tree that file set has been removed\r\n\temit viewRemoved(index.row());\r\n\r\n\t// tell also parent widget that contents have been changed\r\n\temit contentChanged();\r\n}\r\n"
  },
  {
    "path": "editors/ComponentEditor/views/viewsmodel.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: viewsmodel.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 12.6.2012\r\n//\r\n// Description:\r\n// The model to manage the views summary.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef VIEWSMODEL_H\r\n#define VIEWSMODEL_H\r\n\r\n#include <IPXACTmodels/Component/Component.h>\r\n#include <IPXACTmodels/Component/View.h>\r\n\r\n#include <QAbstractTableModel>\r\n#include <QList>\r\n#include <QSharedPointer>\r\n\r\nclass ViewValidator;\r\n//-----------------------------------------------------------------------------\r\n//! The model to manage the views summary.\r\n//-----------------------------------------------------------------------------\r\nclass ViewsModel : public QAbstractTableModel\r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\r\n\t/*!\r\n     *  The constructor.\r\n\t *\r\n\t *    @param [in] component       Pointer to the component being edited.\r\n     *    @param [in] viewValidator   The validator used for views.\r\n\t *    @param [in] parent          Pointer to the owner of the model.\r\n\t */\r\n\tViewsModel(QSharedPointer<Component> component, QSharedPointer<ViewValidator> viewValidator, QObject* parent);\r\n\t\r\n\t//! The destructor.\r\n\tvirtual ~ViewsModel();\r\n\r\n\t/*!\r\n     *  Get the number of rows an item contains.\r\n\t *\r\n\t *    @param [in] parent  Identifies the parent that's row count is requested.\r\n\t *\r\n\t *    @return Number of rows the item has.\r\n\t */\r\n\tvirtual int rowCount(QModelIndex const& parent = QModelIndex()) const;\r\n\r\n\t/*!\r\n     *  Get the number of columns the item has to be displayed.\r\n\t *\r\n\t *    @param [in] parent  Identifies the parent that's column count is requested.\r\n\t *\r\n\t *    @return The number of columns to be displayed.\r\n\t */\r\n\tvirtual int columnCount(QModelIndex const& parent = QModelIndex()) const;\r\n\r\n\t/*!\r\n     *  Get the item flags that defines the possible operations for the item.\r\n\t *\r\n\t *    @param [in] index   Model index that identifies the item.\r\n\t *\r\n\t *    @return Qt::ItemFlags specify the possible operations for the item.\r\n\t */\r\n\tQt::ItemFlags flags(QModelIndex const& index) const;\r\n\r\n\t/*!\r\n     *  Get the header data for specified header.\r\n\t *\r\n\t *    @param [in] section         The section specifies the row/column number for the header.\r\n\t *    @param [in] orientation     Specified if horizontal or vertical header is wanted.\r\n\t *    @param [in] role            Specifies the type of the requested data.\r\n\t *\r\n\t *    @return QVariant Contains the requested data.\r\n\t */\r\n\tvirtual QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;\r\n\r\n\t/*!\r\n     *  Get the data for specified item.\r\n\t *\r\n\t *    @param [in] index   Specifies the item that's data is requested.\r\n\t *    @param [in] role    The role that defines what kind of data is requested.\r\n\t *\r\n\t *    @return QVariant Contains the data for the item.\r\n\t */\r\n\tvirtual QVariant data(QModelIndex const& index, int role = Qt::DisplayRole) const;\r\n\r\n\t/*!\r\n     *  Save the data to the model for specified item.\r\n\t *\r\n\t *    @param [in] index   The model index of the item that's data is to be saved.\r\n\t *    @param [in] value   The data that is to be saved.\r\n\t *    @param [in] role    The role specifies what kind of data should be saved.\r\n\t *\r\n\t *    @return True if saving happened successfully.\r\n\t */\r\n\tbool setData(QModelIndex const& index, const QVariant& value, int role = Qt::EditRole);\r\n\r\n\t/*!\r\n     *  Check if the views model is in a valid state.\r\n\t *\r\n\t *    @return bool True if the state is valid and writing is possible.\r\n\t */\r\n\tbool isValid() const;\r\n\r\npublic slots:\r\n\r\n\t/*!\r\n     *  Add a new item to the given index.\r\n\t *\r\n\t *    @param [in] index   The index identifying the position for new item.\r\n\t */\r\n\tvirtual void onAddItem(QModelIndex const& index);\r\n\r\n\t/*!\r\n     *  Remove the item in the given index.\r\n\t *\r\n\t *    @param [in] index   The index identifying the item to remove.\r\n\t */\r\n\tvirtual void onRemoveItem(QModelIndex const& index);\r\n\r\nsignals:\r\n\r\n\t//! Emitted when the contents of the model change.\r\n\tvoid contentChanged();\r\n\r\n\t//! Emitted when a new view is added to the given index.\r\n\tvoid viewAdded(int index);\r\n\r\n\t//! Emitted when a view is removed from the given index.\r\n\tvoid viewRemoved(int index);\r\n\r\nprivate:\r\n\t//! No copying.\r\n\tViewsModel(const ViewsModel& other);\r\n\tViewsModel& operator=(const ViewsModel& other);\r\n\r\n\t//! Pointer to the component being edited.\r\n\tQSharedPointer<Component> component_;\r\n\r\n\t//! Contains the views to manage.\r\n    QSharedPointer<QList<QSharedPointer<View> > > views_;\r\n\r\n    //! The validator used for views.\r\n    QSharedPointer<ViewValidator> viewValidator_;\r\n};\r\n\r\n#endif // VIEWSMODEL_H\r\n"
  },
  {
    "path": "editors/ComponentEditor/visualization/AddressableItem.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: AddressableItem.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Esko Pekkarinen\n// Date: 11.10.2023\n//\n// Description:\n// Common base class for address space and memory map visualization items.\n//-----------------------------------------------------------------------------\n\n#include \"AddressableItem.h\"\n#include \"memorygapitem.h\"\n\n#include <common/KactusColors.h>\n\n#include <KactusAPI/include/ExpressionParser.h>\n\n#include <QRectF>\n#include <QPen>\n\n//-----------------------------------------------------------------------------\n// Function: AddressableItem::AddressableItem()\n//-----------------------------------------------------------------------------\nAddressableItem::AddressableItem(QGraphicsItem* parent):\nVisualizerItem(parent)\n{\n    setPen(QPen(Qt::gray));\n}\n\n//-----------------------------------------------------------------------------\n// Function: AddressableItem::setDisplayOffset()\n//-----------------------------------------------------------------------------\nvoid AddressableItem::setDisplayOffset(quint64 const& address)\n{\n    firstAddress_ = address;\n    setTopLabelText(firstAddress_);\n}\n\n//-----------------------------------------------------------------------------\n// Function: AddressableItem::getDisplayOffset()\n//-----------------------------------------------------------------------------\nquint64 AddressableItem::getDisplayOffset()\n{\n    return firstAddress_;\n}\n\n//-----------------------------------------------------------------------------\n// Function: AddressableItem::setDisplayLastAddress()\n//-----------------------------------------------------------------------------\nvoid AddressableItem::setDisplayLastAddress(quint64 const& address)\n{\n    lastAddress_ = address;\n\n    if (firstAddress_ != lastAddress_)\n    {\n        setBottomLabelText(lastAddress_);\n    }\n    else\n    {\n        VisualizerItem::setBottomLabelText(QString());\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: AddressableItem::getDisplayLastAddress()\n//-----------------------------------------------------------------------------\nquint64 AddressableItem::getDisplayLastAddress()\n{\n    return lastAddress_;\n}\n\n//-----------------------------------------------------------------------------\n// Function: AddressableItem::setConflicted()\n//-----------------------------------------------------------------------------\nvoid AddressableItem::setConflicted(bool conflicted)\n{\n    conflicted_ = conflicted;\n\n    QBrush colorBrush = defaultBrush();\n    if (conflicted)\n    {\n        colorBrush = KactusColors::MISSING_COMPONENT;\n    }\n\n    setBrush(colorBrush);\n}\n\n//-----------------------------------------------------------------------------\n// Function: AddressableItem::isConflicted()\n//-----------------------------------------------------------------------------\nbool AddressableItem::isConflicted() const\n{\n    return conflicted_;\n}\n\n//-----------------------------------------------------------------------------\n// Function: AddressableItem::setLeftTopCorner()\n//-----------------------------------------------------------------------------\nvoid AddressableItem::setTopLabelText(quint64 address)\n{\n    VisualizerItem::setTopLabelText(toHexString(address, getBitWidth()));\n}\n\n//-----------------------------------------------------------------------------\n// Function: AddressableItem::setLeftBottomCorner()\n//-----------------------------------------------------------------------------\nvoid AddressableItem::setBottomLabelText(quint64 address)\n{\n    VisualizerItem::setBottomLabelText(toHexString(address, getBitWidth()));\n}\n\n//-----------------------------------------------------------------------------\n// Function: AddressableItem::toHexString()\n//-----------------------------------------------------------------------------\nQString AddressableItem::toHexString(quint64 address, int bitWidth)\n{\n    QString str = QString::number(address, 16);\n    str = str.toUpper();\n\n    // one hexadecimal number accounts for four bits\n    int fieldSize = bitWidth / 4;\n    if (fieldSize * 4 < bitWidth)\n    {\n        fieldSize++; //Round upwards, e.g. 7 bits needs 4 hex digits\n    }\n\n    QString padded = QString(\"%1\").arg(str, fieldSize, QLatin1Char('0'));\n    int size = padded.size();\n    for (int i = size; i > 0; i -= 4)\n    {\n        padded.insert(i, QLatin1Char(' '));\n    }\n\n    return padded;\n}\n\n//-----------------------------------------------------------------------------\n// Function: AddressableItem::compareItems()\n//-----------------------------------------------------------------------------\nbool AddressableItem::compareItems(const AddressableItem* s1, const AddressableItem* s2)\n{\n    // Item with bigger last address precedes the other.\n    return s1->getLastAddress() > s2->getLastAddress();\n}\n"
  },
  {
    "path": "editors/ComponentEditor/visualization/AddressableItem.h",
    "content": "//-----------------------------------------------------------------------------\n// File: AddressableItem.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Esko Pekkarinen\n// Date: 11.10.2023\n//\n// Description:\n// Common base class for address space and memory map visualization items.\n//-----------------------------------------------------------------------------\n\n#ifndef ADDRESSABLE_ITEM_H\n#define ADDRESSABLE_ITEM_H\n\n#include <common/graphicsItems/visualizeritem.h>\n\n#include <QMultiMap>\n\n//-----------------------------------------------------------------------------\n//! Common base class for address space and memory map visualization items.\n//-----------------------------------------------------------------------------\nclass AddressableItem : public VisualizerItem\n{\n\tQ_OBJECT\n\npublic:\n\n\t/*!\n     *  The constructor.\n\t *\n\t *    @param [in] parent              The owner of the item.\n\t */\n\tAddressableItem(QGraphicsItem* parent = nullptr);\n\t\n    //! The destructor.\n\tvirtual ~AddressableItem() = default;\n    \n    //! No copying.\n    AddressableItem(const AddressableItem& other) = delete;\n    AddressableItem& operator=(const AddressableItem& other) = delete;\n\n    //! Refresh the item.\n\tvirtual void refresh() {};\n\n\t/*!\n     *  Get the offset of the item. \n\t *\n\t *    @return The offset of the item from the parent item's base address.\n\t */\n\tvirtual quint64 getOffset() const = 0;\n\n\t/*!\n     *  Get the last address contained in the item.\n\t *\n\t *    @return The last address.\n\t */\n\tvirtual quint64 getLastAddress() const = 0;\n\n\t/*!\n     *  Get the bit width of the item.\n\t * \n\t *    @return The bit width of the item.\n\t */\n\tvirtual int getBitWidth() const = 0;\n\n\t/*!\n     *  Get number of bits the addressable unit contains.\n\t *\n\t *    @return The size of least addressable unit.\n\t */\n\t//virtual unsigned int getAddressUnitSize() const = 0;\n\n\t/*!\n     *  Sets the first non-overlapping address to display.\n\t *\n\t *    @param [in] The first address to set.\n\t */\n    virtual void setDisplayOffset(quint64 const& address);\n\n\t/*!\n     *  Get the first non-overlapping address of the item.\n\t *\n\t *    @return The first non-overlapping address.\n\t */\n    virtual quint64 getDisplayOffset();\n\n\t/*!\n     *  Sets the last non-overlapping address to display.\n\t *\n\t *    @param [in] The last address to set.\n\t */\n    virtual void setDisplayLastAddress(quint64 const& address);\n\n    /*!\n     *  Get the last non-overlapping address of the item.\n     *\n     *    @return The last non-overlapping address.\n     */\n    virtual quint64 getDisplayLastAddress();\n\n    //! Set the item into conflicted (overlapping memory) state.\n    virtual void setConflicted(bool conflicted);\n\n    /*!\n     *  Checks if the item is conflicted (overlapping with others).\n     *\n     *    @return True, if the item is conflicted, otherwise false.\n     */\n    bool isConflicted() const;\n\nprotected:\n\n\t/*!\n     *  Set the address to be shown on the top left corner.\n\t *\n\t *    @param [in] address The address to be shown in hexadecimal form.\n\t */\n\t void setTopLabelText(quint64 address);\n\n\t/*!\n     *  Set the address to be shown on the bottom left corner.\n\t *\n\t *    @param [in] address The address to be shown in hexadecimal form.\n\t */\n\t void setBottomLabelText(quint64 address);\n\n\t/*!\n\t *  Converts an address to hexadecimal string.\n\t *\n     *    @param [in] address   The address to convert.\n     *    @param [in] bitWidth  The number of bits used in the representation.\n\t *\n\t *    @return The hexadecimal representation.\n\t */\n\tstatic QString toHexString(quint64 address, int bitWidth);\n\n    //! comparison function for two equal offsets.\n    static bool compareItems(const AddressableItem* s1, const AddressableItem* s2);\n\n    //! The first address of the item.\n    quint64 firstAddress_ = 0;\n\n    //! The last address of the item.\n    quint64 lastAddress_ = 0;\n\nprivate:\n    \n    //-----------------------------------------------------------------------------\n    // Data.\n    //-----------------------------------------------------------------------------\n\n\t//! Conflicted state. Item is conflicted if it overlaps with other items.\n    bool conflicted_ = false;\n\n};\n\n#endif // MEMORYVISUALIZATIONITEM_H\n"
  },
  {
    "path": "editors/ComponentEditor/visualization/fieldgapitem.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: fieldgapitem.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 30.11.2012\r\n//\r\n// Description:\r\n// The graphical item that represents a gap between fields.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"fieldgapitem.h\"\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FieldGapItem()\r\n//-----------------------------------------------------------------------------\r\nFieldGapItem::FieldGapItem(QString const& name, QSharedPointer<ExpressionParser> expressionParser,\r\n    QGraphicsItem* parent):\r\nMemoryGapItem(expressionParser, parent)\r\n{\r\n    // fields show name in the middle\r\n    setLayoutType(LABELS_TOP);\r\n    setClipText(true);\r\n\r\n    setName(name);\r\n\r\n    // fields can never be expanded\r\n    setExpansionRectVisible(false);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: updateDisplay()\r\n//-----------------------------------------------------------------------------\r\nvoid FieldGapItem::updateDisplay()\r\n{\r\n\tQString startStr = QString::number(firstAddress_);\r\n    VisualizerItem::setBottomLabelText(startStr);\r\n\r\n\tQString endStr = QString::number(lastAddress_);\r\n    VisualizerItem::setTopLabelText(endStr);\r\n    setToolTip(\"<b>\" + name() + \"</b> [\" + endStr + \"..\" + startStr + \"]\");\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: getBitWidth()\r\n//-----------------------------------------------------------------------------\r\nint FieldGapItem::getBitWidth() const\r\n{\r\n\treturn lastAddress_ - firstAddress_ + 1;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: itemTotalWidth()\r\n//-----------------------------------------------------------------------------\r\nqreal FieldGapItem::itemTotalWidth() const\r\n{\r\n\treturn rect().width();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FieldGapItem::setConflicted()\r\n//-----------------------------------------------------------------------------\r\nvoid FieldGapItem::setConflicted(bool /*conflicted*/)\r\n{\r\n    // Do nothing.\r\n}\r\n"
  },
  {
    "path": "editors/ComponentEditor/visualization/fieldgapitem.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: fieldgapitem.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 30.11.2012\r\n//\r\n// Description:\r\n// The graphical item that represents a gap between fields.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef FIELDGAPITEM_H\r\n#define FIELDGAPITEM_H\r\n\r\n#include <editors/ComponentEditor/visualization/memorygapitem.h>\r\n\r\n#include <QGraphicsItem>\r\n\r\nclass ExpressionParser;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! The graphical item that represents a gap between fields.\r\n//-----------------------------------------------------------------------------\r\nclass FieldGapItem : public MemoryGapItem\r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\r\n\t/*!\r\n     *  The constructor.\r\n\t *\r\n     *    @param [in] name    Name to display for the gap item.\r\n\t *    @param [in] parent  The parent graphics item.\r\n\t */\r\n\tFieldGapItem(QString const& name, QSharedPointer<ExpressionParser> expressionParser, QGraphicsItem* parent);\r\n\r\n\t//! The destructor.\r\n\tvirtual ~FieldGapItem() = default;\r\n\r\n    //! No copying.\r\n    FieldGapItem(const FieldGapItem& other) = delete;\r\n\r\n    //! No assignment.\r\n    FieldGapItem& operator=(const FieldGapItem& other) = delete;\r\n\r\n\t//! Refresh the gap item.\r\n\tvirtual void updateDisplay() override final;\r\n\r\n\t/*!\r\n     *  Get the bit width of the item.\r\n\t * \r\n\t *    @return The bit width of the item.\r\n\t */\r\n\tvirtual int getBitWidth() const override final;\r\n\r\n\t/*!\r\n     *  Get the width of the item.\r\n\t *\r\n\t *    @return The width of the gap item.\r\n\t */\r\n\tvirtual qreal itemTotalWidth() const override final;\r\n\r\n    //! Set the item into conflicted (overlapping memory) state.\r\n    virtual void setConflicted(bool conflicted) override final;\r\n\r\n};\r\n\r\n#endif // FIELDGAPITEM_H\r\n"
  },
  {
    "path": "editors/ComponentEditor/visualization/memorygapitem.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: memorygapitem.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 20.11.2012\r\n//\r\n// Description:\r\n// The graphical item that represents a gap in the memory between objects.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"memorygapitem.h\"\r\n\r\n#include <editors/ComponentEditor/memoryMaps/memoryMapsVisualizer/memorymapgraphitem.h>\r\n\r\n#include <QBrush>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryGapItem()\r\n//-----------------------------------------------------------------------------\r\nMemoryGapItem::MemoryGapItem(QSharedPointer<ExpressionParser> expressionParser, QGraphicsItem* parent):\r\nMemoryVisualizationItem(expressionParser, parent)\r\n{\r\n\tsetDefaultBrush(QBrush(QColor(Qt::white)));\r\n\r\n    setShowExpandableItem(false);\r\n\r\n\tsetName(QStringLiteral(\"Reserved\"));\r\n    setToolTip(\"This memory block is reserved for future use.\");\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryGapItem::updateDisplay()\r\n//-----------------------------------------------------------------------------\r\nvoid MemoryGapItem::updateDisplay()\r\n{\r\n    // Nothing to do.\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryGapItem::getOffset()\r\n//-----------------------------------------------------------------------------\r\nquint64 MemoryGapItem::getOffset() const\r\n{\r\n\treturn firstAddress_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryGapItem::getLastAddress()\r\n//-----------------------------------------------------------------------------\r\nquint64 MemoryGapItem::getLastAddress() const\r\n{\r\n    return lastAddress_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryGapItem::getBitWidth()\r\n//-----------------------------------------------------------------------------\r\nint MemoryGapItem::getBitWidth() const\r\n{\r\n\tauto memItem = static_cast<MemoryVisualizationItem const*>(parentItem());\r\n\tQ_ASSERT(memItem);\r\n\treturn memItem->getBitWidth();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryGapItem::getAddressUnitSize()\r\n//-----------------------------------------------------------------------------\r\nunsigned int MemoryGapItem::getAddressUnitSize() const\r\n{\r\n\tauto memItem = static_cast<MemoryVisualizationItem const*>(parentItem());\r\n\tQ_ASSERT(memItem);\r\n\treturn memItem->getAddressUnitSize();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryGapItem::redoChildLayout()\r\n//-----------------------------------------------------------------------------\r\nvoid MemoryGapItem::redoChildLayout()\r\n{\r\n    // Do nothing. Gaps do not have child items.\r\n}\r\n"
  },
  {
    "path": "editors/ComponentEditor/visualization/memorygapitem.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: memorygapitem.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 20.11.2012\r\n//\r\n// Description:\r\n// The graphical item that represents a gap in the memory between objects.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef MEMORYGAPITEM_H\r\n#define MEMORYGAPITEM_H\r\n\r\n#include \"memoryvisualizationitem.h\"\r\n\r\nclass ExpressionParser;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! The graphical item that represents a gap in the memory between objects.\r\n//-----------------------------------------------------------------------------\r\nclass MemoryGapItem : public MemoryVisualizationItem\r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\r\n\t/*!\r\n     *  The constructor.\r\n\t *\r\n\t *    @param [in] parent  Pointer to the parent of the gap item.\r\n\t */\r\n\tMemoryGapItem(QSharedPointer<ExpressionParser> expressionParser, QGraphicsItem* parent);\r\n\t\r\n\t//! The destructor.\r\n\tvirtual ~MemoryGapItem() = default;\r\n\r\n    //! No copying.\r\n    MemoryGapItem(const MemoryGapItem& other) = delete;\r\n\r\n    //! No assignment.\r\n    MemoryGapItem& operator=(const MemoryGapItem& other) = delete;\r\n\r\n    //! Updates the labels and tooltip for the item.\r\n    void updateDisplay() override;\r\n\r\n\t/*!\r\n     *  Get the offset of the item. \r\n\t *\r\n\t *    @return int The offset of the item from the parent item's base address.\r\n\t */\r\n\tquint64 getOffset() const override;\r\n\r\n\t/*!\r\n     *  Get the last address contained in the gap.\r\n\t *\r\n\t *    @return The last address.\r\n\t */\r\n\tquint64 getLastAddress() const override;\r\n\r\n\t/*!\r\n     *  Get the bit width of the item.\r\n\t * \r\n\t *    @return The bit width of the item.\r\n\t */\r\n\tint getBitWidth() const override;\r\n\r\n\t/*!\r\n     *  Get number of bits the addressable unit contains.\r\n\t *\r\n\t *    @return The size of least addressable unit.\r\n\t */\r\n\tunsigned int getAddressUnitSize() const override;\r\n\r\n    //! Re-layouts the child items.\r\n    void redoChildLayout() override final;\r\n};\r\n\r\n#endif // MEMORYGAPITEM_H\r\n"
  },
  {
    "path": "editors/ComponentEditor/visualization/memoryvisualizationitem.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: memoryvisualizationitem.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 15.10.2012\r\n//\r\n// Description:\r\n// A base class for graphics items to visualize memory objects.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"memoryvisualizationitem.h\"\r\n#include \"memorygapitem.h\"\r\n\r\n#include <common/KactusColors.h>\r\n\r\n#include <KactusAPI/include/ExpressionParser.h>\r\n\r\n#include <QRectF>\r\n#include <QPen>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryVisualizationItem::MemoryVisualizationItem()\r\n//-----------------------------------------------------------------------------\r\nMemoryVisualizationItem::MemoryVisualizationItem(QSharedPointer<ExpressionParser> expressionParser,\r\n    QGraphicsItem* parent):\r\nExpandableItem(parent),\r\n    expressionParser_(expressionParser)\r\n{\r\n    QPen pen(Qt::gray);\r\n    setPen(pen);\r\n    setExpansionPen(pen);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryVisualizationItem::itemTotalRect()\r\n//-----------------------------------------------------------------------------\r\nQRectF MemoryVisualizationItem::itemTotalRect() const\r\n{    \r\n    QRectF totalRect(rect());\r\n\r\n    // The rectangle must contain this item and also the child item.\r\n    for (auto const& child : childItems_)\r\n    {   \r\n        if (child->isVisible())\r\n        {\r\n            totalRect = totalRect.united(mapRectFromItem(child, child->itemTotalRect()));\r\n        }        \r\n    }\r\n\r\n    return totalRect;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryVisualizationItem::addChild()\r\n//-----------------------------------------------------------------------------\r\nvoid MemoryVisualizationItem::addChild(MemoryVisualizationItem* childItem)\r\n{\r\n    childItems_.insert(childItem->getOffset(), childItem);\r\n\r\n    childItem->setWidth(childWidth_);\r\n    childItem->setVisible(isExpanded());\r\n\r\n    connect(childItem, SIGNAL(expandStateChanged()), this, SLOT(repositionChildren()), Qt::UniqueConnection);\r\n    connect(childItem, SIGNAL(expandStateChanged()), this, SIGNAL(expandStateChanged()), Qt::UniqueConnection);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryVisualizationItem::removeChild()\r\n//-----------------------------------------------------------------------------\r\nvoid MemoryVisualizationItem::removeChild(MemoryVisualizationItem* childItem)\r\n{\r\n    quint64 offset = childItems_.key(childItem);\r\n\r\n    Q_ASSERT(childItems_.contains(offset));\r\n    childItems_.remove(offset, childItem);\r\n\r\n    disconnect(childItem, SIGNAL(expandStateChanged()), this, SLOT(repositionChildren()));\r\n    disconnect(childItem, SIGNAL(expandStateChanged()), this, SIGNAL(expandStateChanged()));\r\n\r\n    showExpandIconIfHasChildren();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryVisualizationItem::getChildCount()\r\n//-----------------------------------------------------------------------------\r\nint MemoryVisualizationItem::getChildCount() const\r\n{\r\n    return childItems_.count();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryVisualizationItem::setWidth()\r\n//-----------------------------------------------------------------------------\r\nvoid MemoryVisualizationItem::setWidth(qreal width)\r\n{\r\n    qreal newChildWidth = width - MemoryVisualizationItem::CHILD_INDENTATION;\r\n\r\n    if (childWidth_ != newChildWidth)\r\n    {\r\n        childWidth_ = newChildWidth;\r\n\r\n        VisualizerItem::setWidth(width);\r\n        \r\n        for (auto& child : childItems_)\r\n        {\r\n            child->setWidth(childWidth_);\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryVisualizationItem::boundingRect()\r\n//-----------------------------------------------------------------------------\r\nQRectF MemoryVisualizationItem::boundingRect() const\r\n{\r\n    return itemTotalRect();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryVisualizationItem::redoChildLayout()\r\n//-----------------------------------------------------------------------------\r\nvoid MemoryVisualizationItem::redoChildLayout()\r\n{    \r\n    updateChildMap();\r\n\r\n    repositionChildren();\r\n\r\n    showExpandIconIfHasChildren();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: memoryvisualizationitem::parseExpression()\r\n//-----------------------------------------------------------------------------\r\nquint64 MemoryVisualizationItem::parseExpression(QString const& expression) const\r\n{\r\n    return expressionParser_->parseExpression(expression).toULongLong();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: memoryvisualizationitem::getExpressionParser()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<ExpressionParser> MemoryVisualizationItem::getExpressionParser() const\r\n{\r\n    return expressionParser_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryVisualizationItem::showExpandIconIfHasChildren()\r\n//-----------------------------------------------------------------------------\r\nvoid MemoryVisualizationItem::showExpandIconIfHasChildren()\r\n{    \r\n    ExpandableItem::setShowExpandableItem(childItems_.isEmpty() == false);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryVisualizationItem::updateChildMap()\r\n//-----------------------------------------------------------------------------\r\nvoid MemoryVisualizationItem::updateChildMap()\r\n{\r\n    removeGapsAndSortChildren();\r\n   \r\n    fillGapsBetweenChildren();\r\n\r\n    markConflictingChildren();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryVisualizationItem::removeGapsAndSortChildren()\r\n//-----------------------------------------------------------------------------\r\nvoid MemoryVisualizationItem::removeGapsAndSortChildren()\r\n{\r\n    QMultiMap<quint64, MemoryVisualizationItem*> updatedMap;\r\n\r\n    for (auto item = childItems_.cbegin(); item != childItems_.cend(); ++item)\r\n    {\r\n        if (auto gap = dynamic_cast<MemoryGapItem*>(*item))\r\n        {\r\n            delete gap;\r\n        }\r\n        else\r\n        {\r\n            updatedMap.insert((*item)->getOffset(), *item);\r\n        }\r\n    }\r\n\r\n    // Sort childs with same offset for stable order.\r\n    for (auto const& offset : updatedMap.uniqueKeys())\r\n    {\r\n        if (updatedMap.count(offset) != 1)\r\n        {\r\n            auto childs = updatedMap.values(offset);\r\n            updatedMap.remove(offset);\r\n\r\n            std::stable_sort(childs.begin(), childs.end(), compareItems);\r\n            for (auto& child : childs)\r\n            {\r\n                updatedMap.insert(offset, child);\r\n            }\r\n        }\r\n    }\r\n\r\n    childItems_ = updatedMap;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryVisualizationItem::fillGapsBetweenChildren()\r\n//-----------------------------------------------------------------------------\r\nvoid MemoryVisualizationItem::fillGapsBetweenChildren()\r\n{\r\n    quint64 lastAddressInUse = getOffset();\r\n\r\n    for (auto i = childItems_.begin(); i != childItems_.end(); ++i)\r\n    {\r\n        if (auto current = i.value(); current->isPresent())\r\n        {\r\n            if (quint64 currentOffset = childItems_.key(current); \r\n                lastAddressInUse == 0 && currentOffset > 0 && i == childItems_.begin())\r\n            {\r\n                i = createMemoryGap(0, currentOffset - 1);\r\n                lastAddressInUse = currentOffset - 1;\r\n            }\r\n            else if (emptySpaceBeforeChild(current, lastAddressInUse))\r\n            {\r\n                i = createMemoryGap(lastAddressInUse + 1, currentOffset - 1);\r\n            }\r\n\r\n            lastAddressInUse = qMax(current->getLastAddress(), lastAddressInUse);\r\n        }\r\n    }\r\n\r\n    // Fill in any addresses left between children and the end of this item.\r\n    if (childItems_.isEmpty() == false && getLastAddress() > lastAddressInUse)\r\n    {\r\n        createMemoryGap(lastAddressInUse + 1, getLastAddress());\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryVisualizationItem::markConflictingChildren()\r\n//-----------------------------------------------------------------------------\r\nvoid MemoryVisualizationItem::markConflictingChildren()\r\n{\r\n    for (auto child = childItems_.begin(); child != childItems_.end(); ++child)\r\n    {\r\n        markChildIfConflicting(child.value());\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryVisualizationItem::markChildIfConflicting()\r\n//-----------------------------------------------------------------------------\r\nvoid MemoryVisualizationItem::markChildIfConflicting(MemoryVisualizationItem* child)\r\n{\r\n    if (!child || !child->isPresent())\r\n    {\r\n        return;\r\n    }\r\n\r\n    auto parentOffset = getOffset();\r\n    auto lastAddress = getLastAddress();\r\n\r\n    auto const& currentChildOffset = child->getOffset();\r\n\r\n    bool isOutsideBounds = currentChildOffset < parentOffset || child->getLastAddress() > lastAddress;\r\n\r\n    child->setConflicted(isOutsideBounds);\r\n\r\n    // Check overlap with preceding children. Mark any overlapping items conflicted.\r\n    for (auto precedingChild = childItems_.begin(); precedingChild.value() != child; ++precedingChild)\r\n    {\r\n        if ((*precedingChild)->getLastAddress() >= currentChildOffset)\r\n        {\r\n            (*precedingChild)->setConflicted(true);\r\n            child->setConflicted(true);\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryVisualizationItem::repositionChildren()\r\n//-----------------------------------------------------------------------------\r\nvoid MemoryVisualizationItem::repositionChildren()\r\n{\r\n    qreal yCoordinate = rect().bottom();\r\n    \r\n    bool parentExpanded = isExpanded();\r\n    for (auto& current : childItems_)\r\n    {\r\n        bool present = current->isPresent();\r\n        current->setVisible(present && parentExpanded);\r\n\r\n        if (present)\r\n        {\r\n            current->setPos(MemoryVisualizationItem::CHILD_INDENTATION, yCoordinate);\r\n            yCoordinate = mapRectFromItem(current, current->itemTotalRect()).bottom();\r\n        }\r\n    }\r\n\r\n    resizeToContent();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryVisualizationItem::mousePressEvent()\r\n//-----------------------------------------------------------------------------\r\nvoid MemoryVisualizationItem::mousePressEvent(QGraphicsSceneMouseEvent* event)\r\n{\r\n    QGraphicsItem::mousePressEvent(event);\r\n    emit selectEditor();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryVisualizationItem::emptySpaceBeforeChild()\r\n//-----------------------------------------------------------------------------\r\nbool MemoryVisualizationItem::emptySpaceBeforeChild(MemoryVisualizationItem const* current,\r\n    quint64 lastAddressInUse) const\r\n{    \r\n    return current->getOffset() > lastAddressInUse + 1;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryVisualizationItem::createMemoryGap()\r\n//-----------------------------------------------------------------------------\r\nQMultiMap<quint64, MemoryVisualizationItem*>::iterator MemoryVisualizationItem::createMemoryGap(quint64 startAddress,\r\n    quint64 endAddress)\r\n{\r\n    auto gap = new MemoryGapItem(expressionParser_, this);\r\n    gap->setWidth(childWidth_);\r\n    gap->setDisplayOffset(startAddress);\r\n    gap->setDisplayLastAddress(endAddress);    \r\n    gap->repositionLabels();\r\n\r\n    return childItems_.insert(gap->getOffset(), gap);\r\n}\r\n"
  },
  {
    "path": "editors/ComponentEditor/visualization/memoryvisualizationitem.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: memoryvisualizationitem.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 15.10.2012\r\n//\r\n// Description:\r\n// A base class for graphics items to visualize memory objects\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef MEMORYVISUALIZATIONITEM_H\r\n#define MEMORYVISUALIZATIONITEM_H\r\n\r\n#include <common/graphicsItems/expandableitem.h>\r\n#include <common/graphicsItems/graphicsexpandcollapseitem.h>\r\n\r\n#include <QMultiMap>\r\n#include <QGraphicsSceneMouseEvent>\r\n\r\nclass MemoryGapItem;\r\nclass ExpressionParser;\r\n//-----------------------------------------------------------------------------\r\n//! A base class for graphics items to visualize memory objects.\r\n//-----------------------------------------------------------------------------\r\nclass MemoryVisualizationItem : public ExpandableItem\r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\r\n\t//! The indentation of each child under its parent.\r\n\tenum Indentation \r\n    {\r\n\t\tCHILD_INDENTATION = GraphicsExpandCollapseItem::SIDE\r\n\t};\r\n\r\n\t/*!\r\n     *  The constructor.\r\n\t *\r\n     *    @param [in] expressionParser    The used expression parser.\r\n\t *    @param [in] parent              The owner of the item.\r\n\t */\r\n\tMemoryVisualizationItem(QSharedPointer<ExpressionParser> expressionParser, QGraphicsItem* parent = 0);\r\n\t\r\n   \r\n    //! The destructor.\r\n\tvirtual ~MemoryVisualizationItem() = default;\r\n    \r\n    virtual  QRectF itemTotalRect() const override final;\r\n\r\n    //! No copying.\r\n    MemoryVisualizationItem(const MemoryVisualizationItem& other) = delete;\r\n    MemoryVisualizationItem& operator=(const MemoryVisualizationItem& other) = delete;\r\n\r\n    //! Updates the labels and tooltip for the item.\r\n    virtual void updateDisplay() = 0;\r\n\r\n\t/*!\r\n     *  Get the offset of the item. \r\n\t *\r\n\t *    @return The offset of the item from the parent item's base address.\r\n\t */\r\n\tvirtual quint64 getOffset() const = 0;\r\n\r\n\t/*!\r\n     *  Get the last address contained in the item.\r\n\t *\r\n\t *    @return The last address.\r\n\t */\r\n\tvirtual quint64 getLastAddress() const = 0;\r\n\r\n\t/*!\r\n     *  Get the bit width of the item.\r\n\t * \r\n\t *    @return The bit width of the item.\r\n\t */\r\n\tvirtual int getBitWidth() const = 0;\r\n\r\n\t/*!\r\n     *  Get number of bits the addressable unit contains.\r\n\t *\r\n\t *    @return The size of least addressable unit.\r\n\t */\r\n\tvirtual unsigned int getAddressUnitSize() const = 0;\r\n\r\n    //! Re-layouts the child items.\r\n    virtual void redoChildLayout();\r\n\r\n\t/*!\r\n     *  Add a child visualization item for this item.\r\n\t *\r\n\t *    @param [in] childItem Pointer to the child to add.\r\n\t */\r\n\tvirtual void addChild(MemoryVisualizationItem* childItem);\r\n\r\n    /*!\r\n     *  Remove a child visualization item from this item.\r\n\t *\r\n\t *    @param [in] childItem Pointer to the child to remove.\r\n\t */\r\n\tvirtual void removeChild(MemoryVisualizationItem* childItem);\r\n\r\n    int getChildCount() const;\r\n\r\n    /*!\r\n     *  Set the width for the item.\r\n\t *\r\n\t *    @param [in] width The new width of the item.\r\n\t */\r\n\tvirtual void setWidth(qreal width);\r\n\r\n\t/*!\r\n     *  The bounding rect of the item.\r\n\t *\r\n\t *    @return The rectangle that bounds the item and possible sub items.\r\n\t */\r\n\tvirtual QRectF boundingRect() const;\r\n\r\n\r\nsignals:\r\n\r\n\t//! Emitted when this item's editor should be displayed.\r\n\tvoid selectEditor();\r\n\r\nprotected slots:\r\n\r\n    \r\n    /*!\r\n     *  Repositions the child items within this item.\r\n     */\r\n    virtual void repositionChildren();\r\n\r\nprotected:\r\n   \r\n    /*!\r\n     *  Parse a given expression.\r\n     *\r\n     *    @param [in] expression  The expression to be parsed.\r\n     */\r\n    quint64 parseExpression(QString const& expression) const;\r\n\r\n    /*!\r\n     *  Get the used expression parser.\r\n     *\r\n     *    @return Pointer to the expression parser.\r\n     */\r\n    QSharedPointer<ExpressionParser> getExpressionParser() const;\r\n\r\n    //! Shows the expand/collapse icon if the item has any children. Otherwise the icon is hidden.\r\n    void showExpandIconIfHasChildren();\r\n\r\n    //! Update the offsets of the child items in the map and fills the empty gaps between them.\r\n    void updateChildMap();\r\n\r\n    //! Removes current gaps between child items and re-sorts items by offset.\r\n    virtual void removeGapsAndSortChildren();\r\n\r\n    /*!\r\n     * Fills the gaps between child items with gap items.\r\n     */\r\n    virtual void fillGapsBetweenChildren();\r\n\r\n    //! Mark all invalid children outside item boundaries.\r\n    virtual void markConflictingChildren();\r\n\r\n\t//! Handler for mouse press events\r\n\tvirtual void mousePressEvent(QGraphicsSceneMouseEvent* event);\r\n\r\n\t//! Contains the child memory items. The offset of the child is the key.\r\n\tQMultiMap<quint64, MemoryVisualizationItem*> childItems_;\r\n\r\nprivate:\r\n    \r\n    /*!\r\n     *  Checks if there is empty memory space between the given child and the last known used address.\r\n     *\r\n     *    @param [in] current             The currently iterated child.\r\n     *    @param [in] lastAddressInUse    The last known used address.\r\n     *\r\n     *    @return True, if there is empty space, otherwise false.\r\n     */\r\n    bool emptySpaceBeforeChild(MemoryVisualizationItem const* current, quint64 lastAddressInUse) const;\r\n\r\n    /*!\r\n     *\tMark child and its preceding children conflicting, if overlapping.\r\n     *  \r\n     *    @param [in] child     The child to check.   \r\n     */\r\n    void markChildIfConflicting(MemoryVisualizationItem* child);\r\n\r\n    /*!\r\n     *  Creates a new child for representing a free memory slot.\r\n     *\r\n     *    @param [in] offset          The offset of the free memory slot.\r\n     *    @param [in] lastAddress     The last address of the free memory slot.\r\n     *\r\n     *    @return The created child item.\r\n     */\r\n    QMultiMap<quint64, MemoryVisualizationItem*>::iterator createMemoryGap(quint64 offset, quint64 lastAddress);\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! Width for child items.\r\n    qreal childWidth_ = VisualizerItem::DEFAULT_WIDTH;\r\n\r\n    //! The used expression parser.\r\n    QSharedPointer<ExpressionParser> expressionParser_;\r\n\r\n};\r\n\r\n#endif // MEMORYVISUALIZATIONITEM_H\r\n"
  },
  {
    "path": "editors/ConfigurationTools/ViewConfigurer.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ViewConfigurer.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Mikko Teuho\r\n// Date: 19.05.2015\r\n//\r\n// Description:\r\n// Configures the views in the component design of the selected component.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"ViewConfigurer.h\"\r\n#include \"ViewConfigurerColumns.h\"\r\n#include \"ViewConfigurerDelegate.h\"\r\n\r\n#include <KactusAPI/include/LibraryHandler.h>\r\n\r\n#include <IPXACTmodels/common/VLNV.h>\r\n#include <IPXACTmodels/Component/Component.h>\r\n#include <IPXACTmodels/Design/Design.h>\r\n#include <IPXACTmodels/DesignConfiguration/DesignConfiguration.h>\r\n#include <IPXACTmodels/kactusExtensions/Kactus2Placeholder.h>\r\n#include <IPXACTmodels/kactusExtensions/Kactus2Group.h>\r\n\r\n#include <QSharedPointer>\r\n#include <QDialogButtonBox>\r\n#include <QVBoxLayout>\r\n#include <QBrush>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ViewConfigurer::ViewConfigurer()\r\n//-----------------------------------------------------------------------------\r\nViewConfigurer::ViewConfigurer(QSharedPointer<Component> selectedComponent, QSharedPointer<Design> selectedDesign,\r\n    QSharedPointer<DesignConfiguration> selectedDesignConfiguration, LibraryHandler* libraryHandler,\r\n    QString const& openViewName, QWidget* parent /* = 0 */):\r\nQDialog(parent),\r\nselectedDesignConfiguration_(selectedDesignConfiguration),\r\nviewsTree_(new QTreeWidget(this)),\r\nlibraryHandler_(libraryHandler),\r\nusedHierarchicalComponentVLNVS_(),\r\ncommitButton_ (new QPushButton(QIcon(\":/icons/common/graphics/file-save.png\"), tr(\"Save\"), this)),\r\nclearButton_(new QPushButton(QIcon(\":/icons/common/graphics/cleanup.png\"), tr(\"Clear\"), this))\r\n{\r\n    clearButton_->setEnabled(false);\r\n\r\n    setMinimumWidth(600);\r\n    setMinimumHeight(400);\r\n\r\n    QStringList treeHeaderLabels;\r\n    treeHeaderLabels << \"VLNV\" << \"Instance\" << \"View\" << \"ID\";\r\n    \r\n    viewsTree_->setHeaderLabels(treeHeaderLabels);\r\n    viewsTree_->setColumnCount(ViewConfigurerColumns::COLUMN_COUNT);\r\n    viewsTree_->hideColumn(ViewConfigurerColumns::INSTANCE_ID);\r\n    viewsTree_->setIndentation(15);\r\n\r\n    viewsTree_->setAlternatingRowColors(true);\r\n\r\n    viewsTree_->setItemDelegate(new ViewConfigurerDelegate(libraryHandler, this));\r\n\r\n    QTreeWidgetItem* topComponentItem (new QTreeWidgetItem(viewsTree_));\r\n    \r\n    if (!selectedDesign && !selectedDesignConfiguration_)\r\n    {\r\n        topComponentItem->setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsEditable);\r\n\r\n        topComponentItem->setIcon(ViewConfigurerColumns::ITEM_VLNV,\r\n            QIcon(\":/icons/common/graphics/hw-component.png\"));\r\n    }\r\n    else\r\n    {\r\n        usedHierarchicalComponentVLNVS_.append(selectedComponent->getVlnv().toString(\":\"));\r\n\r\n        topComponentItem->setIcon(ViewConfigurerColumns::ITEM_VLNV,\r\n            QIcon(\":/icons/common/graphics/hier-hw-component.png\"));\r\n    }\r\n\r\n    topComponentItem->setText(ViewConfigurerColumns::ITEM_VLNV, selectedComponent->getVlnv().toString(\":\"));\r\n    topComponentItem->setText(ViewConfigurerColumns::INSTANCE_NAME, selectedComponent->getVlnv().getName());\r\n\r\n    if (openViewName.isEmpty())\r\n    {\r\n        topComponentItem->setText(ViewConfigurerColumns::INSTANCE_VIEW, ViewConfigurerColumns::NOVIEWTEXT);\r\n\r\n        QBrush foreGroundBrush (Qt::red);\r\n        topComponentItem->setForeground(ViewConfigurerColumns::INSTANCE_VIEW, foreGroundBrush);\r\n    }\r\n    else\r\n    {\r\n        topComponentItem->setText(ViewConfigurerColumns::INSTANCE_VIEW, openViewName);\r\n    }\r\n\r\n    viewsTree_->addTopLevelItem(topComponentItem);\r\n\r\n    if (selectedDesign)\r\n    {\r\n        createChildTreeWidgetItems(selectedDesign, selectedDesignConfiguration_, topComponentItem);\r\n\r\n        modifyTreeWithExistingViewGroup();\r\n    }\r\n\r\n    viewsTree_->expandAll();\r\n\r\n    viewsTree_->resizeColumnToContents(ViewConfigurerColumns::ITEM_VLNV);\r\n    viewsTree_->resizeColumnToContents(ViewConfigurerColumns::INSTANCE_NAME);\r\n    viewsTree_->resizeColumnToContents(ViewConfigurerColumns::INSTANCE_VIEW);\r\n\r\n    setupLayout();\r\n\r\n    connect(viewsTree_, SIGNAL(itemChanged(QTreeWidgetItem*, int)),\r\n        this, SLOT(onInstanceViewChanged(QTreeWidgetItem*, int)), Qt::UniqueConnection);\r\n\r\n    setCommmitButtonEnabledStatus();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ViewConfigurer::~ViewConfigurer()\r\n//-----------------------------------------------------------------------------\r\nViewConfigurer::~ViewConfigurer()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ViewConfigurer::setupLayout()\r\n//-----------------------------------------------------------------------------\r\nvoid ViewConfigurer::setupLayout()\r\n{\r\n    connect(clearButton_, SIGNAL(released()), this, SLOT(clearViewOverrides()), Qt::UniqueConnection);\r\n\r\n    connect(commitButton_, SIGNAL(released()), this, SLOT(saveAndCloseConfigurer()), Qt::UniqueConnection);\r\n\r\n    QPushButton* closeButton (new QPushButton(tr(\"Close\"), this));\r\n    connect(closeButton, SIGNAL(released()), this, SLOT(reject()), Qt::UniqueConnection);\r\n\r\n    QDialogButtonBox* buttonBox (new QDialogButtonBox(Qt::Horizontal));\r\n    buttonBox->addButton(clearButton_, QDialogButtonBox::ActionRole);\r\n    buttonBox->addButton(commitButton_, QDialogButtonBox::ActionRole);\r\n    buttonBox->addButton(closeButton, QDialogButtonBox::ActionRole);\r\n\r\n    setWindowTitle(\"Configure view overrides\");\r\n\r\n    QVBoxLayout* mainLayout (new QVBoxLayout(this));\r\n    mainLayout->addWidget(viewsTree_);\r\n    mainLayout->addWidget(buttonBox);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ViewConfigurer::createChildTreeWidgetItem()\r\n//-----------------------------------------------------------------------------\r\nvoid ViewConfigurer::createChildTreeWidgetItems(QSharedPointer<Design> currentDesign,\r\n    QSharedPointer<DesignConfiguration> currentDesignConfiguration, QTreeWidgetItem* parentItem)\r\n{\r\n    for (QSharedPointer<ComponentInstance> currentInstance : *currentDesign->getComponentInstances())\r\n    {\r\n        if (!currentInstance->isDraft())\r\n        {\r\n            VLNV componentReference = *currentInstance->getComponentRef();\r\n            QSharedPointer<Component> component = libraryHandler_->getModel(componentReference).dynamicCast<Component>();\r\n\r\n            QString instanceViewName = currentDesignConfiguration->getActiveView(currentInstance->getInstanceName());\r\n\r\n            QTreeWidgetItem* instanceItem (new QTreeWidgetItem(parentItem));\r\n            instanceItem->setText(ViewConfigurerColumns::ITEM_VLNV, componentReference.toString(\":\"));\r\n            instanceItem->setText(ViewConfigurerColumns::INSTANCE_NAME, currentInstance->getInstanceName());\r\n\r\n            if (instanceViewName.isEmpty())\r\n            {\r\n                instanceViewName = ViewConfigurerColumns::NOVIEWTEXT;\r\n\r\n                QBrush foreGroundBrush(Qt::red);\r\n                instanceItem->setForeground(ViewConfigurerColumns::INSTANCE_VIEW, foreGroundBrush);\r\n            }\r\n\r\n            instanceItem->setText(ViewConfigurerColumns::INSTANCE_VIEW, instanceViewName);\r\n            instanceItem->setText(ViewConfigurerColumns::INSTANCE_ID, currentInstance->getUuid());\r\n\r\n            instanceItem->setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsEditable);\r\n\r\n            instanceItem->setIcon(ViewConfigurerColumns::ITEM_VLNV, QIcon(\":/icons/common/graphics/hw-component.png\"));\r\n\r\n            if (usedHierarchicalComponentVLNVS_.contains(instanceItem->text(ViewConfigurerColumns::ITEM_VLNV)))\r\n            {\r\n                instanceItem->setText(ViewConfigurerColumns::INSTANCE_VIEW, ViewConfigurerColumns::CYCLICCOMPONENTTEXT);\r\n\r\n                QBrush foreGroundBrush (Qt::red);\r\n                instanceItem->setForeground(ViewConfigurerColumns::INSTANCE_VIEW, foreGroundBrush);\r\n                instanceItem->setForeground(ViewConfigurerColumns::ITEM_VLNV, foreGroundBrush);\r\n                instanceItem->setForeground(ViewConfigurerColumns::INSTANCE_NAME, foreGroundBrush);\r\n                instanceItem->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);\r\n            }\r\n            else\r\n            {\r\n                usedHierarchicalComponentVLNVS_.append(instanceItem->text(ViewConfigurerColumns::ITEM_VLNV));\r\n\r\n                checkInstanceDesign(component, instanceViewName, instanceItem);\r\n\r\n                if (usedHierarchicalComponentVLNVS_.size() > 1)\r\n                {\r\n                    usedHierarchicalComponentVLNVS_.removeAll(instanceItem->text(ViewConfigurerColumns::ITEM_VLNV));\r\n                }\r\n            }\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ViewConfigurer::checkInstanceDesign()\r\n//-----------------------------------------------------------------------------\r\nvoid ViewConfigurer::checkInstanceDesign(QSharedPointer<Component> component, QString const& viewName,\r\n    QTreeWidgetItem* currentTreeItem)\r\n{\r\n    if (!viewName.isEmpty())\r\n    {\r\n        VLNV viewDesignVLNV = component->getHierRef(viewName);\r\n\r\n        if (viewDesignVLNV.isValid())\r\n        {\r\n            QSharedPointer<DesignConfiguration> viewDesignConfiguration = libraryHandler_->getModel(\r\n                viewDesignVLNV).dynamicCast<DesignConfiguration>();\r\n\r\n            if (viewDesignConfiguration)\r\n            {\r\n                VLNV designReference = viewDesignConfiguration->getDesignRef();\r\n\r\n                QSharedPointer<Design> viewDesign = libraryHandler_->getModel(designReference).\r\n                    dynamicCast<Design>();\r\n\r\n                if (viewDesign)\r\n                {\r\n                    currentTreeItem->setIcon(ViewConfigurerColumns::ITEM_VLNV,\r\n                        QIcon(\":/icons/common/graphics/hier-hw-component.png\"));\r\n\r\n                    createChildTreeWidgetItems(viewDesign, viewDesignConfiguration, currentTreeItem);\r\n\r\n                    currentTreeItem->setExpanded(true);\r\n                }\r\n            }\r\n        } \r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ViewConfigurer::modifyTreeWithExistingViewGroup()\r\n//-----------------------------------------------------------------------------\r\nvoid ViewConfigurer::modifyTreeWithExistingViewGroup()\r\n{\r\n    if(selectedDesignConfiguration_)\r\n    {\r\n        auto viewOverrides = selectedDesignConfiguration_->getKactus2ViewOverrides();\r\n\r\n        if (!viewOverrides.isEmpty())\r\n        {\r\n            clearButton_->setEnabled(true);\r\n\r\n            for (int treeTopIndex = 0; treeTopIndex < viewsTree_->topLevelItemCount(); ++treeTopIndex)\r\n            {\r\n                parseExistingInstanceView(viewsTree_->topLevelItem(treeTopIndex), viewOverrides);\r\n            }\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ViewConfigurer::parseExistingInstanceView()\r\n//-----------------------------------------------------------------------------\r\nvoid ViewConfigurer::parseExistingInstanceView(QTreeWidgetItem* currentTreeItem, QMap<QString, QString> viewOverrides)\r\n{\r\n    QString treeItemOverrideView = viewOverrides.value(currentTreeItem->text(ViewConfigurerColumns::INSTANCE_ID));\r\n\r\n    if (!treeItemOverrideView.isEmpty())\r\n    {\r\n        currentTreeItem->setText(ViewConfigurerColumns::INSTANCE_VIEW, treeItemOverrideView);\r\n\r\n        onInstanceViewChanged(currentTreeItem, ViewConfigurerColumns::INSTANCE_VIEW);\r\n    }\r\n\r\n    for (int treeItemChildIndex = 0; treeItemChildIndex < currentTreeItem->childCount(); ++treeItemChildIndex)\r\n    {\r\n        parseExistingInstanceView(currentTreeItem->child(treeItemChildIndex), viewOverrides);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ViewConfigurer::onInstanceViewChanged()\r\n//-----------------------------------------------------------------------------\r\nvoid ViewConfigurer::onInstanceViewChanged(QTreeWidgetItem* changedItem, int column)\r\n{\r\n    if (changedItem && column == ViewConfigurerColumns::INSTANCE_VIEW)\r\n    {\r\n        changedItem->takeChildren();\r\n\r\n        changedItem->setIcon(ViewConfigurerColumns::ITEM_VLNV, QIcon(\":/icons/common/graphics/hw-component.png\"));\r\n\r\n        QString itemVLNV = changedItem->text(ViewConfigurerColumns::ITEM_VLNV);\r\n        VLNV componentVLNV (VLNV::COMPONENT, itemVLNV, \":\");\r\n\r\n        QSharedPointer<Component> component = libraryHandler_->getModel(componentVLNV).dynamicCast<Component>();\r\n\r\n        QString viewName = changedItem->text(ViewConfigurerColumns::INSTANCE_VIEW);\r\n\r\n        if (isChangedItemTopItem(changedItem))\r\n        {\r\n            clearButton_->setEnabled(false);\r\n            changedTopItemChangesDesignConfiguration(component, viewName);\r\n        }\r\n\r\n        viewsTree_->blockSignals(true);\r\n\r\n        checkInstanceDesign(component, viewName, changedItem);\r\n\r\n        if (changedItem->text(ViewConfigurerColumns::INSTANCE_VIEW) == ViewConfigurerColumns::NOVIEWTEXT ||\r\n            !component->getViewNames().contains(changedItem->text(ViewConfigurerColumns::INSTANCE_VIEW)))\r\n        {\r\n            QBrush foreGroundBrush (Qt::red);\r\n            changedItem->setForeground(ViewConfigurerColumns::INSTANCE_VIEW, foreGroundBrush);\r\n\r\n            if (isChangedItemTopItem(changedItem))\r\n            {\r\n                usedHierarchicalComponentVLNVS_.removeAll(itemVLNV);\r\n            }\r\n        }\r\n        else\r\n        {\r\n            QBrush foreGroundBrush = changedItem->foreground(ViewConfigurerColumns::ITEM_VLNV);\r\n            changedItem->setForeground(ViewConfigurerColumns::INSTANCE_VIEW, foreGroundBrush);\r\n        }\r\n\r\n        if (isChangedItemTopItem(changedItem))\r\n        {\r\n            modifyTreeWithExistingViewGroup();\r\n        }\r\n\r\n        viewsTree_->blockSignals(false);\r\n\r\n        setCommmitButtonEnabledStatus();\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ViewConfigurer::isChangedItemTopItem()\r\n//-----------------------------------------------------------------------------\r\nbool ViewConfigurer::isChangedItemTopItem(QTreeWidgetItem* changedTreeItem)\r\n{\r\n    for (int treeTopIndex = 0; treeTopIndex < viewsTree_->topLevelItemCount(); ++treeTopIndex)\r\n    {\r\n        if (changedTreeItem == viewsTree_->topLevelItem(treeTopIndex))\r\n        {\r\n            return true;\r\n        }\r\n    }\r\n\r\n    return false;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ViewConfigurer::changedTopItemChangesDesignConfiguration()\r\n//-----------------------------------------------------------------------------\r\nvoid ViewConfigurer::changedTopItemChangesDesignConfiguration(QSharedPointer<Component> component,\r\n    QString const& viewName)\r\n{\r\n    selectedDesignConfiguration_.clear();\r\n\r\n    VLNV viewDesignVLNV = component->getHierRef(viewName);\r\n    if (viewDesignVLNV.isValid())\r\n    {\r\n        QSharedPointer<DesignConfiguration> viewDesignConfiguration =\r\n            libraryHandler_->getModel(viewDesignVLNV).dynamicCast<DesignConfiguration>();\r\n\r\n        if (viewDesignConfiguration)\r\n        {\r\n            selectedDesignConfiguration_ = viewDesignConfiguration;\r\n\r\n            usedHierarchicalComponentVLNVS_.append(component->getVlnv().toString(\":\"));\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ViewConfigurer::setCommmitButtonEnabledStatus()\r\n//-----------------------------------------------------------------------------\r\nvoid ViewConfigurer::setCommmitButtonEnabledStatus()\r\n{\r\n    bool commitButtonStatus = true;\r\n\r\n    for (int i = 0; i < viewsTree_->topLevelItemCount(); ++i)\r\n    {\r\n        if (treeItemContainsEmptyOrCyclicalViews(viewsTree_->topLevelItem(i)))\r\n        {\r\n            commitButtonStatus = false;\r\n            break;\r\n        }\r\n    }\r\n\r\n    commitButton_->setEnabled(commitButtonStatus);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ViewConfigurer::treeContainsEmptyOrCyclicalViews()\r\n//-----------------------------------------------------------------------------\r\nbool ViewConfigurer::treeItemContainsEmptyOrCyclicalViews(QTreeWidgetItem* treeItem)\r\n{\r\n    if (treeItem->text(ViewConfigurerColumns::INSTANCE_VIEW) == ViewConfigurerColumns::NOVIEWTEXT ||\r\n        treeItem->text(ViewConfigurerColumns::INSTANCE_VIEW) == ViewConfigurerColumns::CYCLICCOMPONENTTEXT)\r\n    {\r\n        return true;\r\n    }\r\n\r\n    for (int treeItemIndex = 0; treeItemIndex < treeItem->childCount(); ++treeItemIndex)\r\n    {\r\n        if (treeItemContainsEmptyOrCyclicalViews(treeItem->child(treeItemIndex)))\r\n        {\r\n            return true;\r\n        }\r\n    }\r\n\r\n    return false;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ViewConfigurer::saveAndCloseConfigurer()\r\n//-----------------------------------------------------------------------------\r\nvoid ViewConfigurer::saveAndCloseConfigurer()\r\n{\r\n    if(selectedDesignConfiguration_)\r\n    {\r\n        QMap<QString, QString> viewOverrides;\r\n        for (int treetopIndex = 0; treetopIndex < viewsTree_->topLevelItemCount(); ++treetopIndex)\r\n        {\r\n            QTreeWidgetItem* topItem = viewsTree_->topLevelItem(treetopIndex);\r\n\r\n            for (int topItemChildIndex = 0; topItemChildIndex < topItem->childCount(); ++topItemChildIndex)\r\n            {\r\n                parseChildTreeItem(topItem->child(topItemChildIndex), viewOverrides);\r\n            }\r\n        }\r\n\r\n        selectedDesignConfiguration_->setKactus2ViewOverrides(viewOverrides);\r\n        libraryHandler_->writeModelToFile(selectedDesignConfiguration_);\r\n    }\r\n\r\n    accept();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ViewConfigurer::parseChildTreeItem()\r\n//-----------------------------------------------------------------------------\r\nvoid ViewConfigurer::parseChildTreeItem(QTreeWidgetItem* treeItem, QMap<QString, QString>& viewOverrides)\r\n{\r\n    QString treeItemID = treeItem->text(ViewConfigurerColumns::INSTANCE_ID);\r\n    QString treeItemView = treeItem->text(ViewConfigurerColumns::INSTANCE_VIEW);\r\n\r\n    if (treeItemView != ViewConfigurerColumns::NOVIEWTEXT &&\r\n        treeItemView != ViewConfigurerColumns::CYCLICCOMPONENTTEXT)\r\n    {\r\n        viewOverrides.insert(treeItemID, treeItemView);\r\n\r\n        for (int itemChildIndex = 0; itemChildIndex < treeItem->childCount(); ++itemChildIndex)\r\n        {\r\n            parseChildTreeItem(treeItem->child(itemChildIndex), viewOverrides);\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ViewConfigurer::clearViewOverrides()\r\n//-----------------------------------------------------------------------------\r\nvoid ViewConfigurer::clearViewOverrides()\r\n{\r\n    if(selectedDesignConfiguration_)\r\n    {\r\n        selectedDesignConfiguration_->setKactus2ViewOverrides(QMap<QString, QString> ());\r\n        libraryHandler_->writeModelToFile(selectedDesignConfiguration_);\r\n\r\n        for (int treeTopIndex = 0; treeTopIndex < viewsTree_->topLevelItemCount(); ++treeTopIndex)\r\n        {\r\n            QTreeWidgetItem* treeTopItem = viewsTree_->topLevelItem(treeTopIndex);\r\n\r\n            treeTopItem->takeChildren();\r\n\r\n            QString topItemView = treeTopItem->text(ViewConfigurerColumns::INSTANCE_VIEW);\r\n            QString topItemVLNV = treeTopItem->text(ViewConfigurerColumns::ITEM_VLNV);\r\n            VLNV topComponentVLNV (VLNV::COMPONENT, topItemVLNV, \":\");\r\n\r\n            QSharedPointer<Component> topComponent = libraryHandler_->getModel(topComponentVLNV).\r\n                dynamicCast<Component>();\r\n\r\n            disconnect(viewsTree_, SIGNAL(itemChanged(QTreeWidgetItem*, int)),\r\n                this, SLOT(onInstanceViewChanged(QTreeWidgetItem*, int)));\r\n\r\n            checkInstanceDesign(topComponent, topItemView, treeTopItem);\r\n\r\n            connect(viewsTree_, SIGNAL(itemChanged(QTreeWidgetItem*, int)),\r\n                this, SLOT(onInstanceViewChanged(QTreeWidgetItem*, int)), Qt::UniqueConnection);\r\n        }\r\n\r\n        clearButton_->setEnabled(false);\r\n\r\n        setCommmitButtonEnabledStatus();\r\n    }\r\n}\r\n"
  },
  {
    "path": "editors/ConfigurationTools/ViewConfigurer.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ViewConfigurer.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Mikko Teuho\r\n// Date: 19.05.2015\r\n//\r\n// Description:\r\n// Configures the views in the component design of the selected component.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef VIEWCONFIGURER_H\r\n#define VIEWCONFIGURER_H\r\n\r\n#include <QDialog>\r\n#include <QTreeWidget>\r\n#include <QObject>\r\n#include <QStringList>\r\n#include <QPushButton>\r\n\r\nclass Component;\r\nclass Design;\r\nclass DesignConfiguration;\r\nclass LibraryHandler;\r\nclass Kactus2Group;\r\n//-----------------------------------------------------------------------------\r\n//! Configures the views in the component design of the selected component.\r\n//-----------------------------------------------------------------------------\r\nclass ViewConfigurer : public QDialog\r\n{\r\n    Q_OBJECT\r\n\r\npublic:\r\n\r\n    /*!\r\n     *  The constructor.\r\n     *\r\n     *    @param [in] selectedComponent               The component used to configure the views.\r\n     *    @param [in] selectedDesign                  The component design used to configure the views.\r\n     *    @param [in] selectedDesignConfiguration     The design configuration used to configure the views.\r\n     *    @param [in] libraryHandler                  The library manager.\r\n     *    @param [in] openViewName                    The name of the currently open view.\r\n     *    @param [in] parent                          The parent of this widget.\r\n     */\r\n    ViewConfigurer(QSharedPointer<Component> selectedComponent, QSharedPointer<Design> selectedDesign,\r\n        QSharedPointer<DesignConfiguration> selectedDesignConfiguration, LibraryHandler* libraryHandler,\r\n        QString const& openViewName, QWidget* parent = 0);\r\n\r\n    /*!\r\n     *  Destructor.\r\n     */\r\n    ~ViewConfigurer();\r\n\r\nprivate slots:\r\n\r\n    /*!\r\n     *  Handles the changes in the instance views.\r\n     *\r\n     *    @param [in] changedItem     The changed tree widget item.\r\n     *    @param [in] column          The column of the changed data.\r\n     */\r\n    void onInstanceViewChanged(QTreeWidgetItem* changedItem, int column);\r\n\r\n    /*!\r\n     *  Save the data created to the design configurations vendor extensions.\r\n     */\r\n    void saveAndCloseConfigurer();\r\n\r\n    /*!\r\n     *  Remove the view overrides from the design configuration.\r\n     */\r\n    void clearViewOverrides();\r\n\r\nprivate:\r\n    // No copying allowed.\r\n    ViewConfigurer(ViewConfigurer const& rhs);\r\n\r\n    // No assignment allowed.\r\n    ViewConfigurer& operator=(ViewConfigurer const& rhs);\r\n\r\n    /*!\r\n     *  Setup the layout.\r\n     */\r\n    void setupLayout();\r\n\r\n    /*!\r\n     *  Create child tree items.\r\n     *\r\n     *    @param [in] currentDesign               The design associated with the current tree item.\r\n     *    @param [in] currentDesignConfiguration  The design configuration associated with the current tree item.\r\n     *    @param [in] parentItem                  The parent tree item of the child items.\r\n     */\r\n    void createChildTreeWidgetItems(QSharedPointer<Design> currentDesign,\r\n        QSharedPointer<DesignConfiguration> currentDesignConfiguration, QTreeWidgetItem* parentItem);\r\n    \r\n    /*!\r\n     *  Check the possible design of the component instance.\r\n     *\r\n     *    @param [in] component           The component associated with the instance.\r\n     *    @param [in] viewName            The name of the view used by the instance.\r\n     *    @param [in] currentTreeItem     The tree item associated with the instance.\r\n     */\r\n    void checkInstanceDesign(QSharedPointer<Component> component, QString const& viewName,\r\n        QTreeWidgetItem* currentTreeItem);\r\n\r\n    /*!\r\n     *  Modify the contents of the tree with the tree with the stored view configuration.\r\n     */\r\n    void modifyTreeWithExistingViewGroup();\r\n\r\n    /*!\r\n     *  Change the view data of the tree item, if found in the stored configuration.\r\n     *\r\n     *    @param [in] currentTreeItem     The current tree item.\r\n     *    @param [in] viewOverrides       The stored view overrides.\r\n     */\r\n    void parseExistingInstanceView(QTreeWidgetItem* currentTreeItem, QMap<QString, QString> viewOverrides);\r\n\r\n    /*!\r\n     *  Check if the changed item is a top level tree item.\r\n     *\r\n     *    @param [in] changedTreeItem     The changed item.\r\n     *\r\n     *    @return True, if the changed item is a top item, otherwise false.\r\n     */\r\n    bool isChangedItemTopItem(QTreeWidgetItem* changedTreeItem);\r\n\r\n    /*!\r\n     *  A changed top item means that the used design configuration needs to be changed.\r\n     *\r\n     *    @param [in] component   The component associated with the top tree item.\r\n     *    @param [in] viewName    The new view name.\r\n     */\r\n    void changedTopItemChangesDesignConfiguration(QSharedPointer<Component> component, QString const& viewName);\r\n\r\n    /*!\r\n     *  Set the enabled status for the commit button.\r\n     */\r\n    void setCommmitButtonEnabledStatus();\r\n\r\n    /*!\r\n     *  Check if the tree item contains empty or cyclical views.\r\n     *\r\n     *    @param [in] treeItem    The selected tree item.\r\n     */\r\n    bool treeItemContainsEmptyOrCyclicalViews(QTreeWidgetItem* treeItem);\r\n\r\n    /*!\r\n     *  Prepare the tree items for saving.\r\n     *\r\n     *    @param [in] treeItem        The current tree item.\r\n     *    @param [in] viewOverrides   The view overrides.\r\n     */\r\n    void parseChildTreeItem(QTreeWidgetItem* treeItem, QMap<QString, QString>& viewOverrides);\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! The design configuration used to store the view configuration.\r\n    QSharedPointer<DesignConfiguration> selectedDesignConfiguration_;\r\n\r\n    //! The constructed tree.\r\n    QTreeWidget* viewsTree_;\r\n\r\n    //! The library manager\r\n    LibraryHandler* libraryHandler_;\r\n\r\n    //! A list of used hierarchical component VLNVs, used to check for cyclical designs.\r\n    QStringList usedHierarchicalComponentVLNVS_;\r\n\r\n    //! The commit button.\r\n    QPushButton* commitButton_; \r\n\r\n    //! The button for removing the view overrides.\r\n    QPushButton* clearButton_;\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n\r\n#endif // VIEWCONFIGURER_H\r\n"
  },
  {
    "path": "editors/ConfigurationTools/ViewConfigurerColumns.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ViewConfigurerColumns.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Mikko Teuho\r\n// Date: 19.05.2015\r\n//\r\n// Description:\r\n// Common declarations for view configurer.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include <QObject>\r\n\r\nnamespace ViewConfigurerColumns\r\n{\r\n    //! The columns in the view configurer.\r\n    enum columns\r\n    {\r\n        ITEM_VLNV = 0,\r\n        INSTANCE_NAME,\r\n        INSTANCE_VIEW,\r\n        INSTANCE_ID,\r\n        COLUMN_COUNT\r\n    };\r\n\r\n    //! Text for an item that does not contain a view.\r\n    QString const NOVIEWTEXT = QObject::tr(\"No view selected\");\r\n\r\n    //! Text for an item that causes cyclical instantiation of component instances.\r\n    QString const CYCLICCOMPONENTTEXT = QObject::tr(\"Cyclic instantiation\");\r\n}"
  },
  {
    "path": "editors/ConfigurationTools/ViewConfigurerDelegate.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ViewConfigurerDelegate.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Mikko Teuho\r\n// Date: 19.05.2015\r\n//\r\n// Description:\r\n// Delegate for view configurer.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"ViewConfigurerDelegate.h\"\r\n#include \"ViewConfigurerColumns.h\"\r\n\r\n#include <editors/ComponentEditor/common/ReferenceSelector/ReferenceSelector.h>\r\n\r\n#include <KactusAPI/include/LibraryHandler.h>\r\n\r\n#include <IPXACTmodels/Component/Component.h>\r\n#include <IPXACTmodels/common/VLNV.h>\r\n\r\n#include <QPainter>\r\n#include <QPen>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ViewConfigurerDelegate::ViewConfigurerDelegate()\r\n//-----------------------------------------------------------------------------\r\nViewConfigurerDelegate::ViewConfigurerDelegate(LibraryHandler* libraryHandler, QObject* parent):\r\nQStyledItemDelegate(parent),\r\nlibraryHandler_(libraryHandler)\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ViewConfigurerDelegate::~ViewConfigurerDelegate()\r\n//-----------------------------------------------------------------------------\r\nViewConfigurerDelegate::~ViewConfigurerDelegate()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ViewConfigurerDelegate::createEditor()\r\n//-----------------------------------------------------------------------------\r\nQWidget* ViewConfigurerDelegate::createEditor(QWidget* parent, QStyleOptionViewItem const& /*option*/,\r\n    QModelIndex const& index) const\r\n{\r\n    if (index.column() == ViewConfigurerColumns::INSTANCE_VIEW)\r\n    {\r\n        return createViewSelector(index, parent);\r\n    }\r\n\r\n    return 0;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ViewConfigurerDelegate::setEditorData()\r\n//-----------------------------------------------------------------------------\r\nvoid ViewConfigurerDelegate::setEditorData(QWidget* editor, QModelIndex const& index) const\r\n{\r\n    if (index.column() == ViewConfigurerColumns::INSTANCE_VIEW)\r\n    {\r\n        QString text = index.model()->data(index, Qt::DisplayRole).toString();\r\n\r\n        ReferenceSelector* viewCombo = qobject_cast<ReferenceSelector*>(editor);\r\n\r\n        if (text == ViewConfigurerColumns::NOVIEWTEXT)\r\n        {\r\n            text = \"\";\r\n        }\r\n\r\n        viewCombo->selectItem(text);\r\n    }\r\n    else\r\n    {\r\n        QStyledItemDelegate::setEditorData(editor, index);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ViewConfigurerDelegate::setModelData()\r\n//-----------------------------------------------------------------------------\r\nvoid ViewConfigurerDelegate::setModelData(QWidget* editor, QAbstractItemModel* model, QModelIndex const& index)\r\n    const\r\n{\r\n    if (index.column() == ViewConfigurerColumns::INSTANCE_VIEW)\r\n    {\r\n        ReferenceSelector* viewCombo = qobject_cast<ReferenceSelector*>(editor);\r\n        QString text = viewCombo->currentText();\r\n\r\n        if (text.isEmpty())\r\n        {\r\n            text = ViewConfigurerColumns::NOVIEWTEXT;\r\n        }\r\n\r\n        model->setData(index, text, Qt::EditRole);\r\n    }\r\n    else\r\n    {\r\n        QStyledItemDelegate::setModelData(editor, model, index);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ViewConfigurerDelegate::createViewSelector()\r\n//-----------------------------------------------------------------------------\r\nQWidget* ViewConfigurerDelegate::createViewSelector(QModelIndex const& currentIndex, QWidget* parent) const\r\n{\r\n    QModelIndex vlnvIndex = currentIndex.sibling(currentIndex.row(), ViewConfigurerColumns::ITEM_VLNV);\r\n    QString itemVlnv = vlnvIndex.data(Qt::DisplayRole).toString();\r\n\r\n    ReferenceSelector* viewCombo = new ReferenceSelector(parent);\r\n\r\n    if (itemVlnv.count(\":\") == 3)\r\n    {\r\n        VLNV componentVLNV (VLNV::COMPONENT, itemVlnv);\r\n\r\n        QSharedPointer<const Component> indexedComponent = libraryHandler_->getModelReadOnly(componentVLNV).\r\n            dynamicCast<const Component>();\r\n\r\n        QStringList viewNames = indexedComponent->getViewNames();\r\n        viewCombo->refresh(viewNames);\r\n    }\r\n\r\n    return viewCombo;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ViewConfigurerDelegate::paint()\r\n//-----------------------------------------------------------------------------\r\nvoid ViewConfigurerDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index)\r\n    const\r\n{\r\n    QStyledItemDelegate::paint(painter, option, index);\r\n\r\n    QPen oldPen = painter->pen();\r\n    QPen newPen(Qt::lightGray);\r\n    newPen.setWidth(1);\r\n    painter->setPen(newPen);\r\n\r\n    painter->drawLine(option.rect.topRight(), option.rect.bottomRight());\r\n\r\n    painter->setPen(oldPen);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ViewConfigurerDelegate::sizeHint()\r\n//-----------------------------------------------------------------------------\r\nQSize ViewConfigurerDelegate::sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const\r\n{\r\n    QSize rowSize = QStyledItemDelegate::sizeHint(option, index);\r\n    rowSize.setHeight(rowSize.height() + 5);\r\n\r\n    return rowSize;\r\n}"
  },
  {
    "path": "editors/ConfigurationTools/ViewConfigurerDelegate.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ViewConfigurerDelegate.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Mikko Teuho\r\n// Date: 19.05.2015\r\n//\r\n// Description:\r\n// Delegate for view configurer.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef VIEWCONFIGURERDELEGATE_H\r\n#define VIEWCONFIGURERDELEGATE_H\r\n\r\n#include <QStyledItemDelegate>\r\n\r\nclass LibraryHandler;\r\n//-----------------------------------------------------------------------------\r\n//! Delegate for view configurer.\r\n//-----------------------------------------------------------------------------\r\nclass ViewConfigurerDelegate : public QStyledItemDelegate\r\n{\r\n    Q_OBJECT\r\n\r\npublic:\r\n\r\n    /*!\r\n     *  The constructor.\r\n     *\r\n     *    @param [in] libraryHandler  The library manager.\r\n     *    @param [in] parent          The parent of this delegate.\r\n     */\r\n    ViewConfigurerDelegate(LibraryHandler* libraryHandler, QObject* parent);\r\n\r\n    /*!\r\n     *  The destructor.\r\n     */\r\n    ~ViewConfigurerDelegate();\r\n\r\n    /*!\r\n\t *  Create a new editor for the given item.\r\n\t *\r\n\t *    @param [in] parent  Owner of the editor.\r\n\t *    @param [in] option  Contains options for the editor.\r\n\t *    @param [in] index   Model index identifying the item.\r\n     *\r\n     *    @return Pointer to the editor to be used to edit the item.\r\n\t */\r\n\tvirtual QWidget* createEditor(QWidget* parent, QStyleOptionViewItem const& option, QModelIndex const& index)\r\n        const;\r\n\r\n\t/*!\r\n\t *  Set the data for the editor.\r\n\t *\r\n\t *    @param [in] editor  Pointer to the editor where the data is to be set.\r\n\t *    @param [in] index   Model index identifying the item that's data is to be set.\r\n\t */\r\n\tvirtual void setEditorData(QWidget* editor, QModelIndex const& index) const;\r\n\r\n    /*!\r\n\t *  Save the data from the editor to the model.\r\n\t *\r\n\t *    @param [in] editor  Pointer to the editor that contains the data to store.\r\n\t *    @param [in] model   Model that contains the data structure where data is to be saved to.\r\n\t *    @param [in] index   Model index identifying the item thats data is to be saved.\r\n\t */\r\n\tvirtual void setModelData(QWidget* editor, QAbstractItemModel* model, QModelIndex const& index) const;\r\n\r\n    /*!\r\n     *  Paints the delegate.\r\n     *\r\n     *    @param [in] painter     The painter used.\r\n     *    @param [in] option      Options for the painter.\r\n     *    @param [in] index       Model index identifying the item thats data is to be saved.\r\n     */\r\n    virtual void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const;\r\n\r\n    /*!\r\n     *  Gets the modified size hint for the item of this delegate.\r\n     *\r\n     *    @param [in] option  The used style option.\r\n     *    @param [in] index   The current index.\r\n     *\r\n     *    @return The size hint of the item at the given index.\r\n     */\r\n    virtual QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const;\r\n\r\nprivate:\r\n    // Disable copying and assignment.\r\n    ViewConfigurerDelegate(ViewConfigurerDelegate const& rhs);\r\n    ViewConfigurerDelegate& operator=(ViewConfigurerDelegate const& rhs);\r\n\r\n    /*!\r\n     *  Create the view selector the selected item.\r\n     *\r\n     *    @param [in] currentIndex    Model Index of the item.\r\n     *    @param [in] parent          The owner of the item.\r\n     *\r\n     *    @return View selector for the selected item.\r\n     */\r\n    QWidget* createViewSelector(QModelIndex const& currentIndex, QWidget* parent) const;\r\n\r\n    //! The library manager.\r\n    LibraryHandler* libraryHandler_;\r\n};\r\n\r\n#endif // VIEWCONFIGURERDELEGATE_H\r\n"
  },
  {
    "path": "editors/HWDesign/ActiveBusInterfaceItem.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ActiveBusInterfaceItem.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: \r\n// Date: \r\n//\r\n// Description:\r\n// HWConnection represents graphically an IP-XACT bus interface in a component instance.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"ActiveBusInterfaceItem.h\"\r\n\r\n#include \"HWComponentItem.h\"\r\n#include \"HWMoveCommands.h\"\r\n#include \"HWDesignDiagram.h\"\r\n\r\n#include <common/IEditProvider.h>\r\n#include <common/graphicsItems/GraphicsConnection.h>\r\n\r\n#include <editors/common/diagramgrid.h>\r\n#include <editors/common/NamelabelWidth.h>\r\n#include <editors/common/GraphicsItemLabel.h>\r\n#include <KactusAPI/include/BusInterfaceUtilities.h>\r\n\r\n#include <KactusAPI/include/LibraryInterface.h>\r\n\r\n#include <IPXACTmodels/Component/BusInterface.h>\r\n#include <IPXACTmodels/Component/Component.h>\r\n#include <IPXACTmodels/Design/ComponentInstance.h>\r\n#include <IPXACTmodels/BusDefinition/BusDefinition.h>\r\n\r\n#include <QFont>\r\n#include <QVector2D>\r\n#include <QGraphicsScene>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ActiveBusInterfaceItem::ActiveBusInterfaceItem()\r\n//-----------------------------------------------------------------------------\r\nActiveBusInterfaceItem::ActiveBusInterfaceItem(QSharedPointer<BusInterface> busIf, LibraryInterface* library,\r\n    HWComponentItem* parent):\r\nBusInterfaceEndPoint(busIf, parent->componentModel(), library, parent->isDraft(), parent)\r\n{\r\n    Q_ASSERT_X(busIf, \"ActiveBusInterfaceItem constructor\", \"Null BusInterface pointer given as parameter\");\r\n\r\n\r\n    ActiveBusInterfaceItem::updateInterface();\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ActiveBusInterfaceItem::updateName()\r\n//-----------------------------------------------------------------------------\r\nvoid ActiveBusInterfaceItem::updateName(QString const& previousName, QString const& newName)\r\n{\r\n    if (previousName.compare(newName) != 0)\r\n    {\r\n        encompassingComp()->getComponentInstance()->removeBusInterfacePosition(previousName);\r\n        encompassingComp()->getComponentInstance()->updateBusInterfacePosition(newName, pos());\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ActiveBusInterfaceItem::createMoveCommandForClashedItem()\r\n//-----------------------------------------------------------------------------\r\nvoid ActiveBusInterfaceItem::createMoveCommandForClashedItem(ConnectionEndpoint* endPoint, QPointF endPointPosition,\r\n    DesignDiagram* diagram, QSharedPointer<QUndoCommand> parentCommand)\r\n{\r\n    if (endPoint)\r\n    {\r\n        auto hwEndPoint = dynamic_cast<HWConnectionEndpoint*>(endPoint);\r\n        if (hwEndPoint && endPoint->pos() != endPointPosition)\r\n        {\r\n            new PortMoveCommand(hwEndPoint, endPointPosition, diagram, parentCommand.data());\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ActiveBusInterfaceItem::canConnectToInterface()\r\n//-----------------------------------------------------------------------------\r\nbool ActiveBusInterfaceItem::canConnectToInterface(ConnectionEndpoint const* otherEndPoint) const\r\n{\r\n    QSharedPointer<BusInterface> otherInterface = otherEndPoint->getBusInterface();\r\n    if (otherInterface)\r\n    {\r\n        if (otherEndPoint->isHierarchical())\r\n        {\r\n            return (otherInterface->getInterfaceMode() == getBusInterface()->getInterfaceMode() ||\r\n                otherInterface->getInterfaceMode() == General::INTERFACE_MODE_COUNT ||\r\n                !getBusInterface()->getBusType().isValid());\r\n        }\r\n\r\n        // If only one port has a bus definition defined at most, then the end points can be connected.\r\n        else if (!(getBusInterface()->getBusType().isValid() && otherInterface->getBusType().isValid()))\r\n        {\r\n            return true;\r\n        }\r\n\r\n        // Otherwise make sure that the bus and abstraction definitions are of the same type.\r\n        QSharedPointer<const BusDefinition> busDefinition = getLibraryAccess()->getModelReadOnly(\r\n            getBusInterface()->getBusType()).dynamicCast<const BusDefinition>();\r\n        if (busDefinition)\r\n        {\r\n            if (BusInterfaceUtilities::hasMatchingBusDefinitions(\r\n                busDefinition, otherInterface->getBusType(), getLibraryAccess()))\r\n            {\r\n                QList<General::InterfaceMode> compatibleModes = getOpposingModes(getBusInterface());\r\n                compatibleModes.append(General::SYSTEM);\r\n\r\n                General::InterfaceMode otherMode = otherInterface->getInterfaceMode();\r\n\r\n                return getBusInterface()->getInterfaceMode() !=\r\n                    General::MONITOR && compatibleModes.contains(otherMode);\r\n            }\r\n        }\r\n    }\r\n\r\n    return false;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: isHierarchical()\r\n//-----------------------------------------------------------------------------\r\nbool ActiveBusInterfaceItem::isHierarchical() const noexcept\r\n{\r\n    return false;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ActiveBusInterfaceItem::setTemporary()\r\n//-----------------------------------------------------------------------------\r\nvoid ActiveBusInterfaceItem::setTemporary(bool temp)\r\n{\r\n    setTypeLocked(!temp);\r\n    HWConnectionEndpoint::setTemporary(temp);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ActiveBusInterfaceItem::isDirectionFixed()\r\n//-----------------------------------------------------------------------------\r\nbool ActiveBusInterfaceItem::isDirectionFixed() const noexcept\r\n{\r\n    return true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ActiveBusInterfaceItem::setLabelPosition()\r\n//-----------------------------------------------------------------------------\r\nvoid ActiveBusInterfaceItem::setLabelPosition()\r\n{\r\n    qreal nameWidth = getNameLabel()->boundingRect().width();\r\n    qreal nameHeight = getNameLabel()->boundingRect().height();\r\n\r\n    // Check if the port is directed to the left.\r\n    if (pos().x() < 0)\r\n    {\r\n        getNameLabel()->setPos(nameHeight/2, GridSize);\r\n    }\r\n    else // The port is directed to the right.\r\n    {\r\n        getNameLabel()->setPos(-nameHeight/2, GridSize + nameWidth);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ActiveBusInterfaceItem::checkDirection()\r\n//-----------------------------------------------------------------------------\r\nvoid ActiveBusInterfaceItem::checkDirection()\r\n{\r\n    // Check if the port is directed to the left\r\n    if (pos().x() < 0)\r\n    {\r\n        setDirection(QVector2D(-1.0f, 0.0f));\r\n    }\r\n    else // The port is directed to the right.\r\n    {\r\n        setDirection(QVector2D(1.0f, 0.0f));\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ActiveBusInterfaceItem::getNameLength()\r\n//-----------------------------------------------------------------------------\r\nqreal ActiveBusInterfaceItem::getNameLength()\r\n{\r\n    QFont font = getNameLabel()->font();\r\n    return NamelabelWidth::getTextLength(name(), font);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ActiveBusInterfaceItem::shortenNameLabel()\r\n//-----------------------------------------------------------------------------\r\nvoid ActiveBusInterfaceItem::shortenNameLabel(qreal width)\r\n{\r\n    QString nameLabelText = NamelabelWidth::setNameLabel(name(), getNameLabel()->font(), width);\r\n    getNameLabel()->setText(nameLabelText);\r\n\r\n    setLabelPosition();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ActiveBusInterfaceItem::itemChange()\r\n//-----------------------------------------------------------------------------\r\nQVariant ActiveBusInterfaceItem::itemChange(GraphicsItemChange change, QVariant const& value)\r\n{\r\n    if (change == ItemPositionChange)\r\n    {\r\n        QPointF pos = value.toPointF();\r\n\r\n        if (parentItem())\r\n        {\r\n            QRectF parentRect = encompassingComp()->rect();\r\n\r\n            if (pos.x() < 0)\r\n            {\r\n                pos.setX(parentRect.left());\r\n            }\r\n            else\r\n            {\r\n                pos.setX(parentRect.right());\r\n            }\r\n        }\r\n\r\n        return snapPointToGrid(pos);\r\n    }\r\n    else if (change == ItemPositionHasChanged && parentItem())\r\n    {\r\n        checkDirection();\r\n        setLabelPosition();\r\n    }\r\n    else if (change == ItemRotationHasChanged)\r\n    {\r\n        getNameLabel()->setRotation(-rotation());\r\n    }\r\n    else if (change == ItemScenePositionHasChanged)\r\n    {\r\n        updateConnectionPositions();\r\n    }\r\n\r\n    return QGraphicsItem::itemChange(change, value);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ActiveBusInterfaceItem::mousePressEvent()\r\n//-----------------------------------------------------------------------------\r\nvoid ActiveBusInterfaceItem::mousePressEvent(QGraphicsSceneMouseEvent *event)\r\n{\r\n    HWConnectionEndpoint::mousePressEvent(event);  \r\n\r\n    if (sceneIsLocked())\r\n    {\r\n        return;\r\n    }\r\n\r\n    setOldPosition(pos());\r\n    saveOldPortPositions(parentItem()->childItems());\r\n\r\n    beginUpdateConnectionPositions();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ActiveBusInterfaceItem::moveItemByMouse()\r\n//-----------------------------------------------------------------------------\r\nvoid ActiveBusInterfaceItem::moveItemByMouse()\r\n{\r\n    encompassingComp()->onMovePort(this);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ActiveBusInterfaceItem::createMouseMoveCommand()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<QUndoCommand> ActiveBusInterfaceItem::createMouseMoveCommand(DesignDiagram* diagram)\r\n{\r\n    QSharedPointer<QUndoCommand> moveUndoCommand;\r\n\r\n    // Check if the port position was really changed.\r\n    if (getOldPosition() != pos())\r\n    {\r\n        moveUndoCommand = QSharedPointer<QUndoCommand>(new PortMoveCommand(this, getOldPosition(), diagram));\r\n    }\r\n    else\r\n    {\r\n        moveUndoCommand = QSharedPointer<QUndoCommand>(new QUndoCommand());\r\n    }\r\n\r\n    return moveUndoCommand;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ActiveBusInterfaceItem::getOpposingModes()\r\n//-----------------------------------------------------------------------------\r\nQList<General::InterfaceMode> ActiveBusInterfaceItem::getOpposingModes(QSharedPointer<BusInterface> busIf) const\r\n{\r\n    QList<General::InterfaceMode> possibleModes;\r\n\r\n    General::InterfaceMode sourceMode = busIf->getInterfaceMode();\r\n\r\n    if (sourceMode == General::INTERFACE_MODE_COUNT)\r\n    {\r\n        return possibleModes;\r\n    }\r\n\r\n    auto busDef = getLibraryAccess()->getModelReadOnly<BusDefinition>(busIf->getBusType());\r\n    if (busDef != nullptr && busDef->getDirectConnection())\r\n    {\r\n        possibleModes.append(General::getCompatibleInterfaceModesForActiveInterface(sourceMode));\r\n    }\r\n    else\r\n    {\r\n        possibleModes.append(General::getCompatibleInterfaceMode(sourceMode));\r\n    }\r\n\r\n    return possibleModes;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ActiveBusInterfaceItem::getCurrentPosition()\r\n//-----------------------------------------------------------------------------\r\nQPointF ActiveBusInterfaceItem::getCurrentPosition() const\r\n{\r\n    return pos();\r\n}\r\n"
  },
  {
    "path": "editors/HWDesign/ActiveBusInterfaceItem.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ActiveBusInterfaceItem.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: \r\n// Date: \r\n//\r\n// Description:\r\n// HWConnection represents graphically an IP-XACT bus interface in a component instance.\r\n//-----------------------------------------------------------------------------\r\n#ifndef ACTIVEBUSINTERFACEITEM_H\r\n#define ACTIVEBUSINTERFACEITEM_H\r\n\r\n#include <common/graphicsItems/GraphicsItemTypes.h>\r\n\r\n#include <editors/HWDesign/BusInterfaceEndPoint.h>\r\n\r\n#include <IPXACTmodels/Component/PortMap.h>\r\n\r\n#include <QSharedPointer>\r\n#include <QPolygonF>\r\n\r\nclass BusInterface;\r\nclass HWComponentItem;\r\nclass LibraryInterface;\r\nclass DesignDiagram;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! HWConnection represents graphically an IP-XACT bus interface in a component instance\r\n//-----------------------------------------------------------------------------\r\nclass ActiveBusInterfaceItem : public BusInterfaceEndPoint\r\n{\r\n    Q_OBJECT\r\n\r\npublic:\r\n    enum { Type = GFX_TYPE_DIAGRAM_PORT };\r\n\r\n    \r\n    /*!\r\n     *  The constructor.\r\n     *\r\n     *    @param [in] busIf       The bus interface represented by the item.\r\n     *    @param [in] library     The IP-XACT library in use.\r\n     *    @param [in] parent      The parent object.\r\n     */\r\n    ActiveBusInterfaceItem(QSharedPointer<BusInterface> busIf, LibraryInterface* library, HWComponentItem* parent);\r\n\r\n\t/*!\r\n     *  The destructor.\r\n     */\r\n\t~ActiveBusInterfaceItem() final = default;\r\n\r\n    // Disable copying.\r\n    ActiveBusInterfaceItem(ActiveBusInterfaceItem const& rhs) = delete;\r\n    ActiveBusInterfaceItem& operator=(ActiveBusInterfaceItem const& rhs) = delete;\r\n\r\n\t/*!\r\n\t *  Get the graphics item type.\r\n\t *\r\n     *    @return The item type.\r\n\t */\r\n\tint type() const final { return Type; }\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // HWConnectionEndpoint implementation.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    /*!\r\n     *  Returns true if the port represents a hierarchical connection\r\n     */\r\n    bool isHierarchical() const noexcept final;\r\n\r\n    /*!\r\n     *  Sets the endpoint temporary or not temporary. Temporary endpoints can be deleted.\r\n     *\r\n     *    @param [in] temp True if temporary; false if not temporary.\r\n     */\r\n    void setTemporary(bool temp) final;\r\n\r\n    /*!\r\n     *  Returns true if the draw direction is fixed and thus, cannot be changed.\r\n     */\r\n    bool isDirectionFixed() const noexcept final;\r\n\r\n\t/*!\r\n\t *  Set the position of the name label.\r\n\t */\r\n\tvoid setLabelPosition() final;\r\n\r\n\t/*!\r\n\t *  Check the direction of the port and change it if necessary.\r\n\t */\r\n\tvoid checkDirection();\r\n\r\n\t/*!\r\n\t *  Return the correct length of the name label.\r\n\t */\r\n\tqreal getNameLength() final;\r\n\r\n\t/*!\r\n\t *  Shorten the name label to better fit the component.\r\n\t *  \r\n\t *    @param [in] width   The width of the shortened name.\r\n\t */\r\n\tvoid shortenNameLabel( qreal width ) final;\r\n\r\nprotected:\r\n\r\n    /*!\r\n     *  Notifies item state changes.\r\n     *\r\n     *    @param [in] change  The change.\r\n     *    @param [in] value   The new value.\r\n     */\r\n    QVariant itemChange(GraphicsItemChange change, QVariant const& value) final;\r\n\r\n    /*!\r\n     *  Event for mouse press.\r\n     *\r\n     *    @param [in] event   The pressed mouse button.\r\n     */\r\n    void mousePressEvent(QGraphicsSceneMouseEvent *event) final;\r\n\r\nprivate:\r\n    \r\n    /*!\r\n     *  Update the name change to the relevant contained variables.\r\n     *\r\n     *    @param [in] previousName    The previous name of the bus interface.\r\n     *    @param [in] newName         The new name of the bus interface.\r\n     */\r\n    void updateName(QString const& previousName, QString const& newName) final;\r\n\r\n    /*!\r\n     *  Finds the possible opposing modes for a bus interface.\r\n     *\r\n     *    @param [in] busIf   The interface for which the opposing mode is searched.\r\n     *    \r\n     *    @return The possible opposing modes.\r\n     */\r\n    QList<General::InterfaceMode> getOpposingModes(QSharedPointer<BusInterface> busIf) const;\r\n\r\n    /*!\r\n     *  Move by dragging with the mouse.\r\n     */\r\n    void moveItemByMouse() final;\r\n\r\n    /*!\r\n     *  Create a move command for this end point item.\r\n     *\r\n     *    @param [in] diagram     The containing design diagram.\r\n     *\r\n     *    @return The created move command.\r\n     */\r\n    QSharedPointer<QUndoCommand> createMouseMoveCommand(DesignDiagram* diagram) final;\r\n\r\n    /*!\r\n     *  Create move command for an end point that has been moved by the movement of this end point.\r\n     *\r\n     *    @param [in] endPoint            The selected end point.\r\n     *    @param [in] endPointPosition    The new position of the end point.\r\n     *    @param [in] diagram             Design diagram containing the end point.\r\n     *    @param [in] parentCommand       Parent command.\r\n     */\r\n    void createMoveCommandForClashedItem(ConnectionEndpoint* endPoint, QPointF endPointPosition,\r\n        DesignDiagram* diagram, QSharedPointer<QUndoCommand> parentCommand) final;\r\n\r\n    /*!\r\n     *  Check if a connection can be made to the selected connection end point.\r\n     *\r\n     *    @param [in] otherEndPoint   The selected connection end point.\r\n     *\r\n     *    @return True, if the connection can be made, false otherwise.\r\n     */\r\n    bool canConnectToInterface(ConnectionEndpoint const* otherEndPoint) const final;\r\n\r\n    /*!\r\n     *  Get the current position of the end point.\r\n     *\r\n     *    @return The current position of the end point.\r\n     */\r\n    QPointF getCurrentPosition() const final;\r\n};\r\n\r\n#endif // ACTIVEBUSINTERFACEITEM_H\r\n"
  },
  {
    "path": "editors/HWDesign/ActivePortItem.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ActivePortItem.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Joni-Matti Maatta\r\n// Date: 9.2.2012\r\n//\r\n// Description:\r\n// Diagram graphics item for ad-hoc ports.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"ActivePortItem.h\"\r\n\r\n#include \"HWMoveCommands.h\"\r\n\r\n#include <common/IEditProvider.h>\r\n#include <common/graphicsItems/GraphicsConnection.h>\r\n\r\n#include <editors/common/diagramgrid.h>\r\n#include <editors/common/DesignDiagram.h>\r\n#include <editors/common/NamelabelWidth.h>\r\n#include <editors/common/GraphicsItemLabel.h>\r\n#include <editors/HWDesign/HWComponentItem.h>\r\n\r\n#include <IPXACTmodels/common/DirectionTypes.h>\r\n#include <IPXACTmodels/Component/Component.h>\r\n#include <IPXACTmodels/Component/Port.h>\r\n\r\n#include <QBrush>\r\n#include <QFont>\r\n#include <QVector2D>\r\n#include <QGraphicsScene>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ActivePortItem::ActivePortItem()\r\n//-----------------------------------------------------------------------------\r\nActivePortItem::ActivePortItem(QSharedPointer<Port> port, HWComponentItem* parent):\r\nAdHocItem(port, parent->componentModel(), parent)\r\n{\r\n    setPolygon(getPortShape());\r\n\r\n    updateInterface();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ActivePortItem::isHierarchical()\r\n//-----------------------------------------------------------------------------\r\nbool ActivePortItem::isHierarchical() const noexcept\r\n{\r\n    return false;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ActivePortItem::isConnectionValid()\r\n//-----------------------------------------------------------------------------\r\nbool ActivePortItem::isConnectionValid(ConnectionEndpoint const* other) const\r\n{\r\n    if (!AdHocItem::isConnectionValid(other))\r\n    {\r\n        return false;\r\n    }\r\n\r\n    QSharedPointer<Port> thisPort = getPort();\r\n    QSharedPointer<Port> otherPort = other->getPort();\r\n\r\n    if (other->isHierarchical())\r\n    {\r\n        return (thisPort->getDirection() == DirectionTypes::INOUT ||\r\n            otherPort->getDirection() == DirectionTypes::INOUT ||\r\n            thisPort->getDirection() == other->getPort()->getDirection());\r\n    }\r\n    else\r\n    {\r\n        return (thisPort->getDirection() == DirectionTypes::INOUT ||\r\n            otherPort->getDirection() == DirectionTypes::INOUT ||\r\n            (thisPort->getDirection() == DirectionTypes::IN && otherPort->getDirection() == DirectionTypes::OUT) ||\r\n            (thisPort->getDirection() == DirectionTypes::OUT && otherPort->getDirection() == DirectionTypes::IN));\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ActivePortItem::itemChange()\r\n//-----------------------------------------------------------------------------\r\nQVariant ActivePortItem::itemChange(GraphicsItemChange change, QVariant const& value)\r\n{\r\n    if (change == ItemPositionChange)\r\n    {\r\n        QPointF pos = value.toPointF();\r\n\r\n        if (parentItem())\r\n        {\r\n            QRectF parentRect = encompassingComp()->rect();\r\n            if (pos.x() < 0)\r\n            {\r\n                pos.setX(parentRect.left());\r\n            }\r\n            else\r\n            {\r\n                pos.setX(parentRect.right());\r\n            }\r\n        }\r\n\r\n        return snapPointToGrid(pos);\r\n    }\r\n    else if (change == ItemPositionHasChanged && parentItem())\r\n    {\r\n        checkDirection();\r\n        setLabelPosition();\r\n        setTieOffLabelPosition();\r\n    }\r\n    else if (change == ItemRotationHasChanged)\r\n    {\r\n        getNameLabel()->setRotation(-rotation());\r\n        if (getTieOffLabel() != nullptr)\r\n        {\r\n            getTieOffLabel()->setRotation(-rotation());\r\n        }\r\n    }\r\n    else if (change == ItemScenePositionHasChanged)\r\n    {\r\n        // Update the connections.\r\n        updateConnectionPositions();\r\n    }\r\n\r\n    return QGraphicsItem::itemChange(change, value);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ActivePortItem::isDirectionFixed()\r\n//-----------------------------------------------------------------------------\r\nbool ActivePortItem::isDirectionFixed() const noexcept\r\n{\r\n    return true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ActivePortItem::moveItemByMouse()\r\n//-----------------------------------------------------------------------------\r\nvoid ActivePortItem::moveItemByMouse()\r\n{\r\n    encompassingComp()->onMovePort(this);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ActivePortItem::saveOldPortPositions()\r\n//-----------------------------------------------------------------------------\r\nvoid ActivePortItem::saveOldPortPositions()\r\n{\r\n    oldPos_ = pos();\r\n\r\n    // Save old port positions for all ports in the parent component.\r\n    for (QGraphicsItem* item : parentItem()->childItems())\r\n    {\r\n        if (dynamic_cast<ConnectionEndpoint*>(item) != nullptr && item != this)\r\n        {\r\n            auto port = static_cast<ConnectionEndpoint*>(item);\r\n            oldPortPositions_.insert(port, port->pos());\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ActivePortItem::mouseReleaseEvent()\r\n//-----------------------------------------------------------------------------\r\nvoid ActivePortItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)\r\n{\r\n    HWConnectionEndpoint::mouseReleaseEvent(event);\r\n\r\n    auto diagram = dynamic_cast<DesignDiagram*>(scene());\r\n    if (diagram == nullptr)\r\n    {\r\n        // Update the default position in case the graphics are located in other scene than the designer.\r\n        getPort()->setDefaultPos(pos());\r\n\r\n        if (oldPos_ != pos())\r\n        {\r\n            emit moved(this);\r\n        }\r\n\r\n        return;\r\n    }\r\n\r\n    QSharedPointer<QUndoCommand> cmd;\r\n\r\n    // Check if the port position was really changed.\r\n    if (oldPos_ != pos())\r\n    {\r\n        cmd = QSharedPointer<QUndoCommand>(new PortMoveCommand(this, oldPos_, diagram));\r\n    }\r\n    else\r\n    {\r\n        cmd = QSharedPointer<QUndoCommand>(new QUndoCommand());\r\n    }\r\n\r\n    // Determine if the other ports changed their position and create undo commands for them.\r\n    QMap<ConnectionEndpoint*, QPointF>::iterator cur = oldPortPositions_.begin();\r\n    while (cur != oldPortPositions_.end())\r\n    {\r\n        if (cur.key()->pos() != cur.value())\r\n        {\r\n            new PortMoveCommand(static_cast<HWConnectionEndpoint*>(cur.key()), cur.value(), diagram, cmd.data());\r\n        }\r\n\r\n        cur++;\r\n    }\r\n\r\n    oldPortPositions_.clear();\r\n    \r\n    // End the position update for all connections.\r\n    endUpdateConnectionPositions(cmd.data());\r\n\r\n\r\n    // Add the undo command to the edit stack only if it has changes.\r\n    if (cmd->childCount() > 0 || oldPos_ != pos())\r\n    {\r\n        diagram->getEditProvider()->addCommand(cmd);\r\n        cmd->redo();\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ActivePortItem::setLabelPosition()\r\n//-----------------------------------------------------------------------------\r\nvoid ActivePortItem::setLabelPosition()\r\n{\r\n    qreal nameHeight = getNameLabel()->boundingRect().height();\r\n\r\n\t// Check if the port is directed to the left.\r\n\tif (pos().x() < 0)\r\n\t{\r\n        getNameLabel()->setPos( nameHeight / 2, GridSize / 2 );\r\n\t}\r\n\t// Otherwise the port is directed to the right.\r\n\telse\r\n    {\r\n        qreal nameWidth = getNameLabel()->boundingRect().width();\r\n        getNameLabel()->setPos( -nameHeight / 2, GridSize / 2 + nameWidth);\r\n\t}\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ActivePortItem::checkDirection()\r\n//-----------------------------------------------------------------------------\r\nvoid ActivePortItem::checkDirection()\r\n{\r\n\t// Check if the port is directed to the left.\r\n\tif (pos().x() < 0)\r\n\t{\r\n\t\tsetDirection(QVector2D(-1.0f, 0.0f));\r\n\t}\r\n\t// Otherwise the port is directed to the right.\r\n\telse\r\n\t{\r\n\t\tsetDirection(QVector2D(1.0f, 0.0f));\r\n\t}\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ActivePortItem::getNameLength()\r\n//-----------------------------------------------------------------------------\r\nqreal ActivePortItem::getNameLength()\r\n{\r\n    QFont font = getNameLabel()->font();\r\n\r\n\treturn NamelabelWidth::getTextLength(name(), font);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ActivePortItem::shortenNameLabel()\r\n//-----------------------------------------------------------------------------\r\nvoid ActivePortItem::shortenNameLabel( qreal width )\r\n{\r\n    QFont font = getNameLabel()->font();\r\n\tQString nameLabelText = NamelabelWidth::setNameLabel(name(), font, width);\r\n\r\n\tsetLabelPosition();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ActivePortItem::tieOffLabelShouldBeDrawnLeft()\r\n//-----------------------------------------------------------------------------\r\nbool ActivePortItem::labelShouldBeDrawnLeft() const\r\n{\r\n    return pos().x() < 0;\r\n}\r\n"
  },
  {
    "path": "editors/HWDesign/ActivePortItem.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ActivePortItem.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Joni-Matti Maatta\r\n// Date: 9.2.2012\r\n//\r\n// Description:\r\n// Diagram graphics item for ad-hoc ports.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef ACTIVEPORTITEM_H\r\n#define ACTIVEPORTITEM_H\r\n\r\n#include <QSharedPointer>\r\n#include <QVector2D>\r\n\r\n#include <common/graphicsItems/GraphicsItemTypes.h>\r\n\r\n#include <editors/HWDesign/AdHocItem.h>\r\n\r\n#include <QPolygonF>\r\n\r\nclass HWComponentItem;\r\nclass Port;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! ActivePortItem class.\r\n//-----------------------------------------------------------------------------\r\nclass ActivePortItem : public AdHocItem\r\n{\r\n    Q_OBJECT\r\n\r\npublic:\r\n    enum { Type = GFX_TYPE_DIAGRAM_ADHOC_PORT };\r\n\r\n    /*!\r\n     *  The constructor.\r\n     *\r\n     *    @param [in] port    The selected port.\r\n     *    @param [in] parent  The owner of this item.\r\n     */\r\n    ActivePortItem(QSharedPointer<Port> port, HWComponentItem* parent);\r\n\r\n\t/*!\r\n     *  The destructor.\r\n     */\r\n\t~ActivePortItem() final = default;\r\n\r\n    // Disable copying.\r\n    ActivePortItem(ActivePortItem const& rhs) = delete;\r\n    ActivePortItem& operator=(ActivePortItem const& rhs) = delete;\r\n\r\n\t/*!\r\n\t *  Get the type of this graphics item.\r\n\t *\r\n     *    @return AdHoc interface item type.\r\n\t */\r\n\tint type() const final { return Type; }\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // HWConnectionEndpoint implementation.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    /*!\r\n     *  Returns true if the draw direction is fixed and thus, cannot be changed.\r\n     */\r\n    bool isDirectionFixed() const noexcept final;\r\n\r\n    /*!\r\n     *  Returns true if a connection is valid between the two endpoints.\r\n     *\r\n     *    @param [in] other The other endpoint.\r\n     *\r\n     *      @remarks Does not take existing connections into account but simply\r\n     *               validates whether a connection between the endpoints would be valid\r\n     *               in a general case.\r\n     */\r\n    bool isConnectionValid(ConnectionEndpoint const* other) const final;\r\n\r\n    /*!\r\n     *  Check if the port is hierarchical.\r\n     *\r\n     *    @return False, port items are always instance items and thus non-hierarchical.\r\n     */\r\n    bool isHierarchical() const noexcept final;\r\n\r\n\t/*!\r\n\t *  Set the position of the name label.\r\n\t */\r\n\tvoid setLabelPosition() final;\r\n\r\n\t/*!\r\n\t *  Check the direction of the port and change it if necessary.\r\n\t */\r\n\tvoid checkDirection();\r\n\r\n\t/*!\r\n\t *  Gives the length of the text in the name label.\r\n\t */\r\n\tqreal getNameLength();\r\n\t\r\n\t/*!\r\n\t *  Shortens the name label to better fit in the component.\r\n\t *\r\n\t *    @param [in] width   The width of the shortened name.\r\n\t */\r\n    void shortenNameLabel(qreal width) final;\r\n\r\nprotected:\r\n\r\n    /*!\r\n     *  Notifies item state changes.\r\n     *\r\n     *    @param [in] change  The change.\r\n     *    @param [in] value   The new value.\r\n     */\r\n    QVariant itemChange(GraphicsItemChange change, const QVariant &value) final;\r\n\r\n    /*!\r\n     *  Event for mouse button release.\r\n     *\r\n     *    @param [in] event   The release event.\r\n     */\r\n    void mouseReleaseEvent(QGraphicsSceneMouseEvent *event)  final;\r\n\r\nprivate:\r\n\r\n    /*!\r\n     *  Check whether the label should be drawn on the left side of the interface.\r\n     *\r\n     *    @return True, if the label should be drawn to the left side.\r\n     */\r\n    bool labelShouldBeDrawnLeft() const final;\r\n\r\n    /*!\r\n     *  Move the ad hoc item by dragging with the mouse.\r\n     */\r\n    void moveItemByMouse() final;\r\n\r\n    /*!\r\n     *  Save the positions of the other associated ports.\r\n     */\r\n    void saveOldPortPositions() final;\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! The position of the port before mouse move.\r\n    QPointF oldPos_;\r\n\r\n    //! The old positions of the other component ports before mouse move.\r\n    QMap<ConnectionEndpoint*, QPointF> oldPortPositions_;\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n\r\n#endif // ACTIVEPORTITEM_H\r\n"
  },
  {
    "path": "editors/HWDesign/AdHocConnectionItem.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: AdHocConnectionItem.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Esko Pekkarinen\r\n// Date: 02.10.2015\r\n//\r\n// Description:\r\n// Graphical item to represent ad-hoc connections in a design.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"AdHocConnectionItem.h\"\r\n\r\n#include \"HWComponentItem.h\"\r\n#include \"HWMoveCommands.h\"\r\n#include \"HWDesignDiagram.h\"\r\n#include \"HWDesignWidget.h\"\r\n\r\n#include <editors/common/diagramgrid.h>\r\n#include <editors/common/DiagramUtil.h>\r\n\r\n#include <IPXACTmodels/Design/AdHocConnection.h>\r\n\r\n#include <IPXACTmodels/Component/BusInterface.h>\r\n#include <IPXACTmodels/Component/PortMap.h>\r\n\r\n#include <IPXACTmodels/generaldeclarations.h>\r\n\r\n#include <IPXACTmodels/kactusExtensions/ConnectionRoute.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AdHocConnectionItem::AdHocConnectionItem()\r\n//-----------------------------------------------------------------------------\r\nAdHocConnectionItem::AdHocConnectionItem(ConnectionEndpoint* endpoint1, ConnectionEndpoint* endpoint2, \r\n    QSharedPointer<AdHocConnection> adhocConnection, QSharedPointer<ConnectionRoute> route,\r\n    DesignDiagram* parent):\r\n    ConnectionItem(endpoint1, endpoint2, adhocConnection, route, false, parent)\r\n{\r\n    setLineWidth(1);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AdHocConnectionItem::AdHocConnectionItem()\r\n//-----------------------------------------------------------------------------\r\nAdHocConnectionItem::AdHocConnectionItem(QPointF const& p1, QVector2D const& dir1,\r\n    QPointF const& p2, QVector2D const& dir2,\r\n    DesignDiagram* parent):\r\n    ConnectionItem(p1, dir1, p2, dir2, parent)\r\n{\r\n    setLineWidth(1);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AdHocConnectionItem::isBus()\r\n//-----------------------------------------------------------------------------\r\nbool AdHocConnectionItem::isBus() const noexcept\r\n{\r\n    return false;\r\n}\r\n\r\n"
  },
  {
    "path": "editors/HWDesign/AdHocConnectionItem.h",
    "content": "//-----------------------------------------------------------------------------\n// File: AdHocConnectionItem.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Esko Pekkarinen\n// Date: 02.10.2015\n//\n// Description:\n// Graphical item to represent ad-hoc connections in a design.\n//-----------------------------------------------------------------------------\n\n#ifndef ADHOCCONNECTIONITEM_H\n#define ADHOCCONNECTIONITEM_H\n\n#include <QGraphicsPathItem>\n#include <QGraphicsTextItem>\n#include <QUndoCommand>\n\n#include <common/graphicsItems/ConnectionItem.h>\n#include <common/graphicsItems/GraphicsItemTypes.h>\n\n#include <IPXACTmodels/Design/AdHocConnection.h>\n\nclass ConnectionRoute;\n\n//-----------------------------------------------------------------------------\n//! Graphical item to represent ad-hoc connections in a design.\n//-----------------------------------------------------------------------------\nclass AdHocConnectionItem : public ConnectionItem<AdHocConnection>\n{\n    Q_OBJECT\n\npublic:\n    enum { Type = GFX_TYPE_DIAGRAM_ADHOC_CONNECTION };\n  \n    AdHocConnectionItem(QPointF const& p1, QVector2D const& dir1, QPointF const& p2,\n        QVector2D const& dir2, DesignDiagram* parent);\n\n    AdHocConnectionItem(ConnectionEndpoint* endpoint1, ConnectionEndpoint* endpoint2,\n        QSharedPointer<AdHocConnection> adhocConnection, QSharedPointer<ConnectionRoute> route,\n        DesignDiagram* parent);\n\n    virtual ~AdHocConnectionItem() = default;\n\n    // Disable copying.\n    AdHocConnectionItem(AdHocConnectionItem const& rhs) = delete;\n    AdHocConnectionItem& operator=(AdHocConnectionItem const& rhs) = delete;\n\n    /*!\n     *  Returns true if the connection is a bus connection. Returns false if it isn't (i.e. it is an ad-hoc\n     *  connection).\n     */\n    bool isBus() const noexcept;\n\n    /*!\n     *  Get the type of this connection item.\n     *\n     *    @return Ad hoc connection item type.\n     */\n    int type() const final { return Type; }\n\n};\n\n#endif // ADHOCCONNECTIONITEM_H\n"
  },
  {
    "path": "editors/HWDesign/AdHocEnabled.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: AdHocEnabled.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Joni-Matti Maatta\r\n// Date: 27.2.2012\r\n//\r\n// Description:\r\n// Base class for adding ad-hoc support to a derived class.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"AdHocEnabled.h\"\r\n\r\n#include <editors/HWDesign/AdHocItem.h>\r\n\r\n#include <IPXACTmodels/Component/Component.h>\r\n#include <IPXACTmodels/Component/Port.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AdHocEnabled::AdHocEnabled()\r\n//-----------------------------------------------------------------------------\r\nAdHocEnabled::AdHocEnabled()\r\n{\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AdHocEnabled::setAdHocData()\r\n//-----------------------------------------------------------------------------\r\nvoid AdHocEnabled::setAdHocData(QSharedPointer<Component> component, QMap<QString, bool> const& portAdHocVisibilities)\r\n{\r\n    component_ = component;\r\n    portAdHocVisibilities_.clear();\r\n\r\n    // Parse port ad-hoc visibilities.\r\n    if (component->hasPorts())\r\n    {\r\n        for (QSharedPointer<Port> adhocPort : *component->getPorts())\r\n        {\r\n            bool visible = adhocPort->isAdHocVisible();\r\n\r\n            if (portAdHocVisibilities.contains(adhocPort->name()))\r\n            {\r\n                visible = portAdHocVisibilities.value(adhocPort->name());\r\n            }\r\n\r\n            portAdHocVisibilities_.insert(adhocPort->name(), visible);\r\n        }\r\n    }\r\n\r\n    QMapIterator visibilityIterator(portAdHocVisibilities);\r\n    while (visibilityIterator.hasNext())\r\n    {\r\n        visibilityIterator.next();\r\n\r\n        if (!portAdHocVisibilities_.contains(visibilityIterator.key()))\r\n        {\r\n            portAdHocVisibilities_.insert(visibilityIterator.key(), visibilityIterator.value());\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AdHocEnabled::setPortAdHocVisible()\r\n//-----------------------------------------------------------------------------\r\nvoid AdHocEnabled::setPortAdHocVisible(QString const& portName, bool visible)\r\n{\r\n    // Check if the visibility has changed.\r\n    if (portAdHocVisibilities_.value(portName) != visible)\r\n    {\r\n        // Update the value and call onAdHocVisiblityChanged().\r\n        portAdHocVisibilities_.insert(portName, visible);\r\n        onAdHocVisibilityChanged(portName, visible);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AdHocEnabled::isPortAdHocVisible()\r\n//-----------------------------------------------------------------------------\r\nbool AdHocEnabled::isPortAdHocVisible(QString const& portName) const\r\n{\r\n    return portAdHocVisibilities_.value(portName, false);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AdHocEnabled::onAdHocVisibilityChanged()\r\n//-----------------------------------------------------------------------------\r\nvoid AdHocEnabled::onAdHocVisibilityChanged(QString const&, bool)\r\n{\r\n    // Default implementation is empty.\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AdHocEnabled::getPortAdHocVisibilities()\r\n//-----------------------------------------------------------------------------\r\nQMap<QString, bool> AdHocEnabled::getPortAdHocVisibilities() const\r\n{\r\n    return portAdHocVisibilities_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AdHocEnabled::getPorts()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<QList<QSharedPointer<Port> > > AdHocEnabled::getPorts() const\r\n{\r\n    Q_ASSERT(component_ != nullptr);\r\n    return component_->getPorts();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AdHocEnabled::getDiagramAdHocPort()\r\n//-----------------------------------------------------------------------------\r\nHWConnectionEndpoint* AdHocEnabled::getDiagramAdHocPort(QString const&)\r\n{\r\n    return nullptr;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AdHocEnabled::createAdhocItem()\r\n//-----------------------------------------------------------------------------\r\nAdHocItem* AdHocEnabled::createAdhocItem(QString const&)\r\n{\r\n    return nullptr;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AdHocEnabled::changeAdhocVisibility()\r\n//-----------------------------------------------------------------------------\r\nvoid AdHocEnabled::changeAdhocVisibility(AdHocItem* portItem, bool newVisibility)\r\n{\r\n    // Check if the visibility has changed.\r\n    if (portAdHocVisibilities_.value(portItem->name()) != newVisibility || portItem->getPort()->isAdHocVisible())\r\n    {\r\n        if (!portAdHocVisibilities_.contains(portItem->name()) || !portItem->getPort()->isAdHocVisible())\r\n        {\r\n            // Update the value and call onAdHocVisiblityChanged().\r\n            portAdHocVisibilities_.insert(portItem->name(), newVisibility);\r\n        }\r\n\r\n        if (newVisibility == true)\r\n        {\r\n            showAdhocPort(portItem);\r\n        }\r\n        else\r\n        {\r\n            hideAdhocPort(portItem);\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AdHocEnabled::showAdhocPort()\r\n//-----------------------------------------------------------------------------\r\nvoid AdHocEnabled::showAdhocPort(AdHocItem*)\r\n{\r\n    // Intentionally empty.\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AdHocEnabled::hideAdhocPort()\r\n//-----------------------------------------------------------------------------\r\nvoid AdHocEnabled::hideAdhocPort(AdHocItem*)\r\n{\r\n    // Intentionally empty.\r\n}\r\n"
  },
  {
    "path": "editors/HWDesign/AdHocEnabled.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: AdHocEnabled.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Joni-Matti Maatta\r\n// Date: 27.2.2012\r\n//\r\n// Description:\r\n// Base class for adding ad-hoc support to a derived class.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef ADHOCENABLED_H\r\n#define ADHOCENABLED_H\r\n\r\n#include <IPXACTmodels/Component/Component.h>\r\n\r\n#include <QString>\r\n#include <QSharedPointer>\r\n#include <QMap>\r\n\r\nclass Port;\r\nclass HWConnectionEndpoint;\r\nclass GenericEditProvider;\r\nclass AdHocVisibilityEditor;\r\nclass AdHocItem;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Base class for adding ad-hoc support to a derived class.\r\n//-----------------------------------------------------------------------------\r\nclass AdHocEnabled\r\n{\r\npublic:\r\n    /*!\r\n     *  Constructor.\r\n     */\r\n    AdHocEnabled();\r\n\r\n    virtual ~AdHocEnabled() = default;\r\n\r\n    // Disable copying.\r\n    AdHocEnabled(AdHocEnabled const& rhs) = delete;\r\n    AdHocEnabled& operator=(AdHocEnabled const& rhs) = delete;\r\n\r\n    /*!\r\n     *  Sets the ad-hoc data based on the given component and saved port ad-hoc visibilities.\r\n     *\r\n     *    @param [in] component              The component whose ports are considered.\r\n     *    @param [in] portAdHocVisibilities  The saved ad-hoc visibilities for the ports.\r\n     */\r\n    void setAdHocData(QSharedPointer<Component> component,\r\n                      QMap<QString, bool> const& portAdHocVisibilities = QMap<QString, bool>());\r\n\r\n    /*!\r\n     *  Sets the ad-hoc visibility of the given port.\r\n     *\r\n     *    @param [in] portName The name of the port.\r\n     *    @param [in] visible  If true, the port is set visible for ad-hoc.\r\n     */\r\n    void setPortAdHocVisible(QString const& portName, bool visible);\r\n\r\n    /*!\r\n     *  Returns true if the given port is currently visible for ad-hoc.\r\n     *\r\n     *    @param [in] portName The name of the port.\r\n     */\r\n    bool isPortAdHocVisible(QString const& portName) const;\r\n\r\n    /*!\r\n     *  Returns the ad-hoc visibility map.\r\n     */\r\n    QMap<QString, bool> getPortAdHocVisibilities() const;\r\n\r\n    /*!\r\n     *  Returns the list of ports.\r\n     */\r\n    QSharedPointer<QList<QSharedPointer<Port> > > getPorts() const;\r\n\r\n    /*!\r\n     *  Called when a port's ad-hoc visibility has been changed.\r\n     *\r\n     *    @param [in] portName  The name of the port.\r\n     *    @param [in] visible   The new ad-hoc visibility.\r\n     */\r\n    virtual void onAdHocVisibilityChanged(QString const& portName, bool visible);\r\n\r\n    /*!\r\n     *  Attaches the data source to an ad-hoc editor.\r\n     */\r\n    virtual void attach(AdHocVisibilityEditor* editor) = 0;\r\n\r\n    /*!\r\n     *  Detaches the data source from the ad-hoc editor.\r\n     */\r\n    virtual void detach(AdHocVisibilityEditor* editor) = 0;\r\n\r\n    /*!\r\n     *  Get the name of the ad hoc enabled item.\r\n     *\r\n     *    @return The name of the ad hoc enabled item.\r\n     */\r\n    virtual QString adHocIdentifier() const = 0;\r\n\r\n    /*!\r\n     *  Returns the ad-hoc port with the given name or null if not found.\r\n     */\r\n    virtual HWConnectionEndpoint* getDiagramAdHocPort(QString const& portName);\r\n\r\n    /*!\r\n     *  Create an ad hoc port item with the selected name.\r\n     *\r\n     *    @param [in] portName    The selected port name.\r\n     *\r\n     *    @return 0. Child items should create their own items where desired.\r\n     */\r\n    virtual AdHocItem* createAdhocItem(QString const& portName);\r\n\r\n    /*!\r\n     *  Change the visibility of an ad hoc port item.\r\n     *\r\n     *    @param [in] portItem        The selected port item.\r\n     *    @param [in] newVisibility   The new visibility of the port item.\r\n     */\r\n    void changeAdhocVisibility(AdHocItem* portItem, bool newVisibility);\r\n\r\nprivate:\r\n\r\n    /*!\r\n     *  Show an ad hoc port item.\r\n     *\r\n     *    @param [in] portItem    The selected item.\r\n     */\r\n    virtual void showAdhocPort(AdHocItem* portItem);\r\n\r\n    /*!\r\n     *  Hide an ad hoc port item.\r\n     *\r\n     *    @param [in] portItem    The selected item.\r\n     */\r\n    virtual void hideAdhocPort(AdHocItem* portItem);\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! The component whose ports to consider.\r\n    QSharedPointer<Component> component_ = nullptr;\r\n\r\n    //! The ad-hoc visibility flags for ports.\r\n    QMap<QString, bool> portAdHocVisibilities_;\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n\r\n#endif // ADHOCENABLED_H\r\n"
  },
  {
    "path": "editors/HWDesign/AdHocItem.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: AdHocItem.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Mikko Teuho\r\n// Date: 03.05.2016\r\n//\r\n// Description:\r\n// Parent graphics item for ad-hoc ports.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"AdHocItem.h\"\r\n\r\n#include <common/graphicsItems/GraphicsConnection.h>\r\n\r\n#include <editors/common/DesignDiagram.h>\r\n#include <editors/common/GraphicsItemLabel.h>\r\n\r\n#include <QPen>\r\n#include <QFont>\r\n#include <QGraphicsDropShadowEffect>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AdHocItem::AdHocItem()\r\n//-----------------------------------------------------------------------------\r\nAdHocItem::AdHocItem(QSharedPointer<Port> port, QSharedPointer<Component> containingComponent,\r\n    QGraphicsItem* parent, QVector2D const& dir):\r\n    HWConnectionEndpoint(port->name(), containingComponent, parent, dir),\r\n    port_(port)\r\n{\r\n    Q_ASSERT_X(port, \"AdHocPortItem constructor\", \"Null Port pointer given as parameter\");\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AdHocItem::getPortShape()\r\n//-----------------------------------------------------------------------------\r\nQPolygonF AdHocItem::getPortShape() const\r\n{\r\n    QPolygonF shape;\r\n    if (port_->getDirection() == DirectionTypes::IN)\r\n    {\r\n        if (isHierarchical())\r\n        {\r\n            shape = getInPortShape();\r\n        }\r\n        else\r\n        {\r\n            shape = getOutPortShape();\r\n        }\r\n    }\r\n    else if (port_->getDirection() == DirectionTypes::OUT)\r\n    {\r\n        if (isHierarchical())\r\n        {\r\n            shape = getOutPortShape();\r\n        }\r\n        else\r\n        {\r\n            shape = getInPortShape();\r\n        }\r\n    }\r\n    else\r\n    {\r\n        shape = QPolygonF({ QPointF(-SQUARE_SIZE / 2, SQUARE_SIZE / 2),\r\n            QPointF(-SQUARE_SIZE / 2, -SQUARE_SIZE / 2),\r\n            QPointF(0, -SQUARE_SIZE),\r\n            QPointF(SQUARE_SIZE / 2, -SQUARE_SIZE / 2),\r\n            QPointF(SQUARE_SIZE / 2, SQUARE_SIZE / 2),\r\n            QPointF(0, SQUARE_SIZE),\r\n            });\r\n    }\r\n\r\n    return shape;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AdHocItem::getInPortShape()\r\n//-----------------------------------------------------------------------------\r\nQPolygonF AdHocItem::getInPortShape()\r\n{\r\n    constexpr int halfSquare = SQUARE_SIZE / 2;\r\n\r\n    QPolygonF shape({\r\n        QPointF(-halfSquare, halfSquare),\r\n        QPointF(-halfSquare, -halfSquare),\r\n        QPointF(0, -SQUARE_SIZE),\r\n        QPointF(halfSquare, -halfSquare),\r\n        QPointF(halfSquare, halfSquare),\r\n    });\r\n\r\n    return shape;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AdHocItem::getOutPortShape()\r\n//-----------------------------------------------------------------------------\r\nQPolygonF AdHocItem::getOutPortShape()\r\n{\r\n    constexpr int halfSquare = SQUARE_SIZE / 2;\r\n\r\n    QPolygonF shape({\r\n        QPointF(-halfSquare, halfSquare),\r\n        QPointF(-halfSquare, -halfSquare),\r\n        QPointF(halfSquare, -halfSquare),\r\n        QPointF(halfSquare, halfSquare),\r\n        QPointF(0, SQUARE_SIZE),\r\n    });\r\n\r\n    return shape;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AdHocItem::updateEndPointGraphics()\r\n//-----------------------------------------------------------------------------\r\nvoid AdHocItem::updateEndPointGraphics()\r\n{\r\n    if (adhocPortIsValid())\r\n    {\r\n        setBrush(QBrush(Qt::black));\r\n    }\r\n    else\r\n    {\r\n        setBrush(QBrush(Qt::red));\r\n    }\r\n\r\n    setTieOffLabelPosition();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AdHocItem::adhocPortIsValid()\r\n//-----------------------------------------------------------------------------\r\nbool AdHocItem::adhocPortIsValid() const\r\n{\r\n    bool portExists = (getOwnerComponent()->getPort(getPort()->name()).isNull() == false);\r\n    return portExists;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AdHocItem::name()\r\n//-----------------------------------------------------------------------------\r\nQString AdHocItem::name() const\r\n{\r\n    return port_->name();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AdHocItem::description()\r\n//-----------------------------------------------------------------------------\r\nQString AdHocItem::description() const\r\n{\r\n    Q_ASSERT(port_);\r\n    if (port_)\r\n    {\r\n        return port_->description();\r\n    }\r\n    else\r\n    {\r\n        return QString();\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AdHocItem::setDescription()\r\n//-----------------------------------------------------------------------------\r\nvoid AdHocItem::setDescription(QString const& description)\r\n{\r\n    Q_ASSERT(port_);\r\n    if (port_)\r\n    {\r\n        port_->setDescription(description);\r\n        emit contentChanged();\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AdHocItem::onConnect()\r\n//-----------------------------------------------------------------------------\r\nbool AdHocItem::onConnect(ConnectionEndpoint const* )\r\n{\r\n    return true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AdHocItem::isExclusive()\r\n//-----------------------------------------------------------------------------\r\nbool AdHocItem::isExclusive() const\r\n{\r\n    // Ad-hoc ports are always non-exclusive.\r\n    return false;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AdHocItem::getBusInterface()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<BusInterface> AdHocItem::getBusInterface() const\r\n{\r\n    return nullptr;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AdHocItem::isAdHoc()\r\n//-----------------------------------------------------------------------------\r\nbool AdHocItem::isAdHoc() const noexcept\r\n{\r\n    return true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AdHocItem::getType()\r\n//-----------------------------------------------------------------------------\r\nConnectionEndpoint::EndpointType AdHocItem::getType() const noexcept\r\n{\r\n    return ConnectionEndpoint::ENDPOINT_TYPE_ADHOC;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AdHocItem::getPort()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<Port> AdHocItem::getPort() const\r\n{\r\n    return port_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AdHocItem::setPort()\r\n//-----------------------------------------------------------------------------\r\nvoid AdHocItem::setPort(QSharedPointer<Port> newPort)\r\n{\r\n    port_ = newPort;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AdHocItem::changeTieOffLabel()\r\n//-----------------------------------------------------------------------------\r\nvoid AdHocItem::changeTieOffLabel(QString const& tieOffExpression, QString const& tieOffValue,\r\n    bool tieOffIsSupported)\r\n{\r\n    if (tieOffLabel_ == 0)\r\n    {\r\n        createTieOffLabel();\r\n    }\r\n\r\n    QString tieOffText = tieOffValue;\r\n    if (!tieOffIsSupported && tieOffExpression.compare(QLatin1String(\"open\"), Qt::CaseInsensitive) != 0)\r\n    {\r\n        tieOffText = QStringLiteral(\"n/a\");\r\n    }\r\n\r\n    if (tieOffText.size() > 4)\r\n    {\r\n        tieOffText = tieOffValue.left(4) + QStringLiteral(\"...\");\r\n    }\r\n\r\n    tieOffLabel_->setText(tieOffText);\r\n    tieOffLabel_->setToolTip(tieOffExpression);\r\n\r\n    setTieOffLabelPosition();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AdHocItem::createTieOffLabel()\r\n//-----------------------------------------------------------------------------\r\nvoid AdHocItem::createTieOffLabel()\r\n{\r\n    tieOffLabel_ = new GraphicsItemLabel(QString(), this);\r\n\r\n    QFont font = tieOffLabel_->font();\r\n    font.setPointSize(8);\r\n    tieOffLabel_->setFont(font);\r\n    tieOffLabel_->setRotation(-rotation());\r\n\r\n    createTieOffPath();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AdHocItem::createTieOffPath()\r\n//-----------------------------------------------------------------------------\r\nvoid AdHocItem::createTieOffPath()\r\n{\r\n    if (tieOffPath_ == nullptr)\r\n    {\r\n        QPainterPath pathToTieOff;\r\n        pathToTieOff.addRect(0, -TIEOFFITEM_DISTANCE, 1, TIEOFFITEM_DISTANCE);\r\n        tieOffPath_ = new QGraphicsPathItem(pathToTieOff, this);\r\n        tieOffPath_->setFlag(ItemStacksBehindParent);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AdHocItem::setTieOffLabelPosition()\r\n//-----------------------------------------------------------------------------\r\nvoid AdHocItem::setTieOffLabelPosition()\r\n{\r\n    if (tieOffLabel_ != nullptr)\r\n    {\r\n        qreal labelHeight = tieOffLabel_->boundingRect().height();\r\n        qreal labelWidth = tieOffLabel_->boundingRect().width();\r\n\r\n        if (labelShouldBeDrawnLeft())\r\n        {\r\n            tieOffLabel_->setPos(labelHeight / 2, -(TIEOFFITEM_DISTANCE-5) - labelWidth);\r\n        }\r\n        else\r\n        {\r\n            tieOffLabel_->setPos( -labelHeight / 2, -(TIEOFFITEM_DISTANCE-5));\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AdHocItem::removeTieOffItem()\r\n//-----------------------------------------------------------------------------\r\nvoid AdHocItem::removeTieOffItem()\r\n{\r\n    delete tieOffPath_;\r\n    tieOffPath_ = nullptr;\r\n\r\n    delete tieOffLabel_;\r\n    tieOffLabel_ = nullptr;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AdHocItem::getTieOffLabel()\r\n//-----------------------------------------------------------------------------\r\nGraphicsItemLabel* AdHocItem::getTieOffLabel()\r\n{\r\n    return tieOffLabel_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AdHocItem::isConnectionValid()\r\n//-----------------------------------------------------------------------------\r\nbool AdHocItem::isConnectionValid(ConnectionEndpoint const* other) const\r\n{\r\n    return HWConnectionEndpoint::isConnectionValid(other) && !other->isBus();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AdHocItem::mousePressEvent()\r\n//-----------------------------------------------------------------------------\r\nvoid AdHocItem::mousePressEvent(QGraphicsSceneMouseEvent *event)\r\n{\r\n    HWConnectionEndpoint::mousePressEvent(event);\r\n\r\n    saveOldPortPositions();\r\n\r\n    beginUpdateConnectionPositions();\r\n}\r\n"
  },
  {
    "path": "editors/HWDesign/AdHocItem.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: AdHocItem.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Mikko Teuho\r\n// Date: 03.05.2016\r\n//\r\n// Description:\r\n// Parent graphics item for ad-hoc ports.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef ADHOCITEM_H\r\n#define ADHOCITEM_H\r\n\r\n#include \"HWConnectionEndpoint.h\"\r\n\r\n#include <editors/common/diagramgrid.h>\r\n\r\n#include <QSharedPointer>\r\n#include <QVector2D>\r\n#include <QPolygonF>\r\n\r\nclass Port;\r\nclass GraphicsItemLabel;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Parent graphics item for ad-hoc ports.\r\n//-----------------------------------------------------------------------------\r\nclass AdHocItem : public HWConnectionEndpoint\r\n{\r\n    Q_OBJECT\r\n\r\npublic:\r\n\r\n    /*!\r\n     *  The constructor.\r\n     *\r\n     *    @param [in] port                    The selected port.\r\n     *    @param [in] containingComponent     Component containing the port.\r\n     *    @param [in] parent                  The owner of this item.\r\n     *    @param [in] dir                     The direction of the item.\r\n     */\r\n    AdHocItem(QSharedPointer<Port> port, QSharedPointer<Component> containingComponent, QGraphicsItem* parent = 0,\r\n        QVector2D const& dir = QVector2D(0.0f, -1.0f));\r\n\r\n\t/*!\r\n     *  The destructor.\r\n     */\r\n\t~AdHocItem() override = default;\r\n\r\n    // Disable copying.\r\n    AdHocItem(AdHocItem const& rhs) = delete;\r\n    AdHocItem& operator=(AdHocItem const& rhs) = delete;\r\n\r\n    /*!\r\n     *  Check if the ad hoc port is valid or not.\r\n     *\r\n     *    @return True, if the port is valid, otherwise false.\r\n     */\r\n    bool adhocPortIsValid() const;\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // HWConnectionEndpoint implementation.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    /*!\r\n     *  Returns the name of the ad-hoc port.\r\n     *\r\n     *    @return The name of the ad hoc port.\r\n     */\r\n    QString name() const override;\r\n\r\n\t/*!\r\n     *  Returns the description of the port.\r\n     *\r\n     *    @return The description of the port.\r\n     */\r\n\tQString description() const override;\r\n\r\n\t/*!\r\n     *  Sets the description of the port.\r\n     *\r\n     *    @param [in] description The description to set.\r\n     */\r\n\tvoid setDescription(QString const& description) override;\r\n\r\n    /*!\r\n     *  Called when a connection between this and another end point is done.\r\n     *\r\n     *    @param [in] other The other end point of the connection.\r\n     *\r\n     *    @return False if there was an error in the connection. Otherwise true.\r\n     */\r\n    bool onConnect(ConnectionEndpoint const* other) override;\r\n\r\n    /*!\r\n     *  Check if the port is exclusive, i.e. can only have one connection.\r\n     *\r\n     *    @return False. Ad hoc ports are always non-exclusive.\r\n     */\r\n    bool isExclusive() const final;\r\n\r\n    /*! \r\n     *  Returns the IP-XACT bus interface model of the port.\r\n     *\r\n     *    @return Ad hoc interfaces do not have a bus interface, returns an empty pointer.\r\n     */\r\n    QSharedPointer<BusInterface> getBusInterface() const override;\r\n\r\n    /*!\r\n     *  Returns the ad-hoc port of the end point.\r\n     *\r\n     *      @remarks The function returns a null pointer if the end point is a bus interface.\r\n     *               Use isBus() function to check for ad-hoc support (isBus() == false).\r\n     *\r\n     *    @return The ad hoc port of the item.\r\n     */\r\n    QSharedPointer<Port> getPort() const override;\r\n\r\n    void setPort(QSharedPointer<Port> newPort);\r\n\r\n    /*!\r\n     *  Check if the end point is an ad hoc port.\r\n     *\r\n     *    @return True, if the end point is an ad hoc port, false otherwise.\r\n     */\r\n    bool isAdHoc() const noexcept override;\r\n\r\n    /*!\r\n     *  Returns the type of the endpoint (API/COM/bus/ad-hoc/undefined).\r\n     */\r\n    ConnectionEndpoint::EndpointType getType() const noexcept override;\r\n\r\n    /*!\r\n     *  Create or change the current tie off label.\r\n     *\r\n     *    @param [in] tieOffExpression    The expression containing the tie off.\r\n     *    @param [in] tieOffValue         The formatted tie off value.\r\n     *    @param [in] tieOffIsSupported   Flag for determining whether the tie off is supported or not.\r\n     */\r\n    void changeTieOffLabel(QString const& tieOffExpression, QString const& tieOffValue, bool tieOffIsSupported);\r\n\r\n    /*!\r\n     *  Remove the tie off symbol.\r\n     */\r\n    void removeTieOffItem();\r\n\r\n    /*!\r\n     *  Check if a connection to the selected connection end point is valid.\r\n     *\r\n     *    @param [in] other   The selected connection end point.\r\n     *\r\n     *    @return True, if the connection can be created, false otherwise.\r\n     */\r\n    bool isConnectionValid(ConnectionEndpoint const* other) const override;\r\n\r\nprotected:\r\n\r\n    /*!\r\n     *  Get the shape of the item.\r\n     *\r\n     *    @return Polygon containing the shape of the item.\r\n     */\r\n    QPolygonF getPortShape() const;\r\n\r\n    /*!\r\n     *  Get the tie off label of the item.\r\n     *\r\n     *    @return The label item containing the current tie off.\r\n     */\r\n    GraphicsItemLabel* getTieOffLabel();\r\n\r\n    /*!\r\n     *  Set the position for the tie off label.\r\n     */\r\n    void setTieOffLabelPosition();\r\n\r\n    /*!\r\n     *  Event handling for mouse press.\r\n     *\r\n     *    @param [in] event   The mouse press event.\r\n     */\r\n    void mousePressEvent(QGraphicsSceneMouseEvent *event) override;\r\n\r\nprivate:\r\n\r\n    /*!\r\n     *  Get the shape of an in port.\r\n     *\r\n     *    @return Polygon containing the shape of an in port.\r\n     */\r\n    static QPolygonF getInPortShape();\r\n\r\n    /*!\r\n     *  Get the shape of an out port.\r\n     *\r\n     *    @return Polygon containing the shape of an out port.\r\n     */\r\n    static QPolygonF getOutPortShape();\r\n\r\n    /*!\r\n     *  Create the tie off label.\r\n     */\r\n    void createTieOffLabel();\r\n\r\n    /*!\r\n     *  Create the graphical path connecting the tie off to the selected port.\r\n     */\r\n    void createTieOffPath();\r\n\r\n    /*!\r\n     *  Check whether the label should be drawn on the left side of the interface.\r\n     *\r\n     *    @return True, if the label should be drawn to the left side.\r\n     */\r\n    virtual bool labelShouldBeDrawnLeft() const = 0;\r\n\r\n    /*!\r\n     *  Store the positions of the associated end points.\r\n     */\r\n    virtual void saveOldPortPositions() = 0;\r\n\r\n    /*!\r\n     *  Update the graphics of the end point.\r\n     */\r\n    virtual void updateEndPointGraphics();\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    static constexpr int SQUARE_SIZE = GridSize - 4;\r\n    static constexpr int TIEOFFITEM_DISTANCE = 20;\r\n\r\n    //! The port contained within the item.\r\n    QSharedPointer<Port> port_ = nullptr;\r\n\r\n    //! The tie off label.\r\n    GraphicsItemLabel* tieOffLabel_ = nullptr;\r\n\r\n    //! The path connecting the tie off label to this item.\r\n    QGraphicsItem* tieOffPath_ = nullptr;\r\n\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n\r\n#endif // ADHOCITEM_H\r\n"
  },
  {
    "path": "editors/HWDesign/AdhocEditor/AdHocVisibilityColumns.h",
    "content": "//-----------------------------------------------------------------------------\n// File: AdHocVisibilityColumns.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 30.10.2015\n//\n// Description:\n// Common declarations for ad hoc columns.\n//-----------------------------------------------------------------------------\n\n#ifndef ADHOCVISIBILITYCOLUMNS_H\n#define ADHOCVISIBILITYCOLUMNS_H\n\nnamespace AdHocVisibilityColumns\n{\n    //! Defines the columns for the ad hoc table.\n    enum Columns\n    {\n        ADHOC_COL_NAME = 0,          //!< Column for the port name.\n        ADHOC_COL_DIRECTION,         //!< Column for the port direction.\n        ADHOC_COL_VISIBILITY,        //!< Column for toggling ad-hoc visibility on/off.\n        ADHOC_COL_COUNT\n    };\n}\n\n#endif //ADHOCVISIBILITYCOLUMNS_H"
  },
  {
    "path": "editors/HWDesign/AdhocEditor/AdHocVisibilityDelegate.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: AdHocVisibilityDelegate.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Joni-Matti Maatta\n// Date: 20.2.2012\n//\n// Description:\n// Delegate for the table visualizing ad-hoc visibility for component ports.\n//-----------------------------------------------------------------------------\n\n#include \"AdHocVisibilityDelegate.h\"\n#include \"AdHocVisibilityColumns.h\"\n\n#include <QLabel>\n#include <QApplication>\n#include <QMouseEvent>\n#include <QPainter>\n\n//-----------------------------------------------------------------------------\n// Function: AdHocVisibilityDelegate::AdHocVisibilityDelegate()\n//-----------------------------------------------------------------------------\nAdHocVisibilityDelegate::AdHocVisibilityDelegate(QObject *parent /*= 0*/):\nQStyledItemDelegate(parent),\nadhocGroupModify_(false),\nadhocGroupState_(Qt::Unchecked)\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: AdHocVisibilityDelegate::~AdHocVisibilityDelegate()\n//-----------------------------------------------------------------------------\nAdHocVisibilityDelegate::~AdHocVisibilityDelegate()\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: AdHocVisibilityDelegate::createEditor()\n//-----------------------------------------------------------------------------\nQWidget* AdHocVisibilityDelegate::createEditor(QWidget* parent, QStyleOptionViewItem const& option,\n                                     QModelIndex const& index) const\n{\n    if (index.column() == AdHocVisibilityColumns::ADHOC_COL_NAME ||\n        index.column() == AdHocVisibilityColumns::ADHOC_COL_DIRECTION)\n    {\n        QLabel* label = new QLabel(parent);\n        return label;\n    }\n\n    else\n    {\n        return QStyledItemDelegate::createEditor(parent, option, index);\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: AdHocVisibilityDelegate::setEditorData()\n//-----------------------------------------------------------------------------\nvoid AdHocVisibilityDelegate::setEditorData(QWidget* editor, const QModelIndex& index) const\n{\n    if (index.column() == AdHocVisibilityColumns::ADHOC_COL_NAME ||\n        index.column() == AdHocVisibilityColumns::ADHOC_COL_DIRECTION)\n    {\n        QString text = index.model()->data(index, Qt::DisplayRole).toString();\n        QLabel* label = qobject_cast<QLabel*>(editor);\n        label->setText(text);\n    }\n    else\n    {\n        QStyledItemDelegate::setEditorData(editor, index);\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: AdHocVisibilityDelegate::setModelData()\n//-----------------------------------------------------------------------------\nvoid AdHocVisibilityDelegate::setModelData(QWidget* editor, QAbstractItemModel* model, QModelIndex const& index)\n    const\n{\n    QStyledItemDelegate::setModelData(editor, model, index);\n}\n\n//-----------------------------------------------------------------------------\n// Function: AdHocVisibilityDelegate::paint()\n//-----------------------------------------------------------------------------\nvoid AdHocVisibilityDelegate::paint(QPainter *painter, QStyleOptionViewItem const& option,\n    QModelIndex const& index) const\n{\n\tQStyleOptionViewItem viewItemOption(option);\n\n    if (index.column() == AdHocVisibilityColumns::ADHOC_COL_VISIBILITY)\n    {\n        painter->fillRect(option.rect, Qt::white);\n\n        const int textMargin = QApplication::style()->pixelMetric(QStyle::PM_FocusFrameHMargin) + 1;\n\n        QRect newRect = QStyle::alignedRect(option.direction, Qt::AlignCenter,\n            QSize(option.decorationSize.width() + 5, option.decorationSize.height()),\n            QRect(option.rect.x() + textMargin, option.rect.y(),\n            option.rect.width() - (2 * textMargin), option.rect.height()));\n        viewItemOption.rect = newRect;\n    }\n\n    QStyledItemDelegate::paint(painter, viewItemOption, index);\n}\n\n//-----------------------------------------------------------------------------\n// Function: AdHocVisibilityDelegate::editorEvent()\n//-----------------------------------------------------------------------------\nbool AdHocVisibilityDelegate::editorEvent(QEvent* event, QAbstractItemModel* model,\n    QStyleOptionViewItem const& option, QModelIndex const& index)\n{\n    Q_ASSERT(event);\n    Q_ASSERT(model);\n\n    // Always reset the ad-hoc group modify flag.\n    if (event->type() == QEvent::MouseButtonRelease)\n    {\n        adhocGroupModify_ = false;\n    }\n\n    // Make sure that the item is checkable.\n    Qt::ItemFlags flags = model->flags(index);\n\n    if (!(flags & Qt::ItemIsUserCheckable) || !(flags & Qt::ItemIsEnabled))\n    {\n        return false;\n    }\n\n    // Make sure that we have a check state.\n    QVariant value = index.data(Qt::CheckStateRole);\n\n    if (!value.isValid())\n    {\n        return false;\n    }\n\n    Qt::CheckState newState = static_cast<Qt::CheckState>(value.toInt());\n\n    // Handle the mouse button events.\n    if (event->type() == QEvent::MouseButtonPress)\n    {\n        const int textMargin = QApplication::style()->pixelMetric(QStyle::PM_FocusFrameHMargin) + 1;\n\n        QRect checkRect = QStyle::alignedRect(option.direction, Qt::AlignCenter,\n            option.decorationSize,\n            QRect(option.rect.x() + (2 * textMargin), option.rect.y(),\n            option.rect.width() - (2 * textMargin),\n            option.rect.height()));\n\n        if (!checkRect.contains(static_cast<QMouseEvent*>(event)->pos()))\n        {\n            return false;\n        }\n\n        newState = (static_cast<Qt::CheckState>(value.toInt()) == Qt::Checked ? Qt::Unchecked : Qt::Checked);\n        adhocGroupModify_ = true;\n        adhocGroupState_ = newState;\n    }\n    else if (event->type() == QEvent::MouseMove)\n    {\n        if (!adhocGroupModify_ || static_cast<Qt::CheckState>(value.toInt()) == adhocGroupState_)\n        {\n            return false;\n        }\n\n        const int textMargin = QApplication::style()->pixelMetric(QStyle::PM_FocusFrameHMargin) + 1;\n\n        QRect checkRect = QStyle::alignedRect(option.direction, Qt::AlignCenter,\n            option.decorationSize,\n            QRect(option.rect.x() + (2 * textMargin), option.rect.y(),\n            option.rect.width() - (2 * textMargin),\n            option.rect.height()));\n\n        if (!checkRect.contains(static_cast<QMouseEvent*>(event)->pos()))\n        {\n            return false;\n        }\n\n        newState = adhocGroupState_;\n    }\n    else if (event->type() == QEvent::KeyPress)\n    {\n        if (static_cast<QKeyEvent*>(event)->key() != Qt::Key_Space &&\n            static_cast<QKeyEvent*>(event)->key() != Qt::Key_Select)\n        {\n            return false;\n        }\n    }\n    else\n    {\n        return false;\n    }\n\n    return model->setData(index, newState, Qt::CheckStateRole);\n}\n"
  },
  {
    "path": "editors/HWDesign/AdhocEditor/AdHocVisibilityDelegate.h",
    "content": "//-----------------------------------------------------------------------------\n// File: AdHocVisibilityDelegate.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Joni-Matti Maatta\n// Date: 20.2.2012\n//\n// Description:\n// Delegate for the table visualizing ad-hoc visibility for component ports.\n//-----------------------------------------------------------------------------\n\n#ifndef ADHOCVISIBILITYDELEGATE_H\n#define ADHOCVISIBILITYDELEGATE_H\n\n#include <QStyledItemDelegate>\n\n//-----------------------------------------------------------------------------\n//! Delegate for the table visualizing ad-hoc visibility for component ports.\n//-----------------------------------------------------------------------------\nclass AdHocVisibilityDelegate : public QStyledItemDelegate\n{\n\tQ_OBJECT\n\npublic:\n\n\t/*!\n\t *  Constructor.\n     *\n\t *    @param [in] parent Pointer to the owner of this instance.\n\t */\n\tAdHocVisibilityDelegate(QObject *parent = 0);\n\t\n\t/*!\n     *  Destructor.\n     */\n\tvirtual ~AdHocVisibilityDelegate();\n\n\t/*!\n     *  Creates a new editor for the given item.\n\t *\n\t *    @param [in] parent  Owner for the editor.\n\t *    @param [in] option  Contains options for the editor.\n\t *    @param [in] index   Model index identifying the item.\n\t *\n\t *    @return The editor to be used to edit the item.\n\t */\n\tvirtual QWidget* createEditor(QWidget* parent, QStyleOptionViewItem const& option, QModelIndex const& index)\n        const;\n\n\t/*!\n     *  Sets the data for the editor.\n\t *\n\t *    @param [in] editor  Pointer to the editor where the data is to be set.\n\t *    @param [in] index   Model index identifying the item that's data is to be set.\n\t */\n\tvirtual void setEditorData(QWidget* editor, const QModelIndex& index) const;\n\n\t/*!\n     *  Saves the data from the editor to the model.\n\t *\n\t *    @param [in] editor  Pointer to the editor that contains the data to store.\n\t *    @param [in] model   Model that contains the data structure where data is to be saved to.\n\t *    @param [in] index   Model index identifying the item that's data is to be saved.\n\t */\n\tvirtual void setModelData(QWidget* editor, QAbstractItemModel* model, QModelIndex const& index) const;\n\nprotected:\n\n    /*!\n     *  Paint the editor.\n     *\n     *    @param [in] painter     The used painter.\n     *    @param [in] option      The style options.\n     *    @param [in] index       The current index.\n     */\n    void paint(QPainter *painter, QStyleOptionViewItem const& option, QModelIndex const& index) const;\n\n    /*!\n     *  The editor events.\n     *\n     *    @param [in] event   The event itself.\n     *    @param [in] model   The used item model.\n     *    @param [in] option  The style options.\n     *    @param [in] index   The current model index.\n     */\n    bool editorEvent(QEvent* event, QAbstractItemModel* model, QStyleOptionViewItem const& option,\n        QModelIndex const& index);\n\nprivate:\n    // Disable copying.\n    AdHocVisibilityDelegate(AdHocVisibilityDelegate const& rhs);\n    AdHocVisibilityDelegate& operator=(AdHocVisibilityDelegate const& rhs);\n\n    //! Boolean for ad-hoc group modify.\n    bool adhocGroupModify_;\n\n    //! The new state for the group modify.\n    Qt::CheckState adhocGroupState_;\n};\n\n//-----------------------------------------------------------------------------\n\n#endif // ADHOCVISIBILITYDELEGATE_H\n"
  },
  {
    "path": "editors/HWDesign/AdhocEditor/AdHocVisibilityEditor.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: AdHocVisibilityEditor.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Joni-Matti Maatta\n// Date: 16.2.2012\n//\n// Description:\n// Ad-hoc visibility editor.\n//-----------------------------------------------------------------------------\n\n#include \"AdHocVisibilityEditor.h\"\n#include \"AdHocVisibilityDelegate.h\"\n#include \"AdHocVisibilityColumns.h\"\n\n#include <common/IEditProvider.h>\n\n#include <editors/HWDesign/AdHocEnabled.h>\n#include <editors/HWDesign/HWChangeCommands.h>\n#include <editors/HWDesign/AdhocEditor/AdHocVisibilityPolicy.h>\n\n#include <IPXACTmodels/Component/Component.h>\n#include <IPXACTmodels/common/VLNV.h>\n#include <IPXACTmodels/Design/Design.h>\n\n#include <QVBoxLayout>\n#include <QHeaderView>\n#include <QSortFilterProxyModel>\n\n//-----------------------------------------------------------------------------\n// Function: AdHocVisibilityEditor::AdHocVisibilityEditor()\n//-----------------------------------------------------------------------------\nAdHocVisibilityEditor::AdHocVisibilityEditor(QWidget *parent):\nQWidget(parent),\ndataSource_(nullptr),\nvisibilityPolicy_(new AdHocVisibilityPolicy()),\nnameLabel_(this),\nportAdHocTable_(this),\nadHocModel_(visibilityPolicy_, this)\n{\n\tsetSizePolicy(QSizePolicy::Preferred, QSizePolicy::Expanding);\n\n    // Set settings for the table view.\n    portAdHocTable_.setSortingEnabled(true);\n    portAdHocTable_.setSelectionMode(QAbstractItemView::SingleSelection);\n    portAdHocTable_.setItemDelegate(new AdHocVisibilityDelegate(this));\n    portAdHocTable_.verticalHeader()->hide();\n\n    QSortFilterProxyModel* proxy = new QSortFilterProxyModel(this);\n    proxy->setSourceModel(&adHocModel_);\n    portAdHocTable_.setModel(proxy);\n\n    // Sort the table.\n    portAdHocTable_.sortByColumn(0, Qt::AscendingOrder);\n\n    portAdHocTable_.setColumnWidth(AdHocVisibilityColumns::ADHOC_COL_DIRECTION, 70);\n    portAdHocTable_.setColumnWidth(AdHocVisibilityColumns::ADHOC_COL_VISIBILITY, 70);\n    portAdHocTable_.horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch);\n    portAdHocTable_.horizontalHeader()->setSectionResizeMode(\n        AdHocVisibilityColumns::ADHOC_COL_DIRECTION, QHeaderView::Fixed);\n    portAdHocTable_.horizontalHeader()->setSectionResizeMode(\n        AdHocVisibilityColumns::ADHOC_COL_VISIBILITY, QHeaderView::Fixed);\n\n    QVBoxLayout* layout = new QVBoxLayout(this);\n    layout->addWidget(&nameLabel_);\n    layout->addWidget(&portAdHocTable_, 1);\n}\n\n//-----------------------------------------------------------------------------\n// Function: AdHocVisibilityEditor::~AdHocVisibilityEditor()\n//-----------------------------------------------------------------------------\nAdHocVisibilityEditor::~AdHocVisibilityEditor()\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: AdHocVisibilityEditor::setDataSource()\n//-----------------------------------------------------------------------------\nvoid AdHocVisibilityEditor::setDataSource(AdHocEnabled* dataSource, QSharedPointer<Design> design,\n    QSharedPointer<IEditProvider> editProvider, bool lockEditor)\n{\n\tQ_ASSERT(dataSource);\n\t//parentWidget()->raise();\n\n\t// If a previous data source has been specified, detach it from the editor.\n\tif (dataSource_ != nullptr)\n    {\n        dataSource_->detach(this);\n\t}\n\n\tdataSource_ = dataSource;\n\n    nameLabel_.setText(tr(\"Component: %1\").arg(dataSource_->adHocIdentifier()));\n\n    portAdHocTable_.setEnabled(!lockEditor);\n\n    visibilityPolicy_->setDataSource(dataSource, design->getAdHocConnections());\n\n    adHocModel_.setDataSource(dataSource_, editProvider);\n    portAdHocTable_.resizeRowsToContents();\n    portAdHocTable_.show();\n    nameLabel_.show();\n\n    // Attach the data source to the editor.\n    dataSource_->attach(this);\n}\n\n//-----------------------------------------------------------------------------\n// Function: AdHocVisibilityEditor::clear()\n//-----------------------------------------------------------------------------\nvoid AdHocVisibilityEditor::clear()\n{\n\tdataSource_ = nullptr;\n    adHocModel_.setDataSource(nullptr, nullptr);\n\n    visibilityPolicy_->setDataSource(nullptr, nullptr);\n\n    nameLabel_.hide();\n    portAdHocTable_.hide();\n}\n\n//-----------------------------------------------------------------------------\n// Function: AdHocVisibilityEditor::onContentChanged()\n//-----------------------------------------------------------------------------\nvoid AdHocVisibilityEditor::onContentChanged()\n{\n    adHocModel_.updateVisibilities();\n}\n"
  },
  {
    "path": "editors/HWDesign/AdhocEditor/AdHocVisibilityEditor.h",
    "content": "//-----------------------------------------------------------------------------\n// File: AdHocVisibilityEditor.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Joni-Matti Maatta\n// Date: 16.2.2012\n//\n// Description:\n// Ad-hoc visibility editor.\n//-----------------------------------------------------------------------------\n\n#ifndef ADHOCVISIBILITYEDITOR_H\n#define ADHOCVISIBILITYEDITOR_H\n\n#include \"AdHocVisibilityModel.h\"\n\n#include <common/widgets/vlnvDisplayer/vlnvdisplayer.h>\n#include <common/widgets/nameGroupBox/namegroupbox.h>\n#include <common/GenericEditProvider.h>\n\n#include <QWidget>\n#include <QLabel>\n#include <QSharedPointer>\n#include <QTableWidget>\n\nclass AdHocEnabled;\nclass ComponentItem;\nclass IEditProvider;\nclass AdHocVisibilityPolicy;\nclass Design;\n\n//-----------------------------------------------------------------------------\n//! Editor to edit the details of a component instance within a design.\n//-----------------------------------------------------------------------------\nclass AdHocVisibilityEditor : public QWidget\n{\n\tQ_OBJECT\n\npublic:\n    /*!\n     *  Constructor.\n     *\n     *    @param [in] parent The parent widget.\n     */\n\tAdHocVisibilityEditor(QWidget *parent);\n\t\n\t/*!\n     *  Destructor.\n     */\n\tvirtual ~AdHocVisibilityEditor();\n\n\t/*!\n\t *  Sets the ad-hoc ports visibility data source.\n\t *\n\t *    @param [in] dataSource      The data source.\n     *    @param [in] design          The design containing the data source.\n\t *    @param [in] editProvider    The edit provider to use for undo/redo.\n\t *    @param [in] lockEditor      If true, the contents cannot be edited.\n\t */\n\tvoid setDataSource(AdHocEnabled* dataSource, QSharedPointer<Design> design,\n        QSharedPointer<IEditProvider> editProvider, bool lockEditor);\n\npublic slots:\n    /*!\n     *  Hides all information in the editor.\n     */\n\tvoid clear();\n\n    /*!\n     *  Called when the data source contents have changed.\n     */\n    void onContentChanged();\n\nprivate slots:\n\nprivate:\n\t// Disable copying.\n\tAdHocVisibilityEditor(AdHocVisibilityEditor const& rhs);\n\tAdHocVisibilityEditor& operator=(AdHocVisibilityEditor const& rhs);\n\n    //-----------------------------------------------------------------------------\n    // Data.\n    //-----------------------------------------------------------------------------\n\n\t//! The data source being edited.\n\tAdHocEnabled* dataSource_;\n\n    //! The handler for ad hoc port visibilities.\n    QSharedPointer<AdHocVisibilityPolicy> visibilityPolicy_;\n\n    //! The name label.\n    QLabel nameLabel_;\n\n\t//! The port ad-hoc visibility table.\n    QTableView portAdHocTable_;\n\n    //! The ad-hoc model.\n    AdHocVisibilityModel adHocModel_;\n};\n\n#endif // ADHOCVISIBILITYEDITOR_H\n"
  },
  {
    "path": "editors/HWDesign/AdhocEditor/AdHocVisibilityModel.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: AdHocVisibilityModel.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Joni-Matti Maatta\n// Date: 20.2.2012\n//\n// Description:\n// Table model for visualizing ad-hoc visibility for dataSource ports.\n//-----------------------------------------------------------------------------\n\n#include \"AdHocVisibilityModel.h\"\n#include \"AdHocVisibilityColumns.h\"\n\n#include <common/IEditProvider.h>\n#include <common/KactusColors.h>\n\n#include <editors/HWDesign/HWComponentItem.h>\n#include <editors/HWDesign/AdHocEnabled.h>\n#include <editors/HWDesign/HWConnectionEndpoint.h>\n#include <editors/HWDesign/HWDesignDiagram.h>\n#include <editors/HWDesign/AdhocEditor/AdHocVisibilityPolicy.h>\n#include <editors/HWDesign/undoCommands/AdHocVisibilityChangeCommand.h>\n#include <editors/HWDesign/undoCommands/TopAdHocVisibilityChangeCommand.h>\n\n#include <IPXACTmodels/common/DirectionTypes.h>\n#include <IPXACTmodels/Component/Component.h>\n#include <IPXACTmodels/Component/Port.h>\n\n//-----------------------------------------------------------------------------\n// Function: AdHocVisibilityModel::AdHocVisibilityModel()\n//-----------------------------------------------------------------------------\nAdHocVisibilityModel::AdHocVisibilityModel(QSharedPointer<AdHocVisibilityPolicy> visibilityPolicy,\n    QObject *parent):\nQAbstractTableModel(parent),\nvisibilityPolicy_(visibilityPolicy),\ntable_(new QList<QSharedPointer<Port> > ())\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: AdHocVisibilityModel::~AdHocVisibilityModel()\n//-----------------------------------------------------------------------------\nAdHocVisibilityModel::~AdHocVisibilityModel()\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: AdHocVisibilityModel::setDataSource()\n//-----------------------------------------------------------------------------\nvoid AdHocVisibilityModel::setDataSource(AdHocEnabled* dataSource, QSharedPointer<IEditProvider> editProvider)\n{\n    editProvider_ = editProvider;\n\n    beginResetModel();\n\n    if (dataSource != 0)\n    {\n        table_ = dataSource->getPorts();\n    }\n    else\n    {\n        table_.clear();\n    }\n\n    endResetModel();\n}\n\n//-----------------------------------------------------------------------------\n// Function: AdHocVisibilityModel::rowCount()\n//-----------------------------------------------------------------------------\nint AdHocVisibilityModel::rowCount(QModelIndex const& parent /*= QModelIndex()*/) const\n{\n    if (parent.isValid() || !table_)\n    {\n        return 0;\n    }\n\n    return table_->size();\n}\n\n//-----------------------------------------------------------------------------\n// Function: AdHocVisibilityModel::columnCount()\n//-----------------------------------------------------------------------------\nint AdHocVisibilityModel::columnCount(QModelIndex const& parent /*= QModelIndex()*/) const\n{\n    if (parent.isValid())\n    {\n        return 0;\n    }\n\n    return AdHocVisibilityColumns::ADHOC_COL_COUNT;\n}\n\n//-----------------------------------------------------------------------------\n// Function: AdHocVisibilityModel::data()\n//-----------------------------------------------------------------------------\nQVariant AdHocVisibilityModel::data(QModelIndex const& index, int role /*= Qt::DisplayRole*/) const\n{\n    // Check for invalid index.\n    if (!index.isValid() || index.row() < 0 || index.row() >= table_->size())\n    {\n        return QVariant();\n    }\n\n    QSharedPointer<Port> adhocPort = table_->at(index.row());\n\n    if (role == Qt::DisplayRole)\n    {\n        if (index.column() == AdHocVisibilityColumns::ADHOC_COL_NAME)\n        {\n            return table_->at(index.row())->name();\n        }\n        else if (index.column() == AdHocVisibilityColumns::ADHOC_COL_DIRECTION)\n        {\n            return getPortDirection(adhocPort);\n        }\n        else\n        {\n            return QVariant();\n        }\n    }\n    else if (Qt::CheckStateRole == role)\n    {\n        if (index.column() == AdHocVisibilityColumns::ADHOC_COL_VISIBILITY)\n        {\n            if (visibilityPolicy_->isPortAdhocVisible(adhocPort->name()))\n            {\n                return Qt::Checked;\n            }\n            else\n            {\n                return Qt::Unchecked;\n            }\n        }\n        else\n        {\n            return QVariant();\n        }\n    }\n\n    else if (role == Qt::ForegroundRole)\n    {\n        if (!visibilityPolicy_->canChangeVisibility(adhocPort))\n        {\n            return KactusColors::DISABLED_TEXT;\n        }\n        else\n        {\n            return KactusColors::REGULAR_TEXT;\n        }\n    }\n\n    else if (role == Qt::ToolTipRole)\n    {\n        if (visibilityPolicy_->portHasConnections(adhocPort))\n        {\n            QString connectedText = QObject::tr(\"Connected ad hoc port cannot be disabled.\");\n            return connectedText;\n        }\n        else if (visibilityPolicy_->portHasTieOffConnection(adhocPort))\n        {\n            QString tieOffText = QObject::tr(\"Port with a tie off value cannot be disabled.\");\n            return tieOffText;\n        }\n        else if (adhocPort->isAdHocVisible())\n        {\n            QString componentPortVisibleText = QObject::tr(\"Component determines port %1 to be visible.\").\n                arg(adhocPort->name());\n            return componentPortVisibleText;\n        }\n        else\n        {\n            return QString();\n        }\n    }\n\n    return QVariant();\n}\n\n//-----------------------------------------------------------------------------\n// Function: AdHocVisibilityModel::getPortDirection()\n//-----------------------------------------------------------------------------\nQString AdHocVisibilityModel::getPortDirection(QSharedPointer<Port> adhocPort) const\n{\n    DirectionTypes::Direction portDirection = adhocPort->getDirection();\n    if (portDirection == DirectionTypes::DIRECTION_INVALID && adhocPort->getTransactional())\n    {\n        QString initiative = adhocPort->getTransactional()->getInitiative();\n        if (initiative == TransactionalTypes::INITIATIVE_BOTH)\n        {\n            initiative = TransactionalTypes::INITIATIVE_REQUIRES_PROVIDES;\n        }\n\n        return initiative;\n    }\n    else\n    {\n        return DirectionTypes::direction2Str(portDirection);\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: AdHocVisibilityModel::headerData()\n//-----------------------------------------------------------------------------\nQVariant AdHocVisibilityModel::headerData(int section, Qt::Orientation orientation, int role /*= Qt::DisplayRole*/) const\n{\n    if (role == Qt::DisplayRole)\n    {\n        if (orientation == Qt::Horizontal)\n        {\n            if (section == AdHocVisibilityColumns::ADHOC_COL_NAME)\n            {\n                return tr(\"Name\");\n            }\n            else if (section == AdHocVisibilityColumns::ADHOC_COL_DIRECTION)\n            {\n                return tr(\"Direction\");\n            }\n            else if (section == AdHocVisibilityColumns::ADHOC_COL_VISIBILITY)\n            {\n                return tr(\"Ad-hoc\");\n            }\n            else\n            {\n                return QVariant();\n            }\n        } \n        // Vertical headers get running numbers.\n        else\n        {\n            return section + 1;\n        }\n    }\n    \n    return QVariant();\n}\n\n//-----------------------------------------------------------------------------\n// Function: AdHocVisibilityModel::setData()\n//-----------------------------------------------------------------------------\nbool AdHocVisibilityModel::setData(const QModelIndex& index, const QVariant& value, int role /*= Qt::EditRole*/)\n{\n    // Check for invalid index.\n    if (!index.isValid() || index.row() < 0 || index.row() >= table_->size())\n    {\n        return false;\n    }\n\n    if (role == Qt::CheckStateRole)\n    {\n        QSharedPointer<QUndoCommand> visibilityCommand(0);\n\n        AdHocEnabled* dataSource = visibilityPolicy_->getDataSource();\n        HWDesignDiagram* dataSourceDiagram = dynamic_cast<HWDesignDiagram*>(dataSource);\n        if (dataSourceDiagram)\n        {\n            visibilityCommand = QSharedPointer<QUndoCommand>(new TopAdHocVisibilityChangeCommand(\n                dataSourceDiagram, table_->at(index.row())->name(), value == Qt::Checked));\n        }\n        else\n        {\n            visibilityCommand = QSharedPointer<QUndoCommand>(new AdHocVisibilityChangeCommand(\n                dataSource, table_->at(index.row())->name(), value == Qt::Checked));\n        }\n\n        editProvider_->addCommand(visibilityCommand);\n        visibilityCommand->redo();\n\n        emit dataChanged(index, index);\n        return true;\n    }\n\n    return false;\n}\n\n//-----------------------------------------------------------------------------\n// Function: AdHocVisibilityModel::flags()\n//-----------------------------------------------------------------------------\nQt::ItemFlags AdHocVisibilityModel::flags(const QModelIndex& index) const\n{\n    if (!index.isValid())\n    {\n        return Qt::NoItemFlags;\n    }\n\n    Qt::ItemFlags flags = Qt::ItemIsEnabled;\n\n    QSharedPointer<Port> indexedPort = table_->at(index.row());\n    if (index.column() == AdHocVisibilityColumns::ADHOC_COL_VISIBILITY &&\n        visibilityPolicy_->canChangeVisibility(indexedPort))\n    {\n        flags |= Qt::ItemIsUserCheckable | Qt::ItemIsSelectable;\n    }\n\n    return flags;\n}\n\n//-----------------------------------------------------------------------------\n// Function: AdHocVisibilityModel::updateVisibilities()\n//-----------------------------------------------------------------------------\nvoid AdHocVisibilityModel::updateVisibilities()\n{\n    if (table_)\n    {\n        emit dataChanged(index(0, AdHocVisibilityColumns::ADHOC_COL_VISIBILITY), index(table_->size() - 1,\n            AdHocVisibilityColumns::ADHOC_COL_VISIBILITY));\n    }\n}\n"
  },
  {
    "path": "editors/HWDesign/AdhocEditor/AdHocVisibilityModel.h",
    "content": "//-----------------------------------------------------------------------------\n// File: AdHocVisibilityModel.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Joni-Matti Maatta\n// Date: 20.2.2012\n//\n// Description:\n// Table model for visualizing ad-hoc visibility for component ports.\n//-----------------------------------------------------------------------------\n\n#ifndef ADHOCVISIBILITYMODEL_H\n#define ADHOCVISIBILITYMODEL_H\n\n#include <QAbstractTableModel>\n#include <QSharedPointer>\n\nclass AdHocEnabled;\nclass GenericEditProvider;\nclass IEditProvider;\nclass Port;\nclass AdHocVisibilityPolicy;\n\n//-----------------------------------------------------------------------------\n//! Table model for visualizing ad-hoc visibility for component ports.\n//-----------------------------------------------------------------------------\nclass AdHocVisibilityModel : public QAbstractTableModel\n{\n\npublic:\n\n\t/*!\n     *  The constructor.\n\t *\n     *    @param [in] visibilityPolicy    Handler for ad hoc visibilities.\n     *    @param [in] parent              Pointer to the owner of this model.\n\t */\n\tAdHocVisibilityModel(QSharedPointer<AdHocVisibilityPolicy> visibilityPolicy, QObject *parent);\n\t\n\t/*!\n     *  The destructor.\n     */\n\tvirtual ~AdHocVisibilityModel();\n\n    /*!\n     *  Sets the ad-hoc port visibility data source being edited.\n     *\n     *    @param [in] dataSource      The data source.\n     *    @param [in] editProvider    The provider for undo commands.\n     */\n    void setDataSource(AdHocEnabled* dataSource, QSharedPointer<IEditProvider> editProvider);\n\n\t/*!\n     *  Returns the number of rows in the model.\n\t *\n\t *    @param [in] parent Model index of the parent of the item. Must be invalid because this is not a\n     *                  hierarchical model.\n\t *\n\t *    @return Number of rows currently in the model.\n\t */\n\tvirtual int rowCount(QModelIndex const& parent = QModelIndex()) const;\n\n\t/*!\n     *  Returns the number of columns in the model.\n\t *\n\t *    @param [in] parent Model index of the parent of the item. Must be invalid because this is not a\n     *                  hierarchical model.\n\t *\n\t *    @return Always returns 3.\n\t */\n\tvirtual int columnCount(QModelIndex const& parent = QModelIndex()) const;\n\n\t/*!\n     *  Returns the data for the specified item for specified role.\n\t *\n\t *    @param [in] index  Identifies the item that's data is wanted.\n\t *    @param [in] role   Specifies what kind of data is wanted\n\t *\n\t *    @return QVariant containing the data.\n\t */\n\tvirtual QVariant data(QModelIndex const& index, int role = Qt::DisplayRole) const;\n\n\t/*!\n     *  Returns the data for the headers.\n\t *\n\t *    @param [in] section      The column that's header is wanted\n\t *    @param [in] orientation  Only Qt::Horizontal is supported\n\t *    @param [in] role         Specified the type of data that is wanted.\n\t *\n\t *    @return QVariant containing the data to be displayed.\n\t */\n\tvirtual QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;\n\n\t/*!\n     *  Set the data for specified item.\n\t *\n\t *    @param [in] index  Specifies the item that's data is modified\n\t *    @param [in] value  The value to be set.\n\t *    @param [in] role   The role that is trying to modify the data. Only Qt::EditRole\n\t *                         is supported.\n\t *\n\t *    @return True if data was successfully set.\n\t */\n\tvirtual bool setData(const QModelIndex& index, const QVariant& value, int role = Qt::EditRole);\n\n\t/*!\n     *  Returns information on how specified item can be handled.\n\t *\n\t *    @param [in] index Specifies the item that's flags are wanted.\n\t *\n\t *    @return Qt::ItemFlags that define how object can be handled.\n\t */\n\tvirtual Qt::ItemFlags flags(const QModelIndex& index) const;\n\npublic slots:\n    /*!\n     *  Updates the visibilities.\n     */\n    void updateVisibilities();\n\nsignals:\n\n\t//! Emitted when contents of the model change.\n\tvoid contentChanged();\n\nprivate:\n    // Disable copying.\n    AdHocVisibilityModel(AdHocVisibilityModel const& rhs);\n    AdHocVisibilityModel& operator=(AdHocVisibilityModel const& rhs);\n\n    /*!\n     *  Get the direction of the selected port.\n     *\n     *    @param [in] adhocPort   The selected port.\n     *\n     *    @return Direction of the selected port.\n     */\n    QString getPortDirection(QSharedPointer<Port> adhocPort) const;\n\n    //-----------------------------------------------------------------------------\n    // Data.\n    //-----------------------------------------------------------------------------\n\n    //! The handler for ad hoc visibilities.\n    QSharedPointer<AdHocVisibilityPolicy> visibilityPolicy_;\n\n    //! The edit provider.\n     QSharedPointer<IEditProvider> editProvider_;\n\n\t//! The table that is displayed to the user.\n    QSharedPointer<QList<QSharedPointer<Port> > > table_;\n};\n\n//-----------------------------------------------------------------------------\n\n#endif // ADHOCVISIBILITYMODEL_H"
  },
  {
    "path": "editors/HWDesign/AdhocEditor/AdHocVisibilityPolicy.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: AdHocVisibilityPolicy.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 09.05.2016\n//\n// Description:\n// Policy handler for ad hoc port visibilities.\n//-----------------------------------------------------------------------------\n\n#include \"AdHocVisibilityPolicy.h\"\n\n#include <editors/HWDesign/AdHocEnabled.h>\n#include <editors/HWDesign/HWConnectionEndpoint.h>\n\n#include <IPXACTmodels/Design/AdHocConnection.h>\n#include <IPXACTmodels/Component/Port.h>\n\n//-----------------------------------------------------------------------------\n// Function: AdHocVisibilityPolicy::AdHocVisibilityPolicy()\n//-----------------------------------------------------------------------------\nAdHocVisibilityPolicy::AdHocVisibilityPolicy():\ndataSource_(0),\nadhocConnections_(new QList<QSharedPointer<AdHocConnection> > ())\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: AdHocVisibilityPolicy::~AdHocVisibilityPolicy()\n//-----------------------------------------------------------------------------\nAdHocVisibilityPolicy::~AdHocVisibilityPolicy()\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: AdHocVisibilityPolicy::setDataSource()\n//-----------------------------------------------------------------------------\nvoid AdHocVisibilityPolicy::setDataSource(AdHocEnabled* dataSource,\n    QSharedPointer<QList<QSharedPointer<AdHocConnection> > > connections)\n{\n    dataSource_ = dataSource;\n    adhocConnections_ = connections;\n}\n\n//-----------------------------------------------------------------------------\n// Function: AdHocVisibilityPolicy::canChangeVisibility()\n//-----------------------------------------------------------------------------\nbool AdHocVisibilityPolicy::canChangeVisibility(QSharedPointer<Port> port) const\n{\n    if (portHasConnections(port) || portHasTieOffConnection(port) || port->isAdHocVisible())\n    {\n        return false;\n    }\n\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: AdHocVisibilityPolicy::portHasConnections()\n//-----------------------------------------------------------------------------\nbool AdHocVisibilityPolicy::portHasConnections(QSharedPointer<Port> port) const\n{\n    if (dataSource_)\n    {\n        HWConnectionEndpoint* endpoint = dataSource_->getDiagramAdHocPort(port->name());\n        if (endpoint)\n        {\n            if (!endpoint->getConnections().isEmpty() ||\n                (endpoint->getOffPageConnector() && !endpoint->getOffPageConnector()->getConnections().isEmpty()))\n            {\n                return true;\n            }\n        }\n    }\n\n    return false;\n}\n\n//-----------------------------------------------------------------------------\n// Function: AdHocVisibilityPolicy::portHasTieOffConnection()\n//-----------------------------------------------------------------------------\nbool AdHocVisibilityPolicy::portHasTieOffConnection(QSharedPointer<Port> port) const\n{\n    if (adhocConnections_ && !adhocConnections_->isEmpty())\n    {\n        QSharedPointer<AdHocConnection> connection = getTieOffConnection(port);\n\n        if (connection)\n        {\n            return true;\n        }\n    }\n\n    return false;\n}\n\n//-----------------------------------------------------------------------------\n// Function: AdHocVisibilityPolicy::getTieOffConnection()\n//-----------------------------------------------------------------------------\nQSharedPointer<AdHocConnection> AdHocVisibilityPolicy::getTieOffConnection(QSharedPointer<Port> port) const\n{\n    QString adHocId = dataSource_->adHocIdentifier();\n\n    if (adHocId == QObject::tr(\"top-level\"))\n    {\n        return getTopComponentTieOffConnection(port);\n    }\n    else\n    {\n        return getInstanceTieOffConnection(port);\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: AdHocVisibilityPolicy::getTopComponentTieOff()\n//-----------------------------------------------------------------------------\nQSharedPointer<AdHocConnection> AdHocVisibilityPolicy::getTopComponentTieOffConnection(QSharedPointer<Port> port)\n    const\n{\n    foreach (QSharedPointer<AdHocConnection> connection, *adhocConnections_)\n    {\n        foreach (QSharedPointer<PortReference> externalReference, *connection->getExternalPortReferences())\n        {\n            if (externalReference->getPortRef() == port->name() && !connection->getTiedValue().isEmpty())\n            {\n                return connection;\n            }\n        }\n    }\n\n    return QSharedPointer<AdHocConnection>();\n}\n\n//-----------------------------------------------------------------------------\n// Function: AdHocVisibilityPolicy::getInstanceTieOff()\n//-----------------------------------------------------------------------------\nQSharedPointer<AdHocConnection> AdHocVisibilityPolicy::getInstanceTieOffConnection(QSharedPointer<Port> port) const\n{\n    foreach (QSharedPointer<AdHocConnection> connection, *adhocConnections_)\n    {\n        foreach (QSharedPointer<PortReference> internalReference, *connection->getInternalPortReferences())\n        {\n            if (dataSource_->adHocIdentifier() == internalReference->getComponentRef() &&\n                internalReference->getPortRef() == port->name() && !connection->getTiedValue().isEmpty())\n            {\n                return connection;\n            }\n        }\n    }\n\n    return QSharedPointer<AdHocConnection>();\n}\n\n//-----------------------------------------------------------------------------\n// Function: AdHocVisibilityPolicy::isPortAdhocVisible()\n//-----------------------------------------------------------------------------\nbool AdHocVisibilityPolicy::isPortAdhocVisible(QString const& portName) const\n{\n    if (dataSource_)\n    {\n        return dataSource_->isPortAdHocVisible(portName);\n    }\n    else\n    {\n        return false;\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: AdHocVisibilityPolicy::getDataSource()\n//-----------------------------------------------------------------------------\nAdHocEnabled* AdHocVisibilityPolicy::getDataSource()\n{\n    return dataSource_;\n}\n"
  },
  {
    "path": "editors/HWDesign/AdhocEditor/AdHocVisibilityPolicy.h",
    "content": "//-----------------------------------------------------------------------------\n// File: AdHocVisibilityPolicy.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 09.05.2016\n//\n// Description:\n// Policy handler for ad hoc port visibilities.\n//-----------------------------------------------------------------------------\n\n#ifndef ADHOCVISIBILITYPOLICY_H\n#define ADHOCVISIBILITYPOLICY_H\n\n#include <QSharedPointer>\n\nclass AdHocEnabled;\nclass AdHocConnection;\nclass Port;\n\n//-----------------------------------------------------------------------------\n//! Policy handler for ad hoc port visibilities.\n//-----------------------------------------------------------------------------\nclass AdHocVisibilityPolicy\n{\n\npublic:\n\n\t/*!\n     *  The constructor.\n\t */\n\tAdHocVisibilityPolicy();\n\t\n\t/*!\n     *  The destructor.\n     */\n\t~AdHocVisibilityPolicy();\n\n    /*!\n     *  Sets the ad-hoc port visibility data source being edited.\n     *\n     *    @param [in] dataSource      The data source.\n     *    @param [in] connections     List of ad hoc connections within the design.\n     */\n    void setDataSource(AdHocEnabled* dataSource,\n        QSharedPointer<QList<QSharedPointer<AdHocConnection> > > connections);\n\n    /*!\n     *  Check if the visibility can be changed for the selected port.\n     *\n     *    @param [in] port    The selected port.\n     *\n     *    @return True, if the visibility can be changed, false otherwise.\n     */\n    bool canChangeVisibility(QSharedPointer<Port> port) const;\n\n    /*!\n     *  Check if the selected port has connections.\n     *\n     *    @param [in] port    The selected port.\n     *\n     *    @return True, if the selected port has been connected, otherwise false.\n     */\n    bool portHasConnections(QSharedPointer<Port> port) const;\n\n    /*!\n     *  Check if the selected port has a tie off value.\n     *\n     *    @param [in] port    The selected port.\n     *\n     *    @return True, if the selected port has a tie off value, otherwise false.\n     */\n    bool portHasTieOffConnection(QSharedPointer<Port> port) const;\n\n    /*!\n     *  Check if the selected port is determined to be visible within the containing component.\n     *\n     *    @param [in] portName    The name of the port.\n     *\n     *    @return True, if the selected port is determined to be visible, otherwise false.\n     */\n    bool isPortAdhocVisible(QString const& portName) const;\n\n    AdHocEnabled* getDataSource();\n\nprivate:\n\n    // Disable copying.\n    AdHocVisibilityPolicy(AdHocVisibilityPolicy const& rhs);\n    AdHocVisibilityPolicy& operator=(AdHocVisibilityPolicy const& rhs);\n\n    /*!\n     *  Get a connection containing the tie off value of the selected port.\n     *\n     *    @param [in] port    The selected port.\n     *\n     *    @return A connection containing the tie off value of the selected port. Empty pointer if no\n     *              connection is found.\n     */\n    QSharedPointer<AdHocConnection> getTieOffConnection(QSharedPointer<Port> port) const;\n\n    QSharedPointer<AdHocConnection> getInstanceTieOffConnection(QSharedPointer<Port> port) const;\n\n    QSharedPointer<AdHocConnection> getTopComponentTieOffConnection(QSharedPointer<Port> port) const;\n\n    //-----------------------------------------------------------------------------\n    // Data.\n    //-----------------------------------------------------------------------------\n\n    //! The component whose ad-hoc port visibility is being edited.\n    AdHocEnabled* dataSource_;\n\n    //! A list of ad hoc connections within the design.\n    QSharedPointer<QList<QSharedPointer<AdHocConnection> > > adhocConnections_;\n};\n\n//-----------------------------------------------------------------------------\n\n#endif // ADHOCVISIBILITYMODEL_H"
  },
  {
    "path": "editors/HWDesign/AdhocEditor/AdhocEditor.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: AdhocEditor.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Esko Pekkarinen\r\n// Date: 27.04.2023\r\n//\r\n// Description:\r\n// Editor for ad-hoc port visibilities and tie off values.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"AdhocEditor.h\"\r\n\r\n#include <QGridLayout>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AdhocEditor::AdhocEditor()\r\n//-----------------------------------------------------------------------------\r\nAdhocEditor::AdhocEditor(QSharedPointer<ParameterFinder> designFinder, QWidget* parent) : QWidget(parent),\r\nvisibilityEditor_(this),\r\nportEditor_(designFinder, this)\r\n{\r\n    connect(&portEditor_, SIGNAL(increaseReferences(QString const&)),\r\n        this, SIGNAL(increaseReferences(QString const&)), Qt::UniqueConnection);\r\n    connect(&portEditor_, SIGNAL(decreaseReferences(QString const&)),\r\n        this, SIGNAL(decreaseReferences(QString const&)), Qt::UniqueConnection);\r\n    connect(&portEditor_, SIGNAL(contentChanged()),\r\n        this, SIGNAL(contentChanged()), Qt::UniqueConnection);\r\n\r\n    setupLayout();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AdhocEditor::setVisibilityData()\r\n//-----------------------------------------------------------------------------\r\nvoid AdhocEditor::setVisibilityData(AdHocEnabled* dataSource, QSharedPointer<Design> design,\r\n    QSharedPointer<IEditProvider> editProvider, bool lockEditor)\r\n{\r\n    visibilityEditor_.setDataSource(dataSource, design, editProvider, lockEditor);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AdhocEditor::clearVisibilityData()\r\n//-----------------------------------------------------------------------------\r\nvoid AdhocEditor::clearVisibilityData()\r\n{\r\n    visibilityEditor_.clear();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AdhocEditor::setPortData()\r\n//-----------------------------------------------------------------------------\r\nvoid AdhocEditor::setPortData(AdHocItem* endPoint, HWDesignDiagram* containingDiagram,\r\n    QSharedPointer<IEditProvider> editProvider)\r\n{\r\n    portEditor_.setAdhocPort(endPoint, containingDiagram, editProvider);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AdhocEditor::clearPortData()\r\n//-----------------------------------------------------------------------------\r\nvoid AdhocEditor::clearPortData()\r\n{\r\n    portEditor_.clear();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AdhocEditor::setupLayout()\r\n//-----------------------------------------------------------------------------\r\nvoid AdhocEditor::setupLayout()\r\n{\r\n    auto layout = new QGridLayout(this);\r\n    layout->addWidget(&visibilityEditor_, 0, 0);\r\n    layout->addWidget(&portEditor_, 1, 0);\r\n    layout->setRowStretch(0, 1);\r\n    layout->setSpacing(0);\r\n    layout->setContentsMargins(0, 0, 0, 0);\r\n}\r\n"
  },
  {
    "path": "editors/HWDesign/AdhocEditor/AdhocEditor.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: AdhocEditor.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Esko Pekkarinen\r\n// Date: 27.04.2023\r\n//\r\n// Description:\r\n// Editor for ad-hoc port visibilities and tie off values.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef ADHOC_EDITOR_H\r\n#define ADHOC_EDITOR_H\r\n\r\n#include \"AdhocPortEditor.h\"\r\n#include \"AdHocVisibilityEditor.h\"\r\n\r\n#include <KactusAPI/include/ParameterFinder.h>\r\n\r\n#include <QWidget>\r\n#include <QSharedPointer>\r\n\r\nclass AdHocItem;\r\nclass HWDesignDiagram;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Editor for ad-hoc port visibilities and tie off values.\r\n//-----------------------------------------------------------------------------\r\nclass AdhocEditor : public QWidget\r\n{\r\n    Q_OBJECT\r\npublic:\r\n\r\n    //! The constructor.\r\n    AdhocEditor(QSharedPointer<ParameterFinder> designFinder, QWidget* parent = nullptr);\r\n\r\n\r\n    //! The destructor.\r\n    virtual ~AdhocEditor() = default;\r\n\r\n    //! No copying.\r\n    AdhocEditor(const AdhocEditor& other) = delete;\r\n\r\n    //! No assignment.\r\n    AdhocEditor& operator=(const AdhocEditor& other) = delete;\r\n\r\n    /*!\r\n     *  Sets the ad-hoc ports visibility data source.\r\n     *\r\n     *    @param [in] dataSource      The data source.\r\n     *    @param [in] design          The design containing the data source.\r\n     *    @param [in] editProvider    The edit provider to use for undo/redo.\r\n     *    @param [in] lockEditor      If true, the contents cannot be edited.\r\n     */\r\n    void setVisibilityData(AdHocEnabled* dataSource, QSharedPointer<Design> design, \r\n        QSharedPointer<IEditProvider> editProvider, bool lockEditor);\r\n\r\n    /*!\r\n     *  Hides all information in the port visibility section.\r\n     */\r\n    void clearVisibilityData();\r\n\r\n    /*!\r\n     *  Set the ad hoc port data to display.\r\n     *\r\n     *    @param [in] endPoint            The selected ad hoc port.\r\n     *    @param [in] containingDiagram   The design diagram containing the ad hoc port.\r\n     *    @param [in] editProvider        The provider for undo commands.\r\n     */\r\n    void setPortData(AdHocItem* endPoint, HWDesignDiagram* containingDiagram, QSharedPointer<IEditProvider> editProvider);\r\n\r\n    /*!\r\n     *  Hides all information in the port section.\r\n     */\r\n    void clearPortData();\r\n\r\nsignals:\r\n\r\n    /*!\r\n     *  Informs of a change in the contents.\r\n     */\r\n    void contentChanged();\r\n\r\n    /*!\r\n     *  Informs of new references made to the parameter with the selected ID.\r\n     *\r\n     *    @param [in] parameterID     ID of the selected parameter.\r\n     */\r\n    void increaseReferences(QString const& parameterID);\r\n\r\n    /*!\r\n     *  Informs of removing references from the parameter with the selected ID.\r\n     *\r\n     *    @param [in] parameterID     ID of the selected parameter.\r\n     */\r\n    void decreaseReferences(QString const& parameterID);\r\n\r\nprivate:\r\n\r\n    //! Setup the widget layout.\r\n    void setupLayout();\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    AdHocVisibilityEditor visibilityEditor_;\r\n\r\n    AdhocPortEditor portEditor_;\r\n\r\n};\r\n\r\n\r\n#endif // ADHOC_EDITOR_H\r\n"
  },
  {
    "path": "editors/HWDesign/AdhocEditor/AdhocPortEditor.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: AdhocPortEditor.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 29.04.2016\n//\n// Description:\n// Editor to edit the details of an Ad hoc port in designAd-hoc editor.\n//-----------------------------------------------------------------------------\n\n#include \"AdhocPortEditor.h\"\n\n#include <common/graphicsItems/ComponentItem.h>\n#include <common/GenericEditProvider.h>\n\n#include <editors/ComponentEditor/common/ExpressionEditor.h>\n#include <KactusAPI/include/ComponentParameterFinder.h>\n#include <KactusAPI/include/IPXactSystemVerilogParser.h>\n#include <KactusAPI/include/ExpressionFormatter.h>\n#include <editors/ComponentEditor/parameters/ComponentParameterModel.h>\n\n#include <editors/HWDesign/AdHocItem.h>\n#include <editors/HWDesign/ActivePortItem.h>\n#include <editors/HWDesign/HierarchicalPortItem.h>\n#include <editors/HWDesign/HWDesignDiagram.h>\n#include <editors/HWDesign/undoCommands/AdHocTieOffChangeCommand.h>\n#include <editors/HWDesign/undoCommands/AdHocTieOffBoundsChangeCommand.h>\n\n#include <IPXACTmodels/common/validators/ValueFormatter.h>\n#include <IPXACTmodels/Design/Design.h>\n\n#include <QCompleter>\n#include <QFormLayout>\n#include <QVBoxLayout>\n#include <QGroupBox>\n\n//-----------------------------------------------------------------------------\n// Function: AdhocPortEditor::AdhocPortEditor()\n//-----------------------------------------------------------------------------\nAdhocPortEditor::AdhocPortEditor(QSharedPointer<ParameterFinder> designParameterFinder, QWidget* parent) :\n    QWidget(parent),\n    expressionParser_(new IPXactSystemVerilogParser(designParameterFinder)),\n    expressionFormatter_(new ExpressionFormatter(designParameterFinder)),\n    portName_(new QLabel(this)),\n    portDirection_(new QLabel(this)),\n    leftBoundValue_(new QLabel(this)),\n    rightBoundValue_(new QLabel(this)),\n    tiedValueEditor_(new ExpressionEditor(designParameterFinder, this)),\n    containedPortItem_(),\n    editProvider_(),\n    designDiagram_(),\n    tiedValueLeftBoundEditor_(new ExpressionEditor(designParameterFinder, this)),\n    tiedValueRightBoundEditor_(new ExpressionEditor(designParameterFinder, this)),\n    designParameterFinder_(designParameterFinder)\n{\n    tiedValueEditor_->setFixedHeight(ExpressionEditor::DEFAULT_HEIGHT);\n\n    tiedValueLeftBoundEditor_->setFixedHeight(ExpressionEditor::DEFAULT_HEIGHT);\n    tiedValueRightBoundEditor_->setFixedHeight(ExpressionEditor::DEFAULT_HEIGHT);\n\n    ComponentParameterModel* parameterModel = new ComponentParameterModel(designParameterFinder, this);\n    parameterModel->setExpressionParser(expressionParser_);\n\n    auto tiedValueCompleter = new QCompleter(this);\n    tiedValueCompleter->setModel(parameterModel);\n\n    auto tiedValueLeftBoundCompleter = new QCompleter(this);\n    tiedValueLeftBoundCompleter->setModel(parameterModel);\n\n    auto tiedValueRightBoundCompleter = new QCompleter(this);\n    tiedValueRightBoundCompleter->setModel(parameterModel);\n\n    tiedValueEditor_->setAppendingCompleter(tiedValueCompleter);\n\n    tiedValueLeftBoundEditor_->setAppendingCompleter(tiedValueLeftBoundCompleter);\n    tiedValueRightBoundEditor_->setAppendingCompleter(tiedValueRightBoundCompleter);\n\n    tiedValueEditor_->setReservedWords(QStringList({ \"open\", \"default\" }));\n\n    setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Expanding);\n\n    setupLayout();\n\n    connect(tiedValueEditor_, SIGNAL(editingFinished()), this, SLOT(onTiedValueChanged()), Qt::UniqueConnection);\n    connect(tiedValueLeftBoundEditor_, SIGNAL(editingFinished()),\n        this, SLOT(onTiedValueLeftBoundChanged()), Qt::UniqueConnection);\n    connect(tiedValueRightBoundEditor_, SIGNAL(editingFinished()),\n        this, SLOT(onTiedValueRightBoundChanged()), Qt::UniqueConnection);\n}\n\n\n//-----------------------------------------------------------------------------\n// Function: AdhocPortEditor::setAdhocPort()\n//-----------------------------------------------------------------------------\nvoid AdhocPortEditor::setAdhocPort(AdHocItem* endPoint, HWDesignDiagram* containingDiagram,\n    QSharedPointer<IEditProvider> editProvider)\n{\n    if (!endPoint->isAdHoc())\n    {\n        return;\n    }\n\n    designDiagram_ = containingDiagram;\n    editProvider_ = editProvider;\n    containedPortItem_ = endPoint;\n\n    portName_->parentWidget()->show();\n    tiedValueEditor_->parentWidget()->show();\n\n    ActivePortItem* adhocPortItem = dynamic_cast<ActivePortItem*>(containedPortItem_);\n    HierarchicalPortItem* adhocInterfaceItem = dynamic_cast<HierarchicalPortItem*>(containedPortItem_);\n\n    QSharedPointer<Port> referencedPort = containedPortItem_->getPort();\n\n    if (referencedPort)\n    {\n        DirectionTypes::Direction direction = referencedPort->getDirection();\n\n        portName_->setText(referencedPort->name());\n        portDirection_->setText(DirectionTypes::direction2Str(direction));\n        leftBoundValue_->setText(formattedValueFor(referencedPort->getLeftBound()));\n        rightBoundValue_->setText(formattedValueFor(referencedPort->getRightBound()));\n\n        QString tiedValue = QString();\n\n        QSharedPointer<PartSelect> portPartSelect;\n\n        if ((adhocPortItem && direction == DirectionTypes::IN) ||\n            (adhocInterfaceItem && direction == DirectionTypes::OUT) ||\n            direction == DirectionTypes::INOUT)\n        {\n            tiedValueEditor_->setEnabled(!designDiagram_->isProtected());\n            tiedValueLeftBoundEditor_->setEnabled(!designDiagram_->isProtected());\n            tiedValueRightBoundEditor_->setEnabled(!designDiagram_->isProtected());\n\n            QSharedPointer<AdHocConnection> connectionItem = getTiedConnection();\n            tiedValue = getTiedValue(connectionItem);\n            portPartSelect = getEndPointPartSelect(connectionItem);\n        }\n        else\n        {\n            tiedValueEditor_->setEnabled(false);\n            tiedValueLeftBoundEditor_->setEnabled(false);\n            tiedValueRightBoundEditor_->setEnabled(false);\n        }\n\n        tiedValueEditor_->blockSignals(true);\n        tiedValueEditor_->setExpression(tiedValue);\n        setTiedValueEditorToolTip(tiedValue);\n        tiedValueEditor_->blockSignals(false);\n\n        updateTiedValueBounds(portPartSelect);\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: AdhocPortEditor::clear()\n//-----------------------------------------------------------------------------\nvoid AdhocPortEditor::clear()\n{\n    portName_->parentWidget()->hide();\n    tiedValueEditor_->parentWidget()->hide();\n}\n\n//-----------------------------------------------------------------------------\n// Function: AdhocPortEditor::getTiedValue()\n//-----------------------------------------------------------------------------\nQString AdhocPortEditor::getTiedValue(QSharedPointer<AdHocConnection> connectionItem) const\n{\n    if (connectionItem)\n    {\n        return connectionItem->getTiedValue();\n    }\n\n    return QString();\n}\n\n//-----------------------------------------------------------------------------\n// Function: AdhocPortEditor::getTiedConnection()\n//-----------------------------------------------------------------------------\nQSharedPointer<AdHocConnection> AdhocPortEditor::getTiedConnection() const\n{\n    QString instanceName = getInstanceName();\n\n    QSharedPointer<Design> containingDesign = designDiagram_->getDesign();\n    for (QSharedPointer<AdHocConnection> connection : *containingDesign->getAdHocConnections())\n    {\n        if (!instanceName.isEmpty())\n        {\n            for (QSharedPointer<PortReference> internalReference : *connection->getInternalPortReferences())\n            {\n                if (internalReference->getPortRef() == containedPortItem_->name() &&\n                    internalReference->getComponentRef() == instanceName &&\n                    (!connection->getTiedValue().isEmpty() || internalReference->getPartSelect()))\n                {\n                    return connection;\n                }\n            }\n        }\n        else\n        {\n            for (QSharedPointer<PortReference> externalReference : *connection->getExternalPortReferences())\n            {\n                if (externalReference->getPortRef() == containedPortItem_->name() &&\n                    (!connection->getTiedValue().isEmpty() || externalReference->getPartSelect()))\n                {\n                    return connection;\n                }\n            }\n        }\n    }\n\n    return QSharedPointer<AdHocConnection>();\n}\n\n//-----------------------------------------------------------------------------\n// Function: AdhocPortEditor::getInstanceName()\n//-----------------------------------------------------------------------------\nQString AdhocPortEditor::getInstanceName() const\n{\n    QString instanceName;\n    ComponentItem* containingInstance = containedPortItem_->encompassingComp();\n    if (containingInstance)\n    {\n        instanceName = containingInstance->name();\n    }\n\n    return instanceName;\n}\n\n//-----------------------------------------------------------------------------\n// Function: AdhocPortEditor::setTiedValueEditorToolTip()\n//-----------------------------------------------------------------------------\nvoid AdhocPortEditor::setTiedValueEditorToolTip(QString const& tiedValue)\n{\n    QString newToolTip;\n\n    if (QString::compare(tiedValue, QLatin1String(\"open\"), Qt::CaseInsensitive) != 0)\n    {\n        QString parsedTieOff = getParsedTieOffValue(tiedValue);\n\n        if (parsedTieOff.isEmpty() && QString::compare(tiedValue, \"default\", Qt::CaseInsensitive) == 0)\n        {\n            newToolTip = QObject::tr(\"No default value defined for port \") + containedPortItem_->name();\n        }\n        else\n        {\n            newToolTip = formattedValueFor(getParsedTieOffValue(tiedValue));\n        }\n    }\n\n    tiedValueEditor_->setToolTip(newToolTip);\n}\n\n//-----------------------------------------------------------------------------\n// Function: AdhocPortEditor::formattedValueFor()\n//-----------------------------------------------------------------------------\nQString AdhocPortEditor::formattedValueFor(QString const& expression) const\n{\n    bool isValidExpression = false;\n    QString value = expressionParser_->parseExpression(expression, &isValidExpression);\n\n    if (isValidExpression)\n    {\n        ValueFormatter formatter;\n        return formatter.format(value, expressionParser_->baseForExpression(expression));\n    }\n    else\n    {\n        return tr(\"n/a\");\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: AdhocPortEditor::onTiedValueChanged()\n//-----------------------------------------------------------------------------\nvoid AdhocPortEditor::onTiedValueChanged()\n{\n    tiedValueEditor_->finishEditingCurrentWord();\n\n    QString newTiedValue = tiedValueEditor_->getExpression();\n\n    setTiedValueEditorToolTip(newTiedValue);\n\n    createTieOffChangeCommand(newTiedValue);\n}\n\n//-----------------------------------------------------------------------------\n// Function: AdhocPortEditor::onTiedValueLeftBoundChanged()\n//-----------------------------------------------------------------------------\nvoid AdhocPortEditor::onTiedValueLeftBoundChanged()\n{\n    tiedValueLeftBoundEditor_->finishEditingCurrentWord();\n\n    QString newLeftBoundValue = tiedValueLeftBoundEditor_->getExpression();\n\n    QString leftToolTip = formattedValueFor(expressionParser_->parseExpression(newLeftBoundValue));\n    tiedValueLeftBoundEditor_->setToolTip(leftToolTip);\n\n    createTieOffBoundsChangeCommand(newLeftBoundValue, tiedValueRightBoundEditor_->getExpression());\n\n    emit contentChanged();\n}\n\n//-----------------------------------------------------------------------------\n// Function: AdhocPortEditor::onTiedValueRightBoundChanged()\n//-----------------------------------------------------------------------------\nvoid AdhocPortEditor::onTiedValueRightBoundChanged()\n{\n    tiedValueRightBoundEditor_->finishEditingCurrentWord();\n\n    QString newRightBoundValue = tiedValueRightBoundEditor_->getExpression();\n\n    QString rightToolTip = formattedValueFor(expressionParser_->parseExpression(newRightBoundValue));\n    tiedValueRightBoundEditor_->setToolTip(rightToolTip);\n\n    createTieOffBoundsChangeCommand(tiedValueLeftBoundEditor_->getExpression(), newRightBoundValue);\n\n    emit contentChanged();\n}\n\n//-----------------------------------------------------------------------------\n// Function: AdhocPortEditor::createTieOffBoundsChangeCommand()\n//-----------------------------------------------------------------------------\nvoid AdhocPortEditor::createTieOffBoundsChangeCommand(QString const& newLeftBound, QString const& newRightBound)\n{\n    QSharedPointer<AdHocConnection> connection = getTiedConnection();\n    if (tieOffBoundsHaveChanged(newLeftBound, newRightBound, connection))\n    {\n        QSharedPointer<AdHocTieOffBoundsChangeCommand> tieOffBoundsCommand(new AdHocTieOffBoundsChangeCommand(\n            containedPortItem_, newLeftBound, newRightBound, connection, designDiagram_));\n\n        connect(tieOffBoundsCommand.data(), SIGNAL(increaseReferences(QString const&)),\n            this, SLOT(onIncreaseReferencesInExpression(QString const&)), Qt::UniqueConnection);\n        connect(tieOffBoundsCommand.data(), SIGNAL(decreaseReferences(QString const&)),\n            this, SLOT(onDecreaseReferencesInExpression(QString const&)), Qt::UniqueConnection);\n        connect(tieOffBoundsCommand.data(), SIGNAL(refreshEditors()),\n            this, SLOT(refreshEditors()), Qt::UniqueConnection);\n\n        editProvider_->addCommand(tieOffBoundsCommand);\n        tieOffBoundsCommand->redo();\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: AdhocPortEditor::tieOffBoundsHaveChanged()\n//-----------------------------------------------------------------------------\nbool AdhocPortEditor::tieOffBoundsHaveChanged(QString const& newLeftBound, QString const& newRightBound,\n    QSharedPointer<AdHocConnection> connection) const\n{\n    QString oldLeft;\n    QString oldRight;\n\n    QSharedPointer<PartSelect> partSelect = getEndPointPartSelect(connection);\n    if (partSelect)\n    {\n        oldLeft = partSelect->getLeftRange();\n        oldRight = partSelect->getRightRange();\n    }\n\n    return !(oldLeft == newLeftBound && oldRight == newRightBound);\n}\n\n//-----------------------------------------------------------------------------\n// Function: AdhocPortEditor::updateTiedValueBounds()\n//-----------------------------------------------------------------------------\nvoid AdhocPortEditor::updateTiedValueBounds(QSharedPointer<PartSelect> portPartSelect)\n{\n    if (portPartSelect)\n    {\n        QString tiedValueLeftValue = portPartSelect->getLeftRange();\n        QString leftToolTip = formattedValueFor(expressionParser_->parseExpression(tiedValueLeftValue));\n\n        QString tiedValueRightValue = portPartSelect->getRightRange();\n        QString rightToolTip = formattedValueFor(expressionParser_->parseExpression(tiedValueRightValue));\n\n        tiedValueLeftBoundEditor_->blockSignals(true);\n        tiedValueLeftBoundEditor_->setExpression(tiedValueLeftValue);\n        tiedValueLeftBoundEditor_->setToolTip(leftToolTip);\n        tiedValueLeftBoundEditor_->blockSignals(false);\n\n        tiedValueRightBoundEditor_->blockSignals(true);\n        tiedValueRightBoundEditor_->setExpression(tiedValueRightValue);\n        tiedValueRightBoundEditor_->setToolTip(rightToolTip);\n        tiedValueRightBoundEditor_->blockSignals(false);\n    }\n    else\n    {\n        QString emptyText;\n\n        tiedValueLeftBoundEditor_->blockSignals(true);\n        tiedValueLeftBoundEditor_->setExpression(emptyText);\n        tiedValueLeftBoundEditor_->setToolTip(emptyText);\n        tiedValueLeftBoundEditor_->blockSignals(false);\n\n        tiedValueRightBoundEditor_->blockSignals(true);\n        tiedValueRightBoundEditor_->setExpression(emptyText);\n        tiedValueRightBoundEditor_->setToolTip(emptyText);\n        tiedValueRightBoundEditor_->blockSignals(false);\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: AdhocPortEditor::getEndPointPartSelect()\n//-----------------------------------------------------------------------------\nQSharedPointer<PartSelect> AdhocPortEditor::getEndPointPartSelect(QSharedPointer<AdHocConnection> adHocConnection)\nconst\n{\n    QString instanceName = getInstanceName();\n\n    if (adHocConnection)\n    {\n        auto adhocPortName = containedPortItem_->name();\n\n        for (QSharedPointer<PortReference> internalPort : *adHocConnection->getInternalPortReferences())\n        {\n            if (internalPort->getPortRef().compare(adhocPortName) == 0 &&\n                internalPort->getComponentRef() == instanceName)\n            {\n                return internalPort->getPartSelect();\n            }\n        }\n\n        for (QSharedPointer<PortReference> externalPort : *adHocConnection->getExternalPortReferences())\n        {\n            if (externalPort->getPortRef().compare(adhocPortName) == 0)\n            {\n                return externalPort->getPartSelect();\n            }\n        }\n    }\n\n    return QSharedPointer<PartSelect>();\n}\n\n//-----------------------------------------------------------------------------\n// Function: AdhocPortEditor::createTieOffChangeCommand()\n//-----------------------------------------------------------------------------\nvoid AdhocPortEditor::createTieOffChangeCommand(QString const& newTiedValue)\n{\n    QString parsedNewTieOff = getParsedTieOffValue(newTiedValue);\n\n    QSharedPointer<AdHocConnection> connection = getTiedConnection();\n\n    QString oldTieOffValue = \"\";\n    QString parsedOldTieOff = \"\";\n\n    if (connection)\n    {\n        oldTieOffValue = connection->getTiedValue();\n        parsedOldTieOff = getParsedTieOffValue(oldTieOffValue);\n    }\n\n    if (newTiedValue != oldTieOffValue)\n    {\n        QString formattedOldTieOff = expressionFormatter_->formatReferringExpression(oldTieOffValue);\n        QString formattedNewTieOff = expressionFormatter_->formatReferringExpression(newTiedValue);\n\n        int oldBase = expressionParser_->baseForExpression(oldTieOffValue);\n        int newBase = expressionParser_->baseForExpression(newTiedValue);\n\n        QSharedPointer<AdHocTieOffChangeCommand> tieOffUndoCommand(new AdHocTieOffChangeCommand(\n            containedPortItem_, connection, newTiedValue, parsedNewTieOff, formattedNewTieOff, newBase,\n            oldTieOffValue, parsedOldTieOff, formattedOldTieOff, oldBase, designDiagram_));\n\n        connect(tieOffUndoCommand.data(), SIGNAL(increaseReferences(QString const&)),\n            this, SLOT(onIncreaseReferencesInExpression(QString const&)), Qt::UniqueConnection);\n        connect(tieOffUndoCommand.data(), SIGNAL(decreaseReferences(QString const&)),\n            this, SLOT(onDecreaseReferencesInExpression(QString const&)), Qt::UniqueConnection);\n        connect(tieOffUndoCommand.data(), SIGNAL(refreshEditors()),\n            this, SLOT(refreshEditors()), Qt::UniqueConnection);\n\n        editProvider_->addCommand(tieOffUndoCommand);\n        tieOffUndoCommand->redo();\n\n        emit contentChanged();\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: AdhocPortEditor::getParsedTieOffValue()\n//-----------------------------------------------------------------------------\nQString AdhocPortEditor::getParsedTieOffValue(QString const& tieOffValue) const\n{\n    QString parsedTieOff;\n\n    if (QString::compare(tieOffValue, QLatin1String(\"default\"), Qt::CaseInsensitive) == 0)\n    {\n        QString portDefaultValue = containedPortItem_->getPort()->getDefaultValue();\n        parsedTieOff = expressionParser_->parseExpression(portDefaultValue);\n    }\n    else if (QString::compare(tieOffValue, QLatin1String(\"open\"), Qt::CaseInsensitive) != 0)\n    {\n        parsedTieOff = expressionParser_->parseExpression(tieOffValue);\n    }\n\n    return parsedTieOff;\n}\n\n//-----------------------------------------------------------------------------\n// Function: AdhocPortEditor::onIncreaseReferencesInExpression()\n//-----------------------------------------------------------------------------\nvoid AdhocPortEditor::onIncreaseReferencesInExpression(QString const& expression)\n{\n    if (!expression.isEmpty())\n    {\n        for (QString const& parameterID : designParameterFinder_->getAllParameterIds())\n        {\n            auto const referencesToID = expression.count(parameterID);\n            for (int i = 0; i < referencesToID; ++i)\n            {\n                emit increaseReferences(parameterID);\n            }\n        }\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: AdhocPortEditor::onDecreaseReferencesInExpression()\n//-----------------------------------------------------------------------------\nvoid AdhocPortEditor::onDecreaseReferencesInExpression(QString const& expression)\n{\n    if (!expression.isEmpty())\n    {\n        for (QString const& parameterID : designParameterFinder_->getAllParameterIds())\n        {\n            auto const referencesToID = expression.count(parameterID);\n            for (int i = 0; i < referencesToID; ++i)\n            {\n                emit decreaseReferences(parameterID);\n            }\n        }\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: AdhocPortEditor::refreshEditors()\n//-----------------------------------------------------------------------------\nvoid AdhocPortEditor::refreshEditors()\n{\n    blockExpressionEditorSignals(true);\n\n    QString tiedValue;\n    QString tieLeftBound;\n    QString tieRightBound;\n\n    QSharedPointer<AdHocConnection> connection = getTiedConnection();\n    if (connection)\n    {\n        tiedValue = connection->getTiedValue();\n\n        QSharedPointer<PartSelect> partSelect = getEndPointPartSelect(connection);\n        if (partSelect)\n        {\n            tieLeftBound = partSelect->getLeftRange();\n            tieRightBound = partSelect->getRightRange();\n        }\n    }\n\n    tiedValueEditor_->setExpression(tiedValue);\n    tiedValueLeftBoundEditor_->setExpression(tieLeftBound);\n    tiedValueRightBoundEditor_->setExpression(tieRightBound);\n\n    blockExpressionEditorSignals(false);\n}\n\n//-----------------------------------------------------------------------------\n// Function: AdhocPortEditor::blockExpressionEditorSignals()\n//-----------------------------------------------------------------------------\nvoid AdhocPortEditor::blockExpressionEditorSignals(bool block)\n{\n    tiedValueEditor_->blockSignals(block);\n    tiedValueLeftBoundEditor_->blockSignals(block);\n    tiedValueRightBoundEditor_->blockSignals(block);\n}\n\n//-----------------------------------------------------------------------------\n// Function: AdhocPortEditor::setupLayout()\n//-----------------------------------------------------------------------------\nvoid AdhocPortEditor::setupLayout()\n{\n    QGroupBox* detailBox = new QGroupBox(tr(\"Port information\"), this);\n    detailBox->setFlat(true);\n    QFormLayout* overallLayout = new QFormLayout(detailBox);\n    overallLayout->addRow(tr(\"Name:\"), portName_);\n    overallLayout->addRow(tr(\"Direction:\"), portDirection_);\n    overallLayout->addRow(tr(\"Left bound:\"), leftBoundValue_);\n    overallLayout->addRow(tr(\"Right bound:\"), rightBoundValue_);\n\n    QGroupBox* tiedValueGroup = new QGroupBox(tr(\"Tied value\"));\n    tiedValueGroup->setFlat(true);\n    QFormLayout* tiedValueLayout = new QFormLayout(tiedValueGroup);\n    tiedValueLayout->addRow(tr(\"Value:\"), tiedValueEditor_);\n    tiedValueLayout->addRow(tr(\"Left bound:\"), tiedValueLeftBoundEditor_);\n    tiedValueLayout->addRow(tr(\"Right bound:\"), tiedValueRightBoundEditor_);\n\n    QVBoxLayout* topLayout = new QVBoxLayout(this);\n    topLayout->addWidget(detailBox);\n    topLayout->addWidget(tiedValueGroup);\n}\n"
  },
  {
    "path": "editors/HWDesign/AdhocEditor/AdhocPortEditor.h",
    "content": "//-----------------------------------------------------------------------------\n// File: AdhocPortEditor.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 29.04.2016\n//\n// Description:\n// Editor to edit the details of an Ad hoc port in designAd-hoc editor.\n//-----------------------------------------------------------------------------\n\n#ifndef ADHOC_PORT_EDITOR_H\n#define ADHOC_PORT_EDITOR_H\n\n#include <editors/common/ConnectionEditor/AdHocBoundsModel.h>\n\n#include <QWidget>\n#include <QLabel>\n#include <QTableWidget>\n\nclass AdHocItem;\nclass AdHocConnection;\nclass PartSelect;\nclass ExpressionEditor;\nclass ExpressionParser;\nclass Design;\nclass IEditProvider;\nclass HWDesignDiagram;\nclass ExpressionFormatter;\nclass ParameterFinder;\n\n//-----------------------------------------------------------------------------\n//! Editor to edit the details of an Ad hoc port in designAd-hoc editor.\n//-----------------------------------------------------------------------------\nclass AdhocPortEditor : public QWidget\n{\n    Q_OBJECT\n\npublic:\n\n    /*!\n     *  The constructor.\n     *\n     *    @param [in] designParameterFinder   Parameter finder for design parameters.\n     *    @param [in] parent                  The parent widget.\n     */\n    AdhocPortEditor(QSharedPointer<ParameterFinder> designParameterFinder, QWidget* parent);\n\n    /*!\n     *  The destructor.\n     */\n    virtual ~AdhocPortEditor() = default;\n\n    /*!\n     *  Set the ad hoc port.\n     *\n     *    @param [in] endPoint            The selected ad hoc port.\n     *    @param [in] containingDiagram   The design diagram containing the ad hoc port.\n     *    @param [in] editProvider        The provider for undo commands.\n     */\n    void setAdhocPort(AdHocItem* endPoint, HWDesignDiagram* containingDiagram,\n        QSharedPointer<IEditProvider> editProvider);\n\npublic slots:\n\n    /*!\n     *  Hides all information in the editor.\n     */\n    void clear();\n\nprivate slots:\n\n    /*!\n     *  Handles the changes in tied value editor.\n     */\n    void onTiedValueChanged();\n\n    /*!\n     *  Handles the changes in the left bound of the tied value.\n     */\n    void onTiedValueLeftBoundChanged();\n\n    /*!\n     *  Handles the changes in the right bound of the tied value.\n     */\n    void onTiedValueRightBoundChanged();\n\n    /*!\n     *  Handles the increasing of parameter reference counts in the selected expression.\n     *\n     *    @param [in] expression  The selected expression.\n     */\n    void onIncreaseReferencesInExpression(QString const& expression);\n\n    /*!\n     *  Handles the decreasing of parameter reference counts in the selected expression.\n     *\n     *    @param [in] expression  The selected expression.\n     */\n    void onDecreaseReferencesInExpression(QString const& expression);\n\n    /*!\n     *  Handles the refreshing of ad hoc tied value editors.\n     */\n    void refreshEditors();\n\nsignals:\n\n    /*!\n     *  Informs of a change in the contents.\n     */\n    void contentChanged();\n\n    /*!\n     *  Informs of new references made to the parameter with the selected ID.\n     *\n     *    @param [in] parameterID     ID of the selected parameter.\n     */\n    void increaseReferences(QString const& parameterID);\n\n    /*!\n     *  Informs of removing references from the parameter with the selected ID.\n     *\n     *    @param [in] parameterID     ID of the selected parameter.\n     */\n    void decreaseReferences(QString const& parameterID);\n\nprivate:\n\n    // Disable copying.\n    AdhocPortEditor(AdhocPortEditor const& rhs);\n    AdhocPortEditor& operator=(AdhocPortEditor const& rhs);\n\n    /*!\n     *  Calculate the formatted value for a given expression.\n     *\n     *    @param [in] expression  The selected expression.\n     *\n     *    @return The formatted value of a given expression.\n     */\n    QString formattedValueFor(QString const& expression) const;\n\n    /*!\n     *  Get the tied value associated with contained ad hoc port.\n     *\n     *    @param [in] connectionItem  The tied value connection of the associated ad hoc port.\n     *\n     *    @return The tied value of the ad hoc port.\n     */\n    QString getTiedValue(QSharedPointer<AdHocConnection> connectionItem) const;\n\n    /*!\n     *  Get the ad hoc connection containing this ad hoc ports tied value.\n     *\n     *    @return The selected ad hoc connection, or an empty pointer if no connection was found.\n     */\n    QSharedPointer<AdHocConnection> getTiedConnection() const;\n\n    QString getInstanceName() const;\n\n    /*!\n     *  Create a tie off change command.\n     *\n     *    @param [in] newTiedValue    The new tie off value.\n     */\n    void createTieOffChangeCommand(QString const& newTiedValue);\n\n    /*!\n     *  Calculate the tie off value.\n     *\n     *    @param [in] tieOffValue     The selected tie off value.\n     *\n     *    @return The calculated tie off value.\n     */\n    QString getParsedTieOffValue(QString const& tieOffValue) const;\n\n    /*!\n     *  Set a tool tip for the tied value editor.\n     *\n     *    @param [in] tiedValue   The new tied value.\n     */\n    void setTiedValueEditorToolTip(QString const& tiedValue);\n\n    /*!\n     *  Update the bounds of the tied value connection.\n     *\n     *    @param [in] portPartSelect  Part select of the referenced port.\n     */\n    void updateTiedValueBounds(QSharedPointer<PartSelect> portPartSelect);\n\n    /*!\n     *  Get the part select of the referenced port.\n     *\n     *    @param [in] adHocConnection     Connection containing the ad hoc item.\n     *\n     *    @return The part select of the referenced port.\n     */\n    QSharedPointer<PartSelect> getEndPointPartSelect(QSharedPointer<AdHocConnection> adHocConnection) const;\n\n    /*!\n     *  Create a change command for the tie off bounds.\n     *\n     *    @param [in] newLeftBound    New value for the left bound of the tied value.\n     *    @param [in] newRightBound   New value for the right bounds of the tied value.\n     */\n    void createTieOffBoundsChangeCommand(QString const& newLeftBound, QString const& newRightBound);\n\n    /*!\n     *  Check if the new tie off bounds values differ from the current values.\n     *\n     *    @param [in] newLeftBound    New tie off left bound.\n     *    @param [in] newRightBound   New tie off right bound.\n     *    @param [in] connection      The selected ad hoc connection.\n     *\n     *    @return True, if the tie off values have changed, false otherwise.\n     */\n    bool tieOffBoundsHaveChanged(QString const& newLeftBound, QString const& newRightBound,\n        QSharedPointer<AdHocConnection> connection) const;\n\n    /*!\n     *  Change the signal block status of the expression editors.\n     *\n     *    @param [in] block   New block status for the expression editor signals.\n     */\n    void blockExpressionEditorSignals(bool block);\n\n    /*!\n     *  Setup the layout.\n     */\n    void setupLayout();\n\n    //-----------------------------------------------------------------------------\n    // Data.\n    //-----------------------------------------------------------------------------\n\n    //! The used expression parser.\n    QSharedPointer<ExpressionParser> expressionParser_;\n\n    //! Used to format the referenced parameter UUIDs to parameter names.\n    QSharedPointer<ExpressionFormatter> expressionFormatter_;\n\n    //! Label containing the name of the ad hoc port.\n    QLabel* portName_;\n\n    //! Label containing the direction of the ad hoc port.\n    QLabel* portDirection_;\n\n    //! Label containing the left bound value of the ad hoc port.\n    QLabel* leftBoundValue_;\n\n    //! Label containing the right bound value of the ad hoc port.\n    QLabel* rightBoundValue_;\n\n    //! Expression editor for the tied value.\n    ExpressionEditor* tiedValueEditor_;\n\n    //! The selected ad hoc port item.\n    AdHocItem* containedPortItem_;\n\n    //! The currently used provider for undo commands.\n    QSharedPointer<IEditProvider> editProvider_;\n\n    //! The design diagram containing the ad hoc port item.\n    HWDesignDiagram* designDiagram_;\n\n    //! Editor for the left bound value of the tied value.\n    ExpressionEditor* tiedValueLeftBoundEditor_;\n\n    //! Editor for the right bound value of the tied value.\n    ExpressionEditor* tiedValueRightBoundEditor_;\n\n    //! The used design parameter finder.\n    QSharedPointer<ParameterFinder> designParameterFinder_;\n};\n\n#endif // ADHOC_PORT_EDITOR_H\n"
  },
  {
    "path": "editors/HWDesign/BusInterfaceDialog.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: BusInterfaceDialog.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Joni-Matti Maatta\r\n// Date: 30.5.2011\r\n//\r\n// Description:\r\n// Interface mode selection dialog.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"BusInterfaceDialog.h\"\r\n\r\n#include <QLabel>\r\n\r\n#include <KactusAPI/include/LibraryInterface.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusInterfaceDialog::BusInterfaceDialog()\r\n//-----------------------------------------------------------------------------\r\nBusInterfaceDialog::BusInterfaceDialog(QWidget* parent) \r\n    : QDialog(parent),\r\n      modeGroup_(new QGroupBox(tr(\"Select Interface Mode\"), this)),\r\n      btnOK_(new QPushButton(tr(\"&OK\"),this)),\r\n      btnCancel_(new QPushButton(tr(\"&Cancel\"),this))\r\n{\r\n    setWindowTitle(tr(\"Define Bus Interface\"));\r\n\r\n    // Create the radio button group.\r\n    for (unsigned int i = 0; i < General::INTERFACE_MODE_COUNT; i++)\r\n    {\r\n        QString modeName = General::interfaceMode2Str(static_cast<General::InterfaceMode>(i));\r\n        modeName.replace(0, 1, modeName.at(0).toUpper());\r\n\r\n        modeRadioButtons_[i] = new QRadioButton(modeName, modeGroup_);\r\n        modeRadioButtons_[i]->setVisible(false);       \r\n    }\r\n\r\n    // Connect the button signals to accept() and reject().\r\n    connect(btnOK_, SIGNAL(clicked()), this, SLOT(accept()));\r\n    connect(btnCancel_, SIGNAL(clicked()), this, SLOT(reject()));    \r\n\r\n    setupLayout();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusInterfaceDialog::~BusInterfaceDialog()\r\n//-----------------------------------------------------------------------------\r\nBusInterfaceDialog::~BusInterfaceDialog()\r\n{\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusInterfaceDialog::addMode()\r\n//-----------------------------------------------------------------------------\r\nvoid BusInterfaceDialog::addMode(General::InterfaceMode mode)\r\n{\r\n    modeRadioButtons_[mode]->setVisible(true);\r\n    modeRadioButtons_[mode]->setChecked(true);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusInterfaceDialog::getSelectedMode()\r\n//-----------------------------------------------------------------------------\r\nGeneral::InterfaceMode BusInterfaceDialog::getSelectedMode() const\r\n{\r\n    for (unsigned int i = 0; i < General::INTERFACE_MODE_COUNT; ++i)\r\n    {\r\n        if (modeRadioButtons_[i]->isChecked())\r\n        {\r\n            return static_cast<General::InterfaceMode>(i);\r\n        }\r\n    }\r\n\r\n    // Should not be possible to get here.\r\n    Q_ASSERT(false);\r\n    return General::MASTER;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusInterfaceDialog::setupLayout()\r\n//-----------------------------------------------------------------------------\r\nvoid BusInterfaceDialog::setupLayout()\r\n{\r\n    QVBoxLayout* topLayout = new QVBoxLayout(this);\r\n\r\n    // Create vertical layout for radio buttons.\r\n    QGridLayout* itemLayout = new QGridLayout(modeGroup_);\r\n    for (unsigned int i = 0; i < General::INTERFACE_MODE_COUNT; i++)\r\n    {\r\n        itemLayout->addWidget(modeRadioButtons_[i], i, 0, 1, 1);\r\n    }\r\n\r\n    topLayout->addWidget(modeGroup_);\r\n  \r\n    // Create layout for OK and Cancel buttons.\r\n    QHBoxLayout* buttonLayout = new QHBoxLayout();\r\n    buttonLayout->addStretch();\r\n    buttonLayout->addWidget(btnOK_, 0, Qt::AlignRight);\r\n    buttonLayout->addWidget(btnCancel_, 0, Qt::AlignRight);\r\n\r\n    topLayout->addLayout(buttonLayout);\r\n}\r\n"
  },
  {
    "path": "editors/HWDesign/BusInterfaceDialog.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: BusInterfaceDialog.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Joni-Matti Maatta\r\n// Date: 30.5.2011\r\n//\r\n// Description:\r\n// Interface mode selection dialog.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef SELECTINTERFACEMODEDIALOG_H\r\n#define SELECTINTERFACEMODEDIALOG_H\r\n\r\n#include <IPXACTmodels/generaldeclarations.h>\r\n\r\n#include <QDialog>\r\n#include <QGridLayout>\r\n#include <QGroupBox>\r\n#include <QRadioButton>\r\n#include <QPushButton>\r\n\r\n//-----------------------------------------------------------------------------\r\n//! BusInterfaceDialog class.\r\n//-----------------------------------------------------------------------------\r\nclass BusInterfaceDialog : public QDialog\r\n{\r\n    Q_OBJECT\r\n\r\npublic:\r\n    /*!\r\n     *  Constructor.\r\n     *\r\n     *    @param [in] parent          The parent widget.\r\n     */\r\n    BusInterfaceDialog(QWidget* parent = 0);\r\n\r\n    /*!\r\n     *  Destructor.\r\n     */\r\n    ~BusInterfaceDialog();\r\n    \r\n    /*!\r\n     *  Adds a mode to the possible alternatives.\r\n     *\r\n     *    @param [in] mode The interface mode to add.\r\n     */\r\n    void addMode(General::InterfaceMode mode);\r\n\r\n    /*!\r\n     *  Returns the selected mode.\r\n     */\r\n    General::InterfaceMode getSelectedMode() const;\r\n\r\n\r\nprivate:\r\n    // Disable copying.\r\n    BusInterfaceDialog(BusInterfaceDialog const& rhs);\r\n    BusInterfaceDialog& operator=(BusInterfaceDialog const& rhs);\r\n\r\n    /*!\r\n     *  Sets dialog layout for interface selection.\r\n     *\r\n     */\r\n    void setupLayout();\r\n\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! The group box for the mode selection.\r\n    QGroupBox* modeGroup_;\r\n\r\n    //! The OK button.\r\n    QPushButton* btnOK_;\r\n\r\n    //! The Cancel button.\r\n    QPushButton* btnCancel_;\r\n\r\n    //! The mode radio buttons.\r\n    QRadioButton* modeRadioButtons_[General::MONITOR + 1];\r\n\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n\r\n#endif // SELECTINTERFACEMODEDIALOG_H\r\n"
  },
  {
    "path": "editors/HWDesign/BusInterfaceEndPoint.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: BusInterfaceEndPoint.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 02.02.2018\n//\n// Description:\n// Parent interface class for HW bus interfaces.\n//-----------------------------------------------------------------------------\n\n#include \"BusInterfaceEndPoint.h\"\n\n#include <common/graphicsItems/GraphicsConnection.h>\n#include <common/graphicsItems/CommonGraphicsUndoCommands.h>\n#include <common/IEditProvider.h>\n\n#include <editors/common/DesignDiagram.h>\n#include <editors/common/diagramgrid.h>\n#include <editors/HWDesign/InterfaceGraphics.h>\n#include <editors/HWDesign/HWMoveCommands.h>\n#include <editors/HWDesign/columnview/HWColumn.h>\n\n#include <IPXACTmodels/Component/Component.h>\n#include <IPXACTmodels/Component/BusInterface.h>\n\n#include <QFont>\n#include <QGraphicsDropShadowEffect>\n#include <QGraphicsScene>\n\n//-----------------------------------------------------------------------------\n// Function: BusInterfaceEndPoint::BusInterfaceEndPoint()\n//-----------------------------------------------------------------------------\nBusInterfaceEndPoint::BusInterfaceEndPoint(QSharedPointer<BusInterface> busIf, QSharedPointer<Component> component,\n    LibraryInterface* library, bool isDraft, QGraphicsItem* parent, QVector2D const& dir) :\n    HWConnectionEndpoint(busIf->name(), component, parent, dir),\n    busInterface_(busIf),\n    library_(library),\n    isDraft_(isDraft)\n{\n    portMapWarning_->setVisible(false);\n}\n\n//-----------------------------------------------------------------------------\n// Function: BusInterfaceEndPoint::getBusInterface()\n//-----------------------------------------------------------------------------\nQSharedPointer<BusInterface> BusInterfaceEndPoint::getBusInterface() const\n{\n    return busInterface_;\n}\n\n//-----------------------------------------------------------------------------\n// Function: BusInterfaceEndPoint::updateEndPointGraphics()\n//-----------------------------------------------------------------------------\nvoid BusInterfaceEndPoint::updateEndPointGraphics()\n{\n    QPolygonF shape;\n\n    DirectionTypes::Direction direction =\n        InterfaceGraphics::getInterfaceDirection(busInterface_, getOwnerComponent());\n    TransactionalTypes::Initiative initiative =\n        InterfaceGraphics::getInterfaceInitiative(busInterface_, getOwnerComponent());\n\n    if (direction == DirectionTypes::DIRECTION_INVALID && initiative != TransactionalTypes::Initiative::INITIATIVE_INVALID)\n    {\n        shape = getInterfaceShapeWithInitiative(initiative);\n    }\n    else\n    {\n        shape = getInterfaceShapeWithDirection(direction);\n    }\n\n    if (busInterface_->getAllPortMaps()->isEmpty() && !getIsDraft())\n    {\n        portMapWarning_->setVisible(true);\n    }\n    else\n    {\n        portMapWarning_->setVisible(false);\n    }\n\n    setPolygon(shape);\n}\n\n\n//-----------------------------------------------------------------------------\n// Function: BusInterfaceEndPoint::getInterfaceShapeWithDirection()\n//-----------------------------------------------------------------------------\nQPolygonF BusInterfaceEndPoint::getInterfaceShapeWithDirection(DirectionTypes::Direction direction) const\n{\n    if (direction == DirectionTypes::IN)\n    {\n        if (isHierarchical())\n        {\n            return getDirectionOutShape();\n        }\n        else\n        {\n            return getDirectionInShape();\n        }\n    }\n    else if (direction == DirectionTypes::OUT)\n    {\n        if (isHierarchical())\n        {\n            return getDirectionInShape();\n        }\n        else\n        {\n            return getDirectionOutShape();\n        }\n    }\n    else\n    {\n        return getDirectionInOutShape();\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: BusInterfaceEndPoint::getInterfaceShapeWithInitiative()\n//-----------------------------------------------------------------------------\nQPolygonF BusInterfaceEndPoint::getInterfaceShapeWithInitiative(TransactionalTypes::Initiative initiative) const\n{\n    if (initiative == TransactionalTypes::Initiative::PROVIDES)\n    {\n        return getInitiativeProvidesShape();\n    }\n    else if (initiative == TransactionalTypes::Initiative::REQUIRES)\n    {\n        return getInitiativeRequiresShape();\n    }\n    else\n    {\n        return getInitiativeRequiresProvidesShape();\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: BusInterfaceEndPoint::name()\n//-----------------------------------------------------------------------------\nQString BusInterfaceEndPoint::name() const\n{\n    return busInterface_->name();\n}\n\n//-----------------------------------------------------------------------------\n// Function: BusInterfaceEndPoint::setName()\n//-----------------------------------------------------------------------------\nvoid BusInterfaceEndPoint::setName(QString const& name)\n{\n    HWConnectionEndpoint::setName(name);\n    beginUpdateConnectionNames();\n\n    QString previousName = busInterface_->name();\n\n    busInterface_->setName(name);\n\n    updateName(previousName, name);\n\n    updateInterface();\n    emit contentChanged();\n\n    endUpdateConnectionNames();\n}\n\n//-----------------------------------------------------------------------------\n// Function: BusInterfaceEndPoint::setBusInterface()\n//-----------------------------------------------------------------------------\nvoid BusInterfaceEndPoint::setBusInterface(QSharedPointer<BusInterface> newBus)\n{\n    busInterface_ = newBus;\n}\n\n//-----------------------------------------------------------------------------\n// Function: BusInterfaceEndPoint::description()\n//-----------------------------------------------------------------------------\nQString BusInterfaceEndPoint::description() const\n{\n    if (busInterface_)\n    {\n        return busInterface_->description();\n    }\n    else\n    {\n        return QString();\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: BusInterfaceEndPoint::setDescription()\n//-----------------------------------------------------------------------------\nvoid BusInterfaceEndPoint::setDescription(QString const& description)\n{\n    if (busInterface_)\n    {\n        busInterface_->setDescription(description);\n        emit contentChanged();\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: BusInterfaceEndPoint::isExclusive()\n//-----------------------------------------------------------------------------\nbool BusInterfaceEndPoint::isExclusive() const\n{\n    return false;\n}\n\n//-----------------------------------------------------------------------------\n// Function: BusInterfaceEndPoint::setDirection()\n//-----------------------------------------------------------------------------\nvoid BusInterfaceEndPoint::setDirection(QVector2D const& dir)\n{\n    portMapWarning_->moveSymbol(dir);\n\n    HWConnectionEndpoint::setDirection(dir);\n}\n\n//-----------------------------------------------------------------------------\n// Function: BusInterfaceEndPoint::isBus()\n//-----------------------------------------------------------------------------\nbool BusInterfaceEndPoint::isBus() const noexcept\n{\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: BusInterfaceEndPoint::getType()\n//-----------------------------------------------------------------------------\nConnectionEndpoint::EndpointType BusInterfaceEndPoint::getType() const noexcept\n{\n    return ConnectionEndpoint::ENDPOINT_TYPE_BUS;\n}\n\n//-----------------------------------------------------------------------------\n// Function: BusInterfaceEndPoint::setInterfaceMode()\n//-----------------------------------------------------------------------------\nvoid BusInterfaceEndPoint::setInterfaceMode(General::InterfaceMode mode)\n{\n    if (busInterface_)\n    {\n        busInterface_->setInterfaceMode(mode);\n        updateInterface();\n        emit contentChanged();\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: BusInterfaceEndPoint::getInterfaceMode()\n//-----------------------------------------------------------------------------\nGeneral::InterfaceMode BusInterfaceEndPoint::getInterfaceMode() const\n{\n    return busInterface_->getInterfaceMode();\n}\n\n//-----------------------------------------------------------------------------\n// Function: BusInterfaceEndPoint::getOldPosition()\n//-----------------------------------------------------------------------------\nQPointF BusInterfaceEndPoint::getOldPosition() const\n{\n    return oldPos_;\n}\n\n//-----------------------------------------------------------------------------\n// Function: BusInterfaceEndPoint::setOldPosition()\n//-----------------------------------------------------------------------------\nvoid BusInterfaceEndPoint::setOldPosition(QPointF const& newPosition)\n{\n    oldPos_ = newPosition;\n}\n\n//-----------------------------------------------------------------------------\n// Function: BusInterfaceEndPoint::saveOldPortPositions()\n//-----------------------------------------------------------------------------\nvoid BusInterfaceEndPoint::saveOldPortPositions(QList<QGraphicsItem*> items)\n{\n    for (QGraphicsItem* item : items)\n    {\n        ConnectionEndpoint* endPointItem = dynamic_cast<ConnectionEndpoint*>(item);\n        if (endPointItem && item != this && endPointItem->isHierarchical() == isHierarchical())\n        {\n            oldPortPositions_.insert(endPointItem, endPointItem->pos());\n        }\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: BusInterfaceEndPoint::getOldPortPositions()\n//-----------------------------------------------------------------------------\nQMap<ConnectionEndpoint*, QPointF> BusInterfaceEndPoint::getOldPortPositions() const\n{\n    return oldPortPositions_;\n}\n\n//-----------------------------------------------------------------------------\n// Function: BusInterfaceEndPoint::clearOldPortPositions()\n//-----------------------------------------------------------------------------\nvoid BusInterfaceEndPoint::clearOldPortPositions()\n{\n    oldPortPositions_.clear();\n}\n\n//-----------------------------------------------------------------------------\n// Function: BusInterfaceEndPoint::mouseReleaseEvent()\n//-----------------------------------------------------------------------------\nvoid BusInterfaceEndPoint::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)\n{\n    if (sceneIsLocked())\n    {\n        return;\n    }\n\n    HWConnectionEndpoint::mouseReleaseEvent(event);\n    setZValue(0.0);\n\n    auto diagram = dynamic_cast<DesignDiagram*>(scene());\n    if (diagram)\n    {\n        QSharedPointer<QUndoCommand> moveCommand = createMouseMoveCommand(diagram);\n        if (moveCommand)\n        {\n            QMap<ConnectionEndpoint*, QPointF> oldPortPositions = getOldPortPositions();\n            QMap<ConnectionEndpoint*, QPointF>::iterator cur = oldPortPositions.begin();\n            while (cur != oldPortPositions.end())\n            {\n                createMoveCommandForClashedItem(cur.key(), cur.value(), diagram, moveCommand);\n                ++cur;\n            }\n\n            clearOldPortPositions();\n\n            // End the position update for all connections.\n            endUpdateConnectionPositions(moveCommand.data());\n\n            // Add the undo command to the edit stack only if it has changes.\n            if (moveCommand->childCount() > 0 || getOldPosition() != getCurrentPosition())\n            {\n                diagram->getEditProvider()->addCommand(moveCommand);\n                moveCommand->redo();\n            }\n        }\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: BusInterfaceEndPoint::isConnectionValid()\n//-----------------------------------------------------------------------------\nbool BusInterfaceEndPoint::isConnectionValid(ConnectionEndpoint const* other) const\n{\n    if (!HWConnectionEndpoint::isConnectionValid(other) || !other->isBus() || other->getBusInterface() == nullptr)\n    {\n        return false;\n    }\n\n    return canConnectToInterface(other);\n}\n\n//-----------------------------------------------------------------------------\n// Function: BusInterfaceEndPoint::onConnect()\n//-----------------------------------------------------------------------------\nbool BusInterfaceEndPoint::onConnect(ConnectionEndpoint const* other)\n{\n    updateInterface();\n\n    return other != nullptr;\n}\n\n//-----------------------------------------------------------------------------\n// Function: BusInterfaceEndPoint::getDirectionOutShape()\n//-----------------------------------------------------------------------------\nQPolygonF BusInterfaceEndPoint::getDirectionOutShape()\n{\n    constexpr int squareSize = GridSize;\n    QPolygonF shape({\n        QPointF(-squareSize / 2, squareSize / 2),\n        QPointF(-squareSize / 2, 0),\n        QPointF(0, -squareSize / 2),\n        QPointF(squareSize / 2, 0),\n        QPointF(squareSize / 2, squareSize / 2)\n    });\n\n    return shape;\n}\n\n//-----------------------------------------------------------------------------\n// Function: BusInterfaceEndPoint::getDirectionInShape()\n//-----------------------------------------------------------------------------\nQPolygonF BusInterfaceEndPoint::getDirectionInShape()\n{\n    constexpr int squareSize = GridSize;\n\n    QPolygonF shape({ QPointF(-squareSize / 2, 0),\n        QPointF(-squareSize / 2, -squareSize / 2),\n        QPointF(squareSize / 2, -squareSize / 2),\n        QPointF(squareSize / 2, 0),\n        QPointF(0, squareSize / 2),\n    });\n\n    return shape;\n}\n\n//-----------------------------------------------------------------------------\n// Function: BusInterfaceEndPoint::getDirectionInOutShape()\n//-----------------------------------------------------------------------------\nQPolygonF BusInterfaceEndPoint::getDirectionInOutShape()\n{\n    constexpr int squareSize = GridSize;\n\n    QPolygonF shape({\n        QPointF(-squareSize / 2, squareSize / 2),\n        QPointF(-squareSize / 2, 0),\n        QPointF(0, -squareSize / 2),\n        QPointF(squareSize / 2, 0),\n        QPointF(squareSize / 2, squareSize / 2),\n        QPointF(0, squareSize)\n    });\n\n    return shape;\n}\n\n//-----------------------------------------------------------------------------\n// Function: BusInterfaceEndPoint::getInitiativeProvidesShape()\n//-----------------------------------------------------------------------------\nQPolygonF BusInterfaceEndPoint::getInitiativeProvidesShape()\n{\n    constexpr int squareSize = GridSize;\n\n    QPolygonF shape({\n        QPointF(-squareSize / 2, squareSize * 3 / 4),\n        QPointF(-squareSize / 2, -squareSize / 4),\n        QPointF(-squareSize / 4, -squareSize / 4),\n        QPointF(-squareSize / 4, -squareSize / 2),\n        QPointF(squareSize / 4, -squareSize / 2),\n        QPointF(squareSize / 4, -squareSize / 4),\n        QPointF(squareSize / 2, -squareSize / 4),\n        QPointF(squareSize / 2, squareSize * 3 / 4)\n    });\n\n    return shape;\n}\n\n//-----------------------------------------------------------------------------\n// Function: BusInterfaceEndPoint::getInitiativeRequiresShape()\n//-----------------------------------------------------------------------------\nQPolygonF BusInterfaceEndPoint::getInitiativeRequiresShape()\n{\n    constexpr int squareSize = GridSize;\n\n    QPolygonF shape({\n        QPointF(-squareSize / 2, squareSize * 3 / 4),\n        QPointF(-squareSize / 2, -squareSize / 2),\n        QPointF(-squareSize / 4, -squareSize / 2),\n        QPointF(-squareSize / 4, -squareSize / 4),\n        QPointF(squareSize / 4, -squareSize / 4),\n        QPointF(squareSize / 4, -squareSize / 2),\n        QPointF(squareSize / 2, -squareSize / 2),\n        QPointF(squareSize / 2, squareSize * 3 / 4)\n    });\n\n    return shape;\n}\n\n//-----------------------------------------------------------------------------\n// Function: BusInterfaceEndPoint::getInitiativeRequiresProvidesShape()\n//-----------------------------------------------------------------------------\nQPolygonF BusInterfaceEndPoint::getInitiativeRequiresProvidesShape()\n{\n    constexpr int squareSize = GridSize;\n\n    QPolygonF shape({\n        QPointF(-squareSize / 2, squareSize * 3 / 4),\n        QPointF(-squareSize / 2, -squareSize / 4),\n        QPointF(-squareSize / 4, -squareSize / 4),\n        QPointF(-squareSize / 4, -squareSize / 2),\n        QPointF(squareSize / 4, -squareSize / 2),\n        QPointF(squareSize / 4, -squareSize / 4),\n        QPointF(squareSize / 2, -squareSize / 4),\n        QPointF(squareSize / 2, squareSize * 3 / 4),\n        QPointF(squareSize / 4, squareSize * 3 / 4),\n        QPointF(squareSize / 4, squareSize / 2),\n        QPointF(-squareSize / 4, squareSize / 2),\n        QPointF(-squareSize / 4, squareSize * 3 / 4)\n    });\n\n    return shape;\n}\n\n//-----------------------------------------------------------------------------\n// Function: BusInterfaceEndPoint::getLibraryAccess()\n//-----------------------------------------------------------------------------\nLibraryInterface* BusInterfaceEndPoint::getLibraryAccess() const\n{\n    return library_;\n}\n\n//-----------------------------------------------------------------------------\n// Function: BusInterfaceEndPoint::getIsDraft()\n//-----------------------------------------------------------------------------\nbool BusInterfaceEndPoint::getIsDraft() const\n{\n    return isDraft_;\n}\n\n//-----------------------------------------------------------------------------\n// Function: BusInterfaceEndPoint::setIsDraft()\n//-----------------------------------------------------------------------------\nvoid BusInterfaceEndPoint::setIsDraft(bool isDraft)\n{\n    isDraft_ = isDraft;\n}\n"
  },
  {
    "path": "editors/HWDesign/BusInterfaceEndPoint.h",
    "content": "//-----------------------------------------------------------------------------\n// File: BusInterfaceEndPoint.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 02.02.2018\n//\n// Description:\n// Parent interface class for HW bus interfaces.\n//-----------------------------------------------------------------------------\n\n#ifndef BUSINTERFACEENDPOINT_H\n#define BUSINTERFACEENDPOINT_H\n\n#include <editors/HWDesign/HWConnectionEndpoint.h>\n#include <editors/HWDesign/WarningSymbol.h>\n\n#include <QSharedPointer>\n#include <QGraphicsTextItem>\n#include <QUndoCommand>\n\nclass InterfaceGraphicsData;\nclass Component;\nclass BusInterface;\nclass Port;\nclass DesignDiagram;\nclass HWComponentItem;\nclass LibraryInterface;\n\n//-----------------------------------------------------------------------------\n//! Parent interface class for HW bus interfaces.\n//-----------------------------------------------------------------------------\nclass BusInterfaceEndPoint : public HWConnectionEndpoint\n{\n    Q_OBJECT\n\npublic:\n\n    /*!\n     *  The constructor.\n     *\n     *    @param [in] busIf       The bus interface this item represents.\n     *    @param [in] component   Component containing the bus interface.\n     *    @param [in] library     Access to the library.\n     *    @param [in] parent      The parent object.\n     *    @param [in] dir         Direction for the end point graphics.\n     */\n    BusInterfaceEndPoint(QSharedPointer<BusInterface> busIf, QSharedPointer<Component> component,\n        LibraryInterface* library, bool isDraft, QGraphicsItem *parent = nullptr, QVector2D const& dir = QVector2D(0.0f, -1.0f));\n\n\t/*!\n     *  The destructor.\n     */\n    ~BusInterfaceEndPoint() override = default;\n\n    // Disable copying.\n    BusInterfaceEndPoint(BusInterfaceEndPoint const& rhs) = delete;\n    BusInterfaceEndPoint& operator=(BusInterfaceEndPoint const& rhs) = delete;\n\n    /*!\n     *  Get the name of the bus interface.\n     */\n    QString name() const override;\n\n    /*!\n     *  Set a new name for the bus interface.\n     *\n     *    @param [in] name    The new bus interface name.\n     */\n    void setName(QString const& name) override;\n    \n    /*!\n     *  Get the description of the bus interface.\n\t *\n\t *    @return The bus interface description.\n     */\n\tQString description() const override;\n\n\t/*!\n     *  Set a new description for the bus interface.\n\t *\n\t *    @param [in] description     The selected description to set.\n     */\n\tvoid setDescription(QString const& description) override;\n\n    /*!\n     *  Get the contained bus interface.\n     *\n     *    @return The contained bus interface.\n     */\n    QSharedPointer<BusInterface> getBusInterface() const override;\n\n    /*!\n     *  Check if the bus interface can only have one connection.\n     *\n     *    @return True, if the bus interface is exclusive, false otherwise.\n     */\n    bool isExclusive() const override;\n\n    /*!\n     *  Sets the draw direction of the endpoint.\n     *\n     *    @param [in] dir The draw direction to set.\n     *\n     *      @remarks The direction can be changed only if isDirectionFixed() returns false.\n     */\n    void setDirection(QVector2D const& dir) override;\n\n    /*!\n     *  Check if the end point is a bus interface.\n     *\n     *    @return True.\n     */\n    bool isBus() const noexcept override;\n\n    /*!\n     *  Get the type of the connection end point.\n     *\n     *    @return This end point is a bus interface.\n     */\n    ConnectionEndpoint::EndpointType getType() const noexcept override;\n\n    /*!\n     *  Set the interface mode for the end point.\n\t *\n\t *    @param mode [in]    The interface mode to set.\n     */\n\tvirtual void setInterfaceMode(General::InterfaceMode mode);\n\n    /*!\n     *  Get the mode of the contained bus interface.\n     *\n     *    @return The bus interface mode.\n     */\n    virtual General::InterfaceMode getInterfaceMode() const;\n\n    /*!\n     *  Check if a connection can be made to the selected end point.\n     *\n     *    @param [in] other   The end point to be connected.\n     *\n     *    @return True, if the connection can be made, false otherwise.\n     */\n    bool isConnectionValid(ConnectionEndpoint const* other) const override;\n\n    /*!\n     *  Handles the connecting of the connection end points.\n     *\n     *    @param [in] other   The other end of the connection.\n     *\n     *    @return True, if the connection was made successfully, false otherwise.\n     */\n    bool onConnect(ConnectionEndpoint const* other) override;\n\n    /*!\n     *  Set a new bus interface.\n     *\n     *    @param [in] newBus  The selected bus interface.\n     */\n    void setBusInterface(QSharedPointer<BusInterface> newBus);\n\nprotected:\n\n    /*!\n     *  Get the position of the bus interface item before moving it.\n     *\n     *    @return The old position of the bus interface item.\n     */\n    QPointF getOldPosition() const;\n\n    /*!\n     *  Store the given position as the old position of the item.\n     *\n     *    @param [in] newPosition     The position to be stored.\n     */\n    void setOldPosition(QPointF const& newPosition);\n\n    /*!\n     *  Set the positions of the end point items from the same level as this item.\n     *\n     *    @param [in] items   List of the associated end point items.\n     */\n    void saveOldPortPositions(QList<QGraphicsItem*> items);\n\n    /*!\n     *  Get the stored positions of the associated end point items.\n     *\n     *    @return The stored positions of the associated end point items.\n     */\n    QMap<ConnectionEndpoint*, QPointF> getOldPortPositions() const;\n\n    /*!\n     *  Clear the stored positions of the associated end points.\n     */\n    void clearOldPortPositions();\n\n    /*!\n     *  Handle the mouse release events.\n     *\n     *    @param [in] event   The mouse release event.\n     */\n    void mouseReleaseEvent(QGraphicsSceneMouseEvent *event) override;\n\n    /*!\n     *  Get the shape of the bus interface with direction in.\n     *\n     *    @return The shape of the bus interface with direction in.\n     */\n    static QPolygonF getDirectionInShape();\n\n    /*!\n     *  Get the shape of the bus interface with direction out.\n     *\n     *    @return The shape of the bus interface with direction out.\n     */\n    static QPolygonF getDirectionOutShape();\n\n    /*!\n     *  Get the shape of the bus interface with direction in/out.\n     *\n     *    @return The shape of the bus interface with direction in/out.\n     */\n    static QPolygonF getDirectionInOutShape();\n\n    /*!\n     *  Get the shape of the bus interface with initiative provides.\n     *\n     *    @return The shape of the bus interface with initiative provides.\n     */\n    static QPolygonF getInitiativeProvidesShape();\n\n    /*!\n     *  Get the shape of the bus interface with initiative requires.\n     *\n     *    @return The shape of the bus interface with initiative requires.\n     */\n    static QPolygonF getInitiativeRequiresShape();\n\n    /*!\n     *  Get the shape of the bus interface with initiative requires / provides.\n     *\n     *    @return The shape of the bus interface with initiative requires / provides.\n     */\n    static QPolygonF getInitiativeRequiresProvidesShape();\n\n    /*!\n     *  Get access to the library.\n     *\n     *    @return The library interface.\n     */\n    LibraryInterface* getLibraryAccess() const;\n\n    /*!\n     *  Get isDraft_ parameter.\n     *\n     *    @return Boolean isDraft_ parameter.\n     */\n    bool getIsDraft() const;\n\n    /*!\n     *  Set isDraft_ parameter.\n     * \n     *    @param [in] isDraft   Value to be set to isDraft_.\n     */\n    void setIsDraft(bool isDraft);\n\nprivate:\n\n    /*!\n     *  Get the graphical shape for the interface item.\n     *\n     *    @param [in] direction   Direction of the interface item.\n     *\n     *    @return The new shape for the interface item.\n     */\n    QPolygonF getInterfaceShapeWithDirection(DirectionTypes::Direction direction) const;\n\n    /*!\n     *  Get the graphical shape for the interface item.\n     *\n     *    @param [in] initiative  Initiative of the interface item.\n     *\n     *    @return The new shape for the interface item.\n     */\n    QPolygonF getInterfaceShapeWithInitiative(TransactionalTypes::Initiative initiative) const;\n\n    /*!\n     *  Handle the name change of the bus interface.\n     *\n     *    @param [in] previousName    The previous name.\n     *    @param [in] newName         The new name.\n     */\n    virtual void updateName(QString const& previousName, QString const& newName) = 0;\n\n    /*!\n     *  Create a move command for this end point item.\n     *\n     *    @param [in] diagram     The containing design diagram.\n     *\n     *    @return The created move command.\n     */\n    virtual QSharedPointer<QUndoCommand> createMouseMoveCommand(DesignDiagram* diagram) = 0;\n\n    /*!\n     *  Create move command for an end point that has been moved by the movement of this end point.\n     *\n     *    @param [in] endPoint            The selected end point.\n     *    @param [in] endPointPosition    The new position of the end point.\n     *    @param [in] diagram             Design diagram containing the end point.\n     *    @param [in] parentCommand       Parent command.\n     */\n    virtual void createMoveCommandForClashedItem(ConnectionEndpoint* endPoint, QPointF endPointPosition,\n        DesignDiagram* diagram, QSharedPointer<QUndoCommand> parentCommand) = 0;\n\n    /*!\n     *  Check if a connection can be made to the selected connection end point.\n     *\n     *    @param [in] otherEndPoint   The selected connection end point.\n     *\n     *    @return True, if the connection can be made, false otherwise.\n     */\n    virtual bool canConnectToInterface(ConnectionEndpoint const* otherEndPoint) const = 0;\n\n    /*!\n     *  Update the end point item graphics.\n     */\n    void updateEndPointGraphics() override;\n\n    /*!\n     *  Get the current position of the end point.\n     *\n     *    @return The current position of the end point.\n     */\n    virtual QPointF getCurrentPosition() const = 0;\n\n    //-----------------------------------------------------------------------------\n    // Data.\n    //-----------------------------------------------------------------------------\n\n    //! The bus interface.\n    QSharedPointer<BusInterface> busInterface_ = nullptr;\n\n    //! Old position of the interface item.\n    QPointF oldPos_;\n\n    //! Old positions of the associated end points.\n    QMap<ConnectionEndpoint*, QPointF> oldPortPositions_;\n\n    //! Warning symbol for bus interfaces with no port maps.\n    WarningSymbol* portMapWarning_ = new WarningSymbol(this);\n\n    //! Access to the library.\n    LibraryInterface* library_ = nullptr;\n\n    //! Determines if Bus Interface is draft or not.\n    bool isDraft_ = false;\n};\n\n#endif // BUSINTERFACEENDPOINT_H\n"
  },
  {
    "path": "editors/HWDesign/HWAddCommands.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: HWAddCommands.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Joni-Matti Maatta\r\n// Date: 4.8.2011\r\n//\r\n// Description:\r\n// Undo add commands for the design diagram.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"HWAddCommands.h\"\r\n\r\n#include \"HWConnection.h\"\r\n#include \"HWComponentItem.h\"\r\n\r\n#include <common/GenericEditProvider.h>\r\n#include <common/graphicsItems/GraphicsColumn.h>\r\n#include <common/graphicsItems/GraphicsColumnConstants.h>\r\n\r\n#include <editors/common/DesignDiagram.h>\r\n#include <editors/HWDesign/HierarchicalBusInterfaceItem.h>\r\n#include <editors/HWDesign/ActiveBusInterfaceItem.h>\r\n\r\n#include <IPXACTmodels/Component/BusInterface.h>\r\n#include <IPXACTmodels/Component/PortMap.h>\r\n#include <IPXACTmodels/Design/Design.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PortAddCommand()\r\n//-----------------------------------------------------------------------------\r\nPortAddCommand::PortAddCommand(HWComponentItem* component, QPointF const& pos, DesignDiagram* diagram,\r\n    QUndoCommand* parent):\r\nQUndoCommand(parent),\r\ncomponent_(component),\r\npos_(pos),\r\nport_(0), \r\nscene_(component->scene()),\r\ndel_(false),\r\ndiagram_(diagram)\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ~PortAddCommand()\r\n//-----------------------------------------------------------------------------\r\nPortAddCommand::~PortAddCommand()\r\n{\r\n    if (del_)\r\n    {\r\n        delete port_;\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: undo()\r\n//-----------------------------------------------------------------------------\r\nvoid PortAddCommand::undo()\r\n{\r\n    Q_ASSERT(port_ != 0);\r\n\r\n    // Remove the port from the component and from the scene\r\n    component_->removePort(port_);\r\n    scene_->removeItem(port_);\r\n    del_ = true;\r\n\r\n    // Execute child commands.\r\n    QUndoCommand::undo();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: redo()\r\n//-----------------------------------------------------------------------------\r\nvoid PortAddCommand::redo()\r\n{\r\n    // Add a port to the component.\r\n    if (port_ == 0)\r\n    {\r\n        port_ = component_->addPort(pos_);\r\n    }\r\n    else\r\n    {\r\n        component_->addPort(port_);\r\n    }\r\n\r\n    del_ = false;\r\n\r\n    // Child commands need not be executed because the other ports change their position in a deterministic way.\r\n    if (port_->scenePos().y() + GraphicsColumnConstants::MIN_Y_PLACEMENT > diagram_->sceneRect().height())\r\n    {\r\n        diagram_->resetSceneRectangleForItems();\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ConnectionAddCommand::ConnectionAddCommand()\r\n//-----------------------------------------------------------------------------\r\nConnectionAddCommand::ConnectionAddCommand(QGraphicsScene* scene, HWConnection* connectionItem,\r\n    QSharedPointer<Design> design, QUndoCommand* parent) :\r\nQUndoCommand(parent),\r\n    connection_(connectionItem),\r\n    design_(design),\r\n    scene_(scene),\r\n    del_(false)\r\n{\r\n  \r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ConnectionAddCommand::~ConnectionAddCommand()\r\n//-----------------------------------------------------------------------------\r\nConnectionAddCommand::~ConnectionAddCommand()\r\n{\r\n    if (del_)\r\n    {\r\n        delete connection_;\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ConnectionAddCommand::undo()\r\n//-----------------------------------------------------------------------------\r\nvoid ConnectionAddCommand::undo()\r\n{\r\n    // Remove the interconnection from the scene.\r\n    if (connection_->scene() != 0)\r\n    {\r\n        scene_->removeItem(connection_);\r\n    }\r\n\r\n    // Disconnect the ends.\r\n    connection_->setSelected(false);\r\n    connection_->disconnectEnds();\r\n\r\n    del_ = true;\r\n\r\n    design_->getInterconnections()->removeAll(connection_->getInterconnection());\r\n    design_->removeRoute(connection_->getRouteExtension());\r\n    \r\n    // Execute child commands.\r\n    QUndoCommand::undo();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ConnectionAddCommand::redo()\r\n//-----------------------------------------------------------------------------\r\nvoid ConnectionAddCommand::redo()\r\n{\r\n    // Execute child commands.\r\n    QUndoCommand::redo();\r\n\r\n    // Add the back to the scene.\r\n    if (connection_->scene() != scene_)\r\n    {\r\n        scene_->addItem(connection_);\r\n    }\r\n\r\n    // Connect the ends and set the interface modes and port map for the hierarchical end point.\r\n    if (connection_->connectEnds())\r\n    {\r\n        design_->getInterconnections()->append(connection_->getInterconnection());\r\n        design_->addRoute(connection_->getRouteExtension());\r\n    }\r\n\r\n    del_ = false;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusInterfacePasteCommand()\r\n//-----------------------------------------------------------------------------\r\nBusInterfacePasteCommand::BusInterfacePasteCommand(\r\n    QSharedPointer<Component> destComponent, HierarchicalBusInterfaceItem* interfaceItem, GraphicsColumn* column,\r\n    DesignDiagram* diagram, QUndoCommand* parent) :\r\nQUndoCommand(parent),\r\ndestComponent_(destComponent),\r\nbusInterface_(interfaceItem->getBusInterface()), \r\ninterfaceItem_(interfaceItem),\r\ncolumn_(column),\r\ndiagram_(diagram),\r\ndel_(false)\r\n{\r\n  \r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusInterfacePasteCommand::~BusInterfacePasteCommand()\r\n//-----------------------------------------------------------------------------\r\nBusInterfacePasteCommand::~BusInterfacePasteCommand()\r\n{\r\n    if (del_)\r\n    {\r\n        delete interfaceItem_;\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusInterfacePasteCommand::undo()\r\n//-----------------------------------------------------------------------------\r\nvoid BusInterfacePasteCommand::undo()\r\n{\r\n    // Execute child commands.\r\n    QUndoCommand::undo();\r\n\r\n    Q_ASSERT(interfaceItem_ != 0);\r\n\r\n    // Remove the port from the component and from the scene\r\n    destComponent_->getBusInterfaces()->removeOne(busInterface_);\r\n\r\n    column_->removeItem(interfaceItem_);\r\n    diagram_->removeItem(interfaceItem_);       \r\n    diagram_->getDesign()->getVendorExtensions()->removeOne(interfaceItem_->getDataExtension());\r\n\r\n    del_ = true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusInterfacePasteCommand::redo()\r\n//-----------------------------------------------------------------------------\r\nvoid BusInterfacePasteCommand::redo()\r\n{\r\n    // Execute child commands.\r\n    QUndoCommand::redo();    \r\n\r\n    Q_ASSERT(interfaceItem_ != 0);\r\n\r\n    // Copy a port to the component.\r\n    destComponent_->getBusInterfaces()->append(busInterface_);\r\n    column_->addItem(interfaceItem_);\r\n    diagram_->getDesign()->getVendorExtensions()->append(interfaceItem_->getDataExtension());\r\n\r\n    del_ = false;\r\n\r\n    interfaceItem_->updateInterface();\r\n\r\n    if (interfaceItem_->scenePos().y() + GraphicsColumnConstants::MIN_Y_PLACEMENT > diagram_->sceneRect().height())\r\n    {\r\n        diagram_->resetSceneRectangleForItems();\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddPhysicalPortCommand()\r\n//-----------------------------------------------------------------------------\r\nAddPhysicalPortCommand::AddPhysicalPortCommand(QSharedPointer<Component> component,\r\n                                               QSharedPointer<Port> port,\r\n                                               QUndoCommand* parent)\r\n    : QUndoCommand(parent),\r\n      component_(component),\r\n      port_(port)                                                           \r\n{\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ~AddPhysicalPortCommand()\r\n//-----------------------------------------------------------------------------\r\nAddPhysicalPortCommand::~AddPhysicalPortCommand()\r\n{\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: undo()\r\n//-----------------------------------------------------------------------------\r\nvoid AddPhysicalPortCommand::undo()\r\n{\r\n    Q_ASSERT(component_ != 0 && port_ != 0);\r\n    component_->getPorts()->removeOne(port_);\r\n\t\r\n    // Execute child commands.\r\n    QUndoCommand::undo();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: redo()\r\n//-----------------------------------------------------------------------------\r\nvoid AddPhysicalPortCommand::redo()\r\n{\r\n\tQ_ASSERT(component_ != 0 && port_ != 0);\r\n    \r\n    if (!component_->getPorts()->contains(port_))\r\n    {\r\n        component_->getPorts()->append(port_);\r\n    }\r\n  \r\n\t// Execute child commands.\r\n    QUndoCommand::redo();\r\n}\r\n"
  },
  {
    "path": "editors/HWDesign/HWAddCommands.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: HWAddCommands.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Joni-Matti Maatta\r\n// Date: 3.8.2011\r\n//\r\n// Description:\r\n// Undo add commands for the design diagram.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef HWADDCOMMANDS_H\r\n#define HWADDCOMMANDS_H\r\n\r\n#include <IPXACTmodels/generaldeclarations.h>\r\n\r\n#include <IPXACTmodels/common/DirectionTypes.h>\r\n\r\n#include <IPXACTmodels/Component/PortMap.h>\r\n\r\n#include <QUndoCommand>\r\n#include <QGraphicsItem>\r\n#include <QGraphicsScene>\r\n#include <QString>\r\n#include <QObject>\r\n\r\nclass ActiveBusInterfaceItem;\r\nclass HierarchicalBusInterfaceItem;\r\nclass BusInterface;\r\nclass Component;\r\nclass ComponentItem;\r\nclass Design;\r\nclass DesignDiagram;\r\nclass GraphicsColumn;\r\nclass GraphicsColumnLayout;\r\nclass HWConnection;\r\nclass HWComponentItem;\r\nclass IGraphicsItemStack;\r\nclass Port;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! PortAddCommand class.\r\n//-----------------------------------------------------------------------------\r\nclass PortAddCommand : public QUndoCommand\r\n{\r\npublic:\r\n    /*!\r\n     *  Constructor.\r\n     *\r\n     *    @param [in] component   The component to which to add a port.\r\n     *    @param [in] pos         The position where to add the port.\r\n     *    @param [in] diagram     Diagram containing the scene of the port.\r\n     *    @param [in] parent      The parent command.\r\n     */\r\n    PortAddCommand(HWComponentItem* component, QPointF const& pos, DesignDiagram* diagram,\r\n        QUndoCommand* parent = 0);\r\n\r\n    /*!\r\n     *  Destructor.\r\n     */\r\n    ~PortAddCommand();\r\n\r\n    /*!\r\n     *  Undoes the command.\r\n     */\r\n    virtual void undo();\r\n\r\n    /*!\r\n     *  Redoes the command.\r\n     */\r\n    virtual void redo();\r\n\r\nprivate:\r\n    // Disable copying.\r\n    PortAddCommand(PortAddCommand const& rhs);\r\n    PortAddCommand& operator=(PortAddCommand const& rhs);\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! The item.\r\n    HWComponentItem* component_;\r\n\r\n    //! The port position.\r\n    QPointF pos_;\r\n\r\n    //! The diagram port.\r\n    ActiveBusInterfaceItem* port_;\r\n\r\n    //! The graphics scene.\r\n    QGraphicsScene* scene_;\r\n\r\n    //! Boolean flag for indicating if the port should be deleted in the destructor.\r\n    bool del_;\r\n\r\n    //! Diagram containing the scene of the port.\r\n    DesignDiagram* diagram_;\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n//! ConnectionAddCommand class.\r\n//-----------------------------------------------------------------------------\r\nclass ConnectionAddCommand : public QUndoCommand\r\n{\r\npublic:\r\n    /*!\r\n     *  Constructor.\r\n     *\r\n     *    @param [in] scene           The scene.\r\n     *    @param [in] connectionItem  The interconnection to add.\r\n     *    @param [in] parent          The parent command.\r\n     */\r\n    ConnectionAddCommand(QGraphicsScene* scene, HWConnection* connectionItem, QSharedPointer<Design> design,\r\n                         QUndoCommand* parent = 0);\r\n\r\n    /*!\r\n     *  Destructor.\r\n     */\r\n    ~ConnectionAddCommand();\r\n\r\n    /*!\r\n     *  Undoes the command.\r\n     */\r\n    virtual void undo();\r\n\r\n    /*!\r\n     *  Redoes the command.\r\n     */\r\n    virtual void redo();\r\n\r\nprivate:\r\n    // Disable copying.\r\n    ConnectionAddCommand(ConnectionAddCommand const& rhs);\r\n    ConnectionAddCommand& operator=(ConnectionAddCommand const& rhs);\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! The interconnection.\r\n    HWConnection* connection_;\r\n\r\n    QSharedPointer<Design> design_;\r\n\r\n    //! The graphics scene.\r\n    QGraphicsScene* scene_;\r\n\r\n    //! Boolean flag for indicating if the connection should be deleted in the destructor.\r\n    bool del_;\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n//! BusInterfacePasteCommand class.\r\n//-----------------------------------------------------------------------------\r\nclass BusInterfacePasteCommand : public QUndoCommand\r\n{\r\npublic:\r\n    /*!\r\n     *  Constructor.\r\n     *\r\n\t *      Creates the child commands for adding physical ports to the component model. \r\n\t *\r\n     *    @param [in] destComponent  The component to which to copy an interface.\r\n\t *    @param [in] interface      The interface item to paste.\r\n\t *    @param [in] column         The target column.\r\n     *    @param [in] diagram        The target design diagram.\r\n     *    @param [in] parent         The parent command.\r\n     */\r\n    BusInterfacePasteCommand(QSharedPointer<Component> destComponent, HierarchicalBusInterfaceItem* interfaceItem,\r\n        GraphicsColumn* column, DesignDiagram* diagram, QUndoCommand* parent = 0);\r\n\r\n    /*!\r\n     *  Destructor.\r\n     */\r\n    ~BusInterfacePasteCommand();\r\n\r\n    /*!\r\n     *  Undoes the command.\r\n     */\r\n    virtual void undo();\r\n\r\n    /*!\r\n     *  Redoes the command.\r\n     */\r\n    virtual void redo();\r\n\r\nprivate:\r\n    // Disable copying.\r\n    BusInterfacePasteCommand(BusInterfacePasteCommand const& rhs);\r\n    BusInterfacePasteCommand& operator=(BusInterfacePasteCommand const& rhs);\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! The component to copy to.\r\n    QSharedPointer<Component> destComponent_;\r\n\r\n    //! The bus interface to copy.\r\n    QSharedPointer<BusInterface> busInterface_;\r\n\r\n    //! The interface position.\r\n    QPointF pos_;\r\n\r\n    //! The interface item.\r\n    HierarchicalBusInterfaceItem* interfaceItem_;\r\n\r\n    //! The target column.\r\n    GraphicsColumn* column_;\r\n\r\n    //! The target design diagram.\r\n    DesignDiagram* diagram_;\r\n\r\n    //! If true, the bus interface item is deleted in the destructor.\r\n    bool del_;\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n//! AddPhysicalPortCommand class.\r\n//-----------------------------------------------------------------------------\r\nclass AddPhysicalPortCommand : public QUndoCommand\r\n{\r\npublic:\r\n    /*!\r\n     *  Constructor.\r\n     *\r\n     *    @param [in] component  The component to which to copy a physical port.\r\n\t *    @param [in] port       The port to paste.\r\n     *    @param [in] parent     The parent command.\r\n     */\r\n   AddPhysicalPortCommand(QSharedPointer<Component>, QSharedPointer<Port> port, QUndoCommand* parent = 0);\r\n\r\n    /*!\r\n     *  Destructor.\r\n     */\r\n    ~AddPhysicalPortCommand();\r\n\r\n    // Disable copying.\r\n    AddPhysicalPortCommand(AddPhysicalPortCommand const& rhs) = delete;\r\n    AddPhysicalPortCommand& operator=(AddPhysicalPortCommand const& rhs) = delete;\r\n\r\n    /*!\r\n     *  Undoes the command.\r\n     */\r\n    virtual void undo();\r\n\r\n    /*!\r\n     *  Redoes the command.\r\n     */\r\n    virtual void redo();\r\n\r\nprivate:\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! The target component model.\r\n    QSharedPointer<Component> component_;\r\n\r\n    //! The port to paste.\r\n\tQSharedPointer<Port> port_;\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n\r\n#endif // HWADDCOMMANDS_H\r\n"
  },
  {
    "path": "editors/HWDesign/HWChangeCommands.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: HWChangeCommands.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Joni-Matti Maatta\r\n// Date: 5.8.2011\r\n//\r\n// Description:\r\n// Undo change commands for the block diagram.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"HWChangeCommands.h\"\r\n#include \"HWMoveCommands.h\"\r\n#include \"HWAddCommands.h\"\r\n#include \"HWConnection.h\"\r\n#include \"HWComponentItem.h\"\r\n#include \"columnview/HWColumn.h\"\r\n\r\n#include <common/graphicsItems/ComponentItem.h>\r\n#include <common/graphicsItems/ConnectionUndoCommands.h>\r\n#include <common/graphicsItems/CommonGraphicsUndoCommands.h>\r\n#include <common/graphicsItems/GraphicsColumnLayout.h>\r\n\r\n#include <editors/common/DesignDiagram.h>\r\n#include <editors/common/DesignWidget.h>\r\n#include <editors/common/Association/AssociationChangeEndpointCommand.h>\r\n#include <editors/common/ConfigurationEditor/activeviewmodel.h>\r\n\r\n#include <editors/HWDesign/HierarchicalBusInterfaceItem.h>\r\n#include <editors/HWDesign/ActiveBusInterfaceItem.h>\r\n#include <editors/HWDesign/HierarchicalPortItem.h>\r\n#include <editors/HWDesign/ActivePortItem.h>\r\n#include <editors/HWDesign/AdHocConnectionItem.h>\r\n#include <editors/HWDesign/undoCommands/ConnectionDeleteCommand.h>\r\n#include <editors/HWDesign/undoCommands/ComponentDeleteCommand.h>\r\n\r\n#include <IPXACTmodels/common/ConfigurableVLNVReference.h>\r\n#include <IPXACTmodels/common/ConfigurableElementValue.h>\r\n\r\n#include <IPXACTmodels/Component/BusInterface.h>\r\n#include <IPXACTmodels/Component/Component.h>\r\n\r\n#include <IPXACTmodels/Design/Design.h>\r\n#include <IPXACTmodels/Design/AdHocConnection.h>\r\n#include <IPXACTmodels/Design/PortReference.h>\r\n#include <IPXACTmodels/Design/ComponentInstance.h>\r\n\r\n#include <IPXACTmodels/kactusExtensions/ComInterface.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentChangeNameCommand::ComponentChangeNameCommand()\r\n//-----------------------------------------------------------------------------\r\nComponentChangeNameCommand::ComponentChangeNameCommand(ComponentItem* component, QString const& newName,\r\n    QSharedPointer<Design> design, QUndoCommand* parent):\r\nQUndoCommand(parent),\r\n    component_(component),\r\n    oldName_(component->name()),\r\n    newName_(newName),\r\n    containingDesign_(design)\r\n{\r\n    Q_ASSERT(design);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentChangeNameCommand::~ComponentChangeNameCommand()\r\n//-----------------------------------------------------------------------------\r\nComponentChangeNameCommand::~ComponentChangeNameCommand()\r\n{\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentChangeNameCommand::undo()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentChangeNameCommand::undo()\r\n{\r\n    renameInstanceAndConnections(newName_, oldName_);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentChangeNameCommand::redo()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentChangeNameCommand::redo()\r\n{\r\n    renameInstanceAndConnections(oldName_, newName_);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HWChangeCommands::renameInstanceAndConnections()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentChangeNameCommand::renameInstanceAndConnections(QString const& previousName,\r\n    QString const& newName)\r\n{\r\n    QList<GraphicsConnection*> allConnections;\r\n\r\n    // Update component reference in interconnections and ad-hoc connections.\r\n    for (ConnectionEndpoint* endpoint : component_->getEndpoints())\r\n    {\r\n        allConnections.append(endpoint->getConnections()); \r\n        allConnections.append(endpoint->getOffPageConnector()->getConnections());\r\n    }\r\n\r\n    for (GraphicsConnection* connection : allConnections)\r\n    {\r\n         connection->changeConnectionComponentReference(previousName, newName);\r\n    }\r\n\r\n    // Find all connections, including ad-hoc, that are using the default naming and should be renamed.\r\n    QList<GraphicsConnection*> renamedConnections;\r\n    for (GraphicsConnection* connection : allConnections)\r\n    {\r\n        if (connection->hasDefaultName())\r\n        {\r\n            renamedConnections.append(connection);\r\n        }\r\n    }\r\n\r\n    // Rename component instance.\r\n    component_->setName(newName);\r\n\r\n    // Instance must be renamed before renaming the connections with automatic naming.\r\n    for (GraphicsConnection* connection : renamedConnections)\r\n    {\r\n        connection->setName(connection->createDefaultName());\r\n    }\r\n\r\n    // Rename ad-hoc connections defining tie-offs for the component instance.\r\n    for (auto const& adhocConnection : *containingDesign_->getAdHocConnections())\r\n    {\r\n        if (!adhocConnection->getTiedValue().isEmpty())\r\n        {\r\n            for (auto const& internalReference : *adhocConnection->getInternalPortReferences())\r\n            {\r\n                if (internalReference->getComponentRef().compare(previousName) == 0)\r\n                {\r\n                    internalReference->setComponentRef(newName);\r\n                    changeAdHocConnectionDefaultName(adhocConnection, internalReference->getPortRef(),\r\n                        previousName, newName);\r\n                }\r\n            }           \r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HWChangeCommands::changeAdHocConnectionDefaultName()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentChangeNameCommand::changeAdHocConnectionDefaultName(QSharedPointer<AdHocConnection> connection,\r\n    QString const& portReference, QString const& oldReference, QString const& newReference)\r\n{\r\n    QString defaultName = oldReference + \"_\" + portReference + \"_to_tiedValue\";\r\n    if (connection->name().compare(defaultName) == 0)\r\n    {\r\n        QString newName = newReference + \"_\" + portReference + \"_to_tiedValue\";\r\n        connection->setName(newName);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentChangeDisplayNameCommand::ComponentChangeDisplayNameCommand()\r\n//-----------------------------------------------------------------------------\r\nComponentChangeDisplayNameCommand::ComponentChangeDisplayNameCommand(ComponentItem* component,\r\n    QString const& newDisplayName,\r\n    QUndoCommand* parent):\r\nQUndoCommand(parent),\r\n    component_(component),\r\n    oldDisplayName_(component->displayName()),\r\n    newDisplayName_(newDisplayName)\r\n{\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentChangeDisplayNameCommand::~ComponentChangeDisplayNameCommand()\r\n//-----------------------------------------------------------------------------\r\nComponentChangeDisplayNameCommand::~ComponentChangeDisplayNameCommand()\r\n{\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentChangeDisplayNameCommand::undo()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentChangeDisplayNameCommand::undo()\r\n{\r\n\tcomponent_->setDisplayName(oldDisplayName_);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentChangeDisplayNameCommand::redo()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentChangeDisplayNameCommand::redo()\r\n{\r\n\tcomponent_->setDisplayName(newDisplayName_);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentChangeDescriptionNameCommand::ComponentChangeDescriptionNameCommand()\r\n//-----------------------------------------------------------------------------\r\nComponentChangeDescriptionNameCommand::ComponentChangeDescriptionNameCommand(ComponentItem* component,\r\n    QString const& newDescription, \r\n    QUndoCommand* parent):\r\nQUndoCommand(parent),\r\n    component_(component),\r\n    oldDescription_(component->description()),\r\n    newDescription_(newDescription)\r\n{\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentChangeDescriptionNameCommand::~ComponentChangeDescriptionNameCommand()\r\n//-----------------------------------------------------------------------------\r\nComponentChangeDescriptionNameCommand::~ComponentChangeDescriptionNameCommand()\r\n{\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentChangeDescriptionNameCommand::undo()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentChangeDescriptionNameCommand::undo()\r\n{\r\n\tcomponent_->setDescription(oldDescription_);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentChangeDescriptionNameCommand::redo()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentChangeDescriptionNameCommand::redo()\r\n{\r\n\tcomponent_->setDescription(newDescription_);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentActiveViewChangeCommand::ComponentActiveViewChangeCommand()\r\n//-----------------------------------------------------------------------------\r\nComponentActiveViewChangeCommand::ComponentActiveViewChangeCommand(QString const& instanceName, \r\n    QString const& oldActiveView, QString const& newActiveView, ActiveViewModel* activeViewModel,\r\n    QUndoCommand* parent):\r\nQUndoCommand(parent),\r\ninstanceName_(instanceName),\r\nnewViewName_(newActiveView),\r\noldViewName_(oldActiveView),\r\nactiveViewModel_(activeViewModel)\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentActiveViewChangeCommand::~ComponentActiveViewChangeCommand()\r\n//-----------------------------------------------------------------------------\r\nComponentActiveViewChangeCommand::~ComponentActiveViewChangeCommand()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentActiveViewChangeCommand::undo()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentActiveViewChangeCommand::undo()\r\n{\r\n\tactiveViewModel_->setActiveView(instanceName_, oldViewName_);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentActiveViewChangeCommand::redo()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentActiveViewChangeCommand::redo()\r\n{\r\n\tactiveViewModel_->setActiveView(instanceName_, newViewName_);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentPacketizeCommand::ComponentPacketizeCommand()\r\n//-----------------------------------------------------------------------------\r\nComponentPacketizeCommand::ComponentPacketizeCommand(DesignDiagram* diagram,\r\n    ComponentItem* component,\r\n    VLNV const& vlnv,\r\n    QUndoCommand* parent) : QUndoCommand(parent),\r\n    diagram_(diagram),\r\n    componentItem_(component),\r\n    vlnv_(vlnv)\r\n{\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentPacketizeCommand::~ComponentPacketizeCommand()\r\n//-----------------------------------------------------------------------------\r\nComponentPacketizeCommand::~ComponentPacketizeCommand()\r\n{\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentPacketizeCommand::undo()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentPacketizeCommand::undo()\r\n{\r\n    QUndoCommand::undo();\r\n\r\n    diagram_->getParent()->removeRelatedVLNV(vlnv_);\r\n\r\n    componentItem_->setDraft();\r\n    componentItem_->getComponentInstance()->getComponentRef()->setVLNV(VLNV());\r\n    componentItem_->componentModel()->setVlnv(VLNV());    \r\n\r\n    componentItem_->updateComponent();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentPacketizeCommand::redo()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentPacketizeCommand::redo()\r\n{\r\n    QUndoCommand::redo();\r\n\r\n    componentItem_->componentModel()->setVlnv(vlnv_);\r\n    componentItem_->getComponentInstance()->getComponentRef()->setVLNV(vlnv_);\r\n    componentItem_->setPackaged();\r\n\r\n    diagram_->getParent()->addRelatedVLNV(vlnv_);\r\n\r\n    componentItem_->updateComponent();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: EndpointChangeCommand::EndpointChangeCommand()\r\n//-----------------------------------------------------------------------------\r\nEndpointChangeCommand::EndpointChangeCommand(ConnectionEndpoint* endpoint, \r\n                                             General::InterfaceMode newMode,\r\n\t\t\t\t\t\t\t\t\t\t\t QUndoCommand* parent):\r\nQUndoCommand(parent), \r\nendpoint_(endpoint),\r\noldMode_(endpoint->getBusInterface()->getInterfaceMode()),\r\nnewMode_(newMode)\r\n{\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: EndpointChangeCommand::~EndpointChangeCommand()\r\n//-----------------------------------------------------------------------------\r\nEndpointChangeCommand::~EndpointChangeCommand()\r\n{\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: EndpointChangeCommand::undo()\r\n//-----------------------------------------------------------------------------\r\nvoid EndpointChangeCommand::undo()\r\n{\r\n    QUndoCommand::undo();\r\n\r\n    endpoint_->getBusInterface()->setInterfaceMode(oldMode_);\r\n    endpoint_->revalidateConnections();\r\n    endpoint_->updateInterface();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: EndpointChangeCommand::redo()\r\n//-----------------------------------------------------------------------------\r\nvoid EndpointChangeCommand::redo()\r\n{\r\n    QUndoCommand::redo();\r\n\r\n    endpoint_->getBusInterface()->setInterfaceMode(newMode_);\r\n    endpoint_->revalidateConnections();\r\n    endpoint_->updateInterface();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: EndpointNameChangeCommand::EndpointNameChangeCommand()\r\n//-----------------------------------------------------------------------------\r\nEndpointNameChangeCommand::EndpointNameChangeCommand(ConnectionEndpoint* endpoint, \r\n    QString const& newName,\r\n    QList<QSharedPointer<HierInterface> > activeIntefaces,\r\n    QUndoCommand* parent) :\r\n    QUndoCommand(parent),\r\n    endpoint_(endpoint),\r\n    oldName_(endpoint->name()),\r\n    newName_(newName),\r\n    activeIntefaces_(activeIntefaces)\r\n{\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: EndpointNameChangeCommand::~EndpointNameChangeCommand()\r\n//-----------------------------------------------------------------------------\r\nEndpointNameChangeCommand::~EndpointNameChangeCommand()\r\n{\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: EndpointNameChangeCommand::undo()\r\n//-----------------------------------------------------------------------------\r\nvoid EndpointNameChangeCommand::undo()\r\n{\r\n    QUndoCommand::undo();\r\n\r\n    endpoint_->setName(oldName_);\r\n    for (auto const& interface : activeIntefaces_)\r\n    {\r\n        interface->setBusReference(oldName_);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: EndpointNameChangeCommand::redo()\r\n//-----------------------------------------------------------------------------\r\nvoid EndpointNameChangeCommand::redo()\r\n{\r\n    QUndoCommand::redo();\r\n\r\n    endpoint_->setName(newName_);\r\n    for (auto const& interface : activeIntefaces_)\r\n    {\r\n        interface->setBusReference(newName_);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: EndpointDescChangeCommand::EndpointDescChangeCommand()\r\n//-----------------------------------------------------------------------------\r\nEndpointDescChangeCommand::EndpointDescChangeCommand(ConnectionEndpoint* endpoint, \r\n    QString const& newDescription,\r\n                                                     QUndoCommand* parent)\r\n    : QUndoCommand(parent), \r\n      endpoint_(endpoint),\r\n      oldDescription_(endpoint->description()), \r\n      newDescription_(newDescription)\r\n{\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: EndpointDescChangeCommand::~EndpointDescChangeCommand()\r\n//-----------------------------------------------------------------------------\r\nEndpointDescChangeCommand::~EndpointDescChangeCommand() {\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: EndpointDescChangeCommand::undo()\r\n//-----------------------------------------------------------------------------\r\nvoid EndpointDescChangeCommand::undo()\r\n{\r\n    endpoint_->setDescription(oldDescription_);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: EndpointDescChangeCommand::redo()\r\n//-----------------------------------------------------------------------------\r\nvoid EndpointDescChangeCommand::redo()\r\n{\r\n    endpoint_->setDescription(newDescription_);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: EndpointDependencyDirectionChangeCommand::EndpointDependencyDirectionChangeCommand()\r\n//-----------------------------------------------------------------------------\r\nEndpointDependencyDirectionChangeCommand::EndpointDependencyDirectionChangeCommand(ConnectionEndpoint* endpoint, \r\n                                                                                   DependencyDirection newDir,\r\n                                                                                   QUndoCommand* parent)\r\n    : QUndoCommand(parent), \r\n      endpoint_(endpoint),\r\n      oldDir_(endpoint->getApiInterface()->getDependencyDirection()), \r\n      newDir_(newDir)\r\n{\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: EndpointDependencyDirectionChangeCommand::~EndpointDependencyDirectionChangeCommand()\r\n//-----------------------------------------------------------------------------\r\nEndpointDependencyDirectionChangeCommand::~EndpointDependencyDirectionChangeCommand()\r\n{\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: EndpointDependencyDirectionChangeCommand::undo()\r\n//-----------------------------------------------------------------------------\r\nvoid EndpointDependencyDirectionChangeCommand::undo()\r\n{\r\n    endpoint_->getApiInterface()->setDependencyDirection(oldDir_);\r\n    endpoint_->updateInterface();\r\n    endpoint_->revalidateConnections();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: EndpointDependencyDirectionChangeCommand::redo()\r\n//-----------------------------------------------------------------------------\r\nvoid EndpointDependencyDirectionChangeCommand::redo()\r\n{\r\n    endpoint_->getApiInterface()->setDependencyDirection(newDir_);\r\n    endpoint_->updateInterface();\r\n    endpoint_->revalidateConnections();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: EndpointComDirectionChangeCommand::EndpointComDirectionChangeCommand()\r\n//-----------------------------------------------------------------------------\r\nEndpointComDirectionChangeCommand::EndpointComDirectionChangeCommand(ConnectionEndpoint* endpoint, \r\n                                                                     DirectionTypes::Direction newDir,\r\n                                                                     QUndoCommand* parent)\r\n    : QUndoCommand(parent), \r\n      endpoint_(endpoint),\r\n      oldDir_(endpoint->getComInterface()->getDirection()), \r\n      newDir_(newDir)\r\n{\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: EndpointComDirectionChangeCommand::~EndpointComDirectionChangeCommand()\r\n//-----------------------------------------------------------------------------\r\nEndpointComDirectionChangeCommand::~EndpointComDirectionChangeCommand()\r\n{\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: EndpointComDirectionChangeCommand::undo()\r\n//-----------------------------------------------------------------------------\r\nvoid EndpointComDirectionChangeCommand::undo()\r\n{\r\n    endpoint_->getComInterface()->setDirection(oldDir_);\r\n    endpoint_->updateInterface();\r\n    endpoint_->revalidateConnections();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: EndpointComDirectionChangeCommand::redo()\r\n//-----------------------------------------------------------------------------\r\nvoid EndpointComDirectionChangeCommand::redo()\r\n{\r\n    endpoint_->getComInterface()->setDirection(newDir_);\r\n    endpoint_->updateInterface();\r\n    endpoint_->revalidateConnections();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: EndpointTransferTypeChangeCommand::EndpointTransferTypeChangeCommand()\r\n//-----------------------------------------------------------------------------\r\nEndpointTransferTypeChangeCommand::EndpointTransferTypeChangeCommand(ConnectionEndpoint* endpoint,\r\n    QString const& newTransferType,\r\n    QUndoCommand* parent):\r\nQUndoCommand(parent), \r\n    endpoint_(endpoint),\r\n    oldTransferType_(endpoint->getComInterface()->getTransferType()),\r\n    newTransferType_(newTransferType)\r\n{\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: EndpointTransferTypeChangeCommand::~EndpointTransferTypeChangeCommand()\r\n//-----------------------------------------------------------------------------\r\nEndpointTransferTypeChangeCommand::~EndpointTransferTypeChangeCommand()\r\n{\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: EndpointTransferTypeChangeCommand::undo()\r\n//-----------------------------------------------------------------------------\r\nvoid EndpointTransferTypeChangeCommand::undo()\r\n{\r\n    endpoint_->getComInterface()->setTransferType(oldTransferType_);\r\n    endpoint_->updateInterface();\r\n    endpoint_->revalidateConnections();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: EndpointTransferTypeChangeCommand::redo()\r\n//-----------------------------------------------------------------------------\r\nvoid EndpointTransferTypeChangeCommand::redo()\r\n{\r\n    endpoint_->getComInterface()->setTransferType(newTransferType_);\r\n    endpoint_->updateInterface();\r\n    endpoint_->revalidateConnections();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: EndpointPropertyValuesChangeCommand::EndpointPropertyValuesChangeCommand()\r\n//-----------------------------------------------------------------------------\r\nEndpointPropertyValuesChangeCommand::EndpointPropertyValuesChangeCommand(ConnectionEndpoint* endpoint,\r\n                                                                         QMap<QString, QString> const & newValues,\r\n                                                                         QUndoCommand* parent)\r\n    : QUndoCommand(parent), \r\n      endpoint_(endpoint),\r\n      oldValues_(endpoint->getComInterface()->getPropertyValues()),\r\n      newValues_(newValues)\r\n{\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: EndpointPropertyValuesChangeCommand::~EndpointPropertyValuesChangeCommand()\r\n//-----------------------------------------------------------------------------\r\nEndpointPropertyValuesChangeCommand::~EndpointPropertyValuesChangeCommand()\r\n{\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: EndpointPropertyValuesChangeCommand::undo()\r\n//-----------------------------------------------------------------------------\r\nvoid EndpointPropertyValuesChangeCommand::undo()\r\n{\r\n    endpoint_->getComInterface()->setPropertyValues(oldValues_);\r\n    endpoint_->updateInterface();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: EndpointPropertyValuesChangeCommand::redo()\r\n//-----------------------------------------------------------------------------\r\nvoid EndpointPropertyValuesChangeCommand::redo()\r\n{\r\n    endpoint_->getComInterface()->setPropertyValues(newValues_);\r\n    endpoint_->updateInterface();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: EndPointTypesCommand::EndPointTypesCommand()\r\n//-----------------------------------------------------------------------------\r\nEndPointTypesCommand::EndPointTypesCommand(ConnectionEndpoint* endpoint, VLNV const& busType, VLNV const& absType,\r\n    QString const& activeView, QUndoCommand* parent /* = 0 */):\r\nQUndoCommand(parent),\r\nendpoint_(endpoint),\r\noldBusType_(),\r\noldAbsType_(),\r\nnewBusType_(busType),\r\nnewAbsType_(absType),\r\nactiveView_(activeView)\r\n{\r\n    if (endpoint_->getBusInterface() != 0)\r\n    {\r\n        oldBusType_ = endpoint_->getBusInterface()->getBusType();\r\n\r\n        if (endpoint_->getBusInterface()->getAbstractionTypes())\r\n        {\r\n            QSharedPointer<AbstractionType> abstraction =\r\n                endpoint_->getBusInterface()->getAbstractionContainingView(activeView);\r\n            if (abstraction && abstraction->getAbstractionRef())\r\n            {\r\n                oldAbsType_ = *abstraction->getAbstractionRef().data();\r\n            }\r\n        }\r\n\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: EndPointTypesCommand::~EndPointTypesCommand()\r\n//-----------------------------------------------------------------------------\r\nEndPointTypesCommand::~EndPointTypesCommand()\r\n{\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: EndPointTypesCommand::undo()\r\n//-----------------------------------------------------------------------------\r\nvoid EndPointTypesCommand::undo()\r\n{\r\n    QUndoCommand::undo();\r\n\r\n    setTypes(oldBusType_, oldAbsType_);\r\n\r\n    endpoint_->updateInterface();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: EndPointTypesCommand::redo()\r\n//-----------------------------------------------------------------------------\r\nvoid EndPointTypesCommand::redo()\r\n{\r\n    QUndoCommand::redo();\r\n\r\n    setTypes(newBusType_, newAbsType_);\r\n\r\n    endpoint_->updateInterface();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: EndPointTypesCommand::setTypes()\r\n//-----------------------------------------------------------------------------\r\nvoid EndPointTypesCommand::setTypes(VLNV const& busType, VLNV const& absType)\r\n{\r\n    // Disconnect the connections.\r\n    if (endpoint_->getBusInterface()->getInterfaceMode() != General::INTERFACE_MODE_COUNT)\r\n    {\r\n        for (GraphicsConnection* conn : endpoint_->getConnections())\r\n        {\r\n            if (conn->endpoint1() != endpoint_)\r\n            {\r\n                conn->endpoint1()->onDisconnect();\r\n            }\r\n            else\r\n            {\r\n                conn->endpoint2()->onDisconnect();\r\n            }\r\n        }\r\n    }\r\n\r\n    endpoint_->getBusInterface()->setBusType(busType);\r\n\r\n    if (endpoint_->getBusInterface())\r\n    {\r\n        QSharedPointer<AbstractionType> abstraction =\r\n            endpoint_->getBusInterface()->getAbstractionContainingView(activeView_);\r\n        if (!abstraction)\r\n        {\r\n            QSharedPointer<AbstractionType> newAbstraction(new AbstractionType());\r\n            endpoint_->getBusInterface()->getAbstractionTypes()->append(newAbstraction);\r\n            abstraction = newAbstraction;\r\n        }\r\n\r\n        QSharedPointer<ConfigurableVLNVReference> newVLNVReference;\r\n        if (abstraction && abstraction->getAbstractionRef())\r\n        {\r\n            newVLNVReference = abstraction->getAbstractionRef();\r\n        }\r\n        else\r\n        {\r\n            newVLNVReference = QSharedPointer<ConfigurableVLNVReference>(new ConfigurableVLNVReference());\r\n            abstraction->setAbstractionRef(newVLNVReference);\r\n        }\r\n\r\n        newVLNVReference->setVLNV(absType);\r\n    }\r\n\r\n    endpoint_->setTypeLocked(busType.isValid());\r\n\r\n    // Undefined end points of the connections can now be defined.\r\n    if (busType.isValid())\r\n    {\r\n        for (GraphicsConnection* conn : endpoint_->getConnections())\r\n        {\r\n            if (conn->endpoint1() != endpoint_)\r\n            {\r\n                conn->endpoint1()->onConnect(endpoint_);\r\n                conn->endpoint2()->onConnect(conn->endpoint1());\r\n            }\r\n            else\r\n            {\r\n                conn->endpoint2()->onConnect(endpoint_);\r\n                conn->endpoint1()->onConnect(conn->endpoint2());\r\n            }\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: EndPointPortMapCommand::EndPointPortMapCommand()\r\n//-----------------------------------------------------------------------------\r\nEndPointPortMapCommand::EndPointPortMapCommand(ConnectionEndpoint* endpoint,\r\n    QList< QSharedPointer<PortMap> > newPortMaps, QSharedPointer<Component> component,\r\n    QUndoCommand* parent) :\r\nQUndoCommand(parent),\r\nendpoint_(endpoint),\r\nabstraction_(),\r\noldPortMaps_(),\r\nnewPortMaps_(newPortMaps),\r\ncomponent_(component)\r\n{\r\n    QSharedPointer<BusInterface> endPointBus = endpoint->getBusInterface();\r\n    if (endPointBus && endPointBus->getAbstractionTypes() && endPointBus->getAbstractionTypes()->size() > 0)\r\n    {\r\n        abstraction_ = endPointBus->getAbstractionTypes()->first();\r\n        if (abstraction_->getPortMaps())\r\n        {\r\n            for (auto const& oldMap : *abstraction_->getPortMaps())\r\n            {\r\n                oldPortMaps_.append(oldMap);\r\n            }\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: EndPointPortMapCommand::~EndPointPortMapCommand()\r\n//-----------------------------------------------------------------------------\r\nEndPointPortMapCommand::~EndPointPortMapCommand()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: EndPointPortMapCommand::undo()\r\n//-----------------------------------------------------------------------------\r\nvoid EndPointPortMapCommand::undo()\r\n{\r\n    if (endpoint_->isBus())\r\n    {\r\n        component_->getBusInterfaces()->removeOne(endpoint_->getBusInterface());\r\n        abstraction_->getPortMaps()->clear();\r\n        for (auto const& oldMap : oldPortMaps_)\r\n        {\r\n            abstraction_->getPortMaps()->append(oldMap);\r\n        }\r\n\r\n        endpoint_->updateInterface();\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: EndPointPortMapCommand::redo()\r\n//-----------------------------------------------------------------------------\r\nvoid EndPointPortMapCommand::redo()\r\n{\r\n    if (endpoint_->isBus())\r\n    {\r\n        if (!component_->getBusInterfaces()->contains(endpoint_->getBusInterface()))\r\n        {\r\n            component_->getBusInterfaces()->append(endpoint_->getBusInterface());\r\n        }\r\n\r\n        abstraction_->getPortMaps()->clear();\r\n        for (auto const& newMap : newPortMaps_)\r\n        {\r\n            abstraction_->getPortMaps()->append(newMap);\r\n        }\r\n\r\n        endpoint_->updateInterface();\r\n    }\r\n}\r\n"
  },
  {
    "path": "editors/HWDesign/HWChangeCommands.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: HWChangeCommands.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Joni-Matti Maatta\r\n// Date: 5.8.2011\r\n//\r\n// Description:\r\n// Undo change commands for the block diagram.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef HWCHANGECOMMANDS_H\r\n#define HWCHANGECOMMANDS_H\r\n\r\n#include <IPXACTmodels/generaldeclarations.h>\r\n\r\n#include <IPXACTmodels/common/DirectionTypes.h>\r\n\r\n#include <IPXACTmodels/Component/PortMap.h>\r\n\r\n#include <IPXACTmodels/kactusExtensions/ApiInterface.h>\r\n\r\n#include <QUndoCommand>\r\n#include <QSharedPointer>\r\n#include <QGraphicsItem>\r\n#include <QGraphicsScene>\r\n#include <QString>\r\n#include <QMap>\r\n\r\nclass ActiveViewModel;\r\nclass AdHocEnabled;\r\nclass AdHocConnectionItem;\r\nclass ActivePortItem;\r\nclass HierarchicalBusInterfaceItem;\r\nclass ActiveBusInterfaceItem;\r\nclass ComponentItem;\r\nclass ConfigurableElementValue;\r\nclass ConnectionEndpoint;\r\nclass DesignDiagram;\r\nclass GraphicsColumn;\r\nclass GraphicsColumnLayout;\r\nclass GraphicsConnection;\r\nclass HWComponentItem;\r\nclass HWConnection;\r\nclass HWConnectionEndpoint;\r\nclass Component;\r\n\r\nclass AdHocConnection;\r\nclass ComponentInstance;\r\nclass Design;\r\nclass HierInterface;\r\nclass ViewConfiguration;\r\nclass PortReference;\r\nclass AbstractionType;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! ComponentChangeNameCommand class.\r\n//-----------------------------------------------------------------------------\r\nclass ComponentChangeNameCommand : public QUndoCommand\r\n{\r\npublic:\r\n    /*!\r\n     *  Constructor.\r\n     *\r\n     *    @param [in] component   The component.\r\n     *    @param [in] newName     The component's new name.\r\n     *    @param [in] design      Design containing the component instance.\r\n     *    @param [in] parent      The parent command.\r\n     */\r\n    ComponentChangeNameCommand(ComponentItem* component, QString const& newName, QSharedPointer<Design> design,\r\n        QUndoCommand* parent = 0);\r\n\r\n    /*!\r\n     *  Destructor.\r\n     */\r\n    ~ComponentChangeNameCommand();\r\n\r\n    /*!\r\n     *  Undoes the command.\r\n     */\r\n    virtual void undo();\r\n\r\n    /*!\r\n     *  Redoes the command.\r\n     */\r\n    virtual void redo();\r\n\r\nprivate:\r\n    // Disable copying.\r\n    ComponentChangeNameCommand(ComponentChangeNameCommand const& rhs);\r\n    ComponentChangeNameCommand& operator=(ComponentChangeNameCommand const& rhs);\r\n\r\n    /*!\r\n     *  Renames the component instance and change the component reference in connections.\r\n     *\r\n     *    @param [in] oldReference    The old component reference.\r\n     *    @param [in] newReference    The new component reference.\r\n     */\r\n    void renameInstanceAndConnections(QString const& previousName, QString const& newReference);\r\n\r\n    /*!\r\n     *  Change the default name of an ad hoc connection.\r\n     *\r\n     *    @param [in] connection      The selected ad hoc connection.\r\n     *    @param [in] portReference   The reference port of the containing interface.\r\n     *    @param [in] oldReference    Old component reference.\r\n     *    @param [in] newReference    New component reference.\r\n     */\r\n    void changeAdHocConnectionDefaultName(QSharedPointer<AdHocConnection> connection, QString const& portReference,\r\n        QString const& oldReference, QString const& newReference);\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! The diagram component.\r\n    ComponentItem* component_;\r\n\r\n    //! The component's old name.\r\n    QString oldName_;\r\n\r\n    //! The component's new name.\r\n    QString newName_;\r\n\r\n    //! Design containing the componnet instance.\r\n    QSharedPointer<Design> containingDesign_;\r\n};\r\n\r\nclass ComponentChangeDisplayNameCommand : public QUndoCommand\r\n{\r\npublic:\r\n    /*!\r\n     *  Constructor.\r\n     *\r\n     *    @param [in] component      The component.\r\n     *    @param [in] newDisplayName The component's new display name.\r\n     *    @param [in] parent         The parent command.\r\n     */\r\n    ComponentChangeDisplayNameCommand(ComponentItem* component, QString const& newDisplayName,\r\n\t\tQUndoCommand* parent = 0);\r\n\r\n    /*!\r\n     *  Destructor.\r\n     */\r\n    ~ComponentChangeDisplayNameCommand();\r\n\r\n    /*!\r\n     *  Undoes the command.\r\n     */\r\n    virtual void undo();\r\n\r\n    /*!\r\n     *  Redoes the command.\r\n     */\r\n    virtual void redo();\r\n\r\nprivate:\r\n    // Disable copying.\r\n    ComponentChangeDisplayNameCommand(ComponentChangeDisplayNameCommand const& rhs);\r\n    ComponentChangeDisplayNameCommand& operator=(ComponentChangeDisplayNameCommand const& rhs);\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! The diagram component.\r\n    ComponentItem* component_;\r\n\r\n    //! The component's old display name.\r\n    QString oldDisplayName_;\r\n\r\n    //! The component's new display name.\r\n    QString newDisplayName_;\r\n};\r\n\r\nclass ComponentChangeDescriptionNameCommand : public QUndoCommand\r\n{\r\npublic:\r\n    /*!\r\n     *  Constructor.\r\n     *\r\n     *    @param [in] component      The component.\r\n     *    @param [in] newDescription The component's new description.\r\n     *    @param [in] parent         The parent command.\r\n     */\r\n    ComponentChangeDescriptionNameCommand(ComponentItem* component, QString const& newDescription,\r\n\t\tQUndoCommand* parent = 0);\r\n\r\n    /*!\r\n     *  Destructor.\r\n     */\r\n    ~ComponentChangeDescriptionNameCommand();\r\n\r\n    /*!\r\n     *  Undoes the command.\r\n     */\r\n    virtual void undo();\r\n\r\n    /*!\r\n     *  Redoes the command.\r\n     */\r\n    virtual void redo();\r\n\r\nprivate:\r\n    // Disable copying.\r\n    ComponentChangeDescriptionNameCommand(ComponentChangeDescriptionNameCommand const& rhs);\r\n    ComponentChangeDescriptionNameCommand& operator=(ComponentChangeDescriptionNameCommand const& rhs);\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! The diagram component.\r\n    ComponentItem* component_;\r\n\r\n    //! The component's old display name.\r\n    QString oldDescription_;\r\n\r\n    //! The component's new display name.\r\n    QString newDescription_;\r\n};\r\n\r\nclass ComponentActiveViewChangeCommand : public QUndoCommand\r\n{\r\npublic:\r\n\r\n    /*!\r\n     *  The constructor\r\n     *\r\n     *    @param [in] instanceName        The name of the component instance\r\n     *    @param [in] oldActiveView       The name of the previous active view.\r\n     *    @param [in] newActiveView       The name of the new active view.\r\n     *    @param [in] activeViewModel     Pointer to the model that manages the active views.\r\n     *    @param [in] parent              Pointer to the parent command.\r\n     */\r\n    ComponentActiveViewChangeCommand(const QString& instanceName, QString const& oldActiveView,\r\n        QString const& newActiveView, ActiveViewModel* activeViewModel, QUndoCommand* parent = 0);\r\n\r\n    /*!\r\n     *  Destructor.\r\n     */\r\n    ~ComponentActiveViewChangeCommand();\r\n\r\n    // Disable copying.\r\n    ComponentActiveViewChangeCommand(ComponentChangeNameCommand const& rhs) = delete;\r\n    ComponentActiveViewChangeCommand& operator=(ComponentChangeNameCommand const& rhs) = delete;\r\n\r\n    /*!\r\n     *  Undoes the command.\r\n     */\r\n    virtual void undo();\r\n\r\n    /*!\r\n     *  Redoes the command.\r\n     */\r\n    virtual void redo();\r\n\r\nprivate:\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! The component's old active view.\r\n    QString instanceName_;\r\n\r\n    //! The component's new name.\r\n    QString newViewName_;\r\n\r\n    //! The component's new active view.\r\n    QString oldViewName_;\r\n\r\n\t//! Pointer to the model that manages the active views.\r\n\tActiveViewModel* activeViewModel_;\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n//! ComponentPacketizeCommand class.\r\n//-----------------------------------------------------------------------------\r\nclass ComponentPacketizeCommand : public QObject, public QUndoCommand\r\n{\r\n    Q_OBJECT\r\n\r\npublic:\r\n    /*!\r\n     *  Constructor.\r\n     *\r\n     *    @param [in] diagram     The design diagram containing the packaged component.\r\n     *    @param [in] component   The component to package.\r\n     *    @param [in] vlnv        The VLNV of the packaged component.\r\n     *    @param [in] parent      The parent command.\r\n     */\r\n    ComponentPacketizeCommand(DesignDiagram* diagram, ComponentItem* component, VLNV const& vlnv, \r\n        QUndoCommand* parent = 0);\r\n\r\n    /*!\r\n     *  Destructor.\r\n     */\r\n    ~ComponentPacketizeCommand();\r\n\r\n    /*!\r\n     *  Undoes the command.\r\n     */\r\n    virtual void undo();\r\n\r\n    /*!\r\n     *  Redoes the command.\r\n     */\r\n    virtual void redo();\r\n\r\nsignals:\r\n    void contentChanged();\r\n\r\nprivate:\r\n    // Disable copying.\r\n    ComponentPacketizeCommand(ComponentPacketizeCommand const& rhs);\r\n    ComponentPacketizeCommand& operator=(ComponentPacketizeCommand const& rhs);\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! The containing design diagram.\r\n    DesignDiagram* diagram_;\r\n\r\n    //! The diagram component.\r\n    ComponentItem* componentItem_;\r\n\r\n    //! The component VLNV.\r\n    VLNV vlnv_;\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n//! EndpointChangeCommand class.\r\n//-----------------------------------------------------------------------------\r\nclass EndpointChangeCommand : public QUndoCommand\r\n{\r\npublic:\r\n    /*!\r\n     *  Constructor.\r\n     *\r\n     *    @param [in] endpoint          The diagram connection end point.\r\n     *    @param [in] newInterfaceMode  The end point's new interface mode.\r\n     *    @param [in] parent            The parent command.\r\n     */\r\n\tEndpointChangeCommand(ConnectionEndpoint* endpoint,\r\n\t\tGeneral::InterfaceMode newMode,\r\n\t\tQUndoCommand* parent = 0);\r\n\r\n    /*!\r\n     *  Destructor.\r\n     */\r\n    ~EndpointChangeCommand();\r\n\r\n    /*!\r\n     *  Undoes the command.\r\n     */\r\n    virtual void undo();\r\n\r\n    /*!\r\n     *  Redoes the command.\r\n     */\r\n    virtual void redo();\r\n\r\nprivate:\r\n    // Disable copying.\r\n    EndpointChangeCommand(EndpointChangeCommand const& rhs);\r\n    EndpointChangeCommand& operator=(EndpointChangeCommand const& rhs);\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! The diagram connection end point.\r\n    ConnectionEndpoint* endpoint_;\r\n\r\n    //! The end point's old interface mode.\r\n    General::InterfaceMode oldMode_;\r\n\r\n    //! The end point's new interface mode.\r\n    General::InterfaceMode newMode_;\r\n\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n//! EndpointNameChangeCommand class.\r\n//-----------------------------------------------------------------------------\r\nclass EndpointNameChangeCommand : public QUndoCommand\r\n{\r\npublic:\r\n    /*!\r\n     *  Constructor.\r\n     *\r\n     *    @param [in] endpoint  The connection endpoint.\r\n     *    @param [in] newName   The endpoint's new name.\r\n     *    @param [in] parent    The parent command.\r\n     */\r\n    EndpointNameChangeCommand(ConnectionEndpoint* endpoint, \r\n        QString const& newName,\r\n        QList<QSharedPointer<HierInterface> > activeIntefaces,\r\n        QUndoCommand* parent = 0);\r\n\r\n    /*!\r\n     *  Destructor.\r\n     */\r\n    ~EndpointNameChangeCommand();\r\n\r\n    /*!\r\n     *  Undoes the command.\r\n     */\r\n    virtual void undo();\r\n\r\n    /*!\r\n     *  Redoes the command.\r\n     */\r\n    virtual void redo();\r\n\r\nprivate:\r\n    // Disable copying.\r\n    EndpointNameChangeCommand(EndpointNameChangeCommand const& rhs);\r\n    EndpointNameChangeCommand& operator=(EndpointNameChangeCommand const& rhs);\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! The connection endpoint.\r\n    ConnectionEndpoint* endpoint_;\r\n\r\n    //! The endpoint's old name.\r\n    QString oldName_;\r\n\r\n    //! The endpoint's new name.\r\n    QString newName_;\r\n\r\n    //! The interfaces affected by the name change.\r\n    QList<QSharedPointer<HierInterface> > activeIntefaces_;\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n//! EndpointDescChangeCommand class.\r\n//-----------------------------------------------------------------------------\r\nclass EndpointDescChangeCommand : public QUndoCommand\r\n{\r\npublic:\r\n    /*!\r\n     *  Constructor.\r\n     *\r\n     *    @param [in] endpoint        The connection endpoint.\r\n     *    @param [in] newDescription  The endpoint's new description.\r\n     *    @param [in] parent          The parent command.\r\n     */\r\n\tEndpointDescChangeCommand(ConnectionEndpoint* endpoint, QString const& newDescription,\r\n                              QUndoCommand* parent = 0);\r\n\r\n    /*!\r\n     *  Destructor.\r\n     */\r\n    ~EndpointDescChangeCommand();\r\n\r\n    /*!\r\n     *  Undoes the command.\r\n     */\r\n    virtual void undo();\r\n\r\n    /*!\r\n     *  Redoes the command.\r\n     */\r\n    virtual void redo();\r\n\r\nprivate:\r\n    // Disable copying.\r\n    EndpointDescChangeCommand(EndpointDescChangeCommand const& rhs);\r\n    EndpointDescChangeCommand& operator=(EndpointDescChangeCommand const& rhs);\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! The connection endpoint.\r\n    ConnectionEndpoint* endpoint_;\r\n\r\n    //! The endpoint's old description.\r\n    QString oldDescription_;\r\n\r\n    //! The endpoint's new description.\r\n    QString newDescription_;\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n//! EndpointDependencyDirectionChangeCommand class.\r\n//-----------------------------------------------------------------------------\r\nclass EndpointDependencyDirectionChangeCommand : public QUndoCommand\r\n{\r\npublic:\r\n    /*!\r\n     *  Constructor.\r\n     *\r\n     *    @param [in] endpoint  The connection endpoint.\r\n     *    @param [in] newDir    The endpoint's new dependency direction.\r\n     *    @param [in] parent    The parent command.\r\n     */\r\n\tEndpointDependencyDirectionChangeCommand(ConnectionEndpoint* endpoint, DependencyDirection newDir,\r\n                                             QUndoCommand* parent = 0);\r\n\r\n    /*!\r\n     *  Destructor.\r\n     */\r\n    ~EndpointDependencyDirectionChangeCommand();\r\n\r\n    /*!\r\n     *  Undoes the command.\r\n     */\r\n    virtual void undo();\r\n\r\n    /*!\r\n     *  Redoes the command.\r\n     */\r\n    virtual void redo();\r\n\r\nprivate:\r\n    // Disable copying.\r\n    EndpointDependencyDirectionChangeCommand(EndpointDependencyDirectionChangeCommand const& rhs);\r\n    EndpointDependencyDirectionChangeCommand& operator=(EndpointDependencyDirectionChangeCommand const& rhs);\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! The connection endpoint.\r\n    ConnectionEndpoint* endpoint_;\r\n\r\n    //! The endpoint's old dependency direction.\r\n    DependencyDirection oldDir_;\r\n\r\n    //! The endpoint's new dependency direction.\r\n    DependencyDirection newDir_;\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n//! EndpointComDirectionChangeCommand class.\r\n//-----------------------------------------------------------------------------\r\nclass EndpointComDirectionChangeCommand : public QUndoCommand\r\n{\r\npublic:\r\n    /*!\r\n     *  Constructor.\r\n     *\r\n     *    @param [in] endpoint  The connection endpoint.\r\n     *    @param [in] newDir    The endpoint's new COM direction.\r\n     *    @param [in] parent    The parent command.\r\n     */\r\n    EndpointComDirectionChangeCommand(ConnectionEndpoint* endpoint, DirectionTypes::Direction newDir,\r\n                                      QUndoCommand* parent = 0);\r\n\r\n    /*!\r\n     *  Destructor.\r\n     */\r\n    ~EndpointComDirectionChangeCommand();\r\n\r\n    /*!\r\n     *  Undoes the command.\r\n     */\r\n    virtual void undo();\r\n\r\n    /*!\r\n     *  Redoes the command.\r\n     */\r\n    virtual void redo();\r\n\r\nprivate:\r\n    // Disable copying.\r\n    EndpointComDirectionChangeCommand(EndpointComDirectionChangeCommand const& rhs);\r\n    EndpointComDirectionChangeCommand& operator=(EndpointComDirectionChangeCommand const& rhs);\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! The connection endpoint.\r\n    ConnectionEndpoint* endpoint_;\r\n\r\n    //! The endpoint's old COM direction.\r\n    DirectionTypes::Direction oldDir_;\r\n\r\n    //! The endpoint's new COM direction.\r\n    DirectionTypes::Direction newDir_;\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n//! EndpointTransferTypeChangeCommand class.\r\n//-----------------------------------------------------------------------------\r\nclass EndpointTransferTypeChangeCommand : public QUndoCommand\r\n{\r\npublic:\r\n    /*!\r\n     *  Constructor.\r\n     *\r\n     *    @param [in] endpoint  The connection endpoint.\r\n     *    @param [in] newDir    The endpoint's new COM data type.\r\n     *    @param [in] parent    The parent command.\r\n     */\r\n    EndpointTransferTypeChangeCommand(ConnectionEndpoint* endpoint, QString const& newTransferType,\r\n                                  QUndoCommand* parent = 0);\r\n\r\n    /*!\r\n     *  Destructor.\r\n     */\r\n    ~EndpointTransferTypeChangeCommand();\r\n\r\n    /*!\r\n     *  Undoes the command.\r\n     */\r\n    virtual void undo();\r\n\r\n    /*!\r\n     *  Redoes the command.\r\n     */\r\n    virtual void redo();\r\n\r\nprivate:\r\n    // Disable copying.\r\n    EndpointTransferTypeChangeCommand(EndpointTransferTypeChangeCommand const& rhs);\r\n    EndpointTransferTypeChangeCommand& operator=(EndpointTransferTypeChangeCommand const& rhs);\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! The connection endpoint.\r\n    ConnectionEndpoint* endpoint_;\r\n\r\n    //! The endpoint's old COM data type.\r\n    QString oldTransferType_;\r\n\r\n    //! The endpoint's new COM direction.\r\n    QString newTransferType_;\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n//! EndpointPropertyValuesChangeCommand class.\r\n//-----------------------------------------------------------------------------\r\nclass EndpointPropertyValuesChangeCommand : public QUndoCommand\r\n{\r\npublic:\r\n    /*!\r\n     *  Constructor.\r\n     *\r\n     *    @param [in] endpoint   The connection endpoint.\r\n     *    @param [in] newValues  The endpoint's new property values.\r\n     *    @param [in] parent     The parent command.\r\n     */\r\n    EndpointPropertyValuesChangeCommand(ConnectionEndpoint* endpoint,\r\n                                        QMap<QString, QString> const& newValues,\r\n                                        QUndoCommand* parent = 0);\r\n\r\n    /*!\r\n     *  Destructor.\r\n     */\r\n    ~EndpointPropertyValuesChangeCommand();\r\n\r\n    /*!\r\n     *  Undoes the command.\r\n     */\r\n    virtual void undo();\r\n\r\n    /*!\r\n     *  Redoes the command.\r\n     */\r\n    virtual void redo();\r\n\r\nprivate:\r\n    // Disable copying.\r\n    EndpointPropertyValuesChangeCommand(EndpointPropertyValuesChangeCommand const& rhs);\r\n    EndpointPropertyValuesChangeCommand& operator=(EndpointPropertyValuesChangeCommand const& rhs);\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! The connection endpoint.\r\n    ConnectionEndpoint* endpoint_;\r\n\r\n    //! The endpoint's old property values.\r\n    QMap<QString, QString> oldValues_;\r\n\r\n    //! The endpoint's new property values.\r\n    QMap<QString, QString> newValues_;\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n//! EndPointTypesCommand class.\r\n//-----------------------------------------------------------------------------\r\nclass EndPointTypesCommand : public QUndoCommand\r\n{\r\npublic:\r\n    /*!\r\n     *  Constructor.\r\n     *\r\n     *    @param [in] endpoint    The diagram connection end point.\r\n     *    @param [in] busType     The end point's current bus type.\r\n     *    @param [in] absType     The end point's current abs type.\r\n     *    @param [in] activeView  The active view of the containing item.\r\n     *    @param [in] parent      The parent command.\r\n     */\r\n    EndPointTypesCommand(ConnectionEndpoint* endpoint, VLNV const& busType, VLNV const& absType,\r\n        QString const& activeView, QUndoCommand* parent = 0);\r\n\r\n    /*!\r\n     *  Destructor.\r\n     */\r\n    ~EndPointTypesCommand();\r\n\r\n    /*!\r\n     *  Undoes the command.\r\n     */\r\n    virtual void undo();\r\n\r\n    /*!\r\n     *  Redoes the command.\r\n     */\r\n    virtual void redo();\r\n\r\n\r\n\r\nprivate:\r\n    // Disable copying.\r\n    EndPointTypesCommand(EndPointTypesCommand const& rhs);\r\n    EndPointTypesCommand& operator=(EndPointTypesCommand const& rhs);\r\n\r\n    void setTypes(VLNV const& busType, VLNV const& absType);\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! The diagram connection end point.\r\n    ConnectionEndpoint* endpoint_;\r\n\r\n    //! The end point's old bus type.\r\n    VLNV oldBusType_;\r\n\r\n    //! The end point's old abs type.\r\n    VLNV oldAbsType_;\r\n\r\n    //! The end point's new bus type.\r\n    VLNV newBusType_;\r\n\r\n    //! The end point's new abs type.\r\n    VLNV newAbsType_;\r\n\r\n    //! The active view of the containing item.\r\n    QString activeView_;\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n//! EndPointPortMapCommand class.\r\n//-----------------------------------------------------------------------------\r\nclass EndPointPortMapCommand : public QUndoCommand\r\n{\r\npublic:\r\n    /*!\r\n     *  Constructor.\r\n     *\r\n     *    @param [in] endpoint          The diagram connection end point.\r\n     *    @param [in] newPortMaps       The new port maps for the end point.\r\n     *    @param [in] component         The component whose design is being edited.\r\n     *    @param [in] parent            The parent command.\r\n     */\r\n    EndPointPortMapCommand(ConnectionEndpoint* endpoint,\r\n                           QList< QSharedPointer<PortMap> > newPortMaps,\r\n                           QSharedPointer<Component> component,\r\n                           QUndoCommand* parent = 0);\r\n\r\n    /*!\r\n     *  Destructor.\r\n     */\r\n    ~EndPointPortMapCommand();\r\n\r\n    /*!\r\n     *  Undoes the command.\r\n     */\r\n    virtual void undo();\r\n\r\n    /*!\r\n     *  Redoes the command.\r\n     */\r\n    virtual void redo();\r\n\r\nprivate:\r\n    // Disable copying.\r\n    EndPointPortMapCommand(EndPointPortMapCommand const& rhs);\r\n    EndPointPortMapCommand& operator=(EndPointPortMapCommand const& rhs);\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! The diagram connection end point.\r\n    ConnectionEndpoint* endpoint_;\r\n\r\n    //! The currently active abstraction type.\r\n    QSharedPointer<AbstractionType> abstraction_;\r\n\r\n    //! The end point's old port maps.\r\n    QList< QSharedPointer<PortMap> > oldPortMaps_;\r\n\r\n    //! The end point's new port maps.\r\n    QList< QSharedPointer<PortMap> > newPortMaps_;\r\n\r\n    //! The component whose design is being edited.\r\n    QSharedPointer<Component> component_;\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n\r\n#endif // HWCHANGECOMMANDS_H\r\n"
  },
  {
    "path": "editors/HWDesign/HWComponentItem.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: HWComponentItem.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: \r\n// Date:\r\n//\r\n// Description:\r\n// HWComponentItem represents graphically an IP-XACT component instance.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"HWComponentItem.h\"\r\n#include \"HWMoveCommands.h\"\r\n\r\n#include \"columnview/HWColumn.h\"\r\n\r\n#include <KactusAPI/include/LibraryInterface.h>\r\n\r\n#include <common/IEditProvider.h>\r\n#include <common/KactusColors.h>\r\n\r\n#include <common/graphicsItems/CommonGraphicsUndoCommands.h>\r\n#include <common/graphicsItems/GraphicsConnection.h>\r\n\r\n#include <editors/common/diagramgrid.h>\r\n#include <editors/common/DesignDiagram.h>\r\n#include <editors/HWDesign/AdHocItem.h>\r\n#include <editors/HWDesign/ActiveBusInterfaceItem.h>\r\n#include <editors/HWDesign/ActivePortItem.h>\r\n#include <editors/HWDesign/AdhocEditor/AdHocVisibilityEditor.h>\r\n#include <editors/HWDesign/undoCommands/ComponentItemMoveCommand.h>\r\n\r\n#include <IPXACTmodels/Design/ComponentInstance.h>\r\n\r\n#include <IPXACTmodels/Component/Component.h>\r\n#include <IPXACTmodels/Component/BusInterface.h>\r\n\r\n#include <QGraphicsDropShadowEffect>\r\n#include <QFont>\r\n#include <QTextDocument>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HWComponentItem::HWComponentItem()\r\n//-----------------------------------------------------------------------------\r\nHWComponentItem::HWComponentItem(LibraryInterface* libInterface,\r\nQSharedPointer<ComponentInstance> instance, QSharedPointer<Component> component,\r\nQGraphicsItem* parent) : \r\nComponentItem(QRectF(), libInterface, instance, component, parent)\r\n{\r\n    setFlag(ItemIsMovable);\r\n    setAdHocData(component, instance->getPortAdHocVisibilities());\r\n\r\n    hierIcon_->setToolTip(tr(\"Hierarchical\"));\r\n    hierIcon_->setPos(COMPONENTWIDTH/2 - hierIcon_->pixmap().width() - SPACING, SPACING);\r\n\r\n    static constexpr int portSpacing = 3*GridSize;\r\n    int portCountOnLeft = component->getBusInterfaces()->size() / 2.0 + .5;\r\n    setRect(-COMPONENTWIDTH/ 2, 0, COMPONENTWIDTH, 6 * GridSize + portSpacing * qMax(portCountOnLeft - 1, 0));\r\n\r\n    positionBusInterfaceTerminals();\r\n\r\n    positionAdHocPortTerminals();\r\n\r\n    updateSize();\r\n    HWComponentItem::updateComponent();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HWComponentItem::~HWComponentItem()\r\n//-----------------------------------------------------------------------------\r\nHWComponentItem::~HWComponentItem()\r\n{\r\n    // Remove all interconnections.\r\n    for (QGraphicsItem *item : childItems())\r\n    {\r\n        if (item->type() == ActiveBusInterfaceItem::Type)\r\n        {\r\n            auto diagramPort = qgraphicsitem_cast<ActiveBusInterfaceItem*>(item);\r\n            for (GraphicsConnection* interconnection : diagramPort->getConnections())\r\n            {\r\n                delete interconnection;\r\n            }\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HWComponentItem::updateComponent()\r\n//-----------------------------------------------------------------------------\r\nvoid HWComponentItem::updateComponent()\r\n{\r\n    ComponentItem::updateComponent();\r\n\r\n    // Check whether the component is packaged (valid vlnv) or not.\r\n    if (isDraft())\r\n    {\r\n        setBrush(QBrush(KactusColors::DRAFT_COMPONENT));\r\n    }\r\n    else if (getLibraryInterface()->contains(componentModel()->getVlnv()) == false)\r\n    {\r\n        setBrush(QBrush(KactusColors::MISSING_COMPONENT));\r\n    }\r\n    else if (componentModel()->isBus())\r\n    {\r\n        setBrush(QBrush(KactusColors::HW_BUS_COMPONENT));\r\n    }\r\n    else\r\n    {\r\n        setBrush(QBrush(KactusColors::HW_COMPONENT));\r\n    }\r\n\r\n    // Show a hierarchy icon if the component is a hierarchical one.\r\n    hierIcon_->setVisible(componentModel()->isHierarchical());\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HWComponentItem::setPortAdHocVisible()\r\n//-----------------------------------------------------------------------------\r\nvoid HWComponentItem::onAdHocVisibilityChanged(QString const& portName, bool visible)\r\n{\r\n    ActivePortItem* port = getAdHocPort(portName);\r\n\r\n    // Create/destroy the ad-hoc port graphics item.\r\n    if (visible)\r\n    {\r\n        QSharedPointer<Port> adhocPort = componentModel()->getPort(portName);\r\n        if (!adhocPort)\r\n        {\r\n            adhocPort = QSharedPointer<Port>(new Port(portName));\r\n        }\r\n\r\n        if (!port)\r\n        {\r\n            port = new ActivePortItem(adhocPort, this);\r\n            addPortToSideWithLessPorts(port);\r\n        }\r\n        \r\n        getComponentInstance()->updateAdHocPortPosition(portName, port->pos());\r\n\r\n        // Update the component's size after addition.\r\n        updateSize();\r\n    }\r\n    else\r\n    {\r\n        // Search for the ad-hoc port from both sides.\r\n        Q_ASSERT(port != nullptr);\r\n\r\n        // Remove the port and delete it.\r\n        removePort(port);\r\n        delete port;\r\n        port = nullptr;\r\n\r\n        getComponentInstance()->hideAdHocPort(portName);\r\n    }\r\n\r\n    emit adHocVisibilitiesChanged();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HWComponentItem::attach()\r\n//-----------------------------------------------------------------------------\r\nvoid HWComponentItem::attach(AdHocVisibilityEditor* editor)\r\n{\r\n    connect(this, SIGNAL(adHocVisibilitiesChanged()), editor, SLOT(onContentChanged()), Qt::UniqueConnection);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HWComponentItem::detach()\r\n//-----------------------------------------------------------------------------\r\nvoid HWComponentItem::detach(AdHocVisibilityEditor* editor)\r\n{\r\n    disconnect(editor);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HWComponentItem::adHocIdentifier()\r\n//-----------------------------------------------------------------------------\r\nQString HWComponentItem::adHocIdentifier() const\r\n{\r\n    return name();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HWComponentItem::getDiagramAdHocPort()\r\n//-----------------------------------------------------------------------------\r\nHWConnectionEndpoint* HWComponentItem::getDiagramAdHocPort(QString const& portName)\r\n{\r\n    return getAdHocPort(portName);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HWComponentItem::addPort()\r\n//-----------------------------------------------------------------------------\r\nActiveBusInterfaceItem* HWComponentItem::addPort(QPointF const& pos)\r\n{\r\n    // Determine a unique name for the bus interface.\r\n    QString name = QStringLiteral(\"bus\");\r\n    unsigned int count = 0;\r\n\r\n    QStringList knownNames = componentModel()->getBusInterfaceNames();\r\n\r\n    while (knownNames.contains(name))\r\n    {\r\n        count++;\r\n        name = \"bus_\" + QString::number(count);\r\n    }\r\n\r\n    // Create an empty bus interface and add it to the component model.\r\n    QSharedPointer<BusInterface> busIf(new BusInterface());\r\n    busIf->setName(name);\r\n    busIf->setInterfaceMode(General::INTERFACE_MODE_COUNT);\r\n    componentModel()->getBusInterfaces()->append(busIf);\r\n\r\n    // Create the visualization for the bus interface.\r\n    auto draftPort = new ActiveBusInterfaceItem(busIf, getLibraryInterface(), this);\r\n    draftPort->setTemporary(true);\r\n    draftPort->setPos(mapFromScene(pos));\r\n    \r\n    addPortToSideByPosition(draftPort);\r\n\r\n    onMovePort(draftPort);\r\n\r\n    return draftPort;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HWComponentItem::addPort()\r\n//-----------------------------------------------------------------------------\r\nvoid HWComponentItem::addPort(HWConnectionEndpoint* port)\r\n{\r\n    port->setParentItem(this);\r\n\r\n    if (port->type() == ActiveBusInterfaceItem::Type)\r\n    {\r\n        // Add the bus interface to the component.\r\n        componentModel()->getBusInterfaces()->append(port->getBusInterface());\r\n    }\r\n\r\n    addPortToSideByPosition(port);\r\n\r\n    onMovePort(port);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HWComponentItem::removePort()\r\n//-----------------------------------------------------------------------------\r\nvoid HWComponentItem::removePort(HWConnectionEndpoint* port)\r\n{\r\n    disconnect(port, SIGNAL(moved(ConnectionEndpoint*)), this, SIGNAL(endpointMoved(ConnectionEndpoint*)));\r\n\r\n    leftPorts_.removeAll(port);\r\n    rightPorts_.removeAll(port);\r\n    updateSize();\r\n\r\n    if (port->type() == ActiveBusInterfaceItem::Type)\r\n    {\r\n        componentModel()->getBusInterfaces()->removeOne(port->getBusInterface());\r\n        getComponentInstance()->removeBusInterfacePosition(port->name());\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HWComponentItem::getBusPort()\r\n//-----------------------------------------------------------------------------\r\nActiveBusInterfaceItem* HWComponentItem::getBusPort(QString const& name) const\r\n{\r\n    for (QGraphicsItem* item : QGraphicsRectItem::childItems())\r\n    {\r\n        if (item->type() == ActiveBusInterfaceItem::Type)\r\n        {\r\n            ActiveBusInterfaceItem* busPort = qgraphicsitem_cast<ActiveBusInterfaceItem*>(item);\r\n            if (busPort->name() == name)\r\n            {\r\n                return busPort;\r\n            }\r\n        }\r\n    }\r\n\r\n    return nullptr;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HWComponentItem::getAdHocPort()\r\n//-----------------------------------------------------------------------------\r\nActivePortItem* HWComponentItem::getAdHocPort(QString const& portName) const\r\n{\r\n    auto matchName = [&portName](auto endpoint) {\r\n        return dynamic_cast<ActivePortItem*>(endpoint) != nullptr && endpoint->name() == portName; };\r\n\r\n    if (auto leftPort = std::find_if(leftPorts_.cbegin(), leftPorts_.cend(), matchName);\r\n        leftPort != leftPorts_.cend())\r\n    {\r\n        return static_cast<ActivePortItem*>(*leftPort);\r\n    }\r\n\r\n    if (auto rightPort = std::find_if(rightPorts_.cbegin(), rightPorts_.cend(), matchName); \r\n        rightPort != rightPorts_.cend())\r\n    {\r\n        return static_cast<ActivePortItem*>(*rightPort);\r\n    }\r\n\r\n    return nullptr;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HWComponentItem::onMovePort()\r\n//-----------------------------------------------------------------------------\r\nvoid HWComponentItem::onMovePort(ConnectionEndpoint* port)\r\n{\r\n    // Remove the port from the stacks (this simplifies code).\r\n    leftPorts_.removeAll(port);\r\n    rightPorts_.removeAll(port);\r\n\r\n    // Restrict the position so that the port cannot be placed too high.\r\n    port->setPos(snapPointToGrid(port->x(), qMax(MIN_Y_PLACEMENT - port->boundingRect().top(), port->y())));\r\n\r\n    // Check on which side the port is to determine the stack to which it should be placed.\r\n    if (port->x() < 0)\r\n    {\r\n        portLayout_->updateItemMove(leftPorts_, port, MIN_Y_PLACEMENT);\r\n        checkPortLabelSize(port, rightPorts_);\r\n    }\r\n    else\r\n    {\r\n        portLayout_->updateItemMove(rightPorts_, port, MIN_Y_PLACEMENT);\r\n        checkPortLabelSize(port, leftPorts_);\r\n    }\r\n\r\n    if (port->isBus())\r\n    {\r\n        getComponentInstance()->updateBusInterfacePosition(port->name(), port->pos());\r\n    }\r\n    else\r\n    {\r\n        getComponentInstance()->updateAdHocPortPosition(port->name(), port->pos());\r\n    }\r\n\r\n    updateSize();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HWComponentItem::getBusInterfacePositions()\r\n//-----------------------------------------------------------------------------\r\nQMap<QString, QPointF> HWComponentItem::getBusInterfacePositions() const\r\n{\r\n    return getComponentInstance()->getBusInterfacePositions();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HWComponentItem::getAdHocPortPositions()\r\n//-----------------------------------------------------------------------------\r\nQMap<QString, QPointF> HWComponentItem::getAdHocPortPositions() const\r\n{\r\n    return getComponentInstance()->getAdHocPortPositions();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HWComponentItem::setPackaged()\r\n//-----------------------------------------------------------------------------\r\nvoid HWComponentItem::setPackaged()\r\n{\r\n    getComponentInstance()->setDraft(false);\r\n\r\n    updateComponent();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HWComponentItem::setDraft()\r\n//-----------------------------------------------------------------------------\r\nvoid HWComponentItem::setDraft()\r\n{\r\n    getComponentInstance()->setDraft(true);\r\n\r\n    updateComponent();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HWComponentItem::isDraft()\r\n//-----------------------------------------------------------------------------\r\nbool HWComponentItem::isDraft() const\r\n{\r\n    return getComponentInstance()->isDraft();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: mousePressEvent()\r\n//-----------------------------------------------------------------------------\r\nvoid HWComponentItem::mousePressEvent(QGraphicsSceneMouseEvent *event)\r\n{\r\n    ComponentItem::mousePressEvent(event);\r\n    setZValue(1001.0);\r\n\r\n    oldPos_ = scenePos();\r\n    oldColumn_ = dynamic_cast<HWColumn*>(parentItem());\r\n\r\n    // Begin the position update for all connections.\r\n    for (QGraphicsItem *item : scene()->items())\r\n    {\r\n        auto conn = dynamic_cast<GraphicsConnection*>(item);\r\n\r\n        if (conn != nullptr)\r\n        {\r\n            conn->beginUpdatePosition();\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HWComponentItem::mouseMoveEvent()\r\n//-----------------------------------------------------------------------------\r\nvoid HWComponentItem::mouseMoveEvent(QGraphicsSceneMouseEvent* event)\r\n{\r\n    // Discard movement if the diagram is protected.\r\n    if (auto diagram = dynamic_cast<DesignDiagram*>(scene()); diagram == nullptr || diagram->isProtected())\r\n    {\r\n        return;\r\n    }\r\n    \r\n    ComponentItem::mouseMoveEvent(event);\r\n\r\n    if (oldColumn_ != nullptr)\r\n    {\r\n        setPos(parentItem()->mapFromScene(oldColumn_->mapToScene(pos())));\r\n\r\n        auto column = dynamic_cast<HWColumn*>(parentItem());\r\n        Q_ASSERT(column != nullptr);\r\n        column->onMoveItem(this);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HWComponentItem::mouseReleaseEvent()\r\n//-----------------------------------------------------------------------------\r\nvoid HWComponentItem::mouseReleaseEvent(QGraphicsSceneMouseEvent* event)\r\n{\r\n    ComponentItem::mouseReleaseEvent(event);\r\n    setZValue(0.0);\r\n\r\n    auto diagram = dynamic_cast<DesignDiagram*>(scene());\r\n    if (diagram && oldColumn_ != nullptr && scenePos() != oldPos_)\r\n    {\r\n        auto column = dynamic_cast<HWColumn*>(parentItem());\r\n        Q_ASSERT(column != nullptr);\r\n        column->onReleaseItem(this);\r\n\r\n        QSharedPointer<QUndoCommand> cmd(new ComponentItemMoveCommand(this, oldPos_, oldColumn_, diagram));\r\n\r\n        // End the position update for all connections.\r\n        for (QGraphicsItem *item : scene()->items())\r\n        {\r\n            auto conn = dynamic_cast<GraphicsConnection*>(item);\r\n\r\n            if (conn != nullptr)\r\n            {\r\n                conn->endUpdatePosition(cmd.data());\r\n            }\r\n        }\r\n\r\n        diagram->getEditProvider()->addCommand(cmd);\r\n        cmd->redo();\r\n\r\n        oldColumn_ = nullptr;\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HWComponentItem::positionBusInterfaceTerminals()\r\n//-----------------------------------------------------------------------------\r\nvoid HWComponentItem::positionBusInterfaceTerminals()\r\n{\r\n    QMap<QString, QPointF> instancePositions = getComponentInstance()->getBusInterfacePositions();\r\n\r\n    for (QSharedPointer<BusInterface> busInterface : *componentModel()->getBusInterfaces())\r\n    {\r\n        auto port = new ActiveBusInterfaceItem(busInterface, getLibraryInterface(), this);\r\n\r\n        // Check if instance specific position has been specified.\r\n        if (instancePositions.contains(busInterface->name()))\r\n        {\r\n            port->setPos(instancePositions.value(busInterface->name()));\r\n            addPortToSideByPosition(port);\r\n        }\r\n        // Check if the default position has been specified.\r\n        else if (!busInterface->getDefaultPos().isNull())\r\n        {\r\n            port->setPos(busInterface->getDefaultPos());\r\n            addPortToSideByPosition(port);\r\n        }\r\n        else\r\n        {\r\n            addPortToSideWithLessPorts(port);\r\n        }\r\n    }\r\n\r\n    if (isDraft())\r\n    {\r\n        for (QString const& interfaceName : instancePositions.keys())\r\n        {\r\n            QSharedPointer<BusInterface> busInterface(new BusInterface());\r\n            busInterface->setName(interfaceName);\r\n            componentModel()->getBusInterfaces()->append(busInterface);\r\n\r\n            auto port = new ActiveBusInterfaceItem(busInterface, getLibraryInterface(), this);\r\n\r\n            port->setPos(instancePositions.value(interfaceName));\r\n            port->setTemporary(true);\r\n            addPortToSideByPosition(port);\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HWComponentItem::positionAdHocPortTerminals()\r\n//-----------------------------------------------------------------------------\r\nvoid HWComponentItem::positionAdHocPortTerminals()\r\n{\r\n    QMap<QString, QPointF> instancePositions = getComponentInstance()->getAdHocPortPositions();\r\n\r\n    for(auto it = instancePositions.cbegin(); it != instancePositions.cend(); ++it)\r\n    {\r\n        auto const& portName = it.key();\r\n\r\n        QSharedPointer<Port> adhocPort = componentModel()->getPort(portName);\r\n        if (!adhocPort)\r\n        {\r\n            adhocPort = QSharedPointer<Port>(new Port(portName));\r\n        }\r\n\r\n        auto portItem = new ActivePortItem(adhocPort, this);\r\n        portItem->setPos(it.value());\r\n\r\n        addPortToSideByPosition(portItem);\r\n    }\r\n\r\n    for (QSharedPointer<Port> adhocPort : *componentModel()->getPorts())\r\n    {\r\n        if (adhocPort->isAdHocVisible() && !instancePositions.contains(adhocPort->name()))\r\n        {\r\n            auto adhocItem (new ActivePortItem(adhocPort, this));\r\n\r\n            addPortToSideWithLessPorts(adhocItem);\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HWComponentItem::createAdhocItem()\r\n//-----------------------------------------------------------------------------\r\nAdHocItem* HWComponentItem::createAdhocItem(QString const& portName)\r\n{\r\n    QSharedPointer<Port> adhocPort = componentModel()->getPort(portName);\r\n    if (!adhocPort)\r\n    {\r\n        adhocPort = QSharedPointer<Port>(new Port(portName));\r\n    }\r\n\r\n    ActivePortItem* portItem = getAdHocPort(portName);\r\n    if (!portItem)\r\n    {\r\n        portItem = new ActivePortItem(adhocPort, this);\r\n        addPortToSideWithLessPorts(portItem);\r\n\r\n        updateSize();\r\n    }\r\n\r\n    return portItem;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HWComponentItem::showAdhocPort()\r\n//-----------------------------------------------------------------------------\r\nvoid HWComponentItem::showAdhocPort(AdHocItem* portItem)\r\n{\r\n    auto adhocPortItem = dynamic_cast<ActivePortItem*>(portItem);\r\n    if (adhocPortItem)\r\n    {\r\n        getComponentInstance()->updateAdHocPortPosition(adhocPortItem->name(), adhocPortItem->pos());\r\n\r\n        updateSize();\r\n\r\n        emit adHocVisibilitiesChanged();\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HWComponentItem::hideAdhocPort()\r\n//-----------------------------------------------------------------------------\r\nvoid HWComponentItem::hideAdhocPort(AdHocItem* portItem)\r\n{\r\n    auto adhocPortItem = dynamic_cast<ActivePortItem*>(portItem);\r\n    if (adhocPortItem)\r\n    {\r\n        removePort(adhocPortItem);\r\n\r\n        getComponentInstance()->hideAdHocPort(adhocPortItem->name());\r\n\r\n        emit adHocVisibilitiesChanged();\r\n    }\r\n}\r\n"
  },
  {
    "path": "editors/HWDesign/HWComponentItem.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: HWComponentItem.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: \r\n// Date:\r\n//\r\n// Description:\r\n// HWComponentItem represents graphically an IP-XACT component instance.\r\n//-----------------------------------------------------------------------------\r\n\r\n\r\n#ifndef HWCOMPONENTITEM_H\r\n#define HWCOMPONENTITEM_H\r\n\r\n#include \"AdHocEnabled.h\"\r\n\r\n#include <common/graphicsItems/ComponentItem.h>\r\n#include <common/graphicsItems/GraphicsItemTypes.h>\r\n#include <common/layouts/IVGraphicsLayout.h>\r\n\r\n#include <QSharedPointer>\r\n\r\nclass AdHocVisibilityEditor;\r\nclass ActivePortItem;\r\nclass ActiveBusInterfaceItem;\r\nclass ComponentInstance;\r\nclass HWConnectionEndpoint;\r\nclass HWColumn;\r\nclass LibraryInterface;\r\nclass VendorExtension;\r\nclass AdHocItem;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! HWComponentItem represents graphically an IP-XACT component instance\r\n//-----------------------------------------------------------------------------\r\nclass HWComponentItem : public ComponentItem, public AdHocEnabled\r\n{\r\n    Q_OBJECT\r\n\r\npublic:\r\n    enum { Type = GFX_TYPE_DIAGRAM_COMPONENT };\r\n\r\n    /*!\r\n     *  The constructor.\r\n     *\r\n     *    @param [in] libInterface    The library in use.\r\n     *    @param [in] instance        The component instance represented by the item.\r\n     *    @param [in] component       The component represented by the instance.\r\n     *    @param [in] parent          The parent object.\r\n     */\r\n    HWComponentItem(LibraryInterface* libInterface, QSharedPointer<ComponentInstance> instance,\r\n        QSharedPointer<Component> component, QGraphicsItem* parent = nullptr);\r\n\r\n\t//! The destructor\r\n\t~HWComponentItem() final;\r\n\r\n    int type() const { return Type; }\r\n\r\n    /*!\r\n     *  Updates the diagram component to reflect the current state of the component model.\r\n     */\r\n    virtual void updateComponent();\r\n\r\n    /*!\r\n     *  Called when a port's ad-hoc visibility has been changed.\r\n     *\r\n     *    @param [in] portName  The name of the port.\r\n     *    @param [in] visible   The new ad-hoc visibility.\r\n     */\r\n    virtual void onAdHocVisibilityChanged(QString const& portName, bool visible);\r\n\r\n    /*!\r\n     *  Attaches the data source to an ad-hoc editor.\r\n     */\r\n    virtual void attach(AdHocVisibilityEditor* editor);\r\n\r\n    /*!\r\n     *  Detaches the data source from the ad-hoc editor.\r\n     */\r\n    virtual void detach(AdHocVisibilityEditor* editor);\r\n\r\n    virtual QString adHocIdentifier() const;\r\n\r\n    /*!\r\n     *  Returns the ad-hoc port with the given name or null if not found.\r\n     */\r\n    virtual HWConnectionEndpoint* getDiagramAdHocPort(QString const& portName);\r\n\r\n    /*!\r\n     *  Adds a new, empty bus interface to the component. This function creates automatically an empty\r\n     *  bus interface to the component.\r\n     *\r\n     *    @param [in] pos The position hint for the port.\r\n     *\r\n     *    @return The newly created port.\r\n     */\r\n    ActiveBusInterfaceItem* addPort(QPointF const& pos);\r\n\r\n    /*!\r\n     *  Adds an already created bus interface to the component.\r\n     *\r\n     *    @param [in] port The interface to add. Must not be used in any other component.\r\n     */\r\n    void addPort(HWConnectionEndpoint* port);\r\n\r\n    /*!\r\n     *  Removes the given port from the component.\r\n     *\r\n     *    @param [in] port The port to remove.\r\n     */\r\n    void removePort(HWConnectionEndpoint* port);\r\n\r\n    /*! Get the BusPortItem that corresponds to the given bus interface name\r\n     *\r\n     */\r\n    ActiveBusInterfaceItem* getBusPort(QString const& name) const;\r\n\r\n    /*\r\n     *  Returns the ad-hoc port with the given name, or null if not found.\r\n     */\r\n    ActivePortItem* getAdHocPort(QString const& portName) const;\r\n\r\n\r\n    /*! Called when a port is being moved.\r\n     *\r\n     *    @param [in] port The port that is being moved.\r\n     */\r\n    virtual void onMovePort(ConnectionEndpoint* port);\r\n\r\n    /*!\r\n     *  Returns the bus interface positions.\r\n     */\r\n    QMap<QString, QPointF> getBusInterfacePositions() const;\r\n\r\n    /*!\r\n     *  Returns the ad-hoc port positions.\r\n     */\r\n    QMap<QString, QPointF> getAdHocPortPositions() const;\r\n\r\n    /*!\r\n     *  Marks the component as a packaged component.\r\n     */\r\n    virtual void setPackaged();\r\n\r\n    /*!\r\n     *  Marks the component as a draft component.\r\n     */\r\n    virtual void setDraft();\r\n\r\n    /*!\r\n     *  Checks if the item is a draft component.\r\n     *\r\n     *    @return True, if the component is a draft component, otherwise false.\r\n     */\r\n    bool isDraft() const;\r\n\r\n    /*!\r\n     *  Create an ad hoc port item with the given name.\r\n     *\r\n     *    @param [in] portName    The name of the ad hoc port item.\r\n     *\r\n     *    @return The created ad hoc port item.\r\n     */\r\n    virtual AdHocItem* createAdhocItem(QString const& portName);\r\n\r\nsignals:\r\n    //! Emitted when the ad-hoc visibilities have been changed.\r\n    void adHocVisibilitiesChanged();\r\n\r\n    //! Emitted right before this diagram component is destroyed.\r\n\tvoid destroyed(HWComponentItem* diaComp);\r\n\r\nprotected:\r\n    // Called when the user presses the mouse button.\r\n    void mousePressEvent(QGraphicsSceneMouseEvent *event);\r\n\r\n    //! Called when the user moves the column with the mouse.\r\n    void mouseMoveEvent(QGraphicsSceneMouseEvent* event);\r\n\r\n    //! Called when the user release the mouse.\r\n    void mouseReleaseEvent(QGraphicsSceneMouseEvent* event);\r\n\r\nprivate:\r\n\t\r\n\t//! No copying\r\n\tHWComponentItem(const HWComponentItem& other);    \r\n\r\n    //! No assignment\r\n\tHWComponentItem& operator=(const HWComponentItem& other);\r\n\r\n   \r\n    //! Positions the bus interface items for the component.        \r\n    void positionBusInterfaceTerminals();\r\n\r\n    //! Positions the adhoc port items for the component.\r\n    void positionAdHocPortTerminals();\r\n\r\n    /*!\r\n     *  Show the selected ad hoc port item.\r\n     *\r\n     *    @param [in] portItem    The selected port item.\r\n     */\r\n    virtual void showAdhocPort(AdHocItem* portItem);\r\n\r\n    /*!\r\n     *  Hide the selected ad hoc port item.\r\n     *\r\n     *    @param [in] portItem    The selected port item.\r\n     */\r\n    virtual void hideAdhocPort(AdHocItem* portItem);\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n\t//! Hierarchy icon for the component.\r\n    QGraphicsPixmapItem* hierIcon_ =\r\n        new QGraphicsPixmapItem(QPixmap(QStringLiteral(\":icons/common/graphics/hierarchy.png\")), this);\r\n\r\n    //! The old column from where the mouse drag event began.\r\n    HWColumn* oldColumn_ = nullptr;\r\n\r\n    //! The old position.\r\n    QPointF oldPos_;\r\n};\r\n\r\n#endif // HWCOMPONENTITEM_H\r\n"
  },
  {
    "path": "editors/HWDesign/HWConnection.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: HWConnection.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: \r\n// Date: \r\n//\r\n// Description:\r\n// HWConnection represents graphically an IP-XACT interconnection.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"HWConnection.h\"\r\n#include \"HWComponentItem.h\"\r\n#include \"HWMoveCommands.h\"\r\n#include \"HWDesignDiagram.h\"\r\n#include \"HWDesignWidget.h\"\r\n\r\n#include <editors/common/diagramgrid.h>\r\n#include <editors/common/DiagramUtil.h>\r\n\r\n#include <IPXACTmodels/Design/Interconnection.h>\r\n\r\n#include <IPXACTmodels/Component/BusInterface.h>\r\n#include <IPXACTmodels/Component/PortMap.h>\r\n\r\n#include <IPXACTmodels/generaldeclarations.h>\r\n\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HWConnection::HWConnection()\r\n//-----------------------------------------------------------------------------\r\nHWConnection::HWConnection(ConnectionEndpoint* endpoint1, ConnectionEndpoint* endpoint2, \r\n    QSharedPointer<Interconnection> interconnection, QSharedPointer<ConnectionRoute> route, DesignDiagram* parent):\r\nConnectionItem(endpoint1, endpoint2, interconnection, route, false, parent)\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HWConnection::HWConnection()\r\n//-----------------------------------------------------------------------------\r\nHWConnection::HWConnection(QPointF const& p1, QVector2D const& dir1, QPointF const& p2, QVector2D const& dir2,\r\n    DesignDiagram* parent):\r\n    ConnectionItem(p1, dir1, p2, dir2, parent)\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ConnectionItem::isBus()\r\n//-----------------------------------------------------------------------------\r\nbool HWConnection::isBus() const\r\n{\r\n    return endpoint1()->isBus();\r\n}\r\n\r\n"
  },
  {
    "path": "editors/HWDesign/HWConnection.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: HWConnection.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: \r\n// Date: \r\n//\r\n// Description:\r\n// HWConnection represents graphically an IP-XACT interconnection.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef HWCONNECTION_H\r\n#define HWCONNECTION_H\r\n\r\n#include <QGraphicsPathItem>\r\n#include <QGraphicsTextItem>\r\n#include <QUndoCommand>\r\n\r\n#include <common/graphicsItems/ConnectionItem.h>\r\n#include <common/graphicsItems/GraphicsItemTypes.h>\r\n\r\n#include <IPXACTmodels/Design/Interconnection.h>\r\n\r\nclass ConnectionRoute;\r\nclass ActiveInterface;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! HWConnection represents graphically an IP-XACT interconnection\r\n//-----------------------------------------------------------------------------\r\nclass HWConnection : public ConnectionItem<Interconnection>\r\n{\r\n    Q_OBJECT\r\n\r\npublic:\r\n    enum { Type = GFX_TYPE_DIAGRAM_INTERCONNECTION };\r\n\r\n    /*!\r\n     *  Constructor which creates an open-ended diagram interconnection.\r\n     *\r\n     *    @param [in] p1              The first end point.\r\n     *    @param [in] dir1            Direction of the first end point.\r\n     *    @param [in] p2              The second end point.\r\n     *    @param [in] dir2            Direction of the second end point.\r\n     *    @param [in] parent          Owner of the connection item.\r\n     */\r\n    HWConnection(QPointF const& p1, QVector2D const& dir1, QPointF const& p2, QVector2D const& dir2,\r\n         DesignDiagram* parent);\r\n\r\n    /*!\r\n     *  Constructor.\r\n     *\r\n     *    @param [in] endpoint1           The first end point.\r\n     *    @param [in] endpoint2           The second end point.\r\n     *    @param [in] interconnection     The contained interconnection.\r\n     *    @param [in] route               Route for the connection item.\r\n     *    @param [in] parent              Owner of the connection item.\r\n     */\r\n    HWConnection(ConnectionEndpoint* endpoint1, ConnectionEndpoint* endpoint2,\r\n        QSharedPointer<Interconnection> interconnection, QSharedPointer<ConnectionRoute> route,\r\n        DesignDiagram* parent);\r\n\r\n    /*!\r\n     *  The destructor.\r\n     */\r\n    virtual ~HWConnection() = default;\r\n\r\n    /*!\r\n     *  Get the type of this connection.\r\n     *\r\n     *    @return HW connection.\r\n     */\r\n    int type() const final { return Type; }\r\n\r\n    /*!\r\n     *  Returns true if the connection is a bus connection. Returns false if it isn't (i.e. it is an ad-hoc\r\n     *  connection).\r\n     */\r\n    bool isBus() const;\r\n\r\n};\r\n\r\n#endif // HWCONNECTION_H\r\n"
  },
  {
    "path": "editors/HWDesign/HWConnectionEndPoint.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: HWConnectionEndpoint.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Joni-Matti Maatta\r\n// Date: 18.3.2011\r\n//\r\n// Description:\r\n// Interface class for the diagram connection end points.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"HWConnectionEndpoint.h\"\r\n\r\n#include <editors/common/diagramgrid.h>\r\n#include <editors/common/DesignDiagram.h>\r\n\r\n#include <editors/HWDesign/HWComponentItem.h>\r\n#include <editors/HWDesign/OffPageConnectorItem.h>\r\n\r\n#include <common/KactusColors.h>\r\n\r\n#include <IPXACTmodels/generaldeclarations.h>\r\n\r\n#include <QPen>\r\n#include <QFont>\r\n#include <QGraphicsDropShadowEffect>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HWConnectionEndpont::HWConnectionEndpoint()\r\n//-----------------------------------------------------------------------------\r\nHWConnectionEndpoint::HWConnectionEndpoint(QString const& name, QSharedPointer<Component> containingComponent,\r\n    QGraphicsItem* parent, QVector2D const& dir) :\r\n    ConnectionEndpoint(parent),\r\n    containingComponent_(containingComponent)\r\n{\r\n    setDirection(dir);\r\n\r\n    QFont font = nameLabel_->font();\r\n    font.setPointSize(8);\r\n    nameLabel_->setFont(font);\r\n    nameLabel_->setFlag(ItemStacksBehindParent);\r\n    nameLabel_->setText(name);\r\n\r\n    setFlag(ItemIsMovable);\r\n    setFlag(ItemIsSelectable);\r\n    setFlag(ItemSendsGeometryChanges);\r\n    setFlag(ItemSendsScenePositionChanges);\r\n\r\n    offPageConnector_ = new OffPageConnectorItem(this);\r\n    offPageConnector_->setPos(0.0, -GridSize * 3);\r\n    offPageConnector_->setFlag(ItemStacksBehindParent);\r\n    offPageConnector_->setVisible(false);\r\n\r\n    if (parent)\r\n    {\r\n        auto parentHW = dynamic_cast<HWComponentItem*>(parent);\r\n        if (parentHW)\r\n        {\r\n            parentComponentItem_ = parentHW;\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HWConnectionEndpoint::updateInterface()\r\n//-----------------------------------------------------------------------------\r\nvoid HWConnectionEndpoint::updateInterface()\r\n{\r\n    ConnectionEndpoint::updateInterface();\r\n\r\n    General::InterfaceMode mode = getInterfaceMode();\r\n\r\n    static const QMap<General::InterfaceMode, QColor> interfaceColors({\r\n        {General::MASTER, KactusColors::MASTER_INTERFACE},\r\n        {General::INITIATOR, KactusColors::MASTER_INTERFACE},\r\n        {General::SLAVE, KactusColors::SLAVE_INTERFACE},\r\n        {General::TARGET, KactusColors::SLAVE_INTERFACE},\r\n        {General::MIRRORED_MASTER, KactusColors::MIRROREDMASTER_INTERFACE},\r\n        {General::MIRRORED_INITIATOR, KactusColors::MIRROREDMASTER_INTERFACE},\r\n        {General::MIRRORED_SLAVE, KactusColors::MIRROREDSLAVE_INTERFACE},\r\n        {General::MIRRORED_TARGET, KactusColors::MIRROREDSLAVE_INTERFACE},\r\n        {General::SYSTEM, KactusColors::SYSTEM_INTERFACE},\r\n        {General::MIRRORED_SYSTEM, KactusColors::MIRROREDSYSTEM_INTERFACE},\r\n        {General::MONITOR, KactusColors::MONITOR_INTERFACE}\r\n    });\r\n\r\n    auto const brushColor = interfaceColors.value(mode, KactusColors::INVALID_INTERFACE);\r\n    setBrush(QBrush(brushColor));\r\n\r\n    updateEndPointGraphics();\r\n\r\n    nameLabel_->updateLabelGeometry();\r\n\r\n    setLabelPosition();\r\n\r\n    offPageConnector_->updateInterface();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HWConnectionEndPoint::getOwnerComponent()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<Component> HWConnectionEndpoint::getOwnerComponent() const\r\n{\r\n    return containingComponent_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HWConnectionEndPoint::setName()\r\n//-----------------------------------------------------------------------------\r\nvoid HWConnectionEndpoint::setName(QString const& name)\r\n{\r\n    nameLabel_->setText(name);\r\n    updateInterface();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HWConnectionEndpont::getNameLength()\r\n//-----------------------------------------------------------------------------\r\nqreal HWConnectionEndpoint::getNameLength()\r\n{\r\n\treturn name().length();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HWConnectionEndPoint::getNameLabel()\r\n//-----------------------------------------------------------------------------\r\nGraphicsItemLabel* HWConnectionEndpoint::getNameLabel() const\r\n{\r\n    return nameLabel_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HWConnectionEndPoint::getOffPageConnector()\r\n//-----------------------------------------------------------------------------\r\nConnectionEndpoint* HWConnectionEndpoint::getOffPageConnector() const\r\n{\r\n    return offPageConnector_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HWConnectionEndPoint::HWConnectionEndpoint()\r\n//-----------------------------------------------------------------------------\r\nComponentItem* HWConnectionEndpoint::encompassingComp() const\r\n{\r\n    return parentComponentItem_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HWConnectionEndPoint::sceneIsLocked()\r\n//-----------------------------------------------------------------------------\r\nbool HWConnectionEndpoint::sceneIsLocked() const\r\n{\r\n    auto diagram = dynamic_cast<DesignDiagram*>(scene());\r\n    return diagram != nullptr && diagram->isProtected();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HWConnectionEndPoint::mouseMoveEvent()\r\n//-----------------------------------------------------------------------------\r\nvoid HWConnectionEndpoint::mouseMoveEvent(QGraphicsSceneMouseEvent *event)\r\n{\r\n    if (!sceneIsLocked())\r\n    {\r\n        ConnectionEndpoint::mouseMoveEvent(event);\r\n\r\n        moveItemByMouse();\r\n    }\r\n}\r\n"
  },
  {
    "path": "editors/HWDesign/HWConnectionEndpoint.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: HWConnectionEndpoint.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Joni-Matti Maatta\r\n// Date: 18.3.2011\r\n//\r\n// Description:\r\n// Interface class for the diagram connection end points.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef HWCONNECTIONENDPOINT_H\r\n#define HWCONNECTIONENDPOINT_H\r\n\r\n#include <IPXACTmodels/common/DirectionTypes.h>\r\n#include <IPXACTmodels/common/TransactionalTypes.h>\r\n#include <IPXACTmodels/Component/Component.h>\r\n\r\n#include <common/graphicsItems/ConnectionEndpoint.h>\r\n\r\n#include <editors/common/GraphicsItemLabel.h>\r\n\r\n#include <QList>\r\n#include <QPointF>\r\n#include <QVector2D>\r\n#include <QSharedPointer>\r\n#include <QGraphicsPolygonItem>\r\n\r\nclass HWConnection;\r\nclass ComponentItem;\r\nclass BusInterface;\r\nclass VLNV;\r\nclass OffPageConnectorItem;\r\nclass HWComponentItem;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! HWConnectionEndpoint interface.\r\n//-----------------------------------------------------------------------------\r\nclass HWConnectionEndpoint : public ConnectionEndpoint\r\n{\r\n    Q_OBJECT\r\n\r\npublic:\r\n    /*!\r\n     *  Constructor.\r\n     *\r\n     *    @param [in] name                    Name of the end point.\r\n     *    @param [in] containingComponent     Component containing the end point item.\r\n     *    @param [in] parent                  The parent graphics item.\r\n     *    @param [in] dir                     The initial direction for the endpoint.\r\n     */\r\n    HWConnectionEndpoint(QString const& name, QSharedPointer<Component> containingComponent,\r\n        QGraphicsItem* parent = nullptr, QVector2D const& dir = QVector2D(0.0f, -1.0f));\r\n\r\n    /*!\r\n     *  Destructor.\r\n     */\r\n    ~HWConnectionEndpoint() override = default;\r\n\r\n    // Disable copying.\r\n    HWConnectionEndpoint(HWConnectionEndpoint const& rhs) = delete;\r\n    HWConnectionEndpoint& operator=(HWConnectionEndpoint const& rhs) = delete;\r\n\r\n    void updateInterface() override;\r\n\r\n\t/*!\r\n\t *  Gives the length of the text in the name label.\r\n\t */\r\n\tvirtual qreal getNameLength();\r\n\r\n    /*!\r\n     *  Get the component containing this end point item.\r\n     *\r\n     *    @return The component containing this end point item.\r\n     */\r\n    virtual QSharedPointer<Component> getOwnerComponent() const;\r\n\r\n    /*!\r\n     *  Set the position for the bus interface name label.\r\n     */\r\n    virtual void setLabelPosition() = 0;\r\n\r\n    /*!\r\n     *  Set a new name for the connection end point.\r\n     *\r\n     *    @param [in] name    The selected name.\r\n     */\r\n    void setName(QString const& name) override;\r\n\r\n    /*!\r\n     *  Get the off page connector item.\r\n     *\r\n     *    @return the off page connector item.\r\n     */\r\n    virtual ConnectionEndpoint* getOffPageConnector() const;\r\n\r\n    /*!\r\n     *  Check if the scene is locked.\r\n     *\r\n     *    @return True, if the scene is locked, false otherwise.\r\n     */\r\n    bool sceneIsLocked() const;\r\n\r\n    /*!\r\n     *  Get the component item containing this end point item.\r\n     *\r\n     *    @return The component item containing this end point item.\r\n     */\r\n    ComponentItem* encompassingComp() const override;\r\n\r\nprotected:\r\n\r\n    /*!\r\n     *  Get the label containing the name of this end point.\r\n     *\r\n     *    @return The name label.\r\n     */\r\n    GraphicsItemLabel* getNameLabel() const;\r\n\r\n    /*!\r\n     *  Handles the mouse move events.\r\n     *\r\n     *    @param [in] event   The mouse move event.\r\n     */\r\n    void mouseMoveEvent(QGraphicsSceneMouseEvent *event) override;\r\n\r\n\r\nprivate:\r\n\r\n    /*!\r\n     *  Update the graphics of the end point item.\r\n     */\r\n    virtual void updateEndPointGraphics() = 0;\r\n\r\n    /*!\r\n     *  Move the item by dragging with the mouse.\r\n     */\r\n    virtual void moveItemByMouse() = 0;\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! Component containing this end point.\r\n    QSharedPointer<Component> containingComponent_ = nullptr;\r\n\r\n    //! Component item containing this end point item.\r\n    HWComponentItem* parentComponentItem_ = nullptr;\r\n\r\n    //! The name label.\r\n    GraphicsItemLabel* nameLabel_ = new GraphicsItemLabel(QString(), this);\r\n\r\n    //! The off page connector item.\r\n    OffPageConnectorItem* offPageConnector_ = nullptr;\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n\r\n#endif // HWCONNECTIONENDPOINT_H\r\n"
  },
  {
    "path": "editors/HWDesign/HWDesignDiagram.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: HWDesignDiagram.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: \r\n// Date: \r\n//\r\n// Description:\r\n// HWDesignDiagram is a graphical view to a design.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"HWDesignDiagram.h\"\r\n\r\n#include \"BusInterfaceDialog.h\"\r\n#include \"HWComponentItem.h\"\r\n#include \"HWConnection.h\"\r\n#include \"AdHocConnectionItem.h\"\r\n#include \"HWDesignWidget.h\"\r\n#include \"HWAddCommands.h\"\r\n#include \"HWMoveCommands.h\"\r\n#include \"HWChangeCommands.h\"\r\n#include \"OffPageConnectorItem.h\"\r\n#include \"SelectItemTypeDialog.h\"\r\n\r\n#include \"PortmapDialog.h\"\r\n\r\n#include \"columnview/HWColumn.h\"\r\n#include \"columnview/ColumnEditDialog.h\"\r\n\r\n#include <common/GenericEditProvider.h>\r\n#include <common/graphicsItems/GraphicsColumnUndoCommands.h>\r\n#include <common/graphicsItems/GraphicsColumnLayout.h>\r\n#include <common/graphicsItems/CommonGraphicsUndoCommands.h>\r\n#include <common/graphicsItems/ConnectionUndoCommands.h>\r\n#include <common/graphicsItems/GraphicsColumnConstants.h>\r\n\r\n#include <common/dialogs/newObjectDialog/newobjectdialog.h>\r\n\r\n#include <KactusAPI/include/ComponentParameterFinder.h>\r\n#include <KactusAPI/include/MultipleParameterFinder.h>\r\n\r\n#include <editors/common/DiagramUtil.h>\r\n#include <editors/common/diagramgrid.h>\r\n#include <editors/common/DesignDiagramResolver.h>\r\n#include <editors/common/StickyNote/StickyNote.h>\r\n#include <editors/common/Association/Association.h>\r\n#include <editors/common/ComponentItemAutoConnector/ComponentItemAutoConnector.h>\r\n#include <editors/common/ComponentItemAutoConnector/AutoConnectorItem.h>\r\n#include <editors/common/ComponentItemAutoConnector/HierarchicalPortItemMatcher.h>\r\n#include <editors/common/ComponentItemAutoConnector/PortItemMatcher.h>\r\n#include <editors/common/ComponentItemAutoConnector/HierarchicalPortTableAutoConnector.h>\r\n#include <editors/common/ComponentItemAutoConnector/PortTableAutoConnector.h>\r\n#include <editors/common/ComponentItemAutoConnector/HierarchicalBusInterfaceItemMatcher.h>\r\n#include <editors/common/ComponentItemAutoConnector/BusInterfaceItemMatcher.h>\r\n#include <editors/common/ComponentItemAutoConnector/HierarchicalBusInterfaceTableAutoConnector.h>\r\n#include <editors/common/ComponentItemAutoConnector/BusInterfaceTableAutoConnector.h>\r\n#include <editors/common/ComponentItemAutoConnector/BusInterfaceListFiller.h>\r\n#include <editors/common/ComponentItemAutoConnector/PortListFiller.h>\r\n\r\n#include <editors/HWDesign/HierarchicalBusInterfaceItem.h>\r\n#include <editors/HWDesign/ActiveBusInterfaceItem.h>\r\n#include <editors/HWDesign/HierarchicalPortItem.h>\r\n#include <editors/HWDesign/ActivePortItem.h>\r\n#include <editors/HWDesign/AdHocItem.h>\r\n#include <editors/HWDesign/undoCommands/AdHocConnectionAddCommand.h>\r\n#include <editors/HWDesign/undoCommands/ComponentDeleteCommand.h>\r\n#include <editors/HWDesign/undoCommands/ComponentInstancePasteCommand.h>\r\n#include <editors/HWDesign/undoCommands/PortPasteCommand.h>\r\n#include <editors/HWDesign/undoCommands/ReplaceComponentCommand.h>\r\n#include <editors/HWDesign/undoCommands/HWComponentAddCommand.h>\r\n#include <editors/HWDesign/undoCommands/HWColumnAddCommand.h>\r\n#include <editors/HWDesign/undoCommands/AdHocVisibilityChangeCommand.h>\r\n#include <editors/HWDesign/undoCommands/TopAdHocVisibilityChangeCommand.h>\r\n\r\n#include <KactusAPI/include/LibraryHandler.h>\r\n\r\n#include <IPXACTmodels/common/DirectionTypes.h>\r\n#include <IPXACTmodels/common/PartSelect.h>\r\n\r\n#include <IPXACTmodels/AbstractionDefinition/AbstractionDefinition.h>\r\n#include <IPXACTmodels/AbstractionDefinition/PortAbstraction.h>\r\n\r\n#include <IPXACTmodels/BusDefinition/BusDefinition.h>\r\n\r\n#include <IPXACTmodels/Component/BusInterface.h>\r\n#include <IPXACTmodels/Component/Component.h>\r\n#include <IPXACTmodels/Component/Model.h>\r\n\r\n#include <IPXACTmodels/Design/Design.h>\r\n#include <IPXACTmodels/Design/ActiveInterface.h>\r\n#include <IPXACTmodels/Design/Interconnection.h>\r\n#include <IPXACTmodels/Design/PortReference.h>\r\n\r\n#include <IPXACTmodels/DesignConfiguration/DesignConfiguration.h>\r\n\r\n#include <IPXACTmodels/kactusExtensions/ConnectionRoute.h>\r\n#include <IPXACTmodels/kactusExtensions/Kactus2Placeholder.h>\r\n#include <IPXACTmodels/kactusExtensions/InterfaceGraphicsData.h>\r\n\r\n#include <QPair>\r\n#include <QGraphicsSceneMouseEvent>\r\n#include <QMimeData>\r\n#include <QString>\r\n#include <QMessageBox>\r\n#include <QCoreApplication>\r\n#include <QListIterator>\r\n#include <QApplication>\r\n#include <QMenu>\r\n#include <QClipboard>\r\n\r\nQ_DECLARE_METATYPE(HWDesignDiagram::BusInterfaceCollectionCopyData)\r\nQ_DECLARE_METATYPE(HWDesignDiagram::ComponentCollectionCopyData)\r\nQ_DECLARE_METATYPE(HWDesignDiagram::ColumnCollectionCopyData)\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HWDesignDiagram::HWDesignDiagram()\r\n//-----------------------------------------------------------------------------\r\nHWDesignDiagram::HWDesignDiagram(LibraryInterface *lh, QSharedPointer<IEditProvider> editProvider,\r\n    QSharedPointer<MultipleParameterFinder> designandInstancesParameterFinder,\r\n    QSharedPointer<ListParameterFinder> designParameterFinder, DesignWidget* parent):\r\nComponentDesignDiagram(lh, editProvider, parent),\r\ndiagramResolver_(new DesignDiagramResolver(designParameterFinder)),\r\ndesignAndInstancesParameterFinder_(designandInstancesParameterFinder)\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HWDesignDiagram::loadDesign()\r\n//-----------------------------------------------------------------------------\r\nvoid HWDesignDiagram::loadDesign(QSharedPointer<Design> design)\r\n{\r\n    \r\n    if (QList<QSharedPointer<ColumnDesc> > designColumns = design->getColumns(); \r\n        designColumns.isEmpty())\r\n    {\r\n        loadColumn(QSharedPointer<ColumnDesc>(new ColumnDesc(\r\n            \"IO\", ColumnTypes::IO, 0, GraphicsColumnConstants::IO_COLUMN_WIDTH)));\r\n        loadColumn(QSharedPointer<ColumnDesc>(new ColumnDesc(\r\n            \"Buses\", ColumnTypes::BUSES, 0, GraphicsColumnConstants::COMPONENT_COLUMN_WIDTH)));\r\n        loadColumn(QSharedPointer<ColumnDesc>(new ColumnDesc(\r\n            \"Components\", ColumnTypes::COMPONENTS, 0, GraphicsColumnConstants::COMPONENT_COLUMN_WIDTH)));\r\n        loadColumn(QSharedPointer<ColumnDesc>(new ColumnDesc(\r\n            \"IO\", ColumnTypes::IO, 0, GraphicsColumnConstants::IO_COLUMN_WIDTH)));\r\n    }\r\n    else\r\n    {\r\n        QMultiMap<unsigned int, QSharedPointer<ColumnDesc> > orderedColumns;\r\n        for (QSharedPointer<ColumnDesc> desc : designColumns)\r\n        {\r\n            orderedColumns.insert(desc->getPosition(), desc);\r\n        }\r\n\r\n        for (QSharedPointer<ColumnDesc> desc : orderedColumns)\r\n        {\r\n            loadColumn(desc);\r\n        }\r\n    }\r\n\r\n    // Clear undo/redo stack to prevent undoing the column adds.\r\n    getEditProvider()->clear();\r\n\r\n    // Create diagram interfaces for the top-level bus interfaces.\r\n    for (QSharedPointer<BusInterface> busIf : *getEditedComponent()->getBusInterfaces())\r\n    {\r\n        QSharedPointer<InterfaceGraphicsData> dataGroup =\r\n            findOrCreateInterfaceExtensionGroup(design, busIf->name());\r\n\r\n        // If the mode of the bus interface is not set, then it is considered as draft port (e.g. warning sign is not displayed)\r\n        auto topInterface =\r\n            new HierarchicalBusInterfaceItem(getEditedComponent(), busIf, dataGroup, getLibraryInterface(),0, \r\n                busIf->getInterfaceMode() == General::InterfaceMode::INTERFACE_MODE_COUNT);\r\n        GraphicsColumn* targetColumn = getLayout()->findColumnAt(topInterface->scenePos());\r\n        if (targetColumn && targetColumn->isItemAllowed(topInterface))\r\n        {\r\n            targetColumn->addItem(topInterface);\r\n        }\r\n        else\r\n        {\r\n            getLayout()->addItem(topInterface);\r\n        }        \r\n    }\r\n\r\n    for (QSharedPointer<ComponentInstance> instance : *design->getComponentInstances())\r\n    {\r\n        createComponentItem(instance, design);\r\n    }\r\n\r\n    for (QSharedPointer<Interconnection> interconnection : *design->getInterconnections())\r\n    {\r\n        createInterconnection(interconnection, design);\r\n    }\r\n\r\n    // Set the ad-hoc data for the diagram.\r\n    setAdHocData(getEditedComponent(), design->getPortAdHocVisibilities());\r\n\r\n    // Create top-level ad-hoc interfaces and set their positions.\r\n    createHierachicalAdHocPorts(design);\r\n\r\n    // Create ad-hoc connections based on the design data.\r\n    for (QSharedPointer<AdHocConnection> adHocConn : *design->getAdHocConnections())\r\n    {\r\n        createAdHocConnection(adHocConn);\r\n    }\r\n\r\n    // Update the stacking of the columns.\r\n    for (GraphicsColumn* column : getLayout()->getColumns())\r\n    {\r\n        column->updateItemPositions();\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HWDesignDiagram::getComponentItem()\r\n//-----------------------------------------------------------------------------\r\nHWComponentItem* HWDesignDiagram::getComponentItem(QString const& instanceName)\r\n{\r\n\t// Search all items in the scene.\r\n\tfor (QGraphicsItem* item : items())\r\n    {\r\n\t\t// if the item is a component\r\n        if (item->type() == HWComponentItem::Type)\r\n        {\r\n            HWComponentItem *comp = qgraphicsitem_cast<HWComponentItem *>(item);\r\n            if (comp->name().compare(instanceName) == 0)\r\n            {\r\n                return comp;\r\n            }\r\n        }\r\n    }\r\n\r\n\t// if no component was found\r\n\temit errorMessage(tr(\"Component %1 was not found within design\").arg(instanceName));\r\n    return nullptr;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HWDesignDiagram::updateHierComponent()\r\n//-----------------------------------------------------------------------------\r\nvoid HWDesignDiagram::updateHierComponent()\r\n{\r\n    // Store all the bus interfaces.\r\n    QList<QSharedPointer<BusInterface> > busIfs;\r\n\r\n    // Search all graphics items in the scene.\r\n    for (QGraphicsItem* item : items())\r\n    {\r\n        // Check if the item is a diagram interface and its bus interface is defined.\r\n        if (auto diagIf = dynamic_cast<HierarchicalBusInterfaceItem*>(item))\r\n        {\r\n            if (diagIf->getBusInterface() != nullptr && !diagIf->isInvalid())\r\n            {\r\n                busIfs.append(diagIf->getBusInterface());\r\n            }\r\n        }\r\n    }\r\n\r\n    auto componentInterfaces = getEditedComponent()->getBusInterfaces();\r\n\r\n    // Add any new interfaces in the component.\r\n    for (auto diagramInterface : busIfs)\r\n    {\r\n        bool busExists = std::find_if(componentInterfaces->cbegin(), componentInterfaces->cend(), [&diagramInterface](auto componentBusIf)\r\n            {\r\n                return componentBusIf->name() == diagramInterface->name();\r\n            }) != componentInterfaces->cend();\r\n\r\n        if (!busExists)\r\n        {\r\n            componentInterfaces->append(diagramInterface);\r\n        }\r\n    }\r\n\r\n    if (manuallyDeletedInterfaces_)\r\n    {\r\n        QList<QSharedPointer<BusInterface> > toRemove;\r\n        // Remove interfaces deleted in the design from the component.\r\n        for (auto componentInterface : *componentInterfaces)\r\n        {\r\n            bool busExists = std::find_if(busIfs.cbegin(), busIfs.cend(), [&componentInterface](auto diagramInterface)\r\n                {\r\n                    return componentInterface->name() == diagramInterface->name();\r\n                }) != busIfs.cend();\r\n\r\n            if (!busExists)\r\n            {\r\n                toRemove.append(componentInterface);\r\n            }\r\n        }\r\n\r\n        for (auto interfaceToRemove : toRemove)\r\n        {\r\n            componentInterfaces->removeAll(interfaceToRemove);\r\n        }\r\n    }\r\n\r\n    manuallyDeletedInterfaces_ = false;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HWDesignDiagram::loadColumn()\r\n//-----------------------------------------------------------------------------\r\nvoid HWDesignDiagram::loadColumn(QSharedPointer<ColumnDesc> description)\r\n{\r\n    auto column = new HWColumn(description, getLayout().data());\r\n\r\n    getLayout()->appendColumn(column);\r\n    getDesign()->addColumn(description);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HWDesignDiagram::addColumn()\r\n//-----------------------------------------------------------------------------\r\nvoid HWDesignDiagram::addColumn(QSharedPointer<ColumnDesc> desc)\r\n{\r\n    auto column = new HWColumn(desc, getLayout().data());\r\n\r\n    QSharedPointer<QUndoCommand> cmd(new HWColumnAddCommand(getLayout().data(), column, this));\r\n    getEditProvider()->addCommand(cmd);\r\n    cmd->redo();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HWDesignDiagram::onAdHocVisibilityChanged()\r\n//-----------------------------------------------------------------------------\r\nvoid HWDesignDiagram::onAdHocVisibilityChanged(QString const& portName, bool visible)\r\n{\r\n    QSharedPointer<VendorExtension> adhocExtension = getDesign()->getAdHocPortPositions();\r\n    QSharedPointer<Kactus2Group> adhocGroup = adhocExtension.dynamicCast<Kactus2Group>();\r\n\r\n    if (!adhocGroup)\r\n    {\r\n        adhocGroup = QSharedPointer<Kactus2Group>(new Kactus2Group(\"kactus2:adHocVisibilities\"));\r\n        getDesign()->getVendorExtensions()->append(adhocGroup);\r\n    }\r\n\r\n    if (visible)\r\n    {\r\n        QSharedPointer<Kactus2Placeholder> adhocData(new Kactus2Placeholder(\"kactus2:adHocVisible\"));\r\n        adhocGroup->addToGroup(adhocData);\r\n\r\n        HierarchicalPortItem* adHocIf;\r\n\r\n        \r\n        if (QSharedPointer<Port> adhocPort = getEditedComponent()->getPort(portName); adhocPort)\r\n        {\r\n            adHocIf = new HierarchicalPortItem(getEditedComponent(), adhocPort, adhocData, 0);\r\n        }\r\n        else\r\n        {\r\n            adHocIf = createMissingHierarchicalAdHocPort(portName, adhocData, nullptr);\r\n        }\r\n\r\n        // Add the ad-hoc interface to the first column where it is allowed to be placed.\r\n        getLayout()->addItem(adHocIf);\r\n    }\r\n    else\r\n    {\r\n        // Search for the ad-hoc interface and delete it.\r\n        HWConnectionEndpoint* found = getDiagramAdHocPort(portName);\r\n        Q_ASSERT(found != nullptr);\r\n\r\n        static_cast<GraphicsColumn*>(found->parentItem())->removeItem(found);\r\n        delete found;\r\n        found = nullptr;\r\n\r\n        for (QSharedPointer<VendorExtension> extension : adhocGroup->getByType(\"kactus2:adHocVisible\"))\r\n        {\r\n            QSharedPointer<Kactus2Placeholder> portExtension = extension.dynamicCast<Kactus2Placeholder>();\r\n            if (portExtension->getAttributeValue(QStringLiteral(\"portName\")) == portName)\r\n            {\r\n                adhocGroup->removeFromGroup(portExtension);\r\n            }\r\n        }\r\n\r\n        if (adhocGroup->getByType(QStringLiteral(\"kactus2:adHocVisible\")).isEmpty())\r\n        {\r\n            getDesign()->getVendorExtensions()->removeAll(adhocExtension);\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HWDesignDiagram::getDiagramAdHocPort()\r\n//-----------------------------------------------------------------------------\r\nHWConnectionEndpoint* HWDesignDiagram::getDiagramAdHocPort(QString const& portName)\r\n{\r\n    for (QGraphicsItem* item : items())\r\n    {\r\n        if (item->type() == HierarchicalPortItem::Type &&\r\n            static_cast<HierarchicalPortItem*>(item)->name().compare(portName) == 0)\r\n        {\r\n            return static_cast<HWConnectionEndpoint*>(item);\r\n        }\r\n    }\r\n\r\n    return nullptr;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HWDesignDiagram::getHierarchicalInterface()\r\n//-----------------------------------------------------------------------------\r\nHWConnectionEndpoint* HWDesignDiagram::getHierarchicalInterface(QString const& busRef) const\r\n{\r\n    for (QGraphicsItem* item : items())\r\n    {\r\n        if (item->type() == HierarchicalBusInterfaceItem::Type &&\r\n            static_cast<HierarchicalBusInterfaceItem*>(item)->name().compare(busRef) == 0)\r\n        {\r\n            return static_cast<HWConnectionEndpoint*>(item);\r\n        }\r\n    }\r\n\r\n    return nullptr;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HWDesignDiagram::getInterfacesToDelete()\r\n//-----------------------------------------------------------------------------\r\nvoid HWDesignDiagram::setInterfacesHaveBeenDeleted()\r\n{\r\n    manuallyDeletedInterfaces_ = true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HWDesignDiagram::onCopyAction()\r\n//-----------------------------------------------------------------------------\r\nvoid HWDesignDiagram::onCopyAction()\r\n{\r\n    if (!isProtected())\r\n    {\r\n        QList<QGraphicsItem*> items = selectedItems();\r\n        int type = getCommonItemType(items);\r\n\r\n        if (type == HierarchicalBusInterfaceItem::Type || type == ActiveBusInterfaceItem::Type)\r\n        {\r\n            BusInterfaceCollectionCopyData collection;\r\n            copyInterfaces(items, collection);\r\n\r\n            auto mimeData = new QMimeData();\r\n            mimeData->setImageData(QVariant::fromValue(collection));\r\n            QApplication::clipboard()->setMimeData(mimeData);\r\n        }\r\n        else if (type == HWComponentItem::Type)\r\n        {\r\n            ComponentCollectionCopyData collection;\r\n            copyInstances(items, collection);\r\n\r\n            auto mimeData = new QMimeData();\r\n            mimeData->setImageData(QVariant::fromValue(collection));\r\n            QApplication::clipboard()->setMimeData(mimeData);\r\n        }\r\n        else if (type == HWColumn::Type)\r\n        {\r\n            std::sort(items.begin(), items.end(), &sortByX);\r\n\r\n            ColumnCollectionCopyData collection;\r\n\r\n            for (QGraphicsItem* item : items)\r\n            {\r\n                auto column = static_cast<HWColumn*>(item);\r\n\r\n                collection.columns.append(ColumnCopyData());\r\n                ColumnCopyData& columnData = collection.columns.back();\r\n                columnData.desc = column->getColumnDesc();\r\n\r\n                copyInstances(column->getItems(), columnData.components);\r\n                copyInterfaces(column->getItems(), columnData.interfaces);\r\n            }\r\n\r\n            auto mimeData = new QMimeData();\r\n            mimeData->setImageData(QVariant::fromValue(collection));\r\n            QApplication::clipboard()->setMimeData(mimeData);\r\n        }\r\n    }\r\n\r\n    prepareContextMenuActions();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HWDesignDiagram::onPasteAction()\r\n//-----------------------------------------------------------------------------\r\nvoid HWDesignDiagram::onPasteAction()\r\n{\r\n    if (isProtected())\r\n    {\r\n        return;\r\n    }\r\n\r\n    QList<QGraphicsItem*> selection = selectedItems();\r\n    int selectionType = getCommonItemType(selection);\r\n\r\n    QMimeData const* mimeData = QApplication::clipboard()->mimeData();\r\n\r\n    if (selectionType == HWComponentItem::Type)\r\n    {\r\n        pasteInterfacesToDraftComponent(static_cast<HWComponentItem*>(selection.first()));\r\n    }\r\n    else if (mimeData->imageData().canConvert<ComponentCollectionCopyData>() && selection.empty())\r\n    {\r\n        pasteComponentsToColumn();\r\n    }\r\n    else if (mimeData->imageData().canConvert<ColumnCollectionCopyData>() &&\r\n        (selection.empty() || selectionType == HWColumn::Type))\r\n    {\r\n        pasteColumns();\r\n    }\r\n    else if (mimeData->imageData().canConvert<BusInterfaceCollectionCopyData>() && selection.empty()) \r\n    {\r\n        pasteHierarchicalInterfaces(mimeData);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HWDesignDiagram::pasteInterfacesToDraftComponent()\r\n//-----------------------------------------------------------------------------\r\nvoid HWDesignDiagram::pasteInterfacesToDraftComponent(HWComponentItem* targetItem)\r\n{\r\n    // Paste interfaces only to draft components.\r\n    if (targetItem->isDraft())\r\n    {\r\n        auto const* mimedata = QApplication::clipboard()->mimeData();\r\n        if (mimedata->hasImage() && mimedata->imageData().canConvert<BusInterfaceCollectionCopyData>())\r\n        {\t\t\t\t\r\n            BusInterfaceCollectionCopyData collection = mimedata->imageData().value<BusInterfaceCollectionCopyData>();\r\n\r\n            QSharedPointer<QUndoCommand> pasteUndoCommand(new QUndoCommand());\r\n            pasteInterfaces(collection, targetItem, pasteUndoCommand.data());\r\n            getEditProvider()->addCommand(pasteUndoCommand);\r\n\r\n            // Update sidebar view.\r\n            emit componentSelected(targetItem);\r\n            emit helpUrlRequested(QStringLiteral(\"hwdesign/hwinstance.html\"));\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HWDesignDiagram::pasteComponentsToColumn()\r\n//-----------------------------------------------------------------------------\r\nvoid HWDesignDiagram::pasteComponentsToColumn()\r\n{\r\n    GraphicsColumn* column = getLayout()->findColumnAt(contextMenuPosition());\r\n    if (column != nullptr)\r\n    {\r\n        auto const* mimeData = QApplication::clipboard()->mimeData();\r\n        ComponentCollectionCopyData collection = mimeData->imageData().value<ComponentCollectionCopyData>();\r\n\r\n        QSharedPointer<QUndoCommand> pasteUndoCommand(new QUndoCommand());\r\n        createComponentPasteCommand(collection, column, pasteUndoCommand.data(), true);\r\n        \r\n        getEditProvider()->addCommand(pasteUndoCommand);\r\n        pasteUndoCommand->redo();\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HWDesignDiagram::pasteColumns()\r\n//-----------------------------------------------------------------------------\r\nvoid HWDesignDiagram::pasteColumns()\r\n{\r\n    auto const* mimeData = QApplication::clipboard()->mimeData();\r\n    ColumnCollectionCopyData collection = mimeData->imageData().value<ColumnCollectionCopyData>();\r\n\r\n    QSharedPointer<QUndoCommand> parentCommand(new QUndoCommand());\r\n\r\n    QPointF columnPosition = findCursorPositionMappedToScene();\r\n\r\n    for (ColumnCopyData const& columnData : collection.columns)\r\n    {\r\n        QSharedPointer<ColumnDesc> columnCopy(new ColumnDesc(*columnData.desc));\r\n        auto columnItem = new HWColumn(columnCopy, getLayout().data());\r\n        columnItem->setPos(columnPosition);\r\n\r\n        new HWColumnAddCommand(getLayout().data(), columnItem, this, parentCommand.data());\r\n\r\n        createComponentPasteCommand(columnData.components, columnItem, parentCommand.data(), false);\r\n        \r\n        pasteTopLevelInterfaces(columnData.interfaces, columnItem, parentCommand.data(), false);\r\n\r\n        columnPosition += QPointF(columnCopy->getWidth(), 0);\r\n    }\r\n\r\n    getEditProvider()->addCommand(parentCommand);\r\n    parentCommand->redo();\r\n\r\n    emit clearItemSelection();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HWDesignDiagram::pasteHierarchicalInterfaces()\r\n//-----------------------------------------------------------------------------\r\nvoid HWDesignDiagram::pasteHierarchicalInterfaces(QMimeData const* mimeData)\r\n{\r\n    GraphicsColumn* column = getLayout()->findColumnAt(contextMenuPosition());\r\n    if (column != nullptr)\r\n    {\r\n        BusInterfaceCollectionCopyData collection = mimeData->imageData().value<BusInterfaceCollectionCopyData>();\r\n\r\n        QSharedPointer<QUndoCommand> pasteUndoCommand(new QUndoCommand());\r\n        pasteTopLevelInterfaces(collection, column, pasteUndoCommand.data(), true);\r\n\r\n        if (pasteUndoCommand->childCount() > 0)\r\n        {\r\n            getEditProvider()->addCommand(pasteUndoCommand); \r\n        }\r\n\r\n        emit clearItemSelection();       \r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HWDesignDiagram::onAddToLibraryAction()\r\n//-----------------------------------------------------------------------------\r\nvoid HWDesignDiagram::onAddToLibraryAction()\r\n{\r\n    if (!singleSelection())\r\n    {\r\n        return;\r\n    }\r\n\r\n    QGraphicsItem* selection = selectedItems().first();\r\n    if (selection != nullptr && selection->type() == HWComponentItem::Type)\r\n    {\r\n        selection->setSelected(true);\r\n        HWComponentItem* componentItem = qgraphicsitem_cast<HWComponentItem *>(selection);\r\n\r\n        QSharedPointer<Component> targetComponent = componentItem->componentModel();\r\n\r\n        // Set the instance name as default name suggestion.\r\n        VLNV componentVLNV = targetComponent->getVlnv();\r\n        componentVLNV.setName(componentItem->name());\r\n\r\n        NewObjectDialog dialog(getLibraryInterface(), VLNV::COMPONENT, true, getParent());\r\n        dialog.setVLNV(componentVLNV);\r\n        dialog.setWindowTitle(tr(\"Add Component to Library\"));\r\n\r\n        if (dialog.exec() == QDialog::Accepted)\r\n        {\r\n            VLNV vlnv = dialog.getVLNV();\r\n                \r\n            QSharedPointer<QUndoCommand> cmd(new ComponentPacketizeCommand(this, componentItem, vlnv));\r\n\r\n            targetComponent->setVlnv(vlnv);\r\n            targetComponent->setHierarchy(dialog.getProductHierarchy());\r\n            targetComponent->setFirmness(dialog.getFirmness());\r\n            targetComponent->setTags(dialog.getTags());\r\n\r\n            for (ConnectionEndpoint* interfacePoint : componentItem->getEndpoints())\r\n            {\r\n                interfacePoint->setSelectionHighlight(true);\r\n                interfacePoint->setTemporary(false);\r\n\r\n                ConnectionEndpoint* definedPoint(nullptr);\r\n\r\n                for (auto const connection : interfacePoint->getConnections())\r\n                {\r\n                    if (connection->endpoint1() != interfacePoint && !connection->endpoint1()->isTemporary())\r\n                    {\r\n                        definedPoint = connection->endpoint1();\r\n                        break;\r\n                    }\r\n                    else if (connection->endpoint2() != interfacePoint && !connection->endpoint2()->isTemporary())\r\n                    {\r\n                        definedPoint = connection->endpoint2();\r\n                        break;\r\n                    }\r\n                }\r\n\r\n                if (definedPoint)\r\n                {\r\n                    copyMode(definedPoint, interfacePoint, cmd.data());\r\n                    copyType(definedPoint, interfacePoint, cmd.data());                    \r\n                    copyPortMapsAndPhysicalPorts(definedPoint->getOwnerComponent(),\r\n                        definedPoint->getBusInterface(), definedPoint->encompassingComp(), interfacePoint,\r\n                        cmd.data());\r\n                }\r\n\r\n                interfacePoint->setSelectionHighlight(false);\r\n                interfacePoint->updateInterface();\r\n            }\r\n\r\n            getLibraryInterface()->writeModelToFile(dialog.getPath(), targetComponent);\r\n\r\n            getEditProvider()->addCommand(cmd);\r\n            cmd->redo();\r\n\r\n            QMessageBox msgBox(QMessageBox::Question, QCoreApplication::applicationName(),\r\n                tr(\"Do you want to continue packaging the component completely?\"),\r\n                QMessageBox::NoButton, getParent());\r\n            msgBox.setInformativeText(tr(\"Pressing Continue opens up the component editor.\"));\r\n\r\n            QPushButton* btnContinue = msgBox.addButton(tr(\"Continue\"), QMessageBox::ActionRole);\r\n            msgBox.addButton(tr(\"Skip\"), QMessageBox::RejectRole);\r\n\r\n            msgBox.exec();\r\n\r\n            if (msgBox.clickedButton() == btnContinue)\r\n            {\r\n                openInComponentEditor(componentItem);\r\n            }\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HWDesignDiagram::openDesignForComponent()\r\n//-----------------------------------------------------------------------------\r\nvoid HWDesignDiagram::openDesignForComponent(ComponentItem* component, QString const& viewName)\r\n{\r\n    if (component->componentModel()->hasView(viewName))\r\n    {\r\n        emit openDesign(component->componentModel()->getVlnv(), viewName);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HWDesignDiagram::mouseDoubleClickEvent()\r\n//-----------------------------------------------------------------------------\r\nvoid HWDesignDiagram::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *mouseEvent)\r\n{\r\n    // Allow double click only when the mode is select.\r\n    if (getMode() != MODE_SELECT)\r\n    {\r\n        return;\r\n    }\r\n\r\n    // Find the item under the cursor.\r\n    QGraphicsItem *item = itemAt(snapPointToGrid(mouseEvent->scenePos()), QTransform());\r\n\r\n    if (item == nullptr)\r\n    {\r\n        return;\r\n    }\r\n\r\n    item = getBaseItemOf(item);\r\n\r\n    if (item->type() == HWComponentItem::Type)\r\n    {\r\n        item->setSelected(true);\r\n        HWComponentItem *comp = qgraphicsitem_cast<HWComponentItem *>(item);\r\n\r\n        if (getLibraryInterface()->contains(comp->componentModel()->getVlnv()))\r\n        {\r\n            openComponentItem(comp);\r\n        }\r\n        else if (!isProtected())\r\n        {           \r\n           onAddToLibraryAction();\r\n        }\r\n    }\r\n    else if (item->type() == HWColumn::Type && !isProtected())\r\n    {\r\n        item->setSelected(true);\r\n        HWColumn* column = qgraphicsitem_cast<HWColumn*>(item);\r\n\r\n        ColumnEditDialog dialog(getParent(), false, column);\r\n\r\n        if (dialog.exec() == QDialog::Accepted)\r\n        {\r\n            int columnWidth = GraphicsColumnConstants::COMPONENT_COLUMN_WIDTH;\r\n\r\n            if (dialog.getContentType() == ColumnTypes::IO)\r\n            {\r\n                columnWidth = GraphicsColumnConstants::IO_COLUMN_WIDTH;\r\n            }\r\n\r\n            QSharedPointer<ColumnDesc> desc(new ColumnDesc(dialog.name(), dialog.getContentType(),\r\n                dialog.getAllowedItems(), columnWidth));\r\n\r\n            // Keep the previous width if the content type did not change.\r\n            if (dialog.getContentType() == column->getColumnDesc()->getContentType())\r\n            {\r\n                desc->setWidth(column->getColumnDesc()->getWidth());\r\n            }\r\n\r\n            QSharedPointer<QUndoCommand> cmd(new GraphicsColumnChangeCommand(column, desc, this));\r\n            getEditProvider()->addCommand(cmd);\r\n            cmd->redo();\r\n\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HWDesignDiagram::dragEnterEvent()\r\n//-----------------------------------------------------------------------------\r\nvoid HWDesignDiagram::dragEnterEvent(QGraphicsSceneDragDropEvent * event)\r\n{\r\n    dragCompType_ = ColumnTypes::NONE;\r\n    dragBus_ = false;\r\n\r\n    // Allow drag only if the diagram is not locked and the dragged object is a vlnv.\r\n    if (isProtected() || !event->mimeData()->hasImage() || !event->mimeData()->imageData().canConvert<VLNV>())\r\n    {\r\n        return;\r\n    }\r\n\r\n    event->acceptProposedAction();\r\n    VLNV draggedVLNV = event->mimeData()->imageData().value<VLNV>();\r\n\r\n    if (draggedVLNV.getType() == VLNV::BUSDEFINITION || draggedVLNV.getType() == VLNV::ABSTRACTIONDEFINITION)\r\n    {\r\n        dragBus_ = true;\r\n    }\r\n    else if (draggedVLNV.getType() == VLNV::COMPONENT)\r\n    {\r\n        // Determine the component type.\r\n        QSharedPointer<Document const> libComp = getLibraryInterface()->getModelReadOnly(draggedVLNV);\r\n        QSharedPointer<Component const> component = libComp.dynamicCast<Component const>();\r\n\r\n        // component with given vlnv was not found\r\n        if (!component) \r\n        {\r\n            emit errorMessage(tr(\"Component with the VLNV %1 was not found in the library.\").arg(\r\n                draggedVLNV.toString()));\r\n            return;\r\n        }\r\n\r\n        // Check if the implementation does not match with the edited component.\r\n        if (component->getImplementation() != getEditedComponent()->getImplementation())\r\n        {\r\n            return;\r\n        }\r\n\r\n        if (component->isTransparentBridge() ||component->isOpaqueBridge())\r\n        {\r\n            dragCompType_ = ColumnTypes::BRIDGE;\r\n        }\r\n        else if (component->isChannel())\r\n        {\r\n            dragCompType_ = ColumnTypes::CHANNEL;\r\n        }\r\n        else\r\n        {\r\n            dragCompType_ = ColumnTypes::COMPONENT;\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HWDesignDiagram::dragLeaveEvent()\r\n//-----------------------------------------------------------------------------\r\nvoid HWDesignDiagram::dragLeaveEvent(QGraphicsSceneDragDropEvent*)\r\n{\r\n    dragCompType_ = ColumnTypes::NONE;\r\n    dragBus_ = false;\r\n    \r\n    if (dragEndPoint_)\r\n    {\r\n        dragEndPoint_->setHighlight(ConnectionEndpoint::HIGHLIGHT_OFF);\r\n        dragEndPoint_ = nullptr;\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HWDesignDiagram::dropEvent()\r\n//-----------------------------------------------------------------------------\r\nvoid HWDesignDiagram::dropEvent(QGraphicsSceneDragDropEvent *event)\r\n{\r\n    // Retrieve the vlnv.\r\n    QVariant data = event->mimeData()->imageData();\r\n    if (!data.canConvert<VLNV>())\r\n    {\r\n        return;\r\n    }\r\n\r\n    VLNV droppedVLNV = data.value<VLNV>();\r\n    updateDropAction(event);\r\n\r\n    // Check if the dragged item was a valid one.\r\n    if (dragCompType_ != ColumnTypes::NONE)\r\n    {\r\n        // Do not allow self-instantiation.\r\n        if (droppedVLNV == getEditedComponent()->getVlnv())\r\n        {\r\n            QMessageBox msgBox(QMessageBox::Warning, QCoreApplication::applicationName(),\r\n                tr(\"Component cannot be instantiated to its own design.\"), QMessageBox::Ok, getParent());\r\n            msgBox.exec();\r\n            return;\r\n        }\r\n\r\n        // Create the component model.\r\n        QSharedPointer<Component> dropComponent = getLibraryInterface()->getModel(droppedVLNV).staticCast<Component>();\r\n\r\n        // Disallow instantiation of components marked as template.\r\n        if (dropComponent->getFirmness() == KactusAttribute::TEMPLATE)\r\n        {\r\n            QMessageBox msgBox(QMessageBox::Warning, QCoreApplication::applicationName(),\r\n                tr(\"Template component cannot be directly instantiated in a design. \"\r\n                \"Save the template component as a new non-template component to enable instantiation.\"),\r\n                QMessageBox::Ok, getParent());\r\n            msgBox.exec();\r\n            return;\r\n        }\r\n        \r\n        // Display error if user is trying to instantiate component of different standard revision.\r\n        if (dropComponent->getRevision() != getEditedComponent()->getRevision())\r\n        {\r\n            QMessageBox msgBox(QMessageBox::Warning, QCoreApplication::applicationName(),\r\n                tr(\"Component %1 using IP-XACT %2 cannot be instantiated in the design using IP-XACT %3\")\r\n                .arg(dropComponent->getVlnv().toString())\r\n                .arg(Document::toString(dropComponent->getRevision()))\r\n                .arg(Document::toString(getEditedComponent()->getRevision())),\r\n                QMessageBox::Ok, getParent());\r\n\r\n            msgBox.exec();\r\n            return;\r\n        }\r\n\r\n        // Act based on the selected drop action.\r\n        if (event->dropAction() == Qt::CopyAction)\r\n        {\r\n            QSharedPointer<QUndoCommand> addCommand(new QUndoCommand());\r\n            QString instanceName = createInstanceName(dropComponent->getVlnv().getName());\r\n\r\n            auto createdItem = createComponentItem(dropComponent, instanceName,\r\n                event->scenePos(), addCommand.data());\r\n\r\n            if (createdItem)\r\n            {\r\n                getEditProvider()->addCommand(addCommand);\r\n            }\r\n        }\r\n        else if (event->dropAction() == Qt::MoveAction)\r\n        {\r\n            replaceComponentItemAtPositionWith(event->scenePos(), dropComponent);\r\n        }\r\n    }\r\n    else if (dragBus_ && dragEndPoint_ != nullptr)\r\n    {\r\n        setInterfaceVLNVatEndpoint(droppedVLNV);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HWDesignDiagram::setInterfaceVLNVatEndpoint()\r\n//-----------------------------------------------------------------------------\r\nvoid HWDesignDiagram::setInterfaceVLNVatEndpoint(VLNV const& droppedVLNV)\r\n{\r\n    Q_ASSERT(getLibraryInterface()->contains(droppedVLNV));\r\n\r\n    VLNV busVLNV;\r\n    VLNV absdefVLNV;\r\n\r\n    // if the dropped was an abstraction definition\r\n    if (getLibraryInterface()->getDocumentType(droppedVLNV) == VLNV::ABSTRACTIONDEFINITION)\r\n    {\r\n        QSharedPointer<AbstractionDefinition const> absDef = \r\n            getLibraryInterface()->getModelReadOnly(droppedVLNV).staticCast<AbstractionDefinition const>();\r\n\r\n        busVLNV = absDef->getBusType();\r\n        absdefVLNV = droppedVLNV;\r\n    }\r\n    else\r\n    {\r\n        busVLNV = droppedVLNV;\r\n    }\r\n\r\n    Q_ASSERT(busVLNV.getType() == VLNV::BUSDEFINITION);\r\n\r\n    // Ask the user for the interface mode.\r\n    BusInterfaceDialog dialog(getParent());\r\n    dialog.addMode(General::MIRRORED_MASTER);\r\n    dialog.addMode(General::SLAVE);\r\n    dialog.addMode(General::MIRRORED_SLAVE);\r\n    dialog.addMode(General::SYSTEM);\r\n    dialog.addMode(General::MIRRORED_SYSTEM);\r\n    dialog.addMode(General::MASTER);\r\n\r\n    int result = dialog.exec();\r\n    dragEndPoint_->setHighlight(ConnectionEndpoint::HIGHLIGHT_OFF);\r\n\r\n    if (result == QDialog::Accepted)\r\n    {\r\n        QString activeView = getActiveViewForEndPoint(dragEndPoint_);\r\n\r\n        QSharedPointer<QUndoCommand> typeCommand(\r\n            new EndPointTypesCommand(dragEndPoint_, busVLNV, absdefVLNV, activeView));\r\n        new EndpointChangeCommand(dragEndPoint_, dialog.getSelectedMode(), typeCommand.data());\r\n\r\n        getEditProvider()->addCommand(typeCommand);\r\n        typeCommand->redo();\r\n\r\n        dragEndPoint_ = nullptr;\r\n    }    \r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HWDesignDiagram::replaceComponentItemAt()\r\n//-----------------------------------------------------------------------------\r\nvoid HWDesignDiagram::replaceComponentItemAtPositionWith(QPointF position, QSharedPointer<Component> component)\r\n{\r\n    // Replace the underlying component with the new one.\r\n    auto previousItem = static_cast<HWComponentItem*>(getTopmostComponent(position));\r\n    Q_ASSERT(previousItem != nullptr);\r\n\r\n    QMessageBox msgBox(QMessageBox::Warning, QCoreApplication::applicationName(),\r\n        tr(\"Component instance '%1' is about to be replaced with an instance of %2. Continue and replace?\").arg(\r\n        previousItem->name(), component->getVlnv().toString()), QMessageBox::Yes | QMessageBox::No, getParent());\r\n\r\n    if (msgBox.exec() == QMessageBox::Yes)\r\n    {\r\n        QSharedPointer<QUndoCommand> parentCommand(new QUndoCommand());\r\n\r\n        // Create instance of the dropped component.\r\n        HWComponentItem* newCompItem = createComponentItem(component, previousItem->name(), previousItem->scenePos(),\r\n            parentCommand.data());\r\n\r\n        // Perform the replacement.\r\n        auto replaceCommand(new ReplaceComponentCommand(previousItem, newCompItem, this, parentCommand.data()));\r\n\r\n        connect(replaceCommand, SIGNAL(componentInstantiated(ComponentItem*)),\r\n            this, SIGNAL(componentInstantiated(ComponentItem*)), Qt::UniqueConnection);\r\n        connect(replaceCommand, SIGNAL(componentInstanceRemoved(ComponentItem*)),\r\n            this, SIGNAL(componentInstanceRemoved(ComponentItem*)), Qt::UniqueConnection);\r\n\r\n        replaceCommand->redo();\r\n\r\n        // Remove the old component.\r\n        auto deleteCmd = new ComponentDeleteCommand(this, \r\n            getLayout()->findColumnAt(previousItem->scenePos()), previousItem, parentCommand.data());\r\n\r\n        connect(deleteCmd, SIGNAL(componentInstantiated(ComponentItem*)),\r\n            this, SIGNAL(componentInstantiated(ComponentItem*)), Qt::UniqueConnection);\r\n        connect(deleteCmd, SIGNAL(componentInstanceRemoved(ComponentItem*)),\r\n            this, SIGNAL(componentInstanceRemoved(ComponentItem*)), Qt::UniqueConnection);\r\n\r\n        deleteCmd->redo();\r\n\r\n        getEditProvider()->addCommand(parentCommand);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HWDesignDiagram::updateDropAction()\r\n//-----------------------------------------------------------------------------\r\nvoid HWDesignDiagram::updateDropAction(QGraphicsSceneDragDropEvent* event)\r\n{\r\n    if (dragCompType_ != ColumnTypes::NONE)\r\n    {\r\n        // Find the topmost component under the cursor.\r\n        auto const item = getTopmostComponent(event->scenePos());\r\n\r\n        auto const column = getLayout()->findColumnAt(snapPointToGrid(event->scenePos()));\r\n\r\n        // If the item is a HW component, determine whether the component can be replaced with the dragged one.\r\n        if (item != nullptr && item->type() == HWComponentItem::Type && column != nullptr)\r\n        {\r\n            if (column->getColumnDesc()->getAllowedItems() & dragCompType_)\r\n            {\r\n                event->setDropAction(Qt::MoveAction);\r\n            }\r\n            else\r\n            {\r\n                event->setDropAction(Qt::IgnoreAction);\r\n            }\r\n        }\r\n        else\r\n        {\r\n            // Otherwise check whether the component can be placed to the underlying column.\r\n            if (column != nullptr && column->getColumnDesc()->getAllowedItems() & dragCompType_)\r\n            {\r\n                event->setDropAction(Qt::CopyAction);\r\n            }\r\n            else\r\n            {\r\n                event->setDropAction(Qt::IgnoreAction);\r\n            }\r\n        }\r\n\r\n        event->accept();\r\n    }\r\n\r\n    else if (dragBus_)\r\n    {        \r\n        if (dragEndPoint_)\r\n        {\r\n            dragEndPoint_->setHighlight(ConnectionEndpoint::HIGHLIGHT_OFF);\r\n        }\r\n        \r\n        dragEndPoint_ =  DiagramUtil::snapToItem<HWConnectionEndpoint>(event->scenePos(), this, GridSize);     \r\n\r\n        // Allow the drop event if the end point is undefined.\r\n        if (dragEndPoint_ != nullptr && dragEndPoint_->isBus() && dragEndPoint_->isHierarchical() &&\r\n            (dragEndPoint_->getBusInterface() == nullptr || !dragEndPoint_->getBusInterface()->getBusType().isValid()))\r\n        {\r\n            event->setDropAction(Qt::CopyAction);\r\n            dragEndPoint_->setHighlight(ConnectionEndpoint::HIGHLIGHT_HOVER);\r\n        }\r\n        else\r\n        {\r\n            event->setDropAction(Qt::IgnoreAction);\r\n        }\r\n\r\n        event->accept();\r\n    }\r\n    else\r\n    {\r\n        event->setDropAction(Qt::IgnoreAction);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HWDesignDiagram::openComponentActionEnabled()\r\n//-----------------------------------------------------------------------------\r\nbool HWDesignDiagram::openComponentActionEnabled() const\r\n{\r\n    return singleSelection() && selectedItems().first()->type() == componentType() && !draftSelected();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HWDesignDiagram::itemIsCorrectType()\r\n//-----------------------------------------------------------------------------\r\nbool HWDesignDiagram::selectedItemIsCorrectType() const\r\n{\r\n    int type = selectedItems().first()->type();\r\n\r\n    return type == componentType() || type == HierarchicalBusInterfaceItem::Type ||\r\n        type == ActiveBusInterfaceItem::Type || type == HWConnection::Type || type == AdHocConnectionItem::Type ||\r\n        type == HWColumn::Type || type == HierarchicalPortItem::Type || type == ActivePortItem::Type ||\r\n        type == StickyNote::Type || type == Association::Type;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HWDesignDiagram::isHierarchicalComponent()\r\n//-----------------------------------------------------------------------------\r\nbool HWDesignDiagram::isHierarchicalComponent(QGraphicsItem* item) const\r\n{\r\n    if (auto const component = qgraphicsitem_cast<HWComponentItem*>(item); component)\r\n    {\r\n        return component->componentModel()->isHierarchical();\r\n    }\r\n\r\n    return false;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HWDesignDiagram::copyActionEnabled()\r\n//-----------------------------------------------------------------------------\r\nbool HWDesignDiagram::copyActionEnabled() const\r\n{\r\n    if (selectedItems().empty())\r\n    {\r\n        return false;\r\n    }\r\n\r\n    int itemType = getCommonItemType(selectedItems());\r\n    return (!isProtected() && \r\n        (itemType == ActiveBusInterfaceItem::Type || itemType == HierarchicalBusInterfaceItem::Type ||\r\n         itemType == HWComponentItem::Type || itemType == HWColumn::Type));  \r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HWDesignDiagram::pasteActionEnabled()\r\n//-----------------------------------------------------------------------------\r\nbool HWDesignDiagram::pasteActionEnabled() const\r\n{\r\n    // If the selection is empty, check if the clipboard contains components or a column.\r\n    QMimeData const* mimeData = QApplication::clipboard()->mimeData();\r\n\r\n    if (isProtected() || !mimeData || !mimeData->hasImage())\r\n    {\r\n        return false;\r\n    }\r\n\r\n    bool pasteEnabled = false;        \r\n\r\n    QList<QGraphicsItem*> selection = selectedItems();\r\n    int commonType = getCommonItemType(selection);\r\n\r\n    if (selection.empty())\r\n    {\r\n        auto const column = getLayout()->findColumnAt(contextMenuPosition());\r\n\r\n        pasteEnabled = (mimeData->imageData().canConvert<ColumnCollectionCopyData>() || \r\n            (column != nullptr && mimeData->imageData().canConvert<ComponentCollectionCopyData>()) ||\r\n            (column != nullptr && mimeData->imageData().canConvert<BusInterfaceCollectionCopyData>()));\r\n    }\r\n    else if (commonType == HWColumn::Type)\r\n    {\r\n        pasteEnabled = mimeData->imageData().canConvert<ColumnCollectionCopyData>();\r\n    }\r\n    else\r\n    {\r\n        pasteEnabled = singleSelection() && draftSelected() && \r\n            mimeData->imageData().canConvert<BusInterfaceCollectionCopyData>();\r\n    }\r\n\r\n    return pasteEnabled;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HWDesignDiagram::openComponentByActiveView()\r\n//-----------------------------------------------------------------------------\r\nvoid HWDesignDiagram::openComponentByActiveView(ComponentItem* comp)\r\n{\r\n    QString viewName = getActiveViewOf(comp);\r\n\r\n    // if view was found\r\n    if (comp->componentModel()->hasView(viewName) && hierarchicalViewsOf(comp).contains(viewName))\r\n    {\r\n        openDesignForComponent(comp, viewName);\r\n    }\r\n    else\r\n    {\r\n        openInComponentEditor(comp);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HWDesignDiagram::hierarchicalViewsOf()\r\n//-----------------------------------------------------------------------------\r\nQStringList HWDesignDiagram::hierarchicalViewsOf(ComponentItem* component) const\r\n{\r\n    return component->componentModel()->getHierViews();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HWDesignDiagram::componentType()\r\n//-----------------------------------------------------------------------------\r\nint HWDesignDiagram::componentType() const\r\n{\r\n    return HWComponentItem::Type;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HWDesignDiagram::offpageConnectorType()\r\n//-----------------------------------------------------------------------------\r\nint HWDesignDiagram::offpageConnectorType() const\r\n{\r\n    return OffPageConnectorItem::Type;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HWDesignDiagram::connectionType()\r\n//-----------------------------------------------------------------------------\r\nint HWDesignDiagram::connectionType() const\r\n{\r\n    return HWConnection::Type;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HWDesignDiagram::findOrCreateInterfaceExtensionGroup()getCo\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<InterfaceGraphicsData> HWDesignDiagram::findOrCreateInterfaceExtensionGroup(\r\n    QSharedPointer<Design> design, QString const& busInterfaceName)\r\n{\r\n    for (QSharedPointer<InterfaceGraphicsData> graphicsData : design->getInterfaceGraphicsData())\r\n    {\r\n        if (busInterfaceName == graphicsData->getName())\r\n        {\r\n            return graphicsData;\r\n        }\r\n    }\r\n\r\n    QSharedPointer<InterfaceGraphicsData> dataGroup (new InterfaceGraphicsData(busInterfaceName));\r\n    dataGroup->setDirection(QVector2D(1, 0));\r\n    design->getVendorExtensions()->append(dataGroup);\r\n\r\n    return dataGroup;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HWDesignDiagram::onSelected()\r\n//-----------------------------------------------------------------------------\r\nvoid HWDesignDiagram::onSelected(QGraphicsItem* newSelection)\r\n{\r\n    // Activate the correct views when something has been selected.\r\n    if (newSelection != nullptr)\r\n    {\r\n        QString revisionSuffix;\r\n\r\n        if (getDesign()->getRevision() == Document::Revision::Std22)\r\n        {\r\n            revisionSuffix = QStringLiteral(\"2022\");\r\n        }\r\n\r\n        // Check if the selected item was a component.\r\n        if (newSelection->type() == HWComponentItem::Type)\r\n        {\r\n            auto comp = qgraphicsitem_cast<HWComponentItem *>(newSelection);\r\n            emit componentSelected(comp);\r\n            emit helpUrlRequested(tr(\"hwdesign/hwinstance%1.html\").arg(revisionSuffix));\r\n        }\r\n        // Check if the selected item was a port.\r\n        else if (newSelection->type() == ActiveBusInterfaceItem::Type)\r\n        {\r\n            auto port = qgraphicsitem_cast<ActiveBusInterfaceItem*>(newSelection);\r\n            emit interfaceSelected(port);\r\n            emit helpUrlRequested(tr(\"hwdesign/busport%1.html\").arg(revisionSuffix));\r\n        }\r\n        // Check if the selected item was an interface.\r\n        else if (newSelection->type() == HierarchicalBusInterfaceItem::Type)\r\n        {\r\n            auto interface = qgraphicsitem_cast<HierarchicalBusInterfaceItem*>(newSelection);\r\n            emit interfaceSelected(interface);\r\n            emit helpUrlRequested(tr(\"hwdesign/busport%1.html\").arg(revisionSuffix));\r\n        }\r\n        // Check if the selected item was an ad-hoc port.\r\n        else if (newSelection->type() == ActivePortItem::Type)\r\n        {\r\n            auto adHocPort = static_cast<ActivePortItem*>(newSelection);\r\n            emit interfaceSelected(adHocPort);\r\n            emit helpUrlRequested(QStringLiteral(\"hwdesign/adhocport.html\"));\r\n        }\r\n        // Check if the selected item was an ad-hoc interface.\r\n        else if (newSelection->type() == HierarchicalPortItem::Type)\r\n        {\r\n            auto adHocIf = static_cast<HierarchicalPortItem*>(newSelection);\r\n            emit interfaceSelected(adHocIf);\r\n            emit helpUrlRequested(QStringLiteral(\"hwdesign/adhocport.html\"));\r\n        }\r\n\t\t// check if the selected item was a connection\r\n\t\telse if (newSelection->type() == HWConnection::Type)\r\n        {\r\n            auto connection = qgraphicsitem_cast<HWConnection*>(newSelection);\r\n\t\t\temit connectionSelected(connection);\r\n            emit helpUrlRequested(QStringLiteral(\"hwdesign/connection.html\"));\r\n\t\t}\r\n        else if (newSelection->type() == AdHocConnectionItem::Type)\r\n        {\r\n            auto connection = qgraphicsitem_cast<AdHocConnectionItem*>(newSelection);\r\n            emit connectionSelected(connection);\r\n            emit helpUrlRequested(QStringLiteral(\"hwdesign/adhocconnection.html\"));\r\n        }\r\n        else\r\n        {\r\n            // inform others that nothing is currently selected\r\n            emit clearItemSelection();\r\n            emit helpUrlRequested(QStringLiteral(\"hwdesign/hwdesign.html\"));\r\n        }\r\n    }\r\n    else\r\n    {\r\n        // Clear the selection.\r\n        emit clearItemSelection();\r\n        emit helpUrlRequested(QStringLiteral(\"hwdesign/hwdesign.html\"));\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HWDesignDiagram::createConnection()\r\n//-----------------------------------------------------------------------------\r\nGraphicsConnection* HWDesignDiagram::createConnection(ConnectionEndpoint* startPoint, ConnectionEndpoint* endPoint, bool isOffPage)\r\n{    \r\n    QSharedPointer<ConnectionRoute> route(new ConnectionRoute(\"\"));\r\n    \r\n    GraphicsConnection* connection;\r\n\r\n    if (startPoint->isAdHoc())\r\n    {\r\n        QSharedPointer<AdHocConnection> adHocConnection(new AdHocConnection(\"\"));\r\n        \r\n        if (startPoint->isHierarchical())\r\n        {\r\n            QSharedPointer<PortReference> startReference(new PortReference(startPoint->getPort()->name()));\r\n            adHocConnection->getExternalPortReferences()->append(startReference);\r\n        }\r\n        else\r\n        {\r\n            QSharedPointer<PortReference> startReference(new PortReference(startPoint->getPort()->name(),\r\n                startPoint->encompassingComp()->name()));\r\n            adHocConnection->getInternalPortReferences()->append(startReference);\r\n        }\r\n        \r\n        if (endPoint->isHierarchical())\r\n        {\r\n            QSharedPointer<PortReference> endReference(new PortReference(endPoint->name()));\r\n            adHocConnection->getExternalPortReferences()->append(endReference);\r\n        }\r\n        else\r\n        {\r\n            QSharedPointer<PortReference> endReference(new PortReference(endPoint->name(),\r\n                endPoint->encompassingComp()->name()));\r\n            adHocConnection->getInternalPortReferences()->append(endReference);\r\n        }\r\n\r\n        connection = new AdHocConnectionItem(startPoint, endPoint, adHocConnection, route, this);   \r\n\r\n        auto connectionName = connection->createDefaultName();\r\n        connection->setName(connectionName);\r\n    }\r\n    else\r\n    {\r\n        QSharedPointer<Interconnection> interconnection(new Interconnection());\r\n\r\n        if (startPoint->isHierarchical())\r\n        {\r\n            QSharedPointer<HierInterface> startInterface(new HierInterface(startPoint->name()));\r\n            interconnection->getHierInterfaces()->append(startInterface);\r\n        }\r\n        else\r\n        {\r\n            QSharedPointer<ActiveInterface> startInterface(\r\n                new ActiveInterface(startPoint->encompassingComp()->name(), startPoint->name()));\r\n            interconnection->setStartInterface(startInterface);\r\n        }\r\n\r\n        if (endPoint->isHierarchical())\r\n        {\r\n            QSharedPointer<HierInterface> endInterface(new HierInterface(endPoint->name()));\r\n            interconnection->getHierInterfaces()->append(endInterface);\r\n        }\r\n        else\r\n        {\r\n            QSharedPointer<ActiveInterface> endInterface(\r\n                new ActiveInterface(endPoint->encompassingComp()->name(), endPoint->name()));\r\n            if (startPoint->isHierarchical())\r\n            {\r\n                interconnection->setStartInterface(endInterface);\r\n            }\r\n            else\r\n            {\r\n                interconnection->getActiveInterfaces()->append(endInterface);\r\n            }            \r\n        }\r\n\r\n        connection = new HWConnection(startPoint, endPoint, interconnection, route, this);  \r\n\r\n        auto connectionName = connection->createDefaultName();\r\n        connection->setName(connectionName);\r\n    }\r\n\r\n    // The code below ensures that the connection will be displayed \r\n    // with an off-page style after reloading the design\r\n    connection->getRouteExtension()->setOffpage(isOffPage);\r\n\r\n    return connection;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HWDesignDiagram::createConnection()\r\n//-----------------------------------------------------------------------------\r\nGraphicsConnection* HWDesignDiagram::createConnection(ConnectionEndpoint* startPoint, QPointF const& endPoint)\r\n{\r\n    if (startPoint->isAdHoc())\r\n    {\r\n        return new AdHocConnectionItem(startPoint->scenePos(), startPoint->getDirection(), endPoint,\r\n            QVector2D(0.0f, 0.0f), this);\r\n    }\r\n    else\r\n    {\r\n        return new HWConnection(startPoint->scenePos(), startPoint->getDirection(), endPoint,\r\n            QVector2D(0.0f, 0.0f), this);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HWDesignDiagram::createAddCommandForConnection()\r\n//-----------------------------------------------------------------------------\r\nQUndoCommand* HWDesignDiagram::createAddCommandForConnection(GraphicsConnection* connection, QUndoCommand* parentCommand /*= nullptr*/)\r\n{\r\n    if (auto const adhocConnection = dynamic_cast<AdHocConnectionItem*>(connection); adhocConnection)\r\n    {\r\n        return new AdHocConnectionAddCommand(this, adhocConnection, getDesign(), parentCommand);\r\n    }\r\n\r\n    if (auto const hwConnection = dynamic_cast<HWConnection*>(connection); hwConnection)\r\n    {\r\n        auto connectionCommand(new ConnectionAddCommand(this, hwConnection, getDesign(), parentCommand));\r\n\r\n        ConnectionEndpoint* startPoint = connection->endpoint1();\r\n        ConnectionEndpoint* endPoint = connection->endpoint2();\r\n\r\n        ConnectionEndpoint* definedPoint = nullptr;\r\n        ConnectionEndpoint* draftPoint = nullptr;\r\n        \r\n        if (!startPoint->isTypeLocked())\r\n        {\r\n            draftPoint = startPoint;\r\n        }\r\n        else\r\n        {\r\n            definedPoint = startPoint;\r\n        }\r\n\r\n        if (!endPoint->isTypeLocked())\r\n        {\r\n            draftPoint = endPoint;\r\n        }\r\n        else\r\n        {\r\n            definedPoint = endPoint;\r\n        }\r\n\r\n        if (definedPoint && draftPoint && draftPoint->isHierarchical())\r\n        {\r\n            if (!copyDefinitions(definedPoint, draftPoint, hwConnection, connectionCommand))\r\n            {\r\n                connectionCommand->undo();\r\n                return nullptr;\r\n            }\r\n\r\n            // Set correct name for interconnection, replacing old draft interface name\r\n            hwConnection->getInterconnection()->setName(hwConnection->createDefaultName());\r\n        }\r\n                        \r\n        return connectionCommand;\r\n    }\r\n\r\n    return nullptr;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HWDesignDiagram::copyDefinitions()\r\n//-----------------------------------------------------------------------------\r\nbool HWDesignDiagram::copyDefinitions(ConnectionEndpoint* definedPoint, ConnectionEndpoint* undefinedPoint,\r\n    HWConnection* definingConnection, QUndoCommand* parentCommand)\r\n{    \r\n    if (undefinedPoint->isHierarchical() && hasDefaultName(undefinedPoint))\r\n    {\r\n        copyInterfaceName(definedPoint, undefinedPoint, definingConnection, parentCommand);\r\n    }\r\n    \r\n    copyMode(definedPoint, undefinedPoint, parentCommand);\r\n\r\n    copyType(definedPoint, undefinedPoint, parentCommand);\r\n   \r\n    return copyPortsAndMapsForHierarchicalPoint(definedPoint, undefinedPoint, parentCommand);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HWDesignDiagram::hasDefaultName()\r\n//-----------------------------------------------------------------------------\r\nbool HWDesignDiagram::hasDefaultName(ConnectionEndpoint const* connectionPoint) const\r\n{\r\n    QRegularExpression defaultInterfaceName(\"bus(_\\\\d+)?\");\r\n    return defaultInterfaceName.match(connectionPoint->name()).hasMatch();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HWDesignDiagram::copyInterfaceName()\r\n//-----------------------------------------------------------------------------\r\nvoid HWDesignDiagram::copyInterfaceName(ConnectionEndpoint* sourceInterface,\r\n    ConnectionEndpoint* targetInterface, HWConnection* definingConnection, QUndoCommand* parentCommand)\r\n{\r\n    auto previousName = targetInterface->name();\r\n    \r\n    QStringList reservedNames = getTopLevelInterfaceNames();\r\n    auto interfaceName = generateUniqueName(sourceInterface->name(), reservedNames);\r\n       \r\n    QList<QSharedPointer<HierInterface> > affectedInterfaces = \r\n        findInterfacesByName(previousName, definingConnection->getInterconnection());\r\n\r\n    QUndoCommand* nameCommand = new EndpointNameChangeCommand(targetInterface, interfaceName, affectedInterfaces,\r\n        parentCommand);\r\n    nameCommand->redo();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HWDesignDiagram::findInterfacesByName()\r\n//-----------------------------------------------------------------------------\r\nQList<QSharedPointer<HierInterface> > HWDesignDiagram::findInterfacesByName(QString const& previousName,\r\n     QSharedPointer<Interconnection> connection) const\r\n{\r\n    QList<QSharedPointer<HierInterface> > foundInterfaces;\r\n\r\n    for (QSharedPointer<HierInterface> designInterface : *connection->getHierInterfaces())\r\n    {\r\n        if (designInterface->getBusReference().compare(previousName) == 0)\r\n        {\r\n            foundInterfaces.append(designInterface);\r\n        }\r\n    }\r\n\r\n    return foundInterfaces;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HWDesignDiagram::copyMode()\r\n//-----------------------------------------------------------------------------\r\nvoid HWDesignDiagram::copyMode(ConnectionEndpoint* sourceInterface, ConnectionEndpoint* targetInterface,\r\n    QUndoCommand* parentCommand)\r\n{\r\n    General::InterfaceMode selectedMode = targetInterface->getBusInterface()->getInterfaceMode();\r\n\r\n    if (selectedMode == General::INTERFACE_MODE_COUNT)\r\n    {\r\n        General::InterfaceMode sourceMode = sourceInterface->getBusInterface()->getInterfaceMode();\r\n\r\n        if (targetInterface->isHierarchical() || sourceInterface->isHierarchical())\r\n        {\r\n            selectedMode = sourceMode;\r\n        }\r\n        else\r\n        {\r\n            selectedMode = General::getCompatibleInterfaceMode(sourceMode);\r\n        }\r\n    }    \r\n\r\n    QUndoCommand* modeChangeCommand = new EndpointChangeCommand(targetInterface, selectedMode, parentCommand);\r\n    modeChangeCommand->redo();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HWDesignDiagram::copyType()\r\n//-----------------------------------------------------------------------------\r\nvoid HWDesignDiagram::copyType(ConnectionEndpoint* definedPoint, ConnectionEndpoint* draftPoint,\r\n    QUndoCommand* parentCommand)\r\n{\r\n    VLNV busVLNV = definedPoint->getBusInterface()->getBusType();\r\n\r\n    QString activeView = getActiveViewForEndPoint(definedPoint);\r\n\r\n    VLNV absVLNV;\r\n    if (definedPoint && definedPoint->getBusInterface() &&\r\n        definedPoint->getBusInterface()->getAbstractionContainingView(activeView))\r\n    {\r\n        QSharedPointer<AbstractionType> sourceAbstraction =\r\n            definedPoint->getBusInterface()->getAbstractionContainingView(activeView);\r\n        if (sourceAbstraction)\r\n        {\r\n            absVLNV = *sourceAbstraction->getAbstractionRef().data();\r\n        }\r\n    }\r\n\r\n    QUndoCommand* typeChangeCommand =\r\n        new EndPointTypesCommand(draftPoint, busVLNV, absVLNV, activeView, parentCommand);\r\n    typeChangeCommand->redo();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HWDesignDiagram::copyPortsAndMapsForHierarchicalPoint()\r\n//-----------------------------------------------------------------------------\r\nbool HWDesignDiagram::copyPortsAndMapsForHierarchicalPoint(ConnectionEndpoint* sourcePoint,\r\n    ConnectionEndpoint* targetPoint, QUndoCommand* parentCommand)\r\n{\r\n    QMessageBox msgBox(QMessageBox::Question, QCoreApplication::applicationName(),\r\n        tr(\"Do you want to auto-copy the port maps or perform a manual setup using the existing ports instead?\"),\r\n        QMessageBox::NoButton, getParent());\r\n\r\n    QPushButton* copyButton = msgBox.addButton(tr(\"Copy\"), QMessageBox::YesRole);\r\n    QPushButton* manualSetupButton = msgBox.addButton(tr(\"Manual Setup\"), QMessageBox::NoRole);\r\n    msgBox.addButton(tr(\"Cancel\"), QMessageBox::RejectRole);\r\n\r\n    targetPoint->setSelectionHighlight(true);\r\n    msgBox.exec();\r\n    targetPoint->setSelectionHighlight(false);\r\n    \r\n    bool setupDone = false;\r\n    if (msgBox.clickedButton() == copyButton)\r\n    {\r\n        copyPortMapsAndPhysicalPorts(sourcePoint->getOwnerComponent(), sourcePoint->getBusInterface(),\r\n            sourcePoint->encompassingComp(), targetPoint, parentCommand);\r\n        setupDone = true;\r\n    }\r\n    else if (msgBox.clickedButton() == manualSetupButton)\r\n    {\r\n        setupDone = createPortMapsManually(sourcePoint, targetPoint, parentCommand);\r\n    }\r\n\r\n    return setupDone;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusInterfaceItem::copyPortMapsAndPhysicalPorts()\r\n//-----------------------------------------------------------------------------\r\nvoid HWDesignDiagram::copyPortMapsAndPhysicalPorts(QSharedPointer<Component> sourceComponent,\r\n    QSharedPointer<BusInterface> sourceInterface, ComponentItem* sourceInstanceItem, ConnectionEndpoint* target,\r\n    QUndoCommand* parentCommand)\r\n{\r\n    QString sourceView;\r\n    if (!sourceInstanceItem)\r\n    {\r\n        sourceView = getTopView();\r\n    }\r\n    else\r\n    {\r\n        sourceView = getActiveViewOf(sourceInstanceItem);\r\n    }\r\n\r\n    QSharedPointer<AbstractionType> sourceAbstraction = sourceInterface->getAbstractionContainingView(sourceView);\r\n\r\n    if (!sourceAbstraction || (sourceAbstraction && !sourceAbstraction->getAbstractionRef()))\r\n    {\r\n       return;\r\n    }\r\n\r\n    VLNV abstractionVLNV = *sourceAbstraction->getAbstractionRef();\r\n    QSharedPointer<AbstractionDefinition const> absDef =\r\n        getLibraryInterface()->getModelReadOnly(abstractionVLNV).staticCast<AbstractionDefinition const>();\r\n\r\n    diagramResolver_->setContext(sourceComponent);\r\n\r\n    General::InterfaceMode mode = target->getBusInterface()->getInterfaceMode();\r\n    QStringList reservedNames = target->getOwnerComponent()->getPortNames();\r\n\r\n    auto copyCommand = new QUndoCommand(parentCommand);\r\n\r\n    QMap<QString, QString> nameTranslations;\r\n    QList< QSharedPointer<PortMap> > newPortMaps;   \r\n    for (QSharedPointer<PortMap> portMap : *sourceAbstraction->getPortMaps())\r\n    {\r\n        if (portMap->getPhysicalPort() && portMap->getLogicalPort())\r\n        {\r\n            QString logicalName = portMap->getLogicalPort()->name_;\r\n            QString physicalName = portMap->getPhysicalPort()->name_;\r\n\r\n            if (!nameTranslations.contains(physicalName) && sourceComponent->hasPort(physicalName))\r\n            { \r\n                QSharedPointer<Port> sourcePort = sourceComponent->getPort(physicalName);\r\n\r\n                DirectionTypes::Direction directionOverride = sourcePort->getDirection();\r\n                if (absDef && absDef->hasPort(logicalName, mode))\r\n                { \r\n                    directionOverride = absDef->getPortDirection(logicalName, mode, target->getBusInterface()->getSystem());\r\n                }\r\n\r\n                QSharedPointer<Port> clonePort = createConnectingPhysicalPort(sourcePort, directionOverride, reservedNames);\r\n                nameTranslations.insert(physicalName, clonePort->name());\r\n\r\n                QUndoCommand* portCopyCommand = new AddPhysicalPortCommand(target->getOwnerComponent(), clonePort, copyCommand);\r\n                portCopyCommand->redo();\r\n            }\r\n\r\n            QSharedPointer<PortMap> cloneMap(new PortMap(*portMap));\r\n            cloneMap->getPhysicalPort()->name_ = nameTranslations.value(physicalName);   \r\n\r\n            if (QSharedPointer<PartSelect> clonePart = cloneMap->getPhysicalPort()->partSelect_; \r\n                clonePart)\r\n            {\r\n                clonePart->setLeftRange(diagramResolver_->parseToConstant(clonePart->getLeftRange()));\r\n                clonePart->setRightRange(diagramResolver_->parseToConstant(clonePart->getRightRange()));\r\n            }\r\n            \r\n            if (QSharedPointer<Range> logicalRange = cloneMap->getLogicalPort()->range_; \r\n                logicalRange)\r\n            {\r\n                logicalRange->setLeft(diagramResolver_->parseToConstant(logicalRange->getLeft()));\r\n                logicalRange->setRight(diagramResolver_->parseToConstant(logicalRange->getRight()));\r\n            }\r\n\r\n            cloneMap->setLogicalTieOff(diagramResolver_->parseToConstant(portMap->getLogicalTieOff()));\r\n\r\n            newPortMaps.append(cloneMap);\r\n        }\r\n    }\r\n\r\n    QUndoCommand* portMapCreationCommand = new EndPointPortMapCommand(target, newPortMaps, getEditedComponent(), copyCommand);\r\n    portMapCreationCommand->redo();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HWDesignDiagram::createConnectingPhysicalPort()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<Port> HWDesignDiagram::createConnectingPhysicalPort(QSharedPointer<Port> sourcePort, \r\n    DirectionTypes::Direction portDirection, QStringList const& reservedNames)\r\n{\r\n    QSharedPointer<Port> connectingPort(new Port(*sourcePort));\r\n\r\n    QString newPortName = sourcePort->name();\r\n    QRegularExpression directionalEnd(QStringLiteral(\"_((i)|(in)|(o)|(out)|(inout))$\"));\r\n    if (sourcePort->getDirection() != portDirection && directionalEnd.match(newPortName).hasMatch())\r\n    {\r\n        newPortName.remove(directionalEnd);\r\n        newPortName.append('_');\r\n        newPortName.append(DirectionTypes::direction2Str(portDirection));\r\n    }\r\n\r\n    newPortName = generateUniqueName(newPortName, reservedNames);\r\n    connectingPort->setName(newPortName);\r\n\r\n    connectingPort->setDirection(portDirection);\r\n\r\n    connectingPort->setLeftBound(diagramResolver_->parseToConstant(sourcePort->getLeftBound()));\r\n    connectingPort->setRightBound(diagramResolver_->parseToConstant(sourcePort->getRightBound()));\r\n\r\n    connectingPort->setDefaultValue(diagramResolver_->parseToConstant(sourcePort->getDefaultValue()));\r\n\r\n    connectingPort->setArrayLeft(diagramResolver_->parseToConstant(sourcePort->getArrayLeft()));\r\n    connectingPort->setArrayRight(diagramResolver_->parseToConstant(sourcePort->getArrayRight()));\r\n\r\n    return connectingPort;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HWDesignDiagram::createPortMapsManually()\r\n//-----------------------------------------------------------------------------\r\nbool HWDesignDiagram::createPortMapsManually(ConnectionEndpoint* sourcePoint, ConnectionEndpoint* targetPoint,\r\n    QUndoCommand* parentCommand)\r\n{\r\n    PortmapDialog dialog(getLibraryInterface(), targetPoint->getOwnerComponent(), \r\n        targetPoint->getBusInterface(), sourcePoint->getBusInterface(), getParent());\r\n\r\n    if (dialog.exec() != QDialog::Accepted)\r\n    {\r\n        return false;\r\n    }\r\n\r\n    QList<QSharedPointer<PortMap> > newMaps = *targetPoint->getBusInterface()->getAllPortMaps();\r\n    targetPoint->getBusInterface()->clearAllPortMaps(); // clear temprorary portmaps so that undo works\r\n\r\n    new EndPointPortMapCommand(targetPoint, newMaps, getEditedComponent(), parentCommand);\r\n    return true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HWDesignDiagram::addTopLevelInterface()\r\n//-----------------------------------------------------------------------------\r\nvoid HWDesignDiagram::addTopLevelInterface(GraphicsColumn* column, QPointF const& pos, bool isDraft)\r\n{\r\n    QStringList reservedNames = getTopLevelInterfaceNames();\r\n    QString draftInterfaceName = generateUniqueName(\"bus\", reservedNames);\r\n\r\n    QSharedPointer<BusInterface> busif(new BusInterface());\r\n    busif->setName(draftInterfaceName);\r\n\r\n    QPointF newPosition = snapPointToGrid(pos);\r\n\r\n    QSharedPointer<InterfaceGraphicsData> dataGroup(new InterfaceGraphicsData(busif->name()));\r\n    dataGroup->setPosition(newPosition);\r\n    getDesign()->getVendorExtensions()->append(dataGroup);\r\n\r\n    auto newItem = new HierarchicalBusInterfaceItem(getEditedComponent(), busif, dataGroup, getLibraryInterface(), 0,isDraft);\r\n    newItem->setPos(newPosition);\r\n\r\n    // Save the positions of the other diagram interfaces.\r\n    QMap<HierarchicalBusInterfaceItem*, QPointF> oldPositions;\r\n\r\n    if (column->getContentType() == ColumnTypes::IO)\r\n    {\r\n        for (QGraphicsItem* item : column->childItems())\r\n        {\r\n            if (item->type() == HierarchicalBusInterfaceItem::Type)\r\n            {\r\n                auto interface = static_cast<HierarchicalBusInterfaceItem*>(item);\r\n                oldPositions.insert(interface, interface->scenePos());\r\n            }\r\n        }\r\n    }\r\n\r\n    QSharedPointer<QUndoCommand> cmd(new ItemAddCommand(column, newItem, this));\r\n    cmd->redo();\r\n\r\n    // Determine if the other interfaces changed their position and create undo commands for them.\r\n    if (column->getContentType() == ColumnTypes::IO)\r\n    {\r\n        for (auto cur = oldPositions.cbegin(); cur != oldPositions.cend(); ++cur)\r\n        {\r\n            if (cur.key()->scenePos() != cur.value())\r\n            {\r\n                new ItemMoveCommand(cur.key(), cur.value(), column, this, cmd.data());\r\n            }\r\n        }\r\n    }\r\n\r\n    getEditProvider()->addCommand(cmd);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HWDesignDiagram::draftAt()\r\n//-----------------------------------------------------------------------------\r\nvoid HWDesignDiagram::draftAt(QPointF const& clickedPosition)\r\n{\r\n    // Find the bottom-most item under the cursor.\r\n    QList<QGraphicsItem*> itemList = items(clickedPosition);\r\n    QGraphicsItem* clickedItem = nullptr;\r\n    if (!itemList.empty())\r\n    {\r\n        clickedItem = itemList.back();\r\n    }\r\n\r\n    // If there was no item, then the new item should be added to the column under cursor.\r\n    if (clickedItem == nullptr)\r\n    {\r\n        GraphicsColumn* column = getLayout()->findColumnAt(clickedPosition);\r\n\r\n        if (column != nullptr)\r\n        {\r\n            // Check what kind of item should be created.\r\n            if (unsigned int itemType = findColumnItemType(column); \r\n                itemType == ColumnTypes::INTERFACE)\r\n            {\r\n                addTopLevelInterface(column, clickedPosition, true);\r\n            }\r\n            else if (itemType != ColumnTypes::NONE)\r\n            {\r\n                addDraftComponentInstance(column, clickedPosition);\r\n            }\r\n        }\r\n    }\r\n    // Otherwise check if the item is an unpackaged component in which case\r\n    // we can add a new port (bus interface) to it.\r\n    else if (clickedItem->type() == HWComponentItem::Type)\r\n    {\r\n        auto component = static_cast<HWComponentItem*>(clickedItem);\r\n        addDraftComponentInterface(component, clickedPosition);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HWDesignDiagram::findItemTypeForColumn()\r\n//-----------------------------------------------------------------------------\r\nunsigned int HWDesignDiagram::findColumnItemType(GraphicsColumn* column) const\r\n{\r\n    unsigned int itemType = column->getColumnDesc()->getAllowedItems();\r\n\r\n    // Check if the item type is ambiguous (interface vs. the rest of the types).\r\n    if (itemType != ColumnTypes::INTERFACE && itemType & ColumnTypes::INTERFACE)\r\n    {\r\n        // Open a dialog to determine which type of item to create.\r\n        SelectItemTypeDialog dialog(column->getColumnDesc()->getAllowedItems(), getParent());\r\n\r\n        if (dialog.exec() == QDialog::Accepted)\r\n        {\r\n            itemType = dialog.getSelectedItemType();\r\n        }\r\n        else\r\n        {\r\n            itemType = ColumnTypes::NONE;\r\n        }\r\n    }\r\n\r\n    return itemType;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HWDesignDiagram::createDraftInnstance()\r\n//-----------------------------------------------------------------------------\r\nvoid HWDesignDiagram::addDraftComponentInstance(GraphicsColumn* column, QPointF const& position)\r\n{\r\n    // Determine an unused name for the component instance.\r\n    QString name = createInstanceName(\"instance\");\r\n\r\n    // Create a component model without a valid vlnv.\r\n    auto comp = QSharedPointer<Component>(new Component(VLNV(), getEditedComponent()->getRevision()));\r\n    comp->setImplementation(getEditedComponent()->getImplementation());\r\n\r\n    // Create the corresponding diagram component.\r\n    QSharedPointer<ComponentInstance> componentInstance(new ComponentInstance());\r\n    componentInstance->setInstanceName(name);\r\n\r\n    auto diagComp = new HWComponentItem(getLibraryInterface(), componentInstance, comp, column);\r\n    diagComp->setDraft();\r\n    diagComp->setPos(snapPointToGrid(position));\r\n\r\n    QSharedPointer<HWComponentAddCommand> addCommand(new HWComponentAddCommand(this, column, diagComp));\r\n\r\n    connect(addCommand.data(), SIGNAL(componentInstantiated(ComponentItem*)),\r\n        this, SIGNAL(componentInstantiated(ComponentItem*)), Qt::UniqueConnection);\r\n    connect(addCommand.data(), SIGNAL(componentInstanceRemoved(ComponentItem*)),\r\n        this, SIGNAL(componentInstanceRemoved(ComponentItem*)), Qt::UniqueConnection);\r\n\r\n    getEditProvider()->addCommand(addCommand);\r\n    addCommand->redo();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HWDesignDiagram::addDraftInterface()\r\n//-----------------------------------------------------------------------------\r\nvoid HWDesignDiagram::addDraftComponentInterface(HWComponentItem* targetComponent, QPointF const& position)\r\n{\r\n    // The component is unpackaged if it has an invalid vlnv.\r\n    if (!targetComponent->componentModel()->getVlnv().isValid())\r\n    {\r\n        QMap<ActiveBusInterfaceItem*, QPointF> oldPositions;\r\n\r\n        // Save old port positions.\r\n        for (QGraphicsItem* item : targetComponent->childItems())\r\n        {\r\n            if (item->type() == ActiveBusInterfaceItem::Type)\r\n            {\r\n                auto port = static_cast<ActiveBusInterfaceItem*>(item);\r\n                oldPositions.insert(port, port->pos());\r\n            }\r\n        }\r\n\r\n        QSharedPointer<QUndoCommand> cmd(new PortAddCommand(targetComponent, snapPointToGrid(position), this));\r\n        cmd->redo();\r\n\r\n        // Create child undo commands for the ports with changed position.\r\n        for (auto current = oldPositions.cbegin(); current != oldPositions.cend(); ++current)\r\n        {\r\n            if (current.key()->pos() != current.value())\r\n            {\r\n                new PortMoveCommand(current.key(), current.value(), this, cmd.data());\r\n            }\r\n        }\r\n\r\n        // Add the command to the edit stack.\r\n        getEditProvider()->addCommand(cmd);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HWDesignDiagram::replace()\r\n//-----------------------------------------------------------------------------\r\nvoid HWDesignDiagram::replace(ComponentItem* destComp, ComponentItem* sourceComp)\r\n{\r\n    HWComponentItem* destHWComponent = qgraphicsitem_cast<HWComponentItem*>(destComp);\r\n    HWComponentItem* sourceHWComponent = qgraphicsitem_cast<HWComponentItem*>(sourceComp);\r\n\r\n    if (destHWComponent && sourceHWComponent)\r\n    {\r\n        QSharedPointer<ReplaceComponentCommand> cmd(\r\n            new ReplaceComponentCommand(destHWComponent, sourceHWComponent, this));\r\n\r\n        connect(cmd.data(), SIGNAL(componentInstantiated(ComponentItem*)),\r\n            this, SIGNAL(componentInstantiated(ComponentItem*)), Qt::UniqueConnection);\r\n        connect(cmd.data(), SIGNAL(componentInstanceRemoved(ComponentItem*)),\r\n            this, SIGNAL(componentInstanceRemoved(ComponentItem*)), Qt::UniqueConnection);\r\n\r\n        getEditProvider()->addCommand(cmd);\r\n        cmd->redo();\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HWDesignDiagram::createComponentItem()\r\n//-----------------------------------------------------------------------------\r\nvoid HWDesignDiagram::createComponentItem(QSharedPointer<ComponentInstance> instance, QSharedPointer<Design> design)\r\n{\r\n    QSharedPointer<Component> component;\r\n\r\n    if (!instance->isDraft())\r\n    {\r\n        component = getLibraryInterface()->getModel<Component>(*instance->getComponentRef());\r\n\r\n        if (!component && instance->getComponentRef()->isValid())\r\n        {\r\n            emit errorMessage(tr(\"Component %1 instantiated within design %2 was not found in the library\").arg(\r\n                instance->getComponentRef()->getName(), design->getVlnv().getName()));\r\n        }           \r\n    }\r\n\r\n    if(!component)\r\n    {\r\n        // Create an unpackaged component so that we can still visualize the component instance.\r\n        component = QSharedPointer<Component>(new Component(*instance->getComponentRef(), getEditedComponent()->getRevision()));\r\n        component->setImplementation(KactusAttribute::HW);\r\n    }\r\n    \r\n    auto item = new HWComponentItem(getLibraryInterface(), instance, component);\r\n\r\n    // Check if the position is not found.\r\n    // Migrate from the old layout to the column based layout.\r\n    \r\n    if (QPointF instancePosition = instance->getPosition(); \r\n        instancePosition.isNull())\r\n    {\r\n        getLayout()->addItem(item);\r\n    }\r\n    else\r\n    {\r\n        GraphicsColumn* column = getLayout()->findColumnAt(instancePosition);\r\n        if (column != nullptr && column->isItemAllowed(item))\r\n        {\r\n            column->addItem(item, true);\r\n        }\r\n        else\r\n        {\r\n            getLayout()->addItem(item);\r\n        }\r\n    }\r\n\r\n    onComponentInstanceAdded(item);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HWDesignDiagram::createComponentItem()\r\n//-----------------------------------------------------------------------------\r\nHWComponentItem* HWDesignDiagram::createComponentItem(QSharedPointer<Component> comp, QString const& instanceName,\r\n    QPointF position, QUndoCommand* parentCommand)\r\n{\r\n    if (GraphicsColumn* column = getLayout()->findColumnAt(snapPointToGrid(position)); \r\n        column != nullptr)\r\n    {\r\n        if (!referenceFinderContainsComponent(comp))\r\n        {\r\n            QSharedPointer<ComponentParameterFinder> componentFinder(new ComponentParameterFinder(comp));\r\n            designAndInstancesParameterFinder_->addFinder(componentFinder);\r\n        }\r\n\r\n        // Create the diagram component.                            \r\n        QSharedPointer<ComponentInstance> componentInstance(new ComponentInstance());\r\n        componentInstance->setComponentRef(QSharedPointer<ConfigurableVLNVReference>(\r\n            new ConfigurableVLNVReference(comp->getVlnv())));\r\n\r\n        componentInstance->setInstanceName(instanceName);\r\n\r\n        auto newItem = new HWComponentItem(getLibraryInterface(), componentInstance, comp);\r\n        newItem->setPos(snapPointToGrid(position));\r\n\r\n        auto addCommand(new HWComponentAddCommand(this, column, newItem, parentCommand));\r\n\r\n        connect(addCommand, SIGNAL(componentInstantiated(ComponentItem*)),\r\n            this, SIGNAL(componentInstantiated(ComponentItem*)), Qt::UniqueConnection);\r\n        connect(addCommand, SIGNAL(componentInstanceRemoved(ComponentItem*)),\r\n            this, SIGNAL(componentInstanceRemoved(ComponentItem*)), Qt::UniqueConnection);\r\n\r\n        addCommand->redo();\r\n\r\n        return newItem;\r\n    }\r\n\r\n    return nullptr;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HWDesignDiagram::referenceFinderContainsComponent()\r\n//-----------------------------------------------------------------------------\r\nbool HWDesignDiagram::referenceFinderContainsComponent(QSharedPointer<Component> component)\r\n{\r\n    for (QSharedPointer<ComponentInstance> instance : *getDesign()->getComponentInstances())\r\n    {\r\n        if (instance->getComponentRef())\r\n        {\r\n            QSharedPointer<Document> componentDocument =\r\n                getLibraryInterface()->getModel(*instance->getComponentRef().data());\r\n            if (componentDocument)\r\n            {\r\n                QSharedPointer<Component> instancedComponent = componentDocument.dynamicCast<Component>();\r\n                if (instancedComponent && instancedComponent->getVlnv() == component->getVlnv())\r\n                {\r\n                    return true;\r\n                }\r\n            }\r\n        }\r\n    }\r\n\r\n    return false;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HWDesignDiagram::createInterconnection()\r\n//-----------------------------------------------------------------------------\r\nvoid HWDesignDiagram::createInterconnection(QSharedPointer<Interconnection> interconnection,\r\n    QSharedPointer<Design> design)\r\n{\r\n    if (!interconnection->getHierInterfaces()->isEmpty())\r\n    {\r\n        createHierarchicalConnection(interconnection, design);\r\n    }\r\n    \r\n    if (!interconnection->getActiveInterfaces()->isEmpty())\r\n    {\r\n        createInterconnectionBetweenComponents(interconnection, design);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HWDesignDiagram::createInterconnectionBetweenComponents()\r\n//-----------------------------------------------------------------------------\r\nvoid HWDesignDiagram::createInterconnectionBetweenComponents(QSharedPointer<Interconnection> interconnection,\r\n    QSharedPointer<Design> design)\r\n{\r\n    QSharedPointer<ActiveInterface> startInterface = interconnection->getStartInterface();\r\n    QString startComponentRef = startInterface->getComponentReference();\r\n    HWComponentItem* startComponent = getComponentItem(startComponentRef);\r\n    if (!startComponent)\r\n    {\r\n        emit errorMessage(tr(\"Component %1 was not found in the design\").arg(startComponentRef));\r\n        return;\r\n    }\r\n\r\n    QSharedPointer<ActiveInterface> endInterface = interconnection->getActiveInterfaces()->first();\r\n    QString endComponentRef = endInterface->getComponentReference();\r\n    HWComponentItem* endComponent = getComponentItem(endComponentRef);\r\n    if (!endComponent)\r\n    {\r\n        emit errorMessage(tr(\"Component %1 was not found in the design\").arg(endComponentRef));\r\n        return;\r\n    }\r\n\r\n    // Find the referenced ports.\r\n    ConnectionEndpoint* startPort = findOrCreateMissingInterface(startComponent, \r\n        startInterface->getComponentReference(), startInterface->getBusReference(), design);\r\n    ConnectionEndpoint* endPort = findOrCreateMissingInterface(endComponent, \r\n        endComponentRef, endInterface->getBusReference(), design);\r\n\r\n    QSharedPointer<ConnectionRoute> route = findOrCreateRouteForInterconnection(interconnection->name());\r\n\r\n    if (route->isOffpage())\r\n    {\r\n        startPort = startPort->getOffPageConnector();\r\n        endPort = endPort->getOffPageConnector();\r\n    }\r\n\r\n    auto connectionItem = new HWConnection(startPort, endPort, interconnection, route, this);\r\n    addItem(connectionItem);\r\n\r\n    startPort->onConnect(endPort);\r\n    endPort->onConnect(startPort);\r\n\r\n    connectionItem->validate();\r\n\r\n    startPort->addConnection(connectionItem);\r\n    endPort->addConnection(connectionItem);\r\n\r\n    if (route->isOffpage())\r\n    {\r\n        connectionItem->hide();\r\n    }\r\n\r\n    connectionItem->updatePosition();\r\n\r\n    connect(connectionItem, SIGNAL(errorMessage(QString const&)), this, SIGNAL(errorMessage(QString const&)));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HWDesignDiagram::findOrCreateRouteForInterconnection()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<ConnectionRoute> HWDesignDiagram::findOrCreateRouteForInterconnection(QString const& interconnectionName)\r\n{\r\n    for (QSharedPointer<ConnectionRoute> knownRoute : getDesign()->getRoutes())\r\n    {\r\n        if (knownRoute->name() == interconnectionName)\r\n        {\r\n            return knownRoute;\r\n        }\r\n    }\r\n\r\n    QSharedPointer<ConnectionRoute> route(new ConnectionRoute(interconnectionName));\r\n    getDesign()->addRoute(route);\r\n    return route;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HWDesignDiagram::findOrCreateMissingInterface()\r\n//-----------------------------------------------------------------------------\r\nConnectionEndpoint* HWDesignDiagram::findOrCreateMissingInterface(HWComponentItem* componentItem, \r\n    QString const& componentRef, QString const& busRef, QSharedPointer<Design> design)\r\n{\r\n    ConnectionEndpoint* interfaceItem = componentItem->getBusPort(busRef);\r\n\r\n    if (!interfaceItem)\r\n    {\r\n        emit errorMessage(tr(\"Bus interface %1 was not found in the component %2\").arg(busRef, componentRef));\r\n        interfaceItem = createMissingBusInterface(busRef, componentItem, design);\r\n    }\t\r\n\r\n    return interfaceItem;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HWDesignDiagram::createMissingBusInterface()\r\n//-----------------------------------------------------------------------------\r\nActiveBusInterfaceItem* HWDesignDiagram::createMissingBusInterface(QString const& interfaceName,\r\n    HWComponentItem* containingComponent, QSharedPointer<Design> design)\r\n{\r\n    QSharedPointer<BusInterface> busIf(new BusInterface());\r\n    busIf->setName(interfaceName);\r\n\r\n    auto missingInterface = new ActiveBusInterfaceItem(busIf, getLibraryInterface(), containingComponent);\r\n    missingInterface->setTemporary(true);\r\n    containingComponent->addPort(missingInterface);\r\n\r\n    for (QSharedPointer<ComponentInstance> instance : *design->getComponentInstances())\r\n    {\r\n        if (instance->getInstanceName() == containingComponent->name())\r\n        {\r\n            missingInterface->setPos(instance->getBusInterfacePositions().value(interfaceName));\r\n            containingComponent->onMovePort(missingInterface);\r\n            return missingInterface;\r\n        }\r\n    }\r\n\r\n    return missingInterface;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HWDesignDiagram::createHierarchicalConnection()\r\n//-----------------------------------------------------------------------------\r\nvoid HWDesignDiagram::createHierarchicalConnection(QSharedPointer<Interconnection> connection,\r\n    QSharedPointer<Design> design)\r\n{\r\n    QSharedPointer<ActiveInterface> startInterface = connection->getStartInterface();\r\n\r\n    QString startComponentRef = startInterface->getComponentReference();\r\n    \r\n    if (auto startComponent = getComponentItem(startComponentRef); \r\n        !startComponent)\r\n    {\r\n        emit errorMessage(tr(\"Component %1 was not found in the design\").arg(startComponentRef));\r\n        return;\r\n    }\r\n\r\n    QSharedPointer<HierInterface> hierInterface = connection->getHierInterfaces()->first();\r\n    ConnectionEndpoint* hierarchicalInterface = findOrCreateHierarchicalInterface(hierInterface->getBusReference());\r\n    Q_ASSERT(hierarchicalInterface != nullptr);\r\n\r\n    // Check if the interface item is already assigned to a column.\r\n    \r\n    if (GraphicsColumn* column = getLayout()->findColumnAt(hierarchicalInterface->scenePos()); \r\n        column != nullptr)\r\n    {\r\n        column->addItem(hierarchicalInterface);\r\n    }\r\n    else\r\n    {\r\n        getLayout()->addItem(hierarchicalInterface);\r\n    }\r\n\r\n    // Find the component where the hierarchical connection is connected.\r\n    HWComponentItem *comp = getComponentItem(startInterface->getComponentReference());\r\n    if (!comp)\r\n    {\r\n        emit errorMessage(tr(\"Component %1 was not found in the top-design\").arg(\r\n            startInterface->getComponentReference()));\r\n        return;\r\n    }\r\n\r\n    // Find the port of the component.\r\n    ConnectionEndpoint* componentPort = findOrCreateMissingInterface(comp, startInterface->getComponentReference(), \r\n        startInterface->getBusReference(), design);\r\n    \r\n    QSharedPointer<ConnectionRoute> route = findOrCreateRouteForInterconnection(connection->name());\r\n\r\n    if (route->isOffpage())\r\n    {\r\n        componentPort = componentPort->getOffPageConnector();\r\n        hierarchicalInterface = hierarchicalInterface->getOffPageConnector();\r\n    }\r\n  \r\n    auto connectionItem = new HWConnection(componentPort, hierarchicalInterface, connection, route, this);\r\n    if (route->isOffpage())\r\n    {\r\n        connectionItem->hide();\r\n    }\r\n\r\n    componentPort->onConnect(hierarchicalInterface);\r\n    hierarchicalInterface->onConnect(componentPort);\r\n\r\n    connectionItem->validate();\r\n\r\n    componentPort->addConnection(connectionItem);\r\n    hierarchicalInterface->addConnection(connectionItem);\r\n\r\n    connect(connectionItem, SIGNAL(errorMessage(QString const&)), this, SIGNAL(errorMessage(QString const&)));\r\n\r\n    addItem(connectionItem);\r\n    connectionItem->updatePosition();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HWDesignDiagram::findOrCreateHierarchicalInterface()\r\n//-----------------------------------------------------------------------------\r\nConnectionEndpoint* HWDesignDiagram::findOrCreateHierarchicalInterface(QString const& busRef)\r\n{\r\n    // if the bus interface was not found\r\n    if (QSharedPointer<BusInterface> busIf = getEditedComponent()->getBusInterface(busRef); \r\n        busIf != nullptr)\r\n    {\r\n        // Find the corresponding diagram interface.\r\n        for (QGraphicsItem* item : items())\r\n        {\r\n            if (item->type() == HierarchicalBusInterfaceItem::Type &&\r\n                qgraphicsitem_cast<HierarchicalBusInterfaceItem*>(item)->getBusInterface() == busIf)\r\n            {\r\n                return qgraphicsitem_cast<HierarchicalBusInterfaceItem*>(item);\r\n            }\r\n        }\r\n    }\r\n    else\r\n    {\t\t\t\r\n        emit errorMessage(tr(\"Bus interface %1 was not found in the top-component\").arg(busRef));\r\n\r\n        // Create a dummy interface which is marked as invalid.\r\n        busIf = QSharedPointer<BusInterface>(new BusInterface());\r\n        busIf->setName(busRef);\r\n\r\n        // Check if there already is data for interface with this name (interface was deleted or renamed)\r\n        auto designInterfaceGraphicsData = getDesign()->getInterfaceGraphicsData();\r\n        auto interfaceGraphicsDataIter = std::find_if(designInterfaceGraphicsData.cbegin(), designInterfaceGraphicsData.cend(),\r\n            [&busIf](QSharedPointer<InterfaceGraphicsData> graphicsData)\r\n            {\r\n                return graphicsData->getName() == busIf->name();\r\n            });\r\n\r\n        QSharedPointer<InterfaceGraphicsData> dataGroup;\r\n        if (interfaceGraphicsDataIter != designInterfaceGraphicsData.cend())\r\n        {\r\n            dataGroup = *interfaceGraphicsDataIter;\r\n        }\r\n        else\r\n        {\r\n            dataGroup = QSharedPointer<InterfaceGraphicsData>(new InterfaceGraphicsData(busIf->name()));\r\n            getDesign()->getVendorExtensions()->append(dataGroup);\r\n        }\r\n\r\n        auto hierarchicalInterface = new HierarchicalBusInterfaceItem(getEditedComponent(), busIf, dataGroup, nullptr);\r\n        hierarchicalInterface->setTemporary(true);\r\n        hierarchicalInterface->updateInterface();\r\n\r\n        return hierarchicalInterface;\r\n    }\r\n\r\n    return nullptr;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HWDesignDiagram::createHierachicalAdHocPorts()\r\n//-----------------------------------------------------------------------------\r\nvoid HWDesignDiagram::createHierachicalAdHocPorts(QSharedPointer<Design> design)\r\n{\r\n    QSharedPointer<VendorExtension> adHocPortPositions = design->getAdHocPortPositions();\r\n    QSharedPointer<Kactus2Group> adhocGroup = adHocPortPositions.dynamicCast<Kactus2Group>();\r\n\r\n    QStringList visiblePortNames;\r\n\r\n    if (adhocGroup.isNull())\r\n\t{\r\n\t\tadhocGroup = QSharedPointer<Kactus2Group>(new Kactus2Group(\"kactus2:adHocVisibilities\"));\r\n\t\tdesign->getVendorExtensions()->append(adhocGroup);\r\n\t}\r\n\r\n    for (QSharedPointer<VendorExtension> positionExtension : adhocGroup->getByType(\"kactus2:adHocVisible\"))\r\n    {\r\n        QSharedPointer<Kactus2Placeholder> adHocExtension = positionExtension.dynamicCast<Kactus2Placeholder>();\r\n        QString portName = adHocExtension->getAttributeValue(\"portName\");\r\n\r\n        QSharedPointer<Port> adHocPort = getEditedComponent()->getPort(portName);\r\n\r\n        HierarchicalPortItem* adHocIf;\r\n\r\n        if (adHocPort)\r\n        {\r\n            adHocIf = new HierarchicalPortItem(getEditedComponent(), adHocPort, adHocExtension, 0);\r\n            visiblePortNames.append(portName);\r\n        }\r\n        else\r\n        {\r\n            adHocIf = createMissingHierarchicalAdHocPort(portName, adHocExtension, 0);\r\n        }\r\n\r\n        // Add the ad-hoc interface to the first column where it is allowed to be placed.\r\n        GraphicsColumn* column = getLayout()->findColumnAt(adHocIf->scenePos());\r\n        if (column != nullptr && column->isItemAllowed(adHocIf))\r\n        {\r\n            column->addItem(adHocIf, true);\r\n        }\r\n        else\r\n        {\r\n            getLayout()->addItem(adHocIf);\r\n        }\r\n    }\r\n\r\n    for (QSharedPointer<Port> adhocPort : *getEditedComponent()->getPorts())\r\n    {\r\n        if (adhocPort->isAdHocVisible() && !visiblePortNames.contains(adhocPort->name()))\r\n        {\r\n            QSharedPointer<Kactus2Placeholder> positionPlaceHolder(new Kactus2Placeholder(\"kactus2:adHocVisible\"));\r\n            positionPlaceHolder->setAttribute(\"portName\", adhocPort->name());\r\n\r\n            adhocGroup->addToGroup(positionPlaceHolder);\r\n\r\n            auto adhocInterface(new HierarchicalPortItem(getEditedComponent(), adhocPort, positionPlaceHolder, nullptr));\r\n\r\n            getLayout()->addItem(adhocInterface);\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HWDesignDiagram::createMissingHierarchicalAdHocPort()\r\n//-----------------------------------------------------------------------------\r\nHierarchicalPortItem* HWDesignDiagram::createMissingHierarchicalAdHocPort(QString const& portName,\r\n    QSharedPointer<Kactus2Placeholder> adHocExtension, QGraphicsItem* parentItem)\r\n{\r\n    QSharedPointer<Port> missingPort (new Port());\r\n    missingPort->setName(portName);\r\n\r\n    auto missingInterface = new HierarchicalPortItem(getEditedComponent(), missingPort, adHocExtension, parentItem);\r\n\r\n    return missingInterface;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HWDesignDiagram::createAdHocConnection()\r\n//-----------------------------------------------------------------------------\r\nvoid HWDesignDiagram::createAdHocConnection(QSharedPointer<AdHocConnection> adHocConnection)\r\n{\r\n    if (!adHocConnection->getTiedValue().isEmpty())\r\n    {\r\n        createAdHocTieOffConnection(adHocConnection);\r\n        return;\r\n    }\r\n\r\n    // Convert one-to-many internal connections to one-to-one connections.\r\n    if (adHocConnection->getExternalPortReferences()->isEmpty() &&\r\n        !adHocConnection->getInternalPortReferences()->isEmpty())\r\n    {\r\n        QSharedPointer<PortReference> primaryPort = adHocConnection->getInternalPortReferences()->at(0);\r\n\r\n\r\n        HWConnectionEndpoint* primaryPortItem = findAdhocPort(primaryPort);        \r\n\r\n        if (primaryPortItem == nullptr)\r\n        {\r\n            return;\r\n        }\r\n\r\n        if (adHocConnection->isOffPage())\r\n        {\r\n            primaryPortItem = static_cast<HWConnectionEndpoint*>(primaryPortItem->getOffPageConnector());\r\n        }\r\n\r\n        for (int i = 1; i < adHocConnection->getInternalPortReferences()->size(); ++i)\r\n        {\r\n            QSharedPointer<PortReference> secondaryPort = adHocConnection->getInternalPortReferences()->at(i);\r\n            createConnectionForAdHocPorts(adHocConnection, secondaryPort, primaryPortItem);\r\n        }    \r\n    }\r\n\r\n    const int EXTERNAL_PORT_COUNT = adHocConnection->getExternalPortReferences()->count();\r\n    for (int i = 0; i < EXTERNAL_PORT_COUNT; i++)\r\n    {\r\n        QSharedPointer<PortReference> externalPort = adHocConnection->getExternalPortReferences()->at(i);\r\n\r\n        if (!getEditedComponent()->hasPort(externalPort->getPortRef()))\r\n        {\r\n            emit errorMessage(tr(\"Port %1 was not found in the top-level component\").arg(\r\n                externalPort->getPortRef()));\r\n        }\r\n\r\n        setPortAdHocVisible(externalPort->getPortRef(), true);\r\n        ConnectionEndpoint* topPortItem = getDiagramAdHocPort(externalPort->getPortRef());\r\n\r\n        for (int j = i + 1; j < EXTERNAL_PORT_COUNT; j++)\r\n        {\r\n            QSharedPointer<PortReference> connectedExternalPort = \r\n                adHocConnection->getExternalPortReferences()->at(j);\r\n            createConnectionForAdHocPorts(adHocConnection, connectedExternalPort, topPortItem);\r\n        }\r\n\r\n        for (QSharedPointer<PortReference> internalPort : *adHocConnection->getInternalPortReferences())\r\n        {\r\n            createConnectionForAdHocPorts(adHocConnection, internalPort, topPortItem);\r\n        }\r\n\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HWDesignDiagram::findAdhocPort()\r\n//-----------------------------------------------------------------------------\r\nActivePortItem* HWDesignDiagram::findAdhocPort(QSharedPointer<PortReference> primaryPort)\r\n{\r\n    ActivePortItem* portItem(nullptr);\r\n \r\n    if (HWComponentItem* componentItem = getComponentItem(primaryPort->getComponentRef()); \r\n        componentItem == nullptr)\r\n    {\r\n        emit errorMessage(tr(\"Component %1 was not found in the design\").arg(primaryPort->getComponentRef()));\r\n    }\r\n    else\r\n    {\r\n        portItem = componentItem->getAdHocPort(primaryPort->getPortRef());\r\n        \r\n        if (portItem == nullptr)\r\n        {\r\n            QSharedPointer<Port> physicalPort = componentItem->componentModel()->getPort(primaryPort->getPortRef());\r\n            if (!physicalPort)\r\n            {\r\n                emit errorMessage(tr(\"Port %1 was not found in the component %2\").arg(primaryPort->getPortRef(), \r\n                    primaryPort->getComponentRef()));\r\n            }\r\n            else\r\n            {\r\n                portItem = new ActivePortItem(physicalPort, componentItem);\r\n                componentItem->addPort(portItem);\r\n                componentItem->setPortAdHocVisible(primaryPort->getPortRef(), true);\r\n            }\r\n        }\r\n    }    \r\n\r\n    return portItem;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HWDesignDiagram::createAdHocTieOffConnection()\r\n//-----------------------------------------------------------------------------\r\nvoid HWDesignDiagram::createAdHocTieOffConnection(QSharedPointer<AdHocConnection> connection)\r\n{\r\n    for (QSharedPointer<PortReference> internalPort : *connection->getInternalPortReferences())\r\n    {\r\n        HWComponentItem* comp1 = getComponentItem(internalPort->getComponentRef());\r\n\r\n        if (!comp1)\r\n        {\r\n            continue;\r\n        }\r\n\r\n        AdHocItem* componentPort = comp1->getAdHocPort(internalPort->getPortRef());\r\n\r\n        if (!componentPort)\r\n        {\r\n            componentPort = comp1->createAdhocItem(internalPort->getPortRef());\r\n        }\r\n\r\n        QSharedPointer<Component> referencedComponent = componentPort->getOwnerComponent();\r\n        diagramResolver_->setContext(referencedComponent);\r\n\r\n        diagramResolver_->resolveAdhocTieOff(connection->getTiedValue(), componentPort);\r\n    }\r\n\r\n    for (QSharedPointer<PortReference> externalPort : *connection->getExternalPortReferences())\r\n    {\r\n        HWConnectionEndpoint* topAdHocPort = getDiagramAdHocPort(externalPort->getPortRef());\r\n\r\n        AdHocItem* topPort;\r\n        if (topAdHocPort)\r\n        {\r\n            topPort = dynamic_cast<AdHocItem*>(topAdHocPort);\r\n        }\r\n        else\r\n        {\r\n            topPort = createAdhocItem(externalPort->getPortRef());\r\n        }\r\n\r\n        QSharedPointer<Component> referencedComponent = topPort->getOwnerComponent();\r\n        diagramResolver_->setContext(referencedComponent);\r\n\r\n        diagramResolver_->resolveAdhocTieOff(connection->getTiedValue(), topPort);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HWDesignDiagram::createConnectionForAdHocPorts()\r\n//-----------------------------------------------------------------------------\r\nvoid HWDesignDiagram::createConnectionForAdHocPorts(QSharedPointer<AdHocConnection> adHocConnection, \r\n    QSharedPointer<PortReference> secondaryPort, \r\n    ConnectionEndpoint* primaryPortItem)\r\n{ \r\n    HWConnectionEndpoint* secondaryPortItem(0);\r\n\r\n    if (secondaryPort->getComponentRef().isEmpty())\r\n    {\r\n        secondaryPortItem = getDiagramAdHocPort(secondaryPort->getPortRef());\r\n    }\r\n    else\r\n    {\r\n        secondaryPortItem = findAdhocPort(secondaryPort); \r\n    }\r\n\r\n    if (secondaryPortItem == nullptr)\r\n    {\r\n        return;\r\n    }\r\n\r\n    QSharedPointer<ConnectionRoute> route = findOrCreateRouteForInterconnection(adHocConnection->name());\r\n\r\n    if (route->isOffpage())\r\n    {\r\n        secondaryPortItem = static_cast<HWConnectionEndpoint*>(secondaryPortItem->getOffPageConnector());\r\n\r\n        primaryPortItem = primaryPortItem->getOffPageConnector();\r\n    }\r\n\r\n    // Create the ad-hoc connection graphics item.\r\n    auto connection = new AdHocConnectionItem(primaryPortItem, secondaryPortItem, adHocConnection, route, this);\r\n\r\n    primaryPortItem->onConnect(secondaryPortItem);\r\n    secondaryPortItem->onConnect(primaryPortItem);\r\n\r\n    connection->validate();\r\n\r\n    primaryPortItem->addConnection(connection);\r\n    secondaryPortItem->addConnection(connection);\r\n\r\n    connection->setRoute(adHocConnection->getRoute());\r\n\r\n    if (route->isOffpage())\r\n    {\r\n        connection->hide();\r\n    }\r\n\r\n    connect(connection, SIGNAL(errorMessage(QString const&)), this, SIGNAL(errorMessage(QString const&)));\r\n\r\n    addItem(connection);\r\n    connection->updatePosition();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HWDesignDiagram::copyInterfaces()\r\n//-----------------------------------------------------------------------------\r\nvoid HWDesignDiagram::copyInterfaces(QList<QGraphicsItem*> const& items, BusInterfaceCollectionCopyData &collection)\r\n{\r\n    // Create instance copies.\r\n    for (QGraphicsItem* item : items)\r\n    {\r\n        if (item->type() == HierarchicalBusInterfaceItem::Type || item->type() == ActiveBusInterfaceItem::Type)\r\n        {\r\n            HierarchicalBusInterfaceItem* busPort = static_cast<HierarchicalBusInterfaceItem*>(item);\r\n\r\n            collection.instances.append(BusInterfaceCopyData());\r\n            BusInterfaceCopyData& instance = collection.instances.back();\r\n\r\n            instance.srcComponent = busPort->getOwnerComponent();\r\n            instance.busInterface = busPort->getBusInterface();\r\n            instance.containingItem = busPort->encompassingComp();\r\n            instance.position = busPort->pos();\r\n            instance.topLevelIf = item->type() == HierarchicalBusInterfaceItem::Type;\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HWDesignDiagram::copyInstances()\r\n//-----------------------------------------------------------------------------\r\nvoid HWDesignDiagram::copyInstances(QList<QGraphicsItem*> const& items, ComponentCollectionCopyData &collection)\r\n{\r\n    // Create instance copies.\r\n    for (QGraphicsItem* item : items)\r\n    {\r\n        if (item->type() == HWComponentItem::Type)\r\n        {\r\n            HWComponentItem* comp = static_cast<HWComponentItem*>(item);\r\n\r\n            collection.instances.append(ComponentInstanceCopyData());\r\n            ComponentInstanceCopyData& instance = collection.instances.back();\r\n\r\n            instance.component = comp->componentModel(); \r\n            instance.instance = comp->getComponentInstance();\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HWDesignDiagram::pasteInterfaces()\r\n//-----------------------------------------------------------------------------\r\nvoid HWDesignDiagram::pasteInterfaces(BusInterfaceCollectionCopyData const& collection,\r\n    HWComponentItem* component, QUndoCommand* cmd)\r\n{\r\n    QStringList reservedNames = component->componentModel()->getBusInterfaceNames();\r\n\r\n    for (BusInterfaceCopyData const& instance : collection.instances)\r\n    {        \r\n        QString uniqueBusName = generateUniqueName(instance.busInterface->name(), reservedNames);        \t      \r\n        reservedNames.append(uniqueBusName);\r\n\r\n        QSharedPointer<BusInterface> interfaceCopy;\r\n        if (!component->isDraft())\r\n        {\r\n            interfaceCopy = QSharedPointer<BusInterface>(new BusInterface(*instance.busInterface));            \r\n        }\r\n        else\r\n        {\r\n            interfaceCopy = QSharedPointer<BusInterface>(new BusInterface());\r\n            interfaceCopy->setInterfaceMode(instance.busInterface->getInterfaceMode());\r\n        }\r\n\r\n        interfaceCopy->setName(uniqueBusName);\r\n\r\n        ActiveBusInterfaceItem* interfaceItem =\r\n            new ActiveBusInterfaceItem(interfaceCopy, getLibraryInterface(), component);\r\n        interfaceItem->setPos(snapPointToGrid(component->mapFromScene(contextMenuPosition())));\r\n        \r\n        // Lock the interface type for non-draft interfaces.\r\n        interfaceItem->setTemporary(true);\r\n        interfaceItem->setTypeLocked(interfaceCopy->getInterfaceMode() != General::INTERFACE_MODE_COUNT);\r\n\r\n        QMap<QString, QPointF> oldLocations = component->getBusInterfacePositions();\r\n\r\n        PortPasteCommand* pasteCmd = new PortPasteCommand(component, interfaceItem, this, cmd);\r\n\r\n        if (!component->isDraft())\r\n        {\r\n            copyPortMapsAndPhysicalPorts(instance.srcComponent, instance.busInterface, instance.containingItem,\r\n                interfaceItem, pasteCmd);\r\n        }\r\n        \r\n        pasteCmd->redo();\r\n\r\n        QMap<QString, QPointF>::iterator current = oldLocations.begin();\r\n        while (current != oldLocations.end())\r\n        {\r\n            if (component->getBusPort(current.key())->pos() != current.value())\r\n            {\r\n                new PortMoveCommand(component->getBusPort(current.key()), current.value(), this, pasteCmd);\r\n            }\r\n            ++current;\r\n        }  \r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HWDesignDiagram::pasteTopLevelInterfaces()\r\n//-----------------------------------------------------------------------------\r\nvoid HWDesignDiagram::pasteTopLevelInterfaces(BusInterfaceCollectionCopyData const& collection,\r\n    GraphicsColumn* column, QUndoCommand* cmd, bool useCursorPos)\r\n{\r\n    QStringList existingNames = getTopLevelInterfaceNames();\r\n\r\n    for (BusInterfaceCopyData const& instance : collection.instances)\r\n    {\r\n        GraphicsColumn* targetColumn = column;\r\n        if (!targetColumn->getContentType() == ColumnTypes::IO)\r\n        {\r\n            targetColumn = nullptr;\r\n\r\n            for (GraphicsColumn* otherColumn : getLayout()->getColumns())\r\n            {\r\n                if (otherColumn->getContentType() == ColumnTypes::IO)\r\n                {\r\n                    targetColumn = otherColumn;\r\n                    break;\r\n                }\r\n            }\r\n        }\r\n        \r\n        if (targetColumn != nullptr)\r\n        {           \r\n            // Bus interface must have a unique name within the component.\r\n            QString uniqueBusName = generateUniqueName(instance.busInterface->name(), existingNames);\r\n            existingNames.append(uniqueBusName);\r\n\r\n            QSharedPointer<BusInterface> copyBusIf(new BusInterface(*instance.busInterface));\r\n            copyBusIf->setName(uniqueBusName);\r\n\r\n            QSharedPointer<InterfaceGraphicsData> dataGroup(new InterfaceGraphicsData(copyBusIf->name()));\r\n\r\n            HierarchicalBusInterfaceItem* pastedItem = new HierarchicalBusInterfaceItem(\r\n                getEditedComponent(), copyBusIf, dataGroup, getLibraryInterface(), targetColumn);\r\n\r\n            BusInterfacePasteCommand* pasteCmd = new BusInterfacePasteCommand(getEditedComponent(), pastedItem,\r\n                targetColumn, this, cmd);    \r\n\r\n            copyPortMapsAndPhysicalPorts(instance.srcComponent, instance.busInterface, instance.containingItem,\r\n                pastedItem, pasteCmd);\r\n\r\n            if (useCursorPos)\r\n            {\r\n                pastedItem->setPos(findCursorPositionMappedToScene());\r\n            }\r\n            else\r\n            {\r\n                pastedItem->setPos(instance.position);\r\n            }\r\n\r\n            // Store the positions of other interfaces.\r\n            QMap<HierarchicalBusInterfaceItem*, QPointF> oldPositions;\r\n            for (QGraphicsItem* item : targetColumn->childItems())\r\n            {\r\n                if (item->type() == HierarchicalBusInterfaceItem::Type)\r\n                {\r\n                    HierarchicalBusInterfaceItem* interface = static_cast<HierarchicalBusInterfaceItem*>(item);\r\n                    oldPositions.insert(interface, interface->scenePos());\r\n                }\r\n            }\r\n\r\n            // Paste interface to component.\r\n            pasteCmd->redo();\r\n\r\n            // Determine if the other interfaces changed their position and create undo commands for them.\r\n            QMap<HierarchicalBusInterfaceItem*, QPointF>::iterator cur = oldPositions.begin();\r\n\r\n            while (cur != oldPositions.end())\r\n            {\r\n                if (cur.key()->scenePos() != cur.value())\r\n                {\r\n                    new ItemMoveCommand(cur.key(), cur.value(), targetColumn, this, pasteCmd);\r\n                }\r\n                ++cur;\r\n            }  \r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HWDesignDiagram::createComponentPasteCommand()\r\n//-----------------------------------------------------------------------------\r\nvoid HWDesignDiagram::createComponentPasteCommand(ComponentCollectionCopyData const& collection, GraphicsColumn* column,\r\n    QUndoCommand* parentCommand, bool useCursorPos)\r\n{\r\n    for (ComponentInstanceCopyData const& instance : collection.instances)\r\n    {\r\n        QPointF position;\r\n        if (useCursorPos)\r\n        {\r\n            position = findCursorPositionMappedToScene();\r\n        }\r\n        else\r\n        {\r\n            position = instance.instance->getPosition();\r\n        }\r\n\r\n        new ComponentInstancePasteCommand(instance.component, instance.instance, position, column, this,\r\n            parentCommand);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HWDesignDiagram::createAdhocItem()\r\n//-----------------------------------------------------------------------------\r\nAdHocItem* HWDesignDiagram::createAdhocItem(QString const& portName)\r\n{\r\n    QSharedPointer<VendorExtension> adhocExtension = getDesign()->getAdHocPortPositions();\r\n    QSharedPointer<Kactus2Group> adhocGroup = adhocExtension.dynamicCast<Kactus2Group>();\r\n\r\n    if (!adhocGroup)\r\n    {\r\n        adhocGroup = QSharedPointer<Kactus2Group>(new Kactus2Group(\"kactus2:adHocVisibilities\"));\r\n        getDesign()->getVendorExtensions()->append(adhocGroup);\r\n    }\r\n\r\n    QSharedPointer<Kactus2Placeholder> adhocData(new Kactus2Placeholder(\"kactus2:adHocVisible\"));\r\n    adhocGroup->addToGroup(adhocData);\r\n\r\n    HierarchicalPortItem* adHocIf;\r\n\r\n    QSharedPointer<Port> adhocPort = getEditedComponent()->getPort(portName);\r\n    if (adhocPort)\r\n    {\r\n        adHocIf = new HierarchicalPortItem(getEditedComponent(), adhocPort, adhocData, nullptr);\r\n    }\r\n    else\r\n    {\r\n        adHocIf = createMissingHierarchicalAdHocPort(portName, adhocData, nullptr);\r\n    }\r\n\r\n    return adHocIf;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HWDesignDiagram::showAdhocPort()\r\n//-----------------------------------------------------------------------------\r\nvoid HWDesignDiagram::showAdhocPort(AdHocItem* portItem)\r\n{\r\n    HierarchicalPortItem* interfaceItem = dynamic_cast<HierarchicalPortItem*>(portItem);\r\n    if (interfaceItem)\r\n    {\r\n        QPointF interfacePosition = interfaceItem->scenePos();\r\n\r\n        GraphicsColumn* targetColumn = getLayout()->findColumnAt(interfacePosition);\r\n\r\n        if (targetColumn->isItemAllowed(interfaceItem))\r\n        {\r\n            targetColumn->addItem(interfaceItem);\r\n        }\r\n        else\r\n        {\r\n            getLayout()->addItem(interfaceItem);\r\n        }\r\n    }\r\n\r\n    QSharedPointer<VendorExtension> adhocExtension = getDesign()->getAdHocPortPositions();\r\n    QSharedPointer<Kactus2Group> adhocGroup = adhocExtension.dynamicCast<Kactus2Group>();\r\n    if (!adhocGroup)\r\n    {\r\n        adhocGroup = QSharedPointer<Kactus2Group>(new Kactus2Group(\"kactus2:adHocVisibilities\"));\r\n        getDesign()->getVendorExtensions()->append(adhocGroup);\r\n    }\r\n\r\n    for (QSharedPointer<VendorExtension> extension : adhocGroup->getByType(\"kactus2:adHocVisible\"))\r\n    {\r\n        QSharedPointer<Kactus2Placeholder> portExtension = extension.dynamicCast<Kactus2Placeholder>();\r\n        if (portExtension->getAttributeValue(\"portName\") == portItem->name())\r\n        {\r\n            return;\r\n        }\r\n    }\r\n\r\n    QSharedPointer<Kactus2Placeholder> newPortExtension = interfaceItem->getDataGroup();\r\n    if (newPortExtension.isNull())\r\n    {\r\n        newPortExtension = QSharedPointer<Kactus2Placeholder>(new Kactus2Placeholder(\"kactus2:adHocVisible\"));\r\n        newPortExtension->setAttribute(\"portName\", portItem->name());\r\n        newPortExtension->setAttribute(\"x\", QString::number(portItem->scenePos().x()));\r\n        newPortExtension->setAttribute(\"y\", QString::number(portItem->scenePos().y()));\r\n\r\n        interfaceItem->setDataGroup(newPortExtension);\r\n    }\r\n\r\n    adhocGroup->addToGroup(newPortExtension);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HWDesignDiagram::hideAdhocPort()\r\n//-----------------------------------------------------------------------------\r\nvoid HWDesignDiagram::hideAdhocPort(AdHocItem* portItem)\r\n{\r\n    QSharedPointer<VendorExtension> adhocExtension = getDesign()->getAdHocPortPositions();\r\n    QSharedPointer<Kactus2Group> adhocGroup = adhocExtension.dynamicCast<Kactus2Group>();\r\n\r\n    HierarchicalPortItem* interfaceItem = dynamic_cast<HierarchicalPortItem*>(portItem);\r\n    if (adhocGroup && interfaceItem && interfaceItem->parentItem())\r\n    {\r\n        static_cast<GraphicsColumn*>(interfaceItem->parentItem())->removeItem(interfaceItem);\r\n\r\n        for (QSharedPointer<VendorExtension> extension : adhocGroup->getByType(\"kactus2:adHocVisible\"))\r\n        {\r\n            QSharedPointer<Kactus2Placeholder> portExtension = extension.dynamicCast<Kactus2Placeholder>();\r\n            if (portExtension->getAttributeValue(\"portName\") == interfaceItem->name())\r\n            {\r\n                adhocGroup->removeFromGroup(portExtension);\r\n            }\r\n        }\r\n\r\n        if (adhocGroup->getByType(\"kactus2:adHocVisible\").isEmpty())\r\n        {\r\n            getDesign()->getVendorExtensions()->removeAll(adhocExtension);\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HWDesignDiagram::createUniqueName()\r\n//-----------------------------------------------------------------------------\r\nQString HWDesignDiagram::generateUniqueName(QString const& name, QStringList const& reservedNames) const\r\n{\r\n    QString uniqueName = name;\r\n    QRegularExpression trailingCount(\"_\\\\d+$\");\r\n\r\n    int count = 0;\r\n\r\n    while (reservedNames.contains(uniqueName))\r\n    {\r\n        uniqueName.remove(trailingCount);\r\n        count++;        \r\n        uniqueName.append(\"_\");\r\n        uniqueName.append(QString::number(count));\r\n    }    \r\n\r\n    return uniqueName;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HWDesignDiagram::getTopLevelInterfaceNames()\r\n//-----------------------------------------------------------------------------\r\nQStringList HWDesignDiagram::getTopLevelInterfaceNames() const\r\n{\r\n    QStringList existingNames;\r\n    for (QGraphicsItem* item : items())\r\n    {\r\n        if (item->type() == HierarchicalBusInterfaceItem::Type)\r\n        {\r\n            HierarchicalBusInterfaceItem* interface = static_cast<HierarchicalBusInterfaceItem*>(item);\r\n            existingNames.append(interface->name());\r\n        }\r\n    }\r\n\r\n    return existingNames;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HWDesignDiagram::createAutoConnector()\r\n//-----------------------------------------------------------------------------\r\nComponentItemAutoConnector* HWDesignDiagram::createAutoConnector(ComponentItem* firstItem) const\r\n{\r\n    QString firstItemName = firstItem->name();\r\n    QString firstItemVisibleName = getVisibleNameForComponentItem(firstItem);\r\n    QString secondItemName = \"\";\r\n    QString secondItemVisibleName = \"\";\r\n    QSharedPointer<Component> firstComponent = firstItem->componentModel();\r\n    QSharedPointer<Component> secondComponent;\r\n\r\n    QSharedPointer<TableItemMatcher> busItemMatcher;\r\n    QSharedPointer<TableAutoConnector> busAutoConnector;\r\n    QSharedPointer<TableItemMatcher> portItemMatcher;\r\n    QSharedPointer<TableAutoConnector> portAutoConnector;\r\n\r\n    AutoConnectorItem::ContainerType secondContainerType;\r\n\r\n    if (selectedItems().count() == 1)\r\n    {\r\n        secondComponent = getEditedComponent();\r\n        secondItemName = secondComponent->getVlnv().getName();\r\n        secondItemVisibleName = secondItemName;\r\n\r\n        busItemMatcher = QSharedPointer<HierarchicalBusInterfaceItemMatcher>(\r\n            new HierarchicalBusInterfaceItemMatcher(getLibraryInterface()));\r\n        busAutoConnector = QSharedPointer< HierarchicalBusInterfaceTableAutoConnector>(\r\n            new HierarchicalBusInterfaceTableAutoConnector(getLibraryInterface()));\r\n\r\n        portItemMatcher = QSharedPointer<HierarchicalPortItemMatcher>(new HierarchicalPortItemMatcher());\r\n        portAutoConnector = QSharedPointer< HierarchicalPortTableAutoConnector>(\r\n            new HierarchicalPortTableAutoConnector());\r\n\r\n        secondContainerType = AutoConnectorItem::TOP_COMPONENT;\r\n    }\r\n    else\r\n    {\r\n        QGraphicsItem* secondItem = selectedItems().first();\r\n        if (secondItem == firstItem)\r\n        {\r\n            secondItem = selectedItems().last();\r\n        }\r\n\r\n        ComponentItem* secondComponentItem = dynamic_cast<ComponentItem*>(secondItem);\r\n\r\n        secondItemName = secondComponentItem->name();\r\n        secondItemVisibleName = getVisibleNameForComponentItem(secondComponentItem);\r\n        secondComponent = secondComponentItem->componentModel();\r\n\r\n        busItemMatcher = QSharedPointer<BusInterfaceItemMatcher>(\r\n            new BusInterfaceItemMatcher(getLibraryInterface()));\r\n        busAutoConnector = QSharedPointer<BusInterfaceTableAutoConnector>(\r\n            new BusInterfaceTableAutoConnector(getLibraryInterface()));\r\n\r\n        portItemMatcher = QSharedPointer<PortItemMatcher>(new PortItemMatcher());\r\n        portAutoConnector = QSharedPointer<PortTableAutoConnector>(\r\n            new PortTableAutoConnector());\r\n\r\n        secondContainerType = AutoConnectorItem::COMPONENT_ITEM;\r\n    }\r\n\r\n    ComponentItemAutoConnector::AutoContainer firstContainer;\r\n    firstContainer.component_ = firstComponent;\r\n    firstContainer.name_ = firstItemName;\r\n    firstContainer.visibleName_ = firstItemVisibleName;\r\n    ComponentItemAutoConnector::AutoContainer secondContainer;\r\n    secondContainer.component_ = secondComponent;\r\n    secondContainer.name_ = secondItemName;\r\n    secondContainer.visibleName_ = secondItemVisibleName;\r\n\r\n    ComponentItemAutoConnector::TableTools busTools;\r\n    busTools.itemMatcher_ = busItemMatcher;\r\n    busTools.tableConnector_ = busAutoConnector;\r\n    busTools.listFiller_ = QSharedPointer<BusInterfaceListFiller>(new BusInterfaceListFiller());\r\n\r\n    ComponentItemAutoConnector::TableTools portTools;\r\n    portTools.itemMatcher_ = portItemMatcher;\r\n    portTools.tableConnector_ = portAutoConnector;\r\n    portTools.listFiller_ = QSharedPointer<PortListFiller>(new PortListFiller());\r\n\r\n    ComponentItemAutoConnector* autoConnector = new ComponentItemAutoConnector(\r\n        firstContainer, secondContainer, busTools, portTools, secondContainerType, getDesign(), getParent());\r\n\r\n    return autoConnector;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HWDesignDiagram::getEndPointForItem()\r\n//-----------------------------------------------------------------------------\r\nConnectionEndpoint* HWDesignDiagram::getEndPointForItem(AutoConnectorItem* connectorItem,\r\n    QUndoCommand* parentUndoCommand /*= nullptr*/)\r\n{\r\n    if (connectorItem->getContainterType() == AutoConnectorItem::COMPONENT_ITEM)\r\n    {\r\n        return getEndPointFromComponentItem(connectorItem, parentUndoCommand);\r\n    }\r\n    else\r\n    {\r\n        return getEndPointForTopComponentItem(connectorItem);\r\n    }\r\n\r\n    return nullptr;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HWDesignDiagram::getEndPointFromComponentItem()\r\n//-----------------------------------------------------------------------------\r\nConnectionEndpoint* HWDesignDiagram::getEndPointFromComponentItem(AutoConnectorItem* connectorItem,\r\n    QUndoCommand* parentUndoCommand /*= nullptr*/)\r\n{\r\n    HWComponentItem* containingItem = getComponentItem(connectorItem->getContainingItem());\r\n    auto itemName = connectorItem->getName();\r\n    if (connectorItem->getItemType() == AutoConnectorItem::PORT)\r\n    {\r\n        for (auto const& endpoint : containingItem->getEndpoints())\r\n        {\r\n            if (endpoint->isAdHoc() && endpoint->name() == itemName)\r\n            {\r\n                return endpoint;\r\n            }\r\n        }\r\n\r\n        QString name = connectorItem->getName();\r\n        for (auto const& port : *containingItem->componentModel()->getPorts())\r\n        {\r\n            if (port->name() == name)\r\n            {\r\n                AdHocVisibilityChangeCommand* newVisibilityCommand =\r\n                    new AdHocVisibilityChangeCommand(containingItem, itemName, true, parentUndoCommand);\r\n                newVisibilityCommand->redo();\r\n\r\n                for (auto const& endpoint : containingItem->getEndpoints())\r\n                {\r\n                    if (endpoint->isAdHoc() && endpoint->getPort()->name() == name)\r\n                    {\r\n                        return endpoint;\r\n                    }\r\n                }\r\n            }\r\n        }\r\n    }\r\n    else if (connectorItem->getItemType() == AutoConnectorItem::BUS_INTERFACE)\r\n    {\r\n        for (auto const& endPoint : containingItem->getEndpoints())\r\n        {\r\n            if (endPoint->isBus() && endPoint->name() == itemName)\r\n            {\r\n                return endPoint;\r\n            }\r\n        }\r\n    }\r\n\r\n    return nullptr;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HWDesignDiagram::getEndPointForTopComponentItem()\r\n//-----------------------------------------------------------------------------\r\nConnectionEndpoint* HWDesignDiagram::getEndPointForTopComponentItem(AutoConnectorItem* connectorItem,\r\n    QUndoCommand* parentUndoCommand /*= nullptr*/)\r\n{\r\n    auto itemName = connectorItem->getName();\r\n    if (connectorItem->getItemType() == AutoConnectorItem::PORT)\r\n    {\r\n        HWConnectionEndpoint* portEndPoint = getDiagramAdHocPort(itemName);\r\n        if (!portEndPoint && getEditedComponent()->hasPort(connectorItem->getName()))\r\n        {\r\n            TopAdHocVisibilityChangeCommand* adHocCommand =\r\n                new TopAdHocVisibilityChangeCommand(this, itemName, true, parentUndoCommand);\r\n            adHocCommand->redo();\r\n            portEndPoint = getDiagramAdHocPort(itemName);\r\n        }\r\n\r\n        return portEndPoint;\r\n    }\r\n    else\r\n    {\r\n        return findOrCreateHierarchicalInterface(itemName);\r\n    }\r\n\r\n    return nullptr;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HWDesignDiagram::createConnectionBetweenEndPoints()\r\n//-----------------------------------------------------------------------------\r\nvoid HWDesignDiagram::createConnectionBetweenEndPoints(ConnectionEndpoint* startPoint,\r\n    ConnectionEndpoint* endPoint)\r\n{\r\n    if (startPoint->isAdHoc() || startPoint->isBus())\r\n    {\r\n        GraphicsConnection* newConnection = createConnection(startPoint, endPoint);\r\n\r\n        startPoint->onConnect(endPoint);\r\n        startPoint->onConnect(endPoint);\r\n\r\n        startPoint->addConnection(newConnection);\r\n        endPoint->addConnection(newConnection);\r\n\r\n        if (startPoint->isAdHoc() && endPoint->isAdHoc())\r\n        {\r\n            AdHocConnectionItem* adhocItem = dynamic_cast<AdHocConnectionItem*>(newConnection);\r\n            addItem(adhocItem);\r\n\r\n            getDesign()->getAdHocConnections()->append(adhocItem->getInterconnection());\r\n            getDesign()->addRoute(adhocItem->getRouteExtension());\r\n        }\r\n        else if (startPoint->isBus() && endPoint->isBus())\r\n        {\r\n            HWConnection* hwConnectionItem = dynamic_cast<HWConnection*>(newConnection);\r\n\r\n            addItem(hwConnectionItem);\r\n\r\n            getDesign()->getInterconnections()->append(hwConnectionItem->getInterconnection());\r\n            getDesign()->addRoute(hwConnectionItem->getRouteExtension());\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HWDesignDiagram::addAutoConnectorActionToContextMenu()\r\n//-----------------------------------------------------------------------------\r\nbool HWDesignDiagram::addAutoConnectorActionToContextMenu() const\r\n{\r\n    return true;\r\n}\r\n"
  },
  {
    "path": "editors/HWDesign/HWDesignDiagram.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: HWDesignDiagram.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: \r\n// Date: \r\n//\r\n// Description:\r\n// HWDesignDiagram is a graphical view to a design.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef HWDESIGNDIAGRAM_H\r\n#define HWDESIGNDIAGRAM_H\r\n\r\n#include \"AdHocEnabled.h\"\r\n\r\n#include <editors/common/ComponentDesignDiagram.h>\r\n\r\n#include <IPXACTmodels/generaldeclarations.h>\r\n\r\n#include <IPXACTmodels/Component/BusInterface.h>\r\n#include <IPXACTmodels/kactusExtensions/ColumnDesc.h>\r\n\r\n#include <QMap>\r\n#include <QVector>\r\n#include <QSharedPointer>\r\n#include <QUndoCommand>\r\n\r\nclass AbstractionDefinition;\r\nclass AdHocConnection;\r\nclass HierarchicalPortItem;\r\nclass ActivePortItem;\r\nclass ActiveBusInterfaceItem;\r\nclass HierarchicalBusInterfaceItem;\r\nclass Component;\r\nclass ComponentInstance;\r\nclass ComponentItem;\r\nclass ConnectionEndpoint;\r\nclass ConnectionRoute;\r\nclass Design;\r\nclass DesignConfiguration;\r\nclass GenericEditProvider;\r\nclass GraphicsColumn;\r\nclass GraphicsColumnLayout;\r\nclass GraphicsConnection;\r\nclass HierConnection;\r\nclass HierInterface;\r\nclass HWComponentItem;\r\nclass HWConnection;\r\nclass HWConnectionEndpoint;\r\nclass Interconnection;\r\nclass LibraryInterface;\r\nclass PortReference;\r\nclass VLNV;\r\nclass InterfaceGraphicsData;\r\nclass Kactus2Placeholder;\r\nclass DesignDiagramResolver;\r\nclass AdHocItem;\r\nclass MultipleParameterFinder;\r\nclass ListParameterFinder;\r\nclass ComponentItemAutoConnector;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! HWDesignDiagram is a graphical view to a design.\r\n//-----------------------------------------------------------------------------\r\nclass HWDesignDiagram : public ComponentDesignDiagram\r\n{\r\n    Q_OBJECT\r\n\r\npublic:\r\n\r\n    //-----------------------------------------------------------------------------\r\n    //! Clipboard copy data for a single bus interface instance.\r\n    //-----------------------------------------------------------------------------\r\n    struct BusInterfaceCopyData\r\n    {\r\n        QSharedPointer<Component> srcComponent;         //!< The origin component.\r\n        QSharedPointer<BusInterface> busInterface;      //!< The bus interface.\r\n        ComponentItem* containingItem;                  //!< The containing component item.\r\n        QPointF position;\r\n        bool topLevelIf;                                //!< Top-level or bus port interface.\r\n\r\n        /*!\r\n        *  Constructor.\r\n        */\r\n        BusInterfaceCopyData()\r\n            : srcComponent(),\r\n            busInterface(),\r\n            containingItem(),\r\n            position(),\r\n            topLevelIf()\r\n        {\r\n        }\r\n    };\r\n\r\n    //-----------------------------------------------------------------------------\r\n    //! Clipboard copy data for a collection of copied bus interface instances.\r\n    //-----------------------------------------------------------------------------\r\n    struct BusInterfaceCollectionCopyData\r\n    {\r\n        QList<BusInterfaceCopyData> instances;\r\n\r\n        /*!\r\n        *  Constructor.\r\n        */\r\n        BusInterfaceCollectionCopyData()\r\n            : instances()\r\n        {\r\n        }\r\n    };\r\n\r\n\r\n    //-----------------------------------------------------------------------------\r\n    //! Clipboard copy data for a single component instance.\r\n    //-----------------------------------------------------------------------------\r\n    struct ComponentInstanceCopyData\r\n    {\r\n        QSharedPointer<Component> component;            //!< The referenced component.\r\n        QSharedPointer<ComponentInstance> instance;\r\n\r\n        ComponentInstanceCopyData()\r\n            : component(),\r\n            instance()\r\n        {\r\n        }\r\n    };\r\n\r\n    //-----------------------------------------------------------------------------\r\n    //! Clipboard copy data for a collection of copied component instances.\r\n    //-----------------------------------------------------------------------------\r\n    struct ComponentCollectionCopyData\r\n    {\r\n        QList<ComponentInstanceCopyData> instances;\r\n\r\n        /*!\r\n         *  Constructor.\r\n         */\r\n        ComponentCollectionCopyData()\r\n            : instances()\r\n        {\r\n        }\r\n    };\r\n\r\n    //-----------------------------------------------------------------------------\r\n    //! Clipboard copy data for a single column.\r\n    //-----------------------------------------------------------------------------\r\n    struct ColumnCopyData\r\n    {\r\n        QSharedPointer<ColumnDesc> desc;            //!< Column description.\r\n        ComponentCollectionCopyData components;     //!< Components.\r\n        BusInterfaceCollectionCopyData interfaces;  //!< Top-level bus interfaces.\r\n\r\n        /*!\r\n         *  Constructor.\r\n         */\r\n        ColumnCopyData()\r\n            : desc(),\r\n            components(),\r\n            interfaces()\r\n        {\r\n        }\r\n    };\r\n\r\n    //-----------------------------------------------------------------------------\r\n    //! Clipboard copy data for a collection of columns.\r\n    //-----------------------------------------------------------------------------\r\n    struct ColumnCollectionCopyData\r\n    {\r\n        QList<ColumnCopyData> columns;\r\n\r\n        /*!\r\n         *  Constructor.\r\n         */\r\n        ColumnCollectionCopyData()\r\n            : columns()\r\n        {\r\n        }\r\n    };\r\n\r\n    /*!\r\n     *  The constructor.\r\n     *\r\n     *    @param [in] lh                                  Enables access to the library.\r\n     *    @param [in] editProvider                        The edit provider.\r\n     *    @param [in] designAndInstancesParameterFinder   Parameter finder for design parameter reference tree.\r\n     *    @param [in] designParameterFinder               Parameter finder for design parameters.\r\n     *    @param [in] parent                              Owner of this diagram.\r\n     */\r\n    HWDesignDiagram(LibraryInterface* lh, QSharedPointer<IEditProvider> editProvider,\r\n        QSharedPointer<MultipleParameterFinder> designAndInstancesParameterFinder,\r\n        QSharedPointer<ListParameterFinder> designParameterFinder,\r\n        DesignWidget* parent = 0);\r\n\r\n    /*!\r\n     *  The destructor.\r\n     */\r\n    ~HWDesignDiagram() final = default;\r\n\r\n    /*!\r\n     *  Set the IP-XACT document that is viewed in HWDesignDiagram.\r\n     */\r\n    void loadDesign(QSharedPointer<Design> design);\r\n\r\n    /*!\r\n     *  Get HWComponentItem that has the given instance name.\r\n     */\r\n    HWComponentItem* getComponentItem(QString const& instanceName);\r\n\r\n    /*!\r\n     *  Reflects the changes in the design to the top-level component.\r\n     */\r\n    virtual void updateHierComponent();\r\n\r\n    /*!\r\n     *  Load and insert the selected column to the graphics layout.\r\n     *\r\n     *    @param [in] description     Column description of the selected column.\r\n     */\r\n    void loadColumn(QSharedPointer<ColumnDesc> description);\r\n\r\n    /*!\r\n     *  Adds a column to the diagram's layout.\r\n     *\r\n     *    @param [in] desc The column description.\r\n     */\r\n    void addColumn(QSharedPointer<ColumnDesc> desc);\r\n\r\n    /*!\r\n     *  Called when a port's ad-hoc visibility has been changed.\r\n     *\r\n     *    @param [in] portName  The name of the port.\r\n     *    @param [in] visible   The new ad-hoc visibility.\r\n     */\r\n    virtual void onAdHocVisibilityChanged(QString const& portName, bool visible);\r\n\r\n    /*!\r\n     *  Returns the ad-hoc port with the given name or null if not found.\r\n     */\r\n    virtual HWConnectionEndpoint* getDiagramAdHocPort(QString const& portName);\r\n\r\n    /*!\r\n     *\tReturns the bus interface item of the corresponding design component bus interface with the given name\r\n     *  or nullptr if not found.\r\n     *\r\n     *    @param [in] busRef     The interface name.\r\n     *\r\n     * \t    @return The hierarchical bus interface item found or null.\r\n     */\r\n    HWConnectionEndpoint* getHierarchicalInterface(QString const& busRef) const;\r\n\r\n    /*!\r\n     *\tSets the value of the flag indicating if interfaces have been deleted in the design diagram.\r\n     *  \r\n     *    @param [in] haveBeenDeleted     Flag value to set.\r\n     */\r\n    void setInterfacesHaveBeenDeleted();\r\n\r\npublic slots:\r\n\r\n\t/*!\r\n     *  Called when copy is selected from the context menu.\r\n     */\r\n\tvirtual void onCopyAction();\r\n\r\n    /*!\r\n     *  Called when paste is selected from the context menu.\r\n     */\r\n\tvirtual void onPasteAction();\r\n    \r\n    /*!\r\n     *  Paste hierarchical interfaces.\r\n     *\r\n     *    @param [in] mimeData    The data containing the pasted items.\r\n     */\r\n    void pasteHierarchicalInterfaces(QMimeData const* mimeData);\r\n\r\n    /*!\r\n     *  Paste columns.\r\n     */\r\n    void pasteColumns();\r\n\r\n    /*!\r\n     *  Paste components to a new column.\r\n     */\r\n    void pasteComponentsToColumn();\r\n\r\n    /*!\r\n     *  Paste interfaces to a draft component.\r\n     *\r\n     *    @param [in] targetItem  The component item to paste interfaces into.\r\n     */\r\n    void pasteInterfacesToDraftComponent(HWComponentItem* targetItem);\r\n\r\n    /*!\r\n     *  Called when add to library is selected from the context menu.\r\n     */\r\n\tvirtual void onAddToLibraryAction();\r\n\r\nprotected:\r\n\r\n    /*!\r\n     *  Opens a design for a given component.\r\n     *\r\n     *    @param [in] component   The component whose design to open.\r\n     *    @param [in] viewName    The name of the view to open.\r\n     */\r\n    virtual void openDesignForComponent(ComponentItem* component, QString const& viewName) override;\r\n\r\n    //! Handler for mouse double click events.\r\n    void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *mouseEvent);\r\n\r\n    //! Handler for drag enter event. \r\n    void dragEnterEvent(QGraphicsSceneDragDropEvent *event);\r\n\r\n    //! Handler for drag leave event.\r\n    void dragLeaveEvent(QGraphicsSceneDragDropEvent * event);\r\n\r\n    //! Handler for drop event.\r\n    void dropEvent(QGraphicsSceneDragDropEvent *event);\r\n    \r\n    /*!\r\n     *  Set the interface VLNV at an end point.\r\n     *\r\n     *    @param [in] droppedVLNV     The selected VLNV.\r\n     */\r\n    void setInterfaceVLNVatEndpoint(VLNV const& droppedVLNV);\r\n\r\n    /*!\r\n     *  Replace the component item at the selected position.\r\n     *\r\n     *    @param [in] position    The position of the replaced component item.\r\n     *    @param [in] component   The component to replace the item at position.\r\n     */\r\n    void replaceComponentItemAtPositionWith(QPointF position, QSharedPointer<Component> component);\r\n\r\n    /*!\r\n     *  Create a new component item.\r\n     *\r\n     *    @param [in] comp            The selected component.\r\n     *    @param [in] instanceName    The name of the instance to create.\r\n     *    @param [in] position        Position of the new component item.\r\n     *    @param [in] parentCommand   Parent undo command for item creation.\r\n     */\r\n    HWComponentItem* createComponentItem(QSharedPointer<Component> comp, QString const& instanceName,\r\n        QPointF position, QUndoCommand* parentCommand);\r\n\r\n    //! Updates the dropAction and highlight according to underlying element.\r\n    virtual void updateDropAction(QGraphicsSceneDragDropEvent* event) override;\r\n\r\n    /*!\r\n     *  Checks if open component action should be enabled.\r\n     *\r\n     *    @return True, if action should be enabled, otherwise false.\r\n     */\r\n    virtual bool openComponentActionEnabled() const override;\r\n\r\n    /*!\r\n     *  Check if the selected items are of a type used in the HW design.\r\n     *\r\n     *    @return True, if the items are used in HW design, false otherwise.\r\n     */\r\n    virtual bool selectedItemIsCorrectType() const override;\r\n\r\n    /*!\r\n     *  Checks if the given item is a hierarchical component.\r\n     *\r\n     *    @param [in] item   The item to check.\r\n     *\r\n     *    @return True, if item is a hierarchical component, otherwise false.\r\n     */\r\n    virtual bool isHierarchicalComponent(QGraphicsItem* item) const override;\r\n\r\n    /*!\r\n     *  Checks if copy action should be enabled.\r\n     *\r\n     *    @return True, if action should be enabled, otherwise false.\r\n     */\r\n    virtual bool copyActionEnabled() const override;\r\n\r\n    /*!\r\n     *  Checks if paste action should be enabled.\r\n     *\r\n     *    @return True, if action should be enabled, otherwise false.\r\n     */\r\n    virtual bool pasteActionEnabled() const override;\r\n\r\n    /*!\r\n     *  Opens the given component according to the active view of the component.\r\n     *\r\n     *    @param [in] comp   The component to open.\r\n     */\r\n    void openComponentByActiveView(ComponentItem * comp);\r\n\r\n   /*!\r\n    *  Gets the names of hierarchical views of a component.\r\n    *\r\n    *    @param [in] component   The component whose hierarchical views to get.\r\n    *\r\n    *    @return The names of the hierarchical views.\r\n    */\r\n    virtual QStringList hierarchicalViewsOf(ComponentItem* component) const override;\r\n\r\n    /*!\r\n     *  Gets the graphics item type of the components in the diagram.\r\n     *     \r\n     *    @return The type of the components.\r\n     */\r\n    virtual int componentType() const;\r\n\r\n    /*!\r\n     *  Gets the graphics item type of the off page connectors in the diagram.\r\n     *     \r\n     *    @return The type of the components.\r\n     */\r\n    virtual int offpageConnectorType() const;\r\n\r\n    /*!\r\n     *  Gets the graphics item type of the connections in the diagram.\r\n     *     \r\n     *    @return The type of the components.\r\n     */\r\n    virtual int connectionType() const;\r\n\r\n    /*!\r\n     *  Create an ad hoc interface item with the selected name.\r\n     *\r\n     *    @param [in] portName    The name of the new ad hoc interface item.\r\n     *\r\n     *    @return The created ad hoc interface item.\r\n     */\r\n    virtual AdHocItem* createAdhocItem(QString const& portName) override;\r\n\r\nprivate:\r\n    // Disable copying.\r\n    HWDesignDiagram(HWDesignDiagram const& rhs);\r\n    HWDesignDiagram& operator=(HWDesignDiagram const& rhs);\r\n\r\n    /*!\r\n     *  Finds the design extension for a hierarchical bus interface item. If the extension does not exist,\r\n     *  it is created.\r\n     *\r\n     *    @param [in] design              The design to search extensions in.\r\n     *    @param [in] busInterfaceName    The name of the bus interface to search for.\r\n     *\r\n     *    @return The extension for hierarchical bus interface data.\r\n     */\r\n    QSharedPointer<InterfaceGraphicsData> findOrCreateInterfaceExtensionGroup(QSharedPointer<Design> design,\r\n        QString const& busInterfaceName);\r\n\r\n    /*!\r\n     *  Called when an item has been selected in the diagram.\r\n     *\r\n     *    @param [in] newSelection The selected item.\r\n     */\r\n    virtual void onSelected(QGraphicsItem* newSelection);\r\n\r\n    /*!\r\n     *  Creates a connection between the given two endpoints.\r\n     *\r\n     *    @param [in] startPoint  The starting connection end point.\r\n     *    @param [in] endPoint    The ending connection end point.\r\n     *    @param [in] isOffPage   Determines if connection to be created is off-page or not.\r\n     *\r\n     *    @return The created connection.\r\n     */\r\n    virtual GraphicsConnection* createConnection(ConnectionEndpoint* startPoint, ConnectionEndpoint* endPoint, bool isOffPage = false);\r\n\r\n    /*!\r\n     *  Creates a connection between the given endpoint and a coordinate point.\r\n     *\r\n     *    @param [in] startPoint  The starting connection end point.\r\n     *    @param [in] endPoint    The ending coordinate point.\r\n     *\r\n     *    @return The created connection.\r\n     */\r\n    virtual GraphicsConnection* createConnection(ConnectionEndpoint* startPoint, QPointF const& endPoint);\r\n\r\n    /*!\r\n     *  Creates an add command for a given connection.\r\n     *\r\n     *    @param [in] connection          The connection to create a command for.     \r\n     *    @param [in] parentUndoCommand   Optional undocommand to set as parent for created commands.\r\n     *\r\n     *    @return The created add command.\r\n     */\r\n    virtual QUndoCommand* createAddCommandForConnection(GraphicsConnection* connection, QUndoCommand* parentCommand = nullptr);\r\n\r\n    /*!\r\n     *  Copies the interface definition to hierarchical interface from a defined interface.\r\n     *\r\n     *    @param [in] definedPoint        The interface item to copy definitions from.\r\n     *    @param [in] undefinedPoint      The interface item to copy definitions into.\r\n     *    @param [in] definingConnection  The connection between the points initiating the copy.\r\n     *    @param [in] parentCommand       The parent undo command.\r\n     *\r\n     *    @return True, if the copy was accepted by the user, otherwise false.\r\n     */\r\n    bool copyDefinitions(ConnectionEndpoint* definedPoint, ConnectionEndpoint* undefinedPoint,\r\n        HWConnection* definingConnection, QUndoCommand* parentCommand);\r\n\r\n    /*!\r\n     *  Checks if the given bus interface item has a default name.\r\n     *\r\n     *    @param [in] connectionPoint   The bus interface item to check.\r\n     *\r\n     *    @return True, if the name is default pattern, otherwise false.\r\n     */\r\n    bool hasDefaultName(ConnectionEndpoint const* undefinedPoint) const;\r\n    \r\n    /*!\r\n     *  Copies the interface name to hierarchical interface from a defined interface.\r\n     *\r\n     *    @param [in] sourceInterface     The interface item to copy name from.\r\n     *    @param [in] targetInterface     The interface item to copy the name into.\r\n     *    @param [in] definingConnection  The connection between the points initiating the copy.\r\n     *    @param [in] parentCommand       The parent undo command.\r\n     */\r\n    void copyInterfaceName(ConnectionEndpoint* sourceInterface, ConnectionEndpoint* targetInterface,\r\n        HWConnection* definingConnection, QUndoCommand* parentCommand);\r\n\r\n    /*!\r\n     *  Finds the hierInterfaces corresponding to the given interface name.\r\n     *\r\n     *    @param [in] previousName    The name to search for.\r\n     *    @param [in] connection      The interconnection to search in.\r\n     *\r\n     *    @return The hierInterfaces with the given name.\r\n     */\r\n    QList<QSharedPointer<HierInterface> > findInterfacesByName(QString const& previousName,\r\n        QSharedPointer<Interconnection> connection) const;\r\n    \r\n    /*!\r\n     *  Copies the interface mode to hierarchical interface from a defined interface.\r\n     *\r\n     *    @param [in] sourceInterface     The interface item to copy mode from.\r\n     *    @param [in] targetInterface     The interface item to copy mode into.\r\n     *    @param [in] parentCommand       The parent undo command.\r\n     */\r\n    void copyMode(ConnectionEndpoint* sourceInterface, ConnectionEndpoint* targetInterface,\r\n        QUndoCommand* parentCommand);\r\n\r\n    /*!\r\n     *  Copies the interface type to hierarchical interface from a defined interface.\r\n     *\r\n     *    @param [in] definedPoint        The interface item to copy type from.\r\n     *    @param [in] draftPoint          The interface item to copy type into.\r\n     *    @param [in] parentCommand       The parent undo command.\r\n     */\r\n    void copyType(ConnectionEndpoint* definedPoint, ConnectionEndpoint* draftPoint, QUndoCommand* parentCommand);\r\n\r\n    /*!\r\n     *  Copies the port maps and ports into a hierarchical bus interface.\r\n     *\r\n     *    @param [in] sourcePoint         The interface item to copy from.\r\n     *    @param [in] targetPoint         The interface item to copy into.\r\n     *    @param [in] parentCommand       The parent undo command.\r\n     *\r\n     *    @return True, if the copy was accepted by the user, otherwise false.\r\n     */\r\n    bool copyPortsAndMapsForHierarchicalPoint(ConnectionEndpoint* sourcePoint, ConnectionEndpoint* targetPoint,\r\n        QUndoCommand* parentCommand);\r\n\r\n    /*!\r\n     *  Copies port and port maps from the given bus interface into a bus interface item.\r\n     *\r\n     *    @param [in] sourceComponent     The component containing the bus interface to copy from.\r\n     *    @param [in] sourceInterface     The bus interface to copy from.\r\n     *    @param [in] sourceInstanceItem  The item containing the copied end point.\r\n     *    @param [in] target              The bus interface item to copy into.\r\n     *    @param [in] parentCommand       The parent undo command.\r\n     */\r\n    void copyPortMapsAndPhysicalPorts(QSharedPointer<Component> sourceComponent, \r\n        QSharedPointer<BusInterface> sourceInterface, ComponentItem* sourceInstanceItem,\r\n        ConnectionEndpoint* target, QUndoCommand* parentCommand);\r\n\r\n    /*!\r\n     *  Creates a connecting port for opposing the given port.\r\n     *\r\n     *    @param [in] sourcePort      The port whose opposing port to create.\r\n     *    @param [in] portDirection   The port direction for the created port.\r\n     *    @param [in] reservedNames   The names of existing ports in the target component.\r\n     *\r\n     *    @return The newly created port matching the source port in size and type.\r\n     */\r\n    QSharedPointer<Port> createConnectingPhysicalPort(QSharedPointer<Port> sourcePort, \r\n        DirectionTypes::Direction portDirection, QStringList const& reservedNames);\r\n\r\n    /*!\r\n     *  Creates the port maps for hierarchical interface by user selection.\r\n     *\r\n     *    @param [in] sourcePoint     The bus interface whose mode and definitions to use as a starting point.\r\n     *    @param [in] targetPoint     The interface whose port maps to create.\r\n     *    @param [in] parentCommand   The parent undo command.\r\n     *\r\n     *    @return True, if the selection was accepted by the user, otherwise false.\r\n     */\r\n    bool createPortMapsManually(ConnectionEndpoint* sourcePoint, ConnectionEndpoint* targetPoint,\r\n        QUndoCommand* parentCommand);\r\n\r\n    /*!\r\n     *  Adds a new interface to the given diagram column.\r\n     *\r\n     *    @param [in] column      The column where to add the interface.\r\n     *    @param [in] pos         The interface position.\r\n     *    @param [in] isDraft     Determines if Bus Interface is draft or not.\r\n     */\r\n    virtual void addTopLevelInterface(GraphicsColumn* column, QPointF const& pos, bool isDraft);\r\n\r\n    /*!\r\n     *  Handler for draft tool clicks. Creates a draft component instance or a draft interface according to the\r\n     *  clicked position.\r\n     *\r\n     *    @param [in] clickedPosition   The position to create the draft item to.     \r\n     */\r\n    virtual void draftAt(QPointF const& clickedPosition);\r\n\r\n    /*!\r\n     *  Finds the item types for the given column. If the types are ambiguous, asks the user for types.\r\n     *\r\n     *    @param [in] column   The column to find the types for.\r\n     *\r\n     *    @return The column types.\r\n     */\r\n    unsigned int findColumnItemType(GraphicsColumn* column) const;\r\n\r\n    /*!\r\n     *  Adds a draft component instance to the design.\r\n     *\r\n     *    @param [in] column      The column to add the instance to.\r\n     *    @param [in] position    The initial position to add the instance at.     \r\n     */\r\n    void addDraftComponentInstance(GraphicsColumn* column, QPointF const& position);\r\n\r\n    /*!\r\n     *  Adds a draft interface in a draft component instance.\r\n     *\r\n     *    @param [in] targetComponent     The component item to add the interface to.\r\n     *    @param [in] position            The initial position of the interface.     \r\n     */\r\n    void addDraftComponentInterface(HWComponentItem* targetComponent, QPointF const& position);\r\n\r\n    /*!\r\n     *  Performs the replacing of destination component with source component.\r\n     *\r\n     *    @param [in] destComp        The component to replace.\r\n     *    @param [in] sourceComp      The replacing component.     \r\n     */\r\n    virtual void replace(ComponentItem* destComp, ComponentItem* sourceComp);\r\n\r\n    /*!\r\n     *  Creates a graphics item for component instance and adds it to the diagram.\r\n     *\r\n     *    @param [in] instance    The instance to create item for.\r\n     *    @param [in] design      The design containing the instance.\r\n     */\r\n    void createComponentItem(QSharedPointer<ComponentInstance> instance, QSharedPointer<Design> design);\r\n\r\n    /*!\r\n     *  Finds a port item on a component item or creates one if not found.\r\n     *\r\n     *    @param [in] componentItem   The component graphic item containing the port.\r\n     *    @param [in] componentRef    The reference name for the component.\r\n     *    @param [in] busRef          The reference name for the bus interface.\r\n     *    @param [in] design          The design containing the component instance.\r\n     *\r\n     *    @return The port item on the component.\r\n     */\r\n    ConnectionEndpoint* findOrCreateMissingInterface(HWComponentItem* componentItem, QString const& componentRef, \r\n        QString const& busRef, QSharedPointer<Design> design);\r\n    \r\n    /*!\r\n     *  Creates a missing port to the given component item.\r\n     *\r\n     *    @param [in] portName   The name of the port to create.\r\n     *    @param [in] component  The parent component.\r\n     *    @param [in] design     The design containing related information.\r\n     *\r\n     *    @return A port item for a missing port.\r\n     */\r\n    ActiveBusInterfaceItem* createMissingBusInterface(QString const& interfaceName, HWComponentItem* containingComponent,\r\n        QSharedPointer<Design> design);\r\n\r\n    /*!\r\n     *  Creates a graphics item for interconnection and adds it to the diagram.\r\n     *\r\n     *    @param [in] interconnection     The interconnection to create item for.\r\n     *    @param [in] design              The design containing the interconnection.\r\n     */\r\n    void createInterconnection(QSharedPointer<Interconnection> interconnection, QSharedPointer<Design> design);\r\n\r\n    /*!\r\n     *  Create an interconnection between components.\r\n     *\r\n     *    @param [in] interconnection     The selected interconnection.\r\n     *    @param [in] design              The design in which to create the interconnection.\r\n     */\r\n    void createInterconnectionBetweenComponents(QSharedPointer<Interconnection> interconnection, QSharedPointer<Design> design);\r\n\r\n    /*!\r\n     *  Find or create a route for the interconnection.\r\n     *\r\n     *    @param [in] interconnectionName     The name of the interconnection.\r\n     */\r\n    QSharedPointer<ConnectionRoute> findOrCreateRouteForInterconnection(QString const& interconnectionName);\r\n\r\n    /*!\r\n     *  Creates a graphics item for hierarchical interconnection and adds it to the diagram.\r\n     *\r\n     *    @param [in] hierConn    The hierarchical interconnection to create item for.\r\n     *    @param [in] design      The design containing the interconnection.\r\n     */\r\n    void createHierarchicalConnection(QSharedPointer<Interconnection> connection,\r\n          QSharedPointer<Design> design);\r\n    \r\n    /*!\r\n     *  Find or create a hierarchical interface.\r\n     *\r\n     *    @param [in] busRef  The name of the interface.\r\n     */\r\n    ConnectionEndpoint* findOrCreateHierarchicalInterface(QString const& busRef);\r\n\r\n    /*!\r\n     *  Creates the hierarchical ad-hoc port items in the diagram.\r\n     *\r\n     *    @param [in] design   The design containing the ad-hoc ports.\r\n     */\r\n    void createHierachicalAdHocPorts(QSharedPointer<Design> design);\r\n    \r\n    /*!\r\n     *  Create a missing hierarchical ad hoc port.\r\n     *\r\n     *    @param [in] portName        The name of the missing port.\r\n     *    @param [in] adHocExtension  The extension containing information of the port.\r\n     *    @param [in] parentItem      The parent item of the missing ad hoc port.\r\n     *\r\n     *    @return The interface item for the missing interface.\r\n     */\r\n    HierarchicalPortItem* createMissingHierarchicalAdHocPort(QString const& portName,\r\n        QSharedPointer<Kactus2Placeholder> adHocExtension, QGraphicsItem* parentItem = (QGraphicsItem*)0);\r\n\r\n    /*!\r\n     *  Creates a graphics item for an ad-hoc interconnection and adds it to the diagram.\r\n     *\r\n     *    @param [in] adHocConn   The ad-hoc connection to create the item for.\r\n     */\r\n    void createAdHocConnection(QSharedPointer<AdHocConnection> adHocConnection);\r\n\r\n    /*!\r\n     *  Finds the graphical item for the given port reference.\r\n     *\r\n     *    @param [in] portReference   The port reference whose graphical item to find.\r\n     *\r\n     *    @return The port item or 0 if port cannot be found.\r\n     */\r\n    ActivePortItem* findAdhocPort(QSharedPointer<PortReference> portReference);\r\n\r\n    /*!\r\n     *  Create a symbol for an ad hoc tie off value.\r\n     *\r\n     *    @param [in] connection  The selected ad hoc connection.\r\n     */\r\n    void createAdHocTieOffConnection(QSharedPointer<AdHocConnection> connection);\r\n\r\n    /*!\r\n     *  Creates a graphics item for an ad-hoc interconnection between two ports and adds it to the diagram.\r\n     *\r\n     *    @param [in] adHocConnection     The ad-hoc connection containing the ports.\r\n     *    @param [in] secondaryPort       The connected internal/hierarchical port.\r\n     *    @param [in] primaryPortItem     The port item for the primary port.\r\n     */\r\n    void createConnectionForAdHocPorts(QSharedPointer<AdHocConnection> adHocConnection,\r\n        QSharedPointer<PortReference> secondaryPort, \r\n        ConnectionEndpoint* primaryPortItem);\r\n    /*!\r\n     *  Copies component instances in a format which can be saved to clipboard.\r\n     *\r\n     *    @param [in]  items       The top-level bus interface instance items to copy.\r\n     *    @param [out] collection  The resulted collection of bus interface instance copy data.\r\n     */\r\n    void copyInterfaces(QList<QGraphicsItem*> const& items, BusInterfaceCollectionCopyData &collection);\r\n\r\n    /*!\r\n     *  Copies component instances in a format which can be saved to clipboard.\r\n     *\r\n     *    @param [in]  items       The component instance items to copy.\r\n     *    @param [out] collection  The resulted collection of component instance copy data.\r\n     */\r\n    void copyInstances(QList<QGraphicsItem*> const& items, ComponentCollectionCopyData &collection);\r\n \r\n    /*!\r\n     *  Pastes bus port instances from a copy data collection.\r\n     *\r\n     *    @param [in] collection     The collection of bus port instance copy data.\r\n     *    @param [in] component      The component where to place the ports.\r\n     *    @param [in] cmd            The parent undo command for the paste undo commands.\r\n     */\r\n   void pasteInterfaces(BusInterfaceCollectionCopyData const& collection, HWComponentItem* component, \r\n       QUndoCommand* cmd);\r\n\r\n   /*!\r\n     *  Pastes top-level bus interface instances from a copy data collection.\r\n     *\r\n     *    @param [in] collection     The collection of bus interface instance copy data.\r\n     *    @param [in] column         The column where to place the instances.\r\n     *    @param [in] cmd            The parent undo command for the paste undo commands.\r\n     *    @param [in] userCursorPos  If true, the instances are placed close to the cursor position.\r\n     *                                 Otherwise the original positions are used.\r\n     */\r\n    void pasteTopLevelInterfaces(BusInterfaceCollectionCopyData const& collection, GraphicsColumn* column,\r\n        QUndoCommand* cmd, bool useCursorPos);\r\n\r\n    /*!\r\n     *  Creates paste command for component instances from a copy data collection.\r\n     *\r\n     *    @param [in] collection     The collection of component instance copy data.\r\n     *    @param [in] column         The column where to place the instances.\r\n     *    @param [in] cmd            The parent undo command for the paste undo commands.\r\n     *    @param [in] userCursorPos  If true, the instances are placed close to the cursor position.\r\n     *                                 Otherwise the original positions are used.\r\n     */\r\n    void createComponentPasteCommand(ComponentCollectionCopyData const& collection, GraphicsColumn* column, \r\n        QUndoCommand* parentCommand, bool useCursorPos);\r\n\r\n    /*!\r\n     *  Show the selected hoc port item.\r\n     *\r\n     *    @param [in] portItem    The selected ad hoc port item.\r\n     */\r\n    virtual void showAdhocPort(AdHocItem* portItem);\r\n\r\n    /*!\r\n     *  Hide the selected hoc port item.\r\n     *\r\n     *    @param [in] portItem    The selected ad hoc port item.\r\n     */\r\n    virtual void hideAdhocPort(AdHocItem* portItem);\r\n\r\n    /*!\r\n     *  Generates a unique name.\r\n     *\r\n     *    @param [in] name            The base for the name.\r\n     *    @param [in] reservedNames   The existing names that should not be generated.\r\n     *\r\n     *    @return A unique name.\r\n     */\r\n    QString generateUniqueName(QString const& name, QStringList const& reservedNames) const;\r\n\r\n    /*!\r\n     *  Finds the name of hierarchical interfaces in the design.\r\n     *\r\n     *    @return The names of the hierarchical interfaces.\r\n     */\r\n    QStringList getTopLevelInterfaceNames() const;\r\n\r\n    /*!\r\n     *  Check if the design parameter reference finder contains a component finder for the selected component.\r\n     *\r\n     *    @param [in] component   The selected component.\r\n     *\r\n     *    @return True, if the design parameter reference finder contains the selected component, otherwise\r\n     *              false.\r\n     */\r\n    bool referenceFinderContainsComponent(QSharedPointer<Component> component);\r\n\r\n    /*!\r\n     *  Create auto connection dialog.\r\n     *\r\n     *    @param [in] firstItem   The first item for the auto connector.\r\n     *\r\n     *    @return The auto connector dialog.\r\n     */\r\n    virtual ComponentItemAutoConnector* createAutoConnector(ComponentItem* firstItem) const;\r\n\r\n    /*!\r\n     *  Get the connection end point for the selected auto connector item.\r\n     *\r\n     *    @param [in] connectorItem       The selected auto connector item.\r\n     *    @param [in] parentUndoCommand   Optional undocommand to set as parent for created child commands.\r\n     *\r\n     *    @return The end point item for the selected auto connector item.\r\n     */\r\n    virtual ConnectionEndpoint* getEndPointForItem(AutoConnectorItem* connectorItem, QUndoCommand* parentUndoCommand = nullptr);\r\n\r\n    /*!\r\n     *  Get the component item connection end point for the selected auto connector item.\r\n     *\r\n     *    @param [in] connectorItem       The selected auto connector item.\r\n     *    @param [in] parentUndoCommand   Optional undocommand to set as parent for created child commands.\r\n     *\r\n     *    @return The selected component item connection end point.\r\n     */\r\n    ConnectionEndpoint* getEndPointFromComponentItem(AutoConnectorItem* connectorItem, QUndoCommand* parentUndoCommand = nullptr);\r\n\r\n    /*!\r\n     *  Get the top component connection end point for the selected auto connector item.\r\n     *\r\n     *    @param [in] connectorItem       The selected auto connector item.\r\n     *    @param [in] parentUndoCommand   Optional undocommand to set as parent for created child commands.\r\n     * \r\n     *    @return The selected top component connection end point.\r\n     */\r\n    ConnectionEndpoint* getEndPointForTopComponentItem(AutoConnectorItem* connectorItem, QUndoCommand* parentUndoCommand = nullptr);\r\n\r\n    /*!\r\n     *  Create connection between the selected end points.\r\n     *\r\n     *    @param [in] startPoint  Start point for the connection.\r\n     *    @param [in] endPoint    End point for the connection.\r\n     */\r\n    virtual void createConnectionBetweenEndPoints(ConnectionEndpoint* startPoint, ConnectionEndpoint* endPoint);\r\n\r\n    /*!\r\n     *  Check if the auto connector should be added to the context menu.\r\n     *\r\n     *    @return True, if the auto connected should be added, false otherwise.\r\n     */\r\n    virtual bool addAutoConnectorActionToContextMenu() const;\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! The type of the item being dragged.\r\n    ColumnTypes::ColumnItemType dragCompType_ = ColumnTypes::NONE;\r\n\r\n    //! Flag for indicating that the item being dragged is a bus.\r\n    bool dragBus_ = false;\r\n\r\n    //! The possible end point under cursor while performing drag.\r\n    HWConnectionEndpoint* dragEndPoint_ = nullptr;\r\n\r\n    //! Handler for design diagram calculation.\r\n    QSharedPointer<DesignDiagramResolver> diagramResolver_;\r\n\r\n    //! Parameter finder for design parameter reference tree\r\n    QSharedPointer<MultipleParameterFinder> designAndInstancesParameterFinder_;\r\n\r\n    //! Flag indicating if interfaces have been deleted from the design diagram.\r\n    bool manuallyDeletedInterfaces_ = false;\r\n};\r\n\r\n#endif // HWDESIGNDIAGRAM_H\r\n"
  },
  {
    "path": "editors/HWDesign/HWDesignWidget.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: designwidget.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: \r\n// Date: \r\n//\r\n// Description:\r\n// HWDesignWidget is used to edit and view one design\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"HWDesignWidget.h\"\r\n\r\n#include \"HWDesignDiagram.h\"\r\n#include \"HWComponentItem.h\"\r\n#include \"HWConnection.h\"\r\n#include \"AdHocConnectionItem.h\"\r\n\r\n#include <KactusAPI/include/IPXactSystemVerilogParser.h>\r\n#include <KactusAPI/include/ComponentParameterFinder.h>\r\n\r\n#include <editors/common/Association/Association.h>\r\n#include <editors/common/StickyNote/StickyNote.h>\r\n#include <editors/common/Association/AssociationRemoveCommand.h>\r\n\r\n#include <editors/HWDesign/HierarchicalBusInterfaceItem.h>\r\n#include <editors/HWDesign/ActiveBusInterfaceItem.h>\r\n#include <editors/HWDesign/HierarchicalPortItem.h>\r\n#include <editors/HWDesign/ActivePortItem.h>\r\n#include <editors/HWDesign/HWComponentItem.h>\r\n\r\n#include <editors/HWDesign/undoCommands/ColumnDeleteCommand.h>\r\n#include <editors/HWDesign/undoCommands/ComponentDeleteCommand.h>\r\n#include <editors/HWDesign/undoCommands/ConnectionDeleteCommand.h>\r\n#include <editors/HWDesign/undoCommands/InterfaceDeleteCommand.h>\r\n#include <editors/HWDesign/undoCommands/PortDeleteCommand.h>\r\n#include <editors/HWDesign/undoCommands/AdHocConnectionDeleteCommand.h>\r\n#include <editors/HWDesign/undoCommands/AdHocVisibilityChangeCommand.h>\r\n\r\n#include <common/graphicsItems/GraphicsColumn.h>\r\n#include <common/graphicsItems/GraphicsColumnLayout.h>\r\n#include <common/graphicsItems/GraphicsColumnConstants.h>\r\n#include <common/dialogs/newObjectDialog/newobjectdialog.h>\r\n#include <common/GenericEditProvider.h>\r\n\r\n#include <KactusAPI/include/LibraryInterface.h>\r\n\r\n#include <common/NameGenerationPolicy.h>\r\n\r\n#include \"columnview/ColumnEditDialog.h\"\r\n#include \"columnview/HWColumn.h\"\r\n\r\n#include <IPXACTmodels/common/TagData.h>\r\n\r\n#include <IPXACTmodels/Component/Component.h>\r\n#include <IPXACTmodels/Component/ComponentInstantiation.h>\r\n#include <IPXACTmodels/Component/File.h>\r\n#include <IPXACTmodels/Component/FileSet.h>\r\n#include <IPXACTmodels/Component/Model.h>\r\n#include <IPXACTmodels/Component/View.h>\r\n\r\n#include <IPXACTmodels/Design/Design.h>\r\n\r\n#include <IPXACTmodels/DesignConfiguration/DesignConfiguration.h>\r\n\r\n#include <IPXACTmodels/generaldeclarations.h>\r\n#include <IPXACTmodels/utilities/Search.h>\r\n\r\n#include <QMessageBox>\r\n#include <QFileDialog>\r\n#include <QFileInfo>\r\n#include <QCoreApplication>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HWDesignWidget::HWDesignWidget()\r\n//-----------------------------------------------------------------------------\r\nHWDesignWidget::HWDesignWidget(LibraryInterface *lh,\r\n    QSharedPointer<MultipleParameterFinder> designAndIsntancesParameterFinder,\r\n    QSharedPointer<ListParameterFinder> designParameterFinder, QWidget *parent):\r\nDesignWidget(lh, parent)\r\n{\r\n\t// update the supported windows \r\n\tsupportedWindows_ = (supportedWindows_ | CONFIGURATIONWINDOW | CONNECTIONWINDOW | INTERFACEWINDOW |\r\n        INSTANCEWINDOW | ADHOC_WINDOW | DESIGNPARAMETERSWINDOW);\r\n\r\n    setDiagram(new HWDesignDiagram(\r\n        lh, getEditProvider(), designAndIsntancesParameterFinder, designParameterFinder, this));\r\n    getDiagram()->setProtection(false);\r\n    getDiagram()->setMode(MODE_SELECT);\r\n    \r\n    QSharedPointer<ComponentParameterFinder> parameterFinder (new ComponentParameterFinder(getEditedComponent()));\r\n    expressionParser_ = QSharedPointer<IPXactSystemVerilogParser>(new IPXactSystemVerilogParser(parameterFinder));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HWDesignWidget::setDesign()\r\n//-----------------------------------------------------------------------------\r\nbool HWDesignWidget::setDesign(VLNV const& vlnv, QString const& viewName)\r\n{\t\r\n\tdisconnect(getDiagram(), SIGNAL(contentChanged()), this, SIGNAL(contentChanged()));\r\n\r\n\t// if vlnv and view name was defined which means that an existing component is opened\r\n\tif (vlnv.isValid() && !viewName.isEmpty())\r\n    {\r\n\t\t// if vlnv is writeSucceeded and the type is component\r\n\t\tif (vlnv.isValid() && vlnv.getType() == VLNV::COMPONENT) {\r\n\r\n\t\t\t// create model \r\n\t\t\tQSharedPointer<Component> comp = getLibHandler()->getModel<Component>(vlnv);\r\n\r\n\t\t\tif (comp == nullptr|| !setDesign(comp, viewName))\r\n            {\r\n\t\t\t\treturn false;\r\n            }\r\n\t\t}\r\n\t}\r\n\t// if vlnv was writeSucceeded but view is empty then should create a new design for the component\r\n\telse if (vlnv.isValid() && viewName.isEmpty())\r\n    {\r\n\t\tQ_ASSERT(getLibHandler()->contains(vlnv));\r\n\t\tQ_ASSERT(getLibHandler()->getDocumentType(vlnv) == VLNV::COMPONENT);\r\n\r\n\t\tQSharedPointer<Component> comp = getLibHandler()->getModel<Component>(vlnv);\r\n\r\n\t\t// get the directory path where the component's xml file is located\r\n\t\tconst QString xmlPath = getLibHandler()->getPath(vlnv);\r\n\t\tQFileInfo xmlInfo(xmlPath);\r\n\t\tconst QString dirPath = xmlInfo.absolutePath();\r\n\r\n\t\tcreateDesignForComponent(comp, dirPath);\r\n\t}\r\n\t// if vlnv was not defined (a new hierarchical component is created)\r\n\telse\r\n    {\r\n\t\tif (!createEmptyDesign(vlnv))\r\n        {\r\n            return false;\r\n        }\r\n\t}\r\n\r\n\t// disable the save at startup\r\n\tconnect(getDiagram(), SIGNAL(contentChanged()), this, SIGNAL(contentChanged()), Qt::UniqueConnection);\r\n\tconnect(getDiagram(), SIGNAL(modeChanged(DrawMode)), this, SIGNAL(modeChanged(DrawMode)), Qt::UniqueConnection);\r\n\r\n\tsetModified(false);\r\n\r\n    setDocumentType(DocumentType::HW_DESIGN);\r\n\tsetDocumentName(QString(\"%1 (%2)\").arg(getIdentifyingVLNV().getName()).arg(getIdentifyingVLNV().getVersion()));\r\n\r\n\temit clearItemSelection();\r\n\r\n    return true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HWDesignWidget::setDesign()\r\n//-----------------------------------------------------------------------------\r\nbool HWDesignWidget::setDesign(QSharedPointer<Component> component, QString const& viewName)\r\n{\r\n    QSharedPointer<View> openView = Search::findByName(viewName, *component->getViews());\r\n\r\n    if (!openView || !openView->isHierarchical())\r\n    {\r\n        return false;\r\n    }\r\n\r\n    QSharedPointer<Design> design;\r\n    QSharedPointer<DesignConfiguration> designConfiguration;\r\n    \r\n    if (!openView->getDesignConfigurationInstantiationRef().isEmpty())\r\n    {\r\n        VLNV configurationVLNV;\r\n\r\n        for (QSharedPointer<DesignConfigurationInstantiation> configuration : \r\n            *component->getDesignConfigurationInstantiations())\r\n        {\r\n            if (configuration->name() == openView->getDesignConfigurationInstantiationRef())\r\n            {\r\n                configurationVLNV = *configuration->getDesignConfigurationReference();\r\n            }\r\n        }\r\n\r\n        designConfiguration = getLibHandler()->getModel(configurationVLNV).dynamicCast<DesignConfiguration>();       \r\n        if (designConfiguration)\r\n        {\r\n            design = getLibHandler()->getModel(designConfiguration->getDesignRef()).dynamicCast<Design>();\r\n        }\r\n\r\n        if (!design)\r\n        {\r\n            emit errorMessage(tr(\"Component %1 did not contain a hierarchical view\").arg(component->getVlnv().getName()));\r\n            return false;\r\n        }\r\n    }\r\n    else if (!openView->getDesignInstantiationRef().isEmpty())\r\n    {\r\n        VLNV designVLNV;\r\n\r\n        for (QSharedPointer<DesignInstantiation> designInstantiation : *component->getDesignInstantiations())\r\n        {\r\n            if (designInstantiation->name() == openView->getDesignInstantiationRef())\r\n            {\r\n                designVLNV = *designInstantiation->getDesignReference();\r\n            }\r\n        }\r\n\r\n        design = getLibHandler()->getModel(designVLNV).dynamicCast<Design>();\r\n        if (!design)\r\n        {\r\n            emit errorMessage(tr(\"VLNV %1 was not found in library.\").arg(designVLNV.toString()));\r\n            return false;\r\n        }\r\n    }\r\n\r\n    if (!getDiagram()->setDesign(component, viewName, design, designConfiguration))\r\n    {\r\n        return false;\r\n    }\r\n\r\n    DesignWidget::setDesign(component, viewName);\r\n\tsetDocumentName(QString(\"%1 (%2)\").arg(getIdentifyingVLNV().getName()).arg(getIdentifyingVLNV().getVersion()));\r\n\r\n    return true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HWDesignWidget::saveAs()\r\n//-----------------------------------------------------------------------------\r\nbool HWDesignWidget::saveAs()\r\n{\r\n\tVLNV oldVLNV = getEditedComponent()->getVlnv();\r\n\r\n    // Ask the user for a new VLNV along with attributes and directory.\r\n    KactusAttribute::ProductHierarchy prodHier = getEditedComponent()->getHierarchy();\r\n    KactusAttribute::Firmness firmness = getEditedComponent()->getFirmness();\r\n    QVector<TagData> tags = getEditedComponent()->getTags();\r\n\r\n    VLNV vlnv;\r\n\r\n    QString directory;\r\n    if (!NewObjectDialog::saveAsDialog(this, getLibHandler(), oldVLNV, prodHier, firmness, tags, vlnv,\r\n        directory))\r\n    {\r\n        return false;\r\n    }\r\n\r\n\t// create the vlnv for design and design configuration\r\n\tVLNV designVLNV(VLNV::DESIGN, vlnv.getVendor(), vlnv.getLibrary(),\r\n\t\tvlnv.getName().remove(\".comp\") + \".design\", vlnv.getVersion());\r\n\tVLNV desConfVLNV(VLNV::DESIGNCONFIGURATION, vlnv.getVendor(), vlnv.getLibrary(),\r\n\t\tvlnv.getName().remove(\".comp\") + \".designcfg\", vlnv.getVersion());\r\n\r\n    // create the design\r\n    QSharedPointer<Design> design;\r\n\tQSharedPointer<Component> oldComponent = getEditedComponent();\r\n\r\n\t// make a copy of the hierarchical component\r\n    QSharedPointer<Component> topComponent(new Component(*oldComponent));\r\n\tsetEditedComponent(topComponent);\r\n\r\n\t// set the new vlnv for the component\r\n\ttopComponent->setVlnv(vlnv);\r\n\r\n    QSharedPointer<View> openView = Search::findByName(getOpenViewName(), *topComponent->getViews());\r\n\r\n\tQSharedPointer<DesignConfiguration> designConf = getDiagram()->getDesignConfiguration();\r\n\r\n\t// if design configuration is used\r\n\tif (designConf)\r\n    {\r\n\t\t// make a copy of the design configuration\r\n\t\tdesignConf = QSharedPointer<DesignConfiguration>(new DesignConfiguration(*designConf));\r\n\t\tdesignConf->setVlnv(desConfVLNV);\r\n\t\tdesignConf->setDesignRef(designVLNV);\r\n\r\n        for (QSharedPointer<DesignConfigurationInstantiation> configuration : \r\n            *topComponent->getDesignConfigurationInstantiations())\r\n        {\r\n            if (configuration->name() == openView->getDesignConfigurationInstantiationRef())\r\n            {\r\n                configuration->setDesignConfigurationReference(QSharedPointer<ConfigurableVLNVReference>(\r\n                    new ConfigurableVLNVReference(desConfVLNV)));\r\n            }\r\n        }\r\n\r\n\t\tdesign = getDiagram()->getDesign();\r\n\t}\r\n\t// if component does not use design configuration then it references directly to design\r\n\telse\r\n    {\r\n        for (QSharedPointer<DesignInstantiation> designInstantiation : *topComponent->getDesignInstantiations())\r\n        {\r\n            if (designInstantiation->name() == openView->getDesignInstantiationRef())\r\n            {\r\n                designInstantiation->setDesignReference(QSharedPointer<ConfigurableVLNVReference>(\r\n                    new ConfigurableVLNVReference(designVLNV)));\r\n            }\r\n        }\r\n\r\n\t\tdesign = getDiagram()->getDesign();\r\n\t}\r\n\r\n\tif (design == nullptr)\r\n\t{\r\n\t\treturn false;\r\n\t}\r\n\r\n    design = QSharedPointer<Design>(new Design(*design));\r\n    design->setVlnv(designVLNV);\r\n\r\n\t// update the hierarchical bus interfaces of the top-component\r\n\tgetDiagram()->updateHierComponent();\r\n\r\n\t// get the paths to the original xml file\r\n\tQFileInfo sourceInfo(getLibHandler()->getPath(oldComponent->getVlnv()));\r\n\tQString sourcePath = sourceInfo.absolutePath();\r\n\r\n\t// update the file paths and copy necessary files\r\n\tupdateFiles(topComponent, sourcePath, directory);\r\n\r\n\t// create the files for the documents\r\n\r\n\tbool writeSucceeded = true;\r\n\r\n\tgetLibHandler()->beginSave();\r\n\r\n\t// if design configuration is used then write it.\r\n\tif (designConf && !getLibHandler()->writeModelToFile(directory, designConf))\r\n    {\r\n\t    writeSucceeded = false;\r\n\t}\r\n\r\n\tif (!getLibHandler()->writeModelToFile(directory, design))\r\n    {\r\n\t\twriteSucceeded = false;\r\n\t}\r\n\r\n\tif (!getLibHandler()->writeModelToFile(directory, topComponent))\r\n    {\r\n\t\twriteSucceeded = false;\r\n\t}\r\n\r\n\tgetLibHandler()->endSave();\r\n\r\n\tif (writeSucceeded)\r\n    {\r\n\t\tsetDocumentName(getEditedComponent()->getVlnv().getName() + \" (\" + getEditedComponent()->getVlnv().getVersion() + \")\");\r\n\t\treturn TabDocument::saveAs();\r\n\t}\r\n\telse\r\n    {\r\n\t\temit errorMessage(tr(\"Error saving design to disk.\"));\r\n\t\treturn false;\r\n\t}\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HWDesignWidget::keyPressEvent()\r\n//-----------------------------------------------------------------------------\r\nvoid HWDesignWidget::keyPressEvent(QKeyEvent *event)\r\n{\r\n    // Handle delete events if the document is not protected.\r\n    if (!isProtected() && event->key() == Qt::Key_Delete)\r\n    {\r\n        onDeleteSelectedItems();\r\n    }\r\n    else\r\n    {\r\n        TabDocument::keyPressEvent(event);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HWDesignWidget::onDeleteSelectedItems()\r\n//-----------------------------------------------------------------------------\r\nvoid HWDesignWidget::onDeleteSelectedItems()\r\n{\r\n    QList<QGraphicsItem*> selectedItems = getDiagram()->selectedItems();\r\n\r\n    if (selectedItems.empty())\r\n    {\r\n        return;\r\n    }\r\n\r\n    int type = DesignDiagram::getCommonItemType(selectedItems);\r\n    if (type == HWComponentItem::Type)\r\n    {\r\n        deleteSelectedComponentItems(selectedItems);\r\n    }\r\n    else if (type == HierarchicalBusInterfaceItem::Type)\r\n    {\r\n        deleteSelectedBusInterfaceItems(selectedItems);\r\n    }\r\n    else if (type == ActiveBusInterfaceItem::Type)\r\n    {\r\n        deleteSelectedBusPortItems(selectedItems);\r\n    }\r\n    else if (type == HWConnection::Type)\r\n    {\r\n        deleteSelectedHWConnectionItems(selectedItems);\r\n    }\r\n    else if (type == AdHocConnectionItem::Type)\r\n    {\r\n        deleteSelectedAdHocConnectionItems(selectedItems);\r\n    }\r\n    else if (type == HWColumn::Type)\r\n    {\r\n        deleteSelectedHWColumns(selectedItems);\r\n    }\r\n    else if (type == HierarchicalPortItem::Type)\r\n    {\r\n        deleteSelectedAdhocInterfaces(selectedItems);\r\n    }\r\n    else if (type == ActivePortItem::Type)\r\n    {\r\n        deleteSelectedAdHocPorts(selectedItems);\r\n    }\r\n    else if (type == StickyNote::Type)\r\n    {\r\n        removeSelectedNotes();\r\n    }\r\n    else if (type == Association::Type)\r\n    {\r\n        removeSelectedAssociations();\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HWDesignWidget::deleteSelectedComponentItems()\r\n//-----------------------------------------------------------------------------\r\nvoid HWDesignWidget::deleteSelectedComponentItems(QList<QGraphicsItem*> selectedItems)\r\n{\r\n    getDiagram()->clearSelection();\r\n\r\n    QSharedPointer<QUndoCommand> deleteCommand(new QUndoCommand());\r\n\r\n    for (QGraphicsItem* selected : selectedItems)\r\n    {\r\n        auto component = static_cast<HWComponentItem*>(selected);\r\n        getDiagram()->clearSelection();\r\n\r\n        auto componentDeleteCommand = new ComponentDeleteCommand(\r\n            getDiagram(), getDiagram()->getLayout()->findColumnAt(component->scenePos()),\r\n            component, deleteCommand.data());\r\n\r\n        connect(componentDeleteCommand, SIGNAL(componentInstanceRemoved(ComponentItem*)),\r\n            this, SIGNAL(componentInstanceRemoved(ComponentItem*)), Qt::UniqueConnection);\r\n        connect(componentDeleteCommand, SIGNAL(componentInstantiated(ComponentItem*)),\r\n            this, SIGNAL(componentInstantiated(ComponentItem*)), Qt::UniqueConnection);\r\n\r\n        componentDeleteCommand->redo();\r\n\r\n        for(Association* association : component->getAssociations())\r\n        {\r\n            QUndoCommand* associationDeleteCommand = new AssociationRemoveCommand(association,\r\n                getDiagram(), componentDeleteCommand);\r\n            associationDeleteCommand->redo();\r\n        }\r\n    }\r\n\r\n    getEditProvider()->addCommand(deleteCommand);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HWDesignWidget::deleteSelectedBusInterfaceItems()\r\n//-----------------------------------------------------------------------------\r\nvoid HWDesignWidget::deleteSelectedBusInterfaceItems(QList<QGraphicsItem*> selectedItems)\r\n{\r\n    // Enumerate all ports that are part of the selected bus interfaces.\r\n    QStringList ports;\r\n\r\n    for (auto const& selected : selectedItems)\r\n    {\r\n        auto diagIf = static_cast<HierarchicalBusInterfaceItem*>(selected);\r\n\r\n        for (auto const& portName : diagIf->getBusInterface()->getAllMappedPhysicalPorts())\r\n        {\r\n            if (!ports.contains(portName))\r\n            {\r\n                ports.append(portName);\r\n            }\r\n        }\r\n    }\r\n\r\n    // Ask confirmation for port deletion from the user if there were ports in any of the bus interfaces.\r\n    bool removePorts = false;\r\n\r\n    if (!ports.isEmpty())\r\n    {\r\n        QMessageBox msgBox(QMessageBox::Warning, QCoreApplication::applicationName(),\r\n            tr(\"Do you want to delete also the ports that are part of the interfaces?\"),\r\n            QMessageBox::Yes | QMessageBox::No, this);\r\n\r\n        QStringList textList(\"Interface ports:\");\r\n\r\n        for(QString const& port : ports)\r\n        {\r\n            textList.append(\"* \" + port);\r\n        }\r\n\r\n        msgBox.setDetailedText(textList.join(\"\\n\"));\r\n        removePorts = (msgBox.exec() == QMessageBox::Yes);\r\n    }\r\n\r\n    // Delete the interfaces.\r\n    getDiagram()->clearSelection();\r\n    QSharedPointer<QUndoCommand> cmd(new QUndoCommand());\r\n\r\n    for (QGraphicsItem* selected : selectedItems)\r\n    {\r\n        auto diagIf = static_cast<HierarchicalBusInterfaceItem*>(selected);\r\n\r\n        auto childCmd =\r\n            new InterfaceDeleteCommand(getDiagram(), diagIf, removePorts, cmd.data());\r\n        connect(childCmd, SIGNAL(interfaceDeleted()), this, SIGNAL(clearItemSelection()), Qt::UniqueConnection);            \r\n\r\n        static_cast<HWDesignDiagram*>(getDiagram())->setInterfacesHaveBeenDeleted();\r\n        childCmd->redo();\r\n    }\r\n\r\n    getEditProvider()->addCommand(cmd);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HWDesignWidget::deleteSelectedBusPortItems()\r\n//-----------------------------------------------------------------------------\r\nvoid HWDesignWidget::deleteSelectedBusPortItems(QList<QGraphicsItem*> selectedItems)\r\n{\r\n    getDiagram()->clearSelection();\r\n    QSharedPointer<QUndoCommand> cmd(new QUndoCommand());\r\n\r\n    for (QGraphicsItem* selected : selectedItems)\r\n    {\r\n        auto port = static_cast<ActiveBusInterfaceItem*>(selected);\r\n\r\n        // Ports can be removed only if they are temporary.\r\n        if (port->isTemporary())\r\n        {\r\n            // Delete the port.\r\n            QUndoCommand* childCmd = new PortDeleteCommand(getDiagram(), port, cmd.data());\r\n            childCmd->redo();\r\n        }\r\n    }\r\n\r\n    getEditProvider()->addCommand(cmd);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HWDesignWidget::deleteSelectedHWConnectionItems()\r\n//-----------------------------------------------------------------------------\r\nvoid HWDesignWidget::deleteSelectedHWConnectionItems(QList<QGraphicsItem*> selectedItems)\r\n{\r\n    getDiagram()->clearSelection();\r\n    QSharedPointer<QUndoCommand> cmd(new QUndoCommand());\r\n\r\n    for (QGraphicsItem* selected : selectedItems)\r\n    {\r\n        // Delete the interconnection.\r\n        auto conn = static_cast<HWConnection*>(selected);\r\n        auto endpoint1 = static_cast<HWConnectionEndpoint*>(conn->endpoint1());\r\n        auto endpoint2 = static_cast<HWConnectionEndpoint*>(conn->endpoint2());\r\n\r\n        QUndoCommand* childCmd = new ConnectionDeleteCommand(getDiagram(), conn, cmd.data());\r\n        childCmd->redo();\r\n\r\n        // If the bus ports are invalid, delete them too.\r\n        if (endpoint1->isInvalid())\r\n        {\r\n            QUndoCommand* rmCmd = 0;\r\n\r\n            if (endpoint1->type() == ActiveBusInterfaceItem::Type)\r\n            {\r\n                rmCmd = new PortDeleteCommand(getDiagram(), endpoint1, cmd.data());\r\n            }\r\n            else\r\n            {\r\n                rmCmd = new InterfaceDeleteCommand(\r\n                    getDiagram(), static_cast<HierarchicalBusInterfaceItem*>(endpoint1), false, cmd.data());\r\n            }\r\n\r\n            rmCmd->redo();\r\n        }\r\n\r\n        if (endpoint2->isInvalid())\r\n        {\r\n            QUndoCommand* rmCmd = 0;\r\n\r\n            if (endpoint2->type() == ActiveBusInterfaceItem::Type)\r\n            {\r\n                rmCmd = new PortDeleteCommand(getDiagram(), endpoint2, cmd.data());\r\n            }\r\n            else\r\n            {\r\n                rmCmd = new InterfaceDeleteCommand(\r\n                    getDiagram(), static_cast<HierarchicalBusInterfaceItem*>(endpoint2), false, cmd.data());\r\n            }\r\n\r\n            rmCmd->redo();\r\n        }\r\n    }\r\n\r\n    getEditProvider()->addCommand(cmd);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HWDesignWidget::deleteSelectedAdHocConnectionItems()\r\n//-----------------------------------------------------------------------------\r\nvoid HWDesignWidget::deleteSelectedAdHocConnectionItems(QList<QGraphicsItem*> selectedItems)\r\n{\r\n    getDiagram()->clearSelection();\r\n    QSharedPointer<QUndoCommand> cmd(new QUndoCommand());\r\n\r\n    for (QGraphicsItem* selected : selectedItems)\r\n    {\r\n        auto conn = static_cast<AdHocConnectionItem*>(selected);\r\n\r\n        QUndoCommand* childCmd = new AdHocConnectionDeleteCommand(getDiagram(), conn, cmd.data());\r\n        childCmd->redo();\r\n    }\r\n\r\n    getEditProvider()->addCommand(cmd);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HWDesignWidget::deleteSelectedHWColumns()\r\n//-----------------------------------------------------------------------------\r\nvoid HWDesignWidget::deleteSelectedHWColumns(QList<QGraphicsItem*> selectedItems)\r\n{\r\n    // Ask a confirmation if the user really wants to delete the entire column if it is not empty.\r\n    for (QGraphicsItem* selected : selectedItems)\r\n    {\r\n        auto column = static_cast<HWColumn*>(selected);\r\n        if (!column->isEmpty())\r\n        {\r\n            QMessageBox msgBox(QMessageBox::Warning, QCoreApplication::applicationName(),\r\n                tr(\"The columns are not empty. Do you want to delete the columns and all of their contents?\"),\r\n                QMessageBox::Yes | QMessageBox::No, this);\r\n\r\n            if (msgBox.exec() == QMessageBox::No)\r\n            {\r\n                return;\r\n            }\r\n\r\n            break;\r\n        }\r\n    }\r\n\r\n    // Delete the columns.\r\n    getDiagram()->clearSelection();\r\n    QSharedPointer<QUndoCommand> parentCommand(new QUndoCommand());\r\n\r\n    for (QGraphicsItem* selected : selectedItems)\r\n    {\r\n        HWColumn* column = static_cast<HWColumn*>(selected);\r\n        QUndoCommand* columnRemoveCommand = new ColumnDeleteCommand(getDiagram(), \r\n            getDiagram()->getLayout().data(), column, parentCommand.data());\r\n        columnRemoveCommand->redo();\r\n    }\r\n\r\n    getEditProvider()->addCommand(parentCommand);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HWDesignWidget::deleteSelectedAdhocInterfaces()\r\n//-----------------------------------------------------------------------------\r\nvoid HWDesignWidget::deleteSelectedAdhocInterfaces(QList<QGraphicsItem*> selectedItems)\r\n{\r\n    QList<HierarchicalPortItem*> adhocDeleteList;\r\n\r\n    for (QGraphicsItem* selected : selectedItems)\r\n    {\r\n        HierarchicalPortItem* adhocItem = static_cast<HierarchicalPortItem*>(selected);\r\n        if (adhocItem && !adhocItem->adhocPortIsValid())\r\n        {\r\n            adhocDeleteList.append(adhocItem);\r\n        }\r\n    }\r\n\r\n    if (!adhocDeleteList.isEmpty())\r\n    {\r\n        getDiagram()->clearSelection();\r\n\r\n        QSharedPointer<QUndoCommand> parentCommand(new QUndoCommand());\r\n        for (HierarchicalPortItem* interfaceItem : adhocDeleteList)\r\n        {\r\n            new AdHocVisibilityChangeCommand(getDiagram(), interfaceItem->name(), false, parentCommand.data());\r\n        }\r\n\r\n        parentCommand->redo();\r\n\r\n        getEditProvider()->addCommand(parentCommand);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HWDesignWidget::deleteSelectedAdHocPorts()\r\n//-----------------------------------------------------------------------------\r\nvoid HWDesignWidget::deleteSelectedAdHocPorts(QList<QGraphicsItem*> selectedItems)\r\n{\r\n    QList<ActivePortItem*> adhocDeleteList;\r\n    for (QGraphicsItem* selected : selectedItems)\r\n    {\r\n        auto adHocItem = static_cast<ActivePortItem*>(selected);\r\n        if (adHocItem && !adHocItem->adhocPortIsValid())\r\n        {\r\n            adhocDeleteList.append(adHocItem);\r\n        }\r\n    }\r\n\r\n    if (!adhocDeleteList.isEmpty())\r\n    {\r\n        auto containingItem = dynamic_cast<HWComponentItem*>(adhocDeleteList.first()->parentItem());\r\n        if (containingItem)\r\n        {\r\n            getDiagram()->clearSelection();\r\n\r\n            QSharedPointer<QUndoCommand> parentCommand (new QUndoCommand());\r\n            for (ActivePortItem* portItem : adhocDeleteList)\r\n            {\r\n                new AdHocVisibilityChangeCommand(containingItem, portItem->name(), false, parentCommand.data());\r\n            }\r\n\r\n            parentCommand->redo();\r\n\r\n            getEditProvider()->addCommand(parentCommand);\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HWDesignWidget::createEmptyDesign()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<Component> HWDesignWidget::createEmptyDesign(VLNV const& prevlnv)\r\n{    \r\n\tVLNV vlnv;\r\n\tQString path;\r\n\r\n\tif (prevlnv.isValid() && getLibHandler()->contains(prevlnv)) \r\n    {\r\n\t\tvlnv = prevlnv;\r\n\t\tpath = getLibHandler()->getPath(prevlnv);\r\n\r\n\t\tQFileInfo info(path);\r\n\t\tpath = info.absolutePath();\r\n\t}\r\n\telse\r\n    {\r\n        NewObjectDialog newDesignDialog(getLibHandler(), VLNV::COMPONENT, true, parentWidget());\r\n\t\tnewDesignDialog.setVLNV(prevlnv);\r\n\t\tnewDesignDialog.exec();\r\n\r\n\t\tif (newDesignDialog.result() == QDialog::Rejected)\r\n        {\r\n\t\t\treturn QSharedPointer<Component>();\r\n        }\r\n\r\n\t\tvlnv = newDesignDialog.getVLNV();\r\n\t\tpath = newDesignDialog.getPath();\r\n\t}\r\n\r\n\tQSharedPointer<Component> newComponent;\r\n\t\r\n\tif (getLibHandler()->contains(prevlnv))\r\n    {\r\n\t\t// find the component\r\n\t\tQSharedPointer<Document> libComp = getLibHandler()->getModel(prevlnv);\r\n\t\tnewComponent = libComp.staticCast<Component>();\r\n\r\n\t\tQ_ASSERT_X(newComponent, \"HWDesignWidget::createEmptyDesign\",\r\n\t\t\t\"The selected library item has to be component\");\r\n\t}\r\n\telse \r\n    {\r\n\t\t// create the component \r\n\t\tnewComponent = QSharedPointer<Component>(new Component(vlnv, getEditedComponent()->getRevision()));\r\n\t}\r\n\r\n    getLibHandler()->writeModelToFile(path, newComponent);\r\n\r\n\tcreateDesignForComponent(newComponent, path);\r\n\r\n    return newComponent;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HWDesignWidget::createDesignForComponent()\r\n//-----------------------------------------------------------------------------\r\nvoid HWDesignWidget::createDesignForComponent(QSharedPointer<Component> component, const QString& dirPath)\r\n{\r\n\tVLNV vlnv = component->getVlnv();\r\n\r\n\t// create a unique vlnv for the design\r\n\tVLNV designVLNV(VLNV::DESIGN, vlnv.getVendor(), vlnv.getLibrary(),\r\n\t\tvlnv.getName().remove(\".comp\") + \".design\", vlnv.getVersion());\r\n\r\n\tint runningNumber = 1;\r\n\tQString version = designVLNV.getVersion();\r\n\r\n\t// if vlnv is reserved then add \"(<number>)\" to end of version field\r\n\twhile (getLibHandler()->contains(designVLNV))\r\n    {\r\n\t\t++runningNumber;\r\n\t\tdesignVLNV.setVersion(version + \"(\" + QString::number(runningNumber) + \")\");\r\n\t}\r\n\r\n\t// create a unique vlnv for the design configuration\r\n\tVLNV desConfVLNV(VLNV::DESIGNCONFIGURATION, vlnv.getVendor(), vlnv.getLibrary(),\r\n\t\tvlnv.getName().remove(\".comp\") + \".designcfg\", vlnv.getVersion());\r\n\r\n\trunningNumber = 1;\r\n\tversion = desConfVLNV.getVersion();\r\n\r\n\t// if vlnv is reserved then add \"(<number>)\" to end of version field\r\n\twhile (getLibHandler()->contains(desConfVLNV))\r\n    {\r\n\t\t++runningNumber;\r\n\t\tdesConfVLNV.setVersion(version + \"(\" + QString::number(runningNumber) + \")\");\r\n\t}\r\n\r\n\t// the name of the view to create\r\n\tQString viewName = NameGenerationPolicy::hierarchicalViewName();\r\n    QString configurationName = NameGenerationPolicy::designConfigurationInstantiationName(viewName);\r\n\r\n\t// and a hierarchical view for it\r\n\tQSharedPointer<Model> model = component->getModel();\r\n\tQ_ASSERT(model);\r\n\r\n\tQSharedPointer<View> hierView(new View(viewName));\r\n    hierView->setDesignConfigurationInstantiationRef(configurationName);\r\n    \r\n    QSharedPointer<DesignConfigurationInstantiation> configuration(new DesignConfigurationInstantiation());\r\n    configuration->setName(configurationName);\r\n    configuration->setDesignConfigurationReference(\r\n        QSharedPointer<ConfigurableVLNVReference>(new ConfigurableVLNVReference(desConfVLNV)));\r\n\r\n\tmodel->getViews()->append(hierView);\r\n\r\n\t// create the design configuration\r\n\tauto designConf = QSharedPointer<DesignConfiguration>(new DesignConfiguration(desConfVLNV, component->getRevision()));\r\n\tdesignConf->setDesignRef(designVLNV);\r\n\r\n\tauto newDesign = QSharedPointer<Design>(new Design(designVLNV, component->getRevision()));\r\n\r\n\tgetLibHandler()->writeModelToFile(dirPath, newDesign);\r\n\tgetLibHandler()->writeModelToFile(dirPath, designConf);\r\n    getLibHandler()->writeModelToFile(component);\r\n\r\n\tsetDesign(component, viewName);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HWDesignWidget::updateFiles()\r\n//-----------------------------------------------------------------------------\r\nvoid HWDesignWidget::updateFiles(QSharedPointer<Component> topComponent, QString const& sourcePath,\r\n    QString const& targetPath) const\r\n{\r\n    QDir sourceDirectory(sourcePath);\r\n\r\n    for (QSharedPointer<FileSet> fileSet : *topComponent->getFileSets())\r\n    {\r\n        for (QSharedPointer<File> componentFile : *fileSet->getFiles())\r\n        {\r\n            QString filePath = componentFile->name();            \r\n            QString absoluteSource = sourceDirectory.absoluteFilePath(filePath);\r\n\r\n            // If file is located under the source directory.\r\n            if (!filePath.contains(QLatin1String(\"../\")))\r\n            {\r\n                QDir targetDirectory(targetPath);\r\n                QString absoluteTarget = targetDirectory.absoluteFilePath(filePath);\r\n\r\n                QFileInfo targetInfo(absoluteTarget);\r\n\r\n                targetDirectory.mkpath(targetInfo.absolutePath());\r\n                QFile::copy(absoluteSource, absoluteTarget);\r\n\r\n            }\r\n            // if file is higher in directory hierarchy than the source directory.\r\n            else\r\n            {\r\n                componentFile->setName(absoluteSource);\r\n            }\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HWDesignWidget::loadChangesFromSibling()\r\n//-----------------------------------------------------------------------------\r\nvoid HWDesignWidget::loadChangesFromRelatedTab()\r\n{\r\n    // Load updated component from disk\r\n    if (auto libraryComponent = getLibHandler()->getModelReadOnly<Component>(getEditedComponent()->getVlnv()))\r\n    {\r\n        loadBusInterfaceChanges(libraryComponent);\r\n        loadPortChanges(libraryComponent);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HWDesignWidget::loadBusInterfaceChanges()\r\n//-----------------------------------------------------------------------------\r\nvoid HWDesignWidget::loadBusInterfaceChanges(QSharedPointer<Component const> libraryComponent)\r\n{\r\n    auto design = getDiagram()->getDesign();\r\n    auto designComponentInterfaces = QList<QSharedPointer<BusInterface> >(*getEditedComponent()->getBusInterfaces());\r\n    auto libraryComponentInterfaces = QList<QSharedPointer<BusInterface> >(*libraryComponent->getBusInterfaces());\r\n\r\n    // First check for added interfaces\r\n    for (auto const& compBusif : libraryComponentInterfaces)\r\n    {\r\n        // Replace if found with same name\r\n        if (auto foundInterface = Search::findByName(compBusif->name(), designComponentInterfaces))\r\n        {\r\n            designComponentInterfaces.removeOne(foundInterface);\r\n        }\r\n\r\n        designComponentInterfaces.append(compBusif);\r\n    }\r\n\r\n    auto hwDiagram = static_cast<HWDesignDiagram*>(getDiagram());\r\n   \r\n    // Remove deleted interfaces (aka if interface exists in design component but not in component loaded from disk).\r\n    for (auto designComponentInterfaceIt = designComponentInterfaces.begin(); designComponentInterfaceIt != designComponentInterfaces.end();)\r\n    {\r\n        if (auto foundInterface = Search::findByName((*designComponentInterfaceIt)->name(), libraryComponentInterfaces);\r\n            foundInterface == nullptr)\r\n        {\r\n            // Remove connections and routes from design, if interface had no connections\r\n            if (auto endpointItem = hwDiagram->getHierarchicalInterface((*designComponentInterfaceIt)->name()))\r\n            {\r\n                auto busItem = static_cast<HierarchicalBusInterfaceItem*>(endpointItem);\r\n\r\n                if (auto const& connections = busItem->getConnections(); connections.isEmpty())\r\n                {\r\n                    design->removeInterfaceGraphicsData((*designComponentInterfaceIt)->name());\r\n                    for (auto const& connection : busItem->getConnections())\r\n                    {\r\n                        auto interconnectionItem = static_cast<HWConnection*>(connection);\r\n                        design->removeRoute(interconnectionItem->getRouteExtension());\r\n                        design->getInterconnections()->removeOne(interconnectionItem->getInterconnection());\r\n                    }\r\n                }\r\n\r\n                hwDiagram->removeItem(busItem);\r\n            }\r\n\r\n            designComponentInterfaceIt = designComponentInterfaces.erase(designComponentInterfaceIt);\r\n        }\r\n        else\r\n        {\r\n            ++designComponentInterfaceIt;\r\n        }\r\n    }\r\n\r\n    QSharedPointer<QList<QSharedPointer<BusInterface> > >newBuses(new QList(designComponentInterfaces));\r\n    getEditedComponent()->setBusInterfaces(newBuses);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HWDesignWidget::loadPortChanges()\r\n//-----------------------------------------------------------------------------\r\nvoid HWDesignWidget::loadPortChanges(QSharedPointer<Component const> libraryComponent)\r\n{\r\n    auto design = getDiagram()->getDesign();\r\n    auto designComponentPorts = QList<QSharedPointer<Port> >(*getEditedComponent()->getPorts());\r\n    auto libraryComponentPorts = QList<QSharedPointer<Port> >(*libraryComponent->getPorts());\r\n\r\n    // First check for added ports\r\n    for (auto const& compPort : libraryComponentPorts)\r\n    {\r\n        // Replace if found with same name\r\n        if (auto foundPort = Search::findByName(compPort->name(), designComponentPorts))\r\n        {\r\n            designComponentPorts.removeOne(foundPort);\r\n        }\r\n\r\n        designComponentPorts.append(compPort);\r\n    }\r\n\r\n    // Remove deleted ports (aka if port exists in design component but not in component loaded from disk)\r\n    for (auto designComponentPortIt = designComponentPorts.begin(); designComponentPortIt != designComponentPorts.end();)\r\n    {\r\n        if (auto foundPort = Search::findByName((*designComponentPortIt)->name(), libraryComponentPorts);\r\n            foundPort == nullptr)\r\n        {\r\n            // Remove from design\r\n            auto adHocVisibilities = getDiagram()->getDesign()->getAdHocPortPositions().dynamicCast<Kactus2Group>();\r\n            for (auto const& adHocVisibility : adHocVisibilities->getByType(\"kactus2:adHocVisible\"))\r\n            {\r\n                if (adHocVisibility.dynamicCast<Kactus2Placeholder>()->getAttributeValue(\"portName\") == (*designComponentPortIt)->name())\r\n                {\r\n                    adHocVisibilities->removeFromGroup(adHocVisibility);\r\n                    break;\r\n                }\r\n            }\r\n\r\n            designComponentPortIt = designComponentPorts.erase(designComponentPortIt);\r\n        }\r\n        else\r\n        {\r\n            // Update adhoc visibility\r\n            auto adHocVisibilitiesDesignGroup = getDiagram()->getDesign()->getAdHocPortPositions().dynamicCast<Kactus2Group>();\r\n            auto adHocVisibilitiesDesign = adHocVisibilitiesDesignGroup->getByType(\"kactus2:adHocVisible\");\r\n\r\n            auto portVisibilityDesign = std::find_if(adHocVisibilitiesDesign.cbegin(), adHocVisibilitiesDesign.cend(),\r\n                [&foundPort](QSharedPointer<VendorExtension> extension)\r\n                {\r\n                    return extension.dynamicCast<Kactus2Placeholder>()->getAttributeValue(\"portName\") == foundPort->name();\r\n                });\r\n\r\n            bool visibleInDesign = portVisibilityDesign != adHocVisibilitiesDesign.cend();\r\n            auto oldComponentPort = getEditedComponent()->getPort(foundPort->name());\r\n\r\n            if (!oldComponentPort)\r\n            {\r\n                ++designComponentPortIt;\r\n                continue;\r\n            }\r\n\r\n            bool visibleInOldComponent = oldComponentPort->isAdHocVisible();\r\n            bool visibleInUpdatedComponent = foundPort->isAdHocVisible();\r\n\r\n            // AdHoc visible, if visible in updated component or in design\r\n            // AdHoc not visible, if was visible in design and old component, but not new component\r\n            if (visibleInDesign && visibleInOldComponent && !visibleInUpdatedComponent)\r\n            {\r\n                adHocVisibilitiesDesignGroup->removeFromGroup(*portVisibilityDesign);\r\n            }\r\n\r\n            ++designComponentPortIt;\r\n        }\r\n    }\r\n\r\n    QSharedPointer<QList<QSharedPointer<Port> > >newPortsQ(new QList(designComponentPorts));\r\n    getEditedComponent()->setPorts(newPortsQ);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HWDesignWidget::addColumn()\r\n//-----------------------------------------------------------------------------\r\nvoid HWDesignWidget::addColumn()\r\n{\r\n    ColumnEditDialog dialog(this, false);\r\n\r\n    if (dialog.exec() == QDialog::Accepted)\r\n    {\r\n        int columnWidth = GraphicsColumnConstants::COMPONENT_COLUMN_WIDTH;\r\n\r\n        if (dialog.getContentType() == ColumnTypes::IO)\r\n        {\r\n            columnWidth = GraphicsColumnConstants::IO_COLUMN_WIDTH;\r\n        }\r\n\r\n        QSharedPointer<ColumnDesc> desc(new ColumnDesc(dialog.name(), dialog.getContentType(), \r\n            dialog.getAllowedItems(), columnWidth));\r\n\r\n        getDiagram()->addColumn(desc);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HWDesignWidget::getSupportedDrawModes()\r\n//-----------------------------------------------------------------------------\r\nunsigned int HWDesignWidget::getSupportedDrawModes() const\r\n{\r\n    if (isProtected())\r\n    {\r\n        // Force to selection mode in read-only mode.\r\n        return MODE_SELECT;        \r\n    }\r\n    else\r\n    {\r\n        return (MODE_SELECT | MODE_CONNECT | MODE_INTERFACE | MODE_DRAFT | MODE_TOGGLE_OFFPAGE | MODE_LABEL);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HWDesignWidget::getImplementation()\r\n//-----------------------------------------------------------------------------\r\nKactusAttribute::Implementation HWDesignWidget::getImplementation() const\r\n{\r\n    return KactusAttribute::HW;\r\n}\r\n"
  },
  {
    "path": "editors/HWDesign/HWDesignWidget.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: designwidget.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: \r\n// Date: \r\n//\r\n// Description:\r\n// HWDesignWidget is used to edit and view one design\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef HWDESIGNWIDGET_H\r\n#define HWDESIGNWIDGET_H\r\n\r\n#include <IPXACTmodels/common/VLNV.h>\r\n\r\n#include \"HWDesignDiagram.h\"\r\n\r\n#include <editors/common/DesignWidget.h>\r\n\r\n#include <QString>\r\n#include <QKeyEvent>\r\n#include <QSharedPointer>\r\n\r\nclass LibraryInterface;\r\nclass VLNV;\r\nclass Component;\r\nclass HWComponentItem;\r\nclass ActiveBusInterfaceItem;\r\nclass DesignConfiguration;\r\nclass ExpressionParser;\r\nclass MultipleParameterFinder;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! HWDesignWidget is used to edit and view one design\r\n//-----------------------------------------------------------------------------\r\nclass HWDesignWidget : public DesignWidget\r\n{\r\n    Q_OBJECT\r\n\r\npublic:\r\n\r\n    /*!\r\n     *  The constructor.\r\n     *\r\n     *    @param [in] lh                                  The library interface.\r\n     *    @param [in] designAndInstancesParameterFinder   Parameter finder for design parameter reference tree.\r\n     *    @param [in] designParameterFinder               Design parameter finder.\r\n     *    @param [in] parent                              Owner of this object.\r\n     */\r\n    HWDesignWidget(LibraryInterface *lh, QSharedPointer<MultipleParameterFinder> designAndIsntancesParameterFinder,\r\n        QSharedPointer<ListParameterFinder> designParameterFinder, QWidget *parent = 0);\r\n\r\n\t/*!\r\n     *  The destructor.\r\n     */\r\n\tvirtual ~HWDesignWidget() = default;\r\n\r\n    //! No mutants allowed.\r\n    HWDesignWidget(const HWDesignWidget&) = delete;\r\n    HWDesignWidget& operator=(const HWDesignWidget&) = delete;\r\n\r\n\t/*!\r\n     *  Set the design to be displayed in the block diagram\r\n\t *\r\n\t *    @param [in] vlnv        VLNV of the design to open\r\n\t *    @param [in] viewName    Name of the view to open within component.\r\n\t */\r\n\tbool setDesign(VLNV const& vlnv, QString const& viewName) final;\r\n    \r\n    /*!\r\n     *  Called when a new column is requested to be added to the design.\r\n     */\r\n    void addColumn() final;\r\n\r\n    /*!\r\n     *  Returns the supported draw modes.\r\n     */\r\n    unsigned int getSupportedDrawModes() const final;\r\n\r\n    /*!\r\n     *  Returns the implementation attribute.\r\n     */\r\n    KactusAttribute::Implementation getImplementation() const final;\r\n\r\nsignals:\r\n    \r\n    /*!\r\n     *  Emitted when user wants to refresh this widget\r\n\t *\r\n\t *    @param [in] designWidget    Pointer to this HWDesignWidget instance\r\n\t */\r\n\tvoid refresh(const HWDesignWidget* designWidget);\r\n\r\npublic slots:\r\n    \r\n    //! Saves the design as new object.\r\n\tbool saveAs() final;\r\n\r\n    /*!\r\n     *  Handler for item deletion in the design diagram.\r\n     */\r\n    void onDeleteSelectedItems() final;\r\n\r\nprotected:\r\n    \r\n    /*!\r\n     *  Handler for key press event.\r\n     *\r\n     *    @param [in] event   The selected key event.\r\n     */\r\n    void keyPressEvent(QKeyEvent *event);\r\n\r\nprivate:\r\n\r\n\r\n    /*!\r\n     *  Delete the selected component items.\r\n     *\r\n     *    @param [in] selectedItems   The selected graphics items.\r\n     */\r\n    void deleteSelectedComponentItems(QList<QGraphicsItem*> selectedItems);\r\n\r\n    /*!\r\n     *  Delete the selected bus interface items.\r\n     *\r\n     *    @param [in] selectedItems   The selected graphics items.\r\n     */\r\n    void deleteSelectedBusInterfaceItems(QList<QGraphicsItem*> selectedItems);\r\n\r\n    /*!\r\n     *  Delete the selected bus port items.\r\n     *\r\n     *    @param [in] selectedItems   The selected graphics items.\r\n     */\r\n    void deleteSelectedBusPortItems(QList<QGraphicsItem*> selectedItems);\r\n\r\n    /*!\r\n     *  Delete the selected HW connection items.\r\n     *\r\n     *    @param [in] selectedItems   The selected graphics items.\r\n     */\r\n    void deleteSelectedHWConnectionItems(QList<QGraphicsItem*> selectedItems);\r\n\r\n    /*!\r\n     *  Delete the selected ad hoc connection items.\r\n     *\r\n     *    @param [in] selectedItems   The selected graphics items.\r\n     */\r\n    void deleteSelectedAdHocConnectionItems(QList<QGraphicsItem*> selectedItems);\r\n\r\n    /*!\r\n     *  Delete the selected HW column items.\r\n     *\r\n     *    @param [in] selectedItems   The selected graphics items.\r\n     */\r\n    void deleteSelectedHWColumns(QList<QGraphicsItem*> selectedItems);\r\n\r\n    /*!\r\n     *  Delete the selected ad hoc interface items. Only invalid interfaces can be deleted.\r\n     *\r\n     *    @param [in] selectedItems   A list of the selected items.\r\n     */\r\n    void deleteSelectedAdhocInterfaces(QList<QGraphicsItem*> selectedItems);\r\n\r\n    /*!\r\n     *  Delete the selected ad hoc port items. Only invalid ports can be deleted.\r\n     *\r\n     *    @param [in] selectedItems   A list of the selected items.\r\n     */\r\n    void deleteSelectedAdHocPorts(QList<QGraphicsItem*> selectedItems);\r\n\r\n    /*!\r\n     *  Create an empty hierarchical component.\r\n     *\r\n     *    @return Pointer to the created component.\r\n     */\r\n    QSharedPointer<Component> createEmptyDesign(VLNV const& prevlnv);\r\n\r\n    /*!\r\n     *  Set a design to be edited.\r\n     *\r\n     *    @param [in] comp        The selected component.\r\n     *    @param [in] viewName    The name of the view containing the design.\r\n     *\r\n     *    @return True, if the design is set correctly, false if an error occurred.\r\n     */\r\n    bool setDesign(QSharedPointer<Component> comp, const QString& viewName);\r\n\r\n\t/*!\r\n     *  Create an empty design and configuration for a component.\r\n\t *\r\n\t *    @param [in] component   Pointer to the component to create the design for.\r\n\t *    @param [in] dirPath     File path to the directory to create the design and configuration to.\r\n\t */\r\n\tvoid createDesignForComponent(QSharedPointer<Component> component, const QString& dirPath);\r\n\r\n    /*!\r\n     *  Update the files.\r\n     *\r\n     *    @param [in] topComponent        The top component of the design.\r\n     *    @param [in] sourcePath          The source path.\r\n     *    @param [in] targetPath          The target directory.\r\n     */\r\n    void updateFiles(QSharedPointer<Component> topComponent, QString const& sourcePath,\r\n        QString const& targetPath) const;\r\n\r\n    /*!\r\n     *\tLoad changes made in component editor to be applied to design before refresh and save.\r\n     */\r\n    void loadChangesFromRelatedTab() override;\r\n\r\n    /*!\r\n     *\tLoad bus interface changes made in the component editor. Checks for removed and added bus interfaces.\r\n     *  \r\n     *    @param [in] libraryComponent     The component loaded from disk.\r\n     */\r\n    void loadBusInterfaceChanges(QSharedPointer<Component const> libraryComponent);\r\n\r\n    /*!\r\n     *\tLoad adhoc port changes made in the component editor. Checks for removed and added ports.\r\n     *\r\n     *    @param [in] libraryComponent     The component loaded from disk.\r\n     */\r\n    void loadPortChanges(QSharedPointer<Component const> libraryComponent);\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! The expression parser for the top component.\r\n    QSharedPointer<ExpressionParser> expressionParser_ = nullptr;\r\n};\r\n\r\n#endif // HWDESIGNWIDGET_H\r\n"
  },
  {
    "path": "editors/HWDesign/HWMoveCommands.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: HWMoveCommands.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Joni-Matti Maatta\r\n// Date: 4.8.2011\r\n//\r\n// Description:\r\n// Undo move commands for the design diagram.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"HWMoveCommands.h\"\r\n\r\n#include \"HWConnection.h\"\r\n#include \"HWComponentItem.h\"\r\n#include \"columnview/HWColumn.h\"\r\n\r\n#include <common/graphicsItems/GraphicsColumnConstants.h>\r\n\r\n#include <editors/common/DesignDiagram.h>\r\n#include <editors/HWDesign/HWConnectionEndpoint.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ItemMoveCommand()\r\n//-----------------------------------------------------------------------------\r\nPortMoveCommand::PortMoveCommand(HWConnectionEndpoint* port, QPointF const& oldPos, DesignDiagram* diagram,\r\n    QUndoCommand* parent):\r\nQUndoCommand(parent),\r\nport_(port),\r\noldPos_(oldPos),\r\nnewPos_(port->pos()),\r\ndiagram_(diagram)\r\n{\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PortMoveCommand::PortMoveCommand()\r\n//-----------------------------------------------------------------------------\r\nPortMoveCommand::PortMoveCommand(HWConnectionEndpoint* port, QPointF const& oldPos, QPointF const& newPos,\r\n    DesignDiagram* diagram, QUndoCommand* parent):\r\nQUndoCommand(parent),\r\nport_(port),\r\noldPos_(oldPos),\r\nnewPos_(newPos),\r\ndiagram_(diagram)\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ~PortMoveCommand()\r\n//-----------------------------------------------------------------------------\r\nPortMoveCommand::~PortMoveCommand()\r\n{\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: undo()\r\n//-----------------------------------------------------------------------------\r\nvoid PortMoveCommand::undo()\r\n{\r\n    HWComponentItem* comp = static_cast<HWComponentItem*>(port_->parentItem());\r\n    if (comp)\r\n    {\r\n        port_->setPos(oldPos_);\r\n        comp->onMovePort(port_);\r\n    }\r\n\r\n    // Execute child commands.\r\n    QUndoCommand::undo();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: redo()\r\n//-----------------------------------------------------------------------------\r\nvoid PortMoveCommand::redo()\r\n{\r\n    HWComponentItem* comp = static_cast<HWComponentItem*>(port_->parentItem());\r\n    if (comp)\r\n    {\r\n        port_->setPos(newPos_);\r\n        comp->onMovePort(port_);\r\n    }\r\n\r\n    // Execute child commands.\r\n    QUndoCommand::redo();\r\n\r\n    if (port_->scenePos().y() + GraphicsColumnConstants::MIN_Y_PLACEMENT > port_->scene()->height())\r\n    {\r\n        diagram_->resetSceneRectangleForItems();\r\n    }\r\n}\r\n"
  },
  {
    "path": "editors/HWDesign/HWMoveCommands.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: HWMoveCommands.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Joni-Matti Maatta\r\n// Date: 4.8.2011\r\n//\r\n// Description:\r\n// Undo move commands for the design diagram.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef HWMOVECOMMANDS_H\r\n#define HWMOVECOMMANDS_H\r\n\r\n#include <QUndoCommand>\r\n#include <QGraphicsItem>\r\n#include <QGraphicsScene>\r\n#include <QString>\r\n\r\nclass HWConnection;\r\nclass HWComponentItem;\r\nclass HWConnectionEndpoint;\r\nclass IGraphicsItemStack;\r\nclass DesignDiagram;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! PortMoveCommand class.\r\n//-----------------------------------------------------------------------------\r\nclass PortMoveCommand : public QUndoCommand\r\n{\r\npublic:\r\n    /*!\r\n     *  Constructor which assumes that the port has already been moved to its new position.\r\n     *\r\n     *    @param [in] port        The port to move.\r\n     *    @param [in] oldPos      The port's old position.\r\n     *    @param [in] diagram     Diagram containing the scene of the port.\r\n     *    @param [in] parent      The parent command.\r\n     */\r\n    PortMoveCommand(HWConnectionEndpoint* port, QPointF const& oldPos, DesignDiagram* diagram,\r\n        QUndoCommand* parent = 0);\r\n\r\n    /*!\r\n     *  Constructor.\r\n     *\r\n     *    @param [in] port        The port to move.\r\n     *    @param [in] oldPos      The port's old position.\r\n     *    @param [in] newPos      The port's new position.\r\n     *    @param [in] diagram     Diagram containing the scene of the port.\r\n     *    @param [in] parent      The parent command.\r\n     */\r\n    PortMoveCommand(HWConnectionEndpoint* port, QPointF const& oldPos, QPointF const& newPos,\r\n        DesignDiagram* diagram, QUndoCommand* parent = 0);\r\n\r\n    /*!\r\n     *  Destructor.\r\n     */\r\n    ~PortMoveCommand();\r\n\r\n    /*!\r\n     *  Undoes the command.\r\n     */\r\n    virtual void undo();\r\n\r\n    /*!\r\n     *  Redoes the command.\r\n     */\r\n    virtual void redo();\r\n\r\nprivate:\r\n    // Disable copying.\r\n    PortMoveCommand(PortMoveCommand const& rhs);\r\n    PortMoveCommand& operator=(PortMoveCommand const& rhs);\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! The graphics port.\r\n    HWConnectionEndpoint* port_;\r\n\r\n    //! The old position of the port.\r\n    QPointF oldPos_;\r\n\r\n    //! The new position of the port.\r\n    QPointF newPos_;\r\n\r\n    //! Diagram containing the scene of the port.\r\n    DesignDiagram* diagram_;\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n\r\n#endif // HWMOVECOMMANDS_H\r\n"
  },
  {
    "path": "editors/HWDesign/HierarchicalBusInterfaceItem.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: diagraminterface.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Joni-Matti Maatta\r\n// Date: 17.3.2011\r\n//\r\n// Description:\r\n// Diagram interface graphics item.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"HierarchicalBusInterfaceItem.h\"\r\n\r\n#include \"HWMoveCommands.h\"\r\n#include \"HWDesignDiagram.h\"\r\n\r\n#include \"columnview/HWColumn.h\"\r\n\r\n#include <common/IEditProvider.h>\r\n\r\n#include <common/graphicsItems/GraphicsConnection.h>\r\n#include <common/graphicsItems/GraphicsColumnLayout.h>\r\n#include <common/graphicsItems/CommonGraphicsUndoCommands.h>\r\n\r\n#include <editors/common/diagramgrid.h>\r\n#include <editors/common/DesignDiagram.h>\r\n#include <editors/common/GraphicsItemLabel.h>\r\n#include <KactusAPI/include/BusInterfaceUtilities.h>\r\n\r\n#include <KactusAPI/include/LibraryInterface.h>\r\n\r\n#include <IPXACTmodels/BusDefinition/BusDefinition.h>\r\n\r\n#include <IPXACTmodels/Component/BusInterface.h>\r\n#include <IPXACTmodels/Component/Component.h>\r\n\r\n#include <IPXACTmodels/kactusExtensions/InterfaceGraphicsData.h>\r\n\r\n#include <QGraphicsScene>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HierarchicalBusInterfaceItem::HierarchicalBusInterfaceItem()\r\n//-----------------------------------------------------------------------------\r\nHierarchicalBusInterfaceItem::HierarchicalBusInterfaceItem(QSharedPointer<Component> component,\r\n    QSharedPointer<BusInterface> busIf, QSharedPointer<InterfaceGraphicsData> dataGroup, LibraryInterface* library,\r\n    QGraphicsItem *parent, bool isDraft):\r\nBusInterfaceEndPoint(busIf, component, library, isDraft, parent),\r\ndataGroup_(dataGroup)\r\n{\r\n    HierarchicalBusInterfaceItem::setTemporary(busIf == 0);\r\n    setTypeLocked(busIf != 0 && busIf->getInterfaceMode() != General::INTERFACE_MODE_COUNT);\r\n    setPolygon(HierarchicalBusInterfaceItem:: getDirectionOutShape());\r\n\r\n    dataGroup_->setName(busIf->name());\r\n\r\n    if (dataGroup_->hasPosition())\r\n    {\r\n        setPos(dataGroup_->getPosition());\r\n    }\r\n  \r\n    HierarchicalBusInterfaceItem::setDirection(QVector2D(1,0));\r\n\r\n\tgetNameLabel()->setRotation(-rotation());\r\n\r\n    HierarchicalBusInterfaceItem::updateInterface();\r\n}\r\n\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HierarchicalBusInterfaceItem::updateName()\r\n//-----------------------------------------------------------------------------\r\nvoid HierarchicalBusInterfaceItem::updateName(QString const&, QString const& newName)\r\n{\r\n    dataGroup_->setName(newName);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HierarchicalBusInterfaceItem::createMoveCommandForClashedItem()\r\n//-----------------------------------------------------------------------------\r\nvoid HierarchicalBusInterfaceItem::createMoveCommandForClashedItem(ConnectionEndpoint* endPoint, QPointF endPointPosition,\r\n    DesignDiagram* diagram, QSharedPointer<QUndoCommand> parentCommand)\r\n{\r\n    if (endPoint && endPoint->isHierarchical() && endPoint->pos() != endPointPosition)\r\n    {\r\n        auto itemColumn = dynamic_cast<HWColumn*>(endPoint->parentItem());\r\n        if (itemColumn)\r\n        {\r\n            new ItemMoveCommand(endPoint, endPointPosition, itemColumn, diagram, parentCommand.data());\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HierarchicalBusInterfaceItem::canConnectToInterface()\r\n//-----------------------------------------------------------------------------\r\nbool HierarchicalBusInterfaceItem::canConnectToInterface(ConnectionEndpoint const* otherEndPoint) const\r\n{\r\n    QSharedPointer<BusInterface> bus = getBusInterface();\r\n    QSharedPointer<const BusDefinition> busDefinition;\r\n    QSharedPointer<BusInterface> otherInterface = otherEndPoint->getBusInterface();\r\n\r\n    if (bus)\r\n    {\r\n        busDefinition = getLibraryAccess()->getModelReadOnly<BusDefinition>(bus->getBusType());\r\n    }\r\n\r\n    return (otherInterface &&\r\n            (getBusInterface()->getInterfaceMode() == General::INTERFACE_MODE_COUNT ||\r\n            !otherInterface->getBusType().isValid() ||\r\n            (busDefinition && BusInterfaceUtilities::hasMatchingBusDefinitions(\r\n                busDefinition, otherInterface->getBusType(), getLibraryAccess()))));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HierarchicalBusInterfaceItem::isHierarchical()\r\n//-----------------------------------------------------------------------------\r\nbool HierarchicalBusInterfaceItem::isHierarchical() const noexcept\r\n{\r\n    return true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HierarchicalBusInterfaceItem::setDirection()\r\n//-----------------------------------------------------------------------------\r\nvoid HierarchicalBusInterfaceItem::setDirection(QVector2D const& dir)\r\n{\r\n    BusInterfaceEndPoint::setDirection(dir);\r\n\r\n    dataGroup_->setDirection(dir);\r\n\r\n    setLabelPosition();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HierarchicalBusInterfaceItem::setLabelPosition()\r\n//-----------------------------------------------------------------------------\r\nvoid HierarchicalBusInterfaceItem::setLabelPosition()\r\n{\r\n    qreal nameWidth = getNameLabel()->boundingRect().width();\r\n    qreal nameHeight = getNameLabel()->boundingRect().height();\r\n\r\n    // Check if the port is directed to the left.\r\n    if (getDirection().x() < 0)\r\n    {\r\n        getNameLabel()->setPos(-nameHeight / 2 + 2, GridSize * 3.0 / 4.0 - nameWidth / 2.0);\r\n    }\r\n    // Otherwise the port is directed to the right.\r\n    else\r\n    {\r\n        getNameLabel()->setPos(nameHeight / 2 - 2, GridSize * 3.0 / 4.0 + nameWidth / 2.0);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HierarchicalBusInterfaceItem::getDataExtension()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<VendorExtension> HierarchicalBusInterfaceItem::getDataExtension() const\r\n{\r\n    return dataGroup_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HierarchicalBusInterfaceItem::itemChange()\r\n//-----------------------------------------------------------------------------\r\nQVariant HierarchicalBusInterfaceItem::itemChange(GraphicsItemChange change, QVariant const& value)\r\n{\r\n    if (change == ItemPositionChange)\r\n    {\r\n        return snapPointToGrid(value.toPointF());\r\n    }\r\n    else if (change == ItemRotationHasChanged)\r\n    {\r\n        getNameLabel()->setRotation(-rotation());\r\n\r\n        dataGroup_->setDirection(getDirection());\r\n    }\r\n    else if (change == ItemScenePositionHasChanged)\r\n    {   \r\n        dataGroup_->setPosition(value.toPointF());\r\n\r\n        updateConnectionPositions();\r\n    }\r\n\r\n    return QGraphicsItem::itemChange(change, value);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HierarchicalBusInterfaceItem::mousePressEvent()\r\n//-----------------------------------------------------------------------------\r\nvoid HierarchicalBusInterfaceItem::mousePressEvent(QGraphicsSceneMouseEvent *event)\r\n{\r\n    HWConnectionEndpoint::mousePressEvent(event);\r\n    setZValue(1001.0);\r\n\r\n    oldColumn_ = dynamic_cast<HWColumn*>(parentItem());\r\n    setOldPosition(scenePos());\r\n    Q_ASSERT(oldColumn_ != 0);\r\n\r\n    saveOldPortPositions(scene()->items());\r\n    \r\n    beginUpdateConnectionPositions();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HierarchicalBusInterfaceItem::moveItemByMouse()\r\n//-----------------------------------------------------------------------------\r\nvoid HierarchicalBusInterfaceItem::moveItemByMouse()\r\n{\r\n    setPos(parentItem()->mapFromScene(oldColumn_->mapToScene(pos())));\r\n\r\n    auto column = dynamic_cast<HWColumn*>(parentItem());\r\n    if (column)\r\n    {\r\n        column->onMoveItem(this);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HierarchicalBusInterfaceItem::createMouseMoveCommand()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<QUndoCommand> HierarchicalBusInterfaceItem::createMouseMoveCommand(DesignDiagram* diagram)\r\n{\r\n    if (!oldColumn_)\r\n    {\r\n        return QSharedPointer<QUndoCommand>();\r\n    }\r\n\r\n    auto column = dynamic_cast<HWColumn*>(parentItem());\r\n    Q_ASSERT(column != 0);\r\n    column->onReleaseItem(this);\r\n\r\n    QSharedPointer<QUndoCommand> cmd;\r\n\r\n    // Check if the interface position was really changed.\r\n    if (getOldPosition() != scenePos())\r\n    {\r\n        cmd = QSharedPointer<QUndoCommand>(new ItemMoveCommand(this, getOldPosition(), oldColumn_, diagram));\r\n    }\r\n    else\r\n    {\r\n        cmd = QSharedPointer<QUndoCommand>(new QUndoCommand());\r\n    }\r\n\r\n    return cmd;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HierarchicalBusInterfaceItem::getCurrentPosition()\r\n//-----------------------------------------------------------------------------\r\nQPointF HierarchicalBusInterfaceItem::getCurrentPosition() const\r\n{\r\n    return scenePos();\r\n}\r\n"
  },
  {
    "path": "editors/HWDesign/HierarchicalBusInterfaceItem.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: HierarchicalBusInterfaceItem.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Joni-Matti Maatta\r\n// Date: 17.3.2011\r\n//\r\n// Description:\r\n// Diagram interface graphics item.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef HIERARCHICALBUSINTERFACEITEM_H\r\n#define HIERARCHICALBUSINTERFACEITEM_H\r\n\r\n#include <common/graphicsItems/GraphicsItemTypes.h>\r\n\r\n#include <editors/HWDesign/BusInterfaceEndPoint.h>\r\n\r\n#include <IPXACTmodels/common/DirectionTypes.h>\r\n\r\n#include <QGraphicsPolygonItem>\r\n#include <QSharedPointer>\r\n#include <QVector2D>\r\n\r\nclass BusInterface;\r\nclass HWComponentItem;\r\nclass HWColumn;\r\nclass Component;\r\nclass LibraryInterface;\r\nclass InterfaceGraphicsData;\r\nclass DesignDiagram;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! BusInterfaceItem class.\r\n//-----------------------------------------------------------------------------\r\nclass HierarchicalBusInterfaceItem : public BusInterfaceEndPoint\r\n{\r\n    Q_OBJECT\r\n\r\npublic:\r\n    enum { Type = GFX_TYPE_DIAGRAM_INTERFACE };\r\n\r\n    /*!\r\n     *  The constructor.\r\n     *\r\n     *    @param [in] component   The component containing the bus interface this item represents.\r\n     *    @param [in] busIf       The bus interface this item represents.\r\n     *    @param [in] dataGroup   The container for the item data.\r\n     *    @param [in] library     Access to the library.\r\n     *    @param [in] parent      The parent object.\r\n     *    @param [in] isDraft     Determines if Bus Interface is draft or not.\r\n     */\r\n    HierarchicalBusInterfaceItem(QSharedPointer<Component> component, QSharedPointer<BusInterface> busIf,\r\n        QSharedPointer<InterfaceGraphicsData> dataGroup, LibraryInterface* library, QGraphicsItem *parent = 0, bool isDraft=false);\r\n\r\n\t/*!\r\n     *  The destructor.\r\n     */\r\n\t~HierarchicalBusInterfaceItem() final = default;\r\n\r\n    // Disable copying.\r\n    HierarchicalBusInterfaceItem(HierarchicalBusInterfaceItem const& rhs) = delete;\r\n    HierarchicalBusInterfaceItem& operator=(HierarchicalBusInterfaceItem const& rhs) = delete;\r\n\r\n    /*!\r\n     *  Get the graphics item type of this item.\r\n     *\r\n     *    @return The graphics item type of this item.\r\n     */\r\n    int type() const final { return Type; }\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // HWConnectionEndpoint implementation.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    /*!\r\n     *  Returns true if the port represents a hierarchical connection\r\n     */\r\n    bool isHierarchical() const noexcept final;\r\n\r\n    /*!\r\n     *  Set the direction for the bus interface item.\r\n     *\r\n     *    @param [in] dir     The new direction.\r\n     */\r\n    void setDirection(QVector2D const& dir);\r\n\r\n\t/*!\r\n\t * Set the position of the name label.\r\n\t */\r\n\tvoid setLabelPosition() final;\r\n\r\n    /*!\r\n     *  Gets the data extension for the bus interface.\r\n     *\r\n     *    @return The data vendor extension.\r\n     */\r\n    QSharedPointer<VendorExtension> getDataExtension() const;\r\n\r\nprotected:\r\n    \r\n    /*!\r\n     *  Notifies item state changes.\r\n     *\r\n     *    @param [in] change  The change.\r\n     *    @param [in] value   The new value.\r\n     */\r\n    QVariant itemChange(GraphicsItemChange change, QVariant const& value) final;\r\n\r\n    /*!\r\n     *  Event for mouse press.\r\n     *\r\n     *    @param [in] event   The pressed mouse button.\r\n     */\r\n    void mousePressEvent(QGraphicsSceneMouseEvent *event) final;\r\n\r\nprivate:\r\n\r\n    /*!\r\n     *  Update the name change to the relevant contained variables.\r\n     *\r\n     *    @param [in] previousName    The previous name of the bus interface.\r\n     *    @param [in] newName         The new name of the bus interface.\r\n     */\r\n    void updateName(QString const& previousName, QString const& newName) final;\r\n\r\n    /*!\r\n     *  Move by dragging with the mouse.\r\n     */\r\n    void moveItemByMouse() final;\r\n\r\n    /*!\r\n     *  Create a move command for this end point item.\r\n     *\r\n     *    @param [in] diagram     The containing design diagram.\r\n     *\r\n     *    @return The created move command.\r\n     */\r\n    QSharedPointer<QUndoCommand> createMouseMoveCommand(DesignDiagram* diagram) final;\r\n\r\n    /*!\r\n     *  Create move command for an end point that has been moved by the movement of this end point.\r\n     *\r\n     *    @param [in] endPoint            The selected end point.\r\n     *    @param [in] endPointPosition    The new position of the end point.\r\n     *    @param [in] diagram             Design diagram containing the end point.\r\n     *    @param [in] parentCommand       Parent command.\r\n     */\r\n    void createMoveCommandForClashedItem(ConnectionEndpoint* endPoint, QPointF endPointPosition,\r\n        DesignDiagram* diagram, QSharedPointer<QUndoCommand> parentCommand) final;\r\n\r\n    /*!\r\n     *  Check if a connection can be made to the selected connection end point.\r\n     *\r\n     *    @param [in] otherEndPoint   The selected connection end point.\r\n     *\r\n     *    @return True, if the connection can be made, false otherwise.\r\n     */\r\n    bool canConnectToInterface(ConnectionEndpoint const* otherEndPoint) const final;\r\n\r\n    /*!\r\n     *  Get the current position of the end point.\r\n     *\r\n     *    @return The current position of the end point.\r\n     */\r\n    QPointF getCurrentPosition() const final;\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! The data extension for the item.\r\n    QSharedPointer<InterfaceGraphicsData> dataGroup_ = nullptr;\r\n\r\n    //! The old column from where the mouse drag event began.\r\n    HWColumn* oldColumn_ = nullptr;\r\n};\r\n\r\n#endif // HIERARCHICALBUSINTERFACEITEM_H\r\n"
  },
  {
    "path": "editors/HWDesign/HierarchicalPortItem.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: HierarchicalPortItem.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Joni-Matti Maatta\r\n// Date: 9.2.2012\r\n//\r\n// Description:\r\n// Diagram graphics item for ad-hoc ports.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"HierarchicalPortItem.h\"\r\n\r\n#include <common/IEditProvider.h>\r\n#include <common/graphicsItems/GraphicsConnection.h>\r\n#include <common/graphicsItems/GraphicsColumn.h>\r\n#include <common/graphicsItems/CommonGraphicsUndoCommands.h>\r\n\r\n#include <editors/common/diagramgrid.h>\r\n#include <editors/common/DesignDiagram.h>\r\n#include <editors/common/GraphicsItemLabel.h>\r\n\r\n#include <IPXACTmodels/kactusExtensions/Kactus2Placeholder.h>\r\n\r\n#include <QBrush>\r\n#include <QVector2D>\r\n#include <QGraphicsScene>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HierarchicalPortItem::HierarchicalPortItem()\r\n//-----------------------------------------------------------------------------\r\nHierarchicalPortItem::HierarchicalPortItem(QSharedPointer<Component> component, QSharedPointer<Port> port,\r\n    QSharedPointer<Kactus2Placeholder> dataGroup, QGraphicsItem* parent):\r\nAdHocItem(port, component, parent, QVector2D(1.0f, 0.0f)),\r\ndataGroup_(dataGroup)\r\n{\r\n    if (dataGroup_->getAttributeValue(QStringLiteral(\"portName\")).isEmpty())\r\n    {\r\n        dataGroup_->setAttribute(QStringLiteral(\"portName\"), getPort()->name());\r\n    }\r\n\r\n    if (!dataGroup_->getAttributeValue(QStringLiteral(\"x\")).isEmpty())\r\n    {\r\n        QPointF position(dataGroup_->getAttributeValue(QStringLiteral(\"x\")).toInt(),\r\n            dataGroup_->getAttributeValue(QStringLiteral(\"y\")).toInt());\r\n        setPos(position);\r\n    }\r\n\r\n    getNameLabel()->setRotation(-rotation());\r\n\r\n    setPolygon(getPortShape());\r\n\r\n    updateInterface();\r\n}\r\n\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HierarchicalPortItem::isHierarchical()\r\n//-----------------------------------------------------------------------------\r\nbool HierarchicalPortItem::isHierarchical() const noexcept\r\n{\r\n    return true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HierarchicalPortItem::setDirection()\r\n//-----------------------------------------------------------------------------\r\nvoid HierarchicalPortItem::setDirection(QVector2D const& dir)\r\n{\r\n    HWConnectionEndpoint::setDirection(dir);\r\n    setLabelPosition();\r\n    setTieOffLabelPosition();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HierarchicalPortItem::isDirectionFixed()\r\n//-----------------------------------------------------------------------------\r\nbool HierarchicalPortItem::isDirectionFixed() const noexcept\r\n{\r\n    return false;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HierarchicalPortItem::setLabelPosition()\r\n//-----------------------------------------------------------------------------\r\nvoid HierarchicalPortItem::setLabelPosition()\r\n{\r\n    qreal nameWidth = getNameLabel()->boundingRect().width();\r\n    qreal nameHeight = getNameLabel()->boundingRect().height();\r\n\r\n    // Check if the port is directed to the left.\r\n    if (getDirection().x() < 0)\r\n    {\r\n        getNameLabel()->setPos(-nameHeight / 2 + 4, GridSize * 3.0 / 4.0 - nameWidth / 2.0);\r\n    }\r\n    // Otherwise the port is directed to the right.\r\n    else\r\n    {\r\n        getNameLabel()->setPos(nameHeight / 2 - 4, GridSize * 3.0 / 4.0 + nameWidth / 2.0);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HierarchicalPortItem::itemChange()\r\n//-----------------------------------------------------------------------------\r\nQVariant HierarchicalPortItem::itemChange(GraphicsItemChange change, QVariant const& value)\r\n{\r\n    if (change == ItemPositionChange)\r\n    {\r\n        return snapPointToGrid(value.toPointF());\r\n    }\r\n    else if (change == ItemRotationHasChanged)\r\n    {\r\n        getNameLabel()->setRotation(-rotation());\r\n        if (getTieOffLabel() != nullptr)\r\n        {\r\n            getTieOffLabel()->setRotation(-rotation());\r\n        }\r\n    }\r\n    else if (change == ItemScenePositionHasChanged)\r\n    {\r\n        dataGroup_->setAttribute(\"x\", QString::number(value.toPointF().x()));\r\n        dataGroup_->setAttribute(\"y\", QString::number(value.toPointF().y()));\r\n\r\n        updateConnectionPositions();\r\n    }\r\n\r\n    return QGraphicsItem::itemChange(change, value);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HierarchicalPortItem::saveOldPortPositions()\r\n//-----------------------------------------------------------------------------\r\nvoid HierarchicalPortItem::saveOldPortPositions()\r\n{\r\n    setZValue(1001.0);\r\n\r\n    oldColumn_ = dynamic_cast<GraphicsColumn*>(parentItem());\r\n    oldPos_ = scenePos();\r\n    Q_ASSERT(oldColumn_ != nullptr);\r\n\r\n    for (QGraphicsItem* item : scene()->items())\r\n    {\r\n        if (item->type() == GFX_TYPE_DIAGRAM_INTERFACE || item->type() == HierarchicalPortItem::Type)\r\n        {\r\n            oldInterfacePositions_.insert(item, item->scenePos());\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HierarchicalPortItem::moveItemByMouse()\r\n//-----------------------------------------------------------------------------\r\nvoid HierarchicalPortItem::moveItemByMouse()\r\n{\r\n    setPos(parentItem()->mapFromScene(oldColumn_->mapToScene(pos())));\r\n\r\n    auto column = dynamic_cast<GraphicsColumn*>(parentItem());\r\n    Q_ASSERT(column != 0);\r\n    column->onMoveItem(this);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HierarchicalPortItem::mouseReleaseEvent()\r\n//-----------------------------------------------------------------------------\r\nvoid HierarchicalPortItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)\r\n{\r\n    HWConnectionEndpoint::mouseReleaseEvent(event);\r\n    setZValue(0.0);\r\n\r\n    auto diagram = dynamic_cast<DesignDiagram*>(scene());\r\n    if (diagram && oldColumn_ != nullptr)\r\n    {\r\n        auto column = dynamic_cast<GraphicsColumn*>(parentItem());\r\n        Q_ASSERT(column != nullptr);\r\n        column->onReleaseItem(this);\r\n\r\n        QSharedPointer<QUndoCommand> cmd;\r\n\r\n        // Check if the interface position was really changed.\r\n        if (oldPos_ != scenePos())\r\n        {\r\n            cmd = QSharedPointer<QUndoCommand>(new ItemMoveCommand(this, oldPos_, oldColumn_, diagram));\r\n        }\r\n        else\r\n        {\r\n            cmd = QSharedPointer<QUndoCommand>(new QUndoCommand());\r\n        }\r\n\r\n        // Determine if the other interfaces changed their position and create undo commands for them.\r\n        QMap<QGraphicsItem*, QPointF>::iterator cur = oldInterfacePositions_.begin();\r\n        while (cur != oldInterfacePositions_.end())\r\n        {\r\n            if (cur.key()->scenePos() != cur.value())\r\n            {\r\n                new ItemMoveCommand(cur.key(), cur.value(), oldColumn_, diagram, cmd.data());\r\n            }\r\n\r\n            cur++;\r\n        }\r\n\r\n        // End the position update for all connections.\r\n        endUpdateConnectionPositions(cmd.data());\r\n\r\n        // Add the undo command to the edit stack only if it has changes.\r\n        if (cmd->childCount() > 0 || oldPos_ != scenePos())\r\n        {\r\n            diagram->getEditProvider()->addCommand(cmd);\r\n            cmd->redo();\r\n        }\r\n\r\n        oldColumn_ = nullptr;\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HierarchicalPortItem::getDataGroup()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<Kactus2Placeholder> HierarchicalPortItem::getDataGroup() const\r\n{\r\n    return dataGroup_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HierarchicalPortItem::setDataGroup()\r\n//-----------------------------------------------------------------------------\r\nvoid HierarchicalPortItem::setDataGroup(QSharedPointer<Kactus2Placeholder> newDataGroup)\r\n{\r\n    dataGroup_ = newDataGroup;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HierarchicalPortItem::labelShouldBeDrawnLeft()\r\n//-----------------------------------------------------------------------------\r\nbool HierarchicalPortItem::labelShouldBeDrawnLeft() const\r\n{\r\n    return getDirection().x() < 0;\r\n}\r\n"
  },
  {
    "path": "editors/HWDesign/HierarchicalPortItem.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: HierarchicalPortItem.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Joni-Matti Maatta\r\n// Date: 9.2.2012\r\n//\r\n// Description:\r\n// Diagram graphics item for ad-hoc ports.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef HIERARCHICALPORTITEM_H\r\n#define HIERARCHICALPORTITEM_H\r\n\r\n#include <QSharedPointer>\r\n#include <QVector2D>\r\n#include <QPolygonF>\r\n\r\n#include <editors/HWDesign/AdHocItem.h>\r\n\r\n#include <common/graphicsItems/GraphicsItemTypes.h>\r\n\r\nclass GraphicsColumn;\r\nclass Kactus2Placeholder;\r\nclass Port;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! HierarchicalPortItem class.\r\n//-----------------------------------------------------------------------------\r\nclass HierarchicalPortItem : public AdHocItem\r\n{\r\n    Q_OBJECT\r\n\r\npublic:\r\n    enum { Type = GFX_TYPE_DIAGRAM_ADHOC_INTERFACE };\r\n\r\n    /*!\r\n     *  The constructor.\r\n     *\r\n     *    @param [in] component   The component containing the ad hoc port.\r\n     *    @param [in] port        The selected port.\r\n     *    @param [in] dataGroup   The visibility data group of the item.\r\n     *    @param [in] parent      The owner of this item.\r\n     */\r\n    HierarchicalPortItem(QSharedPointer<Component> component, QSharedPointer<Port> port,\r\n        QSharedPointer<Kactus2Placeholder> dataGroup, QGraphicsItem* parent = 0);\r\n\r\n\t/*!\r\n     *  The destructor.\r\n     */\r\n\t~HierarchicalPortItem() final = default;\r\n\r\n\t/*!\r\n\t *  Get the type of this graphics item.\r\n\t *\r\n     *    @return AdHoc interface item type.\r\n\t */\r\n\tint type() const { return Type; }\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // HWConnectionEndpoint implementation.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    /*! \r\n     *  Returns true if the port represents a hierarchical connection.\r\n     */\r\n    bool isHierarchical() const noexcept final;\r\n\r\n    /*!\r\n     *  Set the direction for this ad hoc interface item.\r\n     *\r\n     *    @param [in] dir     The new item direction.\r\n     */\r\n    void setDirection(QVector2D const& dir);\r\n\r\n    /*!\r\n     *  Returns true if the draw direction is fixed and thus, cannot be changed.\r\n     */\r\n    bool isDirectionFixed() const noexcept final;\r\n\r\n\t/*!\r\n\t *  Set the position of the name label.\r\n\t */\r\n\tvoid setLabelPosition();\r\n    \r\n    /*!\r\n     *  Get the visibility data group of the item.\r\n     *\r\n     *    @return The visibility data group of the item.\r\n     */\r\n    QSharedPointer<Kactus2Placeholder> getDataGroup() const;\r\n\r\n    /*!\r\n     *  Set a new visibility and position data group.\r\n     *\r\n     *    @param [in] newDataGroup    The new visibility and position data group.\r\n     */\r\n    void setDataGroup(QSharedPointer<Kactus2Placeholder> newDataGroup);\r\n\r\nprotected:\r\n\r\n    /*!\r\n     *  Notifies item state changes.\r\n     *\r\n     *    @param [in] change  The change.\r\n     *    @param [in] value   The new value.\r\n     */\r\n    QVariant itemChange(GraphicsItemChange change, QVariant const& value) final;\r\n\r\n    /*!\r\n     *  Event for mouse button release.\r\n     *\r\n     *    @param [in] event   The release event.\r\n     */\r\n    void mouseReleaseEvent(QGraphicsSceneMouseEvent *event) final;\r\n\r\nprivate:\r\n\r\n    /*!\r\n     *  Check whether the label should be drawn on the left side of the interface.\r\n     *\r\n     *    @return True, if the label should be drawn to the left side.\r\n     */\r\n    bool labelShouldBeDrawnLeft() const final;\r\n\r\n    /*!\r\n     *  Move the ad hoc item by dragging with the mouse.\r\n     */\r\n    void moveItemByMouse() final;\r\n\r\n    /*!\r\n     *  Save the positions of the other associated ports.\r\n     */\r\n    void saveOldPortPositions() final;\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! The visibility data group of the item.\r\n    QSharedPointer<Kactus2Placeholder> dataGroup_ = nullptr;\r\n\r\n    //! The old column from where the mouse drag event began.\r\n    GraphicsColumn* oldColumn_ = nullptr;\r\n\r\n    //! The old positions of the other interfaces before mouse move.\r\n    QMap<QGraphicsItem*, QPointF> oldInterfacePositions_;\r\n\r\n    //! The position of the port before mouse move.\r\n    QPointF oldPos_;\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n\r\n#endif // HIERARCHICALPORTITEM_H\r\n"
  },
  {
    "path": "editors/HWDesign/InterfaceGraphics.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: InterfaceGraphics.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Esko Pekkarinen\r\n// Date: 04.09.2015\r\n//\r\n// Description:\r\n// <Short description of the class/file contents>\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef INTERFACEGRAPHICS_H\r\n#define INTERFACEGRAPHICS_H\r\n\r\n#include <IPXACTmodels/common/DirectionTypes.h>\r\n#include <IPXACTmodels/common/TransactionalTypes.h>\r\n\r\n#include <IPXACTmodels/Component/BusInterface.h>\r\n\r\nnamespace InterfaceGraphics\r\n{\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Function: getInterfaceDirection()\r\n    //-----------------------------------------------------------------------------\r\n    static DirectionTypes::Direction getInterfaceDirection(QSharedPointer<BusInterface> busInterface_, \r\n        QSharedPointer<Component> component) \r\n    {\r\n        DirectionTypes::Direction direction = DirectionTypes::DIRECTION_INVALID;\r\n\r\n        if (busInterface_->getAbstractionTypes() && !busInterface_->getAbstractionTypes()->isEmpty())\r\n        {\r\n            if (busInterface_->getAbstractionTypes()->size() != 1)\r\n            {\r\n                direction = DirectionTypes::INOUT;\r\n            }\r\n\r\n            else\r\n            {\r\n                QSharedPointer<AbstractionType> abstraction = busInterface_->getAbstractionTypes()->first();\r\n                for (auto const& portName : abstraction->getPhysicalPortNames())\r\n                {\r\n                    QSharedPointer<Port> port = component->getPort(portName);\r\n                    if (port != 0)\r\n                    {\r\n                        if (direction == DirectionTypes::DIRECTION_INVALID)\r\n                        {\r\n                            direction = port->getDirection();\r\n                        }\r\n                        else if (direction != port->getDirection())\r\n                        {\r\n                            return DirectionTypes::INOUT;\r\n                        }\r\n                    }\r\n                }\r\n            }\r\n        }\r\n\r\n        return direction;\r\n    }\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Function: getInterfaceInitiative()\r\n    //-----------------------------------------------------------------------------\r\n    static TransactionalTypes::Initiative getInterfaceInitiative(QSharedPointer<BusInterface> busInterface,\r\n        QSharedPointer<Component> component)\r\n    {\r\n        TransactionalTypes::Initiative initiative = TransactionalTypes::Initiative::INITIATIVE_INVALID;\r\n\r\n        if (busInterface->getAbstractionTypes() && !busInterface->getAbstractionTypes()->isEmpty())\r\n        {\r\n            if (busInterface->getAbstractionTypes()->size() != 1)\r\n            {\r\n                initiative = TransactionalTypes::Initiative::BOTH;\r\n            }\r\n\r\n            else\r\n            {\r\n                QSharedPointer<AbstractionType> abstraction = busInterface->getAbstractionTypes()->first();\r\n                for (auto const& portName : abstraction->getPhysicalPortNames())\r\n                {\r\n                    QSharedPointer<Port> port = component->getPort(portName);\r\n                    if (port != 0 && port->getTransactional() != 0)\r\n                    {\r\n                        TransactionalTypes::Initiative portInitiative =\r\n                            TransactionalTypes::strToInitiative(port->getTransactional()->getInitiative());\r\n                        if (initiative == TransactionalTypes::Initiative::INITIATIVE_INVALID)\r\n                        {\r\n                            initiative = portInitiative;\r\n                        }\r\n                        else if (initiative != portInitiative)\r\n                        {\r\n                            return TransactionalTypes::Initiative::BOTH;\r\n                        }\r\n                    }\r\n                }\r\n            }\r\n        }\r\n\r\n        return initiative;\r\n    }\r\n}\r\n\r\n#endif\r\n"
  },
  {
    "path": "editors/HWDesign/OffPageConnectorItem.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: OffPageConnectorItem.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Joni-Matti Maatta\r\n// Date: 9.1.2012\r\n//\r\n// Description:\r\n// Off-page connector for the block diagram.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"OffPageConnectorItem.h\"\r\n\r\n#include <common/graphicsItems/ComponentItem.h>\r\n#include <common/graphicsItems/GraphicsConnection.h>\r\n\r\n#include <editors/common/diagramgrid.h>\r\n\r\n#include <IPXACTmodels/Component/BusInterface.h>\r\n\r\n#include <QBrush>\r\n#include <QPen>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: OffPageConnectorItem::OffPageConnectorItem()\r\n//-----------------------------------------------------------------------------\r\nOffPageConnectorItem::OffPageConnectorItem(ConnectionEndpoint* parent):\r\nConnectionEndpoint(parent),\r\nparent_(parent)\r\n{\r\n    Q_ASSERT(parent != 0);\r\n\r\n    int squareSize = GridSize;\r\n    QPolygonF shape;\r\n    shape << QPointF(-squareSize / 2,  squareSize / 2)\r\n          << QPointF(-squareSize / 2, -squareSize / 2)\r\n          << QPointF( squareSize / 2, -squareSize / 2)\r\n          << QPointF( squareSize / 2,  squareSize / 2);\r\n    setPolygon(shape);\r\n\r\n    // Add a line as a child graphics item.\r\n    auto line = new QGraphicsLineItem(0.0, 0.0, 0.0, 3*GridSize, this);\r\n    line->setFlag(ItemStacksBehindParent);\r\n    \r\n    QPen newPen = line->pen();\r\n    newPen.setWidth(3);\r\n    line->setPen(newPen);\r\n\r\n    setFlag(ItemIsSelectable);\r\n    setFlag(ItemSendsGeometryChanges);\r\n    setFlag(ItemSendsScenePositionChanges);\r\n\r\n    OffPageConnectorItem::updateInterface();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: OffPageConnectorItem::updateInterface()\r\n//-----------------------------------------------------------------------------\r\nvoid OffPageConnectorItem::updateInterface()\r\n{\r\n    // Retrieve the correct brush from the parent diagram port.\r\n    setBrush(parent_->brush());\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: OffPageConnectorItem::name()\r\n//-----------------------------------------------------------------------------\r\nQString OffPageConnectorItem::name() const\r\n{\r\n    return parent_->name();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: OffPageConnectorItem::setName()\r\n//-----------------------------------------------------------------------------\r\nvoid OffPageConnectorItem::setName(QString const& name)\r\n{\r\n\tparent_->setName(name);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: OffPageConnectorItem::description()\r\n//-----------------------------------------------------------------------------\r\nQString OffPageConnectorItem::description() const\r\n{\r\n    return parent_->description();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: OffPageConnectorItem::setDescription()\r\n//-----------------------------------------------------------------------------\r\nvoid OffPageConnectorItem::setDescription(QString const& description)\r\n{\r\n    parent_->setDescription(description);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: OffPageConnectorItem::addConnection()\r\n//-----------------------------------------------------------------------------\r\nvoid OffPageConnectorItem::addConnection(GraphicsConnection* connection)\r\n{\r\n    ConnectionEndpoint::addConnection(connection);\r\n    connection->setRoutingMode(GraphicsConnection::ROUTING_MODE_OFFPAGE);\r\n\r\n    setVisible(true);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: OffPageConnectorItem::removeConnection()\r\n//-----------------------------------------------------------------------------\r\nvoid OffPageConnectorItem::removeConnection(GraphicsConnection* connection)\r\n{\r\n    ConnectionEndpoint::removeConnection(connection);\r\n    connection->setRoutingMode(GraphicsConnection::ROUTING_MODE_NORMAL);\r\n\r\n    if (getConnections().isEmpty())\r\n    {\r\n        setVisible(false);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: OffPageConnectorItem::onConnect()\r\n//-----------------------------------------------------------------------------\r\nbool OffPageConnectorItem::onConnect(ConnectionEndpoint const* other)\r\n{\r\n    return parent_->onConnect(other);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: OffPageConnectorItem::onDisonnect()\r\n//-----------------------------------------------------------------------------\r\nvoid OffPageConnectorItem::onDisconnect()\r\n{\r\n    parent_->onDisconnect();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: OffPageConnectorItem::isConnectionValid()\r\n//-----------------------------------------------------------------------------\r\nbool OffPageConnectorItem::isConnectionValid(ConnectionEndpoint const* other) const\r\n{\r\n    return parent_->isConnectionValid(other);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: OffPageConnectorItem::isExclusive()\r\n//-----------------------------------------------------------------------------\r\nbool OffPageConnectorItem::isExclusive() const\r\n{\r\n    return parent_->isExclusive();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: OffPageConnectorItem::setDirection()\r\n//-----------------------------------------------------------------------------\r\nvoid OffPageConnectorItem::setDirection(QVector2D const& dir)\r\n{\r\n    // Translate the direction to a valid one.\r\n    if (dir.x() < 0.0)\r\n    {\r\n        parent_->setDirection(QVector2D(-1.0f, 0.0f));\r\n    }\r\n    else\r\n    {\r\n        parent_->setDirection(QVector2D(1.0f, 0.0f));\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: OffPageConnectorItem::getDirection()\r\n//-----------------------------------------------------------------------------\r\nQVector2D OffPageConnectorItem::getDirection() const\r\n{\r\n    return parent_->getDirection();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: OffPageConnectorItem::isDirectionFixed()\r\n//-----------------------------------------------------------------------------\r\nbool OffPageConnectorItem::isDirectionFixed() const noexcept\r\n{\r\n    if (getConnections().isEmpty() == false)\r\n    {\r\n        return true;\r\n    }\r\n    else\r\n    {\r\n        return parent_->isDirectionFixed();\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: OffPageConnectorItem::encompassingComp()\r\n//-----------------------------------------------------------------------------\r\nComponentItem* OffPageConnectorItem::encompassingComp() const\r\n{\r\n    return parent_->encompassingComp();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: OffPageConnectorItem::getOwnerComponent()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<Component> OffPageConnectorItem::getOwnerComponent() const\r\n{\r\n    return parent_->getOwnerComponent();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: OffPageConnectorItem::getBusInterface()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<BusInterface> OffPageConnectorItem::getBusInterface() const\r\n{\r\n    return parent_->getBusInterface();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: OffPageConnectorItem::getPort()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<Port> OffPageConnectorItem::getPort() const\r\n{\r\n    return parent_->getPort();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: OffPageConnectorItem::getComInterface()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<ComInterface> OffPageConnectorItem::getComInterface() const\r\n{\r\n    return parent_->getComInterface();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: OffPageConnectorItem::getApiInterface()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<ApiInterface> OffPageConnectorItem::getApiInterface() const\r\n{\r\n    return parent_->getApiInterface();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: OffPageConnectorItem::isHierarchical()\r\n//-----------------------------------------------------------------------------\r\nbool OffPageConnectorItem::isHierarchical() const noexcept\r\n{\r\n    return parent_->isHierarchical();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: OffPageConnectorItem::getInterfaceMode()\r\n//-----------------------------------------------------------------------------\r\nGeneral::InterfaceMode OffPageConnectorItem::getInterfaceMode() const\r\n{\r\n    return parent_->getInterfaceMode();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: OffPageConnectorItem::itemChange()\r\n//-----------------------------------------------------------------------------\r\nQVariant OffPageConnectorItem::itemChange(GraphicsItemChange change, QVariant const& value)\r\n{\r\n    if (change == ItemScenePositionHasChanged)\r\n    {\r\n        updateConnectionPositions();\r\n    }\r\n\r\n    return QGraphicsItem::itemChange(change, value);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: OffPageConnectorItem::getType()\r\n//-----------------------------------------------------------------------------\r\nConnectionEndpoint::EndpointType OffPageConnectorItem::getType() const noexcept\r\n{\r\n    return parent_->getType();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: OffPageConnectorItem::isBus()\r\n//-----------------------------------------------------------------------------\r\nbool OffPageConnectorItem::isBus() const noexcept\r\n{\r\n    return parent_->isBus();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: OffPageConnectorItem::isAdHoc()\r\n//-----------------------------------------------------------------------------\r\nbool OffPageConnectorItem::isAdHoc() const noexcept\r\n{\r\n    return parent_->isAdHoc();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: OffPageConnectorItem::isCom()\r\n//-----------------------------------------------------------------------------\r\nbool OffPageConnectorItem::isCom() const noexcept\r\n{\r\n    return parent_->isCom();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: OffPageConnectorItem::isApi()\r\n//-----------------------------------------------------------------------------\r\nbool OffPageConnectorItem::isApi() const noexcept\r\n{\r\n    return parent_->isApi();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: OffPageConnectorItem::getParentConnector()\r\n//-----------------------------------------------------------------------------\r\nConnectionEndpoint* OffPageConnectorItem::getParentConnector() const\r\n{\r\n    return parent_;\r\n}\r\n"
  },
  {
    "path": "editors/HWDesign/OffPageConnectorItem.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: OffPageConnectorItem.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Joni-Matti Maatta\r\n// Date: 9.1.2012\r\n//\r\n// Description:\r\n// Off-page connector for the block diagram.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef OFFPAGECONNECTORITEM_H\r\n#define OFFPAGECONNECTORITEM_H\r\n\r\n#include <common/graphicsItems/ConnectionEndpoint.h>\r\n#include <common/graphicsItems/GraphicsItemTypes.h>\r\n\r\n#include <QSharedPointer>\r\n#include <QVector2D>\r\n#include <QPolygonF>\r\n\r\nclass BusInterface;\r\nclass HWComponentItem;\r\nclass HWConnectionEndpoint;\r\nclass LibraryInterface;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! OffPageConnectorItem class.\r\n//-----------------------------------------------------------------------------\r\nclass OffPageConnectorItem : public ConnectionEndpoint\r\n{\r\n    Q_OBJECT\r\n\r\npublic:\r\n    enum\r\n    {\r\n        Type = GFX_TYPE_DIAGRAM_OFF_PAGE_CONNECTOR\r\n    };\r\n\r\n    /*!\r\n     *  The constructor.\r\n     *\r\n     *    @param [in] parent  The parent connection endpoint.\r\n     */\r\n    explicit OffPageConnectorItem(ConnectionEndpoint* parent);\r\n\r\n\t/*!\r\n     *  The destructor.\r\n     */\r\n\t~OffPageConnectorItem() final = default;\r\n\r\n    // Disable copying.\r\n    OffPageConnectorItem(OffPageConnectorItem const& rhs) = delete;\r\n    OffPageConnectorItem& operator=(OffPageConnectorItem const& rhs) = delete;\r\n\r\n    /*! \r\n     *  Updates the graphics to match the IP-XACT bus interface.\r\n     */\r\n    void updateInterface();\r\n\r\n\tint type() const { return Type; }\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // HWConnectionEndpoint implementation.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    /*! \r\n     *  Returns the name of the parent bus interface.\r\n     */\r\n    QString name() const override;\r\n\r\n\t/*!\r\n\t *  Set the name of the parent bus interface.\r\n\t *\r\n     *    @param [in] name The name to set for the port.\r\n\t *\r\n\t*/\r\n\tvoid setName(QString const& name) override;\r\n\r\n\t/*! \r\n     *  Get the description of the port.\r\n\t *\r\n     *    @return QString containing the description.\r\n\t */\r\n\tQString description() const override;\r\n\r\n\t/*!\r\n\t *  Set the description for the port.\r\n     *\r\n\t *    @param [in] description The description to set.\r\n\t */\r\n\tvoid setDescription(QString const& description) override;\r\n\r\n    /*!\r\n     *  Attaches the endpoint to a connection.\r\n     *\r\n     *    @param [in] connection The connection.\r\n     */\r\n    void addConnection(GraphicsConnection* connection) override;\r\n\r\n    /*!\r\n     *  Unattaches the endpoint from a connection.\r\n     *\r\n     *    @param [in] connection The connection.\r\n     */\r\n    void removeConnection(GraphicsConnection* connection) override;\r\n\r\n    /*!\r\n     *  Called when a connection between this and another endpoint is done.\r\n     *\r\n     *    @param [in] other The other endpoint of the connection.\r\n     *\r\n     *    @return False if there was an error in the connection. Otherwise true.\r\n     */\r\n    bool onConnect(ConnectionEndpoint const* other) override;\r\n\r\n    /*!\r\n     *  Called when a connection has been removed from between this and another endpoint.\r\n     */\r\n    void onDisconnect() final;\r\n\r\n    /*!\r\n     *  Returns true if a connection is valid between the two endpoints.\r\n     *\r\n     *    @param [in] other The other endpoint.\r\n     *\r\n     *      @remarks Does not take existing connections into account but simply\r\n     *               validates whether a connection between the endpoints would be valid\r\n     *               in a general case.\r\n     */\r\n    bool isConnectionValid(ConnectionEndpoint const* other) const override;\r\n\r\n    /*!\r\n     *  Returns true if the endpoint is exclusive, i.e. can only have one connection.\r\n     */\r\n    bool isExclusive() const override;\r\n\r\n    /*!\r\n     *  Sets the draw direction of the endpoint.\r\n     *\r\n     *    @param [in] dir The draw direction to set.\r\n     *\r\n     *      @remarks The direction can be changed only if isDirectionFixed() returns false.\r\n     */\r\n    void setDirection(QVector2D const& dir) override;\r\n\r\n    /*!\r\n\t *\tReturns the draw direction of the endpoint.\r\n\t */\r\n\tvirtual QVector2D getDirection() const;\r\n      \r\n    /*!\r\n     *  Returns true if the draw direction is fixed and thus, cannot be changed.\r\n     */\r\n    bool isDirectionFixed() const noexcept override;\r\n\r\n    /*! \r\n     *  Returns the encompassing component, if it represents a bus interface on a component.\r\n     */\r\n    virtual ComponentItem* encompassingComp() const;\r\n\r\n\t/*!\r\n\t *  Returns pointer to the top component that owns this interface.\r\n\t *\r\n\t *    @return Pointer to the component to which this interface belongs to.\r\n\t*/\r\n\tvirtual QSharedPointer<Component> getOwnerComponent() const;\r\n\r\n    /*! \r\n     *  Returns the IP-XACT bus interface model of the parent diagram connection endpoint.\r\n     */\r\n    virtual QSharedPointer<BusInterface> getBusInterface() const;\r\n\r\n    /*!\r\n     *  Returns the ad-hoc port of the endpoint.\r\n     *\r\n     *      @remarks The function returns a null pointer if the endpoint is a bus interface.\r\n     *               Use isBus() function to check for ad-hoc support (isBus() == false).\r\n     */\r\n    virtual QSharedPointer<Port> getPort() const;\r\n\r\n    /*! \r\n     *  Returns the COM interface model of the endpoint.\r\n     *\r\n     *      @remarks The function returns a null pointer if the endpoint is not a COM interface.\r\n     *               Use isCom() function to check for COM interface support.\r\n     */\r\n    virtual QSharedPointer<ComInterface> getComInterface() const;\r\n\r\n    /*! \r\n     *  Returns the API interface model of the endpoint.\r\n     *\r\n     *      @remarks The function returns a null pointer if the endpoint is not a API interface.\r\n     *               Use isApi() function to check for API interface support.\r\n     */\r\n    virtual QSharedPointer<ApiInterface> getApiInterface() const;\r\n\r\n    /*!\r\n     *  Returns true if the port represents a hierarchical connection.\r\n     */\r\n    bool isHierarchical() const noexcept override;\r\n\r\n    /*!\r\n     *  Get the bus interface mode of the end point item.\r\n     *\r\n     *    @return The bus interface mode.\r\n     */\r\n    virtual General::InterfaceMode getInterfaceMode() const;\r\n\r\n    /*!\r\n     *  Get the type of the end point item.\r\n     *\r\n     *    @return The type of the end point item.\r\n     */\r\n    ConnectionEndpoint::EndpointType getType() const noexcept override;\r\n    \r\n    /*!\r\n     *  Check if the end point is a bus interface.\r\n     *\r\n     *    @return True, if the end point is a bus interface end point, otherwise false.\r\n     */\r\n    bool isBus() const noexcept override;\r\n\r\n    /*!\r\n     *  Check if the end point is an ad hoc.\r\n     *\r\n     *    @return True if the endpoint is an ad-hoc port, otherwise false.\r\n     */\r\n    bool isAdHoc() const noexcept override;\r\n\r\n    /*!\r\n     *  Check if the end point is a com interface.\r\n     *\r\n     *    @return True if the endpoint is a COM interface endpoint, otherwise false.\r\n     */\r\n    bool isCom() const noexcept override;\r\n\r\n    /*!\r\n     *  Check if the end point is an api interface.\r\n     *\r\n     *    @return True if the endpoint is an API interface endpoint, otherwise false.\r\n     */\r\n    bool isApi() const noexcept override;\r\n\r\n    /*!\r\n     *  Returns the corresponding parent connector.\r\n     *\r\n     *    @return     The parent connector.\r\n     */\r\n    virtual ConnectionEndpoint* getParentConnector() const;\r\n\r\nprotected:\r\n\r\n    /*!\r\n     *  Handle the item changes.\r\n     *\r\n     *    @param [in] change  The change in the item.\r\n     *    @param [in] value   Value for change.\r\n     *\r\n     *    @return The item change.\r\n     */\r\n    QVariant itemChange(GraphicsItemChange change, QVariant const& value) override;\r\n\r\nprivate:\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! The parent diagram connection endpoint.\r\n    ConnectionEndpoint* parent_ = nullptr;\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n\r\n#endif // OFFPAGECONNECTORITEM_H\r\n"
  },
  {
    "path": "editors/HWDesign/PortmapDialog.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: PortmapDialog.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Joni-Matti Maatta\r\n// Date: 10.6.2011\r\n//\r\n// Description:\r\n// Port map dialog.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"PortmapDialog.h\"\r\n\r\n#include <editors/ComponentEditor/busInterfaces/portmaps/BusInterfacePortMapTab.h>\r\n\r\n#include <KactusAPI/include/LibraryInterface.h>\r\n\r\n#include <IPXACTmodels/Component/BusInterface.h>\r\n#include <IPXACTmodels/Component/Component.h>\r\n#include <IPXACTmodels/Component/PortMap.h>\r\n\r\n#include <KactusAPI/include/ExpressionFormatter.h>\r\n#include <KactusAPI/include/ComponentParameterFinder.h>\r\n#include <KactusAPI/include/IPXactSystemVerilogParser.h>\r\n#include <KactusAPI/include/BusInterfaceInterface.h>\r\n#include <KactusAPI/include/BusInterfaceInterfaceFactory.h>\r\n#include <KactusAPI/include/AbstractionTypeInterface.h>\r\n#include <KactusAPI/include/PortMapInterface.h>\r\n\r\n#include <QHBoxLayout>\r\n#include <QVBoxLayout>\r\n#include <QGroupBox>\r\n#include <QPushButton>\r\n#include <QCoreApplication>\r\n#include <QMessageBox>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PortmapDialog()\r\n//-----------------------------------------------------------------------------\r\nPortmapDialog::PortmapDialog(LibraryInterface* library, QSharedPointer<Component> component,\r\n    QSharedPointer<BusInterface> busIf, QSharedPointer<BusInterface> otherBusIf, QWidget* parent) :\r\nQDialog(parent),\r\nbusIf_(busIf),\r\notherBusIf_(otherBusIf),\r\ndesignComponent_(component)\r\n{\r\n    Q_ASSERT(library != 0);\r\n    Q_ASSERT(component != 0);\r\n    Q_ASSERT(busIf != 0);\r\n    Q_ASSERT(otherBusIf != 0);\r\n\r\n    setWindowTitle(tr(\"Define Port Maps\"));\r\n\r\n    QSharedPointer<ParameterFinder> parameterFinder(new ComponentParameterFinder(component));\r\n    QSharedPointer<ExpressionFormatter> expressionFormatter(new ExpressionFormatter(parameterFinder));\r\n    QSharedPointer<IPXactSystemVerilogParser> expressionParser(new IPXactSystemVerilogParser(parameterFinder));\r\n\r\n\r\n    BusInterfaceInterface* busInterface = BusInterfaceInterfaceFactory::createBusInterface(\r\n        parameterFinder, expressionFormatter, expressionParser, component, library);\r\n\r\n    // Temporarily add businterface to design component\r\n    component->getBusInterfaces()->append(busIf);\r\n\r\n    AbstractionTypeInterface* absTypeInterface = busInterface->getAbstractionTypeInterface();\r\n    PortMapInterface* portMapInterface = absTypeInterface->getPortMapInterface();\r\n    if (portMapInterface)\r\n    {\r\n        // Create the port map widget.\r\n        portmapWidget_ = new BusInterfacePortMapTab(library, component, busInterface, busIf->name().toStdString(),\r\n            expressionParser, parameterFinder, portMapInterface, this);\r\n\r\n        portmapWidget_->setAbstractionDefinitions();\r\n\r\n        // Create a separator.\r\n        QGroupBox* separator = new QGroupBox(this);\r\n        separator->setFlat(true);\r\n\r\n        // Create the buttons and their layout.\r\n        QPushButton* btnOk = new QPushButton(tr(\"OK\"), this);\r\n        QPushButton* btnCancel = new QPushButton(tr(\"Cancel\"), this);\r\n\r\n        QHBoxLayout* buttonLayout = new QHBoxLayout();\r\n        buttonLayout->addStretch(1);\r\n        buttonLayout->addWidget(btnOk);\r\n        buttonLayout->addWidget(btnCancel);\r\n\r\n        // Create the main layout.\r\n        QVBoxLayout* mainLayout = new QVBoxLayout(this);\r\n        mainLayout->addWidget(portmapWidget_);\r\n        mainLayout->addWidget(separator);\r\n        mainLayout->addLayout(buttonLayout);\r\n\r\n        connect(btnOk, SIGNAL(clicked()), this, SLOT(accept()));\r\n        connect(btnCancel, SIGNAL(clicked()), this, SLOT(reject()));\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ~PortmapDialog()\r\n//-----------------------------------------------------------------------------\r\nPortmapDialog::~PortmapDialog()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: accept()\r\n//-----------------------------------------------------------------------------\r\nvoid PortmapDialog::accept()\r\n{\r\n    // Remove temporary bus interface. Results in duplicate component when saved if not deleted\r\n    designComponent_->getBusInterfaces()->removeOne(busIf_);\r\n    QDialog::accept();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PortmapDialog::reject()\r\n//-----------------------------------------------------------------------------\r\nvoid PortmapDialog::reject()\r\n{\r\n    // Remove added temporary interface, if operation is cancelled.\r\n    auto componentBuses = designComponent_->getBusInterfaces();\r\n    for (auto const& bus : *componentBuses)\r\n    {\r\n        if (bus->name() == busIf_->name())\r\n        {\r\n            bus->clearAllPortMaps();\r\n            componentBuses->removeOne(bus);\r\n            break;\r\n        }\r\n    }\r\n\r\n    QDialog::reject();\r\n}\r\n"
  },
  {
    "path": "editors/HWDesign/PortmapDialog.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: PortmapDialog.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Joni-Matti Maatta\r\n// Date: 10.6.2011\r\n//\r\n// Description:\r\n// Port map dialog.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef PORTMAPDIALOG_H\r\n#define PORTMAPDIALOG_H\r\n\r\n#include <QDialog>\r\n\r\nclass BusInterface;\r\nclass Component;\r\nclass LibraryInterface;\r\nclass BusInterfacePortMapTab;\r\nclass BusInterfaceInterface;\r\nclass FileSetInterface;\r\nclass PortMapInterface;\r\nclass MemoryMapInterface;\r\nclass AbstractionTypeInterface;\r\nclass TransparentBridgeInterface;\r\nclass PortMapValidator;\r\nclass ParameterValidator;\r\nclass ParameterFinder;\r\nclass ExpressionFormatter;\r\nclass IPXactSystemVerilogParser;\r\nclass ParametersInterface;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! PortmapDialog class.\r\n//-----------------------------------------------------------------------------\r\nclass PortmapDialog : public QDialog\r\n{\r\npublic:\r\n\r\n    /*!\r\n     *  Constructor.\r\n     *\r\n     *    @param [in] library     The library interface.\r\n     *    @param [in] component   The parent component of the bus interface.\r\n     *    @param [in] busIf       The bus interface whose port map will be edited.\r\n     *    @param [in] otherBusIf  The bus interface in the other end of the connection.\r\n     *    @param [in] parent      The owner of this dialog.\r\n     */\r\n    PortmapDialog(LibraryInterface* library, QSharedPointer<Component> component,\r\n                  QSharedPointer<BusInterface> busIf, QSharedPointer<BusInterface> otherBusIf, QWidget* parent = 0);\r\n\r\n    /*!\r\n     *  The destructor.\r\n     */\r\n    ~PortmapDialog();\r\n\r\npublic slots:\r\n    void accept();\r\n\r\n    void reject();\r\n\r\nprivate:\r\n    // Disable copying.\r\n    PortmapDialog(PortmapDialog const& rhs);\r\n    PortmapDialog& operator=(PortmapDialog const& rhs);\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! Port map editor widget.\r\n    BusInterfacePortMapTab* portmapWidget_;\r\n\r\n    //! The bus interface whose port map to edit.\r\n    QSharedPointer<BusInterface> busIf_;\r\n\r\n    //! The bus interface in the other end of the connection (for validity checks).\r\n    QSharedPointer<BusInterface> otherBusIf_;\r\n\r\n    //! The component whose design is being edited.\r\n    QSharedPointer<Component> designComponent_;\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n\r\n#endif // PORTMAPDIALOG_H\r\n"
  },
  {
    "path": "editors/HWDesign/SelectItemTypeDialog.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: SelectItemTypeDialog.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Joni-Matti Maatta\r\n// Date: 20.5.2011\r\n//\r\n// Description:\r\n// Item type selection dialog.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"SelectItemTypeDialog.h\"\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SelectItemTypeDialog()\r\n//-----------------------------------------------------------------------------\r\nSelectItemTypeDialog::SelectItemTypeDialog(unsigned int allowedItems, QWidget* parent) : \r\n    QDialog(parent),\r\n    allowedItems_(allowedItems),\r\n    layout_(new QVBoxLayout(this)), \r\n    allowedItemsGroup_(new QGroupBox(tr(\"Item Type\"), this)),    \r\n    interfaceButton_(new QRadioButton(tr(\"Interface\"), allowedItemsGroup_)),\r\n    componentButton_(new QRadioButton(allowedItemsGroup_)),\r\n    dialogButtons_(new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, Qt::Horizontal, this))\r\n{\r\n    Q_ASSERT(allowedItems != ColumnTypes::NONE);\r\n\r\n    setWindowTitle(tr(\"Add Item\"));\r\n\r\n    setupLayout();\r\n\r\n    setComponentButtonLabel();\r\n\r\n    connect(dialogButtons_, SIGNAL(accepted()), this, SLOT(accept()));\r\n    connect(dialogButtons_, SIGNAL(rejected()), this, SLOT(reject()));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ~SelectItemTypeDialog()\r\n//-----------------------------------------------------------------------------\r\nSelectItemTypeDialog::~SelectItemTypeDialog()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: getSelectedItemType()\r\n//-----------------------------------------------------------------------------\r\nColumnTypes::ColumnItemType SelectItemTypeDialog::getSelectedItemType() const\r\n{\r\n    ColumnTypes::ColumnItemType type = ColumnTypes::NONE;\r\n\r\n    if (interfaceButton_->isChecked())\r\n    {\r\n        type = ColumnTypes::INTERFACE;\r\n    }\r\n    else if (componentButton_->isChecked())\r\n    {\r\n        type = ColumnTypes::COMPONENT;\r\n    }\r\n    else\r\n    {\r\n        // We should not get here at all.\r\n        Q_ASSERT(false);     \r\n    }\r\n\r\n    return type;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SelectItemTypeDialog::setupLayout()\r\n//-----------------------------------------------------------------------------\r\nvoid SelectItemTypeDialog::setupLayout()\r\n{\r\n    QVBoxLayout* itemLayout = new QVBoxLayout(allowedItemsGroup_);\r\n    itemLayout->addWidget(interfaceButton_);\r\n    itemLayout->addWidget(componentButton_);\r\n\r\n    layout_->addWidget(allowedItemsGroup_);\r\n    layout_->addWidget(dialogButtons_);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SelectItemTypeDialog::setComponentButtonLabel()\r\n//-----------------------------------------------------------------------------\r\nvoid SelectItemTypeDialog::setComponentButtonLabel()\r\n{\r\n    QString componentButtonLabel = \"\";\r\n\r\n    if (allowedItems_ & ColumnTypes::COMPONENT)\r\n    {\r\n        componentButtonLabel += tr(\"Component/\");\r\n    }\r\n\r\n    if (allowedItems_ & ColumnTypes::CHANNEL)\r\n    {\r\n        componentButtonLabel += tr(\"Channel/\");\r\n    }\r\n\r\n    if (allowedItems_ & ColumnTypes::BRIDGE)\r\n    {\r\n        componentButtonLabel += tr(\"Bridge/\");\r\n    }\r\n\r\n    Q_ASSERT(!componentButtonLabel.isEmpty());\r\n\r\n    componentButtonLabel.chop(1);   //<! Remove last slash.\r\n    componentButton_->setText(componentButtonLabel);\r\n}\r\n"
  },
  {
    "path": "editors/HWDesign/SelectItemTypeDialog.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: SelectItemTypeDialog.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Joni-Matti Maatta\r\n// Date: 20.5.2011\r\n//\r\n// Description:\r\n// Item type selection dialog.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef SELECTITEMTYPEDIALOG_H\r\n#define SELECTITEMTYPEDIALOG_H\r\n\r\n#include <QDialog>\r\n#include <QRadioButton>\r\n#include <QVBoxLayout>\r\n#include <QGroupBox>\r\n#include <QDialogButtonBox>\r\n\r\n#include <editors/common/ColumnTypes.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n//! SelectItemTypeDialog class.\r\n//-----------------------------------------------------------------------------\r\nclass SelectItemTypeDialog : public QDialog\r\n{\r\n    Q_OBJECT\r\n\r\npublic:\r\n    /*!\r\n     *  Constructor.\r\n     *     \r\n     *    @param [in] allowedItems  The item types from which the user can select from.\r\n     *    @param [in] parent        The parent widget.\r\n     */\r\n    SelectItemTypeDialog(unsigned int allowedItems, QWidget* parent);\r\n\r\n    //! The destructor.\r\n    ~SelectItemTypeDialog();\r\n\r\n    //!  Returns the selected item type.\r\n    ColumnTypes::ColumnItemType getSelectedItemType() const;\r\n\r\nprivate:\r\n    // Disable copying.\r\n    SelectItemTypeDialog(SelectItemTypeDialog const& rhs);\r\n    \r\n    //! Disable assignment.\r\n    SelectItemTypeDialog& operator=(SelectItemTypeDialog const& rhs);\r\n    \r\n    //! Sets the dialog layout.\r\n    void setupLayout();\r\n\r\n    //! Sets the label for selecting component/channel/bridge according to allowed item types.\r\n    void setComponentButtonLabel();    \r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! The allowed items.\r\n    unsigned int allowedItems_;\r\n\r\n    //! The layout for the UI widgets.\r\n    QVBoxLayout* layout_;\r\n\r\n    //! The group box for the allowed column items selection.\r\n    QGroupBox* allowedItemsGroup_;\r\n\r\n    //! The radio button for selecting interface.\r\n    QRadioButton* interfaceButton_;\r\n\r\n    //! The radio button for selecting component/channel/bridge.\r\n    QRadioButton* componentButton_;\r\n    \r\n    //! Dialog OK and Cancel buttons.\r\n    QDialogButtonBox* dialogButtons_;\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n\r\n#endif // SELECTITEMTYPEDIALOG_H\r\n"
  },
  {
    "path": "editors/HWDesign/WarningSymbol.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: WarningSymbol.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 02.11.2021\n//\n// Description:\n// Warning symbol constructed from QPolygonf\n//-----------------------------------------------------------------------------\n\n#include \"WarningSymbol.h\"\n\n#include <editors/common/diagramgrid.h>\n\n#include <QPen>\n\n//-----------------------------------------------------------------------------\n// Function: WarningSymbol::WarningSymbol()\n//-----------------------------------------------------------------------------\nWarningSymbol::WarningSymbol(QGraphicsItem* parent) :\nQGraphicsPolygonItem(parent)\n{\n    setToolTip(QObject::tr(\"No portmaps found\"));\n\n    QPen warningPen(Qt::black, 0);\n    setPen(warningPen);\n\n    QBrush warningBrush(QColor(255, 223, 0));\n    setBrush(warningBrush);\n\n    constexpr int squareSize = GridSize;\n    constexpr qreal startingY = squareSize - 2;\n    constexpr qreal pointDistance = 2 * squareSize / 3;\n\n    QPolygonF warningShape({\n        QPointF(0, startingY),\n        QPointF(-pointDistance, startingY + pointDistance),\n        QPointF(-pointDistance * 2, startingY),\n        QPointF(-pointDistance, startingY - pointDistance)\n    });\n\n    setPolygon(warningShape);\n\n    QPolygonF exclamationShape({ QPointF(-squareSize / 5, startingY), QPointF(-squareSize + 3, startingY) });\n    exclamationLine_->setPolygon(exclamationShape);\n\n    QPolygonF exclamationDotShape({ QPointF(-squareSize, startingY), QPointF(-squareSize + 1 , startingY) });\n    exclamationDot_->setPolygon(exclamationDotShape);\n}\n\n//-----------------------------------------------------------------------------\n// Function: WarningSymbol::moveSymbol()\n//-----------------------------------------------------------------------------\nvoid WarningSymbol::moveSymbol(QVector2D const& dir)\n{\n    if (qFuzzyCompare(dir, QVector2D(1.0f, 0.0f)))\n    {\n        setRotation(180.0);\n        setPos(QPointF(0,  2* (GridSize - 2)));\n    }\n\n    else if (qFuzzyCompare(dir, QVector2D(-1.0f, 0.0f)))\n    {\n        setRotation(0);\n        setPos(QPointF(0.0, 0.0));\n    }\n}\n"
  },
  {
    "path": "editors/HWDesign/WarningSymbol.h",
    "content": "//-----------------------------------------------------------------------------\n// File: WarningSymbol.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 02.11.2021\n//\n// Description:\n// Warning symbol constructed from QPolygonf\n//-----------------------------------------------------------------------------\n\n#ifndef WARNINGSYMBOL_H\n#define WARNINGSYMBOL_H\n\n#include <QGraphicsPolygonItem>\n#include <QVector2D>\n\n//-----------------------------------------------------------------------------\n//! Warning symbol constructed from QPolygonf\n//-----------------------------------------------------------------------------\nclass WarningSymbol : public QGraphicsPolygonItem\n{\n\npublic:\n\n    /*!\n     *  The constructor.\n     *\n     *    @param [in] busIf       The bus interface this item represents.\n     *    @param [in] component   Component containing the bus interface.\n     *    @param [in] library     Access to the library.\n     *    @param [in] parent      The parent object.\n     *    @param [in] dir         Direction for the end point graphics.\n     */\n    WarningSymbol(QGraphicsItem* parent);\n\n\t/*!\n     *  The destructor.\n     */\n    virtual ~WarningSymbol() = default;\n\n    /*!\n     *  Move the warning symbol in the design according to direction.\n     *\n     *    @param [in] dir     The selected direction.\n     */\n    void moveSymbol(QVector2D const& dir);\n\n    // Disable copying.\n    WarningSymbol(WarningSymbol const& rhs) = delete;\n    WarningSymbol& operator=(WarningSymbol const& rhs) = delete;\n\nprivate:\n\n    //-----------------------------------------------------------------------------\n    // Data.\n    //-----------------------------------------------------------------------------\n\n    //! Line of the warning exclamation mark.\n    QGraphicsPolygonItem* exclamationLine_ = new QGraphicsPolygonItem(this);\n\n    //! Dot of the warning exclamation mark.\n    QGraphicsPolygonItem* exclamationDot_ = new QGraphicsPolygonItem(this);\n};\n\n#endif // WARNINGSYMBOL_H\n"
  },
  {
    "path": "editors/HWDesign/columnview/ColumnEditDialog.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ColumnEditDialog.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Joni-Matti Maatta\r\n// Date: 15.4.2011\r\n//\r\n// Description:\r\n// Dialog for editing diagram column properties.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"ColumnEditDialog.h\"\r\n\r\n#include <QMessageBox>\r\n#include <QCoreApplication>\r\n\r\nnamespace\r\n{\r\n    const unsigned int ALLOWED_ITEMS[ColumnTypes::CUSTOM] = \r\n    {\r\n        ColumnTypes::INTERFACE,                             //<! For COLUMN_CONTENT_IO.\r\n        ColumnTypes::CHANNEL | ColumnTypes::BRIDGE,     //<! For COLUMN_CONTENT_BUSES.\r\n        ColumnTypes::COMPONENT,                             //<! For COLUMN_CONTENT_COMPONENTS.\r\n        ColumnTypes::COMPONENT                              //<! For COLUMN_CONTENT_MEMORY.\r\n    };\r\n\r\n    const QString ITEM_NAMES[ColumnTypes::TYPE_COUNT] = \r\n    {\r\n        QObject::tr(\"Interfaces\"),\r\n        QObject::tr(\"Components\"),\r\n        QObject::tr(\"Channels\"),\r\n        QObject::tr(\"Bridges\")        \r\n    };\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ColumnEditDialog::ColumnEditDialog()\r\n//-----------------------------------------------------------------------------\r\nColumnEditDialog::ColumnEditDialog(QWidget* parent, bool sw, GraphicsColumn const* column)\r\n    : QDialog(parent), \r\n      layout_(new QVBoxLayout(this)), \r\n      nameLabel_(new QLabel(tr(\"Name:\"), this)), \r\n      nameEdit_(new QLineEdit(this)),\r\n      typeLabel_(new QLabel(tr(\"Type:\"), this)), \r\n      typeCombo_(new QComboBox(this)),\r\n      allowedItemsGroup_(new QGroupBox(tr(\"Allowed Items\"), this)),       \r\n      buttons_(new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, Qt::Horizontal, this)),\r\n      column_(column),\r\n      types_()\r\n{\r\n    setupLayout(sw);\r\n    initializeTypes(sw);\r\n\r\n    // Fill the fields with the data from the column, if given.\r\n    if (column_ != 0)\r\n    {\r\n        setWindowTitle(tr(\"Edit Column\"));\r\n        nameEdit_->setText(column_->name());\r\n        setAllowedItems(column_->getColumnDesc()->getAllowedItems());\r\n\r\n        QString typeName = types_.key(column_->getContentType(), tr(\"IO\"));\r\n        typeCombo_->setCurrentIndex(typeCombo_->findText(typeName));\r\n    }\r\n    else\r\n    {\r\n        setWindowTitle(tr(\"Add Column\"));\r\n        setAllowedItems(ColumnTypes::NONE);\r\n        typeCombo_->setCurrentIndex((typeCombo_->findText(tr(\"IO\"))));\r\n    }\r\n\r\n    onTypeChange(typeCombo_->currentText());\r\n\r\n    connect(typeCombo_, SIGNAL(currentTextChanged(QString const&)), this, SLOT(onTypeChange(QString const&)));\r\n    connect(buttons_, SIGNAL(accepted()), this, SLOT(accept()));\r\n    connect(buttons_, SIGNAL(rejected()), this, SLOT(reject()));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ColumnEditDialog::~ColumnEditDialog()\r\n//-----------------------------------------------------------------------------\r\nColumnEditDialog::~ColumnEditDialog()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ColumnEditDialog::hideContentSettings()\r\n//-----------------------------------------------------------------------------\r\nvoid ColumnEditDialog::hideContentSettings()\r\n{\r\n    typeLabel_->hide();\r\n    typeCombo_->hide();\r\n    allowedItemsGroup_->hide();\r\n\r\n    layout_->activate();\r\n    setFixedSize(sizeHint());\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ColumnEditDialog::onTypeChange()\r\n//-----------------------------------------------------------------------------\r\nvoid ColumnEditDialog::onTypeChange(QString const& type)\r\n{\r\n    // Convert the index to a column content type.\r\n    ColumnTypes::ColumnContentType contentType = types_.value(type, ColumnTypes::CUSTOM);\r\n    \r\n    // Set enabled/disabled based on the content type.\r\n    for (int i = 0; i < ColumnTypes::TYPE_COUNT; ++i)\r\n    {\r\n        itemCheckBoxes_[i]->setEnabled(contentType == ColumnTypes::CUSTOM);\r\n    }\r\n\r\n    if (contentType != ColumnTypes::CUSTOM)\r\n    {\r\n        setAllowedItems(ALLOWED_ITEMS[contentType]);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ColumnEditDialog::setAllowedItems()\r\n//-----------------------------------------------------------------------------\r\nvoid ColumnEditDialog::setAllowedItems(unsigned int allowedItems)\r\n{\r\n    for (int i = 0; i < ColumnTypes::TYPE_COUNT; ++i)\r\n    {\r\n        // Set the checked states based on the corresponding flag.\r\n        itemCheckBoxes_[i]->setChecked((1 << i) & allowedItems);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ColumnEditDialog::name()\r\n//-----------------------------------------------------------------------------\r\nQString ColumnEditDialog::name() const\r\n{\r\n    return nameEdit_->text();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ColumnEditDialog::getContentType()\r\n//-----------------------------------------------------------------------------\r\nColumnTypes::ColumnContentType ColumnEditDialog::getContentType() const\r\n{\r\n    // Convert the index to a column content type.   \r\n    QString type = typeCombo_->currentText();\r\n    return types_.value(type, ColumnTypes::CUSTOM);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ColumnEditDialog::getAllowedItems()\r\n//-----------------------------------------------------------------------------\r\nunsigned int ColumnEditDialog::getAllowedItems() const\r\n{\r\n    unsigned int allowedItems = ColumnTypes::NONE;\r\n\r\n    for (int i = 0; i < ColumnTypes::TYPE_COUNT; ++i)\r\n    {\r\n        allowedItems |= (itemCheckBoxes_[i]->isChecked() << i);\r\n    }\r\n\r\n    return allowedItems;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ColumnEditDialog::accept()\r\n//-----------------------------------------------------------------------------\r\nvoid ColumnEditDialog::accept()\r\n{\r\n    if (column_ != 0 && !column_->isAllowedItemsValid(getAllowedItems()))\r\n    {\r\n        QMessageBox msgBox(QMessageBox::Critical, QCoreApplication::applicationName(),\r\n            tr(\"The column contains items that would not be allowed in the new column configuration.\" \r\n            \"Please delete the items of the unallowed type before changing the column configuration.\"),\r\n            QMessageBox::Ok, (QWidget*)parent());\r\n        msgBox.exec();\r\n        return;\r\n    }\r\n\r\n    QDialog::accept();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ColumnEditDialog::initializeTypes()\r\n//-----------------------------------------------------------------------------\r\nvoid ColumnEditDialog::initializeTypes(bool sw)\r\n{\r\n    types_.insert(tr(\"IO\"), ColumnTypes::IO);\r\n    types_.insert(tr(\"Components\"), ColumnTypes::COMPONENTS);    \r\n\r\n    if (!sw)\r\n    {\r\n        types_.insert(tr(\"Buses\"), ColumnTypes::BUSES);\r\n        types_.insert(tr(\"Memory\"), ColumnTypes::MEMORY);\r\n        types_.insert(tr(\"Custom\"), ColumnTypes::CUSTOM);\r\n    }\r\n\r\n    foreach(QString typeName, types_.keys())\r\n    {\r\n        typeCombo_->addItem(typeName);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ColumnEditDialog::setupLayout()\r\n//-----------------------------------------------------------------------------\r\nvoid ColumnEditDialog::setupLayout(bool sw)\r\n{\r\n    layout_->addWidget(nameLabel_);\r\n    layout_->addWidget(nameEdit_);\r\n    layout_->addWidget(typeLabel_);\r\n    layout_->addWidget(typeCombo_);\r\n\r\n    // Create the allowed items group box and check boxes.\r\n    QVBoxLayout* itemLayout = new QVBoxLayout(allowedItemsGroup_);\r\n\r\n    for (int i = 0; i < ColumnTypes::TYPE_COUNT; ++i)\r\n    {\r\n        itemCheckBoxes_[i] = new QCheckBox(ITEM_NAMES[i], allowedItemsGroup_);\r\n        itemLayout->addWidget(itemCheckBoxes_[i]);\r\n    }\r\n\r\n    allowedItemsGroup_->setVisible(!sw);\r\n\r\n    layout_->addWidget(allowedItemsGroup_);\r\n    layout_->addWidget(buttons_);\r\n\r\n    setFixedSize(sizeHint());\r\n}\r\n"
  },
  {
    "path": "editors/HWDesign/columnview/ColumnEditDialog.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ColumnEditDialog.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Joni-Matti Maatta\r\n// Date: 15.4.2011\r\n//\r\n// Description:\r\n// Dialog for editing diagram column properties.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef COLUMNEDITDIALOG_H\r\n#define COLUMNEDITDIALOG_H\r\n\r\n#include <QDialog>\r\n#include <QLabel>\r\n#include <QLineEdit>\r\n#include <QComboBox>\r\n#include <QGroupBox>\r\n#include <QCheckBox>\r\n#include <QVBoxLayout>\r\n#include <QDialogButtonBox>\r\n\r\n#include <common/graphicsItems/GraphicsColumn.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n//! ColumnEditDialog class.\r\n//-----------------------------------------------------------------------------\r\nclass ColumnEditDialog : public QDialog\r\n{\r\n    Q_OBJECT\r\n\r\npublic:\r\n    /*!\r\n     *  Constructor.\r\n     *\r\n     *    @param [in] parent  The parent widget.\r\n     *    @param [in] sw      If true, the dialog shows only options valid for SW designs.\r\n     *    @param [in] column  The existing column to edit.\r\n     */\r\n    ColumnEditDialog(QWidget* parent, bool sw, GraphicsColumn const* column = 0);\r\n\r\n    /*!\r\n     *  Destructor.\r\n     */\r\n    virtual ~ColumnEditDialog();\r\n\r\n\r\n    /*!\r\n     *  Hides the column content settings.\r\n     */\r\n    void hideContentSettings();\r\n\r\n    /*!\r\n     *  Returns the column name from the dialog.\r\n     */\r\n    QString name() const;\r\n\r\n    /*!\r\n     *  Returns the column content type from the dialog.\r\n     */\r\n    ColumnTypes::ColumnContentType getContentType() const;\r\n\r\n    /*!\r\n     *  Returns the allowed items from the dialog.\r\n     */\r\n    unsigned int getAllowedItems() const;\r\n\r\nprivate slots:\r\n    //! Called when the content type has changed.\r\n    void onTypeChange(QString const& type);\r\n\r\n    //! Called when OK button has been clicked.\r\n    virtual void accept();\r\n\r\nprivate:\r\n    // Disable copying.\r\n    ColumnEditDialog(ColumnEditDialog const& rhs);\r\n    \r\n    // Disable assignment.\r\n    ColumnEditDialog& operator=(ColumnEditDialog const& rhs);\r\n\r\n    /*!\r\n     *  Initializes the selectable types.\r\n     *\r\n     *    @param [in] sw   True if editing sw columns.     \r\n     */\r\n    void initializeTypes(bool sw);\r\n\r\n    /*!\r\n     *  Sets the dialog layout.\r\n     *\r\n     *    @param [in] sw   True if editing sw columns.     \r\n     */\r\n    void setupLayout(bool sw);\r\n\r\n    /*!\r\n     *  Sets the allowed items in the dialog.\r\n     *\r\n     *    @param [in] allowedItems The allowed items. See ComponentItemType for possible values.\r\n     */\r\n    void setAllowedItems(unsigned int allowedItems);\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! The layout for the UI widgets.\r\n    QVBoxLayout* layout_;\r\n\r\n    //! The label for the name line edit.\r\n    QLabel* nameLabel_;\r\n\r\n    //! The line edit for the column name.\r\n    QLineEdit* nameEdit_;\r\n\r\n    //! The label for the type combo box.\r\n    QLabel* typeLabel_;\r\n\r\n    //! The combo box for the column type.\r\n    QComboBox* typeCombo_;\r\n\r\n    //! The group box for the allowed column items selection.\r\n    QGroupBox* allowedItemsGroup_;\r\n\r\n    //! The check boxes for the allowed column items.\r\n    QCheckBox* itemCheckBoxes_[ColumnTypes::TYPE_COUNT];\r\n\r\n    //! Dialog buttons.\r\n    QDialogButtonBox* buttons_;\r\n\r\n    //! The column that is being edited. If null, we're creating a new column.\r\n    GraphicsColumn const* column_;\r\n\r\n    //! The names and types of possible columns.\r\n    QMap<QString, ColumnTypes::ColumnContentType> types_;\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n\r\n#endif // COLUMNEDITDIALOG_H"
  },
  {
    "path": "editors/HWDesign/columnview/HWColumn.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: HWColumn.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Joni-Matti Maatta\r\n// Date: 4.4.2011\r\n//\r\n// Description:\r\n// Diagram column class.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"HWColumn.h\"\r\n\r\n#include \"../HWMoveCommands.h\"\r\n#include \"../HWComponentItem.h\"\r\n\r\n#include <common/graphicsItems/GraphicsConnection.h>\r\n\r\n#include <editors/common/DesignDiagram.h>\r\n#include <editors/common/diagramgrid.h>\r\n#include <editors/common/DiagramUtil.h>\r\n\r\n#include <IPXACTmodels/Component/Component.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HWColumn()\r\n//-----------------------------------------------------------------------------\r\nHWColumn::HWColumn(QSharedPointer<ColumnDesc> desc, GraphicsColumnLayout* layout):\r\n    GraphicsColumn(desc, layout)\r\n{\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ~HWColumn()\r\n//-----------------------------------------------------------------------------\r\nHWColumn::~HWColumn()\r\n{\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HWColumn::isItemAllowed()\r\n//-----------------------------------------------------------------------------\r\nbool HWColumn::isItemAllowed(QGraphicsItem* item, unsigned int allowedItems) const\r\n{\r\n    if (item->type() == GFX_TYPE_DIAGRAM_INTERFACE || item->type() == GFX_TYPE_DIAGRAM_ADHOC_INTERFACE)\r\n    {\r\n        return (allowedItems & ColumnTypes::INTERFACE);\r\n    }\r\n    else if (item->type() == GFX_TYPE_DIAGRAM_COMPONENT)\r\n    {\r\n        QSharedPointer<Component> comp = qgraphicsitem_cast<HWComponentItem*>(item)->componentModel();\r\n\r\n        // Check if this is a packaged component (and has a strict type).\r\n        if (comp->getVlnv().isValid())\r\n        {\r\n            return (((comp->isTransparentBridge() || comp->isOpaqueBridge()) && (allowedItems & ColumnTypes::BRIDGE)) ||\r\n                (comp->isChannel() && (allowedItems & ColumnTypes::CHANNEL)) ||\r\n                (!comp->isBus() && (allowedItems & ColumnTypes::COMPONENT)));\r\n        }\r\n        else\r\n        {\r\n            // Otherwise this is an unpacked component and can be of any type.\r\n            return (allowedItems & (ColumnTypes::BRIDGE | ColumnTypes::CHANNEL | ColumnTypes::COMPONENT));\r\n        }\r\n    }\r\n    else\r\n    {\r\n        return false;\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HWColumn::prepareColumnMove()\r\n//-----------------------------------------------------------------------------\r\nvoid HWColumn::prepareColumnMove()\r\n{\r\n    for (QGraphicsItem *item : scene()->items())\r\n    {\r\n        auto conn = dynamic_cast<GraphicsConnection*>(item);\r\n        if (conn != nullptr)\r\n        {\r\n            conn->beginUpdatePosition();\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HWColumn::createMoveUndoCommand()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<QUndoCommand> HWColumn::createMoveUndoCommand()\r\n{\r\n    QSharedPointer<QUndoCommand> cmd = GraphicsColumn::createMoveUndoCommand();\r\n\r\n    for (QGraphicsItem *item : scene()->items())\r\n    {\r\n        auto conn = dynamic_cast<GraphicsConnection*>(item);\r\n        if (conn != nullptr)\r\n        {\r\n            conn->endUpdatePosition(cmd.data());\r\n        }\r\n    }\r\n\r\n    return cmd;\r\n}\r\n"
  },
  {
    "path": "editors/HWDesign/columnview/HWColumn.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: HWColumn.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Joni-Matti Maatta\r\n// Date: 4.4.2011\r\n//\r\n// Description:\r\n// Diagram column class.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef HWCOLUMN_H\r\n#define HWCOLUMN_H\r\n\r\n#include <editors/common/ColumnTypes.h>\r\n\r\n#include <common/graphicsItems/GraphicsItemTypes.h>\r\n#include <common/graphicsItems/GraphicsColumn.h>\r\n\r\n#include <IPXACTmodels/kactusExtensions/ColumnDesc.h>\r\n\r\n\r\nclass GraphicsConnection;\r\nclass Component;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! HWColumn class.\r\n//-----------------------------------------------------------------------------\r\nclass HWColumn : public GraphicsColumn\r\n{\r\n    Q_OBJECT\r\n\r\npublic:\r\n    enum { Type = GFX_TYPE_DIAGRAM_COLUMN };\r\n\r\n    /*!\r\n     *  Constructor.\r\n     *\r\n     *    @param [in] desc    The column description.\r\n     *    @param [in] layout  The parent column layout.\r\n     */\r\n    HWColumn(QSharedPointer<ColumnDesc> desc, GraphicsColumnLayout* layout);\r\n\r\n    /*!\r\n     *  Destructor.\r\n     */\r\n    virtual ~HWColumn();\r\n\r\n    int type() const { return Type; }\r\n\r\nprotected:\r\n    /*!\r\n     *  Returns true if the given item is allowed to reside in the column based on the allowed items.\r\n     *\r\n     *    @param [in] item          The item.\r\n     *    @param [in] allowedItems  The allowed items flags.\r\n     */\r\n    virtual bool isItemAllowed(QGraphicsItem* item, unsigned int allowedItems) const;\r\n\r\n    /*!\r\n     *  Prepares for column move.\r\n     */\r\n    virtual void prepareColumnMove();\r\n\r\n    /*!\r\n     *  Creates an undo command for the column move.\r\n     *\r\n     *    @return The created undo command.\r\n     */\r\n    virtual QSharedPointer<QUndoCommand> createMoveUndoCommand();\r\n\r\nprivate:\r\n    // Disable copying.\r\n    HWColumn(HWColumn const& rhs);\r\n    HWColumn& operator=(HWColumn const& rhs);\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n\r\n#endif // HWCOLUMN_H\r\n"
  },
  {
    "path": "editors/HWDesign/undoCommands/AdHocBoundsChangeCommand.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: AdHocBoundsChangeCommand.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 03.05.2017\n//\n// Description:\n// Undo command for changing left and right bounds of an ad hoc port.\n//-----------------------------------------------------------------------------\n\n#include \"AdHocBoundsChangeCommand.h\"\n\n#include <IPXACTmodels/common/PartSelect.h>\n#include <IPXACTmodels/Design/PortReference.h>\n\n//-----------------------------------------------------------------------------\n// Function: AdHocBoundsChangeCommand::AdHocBoundsChangeCommand()\n//-----------------------------------------------------------------------------\nAdHocBoundsChangeCommand::AdHocBoundsChangeCommand(QSharedPointer<PortReference> referencedPort,\n    QString const& newLeftBound, QString const& newRightBound, QUndoCommand* parent):\nQObject(0),\nQUndoCommand(parent),\nreferencedPort_(referencedPort),\noldPartSelect_(0),\nnewPartSelect_(0)\n{\n    setupPartSelectForPortReference(newLeftBound, newRightBound);\n}\n\n//-----------------------------------------------------------------------------\n// Function: AdHocBoundsChangeCommand::setupPartSelectForPortReference()\n//-----------------------------------------------------------------------------\nvoid AdHocBoundsChangeCommand::setupPartSelectForPortReference(QString const& newLeftValue,\n    QString const& newRightValue)\n{\n    newPartSelect_ = QSharedPointer<PartSelect>(new PartSelect(newLeftValue, newRightValue));\n\n    if (referencedPort_->getPartSelect())\n    {\n        oldPartSelect_ = referencedPort_->getPartSelect();\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: AdHocBoundsChangeCommand::~AdHocBoundsChangeCommand()\n//-----------------------------------------------------------------------------\nAdHocBoundsChangeCommand::~AdHocBoundsChangeCommand()\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: AdHocBoundsChangeCommand::undo()\n//-----------------------------------------------------------------------------\nvoid AdHocBoundsChangeCommand::undo()\n{\n    QUndoCommand::undo();\n\n    setPartSelectForReferencedPort(oldPartSelect_);\n\n    if (oldPartSelect_)\n    {\n        emit increaseReferences(oldPartSelect_->getLeftRange());\n        emit increaseReferences(oldPartSelect_->getRightRange());\n    }\n    if (newPartSelect_)\n    {\n        emit decreaseReferences(newPartSelect_->getLeftRange());\n        emit decreaseReferences(newPartSelect_->getRightRange());\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: AdHocBoundsChangeCommand::redo()\n//-----------------------------------------------------------------------------\nvoid AdHocBoundsChangeCommand::redo()\n{\n    setPartSelectForReferencedPort(newPartSelect_);\n\n    if (newPartSelect_)\n    {\n        emit increaseReferences(newPartSelect_->getLeftRange());\n        emit increaseReferences(newPartSelect_->getRightRange());\n    }\n    if (oldPartSelect_)\n    {\n        emit decreaseReferences(oldPartSelect_->getLeftRange());\n        emit decreaseReferences(oldPartSelect_->getRightRange());\n    }\n\n    QUndoCommand::redo();\n}\n\n//-----------------------------------------------------------------------------\n// Function: AdHocBoundsChangeCommand::setPartSelectForReferencedPort()\n//-----------------------------------------------------------------------------\nvoid AdHocBoundsChangeCommand::setPartSelectForReferencedPort(QSharedPointer<PartSelect> partSelect)\n{\n    if (partSelect && (!partSelect->getLeftRange().isEmpty() || !partSelect->getRightRange().isEmpty()))\n    {\n        referencedPort_->setPartSelect(partSelect);\n    }\n    else\n    {\n        referencedPort_->setPartSelect(QSharedPointer<PartSelect>());\n    }\n}\n"
  },
  {
    "path": "editors/HWDesign/undoCommands/AdHocBoundsChangeCommand.h",
    "content": "//-----------------------------------------------------------------------------\n// File: AdHocBoundsChangeCommand.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 03.05.2017\n//\n// Description:\n// Undo command for changing left and right bounds of an ad hoc port.\n//-----------------------------------------------------------------------------\n\n#ifndef ADHOCBOUNDSCHANGECOMMAND_H\n#define ADHOCBOUNDSCHANGECOMMAND_H\n\nclass PortReference;\nclass PartSelect;\n\n#include <QUndoCommand>\n#include <QSharedPointer>\n#include <QString>\n#include <QObject>\n\n//-----------------------------------------------------------------------------\n//! Undo command for changing left and right bounds of an ad hoc port.\n//-----------------------------------------------------------------------------\nclass AdHocBoundsChangeCommand : public QObject, public QUndoCommand\n{\n    Q_OBJECT\n\npublic:\n\n    /*!\n     *  The constructor.\n     *\n     *    @param [in] referencedPort  The changed ad hoc port.\n     *    @param [in] newLeftBound    New value for the left bound of the tie off.\n     *    @param [in] newRightBound   New value for the right bound of the tie off.\n     *    @param [in] parent          The parent command.\n     */\n    AdHocBoundsChangeCommand(QSharedPointer<PortReference> referencedPort, QString const& newLeftBound,\n        QString const& newRightBound, QUndoCommand* parent = 0);\n\n    /*!\n     *  The destructor.\n     */\n    ~AdHocBoundsChangeCommand();\n\n    /*!\n     *  Undoes the command.\n     */\n    virtual void undo();\n\n    /*!\n     *  Redoes the command.\n     */\n    virtual void redo();\n\nsignals:\n    \n    /*!\n     *  Informs of new references created from the selected expression.\n     *\n     *    @param [in] expression  The selected expression.\n     */\n    void increaseReferences(QString const& expression);\n\n    /*!\n     *  Informs of old references created from the selected expression.\n     *\n     *    @param [in] expression  The selected expression.\n     */\n    void decreaseReferences(QString const& expression);\n\n    /*!\n     *  Informs of the need to refresh the ad hoc editors.\n     */\n    void refreshEditors();\n\nprivate:\n    \n    // Disable copying.\n    AdHocBoundsChangeCommand(AdHocBoundsChangeCommand const& rhs);\n    AdHocBoundsChangeCommand& operator=(AdHocBoundsChangeCommand const& rhs);\n\n    /*!\n     *  Setup the part select for the selected port reference.\n     *\n     *    @param [in] newLeftValue    New value for the left bound.\n     *    @param [in] newRightValue   New value for the right bound.\n     */\n    void setupPartSelectForPortReference(QString const& newLeftValue, QString const& newRightValue);\n\n    /*!\n     *  Set a new part select for the referenced port.\n     *\n     *    @param [in] partSelect  The new part select.\n     */\n    void setPartSelectForReferencedPort(QSharedPointer<PartSelect> partSelect);\n\n    //-----------------------------------------------------------------------------\n    // Data.\n    //-----------------------------------------------------------------------------\n\n    //! The selected port.\n    QSharedPointer<PortReference> referencedPort_;\n\n    //! The old part select of the referenced port.\n    QSharedPointer<PartSelect> oldPartSelect_;\n\n    //! The new part select of the referenced port.\n    QSharedPointer<PartSelect> newPartSelect_;\n};\n\n#endif // ADHOCTIEOFFBOUNDSCHANGECOMMAND_H\n"
  },
  {
    "path": "editors/HWDesign/undoCommands/AdHocConnectionAddCommand.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: AdHocConnectionAddCommand.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Esko Pekkarinen\r\n// Date: 02.10.2015\r\n//\r\n// Description:\r\n// <Short description of the class/file contents>\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"AdHocConnectionAddCommand.h\"\r\n\r\n#include <editors/common/DesignDiagram.h>\r\n\r\n#include <editors/HWDesign/AdHocConnectionItem.h>\r\n\r\n#include <IPXACTmodels/Design/Design.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AhHocConnectionAddCommand::AhHocConnectionAddCommand()\r\n//-----------------------------------------------------------------------------\r\nAdHocConnectionAddCommand::AdHocConnectionAddCommand(DesignDiagram* scene,\r\n    AdHocConnectionItem* connection,\r\n    QSharedPointer<Design> design,\r\n    QUndoCommand* parent) : QUndoCommand(parent),\r\n    connection_(connection),\r\n    scene_(scene),\r\n    design_(design),   \r\n    del_(false)\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AhHocConnectionAddCommand::~AhHocConnectionAddCommand()\r\n//-----------------------------------------------------------------------------\r\nAdHocConnectionAddCommand::~AdHocConnectionAddCommand()\r\n{\r\n    if (del_)\r\n    {\r\n        delete connection_;\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AhHocConnectionAddCommand::undo()\r\n//-----------------------------------------------------------------------------\r\nvoid AdHocConnectionAddCommand::undo()\r\n{\r\n    // Disconnect the ends.\r\n    connection_->disconnectEnds();\r\n    connection_->setSelected(false);\r\n\r\n    // Remove the interconnection from the scene.\r\n    scene_->removeItem(connection_);\r\n    del_ = true;\r\n\r\n    design_->getAdHocConnections()->removeAll(connection_->getInterconnection());\r\n    design_->removeRoute(connection_->getRouteExtension());\r\n    \r\n    // Execute child commands.\r\n    QUndoCommand::undo();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AhHocConnectionAddCommand::redo()\r\n//-----------------------------------------------------------------------------\r\nvoid AdHocConnectionAddCommand::redo()\r\n{\r\n    // Execute child commands.\r\n    QUndoCommand::redo();\r\n\r\n    if (!scene_->items().contains(connection_))\r\n    {\r\n        scene_->addItem(connection_);\r\n    }\r\n\r\n    design_->getAdHocConnections()->append(connection_->getInterconnection());\r\n    design_->addRoute(connection_->getRouteExtension());\r\n\r\n    connection_->connectEnds();\r\n\r\n    scene_->clearSelection();\r\n    connection_->setVisible(true);\r\n    del_ = false;\r\n}\r\n"
  },
  {
    "path": "editors/HWDesign/undoCommands/AdHocConnectionAddCommand.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: AhHocConnectionAddCommand.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Esko Pekkarinen\r\n// Date: 02.10.2015\r\n//\r\n// Description:\r\n// <Short description of the class/file contents>\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef ADHOCCONNECTION_ADD_COMMAND_H\r\n#define ADHOCCONNECTION_ADD_COMMAND_H\r\n\r\n#include <QSharedPointer>\r\n#include <QUndoCommand>\r\n\r\nclass AdHocConnection;\r\nclass AdHocConnectionItem;\r\nclass Design;\r\nclass DesignDiagram;\r\n//-----------------------------------------------------------------------------\r\n//! AhHocConnectionAddCommand class.\r\n//-----------------------------------------------------------------------------\r\nclass AdHocConnectionAddCommand : public QUndoCommand\r\n{\r\npublic:\r\n    /*!\r\n     *  Constructor.\r\n     *\r\n     *    @param [in] diagram     The diagram containing the item.\r\n     *    @param [in] conn        The adhoc connection to add.\r\n     *    @param [in] design      The design containing the adhoc connection.\r\n     *    @param [in] parent      The parent command.\r\n     */\r\n    AdHocConnectionAddCommand(DesignDiagram* diagram, AdHocConnectionItem* conn, QSharedPointer<Design> design,\r\n        QUndoCommand* parent = 0);\r\n\r\n    //! The destructor.\r\n    ~AdHocConnectionAddCommand();\r\n\r\n    //! Undoes the command.\r\n    virtual void undo();\r\n\r\n    //! Redoes the command.\r\n    virtual void redo();\r\n\r\nprivate:\r\n    // Disable copying.\r\n    AdHocConnectionAddCommand(AdHocConnectionAddCommand const& rhs);\r\n    AdHocConnectionAddCommand& operator=(AdHocConnectionAddCommand const& rhs);\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! The interconnection.\r\n    AdHocConnectionItem* connection_;\r\n\r\n    //! The diagram containing the added item.\r\n    DesignDiagram* scene_;\r\n\r\n    //! The design containing the ad hoc connection represented by the item.\r\n    QSharedPointer<Design> design_;\r\n\r\n    //! Boolean flag for indicating if the connection should be deleted in the destructor.\r\n    bool del_;\r\n};\r\n\r\n#endif // ADHOCCONNECTION_ADD_COMMAND_H\r\n"
  },
  {
    "path": "editors/HWDesign/undoCommands/AdHocConnectionDeleteCommand.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: AdHocConnectionDeleteCommand.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Esko Pekkarinen\r\n// Date: 04.02.2016\r\n//\r\n// Description:\r\n// Undo command for removing a AdHocConnection in design diagram.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"AdHocConnectionDeleteCommand.h\"\r\n\r\n#include <common/GenericEditProvider.h>\r\n\r\n#include <editors/common/Association/Association.h>\r\n#include <editors/common/Association/AssociationRemoveCommand.h>\r\n\r\n#include <editors/common/DesignDiagram.h>\r\n\r\n#include <editors/HWDesign/AdHocConnectionItem.h>\r\n\r\n#include <IPXACTmodels/Design/AdHocConnection.h>\r\n#include <IPXACTmodels/Design/Design.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AdHocConnectionDeleteCommand::AdHocConnectionDeleteCommand()\r\n//-----------------------------------------------------------------------------\r\nAdHocConnectionDeleteCommand::AdHocConnectionDeleteCommand(DesignDiagram* diagram, \r\n    AdHocConnectionItem* adHocConnection, QUndoCommand* parent) :\r\nQUndoCommand(parent),\r\nadHocConnection_(adHocConnection),\r\ndiagram_(diagram),\r\ndel_(true)\r\n{\r\n    for (Association* association : adHocConnection_->getAssociations())\r\n    {\r\n        new AssociationRemoveCommand(association, diagram_, this);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AdHocConnectionDeleteCommand::~AdHocConnectionDeleteCommand()\r\n//-----------------------------------------------------------------------------\r\nAdHocConnectionDeleteCommand::~AdHocConnectionDeleteCommand()\r\n{\r\n    if (del_)\r\n    {\r\n        delete adHocConnection_;\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AdHocConnectionDeleteCommand::undo()\r\n//-----------------------------------------------------------------------------\r\nvoid AdHocConnectionDeleteCommand::undo()\r\n{\r\n    // Execute child commands.\r\n    QUndoCommand::undo();\r\n\r\n    // Add the item back to the scene.\r\n    diagram_->addItem(adHocConnection_);\r\n    diagram_->clearSelection();\r\n\r\n    diagram_->getDesign()->getAdHocConnections()->append(adHocConnection_->getInterconnection());\r\n    diagram_->getDesign()->addRoute(adHocConnection_->getRouteExtension());\r\n\r\n    adHocConnection_->connectEnds();\r\n    adHocConnection_->setVisible(true);\r\n\r\n    del_ = false;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AdHocConnectionDeleteCommand::redo()\r\n//-----------------------------------------------------------------------------\r\nvoid AdHocConnectionDeleteCommand::redo()\r\n{\r\n    // Disconnect the ends.\r\n    adHocConnection_->setSelected(false);\r\n    adHocConnection_->disconnectEnds();\r\n\r\n    diagram_->getDesign()->getAdHocConnections()->removeOne(adHocConnection_->getInterconnection());\r\n    diagram_->getDesign()->removeRoute(adHocConnection_->getRouteExtension());\r\n\r\n    // Remove the item from the scene.\r\n    diagram_->removeItem(adHocConnection_);\r\n    del_ = true;\r\n\r\n    // Execute child commands.\r\n    QUndoCommand::redo();\r\n}\r\n"
  },
  {
    "path": "editors/HWDesign/undoCommands/AdHocConnectionDeleteCommand.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: AdHocConnectionDeleteCommand.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Esko Pekkarinen\r\n// Date: 04.02.2016\r\n//\r\n// Description:\r\n// Undo command for removing a AdHocConnection in design diagram.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef AdHocConnectionDELETECOMMAND_H\r\n#define ADHOCAdHocConnectionDELETECOMMAND_H\r\n\r\n#include <QObject>\r\n#include <QSharedPointer>\r\n#include <QUndoCommand>\r\n\r\n#include <IPXACTmodels/generaldeclarations.h>\r\n\r\nclass DesignDiagram;\r\nclass AdHocConnectionItem;\r\nclass PortMap;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Undo command for removing a AdHocConnection in design diagram.\r\n//-----------------------------------------------------------------------------\r\nclass AdHocConnectionDeleteCommand : public QUndoCommand\r\n{\r\npublic:\r\n\r\n    /*!\r\n     *  The constructor.\r\n     *\r\n     *    @param [in] diagram             The diagram containing the AdHocConnection item.\r\n     *    @param [in] adHocConnection     The AdHocConnection to remove.\r\n     *    @param [in] parent              The parent command.\r\n     */\r\n    AdHocConnectionDeleteCommand(DesignDiagram* diagram, AdHocConnectionItem* AdHocConnection,\r\n        QUndoCommand* parent = 0);\r\n\r\n    /*!\r\n     *  Destructor.\r\n     */\r\n    ~AdHocConnectionDeleteCommand();\r\n\r\n    /*!\r\n     *  Undoes the command.\r\n     */\r\n    virtual void undo();\r\n\r\n    /*!\r\n     *  Redoes the command.\r\n     */\r\n    virtual void redo();\r\n\r\nprivate:\r\n    // Disable copying.\r\n    AdHocConnectionDeleteCommand(AdHocConnectionDeleteCommand const& rhs);\r\n    AdHocConnectionDeleteCommand& operator=(AdHocConnectionDeleteCommand const& rhs);\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! The connection.\r\n    AdHocConnectionItem* adHocConnection_;\r\n\r\n    //! The port maps for the hierarchical end point (if any).\r\n    QList< QSharedPointer<PortMap> > portMaps_;\r\n\r\n    //! The graphics scene.\r\n    DesignDiagram* diagram_;\r\n\r\n    //! Boolean flag for indicating if the AdHocConnection should be deleted in the destructor.\r\n    bool del_;\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n\r\n#endif // AdHocConnectionDELETECOMMAND_H\r\n"
  },
  {
    "path": "editors/HWDesign/undoCommands/AdHocTieOffBoundsChangeCommand.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: AdHocTieOffBoundsChangeCommand.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 27.04.2017\n//\n// Description:\n// Undo command for changing tie off left and right bounds in the ad hoc editor.\n//-----------------------------------------------------------------------------\n\n#include \"AdHocTieOffBoundsChangeCommand.h\"\n\n#include <IPXACTmodels/common/PartSelect.h>\n#include <IPXACTmodels/Design/AdHocConnection.h>\n#include <IPXACTmodels/Design/Design.h>\n\n#include <editors/HWDesign/AdHocItem.h>\n#include <editors/HWDesign/HWComponentItem.h>\n#include <editors/HWDesign/HWDesignDiagram.h>\n\n//-----------------------------------------------------------------------------\n// Function: AdHocTieOffBoundsChangeCommand::AdHocTieOffBoundsChangeCommand()\n//-----------------------------------------------------------------------------\nAdHocTieOffBoundsChangeCommand::AdHocTieOffBoundsChangeCommand(AdHocItem* portItem, QString const& newLeftValue,\n    QString const& newRightValue, QSharedPointer<AdHocConnection> tieOffConnection, HWDesignDiagram* designDiagram,\n    QUndoCommand* parent):\nAdHocTiedValueCommand(portItem, tieOffConnection, designDiagram),\nAdHocBoundsChangeCommand(AdHocTiedValueCommand::getReferencedPort(), newLeftValue, newRightValue, parent)\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: AdHocTieOffBoundsChangeCommand::~AdHocTieOffBoundsChangeCommand()\n//-----------------------------------------------------------------------------\nAdHocTieOffBoundsChangeCommand::~AdHocTieOffBoundsChangeCommand()\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: AdHocTieOffBoundsChangeCommand::undo()\n//-----------------------------------------------------------------------------\nvoid AdHocTieOffBoundsChangeCommand::undo()\n{\n    AdHocBoundsChangeCommand::undo();\n\n    addOrRemoveTiedValueConnection();\n\n    emit refreshEditors();\n}\n\n//-----------------------------------------------------------------------------\n// Function: AdHocTieOffBoundsChangeCommand::redo()\n//-----------------------------------------------------------------------------\nvoid AdHocTieOffBoundsChangeCommand::redo()\n{\n    AdHocBoundsChangeCommand::redo();\n\n    addOrRemoveTiedValueConnection();\n\n    emit refreshEditors();\n}\n"
  },
  {
    "path": "editors/HWDesign/undoCommands/AdHocTieOffBoundsChangeCommand.h",
    "content": "//-----------------------------------------------------------------------------\n// File: AdHocTieOffBoundsChangeCommand.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 27.04.2017\n//\n// Description:\n// Undo command for changing tie off left and right bounds in the ad hoc editor.\n//-----------------------------------------------------------------------------\n\n#ifndef ADHOCTIEOFFBOUNDSCHANGECOMMAND_H\n#define ADHOCTIEOFFBOUNDSCHANGECOMMAND_H\n\n#include <editors/HWDesign/undoCommands/AdHocTiedValueCommand.h>\n\n#include <editors/HWDesign/undoCommands/AdHocBoundsChangeCommand.h>\n\nclass AdHocItem;\nclass AdHocConnection;\nclass HWDesignDiagram;\n\n#include <QUndoCommand>\n#include <QSharedPointer>\n#include <QString>\n\n//-----------------------------------------------------------------------------\n//! Undo command for changing tie off left and right bounds in the ad hoc editor.\n//-----------------------------------------------------------------------------\nclass AdHocTieOffBoundsChangeCommand : public AdHocTiedValueCommand, public AdHocBoundsChangeCommand\n{\npublic:\n\n    /*!\n     *  The constructor.\n     *\n     *    @param [in] portItem            The selected port item.\n     *    @param [in] newLeftValue        New value for the left bound of the tie off.\n     *    @param [in] newRightValue       New value for the right bound of the tie off.\n     *    @param [in] tieOffConnection    Connection containing the tie off.\n     *    @param [in] designDiagram       Diagram containing the HW design.\n     *    @param [in] parent              The parent command.\n     */\n    AdHocTieOffBoundsChangeCommand(AdHocItem* portItem, QString const& newLeftValue, QString const& newRightValue,\n        QSharedPointer<AdHocConnection> tieOffConnection, HWDesignDiagram* designDiagram,\n        QUndoCommand* parent = 0);\n\n    /*!\n     *  The destructor.\n     */\n    ~AdHocTieOffBoundsChangeCommand();\n\n    /*!\n     *  Undoes the command.\n     */\n    virtual void undo();\n\n    /*!\n     *  Redoes the command.\n     */\n    virtual void redo();\n\nprivate:\n    \n    // Disable copying.\n    AdHocTieOffBoundsChangeCommand(AdHocTieOffBoundsChangeCommand const& rhs);\n    AdHocTieOffBoundsChangeCommand& operator=(AdHocTieOffBoundsChangeCommand const& rhs);\n};\n\n#endif // ADHOCTIEOFFBOUNDSCHANGECOMMAND_H\n"
  },
  {
    "path": "editors/HWDesign/undoCommands/AdHocTieOffChangeCommand.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: AdHocTieOffChangeCommand.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Mikko Teuho\r\n// Date: 10.05.2016\r\n//\r\n// Description:\r\n// Undo command for changing tie off in ad hoc editor.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"AdHocTieOffChangeCommand.h\"\r\n\r\n#include <editors/HWDesign/HWComponentItem.h>\r\n#include <editors/HWDesign/AdHocItem.h>\r\n#include <editors/HWDesign/ActivePortItem.h>\r\n#include <editors/HWDesign/HierarchicalPortItem.h>\r\n#include <editors/HWDesign/HWDesignDiagram.h>\r\n\r\n#include <IPXACTmodels/Design/AdHocConnection.h>\r\n#include <IPXACTmodels/Design/Design.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AdHocTieOffChangeCommand::AdHocTieOffChangeCommand()\r\n//-----------------------------------------------------------------------------\r\nAdHocTieOffChangeCommand::AdHocTieOffChangeCommand(AdHocItem* portItem, QSharedPointer<AdHocConnection> connection,\r\n    QString const& newTieOffValue, QString newParsedTieOff, QString newFormattedTieOff, int newBase,\r\n    QString const& oldTieOffValue, QString oldParsedTieOff, QString oldFormattedTieOff, int oldBase,\r\n    HWDesignDiagram* designDiagram, QUndoCommand* parent):\r\nQObject(0),\r\nAdHocTiedValueCommand(portItem, connection, designDiagram),\r\nQUndoCommand(parent),\r\ncontainingDiagram_(designDiagram),\r\noldTieOff_(oldTieOffValue),\r\nparsedOldTieOff_(oldParsedTieOff),\r\nformattedOldTieOff_(oldFormattedTieOff),\r\noldBase_(oldBase),\r\nnewTieOff_(newTieOffValue),\r\nparsedNewTieOff_(newParsedTieOff),\r\nformattedNewTieOff_(newFormattedTieOff),\r\nnewBase_(newBase),\r\nvalueFormatter_()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AdHocTieOffChangeCommand::~AdHocTieOffChangeCommand()\r\n//-----------------------------------------------------------------------------\r\nAdHocTieOffChangeCommand::~AdHocTieOffChangeCommand()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AdHocTieOffChangeCommand::undo()\r\n//-----------------------------------------------------------------------------\r\nvoid AdHocTieOffChangeCommand::undo()\r\n{\r\n    QUndoCommand::undo();\r\n\r\n    QSharedPointer<AdHocConnection> tieOffConnection = getTiedValueConnection();\r\n    if (tieOffConnection)\r\n    {\r\n        tieOffConnection->setTiedValue(oldTieOff_);\r\n\r\n        changeTieOffSymbolsInConnectedPorts(oldTieOff_, parsedOldTieOff_, formattedOldTieOff_, oldBase_);\r\n\r\n        addOrRemoveTiedValueConnection();\r\n\r\n        emit increaseReferences(oldTieOff_);\r\n        emit decreaseReferences(newTieOff_);\r\n    }\r\n\r\n    emit refreshEditors();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AdHocTieOffChangeCommand::redo()\r\n//-----------------------------------------------------------------------------\r\nvoid AdHocTieOffChangeCommand::redo()\r\n{\r\n    QSharedPointer<AdHocConnection> tieOffConnection = getTiedValueConnection();\r\n    if (tieOffConnection)\r\n    {\r\n        tieOffConnection->setTiedValue(newTieOff_);\r\n\r\n        changeTieOffSymbolsInConnectedPorts(newTieOff_, parsedNewTieOff_, formattedNewTieOff_, newBase_);\r\n\r\n        addOrRemoveTiedValueConnection();\r\n\r\n        emit increaseReferences(newTieOff_);\r\n        emit decreaseReferences(oldTieOff_);\r\n    }\r\n\r\n    emit refreshEditors();\r\n\r\n    QUndoCommand::redo();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AdHocTieOffChangeCommand::changeTieOffSymbolsInConnectedPorts()\r\n//-----------------------------------------------------------------------------\r\nvoid AdHocTieOffChangeCommand::changeTieOffSymbolsInConnectedPorts(QString const& tieOffValue,\r\n    QString const& parsedTieOff, QString const& formattedTieOff, int tieOffBase) const\r\n{\r\n    QSharedPointer<AdHocConnection> tieOffConnection = getTiedValueConnection();\r\n\r\n    if (!tieOffConnection->getInternalPortReferences()->isEmpty())\r\n    {\r\n        for (auto const& internalReference : *tieOffConnection->getInternalPortReferences())\r\n        {\r\n            HWComponentItem* componentItem =\r\n                containingDiagram_->getComponentItem(internalReference->getComponentRef());\r\n\r\n            if (componentItem)\r\n            {\r\n                ActivePortItem* portItem = componentItem->getAdHocPort(internalReference->getPortRef());\r\n\r\n                if (portItem)\r\n                {\r\n                    drawTieOffSymbol(portItem, tieOffValue, parsedTieOff, formattedTieOff, tieOffBase);\r\n                }\r\n            }\r\n        }\r\n    }\r\n\r\n    if (!tieOffConnection->getExternalPortReferences()->isEmpty())\r\n    {\r\n        for (auto const& externalReference : *tieOffConnection->getExternalPortReferences())\r\n        {\r\n            HWConnectionEndpoint* endPoint =\r\n                containingDiagram_->getDiagramAdHocPort(externalReference->getPortRef());\r\n            if (endPoint)\r\n            {\r\n                AdHocItem* portItem = dynamic_cast<AdHocItem*>(endPoint);\r\n                if (portItem)\r\n                {\r\n                    drawTieOffSymbol(portItem, tieOffValue, parsedTieOff, formattedTieOff, tieOffBase);\r\n                }\r\n            }\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AdHocTieOffChangeCommand::drawTieOffSymbol()\r\n//-----------------------------------------------------------------------------\r\nvoid AdHocTieOffChangeCommand::drawTieOffSymbol(AdHocItem* portItem, QString const& tieOffValue,\r\n    QString parsedTieOff, QString formattedTieOff, int tieOffBase) const\r\n{\r\n    bool canConvertTieOffToInt = true;\r\n    parsedTieOff.toInt(&canConvertTieOffToInt);\r\n\r\n    if (tieOffValue.isEmpty())\r\n    {\r\n        portItem->removeTieOffItem();\r\n    }\r\n    else\r\n    {\r\n        QString tieOffWithBase = valueFormatter_.format(parsedTieOff, tieOffBase);\r\n\r\n        portItem->changeTieOffLabel(formattedTieOff, tieOffWithBase, canConvertTieOffToInt);\r\n    }\r\n}\r\n"
  },
  {
    "path": "editors/HWDesign/undoCommands/AdHocTieOffChangeCommand.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: AdHocTieOffChangeCommand.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Mikko Teuho\r\n// Date: 10.05.2016\r\n//\r\n// Description:\r\n// Undo command for changing tie off in ad hoc editor.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef ADHOCTIEOFFCHANGECOMMAND_H\r\n#define ADHOCTIEOFFCHANGECOMMAND_H\r\n\r\n#include <IPXACTmodels/common/validators/ValueFormatter.h>\r\n\r\n#include <editors/HWDesign/undoCommands/AdHocTiedValueCommand.h>\r\n\r\n#include <QUndoCommand>\r\n#include <QSharedPointer>\r\n#include <QObject>\r\n\r\nclass AdHocItem;\r\nclass AdHocConnection;\r\nclass Design;\r\nclass HWDesignDiagram;\r\nclass PortReference;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Undo command for changing tie off in ad hoc editor.\r\n//-----------------------------------------------------------------------------\r\nclass AdHocTieOffChangeCommand : public QObject, public AdHocTiedValueCommand, public QUndoCommand\r\n{\r\n    Q_OBJECT\r\n\r\npublic:\r\n\r\n    /*!\r\n     *  The constructor.\r\n     *\r\n     *    @param [in] portItem            The selected port item.\r\n     *    @param [in] connection          The tie off connection.\r\n     *    @param [in] newTieOffValue      A new value for tie off.\r\n     *    @param [in] newParsedTieOff     Parsed value of the new tie off.\r\n     *    @param [in] newFormattedTieOff  New tie off with the referenced parameter UUIDs changed into names.\r\n     *    @param [in] newBase             The base number of the parsed new tie off.\r\n     *    @param [in] oldTieOffValue      The old value for the tie off.\r\n     *    @param [in] oldParsedTieOff     Parsed value of the old tie off.\r\n     *    @param [in] oldFormattedTieOff  Old tie off with the referenced parameter UUIDs changed into names.\r\n     *    @param [in] oldBase             The base number of the parsed old tie off.\r\n     *    @param [in] design              The containing design.\r\n     *    @param [in] parent              Parent command.\r\n     */\r\n    AdHocTieOffChangeCommand(AdHocItem* portItem, QSharedPointer<AdHocConnection> connection,\r\n        QString const& newTieOffValue, QString newParsedTieOff, QString newFormattedTieOff, int newBase,\r\n        QString const& oldTieOffValue, QString oldParsedTieOff, QString oldFormattedTieOff, int oldBase,\r\n        HWDesignDiagram* designDiagram, QUndoCommand* parent = 0);\r\n\r\n    /*!\r\n     *  The destructor.\r\n     */\r\n    ~AdHocTieOffChangeCommand();\r\n\r\n    /*!\r\n     *  Undoes the command.\r\n     */\r\n    virtual void undo();\r\n\r\n    /*!\r\n     *  Redoes the command.\r\n     */\r\n    virtual void redo();\r\n\r\nsignals:\r\n\r\n    /*!\r\n     *  Informs of new references created from the selected expression.\r\n     *\r\n     *    @param [in] expression  The selected expression.\r\n     */\r\n    void increaseReferences(QString const& expression);\r\n\r\n    /*!\r\n     *  Informs of old references created from the selected expression.\r\n     *\r\n     *    @param [in] expression  The selected expression.\r\n     */\r\n    void decreaseReferences(QString const& expression);\r\n\r\n    /*!\r\n     *  Informs of the need to refresh the ad hoc editors.\r\n     */\r\n    void refreshEditors();\r\n\r\nprivate:\r\n    \r\n    // Disable copying.\r\n    AdHocTieOffChangeCommand(AdHocTieOffChangeCommand const& rhs);\r\n    AdHocTieOffChangeCommand& operator=(AdHocTieOffChangeCommand const& rhs);\r\n\r\n    /*!\r\n     *  Change the tie off symbols in the connected ports.\r\n     *\r\n     *    @param [in] tieOffValue         The tie off value.\r\n     *    @param [in] parsedTieOff        The parsed tie off value.\r\n     *    @param [in] formattedTieOff     The tie off with referenced parameter UUIDs changed to names.\r\n     *    @param [in] tieOffBase          The base number of the tie off.\r\n     */\r\n    void changeTieOffSymbolsInConnectedPorts(QString const& tieOffValue, QString const& parsedTieOff,\r\n        QString const& formattedTieOff, int tieOffBase) const;\r\n\r\n    /*!\r\n     *  Draw a tie off symbol matching the given value.\r\n     *\r\n     *    @param [in] portItem            The port item whose symbol is being redrawn.\r\n     *    @param [in] tieOffValue         The tie off expression.\r\n     *    @param [in] parsedTieOff        The parsed tie off value.\r\n     *    @param [in] formattedTieOff     The tie off with the referenced parameter UUIDs changed to names.\r\n     *    @param [in] tieOffBase          The base number of the tie off.\r\n     */\r\n    void drawTieOffSymbol(AdHocItem* portItem, QString const& tieOffValue, QString parsedTieOff,\r\n        QString formattedTieOff, int tieOffBase) const;\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! The design diagram containing the related ad hoc port item.\r\n    HWDesignDiagram* containingDiagram_;\r\n\r\n    //! The old value for the tie off.\r\n    QString oldTieOff_;\r\n\r\n    //! Parsed value of the old tie off.\r\n    QString parsedOldTieOff_;\r\n\r\n    //! Old tie off with the referenced parameter UUIDs changed to parameter names.\r\n    QString formattedOldTieOff_;\r\n\r\n    //! The base number of the old tie off.\r\n    int oldBase_;\r\n\r\n    //! A new value for tie off.\r\n    QString newTieOff_;\r\n\r\n    //! Parsed value of the new tie off.\r\n    QString parsedNewTieOff_;\r\n\r\n    //! New tie off with the referenced parameter UUIDs changed to parameter names.\r\n    QString formattedNewTieOff_;\r\n\r\n    //! The base number of the new tie off.\r\n    int newBase_;\r\n\r\n    //! Formats values to the base number of the expression.\r\n    ValueFormatter valueFormatter_;\r\n};\r\n\r\n#endif // ADHOCTIEOFFCHANGECOMMAND_H\r\n"
  },
  {
    "path": "editors/HWDesign/undoCommands/AdHocTieOffConnectionDeleteCommand.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: AdHocTieOffConnectionDeleteCommand.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 20.10.2017\n//\n// Description:\n// Undo command for deleting ad hoc tie off connection.\n//-----------------------------------------------------------------------------\n\n#include \"AdHocTieOffConnectionDeleteCommand.h\"\n\n#include <IPXACTmodels/Design/Design.h>\n#include <IPXACTmodels/Design/AdHocConnection.h>\n\n//-----------------------------------------------------------------------------\n// Function: AdHocTieOffConnectionDeleteCommand::AdHocTieOffConnectionDeleteCommand()\n//-----------------------------------------------------------------------------\nAdHocTieOffConnectionDeleteCommand::AdHocTieOffConnectionDeleteCommand(QSharedPointer<Design> containingDesign,\n    QSharedPointer<AdHocConnection> connection, QUndoCommand* parent):\nQUndoCommand(parent),\ncontainingDesign_(containingDesign),\ntieOffConnection_(connection)\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: AdHocTieOffConnectionDeleteCommand::~AdHocTieOffConnectionDeleteCommand()\n//-----------------------------------------------------------------------------\nAdHocTieOffConnectionDeleteCommand::~AdHocTieOffConnectionDeleteCommand()\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: AdHocTieOffConnectionDeleteCommand::undo()\n//-----------------------------------------------------------------------------\nvoid AdHocTieOffConnectionDeleteCommand::undo()\n{\n    if (containingDesign_ && tieOffConnection_ &&\n        !containingDesign_->getAdHocConnections()->contains(tieOffConnection_))\n    {\n        containingDesign_->getAdHocConnections()->append(tieOffConnection_);\n    }\n\n    // Execute child commands.\n    QUndoCommand::undo();\n}\n\n//-----------------------------------------------------------------------------\n// Function: AdHocTieOffConnectionDeleteCommand::redo()\n//-----------------------------------------------------------------------------\nvoid AdHocTieOffConnectionDeleteCommand::redo()\n{\n    // Execute child commands.\n    QUndoCommand::redo();\n\n    if (containingDesign_ && tieOffConnection_ &&\n        containingDesign_->getAdHocConnections()->contains(tieOffConnection_))\n    {\n        containingDesign_->getAdHocConnections()->removeAll(tieOffConnection_);\n    }\n}\n"
  },
  {
    "path": "editors/HWDesign/undoCommands/AdHocTieOffConnectionDeleteCommand.h",
    "content": "//-----------------------------------------------------------------------------\n// File: AdHocTieOffConnectionDeleteCommand.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 20.10.2017\n//\n// Description:\n// Undo command for deleting ad hoc tie off connection.\n//-----------------------------------------------------------------------------\n\n#ifndef ADHOCTIEOFFCONNECTIONDELETECOMMAND_H\n#define ADHOCTIEOFFCONNECTIONDELETECOMMAND_H\n\n#include <QUndoCommand>\n#include <QSharedPointer>\n\nclass AdHocConnection;\nclass Design;\n\n//-----------------------------------------------------------------------------\n//! Undo command for deleting ad hoc tie off connection.\n//-----------------------------------------------------------------------------\nclass AdHocTieOffConnectionDeleteCommand : public QUndoCommand\n{\npublic:\n\n    /*!\n     *  Constructor.\n     *\n     *    @param [in] containingDesign    The design containing the ad hoc tie off connection.\n     *    @param [in] connection          The deleted ad hoc connection containing a tie off value.\n     *    @param [in] parent              The parent undo command.\n     */\n    AdHocTieOffConnectionDeleteCommand(QSharedPointer<Design> containingDesign,\n        QSharedPointer<AdHocConnection> connection, QUndoCommand* parent = 0);\n\n    /*!\n     *  Destructor.\n     */\n    ~AdHocTieOffConnectionDeleteCommand();\n\n    /*!\n     *  Undoes the command.\n     */\n    virtual void undo();\n\n    /*!\n     *  Redoes the command.\n     */\n    virtual void redo();\n\nprivate:\n\n    // Disable copying.\n    AdHocTieOffConnectionDeleteCommand(AdHocTieOffConnectionDeleteCommand const& rhs);\n    AdHocTieOffConnectionDeleteCommand& operator=(AdHocTieOffConnectionDeleteCommand const& rhs);\n\n    //-----------------------------------------------------------------------------\n    // Data.\n    //-----------------------------------------------------------------------------\n\n    //! The design containing the ad hoc tie off connection.\n    QSharedPointer<Design> containingDesign_;\n\n    //! The deleted ad hoc connection containing a tie off value.\n    QSharedPointer<AdHocConnection> tieOffConnection_;\n};\n\n#endif // ADHOCTIEOFFCONNECTIONDELETECOMMAND_H\n"
  },
  {
    "path": "editors/HWDesign/undoCommands/AdHocTiedValueCommand.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: AdHocTiedValueCommand.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 03.05.2017\n//\n// Description:\n// Parent undo command for ad hoc tied value commands.\n//-----------------------------------------------------------------------------\n\n#include \"AdHocTiedValueCommand.h\"\n\n#include <IPXACTmodels/Design/Design.h>\n\n#include <editors/HWDesign/AdHocItem.h>\n#include <editors/HWDesign/HWDesignDiagram.h>\n#include <editors/HWDesign/HWComponentItem.h>\n\n//-----------------------------------------------------------------------------\n// Function: AdHocTiedValueCommand::AdHocTiedValueCommand()\n//-----------------------------------------------------------------------------\nAdHocTiedValueCommand::AdHocTiedValueCommand(AdHocItem* portItem,\n    QSharedPointer<AdHocConnection> tiedValueConnection, HWDesignDiagram* designDiagram):\ntiedValueConnection_(tiedValueConnection),\ncontainingDesign_(designDiagram->getDesign()),\nreferencedPort_()\n{\n    if (!tiedValueConnection_)\n    {\n        tiedValueConnection_ = createConnectionForTiedValue(portItem);\n    }\n    else\n    {\n        setupReferencedPort(portItem->name());\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: AdHocTiedValueCommand::createConnectionForTiedValue()\n//-----------------------------------------------------------------------------\nQSharedPointer<AdHocConnection> AdHocTiedValueCommand::createConnectionForTiedValue(AdHocItem* portItem)\n{\n    QString connectionName = createNameForTiedValueConnection(portItem);\n\n    QSharedPointer<AdHocConnection> connection (new AdHocConnection(connectionName));\n\n    QSharedPointer<PortReference> portReference (new PortReference(portItem->name()));\n\n    ComponentItem* containingComponent = portItem->encompassingComp();\n    if (containingComponent)\n    {\n        portReference->setComponentRef(containingComponent->name());\n        connection->getInternalPortReferences()->append(portReference);\n    }\n    else\n    {\n        connection->getExternalPortReferences()->append(portReference);\n    }\n\n    referencedPort_ = portReference;\n\n    return connection;\n}\n\n//-----------------------------------------------------------------------------\n// Function: AdHocTiedValueCommand::createNameForTiedValueConnection()\n//-----------------------------------------------------------------------------\nQString AdHocTiedValueCommand::createNameForTiedValueConnection(AdHocItem* portItem) const\n{\n    ComponentItem* containingComponent = portItem->encompassingComp();\n\n    QString instanceName = \"\";\n\n    if (containingComponent)\n    {\n        instanceName = containingComponent->name();\n        instanceName.append(\"_\");\n    }\n\n    return instanceName + portItem->name() + QStringLiteral(\"_to_tiedValue\");\n}\n\n//-----------------------------------------------------------------------------\n// Function: AdHocTiedValueCommand::~AdHocTiedValueCommand()\n//-----------------------------------------------------------------------------\nAdHocTiedValueCommand::~AdHocTiedValueCommand()\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: AdHocTiedValueCommand::getTiedValueConnection()\n//-----------------------------------------------------------------------------\nQSharedPointer<AdHocConnection> AdHocTiedValueCommand::getTiedValueConnection() const\n{\n    return tiedValueConnection_;\n}\n\n//-----------------------------------------------------------------------------\n// Function: AdHocTiedValueCommand::setupReferencedPort()\n//-----------------------------------------------------------------------------\nvoid AdHocTiedValueCommand::setupReferencedPort(QString const& portName)\n{\n    for (auto const& externalPort : *tiedValueConnection_->getExternalPortReferences())\n    {\n        if (externalPort->getPortRef().compare(portName) == 0)\n        {\n            referencedPort_ = externalPort;\n            return;\n        }\n    }\n\n    for (auto const& internalPort : *tiedValueConnection_->getInternalPortReferences())\n    {\n        if (internalPort->getPortRef().compare(portName) == 0)\n        {\n            referencedPort_ = internalPort;\n            return;\n        }\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: AdHocTiedValueCommand::getReferencedPort()\n//-----------------------------------------------------------------------------\nQSharedPointer<PortReference> AdHocTiedValueCommand::getReferencedPort() const\n{\n    return referencedPort_;\n}\n\n//-----------------------------------------------------------------------------\n// Function: AdHocTiedValueCommand::addOrRemoveConnection()\n//-----------------------------------------------------------------------------\nvoid AdHocTiedValueCommand::addOrRemoveTiedValueConnection()\n{\n    QSharedPointer<PartSelect> portPartSelect = referencedPort_->getPartSelect();\n\n    if (containingDesign_->getAdHocConnections()->contains(tiedValueConnection_) &&\n        tiedValueConnection_->getTiedValue().isEmpty() && (!portPartSelect ||\n        (portPartSelect && portPartSelect->getLeftRange().isEmpty() && portPartSelect->getRightRange().isEmpty())))\n    {\n        containingDesign_->getAdHocConnections()->removeAll(tiedValueConnection_);\n    }\n    else if (!containingDesign_->getAdHocConnections()->contains(tiedValueConnection_))\n    {\n        containingDesign_->getAdHocConnections()->append(tiedValueConnection_);\n    }\n}\n"
  },
  {
    "path": "editors/HWDesign/undoCommands/AdHocTiedValueCommand.h",
    "content": "//-----------------------------------------------------------------------------\n// File: AdHocTiedValueCommand.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 03.05.2017\n//\n// Description:\n// Parent undo command for ad hoc tied value commands.\n//-----------------------------------------------------------------------------\n\n#ifndef ADHOCTIEDVALUECOMMAND_H\n#define ADHOCTIEDVALUECOMMAND_H\n\n#include <QUndoCommand>\n#include <QSharedPointer>\n\nclass AdHocItem;\nclass AdHocConnection;\nclass PortReference;\nclass Design;\nclass HWDesignDiagram;\n\n//-----------------------------------------------------------------------------\n//! Parent undo command for ad hoc tied value commands.\n//-----------------------------------------------------------------------------\nclass AdHocTiedValueCommand\n{\npublic:\n\n    /*!\n     *  The constructor.\n     *\n     *    @param [in] portItem                The selected port item.\n     *    @param [in] tiedValueConnection     The tie off connection.\n     *    @param [in] designDiagram           Diagram containing the HW design.\n     */\n    AdHocTiedValueCommand(AdHocItem* portItem, QSharedPointer<AdHocConnection> tiedValueConnection,\n        HWDesignDiagram* designDiagram);\n\n    /*!\n     *  The destructor.\n     */\n    ~AdHocTiedValueCommand();\n\nprotected:\n\n    /*!\n     *  Get the tied value connection.\n     *\n     *    @return The connection containing the tied values.\n     */\n    QSharedPointer<AdHocConnection> getTiedValueConnection() const;\n\n    /*!\n     *  Get the referenced port of the tied value connection.\n     *\n     *    @return The referenced port.\n     */\n    QSharedPointer<PortReference> getReferencedPort() const;\n\n    /*!\n     *  Add or remove the tied value connection.\n     */\n    void addOrRemoveTiedValueConnection();\n\nprivate:\n    \n    // Disable copying.\n    AdHocTiedValueCommand(AdHocTiedValueCommand const& rhs);\n    AdHocTiedValueCommand& operator=(AdHocTiedValueCommand const& rhs);\n\n    /*!\n     *  Create an ad hoc connection for the selected port item.\n     *\n     *    @param [in] portItem    The selected port item.\n     *\n     *    @return The ad hoc connection for containing the tie off value.\n     */\n    QSharedPointer<AdHocConnection> createConnectionForTiedValue(AdHocItem* portItem);\n\n    /*!\n     *  Create a name for a tied value connection.\n     *\n     *    @param [in] portItem    The port item whose connection is being created.\n     *\n     *    @return Name of the tied value connection, <InstanceName>_<portName>_to_tiedValue\n     */\n    QString createNameForTiedValueConnection(AdHocItem* portItem) const;\n\n    /*!\n     *  Setup the referenced port.\n     *\n     *    @param [in] portName    Name of the ad hoc port item.\n     */\n    void setupReferencedPort(QString const& portName);\n\n    //-----------------------------------------------------------------------------\n    // Data.\n    //-----------------------------------------------------------------------------\n\n    //! The tie off connection.\n    QSharedPointer<AdHocConnection> tiedValueConnection_;\n\n    //! The containing design.\n    QSharedPointer<Design> containingDesign_;\n\n    //! The referenced port.\n    QSharedPointer<PortReference> referencedPort_;\n};\n\n#endif // ADHOCTIEDVALUECOMMAND_H\n"
  },
  {
    "path": "editors/HWDesign/undoCommands/AdHocVisibilityChangeCommand.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: AdHocVisibilityChangeCommand.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Esko Pekkarinen\r\n// Date: 30.09.2015\r\n//\r\n// Description:\r\n// Undo command for changing port adhoc visibility in design diagram.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"AdHocVisibilityChangeCommand.h\"\r\n\r\n#include <common/graphicsItems/GraphicsColumn.h>\r\n\r\n#include <editors/common/DesignDiagram.h>\r\n\r\n#include <editors/HWDesign/AdHocItem.h>\r\n#include <editors/HWDesign/AdHocEnabled.h>\r\n#include <editors/HWDesign/HWComponentItem.h>\r\n#include <editors/HWDesign/HWConnectionEndpoint.h>\r\n#include <editors/HWDesign/AdHocConnectionItem.h>\r\n#include <editors/HWDesign/undoCommands/AdHocConnectionDeleteCommand.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AdHocVisibilityChangeCommand::AdHocVisibilityChangeCommand()\r\n//-----------------------------------------------------------------------------\r\nAdHocVisibilityChangeCommand::AdHocVisibilityChangeCommand(AdHocEnabled* dataSource, QString const& portName,\r\n                                                           bool newVisibility, QUndoCommand* parent):\r\nQUndoCommand(parent),\r\ndataSource_(dataSource),\r\nportName_(portName),\r\nnewVisibility_(newVisibility),\r\nadhocPort_()\r\n{\r\n    HWConnectionEndpoint* port = dataSource_->getDiagramAdHocPort(portName);\r\n\r\n    if (port)\r\n    {\r\n        adhocPort_ = dynamic_cast<AdHocItem*>(port);\r\n        \r\n        if (!newVisibility_ && adhocPort_)\r\n        {\r\n            pos_ = port->scenePos();\r\n\r\n            for (GraphicsConnection* connection : adhocPort_->getConnections())\r\n            {\r\n                createConnectionDeleteCommand(connection);\r\n            }\r\n\r\n            for (GraphicsConnection* connection : adhocPort_->getOffPageConnector()->getConnections())\r\n            {\r\n                createConnectionDeleteCommand(connection);\r\n            }\r\n        }\r\n    }\r\n    else\r\n    {\r\n        adhocPort_ = dataSource_->createAdhocItem(portName);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AdHocVisibilityChangeCommand::createConnectionDeleteCommand()\r\n//-----------------------------------------------------------------------------\r\nvoid AdHocVisibilityChangeCommand::createConnectionDeleteCommand(GraphicsConnection* connection)\r\n{\r\n    DesignDiagram* adHocDiagram = dynamic_cast<DesignDiagram*>(dataSource_);\r\n    if (adHocDiagram)\r\n    {\r\n        AdHocConnectionItem* adHocConnection = dynamic_cast<AdHocConnectionItem*>(connection);\r\n        if (adHocConnection)\r\n        {\r\n            new AdHocConnectionDeleteCommand(adHocDiagram, adHocConnection, this);\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AdHocVisibilityChangeCommand::~AdHocVisibilityChangeCommand()\r\n//-----------------------------------------------------------------------------\r\nAdHocVisibilityChangeCommand::~AdHocVisibilityChangeCommand()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AdHocVisibilityChangeCommand::undo()\r\n//-----------------------------------------------------------------------------\r\nvoid AdHocVisibilityChangeCommand::undo()\r\n{\r\n    dataSource_->changeAdhocVisibility(adhocPort_, !newVisibility_);\r\n\r\n    changePortItemVisibility(!newVisibility_);\r\n\r\n    if (!newVisibility_)\r\n    {\r\n        adhocPort_->setPos(adhocPort_->parentItem()->mapFromScene(pos_));\r\n\r\n        if (adhocPort_->type() == GFX_TYPE_DIAGRAM_ADHOC_INTERFACE)\r\n        {\r\n            GraphicsColumn* column = static_cast<GraphicsColumn*>(adhocPort_->parentItem());\r\n            if (column)\r\n            {\r\n                column->onMoveItem(adhocPort_);\r\n            }\r\n        }\r\n        else if (adhocPort_->type() == GFX_TYPE_DIAGRAM_ADHOC_PORT)\r\n        {\r\n            HWComponentItem* componentItem = static_cast<HWComponentItem*>(adhocPort_->parentItem());\r\n            componentItem->onMovePort(adhocPort_);\r\n        }\r\n    }\r\n\r\n    // Execute child commands.\r\n    QUndoCommand::undo();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AdHocVisibilityChangeCommand::redo()\r\n//-----------------------------------------------------------------------------\r\nvoid AdHocVisibilityChangeCommand::redo()\r\n{\r\n    // Execute child commands.\r\n    QUndoCommand::redo();\r\n\r\n    dataSource_->changeAdhocVisibility(adhocPort_, newVisibility_);\r\n\r\n    changePortItemVisibility(newVisibility_);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AdHocVisibilityChangeCommand::changePortItemVisibility()\r\n//-----------------------------------------------------------------------------\r\nvoid AdHocVisibilityChangeCommand::changePortItemVisibility(bool currentVisibility)\r\n{\r\n    if (currentVisibility)\r\n    {\r\n        adhocPort_->show();\r\n    }\r\n    else\r\n    {\r\n        adhocPort_->hide();\r\n    }\r\n}\r\n"
  },
  {
    "path": "editors/HWDesign/undoCommands/AdHocVisibilityChangeCommand.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: AdHocVisibilityChangeCommand.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Esko Pekkarinen\r\n// Date: 30.09.2015\r\n//\r\n// Description:\r\n// Undo command for changing port adhoc visibility in design diagram.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef ADHOCVISIBILITYCHANGECOMMAND_H\r\n#define ADHOCVISIBILITYCHANGECOMMAND_H\r\n\r\n#include <QPointF>\r\n#include <QUndoCommand>\r\n\r\nclass AdHocItem;\r\nclass AdHocEnabled;\r\nclass GraphicsConnection;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Undo command for changing port adhoc visibility in design diagram.\r\n//-----------------------------------------------------------------------------\r\nclass AdHocVisibilityChangeCommand : public QUndoCommand\r\n{\r\npublic:\r\n    /*!\r\n     *  Constructor.\r\n     *\r\n     *    @param [in] dataSource    The ad-hoc enabled data source.\r\n     *    @param [in] portName      The name of the port.\r\n     *    @param [in] newVisiblity  The new ad-hoc visibility of the port.\r\n     *    @param [in] parent        The parent undo command.\r\n     */\r\n    AdHocVisibilityChangeCommand(AdHocEnabled* dataSource, QString const& portName, bool newVisibility,\r\n        QUndoCommand* parent = 0);\r\n\r\n    /*!\r\n     *  Destructor.\r\n     */\r\n    ~AdHocVisibilityChangeCommand();\r\n\r\n    /*!\r\n     *  Undoes the command.\r\n     */\r\n    virtual void undo();\r\n\r\n    /*!\r\n     *  Redoes the command.\r\n     */\r\n    virtual void redo();\r\n\r\nprivate:\r\n    // Disable copying.\r\n    AdHocVisibilityChangeCommand(AdHocVisibilityChangeCommand const& rhs);\r\n    AdHocVisibilityChangeCommand& operator=(AdHocVisibilityChangeCommand const& rhs);\r\n\r\n    /*!\r\n     *  Create a delete command for a connected connection.\r\n     *\r\n     *    @param [in] connection  The selected connection.\r\n     */\r\n    void createConnectionDeleteCommand(GraphicsConnection* connection);\r\n\r\n    /*!\r\n     *  Change the visibility status of the selected port item.\r\n     *\r\n     *    @param [in] currentVisibility   The new visibility of the port item.\r\n     */\r\n    void changePortItemVisibility(bool currentVisibility);\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! The component containing the port.\r\n    AdHocEnabled* dataSource_;\r\n\r\n    //! The name of the port.\r\n    QString portName_;\r\n\r\n    //! The saved port position.\r\n    QPointF pos_;\r\n\r\n    //! The new ad-hoc visibility for the port.\r\n    bool newVisibility_;\r\n\r\n    //! The selected ad hoc port item.\r\n    AdHocItem* adhocPort_;\r\n};\r\n\r\n#endif // ADHOCVISIBILITYCHANGECOMMAND_H\r\n"
  },
  {
    "path": "editors/HWDesign/undoCommands/ColumnDeleteCommand.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ColumnDeleteCommand.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Esko Pekkarinen\r\n// Date: 30.09.2015\r\n//\r\n// Description:\r\n// Undo command for removing a column in a design diagram.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"ColumnDeleteCommand.h\"\r\n#include \"ComponentDeleteCommand.h\"\r\n#include \"ConnectionDeleteCommand.h\"\r\n\r\n#include <common/graphicsItems/GraphicsItemTypes.h>\r\n#include <common/graphicsItems/GraphicsColumn.h>\r\n#include <common/graphicsItems/GraphicsColumnLayout.h>\r\n\r\n#include <editors/common/DesignDiagram.h>\r\n#include <editors/common/Association/AssociationRemoveCommand.h>\r\n\r\n#include <editors/HWDesign/HWComponentItem.h>\r\n#include <editors/HWDesign/HWConnection.h>\r\n#include <editors/HWDesign/HWConnectionEndpoint.h>\r\n#include <editors/HWDesign/HierarchicalPortItem.h>\r\n#include <editors/HWDesign/HWDesignDiagram.h>\r\n\r\n#include <editors/HWDesign/undoCommands/TopAdHocVisibilityChangeCommand.h>\r\n\r\n#include <IPXACTmodels/Design/Design.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ColumnDeleteCommand::ColumnDeleteCommand()\r\n//-----------------------------------------------------------------------------\r\nColumnDeleteCommand::ColumnDeleteCommand(DesignDiagram* diagram, GraphicsColumnLayout* layout,\r\n    GraphicsColumn* column, QUndoCommand* parent): \r\nQUndoCommand(parent),\r\ndesign_(diagram->getDesign()),\r\nlayout_(layout),\r\ncolumnItem_(column),\r\ndel_(true)\r\n{\r\n    // Create child commands for removing interconnections.\r\n    QList<GraphicsConnection*> connections;\r\n\r\n    for (QGraphicsItem* item : column->childItems())\r\n    {\r\n        if (item->type() == HWComponentItem::Type)\r\n        {\r\n            HWComponentItem* comp = static_cast<HWComponentItem*>(item);\r\n\r\n            new ComponentDeleteCommand(diagram, column, comp, this);\r\n        }\r\n        else if (item->type() == GFX_TYPE_DIAGRAM_INTERFACE)\r\n        {\r\n            HWConnectionEndpoint* endpoint = static_cast<HWConnectionEndpoint*>(item);\r\n\r\n            for (GraphicsConnection* connection : endpoint->getConnections())\r\n            {\r\n                if (!connections.contains(connection))\r\n                {\r\n                    new ConnectionDeleteCommand(diagram, static_cast<HWConnection*>(connection), this);\r\n                    connections.append(connection);\r\n                }\r\n            }\r\n\r\n            if (endpoint->getOffPageConnector() != 0)\r\n            {\r\n                for (GraphicsConnection* connection : endpoint->getOffPageConnector()->getConnections())\r\n                {\r\n                    if (!connections.contains(connection))\r\n                    {\r\n                        new ConnectionDeleteCommand(diagram, static_cast<HWConnection*>(connection), this);\r\n                        connections.append(connections);\r\n                    }\r\n                }\r\n            }\r\n        }\r\n        else if (item->type() == GFX_TYPE_DIAGRAM_ADHOC_INTERFACE)\r\n        {\r\n            HWDesignDiagram* hwDiagram = dynamic_cast<HWDesignDiagram*>(diagram);\r\n            if (hwDiagram)\r\n            {\r\n                HierarchicalPortItem* adHocInterface = dynamic_cast<HierarchicalPortItem*>(item);\r\n\r\n                new TopAdHocVisibilityChangeCommand(hwDiagram, adHocInterface->name(), false, this);\r\n            }\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ColumnDeleteCommand::~ColumnDeleteCommand()\r\n//-----------------------------------------------------------------------------\r\nColumnDeleteCommand::~ColumnDeleteCommand()\r\n{\r\n    if (del_)\r\n    {\r\n        delete columnItem_;\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ColumnDeleteCommand::undo()\r\n//-----------------------------------------------------------------------------\r\nvoid ColumnDeleteCommand::undo()\r\n{\r\n    // Add the item back to the layout.\r\n    design_->addColumn(columnItem_->getColumnDesc());\r\n    layout_->addColumn(columnItem_);\r\n    del_ = false;\r\n\r\n    // Execute child commands.\r\n    QUndoCommand::undo();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ColumnDeleteCommand::redo()\r\n//-----------------------------------------------------------------------------\r\nvoid ColumnDeleteCommand::redo()\r\n{\r\n    // Execute child commands.\r\n    QUndoCommand::redo();\r\n\r\n    // Remove the item from the layout.\r\n    layout_->removeColumn(columnItem_);\r\n    design_->removeColumn(columnItem_->getColumnDesc());\r\n\r\n    del_ = true;\r\n}\r\n"
  },
  {
    "path": "editors/HWDesign/undoCommands/ColumnDeleteCommand.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ColumnDeleteCommand.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Esko Pekkarinen\r\n// Date: 30.09.2015\r\n//\r\n// Description:\r\n// Undo command for removing a column in a design diagram.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef COLUMNDELETECOMMAND_H\r\n#define COLUMNDELETECOMMAND_H\r\n\r\n#include <QUndoCommand>\r\n#include <QGraphicsItem>\r\n#include <QObject>\r\n\r\nclass Design;\r\nclass DesignDiagram;\r\nclass GraphicsColumn;\r\nclass GraphicsColumnLayout;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Undo command for removing a column in a design diagram.\r\n//-----------------------------------------------------------------------------\r\nclass ColumnDeleteCommand : public QUndoCommand\r\n{\r\npublic:\r\n    /*!\r\n     *  The constructor.\r\n     *\r\n     *    @param [in] diagram     The diagram containing the column item.\r\n     *    @param [in] layout      The column layout to use.\r\n     *    @param [in] column      The column to remove.\r\n     *    @param [in] parent      The parent command.\r\n     */\r\n    ColumnDeleteCommand(DesignDiagram* diagram, GraphicsColumnLayout* layout, GraphicsColumn* column, \r\n                        QUndoCommand* parent = 0);\r\n\r\n    /*!\r\n     *  Destructor.\r\n     */\r\n    ~ColumnDeleteCommand();\r\n\r\n    /*!\r\n     *  Undoes the command.\r\n     */\r\n    virtual void undo();\r\n\r\n    /*!\r\n     *  Redoes the command.\r\n     */\r\n    virtual void redo();\r\n\r\nprivate:\r\n    // Disable copying.\r\n    ColumnDeleteCommand(ColumnDeleteCommand const& rhs);\r\n    ColumnDeleteCommand& operator=(ColumnDeleteCommand const& rhs);\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! The design being edited.\r\n    QSharedPointer<Design> design_;\r\n\r\n    //! The column layout.\r\n    GraphicsColumnLayout* layout_;\r\n\r\n    //! The diagram column.\r\n    GraphicsColumn* columnItem_;\r\n\r\n    //! Boolean flag for indicating if the column should be deleted in the destructor.\r\n    bool del_;\r\n};\r\n\r\n#endif // COLUMNDELETECOMMAND_H\r\n"
  },
  {
    "path": "editors/HWDesign/undoCommands/ComponentDeleteCommand.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ComponentDeleteCommand.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Esko Pekkarinen\r\n// Date: 30.09.2015\r\n//\r\n// Description:\r\n// Undo command for removing a component item in a design diagram.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"ComponentDeleteCommand.h\"\r\n\r\n#include \"ConnectionDeleteCommand.h\"\r\n\r\n#include <common/graphicsItems/GraphicsColumn.h>\r\n#include <common/graphicsItems/GraphicsConnection.h>\r\n\r\n#include <editors/common/DesignDiagram.h>\r\n\r\n#include <editors/HWDesign/HWComponentItem.h>\r\n#include <editors/HWDesign/HWConnection.h>\r\n#include <editors/HWDesign/HWConnectionEndpoint.h>\r\n#include <editors/HWDesign/AdHocConnectionItem.h>\r\n#include <editors/HWDesign/undoCommands/AdHocConnectionDeleteCommand.h>\r\n#include <editors/HWDesign/undoCommands/AdHocTieOffConnectionDeleteCommand.h>\r\n\r\n#include <IPXACTmodels/Component/Component.h>\r\n#include <IPXACTmodels/Component/BusInterface.h>\r\n\r\n#include <IPXACTmodels/Design/Design.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentDeleteCommand::ComponentDeleteCommand()\r\n//-----------------------------------------------------------------------------\r\nComponentDeleteCommand::ComponentDeleteCommand(DesignDiagram* diagram, GraphicsColumn* column,\r\n    HWComponentItem* component, QUndoCommand* parent):\r\nQUndoCommand(parent),\r\ncomponentItem_(component),\r\ncolumn_(column),\r\ndiagram_(diagram),\r\ndel_(true)\r\n{\r\n    // Create child commands for removing interconnections.\r\n    QList<GraphicsConnection*> connections;\r\n\r\n    for (ConnectionEndpoint* endpoint : componentItem_->getEndpoints())\r\n    {\r\n        //HWConnectionEndpoint* endpoint = dynamic_cast<HWConnectionEndpoint*>(item);\r\n\r\n        QList<GraphicsConnection*> portConnections = endpoint->getConnections();\r\n        if (endpoint->getOffPageConnector() != 0)\r\n        {\r\n            portConnections.append(endpoint->getOffPageConnector()->getConnections());\r\n        }\r\n\r\n        for (GraphicsConnection* connection : portConnections)\r\n        {\r\n            if (!connections.contains(connection))\r\n            {\r\n                HWConnection* hwConnection = dynamic_cast<HWConnection*>(connection);\r\n                if (hwConnection)\r\n                {\r\n                    new ConnectionDeleteCommand(diagram_, hwConnection, this);\r\n                }\r\n                else\r\n                {\r\n                    AdHocConnectionItem* adHocConnection = dynamic_cast<AdHocConnectionItem*>(connection);\r\n                    if (adHocConnection)\r\n                    {\r\n                        new AdHocConnectionDeleteCommand(diagram_, adHocConnection, this);\r\n                    }\r\n                }\r\n\r\n                connections.append(connection);\r\n            }\r\n        }\r\n\r\n        if (endpoint->isAdHoc())\r\n        {\r\n            createTieOffDeleteCommand(endpoint);\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentDeleteCommand::createTieOffDeleteCommand()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentDeleteCommand::createTieOffDeleteCommand(ConnectionEndpoint* endPoint)\r\n{\r\n    QString portName = endPoint->name();\r\n\r\n    for (QSharedPointer<AdHocConnection> connection : *diagram_->getDesign()->getAdHocConnections())\r\n    {\r\n        if (connection->getInternalPortReferences()->size() == 1 &&\r\n            connection->getExternalPortReferences()->isEmpty())\r\n        {\r\n            QSharedPointer<PortReference> referencedPort =\r\n                connection->getInternalPortReferences()->first();\r\n            if (referencedPort->getPortRef() == portName &&\r\n                referencedPort->getComponentRef() == componentItem_->name())\r\n            {\r\n                new AdHocTieOffConnectionDeleteCommand(diagram_->getDesign(), connection, this);\r\n            }\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentDeleteCommand::~ComponentDeleteCommand()\r\n//-----------------------------------------------------------------------------\r\nComponentDeleteCommand::~ComponentDeleteCommand()\r\n{\r\n    if (del_)\r\n    {\r\n        delete componentItem_;\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentDeleteCommand::undo()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentDeleteCommand::undo()\r\n{\r\n    // Add the item back to the scene.\r\n    diagram_->getDesign()->getComponentInstances()->append(componentItem_->getComponentInstance());\r\n    column_->addItem(componentItem_);    \r\n    del_ = false;\r\n\r\n\temit componentInstantiated(componentItem_);\r\n\r\n    // Execute child commands.\r\n    QUndoCommand::undo();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentDeleteCommand::redo()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentDeleteCommand::redo()\r\n{\r\n    // Execute child commands.\r\n    QUndoCommand::redo();\r\n\r\n    // Remove the item from the scene.\r\n    column_->removeItem(componentItem_);\r\n    diagram_->removeItem(componentItem_);\r\n    diagram_->getDesign()->getComponentInstances()->removeOne(componentItem_->getComponentInstance());\r\n    del_ = true;\r\n\r\n\temit componentInstanceRemoved(componentItem_);\r\n}\r\n"
  },
  {
    "path": "editors/HWDesign/undoCommands/ComponentDeleteCommand.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ComponentDeleteCommand.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Esko Pekkarinen\r\n// Date: 30.09.2015\r\n//\r\n// Description:\r\n// Undo command for removing a component item in a design diagram.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef COMPONENTDELETECOMMAND_H\r\n#define COMPONENTDELETECOMMAND_H\r\n\r\n#include <QUndoCommand>\r\n#include <QObject>\r\n\r\nclass ComponentItem;\r\nclass DesignDiagram;\r\nclass GraphicsColumn;\r\nclass HWComponentItem;\r\nclass ConnectionEndpoint;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Undo command for removing a component item in a design diagram.\r\n//-----------------------------------------------------------------------------\r\nclass ComponentDeleteCommand : public QObject, public QUndoCommand\r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\r\n    /*!\r\n     *  The constructor.\r\n     *\r\n     *    @param [in] diagram     The diagram containing the component item.\r\n     *    @param [in] column      The column containing the component item.\r\n     *    @param [in] component   The component item to remove.\r\n     *    @param [in] parent      The parent command.\r\n     */\r\n    ComponentDeleteCommand(DesignDiagram* diagram, GraphicsColumn* column, HWComponentItem* component,\r\n        QUndoCommand* parent = 0);\r\n\r\n    /*!\r\n     *  Destructor.\r\n     */\r\n    ~ComponentDeleteCommand();\r\n\r\n    /*!\r\n     *  Undoes the command.\r\n     */\r\n    virtual void undo();\r\n\r\n    /*!\r\n     *  Redoes the command.\r\n     */\r\n    virtual void redo();\r\n\r\nsignals:\r\n\r\n\t//! Emitted when a new component is instantiated to the design.\r\n\tvoid componentInstantiated(ComponentItem*);\r\n\r\n\t//! Emitted when a component instance is removed from the design.\r\n\tvoid componentInstanceRemoved(ComponentItem*);\r\n\r\nprivate:\r\n    // Disable copying.\r\n    ComponentDeleteCommand(ComponentDeleteCommand const& rhs);\r\n    ComponentDeleteCommand& operator=(ComponentDeleteCommand const& rhs);\r\n\r\n    /*!\r\n     *  Create a possible tie off value delete command for the selected connection end point.\r\n     *\r\n     *    @param [in] endPoint    The selected connection end point.\r\n     */\r\n    void createTieOffDeleteCommand(ConnectionEndpoint* endPoint);\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! The diagram component.\r\n    HWComponentItem* componentItem_;\r\n\r\n    //! The component's parent column.\r\n    GraphicsColumn* column_;\r\n\r\n    //! The graphics diagram.\r\n    DesignDiagram* diagram_;\r\n\r\n    //! Boolean flag for indicating if the component should be deleted in the destructor.\r\n    bool del_;\r\n};\r\n\r\n#endif // COMPONENTDELETECOMMAND_H\r\n"
  },
  {
    "path": "editors/HWDesign/undoCommands/ComponentInstancePasteCommand.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ComponentInstancePasteCommand.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Esko Pekkarinen\r\n// Date: 15.02.2016\r\n//\r\n// Description:\r\n// Undo command for pasting a component instance in a design.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"ComponentInstancePasteCommand.h\"\r\n\r\n#include <common/graphicsItems/CommonGraphicsUndoCommands.h>\r\n#include <common/graphicsItems/GraphicsColumn.h>\r\n#include <common/graphicsItems/GraphicsColumnLayout.h>\r\n\r\n#include <editors/common/DesignDiagram.h>\r\n\r\n#include <editors/HWDesign/HWComponentItem.h>\r\n#include <editors/HWDesign/undoCommands/HWComponentAddCommand.h>\r\n\r\n#include <IPXACTmodels/Component/Component.h>\r\n#include <IPXACTmodels/Design/ComponentInstance.h>\r\n#include <IPXACTmodels/Design/Design.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentInstancePasteCommand::ComponentInstancePasteCommand()\r\n//-----------------------------------------------------------------------------\r\nComponentInstancePasteCommand::ComponentInstancePasteCommand(QSharedPointer<Component> component,\r\n    QSharedPointer<ComponentInstance> componentInstance, QPointF const& position, GraphicsColumn* column,\r\n    DesignDiagram* diagram, QUndoCommand* parent):\r\nQUndoCommand(parent),\r\ncomponentInstance_(new ComponentInstance(*componentInstance)),\r\ndesign_(diagram->getDesign())\r\n{\r\n    // Take a copy of the component in case of a draft.\r\n    QSharedPointer<Component> componentCopy = component;\r\n    if (!componentCopy->getVlnv().isValid())\r\n    {\r\n        componentCopy = QSharedPointer<Component>(new Component(*component));\r\n    }\r\n\r\n    QString uniqueInstanceName = diagram->createInstanceName(componentInstance->getInstanceName());\r\n    componentInstance_->setInstanceName(uniqueInstanceName);\r\n\r\n    HWComponentItem* componentItem = new HWComponentItem(diagram->getLibraryInterface(), componentInstance_, \r\n        componentCopy, column);\r\n    componentItem->setPos(position);\r\n\r\n    //comp->setBusInterfacePositions(instance.instance->getBusInterfacePositions(), false);\r\n    //comp->setAdHocPortPositions(instance.instance->getAdHocPortPositions());\r\n\r\n    GraphicsColumn* targetColumn = column;\r\n\r\n    // Check if the column does not accept the given component.\r\n    if (!targetColumn->isItemAllowed(componentItem))\r\n    {\r\n        targetColumn = 0;\r\n\r\n        // Find the first column that accepts it.\r\n        for (GraphicsColumn* otherColumn : diagram->getLayout()->getColumns())\r\n        {\r\n            if (otherColumn->isItemAllowed(componentItem))\r\n            {\r\n                targetColumn = otherColumn;\r\n                break;\r\n            }\r\n        }\r\n    }\r\n\r\n    if (targetColumn != 0)\r\n    {\r\n        HWComponentAddCommand* graphicsAddCommand =\r\n            new HWComponentAddCommand(diagram, targetColumn, componentItem, this);\r\n\r\n        QObject::connect(graphicsAddCommand, SIGNAL(componentInstantiated(ComponentItem*)),\r\n            diagram, SIGNAL(componentInstantiated(ComponentItem*)), Qt::UniqueConnection);\r\n        QObject::connect(graphicsAddCommand, SIGNAL(componentInstanceRemoved(ComponentItem*)),\r\n            diagram, SIGNAL(componentInstanceRemoved(ComponentItem*)), Qt::UniqueConnection);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentInstancePasteCommand::~ComponentInstancePasteCommand()\r\n//-----------------------------------------------------------------------------\r\nComponentInstancePasteCommand::~ComponentInstancePasteCommand()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentInstancePasteCommand::undo()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentInstancePasteCommand::undo()\r\n{\r\n    QUndoCommand::undo();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentInstancePasteCommand::redo()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentInstancePasteCommand::redo()\r\n{\r\n    QUndoCommand::redo();\r\n}\r\n"
  },
  {
    "path": "editors/HWDesign/undoCommands/ComponentInstancePasteCommand.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ComponentInstancePasteCommand.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Esko Pekkarinen\r\n// Date: 15.02.2016\r\n//\r\n// Description:\r\n// Undo command for pasting a component instance in a design.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef COMPONENTINSTANCEPASTECOMMAND_H\r\n#define COMPONENTINSTANCEPASTECOMMAND_H\r\n\r\n#include <QUndoCommand>\r\n#include <QSharedPointer>\r\n\r\nclass Component;\r\nclass ComponentInstance;\r\nclass ComponentItem;\r\nclass Design;\r\nclass DesignDiagram;\r\nclass GraphicsColumn;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Undo command for pasting a component instance in a design.\r\n//-----------------------------------------------------------------------------\r\nclass ComponentInstancePasteCommand : public QUndoCommand\r\n{\r\npublic:\r\n\r\n\t//! The constructor.\r\n    ComponentInstancePasteCommand(QSharedPointer<Component> component,\r\n        QSharedPointer<ComponentInstance> componentInstance, QPointF const& position, \r\n        GraphicsColumn* column, DesignDiagram* diagram, QUndoCommand* parent);\r\n\r\n\t//! The destructor.\r\n\t~ComponentInstancePasteCommand();\r\n\r\n    virtual void undo();\r\n\r\n    virtual void redo();\r\n\r\n\r\nprivate:\r\n\r\n\t// Disable copying.\r\n\tComponentInstancePasteCommand(ComponentInstancePasteCommand const& rhs);\r\n\tComponentInstancePasteCommand& operator=(ComponentInstancePasteCommand const& rhs);\r\n\r\n    //! The component instance to add in the design.\r\n    QSharedPointer<ComponentInstance> componentInstance_;\r\n\r\n    //! The target design.\r\n    QSharedPointer<Design> design_;\r\n};\r\n\r\n#endif // COMPONENTINSTANCEPASTECOMMAND_H"
  },
  {
    "path": "editors/HWDesign/undoCommands/ComponentItemMoveCommand.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ComponentItemMoveCommand.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Esko Pekkarinen\r\n// Date: 17.09.2015\r\n//\r\n// Description:\r\n// Undo command for moving component instances in a design.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"ComponentItemMoveCommand.h\"\r\n\r\n#include <common/graphicsItems/ComponentItem.h>\r\n#include <common/graphicsItems/IGraphicsItemStack.h>\r\n\r\n#include <editors/common/DesignDiagram.h>\r\n\r\n#include <IPXACTmodels/Design/ComponentInstance.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentItemMoveCommand()\r\n//-----------------------------------------------------------------------------\r\nComponentItemMoveCommand::ComponentItemMoveCommand(ComponentItem* item, QPointF const& oldPos,\r\n    IGraphicsItemStack* oldStack, DesignDiagram* diagram, QUndoCommand* parent):\r\nQUndoCommand(parent),\r\nitem_(item),\r\noldPos_(oldPos),\r\noldStack_(oldStack),\r\nnewPos_(item->scenePos()),\r\nnewStack_(dynamic_cast<IGraphicsItemStack*>(item->parentItem())),\r\ndiagram_(diagram)\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ~ComponentItemMoveCommand()\r\n//-----------------------------------------------------------------------------\r\nComponentItemMoveCommand::~ComponentItemMoveCommand()\r\n{\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: undo()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentItemMoveCommand::undo()\r\n{\r\n    newStack_->removeItem(item_);\r\n\r\n    item_->setPos(oldPos_);\r\n    oldStack_->addItem(item_);\r\n\r\n    item_->getComponentInstance()->setPosition(oldPos_);\r\n\r\n    // Execute child commands.\r\n    QUndoCommand::undo();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: redo()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentItemMoveCommand::redo()\r\n{\r\n    oldStack_->removeItem(item_);\r\n\r\n    item_->setPos(newPos_);\r\n    newStack_->addItem(item_);\r\n\r\n     item_->getComponentInstance()->setPosition(newPos_);\r\n    // Execute child commands.\r\n    QUndoCommand::redo();\r\n\r\n    resetSceneRectangle();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentItemMoveCommand::resetSceneRectangle()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentItemMoveCommand::resetSceneRectangle()\r\n{\r\n    if (oldStack_ != newStack_)\r\n    {\r\n        diagram_->resetSceneRectangleForItems();\r\n    }\r\n}\r\n"
  },
  {
    "path": "editors/HWDesign/undoCommands/ComponentItemMoveCommand.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ComponentItemMoveCommand.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Esko Pekkarinen\r\n// Date: 17.09.2015\r\n//\r\n// Description:\r\n// Undo command for moving component instances in a design.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef COMPONENT_ITEM_MOVE_COMMAND_H\r\n#define COMPONENT_ITEM_MOVE_COMMAND_H\r\n\r\n#include <QUndoCommand>\r\n#include <QGraphicsItem>\r\n#include <QGraphicsScene>\r\n#include <QString>\r\n#include <QObject>\r\n\r\nclass IGraphicsItemStack;\r\nclass ComponentItem;\r\nclass DesignDiagram;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Undo command for moving component instances in a design.\r\n//-----------------------------------------------------------------------------\r\nclass ComponentItemMoveCommand : public QUndoCommand\r\n{\r\npublic:\r\n    /*!\r\n     *  Constructor.\r\n     *\r\n     *    @param [in] item        The component item to move.\r\n     *    @param [in] oldPos      The item's old position.\r\n     *    @param [in] oldStack    The item's old stack.\r\n     *    @param [in] diagram     Diagram containing the scene of the component item.\r\n     *    @param [in] parent      The parent command.\r\n     */\r\n    ComponentItemMoveCommand(ComponentItem* item, QPointF const& oldPos, IGraphicsItemStack* oldStack,\r\n        DesignDiagram* diagram, QUndoCommand* parent = 0);\r\n\r\n    //! The destructor.\r\n    ~ComponentItemMoveCommand();\r\n\r\n    //! Undoes the move.\r\n    virtual void undo();\r\n\r\n    //! Redoes the move.\r\n    virtual void redo();\r\n\r\nprivate:\r\n    // Disable copying.\r\n    ComponentItemMoveCommand(ComponentItemMoveCommand const& rhs);\r\n    ComponentItemMoveCommand& operator=(ComponentItemMoveCommand const& rhs);\r\n\r\n    /*!\r\n     *  Reset the scene area.\r\n     */\r\n    void resetSceneRectangle();\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! The component item representing the instance.\r\n    ComponentItem* item_;\r\n\r\n    //! The old position of the component item.\r\n    QPointF oldPos_;\r\n\r\n    //! The old parent stack.\r\n    IGraphicsItemStack* oldStack_;\r\n\r\n    //! The new position of the item.\r\n    QPointF newPos_;\r\n\r\n    //! The new parent stack.\r\n    IGraphicsItemStack* newStack_;\r\n\r\n    //! Diagram containing the scene of the component item.\r\n    DesignDiagram* diagram_;\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n\r\n#endif // COMPONENT_ITEM_MOVE_COMMAND_H"
  },
  {
    "path": "editors/HWDesign/undoCommands/ConfigurableElementChangeCommand.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: ConfigurableElementChangeCommand.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 22.08.2017\n//\n// Description:\n// Undo change commands for configurable element value editor.\n//-----------------------------------------------------------------------------\n\n#include \"ConfigurableElementChangeCommand.h\"\n\n#include <IPXACTmodels/common/ConfigurableElementValue.h>\n\n//-----------------------------------------------------------------------------\n// Function: ConfigurableElementChangeCommand::ConfigurableElementChangeCommand()\n//-----------------------------------------------------------------------------\nConfigurableElementChangeCommand::ConfigurableElementChangeCommand(QString const& elementID,\n    QString const& oldValue, QString const& newValue, QString const& defaultValue,\n    QSharedPointer<QList<QSharedPointer<ConfigurableElementValue> > > configurableElements, QUndoCommand* parent):\nQObject(0),\nQUndoCommand(parent),\noldValue_(oldValue),\nnewValue_(newValue),\ndefaultValue_(defaultValue),\nelement_(0),\nconfigurableElements_(configurableElements)\n{\n    element_ = setupConfigurableElement(elementID);\n}\n\n//-----------------------------------------------------------------------------\n// Function: ConfigurableElementChangeCommand::~ConfigurableElementChangeCommand()\n//-----------------------------------------------------------------------------\nConfigurableElementChangeCommand::~ConfigurableElementChangeCommand()\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: ConfigurableElementChangeCommand::setupConfigurableElement()\n//-----------------------------------------------------------------------------\nQSharedPointer<ConfigurableElementValue> ConfigurableElementChangeCommand::setupConfigurableElement(\n    QString const& elementID)\n{\n    for (auto const& singleElement : *configurableElements_)\n    {\n        if (singleElement->getReferenceId() == elementID)\n        {\n            return singleElement;\n        }\n    }\n\n    QSharedPointer<ConfigurableElementValue> newElement(new ConfigurableElementValue(newValue_, elementID));\n    return newElement;\n}\n\n//-----------------------------------------------------------------------------\n// Function: ConfigurableElementChangeCommand::undo()\n//-----------------------------------------------------------------------------\nvoid ConfigurableElementChangeCommand::undo()\n{\n    changeConfigurableElement(oldValue_);\n\n    emit increaseReferencesInNewValue(oldValue_);\n    emit decreaseReferencesInOldValue(newValue_);\n}\n\n//-----------------------------------------------------------------------------\n// Function: ConfigurableElementChangeCommand::redo()\n//-----------------------------------------------------------------------------\nvoid ConfigurableElementChangeCommand::redo()\n{\n    changeConfigurableElement(newValue_);\n\n    emit increaseReferencesInNewValue(newValue_);\n    emit decreaseReferencesInOldValue(oldValue_);\n}\n\n//-----------------------------------------------------------------------------\n// Function: ConfigurableElementChangeCommand::changeConfigurableElement()\n//-----------------------------------------------------------------------------\nvoid ConfigurableElementChangeCommand::changeConfigurableElement(QString const& newElementValue)\n{\n    element_->setConfigurableValue(newElementValue);\n\n    if (!defaultValue_.isEmpty())\n    {\n        if (newElementValue.isEmpty() || newElementValue == defaultValue_)\n        {\n            if (configurableElements_->contains(element_))\n            {\n                configurableElements_->removeOne(element_);\n            }\n        }\n        else if (!configurableElements_->contains(element_))\n        {\n            configurableElements_->append(element_);\n        }\n    }\n\n    emit dataChangedInID(element_->getReferenceId(), newElementValue);\n}\n"
  },
  {
    "path": "editors/HWDesign/undoCommands/ConfigurableElementChangeCommand.h",
    "content": "//-----------------------------------------------------------------------------\n// File: ConfigurableElementChangeCommand.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 22.08.2017\n//\n// Description:\n// Undo change commands for configurable element value editor.\n//-----------------------------------------------------------------------------\n\n#ifndef CONFIGURABLEELEMENTCHANGECOMMAND_H\n#define CONFIGURABLEELEMENTCHANGECOMMAND_H\n\n#include <QUndoCommand>\n#include <QSharedPointer>\n#include <QObject>\n\nclass ConfigurableElementValue;\n\n//-----------------------------------------------------------------------------\n//! Undo change commands for configurable element value editor.\n//-----------------------------------------------------------------------------\nclass ConfigurableElementChangeCommand: public QObject, public QUndoCommand\n{\n    Q_OBJECT\n\npublic:\n\n    /*!\n     *  The constructor.\n     *\n     *    @param [in] elementID               Parameter ID referenced by the changed configurable element.\n     *    @param [in] oldValue                Old value of the changed configurable element.\n     *    @param [in] newValue                New value of the changed configurable element.\n     *    @param [in] defaultValue            Default value of the parameter.\n     *    @param [in] configurableElements    List of the associated configurable element values.\n     *    @param [in] parent                  The parent undo command.\n     */\n    ConfigurableElementChangeCommand(QString const& elementID, QString const& oldValue, QString const& newValue,\n        QString const& defaultValue,\n        QSharedPointer<QList<QSharedPointer<ConfigurableElementValue> > > configurableElements,\n        QUndoCommand* parent = 0);\n\n\t/*!\n     *  The destructor.\n     */\n\tvirtual ~ConfigurableElementChangeCommand();\n\n\t/*!\n     *  Undoes the command.\n     */\n\tvirtual void undo();\n\n\t/*!\n     *  Redoes the command.\n     */\n\tvirtual void redo();\n\nsignals:\n\n    /*!\n     *  Informs of data change in the configurable element referencing the selected ID.\n     *\n     *    @param [in] parameterID     ID of the referenced parameter.\n     *    @param [in] newDataValue    New value of the configurable element.\n     */\n    void dataChangedInID(QString const& parameterID, QString const& newDataValue);\n\n    /*!\n     *  Increase the amount of references in the new value.\n     *\n     *    @param [in] newValue    The new value for the configurable element.\n     */\n    void increaseReferencesInNewValue(QString const& newValue);\n\n    /*!\n     *  Decrease the amount of references in the old value.\n     *\n     *    @param [in] oldValue    The old value for the configurable element.\n     */\n    void decreaseReferencesInOldValue(QString const& oldValue);\n\nprivate:\n\n    //! No copying. No assignment.\n    ConfigurableElementChangeCommand(const ConfigurableElementChangeCommand& other);\n    ConfigurableElementChangeCommand& operator=(const ConfigurableElementChangeCommand& other);\n\n    /*!\n     *  Find the configurable element from the list of associated configurable elements.\n     *\n     *    @param [in] elementID   ID of the parameter referenced by the configurable element.\n     *\n     *    @return The configurable element value referencing the selected parameter. A new configurable element\n     *              value is constructed if one does not exist.\n     */\n    QSharedPointer<ConfigurableElementValue> setupConfigurableElement(QString const& elementID);\n\n    /*!\n     *  Change the value in the configurable element.\n     *\n     *    @param [in] newElementValue     New value for the configurable element.\n     */\n    void changeConfigurableElement(QString const& newElementValue);\n\n    //! The value before the change command.\n    QString oldValue_;\n\n    //! The changed value.\n    QString newValue_;\n\n    //! The default value.\n    QString defaultValue_;\n\n    //! The configurable element.\n    QSharedPointer<ConfigurableElementValue> element_;\n\n    //! List of the configurable elements containing the selected element.\n    QSharedPointer<QList<QSharedPointer<ConfigurableElementValue> > > configurableElements_;\n};\n\n//-----------------------------------------------------------------------------\n\n#endif // CONFIGURABLEELEMENTCHANGECOMMAND_H\n"
  },
  {
    "path": "editors/HWDesign/undoCommands/ConfigurableElementRemoveCommand.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: ConfigurableElementRemoveCommand.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 28.08.2017\n//\n// Description:\n// Undo remove command for configurable element values.\n//-----------------------------------------------------------------------------\n\n#include \"ConfigurableElementRemoveCommand.h\"\n\n#include <IPXACTmodels/common/ConfigurableElementValue.h>\n\n//-----------------------------------------------------------------------------\n// Function: ConfigurableElementRemoveCommand::ConfigurableElementRemoveCommand()\n//-----------------------------------------------------------------------------\nConfigurableElementRemoveCommand::ConfigurableElementRemoveCommand(QString const& elementID, int itemRow,\n    QString const& parentName,\n    QSharedPointer<QList<QSharedPointer<ConfigurableElementValue> > > configurableElements, QUndoCommand* parent):\nQObject(0),\nQUndoCommand(parent),\nparentName_(parentName),\nitemRow_(itemRow),\nrowInConfigurableElements_(0),\nconfigurableElements_(configurableElements),\nremovedElement_(getRemovedConfigurableElement(elementID))\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: ConfigurableElementRemoveCommand::getRemovedConfigurableElement()\n//-----------------------------------------------------------------------------\nQSharedPointer<ConfigurableElementValue> ConfigurableElementRemoveCommand::getRemovedConfigurableElement(\n    QString const& elementID)\n{\n    for (auto const& element : *configurableElements_)\n    {\n        if (element->getReferenceId() == elementID)\n        {\n            return element;\n        }\n    }\n\n    return QSharedPointer<ConfigurableElementValue>();\n}\n\n//-----------------------------------------------------------------------------\n// Function: ConfigurableElementRemoveCommand::undo()\n//-----------------------------------------------------------------------------\nvoid ConfigurableElementRemoveCommand::undo()\n{\n    if (removedElement_)\n    {\n        if (!configurableElements_->contains(removedElement_))\n        {\n            configurableElements_->insert(rowInConfigurableElements_, removedElement_);\n\n            emit addConfigurableElement(\n                removedElement_->getReferenceId(), removedElement_->getConfigurableValue(), itemRow_);\n\n            emit increaseReferencesInNewValue(removedElement_->getConfigurableValue());\n        }\n    }\n\n    QUndoCommand::undo();\n}\n\n//-----------------------------------------------------------------------------\n// Function: ConfigurableElementRemoveCommand::redo()\n//-----------------------------------------------------------------------------\nvoid ConfigurableElementRemoveCommand::redo()\n{\n    QUndoCommand::redo();\n\n    if (removedElement_)\n    {\n        rowInConfigurableElements_ = configurableElements_->indexOf(removedElement_);\n\n        if (configurableElements_->contains(removedElement_))\n        {\n            configurableElements_->removeOne(removedElement_);\n\n            emit removeConfigurableElement(removedElement_->getReferenceId(), itemRow_);\n\n            emit decreaseReferencesInOldValue(removedElement_->getConfigurableValue());\n        }\n    }\n}\n"
  },
  {
    "path": "editors/HWDesign/undoCommands/ConfigurableElementRemoveCommand.h",
    "content": "//-----------------------------------------------------------------------------\n// File: ConfigurableElementRemoveCommand.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 28.08.2017\n//\n// Description:\n// Undo remove command for configurable element values.\n//-----------------------------------------------------------------------------\n\n#ifndef CONFIGURABLEELEMENTREMOVECOMMAND_H\n#define CONFIGURABLEELEMENTREMOVECOMMAND_H\n\n#include <QUndoCommand>\n#include <QSharedPointer>\n#include <QObject>\n\nclass ConfigurableElementValue;\n\n//-----------------------------------------------------------------------------\n//! Undo remove command for configurable element values.\n//-----------------------------------------------------------------------------\nclass ConfigurableElementRemoveCommand : public QObject, public QUndoCommand\n{\n    Q_OBJECT\n\npublic:\n\n    /*!\n     *  The constructor.\n     *\n     *    @param [in] elementID               ID of the parameter referenced by the configurable element.\n     *    @param [in] itemRow                 Row of the item.\n     *    @param [in] parentName              Name of the parent item.\n     *    @param [in] configurableElements    List of the configurable element values containing the element\n     *                                          removed in this command.\n     *    @param [in] parent                  The parent undo command.\n     */\n    ConfigurableElementRemoveCommand(QString const& elementID, int itemRow, QString const& parentName,\n        QSharedPointer<QList<QSharedPointer<ConfigurableElementValue> > > configurableElements,\n        QUndoCommand* parent = 0);\n\n    //! No copying. No assignment.\n    ConfigurableElementRemoveCommand(const ConfigurableElementRemoveCommand& other) = delete;\n    ConfigurableElementRemoveCommand& operator=(const ConfigurableElementRemoveCommand& other) = delete;\n\n\t/*!\n     *  The destructor.\n     */\n    virtual ~ConfigurableElementRemoveCommand() = default;\n\n\t/*!\n     *  Undoes the command.\n     */\n\tvirtual void undo();\n\n\t/*!\n     *  Redoes the command.\n     */\n\tvirtual void redo();\n\nsignals:\n\n    /*!\n     *  Informs that the selected configurable element value has been added to the associated table.\n     *\n     *    @param [in] elementID       ID of the selected configurable element.\n     *    @param [in] elementValue    Value of the selected configurable element.\n     *    @param [in] elementRow      Row of the configurable element in the associated table.\n     */\n    void addConfigurableElement(QString const& elementID, QString const& elementValue, \n        int elementRow);\n\n    /*!\n     *  Informs that the selected configurable element value has been removed from the associated table.\n     *\n     *    @param [in] elementID   ID of the parameter referenced by the selected configurable element.\n     *    @param [in] parentName  Name of the parent item containing the configurable element item.\n     *    @param [in] elementRow  Row of the removed configurable element value.\n     */\n    void removeConfigurableElement(QString const& elementID, int elementRow);\n\n    /*!\n     *  Increase the amount of references in the new value.\n     *\n     *    @param [in] newValue    The new value for the configurable element.\n     */\n    void increaseReferencesInNewValue(QString const& newValue);\n\n    /*!\n     *  Decrease the amount of references in the old value.\n     *\n     *    @param [in] oldValue    The old value for the configurable element.\n     */\n    void decreaseReferencesInOldValue(QString const& oldValue);\n\nprivate:\n\n    /*!\n     *  Locate the configurable element value with the referenced parameter ID.\n     *\n     *    @param [in] elementID   ID of the parameter referenced by the selected configurable element value.\n     *\n     *    @return The configurable element value containing a reference to the selected parameter ID.\n     */\n    QSharedPointer<ConfigurableElementValue> getRemovedConfigurableElement(QString const& elementID);\n\n    //-----------------------------------------------------------------------------\n    // Data.\n    //-----------------------------------------------------------------------------\n\n    //! Name of the parent item.\n    QString parentName_;\n\n    //! Row of the configurable element in the associated table.\n    int itemRow_;\n\n    //! Index of the configurable element in the list of configurable element values.\n    int rowInConfigurableElements_;\n\n    //! List of the configurable element values containing the selected configurable element.\n    QSharedPointer<QList<QSharedPointer<ConfigurableElementValue> > > configurableElements_;\n\n    //! The selected configurable element value.\n    QSharedPointer<ConfigurableElementValue> removedElement_;\n};\n\n//-----------------------------------------------------------------------------\n\n#endif // CONFIGURABLEELEMENTREMOVECOMMAND_H\n"
  },
  {
    "path": "editors/HWDesign/undoCommands/ConnectionDeleteCommand.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ConnectionDeleteCommand.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Esko Pekkarinen\r\n// Date: 30.09.2015\r\n//\r\n// Description:\r\n// Undo command for removing a connection in design diagram.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"ConnectionDeleteCommand.h\"\r\n#include \"PhysicalPortDeleteCommand.h\"\r\n\r\n#include \"AdHocVisibilityChangeCommand.h\"\r\n\r\n#include <common/GenericEditProvider.h>\r\n\r\n#include <editors/common/Association/Association.h>\r\n#include <editors/common/Association/AssociationRemoveCommand.h>\r\n\r\n#include <editors/common/DesignDiagram.h>\r\n\r\n#include <editors/HWDesign/HWConnection.h>\r\n\r\n#include <IPXACTmodels/Component/BusInterface.h>\r\n#include <IPXACTmodels/Component/Component.h>\r\n#include <IPXACTmodels/Component/PortMap.h>\r\n\r\n#include <IPXACTmodels/Design/Design.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ConnectionDeleteCommand::ConnectionDeleteCommand()\r\n//-----------------------------------------------------------------------------\r\nConnectionDeleteCommand::ConnectionDeleteCommand(DesignDiagram* diagram, HWConnection* connection,\r\n     QUndoCommand* parent) : QUndoCommand(parent),\r\n      connection_(connection),\r\n      diagram_(diagram),\r\n      del_(true)\r\n{\r\n    for (Association* association : connection_->getAssociations())\r\n    {\r\n        new AssociationRemoveCommand(association, diagram_, this);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ConnectionDeleteCommand::~ConnectionDeleteCommand()\r\n//-----------------------------------------------------------------------------\r\nConnectionDeleteCommand::~ConnectionDeleteCommand()\r\n{\r\n    if (del_)\r\n    {\r\n        delete connection_;\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ConnectionDeleteCommand::undo()\r\n//-----------------------------------------------------------------------------\r\nvoid ConnectionDeleteCommand::undo()\r\n{\r\n    // Execute child commands.\r\n    QUndoCommand::undo();\r\n\r\n    // Add the item back to the scene.\r\n    diagram_->addItem(connection_);\r\n    \r\n    if (connection_->connectEnds())\r\n    {    \r\n        connection_->endpoint1()->updateInterface();\r\n        connection_->endpoint2()->updateInterface();\r\n\r\n        diagram_->getDesign()->getInterconnections()->append(connection_->getInterconnection());\r\n        diagram_->getDesign()->addRoute(connection_->getRouteExtension());\r\n    }\r\n\r\n    del_ = false;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ConnectionDeleteCommand::redo()\r\n//-----------------------------------------------------------------------------\r\nvoid ConnectionDeleteCommand::redo()\r\n{\r\n    // Disconnect the ends.\r\n    connection_->setSelected(false);\r\n\r\n    diagram_->removeItem(connection_);\r\n\r\n    connection_->disconnectEnds();\r\n\r\n    // Remove the item from the scene.\r\n    diagram_->getDesign()->getInterconnections()->removeOne(connection_->getInterconnection());\r\n    diagram_->getDesign()->removeRoute(connection_->getRouteExtension());\r\n\r\n    del_ = true;\r\n\r\n    // Execute child commands.\r\n    QUndoCommand::redo();\r\n}\r\n"
  },
  {
    "path": "editors/HWDesign/undoCommands/ConnectionDeleteCommand.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ConnectionDeleteCommand.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Esko Pekkarinen\r\n// Date: 30.09.2015\r\n//\r\n// Description:\r\n// Undo command for removing a connection in design diagram.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef CONNECTIONDELETECOMMAND_H\r\n#define CONNECTIONDELETECOMMAND_H\r\n\r\n#include <QObject>\r\n#include <QSharedPointer>\r\n#include <QUndoCommand>\r\n\r\n#include <IPXACTmodels/generaldeclarations.h>\r\n\r\nclass DesignDiagram;\r\nclass HWConnection;\r\nclass PortMap;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Undo command for removing a connection in design diagram.\r\n//-----------------------------------------------------------------------------\r\nclass ConnectionDeleteCommand : public QUndoCommand\r\n{\r\npublic:\r\n\r\n    /*!\r\n     *  The constructor.\r\n     *\r\n     *    @param [in] diagram     The diagram containing the connection item.\r\n     *    @param [in] connection  The connection to remove.\r\n     *    @param [in] parent      The parent command.\r\n     */\r\n    ConnectionDeleteCommand(DesignDiagram* diagram, HWConnection* connection, QUndoCommand* parent = 0);\r\n\r\n    /*!\r\n     *  Destructor.\r\n     */\r\n    ~ConnectionDeleteCommand();\r\n\r\n    /*!\r\n     *  Undoes the command.\r\n     */\r\n    virtual void undo();\r\n\r\n    /*!\r\n     *  Redoes the command.\r\n     */\r\n    virtual void redo();\r\n\r\nprivate:\r\n    // Disable copying.\r\n    ConnectionDeleteCommand(ConnectionDeleteCommand const& rhs);\r\n    ConnectionDeleteCommand& operator=(ConnectionDeleteCommand const& rhs);\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! The interconnection.\r\n    HWConnection* connection_;\r\n\r\n    //! The graphics scene.\r\n    DesignDiagram* diagram_;\r\n\r\n    //! Boolean flag for indicating if the connection should be deleted in the destructor.\r\n    bool del_;\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n\r\n#endif // CONNECTIONDELETECOMMAND_H\r\n"
  },
  {
    "path": "editors/HWDesign/undoCommands/HWColumnAddCommand.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: HWColumnAddCommand.h\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Mikko Teuho\n// Date: 24.10.2017\n//\n// Description:\n// Undo command for adding HW graphics columns.\n//-----------------------------------------------------------------------------\n\n#include \"HWColumnAddCommand.h\"\n\n#include <common/graphicsItems/GraphicsColumn.h>\n#include <common/graphicsItems/GraphicsColumnLayout.h>\n\n#include <editors/common/DesignDiagram.h>\n#include <editors/HWDesign/HierarchicalPortItem.h>\n\n#include <IPXACTmodels/Design/Design.h>\n#include <IPXACTmodels/kactusExtensions/Kactus2Placeholder.h>\n\n//-----------------------------------------------------------------------------\n// Function: HWColumnAddCommand::HWColumnAddCommand()\n//-----------------------------------------------------------------------------\nHWColumnAddCommand::HWColumnAddCommand(GraphicsColumnLayout* layout, GraphicsColumn* column,\n    DesignDiagram* diagram, QUndoCommand* parent):\nGraphicsColumnAddCommand(layout, column, diagram, parent),\nmissingAdHocPortItems_(getMissingAdHocPortItems())\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: HWColumnAddCommand::getMissingAdHocPortItems()\n//-----------------------------------------------------------------------------\nQVector<HierarchicalPortItem*> HWColumnAddCommand::getMissingAdHocPortItems() const\n{\n    QVector<HierarchicalPortItem*> missingAdHocInterfaces;\n\n    QVector<QSharedPointer<Port> > missingPorts = getMissingAdHocPorts();\n\n    if (!missingPorts.isEmpty())\n    {\n        QSharedPointer<VendorExtension> adhocExtension = getDiagram()->getDesign()->getAdHocPortPositions();\n        QSharedPointer<Kactus2Group> adhocGroup = adhocExtension.dynamicCast<Kactus2Group>();\n        if (!adhocGroup)\n        {\n            adhocGroup = QSharedPointer<Kactus2Group>(new Kactus2Group(\"kactus2:adHocVisibilities\"));\n            getDiagram()->getDesign()->getVendorExtensions()->append(adhocGroup);\n        }\n\n        for (QSharedPointer<Port> port : missingPorts)\n        {\n            QSharedPointer<Kactus2Placeholder> newAdHocPosition = getAdHocPositionExtension(adhocGroup, port);\n\n            HierarchicalPortItem* newAdHocItem =\n                new HierarchicalPortItem(getDiagram()->getEditedComponent(), port, newAdHocPosition);\n\n            missingAdHocInterfaces.append(newAdHocItem);\n        }\n    }\n\n    return missingAdHocInterfaces;\n}\n\n\n//-----------------------------------------------------------------------------\n// Function: HWColumnAddCommand::getMissingPorts()\n//-----------------------------------------------------------------------------\nQVector<QSharedPointer<Port> > HWColumnAddCommand::getMissingAdHocPorts() const\n{\n    QVector<QSharedPointer<Port> > missingPorts;\n\n    for (auto const& adhocPort : *getDiagram()->getEditedComponent()->getPorts())\n    {\n        if (adhocPort->isAdHocVisible() && !portExistsInDiagram(adhocPort))\n        {\n            missingPorts.append(adhocPort);\n        }\n    }\n\n    return missingPorts;\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: HWColumnAddCommand::portExistsInDiagram()\n//-----------------------------------------------------------------------------\nbool HWColumnAddCommand::portExistsInDiagram(QSharedPointer<Port> adHocPort) const\n{\n    QString portName = adHocPort->name();\n\n    if (getDiagram()->getDiagramAdHocPort(portName))\n    {\n        return true;\n    }\n\n    return false;\n}\n//-----------------------------------------------------------------------------\n// Function: HWColumnAddCommand::getPositionExtension()\n//-----------------------------------------------------------------------------\nQSharedPointer<Kactus2Placeholder> HWColumnAddCommand::getAdHocPositionExtension(\n    QSharedPointer<Kactus2Group> positionGroup, QSharedPointer<Port> adhocPort) const\n{\n    for (auto const& extension : positionGroup->getByType(\"kactus2:adHocVisible\"))\n    {\n        QSharedPointer<Kactus2Placeholder> adhocPosition = extension.dynamicCast<Kactus2Placeholder>();\n        if (adhocPosition && adhocPosition->getAttributeValue(QString(\"portName\")) == adhocPort->name())\n        {\n            return adhocPosition;\n        }\n    }\n\n    QSharedPointer<Kactus2Placeholder> newAdHocPosition(new Kactus2Placeholder(\"kactus2:adHocVisible\"));\n    return newAdHocPosition;\n}\n\n//-----------------------------------------------------------------------------\n// Function: HWColumnAddCommand::~HWColumnAddCommand()\n//-----------------------------------------------------------------------------\nHWColumnAddCommand::~HWColumnAddCommand()\n{\n    if (columnShouldBeDeleted())\n    {\n        while (!missingAdHocPortItems_.isEmpty())\n        {\n            HierarchicalPortItem* firstAdHoc = missingAdHocPortItems_.takeFirst();\n            delete firstAdHoc;\n        }\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: HWColumnAddCommand::undo()\n//-----------------------------------------------------------------------------\nvoid HWColumnAddCommand::undo()\n{\n    if (getColumn()->getColumnDesc()->getAllowedItems() & ColumnTypes::INTERFACE &&\n        !missingAdHocPortItems_.isEmpty())\n    {\n        removeMissingPortsFromDesign();\n    }\n\n    GraphicsColumnAddCommand::undo();\n}\n\n//-----------------------------------------------------------------------------\n// Function: HWColumnAddCommand::removeMissingPortsFromDesign()\n//-----------------------------------------------------------------------------\nvoid HWColumnAddCommand::removeMissingPortsFromDesign()\n{\n    QSharedPointer<VendorExtension> adhocExtension = getDiagram()->getDesign()->getAdHocPortPositions();\n    QSharedPointer<Kactus2Group> adhocGroup = adhocExtension.dynamicCast<Kactus2Group>();\n    \n    for (HierarchicalPortItem* adHocItem : missingAdHocPortItems_)\n    {\n        getColumn()->removeItem(adHocItem);\n\n        for (QSharedPointer<VendorExtension> extension : adhocGroup->getByType(\"kactus2:adHocVisible\"))\n        {\n            QSharedPointer<Kactus2Placeholder> portExtension = extension.dynamicCast<Kactus2Placeholder>();\n            if (portExtension->getAttributeValue(\"portName\") == adHocItem->name())\n            {\n                adhocGroup->removeFromGroup(portExtension);\n            }\n        }\n    }\n    \n    if (adhocGroup->getByType(\"kactus2:adHocVisible\").isEmpty())\n    {\n        getDiagram()->getDesign()->getVendorExtensions()->removeAll(adhocExtension);\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: HWColumnAddCommand::redo()\n//-----------------------------------------------------------------------------\nvoid HWColumnAddCommand::redo()\n{\n    if (getColumn()->getColumnDesc()->getAllowedItems() & ColumnTypes::INTERFACE &&\n        !missingAdHocPortItems_.isEmpty())\n    {\n        addMissingPortsToNewColumn();\n    }\n\n    GraphicsColumnAddCommand::redo();\n}\n\n//-----------------------------------------------------------------------------\n// Function: HWColumnAddCommand::addMissingPortsToNewColumn()\n//-----------------------------------------------------------------------------\nvoid HWColumnAddCommand::addMissingPortsToNewColumn()\n{\n    QSharedPointer<VendorExtension> adHocPortPositions = getDiagram()->getDesign()->getAdHocPortPositions();\n    QSharedPointer<Kactus2Group> adhocGroup = adHocPortPositions.dynamicCast<Kactus2Group>();\n    if (!adhocGroup)\n    {\n        adhocGroup = QSharedPointer<Kactus2Group>(new Kactus2Group(\"kactus2:adHocVisibilities\"));\n        getDiagram()->getDesign()->getVendorExtensions()->append(adhocGroup);\n    }\n\n    for (HierarchicalPortItem* adhocItem : missingAdHocPortItems_)\n    {\n        getColumn()->addItem(adhocItem);\n\n        QSharedPointer<Kactus2Placeholder> adhocPositionData = adhocItem->getDataGroup();\n        adhocPositionData->setAttribute(\"x\", QString::number(adhocItem->scenePos().x()));\n        adhocPositionData->setAttribute(\"y\", QString::number(adhocItem->scenePos().y()));\n        adhocItem->setDataGroup(adhocPositionData);\n\n        adhocGroup->addToGroup(adhocPositionData);\n    }\n}\n"
  },
  {
    "path": "editors/HWDesign/undoCommands/HWColumnAddCommand.h",
    "content": "//-----------------------------------------------------------------------------\n// File: HWColumnAddCommand.h\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Mikko Teuho\n// Date: 24.10.2017\n//\n// Description:\n// Undo command for adding HW graphics columns.\n//-----------------------------------------------------------------------------\n\n#ifndef HWCOLUMNADDCOMMAND_H\n#define HWCOLUMNADDCOMMAND_H\n\n#include <common/graphicsItems/GraphicsColumnAddCommand.h>\n\n#include <editors/HWDesign/HierarchicalPortItem.h>\n\nclass Kactus2Group;\nclass Kactus2Placeholder;\n\n//-----------------------------------------------------------------------------\n//! Undo command for adding HW graphics columns.\n//-----------------------------------------------------------------------------\nclass HWColumnAddCommand : public GraphicsColumnAddCommand\n{\npublic:\n\n    /*!\n     *  Constructor.\n     *\n     *    @param [in] layout      The column layout.\n     *    @param [in] column      The column to add.\n     *    @param [in] diagram     Diagram containing the column layout.\n     *    @param [in] parent      The parent command.\n     */\n    HWColumnAddCommand(GraphicsColumnLayout* layout, GraphicsColumn* column, DesignDiagram* diagram,\n        QUndoCommand* parent = 0);\n\n    /*!\n     *  Destructor.\n     */\n    ~HWColumnAddCommand();\n\n    /*!\n     *  Undoes the command.\n     */\n    virtual void undo();\n\n    /*!\n     *  Redoes the command.\n     */\n    virtual void redo();\n\nprivate:\n    // Disable copying.\n    HWColumnAddCommand(HWColumnAddCommand const& rhs);\n    HWColumnAddCommand& operator=(HWColumnAddCommand const& rhs);\n\n    /*!\n     *  Get the mandatory port items that have not been inserted into any columns.\n     *\n     *    @return The mandatory port items that have not been inserted into any columns.\n     */\n    QVector<HierarchicalPortItem*> getMissingAdHocPortItems() const;\n\n    /*!\n     *  Get the mandatory ports that have not been inserted into any columns.\n     *\n     *    @return The mandatory ports that have not been inserted into any column\n     */\n    QVector<QSharedPointer<Port> > getMissingAdHocPorts() const;\n\n    /*!\n     *  Remove the mandatory ad hoc ports that have been inserted in the column.\n     */\n    void removeMissingPortsFromDesign();\n\n    /*!\n     *  Add the missing mandatory ad hoc ports to the column.\n     */\n    void addMissingPortsToNewColumn();\n\n    /*!\n     *  Check if the selected port exists in the design diagram.\n     *\n     *    @param [in] adHocPort   The selected ad hoc port.\n     *\n     *    @return True, if the port is found in the design diagram, otherwise false.\n     */\n    bool portExistsInDiagram(QSharedPointer<Port> adHocPort) const;\n\n    /*!\n     *  Get the position vendor extension for the selected ad hoc port.\n     *\n     *    @param [in] positionGroup   Extension group for ad hoc positions.\n     *    @param [in] adhocPort       The selected ad hoc port.\n     */\n    QSharedPointer<Kactus2Placeholder> getAdHocPositionExtension(QSharedPointer<Kactus2Group> positionGroup,\n        QSharedPointer<Port> adhocPort) const;\n\n    //-----------------------------------------------------------------------------\n    // Data.\n    //-----------------------------------------------------------------------------\n\n    //! The missing mandatory ad hoc port items.\n    QVector<HierarchicalPortItem*> missingAdHocPortItems_;\n};\n\n//-----------------------------------------------------------------------------\n\n#endif // HWCOLUMNADDCOMMAND_H"
  },
  {
    "path": "editors/HWDesign/undoCommands/HWComponentAddCommand.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: HWComponentAddCommand.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Mikko Teuho\r\n// Date: 18.04.2016\r\n//\r\n// Description:\r\n// Undo add command for component items in HW design.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"HWComponentAddCommand.h\"\r\n\r\n#include <common/graphicsItems/IGraphicsItemStack.h>\r\n\r\n#include <editors/common/DesignDiagram.h>\r\n#include <editors/HWDesign/HWComponentItem.h>\r\n\r\n#include <IPXACTmodels/Design/ComponentInstance.h>\r\n#include <IPXACTmodels/Design/Design.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HWComponentAddCommand::HWComponentAddCommand()\r\n//-----------------------------------------------------------------------------\r\nHWComponentAddCommand::HWComponentAddCommand(DesignDiagram* diagram, IGraphicsItemStack* stack,\r\n    ComponentItem* item, QUndoCommand* parent):\r\nQUndoCommand(parent),\r\ncontainingDesign_(diagram->getDesign()),\r\nitem_(item),\r\nstack_(stack),\r\ndel_(false),\r\ndiagram_(diagram)\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HWComponentAddCommand::~HWComponentAddCommand()\r\n//-----------------------------------------------------------------------------\r\nHWComponentAddCommand::~HWComponentAddCommand()\r\n{\r\n    if (del_)\r\n    {\r\n        delete item_;\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HWComponentAddCommand::undo()\r\n//-----------------------------------------------------------------------------\r\nvoid HWComponentAddCommand::undo()\r\n{\r\n    stack_->removeItem(item_);\r\n    item_->scene()->removeItem(item_);\r\n    del_ = true;\r\n\r\n    QSharedPointer<ComponentInstance> itemInstance = item_->getComponentInstance();\r\n    containingDesign_->getComponentInstances()->removeAll(itemInstance);\r\n\r\n    emit componentInstanceRemoved(item_);\r\n\r\n    QUndoCommand::undo();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HWComponentAddCommand::redo()\r\n//-----------------------------------------------------------------------------\r\nvoid HWComponentAddCommand::redo()\r\n{\r\n    stack_->addItem(item_);\r\n    del_ = false;\r\n\r\n    QSharedPointer<ComponentInstance> itemInstance = item_->getComponentInstance();\r\n    containingDesign_->getComponentInstances()->append(itemInstance);\r\n\r\n    emit componentInstantiated(item_);\r\n\r\n    diagram_->resetSceneRectangleForItems();\r\n}\r\n"
  },
  {
    "path": "editors/HWDesign/undoCommands/HWComponentAddCommand.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: HWComponentAddCommand.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Mikko Teuho\r\n// Date: 18.04.2016\r\n//\r\n// Description:\r\n// Undo add command for component items in HW design.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef HWCOMPONENTADDCOMMAND_H\r\n#define HWCOMPONENTADDCOMMAND_H\r\n\r\n#include <QGraphicsScene>\r\n#include <QObject>\r\n#include <QSharedPointer>\r\n#include <QString>\r\n#include <QUndoCommand>\r\n\r\nclass IGraphicsItemStack;\r\nclass ComponentItem;\r\nclass Design;\r\nclass DesignDiagram;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Undo add command for component items in HW design.\r\n//-----------------------------------------------------------------------------\r\nclass HWComponentAddCommand : public QObject, public QUndoCommand\r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\r\n    /*!\r\n     *  Constructor.\r\n     *\r\n     *    @param [in] diagram     Diagram containing the scene of the component item.\r\n     *    @param [in] stack       The stack to which to add the item.\r\n     *    @param [in] item        The item to add.\r\n     *    @param [in] parent      The parent command.\r\n     */\r\n    HWComponentAddCommand(DesignDiagram* diagram, IGraphicsItemStack* stack, ComponentItem* item,\r\n        QUndoCommand* parent = 0);\r\n\r\n    /*!\r\n     *  Destructor.\r\n     */\r\n    ~HWComponentAddCommand();\r\n\r\n    /*!\r\n     *  Undoes the command.\r\n     */\r\n    virtual void undo();\r\n\r\n    /*!\r\n     *  Redoes the command.\r\n     */\r\n    virtual void redo();\r\n\r\nsignals:\r\n\r\n\t//! Emitted when a new component is instantiated to the design.\r\n\tvoid componentInstantiated(ComponentItem*);\r\n\r\n\t//! Emitted when a component instance is removed from the design.\r\n\tvoid componentInstanceRemoved(ComponentItem*);\r\n\r\nprivate:\r\n\r\n    // Disable copying.\r\n    HWComponentAddCommand(HWComponentAddCommand const& rhs);\r\n    HWComponentAddCommand& operator=(HWComponentAddCommand const& rhs);\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! The design containing the hw component item.\r\n    QSharedPointer<Design> containingDesign_;\r\n\r\n    //! The graphics item.\r\n    ComponentItem* item_;\r\n\r\n    //! The item's parent column.\r\n    IGraphicsItemStack* stack_;\r\n\r\n    //! Boolean flag for indicating if the component should be deleted in the destructor.\r\n    bool del_;\r\n\r\n    //! Diagram containing the scene of the component item.\r\n    DesignDiagram* diagram_;\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n\r\n#endif // HWCOMPONENTADDCOMMAND_H"
  },
  {
    "path": "editors/HWDesign/undoCommands/InterfaceDeleteCommand.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: InterfaceDeleteCommand.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Esko Pekkarinen\r\n// Date: 30.09.2015\r\n//\r\n// Description:\r\n// Undo command for removing top interface item in design diagram.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"InterfaceDeleteCommand.h\"\r\n\r\n#include \"AdHocVisibilityChangeCommand.h\"\r\n#include \"ConnectionDeleteCommand.h\"\r\n#include \"PhysicalPortDeleteCommand.h\"\r\n\r\n#include <editors/HWDesign/HierarchicalBusInterfaceItem.h>\r\n#include <editors/HWDesign/HWComponentItem.h>\r\n#include <editors/HWDesign/HWConnection.h>\r\n#include <editors/HWDesign/HWConnectionEndpoint.h>\r\n\r\n#include <common/graphicsItems/GraphicsColumn.h>\r\n\r\n#include <editors/common/DesignDiagram.h>\r\n#include <editors/common/Association/AssociationRemoveCommand.h>\r\n\r\n#include <IPXACTmodels/Component/BusInterface.h>\r\n#include <IPXACTmodels/Component/Port.h>\r\n#include <IPXACTmodels/Component/PortMap.h>\r\n\r\n#include <IPXACTmodels/Design/Design.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: InterfaceDeleteCommand::InterfaceDeleteCommand()\r\n//-----------------------------------------------------------------------------\r\nInterfaceDeleteCommand::InterfaceDeleteCommand(DesignDiagram* diagram, HierarchicalBusInterfaceItem* interface,\r\n    bool removePorts, QUndoCommand* parent):\r\nQUndoCommand(parent),\r\ninterface_(interface),\r\nbusIf_(interface_->getBusInterface()),\r\nparent_(static_cast<GraphicsColumn*>(interface->parentItem())),\r\ndiagram_(diagram),\r\ndel_(true)\r\n{\r\n    if (removePorts)\r\n    {\r\n        // Create copies of the related ports and remove commands for them.\r\n        for (QSharedPointer<Port> port : \r\n            interface_->getOwnerComponent()->getPortsMappedInInterface(busIf_->name()))\r\n        {\r\n            DeletePhysicalPortCommand* delCmd =\r\n                new DeletePhysicalPortCommand(interface_->getOwnerComponent(), port, this);\r\n\r\n            // If the port is visible as ad-hoc in the current design, it must be hidden.\r\n            if (diagram->getDiagramAdHocPort(port->name()) != nullptr)\r\n            {                               \r\n                new AdHocVisibilityChangeCommand(diagram, port->name(), false, delCmd);\r\n            }\r\n        }\r\n    }\r\n\r\n    // Create child commands for removing interconnections.\r\n    for (GraphicsConnection* conn : interface_->getConnections())\r\n    {\r\n        new ConnectionDeleteCommand(diagram, static_cast<HWConnection*>(conn), this);\r\n    }\r\n\r\n    for (GraphicsConnection* conn : interface_->getOffPageConnector()->getConnections())\r\n    {\r\n        new ConnectionDeleteCommand(diagram, static_cast<HWConnection*>(conn), this);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: InterfaceDeleteCommand::~InterfaceDeleteCommand()\r\n//-----------------------------------------------------------------------------\r\nInterfaceDeleteCommand::~InterfaceDeleteCommand()\r\n{\r\n    if (del_)\r\n    {\r\n        delete interface_;\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: InterfaceDeleteCommand::undo()\r\n//-----------------------------------------------------------------------------\r\nvoid InterfaceDeleteCommand::undo()\r\n{\r\n    // Add the interface back to the scene.\r\n    parent_->addItem(interface_);\r\n    del_ = false;\r\n\r\n    // Redefine the interface.\r\n    if (busIf_ != nullptr && !interface_->getOwnerComponent()->hasInterface(busIf_->name()))\r\n    {\r\n        interface_->getOwnerComponent()->getBusInterfaces()->append(busIf_);\r\n        interface_->setBusInterface(busIf_);\r\n        interface_->updateInterface();\r\n\r\n        diagram_->getDesign()->getVendorExtensions()->append(interface_->getDataExtension());\r\n    }\r\n    else if (interface_->getOwnerComponent()->hasInterface(busIf_->name()))\r\n    {\r\n        diagram_->getDesign()->getVendorExtensions()->append(interface_->getDataExtension());\r\n    }\r\n\r\n    // Execute child commands.\r\n    QUndoCommand::undo();\r\n\r\n    interface_->updateInterface();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: InterfaceDeleteCommand::redo()\r\n//-----------------------------------------------------------------------------\r\nvoid InterfaceDeleteCommand::redo()\r\n{\r\n    // Execute child commands.\r\n    QUndoCommand::redo();\r\n\r\n    // Remove the interface from the scene.\r\n    parent_->removeItem(interface_);\r\n    diagram_->removeItem(interface_);\r\n    diagram_->getDesign()->getVendorExtensions()->removeOne(interface_->getDataExtension());\r\n\r\n    emit interfaceDeleted();\r\n    del_ = true;\r\n}\r\n"
  },
  {
    "path": "editors/HWDesign/undoCommands/InterfaceDeleteCommand.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: InterfaceDeleteCommand.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Esko Pekkarinen\r\n// Date: 30.09.2015\r\n//\r\n// Description:\r\n// Undo command for removing top interface item in design diagram.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef INTERFACEDELETECOMMANDS_H\r\n#define INTERFACEDELETECOMMANDS_H\r\n\r\n#include <QObject>\r\n#include <QUndoCommand>\r\n\r\n#include <IPXACTmodels/generaldeclarations.h>\r\n\r\n#include <IPXACTmodels/common/VLNV.h>\r\n\r\nclass AbstractionType;\r\nclass BusInterface;\r\nclass HierarchicalBusInterfaceItem;\r\nclass DesignDiagram;\r\nclass GraphicsColumn;\r\nclass Port;\r\nclass PortMap;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Undo command for removing top interface item in design diagram.\r\n//-----------------------------------------------------------------------------\r\nclass InterfaceDeleteCommand : public QObject, public QUndoCommand\r\n{\r\n    Q_OBJECT\r\n\r\npublic:\r\n    /*!\r\n     *  Constructor.\r\n     *\r\n     *    @param [in] interface    The interface to delete.\r\n     *    @param [in] removePorts  If true, the ports that are part of the interface are also removed.\r\n     */\r\n    InterfaceDeleteCommand(DesignDiagram* diagram, HierarchicalBusInterfaceItem* interface, bool removePorts,\r\n        QUndoCommand* parent = 0);\r\n\r\n    /*!\r\n     *  Destructor.\r\n     */\r\n    ~InterfaceDeleteCommand();\r\n\r\n    /*!\r\n     *  Undoes the command.\r\n     */\r\n    virtual void undo();\r\n\r\n    /*!\r\n     *  Redoes the command.\r\n     */\r\n    virtual void redo();\r\n\r\nsignals:\r\n\r\n    //! Emitted when the interface is deleted.\r\n    void interfaceDeleted();\r\n\r\nprivate:\r\n    //! Disable copying.\r\n    InterfaceDeleteCommand(InterfaceDeleteCommand const& rhs);\r\n    InterfaceDeleteCommand& operator=(InterfaceDeleteCommand const& rhs);\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! The diagram interface.\r\n    HierarchicalBusInterfaceItem* interface_;\r\n\r\n    //! The bus interface.\r\n    QSharedPointer<BusInterface> busIf_;\r\n\r\n    //! The port's parent.\r\n    GraphicsColumn* parent_;\r\n\r\n    //! The graphics scene.\r\n    DesignDiagram* diagram_;\r\n\r\n    //! Boolean flag for indicating if the connection should be deleted in the destructor.\r\n    bool del_;\r\n};\r\n\r\n#endif // INTERFACEDELETECOMMANDS_H\r\n"
  },
  {
    "path": "editors/HWDesign/undoCommands/PhysicalPortDeleteCommand.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: PhysicalPortDeleteCommand.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Esko Pekkarinen\r\n// Date: 30.09.2015\r\n//\r\n// Description:\r\n// Undo command for removing a physical port in component.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"PhysicalPortDeleteCommand.h\"\r\n\r\n#include <IPXACTmodels/Component/Component.h>\r\n#include <IPXACTmodels/Component/Port.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DeletePhysicalPortCommand::DeletePhysicalPortCommand()\r\n//-----------------------------------------------------------------------------\r\nDeletePhysicalPortCommand::DeletePhysicalPortCommand(QSharedPointer<Component> component,\r\n    QSharedPointer<Port> port, QUndoCommand* parent):\r\nQUndoCommand(parent),\r\ncomponent_(component),\r\nport_(port)                                                           \r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DeletePhysicalPortCommand::~DeletePhysicalPortCommand()\r\n//-----------------------------------------------------------------------------\r\nDeletePhysicalPortCommand::~DeletePhysicalPortCommand()\r\n{\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DeletePhysicalPortCommand::undo()\r\n//-----------------------------------------------------------------------------\r\nvoid DeletePhysicalPortCommand::undo()\r\n{\r\n    Q_ASSERT(component_ != 0 && !port_.isNull());\r\n    component_->getPorts()->append(port_);\r\n\r\n    QUndoCommand::undo();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DeletePhysicalPortCommand::redo()\r\n//-----------------------------------------------------------------------------\r\nvoid DeletePhysicalPortCommand::redo()\r\n{\r\n    QUndoCommand::redo();\r\n\r\n    Q_ASSERT(component_ != 0 && !port_.isNull());\r\n    component_->getPorts()->removeAll(port_);\r\n}\r\n"
  },
  {
    "path": "editors/HWDesign/undoCommands/PhysicalPortDeleteCommand.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: PhysicalPortDeleteCommand.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Esko Pekkarinen\r\n// Date: 30.09.2015\r\n//\r\n// Description:\r\n// Undo command for removing a physical port in component.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef PHYSICALPORTDELETECOMMAND_H\r\n#define PHYSICALPORTDELETECOMMAND_H\r\n\r\n#include <QObject>\r\n#include <QSharedPointer>\r\n#include <QUndoCommand>\r\n\r\nclass Component;\r\nclass Port;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Undo command for removing a physical port in component.\r\n//-----------------------------------------------------------------------------\r\nclass DeletePhysicalPortCommand : public QUndoCommand\r\n{\r\n\r\npublic:\r\n    /*!\r\n     *  Constructor.\r\n     *\r\n     *    @param [in] component  The component from which to delete a physical port.\r\n\t *    @param [in] port       The port to delete.\r\n     *    @param [in] parent     The parent command.\r\n     */\r\n   DeletePhysicalPortCommand(QSharedPointer<Component>, QSharedPointer<Port> port, QUndoCommand* parent = 0);\r\n\r\n    /*!\r\n     *  Destructor.\r\n     */\r\n    ~DeletePhysicalPortCommand();\r\n\r\n    /*!\r\n     *  Undoes the command.\r\n     */\r\n    virtual void undo();\r\n\r\n    /*!\r\n     *  Redoes the command.\r\n     */\r\n    virtual void redo();\r\n\r\nprivate:\r\n    // Disable copying.\r\n   DeletePhysicalPortCommand(DeletePhysicalPortCommand const& rhs);\r\n   DeletePhysicalPortCommand& operator=(DeletePhysicalPortCommand const& rhs);\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! The target component model.\r\n    QSharedPointer<Component> component_;\r\n\r\n    //! The port to delete.\r\n\tQSharedPointer<Port> port_;\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n\r\n#endif // PHYSICALPORTDELETECOMMAND_H\r\n"
  },
  {
    "path": "editors/HWDesign/undoCommands/PortDeleteCommand.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: PortDeleteCommand.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Esko Pekkarinen\r\n// Date: 30.09.2015\r\n//\r\n// Description:\r\n// Undo command for removing an interface item in design diagram.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"PortDeleteCommand.h\"\r\n#include \"PhysicalPortDeleteCommand.h\"\r\n\r\n#include \"ConnectionDeleteCommand.h\"\r\n\r\n#include <editors/HWDesign/HWComponentItem.h>\r\n#include <editors/HWDesign/HWConnection.h>\r\n#include <editors/HWDesign/HWConnectionEndpoint.h>\r\n\r\n#include <editors/common/DesignDiagram.h>\r\n\r\n#include <IPXACTmodels/Component/BusInterface.h>\r\n#include <IPXACTmodels/Component/PortMap.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PortDeleteCommand::PortDeleteCommand()\r\n//-----------------------------------------------------------------------------\r\nPortDeleteCommand::PortDeleteCommand(DesignDiagram* diagram, HWConnectionEndpoint* port, QUndoCommand* parent) :\r\nQUndoCommand(parent), \r\n    port_(port), \r\n    componentItem_(static_cast<HWComponentItem*>(port->parentItem())),\r\n    scene_(port->scene()), \r\n    del_(true)\r\n{\r\n    // Create child commands for removing interconnections.\r\n    for (GraphicsConnection* conn : port_->getConnections())\r\n    {\r\n        new ConnectionDeleteCommand(diagram, static_cast<HWConnection*>(conn), this);\r\n    }\r\n\r\n    for (GraphicsConnection* conn : port_->getOffPageConnector()->getConnections())\r\n    {\r\n        new ConnectionDeleteCommand(diagram, static_cast<HWConnection*>(conn), this);\r\n    }\r\n\r\n    if (port_->getBusInterface()->getAllPortMaps())\r\n    {\r\n        auto const& allPortMaps = port_->getBusInterface()->getAllPortMaps();\r\n        for (auto const& portMap : *allPortMaps)\r\n        {\r\n            new DeletePhysicalPortCommand(componentItem_->componentModel(),\r\n                componentItem_->componentModel()->getPort(portMap->getPhysicalPort()->name_),\r\n                this);\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PortDeleteCommand::~PortDeleteCommand()\r\n//-----------------------------------------------------------------------------\r\nPortDeleteCommand::~PortDeleteCommand()\r\n{\r\n    if (del_)\r\n    {\r\n        delete port_;\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PortDeleteCommand::undo()\r\n//-----------------------------------------------------------------------------\r\nvoid PortDeleteCommand::undo()\r\n{\r\n    // Add the port to the parent component.\r\n    componentItem_->addPort(port_);\r\n\r\n    del_ = false;\r\n\r\n    // Execute child commands.\r\n    QUndoCommand::undo();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PortDeleteCommand::redo()\r\n//-----------------------------------------------------------------------------\r\nvoid PortDeleteCommand::redo()\r\n{\r\n    // Execute child commands.\r\n    QUndoCommand::redo();\r\n\r\n    // Remove the port from the parent component.\r\n    componentItem_->removePort(port_);\r\n\r\n    // Remove the port from the scene.\r\n    scene_->removeItem(port_);\r\n    del_ = true;\r\n}\r\n"
  },
  {
    "path": "editors/HWDesign/undoCommands/PortDeleteCommand.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: PortDeleteCommand.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Esko Pekkarinen\r\n// Date: 30.09.2015\r\n//\r\n// Description:\r\n// Undo command for removing an interface item in design diagram.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef PORTDELETECOMMAND_H\r\n#define PORTDELETECOMMAND_H\r\n\r\n#include <QGraphicsScene>\r\n#include <QObject>\r\n#include <QUndoCommand>\r\n\r\nclass DesignDiagram;\r\nclass HWComponentItem;\r\nclass HWConnectionEndpoint;\r\n\r\n//----------------------------------------------------------------------------\r\n//! Undo command for removing an interface item in design diagram.\r\n//-----------------------------------------------------------------------------\r\nclass PortDeleteCommand : public QUndoCommand\r\n{\r\npublic:\r\n    /*!\r\n     *  Constructor.\r\n     *\r\n     *    @param [in] port The port to delete.\r\n     */\r\n    PortDeleteCommand(DesignDiagram* diagram, HWConnectionEndpoint* port, QUndoCommand* parent = 0);\r\n\r\n    /*!\r\n     *  Destructor.\r\n     */\r\n    ~PortDeleteCommand();\r\n\r\n    /*!\r\n     *  Undoes the command.\r\n     */\r\n    virtual void undo();\r\n\r\n    /*!\r\n     *  Redoes the command.\r\n     */\r\n    virtual void redo();\r\n\r\nprivate:\r\n    // Disable copying.\r\n    PortDeleteCommand(PortDeleteCommand const& rhs);\r\n    PortDeleteCommand& operator=(PortDeleteCommand const& rhs);\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! The diagram port.\r\n    HWConnectionEndpoint* port_;\r\n\r\n    //! The port's parent.\r\n    HWComponentItem* componentItem_;\r\n\r\n    //! The graphics scene.\r\n    QGraphicsScene* scene_;\r\n\r\n    //! Boolean flag for indicating if the port should be deleted in the destructor.\r\n    bool del_;\r\n};\r\n\r\n#endif // PORTDELETECOMMAND_H\r\n"
  },
  {
    "path": "editors/HWDesign/undoCommands/PortPasteCommand.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: PortPasteCommand.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Esko Pekkarinen\r\n// Date: 15.02.2016\r\n//\r\n// Description:\r\n// Paste undo/redo command for interface items in component instances.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"PortPasteCommand.h\"\r\n\r\n#include <common/graphicsItems/GraphicsColumnConstants.h>\r\n\r\n#include <editors/common/DesignDiagram.h>\r\n#include <editors/HWDesign/ActiveBusInterfaceItem.h>\r\n#include <editors/HWDesign/HWComponentItem.h>\r\n\r\n#include <IPXACTmodels/Component/BusInterface.h>\r\n#include <IPXACTmodels/Component/Component.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PortPasteCommand::PortPasteCommand()\r\n//-----------------------------------------------------------------------------\r\nPortPasteCommand::PortPasteCommand(HWComponentItem* destComponent, ActiveBusInterfaceItem* port,\r\n    DesignDiagram* diagram, QUndoCommand* parent):\r\nQUndoCommand(parent),\r\ncomponent_(destComponent),\r\nport_(port),\r\ndel_(false),\r\ndiagram_(diagram)\r\n{\r\n   \r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PortPasteCommand::~PortPasteCommand()\r\n//-----------------------------------------------------------------------------\r\nPortPasteCommand::~PortPasteCommand()\r\n{\r\n    if (del_)\r\n    {\r\n        delete port_;\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PortPasteCommand::undo()\r\n//-----------------------------------------------------------------------------\r\nvoid PortPasteCommand::undo()\r\n{\r\n    Q_ASSERT(port_ != 0);\r\n\r\n    // Remove the port from the component and from the scene\r\n    component_->removePort(port_);\r\n    diagram_->removeItem(port_);\r\n\r\n    del_ = true;\r\n\r\n    // Execute child commands.\r\n    QUndoCommand::undo();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PortPasteCommand::redo()\r\n//-----------------------------------------------------------------------------\r\nvoid PortPasteCommand::redo()\r\n{\r\n    QUndoCommand::redo();\r\n\r\n    Q_ASSERT(port_ != 0);\r\n\r\n    // Copy a port to the component.\r\n    component_->addPort(port_);\r\n    port_->updateInterface();\r\n\r\n    del_ = false;\r\n\r\n    if (port_->scenePos().y() + GraphicsColumnConstants::MIN_Y_PLACEMENT > diagram_->sceneRect().height())\r\n    {\r\n        diagram_->resetSceneRectangleForItems();\r\n    }\r\n}\r\n"
  },
  {
    "path": "editors/HWDesign/undoCommands/PortPasteCommand.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: PortPasteCommand.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Esko Pekkarinen\r\n// Date: 15.02.2016\r\n//\r\n// Description:\r\n// Paste undo/redo command for interface items in component instances.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include <QGraphicsScene>\r\n#include <QUndoCommand>\r\n\r\nclass Component;\r\nclass HWComponentItem;\r\nclass ActiveBusInterfaceItem;\r\nclass DesignDiagram;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! PortPasteCommand class.\r\n//-----------------------------------------------------------------------------\r\nclass PortPasteCommand : public QUndoCommand\r\n{\r\npublic:\r\n    /*!\r\n     *  Constructor.\r\n     *\r\n\t *      Creates the child commands for adding physical ports to the component model. \r\n\t *\r\n     *    @param [in] destComponent   The component to which to copy a port.\r\n\t *    @param [in] port            The port to paste.\r\n     *    @param [in] diagram         Diagram containing the scene of the port.\r\n     *    @param [in] parent          The parent command.\r\n     */\r\n    PortPasteCommand(HWComponentItem* destComponent, ActiveBusInterfaceItem* port, DesignDiagram* diagram,\r\n        QUndoCommand* parent = 0);\r\n\r\n    /*!\r\n     *  Destructor.\r\n     */\r\n    ~PortPasteCommand();\r\n\r\n    /*!\r\n     *  Undoes the command.\r\n     */\r\n    virtual void undo();\r\n\r\n    /*!\r\n     *  Redoes the command.\r\n     */\r\n    virtual void redo();\r\n\r\nprivate:\r\n    // Disable copying.\r\n    PortPasteCommand(PortPasteCommand const& rhs);\r\n    PortPasteCommand& operator=(PortPasteCommand const& rhs);\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! The target item.\r\n    HWComponentItem* component_;\r\n\r\n    //! The diagram port.\r\n    ActiveBusInterfaceItem* port_;\r\n\r\n\t//! Boolean flag for indicating if the port should be deleted in the destructor.\r\n    bool del_;\r\n\r\n    //! Diagram containing the scene of the port.\r\n    DesignDiagram* diagram_;\r\n};\r\n"
  },
  {
    "path": "editors/HWDesign/undoCommands/ReplaceComponentCommand.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ReplaceComponentCommand.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Mikko Teuho\r\n// Date: 04.04.2016\r\n//\r\n// Description:\r\n// Undo command for replacing a HW component instance with another one.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"ReplaceComponentCommand.h\"\r\n\r\n#include <common/graphicsItems/ComponentItem.h>\r\n#include <common/graphicsItems/ConnectionUndoCommands.h>\r\n#include <common/graphicsItems/CommonGraphicsUndoCommands.h>\r\n#include <common/graphicsItems/GraphicsColumnLayout.h>\r\n#include <common/graphicsItems/GraphicsColumn.h>\r\n#include <common/graphicsItems/GraphicsConnection.h>\r\n\r\n#include <editors/common/DesignDiagram.h>\r\n#include <editors/common/Association/AssociationChangeEndpointCommand.h>\r\n\r\n#include <editors/HWDesign/HWMoveCommands.h>\r\n#include <editors/HWDesign/AdHocConnectionItem.h>\r\n#include <editors/HWDesign/HWConnection.h>\r\n#include <editors/HWDesign/ActiveBusInterfaceItem.h>\r\n#include <editors/HWDesign/ActivePortItem.h>\r\n#include <editors/HWDesign/HierarchicalPortItem.h>\r\n#include <editors/HWDesign/HWComponentItem.h>\r\n\r\n#include <editors/HWDesign/undoCommands/HWComponentAddCommand.h>\r\n#include <editors/HWDesign/undoCommands/ConnectionDeleteCommand.h>\r\n#include <editors/HWDesign/undoCommands/ComponentDeleteCommand.h>\r\n#include <editors/HWDesign/undoCommands/AdHocConnectionDeleteCommand.h>\r\n#include <editors/HWDesign/HWChangeCommands.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ReplaceComponentCommand::ReplaceComponentCommand()\r\n//-----------------------------------------------------------------------------\r\nReplaceComponentCommand::ReplaceComponentCommand(HWComponentItem* oldComp, HWComponentItem* newComp,\r\n    DesignDiagram* diagram, QUndoCommand* parent):\r\nQUndoCommand(parent),\r\nposition_(oldComp->scenePos()),\r\nnewComp_(newComp),\r\ndiagram_(diagram)\r\n{\r\n    new ItemMoveCommand(newComp_, newComp_->scenePos(), newComp_->getParentStack(), position_,\r\n        oldComp->getParentStack(), diagram, this);\r\n\r\n    new ItemMoveCommand(oldComp, position_, oldComp->getParentStack(), newComp_->scenePos(),\r\n        newComp_->getParentStack(), diagram, this);\r\n\r\n    QVector<QString> connectionNames;\r\n    changeConnections(oldComp, newComp_, connectionNames);\r\n    changeConnections(newComp_, oldComp, connectionNames);\r\n\r\n    for (Association* association : oldComp->getAssociations())\r\n    {\r\n        new AssociationChangeEndpointCommand(association, oldComp, newComp_, this);\r\n    }\r\n\r\n    QSharedPointer<Design> design = diagram->getDesign();\r\n    new ComponentChangeNameCommand(oldComp, newComp_->name(), design, this);\r\n    new ComponentChangeNameCommand(newComp_, oldComp->name(), design, this);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ReplaceComponentCommand::changeConnections()\r\n//-----------------------------------------------------------------------------\r\nvoid ReplaceComponentCommand::changeConnections(HWComponentItem* oldComponentItem, \r\n    HWComponentItem* newComponentItem, QVector<QString>& connectionNames)\r\n{\r\n    for (ConnectionEndpoint* oldEndpoint : oldComponentItem->getEndpoints())\r\n    {\r\n        if (!oldEndpoint->getConnections().isEmpty() || \r\n            (oldEndpoint->getOffPageConnector() && !oldEndpoint->getOffPageConnector()->getConnections().isEmpty()))\r\n        {\r\n            HWConnectionEndpoint* newEndpoint = 0;\r\n\r\n            if (oldEndpoint->type() == ActiveBusInterfaceItem::Type)\r\n            {\r\n                newEndpoint = newComponentItem->getBusPort(oldEndpoint->name());\r\n            }\r\n            else if (oldEndpoint->type() == ActivePortItem::Type)\r\n            {\r\n                newEndpoint = newComponentItem->getAdHocPort(oldEndpoint->name());\r\n            }\r\n\r\n            if (newEndpoint != 0)\r\n            {\r\n                createConnectionExchangeCommands(oldEndpoint, newEndpoint, connectionNames);\r\n            }\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ReplaceComponentCommand::createConnectionExchangeCommands()\r\n//-----------------------------------------------------------------------------\r\nvoid ReplaceComponentCommand::createConnectionExchangeCommands(ConnectionEndpoint* oldEndpoint, \r\n    HWConnectionEndpoint* newEndpoint, QVector<QString>& connectionNames)\r\n{\r\n    // Create a move command to move the port to the same place where it is in the old component.\r\n    new PortMoveCommand(newEndpoint, newEndpoint->pos(), oldEndpoint->pos(), diagram_, this);\r\n\r\n    // Exchange connections between the endpoints.\r\n    for (GraphicsConnection* connection : oldEndpoint->getConnections())\r\n    {\r\n        if (!connectionNames.contains(connection->name()))\r\n        {\r\n            new ConnectionExchangeCommand(connection, oldEndpoint, newEndpoint, this);\r\n            connectionNames.append(connection->name());\r\n        }\r\n    }\r\n\r\n    if (oldEndpoint->getOffPageConnector() &&\r\n        !oldEndpoint->getOffPageConnector()->getConnections().isEmpty())\r\n    {\r\n        for (GraphicsConnection* connection : oldEndpoint->getOffPageConnector()->getConnections())\r\n        {\r\n            if (!connectionNames.contains(connection->name()))\r\n            {\r\n                new ConnectionExchangeCommand(connection, oldEndpoint->getOffPageConnector(),\r\n                    newEndpoint->getOffPageConnector(), this);\r\n                connectionNames.append(connection->name());\r\n            }\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ReplaceComponentCommand::~ReplaceComponentCommand()\r\n//-----------------------------------------------------------------------------\r\nReplaceComponentCommand::~ReplaceComponentCommand()\r\n{\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ReplaceComponentCommand::undo()\r\n//-----------------------------------------------------------------------------\r\nvoid ReplaceComponentCommand::undo()\r\n{\r\n    // Execute child commands.\r\n    QUndoCommand::undo();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ReplaceComponentCommand::redo()\r\n//-----------------------------------------------------------------------------\r\nvoid ReplaceComponentCommand::redo()\r\n{\r\n    // Place the new component to the exact same location as the old one.\r\n    newComp_->setParentItem(0);\r\n    newComp_->setPos(position_);\r\n\r\n    // Execute child commands.\r\n    QUndoCommand::redo();\r\n}\r\n"
  },
  {
    "path": "editors/HWDesign/undoCommands/ReplaceComponentCommand.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ReplaceComponentCommand.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Mikko Teuho\r\n// Date: 04.04.2016\r\n//\r\n// Description:\r\n// Undo command for replacing a HW component instance with another one.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef REPLACECOMPONENTCOMMAND_H\r\n#define REPLACECOMPONENTCOMMAND_H\r\n\r\n#include <QUndoCommand>\r\n\r\n#include <QPointF>\r\n\r\nclass Design;\r\n\r\nclass ComponentItem;\r\nclass DesignDiagram;\r\nclass HWComponentItem;\r\nclass HWConnectionEndpoint;\r\nclass ConnectionEndpoint;\r\nclass GraphicsConnection;\r\nclass ComponentInstance;\r\nclass DesignDiagram;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Undo command for replacing a HW component instance with another one.\r\n//-----------------------------------------------------------------------------\r\nclass ReplaceComponentCommand : public QObject, public QUndoCommand\r\n{\r\n    Q_OBJECT\r\n\r\npublic:\r\n\r\n\t/*!\r\n\t *  The constructor.\r\n\t *\r\n\t *    @param [in] diagram     The containing design diagram.\r\n\t *    @param [in] oldComp     The replaced component.\r\n\t *    @param [in] newComp     The new component.\r\n     *    @param [in] diagram     Diagram containing the scene of the component items.\r\n\t *    @param [in] parent      Owner of this command.\r\n\t */\r\n    ReplaceComponentCommand(HWComponentItem* oldComp, HWComponentItem* newComp, DesignDiagram* diagram,\r\n        QUndoCommand* parent = 0);\r\n\r\n\t/*!\r\n     *  Destructor.\r\n     */\r\n\tvirtual ~ReplaceComponentCommand();\r\n\r\n\t/*!\r\n\t *  Undoes the command.\r\n\t */\r\n\tvirtual void undo();\r\n\r\n\t/*! \r\n\t *  Redoes the command.\r\n\t */\r\n\tvirtual void redo();\r\n\r\nsignals:\r\n    //! Emitted when a new component is instantiated to the design.\r\n    void componentInstantiated(ComponentItem*);\r\n\r\n    //! Emitted when a component instance is removed from the design.\r\n    void componentInstanceRemoved(ComponentItem*);\r\n\r\nprivate:\r\n    // Disable copying.\r\n    ReplaceComponentCommand(ReplaceComponentCommand const& rhs);\r\n    ReplaceComponentCommand& operator=(ReplaceComponentCommand const& rhs);\r\n\r\n    /*!\r\n     *  Change connections.\r\n     *\r\n     *    @param [in] keepExistingComponent   Flag for existence checking.\r\n     *    @param [in] connectionNames         Names of the changed connections.\r\n     *    @param [in] oldComponentItem        The replaced component.\r\n     *    @param [in] newComponentItem        The new component.\r\n     *    @param [in] diagram                 The containing design diagram.\r\n     */\r\n    void changeConnections(HWComponentItem* oldComponentItem, HWComponentItem* newComponentItem, \r\n        QVector<QString>& connectionNames);\r\n\r\n    /*!\r\n     *  Create exchange commands for connections between the end points.\r\n     *\r\n     *    @param [in] connectionNames     Names of the changed connections.\r\n     *    @param [in] oldEndpoint         The replaced end point.\r\n     *    @param [in] newEndpoint         The new end point.\r\n     */\r\n    void createConnectionExchangeCommands(ConnectionEndpoint* oldEndpoint,\r\n        HWConnectionEndpoint* newEndpoint, QVector<QString>& connectionNames);\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n\t//! The old component to replace.\r\n    QPointF position_;\r\n\r\n    //! The new component that replaces the old one.\r\n    HWComponentItem* newComp_;\r\n\r\n    //! Diagram containing the scene of the component items.\r\n    DesignDiagram* diagram_;\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n\r\n#endif // REPLACECOMPONENTCOMMAND_H\r\n"
  },
  {
    "path": "editors/HWDesign/undoCommands/TopAdHocVisibilityChangeCommand.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: TopAdHocVisibilityChangeCommand.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 25.10.2017\n//\n// Description:\n// Undo command for changing port adhoc visibility in top component of design diagram.\n//-----------------------------------------------------------------------------\n\n#include \"TopAdHocVisibilityChangeCommand.h\"\n\n#include <editors/HWDesign/HWDesignDiagram.h>\n#include <editors/HWDesign/columnview/HWColumn.h>\n#include <editors/HWDesign/undoCommands/AdHocTieOffConnectionDeleteCommand.h>\n#include <editors/HWDesign/undoCommands/HWColumnAddCommand.h>\n\n#include <common/graphicsItems/GraphicsColumnLayout.h>\n#include <common/graphicsItems/GraphicsColumnConstants.h>\n\n#include <IPXACTmodels/Design/AdHocConnection.h>\n#include <IPXACTmodels/Design/Design.h>\n\n//-----------------------------------------------------------------------------\n// Function: TopAdHocVisibilityChangeCommand::TopAdHocVisibilityChangeCommand()\n//-----------------------------------------------------------------------------\nTopAdHocVisibilityChangeCommand::TopAdHocVisibilityChangeCommand(HWDesignDiagram* diagram, \n    QString const& portName,\n    bool newVisibility, \n    QUndoCommand* parent):\nAdHocVisibilityChangeCommand(diagram, portName, newVisibility, parent)\n{\n    setupTieOffConnectionForDeletion(diagram, portName);\n\n    if (newVisibility)\n    {\n        setupColumnAddition(diagram);\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: TopAdHocVisibilityChangeCommand::setupTieOffConnectionForDeletion()\n//-----------------------------------------------------------------------------\nvoid TopAdHocVisibilityChangeCommand::setupTieOffConnectionForDeletion(HWDesignDiagram* diagram,\n    QString const& portName)\n{\n    if (diagram && diagram->getDesign())\n    {\n        QSharedPointer<Design> containingDesign = diagram->getDesign();\n        if (containingDesign)\n        {\n            for (QSharedPointer<AdHocConnection> connection : *containingDesign->getAdHocConnections())\n            {\n                if (!connection->getTiedValue().isEmpty())\n                {\n                    if ((connection->getInternalPortReferences()->size() == 1 &&\n                        connection->getExternalPortReferences()->isEmpty() &&\n                        connection->getInternalPortReferences()->first()->getPortRef() == portName) ||\n                        (connection->getExternalPortReferences()->size() == 1 &&\n                        connection->getInternalPortReferences()->isEmpty() &&\n                        connection->getExternalPortReferences()->first()->getPortRef() == portName))\n                    {\n                        new AdHocTieOffConnectionDeleteCommand(containingDesign, connection, this);\n                    }\n                }\n            }\n        }\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: TopAdHocVisibilityChangeCommand::setupColumnAddition()\n//-----------------------------------------------------------------------------\nvoid TopAdHocVisibilityChangeCommand::setupColumnAddition(HWDesignDiagram* diagram)\n{\n    GraphicsColumnLayout* diagramLayout = diagram->getLayout().data();\n    for  (GraphicsColumn* column : diagramLayout->getColumns())\n    {\n        if (column->getColumnDesc()->getAllowedItems() & ColumnTypes::INTERFACE)\n        {\n            return;\n        }\n    }\n\n    QSharedPointer<ColumnDesc> newColumnDescription(\n        new ColumnDesc(QString(\"IO\"), ColumnTypes::IO, 0, GraphicsColumnConstants::IO_COLUMN_WIDTH));\n\n    HWColumn* newColumn(new HWColumn(newColumnDescription, diagramLayout));\n\n    new HWColumnAddCommand(diagramLayout, newColumn, diagram, this);\n}\n"
  },
  {
    "path": "editors/HWDesign/undoCommands/TopAdHocVisibilityChangeCommand.h",
    "content": "//-----------------------------------------------------------------------------\n// File: TopAdHocVisibilityChangeCommand.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 25.10.2017\n//\n// Description:\n// Undo command for changing port adhoc visibility in top component of design diagram.\n//-----------------------------------------------------------------------------\n\n#ifndef TOPADHOCVISIBILITYCHANGECOMMAND_H\n#define TOPADHOCVISIBILITYCHANGECOMMAND_H\n\n#include <editors/HWDesign/undoCommands/AdHocVisibilityChangeCommand.h>\n\nclass HWDesignDiagram;\nclass GraphicsColumnLayout;\n\n//-----------------------------------------------------------------------------\n//! Undo command for changing port adhoc visibility in top component of design diagram.\n//-----------------------------------------------------------------------------\nclass TopAdHocVisibilityChangeCommand : public AdHocVisibilityChangeCommand\n{\npublic:\n\n    /*!\n     *  Constructor.\n     *\n     *    @param [in] dataSource    The ad-hoc enabled data source.\n     *    @param [in] portName      The name of the port.\n     *    @param [in] newVisiblity  The new ad-hoc visibility of the port.\n     *    @param [in] parent        The parent undo command.\n     */\n    TopAdHocVisibilityChangeCommand(HWDesignDiagram* dataSource, QString const& portName, bool newVisibility,\n        QUndoCommand* parent = nullptr);\n\n    /*!\n     *  Destructor.\n     */\n    ~TopAdHocVisibilityChangeCommand() = default;\n\nprivate:\n\n    // Disable copying.\n    TopAdHocVisibilityChangeCommand(TopAdHocVisibilityChangeCommand const& rhs);\n    TopAdHocVisibilityChangeCommand& operator=(TopAdHocVisibilityChangeCommand const& rhs);\n\n    /*!\n     *  Setup a command for the deleting of the tie off value connection of the selected port item.\n     *\n     *    @param [in] diagram     Design diagram containing the ad hoc port.\n     *    @param [in] portName    Name of the selected port item.\n     */\n    void setupTieOffConnectionForDeletion(HWDesignDiagram* diagram, QString const& portName);\n\n    /*!\n     *  Setup the addition of an ad hoc port column.\n     *\n     *    @param [in] diagram     Design diagram containing the ad hoc port.\n     */\n    void setupColumnAddition(HWDesignDiagram* diagram);\n\n    //-----------------------------------------------------------------------------\n    // Data.\n    //-----------------------------------------------------------------------------\n};\n\n#endif // TOPADHOCVISIBILITYCHANGECOMMAND_H\n"
  },
  {
    "path": "editors/InterconnectGenerator/InstanceInterfacesEditor.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: InstanceInterfacesEditor.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Anton Hagqvist\n// Date: 12.08.2025\n//\n// Description:\n// Editor for selecting instance and its interfaces to connect to interconnect\n//-----------------------------------------------------------------------------\n\n#include \"InstanceInterfacesEditor.h\"\n#include <common/widgets/instanceWidgets/InstanceWidgets.h>\n\n#include <common/widgets/EnumCollectionEditor/InterfaceEnumEditor.h>\n\n#include <QLabel>\n#include <QPushButton>\n\n//-----------------------------------------------------------------------------\n// Function: InstanceInterfacesEditor::InstanceInterfacesEditor()\n//-----------------------------------------------------------------------------\nInstanceInterfacesEditor::InstanceInterfacesEditor(ExpressionSet const& expressionSet, ComponentParameterModel* parameterCompleterModel, Document::Revision docRevision, QWidget* parent) :\n    QFrame(parent),\n    instanceNameLabel_(new QLabel(\"Instance name:\")),\n    instanceSelectorCombo_(new InstanceComboBox()),\n    removeInstanceButton_(new QPushButton(QIcon(\":/icons/common/graphics/cross.png\"), \"Remove\")),\n    interfacesEditor_(new InterfaceEnumEditor(expressionSet, parameterCompleterModel, docRevision))\n{\n    setLayout(&topLayout_);\n    setSizePolicy(QSizePolicy::Preferred, QSizePolicy::MinimumExpanding);\n\n    buttonRowLayout_.addWidget(instanceNameLabel_);\n    buttonRowLayout_.addWidget(instanceSelectorCombo_);\n    buttonRowLayout_.addWidget(removeInstanceButton_);\n\n    topLayout_.addLayout(&buttonRowLayout_);\n    topLayout_.addWidget(interfacesEditor_);\n\n    connect(instanceSelectorCombo_, &QComboBox::currentIndexChanged, this, &InstanceInterfacesEditor::onInstanceSelected, Qt::UniqueConnection);\n    connect(removeInstanceButton_, SIGNAL(clicked()), this, SIGNAL(instanceRemoved()), Qt::UniqueConnection);\n}\n\n//-----------------------------------------------------------------------------\n// Function: InstanceInterfacesEditor::updateAvailableInstances()\n//-----------------------------------------------------------------------------\nvoid InstanceInterfacesEditor::updateAvailableInstances(QSet<QString> const& availableInterfaces)\n{\n    auto currentSelection = instanceSelectorCombo_->currentText();\n    instanceSelectorCombo_->clear();\n    instanceSelectorCombo_->addItems(QStringList(availableInterfaces.cbegin(), availableInterfaces.cend()));\n    \n    // If there was a previous (non-empty) selection, add and select it again. Otherwise just pick the first option\n    if (currentSelection.isEmpty() == false)\n    {\n        instanceSelectorCombo_->addItem(currentSelection);\n        instanceSelectorCombo_->setCurrentText(currentSelection);\n    }\n    else\n    {\n        instanceSelectorCombo_->setCurrentIndex(0);\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: InstanceInterfacesEditor::getSelectedInstance()\n//-----------------------------------------------------------------------------\nQString InstanceInterfacesEditor::getSelectedInstance() const\n{\n    return instanceSelectorCombo_->currentText();\n}\n\n//-----------------------------------------------------------------------------\n// Function: InstanceInterfacesEditor::addInterfaceItems()\n//-----------------------------------------------------------------------------\nvoid InstanceInterfacesEditor::addInterfaceItems(const QList<InterfaceEnumEditor::InterfaceInput>& items, General::InterfaceMode interfaceMode)\n{\n    interfacesToAdd_.insert(interfaceMode, items);\n}\n\n//-----------------------------------------------------------------------------\n// Function: InstanceInterfacesEditor::createInterfaceItems()\n//-----------------------------------------------------------------------------\nvoid InstanceInterfacesEditor::createInterfaceItems(bool isChannel)\n{\n    if (interfacesToAdd_.contains(General::InterfaceMode::INITIATOR))\n    {\n        interfacesEditor_->addItems(interfacesToAdd_.value(General::InterfaceMode::INITIATOR), \n                General::InterfaceMode::INITIATOR, isChannel);\n    }\n\n    if (interfacesToAdd_.contains(General::InterfaceMode::TARGET))\n    {\n        interfacesEditor_->addItems(interfacesToAdd_.value(General::InterfaceMode::TARGET),\n            General::InterfaceMode::TARGET, isChannel);\n    }\n\n    if (interfacesToAdd_.contains(General::InterfaceMode::MIRRORED_INITIATOR))\n    {\n        interfacesEditor_->addItems(interfacesToAdd_.value(General::InterfaceMode::MIRRORED_INITIATOR),\n            General::InterfaceMode::MIRRORED_INITIATOR, isChannel);\n    }\n\n    if (interfacesToAdd_.contains(General::InterfaceMode::MIRRORED_TARGET))\n    {\n        interfacesEditor_->addItems(interfacesToAdd_.value(General::InterfaceMode::MIRRORED_TARGET),\n            General::InterfaceMode::MIRRORED_TARGET, isChannel);\n    }\n\n    // Add stretch to editor if needed (determined in interfaces editor)\n    interfacesEditor_->addStretchIfNeeded();\n\n    // Recalculate the checkbox widths based on widths of added interface names, shortens names if needed\n    interfacesEditor_->limitCheckboxTextWidths();\n}\n\n//-----------------------------------------------------------------------------\n// Function: InstanceInterfacesEditor::getSelectedInterfaces()\n//-----------------------------------------------------------------------------\nQList<InterfaceEnumEditor::InterfaceData> InstanceInterfacesEditor::getSelectedInterfaces() const\n{\n    return interfacesEditor_->getSelectedInterfaces();\n}\n\n//-----------------------------------------------------------------------------\n// Function: InstanceInterfacesEditor::clearInterfaceItems()\n//-----------------------------------------------------------------------------\nvoid InstanceInterfacesEditor::clearInterfaceItems()\n{\n    interfacesEditor_->clearAll();\n    interfacesToAdd_.clear();\n}\n\n//-----------------------------------------------------------------------------\n// Function: InstanceInterfacesEditor::onInstanceSelected()\n//-----------------------------------------------------------------------------\nvoid InstanceInterfacesEditor::onInstanceSelected()\n{\n    emit instanceSelected(instanceSelectorCombo_->currentText(), previousInstanceSelection_);\n    previousInstanceSelection_ = instanceSelectorCombo_->currentText();\n}\n"
  },
  {
    "path": "editors/InterconnectGenerator/InstanceInterfacesEditor.h",
    "content": "//-----------------------------------------------------------------------------\n// File: InstanceInterfacesEditor.h\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Anton Hagqvist\n// Date: 12.08.2025\n//\n// Description:\n// Editor for selecting instance and its interfaces to connect to interconnect\n//-----------------------------------------------------------------------------\n\n#ifndef INSTANCEINTERFACESEDITOR_H\n#define INSTANCEINTERFACESEDITOR_H\n\n#include <common/widgets/EnumCollectionEditor/InterfaceEnumEditor.h>\n#include <IPXACTmodels/common/Document.h>\n#include <editors/common/ExpressionSet.h>\n\n#include <QFrame>\n#include <QVBoxLayout>\n#include <QHBoxLayout>\n\nclass QLabel;\nclass QPushButton;\nclass QComboBox;\nclass InstanceComboBox;\nclass ParameterFinder;\nclass ComponentParameterModel;\n\nclass InstanceInterfacesEditor : public QFrame\n{\n    Q_OBJECT\npublic:\n\n    /*!\n     *\tConstructor\n     *  \n     *    @param [in] expressionSet                 Struct containing items needed for expression parsing and formatting\n     *    @param [in] parameterCompleterModel       Parameter completer model for expressions\n     *    @param [in] docRevision                   IP-XACT standard revision in use\n     *    @param [in] parent                        The parent widget\n     */\n    InstanceInterfacesEditor(ExpressionSet const& expressionSet, ComponentParameterModel* parameterCompleterModel, Document::Revision docRevision, QWidget* parent = nullptr);\n\n    virtual ~InstanceInterfacesEditor() = default;\n\n    //! No copying\n    InstanceInterfacesEditor(InstanceInterfacesEditor const& other) = delete;\n    InstanceInterfacesEditor& operator=(InstanceInterfacesEditor const& other) = delete;\n\n    // Call this whenever an instance is added (= removed from available instances)\n    // => updates combo box options\n    \n    \n    /*!\n     *\tUpdate the instance options for instance combo box.\n     *  Should called be whenever an instance is added (= removed from available instances).\n     *  Reselects the same instance, if there was a selection before. Otherwise picks the first option.\n     * \n     *    @param [in] availableInterfaces     The instances available to select.\n     */\n    void updateAvailableInstances(QSet<QString> const& availableInterfaces);\n\n    /*!\n     *\tGets the currently selected instance name.\n     *\t    \n     *    @return The currently selected instance.\n     */\n    QString getSelectedInstance() const;\n\n    /*!\n     *\tAdds provided instance interfaces (of same mode) to the list of interfaces to create.\n     *  \n     *    @param [in] items             The interfaces to add.\n     *    @param [in] interfaceMode     The mode of the added interfaces.\n     */\n    void addInterfaceItems(const QList<InterfaceEnumEditor::InterfaceInput>& items, General::InterfaceMode interfaceMode);\n    \n    /*!\n     *\tCreates widgets for all of the added instance interfaces.\n     *  \n     *    @param [in] isChannel     Flag indicating if interconnect should use channel or bridge.\n     */\n    void createInterfaceItems(bool isChannel);\n\n    /*!\n     *\tGet the selected interfaces.\n     *  \n     *    @return A list containing information about each selected interface.\n     */\n    QList<InterfaceEnumEditor::InterfaceData> getSelectedInterfaces() const;\n\n    /*!\n     *\tClear all interface items of this editor.\n     */\n    void clearInterfaceItems();\n\npublic slots:\n\n    /*!\n     *\tHandler for when new instance is selected.\n     */\n    void onInstanceSelected();\n\nsignals:\n\n    //! Signal for parent widget emitted when new instance is selected\n    void instanceSelected(QString const& newSelection, QString const& oldSelection);\n\n    //! Signal for parent to remove the selected instance\n    void instanceRemoved();\n\nprivate:\n\n    //! Top level layout for the editor.\n    QVBoxLayout topLayout_;\n\n    //! Layout for the button row.\n    QHBoxLayout buttonRowLayout_;\n\n    //! Widgets for the button row\n    QLabel* instanceNameLabel_;\n    QPushButton* removeInstanceButton_;\n    InstanceComboBox* instanceSelectorCombo_;\n\n    //! Stores the previous instance selection for comparison when new instance is selected.\n    QString previousInstanceSelection_;\n\n    //! Editor for the instance interfaces.\n    InterfaceEnumEditor* interfacesEditor_;\n\n    //! Temporarily stores the interfaces to add to the interfaces editor.\n    QHash<General::InterfaceMode, QList<InterfaceEnumEditor::InterfaceInput> > interfacesToAdd_;\n};\n\n\n#endif // INSTANCEINTERFACESEDITOR_H\n\n"
  },
  {
    "path": "editors/InterconnectGenerator/InterconnectAddressHelper.cpp",
    "content": "#include \"InterconnectAddressHelper.h\"\n\n#include <QHash>\n#include <QString>\n#include <QSharedPointer>\n\n#include <IPXACTmodels/common/Document.h>\n#include <IPXACTmodels/Component/Component.h>\n#include <KactusAPI/include/ExpressionParser.h>\n#include <KactusAPI/include/ExpressionFormatter.h>\n#include <KactusAPI/include/LibraryHandler.h>\n#include <KactusAPI/include/ComponentInstanceInterface.h>\n#include <KactusAPI/include/MemoryMapInterface.h>\n#include <KactusAPI/include/AddressBlockInterface.h>\n#include <KactusAPI/include/IPXactSystemVerilogParser.h>\n#include <IPXACTmodels/Component/validators/EnumeratedValueValidator.h>\n#include <IPXACTmodels/Component/validators/FieldValidator.h>\n#include <IPXACTmodels/Component/validators/RegisterValidator.h>\n#include <IPXACTmodels/Component/validators/RegisterFileValidator.h>\n#include <IPXACTmodels/Component/validators/AddressBlockValidator.h>\n#include <IPXACTmodels/Component/validators/SubspaceMapValidator.h>\n#include <IPXACTmodels/Component/validators/MemoryMapValidator.h>\n#include <IPXACTmodels/Component/MemoryMap.h>\n#include <IPXACTmodels/DesignConfiguration/DesignConfiguration.h>\n\n//-----------------------------------------------------------------------------\n// Function: InterconnectAddressHelper::InterconnectAddressHelper()\n//-----------------------------------------------------------------------------\nInterconnectAddressHelper::InterconnectAddressHelper(VLNV designVLNV,\n    LibraryHandler* library, MessageMediator* messager)\n    : library_(library),\n    messager_(messager), \n    expressionParser_(0),\n    expressionFormatter_(0),\n    accessPolicyInterface_(0),\n    busInfInterface_(0),\n    fieldInterface_(0),\n    modeRefInterface_(0),\n    registerInterface_(0),\n    resetInterface_(0)\n{\n    QSharedPointer<Document> designCompDocument = library_->getModel(designVLNV);\n\n    QSharedPointer<Component> designComp = designCompDocument.dynamicCast<Component>();\n    QSharedPointer<QList<QSharedPointer<DesignConfigurationInstantiation> > > list = designComp->getDesignConfigurationInstantiations();\n    QSharedPointer<DesignConfigurationInstantiation> inst = list->at(0);\n    QSharedPointer<ConfigurableVLNVReference> vlnv = inst->getDesignConfigurationReference();\n\n    QSharedPointer<Document> designConfDocument = library_->getModel(*vlnv);\n    QSharedPointer<DesignConfiguration> designConfig = designConfDocument.dynamicCast<DesignConfiguration>();\n\n    QSharedPointer<Document> designDocument = library_->getModel(designConfig->getDesignRef());\n    QSharedPointer<Design> design = designDocument.dynamicCast<Design>();\n\n    instanceInterface_->setComponentInstances(design);\n    listParameterFinder_ = QSharedPointer<ListParameterFinder>::create();\n    expressionFormatter_ = QSharedPointer<ExpressionFormatter>::create(listParameterFinder_);\n    expressionParser_ = QSharedPointer<IPXactSystemVerilogParser>::create(listParameterFinder_);\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: InterconnectAddressHelper::reset()\n//-----------------------------------------------------------------------------\nvoid InterconnectAddressHelper::reset() {\n    usedAddressRanges_.clear();\n    nextAvailableAddress_ = 0;\n}\n\n//-----------------------------------------------------------------------------\n// Function: InterconnectAddressHelper::getEndpointAddressRange()\n//-----------------------------------------------------------------------------\nbool InterconnectAddressHelper::getEndpointAddressRange(const QString& instanceName,\n    const QString& interfaceName,\n    quint64& outStart,\n    quint64& outRange)\n{\n    outStart = 0;\n    outRange = 0;\n\n    QSharedPointer<Component> component = loadComponentForInstance(instanceName);\n    if (!component) return false;\n\n    QString matchingMap = findMatchingMemoryMap(component, interfaceName);\n    if (matchingMap.isEmpty()) return false;\n\n    quint64 totalRange = calculateTotalRange(component, matchingMap);\n    if (totalRange == 0) return false;\n\n    return assignAddressRange(instanceName, totalRange, outStart, outRange);\n}\n\n//-----------------------------------------------------------------------------\n// Function: InterconnectAddressHelper::loadComponentForInstance()\n//-----------------------------------------------------------------------------\nQSharedPointer<Component> InterconnectAddressHelper::loadComponentForInstance(const QString& instanceName)\n{\n    QSharedPointer<VLNV> compVLNV = instanceInterface_->getComponentReference(instanceName.toStdString());\n    if (!compVLNV) return nullptr;\n\n    QSharedPointer<Document> doc = library_->getModel(*compVLNV);\n    if (!doc) return nullptr;\n\n    QSharedPointer<QList<QSharedPointer<Parameter>>> parameters = doc->getParameters();\n    listParameterFinder_->setParameterList(parameters);\n\n    QSharedPointer<Component> component = doc.dynamicCast<Component>();\n    if (!component) return nullptr;\n\n    initialize(component);\n    memoryMapInterface_->setMemoryMaps(component);\n\n    return component;\n}\n\n//-----------------------------------------------------------------------------\n// Function: InterconnectAddressHelper::findMatchingMemoryMap()\n//-----------------------------------------------------------------------------\nQString InterconnectAddressHelper::findMatchingMemoryMap(QSharedPointer<Component> component, const QString& interfaceName)\n{\n    std::vector<std::string> mapNames = memoryMapInterface_->getItemNames();\n\n    for (const std::string& nameStr : mapNames) {\n        std::string boundIf = memoryMapInterface_->getInterfaceBinding(nameStr);\n        if (boundIf == interfaceName.toStdString()) {\n            return QString::fromStdString(nameStr);\n        }\n    }\n\n    return QString();\n}\n\n//-----------------------------------------------------------------------------\n// Function: InterconnectAddressHelper::calculateTotalRange()\n//-----------------------------------------------------------------------------\nquint64 InterconnectAddressHelper::calculateTotalRange(QSharedPointer<Component> component, const QString& mapName)\n{\n    MemoryMap* map = memoryMapInterface_->getMapPointer(mapName.toStdString());\n    if (!map || !map->getMemoryBlocks()) return 0;\n\n    addressBlockInterface_->setMemoryBlocks(map->getMemoryBlocks());\n    addressBlockInterface_->setAddressUnitBits(memoryMapInterface_->getAddressUnitBitsValue(mapName.toStdString()));\n    addressBlockInterface_->setupSubInterfaces(component);\n\n    std::vector<std::string> blockNames = addressBlockInterface_->getItemNames();\n    quint64 totalRange = 0;\n\n    for (const std::string& blockName : blockNames) {\n        QString blockRangeStr = QString::fromStdString(addressBlockInterface_->getRangeValue(blockName));\n\n        bool ok = false;\n        quint64 blockRange = blockRangeStr.toULongLong(&ok, 0);\n        if (ok) {\n            totalRange += blockRange;\n        }\n    }\n\n    return totalRange;\n}\n\n//-----------------------------------------------------------------------------\n// Function: InterconnectAddressHelper::assignAddressRange()\n//-----------------------------------------------------------------------------\nbool InterconnectAddressHelper::assignAddressRange(const QString& instanceName, quint64 totalRange,\n    quint64& outStart, quint64& outRange)\n{\n    if (usedAddressRanges_.contains(instanceName)) {\n        const auto& pair = usedAddressRanges_.value(instanceName);\n        outStart = pair.first;\n        outRange = pair.second;\n        return true;\n    }\n\n    std::sort(freeAddressSpaces_.begin(), freeAddressSpaces_.end());\n\n    for (int i = 0; i < freeAddressSpaces_.size(); ++i) {\n        const QPair<quint64, quint64>& free = freeAddressSpaces_.at(i);\n\n        // If block is large enough to hold the range\n        if (free.second >= totalRange) {\n            outStart = free.first;\n            outRange = totalRange;\n            usedAddressRanges_.insert(instanceName, qMakePair(outStart, outRange));\n\n            if (free.second == totalRange) {\n                freeAddressSpaces_.removeAt(i);\n            }\n            else {\n                freeAddressSpaces_[i].first += totalRange;\n                freeAddressSpaces_[i].second -= totalRange;\n            }\n\n            return true;\n        }\n    }\n\n    // No free block fit; use the next available address\n    outStart = nextAvailableAddress_;\n    outRange = totalRange;\n    usedAddressRanges_.insert(instanceName, qMakePair(outStart, outRange));\n    nextAvailableAddress_ += totalRange;\n\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: InterconnectAddressHelper::releaseEndpointAddress()\n//-----------------------------------------------------------------------------\nvoid InterconnectAddressHelper::releaseEndpointAddress(const QString& instanceName) {\n    if (!usedAddressRanges_.contains(instanceName)) return;\n\n    auto released = usedAddressRanges_.take(instanceName);\n    quint64 releasedStart = released.first;\n    quint64 releasedRange = released.second;\n\n    freeAddressSpaces_.append(qMakePair(releasedStart, releasedRange));\n\n    mergeFreeSpaces();\n}\n\nvoid InterconnectAddressHelper::mergeFreeSpaces() {\n    std::sort(freeAddressSpaces_.begin(), freeAddressSpaces_.end());\n\n    QList<QPair<quint64, quint64>> merged;\n    for (const auto& block : freeAddressSpaces_) {\n        if (merged.isEmpty()) {\n            merged.append(block);\n        }\n        else {\n            QPair<quint64, quint64>& last = merged.last();\n            if (last.first + last.second == block.first) {\n                last.second += block.second;\n            }\n            else {\n                merged.append(block);\n            }\n        }\n    }\n    freeAddressSpaces_ = merged;\n}\n\n//-----------------------------------------------------------------------------\n// Function: InterconnectAddressHelper::initialize()\n//-----------------------------------------------------------------------------\nvoid InterconnectAddressHelper::initialize(QSharedPointer<Component> component) {\n    if (component == currentComponent_ && memoryMapInterface_ && addressBlockInterface_) return;\n    currentComponent_ = component;\n    createValidators(component);\n    createInterfaces(component);\n}\n\n//-----------------------------------------------------------------------------\n// Function: InterconnectAddressHelper::createValidators()\n//-----------------------------------------------------------------------------\nvoid InterconnectAddressHelper::createValidators(QSharedPointer<Component> component) {\n    parameterValidator_ = QSharedPointer<ParameterValidator>::create(\n        expressionParser_, component->getChoices(), component->getRevision());\n\n    enumValidator_ = QSharedPointer<EnumeratedValueValidator>::create(expressionParser_);\n\n    fieldValidator_ = QSharedPointer<FieldValidator>::create(\n        expressionParser_, enumValidator_, parameterValidator_);\n\n    registerValidator_ = QSharedPointer<RegisterValidator>::create(\n        expressionParser_, fieldValidator_, parameterValidator_);\n\n    registerFileValidator_ = QSharedPointer<RegisterFileValidator>::create(\n        expressionParser_, registerValidator_, parameterValidator_, component->getRevision());\n\n    addressBlockValidator_ = QSharedPointer<AddressBlockValidator>::create(\n        expressionParser_, registerValidator_, registerFileValidator_, \n        parameterValidator_, component->getRevision());\n\n    subspaceValidator_ = QSharedPointer<SubspaceMapValidator>::create(\n        expressionParser_, parameterValidator_, component->getRevision());\n\n    memoryMapValidator_ = QSharedPointer<MemoryMapValidator>::create(\n        expressionParser_, addressBlockValidator_, subspaceValidator_, component);\n    memoryMapValidator_->componentChange(component);\n\n    portMapValidator_ = QSharedPointer<PortMapValidator>::create(expressionParser_, component->getPorts(), library_);\n\n    busValidator_ = QSharedPointer<BusInterfaceValidator>::create(expressionParser_,\n        component->getChoices(), component->getViews(), component->getPorts(), component->getAddressSpaces(),\n        component->getMemoryMaps(), component->getBusInterfaces(), component->getFileSets(), component->getRemapStates(),\n        component->getModes(),\n        portMapValidator_, parameterValidator_, library_);\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: InterconnectAddressHelper::createInterfaces()\n//-----------------------------------------------------------------------------\nvoid InterconnectAddressHelper::createInterfaces(QSharedPointer<Component> component) \n{\n    resetInterface_ = new ResetInterface(fieldValidator_, expressionParser_, expressionFormatter_);\n    fieldInterface_ = new FieldInterface(fieldValidator_, expressionParser_, expressionFormatter_, resetInterface_);\n\n    modeRefInterface_ = new ModeReferenceInterface();\n    modeRefInterface_->setComponentModes(component->getModes());\n\n    accessPolicyInterface_ = new AccessPolicyInterface(modeRefInterface_);\n    accessPolicyInterface_->setComponentModes(component->getModes());\n\n    busInfInterface_ = new BusInterfaceInterface(busValidator_, expressionParser_, expressionFormatter_);\n\n    registerInterface_ = new RegisterInterface(\n        registerValidator_, expressionParser_, expressionFormatter_, fieldInterface_, accessPolicyInterface_);\n\n    parameterInterface_ = QSharedPointer<ParametersInterface>::create(\n        parameterValidator_, expressionParser_, expressionFormatter_);\n\n    addressBlockInterface_ = QSharedPointer<AddressBlockInterface>::create(\n        addressBlockValidator_, expressionParser_, expressionFormatter_, \n        busInfInterface_, registerInterface_, parameterInterface_.data());\n\n    memoryMapInterface_ = QSharedPointer<MemoryMapInterface>::create(\n        memoryMapValidator_, expressionParser_, expressionFormatter_);\n    memoryMapInterface_->setAddressBlockInterface(addressBlockInterface_.data());\n}\n"
  },
  {
    "path": "editors/InterconnectGenerator/InterconnectAddressHelper.h",
    "content": "//-----------------------------------------------------------------------------------\n// File: InterconnectAddressHelper.h\n//-----------------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Sampo Suokuisma\n// Date: 05.06.2025\n//\n// Description:\n// Class for calculating start and range values for interconnect endpoint interfaces\n//-----------------------------------------------------------------------------------\n\n#ifndef INTERCONNECTADDRESSHELPER_H\n#define INTERCONNECTADDRESSHELPER_H\n\n#include <QHash>\n#include <QString>\n#include <QSharedPointer>\n\n#include <KactusAPI/include/ExpressionParser.h>\n#include <KactusAPI/include/ExpressionFormatter.h>\n#include <KactusAPI/include/LibraryHandler.h>\n#include <KactusAPI/include/ComponentInstanceInterface.h>\n#include <KactusAPI/include/MemoryMapInterface.h>\n#include <KactusAPI/include/AddressBlockInterface.h>\n#include <KactusAPI/include/ComponentInstanceInterface.h>\n#include <KactusAPI/include/InterconnectionInterface.h>\n#include <KactusAPI/include/AdHocConnectionInterface.h>\n#include <KactusAPI/include/BusInterfaceInterface.h>\n#include <KactusAPI/include/RegisterInterface.h>\n#include <KactusAPI/include/ResetInterface.h>\n#include <KactusAPI/include/FieldInterface.h>\n#include <KactusAPI/include/AccessPolicyInterface.h>\n#include <KactusAPI/include/ModeReferenceInterface.h>\n#include <KactusAPI/include/ParametersInterface.h>\n#include <KactusAPI/include/MessageMediator.h>\n\n#include <IPXACTmodels/common/Document.h>\n#include <IPXACTmodels/Component/Component.h>\n#include <IPXACTmodels/Component/validators/EnumeratedValueValidator.h>\n#include <IPXACTmodels/Component/validators/FieldValidator.h>\n#include <IPXACTmodels/Component/validators/RegisterValidator.h>\n#include <IPXACTmodels/Component/validators/RegisterFileValidator.h>\n#include <IPXACTmodels/Component/validators/AddressBlockValidator.h>\n#include <IPXACTmodels/Component/validators/SubspaceMapValidator.h>\n#include <IPXACTmodels/Component/validators/PortMapValidator.h>\n#include <IPXACTmodels/Component/validators/BusInterfaceValidator.h>\n\n//----------------------------------------------------------------------------------\n//! Class for calculating start and range values for interconnect endpoint interfaces\n//----------------------------------------------------------------------------------\nclass InterconnectAddressHelper {\npublic:\n\n    /*!\n     *  Constructor.\n     *\n     *  @param [in] designVLNV   The VLNV of the design component to inspect.\n     *  @param [in] library      Library interface for resolving IP-XACT documents.\n     *  @param [in] messager     Messaging interface for logging and user feedback.\n     */\n    InterconnectAddressHelper(VLNV designVLNV,\n        LibraryHandler* library, MessageMediator* messager);\n\n    /*!\n     *  Destructor.\n     */\n    virtual ~InterconnectAddressHelper() = default;\n\n    /*!\n     *  Resolve and assign a target address range for a bus interface.\n     *\n     *  @param [in]  instanceName     Instance name of the component.\n     *  @param [in]  interfaceName    Bus interface bound to a memory map.\n     *  @param [out] outStart         Assigned start address (result).\n     *  @param [out] outRange         Size of the assigned address space (result).\n     *\n     *  @return True if an address range could be resolved and assigned.\n     */\n    bool getEndpointAddressRange(const QString& instanceName,\n        const QString& interfaceName,\n        quint64& outStart,\n        quint64& outRange);\n\n    /*!\n     *  Release an assigned address range previously allocated to a component.\n     *\n     *  @param [in] instanceName  The instance whose range to release.\n     */\n    void releaseEndpointAddress(const QString& instanceName);\n\n    /*!\n     *  Reset all allocated and free address tracking state.\n     */\n    void reset();\n\nprivate:\n\n    /*!\n     *  Ensure all interfaces and validators are initialized for the given component.\n     *\n     *  @param [in] component  Component to prepare for address evaluation.\n     */\n    void initialize(QSharedPointer<Component> component);\n\n    /*!\n     *  Create validators used in parsing and validating address-related IP-XACT structures.\n     *\n     *  @param [in] component  Component to base validators on.\n     */\n    void createValidators(QSharedPointer<Component> component);\n\n    /*!\n     *  Create interfaces for interacting with memory maps, blocks, and parameters.\n     *\n     *  @param [in] component  Component to initialize interfaces for.\n     */\n    void createInterfaces(QSharedPointer<Component> component);\n\n    /*!\n     *  Load and return the component bound to the given instance.\n     *\n     *  @param [in] instanceName  Name of the instance to resolve.\n     *\n     *  @return The loaded component, or nullptr on failure.\n     */\n    QSharedPointer<Component> loadComponentForInstance(const QString& instanceName);\n\n    /*!\n     *  Find the memory map bound to a given bus interface name.\n     *\n     *  @param [in] component      The component to search within.\n     *  @param [in] interfaceName  Name of the interface to match.\n     *\n     *  @return Name of the matching memory map, or empty string if none found.\n     */\n    QString findMatchingMemoryMap(QSharedPointer<Component> component, const QString& interfaceName);\n\n    /*!\n     *  Calculate the total range (in address units) required by all address blocks in a memory map.\n     *\n     *  @param [in] component  The component owning the memory map.\n     *  @param [in] mapName    Name of the memory map to analyze.\n     *\n     *  @return Total address range in units.\n     */\n    quint64 calculateTotalRange(QSharedPointer<Component> component, const QString& mapName);\n\n    /*!\n     *  Assign an available address range for a component and record the assignment.\n     *\n     *  @param [in]  instanceName  Name of the instance being assigned.\n     *  @param [in]  totalRange    Number of address units required.\n     *  @param [out] outStart      Start of assigned range.\n     *  @param [out] outRange      Size of assigned range.\n     *\n     *  @return True if assignment succeeded.\n     */\n    bool assignAddressRange(const QString& instanceName, quint64 totalRange,\n        quint64& outStart, quint64& outRange);\n\n    /*!\n     *  Merge overlapping or adjacent free address blocks into a compact list.\n     */\n    void mergeFreeSpaces();\n\n    //-----------------------------------------------------------------------------\n    // Data.\n    //-----------------------------------------------------------------------------\n\n    //! Interface for displaying messages, warnings, or errors to the user.\n    MessageMediator* messager_;\n\n    //! Parses expressions (e.g., widths or addresses) into evaluated forms.\n    QSharedPointer<ExpressionParser> expressionParser_;\n\n    //! Formats expressions into human-readable strings.\n    QSharedPointer<ExpressionFormatter> expressionFormatter_;\n\n    //! Finds parameter values within a component, supports expression evaluation.\n    QSharedPointer<ListParameterFinder> listParameterFinder_;\n\n    //! Access to the IP-XACT library and all registered documents.\n    LibraryHandler* library_;\n\n    //! Validates parameter expressions and types against IP-XACT constraints.\n    QSharedPointer<ParameterValidator> parameterValidator_;\n\n    //! Validates enumerated values within fields and registers.\n    QSharedPointer<EnumeratedValueValidator> enumValidator_;\n\n    //! Validates individual fields within a register.\n    QSharedPointer<FieldValidator> fieldValidator_;\n\n    //! Validates complete registers, including fields and constraints.\n    QSharedPointer<RegisterValidator> registerValidator_;\n\n    //! Validates register files, including nested structures and register sets.\n    QSharedPointer<RegisterFileValidator> registerFileValidator_;\n\n    //! Validates address blocks, their layout, and contents.\n    QSharedPointer<AddressBlockValidator> addressBlockValidator_;\n\n    //! Validates subspace maps and address translations.\n    QSharedPointer<SubspaceMapValidator> subspaceValidator_;\n\n    //! Validates memory maps and their address layout.\n    QSharedPointer<MemoryMapValidator> memoryMapValidator_;\n\n    //! Validates port map bindings and directionality.\n    QSharedPointer<PortMapValidator> portMapValidator_;\n\n    //! Validates bus interfaces including ports, views, and connections.\n    QSharedPointer<BusInterfaceValidator> busValidator_;\n\n    //! Interface for interacting with memory maps.\n    QSharedPointer<MemoryMapInterface> memoryMapInterface_;\n\n    //! Interface for interacting with address blocks.\n    QSharedPointer<AddressBlockInterface> addressBlockInterface_;\n\n    //! Interface for handling reset types and default values.\n    ResetInterface* resetInterface_;\n\n    //! Interface for accessing and editing register fields.\n    FieldInterface* fieldInterface_;\n\n    //! Interface for accessing component mode definitions.\n    ModeReferenceInterface* modeRefInterface_;\n\n    //! Interface for resolving access policies based on active modes.\n    AccessPolicyInterface* accessPolicyInterface_;\n\n    //! Interface for resolving bus interface structure and metadata.\n    BusInterfaceInterface* busInfInterface_;\n\n    //! Interface for interacting with parameters in a component.\n    QSharedPointer<ParametersInterface> parameterInterface_;\n\n    //! Interface for accessing registers and register fields.\n    RegisterInterface* registerInterface_;\n\n    //! Interface for reading and writing system-level interconnect data.\n    InterconnectionInterface* connectionInterface_{ new InterconnectionInterface() };\n\n    //! Interface for accessing ad hoc (non-bus) connections in the design.\n    AdHocConnectionInterface* adhocConnectionInterface_{ new AdHocConnectionInterface() };\n\n    //! Interface for enumerating and accessing component instances.\n    ComponentInstanceInterface* instanceInterface_{ new ComponentInstanceInterface(connectionInterface_, adhocConnectionInterface_) };\n\n    //! The currently loaded component for address evaluation.\n    QSharedPointer<Component> currentComponent_;\n\n    //! Stores address ranges assigned to each component instance.\n    QHash<QString, QPair<quint64, quint64>> usedAddressRanges_;\n\n    //! Monotonically increasing next free address.\n    quint64 nextAvailableAddress_ = 0;\n\n    //! List of reusable free address regions that can be assigned again.\n    QList<QPair<quint64, quint64>> freeAddressSpaces_;\n};\n\n#endif // INTERCONNECTADDRESSHELPER_H\n"
  },
  {
    "path": "editors/InterconnectGenerator/InterconnectDataModel.cpp",
    "content": "#include \"InterconnectDataModel.h\"\n\n#include <IPXACTmodels/Component/AbstractionType.h>\n#include <IPXACTmodels/common/Document.h>\n#include <common/graphicsItems/ComponentItem.h>\n\nusing namespace InterconnectGeneration;\n\n//-----------------------------------------------------------------------------\n// Function: InterconnectDataModel::InterconnectDataModel()\n//-----------------------------------------------------------------------------\nInterconnectDataModel::InterconnectDataModel(DesignWidget* designWidget, LibraryHandler* library, MessageMediator* messager)\n    : designWidget_(designWidget),\n    library_(library),\n    messager_(messager)\n{\n}\n\n//-----------------------------------------------------------------------------\n// Function: InterconnectDataModel::gatherBusAndAbstractionData()\n//-----------------------------------------------------------------------------\nvoid InterconnectDataModel::gatherBusAndAbstractionData() {\n    getBusesFromInstances();\n    getBusesFromTopComponent();\n    initConnectionRules();\n    initAllowedInterfaceModeRules();\n    createInterfaceAdjacencyRules();\n    filterValidAbstractionReferences();\n}\n\n//-----------------------------------------------------------------------------\n// Function: InterconnectDataModel::getValidAbstractionRefs()\n//-----------------------------------------------------------------------------\nQSet<QSharedPointer<ConfigurableVLNVReference>> InterconnectDataModel::getValidAbstractionRefs() const\n{\n    return validAbsRefs_;\n}\n\n//-----------------------------------------------------------------------------\n// Function: InterconnectDataModel::getAllAbstractionRefs()\n//-----------------------------------------------------------------------------\nQSet<QSharedPointer<ConfigurableVLNVReference>> InterconnectDataModel::getAllAbstractionRefs() const\n{\n    return allAbsRefs_;\n}\n\n//-----------------------------------------------------------------------------\n// Function: InterconnectDataModel::getInstanceBusMap()\n//-----------------------------------------------------------------------------\nQHash<QString, QSet<QSharedPointer<BusInterface>>> InterconnectDataModel::getInstanceBusMap() const\n{\n    return instanceBusesHash_;\n}\n\n//-----------------------------------------------------------------------------\n// Function: InterconnectDataModel::getInterfaceAbstractionHash()\n//-----------------------------------------------------------------------------\nQHash<QSharedPointer<BusInterface>, QSet<QString>> InterconnectDataModel::getInterfaceAbstractionHash() const\n{\n    return interfaceAbsDefsHash_;\n}\n\n//-----------------------------------------------------------------------------\n// Function: InterconnectDataModel::getLastInvalidConnectionMessage()\n//-----------------------------------------------------------------------------\nQString InterconnectDataModel::getLastInvalidConnectionMessage() const \n{ \n    return lastInvalidConnectionMessage_; \n}\n\n//-----------------------------------------------------------------------------\n// Function: InterconnectDataModel::interfaceIsTargetAdjacent()\n//-----------------------------------------------------------------------------\nbool InterconnectDataModel::interfaceIsTargetAdjacent(General::InterfaceMode ifMode, InterconnectType icType, EntityType componentType)\n{\n    return targetAdjacencyRules_.contains(InterfaceModeAdjacencyKey{ ifMode, icType, componentType });\n}\n\n//-----------------------------------------------------------------------------\n// Function: InterconnectDataModel::interfaceIsInitiatorAdjacent()\n//-----------------------------------------------------------------------------\nbool InterconnectDataModel::interfaceIsInitiatorAdjacent(General::InterfaceMode ifMode, InterconnectType icType, EntityType componentType)\n{\n    return initiatorAdjacencyRules_.contains(InterfaceModeAdjacencyKey{ ifMode, icType, componentType });\n}\n\n//-----------------------------------------------------------------------------\n// Function: InterconnectDataModel::getBusesFromInstances()\n//-----------------------------------------------------------------------------\nvoid InterconnectDataModel::getBusesFromInstances()\n{\n    QList<ComponentItem*> componentItems = designWidget_->getInstances();\n    for (ComponentItem* componentItem : componentItems)\n    {\n        QString instanceName = componentItem->name();\n        instanceBusesHash_.insert(instanceName, QSet<QSharedPointer<BusInterface>>());\n\n        QList<ConnectionEndpoint*> endpoints = componentItem->getEndpoints();\n        for (ConnectionEndpoint* endpoint : endpoints)\n        {\n            QSharedPointer<BusInterface> bus = endpoint->getBusInterface();\n            if (!bus)\n                continue;\n\n            instanceBusesHash_[instanceName].insert(bus);\n            getAbstractionDefinitions(bus);\n        }\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: InterconnectDataModel::getBusesFromTopComponent()\n//-----------------------------------------------------------------------------\nvoid InterconnectDataModel::getBusesFromTopComponent()\n{\n    QSharedPointer<Component> topComponent = designWidget_->getEditedComponent();\n    if (!topComponent)\n        return;\n\n    QString name = topComponent->getVlnv().getName();\n    QSharedPointer<QList<QSharedPointer<BusInterface>>> buses = topComponent->getBusInterfaces();\n    if (!buses)\n        return;\n\n    instanceBusesHash_.insert(name, QSet<QSharedPointer<BusInterface>>());\n    for (QSharedPointer<BusInterface> bus : *buses)\n    {\n        instanceBusesHash_[name].insert(bus);\n        getAbstractionDefinitions(bus);\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: InterconnectDataModel::getAbstractionDefinitions()\n//-----------------------------------------------------------------------------\nvoid InterconnectDataModel::getAbstractionDefinitions(QSharedPointer<BusInterface> bus)\n{\n    QSharedPointer<QList<QSharedPointer<AbstractionType>>> absTypes = bus->getAbstractionTypes();\n    if (!absTypes)\n        return;\n\n    for (const QSharedPointer<AbstractionType>& type : *absTypes)\n    {\n        if (!type)\n            continue;\n\n        QSharedPointer<ConfigurableVLNVReference> absRef = type->getAbstractionRef();\n        if (!absRef)\n            continue;\n\n        allAbsRefs_.insert(absRef);\n\n        if (!interfaceAbsDefsHash_.contains(bus))\n            interfaceAbsDefsHash_.insert(bus, QSet<QString>());\n\n        interfaceAbsDefsHash_[bus].insert(absRef->getName());\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: InterconnectDataModel::filterValidAbstractionReferences()\n//-----------------------------------------------------------------------------\nvoid InterconnectDataModel::filterValidAbstractionReferences()\n{\n    validAbsRefs_.clear();\n\n    auto absToBuses = buildAbstractionToBusMap();\n    auto modeEntityToBuses = buildModeEntityToBusMap();\n\n    for (const auto& absRef : allAbsRefs_) {\n        if (isAbstractionConnectable(absRef, absToBuses, modeEntityToBuses)) {\n            validAbsRefs_.insert(absRef);\n        }\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: InterconnectDataModel::buildAbstractionToBusMap()\n//-----------------------------------------------------------------------------\nQHash<QString, QSet<QSharedPointer<BusInterface>>> InterconnectDataModel::buildAbstractionToBusMap() const\n{\n    QHash<QString, QSet<QSharedPointer<BusInterface>>> map;\n    for (auto it = interfaceAbsDefsHash_.cbegin(); it != interfaceAbsDefsHash_.cend(); ++it) {\n        const auto& bus = it.key();\n        for (const QString& absName : it.value()) {\n            map[absName].insert(bus);\n        }\n    }\n    return map;\n}\n\n//-----------------------------------------------------------------------------\n// Function: InterconnectDataModel::buildModeEntityToBusMap()\n//-----------------------------------------------------------------------------\nQMultiHash<QPair<General::InterfaceMode, EntityType>, QSharedPointer<BusInterface>>\nInterconnectDataModel::buildModeEntityToBusMap() const\n{\n    QMultiHash<QPair<General::InterfaceMode, EntityType>, QSharedPointer<BusInterface>> map;\n\n    auto topComponentName = designWidget_->getEditedComponent()->getVlnv().getName();\n\n    for (auto it = instanceBusesHash_.cbegin(); it != instanceBusesHash_.cend(); ++it) {\n        EntityType entity = (it.key() == topComponentName)\n            ? EntityType::TopComponent : EntityType::Instance;\n\n        for (const auto& bus : it.value()) {\n            map.insert({ normalizeTo2022(bus->getInterfaceMode()), entity }, bus);\n        }\n    }\n\n    return map;\n}\n\n//-----------------------------------------------------------------------------\n// Function: InterconnectDataModel::isAbstractionConnectable()\n//-----------------------------------------------------------------------------\nbool InterconnectDataModel::isAbstractionConnectable(\n    QSharedPointer<ConfigurableVLNVReference> absRef,\n    const QHash<QString, QSet<QSharedPointer<BusInterface>>>& absToBuses,\n    const QMultiHash<QPair<General::InterfaceMode, EntityType>, QSharedPointer<BusInterface>>& modeEntityToBuses) const\n{\n    const QString absName = absRef->getName();\n    const auto& sourceBuses = absToBuses.value(absName);\n\n    for (const auto& sourceBus : sourceBuses) {\n        General::InterfaceMode srcMode = normalizeTo2022(sourceBus->getInterfaceMode());\n        EntityType srcEntity = getEntityTypeForBus(sourceBus);\n\n        auto rules = getValidConnectionTargets(srcEntity, srcMode, InterconnectType::Bridge);\n        rules += getValidConnectionTargets(srcEntity, srcMode, InterconnectType::Channel);\n\n        for (const ConnectionRule& rule : rules) {\n            auto targets = modeEntityToBuses.values({ rule.targetMode, rule.targetEntity });\n\n            for (const auto& targetBus : targets) {\n                if (!absToBuses.value(absName).contains(targetBus)) continue;\n\n                if (normalizeTo2022(targetBus->getInterfaceMode()) == rule.targetMode) {\n                    return true;\n                }\n            }\n        }\n    }\n\n    return false;\n}\n\n//-----------------------------------------------------------------------------\n// Function: InterconnectDataModel::getEntityTypeForBus()\n//-----------------------------------------------------------------------------\nEntityType InterconnectDataModel::getEntityTypeForBus(const QSharedPointer<BusInterface>& bus) const\n{\n    for (auto it = instanceBusesHash_.cbegin(); it != instanceBusesHash_.cend(); ++it) {\n        if (it.value().contains(bus)) {\n            return (it.key() == designWidget_->getEditedComponent()->getVlnv().getName())\n                ? EntityType::TopComponent : EntityType::Instance;\n        }\n    }\n\n    return EntityType::Instance;\n}\n\n//-----------------------------------------------------------------------------\n// Function: InterconnectDataModel::createInterfaceAdjacencyRules()\n//-----------------------------------------------------------------------------\nvoid InterconnectDataModel::createInterfaceAdjacencyRules()\n{\n    \n    // The following rules define initiator-adjacent combinations for bridges:\n    initiatorAdjacencyRules_.insert(InterfaceModeAdjacencyKey{ General::InterfaceMode::INITIATOR, InterconnectType::Bridge, EntityType::Instance });\n    initiatorAdjacencyRules_.insert(InterfaceModeAdjacencyKey{ General::InterfaceMode::MASTER, InterconnectType::Bridge, EntityType::Instance });\n    initiatorAdjacencyRules_.insert(InterfaceModeAdjacencyKey{ General::InterfaceMode::MIRRORED_TARGET, InterconnectType::Bridge, EntityType::Instance });\n    initiatorAdjacencyRules_.insert(InterfaceModeAdjacencyKey{ General::InterfaceMode::MIRRORED_SLAVE, InterconnectType::Bridge, EntityType::Instance });\n    initiatorAdjacencyRules_.insert(InterfaceModeAdjacencyKey{ General::InterfaceMode::SLAVE, InterconnectType::Bridge, EntityType::TopComponent });\n\n    // The following rules define initiator-adjacent combinations for channels:\n    initiatorAdjacencyRules_.insert(InterfaceModeAdjacencyKey{ General::InterfaceMode::INITIATOR, InterconnectType::Channel, EntityType::Instance });\n    initiatorAdjacencyRules_.insert(InterfaceModeAdjacencyKey{ General::InterfaceMode::MASTER, InterconnectType::Channel, EntityType::Instance });\n    initiatorAdjacencyRules_.insert(InterfaceModeAdjacencyKey{ General::InterfaceMode::MIRRORED_INITIATOR, InterconnectType::Channel, EntityType::TopComponent });\n    initiatorAdjacencyRules_.insert(InterfaceModeAdjacencyKey{ General::InterfaceMode::MIRRORED_MASTER, InterconnectType::Channel, EntityType::TopComponent });\n\n    // The following rules define target-adjacent combinations for bridges:\n    targetAdjacencyRules_.insert(InterfaceModeAdjacencyKey{ General::InterfaceMode::TARGET, InterconnectType::Bridge, EntityType::Instance });\n    targetAdjacencyRules_.insert(InterfaceModeAdjacencyKey{ General::InterfaceMode::SLAVE, InterconnectType::Bridge, EntityType::Instance });\n    targetAdjacencyRules_.insert(InterfaceModeAdjacencyKey{ General::InterfaceMode::MIRRORED_INITIATOR, InterconnectType::Bridge, EntityType::Instance });\n    targetAdjacencyRules_.insert(InterfaceModeAdjacencyKey{ General::InterfaceMode::MIRRORED_MASTER, InterconnectType::Bridge, EntityType::Instance });\n    targetAdjacencyRules_.insert(InterfaceModeAdjacencyKey{ General::InterfaceMode::INITIATOR, InterconnectType::Bridge, EntityType::TopComponent });\n    targetAdjacencyRules_.insert(InterfaceModeAdjacencyKey{ General::InterfaceMode::MASTER, InterconnectType::Bridge, EntityType::TopComponent });\n\n    // The following rules define target-adjacent combinations for channels:\n    targetAdjacencyRules_.insert(InterfaceModeAdjacencyKey{ General::InterfaceMode::TARGET, InterconnectType::Channel, EntityType::Instance });\n    targetAdjacencyRules_.insert(InterfaceModeAdjacencyKey{ General::InterfaceMode::SLAVE, InterconnectType::Channel, EntityType::Instance });\n    targetAdjacencyRules_.insert(InterfaceModeAdjacencyKey{ General::InterfaceMode::MIRRORED_TARGET, InterconnectType::Channel, EntityType::TopComponent });\n    targetAdjacencyRules_.insert(InterfaceModeAdjacencyKey{ General::InterfaceMode::MIRRORED_SLAVE, InterconnectType::Channel, EntityType::TopComponent });\n}\n\n//-----------------------------------------------------------------------------\n// Function: InterconnectDataModel::isModeValidForAllConnections()\n//-----------------------------------------------------------------------------\nbool InterconnectDataModel::isModeValidForAllConnections(\n    const QHash<QString, QList<QSharedPointer<BusInterface>>>& startingPoints,\n    const QHash<QString, QList<QSharedPointer<EndpointData>>>& endpoints,\n    InterconnectType mode) const\n{\n    lastInvalidConnectionMessage_.clear(); // Reset previous message\n\n    auto instanceBusesLookup = createInstanceBusesLookup();\n\n    for (auto it = startingPoints.cbegin(); it != startingPoints.cend(); ++it) {\n        QString initiatorInstance = it.key();\n        EntityType initiatorEntity =\n            (initiatorInstance == designWidget_->getEditedComponent()->getVlnv().getName()) ?\n            EntityType::TopComponent :\n            EntityType::Instance;\n\n        for (const auto& initiatorBus : it.value()) {\n            General::InterfaceMode initiatorMode = normalizeTo2022(initiatorBus->getInterfaceMode());\n            const QList<ConnectionRule> validRules =\n                getValidConnectionTargets(initiatorEntity, initiatorMode, mode);\n\n            for (auto jt = endpoints.cbegin(); jt != endpoints.cend(); ++jt) {\n                QString targetInstance = jt.key();\n                EntityType targetEntity =\n                    (targetInstance == designWidget_->getEditedComponent()->getVlnv().getName()) ?\n                    EntityType::TopComponent :\n                    EntityType::Instance;\n\n                for (const auto& targetData : jt.value()) {\n                    QSharedPointer<BusInterface> targetBus = targetData->endpointBus;\n                    General::InterfaceMode targetMode = normalizeTo2022(targetBus->getInterfaceMode());\n\n                    bool valid = std::any_of(validRules.begin(), validRules.end(),\n                        [&](const ConnectionRule& rule) {\n                            return rule.targetEntity == targetEntity && rule.targetMode == targetMode;\n                        });\n\n                    if (!valid) {\n                        lastInvalidConnectionMessage_ =\n                            QString(\"Can't connect selected interfaces: %1 [%2] -> %3 [%4]\")\n                            .arg(initiatorInstance,\n                                General::interfaceMode2Str(initiatorMode),\n                                targetInstance,\n                                General::interfaceMode2Str(targetMode));\n                        return false;\n                    }\n                }\n            }\n        }\n    }\n\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: InterconnectDataModel::ConnectionKey()\n//-----------------------------------------------------------------------------\nbool ConnectionKey::operator==(const ConnectionKey& other) const {\n    return sourceEntity == other.sourceEntity && sourceMode == other.sourceMode;\n}\n\n//-----------------------------------------------------------------------------\n// Function: InterconnectDataModel::ConnectionKey()\n//-----------------------------------------------------------------------------\nbool ConnectionKey::operator!=(const ConnectionKey& other) const {\n    return !(*this == other);\n}\n\n//-----------------------------------------------------------------------------\n// Function: InterconnectDataModel::getValidConnectionTargets()\n//-----------------------------------------------------------------------------\nQList<ConnectionRule> InterconnectDataModel::getValidConnectionTargets(\n    EntityType sourceEntity,\n    General::InterfaceMode sourceMode,\n    InterconnectType currentInterconnect) const\n{   \n\n    ConnectionKey key{ sourceEntity, sourceMode };\n    QList<ConnectionRule> result;\n\n    if (!connectionRules_.contains(key)) {\n        return result;\n    }\n\n    for (const ConnectionRule& rule : connectionRules_.value(key)) {\n        if (rule.interconnect == currentInterconnect) {\n            result.append(rule);\n        }\n    }\n    return result;\n}\n\n//-----------------------------------------------------------------------------\n// Function: InterconnectDataModel::getConnectableInterfaceTypes()\n//-----------------------------------------------------------------------------\nQSet<General::InterfaceMode> InterconnectDataModel::getConnectableInterfaceTypes(AllowedInterfaceModesKey const& connectionKey) const\n{\n    return allowedInterfaceModeRules_.value(connectionKey);\n}\n\n//-----------------------------------------------------------------------------\n// Function: InterconnectDataModel::hasAnyValidConnection()\n//-----------------------------------------------------------------------------\nbool InterconnectDataModel::hasAnyValidConnection(EntityType sourceEntity, General::InterfaceMode sourceMode) const\n{\n    ConnectionKey key{ sourceEntity, sourceMode };\n\n    return connectionRules_.contains(key) && !connectionRules_.value(key).isEmpty();\n}\n\n//-----------------------------------------------------------------------------\n// Function: InterconnectDataModel::normalizeTo2022()\n//-----------------------------------------------------------------------------\nGeneral::InterfaceMode InterconnectDataModel::normalizeTo2022(General::InterfaceMode mode)\n{\n    switch (mode) {\n    case General::MASTER: return General::INITIATOR;\n    case General::SLAVE:  return General::TARGET;\n    case General::MIRRORED_MASTER: return General::MIRRORED_INITIATOR;\n    case General::MIRRORED_SLAVE:  return General::MIRRORED_TARGET;\n    default: return mode;\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: InterconnectDataModel::initConnectionRules()\n//-----------------------------------------------------------------------------\nvoid InterconnectDataModel::initConnectionRules()\n{\n    using ET = EntityType;\n    using IM = General::InterfaceMode;\n    using IC = InterconnectType;\n\n    connectionRules_.clear();\n\n    // === Instance ===\n    connectionRules_[{ET::Instance, IM::INITIATOR}] = {\n        {ET::Instance, IM::TARGET, IC::Bridge},\n        {ET::Instance, IM::TARGET, IC::Channel},\n        {ET::Instance, IM::MIRRORED_INITIATOR, IC::Bridge},\n        {ET::TopComponent, IM::INITIATOR, IC::Bridge},\n        {ET::TopComponent, IM::MIRRORED_TARGET, IC::Channel}\n    };\n\n    connectionRules_[{ET::Instance, IM::TARGET}] = {\n        {ET::Instance, IM::INITIATOR, IC::Bridge},\n        {ET::Instance, IM::INITIATOR, IC::Channel},\n        {ET::Instance, IM::MIRRORED_TARGET, IC::Bridge},\n        {ET::TopComponent, IM::TARGET, IC::Bridge},\n        {ET::TopComponent, IM::MIRRORED_INITIATOR, IC::Channel}\n    };\n\n    connectionRules_[{ET::Instance, IM::MIRRORED_INITIATOR}] = {\n        {ET::Instance, IM::INITIATOR, IC::Bridge},\n        {ET::Instance, IM::MIRRORED_TARGET, IC::Bridge},\n        {ET::TopComponent, IM::TARGET, IC::Bridge}\n    };\n\n    connectionRules_[{ET::Instance, IM::MIRRORED_TARGET}] = {\n        {ET::Instance, IM::TARGET, IC::Bridge},\n        {ET::Instance, IM::MIRRORED_INITIATOR, IC::Bridge},\n        {ET::TopComponent, IM::TARGET, IC::Bridge}\n    };\n\n    // === TopComponent ===\n    connectionRules_[{ET::TopComponent, IM::INITIATOR}] = {\n        {ET::Instance, IM::INITIATOR, IC::Bridge},\n        {ET::Instance, IM::MIRRORED_TARGET, IC::Bridge},\n        {ET::TopComponent, IM::TARGET, IC::Bridge}\n    };\n\n    connectionRules_[{ET::TopComponent, IM::TARGET}] = {\n        {ET::Instance, IM::TARGET, IC::Bridge},\n        {ET::Instance, IM::MIRRORED_INITIATOR, IC::Bridge},\n        {ET::TopComponent, IM::INITIATOR, IC::Bridge}\n    };\n\n    connectionRules_[{ET::TopComponent, IM::MIRRORED_INITIATOR}] = {\n        {ET::Instance, IM::TARGET, IC::Channel},\n        {ET::TopComponent, IM::MIRRORED_TARGET, IC::Channel}\n    };\n\n    connectionRules_[{ET::TopComponent, IM::MIRRORED_TARGET}] = {\n        {ET::Instance, IM::INITIATOR, IC::Channel},\n        {ET::TopComponent, IM::MIRRORED_INITIATOR, IC::Channel}\n    };\n}\n\n//-----------------------------------------------------------------------------\n// Function: InterconnectDataModel::initAllowedInterfaceModeRules()\n//-----------------------------------------------------------------------------\nvoid InterconnectDataModel::initAllowedInterfaceModeRules()\n{\n    allowedInterfaceModeRules_.clear();\n\n    // Connection rules for editor where all types of interfaces can be selected.\n    // Selectable interfaces depend only on type of interconnect and instance.\n\n\n    // Valid interface types if bridge interconnect and interface is in instance\n    allowedInterfaceModeRules_[{InterconnectType::Bridge, EntityType::Instance}] = {\n        General::InterfaceMode::INITIATOR, General::InterfaceMode::TARGET,\n        General::InterfaceMode::MIRRORED_INITIATOR, General::InterfaceMode::MIRRORED_TARGET,\n        General::InterfaceMode::MASTER, General::InterfaceMode::SLAVE,\n        General::InterfaceMode::MIRRORED_MASTER, General::InterfaceMode::MIRRORED_SLAVE\n    };\n\n    // Valid interface types if bridge interconnect and interface is in top component\n    allowedInterfaceModeRules_[{InterconnectType::Bridge, EntityType::TopComponent}] = {\n        General::InterfaceMode::INITIATOR, General::InterfaceMode::TARGET,\n        General::InterfaceMode::MASTER, General::InterfaceMode::SLAVE\n    };\n\n    // Valid interface types if channel interconnect and interface is in instance\n    allowedInterfaceModeRules_[{InterconnectType::Channel, EntityType::Instance}] = {\n        General::InterfaceMode::INITIATOR, General::InterfaceMode::TARGET,\n        General::InterfaceMode::MASTER, General::InterfaceMode::SLAVE\n    };\n    \n    // Valid interface types if channel interconnect and interface is in top component\n    allowedInterfaceModeRules_[{InterconnectType::Channel, EntityType::TopComponent}] = {\n        General::InterfaceMode::MIRRORED_INITIATOR, General::InterfaceMode::MIRRORED_TARGET,\n        General::InterfaceMode::MIRRORED_MASTER, General::InterfaceMode::MIRRORED_SLAVE\n    };\n}\n\n//-----------------------------------------------------------------------------\n// Function: InterconnectDataModel::createInstanceBusesLookup()\n//-----------------------------------------------------------------------------\nQHash<QString, QHash<QString, QSharedPointer<BusInterface>>> InterconnectDataModel::createInstanceBusesLookup() const\n{\n    QHash<QString, QHash<QString, QSharedPointer<BusInterface>>> lookup;\n\n    for (auto it = instanceBusesHash_.constBegin(); it != instanceBusesHash_.constEnd(); ++it)\n    {\n        QHash<QString, QSharedPointer<BusInterface>> nameToInterfaceMap;\n        for (const QSharedPointer<BusInterface>& busInterface : it.value())\n        {\n            nameToInterfaceMap.insert(busInterface->name(), busInterface);\n        }\n        lookup.insert(it.key(), nameToInterfaceMap);\n    }\n\n    return lookup;\n}\n"
  },
  {
    "path": "editors/InterconnectGenerator/InterconnectDataModel.h",
    "content": "//---------------------------------------------------------------------------\n// File: InterconnectDataModel.h\n//---------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Sampo Suokuisma\n// Date: 05.06.2025\n//\n// Description:\n// Model class for collecting and validating interconnect data from a design.\n//---------------------------------------------------------------------------\n\n\n#ifndef INTERCONNECTDATAMODEL_H\n#define INTERCONNECTDATAMODEL_H\n\n#include <QHash>\n#include <QSet>\n#include <QList>\n#include <QSharedPointer>\n\n#include <IPXACTmodels/Component/BusInterface.h>\n#include <IPXACTmodels/Component/MemoryMap.h>\n#include <IPXACTmodels/common/ConfigurableVLNVReference.h>\n\n#include <KactusAPI/include/LibraryHandler.h>\n#include <KactusAPI/include/InterconnectGenerator.h>\n#include <editors/common/DesignWidget.h>\n\nnamespace InterconnectGeneration\n{\n    /*!\n     *  Types of connection entities in the design.\n     */\n    enum EntityType\n    {\n        Instance,       /*!< A sub-component instance within the design. */\n        TopComponent    /*!< The top-level component of the design. */\n    };\n\n    /*!\n     *  Supported types of interconnect behavior.\n     */\n    enum InterconnectType\n    {\n        Bridge,         /*!< Transparent bridge with no arbitration. */\n        Channel         /*!< Channel with arbitration and address mapping. */\n    };\n\n    /*!\n     *  Key for identifying valid connection rule sources.\n     */\n    struct ConnectionKey\n    {\n        EntityType sourceEntity;             /*!< Source entity type (instance or top). */\n        General::InterfaceMode sourceMode;   /*!< Mode of the source interface. */\n\n        bool operator==(const ConnectionKey& other) const;\n        bool operator!=(const ConnectionKey& other) const;\n    };\n\n    struct AllowedInterfaceModesKey\n    {\n        InterconnectType icType;\n        EntityType entityType;\n\n        bool operator==(const AllowedInterfaceModesKey& other) const\n        {\n            return other.icType == icType && other.entityType == entityType;\n        }\n        bool operator!=(const AllowedInterfaceModesKey& other) const\n        {\n            return !operator==(other);\n        }\n    };\n\n    struct InterfaceModeAdjacencyKey\n    {\n        General::InterfaceMode ifMode;\n        InterconnectType icType;\n        EntityType componentType;\n\n        bool operator==(const InterfaceModeAdjacencyKey& other) const\n        {\n            return other.icType == icType && other.componentType == componentType && other.ifMode == ifMode;\n        }\n        bool operator!=(const InterfaceModeAdjacencyKey& other) const\n        {\n            return !operator==(other);\n        }\n    };\n\n    /*!\n     *  Describes a valid target connection rule.\n     */\n    struct ConnectionRule\n    {\n        EntityType targetEntity;             /*!< Target entity type (instance or top). */\n        General::InterfaceMode targetMode;   /*!< Interface mode for the target. */\n        InterconnectType interconnect;       /*!< Compatible interconnect type. */\n    };\n    \n    // qHash overloads here to link properly\n    \n    /*Added by Teemu Hanhisuanto 10.7.2025 in order to pass the CI tests*/\n    inline size_t qHash(EntityType const& key, size_t seed)\n    {\n        return ::qHash(static_cast<size_t>(key), seed);\n    }\n        \n    /*Added by Teemu Hanhisuanto 10.7.2025 in order to pass the CI tests*/\n    inline size_t qHash(InterconnectType const& key, size_t seed)\n    {\n        return ::qHash(static_cast<std::underlying_type_t<InterconnectType>>(key), seed);\n    }\n        \n        \n    inline size_t qHash(const ConnectionKey& key, size_t seed)\n    {\n        return ::qHash(static_cast<int>(key.sourceEntity), seed) ^\n            ::qHash(static_cast<int>(key.sourceMode), seed << 1);\n    }\n        \n    //-----------------------------------------------------------------------------\n    // Function: qHash()\n    //-----------------------------------------------------------------------------\n    inline size_t qHash(const AllowedInterfaceModesKey& key, size_t seed /*= 0*/)\n    {\n        return ::qHashMulti(seed, static_cast<size_t>(key.entityType), static_cast<size_t>(key.icType));\n    }\n        \n    //-----------------------------------------------------------------------------\n    // Function: qHash()\n    //-----------------------------------------------------------------------------\n    inline size_t qHash(const InterfaceModeAdjacencyKey& key, size_t seed /*= 0*/)\n    {\n        return ::qHashMulti(seed, static_cast<size_t>(key.componentType), static_cast<size_t>(key.icType), static_cast<size_t>(key.ifMode));\n    }\n\n\n    /*!\n     *  Model class for collecting and validating interconnect data from a design.\n     *  Used to determine valid connection rules between bus interfaces in a component hierarchy.\n     */\n    class InterconnectDataModel\n    {\n\n    public:\n        /*!\n         *  Constructor.\n         *\n         *  @param [in] designWidget  Design editor widget (provides model access).\n         *  @param [in] library       Library handler for VLNV models.\n         *  @param [in] messager      Mediator for messaging and errors.\n         */\n        InterconnectDataModel(DesignWidget* designWidget, LibraryHandler* library, MessageMediator* messager);\n\n        /*!\n         *  Destructor.\n         */\n        virtual ~InterconnectDataModel() = default;\n\n        /*!\n         *  Gathers all bus interfaces and abstraction definitions from the design and its instances.\n         */\n        void gatherBusAndAbstractionData();\n\n        /*!\n         *  Returns abstraction references validated as compatible with existing buses.\n         *\n         *  @return Set of compatible abstraction references.\n         */\n        QSet<QSharedPointer<ConfigurableVLNVReference>> getValidAbstractionRefs() const;\n\n        /*!\n         *  Returns all abstraction references found in the design, regardless of validation.\n         *\n         *  @return Set of all abstraction references.\n         */\n        QSet<QSharedPointer<ConfigurableVLNVReference>> getAllAbstractionRefs() const;\n\n        /*!\n         *  Returns map of instances and their associated bus interfaces.\n         *\n         *  @return Hash of instance names to bus interface sets.\n         */\n        QHash<QString, QSet<QSharedPointer<BusInterface>>> getInstanceBusMap() const;\n\n        /*!\n         *  Returns hash of bus interfaces to abstraction names they implement.\n         *\n         *  @return Interface-to-abstraction-name hash.\n         */\n        QHash<QSharedPointer<BusInterface>, QSet<QString>> getInterfaceAbstractionHash() const;\n\n        /*!\n         *  Constructs a lookup table for [instance][interface name] -> BusInterface.\n         *\n         *  @return Nested hash lookup for quick bus interface resolution.\n         */\n        QHash<QString, QHash<QString, QSharedPointer<BusInterface>>> createInstanceBusesLookup() const;\n\n        /*!\n         *  Normalizes a legacy interface mode to IP-XACT 2022 standard.\n         *\n         *  @param [in] mode  Interface mode to normalize.\n         *  @return Standardized interface mode.\n         */\n        static General::InterfaceMode normalizeTo2022(General::InterfaceMode mode);\n\n        /*!\n         *  Returns valid connection targets for a given source configuration.\n         *\n         *  @param [in] sourceEntity         Type of the source entity.\n         *  @param [in] sourceMode           Interface mode of the source.\n         *  @param [in] currentInterconnect  Selected interconnect type (bridge or channel).\n         *  @return List of valid connection rules.\n         */\n        QList<ConnectionRule> getValidConnectionTargets(\n            EntityType sourceEntity,\n            General::InterfaceMode sourceMode,\n            InterconnectType currentInterconnect) const;\n\n        QSet<General::InterfaceMode> getConnectableInterfaceTypes(AllowedInterfaceModesKey const& connectionKey) const;\n\n        /*!\n         *  Verifies whether the provided interconnect mode is valid for all\n         *  current starting point and endpoint combinations.\n         *\n         *  @param [in] startingPoints   Map of instance names to source interfaces.\n         *  @param [in] endpoints        Map of instance names to endpoint data.\n         *  @param [in] mode             Interconnect type to validate.\n         *  @return True if valid for all combinations; otherwise false.\n         */\n        bool isModeValidForAllConnections(\n            const QHash<QString, QList<QSharedPointer<BusInterface>>>& startingPoints,\n            const QHash<QString, QList<QSharedPointer<EndpointData>>>& endpoints,\n            InterconnectType mode) const;\n\n        /*!\n         *  Returns true if the given source bus can connect to any target under any interconnect type.\n         *\n         *  @param [in] sourceEntity     Type of the source entity (Instance or TopComponent).\n         *  @param [in] sourceMode       Normalized interface mode of the source.\n         *  @return True if connectable under any interconnect type.\n         */\n        bool hasAnyValidConnection(EntityType sourceEntity, General::InterfaceMode sourceMode) const;\n\n        /*!\n         *  Returns invalid connection string to show on the dialog.\n         *\n         *  @return True if valid for all combinations; otherwise false.\n         */\n        QString getLastInvalidConnectionMessage() const;\n\n        bool interfaceIsTargetAdjacent(General::InterfaceMode ifMode, InterconnectType icType, EntityType componentType);\n        bool interfaceIsInitiatorAdjacent(General::InterfaceMode ifMode, InterconnectType icType, EntityType componentType);\n\n    private:\n        /*!\n         *  Initialize all valid connection rules.\n         */\n        void initConnectionRules();\n        void initAllowedInterfaceModeRules();\n        /*!\n         *  Collect bus interfaces from all component instances in the design.\n         */\n        void getBusesFromInstances();\n\n        /*!\n         *  Collect bus interfaces from the top-level component.\n         */\n        void getBusesFromTopComponent();\n\n        /*!\n         *  Extract and record abstraction definitions used by the given bus.\n         *\n         *  @param [in] bus  Bus interface to analyze.\n         */\n        void getAbstractionDefinitions(QSharedPointer<BusInterface> bus);\n\n        /*!\n         *  Filters abstraction references to determine which are connectable\n         *  based on current design topology and connection rules.\n         */\n        void filterValidAbstractionReferences();\n\n    private:\n\n        /*!\n         *  Builds a lookup map of abstraction names to the bus interfaces\n         *  that declare them.\n         *\n         *  @return Mapping from abstraction name to set of associated BusInterfaces.\n         */\n        QHash<QString, QSet<QSharedPointer<BusInterface>>> buildAbstractionToBusMap() const;\n\n        /*!\n         *  Constructs a multimap grouping bus interfaces by their mode\n         *  and whether they belong to an instance or the top component.\n         *\n         *  @param [in] instanceBusesHash_   Map of instance names to sets of bus interfaces.\n         *  @param [in] designWidget_        Design context used to resolve top component name.\n         *\n         *  @return Multi-hash mapping (interface mode, entity type) to BusInterfaces.\n         */\n        QMultiHash<QPair<General::InterfaceMode, EntityType>, QSharedPointer<BusInterface>>\n            buildModeEntityToBusMap() const;\n\n        /*!\n         *  Checks if a given abstraction reference can be used to connect\n         *  at least one valid pair of interfaces based on defined rules.\n         *\n         *  @param [in] absRef             Abstraction reference to validate.\n         *  @param [in] absToBuses         Lookup from abstraction name to BusInterfaces.\n         *  @param [in] modeEntityToBuses  Lookup from (mode, entity) to BusInterfaces.\n         *\n         *  @return True if the abstraction is connectable; otherwise false.\n         */\n        bool isAbstractionConnectable(\n            QSharedPointer<ConfigurableVLNVReference> absRef,\n            const QHash<QString, QSet<QSharedPointer<BusInterface>>>& absToBuses,\n            const QMultiHash<QPair<General::InterfaceMode, EntityType>,\n            QSharedPointer<BusInterface>>&modeEntityToBuses) const;\n\n        /*!\n         *  Determines the entity type (Instance or TopComponent) of a given bus interface.\n         *\n         *  @param [in] bus  The BusInterface whose owning entity is to be identified.\n         *  @return EntityType indicating if it's part of the top-level component or an instance.\n         */\n        EntityType getEntityTypeForBus(const QSharedPointer<BusInterface>& bus) const;\n\n        void createInterfaceAdjacencyRules();\n\n        //-----------------------------------------------------------------------------\n        // Data.\n        //-----------------------------------------------------------------------------\n\n        //! Pointer to the design widget (for accessing model and instances).\n        DesignWidget* designWidget_;\n\n        //! Handler to access library models.\n        LibraryHandler* library_;\n\n        //! Interface to show messages or warnings to the user.\n        MessageMediator* messager_;\n\n        //! Component currently edited in the design view.\n        QSharedPointer<Component> currentComponent_;\n\n        //! Set of all abstraction definitions referenced by the design.\n        QSet<QSharedPointer<ConfigurableVLNVReference>> allAbsRefs_;\n\n        //! Set of filtered abstraction references compatible with the selected bus.\n        QSet<QSharedPointer<ConfigurableVLNVReference>> validAbsRefs_;\n\n        //! Hash mapping instance names to their associated bus interfaces.\n        QHash<QString, QSet<QSharedPointer<BusInterface>>> instanceBusesHash_;\n\n        //! Hash of bus interface to the abstraction names it supports.\n        QHash<QSharedPointer<BusInterface>, QSet<QString>> interfaceAbsDefsHash_;\n\n        //! Lookup of all valid connection rules for each source configuration.\n        QHash<ConnectionKey, QList<ConnectionRule>> connectionRules_;\n\n        QHash<AllowedInterfaceModesKey, QSet<General::InterfaceMode> > allowedInterfaceModeRules_;\n\n        QSet<InterfaceModeAdjacencyKey> targetAdjacencyRules_;\n        QSet<InterfaceModeAdjacencyKey> initiatorAdjacencyRules_;\n\n        //! Used to store invalid connection message to display on dialog.\n        mutable QString lastInvalidConnectionMessage_;\n    };\n}\n\n#endif // INTERCONNECTDATAMODEL_H\n"
  },
  {
    "path": "editors/InterconnectGenerator/InterconnectGeneratorDialog.cpp",
    "content": "#include \"InterconnectGeneratorDialog.h\"\n#include \"InterconnectDataModel.h\"\n#include \"InstanceInterfacesEditor.h\"\n\n#include <Plugins/PluginSystem/GeneratorPlugin/AddToFilesetWidget.h>\n\n#include <KactusAPI/KactusAPI.h>\n#include <KactusAPI/include/LibraryInterface.h>\n#include <KactusAPI/include/PluginManager.h>\n#include <KactusAPI/include/CLIGenerator.h>\n#include <KactusAPI/include/IPlugin.h>\n\n#include <editors/common/ExpressionSet.h>\n#include <editors/ComponentEditor/common/ExpressionEditor.h>\n#include <editors/ComponentEditor/parameters/ComponentParameterModel.h>\n\n#include <IPXACTmodels/AbstractionDefinition/WireAbstraction.h>\n#include <editors/ComponentEditor/parameters/ParameterColumns.h>\n\n#include <editors/ComponentEditor/referenceCounter/ParameterReferenceCounter.h>\n\n#include <common/KactusColors.h>\n\n#include <QMessageBox>\n#include <QApplication>\n#include <QFileDialog>\n\nusing namespace InterconnectGeneration;\n\n//-----------------------------------------------------------------------------\n// Function: InterconnectGeneratorDialog::InterconnectGeneratorDialog()\n//-----------------------------------------------------------------------------\nDialog::Dialog(DesignWidget* designWidget, LibraryHandler* library,\n    MessageMediator* messager, QWidget* parent)\n    : QDialog(parent),\n    designWidget_(designWidget),\n    library_(library),\n    messager_(messager),\n    vlnvEditor_(new VLNVEditor(VLNV::BUSDEFINITION, library, this, this)),\n    instancesLayout_(new QVBoxLayout())\n{\n    setMinimumWidth(1200);\n    setMinimumHeight(700);\n\n    designVLNV_ = designWidget->getEditedComponent()->getVlnv().toString(\":\");\n\n    auto parameters = QSharedPointer<QList<QSharedPointer<Parameter>>>::create();\n    auto choices = QSharedPointer<QList<QSharedPointer<Choice>>>::create();\n\n    QSharedPointer<ListParameterFinder> listFinder = QSharedPointer<ListParameterFinder>::create();\n    parameterFinder_ = listFinder;\n    expressionFormatter_ = QSharedPointer<ExpressionFormatter>(new ExpressionFormatter(listFinder));\n\n    parameterCompleterModel_ = new ComponentParameterModel(parameterFinder_, this);\n    parameterCompleterModel_->setExpressionParser(expressionParser_);\n\n    parameterGroupBox_ = new ParameterGroupBox(parameters, choices, listFinder, expressionFormatter_,\n        designWidget_->getEditedComponent()->getRevision(), this);\n    parameterGroupBox_->setTitle(\"Interconnect Component Parameters\");\n\n    paramRefCounter_ = QSharedPointer<ParameterReferenceCounter>(new ParameterReferenceCounter(parameterFinder_));\n    connect(parameterGroupBox_, SIGNAL(increaseReferences(QString)), paramRefCounter_.data(), SLOT(increaseReferenceCount(QString const&)), Qt::UniqueConnection);\n    connect(parameterGroupBox_, SIGNAL(decreaseReferences(QString)), paramRefCounter_.data(), SLOT(decreaseReferenceCount(QString const&)), Qt::UniqueConnection);\n    connect(parameterGroupBox_,\n        SIGNAL(recalculateReferencesToParameters(QVector<QString> const&, AbstractParameterInterface*)),\n        paramRefCounter_.data(),\n        SLOT(recalculateReferencesToParameters(QVector<QString> const&, AbstractParameterInterface*)),\n        Qt::UniqueConnection);\n\n    dataModel_ = QSharedPointer<InterconnectDataModel>::create(designWidget_, library_, messager_);\n    dataModel_->gatherBusAndAbstractionData();\n\n    //addressHelper_ = QSharedPointer<InterconnectAddressHelper>::create(\n    //    designWidget->getEditedComponent()->getVlnv(), \n    //    library_, messager_);\n\n    filteredAbsRefs_ = dataModel_->getValidAbstractionRefs();\n    if (filteredAbsRefs_.isEmpty()) {\n        messager_->showMessage(\"empty\");\n    }\n    allAbsRefs_ = dataModel_->getAllAbstractionRefs();\n    instanceBusesHash_ = dataModel_->getInstanceBusMap();\n    interfaceAbsDefsHash_ = dataModel_->getInterfaceAbstractionHash();\n    busLookUp_ = dataModel_->createInstanceBusesLookup();\n\n    connect(vlnvEditor_, SIGNAL(contentChanged()), this, SLOT(onVlnvChanged()), Qt::UniqueConnection);\n\n    setUpLayout();\n}\n\n//-----------------------------------------------------------------------------\n// Function: InterconnectGeneratorDialog::~InterconnectGeneratorDialog()\n//-----------------------------------------------------------------------------\nDialog::~Dialog()\n{\n    if (config_)\n        delete config_;\n}\n\n//-----------------------------------------------------------------------------\n// Function: InterconnectGeneratorDialog::getConfig()\n//-----------------------------------------------------------------------------\nConfigStruct* Dialog::getConfig()  const\n{\n    return config_;\n}\n\n//-----------------------------------------------------------------------------\n// Function: InterconnectGeneratorDialog::getSelectedInitiators()\n//-----------------------------------------------------------------------------\nQHash<QString, QList<QSharedPointer<BusInterface>>> Dialog::getSelectedStartingPoints() const\n{\n    return selectedStartingPoints_;\n}\n\n//-----------------------------------------------------------------------------\n// Function: InterconnectGeneratorDialog::getSelectedTargets()\n//-----------------------------------------------------------------------------\nQHash<QString, QList<QSharedPointer<EndpointData>>> Dialog::getSelectedEndpoints() const\n{\n    return selectedEndpoints_;\n}\n\n//-----------------------------------------------------------------------------\n// Function: InterconnectGeneratorDialog::rtlGenerationSelected()\n//-----------------------------------------------------------------------------\nbool Dialog::rtlGenerationSelected()\n{\n    return rtlGenerationGroup_->isChecked();\n}\n\n//-----------------------------------------------------------------------------\n// Function: InterconnectGeneratorDialog::populateParameters()\n//-----------------------------------------------------------------------------\nvoid Dialog::populateParameters()\n{\n    QSharedPointer<ConfigurableVLNVReference> absRef;\n    for (auto& ref : filteredAbsRefs_) {\n        if (ref->getName() == absDefCombo_->currentText()) {\n            absRef = ref;\n        }\n    }\n    if (!absRef) \n    {\n        return;\n    }\n    QSharedPointer<Document> libComp = library_->getModel(*absRef);\n    QSharedPointer<AbstractionDefinition> absDef = libComp.staticCast<AbstractionDefinition>();\n\n    interconnectParams_ = QSharedPointer<QList<QSharedPointer<Parameter>>>::create();\n    for (const auto& param : *absDef->getParameters()) {\n        auto copiedParam = QSharedPointer<Parameter>::create(*param);\n        copiedParam->setUsageCount(0);\n        interconnectParams_->append(copiedParam);\n    }\n\n    auto copiedChoices = QSharedPointer<QList<QSharedPointer<Choice>>>::create();\n    for (const auto& choice : *absDef->getChoices()) {\n        copiedChoices->append(QSharedPointer<Choice>::create(*choice));\n    }\n\n    parameterGroupBox_->setNewParameters(interconnectParams_, copiedChoices, absDef->getRevision());\n\n    addrWidthParamName_ = QString();\n    dataWidthParamName_ = QString();\n\n    // If AXI or OBI selected, width values must be set to parameters\n    if (rtlCanBeGenerated())\n    {\n        // Find parameters corresponding to addr and data widths\n        findWidthParameters();\n\n        // Create parameters for widths with empty values, if not found\n        bool hasDefaultAddrWidhtParam = std::find_if(interconnectParams_->cbegin(), interconnectParams_->cend(), [](QSharedPointer<Parameter> param)\n            {\n                return param->name().compare(\"ADDR_WIDTH\") == 0;\n            }) != interconnectParams_->cend();\n\n        bool hasDefaultDataWidhtParam = std::find_if(interconnectParams_->cbegin(), interconnectParams_->cend(), [](QSharedPointer<Parameter> param)\n            {\n                return param->name().compare(\"DATA_WIDTH\") == 0;\n            }) != interconnectParams_->cend();\n\n        if (addrWidthParamName_.isEmpty())\n        {\n            addrWidthParamName_ = QStringLiteral(\"ADDR_WIDTH\");\n            if (!hasDefaultAddrWidhtParam)\n            {\n                parameterGroupBox_->addParameter(addrWidthParamName_);\n            }\n        }\n\n        if (dataWidthParamName_.isEmpty())\n        {\n            dataWidthParamName_ = QStringLiteral(\"DATA_WIDTH\");\n            if (!hasDefaultDataWidhtParam)\n            {\n                parameterGroupBox_->addParameter(dataWidthParamName_);\n            }\n        }\n\n        parameterGroupBox_->refresh();\n\n        // partially lock width parameters (only value editable)\n        for (auto i = 0; i < ParameterColumns::COLUMN_COUNT; ++i)\n        {\n            if (i != ParameterColumns::VALUE)\n            {\n                parameterGroupBox_->lockParameterColumn(addrWidthParamName_, static_cast<ParameterColumns::columns>(i));\n                parameterGroupBox_->lockParameterColumn(dataWidthParamName_, static_cast<ParameterColumns::columns>(i));\n            }\n        }\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: InterconnectGeneratorDialog::addNewInstance()\n//-----------------------------------------------------------------------------\nvoid Dialog::addNewInstance()\n{\n    // create instance editor\n    auto newInterfacesEditor = new InstanceInterfacesEditor(ExpressionSet{parameterFinder_, expressionParser_, expressionFormatter_}, \n        parameterCompleterModel_, designWidget_->getEditedComponent()->getRevision());\n\n    connect(newInterfacesEditor, SIGNAL(instanceRemoved()), this, SLOT(onInstanceRemoved()), Qt::UniqueConnection);\n\n    // Add new instance to the front\n    instancesLayout_->insertWidget(0, newInterfacesEditor);\n    instanceEditors_.insert(newInterfacesEditor);\n\n    // Update available instances of new editor\n    newInterfacesEditor->updateAvailableInstances(availableInstances_);\n    \n    // Remove item currently selected in new editor from available instances, then update the rest of the editors,\n    // ignoring the new editor\n    availableInstances_.remove(newInterfacesEditor->getSelectedInstance());\n    updateAvailableInstances();\n\n    connect(newInterfacesEditor, SIGNAL(instanceSelected(QString const&, QString const&)), this, SLOT(onInstanceSelected(QString const&, QString const&)), Qt::UniqueConnection);\n    updateAvailableInstanceInterfaces(newInterfacesEditor, newInterfacesEditor->getSelectedInstance());\n\n    updateAddInstanceButtonStatus();\n}\n\n//-----------------------------------------------------------------------------\n// Function: InterconnectGeneratorDialog::onInterconnectModeChanged()\n//-----------------------------------------------------------------------------\nvoid Dialog::onInterconnectSelectorToggled(bool checked)\n{\n    if (!checked)\n    {\n        return;\n    }\n\n    // Clear already selected instances and interfaces, if permission is given. Otherwise set selection back to previous interface mode.\n    if (hasSelectedInstances())\n    {\n        auto response = QMessageBox::warning(this, tr(\"Change interconnect mode\"), \n            tr(\"All existing interface selections will be removed if interface mode is changed. Continue?\"), \n            QMessageBox::Yes | QMessageBox::No, QMessageBox::No);\n\n        if (response == QMessageBox::No)\n        {\n            if (static_cast<QRadioButton*>(sender()) == bridgeButton_)\n            {\n                disconnect(channelButton_, SIGNAL(toggled(bool)), this, SLOT(onInterconnectSelectorToggled(bool)));\n                channelButton_->setChecked(true);\n                connect(channelButton_, SIGNAL(toggled(bool)), this, SLOT(onInterconnectSelectorToggled(bool)), Qt::UniqueConnection);\n            }\n            else\n            {\n                disconnect(bridgeButton_, SIGNAL(toggled(bool)), this, SLOT(onInterconnectSelectorToggled(bool)));\n                bridgeButton_->setChecked(true);\n                connect(bridgeButton_, SIGNAL(toggled(bool)), this, SLOT(onInterconnectSelectorToggled(bool)), Qt::UniqueConnection);\n            }\n\n            return;\n        }\n\n        clearInstanceSelections();\n    }\n\n    if (sender() == bridgeButton_)\n    {\n        isChannel_ = false;\n    }\n    else if (sender() == channelButton_)\n    {\n        isChannel_ = true;\n    }\n\n    filterAvailableInstancesByAbsDef();\n    updateAddInstanceButtonStatus();\n}\n\nInterconnectGeneration::InterconnectType Dialog::getSelectedInterconnectType() const\n{\n    return isChannel_ ? InterconnectGeneration::InterconnectType::Channel\n        : InterconnectGeneration::InterconnectType::Bridge;\n}\n\n//-----------------------------------------------------------------------------\n// Function: InterconnectGeneratorDialog::onInstanceSelected()\n//-----------------------------------------------------------------------------\nvoid Dialog::onInstanceSelected(QString const& newInstanceName, QString const& oldInstanceName)\n{\n    if (auto interfaceEditor = dynamic_cast<InstanceInterfacesEditor*>(sender()))\n    {\n        // Clear old interface selections and add new interface options\n\n        interfaceEditor->clearInterfaceItems();\n\n        // Figure out which interfaces are valid options to choose from the selected instance based on selected \n        // interconnect type (bridge or channel) and type of instance (design instance or top component)\n        updateAvailableInstanceInterfaces(interfaceEditor, newInstanceName);\n\n        if (newInstanceName.compare(oldInstanceName) != 0)\n        {\n            // update available instances if new selection is different from old\n            availableInstances_.remove(newInstanceName);\n\n            if (!oldInstanceName.isEmpty())\n            {\n                availableInstances_.insert(oldInstanceName);\n            }\n        }\n    }\n\n    updateAvailableInstances();\n}\n\n//-----------------------------------------------------------------------------\n// Function: InterconnectGeneratorDialog::onInstanceRemoved()\n//-----------------------------------------------------------------------------\nvoid Dialog::onInstanceRemoved()\n{\n    auto interfacesEditor = dynamic_cast<InstanceInterfacesEditor*>(sender());\n    Q_ASSERT_X(interfacesEditor, \"InterconnectGeneratorDialog::onInstanceRemoved\", \"Invalid sender connected to slot\");\n\n    if (!interfacesEditor)\n    {\n        return;\n    }\n    \n    availableInstances_.insert(interfacesEditor->getSelectedInstance());\n\n    instancesLayout_->removeWidget(interfacesEditor);\n    instanceEditors_.remove(interfacesEditor);\n    interfacesEditor->deleteLater();\n\n    // Need to update available instances of added combo boxes\n    updateAvailableInstances();\n    updateAddInstanceButtonStatus();\n}\n\n//-----------------------------------------------------------------------------\n// Function: InterconnectGeneratorDialog::filterAvailableInstancesByAbsDef()\n//-----------------------------------------------------------------------------\nvoid Dialog::filterAvailableInstancesByAbsDef()\n{\n    auto currentAbsDef = absDefCombo_->currentText();\n    QSet<QString> newAvailableInstances;\n\n    for (const QString& instanceName : instanceBusesHash_.keys())\n    {\n        // Take into account that interconnect type limits possible instances\n        // AKA for bridge interconnect only instances with interfaces that can be connected to bridge should be listed\n        auto allowedInterfaceTypes = getAllowedInterfaceModes(instanceName);\n\n        for (auto const& bus : instanceBusesHash_.value(instanceName))\n        {\n            if (interfaceAbsDefsHash_.contains(bus) && interfaceAbsDefsHash_.value(bus).contains(currentAbsDef)\n                && allowedInterfaceTypes.contains(bus->getInterfaceMode()))\n            {\n                newAvailableInstances.insert(instanceName);\n                break;\n            }\n        }\n    }\n\n    availableInstances_ = newAvailableInstances;\n}\n\n//-----------------------------------------------------------------------------\n// Function: InterconnectGeneratorDialog::updateAvailableInstances()\n//-----------------------------------------------------------------------------\nvoid Dialog::updateAvailableInstances()\n{\n    // Update available instances of instance interface editor combo boxes\n    for (auto const& singleEditor : instanceEditors_)\n    {\n        disconnect(singleEditor, SIGNAL(instanceSelected(QString const&, QString const&)), this, SLOT(onInstanceSelected(QString const&, QString const&)));\n        singleEditor->updateAvailableInstances(availableInstances_);\n        connect(singleEditor, SIGNAL(instanceSelected(QString const&, QString const&)), this, SLOT(onInstanceSelected(QString const&, QString const&)), Qt::UniqueConnection);\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: InterconnectGeneratorDialog::updateAllowedInstanceInterfaces()\n//-----------------------------------------------------------------------------\nvoid Dialog::updateAvailableInstanceInterfaces(InstanceInterfacesEditor* interfacesEditor, QString const& selectedInstance)\n{\n    // Get component interfaces\n    auto const& instanceInterfaces = instanceBusesHash_.value(selectedInstance);\n\n    if (instanceInterfaces.isEmpty())\n    {\n        return;\n    }\n\n    QList<QPair<QString, bool> > interfacesToAdd;\n\n    auto allowedInterfaceTypes = getAllowedInterfaceModes(selectedInstance);\n    auto currentAbsDef = absDefCombo_->currentText();\n\n    bool isTopComponent = instanceIsTopComponent(selectedInstance);\n\n    QList<InterfaceEnumEditor::InterfaceInput> targetsToAdd;\n    QList<InterfaceEnumEditor::InterfaceInput> initiatorsToAdd;\n    QList<InterfaceEnumEditor::InterfaceInput> mirroredTargetsToAdd;\n    QList<InterfaceEnumEditor::InterfaceInput> mirroredInitiatorsToAdd;\n\n    for (auto const& busInterface : instanceInterfaces)\n    {\n        auto busAbsTypes = busInterface->getAbstractionTypes();\n        auto interfaceMode = busInterface->getInterfaceMode();\n        bool interfaceModeAllowed = allowedInterfaceTypes.contains(interfaceMode);\n        bool busHasCompatibleAbsType = interfaceAbsDefsHash_.value(busInterface).contains(currentAbsDef);\n\n        if (interfaceModeAllowed && busHasCompatibleAbsType)\n        {\n            // Divide interfaces in groups based on 1) type and 2) if they are target- or initiator adjacent\n            // (target adjacent = start and range can be set)\n            if (isChannel_)\n            {\n                // E.g. Target is always target-adjacent when used with channel\n                // (because function getAllowedInterfaceTypes() filters top component targets)\n                if (interfaceMode == General::InterfaceMode::TARGET || interfaceMode == General::InterfaceMode::SLAVE)\n                {\n                    targetsToAdd.append(InterfaceEnumEditor::InterfaceInput{ busInterface->name(), true });\n                }\n                else if (interfaceMode == General::InterfaceMode::INITIATOR || interfaceMode == General::InterfaceMode::MASTER)\n                {\n                    initiatorsToAdd.append(InterfaceEnumEditor::InterfaceInput{ busInterface->name(), false });\n                }\n                else if (interfaceMode == General::InterfaceMode::MIRRORED_TARGET || interfaceMode == General::InterfaceMode::MIRRORED_SLAVE)\n                {\n                    mirroredTargetsToAdd.append(InterfaceEnumEditor::InterfaceInput{ busInterface->name(), true });\n                }\n                else if (interfaceMode == General::InterfaceMode::MIRRORED_INITIATOR || interfaceMode == General::InterfaceMode::MIRRORED_MASTER)\n                {\n                    mirroredInitiatorsToAdd.append(InterfaceEnumEditor::InterfaceInput{ busInterface->name(), false });\n                }\n            }\n            else\n            {\n                if (interfaceMode == General::InterfaceMode::TARGET || interfaceMode == General::InterfaceMode::SLAVE)\n                {\n                    // Both top component and instance targets can be connected when using bridge, target is target-adjacent\n                    // if it is an instance interface.\n                    targetsToAdd.append(InterfaceEnumEditor::InterfaceInput{ busInterface->name(), isTopComponent == false });\n                }\n                else if (interfaceMode == General::InterfaceMode::INITIATOR || interfaceMode == General::InterfaceMode::MASTER)\n                {\n                    // Both top component and instance initiators can be connected when using bridge. Initiator is target-adjacent,\n                    // if it is a top component interface.\n                    initiatorsToAdd.append(InterfaceEnumEditor::InterfaceInput{ busInterface->name(), isTopComponent == true });\n                }\n                else if (interfaceMode == General::InterfaceMode::MIRRORED_TARGET || interfaceMode == General::InterfaceMode::MIRRORED_SLAVE)\n                {\n                    mirroredTargetsToAdd.append(InterfaceEnumEditor::InterfaceInput{ busInterface->name(), false });\n                }\n                else if (interfaceMode == General::InterfaceMode::MIRRORED_INITIATOR || interfaceMode == General::InterfaceMode::MIRRORED_MASTER)\n                {\n                    mirroredInitiatorsToAdd.append(InterfaceEnumEditor::InterfaceInput{ busInterface->name(), true });\n                }\n            }\n        }\n    }\n\n    interfacesEditor->addInterfaceItems(initiatorsToAdd, General::InterfaceMode::INITIATOR);\n    interfacesEditor->addInterfaceItems(mirroredInitiatorsToAdd, General::InterfaceMode::MIRRORED_INITIATOR);\n    interfacesEditor->addInterfaceItems(targetsToAdd, General::InterfaceMode::TARGET);\n    interfacesEditor->addInterfaceItems(mirroredTargetsToAdd, General::InterfaceMode::MIRRORED_TARGET);\n\n    interfacesEditor->createInterfaceItems(isChannel_);\n}\n\n//-----------------------------------------------------------------------------\n// Function: InterconnectGeneratorDialog::updateAddInstanceButtonStatus()\n//-----------------------------------------------------------------------------\nvoid Dialog::updateAddInstanceButtonStatus()\n{\n    addInstanceButton_->setEnabled(availableInstances_.isEmpty() == false);\n}\n\n//-----------------------------------------------------------------------------\n// Function: InterconnectGeneratorDialog::hasSelectedInstances()\n//-----------------------------------------------------------------------------\nbool Dialog::hasSelectedInstances()\n{\n    return instanceEditors_.size() > 0;\n}\n\n//-----------------------------------------------------------------------------\n// Function: InterconnectGeneratorDialog::getAllowedInterfaceModes()\n//-----------------------------------------------------------------------------\nQSet<General::InterfaceMode> Dialog::getAllowedInterfaceModes(QString const& selectedInstance)\n{\n    // Need to figure out if selected instance is top component or regular instance\n    auto isTopComponent = instanceIsTopComponent(selectedInstance);\n\n    InterconnectGeneration::EntityType instanceType = isTopComponent\n        ? InterconnectGeneration::EntityType::TopComponent\n        : InterconnectGeneration::EntityType::Instance;\n\n    InterconnectGeneration::AllowedInterfaceModesKey allowedInterfacesKey;\n\n    // Allowed interfaces when channel is selected:\n    // Top component: mirrored target/slave & mirrored initiator/master\n    // Instance: initiator/master, target/slave, mirrored initiator/master, mirrored target/slave\n    if (isChannel_)\n    {\n        allowedInterfacesKey = {\n            InterconnectGeneration::InterconnectType::Channel,\n            instanceType\n        };\n    }\n    else\n    {\n        allowedInterfacesKey = {\n            InterconnectGeneration::InterconnectType::Bridge,\n            instanceType\n        };\n    }\n\n    return dataModel_->getConnectableInterfaceTypes(allowedInterfacesKey);\n}\n\n//-----------------------------------------------------------------------------\n// Function: InterconnectGeneratorDialog::interfaceSelectionsAreValid()\n//-----------------------------------------------------------------------------\nbool Dialog::interfaceSelectionsAreValid(QString& errorMsg)\n{\n    auto isStd22 = designWidget_->getEditedComponent()->getRevision() == Document::Revision::Std22;\n\n    QString initStr = isStd22 ? QStringLiteral(\"initiator\") : QStringLiteral(\"master\");\n    QString targetStr = isStd22 ? QStringLiteral(\"target\") : QStringLiteral(\"slave\");\n\n    if (selectedEndpoints_.isEmpty() || selectedStartingPoints_.isEmpty())\n    {\n        if (isChannel_)\n        {\n            errorMsg = tr(\"Selections must contain the following:\\n\"\n                          \"1. At least one instance %1 or design component mirrored %1\\n\"\n                          \"2. At least one instance %2 or design component mirrored %2\")\n                .arg(initStr).arg(targetStr);\n        }\n        else\n        {\n            errorMsg = tr(\"Selections must contain the following:\\n\"\n                          \"1. At least one instance %1 or design component %2\\n\"\n                          \"2. At least one instance %2 or mirrored %1 or design component %1\")\n                .arg(initStr).arg(targetStr);\n        }\n\n        return false;\n    }\n\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: InterconnectGeneratorDialog::instanceIsTopComponent()\n//-----------------------------------------------------------------------------\nbool Dialog::instanceIsTopComponent(QString const& instanceName)\n{\n    return designWidget_->getEditedComponent()->getVlnv().getName().compare(instanceName) == 0;\n}\n\n//-----------------------------------------------------------------------------\n// Function: InterconnectGeneratorDialog::clearInitiatorAndTargetLists()\n//-----------------------------------------------------------------------------\nvoid Dialog::clearInstanceSelections()\n{\n    QLayoutItem* item;\n\n    // Temporarily remove condenser item\n    auto condenserItem = instancesLayout_->takeAt(instancesLayout_->count() - 1);\n\n    while ((item = instancesLayout_->takeAt(0)) != nullptr) {\n        if (item->widget()) {\n            item->widget()->deleteLater();\n        }\n        delete item;\n    }\n    instanceEditors_.clear();\n\n    // Add condenser item and stretch back\n    instancesLayout_->addItem(condenserItem);\n    instancesLayout_->addStretch(1);\n\n    instancesLayout_->update();\n}\n\n//-----------------------------------------------------------------------------\n// Function: InterconnectGeneratorDialog::createTopConfigSection()\n//-----------------------------------------------------------------------------\nQWidget* Dialog::createTopConfigSection() \n{\n    QGroupBox* configGroup = new QGroupBox(tr(\"Interconnect Component Configuration\"), this);\n    QFormLayout* formLayout = new QFormLayout();\n\n    absDefCombo_ = new InstanceComboBox(this);\n    clockCombo_ = new InstanceComboBox(this);\n    resetCombo_ = new InstanceComboBox(this);\n    clockCombo_->setEnabled(false);\n    resetCombo_->setEnabled(false);\n\n    clockCheckBox_ = new QCheckBox(tr(\"Enable Clock\"), this);\n    resetCheckBox_ = new QCheckBox(tr(\"Enable Reset\"), this);\n    clockCheckBox_->setChecked(false);\n    resetCheckBox_->setChecked(false);\n\n    for (QSharedPointer<ConfigurableVLNVReference> ref : filteredAbsRefs_) {\n        QString name = ref->getName();\n        if (absDefCombo_->findText(name) != -1) continue;\n        absDefCombo_->addItem(name);\n    }\n\n    for (QSharedPointer<ConfigurableVLNVReference> ref : allAbsRefs_) {\n        QString name = ref->getName();\n        if (clockCombo_->findText(name) != -1) continue;\n\n        clockCombo_->addItem(name);\n        resetCombo_->addItem(name);\n    }\n\n    previousAbsDefIndex_ = absDefCombo_->currentIndex();\n    populateParameters();\n    filterAvailableInstancesByAbsDef();\n\n    connect(absDefCombo_, SIGNAL(currentIndexChanged(int)), SLOT(onAbsDefChanged(int)), Qt::UniqueConnection);\n\n    connect(absDefCombo_, &QComboBox::activated, this, [this]() {\n        previousAbsDefIndex_ = absDefCombo_->currentIndex();\n        });\n\n    connect(clockCheckBox_, &QCheckBox::stateChanged, this, [this](int state) {\n        clockCombo_->setEnabled(state == Qt::Checked);\n        });\n    connect(resetCheckBox_, &QCheckBox::stateChanged, this, [this](int state) {\n        resetCombo_->setEnabled(state == Qt::Checked);\n        });\n\n    formLayout->addRow(tr(\"Abstraction Definition:\"), absDefCombo_);\n    formLayout->addRow(clockCheckBox_, clockCombo_);\n    formLayout->addRow(resetCheckBox_, resetCombo_);\n\n    configGroup->setLayout(formLayout);\n\n    QWidget* container = new QWidget();\n    QHBoxLayout* topRowLayout = new QHBoxLayout(container);\n    vlnvEditor_->setTitle(\"Interconnect Component VLNV\");\n    topRowLayout->addWidget(vlnvEditor_, 1);\n    topRowLayout->addWidget(configGroup, 1);\n\n    return container;\n}\n\n//-----------------------------------------------------------------------------\n// Function: InterconnectGeneratorDialog::createInstancesSection()\n//-----------------------------------------------------------------------------\nQGroupBox* Dialog::createInstancesSection()\n{\n    connect(addInstanceButton_, SIGNAL(clicked()), this, SLOT(addNewInstance()));\n\n    instancesLayout_->setAlignment(Qt::AlignTop);\n    QWidget* scrollWidget = new QWidget();\n    scrollWidget->setLayout(instancesLayout_);\n\n    // Condenser item and stretch to fill space at bottom of instances list\n    QWidget* layoutCondenser = new QWidget();\n    layoutCondenser->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Expanding);\n    instancesLayout_->addWidget(layoutCondenser);\n    instancesLayout_->addStretch(1);\n\n    QScrollArea* scrollArea = new QScrollArea();\n    scrollArea->setWidget(scrollWidget);\n    scrollArea->setWidgetResizable(true);\n\n    QVBoxLayout* sectionLayout = new QVBoxLayout();\n    sectionLayout->addWidget(addInstanceButton_);\n    sectionLayout->addWidget(scrollArea);\n\n    QGroupBox* groupBox = new QGroupBox(tr(\"Instances to connect\"), this);\n    groupBox->setLayout(sectionLayout);\n    return groupBox;\n}\n\n//-----------------------------------------------------------------------------\n// Function: InterconnectGeneratorDialog::createInterconnectModeSelector()\n//-----------------------------------------------------------------------------\nQWidget* Dialog::createInterconnectModeSelector() \n{\n    QGroupBox* modeGroup = new QGroupBox(tr(\"Interconnect Mode\"), this);\n    QHBoxLayout* modeLayout = new QHBoxLayout(modeGroup);\n\n    bridgeButton_ = new QRadioButton(tr(\"Transparent Bridge\"), this);\n    channelButton_ = new QRadioButton(tr(\"Channel\"), this);\n    bridgeButton_->setChecked(true);\n\n    modeLayout->addWidget(bridgeButton_);\n    modeLayout->addWidget(channelButton_);\n    modeGroup->setLayout(modeLayout);\n\n    connect(bridgeButton_, SIGNAL(toggled(bool)), this, SLOT(onInterconnectSelectorToggled(bool)), Qt::UniqueConnection);\n    connect(channelButton_, SIGNAL(toggled(bool)), this, SLOT(onInterconnectSelectorToggled(bool)), Qt::UniqueConnection);\n\n    return modeGroup;\n}\n\n//-----------------------------------------------------------------------------\n// Function: InterconnectGeneratorDialog::createRtlOutputSection()\n//-----------------------------------------------------------------------------\nQWidget* Dialog::createRtlOutputSection()\n{\n    rtlGenerationGroup_ = new QGroupBox(tr(\"Generate RTL (for compatible abstraction definitions)\"), this);\n    rtlGenerationGroup_->setCheckable(true);\n    rtlGenerationGroup_->setToolTip(\"RTL generation support is currently only provided for TUNI-authored abstractions for OBI and AXI4/AXI4LITE.\");\n    rtlGenerationGroup_->setChecked(false);\n\n    connect(rtlGenerationGroup_, SIGNAL(toggled(bool)), this, SLOT(onRtlGenerationToggled(bool)), Qt::UniqueConnection);\n\n    // Set the style of disabled group box text to match other disabled widgets\n    QPalette palette = QApplication::palette();\n    QColor color = palette.color(QPalette::Disabled, QPalette::Text);\n    rtlGenerationGroup_->setStyleSheet(\"QGroupBox::title::disabled { color: \" + color.name() + \" }\");\n\n    auto layout = new QVBoxLayout();\n    rtlGenerationGroup_->setLayout(layout);\n    \n    // Add file output stuff\n    addToFileSet_ = new AddToFilesetWidget(this);\n    \n    // TODO add save location customization later\n    //auto fileSaveLayout = new QHBoxLayout();\n    //auto saveLocationLabel = new QLabel(\"RTL file output location:\");\n    //rtlSaveLocationEdit_ = new QLineEdit(this);\n    //auto browseButton = new QPushButton(QIcon(\":/icons/common/graphics/opened-folder.png\"), QStringLiteral(\"\"), this);\n\n    //connect(browseButton, SIGNAL(clicked()), this, SLOT(onRtlOutputBrowsePressed()), Qt::UniqueConnection);\n\n    //fileSaveLayout->addWidget(saveLocationLabel);\n    //fileSaveLayout->addWidget(rtlSaveLocationEdit_, 1);\n    //fileSaveLayout->addWidget(browseButton);\n    \n    //layout->addLayout(fileSaveLayout);\n\n    // TODO refine verilog generator warning look\n    if (verilogGeneratorAvailable() == false)\n    {\n        QLabel* verilogNotFoundLabel = new QLabel(\"Verilog generator not loaded\");\n        auto labelPalette = verilogNotFoundLabel->palette();\n        labelPalette.setColor(QPalette::ColorRole::Text, KactusColors::ERROR);\n        verilogNotFoundLabel->setPalette(labelPalette);\n\n        layout->addWidget(verilogNotFoundLabel);\n        rtlGenerationGroup_->setEnabled(false);\n    }\n\n    layout->addWidget(addToFileSet_);\n    return rtlGenerationGroup_;\n}\n\n//-----------------------------------------------------------------------------\n// Function: InterconnectGeneratorDialog::rtlCanBeGenerated()\n//-----------------------------------------------------------------------------\nbool Dialog::rtlCanBeGenerated()\n{\n    // RTL can only be generated for compatible abs defs (TUNI versions of AXI4, AXI4LITE, OBI for now)\n    // Check if selected abs def is compatible.\n\n    if (auto currentAbsDefVLNV = getCurrentlySelectedAbsDef())\n    {\n        for (auto const& validVlnvStr : rtlCompatibleAbsDefs_)\n        {\n            auto validAbsDefVlnv = VLNV(VLNV::ABSTRACTIONDEFINITION, validVlnvStr);\n\n            if (validAbsDefVlnv.getVendor().compare(currentAbsDefVLNV->getVendor()) == 0\n                && validAbsDefVlnv.getLibrary().compare(currentAbsDefVLNV->getLibrary()) == 0\n                && validAbsDefVlnv.getName().compare(currentAbsDefVLNV->getName()) == 0)\n            {\n                return true;\n            }\n        }\n    }\n    return false;\n}\n\n//-----------------------------------------------------------------------------\n// Function: InterconnectGeneratorDialog::createButtonBox()\n//-----------------------------------------------------------------------------\nQDialogButtonBox* Dialog::createButtonBox() \n{\n    QDialogButtonBox* buttonBox = new QDialogButtonBox(Qt::Horizontal, this);\n    buttonBox->addButton(tr(\"Generate\"), QDialogButtonBox::AcceptRole);\n    buttonBox->addButton(QDialogButtonBox::Cancel);\n\n    connect(buttonBox, &QDialogButtonBox::accepted, this, &Dialog::accept);\n    connect(buttonBox, &QDialogButtonBox::rejected, this, &Dialog::reject);\n\n    return buttonBox;\n}\n\n//-----------------------------------------------------------------------------\n// Function: InterconnectGeneratorDialog::setUpLayout()\n//-----------------------------------------------------------------------------\nvoid Dialog::setUpLayout() \n{\n    setWindowTitle(\"Interconnect Component Configuration\");\n\n    auto mainLayout = new QVBoxLayout(this);\n    auto leftRightLayout = new QHBoxLayout();\n\n    auto leftSideLayout = new QVBoxLayout();\n    leftSideLayout->addWidget(createTopConfigSection());\n    leftSideLayout->addWidget(createRtlOutputSection());\n    leftSideLayout->addWidget(parameterGroupBox_);\n\n    // Refresh rtl checkbox status after creation\n    onAbsDefChanged(absDefCombo_->currentIndex());\n\n    auto rightSideLayout = new QVBoxLayout();\n    rightSideLayout->addWidget(createInterconnectModeSelector());\n    rightSideLayout->addWidget(createInstancesSection());\n\n    leftRightLayout->addLayout(leftSideLayout);\n    leftRightLayout->addLayout(rightSideLayout);\n\n    mainLayout->addLayout(leftRightLayout);\n    mainLayout->addWidget(createButtonBox());\n\n    setLayout(mainLayout);\n}\n\n//-----------------------------------------------------------------------------\n// Function: InterconnectGeneratorDialog::accept()\n//-----------------------------------------------------------------------------\nvoid Dialog::accept()\n{\n    InterconnectGeneration::ConfigStruct* config = new ConfigStruct;\n\n    if (!vlnvEditor_->isValid()) {\n        QMessageBox::warning(this, tr(\"Input Error\"), tr(\"Select valid VLNV for interconnect component.\"));\n        return;\n    }\n    if (KactusAPI::getLibrary()->contains(vlnvEditor_->getVLNV()))\n    {\n        QMessageBox::warning(this, tr(\"Input Error\"), tr(\"Selected VLNV for interconnect component already exists.\"));\n        return;\n    }\n    if (!bridgeButton_->isEnabled() && !channelButton_->isEnabled()) \n    {\n        QString message = dataModel_->getLastInvalidConnectionMessage();\n        QMessageBox::warning(this, tr(\"Input Error\"), message);\n        return;\n    }\n\n    QSharedPointer<ConfigurableVLNVReference> absRef;\n    QSharedPointer<ConfigurableVLNVReference> clkRef;\n    QSharedPointer<ConfigurableVLNVReference> rstRef;\n    for (auto& ref : allAbsRefs_) {\n        if (ref->getName() == absDefCombo_->currentText()) {\n            absRef = ref;\n        }\n        if (ref->getName() == clockCombo_->currentText()) {\n            clkRef = ref;\n        }\n        if (ref->getName() == resetCombo_->currentText()) {\n            rstRef = ref;\n        }\n    }\n\n    auto interconVLNV = vlnvEditor_->getVLNV().toString();\n    auto busVLNV = absRef->toString();\n    auto busType = absRef->getName();\n    auto clkVLNV = clockCheckBox_->isChecked() ? clkRef->toString() : QString();\n    auto rstVLNV = resetCheckBox_->isChecked() ? rstRef->toString() : QString();\n    \n    config->designVLNV = designVLNV_;\n    config->interconVLNV = interconVLNV;\n    config->busVLNV = busVLNV;\n    config->clkVLNV = clkVLNV;\n    config->rstVLNV = rstVLNV;\n    config->busType = InterconnectGeneration::ConfigJsonParser::strToBusType(busType.split(\".abs\")[0]);\n    config->addressWidth = QString();\n    config->dataWidth = QString();\n    config->addressWidthParamName = addrWidthParamName_;\n    config->dataWidthParamName = dataWidthParamName_;\n    config->idWidth = 8;\n    config->userWidth = 1;\n    config->isChannel = isChannel_;\n    config->interconnectParams = *interconnectParams_;\n\n    config_ = config;\n    \n    addrWidthValue_ = QString::fromStdString(parameterGroupBox_->getInterface()->getValueFormattedExpression(addrWidthParamName_.toStdString()));\n\n    if (rtlGenerationSelected() && (config->busType == BusType::AXI4 || config->busType == BusType::AXI4LITE))\n    {\n        // Get value of addr and data width, check if they are 32 or 64, complain if not (requirement of AXI4(LITE) implementation used)\n        bool widthOk = false;\n        auto val = expressionParser_->parseExpression(addrWidthValue_, &widthOk).toInt();\n\n        if (widthOk && (val == 32 || val == 64))\n        {\n            config_->parsedAddressWidth = val;\n        }\n        else\n        {\n            if (QMessageBox::warning(this, \"Unsupported configuration\", \"Warning: Unsupported address width. Continue?\", QMessageBox::Yes, QMessageBox::No) == QMessageBox::No)\n            {\n                return;\n            }\n        }\n\n        // Get currently selected fileset, if selected\n        if (addToFileSet_->isChecked())\n        {\n            config_->filesetToGenerate = addToFileSet_->currentSelection();\n\n            // Generate with default name if empty\n            if (config_->filesetToGenerate.isEmpty())\n            {\n                config_->filesetToGenerate = QStringLiteral(\"rtl\");\n            }\n        }\n\n        // TODO implement save location later \n        // Check that save location exists\n        //auto savePath = rtlSaveLocationEdit_->text();\n        //auto lastSlash = savePath.lastIndexOf(\"/\");\n        //auto dirPath = savePath.mid(0, lastSlash);\n\n        //auto expectedDefaultPath = KactusAPI::getDefaultLibraryPath() % \"/\" % vlnvEditor_->getVLNV().getVendor() % \"/\" % vlnvEditor_->getVLNV().getLibrary() % \"/\" % vlnvEditor_->getVLNV().getName() % \"/\" % vlnvEditor_->getVLNV().getVersion();\n\n        //QFileInfo saveInfo(dirPath);\n\n        //if (saveInfo.exists() == false && dirPath != expectedDefaultPath)\n        //{\n        //    QMessageBox::warning(this, \"Save location\", \"Warning: RTL save location doesn't exist\", QMessageBox::Ok);\n        //    return;\n        //}\n    }\n\n\n    // Collect selected interfaces into selectedStartingPoints_ and selectedEndpoints_\n    // Interfaces shall be mapped to either bucket based on which interconnect mode is selected.\n\n    // 1. get all selected interfaces\n    // 2. divide into startpoints and endpoints\n\n    collectSelectedInterfaces();\n\n    QString selectionErrorMsg;\n    if (interfaceSelectionsAreValid(selectionErrorMsg) == false)\n    {\n        QMessageBox::warning(this, tr(\"Input Error\"), selectionErrorMsg);\n        return;\n    }\n\n    QDialog::accept();\n}\n\n//-----------------------------------------------------------------------------\n// Function: InterconnectGeneratorDialog::onAbsDefChanged()\n//-----------------------------------------------------------------------------\nvoid Dialog::onAbsDefChanged(int currentIndex)\n{\n    if (ignoreChange_)\n    {\n        ignoreChange_ = false;\n        return;\n    }\n\n    populateParameters();\n    filterAvailableInstancesByAbsDef();\n\n    if (hasSelectedInstances())\n    {\n        int response = QMessageBox::warning(this, tr(\"Data Loss\"),\n            tr(\"All existing interface selections will be removed if abstraction definition is changed. Do you want to continue?\"),\n            QMessageBox::Yes | QMessageBox::No, QMessageBox::No);\n\n        if (response == QMessageBox::No)\n        {\n            ignoreChange_ = true;\n            absDefCombo_->setCurrentIndex(previousAbsDefIndex_);\n            return;\n        }\n\n        clearInstanceSelections();\n        filterAvailableInstancesByAbsDef();\n        updateAddInstanceButtonStatus();\n    }\n    previousAbsDefIndex_ = currentIndex;\n\n    // Check if new abs def selection allows for RTL generation, disable/enable widgets accordingly\n    if (rtlCanBeGenerated() == false)\n    {\n        rtlGenerationGroup_->setEnabled(false);\n        rtlGenerationGroup_->setChecked(false);\n\n        addToFileSet_->setChecked(false);\n    }\n    else\n    {\n        rtlGenerationGroup_->setEnabled(true);\n        rtlGenerationGroup_->setChecked(rtlGenerationGroup_->isChecked());\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: InterconnectGeneratorDialog::collectSelectedInterfaces()\n//-----------------------------------------------------------------------------\nvoid Dialog::collectSelectedInterfaces()\n{\n    // Get all selected interfaces, divide them into starting points and end points (= initiator adjacent \n    // and target adjacent interfaces)\n    // Starting points (bridge): instance initiator or mirrored target, top component target\n    // Starting points (channel): Instance initiator or top component mirrored initiator\n    // Endpoints (bridge): Instance target or mirrored initiator, top component initiator\n    // Endpoints (channel): Instance target or top component mirrored target\n\n    selectedStartingPoints_.clear();\n    selectedEndpoints_.clear();\n\n    InterconnectGeneration::InterconnectType interconnectType = isChannel_\n        ? InterconnectGeneration::InterconnectType::Channel\n        : InterconnectGeneration::InterconnectType::Bridge;\n\n    int targetIndex = 0;\n    int initIndex = 0;\n\n    for (auto const& editor : instanceEditors_)\n    {\n        auto interfaceData = editor->getSelectedInterfaces();\n        auto currentInstance = editor->getSelectedInstance();\n        auto instanceBuses = busLookUp_.value(currentInstance);\n        bool isTopComponent = instanceIsTopComponent(currentInstance);\n\n        InterconnectGeneration::EntityType currentInstanceType = isTopComponent\n            ? InterconnectGeneration::EntityType::TopComponent\n            : InterconnectGeneration::EntityType::Instance;\n\n        for (auto const& singleInterface : interfaceData)\n        {\n            // Get interface mode\n            auto interfaceModel = instanceBuses.value(singleInterface.name);\n\n            auto interfaceMode = interfaceModel->getInterfaceMode();\n\n            if (dataModel_->interfaceIsTargetAdjacent(interfaceMode, interconnectType, currentInstanceType))\n            {\n                if (selectedEndpoints_.contains(currentInstance) == false)\n                {\n                    selectedEndpoints_.insert(currentInstance, QList<QSharedPointer<EndpointData> >());\n                }\n                \n                // Data for IP-XACT model of interconnect\n                QSharedPointer<EndpointData> newEndpoint(new EndpointData);\n                newEndpoint->endpointBus = interfaceModel;\n                newEndpoint->start = singleInterface.startValue;\n                newEndpoint->range = singleInterface.range;\n\n                selectedEndpoints_[currentInstance].append(newEndpoint);\n\n                // Below is data for RTL writer\n                AddressPair addr;\n\n                // Format start and range values to contain parameter names instead of UUIDs\n                auto formattedStartValue = expressionFormatter_->formatReferringExpression(singleInterface.startValue);\n                auto formattedRangeValue = expressionFormatter_->formatReferringExpression(singleInterface.range);\n\n                addr.start = singleInterface.startValue.isEmpty() ? \"##null##\" : formattedStartValue;\n                addr.end = singleInterface.range.isEmpty() ? \"##null##\" : formattedRangeValue;\n\n                TargetStruct target;\n                target.name = currentInstance + \"_\" + singleInterface.name;\n                target.index = targetIndex++;\n                target.addressRegions.append(addr);\n                config_->targetList.append(target);\n            }\n            else if (dataModel_->interfaceIsInitiatorAdjacent(interfaceMode, interconnectType, currentInstanceType))\n            {\n                if (selectedStartingPoints_.contains(currentInstance) == false)\n                {\n                    selectedStartingPoints_.insert(currentInstance, QList<QSharedPointer<BusInterface> >());\n                }\n\n                selectedStartingPoints_[currentInstance].append(interfaceModel);\n\n                // Data for RTL writer\n                InitStruct init;\n                init.index = initIndex++;\n                init.name = currentInstance + \"_\" + singleInterface.name;\n\n                config_->initList.append(init);\n            }\n        }\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: Dialog::findWidthParameters()\n//-----------------------------------------------------------------------------\nvoid Dialog::findWidthParameters()\n{\n    // Find currently selected abs def document\n    auto currentAbsDefVLNV = getCurrentlySelectedAbsDef();\n\n    if (currentAbsDefVLNV == nullptr)\n    {\n        return;\n    }\n\n    auto absDef = library_->getModelReadOnly(*currentAbsDefVLNV).dynamicCast<AbstractionDefinition const>();\n\n    if (absDef == nullptr)\n    {\n        return;\n    }\n    \n    bool addressPortFound = false;\n    bool dataPortFound = false;\n\n    QSharedPointer<PortAbstraction> addrPort;\n    QSharedPointer<PortAbstraction> dataPort;\n\n\n    // Go through abs adef logical ports\n    // Look for port with qualifier address or data\n    for (auto const& port : *absDef->getLogicalPorts())\n    {\n        if (addressPortFound && dataPortFound)\n            break;\n\n        auto portQualifier = port->getQualifier();\n        auto qualifierTypes = portQualifier->getTypes();\n\n        if (qualifierTypes.contains(Qualifier::Type::Address) && addressPortFound == false)\n        {\n            addressPortFound = true;\n            addrPort = port;\n        }\n\n        if (qualifierTypes.contains(Qualifier::Type::Data) && dataPortFound == false)\n        {\n            dataPortFound = true;\n            dataPort = port;\n        }\n    }\n\n    \n\n    // Check if parameterized\n    // Gotta check all modes of port (master, slave etc.) and check if that mode has non-empty width.\n    // Use first non-empty that is found. If all modes have mepty widths, then use empty.\n    auto foundAddrWidth = QString();\n    auto foundDataWidth = QString();\n\n    for (int i = 0; i < General::InterfaceMode::INTERFACE_MODE_COUNT; ++i)\n    {\n        auto mode = static_cast<General::InterfaceMode>(i);\n\n        if (foundAddrWidth.isEmpty() == false && foundDataWidth.isEmpty() == false)\n        {\n            break;\n        }\n\n        if (addrPort && addrPort->hasMode(mode, QString()))\n        {\n            if (auto widthStr = addrPort->getWire()->getWidth(mode, QString()); widthStr.isEmpty() == false)\n            {\n                foundAddrWidth = widthStr;\n            }\n        }\n\n        if (dataPort && dataPort->hasMode(mode, QString()))\n        {\n            if (auto widthStr = dataPort->getWire()->getWidth(mode, QString()); widthStr.isEmpty() == false)\n            {\n                foundDataWidth = widthStr;\n            }\n        }\n    }\n\n    QSharedPointer<ListParameterFinder> absDefParamFinder(new ListParameterFinder());\n    absDefParamFinder->setParameterList(absDef->getParameters());\n    auto addrWidthParam = absDefParamFinder->getParameterWithID(foundAddrWidth);\n    auto dataWidthParam = absDefParamFinder->getParameterWithID(foundDataWidth);\n\n    if (addrWidthParam)\n    {\n        addrWidthParamName_ = addrWidthParam->name();\n    }\n\n    if (dataWidthParam)\n    {\n        dataWidthParamName_ = dataWidthParam->name();\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: Dialog::getCurrentlySelectedAbsDef()\n//-----------------------------------------------------------------------------\nConfigurableVLNVReference* Dialog::getCurrentlySelectedAbsDef()\n{\n    auto selectedAbsDef = absDefCombo_->currentText();\n\n    // Find selected abs def vlnv\n    auto foundIt = std::find_if(allAbsRefs_.cbegin(), allAbsRefs_.cend(),\n        [&selectedAbsDef](QSharedPointer<ConfigurableVLNVReference> vlnv)\n        {\n            return vlnv->getName().compare(selectedAbsDef) == 0;\n        });\n\n    if (foundIt == allAbsRefs_.cend())\n    {\n        return nullptr;\n    }\n\n    return foundIt->data();\n}\n\n//-----------------------------------------------------------------------------\n// Function: Dialog::onRtlOutputBrowsePressed()\n//-----------------------------------------------------------------------------\n//void Dialog::onRtlOutputBrowsePressed()\n//{\n//    auto defaultLibPath = KactusAPI::getDefaultLibraryPath();\n//\n//    QFileDialog browseDialog(this, tr(\"Select file to save\"), defaultLibPath);\n//    browseDialog.setFileMode(QFileDialog::AnyFile);\n//    browseDialog.setDefaultSuffix(\"v\");\n//\n//    if (browseDialog.exec() == QDialog::Accepted)\n//    {\n//        rtlSaveLocationOverridden_ = true;\n//\n//        QStringList selectedFiles = browseDialog.selectedFiles();\n//        if (!selectedFiles.isEmpty())\n//        {\n//            rtlSaveLocationEdit_->setText(selectedFiles.first());\n//        }\n//    }\n//}\n\n//-----------------------------------------------------------------------------\n// Function: Dialog::onVlnvChanged()\n//-----------------------------------------------------------------------------\nvoid Dialog::onVlnvChanged()\n{\n    // TODO implement later\n    //if ((rtlGenerationGroup_->isChecked() && rtlSaveLocationOverridden_ == false) || \n    //    (rtlSaveLocationOverridden_ && rtlSaveLocationEdit_->text().isEmpty()))\n    //{\n    //    rtlSaveLocationOverridden_ = false;\n    //    QString defaultPath = KactusAPI::getDefaultLibraryPath();\n    //    QString defaultSavePath = defaultPath % \"/\" % vlnvEditor_->getVLNV().getVendor() % \"/\" % vlnvEditor_->getVLNV().getLibrary() % \"/\" % vlnvEditor_->getVLNV().getName() % \"/\" % vlnvEditor_->getVLNV().getVersion() % \"/\";\n    //    QString fullSavePath = defaultSavePath % vlnvEditor_->getVLNV().getName() % \".v\";\n    //    rtlSaveLocationEdit_->setText(fullSavePath);\n    //}\n}\n\n//-----------------------------------------------------------------------------\n// Function: Dialog::onRtlGenerationToggled()\n//-----------------------------------------------------------------------------\nvoid Dialog::onRtlGenerationToggled(bool on)\n{\n    if (on == false)\n    {\n        // TODO implement later\n        //rtlSaveLocationOverridden_ = false;\n        //rtlSaveLocationEdit_->clear();\n        addToFileSet_->clear();\n    }\n    else\n    {\n        // Fill default path\n        onVlnvChanged();\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: Dialog::findVerilogGenerator()\n//-----------------------------------------------------------------------------\nbool Dialog::verilogGeneratorAvailable()\n{\n    for (auto plugin : PluginManager::getInstance().getActivePlugins())\n    {\n        if (auto runnable = dynamic_cast<CLIGenerator*>(plugin))\n        {\n            if (runnable->getOutputFormat().toLower() == \"verilog\")\n            {\n                return true;\n            }\n        }\n    }\n\n    return false;\n}\n"
  },
  {
    "path": "editors/InterconnectGenerator/InterconnectGeneratorDialog.h",
    "content": "//-----------------------------------------------------------------------------\n// File: InterconnectGeneratorDialog.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Sampo Suokuisma\n// Date: 05.06.2025\n//\n// Description:\n// Class for configuring generated interconnect component\n//-----------------------------------------------------------------------------\n\n#ifndef INTERCONNECTGENERATORDIALOG_H\n#define INTERCONNECTGENERATORDIALOG_H\n\n#include <QDialog>\n#include <QDialogButtonBox>\n#include <QFormLayout>\n#include <QVBoxLayout>\n#include <QHBoxLayout>\n#include <QPushButton>\n#include <QGroupBox>\n#include <QLabel>\n#include <QLineEdit>\n#include <QCheckBox>\n#include <QComboBox>\n#include <QString>\n#include <QScrollArea>\n#include <QFrame>\n#include <QSet>\n#include <QHash>\n#include <QList>\n#include <QRadioButton>\n\n#include <common/widgets/ParameterGroupBox/parametergroupbox.h>\n#include <common/widgets/vlnvEditor/vlnveditor.h>\n#include <common/widgets/EnumCollectionEditor/InterfaceEnumEditor.h>\n#include <common/widgets/instanceWidgets/InstanceWidgets.h>\n#include <editors/common/DesignWidget.h>\n#include <editors/InterconnectGenerator/InterconnectAddressHelper.h>\n#include <editors/InterconnectGenerator/InterconnectDataModel.h>\n#include <common/graphicsItems/ComponentItem.h>\n\n#include <KactusAPI/include/ExpressionParser.h>\n#include <IPXACTmodels/Component/BusInterface.h>\n#include <KactusAPI/include/ConfigJsonParser.h>\n#include <KactusAPI/include/LibraryHandler.h>\n#include <KactusAPI/include/InterconnectGenerator.h>\n#include <KactusAPI/include/MessageMediator.h>\n\nclass ExpressionEditor;\nclass InstanceInterfacesEditor;\nclass ParameterReferenceCounter;\nclass AddToFilesetWidget;\n\nnamespace InterconnectGeneration\n{\n\n    //-----------------------------------------------------------------------------\n    //! Class for configuring generated interconnect component\n    //-----------------------------------------------------------------------------\n    class Dialog : public QDialog\n    {\n        Q_OBJECT\n    public:\n        /*!\n         *  The constructor.\n         *\n         *  @param [in] designWidget            class for showing design diagrams.\n         *  @param [in] library                 Interface for accessing IP-XACT-library.\n         *  @param [in] messager                Interface for outputting messages.\n         *  @param [in] parent                  The parent widget.\n         */\n        Dialog(DesignWidget* designWidget, LibraryHandler* library,\n            MessageMediator* messager, QWidget* parent = nullptr);\n\n        /*!\n         *  The destructor.\n         */\n        ~Dialog();\n\n        /*!\n         *  Get config to generate interconnect.\n         *\n         *  @return Struct containing interconnect configurations.\n         */\n        ConfigStruct* getConfig() const;\n\n        /*!\n         *  Get selected starting point interfaces.\n         *\n         *  @return QHash containing instance name as key and bus interfaces as values.\n         */\n        QHash<QString, QList<QSharedPointer<BusInterface>>> getSelectedStartingPoints() const;\n\n        /*!\n         *  Get selected endpoint interfaces.\n         *\n         *  @return QHash containing instance name as key and bus interfaces as values.\n         */\n        QHash<QString, QList<QSharedPointer<EndpointData>>> getSelectedEndpoints() const;\n\n        /*!\n         *\tChecks if RTL generation is enabled or not.\n         *\n         *    @return True, if generator should generate RTL, otherwise false.\n         */\n        bool rtlGenerationSelected();\n\n    protected:\n\n        /*!\n         *  Overrides QDialog accept.\n         */\n        void accept() override;\n\n    private slots:\n\n        /*!\n         *\tHandle change in selected abstraction definition (abstraction type) for interconnect component.\n         *\n         *    @param [in] currentIndex     Index of currently selected abstraction definition\n         */\n        void onAbsDefChanged(int currentIndex);\n\n        /*!\n         *  Handle logic triggered when a new instance is selected from the list.\n         *\n         *  @param [in] newInstanceName     Name of the newly selected instance.\n         *  @param [in] oldInstanceName     Name of the previously selected instance.\n         */\n        void onInstanceSelected(QString const& newInstanceName, QString const& oldInstanceName);\n\n        /*!\n         *\tHandle removing instance and its selected interfaces.\n         */\n        void onInstanceRemoved();\n\n        /*!\n         *\tHandler for adding a new instance.\n         */\n        void addNewInstance();\n\n        /*!\n         *\tHandle toggling of interconnect mode selector. Called for each radio button in selector group box.\n         *\n         *    @param [in] checked     Flag indicating if the calling radio button is checked or not.\n         */\n        void onInterconnectSelectorToggled(bool checked);\n\n        /*!\n         *\tHandle browsing for output file location.\n         */\n        //void onRtlOutputBrowsePressed();\n\n        /*!\n         *\tCalled on change to interconnect component VLNV\n         */\n        void onVlnvChanged();\n\n        /*!\n         *\tCalled when rtl generation is toggled.\n         */\n        void onRtlGenerationToggled(bool on);\n\n    private:\n\n        /*!\n         *  Create the top section of the configuration UI containing global settings.\n         *\n         *  @return Pointer to the created QWidget.\n         */\n        QWidget* createTopConfigSection();\n\n        /*!\n         *  Create the UI section for listing and managing starting point interfaces.\n         *\n         *  @return Pointer to the created QGroupBox containing starting point controls.\n         */\n        QGroupBox* createInstancesSection();\n\n        /*!\n         *  Create the standard button box for dialog actions (OK/Cancel).\n         *\n         *  @return Pointer to the created QDialogButtonBox.\n         */\n        QDialogButtonBox* createButtonBox();\n\n        /*!\n         *  Create a widget that allows the user to select the interconnect mode.\n         *\n         *  @return Pointer to the created QWidget.\n         */\n        QWidget* createInterconnectModeSelector();\n\n        /*!\n         *  Creates the checkbox which is used to enable RTL generation.\n         *\n         *  @return Pointer to the created QWidget.\n         */\n        QWidget* createRtlOutputSection();\n\n        /*!\n         *\tChecks the selected abstraction definition for RTL generation compatibility. Compatible VLNVs are\n         *  defined in rtlCompatibleAbsDefs_\n         *\n         *    @return True, if RTL can be generated, otherwise false.\n         */\n        bool rtlCanBeGenerated();\n\n        /*!\n         *  Set up the full layout of the interconnect generator dialog.\n         */\n        void setUpLayout();\n\n        /*!\n         *  Populate the parameter editor with a copy of abstraction definition parameters.\n         */\n        void populateParameters();\n\n        /*!\n         *  Clear all entries from both the starting and endpoint lists.\n         */\n        void clearInstanceSelections();\n\n        /*!\n         *  Collect instance configurations for interconnect generation.\n         */\n        void collectSelectedInterfaces();\n\n        /*!\n         *  Get the currently selected interconnect type.\n         *\n         *  @return The selected interconnect type (Bridge or Channel).\n         */\n        InterconnectGeneration::InterconnectType getSelectedInterconnectType() const;\n\n        void filterAvailableInstancesByAbsDef();\n\n        /*!\n         *\tUpdate the available instances for all instance interface editors\n         */\n        void updateAvailableInstances();\n\n        /*!\n         *\tSet the available interfaces for selected instance interface editor.\n         *\n         *    @param [in] interfacesEditor     The selected editor.\n         *    @param [in] selectedInstance     The currently selected instance whose interfaces will be set.\n         */\n        void updateAvailableInstanceInterfaces(InstanceInterfacesEditor* interfacesEditor, QString const& selectedInstance);\n\n        /*!\n         *\tDisable or enable add instances button based on available instances.\n         */\n        void updateAddInstanceButtonStatus();\n\n        /*!\n         *\tChecks if any instances have been added.\n         *\n         *    @return True, if at least one instance has been added. Otherwise false.\n         */\n        bool hasSelectedInstances();\n\n        /*!\n         *\tGet the allowed interface modes that can be selected for a given instance.\n         *\n         *    @param [in] selectedInstance     The selected instance.\n         *\n         *    @return A set of allowed interface modes.\n         */\n        QSet<General::InterfaceMode> getAllowedInterfaceModes(QString const& selectedInstance);\n\n        /*!\n         *\tChecks if gathered interface selections satisfy the requirements for generating an interconnect component.\n         *\n         *    @param [in/out] errorMsg     Error message to create if selections are invalid.\n         *\n         *    @return True, if the selections are valid, otherwise false.\n         */\n        bool interfaceSelectionsAreValid(QString& errorMsg);\n\n        /*!\n         *\tChecks if the given instance is the top component of the open design.\n         *\n         *    @param [in] instanceName     Name of the instance to check.\n         *\n         *    @return  True, if the instance is top component, otherwise false.\n         */\n        bool instanceIsTopComponent(QString const& instanceName);\n\n        /*!\n         *\tFind parameters that define address and data width. Finds ports in abs def with address and data qualifers and gets their widths.\n         *  If width is parameterized, addr/data width is set as that parameter. Otherwise hard-coded parameter is created with found width.\n         *  If no widths are found, a default value of ????? (32 or non-numeric?) is used.\n         */\n        void findWidthParameters();\n\n        ConfigurableVLNVReference* getCurrentlySelectedAbsDef();\n\n        bool verilogGeneratorAvailable();\n\n        //-----------------------------------------------------------------------------\n        // Data.\n        //-----------------------------------------------------------------------------\n\n        //! Reference to the design widget used to query the edited component.\n        DesignWidget* designWidget_;\n\n        //! Interface for accessing IP-XACT library models.\n        LibraryHandler* library_;\n\n        //! Message output interface for displaying user-facing notifications or errors.\n        MessageMediator* messager_;\n\n        //! Shared data model that provides abstraction and bus/interface information.\n        QSharedPointer<InterconnectDataModel> dataModel_;\n\n        //! TODO delete if addressing auto population isn't implemented\n        //! Helper for generating and analyzing address mappings in interconnects.\n        //QSharedPointer<InterconnectAddressHelper> addressHelper_;\n\n        //! Parameters specific to the generated interconnect component.\n        QSharedPointer<QList<QSharedPointer<Parameter>>> interconnectParams_;\n\n        QSharedPointer<ExpressionParser> expressionParser_{ new SystemVerilogExpressionParser() };\n\n        //! Formatter for expressions.\n        QSharedPointer<ExpressionFormatter> expressionFormatter_;\n\n        //! Current working interconnect configuration.\n        ConfigStruct* config_ = nullptr;\n\n        //! Nested hash lookup for quick bus interface resolution.\n        QHash<QString, QHash<QString, QSharedPointer<BusInterface>>> busLookUp_;\n\n        //! VLNV identifier of the design currently being edited.\n        QString designVLNV_;\n\n        //! Editor widget for editing the VLNV of the interconnect.\n        VLNVEditor* vlnvEditor_;\n\n        //! Parameter editor group box for the interconnect component.\n        ParameterGroupBox* parameterGroupBox_;\n\n        //! Combo box for selecting a bus interface.\n        InstanceComboBox* absDefCombo_;\n\n        //! Combo box for selecting a clock interface.\n        InstanceComboBox* clockCombo_;\n\n        //! Combo box for selecting a reset interface.\n        InstanceComboBox* resetCombo_;\n\n        //! Checkbox to enable or disable clock signal configuration.\n        QCheckBox* clockCheckBox_;\n\n        //! Checkbox to enable or disable reset signal configuration.\n        QCheckBox* resetCheckBox_;\n\n        //! Checkbox to select if RTL code should be generated if compatible abs def is selected.\n        QGroupBox* rtlGenerationGroup_;\n\n        //! Line edit for rtl file save location.\n        //QLineEdit* rtlSaveLocationEdit_;\n\n        //! Flag to control if default save location should be used or not.\n        //bool rtlSaveLocationOverridden_ = false;\n\n        //! Widget for adding generated rtl to a file set.\n        AddToFilesetWidget* addToFileSet_;\n\n        //! Radio button to choose channel-based interconnect generation.\n        QRadioButton* channelButton_;\n\n        //! Radio button to choose bridge-based interconnect generation.\n        QRadioButton* bridgeButton_;\n\n        //! Layout container for instance and interface selection.\n        QVBoxLayout* instancesLayout_;\n\n        //! Button for adding new instances to select interfaces from.\n        QPushButton* addInstanceButton_ = new QPushButton(QIcon(\":/icons/common/graphics/add.png\"), tr(\"Add New Instance\"));\n\n        //! Previous index selected in UI (used for change tracking).\n        int previousAbsDefIndex_ = -1;\n\n        //! Internal flag to suppress change-triggered logic during setup.\n        bool ignoreChange_ = false;\n\n        //! Indicates whether the interconnect is being generated as a channel.\n        bool isChannel_ = false;\n\n        //! Set containing names of available instances to select.\n        QSet<QString> availableInstances_;\n\n        //! Set of filtered abstraction references compatible with the selected bus.\n        QSet<QSharedPointer<ConfigurableVLNVReference>> filteredAbsRefs_;\n\n        //! Set of all abstraction references for the selected design.\n        QSet<QSharedPointer<ConfigurableVLNVReference>> allAbsRefs_;\n\n        //! Map of instance names to their associated bus interfaces.\n        QHash<QString, QSet<QSharedPointer<BusInterface>>> instanceBusesHash_;\n\n        //! Map of bus interfaces to abstraction definitions used by them.\n        QHash<QSharedPointer<BusInterface>, QSet<QString>> interfaceAbsDefsHash_;\n\n        //! Parameter finder for editors needing access to interconnect component parameters.\n        QSharedPointer<ParameterFinder> parameterFinder_;\n\n        //! Parameter completer model for expression editors in interface selection editors.\n        ComponentParameterModel* parameterCompleterModel_;\n\n        //! Map of selected initiator interfaces, grouped by instance name.\n        QHash<QString, QList<QSharedPointer<BusInterface>>> selectedStartingPoints_;\n\n        //! Map of selected target interfaces and related metadata, grouped by instance name.\n        QHash<QString, QList<QSharedPointer<EndpointData>>> selectedEndpoints_;\n\n        //! Set containing all editors for added instances\n        QSet<InstanceInterfacesEditor*> instanceEditors_;\n\n        //! Reference counter for interconnect component parameters\n        QSharedPointer<ParameterReferenceCounter> paramRefCounter_;\n\n        QString addrWidthParamName_;\n        QString dataWidthParamName_;\n\n        QString addrWidthValue_;\n        QString dataWidthValue_;\n\n        //! RTL generation -compatible VLNV bases (version doesn't matter)\n        const QStringList rtlCompatibleAbsDefs_ = {\n            \"tuni.fi:interface:AXI4.absDef:version\",\n            \"tuni.fi:interface:AXI4LITE.absDef:version\",\n            \"tuni.fi:interface:OBI.absDef:version\",\n        };\n    };\n}\n\n#endif // INTERCONNECTGENERATORDIALOG_H\n"
  },
  {
    "path": "editors/MemoryDesigner/AddressBlockGraphicsItem.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: AddressBlockGraphicsItem.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Mikko Teuho\r\n// Date: 19.09.2016\r\n//\r\n// Description:\r\n// Graphics item for visualizing an address block in the memory designer.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"AddressBlockGraphicsItem.h\"\r\n\r\n#include <common/KactusColors.h>\r\n\r\n#include <editors/MemoryDesigner/MemoryItem.h>\r\n#include <editors/MemoryDesigner/MemoryMapGraphicsItem.h>\r\n#include <editors/MemoryDesigner/RegisterGraphicsItem.h>\r\n#include <editors/MemoryDesigner/MemoryConnectionItem.h>\r\n#include <editors/MemoryDesigner/MemoryDesignerConstants.h>\r\n\r\n#include <QBrush>\r\n#include <QFont>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressBlockGraphicsItem::AddressBlockGraphicsItem()\r\n//-----------------------------------------------------------------------------\r\nAddressBlockGraphicsItem::AddressBlockGraphicsItem(QSharedPointer<MemoryItem const> blockItem,\r\n    QVector<QString> identifierChain, bool isEmptyBlock, bool filterRegisters, bool filterFields,\r\n    qreal addressBlockWidth, QSharedPointer<ConnectivityComponent const> containingInstance,\r\n    MemoryMapGraphicsItem* memoryMapItem):\r\nMemoryDesignerChildGraphicsItem(blockItem, QStringLiteral(\"Address Block\"), blockItem->getAddress().toULongLong(),\r\n    blockItem->getRange().toULongLong(), addressBlockWidth, identifierChain, containingInstance, memoryMapItem),\r\nSubMemoryLayout(blockItem, MemoryDesignerConstants::REGISTER_TYPE, filterRegisters, this),\r\naddressUnitBits_(blockItem->getAUB()),\r\nfilterFields_(filterFields),\r\nisEmpty_(isEmptyBlock)\r\n{\r\n    setupAddressBlock();\r\n\r\n    qreal xPosition = MemoryDesignerConstants::MAPSUBITEMPOSITIONX - 1;\r\n    setupSubItems(xPosition, getSubItemType(), blockItem);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressBlockGraphicsItem::AddressBlockGraphicsItem()\r\n//-----------------------------------------------------------------------------\r\nAddressBlockGraphicsItem::AddressBlockGraphicsItem(AddressBlockGraphicsItem const& other, MemoryMapGraphicsItem* memoryMapItem):\r\nMemoryDesignerChildGraphicsItem(other, memoryMapItem),\r\nSubMemoryLayout(other, this),\r\naddressUnitBits_(other.addressUnitBits_),\r\nfilterFields_(other.filterFields_),\r\nisEmpty_(other.isEmpty_)\r\n{\r\n    setupAddressBlock();\r\n    cloneSubItems(other);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressBlockGraphicsItem::setupAddressBlock()\r\n//-----------------------------------------------------------------------------\r\nvoid AddressBlockGraphicsItem::setupAddressBlock()\r\n{\r\n    setColors(KactusColors::ADDR_BLOCK_COLOR, isEmpty_);\r\n    setLabelPositions();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressBlockGraphicsItem::~AddressBlockGraphicsItem()\r\n//-----------------------------------------------------------------------------\r\nAddressBlockGraphicsItem::~AddressBlockGraphicsItem()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressBlockGraphicsItem::setLabelPositions()\r\n//-----------------------------------------------------------------------------\r\nvoid AddressBlockGraphicsItem::setLabelPositions()\r\n{\r\n    qreal nameX = 0;\r\n    QRectF blockRectangle = boundingRect();\r\n    QRectF nameRectangle = getNameLabel()->boundingRect();\r\n    if (subItemsAreFiltered())\r\n    {\r\n        nameX = blockRectangle.right() - nameRectangle.width();\r\n    }\r\n    else\r\n    {\r\n        nameX = blockRectangle.left() + MemoryDesignerConstants::MAPSUBITEMPOSITIONX * 2 - nameRectangle.width();\r\n    }\r\n    qreal nameY = (blockRectangle.height() / 2) - (nameRectangle.height() / 2);\r\n\r\n    getNameLabel()->setPos(nameX, nameY);\r\n\r\n    qreal rangeStartX = blockRectangle.left();\r\n    qreal rangeStartY = blockRectangle.top();\r\n    qreal rangeEndY = blockRectangle.bottom() - getRangeEndLabel()->boundingRect().height();\r\n\r\n    if (!getRangeStartLabel()->isVisible())\r\n    {\r\n        rangeEndY += 2;\r\n    }\r\n\r\n    getRangeStartLabel()->setPos(rangeStartX, rangeStartY);\r\n    getRangeEndLabel()->setPos(rangeStartX, rangeEndY);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressBlockGraphicsItem::createNewSubItem()\r\n//-----------------------------------------------------------------------------\r\nMemoryDesignerChildGraphicsItem* AddressBlockGraphicsItem::createNewSubItem(\r\n    QSharedPointer<MemoryItem const> subMemoryItem, bool isEmpty)\r\n{\r\n    int registerWidth = getRegisterWidth();\r\n\r\n    RegisterGraphicsItem* registerItem = new RegisterGraphicsItem(\r\n        subMemoryItem, isEmpty, registerWidth, getIdentifierChain(), filterFields_, getContainingInstance(), this);\r\n\r\n    connect(registerItem, SIGNAL(openComponentDocument(VLNV const&, QVector<QString>)),\r\n        this, SIGNAL(openComponentDocument(VLNV const&, QVector<QString>)), Qt::UniqueConnection);\r\n\r\n    return registerItem;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressBlockGraphicsItem::createCopyOfSubItem()\r\n//-----------------------------------------------------------------------------\r\nMemoryDesignerChildGraphicsItem* AddressBlockGraphicsItem::createCopyOfSubItem(MemoryDesignerChildGraphicsItem* subItem)\r\n{\r\n    auto registerItem = dynamic_cast<RegisterGraphicsItem*>(subItem);\r\n    MemoryDesignerChildGraphicsItem* newSubItem = nullptr;\r\n    if (registerItem)\r\n    {\r\n        newSubItem = new RegisterGraphicsItem(*registerItem, this);\r\n\r\n        connect(newSubItem, SIGNAL(openComponentDocument(VLNV const&, QVector<QString>)),\r\n            this, SIGNAL(openComponentDocument(VLNV const&, QVector<QString>)), Qt::UniqueConnection);\r\n    }\r\n\r\n    return newSubItem;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressBlockGraphicsItem::getRegisterWidth()\r\n//-----------------------------------------------------------------------------\r\nqreal AddressBlockGraphicsItem::getRegisterWidth() const\r\n{\r\n    int registerWidth = boundingRect().width() - MemoryDesignerConstants::MAPSUBITEMPOSITIONX * 2 + 1;\r\n    return registerWidth;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressBlockGraphicsItem::createEmptySubItem()\r\n//-----------------------------------------------------------------------------\r\nMemoryDesignerChildGraphicsItem* AddressBlockGraphicsItem::createEmptySubItem(quint64 beginAddress,\r\n    quint64 rangeEnd)\r\n{\r\n    quint64 emptyRegisterRangeInt = rangeEnd - beginAddress + 1;\r\n\r\n    QString emptyRegisterBaseAddress = QString::number(beginAddress);\r\n\r\n    int intAUB = addressUnitBits_.toInt();\r\n    quint64 registerSize = emptyRegisterRangeInt * intAUB;\r\n\r\n    QSharedPointer<MemoryItem> emptyRegister (\r\n        new MemoryItem(MemoryDesignerConstants::RESERVED_NAME, MemoryDesignerConstants::REGISTER_TYPE));\r\n    emptyRegister->setAddress(emptyRegisterBaseAddress);\r\n    emptyRegister->setSize(QString::number(registerSize));\r\n    emptyRegister->setAUB(addressUnitBits_);\r\n\r\n    return createNewSubItem(emptyRegister, true);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressBlockGraphicsItem::changeAddress()\r\n//-----------------------------------------------------------------------------\r\nvoid AddressBlockGraphicsItem::changeAddress(quint64 const& newAddress)\r\n{\r\n    SubMemoryLayout::changeChildItemAddress(getBaseAddress(), newAddress);\r\n\r\n    MemoryDesignerChildGraphicsItem::changeAddress(newAddress);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressBlockGraphicsItem::addMemoryConnection()\r\n//-----------------------------------------------------------------------------\r\nvoid AddressBlockGraphicsItem::addMemoryConnection(MemoryConnectionItem* connectionItem)\r\n{\r\n    MemoryDesignerGraphicsItem::addMemoryConnection(connectionItem);\r\n\r\n    addConnectionToSubItems(connectionItem);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressBlockGraphicsItem::getItemWidth()\r\n//-----------------------------------------------------------------------------\r\nqreal AddressBlockGraphicsItem::getItemWidth() const\r\n{\r\n    qreal registerWidth = 0;\r\n\r\n    if (!subItemsAreFiltered())\r\n    {\r\n        registerWidth = getSubMemoryItems().first()->boundingRect().width();\r\n    }\r\n    qreal itemBoundingWidth = boundingRect().width() - registerWidth;\r\n    return itemBoundingWidth;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressBlockGraphicsItem::changeWidth()\r\n//-----------------------------------------------------------------------------\r\nvoid AddressBlockGraphicsItem::changeWidth(qreal widthChange)\r\n{\r\n    if (!subItemsAreFiltered())\r\n    {\r\n        QMultiMapIterator<quint64, MemoryDesignerChildGraphicsItem*> subItemIterator(getSubMemoryItems());\r\n        while (subItemIterator.hasNext())\r\n        {\r\n            subItemIterator.next();\r\n            MemoryDesignerChildGraphicsItem* subItem = subItemIterator.value();\r\n            RegisterGraphicsItem* registerItem = dynamic_cast<RegisterGraphicsItem*>(subItem);\r\n            if (registerItem)\r\n            {\r\n                registerItem->changeWidth(widthChange);\r\n            }\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressBlockGraphicsItem::getMaximumNeededChangeInFieldWidth()\r\n//-----------------------------------------------------------------------------\r\nqreal AddressBlockGraphicsItem::getMaximumNeededChangeInFieldWidth() const\r\n{\r\n    qreal maximumWidthChange = 0;\r\n    if (!filterFields_)\r\n    {\r\n        foreach (MemoryDesignerChildGraphicsItem* subItem, getSubMemoryItems())\r\n        {\r\n            RegisterGraphicsItem* registerItem = dynamic_cast<RegisterGraphicsItem*>(subItem);\r\n            if (registerItem)\r\n            {\r\n                maximumWidthChange = qMax(maximumWidthChange, registerItem->getMaximumNeededChangeInFieldWidth());\r\n            }\r\n        }\r\n    }\r\n\r\n    return maximumWidthChange;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressBlockGraphicsItem::createFieldOverlapItems()\r\n//-----------------------------------------------------------------------------\r\nvoid AddressBlockGraphicsItem::createFieldOverlapItems()\r\n{\r\n    if (!subItemsAreFiltered())\r\n    {\r\n        QMultiMapIterator<quint64, MemoryDesignerChildGraphicsItem*> subItemIterator(getSubMemoryItems());\r\n        while (subItemIterator.hasNext())\r\n        {\r\n            subItemIterator.next();\r\n            MemoryDesignerChildGraphicsItem* subItem = subItemIterator.value();\r\n            RegisterGraphicsItem* registerItem = dynamic_cast<RegisterGraphicsItem*>(subItem);\r\n            if (registerItem)\r\n            {\r\n                registerItem->createOverlappingFieldMarkers();\r\n            }\r\n        }\r\n    }\r\n}\r\n"
  },
  {
    "path": "editors/MemoryDesigner/AddressBlockGraphicsItem.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: AddressBlockGraphicsItem.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Mikko Teuho\r\n// Date: 19.09.2016\r\n//\r\n// Description:\r\n// Graphics item for visualizing an address block in the memory designer.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef ADDRESSBLOCKGRAPHICSITEM_H\r\n#define ADDRESSBLOCKGRAPHICSITEM_H\r\n\r\n#include <editors/MemoryDesigner/MemoryDesignerChildGraphicsItem.h>\r\n#include <editors/MemoryDesigner/SubMemoryLayout.h>\r\n\r\n#include <common/graphicsItems/GraphicsItemTypes.h>\r\n\r\nclass MemoryItem;\r\nclass MemoryMapGraphicsItem;\r\nclass RegisterGraphicsItem;\r\nclass MemoryConnectionItem;\r\n\r\n#include <QSharedPointer>\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Graphics item for visualizing an address block in the memory designer.\r\n//-----------------------------------------------------------------------------\r\nclass AddressBlockGraphicsItem : public MemoryDesignerChildGraphicsItem, public SubMemoryLayout\r\n{\r\n\r\npublic:\r\n\r\n    //! The type for the address block graphics item.\r\n    enum { Type = GFX_TYPE_MEMORY_ITEM };\r\n\r\n    /*!\r\n     *  The constructor.\r\n     *\r\n     *    @param [in] blockItem               Memory item containing the address block data.\r\n     *    @param [in] identifierChain         Chain of strings identifying this item.\r\n     *    @param [in] isEmptyBlock            Boolean value for existing blocks.\r\n     *    @param [in] filterRegisters         Filtering value for address block registers.\r\n     *    @param [in] filterFields            Filtering value for register fields.\r\n     *    @param [in] addressBlockWidth       Width of the address block graphics item.\r\n     *    @param [in] containingInstanceName  Name of the containing component instance.\r\n     *    @param [in] memoryMapItem           The parent memory map item.\r\n     */\r\n    AddressBlockGraphicsItem(QSharedPointer<MemoryItem const> blockItem, QVector<QString> identifierChain,\r\n        bool isEmptyBlock, bool filterRegisters, bool filterFields, qreal addressBlockWidth,\r\n        QSharedPointer<ConnectivityComponent const> containingInstance, MemoryMapGraphicsItem* memoryMapItem);\r\n\r\n    /*!\r\n     *  The copy constructor.\r\n     *\r\n     *    @param [in] other             The original address block item.\r\n     *    @param [in] memoryMapItem     The parent memory map item.\r\n     *\r\n     *    @return Copy of the original address block item.\r\n     */\r\n    AddressBlockGraphicsItem(AddressBlockGraphicsItem const& other, MemoryMapGraphicsItem* memoryMapItem);\r\n\r\n\t/*!\r\n     *  The destructor.\r\n     */\r\n    virtual ~AddressBlockGraphicsItem();\r\n\r\n    /*!\r\n     *  Get the type of the address block graphics item.\r\n     */\r\n    int type() const { return Type; }\r\n\r\n    /*!\r\n     *  Change the address block ranges.\r\n     *\r\n     *    @param [in] newAddress    New address for the address block.\r\n     */\r\n    virtual void changeAddress(quint64 const& newAddress) override;\r\n\r\n    /*!\r\n     *  Add a memory connection to address block item and to the correct sub items.\r\n     *\r\n     *    @param [in] connectionItem  The selected memory connection item.\r\n     */\r\n    virtual void addMemoryConnection(MemoryConnectionItem* connectionItem);\r\n\r\n    /*!\r\n     *  Change the width of the contained register graphics items.\r\n     *\r\n     *    @param [in] widthChange     The given change in width.\r\n     */\r\n    void changeWidth(qreal widthChange);\r\n\r\n    /*!\r\n     *  Get the maximum needed change in width to display the name labels of all the field items within the\r\n     *  register items.\r\n     *\r\n     *    @return The maximum needed change in width to display the name labels of all the field items.\r\n     */\r\n    qreal getMaximumNeededChangeInFieldWidth() const;\r\n\r\n    /*!\r\n     *  Create overlapping register field items.\r\n     */\r\n    void createFieldOverlapItems();\r\n\r\nprivate:\r\n    // Disable copying.\r\n    AddressBlockGraphicsItem& operator=(AddressBlockGraphicsItem const& rhs);\r\n\r\n    /*!\r\n     *  Setup the address block item.\r\n     */\r\n    void setupAddressBlock();\r\n\r\n    /*!\r\n     *  Get the width of the block item.\r\n     *\r\n     *    @param [in] memoryMapItem           The parent item of the address block item.\r\n     *    @param [in] registersAreFiltered    Filtering value for address block registers.\r\n     */\r\n    qreal getBlockWidth(MemoryMapGraphicsItem* memoryMapItem, bool registersAreFiltered) const;\r\n\r\n    /*!\r\n     *  Set the positions for the labels.\r\n     */\r\n    virtual void setLabelPositions();\r\n\r\n    /*!\r\n     *  Create a new register graphics item.\r\n     *\r\n     *    @param [in] subMemoryItem   Memory item containing register data.\r\n     *    @param [in] isEmpty         Boolean value for an empty register.\r\n     *\r\n     *    @return The created register graphics item.\r\n     */\r\n    virtual MemoryDesignerChildGraphicsItem* createNewSubItem(QSharedPointer<MemoryItem const> subMemoryItem,\r\n        bool isEmpty);\r\n\r\n    /*!\r\n     *  Create a copy of the selected sub item.\r\n     *\r\n     *    @param [in] subItem   The selected sub item.\r\n     *\r\n     *    @return Copy of the selected sub item.\r\n     */\r\n    virtual MemoryDesignerChildGraphicsItem* createCopyOfSubItem(MemoryDesignerChildGraphicsItem* subItem) override final;\r\n\r\n    /*!\r\n     *  Create an empty register graphics item.\r\n     *\r\n     *    @param [in] beginAddress    Base address of the empty register graphics item.\r\n     *    @param [in] rangeEnd        End address of the empty register graphics item.\r\n     *\r\n     *    @return The created register graphics item.\r\n     */\r\n    virtual MemoryDesignerChildGraphicsItem* createEmptySubItem(quint64 beginAddress, quint64 rangeEnd);\r\n\r\n    /*!\r\n     *  Get the width of the available area used by the address block item.\r\n     *\r\n     *    @return The width of the available area used by the address block item.\r\n     */\r\n    virtual qreal getItemWidth() const;\r\n\r\n    /*!\r\n     *  Get the width for the register graphics items.\r\n     *\r\n     *    @return Width for the register graphics items.\r\n     */\r\n    qreal getRegisterWidth() const;\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! Address unit bits of the containing memory map.\r\n    QString addressUnitBits_;\r\n\r\n    //! Filtering value for register fields.\r\n    bool filterFields_;\r\n\r\n    //! Flag for empty address blocks.\r\n    bool isEmpty_;\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n\r\n#endif // ADDRESSBLOCKGRAPHICSITEM_H\r\n"
  },
  {
    "path": "editors/MemoryDesigner/AddressSegmentGraphicsItem.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: AddressSegmentGraphicsItem.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Mikko Teuho\r\n// Date: 16.09.2016\r\n//\r\n// Description:\r\n// Graphics item for visualizing an address segment in the memory designer.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"AddressSegmentGraphicsItem.h\"\r\n\r\n#include <common/KactusColors.h>\r\n\r\n#include <editors/MemoryDesigner/MemoryItem.h>\r\n#include <editors/MemoryDesigner/AddressSpaceGraphicsItem.h>\r\n\r\n#include <QBrush>\r\n#include <QFont>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressSegmentGraphicsItem::AddressSegmentGraphicsItem()\r\n//-----------------------------------------------------------------------------\r\nAddressSegmentGraphicsItem::AddressSegmentGraphicsItem(QSharedPointer<MemoryItem const> segmentItem,\r\n    bool isEmptySegment, QVector<QString> identifierChain,\r\n    QSharedPointer<ConnectivityComponent const> containingInstance, AddressSpaceGraphicsItem* spaceItem):\r\nMemoryDesignerChildGraphicsItem(segmentItem, QStringLiteral(\"Segment\"), segmentItem->getOffset().toULongLong(),\r\n    segmentItem->getRange().toULongLong(), getSegmentItemWidth(spaceItem), identifierChain, containingInstance,\r\n    spaceItem),\r\nisEmptySegment_(isEmptySegment)\r\n{\r\n    setupSegment();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressSegmentGraphicsItem::AddressSegmentGraphicsItem()\r\n//-----------------------------------------------------------------------------\r\nAddressSegmentGraphicsItem::AddressSegmentGraphicsItem(AddressSegmentGraphicsItem const& other, AddressSpaceGraphicsItem* parentItem) :\r\nMemoryDesignerChildGraphicsItem(other, parentItem),\r\nisEmptySegment_(other.isEmptySegment_)\r\n{\r\n    setupSegment();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressSegmentGraphicsItem::setupSegment()\r\n//-----------------------------------------------------------------------------\r\nvoid AddressSegmentGraphicsItem::setupSegment()\r\n{\r\n    setColors(KactusColors::ADDRESS_SEGMENT, isEmptySegment_);\r\n    setLabelPositions();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressSegmentGraphicsItem::~AddressSegmentGraphicsItem()\r\n//-----------------------------------------------------------------------------\r\nAddressSegmentGraphicsItem::~AddressSegmentGraphicsItem()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressSegmentGraphicsItem::getSegmentItemWidth()\r\n//-----------------------------------------------------------------------------\r\nqreal AddressSegmentGraphicsItem::getSegmentItemWidth(AddressSpaceGraphicsItem* addressSpaceItem) const\r\n{\r\n    qreal segmentWidth = addressSpaceItem->boundingRect().width() / 2;\r\n    return segmentWidth;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressSegmentGraphicsItem::setLabelPositions()\r\n//-----------------------------------------------------------------------------\r\nvoid AddressSegmentGraphicsItem::setLabelPositions()\r\n{\r\n    QRectF itemRectangle = boundingRect();\r\n    QRectF nameRectange = getNameLabel()->boundingRect();\r\n\r\n    qreal nameX = itemRectangle.right() - nameRectange.width();\r\n    qreal nameY = (itemRectangle.height() / 2) - (nameRectange.height() / 2);\r\n\r\n    getNameLabel()->setPos(nameX, nameY);\r\n\r\n    qreal rangeEndX = itemRectangle.bottomLeft().x();\r\n    qreal rangeEndY = itemRectangle.bottomLeft().y() - getRangeEndLabel()->boundingRect().height();\r\n\r\n    getRangeStartLabel()->setPos(itemRectangle.topLeft());\r\n    if (!getRangeStartLabel()->isVisible())\r\n    {\r\n        rangeEndY += 2;\r\n    }\r\n    getRangeEndLabel()->setPos(rangeEndX, rangeEndY);\r\n}\r\n"
  },
  {
    "path": "editors/MemoryDesigner/AddressSegmentGraphicsItem.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: AddressSegmentGraphicsItem.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Mikko Teuho\r\n// Date: 16.09.2016\r\n//\r\n// Description:\r\n// Graphics item for visualizing an address segment in the memory designer.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef ADDRESSSEGMENTGRAPHICSITEM_H\r\n#define ADDRESSSEGMENTGRAPHICSITEM_H\r\n\r\n#include <common/graphicsItems/GraphicsItemTypes.h>\r\n#include <editors/MemoryDesigner/MemoryDesignerChildGraphicsItem.h>\r\n\r\nclass MemoryItem;\r\nclass AddressSpaceGraphicsItem;\r\n\r\n#include <QSharedPointer>\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Graphics item for visualizing an address segment in the memory designer.\r\n//-----------------------------------------------------------------------------\r\nclass AddressSegmentGraphicsItem : public MemoryDesignerChildGraphicsItem\r\n{\r\n\r\npublic:\r\n    //! The type of the address segment graphics item.\r\n    enum { Type = GFX_TYPE_ADDRESS_SECTION_ITEM };\r\n\r\n    /*!\r\n     *  The constructor.\r\n     *\r\n     *    @param [in] segmentItem         The memory item containing address segment data.\r\n     *    @param [in] isEmptySegment      Boolean value to inform of an empty segment.\r\n     *    @param [in] identifierChain     Chain of strings identifying this item.\r\n     *    @param [in] containingInstance  Name of the containing component instance.\r\n     *    @param [in] spaceItem           The address space item containing the address segment.\r\n     */\r\n    AddressSegmentGraphicsItem(QSharedPointer<MemoryItem const> segmentItem, bool isEmptySegment,\r\n        QVector<QString> identifierChain, QSharedPointer<ConnectivityComponent const> containingInstance,\r\n        AddressSpaceGraphicsItem* spaceItem);\r\n\r\n    /*!\r\n     *  The copy constructor.\r\n     *\r\n     *    @param [in] other         The original address segment item.\r\n     *    @param [in] parentItem    The parent address space item.\r\n     *\r\n     *    @return Copy of the original address segment item.\r\n     */\r\n    AddressSegmentGraphicsItem(AddressSegmentGraphicsItem const& other, AddressSpaceGraphicsItem* parentItem);\r\n\r\n\t/*!\r\n     *  The destructor.\r\n     */\r\n    virtual ~AddressSegmentGraphicsItem();\r\n\r\n    /*!\r\n     *  Get the type of the address segment graphics item.\r\n     */\r\n    int type() const { return Type; }\r\n\r\nprivate:\r\n    // Disable copying.\r\n    AddressSegmentGraphicsItem(AddressSegmentGraphicsItem const& rhs);\r\n    AddressSegmentGraphicsItem& operator=(AddressSegmentGraphicsItem const& rhs);\r\n\r\n    /*!\r\n     *  Setup the address segment item.\r\n     */\r\n    void setupSegment();\r\n\r\n    /*!\r\n     *  Get the width of the address segment item.\r\n     *\r\n     *    @param [in] addressSpaceItem   [Description].\r\n     */\r\n    qreal getSegmentItemWidth(AddressSpaceGraphicsItem* addressSpaceItem) const;\r\n\r\n    /*!\r\n     *  Set the positions for the labels.\r\n     */\r\n    virtual void setLabelPositions();\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! Flag for empty address segment.\r\n    bool isEmptySegment_ = false;\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n\r\n\r\n#endif // ADDRESSSPACEGRAPHICSITEM_H\r\n"
  },
  {
    "path": "editors/MemoryDesigner/AddressSpaceGraphicsItem.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: AddressSpaceGraphicsItem.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Mikko Teuho\r\n// Date: 08.07.2016\r\n//\r\n// Description:\r\n// Graphics item for visualizing an address space in the memory designer.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"AddressSpaceGraphicsItem.h\"\r\n\r\n#include <common/KactusColors.h>\r\n\r\n#include <editors/MemoryDesigner/MemoryItem.h>\r\n#include <editors/MemoryDesigner/ConnectivityComponent.h>\r\n#include <editors/MemoryDesigner/AddressSegmentGraphicsItem.h>\r\n#include <editors/MemoryDesigner/MemoryDesignerConstants.h>\r\n#include <editors/MemoryDesigner/MemoryConnectionItem.h>\r\n#include <editors/MemoryDesigner/MemoryExtensionGraphicsItem.h>\r\n\r\n#include <QBrush>\r\n#include <QFont>\r\n#include <QPen>\r\n#include <QtMath>\r\n\r\nnamespace AddressSpaceItemConstants\r\n{\r\n    const int MINIMUMSUBITEMHEIGHT = 3 * MemoryDesignerConstants::RANGEINTERVAL;\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressSpaceGraphicsItem::AddressSpaceGraphicsItem()\r\n//-----------------------------------------------------------------------------\r\nAddressSpaceGraphicsItem::AddressSpaceGraphicsItem(QSharedPointer<MemoryItem const> memoryItem,\r\n    QVector<QString> identifierChain, QSharedPointer<ConnectivityComponent const> containingInstance,\r\n    bool filterSegments, QGraphicsItem* parent):\r\nMainMemoryGraphicsItem(memoryItem, containingInstance, MemoryDesignerConstants::ADDRESSSEGMENT_TYPE,\r\n    filterSegments, identifierChain, parent),\r\ncpuIcon_(new QGraphicsPixmapItem(QPixmap(\":icons/common/graphics/settings-code_editor.png\"), this))\r\n{\r\n    QBrush addressSpaceBrush(KactusColors::ADDRESS_SEGMENT);\r\n    setBrush(addressSpaceBrush);\r\n\r\n    spaceRangeInt_ = memoryItem->getRange().toULongLong();\r\n    int spaceWidth = MemoryDesignerConstants::ITEMWIDTH;\r\n\r\n    setGraphicsRectangle(spaceWidth + 1, spaceRangeInt_);\r\n\r\n    setupGraphicsItem(0, spaceRangeInt_ - 1, QStringLiteral(\"Address Space\"));\r\n\r\n    cpuIcon_->setPos(spaceWidth / 2 - cpuIcon_->pixmap().width() - GridSize, GridSize * 3);\r\n    cpuIcon_->setVisible(false);\r\n\r\n    qreal segmentPositionX = - MemoryDesignerConstants::MAPSUBITEMPOSITIONX - 1;\r\n    setupSubItems(segmentPositionX, getSubItemType(), memoryItem);\r\n\r\n    setLabelPositions();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressSpaceGraphicsItem::AddressSpaceGraphicsItem()\r\n//-----------------------------------------------------------------------------\r\nAddressSpaceGraphicsItem::AddressSpaceGraphicsItem(AddressSpaceGraphicsItem const& other):\r\nMainMemoryGraphicsItem(other),\r\ncpuIcon_(new QGraphicsPixmapItem(QPixmap(\":icons/common/graphics/settings-code_editor.png\"), this)),\r\nspaceRangeInt_(other.spaceRangeInt_)\r\n{\r\n    setBrush(other.brush());\r\n\r\n    int spaceWidth = MemoryDesignerConstants::ITEMWIDTH;\r\n\r\n    setGraphicsRectangle(spaceWidth + 1, spaceRangeInt_);\r\n    setupGraphicsItem(0, spaceRangeInt_ - 1, QStringLiteral(\"Address Space\"));\r\n\r\n    cpuIcon_->setPos(spaceWidth / 2 - cpuIcon_->pixmap().width() - GridSize, GridSize * 3);\r\n    cpuIcon_->setVisible(false);\r\n\r\n    cloneSubItems(other);\r\n    setLabelPositions();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressSpaceGraphicsItem::setLabelPositions()\r\n//-----------------------------------------------------------------------------\r\nvoid AddressSpaceGraphicsItem::setLabelPositions()\r\n{\r\n    qreal nameLabelY = boundingRect().height() / 2 - (getNameLabel()->boundingRect().height() * 3 / 4);\r\n    qreal instanceNameLabelY = nameLabelY + (getNameLabel()->boundingRect().height() / 2);\r\n\r\n    qreal nameLabelX = 0;\r\n    if (subItemsAreFiltered())\r\n    {\r\n        nameLabelX = boundingRect().left();\r\n    }\r\n\r\n    getNameLabel()->setPos(nameLabelX, nameLabelY);\r\n    getInstanceNameLabel()->setPos(nameLabelX, instanceNameLabelY);\r\n\r\n    fitLabel(getNameLabel());\r\n    fitLabel(getInstanceNameLabel());\r\n\r\n    qreal rangeStartLabelX = boundingRect().right() - getRangeStartLabel()->boundingRect().width();\r\n    qreal rangeStartLabelY = boundingRect().top();\r\n    qreal rangeEndLabelX = boundingRect().right() - getRangeEndLabel()->boundingRect().width();\r\n    qreal rangeEndLabelY = boundingRect().bottom() - getRangeEndLabel()->boundingRect().height();\r\n\r\n    getRangeStartLabel()->setPos(rangeStartLabelX, rangeStartLabelY);\r\n    getRangeEndLabel()->setPos(rangeEndLabelX, rangeEndLabelY);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressSpaceGraphicsItem::createNewSubItem()\r\n//-----------------------------------------------------------------------------\r\nMemoryDesignerChildGraphicsItem* AddressSpaceGraphicsItem::createNewSubItem(\r\n    QSharedPointer<MemoryItem const> subMemoryItem, bool isEmpty)\r\n{\r\n    auto segmentItem = new AddressSegmentGraphicsItem(subMemoryItem, isEmpty, getIdentifierChain(), getContainingInstance(), this);\r\n\r\n    connect(segmentItem, SIGNAL(openComponentDocument(VLNV const&, QVector<QString>)),\r\n        this, SIGNAL(openComponentDocument(VLNV const&, QVector<QString>)), Qt::UniqueConnection);\r\n\r\n    return segmentItem;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressSpaceGraphicsItem::createEmptySubItem()\r\n//-----------------------------------------------------------------------------\r\nMemoryDesignerChildGraphicsItem* AddressSpaceGraphicsItem::createEmptySubItem(quint64 beginAddress,\r\n    quint64 rangeEnd)\r\n{\r\n    QString emptySegmentOffset = QString::number(beginAddress);\r\n    QString emptySegmentRange = QString::number(rangeEnd - beginAddress + 1);\r\n\r\n    QSharedPointer<MemoryItem> emptySegment(new MemoryItem(\"Empty\", MemoryDesignerConstants::ADDRESSSEGMENT_TYPE));\r\n    emptySegment->setOffset(emptySegmentOffset);\r\n    emptySegment->setRange(emptySegmentRange);\r\n\r\n    return createNewSubItem(emptySegment, true);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressSpaceGraphicsItem::createCopyOfSubItem()\r\n//-----------------------------------------------------------------------------\r\nMemoryDesignerChildGraphicsItem* AddressSpaceGraphicsItem::createCopyOfSubItem(MemoryDesignerChildGraphicsItem* subItem)\r\n{\r\n    AddressSegmentGraphicsItem* clonedSegmentItem = nullptr;\r\n    auto segmentItem = dynamic_cast<AddressSegmentGraphicsItem*>(subItem);\r\n    if (segmentItem)\r\n    {\r\n        clonedSegmentItem = new AddressSegmentGraphicsItem(*segmentItem, this);\r\n\r\n        connect(clonedSegmentItem, SIGNAL(openComponentDocument(VLNV const&, QVector<QString>)),\r\n            this, SIGNAL(openComponentDocument(VLNV const&, QVector<QString>)), Qt::UniqueConnection);\r\n    }\r\n\r\n    return clonedSegmentItem;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressSpaceGraphicsItem::getAllConnectedSpaceItems()\r\n//-----------------------------------------------------------------------------\r\nQVector<MainMemoryGraphicsItem*> AddressSpaceGraphicsItem::getAllConnectedSpaceItems() const\r\n{\r\n    QVector<MainMemoryGraphicsItem*> allConnectedSpaceItems;\r\n\r\n    QSharedPointer<QVector<MainMemoryGraphicsItem*> > visitedItems (new QVector<MainMemoryGraphicsItem*> ());\r\n\r\n    QMultiMap<quint64, MemoryConnectionItem*> allConnections = getAllConnectionsFromConnectedItems(visitedItems);\r\n    QMultiMapIterator<quint64, MemoryConnectionItem*> connectionIterator (allConnections);\r\n    while (connectionIterator.hasNext())\r\n    {\r\n        connectionIterator.next();\r\n\r\n        MemoryConnectionItem const* connectionItem = connectionIterator.value();\r\n        if (auto connectionStartItem = connectionItem->getConnectionStartItem();\r\n            connectionStartItem && connectionStartItem != this &&\r\n            dynamic_cast<AddressSpaceGraphicsItem*>(connectionStartItem) &&\r\n            !allConnectedSpaceItems.contains(connectionStartItem))\r\n        {\r\n            allConnectedSpaceItems.append(connectionStartItem);\r\n        }\r\n\r\n        if (auto connectionEndItem = connectionItem->getConnectionEndItem();\r\n            connectionEndItem && connectionEndItem != this &&\r\n            dynamic_cast<AddressSpaceGraphicsItem*>(connectionEndItem) &&\r\n            !allConnectedSpaceItems.contains(connectionEndItem))\r\n        {\r\n            allConnectedSpaceItems.append(connectionEndItem);\r\n        }\r\n    }\r\n\r\n    return allConnectedSpaceItems;\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AddressSpaceGraphicsItem::getMinimumHeightForSubItems()\r\n//-----------------------------------------------------------------------------\r\nqreal AddressSpaceGraphicsItem::getMinimumHeightForSubItems() const\r\n{\r\n    return AddressSpaceItemConstants::MINIMUMSUBITEMHEIGHT;\r\n}\r\n"
  },
  {
    "path": "editors/MemoryDesigner/AddressSpaceGraphicsItem.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: AddressSpaceGraphicsItem.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Mikko Teuho\r\n// Date: 08.07.2016\r\n//\r\n// Description:\r\n// Graphics item for visualizing an address space in the memory designer.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef ADDRESSSPACEGRAPHICSITEM_H\r\n#define ADDRESSSPACEGRAPHICSITEM_H\r\n\r\n#include <common/graphicsItems/GraphicsItemTypes.h>\r\n\r\n#include <editors/MemoryDesigner/MainMemoryGraphicsItem.h>\r\n\r\nclass AddressSpace;\r\nclass MemoryItem;\r\nclass ConnectivityComponent;\r\nclass AddressSegmentGraphicsItem;\r\n\r\n#include <QSharedPointer>\r\n#include <QGraphicsPixmapItem>\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Graphics item for visualizing address spaces in the memory designer.\r\n//-----------------------------------------------------------------------------\r\nclass AddressSpaceGraphicsItem : public MainMemoryGraphicsItem\r\n{\r\n\r\npublic:\r\n\r\n    //! The type of the address space graphics item.\r\n    enum { Type = GFX_TYPE_ADDRESS_SPACE_ITEM };\r\n\r\n    /*!\r\n     *  The constructor.\r\n     *\r\n     *    @param [in] memoryItem          Memory item containing address space data.\r\n     *    @param [in] identifierChain     Chain of strings identifying this item.\r\n     *    @param [in] containingInstance  Data of the containing component instance.\r\n     *    @param [in] filterSegments      Value for filtering address space segments.\r\n     *    @param [in] parent              The parent item.\r\n     */\r\n    AddressSpaceGraphicsItem(QSharedPointer<MemoryItem const> memoryItem, QVector<QString> identifierChain,\r\n        QSharedPointer<ConnectivityComponent const> containingInstance, bool filterSegments,\r\n        QGraphicsItem* parent = 0);\r\n\r\n    /*!\r\n     *  The copy constructor.\r\n     *\r\n     *    @param [in] other     The original address space item.\r\n     *\r\n     *    @return Copy of the original address space item.\r\n     */\r\n    AddressSpaceGraphicsItem(AddressSpaceGraphicsItem const& other);\r\n\r\n    // Disable copying.\r\n    AddressSpaceGraphicsItem& operator=(AddressSpaceGraphicsItem const& rhs) = delete;\r\n\r\n\t/*!\r\n     *  The destructor.\r\n     */\r\n    virtual ~AddressSpaceGraphicsItem() = default;\r\n\r\n    /*!\r\n     *  Get the type of the address space graphics item.\r\n     */\r\n    int type() const { return Type; }\r\n\r\n    /*!\r\n     *  Get all the address space graphics items connected to the origin item.\r\n     */\r\n    QVector<MainMemoryGraphicsItem*> getAllConnectedSpaceItems() const;\r\n\r\nprivate:\r\n\r\n    /*!\r\n     *  Set the positions of the labels.\r\n     */\r\n    virtual void setLabelPositions() override;\r\n\r\n    /*!\r\n     *  Create a new address segment graphics item.\r\n     *\r\n     *    @param [in] subMemoryItem   Memory item containing address segment data.\r\n     *    @param [in] isEmpty         Boolean value for an empty address segment.\r\n     *\r\n     *    @return The created address segment graphics item.\r\n     */\r\n    virtual MemoryDesignerChildGraphicsItem* createNewSubItem(QSharedPointer<MemoryItem const> subMemoryItem,\r\n        bool isEmpty) override;\r\n\r\n    /*!\r\n     *  Create an empty address segment graphics item.\r\n     *\r\n     *    @param [in] beginAddress    Base address of the empty address segment graphics item.\r\n     *    @param [in] rangeEnd        End address of the empty address segment graphics item.\r\n     *\r\n     *    @return The created address segment graphics item.\r\n     */\r\n    virtual MemoryDesignerChildGraphicsItem* createEmptySubItem(quint64 beginAddress, quint64 rangeEnd) override;\r\n\r\n    /*!\r\n     *  Create a copy of the selected sub item.\r\n     *\r\n     *    @param [in] subItem   The selected sub item.\r\n     *\r\n     *    @return Copy of the selected sub item.\r\n     */\r\n    virtual MemoryDesignerChildGraphicsItem* createCopyOfSubItem(MemoryDesignerChildGraphicsItem* subItem) override final;\r\n\r\n    /*!\r\n     *  Get the minimum height required to display for the memory item.\r\n     *\t\r\n     *    @return The minimum height required to display the memory item.\r\n     */\r\n    virtual qreal getMinimumHeightForSubItems() const override final;\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! The icon for an address space with a CPU.\r\n    QGraphicsPixmapItem* cpuIcon_;\r\n\r\n    //! Range of the address space item.\r\n    quint64 spaceRangeInt_ = 0;\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n\r\n#endif // ADDRESSSPACEGRAPHICSITEM_H\r\n"
  },
  {
    "path": "editors/MemoryDesigner/ConnectivityComponent.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ConnectivityComponent.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Esko Pekkarinen\r\n// Date: 03.08.2016\r\n//\r\n// Description:\r\n// A component instance in a connectivity graph.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"ConnectivityComponent.h\"\r\n\r\n#include \"MemoryItem.h\"\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ConnectivityComponent::ConnectivityComponent()\r\n//-----------------------------------------------------------------------------\r\nConnectivityComponent::ConnectivityComponent(QString const& name):\r\nname_(name),\r\nvlnv_(),\r\nuuid_(),\r\nactiveView_(),\r\nchanneled_(false),\r\nmemories_()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ConnectivityComponent::~ConnectivityComponent()\r\n//-----------------------------------------------------------------------------\r\nConnectivityComponent::~ConnectivityComponent()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ConnectivityComponent::setName()\r\n//-----------------------------------------------------------------------------\r\nvoid ConnectivityComponent::setName(QString const& newName)\r\n{\r\n    name_ = newName;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ConnectivityComponent::getName()\r\n//-----------------------------------------------------------------------------\r\nQString ConnectivityComponent::getName() const\r\n{\r\n    return name_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ConnectivityComponent::setDescription()\r\n//-----------------------------------------------------------------------------\r\nvoid ConnectivityComponent::setDescription(QString const& newDescription)\r\n{\r\n    description_ = newDescription;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ConnectivityComponent::getDescription()\r\n//-----------------------------------------------------------------------------\r\nQString ConnectivityComponent::getDescription() const\r\n{\r\n    return description_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ConnectivityComponent::setInstanceUuid()\r\n//-----------------------------------------------------------------------------\r\nvoid ConnectivityComponent::setInstanceUuid(QString const& uuid)\r\n{\r\n    uuid_ = uuid;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ConnectivityComponent::getInstanceUuid()\r\n//-----------------------------------------------------------------------------\r\nQString ConnectivityComponent::getInstanceUuid() const\r\n{\r\n    return uuid_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ConnectivityComponent::setVlnv()\r\n//-----------------------------------------------------------------------------\r\nvoid ConnectivityComponent::setVlnv(QString const& vlnv)\r\n{\r\n    vlnv_ = vlnv;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ConnectivityComponent::getVlnv()\r\n//-----------------------------------------------------------------------------\r\nQString ConnectivityComponent::getVlnv() const\r\n{\r\n    return vlnv_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ConnectivityComponent::setActiveView()\r\n//-----------------------------------------------------------------------------\r\nvoid ConnectivityComponent::setActiveView(QString const& viewName)\r\n{\r\n    activeView_ = viewName;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ConnectivityComponent::addMemory()\r\n//-----------------------------------------------------------------------------\r\nvoid ConnectivityComponent::addMemory(QSharedPointer<MemoryItem> spaceItem)\r\n{\r\n    memories_.append(spaceItem);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ConnectivityComponent::getMemories()\r\n//-----------------------------------------------------------------------------\r\nQVector<QSharedPointer<MemoryItem> > ConnectivityComponent::getMemories() const\r\n{\r\n    return memories_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ConnectivityComponent::setChanneled()\r\n//-----------------------------------------------------------------------------\r\nvoid ConnectivityComponent::setChanneled()\r\n{\r\n    channeled_ = true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ConnectivityComponent::isChanneled()\r\n//-----------------------------------------------------------------------------\r\nbool ConnectivityComponent::isChanneled() const\r\n{\r\n    return channeled_;\r\n}\r\n"
  },
  {
    "path": "editors/MemoryDesigner/ConnectivityComponent.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ConnectivityComponent.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Esko Pekkarinen\r\n// Date: 03.08.2016\r\n//\r\n// Description:\r\n// A component instance in a connectivity graph.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef INSTANCE_H\r\n#define INSTANCE_H\r\n\r\n#include <QSharedPointer>\r\n#include <QString>\r\n#include <QVector>\r\n\r\nclass MemoryItem;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! A component instance in a connectivity graph.\r\n//-----------------------------------------------------------------------------\r\nclass ConnectivityComponent \r\n{\r\npublic:\r\n\r\n\t/*!\r\n     *  The constructor.\r\n     *\r\n     *    @param [in] name    Name for the component instance.\r\n     */\r\n\tConnectivityComponent(QString const& name);\r\n\r\n\t/*!\r\n     *  The destructor.\r\n     */\r\n\t~ConnectivityComponent();\r\n\r\n    /*!\r\n     *  Set a new name for the component instance.\r\n     *\r\n     *    @param [in] newName     The new name.\r\n     */\r\n    void setName(QString const& newName);\r\n\r\n    /*!\r\n     *  Gets the name of the instance.\r\n     *\r\n     *    @return The instance name.\r\n     */\r\n    QString getName() const;\r\n\r\n    /*!\r\n     *  Set a new description for the component instance.\r\n     *\r\n     *    @param [in] newDescription    The new description.\r\n     */\r\n    void setDescription(QString const& newDescription);\r\n\r\n    /*!\r\n     *  Gets the description of the instance.\r\n     *\r\n     *    @return The instance description.\r\n     */\r\n    QString getDescription() const;\r\n\r\n    /*!\r\n     *  Sets the identifier for the instance.\r\n     *\r\n     *    @param [in] uuid   The identifier to set.\r\n     */\r\n    void setInstanceUuid(QString const& uuid);\r\n\r\n    /*!\r\n     *  Gets the identifier for the component instance.\r\n     *\r\n     *    @return The identifier for the instance.\r\n     */\r\n    QString getInstanceUuid() const;\r\n\r\n    /*!\r\n     *  Sets the instance VLNV identifier.\r\n     *\r\n     *    @param [in] vlnv   The VLNV to set.\r\n     */\r\n    void setVlnv(QString const& vlnv);\r\n\r\n    /*!\r\n     *  Gets the instance VLNV identifier.\r\n     *\r\n     *    @return The instance VLNV identifier.\r\n     */\r\n    QString getVlnv() const;\r\n\r\n    /*!\r\n     *  Sets the active view for the instance.\r\n     *\r\n     *    @param [in] viewName   The name of the active view to set.\r\n     */\r\n    void setActiveView(QString const& viewName);\r\n\r\n    /*!\r\n     *  Adds a memory associated with the instance.\r\n     *\r\n     *    @param [in] memory      The memory to add.\r\n     */\r\n    void addMemory(QSharedPointer<MemoryItem> memory);\r\n\r\n    /*!\r\n     *  Gets the associated memories for the instance.\r\n     *\r\n     *    @return The associated memories.\r\n     */\r\n    QVector<QSharedPointer<MemoryItem> > getMemories() const;\r\n\r\n    /*!\r\n     *  Marks the component as a channel.\r\n     */\r\n    void setChanneled();\r\n\r\n    /*!\r\n     *  Checks if the component is a channel.\r\n     *\r\n     *    @return True, if the component is a channel, otherwise false.\r\n     */\r\n    bool isChanneled() const;\r\n\r\nprivate:\r\n\r\n\t// Disable copying.\r\n\tConnectivityComponent(ConnectivityComponent const& rhs);\r\n\tConnectivityComponent& operator=(ConnectivityComponent const& rhs);\r\n\r\n    //! The name of the instance.\r\n    QString name_;\r\n\r\n    //! The description of the instance.\r\n    QString description_;\r\n\r\n    //! The VLNV of the instance.\r\n    QString vlnv_;\r\n\r\n    //! The unique identifier of the instance.\r\n    QString uuid_;\r\n\r\n    //! The name of the active view of the instance.\r\n    QString activeView_;\r\n\r\n    //! Whether the component is a channel or not.\r\n    bool channeled_;\r\n\r\n    //! Memories associated with the instance.\r\n    QVector<QSharedPointer<MemoryItem> > memories_;\r\n};\r\n\r\n#endif // INSTANCE_H\r\n"
  },
  {
    "path": "editors/MemoryDesigner/ConnectivityConnection.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ConnectivityConnection.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Esko Pekkarinen\r\n// Date: 03.08.2016\r\n//\r\n// Description:\r\n// A connection in a connectivity graph.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"ConnectivityConnection.h\"\r\n\r\n#include \"ConnectivityInterface.h\"\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ConnectivityConnection::ConnectivityConnection()\r\n//-----------------------------------------------------------------------------\r\nConnectivityConnection::ConnectivityConnection(QString const& name,\r\n    QSharedPointer<ConnectivityInterface> startPoint, QSharedPointer<ConnectivityInterface> endPoint):\r\nname_(name),\r\nfirstInterface_(startPoint),\r\nsecondInterface_(endPoint)\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ConnectivityConnection::~ConnectivityConnection()\r\n//-----------------------------------------------------------------------------\r\nConnectivityConnection::~ConnectivityConnection()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ConnectivityConnection::getName()\r\n//-----------------------------------------------------------------------------\r\nQString ConnectivityConnection::getName() const\r\n{\r\n    return name_;         \r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ConnectivityConnection::getFirstInterface()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<ConnectivityInterface> ConnectivityConnection::getFirstInterface() const\r\n{\r\n    return firstInterface_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ConnectivityConnection::getSecondInterface()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<ConnectivityInterface> ConnectivityConnection::getSecondInterface() const\r\n{\r\n    return secondInterface_;\r\n}\r\n"
  },
  {
    "path": "editors/MemoryDesigner/ConnectivityConnection.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ConnectivityConnection.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Esko Pekkarinen\r\n// Date: 03.08.2016\r\n//\r\n// Description:\r\n// A connection in a connectivity graph.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef CONNECTION_H\r\n#define CONNECTION_H\r\n\r\n#include <QSharedPointer>\r\n#include <QString>\r\n\r\nclass ConnectivityInterface;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! A connection in a connectivity graph.\r\n//-----------------------------------------------------------------------------\r\nclass ConnectivityConnection \r\n{\r\npublic:\r\n\r\n\t/*!\r\n\t *  The constructor.\r\n\t *\r\n\t *    @param [in] name        The name of the connection.\r\n\t *    @param [in] startPoint  The starting interface in the connection.\r\n\t *    @param [in] endPoint    The end interface in the connection.\r\n\t */\r\n    ConnectivityConnection(QString const& name, QSharedPointer<ConnectivityInterface> startPoint,\r\n        QSharedPointer<ConnectivityInterface> endPoint);\r\n\r\n\t/*!\r\n     *  The destructor.\r\n     */\r\n\t~ConnectivityConnection();\r\n\r\n    /*!\r\n     *  Gets the name of the connection.\r\n     *\r\n     *    @return The name of the connection.\r\n     */\r\n    QString getName() const;\r\n\r\n    /*!\r\n     *  Gets the first interface in the connection.\r\n     *\r\n     *    @return The first interface in the connection.\r\n     */\r\n    QSharedPointer<ConnectivityInterface> getFirstInterface() const;\r\n\r\n    /*!\r\n     *  Gets the second interface in the connection.\r\n     *\r\n     *    @return The second interface in the connection.\r\n     */\r\n    QSharedPointer<ConnectivityInterface> getSecondInterface() const;\r\n\r\nprivate:\r\n\r\n\t// Disable copying.\r\n\tConnectivityConnection(ConnectivityConnection const& rhs);\r\n\tConnectivityConnection& operator=(ConnectivityConnection const& rhs);\r\n\r\n    //! The name of the connection.\r\n    QString name_;\r\n\r\n    //! The first interface in the connection.\r\n    QSharedPointer<ConnectivityInterface> firstInterface_;\r\n\r\n    //! The second interface in the connection.\r\n    QSharedPointer<ConnectivityInterface> secondInterface_;\r\n};\r\n\r\n#endif // CONNECTION_H\r\n"
  },
  {
    "path": "editors/MemoryDesigner/ConnectivityGraph.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ConnectivityGraph.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Esko Pekkarinen\r\n// Date: 12.08.2016\r\n//\r\n// Description:\r\n// Graph for representing component connectivity through design hierarchies.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"ConnectivityGraph.h\"\r\n\r\n#include \"ConnectivityConnection.h\"\r\n#include \"ConnectivityInterface.h\"\r\n#include \"ConnectivityComponent.h\"\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ConnectivityGraph::ConnectivityGraph()\r\n//-----------------------------------------------------------------------------\r\nConnectivityGraph::ConnectivityGraph():\r\nvertices_(),\r\nedges_(),\r\ninstances_()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ConnectivityGraph::~ConnectivityGraph()\r\n//-----------------------------------------------------------------------------\r\nConnectivityGraph::~ConnectivityGraph()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ConnectivityGraph::getInterfaces()\r\n//-----------------------------------------------------------------------------\r\nQVector<QSharedPointer<ConnectivityInterface> >& ConnectivityGraph::getInterfaces() const\r\n{\r\n    return vertices_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ConnectivityGraph::getInstances()\r\n//-----------------------------------------------------------------------------\r\nQVector<QSharedPointer<ConnectivityComponent> >& ConnectivityGraph::getInstances() const\r\n{\r\n    return instances_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ConnectivityGraph::getConnectionsFor()\r\n//-----------------------------------------------------------------------------\r\nQVector<QSharedPointer<ConnectivityConnection const> > ConnectivityGraph::getConnectionsFor(\r\n    QSharedPointer<ConnectivityInterface const> startPoint) const\r\n{\r\n    QVector<QSharedPointer<ConnectivityConnection const> > connections;\r\n\r\n    for (int i = 0; i< edges_.size(); ++i)\r\n    {\r\n        QSharedPointer<ConnectivityConnection const> edge = edges_.at(i);\r\n        if (edge->getFirstInterface() == startPoint || edge->getSecondInterface() == startPoint)\r\n        {\r\n            connections.append(edge);\r\n        }\r\n    }\r\n\r\n    return connections;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ConnectivityGraph::getInterface()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<ConnectivityInterface const> ConnectivityGraph::getInterface(QString const& interfaceName,\r\n    QString const& instanceName) \r\n{\r\n    for (int i = 0; i < vertices_.size(); ++i)\r\n    {\r\n        QSharedPointer<ConnectivityInterface const> vertex = vertices_[i];\r\n        if (vertex->getName().compare(interfaceName) == 0 &&\r\n            vertex->getInstance()->getName().compare(instanceName) == 0)            \r\n        {\r\n            return vertex;\r\n        }\r\n    }\r\n\r\n    return QSharedPointer<ConnectivityInterface const>();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ConnectivityGraph::getConnections()\r\n//-----------------------------------------------------------------------------\r\nQVector<QSharedPointer<ConnectivityConnection> >& ConnectivityGraph::getConnections() const\r\n{\r\n    return edges_;\r\n}\r\n"
  },
  {
    "path": "editors/MemoryDesigner/ConnectivityGraph.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ConnectivityGraph.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Esko Pekkarinen\r\n// Date: 12.08.2016\r\n//\r\n// Description:\r\n// Graph for representing component connectivity through design hierarchies.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef CONNECTIVITYGRAPH_H\r\n#define CONNECTIVITYGRAPH_H\r\n\r\n#include <QSharedPointer>\r\n#include <QVector>\r\n\r\nclass ConnectivityConnection;\r\nclass ConnectivityInterface;\r\nclass ConnectivityComponent;\r\nclass MemoryItem;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Graph for representing component connectivity through design hierarchies.\r\n//-----------------------------------------------------------------------------\r\nclass ConnectivityGraph \r\n{\r\npublic:\r\n\r\n\t//! The constructor.\r\n\tConnectivityGraph();\r\n\r\n\t//! The destructor.\r\n\t~ConnectivityGraph();\r\n\r\n    /*!\r\n     *  Gets all interfaces (=vertices) in the graph.\r\n     *\r\n     *    @return All interfaces.\r\n     */\r\n    QVector<QSharedPointer<ConnectivityInterface> >& getInterfaces() const;\r\n\r\n    /*!\r\n     *  Gets all the instances in the graph.\r\n     *\r\n     *    @return All instances.\r\n     */\r\n    QVector<QSharedPointer<ConnectivityComponent> >& getInstances() const;\r\n    \r\n    /*!\r\n     *  Finds all connections for the given interface.\r\n     *\r\n     *    @param [in] startPoint   The interface to find connections for.\r\n     *\r\n     *    @return All connections to/from the given interface.\r\n     */\r\n    QVector<QSharedPointer<ConnectivityConnection const> > getConnectionsFor(\r\n        QSharedPointer<ConnectivityInterface const> startPoint) const;\r\n\r\n    /*!\r\n     *  Finds the interface with the given name in the given instance.\r\n     *\r\n     *    @param [in] instanceName    The name of the instance containing the interface.\r\n     *    @param [in] interfaceName   The name of the interface to find.\r\n     *\r\n     *    @return The found interface matching the given name and instance.\r\n     */\r\n    QSharedPointer<ConnectivityInterface const> getInterface(QString const& interfaceName,\r\n        QString const& instanceName);\r\n\r\n    /*!\r\n     *  Get all connections in the graph.\r\n     *\r\n     *    @return All connections in the graph.\r\n     */\r\n    QVector<QSharedPointer<ConnectivityConnection> >& getConnections() const;\r\n\r\nprivate:\r\n\r\n\t// Disable copying.\r\n\tConnectivityGraph(ConnectivityGraph const& rhs);\r\n\tConnectivityGraph& operator=(ConnectivityGraph const& rhs);\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! The vertices of the graph.\r\n    mutable QVector<QSharedPointer<ConnectivityInterface> > vertices_;\r\n\r\n    //! The edges of the graph.\r\n    mutable QVector<QSharedPointer<ConnectivityConnection> > edges_;\r\n\r\n    //! The component instances in the graph.\r\n    mutable QVector<QSharedPointer<ConnectivityComponent> > instances_;\r\n};\r\n\r\n#endif // CONNECTIVITYGRAPH_H\r\n"
  },
  {
    "path": "editors/MemoryDesigner/ConnectivityGraphFactory.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ConnectivityGraphFactory.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Mikko Teuho\r\n// Date: 08.07.2016\r\n//\r\n// Description:\r\n// Creates a connectivity graph from a given design and design configuration.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"ConnectivityGraphFactory.h\"\r\n\r\n#include <KactusAPI/include/LibraryInterface.h>\r\n\r\n#include \"ConnectivityConnection.h\"\r\n#include \"ConnectivityInterface.h\"\r\n#include \"ConnectivityComponent.h\"\r\n#include \"MemoryItem.h\"\r\n#include \"ConnectivityGraph.h\"\r\n\r\n#include <KactusAPI/include/IPXactSystemVerilogParser.h>\r\n#include <KactusAPI/include/ExpressionFormatter.h>\r\n#include <KactusAPI/include/ParameterCache.h>\r\n#include <KactusAPI/include/ListParameterFinder.h>\r\n#include <KactusAPI/include/MultipleParameterFinder.h>\r\n#include <KactusAPI/include/ComponentInstanceParameterFinder.h>\r\n#include <KactusAPI/include/DesignParameterFinder.h>\r\n\r\n#include <editors/MemoryDesigner/MemoryDesignerConstants.h>\r\n\r\n#include <IPXACTmodels/generaldeclarations.h>\r\n#include <IPXACTmodels/Component/AddressSpace.h>\r\n#include <IPXACTmodels/Component/AddressBlock.h>\r\n#include <IPXACTmodels/Component/SubSpaceMap.h>\r\n#include <IPXACTmodels/Component/BusInterface.h>\r\n#include <IPXACTmodels/Component/Channel.h>\r\n#include <IPXACTmodels/Component/Component.h>\r\n#include <IPXACTmodels/Component/Field.h>\r\n#include <IPXACTmodels/Component/FieldReset.h>\r\n#include <IPXACTmodels/Component/EnumeratedValue.h>\r\n#include <IPXACTmodels/Component/InitiatorInterface.h>\r\n#include <IPXACTmodels/Component/MemoryMap.h>\r\n#include <IPXACTmodels/Component/MemoryRemap.h>\r\n#include <IPXACTmodels/Component/MemoryMapBase.h>\r\n#include <IPXACTmodels/Component/MirroredTargetInterface.h>\r\n#include <IPXACTmodels/Component/RegisterBase.h>\r\n#include <IPXACTmodels/Component/Register.h>\r\n#include <IPXACTmodels/Component/TargetInterface.h>\r\n\r\n#include <IPXACTmodels/Design/Design.h>\r\n#include <IPXACTmodels/DesignConfiguration/DesignConfiguration.h>\r\n\r\n#include <IPXACTmodels/utilities/Search.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ConnectivityGraphFactory::ConnectivityGraphFactory()\r\n//-----------------------------------------------------------------------------\r\nConnectivityGraphFactory::ConnectivityGraphFactory(LibraryInterface* library):\r\nlibrary_(library),\r\nparameterFinder_(new MultipleParameterFinder()), \r\nexpressionParser_(new IPXactSystemVerilogParser(parameterFinder_)),\r\nformatter_(new ExpressionFormatter(parameterFinder_))\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ConnectivityGraphFactory::~ConnectivityGraphFactory()\r\n//-----------------------------------------------------------------------------\r\nConnectivityGraphFactory::~ConnectivityGraphFactory()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ConnectivityGraphFactory::createConnectivityGraph()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<ConnectivityGraph> ConnectivityGraphFactory::createConnectivityGraph(\r\n    QSharedPointer<const Component> topComponent, QString const& activeView)\r\n{\r\n    QSharedPointer<ConnectivityGraph> graph(new ConnectivityGraph());\r\n\r\n    if (topComponent)\r\n    {\r\n        parameterFinder_->addFinder(QSharedPointer<ParameterFinder>(new ParameterCache(topComponent)));\r\n\r\n        QSharedPointer<ConnectivityComponent> instanceNode =\r\n            createInstanceData(QSharedPointer<ComponentInstance>(0), topComponent, activeView, graph);\r\n\r\n        QVector<QSharedPointer<ConnectivityInterface> > instanceInterfaces =\r\n            createInterfacesForInstance(topComponent, instanceNode, graph);\r\n\r\n        createConnectionsForDesign(topComponent, activeView, instanceInterfaces, graph);\r\n    }\r\n\r\n    return graph;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ConnectivityGraphFactory::analyzeDesign()\r\n//-----------------------------------------------------------------------------\r\nvoid ConnectivityGraphFactory::analyzeDesign(QSharedPointer<DesignInstantiation> designInstantiation,\r\n    QSharedPointer<const Design> design, QSharedPointer<const DesignConfiguration> designConfiguration,\r\n    QVector<QSharedPointer<ConnectivityInterface>> const& topInterfaces, QSharedPointer<ConnectivityGraph> graph)\r\n    const\r\n{\r\n    QSharedPointer<DesignParameterFinder> designParameterFinder(new DesignParameterFinder(designInstantiation));\r\n    designParameterFinder->setParameterList(design->getParameters());\r\n\r\n    parameterFinder_->addFinder(designParameterFinder);\r\n\r\n    QVector<QSharedPointer<ConnectivityInterface> > interfacesInDesign;\r\n\r\n    for (QSharedPointer<ComponentInstance> componentInstance : *design->getComponentInstances())\r\n    {\r\n        QSharedPointer<Component const> instancedComponent = \r\n            library_->getModelReadOnly(*componentInstance->getComponentRef()).dynamicCast<Component const>();\r\n\r\n        if (instancedComponent)\r\n        {\r\n            QSharedPointer<ComponentInstanceParameterFinder> componentFinder(\r\n                new ComponentInstanceParameterFinder(componentInstance, instancedComponent));\r\n\r\n            parameterFinder_->addFinder(componentFinder);\r\n\r\n            QString activeView;\r\n            if (designConfiguration)\r\n            {\r\n                activeView = designConfiguration->getActiveView(componentInstance->getInstanceName());\r\n            }\r\n\r\n            QSharedPointer<ConnectivityComponent> instanceNode = createInstanceData(componentInstance, \r\n                instancedComponent, activeView, graph);\r\n\r\n            QVector<QSharedPointer<ConnectivityInterface> > instanceInterfaces =\r\n                createInterfacesForInstance(instancedComponent, instanceNode, graph);\r\n\r\n            createInternalConnectionsAndDesigns(instancedComponent, instanceNode,\r\n                componentInstance->getInstanceName(), activeView, instanceInterfaces, graph);\r\n\r\n            interfacesInDesign += instanceInterfaces;\r\n\r\n            parameterFinder_->removeFinder(componentFinder);\r\n        }\r\n    }\r\n\r\n    for (QSharedPointer<Interconnection> interconnection : *design->getInterconnections())\r\n    {\r\n        createConnectionsForInterconnection(interconnection, interfacesInDesign, topInterfaces, graph);\r\n    }\r\n\r\n    parameterFinder_->removeFinder(designParameterFinder);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ConnectivityGraphFactory::getInstanceData()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<ConnectivityComponent> ConnectivityGraphFactory::createInstanceData(\r\n    QSharedPointer<ComponentInstance> instance, QSharedPointer<const Component> component,\r\n    QString const& activeView, QSharedPointer<ConnectivityGraph> graph) const\r\n{\r\n    QSharedPointer<ConnectivityComponent> newInstance;\r\n    if (instance)\r\n    {\r\n        newInstance =\r\n            QSharedPointer<ConnectivityComponent>(new ConnectivityComponent(instance->getInstanceName()));\r\n        newInstance->setInstanceUuid(instance->getUuid());\r\n        newInstance->setVlnv(instance->getComponentRef()->toString());\r\n        newInstance->setDescription(instance->description());\r\n    }\r\n    else\r\n    {\r\n        newInstance = QSharedPointer<ConnectivityComponent>(new ConnectivityComponent(\"top\"));\r\n        newInstance->setInstanceUuid(\"top\");\r\n        newInstance->setVlnv(component->getVlnv().toString());\r\n        newInstance->setDescription(component->getDescription());\r\n    }\r\n\r\n    newInstance->setActiveView(activeView);\r\n\r\n    addAddressSpaceMemories(newInstance, component);\r\n\r\n    addMemoryMapMemories(newInstance, component);\r\n\r\n    graph->getInstances().append(newInstance);\r\n    return newInstance;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ConnectivityGraphFactory::addAddressSpaceMemories()\r\n//-----------------------------------------------------------------------------\r\nvoid ConnectivityGraphFactory::addAddressSpaceMemories(QSharedPointer<ConnectivityComponent> newInstance,\r\n    QSharedPointer<const Component> component) const\r\n{\r\n    QString instanceIdentifier = newInstance->getVlnv().replace(':', '.') + \".\" + newInstance->getInstanceUuid() +\r\n        \".\" + newInstance->getName();\r\n\r\n    for (QSharedPointer<AddressSpace> space : *component->getAddressSpaces())\r\n    {\r\n        if (space->getIsPresent().isEmpty() ||\r\n            expressionParser_->parseExpression(space->getIsPresent()).toInt() == 1)\r\n        {\r\n            QString spaceAUB = space->getAddressUnitBits();\r\n            QString spaceIdentifier = instanceIdentifier + \".\" + space->name();\r\n\r\n            QSharedPointer<MemoryItem> spaceItem(new MemoryItem(space->name(), MemoryDesignerConstants::ADDRESSSPACE_TYPE));\r\n            spaceItem->setIdentifier(spaceIdentifier);\r\n            spaceItem->setDisplayName(space->displayName());\r\n            spaceItem->setAUB(spaceAUB);\r\n            spaceItem->setAddress(\"0\");\r\n\r\n            if (!space->getRange().isEmpty())\r\n            {\r\n                spaceItem->setRange(expressionParser_->parseExpression(space->getRange()));\r\n            }\r\n\r\n            if (!space->getWidth().isEmpty())\r\n            {\r\n                spaceItem->setWidth(expressionParser_->parseExpression(space->getWidth()));\r\n            }\r\n\r\n            newInstance->addMemory(spaceItem);\r\n\r\n            for (QSharedPointer<Segment> segment : *space->getSegments())\r\n            {\r\n                if (segment->getIsPresent().isEmpty() ||\r\n                    expressionParser_->parseExpression(segment->getIsPresent()).toInt() == 1)\r\n                {\r\n                    QSharedPointer<MemoryItem> segmentItem(new MemoryItem(segment->name(), MemoryDesignerConstants::ADDRESSSEGMENT_TYPE));\r\n                    segmentItem->setIdentifier(spaceIdentifier + '.' + segment->name());\r\n                    segmentItem->setDisplayName(segment->displayName());\r\n                    segmentItem->setRange(expressionParser_->parseExpression(segment->getRange()));\r\n                    segmentItem->setOffset(expressionParser_->parseExpression(segment->getAddressOffset()));\r\n\r\n                    spaceItem->addChild(segmentItem);\r\n                }\r\n            }\r\n\r\n            if (space->hasLocalMemoryMap())\r\n            {\r\n                QSharedPointer<MemoryMapBase> localMap = space->getLocalMemoryMap();\r\n                int aubInInt = expressionParser_->parseExpression(spaceAUB).toInt();\r\n\r\n                QSharedPointer<MemoryItem> localMemoryItem = createMemoryMapData(localMap, aubInInt, newInstance);\r\n                spaceItem->addChild(localMemoryItem);\r\n            }\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ConnectivityGraphFactory::addMemoryMapMemories()\r\n//-----------------------------------------------------------------------------\r\nvoid ConnectivityGraphFactory::addMemoryMapMemories(QSharedPointer<ConnectivityComponent> instanceData,\r\n    QSharedPointer<const Component> component) const\r\n{\r\n    for (QSharedPointer<const MemoryMap> map : *component->getMemoryMaps())\r\n    {\r\n        if (map->getIsPresent().isEmpty() ||\r\n            expressionParser_->parseExpression(map->getIsPresent()).toInt() == 1)\r\n        {\r\n            int addressableUnitBits = expressionParser_->parseExpression(map->getAddressUnitBits()).toInt();\r\n            if (addressableUnitBits == 0)\r\n            {\r\n                addressableUnitBits = 8;\r\n            }\r\n\r\n            QSharedPointer<MemoryItem> mapItem = createMemoryMapData(map, addressableUnitBits, instanceData);\r\n            instanceData->addMemory(mapItem);\r\n\r\n            addMemoryRemapData(map, mapItem, addressableUnitBits, instanceData);\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ConnectivityGraphFactory::createMemoryMapData()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<MemoryItem> ConnectivityGraphFactory::createMemoryMapData(QSharedPointer<const MemoryMapBase> map,\r\n    int addressableUnitBits, QSharedPointer<ConnectivityComponent> containingInstance) const\r\n{\r\n    QString mapIdentifier = containingInstance->getVlnv().replace(':', '.') + \".\" + \r\n        containingInstance->getInstanceUuid() + \".\" + containingInstance->getName() + \".\" + map->name();\r\n\r\n    QSharedPointer<MemoryItem> mapItem(new MemoryItem(map->name(), MemoryDesignerConstants::MEMORYMAP_TYPE));\r\n    mapItem->setIdentifier(mapIdentifier);\r\n    mapItem->setDisplayName(map->displayName());\r\n    mapItem->setAUB(QString::number(addressableUnitBits));\r\n\r\n    General::Usage mapUsage = General::USAGE_COUNT;\r\n    for (QSharedPointer<MemoryBlockBase> block : *map->getMemoryBlocks())\r\n    {\r\n        if (block->getIsPresent().isEmpty() ||\r\n            expressionParser_->parseExpression(block->getIsPresent()).toInt() == 1)\r\n        {\r\n            QSharedPointer<MemoryItem> blockItem = createMemoryBlock(block, mapIdentifier, addressableUnitBits);\r\n            if (blockItem)\r\n            {\r\n                mapItem->addChild(blockItem);\r\n\r\n                QSharedPointer<AddressBlock> addressBlock = block.dynamicCast<AddressBlock>();\r\n                if (addressBlock)\r\n                {\r\n                    mapUsage = addressBlock->getUsage();\r\n                }\r\n            }\r\n        }\r\n    }\r\n\r\n    if (map->getMemoryBlocks()->size() == 1 && mapUsage == General::MEMORY)\r\n    {\r\n        mapItem->setUsage(General::MEMORY);\r\n    }\r\n\r\n    return mapItem;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ConnectivityGraphFactory::createMemoryBlock()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<MemoryItem> ConnectivityGraphFactory::createMemoryBlock(QSharedPointer<MemoryBlockBase> block,\r\n    QString const& mapIdentifier, int addressableUnitBits) const\r\n{\r\n    QSharedPointer<AddressBlock> addressBlock = block.dynamicCast<AddressBlock>();\r\n    if (addressBlock)\r\n    {\r\n        return createMemoryAddressBlockItem(addressBlock, mapIdentifier, addressableUnitBits);\r\n    }\r\n\r\n    QSharedPointer<SubSpaceMap> subspace = block.dynamicCast<SubSpaceMap>();\r\n    if (subspace)\r\n    {\r\n        return createMemorySubSpaceMapItem(subspace, mapIdentifier, addressableUnitBits);\r\n    }\r\n\r\n    return QSharedPointer<MemoryItem>();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ConnectivityGraphFactory::createMemoryAddressBlockItem()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<MemoryItem> ConnectivityGraphFactory::createMemoryAddressBlockItem(\r\n    QSharedPointer<const AddressBlock> addressBlock, QString const& mapIdentifier, int addressableUnitBits) const\r\n{\r\n    QString blockIdentifier = mapIdentifier + \".\" + addressBlock->name();\r\n\r\n    QSharedPointer<MemoryItem> blockItem(new MemoryItem(addressBlock->name(), MemoryDesignerConstants::ADDRESSBLOCK_TYPE));\r\n    blockItem->setIdentifier(blockIdentifier);\r\n    blockItem->setDisplayName(addressBlock->displayName());\r\n    blockItem->setDescription(addressBlock->description());\r\n    blockItem->setAUB(QString::number(addressableUnitBits));\r\n    blockItem->setUsage(addressBlock->getUsage());\r\n    blockItem->setAccess(addressBlock->getAccess());\r\n\r\n\tauto baseAddressString = addressBlock->getBaseAddress();\r\n    auto baseAddress = expressionParser_->parseExpression(baseAddressString);\r\n\tblockItem->setAddress(baseAddress);\r\n    if (expressionParser_->isPlainValue(baseAddressString) == false)\r\n    {\r\n        blockItem->setFormattedAddressExpression(formatter_->formatReferringExpression(baseAddressString));\r\n    }\r\n\r\n    auto blockRange = addressBlock->getRange();\r\n\tblockItem->setRange(expressionParser_->parseExpression(blockRange));\r\n    if (expressionParser_->isPlainValue(blockRange) == false)\r\n    {\r\n        blockItem->setFormattedRangeExpression(formatter_->formatReferringExpression(blockRange));\r\n    }\r\n\r\n    auto blockWidth = addressBlock->getWidth();\r\n\tblockItem->setWidth(expressionParser_->parseExpression(blockWidth));\r\n    if (expressionParser_->isPlainValue(blockWidth) == false)\r\n    {\r\n\t\tblockItem->setFormattedWidthExpression(formatter_->formatReferringExpression(blockWidth));\r\n    }\r\n\r\n    QString blockPresence = addressBlock->getIsPresent();\r\n    if (blockPresence.isEmpty())\r\n    {\r\n        blockPresence = \"1\";\r\n    }\r\n    else\r\n    {\r\n        blockPresence = expressionParser_->parseExpression(addressBlock->getIsPresent());\r\n    }\r\n\r\n    blockItem->setIsPresent(blockPresence);\r\n\r\n    for (QSharedPointer<RegisterBase> registerBase : *addressBlock->getRegisterData())\r\n    {\r\n        if (registerBase->getIsPresent().isEmpty() || \r\n            expressionParser_->parseExpression(registerBase->getIsPresent()).toInt() == 1)\r\n        {\r\n            QSharedPointer<Register> reg = registerBase.dynamicCast<Register>();\r\n            if (reg)\r\n            {\r\n                addRegisterData(reg, baseAddress.toULongLong(), addressableUnitBits, blockIdentifier, blockItem);\r\n            }\r\n\r\n            //! What about register files?\r\n        }\r\n    }\r\n\r\n    return blockItem;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ConnectivityGraphFactory::createMemorySubSpaceMapItem()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<MemoryItem> ConnectivityGraphFactory::createMemorySubSpaceMapItem(\r\n    QSharedPointer<const SubSpaceMap> subspace, QString const& mapIdentifier, int addressableUnitBits) const\r\n{\r\n    QString blockIdentifier = mapIdentifier + \".\" + subspace->name();\r\n    int baseAddress = expressionParser_->parseExpression(subspace->getBaseAddress()).toInt();\r\n\r\n    QSharedPointer<MemoryItem> blockItem(new MemoryItem(subspace->name(), MemoryDesignerConstants::SUBSPACEMAP_TYPE));\r\n    blockItem->setIdentifier(blockIdentifier);\r\n    blockItem->setAUB(QString::number(addressableUnitBits));\r\n    blockItem->setAddress(QString::number(baseAddress));\r\n\r\n    QString blockPresence = subspace->getIsPresent();\r\n    if (blockPresence.isEmpty())\r\n    {\r\n        blockPresence = \"1\";\r\n    }\r\n    else\r\n    {\r\n        blockPresence = expressionParser_->parseExpression(subspace->getIsPresent());\r\n    }\r\n\r\n    blockItem->setIsPresent(blockPresence);\r\n    blockItem->setInitiatorReference(subspace->getInitiatorReference());\r\n    blockItem->setSegmentReference(subspace->getSegmentReference());\r\n\r\n    return blockItem;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ConnectivityGraphFactory::addRegisterData()\r\n//-----------------------------------------------------------------------------\r\nvoid ConnectivityGraphFactory::addRegisterData(QSharedPointer<const Register> reg,\r\n    quint64 const& baseAddress, \r\n    int addressableUnitBits,\r\n    QString const& blockIdentifier,\r\n    QSharedPointer<MemoryItem> blockItem) const\r\n{\r\n    quint64 registerOffset = expressionParser_->parseExpression(reg->getAddressOffset()).toULongLong();\r\n    quint64 registerAddress = baseAddress + registerOffset;\r\n    int registerSize =  expressionParser_->parseExpression(reg->getSize()).toInt();\r\n    int registerDimension = expressionParser_->parseExpression(reg->getDimension()).toInt();\r\n\r\n    for (int i = 0; i < registerDimension || (i == 0 && registerDimension == 0); i++)\r\n    {\r\n        QString registerIdentifier = blockIdentifier + \".\" + reg->name();\r\n\r\n        QSharedPointer<MemoryItem> regItem(new MemoryItem(reg->name(), MemoryDesignerConstants::REGISTER_TYPE));\r\n\r\n        if (!reg->getDimension().isEmpty())\r\n        {\r\n            regItem->setDimension(QString::number(registerDimension));\r\n            registerIdentifier.append(QString(\"[%1]\").arg(i));\r\n        }\r\n\r\n        regItem->setIdentifier(registerIdentifier);\r\n        regItem->setDisplayName(reg->displayName());\r\n        regItem->setDescription(reg->description());\r\n        regItem->setAUB(QString::number(addressableUnitBits));\r\n        regItem->setAddress(QString::number(registerAddress));\r\n        regItem->setOffset(QString::number(registerOffset));\r\n        regItem->setSize(expressionParser_->parseExpression(reg->getSize()));\r\n\r\n        if (expressionParser_->isPlainValue(reg->getAddressOffset()) == false)\r\n        {\r\n            regItem->setFormattedOffsetExpression(formatter_->formatReferringExpression(reg->getAddressOffset()));\r\n        }\r\n\r\n        QVector<QSharedPointer<MemoryItem> > fieldItems;\r\n\r\n        for (QSharedPointer<Field> field : *reg->getFields())\r\n        {\r\n            if (field->getIsPresent().isEmpty() ||\r\n                expressionParser_->parseExpression(field->getIsPresent()).toInt() == 1)\r\n            {\r\n                fieldItems.append(createField(field, registerIdentifier, registerAddress, addressableUnitBits));\r\n            }\r\n        }\r\n\r\n        QMap<quint64, QSharedPointer<MemoryItem> > orderedFieldItems = getOrderedFieldItems(regItem, fieldItems);\r\n\r\n        QMapIterator<quint64, QSharedPointer<MemoryItem> > fieldIterator(orderedFieldItems);\r\n        while (fieldIterator.hasNext())\r\n        {\r\n            fieldIterator.next();\r\n            regItem->addChild(fieldIterator.value());\r\n        }\r\n\r\n        regItem->addChild(\r\n            createRegisterResetItem(orderedFieldItems, regItem, registerIdentifier, addressableUnitBits));\r\n\r\n        registerAddress += registerSize / addressableUnitBits;\r\n\r\n        blockItem->addChild(regItem);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ConnectivityGraphFactory::setOrderedFieldItemsForRegister()\r\n//-----------------------------------------------------------------------------\r\nQMap<quint64, QSharedPointer<MemoryItem> > ConnectivityGraphFactory::getOrderedFieldItems(\r\n    QSharedPointer<MemoryItem> registerItem, QVector<QSharedPointer<MemoryItem> > fieldItems) const\r\n{\r\n    quint64 registerOffset = registerItem->getAddress().toULongLong();\r\n    QMap<quint64, QSharedPointer<MemoryItem> > orderedFieldItems;\r\n\r\n    for (auto fieldItem : fieldItems)\r\n    {\r\n        quint64 fieldAddress = fieldItem->getAddress().toInt();\r\n        quint64 fieldStart = fieldItem->getOffset().toInt();\r\n\r\n        int aub = fieldItem->getAUB().toInt();\r\n\r\n        fieldStart = (fieldAddress - registerOffset) * aub + fieldStart;\r\n\r\n        orderedFieldItems.insert(fieldStart, fieldItem);\r\n    }\r\n\r\n    return orderedFieldItems;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ConnectivityGraphFactory::createField()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<MemoryItem> ConnectivityGraphFactory::createField(QSharedPointer<const Field> field, \r\n    QString const& registerIdentifier,\r\n    quint64 const& regAddress,\r\n    int addressableUnitBits) const\r\n{\r\n    QString fieldIdentifier = registerIdentifier + \".\" + field->name();\r\n    int bitOffset = expressionParser_->parseExpression(field->getBitOffset()).toInt();\r\n\r\n    QSharedPointer<MemoryItem> fieldItem(new MemoryItem(field->name(), MemoryDesignerConstants::FIELD_TYPE));\r\n    fieldItem->setIdentifier(fieldIdentifier);\r\n    fieldItem->setDisplayName(field->displayName());\r\n    fieldItem->setAUB(QString::number(addressableUnitBits));\r\n    fieldItem->setWidth(expressionParser_->parseExpression(field->getBitWidth()));\r\n    fieldItem->setAddress(QString::number(regAddress + bitOffset/addressableUnitBits));\r\n    fieldItem->setOffset(QString::number(bitOffset));\r\n\r\n    for (auto enumeratedValue : *field->getEnumeratedValues())\r\n    {\r\n        fieldItem->addChild(createEnumeratedValueItem(enumeratedValue, fieldIdentifier, addressableUnitBits));\r\n    }\r\n\r\n    for (auto reset : *field->getResets())\r\n    {\r\n        fieldItem->addChild(createFieldResetItem(reset, fieldIdentifier, addressableUnitBits, fieldItem->getWidth()));\r\n    }\r\n\r\n    return fieldItem;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ConnectivityGraphFactory::createEnumeratedValueItem()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<MemoryItem> ConnectivityGraphFactory::createEnumeratedValueItem(\r\n    QSharedPointer<const EnumeratedValue> enumeratedValue, QString const& fieldIdentifier,\r\n    int const& addressUnitBits) const\r\n{\r\n    QString enumName = enumeratedValue->name();\r\n    QString enumeratedValueIdentifier = fieldIdentifier + enumName;\r\n\r\n    QSharedPointer<MemoryItem> enumItem(new MemoryItem(enumName, MemoryDesignerConstants::ENUMERATED_VALUE_TYPE));\r\n    enumItem->setIdentifier(enumeratedValueIdentifier);\r\n    enumItem->setDisplayName(enumeratedValue->displayName());\r\n    enumItem->setAUB(QString::number(addressUnitBits));\r\n    enumItem->setValue(expressionParser_->parseExpression(enumeratedValue->getValue()));\r\n\r\n    return enumItem;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ConnectivityGraphFactory::createFieldResetItem()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<MemoryItem> ConnectivityGraphFactory::createFieldResetItem(QSharedPointer<FieldReset> fieldReset,\r\n    QString const& fieldIdentifier, int const& addressUnitBits, QString const& fieldWidth) const\r\n{\r\n    QString resetType = fieldReset->getResetTypeReference();\r\n    if (resetType.isEmpty())\r\n    {\r\n        resetType = MemoryDesignerConstants::HARD_RESET_TYPE;\r\n    }\r\n\r\n    QString resetIdentifier = fieldIdentifier + resetType;\r\n\r\n    QSharedPointer<MemoryItem> resetItem(new MemoryItem(resetType, MemoryDesignerConstants::RESET_TYPE));\r\n    resetItem->setIdentifier(resetIdentifier);\r\n    resetItem->setAUB(QString::number(addressUnitBits));\r\n\r\n    QString resetValue = expressionParser_->parseExpression(fieldReset->getResetValue());\r\n    qulonglong decimalResetValue = resetValue.toULongLong();\r\n    resetValue.setNum(decimalResetValue, 2);\r\n\r\n    QString resetMask;\r\n    if (fieldReset->getResetMask().isEmpty())\r\n    {\r\n        resetMask = QString(\"1\").repeated(fieldWidth.toInt());\r\n    } \r\n    else\r\n    {\r\n        resetMask = expressionParser_->parseExpression(fieldReset->getResetMask());\r\n        qulonglong decimalResetMask = resetMask.toULongLong();\r\n        resetMask.setNum(decimalResetMask, 2);\r\n    } \r\n\r\n    resetItem->setResetValue(resetValue);\r\n    resetItem->setResetMask(resetMask);\r\n\r\n    return resetItem;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ConnectivityGraphFactory::createRegisterResetItem()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<MemoryItem> ConnectivityGraphFactory::createRegisterResetItem(\r\n    QMap<quint64, QSharedPointer<MemoryItem>> fieldItems, QSharedPointer<MemoryItem> registerItem,\r\n    QString const& registerIdentifier, int const& addressUnitBits) const\r\n{\r\n    QString resetIdentifier = registerIdentifier + QStringLiteral(\".\") + MemoryDesignerConstants::HARD_RESET_TYPE;\r\n\r\n    QString resetValue = \"\";\r\n    QString resetMask = \"\";\r\n\r\n    QSharedPointer<MemoryItem> resetItem(\r\n        new MemoryItem(MemoryDesignerConstants::HARD_RESET_TYPE, MemoryDesignerConstants::RESET_TYPE));\r\n    resetItem->setIdentifier(resetIdentifier);\r\n    resetItem->setAUB(QString::number(addressUnitBits));\r\n\r\n    QMapIterator<quint64, QSharedPointer<MemoryItem> > fieldIterator(fieldItems);\r\n    quint64 currentEnd = 0;\r\n    while (fieldIterator.hasNext())\r\n    {\r\n        fieldIterator.next();\r\n        quint64 fieldStart = fieldIterator.key();\r\n        quint64 fieldEnd = 0;\r\n\r\n        QSharedPointer<MemoryItem> fieldItem = fieldIterator.value();\r\n        int fieldWidth = fieldItem->getWidth().toInt();\r\n\r\n        if (fieldWidth > 0)\r\n        {\r\n            fieldEnd = fieldStart + fieldWidth - 1;\r\n        }\r\n\r\n        if (currentEnd < fieldStart)\r\n        {\r\n            for (auto i = currentEnd; i < fieldStart; ++i )\r\n            {\r\n                resetValue.prepend(\"0\");\r\n                resetMask.prepend(\"0\");\r\n            }\r\n        }\r\n\r\n        QSharedPointer<MemoryItem> fieldResetItem = getHardResetItem(fieldItem);\r\n        if (fieldResetItem)\r\n        {\r\n            QString fieldResetValue = fieldResetItem->getResetValue();\r\n            QString fieldResetMask = fieldResetItem->getResetMask();\r\n\r\n            fieldResetValue = fieldResetValue.rightJustified(fieldWidth, '0', true);\r\n            fieldResetMask = fieldResetMask.rightJustified(fieldWidth, '0', true);\r\n\r\n            resetValue.prepend(fieldResetValue);\r\n            resetMask.prepend(fieldResetMask);\r\n        }\r\n        else\r\n        {\r\n            for (int i = 0; i < fieldWidth; ++i)\r\n            {\r\n                resetValue.prepend(\"0\");\r\n                resetMask.prepend(\"0\");\r\n            }\r\n        }\r\n        currentEnd = fieldEnd + 1;\r\n    }\r\n\r\n    quint64 registerSize = registerItem->getSize().toULongLong();\r\n    resetValue = resetValue.rightJustified(registerSize, '0', true);\r\n    resetMask = resetMask.rightJustified(registerSize, '0', true);\r\n\r\n    resetItem->setResetValue(resetValue);\r\n    resetItem->setResetMask(resetMask);\r\n\r\n    return resetItem;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ConnectivityGraphFactory::getHardResetItem()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<MemoryItem> ConnectivityGraphFactory::getHardResetItem(QSharedPointer<MemoryItem> containingItem)\r\n    const\r\n{\r\n    for (auto resetItem : containingItem->getChildItems())\r\n    {\r\n        if (resetItem->getType() == MemoryDesignerConstants::RESET_TYPE &&\r\n            resetItem->getName() == MemoryDesignerConstants::HARD_RESET_TYPE)\r\n        {\r\n            return resetItem;\r\n        }\r\n    }\r\n\r\n    return QSharedPointer<MemoryItem>();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ConnectivityGraphFactory::addMemoryRemapData()\r\n//-----------------------------------------------------------------------------\r\nvoid ConnectivityGraphFactory::addMemoryRemapData(QSharedPointer<const MemoryMap> map,\r\n    QSharedPointer<MemoryItem> mapItem, int addressableUnitBits,\r\n    QSharedPointer<ConnectivityComponent> containingInstance) const\r\n{\r\n    QString remapPrefix =  containingInstance->getVlnv().replace(':', '.') + \".\" +\r\n        containingInstance->getInstanceUuid() + \".\" + containingInstance->getName() + \".\";\r\n\r\n    for (QSharedPointer<MemoryRemap> remap : *map->getMemoryRemaps())\r\n    {\r\n        QString remapIdentifier = remapPrefix + remap->name();\r\n\r\n        QSharedPointer<MemoryItem> remapItem(new MemoryItem(remap->name(), MemoryDesignerConstants::MEMORYREMAP_TYPE));\r\n        remapItem->setDisplayName(remap->displayName());\r\n        remapItem->setIdentifier(remapIdentifier);\r\n        remapItem->setAUB(QString::number(addressableUnitBits));\r\n\r\n        mapItem->addChild(remapItem);\r\n\r\n        for (QSharedPointer<MemoryBlockBase> block : *remap->getMemoryBlocks())\r\n        {\r\n            if (block->getIsPresent().isEmpty() ||\r\n                expressionParser_->parseExpression(block->getIsPresent()).toInt() == 1)\r\n            {\r\n                QSharedPointer<MemoryItem> blockItem = createMemoryBlock(block, remapIdentifier, addressableUnitBits);\r\n                if (blockItem)\r\n                {\r\n                    remapItem->addChild(blockItem);\r\n                }\r\n            }\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ConnectivityGraphFactory::createInterfacesForInstance()\r\n//-----------------------------------------------------------------------------\r\nQVector<QSharedPointer<ConnectivityInterface> > ConnectivityGraphFactory::createInterfacesForInstance(\r\n    QSharedPointer<Component const> instancedComponent, QSharedPointer<ConnectivityComponent> instanceNode,\r\n    QSharedPointer<ConnectivityGraph> graph) const\r\n{\r\n    QVector<QSharedPointer<ConnectivityInterface> > instanceInterfaces;\r\n\r\n    for (QSharedPointer<const BusInterface> busInterface : *instancedComponent->getBusInterfaces())\r\n    {\r\n        QSharedPointer<ConnectivityInterface> node = createInterfaceData(busInterface, instanceNode, graph);\r\n        instanceInterfaces.append(node);\r\n    }\r\n\r\n    return instanceInterfaces;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ConnectivityGraphFactory::createInterfaceData()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<ConnectivityInterface> ConnectivityGraphFactory::createInterfaceData(\r\n    QSharedPointer<const BusInterface> busInterface, QSharedPointer<ConnectivityComponent> instanceNode,\r\n    QSharedPointer<ConnectivityGraph> graph) const\r\n{\r\n    QSharedPointer<ConnectivityInterface> interfaceNode(new ConnectivityInterface(busInterface->name()));\r\n    interfaceNode->setMode(busInterface->getInterfaceMode());\r\n    interfaceNode->setInstance(instanceNode);\r\n\r\n    QString memoryReference;\r\n    General::InterfaceMode busMode = busInterface->getInterfaceMode();\r\n\r\n    if (busMode == General::MASTER || busMode == General::INITIATOR)\r\n    {\r\n        interfaceNode->setBaseAddress(\r\n            expressionParser_->parseExpression(busInterface->getMaster()->getBaseAddress()));\r\n        memoryReference = busInterface->getAddressSpaceRef();\r\n    }\r\n    else if (busMode == General::SLAVE || busMode == General::TARGET)\r\n    {\r\n        memoryReference = busInterface->getMemoryMapRef();\r\n    }\r\n    else if ((busMode == General::MIRRORED_SLAVE || busMode == General::MIRRORED_TARGET) && !busInterface->getMirroredSlave()->getRemapAddresses()->isEmpty())\r\n    {\r\n        interfaceNode->setRemapAddress(expressionParser_->parseExpression(\r\n            busInterface->getMirroredSlave()->getRemapAddresses()->first()->remapAddress_));\r\n\r\n        interfaceNode->setRemapRange(\r\n            expressionParser_->parseExpression(busInterface->getMirroredSlave()->getRange()));\r\n    }\r\n\r\n    if (!memoryReference.isEmpty())\r\n    {\r\n        QVector<QSharedPointer<MemoryItem> > instanceMemories = instanceNode->getMemories();\r\n        for (int i = 0; i < instanceMemories.size(); ++i)\r\n        {\r\n            QSharedPointer<MemoryItem> memory = instanceMemories.at(i);\r\n            if (memory->getName().compare(memoryReference) == 0)\r\n            {\r\n                interfaceNode->setConnectedMemory(memory);\r\n            }\r\n        }\r\n    }\r\n\r\n    graph->getInterfaces().append(interfaceNode);\r\n    return interfaceNode;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ConnectivityGraphFactory::createInternalConnectionsAndDesigns()\r\n//-----------------------------------------------------------------------------\r\nvoid ConnectivityGraphFactory::createInternalConnectionsAndDesigns(\r\n    QSharedPointer<const Component> instancedComponent, QSharedPointer<ConnectivityComponent> instanceNode,\r\n    QString const& instanceName, QString const& activeView,\r\n    QVector<QSharedPointer<ConnectivityInterface> > instanceInterfaces, QSharedPointer<ConnectivityGraph> graph)\r\n    const\r\n{\r\n    if (!instancedComponent->getChannels()->isEmpty())\r\n    {\r\n        instanceNode->setChanneled();\r\n    }\r\n\r\n    for (QSharedPointer<Channel> channel : *instancedComponent->getChannels())\r\n    {\r\n        createInternalConnectionsForChannel(channel, instanceName, instanceInterfaces, graph);\r\n    }\r\n\r\n    for (QSharedPointer<BusInterface> busInterface : *instancedComponent->getBusInterfaces())\r\n    {\r\n        if (busInterface->hasTransparentBridge())\r\n        {\r\n            createInternalConnectionsForTransparentBridge(busInterface, instanceName, instanceInterfaces, graph);\r\n        }\r\n        else if (!busInterface->getMemoryMapRef().isEmpty())\r\n        {\r\n            createInternalConnectionsForOpaqueBridge(busInterface, instanceName, instanceInterfaces, graph, instancedComponent);\r\n        }\r\n    }\r\n    \r\n    for (QSharedPointer<AddressSpace> space : *instancedComponent->getAddressSpaces())\r\n    {\r\n        if (space->hasLocalMemoryMap())\r\n        {\r\n            createInternalSpaceMapConnection(\r\n                instancedComponent, instanceNode, instanceName, space, instanceInterfaces, graph);\r\n        }\r\n    }\r\n\r\n    createConnectionsForDesign(instancedComponent, activeView, instanceInterfaces, graph);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ConnectivityGraphFactory::createInternalSpaceMapConnection()\r\n//-----------------------------------------------------------------------------\r\nvoid ConnectivityGraphFactory::createInternalSpaceMapConnection(QSharedPointer<const Component> instancedComponent,\r\n    QSharedPointer<ConnectivityComponent> instanceNode, QString const& instanceName,\r\n    QSharedPointer<AddressSpace> addressSpace, QVector<QSharedPointer<ConnectivityInterface> > instanceInterfaces,\r\n    QSharedPointer<ConnectivityGraph> graph) const\r\n{\r\n    QSharedPointer<BusInterface> containingBus =\r\n        getBusInterfaceReferencingAddressSpace(instancedComponent, addressSpace->name());\r\n    QSharedPointer<ConnectivityInterface> localConnectionInterface;\r\n\r\n    if (containingBus)\r\n    {\r\n        localConnectionInterface = getInterface(containingBus->name(), instanceName, instanceInterfaces);\r\n    }\r\n    else\r\n    {\r\n        QSharedPointer<MemoryItem> interfacedMemory = getMemoryItemNode(addressSpace->name(), instanceNode);\r\n        if (interfacedMemory)\r\n        {\r\n            localConnectionInterface =\r\n                createLocalInterfaceData(addressSpace, interfacedMemory, instanceNode, graph);\r\n        }\r\n    }\r\n\r\n    QString connectionName =\r\n        addressSpace->name() + \"_to_local_memory_map_\" + addressSpace->getLocalMemoryMap()->name();\r\n\r\n    createConnectionData(connectionName, localConnectionInterface, localConnectionInterface, graph);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ConnectivityGraphFactory::createLocalInterfaceData()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<ConnectivityInterface> ConnectivityGraphFactory::createLocalInterfaceData(\r\n    QSharedPointer<AddressSpace> addressSpace, QSharedPointer<MemoryItem> interfacedMemory,\r\n    QSharedPointer<ConnectivityComponent> instanceNode, QSharedPointer<ConnectivityGraph> graph) const\r\n{\r\n    QSharedPointer<ConnectivityInterface> localConnectionInterface(\r\n        new ConnectivityInterface(addressSpace->name() + QStringLiteral(\" interface\")));\r\n\r\n    localConnectionInterface->setConnectedMemory(interfacedMemory);\r\n    localConnectionInterface->setInstance(instanceNode);\r\n\r\n    graph->getInterfaces().append(localConnectionInterface);\r\n\r\n    return localConnectionInterface;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ConnectivityGraphFactory::getBusInterfaceReferencingAddressSpace()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<BusInterface> ConnectivityGraphFactory::getBusInterfaceReferencingAddressSpace(\r\n    QSharedPointer<const Component> instancedComponent, QString const& spaceName) const\r\n{\r\n    for (QSharedPointer<BusInterface> busInterface : *instancedComponent->getBusInterfaces())\r\n    {\r\n        if (busInterface->getAddressSpaceRef().compare(spaceName) == 0)\r\n        {\r\n            return busInterface;\r\n        }\r\n    }\r\n\r\n    return QSharedPointer<BusInterface>();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ConnectivityGraphFactory::getMemoryItemNode()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<MemoryItem> ConnectivityGraphFactory::getMemoryItemNode(QString const& memoryReference,\r\n    QSharedPointer<ConnectivityComponent> instanceNode) const\r\n{\r\n    QVector<QSharedPointer<MemoryItem> > instanceMemories = instanceNode->getMemories();\r\n    for (int i = 0; i < instanceMemories.size(); ++i)\r\n    {\r\n        QSharedPointer<MemoryItem> memory = instanceMemories.at(i);\r\n        if (memory->getName().compare(memoryReference) == 0)\r\n        {\r\n            return memory;\r\n        }\r\n    }\r\n\r\n    return QSharedPointer<MemoryItem>();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ConnectivityGraphFactory::createConnectionsForDesign()\r\n//-----------------------------------------------------------------------------\r\nvoid ConnectivityGraphFactory::createConnectionsForDesign(QSharedPointer<const Component> instancedComponent,\r\n    QString const& activeView, QVector<QSharedPointer<ConnectivityInterface> > instanceInterfaces,\r\n    QSharedPointer<ConnectivityGraph> graph) const\r\n{\r\n    QSharedPointer<View> activeComponentView = findView(instancedComponent, activeView);\r\n\r\n    if (activeComponentView && activeComponentView->isHierarchical())\r\n    {\r\n        QSharedPointer<const DesignConfiguration> hierarchicalConfiguration =\r\n            getHierarchicalDesignConfiguration(instancedComponent, activeComponentView);\r\n\r\n        QSharedPointer<const Design> hierarchicalDesign = getHierarchicalDesign(instancedComponent,\r\n            activeComponentView, hierarchicalConfiguration);\r\n\r\n        if (hierarchicalDesign)\r\n        {              \r\n            for (QSharedPointer<ConnectivityInterface> topInterface : instanceInterfaces)\r\n            {\r\n                topInterface->setHierarchical();\r\n            }\r\n\r\n            QSharedPointer<DesignInstantiation> designInstantiation =\r\n                getDesignInstantiation(instancedComponent, activeComponentView);\r\n            analyzeDesign(designInstantiation, hierarchicalDesign, hierarchicalConfiguration, instanceInterfaces,\r\n                graph);\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ConnectivityGraphFactory::getDesignInstantiation()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<DesignInstantiation> ConnectivityGraphFactory::getDesignInstantiation(\r\n    QSharedPointer<const Component> instancedComponent, QSharedPointer<View> activeView) const\r\n{\r\n    QString designInstantiationReference = activeView->getDesignInstantiationRef();\r\n    for (auto instantiation : *instancedComponent->getDesignInstantiations())\r\n    {\r\n        if (instantiation->name() == designInstantiationReference)\r\n        {\r\n            return instantiation;\r\n        }\r\n    }\r\n\r\n    return QSharedPointer<DesignInstantiation>();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ConnectivityGraphFactory::createConnectionsForInterconnection()\r\n//-----------------------------------------------------------------------------\r\nvoid ConnectivityGraphFactory::createConnectionsForInterconnection(\r\n    QSharedPointer<const Interconnection> interconnection,\r\n    QVector<QSharedPointer<ConnectivityInterface> > designInterfaces,\r\n    QVector<QSharedPointer<ConnectivityInterface> > const& topInterfaces,\r\n    QSharedPointer<ConnectivityGraph> graph) const\r\n{\r\n    QSharedPointer<ActiveInterface> start = interconnection->getStartInterface();\r\n\r\n    QSharedPointer<ConnectivityInterface> startInterface =\r\n        getInterface(start->getBusReference(), start->getComponentReference(), designInterfaces);\r\n\r\n    for (QSharedPointer<HierInterface> hierInterface : *interconnection->getHierInterfaces())\r\n    {\r\n        QSharedPointer<ConnectivityInterface> target = getTopInterface(hierInterface->getBusReference(), topInterfaces);\r\n\r\n        createConnectionData(interconnection->name(), startInterface, target, graph);\r\n    }\r\n\r\n    for (QSharedPointer<ActiveInterface> activeInterface : *interconnection->getActiveInterfaces())\r\n    {                \r\n        QSharedPointer<ConnectivityInterface> target = getInterface(activeInterface->getBusReference(),\r\n            activeInterface->getComponentReference(), designInterfaces);\r\n\r\n        createConnectionData(interconnection->name(), startInterface, target, graph);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ConnectivityGraphFactory::getInterface()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<ConnectivityInterface> ConnectivityGraphFactory::getInterface(QString const& interfaceName,\r\n    QString const& instanceName, QVector<QSharedPointer<ConnectivityInterface> > const& instanceInterfaces) const\r\n{\r\n    for (int i = 0; i < instanceInterfaces.size(); ++i)\r\n    {\r\n        QSharedPointer<ConnectivityInterface> currentInterface = instanceInterfaces[i];\r\n        if (currentInterface->getName().compare(interfaceName) == 0 &&\r\n            currentInterface->getInstance()->getName().compare(instanceName) == 0)\r\n        {\r\n            return currentInterface;\r\n        }\r\n    }\r\n\r\n    return QSharedPointer<ConnectivityInterface>();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ConnectivityGraphFactory::getTopInterface()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<ConnectivityInterface> ConnectivityGraphFactory::getTopInterface(QString const& interfaceName,\r\n    QVector<QSharedPointer<ConnectivityInterface> > const& topInterfaces) const\r\n{\r\n    for (int i = 0; i < topInterfaces.size(); ++i)\r\n    {\r\n        QSharedPointer<ConnectivityInterface> interface = topInterfaces[i];\r\n        if (interface->getName().compare(interfaceName) == 0)\r\n        {\r\n            return interface;\r\n        }\r\n    }\r\n\r\n    return QSharedPointer<ConnectivityInterface>();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ConnectivityGraphFactory::findView()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<View> ConnectivityGraphFactory::findView(QSharedPointer<const Component> instancedComponent,\r\n    QString const& viewName) const\r\n{\r\n    if (viewName.isEmpty() && instancedComponent->getViews()->count() == 1)\r\n    {\r\n        return instancedComponent->getViews()->first();\r\n    }\r\n\r\n    for (QSharedPointer<View> componentView : *instancedComponent->getViews())\r\n    {\r\n        if (componentView->name().compare(viewName) == 0)\r\n        {\r\n            return componentView;\r\n        }\r\n    }\r\n\r\n    return QSharedPointer<View>();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ConnectivityGraphFactory::createInternalConnectionsForChannel()\r\n//-----------------------------------------------------------------------------\r\nvoid ConnectivityGraphFactory::createInternalConnectionsForChannel(QSharedPointer<const Channel> channel, \r\n    QString const& instanceName, QVector<QSharedPointer<ConnectivityInterface> > instanceInterfaces,\r\n    QSharedPointer<ConnectivityGraph> graph) const\r\n{\r\n    QStringList channelInterfaces = channel->getInterfaceNames();\r\n\r\n    while (!channelInterfaces.isEmpty())\r\n    {\r\n        QString startInterfaceName = channelInterfaces.takeFirst();\r\n        QSharedPointer<ConnectivityInterface> startInterface =\r\n            getInterface(startInterfaceName, instanceName, instanceInterfaces);\r\n\r\n        if (startInterface)\r\n        {\r\n            for (QString const& targetName : channelInterfaces)\r\n            {\r\n                QSharedPointer<ConnectivityInterface> target =\r\n                    getInterface(targetName, instanceName, instanceInterfaces);\r\n\r\n                if (target)\r\n                {\r\n                    createConnectionData(channel->name(), startInterface, target, graph);\r\n                }\r\n            }\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ConnectivityGraphFactory::createInternalConnectionsForTransparentBridge()\r\n//-----------------------------------------------------------------------------\r\nvoid ConnectivityGraphFactory::createInternalConnectionsForTransparentBridge(QSharedPointer<const BusInterface> busInterface,\r\n    QString const& instanceName, QVector<QSharedPointer<ConnectivityInterface> > const& instanceInterfaces,\r\n    QSharedPointer<ConnectivityGraph> graph) const\r\n{\r\n    QSharedPointer<ConnectivityInterface> startInterface =\r\n        getInterface(busInterface->name(), instanceName, instanceInterfaces);\r\n    startInterface->setBridged();\r\n\r\n    for (QSharedPointer<TransparentBridge> bridge : *busInterface->getSlave()->getBridges())\r\n    {\r\n        QSharedPointer<ConnectivityInterface> endInterface =\r\n            getInterface(bridge->getMasterRef(), instanceName, instanceInterfaces);\r\n\r\n        if (endInterface)\r\n        {\r\n            endInterface->setBridged();\r\n\r\n            QString bridgeName = startInterface->getName() + \"_bridge_to_\" + endInterface->getName();\r\n            createConnectionData(bridgeName, startInterface, endInterface, graph);\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ConnectivityGraphFactory::createInternalConnectionsForOpaqueBridge()\r\n//-----------------------------------------------------------------------------\r\nvoid ConnectivityGraphFactory::createInternalConnectionsForOpaqueBridge(QSharedPointer<const BusInterface> busInterface, \r\n    QString const& instanceName, QVector<QSharedPointer<ConnectivityInterface> > const& instanceInterfaces, \r\n    QSharedPointer<ConnectivityGraph> graph, QSharedPointer<const Component> component) const\r\n{\r\n    // Find memory map connected to target, look through subspace maps and their initiator references.\r\n    // Create connections between each referenced initiator and the target connected to memory map.\r\n\r\n    auto targetInterface = busInterface->getTarget();\r\n    auto memMapRef = targetInterface->getMemoryMapRef();\r\n\r\n    auto memoryMap = Search::findByName(memMapRef, component->getMemoryMaps());\r\n    if (!memoryMap)\r\n    {\r\n        return;\r\n    }\r\n\r\n    QSharedPointer<ConnectivityInterface> startInterface =\r\n        getInterface(busInterface->name(), instanceName, instanceInterfaces);\r\n\r\n    for (auto const& memoryBlock : *memoryMap->getMemoryBlocks())\r\n    {\r\n        if (auto subspaceMap = memoryBlock.dynamicCast<SubSpaceMap>())\r\n        {\r\n            startInterface->setBridged();\r\n\r\n            QSharedPointer<ConnectivityInterface> endInterface =\r\n                getInterface(subspaceMap->getInitiatorReference(), instanceName, instanceInterfaces);\r\n\r\n            if (endInterface)\r\n            {\r\n                QString bridgeName = startInterface->getName() + \"_bridge_to_\" + endInterface->getName();\r\n                createConnectionData(bridgeName, startInterface, endInterface, graph);\r\n                endInterface->setBridged();\r\n            }\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ConnectivityGraphFactory::getHierarchicalDesignConfiguration()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<const DesignConfiguration> ConnectivityGraphFactory::getHierarchicalDesignConfiguration(\r\n    QSharedPointer<const Component> component, QSharedPointer<const View> hierarchicalView) const\r\n{\r\n    QString configurationReference = hierarchicalView->getDesignConfigurationInstantiationRef();\r\n    if (!configurationReference.isEmpty())\r\n    {\r\n        for (QSharedPointer<DesignConfigurationInstantiation> instantiation :\r\n            *component->getDesignConfigurationInstantiations())\r\n        {\r\n            if (instantiation->name().compare(configurationReference) == 0)\r\n            {\r\n                QSharedPointer<ConfigurableVLNVReference> configurationVLNV =\r\n                    instantiation->getDesignConfigurationReference();\r\n\r\n                QSharedPointer<const Document> configurationDocument =\r\n                    library_->getModelReadOnly(*configurationVLNV);\r\n\r\n                return configurationDocument.dynamicCast<const DesignConfiguration>();\r\n            }\r\n        }\r\n    }\r\n\r\n    return QSharedPointer<const DesignConfiguration>();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ConnectivityGraphFactory::getHierarchicalDesign()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<const Design> ConnectivityGraphFactory::getHierarchicalDesign(QSharedPointer<const Component> component,\r\n    QSharedPointer<const View> hierarchicalView, QSharedPointer<const DesignConfiguration> designConfiguration) const\r\n{\r\n    VLNV designVLNV = getHierarchicalDesignVLNV(component, hierarchicalView);\r\n\r\n    if (!designVLNV.isValid() && !designConfiguration.isNull())\r\n    {\r\n        designVLNV = designConfiguration->getDesignRef();        \r\n    }\r\n\r\n    if (designVLNV.isValid())\r\n    {\r\n        return library_->getModelReadOnly(designVLNV).dynamicCast<const Design>();\r\n    }\r\n\r\n    return QSharedPointer<const Design>();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ConnectivityGraphFactory::getHierarchicalDesignVLNV()\r\n//-----------------------------------------------------------------------------\r\nVLNV ConnectivityGraphFactory::getHierarchicalDesignVLNV(QSharedPointer<const Component> component,\r\n    QSharedPointer<const View> hierarchicalView) const\r\n{\r\n    QString referencedInstantiation = hierarchicalView->getDesignInstantiationRef();\r\n\r\n    if (!referencedInstantiation.isEmpty())\r\n    {\r\n        for (QSharedPointer<DesignInstantiation> instantiation : *component->getDesignInstantiations())\r\n        {\r\n            if (instantiation->name().compare(referencedInstantiation) == 0)\r\n            {\r\n                return *instantiation->getDesignReference();\r\n            }\r\n        }\r\n    }\r\n\r\n    return VLNV();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ConnectivityGraphFactory::createConnectionData()\r\n//-----------------------------------------------------------------------------\r\nvoid ConnectivityGraphFactory::createConnectionData(QString const& connectionName,\r\n    QSharedPointer<ConnectivityInterface> startPoint, QSharedPointer<ConnectivityInterface> endPoint,\r\n    QSharedPointer<ConnectivityGraph> graph) const\r\n{\r\n    if (startPoint != nullptr && endPoint != nullptr)\r\n    {\r\n        QSharedPointer<ConnectivityConnection> connection(\r\n            new ConnectivityConnection(connectionName, startPoint, endPoint));\r\n\r\n        graph->getConnections().append(connection);\r\n    }\r\n}\r\n"
  },
  {
    "path": "editors/MemoryDesigner/ConnectivityGraphFactory.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ConnectivityGraphFactory.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Mikko Teuho\r\n// Date: 08.07.2016\r\n//\r\n// Description:\r\n// Creates a connectivity graph from a given design and design configuration.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef CONNECTIVITYGRAPHFACTORY_H\r\n#define CONNECTIVITYGRAPHFACTORY_H\r\n\r\n#include <IPXACTmodels/common/VLNV.h>\r\n\r\nclass ActiveInterface;\r\nclass MemoryBlockBase;\r\nclass SubSpaceMap;\r\nclass AddressBlock;\r\nclass BusInterface;\r\nclass Channel;\r\nclass ConfigurableVLNVReference;\r\nclass Component;\r\nclass ComponentInstance;\r\nclass Design;\r\nclass DesignConfiguration;\r\nclass DesignInstantiation;\r\n\r\nclass Interconnection;\r\nclass AddressSpace;\r\nclass MemoryMap;\r\nclass MemoryMapBase;\r\nclass Register;\r\nclass Field;\r\nclass EnumeratedValue;\r\nclass FieldReset;\r\nclass View;\r\n\r\nclass LibraryInterface;\r\n\r\nclass ConnectivityConnection;\r\nclass ConnectivityGraph;\r\nclass ConnectivityComponent;\r\nclass ConnectivityInterface;\r\nclass ExpressionParser;\r\nclass MemoryItem;\r\nclass MultipleParameterFinder;\r\nclass ExpressionFormatter;\r\n\r\n#include <QString>\r\n#include <QSharedPointer>\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Creates a connectivity graph from a given design and design configuration.\r\n//-----------------------------------------------------------------------------\r\nclass ConnectivityGraphFactory\r\n{\r\n\r\npublic:\r\n\r\n    /*!\r\n     *  The constructor.\r\n     *\r\n     *    @param [in] library     The library interface.\r\n     */    \r\n    ConnectivityGraphFactory(LibraryInterface* library);\r\n\r\n    //! The destructor.\r\n    ~ConnectivityGraphFactory();\r\n   \r\n    /*!\r\n     *  Creates a connectivity graph from the component and its underlying hierarchy.\r\n     *\r\n     *    @param [in] topComponent    The selected component.\r\n     *    @param [in] activeView      The view to determine hierarchy.\r\n     *\r\n     *    @return Connectivity graph for the design hierarchy.\r\n     */\r\n    QSharedPointer<ConnectivityGraph> createConnectivityGraph(QSharedPointer<const Component> topComponent,\r\n        QString const& activeView);\r\n\r\nprivate:\r\n    // Disable copying.\r\n    ConnectivityGraphFactory(ConnectivityGraphFactory const& rhs);\r\n    ConnectivityGraphFactory& operator=(ConnectivityGraphFactory const& rhs);\r\n\r\n    /*!\r\n     *  Creates graph elements from the given design and configuration.\r\n     *\r\n     *    @param [in] designInstantiation     The design instantiation used in the top component.\r\n     *    @param [in] design                  The design to analyze and transform into graph.\r\n     *    @param [in] designConfiguration     The design configuration to analyze and transform into graph.\r\n     *    @param [in] topInterfaces           The top-level component interfaces available for connections.\r\n     *    @param [in/out] graph               The graph to add elements into.\r\n     */\r\n    void analyzeDesign(QSharedPointer<DesignInstantiation> designInstantiation,\r\n        QSharedPointer<const Design> design,\r\n        QSharedPointer<const DesignConfiguration> designConfiguration,\r\n        QVector<QSharedPointer<ConnectivityInterface> > const& topInterfaces,\r\n        QSharedPointer<ConnectivityGraph> graph) const;\r\n\r\n    /*!\r\n     *  Creates a component instance representation for a component instance.\r\n     *\r\n     *    @param [in] instance      The component instance to transform into the graph.\r\n     *    @param [in] component     The component for the instance.\r\n     *    @param [in] activeView    The active view for the instance.\r\n     *    @param [in/out] graph     The graph to add instance node into.\r\n     *\r\n     *    @return The graph representation for the component instance.\r\n     */\r\n    QSharedPointer<ConnectivityComponent> createInstanceData(QSharedPointer<ComponentInstance> instance,\r\n        QSharedPointer<const Component> component, QString const& activeView, \r\n        QSharedPointer<ConnectivityGraph> graph) const;\r\n    \r\n    /*!\r\n     *  Adds all address spaces to a component instance in the graph.\r\n     *\r\n     *    @param [in/out] instance    The component instance to add the address spaces into.\r\n     *    @param [in] component       The component for the instance.\r\n     */\r\n    void addAddressSpaceMemories(QSharedPointer<ConnectivityComponent> instance,\r\n        QSharedPointer<const Component> component) const;\r\n\r\n    /*!\r\n     *  Adds all memory maps to a component instance in the graph.\r\n     *\r\n     *    @param [in] instanceData    The component instance representation to add memory maps into.\r\n     *    @param [in] component       The component for the instance.     \r\n     */\r\n    void addMemoryMapMemories(QSharedPointer<ConnectivityComponent> instanceData,\r\n        QSharedPointer<const Component> component) const;\r\n\r\n    /*!\r\n     *  Creates a representation for a memory map in a component instance.\r\n     *\r\n     *    @param [in] map                     The memory map to transform into the graph.\r\n     *    @param [in] addressableUnitBits     The number of addressable unit bits in the memory map.\r\n     *    @param [in] containingInstance      The component instance containing the memory map.\r\n     *\r\n     *    @return Representation for the memory map.\r\n     */\r\n    QSharedPointer<MemoryItem> createMemoryMapData(QSharedPointer<const MemoryMapBase> map,\r\n        int addressableUnitBits, QSharedPointer<ConnectivityComponent> containingInstance) const;\r\n\r\n    /*!\r\n     *  Adds a all memory remap representations into a component instance representation.\r\n     *\r\n     *    @param [in] map                     The memory map containing the memory remaps.\r\n     *    @param [in] mapItem                 The memory map representation for the memory map.\r\n     *    @param [in] addressableUnitBits     The number of addressable unit bits in the memory map.\r\n     *    @param [in] containingInstance      The component instance containing the memory map and remaps.\r\n     */\r\n    void addMemoryRemapData(QSharedPointer<const MemoryMap> map, QSharedPointer<MemoryItem> mapItem, \r\n        int addressableUnitBits, QSharedPointer<ConnectivityComponent> containingInstance) const;\r\n\r\n    /*!\r\n     *  Create a representation of a memory block.\r\n     *\t\r\n     *    @param [in] block                   The selected memory block.\r\n     *    @param [in] mapIdentifier           Identifier for the containing memory map.\r\n     *    @param [in] addressableUnitBits     The used address unit bits.\r\n     *\r\n     *    @return Representation of the memory block.\r\n     */\r\n    QSharedPointer<MemoryItem> createMemoryBlock(QSharedPointer<MemoryBlockBase> block,\r\n        QString const& mapIdentifier, int addressableUnitBits) const;\r\n\r\n    /*!\r\n     *  Creates a representation for an address block.\r\n     *\r\n     *    @param [in] block                   The address block to transform into the graph.\r\n     *    @param [in] mapIdentifier           Identifier for the containing memory map.\r\n     *    @param [in] addressableUnitBits     The number of addressable unit bits in the memory map.\r\n     *\r\n     *    @return Representation for the address block.\r\n     */\r\n    QSharedPointer<MemoryItem> createMemoryAddressBlockItem(QSharedPointer<const AddressBlock> block,\r\n        QString const& mapIdentifier, int addressableUnitBits) const;\r\n\r\n    /*!\r\n     *  Creates a representation for a subspace map.\r\n     *\t\r\n     *    @param [in] subspace                The selected subspace map.\r\n     *    @param [in] mapIdentifier           Identifier for the containing memory map.\r\n     *    @param [in] addressableUnitBits     The number of addressable unit bits in the memory map.\r\n     *\r\n     *    @return Represenation for the subspace map.\r\n     */\r\n    QSharedPointer<MemoryItem> createMemorySubSpaceMapItem(QSharedPointer<const SubSpaceMap> subspace,\r\n        QString const& mapIdentifier, int addressableUnitBits) const;\r\n\r\n    /*!\r\n     *  Adds a register representations into an address block representation.\r\n     *\r\n     *    @param [in] reg                     The register to add.\r\n     *    @param [in] baseAddress             The base address for the address block.\r\n     *    @param [in] addressableUnitBits     The number of addressable unit bits in the memory map.\r\n     *    @param [in] blockIdentifier         Identifier for the containing address block.\r\n     *    @param [in/out] blockItem           The address block to the add register into.\r\n     */\r\n    void addRegisterData(QSharedPointer<const Register> reg, quint64 const& baseAddress, int addressableUnitBits,\r\n        QString const& blockIdentifier, QSharedPointer<MemoryItem> blockItem) const;\r\n\r\n    /*!\r\n     *  Get field items of the selected register item in order of offset.\r\n     *\r\n     *    @param [in] registerItem    The selected register item.\r\n     *    @param [in] fieldItems      Field items of the register item.\r\n     *\r\n     *    @return Field items in order of offset.\r\n     */\r\n    QMap<quint64, QSharedPointer<MemoryItem> > getOrderedFieldItems(QSharedPointer<MemoryItem> registerItem,\r\n        QVector<QSharedPointer<MemoryItem> > fieldItems) const;\r\n\r\n    /*!\r\n     *  Creates a representation for a field within a register.\r\n     *\r\n     *    @param [in] field                   The field to transform into the graph.\r\n     *    @param [in] registerIdentifier      Identifier for the containing register.\r\n     *    @param [in] regAddress              The base address for the containing register.\r\n     *    @param [in] addressableUnitBits     The number of addressable unit bits in the memory map.\r\n     *\r\n     *    @return Representation for the field.\r\n     */\r\n    QSharedPointer<MemoryItem> createField(QSharedPointer<const Field> field, QString const& registerIdentifier,\r\n        quint64 const& regAddress, int addressableUnitBits) const;\r\n\r\n    /*!\r\n     *  Creates a representation for an enumerated value within a field.\r\n     *\r\n     *    @param [in] enumeratedValue     The enumerated value to transform into the graph.\r\n     *    @param [in] fieldIdentifier     Identifier for the containing field.\r\n     *    @param [in] addressUnitBits     The number of address unit bits in the memory map.\r\n     *\r\n     *    @return Representation of the enumerated value.\r\n     */\r\n    QSharedPointer<MemoryItem> createEnumeratedValueItem(QSharedPointer<const EnumeratedValue> enumeratedValue,\r\n        QString const& fieldIdentifier, int const& addressUnitBits) const;\r\n\r\n    /*!\r\n     *  Create a representation of a reset within a field.\r\n     *\r\n     *    @param [in] fieldReset          The selected field reset.\r\n     *    @param [in] fieldIdentifier     Identifier of the containing field.\r\n     *    @param [in] addressUnitBits     The number of address unit bits in the memory map.\r\n     *    @param [in] fieldWidth          The bit width of the field.\r\n     *\r\n     *    @return Representation of the reset.\r\n     */\r\n    QSharedPointer<MemoryItem> createFieldResetItem(QSharedPointer<FieldReset> fieldReset,\r\n        QString const& fieldIdentifier, int const& addressUnitBits, QString const& fieldWidth) const;\r\n\r\n    /*!\r\n     *  Create a representation of a reset within a register.\r\n     *\r\n     *    @param [in] fieldItems          Field items within the selected register.\r\n     *    @param [in] registerItem        The selected register item.\r\n     *    @param [in] registerIdentifier  Identifier of the containing register.\r\n     *    @param [in] addressUnitBits     The number of address unit bits in the memory map.\r\n     *\r\n     *    @return Representation of the reset.\r\n     */\r\n    QSharedPointer<MemoryItem> createRegisterResetItem(QMap<quint64, QSharedPointer<MemoryItem> > fieldItems,\r\n        QSharedPointer<MemoryItem> registerItem, QString const& registerIdentifier, int const& addressUnitBits)\r\n        const;\r\n\r\n    /*!\r\n     *  Get the representation of HARD reset of the selected item.\r\n     *\r\n     *    @param [in] containingItem  The selected item.\r\n     *\r\n     *    @return Representation of a HARD reset.\r\n     */\r\n    QSharedPointer<MemoryItem> getHardResetItem(QSharedPointer<MemoryItem> containingItem) const;\r\n\r\n    /*!\r\n     *  Creates graph vertices from the bus interfaces of the given component.\r\n     *\r\n     *    @param [in] instancedComponent      The component whose bus interfaces to transform into graph.\r\n     *    @param [in] instanceNode            The graph element representing the instance.\r\n     *    @param [in/out] graph               The graph to add elements into.\r\n     *\r\n     *    @return The vertices created from the component bus interfaces.\r\n     */\r\n    QVector<QSharedPointer<ConnectivityInterface> > createInterfacesForInstance(\r\n        QSharedPointer<Component const> instancedComponent, QSharedPointer<ConnectivityComponent> instanceNode,\r\n        QSharedPointer<ConnectivityGraph> graph) const;\r\n    \r\n    /*!\r\n     *  Creates an interface representation for a bus interface.\r\n     *\r\n     *    @param [in] busInterface    The bus interface to transform into the graph.\r\n     *    @param [in] instanceNode    The instance containing the interface.\r\n     *    @param [in/out] graph       The graph to add elements into.\r\n     *\r\n     *    @return The graph representation for the interface.\r\n     */\r\n    QSharedPointer<ConnectivityInterface> createInterfaceData(QSharedPointer<const BusInterface> busInterface,\r\n        QSharedPointer<ConnectivityComponent> instanceNode, QSharedPointer<ConnectivityGraph> graph) const;\r\n\r\n    /*!\r\n     *  Creates an interfaces representation of a local memory map of an address space.\r\n     *\r\n     *    @param [in] addressSpace        The selected address space.\r\n     *    @param [in] interfacedMemory    Memory item created for the address space.\r\n     *    @param [in] instanceNode        Component instance containing the interface.\r\n     *    @param [in/out] graph           The graph containing the interface.\r\n     *\r\n     *    @return The graph representation for the local memory map.\r\n     */\r\n    QSharedPointer<ConnectivityInterface> createLocalInterfaceData(QSharedPointer<AddressSpace> addressSpace,\r\n        QSharedPointer<MemoryItem> interfacedMemory, QSharedPointer<ConnectivityComponent> instanceNode,\r\n        QSharedPointer<ConnectivityGraph> graph) const;\r\n\r\n    /*!\r\n     *  Creates graph elements for component instance internal connections and a possible sub design.\r\n     *\r\n     *    @param [in] instancedComponent      The instanced component to transform.\r\n     *    @param [in] instanceNode            The node containing the component instance.\r\n     *    @param [in] instanceName            The name of the instance.\r\n     *    @param [in] activeView              The active view of the component instance.\r\n     *    @param [in] instanceInterfaces      The graph interfaces for the instanced component.\r\n     *    @param [in/out] graph               The graph to add elements into.\r\n     */\r\n    void createInternalConnectionsAndDesigns(QSharedPointer<const Component> instancedComponent,\r\n        QSharedPointer<ConnectivityComponent> instanceNode, QString const& instanceName, QString const& activeView,\r\n        QVector<QSharedPointer<ConnectivityInterface> > instanceInterfaces,\r\n        QSharedPointer<ConnectivityGraph> graph) const;\r\n\r\n    /*!\r\n     *  Create a connection between an address space and its local memory map.\r\n     *\r\n     *    @param [in] instancedComponent  Instanced component containing the address space.\r\n     *    @param [in] instanceNode        The node containing the component instance.\r\n     *    @param [in] instanceName        Name of the instance.\r\n     *    @param [in] addressSpace        The selected address space.\r\n     *    @param [in] instanceInterfaces  Interfaces within the instanced component.\r\n     *    @param [in/out] graph               The graph to add elements into.\r\n     */\r\n    void createInternalSpaceMapConnection(QSharedPointer<const Component> instancedComponent,\r\n        QSharedPointer<ConnectivityComponent> instanceNode, QString const& instanceName,\r\n        QSharedPointer<AddressSpace> addressSpace,\r\n        QVector<QSharedPointer<ConnectivityInterface> > instanceInterfaces,\r\n        QSharedPointer<ConnectivityGraph> graph) const;\r\n\r\n    /*!\r\n     *  Get the bus interface that references the selected address space.\r\n     *\r\n     *    @param [in] instancedComponent  Instanced component containing the address space.\r\n     *    @param [in] spaceName           Name of the selected address space.\r\n     *\r\n     *    @return The bus interface referencing the selected address space.\r\n     */\r\n    QSharedPointer<BusInterface> getBusInterfaceReferencingAddressSpace(\r\n        QSharedPointer<const Component> instancedComponent, QString const& spaceName) const;\r\n\r\n    /*!\r\n     *  Get the memory item node containing the selected memory item.\r\n     *\r\n     *    @param [in] memoryReference     Name of the selected memory item.\r\n     *    @param [in] instanceNode        The node containing the component instance.\r\n     *\r\n     *    @return The node containing the selected memory item.\r\n     */\r\n    QSharedPointer<MemoryItem> getMemoryItemNode(QString const& memoryReference,\r\n        QSharedPointer<ConnectivityComponent> instanceNode) const;\r\n\r\n    /*!\r\n     *   Creates graph elements for component instance sub designs.\r\n     *\r\n     *    @param [in] instancedComponent      The instanced component whose sub design to transform.\r\n     *    @param [in] activeView              The active view of the component instance.\r\n     *    @param [in] instanceInterfaces      The graph interfaces for the instances component.\r\n     *    @param [in/out] graph               The graph to add elements into.\r\n     */\r\n    void createConnectionsForDesign(QSharedPointer<const Component> instancedComponent, QString const& activeView,\r\n        QVector<QSharedPointer<ConnectivityInterface> > instanceInterfaces, QSharedPointer<ConnectivityGraph> graph) const;\r\n\r\n    /*!\r\n     *  Get the design instantiation for the selected view from the selected component.\r\n     *\r\n     *    @param [in] instancedComponent  The selected component.\r\n     *    @param [in] activeView          The selected view.\r\n     *\r\n     *    @return The design instantiation for the selected view from the selected component.\r\n     */\r\n    QSharedPointer<DesignInstantiation> getDesignInstantiation(\r\n        QSharedPointer<const Component> instancedComponent, QSharedPointer<View> activeView) const;\r\n\r\n    /*!\r\n     *  Creates graph edges for the given design interconnection.\r\n     *\r\n     *    @param [in] interconnection     The interconnection to transform into edge(s).\r\n     *    @param [in] designInterfaces    The interfaces in the component instances available for connections.\r\n     *    @param [in] topInterfaces       The top-level interfaces in the design available for connections.\r\n     *    @param [in/out] graph           The graph to add elements into.\r\n     */\r\n    void createConnectionsForInterconnection(QSharedPointer<const Interconnection> interconnection,\r\n        QVector<QSharedPointer<ConnectivityInterface> > designInterfaces,\r\n        QVector<QSharedPointer<ConnectivityInterface> > const& topInterfaces,\r\n        QSharedPointer<ConnectivityGraph> graph) const;\r\n\r\n    /*!\r\n     *  Finds the interface vertex for the given interface name and instance.\r\n     *\r\n     *    @param [in] interfaceName           The name of the interface to find.\r\n     *    @param [in] instanceName            The name of the component instance containing the interface.\r\n     *    @param [in] instanceInterfaces      The interfaces available to search from.\r\n     *\r\n     *    @return The found interface vertex.\r\n     */\r\n    QSharedPointer<ConnectivityInterface> getInterface(QString const& interfaceName, QString const& instanceName,\r\n        QVector<QSharedPointer<ConnectivityInterface> > const& instanceInterfaces) const;\r\n    \r\n    /*!\r\n     *  Finds the top-level interface vertex for the given interface.\r\n     *\r\n     *    @param [in] interfaceName       The name of the interface to find.\r\n     *    @param [in] topInterfaces       The interfaces available to search from.\r\n     *\r\n     *    @return The found interface vertex.\r\n     */\r\n    QSharedPointer<ConnectivityInterface> getTopInterface(QString const& interfaceName,\r\n        QVector<QSharedPointer<ConnectivityInterface> > const& topInterfaces) const;\r\n\r\n    /*!\r\n     *  Finds the given view in a component.\r\n     *\r\n     *    @param [in] component       The component to search the view for.\r\n     *    @param [in] viewName        The name of the view.\r\n     *\r\n     *    @return The view with the given name.\r\n     */\r\n    QSharedPointer<View> findView(QSharedPointer<const Component> component, QString const& viewName) const;\r\n\r\n    /*!\r\n     *  Creates the graph edges for the given channel.\r\n     *\r\n     *    @param [in] channel                 The channel to transform into edge(s).\r\n     *    @param [in] instanceName            The name of the containing component instance.\r\n     *    @param [in] instanceInterfaces      The interface vertices of the instance.\r\n     *    @param [in/out] graph               The graph to add elements into.\r\n     */\r\n    void createInternalConnectionsForChannel(QSharedPointer<const Channel> channel, QString const& instanceName, \r\n        QVector<QSharedPointer<ConnectivityInterface> > instanceInterfaces, \r\n        QSharedPointer<ConnectivityGraph> graph) const;\r\n\r\n    /*!\r\n     *  Creates the graph edges for the given transparently bridged bus interface.\r\n     *\r\n     *    @param [in] busInterface            The interface whose bridge(s) to transform into edge(s).\r\n     *    @param [in] instanceName            The name of the containing component instance.\r\n     *    @param [in] instanceInterfaces      The interface vertices of the instance.\r\n     *    @param [in/out] graph               The graph to add elements into.\r\n     */\r\n    void createInternalConnectionsForTransparentBridge(QSharedPointer<const BusInterface> busInterface, \r\n        QString const& instanceName, QVector<QSharedPointer<ConnectivityInterface> > const& instanceInterfaces, \r\n        QSharedPointer<ConnectivityGraph> graph) const;\r\n\r\n    /*!\r\n     *  Creates the graph edges for the given opaquely bridged bus interface.\r\n     *\r\n     *    @param [in] busInterface            The interface whose bridge(s) to transform into edge(s).\r\n     *    @param [in] instanceName            The name of the containing component instance.\r\n     *    @param [in] instanceInterfaces      The interface vertices of the instance.\r\n     *    @param [in/out] graph               The graph to add elements into.\r\n     *    @param [in] component               The containing component.\r\n     */\r\n    void createInternalConnectionsForOpaqueBridge(QSharedPointer<const BusInterface> busInterface,\r\n        QString const& instanceName, QVector<QSharedPointer<ConnectivityInterface> > const& instanceInterfaces,\r\n        QSharedPointer<ConnectivityGraph> graph, QSharedPointer<const Component> component) const;\r\n\r\n    /*!\r\n     *  Get the design configuration from the selected view.\r\n     *\r\n     *    @param [in] component           The component containing the selected view.\r\n     *    @param [in] hierarchicalView    The selected view.\r\n     *\r\n     *    @return The design configuration referenced by the selected view.\r\n     */\r\n    QSharedPointer<const DesignConfiguration> getHierarchicalDesignConfiguration(\r\n        QSharedPointer<const Component> component, QSharedPointer<const View> hierarchicalView) const;\r\n\r\n    /*!\r\n     *  Get the design from the selected view.\r\n     *\r\n     *    @param [in] component               Component containing the selected view.\r\n     *    @param [in] hierarchicalView        The selected view.\r\n     *    @param [in] designConfiguration     Design configuration referenced by the selected view.\r\n     *\r\n     *    @return The design referenced by the selected view.\r\n     */\r\n    QSharedPointer<const Design> getHierarchicalDesign(QSharedPointer<const Component> component,\r\n        QSharedPointer<const View> hierarchicalView,\r\n        QSharedPointer<const DesignConfiguration> designConfiguration) const;\r\n\r\n    /*!\r\n     *  Gets the VLNV of the design referenced by the selected view.\r\n     *\r\n     *    @param [in] component               Component containing the selected view.\r\n     *    @param [in] hierarchicalView        The selected view.\r\n     *\r\n     *    @return The VLNV of the design referenced by the selected view.\r\n     */\r\n    VLNV getHierarchicalDesignVLNV(QSharedPointer<const Component> component,\r\n        QSharedPointer<const View> hierarchicalView) const;\r\n\r\n    /*!\r\n     *  Creates an interconnection representation between bus interfaces.\r\n     *\r\n     *    @param [in] connectionName  Name of the interconnection.\r\n     *    @param [in] startPoint      The starting interface of the connection.\r\n     *    @param [in] endPoint        The ending interface of the connection.\r\n     *    @param [in/out] graph       The graph to add elements into.\r\n     *\r\n     *    @return The graph representation for the interface.\r\n     */\r\n    void createConnectionData(QString const& connectionName, QSharedPointer<ConnectivityInterface> startPoint,\r\n        QSharedPointer<ConnectivityInterface> endPoint, QSharedPointer<ConnectivityGraph> graph) const;\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! The library interface.\r\n    LibraryInterface* library_;\r\n\r\n    //! The parameter finder to use for instantiated components.\r\n    QSharedPointer<MultipleParameterFinder> parameterFinder_;\r\n\r\n    //! Parser for resolving expressions.\r\n    ExpressionParser* expressionParser_;\r\n\r\n    //! Formatter for expressions.\r\n    ExpressionFormatter* formatter_;\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n\r\n#endif // CONNECTIVITYGRAPHFACTORY_H\r\n"
  },
  {
    "path": "editors/MemoryDesigner/ConnectivityInterface.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ConnectivityInterface.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Esko Pekkarinen\r\n// Date: 03.08.2016\r\n//\r\n// Description:\r\n// An interface in a connectivity graph.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"ConnectivityInterface.h\"\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ConnectivityInterface::ConnectivityInterface()\r\n//-----------------------------------------------------------------------------\r\nConnectivityInterface::ConnectivityInterface(QString const& name):\r\nname_(name),\r\nbaseAddress_(),\r\nremapAddress_(),\r\ninstance_(),\r\nmemory_(nullptr),\r\nhierarchical_(false),\r\nbridged_(false),\r\nchildInterfaceNodes_()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ConnectivityInterface::getName()\r\n//-----------------------------------------------------------------------------\r\nQString ConnectivityInterface::getName() const\r\n{\r\n    return name_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ConnectivityInterface::setMode()\r\n//-----------------------------------------------------------------------------\r\nvoid ConnectivityInterface::setMode(General::InterfaceMode newMode)\r\n{\r\n    mode_ = newMode;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ConnectivityInterface::getMode()\r\n//-----------------------------------------------------------------------------\r\nGeneral::InterfaceMode ConnectivityInterface::getMode() const\r\n{\r\n    return mode_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ConnectivityInterface::setBaseAddress()\r\n//-----------------------------------------------------------------------------\r\nvoid ConnectivityInterface::setBaseAddress(QString const& address)\r\n{\r\n    baseAddress_ = address;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ConnectivityInterface::getBaseAddress()\r\n//-----------------------------------------------------------------------------\r\nQString ConnectivityInterface::getBaseAddress() const\r\n{\r\n    return baseAddress_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ConnectivityInterface::setRemapAddress()\r\n//-----------------------------------------------------------------------------\r\nvoid ConnectivityInterface::setRemapAddress(QString const& address)\r\n{\r\n    remapAddress_ = address;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ConnectivityInterface::getRemapAddress()\r\n//-----------------------------------------------------------------------------\r\nQString ConnectivityInterface::getRemapAddress() const\r\n{\r\n    return remapAddress_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ConnectivityInterface::setRemapRange()\r\n//-----------------------------------------------------------------------------\r\nvoid ConnectivityInterface::setRemapRange(QString const& range)\r\n{\r\n    range_ = range;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ConnectivityInterface::getRemapRange()\r\n//-----------------------------------------------------------------------------\r\nQString ConnectivityInterface::getRemapRange() const\r\n{\r\n    return range_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ConnectivityInterface::setInstance()\r\n//-----------------------------------------------------------------------------\r\nvoid ConnectivityInterface::setInstance(QSharedPointer<ConnectivityComponent const> instance)\r\n{\r\n    instance_ = instance;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ConnectivityInterface::getInstance()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<ConnectivityComponent const> ConnectivityInterface::getInstance() const\r\n{\r\n    return instance_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ConnectivityInterface::isConnectedToMemory()\r\n//-----------------------------------------------------------------------------\r\nbool ConnectivityInterface::isConnectedToMemory() const\r\n{\r\n    return !memory_.isNull();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ConnectivityInterface::setConnectedMemory()\r\n//-----------------------------------------------------------------------------\r\nvoid ConnectivityInterface::setConnectedMemory(QSharedPointer<MemoryItem> item)\r\n{\r\n    memory_ = item;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ConnectivityInterface::getConnectedMemory()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<MemoryItem> ConnectivityInterface::getConnectedMemory() const\r\n{\r\n    return memory_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ConnectivityInterface::setHierarchical()\r\n//-----------------------------------------------------------------------------\r\nvoid ConnectivityInterface::setHierarchical()\r\n{\r\n    hierarchical_ = true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ConnectivityInterface::isHierarchical()\r\n//-----------------------------------------------------------------------------\r\nbool ConnectivityInterface::isHierarchical() const\r\n{\r\n    return hierarchical_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ConnectivityInterface::setBridgd()\r\n//-----------------------------------------------------------------------------\r\nvoid ConnectivityInterface::setBridged()\r\n{\r\n    bridged_ = true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ConnectivityInterface::isBridged()\r\n//-----------------------------------------------------------------------------\r\nbool ConnectivityInterface::isBridged() const\r\n{\r\n    return bridged_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ConnectivityInterface::getChildInterfaceNodes()\r\n//-----------------------------------------------------------------------------\r\nQVector<QSharedPointer<ConnectivityInterface> > ConnectivityInterface::getChildInterfaceNodes() const\r\n{\r\n    return childInterfaceNodes_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ConnectivityInterface::addChildInterfaceNode()\r\n//-----------------------------------------------------------------------------\r\nvoid ConnectivityInterface::addChildInterfaceNode(QSharedPointer<ConnectivityInterface> newChild)\r\n{\r\n    childInterfaceNodes_.append(newChild);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ConnectivityInterface::removeChildInterface()\r\n//-----------------------------------------------------------------------------\r\nvoid ConnectivityInterface::removeChildInterface(int const& indexOfInterface)\r\n{\r\n    childInterfaceNodes_.removeAt(indexOfInterface);\r\n}\r\n"
  },
  {
    "path": "editors/MemoryDesigner/ConnectivityInterface.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ConnectivityInterface.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Esko Pekkarinen\r\n// Date: 03.08.2016\r\n//\r\n// Description:\r\n// An interface in a connectivity graph.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef INTERFACE_H\r\n#define INTERFACE_H\r\n\r\n#include <QString>\r\n#include <QVector>\r\n#include <QSharedPointer>\r\n\r\n#include <IPXACTmodels/generaldeclarations.h>\r\n\r\nclass ConnectivityComponent;\r\nclass MemoryItem;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! An interface in a connectivity graph.\r\n//-----------------------------------------------------------------------------\r\nclass ConnectivityInterface \r\n{\r\npublic:\r\n\r\n\t/*!\r\n\t *  The constructor.\r\n\t *\r\n\t *    @param [in] name   The name of the interface.\r\n\t */\r\n\texplicit ConnectivityInterface(QString const& name);\r\n\r\n\t/*!\r\n     *  The destructor.\r\n     */\r\n\t~ConnectivityInterface() = default;\r\n\r\n    /*!\r\n     *  Gets the name of the interface.\r\n     *\r\n     *    @return The name of the interface.\r\n     */\r\n    QString getName() const;\r\n\r\n    /*!\r\n     *  Sets the mode for the interface.\r\n     *\r\n     *    @param [in] newMode     The mode to set.\r\n     */\r\n    void setMode(General::InterfaceMode newMode);\r\n\r\n    /*!\r\n     *  Gets the mode of the interface.\r\n     *\r\n     *    @return The mode of the interface.\r\n     */\r\n    General::InterfaceMode getMode() const;\r\n\r\n    /*!\r\n     *  Sets the base address for the memories connected to the interface.\r\n     *\r\n     *    @param [in] address   The base address to set.\r\n     */\r\n    void setBaseAddress(QString const& address);\r\n\r\n    /*!\r\n     *  Gets the base address for the memories connected to the interface. \r\n     *\r\n     *    @return The base address for the memories connected to the interface.\r\n     */\r\n    QString getBaseAddress() const;\r\n\r\n    /*!\r\n     *  Sets the remap address for the memories connected to the interface.\r\n     *\r\n     *    @param [in] address   The remap address to set.\r\n     */\r\n    void setRemapAddress(QString const& address);\r\n\r\n    /*!\r\n     *  Gets the remap address for the memories connected to the interface.\r\n     *\r\n     *    @return The remap address.\r\n     */\r\n    QString getRemapAddress() const;\r\n\r\n    /*!\r\n     *  Sets the remap range for the memories connected to the interface.\r\n     *\r\n     *    @param [in] range   The range to set.\r\n     */\r\n    void setRemapRange(QString const& range);\r\n\r\n    /*!\r\n     *   Gets the remap range for the memories connected to the interface.\r\n     *\r\n     *    @return The remap range.\r\n     */\r\n    QString getRemapRange() const;\r\n\r\n    /*!\r\n     *  Sets the instance the interface is a part of.\r\n     *\r\n     *    @param [in] instance   The instance to set.\r\n     */\r\n    void setInstance(QSharedPointer<ConnectivityComponent const> instance);\r\n\r\n    /*!\r\n     *  Gets the instance the interface is part of.\r\n     *\r\n     *    @return The instance containing the interface.\r\n     */\r\n    QSharedPointer<ConnectivityComponent const> getInstance() const;\r\n\r\n    /*!\r\n     *  Checks if the interface is associated with a memory.\r\n     *\r\n     *    @return True, if the interface is connected to a memory, otherwise false.\r\n     */\r\n    bool isConnectedToMemory() const;\r\n\r\n    /*!\r\n     *  Sets the associated memory for the interface.\r\n     *\r\n     *    @param [in] memory      The memory to associate the interface with.\r\n     */\r\n    void setConnectedMemory(QSharedPointer<MemoryItem> memory);\r\n\r\n    /*!\r\n     *  Gets the memory associated with the interface.\r\n     *\r\n     *    @return The associated memory if any.\r\n     */\r\n    QSharedPointer<MemoryItem> getConnectedMemory() const;\r\n\r\n    //! Marks the interface as hierarchical.     \r\n    void setHierarchical();\r\n\r\n    /*!\r\n     *  Checks if the interface is hierarchical.\r\n     *\r\n     *    @return True, if the interface is hierarchical, otherwise false.\r\n     */\r\n    bool isHierarchical() const;\r\n\r\n    //! Marks the interface as bridged.     \r\n    void setBridged();\r\n\r\n    /*!\r\n     *  Checks if the interface is bridged.\r\n     *\r\n     *    @return True, if the interface is bridged, otherwise false.\r\n     */\r\n    bool isBridged() const;\r\n\r\n    /*!\r\n     *  Get the next interface nodes for a connection tree.\r\n     *\r\n     *    @return List of the next interface nodes.\r\n     */\r\n    QVector<QSharedPointer<ConnectivityInterface> > getChildInterfaceNodes() const;\r\n\r\n    /*!\r\n     *  Add an interface node to the tree.\r\n     *\r\n     *    @param [in] newChild    The new tree interface node.\r\n     */\r\n    void addChildInterfaceNode(QSharedPointer<ConnectivityInterface> newChild);\r\n\r\n    /*!\r\n     *  Remove a node from the tree.\r\n     *\r\n     *    @param [in] indexOfInterface    Index of the tree node.\r\n     */\r\n    void removeChildInterface(int const& indexOfInterface);\r\n\r\nprivate:\r\n\r\n\t// Disable copying.\r\n    ConnectivityInterface(ConnectivityInterface const& rhs);\r\n    ConnectivityInterface& operator=(ConnectivityInterface const& rhs);\r\n\r\n    //! The name of the interface.\r\n    QString name_;\r\n\r\n    //! The mode of the interface.\r\n    General::InterfaceMode mode_ = General::INTERFACE_MODE_COUNT;\r\n\r\n    //! The base address for the associated memories. Applicable for master interfaces.\r\n    QString baseAddress_;\r\n\r\n    //! The remap address for the associated memories. Applicable for mirrored slave interfaces.\r\n    QString remapAddress_;\r\n\r\n    //! The remap range for the associated memories. Applicable for mirrored slave interfaces.\r\n    QString range_;\r\n\r\n    //! The instance containing the interface.\r\n    QSharedPointer<ConnectivityComponent const> instance_;\r\n\r\n    //! The associated memory for the interface.\r\n    QSharedPointer<MemoryItem> memory_;\r\n\r\n    //! Whether the interface is hierarchical or not.\r\n    bool hierarchical_;\r\n\r\n    //! Whether the interface is a part of a bridge or not.\r\n    bool bridged_;\r\n\r\n    //! List of the next interface nodes in the tree.\r\n    QVector<QSharedPointer<ConnectivityInterface> > childInterfaceNodes_;\r\n};\r\n\r\n#endif // INTERFACE_H\r\n"
  },
  {
    "path": "editors/MemoryDesigner/FieldGraphicsItem.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: FieldGraphicsItem.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Mikko Teuho\r\n// Date: 22.11.2016\r\n//\r\n// Description:\r\n// Graphics item for visualizing a field in the memory designer.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"FieldGraphicsItem.h\"\r\n\r\n#include <common/KactusColors.h>\r\n\r\n#include <editors/MemoryDesigner/MemoryItem.h>\r\n#include <editors/MemoryDesigner/MemoryDesignerChildGraphicsItem.h>\r\n#include <editors/MemoryDesigner/MemoryDesignerConstants.h>\r\n#include <editors/MemoryDesigner/FieldOverlapItem.h>\r\n\r\n#include <QBrush>\r\n#include <QFont>\r\n#include <QFontMetrics>\r\n#include <QGraphicsScene>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FieldGraphicsItem::FieldGraphicsItem()\r\n//-----------------------------------------------------------------------------\r\nFieldGraphicsItem::FieldGraphicsItem(QSharedPointer<MemoryItem const> fieldItem, quint64 fieldOffset,\r\n    quint64 fieldLastBit, qreal fieldWidth, quint64 fieldHeight, bool isEmptyField,\r\n    QVector<QString> identifierChain, QFont labelFont,\r\n    QSharedPointer<ConnectivityComponent const> containingInstance, bool isOutsideRegister,\r\n    MemoryDesignerGraphicsItem* parentItem):\r\nMemoryDesignerChildGraphicsItem(fieldItem, QStringLiteral(\"Field\"), fieldOffset, fieldHeight, fieldWidth,\r\n    identifierChain, containingInstance, parentItem),\r\ncombinedRangeLabel_(new QGraphicsTextItem(\"\", this)),\r\nfieldName_(fieldItem->getName()),\r\noverlapIcon_(new QGraphicsPixmapItem(QPixmap(\":icons/common/graphics/triangle_arrow_down.png\"), this)),\r\nfieldOffset_(fieldOffset),\r\nfieldLastBit_(fieldLastBit),\r\nisOutsideRegister_(isOutsideRegister),\r\nisEmptyField_(isEmptyField)\r\n{\r\n    if (!fieldItem->getDisplayName().isEmpty())\r\n    {\r\n        fieldName_ = fieldItem->getDisplayName();\r\n    }\r\n\r\n    setupFieldItem(labelFont);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FieldGraphicsItem::FieldGraphicsItem()\r\n//-----------------------------------------------------------------------------\r\nFieldGraphicsItem::FieldGraphicsItem(FieldGraphicsItem const& other, MemoryDesignerGraphicsItem* parentItem):\r\nMemoryDesignerChildGraphicsItem(other, parentItem),\r\ncombinedRangeLabel_(new QGraphicsTextItem(\"\", this)),\r\nfieldName_(other.fieldName_),\r\n// overlapIcon_(new QGraphicsPixmapItem(QPixmap(\":icons/common/graphics/triangle_arrow_down.png\"), this))\r\noverlapIcon_(new QGraphicsPixmapItem(QPixmap(\":icons/common/graphics/triangle_arrow_down.png\"), this)),\r\nfieldOffset_(other.fieldOffset_),\r\nfieldLastBit_(other.fieldLastBit_),\r\nisOutsideRegister_(other.isOutsideRegister_),\r\nisEmptyField_(other.isEmptyField_)\r\n{\r\n    setRect(other.rect());\r\n\r\n    setupFieldItem(other.getNameLabel()->font());\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FieldGraphicsItem::setupFieldItem()\r\n//-----------------------------------------------------------------------------\r\nvoid FieldGraphicsItem::setupFieldItem(QFont const& labelFont)\r\n{\r\n    qreal overlapIconPositionX = boundingRect().right() - overlapIcon_->boundingRect().width() - (GridSize / 2);\r\n    qreal overlapIconPositionY = boundingRect().top() + (GridSize / 2);\r\n    overlapIcon_->setPos(overlapIconPositionX, overlapIconPositionY);\r\n    overlapIcon_->setVisible(false);\r\n\r\n    getNameLabel()->setFont(labelFont);\r\n    combinedRangeLabel_->setFont(labelFont);\r\n\r\n    setupGraphicsItem(fieldOffset_, fieldLastBit_, QStringLiteral(\"Field\"));\r\n    setLabelPositions();\r\n\r\n    QColor fieldColor = KactusColors::FIELD_COLOR;\r\n    if (isOutsideRegister_)\r\n    {\r\n        QString toolTipAddition = QStringLiteral(\r\n            \"<br><br><b><font color=\\\"red\\\">This field is not contained within register</font></b>\");\r\n        addToToolTip(toolTipAddition);\r\n\r\n        fieldColor = KactusColors::MISSING_COMPONENT;\r\n    }\r\n\r\n    setColors(fieldColor, isEmptyField_);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FieldGraphicsItem::~FieldGraphicsItem()\r\n//-----------------------------------------------------------------------------\r\nFieldGraphicsItem::~FieldGraphicsItem()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FieldGraphicsItem::setEmptyItemRangeColors()\r\n//-----------------------------------------------------------------------------\r\nvoid FieldGraphicsItem::setEmptyItemRangeColors(QColor emptyItemRangeColour)\r\n{\r\n    combinedRangeLabel_->setDefaultTextColor(emptyItemRangeColour);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FieldGraphicsItem::setLabelPositions()\r\n//-----------------------------------------------------------------------------\r\nvoid FieldGraphicsItem::setLabelPositions()\r\n{\r\n    hideMemoryRangeLabels();\r\n\r\n    QGraphicsTextItem* nameLabel = getNameLabel();\r\n\r\n    if (combinedRangeLabel_->toPlainText().isEmpty())\r\n    {\r\n        QString rangeValue = QStringLiteral(\"\");\r\n\r\n        quint64 fieldBaseAddress = getBaseAddress();\r\n        quint64 fieldLastAddress = getLastAddress();\r\n        if (fieldBaseAddress == fieldLastAddress)\r\n        {\r\n            rangeValue = QString::number(fieldBaseAddress, 16).toUpper();\r\n        }\r\n        else\r\n        {\r\n            QString offset = QString::number(fieldBaseAddress, 16).toUpper();\r\n            QString lastBit = QString::number(fieldLastAddress, 16).toUpper();\r\n\r\n            rangeValue = lastBit + QStringLiteral(\"..\") + offset;\r\n        }\r\n\r\n        combinedRangeLabel_->setPlainText(rangeValue);\r\n    }\r\n\r\n    qreal nameY = boundingRect().height() / 2 - nameLabel->boundingRect().height() / 2 - 6;\r\n    qreal rangeY = nameY + nameLabel->boundingRect().height() / 2 + 1;\r\n    qreal rangeX = - combinedRangeLabel_->boundingRect().width() / 2;\r\n\r\n    nameLabel->setY(nameY);\r\n    combinedRangeLabel_->setPos(rangeX, rangeY);\r\n\r\n    fitNameToBoundaries(nameLabel);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FieldGraphicsItem::fitNameLabel()\r\n//-----------------------------------------------------------------------------\r\nvoid FieldGraphicsItem::fitNameToBoundaries(QGraphicsTextItem* nameLabel)\r\n{\r\n    const int NAME_MARGIN = 14;\r\n\r\n    QFontMetrics nameFontMetrics(nameLabel->font());\r\n    unsigned int itemBoundingWidth = boundingRect().width() - NAME_MARGIN;\r\n\r\n    QString elidedName = nameFontMetrics.elidedText(fieldName_, Qt::ElideRight, itemBoundingWidth);\r\n    nameLabel->setPlainText(elidedName);\r\n    nameLabel->setX(-nameLabel->boundingRect().width() / 2);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FieldGraphicsItem::condense()\r\n//-----------------------------------------------------------------------------\r\nvoid FieldGraphicsItem::condense(qreal newItemHeight)\r\n{\r\n    QRectF itemRectangle = boundingRect();\r\n\r\n    qreal itemXPosition = -itemRectangle.width() / 2;\r\n    qreal itemWidth = itemRectangle.width() - 1;\r\n\r\n    setRect(itemXPosition, 0, itemWidth, newItemHeight);\r\n    setLabelPositions();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FieldGraphicsItem::changeWidth()\r\n//-----------------------------------------------------------------------------\r\nvoid FieldGraphicsItem::changeWidth(qreal widthChange)\r\n{\r\n    qreal newWidth = boundingRect().width() + widthChange - 1;\r\n\r\n    setRect(-newWidth / 2, 0, newWidth, boundingRect().height() - 1);\r\n\r\n    QGraphicsTextItem* nameLabel = getNameLabel();\r\n\r\n    if (widthChange > 0)\r\n    {\r\n        nameLabel->setPlainText(fieldName_);\r\n    }\r\n\r\n    qreal nameX = - nameLabel->boundingRect().width() / 2;\r\n    nameLabel->setX(nameX);\r\n\r\n    fitNameToBoundaries(nameLabel);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FieldGraphicsItem::resizeAndRepositionOverlappingItems()\r\n//-----------------------------------------------------------------------------\r\nvoid FieldGraphicsItem::resizeAndRepositionOverlappingItems()\r\n{\r\n    if (!overlapFields_.isEmpty())\r\n    {\r\n        qreal overlapRectangleLeft = sceneBoundingRect().left();\r\n        qreal overlapRectangleRight = sceneBoundingRect().right();\r\n        foreach (FieldGraphicsItem::CombinedOverlappingFieldItem overlapCombination, overlapFields_)\r\n        {\r\n            FieldOverlapItem* overlapItem = overlapCombination.overlapItem_;\r\n            FieldGraphicsItem* overlappedField = overlapCombination.overlappedField_;\r\n            QRectF overlapFieldRectangle = overlappedField->sceneBoundingRect();\r\n            int overlapFieldLineWidth = overlappedField->pen().width();\r\n            overlapItem->resizeToRectangle(overlapFieldRectangle, overlapFieldLineWidth);\r\n\r\n            qreal overlappedFieldCurrentPosition = overlappedField->scenePos().x();\r\n            overlapItem->setX(overlappedFieldCurrentPosition);\r\n\r\n            overlapRectangleLeft = qMin(overlapRectangleLeft, overlapItem->sceneBoundingRect().left());\r\n            overlapRectangleRight = qMax(overlapRectangleRight, overlapItem->sceneBoundingRect().right());\r\n        }\r\n\r\n        qreal overlapWidth = overlapRectangleRight - overlapRectangleLeft;\r\n        qreal newOverlapHeight = overlapAreaRectangle_->boundingRect().height() - overlapAreaRectangle_->pen().width();\r\n        qreal overlapPositionX = overlapRectangleLeft + overlapWidth / 2;\r\n        overlapAreaRectangle_->setRect(-overlapWidth / 2, 0, overlapWidth, newOverlapHeight);\r\n        overlapAreaRectangle_->setX(overlapPositionX);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FieldGraphicsItem::getMaximumNeededWidthChange()\r\n//-----------------------------------------------------------------------------\r\nqreal FieldGraphicsItem::getNeededWithChangeToDisplayFullName() const\r\n{\r\n    qreal neededWithChangeToDisplayFullName = 0;\r\n\r\n    QString currentName = getNameLabel()->toPlainText();\r\n    if (currentName.compare(fieldName_, Qt::CaseInsensitive) != 0)\r\n    {\r\n        qreal currentWidth = boundingRect().width();\r\n\r\n        getNameLabel()->setPlainText(fieldName_);\r\n        qreal nameLabelWidth = getNameLabel()->boundingRect().width();\r\n\r\n        neededWithChangeToDisplayFullName = nameLabelWidth - currentWidth + 12;\r\n\r\n        quint64 fieldWidth = getLastAddress() - getBaseAddress() + 1;\r\n        neededWithChangeToDisplayFullName = neededWithChangeToDisplayFullName / fieldWidth;\r\n    }\r\n\r\n    return neededWithChangeToDisplayFullName;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FieldGraphicsItem::addOverlappingFieldItem()\r\n//-----------------------------------------------------------------------------\r\nvoid FieldGraphicsItem::addOverlappingFieldItem(FieldGraphicsItem* overlappingFieldItem, QBrush overlapBrush,\r\n    QGraphicsScene* containingScene)\r\n{\r\n    QRectF fieldRectangle = sceneBoundingRect();\r\n    qreal overlapPositionY = fieldRectangle.bottom();\r\n\r\n    if (!overlapAreaRectangle_)\r\n    {\r\n        createOverlapRectangle(overlapPositionY, fieldRectangle, containingScene);\r\n    }\r\n\r\n    qreal currentOverlapHeight = 0;\r\n    foreach (CombinedOverlappingFieldItem overlapField, overlapFields_)\r\n    {\r\n        FieldOverlapItem* overlapItem = overlapField.overlapItem_;\r\n        currentOverlapHeight += overlapItem->boundingRect().height();\r\n    }\r\n\r\n    setupOverlapRectangle(currentOverlapHeight, overlappingFieldItem);\r\n\r\n    overlapPositionY += currentOverlapHeight;\r\n\r\n    QFont labelFont = combinedRangeLabel_->font();\r\n    FieldOverlapItem* newOverlapItem =\r\n        new FieldOverlapItem(overlappingFieldItem, containingScene, overlapBrush, labelFont);\r\n\r\n    newOverlapItem->setY(overlapPositionY);\r\n\r\n    CombinedOverlappingFieldItem combinedOverlappingField;\r\n    combinedOverlappingField.overlapItem_ = newOverlapItem;\r\n    combinedOverlappingField.overlappedField_ = overlappingFieldItem;\r\n\r\n    overlapFields_.append(combinedOverlappingField);\r\n\r\n    if (!overlapIcon_->isVisible())\r\n    {\r\n        overlapIcon_->setVisible(true);\r\n        setAcceptHoverEvents(true);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FieldGraphicsItem::createOverlapRectangle()\r\n//-----------------------------------------------------------------------------\r\nvoid FieldGraphicsItem::createOverlapRectangle(qreal rectanglePositionY, QRectF fieldRectangle,\r\n    QGraphicsScene* containingScene)\r\n{\r\n    int fieldLineWidth = pen().width();\r\n\r\n    qreal overlapWidth = fieldRectangle.width() - fieldLineWidth;\r\n    qreal overlapHeight = fieldRectangle.height() - fieldLineWidth;\r\n    QRectF newOverlapRectangle(-overlapWidth / 2, 0, overlapWidth, overlapHeight);\r\n    overlapAreaRectangle_ = new QGraphicsRectItem(newOverlapRectangle);\r\n\r\n    overlapAreaRectangle_->setOpacity(0.9);\r\n\r\n    QBrush overlapRectangleBrush(KactusColors::REGULAR_FIELD);\r\n    overlapAreaRectangle_->setBrush(overlapRectangleBrush);\r\n\r\n    overlapAreaRectangle_->setPos(scenePos().x(), rectanglePositionY);\r\n    containingScene->addItem(overlapAreaRectangle_);\r\n\r\n    overlapAreaRectangle_->hide();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FieldGraphicsItem::setupOverlapRectangle()\r\n//-----------------------------------------------------------------------------\r\nvoid FieldGraphicsItem::setupOverlapRectangle(qreal currentOverlapHeight, FieldGraphicsItem* newOverlapItem)\r\n{\r\n    qreal newOverlapItemLineWidth = newOverlapItem->pen().width();\r\n\r\n    QRectF overlappingItemRectangle = newOverlapItem->sceneBoundingRect();\r\n    QRectF oldOverlapRectangle = overlapAreaRectangle_->sceneBoundingRect();\r\n\r\n    qreal newOverlapRectangleLeft =\r\n        qMin(oldOverlapRectangle.left(), overlappingItemRectangle.left() + newOverlapItemLineWidth);\r\n    qreal newOverlapRectangleRight =\r\n        qMax(oldOverlapRectangle.right(), overlappingItemRectangle.right() - newOverlapItemLineWidth);\r\n\r\n    qreal overlapWidth = newOverlapRectangleRight - newOverlapRectangleLeft;\r\n    qreal overlapHeight = currentOverlapHeight + overlappingItemRectangle.height();\r\n\r\n    QRectF newOverlapRectangle(-overlapWidth / 2, 0, overlapWidth, overlapHeight);\r\n    overlapAreaRectangle_->setRect(newOverlapRectangle);\r\n\r\n    qreal newPositionX = newOverlapRectangleLeft + (overlapWidth / 2);\r\n    overlapAreaRectangle_->setX(newPositionX);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FieldGraphicsItem::mousePressEvent()\r\n//-----------------------------------------------------------------------------\r\nvoid FieldGraphicsItem::mousePressEvent(QGraphicsSceneMouseEvent *event)\r\n{\r\n    if (event->button() == Qt::LeftButton && !overlapFields_.isEmpty())\r\n    {\r\n        foreach (CombinedOverlappingFieldItem combinedOverlapField, overlapFields_)\r\n        {\r\n            FieldOverlapItem* overlapField = combinedOverlapField.overlapItem_;\r\n\r\n            overlapField->show();\r\n            overlapAreaRectangle_->show();\r\n\r\n            combinedOverlapField.overlappedField_->hide();\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FieldGraphicsItem::hoverLeaveEvent()\r\n//-----------------------------------------------------------------------------\r\nvoid FieldGraphicsItem::hoverLeaveEvent(QGraphicsSceneHoverEvent*)\r\n{\r\n    if (!overlapFields_.isEmpty())\r\n    {\r\n        foreach (CombinedOverlappingFieldItem combindedOverlapField, overlapFields_)\r\n        {\r\n            combindedOverlapField.overlapItem_->hide();\r\n            overlapAreaRectangle_->hide();\r\n            combindedOverlapField.overlappedField_->show();\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FieldGraphicsItem::getCombinedRangeText()\r\n//-----------------------------------------------------------------------------\r\nQString FieldGraphicsItem::getCombinedRangeText() const\r\n{\r\n    return combinedRangeLabel_->toPlainText();\r\n}\r\n"
  },
  {
    "path": "editors/MemoryDesigner/FieldGraphicsItem.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: FieldGraphicsItem.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Mikko Teuho\r\n// Date: 22.11.2016\r\n//\r\n// Description:\r\n// Graphics item for visualizing a field in the memory designer.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef FIELDGRAPHICSITEM_H\r\n#define FIELDGRAPHICSITEM_H\r\n\r\n#include <common/graphicsItems/GraphicsItemTypes.h>\r\n\r\n#include <editors/MemoryDesigner/MemoryDesignerChildGraphicsItem.h>\r\n\r\nclass MemoryItem;\r\nclass MemoryDesignerChildGraphicsItem;\r\nclass FieldOverlapItem;\r\n\r\n#include <QSharedPointer>\r\n#include <QGraphicsPixmapItem>\r\n#include <QGraphicsSceneMouseEvent>\r\n#include <QGraphicsScene>\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Graphics item for visualizing a field in the memory designer.\r\n//-----------------------------------------------------------------------------\r\nclass FieldGraphicsItem : public MemoryDesignerChildGraphicsItem\r\n{\r\n\r\npublic:\r\n    //! Type of this graphics item.\r\n    enum { Type = GFX_TYPE_MEMORY_ITEM };\r\n\r\n    /*!\r\n     *  The constructor.\r\n     *\r\n     *    @param [in] fieldName           Name of the field.\r\n     *    @param [in] displayName         Display name of the field.\r\n     *    @param [in] fieldOffset         Offset of the field.\r\n     *    @param [in] fieldLastBit        Last bit used by the field.\r\n     *    @param [in] fieldWidth          Width of the field.\r\n     *    @param [in] fieldHeight         Height of the field.\r\n     *    @param [in] isEmptyField        Value for empty fields.\r\n     *    @param [in] identifierChain     Chain of strings identifying this item.\r\n     *    @param [in] labelFont           Font for the field labels.\r\n     *    @param [in] containingInstance  Name of the containing component instance.\r\n     *    @param [in] isOutsideRegister   Holds whether the field is out of bounds of the register or not.\r\n     *    @param [in] parentItem          The parent graphics item.\r\n     */\r\n    FieldGraphicsItem(QSharedPointer<MemoryItem const> fieldItem, quint64 fieldOffset, quint64 fieldLastBit,\r\n        qreal fieldWidth, quint64 fieldHeight, bool isEmptyField, QVector<QString> identifierChain,\r\n        QFont labelFont, QSharedPointer<ConnectivityComponent const> containingInstance, bool isOutsideRegister,\r\n        MemoryDesignerGraphicsItem* parentItem);\r\n\r\n    /*!\r\n     *  The copy constructor.\r\n     *\r\n     *    @param [in] other     The original field item.\r\n     *\r\n     *    @return Copy of the original field item.\r\n     */\r\n    FieldGraphicsItem(FieldGraphicsItem const& other, MemoryDesignerGraphicsItem* parentItem);\r\n\r\n\t/*!\r\n     *  The destructor.\r\n     */\r\n    virtual ~FieldGraphicsItem();\r\n\r\n    /*!\r\n     *  Get the graphics type.\r\n     */\r\n    virtual int type() const { return Type; }\r\n\r\n    /*!\r\n     *  Condense this graphics item.\r\n     *\r\n     *    @param [in] newItemHeight   The new height.\r\n     */\r\n    virtual void condense(qreal newItemHeight);\r\n\r\n    /*!\r\n     *  Change the width.\r\n     *\r\n     *    @param [in] widthChange     Change in width..\r\n     */\r\n    void changeWidth(qreal widthChange);\r\n\r\n    /*!\r\n     *  Get the needed change in width to fully display the name label within this item.\r\n     *\r\n     *    @return The needed change in width to fully display the name label within this item.\r\n     */\r\n    qreal getNeededWithChangeToDisplayFullName() const;\r\n\r\n    /*!\r\n     *  Add an overlap field item from the overlapping field graphics item.\r\n     *\r\n     *    @param [in] overlappingFieldItem    The overlapping field graphics item.\r\n     *    @param [in] overlapBrush            Brush used to draw the overlap item.\r\n     *    @param [in] containingScene         Scene containing the overlapping field item.\r\n     */\r\n    void addOverlappingFieldItem(FieldGraphicsItem* overlappingFieldItem, QBrush overlapBrush,\r\n        QGraphicsScene* containingScene);\r\n\r\n    /*!\r\n     *  Get the text from the combined range label.\r\n     *\r\n     *    @return The text contained within the combined range label.\r\n     */\r\n    QString getCombinedRangeText() const;\r\n\r\n    /*!\r\n     *  Resize and reposition the overlapping items when the fields are extended.\r\n     */\r\n    void resizeAndRepositionOverlappingItems();\r\n\r\nprotected:\r\n\r\n    /*!\r\n     *  Handler for the mouse press event.\r\n     *\r\n     *    @param [in] event   The mouse press event.\r\n     */\r\n    virtual void mousePressEvent(QGraphicsSceneMouseEvent *event);\r\n\r\n    /*!\r\n     *  Handler for the hover leave event.\r\n     *\r\n     *    @param [in] event   The hover leave event.\r\n     */\r\n    virtual void hoverLeaveEvent(QGraphicsSceneHoverEvent *event);\r\n\r\nprivate:\r\n    // Disable copying.\r\n    FieldGraphicsItem& operator=(FieldGraphicsItem const& rhs);\r\n\r\n    /*!\r\n     *  Setup the field item.\r\n     *\r\n     *    @param [in] labelFont     Font used for the labels.\r\n     */\r\n    void setupFieldItem(QFont const& labelFont);\r\n\r\n    /*!\r\n     *  Set colors for ranges in an empty field graphics item.\r\n     *\r\n     *    @param [in] emptyItemRangeColour    The color for the empty field item ranges.\r\n     */\r\n    virtual void setEmptyItemRangeColors(QColor emptyItemRangeColour);\r\n\r\n    /*!\r\n     *  Set the label positions.\r\n     */\r\n    virtual void setLabelPositions();\r\n\r\n    /*!\r\n     *  Fit the name label to the boundaries of the item.\r\n     *\r\n     *    @param [in] nameLabel   The selected name label.\r\n     */\r\n    void fitNameToBoundaries(QGraphicsTextItem* nameLabel);\r\n\r\n    /*!\r\n     *  Create the rectangle for containing the overlapping field items.\r\n     *\r\n     *    @param [in] rectanglePositionY  Y coordinate of the rectangle.\r\n     *    @param [in] fieldRectangle      The field bounding rectangle.\r\n     *    @param [in] containingScene     Scene containing the field item.\r\n     */\r\n    void createOverlapRectangle(qreal rectanglePositionY, QRectF fieldRectangle, QGraphicsScene* containingScene);\r\n\r\n    /*!\r\n     *  Setup the rectangle containing the overlapping field items.\r\n     *\r\n     *    @param [in] currentOverlapHeight    Current height of the overlapping rectangle.\r\n     *    @param [in] newOverlapItem          The new overlapping field item.\r\n     */\r\n    void setupOverlapRectangle(qreal currentOverlapHeight, FieldGraphicsItem* newOverlapItem);\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! Overlapping item containing both the overlapping field graphics item and the overlap field item\r\n    //! constructed from it.\r\n    struct CombinedOverlappingFieldItem\r\n    {\r\n        //! The overlap field item.\r\n        FieldOverlapItem* overlapItem_;\r\n\r\n        //! The overlapped field graphics item.\r\n        FieldGraphicsItem* overlappedField_;\r\n    };\r\n\r\n    //! Label for the combined range value.\r\n    QGraphicsTextItem* combinedRangeLabel_;\r\n\r\n    //! The original name of the field.\r\n    QString fieldName_;\r\n\r\n    //! List of all the overlapped field items.\r\n    QVector<CombinedOverlappingFieldItem> overlapFields_;\r\n\r\n    //! Icon to display the overlapped field items.\r\n    QGraphicsPixmapItem* overlapIcon_;\r\n\r\n    //! Rectangle for containing all the overlapped field graphics items.\r\n    QGraphicsRectItem* overlapAreaRectangle_ = nullptr;\r\n\r\n    //! Offset of the field.\r\n    quint64 fieldOffset_ = 0;\r\n\r\n    //! Last bit used by the field.\r\n    quint64 fieldLastBit_ = 0;\r\n\r\n    //! Flag for fields outside the containing register.\r\n    bool isOutsideRegister_ = false;\r\n\r\n    //! Flag for an empty field.\r\n    bool isEmptyField_ = false;\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n\r\n#endif // FIELDGRAPHICSITEM_H\r\n"
  },
  {
    "path": "editors/MemoryDesigner/FieldOverlapItem.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: FieldOverlapItem.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 07.02.2017\n//\n// Description:\n// Graphics item for visualizing an overlapping field in the memory designer.\n//-----------------------------------------------------------------------------\n\n#include \"FieldOverlapItem.h\"\n\n#include <editors/MemoryDesigner/FieldGraphicsItem.h>\n\n#include <QFontMetrics>\n\n//-----------------------------------------------------------------------------\n// Function: FieldOverlapItem::FieldOverlapItem()\n//-----------------------------------------------------------------------------\nFieldOverlapItem::FieldOverlapItem(FieldGraphicsItem* overlappingFieldItem, QGraphicsScene* containingScene,\n    QBrush overlapBrush, QFont labelFont, QGraphicsItem* parentItem):\nQGraphicsRectItem(parentItem),\nfieldName_(overlappingFieldItem->name()),\nnameLabel_(new QGraphicsTextItem(this)),\ncombinedRangeLabel_(new QGraphicsTextItem(this))\n{\n    QString overlapDisplayName = overlappingFieldItem->displayName();\n    if (!overlapDisplayName.isEmpty())\n    {\n        fieldName_ = overlapDisplayName;\n    }\n\n    nameLabel_->setPlainText(fieldName_);\n    combinedRangeLabel_->setPlainText(overlappingFieldItem->getCombinedRangeText());\n\n    nameLabel_->setFont(labelFont);\n    combinedRangeLabel_->setFont(labelFont);\n\n    int overlapLineWidth = overlappingFieldItem->pen().width();\n    qreal rectangleWidth = overlappingFieldItem->boundingRect().width() - overlapLineWidth;\n    qreal rectangleHeight = overlappingFieldItem->boundingRect().height() - overlapLineWidth;\n    QRectF overlapRectangle(-rectangleWidth / 2, 0, rectangleWidth, rectangleHeight);\n\n    setRect(overlapRectangle);\n    setPos(overlappingFieldItem->scenePos());\n\n    setBrush(overlapBrush);\n    containingScene->addItem(this);\n\n    setLabelPositions();\n\n    hide();\n}\n\n//-----------------------------------------------------------------------------\n// Function: FieldOverlapItem::~FieldOverlapItem()\n//-----------------------------------------------------------------------------\nFieldOverlapItem::~FieldOverlapItem()\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: FieldOverlapItem::setLabelPositions()\n//-----------------------------------------------------------------------------\nvoid FieldOverlapItem::setLabelPositions()\n{\n    qreal nameY = boundingRect().height() / 2 - nameLabel_->boundingRect().height() / 2 - 6;\n    qreal rangeY = nameY + nameLabel_->boundingRect().height() / 2 + 1;\n    qreal rangeX = - combinedRangeLabel_->boundingRect().width() / 2;\n\n    nameLabel_->setY(nameY);\n    combinedRangeLabel_->setPos(rangeX, rangeY);\n\n    fitNameToBoundaries(nameLabel_);\n}\n\n//-----------------------------------------------------------------------------\n// Function: FieldOverlapItem::fitNameToBoundaries()\n//-----------------------------------------------------------------------------\nvoid FieldOverlapItem::fitNameToBoundaries(QGraphicsTextItem* nameLabel)\n{\n    const int NAME_MARGIN = 14;\n\n    QFontMetrics nameFontMetrics(nameLabel->font());\n    unsigned int itemBoundingWidth = boundingRect().width() - NAME_MARGIN;\n\n    QString elidedName = nameFontMetrics.elidedText(fieldName_, Qt::ElideRight, itemBoundingWidth);\n    nameLabel->setPlainText(elidedName);\n    nameLabel->setX(-nameLabel->boundingRect().width() / 2);\n}\n\n//-----------------------------------------------------------------------------\n// Function: FieldOverlapItem::resizeToRectangle()\n//-----------------------------------------------------------------------------\nvoid FieldOverlapItem::resizeToRectangle(QRectF rectangle, int rectangleLineWidth)\n{\n    qreal newWidth = rectangle.width() - rectangleLineWidth;\n    qreal newHeight = rectangle.height() - rectangleLineWidth;\n\n    setRect(-newWidth / 2, 0, newWidth, newHeight);\n}\n"
  },
  {
    "path": "editors/MemoryDesigner/FieldOverlapItem.h",
    "content": "//-----------------------------------------------------------------------------\n// File: FieldOverlapItem.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 07.02.2017\n//\n// Description:\n// Graphics item for visualizing an overlapping field in the memory designer.\n//-----------------------------------------------------------------------------\n\n#ifndef FIELDOVERLAPITEM_H\n#define FIELDOVERLAPITEM_H\n\n#include <common/graphicsItems/GraphicsItemTypes.h>\n\nclass FieldGraphicsItem;\n\n#include <QGraphicsRectItem>\n#include <QGraphicsScene>\n#include <QBrush>\n\n//-----------------------------------------------------------------------------\n//! Graphics item for visualizing an overlapping field in the memory designer.\n//-----------------------------------------------------------------------------\nclass FieldOverlapItem : public QGraphicsRectItem\n{\n\npublic:\n    //! Type of this graphics item.\n    enum { Type = GFX_TYPE_MEMORY_ITEM };\n\n    /*!\n     *  The constructor.\n     *\n     *    @param [in] overlappingFieldItem    Field graphics item from which this overlap item is created from.\n     *    @param [in] containingScene         Graphics scene containing the field graphics item.\n     *    @param [in] overlapBrush            Brush used to draw the overlap item.\n     *    @param [in] labelFont               Font used by the labels.\n     *    @param [in] parentItem              The parent graphics item.\n     */\n    FieldOverlapItem(FieldGraphicsItem* overlappingFieldItem, QGraphicsScene* containingScene, QBrush overlapBrush,\n        QFont labelFont, QGraphicsItem* parentItem = 0);\n\n\t/*!\n     *  The destructor.\n     */\n    virtual ~FieldOverlapItem();\n\n    /*!\n     *  Get the graphics type.\n     */\n    virtual int type() const { return Type; }\n\n    /*!\n     *  Resize this item to match the selected rectangle.\n     *\n     *    @param [in] rectangle           The selected rectangle.\n     *    @param [in] rectangleLineWidth  Line width of the selected rectangle.\n     */\n    void resizeToRectangle(QRectF rectangle, int rectangleLineWidth);\n\nprivate:\n    // Disable copying.\n    FieldOverlapItem(FieldOverlapItem const& rhs);\n    FieldOverlapItem& operator=(FieldOverlapItem const& rhs);\n\n    /*!\n     *  Set the label positions.\n     */\n    virtual void setLabelPositions();\n\n    /*!\n     *  Fit the name label to the boundaries of the item.\n     *\n     *    @param [in] nameLabel   The selected name label.\n     */\n    void fitNameToBoundaries(QGraphicsTextItem* nameLabel);\n\n    //-----------------------------------------------------------------------------\n    // Data.\n    //-----------------------------------------------------------------------------\n\n    //! Name of the overlapping field.\n    QString fieldName_;\n\n    //! Label containing the item name.\n    QGraphicsTextItem* nameLabel_;\n\n    //! Label containing the combined range value.\n    QGraphicsTextItem* combinedRangeLabel_;\n};\n\n//-----------------------------------------------------------------------------\n\n#endif // FIELDOVERLAPITEM_H\n"
  },
  {
    "path": "editors/MemoryDesigner/MainMemoryGraphicsItem.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: MainMemoryGraphicsItem.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Mikko Teuho\r\n// Date: 16.09.2016\r\n//\r\n// Description:\r\n// Parent class for memory map and address space graphics items in memory designer.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"MainMemoryGraphicsItem.h\"\r\n\r\n#include <editors/common/diagramgrid.h>\r\n\r\n#include <editors/MemoryDesigner/MemoryItem.h>\r\n#include <editors/MemoryDesigner/MemoryColumn.h>\r\n#include <editors/MemoryDesigner/MemoryConnectionItem.h>\r\n#include <editors/MemoryDesigner/MemoryCollisionItem.h>\r\n#include <editors/MemoryDesigner/MemoryDesignerChildGraphicsItem.h>\r\n#include <editors/MemoryDesigner/MemoryExtensionGraphicsItem.h>\r\n#include <editors/MemoryDesigner/MemoryDesignerConstants.h>\r\n#include <editors/MemoryDesigner/ConnectivityComponent.h>\r\n\r\n#include <QFont>\r\n#include <QMenu>\r\n#include <QGraphicsSceneEvent>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MainMemoryGraphicsItem::MainMemoryGraphicsItem()\r\n//-----------------------------------------------------------------------------\r\nMainMemoryGraphicsItem::MainMemoryGraphicsItem(QSharedPointer<MemoryItem const> memoryItem,\r\n    QSharedPointer<ConnectivityComponent const> containingInstance,\r\n    QString const& subItemType,\r\n    bool filterSubItems,\r\n    QVector<QString> identifierChain,\r\n    QGraphicsItem* parent):\r\nMemoryDesignerGraphicsItem(memoryItem->getName(), memoryItem->getDisplayName(), identifierChain, containingInstance, parent),\r\nSubMemoryLayout(memoryItem, subItemType, filterSubItems, this),\r\ninstanceNameLabel_(new QGraphicsTextItem(containingInstance->getName(), this)),\r\nmemoryItem_(memoryItem),\r\nisOriginalItem_(true),\r\nclones_(new QVector<MainMemoryGraphicsItem*>())\r\n{\r\n    setupDuringConstruction();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MainMemoryGraphicsItem::MainMemoryGraphicsItem()\r\n//-----------------------------------------------------------------------------\r\nMainMemoryGraphicsItem::MainMemoryGraphicsItem(MainMemoryGraphicsItem const& other) :\r\nMemoryDesignerGraphicsItem(other, other.parentItem()),\r\nSubMemoryLayout(other, this),\r\ninstanceNameLabel_(new QGraphicsTextItem(other.getContainingInstance()->getName(), this)),\r\nmemoryItem_(other.memoryItem_),\r\nisOriginalItem_(false)\r\n{\r\n    setupDuringConstruction();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MainMemoryGraphicsItem::setupDuringConstruction()\r\n//-----------------------------------------------------------------------------\r\nvoid MainMemoryGraphicsItem::setupDuringConstruction()\r\n{\r\n    setFlag(ItemSendsGeometryChanges);\r\n    setFlag(ItemSendsScenePositionChanges);\r\n\r\n    QFont labelFont = getNameLabel()->font();\r\n    instanceNameLabel_->setFont(labelFont);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MainMemoryGraphicsItem::getInstanceNameLabel()\r\n//-----------------------------------------------------------------------------\r\nQGraphicsTextItem* MainMemoryGraphicsItem::getInstanceNameLabel() const\r\n{\r\n    return instanceNameLabel_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MainMemoryGraphicsItem::moveItemAndConnectedItems()\r\n//-----------------------------------------------------------------------------\r\nvoid MainMemoryGraphicsItem::moveItemAndConnectedItems(qreal yTransfer)\r\n{\r\n    moveBy(0, yTransfer);\r\n\r\n    QSharedPointer<QVector<MainMemoryGraphicsItem*> > visitedMemories (new QVector<MainMemoryGraphicsItem*> ());\r\n    visitedMemories->append(this);\r\n\r\n    QMultiMap<quint64, MemoryConnectionItem*> allConnectedConnections =\r\n        getAllConnectionsFromConnectedItems(visitedMemories);\r\n\r\n    QSharedPointer<QVector<MainMemoryGraphicsItem*> > movedItems(new QVector<MainMemoryGraphicsItem*>());\r\n\r\n    QMultiMapIterator<quint64, MemoryConnectionItem*> connectionIterator(allConnectedConnections);\r\n    while (connectionIterator.hasNext())\r\n    {\r\n        connectionIterator.next();\r\n        MemoryConnectionItem* connectionItem = connectionIterator.value();\r\n\r\n        connectionItem->moveConnectedItems(movedItems, this, yTransfer);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MainMemoryGraphicsItem::addMemoryConnection()\r\n//-----------------------------------------------------------------------------\r\nvoid MainMemoryGraphicsItem::addMemoryConnection(MemoryConnectionItem* connectionItem)\r\n{\r\n    MemoryDesignerGraphicsItem::addMemoryConnection(connectionItem);\r\n\r\n    addConnectionToSubItems(connectionItem);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MainMemoryGraphicsItem::getLastConnection()\r\n//-----------------------------------------------------------------------------\r\nMemoryConnectionItem* MainMemoryGraphicsItem::getLastConnection() const\r\n{\r\n    MemoryConnectionItem* lastConnection = 0;\r\n    quint64 lastConnectionRangeEnd = 0;\r\n\r\n    QMultiMapIterator<quint64, MemoryConnectionItem*> connectionIterator(getMemoryConnections());\r\n    while (connectionIterator.hasNext())\r\n    {\r\n        connectionIterator.next();\r\n\r\n        MemoryConnectionItem* connection = connectionIterator.value();\r\n        quint64 connectionRangeEnd = connection->getRangeEndValue();\r\n        if (connectionRangeEnd >= lastConnectionRangeEnd)\r\n        {\r\n            lastConnection = connection;\r\n            lastConnectionRangeEnd = connectionRangeEnd;\r\n        }\r\n    }\r\n\r\n    return lastConnection;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MainMemoryGraphicsItem::getFirstConnection()\r\n//-----------------------------------------------------------------------------\r\nMemoryConnectionItem* MainMemoryGraphicsItem::getFirstConnection() const\r\n{\r\n    MemoryConnectionItem* firstConnection = 0;\r\n\r\n    if (!getMemoryConnections().isEmpty())\r\n    {\r\n        firstConnection = getMemoryConnections().first();\r\n        quint64 firstConnectionRangeStart = firstConnection->getRangeStartValue();\r\n\r\n        QMultiMapIterator<quint64, MemoryConnectionItem*> connectionIterator(getMemoryConnections());\r\n        while (connectionIterator.hasNext())\r\n        {\r\n            connectionIterator.next();\r\n\r\n            MemoryConnectionItem* connection = connectionIterator.value();\r\n            quint64 connectionRangeStart = connection->getRangeStartValue();\r\n            if (connectionRangeStart <= firstConnectionRangeStart)\r\n            {\r\n                firstConnection = connection;\r\n                firstConnectionRangeStart = connectionRangeStart;\r\n            }\r\n        }\r\n    }\r\n\r\n    return firstConnection;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MainMemoryGraphicsItem::isCompressed()\r\n//-----------------------------------------------------------------------------\r\nbool MainMemoryGraphicsItem::isCompressed() const\r\n{\r\n    return compressed_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MainMemoryGraphicsItem::setCompressed()\r\n//-----------------------------------------------------------------------------\r\nvoid MainMemoryGraphicsItem::setCompressed(bool newCompressValue)\r\n{\r\n    compressed_ = newCompressValue;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MainMemoryGraphicsItem::setExtensionItem()\r\n//-----------------------------------------------------------------------------\r\nvoid MainMemoryGraphicsItem::setExtensionItem(MemoryExtensionGraphicsItem* newExtensionItem)\r\n{\r\n    extensionItem_ = newExtensionItem;\r\n\r\n    connect(extensionItem_, SIGNAL(openComponentDocument(const VLNV&, QVector<QString>)),\r\n        this, SIGNAL(openComponentDocument(const VLNV&, QVector<QString>)), Qt::UniqueConnection);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MainMemoryGraphicsItem::getExtensionItem()\r\n//-----------------------------------------------------------------------------\r\nMemoryExtensionGraphicsItem* MainMemoryGraphicsItem::getExtensionItem() const\r\n{\r\n    return extensionItem_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MainMemoryGraphicsItem::hasExtensionItem()\r\n//-----------------------------------------------------------------------------\r\nbool MainMemoryGraphicsItem::hasExtensionItem() const\r\n{\r\n    if (extensionItem_)\r\n    {\r\n        return true;\r\n    }\r\n    else\r\n    {\r\n        return false;\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MainMemoryGraphicsItem::getMemoryItem()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<MemoryItem const> MainMemoryGraphicsItem::getMemoryItem() const\r\n{\r\n    return memoryItem_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MainMemoryGraphicsItem::getItemWidth()\r\n//-----------------------------------------------------------------------------\r\nqreal MainMemoryGraphicsItem::getItemWidth() const\r\n{\r\n    qreal itemWidth = boundingRect().width() - 1;\r\n    if (!subItemsAreFiltered())\r\n    {\r\n        qreal subItemWidth = getSubMemoryItems().first()->boundingRect().width();\r\n        itemWidth = itemWidth - subItemWidth;\r\n    }\r\n\r\n    return itemWidth;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MainMemoryGraphicsItem::labelCollidesWithRangeLabels()\r\n//-----------------------------------------------------------------------------\r\nbool MainMemoryGraphicsItem::labelCollidesWithRangeLabels(QGraphicsTextItem* label, qreal fontHeight) const\r\n{\r\n    foreach (MemoryConnectionItem* connection, getMemoryConnections())\r\n    {\r\n        if (connection->labelCollidesWithRanges(label, fontHeight, this))\r\n        {\r\n            return true;\r\n        }\r\n    }\r\n\r\n    return MemoryDesignerGraphicsItem::labelCollidesWithRangeLabels(label, fontHeight);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MainMemoryGraphicsItem::createOverlappingConnectionMarkers()\r\n//-----------------------------------------------------------------------------\r\nvoid MainMemoryGraphicsItem::createOverlappingConnectionMarkers()\r\n{\r\n    auto memConnections = getMemoryConnections();\r\n\r\n    if (memConnections.size() < 2)\r\n        return;\r\n\r\n    for (auto const& selectedItem : memConnections)\r\n    {\r\n        for (auto const& comparisonItem : memConnections)\r\n        {\r\n            if (!selectedItem || !comparisonItem || selectedItem == comparisonItem)\r\n            {\r\n                continue;\r\n            }\r\n\r\n            QRectF connectionRect = selectedItem->sceneBoundingRect();\r\n            QRectF comparisonRect = comparisonItem->sceneBoundingRect();\r\n\r\n            if (selectedItem->getConnectionStartItem() == this &&\r\n                comparisonItem->getConnectionStartItem() == this &&\r\n                MemoryDesignerConstants::itemOverlapsAnotherItem(connectionRect,\r\n                    selectedItem->pen().width(), comparisonRect, comparisonItem->pen().width()) &&\r\n                connectionRect.width() < comparisonRect.width())\r\n            {\r\n                MemoryCollisionItem* newCollisionItem =\r\n                    new MemoryCollisionItem(selectedItem, comparisonItem, scene());\r\n                memoryCollisions_.append(newCollisionItem);\r\n            }\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MainMemoryGraphicsItem::getMemoryCollisions()\r\n//-----------------------------------------------------------------------------\r\nQVector<MemoryCollisionItem*> MainMemoryGraphicsItem::getMemoryCollisions() const\r\n{\r\n    return memoryCollisions_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MainMemoryGraphicsItem::isConnectedToSpaceItems()\r\n//-----------------------------------------------------------------------------\r\nbool MainMemoryGraphicsItem::isConnectedToSpaceItems(QVector<MainMemoryGraphicsItem*> spaceItems) const\r\n{\r\n    foreach (MemoryConnectionItem* connectionItem, getMemoryConnections())\r\n    {\r\n        MainMemoryGraphicsItem* connectedSpaceItem = connectionItem->getConnectionStartItem();\r\n        if (connectedSpaceItem && connectedSpaceItem != this &&\r\n            (spaceItems.contains(connectedSpaceItem) || connectedSpaceItem->isConnectedToSpaceItems(spaceItems)))\r\n        {\r\n            return true;\r\n        }\r\n    }\r\n\r\n    return false;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MainMemoryGraphicsItem::getChainedSpaceItems()\r\n//-----------------------------------------------------------------------------\r\nQVector<MainMemoryGraphicsItem*> MainMemoryGraphicsItem::getChainedSpaceItems() const\r\n{\r\n    QVector<MainMemoryGraphicsItem*> chainedSpaces;\r\n\r\n    foreach (MemoryConnectionItem* connectionItem, getMemoryConnections())\r\n    {\r\n        MainMemoryGraphicsItem* connectedSpaceItem = connectionItem->getConnectionStartItem();\r\n        if (connectedSpaceItem && connectedSpaceItem != this)\r\n        {\r\n            chainedSpaces.append(connectedSpaceItem);\r\n            foreach (MainMemoryGraphicsItem* chainedSpaceItem, connectedSpaceItem->getChainedSpaceItems())\r\n            {\r\n                chainedSpaces.append(chainedSpaceItem);\r\n            }\r\n        }\r\n    }\r\n\r\n    return chainedSpaces;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MainMemoryGraphicsItem::compressToUnCutCoordinates()\r\n//-----------------------------------------------------------------------------\r\nvoid MainMemoryGraphicsItem::compressToUnCutCoordinates(QVector<qreal> unCutCoordinates, const qreal CUTMODIFIER,\r\n    bool memoryItemsAreCompressed)\r\n{\r\n    if (!subItemsAreFiltered())\r\n    {\r\n        compressSubItemsToUnCutCoordinates(unCutCoordinates, CUTMODIFIER, memoryItemsAreCompressed);\r\n    }\r\n\r\n    MemoryDesignerGraphicsItem::compressToUnCutCoordinates(\r\n        unCutCoordinates, CUTMODIFIER, memoryItemsAreCompressed);\r\n    setCompressed(true);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MainMemoryGraphicsItem::changeAddress()\r\n//-----------------------------------------------------------------------------\r\nvoid MainMemoryGraphicsItem::changeAddress(quint64 const& newAddress)\r\n{\r\n    SubMemoryLayout::changeChildItemAddress(getBaseAddress(), newAddress);\r\n\r\n    MemoryDesignerGraphicsItem::changeAddress(newAddress);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MainMemoryGraphicsItem::getAllConnectionsFromConnectedItems()\r\n//-----------------------------------------------------------------------------\r\nQMultiMap<quint64, MemoryConnectionItem*> MainMemoryGraphicsItem::getAllConnectionsFromConnectedItems(\r\n    QSharedPointer<QVector<MainMemoryGraphicsItem*> > visitedMemoryItems) const\r\n{\r\n    QMultiMap<quint64, MemoryConnectionItem*> allConnections = getMemoryConnections();\r\n    QMultiMapIterator<quint64, MemoryConnectionItem*> connectionIterator (allConnections);\r\n    while (connectionIterator.hasNext())\r\n    {\r\n        connectionIterator.next();\r\n        auto currentConnection = connectionIterator.value();\r\n\r\n        MainMemoryGraphicsItem* connectedItem = currentConnection->getConnectionStartItem();\r\n        if (connectedItem == this)\r\n        {\r\n            connectedItem = currentConnection->getConnectionEndItem();\r\n        }\r\n\r\n        if (connectedItem && !visitedMemoryItems->contains(connectedItem))\r\n        {\r\n            visitedMemoryItems->append(connectedItem);\r\n            \r\n            QMultiMap<quint64, MemoryConnectionItem*> secondConnections =\r\n                connectedItem->getAllConnectionsFromConnectedItems(visitedMemoryItems);\r\n            QMultiMapIterator<quint64, MemoryConnectionItem*> secondConnectionIterator (secondConnections);\r\n            while (secondConnectionIterator.hasNext())\r\n            {\r\n                secondConnectionIterator.next();\r\n                MemoryConnectionItem* secondConnectionItem = secondConnectionIterator.value();\r\n\r\n                if (!allConnections.values().contains(secondConnectionItem))\r\n                {\r\n                    quint64 secondConnectionBaseAddress = secondConnectionIterator.key();\r\n                    if (allConnections.keys().contains(secondConnectionBaseAddress))\r\n                    {\r\n                        QVector<MemoryConnectionItem*> sameKeyItems =\r\n                            allConnections.values(secondConnectionBaseAddress).toVector();\r\n                        sameKeyItems.append(secondConnectionItem);\r\n\r\n                        int amountOfSameKeys = allConnections.remove(secondConnectionBaseAddress) + 1;\r\n                        for (int connectionIndex = amountOfSameKeys - 1; connectionIndex >= 0; --connectionIndex)\r\n                        {\r\n                            MemoryConnectionItem* sameKeyConnection = sameKeyItems.at(connectionIndex);\r\n                            allConnections.insert(secondConnectionBaseAddress, sameKeyConnection);\r\n                        }\r\n                    }\r\n                    else\r\n                    {\r\n                        allConnections.insert(secondConnectionBaseAddress, secondConnectionItem);\r\n                    }\r\n                }\r\n            }\r\n        }\r\n    }\r\n\r\n    return allConnections;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MainMemoryGraphicsItem::getLowestPointOfConnectedItems()\r\n//-----------------------------------------------------------------------------\r\nqreal MainMemoryGraphicsItem::getLowestPointOfConnectedItems()\r\n{\r\n    qreal lowestPoint = sceneBoundingRect().bottom();\r\n\r\n    QSharedPointer<QVector<MainMemoryGraphicsItem*> > visitedItems (new QVector<MainMemoryGraphicsItem*>());\r\n    QMultiMap<quint64, MemoryConnectionItem*> allConnections = getAllConnectionsFromConnectedItems(visitedItems);\r\n\r\n    visitedItems->clear();\r\n\r\n    QMultiMapIterator<quint64, MemoryConnectionItem*> connectionIterator (allConnections);\r\n    while (connectionIterator.hasNext())\r\n    {\r\n        connectionIterator.next();\r\n\r\n        auto connectionItem = connectionIterator.value();\r\n        qreal connectionLowPoint = connectionItem->getConnectionLowPoint(this);\r\n        if (connectionLowPoint > lowestPoint)\r\n        {\r\n            lowestPoint = connectionLowPoint;\r\n        }\r\n    }\r\n\r\n    return lowestPoint;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MainMemoryGraphicsItem::getLowestConnectedBaseAddress()\r\n//-----------------------------------------------------------------------------\r\nquint64 MainMemoryGraphicsItem::getLowestConnectedBaseAddress() const\r\n{\r\n    quint64 lowestBaseAddress = getBaseAddress();\r\n    if (!getMemoryConnections().isEmpty())\r\n    {\r\n        quint64 lowestConnectionBaseAddress = getFirstConnection()->getRangeStartValue();\r\n        if (lowestConnectionBaseAddress < lowestBaseAddress)\r\n        {\r\n            lowestBaseAddress = lowestConnectionBaseAddress;\r\n        }\r\n    }\r\n\r\n    return lowestBaseAddress;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MainMemoryGraphicsItem::getHighestConnectedLastAddress()\r\n//-----------------------------------------------------------------------------\r\nquint64 MainMemoryGraphicsItem::getHighestConnectedLastAddress() const\r\n{\r\n    quint64 highestLastAddress = getLastAddress();\r\n    if (!getMemoryConnections().isEmpty())\r\n    {\r\n        quint64 highestConnectionLastAddress = getLastConnection()->getRangeEndValue();\r\n        if (highestConnectionLastAddress > highestLastAddress)\r\n        {\r\n            highestLastAddress = highestConnectionLastAddress;\r\n        }\r\n    }\r\n\r\n    return highestLastAddress;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MainMemoryGraphicsItem::getUncutCoordinatesFromSet()\r\n//-----------------------------------------------------------------------------\r\nQVector<qreal> MainMemoryGraphicsItem::getUncutCoordinatesFromSet(QVector<MainMemoryGraphicsItem*>& visitedItems, QVector<MemoryConnectionItem*>& visitedConnections)\r\n{\r\n    visitedItems.append(this);\r\n\r\n    QVector<qreal> uncutCoordinates;\r\n    for (auto coordinate : getUnCutCoordinates())\r\n    {\r\n        if (uncutCoordinates.contains(coordinate) == false)\r\n        {\r\n            uncutCoordinates.append(coordinate);\r\n        }\r\n    }\r\n\r\n    QMultiMapIterator connectionIterator(getMemoryConnections());\r\n    while (connectionIterator.hasNext())\r\n    {\r\n        connectionIterator.next();\r\n        MemoryConnectionItem* connectionItem = connectionIterator.value();\r\n\r\n        if (visitedConnections.contains(connectionItem) == false)\r\n        {\r\n            visitedConnections.append(connectionItem);\r\n\r\n            if (auto connectionTop = connectionItem->sceneBoundingRect().top(); uncutCoordinates.contains(connectionTop) == false)\r\n            {\r\n                uncutCoordinates.append(connectionTop);\r\n            }\r\n            if (auto connectionBottom = connectionItem->sceneBoundingRect().bottom(); uncutCoordinates.contains(connectionBottom) == false)\r\n            {\r\n                uncutCoordinates.append(connectionBottom);\r\n            }\r\n\r\n            auto startItem = connectionItem->getConnectionStartItem();\r\n            auto endItem = connectionItem->getConnectionEndItem();\r\n            if (startItem && startItem != this && !visitedItems.contains(startItem))\r\n            {\r\n                for (auto coordinate : startItem->getUncutCoordinatesFromSet(visitedItems, visitedConnections))\r\n                {\r\n                    if (uncutCoordinates.contains(coordinate) == false)\r\n                    {\r\n                        uncutCoordinates.append(coordinate);\r\n                    }\r\n                }\r\n            }\r\n            if (endItem && endItem != this && !visitedItems.contains(endItem))\r\n            {\r\n                for (auto coordinate : endItem->getUncutCoordinatesFromSet(visitedItems, visitedConnections))\r\n                {\r\n                    if (uncutCoordinates.contains(coordinate) == false)\r\n                    {\r\n                        uncutCoordinates.append(coordinate);\r\n                    }\r\n                }\r\n            }\r\n        }\r\n    }\r\n\r\n    std::sort(uncutCoordinates.begin(), uncutCoordinates.end());\r\n    return uncutCoordinates;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MainMemoryGraphicsItem::extendMemoryItem()\r\n//-----------------------------------------------------------------------------\r\nvoid MainMemoryGraphicsItem::extendMemoryItem()\r\n{\r\n    auto firstConnection = getFirstConnection();\r\n    auto lastConnection = getLastConnection();\r\n\r\n    if (firstConnection && lastConnection)\r\n    {\r\n        QPointF itemTopLeft = boundingRect().topLeft();\r\n        QPointF itemLowRight = boundingRect().bottomRight();\r\n\r\n        int lineWidth = pen().width();\r\n\r\n        qreal connectionTop =\r\n            mapFromItem(firstConnection, firstConnection->boundingRect().topLeft()).y() + lineWidth;\r\n        qreal connectionLow =\r\n            mapFromItem(lastConnection, lastConnection->boundingRect().bottomRight()).y();\r\n\r\n        bool connectionsAreBeyond = false;\r\n\r\n        qreal extensionTop = itemLowRight.y();\r\n        if (connectionTop < itemTopLeft.y())\r\n        {\r\n            extensionTop = connectionTop;\r\n            connectionsAreBeyond = true;\r\n        }\r\n\r\n        qreal extensionLow = itemTopLeft.y();\r\n        if (connectionLow > itemLowRight.y())\r\n        {\r\n            extensionLow = connectionLow;\r\n            connectionsAreBeyond = true;\r\n        }\r\n\r\n        if (connectionsAreBeyond)\r\n        {\r\n            qreal positionX = itemTopLeft.x() + lineWidth;\r\n            qreal extensionWidth = itemLowRight.x() - itemTopLeft.x() - lineWidth;\r\n            qreal positionY = extensionTop - lineWidth;\r\n            qreal extensionHeight = extensionLow - extensionTop;\r\n\r\n            auto extensionItem = new MemoryExtensionGraphicsItem(positionX, positionY, extensionWidth, extensionHeight, getContainingInstance(), this);\r\n            setExtensionItem(extensionItem);\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MainMemoryGraphicsItem::compressItemAndChildItems()\r\n//-----------------------------------------------------------------------------\r\nvoid MainMemoryGraphicsItem::compressItemAndChildItems(bool compressMemoryItems)\r\n{\r\n    if (!isCompressed())\r\n    {\r\n        qreal memoryMapNewHeight = 0;\r\n        qreal subItemHeight = getMinimumHeightForSubItems();\r\n\r\n        if (getMemoryConnections().isEmpty())\r\n        {\r\n            memoryMapNewHeight =\r\n                compressChildItems(getBaseAddress(), getLastAddress(), subItemHeight, compressMemoryItems);\r\n        }\r\n\r\n        if (memoryMapNewHeight > 0)\r\n        {\r\n            condense(memoryMapNewHeight);\r\n\r\n            setCompressed(true);\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MainMemoryGraphicsItem::isOriginal()\r\n//-----------------------------------------------------------------------------\r\nbool MainMemoryGraphicsItem::isOriginal() const\r\n{\r\n    return isOriginalItem_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MainMemoryGraphicsItem::getClones()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<QVector<MainMemoryGraphicsItem*> > MainMemoryGraphicsItem::getClones()\r\n{\r\n    return clones_;\r\n}\r\n"
  },
  {
    "path": "editors/MemoryDesigner/MainMemoryGraphicsItem.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: MainMemoryGraphicsItem.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Mikko Teuho\r\n// Date: 16.09.2016\r\n//\r\n// Description:\r\n// Parent class for memory map and address space graphics items in memory designer.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef MAINMEMORYGRAPHICSITEM_H\r\n#define MAINMEMORYGRAPHICSITEM_H\r\n\r\n#include <IPXACTmodels/common/VLNV.h>\r\n\r\n#include <editors/common/diagramgrid.h>\r\n\r\n#include <editors/MemoryDesigner/MemoryDesignerGraphicsItem.h>\r\n#include <editors/MemoryDesigner/SubMemoryLayout.h>\r\n\r\nclass MemoryItem;\r\nclass MemoryExtensionGraphicsItem;\r\nclass ConnectivityComponent;\r\n\r\n#include <QFontMetrics>\r\n#include <QAction>\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Parent class for memory map and address space graphics items in memory designer.\r\n//-----------------------------------------------------------------------------\r\nclass MainMemoryGraphicsItem : public MemoryDesignerGraphicsItem, public SubMemoryLayout\r\n{\r\n\r\npublic:\r\n\r\n    /*!\r\n     *  The constructor.\r\n     *\r\n     *    @param [in] memoryItem          Memory item data.\r\n     *    @param [in] containingInstance  The containing instance.\r\n     *    @param [in] subItemType         Type of the memory sub items.\r\n     *    @param [in] filterSubItems      Value for filtering sub items.\r\n     *    @param [in] identifierChain     Chain of strings identifying this item.\r\n     *    @param [in] parent              The parent item.\r\n     */\r\n    MainMemoryGraphicsItem(QSharedPointer<MemoryItem const> memoryItem,\r\n        QSharedPointer<ConnectivityComponent const> containingInstance, QString const& subItemType,\r\n        bool filterSubItems, QVector<QString> identifierChain, QGraphicsItem* parent = 0);\r\n\r\n    /*!\r\n     *  The copy constructor.\r\n     *\r\n     *    @param [in] other     The original graphics item.\r\n     *\r\n     *    @return Copy of the original graphics item.\r\n     */\r\n    MainMemoryGraphicsItem(const MainMemoryGraphicsItem& other);\r\n\r\n\t/*!\r\n     *  The destructor.\r\n     */\r\n    virtual ~MainMemoryGraphicsItem() = default;\r\n\r\n    /*!\r\n     *  Add a memory connection to this item.\r\n     *\r\n     *    @param [in] connectionItem  The selected memory connection item.\r\n     */\r\n    virtual void addMemoryConnection(MemoryConnectionItem* connectionItem);\r\n\r\n    /*!\r\n     *  Get the memory collision items contained within this item.\r\n     *\r\n     *    @return Memory collision items contained within this item.\r\n     */\r\n    QVector<MemoryCollisionItem*> getMemoryCollisions() const;\r\n\r\n    /*!\r\n     *  Compress the item and the sub items.\r\n     *\t\r\n     *    @param [in] compressMemoryItems     Flag for compressing the memory items.\r\n     */\r\n    void compressItemAndChildItems(bool compressMemoryItems);\r\n\r\n    /*!\r\n     *  Get the used coordinates of the item and all the connected items.\r\n     *\t\r\n     *    @param [in] visitedItems        List of the visited memory items.\r\n     *    @param [in] visitedConnections  List of the visited memory connections.\r\n     *\r\n     *    @return List of visible coordinates.\r\n     */\r\n    QVector<qreal> getUncutCoordinatesFromSet(QVector<MainMemoryGraphicsItem*>& visitedItems, QVector<MemoryConnectionItem*>& visitedConnections);\r\n\r\n    /*!\r\n     *  Move memory item and all the connected memory connections and the connected memory items.\r\n     *\r\n     *    @param [in] yTransfer   The amount of movement in the y-coordinate.\r\n     */\r\n    void moveItemAndConnectedItems(qreal yTransfer);\r\n\r\n    /*!\r\n     *  Get the last memory connection item connected to this memory graphics item.\r\n     *\r\n     *    @return The last memory connection item connected to this memory graphics item.\r\n     */\r\n    MemoryConnectionItem* getLastConnection() const;\r\n\r\n    /*!\r\n     *  Get the first memory connection item connected to this memory graphics item.\r\n     *\r\n     *    @return The memory connection item with the lowest base address.\r\n     */\r\n    MemoryConnectionItem* getFirstConnection() const;\r\n\r\n    /*!\r\n     *  Check if the memory graphics item has been compressed.\r\n     *\r\n     *    @return True, if the item has been compressed, false otherwise.\r\n     */\r\n    bool isCompressed() const;\r\n\r\n    /*!\r\n     *  Set a memory extension item for this graphics item.\r\n     *\r\n     *    @param [in] newExtensionItem    The new memory extension item.\r\n     */\r\n    void setExtensionItem(MemoryExtensionGraphicsItem* newExtensionItem);\r\n\r\n    /*!\r\n     *  Get the memory extension item contained within this graphics item.\r\n     *\r\n     *    @return The memory extension item contained within this graphics item.\r\n     */\r\n    MemoryExtensionGraphicsItem* getExtensionItem() const;\r\n\r\n    /*!\r\n     *  Check whether this item has a memory extension item.\r\n     *\r\n     *    @return True, if a memory extension item exists, false otherwise.\r\n     */\r\n    bool hasExtensionItem() const;\r\n\r\n    /*!\r\n     *  Get the memory item from which this graphics item has been constructed from.\r\n     *\r\n     *    @return The contained memory item.\r\n     */\r\n    QSharedPointer<MemoryItem const> getMemoryItem() const;\r\n\r\n    /*!\r\n     *  Create collision markers for overlapping connections.\r\n     */\r\n    void createOverlappingConnectionMarkers();\r\n\r\n    /*!\r\n     *  Check if the memory map is connected to any of the selected address spaces.\r\n     *\r\n     *    @param [in] spaceItems  List of the selected address space graphics items.\r\n     *\r\n     *    @return True, if the memory map is connected to any of the selected address spaces.\r\n     */\r\n    bool isConnectedToSpaceItems(QVector<MainMemoryGraphicsItem*> spaceItems) const;\r\n\r\n    /*!\r\n     *  Get the chained address space items connected to this item.\r\n     *\r\n     *    @return All the chained address space items connected to this item.\r\n     */\r\n    QVector<MainMemoryGraphicsItem*> getChainedSpaceItems() const;\r\n\r\n    /*!\r\n     *  Compress this item to the uncut coordinates.\r\n     *\r\n     *    @param [in] unCutCoordinates            List of the coordinates that are retained after compression.\r\n     *    @param [in] CUTMODIFIER                 The modifier for the size of the cut area.\r\n     *    @param [in] memoryItemsAreCompressed    Flag for condensing memory items.\r\n     */\r\n    virtual void compressToUnCutCoordinates(QVector<qreal> unCutCoordinates, const qreal CUTMODIFIER,\r\n        bool memoryItemsAreCompressed);\r\n\r\n    /*!\r\n     *  Change the address range of this item and its sub items.\r\n     *\r\n     *    @param [in] newAddress    New base address for the item.\r\n     */\r\n    virtual void changeAddress(quint64 const& newAddress) override;\r\n\r\n    /*!\r\n     *  Get the lowest point of all the connected memory items.\r\n     *\r\n     *    @return The lowest point of all the connected memory items.\r\n     */\r\n    qreal getLowestPointOfConnectedItems();\r\n\r\n    /*!\r\n     *  Get the lowest base address of all the connected memory items.\r\n     *\r\n     *    @return The lowest base address of all the connected memory items.\r\n     */\r\n    quint64 getLowestConnectedBaseAddress() const;\r\n\r\n    /*!\r\n     *  Get the highest last address of all the connected memory items.\r\n     *\r\n     *    @return The highest last address of all the connected memory items.\r\n     */\r\n    quint64 getHighestConnectedLastAddress() const;\r\n\r\n    /*!\r\n     *  Construct a memory graphics extension for this memory item.\r\n     */\r\n    void extendMemoryItem();\r\n\r\n    /*!\r\n     *  Check if this graphics item is original or a clone.\r\n     *\r\n     *    @return True, if the graphics item is original, false otherwise.\r\n     */\r\n    bool isOriginal() const;\r\n\r\n    /*!\r\n     *  Get a list of the memory items cloned from this item.\r\n     *\r\n     *    @return Pointer to a list of memory items cloned from this item.\r\n     */\r\n    QSharedPointer<QVector<MainMemoryGraphicsItem*> > getClones();\r\n\r\nprotected:\r\n\r\n    /*!\r\n     *  Get the instance name label.\r\n     *\r\n     *    @return Graphics text item containing the name of the containing component instance.\r\n     */\r\n    QGraphicsTextItem* getInstanceNameLabel() const;\r\n\r\n    /*!\r\n     *  Set a new compression value.\r\n     *\r\n     *    @param [in] newCompressValue    The new memory compression value.\r\n     */\r\n    void setCompressed(bool newCompressValue);\r\n\r\n    /*!\r\n     *  Get all the connections from connected memory items.\r\n     *\r\n     *    @param [in] visitedMemoryItems  List of all the memory items that have been checked.\r\n     *\r\n     *    @return All the connections from the connected memory items.\r\n     */\r\n    QMultiMap<quint64, MemoryConnectionItem*> getAllConnectionsFromConnectedItems(\r\n        QSharedPointer<QVector<MainMemoryGraphicsItem*> > visitedMemoryItems) const;\r\n\r\nprivate:\r\n\r\n    // Disable copying.\r\n    MainMemoryGraphicsItem& operator=(MainMemoryGraphicsItem const& rhs);\r\n\r\n    /*!\r\n     *  Setup the graphics item.\r\n     */\r\n    void setupDuringConstruction();\r\n\r\n    /*!\r\n     *  Get the available width for this item.\r\n     *\r\n     *    @return Available width for this item.\r\n     */\r\n    virtual qreal getItemWidth() const;\r\n\r\n    /*!\r\n     *  Check if the selected label collides with range labels.\r\n     *\r\n     *    @param [in] label   The selected label.\r\n     *    @param [in] height  Height of the label text.\r\n     *\r\n     *    @return True, if the selected label collides with range labels, false otherwise.\r\n     */\r\n    virtual bool labelCollidesWithRangeLabels(QGraphicsTextItem* label, qreal fontHeight) const;\r\n\r\n    /*!\r\n     *  Get the minimum height required to display for the memory item.\r\n     *\r\n     *    @return The minimum height required to display the memory item.\r\n     */\r\n    virtual qreal getMinimumHeightForSubItems() const = 0;\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! The label containing the name of the containing component instance.\r\n    QGraphicsTextItem* instanceNameLabel_;\r\n\r\n    //! The memory item from which this graphics item has been constructed from.\r\n    QSharedPointer<MemoryItem const> memoryItem_;\r\n\r\n    //! A list of memory collisions connected to this memory item.\r\n    QVector<MemoryCollisionItem*> memoryCollisions_;\r\n\r\n    //! Holds whether the graphics item has been compressed or not.\r\n    bool compressed_ = false;\r\n\r\n    //! The memory extension item.\r\n    MemoryExtensionGraphicsItem* extensionItem_ = nullptr;\r\n\r\n    //! Flag for separating original and cloned items.\r\n    bool isOriginalItem_;\r\n\r\n    //! List of clones created from this item.\r\n    QSharedPointer<QVector<MainMemoryGraphicsItem*> > clones_ = nullptr;\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n\r\n#endif // MAINMEMORYGRAPHICSITEM_H\r\n"
  },
  {
    "path": "editors/MemoryDesigner/MasterSlavePathSearch.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: MasterSlavePathSearch.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Esko Pekkarinen\r\n// Date: 25.08.2016\r\n//\r\n// Description:\r\n// Finds the paths from master interfaces to slave interfaces.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"MasterSlavePathSearch.h\"\r\n\r\n#include <editors/MemoryDesigner/ConnectivityConnection.h>\r\n#include <editors/MemoryDesigner/ConnectivityComponent.h>\r\n#include <editors/MemoryDesigner/ConnectivityGraph.h>\r\n#include <editors/MemoryDesigner/ConnectivityInterface.h>\r\n#include <editors/MemoryDesigner/MemoryItem.h>\r\n#include <editors/MemoryDesigner/MemoryDesignerConstants.h>\r\n\r\n#include <QQueue>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MasterSlavePathSearch::findMasterSlavePaths()\r\n//-----------------------------------------------------------------------------\r\nQVector<QVector<QSharedPointer<ConnectivityInterface const> > > MasterSlavePathSearch::\r\n    findMasterSlavePaths(QSharedPointer<const ConnectivityGraph> graph, bool allowOverlappingPaths) const\r\n{\r\n    QVector<MasterSlavePathSearch::Path> masterPaths;\r\n\r\n    for (auto const& masterInterface : findInitialMasterInterfaces(graph))\r\n    {\r\n        masterPaths.append(findPaths(masterInterface,  graph));\r\n    }\r\n\r\n    masterPaths = findValidPathsIn(masterPaths, allowOverlappingPaths);\r\n\r\n    for (auto const& edge : graph->getConnections())\r\n    {\r\n        if (edge->getName().contains(QStringLiteral(\"_to_local_memory_map_\")) &&\r\n            edge->getFirstInterface() == edge->getSecondInterface())\r\n        {\r\n            QVector<QSharedPointer<ConnectivityInterface const> > localConnection;\r\n            localConnection.append(edge->getFirstInterface());\r\n            localConnection.append(edge->getSecondInterface());\r\n            masterPaths.append(localConnection);\r\n        }\r\n    }\r\n\r\n    return masterPaths;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MasterSlavePathSearch::findInitialMasterInterfaces()\r\n//-----------------------------------------------------------------------------\r\nQVector<QSharedPointer<ConnectivityInterface> > MasterSlavePathSearch::findInitialMasterInterfaces(\r\n    QSharedPointer<const ConnectivityGraph> graph) const\r\n{\r\n    QVector<QSharedPointer<ConnectivityInterface> > masterInterfaces;\r\n\r\n    for (auto const& vertex : graph->getInterfaces())\r\n    {\r\n        if (isStartInterface(vertex) && isConnectedToMemory(vertex))\r\n        {\r\n            masterInterfaces.append(vertex);\r\n        }\r\n    }\r\n\r\n    return masterInterfaces;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MasterSlavePathSearch::isStartInterface()\r\n//-----------------------------------------------------------------------------\r\nbool MasterSlavePathSearch::isStartInterface(QSharedPointer<const ConnectivityInterface> vertex) const\r\n{\r\n    return vertex->getMode() == General::MASTER || vertex->getMode() == General::INITIATOR;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MasterSlavePathSearch::isConnectedToMemory()\r\n//-----------------------------------------------------------------------------\r\nbool MasterSlavePathSearch::isConnectedToMemory(QSharedPointer<const ConnectivityInterface> vertex) const\r\n{\r\n    if (vertex->getMode() == General::MASTER)\r\n    {\r\n        return vertex->isConnectedToMemory();\r\n    }\r\n    else if (vertex->getMode() == General::INITIATOR && vertex->getInstance())\r\n    {\r\n        return vertex->isConnectedToMemory() || isConnectedToSubspaceMap(vertex);\r\n    }\r\n\r\n    return false;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MasterSlavePathSearch::isConnectedToSubspaceMap()\r\n//-----------------------------------------------------------------------------\r\nbool MasterSlavePathSearch::isConnectedToSubspaceMap(QSharedPointer<const ConnectivityInterface> vertex) const\r\n{\r\n    for (auto memoryItem : vertex->getInstance()->getMemories())\r\n    {\r\n        if (memoryItem->getType() == MemoryDesignerConstants::MEMORYMAP_TYPE)\r\n        {\r\n            for (auto memoryBlock : memoryItem->getChildItems())\r\n            {\r\n                if (memoryBlock->getType() == MemoryDesignerConstants::SUBSPACEMAP_TYPE && memoryBlock->getInitiatorReference() == vertex->getName())\r\n                {\r\n                    return true;\r\n                }\r\n            }\r\n        }\r\n    }\r\n\r\n    return false;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MasterSlavePathSearch::findPaths()\r\n//-----------------------------------------------------------------------------\r\nQVector<MasterSlavePathSearch::Path> MasterSlavePathSearch::findPaths(QSharedPointer<ConnectivityInterface > startVertex, QSharedPointer<const ConnectivityGraph> graph) const\r\n{\r\n    QVector<MasterSlavePathSearch::Path> foundPaths;\r\n    QVector<QSharedPointer<ConnectivityInterface> > visitedVertices;\r\n\r\n    for (auto const& path : findPathsFromInterface(startVertex, visitedVertices, graph))\r\n    {\r\n        foundPaths.append(path);\r\n    }\r\n\r\n    return foundPaths;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MasterSlavePathSearch::findPathsFromInterface()\r\n//-----------------------------------------------------------------------------\r\nQVector<MasterSlavePathSearch::Path> MasterSlavePathSearch::findPathsFromInterface(\r\n    QSharedPointer<ConnectivityInterface> currentVertex,\r\n    QVector<QSharedPointer<ConnectivityInterface>> visitedVertices,\r\n    QSharedPointer<const ConnectivityGraph> graph) const\r\n{\r\n    visitedVertices.append(currentVertex);\r\n    QVector<MasterSlavePathSearch::Path> foundPaths;\r\n    QVector<MasterSlavePathSearch::Path> pathsFromVertices;\r\n\r\n    for (auto const& nextEdge : graph->getConnectionsFor(currentVertex))\r\n    {\r\n        auto nextVertex = findConnectedInterface(currentVertex, nextEdge);\r\n\r\n        if (visitedVertices.contains(nextVertex) == false && canConnectInterfaces(currentVertex, nextVertex) && pathDirectionIsAccepted(currentVertex, nextVertex))\r\n        {\r\n            for (auto const& path : findPathsFromInterface(nextVertex, visitedVertices, graph))\r\n            {\r\n                pathsFromVertices.append(path);\r\n            }\r\n        }\r\n    }\r\n\r\n    if (pathsFromVertices.isEmpty())\r\n    {\r\n        MasterSlavePathSearch::Path newPath{ currentVertex };\r\n        foundPaths.append(newPath);\r\n    }\r\n    else\r\n    {\r\n        //! The case of a target interface with a memory map being connected to a hierarchical target\r\n        if ((currentVertex->getMode() == General::TARGET || currentVertex->getMode() == General::SLAVE) && currentVertex->isConnectedToMemory() && currentVertex->isBridged() == false)\r\n        {\r\n            MasterSlavePathSearch::Path newPath{ currentVertex };\r\n            foundPaths.append(newPath);\r\n        }\r\n\r\n        for (auto path : pathsFromVertices)\r\n        {\r\n            path.prepend(currentVertex);\r\n            foundPaths.append(path);\r\n        }\r\n    }\r\n\r\n    return foundPaths;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MasterSlavePathSearch::pathDirectionIsAccepted()\r\n//-----------------------------------------------------------------------------\r\nbool MasterSlavePathSearch::pathDirectionIsAccepted(QSharedPointer<ConnectivityInterface> startVertex, QSharedPointer<ConnectivityInterface> connectedVertex) const\r\n{\r\n    General::InterfaceMode startMode = startVertex->getMode();\r\n    General::InterfaceMode connectedMode = connectedVertex->getMode();\r\n    bool acceptDirection = true;\r\n\r\n    if ((startMode == General::MASTER || startMode == General::INITIATOR) &&\r\n        (connectedMode == General::SLAVE || connectedMode == General::TARGET) &&\r\n        startVertex->getInstance() == connectedVertex->getInstance())\r\n    {\r\n        acceptDirection = false;\r\n    }\r\n    else if (startMode == General::SLAVE || startMode == General::TARGET)\r\n    {\r\n        if (connectedMode == General::MIRRORED_SLAVE || connectedMode == General::MIRRORED_TARGET)\r\n        {\r\n            acceptDirection = false;\r\n        }\r\n        else if ((connectedMode == General::MASTER || connectedMode == General::INITIATOR) &&\r\n            (startVertex->getInstance() != connectedVertex->getInstance()))\r\n        {\r\n            acceptDirection = false;\r\n        }\r\n    }\r\n    else if ((startMode == General::MIRRORED_MASTER || startMode == General::MIRRORED_INITIATOR) &&\r\n        (connectedMode == General::MASTER || connectedMode == General::INITIATOR))\r\n    {\r\n        return false;\r\n    }\r\n    else if ((startMode == General::MIRRORED_SLAVE || startMode == General::MIRRORED_TARGET) &&\r\n        (connectedMode == General::MIRRORED_MASTER || connectedMode == General::MIRRORED_INITIATOR))\r\n    {\r\n        return false;\r\n    }\r\n\r\n    return acceptDirection;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MasterSlavePathSearch::vertexIsLeaf()\r\n//-----------------------------------------------------------------------------\r\nbool MasterSlavePathSearch::vertexIsLeaf(QSharedPointer<ConnectivityInterface> possibleLeaf, QSharedPointer<const ConnectivityGraph> graph) const\r\n{\r\n    General::InterfaceMode leafMode = possibleLeaf->getMode();\r\n\r\n    return (leafMode == General::SLAVE || leafMode == General::TARGET) && possibleLeaf->isBridged() == false;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MasterSlavePathSearch::findConnectedInterface()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<ConnectivityInterface> MasterSlavePathSearch::findConnectedInterface(\r\n    QSharedPointer<ConnectivityInterface const> startInterface, QSharedPointer<ConnectivityConnection const> edge)\r\n    const\r\n{\r\n    QSharedPointer<ConnectivityInterface> firstInterface = edge->getFirstInterface();\r\n    if (startInterface == firstInterface)\r\n    {\r\n        return edge->getSecondInterface();\r\n    }\r\n    else\r\n    {\r\n        return firstInterface;\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MasterSlavePathSearch::canConnectInterfaces()\r\n//-----------------------------------------------------------------------------\r\nbool MasterSlavePathSearch::canConnectInterfaces(QSharedPointer<ConnectivityInterface const> startVertex,\r\n    QSharedPointer<ConnectivityInterface const> endVertex) const\r\n{\r\n    if (startVertex == endVertex)\r\n    {\r\n        return false;\r\n    }\r\n    \r\n    if (startVertex->getMode() == endVertex->getMode() && (startVertex->isHierarchical() || endVertex->isHierarchical()))\r\n    {\r\n        return true;\r\n    }\r\n\r\n    General::InterfaceMode initiatorMode = General::INITIATOR;\r\n    General::InterfaceMode mirroredInitiatorMode = General::MIRRORED_INITIATOR;\r\n    General::InterfaceMode targetMode = General::TARGET;\r\n    General::InterfaceMode mirroredTargetMode = General::MIRRORED_TARGET;\r\n\r\n    General::InterfaceMode startMode = startVertex->getMode();\r\n    bool startModeIsRevision2022 = General::modeIsRevision2022(startMode);\r\n    if (startModeIsRevision2022 == false)\r\n    {\r\n        initiatorMode = General::MASTER;\r\n        mirroredInitiatorMode = General::MIRRORED_MASTER;\r\n        targetMode = General::SLAVE;\r\n        mirroredTargetMode = General::MIRRORED_SLAVE;\r\n    }\r\n\r\n    bool startIsInitiator = startMode == initiatorMode;\r\n    bool startIsTarget = startMode == targetMode;\r\n    bool startIsMirroredInitiator = startMode == mirroredInitiatorMode;\r\n    bool startIsMirroredTarget = startMode == mirroredTargetMode;\r\n    bool startIsBridged = startVertex->isBridged();\r\n\r\n    General::InterfaceMode endMode = endVertex->getMode();\r\n    bool endModeIsRevision2022 = General::modeIsRevision2022(endMode);\r\n    bool endIsInitiator = endMode == initiatorMode;\r\n    bool endIsTarget = endMode == targetMode;\r\n    bool endIsMirroredInitiator = endMode == mirroredInitiatorMode;\r\n    bool endIsMirroredTarget = endMode == mirroredTargetMode;\r\n    bool endIsBridged = endVertex->isBridged();\r\n\r\n    QSharedPointer<ConnectivityComponent const> startInstance = startVertex->getInstance();\r\n    QSharedPointer<ConnectivityComponent const> endInstance = endVertex->getInstance();\r\n\r\n    return\r\n        (startModeIsRevision2022 == endModeIsRevision2022) && (\r\n        (startIsInitiator && ((endIsTarget && startInstance != endInstance) || endIsMirroredInitiator)) ||\r\n        (startIsTarget && (endIsMirroredTarget || (endIsInitiator && startIsBridged && endIsBridged && startInstance == endInstance))) ||\r\n        (startIsMirroredInitiator && endIsMirroredTarget && startInstance == endInstance) ||\r\n        (startIsMirroredTarget && (endIsTarget || (endIsMirroredInitiator && startInstance == endInstance)))\r\n        );\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MasterSlavePathSearch::removeDuplicatePaths()\r\n//-----------------------------------------------------------------------------\r\nQVector<MasterSlavePathSearch::Path> MasterSlavePathSearch::findValidPathsIn(QVector<MasterSlavePathSearch::Path> const& paths,\r\n    bool allowOverlappingPaths) const\r\n{\r\n    QVector<QVector<QSharedPointer<ConnectivityInterface const> > > highPaths;\r\n\r\n    for (auto const& currentPath : paths)\r\n    {\r\n        if ((currentPath.size() > 1 && pathEndsInMemoryMap(currentPath)) &&\r\n            (allowOverlappingPaths == true || (allowOverlappingPaths == false && pathIsFullPath(currentPath, paths))))\r\n        {\r\n            highPaths.append(currentPath);\r\n        }\r\n    }\r\n\r\n    return highPaths;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MasterSlavePathSearch::pathIsFullPath()\r\n//-----------------------------------------------------------------------------\r\nbool MasterSlavePathSearch::pathIsFullPath(MasterSlavePathSearch::Path const& currentPath, \r\n    QVector<MasterSlavePathSearch::Path> const& availablePaths) const\r\n{\r\n    for (int comparisonIndex = 0; comparisonIndex < availablePaths.size(); ++comparisonIndex)\r\n    {\r\n        QVector<QSharedPointer<ConnectivityInterface const> > comparisonPath =\r\n            availablePaths.at(comparisonIndex);\r\n\r\n        if (currentPath != comparisonPath && currentPath.last() == comparisonPath.last())\r\n        {\r\n            auto const pathLength = currentPath.size();\r\n            auto const comparisonPathLength = comparisonPath.size();\r\n\r\n            auto overlapLength = qMin(pathLength, comparisonPathLength);\r\n\r\n            // Exclude path only if the start interface isn't bridged (e.g. if there is a CPU in middle \r\n            // of a path) or the path is contained within another path.\r\n            if (pathLength < comparisonPathLength &&\r\n                pathContainsAnotherPath(currentPath, comparisonPath, overlapLength))\r\n            {\r\n                return false;\r\n            }\r\n        }\r\n    }\r\n\r\n    return true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MasterSlavePathSearch::pathContainsAnotherPath()\r\n//-----------------------------------------------------------------------------\r\nbool MasterSlavePathSearch::pathContainsAnotherPath(\r\n    QVector<QSharedPointer<ConnectivityInterface const> > const& pathOne,\r\n    QVector<QSharedPointer<ConnectivityInterface const> > const& pathTwo, int areaSize) const\r\n{\r\n    for (int areaIndex = 0; areaIndex < areaSize; areaIndex++)\r\n    {\r\n        auto const pathOneIndex = pathOne.size() - 1 - areaIndex;\r\n        auto const pathTwoIndex = pathTwo.size() - 1 - areaIndex;\r\n        if (pathOne.at(pathOneIndex) != pathTwo.at(pathTwoIndex))\r\n        {\r\n            return false;\r\n        }\r\n    }\r\n\r\n    return true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MasterSlavePathSearch::pathEndsInMemoryMap()\r\n//-----------------------------------------------------------------------------\r\nbool MasterSlavePathSearch::pathEndsInMemoryMap(QVector<QSharedPointer<ConnectivityInterface const> > const& path)\r\n    const\r\n{\r\n    QSharedPointer<ConnectivityInterface const> lastInterface = path.last();\r\n\r\n    return lastInterface && lastInterface->getConnectedMemory() &&\r\n        lastInterface->getConnectedMemory()->getType().compare(MemoryDesignerConstants::MEMORYMAP_TYPE) == 0;\r\n}\r\n"
  },
  {
    "path": "editors/MemoryDesigner/MasterSlavePathSearch.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: MasterSlavePathSearch.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Esko Pekkarinen\r\n// Date: 25.08.2016\r\n//\r\n// Description:\r\n// Finds the paths from master interfaces to slave interfaces.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef MASTERSLAVEPATHSEARCH_H\r\n#define MASTERSLAVEPATHSEARCH_H\r\n\r\n#include <QSharedPointer>\r\n#include <QVector>\r\n\r\nclass ConnectivityConnection;\r\nclass ConnectivityGraph;\r\nclass ConnectivityInterface;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Finds the paths from master interfaces to slave interfaces.\r\n//-----------------------------------------------------------------------------\r\nclass MasterSlavePathSearch \r\n{\r\npublic:\r\n\r\n    using Path = QVector<QSharedPointer<ConnectivityInterface const> >;\r\n\r\n\t/*!\r\n     *  The constructor.\r\n     */\r\n\tMasterSlavePathSearch() = default;\r\n\r\n    /*!\r\n     *  Finds all paths from master interfaces to slave interfaces.\r\n     *\r\n     *    @param [in] graph                   The connectivity graph to find the paths from.\r\n     *    @param [in] allowOverlappingPaths   Flag for allowing overlapping paths in the path search.\r\n     *\r\n     *    @return All paths from master interfaces.\r\n     */\r\n    QVector<QVector<QSharedPointer<ConnectivityInterface const> > > findMasterSlavePaths(\r\n        QSharedPointer<const ConnectivityGraph> graph, bool allowOverlappingPaths) const;\r\n\r\nprivate:\r\n\r\n    /*!\r\n     *  Finds the bottom-most master interfaces for the starting points of the paths.\r\n     *\r\n     *    @param [in] graph   The connectivity graph to find the interfaces from.\r\n     *\r\n     *    @return The master interfaces for path start points.\r\n     */\r\n    QVector<QSharedPointer<ConnectivityInterface> > findInitialMasterInterfaces(\r\n        QSharedPointer<const ConnectivityGraph> graph) const;\r\n\r\n    /*!\r\n     *  Check if the selected interface is a starting interface.\r\n     *\t\r\n     *    @param [in] vertex  The selected interface.\r\n     *\r\n     *    @return True, if the interface is a starting interface, false otherwise.\r\n     */\r\n    bool isStartInterface(QSharedPointer<const ConnectivityInterface> vertex) const;\r\n\r\n    /*!\r\n     *  Check if the selected interface is connected to a memory item.\r\n     *\r\n     *    @param [in] vertex  The selected interface.\r\n     *\r\n     *    @return True, if the interface is a starting interface, false otherwise.\r\n     */\r\n    bool isConnectedToMemory(QSharedPointer<const ConnectivityInterface> vertex) const;\r\n\r\n    /*!\r\n     *  Check if the selected interface is connected to a subspace map.\r\n     *\t\r\n     *    @param [in] vertex  The selected interface.\r\n     *\r\n     *    @return True, if the interface is connected to a subspace map, false otherwise.\r\n     */\r\n    bool isConnectedToSubspaceMap(QSharedPointer<const ConnectivityInterface> vertex) const;\r\n\r\n    /*!\r\n     *  Finds all the paths branching from the given start vertex.\r\n     *\r\n     *    @param [in] startVertex     The vertex to start the search from.\r\n     *    @param [in] graph           The connectivity graph to find the paths from.\r\n     */\r\n    QVector<MasterSlavePathSearch::Path> findPaths(QSharedPointer<ConnectivityInterface > startVertex,\r\n        QSharedPointer<const ConnectivityGraph> graph) const;\r\n\r\n    /*!\r\n     *  Find paths from the selected interface.\r\n     *\r\n     *    @param [in] currentVertex     The selected interface.\r\n     *    @param [in] visitedVertices   List of already visited interfaces.\r\n     *    @param [in] graph             The connectivity graph to find the paths from.\r\n     *\r\n     *    @return List of paths found from the selected interface.\r\n     */\r\n    QVector<MasterSlavePathSearch::Path> findPathsFromInterface(QSharedPointer<ConnectivityInterface> currentVertex,\r\n        QVector<QSharedPointer<ConnectivityInterface>> visitedVertices,\r\n        QSharedPointer<const ConnectivityGraph> graph) const;\r\n\r\n    /*!\r\n     *  Check if the direction from start to end is accepted.\r\n     *\r\n     *    @param [in] startVertex       Starting interface.\r\n     *    @param [in] connectedVertex   Ending interface.\r\n     *\r\n     *    @return True, if the direction is accepted, false otherwise.\r\n     */\r\n    bool pathDirectionIsAccepted(QSharedPointer<ConnectivityInterface> startVertex, QSharedPointer<ConnectivityInterface> connectedVertex) const;\r\n\r\n    /*!\r\n     *  Check if the selected interface is an ending point for the path.\r\n     *\r\n     *    @param [in] possibleLeaf  The selected interface.\r\n     *    @param [in] graph         The connectivity graph to find the paths from.\r\n     *\r\n     *    @return True, if the interface is an end point, false otherwise.\r\n     */\r\n    bool vertexIsLeaf(QSharedPointer<ConnectivityInterface> possibleLeaf, QSharedPointer<const ConnectivityGraph> graph) const;\r\n\r\n    /*!\r\n     *  Find the interface connected to the selected interface.\r\n     *\r\n     *    @param [in] startInterface  The selected interface.\r\n     *    @param [in] edge            The connection between the two interfaces.\r\n     *\r\n     *    @return The interface connected to the selected interface.\r\n     */\r\n    QSharedPointer<ConnectivityInterface> findConnectedInterface(\r\n        QSharedPointer<ConnectivityInterface const> startInterface,\r\n        QSharedPointer<ConnectivityConnection const> edge) const;\r\n\r\n    /*!\r\n     *  Check if the selected interfaces can be connected.\r\n     *\r\n     *    @param [in] startVertex     The starting interface.\r\n     *    @param [in] endVertex       The end interface.\r\n     *\r\n     *    @return True, if the interfaces can be connected, false otherwise.\r\n     */\r\n    bool canConnectInterfaces(QSharedPointer<ConnectivityInterface const> startVertex,\r\n        QSharedPointer<ConnectivityInterface const> endVertex) const;\r\n\r\n    /*!\r\n     *  Finds the valid, longest paths in the given set of paths.\r\n     *\r\n     *    @param [in] paths                   The paths to search.\r\n     *    @param [in] allowOverlappingPaths   Flag for allowing overlapping paths in the path search.\r\n     *\r\n     *    @return The valid paths found in the set.\r\n     */\r\n    QVector<MasterSlavePathSearch::Path> findValidPathsIn(QVector<MasterSlavePathSearch::Path> const& paths, bool allowOverlappingPaths) const;\r\n\r\n    /*!\r\n     *  Check if the selected path should be kept in the master paths.\r\n     *\r\n     *    @param [in] currentPath     The selected path.\r\n     *    @param [in] availablePaths  All the available paths.\r\n     *\r\n     *    @return True, if the path is a master path, otherwise false.\r\n     */\r\n    bool pathIsFullPath(MasterSlavePathSearch::Path const& currentPath,\r\n        QVector<MasterSlavePathSearch::Path> const& availablePaths) const;\r\n\r\n    /*!\r\n     *  Check if a path contains another path.\r\n     *\r\n     *    @param [in] pathOne     The first selected path.\r\n     *    @param [in] pathTwo     The second selected path.\r\n     *    @param [in] areaSize    Size of the smaller path.\r\n     *\r\n     *    @return True, if another of the selected paths contains the other, false otherwise.\r\n     */\r\n    bool pathContainsAnotherPath(QVector<QSharedPointer<ConnectivityInterface const> > const& pathOne,\r\n        QVector<QSharedPointer<ConnectivityInterface const> > const& pathTwo, int areaSize) const;\r\n\r\n    /*!\r\n     *  Check if the path ends in a memory map.\r\n     *\r\n     *    @param [in] path    The selected path.\r\n     *\r\n     *    @return True, if the selected path ends in a memory map, false otherwise.\r\n     */\r\n    bool pathEndsInMemoryMap(QVector<QSharedPointer<ConnectivityInterface const> > const& path) const;\r\n\r\n};\r\n\r\n#endif // MASTERSLAVEPATHSEARCH_H\r\n"
  },
  {
    "path": "editors/MemoryDesigner/MemoryCollisionItem.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: MemoryCollisionItem.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Mikko Teuho\r\n// Date: 06.09.2016\r\n//\r\n// Description:\r\n// Graphics item for displaying colliding memory usage in memory designer.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"MemoryCollisionItem.h\"\r\n\r\n#include <common/KactusColors.h>\r\n\r\n#include <editors/MemoryDesigner/MemoryDesignerConstants.h>\r\n#include <editors/MemoryDesigner/MemoryConnectionItem.h>\r\n#include <editors/MemoryDesigner/MemoryDesignerGraphicsItem.h>\r\n#include <editors/MemoryDesigner/MemoryMapGraphicsItem.h>\r\n#include <editors/MemoryDesigner/MemoryColumn.h>\r\n\r\n#include <QFont>\r\n#include <QGraphicsSceneMouseEvent>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryCollisionItem::MemoryCollisionItem()\r\n//-----------------------------------------------------------------------------\r\nMemoryCollisionItem::MemoryCollisionItem(MemoryConnectionItem* firstItem, MemoryConnectionItem* secondItem,\r\n    QGraphicsScene* containingScene):\r\nQObject(),\r\nQGraphicsRectItem(),\r\nfirstConnection_(firstItem),\r\nsecondConnection_(secondItem),\r\nfirstRangeStart_(firstItem->getRangeStartValue()),\r\nfirstRangeEnd_(firstItem->getRangeEndValue()),\r\nsecondRangeStart_(secondItem->getRangeStartValue()),\r\nsecondRangeEnd_(secondItem->getRangeEndValue())\r\n{\r\n    setRectangle();\r\n\r\n    containingScene->addItem(this);\r\n\r\n    setCollisionBrush();\r\n\r\n//     setLabels();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryCollisionItem::~MemoryCollisionItem()\r\n//-----------------------------------------------------------------------------\r\nMemoryCollisionItem::~MemoryCollisionItem()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryCollisionItem::setCollisionBrush()\r\n//-----------------------------------------------------------------------------\r\nvoid MemoryCollisionItem::setCollisionBrush()\r\n{\r\n    QBrush collisionBrush(KactusColors::MISSING_COMPONENT);\r\n    setBrush(collisionBrush);\r\n    setOpacity(0.2);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryCollisionItem::setLabels()\r\n//-----------------------------------------------------------------------------\r\nvoid MemoryCollisionItem::setLabels()\r\n{\r\n    QPointF topLeft = boundingRect().topLeft();\r\n    QPointF lowLeft = boundingRect().bottomLeft();\r\n\r\n    quint64 collisionRangeStart = qMax(firstRangeStart_, secondRangeStart_);\r\n    quint64 collisionRangeEnd = qMin(firstRangeEnd_, secondRangeEnd_);\r\n\r\n    QString collisionBaseInHexa = QString::number(collisionRangeStart, 16).toUpper();\r\n    QString collisionLastInHexa = QString::number(collisionRangeEnd, 16).toUpper();\r\n\r\n    int amountOfNumbers =\r\n        MemoryDesignerConstants::getAmountOfNumbersInRange(collisionBaseInHexa, collisionLastInHexa);\r\n    collisionBaseInHexa = MemoryDesignerConstants::getValueWithZerosAdded(collisionBaseInHexa, amountOfNumbers);\r\n    collisionLastInHexa = MemoryDesignerConstants::getValueWithZerosAdded(collisionLastInHexa, amountOfNumbers);\r\n\r\n    QGraphicsTextItem* startPointRangeStart = new QGraphicsTextItem(collisionBaseInHexa, this);\r\n\r\n    QFont labelFont = startPointRangeStart->font();\r\n    labelFont.setWeight(QFont::Bold);\r\n    startPointRangeStart->setFont(labelFont);\r\n\r\n    QColor faultyTextColor(255, 0, 0);\r\n    startPointRangeStart->setDefaultTextColor(faultyTextColor);\r\n    \r\n    int startPointYCorrection = -3;\r\n    qreal endPointYCorrection = 0;\r\n    if (collisionRangeEnd - collisionRangeStart > 0)\r\n    {\r\n        QGraphicsTextItem* startPointRangeEnd = new QGraphicsTextItem(collisionLastInHexa, this);\r\n\r\n        if (boundingRect().height() <= MemoryDesignerConstants::RANGEINTERVAL + 1)\r\n        {\r\n            startPointYCorrection = -startPointRangeStart->boundingRect().height() + 4;\r\n            endPointYCorrection = 4;\r\n        }\r\n        else\r\n        {\r\n            startPointYCorrection = 0;\r\n            endPointYCorrection = startPointRangeEnd->boundingRect().height() - 1;\r\n        }\r\n\r\n        startPointRangeEnd->setPos(lowLeft.x() + 2, lowLeft.y() - endPointYCorrection);\r\n        startPointRangeEnd->setFont(labelFont);\r\n        startPointRangeEnd->setDefaultTextColor(faultyTextColor);\r\n    }\r\n\r\n    startPointRangeStart->setPos(topLeft.x() + 2, topLeft.y() + startPointYCorrection);\r\n\r\n    QVector<MemoryColumn*> collidingColumns;\r\n\r\n    for (QGraphicsItem* collidingItem : collidingItems())\r\n    {\r\n        MemoryMapGraphicsItem* mapGraphicsItem = dynamic_cast<MemoryMapGraphicsItem*>(collidingItem);\r\n        QGraphicsRectItem* extensionItem = dynamic_cast<QGraphicsRectItem*>(collidingItem);\r\n        if (extensionItem && !mapGraphicsItem)\r\n        {\r\n            mapGraphicsItem = dynamic_cast<MemoryMapGraphicsItem*>(extensionItem->parentItem());\r\n        }\r\n\r\n        if (mapGraphicsItem)\r\n        {\r\n            QGraphicsItem* mapParentItem = mapGraphicsItem->parentItem();\r\n            MemoryColumn* containingColumn = dynamic_cast<MemoryColumn*>(mapParentItem);\r\n            if (containingColumn && !collidingColumns.contains(containingColumn))\r\n            {\r\n                QPointF mapTopLeft = mapFromItem(mapGraphicsItem, mapGraphicsItem->boundingRect().topLeft());\r\n\r\n                QGraphicsTextItem* collidingMapRangeStart = new QGraphicsTextItem(collisionBaseInHexa, this);\r\n                collidingMapRangeStart->setDefaultTextColor(faultyTextColor);\r\n                collidingMapRangeStart->setFont(labelFont);\r\n                collidingMapRangeStart->setPos(\r\n                    mapTopLeft.x() - (collidingMapRangeStart->boundingRect().width() + 2),\r\n                    topLeft.y() + startPointYCorrection);\r\n\r\n                if (collisionRangeEnd - collisionRangeStart > 0)\r\n                {\r\n                    QGraphicsTextItem* collidingMapRangeEnd = new QGraphicsTextItem(collisionLastInHexa, this);\r\n                    collidingMapRangeEnd->setDefaultTextColor(faultyTextColor);\r\n                    collidingMapRangeEnd->setFont(labelFont);\r\n                    collidingMapRangeEnd->setPos(\r\n                        mapTopLeft.x() - (collidingMapRangeEnd->boundingRect().width() + 2),\r\n                        lowLeft.y() - endPointYCorrection);\r\n                }\r\n\r\n                collidingColumns.append(containingColumn);\r\n            }\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryCollisionItem::reDrawCollision()\r\n//-----------------------------------------------------------------------------\r\nvoid MemoryCollisionItem::reDrawCollision()\r\n{\r\n    setRectangle();\r\n\r\n    int childItemCount = childItems().size();\r\n    for (int childItemIndex = 0; childItemIndex < childItemCount; ++childItemIndex)\r\n    {\r\n        QGraphicsItem* childItem = childItems().takeFirst();\r\n        delete childItem;\r\n    }\r\n\r\n//     setLabels();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryCollisionItem::setRectangle()\r\n//-----------------------------------------------------------------------------\r\nvoid MemoryCollisionItem::setRectangle()\r\n{\r\n    const qreal LINEWIDTH = 1;\r\n\r\n    QRectF firstItemRectangle = firstConnection_->sceneBoundingRect();\r\n    QRectF secondItemRectangle = secondConnection_->sceneBoundingRect();\r\n\r\n    qreal startX = qMax(firstItemRectangle.left(), secondItemRectangle.left());\r\n    qreal startY = qMax(firstItemRectangle.top(), secondItemRectangle.top()) + LINEWIDTH / 2;\r\n    qreal endX = qMax(firstItemRectangle.right(), secondItemRectangle.right());\r\n    qreal endY = qMin(firstItemRectangle.bottom(), secondItemRectangle.bottom() + LINEWIDTH / 2);\r\n\r\n    qreal itemWidth = endX - startX;\r\n    qreal itemHeight = endY - startY;\r\n\r\n    QPointF spaceItemStartPoint (startX, startY);\r\n    \r\n    setRect(spaceItemStartPoint.x(), spaceItemStartPoint.y(), itemWidth, itemHeight - 1);\r\n}"
  },
  {
    "path": "editors/MemoryDesigner/MemoryCollisionItem.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: MemoryCollisionItem.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Mikko Teuho\r\n// Date: 06.09.2016\r\n//\r\n// Description:\r\n// Graphics item for displaying colliding memory usage in memory designer.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef MEMORYCOLLISIONITEM_H\r\n#define MEMORYCOLLISIONITEM_H\r\n\r\n#include <QGraphicsRectItem>\r\n#include <QGraphicsTextItem>\r\n\r\nclass MemoryConnectionItem;\r\nclass MemoryDesignerGraphicsItem;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Graphics item for displaying colliding memory usage in memory designer.\r\n//-----------------------------------------------------------------------------\r\nclass MemoryCollisionItem : public QObject, public QGraphicsRectItem\r\n{\r\n\r\npublic:\r\n\r\n    /*!\r\n     *  The constructor.\r\n     *\r\n     *    @param [in] firstItem           The first memory connection.\r\n     *    @param [in] secondItem          The second memory connection.\r\n     *    @param [in] containingScene     The scene containing the memory connections.\r\n     */\r\n    MemoryCollisionItem(MemoryConnectionItem* firstItem, MemoryConnectionItem* secondItem,\r\n        QGraphicsScene* containingScene);\r\n\r\n\t/*!\r\n     *  The destructor.\r\n     */\r\n    virtual ~MemoryCollisionItem();\r\n\r\n    /*!\r\n     *  Redraw the memory connection collision item.\r\n     */\r\n    void reDrawCollision();\r\n\r\nprivate:\r\n    // Disable copying.\r\n    MemoryCollisionItem(MemoryCollisionItem const& rhs);\r\n    MemoryCollisionItem& operator=(MemoryCollisionItem const& rhs);\r\n\r\n    /*!\r\n     *  Setup the brush for memory collision.\r\n     */\r\n    void setCollisionBrush();\r\n\r\n    /*!\r\n     *  Set the labels.\r\n     */\r\n    void setLabels();\r\n\r\n    /*!\r\n     *  Set the collision rectangle.\r\n     */\r\n    void setRectangle();\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! The first memory connection graphics item.\r\n    MemoryConnectionItem* firstConnection_;\r\n\r\n    //! The second memory connection graphics item.\r\n    MemoryConnectionItem* secondConnection_;\r\n\r\n    //! Start of the memory range of the first memory connection.\r\n    quint64 firstRangeStart_;\r\n\r\n    //! End of the memory range of the first memory connection.\r\n    quint64 firstRangeEnd_;\r\n\r\n    //! Start of the memory range of the second memory connection.\r\n    quint64 secondRangeStart_;\r\n\r\n    //! End of the memory range of the second memory connection.\r\n    quint64 secondRangeEnd_;\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n\r\n#endif // MEMORYCOLLISIONITEM_H\r\n"
  },
  {
    "path": "editors/MemoryDesigner/MemoryColumn.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: MemoryColumn.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Joni-Matti Maatta\r\n// Date: 17.10.2012\r\n//\r\n// Description:\r\n// Memory column.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"MemoryColumn.h\"\r\n\r\n#include <common/graphicsItems/GraphicsConnection.h>\r\n#include <common/graphicsItems/GraphicsColumnLayout.h>\r\n#include <common/layouts/IVGraphicsLayout.h>\r\n#include <common/layouts/VNoCollisionNoMovementLayout.h>\r\n\r\n#include <editors/MemoryDesigner/AddressSpaceGraphicsItem.h>\r\n#include <editors/MemoryDesigner/MemoryMapGraphicsItem.h>\r\n#include <editors/MemoryDesigner/MainMemoryGraphicsItem.h>\r\n#include <editors/MemoryDesigner/MemoryExtensionGraphicsItem.h>\r\n#include <editors/MemoryDesigner/MemoryConnectionItem.h>\r\n#include <editors/MemoryDesigner/MemoryDesignerConstants.h>\r\n\r\n#include <IPXACTmodels/Component/Component.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryColumn()\r\n//-----------------------------------------------------------------------------\r\nMemoryColumn::MemoryColumn(QSharedPointer<ColumnDesc> desc, GraphicsColumnLayout* layout, int itemSpacing):\r\nGraphicsColumn(desc, layout, false)\r\n{\r\n    QSharedPointer<IVGraphicsLayout<QGraphicsItem> > newItemLayout(\r\n        new VNoCollisionNoMovementLayout<QGraphicsItem>(itemSpacing));\r\n\r\n    setItemLayout(newItemLayout);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryColumn::isItemAllowed()\r\n//-----------------------------------------------------------------------------\r\nbool MemoryColumn::isItemAllowed(QGraphicsItem* item, unsigned int allowedItems) const\r\n{\r\n    if (allowedItems & ColumnTypes::MEMORY &&\r\n        (item->type() == AddressSpaceGraphicsItem::Type || item->type() == MemoryMapGraphicsItem::Type))\r\n    {\r\n        return true;\r\n    }\r\n\r\n    return false;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryColumn::findGraphicsItemByMemoryItem()\r\n//-----------------------------------------------------------------------------\r\nMainMemoryGraphicsItem* MemoryColumn::findGraphicsItemByMemoryItem(\r\n    QSharedPointer<MemoryItem const> containedMemoryItem) const\r\n{\r\n    if (containedMemoryItem)\r\n    {\r\n        foreach (QGraphicsItem* item, getItems())\r\n        {\r\n            auto memoryGraphicsItem = dynamic_cast<MainMemoryGraphicsItem*>(item);\r\n            if (memoryGraphicsItem && memoryGraphicsItem->getMemoryItem() == containedMemoryItem && memoryGraphicsItem->isOriginal())\r\n            {\r\n                return memoryGraphicsItem;\r\n            }\r\n        }\r\n    }\r\n\r\n    return 0;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryColumn::getGraphicsItemInOrder()\r\n//-----------------------------------------------------------------------------\r\nQMultiMap<qreal, MainMemoryGraphicsItem*> MemoryColumn::getGraphicsItemInOrder() const\r\n{\r\n    QMultiMap<qreal, MainMemoryGraphicsItem*> orderedGraphicsItems;\r\n\r\n    for (QGraphicsItem* graphicsItem : getItems())\r\n    {\r\n        auto memoryItem = dynamic_cast<MainMemoryGraphicsItem*>(graphicsItem);\r\n        if (memoryItem)\r\n        {\r\n            qreal itemScenePositionY = graphicsItem->scenePos().y();\r\n            orderedGraphicsItems.insert(itemScenePositionY, memoryItem);\r\n        }\r\n    }\r\n\r\n    return orderedGraphicsItems;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryColumn::containsMemoryMapItems()\r\n//-----------------------------------------------------------------------------\r\nbool MemoryColumn::containsMemoryMapItems() const\r\n{\r\n    return name().contains(MemoryDesignerConstants::MEMORYMAPCOLUMNCOMMON_NAME);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryColumn::changeWidth()\r\n//-----------------------------------------------------------------------------\r\nvoid MemoryColumn::changeWidth(qreal deltaWidth)\r\n{\r\n    bool columnHasItems = getItems().size() > 0;\r\n\r\n    qreal previousXPosition = 0;\r\n    if (columnHasItems)\r\n    {\r\n        previousXPosition = getItems().first()->pos().x();\r\n    }\r\n\r\n    qreal previousWidth = getColumnDesc()->getWidth();\r\n    setWidth(previousWidth + deltaWidth);\r\n\r\n    foreach (QGraphicsItem* subItem, getItems())\r\n    {\r\n        auto mapItem = dynamic_cast<MemoryMapGraphicsItem*>(subItem);\r\n        if (mapItem)\r\n        {\r\n            mapItem->setX(previousXPosition);\r\n            mapItem->changeWidth(deltaWidth);\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryColumn::getMaximumNeededChangeInWidth()\r\n//-----------------------------------------------------------------------------\r\nqreal MemoryColumn::getMaximumNeededChangeInWidth() const\r\n{\r\n    qreal maximumWidthChange = 0;\r\n    foreach (QGraphicsItem* subItem, getItems())\r\n    {\r\n        auto mapItem = dynamic_cast<MemoryMapGraphicsItem*>(subItem);\r\n        if (mapItem)\r\n        {\r\n            maximumWidthChange = qMax(maximumWidthChange, mapItem->getMaximumNeededChangeInFieldWidth());\r\n        }\r\n    }\r\n\r\n    return maximumWidthChange;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryColumn::moveUnconnectedMemoryItems()\r\n//-----------------------------------------------------------------------------\r\nvoid MemoryColumn::moveUnconnectedMemoryItems(QSharedPointer<QVector<MainMemoryGraphicsItem*> > placedItems) const\r\n{\r\n    qreal currentPosition = getUnconnectedItemPosition(placedItems);\r\n\r\n    foreach (QGraphicsItem* graphicsItem, getItems())\r\n    {\r\n        auto memoryItem = dynamic_cast<MainMemoryGraphicsItem*>(graphicsItem);\r\n        if (memoryItem && memoryItem->getMemoryConnections().isEmpty())\r\n        {\r\n            memoryItem->setY(currentPosition);\r\n\r\n            currentPosition +=\r\n                memoryItem->getHeightWithSubItems() + MemoryDesignerConstants::UNCONNECTED_ITEM_INTERVAL;\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryColumn::getLastItemLow()\r\n//-----------------------------------------------------------------------------\r\nquint64 MemoryColumn::getUnconnectedItemPosition(QSharedPointer<QVector<MainMemoryGraphicsItem*> > placedItems)\r\n    const\r\n{\r\n    qreal lastItemLowLinePosition = 0;\r\n    foreach (MainMemoryGraphicsItem* graphicsItem, *placedItems)\r\n    {\r\n        qreal extensionHeight = 0;\r\n        \r\n        if (auto extensionItem = graphicsItem->getExtensionItem(); extensionItem)\r\n        {\r\n            extensionHeight = extensionItem->sceneBoundingRect().height();\r\n        }\r\n        if (qreal subItemHeightAddition = graphicsItem->getSubItemHeightAddition(); subItemHeightAddition > extensionHeight)\r\n        {\r\n            extensionHeight = subItemHeightAddition;\r\n        }\r\n\r\n        qreal itemLow = graphicsItem->sceneBoundingRect().bottom() + extensionHeight;\r\n        if (itemLow > lastItemLowLinePosition)\r\n        {\r\n            lastItemLowLinePosition = itemLow;\r\n        }\r\n    }\r\n\r\n    quint64 positionY = 0;\r\n    if (lastItemLowLinePosition == 0)\r\n    {\r\n        positionY = MemoryDesignerConstants::SPACEITEMINTERVAL;\r\n    }\r\n    else\r\n    {\r\n        positionY = lastItemLowLinePosition + MemoryDesignerConstants::CONNECTED_UNCONNECTED_INTERVAL;\r\n    }\r\n\r\n    return positionY;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryColumn::memoryMapOverlapsInColumn()\r\n//-----------------------------------------------------------------------------\r\nbool MemoryColumn::memoryMapOverlapsInColumn(MainMemoryGraphicsItem const* memoryGraphicsItem,\r\n    QRectF memoryItemRect,\r\n    int memoryPenWidth,\r\n    QVector<MainMemoryGraphicsItem*> connectedSpaceItems,\r\n    QSharedPointer<QVector<MainMemoryGraphicsItem*> > placedMaps) const\r\n{\r\n    for (auto comparisonMemoryItem : *placedMaps)\r\n    {\r\n        if (comparisonMemoryItem->parentItem() == this && comparisonMemoryItem != memoryGraphicsItem)\r\n        {\r\n            QRectF comparisonRectangle = comparisonMemoryItem->getSceneRectangleWithSubItems();\r\n\r\n            if (comparisonMemoryItem->getMemoryConnections().isEmpty() == false)\r\n            {\r\n                qreal newHeight = comparisonMemoryItem->getLastConnection()->sceneBoundingRect().bottom() - comparisonMemoryItem->scenePos().y();\r\n                comparisonRectangle.setHeight(newHeight);\r\n            }\r\n\r\n            int comparisonLineWidth = comparisonMemoryItem->pen().width();\r\n\r\n            bool overlap = MemoryDesignerConstants::itemOverlapsAnotherItem(\r\n                memoryItemRect, memoryPenWidth, comparisonRectangle, comparisonLineWidth);\r\n\r\n            if (overlap)\r\n            {\r\n                return true;\r\n            }\r\n        }\r\n    }\r\n\r\n    return false;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryColumn::itemOverlapsAnotherPlacedColumnItem()\r\n//-----------------------------------------------------------------------------\r\nbool MemoryColumn::itemOverlapsAnotherPlacedColumnItem(MainMemoryGraphicsItem const* memoryItem,\r\n    QRectF const& itemRectangle,\r\n    int lineWidth,\r\n    QSharedPointer<QVector<MainMemoryGraphicsItem*> > placedItems) const\r\n{\r\n    for (MainMemoryGraphicsItem * comparisonItem : getGraphicsItemInOrder())\r\n    {\r\n        if (placedItems->contains(comparisonItem) && comparisonItem != memoryItem)\r\n        {\r\n            QRectF comparisonRectangle = comparisonItem->getSceneRectangleWithSubItems();\r\n            if (comparisonItem->hasExtensionItem())\r\n            {\r\n                comparisonRectangle.setHeight(comparisonRectangle.height() + comparisonItem->getExtensionItem()->boundingRect().height());\r\n            }\r\n\r\n            int comparisonLineWidth = comparisonItem->pen().width();\r\n\r\n            if (MemoryDesignerConstants::itemOverlapsAnotherItem(\r\n                itemRectangle, lineWidth, comparisonRectangle, comparisonLineWidth))\r\n            {\r\n                return true;\r\n            }\r\n        }\r\n    }\r\n\r\n    return false;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryColumn::compressUnconnectedMemoryItems()\r\n//-----------------------------------------------------------------------------\r\nvoid MemoryColumn::compressUnconnectedMemoryItems(bool compressMemoryItems, QSharedPointer<QVector<MainMemoryGraphicsItem*> > placedItems)\r\n{\r\n    for (auto graphicsItem : getGraphicsItemInOrder())\r\n    {\r\n        if (placedItems->contains(graphicsItem) == false)\r\n        {\r\n            graphicsItem->compressItemAndChildItems(compressMemoryItems);\r\n        }\r\n    }\r\n}\r\n"
  },
  {
    "path": "editors/MemoryDesigner/MemoryColumn.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: MemoryColumn.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Joni-Matti Maatta\r\n// Date: 17.10.2012\r\n//\r\n// Description:\r\n// Memory column.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef MEMORYCOLUMN_H\r\n#define MEMORYCOLUMN_H\r\n\r\n#include <common/graphicsItems/GraphicsItemTypes.h>\r\n#include <common/graphicsItems/GraphicsColumn.h>\r\n\r\nclass GraphicsColumnLayout;\r\nclass GraphicsConnection;\r\nclass MainMemoryGraphicsItem;\r\nclass MemoryItem;\r\nclass MemoryConnectionItem;\r\nclass MemoryMapGraphicsItem;\r\n\r\n#include <QGraphicsRectItem>\r\n#include <QSet>\r\n#include <QCursor>\r\n#include <QMultiMap>\r\n\r\n//-----------------------------------------------------------------------------\r\n//! MemoryColumn class.\r\n//-----------------------------------------------------------------------------\r\nclass MemoryColumn : public GraphicsColumn\r\n{\r\n    Q_OBJECT\r\n\r\npublic:\r\n    enum { Type = GFX_TYPE_SYSTEM_COLUMN };\r\n\r\n    /*!\r\n     *  Constructor.\r\n     *\r\n     *    @param [in] name            The column description.\r\n     *    @param [in] layout          The parent column layout.\r\n     *    @param [in] itemSpacing     Spacing for the graphics items.\r\n     */\r\n    MemoryColumn(QSharedPointer<ColumnDesc> desc, GraphicsColumnLayout* layout, int itemSpacing = 30);\r\n\r\n    /*!\r\n     *  The destructor.\r\n     */\r\n    virtual ~MemoryColumn() = default;\r\n\r\n    /*!\r\n     *  Find a graphics item by a given memory item.\r\n     *\r\n     *    @param [in] containedMemoryItem     The selected memory item.\r\n     *\r\n     *    @return Memory graphics item matching the selected memory item.\r\n     */\r\n    MainMemoryGraphicsItem* findGraphicsItemByMemoryItem(QSharedPointer<MemoryItem const> containedMemoryItem)\r\n        const;\r\n\r\n    /*!\r\n     *  Get the type of this item.\r\n     */\r\n    int type() const { return Type; }\r\n\r\n    /*!\r\n     *  Get the main memory graphics items contained within this column in the order of their scene positions.\r\n     *\r\n     *    @return Map containing y-coordinate, main memory graphics item pairs.\r\n     */\r\n    QMultiMap<qreal, MainMemoryGraphicsItem*> getGraphicsItemInOrder() const;\r\n\r\n    /*!\r\n     *  Check if the memory column contains memory map graphics items.\r\n     *\r\n     *    @return True, if the column contains memory map graphics items, false otherwise.\r\n     */\r\n    bool containsMemoryMapItems() const;\r\n\r\n    /*!\r\n     *  Change the width of the memory column and the contained memory map graphics items.\r\n     *\r\n     *    @param [in] deltaWidth  Change of width.\r\n     */\r\n    void changeWidth(qreal deltaWidth);\r\n\r\n    /*!\r\n     *  Get the maximum needed change in width to display the name labels of all the field items contained within\r\n     *  the memory map items.\r\n     *\r\n     *    @return The maximum needed change in width to display the name labels of all the field items.\r\n     */\r\n    qreal getMaximumNeededChangeInWidth() const;\r\n\r\n    /*!\r\n     *  Move the unconnected memory items to the bottom of the column.\r\n     *\r\n     *    @param [in] placedItems     List of the connected items of the column.\r\n     */\r\n    void moveUnconnectedMemoryItems(QSharedPointer<QVector<MainMemoryGraphicsItem*> > placedItems) const;\r\n\r\n    /*!\r\n     *  Check if a memory map overlaps within this column.\r\n     *\r\n     *    @param [in] connectionBaseAddress   Lowest base address of the connections in the selected memory item.\r\n     *    @param [in] connectionLastAddress   Highest last address of the connections in the selected memory item.\r\n     *    @param [in] memoryGraphicsItem      The selected memory map item.\r\n     *    @param [in] memoryItemRect          Bounding rectangle of the selected memory map item.\r\n     *    @param [in] memoryPenWidth          Line width of the memory map item.\r\n     *    @param [in] connectedSpaceItems     List of address space items connected to the memory map item.\r\n     *    @param [in] placedMaps              List of the placed memory map items.\r\n     *\r\n     *    @return True if the memory map overlaps another item in this column, false otherwise.\r\n     */\r\n    bool memoryMapOverlapsInColumn(MainMemoryGraphicsItem const* memoryGraphicsItem,\r\n        QRectF memoryItemRect,\r\n        int memoryPenWidth,\r\n        QVector<MainMemoryGraphicsItem*> connectedSpaceItems,\r\n        QSharedPointer<QVector<MainMemoryGraphicsItem*> > placedMaps) const;\r\n\r\n    /*!\r\n     *  Check if the item overlaps another placed column item.\r\n     *\t\r\n     *    @param [in] memoryItem      The selected memory item.\r\n     *    @param [in] itemRectangle   Scene rectangle of the memory item.\r\n     *    @param [in] lineWidth       Line width of the rectangle.\r\n     *    @param [in] placedItems     List of the placed memory items.\r\n     *\r\n     *    @return True, if the item overlaps another placed item, false otherwise.\r\n     */\r\n    bool itemOverlapsAnotherPlacedColumnItem(MainMemoryGraphicsItem const* memoryItem, QRectF const& itemRectangle, int lineWidth, QSharedPointer<QVector<MainMemoryGraphicsItem*> > placedItems)\r\n        const;\r\n\r\n    /*!\r\n     *  Compress the unconnected memory items.\r\n     *\t\r\n     *    @param [in] compressMemoryItems     Flag for compressing the memory items.\r\n     *    @param [in] placedItems             List of the placed memory items.\r\n     */\r\n    void compressUnconnectedMemoryItems(bool compressMemoryItems, QSharedPointer<QVector<MainMemoryGraphicsItem*> > placedItems);\r\n\r\nprotected:\r\n\r\n    /*!\r\n     *  Returns true if the given item is allowed to reside in the column based on the allowed items.\r\n     *\r\n     *    @param [in] item          The item.\r\n     *    @param [in] allowedItems  The allowed items flags.\r\n     */\r\n    virtual bool isItemAllowed(QGraphicsItem* item, unsigned int allowedItems) const;\r\n\r\nprivate:\r\n    // Disable copying.\r\n    MemoryColumn(MemoryColumn const& rhs);\r\n    MemoryColumn& operator=(MemoryColumn const& rhs);\r\n\r\n    /*!\r\n     *  Get the position for the unconnected memory items.\r\n     *\r\n     *    @param [in] placedItems     List of the placed memory graphics items.\r\n     *\r\n     *    @return Y-coordinate for the unconnected memory items.\r\n     */\r\n    quint64 getUnconnectedItemPosition(QSharedPointer<QVector<MainMemoryGraphicsItem*> > placedItems) const;\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n\r\n#endif // MEMORYCOLUMN_H\r\n"
  },
  {
    "path": "editors/MemoryDesigner/MemoryColumnHandler.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: MemoryColumnHandler.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 02.01.2017\n//\n// Description:\n// Constructs the columns for the memory design diagram.\n//-----------------------------------------------------------------------------\n\n#include \"MemoryColumnHandler.h\"\n\n#include <editors/MemoryDesigner/MemoryColumn.h>\n#include <editors/MemoryDesigner/MemoryDesignerConstants.h>\n\n//-----------------------------------------------------------------------------\n// Function: MemoryColumnHandler::MemoryColumnHandler()\n//-----------------------------------------------------------------------------\nMemoryColumnHandler::MemoryColumnHandler(QSharedPointer<GraphicsColumnLayout> layout):\nspaceColumnWidth_(MemoryDesignerConstants::SPACECOLUMNWIDTH),\nmemoryMapColumnWidth_(MemoryDesignerConstants::MEMORYMAPCOLUMNWIDTH),\nlayout_(layout)\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: MemoryColumnHandler::~MemoryColumnHandler()\n//-----------------------------------------------------------------------------\nMemoryColumnHandler::~MemoryColumnHandler()\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: MemoryColumnHandler::setNewMemoryMapColumnWidth()\n//-----------------------------------------------------------------------------\nvoid MemoryColumnHandler::setNewMemoryMapColumnWidth(int newMapColumnWidth)\n{\n    memoryMapColumnWidth_ = newMapColumnWidth;\n}\n\n//-----------------------------------------------------------------------------\n// Function: MemoryColumnHandler::getMemoryMapColumnWidth()\n//-----------------------------------------------------------------------------\nint MemoryColumnHandler::getMemoryMapColumnWidth() const\n{\n    return memoryMapColumnWidth_;\n}\n\n//-----------------------------------------------------------------------------\n// Function: MemoryColumnHandler::setNewLayout()\n//-----------------------------------------------------------------------------\nvoid MemoryColumnHandler::setNewLayout(QSharedPointer<GraphicsColumnLayout> newLayout)\n{\n    layout_ = newLayout;\n}\n\n//-----------------------------------------------------------------------------\n// Function: MemoryColumnHandler::getMemoryColumns()\n//-----------------------------------------------------------------------------\nQVector<MemoryColumn*> MemoryColumnHandler::getMemoryColumns() const\n{\n    QVector<MemoryColumn*> columns;\n\n    foreach (GraphicsColumn* currentColumn, layout_->getColumns())\n    {\n        MemoryColumn* memoryColumn = dynamic_cast<MemoryColumn*>(currentColumn);\n        if (memoryColumn)\n        {\n            columns.append(memoryColumn);\n        }\n    }\n\n    return columns;\n}\n\n//-----------------------------------------------------------------------------\n// Function: MemoryColumnHandler::getAddressSpaceColumns()\n//-----------------------------------------------------------------------------\nQVector<MemoryColumn*> MemoryColumnHandler::getAddressSpaceColumns() const\n{\n    QVector<MemoryColumn*> addressSpaceColumns =\n        getSpecifiedColumns(MemoryDesignerConstants::ADDRESSSPACECOLUMN_NAME);\n    return addressSpaceColumns;\n}\n\n//-----------------------------------------------------------------------------\n// Function: MemoryColumnHandler::getMemoryMapColumns()\n//-----------------------------------------------------------------------------\nQVector<MemoryColumn*> MemoryColumnHandler::getMemoryMapColumns() const\n{\n    QVector<MemoryColumn*> memoryColumns =\n        getSpecifiedColumns(MemoryDesignerConstants::MEMORYMAPCOLUMNCOMMON_NAME);\n    return memoryColumns;\n}\n\n//-----------------------------------------------------------------------------\n// Function: MemoryColumnHandler::getMapOverlapColumns()\n//-----------------------------------------------------------------------------\nQVector<MemoryColumn*> MemoryColumnHandler::getMapOverlapColumns() const\n{\n    QVector<MemoryColumn*> overlapColumns =\n        getSpecifiedColumns(MemoryDesignerConstants::MEMORYMAPOVERLAPCOLUMN_NAME);\n    return overlapColumns;\n}\n\n//-----------------------------------------------------------------------------\n// Function: MemoryColumnHandler::findColumnAtPosition()\n//-----------------------------------------------------------------------------\nMemoryColumn* MemoryColumnHandler::findColumnAtPosition(QPointF position) const\n{\n    MemoryColumn* memoryColumnAtPosition = 0;\n\n    GraphicsColumn* columnAtPosition = layout_->findColumnAt(position);\n    if (columnAtPosition)\n    {\n        memoryColumnAtPosition = dynamic_cast<MemoryColumn*>(columnAtPosition);\n    }\n\n    return memoryColumnAtPosition;\n}\n\n//-----------------------------------------------------------------------------\n// Function: MemoryColumnHandler::removeColumnFromLayout()\n//-----------------------------------------------------------------------------\nvoid MemoryColumnHandler::removeColumnFromLayout(MemoryColumn* selectedColumn)\n{\n    layout_->removeColumn(selectedColumn);\n}\n\n//-----------------------------------------------------------------------------\n// Function: MemoryColumnHandler::createInitialColumns()\n//-----------------------------------------------------------------------------\nvoid MemoryColumnHandler::createInitialColumns()\n{\n    createAddressSpaceColumn();\n    createMemoryColumns();\n}\n\n//-----------------------------------------------------------------------------\n// Function: MemoryColumnHandler::createAddressSpaceColumn()\n//-----------------------------------------------------------------------------\nMemoryColumn* MemoryColumnHandler::createAddressSpaceColumn()\n{\n    QString spaceName = MemoryDesignerConstants::ADDRESSSPACECOLUMN_NAME;\n\n    int spaceCounter = 0;\n    int lastSpaceColumnIndex = 0;\n    for (int i = 0; i < layout_->getColumns().size(); ++i)\n    {\n        auto column = layout_->getColumns().at(i);\n\n        if (column->name().contains(spaceName, Qt::CaseInsensitive))\n        {\n            spaceCounter += 1;\n            lastSpaceColumnIndex = i;\n        }\n    }\n    if (spaceCounter != 0)\n    {\n        spaceName.append(QStringLiteral(\"_\") + QString::number(spaceCounter));\n    }\n\n    QSharedPointer<ColumnDesc> addressSpaceColumnDescription(new ColumnDesc());\n    addressSpaceColumnDescription->setName(spaceName);\n    addressSpaceColumnDescription->setMinimumWidth(spaceColumnWidth_);\n    addressSpaceColumnDescription->setWidth(spaceColumnWidth_);\n\n    MemoryColumn* spaceColumn(new MemoryColumn(addressSpaceColumnDescription, layout_.data(), 0));\n    layout_->addColumn(spaceColumn);\n\n    auto lastColumnPos = layout_->getColumns().at(lastSpaceColumnIndex)->pos();\n    auto lastColumnRightSideX = layout_->getColumns().at(lastSpaceColumnIndex)->rect().width() + lastColumnPos.x();\n    \n    spaceColumn->setPos(QPointF(lastColumnRightSideX + 1, 0));\n\n    layout_->onMoveColumn(spaceColumn);\n    layout_->onReleaseColumn(spaceColumn);\n\n    return spaceColumn;\n}\n\n//-----------------------------------------------------------------------------\n// Function: MemoryColumnHandler::createMemoryColumns()\n//-----------------------------------------------------------------------------\nvoid MemoryColumnHandler::createMemoryColumns()\n{\n    QPointF columnPlacement (0,0);\n    foreach (GraphicsColumn* column, layout_->getColumns())\n    {\n        columnPlacement.setX(columnPlacement.x() + column->boundingRect().width());\n    }\n\n    QSharedPointer<ColumnDesc> memoryMapColumnDescription(new ColumnDesc());\n    memoryMapColumnDescription->setName(MemoryDesignerConstants::MEMORYMAPCOLUM_NAME);\n    memoryMapColumnDescription->setMinimumWidth(memoryMapColumnWidth_);\n    memoryMapColumnDescription->setWidth(memoryMapColumnWidth_);\n\n    MemoryColumn* memoryMapColumn(new MemoryColumn(memoryMapColumnDescription, layout_.data(), 0));\n\n    memoryMapColumn->setPos(columnPlacement);\n    layout_->addColumn(memoryMapColumn);\n\n//     createMemoryOverlapColumn();\n}\n\n//-----------------------------------------------------------------------------\n// Function: MemoryColumnHandler::createMemoryOverlapColumn()\n//-----------------------------------------------------------------------------\nMemoryColumn* MemoryColumnHandler::createMemoryOverlapColumn()\n{\n    QString overlapName = MemoryDesignerConstants::MEMORYMAPOVERLAPCOLUMN_NAME;\n\n    int overlapCounter = 0;\n    int columnXPosition = 0;\n    foreach (GraphicsColumn* column, layout_->getColumns())\n    {\n        if (column->name().contains(overlapName))\n        {\n            overlapCounter += 1;\n        }\n\n        columnXPosition += column->boundingRect().width();\n    }\n\n    if (overlapCounter > 0)\n    {\n        QString overlapNameExtension = QStringLiteral(\"_\") + QString::number(overlapCounter);\n        overlapName.append(overlapNameExtension);\n    }\n\n    QSharedPointer<ColumnDesc> memoryMapOverlapColumnDescription(new ColumnDesc());\n    memoryMapOverlapColumnDescription->setName(overlapName);\n    memoryMapOverlapColumnDescription->setMinimumWidth(memoryMapColumnWidth_);\n    memoryMapOverlapColumnDescription->setWidth(memoryMapColumnWidth_);\n\n    MemoryColumn* memoryMapOverlapColumn(new MemoryColumn(memoryMapOverlapColumnDescription, layout_.data(), 0));\n    QPointF columnPosition (columnXPosition, 0);\n    memoryMapOverlapColumn->setPos(columnPosition);\n    layout_->addColumn(memoryMapOverlapColumn);\n\n    return memoryMapOverlapColumn;\n}\n\n//-----------------------------------------------------------------------------\n// Function: MemoryColumnHandler::findColumnByName()\n//-----------------------------------------------------------------------------\nMemoryColumn* MemoryColumnHandler::findColumnByName(QString const& columnName) const\n{\n    foreach (GraphicsColumn* column, layout_->getColumns())\n    {\n        MemoryColumn* memoryColumn = dynamic_cast<MemoryColumn*>(column);\n        if (memoryColumn && memoryColumn->name().compare(columnName) == 0)\n        {\n            return memoryColumn;\n        }\n    }\n\n    return 0;\n}\n\n//-----------------------------------------------------------------------------\n// Function: MemoryColumnHandler::getSpecifiedColumns()\n//-----------------------------------------------------------------------------\nQVector<MemoryColumn*> MemoryColumnHandler::getSpecifiedColumns(QString const& columnSpecification) const\n{\n    QVector<MemoryColumn*> foundColumns;\n    \n    foreach (GraphicsColumn* column, layout_->getColumns())\n    {\n        MemoryColumn* currentColumn = dynamic_cast<MemoryColumn*>(column);\n        if (currentColumn && currentColumn->name().contains(columnSpecification, Qt::CaseInsensitive))\n        {\n            foundColumns.append(currentColumn);\n        }\n    }\n\n    return foundColumns;\n}\n\n//-----------------------------------------------------------------------------\n// Function: MemoryColumnHandler::changeColumnWidths()\n//-----------------------------------------------------------------------------\nvoid MemoryColumnHandler::changeColumnWidths(qreal deltaWidth)\n{\n    foreach (GraphicsColumn* column, layout_->getColumns())\n    {\n        MemoryColumn* memoryColumn = dynamic_cast<MemoryColumn*>(column);\n        if (memoryColumn && memoryColumn->containsMemoryMapItems())\n        {\n            memoryColumn->changeWidth(deltaWidth);\n        }\n    }\n}\n"
  },
  {
    "path": "editors/MemoryDesigner/MemoryColumnHandler.h",
    "content": "//-----------------------------------------------------------------------------\n// File: MemoryColumnHandler.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 02.01.2017\n//\n// Description:\n// Constructs the columns for the memory design diagram.\n//-----------------------------------------------------------------------------\n\n#ifndef MEMORYCOLUMNHANDLER_H\n#define MEMORYCOLUMNHANDLER_H\n\n#include <common/graphicsItems/GraphicsColumnLayout.h>\n\nclass MemoryColumn;\n\n//-----------------------------------------------------------------------------\n//! Constructs the columns for the memory design diagram.\n//-----------------------------------------------------------------------------\nclass MemoryColumnHandler\n{\n\npublic:\n\n    /*!\n     *  The constructor.\n     *\n     *    @param [in] layout  Layout for the memory columns.\n     */    \n    MemoryColumnHandler(QSharedPointer<GraphicsColumnLayout> layout);\n\n    /*!\n     *  The destructor.\n     */\n    ~MemoryColumnHandler();\n\n    /*!\n     *  Set a new column width for memory map columns.\n     *\n     *    @param [in] newMapColumnWidth   The new column width.\n     */\n    void setNewMemoryMapColumnWidth(int newMapColumnWidth);\n\n    /*!\n     *  Get the width of the memory map columns.\n     *\n     *    @return Width of the memory map columns.\n     */\n    int getMemoryMapColumnWidth() const;\n\n    /*!\n     *  Set a new layout for the memory columns.\n     *\n     *    @param [in] newLayout   The new layout for the memory columns.\n     */\n    void setNewLayout(QSharedPointer<GraphicsColumnLayout> newLayout);\n\n    /*!\n     *  Get the memory columns.\n     *\n     *    @return The memory columns in the layout.\n     */\n    QVector<MemoryColumn*> getMemoryColumns() const;\n\n    /*!\n     *  Get the address space columns.\n     *\n     *    @return The address space columns in the layout.\n     */\n    QVector<MemoryColumn*> getAddressSpaceColumns() const;\n\n    /*!\n     *  Get the memory map columns.\n     *\n     *    @return The memory map columns in the layout.\n     */\n    QVector<MemoryColumn*> getMemoryMapColumns() const;\n\n    /*!\n     *  Get the memory map overlap columns.\n     *\n     *    @return The memory map overlap columns in the layout.\n     */\n    QVector<MemoryColumn*> getMapOverlapColumns() const;\n\n    /*!\n     *  Get the column located at the given position.\n     *\n     *    @param [in] position    Position of the selected column.\n     *\n     *    @return Column located at the given position, or 0, if no column was found.\n     */\n    MemoryColumn* findColumnAtPosition(QPointF position) const;\n\n    /*!\n     *  Remove the selected column from the layout.\n     *\n     *    @param [in] selectedColumn  The selected column.\n     */\n    void removeColumnFromLayout(MemoryColumn* selectedColumn);\n\n    /*!\n     *  Create the initial memory columns.\n     */\n    void createInitialColumns();\n\n    /*!\n     *  Create an address space column.\n     *\n     *    @return The created address space column.\n     */\n    MemoryColumn* createAddressSpaceColumn();\n\n    /*!\n     *  Create a new memory overlap column.\n     *\n     *    @return The created memory overlap column.\n     */\n    MemoryColumn* createMemoryOverlapColumn();\n\n    /*!\n     *  Get the selected memory column.\n     *\n     *    @param [in] columnName  Name of the selected memory column.\n     *\n     *    @return The found memory column.\n     */\n    MemoryColumn* findColumnByName(QString const& columnName) const;\n\n    /*!\n     *  Get the specified columns.\n     *\n     *    @param [in] columnSpecification     Identifier for the wanted columns.\n     *\n     *    @return A vector containing the specified columns.\n     */\n    QVector<MemoryColumn*> getSpecifiedColumns(QString const& columnSpecification) const;\n\n    /*!\n     *  Change the column widths by the selected amount.\n     *\n     *    @param [in] deltaWidth  The selected width change.\n     */\n    void changeColumnWidths(qreal deltaWidth);\n\nprivate:\n    // Disable copying.\n    MemoryColumnHandler(MemoryColumnHandler const& rhs);\n    MemoryColumnHandler& operator=(MemoryColumnHandler const& rhs);\n\n    /*!\n     *  Create the initial memory map columns.\n     */\n    void createMemoryColumns();\n\n    //-----------------------------------------------------------------------------\n    // Data.\n    //-----------------------------------------------------------------------------\n\n    //! Width of the address space graphics item columns.\n    int spaceColumnWidth_;\n\n    //! Width of the memory map graphics item columns.\n    int memoryMapColumnWidth_;\n\n    //! Layout for the memory columns.\n    QSharedPointer<GraphicsColumnLayout> layout_;\n};\n\n//-----------------------------------------------------------------------------\n\n#endif // MEMORYCOLUMNHANDLER_H\n"
  },
  {
    "path": "editors/MemoryDesigner/MemoryConnectionAddressCalculator.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: MemoryConnectionAddressCalculator.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 15.05.2018\n//\n// Description:\n// Calculates address ranges for connected memory items.\n//-----------------------------------------------------------------------------\n\n#include \"MemoryConnectionAddressCalculator.h\"\n\n#include <KactusAPI/include/PluginUtilityAdapter.h>\n\n#include <editors/MemoryDesigner/ConnectivityComponent.h>\n\n#include <editors/MemoryDesigner/ConnectivityInterface.h>\n#include <editors/MemoryDesigner/MemoryDesignerConstants.h>\n#include <editors/MemoryDesigner/MemoryItem.h>\n\n//-----------------------------------------------------------------------------\n// Function: MemoryConnectionAddressCalculator::calculatePathAddresses()\n//-----------------------------------------------------------------------------\nMemoryConnectionAddressCalculator::CalculatedPathAddresses MemoryConnectionAddressCalculator::calculatePathAddresses(\n    QSharedPointer<const ConnectivityInterface> startInterface,\n    QSharedPointer<const ConnectivityInterface> endInterface,\n    QVector<QSharedPointer<ConnectivityInterface const> > connectionPath)\n{\n    //! Base address for the connection.\n    quint64 connectionBaseAddress = 0;\n    //! Last address available from the point of the starting item.\n    quint64 availableLastAddress = 0;\n\n    QString remapValue(\"\");\n    QString remapRange(\"\");\n\n    if (startInterface != endInterface)\n    {\n        auto pathMemoryItem = startInterface->getConnectedMemory();\n        auto memoryItemRange = pathMemoryItem->getRange().toULongLong();\n        availableLastAddress = memoryItemRange - 1;\n\n        for (auto pathInterface : connectionPath)\n        {\n            //! Initiator interfaces add their base address to the base address of the connection.\n            //! Size of the connected item, or a remap range value determines the last available address for the connection.\n            if (auto pathMode = pathInterface->getMode(); (pathMode == General::MASTER || pathMode == General::INITIATOR) &&\n                pathInterface->isConnectedToMemory())\n            {\n                if (remapRange.isEmpty())\n                {\n                    pathMemoryItem = pathInterface->getConnectedMemory();\n                    memoryItemRange = pathMemoryItem->getRange().toULongLong();\n                }\n                else\n                {\n                    memoryItemRange = remapRange.toULongLong();\n                    remapRange.clear();\n                }\n                if (remapValue.isEmpty() == false)\n                {\n                    connectionBaseAddress += remapValue.toULongLong();\n                }\n\n                if (quint64 newLastAddress = connectionBaseAddress + memoryItemRange - 1; newLastAddress < availableLastAddress)\n                {\n                    availableLastAddress = newLastAddress;\n                }\n\n                connectionBaseAddress += pathInterface->getBaseAddress().toULongLong();\n                remapValue.clear();\n            }\n\n            //! Mirrored target interfaces remap the base address for the connected item.\n            //! Range determines the size of the connection\n            else if ((pathMode == General::MIRRORED_SLAVE || pathMode == General::MIRRORED_TARGET) &&\n                pathInterface->getRemapAddress().isEmpty() == false &&\n                pathInterface->getRemapRange().isEmpty() == false)\n            {\n                remapValue = pathInterface->getRemapAddress();\n                remapRange = pathInterface->getRemapRange();\n            }\n        }\n    }\n    else\n    {\n        auto startMemory = startInterface->getConnectedMemory();\n        auto startRange = startMemory->getRange().toULongLong();\n        \n        availableLastAddress = connectionBaseAddress + startRange - 1;\n    }\n\n    auto mapItem = MemoryDesignerConstants::getMapItem(startInterface, endInterface);\n    auto [mapBaseAddress, mapLastAddress] = getMemoryMapAddressRanges(mapItem);\n    auto mapSize = mapLastAddress - mapBaseAddress;\n\n    if (remapValue.isEmpty() == false)\n    {\n        mapBaseAddress = remapValue.toULongLong();\n    }\n    if (remapRange.isEmpty() == false)\n    {\n        mapSize = remapRange.toULongLong() - 1;\n    }\n\n    CalculatedPathAddresses pathAddresses;\n\n    connectionBaseAddress += mapBaseAddress;\n    quint64 connectionLastAddress = connectionBaseAddress + mapSize;\n\n    if (connectionBaseAddress < availableLastAddress)\n    {\n        if (connectionLastAddress > availableLastAddress)\n        {\n            connectionLastAddress = availableLastAddress;\n        }\n\n        pathAddresses.connectionBaseAddress_ = connectionBaseAddress;\n        pathAddresses.connectionLastAddress_ = connectionLastAddress;\n        pathAddresses.createConnection_ = true;\n    }\n\n    return pathAddresses;\n}\n\n//-----------------------------------------------------------------------------\n// Function: MemoryConnectionAddressCalculator::getMemoryMapAddressRanges()\n//-----------------------------------------------------------------------------\nQPair<quint64, quint64> MemoryConnectionAddressCalculator::getMemoryMapAddressRanges(\n    QSharedPointer<MemoryItem> mapItem)\n{\n    quint64 baseAddress = 0;\n    quint64 lastAddress = 0;\n    if (mapItem && mapItem->getChildItems().size() > 0)\n    {\n        bool firstBlock = true;\n\n        foreach(QSharedPointer<MemoryItem const> blockItem, mapItem->getChildItems())\n        {\n            if (blockItem->getType().compare(MemoryDesignerConstants::ADDRESSBLOCK_TYPE, Qt::CaseInsensitive) == 0)\n            {\n                quint64 blockBaseAddress = blockItem->getAddress().toULongLong();\n                quint64 blockRange = blockItem->getRange().toULongLong();\n                quint64 blockEndPoint = blockBaseAddress + blockRange - 1;\n\n                if (firstBlock)\n                {\n                    baseAddress = blockBaseAddress;\n                    firstBlock = false;\n                }\n                else\n                {\n                    if (blockBaseAddress < baseAddress)\n                    {\n                        baseAddress = blockBaseAddress;\n                    }\n                }\n\n                if (blockEndPoint > lastAddress)\n                {\n                    lastAddress = blockEndPoint;\n                }\n            }\n        }\n    }\n\n    QPair<quint64, quint64> memoryRanges(baseAddress, lastAddress);\n    return memoryRanges;\n}\n"
  },
  {
    "path": "editors/MemoryDesigner/MemoryConnectionAddressCalculator.h",
    "content": "//-----------------------------------------------------------------------------\n// File: MemoryConnectionAddressCalculator.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 15.05.2018\n//\n// Description:\n// Calculates address ranges for connected memory items.\n//-----------------------------------------------------------------------------\n\n#ifndef MEMORYCONNECTIONADDRESSCALCULATOR_H\n#define MEMORYCONNECTIONADDRESSCALCULATOR_H\n\n#include <QVector>\n#include <QSharedPointer>\n\nclass ConnectivityInterface;\nclass MemoryItem;\n\n//-----------------------------------------------------------------------------\n//! Calculates address ranges for connected memory items.\n//-----------------------------------------------------------------------------\nnamespace MemoryConnectionAddressCalculator\n{\n    //! Calculated path variables for shortened path.\n    struct CalculatedPathAddresses\n    {\n        //! Base address for the memory connection.\n        quint64 connectionBaseAddress_ = 0;\n        \n        //! Last address of the memory connection.\n        quint64 connectionLastAddress_ = 0;\n\n        //! A connection can be created from this path.\n        bool createConnection_ = false;\n    };\n\n    /*!\n     *\tCalculate the address range changes of the selected interface path.\n     *\n     *\t\t@param [in]\tstartInterface  The first interface of the connection path.\n     *\t\t@param [in]\tendInterface    The last interface of the connection path\n     *\t\t@param [in]\tconnectionPath  The connection path\n     *\n     *\t\t@return Path variables containing data of the base address and last address for the connection in the connection path.\n     */\n    CalculatedPathAddresses calculatePathAddresses(QSharedPointer<const ConnectivityInterface> startInterface,\n        QSharedPointer<const ConnectivityInterface> endInterface,\n        QVector<QSharedPointer<ConnectivityInterface const> > connectionPath);\n\n    /*!\n     *\tGet the memory map address ranges from the selected memory item.\n     *\n     *\t\t@param [in]\tmapItem     The selected memory item containing the memory map.\n     *\n     *\t\t@return\tQPair containing the base address and the last address of the selected memory map.\n     */\n    QPair<quint64, quint64> getMemoryMapAddressRanges(QSharedPointer<MemoryItem> mapItem);\n};\n\n//-----------------------------------------------------------------------------\n\n#endif // MEMORYCONNECTIONADDRESSCALCULATOR_H\n"
  },
  {
    "path": "editors/MemoryDesigner/MemoryConnectionHandler.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: MemoryConnectionHandler.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 03.01.2017\n//\n// Description:\n// Constructs the memory connections for the memory design diagram.\n//-----------------------------------------------------------------------------\n\n#include \"MemoryConnectionHandler.h\"\n\n#include <editors/MemoryDesigner/MasterSlavePathSearch.h>\n#include <editors/MemoryDesigner/ConnectivityComponent.h>\n#include <editors/MemoryDesigner/ConnectivityInterface.h>\n#include <editors/MemoryDesigner/MemoryDesignerConstants.h>\n#include <editors/MemoryDesigner/MainMemoryGraphicsItem.h>\n#include <editors/MemoryDesigner/MemoryExtensionGraphicsItem.h>\n#include <editors/MemoryDesigner/MemoryColumn.h>\n#include <editors/MemoryDesigner/MemoryConnectionItem.h>\n#include <editors/MemoryDesigner/MemoryCollisionItem.h>\n#include <editors/MemoryDesigner/MemoryColumnHandler.h>\n#include <editors/MemoryDesigner/MemoryItem.h>\n#include <editors/MemoryDesigner/MemoryGraphicsItemHandler.h>\n\n//-----------------------------------------------------------------------------\n// Function: MemoryConnectionHandler::MemoryConnectionHandler()\n//-----------------------------------------------------------------------------\nMemoryConnectionHandler::MemoryConnectionHandler(QSharedPointer<MemoryColumnHandler> columnHandler, QSharedPointer<MemoryGraphicsItemHandler> itemHandler):\ncolumnHandler_(columnHandler),\nitemHandler_(itemHandler)\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: MemoryConnectionHandler::setCondenseMemoryItems()\n//-----------------------------------------------------------------------------\nvoid MemoryConnectionHandler::setCondenseMemoryItems(bool condenseMemoryItems)\n{\n    condenseMemoryItems_ = condenseMemoryItems;\n}\n\n//-----------------------------------------------------------------------------\n// Function: MemoryConnectionHandler::memoryItemsAreCondensed()\n//-----------------------------------------------------------------------------\nbool MemoryConnectionHandler::memoryItemsAreCondensed() const\n{\n    return condenseMemoryItems_;\n}\n\n//-----------------------------------------------------------------------------\n// Function: MemoryConnectionHandler::setFilterAddressSpaceChains()\n//-----------------------------------------------------------------------------\nvoid MemoryConnectionHandler::setFilterAddressSpaceChains(bool filterChains)\n{\n    filterAddressSpaceChains_ = filterChains;\n}\n\n//-----------------------------------------------------------------------------\n// Function: MemoryConnectionHandler::addressSpaceChainsAreFiltered()\n//-----------------------------------------------------------------------------\nbool MemoryConnectionHandler::addressSpaceChainsAreFiltered() const\n{\n    return filterAddressSpaceChains_;\n}\n\n//-----------------------------------------------------------------------------\n// Function: MemoryConnectionHandler::clearConnectionLists()\n//-----------------------------------------------------------------------------\nvoid MemoryConnectionHandler::clearConnectionLists()\n{\n    connectionsToMemoryMaps_.clear();\n    memoryCollisions_.clear();\n}\n\n//-----------------------------------------------------------------------------\n// Function: MemoryConnectionHandler::reDrawConnectionsAndCollisions()\n//-----------------------------------------------------------------------------\nvoid MemoryConnectionHandler::reDrawConnectionsAndCollisions()\n{\n    for (auto connectionItem : connectionsToMemoryMaps_)\n    {\n        connectionItem->reDrawConnection();\n    }\n    for (auto collisionItem : memoryCollisions_)\n    {\n        collisionItem->reDrawCollision();\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: MemoryConnectionHandler::createConnectedItems()\n//-----------------------------------------------------------------------------\nvoid MemoryConnectionHandler::createConnectedItems(QSharedPointer<ConnectivityGraph> connectionGraph, MemoryColumn* spaceColumn, MemoryColumn* memoryMapColumn)\n{\n    QSharedPointer<QVector<MainMemoryGraphicsItem*> > placedMapItems(\n        new QVector<MainMemoryGraphicsItem*>());\n    QSharedPointer<QVector<MainMemoryGraphicsItem*> > placedSpaceItems(\n        new QVector<MainMemoryGraphicsItem*>());\n    QVector<MemoryConnectionItem*> connections;\n\n    MasterSlavePathSearch pathSearcher;\n    QVector<Path> masterSlavePaths = pathSearcher.findMasterSlavePaths(connectionGraph, false);\n    if (masterSlavePaths.isEmpty() == false)\n    {\n        QVector<QSharedPointer<QVector<Path> > > pathSets = findPathSets(masterSlavePaths);\n\n        qreal spaceYPlacement = MemoryDesignerConstants::SPACEITEMINTERVAL;\n\n        for (auto const& singleSet : pathSets)\n        {\n            QSharedPointer<QVector<MainMemoryGraphicsItem*> > placedMapItemsInSet(new QVector<MainMemoryGraphicsItem*>());\n            QSharedPointer<QVector<MainMemoryGraphicsItem*> > placedSpaceItemsInSet(new QVector<MainMemoryGraphicsItem*>());\n\n            connections.append(createConnectionSet(singleSet, placedMapItemsInSet, memoryMapColumn, spaceColumn, spaceYPlacement, placedSpaceItemsInSet));\n\n            placedMapItems->append(*placedMapItemsInSet);\n            placedSpaceItems->append(*placedSpaceItemsInSet);\n\n            // Reposition items in set\n            repositionCompressedAddressSpaces(placedSpaceItemsInSet);\n            repositionCompressedMemoryMaps(placedMapItemsInSet, memoryMapColumn);\n        }\n    }\n\n    spaceColumn->compressUnconnectedMemoryItems(condenseMemoryItems_, placedSpaceItems);\n    memoryMapColumn->compressUnconnectedMemoryItems(condenseMemoryItems_, placedMapItems);\n\n    spaceColumn->moveUnconnectedMemoryItems(placedSpaceItems);\n    memoryMapColumn->moveUnconnectedMemoryItems(placedMapItems);\n\n    if (masterSlavePaths.isEmpty() == false)\n    {\n        redrawMemoryConnections(connections);\n        createOverlappingConnectionMarkers(placedSpaceItems);\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: MemoryConnectionHandler::findPathSets()\n//-----------------------------------------------------------------------------\nQVector<QSharedPointer<QVector<MemoryConnectionHandler::Path> > > MemoryConnectionHandler::findPathSets(QVector<Path> const& masterSlavePaths) const\n{\n    QVector<QSharedPointer<QVector<Path> > > pathSets;\n\n    for (Path currentPath : masterSlavePaths)\n    {\n        auto setIndexes = findPathSetIndexes(currentPath, pathSets);\n        if (setIndexes.isEmpty())\n        {\n            QSharedPointer<QVector<Path> > newSet(new QVector<Path>());\n            newSet->append(currentPath);\n            pathSets.append(newSet);\n        }\n        else\n        {\n            //! Place into the first set\n            auto firstSet = pathSets.at(setIndexes.dequeue());\n            firstSet->append(currentPath);\n\n            //! Place other sets into the first set\n            while (setIndexes.isEmpty() == false)\n            {\n                auto secondarySet = pathSets.takeAt(setIndexes.dequeue());\n                firstSet->append(*secondarySet);\n            }\n        }\n    }\n\n    return pathSets;\n}\n\n//-----------------------------------------------------------------------------\n// Function: MemoryConnectionHandler::findPathSetIndexes()\n//-----------------------------------------------------------------------------\nQQueue<int> MemoryConnectionHandler::findPathSetIndexes(Path const& currentPath, QVector<QSharedPointer<QVector<Path> > > const& pathSets) const\n{\n    QQueue<int> pathSetIndexes;\n\n    for (int i = 0; i < pathSets.size(); ++i)\n    {\n        auto currentPathSet = pathSets.at(i);\n        if (pathIsContainedWithPathSet(currentPath, currentPathSet))\n        {\n            pathSetIndexes.enqueue(i);\n        }\n    }\n\n    return pathSetIndexes;\n}\n\n//-----------------------------------------------------------------------------\n// Function: MemoryConnectionHandler::pathIsContainedWithPathSet()\n//-----------------------------------------------------------------------------\nbool MemoryConnectionHandler::pathIsContainedWithPathSet(Path const& currentPath, QSharedPointer<QVector<Path>> pathSet) const\n{\n    for (auto const& comparisonPath : *pathSet)\n    {\n        for (auto const& pathInterface : currentPath)\n        {\n            if (pathInterface->isConnectedToMemory() && interfacedItemIsWithinPath(pathInterface, comparisonPath))\n            {\n                return true;\n            }\n        }\n    }\n\n    return false;\n}\n\n//-----------------------------------------------------------------------------\n// Function: MemoryConnectionHandler::interfacedItemIsWithinPath()\n//-----------------------------------------------------------------------------\nbool MemoryConnectionHandler::interfacedItemIsWithinPath(QSharedPointer<const ConnectivityInterface> pathInterface, Path const& comparisonPath) const\n{\n    for (auto const& comparisonInterface : comparisonPath)\n    {\n        if (pathInterface->getConnectedMemory() == comparisonInterface->getConnectedMemory())\n        {\n            return true;\n        }\n    }\n\n    return false;\n}\n\n//-----------------------------------------------------------------------------\n// Function: MemoryConnectionHandler::createConnectionSet()\n//-----------------------------------------------------------------------------\nQVector<MemoryConnectionItem*> MemoryConnectionHandler::createConnectionSet(QSharedPointer<QVector<Path>> pathSet,\n    QSharedPointer<QVector<MainMemoryGraphicsItem*>> placedMapItems,\n    MemoryColumn* memoryMapColumn,\n    MemoryColumn* spaceColumn,\n    qreal& spaceYPlacement,\n    QSharedPointer<QVector<MainMemoryGraphicsItem*>> placedSpaceItems)\n{\n    QSharedPointer<QVector<MainMemoryGraphicsItem*> > placedItems(new QVector<MainMemoryGraphicsItem*>());\n    QSharedPointer<QVector<QSharedPointer<LinkedGraphicItem> > > roots(new QVector<QSharedPointer<LinkedGraphicItem> >());\n\n    for (auto const& connectionPath : *pathSet)\n    {\n        createLinkedItemsForPath(placedItems, roots, spaceColumn, memoryMapColumn, connectionPath);\n    }\n\n    if (filterAddressSpaceChains_)\n    {\n        createOnlyEndsConnectionFromLinks(roots, placedSpaceItems, placedMapItems, memoryMapColumn);\n    }\n    else\n    {\n        createFullConnectionFromLinks(roots, placedSpaceItems, placedMapItems, memoryMapColumn);\n    }\n\n    if (placedSpaceItems->isEmpty())\n    {\n        return QVector<MemoryConnectionItem*>();\n    }\n\n    QVector<MemoryConnectionItem*> connections;\n\n    auto separatedPathSets = separateBrokenPathSet(placedSpaceItems);\n    for (auto pathSet : separatedPathSets)\n    {\n        auto highestItemInSet = pathSet->connectedSpaces_->first();\n        highestItemInSet = getHighestPlacedItemInSet(highestItemInSet, pathSet->connectedSpaces_);\n        highestItemInSet = getHighestPlacedItemInSet(highestItemInSet, pathSet->connectedMaps_);\n\n        auto yMovement = spaceYPlacement - highestItemInSet->scenePos().y();\n\n        // Move entire group of connections to sensible vertical position.\n        // Round movement up to integer, but std::ceil instead of qCeil to preserve type.\n        highestItemInSet->moveItemAndConnectedItems(std::ceil(yMovement));\n\n        for (auto compressedConnection : compressConnectedMemoryItems(pathSet->connectedSpaces_, pathSet->connectedMaps_))\n        {\n            connections.append(compressedConnection);\n        }\n\n        spaceYPlacement = highestItemInSet->getLowestPointOfConnectedItems() + MemoryDesignerConstants::SPACEITEMINTERVAL;\n    }\n\n    return connections;\n}\n\n//-----------------------------------------------------------------------------\n// Function: MemoryConnectionHandler::createLinkedItemsForPath()\n//-----------------------------------------------------------------------------\nvoid MemoryConnectionHandler::createLinkedItemsForPath(\n    QSharedPointer<QVector<MainMemoryGraphicsItem*> > placedItems,\n    QSharedPointer<QVector<QSharedPointer<LinkedGraphicItem> > > roots,\n    MemoryColumn* spaceColumn,\n    MemoryColumn* mapColumn,\n    const Path& connectionPath)\n{\n    //! Possible address changes due to mirrored target interfaces.\n    QString remapValue = \"\";\n    QString remapRange = \"\";\n\n    //! Base addresses for the left and right side of the connection.\n    quint64 leftBaseAddress = 0;\n    quint64 rightBaseAddress = 0;\n\n    //! Cumulative base address for the connections.\n    quint64 connectionBaseAddress = 0;\n\n    //! Amount the connection will be moved in relation to the connection start item.\n    qreal connectedItemTransferY = 0;\n\n    QSharedPointer<LinkedGraphicItem> previousItem = nullptr;\n    QSharedPointer<const ConnectivityInterface> previousInterface = nullptr;\n\n    for (auto const pathInterface : connectionPath)\n    {\n        if (General::InterfaceMode interfaceMode = pathInterface->getMode();\n            (interfaceMode == General::MIRRORED_SLAVE || interfaceMode == General::MIRRORED_TARGET) && !pathInterface->getRemapAddress().isEmpty() && !pathInterface->getRemapRange().isEmpty())\n        {\n            remapValue = pathInterface->getRemapAddress();\n            remapRange = pathInterface->getRemapRange();\n        }\n        //! Initiator and target interfaces must be connected to a memory item for some change to happen with the address calculation.\n        else if (pathInterface->isConnectedToMemory())\n        {\n            //! A path with a connection to itself is a connection to a local memory map.\n            if (previousInterface == pathInterface)\n            {\n                createLocalLinkedItem(previousItem, pathInterface, placedItems, mapColumn);\n                continue;\n            }\n\n            //! If this is reached, there is a connection to be made to an address space (initiator) or memory map (target).\n            if (interfaceMode == General::MASTER || interfaceMode == General::INITIATOR ||\n                interfaceMode == General::SLAVE || interfaceMode == General::TARGET)\n            {\n                auto pathGraphicsItem = getPathGraphicsItem(pathInterface);\n                if (pathGraphicsItem == nullptr)\n                {\n                    continue;\n                }\n\n                if (pathGraphicsItem->isVisible() == false)\n                {\n                    pathGraphicsItem->setVisible(true);\n                }\n\n                //! Base address of the item is calculated because an item (especially memory map) can have a base address different from 0.\n                //! Remap value changes this item base address.\n                quint64 itemBaseAddress = pathGraphicsItem->getOriginalBaseAddress();\n\n                //! Connection is made to the full item, unless a remap range is given.\n                quint64 connectionSize = pathGraphicsItem->getOriginalLastAddress() - itemBaseAddress + 1;\n                if (remapRange.isEmpty() == false)\n                {\n                    connectionSize = remapRange.toULongLong();\n                }\n                else if (leftBaseAddress != rightBaseAddress)\n                {\n                    if (rightBaseAddress >= connectionSize + leftBaseAddress)\n                    {\n                        //! Currently a negative connection that is out of bound for the connected item is ignored.\n                        return;\n                    }\n                    else\n                    {\n                        connectionSize = connectionSize - (rightBaseAddress - leftBaseAddress);\n                    }\n                }\n                if (remapValue.isEmpty() == false)\n                {\n                    itemBaseAddress = remapValue.toULongLong();\n                }\n\n                leftBaseAddress += itemBaseAddress;\n                rightBaseAddress += itemBaseAddress;\n\n                connectionBaseAddress += itemBaseAddress;\n\n                qreal connectionTransfer = connectionBaseAddress * MemoryDesignerConstants::RANGEINTERVAL;\n\n                QSharedPointer<LinkedGraphicItem> currentLinkedItem = nullptr;\n\n                //! An address space connection is created to an initiator interface.\n                //! The base address of the interface must be added to the cumulative base address calculation.\n                //! The connection base address is set to begin from the base address of the interface.\n                if (interfaceMode == General::MASTER || interfaceMode == General::INITIATOR)\n                {\n                    currentLinkedItem = findOrCreateLinkedItem(\n                        placedItems, roots,\n                        previousItem, pathGraphicsItem,\n                        leftBaseAddress, rightBaseAddress, connectionSize,\n                        connectedItemTransferY, connectionTransfer,\n                        spaceColumn);\n\n                    auto interfaceBaseAddress = pathInterface->getBaseAddress().toLongLong();\n                    if (interfaceBaseAddress < 0)\n                    {\n                        connectionBaseAddress = 0;\n                        rightBaseAddress = leftBaseAddress + abs(interfaceBaseAddress);\n                        connectedItemTransferY = interfaceBaseAddress * MemoryDesignerConstants::RANGEINTERVAL;\n                    }\n                    else\n                    {\n                        connectionBaseAddress = interfaceBaseAddress;\n                        leftBaseAddress += interfaceBaseAddress;\n                        rightBaseAddress = leftBaseAddress;\n                        connectedItemTransferY = 0;\n                    }\n\n                }\n                //! A memory map connection is created to a target interface.\n                else if ((interfaceMode == General::TARGET || interfaceMode == General::SLAVE) && pathInterface == connectionPath.last())\n                {\n                    currentLinkedItem = findOrCreateLinkedItem(placedItems, roots, previousItem, pathGraphicsItem, leftBaseAddress, rightBaseAddress, connectionSize, connectedItemTransferY, connectionTransfer, mapColumn);\n                }\n\n                //! After the connection, the effects of the remap address and remap range are done and can be cleared.\n                remapValue.clear();\n                remapRange.clear();\n\n                if (currentLinkedItem != nullptr)\n                {\n                    previousItem = currentLinkedItem;\n                }\n            }\n        }\n\n        previousInterface = pathInterface;\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: MemoryConnectionHandler::createLocalLinkedItem()\n//-----------------------------------------------------------------------------\nvoid MemoryConnectionHandler::createLocalLinkedItem(\n    QSharedPointer<LinkedGraphicItem> previousItem,\n    QSharedPointer<ConnectivityInterface const> localMapInterface,\n    QSharedPointer<QVector<MainMemoryGraphicsItem *>> placedItems,\n    MemoryColumn* mapColumn)\n{\n    auto localMapGraphicsItem = getLocalMemoryMapItem(localMapInterface);\n    if (localMapGraphicsItem->isVisible() == false)\n    {\n        localMapGraphicsItem->setVisible(true);\n    }\n\n    quint64 mapBaseAddress = localMapGraphicsItem->getOriginalBaseAddress();\n    quint64 mapRange = localMapGraphicsItem->getOriginalLastAddress() - localMapGraphicsItem->getOriginalBaseAddress() + 1;\n\n    qreal yTransfer = mapBaseAddress * MemoryDesignerConstants::RANGEINTERVAL;\n\n    createLinkedItem(previousItem->children_, localMapGraphicsItem, mapBaseAddress, mapBaseAddress, mapRange, 0, yTransfer, placedItems, mapColumn);\n}\n\n//-----------------------------------------------------------------------------\n// Function: MemoryConnectionHandler::findOrCreateLinkedItem()\n//-----------------------------------------------------------------------------\nQSharedPointer<MemoryConnectionHandler::LinkedGraphicItem> MemoryConnectionHandler::findOrCreateLinkedItem(\n    QSharedPointer<QVector<MainMemoryGraphicsItem *>> placedItems, QSharedPointer<QVector<QSharedPointer<LinkedGraphicItem>>> roots,\n    QSharedPointer<LinkedGraphicItem> previousItem, MainMemoryGraphicsItem* pathGraphicsItem,\n    quint64 const& connectionLeftBaseAddress, quint64 const& connectionRightBaseAddress, quint64 const& connectionRange,\n    qreal const& itemTransferY, qreal const& connectionTransferY,\n    MemoryColumn* itemColumn)\n{\n    auto itemSet = roots;\n    if (previousItem != nullptr)\n    {\n        itemSet = previousItem->children_;\n    }\n\n    for (auto linkedItem : *itemSet)\n    {\n        if (foundLinkedItem(linkedItem, pathGraphicsItem, connectionLeftBaseAddress, connectionRightBaseAddress))\n        {\n            if (linkedItem->connectionRanges_.contains(connectionRange) == false)\n            {\n                linkedItem->connectionRanges_.append(connectionRange);\n            }\n\n            return linkedItem;\n        }\n    }\n\n    return createLinkedItem(itemSet, pathGraphicsItem, connectionLeftBaseAddress, connectionRightBaseAddress, connectionRange, itemTransferY, connectionTransferY, placedItems, itemColumn);\n}\n\n//-----------------------------------------------------------------------------\n// Function: MemoryConnectionHandler::foundLinkedItem()\n//-----------------------------------------------------------------------------\nbool MemoryConnectionHandler::foundLinkedItem(QSharedPointer<LinkedGraphicItem> linkedItem, MainMemoryGraphicsItem* pathGraphicsItem, quint64 const& connectionLeftBaseAddress, quint64 const& connectionRightBaseAddress) const\n{\n    if (linkedItem->item_ && linkedItem->connectionLeftBaseAddress_ == connectionLeftBaseAddress && linkedItem->connectionRightBaseAddress_ == connectionRightBaseAddress)\n    {\n        if (linkedItem->item_ == pathGraphicsItem ||\n            (linkedItem->item_->name() == pathGraphicsItem->name() && linkedItem->item_->getContainingInstance() == pathGraphicsItem->getContainingInstance()))\n        {\n            return true;\n        }\n    }\n\n    return false;\n}\n\n//-----------------------------------------------------------------------------\n// Function: MemoryConnectionHandler::createLinkedItem()\n//-----------------------------------------------------------------------------\nQSharedPointer<MemoryConnectionHandler::LinkedGraphicItem> MemoryConnectionHandler::createLinkedItem(\n    QSharedPointer<QVector<QSharedPointer<LinkedGraphicItem>>> containingSet,\n    MainMemoryGraphicsItem* pathGraphicsItem,\n    quint64 const& connectionLeftBaseAddress,\n    quint64 const& connectionRightBaseAddress,\n    quint64 const& connectionRange,\n    qreal const& connectedItemTransferY,\n    qreal const& connectionTransferY,\n    QSharedPointer<QVector<MainMemoryGraphicsItem *>> placedItems,\n    MemoryColumn* itemColumn)\n{\n    QSharedPointer<LinkedGraphicItem> newLinkedItem(new LinkedGraphicItem());\n    newLinkedItem->connectionLeftBaseAddress_ = connectionLeftBaseAddress;\n    newLinkedItem->connectionRightBaseAddress_ = connectionRightBaseAddress;\n    newLinkedItem->connectionRanges_.append(connectionRange);\n    newLinkedItem->memoryItemTransferY_ = connectedItemTransferY;\n    newLinkedItem->connectionTransferY_ = connectionTransferY;\n\n    if (placedItems->contains(pathGraphicsItem))\n    {\n        pathGraphicsItem = itemHandler_->cloneMemoryItem(pathGraphicsItem, itemColumn);\n    }\n    \n    newLinkedItem->item_ = pathGraphicsItem;\n    placedItems->append(pathGraphicsItem);\n    containingSet->append(newLinkedItem);\n    return newLinkedItem;\n}\n\n//-----------------------------------------------------------------------------\n// Function: MemoryConnectionHandler::separateBrokenPathSet()\n//-----------------------------------------------------------------------------\nQVector<QSharedPointer<MemoryConnectionHandler::ConnectedItemSet> > MemoryConnectionHandler::separateBrokenPathSet(QSharedPointer<QVector<MainMemoryGraphicsItem*> > placedSpaceItems) const\n{\n    QVector<QSharedPointer<MemoryConnectionHandler::ConnectedItemSet> > itemSets;\n\n    QVector<MainMemoryGraphicsItem*> remainingSpaces;\n    for (auto spaceItem : *placedSpaceItems)\n    {\n        remainingSpaces.append(spaceItem);\n    }\n\n    QSharedPointer<QVector<MainMemoryGraphicsItem*> > visitedItems(new QVector<MainMemoryGraphicsItem*>());\n\n    while (remainingSpaces.isEmpty() == false)\n    {\n        auto spaceItem = remainingSpaces.takeFirst();\n        if (visitedItems->contains(spaceItem) == false)\n        {\n            auto connectedItemSet = getConnectedItemsForSpaceItem(spaceItem, visitedItems);\n            itemSets.append(connectedItemSet);\n        }\n    }\n\n    return itemSets;\n}\n\n//-----------------------------------------------------------------------------\n// Function: MemoryConnectionHandler::getConnectedItemsForSpaceItem()\n//-----------------------------------------------------------------------------\nQSharedPointer<MemoryConnectionHandler::ConnectedItemSet> MemoryConnectionHandler::getConnectedItemsForSpaceItem(MainMemoryGraphicsItem* spaceItem, QSharedPointer<QVector<MainMemoryGraphicsItem *>> visitedItems) const\n{\n    QSharedPointer<QVector<MainMemoryGraphicsItem*> > connectedSpaces(new QVector<MainMemoryGraphicsItem*>());\n    QSharedPointer<QVector<MainMemoryGraphicsItem*> > connectedMaps(new QVector<MainMemoryGraphicsItem*>());\n\n    QVector<MainMemoryGraphicsItem*> itemsConnectedToSpace;\n    getConnectedItems(spaceItem, itemsConnectedToSpace, visitedItems);\n    for (auto connectedItem : itemsConnectedToSpace)\n    {\n        if (connectedItem->type() == GraphicsItemTypes::GFX_TYPE_ADDRESS_SPACE_ITEM)\n        {\n            connectedSpaces->append(connectedItem);\n        }\n        else\n        {\n            connectedMaps->append(connectedItem);\n        }\n    }\n\n    QSharedPointer<MemoryConnectionHandler::ConnectedItemSet> combinedConnectedItems(new MemoryConnectionHandler::ConnectedItemSet());\n    combinedConnectedItems->connectedSpaces_ = connectedSpaces;\n    combinedConnectedItems->connectedMaps_ = connectedMaps;\n\n    return combinedConnectedItems;\n}\n\n//-----------------------------------------------------------------------------\n// Function: MemoryConnectionHandler::getConnectedItems()\n//-----------------------------------------------------------------------------\nvoid MemoryConnectionHandler::getConnectedItems(MainMemoryGraphicsItem* memoryItem, QVector<MainMemoryGraphicsItem*>& itemsConnectedToItem, QSharedPointer<QVector<MainMemoryGraphicsItem *>> visitedItems) const\n{\n    visitedItems->append(memoryItem);\n    itemsConnectedToItem.append(memoryItem);\n    QVector<MainMemoryGraphicsItem*> connectedItems;\n\n    auto connections = memoryItem->getMemoryConnections();\n    for (auto iterator = connections.cbegin(), end = connections.cend(); iterator != end; ++iterator)\n    {\n        auto currentConnection = iterator.value();\n\n        if (auto connectionStartItem = currentConnection->getConnectionStartItem(); visitedItems->contains(connectionStartItem) == false)\n        {\n            getConnectedItems(connectionStartItem, itemsConnectedToItem, visitedItems);\n        }\n        if (auto connectionEndItem = currentConnection->getConnectionEndItem(); visitedItems->contains(connectionEndItem) == false)\n        {\n            getConnectedItems(connectionEndItem, itemsConnectedToItem, visitedItems);\n        }\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: MemoryConnectionHandler::connectionExists()\n//-----------------------------------------------------------------------------\nbool MemoryConnectionHandler::connectionExists(MainMemoryGraphicsItem* startItem, MainMemoryGraphicsItem* endItem, quint64 const& connectionBaseAddress, quint64 const& connectionEndAddress) const\n{\n    QMultiMapIterator connectionIterator(startItem->getMemoryConnections());\n    while (connectionIterator.hasNext())\n    {\n        connectionIterator.next();\n        if (connectionIterator.key() > connectionBaseAddress)\n        {\n            return false;\n        }\n\n        if (connectionIterator.key() == connectionBaseAddress &&\n            connectionIterator.value()->getConnectionEndItem() == endItem && connectionIterator.value()->getRangeEndValue() == connectionEndAddress)\n        {\n            return true;\n        }\n    }\n\n    return false;\n}\n\n//-----------------------------------------------------------------------------\n// Function: MemoryConnectionHandler::moveStartItemNotEndItem()\n//-----------------------------------------------------------------------------\nbool MemoryConnectionHandler::moveStartItemNotEndItem(MainMemoryGraphicsItem const* endItem,\n    quint64 const& connectionBaseAddress) const\n{\n    return endItem->getMemoryConnections().isEmpty() == false && endItem->getBaseAddress() == connectionBaseAddress;\n}\n\n//-----------------------------------------------------------------------------\n// Function: MemoryConnectionHandler::createOnlyEndsConnectionFromLinks()\n//-----------------------------------------------------------------------------\nvoid MemoryConnectionHandler::createOnlyEndsConnectionFromLinks(\n    QSharedPointer<QVector<QSharedPointer<LinkedGraphicItem>>> roots,\n    QSharedPointer<QVector<MainMemoryGraphicsItem *>> placedSpaces,\n    QSharedPointer<QVector<MainMemoryGraphicsItem *>> placedMaps,\n    MemoryColumn* mapColumn)\n{\n    for (auto currentRoot : *roots)\n    {\n        if (currentRoot->item_ == nullptr)\n        {\n            continue;\n        }\n\n        auto maximumRange = *std::max_element(currentRoot->connectionRanges_.begin(), currentRoot->connectionRanges_.end());\n\n        auto leftLastAddress = currentRoot->connectionLeftBaseAddress_ + maximumRange - 1;\n\n        createOnlyEndsConnectionsForRoot(currentRoot, currentRoot, placedSpaces, placedMaps, mapColumn, currentRoot->connectionLeftBaseAddress_, 0, leftLastAddress);\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: MemoryConnectionHandler::createOnlyEndsConnectionsForRoot()\n//-----------------------------------------------------------------------------\nvoid MemoryConnectionHandler::createOnlyEndsConnectionsForRoot(QSharedPointer<LinkedGraphicItem> root,\n    QSharedPointer<LinkedGraphicItem> currentLinkItem,\n    QSharedPointer<QVector<MainMemoryGraphicsItem *>> placedSpaces,\n    QSharedPointer<QVector<MainMemoryGraphicsItem *>> placedMaps,\n    MemoryColumn* mapColumn,\n    quint64 const& maximumLeftBaseAddress,\n    quint64 const& rightBaseAddressChange,\n    quint64 const& minimumLeftLastAddress)\n{\n    auto newRightBaseAddressChange = rightBaseAddressChange;\n\n    //! Not in leaf\n    if (currentLinkItem->children_->isEmpty() == false)\n    {\n        for (auto childItem : *currentLinkItem->children_)\n        {\n            //! Ignore connections that are beyond the root item.\n            if (childItem->connectionLeftBaseAddress_ > currentLinkItem->item_->getOriginalLastAddress() + maximumLeftBaseAddress)\n            {\n                continue;\n            }\n\n            auto childItemMaximumLeftBaseAddress = maximumLeftBaseAddress;\n\n            quint64 baseAddressDifference = 0;\n            quint64 childRightBaseAddressChange = 0;\n            quint64 availableRange = 0;\n\n            //! Create only the largest available connection\n            auto maximumChildItemRange = *std::max_element(childItem->connectionRanges_.begin(), childItem->connectionRanges_.end());\n            if (maximumChildItemRange < 1)\n            {\n                continue;\n            }\n\n            //! If the connected item is connected to another item and this new connection is in different base address\n            if (childItem->connectionLeftBaseAddress_ > currentLinkItem->connectionRightBaseAddress_)\n            {\n                //! Change the connection left base address\n                baseAddressDifference = childItem->connectionLeftBaseAddress_ - currentLinkItem->connectionRightBaseAddress_;\n                childItemMaximumLeftBaseAddress += baseAddressDifference;\n            }\n            else if (currentLinkItem->connectionRightBaseAddress_ > childItem->connectionLeftBaseAddress_)\n            {\n                //! Change the connection right base address\n                baseAddressDifference = currentLinkItem->connectionRightBaseAddress_ - childItem->connectionLeftBaseAddress_;\n                childRightBaseAddressChange = baseAddressDifference;\n            }\n\n            //! If the right base address change is beyond the connection area, discard and continue to the next connected item.\n            if (childRightBaseAddressChange > childItemMaximumLeftBaseAddress + maximumChildItemRange - 1)\n            {\n                continue;\n            }\n\n            auto childItemMinimumLeftLastAddress = childItemMaximumLeftBaseAddress + maximumChildItemRange - 1 - childRightBaseAddressChange;\n            childItemMinimumLeftLastAddress = qMin(childItemMinimumLeftLastAddress, minimumLeftLastAddress);\n\n            if (childItemMaximumLeftBaseAddress > childItemMinimumLeftLastAddress)\n            {\n                continue;\n            }\n            \n            //! Continue along to the next item\n            createOnlyEndsConnectionsForRoot(\n                root, childItem,\n                placedSpaces, placedMaps,\n                mapColumn,\n                childItemMaximumLeftBaseAddress, newRightBaseAddressChange + childRightBaseAddressChange, childItemMinimumLeftLastAddress);\n        }\n    }\n    //! In leaf\n    else if (currentLinkItem->item_->type() == GFX_TYPE_MEMORY_ITEM)\n    {\n        //! A connection can be created between a root item and a memory item at the end of the connection path.\n        if (root->item_->type() == GFX_TYPE_ADDRESS_SPACE_ITEM && placedSpaces->contains(root->item_) == false)\n        {\n            placedSpaces->append(root->item_);\n        }\n\n        auto newConnectionTransferY = maximumLeftBaseAddress * MemoryDesignerConstants::RANGEINTERVAL;\n        auto minimumRange = minimumLeftLastAddress - maximumLeftBaseAddress + 1;\n\n        auto newMaximumRightBaseAddress = currentLinkItem->connectionRightBaseAddress_ + newRightBaseAddressChange;\n        auto itemTransfer = newConnectionTransferY - (newMaximumRightBaseAddress - currentLinkItem->connectionLeftBaseAddress_) * MemoryDesignerConstants::RANGEINTERVAL;\n\n        placeMemoryMap(currentLinkItem->item_, root->item_, itemTransfer, placedMaps, mapColumn);\n\n        placedMaps->append(currentLinkItem->item_);\n\n        createConnectionItem(root->item_, currentLinkItem->item_, maximumLeftBaseAddress, newMaximumRightBaseAddress, currentLinkItem->connectionLeftBaseAddress_, minimumRange, newConnectionTransferY);\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: MemoryConnectionHandler::createFullConnectionFromLinks()\n//-----------------------------------------------------------------------------\nvoid MemoryConnectionHandler::createFullConnectionFromLinks(\n    QSharedPointer<QVector<QSharedPointer<LinkedGraphicItem>>> roots,\n    QSharedPointer<QVector<MainMemoryGraphicsItem *>> placedSpaces,\n    QSharedPointer<QVector<MainMemoryGraphicsItem *>> placedMaps,\n    MemoryColumn* mapColumn)\n{\n    for (auto currentRoot : *roots)\n    {\n        if (currentRoot->item_ == nullptr)\n        {\n            continue;\n        }\n        else if (currentRoot->item_->type() == GFX_TYPE_ADDRESS_SPACE_ITEM)\n        {\n            placedSpaces->append(currentRoot->item_);\n        }\n\n        createConnectionsForLinkedItem(currentRoot, placedSpaces, placedMaps, mapColumn);\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: MemoryConnectionHandler::createConnectionsForLinkedItem()\n//-----------------------------------------------------------------------------\nvoid MemoryConnectionHandler::createConnectionsForLinkedItem(\n    QSharedPointer<LinkedGraphicItem> linkedItem,\n    QSharedPointer<QVector<MainMemoryGraphicsItem *>> placedSpaces,\n    QSharedPointer<QVector<MainMemoryGraphicsItem *>> placedMaps,\n    MemoryColumn* mapColumn)\n{\n    for (auto child : *linkedItem->children_)\n    {\n        MainMemoryGraphicsItem* childItem = child->item_;\n\n        qreal itemTransferY = child->memoryItemTransferY_ + child->connectionTransferY_;\n\n        if (childItem->type() == GFX_TYPE_ADDRESS_SPACE_ITEM)\n        {\n            placeAddressSpace(childItem, linkedItem->item_, itemTransferY, placedSpaces);\n        }\n        else\n        {\n            placeMemoryMap(childItem, linkedItem->item_, itemTransferY, placedMaps, mapColumn);\n            placedMaps->append(child->item_);\n        }\n\n        for (auto connectionRange : child->connectionRanges_)\n        {\n            createConnectionItem(linkedItem->item_, childItem,\n                child->connectionLeftBaseAddress_, child->connectionRightBaseAddress_, child->connectionLeftBaseAddress_, connectionRange,\n                child->connectionTransferY_);\n        }\n\n        createConnectionsForLinkedItem(child, placedSpaces, placedMaps, mapColumn);\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: MemoryConnectionHandler::getPathGraphicsItem()\n//-----------------------------------------------------------------------------\nMainMemoryGraphicsItem* MemoryConnectionHandler::getPathGraphicsItem(QSharedPointer<const ConnectivityInterface> pathInterface) const\n{\n    if (!pathInterface)\n    {\n        return nullptr;\n    }\n\n    QString columnType = \"\";\n    if (QSharedPointer<MemoryItem const> memoryItem = pathInterface->getConnectedMemory(); memoryItem->getType() == MemoryDesignerConstants::ADDRESSSPACE_TYPE)\n    {\n        columnType = MemoryDesignerConstants::ADDRESSSPACECOLUMN_NAME;\n    }\n    else if (memoryItem->getType() == MemoryDesignerConstants::MEMORYMAP_TYPE)\n    {\n        columnType = MemoryDesignerConstants::MEMORYMAPCOLUMNCOMMON_NAME;\n    }\n\n    MainMemoryGraphicsItem* graphicsItem = nullptr;\n    if (!columnType.isEmpty())\n    {\n        graphicsItem = getMainGraphicsItem(pathInterface, columnType);\n    }\n\n    return graphicsItem;\n}\n\n//-----------------------------------------------------------------------------\n// Function: MemoryConnectionHandler::getMainGraphicsItem()\n//-----------------------------------------------------------------------------\nMainMemoryGraphicsItem* MemoryConnectionHandler::getMainGraphicsItem(\n    QSharedPointer<ConnectivityInterface const> connectionInterface, QString const& columnType) const\n{\n    MainMemoryGraphicsItem* graphicsItem = nullptr;\n\n    QSharedPointer<MemoryItem const> memoryItem = connectionInterface->getConnectedMemory();\n    if (QSharedPointer<ConnectivityComponent const> connectionInstance = connectionInterface->getInstance(); memoryItem && connectionInstance)\n    {\n        for (auto currentColumn : columnHandler_->getSpecifiedColumns(columnType))\n        {\n            graphicsItem = currentColumn->findGraphicsItemByMemoryItem(memoryItem);\n            if (graphicsItem)\n            {\n                break;\n            }\n        }\n    }\n\n    return graphicsItem;\n}\n\n//-----------------------------------------------------------------------------\n// Function: MemoryConnectionHandler::getFirstInitiatorInterface()\n//-----------------------------------------------------------------------------\nQSharedPointer<ConnectivityInterface const> MemoryConnectionHandler::getFirstInitiatorInterface(QVector<QSharedPointer<ConnectivityInterface const> > connectionPath) const\n{\n    for (auto pathInterface : connectionPath)\n    {\n        if ((pathInterface->getMode() == General::MASTER || pathInterface->getMode() == General::INITIATOR) && pathInterface->getConnectedMemory())\n        {\n            return pathInterface;\n        }\n    }\n\n    return nullptr;\n}\n\n//-----------------------------------------------------------------------------\n// Function: MemoryConnectionHandler::getConnectionEndItem()\n//-----------------------------------------------------------------------------\nMainMemoryGraphicsItem* MemoryConnectionHandler::getConnectionEndItem(\n    QSharedPointer<ConnectivityInterface const> startInterface,\n    QSharedPointer<ConnectivityInterface const> endInterface) const\n{\n    MainMemoryGraphicsItem* connectionEndItem(nullptr);\n\n    if (startInterface == endInterface)\n    {\n        connectionEndItem = getLocalMemoryMapItem(endInterface);\n    }\n    else\n    {\n        connectionEndItem =\n            getMainGraphicsItem(endInterface, MemoryDesignerConstants::MEMORYMAPCOLUMNCOMMON_NAME);\n    }\n\n    return connectionEndItem;\n}\n\n//-----------------------------------------------------------------------------\n// Function: MemoryConnectionHandler::getLocalMemoryMapItem()\n//-----------------------------------------------------------------------------\nMainMemoryGraphicsItem* MemoryConnectionHandler::getLocalMemoryMapItem(\n    QSharedPointer<ConnectivityInterface const> spaceInterface) const\n{\n    MainMemoryGraphicsItem* localMapItem = nullptr;\n\n    if (auto memoryItemForLocalMap = MemoryDesignerConstants::getMemoryItemForLocalMap(spaceInterface); memoryItemForLocalMap)\n    {\n        for (MemoryColumn * currentColumn : columnHandler_->getSpecifiedColumns(MemoryDesignerConstants::MEMORYMAPCOLUMNCOMMON_NAME))\n        {\n            localMapItem = currentColumn->findGraphicsItemByMemoryItem(memoryItemForLocalMap);\n            if (localMapItem)\n            {\n                break;\n            }\n        }\n    }\n\n    return localMapItem;\n}\n\n//-----------------------------------------------------------------------------\n// Function: MemoryConnectionHandler::placeAddressSpace()\n//-----------------------------------------------------------------------------\nvoid MemoryConnectionHandler::placeAddressSpace(MainMemoryGraphicsItem* spaceItem, MainMemoryGraphicsItem* startItem, qreal const& yTransfer, QSharedPointer<QVector<MainMemoryGraphicsItem *>> placedSpaces)\n{\n    auto originalColumn = dynamic_cast<MemoryColumn*>(spaceItem->parentItem());\n    if (!originalColumn)\n    {\n        return;\n    }\n\n    auto completeTransferValue = yTransfer + startItem->scenePos().y();\n\n    positionSpaceItem(spaceItem, completeTransferValue);\n\n    originalColumn->removeItem(spaceItem);\n\n    auto spaceColumns = columnHandler_->getAddressSpaceColumns();\n    auto newColumnIndex = spaceColumns.indexOf(originalColumn) + 1;\n    if (newColumnIndex < spaceColumns.size())\n    {\n        auto indexedColumn = spaceColumns.at(newColumnIndex);\n        indexedColumn->addItem(spaceItem);\n        if (itemCollidesWithOtherPlacedItems(spaceItem, placedSpaces))\n        {\n            placeCompressedSpaceToColumn(spaceItem, placedSpaces);\n        }\n    }\n    else\n    {\n        MemoryColumn* newSpaceColumn = columnHandler_->createAddressSpaceColumn();\n        newSpaceColumn->addItem(spaceItem);\n    }\n\n    placedSpaces->append(spaceItem);\n}\n\n//-----------------------------------------------------------------------------\n// Function: MemoryConnectionHandler::placeMemoryMap()\n//-----------------------------------------------------------------------------\nvoid MemoryConnectionHandler::placeMemoryMap(MainMemoryGraphicsItem* mapItem,\n    MainMemoryGraphicsItem* startItem,\n    qreal const& yTransfer,\n    QSharedPointer<QVector<MainMemoryGraphicsItem *>> placedMapItems,\n    MemoryColumn* mapColumn)\n{\n    mapItem->setY(startItem->pos().y() + yTransfer);\n\n    if (!placedMapItems->isEmpty())\n    {\n        checkMemoryMapRepositionToOverlapColumn(placedMapItems, mapItem, mapColumn, startItem);\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: MemoryConnectionHandler::checkMemoryMapRepositionToOverlapColumn()\n//-----------------------------------------------------------------------------\nvoid MemoryConnectionHandler::checkMemoryMapRepositionToOverlapColumn(\n    QSharedPointer<QVector<MainMemoryGraphicsItem*> > placedMaps,\n    MainMemoryGraphicsItem* memoryItem, MemoryColumn* originalColumn,\n    MainMemoryGraphicsItem* connectionStartItem)\n{\n    QRectF selectedItemRect = memoryItem->getSceneRectangleWithSubItems();\n\n    int selectedItemPenWidth = memoryItem->pen().width();\n\n    QVector<MainMemoryGraphicsItem*> connectedSpaceItems;\n    connectedSpaceItems.append(connectionStartItem);\n    for (MainMemoryGraphicsItem * chainedSpaceItem : connectionStartItem->getChainedSpaceItems())\n    {\n        connectedSpaceItems.append(chainedSpaceItem);\n    }\n\n    if (originalColumn->memoryMapOverlapsInColumn(memoryItem, selectedItemRect, selectedItemPenWidth, connectedSpaceItems, placedMaps))\n    {\n        for (MemoryColumn * memoryColumn : columnHandler_->getMapOverlapColumns())\n        {\n            selectedItemRect.setX(selectedItemRect.x() + memoryColumn->boundingRect().width());\n\n            if (!memoryColumn->memoryMapOverlapsInColumn(memoryItem, selectedItemRect, selectedItemPenWidth, connectedSpaceItems, placedMaps))\n            {\n                originalColumn->removeItem(memoryItem);\n                memoryColumn->addItem(memoryItem);\n                return;\n            }\n        }\n\n        auto overlapColumn = columnHandler_->createMemoryOverlapColumn();\n        originalColumn->removeItem(memoryItem);\n        overlapColumn->addItem(memoryItem);\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: MemoryConnectionHandler::positionSpaceItem()\n//-----------------------------------------------------------------------------\nvoid MemoryConnectionHandler::positionSpaceItem(MainMemoryGraphicsItem* spaceItem, qreal ypos)\n{\n    spaceItem->setY(ypos);\n}\n\n//-----------------------------------------------------------------------------\n// Function: MemoryConnectionHandler::createConnectionItem()\n//-----------------------------------------------------------------------------\nvoid MemoryConnectionHandler::createConnectionItem(MainMemoryGraphicsItem* startItem, MainMemoryGraphicsItem* endItem,\n    quint64 const& leftBaseAddress, quint64 const& rightBaseAddress, quint64 const& endItemBaseAddress,\n    quint64 const& connectionRange,\n    qreal const& yTransfer)\n{\n    changeConnectionEndItemRanges(endItem, endItemBaseAddress);\n\n    quint64 leftEndAddress = leftBaseAddress + connectionRange - 1;\n    quint64 rightEndAddress = rightBaseAddress + connectionRange - 1;\n\n    auto newConnectionItem = new MemoryConnectionItem(startItem, leftBaseAddress, leftEndAddress, rightBaseAddress, rightEndAddress, endItem, startItem->scene(), yTransfer);\n    connectionsToMemoryMaps_.append(newConnectionItem);\n\n//     startItem->hideCollidingRangeLabels(remappedAddress, remappedEndAddress);\n//     endItem->hideCollidingRangeLabels(remappedAddress, remappedEndAddress);\n}\n\n//-----------------------------------------------------------------------------\n// Function: MemoryConnectionHandler::changeConnectionEndItemRanges()\n//-----------------------------------------------------------------------------\nvoid MemoryConnectionHandler::changeConnectionEndItemRanges(MainMemoryGraphicsItem* connectionEndItem,\n    quint64 const& remappedAddress) const\n{\n    connectionEndItem->changeAddress(remappedAddress);\n}\n\n//-----------------------------------------------------------------------------\n// Function: MemoryConnectionHandler::getHighestPlacedItemInSet()\n//-----------------------------------------------------------------------------\nMainMemoryGraphicsItem* MemoryConnectionHandler::getHighestPlacedItemInSet(MainMemoryGraphicsItem* currentHighestItem, QSharedPointer<QVector<MainMemoryGraphicsItem*> > itemSet) const\n{\n    MainMemoryGraphicsItem* highestItem = currentHighestItem;\n    for (auto comparisonItem : *itemSet)\n    {\n        if (comparisonItem->scenePos().y() < highestItem->scenePos().y())\n        {\n            highestItem = comparisonItem;\n        }\n    }\n\n    return highestItem;\n}\n\n//-----------------------------------------------------------------------------\n// Function: MemoryConnectionHandler::compressConnectedMemoryItems()\n//-----------------------------------------------------------------------------\nQVector<MemoryConnectionItem*> MemoryConnectionHandler::compressConnectedMemoryItems(QSharedPointer<QVector<MainMemoryGraphicsItem*>> placedSpaceItems, QSharedPointer<QVector<MainMemoryGraphicsItem*>> placedMapItems) const\n{\n    MainMemoryGraphicsItem* masterItem = placedSpaceItems->first();\n    masterItem = getHighestPlacedItemInSet(masterItem, placedSpaceItems);\n    masterItem = getHighestPlacedItemInSet(masterItem, placedMapItems);\n\n    QVector<MainMemoryGraphicsItem*> visitedItems;\n    QVector<MemoryConnectionItem*> visitedConnections;\n    QVector<qreal> uncutCoordinates = masterItem->getUncutCoordinatesFromSet(visitedItems, visitedConnections);\n    std::sort(uncutCoordinates.begin(), uncutCoordinates.end());\n\n    visitedItems.clear();\n    for (auto connectionItem : visitedConnections)\n    {\n        connectionItem->compressToUnCutCoordinates(visitedItems, uncutCoordinates, MemoryDesignerConstants::CUTMODIFIER, condenseMemoryItems_);\n    }\n\n    QMap<qreal, qreal> areaMovements = calculateAreaMovements(uncutCoordinates, MemoryDesignerConstants::CUTMODIFIER);\n    for (auto memoryItem : visitedItems)\n    {\n        qreal movementY = -areaMovements.value(memoryItem->sceneBoundingRect().top());\n        memoryItem->moveBy(0, movementY);\n    }\n\n    for (auto connectionItem : visitedConnections)\n    {\n        qreal movementY = -areaMovements.value(connectionItem->sceneBoundingRect().top());\n        connectionItem->moveItemBy(movementY);\n    }\n\n    for (auto memoryItem : visitedItems)\n    {\n        memoryItem->extendMemoryItem();\n    }\n\n    return visitedConnections;\n}\n\n//-----------------------------------------------------------------------------\n// Function: MemoryConnectionHandler::calculateAreaMovements()\n//-----------------------------------------------------------------------------\nQMap<qreal, qreal> MemoryConnectionHandler::calculateAreaMovements(QVector<qreal> uncutCoordinates, qreal const& CUTMODIFIER) const\n{\n    QMap<qreal, qreal> areaMovements;\n\n    qreal areaTop = uncutCoordinates.takeFirst();\n    qreal areaBottom = areaTop;\n    qreal combinedTransferValue = 0;\n\n    while (!uncutCoordinates.isEmpty())\n    {\n        areaBottom = uncutCoordinates.takeFirst();\n        qreal singleCut = areaBottom - areaTop;\n        if (condenseMemoryItems_)\n        {\n            singleCut = singleCut - CUTMODIFIER;\n        }\n        else\n        {\n            qreal requiredArea = MemoryDesignerConstants::getRequiredAreaForUsedArea(singleCut);\n            singleCut = singleCut - requiredArea;\n        }\n\n        if (singleCut > 0)\n        {\n            combinedTransferValue += singleCut;\n        }\n\n        areaMovements.insert(areaBottom, combinedTransferValue);\n\n        areaTop = areaBottom;\n    }\n\n    return areaMovements;\n}\n\n//-----------------------------------------------------------------------------\n// Function: MemoryConnectionHandler::repositionCompressedAddressSpaces()\n//-----------------------------------------------------------------------------\nvoid MemoryConnectionHandler::repositionCompressedAddressSpaces(QSharedPointer<QVector<MainMemoryGraphicsItem*> > placedSpaceItems)\n{\n/*\n    auto spaceIter = std::next(placedSpaceItems->begin());\n    while (spaceIter != placedSpaceItems->end())\n    {\n        //auto spaceItem = spaceIterator.previous();\n        auto spaceItem = *spaceIter;\n        if (itemCollidesWithOtherPlacedItems(spaceItem, placedSpaceItems))\n        {\n            placeCompressedSpaceToColumn(spaceItem, placedSpaceItems);\n        }\n        spaceIter = std::next(spaceIter);\n    }\n*/\n}\n\n//-----------------------------------------------------------------------------\n// Function: MemoryConnectionHandler::itemCollidesWithOtherPlacedItems()\n//-----------------------------------------------------------------------------\nbool MemoryConnectionHandler::itemCollidesWithOtherPlacedItems(MainMemoryGraphicsItem const* memoryItem, QSharedPointer<QVector<MainMemoryGraphicsItem*> > placedItems) const\n{\n    for (auto collidingItem : memoryItem->collidingItems(Qt::IntersectsItemShape))\n    {\n        auto collidingMemoryItem = dynamic_cast<MainMemoryGraphicsItem*>(collidingItem);\n        auto collidingExtensionItem = dynamic_cast<MemoryExtensionGraphicsItem*>(collidingItem);\n        if ((collidingMemoryItem && placedItems->contains(collidingItem)) ||\n            (collidingExtensionItem && placedItems->contains(collidingExtensionItem->parentItem())))\n        {\n            return true;\n        }\n    }\n\n    return false;\n}\n\n//-----------------------------------------------------------------------------\n// Function: MemoryConnectionHandler::placeCompressedSpaceToColumn()\n//-----------------------------------------------------------------------------\nvoid MemoryConnectionHandler::placeCompressedSpaceToColumn(MainMemoryGraphicsItem* spaceItem, QSharedPointer<QVector<MainMemoryGraphicsItem *>> placedSpaceItems)\n{\n    auto originalColumn = dynamic_cast<MemoryColumn*>(spaceItem->parentItem());\n    if (!originalColumn)\n    {\n        return;\n    }\n\n    QRectF spaceRectangle = spaceItem->getSceneRectangleWithSubItems();\n    int spaceLineWidth = spaceItem->pen().width();\n    if (spaceItem->hasExtensionItem())\n    {\n        spaceRectangle.setHeight(spaceRectangle.height() + spaceItem->getExtensionItem()->boundingRect().height());\n    }\n\n    QVectorIterator<MemoryColumn*> columnIterator(columnHandler_->getAddressSpaceColumns());\n    while (columnIterator.hasNext())\n    {\n        MemoryColumn* comparisonColumn = columnIterator.next();\n        if (!comparisonColumn->itemOverlapsAnotherPlacedColumnItem(spaceItem, spaceRectangle, spaceLineWidth, placedSpaceItems))\n        {\n            if (originalColumn != comparisonColumn)\n            {\n                originalColumn->removeItem(spaceItem);\n                comparisonColumn->addItem(spaceItem);\n            }\n\n            return;\n        }\n    }\n\n    originalColumn->removeItem(spaceItem);\n    MemoryColumn* newSpaceColumn = columnHandler_->createAddressSpaceColumn();\n    newSpaceColumn->addItem(spaceItem);\n}\n\n//-----------------------------------------------------------------------------\n// Function: MemoryConnectionHandler::repositionCompressedMemoryMaps()\n//-----------------------------------------------------------------------------\nvoid MemoryConnectionHandler::repositionCompressedMemoryMaps(\n    QSharedPointer<QVector<MainMemoryGraphicsItem*> > placedMapItems, MemoryColumn const* memoryMapColumn)\n{\n    for (MainMemoryGraphicsItem * mapItem : *placedMapItems)\n    {\n        QGraphicsItem* mapParentItem = mapItem->parentItem();\n        MemoryColumn* originalColumn = dynamic_cast<MemoryColumn*>(mapParentItem);\n        if (originalColumn && originalColumn != memoryMapColumn)\n        {\n            QRectF mapRectangle = mapItem->sceneBoundingRect();\n            int mapPenWidth = mapItem->pen().width();\n\n            qreal itemHeight = mapRectangle.height();\n            qreal extensionHeight = 0;\n\n            if (mapItem->hasExtensionItem())\n            {\n                extensionHeight = mapItem->getExtensionItem()->boundingRect().height();\n            }\n\n            if (qreal subItemsHeight = mapItem->getSubItemHeightAddition(); subItemsHeight > extensionHeight)\n            {\n                extensionHeight = subItemsHeight;\n            }\n\n            mapRectangle.setHeight(itemHeight + extensionHeight);\n\n            QVector<MainMemoryGraphicsItem*> connectedSpaceItems = mapItem->getChainedSpaceItems();\n\n            int columnWidth = originalColumn->sceneBoundingRect().width();\n\n            QPointF columnPoint(originalColumn->pos().x() - columnWidth, mapRectangle.y());\n            MemoryColumn* comparisonColumn = columnHandler_->findColumnAtPosition(columnPoint);\n            if (comparisonColumn)\n            {\n                while (comparisonColumn && !comparisonColumn->name().contains(\n                    MemoryDesignerConstants::ADDRESSSPACECOLUMN_NAME, Qt::CaseInsensitive))\n                {\n                    mapRectangle.setX(mapRectangle.x() - columnWidth);\n\n                    if (!comparisonColumn->memoryMapOverlapsInColumn(mapItem, mapRectangle, mapPenWidth, connectedSpaceItems, placedMapItems))\n                    {\n                        originalColumn->removeItem(mapItem);\n                        comparisonColumn->addItem(mapItem, true);\n\n                        if (originalColumn->getItems().isEmpty() && originalColumn->name().contains(\n                            MemoryDesignerConstants::MEMORYMAPOVERLAPCOLUMN_NAME, Qt::CaseInsensitive))\n                        {\n                            columnHandler_->removeColumnFromLayout(originalColumn);\n                        }\n\n                        break;\n                    }\n\n                    columnPoint.setX(columnPoint.x() - columnWidth);\n                    comparisonColumn = columnHandler_->findColumnAtPosition(columnPoint);\n                }\n            }\n        }\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: MemoryConnectionHandler::redrawMemoryConnections()\n//-----------------------------------------------------------------------------\nvoid MemoryConnectionHandler::redrawMemoryConnections(QVector<MemoryConnectionItem*> connectionItems) const\n{\n    for (auto connection : connectionItems)\n    {\n        connection->reDrawConnection();\n        connection->repositionCollidingRangeLabels();\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: MemoryConnectionHandler::createOverlappingConnectionMarkers()\n//-----------------------------------------------------------------------------\nvoid MemoryConnectionHandler::createOverlappingConnectionMarkers(\n    QSharedPointer<QVector<MainMemoryGraphicsItem*> > placedSpaceItems)\n{\n    for (MainMemoryGraphicsItem * spaceItem : *placedSpaceItems)\n    {\n        spaceItem->createOverlappingConnectionMarkers();\n\n        for (MemoryCollisionItem * collisionItem : spaceItem->getMemoryCollisions())\n        {\n            memoryCollisions_.append(collisionItem);\n        }\n    }\n}\n"
  },
  {
    "path": "editors/MemoryDesigner/MemoryConnectionHandler.h",
    "content": "//-----------------------------------------------------------------------------\n// File: MemoryConnectionHandler.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 03.01.2017\n//\n// Description:\n// Constructs the memory connections for the memory design diagram.\n//-----------------------------------------------------------------------------\n\n#ifndef MEMORYCONNECTIONHANDLER_H\n#define MEMORYCONNECTIONHANDLER_H\n\n#include <QSharedPointer>\n#include <QVector>\n#include <QQueue>\n#include <QGraphicsItem>\n\n#include <editors/MemoryDesigner/MemoryConnectionAddressCalculator.h>\n\nclass ConnectivityGraph;\nclass ConnectivityInterface;\nclass MemoryColumn;\nclass MainMemoryGraphicsItem;\nclass MemoryConnectionItem;\nclass MemoryCollisionItem;\nclass MemoryColumnHandler;\nclass MemoryItem;\nclass MemoryGraphicsItemHandler;\n\n//-----------------------------------------------------------------------------\n//! Constructs the memory connections for the memory design diagram.\n//-----------------------------------------------------------------------------\nclass MemoryConnectionHandler\n{\n\npublic:\n\n    //! Used for simplifying the interface path.\n    using Path = QVector<QSharedPointer<ConnectivityInterface const> >;\n\n    /*!\n     *  The constructor.\n     *\n     *    @param [in] columnHandler     Handler for memory columns.\n     *    @param [in] itemHandler       Handler for graphics items.\n     */\n    MemoryConnectionHandler(QSharedPointer<MemoryColumnHandler> columnHandler, QSharedPointer<MemoryGraphicsItemHandler> itemHandler);\n\n    /*!\n     *  The destructor.\n     */\n    ~MemoryConnectionHandler() = default;\n\n    /*!\n     *  Change the condensing of memory graphics items.\n     *\n     *    @param [in] condenseMemoryItems     Value for condensing memory graphics items.\n     */\n    void setCondenseMemoryItems(bool condenseMemoryItems);\n\n    /*!\n     *  Check whether the memory graphics items are condensed or not.\n     *\n     *    @return True, if the memory graphics items are condensed, otherwise false.\n     */\n    bool memoryItemsAreCondensed() const;\n\n    /*!\n     *  Set the filtering for chained address space memory connections.\n     *\n     *    @param [in] filterChains    Value for the chained address space memory connection filtering.\n     */\n    void setFilterAddressSpaceChains(bool filterChains);\n\n    /*!\n     *  Check whether the chained address space memory connections are filtered or not.\n     *\n     *    @return True, if the chained address space memory connections are filtered, false otherwise.\n     */\n    bool addressSpaceChainsAreFiltered() const;\n\n    /*!\n     *  Clear the memory connection and memory connection collision lists.\n     */\n    void clearConnectionLists();\n\n    /*!\n     *  Redraw the memory connections and memory collisions.\n     */\n    void reDrawConnectionsAndCollisions();\n\n    /*!\n     *  Create the connections and place the connected items.\n     *\t\n     *    @param [in] connectionGraph     Graph containing the memory connection paths.\n     *    @param [in] spaceColumn         Column containing the address space graphics items.\n     *    @param [in] memoryMapColumn     Column containing the memory map graphics items.\n     */\n    void createConnectedItems(QSharedPointer<ConnectivityGraph> connectionGraph,\n        MemoryColumn* spaceColumn,\n        MemoryColumn* memoryMapColumn);\n\nprivate:\n    // Disable copying.\n    MemoryConnectionHandler(MemoryConnectionHandler const& rhs);\n    MemoryConnectionHandler& operator=(MemoryConnectionHandler const& rhs);\n\n    //! Collection of memory items connected to each other.\n    struct ConnectedItemSet \n    {\n        //! List of address space items connected to this set.\n        QSharedPointer<QVector<MainMemoryGraphicsItem*> > connectedSpaces_;\n\n        //! List of memory map items connected to this set.\n        QSharedPointer<QVector<MainMemoryGraphicsItem*> > connectedMaps_;\n    };\n\n    //! Graphics item with calculated address ranges and linked child items.\n    struct LinkedGraphicItem\n    {\n        //! Calculated base addresses of the connection to this item.\n        quint64 connectionLeftBaseAddress_ = 0;\n        quint64 connectionRightBaseAddress_ = 0;\n\n        //! List of ranges this item has been connected with to the previous item.\n        QVector<quint64> connectionRanges_;\n\n        //! Value for moving the connection relative to the previous item.\n        qreal connectionTransferY_ = 0;\n\n        //! Value for moving the connected item relative to the connection.\n        qreal memoryItemTransferY_ = 0;\n\n        //! The linked graphics item.\n        MainMemoryGraphicsItem* item_;\n\n        //! List of linked child items.\n        QSharedPointer<QVector<QSharedPointer<LinkedGraphicItem> > > children_ = QSharedPointer<QVector<QSharedPointer<LinkedGraphicItem> > >(new QVector<QSharedPointer<LinkedGraphicItem> >());\n    };\n\n    /*!\n     *  Reorder the graphics items from a connection path into a linked list.\n     *\t\n     *    @param [in] placedItems       List of the linked graphics items.\n     *    @param [in] roots             List of starting graphics items.\n     *    @param [in] spaceColumn       Column containing the address space graphics items.\n     *    @param [in] mapColumn         Column containing the memory map graphics items.\n     *    @param [in] connectionPath    The connection path.\n     */\n    void createLinkedItemsForPath(\n        QSharedPointer<QVector<MainMemoryGraphicsItem*> > placedItems,\n        QSharedPointer<QVector<QSharedPointer<LinkedGraphicItem> > > roots,\n        MemoryColumn* spaceColumn,\n        MemoryColumn* mapColumn,\n        const Path& connectionPath);\n\n    /*!\n     *  Create a linked item for a local memory map.\n     *\n     *    @param [in] previousItem          The previous linked item.\n     *    @param [in] localMapInterface     Interface for the local memory map.\n     *    @param [in] placedItems           List of placed graphics items.\n     *    @param [in] mapColumn             Column containing the memory map graphics items.\n     */\n    void createLocalLinkedItem(\n        QSharedPointer<LinkedGraphicItem> previousItem,\n        QSharedPointer<ConnectivityInterface const> localMapInterface,\n        QSharedPointer<QVector<MainMemoryGraphicsItem*> > placedItems,\n        MemoryColumn* mapColumn);\n\n    /*!\n     *  Find an existing linked item, or create a new one.\n     *\n     *    @param [in] placedItems                   List of linked graphics items.\n     *    @param [in] roots                         List of the starting graphics items.\n     *    @param [in] previousItem                  The previous linked graphics item.\n     *    @param [in] pathGraphicsItem              Graphics item for this linked item.\n     *    @param [in] connectionLeftBaseAddress     Base address of the connection on the starting item.\n     *    @param [in] connectionRightBaseAddress    Base address of the connection on the ending item.\n     *    @param [in] connectionRange               Range of the connection.\n     *    @param [in] itemTransferY                 Value for moving the item relative to the connection.\n     *    @param [in] connectionTransferY           Value for moving the connection relative to the previous item.\n     *    @param [in] itemColumn                    Column for the graphics item.\n     *\n     *    @return The found linked graphics item.\n     */\n    QSharedPointer<LinkedGraphicItem> findOrCreateLinkedItem(\n        QSharedPointer<QVector<MainMemoryGraphicsItem*> > placedItems,\n        QSharedPointer<QVector<QSharedPointer<LinkedGraphicItem> > > roots,\n        QSharedPointer<LinkedGraphicItem> previousItem,\n        MainMemoryGraphicsItem* pathGraphicsItem,\n        quint64 const& connectionLeftBaseAddress,\n        quint64 const& connectionRightBaseAddress,\n        quint64 const& connectionRange,\n        qreal const& itemTransferY,\n        qreal const& connectionTransferY,\n        MemoryColumn* itemColumn);\n\n    /*!\n     *  Check if the graphics item has already been linked to the selected linked item with the selected base address.\n     *\n     *    @param [in] linkedItem                    The selected linked item.\n     *    @param [in] pathGraphicsItem              The selected graphics item.\n     *    @param [in] connectionLeftBaseAddress     Base address of the connection on the starting item.\n     *    @param [in] connectionRightBaseAddress    Base address of the connection on the ending item.\n     *\n     *    @return True, if the graphics item has been linked, false otherwise.\n     */\n    bool foundLinkedItem(QSharedPointer<LinkedGraphicItem> linkedItem, MainMemoryGraphicsItem* pathGraphicsItem, quint64 const& connectionLeftBaseAddress, quint64 const& connectionRightBaseAddress) const;\n\n    /*!\n     *  Create a linked graphics item.\n     *\n     *    @param [in] containingSet                 The set of items to which this linked item will be added to.\n     *    @param [in] pathGraphicsItem              Graphics item to be linked.\n     *    @param [in] itemBaseAddress               Base address for the graphics item.\n     *    @param [in] connectionLeftBaseAddress     Base address of the connection on the starting item.\n     *    @param [in] connectionRightBaseAddress    Base address of the connection on the ending item.\n     *    @param [in] connectionRange               Last address for the connection to the selected item.\n     *    @param [in] connectedItemTransferY        Value for moving the item relative to the connection.\n     *    @param [in] connectionTransferY           Value for moving the connection relative to the previous item.\n     *    @param [in] placedItems                   List of linked graphics items.\n     *    @param [in] itemColumn                    Column containing the linked memory item.\n     *\n     *    @return \n     */\n    QSharedPointer<LinkedGraphicItem> createLinkedItem(\n        QSharedPointer<QVector<QSharedPointer<LinkedGraphicItem> > > containingSet,\n        MainMemoryGraphicsItem* pathGraphicsItem,\n        quint64 const& connectionLeftBaseAddress,\n        quint64 const& connectionRightBaseAddress,\n        quint64 const& connectionRange,\n        qreal const& connectedItemTransferY,\n        qreal const& connectionTransferY,\n        QSharedPointer<QVector<MainMemoryGraphicsItem*> > placedItems,\n        MemoryColumn* itemColumn);\n\n    /*!\n     *  Combine paths containing the same memory items.\n     *\n     *    @param [in] masterSlavePaths    Interface paths from master to slave.\n     *\n     *    @return A list of combined path sets.\n     */\n    QVector<QSharedPointer<QVector<Path> > > findPathSets(QVector<Path> const& masterSlavePaths) const;\n\n    /*!\n     *  Find the indexes of the path sets that the selected path belongs to.\n     *\n     *    @param [in] currentPath     The selected path.\n     *    @param [in] pathSets        List of the path sets.\n     *\n     *    @return List of path set indexes.\n     */\n    QQueue<int> findPathSetIndexes(Path const& currentPath,\n        QVector<QSharedPointer<QVector<Path> > > const& pathSets) const;\n\n    /*!\n     *  Check if an interface of the selected path is contained with the selected path set.\n     *\t\n     *    @param [in] currentPath     The selected path.\n     *    @param [in] pathSet         The selected comparison path set.\n     *\n     *    @return True, if an interface is contained within the path set, false otherwise.\n     */\n    bool pathIsContainedWithPathSet(Path const& currentPath, QSharedPointer<QVector<Path> > pathSet) const;\n\n    /*!\n     *  Check if the selected interface is contained within the selected path.\n     *\t\n     *    @param [in] pathInterface   The selected interface.\n     *    @param [in] comparisonPath  The selected comparison path.\n     *\n     *    @return True, if the interface is contained within the path, false otherwise.\n     */\n    bool interfacedItemIsWithinPath(QSharedPointer<const ConnectivityInterface> pathInterface,\n        Path const& comparisonPath) const;\n\n    /*!\n     *  Create a combined connection set from the selected path set.\n     *\n     *    @param [in] connectionSet     The selected path set.\n     *    @param [in] placedMapItems    List of already placed memory map items.\n     *    @param [in] memoryMapColumn   The memory map column.\n     *    @param [in] spaceColumn       The address space column.\n     *    @param [in] spaceYPlacement   Placement of the top item in the connection set.\n     *    @param [in] placedSpaceItems  List of already placed address space items.\n     *\n     *    @return List of the created memory connections.\n     */\n    QVector<MemoryConnectionItem*> createConnectionSet(QSharedPointer<QVector<Path> > connectionSet,\n        QSharedPointer<QVector<MainMemoryGraphicsItem*> > placedMapItems,\n        MemoryColumn* memoryMapColumn,\n        MemoryColumn* spaceColumn,\n        qreal& spaceYPlacement,\n        QSharedPointer<QVector<MainMemoryGraphicsItem*> > placedSpaceItems);\n\n    /*!\n     *  Check if the selected memory connection already exists.\n     *\n     *    @param [in] startItem                 Start item of the connection.\n     *    @param [in] endItem                   End item of the connection.\n     *    @param [in] connectionBaseAddress     Base address of the connection.\n     *    @param [in] connectionEndAddress      Last address of the connection.\n     *\n     *    @return True, if the connection exists, false otherwise.\n     */\n    bool connectionExists(MainMemoryGraphicsItem* startItem,\n        MainMemoryGraphicsItem* endItem,\n        quint64 const& connectionBaseAddress,\n        quint64 const& connectionEndAddress) const;\n\n    /*!\n     *  Check if the connection start item should be moved, instead of the end item.\n     *\n     *    @param [in] endItem                   The connection end item.\n     *    @param [in] connectionBaseAddress     Base address of the connection.\n     *\n     *    @return True, if the start item should be moved, false otherwise.\n     */\n    bool moveStartItemNotEndItem(MainMemoryGraphicsItem const* endItem,\n        quint64 const& connectionBaseAddress) const;\n\n    /*!\n     *  Create a set for each separate memory item group.\n     *\n     *    @param [in] placedSpaceItems  List of the available address spaces, used as starting points for checking.\n     *\n     *    @return List of grouped memory items.\n     */\n    QVector<QSharedPointer<ConnectedItemSet> > separateBrokenPathSet(QSharedPointer<QVector<MainMemoryGraphicsItem*> > placedSpaceItems) const;\n\n    /*!\n     *  Get connected items for the selected address space item.\n     *\n     *    @param [in] spaceItem     The selected address space item.\n     *    @param [in] visitedItems  List of already visited items.\n     *\n     *    @return A group of memory items connected to each other.\n     */\n    QSharedPointer<ConnectedItemSet> getConnectedItemsForSpaceItem(MainMemoryGraphicsItem* spaceItem, QSharedPointer<QVector<MainMemoryGraphicsItem*> > visitedItems) const;\n\n    /*!\n     *  Get connected items for the selected memory item.\n     *\n     *    @param [in] memoryItem            The selected memory item.\n     *    @param [in] itemsConnectedToItem  List of items connected to this item.\n     *    @param [in] visitedItems          List of already visited items.\n     */\n    void getConnectedItems(MainMemoryGraphicsItem* memoryItem, QVector<MainMemoryGraphicsItem*>& itemsConnectedToItem, QSharedPointer<QVector<MainMemoryGraphicsItem*> > visitedItems) const;\n\n    /*!\n     *  Create connections displaying only the start and end items using the linked lists.\n     *\n     *    @param [in] roots         Starting points for the linked lists.\n     *    @param [in] placedSpaces  List of the already placed address spaces.\n     *    @param [in] placedMaps    List of the already placed memory maps.\n     *    @param [in] mapColumn     The memory map column.\n     */\n    void createOnlyEndsConnectionFromLinks(\n        QSharedPointer<QVector<QSharedPointer<LinkedGraphicItem> > > roots,\n        QSharedPointer<QVector<MainMemoryGraphicsItem*> > placedSpaces,\n        QSharedPointer<QVector<MainMemoryGraphicsItem*> > placedMaps,\n        MemoryColumn* mapColumn);\n\n    /*!\n     *  Create connections for a single linked list.\n     *\n     *    @param [in] roots                     Starting point for the linked list.\n     *    @param [in] currentLinkItem           The currently examined linked item.\n     *    @param [in] placedSpaces              List of the already placed address spaces.\n     *    @param [in] placedMaps                List of the already placed memory maps.\n     *    @param [in] mapColumn                 The memory map column.\n     *    @param [in] maximumLeftBaseAddress    The last base address visible to the connected root item.\n     *    @param [in] rightBaseAddressChange    Change made to the connection end item during the connection.\n     *    @param [in] minimumLeftLastAddress    The minimum last address visible to the connected root item.\n     */\n    void createOnlyEndsConnectionsForRoot(QSharedPointer<LinkedGraphicItem> root,\n        QSharedPointer<LinkedGraphicItem> currentLinkItem,\n        QSharedPointer<QVector<MainMemoryGraphicsItem*> > placedSpaces,\n        QSharedPointer<QVector<MainMemoryGraphicsItem*> > placedMaps,\n        MemoryColumn* mapColumn,\n        quint64 const& maximumLeftBaseAddress,\n        quint64 const& rightBaseAddressChange,\n        quint64 const& minimumLeftLastAddress);\n\n    /*!\n     *  Create full connections from the linked lists.\n     *\n     *    @param [in] roots         Starting points for the linked lists.\n     *    @param [in] placedSpaces  List of placed address space items.\n     *    @param [in] placedMaps    List of placed memory map items.\n     *    @param [in] mapColumn     Column for memory maps.\n     */\n    void createFullConnectionFromLinks(\n        QSharedPointer<QVector<QSharedPointer<LinkedGraphicItem> > > roots,\n        QSharedPointer<QVector<MainMemoryGraphicsItem*> > placedSpaces,\n        QSharedPointer<QVector<MainMemoryGraphicsItem*> > placedMaps,\n        MemoryColumn* mapColumn);\n\n    /*!\n     *  Create connections for the selected linked item.\n     *\n     *    @param [in] linkedItem    The selected linked item.\n     *    @param [in] placedSpaces  List of placed address space items.\n     *    @param [in] placedMaps    List of placed memory map items.\n     *    @param [in] mapColumn     Column for memory maps.\n     */\n    void createConnectionsForLinkedItem(\n        QSharedPointer<LinkedGraphicItem> linkedItem,\n        QSharedPointer<QVector<MainMemoryGraphicsItem*> > placedSpaces,\n        QSharedPointer<QVector<MainMemoryGraphicsItem*> > placedMaps,\n        MemoryColumn* mapColumn);\n\n    /*!\n     *  Get the memory graphics item corresponding to an interface.\n     *\n     *    @param [in] pathInterface     The selected interface.\n     *\n     *    @return Memory graphics item of the selected interface.\n     */\n    MainMemoryGraphicsItem* getPathGraphicsItem(QSharedPointer<const ConnectivityInterface> pathInterface) const;\n\n    /*!\n     *  Get the main graphics item corresponding to the selected connection interface.\n     *\n     *    @param [in] connectionInterface     The selected connection interface.\n     *    @param [in] columnType              The column type of the main graphics item.\n     *\n     *    @return The found main graphics item.\n     */\n    MainMemoryGraphicsItem* getMainGraphicsItem(QSharedPointer<ConnectivityInterface const> connectionInterface,\n        QString const& columnType) const;\n\n    /*!\n     *  Get the first initiator interface connected to an address space for the selected connection path.\n     *\n     *    @param [in] connectionPath    The selected connection path.\n     *\n     *    @return The first initiator interface for the selected connection path.\n     */\n    QSharedPointer<ConnectivityInterface const> getFirstInitiatorInterface(QVector<QSharedPointer<ConnectivityInterface const> > connectionPath) const;\n\n    /*!\n     *  Get the end item for the memory connection.\n     *\n     *    @param [in] startInterface  Start interface of the memory connection path.\n     *    @param [in] endInterface    End interface of the memory connection path.\n     *\n     *    @return The end item of the memory connection.\n     */\n    MainMemoryGraphicsItem* getConnectionEndItem(QSharedPointer<ConnectivityInterface const> startInterface,\n        QSharedPointer<ConnectivityInterface const> endInterface) const;\n\n    /*!\n     *  Get the local memory map graphics item of the selected address space interface.\n     *\n     *    @param [in] spaceInterface  Interface node referencing the selected address space item.\n     *\n     *    @return The local memory map graphics item of contained within the selected interface node.\n     */\n    MainMemoryGraphicsItem* getLocalMemoryMapItem(QSharedPointer<ConnectivityInterface const> spaceInterface) const;\n\n    /*!\n     *  Place the non-root connected address space item.\n     *\n     *    @param [in] spaceItem     The connected address space item.\n     *    @param [in] startItem     The connection start item.\n     *    @param [in] yTransfer     The initial position of the connected item relative to the starting memory item.\n     *    @param [in] placedSpaces  List of the placed address space items.\n     */\n    void placeAddressSpace(MainMemoryGraphicsItem* spaceItem, MainMemoryGraphicsItem* startItem, qreal const& yTransfer, QSharedPointer<QVector<MainMemoryGraphicsItem*> > placedSpaces);\n\n    /*!\n     *  Place the memory map item.\n     *\t\n     *    @param [in] mapItem           The connected memory map item.\n     *    @param [in] startItem         The connection starting item.\n     *    @param [in] yTransfer         The initial position of the connected item relative to the starting memory item.\n     *    @param [in] placedMapItems    List of the placed memory map items.\n     *    @param [in] mapColumn         The memory map column.\n     */\n    void placeMemoryMap(MainMemoryGraphicsItem* mapItem,\n        MainMemoryGraphicsItem* startItem,\n        qreal const& yTransfer,\n        QSharedPointer<QVector<MainMemoryGraphicsItem*> > placedMapItems,\n        MemoryColumn* mapColumn);\n\n    /*!\n     *  Check and reposition a memory map to a memory map overlap column if needed.\n     *\n     *    @param [in] placedMaps            A list of placed memory map items.\n     *    @param [in] memoryItem            The selected memory map item.\n     *    @param [in] originalColumn        The original column of the memory map item.\n     *    @param [in] connectionStartItem   The start item of the memory map connection.\n     */\n    void checkMemoryMapRepositionToOverlapColumn(\n        QSharedPointer<QVector<MainMemoryGraphicsItem*> > placedMaps,\n        MainMemoryGraphicsItem* memoryItem,\n        MemoryColumn* originalColumn,\n        MainMemoryGraphicsItem* connectionStartItem);\n\n    /*!\n     *  Place the address space item.\n     *\t\n     *    @param [in] spaceItem               The selected address space item.\n     *    @param [in] placedSpaceItems        List of the placed address space items.\n     *    @param [in] originalColumn          Original column of the address space items.\n     *    @param [in] targetItem              End item of the connection.\n     *    @param [in] connectionBaseAddress   Base address of the connection.\n     */\n    void positionSpaceItem(MainMemoryGraphicsItem* spaceItem, qreal ypos);\n\n    /*!\n     *  Create the connection item.\n     *\t\n     *    @param [in] startItem             The starting item of the connection.\n     *    @param [in] endItem               The end item of the connection.\n     *    @param [in] leftBaseAddress       Base address of the connection on the starting item.\n     *    @param [in] rightBaseAddress      Base address of the connection on the ending item.\n     *    @param [in] endItemBaseAddress    Base address for the end item.\n     *    @param [in] connectionRange       Range of the connection.\n     *    @param [in] yTransfer             Position of the connection relative to the starting item.\n     */\n    void createConnectionItem(MainMemoryGraphicsItem* startItem,\n        MainMemoryGraphicsItem* endItem,\n        quint64 const& leftBaseAddress,\n        quint64 const& rightBaseAddress,\n        quint64 const& endItemBaseAddress,\n        quint64 const& connectionRange,\n        qreal const& yTransfer);\n\n    /*!\n     *  Change the address range of the selected memory graphics item.\n     *\n     *    @param [in] connectionEndItem       The selected memory graphics item.\n     *    @param [in] remappedAddress         Remapped address of the memory connection.\n     */\n    void changeConnectionEndItemRanges(MainMemoryGraphicsItem* connectionEndItem,\n        quint64 const& remappedAddress) const;\n\n    /*!\n     *  Get the memory item in the highest position of the set.\n     *\t\n     *    @param [in] currentHighestItem  The currently highest memory item.\n     *    @param [in] itemSet             The selected set.\n     *\n     *    @return The highest memory item.\n     */\n    MainMemoryGraphicsItem* getHighestPlacedItemInSet(MainMemoryGraphicsItem* currentHighestItem,\n        QSharedPointer<QVector<MainMemoryGraphicsItem*> > itemSet) const;\n\n    /*!\n     *  Compress and reposition the connection set.\n     *\t\n     *    @param [in] placedSpaceItems    List of the address space items of the connection set.\n     *    @param [in] placedMapItems      List of the memory map items of the connection set.\n     *\n     *    @return The memory connections of the set.\n     */\n    QVector<MemoryConnectionItem*> compressConnectedMemoryItems(\n        QSharedPointer<QVector<MainMemoryGraphicsItem*> > placedSpaceItems,\n        QSharedPointer<QVector<MainMemoryGraphicsItem*> > placedMapItems) const;\n\n    /*!\n     *  Calculate the area movements of the compressed set.\n     *\t\n     *    @param [in] uncutCoordinates    Coordinates that must be visible in the compressed set.\n     *    @param [in] CUTMODIFIER         Maximum height of the compressed set.\n     *\n     *    @return Map with Y-coordinate as the key and total movement up to this coordinate as the value.\n     */\n    QMap<qreal, qreal> calculateAreaMovements(QVector<qreal> uncutCoordinates, qreal const& CUTMODIFIER) const;\n\n    /*!\n     *  Check if an address space item should be repositioned to another column.\n     *\t\n     *    @param [in] placedSpaceItems    List of the placed address space items.\n     */\n    void repositionCompressedAddressSpaces(QSharedPointer<QVector<MainMemoryGraphicsItem*> > placedSpaceItems);\n\n    /*!\n     *  Check if the selected memory item collides with other placed memory items.\n     *\t\n     *    @param [in] memoryItem      The selected memory item.\n     *    @param [in] placedItems     List of the placed memory items.\n     *\n     *    @return True, if the item collides, false otherwise.\n     */\n    bool itemCollidesWithOtherPlacedItems(MainMemoryGraphicsItem const* memoryItem,\n        QSharedPointer<QVector<MainMemoryGraphicsItem*> > placedItems) const;\n\n    /*!\n     *  Place the space item to a column.\n     *\t\n     *    @param [in] spaceItem           The space item.\n     *    @param [in] placedSpaceItems    List of the placed space items.\n     */\n    void placeCompressedSpaceToColumn(MainMemoryGraphicsItem* spaceItem,\n        QSharedPointer<QVector<MainMemoryGraphicsItem*> > placedSpaceItems);\n\n    /*!\n     *  Reposition compressed memory maps to previous columns.\n     *\n     *    @param [in] placedMapItems      A list of the placed memory map items.\n     *    @param [in] memoryMapColumn     The main memory map column.\n     */\n    void repositionCompressedMemoryMaps(QSharedPointer<QVector<MainMemoryGraphicsItem*> > placedMapItems,\n        MemoryColumn const* memoryMapColumn);\n\n    /*!\n     *  Redraw the memory connections.\n     *\t\n     *    @param [in] connectionItems     List of the memory connection items.\n     *\n     *    @return \n     */\n    void redrawMemoryConnections(QVector<MemoryConnectionItem*> connectionItems) const;\n\n    /*!\n     *  Create markers for the overlapping connections.\n     *\n     *    @param [in] placedSpaceItems    List of the placed address space items.\n     */\n    void createOverlappingConnectionMarkers(QSharedPointer<QVector<MainMemoryGraphicsItem*> > placedSpaceItems);\n\n    //-----------------------------------------------------------------------------\n    // Data.\n    //-----------------------------------------------------------------------------\n\n    //! Value for displaying condensed memory connections.\n    bool condenseMemoryItems_ = true;\n\n    //! Value for filtering the chained address space memory connections.\n    bool filterAddressSpaceChains_ = true;\n\n    //! A list of memory connections made to memory maps.\n    QVector<MemoryConnectionItem*> connectionsToMemoryMaps_;\n\n    //! A list of memory collisions.\n    QVector<MemoryCollisionItem*> memoryCollisions_;\n\n    //! Handler for memory columns.\n    QSharedPointer<MemoryColumnHandler> columnHandler_;\n\n    //! Handler for memory items.\n    QSharedPointer<MemoryGraphicsItemHandler> itemHandler_;\n};\n\n//-----------------------------------------------------------------------------\n\n#endif // MEMORYCONNECTIONHANDLER_H\n"
  },
  {
    "path": "editors/MemoryDesigner/MemoryConnectionItem.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: MemoryConnectionItem.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Mikko Teuho\r\n// Date: 16.08.2016\r\n//\r\n// Description:\r\n// Memory designer connection item between.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"MemoryConnectionItem.h\"\r\n\r\n#include <common/KactusColors.h>\r\n\r\n#include <editors/MemoryDesigner/MainMemoryGraphicsItem.h>\r\n#include <editors/MemoryDesigner/MemoryColumn.h>\r\n#include <editors/MemoryDesigner/MemoryDesignerConstants.h>\r\n#include <editors/MemoryDesigner/MemoryMapGraphicsItem.h>\r\n#include <editors/MemoryDesigner/MemoryExtensionGraphicsItem.h>\r\n#include <editors/MemoryDesigner/MemoryItem.h>\r\n\r\n#include <QBrush>\r\n#include <QPen>\r\n#include <QFont>\r\n#include <QGraphicsScene>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryConnectionItem::MemoryConnectionItem()\r\n//-----------------------------------------------------------------------------\r\nMemoryConnectionItem::MemoryConnectionItem(MainMemoryGraphicsItem* startItem,\r\n    quint64 firstStartValue, quint64 firstEndValue,\r\n    quint64 secondStartValue, quint64 secondEndvalue,\r\n    MainMemoryGraphicsItem* endItem,\r\n    QGraphicsScene* containingScene,\r\n    qreal yTransfer,\r\n    QGraphicsItem* parent):\r\nQGraphicsPathItem(parent),\r\nfirstItemStartLabel_(new QGraphicsTextItem(this)),\r\nfirstItemEndLabel_(new QGraphicsTextItem(this)),\r\nsecondItemStartLabel_(new QGraphicsTextItem(this)),\r\nsecondItemEndLabel_(new QGraphicsTextItem(this)),\r\nstartItem_(startItem),\r\nendItem_(endItem),\r\nconnectionBaseAddress_(firstStartValue),\r\nconnectionLastAddress_(firstEndValue),\r\nconnectionWidth_(getConnectionWidth()),\r\nyTransfer_(yTransfer)\r\n{\r\n    setupLabels(firstStartValue, firstEndValue, secondStartValue, secondEndvalue);\r\n\r\n    if (connectionBaseAddress_ == connectionLastAddress_)\r\n    {\r\n        firstItemEndLabel_->hide();\r\n        secondItemEndLabel_->hide();\r\n    }\r\n\r\n    containingScene->addItem(this);\r\n    setZValue(10000);\r\n\r\n    startItem_->addMemoryConnection(this);\r\n    endItem_->addMemoryConnection(this);\r\n\r\n    createPath();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryConnectionItem::createPath()\r\n//-----------------------------------------------------------------------------\r\nvoid MemoryConnectionItem::createPath()\r\n{\r\n    setPath(QPainterPath());\r\n\r\n    const qreal LINEWIDTH = 1;\r\n\r\n    QPointF startItemTopRight = startItem_->sceneBoundingRect().topRight();\r\n    QPointF endItemTopLeft = endItem_->sceneBoundingRect().topLeft();\r\n\r\n    QPointF highStartPoint(startItemTopRight.x(), startItemTopRight.y() + yTransfer_ + LINEWIDTH / 2);\r\n    QPointF lowStartPoint(highStartPoint.x(), highStartPoint.y() + connectionWidth_);\r\n    QPointF highEndPoint(endItemTopLeft.x(), highStartPoint.y());\r\n    QPointF lowEndPoint(highEndPoint.x(), lowStartPoint.y());\r\n\r\n    QPainterPath path = createConnectionPath(highStartPoint, highEndPoint, lowStartPoint, lowEndPoint, LINEWIDTH);\r\n\r\n    setPath(path);\r\n    avoidCollisionsOnPath(highStartPoint, highEndPoint, lowStartPoint, lowEndPoint);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryConnectionItem::createConnectionPath()\r\n//-----------------------------------------------------------------------------\r\nQPainterPath MemoryConnectionItem::createConnectionPath(QPointF const& highStartPoint, QPointF const& highEndPoint,\r\n    QPointF const& lowStartPoint, QPointF const& lowEndPoint, int const& LINEWIDTH)\r\n{\r\n    QPainterPath path;\r\n    path.moveTo(highStartPoint);\r\n\r\n    QPen connectionPen = pen();\r\n    connectionPen.setWidth(LINEWIDTH);\r\n\r\n    if (dynamic_cast<MemoryMapGraphicsItem*>(endItem_) && !isLocalMapConnection())\r\n    {\r\n        path.lineTo(highEndPoint);\r\n        path.moveTo(lowStartPoint);\r\n        path.lineTo(lowEndPoint);\r\n    }\r\n    else\r\n    {\r\n        bool connectionIsLocal = isLocalMapConnection();\r\n        if (connectionIsLocal)\r\n        {\r\n            connectionPen.setColor(QColor(0, 128, 255));\r\n        }\r\n        else\r\n        {\r\n            connectionPen.setColor(QColor(60, 153, 60));\r\n        }\r\n\r\n        path = createCollidingPathForUnusualConnection(\r\n            connectionIsLocal, highStartPoint, highEndPoint, lowStartPoint, lowEndPoint);\r\n    }\r\n\r\n    setPen(connectionPen);\r\n\r\n    return path;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryConnectionItem::isLocalMapConnection()\r\n//-----------------------------------------------------------------------------\r\nbool MemoryConnectionItem::isLocalMapConnection() const\r\n{\r\n    QSharedPointer<MemoryItem const> startMemory = startItem_->getMemoryItem();\r\n    QSharedPointer<MemoryItem const> endMemory = endItem_->getMemoryItem();\r\n\r\n    foreach (QSharedPointer<MemoryItem const> startSubMemory, startMemory->getChildItems())\r\n    {\r\n        if (startSubMemory == endMemory)\r\n        {\r\n            return true;\r\n        }\r\n    }\r\n    \r\n    return false;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryConnectionItem::getConnectionWidth()\r\n//-----------------------------------------------------------------------------\r\nqreal MemoryConnectionItem::getConnectionWidth() const\r\n{\r\n    qreal connectionWidth =\r\n        (connectionLastAddress_ - connectionBaseAddress_ + 1) * MemoryDesignerConstants::RANGEINTERVAL;\r\n\r\n    return connectionWidth;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryConnectionItem::compressToUnCutCoordinates()\r\n//-----------------------------------------------------------------------------\r\nvoid MemoryConnectionItem::compressToUnCutCoordinates(QVector<MainMemoryGraphicsItem*>& condensedItems,\r\n    QVector<qreal> unCutCoordinates, const qreal CUTMODIFIER, bool memoryItemsAreCompressed)\r\n{\r\n    qreal cutArea = 0;\r\n    qreal connectionTop = sceneBoundingRect().top();\r\n    qreal connectionLow = sceneBoundingRect().bottom();\r\n    qreal previousCoordinate = connectionTop;\r\n    foreach(qreal coordinate, unCutCoordinates)\r\n    {\r\n        if (coordinate > connectionTop && coordinate <= connectionLow)\r\n        {\r\n            if (qreal singleCut = coordinate - previousCoordinate; singleCut > 0)\r\n            {\r\n                if (memoryItemsAreCompressed)\r\n                {\r\n                    singleCut = singleCut - CUTMODIFIER;\r\n                }\r\n                else\r\n                {\r\n                    qreal requiredArea = MemoryDesignerConstants::getRequiredAreaForUsedArea(singleCut);\r\n                    singleCut = singleCut - requiredArea;\r\n                }\r\n\r\n                if (singleCut > 0)\r\n                {\r\n                    cutArea += singleCut;\r\n                }\r\n            }\r\n\r\n            previousCoordinate = coordinate;\r\n        }\r\n\r\n        if (coordinate > connectionLow)\r\n        {\r\n            break;\r\n        }\r\n    }\r\n\r\n    if (cutArea > 0)\r\n    {\r\n        qreal condensedHeight = boundingRect().height() - cutArea;\r\n        setCondensedHeight(condensedHeight);\r\n    }\r\n\r\n    compressEndItemToCoordinates(condensedItems, unCutCoordinates, CUTMODIFIER, memoryItemsAreCompressed);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryConnectionItem::compressEndItemToCoordinates()\r\n//-----------------------------------------------------------------------------\r\nvoid MemoryConnectionItem::compressEndItemToCoordinates(\r\n    QVector<MainMemoryGraphicsItem*>& compressedItems, QVector<qreal> unCutCoordinates,\r\n    const qreal CUTMODIFIER, bool memoryItemsAreCompressed)\r\n{\r\n    if (!compressedItems.contains(endItem_))\r\n    {\r\n        compressedItems.append(endItem_);\r\n        endItem_->compressToUnCutCoordinates(unCutCoordinates, CUTMODIFIER, memoryItemsAreCompressed);\r\n    }\r\n\r\n    if (!compressedItems.contains(startItem_))\r\n    {\r\n        compressedItems.append(startItem_);\r\n        startItem_->compressToUnCutCoordinates(unCutCoordinates, CUTMODIFIER, memoryItemsAreCompressed);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryConnectionItem::moveConnectedItems()\r\n//-----------------------------------------------------------------------------\r\nvoid MemoryConnectionItem::moveConnectedItems(QSharedPointer<QVector<MainMemoryGraphicsItem*> > movedItems,\r\n    MainMemoryGraphicsItem* movementOrigin, qreal transferY)\r\n{\r\n    moveConnectedItemWithoutConnections(movedItems, movementOrigin, getConnectionStartItem(), transferY);\r\n    moveConnectedItemWithoutConnections(movedItems, movementOrigin, getConnectionEndItem(), transferY);\r\n\r\n    reDrawConnection();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryConnectionItem::moveConnectedItem()\r\n//-----------------------------------------------------------------------------\r\nvoid MemoryConnectionItem::moveConnectedItemWithoutConnections(\r\n    QSharedPointer<QVector<MainMemoryGraphicsItem*> > movedItems, MainMemoryGraphicsItem const* movementOrigin,\r\n    MainMemoryGraphicsItem* connectedItem, qreal transferY)\r\n{\r\n    if (connectedItem && connectedItem != movementOrigin && !movedItems->contains(connectedItem))\r\n    {\r\n        movedItems->append(connectedItem);\r\n        connectedItem->moveBy(0, transferY);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryConnectionItem::setCondensedHeight()\r\n//-----------------------------------------------------------------------------\r\nvoid MemoryConnectionItem::setCondensedHeight(qreal newHeight)\r\n{\r\n    connectionWidth_ = newHeight;\r\n    reDrawConnection();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryConnectionItem::avoidCollisionsOnPath()\r\n//-----------------------------------------------------------------------------\r\nvoid MemoryConnectionItem::avoidCollisionsOnPath(QPointF const& highStartPoint, QPointF const& highEndPoint,\r\n    QPointF const& lowStartPoint, QPointF const& lowEndPoint)\r\n{\r\n    QList<QGraphicsItem*> collisions = collidingItems(Qt::IntersectsItemBoundingRect);\r\n    if (!collisions.isEmpty())\r\n    {\r\n        qreal connectionTop = highStartPoint.y();\r\n        qreal connectionLow = lowStartPoint.y();\r\n\r\n        QMultiMap<qreal, QPair<QPointF, QPointF> > highCollisionPoints;\r\n        QMultiMap<qreal, QPair<QPointF, QPointF> > lowCollisionPoints;\r\n\r\n        MemoryColumn const* startColumn = dynamic_cast<MemoryColumn*>(startItem_->parentItem());\r\n        MemoryColumn const* endColumn = dynamic_cast<MemoryColumn*>(endItem_->parentItem());\r\n\r\n        foreach (QGraphicsItem* collidingItem, collisions)\r\n        {\r\n            auto memoryItem = dynamic_cast<MemoryDesignerGraphicsItem*>(collidingItem);\r\n            if (memoryItem)\r\n            {\r\n                bool isMainItem = dynamic_cast<MainMemoryGraphicsItem*>(memoryItem);\r\n                bool isExtensionItem = dynamic_cast<MemoryExtensionGraphicsItem*>(memoryItem);\r\n                bool isNotConnectedItem = memoryItem != startItem_ && memoryItem != endItem_;\r\n                if (memoryItem && (isMainItem || isExtensionItem) && isNotConnectedItem)\r\n                {\r\n                    MemoryColumn const* itemColumn = dynamic_cast<MemoryColumn*>(memoryItem->parentItem());\r\n                    if (!itemColumn && isExtensionItem)\r\n                    {\r\n                        MainMemoryGraphicsItem const* extensionParent = dynamic_cast<MainMemoryGraphicsItem*>(memoryItem->parentItem());\r\n                        if (extensionParent)\r\n                        {\r\n                            itemColumn = dynamic_cast<MemoryColumn*>(extensionParent->parentItem());\r\n                        }\r\n                    }\r\n                    bool columnIsNotConnectedColumn = itemColumn != startColumn && itemColumn != endColumn;\r\n                    if (itemColumn && startColumn && endColumn && columnIsNotConnectedColumn)\r\n                    {\r\n                        QRectF collisionRectangle = memoryItem->sceneBoundingRect();\r\n                        qreal collisionTop = collisionRectangle.top();\r\n                        qreal collisionLow = collisionRectangle.bottom();\r\n\r\n                        qreal collisionLeft = collisionRectangle.left();\r\n                        qreal collisionRight = collisionRectangle.right();\r\n\r\n                        if (collisionTop < connectionTop && collisionLow > connectionTop)\r\n                        {\r\n                            QPointF collisionStart (collisionLeft, connectionTop);\r\n                            QPointF collisionEnd (collisionRight, connectionTop);\r\n\r\n                            QPair<QPointF, QPointF> collisionPoints(collisionStart, collisionEnd);\r\n                            highCollisionPoints.insert(collisionLeft, collisionPoints);\r\n                        }\r\n\r\n                        if (collisionTop < connectionLow && collisionLow > connectionLow)\r\n                        {\r\n                            QPointF collisionStart (collisionLeft, connectionLow);\r\n                            QPointF collisionEnd (collisionRight, connectionLow);\r\n\r\n                            QPair<QPointF, QPointF> collisionPoints(collisionStart, collisionEnd);\r\n                            lowCollisionPoints.insert(collisionLeft, collisionPoints);\r\n                        }\r\n                    }\r\n                }\r\n            }\r\n        }\r\n\r\n        if (!highCollisionPoints.isEmpty() || !lowCollisionPoints.isEmpty())\r\n        {\r\n            createCollisionPath(\r\n                highStartPoint, highEndPoint, lowStartPoint, lowEndPoint, highCollisionPoints, lowCollisionPoints);\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryConnectionItem::createCollisionPath()\r\n//-----------------------------------------------------------------------------\r\nvoid MemoryConnectionItem::createCollisionPath(QPointF highStartPoint, QPointF highEndPoint,\r\n    QPointF lowStartPoint, QPointF lowEndPoint,\r\n    QMultiMap<qreal, QPair<QPointF, QPointF> > highCollisionPoints,\r\n    QMultiMap<qreal, QPair<QPointF, QPointF> > lowCollisionPoints)\r\n{\r\n    QPainterPath collisionPath;\r\n    \r\n    if (dynamic_cast<MemoryMapGraphicsItem*>(endItem_) && !isLocalMapConnection())\r\n    {\r\n        collisionPath = eraseCollisionsFromPath(collisionPath, highStartPoint, highCollisionPoints);\r\n        collisionPath.lineTo(highEndPoint);\r\n\r\n        collisionPath = eraseCollisionsFromPath(collisionPath, lowStartPoint, lowCollisionPoints);\r\n        collisionPath.lineTo(lowEndPoint);\r\n    }\r\n    else\r\n    {\r\n        QMultiMap<qreal, QPair<QPointF, QPointF> > newHighCollisions;\r\n        QMultiMapIterator highCollisionIterator(highCollisionPoints);\r\n        while (highCollisionIterator.hasNext())\r\n        {\r\n            highCollisionIterator.next();\r\n\r\n            QPointF newCollisionStartPoint = highCollisionIterator.value().first;\r\n            newCollisionStartPoint.setY(newCollisionStartPoint.y() + BRIDGEMODIFIER_);\r\n            QPointF newCollisionEndPoint = highCollisionIterator.value().second;\r\n            newCollisionEndPoint.setY(newCollisionEndPoint.y() + BRIDGEMODIFIER_);\r\n\r\n            QPair<QPointF, QPointF> collisionPoints;\r\n            collisionPoints.first = newCollisionStartPoint;\r\n            collisionPoints.second = newCollisionEndPoint;\r\n\r\n            newHighCollisions.insert(highCollisionIterator.key(), collisionPoints);\r\n        }\r\n\r\n        QMultiMap<qreal, QPair<QPointF, QPointF> > newLowCollisions;\r\n        QMultiMapIterator lowCollisionIterator(lowCollisionPoints);\r\n        while (lowCollisionIterator.hasNext())\r\n        {\r\n            lowCollisionIterator.next();\r\n\r\n            QPointF newCollisionStartPoint = lowCollisionIterator.value().first;\r\n            newCollisionStartPoint.setY(newCollisionStartPoint.y() - BRIDGEMODIFIER_);\r\n            QPointF newCollisionEndPoint = lowCollisionIterator.value().second;\r\n            newCollisionEndPoint.setY(newCollisionEndPoint.y() - BRIDGEMODIFIER_);\r\n\r\n            QPair<QPointF, QPointF> collisionPoints;\r\n            collisionPoints.first = newCollisionStartPoint;\r\n            collisionPoints.second = newCollisionEndPoint;\r\n\r\n            newLowCollisions.insert(lowCollisionIterator.key(), collisionPoints);\r\n        }\r\n\r\n        collisionPath = createCollidingPathForUnusualConnection(isLocalMapConnection(), highStartPoint, highEndPoint,\r\n            lowStartPoint, lowEndPoint, newHighCollisions, newLowCollisions);\r\n    }\r\n\r\n    setPath(collisionPath);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryConnectionItem::createCollidingPathForLocalConnection()\r\n//-----------------------------------------------------------------------------\r\nQPainterPath MemoryConnectionItem::createCollidingPathForUnusualConnection(bool connectionIsLocal,\r\n    QPointF highStartPoint, QPointF highEndPoint, QPointF lowStartPoint, QPointF lowEndPoint,\r\n    QMultiMap<qreal, QPair<QPointF, QPointF> > highCollisionPoints,\r\n    QMultiMap<qreal, QPair<QPointF, QPointF> > lowCollisionPoints)\r\n{\r\n    QPainterPath collisionPath;\r\n\r\n    qreal bridgeHighLineY = highStartPoint.y();\r\n    qreal bridgeLowLineY = lowStartPoint.y();\r\n    qreal bridgeHighY = highStartPoint.y() + BRIDGEMODIFIER_;\r\n    qreal bridgeLowY = lowStartPoint.y() - BRIDGEMODIFIER_;\r\n    qreal bridgeStartX = highStartPoint.x() + firstItemStartLabel_->boundingRect().width();\r\n    qreal bridgeFirstPillarX = bridgeStartX + BRIDGEMODIFIER_;\r\n    qreal bridgeEndX = highEndPoint.x() - secondItemStartLabel_->boundingRect().width();\r\n    qreal bridgeLastPillarX = bridgeEndX - BRIDGEMODIFIER_;\r\n\r\n    QPointF highCollisionStartPoint (bridgeFirstPillarX, bridgeHighY);\r\n    QPointF lowCollisionStartPoint (bridgeFirstPillarX, bridgeLowY);\r\n\r\n    collisionPath.moveTo(highStartPoint);\r\n    if (connectionIsLocal)\r\n    {\r\n        collisionPath.lineTo(bridgeFirstPillarX, bridgeHighLineY);\r\n        collisionPath.lineTo(highCollisionStartPoint);\r\n    }\r\n    else\r\n    {\r\n        collisionPath.lineTo(bridgeStartX, bridgeHighLineY);\r\n        collisionPath.lineTo(bridgeFirstPillarX, bridgeHighY);\r\n    }\r\n\r\n    if (!highCollisionPoints.isEmpty() && highCollisionPoints.first().first.y() <= bridgeHighY)\r\n    {\r\n        collisionPath = eraseCollisionsFromPath(collisionPath, highCollisionStartPoint, highCollisionPoints);\r\n    }\r\n\r\n    if (connectionIsLocal)\r\n    {\r\n        collisionPath.lineTo(bridgeLastPillarX, bridgeHighY);\r\n        collisionPath.lineTo(bridgeLastPillarX, bridgeHighLineY);\r\n        collisionPath.lineTo(highEndPoint);\r\n\r\n        collisionPath.moveTo(lowStartPoint);\r\n        collisionPath.lineTo(bridgeFirstPillarX, bridgeLowLineY);\r\n        collisionPath.lineTo(lowCollisionStartPoint);\r\n    }\r\n    else\r\n    {\r\n        collisionPath.lineTo(bridgeLastPillarX, bridgeHighY);\r\n        collisionPath.lineTo(bridgeEndX, bridgeHighLineY);\r\n        collisionPath.lineTo(highEndPoint);\r\n\r\n        collisionPath.moveTo(lowStartPoint);\r\n        collisionPath.lineTo(bridgeStartX, bridgeLowLineY);\r\n        collisionPath.lineTo(bridgeFirstPillarX, bridgeLowY);\r\n    }\r\n\r\n    if (!lowCollisionPoints.isEmpty() && lowCollisionPoints.first().first.y() <= bridgeLowY)\r\n    {\r\n        collisionPath = eraseCollisionsFromPath(collisionPath, lowCollisionStartPoint, lowCollisionPoints);\r\n    }\r\n\r\n    if (connectionIsLocal)\r\n    {\r\n        collisionPath.lineTo(bridgeLastPillarX, bridgeLowY);\r\n        collisionPath.lineTo(bridgeLastPillarX, bridgeLowLineY);\r\n    }\r\n    else\r\n    {\r\n        collisionPath.lineTo(bridgeLastPillarX, bridgeLowY);\r\n        collisionPath.lineTo(bridgeEndX, bridgeLowLineY);\r\n   }\r\n\r\n    collisionPath.lineTo(lowEndPoint);\r\n    return collisionPath;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryConnectionItem::eraseCollisionsFromPath()\r\n//-----------------------------------------------------------------------------\r\nQPainterPath MemoryConnectionItem::eraseCollisionsFromPath(QPainterPath collisionPath, QPointF collisionBegin,\r\n    QMultiMap<qreal, QPair<QPointF, QPointF> > collisionPoints)\r\n{\r\n    QPainterPath erasedPath = collisionPath;\r\n    QPointF collisionStartPoint = collisionBegin;\r\n    qreal pathY = collisionStartPoint.y();\r\n\r\n    QMultiMapIterator<qreal, QPair<QPointF, QPointF> > collisionIterator(collisionPoints);\r\n    while (collisionIterator.hasNext())\r\n    {\r\n        collisionIterator.next();\r\n        QPair<QPointF, QPointF> singleCollisionPoints = collisionIterator.value();\r\n        erasedPath.moveTo(collisionStartPoint);\r\n        erasedPath.lineTo(singleCollisionPoints.first.x(), pathY);\r\n\r\n        QPointF collisionEndPoint(singleCollisionPoints.second.x(), pathY);\r\n        collisionStartPoint = collisionEndPoint;\r\n    }\r\n\r\n    erasedPath.moveTo(collisionStartPoint);\r\n\r\n    return erasedPath;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryConnectionItem::repositionLabels()\r\n//-----------------------------------------------------------------------------\r\nvoid MemoryConnectionItem::repositionLabels()\r\n{\r\n    QFont labelFont = firstItemStartLabel_->font();\r\n//     labelFont.setWeight(QFont::Bold);\r\n\r\n    firstItemStartLabel_->setFont(labelFont);\r\n    firstItemEndLabel_->setFont(labelFont);\r\n    secondItemStartLabel_->setFont(labelFont);\r\n    secondItemEndLabel_->setFont(labelFont);\r\n\r\n    QRectF connectionRect = boundingRect();\r\n\r\n    QPointF topLeft = connectionRect.topLeft();\r\n    QPointF topRight = connectionRect.topRight();\r\n    QPointF lowerLeft = connectionRect.bottomLeft();\r\n    QPointF lowerRight = connectionRect.bottomRight();\r\n\r\n    firstItemStartLabel_->setPos(topLeft);\r\n    firstItemEndLabel_->setPos(lowerLeft.x(), lowerLeft.y() - firstItemEndLabel_->boundingRect().height());\r\n\r\n    secondItemStartLabel_->setPos(topRight.x() - secondItemStartLabel_->boundingRect().width(), topRight.y());\r\n    secondItemEndLabel_->setPos(lowerRight.x() - secondItemStartLabel_->boundingRect().width(), lowerRight.y() - secondItemEndLabel_->boundingRect().height());\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryConnectionItem::setupLabels()\r\n//-----------------------------------------------------------------------------\r\nvoid MemoryConnectionItem::setupLabels(quint64 const& leftStartValue, quint64 const& leftEndValue, quint64 const& rightStartValue, quint64 const& rightEndValue)\r\n{\r\n    QString leftStartValueInHexa = QString::number(leftStartValue, 16).toUpper();\r\n    QString leftEndValueInHexa = QString::number(leftEndValue, 16).toUpper();\r\n    QString rightStartValueInHexa = QString::number(rightStartValue, 16).toUpper();\r\n    QString rightEndValueInHexa = QString::number(rightEndValue, 16).toUpper();\r\n\r\n    int amountOfNumbersLeft = MemoryDesignerConstants::getAmountOfNumbersInRange(leftStartValueInHexa, leftEndValueInHexa);\r\n    leftStartValueInHexa = MemoryDesignerConstants::getValueWithZerosAdded(leftStartValueInHexa, amountOfNumbersLeft);\r\n    leftEndValueInHexa = MemoryDesignerConstants::getValueWithZerosAdded(leftEndValueInHexa, amountOfNumbersLeft);\r\n    int amountOfNumbersRight = MemoryDesignerConstants::getAmountOfNumbersInRange(rightStartValueInHexa, rightEndValueInHexa);\r\n    rightStartValueInHexa = MemoryDesignerConstants::getValueWithZerosAdded(rightStartValueInHexa, amountOfNumbersRight);\r\n    rightEndValueInHexa = MemoryDesignerConstants::getValueWithZerosAdded(rightEndValueInHexa, amountOfNumbersRight);\r\n\r\n    firstItemStartLabel_->setPlainText(leftStartValueInHexa);\r\n    firstItemEndLabel_->setPlainText(leftEndValueInHexa);\r\n    secondItemStartLabel_->setPlainText(rightStartValueInHexa);\r\n    secondItemEndLabel_->setPlainText(rightEndValueInHexa);\r\n\r\n    if (startItem_->getBaseAddress() == leftStartValue)\r\n    {\r\n        firstItemStartLabel_->hide();\r\n    }\r\n\tif (startItem_->getLastAddress() == leftEndValue)\r\n\t{\r\n\t\tfirstItemEndLabel_->hide();\r\n\t}\r\n\tif (endItem_->getBaseAddress() == rightStartValue)\r\n\t{\r\n\t\tsecondItemStartLabel_->hide();\r\n\t}\r\n\tif (endItem_->getLastAddress() == rightEndValue)\r\n\t{\r\n\t\tsecondItemEndLabel_->hide();\r\n\t}\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryConnectionItem::moveItemBy()\r\n//-----------------------------------------------------------------------------\r\nvoid MemoryConnectionItem::moveItemBy(qreal const& movementInY)\r\n{\r\n    qreal newPosition = sceneBoundingRect().top() + movementInY;\r\n    yTransfer_ = newPosition - startItem_->sceneBoundingRect().top();\r\n\r\n    createPath();\r\n    repositionLabels();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryConnectionItem::getRangeStartValue()\r\n//-----------------------------------------------------------------------------\r\nquint64 MemoryConnectionItem::getRangeStartValue() const\r\n{\r\n    return connectionBaseAddress_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryConnectionItem::getRangeEndValue()\r\n//-----------------------------------------------------------------------------\r\nquint64 MemoryConnectionItem::getRangeEndValue() const\r\n{\r\n    return connectionLastAddress_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryConnectionItem::reDrawConnection()\r\n//-----------------------------------------------------------------------------\r\nvoid MemoryConnectionItem::reDrawConnection()\r\n{\r\n    createPath();\r\n    repositionLabels();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryConnectionItem::repositionCollidingTextLabels()\r\n//-----------------------------------------------------------------------------\r\nvoid MemoryConnectionItem::repositionCollidingRangeLabels()\r\n{\r\n    repositionSingleRangeLabel(firstItemStartLabel_);\r\n    repositionSingleRangeLabel(firstItemEndLabel_);\r\n    repositionSingleRangeLabel(secondItemStartLabel_);\r\n    repositionSingleRangeLabel(secondItemEndLabel_);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryConnectionItem::repositionCollidingTextLabel()\r\n//-----------------------------------------------------------------------------\r\nvoid MemoryConnectionItem::repositionSingleRangeLabel(QGraphicsTextItem* rangeLabel) const\r\n{\r\n    const int RECTANGLEMODIFIER = 7;\r\n\r\n    QRectF labelRectangle = rangeLabel->sceneBoundingRect();\r\n    labelRectangle.setTop(labelRectangle.top() + RECTANGLEMODIFIER);\r\n    labelRectangle.setBottom(labelRectangle.bottom() - RECTANGLEMODIFIER);\r\n\r\n    foreach (QGraphicsItem* collidingItem, rangeLabel->collidingItems())\r\n    {\r\n        auto collidingLabel = dynamic_cast<QGraphicsTextItem*>(collidingItem);\r\n        if (collidingLabel && collidingLabel != rangeLabel)\r\n        {\r\n            QRectF collidingRectangle = collidingLabel->sceneBoundingRect();\r\n            collidingRectangle.setTop(collidingRectangle.top() + RECTANGLEMODIFIER);\r\n            collidingRectangle.setBottom(collidingRectangle.bottom() - RECTANGLEMODIFIER);\r\n\r\n            if (MemoryDesignerConstants::itemOverlapsAnotherItem(labelRectangle, 0, collidingRectangle, 0))\r\n            {\r\n                quint64 itemValue = rangeLabel->toPlainText().toULongLong(0, 16);\r\n                if (quint64 collidingValue = collidingLabel->toPlainText().toULongLong(0, 16); itemValue < collidingValue)\r\n                {\r\n                    rangeLabel->moveBy(0, -6);\r\n                    collidingLabel->moveBy(0, 7);\r\n                }\r\n\r\n                return;\r\n            }\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryConnectionItem::getSceneEndPoint()\r\n//-----------------------------------------------------------------------------\r\nquint64 MemoryConnectionItem::getSceneEndPoint() const\r\n{\r\n    quint64 sceneEndPoint = sceneBoundingRect().bottom();\r\n    if (quint64 endItemSceneEndPoint = endItem_->getSceneRectangleWithSubItems().bottom(); endItemSceneEndPoint > sceneEndPoint)\r\n    {\r\n        sceneEndPoint = endItemSceneEndPoint;\r\n    }\r\n\r\n    return sceneEndPoint;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryConnectionItem::getStartItem()\r\n//-----------------------------------------------------------------------------\r\nMainMemoryGraphicsItem* MemoryConnectionItem::getConnectionStartItem() const\r\n{\r\n    return startItem_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryConnectionItem::getConnectionEndItem()\r\n//-----------------------------------------------------------------------------\r\nMainMemoryGraphicsItem* MemoryConnectionItem::getConnectionEndItem() const\r\n{\r\n    return endItem_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryConnectionItem::labelCollidesWithRanges()\r\n//-----------------------------------------------------------------------------\r\nbool MemoryConnectionItem::labelCollidesWithRanges(QGraphicsTextItem* label, qreal fontHeight,\r\n    const MainMemoryGraphicsItem* connectedItem) const\r\n{\r\n    QGraphicsTextItem const* comparedStartLabel = firstItemStartLabel_;\r\n    QGraphicsTextItem const* comparedEndLabel = firstItemEndLabel_;\r\n\r\n    if (connectedItem == endItem_)\r\n    {\r\n        comparedStartLabel = secondItemStartLabel_;\r\n        comparedEndLabel = secondItemEndLabel_;\r\n    }\r\n\r\n    QRectF labelRectangle = label->sceneBoundingRect();\r\n    QRectF comparedStartRectangle = comparedStartLabel->sceneBoundingRect();\r\n    QRectF comparedEndRectangle = comparedEndLabel->sceneBoundingRect();\r\n\r\n    labelRectangle.setHeight(fontHeight);\r\n    comparedStartRectangle.setHeight(fontHeight);\r\n    comparedEndRectangle.setHeight(fontHeight);\r\n\r\n    return MemoryDesignerConstants::itemOverlapsAnotherItem(labelRectangle, 0, comparedStartRectangle, 0) ||\r\n        MemoryDesignerConstants::itemOverlapsAnotherItem(labelRectangle, 0, comparedEndRectangle, 0);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryConnectionItem::getConnectionLowPoint()\r\n//-----------------------------------------------------------------------------\r\nqreal MemoryConnectionItem::getConnectionLowPoint(MainMemoryGraphicsItem const* originItem) const\r\n{\r\n    qreal lowestPoint = sceneBoundingRect().bottom();\r\n\r\n    if (MainMemoryGraphicsItem const* connectionStartItem = getConnectionStartItem(); !originItem || connectionStartItem != originItem)\r\n    {\r\n        qreal startItemLow = connectionStartItem->sceneBoundingRect().bottom();\r\n        if (startItemLow > lowestPoint)\r\n        {\r\n            lowestPoint = startItemLow;\r\n        }\r\n    }\r\n\r\n    if (MainMemoryGraphicsItem const* connectionEndItem = getConnectionEndItem(); !originItem || connectionEndItem != originItem)\r\n    {\r\n        qreal endItemLow = connectionEndItem->sceneBoundingRect().bottom();\r\n        if (endItemLow > lowestPoint)\r\n        {\r\n            lowestPoint = endItemLow;\r\n        }\r\n    }\r\n\r\n    return lowestPoint;\r\n}\r\n"
  },
  {
    "path": "editors/MemoryDesigner/MemoryConnectionItem.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: MemoryConnectionItem.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Mikko Teuho\r\n// Date: 16.08.2016\r\n//\r\n// Description:\r\n// Memory designer connection item.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef MEMORYCONNETIONITEM_H\r\n#define MEMORYCONNETIONITEM_H\r\n\r\nclass MainMemoryGraphicsItem;\r\nclass ConnectivityInterface;\r\n\r\n#include <QGraphicsPathItem>\r\n#include <QGraphicsTextItem>\r\n#include <QGraphicsScene>\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Memory designer connection item.\r\n//-----------------------------------------------------------------------------\r\nclass MemoryConnectionItem : public QGraphicsPathItem\r\n{\r\n\r\npublic:\r\n\r\n    /*!\r\n     *  The constructor.\r\n     *\r\n     *    @param [in] startItem           The start item of the connection.\r\n     *    @param [in] firstStartValue     Start address in the start item.\r\n     *    @param [in] firstEndValue       End address in the start item.\r\n     *    @param [in] secondStartValue    Start address in the end item.\r\n     *    @param [in] secondEndValue      End address in the end item.\r\n     *    @param [in] endItem             The end item of the connection.\r\n     *    @param [in] containingScene     Graphics scene containing the memory connection item.\r\n     *    @param [in] yTransfer           Y transfer of the memory connection.\r\n     *    @param [in] parent              Parent item of the connection.\r\n     */\r\n    MemoryConnectionItem(MainMemoryGraphicsItem* startItem,\r\n        quint64 firstStartValue,\r\n        quint64 firstEndValue,\r\n        quint64 secondStartValue,\r\n        quint64 secondEndvalue,\r\n        MainMemoryGraphicsItem* endItem,\r\n        QGraphicsScene* containingScene,\r\n        qreal yTransfer = 0,\r\n        QGraphicsItem* parent = 0);\r\n\r\n    // Disable copying.\r\n    MemoryConnectionItem(MemoryConnectionItem const& rhs) = delete;\r\n    MemoryConnectionItem& operator=(MemoryConnectionItem const& rhs) = delete;\r\n\r\n\t/*!\r\n     *  The Destructor.\r\n     */\r\n    virtual ~MemoryConnectionItem() = default;\r\n\r\n    /*!\r\n     *  Change the position relative to the connection start item.\r\n     *\t\r\n     *    @param [in] movementInY     Movement in the containig scene.\r\n     */\r\n    void moveItemBy(qreal const& movementInY);\r\n\r\n    /*!\r\n     *  Get the start value of the connection.\r\n     *\r\n     *    @return The start value of the connection.\r\n     */\r\n    quint64 getRangeStartValue() const;\r\n\r\n    /*!\r\n     *  Get the end value of the connection.\r\n     *\r\n     *    @return The end value of the connection.\r\n     */\r\n    quint64 getRangeEndValue() const;\r\n\r\n    /*!\r\n     *  Redraw the path of this connection.\r\n     */\r\n    void reDrawConnection();\r\n\r\n    /*!\r\n     *  Get the lowest point of the connection.\r\n     *\r\n     *    @return The lowest point of the connection item.\r\n     */\r\n    quint64 getSceneEndPoint() const;\r\n\r\n    /*!\r\n     *  Get the connected start memory item.\r\n     *\r\n     *    @return The connected start memory item.\r\n     */\r\n    MainMemoryGraphicsItem* getConnectionStartItem() const;\r\n\r\n    /*!\r\n     *  Get the connected end memory item.\r\n     *\r\n     *    @return The connected end memory item.\r\n     */\r\n    MainMemoryGraphicsItem* getConnectionEndItem() const;\r\n\r\n    /*!\r\n     *  Reposition range labels that are colliding with range labels of other memory connection items.\r\n     */\r\n    void repositionCollidingRangeLabels();\r\n\r\n    /*!\r\n     *  Check if the selected label collides with the range labels.\r\n     *\r\n     *    @param [in] label           The selected label.\r\n     *    @param [in] fontHeight      Height of the font used in the selected label.\r\n     *    @param [in] connectedItem   Owner of the selected label.\r\n     *\r\n     *    @return True, if the selected label collides with the range labels, false otherwise.\r\n     */\r\n    bool labelCollidesWithRanges(QGraphicsTextItem* label, qreal fontHeight,\r\n        const MainMemoryGraphicsItem* connectedItem) const;\r\n\r\n    /*!\r\n     *  Compress this and the connected end items to the selected coordinates.\r\n     *\t\r\n     *    @param [in] condensedItems              List of memory items that have been compressed.\r\n     *    @param [in] unCutCoordinates            List of the visible coordinates.\r\n     *    @param [in] CUTMODIFIER                 Maximum height for a compressed area.\r\n     *    @param [in] memoryItemsAreCompressed    Flag for compressing the memory items.\r\n     */\r\n    void compressToUnCutCoordinates(QVector<MainMemoryGraphicsItem*>& condensedItems,\r\n        QVector<qreal> unCutCoordinates, const qreal CUTMODIFIER, bool memoryItemsAreCompressed);\r\n\r\n    /*!\r\n     *  Move the connected memory items.\r\n     *\r\n     *    @param [in] movedItems      Memory items that have already been moved.\r\n     *    @param [in] movementOrigin  Origin of the movement.\r\n     *    @param [in] transferY       The amount to move in y-coordinate.\r\n     */\r\n    void moveConnectedItems(QSharedPointer<QVector<MainMemoryGraphicsItem*> > movedItems,\r\n        MainMemoryGraphicsItem* movementOrigin, qreal transferY);\r\n\r\n    /*!\r\n     *  Get the lowest point of the memory connection and the other connected memory item.\r\n     *\r\n     *    @param [in] originItem  The origin memory item.\r\n     */\r\n    qreal getConnectionLowPoint(MainMemoryGraphicsItem const* originItem) const;\r\n\r\nprivate:\r\n\r\n    /*!\r\n     *  Compress the contained end item using coordinates.\r\n     *\t\r\n     *    @param [in] condensedItems              Memory items that have already been condensed.\r\n     *    @param [in] unCutCoordinates            The addresses tha remain after the compression.\r\n     *    @param [in] CUTMODIFIER                 Modifier for the cut areas.\r\n     *    @param [in] memoryItemsAreCompressed    Flag for condensing memory items.\r\n     */\r\n    void compressEndItemToCoordinates(QVector<MainMemoryGraphicsItem*>& compressedItems,\r\n        QVector<qreal> unCutCoordinates, const qreal CUTMODIFIER, bool memoryItemsAreCompressed);\r\n\r\n    /*!\r\n     *  Set a new height for the memory connection.\r\n     *\r\n     *    @param [in] newHeight   The new height.\r\n     */\r\n    void setCondensedHeight(qreal newHeight);\r\n\r\n    /*!\r\n     *  Setup the range labels.\r\n     *\r\n     *    @param [in] leftStartValue    Base address of the connection on the starting item.\r\n     *    @param [in] leftEndValue      Last address of the connection on the starting item.\r\n     *    @param [in] rightStartValue   Base address of the connection on the ending item.\r\n     *    @param [in] rightEndValue     Last address of the connection on the ending item.\r\n     */\r\n    void setupLabels(quint64 const& leftStartValue, quint64 const& leftEndValue, quint64 const& rightStartValue, quint64 const& rightEndValue);\r\n\r\n    /*!\r\n     *  Create the connection path.\r\n     */\r\n    void createPath();\r\n\r\n    /*!\r\n     *  Avoid collisions on the connection path.\r\n     *\r\n     *    @param [in] highStartPoint  The top start point of the connection.\r\n     *    @param [in] highEndPoint    The top end point of the connection.\r\n     *    @param [in] lowStartPoint   The low start point of the connection.\r\n     *    @param [in] lowEndPoint     The low end point of the connection.\r\n     */\r\n    void avoidCollisionsOnPath(QPointF const& highStartPoint, QPointF const& highEndPoint,\r\n        QPointF const& lowStartPoint, QPointF const& lowEndPoint);\r\n\r\n    /*!\r\n     *  Create a collision path according to the collision points.\r\n     *\r\n     *    @param [in] highStartPoint          The top start point of the connection.\r\n     *    @param [in] highEndPoint            The top end point of the connection.\r\n     *    @param [in] lowStartPoint           The low start point of the connection.\r\n     *    @param [in] lowEndPoint             The low end point of the connection.\r\n     *    @param [in] highCollisionPoints     Map containing the top collision points of the connection item.\r\n     *    @param [in] lowCollisionPoints      Map containing the low collision points of the connection item.\r\n     */\r\n    void createCollisionPath(QPointF highStartPoint, QPointF highEndPoint, QPointF lowStartPoint,\r\n        QPointF lowEndPoint, QMultiMap<qreal, QPair<QPointF, QPointF> > highCollisionPoints,\r\n        QMultiMap<qreal, QPair<QPointF, QPointF> > lowCollisionPoints);\r\n\r\n    /*!\r\n     *  Reposition the connection labels.\r\n     */\r\n    void repositionLabels();\r\n\r\n    /*!\r\n     *  Get the width of the connection.\r\n     *\r\n     *    @return The width of the connection.\r\n     */\r\n    qreal getConnectionWidth() const;\r\n\r\n    /*!\r\n     *  Reposition a single colliding range label.\r\n     *\r\n     *    @param [in] textLabel   The selected range label.\r\n     */\r\n    void repositionSingleRangeLabel(QGraphicsTextItem* rangeLabel) const;\r\n\r\n    /*!\r\n     *  Create a path for the memory connection.\r\n     *\r\n     *    @param [in] highStartPoint  High start point of the memory connection.\r\n     *    @param [in] highEndPoint    High end point of the memory connection.\r\n     *    @param [in] lowStartPoint   Low start point of the memory connection.\r\n     *    @param [in] lowEndPoint     Low end point of the memory connection.\r\n     *    @param [in] LINEWIDTH       Line width of the memory connection.\r\n     *\r\n     *    @return The created painter path.\r\n     */\r\n    QPainterPath createConnectionPath(QPointF const& highStartPoint, QPointF const& highEndPoint,\r\n        QPointF const& lowStartPoint, QPointF const& lowEndPoint, int const& LINEWIDTH);\r\n\r\n    /*!\r\n     *  Move the connected items without moving connected memory connections.\r\n     *\r\n     *    @param [in] movedItems      Memory items that have already been moved.\r\n     *    @param [in] movementOrigin  Origin of the movement.\r\n     *    @param [in] connectedItem   The item to be moved.\r\n     *    @param [in] transferY       The amount to move in y-coordinate.\r\n     */\r\n    void moveConnectedItemWithoutConnections(QSharedPointer<QVector<MainMemoryGraphicsItem*> > movedItems,\r\n        MainMemoryGraphicsItem const* movementOrigin, MainMemoryGraphicsItem* connectedItem, qreal transferY);\r\n\r\n    /*!\r\n     *  Check if this connection is between an address space and its local memory map.\r\n     *\r\n     *    @return True, if the connection is a local memory map connection.\r\n     */\r\n    bool isLocalMapConnection() const;\r\n\r\n    /*!\r\n     *  Create a path for a local memory map connection or an address space connection avoiding colliding items.\r\n     *\r\n     *    @param [in] connectionIsLocal       Flag for identifying the connection type.\r\n     *    @param [in] highStartPoint          High start point of the connection.\r\n     *    @param [in] highEndPoint            High end point of the connection.\r\n     *    @param [in] lowStartPoint           Low start point of the connection.\r\n     *    @param [in] lowEndPoint             Low end point of the connection.\r\n     *    @param [in] highCollisionPoints     High collision points.\r\n     *    @param [in] lowCollisionPoints      Low collision points.\r\n     *\r\n     *    @return The memory connection path for local memory connection and address space connection with the\r\n     *              colliding lines removed.\r\n     */\r\n    QPainterPath createCollidingPathForUnusualConnection(bool connectionIsLocal, QPointF highStartPoint,\r\n        QPointF highEndPoint, QPointF lowStartPoint, QPointF lowEndPoint,\r\n        QMultiMap<qreal, QPair<QPointF, QPointF> > highCollisionPoints = QMultiMap<qreal, QPair<QPointF, QPointF> >(),\r\n        QMultiMap<qreal, QPair<QPointF, QPointF> > lowCollisionPoints = QMultiMap<qreal, QPair<QPointF, QPointF> >());\r\n\r\n    /*!\r\n     *  Erase the colliding lines from the memory connection.\r\n     *\r\n     *    @param [in] collisionPath       The selected memory connection path.\r\n     *    @param [in] collisionBegin      Start point of the colliding connection line.\r\n     *    @param [in] collisionPoints     List of the colliding points.\r\n     *\r\n     *    @return The memory connection path with the colliding lines removed.\r\n     */\r\n    QPainterPath eraseCollisionsFromPath(QPainterPath collisionPath, QPointF collisionBegin,\r\n        QMultiMap<qreal, QPair<QPointF, QPointF> > collisionPoints);\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! The label containing the first item start range.\r\n    QGraphicsTextItem* firstItemStartLabel_;\r\n\r\n    //! The label containing the first item end range.\r\n    QGraphicsTextItem* firstItemEndLabel_;\r\n\r\n    //! The label containing the second item start range.\r\n    QGraphicsTextItem* secondItemStartLabel_;\r\n\r\n    //! The label containing the second item end range.\r\n    QGraphicsTextItem* secondItemEndLabel_;\r\n\r\n    //! The connection start memory graphics item.\r\n    MainMemoryGraphicsItem* startItem_;\r\n\r\n    //! The connection end memory graphics item.\r\n    MainMemoryGraphicsItem* endItem_;\r\n\r\n    //! Connection start range.\r\n    quint64 connectionBaseAddress_;\r\n\r\n    //! Connection end range.\r\n    quint64 connectionLastAddress_;\r\n\r\n    //! Width of the memory connection item.\r\n    qreal connectionWidth_;\r\n\r\n    //! Y transfer of the connection.\r\n    qreal yTransfer_;\r\n\r\n    //! The connection line modifier used in the unusual memory connections.\r\n    const int BRIDGEMODIFIER_ = 10;\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n\r\n\r\n#endif // MEMORYCONNETIONITEM_H\r\n"
  },
  {
    "path": "editors/MemoryDesigner/MemoryDesignConstructor.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: MemoryDesignConstructor.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 02.01.2017\n//\n// Description:\n// Constructs the items for the memory design diagram.\n//-----------------------------------------------------------------------------\n\n#include \"MemoryDesignConstructor.h\"\n\n#include <common/graphicsItems/GraphicsColumnLayout.h>\n\n#include <editors/MemoryDesigner/MemoryColumnHandler.h>\n#include <editors/MemoryDesigner/MemoryGraphicsItemHandler.h>\n#include <editors/MemoryDesigner/MemoryConnectionHandler.h>\n#include <editors/MemoryDesigner/MemoryDesignerConstants.h>\n#include <editors/MemoryDesigner/MemoryColumn.h>\n\n//-----------------------------------------------------------------------------\n// Function: MemoryDesignConstructor::MemoryDesignConstructor()\n//-----------------------------------------------------------------------------\nMemoryDesignConstructor::MemoryDesignConstructor(QSharedPointer<GraphicsColumnLayout> layout):\nQObject(),\ncolumnHandler_(new MemoryColumnHandler(layout)),\nitemHandler_(new MemoryGraphicsItemHandler()),\nconnectionHandler_(new MemoryConnectionHandler(columnHandler_, itemHandler_)),\nwidthBoundary_(0)\n{\n    connect(itemHandler_.data(), SIGNAL(openComponentDocument(VLNV const&, QVector<QString>)),\n        this, SIGNAL(openComponentDocument(VLNV const&, QVector<QString>)), Qt::UniqueConnection);\n}\n\n//-----------------------------------------------------------------------------\n// Function: MemoryDesignConstructor::~MemoryDesignConstructor()\n//-----------------------------------------------------------------------------\nMemoryDesignConstructor::~MemoryDesignConstructor()\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: MemoryDesignConstructor::setCondenseMemoryItems()\n//-----------------------------------------------------------------------------\nvoid MemoryDesignConstructor::setCondenseMemoryItems(bool condenseMemoryItems)\n{\n    connectionHandler_->setCondenseMemoryItems(condenseMemoryItems);\n}\n\n//-----------------------------------------------------------------------------\n// Function: MemoryDesignConstructor::memoryItemsAreCondensed()\n//-----------------------------------------------------------------------------\nbool MemoryDesignConstructor::memoryItemsAreCondensed() const\n{\n    return connectionHandler_->memoryItemsAreCondensed();\n}\n\n//-----------------------------------------------------------------------------\n// Function: MemoryDesignConstructor::setFilterAddressSpaceChains()\n//-----------------------------------------------------------------------------\nvoid MemoryDesignConstructor::setFilterAddressSpaceChains(bool filterChains)\n{\n    connectionHandler_->setFilterAddressSpaceChains(filterChains);\n}\n\n//-----------------------------------------------------------------------------\n// Function: MemoryDesignConstructor::addressSpaceChainsAreFiltered()\n//-----------------------------------------------------------------------------\nbool MemoryDesignConstructor::addressSpaceChainsAreFiltered() const\n{\n    return connectionHandler_->addressSpaceChainsAreFiltered();\n}\n\n//-----------------------------------------------------------------------------\n// Function: MemoryDesignConstructor::condenseFieldItems()\n//-----------------------------------------------------------------------------\nvoid MemoryDesignConstructor::condenseFieldItems()\n{\n    if (!addressBlockRegistersAreFiltered() && !fieldsAreFiltered()  && widthBoundary_ > 0)\n    {\n        changeMemoryMapWidths(-widthBoundary_);\n        widthBoundary_ = 0;\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: MemoryDesignConstructor::extendFieldItems()\n//-----------------------------------------------------------------------------\nvoid MemoryDesignConstructor::extendFieldItems()\n{\n    if (!addressBlockRegistersAreFiltered() && !fieldsAreFiltered())\n    {\n        qreal widthChange = 0;\n\n        foreach (MemoryColumn* memoryColumn, columnHandler_->getMemoryMapColumns())\n        {\n            widthChange = qMax(widthChange, memoryColumn->getMaximumNeededChangeInWidth());\n        }\n\n        if (widthChange > widthBoundary_)\n        {\n            int futureColumnWidth = columnHandler_->getMemoryMapColumnWidth() + widthChange;\n            int widthRemainder = futureColumnWidth % 10;\n            if (widthRemainder != 9)\n            {\n                widthRemainder = 9 - widthRemainder;\n                widthChange += widthRemainder;\n            }\n\n            changeMemoryMapWidths(widthChange);\n            widthBoundary_ += widthChange;\n        }\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: MemoryDesignConstructor::setFilterAddressSpaceSegments()\n//-----------------------------------------------------------------------------\nvoid MemoryDesignConstructor::setFilterAddressSpaceSegments(bool filterSegments)\n{\n    itemHandler_->setFilterAddressSpaceSegments(filterSegments);\n}\n\n//-----------------------------------------------------------------------------\n// Function: MemoryDesignConstructor::addressSpaceSegmentsAreFiltered()\n//-----------------------------------------------------------------------------\nbool MemoryDesignConstructor::addressSpaceSegmentsAreFiltered() const\n{\n    return itemHandler_->addressSpaceSegmentsAreFiltered();\n}\n\n//-----------------------------------------------------------------------------\n// Function: MemoryDesignConstructor::setFilterAddressBlocks()\n//-----------------------------------------------------------------------------\nvoid MemoryDesignConstructor::setFilterAddressBlocks(bool filterBlocks)\n{\n    itemHandler_->setFilterAddressBlocks(filterBlocks);\n}\n\n//-----------------------------------------------------------------------------\n// Function: MemoryDesignConstructor::addressBlocksAreFiltered()\n//-----------------------------------------------------------------------------\nbool MemoryDesignConstructor::addressBlocksAreFiltered() const\n{\n    return itemHandler_->addressBlocksAreFiltered();\n}\n\n//-----------------------------------------------------------------------------\n// Function: MemoryDesignConstructor::setFilterAddressBlockRegisters()\n//-----------------------------------------------------------------------------\nvoid MemoryDesignConstructor::setFilterAddressBlockRegisters(bool filterRegisters)\n{\n    itemHandler_->setFilterAddressBlockRegisters(filterRegisters);\n}\n\n//-----------------------------------------------------------------------------\n// Function: MemoryDesignConstructor::addressBlockRegistersAreFiltered()\n//-----------------------------------------------------------------------------\nbool MemoryDesignConstructor::addressBlockRegistersAreFiltered() const\n{\n    return itemHandler_->addressBlockRegistersAreFiltered();\n}\n\n//-----------------------------------------------------------------------------\n// Function: MemoryDesignConstructor::setFilterFields()\n//-----------------------------------------------------------------------------\nvoid MemoryDesignConstructor::setFilterFields(bool filterFields)\n{\n    itemHandler_->setFilterFields(filterFields);\n}\n\n//-----------------------------------------------------------------------------\n// Function: MemoryDesignConstructor::fieldsAreFiltered()\n//-----------------------------------------------------------------------------\nbool MemoryDesignConstructor::fieldsAreFiltered() const\n{\n    return itemHandler_->fieldsAreFiltered();\n}\n\n//-----------------------------------------------------------------------------\n// Function: MemoryDesignConstructor::filterUnconnectedMemoryItems()\n//-----------------------------------------------------------------------------\nvoid MemoryDesignConstructor::filterUnconnectedMemoryItems(bool filterUnconnected)\n{\n    itemHandler_->filterUnconnectedMemoryItems(filterUnconnected);\n}\n\n//-----------------------------------------------------------------------------\n// Function: MemoryDesignConstructor::unconnectedMemoryItemsAreFiltered()\n//-----------------------------------------------------------------------------\nbool MemoryDesignConstructor::unconnectedMemoryItemsAreFiltered() const\n{\n    return itemHandler_->unconnectedMemoryItemsAreFiltered();\n}\n\n//-----------------------------------------------------------------------------\n// Function: MemoryDesignConstructor::filterMemoryOverlapItems()\n//-----------------------------------------------------------------------------\nvoid MemoryDesignConstructor::filterMemoryOverlapItems(bool filterOverlap)\n{\n    itemHandler_->filterMemoryOverlapItems(filterOverlap);\n}\n\n//-----------------------------------------------------------------------------\n// Function: MemoryDesignConstructor::memoryOverlapItemsAreFiltered()\n//-----------------------------------------------------------------------------\nbool MemoryDesignConstructor::memoryOverlapItemsAreFiltered() const\n{\n    return itemHandler_->memoryOverlapItemsAreFiltered();\n}\n\n//-----------------------------------------------------------------------------\n// Function: MemoryDesignConstructor::constructMemoryDesignItems()\n//-----------------------------------------------------------------------------\nbool MemoryDesignConstructor::constructMemoryDesignItems(QSharedPointer<ConnectivityGraph> connectionGraph)\n{\n    connectionHandler_->clearConnectionLists();\n    widthBoundary_ = 0;\n\n    if (connectionGraph)\n    {\n        int visibleMultiplier = 10;\n        int columnExtension = floor((MemoryDesignerConstants::MAPSUBITEMPOSITIONX * 2 + visibleMultiplier / 2) / visibleMultiplier) * visibleMultiplier;\n\n        if (itemHandler_->addressBlockRegistersAreFiltered() ||\n            (itemHandler_->addressBlocksAreFiltered() && itemHandler_->fieldsAreFiltered()))\n        {\n            columnHandler_->setNewMemoryMapColumnWidth(MemoryDesignerConstants::SPACECOLUMNWIDTH);\n        }\n\n        else if (itemHandler_->fieldsAreFiltered())\n        {\n            columnHandler_->setNewMemoryMapColumnWidth(MemoryDesignerConstants::SPACECOLUMNWIDTH + columnExtension);\n        }\n        else if (itemHandler_->addressBlocksAreFiltered())\n        {\n            columnHandler_->setNewMemoryMapColumnWidth(MemoryDesignerConstants::MEMORYMAPCOLUMNWIDTH - columnExtension);\n        }\n        else\n        {\n            columnHandler_->setNewMemoryMapColumnWidth(MemoryDesignerConstants::MEMORYMAPCOLUMNWIDTH);\n        }\n\n        columnHandler_->createInitialColumns();\n\n        MemoryColumn* addressSpaceColumn =\n            columnHandler_->findColumnByName(MemoryDesignerConstants::ADDRESSSPACECOLUMN_NAME);\n        MemoryColumn* memoryMapColumn =\n            columnHandler_->findColumnByName(MemoryDesignerConstants::MEMORYMAPCOLUM_NAME);\n        if (addressSpaceColumn && memoryMapColumn)\n        {\n            itemHandler_->createMemoryItems(connectionGraph, addressSpaceColumn, memoryMapColumn);\n            connectionHandler_->createConnectedItems(connectionGraph, addressSpaceColumn, memoryMapColumn);\n            filterMemoryOverlapItems(memoryOverlapItemsAreFiltered());\n            \n            itemHandler_->createFieldOverlapItems();\n\n            filterUnconnectedMemoryItems(unconnectedMemoryItemsAreFiltered());\n\n            return true;\n        }\n    }\n\n    return false;\n}\n\n//-----------------------------------------------------------------------------\n// Function: MemoryDesignConstructor::setNewLayout()\n//-----------------------------------------------------------------------------\nvoid MemoryDesignConstructor::setNewLayout(QSharedPointer<GraphicsColumnLayout> newLayout)\n{\n    columnHandler_->setNewLayout(newLayout);\n}\n\n//-----------------------------------------------------------------------------\n// Function: MemoryDesignConstructor::getWidthBoundary()\n//-----------------------------------------------------------------------------\nint MemoryDesignConstructor::getWidthBoundary() const\n{\n    return widthBoundary_;\n}\n\n//-----------------------------------------------------------------------------\n// Function: MemoryDesignConstructor::setNewWidthBoundary()\n//-----------------------------------------------------------------------------\nvoid MemoryDesignConstructor::setNewWidthBoundary(int newWidthBoundary)\n{\n    widthBoundary_ = newWidthBoundary;\n}\n\n//-----------------------------------------------------------------------------\n// Function: MemoryDesignConstructor::changeWidths()\n//-----------------------------------------------------------------------------\nvoid MemoryDesignConstructor::changeMemoryMapWidths(qreal deltaWidth)\n{\n    columnHandler_->changeColumnWidths(deltaWidth);\n    connectionHandler_->reDrawConnectionsAndCollisions();\n}\n"
  },
  {
    "path": "editors/MemoryDesigner/MemoryDesignConstructor.h",
    "content": "//-----------------------------------------------------------------------------\n// File: MemoryDesignConstructor.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 02.01.2017\n//\n// Description:\n// Constructs the items for the memory design diagram.\n//-----------------------------------------------------------------------------\n\n#ifndef MEMORYDESIGNCONSTRUCTOR_H\n#define MEMORYDESIGNCONSTRUCTOR_H\n\n#include <IPXACTmodels/common/VLNV.h>\n\n#include <common/graphicsItems/GraphicsColumnLayout.h>\n\n#include <editors/MemoryDesigner/ConnectivityGraphFactory.h>\n\n#include <QSharedPointer>\n#include <QObject>\n\nclass MemoryColumnHandler;\nclass MemoryGraphicsItemHandler;\nclass MemoryConnectionHandler;\n\n//-----------------------------------------------------------------------------\n//! Constructs the items for the memory design diagram.\n//-----------------------------------------------------------------------------\nclass MemoryDesignConstructor : public QObject\n{\n    Q_OBJECT\n\npublic:\n\n    /*!\n     *  The constructor.\n     *\n     *    @param [in] layout  Layout for the memory graphics items.\n     */    \n    MemoryDesignConstructor(QSharedPointer<GraphicsColumnLayout> layout);\n\n    /*!\n     *  The destructor.\n     */\n    ~MemoryDesignConstructor();\n\n    /*!\n     *  Change the condensing of memory graphics items.\n     *\n     *    @param [in] condenseItems   Value for condensing memory graphics items.\n     */\n    void setCondenseMemoryItems(bool condenseMemoryItems);\n\n    /*!\n     *  Check whether the memory graphics items are condensed or not.\n     *\n     *    @return True, if the memory graphics items are condensed, otherwise false.\n     */\n    bool memoryItemsAreCondensed() const;\n\n    /*!\n     *  Set the filtering for chained address space memory connections.\n     *\n     *    @param [in] filterChains    Value for the chained address space memory connection filtering.\n     */\n    void setFilterAddressSpaceChains(bool filterChains);\n\n    /*!\n     *  Check whether the chained address space memory connections are filtered or not.\n     *\n     *    @return True, if the chained address space memory connections are filtered, false otherwise.\n     */\n    bool addressSpaceChainsAreFiltered() const;\n\n    /*!\n     *  Condense all the field graphics items to their original width.\n     */\n    void condenseFieldItems();\n\n    /*!\n     *  Extend all the field graphics items to fully display their name label.\n     */\n    void extendFieldItems();\n\n    /*!\n     *  Set a new value for filtering the address space segments.\n     *\n     *    @param [in] filterSegments  Value for filtering address space segments.\n     */\n    void setFilterAddressSpaceSegments(bool filterSegments);\n\n    /*!\n     *  Check if the address space segments are filtered.\n     *\n     *    @return True, if the address space segments are filtered, false otherwise.\n     */\n    bool addressSpaceSegmentsAreFiltered() const;\n\n    /*!\n     *  Set a new value for filtering the address blocks.\n     *\n     *    @param [in] filterBlocks    Value for filtering address blocks.\n     */\n    void setFilterAddressBlocks(bool filterBlocks);\n\n    /*!\n     *  Check if the address blocks are filtered.\n     *\n     *    @return True, if the address blocks are filtered, false otherwise.\n     */\n    bool addressBlocksAreFiltered() const;\n\n    /*!\n     *  Set a new value for filtering the address block registers.\n     *\n     *    @param [in] filterSegments  Value for filtering address block registers.\n     */\n    void setFilterAddressBlockRegisters(bool filterRegisters);\n\n    /*!\n     *  Check if the address block registers are filtered.\n     *\n     *    @return True, if the address block registers are filtered, false otherwise.\n     */\n    bool addressBlockRegistersAreFiltered() const;\n\n    /*!\n     *  Set a new value for filtering the register fields.\n     *\n     *    @param [in] filterFields    Value for filtering register fields.\n     */\n    void setFilterFields(bool filterFields);\n\n    /*!\n     *  Check if the register fields are filtered.\n     *\n     *    @return True, if the register fields are filtered, false otherwise.\n     */\n    bool fieldsAreFiltered() const;\n\n    /*!\n     *  Set a new value for filtering the unconnected memory items.\n     *\n     *    @param [in] filterUnconnected   Value for filtering unconnected memory items.\n     */\n    void filterUnconnectedMemoryItems(bool filterUnconnected);\n\n    /*!\n     *  Check if the unconnected memory items are filtered.\n     *\n     *    @return True, if the unconnected memory items are filtered, false otherwise.\n     */\n    bool unconnectedMemoryItemsAreFiltered() const;\n\n    /*!\n     *  Set a new value for filtering the memory overlap items.\n     *\n     *    @param [in] filterOverlap       Value for filtering memory overlap.\n     */\n    void filterMemoryOverlapItems(bool filterOverlap);\n\n    /*!\n     *  Check if the memory overlap items are filtered.\n     *\n     *    @return True, if the memory overlap items are filtered, false otherwise.\n     */\n    bool memoryOverlapItemsAreFiltered() const;\n\n    /*!\n     *  Construct memory design items from the selected connection graph.\n     *\n     *    @param [in] connectionGraph     Connection graph containing connection routes.\n     *\n     *    @return True, if memory items can be created from the graph, false otherwise.\n     */\n    bool constructMemoryDesignItems(QSharedPointer<ConnectivityGraph> connectionGraph);\n\n    /*!\n     *  Set a new graphics layout for the memory graphics items.\n     *\n     *    @param [in] newLayout   The new graphics layout.\n     */\n    void setNewLayout(QSharedPointer<GraphicsColumnLayout> newLayout);\n\n    /*!\n     *  Get the current width change from the original widths.\n     */\n    int getWidthBoundary() const;\n    \n    /*!\n     *  Set a new width change.\n     *\n     *    @param [in] newWidthBoundary    The new width change.\n     */\n    void setNewWidthBoundary(int newWidthBoundary);\n\n    /*!\n     *  Change the width of the memory map columns and their contained memory map graphics items.\n     *\n     *    @param [in] deltaWidth  The change in width.\n     */\n    void changeMemoryMapWidths(qreal deltaWidth);\n\nsignals:\n\n    /*!\n     *  Open the component document for the selected VLNV.\n     *\n     *    @param [in] vlnv                VLNV of the containing component.\n     *    @param [in] identifierChain     List of strings to identify the component item.\n     */\n    void openComponentDocument(VLNV const& vlnv, QVector<QString> identifierChain);\n\nprivate:\n    // Disable copying.\n    MemoryDesignConstructor(MemoryDesignConstructor const& rhs);\n    MemoryDesignConstructor& operator=(MemoryDesignConstructor const& rhs);\n\n    //-----------------------------------------------------------------------------\n    // Data.\n    //-----------------------------------------------------------------------------\n\n    //! Handler for memory columns.\n    QSharedPointer<MemoryColumnHandler> columnHandler_;\n\n    //! Handler for memory graphics items.\n    QSharedPointer<MemoryGraphicsItemHandler> itemHandler_;\n\n    //! Handler for memory connections.\n    QSharedPointer<MemoryConnectionHandler> connectionHandler_;\n\n    //! The current width change from the original widths.\n    qreal widthBoundary_;\n};\n\n//-----------------------------------------------------------------------------\n\n#endif // MEMORYDESIGNCONSTRUCTOR_H\n"
  },
  {
    "path": "editors/MemoryDesigner/MemoryDesignDocument.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: MemoryDesignDocument.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Mikko Teuho\r\n// Date: 06.07.2016\r\n//\r\n// Description:\r\n// Declares the memory design tab document class.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"MemoryDesignDocument.h\"\r\n\r\n#include <editors/common/ImageExporter.h>\r\n\r\n#include <editors/MemoryDesigner/MemoryDesignerDiagram.h>\r\n\r\n#include <KactusAPI/include/LibraryInterface.h>\r\n\r\n#include <IPXACTmodels/common/VLNV.h>\r\n#include <IPXACTmodels/Design/Design.h>\r\n#include <IPXACTmodels/Component/Component.h>\r\n\r\n#include <QScrollBar>\r\n#include <QVBoxLayout>\r\n#include <QApplication>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryDesignDocument::MemoryDesignDocument()\r\n//-----------------------------------------------------------------------------\r\nMemoryDesignDocument::MemoryDesignDocument(LibraryInterface* libHandler, QWidget* parent):\r\nTabDocument(parent, libHandler, DOC_ZOOM_SUPPORT | DOC_PRINT_SUPPORT, 30, 300),\r\nview_(new QGraphicsView(this)),\r\ndiagram_(new MemoryDesignerDiagram(libHandler, this)),\r\nidentifyingVLNV_(),\r\ndesignViewName_()\r\n{\r\n    connect(diagram_, SIGNAL(openComponentDocument(VLNV const&, QVector<QString>)),\r\n        this, SIGNAL(openComponentDocument(VLNV const&, QVector<QString>)), Qt::UniqueConnection);\r\n\r\n    view_->setViewportUpdateMode(QGraphicsView::FullViewportUpdate);\r\n    view_->setTransformationAnchor(QGraphicsView::AnchorUnderMouse);\r\n\r\n    QVBoxLayout* layout = new QVBoxLayout(this);\r\n    layout->addWidget(view_);\r\n\r\n    view_->setAlignment(Qt::AlignLeft | Qt::AlignTop);\r\n    view_->verticalScrollBar()->setTracking(true);\r\n    connect(view_->verticalScrollBar(), SIGNAL(valueChanged(int)), this, SLOT(onVerticalScroll(int)));\r\n\r\n    view_->setScene(diagram_);\r\n\r\n    centerViewTo(QPointF(0,0)); \r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryDesignDocument::~MemoryDesignDocument()\r\n//-----------------------------------------------------------------------------\r\nMemoryDesignDocument::~MemoryDesignDocument()\r\n{\r\n    view_->verticalScrollBar()->disconnect(this);\r\n\r\n    if (diagram_)\r\n    {\r\n        delete diagram_;\r\n        diagram_ = 0;\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryDesignDocument::refresh()\r\n//-----------------------------------------------------------------------------\r\nvoid MemoryDesignDocument::refresh()\r\n{\r\n    diagram_->clearScene();\r\n    setDesign(identifyingVLNV_, designViewName_);\r\n\r\n    TabDocument::refresh();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryDesignDocument::setDesign()\r\n//-----------------------------------------------------------------------------\r\nbool MemoryDesignDocument::setDesign(VLNV const& componentVLNV, QString const& viewName)\r\n{\r\n    QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));\r\n\r\n    bool designSetupSuccessfull = false;\r\n\r\n    if (componentVLNV.isValid() && componentVLNV.getType() == VLNV::COMPONENT && !viewName.isEmpty())\r\n    {\r\n        identifyingVLNV_ = componentVLNV;\r\n\r\n        setDocumentName(QString(\"%1 (%2)\").\r\n            arg(getIdentifyingVLNV().getName()).\r\n            arg(getIdentifyingVLNV().getVersion()));\r\n        setDocumentType(DocumentType::MEMORY_DESIGN);\r\n\r\n        QSharedPointer<const Document> libraryDocument = getLibHandler()->getModelReadOnly(componentVLNV);\r\n        QSharedPointer<const Component> component = libraryDocument.dynamicCast<const Component>();\r\n        if (component)\r\n        {\r\n            if (diagram_->loadDesignFromCurrentView(component, viewName))\r\n            {\r\n                designViewName_ = viewName;\r\n                designSetupSuccessfull = true;\r\n            }\r\n            else\r\n            {\r\n                emit errorMessage(QString(\"Could not setup memory design from %1.\").arg(componentVLNV.toString()));\r\n            }\r\n        }\r\n        else\r\n        {\r\n            emit errorMessage(QString(\"Could not find component %1.\").arg(componentVLNV.toString()));\r\n        }\r\n\r\n    }\r\n    else\r\n    {\r\n        emit errorMessage(QString(\"Selected VLNV %1 is not valid.\").arg(componentVLNV.toString()));\r\n    }\r\n\r\n    QApplication::restoreOverrideCursor();\r\n\r\n    return designSetupSuccessfull;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryDesignDocument::getSupportedDrawModes()\r\n//-----------------------------------------------------------------------------\r\nunsigned int MemoryDesignDocument::getSupportedDrawModes() const\r\n{\r\n    return MODE_SELECT;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryDesignDocument::getIdentifyingVLNV()\r\n//-----------------------------------------------------------------------------\r\nVLNV MemoryDesignDocument::getIdentifyingVLNV() const\r\n{\r\n    return identifyingVLNV_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryDesignDocument::getDocumentVLNV()\r\n//-----------------------------------------------------------------------------\r\nVLNV MemoryDesignDocument::getDocumentVLNV() const\r\n{\r\n    return identifyingVLNV_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryDesignDocument::setVisibilityControlState()\r\n//-----------------------------------------------------------------------------\r\nvoid MemoryDesignDocument::setVisibilityControlState(QString const& name, bool state)\r\n{\r\n    TabDocument::setVisibilityControlState(name, state);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryDesignDocument::setZoomLevel()\r\n//-----------------------------------------------------------------------------\r\nvoid MemoryDesignDocument::setZoomLevel(int level)\r\n{\r\n    TabDocument::setZoomLevel(level);\r\n\r\n    double newScale = getZoomLevel() / 100.0;\r\n    QTransform oldMatrix = view_->transform();\r\n\r\n    view_->resetTransform();\r\n    view_->translate(oldMatrix.dx(), oldMatrix.dy());\r\n    view_->scale(newScale, newScale);\r\n\r\n    emit zoomChanged();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryDesignDocument::fitInView()\r\n//-----------------------------------------------------------------------------\r\nvoid MemoryDesignDocument::fitInView()\r\n{\r\n    QRectF itemRect = diagram_->itemsBoundingRect();\r\n    float scaleX = qMax(0, view_->width() - 10 - view_->verticalScrollBar()->width()) / itemRect.width();\r\n    float scaleY = qMax(0, view_->height() - 10 - view_->horizontalScrollBar()->height()) / itemRect.width();\r\n\r\n    int scaleLevel = int(qMin(scaleX, scaleY) * 10) * 10;\r\n    setZoomLevel(scaleLevel);\r\n\r\n    centerViewTo(itemRect.center());\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryDesignDocument::centerViewTo()\r\n//-----------------------------------------------------------------------------\r\nvoid MemoryDesignDocument::centerViewTo(QPointF const& centerPoint)\r\n{\r\n    view_->centerOn(centerPoint);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryDesignDocument::onVerticalScroll()\r\n//-----------------------------------------------------------------------------\r\nvoid MemoryDesignDocument::onVerticalScroll(int y)\r\n{\r\n//     QPointF pt(0.0, y);\r\n//     QTransform mat = view_->transform().inverted();\r\n//     diagram_->onVerticalScroll(mat.map(pt).y());\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryDesignDocument::showEvent()\r\n//-----------------------------------------------------------------------------\r\nvoid MemoryDesignDocument::showEvent(QShowEvent* event)\r\n{\r\n    emit helpUrlRequested(QLatin1String(\"memoryDesign/memoryDesign.html\"));\r\n    TabDocument::showEvent(event);\r\n    diagram_->onShow();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryDesignDocument::setProtection()\r\n//-----------------------------------------------------------------------------\r\nvoid MemoryDesignDocument::setProtection(bool /*locked*/)\r\n{\r\n    TabDocument::setProtection(false);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryDesignDocument::setCondenseMemoryItems()\r\n//-----------------------------------------------------------------------------\r\nvoid MemoryDesignDocument::setCondenseMemoryItems(bool condenseItems)\r\n{\r\n    diagram_->setCondenseMemoryItems(condenseItems);\r\n    refresh();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryDesignDocument::memoryItemsAreCondensed()\r\n//-----------------------------------------------------------------------------\r\nbool MemoryDesignDocument::memoryItemsAreCondensed() const\r\n{\r\n    return diagram_->memoryItemsAreCondensed();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryDesignDocument::filterAddressSpaces()\r\n//-----------------------------------------------------------------------------\r\nvoid MemoryDesignDocument::filterAddressSpaceChains(bool filterChains)\r\n{\r\n    diagram_->setFilterAddressSpaceChains(filterChains);\r\n    refresh();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryDesignDocument::addressSpaceChainsAreFiltered()\r\n//-----------------------------------------------------------------------------\r\nbool MemoryDesignDocument::addressSpaceChainsAreFiltered() const\r\n{\r\n    return diagram_->addressSpaceChainsAreFiltered();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryDesignDocument::condenseFieldItems()\r\n//-----------------------------------------------------------------------------\r\nvoid MemoryDesignDocument::condenseFieldItems()\r\n{\r\n    diagram_->condenseFieldItems();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryDesignDocument::extendFieldItems()\r\n//-----------------------------------------------------------------------------\r\nvoid MemoryDesignDocument::extendFieldItems()\r\n{\r\n    diagram_->extendFieldItems();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryDesignDocument::filterAddressSpaceSegments()\r\n//-----------------------------------------------------------------------------\r\nvoid MemoryDesignDocument::filterAddressSpaceSegments(bool filterSegments)\r\n{\r\n    diagram_->setFilterAddressSpaceSegments(filterSegments);\r\n    refresh();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryDesignDocument::addressSpaceSegmentsAreFilterted()\r\n//-----------------------------------------------------------------------------\r\nbool MemoryDesignDocument::addressSpaceSegmentsAreFilterted() const\r\n{\r\n    return diagram_->addressSpaceSegmentsAreFiltered();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryDesignDocument::filterAddressBlocks()\r\n//-----------------------------------------------------------------------------\r\nvoid MemoryDesignDocument::filterAddressBlocks(bool filterBlocks)\r\n{\r\n    diagram_->setFilterAddressBlocks(filterBlocks);\r\n    refresh();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryDesignDocument::addressBlocksAreFiltered()\r\n//-----------------------------------------------------------------------------\r\nbool MemoryDesignDocument::addressBlocksAreFiltered() const\r\n{\r\n    return diagram_->addressBlocksAreFiltered();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryDesignDocument::filterAddressBlockRegisters()\r\n//-----------------------------------------------------------------------------\r\nvoid MemoryDesignDocument::filterAddressBlockRegisters(bool filterRegisters)\r\n{\r\n    diagram_->setFilterAddressBlockRegisters(filterRegisters);\r\n    refresh();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryDesignDocument::addressBlockRegistersAreFiltered()\r\n//-----------------------------------------------------------------------------\r\nbool MemoryDesignDocument::addressBlockRegistersAreFiltered() const\r\n{\r\n    return diagram_->addressBlockRegistersAreFiltered();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryDesignDocument::filterFields()\r\n//-----------------------------------------------------------------------------\r\nvoid MemoryDesignDocument::filterFields(bool filterFields)\r\n{\r\n    diagram_->setFilterFields(filterFields);\r\n    refresh();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryDesignDocument::fieldsAreFiltered()\r\n//-----------------------------------------------------------------------------\r\nbool MemoryDesignDocument::fieldsAreFiltered() const\r\n{\r\n    return diagram_->fieldsAreFiltered();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryDesignDocument::unconnectedMemoryItemsAreFiltered()\r\n//-----------------------------------------------------------------------------\r\nbool MemoryDesignDocument::unconnectedMemoryItemsAreFiltered() const\r\n{\r\n    return diagram_->unconnectedMemoryItemsAreFiltered();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryDesignDocument::filterUnconnectedMemoryItems()\r\n//-----------------------------------------------------------------------------\r\nvoid MemoryDesignDocument::filterUnconnectedMemoryItems(bool filterUnconnected)\r\n{\r\n    diagram_->filterUnconnectedMemoryItems(filterUnconnected);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryDesignDocument::filterMemoryOverlapItems()\r\n//-----------------------------------------------------------------------------\r\nvoid MemoryDesignDocument::filterMemoryOverlapItems(bool filterOverlap)\r\n{\r\n    diagram_->filterMemoryOverlapItems(filterOverlap);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryDesignDocument::memoryOverlapItemsAreFiltered()\r\n//-----------------------------------------------------------------------------\r\nbool MemoryDesignDocument::memoryOverlapItemsAreFiltered() const\r\n{\r\n    return diagram_->memoryOverlapItemsAreFiltered();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryDesignDocument::exportImage()\r\n//-----------------------------------------------------------------------------\r\nbool MemoryDesignDocument::exportImage()\r\n{\r\n    QString libraryPath = getLibHandler()->getDirectoryPath(identifyingVLNV_);\r\n    return ImageExporter::exportImage(libraryPath, identifyingVLNV_, diagram_, this);\r\n}\r\n"
  },
  {
    "path": "editors/MemoryDesigner/MemoryDesignDocument.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: MemoryDesignDocument.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Mikko Teuho\r\n// Date: 06.07.2016\r\n//\r\n// Description:\r\n// Declares the memory design tab document class.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef MEMORYDESIGNDOCUMENT_H\r\n#define MEMORYDESIGNDOCUMENT_H\r\n\r\n#include <IPXACTmodels/common/VLNV.h>\r\n\r\n#include <common/widgets/tabDocument/TabDocument.h>\r\n\r\n#include <QGraphicsView>\r\n\r\nclass MemoryDesignerDiagram;\r\nclass VLNV;\r\nclass LibraryInterface;\r\nclass Design;\r\nclass Component;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Declares the memory design tab document class.\r\n//-----------------------------------------------------------------------------\r\nclass MemoryDesignDocument : public TabDocument\r\n{\r\n    Q_OBJECT\r\n\r\npublic:\r\n   \r\n    /*!\r\n     *  The constructor.\r\n     *\r\n     *    @param [in] library     The library interface.\r\n     *    @param [in] parent      The parent.\r\n     */\r\n    MemoryDesignDocument(LibraryInterface* libHandler, QWidget* parent = 0);\r\n\r\n    /*!\r\n     *  The destructor.\r\n     */\r\n    virtual ~MemoryDesignDocument();\r\n\r\n    /*!\r\n     *  Reload the current memory design.\r\n     */\r\n    virtual void refresh();\r\n\r\n    /*!\r\n     *  Set the memory design.\r\n     *\r\n     *    @param [in] componentVLNV   VLNV of the component.\r\n     *    @param [in] viewName        The selected component view.\r\n     *\r\n     *    @return True, if the memory design was opened successfully, false otherwise.\r\n     */\r\n    bool setDesign(VLNV const& componentVLNV, QString const& viewName);\r\n\r\n    /*!\r\n     *  Get the supported draw modes.\r\n     *\r\n     *    @return The supported draw modes.\r\n     */\r\n    virtual unsigned int getSupportedDrawModes() const;\r\n\r\n    /*!\r\n     *  Get the VLNV that can be used to identify the document.\r\n\t * \r\n\t *    @return The VLNV that identifies the document.\r\n\t */\r\n\tvirtual VLNV getIdentifyingVLNV() const;\r\n\r\n    /*!\r\n     *  Get the document VLNV.\r\n     *\r\n     *    @return The VLNV of the containing document.\r\n     */\r\n    virtual VLNV getDocumentVLNV() const;\r\n\r\n    /*!\r\n     *  Changes the state of a visibility control.\r\n     *\r\n     *    @param [in] name   The name of the visibility control.\r\n     *    @param [in] state  The new state for the visibility control.\r\n     */\r\n    virtual void setVisibilityControlState(QString const& name, bool state);\r\n\r\n    /*!\r\n     *  Sets the zoom level of the design.\r\n     *\r\n     *    @param [in] level The zoom level in percents.\r\n     */\r\n    virtual void setZoomLevel(int level);\r\n\r\n    /*!\r\n     *  Fits the whole design in view.\r\n     */\r\n    virtual void fitInView();\r\n\r\n    /*!\r\n     *  Centers the current view to a point.\r\n     *\r\n     *    @param [in] centerPoint   The point to center to.\r\n     */\r\n    void centerViewTo(QPointF const& centerPoint);\r\n\r\n    /*!\r\n     *  Sets the protection state of the document.\r\n     *\r\n     *    @param [in] locked True for locked state; false for unlocked.\r\n     */\r\n    virtual void setProtection(bool locked);\r\n\r\n    /*!\r\n     *  Change the condensing of memory graphics items.\r\n     *\r\n     *    @param [in] condenseItems   Value for condensing memory graphics items.\r\n     */\r\n    void setCondenseMemoryItems(bool condenseItems);\r\n\r\n    /*!\r\n     *  Check whether the memory graphics items are condensed or not.\r\n     *\r\n     *    @return True, if the memory graphics items are condensed, otherwise false.\r\n     */\r\n    bool memoryItemsAreCondensed() const;\r\n\r\n    /*!\r\n     *  Change the filtering of chained address space memory connections.\r\n     *\r\n     *    @param [in] filterChains    Value for filtering chained address space memory connections.\r\n     */\r\n    void filterAddressSpaceChains(bool filterChains);\r\n\r\n    /*!\r\n     *  Check whether the chained address space memory connections are filtered or not.\r\n     *\r\n     *    @return True, if the chained connections are filtered, otherwise false.\r\n     */\r\n    bool addressSpaceChainsAreFiltered() const;\r\n\r\n    /*!\r\n     *  Condense all the field graphics items to their original width.\r\n     */\r\n    void condenseFieldItems();\r\n\r\n    /*!\r\n     *  Extend all the field graphics items to fully display their name label.\r\n     */\r\n    void extendFieldItems();\r\n\r\n    /*!\r\n     *  Check whether the address space segments are filtered or not.\r\n     *\r\n     *    @return True, if address space segments are filtered, otherwise false.\r\n     */\r\n    bool addressSpaceSegmentsAreFilterted() const;\r\n\r\n    /*!\r\n     *  Check whether the address blocks are filtered or not.\r\n     *\r\n     *    @return True, if address blocks are filtered, otherwise false.\r\n     */\r\n    bool addressBlocksAreFiltered() const;\r\n\r\n    /*!\r\n     *  Check whether the address block registers are filtered or not.\r\n     *\r\n     *    @return True, if address block registers are filtered, otherwise false.\r\n     */\r\n    bool addressBlockRegistersAreFiltered() const;\r\n\r\n    /*!\r\n     *  Check whether the register fields are filtered or not.\r\n     *\r\n     *    @return True, if register fields are filtered, otherwise false.\r\n     */\r\n    bool fieldsAreFiltered() const;\r\n\r\n    /*!\r\n     *  Check whether the unconnected memory items are filtered or not.\r\n     *\r\n     *    @return True, if the unconnected memory items are filtered, otherwise false.\r\n     */\r\n    bool unconnectedMemoryItemsAreFiltered() const;\r\n\r\n    /*!\r\n     *  Filter the unconnected memory items.\r\n     *\r\n     *    @param [in] filterUnconnected   Value for filtering the unconnected memory items.\r\n     */\r\n    void filterUnconnectedMemoryItems(bool filterUnconnected);\r\n\r\n    /*!\r\n     *  Filter the memory overlap items.\r\n     *\r\n     *    @param [in] filterOverlap   Value for filtering.\r\n     */\r\n    void filterMemoryOverlapItems(bool filterOverlap);\r\n\r\n    /*!\r\n     *  Check if the memory overlap items are filtered.\r\n     *\r\n     *    @return True, if the memory overlap items are filtered, false otherwise.\r\n     */\r\n    bool memoryOverlapItemsAreFiltered() const;\r\n\r\npublic slots:\r\n\r\n    /*!\r\n     *  Filter the address space segments.\r\n     *\r\n     *    @param [in] filterSegments  Value for filtering the segments.\r\n     */\r\n    void filterAddressSpaceSegments(bool filterSegments);\r\n\r\n    /*!\r\n     *  Filter the address blocks.\r\n     *\r\n     *    @param [in] filterBlocks    Value for filtering the address blocks.\r\n     */\r\n    void filterAddressBlocks(bool filterBlocks);\r\n\r\n    /*!\r\n     *  Filter the address block registers.\r\n     *\r\n     *    @param [in] filterRegisters     Value for filtering the registers.\r\n     */\r\n    void filterAddressBlockRegisters(bool filterRegisters);\r\n\r\n    /*!\r\n     *  Filter the register fields.\r\n     *\r\n     *    @param [in] filterFields    Value for filtering the fields.\r\n     */\r\n    void filterFields(bool filterFields);\r\n\r\n    //! Called when the vertical scrollbar is scrolled.\r\n    void onVerticalScroll(int y);\r\n\r\n    /*!\r\n     *  Exports a screenshot of the document as an image file.\r\n     */\r\n    virtual bool exportImage();\r\n\r\nsignals:\r\n\r\n    //! Signaled when the zoom level has changed.\r\n    void zoomChanged();\r\n\r\n    //! Signaled when all items are deselected.\r\n    void clearItemSelection();\r\n\r\n    /*!\r\n     *  Open the component document for the selected VLNV.\r\n     *\r\n     *    @param [in] vlnv                VLNV of the containing component.\r\n     *    @param [in] identifierChain     List of strings to identify the component item.\r\n     */\r\n    void openComponentDocument(VLNV const& vlnv, QVector<QString> identifierChain);\r\n\r\nprotected:\r\n    \r\n    /*!\r\n     *  Show the document.\r\n     *\r\n     *    @param [in] event   The selected show event.\r\n     */\r\n    void showEvent(QShowEvent* event);\r\n\r\nprivate:\r\n    // Disable copying.\r\n    MemoryDesignDocument(MemoryDesignDocument const& rhs);\r\n    MemoryDesignDocument& operator=(MemoryDesignDocument const& rhs);\r\n\r\n    /*!\r\n     *  Get the design from the selected view.\r\n     *\r\n     *    @param [in] component   Component whose views are used.\r\n     *    @param [in] viewName    The name of the selected view.\r\n     */\r\n    QSharedPointer<Design> getDesignFromView(QSharedPointer<Component> component, QString const& viewName);\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! The graphics view for showing the diagram.\r\n    QGraphicsView* view_;\r\n\r\n    //! The memory design diagram.\r\n    MemoryDesignerDiagram* diagram_;\r\n\r\n    //! VLNV identifying the design.\r\n    VLNV identifyingVLNV_;\r\n\r\n    //! The name of the view used to construct the memory design diagram.\r\n    QString designViewName_;\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n\r\n#endif // MEMORYDESIGNDOCUMENT_H\r\n"
  },
  {
    "path": "editors/MemoryDesigner/MemoryDesignerChildGraphicsItem.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: MemoryDesignerChildGraphicsItem.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Mikko Teuho\r\n// Date: 19.09.2016\r\n//\r\n// Description:\r\n// Parent item for visualizing memory child items i.e. address blocks and segments.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"MemoryDesignerChildGraphicsItem.h\"\r\n\r\n#include <editors/MemoryDesigner/MemoryItem.h>\r\n\r\n#include <QBrush>\r\n#include <QFont>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryDesignerChildGraphicsItem::MemoryDesignerChildGraphicsItem()\r\n//-----------------------------------------------------------------------------\r\nMemoryDesignerChildGraphicsItem::MemoryDesignerChildGraphicsItem(QSharedPointer<MemoryItem const> subMemoryItem,\r\n    QString const& toolTipType, quint64 baseAddress, quint64 range, qreal blockWidth,\r\n    QVector<QString> identifierChain, QSharedPointer<ConnectivityComponent const> containingInstance,\r\n    QGraphicsItem* parent):\r\nMemoryDesignerGraphicsItem(subMemoryItem->getName(), subMemoryItem->getDisplayName(), identifierChain,\r\n    containingInstance, parent),\r\ntooltipType_(toolTipType),\r\nblockWidth_(blockWidth)\r\n{\r\n    quint64 rangeEnd = baseAddress + range - 1;\r\n\r\n    setup(range, baseAddress, rangeEnd);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryDesignerChildGraphicsItem::MemoryDesignerChildGraphicsItem()\r\n//-----------------------------------------------------------------------------\r\nMemoryDesignerChildGraphicsItem::MemoryDesignerChildGraphicsItem(MemoryDesignerChildGraphicsItem const& other, QGraphicsItem* parentItem):\r\nMemoryDesignerGraphicsItem(other, parentItem),\r\ntooltipType_(other.tooltipType_),\r\nblockWidth_(other.blockWidth_)\r\n{\r\n    quint64 lastAddress = other.getOriginalLastAddress();\r\n    quint64 baseAddress = other.getOriginalBaseAddress();\r\n\r\n    quint64 range = lastAddress - baseAddress + 1;\r\n    setup(range, baseAddress, lastAddress);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryDesignerChildGraphicsItem::setup()\r\n//-----------------------------------------------------------------------------\r\nvoid MemoryDesignerChildGraphicsItem::setup(quint64 const& range, quint64 const& baseAddress, quint64 const& lastAddress)\r\n{\r\n    if (range == 1)\r\n    {\r\n        getRangeStartLabel()->hide();\r\n    }\r\n\r\n    setGraphicsRectangle(blockWidth_, range);\r\n\r\n    if (tooltipType_.compare(QStringLiteral(\"Field\")) != 0)\r\n    {\r\n        setupGraphicsItem(baseAddress, lastAddress, tooltipType_);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryDesignerChildGraphicsItem::~MemoryDesignerChildGraphicsItem()\r\n//-----------------------------------------------------------------------------\r\nMemoryDesignerChildGraphicsItem::~MemoryDesignerChildGraphicsItem()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryDesignerChildGraphicsItem::setColors()\r\n//-----------------------------------------------------------------------------\r\nvoid MemoryDesignerChildGraphicsItem::setColors(QColor itemColor, bool itemIsEmpty)\r\n{\r\n    QBrush itemBrush(itemColor);\r\n\r\n    if (itemIsEmpty)\r\n    {\r\n        itemBrush.setColor(QColor(\"whiteSmoke\"));\r\n\r\n        QColor emptyTextColor (180, 180, 180);\r\n        getNameLabel()->setDefaultTextColor(emptyTextColor);\r\n        setEmptyItemRangeColors(emptyTextColor);\r\n    }\r\n    setBrush(itemBrush);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryDesignerChildGraphicsItem::setEmptyItemRangeColors()\r\n//-----------------------------------------------------------------------------\r\nvoid MemoryDesignerChildGraphicsItem::setEmptyItemRangeColors(QColor emptyItemRangeColour)\r\n{\r\n    getRangeStartLabel()->setDefaultTextColor(emptyItemRangeColour);\r\n    getRangeEndLabel()->setDefaultTextColor(emptyItemRangeColour);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryDesignerChildGraphicsItem::fitNameLabel()\r\n//-----------------------------------------------------------------------------\r\nvoid MemoryDesignerChildGraphicsItem::fitNameLabel()\r\n{\r\n    fitLabel(getNameLabel());\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryDesignerChildGraphicsItem::getItemWidth()\r\n//-----------------------------------------------------------------------------\r\nqreal MemoryDesignerChildGraphicsItem::getItemWidth() const\r\n{\r\n    return boundingRect().width();\r\n}\r\n"
  },
  {
    "path": "editors/MemoryDesigner/MemoryDesignerChildGraphicsItem.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: MemoryDesignerChildGraphicsItem.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Mikko Teuho\r\n// Date: 19.09.2016\r\n//\r\n// Description:\r\n// Parent item for visualizing memory child items i.e. address blocks and segments.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef MEMORYDESIGNERCHILDGRAPHICSITEM_H\r\n#define MEMORYDESIGNERCHILDGRAPHICSITEM_H\r\n\r\n#include <editors/MemoryDesigner/MemoryDesignerGraphicsItem.h>\r\n\r\n#include <QSharedPointer>\r\n#include <QGraphicsItem>\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Parent item for visualizing memory child items i.e. address blocks and segments.\r\n//-----------------------------------------------------------------------------\r\nclass MemoryDesignerChildGraphicsItem : public MemoryDesignerGraphicsItem\r\n{\r\n\r\npublic:\r\n\r\n    /*!\r\n     *  The constructor.\r\n     *\r\n     *    @param [in] subMemoryItem       The sub memory item.\r\n     *    @param [in] toolTipType         The type of the memory item.\r\n     *    @param [in] baseAddress         Base address of the memory item.\r\n     *    @param [in] range               Range of the memory item.\r\n     *    @param [in] blockWidth          Width of the memory item.\r\n     *    @param [in] identifierChain     List of strings to identify the component item.\r\n     *    @param [in] containingInstance  Component instance containing the sub memory item.\r\n     *    @param [in] parent              The parent item.\r\n     */\r\n    MemoryDesignerChildGraphicsItem(QSharedPointer<MemoryItem const> subMemoryItem, QString const& toolTipType,\r\n        quint64 baseAddress, quint64 range, qreal blockWidth, QVector<QString> identifierChain,\r\n        QSharedPointer<ConnectivityComponent const> containingInstance, QGraphicsItem* parent);\r\n\r\n    /*!\r\n     *  The copy constructor.\r\n     *\r\n     *    @param [in] other         The original child graphics item.\r\n     *    @param [in] parentItem    The parent item.\r\n     *\r\n     *    @return Copy of the original child graphics item.\r\n     */\r\n    MemoryDesignerChildGraphicsItem(MemoryDesignerChildGraphicsItem const& other, QGraphicsItem* parentItem);\r\n\r\n\t/*!\r\n     *  The destructor.\r\n     */\r\n    virtual ~MemoryDesignerChildGraphicsItem();\r\n\r\n    /*!\r\n     *  Get the type of the memory graphics item.\r\n     */\r\n    virtual int type() const  = 0;\r\n\r\n    /*!\r\n     *  Fit the name label to the available space.\r\n     */\r\n    void fitNameLabel();\r\n\r\nprotected:\r\n\r\n    /*!\r\n     *  Set the colors for the memory item.\r\n     *\r\n     *    @param [in] itemColor       The main color for the memory item.\r\n     *    @param [in] itemIsEmpty     Boolean for determining empty memory item.\r\n     */\r\n    void setColors(QColor itemColor, bool itemIsEmpty);\r\n\r\nprivate:\r\n    // Disable copying.\r\n    MemoryDesignerChildGraphicsItem& operator=(MemoryDesignerChildGraphicsItem const& rhs);\r\n\r\n    /*!\r\n     *  Setup the child graphics item.\r\n     *\r\n     *    @param [in] range         Child graphics item.\r\n     *    @param [in] baseAddress   Base address of the child item.\r\n     *    @param [in] lastAddress   Last address of the child item.\r\n     */\r\n    void setup(quint64 const& range, quint64 const& baseAddress, quint64 const& lastAddress);\r\n\r\n    /*!\r\n     *  Set colors for ranges in an empty sub graphics item.\r\n     *\r\n     *    @param [in] emptyItemRangeColour    The color for the empty sub graphics item ranges.\r\n     */\r\n    virtual void setEmptyItemRangeColors(QColor emptyItemRangeColour);\r\n\r\n    /*!\r\n     *  Get the width of the available area used by the memory sub item.\r\n     *\r\n     *    @return The width of the available area used by the memory sub item.\r\n     */\r\n    virtual qreal getItemWidth() const;\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! Type of the tooltip.\r\n    QString tooltipType_;\r\n\r\n    //! Width of the item block.\r\n    qreal blockWidth_;\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n\r\n#endif // MEMORYDESIGNERCHILDGRAPHICSITEM_H\r\n"
  },
  {
    "path": "editors/MemoryDesigner/MemoryDesignerConstants.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: MemoryDesignerConstants.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 14.12.2016\n//\n// Description:\n// Common declarations for memory designer.\n//-----------------------------------------------------------------------------\n\n#include \"MemoryDesignerConstants.h\"\n\n#include <editors/MemoryDesigner/ConnectivityInterface.h>\n#include <editors/MemoryDesigner/ConnectivityComponent.h>\n#include <editors/MemoryDesigner/MemoryItem.h>\n\n//-----------------------------------------------------------------------------\n// Function: MemoryDesignerConstants::itemOverlapsAnotherItem()\n//-----------------------------------------------------------------------------\nbool MemoryDesignerConstants::itemOverlapsAnotherItem(QRectF const& firstRectangle, int firstLineWidth,\n    QRectF const& secondRectangle, int secondLineWidth)\n{\n    qreal firstItemTop = firstRectangle.topLeft().y() + firstLineWidth;\n    qreal firstItemLow = firstRectangle.bottomLeft().y() - firstLineWidth;\n    qreal secondItemTop = secondRectangle.topLeft().y() + secondLineWidth;\n    qreal secondItemLow = secondRectangle.bottomLeft().y() - secondLineWidth;\n\n    if ((firstItemTop > secondItemTop && firstItemTop < secondItemLow) ||\n        (firstItemLow < secondItemLow && firstItemLow > secondItemTop) ||\n\n        (secondItemTop > firstItemTop && secondItemTop < firstItemLow) ||\n        (secondItemLow < firstItemLow && secondItemLow > firstItemTop) ||\n\n        (firstItemTop == secondItemTop && firstItemLow == secondItemLow))\n    {\n        return true;\n    }\n\n    return false;\n}\n\n//-----------------------------------------------------------------------------\n// Function: MemoryDesignerConstants::getAmountOfNumbersInRange()\n//-----------------------------------------------------------------------------\nint MemoryDesignerConstants::getAmountOfNumbersInRange(QString const& rangeStart, QString const& rangeEnd)\n{\n    int startSize = rangeStart.size();\n    int endSize = rangeEnd.size();\n\n    int amountOfNumbers = endSize;\n    if (startSize > endSize)\n    {\n        amountOfNumbers = startSize;\n    }\n\n    while (amountOfNumbers % 4)\n    {\n        amountOfNumbers++;\n    }\n\n    return amountOfNumbers;\n}\n\n//-----------------------------------------------------------------------------\n// Function: MemoryDesignerConstants::getValueWithZerosAdded()\n//-----------------------------------------------------------------------------\nQString MemoryDesignerConstants::getValueWithZerosAdded(QString const& value, int amountOfNumbers)\n{\n    QString zeroedValue = value;\n\n    int rangeSize = zeroedValue.size();\n    int amountOfZeros = amountOfNumbers - rangeSize;\n    while (amountOfZeros > 0)\n    {\n        zeroedValue.prepend('0');\n        amountOfZeros--;\n    }\n\n    return zeroedValue;\n}\n\n//-----------------------------------------------------------------------------\n// Function: MemoryDesignerConstants::getAreaSizeForRange()\n//-----------------------------------------------------------------------------\nqreal MemoryDesignerConstants::getAreaSizeForRange(quint64 addressRange)\n{\n    int areaMultiplication = getRequiredRowsForRange(addressRange);\n\n    return areaMultiplication * RANGEINTERVAL;\n}\n\n//-----------------------------------------------------------------------------\n// Function: MemoryDesignerConstants::getRequiredRowsForRange()\n//-----------------------------------------------------------------------------\nint MemoryDesignerConstants::getRequiredRowsForRange(quint64 addressRange)\n{\n    int requiredRows = 0;\n\n    if (addressRange == 1 || addressRange == 2)\n    {\n        requiredRows = addressRange;\n    }\n    else if (addressRange <= 16)\n    {\n        requiredRows = 3;\n    }\n    else if (addressRange <= 128)\n    {\n        requiredRows = 6;\n    }\n    else if (addressRange <= 1024)\n    {\n        requiredRows = 10;\n    }\n    else if (addressRange <= 16384)\n    {\n        requiredRows = 16;\n    }\n    else if (addressRange <= 1048576)\n    {\n        requiredRows = 26;\n    }\n    else if (addressRange <= 67108864)\n    {\n        requiredRows = 42;\n    }\n    else\n    {\n        requiredRows = 68;\n    }\n\n    return requiredRows;\n}\n\n//-----------------------------------------------------------------------------\n// Function: MemoryDesignerConstants::getRequiredAreaForUsedArea()\n//-----------------------------------------------------------------------------\nqreal MemoryDesignerConstants::getRequiredAreaForUsedArea(qreal usedArea)\n{\n    int addressRange = qRound(usedArea / RANGEINTERVAL);\n    qreal requiredArea = getAreaSizeForRange(addressRange);\n\n    return requiredArea;\n}\n\n//-----------------------------------------------------------------------------\n// Function: MemoryDesignerConstants::getMapItem()\n//-----------------------------------------------------------------------------\nQSharedPointer<MemoryItem> MemoryDesignerConstants::getMapItem(\n    QSharedPointer<ConnectivityInterface const> startInterface,\n    QSharedPointer<ConnectivityInterface const> endInterface)\n{\n    if (startInterface == endInterface)\n    {\n        return getMemoryItemForLocalMap(startInterface);\n    }\n    else\n    {\n        return endInterface->getConnectedMemory();\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: MemoryDesignerConstants::getMemoryItemForLocalMap()\n//-----------------------------------------------------------------------------\nQSharedPointer<MemoryItem> MemoryDesignerConstants::getMemoryItemForLocalMap(\n    QSharedPointer<ConnectivityInterface const> spaceInterface)\n{\n    QSharedPointer<MemoryItem const> spaceMemoryItem = spaceInterface->getConnectedMemory();\n    QSharedPointer<ConnectivityComponent const> connectionInstance = spaceInterface->getInstance();\n    if (spaceMemoryItem && connectionInstance)\n    {\n        foreach(QSharedPointer<MemoryItem> subSpaceItem, spaceMemoryItem->getChildItems())\n        {\n            if (subSpaceItem->getType().compare(MemoryDesignerConstants::MEMORYMAP_TYPE, Qt::CaseInsensitive) == 0)\n            {\n                return subSpaceItem;\n            }\n        }\n    }\n\n    return QSharedPointer<MemoryItem>();\n}\n"
  },
  {
    "path": "editors/MemoryDesigner/MemoryDesignerConstants.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: MemoryDesignerConstants.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Mikko Teuho\r\n// Date: 23.09.2016\r\n//\r\n// Description:\r\n// Common declarations for memory designer.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef MEMORYDESIGNERCONSTANTS_H\r\n#define MEMORYDESIGNERCONSTANTS_H\r\n\r\n#include <editors/common/diagramgrid.h>\r\n\r\n#include <common/graphicsItems/GraphicsColumnConstants.h>\r\n\r\n#include <QString>\r\n#include <QRectF>\r\n#include <QSharedPointer>\r\n\r\nclass ConnectivityInterface;\r\nclass MemoryItem;\r\n\r\n// Common declarations for memory designer.\r\nnamespace MemoryDesignerConstants\r\n{\r\n    const int ITEMWIDTH = 260;\r\n    const int MEMORYMAPFULLWIDTH = 1280;\r\n\r\n    const int COLUMNMARGIN = 110;\r\n\r\n    //! Starting widths of the memory columns.\r\n    const int SPACECOLUMNWIDTH = ITEMWIDTH + 2 * COLUMNMARGIN + 9;\r\n    const int MEMORYMAPCOLUMNWIDTH = MEMORYMAPFULLWIDTH + 2 * COLUMNMARGIN + 9;\r\n\r\n    //! Interval of one bit in a memory address.\r\n    const qreal RANGEINTERVAL = 25;\r\n    const qreal CUTMODIFIER = 2 * RANGEINTERVAL;\r\n\r\n    //! Minimum interval of address space graphics items.\r\n    const qreal SPACEITEMINTERVAL = GraphicsColumnConstants::MIN_Y_PLACEMENT;\r\n\r\n    //! Intervals used for unconnected memory items.\r\n    const unsigned int CONNECTED_UNCONNECTED_INTERVAL = RANGEINTERVAL * 13;\r\n    const unsigned int UNCONNECTED_ITEM_INTERVAL = RANGEINTERVAL;\r\n\r\n    //! X-position of the memory map graphics item sub items.\r\n    const qreal MAPSUBITEMPOSITIONX = ITEMWIDTH / 4;\r\n\r\n    const QString RESERVED_NAME = QLatin1String(\"Reserved\");\r\n    const QString HARD_RESET_TYPE = QLatin1String(\"HARD\");\r\n\r\n    const QString MEMORYMAP_TYPE = QLatin1String(\"memoryMap\");\r\n    const QString MEMORYREMAP_TYPE = QLatin1String(\"memoryRemap\");\r\n    const QString ADDRESSBLOCK_TYPE = QLatin1String(\"addressBlock\");\r\n    const QString SUBSPACEMAP_TYPE = QLatin1String(\"subspaceMap\");\r\n    const QString REGISTER_TYPE = QLatin1String(\"register\");\r\n    const QString FIELD_TYPE = QLatin1String(\"field\");\r\n    const QString ENUMERATED_VALUE_TYPE = QLatin1String(\"enumeratedValue\");\r\n    const QString RESET_TYPE = QLatin1String(\"reset\");\r\n    const QString ADDRESSSPACE_TYPE = QLatin1String(\"addressSpace\");\r\n    const QString ADDRESSSEGMENT_TYPE = QLatin1String(\"segment\");\r\n\r\n    const QString ADDRESSSPACECOLUMN_NAME = QLatin1String(\"Address Space\");\r\n    const QString MEMORYMAPCOLUMNCOMMON_NAME = QLatin1String(\"Memory Map\");\r\n    const QString MEMORYMAPCOLUM_NAME = QLatin1String(\"Memory Maps\");\r\n    const QString MEMORYMAPOVERLAPCOLUMN_NAME = QLatin1String(\"Memory Map Overlap\");\r\n\r\n    /*!\r\n     *  Check if the bounding rectangle of an item overlaps the bounding rectangle of another item.\r\n     *\r\n     *    @param [in] firstRectangle      The bounding rectangle of the selected item.\r\n     *    @param [in] firstLineWidth      Line width of the selected item.\r\n     *    @param [in] secondRectangle     The bounding rectangle of the comparison item.\r\n     *    @param [in] secondLineWidth     Line width of the comparison item.\r\n     */\r\n    bool itemOverlapsAnotherItem(QRectF const& firstRectangle, int firstLineWidth, QRectF const& secondRectangle,\r\n        int secondLineWidth);\r\n\r\n    /*!\r\n     *  Get the amount of numbers required for the given ranges.\r\n     *\r\n     *    @param [in] rangeStart  The selected address range start.\r\n     *    @param [in] rangeEnd    The selected address range end.\r\n     *\r\n     *    @return The amount of numbers used to display the address ranges.\r\n     */\r\n    int getAmountOfNumbersInRange(QString const& rangeStart, QString const& rangeEnd);\r\n\r\n    /*!\r\n     *  Change the selected value into a value with zeros appended to the beginning.\r\n     *\r\n     *    @param [in] value               The selected value.\r\n     *    @param [in] amountOfNumbers     Amount of numbers used to display the value.\r\n     *\r\n     *    @return The value with zeros appended to display the value.\r\n     */\r\n    QString getValueWithZerosAdded(QString const& value, int amountOfNumbers);\r\n\r\n    /*!\r\n     *  Get the area size required for the selected address range.\r\n     *\r\n     *    @param [in] addressRange    The selected address range.\r\n     *\r\n     *    @return The area size for the selected address range.\r\n     */\r\n    qreal getAreaSizeForRange(quint64 addressRange);\r\n\r\n    /*!\r\n     *  Get the required rows for the selected address range.\r\n     *\r\n     *    @param [in] addressRange    The selected address range.\r\n     *\r\n     *    @return The required rows for the selected address range.\r\n     */\r\n    int getRequiredRowsForRange(quint64 addressRange);\r\n\r\n    /*!\r\n     *  Get the required area size for the selected area.\r\n     *\r\n     *    @param [in] usedArea    The selected area.\r\n     *\r\n     *    @return The required area size for the selected area.\r\n     */\r\n    qreal getRequiredAreaForUsedArea(qreal usedArea);\r\n\r\n    /*!\r\n     *  Get the memory map item node of the connection.\r\n     *\r\n     *    @param [in] startInterface  Interface node containing the first interface of the connection path.\r\n     *    @param [in] endInterface    Interface node containing the last interface of the connection path.\r\n     *\r\n     *    @return The memory map item node of the connection.\r\n     */\r\n    QSharedPointer<MemoryItem> getMapItem(QSharedPointer<ConnectivityInterface const> startInterface,\r\n        QSharedPointer<ConnectivityInterface const> endInterface);\r\n\r\n    /*!\r\n     *\tGet the memory item node of a local memory map connection.\r\n     *\r\n     *\t\t@param [in]\tspaceInterface  Interface containing both the address space and memory map.\r\n     *\r\n     *\t\t@return\tThe local memory map item node.\r\n     */\r\n    QSharedPointer<MemoryItem> getMemoryItemForLocalMap(QSharedPointer<ConnectivityInterface const> spaceInterface);\r\n}\r\n\r\n#endif // MEMORYDESIGNERCONSTANTS_H\r\n"
  },
  {
    "path": "editors/MemoryDesigner/MemoryDesignerDiagram.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: MemoryDesignerDiagram.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Mikko Teuho\r\n// Date: 07.07.2016\r\n//\r\n// Description:\r\n// Declares the memory design diagram class.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"MemoryDesignerDiagram.h\"\r\n\r\n#include <KactusAPI/include/LibraryInterface.h>\r\n\r\n#include <common/graphicsItems/GraphicsColumnLayout.h>\r\n\r\n#include <editors/common/diagramgrid.h>\r\n\r\n#include <editors/MemoryDesigner/MemoryDesignDocument.h>\r\n#include <editors/MemoryDesigner/MemoryDesignConstructor.h>\r\n#include <editors/MemoryDesigner/MainMemoryGraphicsItem.h>\r\n#include <editors/MemoryDesigner/MemoryDesignerConstants.h>\r\n\r\n#include <IPXACTmodels/common/VLNV.h>\r\n#include <IPXACTmodels/Component/Component.h>\r\n#include <IPXACTmodels/DesignConfiguration/DesignConfiguration.h>\r\n\r\n#include <QGraphicsSceneWheelEvent>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryDesignerDiagram::MemoryDesignerDiagram()\r\n//-----------------------------------------------------------------------------\r\nMemoryDesignerDiagram::MemoryDesignerDiagram(LibraryInterface* library, MemoryDesignDocument* parent):\r\nQGraphicsScene(parent),\r\nparentDocument_(parent),\r\nlayout_(new GraphicsColumnLayout(this)),\r\nlibraryHandler_(library),\r\ngraphFactory_(library),\r\nmemoryConstructor_(new MemoryDesignConstructor(layout_))\r\n{\r\n    connect(memoryConstructor_, SIGNAL(openComponentDocument(VLNV const&, QVector<QString>)),\r\n        this, SIGNAL(openComponentDocument(VLNV const&, QVector<QString>)), Qt::UniqueConnection);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryDesignerDiagram::~MemoryDesignDocument()\r\n//-----------------------------------------------------------------------------\r\nMemoryDesignerDiagram::~MemoryDesignerDiagram()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryDesignerDiagram::setCondenseMemoryItems()\r\n//-----------------------------------------------------------------------------\r\nvoid MemoryDesignerDiagram::setCondenseMemoryItems(bool condenseMemoryItems)\r\n{\r\n    memoryConstructor_->setCondenseMemoryItems(condenseMemoryItems);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryDesignerDiagram::memoryItemsAreCondensed()\r\n//-----------------------------------------------------------------------------\r\nbool MemoryDesignerDiagram::memoryItemsAreCondensed() const\r\n{\r\n    return memoryConstructor_->memoryItemsAreCondensed();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryDesignerDiagram::setFilterAddressSpaceChains()\r\n//-----------------------------------------------------------------------------\r\nvoid MemoryDesignerDiagram::setFilterAddressSpaceChains(bool filterChains)\r\n{\r\n    memoryConstructor_->setFilterAddressSpaceChains(filterChains);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryDesignerDiagram::addressSpaceChainsAreFiltered()\r\n//-----------------------------------------------------------------------------\r\nbool MemoryDesignerDiagram::addressSpaceChainsAreFiltered() const\r\n{\r\n    return memoryConstructor_->addressSpaceChainsAreFiltered();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryDesignerDiagram::condenseFieldItems()\r\n//-----------------------------------------------------------------------------\r\nvoid MemoryDesignerDiagram::condenseFieldItems()\r\n{\r\n    memoryConstructor_->condenseFieldItems();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryDesignerDiagram::extendFieldItems()\r\n//-----------------------------------------------------------------------------\r\nvoid MemoryDesignerDiagram::extendFieldItems()\r\n{\r\n    memoryConstructor_->extendFieldItems();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryDesignerDiagram::setFilterAddressSpaceSegments()\r\n//-----------------------------------------------------------------------------\r\nvoid MemoryDesignerDiagram::setFilterAddressSpaceSegments(bool filterSegments)\r\n{\r\n    memoryConstructor_->setFilterAddressSpaceSegments(filterSegments);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryDesignerDiagram::addressSpaceSegmentsAreFiltered()\r\n//-----------------------------------------------------------------------------\r\nbool MemoryDesignerDiagram::addressSpaceSegmentsAreFiltered() const\r\n{\r\n    return memoryConstructor_->addressSpaceSegmentsAreFiltered();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryDesignerDiagram::setFilterAddressBlocks()\r\n//-----------------------------------------------------------------------------\r\nvoid MemoryDesignerDiagram::setFilterAddressBlocks(bool filterBlocks)\r\n{\r\n    memoryConstructor_->setFilterAddressBlocks(filterBlocks);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryDesignerDiagram::addressBlocksAreFiltered()\r\n//-----------------------------------------------------------------------------\r\nbool MemoryDesignerDiagram::addressBlocksAreFiltered() const\r\n{\r\n    return memoryConstructor_->addressBlocksAreFiltered();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryDesignerDiagram::setFilterAddressBlockRegisters()\r\n//-----------------------------------------------------------------------------\r\nvoid MemoryDesignerDiagram::setFilterAddressBlockRegisters(bool filterRegisters)\r\n{\r\n    memoryConstructor_->setFilterAddressBlockRegisters(filterRegisters);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryDesignerDiagram::addressBlockRegistersAreFiltered()\r\n//-----------------------------------------------------------------------------\r\nbool MemoryDesignerDiagram::addressBlockRegistersAreFiltered() const\r\n{\r\n    return memoryConstructor_->addressBlockRegistersAreFiltered();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryDesignerDiagram::setFilterFields()\r\n//-----------------------------------------------------------------------------\r\nvoid MemoryDesignerDiagram::setFilterFields(bool filterFields)\r\n{\r\n    memoryConstructor_->setFilterFields(filterFields);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryDesignerDiagram::fieldsAreFiltered()\r\n//-----------------------------------------------------------------------------\r\nbool MemoryDesignerDiagram::fieldsAreFiltered() const\r\n{\r\n    return memoryConstructor_->fieldsAreFiltered();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryDesignerDiagram::filterUnconnectedMemoryItems()\r\n//-----------------------------------------------------------------------------\r\nvoid MemoryDesignerDiagram::filterUnconnectedMemoryItems(bool filterUnconnected)\r\n{\r\n    memoryConstructor_->filterUnconnectedMemoryItems(filterUnconnected);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryDesignerDiagram::unconnectedMemoryItemsAreFiltered()\r\n//-----------------------------------------------------------------------------\r\nbool MemoryDesignerDiagram::unconnectedMemoryItemsAreFiltered() const\r\n{\r\n    return memoryConstructor_->unconnectedMemoryItemsAreFiltered();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryDesignerDiagram::filterMemoryOverlapItems()\r\n//-----------------------------------------------------------------------------\r\nvoid MemoryDesignerDiagram::filterMemoryOverlapItems(bool filterOverlap)\r\n{\r\n    memoryConstructor_->filterMemoryOverlapItems(filterOverlap);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryDesignerDiagram::memoryOverlapItemsAreFiltered()\r\n//-----------------------------------------------------------------------------\r\nbool MemoryDesignerDiagram::memoryOverlapItemsAreFiltered() const\r\n{\r\n    return memoryConstructor_->memoryOverlapItemsAreFiltered();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryDesignerDiagram::loadDesign()\r\n//-----------------------------------------------------------------------------\r\nbool MemoryDesignerDiagram::loadDesignFromCurrentView(QSharedPointer<const Component> component,\r\n    QString const& viewName)\r\n{\r\n    clearScene();\r\n\r\n    if (auto connectionGraph = graphFactory_.createConnectivityGraph(component, viewName))\r\n    {\r\n        bool constructionIsSuccess = memoryConstructor_->constructMemoryDesignItems(connectionGraph);\r\n        if (constructionIsSuccess)\r\n        {\r\n            QRectF rectangle = itemsBoundingRect();\r\n            qreal requiredWidth = rectangle.width();\r\n            qreal requiredHeight = rectangle.height() + MemoryDesignerConstants::SPACEITEMINTERVAL;\r\n\r\n            setSceneRect(0, 0, requiredWidth, requiredHeight);\r\n        }\r\n\r\n        return constructionIsSuccess;\r\n    }\r\n\r\n    return false;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryDesignerDiagram::clearScene()\r\n//-----------------------------------------------------------------------------\r\nvoid MemoryDesignerDiagram::clearScene()\r\n{\r\n    clearLayout();\r\n    clear();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryDesignerDiagram::clearLayout()\r\n//-----------------------------------------------------------------------------\r\nvoid MemoryDesignerDiagram::clearLayout()\r\n{\r\n    layout_.clear();\r\n    layout_ = QSharedPointer<GraphicsColumnLayout>(new GraphicsColumnLayout(this));\r\n    memoryConstructor_->setNewLayout(layout_);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryDesignerDiagram::onShow()\r\n//-----------------------------------------------------------------------------\r\nvoid MemoryDesignerDiagram::onShow()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryDesignerDiagram::onVerticalScroll()\r\n//-----------------------------------------------------------------------------\r\nvoid MemoryDesignerDiagram::onVerticalScroll(qreal y)\r\n{\r\n    layout_->setOffsetY(y);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryDesignerDiagram::wheelEvent()\r\n//-----------------------------------------------------------------------------\r\nvoid MemoryDesignerDiagram::wheelEvent(QGraphicsSceneWheelEvent *event)\r\n{\r\n    if (event->modifiers() == Qt::CTRL && parentDocument_)\r\n    {\r\n        // Set the zoom level and center the view.\r\n        parentDocument_->setZoomLevel(parentDocument_->getZoomLevel() + event->delta() / 12);\r\n\r\n        event->accept();\r\n    }\r\n    else if (event->modifiers() == Qt::ALT && !addressBlockRegistersAreFiltered() && !fieldsAreFiltered())\r\n    {\r\n        qreal deltaWidth = event->delta();\r\n        deltaWidth = -deltaWidth;\r\n\r\n        qreal previousWidthBoundary = memoryConstructor_->getWidthBoundary();\r\n        int newWidthBoundary = previousWidthBoundary + deltaWidth;\r\n        if (newWidthBoundary < 0)\r\n        {\r\n            deltaWidth = previousWidthBoundary;\r\n            newWidthBoundary = 0;\r\n        }\r\n\r\n        if (deltaWidth != 0)\r\n        {\r\n            memoryConstructor_->setNewWidthBoundary(newWidthBoundary);\r\n\r\n            memoryConstructor_->changeMemoryMapWidths(deltaWidth);\r\n        }\r\n\r\n        event->accept();\r\n    }\r\n    else\r\n    {\r\n        QGraphicsScene::wheelEvent(event);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryDesignerDiagram::drawBackground()\r\n//-----------------------------------------------------------------------------\r\nvoid MemoryDesignerDiagram::drawBackground(QPainter *painter, const QRectF &rect)\r\n{\r\n    painter->setWorldMatrixEnabled(true);\r\n    painter->setPen(QPen(Qt::gray, 0));\r\n\r\n    qreal left = int(rect.left()) - (int(rect.left()) % GridSize );\r\n    qreal top = int(rect.top()) - (int(rect.top()) % GridSize );\r\n\r\n    for (qreal x = left; x < rect.right(); x += GridSize )\r\n    {\r\n        for (qreal y = top; y < rect.bottom(); y += GridSize * 3)\r\n        {\r\n            painter->drawPoint(x, y);\r\n        }\r\n    }\r\n}\r\n"
  },
  {
    "path": "editors/MemoryDesigner/MemoryDesignerDiagram.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: MemoryDesignerDiagram.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Mikko Teuho\r\n// Date: 07.07.2016\r\n//\r\n// Description:\r\n// Declares the memory design diagram class.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef MEMORYDESIGNERDIAGRAM_H\r\n#define MEMORYDESIGNERDIAGRAM_H\r\n\r\n#include <IPXACTmodels/common/VLNV.h>\r\n\r\n#include <common/graphicsItems/GraphicsColumnLayout.h>\r\n\r\n#include <editors/MemoryDesigner/ConnectivityGraphFactory.h>\r\n\r\n#include <QGraphicsScene>\r\n#include <QSharedPointer>\r\n\r\nclass LibraryInterface;\r\nclass MemoryDesignDocument;\r\nclass ConnectivityGraph;\r\nclass MemoryDesignConstructor;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Declares the memory design diagram class.\r\n//-----------------------------------------------------------------------------\r\nclass MemoryDesignerDiagram : public QGraphicsScene\r\n{\r\n    Q_OBJECT\r\n\r\npublic:\r\n\r\n    /*!\r\n     *  The constructor.\r\n     *\r\n     *    @param [in] library     The library interface.\r\n     *    @param [in] parent      The parent widget.\r\n     */    \r\n    MemoryDesignerDiagram(LibraryInterface* library, MemoryDesignDocument* parent = 0);\r\n\r\n    /*!\r\n     *  The destructor.\r\n     */\r\n    ~MemoryDesignerDiagram();\r\n\r\n    /*!\r\n     *  Change the condensing of memory graphics items.\r\n     *\r\n     *    @param [in] condenseItems   Value for condensing memory graphics items.\r\n     */\r\n    void setCondenseMemoryItems(bool condenseMemoryItems);\r\n\r\n    /*!\r\n     *  Check whether the memory graphics items are condensed or not.\r\n     *\r\n     *    @return True, if the memory graphics items are condensed, otherwise false.\r\n     */\r\n    bool memoryItemsAreCondensed() const;\r\n\r\n    /*!\r\n     *  Set the filtering for chained address space memory connections.\r\n     *\r\n     *    @param [in] filterChains    Value for the chained address space memory connection filtering.\r\n     */\r\n    void setFilterAddressSpaceChains(bool filterChains);\r\n\r\n    /*!\r\n     *  Check whether the chained address space memory connections are filtered or not.\r\n     *\r\n     *    @return True, if the chained address space memory connections are filtered, false otherwise.\r\n     */\r\n    bool addressSpaceChainsAreFiltered() const;\r\n\r\n    /*!\r\n     *  Condense all the field graphics items to their original width.\r\n     */\r\n    void condenseFieldItems();\r\n\r\n    /*!\r\n     *  Extend all the field graphics items to fully display their name label.\r\n     */\r\n    void extendFieldItems();\r\n\r\n    /*!\r\n     *  Set a new value for filtering the address space segments.\r\n     *\r\n     *    @param [in] filterSegments  Value for filtering address space segments.\r\n     */\r\n    void setFilterAddressSpaceSegments(bool filterSegments);\r\n\r\n    /*!\r\n     *  Check if the address space segments are filtered.\r\n     *\r\n     *    @return True, if the address space segments are filtered, false otherwise.\r\n     */\r\n    bool addressSpaceSegmentsAreFiltered() const;\r\n\r\n    /*!\r\n     *  Set a new value for filtering the address blocks.\r\n     *\r\n     *    @param [in] filterBlocks    Value for filtering address blocks.\r\n     */\r\n    void setFilterAddressBlocks(bool filterBlocks);\r\n\r\n    /*!\r\n     *  Check if the address blocks are filtered.\r\n     *\r\n     *    @return True, if the address blocks are filtered, false otherwise.\r\n     */\r\n    bool addressBlocksAreFiltered() const;\r\n\r\n    /*!\r\n     *  Set a new value for filtering the address block registers.\r\n     *\r\n     *    @param [in] filterSegments  Value for filtering address block registers.\r\n     */\r\n    void setFilterAddressBlockRegisters(bool filterRegisters);\r\n\r\n    /*!\r\n     *  Check if the address block registers are filtered.\r\n     *\r\n     *    @return True, if the address block registers are filtered, false otherwise.\r\n     */\r\n    bool addressBlockRegistersAreFiltered() const;\r\n\r\n    /*!\r\n     *  Set a new value for filtering the register fields.\r\n     *\r\n     *    @param [in] filterFields    Value for filtering register fields.\r\n     */\r\n    void setFilterFields(bool filterFields);\r\n\r\n    /*!\r\n     *  Check if the register fields are filtered.\r\n     *\r\n     *    @return True, if the register fields are filtered, false otherwise.\r\n     */\r\n    bool fieldsAreFiltered() const;\r\n\r\n    /*!\r\n     *  Set a new value for filtering the unconnected memory items.\r\n     *\r\n     *    @param [in] filterUnconnected   Value for filtering unconnected memory items.\r\n     */\r\n    void filterUnconnectedMemoryItems(bool filterUnconnected);\r\n\r\n    /*!\r\n     *  Check if the unconnected memory items are filtered.\r\n     *\r\n     *    @return True, if the unconnected memory items are filtered, false otherwise.\r\n     */\r\n    bool unconnectedMemoryItemsAreFiltered() const;\r\n    \r\n    /*!\r\n     *  Set a new value for filtering the memory overlap items.\r\n     *\r\n     *    @param [in] filterOverlap       Value for filtering memory overlap.\r\n     */\r\n    void filterMemoryOverlapItems(bool filterOverlap);\r\n\r\n    /*!\r\n     *  Check if the memory overlap items are filtered.\r\n     *\r\n     *    @return True, if the memory overlap items are filtered, false otherwise.\r\n     */\r\n    bool memoryOverlapItemsAreFiltered() const;\r\n\r\n    /*!\r\n     *  Load a design using the selected view.\r\n     *\r\n     *    @param [in] component   Component containing the view.\r\n     *    @param [in] viewName    The name of the selected view.\r\n     */\r\n    bool loadDesignFromCurrentView(QSharedPointer<const Component> component, QString const& viewName);\r\n\r\n    /*!\r\n     *  Clear the graphics scene.\r\n     */\r\n    virtual void clearScene();\r\n\r\n    /*!\r\n     *  Handle the display of the diagram.\r\n     */\r\n    void onShow();\r\n\r\n    /*!\r\n     *  Handle the vertical scroll.\r\n     *\r\n     *    @param [in] y   The amount of vertical scrolling.\r\n     */\r\n    void onVerticalScroll(qreal y);\r\n\r\nprotected:\r\n\r\n    /*!\r\n     *  Handle the mouse wheel event.\r\n     *\r\n     *    @param [in] event   The wheel event.\r\n     */\r\n    virtual void wheelEvent(QGraphicsSceneWheelEvent *event);\r\n\r\n    /*!\r\n     *  Draw the diagram background.\r\n     *\r\n     *    @param [in] painter     The used painter.\r\n     *    @param [in] rect        The containing rectangle of the diagram.\r\n     */\r\n    virtual void drawBackground(QPainter *painter, const QRectF &rect);\r\n\r\nsignals:\r\n\r\n    /*!\r\n     *  Open the component document for the selected VLNV.\r\n     *\r\n     *    @param [in] vlnv                VLNV of the containing component.\r\n     *    @param [in] identifierChain     List of strings to identify the component item.\r\n     */\r\n    void openComponentDocument(VLNV const& vlnv, QVector<QString> identifierChain);\r\n\r\nprivate:\r\n    // Disable copying.\r\n    MemoryDesignerDiagram(MemoryDesignerDiagram const& rhs);\r\n    MemoryDesignerDiagram& operator=(MemoryDesignerDiagram const& rhs);\r\n\r\n    /*!\r\n     *  Clear the layout.\r\n     */\r\n    void clearLayout();\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! Document containing the memory design diagram.\r\n    MemoryDesignDocument* parentDocument_;\r\n\r\n    //! Layout of the memory design diagram.\r\n    QSharedPointer<GraphicsColumnLayout> layout_;\r\n\r\n    //! The used library interface.\r\n    LibraryInterface* libraryHandler_;\r\n\r\n    //! Factory for creating the connectivity graph.\r\n    ConnectivityGraphFactory graphFactory_;\r\n\r\n    //! Constructor for memory design graphics items.\r\n    MemoryDesignConstructor* memoryConstructor_;\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n\r\n#endif // MEMORYDESIGNERDIAGRAM_H\r\n"
  },
  {
    "path": "editors/MemoryDesigner/MemoryDesignerGraphicsItem.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: MemoryDesignerGraphicsItem.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Mikko Teuho\r\n// Date: 10.08.2016\r\n//\r\n// Description:\r\n// Parent class for memory designer graphics items.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"MemoryDesignerGraphicsItem.h\"\r\n\r\n#include <editors/common/diagramgrid.h>\r\n\r\n#include <editors/MemoryDesigner/MemoryColumn.h>\r\n#include <editors/MemoryDesigner/MemoryConnectionItem.h>\r\n#include <editors/MemoryDesigner/MemoryDesignerConstants.h>\r\n#include <editors/MemoryDesigner/ConnectivityComponent.h>\r\n#include <editors/MemoryDesigner/MemoryItem.h>\r\n\r\n#include <QFont>\r\n#include <QFontMetrics>\r\n#include <QGraphicsSceneMouseEvent>\r\n#include <QMenu>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryDesignerGraphicsItem::MemoryDesignerGraphicsItem()\r\n//-----------------------------------------------------------------------------\r\nMemoryDesignerGraphicsItem::MemoryDesignerGraphicsItem(QString const& itemName, QString const& displayName,\r\n    QVector<QString> identifierChain, QSharedPointer<ConnectivityComponent const> componentInstance,\r\n    QGraphicsItem* parent):\r\nQObject(),\r\nQGraphicsRectItem(parent),\r\nnameLabel_(new QGraphicsTextItem(itemName, this)),\r\nstartRangeLabel_(new QGraphicsTextItem(this)),\r\nendRangeLabel_(new QGraphicsTextItem(this)),\r\nbaseAddress_(0),\r\nlastAddress_(0),\r\noriginalBaseAddress_(0),\r\noriginalLastAddress_(0),\r\nitemName_(itemName),\r\ndisplayName_(displayName),\r\ncontainingInstance_(componentInstance),\r\ncomponentVLNV_(getVLNVFromContainingInstance()),\r\nopenComponentAction_(new QAction(this)),\r\nopenItemEditorAction_(new QAction(this)),\r\nidentifierChain_(identifierChain)\r\n{\r\n    if (!itemName.isEmpty())\r\n    {\r\n        identifierChain_.append(itemName);\r\n    }\r\n\r\n    auto openComponentText = QStringLiteral(\"Open containing component\");\r\n    openComponentAction_->setText(openComponentText);\r\n\r\n    auto openItemEditorText = QStringLiteral(\"Open editor for \") + itemName;\r\n    openItemEditorAction_->setText(openItemEditorText);\r\n\r\n    connect(openComponentAction_, SIGNAL(triggered()),\r\n        this, SLOT(openContainingComponent()), Qt::UniqueConnection);\r\n    connect(openItemEditorAction_, SIGNAL(triggered()), this, SLOT(openItemEditor()), Qt::UniqueConnection);\r\n\r\n    if (!displayName_.isEmpty())\r\n    {\r\n        nameLabel_->setPlainText(displayName);\r\n    }\r\n\r\n    QFont labelFont = nameLabel_->font();\r\n    labelFont.setWeight(QFont::Bold);\r\n\r\n    nameLabel_->setFont(labelFont);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryDesignerGraphicsItem::MemoryDesignerGraphicsItem()\r\n//-----------------------------------------------------------------------------\r\nMemoryDesignerGraphicsItem::MemoryDesignerGraphicsItem(MemoryDesignerGraphicsItem const& other, QGraphicsItem* parentItem):\r\nQObject(),\r\nQGraphicsRectItem(parentItem),\r\nnameLabel_(new QGraphicsTextItem(other.itemName_, this)),\r\nstartRangeLabel_(new QGraphicsTextItem(other.startRangeLabel_->toPlainText(), this)),\r\nendRangeLabel_(new QGraphicsTextItem(other.endRangeLabel_->toPlainText(), this)),\r\nbaseAddress_(other.originalBaseAddress_),\r\nlastAddress_(other.originalLastAddress_),\r\noriginalBaseAddress_(other.originalBaseAddress_),\r\noriginalLastAddress_(other.originalLastAddress_),\r\nitemName_(other.itemName_),\r\ndisplayName_(other.displayName_),\r\n// memoryConnections_(),\r\ncontainingInstance_(other.containingInstance_),\r\ncomponentVLNV_(getVLNVFromContainingInstance()),\r\nopenComponentAction_(new QAction(other.openComponentAction_->text(), this)),\r\nopenItemEditorAction_(new QAction(other.openItemEditorAction_->text(), this)),\r\nidentifierChain_(other.identifierChain_)\r\n{\r\n    connect(openComponentAction_, SIGNAL(triggered()), this, SLOT(openContainingComponent()), Qt::UniqueConnection);\r\n    connect(openItemEditorAction_, SIGNAL(triggered()), this, SLOT(openItemEditor()), Qt::UniqueConnection);\r\n\r\n    nameLabel_->setFont(other.nameLabel_->font());\r\n\r\n    setOpacity(0.7);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryDesignerGraphicsItem::hideMemoryRangeLabels()\r\n//-----------------------------------------------------------------------------\r\nvoid MemoryDesignerGraphicsItem::hideMemoryRangeLabels()\r\n{\r\n    hideStartRangeLabel();\r\n    hideEndRangeLabel();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryDesignerGraphicsItem::hideCollidingRangeLabels()\r\n//-----------------------------------------------------------------------------\r\nvoid MemoryDesignerGraphicsItem::hideCollidingRangeLabels(quint64 /*connectionBaseAddress*/, quint64 /*connectionLastAddress*/)\r\n{\r\n/*\r\n    quint64 itemBaseAddress = getBaseAddress();\r\n    quint64 itemLastAddress = getLastAddress();\r\n\r\n    quint64 minItemBaseConnectionLast = qMin(itemBaseAddress, connectionLastAddress);\r\n    quint64 maxItemBaseConnectionLast = qMax(itemBaseAddress, connectionLastAddress);\r\n    if (connectionBaseAddress - itemBaseAddress < 2 || maxItemBaseConnectionLast - minItemBaseConnectionLast < 2)\r\n    {\r\n        hideStartRangeLabel();\r\n    }\r\n\r\n    quint64 minItemLastConnectionBase = qMin(itemLastAddress, connectionBaseAddress);\r\n    quint64 maxItemLastconnectionBase = qMax(itemLastAddress, connectionBaseAddress);\r\n    quint64 minLastAddress = qMin(itemLastAddress, connectionLastAddress);\r\n    quint64 maxLastAddress = qMax(itemLastAddress, connectionLastAddress);\r\n    if (maxItemLastconnectionBase - minItemLastConnectionBase < 2 || maxLastAddress - minLastAddress < 2)\r\n    {\r\n        hideEndRangeLabel();\r\n    }\r\n*/\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryDesignerGraphicsItem::hideStartRangeLabel()\r\n//-----------------------------------------------------------------------------\r\nvoid MemoryDesignerGraphicsItem::hideStartRangeLabel()\r\n{\r\n    startRangeLabel_->hide();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryDesignerGraphicsItem::hideEndRangeLabel()\r\n//-----------------------------------------------------------------------------\r\nvoid MemoryDesignerGraphicsItem::hideEndRangeLabel()\r\n{\r\n    endRangeLabel_->hide();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryDesignerGraphicsItem::setGraphicsRectangle()\r\n//-----------------------------------------------------------------------------\r\nvoid MemoryDesignerGraphicsItem::setGraphicsRectangle(qreal rectangleWidth, qreal rectangleHeight)\r\n{\r\n    setRect(\r\n        QRectF(-rectangleWidth / 2, 0, rectangleWidth, rectangleHeight * MemoryDesignerConstants::RANGEINTERVAL));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryDesignerGraphicsItem::getNameLabel()\r\n//-----------------------------------------------------------------------------\r\nQGraphicsTextItem* MemoryDesignerGraphicsItem::getNameLabel() const\r\n{\r\n    return nameLabel_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryDesignerGraphicsItem::getRangeStartLabel()\r\n//-----------------------------------------------------------------------------\r\nQGraphicsTextItem* MemoryDesignerGraphicsItem::getRangeStartLabel() const\r\n{\r\n    return startRangeLabel_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryDesignerGraphicsItem::getRangeEndLabel()\r\n//-----------------------------------------------------------------------------\r\nQGraphicsTextItem* MemoryDesignerGraphicsItem::getRangeEndLabel() const\r\n{\r\n    return endRangeLabel_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryDesignerGraphicsItem::setupGraphicsItem()\r\n//-----------------------------------------------------------------------------\r\nvoid MemoryDesignerGraphicsItem::setupGraphicsItem(quint64 memoryStart, quint64 memoryEnd, QString const& identifier)\r\n{\r\n    setupLabels(memoryStart, memoryEnd);\r\n    setupOriginalAddresses(memoryStart, memoryEnd);\r\n    setupToolTip(identifier);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryDesignerGraphicsItem::setupLabels()\r\n//-----------------------------------------------------------------------------\r\nvoid MemoryDesignerGraphicsItem::setupLabels(quint64 memoryStart, quint64 memoryEnd)\r\n{\r\n    QString baseAddressInHexa = QString::number(memoryStart, 16).toUpper();\r\n    QString lastAddressInHexa = QString::number(memoryEnd, 16).toUpper();\r\n\r\n    int amountOfNumbers = MemoryDesignerConstants::getAmountOfNumbersInRange(baseAddressInHexa, lastAddressInHexa);\r\n    baseAddressInHexa = MemoryDesignerConstants::getValueWithZerosAdded(baseAddressInHexa, amountOfNumbers);\r\n    lastAddressInHexa = MemoryDesignerConstants::getValueWithZerosAdded(lastAddressInHexa, amountOfNumbers);\r\n\r\n    baseAddress_ = memoryStart;\r\n    lastAddress_ = memoryEnd;\r\n\r\n    startRangeLabel_->setPlainText(baseAddressInHexa);\r\n    endRangeLabel_->setPlainText(lastAddressInHexa);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryDesignerGraphicsItem::setOriginalAddresses()\r\n//-----------------------------------------------------------------------------\r\nvoid MemoryDesignerGraphicsItem::setupOriginalAddresses(quint64 memoryStart, quint64 memoryEnd)\r\n{\r\n    originalBaseAddress_ = memoryStart;\r\n    originalLastAddress_ = memoryEnd;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryDesignerGraphicsItem::setupToolTip()\r\n//-----------------------------------------------------------------------------\r\nvoid MemoryDesignerGraphicsItem::setupToolTip(QString const& identifier)\r\n{\r\n    QString lineEnd = QStringLiteral(\"<br>\");\r\n\r\n    QString identifierText = QStringLiteral(\"<b>\") + identifier + QStringLiteral(\":</b> \") + name() + lineEnd;\r\n\r\n    QString displayNameText(\"\");\r\n    if (!displayName_.isEmpty())\r\n    {\r\n        displayNameText = QStringLiteral(\"<b>Display Name:</b> \") + displayName() + lineEnd;\r\n    }\r\n\r\n    QString instanceText = QStringLiteral(\"<b>Component Instance:</b> \") + containingInstance_->getName() +\r\n        lineEnd + lineEnd;\r\n\r\n    QString baseAddressText =\r\n        QStringLiteral(\"<b>Generic Base Address:</b> \") + getRangeStartLabel()->toPlainText() + lineEnd;\r\n    QString lastAddressText = QStringLiteral(\"<b>Generic Last Address:</b> \") + getRangeEndLabel()->toPlainText();\r\n\r\n    QString toolTipText = identifierText + displayNameText + instanceText + baseAddressText + lastAddressText;\r\n    setToolTip(toolTipText);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryDesignerGraphicsItem::addToToolTip()\r\n//-----------------------------------------------------------------------------\r\nvoid MemoryDesignerGraphicsItem::addToToolTip(QString const& toolTipAddition)\r\n{\r\n    QString toolTipText = toolTip();\r\n    toolTipText += toolTipAddition;\r\n    setToolTip(toolTipText);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryDesignerGraphicsItem::name()\r\n//-----------------------------------------------------------------------------\r\nQString MemoryDesignerGraphicsItem::name() const\r\n{\r\n    return itemName_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryDesignerGraphicsItem::displayName()\r\n//-----------------------------------------------------------------------------\r\nQString MemoryDesignerGraphicsItem::displayName() const\r\n{\r\n    return displayName_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryDesignerGraphicsItem::getBaseAddress()\r\n//-----------------------------------------------------------------------------\r\nquint64 MemoryDesignerGraphicsItem::getBaseAddress() const\r\n{\r\n    return baseAddress_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryDesignerGraphicsItem::getOriginalBaseAddress()\r\n//-----------------------------------------------------------------------------\r\nquint64 MemoryDesignerGraphicsItem::getOriginalBaseAddress() const\r\n{\r\n    return originalBaseAddress_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryDesignerGraphicsItem::getLastAddress()\r\n//-----------------------------------------------------------------------------\r\nquint64 MemoryDesignerGraphicsItem::getLastAddress() const\r\n{\r\n    return lastAddress_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryDesignerGraphicsItem::getOriginalLastAddress()\r\n//-----------------------------------------------------------------------------\r\nquint64 MemoryDesignerGraphicsItem::getOriginalLastAddress() const\r\n{\r\n    return originalLastAddress_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryDesignerGraphicsItem::condense()\r\n//-----------------------------------------------------------------------------\r\nvoid MemoryDesignerGraphicsItem::condense(qreal newItemHeight)\r\n{\r\n    QRectF itemRectangle = boundingRect();\r\n    int itemPenWidth = pen().width();\r\n\r\n    qint16 itemXPosition = -itemRectangle.width() / 2;\r\n    qreal itemWidth = itemRectangle.width() - itemPenWidth;\r\n\r\n    setRect(itemXPosition, 0, itemWidth, newItemHeight);\r\n\r\n    setLabelPositions();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryDesignerGraphicsItem::addMemoryConnection()\r\n//-----------------------------------------------------------------------------\r\nvoid MemoryDesignerGraphicsItem::addMemoryConnection(MemoryConnectionItem* connectionItem)\r\n{\r\n    quint64 connectionBaseAddress = connectionItem->getRangeStartValue();\r\n    memoryConnections_.insert(connectionBaseAddress, connectionItem);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryDesignerGraphicsItem::getMemoryConnections()\r\n//-----------------------------------------------------------------------------\r\nQMultiMap<quint64, MemoryConnectionItem*> MemoryDesignerGraphicsItem::getMemoryConnections() const\r\n{\r\n    return memoryConnections_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryDesignerGraphicsItem::fitNameLabel()\r\n//-----------------------------------------------------------------------------\r\nvoid MemoryDesignerGraphicsItem::fitLabel(QGraphicsTextItem* label)\r\n{\r\n    QString labelText = label->toPlainText();\r\n\r\n    QFontMetrics fontMetrics(label->font());\r\n    qreal originalLabelWidth = fontMetrics.horizontalAdvance(labelText);\r\n    qreal availableArea = getItemWidth() - 6;\r\n\r\n    bool collidesWithRange = labelCollidesWithRangeLabels(label, fontMetrics.height());\r\n\r\n    if (collidesWithRange || originalLabelWidth > availableArea)\r\n    {\r\n        if (collidesWithRange)\r\n        {\r\n            availableArea = availableArea - getRangeStartLabel()->boundingRect().width();\r\n        }\r\n\r\n        QFontMetrics labelMetrics (label->font());\r\n        QString shortened = labelMetrics.elidedText(labelText, Qt::ElideRight, availableArea);\r\n\r\n        label->setPlainText(shortened);\r\n\r\n        if (label->pos().x() < 0)\r\n        {\r\n            qreal shortenedWidth = fontMetrics.horizontalAdvance(shortened);\r\n            qreal widthDifference = originalLabelWidth - shortenedWidth;\r\n            label->setX(label->pos().x() + widthDifference);\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryDesignerGraphicsItem::getItemWidth()\r\n//-----------------------------------------------------------------------------\r\nqreal MemoryDesignerGraphicsItem::getItemWidth() const\r\n{\r\n    return boundingRect().width();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryDesignerGraphicsItem::labelCollidesWithRangeLabels()\r\n//-----------------------------------------------------------------------------\r\nbool MemoryDesignerGraphicsItem::labelCollidesWithRangeLabels(QGraphicsTextItem* label, qreal fontHeight)\r\n    const\r\n{\r\n    if (label->collidesWithItem(getRangeStartLabel()) || label->collidesWithItem(getRangeEndLabel()))\r\n    {\r\n        QRectF labelRectangle = label->sceneBoundingRect();\r\n        QRectF startRangeRectangle = getRangeStartLabel()->sceneBoundingRect();\r\n        QRectF endRangeRectangle = getRangeEndLabel()->sceneBoundingRect();\r\n\r\n        labelRectangle.setHeight(fontHeight);\r\n        startRangeRectangle.setHeight(fontHeight);\r\n        endRangeRectangle.setHeight(fontHeight);\r\n\r\n        return MemoryDesignerConstants::itemOverlapsAnotherItem(labelRectangle, 0, startRangeRectangle, 0) ||\r\n            MemoryDesignerConstants::itemOverlapsAnotherItem(labelRectangle, 0, endRangeRectangle, 0);\r\n    }\r\n\r\n    return false;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryDesignerGraphicsItem::getContainingInstance()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<ConnectivityComponent const> MemoryDesignerGraphicsItem::getContainingInstance() const\r\n{\r\n    return containingInstance_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryDesignerGraphicsItem::changeAddress()\r\n//-----------------------------------------------------------------------------\r\nvoid MemoryDesignerGraphicsItem::changeAddress(quint64 const& newAddress)\r\n{\r\n    quint64 newBaseAddress = newAddress;\r\n    quint64 newLastAddress = newBaseAddress + originalLastAddress_ - originalBaseAddress_;\r\n\r\n    setupLabels(newBaseAddress, newLastAddress);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryDesignerGraphicsItem::compressToUnCutCoordinates()\r\n//-----------------------------------------------------------------------------\r\nvoid MemoryDesignerGraphicsItem::compressToUnCutCoordinates(QVector<qreal> unCutCoordinates,\r\n    const qreal CUTMODIFIER, bool memoryItemsAreCompressed)\r\n{\r\n    qreal cutArea = 0;\r\n\r\n    qreal itemTop = sceneBoundingRect().top();\r\n    qreal itemLow = sceneBoundingRect().bottom();\r\n\r\n    qreal beginArea = unCutCoordinates.first();\r\n    foreach (qreal endArea, unCutCoordinates)\r\n    {\r\n        if (beginArea >= itemTop && endArea <= itemLow)\r\n        {\r\n            qreal areaDifference = endArea - beginArea;\r\n            if (areaDifference > 0)\r\n            {\r\n                if (memoryItemsAreCompressed)\r\n                {\r\n                    areaDifference = areaDifference - CUTMODIFIER;\r\n                }\r\n                else\r\n                {\r\n                    qreal requiredArea = MemoryDesignerConstants::getRequiredAreaForUsedArea(areaDifference);\r\n                    areaDifference = areaDifference - requiredArea;\r\n                }\r\n\r\n                if (areaDifference > 0)\r\n                {\r\n                    cutArea += areaDifference;\r\n                }\r\n            }\r\n        }\r\n        else if (endArea > itemLow)\r\n        {\r\n            break;\r\n        }\r\n\r\n        beginArea = endArea;\r\n    }\r\n\r\n    if (cutArea > 0)\r\n    {\r\n        qreal condensedHeight = boundingRect().height() - cutArea;\r\n        condense(condensedHeight);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryDesignerGraphicsItem::contextMenuEvent()\r\n//-----------------------------------------------------------------------------\r\nvoid MemoryDesignerGraphicsItem::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)\r\n{\r\n    QMenu contextMenu;\r\n    contextMenu.addAction(openComponentAction_);\r\n    if (!identifierChain_.isEmpty())\r\n    {\r\n        contextMenu.addAction(openItemEditorAction_);\r\n    }\r\n\r\n    contextMenu.exec(event->screenPos());\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryDesignerGraphicsItem::openContainingComponent()\r\n//-----------------------------------------------------------------------------\r\nvoid MemoryDesignerGraphicsItem::openContainingComponent()\r\n{\r\n    emit openComponentDocument(componentVLNV_, QVector<QString>());\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryDesignerGraphicsItem::openItemEditor()\r\n//-----------------------------------------------------------------------------\r\nvoid MemoryDesignerGraphicsItem::openItemEditor()\r\n{\r\n    if (!identifierChain_.isEmpty())\r\n    {\r\n        emit openComponentDocument(componentVLNV_, identifierChain_);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryDesignerGraphicsItem::getVLNVFromContainingInstance()\r\n//-----------------------------------------------------------------------------\r\nVLNV MemoryDesignerGraphicsItem::getVLNVFromContainingInstance()\r\n{\r\n    if (containingInstance_)\r\n    {\r\n        VLNV::IPXactType vlnvType = VLNV::COMPONENT;\r\n        QString vlnvString = containingInstance_->getVlnv();\r\n\r\n        VLNV componentVLNV(vlnvType, vlnvString);\r\n        return componentVLNV;\r\n    }\r\n\r\n    return VLNV();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryDesignerGraphicsItem::getIdentifierChain()\r\n//-----------------------------------------------------------------------------\r\nQVector<QString> MemoryDesignerGraphicsItem::getIdentifierChain() const\r\n{\r\n    return identifierChain_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryDesignerGraphicsItem::setNewIdentifierChain()\r\n//-----------------------------------------------------------------------------\r\nvoid MemoryDesignerGraphicsItem::setNewIdentifierChain(QVector<QString> newIdentifiers)\r\n{\r\n    identifierChain_ = newIdentifiers;\r\n}\r\n"
  },
  {
    "path": "editors/MemoryDesigner/MemoryDesignerGraphicsItem.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: MemoryDesignerGraphicsItem.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Mikko Teuho\r\n// Date: 10.08.2016\r\n//\r\n// Description:\r\n// Parent class for memory designer graphics items.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef MEMORYDESIGNERGRAPHICSITEM_H\r\n#define MEMORYDESIGNERGRAPHICSITEM_H\r\n\r\n#include <IPXACTmodels/common/VLNV.h>\r\n\r\n#include <editors/common/diagramgrid.h>\r\n\r\n#include <QGraphicsRectItem>\r\n#include <QSharedPointer>\r\n#include <QGraphicsTextItem>\r\n\r\n#include <QObject>\r\n#include <QAction>\r\n\r\nclass MemoryColumn;\r\nclass MemoryConnectionItem;\r\nclass MemoryCollisionItem;\r\nclass ConnectivityComponent;\r\nclass MemoryItem;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Parent class for memory designer graphics items.\r\n//-----------------------------------------------------------------------------\r\nclass MemoryDesignerGraphicsItem : public QObject, public QGraphicsRectItem\r\n{\r\n    Q_OBJECT\r\n\r\npublic:\r\n\r\n    /*!\r\n     *  The constructor.\r\n     *\r\n     *    @param [in] itemName            Name of the memory graphics item.\r\n     *    @param [in] displayName         Display name of the memory graphics item.\r\n     *    @param [in] identifierChain     List of string containing the identifying information of the item.\r\n     *    @param [in] componentInstance   Component instance containing the memory item.\r\n     *    @param [in] parent              The parent item.\r\n     */\r\n    MemoryDesignerGraphicsItem(QString const& itemName, QString const& displayName,\r\n        QVector<QString> identifierChain, QSharedPointer<ConnectivityComponent const> componentInstance,\r\n        QGraphicsItem* parent = 0);\r\n\r\n    /*!\r\n     *  The copy constructor.\r\n     *\r\n     *    @param [in] other         The original graphics item.\r\n     *    @param [in] parentItem    The parent item.\r\n     *\r\n     *    @return Copy of the original graphics item.\r\n     */\r\n    MemoryDesignerGraphicsItem(MemoryDesignerGraphicsItem const& other, QGraphicsItem* parentItem);\r\n\r\n    // Disable copying.\r\n    MemoryDesignerGraphicsItem& operator=(MemoryDesignerGraphicsItem const& rhs) = delete;\r\n\r\n\t/*!\r\n     *  The destructor.\r\n     */\r\n    virtual ~MemoryDesignerGraphicsItem() = default;\r\n\r\n    /*!\r\n     *  Get the type of the memory item.\r\n     */\r\n    virtual int type() const = 0;\r\n\r\n    /*!\r\n     *  Get the name of the memory item.\r\n     *\r\n     *    @return The name of the memory item.\r\n     */\r\n    QString name() const;\r\n\r\n    /*!\r\n     *  Get the display name of the memory item.\r\n     *\r\n     *    @return The display name of the memory item.\r\n     */\r\n    QString displayName() const;\r\n\r\n    /*!\r\n     *  Hide the memory range labels.\r\n     */\r\n    void hideMemoryRangeLabels();\r\n\r\n    /*!\r\n     *  Hide the colliding memory item range labels.\r\n     *\r\n     *    @param [in] connectionBaseAddress   Base address of the memory connection item.\r\n     *    @param [in] connectionLastAddress   Last address of the memory connection item.\r\n     */\r\n    void hideCollidingRangeLabels(quint64 connectionBaseAddress, quint64 connectionLastAddress);\r\n\r\n    /*!\r\n     *  Hide the start memory range label.\r\n     */\r\n    void hideStartRangeLabel();\r\n\r\n    /*!\r\n     *  Hide the end memory range label.\r\n     */\r\n    void hideEndRangeLabel();\r\n\r\n    /*!\r\n     *  Get the current base address of the memory item.\r\n     *\r\n     *    @return The current base address of the memory item.\r\n     */\r\n    quint64 getBaseAddress() const;\r\n\r\n    /*!\r\n     *  Get the original base address of the memory item.\r\n     *\r\n     *    @return The original base address of the memory item.\r\n     */\r\n    quint64 getOriginalBaseAddress() const;\r\n\r\n    /*!\r\n     *  Get the current last address of the memory item.\r\n     *\r\n     *    @return The current last address of the memory item.\r\n     */\r\n    quint64 getLastAddress() const;\r\n\r\n    /*!\r\n     *  Get the original last address of the memory item.\r\n     *\r\n     *    @return The original last address of the memory item.\r\n     */\r\n    quint64 getOriginalLastAddress() const;\r\n\r\n    /*!\r\n     *  Compress this graphics item.\r\n     *\r\n     *    @param [in] newItemHeight   The new height of the graphics item.\r\n     */\r\n    virtual void condense(qreal newItemHeight);\r\n\r\n    /*!\r\n     *  Add a memory connection graphics item.\r\n     *\r\n     *    @param [in] connectionItem  The selected memory connection item.\r\n     */\r\n    virtual void addMemoryConnection(MemoryConnectionItem* connectionItem);\r\n\r\n    /*!\r\n     *  Get the connected memory connection items.\r\n     *\r\n     *    @return A map containing the memory connection items in the order of their base addresses.\r\n     */\r\n    QMultiMap<quint64, MemoryConnectionItem*> getMemoryConnections() const;\r\n\r\n    /*!\r\n     *  Fit the selected label to this item.\r\n     *\r\n     *    @param [in] label   The selected label.\r\n     */\r\n    virtual void fitLabel(QGraphicsTextItem* label);\r\n\r\n    /*!\r\n     *  Get the containing component instance.\r\n     *\r\n     *    @return The containing component instance.\r\n     */\r\n    QSharedPointer<ConnectivityComponent const> getContainingInstance() const;\r\n\r\n    /*!\r\n     *  Change the address range of the memory item.\r\n     *\r\n     *    @param [in] newAddress    New address for the memory item.\r\n     */\r\n    virtual void changeAddress(quint64 const& newAddress);\r\n\r\n    /*!\r\n     *  Compress this item to contain the selected coordinates.\r\n     *\r\n     *    @param [in] unCutCoordinates            Coordinates that remain after the compression.\r\n     *    @param [in] CUTMODIFIER                 Modifier for the cut area.\r\n     *    @param [in] memoryItemsAreCompressed    Flag for condensing memory items.\r\n     */\r\n    virtual void compressToUnCutCoordinates(QVector<qreal> unCutCoordinates, const qreal CUTMODIFIER,\r\n        bool memoryItemsAreCompressed);\r\n\r\n    /*!\r\n     *  Get the identifying information of the memory item.\r\n     *\r\n     *    @return The identifying information.\r\n     */\r\n    QVector<QString> getIdentifierChain() const;\r\n\r\n    /*!\r\n     *  Set a new identifier chain.\r\n     *\r\n     *    @param [in] newIdentifiers  A list of strings containing the new memory identifier chain.\r\n     */\r\n    virtual void setNewIdentifierChain(QVector<QString> newIdentifiers);\r\n\r\nprotected:\r\n\r\n    /*!\r\n     *  Setup the graphics rectangle.\r\n     *\r\n     *    @param [in] rectangleWidth      Width of the graphics rectangle.\r\n     *    @param [in] rectangleHeight     Height of the graphics rectangle.\r\n     */\r\n    void setGraphicsRectangle(qreal rectangleWidth, qreal rectangleHeight);\r\n\r\n    /*!\r\n     *  Setup the memory graphics item.\r\n     *\r\n     *    @param [in] memoryStart     Base address of the memory item.\r\n     *    @param [in] memoryEnd       Last address of the memory item.\r\n     *    @param [in] identifier      Identifier of the memory item.\r\n     */\r\n    void setupGraphicsItem(quint64 memoryStart, quint64 memoryEnd, QString const& identifier);\r\n\r\n    /*!\r\n     *  Add text to the tooltip.\r\n     *\r\n     *    @param [in] toolTipAddition     Text to be added to the tooltip.\r\n     */\r\n    void addToToolTip(QString const& toolTipAddition);\r\n\r\n    /*!\r\n     *  Get the name label.\r\n     *\r\n     *    @return The label containing the item name.\r\n     */\r\n    QGraphicsTextItem* getNameLabel() const;\r\n\r\n    /*!\r\n     *  Get the range start label.\r\n     *\r\n     *    @return The label containing the item range start.\r\n     */\r\n    QGraphicsTextItem* getRangeStartLabel() const;\r\n\r\n    /*!\r\n     *  Get the range end label.\r\n     *\r\n     *    @return The label containing the item range end.\r\n     */\r\n    QGraphicsTextItem* getRangeEndLabel() const;\r\n\r\n    /*!\r\n     *  Check if the selected label collides with range labels.\r\n     *\r\n     *    @param [in] label       The selected label.\r\n     *    @param [in] fontHeight  Height of the text used in the selected label.\r\n     *\r\n     *    @return True, if the selected label collides with range labels, otherwise false.\r\n     */\r\n    virtual bool labelCollidesWithRangeLabels(QGraphicsTextItem* label, qreal fontHeight) const;\r\n\r\n    /*!\r\n     *  Set the label positions.\r\n     */\r\n    virtual void setLabelPositions() = 0;\r\n\r\n    /*!\r\n     *  Handler for context menu.\r\n     *\r\n     *    @param [in] event   The context menu event.\r\n     */\r\n    void contextMenuEvent(QGraphicsSceneContextMenuEvent *event);\r\n\r\nsignals:\r\n\r\n    /*!\r\n     *  Open the document from which the containing component instance has been built from. Identifying\r\n     *  information allows the editor to be opened from the memory item.\r\n     *\r\n     *    @param [in] vlnv                VLNV of the component.\r\n     *    @param [in] identifierChain     Identifying information for the memory item.\r\n     */\r\n    void openComponentDocument(VLNV const& vlnv, QVector<QString> identifierChain);\r\n\r\nprivate slots:\r\n\r\n    /*!\r\n     *  Open the editor for the containing component.\r\n     */\r\n    void openContainingComponent();\r\n\r\n    /*!\r\n     *  Open the item editor from the containing component.\r\n     */\r\n    void openItemEditor();\r\n\r\nprivate:\r\n\r\n    /*!\r\n     *  Get the available width of this item.\r\n     *\r\n     *    @return The available width of this item.\r\n     */\r\n    virtual qreal getItemWidth() const;\r\n    \r\n    /*!\r\n     *  Setup range labels.\r\n     *\r\n     *    @param [in] memoryStart     The range start.\r\n     *    @param [in] memoryEnd       The range end.\r\n     */\r\n    void setupLabels(quint64 memoryStart, quint64 memoryEnd);\r\n\r\n    /*!\r\n     *  Setup the original addresses for the memory item.\r\n     *\r\n     *    @param [in] memoryStart     Base address of the memory item.\r\n     *    @param [in] memoryEnd       Last address of the memory item.\r\n     */\r\n    void setupOriginalAddresses(quint64 memoryStart, quint64 memoryEnd);\r\n\r\n    /*!\r\n     *  Setup the tooltip and the memory range labels.\r\n     *\r\n     *    @param [in] identifier      Selected identifier.\r\n     */\r\n    void setupToolTip(QString const& identifier);\r\n\r\n    /*!\r\n     *  Get the VLNV of the component from the containing component instance.\r\n     *\r\n     *    @return The VLNV of the component.\r\n     */\r\n    VLNV getVLNVFromContainingInstance();\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! The name label.\r\n    QGraphicsTextItem* nameLabel_;\r\n\r\n    //! The range start label.\r\n    QGraphicsTextItem* startRangeLabel_;\r\n\r\n    //! The range end label.\r\n    QGraphicsTextItem* endRangeLabel_;\r\n\r\n    //! The base address.\r\n    quint64 baseAddress_;\r\n\r\n    //! The last address.\r\n    quint64 lastAddress_;\r\n\r\n    //! The original base address.\r\n    quint64 originalBaseAddress_;\r\n\r\n    //! The original last address.\r\n    quint64 originalLastAddress_;\r\n\r\n    //! Name of the item.\r\n    QString itemName_;\r\n\r\n    //! Display name of the item.\r\n    QString displayName_;\r\n\r\n    //! Map containing memory connection items and their base addresses.\r\n    QMultiMap<quint64, MemoryConnectionItem*> memoryConnections_;\r\n\r\n    //! The containing component instance.\r\n    QSharedPointer<ConnectivityComponent const> containingInstance_;\r\n\r\n    //! VLNV for the containing component.\r\n    VLNV componentVLNV_;\r\n\r\n    //! Action for opening the component document editor.\r\n    QAction* openComponentAction_;\r\n\r\n    //! Action for opening the component editor in the memory item.\r\n    QAction* openItemEditorAction_;\r\n\r\n    //! List of string identifying the memory item.\r\n    QVector<QString> identifierChain_;\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n\r\n#endif // MEMORYDESIGNERGRAPHICSITEM_H\r\n"
  },
  {
    "path": "editors/MemoryDesigner/MemoryExtensionGraphicsItem.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: MemoryExtensionGraphicsItem.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Mikko Teuho\r\n// Date: 21.09.2016\r\n//\r\n// Description:\r\n// Extension item for memory designer graphics items.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"MemoryExtensionGraphicsItem.h\"\r\n\r\n#include <common/graphicsItems/GraphicsItemTypes.h>\r\n\r\n#include <editors/MemoryDesigner/AddressSpaceGraphicsItem.h>\r\n#include <editors/MemoryDesigner/MemoryMapGraphicsItem.h>\r\n\r\n#include <QPen>\r\n#include <QBrush>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryExtensionGraphicsItem::MemoryExtensionGraphicsItem()\r\n//-----------------------------------------------------------------------------\r\nMemoryExtensionGraphicsItem::MemoryExtensionGraphicsItem(qreal positionX, qreal positionY, qreal extensionWidth,\r\n    qreal extensionHeight, QSharedPointer<ConnectivityComponent const> containingInstance,\r\n    QGraphicsItem* parentItem):\r\nMemoryDesignerGraphicsItem(QStringLiteral(\"\"), QStringLiteral(\"\"), QVector<QString>(), containingInstance,\r\n    parentItem)\r\n{\r\n    setRect(positionX, positionY, extensionWidth, extensionHeight);\r\n    setPenAndBrush();\r\n    setLabelPositions();\r\n\r\n    setFlag(QGraphicsItem::ItemStacksBehindParent);\r\n    setZValue(-10);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryExtensionGraphicsItem::~MemoryExtensionGraphicsItem()\r\n//-----------------------------------------------------------------------------\r\nMemoryExtensionGraphicsItem::~MemoryExtensionGraphicsItem()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryExtensionGraphicsItem::type()\r\n//-----------------------------------------------------------------------------\r\nint MemoryExtensionGraphicsItem::type() const\r\n{\r\n    int extensionType = GFX_TYPE_MEMORY_ITEM;\r\n\r\n    QGraphicsItem* parent = parentItem();\r\n    AddressSpaceGraphicsItem* spaceParent = dynamic_cast<AddressSpaceGraphicsItem*>(parent);\r\n    if (spaceParent)\r\n    {\r\n        extensionType = spaceParent->type();\r\n    }\r\n    else\r\n    {\r\n        MemoryMapGraphicsItem* mapParent = dynamic_cast<MemoryMapGraphicsItem*>(parent);\r\n        if (mapParent)\r\n        {\r\n            extensionType = mapParent->type();\r\n        }\r\n    }\r\n\r\n    return extensionType;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryExtensionGraphicsItem::setPenAndBrush()\r\n//-----------------------------------------------------------------------------\r\nvoid MemoryExtensionGraphicsItem::setPenAndBrush()\r\n{\r\n    QPen extensionPen = pen();\r\n    extensionPen.setStyle(Qt::DashLine);\r\n    setPen(extensionPen);\r\n\r\n    QBrush extensionBrush(QColor(\"whiteSmoke\"));\r\n    setBrush(extensionBrush);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryExtensionGraphicsItem::setLabelPositions()\r\n//-----------------------------------------------------------------------------\r\nvoid MemoryExtensionGraphicsItem::setLabelPositions()\r\n{\r\n    hideMemoryRangeLabels();\r\n}\r\n"
  },
  {
    "path": "editors/MemoryDesigner/MemoryExtensionGraphicsItem.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: MemoryExtensionGraphicsItem.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Mikko Teuho\r\n// Date: 21.09.2016\r\n//\r\n// Description:\r\n// Extension item for memory designer graphics items.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef MEMORYEXTENSIONGRAPHICSITEM_H\r\n#define MEMORYEXTENSIONGRAPHICSITEM_H\r\n\r\n#include <editors/MemoryDesigner/MemoryDesignerGraphicsItem.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Parent class for memory designer graphics items.\r\n//-----------------------------------------------------------------------------\r\nclass MemoryExtensionGraphicsItem : public MemoryDesignerGraphicsItem\r\n{\r\n\r\npublic:\r\n\r\n    /*!\r\n     *  The constructor.\r\n     *\r\n     *    @param [in] positionX           X position of the extension.\r\n     *    @param [in] positionY           Y position of the extension.\r\n     *    @param [in] extensionWidth      Width of the extension.\r\n     *    @param [in] extensionHeight     Height of the extension.\r\n     *    @param [in] containingInstance  Component instance containing this memory item.\r\n     *    @param [in] parentItem          Parent item.\r\n     */\r\n    MemoryExtensionGraphicsItem(qreal positionX, qreal positionY, qreal extensionWidth, qreal extensionHeight,\r\n        QSharedPointer<ConnectivityComponent const> containingInstance, QGraphicsItem* parentItem);\r\n\r\n\t/*!\r\n     *  The destructor.\r\n     */\r\n    virtual ~MemoryExtensionGraphicsItem();\r\n\r\n    /*!\r\n     *  Get the type of the parent item.\r\n     */\r\n    virtual int type() const;\r\n\r\nprivate:\r\n    // Disable copying.\r\n    MemoryExtensionGraphicsItem(MemoryExtensionGraphicsItem const& rhs);\r\n    MemoryExtensionGraphicsItem& operator=(MemoryExtensionGraphicsItem const& rhs);\r\n\r\n    /*!\r\n     *  Set the pen and brush for the memory extension.\r\n     */\r\n    void setPenAndBrush();\r\n\r\n    /*!\r\n     *  Set the positions of the information labels.\r\n     */\r\n    virtual void setLabelPositions();\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n\r\n#endif // MEMORYEXTENSIONGRAPHICSITEM_H\r\n"
  },
  {
    "path": "editors/MemoryDesigner/MemoryGraphicsItemHandler.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: MemoryGraphicsItemHandler.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 03.01.2017\n//\n// Description:\n// Constructs the memory graphics items for the memory design diagram.\n//-----------------------------------------------------------------------------\n\n#include \"MemoryGraphicsItemHandler.h\"\n\n#include <editors/MemoryDesigner/ConnectivityGraph.h>\n#include <editors/MemoryDesigner/ConnectivityComponent.h>\n#include <editors/MemoryDesigner/MemoryItem.h>\n\n#include <editors/MemoryDesigner/MemoryDesignerConstants.h>\n#include <editors/MemoryDesigner/AddressSpaceGraphicsItem.h>\n#include <editors/MemoryDesigner/MemoryMapGraphicsItem.h>\n#include <editors/MemoryDesigner/MemoryColumn.h>\n#include <editors/MemoryDesigner/MemoryCollisionItem.h>\n#include <editors/MemoryDesigner/MemoryDesignerChildGraphicsItem.h>\n\n//-----------------------------------------------------------------------------\n// Function: MemoryGraphicsItemHandler::MemoryGraphicsItemHandler()\n//-----------------------------------------------------------------------------\nMemoryGraphicsItemHandler::MemoryGraphicsItemHandler():\nQObject()\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: MemoryGraphicsItemHandler::~MemoryGraphicsItemHandler()\n//-----------------------------------------------------------------------------\nMemoryGraphicsItemHandler::~MemoryGraphicsItemHandler()\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: MemoryGraphicsItemHandler::setFilterAddressSpaceSegments()\n//-----------------------------------------------------------------------------\nvoid MemoryGraphicsItemHandler::setFilterAddressSpaceSegments(bool filterSegments)\n{\n    filterAddressSpaceSegments_ = filterSegments;\n}\n\n//-----------------------------------------------------------------------------\n// Function: MemoryGraphicsItemHandler::addressSpaceSegmentsAreFiltered()\n//-----------------------------------------------------------------------------\nbool MemoryGraphicsItemHandler::addressSpaceSegmentsAreFiltered() const\n{\n    return filterAddressSpaceSegments_;\n}\n\n//-----------------------------------------------------------------------------\n// Function: MemoryGraphicsItemHandler::setFilterAddressBlocks()\n//-----------------------------------------------------------------------------\nvoid MemoryGraphicsItemHandler::setFilterAddressBlocks(bool filterBlocks)\n{\n    filterAddressBlocks_ = filterBlocks;\n}\n\n//-----------------------------------------------------------------------------\n// Function: MemoryGraphicsItemHandler::addressBlocksAreFiltered()\n//-----------------------------------------------------------------------------\nbool MemoryGraphicsItemHandler::addressBlocksAreFiltered() const\n{\n    return filterAddressBlocks_;\n}\n\n//-----------------------------------------------------------------------------\n// Function: MemoryGraphicsItemHandler::setFilterAddressBlockRegisters()\n//-----------------------------------------------------------------------------\nvoid MemoryGraphicsItemHandler::setFilterAddressBlockRegisters(bool filterRegisters)\n{\n    filterRegisters_ = filterRegisters;\n}\n\n//-----------------------------------------------------------------------------\n// Function: MemoryGraphicsItemHandler::addressBlockRegistersAreFiltered()\n//-----------------------------------------------------------------------------\nbool MemoryGraphicsItemHandler::addressBlockRegistersAreFiltered() const\n{\n    return filterRegisters_;\n}\n\n//-----------------------------------------------------------------------------\n// Function: MemoryGraphicsItemHandler::setFilterFields()\n//-----------------------------------------------------------------------------\nvoid MemoryGraphicsItemHandler::setFilterFields(bool filterFields)\n{\n    filterFields_ = filterFields;\n}\n\n//-----------------------------------------------------------------------------\n// Function: MemoryGraphicsItemHandler::fieldsAreFiltered()\n//-----------------------------------------------------------------------------\nbool MemoryGraphicsItemHandler::fieldsAreFiltered() const\n{\n    return filterFields_;\n}\n\n//-----------------------------------------------------------------------------\n// Function: MemoryGraphicsItemHandler::filterUnconnectedMemoryItems()\n//-----------------------------------------------------------------------------\nvoid MemoryGraphicsItemHandler::filterUnconnectedMemoryItems(bool filterUnconnected)\n{\n    filterUnconnectedMemoryItems_ = filterUnconnected;\n\n    for (AddressSpaceGraphicsItem* spaceItem : spaceItems_)\n    {\n        filterUnconnectedMemoryItem(spaceItem);\n    }\n\n    for (MemoryMapGraphicsItem* mapItem : memoryMapItems_)\n    {\n        filterUnconnectedMemoryItem(mapItem);\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: MemoryGraphicsItemHandler::filterUnconnectedMemoryItem()\n//-----------------------------------------------------------------------------\nvoid MemoryGraphicsItemHandler::filterUnconnectedMemoryItem(MainMemoryGraphicsItem* memoryItem)\n{\n    if (memoryItem->getMemoryConnections().isEmpty())\n    {\n        memoryItem->setVisible(!filterUnconnectedMemoryItems_);\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: MemoryGraphicsItemHandler::unconnectedMemoryItemsAreFiltered()\n//-----------------------------------------------------------------------------\nbool MemoryGraphicsItemHandler::unconnectedMemoryItemsAreFiltered() const\n{\n    return filterUnconnectedMemoryItems_;\n}\n\n//-----------------------------------------------------------------------------\n// Function: MemoryGraphicsItemHandler::filterMemoryOverlapItems()\n//-----------------------------------------------------------------------------\nvoid MemoryGraphicsItemHandler::filterMemoryOverlapItems(bool filterOverlap)\n{\n    filterMemoryOverlapItems_ = filterOverlap;\n\n    for (auto addrSpace : spaceItems_)\n    {\n        for (auto overlapItem : addrSpace->getMemoryCollisions())\n        {\n            overlapItem->setVisible(!filterOverlap);\n        }\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: MemoryGraphicsItemHandler::memoryOverlapItemsAreFiltered()\n//-----------------------------------------------------------------------------\nbool MemoryGraphicsItemHandler::memoryOverlapItemsAreFiltered() const\n{\n    return filterMemoryOverlapItems_;\n}\n\n//-----------------------------------------------------------------------------\n// Function: MemoryGraphicsItemHandler::createMemoryItems()\n//-----------------------------------------------------------------------------\nvoid MemoryGraphicsItemHandler::createMemoryItems(QSharedPointer<ConnectivityGraph> connectionGraph,\n    MemoryColumn* spaceColumn, MemoryColumn* memoryMapColumn)\n{\n    memoryMapItems_.clear();\n    spaceItems_.clear();\n\n    QVector<QString> addressSpaceIdentifiers;\n    addressSpaceIdentifiers.append(QStringLiteral(\"Address spaces\"));\n\n    QVector<QString> memoryMapIdentifiers;\n    memoryMapIdentifiers.append(QStringLiteral(\"Memory maps\"));\n\n    for (auto componentInstance : connectionGraph->getInstances())\n    {\n        for (auto memoryItem : componentInstance->getMemories())\n        {\n            if (memoryItem->getType().compare(\n                MemoryDesignerConstants::ADDRESSSPACE_TYPE, Qt::CaseInsensitive) == 0)\n            {\n                createAddressSpaceItem(\n                    memoryItem, addressSpaceIdentifiers, componentInstance, spaceColumn, memoryMapColumn);\n            }\n            else if (memoryItem->getType().compare(\n                MemoryDesignerConstants::MEMORYMAP_TYPE, Qt::CaseInsensitive) == 0)\n            {\n                createMemoryMapItem(memoryItem, memoryMapIdentifiers, componentInstance, memoryMapColumn);\n            }\n        }\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: MemoryGraphicsItemHandler::createAddressSpaceItem()\n//-----------------------------------------------------------------------------\nvoid MemoryGraphicsItemHandler::createAddressSpaceItem(QSharedPointer<MemoryItem const> spaceItem,\n    QVector<QString> identifierChain, QSharedPointer<ConnectivityComponent const> containingInstance,\n    MemoryColumn* spaceColumn, MemoryColumn* mapColumn)\n{\n    if (spaceColumn)\n    {\n        AddressSpaceGraphicsItem* spaceGraphicsItem = new AddressSpaceGraphicsItem(\n            spaceItem, identifierChain, containingInstance, filterAddressSpaceSegments_, spaceColumn);\n        spaceColumn->addItem(spaceGraphicsItem);\n\n        spaceItems_.append(spaceGraphicsItem);\n\n        connectGraphicsItemSignals(spaceGraphicsItem);\n\n        if (!spaceItem->getChildItems().isEmpty())\n        {\n            QSharedPointer<MemoryItem> lastChild = spaceItem->getChildItems().last();\n            if (lastChild->getType().compare(MemoryDesignerConstants::MEMORYMAP_TYPE, Qt::CaseInsensitive) == 0)\n            {\n                QVector<QString> localMapIdentifierChain = spaceGraphicsItem->getIdentifierChain();\n                createMemoryMapItem(lastChild, localMapIdentifierChain, containingInstance, mapColumn);\n            }\n        }\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: MemoryGraphicsItemHandler::createMemoryMapItem()\n//-----------------------------------------------------------------------------\nvoid MemoryGraphicsItemHandler::createMemoryMapItem(QSharedPointer<MemoryItem> mapItem,\n    QVector<QString> identifierChain, QSharedPointer<ConnectivityComponent const> containingInstance,\n    MemoryColumn* containingColumn)\n{\n    if (containingColumn)\n    {\n        MemoryMapGraphicsItem* mapGraphicsItem = new MemoryMapGraphicsItem(mapItem, identifierChain,\n            filterAddressBlocks_, filterRegisters_, filterFields_, containingInstance, containingColumn);\n        containingColumn->addItem(mapGraphicsItem);\n\n        memoryMapItems_.append(mapGraphicsItem);\n\n        connectGraphicsItemSignals(mapGraphicsItem);\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: MemoryGraphicsItemHandler::connectGraphicsItemSignals()\n//-----------------------------------------------------------------------------\nvoid MemoryGraphicsItemHandler::connectGraphicsItemSignals(MainMemoryGraphicsItem* graphicsItem)\n{\n    connect(graphicsItem, SIGNAL(openComponentDocument(VLNV const&, QVector<QString>)),\n        this, SIGNAL(openComponentDocument(VLNV const&, QVector<QString>)), Qt::UniqueConnection);\n}\n\n//-----------------------------------------------------------------------------\n// Function: MemoryGraphicsItemHandler::createFieldOverlapItems()\n//-----------------------------------------------------------------------------\nvoid MemoryGraphicsItemHandler::createFieldOverlapItems()\n{\n    for (MemoryMapGraphicsItem* mapItem : memoryMapItems_)\n    {\n        mapItem->createFieldOverlapItems();\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: MemoryGraphicsItemHandler::cloneMemoryItem()\n//-----------------------------------------------------------------------------\nMainMemoryGraphicsItem* MemoryGraphicsItemHandler::cloneMemoryItem(MainMemoryGraphicsItem* targetItem, MemoryColumn* containingColumn)\n{\n    MainMemoryGraphicsItem* clonedItem = nullptr;\n\n    auto originalItem = getOriginalItem(targetItem);\n    if (containingColumn && originalItem != nullptr)\n    {\n        if (auto mapItem = dynamic_cast<MemoryMapGraphicsItem const*>(originalItem); mapItem)\n        {\n            auto clonedMap = new MemoryMapGraphicsItem(*mapItem);\n            memoryMapItems_.append(clonedMap);\n\n            connectGraphicsItemSignals(clonedMap);\n            containingColumn->addItem(clonedMap, true);\n\n            clonedItem = clonedMap;\n        }\n        else if (auto spaceItem = dynamic_cast<AddressSpaceGraphicsItem const*>(originalItem); spaceItem)\n        {\n            auto clonedSpace = new AddressSpaceGraphicsItem(*spaceItem);\n            spaceItems_.append(clonedSpace);\n\n            connectGraphicsItemSignals(clonedSpace);\n            containingColumn->addItem(clonedSpace, true);\n\n            clonedItem = clonedSpace;\n        }\n    }\n\n    if (clonedItem != nullptr)\n    {\n        originalItem->getClones()->append(clonedItem);\n    }\n\n    return clonedItem;\n}\n\n//-----------------------------------------------------------------------------\n// Function: MemoryGraphicsItemHandler::getOriginalItem()\n//-----------------------------------------------------------------------------\nMainMemoryGraphicsItem* MemoryGraphicsItemHandler::getOriginalItem(MainMemoryGraphicsItem* suspiciousItem)\n{\n    MainMemoryGraphicsItem* originalItem = suspiciousItem;\n\n    if (originalItem != nullptr && originalItem->isOriginal() == false)\n    {\n        if (originalItem->type() == GraphicsItemTypes::GFX_TYPE_ADDRESS_SPACE_ITEM)\n        {\n            for (auto spaceItem : spaceItems_)\n            {\n                if (spaceItem->name() == originalItem->name() && spaceItem->isOriginal())\n                {\n                    originalItem = spaceItem;\n                    break;\n                }\n            }\n        }\n        else if (originalItem->type() == GraphicsItemTypes::GFX_TYPE_MEMORY_ITEM)\n        {\n            for (auto mapItem : memoryMapItems_)\n            {\n                if (mapItem->name() == originalItem->name() && mapItem->isOriginal())\n                {\n                    originalItem = mapItem;\n                    break;\n                }\n            }\n        }\n    }\n\n    return originalItem;\n}\n\n//-----------------------------------------------------------------------------\n// Function: MemoryGraphicsItemHandler::itemHasCloneWithBaseAddress()\n//-----------------------------------------------------------------------------\nbool MemoryGraphicsItemHandler::itemHasCloneWithBaseAddress(MainMemoryGraphicsItem* originalItem, quint64 const& baseAddress) const\n{\n    for (auto cloneItem : *originalItem->getClones())\n    {\n        if (cloneItem->getBaseAddress() == baseAddress)\n        {\n            return true;\n        }\n    }\n\n    return false;\n}\n\n//-----------------------------------------------------------------------------\n// Function: MemoryGraphicsItemHandler::getClonedItemWithBaseAddress()\n//-----------------------------------------------------------------------------\nMainMemoryGraphicsItem* MemoryGraphicsItemHandler::getClonedItemWithBaseAddress(MainMemoryGraphicsItem* originalItem, quint64 const& baseAddress)\n{\n    for (auto cloneItem : *originalItem->getClones())\n    {\n        if (cloneItem->getBaseAddress() == baseAddress)\n        {\n            return cloneItem;\n        }\n    }\n\n    return nullptr;\n}\n"
  },
  {
    "path": "editors/MemoryDesigner/MemoryGraphicsItemHandler.h",
    "content": "//-----------------------------------------------------------------------------\n// File: MemoryGraphicsItemHandler.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 03.01.2017\n//\n// Description:\n// Constructs the memory graphics items for the memory design diagram.\n//-----------------------------------------------------------------------------\n\n#ifndef MEMORYGRAPHICSITEMHANDLER_H\n#define MEMORYGRAPHICSITEMHANDLER_H\n\n#include <IPXACTmodels/common/VLNV.h>\n\nclass ConnectivityGraph;\nclass MemoryColumn;\nclass MemoryItem;\nclass ConnectivityComponent;\nclass MemoryMapGraphicsItem;\nclass AddressSpaceGraphicsItem;\nclass MainMemoryGraphicsItem;\n\n#include <QSharedPointer>\n#include <QVector>\n#include <QObject>\n\n//-----------------------------------------------------------------------------\n//! Constructs the memory graphics items for the memory design diagram.\n//-----------------------------------------------------------------------------\nclass MemoryGraphicsItemHandler : public QObject\n{\n    Q_OBJECT\n\npublic:\n\n    /*!\n     *  The constructor.\n     */    \n    MemoryGraphicsItemHandler();\n\n    /*!\n     *  The destructor.\n     */\n    ~MemoryGraphicsItemHandler();\n    \n    /*!\n     *  Set a new value for filtering the address space segments.\n     *\n     *    @param [in] filterSegments  Value for filtering address space segments.\n     */\n    void setFilterAddressSpaceSegments(bool filterSegments);\n\n    /*!\n     *  Check if the address space segments are filtered.\n     *\n     *    @return True, if the address space segments are filtered, false otherwise.\n     */\n    bool addressSpaceSegmentsAreFiltered() const;\n\n    /*!\n     *  Set a new value for filtering the address blocks.\n     *\n     *    @param [in] filterBlocks    Value for filtering address blocks.\n     */\n    void setFilterAddressBlocks(bool filterBlocks);\n\n    /*!\n     *  Check if the address blocks are filtered.\n     *\n     *    @return True, if the address blocks are filtered, false otherwise.\n     */\n    bool addressBlocksAreFiltered() const;\n\n    /*!\n     *  Set a new value for filtering the address block registers.\n     *\n     *    @param [in] filterSegments  Value for filtering address block registers.\n     */\n    void setFilterAddressBlockRegisters(bool filterRegisters);\n\n    /*!\n     *  Check if the address block registers are filtered.\n     *\n     *    @return True, if the address block registers are filtered, false otherwise.\n     */\n    bool addressBlockRegistersAreFiltered() const;\n\n    /*!\n     *  Set a new value for filtering the register fields.\n     *\n     *    @param [in] filterFields    Value for filtering register fields.\n     */\n    void setFilterFields(bool filterFields);\n\n    /*!\n     *  Check if the register fields are filtered.\n     *\n     *    @return True, if the register fields are filtered, false otherwise.\n     */\n    bool fieldsAreFiltered() const;\n\n    /*!\n     *  Set a new value for filtering the unconnected memory items.\n     *\n     *    @param [in] filterUnconnected   Value for filtering unconnected memory items.\n     */\n    void filterUnconnectedMemoryItems(bool filterUnconnected);\n\n    /*!\n     *  Check if the unconnected memory items are filtered.\n     *\n     *    @return True, if the unconnected memory items are filtered, false otherwise.\n     */\n    bool unconnectedMemoryItemsAreFiltered() const;\n\n    /*!\n     *  Set a new value for filtering the memory overlap items.\n     *\n     *    @param [in] filterOverlap       Value for filtering memory overlap.\n     */\n    void filterMemoryOverlapItems(bool filterOverlap);\n\n    /*!\n     *  Check if the memory overlap items are filtered.\n     *\n     *    @return True, if the memory overlap items are filtered, false otherwise.\n     */\n    bool memoryOverlapItemsAreFiltered() const;\n\n    /*!\n     *  Create the memory items found in the design.\n     *\n     *    @param [in] connectionGraph     Graph containing the connection paths.\n     *    @param [in] spaceColumn         Column for the address space graphics items.\n     *    @param [in] memoryMapColumn     Column for the memory map graphics items.\n     */\n    void createMemoryItems(QSharedPointer<ConnectivityGraph> connectionGraph, MemoryColumn* spaceColumn,\n        MemoryColumn* memoryMapColumn);\n\n    /*!\n     *  Create overlap items for register graphics items.\n     */\n    void createFieldOverlapItems();\n\n    /*!\n     *  Clone the selected memory item.\n     *\n     *    @param [in] targetItem        The selected memory item.\n     *    @param [in] containingColumn  Column containing the selected memory item.\n     *\n     *    @return The cloned memory item.\n     */\n    MainMemoryGraphicsItem* cloneMemoryItem(MainMemoryGraphicsItem* targetItem, MemoryColumn* containingColumn);\n\n    /*!\n     *  Check if the selected item has been cloned and has the selected base address.\n     *\n     *    @param [in] originalItem  The selected item.\n     *    @param [in] baseAddress   The selected base address.\n     *\n     *    @return True, if the item exists, false otherwise.\n     */\n    bool itemHasCloneWithBaseAddress(MainMemoryGraphicsItem* originalItem, quint64 const& baseAddress) const;\n\n    /*!\n     *  Get the cloned memory item of the selected item with the selected base address.\n     *\n     *    @param [in] originalItem  The selected item.\n     *    @param [in] baseAddress   The selected base address.\n     *\n     *    @return The cloned memory item.\n     */\n    MainMemoryGraphicsItem* getClonedItemWithBaseAddress(MainMemoryGraphicsItem* originalItem, quint64 const& baseAddress);\n\nsignals:\n\n    /*!\n     *  Open the component document for the selected VLNV.\n     *\n     *    @param [in] vlnv                VLNV of the containing component.\n     *    @param [in] identifierChain     List of string identifying the memory item.\n     */\n    void openComponentDocument(VLNV const& vlnv, QVector<QString> identifierChain);\n\nprivate:\n    // Disable copying.\n    MemoryGraphicsItemHandler(MemoryGraphicsItemHandler const& rhs);\n    MemoryGraphicsItemHandler& operator=(MemoryGraphicsItemHandler const& rhs);\n\n        /*!\n     *  Create an address space item.\n     *\n     *    @param [in] spaceItem           Memory item containing address space data.\n     *    @param [in] identifierChain     List of string identifying the memory item.\n     *    @param [in] containingInstance  The component instance containing the selected address space.\n     *    @param [in] spaceColumn         The address space column.\n     *    @param [in] mapColumn           The memory map column.\n     */\n    void createAddressSpaceItem(QSharedPointer<MemoryItem const> spaceItem, QVector<QString> identifierChain,\n        QSharedPointer<ConnectivityComponent const> containingInstance, MemoryColumn* spaceColumn,\n        MemoryColumn* mapColumn);\n\n    /*!\n     *  Create a memory map item.\n     *\n     *    @param [in] mapItem             Memory item containing memory map data.\n     *    @param [in] identifierChain     List of string identifying the memory item.\n     *    @param [in] containingInstance  The component instance containing the selected memory map.\n     *    @param [in] containingColumn    The memory map column.\n     */\n    void createMemoryMapItem(QSharedPointer<MemoryItem> mapItem, QVector<QString> identifierChain,\n        QSharedPointer<ConnectivityComponent const> containingInstance, MemoryColumn* containingColumn);\n\n    /*!\n     *  Connect the signals from the selected memory graphics item.\n     *\n     *    @param [in] graphicsItem    The selected memory graphics item.\n     */\n    void connectGraphicsItemSignals(MainMemoryGraphicsItem* graphicsItem);\n\n    /*!\n     *  Filter a single unconnected memory item.\n     *\n     *    @param [in] memoryItem  The selected memory item.\n     */\n    void filterUnconnectedMemoryItem(MainMemoryGraphicsItem* memoryItem);\n\n    /*!\n     *  Get the original item for the selected item.\n     *\n     *    @param [in] suspiciousItem    The selected item with unknown status as original or clone.\n     *\n     *    @return The original item of the selected item.\n     */\n    MainMemoryGraphicsItem* getOriginalItem(MainMemoryGraphicsItem* suspiciousItem);\n\n    //-----------------------------------------------------------------------------\n    // Data.\n    //-----------------------------------------------------------------------------\n\n    //! Value for filtering address space segments.\n    bool filterAddressSpaceSegments_ = true;\n\n    //! Value for filtering memory map address blocks.\n    bool filterAddressBlocks_ = true;\n\n    //! Value for filtering address block registers.\n    bool filterRegisters_ = true;\n\n    //! Value for filtering register fields.\n    bool filterFields_ = true;\n\n    //! Value for filtering unconnected memory items.\n    bool filterUnconnectedMemoryItems_ = true;\n\n    //! Value for filtering memory overlap items.\n    bool filterMemoryOverlapItems_ = false;\n\n    //! List of all the created memory map graphics items.\n    QVector<MemoryMapGraphicsItem*> memoryMapItems_;\n\n    //! List of all the created address space graphics items.\n    QVector<AddressSpaceGraphicsItem*> spaceItems_;\n};\n\n//-----------------------------------------------------------------------------\n\n#endif // MEMORYCOLUMNHANDLER_H\n"
  },
  {
    "path": "editors/MemoryDesigner/MemoryItem.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: MemoryItem.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Esko Pekkarinen\r\n// Date: 03.08.2016\r\n//\r\n// Description:\r\n// A memory in a connectivity graph.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"MemoryItem.h\"\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryItem::MemoryItem()\r\n//-----------------------------------------------------------------------------\r\nMemoryItem::MemoryItem(QString const& name, QString const& type):\r\nname_(name),\r\ntype_(type)\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryItem::getName()\r\n//-----------------------------------------------------------------------------\r\nQString MemoryItem::getName() const\r\n{\r\n    return name_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryItem::getType()\r\n//-----------------------------------------------------------------------------\r\nQString MemoryItem::getType() const\r\n{\r\n    return type_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryItem::setDisplayName()\r\n//-----------------------------------------------------------------------------\r\nvoid MemoryItem::setDisplayName(QString const& displayName)\r\n{\r\n    displayName_ = displayName;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryItem::getDisplayName()\r\n//-----------------------------------------------------------------------------\r\nQString MemoryItem::getDisplayName() const\r\n{\r\n    return displayName_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryItem::setDescription()\r\n//-----------------------------------------------------------------------------\r\nvoid MemoryItem::setDescription(QString const& newDescription)\r\n{\r\n    description_ = newDescription;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryItem::getDescription()\r\n//-----------------------------------------------------------------------------\r\nQString MemoryItem::getDescription() const\r\n{\r\n    return description_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryItem::setIdentifier()\r\n//-----------------------------------------------------------------------------\r\nvoid MemoryItem::setIdentifier(QString const& identifier)\r\n{\r\n    identifier_ = identifier;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryItem::getIdentifier()\r\n//-----------------------------------------------------------------------------\r\nQString MemoryItem::getIdentifier() const\r\n{\r\n    return identifier_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryItem::setAUB()\r\n//-----------------------------------------------------------------------------\r\nvoid MemoryItem::setAUB(QString const& aub)\r\n{\r\n    aub_ = aub;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryItem::getAUB()\r\n//-----------------------------------------------------------------------------\r\nQString MemoryItem::getAUB() const\r\n{\r\n    return aub_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryItem::setAddress()\r\n//-----------------------------------------------------------------------------\r\nvoid MemoryItem::setAddress(QString const& address)\r\n{\r\n    address_ = address;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryItem::getAddress()\r\n//-----------------------------------------------------------------------------\r\nQString MemoryItem::getAddress() const\r\n{\r\n    return address_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryItem::setFormattedAddressExpression()\r\n//-----------------------------------------------------------------------------\r\nvoid MemoryItem::setFormattedAddressExpression(QString const& newFormattedAddressExpression)\r\n{\r\n    formattedAddressExpression_ = newFormattedAddressExpression;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryItem::getFormattedAddressExpression()\r\n//-----------------------------------------------------------------------------\r\nQString MemoryItem::getFormattedAddressExpression() const\r\n{\r\n    return formattedAddressExpression_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryItem::setRange()\r\n//-----------------------------------------------------------------------------\r\nvoid MemoryItem::setRange(QString const& range)\r\n{\r\n    range_ = range;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryItem::getRange()\r\n//-----------------------------------------------------------------------------\r\nQString MemoryItem::getRange() const\r\n{\r\n    return range_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryItem::setFormattedRangeExpression()\r\n//-----------------------------------------------------------------------------\r\nvoid MemoryItem::setFormattedRangeExpression(QString const& newRangeExpression)\r\n{\r\n    formattedRangeExpressin_ = newRangeExpression;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryItem::getFormattedRangeExpression()\r\n//-----------------------------------------------------------------------------\r\nQString MemoryItem::getFormattedRangeExpression() const\r\n{\r\n    return formattedRangeExpressin_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryItem::setWidth()\r\n//-----------------------------------------------------------------------------\r\nvoid MemoryItem::setWidth(QString const& width)\r\n{\r\n    width_ = width;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryItem::getWidth()\r\n//-----------------------------------------------------------------------------\r\nQString MemoryItem::getWidth() const\r\n{\r\n    return width_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryItem::setFormattedWidthExpression()\r\n//-----------------------------------------------------------------------------\r\nvoid MemoryItem::setFormattedWidthExpression(QString const& newWidthExpression)\r\n{\r\n    formattedWidthExpression_ = newWidthExpression;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryItem::getFormattedWidthExpression()\r\n//-----------------------------------------------------------------------------\r\nQString MemoryItem::getFormattedWidthExpression() const\r\n{\r\n    return formattedWidthExpression_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryItem::setAccess()\r\n//-----------------------------------------------------------------------------\r\nvoid MemoryItem::setAccess(AccessTypes::Access const& newAccess)\r\n{\r\n    access_ = newAccess;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryItem::getAccess()\r\n//-----------------------------------------------------------------------------\r\nAccessTypes::Access MemoryItem::getAccess() const\r\n{\r\n    return access_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryItem::setSize()\r\n//-----------------------------------------------------------------------------\r\nvoid MemoryItem::setSize(QString const& size)\r\n{\r\n    size_ = size;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryItem::getSize()\r\n//-----------------------------------------------------------------------------\r\nQString MemoryItem::getSize() const\r\n{\r\n    return size_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryItem::setOffset()\r\n//-----------------------------------------------------------------------------\r\nvoid MemoryItem::setOffset(QString const& offset)\r\n{\r\n    offset_ = offset;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryItem::getOffset()\r\n//-----------------------------------------------------------------------------\r\nQString MemoryItem::getOffset() const\r\n{\r\n    return offset_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryItem::setFormattedOffsetExpression()\r\n//-----------------------------------------------------------------------------\r\nvoid MemoryItem::setFormattedOffsetExpression(QString const& newOffsetExpression)\r\n{\r\n    formattedOffsetExpression_ = newOffsetExpression;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryItem::getFormattedOffsetExpression()\r\n//-----------------------------------------------------------------------------\r\nQString MemoryItem::getFormattedOffsetExpression() const\r\n{\r\n    return formattedOffsetExpression_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryItem::addChild()\r\n//-----------------------------------------------------------------------------\r\nvoid MemoryItem::addChild(QSharedPointer<MemoryItem> child)\r\n{\r\n    childItems_.append(child);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryItem::getChildItems()\r\n//-----------------------------------------------------------------------------\r\nQVector<QSharedPointer<MemoryItem> > MemoryItem::getChildItems() const\r\n{\r\n    return childItems_;         \r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryItem::setDimension()\r\n//-----------------------------------------------------------------------------\r\nvoid MemoryItem::setDimension(QString const& dimension)\r\n{\r\n    dimension_ = dimension;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryItem::getWidth()\r\n//-----------------------------------------------------------------------------\r\nQString MemoryItem::getDimension() const\r\n{\r\n    return dimension_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryItem::setUsage()\r\n//-----------------------------------------------------------------------------\r\nvoid MemoryItem::setUsage(General::Usage const& newUsage)\r\n{\r\n    usage_ = newUsage;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryItem::getUsage()\r\n//-----------------------------------------------------------------------------\r\nGeneral::Usage MemoryItem::getUsage() const\r\n{\r\n    return usage_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryItem::setValue()\r\n//-----------------------------------------------------------------------------\r\nvoid MemoryItem::setValue(QString const& newValue)\r\n{\r\n    value_ = newValue;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryItem::getValue()\r\n//-----------------------------------------------------------------------------\r\nQString MemoryItem::getValue() const\r\n{\r\n    return value_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryItem::getResetValue()\r\n//-----------------------------------------------------------------------------\r\nQString MemoryItem::getResetValue() const\r\n{\r\n    return resetValue_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryItem::setResetValue()\r\n//-----------------------------------------------------------------------------\r\nvoid MemoryItem::setResetValue(QString const& newResetValue)\r\n{\r\n    resetValue_ = newResetValue;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryItem::getResetMask()\r\n//-----------------------------------------------------------------------------\r\nQString MemoryItem::getResetMask() const\r\n{\r\n    return resetMask_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryItem::setResetMask()\r\n//-----------------------------------------------------------------------------\r\nvoid MemoryItem::setResetMask(QString const& newResetMask)\r\n{\r\n    resetMask_ = newResetMask;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryItem::getIsPresent()\r\n//-----------------------------------------------------------------------------\r\nQString MemoryItem::getIsPresent() const\r\n{\r\n    return isPresent_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryItem::setIsPresent()\r\n//-----------------------------------------------------------------------------\r\nvoid MemoryItem::setIsPresent(QString const& newIsPresent)\r\n{\r\n    isPresent_ = newIsPresent;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryItem::setAddressSpaceReference()\r\n//-----------------------------------------------------------------------------\r\nvoid MemoryItem::setInitiatorReference(QString const& newReference)\r\n{\r\n    initiatorReference_ = newReference;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryItem::getAddressSpaceReference()\r\n//-----------------------------------------------------------------------------\r\nQString MemoryItem::getInitiatorReference() const\r\n{\r\n    return initiatorReference_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryItem::setSegmentReference()\r\n//-----------------------------------------------------------------------------\r\nvoid MemoryItem::setSegmentReference(QString const& newReference)\r\n{\r\n    segmentReference_ = newReference;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryItem::getSegmentReference()\r\n//-----------------------------------------------------------------------------\r\nQString MemoryItem::getSegmentReference() const\r\n{\r\n    return segmentReference_;\r\n}\r\n"
  },
  {
    "path": "editors/MemoryDesigner/MemoryItem.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: MemoryItem.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Esko Pekkarinen\r\n// Date: 03.08.2016\r\n//\r\n// Description:\r\n// A memory in a connectivity graph.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef MEMORYITEM_H\r\n#define MEMORYITEM_H\r\n\r\n#include <IPXACTmodels/common/AccessTypes.h>\r\n#include <IPXACTmodels/generaldeclarations.h>\r\n\r\n#include <QString>\r\n#include <QSharedPointer>\r\n#include <QVector>\r\n\r\n//-----------------------------------------------------------------------------\r\n//! A memory in a connectivity graph.\r\n//-----------------------------------------------------------------------------\r\nclass MemoryItem \r\n{\r\npublic:\r\n\r\n\t/*!\r\n\t *  The constructor.\r\n\t *\r\n\t *    @param [in] name   The name of the memory.\r\n     *    @param [in] type   The type of the memory.\r\n\t */\r\n\tMemoryItem(QString const& name, QString const& type);\r\n\r\n    /*!\r\n     *  Gets the name of the memory.\r\n     *\r\n     *    @return The name of the memory.\r\n     */\r\n    QString getName() const;\r\n\r\n    /*!\r\n     *  Gets the type of the memory e.g. address space or register.\r\n     *\r\n     *    @return The type of the memory.\r\n     */\r\n    QString getType() const;\r\n\r\n    /*!\r\n     *  Sets a display name for the memory.\r\n     *\r\n     *    @param [in] displayName   The display name to set.\r\n     */\r\n    void setDisplayName(QString const& displayName);\r\n\r\n    /*!\r\n     *  Gets the display name of the memory.\r\n     *\r\n     *    @return The display name of the memory.\r\n     */\r\n    QString getDisplayName() const;\r\n\r\n    /*!\r\n     *  Set the description\r\n     *\r\n     *    @param [in] newDescription    The new description.\r\n     */\r\n    void setDescription(QString const& newDescription);\r\n\r\n    /*!\r\n     *  Get the description\r\n     *\r\n     *    @return The description\r\n     */\r\n    QString getDescription() const;\r\n\r\n    /*!\r\n     *  Sets an identifier for the memory.\r\n     *\r\n     *    @param [in] identifier   The identifier to set.\r\n     */\r\n    void setIdentifier(QString const& identifier);\r\n    \r\n    /*!\r\n     *  Gets the memory identifier.\r\n     *\r\n     *    @return The identifier for the memory.\r\n     */\r\n    QString getIdentifier() const;\r\n\r\n    /*!\r\n     *  Gets the number of addressable unit bits in the memory.\r\n     *\r\n     *    @return The number addressable unit bits in the memory.\r\n     */\r\n    QString getAUB() const;\r\n\r\n    /*!\r\n     *  Sets the number of addressable unit bits in the memory.\r\n     *\r\n     *    @param [in] aub   The number of bits in an addressable unit.\r\n     */\r\n    void setAUB(QString const& aub);\r\n\r\n    /*!\r\n     *  Sets the address for the memory.\r\n     *\r\n     *    @param [in] address   The memory address to set.\r\n     */\r\n    void setAddress(QString const& address);\r\n\r\n    /*!\r\n     *  Gets the memory address.\r\n     *\r\n     *    @return The address for the memory.\r\n     */\r\n    QString getAddress() const;\r\n\r\n    /*!\r\n     *  Set the formatted address expression.\r\n     *\r\n     *    @param [in] newFormattedAddressExpression     The new formatted address expression.\r\n     */\r\n    void setFormattedAddressExpression(QString const& newFormattedAddressExpression);\r\n\r\n    /*!\r\n     *  Get the formatted address expression.\r\n     *\r\n     *    @return The formatted address expression.\r\n     */\r\n    QString getFormattedAddressExpression() const;\r\n\r\n    /*!\r\n     * Sets the range for the memory.\r\n     *\r\n     *    @param [in] range   The range to set.\r\n     */\r\n    void setRange(QString const& range);\r\n\r\n    /*!\r\n     *  Gets the range for the memory.\r\n     *\r\n     *    @return The range for the memory.\r\n     */\r\n    QString getRange() const;\r\n\r\n    /*!\r\n     *  Set the formatted range expression.\r\n     *\r\n     *    @param [in] newFormattedRangeExpression   The new formatted range expression.\r\n     */\r\n    void setFormattedRangeExpression(QString const& newRangeExpression);\r\n\r\n    /*!\r\n     *  Get the formatted range expression.\r\n     *\r\n     *    @return The formatted range expression.\r\n     */\r\n    QString getFormattedRangeExpression() const;\r\n\r\n    /*!\r\n     *  Sets the width for the memory.\r\n     *\r\n     *    @param [in] width   The memory width to set.\r\n     */\r\n    void setWidth(QString const& width);\r\n\r\n    /*!\r\n     *  Gets the memory width in bits.\r\n     *\r\n     *    @return The width of the memory.\r\n     */\r\n    QString getWidth() const;\r\n\r\n    /*!\r\n     *  Set the formatted width expression.\r\n     *\r\n     *    @param [in] newFormattedWidthExpression   The new formatted width expression.\r\n     */\r\n    void setFormattedWidthExpression(QString const& newWidthExpression);\r\n\r\n    /*!\r\n     *  Get the formatted width expression.\r\n     *\r\n     *    @return The formatted width expression.\r\n     */\r\n    QString getFormattedWidthExpression() const;\r\n\r\n\t/*!\r\n\t *  Set the access value.\r\n\t *\r\n\t *    @param [in] newAccess     The new access value.\r\n\t */\r\n\tvoid setAccess(AccessTypes::Access const& newAccess);\r\n\r\n    /*!\r\n     *  Get the access value.\r\n     *\r\n     *    @return The access value.\r\n     */\r\n    AccessTypes::Access getAccess() const;\r\n\r\n    /*!\r\n     *  Sets the size for the memory.\r\n     *\r\n     *    @param [in] size    The size to set.\r\n     */\r\n    void setSize(QString const& size);\r\n\r\n    /*!\r\n     *  Gets the size for the memory.\r\n     *\r\n     *    @return The memory size.\r\n     */\r\n    QString getSize() const;\r\n\r\n    /*!\r\n     *  Sets the offset for the memory.\r\n     *\r\n     *    @param [in] offset   The offset to set.\r\n     */\r\n    void setOffset(QString const& offset);\r\n\r\n    /*!\r\n     *  Gets the offset for the memory.\r\n     *\r\n     *    @return The memory offset.\r\n     */\r\n    QString getOffset() const;\r\n\r\n    /*!\r\n     *  Set the formatted offset expression.\r\n     *\r\n     *    @param [in] newFormattedOffsetExpression  The new formatted offset expression.\r\n     */\r\n    void setFormattedOffsetExpression(QString const& newOffsetExpression);\r\n\r\n    /*!\r\n     *  Get the formatted offset expression.\r\n     *\r\n     *    @return The formatted offset expression.\r\n     */\r\n    QString getFormattedOffsetExpression() const;\r\n\r\n    /*!\r\n     *  Adds a sub-element for the memory.\r\n     *\r\n     *    @param [in] child   The sub-element to add.\r\n     */\r\n    void addChild(QSharedPointer<MemoryItem> child);\r\n\r\n    /*!\r\n     *  Gets the sub-elements for the memory.\r\n     *\r\n     *    @return The sub-elements for the memory.\r\n     */\r\n    QVector<QSharedPointer<MemoryItem> > getChildItems() const;\r\n\r\n    /*!\r\n     *  Set the dimension of the memory item.\r\n     *\r\n     *    @param [in] dimension    The new dimension value.\r\n     */\r\n    void setDimension(QString const& dimension);\r\n\r\n    /*!\r\n     *  Gets the dimension of the memory. Only used for registers.\r\n     *\r\n     *    @return The dimension of the memory.\r\n     */\r\n    QString getDimension() const;\r\n\r\n    /*!\r\n     *  Set the usage for the memory item.\r\n     *\r\n     *    @param [in] newUsage    The new usage value.\r\n     */\r\n    void setUsage(General::Usage const& newUsage);\r\n\r\n    /*!\r\n     *  Get the usage of the memory item.\r\n     *\r\n     *    @return The usage value.\r\n     */\r\n    General::Usage getUsage() const;\r\n\r\n    /*!\r\n     *  Set the value for the memory item.\r\n     *\r\n     *    @param [in] newValue    The new value.\r\n     */\r\n    void setValue(QString const& newValue);\r\n\r\n    /*!\r\n     *  Get the value of the memory item.\r\n     *\r\n     *    @return The value.\r\n     */\r\n    QString getValue() const;\r\n\r\n    /*!\r\n     *  Get the reset value of the memory item.\r\n     *\r\n     *    @return The reset value of the memory item.\r\n     */\r\n    QString getResetValue() const;\r\n\r\n    /*!\r\n     *  Set a new reset value for the memory item.\r\n     *\r\n     *    @param [in] newResetValue   The new reset value.\r\n     */\r\n    void setResetValue(QString const& newResetValue);\r\n\r\n    /*!\r\n     *  Get the reset mask of the memory item.\r\n     *\r\n     *    @return The reset mask of the memory item.\r\n     */\r\n    QString getResetMask() const;\r\n\r\n    /*!\r\n     *  Set a new reset mask for the memory item.\r\n     *\r\n     *    @param [in] newResetMask    The new reset mask.\r\n     */\r\n    void setResetMask(QString const& newResetMask);\r\n\r\n    /*!\r\n     *  Get the is present of the memory item.\r\n     *\r\n     *    @return The is present of the memory item.\r\n     */\r\n    QString getIsPresent() const;\r\n\r\n    /*!\r\n     *  Set a new is present for the memory item.\r\n     *\r\n     *    @param [in] newIsPresent    The new is present.\r\n     */\r\n    void setIsPresent(QString const& newIsPresent);\r\n\r\n    /*!\r\n     *  Set a new initiator reference for the memory item.\r\n     *\r\n     *    @param [in] newReference    The new initiator reference.\r\n     */\r\n    void setInitiatorReference(QString const& newReference);\r\n\r\n    /*!\r\n     *  Get the initiator reference of the memory item.\r\n     */\r\n    QString getInitiatorReference() const;\r\n\r\n    /*!\r\n     *  Set a new segment reference for the memory item.\r\n     *\r\n     *    @param [in] newReference    The new segment reference.\r\n     */\r\n    void setSegmentReference(QString const& newReference);\r\n\r\n    /*!\r\n     *  Get the segment reference of the memory item.\r\n     */\r\n    QString getSegmentReference() const;\r\n\r\nprivate:\r\n    //! The name of the memory element.\r\n    QString name_ = \"\";\r\n\r\n    //! The display name of the memory element.\r\n    QString displayName_ = \"\";\r\n\r\n    //! Description of the memory element.\r\n    QString description_ = \"\";\r\n\r\n    //! The type of the memory element.\r\n    QString type_ = \"\";\r\n\r\n    //! The identifier for the memory.\r\n    QString identifier_ = \"\";\r\n\r\n    //! The number of addressable unit bits in the memory.\r\n    QString aub_ = \"\";\r\n\r\n    //! The address for the memory.\r\n    QString address_ = \"\";\r\n\r\n    //! Formatted address expression for the memory.\r\n    QString formattedAddressExpression_ = \"\";\r\n\r\n    //! The range for the memory.\r\n    QString range_ = \"\";\r\n\r\n\t//! Formatted range expression for the memory.\r\n    QString formattedRangeExpressin_ = \"\";\r\n\r\n    //! The bit width for the memory.\r\n    QString width_ = \"\";\r\n\r\n\t//! Formatted width expression for the memory.\r\n    QString formattedWidthExpression_ = \"\";\r\n\r\n    //! Access value of the memory.\r\n    AccessTypes::Access access_ = AccessTypes::ACCESS_COUNT;\r\n\r\n    //! The size of the memory.\r\n    QString size_ = \"\";\r\n\r\n    //! The offset of the memory.\r\n    QString offset_ = \"\";\r\n\r\n\t//! Formatted offset expression for the memory.\r\n    QString formattedOffsetExpression_ = \"\";\r\n\r\n    //! Value of the memory item.\r\n    QString value_ = \"\";\r\n\r\n    //! The dimension for the memory.\r\n    QString dimension_ = \"\";\r\n\r\n    //! The usage value of the memory item.\r\n    General::Usage usage_{ General::USAGE_COUNT };\r\n\r\n    //! Reset value of the memory item.\r\n    QString resetValue_ = \"\";\r\n\r\n    //! Reset mask of the memory item.\r\n    QString resetMask_ = \"\";\r\n\r\n    //! Presence of the memory item.\r\n    QString isPresent_{ \"1\" };\r\n\r\n    //! The initiator reference.\r\n    QString initiatorReference_ = \"\";\r\n\r\n    //! The segment reference.\r\n    QString segmentReference_ = \"\";\r\n\r\n    //! The sub-elements of the memory.\r\n    QVector<QSharedPointer<MemoryItem> > childItems_;\r\n};\r\n\r\n#endif // MEMORYITEM_H\r\n"
  },
  {
    "path": "editors/MemoryDesigner/MemoryMapGraphicsItem.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: MemoryMapGraphicsItem.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Mikko Teuho\r\n// Date: 09.08.2016\r\n//\r\n// Description:\r\n// Graphics item for visualizing a memory map in the memory designer.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"MemoryMapGraphicsItem.h\"\r\n\r\n#include <common/KactusColors.h>\r\n\r\n#include <editors/MemoryDesigner/MemoryItem.h>\r\n#include <editors/MemoryDesigner/ConnectivityComponent.h>\r\n#include <editors/MemoryDesigner/AddressBlockGraphicsItem.h>\r\n#include <editors/MemoryDesigner/RegisterGraphicsItem.h>\r\n#include <editors/MemoryDesigner/MemoryDesignerConstants.h>\r\n#include <editors/MemoryDesigner/MemoryConnectionItem.h>\r\n#include <editors/MemoryDesigner/MemoryExtensionGraphicsItem.h>\r\n#include <editors/MemoryDesigner/MemoryConnectionAddressCalculator.h>\r\n\r\n#include <QBrush>\r\n#include <QFont>\r\n#include <QPen>\r\n\r\nnamespace MemoryMapItemConstants\r\n{\r\n    const int MINIMUMSUBITEMHEIGHT = 3 * MemoryDesignerConstants::RANGEINTERVAL;\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryMapGraphicsItem::MemoryMapGraphicsItem()\r\n//-----------------------------------------------------------------------------\r\nMemoryMapGraphicsItem::MemoryMapGraphicsItem(QSharedPointer<MemoryItem> memoryItem,\r\n    QVector<QString> identifierChain, bool filterAddressBlocks, bool filterRegisters, bool filterFields,\r\n    QSharedPointer<ConnectivityComponent const> containingInstance, QGraphicsItem* parent):\r\nMainMemoryGraphicsItem(memoryItem, containingInstance, MemoryDesignerConstants::ADDRESSBLOCK_TYPE,\r\n    filterAddressBlocks, identifierChain, parent),\r\naddressUnitBits_(memoryItem->getAUB()),\r\nfilterAddressBlocks_(filterAddressBlocks),\r\nfilterRegisters_(filterRegisters),\r\nfilterFields_(filterFields)\r\n{\r\n    auto [baseAddress, lastAddress] = MemoryConnectionAddressCalculator::getMemoryMapAddressRanges(memoryItem);\r\n\r\n    setupMemoryMapItem(baseAddress, lastAddress);\r\n\r\n    qreal blockXPosition = MemoryDesignerConstants::MAPSUBITEMPOSITIONX;\r\n\r\n    subItemWidth_ = getSubItemWidth();\r\n\r\n    setupSubItems(blockXPosition, memoryItem);\r\n    setLabelPositions();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryMapGraphicsItem::MemoryMapGraphicsItem()\r\n//-----------------------------------------------------------------------------\r\nMemoryMapGraphicsItem::MemoryMapGraphicsItem(MemoryMapGraphicsItem const& other):\r\nMainMemoryGraphicsItem(other),\r\naddressUnitBits_(other.addressUnitBits_),\r\nfilterAddressBlocks_(other.filterAddressBlocks_),\r\nfilterRegisters_(other.filterRegisters_),\r\nfilterFields_(other.filterFields_),\r\nsubItemWidth_(other.subItemWidth_)\r\n{\r\n    setupMemoryMapItem(other.getOriginalBaseAddress(), other.getOriginalLastAddress());\r\n\r\n    cloneSubItems(other);\r\n    MemoryMapGraphicsItem::setLabelPositions();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryMapGraphicsItem::setupDuringConstruction()\r\n//-----------------------------------------------------------------------------\r\nvoid MemoryMapGraphicsItem::setupMemoryMapItem(quint64 const& baseAddress, quint64 const& lastAddress)\r\n{\r\n    QBrush memoryMapBrush(KactusColors::MEM_MAP_COLOR);\r\n    setBrush(memoryMapBrush);\r\n\r\n    quint64 memoryHeight = (lastAddress - baseAddress + 1);\r\n    int memoryWidth = MemoryDesignerConstants::MEMORYMAPFULLWIDTH;\r\n    if (filterRegisters_ || (filterAddressBlocks_ && filterFields_))\r\n    {\r\n        memoryWidth = MemoryDesignerConstants::ITEMWIDTH;\r\n    }\r\n    else if (filterFields_)\r\n    {\r\n        memoryWidth = MemoryDesignerConstants::ITEMWIDTH + MemoryDesignerConstants::MAPSUBITEMPOSITIONX * 2;\r\n    }\r\n    else if (filterAddressBlocks_)\r\n    {\r\n        memoryWidth -= MemoryDesignerConstants::MAPSUBITEMPOSITIONX * 2 + 1;\r\n    }\r\n\r\n    setGraphicsRectangle(memoryWidth, memoryHeight);\r\n    setupGraphicsItem(baseAddress, lastAddress, QStringLiteral(\"Memory Map\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryMapGraphicsItem::~MemoryMapGraphicsItem()\r\n//-----------------------------------------------------------------------------\r\nMemoryMapGraphicsItem::~MemoryMapGraphicsItem()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryMapGraphicsItem::setupSubItems()\r\n//-----------------------------------------------------------------------------\r\nvoid MemoryMapGraphicsItem::setupSubItems(qreal blockXPosition, QSharedPointer<MemoryItem> memoryItem)\r\n{\r\n    QString subItemType = getSubItemType();\r\n    QSharedPointer<MemoryItem> usedMemoryItem = memoryItem;\r\n\r\n    if (filterAddressBlocks_ && !filterRegisters_)\r\n    {\r\n        setFilterSubItems(filterRegisters_);\r\n\r\n        subItemType = MemoryDesignerConstants::REGISTER_TYPE;\r\n        usedMemoryItem = QSharedPointer<MemoryItem>(new MemoryItem(memoryItem->getName(), memoryItem->getType()));\r\n        usedMemoryItem->setAUB(memoryItem->getAUB());\r\n\r\n        for (QSharedPointer<MemoryItem const> subItem : memoryItem->getChildItems())\r\n        {\r\n            if (subItem->getType().compare(MemoryDesignerConstants::ADDRESSBLOCK_TYPE, Qt::CaseInsensitive) == 0)\r\n            {\r\n                quint64 blockBaseAddress = subItem->getAddress().toULongLong();\r\n                quint64 blockRange = subItem->getRange().toULongLong();\r\n\r\n                FilteredBlock blockItem;\r\n                blockItem.blockName_ = subItem->getName();\r\n                blockItem.blockBaseAddress_ = blockBaseAddress;\r\n                blockItem.blockLastAddress_ = blockBaseAddress + blockRange - 1;\r\n\r\n                filteredBlocks_.append(blockItem);\r\n\r\n                for (QSharedPointer<MemoryItem> registerItem : subItem->getChildItems())\r\n                {\r\n                    usedMemoryItem->addChild(registerItem);\r\n                }\r\n            }\r\n        }\r\n    }\r\n\r\n    SubMemoryLayout::setupSubItems(blockXPosition, subItemType, usedMemoryItem);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryMapGraphicsItem::setLabelPositions()\r\n//-----------------------------------------------------------------------------\r\nvoid MemoryMapGraphicsItem::setLabelPositions()\r\n{\r\n    QRectF nameLabelRect = getNameLabel()->boundingRect();\r\n    QRectF instanceLabelRect = getInstanceNameLabel()->boundingRect();\r\n\r\n    qreal nameLabelY = boundingRect().height() / 2 - (nameLabelRect.height() * 3 / 4);\r\n    qreal instanceNameLabelY = nameLabelY + nameLabelRect.height() / 2 + 1;\r\n\r\n    qreal nameLabelX = 0;\r\n    qreal instanceNameLabelX = 0;\r\n\r\n    if (subItemsAreFiltered())\r\n    {\r\n        nameLabelX = boundingRect().right() - nameLabelRect.width();\r\n        instanceNameLabelX = boundingRect().right() - instanceLabelRect.width();\r\n    }\r\n    else\r\n    {\r\n        nameLabelX =\r\n            boundingRect().left() + (MemoryDesignerConstants::MAPSUBITEMPOSITIONX * 2) - nameLabelRect.width();\r\n        instanceNameLabelX =\r\n            boundingRect().left() + (MemoryDesignerConstants::MAPSUBITEMPOSITIONX * 2) - instanceLabelRect.width();\r\n    }\r\n\r\n    getNameLabel()->setPos(nameLabelX, nameLabelY);\r\n    getInstanceNameLabel()->setPos(instanceNameLabelX, instanceNameLabelY);\r\n\r\n    fitLabel(getNameLabel());\r\n    fitLabel(getInstanceNameLabel());\r\n\r\n    qreal rangeEndLabelYPosition = boundingRect().bottom() - getRangeEndLabel()->boundingRect().height();\r\n    getRangeStartLabel()->setPos(boundingRect().topLeft());\r\n    getRangeEndLabel()->setPos(boundingRect().left(), rangeEndLabelYPosition);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryMapGraphicsItem::createNewSubItem()\r\n//-----------------------------------------------------------------------------\r\nMemoryDesignerChildGraphicsItem* MemoryMapGraphicsItem::createNewSubItem(\r\n    QSharedPointer<MemoryItem const> subMemoryItem, bool isEmpty)\r\n{\r\n    MemoryDesignerChildGraphicsItem* childItem = 0;\r\n\r\n    QVector<QString> remappedIdentifierChain = getIdentifierChain();\r\n    remappedIdentifierChain.append(QStringLiteral(\"Default\"));\r\n\r\n    if (!filterAddressBlocks_)\r\n    {\r\n        childItem = new AddressBlockGraphicsItem(subMemoryItem, remappedIdentifierChain, isEmpty, filterRegisters_,\r\n            filterFields_, subItemWidth_, getContainingInstance(), this);\r\n    }\r\n    else if (!filterRegisters_)\r\n    {\r\n        childItem = new RegisterGraphicsItem(subMemoryItem, isEmpty, subItemWidth_, remappedIdentifierChain,\r\n            filterFields_, getContainingInstance(), this);\r\n\r\n        QString containingBlockName =\r\n            getContainingAddressBlockName(childItem->getBaseAddress(), childItem->getLastAddress());\r\n        if (!containingBlockName.isEmpty())\r\n        {\r\n            remappedIdentifierChain.append(containingBlockName);\r\n            remappedIdentifierChain.append(subMemoryItem->getName());\r\n\r\n            childItem->setNewIdentifierChain(remappedIdentifierChain);\r\n        }\r\n    }\r\n\r\n    connect(childItem, SIGNAL(openComponentDocument(VLNV const&, QVector<QString>)),\r\n        this, SIGNAL(openComponentDocument(VLNV const&, QVector<QString>)), Qt::UniqueConnection);\r\n\r\n    return childItem;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryMapGraphicsItem::createCopyOfSubItem()\r\n//-----------------------------------------------------------------------------\r\nMemoryDesignerChildGraphicsItem* MemoryMapGraphicsItem::createCopyOfSubItem(MemoryDesignerChildGraphicsItem* subItem)\r\n{\r\n    MemoryDesignerChildGraphicsItem* childItem = 0;\r\n\r\n    if (!filterAddressBlocks_)\r\n    {\r\n        auto blockItem = dynamic_cast<AddressBlockGraphicsItem*>(subItem);\r\n        if (blockItem)\r\n        {\r\n            childItem = new AddressBlockGraphicsItem(*blockItem, this);\r\n        }\r\n    }\r\n    else if (!filterRegisters_)\r\n    {\r\n        auto registerItem = dynamic_cast<RegisterGraphicsItem*>(subItem);\r\n        if (registerItem)\r\n        {\r\n            childItem = new RegisterGraphicsItem(*registerItem, this);\r\n        }\r\n    }\r\n\r\n    connect(childItem, SIGNAL(openComponentDocument(VLNV const&, QVector<QString>)), this, SIGNAL(openComponentDocument(VLNV const&, QVector<QString>)), Qt::UniqueConnection);\r\n    return childItem;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryMapGraphicsItem::getContainingAddressBlockName()\r\n//-----------------------------------------------------------------------------\r\nQString MemoryMapGraphicsItem::getContainingAddressBlockName(quint64 registerBaseAddress,\r\n    quint64 registerLastAddress) const\r\n{\r\n    foreach (MemoryMapGraphicsItem::FilteredBlock blockItem, filteredBlocks_)\r\n    {\r\n        if (registerBaseAddress >= blockItem.blockBaseAddress_ &&\r\n            registerBaseAddress <= blockItem.blockLastAddress_ &&\r\n            registerLastAddress >= blockItem.blockBaseAddress_ &&\r\n            registerLastAddress <= blockItem.blockLastAddress_)\r\n        {\r\n            return blockItem.blockName_;\r\n        }\r\n    }\r\n\r\n    return QStringLiteral(\"\");\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryMapGraphicsItem::getSubItemWidth()\r\n//-----------------------------------------------------------------------------\r\nqreal MemoryMapGraphicsItem::getSubItemWidth() const\r\n{\r\n    int subItemWidth = (boundingRect().width() - MemoryDesignerConstants::MAPSUBITEMPOSITIONX * 2) + 1;\r\n    return subItemWidth;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryMapGraphicsItem::createEmptySubItem()\r\n//-----------------------------------------------------------------------------\r\nMemoryDesignerChildGraphicsItem* MemoryMapGraphicsItem::createEmptySubItem(quint64 beginAddress, quint64 rangeEnd)\r\n{\r\n    QSharedPointer<MemoryItem> emptyItem;\r\n\r\n    QString emptyBaseAddress = QString::number(beginAddress);\r\n\r\n    if (!filterAddressBlocks_)\r\n    {\r\n        QString emptyBlockRange = QString::number(rangeEnd - beginAddress + 1);\r\n\r\n        emptyItem = QSharedPointer<MemoryItem>(\r\n            new MemoryItem(MemoryDesignerConstants::RESERVED_NAME, MemoryDesignerConstants::ADDRESSBLOCK_TYPE));\r\n        emptyItem->setAddress(emptyBaseAddress);\r\n        emptyItem->setRange(emptyBlockRange);\r\n        emptyItem->setAUB(addressUnitBits_);\r\n    }\r\n    else if (!filterRegisters_)\r\n    {\r\n        quint64 emptyRegisterRangeInt = rangeEnd - beginAddress + 1;\r\n        QString emptyRegisterRange = QString::number(emptyRegisterRangeInt);\r\n\r\n        unsigned int intAUB = addressUnitBits_.toInt();\r\n        quint64 registerSize = emptyRegisterRangeInt * intAUB;\r\n\r\n        emptyItem = QSharedPointer<MemoryItem>(\r\n            new MemoryItem(MemoryDesignerConstants::RESERVED_NAME, MemoryDesignerConstants::REGISTER_TYPE));\r\n        emptyItem->setAddress(emptyBaseAddress);\r\n        emptyItem->setSize(QString::number(registerSize));\r\n        emptyItem->setAUB(addressUnitBits_);\r\n    }\r\n\r\n    return createNewSubItem(emptyItem, true);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryMapGraphicsItem::getMinimumHeightForSubItems()\r\n//-----------------------------------------------------------------------------\r\nqreal MemoryMapGraphicsItem::getMinimumHeightForSubItems() const\r\n{\r\n    qreal blockHeight = MemoryMapItemConstants::MINIMUMSUBITEMHEIGHT;\r\n    if (getSubMemoryItems().size() == 1)\r\n    {\r\n        MemoryDesignerChildGraphicsItem* blockItem = getSubMemoryItems().first();\r\n        SubMemoryLayout const* blockLayout = dynamic_cast<SubMemoryLayout*>(blockItem);\r\n        if (blockLayout && blockLayout->getSubMemoryItems().size() == 1)\r\n        {\r\n            blockHeight = blockHeight * 1.5;\r\n        }\r\n    }\r\n\r\n    return blockHeight;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryMapGraphicsItem::changeWidth()\r\n//-----------------------------------------------------------------------------\r\nvoid MemoryMapGraphicsItem::changeWidth(qreal widthChange)\r\n{\r\n    qreal newWidth = boundingRect().width() + widthChange - 1;\r\n    setRect(-newWidth / 2, 0, newWidth, boundingRect().height() - 1);\r\n    setLabelPositions();\r\n\r\n    qreal xPosition = pos().x() + widthChange / 2;\r\n    setX(xPosition);\r\n\r\n    if (getExtensionItem())\r\n    {\r\n        getExtensionItem()->setRect(\r\n            -newWidth / 2, boundingRect().bottom() - 1, newWidth, getExtensionItem()->boundingRect().height() - 1);\r\n    }\r\n\r\n    if (!subItemsAreFiltered() && !getSubMemoryItems().isEmpty())\r\n    {\r\n        QMultiMapIterator<quint64, MemoryDesignerChildGraphicsItem*> subItemIterator(getSubMemoryItems());\r\n        while (subItemIterator.hasNext())\r\n        {\r\n            subItemIterator.next();\r\n            MemoryDesignerChildGraphicsItem* subItem = subItemIterator.value();\r\n\r\n            subItem->setX(subItem->pos().x() - widthChange / 2);\r\n\r\n            if (!filterAddressBlocks_)\r\n            {\r\n                AddressBlockGraphicsItem* blockItem = dynamic_cast<AddressBlockGraphicsItem*>(subItem);\r\n                if (blockItem)\r\n                {\r\n                    blockItem->changeWidth(widthChange);\r\n                }\r\n            }\r\n            else if (!filterRegisters_)\r\n            {\r\n                RegisterGraphicsItem* registerItem = dynamic_cast<RegisterGraphicsItem*>(subItem);\r\n                if (registerItem)\r\n                {\r\n                    registerItem->changeWidth(widthChange);\r\n                }\r\n            }\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryMapGraphicsItem::getMaximumNeededChangeInFieldWidth()\r\n//-----------------------------------------------------------------------------\r\nqreal MemoryMapGraphicsItem::getMaximumNeededChangeInFieldWidth() const\r\n{\r\n    qreal maximumNeededWithChange = 0;\r\n    if (!filterFields_)\r\n    {\r\n        foreach (MemoryDesignerChildGraphicsItem* subItem, getSubMemoryItems())\r\n        {\r\n            if (!filterAddressBlocks_)\r\n            {\r\n                AddressBlockGraphicsItem* blockItem = dynamic_cast<AddressBlockGraphicsItem*>(subItem);\r\n                if (blockItem)\r\n                {\r\n                    maximumNeededWithChange =\r\n                        qMax(maximumNeededWithChange, blockItem->getMaximumNeededChangeInFieldWidth());\r\n                }\r\n            }\r\n            else\r\n            {\r\n                RegisterGraphicsItem* registerItem = dynamic_cast<RegisterGraphicsItem*>(subItem);\r\n                if (registerItem)\r\n                {\r\n                    maximumNeededWithChange =\r\n                        qMax(maximumNeededWithChange, registerItem->getMaximumNeededChangeInFieldWidth());\r\n                }\r\n            }\r\n        }\r\n    }\r\n\r\n    return maximumNeededWithChange;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MemoryMapGraphicsItem::createFieldOverlapItems()\r\n//-----------------------------------------------------------------------------\r\nvoid MemoryMapGraphicsItem::createFieldOverlapItems()\r\n{\r\n    if (!subItemsAreFiltered())\r\n    {\r\n        QMultiMapIterator<quint64, MemoryDesignerChildGraphicsItem*> subItemIterator(getSubMemoryItems());\r\n        while (subItemIterator.hasNext())\r\n        {\r\n            subItemIterator.next();\r\n            MemoryDesignerChildGraphicsItem* subItem = subItemIterator.value();\r\n            AddressBlockGraphicsItem* blockItem = dynamic_cast<AddressBlockGraphicsItem*>(subItem);\r\n            if (blockItem)\r\n            {\r\n                blockItem->createFieldOverlapItems();\r\n            }\r\n            else\r\n            {\r\n                RegisterGraphicsItem* registerItem = dynamic_cast<RegisterGraphicsItem*>(subItem);\r\n                if (registerItem)\r\n                {\r\n                    registerItem->createOverlappingFieldMarkers();\r\n                }\r\n            }\r\n        }\r\n    }\r\n}\r\n"
  },
  {
    "path": "editors/MemoryDesigner/MemoryMapGraphicsItem.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: MemoryMapGraphicsItem.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Mikko Teuho\r\n// Date: 09.08.2016\r\n//\r\n// Description:\r\n// Graphics item for visualizing a memory map in the memory designer.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef MEMORYMAPGRAPHICSITEM_H\r\n#define MEMORYMAPGRAPHICSITEM_H\r\n\r\n#include <common/graphicsItems/GraphicsItemTypes.h>\r\n\r\n#include <editors/MemoryDesigner/MainMemoryGraphicsItem.h>\r\n\r\nclass MemoryItem;\r\nclass ConnectivityComponent;\r\nclass AddressBlockGraphicsItem;\r\n\r\n#include <QSharedPointer>\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Graphics item for visualizing a memory map in the memory designer.\r\n//-----------------------------------------------------------------------------\r\nclass MemoryMapGraphicsItem : public MainMemoryGraphicsItem\r\n{\r\n\r\npublic:\r\n\r\n    //! Type of the memory map graphics item.\r\n    enum { Type = GFX_TYPE_MEMORY_ITEM };\r\n\r\n    /*!\r\n     *  The constructor.\r\n     *\r\n     *    @param [in] memoryItem              Memory item containing memory map data.\r\n     *    @param [in] identifierChain         List of string identifying the memory item.\r\n     *    @param [in] filterAddressBlocks     Value for filtering memory map address blocks.\r\n     *    @param [in] filterRegisters         Value for filtering address block registers.\r\n     *    @param [in] filterFields            Value for filtering register fields.\r\n     *    @param [in] containingInstance      Instance containing the memory map.\r\n     *    @param [in] parent                  The parent item.\r\n     */\r\n    MemoryMapGraphicsItem(QSharedPointer<MemoryItem> memoryItem, QVector<QString> identifierChain,\r\n        bool filterAddressBlocks, bool filterRegisters, bool filterFields,\r\n        QSharedPointer<ConnectivityComponent const> containingInstance, QGraphicsItem* parent = 0);\r\n\r\n    /*!\r\n     *  The copy constructor.\r\n     *\r\n     *    @param [in] other     The original memory map item.\r\n     *\r\n     *    @return Copy of the original memory map item.\r\n     */\r\n    MemoryMapGraphicsItem(MemoryMapGraphicsItem const& other);\r\n\r\n\t/*!\r\n     *  The destructor.\r\n     */\r\n    ~MemoryMapGraphicsItem();\r\n\r\n    /*!\r\n     *  Get the type of the memory item.\r\n     */\r\n    int type() const { return Type; }\r\n\r\n    /*!\r\n     *  Change the width of this item and the contained register graphics items.\r\n     *\r\n     *    @param [in] widthChange     The change in width.\r\n     */\r\n    void changeWidth(qreal widthChange);\r\n\r\n    /*!\r\n     *  Get the maximum needed change in width to fully display the name labels of all the field items within the\r\n     *  address block items.\r\n     *\r\n     *    @return The maximum needed change in width to display the name labels of all the field items.\r\n     */\r\n    qreal getMaximumNeededChangeInFieldWidth() const;\r\n\r\n    /*!\r\n     *  Create field overlap items for register fields.\r\n     */\r\n    void createFieldOverlapItems();\r\n\r\nprivate:\r\n    // Disable copying.\r\n    MemoryMapGraphicsItem& operator=(MemoryMapGraphicsItem const& rhs);\r\n\r\n    /*!\r\n     *  Setup the memory item.\r\n     *\r\n     *    @param [in] baseAddress   Base address of the memory item.\r\n     *    @param [in] lastAddress   Last address of the memory item.\r\n     */\r\n    void setupMemoryMapItem(quint64 const& baseAddress, quint64 const& lastAddress);\r\n\r\n    /*!\r\n     *  Create a copy of the selected sub item.\r\n     *\r\n     *    @param [in] subItem   The selected sub item.\r\n     *\r\n     *    @return Copy of the selected sub item.\r\n     */\r\n    virtual MemoryDesignerChildGraphicsItem* createCopyOfSubItem(MemoryDesignerChildGraphicsItem* subItem) override final;\r\n\r\n    /*!\r\n     *  Set the label positions.\r\n     */\r\n    virtual void setLabelPositions();\r\n\r\n    /*!\r\n     *  Create a new address block graphics item.\r\n     *\r\n     *    @param [in] subMemoryItem   Memory item containing address block data.\r\n     *    @param [in] isEmpty         Boolean value for an empty address block.\r\n     *\r\n     *    @return The created address block graphics item.\r\n     */\r\n    virtual MemoryDesignerChildGraphicsItem* createNewSubItem(QSharedPointer<MemoryItem const> subMemoryItem,\r\n        bool isEmpty) override;\r\n\r\n    /*!\r\n     *  Get the name of the address block containing the selected register.\r\n     *\r\n     *    @param [in] registerBaseAddress     Base address of the selected register.\r\n     *    @param [in] registerLastAddress     Last address of the selected register.\r\n     *\r\n     *    @return The name of the address block containing the selected register.\r\n     */\r\n    QString getContainingAddressBlockName(quint64 registerBaseAddress, quint64 registerLastAddress) const;\r\n\r\n    /*!\r\n     *  Create an empty address block graphics item.\r\n     *\r\n     *    @param [in] beginAddress    Base address of the empty address block graphics item.\r\n     *    @param [in] rangeEnd        End address of the empty address block graphics item.\r\n     *\r\n     *    @return The created address block graphics item.\r\n     */\r\n    virtual MemoryDesignerChildGraphicsItem* createEmptySubItem(quint64 beginAddress, quint64 rangeEnd);\r\n\r\n    /*!\r\n     *  Get the minimum height for the memory map sub items.\r\n     *\r\n     *    @return The minimum height for the memory map sub items.\r\n     */\r\n    virtual qreal getMinimumHeightForSubItems() const override final;\r\n\r\n    /*!\r\n     *  Setup sub items for the memory map.\r\n     *\r\n     *    @param [in] blockXPosition  X coordinate of the memory sub items.\r\n     *    @param [in] memoryItem      The memory map memory item.\r\n     */\r\n    void setupSubItems(qreal blockXPosition, QSharedPointer<MemoryItem> memoryItem);\r\n\r\n    /*!\r\n     *  Get the width of the memory map sub items.\r\n     *\r\n     *    @return Width of the memory map sub items.\r\n     */\r\n    qreal getSubItemWidth() const;\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! Information of the filtered address blocks.\r\n    struct FilteredBlock\r\n    {\r\n        //! Name of the filtered address blocks.\r\n        QString blockName_;\r\n\r\n        //! Base address of the filtered address block.\r\n        quint64 blockBaseAddress_;\r\n\r\n        //! Last address of the filtered address block.\r\n        quint64 blockLastAddress_;\r\n    };\r\n\r\n    //! The address unit bits of a memory map.\r\n    QString addressUnitBits_;\r\n\r\n    //! Value for filtering address blocks.\r\n    bool filterAddressBlocks_;\r\n\r\n    //! Value for filtering address block registers.\r\n    bool filterRegisters_;\r\n\r\n    //! Value for filtering register fields.\r\n    bool filterFields_;\r\n\r\n    //! Width of the contained memory sub items.\r\n    qreal subItemWidth_ = 0;\r\n\r\n    //! List of filtered address blocks.\r\n    QVector<MemoryMapGraphicsItem::FilteredBlock> filteredBlocks_;\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n\r\n#endif // MEMORYMAPGRAPHICSITEM_H\r\n"
  },
  {
    "path": "editors/MemoryDesigner/RegisterGraphicsItem.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: RegisterGraphicsItem.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Mikko Teuho\r\n// Date: 19.09.2016\r\n//\r\n// Description:\r\n// Graphics item for visualizing register in the memory designer.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"RegisterGraphicsItem.h\"\r\n\r\n#include <common/KactusColors.h>\r\n\r\n#include <editors/MemoryDesigner/MemoryItem.h>\r\n#include <editors/MemoryDesigner/MemoryDesignerConstants.h>\r\n#include <editors/MemoryDesigner/FieldGraphicsItem.h>\r\n\r\n#include <QBrush>\r\n#include <QFont>\r\n#include <QPen>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: RegisterGraphicsItem::RegisterGraphicsItem()\r\n//-----------------------------------------------------------------------------\r\nRegisterGraphicsItem::RegisterGraphicsItem(QSharedPointer<MemoryItem const> registerItem, bool isEmptyRegister,\r\n    qreal registerWidth, QVector<QString> identifierChain, bool filterFields,\r\n    QSharedPointer<ConnectivityComponent const> containingInstance, MemoryDesignerGraphicsItem* parentItem):\r\nMemoryDesignerChildGraphicsItem(registerItem, QStringLiteral(\"Register\"), registerItem->getAddress().toULongLong(),\r\n    getRegisterEnd(registerItem->getAUB().toUInt(), registerItem->getSize().toULongLong()), registerWidth,\r\n    identifierChain, containingInstance, parentItem),\r\nisEmpty_(isEmptyRegister),\r\nregisterSize_(registerItem->getSize().toULongLong()),\r\naddressUnitBits_(registerItem->getAUB().toUInt()),\r\nfilterFields_(filterFields)\r\n{\r\n    setColors(KactusColors::REGISTER_COLOR, isEmptyRegister);\r\n    setLabelPositions();\r\n\r\n    if (!isEmptyRegister && !filterFields)\r\n    {\r\n        setupFields(registerItem);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: RegisterGraphicsItem::RegisterGraphicsItem()\r\n//-----------------------------------------------------------------------------\r\nRegisterGraphicsItem::RegisterGraphicsItem(RegisterGraphicsItem const& other, MemoryDesignerGraphicsItem* parentItem):\r\nMemoryDesignerChildGraphicsItem(other, parentItem),\r\nisEmpty_(other.isEmpty_),\r\nregisterSize_(other.registerSize_),\r\naddressUnitBits_(other.addressUnitBits_),\r\nfilterFields_(other.filterFields_)\r\n{\r\n    setColors(KactusColors::REGISTER_COLOR, isEmpty_);\r\n    setLabelPositions();\r\n\r\n    if (!isEmpty_ && !filterFields_)\r\n    {\r\n        cloneFields(other);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: RegisterGraphicsItem::getRegisterEnd()\r\n//-----------------------------------------------------------------------------\r\nquint64 RegisterGraphicsItem::getRegisterEnd(unsigned int addressUnitBits, quint64 registerSize) const\r\n{\r\n    quint64 registerEnd = qMax(registerSize / addressUnitBits , qulonglong(1));\r\n    return registerEnd;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: RegisterGraphicsItem::setLabelPositions()\r\n//-----------------------------------------------------------------------------\r\nvoid RegisterGraphicsItem::setLabelPositions()\r\n{\r\n    qreal nameX = 0;\r\n    QRectF registerRectangle = boundingRect();\r\n    QRectF nameRectangle = getNameLabel()->boundingRect();\r\n\r\n    if (filterFields_)\r\n    {\r\n        nameX = registerRectangle.right() - nameRectangle.width();\r\n    }\r\n    else\r\n    {\r\n        nameX = registerRectangle.left() + MemoryDesignerConstants::MAPSUBITEMPOSITIONX * 2 - nameRectangle.width();\r\n    }\r\n\r\n    qreal nameY = (registerRectangle.height() / 2) - (nameRectangle.height() / 2);\r\n\r\n    getNameLabel()->setPos(nameX, nameY);\r\n\r\n    qreal rangeStartX = registerRectangle.left();\r\n    qreal rangeStartY = registerRectangle.top();\r\n    qreal rangeEndY = registerRectangle.bottom() - getRangeEndLabel()->boundingRect().height();\r\n\r\n    if (!getRangeStartLabel()->isVisible())\r\n    {\r\n        rangeEndY += 2;\r\n    }\r\n\r\n    getRangeStartLabel()->setPos(rangeStartX, rangeStartY);\r\n    getRangeEndLabel()->setPos(rangeStartX, rangeEndY);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: RegisterGraphicsItem::condense()\r\n//-----------------------------------------------------------------------------\r\nvoid RegisterGraphicsItem::condense(qreal newItemHeight)\r\n{\r\n    for (FieldGraphicsItem* fieldItem : fieldItems_)\r\n    {\r\n        fieldItem->condense(newItemHeight);\r\n    }\r\n\r\n    MemoryDesignerGraphicsItem::condense(newItemHeight);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: RegisterGraphicsItem::setupFields()\r\n//-----------------------------------------------------------------------------\r\nvoid RegisterGraphicsItem::setupFields(QSharedPointer<MemoryItem const> registerItem)\r\n{\r\n    quint64 registerEnd = getRegisterEnd(addressUnitBits_, registerSize_);\r\n    QString registerName = getNameLabel()->toPlainText();\r\n\r\n    quint64 firstUnusedBit = registerSize_;\r\n    qreal registerWidth = boundingRect().width();\r\n    qreal subItemPosition = MemoryDesignerConstants::MAPSUBITEMPOSITIONX * 2;\r\n    qreal oneBitWidth = (registerWidth - subItemPosition) / registerSize_;\r\n    qreal fieldsStartPosition = boundingRect().left() + subItemPosition;\r\n\r\n    QFont fieldFont = getNameLabel()->font();\r\n    if (registerEnd == 1)\r\n    {\r\n        fieldFont.setPointSizeF(fieldFont.pointSizeF() - 1.6);\r\n    }\r\n    else\r\n    {\r\n        fieldFont.setPointSizeF(fieldFont.pointSizeF() - 1);\r\n    }\r\n\r\n    QMultiMap<quint64, RegisterGraphicsItem::FieldMemoryItem> subItems = getFieldItemsInLastBitOrder(registerItem);\r\n    QMultiMapIterator<quint64, RegisterGraphicsItem::FieldMemoryItem> subItemIterator(subItems);\r\n    subItemIterator.toBack();\r\n    while (subItemIterator.hasPrevious())\r\n    {\r\n        subItemIterator.previous();\r\n\r\n        RegisterGraphicsItem::FieldMemoryItem fieldMemory = subItemIterator.value();\r\n        QSharedPointer<MemoryItem const> fieldItem = fieldMemory.fieldMemoryItem;\r\n        quint64 fieldOffset = fieldMemory.fieldOffset;\r\n        quint64 fieldWidth = fieldMemory.fieldWidth;\r\n        quint64 lastBit = subItemIterator.key();\r\n\r\n        if (firstUnusedBit > 0 && lastBit < firstUnusedBit - 1)\r\n        {\r\n            createEmptyFieldItem(lastBit + 1, firstUnusedBit - 1, oneBitWidth, registerEnd,\r\n                fieldsStartPosition, fieldFont);\r\n        }\r\n\r\n        createFieldGraphicsItem(fieldItem, fieldOffset, fieldWidth, false, oneBitWidth, registerEnd,\r\n            fieldsStartPosition, fieldFont);\r\n\r\n        if (fieldOffset < firstUnusedBit)\r\n        {\r\n            firstUnusedBit = fieldOffset;\r\n        }\r\n    }\r\n\r\n    if (firstUnusedBit > 0)\r\n    {\r\n        createEmptyFieldItem(0, firstUnusedBit - 1, oneBitWidth, registerEnd, fieldsStartPosition, fieldFont);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: RegisterGraphicsItem::getFieldItemsInLastBitOrder()\r\n//-----------------------------------------------------------------------------\r\nQMultiMap<quint64, RegisterGraphicsItem::FieldMemoryItem> RegisterGraphicsItem::getFieldItemsInLastBitOrder(\r\n    QSharedPointer<MemoryItem const> registerItem) const\r\n{\r\n    QMultiMap<quint64, RegisterGraphicsItem::FieldMemoryItem> fieldMap;\r\n\r\n//     quint64 registerOffset = registerItem->getAddress().toULongLong();\r\n\r\n    for (QSharedPointer<MemoryItem const> fieldItem : registerItem->getChildItems())\r\n    {\r\n        if (fieldItem->getType().compare(MemoryDesignerConstants::FIELD_TYPE, Qt::CaseInsensitive) == 0)\r\n        {\r\n            quint64 fieldOffset = fieldItem->getOffset().toULongLong();\r\n\r\n            quint64 fieldWidth = fieldItem->getWidth().toULongLong();\r\n            if (fieldWidth > 0)\r\n            {\r\n                quint64 lastBit = fieldOffset + fieldWidth - 1;\r\n\r\n                FieldMemoryItem newFieldMemoryItem;\r\n                newFieldMemoryItem.fieldOffset = fieldOffset;\r\n                newFieldMemoryItem.fieldWidth = fieldWidth;\r\n                newFieldMemoryItem.fieldMemoryItem = fieldItem;\r\n\r\n                fieldMap.insert(lastBit, newFieldMemoryItem);\r\n            }\r\n        }\r\n    }\r\n\r\n    return fieldMap;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: RegisterGraphicsItem::createEmptyFieldItem()\r\n//-----------------------------------------------------------------------------\r\nvoid RegisterGraphicsItem::createEmptyFieldItem(quint64 currentOffset, quint64 lastBit, qreal oneBitWidth,\r\n    quint64 registerEnd, qreal fieldsStartPosition, QFont fieldFont)\r\n{\r\n    quint64 fieldWidth = lastBit - currentOffset + 1;\r\n\r\n    QSharedPointer<MemoryItem const> newEmptyFieldItem\r\n        (new MemoryItem(MemoryDesignerConstants::RESERVED_NAME, MemoryDesignerConstants::FIELD_TYPE));\r\n\r\n    createFieldGraphicsItem(newEmptyFieldItem, currentOffset, fieldWidth, true, oneBitWidth, registerEnd,\r\n        fieldsStartPosition, fieldFont);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: RegisterGraphicsItem::createFieldGraphicsItem()\r\n//-----------------------------------------------------------------------------\r\nvoid RegisterGraphicsItem::createFieldGraphicsItem(QSharedPointer<MemoryItem const> fieldItem, quint64 fieldOffset,\r\n    quint64 fieldWidth, bool isEmptyField, qreal oneBitWidth, quint64 registerEnd, qreal fieldsStartPosition,\r\n    QFont fieldFont)\r\n{\r\n    quint64 fieldLastBit = fieldOffset + fieldWidth - 1;\r\n\r\n    quint64 modifiedFieldWidth = getModifiedFieldWidth(fieldLastBit, fieldOffset);\r\n    bool fieldIsOutsideRegister = modifiedFieldWidth < fieldWidth;\r\n\r\n    qreal fieldItemWidth = modifiedFieldWidth * oneBitWidth;\r\n\r\n    FieldGraphicsItem* newField =\r\n        new FieldGraphicsItem(fieldItem, fieldOffset, fieldLastBit, fieldItemWidth, registerEnd, isEmptyField,\r\n        getIdentifierChain(), fieldFont, getContainingInstance(), fieldIsOutsideRegister, this);\r\n\r\n    connect(newField, SIGNAL(openComponentDocument(VLNV const&, QVector<QString>)),\r\n        this, SIGNAL(openComponentDocument(VLNV const&, QVector<QString>)), Qt::UniqueConnection);\r\n\r\n    fieldItems_.append(newField);\r\n\r\n    qreal fieldItemPositionX = fieldsStartPosition + fieldItemWidth / 2;\r\n    if (fieldLastBit < registerSize_ - 1)\r\n    {\r\n        fieldItemPositionX += (((registerSize_ - fieldLastBit) - 1) * oneBitWidth);\r\n    }\r\n\r\n    newField->setPos(fieldItemPositionX, 0);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: RegisterGraphicsItem::cloneFields()\r\n//-----------------------------------------------------------------------------\r\nvoid RegisterGraphicsItem::cloneFields(RegisterGraphicsItem const& other)\r\n{\r\n    for (auto otherRegisterFieldItem : other.fieldItems_)\r\n    {\r\n        auto newCloneFieldItem(new FieldGraphicsItem(*otherRegisterFieldItem, this));\r\n        newCloneFieldItem->setPos(otherRegisterFieldItem->pos());\r\n\r\n        fieldItems_.append(newCloneFieldItem);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: RegisterGraphicsItem::getModifiedFieldWidth()\r\n//-----------------------------------------------------------------------------\r\nquint64 RegisterGraphicsItem::getModifiedFieldWidth(quint64 fieldLastBit, quint64 fieldOffset) const\r\n{\r\n    quint64 modifiedFieldWidth = fieldLastBit - fieldOffset + 1;\r\n\r\n    if (fieldLastBit >= registerSize_)\r\n    {\r\n        if (fieldOffset > registerSize_ - 2)\r\n        {\r\n            modifiedFieldWidth = 2;\r\n        }\r\n        else\r\n        {\r\n            modifiedFieldWidth = modifiedFieldWidth - (fieldLastBit - registerSize_ + 1);\r\n        }\r\n    }\r\n\r\n    return modifiedFieldWidth;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: RegisterGraphicsItem::createOverlappingFieldMarkers()\r\n//-----------------------------------------------------------------------------\r\nvoid RegisterGraphicsItem::createOverlappingFieldMarkers()\r\n{\r\n    int fieldCount = fieldItems_.size();\r\n\r\n    if (fieldCount > 1)\r\n    {\r\n        QBrush overlapBrush(KactusColors::MISSING_COMPONENT);\r\n\r\n        QGraphicsScene* containingScene = scene();\r\n\r\n        for (int fieldIndex = 0; fieldIndex < fieldCount; ++fieldIndex)\r\n        {\r\n            FieldGraphicsItem* currentField = fieldItems_.at(fieldIndex);\r\n\r\n            QRectF fieldRectangle = currentField->sceneBoundingRect();\r\n            int fieldLineWidth = currentField->pen().width();\r\n\r\n            createOverlappingMarkersForField(fieldIndex, fieldCount, currentField, fieldRectangle, fieldLineWidth,\r\n                overlapBrush, containingScene);\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: RegisterGraphicsItem::createOverlappingMarkersForField()\r\n//-----------------------------------------------------------------------------\r\nvoid RegisterGraphicsItem::createOverlappingMarkersForField(int /*fieldIndex*/, int /*fieldCount*/,\r\n    FieldGraphicsItem* /*fieldItem*/, QRectF /*fieldRectangle*/, int /*fieldLineWidth*/, QBrush /*overlapBrush*/,\r\n    QGraphicsScene* /*containingScene*/)\r\n{\r\n/*\r\n    for (int comparisonIndex = fieldIndex + 1; comparisonIndex < fieldCount; ++comparisonIndex)\r\n    {\r\n        FieldGraphicsItem* comparisonField = fieldItems_.at(comparisonIndex);\r\n\r\n        QRectF comparisonRectangle = comparisonField->sceneBoundingRect();\r\n        int comparisonLineWidth = comparisonField->pen().width();\r\n\r\n        if (fieldOverlapsAnotherField(fieldRectangle, fieldLineWidth, comparisonRectangle, comparisonLineWidth))\r\n        {\r\n            fieldItem->setBrush(overlapBrush);\r\n            comparisonField->setBrush(overlapBrush);\r\n\r\n            fieldItem->addOverlappingFieldItem(comparisonField, overlapBrush, containingScene);\r\n            comparisonField->addOverlappingFieldItem(fieldItem, overlapBrush, containingScene);\r\n        }\r\n        else\r\n        {\r\n            return;\r\n        }\r\n    }\r\n*/\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: RegisterGraphicsItem::fieldOverlapsAnotherField()\r\n//-----------------------------------------------------------------------------\r\nbool RegisterGraphicsItem::fieldOverlapsAnotherField(QRectF firstItemRectangle, int firstItemLineWidth,\r\n    QRectF secondItemRectangle, int secondItemLineWidth) const\r\n{\r\n    qreal firstItemLeft = firstItemRectangle.left() + firstItemLineWidth;\r\n    qreal firstItemRight = firstItemRectangle.right() - firstItemLineWidth;\r\n\r\n    qreal secondItemLeft = secondItemRectangle.left() + secondItemLineWidth;\r\n    qreal secondItemRight = secondItemRectangle.right() - secondItemLineWidth;\r\n\r\n    return secondItemLeft <= firstItemRight && secondItemRight >= firstItemLeft;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: RegisterGraphicsItem::changeWidth()\r\n//-----------------------------------------------------------------------------\r\nvoid RegisterGraphicsItem::changeWidth(qreal widthChange)\r\n{\r\n    if (!isEmpty_)\r\n    {\r\n        qreal changePerBit = widthChange / registerSize_;\r\n        qreal overallWidthChange = 0;\r\n        qreal overallOverlapModifier = 0;\r\n\r\n        quint64 previousOffset = registerSize_;\r\n        quint64 previousLastBit = registerSize_;\r\n\r\n        qreal subItemPosition = MemoryDesignerConstants::MAPSUBITEMPOSITIONX * 2;\r\n        qreal fieldsStartPosition = boundingRect().left() + subItemPosition;\r\n\r\n        for (FieldGraphicsItem* fieldItem : fieldItems_)\r\n        {\r\n            quint64 fieldOffset = fieldItem->getBaseAddress();\r\n            quint64 fieldLastBit = fieldItem->getLastAddress();\r\n\r\n            quint64 fieldItemWidth = getModifiedFieldWidth(fieldLastBit, fieldOffset);\r\n            qreal fieldItemWidthChange = fieldItemWidth * changePerBit;\r\n\r\n            fieldItem->changeWidth(fieldItemWidthChange);\r\n\r\n            qreal overlapModifier = getOverlappingFieldPositionModifier(\r\n                previousOffset, previousLastBit, fieldOffset, fieldLastBit, changePerBit);\r\n\r\n            qreal newFieldPositionX = getNewFieldPositionX(fieldItem, fieldLastBit, fieldItemWidthChange,\r\n                overallWidthChange, overallOverlapModifier, overlapModifier, fieldsStartPosition);\r\n\r\n            fieldItem->setX(newFieldPositionX);\r\n\r\n            if (fieldOffset < previousOffset)\r\n            {\r\n                previousOffset = fieldOffset;\r\n                previousLastBit = fieldLastBit;\r\n                overallWidthChange += fieldItemWidthChange;\r\n                overallOverlapModifier += overlapModifier;\r\n            }\r\n        }\r\n\r\n        for (FieldGraphicsItem* fieldItem : fieldItems_)\r\n        {\r\n            fieldItem->resizeAndRepositionOverlappingItems();\r\n        }\r\n    }\r\n    else\r\n    {\r\n        qreal newWidth = boundingRect().width() + widthChange - 1;\r\n        qreal xMovement = widthChange / 2;\r\n        setPos(pos().x() + xMovement, pos().y());\r\n        setRect(-newWidth / 2, 0, newWidth, boundingRect().height() - 1);\r\n        setLabelPositions();\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: RegisterGraphicsItem::getOverlappingFieldPositionModifier()\r\n//-----------------------------------------------------------------------------\r\nqreal RegisterGraphicsItem::getOverlappingFieldPositionModifier(quint64 firstOffset, quint64 firstLastBit,\r\n    quint64 secondOffset, quint64 secondLastbit, qreal changePerBit) const\r\n{\r\n    qreal overlapModifier = 0;\r\n\r\n    if (secondLastbit < registerSize_ && secondLastbit >= firstOffset)\r\n    {\r\n        quint64 bitDifference = secondLastbit - firstOffset + 1;\r\n\r\n        overlapModifier = bitDifference * changePerBit;\r\n    }\r\n    else if (firstLastBit > registerSize_ && secondLastbit >= registerSize_)\r\n    {\r\n        if (firstOffset >= registerSize_ - 2 || secondOffset >= registerSize_ - 2)\r\n        {\r\n            overlapModifier = 2 * changePerBit;\r\n        }\r\n        else\r\n        {\r\n            quint64 offsetMax = qMax(firstOffset, secondOffset);\r\n\r\n            quint64 bitDifference = registerSize_ - offsetMax + 1;\r\n            overlapModifier = bitDifference * changePerBit;\r\n        }\r\n    }\r\n\r\n    return overlapModifier;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: RegisterGraphicsItem::getNewFieldPositionX()\r\n//-----------------------------------------------------------------------------\r\nqreal RegisterGraphicsItem::getNewFieldPositionX(FieldGraphicsItem* fieldItem, quint64 fieldLastBit,\r\n    qreal fieldItemWidthChange, qreal overallWidthChange, qreal overallOverlapModifier,\r\n    qreal currentOverlapModifier, qreal fieldsStartPosition) const\r\n{\r\n    qreal newFieldPositionX = 0;\r\n\r\n    if (fieldLastBit >= registerSize_)\r\n    {\r\n        qreal fieldWidth = fieldItem->boundingRect().width();\r\n        newFieldPositionX = fieldsStartPosition + fieldWidth / 2;\r\n    }\r\n    else\r\n    {\r\n        newFieldPositionX = fieldItem->pos().x() + fieldItemWidthChange / 2 + overallWidthChange -\r\n            (overallOverlapModifier + currentOverlapModifier);\r\n    }\r\n\r\n    return newFieldPositionX;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: RegisterGraphicsItem::getMaximumNeededChangeInFieldWidth()\r\n//-----------------------------------------------------------------------------\r\nqreal RegisterGraphicsItem::getMaximumNeededChangeInFieldWidth() const\r\n{\r\n    qreal maximumWidthChange = 0;\r\n\r\n    foreach (FieldGraphicsItem* fieldItem, fieldItems_)\r\n    {\r\n        maximumWidthChange = qMax(maximumWidthChange, fieldItem->getNeededWithChangeToDisplayFullName());\r\n    }\r\n\r\n    maximumWidthChange = registerSize_ * maximumWidthChange;\r\n\r\n    return maximumWidthChange;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: RegisterGraphicsItem::getItemWidth()\r\n//-----------------------------------------------------------------------------\r\nqreal RegisterGraphicsItem::getItemWidth() const\r\n{\r\n    qreal itemWidth = boundingRect().width();\r\n    if (!fieldItems_.isEmpty())\r\n    {\r\n        itemWidth = MemoryDesignerConstants::MAPSUBITEMPOSITIONX * 2;\r\n    }\r\n\r\n    return itemWidth;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: RegisterGraphicsItem::setNewIdentifierChain()\r\n//-----------------------------------------------------------------------------\r\nvoid RegisterGraphicsItem::setNewIdentifierChain(QVector<QString> newIdentifiers)\r\n{\r\n    MemoryDesignerGraphicsItem::setNewIdentifierChain(newIdentifiers);\r\n\r\n    for (FieldGraphicsItem* fieldItem : fieldItems_)\r\n    {\r\n        QVector<QString> newFieldIdentifierChain = newIdentifiers;\r\n        newFieldIdentifierChain.append(fieldItem->name());\r\n\r\n        fieldItem->setNewIdentifierChain(newFieldIdentifierChain);\r\n    }\r\n}\r\n"
  },
  {
    "path": "editors/MemoryDesigner/RegisterGraphicsItem.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: RegisterGraphicsItem.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Mikko Teuho\r\n// Date: 19.09.2016\r\n//\r\n// Description:\r\n// Graphics item for visualizing register in the memory designer.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef REGISTERGRAPHICSITEM_H\r\n#define REGISTERGRAPHICSITEM_H\r\n\r\n#include <editors/MemoryDesigner/MemoryDesignerChildGraphicsItem.h>\r\n\r\n#include <common/graphicsItems/GraphicsItemTypes.h>\r\n\r\nclass MemoryItem;\r\nclass MemoryDesignerGraphicsItem;\r\nclass FieldGraphicsItem;\r\n\r\n#include <QSharedPointer>\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Graphics item for visualizing register in the memory designer.\r\n//-----------------------------------------------------------------------------\r\nclass RegisterGraphicsItem : public MemoryDesignerChildGraphicsItem\r\n{\r\n\r\npublic:\r\n    //! Type of this graphics item.\r\n    enum { Type = GFX_TYPE_MEMORY_ITEM };\r\n\r\n    /*!\r\n     *  The constructor.\r\n     *\r\n     *    @param [in] registerItem        Memory item containing the register data.\r\n     *    @param [in] isEmptyRegister     Boolean value to represent empty registers.\r\n     *    @param [in] registerWidth       Width of the register graphics item.\r\n     *    @param [in] identifierChain     List of string identifying the memory item.\r\n     *    @param [in] filterFields        Value for filtering register fields.\r\n     *    @param [in] containingInstance  Name of the containing component instance.\r\n     *    @param [in] parentItem          The parent memory graphics item.\r\n     */\r\n    RegisterGraphicsItem(QSharedPointer<MemoryItem const> registerItem, bool isEmptyRegister, qreal registerWidth,\r\n        QVector<QString> identifierChain, bool filterFields,\r\n        QSharedPointer<ConnectivityComponent const> containingInstance, MemoryDesignerGraphicsItem* parentItem);\r\n\r\n    /*!\r\n     *  The copy constructor.\r\n     *\r\n     *    @param [in] other         The original register item.\r\n     *    @param [in] parentItem    The parent item.\r\n     *\r\n     *    @return Copy of the original register item.\r\n     */\r\n    RegisterGraphicsItem(RegisterGraphicsItem const& other, MemoryDesignerGraphicsItem* parentItem);\r\n\r\n\t/*!\r\n     *  The destructor.\r\n     */\r\n    virtual ~RegisterGraphicsItem() = default;\r\n\r\n    /*!\r\n     *  Get the graphics type.\r\n     */\r\n    int type() const { return Type; }\r\n\r\n    /*!\r\n     *  Condense this item and the contained field graphics items.\r\n     *\r\n     *    @param [in] newItemHeight   The condensed height.\r\n     */\r\n    virtual void condense(qreal newItemHeight);\r\n\r\n    /*!\r\n     *  Change the width of this item and the contained field graphics items.\r\n     *\r\n     *    @param [in] widthChange     The change in width.\r\n     */\r\n    void changeWidth(qreal widthChange);\r\n\r\n    /*!\r\n     *  Get the maximum needed change in width to fully display the name labels of all the contained field items.\r\n     *\r\n     *    @return The maximum needed change in width to display the name labels of all the field items.\r\n     */\r\n    qreal getMaximumNeededChangeInFieldWidth() const;\r\n\r\n    /*!\r\n     *  Create overlapping field graphics items.\r\n     */\r\n    void createOverlappingFieldMarkers();\r\n\r\n    /*!\r\n     *  Set a new identifier chain.\r\n     *\r\n     *    @param [in] newIdentifiers  A list of strings containing the new memory identifier chain.\r\n     */\r\n    virtual void setNewIdentifierChain(QVector<QString> newIdentifiers);\r\n\r\nprivate:\r\n    // Disable copying.\r\n    RegisterGraphicsItem& operator=(RegisterGraphicsItem const& rhs);\r\n\r\n    //! Field memory items with calculated field offset and width.\r\n    struct FieldMemoryItem\r\n    {\r\n        //! Offset of the field item.\r\n        quint64 fieldOffset;\r\n\r\n        //! Width of the field item.\r\n        quint64 fieldWidth;\r\n\r\n        //! Memory item containing the field item data.\r\n        QSharedPointer<MemoryItem const> fieldMemoryItem;\r\n    };\r\n\r\n    /*!\r\n     *  Get the register end.\r\n     *\r\n     *    @param [in] addressUnitBits     Address unit bits of the register.\r\n     *    @param [in] registerSize        Size of the register.\r\n     *\r\n     *    @return The end range of the register item.\r\n     */\r\n    quint64 getRegisterEnd(unsigned int addressUnitBits, quint64 registerSize) const;\r\n\r\n    /*!\r\n     *  Setup the label positions.\r\n     */\r\n    virtual void setLabelPositions();\r\n\r\n    /*!\r\n     *  Setup the field graphics items.\r\n     *\r\n     *    @param [in] registerItem    The selected register memory item.\r\n     */\r\n    void setupFields(QSharedPointer<MemoryItem const> registerItem);\r\n\r\n    /*!\r\n     *  Clone the field items.\r\n     *\r\n     *    @param [in] other     The original register item\r\n     */\r\n    void cloneFields(RegisterGraphicsItem const& other);\r\n\r\n    /*!\r\n     *  Get the field items in last bit order.\r\n     *\r\n     *    @param [in] registerItem    Memory item containing the register data.\r\n     *\r\n     *    @return Field items in last bit order with calculated offsets and widths.\r\n     */\r\n    QMultiMap<quint64, RegisterGraphicsItem::FieldMemoryItem> getFieldItemsInLastBitOrder(\r\n        QSharedPointer<MemoryItem const> registerItem) const;\r\n\r\n    /*!\r\n     *  Create an empty field graphics item.\r\n     *\r\n     *    @param [in] currentOffset           Offset of the field.\r\n     *    @param [in] lastBit                 Last bit used by the field.\r\n     *    @param [in] oneBitWidth             Width of a one bit.\r\n     *    @param [in] registerEnd             End of the containing register.\r\n     *    @param [in] fieldsStartPosition     The start coordinate for the field graphics items.\r\n     *    @param [in] fieldFont               Font used in fields.\r\n     */\r\n    void createEmptyFieldItem(quint64 currentOffset, quint64 lastBit, qreal oneBitWidth, quint64 registerEnd,\r\n        qreal fieldsStartPosition, QFont fieldFont);\r\n\r\n    /*!\r\n     *  Create a field graphics item.\r\n     *\r\n     *    @param [in] fieldItem               The field memory item.\r\n     *    @param [in] fieldOffset             Offset of the field.\r\n     *    @param [in] fieldWidth              Width of the field.\r\n     *    @param [in] isEmptyField            Holds whether the field is empty or not.\r\n     *    @param [in] oneBitWidth             Width of a one bit.\r\n     *    @param [in] registerEnd             End of the containing register.\r\n     *    @param [in] fieldsStartPosition     The start coordinate for the field graphics items.\r\n     *    @param [in] fieldFont               Font used in fields.\r\n     */\r\n    void createFieldGraphicsItem(QSharedPointer<MemoryItem const> fieldItem, quint64 fieldOffset, quint64 fieldWidth,\r\n        bool isEmptyField, qreal oneBitWidth, quint64 registerEnd, qreal fieldsStartPosition, QFont fieldFont);\r\n\r\n    /*!\r\n     *  Get the width available for the register item.\r\n     *\r\n     *    @return The width available for the register item.\r\n     */\r\n    virtual qreal getItemWidth() const;\r\n\r\n    /*!\r\n     *  Create overlapping markers for the selected field.\r\n     *\r\n     *    @param [in] fieldIndex          Index of the selected field.\r\n     *    @param [in] fieldCount          Number of fields contained within the register.\r\n     *    @param [in] fieldItem           The selected field item.\r\n     *    @param [in] fieldRectangle      Bounding rectangle of the field item.\r\n     *    @param [in] fieldLineWidth      Line width of the field item.\r\n     *    @param [in] overlapBrush        Brush used to draw the field item.\r\n     *    @param [in] containingScene     Scene containing field item.\r\n     */\r\n    void createOverlappingMarkersForField(int fieldIndex, int fieldCount, FieldGraphicsItem* fieldItem,\r\n        QRectF fieldRectangle, int fieldLineWidth, QBrush overlapBrush, QGraphicsScene* containingScene);\r\n\r\n    /*!\r\n     *  Check if a field overlaps another field.\r\n     *\r\n     *    @param [in] firstItemRectangle      Bounding rectangle of the first field item.\r\n     *    @param [in] firstItemLineWidth      Line width of the first field item.\r\n     *    @param [in] secondItemRectangle     Bounding rectangle of the second field item.\r\n     *    @param [in] secondItemLineWidth     Line width of the first field item.\r\n     *\r\n     *    @return True, if the field overlaps another field, false otherwise.\r\n     */\r\n    bool fieldOverlapsAnotherField(QRectF firstItemRectangle, int firstItemLineWidth, QRectF secondItemRectangle,\r\n        int secondItemLineWidth) const;\r\n\r\n    /*!\r\n     *  Get the x coordinate modifier for the overlapping field.\r\n     *\r\n     *    @param [in] firstOffset     Offset of the first field.\r\n     *    @param [in] firstLastBit    Last bit of the first field.\r\n     *    @param [in] secondOffset    Offset of the second field.\r\n     *    @param [in] secondLastbit   Last bit of the second field.\r\n     *    @param [in] changePerBit    Width change per bit.\r\n     *\r\n     *    @return The x coordinate modifier for the overlapping field.\r\n     */\r\n    qreal getOverlappingFieldPositionModifier(quint64 firstOffset, quint64 firstLastBit, quint64 secondOffset,\r\n        quint64 secondLastbit, qreal changePerBit) const;\r\n\r\n    /*!\r\n     *  Get the new x coordinate for the selected field item.\r\n     *\r\n     *    @param [in] fieldItem               The selected field item.\r\n     *    @param [in] fieldLastBit            Last bit of the selected field.\r\n     *    @param [in] fieldItemWidthChange    Width change of the selected field item.\r\n     *    @param [in] overallWidthChange      Overall width change of the contained field items.\r\n     *    @param [in] overallOverlapModifier  Overlap modifier of the selected field item.\r\n     *    @param [in] currentOverlapModifier  Overall overlap modifier of the contained field items.\r\n     *    @param [in] fieldsStartPosition     Start position of the field items.\r\n     *\r\n     *    @return The new x coordinate.\r\n     */\r\n    qreal getNewFieldPositionX(FieldGraphicsItem* fieldItem, quint64 fieldLastBit, qreal fieldItemWidthChange,\r\n        qreal overallWidthChange, qreal overallOverlapModifier, qreal currentOverlapModifier,\r\n        qreal fieldsStartPosition) const;\r\n\r\n    /*!\r\n     *  Get the field width modified to fit into the register bounds.\r\n     *\r\n     *    @param [in] fieldLastBit    Last bit of the selected field.\r\n     *    @param [in] fieldOffset     Offset of the selected field.\r\n     *\r\n     *    @return Modified width of the field item.\r\n     */\r\n    quint64 getModifiedFieldWidth(quint64 fieldLastBit, quint64 fieldOffset) const;\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! List of the field graphics items contained within.\r\n    QVector<FieldGraphicsItem*> fieldItems_;\r\n\r\n    //! Value for empty registers.\r\n    bool isEmpty_;\r\n\r\n    //! Size of the register.\r\n    quint64 registerSize_;\r\n\r\n    //! Address unit bits of the register.\r\n    unsigned int addressUnitBits_;\r\n\r\n    //! Value for filtering fields.\r\n    bool filterFields_;\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n\r\n#endif // ADDRESSBLOCKGRAPHICSITEM_H\r\n"
  },
  {
    "path": "editors/MemoryDesigner/SubMemoryLayout.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: SubMemoryLayout.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Mikko Teuho\r\n// Date: 22.09.2016\r\n//\r\n// Description:\r\n// Layout for sub memory items of a memory graphics item within memory designer.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"SubMemoryLayout.h\"\r\n\r\n#include <common/KactusColors.h>\r\n\r\n#include <editors/MemoryDesigner/MemoryItem.h>\r\n#include <editors/MemoryDesigner/MemoryDesignerChildGraphicsItem.h>\r\n#include <editors/MemoryDesigner/MemoryDesignerGraphicsItem.h>\r\n#include <editors/MemoryDesigner/MemoryDesignerConstants.h>\r\n#include <editors/MemoryDesigner/MemoryConnectionItem.h>\r\n\r\n#include <QBrush>\r\n#include <QPen>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SubMemoryLayout::SubMemoryLayout()\r\n//-----------------------------------------------------------------------------\r\nSubMemoryLayout::SubMemoryLayout(QSharedPointer<MemoryItem const> memoryItem, QString const& subItemType,\r\n    bool filterSubItems, MemoryDesignerGraphicsItem const* mainGraphicsItem):\r\nsubMemoryItems_(),\r\nitemType_(memoryItem->getType()),\r\nmainGraphicsItem_(mainGraphicsItem),\r\nsubItemType_(subItemType),\r\nfilterSubItems_(filterSubItems)\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SubMemoryLayout::SubMemoryLayout()\r\n//-----------------------------------------------------------------------------\r\nSubMemoryLayout::SubMemoryLayout(SubMemoryLayout const& other, MemoryDesignerGraphicsItem const* mainGraphicsItem):\r\nsubMemoryItems_(),\r\nitemType_(other.itemType_),\r\nmainGraphicsItem_(mainGraphicsItem),\r\nsubItemType_(other.subItemType_),\r\nfilterSubItems_(other.filterSubItems_)\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SubMemoryLayout::cloneSubItems()\r\n//-----------------------------------------------------------------------------\r\nvoid SubMemoryLayout::cloneSubItems(SubMemoryLayout const& other)\r\n{\r\n    QMultiMapIterator itemIterator(other.subMemoryItems_);\r\n    while (itemIterator.hasNext())\r\n    {\r\n        itemIterator.next();\r\n\r\n        auto clonedSubItem = createCopyOfSubItem(itemIterator.value());\r\n        if (clonedSubItem)\r\n        {\r\n            subMemoryItems_.insert(clonedSubItem->getOriginalBaseAddress(), clonedSubItem);\r\n            clonedSubItem->setPos(itemIterator.value()->pos());\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SubMemoryLayout::~SubMemoryLayout()\r\n//-----------------------------------------------------------------------------\r\nSubMemoryLayout::~SubMemoryLayout()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SubMemoryLayout::getSubItemType()\r\n//-----------------------------------------------------------------------------\r\nQString SubMemoryLayout::getSubItemType() const\r\n{\r\n    return subItemType_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SubMemoryLayout::setupSubItems()\r\n//-----------------------------------------------------------------------------\r\nvoid SubMemoryLayout::setupSubItems(qreal subItemPositionX, QString const& subItemType,\r\n    QSharedPointer<MemoryItem const> memoryItem)\r\n{\r\n    if (!filterSubItems_)\r\n    {\r\n        quint64 itemBaseAddress = mainGraphicsItem_->getBaseAddress();\r\n        quint64 itemLastAddress = mainGraphicsItem_->getLastAddress();\r\n\r\n        if (!memoryItem->getChildItems().isEmpty())\r\n        {\r\n            QMultiMap<quint64, MemoryDesignerChildGraphicsItem*> subItemsInOrder;\r\n\r\n            for (QSharedPointer<MemoryItem const> subMemoryItem : memoryItem->getChildItems())\r\n            {\r\n                if (subMemoryItem->getType().compare(subItemType, Qt::CaseInsensitive) == 0)\r\n                {\r\n                    MemoryDesignerChildGraphicsItem* newSubItem = createNewSubItem(subMemoryItem, false);\r\n                    quint64 subItemBaseAddress = newSubItem->getBaseAddress();\r\n                    quint64 subItemLastAddress = newSubItem->getLastAddress();\r\n\r\n                    if (subItemBaseAddress > itemLastAddress || subItemLastAddress > itemLastAddress)\r\n                    {\r\n                        setFaultySubItemColor(newSubItem);\r\n                    }\r\n\r\n                    positionNewSubItem(subItemPositionX, itemBaseAddress, subItemBaseAddress, newSubItem);\r\n                    subItemsInOrder.insert(subItemBaseAddress, newSubItem);\r\n                }\r\n            }\r\n\r\n            if (!subItemsInOrder.isEmpty())\r\n            {\r\n                quint64 subItemLastAddress = itemBaseAddress;\r\n\r\n                if (subItemsInOrder.firstKey() > itemBaseAddress)\r\n                {\r\n                    subItemLastAddress = subItemsInOrder.firstKey() - 1;\r\n                    createAndPositionNewEmptySubItem(\r\n                        itemBaseAddress, subItemLastAddress, subItemPositionX, itemBaseAddress);\r\n                }\r\n\r\n                QMultiMapIterator<quint64, MemoryDesignerChildGraphicsItem*> subItemIterator(subItemsInOrder);\r\n\r\n                while (subItemIterator.hasNext())\r\n                {\r\n                    subItemIterator.next();\r\n\r\n                    quint64 currentOffset = subItemIterator.key();\r\n                    if (currentOffset > subItemLastAddress + 1)\r\n                    {\r\n                        createAndPositionNewEmptySubItem(\r\n                            subItemLastAddress + 1, currentOffset - 1, subItemPositionX, itemBaseAddress);\r\n                    }\r\n\r\n                    quint64 rangeEnd = subItemIterator.value()->getLastAddress();\r\n\r\n                    subItemLastAddress = qMax(subItemLastAddress, rangeEnd);\r\n                }\r\n\r\n                if (subItemLastAddress < itemLastAddress)\r\n                {\r\n                    createAndPositionNewEmptySubItem(\r\n                        subItemLastAddress + 1, itemLastAddress, subItemPositionX, itemBaseAddress);\r\n                }\r\n            }\r\n        }\r\n\r\n        if (getSubMemoryItems().isEmpty())\r\n        {\r\n            createAndPositionNewEmptySubItem(itemBaseAddress, itemLastAddress, subItemPositionX, itemBaseAddress);\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SubMemoryLayout::createAndPositionNewEmptySubItem()\r\n//-----------------------------------------------------------------------------\r\nvoid SubMemoryLayout::createAndPositionNewEmptySubItem(quint64 subItemBaseAddress, quint64 subItemLastAddress,\r\n    qreal subItemPositionX, quint64 mainItemBaseAddress)\r\n{\r\n    MemoryDesignerChildGraphicsItem* newEmptyItem = createEmptySubItem(subItemBaseAddress, subItemLastAddress);\r\n    positionNewSubItem(subItemPositionX, mainItemBaseAddress, subItemBaseAddress, newEmptyItem);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SubMemoryLayout::positionNewSubItem()\r\n//-----------------------------------------------------------------------------\r\nvoid SubMemoryLayout::positionNewSubItem(qreal const& subItemXPosition, quint64 const& mainItemBaseAddress,\r\n    quint64 const& subItemOffset, MemoryDesignerChildGraphicsItem* newSubItem)\r\n{\r\n    quint64 segmentTransferY = (subItemOffset - mainItemBaseAddress) * MemoryDesignerConstants::RANGEINTERVAL;\r\n    newSubItem->setPos(subItemXPosition, segmentTransferY);\r\n\r\n    subMemoryItems_.insert(subItemOffset, newSubItem);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SubMemoryLayout::changeChildItemAddress()\r\n//-----------------------------------------------------------------------------\r\nvoid SubMemoryLayout::changeChildItemAddress(quint64 const& previousBaseAddress, quint64 const& newAddress)\r\n{\r\n    bool subtractFromPreviousAddress = true;\r\n    quint64 difference = 0;\r\n    if (newAddress < previousBaseAddress)\r\n    {\r\n        difference = previousBaseAddress - newAddress;\r\n    }\r\n    else\r\n    {\r\n        difference = newAddress - previousBaseAddress;\r\n        subtractFromPreviousAddress = false;\r\n    }\r\n\r\n    QMultiMap<quint64, MemoryDesignerChildGraphicsItem*> newSubItems;\r\n\r\n    QMultiMapIterator subMemoryIterator(subMemoryItems_);\r\n    while (subMemoryIterator.hasNext())\r\n    {\r\n        subMemoryIterator.next();\r\n\r\n        quint64 newItemBaseAddress = 0;\r\n        if (subtractFromPreviousAddress)\r\n        {\r\n            newItemBaseAddress = subMemoryIterator.key() - difference;\r\n        }\r\n        else\r\n        {\r\n            newItemBaseAddress = subMemoryIterator.key() + difference;\r\n        }\r\n\r\n        subMemoryIterator.value()->changeAddress(newItemBaseAddress);\r\n        newSubItems.insertMulti(newItemBaseAddress, subMemoryIterator.value());\r\n    }\r\n\r\n    subMemoryItems_ = newSubItems;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SubMemoryLayout::getSubMemoryItems()\r\n//-----------------------------------------------------------------------------\r\nQMultiMap<quint64, MemoryDesignerChildGraphicsItem*> SubMemoryLayout::getSubMemoryItems() const\r\n{\r\n    return subMemoryItems_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SubMemoryLayout::condenseChildItems()\r\n//-----------------------------------------------------------------------------\r\nqreal SubMemoryLayout::compressChildItems(quint64 itemBaseAddress, quint64 itemLastAddress,\r\n    qreal minimumSubItemHeight, bool memoryItemsAreCondensed)\r\n{\r\n    quint64 positionY = 0;\r\n\r\n    if (filterSubItems_)\r\n    {\r\n        if (memoryItemsAreCondensed)\r\n        {\r\n            positionY = minimumSubItemHeight;\r\n        }\r\n        else\r\n        {\r\n            quint64 addressRange = itemLastAddress - itemBaseAddress + 1;\r\n            positionY = MemoryDesignerConstants::getAreaSizeForRange(addressRange);\r\n        }\r\n    }\r\n    else\r\n    {\r\n        QMultiMapIterator<quint64, MemoryDesignerChildGraphicsItem*> subMemoryIterator(subMemoryItems_);\r\n        while (subMemoryIterator.hasNext())\r\n        {\r\n            subMemoryIterator.next();\r\n\r\n            MemoryDesignerChildGraphicsItem* subItem = subMemoryIterator.value();\r\n\r\n            positionY = compressSubItem(subItem, minimumSubItemHeight, positionY, memoryItemsAreCondensed);\r\n        }\r\n    }\r\n\r\n    return positionY;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SubMemoryLayout::compressSubItem()\r\n//-----------------------------------------------------------------------------\r\nquint64 SubMemoryLayout::compressSubItem(MemoryDesignerChildGraphicsItem* subItem, qreal minimumSubItemHeight,\r\n    quint64 positionY, bool memoryItemsAreCondensed)\r\n{\r\n    quint64 subBaseAddress = subItem->getBaseAddress();\r\n    quint64 subLastAddress = subItem->getLastAddress();\r\n\r\n    SubMemoryLayout* subLayout = dynamic_cast<SubMemoryLayout*>(subItem);\r\n    if (subLayout)\r\n    {\r\n        quint64 newSubItemHeight = subLayout->compressChildItems(\r\n            subBaseAddress, subLastAddress, minimumSubItemHeight, memoryItemsAreCondensed);\r\n        subItem->condense(newSubItemHeight);\r\n    }\r\n    else\r\n    {\r\n        if (subLastAddress - subBaseAddress > 1)\r\n        {\r\n            qreal newSubItemHeight = minimumSubItemHeight;\r\n\r\n            if (!memoryItemsAreCondensed)\r\n            {\r\n                quint64 addressRange = subLastAddress - subBaseAddress + 1;\r\n                newSubItemHeight = MemoryDesignerConstants::getAreaSizeForRange(addressRange);\r\n            }\r\n\r\n            subItem->condense(newSubItemHeight);\r\n        }\r\n    }\r\n\r\n    subItem->setPos(subItem->pos().x(), positionY);\r\n\r\n    return positionY + subItem->boundingRect().bottom();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SubMemoryLayout::addConnectionToSubItems()\r\n//-----------------------------------------------------------------------------\r\nvoid SubMemoryLayout::addConnectionToSubItems(MemoryConnectionItem* connectionItem)\r\n{\r\n    quint64 connectionBaseAddress = connectionItem->getRangeStartValue();\r\n    quint64 connectionLastAddress = connectionItem->getRangeEndValue();\r\n\r\n    QMultiMapIterator<quint64, MemoryDesignerChildGraphicsItem*> subItemIterator(subMemoryItems_);\r\n    while (subItemIterator.hasNext())\r\n    {\r\n        subItemIterator.next();\r\n\r\n        MemoryDesignerChildGraphicsItem* subItem = subItemIterator.value();\r\n        quint64 subItemBaseAddress = subItem->getBaseAddress();\r\n        quint64 subItemLastAddress = subItem->getLastAddress();\r\n\r\n        if (connectionLastAddress >= subItemBaseAddress && subItemLastAddress >= connectionBaseAddress)\r\n        {\r\n            subItem->addMemoryConnection(connectionItem);\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SubMemoryLayout::subItemsAreFiltered()\r\n//-----------------------------------------------------------------------------\r\nbool SubMemoryLayout::subItemsAreFiltered() const\r\n{\r\n    return filterSubItems_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SubMemoryLayout::setFilterSubItems()\r\n//-----------------------------------------------------------------------------\r\nvoid SubMemoryLayout::setFilterSubItems(bool filterValue)\r\n{\r\n    filterSubItems_ = filterValue;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SubMemoryLayout::resizeSubItemNameLabels()\r\n//-----------------------------------------------------------------------------\r\nvoid SubMemoryLayout::resizeSubItemNameLabels()\r\n{\r\n    QMultiMapIterator<quint64, MemoryDesignerChildGraphicsItem*> subItemIterator(getSubMemoryItems());\r\n    while (subItemIterator.hasNext())\r\n    {\r\n        subItemIterator.next();\r\n\r\n        MemoryDesignerChildGraphicsItem* subItem = subItemIterator.value();\r\n        subItem->fitNameLabel();\r\n\r\n        SubMemoryLayout* subItemLayout = dynamic_cast<SubMemoryLayout*>(subItem);\r\n        if (subItemLayout)\r\n        {\r\n            subItemLayout->resizeSubItemNameLabels();\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SubMemoryLayout::createOverlappingSubItemMarkings()\r\n//-----------------------------------------------------------------------------\r\nvoid SubMemoryLayout::createOverlappingSubItemMarkings()\r\n{\r\n    QMultiMapIterator<quint64, MemoryDesignerChildGraphicsItem*> subItemIterator(getSubMemoryItems());\r\n    while (subItemIterator.hasNext())\r\n    {\r\n        subItemIterator.next();\r\n\r\n        MemoryDesignerChildGraphicsItem* subItem = subItemIterator.value();\r\n\r\n        SubMemoryLayout* subItemLayout = dynamic_cast<SubMemoryLayout*>(subItem);\r\n        if (subItemLayout)\r\n        {\r\n            subItemLayout->createOverlappingSubItemMarkings();\r\n        }\r\n\r\n        quint64 subItemBaseAddress = subItem->getBaseAddress();\r\n        quint64 subItemLastAddress = subItem->getLastAddress();\r\n\r\n        QMultiMapIterator<quint64, MemoryDesignerChildGraphicsItem*> comparisonItemIterator = subItemIterator;\r\n        while (comparisonItemIterator.hasNext())\r\n        {\r\n            comparisonItemIterator.next();\r\n\r\n            MemoryDesignerChildGraphicsItem* comparisonItem = comparisonItemIterator.value();\r\n\r\n            quint64 comparisonBaseAddress = comparisonItem->getBaseAddress();\r\n            quint64 comparisonLastAddress = comparisonItem->getLastAddress();\r\n\r\n            if ((comparisonBaseAddress >= subItemBaseAddress && comparisonBaseAddress <= subItemLastAddress) ||\r\n                (comparisonLastAddress >= subItemBaseAddress && comparisonLastAddress <= subItemLastAddress) ||\r\n                (subItemBaseAddress >= comparisonBaseAddress && subItemBaseAddress <= comparisonLastAddress) ||\r\n                (subItemLastAddress >= comparisonBaseAddress && subItemLastAddress <= comparisonLastAddress))\r\n            {\r\n                setFaultySubItemColor(subItem);\r\n                setFaultySubItemColor(comparisonItem);\r\n            }\r\n\r\n            else if (comparisonBaseAddress > subItemLastAddress)\r\n            {\r\n                break;\r\n            }\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SubMemoryLayout::setFaultySubItemColor()\r\n//-----------------------------------------------------------------------------\r\nvoid SubMemoryLayout::setFaultySubItemColor(MemoryDesignerChildGraphicsItem* subItem)\r\n{\r\n    QBrush collisionBrush(KactusColors::MISSING_COMPONENT);\r\n    subItem->setBrush(collisionBrush);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SubMemoryLayout::getSubItemHeightAddition()\r\n//-----------------------------------------------------------------------------\r\nquint64 SubMemoryLayout::getSubItemHeightAddition() const\r\n{\r\n    quint64 heightAddition = 0;\r\n\r\n    if (mainGraphicsItem_ && !subItemsAreFiltered())\r\n    {\r\n        quint64 mainItemLastAddress = mainGraphicsItem_->getLastAddress();\r\n        quint64 mainItemLow = mainGraphicsItem_->sceneBoundingRect().bottom();\r\n\r\n        QMultiMapIterator<quint64, MemoryDesignerChildGraphicsItem*> subItemIterator(getSubMemoryItems());\r\n        while (subItemIterator.hasNext())\r\n        {\r\n            subItemIterator.next();\r\n\r\n            MemoryDesignerChildGraphicsItem* subItem = subItemIterator.value();\r\n            quint64 subItemLastAddress = subItem->getLastAddress();\r\n            SubMemoryLayout* subLayout = dynamic_cast<SubMemoryLayout*>(subItem);\r\n            if (subLayout && !subLayout->subItemsAreFiltered())\r\n            {\r\n                heightAddition = subLayout->getSubItemHeightAddition();\r\n            }\r\n            else if (subItemLastAddress > mainItemLastAddress)\r\n            {\r\n                quint64 subItemLow = subItem->sceneBoundingRect().bottom();\r\n                quint64 subItemAddition = subItemLow - mainItemLow;\r\n                if (subItemAddition > heightAddition)\r\n                {\r\n                    heightAddition = subItemAddition;\r\n                }\r\n            }\r\n        }\r\n    }\r\n\r\n    return heightAddition;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SubMemoryLayout::getHeightWithSubItems()\r\n//-----------------------------------------------------------------------------\r\nquint64 SubMemoryLayout::getHeightWithSubItems() const\r\n{\r\n    quint64 height = mainGraphicsItem_->boundingRect().height() + getSubItemHeightAddition();\r\n\r\n    return height;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SubMemoryLayout::getSceneRectangleWithSubItems()\r\n//-----------------------------------------------------------------------------\r\nQRectF SubMemoryLayout::getSceneRectangleWithSubItems() const\r\n{\r\n    QRectF rectangle = mainGraphicsItem_->sceneBoundingRect();\r\n\r\n    quint64 heightWithSubItems = getHeightWithSubItems();\r\n    if (heightWithSubItems > rectangle.height())\r\n    {\r\n        rectangle.setHeight(heightWithSubItems);\r\n    }\r\n\r\n    return rectangle;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SubMemoryLayout::getUnCutAddresses()\r\n//-----------------------------------------------------------------------------\r\nQVector<quint64> SubMemoryLayout::getUnCutAddresses() const\r\n{\r\n    QVector<quint64> unCutAddresses;\r\n    \r\n    quint64 baseAddress = mainGraphicsItem_->getBaseAddress();\r\n    unCutAddresses.append(baseAddress);\r\n    quint64 lastAddress = mainGraphicsItem_->getLastAddress();\r\n    if (baseAddress != lastAddress)\r\n    {\r\n        unCutAddresses.append(lastAddress);\r\n    }\r\n\r\n    if (!subItemsAreFiltered())\r\n    {\r\n        QMultiMapIterator<quint64, MemoryDesignerChildGraphicsItem*> subItemIterator(getSubMemoryItems());\r\n        while (subItemIterator.hasNext())\r\n        {\r\n            subItemIterator.next();\r\n            MemoryDesignerChildGraphicsItem* subItem = subItemIterator.value();\r\n            quint64 subItemBaseAddress = subItem->getBaseAddress();\r\n            if (!unCutAddresses.contains(subItemBaseAddress))\r\n            {\r\n                unCutAddresses.append(subItemBaseAddress);\r\n            }\r\n\r\n            quint64 subItemLastAddress = subItem->getLastAddress();\r\n            if (!unCutAddresses.contains(subItemLastAddress))\r\n            {\r\n                unCutAddresses.append(subItemLastAddress);\r\n            }\r\n\r\n            SubMemoryLayout* subItemLayout = dynamic_cast<SubMemoryLayout*>(subItem);\r\n            if (subItemLayout && !subItemLayout->subItemsAreFiltered())\r\n            {\r\n                foreach (quint64 address, subItemLayout->getUnCutAddresses())\r\n                {\r\n                    unCutAddresses.append(address);\r\n                }\r\n            }\r\n        }\r\n    }\r\n\r\n    return unCutAddresses;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SubMemoryLayout::getUnCutCoordinates()\r\n//-----------------------------------------------------------------------------\r\nQVector<qreal> SubMemoryLayout::getUnCutCoordinates() const\r\n{\r\n    QVector<qreal> unCutCoordinates;\r\n\r\n    qreal itemTop = mainGraphicsItem_->sceneBoundingRect().top();\r\n    unCutCoordinates.append(itemTop);\r\n    qreal itemLow = mainGraphicsItem_->sceneBoundingRect().bottom();\r\n    if (itemTop != itemLow)\r\n    {\r\n        unCutCoordinates.append(itemLow);\r\n    }\r\n\r\n    if (!subItemsAreFiltered())\r\n    {\r\n        QMultiMapIterator<quint64, MemoryDesignerChildGraphicsItem*> subItemIterator(getSubMemoryItems());\r\n        while (subItemIterator.hasNext())\r\n        {\r\n            subItemIterator.next();\r\n            MemoryDesignerChildGraphicsItem* subItem = subItemIterator.value();\r\n            qreal subItemTop = subItem->sceneBoundingRect().top();\r\n            if (!unCutCoordinates.contains(subItemTop))\r\n            {\r\n                unCutCoordinates.append(subItemTop);\r\n            }\r\n\r\n            qreal subItemLow = subItem->sceneBoundingRect().bottom();\r\n            if (!unCutCoordinates.contains(subItemLow))\r\n            {\r\n                unCutCoordinates.append(subItemLow);\r\n            }\r\n\r\n            SubMemoryLayout* subItemLayout = dynamic_cast<SubMemoryLayout*>(subItem);\r\n            if (subItemLayout && !subItemLayout->subItemsAreFiltered())\r\n            {\r\n                foreach (qreal coordinate, subItemLayout->getUnCutCoordinates())\r\n                {\r\n                    unCutCoordinates.append(coordinate);\r\n                }\r\n            }\r\n        }\r\n    }\r\n\r\n    return unCutCoordinates;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SubMemoryLayout::compressSubItemsToUnCutCoordinates()\r\n//-----------------------------------------------------------------------------\r\nvoid SubMemoryLayout::compressSubItemsToUnCutCoordinates(QVector<qreal> unCutCoordinates, const qreal CUTMODIFIER,\r\n    bool memoryItemsAreCompressed)\r\n{\r\n    qreal lastCoordinate = mainGraphicsItem_->sceneBoundingRect().bottom();\r\n\r\n    QMultiMapIterator<quint64, MemoryDesignerChildGraphicsItem*> subItemIterator(getSubMemoryItems());\r\n    while (subItemIterator.hasNext())\r\n    {\r\n        subItemIterator.next();\r\n        MemoryDesignerChildGraphicsItem* subItem = subItemIterator.value();\r\n\r\n        SubMemoryLayout* subItemLayout = dynamic_cast<SubMemoryLayout*>(subItem);\r\n        if (subItemLayout)\r\n        {\r\n            subItemLayout->compressSubItemsToUnCutCoordinates(\r\n                unCutCoordinates, CUTMODIFIER, memoryItemsAreCompressed);\r\n        }\r\n\r\n        subItem->compressToUnCutCoordinates(unCutCoordinates, CUTMODIFIER, memoryItemsAreCompressed);\r\n\r\n        qreal subItemLow = subItem->sceneBoundingRect().bottom();\r\n        if (subItemLow > lastCoordinate)\r\n        {\r\n            lastCoordinate = subItemLow;\r\n        }\r\n    }\r\n\r\n    QMap<MemoryDesignerChildGraphicsItem*, qreal> subItemTransferValues;\r\n\r\n    qreal itemTop = mainGraphicsItem_->sceneBoundingRect().top();\r\n    qreal areaBegin = itemTop;\r\n    foreach (qreal areaEnd, unCutCoordinates)\r\n    {\r\n        if (areaBegin < lastCoordinate && areaEnd > itemTop)\r\n        {\r\n            qreal areaDifference = areaEnd - areaBegin;\r\n            if (areaDifference > 0)\r\n            {\r\n                if (memoryItemsAreCompressed)\r\n                {\r\n                    areaDifference = areaDifference - CUTMODIFIER;\r\n                }\r\n                else\r\n                {\r\n                    qreal requiredArea = MemoryDesignerConstants::getRequiredAreaForUsedArea(areaDifference);\r\n                    areaDifference = areaDifference - requiredArea;\r\n                }\r\n\r\n                if (areaDifference > 0)\r\n                {\r\n                    qreal transferY = -areaDifference;\r\n\r\n                    subItemIterator.toFront();\r\n                    while (subItemIterator.hasNext())\r\n                    {\r\n                        subItemIterator.next();\r\n                        MemoryDesignerChildGraphicsItem* subItem = subItemIterator.value();\r\n\r\n                        qreal subItemTop = subItem->sceneBoundingRect().top();\r\n                        if (subItemTop > areaBegin)\r\n                        {\r\n                            qreal newSubItemTransferValue = subItemTransferValues.value(subItem, 0) + transferY;\r\n                            subItemTransferValues.insert(subItem, newSubItemTransferValue);\r\n                        }\r\n                    }\r\n                }\r\n            }\r\n        }\r\n        else if (areaBegin >= lastCoordinate)\r\n        {\r\n            break;\r\n        }\r\n\r\n        areaBegin = areaEnd;\r\n    }\r\n\r\n    QMapIterator<MemoryDesignerChildGraphicsItem*, qreal> subItemTransferIterator(subItemTransferValues);\r\n    while (subItemTransferIterator.hasNext())\r\n    {\r\n        subItemTransferIterator.next();\r\n        MemoryDesignerChildGraphicsItem* subItem = subItemTransferIterator.key();\r\n        subItem->moveBy(0, subItemTransferIterator.value());\r\n    }\r\n}\r\n"
  },
  {
    "path": "editors/MemoryDesigner/SubMemoryLayout.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: SubMemoryLayout.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Mikko Teuho\r\n// Date: 22.09.2016\r\n//\r\n// Description:\r\n// Layout for sub memory items of a memory graphics item within memory designer.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef SUBMEMORYLAYOUT_H\r\n#define SUBMEMORYLAYOUT_H\r\n\r\nclass MemoryItem;\r\nclass MemoryDesignerGraphicsItem;\r\nclass MemoryDesignerChildGraphicsItem;\r\nclass MemoryConnectionItem;\r\nclass MainMemoryGraphicsItem;\r\n\r\n#include <QSharedPointer>\r\n#include <QVector>\r\n#include <QMap>\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Layout for sub memory items of a memory graphics item within memory designer.\r\n//-----------------------------------------------------------------------------\r\nclass SubMemoryLayout\r\n{\r\n\r\npublic:\r\n\r\n    /*!\r\n     *  The constructor.\r\n     *\r\n     *    @param [in] memoryItem          Memory item containing main memory item data.\r\n     *    @param [in] subItemType         Type of the sub items.\r\n     *    @param [in] filterSubItems      Value for filtering memory sub items.\r\n     *    @param [in] mainGraphicsItem    The main graphics item.\r\n     */\r\n    SubMemoryLayout(QSharedPointer<MemoryItem const> memoryItem, QString const& subItemType, bool filterSubItems,\r\n        MemoryDesignerGraphicsItem const* mainGraphicsItem);\r\n\r\n    /*!\r\n     *  The copy constructor.\r\n     *\r\n     *    @param [in] other             The original sub layout.\r\n     *    @param [in] mainGraphicsItem  The owner of this layout.\r\n     *\r\n     *    @return Copy of the original sub layout.\r\n     */\r\n    SubMemoryLayout(SubMemoryLayout const& other, MemoryDesignerGraphicsItem const* mainGraphicsItem);\r\n\r\n\t/*!\r\n     *  The destructor.\r\n     */\r\n    virtual ~SubMemoryLayout();\r\n\r\n    /*!\r\n     *  Change the address ranges of the child items.\r\n     *\r\n     *    @param [in] previousAddress   Previous address of the memory item.\r\n     *    @param [in] newAddress        New address for the memory item.\r\n     */\r\n    void changeChildItemAddress(quint64 const& previousBaseAddress, quint64 const& newAddress);\r\n\r\n    /*!\r\n     *  Get the sub memory items.\r\n     *\r\n     *    @return A map containing the sub memory items with the base addresses.\r\n     */\r\n    QMultiMap<quint64, MemoryDesignerChildGraphicsItem*> getSubMemoryItems() const;\r\n\r\n    /*!\r\n     *  Add the memory connection item to the correct memory sub items.\r\n     *\r\n     *    @param [in] connectionItem  The selected memory connection item.\r\n     */\r\n    void addConnectionToSubItems(MemoryConnectionItem* connectionItem);\r\n\r\n    /*!\r\n     *  Check whether the sub items are filtered or not.\r\n     *\r\n     *    @return True, if the sub items are filtered, otherwise false.\r\n     */\r\n    bool subItemsAreFiltered() const;\r\n\r\n    /*!\r\n     *  Resize the name labels for the sub memory items.\r\n     */\r\n    void resizeSubItemNameLabels();\r\n\r\n    /*!\r\n     *  Create overlapping markings for sub memory items.\r\n     */\r\n    void createOverlappingSubItemMarkings();\r\n\r\n    /*!\r\n     *  Get the height addition of the out of bounds sub memory items.\r\n     *\r\n     *    @return The height addition of the out of bounds sub memory items.\r\n     */\r\n    quint64 getSubItemHeightAddition() const;\r\n\r\n    /*!\r\n     *  Get the addresses that are retained after item compression.\r\n     *\r\n     *    @return Addresses that are retained after compressing the item.\r\n     */\r\n    QVector<quint64> getUnCutAddresses() const;\r\n\r\n    /*!\r\n     *  Get the coordinates that are retained after item compression.\r\n     *\r\n     *    @return Coordinates that are retained after compressing the item.\r\n     */\r\n    QVector<qreal> getUnCutCoordinates() const;\r\n\r\n    /*!\r\n     *  Compress the contained sub memory items to contain the retained coordinates.\r\n     *\r\n     *    @param [in] unCutCoordinates            The retained coordinates.\r\n     *    @param [in] CUTMODIFIER                 Modifier for the cut area.\r\n     *    @param [in] memoryItemsAreCompressed    Flag for condensing memory items.\r\n     */\r\n    void compressSubItemsToUnCutCoordinates(QVector<qreal> unCutCoordinates, const qreal CUTMODIFIER,\r\n        bool memoryItemsAreCompressed);\r\n\r\n    /*!\r\n     *  Get layout height modified by the height of the out of bounds sub memory items.\r\n     *\r\n     *    @return True height of the layout.\r\n     */\r\n    virtual quint64 getHeightWithSubItems() const;\r\n\r\n    /*!\r\n     *  Get the scene bounding rectangle of the layout modified by the height of the sub memory items.\r\n     *\r\n     *    @return True scene bounding rectangle of the layout.\r\n     */\r\n    virtual QRectF getSceneRectangleWithSubItems() const;\r\n\r\nprotected:\r\n\r\n    /*!\r\n     *  Clone the sub memory items.\r\n     *\r\n     *    @param [in] other     The original sub memory layout.\r\n     */\r\n    void cloneSubItems(SubMemoryLayout const& other);\r\n\r\n    /*!\r\n     *  Set a new value for filtering memory sub items.\r\n     *\r\n     *    @param [in] filterValue     New filtering value for the memory sub items.\r\n     */\r\n    void setFilterSubItems(bool filterValue);\r\n\r\n    /*!\r\n     *  Get the type of the memory sub items.\r\n     *\r\n     *    @return The type of the memory sub items.\r\n     */\r\n    QString getSubItemType() const;\r\n\r\n    /*!\r\n     *  Setup the sub memory items.\r\n     *\r\n     *    @param [in] subItemPositionX    X position of the sub memory items.\r\n     *    @param [in] subItemType         Type of the memory sub items.\r\n     *    @param [in] memoryItem          The memory item containing the sub items.\r\n     */\r\n    void setupSubItems(qreal subItemPositionX, QString const& subItemType,\r\n        QSharedPointer<MemoryItem const> memoryItem);\r\n\r\n    /*!\r\n     *  Compress the sub items.\r\n     *\r\n     *    @param [in] itemBaseAddress             Base address of the containing item.\r\n     *    @param [in] itemLastAddress             Last address of the containing item.\r\n     *    @param [in] minimumSubItemHeight        The minimum height of the sub items.\r\n     *    @param [in] memoryItemsAreCompressed    Flag for condensing memory items.\r\n     *\r\n     *    @return The total height of the condensed sub items.\r\n     */\r\n    qreal compressChildItems(quint64 itemBaseAddress, quint64 itemLastAddress, qreal minimumSubItemHeight,\r\n        bool memoryItemsAreCondensed);\r\n\r\n    /*!\r\n     *  Compress the selected sub item.\r\n     *\r\n     *    @param [in] subItem                     The selected sub item.\r\n     *    @param [in] minimumSubItemHeight        Minimum height of the sub item.\r\n     *    @param [in] positionY                   Y-coordinate for the sub item.\r\n     *    @param [in] memoryItemsAreCompressed    Flag for condensing memory items.\r\n     */\r\n    quint64 compressSubItem(MemoryDesignerChildGraphicsItem* subItem, qreal minimumSubItemHeight,\r\n        quint64 positionY, bool memoryItemsAreCondensed);\r\n\r\nprivate:\r\n    // Disable copying.\r\n    SubMemoryLayout& operator=(SubMemoryLayout const& rhs);\r\n\r\n    /*!\r\n     *  Create a new sub memory graphics item.\r\n     *\r\n     *    @param [in] subMemoryItem   Memory item containing sub memory item data.\r\n     *    @param [in] isEmpty         Boolean value for an empty sub memory item.\r\n     *\r\n     *    @return The created sub memory graphics item.\r\n     */\r\n    virtual MemoryDesignerChildGraphicsItem* createNewSubItem(QSharedPointer<MemoryItem const> subMemoryItem,\r\n        bool isEmpty) = 0;\r\n\r\n    /*!\r\n     *  Create a copy of the selected sub item.\r\n     *\r\n     *    @param [in] subItem   The selected sub item.\r\n     *\r\n     *    @return Copy of the selected sub item.\r\n     */\r\n    virtual MemoryDesignerChildGraphicsItem* createCopyOfSubItem(MemoryDesignerChildGraphicsItem* subItem) = 0;\r\n\r\n    /*!\r\n     *  Create an empty sub memory graphics item and position it.\r\n     *\r\n     *    @param [in] subItemBaseAddress      Base address of the empty sub memory item.\r\n     *    @param [in] subItemLastAddress      Last address of the empty sub memory item.\r\n     *    @param [in] subItemPositionX        X coordinate of the empty sub memory item.\r\n     *    @param [in] mainItemBaseAddress     Base address of the main memory item.\r\n     */\r\n    void createAndPositionNewEmptySubItem(quint64 subItemBaseAddress, quint64 subItemLastAddress,\r\n        qreal subItemPositionX, quint64 mainItemBaseAddress);\r\n\r\n    /*!\r\n     *  Create an empty sub memory graphics item.\r\n     *\r\n     *    @param [in] beginAddress    Base address of the empty sub memory graphics item.\r\n     *    @param [in] rangeEnd        End address of the empty sub memory graphics item.\r\n     *\r\n     *    @return The created sub memory graphics item.\r\n     */\r\n    virtual MemoryDesignerChildGraphicsItem* createEmptySubItem(quint64 beginAddress, quint64 rangeEnd) = 0;\r\n\r\n    /*!\r\n     *  Place a sub memory graphics item.\r\n     *\r\n     *    @param [in] subItemXPosition        X position of the sub memory item.\r\n     *    @param [in] mainItemBaseAddress     Base address of the main memory item.\r\n     *    @param [in] subItemOffset           Offset of the sub memory item.\r\n     *    @param [in] newSubItem              The selected sub memory item.\r\n     */\r\n    void positionNewSubItem(qreal const& subItemXPosition, quint64 const& mainItemBaseAddress, quint64 const& subItemOffset,\r\n        MemoryDesignerChildGraphicsItem* newSubItem);\r\n\r\n    /*!\r\n     *  Set the color for a faulty sub memory item.\r\n     *\r\n     *    @param [in] subItem     The selected sub memory item.\r\n     */\r\n    void setFaultySubItemColor(MemoryDesignerChildGraphicsItem* subItem);\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! A map containing the sub memory items and their base addresses.\r\n    QMultiMap<quint64, MemoryDesignerChildGraphicsItem*> subMemoryItems_;\r\n\r\n    //! Type of the contained memory item.\r\n    QString itemType_;\r\n\r\n    //! The main graphics memory item.\r\n    MemoryDesignerGraphicsItem const* mainGraphicsItem_;\r\n\r\n    //! Type of the sub memory items.\r\n    QString subItemType_;\r\n\r\n    //! Value for filtering sub memory items.\r\n    bool filterSubItems_;\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n\r\n#endif // SUBMEMORYLAYOUT_H\r\n"
  },
  {
    "path": "editors/PythonSourceEditor/PythonSourceEditor.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: PythonSourceEditor.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Esko Pekkarinen\n// Date: 20.09.2019\n//\n// Description:\n// Widget for Python scripting.\n//-----------------------------------------------------------------------------\n\n#define PY_SSIZE_T_CLEAN\n#include <Python.h>\n\n#include \"PythonSourceEditor.h\"\n\n#include \"PythonSourceHighlight.h\"\n\n#include <QHBoxLayout>\n#include <QFileDialog>\n#include <QTextStream>\n#include <QSplitter>\n#include <QSettings>\n#include <QApplication>\n\n#include <common/widgets/assistedTextEdit/AssistedTextEdit.h>\n#include <common/widgets/assistedTextEdit/HighlightStyleDesc.h>\n\n#include <PythonAPI/PythonInterpreter.h>\n#include <PythonAPI/ChannelRelay.h>\n\n//-----------------------------------------------------------------------------\n// Function: PythonSourceEditor::PythonSourceEditor()\n//-----------------------------------------------------------------------------\nPythonSourceEditor::PythonSourceEditor(QWidget* parent):\n    QWidget(parent),\n    outputChannel_(this),\n    errorChannel_(this),\n    tabs_(this),\n    highlighter_(nullptr),\n    scriptView_(this),\n    interpreter_(new PythonInterpreter(&outputChannel_, &errorChannel_, false, this)),    \n    toolBar_(this),\n    progressBar_(this)\n{    \n    connect(&outputChannel_, SIGNAL(data(QString const&)),\n        &scriptView_, SLOT(print(QString const&)), Qt::UniqueConnection);\n    connect(&errorChannel_, SIGNAL(data(QString const&)),\n        &scriptView_, SLOT(printError(QString const&)), Qt::UniqueConnection);\n\n    bool scriptEnabled = setupInterpreter();\n\n    setupTabs();\n\n    setupToolbar(scriptEnabled);\n\n    setupProgressBar();\n\n    highlighter_.addMultilineCommentRule(QRegularExpression(\"[\\'\\\"]{3}\"),\n        QRegularExpression(\"[\\'\\\"]{3}\"));\n    PythonSourceHighlight highlightRules;\n    highlightRules.apply(&highlighter_);\n\n    setupLayout();\n\n    onNewAction();\n}\n\n//-----------------------------------------------------------------------------\n// Function: PythonSourceEditor::applySettings()\n//-----------------------------------------------------------------------------\nPythonSourceEditor::~PythonSourceEditor()\n{\n    interpreter_->finalize();\n    scriptThread_.quit();\n    scriptThread_.wait();\n}\n\n//-----------------------------------------------------------------------------\n// Function: PythonSourceEditor::applySettings()\n//-----------------------------------------------------------------------------\nvoid PythonSourceEditor::applySettings()\n{\n    QSettings settings;\n\n    // Read font settings.\n    QFont font = settings.value(\"Editor/Font\", QFont(\"Consolas\", 10)).value<QFont>();\n    scriptView_.setFont(font);\n\n    for (int i = 0; i < tabs_.count(); ++i)\n    {\n        auto editor = static_cast<ScriptInputEditor*>(tabs_.widget(i));\n        applySettings(editor);\n    }\n\n    // Read highlight style settings.\n    for (int i = 0; i < LanguageHighlighter::STYLE_COUNT; ++i)\n    {\n        HighlightStyleDesc styleDesc = settings.value(\"Editor/Highlight/\" +\n            LanguageHighlighter::getStyleName(static_cast<LanguageHighlighter::StyleType>(i)),\n            QVariant::fromValue(LanguageHighlighter::DEFAULT_STYLES[i])).value<HighlightStyleDesc>();\n\n        highlighter_.setStyle(static_cast<LanguageHighlighter::StyleType>(i), styleDesc);\n    }\n\n    highlighter_.rehighlight();\n}\n\n//-----------------------------------------------------------------------------\n// Function: PythonSourceEditor::getIdentifyingVLNV()\n//-----------------------------------------------------------------------------\nvoid PythonSourceEditor::onNewAction()\n{\n    createEditor(tr(\"New\"));\n}\n\n//-----------------------------------------------------------------------------\n// Function: PythonSourceEditor::onOpenAction()\n//-----------------------------------------------------------------------------\nvoid PythonSourceEditor::onOpenAction()\n{\n    QString filePath = QFileDialog::getOpenFileName(this, tr(\"Open\"), QString(), tr(\"Python File (*.py)\"));\n\n    if (filePath.isEmpty() == false)\n    {\n        QApplication::setOverrideCursor(Qt::WaitCursor);\n\n        auto editor = createEditor(filePath);\n\n        QFile outputFile(filePath);\n        outputFile.open(QFile::ReadOnly | QFile::Text);\n\n        QTextStream output(&outputFile);\n        editor->setPlainText(output.readAll());\n\n        outputFile.close();\n\n        updateTabLabel(filePath, false);\n      \n        QApplication::restoreOverrideCursor();\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: PythonSourceEditor::onSaveAction()\n//-----------------------------------------------------------------------------\nvoid PythonSourceEditor::onSaveAction()\n{\n    QString filePath = tabs_.tabToolTip(tabs_.currentIndex());\n\n    if (filePath.isEmpty())\n    {\n        onSaveAsAction();\n    }\n    else \n    {\n        QApplication::setOverrideCursor(Qt::WaitCursor);\n\n        auto editor = static_cast<ScriptInputEditor*>(tabs_.currentWidget());\n\n        QFile outputFile(filePath);\n        outputFile.open(QFile::WriteOnly | QFile::Text);\n\n        QTextStream output(&outputFile);\n        output << editor->toPlainText();\n\n        outputFile.close();\n\n        updateTabLabel(filePath, false);\n\n        QApplication::restoreOverrideCursor();\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: PythonSourceEditor::onSaveAsAction()\n//-----------------------------------------------------------------------------\nvoid PythonSourceEditor::onSaveAsAction()\n{\n    QString filePath = QFileDialog::getSaveFileName(this, tr(\"Save As\"), QString(), tr(\"Python File (*.py)\"));\n    if (filePath.isEmpty() == false)\n    {\n        tabs_.setTabToolTip(tabs_.currentIndex(), filePath);\n        onSaveAction();\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: PythonSourceEditor::onRunAction()\n//-----------------------------------------------------------------------------\nvoid PythonSourceEditor::onRunAction()\n{\n    QString script = static_cast<ScriptInputEditor*>(tabs_.currentWidget())->getSelectedLines();\n    scriptView_.printInput(script);\n\n    progressBar_.reset();\n    progressBar_.setRange(0, 0);\n\n    emit executeString(script);\n}\n\n//-----------------------------------------------------------------------------\n// Function: PythonSourceEditor::onRunAllAction()\n//-----------------------------------------------------------------------------\nvoid PythonSourceEditor::onRunAllAction()\n{\n    QString script = static_cast<ScriptInputEditor*>(tabs_.currentWidget())->toPlainText();\n    scriptView_.printInput(script);\n\n    progressBar_.reset();\n    progressBar_.setRange(0, 0);\n\n    emit executeString(script);\n}\n\n//-----------------------------------------------------------------------------\n// Function: PythonSourceEditor::onRunFileAction()\n//-----------------------------------------------------------------------------\nvoid PythonSourceEditor::onRunFileAction()\n{\n    QString fileName = QFileDialog::getOpenFileName(this, tr(\"Select file to run\"), QString(),\n        tr(\"Python File (*.py)\"));\n    if (fileName.isEmpty() == false)\n    {\n        scriptView_.printInput(tr(\"Run script file '%1'.\").arg(fileName));\n\n        progressBar_.reset();\n        progressBar_.setRange(0, 0);\n\n        emit executeFile(fileName);\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: PythonSourceEditor::onRunComplete()\n//-----------------------------------------------------------------------------\nvoid PythonSourceEditor::onRunComplete()\n{\n    progressBar_.setRange(0, 1);\n    progressBar_.setValue(1);\n}\n\n//-----------------------------------------------------------------------------\n// Function: PythonSourceEditor::onTabChanged()\n//-----------------------------------------------------------------------------\nvoid PythonSourceEditor::onTabChanged(int currentIndex)\n{\n    if (currentIndex >= 0)\n    {\n        disconnect(undoAction_, SIGNAL(triggered(bool)), nullptr, nullptr);\n        disconnect(redoAction_, SIGNAL(triggered(bool)), nullptr, nullptr);\n\n        auto editor = static_cast<ScriptInputEditor*>(tabs_.widget(currentIndex));\n        highlighter_.setDocument(editor->document());\n\n        undoAction_->setEnabled(editor->document()->isUndoAvailable());\n        redoAction_->setEnabled(editor->document()->isRedoAvailable());\n\n        connect(undoAction_, SIGNAL(triggered(bool)), editor, SLOT(undo()));\n        connect(redoAction_, SIGNAL(triggered(bool)), editor, SLOT(redo()));\n        connect(editor, SIGNAL(undoAvailable(bool)), undoAction_, SLOT(setEnabled(bool)));\n        connect(editor, SIGNAL(redoAvailable(bool)), redoAction_, SLOT(setEnabled(bool)));\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: PythonSourceEditor::onTabClosed()\n//-----------------------------------------------------------------------------\nvoid PythonSourceEditor::onTabClosed(int index)\n{\n    tabs_.removeTab(index);\n\n    if (tabs_.count() == 0)\n    {\n        onNewAction();\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: PythonSourceEditor::onTabModified()\n//-----------------------------------------------------------------------------\nvoid PythonSourceEditor::onTabModified(bool modified)\n{\n    updateTabLabel(tabs_.tabToolTip(tabs_.currentIndex()), modified);\n}\n\n//-----------------------------------------------------------------------------\n// Function: PythonSourceEditor::updateTabLabel()\n//-----------------------------------------------------------------------------\nvoid PythonSourceEditor::updateTabLabel(QString const& filePath, bool modified)\n{\n    QFileInfo info(filePath);\n\n    QString tabText = info.fileName();\n    if (filePath.isEmpty())\n    {\n        //! Unsaved documents have no filepath, so use name saved on tab text instead.\n        tabText = tabs_.tabText(tabs_.currentIndex());\n    }\n\n    if (modified)\n    {\n        tabText.append(\"*\");\n    }\n    else if (tabText.endsWith(QChar('*')) && modified == false)\n    {\n        //! Unsaved documents have no filepath and may be modified before, so need to remove the asterisk.\n        tabText.chop(1);\n    }\n\n    tabs_.setTabText(tabs_.currentIndex(), tabText);\n    tabs_.setTabToolTip(tabs_.currentIndex(), info.canonicalFilePath());\n}\n\n//-----------------------------------------------------------------------------\n// Function: PythonSourceEditor::createEditor()\n//-----------------------------------------------------------------------------\nScriptInputEditor* PythonSourceEditor::createEditor(QString const& label)\n{\n    auto editor = new ScriptInputEditor();\n    applySettings(editor);\n\n    tabs_.addTab(editor, label);\n    tabs_.setCurrentWidget(editor);\n\n    connect(editor, SIGNAL(modificationChanged(bool)), this, SLOT(onTabModified(bool)), Qt::UniqueConnection);\n\n    return editor;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PythonSourceEditor::applySettings()\n//-----------------------------------------------------------------------------\nvoid PythonSourceEditor::applySettings(ScriptInputEditor* editor) const\n{\n    QSettings settings;\n\n    // Read indentation settings.\n    IndentStyle style = static_cast<IndentStyle>(settings.value(\"Editor/IndentStyle\",\n        INDENT_STYLE_SPACES).toInt());\n    unsigned int width = settings.value(\"Editor/IndentWidth\", 4).toInt();\n    bool useTabs = style == INDENT_STYLE_TAB;\n\n    // Read font settings.\n    QFont font = settings.value(\"Editor/Font\", QFont(\"Consolas\", 10)).value<QFont>();\n\n    editor->setFont(font);\n    editor->setIndentStyle(useTabs, width);\n}\n\n//-----------------------------------------------------------------------------\n// Function: PythonSourceEditor::setupInterpreter()\n//-----------------------------------------------------------------------------\nbool PythonSourceEditor::setupInterpreter()\n{\n    bool enabled = interpreter_->initialize(false);\n    if (enabled)\n    {\n        //! Interpreter runs on different thread so all calls must go through signals for parallel execution.\n        connect(this, SIGNAL(executeLine(QString const&)),\n            interpreter_, SLOT(write(QString const&)), Qt::UniqueConnection);\n        connect(this, SIGNAL(executeString(QString const&)),\n            interpreter_, SLOT(executeString(QString const&)), Qt::UniqueConnection);\n        connect(this, SIGNAL(executeFile(QString const&)),\n            interpreter_, SLOT(runFile(QString const&)), Qt::UniqueConnection);\n\n        connect(interpreter_, SIGNAL(executeDone()),\n            this, SLOT(onRunComplete()), Qt::UniqueConnection);\n\n    }\n\n    return enabled;\n}\n//-----------------------------------------------------------------------------\n// Function: PythonSourceEditor::setupTabs()\n//-----------------------------------------------------------------------------\nvoid PythonSourceEditor::setupTabs()\n{\n    tabs_.setTabsClosable(true);\n    connect(&tabs_, SIGNAL(tabCloseRequested(int)), this, SLOT(onTabClosed(int)), Qt::UniqueConnection);\n    connect(&tabs_, SIGNAL(currentChanged(int)), this, SLOT(onTabChanged(int)), Qt::UniqueConnection);\n}\n\n//-----------------------------------------------------------------------------\n// Function: PythonSourceEditor::setupToolbar()\n//-----------------------------------------------------------------------------\nvoid PythonSourceEditor::setupToolbar(bool enableRun)\n{\n    toolBar_.setOrientation(Qt::Horizontal);\n    toolBar_.setIconSize(QSize(20, 20));\n\n    QAction* newAction = toolBar_.addAction(QIcon(\":/icons/common/graphics/script-new.png\"), QString(), this, SLOT(onNewAction()));\n    newAction->setShortcut(QKeySequence::New);\n    newAction->setShortcutContext(Qt::WidgetWithChildrenShortcut);\n    QString tooltipNew = tr(\"New script (%1)\").arg(newAction->shortcut().toString(QKeySequence::NativeText));\n    newAction->setToolTip(tooltipNew);\n    newAction->setStatusTip(tooltipNew);\n    addAction(newAction);\n\n    QAction* openAction = toolBar_.addAction(QIcon(\":/icons/common/graphics/opened-folder.png\"), QString(), this, SLOT(onOpenAction()));\n    openAction->setShortcut(QKeySequence::Open);\n    openAction->setShortcutContext(Qt::WidgetWithChildrenShortcut);\n    QString tooltipOpen = tr(\"Open script from file... (%1)\").arg(openAction->shortcut().toString(QKeySequence::NativeText));\n    openAction->setToolTip(tooltipOpen);\n    openAction->setStatusTip(tooltipOpen);\n    addAction(openAction);\n\n    QAction* saveAction = toolBar_.addAction(QIcon(\":/icons/common/graphics/script-save.png\"), QString(), this, SLOT(onSaveAction()));\n    saveAction->setShortcut(QKeySequence::Save);\n    saveAction->setShortcutContext(Qt::WidgetWithChildrenShortcut);\n    QString tooltipSave = tr(\"Save script (%1)\").arg(saveAction->shortcut().toString(QKeySequence::NativeText));\n    saveAction->setToolTip(tooltipSave);\n    saveAction->setStatusTip(tooltipSave);\n    addAction(saveAction);\n\n    QAction* saveAsAction = toolBar_.addAction(QIcon(\":/icons/common/graphics/script-save-as.png\"), QString(), this, SLOT(onSaveAsAction()));\n    saveAsAction->setToolTip(tr(\"Save script as...\"));\n    addAction(saveAsAction);\n\n    toolBar_.addSeparator();\n\n    undoAction_ = toolBar_.addAction(QIcon(\":/icons/common/graphics/edit-undo.png\"), QString());\n    undoAction_->setShortcut(QKeySequence::Undo);\n    undoAction_->setShortcutContext(Qt::WidgetWithChildrenShortcut);\n    QString tooltipUndo = tr(\"Undo (%1)\").arg(undoAction_->shortcut().toString(QKeySequence::NativeText));\n    undoAction_->setToolTip(tooltipUndo);\n    undoAction_->setStatusTip(tooltipUndo);\n    addAction(undoAction_);\n\n    redoAction_ = toolBar_.addAction(QIcon(\":/icons/common/graphics/edit-redo.png\"), QString());\n    redoAction_->setShortcut(QKeySequence::Redo);\n    redoAction_->setShortcutContext(Qt::WidgetWithChildrenShortcut);\n    QString tooltipRedo = tr(\"Redo (%1)\").arg(redoAction_->shortcut().toString(QKeySequence::NativeText));\n    redoAction_->setToolTip(tooltipRedo);\n    redoAction_->setStatusTip(tooltipRedo);\n    addAction(redoAction_);\n\n    toolBar_.addSeparator();\n\n    QAction* runAction = toolBar_.addAction(QIcon(\":/icons/common/graphics/control-play.png\"), QString(), this, SLOT(onRunAction()));\n    runAction->setShortcut(QKeySequence(Qt::CTRL | Qt::Key_R));\n    runAction->setShortcutContext(Qt::WidgetWithChildrenShortcut);\n    QString tooltipRun = tr(\"Run selected line(s) (%1)\").arg(runAction->shortcut().toString(QKeySequence::NativeText));\n    runAction->setToolTip(tooltipRun);\n    runAction->setStatusTip(tooltipRun);\n    runAction->setEnabled(enableRun);\n    addAction(runAction);\n\n    QAction* runAllAction = toolBar_.addAction(QIcon(\":/icons/common/graphics/script-run-all.png\"), QString(), this, SLOT(onRunAllAction()));\n    runAllAction->setShortcut(QKeySequence(Qt::CTRL | Qt::SHIFT | Qt::Key_R));\n    runAllAction->setShortcutContext(Qt::WidgetWithChildrenShortcut);\n    QString tooltipRunAll = tr(\"Run all (%1)\").arg(runAllAction->shortcut().toString(QKeySequence::NativeText));\n    runAllAction->setToolTip(tooltipRunAll);\n    runAllAction->setStatusTip(tooltipRunAll);\n    runAllAction->setEnabled(enableRun);\n    addAction(runAllAction);\n\n    QAction* runFileAction = toolBar_.addAction(QIcon(\":/icons/common/graphics/script-run-file.png\"), QString(),\n        this, SLOT(onRunFileAction()));\n    runFileAction->setToolTip(tr(\"Run file...\"));\n    runFileAction->setEnabled(enableRun);\n    addAction(runFileAction);\n\n    toolBar_.addSeparator();\n\n    QAction* clearAction = toolBar_.addAction(QIcon(\":/icons/common/graphics/cleanup.png\"), QString(),\n        &scriptView_, SLOT(clear()));\n    clearAction->setToolTip(tr(\"Clear output\"));\n    addAction(clearAction);\n}\n\n//-----------------------------------------------------------------------------\n// Function: PythonSourceEditor::setupProgressBar()\n//-----------------------------------------------------------------------------\nvoid PythonSourceEditor::setupProgressBar()\n{\n    progressBar_.setTextVisible(false);\n    progressBar_.setRange(0, 1);\n    progressBar_.reset();\n\n    progressBar_.setMaximumHeight(progressBar_.sizeHint().height() / 2);\n}\n\n//-----------------------------------------------------------------------------\n// Function: PythonSourceEditor::setupLayout()\n//-----------------------------------------------------------------------------\nvoid PythonSourceEditor::setupLayout()\n{\n    QWidget* editorContainer = new QWidget(this);\n    QVBoxLayout* editorLayout = new QVBoxLayout(editorContainer);\n\n    editorLayout->addWidget(&tabs_);\n    editorLayout->setContentsMargins(0, 0, 0, 0);\n\n    QWidget* viewContainer = new QWidget(this);\n    QVBoxLayout* viewLayout = new QVBoxLayout(viewContainer);\n    viewLayout->addWidget(&progressBar_);\n    viewLayout->addWidget(&scriptView_);\n    viewLayout->setContentsMargins(0, 0, 0, 0);\n\n    QSplitter* viewSplit = new QSplitter(this);\n    viewSplit->setOrientation(Qt::Vertical);\n    viewSplit->addWidget(editorContainer);\n    viewSplit->addWidget(viewContainer);\n    viewSplit->setStretchFactor(0, 4);\n\n\n    QVBoxLayout* layout = new QVBoxLayout(this);\n    layout->addWidget(&toolBar_);\n    layout->addWidget(viewSplit);\n    layout->setContentsMargins(0, 0, 4, 2);\n}\n"
  },
  {
    "path": "editors/PythonSourceEditor/PythonSourceEditor.h",
    "content": "//-----------------------------------------------------------------------------\n// File: PythonSourceEditor.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Esko Pekkarinen\n// Date: 20.09.2019\n//\n// Description:\n// Widget for Python scripting.\n//-----------------------------------------------------------------------------\n\n#ifndef SCRIPTING_CONSOLE_H\n#define SCRIPTING_CONSOLE_H\n\n#include <QWidget>\n\n#include <QLabel>\n#include <QPlainTextEdit>\n#include <QToolBar>\n#include <QProgressBar>\n#include <QTabWidget>\n#include <QThread>\n#include <QSettings>\n\n#include <PythonAPI/ChannelRelay.h>\n\n#include \"ScriptViewEditor.h\"\n#include \"ScriptInputEditor.h\"\n\n#include <Plugins/common/LanguageHighlighter.h>\n\nclass PythonInterpreter;\n\n//-----------------------------------------------------------------------------\n//! Widget for Python scripting.\n//-----------------------------------------------------------------------------\nclass PythonSourceEditor : public QWidget\n{\n    Q_OBJECT\npublic:\n\n    /*!\n     * The constructor.\n     *\n     *    @param [in] parent  The parent widget.\n     *\n     *    @return \n     */\n     explicit PythonSourceEditor(QWidget* parent = nullptr);\n\n    //! The destructor.\n    virtual ~PythonSourceEditor();\n\n    //! Apply the application settings.\n    void applySettings();\n\nsignals:\n    \n    void executeLine(QString const& line);\n\n    void executeString(QString const& string);\n\n    void executeFile(QString const& path);\n\nprivate slots:\n\n    //! Hander for new button clicks.\n    void onNewAction();\n\n    //! Handler for open button clicks.\n    void onOpenAction();\n\n    //! Handler for save button clicks.\n    void onSaveAction();\n\n    //! Handler for save as button clicks.\n    void onSaveAsAction();\n\n    //! Handler for run button clicks.\n    void onRunAction();\n\n    //! Handler for run all button clicks.\n    void onRunAllAction();\n\n    //! Handler for run file button clicks.\n    void onRunFileAction();\n\n    //! Handler for updating run indicator when run is completed.\n    void onRunComplete();\n\n    //! Handler for editor tab changes.\n    void onTabChanged(int currentIndex);\n\n    //! Handler for editor tab closing.\n    void onTabClosed(int index);\n\n    //! Handler for editor content modification changes.\n    void onTabModified(bool modified);\n\nprivate:\n\n    \n    /*!\n     * Update the tab label and path in tooltip.\n     *\n     *    @param [in] filePath  Path to the edited file.\n     *    @param [in] modified  True, if file content is modified, otherwise false.\n     */\n     void updateTabLabel(QString const& filePath, bool modified);\n\n     /*!\n      * Create a new editor and add it in the tabs.\n      *\n      *    @param [in] label  The label on the tab for the editor.\n      *\n      *    @return The created editor.\n      */\n      ScriptInputEditor* createEditor(QString const& label);\n\n    /*!\n     * Apply formatting settings to a single editor.\n     *\n     *    @param [in] editor  The editor to apply to.\n     */\n    void applySettings(ScriptInputEditor* editor) const;\n\n\n    /*!\n     * Setup the Python interpreter.\n     *\n     *    @return True, if the setup was successful and interpreter stated, otherwise false. \n     */\n     bool setupInterpreter();\n\n     //! Setup the editor tabs.\n     void setupTabs();\n\n    /*\n     * Setup the toolbar and actions.\n     *\n     *    @param[in] enableRun     Enable flag for script run actions.\n     */\n    void setupToolbar(bool enableRun);\n\n    //! Setup the progress bar for script run status indication.\n    void setupProgressBar();\n\n    //! Setup widget layout.\n    void setupLayout();\n\n    //! Write channel for script output.\n    ChannelRelay outputChannel_;\n\n    //! Write channel for script error output.\n    ChannelRelay errorChannel_;\n\n    QAction* undoAction_ = nullptr;\n\n    QAction* redoAction_ = nullptr;\n\n    //! Widget for holding all the tabs for file editors.\n    QTabWidget tabs_;\n\n    //! Syntax highlighter.\n    LanguageHighlighter highlighter_;\n\n    //! Text editor for script writing and run.\n    ScriptViewEditor scriptView_;\n\n    //! Interpreter instance for Python.\n    PythonInterpreter* interpreter_;\n\n    //! Toolbar for actions.\n    QToolBar toolBar_;\n\n    //! Progress bar for displaying editor status.\n    QProgressBar progressBar_;\n\n    //! Thread for running the scripts independent of the editor.\n    QThread scriptThread_;\n\n};\n\n#endif // SCRIPTING_CONSOLE_H\n"
  },
  {
    "path": "editors/PythonSourceEditor/PythonSourceHighlight.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: PythonSourceHighlight.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Esko Pekkarinen\n// Date: 08.06.2022\n//\n// Description:\n// Python language-specific highlight rules.\n//-----------------------------------------------------------------------------\n\n#include \"PythonSourceHighlight.h\"\n\n#include <QRegularExpression>\n\n//-----------------------------------------------------------------------------\n// Function: PythonSourceHighlight::PythonSourceHighlight()\n//-----------------------------------------------------------------------------\nPythonSourceHighlight::PythonSourceHighlight():\n    SourceHighlightStyle()\n{\n    \n}\n\n//-----------------------------------------------------------------------------\n// Function: PythonSourceHighlight::keywords()\n//-----------------------------------------------------------------------------\nQStringList PythonSourceHighlight::keywords() const\n{\n    QStringList keywordPatterns{\n        \"and\", \"as\", \"assert\",\n        \"break\", \"class\", \"continue\",\n        \"def\", \"del\", \"elif\",\n        \"else\", \"except\", \"False\",\n        \"finally\", \"for\", \"from\",\n        \"global\", \"if\", \"import\",\n        \"in\", \"is\", \"lambda\",\n        \"None\", \"nonlocal\", \"not\",\n        \"or\", \"pass\", \"raise\", \n        \"return\", \"True\", \"try\",\n        \"while\", \"with\", \"yield\" };\n\n    return keywordPatterns;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PythonSourceHighlight::preprocessorDirectives()\n//-----------------------------------------------------------------------------\nQStringList PythonSourceHighlight::preprocessorDirectives() const\n{\n    return QStringList();\n}\n\n//-----------------------------------------------------------------------------\n// Function: PythonSourceHighlight::applyLanguageSpecificRules()\n//-----------------------------------------------------------------------------\nvoid PythonSourceHighlight::applyLanguageSpecificRules(LanguageHighlighter* highlighter) const\n{\n    auto stringPattern = QRegularExpression(\"[\\\"][^\\\\r\\\\n]*[\\\"]\");\n    highlighter->addRule(stringPattern, LanguageHighlighter::STRING);\n\n    auto stringPattern2 = QRegularExpression(\"[\\'][^\\\\r\\\\n]*[\\']\");\n    highlighter->addRule(stringPattern2, LanguageHighlighter::STRING);\n\n    auto multilineStringPattern = QRegularExpression(\"[\\\"]{3}.*[\\\"]{3}\",\n        QRegularExpression::InvertedGreedinessOption);\n    highlighter->addRule(multilineStringPattern, LanguageHighlighter::STRING);\n\n    auto multilineStringPattern2 = QRegularExpression(\"[\\']{3}.*[\\']{3}\",\n        QRegularExpression::InvertedGreedinessOption);\n    highlighter->addRule(multilineStringPattern2, LanguageHighlighter::STRING);\n\n    auto commentPattern = QRegularExpression(\"#([^\\\\r\\\\n]*)(?=\\\\r?\\\\n|$)*\");\n    highlighter->addRule(commentPattern, LanguageHighlighter::SINGLE_LINE_COMMENT);\n}\n"
  },
  {
    "path": "editors/PythonSourceEditor/PythonSourceHighlight.h",
    "content": "//-----------------------------------------------------------------------------\n// File: PythonSourceHighlight.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Esko Pekkarinen\n// Date: 08.06.2022\n//\n// Description:\n// Python language-specific highlight rules.\n//-----------------------------------------------------------------------------\n\n#ifndef PYTHONSOURCEHIGHLIGHT_H\n#define PYTHONSOURCEHIGHLIGHT_H\n\n#include <Plugins/common/SourceHighlightStyle.h>\n\nclass LanguageHighlighter;\n\n//-----------------------------------------------------------------------------\n//! PythonSourceHighlight class.\n//-----------------------------------------------------------------------------\nclass PythonSourceHighlight: public SourceHighlightStyle\n{\npublic:\n\n    //! The constructor.\n    PythonSourceHighlight();\n\n    //! The destructor.\n    virtual ~PythonSourceHighlight() = default;\n\n    // Disable copying.\n    PythonSourceHighlight(PythonSourceHighlight const& rhs) = delete;\n    PythonSourceHighlight& operator=(PythonSourceHighlight const& rhs) = delete;\n\nprotected:\n\n    /*!\n     *  Get the language specific keywords.\n     *\n     *    @return The language keywords.\n     */   \n    virtual QStringList keywords() const;\n            \n    /*!\n     *  Get the language specific preprocessor directives.\n     *\n     *    @return The preprocessor directives.\n     */\n    virtual QStringList preprocessorDirectives() const;\n\n    /*!\n     *  Apply other language specific rules to highlighting.\n     *\n     *    @param [in] highlighter   The highlighter to apply the rules to.\n     */\n    virtual void applyLanguageSpecificRules(LanguageHighlighter* highlighter) const; \n\nprivate:\n\n};\n\n//-----------------------------------------------------------------------------\n\n#endif // PYTHONSOURCEHIGHLIGHT_H\n"
  },
  {
    "path": "editors/PythonSourceEditor/ScriptInputEditor.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: ScriptInputEditor.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Esko Pekkarinen\n// Date: 14.10.2019\n//\n// Description:\n// Text editor for script write.\n//-----------------------------------------------------------------------------\n\n#include \"ScriptInputEditor.h\"\n\n#include <QPainter>\n#include <QTextCursor>\n#include <QTextBlock>\n#include <QSettings>\n\n#include <common/KactusColors.h>\n\n#include <PythonAPI/WriteChannel.h>\n\n//-----------------------------------------------------------------------------\n// Function: ScriptInputEditor::ScriptInputEditor()\n//-----------------------------------------------------------------------------\nScriptInputEditor::ScriptInputEditor(QWidget* parent):\n    QPlainTextEdit(parent),\n    editorSideArea_(new ScriptingSideArea(this))\n{\n    setWordWrapMode(QTextOption::NoWrap);\n\n    connect(this, SIGNAL(updateRequest(QRect const&, int)),\n        this, SLOT(updateSideArea(QRect const&, int)), Qt::UniqueConnection);\n    connect(this, SIGNAL(blockCountChanged(int)), this, SLOT(updateSideAreaWidth(int)), Qt::UniqueConnection);\n    connect(this, SIGNAL(cursorPositionChanged()), viewport(), SLOT(update()), Qt::UniqueConnection);\n\n    setViewportMargins(sideAreaWidth(), 0, 0, 0);\n}\n\n//-----------------------------------------------------------------------------\n// Function: ScriptInputEditor::keyPressEvent()\n//-----------------------------------------------------------------------------\nvoid ScriptInputEditor::keyPressEvent(QKeyEvent *e)\n{\n    if (e->key() == Qt::Key_Tab && useTabs_ == false)\n    {\n        insertPlainText(QString(indentWidth_, QChar(' ')));\n        return;\n    }\n\n    QPlainTextEdit::keyPressEvent(e);\n}\n\n//-----------------------------------------------------------------------------\n// Function: ScriptInputEditor::keyPressEvent()\n//-----------------------------------------------------------------------------\nvoid ScriptInputEditor::paintEvent(QPaintEvent *e)\n{\n    QPlainTextEdit::paintEvent(e);\n\n    highlightSelectedLines();\n}\n\n//-----------------------------------------------------------------------------\n// Function: ScriptInputEditor::resizeEvent()\n//-----------------------------------------------------------------------------\nvoid ScriptInputEditor::resizeEvent(QResizeEvent *e)\n{\n    QPlainTextEdit::resizeEvent(e);\n\n    QRect cr = contentsRect();\n    editorSideArea_->setGeometry(QRect(cr.left(), cr.top(), sideAreaWidth(), cr.height()));\n}\n\n//-----------------------------------------------------------------------------\n// Function: ScriptInputEditor::getSelectedLines()\n//-----------------------------------------------------------------------------\nQString ScriptInputEditor::getSelectedLines() const\n{\n    QTextCursor cursor = textCursor();\n    if (cursor.hasSelection() == false)\n    {\n        cursor.movePosition(QTextCursor::StartOfLine);\n        cursor.movePosition(QTextCursor::EndOfLine, QTextCursor::KeepAnchor);\n    }\n    else\n    {\n        int start = cursor.selectionStart();\n        int end = cursor.selectionEnd();\n\n        cursor.setPosition(start);\n        cursor.movePosition(QTextCursor::StartOfLine);\n\n        cursor.setPosition(end, QTextCursor::KeepAnchor);\n        cursor.movePosition(QTextCursor::EndOfLine, QTextCursor::KeepAnchor);\n    }\n\n    return cursor.selectedText().replace(QChar(QChar::ParagraphSeparator), QChar('\\n'));\n}\n\n//-----------------------------------------------------------------------------\n// Function: ScriptInputEditor::setIndentStyle()\n//-----------------------------------------------------------------------------\nvoid ScriptInputEditor::setIndentStyle(bool useTabs, unsigned int width)\n{\n    useTabs_ = useTabs;\n    indentWidth_ = width;\n}\n\n//-----------------------------------------------------------------------------\n// Function: ScriptInputEditor::lineNumberAreaWidth()\n//-----------------------------------------------------------------------------\nint ScriptInputEditor::sideAreaWidth() const\n{\n    int digits = 1;\n    int max = qMax(1, blockCount());\n    while (max >= 10)\n    {\n        max /= 10;\n        ++digits;\n    }\n\n    int space = 2 + fontMetrics().horizontalAdvance(QLatin1Char('9')) * (digits + 1) + 4;\n\n    return space;\n}\n\n//-----------------------------------------------------------------------------\n// Function: ScriptInputEditor::sideAreaPaintEvent()\n//-----------------------------------------------------------------------------\nvoid ScriptInputEditor::sideAreaPaintEvent(QPaintEvent* event)\n{\n    QPainter painter(editorSideArea_);\n\n    //! Draw background.\n    QColor backgroundColor = QColor(Qt::lightGray).lighter(120);\n    painter.setPen(backgroundColor);\n    painter.setBrush(backgroundColor);\n    painter.drawRect(event->rect());\n\n    //! Draw line numbers.\n    QTextBlock block = firstVisibleBlock();\n    int blockNumber = block.blockNumber();\n    int cursorBlock = textCursor().blockNumber();\n\n    int top = qRound(blockBoundingGeometry(block).translated(contentOffset()).top());\n    int bottom = top + qRound(blockBoundingRect(block).height());\n\n    while (block.isValid() && top <= event->rect().bottom())\n    {\n        if (block.isVisible() && bottom >= event->rect().top())\n        {\n            if (blockNumber == cursorBlock)\n            {\n                painter.setPen(Qt::black);\n            }\n            else\n            {\n                painter.setPen(Qt::darkGray);\n            }\n\n            painter.drawText(0, top, editorSideArea_->width()-4, fontMetrics().height(),\n                Qt::AlignRight, QString::number(blockNumber + 1));\n        }\n\n        block = block.next();\n        top = bottom;\n        bottom = top + qRound(blockBoundingRect(block).height());\n        ++blockNumber;\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: ScriptInputEditor::updateSideAreaWidth()\n//-----------------------------------------------------------------------------\nvoid ScriptInputEditor::updateSideAreaWidth(int /* newBlockCount */)\n{\n    setViewportMargins(sideAreaWidth(), 0, 0, 0);\n}  \n\n//-----------------------------------------------------------------------------\n// Function: ScriptInputEditor::updateSideArea()\n//-----------------------------------------------------------------------------\nvoid ScriptInputEditor::updateSideArea(QRect const& rect, int dy)\n{\n    if (dy)\n    {\n        editorSideArea_->scroll(0, dy);\n    }\n    else\n    {\n        editorSideArea_->update(0, rect.y(), editorSideArea_->width(), rect.height());\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: ScriptInputEditor::highlightSelectedLines()\n//-----------------------------------------------------------------------------\nvoid ScriptInputEditor::highlightSelectedLines() const\n{\n    QPainter painter(viewport());\n    painter.setPen(QColor(Qt::lightGray).lighter(120));\n\n    QTextCursor cursor = textCursor();\n    int start = cursor.selectionStart();\n    int end = cursor.selectionEnd();\n\n    cursor.setPosition(start);\n    auto startBlock = cursor.block();\n\n    if (startBlock.isVisible())\n    {\n        auto startRect = blockBoundingGeometry(startBlock).translated(contentOffset());\n        painter.drawLine(startRect.topLeft(), startRect.topRight());\n    }\n\n    cursor.setPosition(end);\n    auto endBlock = cursor.block();\n\n    if (endBlock.isVisible())\n    {\n        auto endRect = blockBoundingGeometry(endBlock).translated(contentOffset());\n        painter.drawLine(endRect.bottomLeft(), endRect.bottomRight());\n    }\n}\n"
  },
  {
    "path": "editors/PythonSourceEditor/ScriptInputEditor.h",
    "content": "//-----------------------------------------------------------------------------\n// File: ScriptInputEditor.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Esko Pekkarinen\n// Date: 14.10.2019\n//\n// Description:\n// Text editor for script write.\n//-----------------------------------------------------------------------------\n\n#ifndef SCRIPTINPUTEDITOR_H\n#define SCRIPTINPUTEDITOR_H\n\n#include <QPlainTextEdit>\n\n#include \"ScriptingSideArea.h\"\n\n//-----------------------------------------------------------------------------\n//! Text editor for script write.\n//-----------------------------------------------------------------------------\nclass ScriptInputEditor : public QPlainTextEdit\n{\n    Q_OBJECT\npublic:\n\n    /*!\n     * The constructor.\n     *\n     *    @param [in] parent  The parent widget.\n     */\n    explicit ScriptInputEditor(QWidget* parent = nullptr);\n\n    //! The destructor.\n    virtual ~ScriptInputEditor() = default;\n\n    /*!\n     * Get the required width of the side area.\n     *\n     *    @return The width of the side area in pixels.\n     */\n    int sideAreaWidth() const;\n\n    /*!\n     * Handler for side area paint event.\n     *\n     *    @param [in]  The paint event.\n     */\n    void sideAreaPaintEvent(QPaintEvent* event);\n\n    /*!\n     * Get the text on selected lines.\n     *\n     *    @return The text on the currently selected lines.\n     */\n     QString getSelectedLines() const;\n\n     /*!\n      * Set the style for automatic indentation.\n      *\n      *    @param [in] useTabs     Whether to use tabs or spaces.\n      *    @param [in] width       Number of spaces to use.\n      */\n      void setIndentStyle(bool useTabs, unsigned int width);\n\nprotected:\n\n    //! Event handler for key press handling.\n    virtual void keyPressEvent(QKeyEvent *e) override final;\n\n    //! Event handler for painting.\n    virtual void paintEvent(QPaintEvent *e) override final;\n\n    //! Event handler for widget resize.\n    void resizeEvent(QResizeEvent *event) override;\n\nprivate slots:\n\n    /*!\n     * Update the side area width when the number of lines (blocks) change.\n     *\n     *    @param [in] newBlockCount  The number of blocks in the text.\n     */\n     void updateSideAreaWidth(int newBlockCount);\n\n      /*!\n       * Handler for side area update event.\n       *\n       *    @param [in] rect     The area being updated.\n       *    @param [in] dy       The change of y coordinate in the update.\n       */\n      void updateSideArea(const QRect &rect, int dy);\n\n\n      //! Add highlight to currently selected lines.\n      void highlightSelectedLines() const;\n\nprivate:\n\n    //-----------------------------------------------------------------------------\n    // Data.\n    //-----------------------------------------------------------------------------\n\n    //! Side area for the widget for holding line numbers.\n    ScriptingSideArea* editorSideArea_;\n\n    //! Use tabs or spaces for indent.\n    bool useTabs_ = false;\n\n    //! How many spaces to use for indent.\n    int indentWidth_ = 4;\n\n\n\n};\n\n#endif // SCRIPTINPUTEDITOR_H\n"
  },
  {
    "path": "editors/PythonSourceEditor/ScriptViewEditor.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: ScriptViewEditor.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Esko Pekkarinen\n// Date: 14.10.2019\n//\n// Description:\n// Text editor for script write and run.\n//-----------------------------------------------------------------------------\n\n#include \"ScriptViewEditor.h\"\n\n#include <QTextBlock>\n#include <QScrollBar>\n#include <QMenu>\n#include <QKeySequence>\n#include <QPainter>\n#include <QVariant>\n#include <QTextStream>\n\n#include <PythonAPI/WriteChannel.h>\n\n//-----------------------------------------------------------------------------\n// Function: ScriptViewEditor::ScriptViewEditor()\n//-----------------------------------------------------------------------------\nScriptViewEditor::ScriptViewEditor(QWidget* parent):\n    QPlainTextEdit(parent)\n{       \n    setReadOnly(true);\n}\n\n//-----------------------------------------------------------------------------\n// Function: ScriptViewEditor::printInput()\n//-----------------------------------------------------------------------------\nvoid ScriptViewEditor::printInput(QString const& input)\n{\n    printWithColor(input, QColor(Qt::blue));\n\n    if (input.endsWith(QChar('\\n')) == false)\n    {\n        QTextCursor cursor = textCursor();\n        cursor.insertBlock();\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: ScriptViewEditor::print()\n//-----------------------------------------------------------------------------\nvoid ScriptViewEditor::print(QString const& input)\n{\n    printWithColor(input, QColor(Qt::black));\n}\n\n//-----------------------------------------------------------------------------\n// Function: ScriptViewEditor::printError()\n//-----------------------------------------------------------------------------\nvoid ScriptViewEditor::printError(QString const& input)\n{\n    printWithColor(input, QColor(Qt::red));\n}\n\n//-----------------------------------------------------------------------------\n// Function: ScriptViewEditor::printWithColor()\n//-----------------------------------------------------------------------------\nvoid ScriptViewEditor::printWithColor(QString const& input, QColor const& textColor)\n{\n    QTextCursor cursor = textCursor();\n    cursor.movePosition(QTextCursor::End);\n\n    QTextBlock block = cursor.block();\n\n    QTextCharFormat format = block.charFormat();\n    format.setForeground(QBrush(textColor));\n\n    cursor.insertText(input, format);\n\n    verticalScrollBar()->setValue(verticalScrollBar()->maximum());\n}\n"
  },
  {
    "path": "editors/PythonSourceEditor/ScriptViewEditor.h",
    "content": "//-----------------------------------------------------------------------------\n// File: ScriptViewEditor.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Esko Pekkarinen\n// Date: 14.10.2019\n//\n// Description:\n// Text editor for script write and run.\n//-----------------------------------------------------------------------------\n\n#ifndef SCRIPTVIEWEDITOR_H\n#define SCRIPTVIEWEDITOR_H\n\n#include <QPlainTextEdit>\n\n//-----------------------------------------------------------------------------\n//! Text editor for script write and run.\n//-----------------------------------------------------------------------------\nclass ScriptViewEditor : public QPlainTextEdit\n{\n    Q_OBJECT\npublic:\n\n    /*!\n     * The constructor.\n     *\n     *    @param [in] parent  The parent widget.\n     */\n    explicit ScriptViewEditor(QWidget* parent = nullptr);\n\n    //! The destructor.\n    virtual ~ScriptViewEditor() = default;\n\npublic slots:\n\n    /*! Print the given text in the editor.\n     *\n     *    @param [in] input  The text to print.\n     */\n    void printInput(QString const& input);\n\n    /*! Print the given text in the editor.\n     *\n     *    @param [in] input  The text to print.\n     */\n    void print(QString const& input);\n\n    /*! Print the given error text in the editor.\n     *\n     *    @param [in] input  The error text to print.\n     */\n    void printError(QString const& input);\n\nprivate:\n\n    /*!\n     * Print the given input with given color.\n     *\n     *    @param [in] input        The input text to print.\n     *    @param [in] textColor    The color of the text to use.\n     */\n     void printWithColor(QString const& input, QColor const& textColor);\n\n    //-----------------------------------------------------------------------------\n    // Data.\n    //-----------------------------------------------------------------------------\n\n    //! The current prompt text.\n    QString promptText_ = QString();\n\n};\n\n#endif // SCRIPTVIEWEDITOR_H\n"
  },
  {
    "path": "editors/PythonSourceEditor/ScriptingSideArea.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: ScriptingConsole.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Esko Pekkarinen\n// Date: 20.09.2019\n//\n// Description:\n// Widget for showing info besides scripting text editor.\n//-----------------------------------------------------------------------------\n\n#include \"ScriptingSideArea.h\"\n\n#include \"ScriptInputEditor.h\"\n\n//-----------------------------------------------------------------------------\n// Function: ScriptingSideArea::ScriptingSideArea()\n//-----------------------------------------------------------------------------\nScriptingSideArea::ScriptingSideArea(ScriptInputEditor* editor) : QWidget(editor), editor_(editor)\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: ScriptingSideArea::sizeHint()\n//-----------------------------------------------------------------------------\nQSize ScriptingSideArea::sizeHint() const\n{\n    return QSize(editor_->sideAreaWidth(), 0);\n}\n\n//-----------------------------------------------------------------------------\n// Function: ScriptingSideArea::paintEvent()\n//-----------------------------------------------------------------------------\nvoid ScriptingSideArea::paintEvent(QPaintEvent *event)\n{\n    editor_->sideAreaPaintEvent(event);\n    event->accept();\n}\n"
  },
  {
    "path": "editors/PythonSourceEditor/ScriptingSideArea.h",
    "content": "//-----------------------------------------------------------------------------\n// File: ScriptingConsole.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Esko Pekkarinen\n// Date: 20.09.2019\n//\n// Description:\n// Widget for showing info besides scripting text editor.\n//-----------------------------------------------------------------------------\n\n#ifndef SCRIPTING_SIDE_AREA_H\n#define SCRIPTING_SIDE_AREA_H\n\n#include <QWidget>\n\n\nclass ScriptInputEditor;\n\n//-----------------------------------------------------------------------------\n//! Widget for showing info besides scripting text editor.\n//-----------------------------------------------------------------------------\nclass ScriptingSideArea : public QWidget\n{\npublic:\n\n    //! The constructor.\n    explicit ScriptingSideArea(ScriptInputEditor* editor);\n\n    virtual ~ScriptingSideArea() = default;\n\n    //! Size hint for preferred size in layout.\n    QSize sizeHint() const override;\n\nprotected:\n\n    //! The handler for paint events.\n    virtual void paintEvent(QPaintEvent *event) override;\n\nprivate:\n\n    //! The scripting editor for which to show side information.\n    ScriptInputEditor* editor_;\n};\n\n#endif // SCRIPTING_SIDE_AREA_H\n"
  },
  {
    "path": "editors/SystemDesign/ApiGraphicsConnection.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ApiGraphicsConnection.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Mikko Teuho\r\n// Date: 16.02.2016\r\n//\r\n// Description:\r\n// A graphical representation of a Kactus2 API interconnection.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"ApiGraphicsConnection.h\"\r\n\r\n#include <editors/common/diagramgrid.h>\r\n#include <editors/common/DiagramUtil.h>\r\n\r\n#include <IPXACTmodels/kactusExtensions/ApiInterconnection.h>\r\n#include <IPXACTmodels/kactusExtensions/ConnectionRoute.h>\r\n#include <IPXACTmodels/generaldeclarations.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ApiGraphicsConnection::ApiGraphicsConnection()\r\n//-----------------------------------------------------------------------------\r\nApiGraphicsConnection::ApiGraphicsConnection(QPointF const& p1, QVector2D const& dir1, QPointF const& p2,\r\n    QVector2D const& dir2, DesignDiagram* parent) :\r\n    ConnectionItem(p1, dir1, p2, dir2, parent)\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ApiGraphicsConnection::ApiGraphicsConnection()\r\n//-----------------------------------------------------------------------------\r\nApiGraphicsConnection::ApiGraphicsConnection(ConnectionEndpoint* endpoint1, ConnectionEndpoint* endpoint2,\r\n    QSharedPointer<ApiInterconnection> apiInterconnection,\r\n    QSharedPointer<ConnectionRoute> route, bool autoConnect,\r\n    DesignDiagram* parent) :\r\n    ConnectionItem(endpoint1, endpoint2, apiInterconnection, route, autoConnect, parent)\r\n{\r\n\r\n}\r\n"
  },
  {
    "path": "editors/SystemDesign/ApiGraphicsConnection.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ApiGraphicsConnection.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Mikko Teuho\r\n// Date: 16.02.2016\r\n//\r\n// Description:\r\n// A graphical representation of a Kactus2 API interconnection.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef APIGRAPHICSCONNECTION_H\r\n#define APIGRAPHICSCONNECTION_H\r\n\r\n#include <QGraphicsPathItem>\r\n#include <QGraphicsTextItem>\r\n#include <QUndoCommand>\r\n\r\n#include <common/graphicsItems/ConnectionItem.h>\r\n#include <common/graphicsItems/GraphicsItemTypes.h>\r\n\r\n#include <IPXACTmodels/kactusExtensions/ApiInterconnection.h>\r\n\r\nclass ConnectionRoute;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! A graphical representation of a Kactus2 API interconnection.\r\n//-----------------------------------------------------------------------------\r\nclass ApiGraphicsConnection : public ConnectionItem<ApiInterconnection>\r\n{\r\n    Q_OBJECT\r\n\r\npublic:\r\n\r\n    //! Type of the API interconnection.\r\n    enum { Type = GFX_TYPE_SW_API_CONNECTION };\r\n\r\n\r\n    /*!\r\n     *  Constructor which creates an open-ended diagram interconnection.\r\n     *\r\n     *    @param [in] p1              The start point of the connection.\r\n     *    @param [in] dir1            Direction of the start point.\r\n     *    @param [in] p2              The end point of the connection.\r\n     *    @param [in] dir2            Direction of the end point.\r\n     *    @param [in] parent          The design diagram containing the connection.\r\n     */\r\n    ApiGraphicsConnection(QPointF const& p1, QVector2D const& dir1, QPointF const& p2, QVector2D const& dir2,\r\n                          DesignDiagram* parent);\r\n\r\n    /*!\r\n     *  The constructor containing the API interconnection.\r\n     *\r\n     *    @param [in] endpoint1           The start point of the connection.\r\n     *    @param [in] endpoint2           The end point of the connection.\r\n     *    @param [in] apiInterconnection  The API interconnection being connected.\r\n     *    @param [in] route               The route of the connection.\r\n     *    @param [in] autoConnect         If true, automatically connects the two end points.\r\n     *    @param [in] parent              The design diagram containing the connection.\r\n     */\r\n    ApiGraphicsConnection(ConnectionEndpoint* endpoint1, ConnectionEndpoint* endpoint2,\r\n                          QSharedPointer<ApiInterconnection> apiInterconnection,\r\n                          QSharedPointer<ConnectionRoute> route, bool autoConnect, DesignDiagram* parent);\r\n\r\n    /*!\r\n     *  The destructor.\r\n     */\r\n    virtual ~ApiGraphicsConnection() = default;\r\n\r\n    /*!\r\n     *  Get the type of the graphics item.\r\n     *\r\n     *    @return GFX_TYPE_SW_API_CONNECTION.\r\n     */\r\n    int type() const final { return Type; }\r\n    \r\n};\r\n\r\n#endif // APIGRAPHICSCONNECTION_H\r\n"
  },
  {
    "path": "editors/SystemDesign/ComGraphicsConnection.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ComGraphicsConnection.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Mikko Teuho\r\n// Date: 15.02.2016\r\n//\r\n// Description:\r\n// A graphical representation of a Kactus2 com interconnection.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"ComGraphicsConnection.h\"\r\n\r\n#include <editors/common/diagramgrid.h>\r\n#include <editors/common/DiagramUtil.h>\r\n\r\n#include <IPXACTmodels/kactusExtensions/ComInterconnection.h>\r\n#include <IPXACTmodels/kactusExtensions/ConnectionRoute.h>\r\n#include <IPXACTmodels/generaldeclarations.h>\r\n\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComGraphicsConnection::ComGraphicsConnection()\r\n//-----------------------------------------------------------------------------\r\nComGraphicsConnection::ComGraphicsConnection(QPointF const& p1, QVector2D const& dir1, QPointF const& p2,\r\n                                             QVector2D const& dir2, DesignDiagram* parent):\r\nConnectionItem(p1, dir1, p2, dir2,  parent)\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComGraphicsConnection::ComGraphicsConnection()\r\n//-----------------------------------------------------------------------------\r\nComGraphicsConnection::ComGraphicsConnection(ConnectionEndpoint* endpoint1, ConnectionEndpoint* endpoint2,\r\n                                             QSharedPointer<ComInterconnection> comInterconnection,\r\n                                             QSharedPointer<ConnectionRoute> route, bool autoConnect,\r\n                                             DesignDiagram* parent):\r\n    ConnectionItem(endpoint1, endpoint2, comInterconnection, route, autoConnect, parent)\r\n{\r\n\r\n}\r\n"
  },
  {
    "path": "editors/SystemDesign/ComGraphicsConnection.h",
    "content": "//-----------------------------------------------------------------------------\n// File: ComGraphicsConnection.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 15.02.2016\n//\n// Description:\n// A graphical representation of a Kactus2 com interconnection.\n//-----------------------------------------------------------------------------\n\n#ifndef COMGRAPHICSCONNECTION_H\n#define COMGRAPHICSCONNECTION_H\n\n#include <QGraphicsPathItem>\n#include <QGraphicsTextItem>\n#include <QUndoCommand>\n\n#include <common/graphicsItems/ConnectionItem.h>\n#include <common/graphicsItems/GraphicsItemTypes.h>\n\n#include <IPXACTmodels/kactusExtensions/ComInterconnection.h>\n\nclass ConnectionRoute;\n\n//-----------------------------------------------------------------------------\n//! A graphical representation of a Kactus2 com interconnection.\n//-----------------------------------------------------------------------------\nclass ComGraphicsConnection : public ConnectionItem<ComInterconnection>\n{\n    Q_OBJECT\n\npublic:\n\n    //! The type of the COM connection item.\n    enum { Type = GFX_TYPE_SW_COM_CONNECTION };\n\n    /*!\n     *  Constructor which creates an open-ended diagram interconnection.\n     *\n     *    @param [in] p1              The start point.\n     *    @param [in] dir1            Direction of the start point.\n     *    @param [in] p2              The end point.\n     *    @param [in] dir2            Direction of the end point.\n     *    @param [in] parent          The design diagram containing the connection.\n     */\n    ComGraphicsConnection(QPointF const& p1, QVector2D const& dir1, QPointF const& p2, QVector2D const& dir2,\n                          DesignDiagram* parent);\n\n    /*!\n     *  The constructor containing the connected COM interconnection.\n     *\n     *    @param [in] endpoint1           The start point of the connection.\n     *    @param [in] endpoint2           The end point of the connection.\n     *    @param [in] comInterconnection  The connected COM interconnection.\n     *    @param [in] route               Route of the interconnection.\n     *    @param [in] autoConnect         If true, the end points are automatically connected.\n     *    @param [in] parent              The containing design diagram.\n     */\n    ComGraphicsConnection(ConnectionEndpoint* endpoint1, ConnectionEndpoint* endpoint2,\n                          QSharedPointer<ComInterconnection> comInterconnection,\n                          QSharedPointer<ConnectionRoute> route, bool autoConnect, DesignDiagram* parent);\n\n    /*!\n     *  The destructor.\n     */\n    virtual ~ComGraphicsConnection() = default;\n\n    /*!\n     *  Get the type of the graphical COM connection.\n     *\n     *    @return The type of the COM connection item.\n     */\n    int type() const { return Type; }\n\n};\n\n#endif // COMGRAPHICSCONNECTION_H\n"
  },
  {
    "path": "editors/SystemDesign/HWMappingItem.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: HWMappingItem.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Joni-Matti Maatta\r\n// Date: 30.4.2012\r\n//\r\n// Description:\r\n// Graphics item for visualizing the underlying HW in system designs.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"HWMappingItem.h\"\r\n\r\n#include \"SystemDesignDiagram.h\"\r\n#include \"SWComponentItem.h\"\r\n#include \"SWPortItem.h\"\r\n\r\n#include <KactusAPI/include/LibraryInterface.h>\r\n\r\n#include <common/graphicsItems/GraphicsConnection.h>\r\n#include <common/graphicsItems/CommonGraphicsUndoCommands.h>\r\n#include <common/GenericEditProvider.h>\r\n#include <common/KactusColors.h>\r\n\r\n#include <IPXACTmodels/Component/Component.h>\r\n#include <IPXACTmodels/Design/ComponentInstance.h>\r\n\r\n#include <QBrush>\r\n#include <QUndoCommand>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HWMappingItem::HWMappingItem()\r\n//-----------------------------------------------------------------------------\r\nHWMappingItem::HWMappingItem(LibraryInterface* libInterface, QSharedPointer<Component> component,\r\n                             QSharedPointer<ComponentInstance> instance):\r\nSystemComponentItem(QRectF(-WIDTH/ 2, 0, WIDTH, 0), libInterface, instance, component, nullptr)\r\n{\r\n    setFlag(ItemIsMovable);\r\n    \r\n    HWMappingItem::updateComponent();\r\n    HWMappingItem::updateItemPositions();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HWMappingItem::~HWMappingItem()\r\n//-----------------------------------------------------------------------------\r\nHWMappingItem::~HWMappingItem()\r\n{\r\n    // Remove this item from the column where it resides.\r\n    auto column = dynamic_cast<IGraphicsItemStack*>(parentItem());\r\n\r\n    if (column != nullptr)\r\n    {\r\n        column->removeItem(this);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: mousePressEvent()\r\n//-----------------------------------------------------------------------------\r\nvoid HWMappingItem::mousePressEvent(QGraphicsSceneMouseEvent *event)\r\n{\r\n    ComponentItem::mousePressEvent(event);\r\n    setZValue(1001.0);\r\n\r\n    oldPos_ = scenePos();\r\n    oldStack_ = dynamic_cast<IGraphicsItemStack*>(parentItem());\r\n\r\n    // End the position update for all connections.\r\n    for (QGraphicsItem *item: scene()->items())\r\n    {\r\n        auto conn = dynamic_cast<GraphicsConnection*>(item);\r\n\r\n        if (conn != nullptr)\r\n        {\r\n            conn->beginUpdatePosition();\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: mouseMoveEvent()\r\n//-----------------------------------------------------------------------------\r\nvoid HWMappingItem::mouseMoveEvent(QGraphicsSceneMouseEvent* event)\r\n{\r\n    // Discard mouse move if the diagram is protected.\r\n    if (static_cast<DesignDiagram*>(scene())->isProtected())\r\n    {\r\n        return;\r\n    }\r\n\r\n    setConnectionUpdateDisabled(true);\r\n\r\n    ComponentItem::mouseMoveEvent(event);\r\n\r\n    if (oldStack_ != nullptr)\r\n    {\r\n        setPos(parentItem()->mapFromScene(oldStack_->mapStackToScene(pos())));\r\n\r\n        auto column = dynamic_cast<IGraphicsItemStack*>(parentItem());\r\n        Q_ASSERT(column != nullptr);\r\n        column->onMoveItem(this);\r\n    }\r\n\r\n    setConnectionUpdateDisabled(false);\r\n\r\n    // Update the port connections manually.\r\n    for (QGraphicsItem *item : childItems())\r\n    {\r\n        if (item->type() != SWPortItem::Type)\r\n        {\r\n            continue;\r\n        }\r\n\r\n        auto port = static_cast<SWPortItem*>(item);\r\n\r\n        for (GraphicsConnection* conn : port->getConnections())\r\n        {\r\n            conn->updatePosition();\r\n        }\r\n\r\n        for (GraphicsConnection* conn : port->getOffPageConnector()->getConnections())\r\n        {\r\n            conn->updatePosition();\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: mouseReleaseEvent()\r\n//-----------------------------------------------------------------------------\r\nvoid HWMappingItem::mouseReleaseEvent(QGraphicsSceneMouseEvent* event)\r\n{\r\n    ComponentItem::mouseReleaseEvent(event);\r\n    setZValue(0.0);\r\n\r\n    auto diagram = dynamic_cast<DesignDiagram*>(scene());\r\n    if (diagram && oldStack_ != nullptr)\r\n    {\r\n        auto column = dynamic_cast<IGraphicsItemStack*>(parentItem());\r\n        Q_ASSERT(column != nullptr);\r\n        column->onReleaseItem(this);\r\n\r\n        QSharedPointer<QUndoCommand> cmd;\r\n\r\n        if (scenePos() != oldPos_)\r\n        {\r\n            cmd = QSharedPointer<QUndoCommand>(new ItemMoveCommand(this, oldPos_, oldStack_, diagram));\r\n        }\r\n        else\r\n        {\r\n            cmd = QSharedPointer<QUndoCommand>(new QUndoCommand());\r\n        }\r\n\r\n        // End the position update for all connections.\r\n        for (QGraphicsItem *item : scene()->items())\r\n        {\r\n            auto conn = dynamic_cast<GraphicsConnection*>(item);\r\n\r\n            if (conn != nullptr)\r\n            {\r\n                conn->endUpdatePosition(cmd.data());\r\n            }\r\n        }\r\n        \r\n        // Add the undo command to the edit stack only if it has at least some real changes.\r\n        if (cmd->childCount() > 0 || scenePos() != oldPos_)\r\n        {\r\n            diagram->getEditProvider()->addCommand(cmd);\r\n            cmd->redo();\r\n        }\r\n\r\n        oldStack_ = nullptr;\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HWMappingItem::getHeight()\r\n//-----------------------------------------------------------------------------\r\nqreal HWMappingItem::getHeight()\r\n{\r\n    // Calculate the minimum height based on the stack contents.\r\n    qreal stackHeight = getComponentStackHeight();\r\n\r\n    // Determine the largest one from the stack height, minimum height (empty) and the height\r\n    // calculated by the base class.\r\n    return qMax<qreal>(qMax<qreal>(stackHeight, MIN_HEIGHT), SystemComponentItem::getHeight());\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HWMappingItem::getWidth()\r\n//-----------------------------------------------------------------------------\r\nqreal HWMappingItem::getWidth() noexcept\r\n{\t\r\n\treturn WIDTH;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HWMappingItem::addItem()\r\n//-----------------------------------------------------------------------------\r\nvoid HWMappingItem::addItem(QGraphicsItem* item, bool load)\r\n{\r\n\tif (item->parentItem() != 0)\r\n\t{\r\n\t\tdynamic_cast<IGraphicsItemStack*>(item->parentItem())->removeItem(item);\r\n\t}\r\n\r\n    // Map the position to the column's local coordinate system\r\n    // and constrain the item to the horizontal center of the column.\r\n    QPointF pos = mapFromScene(item->scenePos());\r\n    pos.setX(0.0);\r\n\r\n    item->setParentItem(this);\r\n    item->setPos(pos);\r\n\r\n    item->setFlag(ItemStacksBehindParent, false);\r\n\r\n    auto compItem = static_cast<ComponentItem*>(item);\r\n\r\n    if (load)\r\n    {\r\n        // Place the item at the correct index in the items list.\r\n        for (int i = 0; i < swComponents_.size(); ++i)\r\n        {\r\n            if (item->y() < swComponents_.at(i)->y())\r\n            {\r\n                swComponents_.insert(i, compItem);\r\n\r\n                offsetPortPositions(getComponentStackHeight() + SPACING);\r\n                updateSize();\r\n                return;\r\n            }\r\n        }\r\n\r\n        // If we got here, the item must be placed at the end of the list.\r\n        swComponents_.append(compItem);\r\n\r\n        offsetPortPositions(getComponentStackHeight() + SPACING);\r\n        updateSize();\r\n    }\r\n    else\r\n    {\r\n        swComponents_.append(compItem);\r\n        \r\n        layout_->updateItemMove(swComponents_, compItem, TOP_MARGIN);\r\n        layout_->setItemPos(swComponents_, compItem, 0.0, TOP_MARGIN);\r\n        updateItemPositions();\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HWMappingItem::removeItem()\r\n//-----------------------------------------------------------------------------\r\nvoid HWMappingItem::removeItem(QGraphicsItem* item)\r\n{\r\n    swComponents_.removeAll(static_cast<ComponentItem*>(item));\r\n    item->setParentItem(nullptr);\r\n    updateItemPositions();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HWMappingItem::onMoveItem()\r\n//-----------------------------------------------------------------------------\r\nvoid HWMappingItem::onMoveItem(QGraphicsItem* item)\r\n{\r\n    auto compItem = static_cast<ComponentItem*>(item);\r\n\r\n    layout_->updateItemMove(swComponents_, compItem, TOP_MARGIN);\r\n    offsetPortPositions(getComponentStackHeight() + SPACING);\r\n    updateSize();\r\n\r\n    // Check if the item is not overlapping the HW mapping item enough.\r\n    QRectF intersection = sceneBoundingRect().intersected(item->sceneBoundingRect());\r\n\r\n    QSharedPointer<ComponentInstance> swInstance = compItem->getComponentInstance();\r\n    if (swInstance)\r\n    {\r\n        swInstance->setMapping(getComponentInstance()->getUuid());\r\n    }\r\n\r\n    auto swItem = static_cast<SWComponentItem*>(compItem);\r\n    // Only non-imported SW components can be moved out of the HW mapping item.\r\n    if (!swItem->isImported() && swItem->rect().height() - intersection.height() >= swItem->rect().height())\r\n    {\r\n        swComponents_.removeAll(compItem);\r\n\r\n        // Let the parent component stack handle the mouse move.\r\n        auto parentStack = dynamic_cast<IGraphicsItemStack*>(parentItem());\r\n        Q_ASSERT(parentStack != nullptr);\r\n        \r\n        QPointF newPos = parentStack->mapStackFromScene(compItem->scenePos());\r\n        compItem->setParentItem(parentItem());\r\n        compItem->setPos(newPos);\r\n        compItem->setFlag(ItemStacksBehindParent);\r\n\r\n        updateItemPositions();\r\n        setZValue(0.0);\r\n\r\n        swInstance->setMapping(\"\");\r\n\r\n        parentStack->onMoveItem(compItem);\r\n        return;\r\n    }\r\n\r\n    setZValue(1001.0);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HWMappingItem::onReleaseItem()\r\n//-----------------------------------------------------------------------------\r\nvoid HWMappingItem::onReleaseItem(QGraphicsItem* item)\r\n{\r\n    setZValue(0.0);\r\n    layout_->setItemPos(swComponents_, static_cast<ComponentItem*>(item), 0.0, TOP_MARGIN);\r\n    offsetPortPositions(getComponentStackHeight() + SPACING);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HWMappingItem::updateItemPositions()\r\n//-----------------------------------------------------------------------------\r\nvoid HWMappingItem::updateItemPositions()\r\n{\r\n    // Just update the item positions.\r\n    layout_->updateItemPositions(swComponents_, 0.0, TOP_MARGIN);\r\n    offsetPortPositions(getComponentStackHeight() + SPACING);\r\n    updateSize();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HWMappingItem::mapStackToScene()\r\n//-----------------------------------------------------------------------------\r\nQPointF HWMappingItem::mapStackToScene(QPointF const& pos) const\r\n{\r\n    return mapToScene(pos);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HWMappingItem::mapStackFromScene()\r\n//-----------------------------------------------------------------------------\r\nQPointF HWMappingItem::mapStackFromScene(QPointF const& pos) const\r\n{\r\n    return mapFromScene(pos);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HWMappingItem::isItemAllowed()\r\n//-----------------------------------------------------------------------------\r\nbool HWMappingItem::isItemAllowed(QGraphicsItem* item) const\r\n{\r\n    return (item->type() == SWComponentItem::Type && componentModel()->isCpu());\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HWMappingItem::getComponentStackHeight()\r\n//-----------------------------------------------------------------------------\r\nqreal HWMappingItem::getComponentStackHeight() const\r\n{\r\n    qreal stackHeight = TOP_MARGIN + BOTTOM_MARGIN;\r\n\r\n    if (!swComponents_.isEmpty())\r\n    {\r\n        for (ComponentItem* item : swComponents_)\r\n        {\r\n            stackHeight += item->boundingRect().height();\r\n        }\r\n\r\n        stackHeight += (swComponents_.size() - 1) * SPACING;\r\n    }\r\n\r\n    return stackHeight;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HWMappingItem::updateComponent()\r\n//-----------------------------------------------------------------------------\r\nvoid HWMappingItem::updateComponent()\r\n{\r\n    ComponentItem::updateComponent();\r\n\r\n    VLNV vlnv = componentModel()->getVlnv();\r\n\r\n    // Check whether the component is packaged (valid vlnv) or not.\r\n    if (vlnv.isValid())\r\n    {\r\n        if (!getLibraryInterface()->contains(vlnv))\r\n        {\r\n            setBrush(QBrush(KactusColors::MISSING_COMPONENT));\r\n        }\r\n        else\r\n        {\r\n            setBrush(QBrush(KactusColors::HW_COMPONENT));\r\n        }\r\n    }\r\n    else\r\n    {\r\n        setBrush(QBrush(KactusColors::DRAFT_COMPONENT));\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HWMappingItem::getContentType()\r\n//-----------------------------------------------------------------------------\r\nColumnTypes::ColumnContentType HWMappingItem::getContentType() const\r\n{\r\n    return ColumnTypes::COMPONENTS;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HWMappingItem::getLinkedHW()\r\n//-----------------------------------------------------------------------------\r\nHWMappingItem const* HWMappingItem::getLinkedHW() const\r\n{\r\n    return this;\r\n}\r\n"
  },
  {
    "path": "editors/SystemDesign/HWMappingItem.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: HWMappingItem.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Joni-Matti Maatta\r\n// Date: 30.4.2012\r\n//\r\n// Description:\r\n// Graphics item for visualizing the underlying HW in system designs.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef HWMAPPINGITEM_H\r\n#define HWMAPPINGITEM_H\r\n\r\n#include \"SystemComponentItem.h\"\r\n\r\n#include <common/graphicsItems/ComponentItem.h>\r\n#include <common/graphicsItems/IGraphicsItemStack.h>\r\n#include <common/layouts/IVGraphicsLayout.h>\r\n#include <common/layouts/VStackedLayout.h>\r\n\r\nclass SWComponentItem;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Graphics item for visualizing the underlying HW in system designs.\r\n//-----------------------------------------------------------------------------\r\nclass HWMappingItem : public SystemComponentItem, public IGraphicsItemStack\r\n{\r\npublic:\r\n    enum { Type = GFX_TYPE_HW_MAPPING_ITEM };\r\n\r\n    /*!\r\n     *  The constructor.\r\n     *\r\n     *    @param [in] libInterface                The library interface.\r\n     *    @param [in] component                   The contained component.\r\n     *    @param [in] instanceName                The instance name.\r\n     *    @param [in] displayName                 The instance display name.\r\n     *    @param [in] description                 The instance description.\r\n     *    @param [in] uuid                        The instance id.\r\n     *    @param [in] configurableElementValues   The configurable element values.\r\n     */\r\n\tHWMappingItem(LibraryInterface* libInterface, QSharedPointer<Component> component,\r\n\t\tQSharedPointer<ComponentInstance> instance);\r\n\r\n    /*!\r\n     *  Destructor.\r\n     */\r\n    ~HWMappingItem() final;\r\n\r\n    // Disable copying.\r\n    HWMappingItem(HWMappingItem const& rhs) = delete;\r\n    HWMappingItem& operator=(HWMappingItem const& rhs) = delete;\r\n\r\n    /*!\r\n     *  Returns the underlying HW linked with this component.\r\n     */\r\n    virtual HWMappingItem const* getLinkedHW() const;\r\n\r\n    /*!\r\n     *  Returns the graphics item type.\r\n     */\r\n    int type() const { return Type; }\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // IGraphicsItemStack implementation.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    /*!\r\n     *  Adds an item to the system column.\r\n     *\r\n     *    @param [in] item  The item to add.\r\n     *    @param [in] load  If true, the item is being loaded from a design.\r\n     */\r\n    void addItem(QGraphicsItem* item, bool load = false);\r\n\r\n    /*!\r\n     *  Removes an item from the system column.\r\n     *\r\n     *    @param [in] item the item to remove.\r\n     */\r\n    void removeItem(QGraphicsItem* item);\r\n\r\n    /*!\r\n     *  Called when an item is moved within the column.\r\n     *\r\n     *    @param [in] item       The item that has been moved.\r\n     */\r\n    void onMoveItem(QGraphicsItem* item);\r\n\r\n    /*!\r\n     *  Called when an item is released from being moved by mouse.\r\n     *\r\n     *    @param [in] item The item that has been released.\r\n     */\r\n    void onReleaseItem(QGraphicsItem* item);\r\n\r\n    /*!\r\n     *  Updates the item positions so that there are no violations of the stacking rule.\r\n     */\r\n    void updateItemPositions();\r\n\r\n    /*!\r\n     *  Maps the given local position to scene coordinates.\r\n     */\r\n    QPointF mapStackToScene(QPointF const& pos) const;\r\n\r\n    /*!\r\n     *  Maps the given scene position to local coordinates.\r\n     */\r\n    QPointF mapStackFromScene(QPointF const& pos) const;\r\n\r\n    /*!\r\n     *  Returns true if the stack is allowed to contain the given item.\r\n     *\r\n     *    @param [in] item The item to test for.\r\n     */\r\n    bool isItemAllowed(QGraphicsItem* item) const;\r\n\r\n    /*!\r\n     *  Returns the content type.\r\n     */\r\n    ColumnTypes::ColumnContentType getContentType() const;\r\n\r\n    virtual void updateComponent();\r\n\r\nprotected:\r\n    // Called when the user presses the mouse button.\r\n    void mousePressEvent(QGraphicsSceneMouseEvent *event);\r\n\r\n    //! Called when the user moves the column with the mouse.\r\n    void mouseMoveEvent(QGraphicsSceneMouseEvent* event);\r\n\r\n    //! Called when the user release the mouse.\r\n    void mouseReleaseEvent(QGraphicsSceneMouseEvent* event);\r\n\r\n    /*!\r\n     *  Returns the height for the component box.\r\n     */\r\n    qreal getHeight() final;\r\n\r\n    /*!\r\n     *  Return the width for the component box.\r\n     */\r\n    qreal getWidth() noexcept final;\r\n\r\n    /*!\r\n     *  Returns the height of the component stack.\r\n     */\r\n    qreal getComponentStackHeight() const;\r\n\r\nprivate:\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    // Constants.\r\n    static constexpr int MIN_HEIGHT = 100;\r\n    static constexpr int TOP_MARGIN = 40;\r\n\r\n    static constexpr int WIDTH = COMPONENTWIDTH + 20;\r\n\r\n    //! The old column from where the mouse drag event began.\r\n    IGraphicsItemStack* oldStack_= nullptr;\r\n\r\n    //! The layout for components.\r\n    QSharedPointer< IVGraphicsLayout<ComponentItem> > layout_ =\r\n        QSharedPointer< IVGraphicsLayout<ComponentItem> >(new VStackedLayout<ComponentItem>(SPACING));\r\n\r\n    //! The mapped SW components.\r\n    QList<ComponentItem*> swComponents_;\r\n\r\n    //! The mapping component's old position before mouse move.\r\n    QPointF oldPos_;\r\n\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n\r\n#endif // HWMAPPINGITEM_H\r\n"
  },
  {
    "path": "editors/SystemDesign/SWComponentItem.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: SWComponentItem.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Joni-Matti Maatta\r\n// Date: 30.4.2012\r\n//\r\n// Description:\r\n// Graphics item for visualizing SW components.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"SWComponentItem.h\"\r\n\r\n#include \"HWMappingItem.h\"\r\n#include \"SWPortItem.h\"\r\n#include \"SystemDesignDiagram.h\"\r\n\r\n#include <IPXACTmodels/Component/Component.h>\r\n#include <IPXACTmodels/Component/Model.h>\r\n#include <IPXACTmodels/Design/ComponentInstance.h>\r\n\r\n#include <KactusAPI/include/LibraryInterface.h>\r\n\r\n#include <common/graphicsItems/GraphicsConnection.h>\r\n#include <common/graphicsItems/IGraphicsItemStack.h>\r\n#include <common/graphicsItems/CommonGraphicsUndoCommands.h>\r\n#include <common/GenericEditProvider.h>\r\n#include <common/KactusColors.h>\r\n\r\n\r\n#include <QBrush>\r\n#include <QUndoCommand>\r\n#include <QMenu>\r\n#include <QGraphicsSceneContextMenuEvent>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SWComponentItem::SWComponentItem()\r\n//-----------------------------------------------------------------------------\r\nSWComponentItem::SWComponentItem(LibraryInterface* libInterface, QSharedPointer<Component> component,\r\n                                 QSharedPointer<ComponentInstance> instance):\r\nSystemComponentItem(QRectF(-COMPONENTWIDTH / 2, 0, COMPONENTWIDTH, MIN_HEIGHT), libInterface, instance,\r\n    component, nullptr)\r\n{\r\n    setFlag(ItemIsMovable);\r\n\r\n    updateComponent();\r\n\r\n    updateSize();\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SWComponentItem::~SWComponentItem()\r\n//-----------------------------------------------------------------------------\r\nSWComponentItem::~SWComponentItem()\r\n{\r\n    // Remove this item from the stack where it resides.\r\n    IGraphicsItemStack* stack = dynamic_cast<IGraphicsItemStack*>(parentItem());\r\n\r\n    if (stack != 0)\r\n    {\r\n        stack->removeItem(this);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: mousePressEvent()\r\n//-----------------------------------------------------------------------------\r\nvoid SWComponentItem::mousePressEvent(QGraphicsSceneMouseEvent *event)\r\n{\r\n    DesignDiagram* diagram = dynamic_cast<DesignDiagram*>(scene());\r\n\r\n    if (diagram == 0)\r\n    {\r\n        return;\r\n    }\r\n\r\n    setZValue(1001.0);\r\n    ComponentItem::mousePressEvent(event);\r\n\r\n    oldPos_ = scenePos();\r\n    oldStack_ = dynamic_cast<IGraphicsItemStack*>(parentItem());\r\n    oldStackPos_ = parentItem()->scenePos();\r\n\r\n    // Begin the position update for all connections.\r\n    for (QGraphicsItem *item : scene()->items())\r\n    {\r\n        GraphicsConnection* conn = dynamic_cast<GraphicsConnection*>(item);\r\n\r\n        if (conn != nullptr)\r\n        {\r\n            conn->beginUpdatePosition();\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: mouseMoveEvent()\r\n//-----------------------------------------------------------------------------\r\nvoid SWComponentItem::mouseMoveEvent(QGraphicsSceneMouseEvent* event)\r\n{\r\n    // Discard movement if the diagram is protected.\r\n    DesignDiagram* diagram = dynamic_cast<DesignDiagram*>(scene());\r\n\r\n    if (diagram == 0 || diagram->isProtected())\r\n    {\r\n        return;\r\n    }\r\n\r\n    setConnectionUpdateDisabled(true);\r\n\r\n    ComponentItem::mouseMoveEvent(event);\r\n\r\n    if (oldStack_ != 0)\r\n    {\r\n        setPos(parentItem()->mapFromScene(oldStackPos_ + pos()));\r\n\r\n        auto stack = dynamic_cast<IGraphicsItemStack*>(parentItem());\r\n        Q_ASSERT(stack != nullptr);\r\n        stack->onMoveItem(this);\r\n    }\r\n\r\n    setConnectionUpdateDisabled(false);\r\n\r\n    // Update the port connections manually.\r\n    for (QGraphicsItem *item : childItems())\r\n    {\r\n        if (item->type() != SWPortItem::Type)\r\n        {\r\n            continue;\r\n        }\r\n\r\n        auto port = static_cast<SWPortItem*>(item);\r\n\r\n        for (GraphicsConnection* conn : port->getConnections())\r\n        {\r\n            conn->updatePosition();\r\n        }\r\n\r\n        for (GraphicsConnection* conn : port->getOffPageConnector()->getConnections())\r\n        {\r\n            conn->updatePosition();\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: mouseReleaseEvent()\r\n//-----------------------------------------------------------------------------\r\nvoid SWComponentItem::mouseReleaseEvent(QGraphicsSceneMouseEvent* event)\r\n{\r\n    DesignDiagram* diagram = dynamic_cast<DesignDiagram*>(scene());\r\n\r\n    if (diagram == 0)\r\n    {\r\n        return;\r\n    }\r\n\r\n    ComponentItem::mouseReleaseEvent(event);\r\n    setZValue(0.0);\r\n\r\n    if (oldStack_ != nullptr)\r\n    {\r\n        auto stack = dynamic_cast<IGraphicsItemStack*>(parentItem());\r\n        Q_ASSERT(stack != nullptr);\r\n        stack->onReleaseItem(this);\r\n\r\n        if (scenePos() != oldPos_)\r\n        {\r\n            auto moveCommand = QSharedPointer<QUndoCommand>(new ItemMoveCommand(this, oldPos_, oldStack_, diagram));\r\n\r\n            diagram->getEditProvider()->addCommand(moveCommand);\r\n\r\n            moveCommand->redo();\r\n        }\r\n\r\n        oldStack_ = nullptr;\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SWComponentItem::updateComponent()\r\n//-----------------------------------------------------------------------------\r\nvoid SWComponentItem::updateComponent()\r\n{\r\n    ComponentItem::updateComponent();\r\n\r\n    VLNV vlnv = componentModel()->getVlnv();\r\n\r\n    // Check whether the component is packaged or not.\r\n    if (isDraft())\r\n    {\r\n        setBrush(QBrush(KactusColors::DRAFT_COMPONENT));\r\n    }\r\n    else if (getLibraryInterface()->contains(vlnv))\r\n    {\r\n        setBrush(QBrush(KactusColors::SW_COMPONENT));\r\n    }\r\n    else\r\n    {\r\n        setBrush(QBrush(KactusColors::MISSING_COMPONENT));\r\n    }\r\n\r\n    // Create a hierarchy icon if the component is a hierarchical one.\r\n    if (componentModel()->isHierarchical())\r\n    {\r\n        if (hierIcon_ == nullptr)\r\n        {\r\n            hierIcon_ = new QGraphicsPixmapItem(QPixmap(\":icons/common/graphics/hierarchy.png\"), this);\r\n            hierIcon_->setToolTip(tr(\"Hierarchical\"));\r\n            hierIcon_->setPos(58, 6);\r\n        }\r\n    }\r\n    else if (hierIcon_ != 0)\r\n    {\r\n        delete hierIcon_;\r\n        hierIcon_ = nullptr;\r\n    }\r\n\r\n    // Create imported icon if the component is an imported one.\r\n    if (isImported())\r\n    {\r\n        if (importedIcon_ == nullptr)\r\n        {\r\n            hierIcon_ = new QGraphicsPixmapItem(QPixmap(\":icons/common/graphics/imported.png\"), this);\r\n            hierIcon_->setToolTip(tr(\"Auto-synced\"));\r\n            hierIcon_->setPos(-75, 6);\r\n        }\r\n    }\r\n    else if (importedIcon_ != nullptr)\r\n    {\r\n        delete importedIcon_;\r\n        importedIcon_ = nullptr;\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: mouseDoubleClickEvent()\r\n//-----------------------------------------------------------------------------\r\nvoid SWComponentItem::contextMenuEvent(QGraphicsSceneContextMenuEvent* event)\r\n{\r\n    QGraphicsItem::contextMenuEvent(event);\r\n\r\n    QMenu menu;\r\n    menu.addAction(\"Open Source...\", this, SLOT(openCSource()));\r\n\r\n    menu.exec(event->screenPos());\r\n    event->accept();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: openCSource()\r\n//-----------------------------------------------------------------------------\r\nvoid SWComponentItem::openCSource()\r\n{\r\n    // TODO: Auto-generate code.\r\n    emit openCSource(this);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SWComponentItem::setFileSetRef()\r\n//-----------------------------------------------------------------------------\r\nvoid SWComponentItem::setFileSetRef(QString const& fileSetName)\r\n{\r\n    if (fileSetRef_ != fileSetName)\r\n    {\r\n        fileSetRef_ = fileSetName;\r\n\t\tgetComponentInstance()->setFileSetRef( fileSetRef_ );\r\n        emit fileSetRefChanged(fileSetRef_);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SWComponentItem::getFileSetRef()\r\n//-----------------------------------------------------------------------------\r\nQString const& SWComponentItem::getFileSetRef() const\r\n{\r\n    return fileSetRef_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SWComponentItem::getParentHW()\r\n//-----------------------------------------------------------------------------\r\nHWMappingItem const* SWComponentItem::getLinkedHW() const\r\n{\r\n    return dynamic_cast<HWMappingItem*>(parentItem());\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SWComponentItem::setPackaged()\r\n//-----------------------------------------------------------------------------\r\nvoid SWComponentItem::setPackaged()\r\n{\r\n    isDraft_ = false;\r\n    updateComponent();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SWComponentItem::setDraft()\r\n//-----------------------------------------------------------------------------\r\nvoid SWComponentItem::setDraft()\r\n{\r\n    isDraft_ = true;\r\n    updateComponent();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SWComponentItem::isDraft()\r\n//-----------------------------------------------------------------------------\r\nbool SWComponentItem::isDraft() const\r\n{\r\n    return isDraft_;\r\n}\r\n\r\n"
  },
  {
    "path": "editors/SystemDesign/SWComponentItem.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: SWComponentItem.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Joni-Matti Maatta\r\n// Date: 30.4.2012\r\n//\r\n// Description:\r\n// Graphics item for visualizing SW components.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef SWCOMPONENTITEM_H\r\n#define SWCOMPONENTITEM_H\r\n\r\n#include \"SystemComponentItem.h\"\r\n\r\n#include <common/graphicsItems/ComponentItem.h>\r\n\r\nclass IGraphicsItemStack;\r\nclass HWMappingItem;\r\nclass ComponentInstance;\r\nclass Component;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Graphics item for visualizing SW components.\r\n//-----------------------------------------------------------------------------\r\nclass SWComponentItem : public SystemComponentItem\r\n{\r\n    Q_OBJECT\r\n\r\npublic:\r\n    enum { Type = GFX_TYPE_SW_COMPONENT_ITEM };\r\n\r\n    /*!\r\n     *  The constructor.\r\n     *\r\n     *    @param [in] libInterface                Library interface.\r\n     *    @param [in] component                   The instantiated component.\r\n     *    @param [in] instanceName                The instance name.\r\n     *    @param [in] displayName                 The instance display name.\r\n     *    @param [in] description                 The instance description.\r\n     *    @param [in] uuid                        The instance id.\r\n     *    @param [in] configurableElementValues   The configurable element values.\r\n     */\r\n\tSWComponentItem(LibraryInterface* libInterface, QSharedPointer<Component> component,\r\n\t\tQSharedPointer<ComponentInstance> instance);\r\n\r\n    /*!\r\n     *  Destructor.\r\n     */\r\n    ~SWComponentItem();\r\n\r\n    /*!\r\n     *  Sets the file set reference.\r\n     *\r\n     *    @param [in] fileSetName The name of the referenced file set in the top-level component.\r\n     */\r\n    void setFileSetRef(QString const& fileSetName);\r\n\r\n    /*!\r\n     *  Returns the file set reference (i.e. the name of the referenced file set).\r\n     */\r\n    QString const& getFileSetRef() const;\r\n\r\n    /*!\r\n     *  Returns the underlying HW linked with this component.\r\n     */\r\n    virtual HWMappingItem const* getLinkedHW() const;\r\n\r\n    /*!\r\n     *  Returns the graphics item type.\r\n     */\r\n    int type() const { return Type; }\r\n\r\n    virtual void updateComponent();\r\n\r\n    /*!\r\n     *  Marks the component as a packetized component.\r\n     */\r\n    virtual void setPackaged();\r\n\r\n    /*!\r\n     *  Marks the component as a draft component.\r\n     */\r\n    virtual void setDraft();\r\n\r\n    /*!\r\n     *  Checks if the component instance is a draft.\r\n     *\r\n     *    @return True, if the instance is a draft, otherwise false.\r\n     */\r\n    bool isDraft() const;\r\n\r\n\r\npublic slots:\r\n    void openCSource();\r\n\r\nsignals:\r\n    //! Requests to open the C source for this component.\r\n    void openCSource(ComponentItem* compItem);\r\n\r\n    //! Occurs when the file set reference has been changed.\r\n    void fileSetRefChanged(QString const& fileSetRef);\r\n\r\nprotected:\r\n    // Called when the user presses the mouse button.\r\n    void mousePressEvent(QGraphicsSceneMouseEvent *event);\r\n\r\n    //! Called when the user moves the column with the mouse.\r\n    void mouseMoveEvent(QGraphicsSceneMouseEvent* event);\r\n\r\n    //! Called when the user release the mouse.\r\n    void mouseReleaseEvent(QGraphicsSceneMouseEvent* event);\r\n\r\n    //! Opens up the context menu when right mouse button is pressed.\r\n    void contextMenuEvent(QGraphicsSceneContextMenuEvent* event);\r\n\r\nprivate:\r\n    // Disable copying.\r\n    SWComponentItem(SWComponentItem const& rhs);\r\n    SWComponentItem& operator=(SWComponentItem const& rhs);\r\n    \r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    // Constants.\r\n    const int MIN_HEIGHT = 60;\r\n\r\n    //! The old stack from where the mouse drag event began.\r\n    IGraphicsItemStack* oldStack_ = nullptr;\r\n\r\n    //! The mapping component's old position before mouse move.\r\n    QPointF oldPos_;\r\n    QPointF oldStackPos_;\r\n\r\n    QGraphicsPixmapItem* hierIcon_ = nullptr;\r\n    QGraphicsPixmapItem* importedIcon_ = nullptr;\r\n\r\n    //! The file set reference. Empty string if no reference.\r\n    QString fileSetRef_;\r\n\r\n    //! If true, the component instance is a draft.\r\n    bool isDraft_ = false;\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n\r\n#endif // SWCOMPONENTITEM_H\r\n"
  },
  {
    "path": "editors/SystemDesign/SWConnectionEndpoint.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: SWConnectionEndpoint.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Joni-Matti Maatta\r\n// Date: 2.5.2012\r\n//\r\n// Description:\r\n// Common interface for SW connection endpoints.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"SWConnectionEndpoint.h\"\r\n\r\n#include <IPXACTmodels/kactusExtensions/ComInterface.h>\r\n\r\n#include <common/KactusColors.h>\r\n\r\n#include <editors/common/diagramgrid.h>\r\n#include <editors/HWDesign/OffPageConnectorItem.h>\r\n#include <editors/SystemDesign/SWComponentItem.h>\r\n\r\n#include <QPen>\r\n#include <QFont>\r\n#include <QGraphicsDropShadowEffect>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SWConnectionEndpoint()\r\n//-----------------------------------------------------------------------------\r\nSWConnectionEndpoint::SWConnectionEndpoint(QSharedPointer<Component> component, QString const& name,\r\n    QGraphicsItem* parent, QVector2D const& dir):\r\nConnectionEndpoint(parent),\r\ntype_(ConnectionEndpoint::ENDPOINT_TYPE_UNDEFINED),\r\nnameLabel_(new GraphicsItemLabel(QString(), this)),\r\ncontainingComponent_(component)\r\n{\r\n    nameLabel_->setText(name);\r\n\r\n    ConnectionEndpoint::setDirection(dir);\r\n\r\n    if (parent)\r\n    {\r\n        auto parentSW = dynamic_cast<SystemComponentItem*>(parent);\r\n        if (parentSW)\r\n        {\r\n            parentItem_ = parentSW;\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SWConnectionEndpoint::encompassingComp()\r\n//-----------------------------------------------------------------------------\r\nComponentItem* SWConnectionEndpoint::encompassingComp() const\r\n{\r\n    return parentItem_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SWConnectionEndpoint::getOwnerComponent()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<Component> SWConnectionEndpoint::getOwnerComponent() const\r\n{\r\n    return containingComponent_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SWConnectionEndpoint::getNameLabel()\r\n//-----------------------------------------------------------------------------\r\nGraphicsItemLabel* SWConnectionEndpoint::getNameLabel() const\r\n{\r\n    return nameLabel_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SWConnectionEndpoint::getOffPageConnector()\r\n//-----------------------------------------------------------------------------\r\nConnectionEndpoint* SWConnectionEndpoint::getOffPageConnector() const\r\n{\r\n    return offPageConnector_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SWConnectionEndpoint::updateInterface()\r\n//-----------------------------------------------------------------------------\r\nvoid SWConnectionEndpoint::updateInterface()\r\n{\r\n    ConnectionEndpoint::updateInterface();\r\n\r\n    if (isInvalid())\r\n    {\r\n        setBrush(QBrush(Qt::red));\r\n        return;\r\n    }\r\n\r\n    ConnectionEndpoint::EndpointType endPointType = getType();\r\n    if (endPointType == ENDPOINT_TYPE_UNDEFINED)\r\n    {\r\n        setBrush(QBrush(KactusColors::INVALID_INTERFACE));\r\n    }\r\n    else if (endPointType == ENDPOINT_TYPE_API)\r\n    {\r\n        setBrush(QBrush(KactusColors::ENDPOINT_TYPE_API));\r\n    }\r\n    else if (endPointType == ENDPOINT_TYPE_COM)\r\n    {\r\n        // Generate a hexadecimal color based on the transfer type.\r\n        unsigned int color = qHash(getComInterface()->getTransferType()) & 0x00FFFFFF;\r\n\r\n        // Extract the color components and make small modifications.\r\n        unsigned char r = (color - 0xDEADC0DE) >> 16;\r\n        unsigned char g = 255 - ((color & 0x0000FF00) >> 8);\r\n        unsigned char b = (color & 0x000000FF);\r\n\r\n        setBrush(QBrush(QColor(r, g, b)));\r\n    }\r\n    else\r\n    {\r\n        Q_ASSERT(false);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SWConnectionEndpoint::isConnectionValid()\r\n//-----------------------------------------------------------------------------\r\nbool SWConnectionEndpoint::isConnectionValid(ConnectionEndpoint const* other) const\r\n{\r\n    if (!ConnectionEndpoint::isConnectionValid(other))\r\n    {\r\n        return false;\r\n    }\r\n\r\n    return commonValidation(other);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SWConnectionEndpoint::isExistingConnectionValid()\r\n//-----------------------------------------------------------------------------\r\nbool SWConnectionEndpoint::isExistingConnectionValid(ConnectionEndpoint const* other) const\r\n{\r\n    if (ConnectionEndpoint::isExistingConnectionValid(other) == false)\r\n    {\r\n        return false;\r\n    }\r\n\r\n    return commonValidation(other);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SWConnectionEndpoint::commonValidation()\r\n//-----------------------------------------------------------------------------\r\nbool SWConnectionEndpoint::commonValidation(ConnectionEndpoint const* other) const\r\n{\r\n\tbool fullyDefined = getType() != ENDPOINT_TYPE_UNDEFINED && other->getType() != ENDPOINT_TYPE_UNDEFINED;\r\n\r\n\t// Check if the types do not match.\r\n\tif (fullyDefined && getType() != other->getType())\r\n\t{\r\n\t\treturn false;\r\n\t}\r\n\r\n\treturn true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SWConnectionEndpoint::isCom()\r\n//-----------------------------------------------------------------------------\r\nbool SWConnectionEndpoint::isCom() const noexcept\r\n{\r\n    return type_ == ConnectionEndpoint::ENDPOINT_TYPE_COM;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SWConnectionEndpoint::isApi()\r\n//-----------------------------------------------------------------------------\r\nbool SWConnectionEndpoint::isApi() const noexcept\r\n{\r\n    return type_ == ConnectionEndpoint::ENDPOINT_TYPE_API;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SWConnectionEndpoint::getType()\r\n//-----------------------------------------------------------------------------\r\nConnectionEndpoint::EndpointType SWConnectionEndpoint::getType() const noexcept\r\n{\r\n    return type_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SWConnectionEndpoint::setType()\r\n//-----------------------------------------------------------------------------\r\nvoid SWConnectionEndpoint::setType(ConnectionEndpoint::EndpointType newType)\r\n{\r\n    type_ = newType;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SWConnectionEndpoint::initialize()\r\n//-----------------------------------------------------------------------------\r\nvoid SWConnectionEndpoint::initialize()\r\n{\r\n    QFont font = nameLabel_->font();\r\n    font.setPointSize(8);\r\n    nameLabel_->setFont(font);\r\n    nameLabel_->setFlag(ItemStacksBehindParent);\r\n    nameLabel_->setRotation(-rotation());\r\n\r\n    setFlag(ItemIsMovable);\r\n    setFlag(ItemIsSelectable);\r\n    setFlag(ItemSendsGeometryChanges);\r\n    setFlag(ItemSendsScenePositionChanges);\r\n\r\n    // Create the off-page connector.\r\n    offPageConnector_ = new OffPageConnectorItem(this);\r\n    offPageConnector_->setPos(0.0, -GridSize * 3);\r\n    offPageConnector_->setFlag(ItemStacksBehindParent);\r\n    offPageConnector_->setVisible(false);\r\n}\r\n"
  },
  {
    "path": "editors/SystemDesign/SWConnectionEndpoint.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: SWConnectionEndpoint.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Joni-Matti Maatta\r\n// Date: 2.5.2012\r\n//\r\n// Description:\r\n// Common interface for SW connection endpoints.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef SWCONNECTIONENDPOINT_H\r\n#define SWCONNECTIONENDPOINT_H\r\n\r\n#include <common/graphicsItems/ConnectionEndpoint.h>\r\n\r\n#include <editors/common/GraphicsItemLabel.h>\r\n\r\n#include <QVector2D>\r\n#include <QSharedPointer>\r\n\r\nclass VLNV;\r\nclass OffPageConnectorItem;\r\nclass Component;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Common interface for SW connection endpoints.\r\n//-----------------------------------------------------------------------------\r\nclass SWConnectionEndpoint : public ConnectionEndpoint\r\n{\r\n    Q_OBJECT\r\n\r\npublic:\r\n    /*!\r\n     *  Constructor.\r\n     *\r\n     *    @param [in] component   Component containing the end point.\r\n     *    @param [in] name        Name of the item.\r\n     *    @param [in] parent      The parent graphics item.\r\n     *    @param [in] dir         The initial direction for the endpoint.\r\n     */\r\n    SWConnectionEndpoint(QSharedPointer<Component> component, QString const& name = QString(),\r\n        QGraphicsItem* parent = 0, QVector2D const& dir = QVector2D(0.0f, -1.0f));\r\n\r\n    /*!\r\n     *  Destructor.\r\n     */\r\n    ~SWConnectionEndpoint() override = default;\r\n\r\n    // Disable copying.\r\n    SWConnectionEndpoint(SWConnectionEndpoint const& rhs) = delete;\r\n    SWConnectionEndpoint& operator=(SWConnectionEndpoint const& rhs) = delete;\r\n\r\n    /*!\r\n     *  Sets the COM/API type. The type of the VLNV determines the type of the endpoint.\r\n     *\r\n     *    @param [in] type The VLNV of the COM/API definition.\r\n     */\r\n    virtual void setTypeDefinition(VLNV const& type) = 0;\r\n\r\n    /*!\r\n     *  Returns the currently set COM/API definition.\r\n     */\r\n    virtual VLNV getTypeDefinition() const = 0;\r\n\r\n    /*!\r\n     *  Called when creating of a connection for this port has begun.\r\n     */\r\n    virtual void onBeginConnect() = 0;\r\n\r\n    /*!\r\n     *  Called when creating of a connection has ended.\r\n     */\r\n    virtual void onEndConnect() = 0;\r\n\r\n    /*!\r\n     *  Returns true if a connection is valid between the two endpoints.\r\n     *\r\n     *    @param [in] other The other endpoint.\r\n     *\r\n     *      @remarks Does not take existing connections into account but simply\r\n     *               validates whether a connection between the endpoints would be valid\r\n     *               in a general case.\r\n     */\r\n    virtual bool isConnectionValid(ConnectionEndpoint const* other) const;\r\n\r\n\t/*!\r\n\t *  Check if an existing connection to this connection end point is valid.\r\n\t *\r\n\t *    @param [in] other     The other connection end point.\r\n\t *\r\n\t *    @return True, if the existing connection is valid, false otherwise.\r\n\t */\r\n\tvirtual bool isExistingConnectionValid(ConnectionEndpoint const* other) const override final;\r\n\r\n    /*!\r\n     *  Updates the endpoint interface.\r\n     */\r\n    virtual void updateInterface();\r\n\r\n    /*!\r\n     *  Returns true if the endpoint is a COM interface endpoint.\r\n     */\r\n    bool isCom() const noexcept override;\r\n\r\n    /*!\r\n     *  Returns true if the endpoint is an API interface endpoint.\r\n     */\r\n    bool isApi() const noexcept override;\r\n\r\n    ConnectionEndpoint::EndpointType getType() const noexcept override;\r\n\r\n    virtual ConnectionEndpoint* getOffPageConnector() const;\r\n    \r\n    /*! \r\n     *  Returns the encompassing component.\r\n     */\r\n    virtual ComponentItem* encompassingComp() const;\r\n\r\n\t/*!\r\n     *  Returns a pointer to the top component that owns this interface.\r\n\t */\r\n\tvirtual QSharedPointer<Component> getOwnerComponent() const;\r\n\r\nprotected:\r\n\r\n    /*!\r\n     *  Set the type for the end point.\r\n     *\r\n     *    @param [in] newType     The new end point type.\r\n     */\r\n    void setType(ConnectionEndpoint::EndpointType newType);\r\n\r\n    /*!\r\n     *  Get the name label.\r\n     *\r\n     *    @return The name label.\r\n     */\r\n    GraphicsItemLabel* getNameLabel() const;\r\n\r\n    /*!\r\n     *  Makes basic initializations common to all constructors.\r\n     */\r\n    virtual void initialize();\r\n\r\nprivate:\r\n\r\n    /*!\r\n     *  Common validation for new and existing connections connected to this end point.\r\n     *\r\n     *    @param [in] other     The other connected end point.\r\n     *\r\n     *    @return True, if the common validation checks are valid, false otherwise.\r\n     */\r\n    bool commonValidation(ConnectionEndpoint const* other) const;\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! The type of the end point.\r\n    ConnectionEndpoint::EndpointType type_ = ConnectionEndpoint::ENDPOINT_TYPE_UNDEFINED;\r\n\r\n    //! The name label.\r\n    GraphicsItemLabel* nameLabel_ = new GraphicsItemLabel(QString(), this);\r\n\r\n    //! The off page connector item.\r\n    OffPageConnectorItem* offPageConnector_ = nullptr;\r\n\r\n    //! Component item containing this end point item.\r\n    ComponentItem* parentItem_= nullptr;\r\n\r\n    //! Component containing this item.\r\n    QSharedPointer<Component> containingComponent_= nullptr;\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n\r\n#endif // SWCONNECTIONENDPOINT_H\r\n"
  },
  {
    "path": "editors/SystemDesign/SWInterfaceItem.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: SWInterfaceItem.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Joni-Matti Maatta\r\n// Date: 2.5.2012\r\n//\r\n// Description:\r\n// Graphics item for visualizing API/COM interfaces as ports of a component.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"SWInterfaceItem.h\"\r\n\r\n#include <common/graphicsItems/GraphicsConnection.h>\r\n#include <common/graphicsItems/GraphicsColumnLayout.h>\r\n#include <common/graphicsItems/CommonGraphicsUndoCommands.h>\r\n#include <common/GenericEditProvider.h>\r\n\r\n#include <editors/common/diagramgrid.h>\r\n#include <editors/common/DesignDiagram.h>\r\n#include <editors/common/GraphicsItemLabel.h>\r\n#include <editors/HWDesign/OffPageConnectorItem.h>\r\n#include <editors/SystemDesign/UndoCommands/SWInterfaceMoveCommand.h>\r\n\r\n#include <IPXACTmodels/Component/Component.h>\r\n#include <IPXACTmodels/kactusExtensions/ApiInterface.h>\r\n#include <IPXACTmodels/kactusExtensions/ComInterface.h>\r\n#include <IPXACTmodels/kactusExtensions/InterfaceGraphicsData.h>\r\n\r\n#include <QFont>\r\n#include <QGraphicsDropShadowEffect>\r\n#include <QGraphicsScene>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SWInterfaceItem::SWInterfaceItem()\r\n//-----------------------------------------------------------------------------\r\nSWInterfaceItem::SWInterfaceItem(QSharedPointer<Component> component, QString const& name,\r\n                                 QSharedPointer<InterfaceGraphicsData> interfaceGraphics, QGraphicsItem *parent):\r\nSWConnectionEndpoint(component, name, parent, QVector2D(1.0f, 0.0f)),\r\ncomponent_(component),\r\ngraphicsData_(interfaceGraphics)\r\n{\r\n    setType(ENDPOINT_TYPE_UNDEFINED);\r\n    setTypeLocked(false);\r\n    SWInterfaceItem::initialize();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SWInterfaceItem::SWInterfaceItem()\r\n//-----------------------------------------------------------------------------\r\nSWInterfaceItem::SWInterfaceItem(QSharedPointer<Component> component, QSharedPointer<ApiInterface> apiIf,\r\n                                 QSharedPointer<InterfaceGraphicsData> interfaceGraphics, QGraphicsItem *parent):\r\nSWConnectionEndpoint(component, apiIf->name(), parent, QVector2D(1.0f, 0.0f)),\r\ncomponent_(component),\r\napiInterface_(apiIf),\r\ngraphicsData_(interfaceGraphics)\r\n{\r\n    Q_ASSERT(apiIf != 0);\r\n    setType(ENDPOINT_TYPE_API);\r\n    setTypeLocked(true);\r\n    SWInterfaceItem::initialize();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SWInterfaceItem::SWInterfaceItem()\r\n//-----------------------------------------------------------------------------\r\nSWInterfaceItem::SWInterfaceItem(QSharedPointer<Component> component, QSharedPointer<ComInterface> comIf,\r\n                                 QSharedPointer<InterfaceGraphicsData> interfaceGraphics, QGraphicsItem *parent):\r\nSWConnectionEndpoint(component, comIf->name(), parent, QVector2D(1.0f, 0.0f)),\r\ncomponent_(component),\r\ncomInterface_(comIf),\r\ngraphicsData_(interfaceGraphics)\r\n{\r\n    Q_ASSERT(comIf != 0);\r\n    setType(ENDPOINT_TYPE_COM);\r\n    setTypeLocked(true);\r\n    SWInterfaceItem::initialize();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SWInterfaceItem::name()\r\n//-----------------------------------------------------------------------------\r\nQString SWInterfaceItem::name() const\r\n{\r\n    if (isCom())\r\n    {\r\n        return comInterface_->name();\r\n    }\r\n    else if (isApi())\r\n    {\r\n        return apiInterface_->name();\r\n    }\r\n    else\r\n    {\r\n        return getNameLabel()->getText();\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: setName()\r\n//-----------------------------------------------------------------------------\r\nvoid SWInterfaceItem::setName(QString const& name)\r\n{\r\n    beginUpdateConnectionNames();\r\n\r\n    if (isCom())\r\n    {\r\n        comInterface_->setName(name);\r\n    }\r\n    else if (isApi())\r\n    {\r\n        apiInterface_->setName(name);\r\n    }\r\n    else\r\n    {\r\n        getNameLabel()->setText(name);\r\n    }\r\n\r\n    graphicsData_->setName(name);\r\n\r\n\tupdateInterface();\r\n    endUpdateConnectionNames();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SWInterfaceItem::getComInterface()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<ComInterface> SWInterfaceItem::getComInterface() const\r\n{\r\n    return comInterface_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SWInterfaceItem::getApiInterface()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<ApiInterface> SWInterfaceItem::getApiInterface() const\r\n{\r\n    return apiInterface_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SWInterfaceItem::updateInterface()\r\n//-----------------------------------------------------------------------------\r\nvoid SWInterfaceItem::updateInterface()\r\n{\r\n    SWConnectionEndpoint::updateInterface();\r\n\r\n    // Update the polygon shape based on the direction.\r\n    int squareSize = GridSize;\r\n    QPolygonF shape;\r\n\r\n    if (isApi())\r\n    {\r\n        if (apiInterface_->getDependencyDirection() == DEPENDENCY_PROVIDER)\r\n        {\r\n            /*  ||\r\n             *  \\/\r\n             */\r\n            shape << QPointF(-squareSize/2, squareSize / 2)\r\n                  << QPointF(-squareSize/2, -squareSize)\r\n                  << QPointF(squareSize/2, -squareSize)\r\n                  << QPointF(squareSize/2, squareSize / 2)\r\n                  << QPointF(0, squareSize);\r\n        }\r\n        else\r\n        {\r\n            /*  ||\r\n             *  /\\\r\n             */\r\n            shape << QPointF(-squareSize/2, squareSize)\r\n                  << QPointF(-squareSize/2, -squareSize)\r\n                  << QPointF(squareSize/2, -squareSize)\r\n                  << QPointF(squareSize/2, squareSize)\r\n                  << QPointF(0, squareSize / 2);\r\n        }\r\n    }\r\n    else if (isCom())\r\n    {\r\n        if (comInterface_->getDirection() == DirectionTypes::IN)\r\n        {\r\n            /*  /\\\r\n             *  ||\r\n             */\r\n            shape << QPointF(-squareSize/2, squareSize)\r\n                << QPointF(-squareSize/2, -squareSize / 2)\r\n                << QPointF(0, -squareSize)\r\n                << QPointF(squareSize/2, -squareSize / 2)\r\n                << QPointF(squareSize/2, squareSize);\r\n        }\r\n        else if (comInterface_->getDirection() == DirectionTypes::OUT)\r\n        {\r\n            /*  ||\r\n             *  \\/\r\n             */\r\n            shape << QPointF(-squareSize/2, squareSize / 2)\r\n                << QPointF(-squareSize/2, -squareSize)\r\n                << QPointF(squareSize/2, -squareSize)\r\n                << QPointF(squareSize/2, squareSize / 2)\r\n                << QPointF(0, squareSize);\r\n        }\r\n        else\r\n        {\r\n            /*  /\\\r\n             *  ||\r\n             *  \\/\r\n             */\r\n            shape << QPointF(-squareSize/2, squareSize / 2)\r\n                << QPointF(-squareSize/2, -squareSize / 2)\r\n                << QPointF(0, -squareSize)\r\n                << QPointF(squareSize/2, -squareSize / 2)\r\n                << QPointF(squareSize/2, squareSize / 2)\r\n                << QPointF(0, squareSize);\r\n        }\r\n    }\r\n    else\r\n    {\r\n        /*  /\\\r\n         *  ||\r\n         *  \\/\r\n         */\r\n        shape << QPointF(-squareSize/2, squareSize / 2)\r\n            << QPointF(-squareSize/2, -squareSize / 2)\r\n            << QPointF(0, -squareSize)\r\n            << QPointF(squareSize/2, -squareSize / 2)\r\n            << QPointF(squareSize/2, squareSize / 2)\r\n            << QPointF(0, squareSize);\r\n    }\r\n\r\n    setPolygon(shape);\r\n\r\n    // Update the name label.\r\n    getNameLabel()->updateLabelGeometry();\r\n\r\n\tsetLabelPosition();\r\n\r\n    getOffPageConnector()->updateInterface();\r\n    emit contentChanged();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SWInterfaceItem::isHierachical()\r\n//-----------------------------------------------------------------------------\r\nbool SWInterfaceItem::isHierarchical() const noexcept\r\n{\r\n    return true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SWInterfaceItem::onConnect()\r\n//-----------------------------------------------------------------------------\r\nbool SWInterfaceItem::onConnect(ConnectionEndpoint const* other)\r\n{\r\n    // If the port is undefined, try to copy the configuration from the other end point.\r\n    if (!isInvalid() && getType() == ENDPOINT_TYPE_UNDEFINED)\r\n    {\r\n        if (other->getType() == ENDPOINT_TYPE_API)\r\n        {\r\n            // Determine the name for the interface.\r\n            QString name = other->getApiInterface()->name();\r\n            unsigned int index = 0;\r\n\r\n            while (component_->getApiInterface(name) != 0)\r\n            {\r\n                ++index;\r\n                name = other->getApiInterface()->name() + \"_\" + QString::number(index);\r\n            }\r\n\r\n            apiInterface_ = QSharedPointer<ApiInterface>(new ApiInterface());\r\n            apiInterface_->setName(SWInterfaceItem::name());\r\n            apiInterface_->setApiType(other->getApiInterface()->getApiType());\r\n            apiInterface_->setDependencyDirection(other->getApiInterface()->getDependencyDirection());\r\n            \r\n            QList<QSharedPointer<ApiInterface> > componentApis = getOwnerComponent()->getApiInterfaces();\r\n            componentApis.append(apiInterface_);\r\n            getOwnerComponent()->setApiInterfaces(componentApis);\r\n        }\r\n        else if (other->getType() == ENDPOINT_TYPE_COM)\r\n        {\r\n            // Determine the name for the interface.\r\n            QString name = other->getComInterface()->name();\r\n            unsigned int index = 0;\r\n\r\n            while (component_->getComInterface(name) != 0)\r\n            {\r\n                ++index;\r\n                name = other->getApiInterface()->name() + \"_\" + QString::number(index);\r\n            }\r\n\r\n            comInterface_ = QSharedPointer<ComInterface>(new ComInterface());\r\n            comInterface_->setName(SWInterfaceItem::name());\r\n            comInterface_->setComType(other->getComInterface()->getComType());\r\n            comInterface_->setTransferType(other->getComInterface()->getTransferType());\r\n            comInterface_->setDirection(other->getComInterface()->getDirection());\r\n\r\n            QList<QSharedPointer<ComInterface> > componentComs = getOwnerComponent()->getComInterfaces();\r\n            componentComs.append(comInterface_);\r\n            getOwnerComponent()->setComInterfaces(componentComs);\r\n        }\r\n\r\n        setType(other->getType());\r\n        updateInterface();\r\n    }\r\n\r\n    return true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SWInterfaceItem::onDisconnect()\r\n//-----------------------------------------------------------------------------\r\nvoid SWInterfaceItem::onDisconnect()\r\n{\r\n    // Undefine the interface if it not typed.\r\n    if (!isTypeLocked() && !isConnected())\r\n    {\r\n        setTypeDefinition(VLNV());\r\n        updateInterface();\r\n    }\r\n\r\n    if (getType() == ConnectionEndpoint::ENDPOINT_TYPE_UNDEFINED)\r\n    {\r\n        if (apiInterface_)\r\n        {\r\n            QList<QSharedPointer<ApiInterface> > componentApis = getOwnerComponent()->getApiInterfaces();\r\n            componentApis.removeAll(apiInterface_);\r\n            getOwnerComponent()->setApiInterfaces(componentApis);\r\n        }\r\n        else if (comInterface_)\r\n        {\r\n            QList<QSharedPointer<ComInterface> > componentComs = getOwnerComponent()->getComInterfaces();\r\n            componentComs.removeAll(comInterface_);\r\n            getOwnerComponent()->setComInterfaces(componentComs);\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SWInterfaceItem::isConnectionValid()\r\n//-----------------------------------------------------------------------------\r\nbool SWInterfaceItem::isConnectionValid(ConnectionEndpoint const* other) const\r\n{\r\n    if (!SWConnectionEndpoint::isConnectionValid(other))\r\n    {\r\n        return false;\r\n    }\r\n\r\n    // Check compatibility of the interfaces based on the connection type.\r\n    bool fullyDefined = getType() != ENDPOINT_TYPE_UNDEFINED && other->getType() != ENDPOINT_TYPE_UNDEFINED;\r\n\r\n    if (fullyDefined)\r\n    {\r\n        if (getType() == ENDPOINT_TYPE_API)\r\n        {\r\n            QSharedPointer<ApiInterface> apiIf1 = getApiInterface();\r\n            QSharedPointer<ApiInterface> apiIf2 = other->getApiInterface();\r\n\r\n            // Check if the API types are not compatible.\r\n            if (!apiIf1->getApiType().isEmpty() && !apiIf2->getApiType().isEmpty() &&\r\n                apiIf1->getApiType() != apiIf2->getApiType())\r\n            {\r\n                return false;\r\n            }\r\n\r\n            return (apiIf1->getDependencyDirection() == apiIf2->getDependencyDirection());\r\n        }\r\n        else if (getType() == ENDPOINT_TYPE_COM)\r\n        {\r\n            QSharedPointer<ComInterface> comIf1 = getComInterface();\r\n            QSharedPointer<ComInterface> comIf2 = other->getComInterface();\r\n\r\n            // Check if the COM types are not compatible.\r\n            if (!comIf1->getComType().isEmpty() && !comIf2->getComType().isEmpty() &&\r\n                comIf1->getComType() != comIf2->getComType())\r\n            {\r\n                return false;\r\n            }\r\n\r\n            // Check if the data types are not compatible.\r\n            if (!comIf1->getTransferType().isEmpty() && !comIf2->getTransferType().isEmpty() &&\r\n                comIf1->getTransferType() != comIf2->getTransferType())\r\n            {\r\n                return false;\r\n            }\r\n\r\n            return (comIf1->getDirection() == comIf2->getDirection());\r\n        }\r\n        else\r\n        {\r\n            Q_ASSERT(false);\r\n            return false;\r\n        }\r\n    }\r\n\r\n    return true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SWInterfaceItem::getInterfaceGraphicsData()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<InterfaceGraphicsData> SWInterfaceItem::getInterfaceGraphicsData() const\r\n{\r\n    return graphicsData_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SWInterfaceItem::itemChange()\r\n//-----------------------------------------------------------------------------\r\nQVariant SWInterfaceItem::itemChange(GraphicsItemChange change, QVariant const& value)\r\n{\r\n    if (change == ItemPositionChange)\r\n    {\r\n        return snapPointToGrid(value.toPointF());\r\n    }\r\n    else if (change == ItemRotationHasChanged)\r\n    {\r\n        getNameLabel()->setRotation(-rotation());\r\n\r\n        graphicsData_->setDirection(getDirection());\r\n    }\r\n    else if (change == ItemScenePositionHasChanged)\r\n    {\r\n        graphicsData_->setPosition(value.toPointF());\r\n\r\n        updateConnectionPositions();\r\n    }\r\n\r\n    return QGraphicsItem::itemChange(change, value);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SWInterfaceItem::isDirectionFixed()\r\n//-----------------------------------------------------------------------------\r\nbool SWInterfaceItem::isDirectionFixed() const noexcept\r\n{\r\n    return false;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SWInterfaceItem::mouseMoveEvent()\r\n//-----------------------------------------------------------------------------\r\nvoid SWInterfaceItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event)\r\n{\r\n    // Discard mouse move if the System is protected.\r\n    if (static_cast<DesignDiagram*>(scene())->isProtected())\r\n    {\r\n        return;\r\n    }\r\n\r\n    SWConnectionEndpoint::mouseMoveEvent(event);\r\n\r\n    setPos(parentItem()->mapFromScene(oldStack_->mapStackToScene(pos())));\r\n\r\n    auto stack = dynamic_cast<IGraphicsItemStack*>(parentItem());\r\n    Q_ASSERT(stack != nullptr);\r\n    stack->onMoveItem(this);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SWInterfaceItem::mousePressEvent()\r\n//-----------------------------------------------------------------------------\r\nvoid SWInterfaceItem::mousePressEvent(QGraphicsSceneMouseEvent *event)\r\n{\r\n    SWConnectionEndpoint::mousePressEvent(event);    \r\n\r\n    oldPos_ = scenePos();\r\n    oldStack_ = dynamic_cast<IGraphicsItemStack*>(parentItem());\r\n    Q_ASSERT(oldStack_ != nullptr);\r\n\r\n    for (QGraphicsItem* item : scene()->items()) //column->childItems())\r\n    {\r\n        if (item->type() == SWInterfaceItem::Type)\r\n        {\r\n            auto interface = static_cast<SWInterfaceItem*>(item);\r\n            oldInterfacePositions_.insert(interface, interface->scenePos());\r\n        }\r\n    }\r\n\r\n    // Begin the position update for all connections.\r\n    beginUpdateConnectionPositions();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SWInterfaceItem::mouseReleaseEvent()\r\n//-----------------------------------------------------------------------------\r\nvoid SWInterfaceItem::mouseReleaseEvent(QGraphicsSceneMouseEvent* event)\r\n{\r\n    SWConnectionEndpoint::mouseReleaseEvent(event);\r\n\r\n    auto diagram = dynamic_cast<DesignDiagram*>(scene());\r\n    if (diagram && oldStack_ != nullptr)\r\n    {\r\n        IGraphicsItemStack* stack = dynamic_cast<IGraphicsItemStack*>(parentItem());\r\n        Q_ASSERT(stack != 0);\r\n        stack->onReleaseItem(this);\r\n\r\n        QSharedPointer<QUndoCommand> cmd;\r\n\r\n        // Check if the interface position was really changed.\r\n        if (oldPos_ != scenePos())\r\n        {\r\n            cmd = QSharedPointer<QUndoCommand>(new SWInterfaceMoveCommand(this, oldPos_, oldStack_, diagram));\r\n        }\r\n        else\r\n        {\r\n            cmd = QSharedPointer<QUndoCommand>(new QUndoCommand());\r\n        }\r\n\r\n        // Determine if the other interfaces changed their position and create undo commands for them.\r\n        QMap<SWInterfaceItem*, QPointF>::iterator cur = oldInterfacePositions_.begin();\r\n\r\n        while (cur != oldInterfacePositions_.end())\r\n        {\r\n            if (cur.key()->scenePos() != cur.value() && cur.key() != this)\r\n            {\r\n                new SWInterfaceMoveCommand(cur.key(), cur.value(),\r\n                    dynamic_cast<IGraphicsItemStack*>(cur.key()->parentItem()), diagram, cmd.data());\r\n            }\r\n\r\n            ++cur;\r\n        }\r\n\r\n        oldInterfacePositions_.clear();\r\n\r\n        endUpdateConnectionPositions(cmd.data());\r\n\r\n        // Add the undo command to the edit stack only if it has changes.\r\n        if (cmd->childCount() > 0 || oldPos_ != scenePos())\r\n        {\r\n            diagram->getEditProvider()->addCommand(cmd);\r\n            cmd->redo();\r\n        }\r\n\r\n        oldStack_ = 0;\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SWInterfaceItem::description()\r\n//-----------------------------------------------------------------------------\r\nQString SWInterfaceItem::description() const\r\n{\r\n\tif (isCom())\r\n    {\r\n\t    return comInterface_->description();\r\n    }\r\n    else if (isApi())\r\n    {\r\n        return apiInterface_->description();\r\n    }\r\n    else\r\n    {\r\n        return QString();\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SWInterfaceItem::setDescription()\r\n//-----------------------------------------------------------------------------\r\nvoid SWInterfaceItem::setDescription(QString const& description)\r\n{\r\n\tif (isCom())\r\n    {\r\n\t    comInterface_->setDescription(description);\r\n    }\r\n    else if (isApi())\r\n    {\r\n        apiInterface_->setDescription(description);\r\n    }\r\n\r\n\temit contentChanged();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SWInterfaceItem::initialize()\r\n//-----------------------------------------------------------------------------\r\nvoid SWInterfaceItem::initialize()\r\n{\r\n    SWConnectionEndpoint::initialize();\r\n\r\n    graphicsData_->setName(name());\r\n\r\n    if (graphicsData_->hasPosition())\r\n    {\r\n        setPos(graphicsData_->getPosition());\r\n    }\r\n    if (graphicsData_->hasDirection())\r\n    {\r\n        setDirection(graphicsData_->getDirection());\r\n    }\r\n    else\r\n    {\r\n        graphicsData_->setDirection(getDirection());\r\n    }\r\n\r\n    updateInterface();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SWInterfaceItem::onBeginConnect()\r\n//-----------------------------------------------------------------------------\r\nvoid SWInterfaceItem::onBeginConnect()\r\n{\r\n    //! Intentionally empty.\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SWInterfaceItem::onEndConnect()\r\n//-----------------------------------------------------------------------------\r\nvoid SWInterfaceItem::onEndConnect()\r\n{\r\n    //! Intentionally empty.\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SWInterfaceItem::setTypeDefinition()\r\n//-----------------------------------------------------------------------------\r\nvoid SWInterfaceItem::setTypeDefinition(VLNV const& type)\r\n{\r\n    // Disconnect existing connections before setting the type.\r\n    for (GraphicsConnection* conn : getConnections())\r\n    {\r\n        if (conn->endpoint1() != this)\r\n        {\r\n            conn->endpoint1()->removeConnection(conn);\r\n            conn->endpoint1()->onDisconnect();\r\n            conn->endpoint1()->addConnection(conn);\r\n        }\r\n        else\r\n        {\r\n            conn->endpoint2()->removeConnection(conn);\r\n            conn->endpoint2()->onDisconnect();\r\n            conn->endpoint2()->addConnection(conn);\r\n        }\r\n    }\r\n\r\n    // Check if the type is valid.\r\n    if (type.isValid())\r\n    {\r\n        if (type.getType() == VLNV::APIDEFINITION)\r\n        {\r\n            apiInterface_ = QSharedPointer<ApiInterface>(new ApiInterface());\r\n            apiInterface_->setName(getNameLabel()->getText());\r\n            apiInterface_->setApiType(type);\r\n            getOwnerComponent()->getVendorExtensions()->append(apiInterface_);\r\n\r\n            setType(ENDPOINT_TYPE_API);\r\n            setTypeLocked(true);\r\n        }\r\n        else if (type.getType() == VLNV::COMDEFINITION)\r\n        {\r\n            comInterface_ = QSharedPointer<ComInterface>(new ComInterface());\r\n            comInterface_->setName(getNameLabel()->getText());\r\n            comInterface_->setComType(type);\r\n            getOwnerComponent()->getVendorExtensions()->append(comInterface_);\r\n\r\n            setType(ENDPOINT_TYPE_COM);\r\n            setTypeLocked(true);\r\n        }\r\n    }\r\n    else\r\n    {\r\n        if (apiInterface_ != 0)\r\n        {\r\n            getOwnerComponent()->getVendorExtensions()->removeOne(apiInterface_);\r\n            apiInterface_.clear();\r\n        }\r\n\r\n        if (comInterface_ != 0)\r\n        {\r\n            getOwnerComponent()->getVendorExtensions()->removeOne(comInterface_);\r\n            comInterface_.clear();\r\n        }\r\n\r\n        setType(ENDPOINT_TYPE_UNDEFINED);\r\n        setTypeLocked(false);\r\n    }\r\n\r\n    updateInterface();\r\n\r\n    if (getType() != ENDPOINT_TYPE_UNDEFINED)\r\n    {\r\n        // Undefined endpoints of the connections can now be defined.\r\n        for (GraphicsConnection* conn : getConnections())\r\n        {\r\n            if (conn->endpoint1() != this)\r\n            {\r\n                conn->endpoint1()->onConnect(this);\r\n                conn->endpoint2()->onConnect(conn->endpoint1());\r\n            }\r\n            else\r\n            {\r\n                conn->endpoint2()->onConnect(this);\r\n                conn->endpoint1()->onConnect(conn->endpoint2());\r\n            }\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SWConnectionEndpoint::getTypeDefinition()\r\n//-----------------------------------------------------------------------------\r\nVLNV SWInterfaceItem::getTypeDefinition() const\r\n{\r\n    if (isCom())\r\n    {\r\n        return comInterface_->getComType();\r\n    }\r\n    else if (isApi())\r\n    {\r\n        return apiInterface_->getApiType();\r\n    }\r\n    else\r\n    {\r\n        return VLNV();\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: setDirection()\r\n//-----------------------------------------------------------------------------\r\nvoid SWInterfaceItem::setDirection(QVector2D const& dir)\r\n{\r\n    SWConnectionEndpoint::setDirection(dir);\r\n\r\n    graphicsData_->setDirection(dir);\r\n\r\n\tsetLabelPosition();\t\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SWInterfaceItem::isExclusive()\r\n//-----------------------------------------------------------------------------\r\nbool SWInterfaceItem::isExclusive() const\r\n{\r\n    if (getType() == ENDPOINT_TYPE_COM)\r\n    {\r\n        // All COM interfaces are exclusive.\r\n        return true;\r\n    }\r\n    else if (getType() == ENDPOINT_TYPE_API)\r\n    {\r\n        // Provider is exclusive.\r\n        return (getApiInterface()->getDependencyDirection() == DEPENDENCY_PROVIDER);\r\n    }\r\n\r\n    return false;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SWInterfaceItem::define()\r\n//-----------------------------------------------------------------------------\r\nvoid SWInterfaceItem::define(QSharedPointer<ApiInterface> apiIf)\r\n{\r\n    apiInterface_ = apiIf;\r\n    getOwnerComponent()->getVendorExtensions()->append(apiInterface_);\r\n\r\n    setType(ENDPOINT_TYPE_API);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SWInterfaceItem::define()\r\n//-----------------------------------------------------------------------------\r\nvoid SWInterfaceItem::define(QSharedPointer<ComInterface> comIf)\r\n{\r\n    comInterface_ = comIf;\r\n    getOwnerComponent()->getVendorExtensions()->append(comInterface_);\r\n\r\n    setType(ENDPOINT_TYPE_COM);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SWInterfaceItem::undefine()\r\n//-----------------------------------------------------------------------------\r\nvoid SWInterfaceItem::undefine()\r\n{\r\n    if (apiInterface_ != nullptr)\r\n    {\r\n        getOwnerComponent()->getVendorExtensions()->removeOne(apiInterface_);\r\n        apiInterface_.clear();\r\n    }\r\n\r\n    if (comInterface_ != nullptr)\r\n    {\r\n        getOwnerComponent()->getVendorExtensions()->removeOne(comInterface_);\r\n        comInterface_.clear();\r\n    }\r\n\r\n    setType(ENDPOINT_TYPE_UNDEFINED);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SWInterfaceItem::setLabelPosition()\r\n//-----------------------------------------------------------------------------\r\nvoid SWInterfaceItem::setLabelPosition()\r\n{\r\n    qreal nameWidth = getNameLabel()->boundingRect().width();\r\n    qreal nameHeight = getNameLabel()->boundingRect().height();\r\n\r\n\t// Check if the port is directed to the left.\r\n\tif (getDirection().x() < 0)\r\n\t{\r\n        getNameLabel()->setPos(-nameHeight / 2 + 2, GridSize * 3.0 / 4.0 - nameWidth / 2.0);\r\n\t}\r\n\t// Otherwise the port is directed to the right.\r\n\telse\r\n\t{\r\n        getNameLabel()->setPos(nameHeight / 2 - 2, GridSize * 3.0 / 4.0 + nameWidth / 2.0);\r\n\t}\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SWInterfaceItem::isCom()\r\n//-----------------------------------------------------------------------------\r\nbool SWInterfaceItem::isCom() const noexcept\r\n{\r\n    return comInterface_ != nullptr;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SWInterfaceItem::isApi()\r\n//-----------------------------------------------------------------------------\r\nbool SWInterfaceItem::isApi() const noexcept\r\n{\r\n    return apiInterface_ != nullptr;\r\n}\r\n"
  },
  {
    "path": "editors/SystemDesign/SWInterfaceItem.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: SWInterfaceItem.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Joni-Matti Maatta\r\n// Date: 24.5.2012\r\n//\r\n// Description:\r\n// Graphics item for visualizing API/COM interfaces as ports of a component.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef SWINTERFACEITEM_H\r\n#define SWINTERFACEITEM_H\r\n\r\n#include \"SWConnectionEndpoint.h\"\r\n\r\n#include <common/graphicsItems/GraphicsItemTypes.h>\r\n\r\n#include <QSharedPointer>\r\n#include <QVector2D>\r\n\r\nclass IGraphicsItemStack;\r\nclass InterfaceGraphicsData;\r\nclass Design;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Graphics item for visualizing API/COM interfaces for the top-level\r\n//! component.\r\n//-----------------------------------------------------------------------------\r\nclass SWInterfaceItem : public SWConnectionEndpoint\r\n{\r\n    Q_OBJECT\r\n\r\npublic:\r\n    enum { Type = GFX_TYPE_SW_INTERFACE_ITEM };\r\n\r\n    /*!\r\n     *  Constructor which creates a graphics item for an undefined interface.\r\n     *\r\n     *    @param [in] component           The selected component.\r\n     *    @param [in] name                The name of the item.\r\n     *    @param [in] interfaceGraphics   Container for the interface graphics data.\r\n     *    @param [in] parent              Owner of this item.\r\n     */\r\n    SWInterfaceItem(QSharedPointer<Component> component, QString const& name,\r\n        QSharedPointer<InterfaceGraphicsData> interfaceGraphics, QGraphicsItem *parent);\r\n\r\n    /*!\r\n     *  Constructor which creates a graphics item for an API interface.\r\n     *\r\n     *    @param [in] component           The selected component.\r\n     *    @param [in] apiIf               The API interface.\r\n     *    @param [in] interfaceGraphics   Container for the interface graphics data.\r\n     *    @param [in] parent              Owner of this item.\r\n     */\r\n    SWInterfaceItem(QSharedPointer<Component> component, QSharedPointer<ApiInterface> apiIf,\r\n        QSharedPointer<InterfaceGraphicsData> interfaceGraphics, QGraphicsItem *parent = 0);\r\n\r\n    /*!\r\n     *  Constructor which creates a graphics item for a COM interface.\r\n     *\r\n     *    @param [in] component           The selected component.\r\n     *    @param [in] comIf               The COM interface.\r\n     *    @param [in] interfaceGraphics   Container for the interface graphics data.\r\n     *    @param [in] parent              Owner of this item.\r\n     */\r\n    SWInterfaceItem(QSharedPointer<Component> component, QSharedPointer<ComInterface> comIf,\r\n        QSharedPointer<InterfaceGraphicsData> interfaceGraphics, QGraphicsItem *parent = 0);\r\n    \r\n    /*!\r\n     *  Destructor.\r\n     */\r\n\t~SWInterfaceItem() override = default;\r\n\r\n    /*!\r\n     *  Called when creating of a connection for this port has begun.\r\n     */\r\n    virtual void onBeginConnect();\r\n\r\n    /*!\r\n     *  Called when creating of a connection has ended.\r\n     */\r\n    virtual void onEndConnect();\r\n\r\n    /*!\r\n     *  Defines the interface as an API interface.\r\n     *\r\n     *    @param [in] apiIf The API interface to set.\r\n     */\r\n    void define(QSharedPointer<ApiInterface> apiIf);\r\n\r\n    /*!\r\n     *  Defines the interface as a COM interface.\r\n     */\r\n    void define(QSharedPointer<ComInterface> comIf);\r\n\r\n    /*!\r\n     *  Undefines the interface.\r\n     */\r\n    void undefine();\r\n\r\n    /*!\r\n     *  Sets the COM/API type. The type of the VLNV determines the type of the endpoint.\r\n     *\r\n     *    @param [in] type The VLNV of the COM/API definition.\r\n     */\r\n    virtual void setTypeDefinition(VLNV const& type);\r\n\r\n    /*!\r\n     *  Returns the currently set COM/API definition.\r\n     */\r\n    virtual VLNV getTypeDefinition() const;\r\n\r\n    /*!\r\n     *  Sets the draw direction of the endpoint.\r\n     *\r\n     *    @param [in] dir The draw direction to set.\r\n     *\r\n     *      @remarks The direction can be changed only if isDirectionFixed() returns false.\r\n     */\r\n    virtual void setDirection(QVector2D const& dir);\r\n\r\n    int type() const { return Type; }\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // SWConnectionEndpoint implementation.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    /*!\r\n     *  Updates the endpoint interface.\r\n     */\r\n    virtual void updateInterface();\r\n\r\n    /*!\r\n     *  Returns true if the draw direction is fixed and thus, cannot be changed.\r\n     */\r\n    bool isDirectionFixed() const noexcept override;\r\n\r\n    /*!\r\n     *  Returns the name of the interface.\r\n     */\r\n    virtual QString name() const;\r\n\r\n\t/*!\r\n     *  Sets the name for the interface.\r\n\t *\r\n\t *    @param [in] name The name to set for the interface.\r\n\t */\r\n\tvirtual void setName(QString const& name);\r\n\r\n\t/*!\r\n     *  Returns the description of the interface.\r\n\t */\r\n\tvirtual QString description() const;\r\n\r\n\t/*! \r\n     *  Sets the description for the interface.\r\n\t *\r\n\t *    @param [in] description The description to set.\r\n\t */\r\n\tvirtual void setDescription(QString const& description);\r\n\r\n    /*!\r\n     *  Called when a connection between this and another end point is done.\r\n     *\r\n     *    @param [in] other The other end point of the connection.\r\n     *\r\n     *    @return False if there was an error in the connection. Otherwise true.\r\n     */\r\n    virtual bool onConnect(ConnectionEndpoint const* other);\r\n\r\n    /*!\r\n     *  Called when a connection has been removed from between this and another end point.\r\n     */\r\n    virtual void onDisconnect() override final;\r\n\r\n    /*!\r\n     *  Returns true if a connection is valid between the two endpoints.\r\n     *\r\n     *    @param [in] other The other endpoint.\r\n     *\r\n     *      @remarks Does not take existing connections into account but simply\r\n     *               validates whether a connection between the endpoints would be valid\r\n     *               in a general case.\r\n     */\r\n    virtual bool isConnectionValid(ConnectionEndpoint const* other) const;\r\n\r\n    /*!\r\n     *  Returns true if the endpoint is exclusive, i.e. can only have one connection.\r\n     */\r\n    virtual bool isExclusive() const;\r\n\r\n    /*! \r\n     *  Returns the COM interface model of the endpoint.\r\n     *\r\n     *      @remarks The function returns a null pointer if the endpoint is not a COM interface.\r\n     *               Use isCom() function to check for COM interface support.\r\n     */\r\n    virtual QSharedPointer<ComInterface> getComInterface() const;\r\n\r\n    /*! \r\n     *  Returns the API interface model of the endpoint.\r\n     *\r\n     *      @remarks The function returns a null pointer if the endpoint is not a API interface.\r\n     *               Use isApi() function to check for API interface support.\r\n     */\r\n    virtual QSharedPointer<ApiInterface> getApiInterface() const;\r\n\r\n    /*!\r\n     *  Returns true if the port represents a hierarchical connection.\r\n     */\r\n    bool isHierarchical() const noexcept override;\r\n\r\n\t/*!\r\n\t *  Set the position of the name label.\r\n\t */\r\n\tvoid setLabelPosition();\r\n\r\n    /*!\r\n     *  Get the graphics data.\r\n     *\r\n     *    @return The container containing graphical data.\r\n     */\r\n    QSharedPointer<InterfaceGraphicsData> getInterfaceGraphicsData() const;\r\n\r\n    /*!\r\n     *  Returns true if the endpoint is a COM interface endpoint.\r\n     */\r\n    bool isCom() const noexcept override;\r\n\r\n    /*!\r\n     *  Returns true if the endpoint is an API interface endpoint.\r\n     */\r\n    bool isApi() const noexcept override;\r\n\r\nprotected:\r\n\r\n    /*!\r\n     *  Handles item changes.\r\n     *\r\n     *    @param [in] change  The change.\r\n     *    @param [in] value   Value for change.\r\n     *\r\n     *    @return The item change.\r\n     */\r\n    virtual QVariant itemChange(GraphicsItemChange change, QVariant const& value);\r\n\r\n    /*!\r\n     *  Handles mouse press events.\r\n     *\r\n     *    @param [in] event   The mouse press event.\r\n     */\r\n    virtual void mousePressEvent(QGraphicsSceneMouseEvent *event);\r\n\r\n    /*!\r\n     *  Handles mouse move events.\r\n     *\r\n     *    @param [in] event   The mouse move event.\r\n     */\r\n    virtual void mouseMoveEvent(QGraphicsSceneMouseEvent *event);\r\n\r\n    /*!\r\n     *  Handles mouse release events.\r\n     *\r\n     *    @param [in] event   The mouse release event.\r\n     */\r\n    virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);\r\n    \r\n    /*!\r\n     *  Makes basic initializations common to all constructors.\r\n     */\r\n    virtual void initialize();\r\n\r\nprivate:\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! The top-level component.\r\n    QSharedPointer<Component> component_ = nullptr;\r\n\r\n    //! The COM interface, or null if not set.\r\n    QSharedPointer<ComInterface> comInterface_ = nullptr;\r\n\r\n    //! The API interface, or null if not set.\r\n    QSharedPointer<ApiInterface> apiInterface_ = nullptr;\r\n\r\n    //! The position of the port before mouse move.\r\n    QPointF oldPos_;\r\n\r\n    //! The old stack from where the mouse drag event began.\r\n    IGraphicsItemStack* oldStack_ = nullptr;\r\n\r\n    //! The old positions of the other interfaces before mouse move.\r\n    QMap<SWInterfaceItem*, QPointF> oldInterfacePositions_;\r\n\r\n    //! The container for the graphical data.\r\n    QSharedPointer<InterfaceGraphicsData> graphicsData_ = nullptr;\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n\r\n#endif // SWINTERFACEITEM_H\r\n"
  },
  {
    "path": "editors/SystemDesign/SWPortItem.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: SWPortItem.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Joni-Matti Maatta\r\n// Date: 2.5.2012\r\n//\r\n// Description:\r\n// Graphics item for visualizing API/COM interfaces as ports of a component.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"SWPortItem.h\"\r\n\r\n#include \"SystemComponentItem.h\"\r\n#include \"HWMappingItem.h\"\r\n\r\n#include <common/KactusColors.h>\r\n#include <common/graphicsItems/GraphicsConnection.h>\r\n#include <common/GenericEditProvider.h>\r\n\r\n#include <editors/common/diagramgrid.h>\r\n#include <editors/common/DesignDiagram.h>\r\n#include <editors/common/NamelabelWidth.h>\r\n#include <editors/common/GraphicsItemLabel.h>\r\n#include <editors/SystemDesign/UndoCommands/SystemMoveCommands.h>\r\n\r\n#include <IPXACTmodels/kactusExtensions/ApiInterface.h>\r\n#include <IPXACTmodels/kactusExtensions/ComInterface.h>\r\n#include <IPXACTmodels/Component/Component.h>\r\n\r\n#include <QFont>\r\n#include <QGraphicsDropShadowEffect>\r\n#include <QVector2D>\r\n#include <QGraphicsScene>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SWPortItem::SWPortItem()\r\n//-----------------------------------------------------------------------------\r\nSWPortItem::SWPortItem(QString const& name, QSharedPointer<Component> containingComponent, QGraphicsItem *parent):\r\nSWConnectionEndpoint(containingComponent, name, parent),\r\nstubLine_(0, 0, 0, -GridSize, this)\r\n{\r\n    setType(ENDPOINT_TYPE_UNDEFINED);\r\n    setTypeLocked(false);\r\n    SWPortItem::setTemporary(true);\r\n    SWPortItem::initialize();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SWPortItem::SWPortItem()\r\n//-----------------------------------------------------------------------------\r\nSWPortItem::SWPortItem(QSharedPointer<ApiInterface> apiIf, QSharedPointer<Component> containingComponent,\r\n    QGraphicsItem *parent):\r\nSWConnectionEndpoint(containingComponent, apiIf->name(), parent),\r\napiInterface_(apiIf),\r\nstubLine_(0, 0, 0, -GridSize, this)\r\n{\r\n    Q_ASSERT(apiIf != 0);\r\n    setType(ENDPOINT_TYPE_API);\r\n    setTypeLocked(true);\r\n    SWPortItem::initialize();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SWPortItem::SWPortItem()\r\n//-----------------------------------------------------------------------------\r\nSWPortItem::SWPortItem(QSharedPointer<ComInterface> comIf, QSharedPointer<Component> containingComponent,\r\n    QGraphicsItem *parent):\r\nSWConnectionEndpoint(containingComponent, comIf->name(), parent),\r\ncomInterface_(comIf),\r\nstubLine_(0, 0, 0, -GridSize, this)\r\n{\r\n    Q_ASSERT(comIf != 0);\r\n    setType(ENDPOINT_TYPE_COM);\r\n    setTypeLocked(true);\r\n    SWPortItem::initialize();\r\n}\r\n\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SWPortItem::name()\r\n//-----------------------------------------------------------------------------\r\nQString SWPortItem::name() const\r\n{\r\n    if (isCom())\r\n    {\r\n        return comInterface_->name();\r\n    }\r\n    else if (isApi())\r\n    {\r\n        return apiInterface_->name();\r\n    }\r\n    else\r\n    {\r\n        return getNameLabel()->getText();\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: setName()\r\n//-----------------------------------------------------------------------------\r\nvoid SWPortItem::setName(QString const& name)\r\n{\r\n    beginUpdateConnectionNames();\r\n\r\n\r\n    if (isCom())\r\n    {\r\n        comInterface_->setName(name);\r\n    }\r\n    else if (isApi())\r\n    {\r\n        apiInterface_->setName(name);\r\n    }\r\n    else\r\n    {\r\n        getNameLabel()->setText(name);\r\n    }\r\n\r\n\tupdateInterface();\r\n    endUpdateConnectionNames();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SWPortItem::getComInterface()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<ComInterface> SWPortItem::getComInterface() const\r\n{\r\n    return comInterface_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SWPortItem::getApiInterface()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<ApiInterface> SWPortItem::getApiInterface() const\r\n{\r\n    return apiInterface_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SWPortItem::updateInterface()\r\n//-----------------------------------------------------------------------------\r\nvoid SWPortItem::updateInterface()\r\n{\r\n    SWConnectionEndpoint::updateInterface();\r\n\r\n    if (isInvalid() || hasInvalidConnections())\r\n    {\r\n        stubLineDefaultPen_.setColor(Qt::red);\r\n    }\r\n    else\r\n    {\r\n        if (getType() == ENDPOINT_TYPE_COM)\r\n        {\r\n            stubLineDefaultPen_.setColor(KactusColors::COM_CONNECTION);\r\n        }\r\n        else\r\n        {\r\n            stubLineDefaultPen_.setColor(Qt::black);\r\n        }\r\n    }\r\n\r\n    stubLine_.setPen(stubLineDefaultPen_);\r\n\r\n    // Update the polygon shape based on the direction.\r\n    int squareSize = GridSize;\r\n    QPolygonF shape;\r\n\r\n    if (isApi())\r\n    {\r\n        if (apiInterface_->getDependencyDirection() == DEPENDENCY_PROVIDER)\r\n        {\r\n            /*  /\\\r\n             *  ||\r\n             */\r\n            shape << QPointF(-squareSize/2, squareSize/2)\r\n                  << QPointF(-squareSize/2, 0)\r\n                  << QPointF(0, -squareSize/2)\r\n                  << QPointF(squareSize/2, 0)\r\n                  << QPointF(squareSize/2, squareSize/2);\r\n        }\r\n        else\r\n        {\r\n            /*  \\/\r\n             *  ||\r\n             */\r\n            shape << QPointF(-squareSize/2, squareSize/2)\r\n                  << QPointF(-squareSize/2, -squareSize/2)\r\n                  << QPointF(0, 0)\r\n                  << QPointF(squareSize/2, -squareSize/2)\r\n                  << QPointF(squareSize/2, squareSize/2);\r\n        }\r\n    }\r\n    else if (isCom())\r\n    {\r\n        if (comInterface_->getDirection() == DirectionTypes::IN)\r\n        {\r\n            /*  ||\r\n             *  \\/\r\n             */\r\n            shape << QPointF(-squareSize/2, 0)\r\n                << QPointF(-squareSize/2, -squareSize/2)\r\n                << QPointF(squareSize/2, -squareSize/2)\r\n                << QPointF(squareSize/2, 0)\r\n                << QPointF(0, squareSize/2);\r\n        }\r\n        else if (comInterface_->getDirection() == DirectionTypes::OUT)\r\n        {\r\n            /*  /\\\r\n             *  ||\r\n             */\r\n            shape << QPointF(-squareSize/2, squareSize/2)\r\n                << QPointF(-squareSize/2, 0)\r\n                << QPointF(0, -squareSize/2)\r\n                << QPointF(squareSize/2, 0)\r\n                << QPointF(squareSize/2, squareSize/2);\r\n        }\r\n        else\r\n        {\r\n            /*  /\\\r\n             *  ||\r\n             *  \\/\r\n             */\r\n            shape << QPointF(-squareSize/2, squareSize/2)\r\n                << QPointF(-squareSize/2, 0)\r\n                << QPointF(0, -squareSize/2)\r\n                << QPointF(squareSize/2, 0)\r\n                << QPointF(squareSize/2, squareSize/2)\r\n                << QPointF(0, squareSize);\r\n        }\r\n    }\r\n    else\r\n    {\r\n        /*  /\\\r\n         *  ||\r\n         */\r\n        shape << QPointF(-squareSize/2, squareSize/2)\r\n              << QPointF(-squareSize/2, 0)\r\n              << QPointF(0, -squareSize/2)\r\n              << QPointF(squareSize/2, 0)\r\n              << QPointF(squareSize/2, squareSize/2);\r\n    }\r\n\r\n    setPolygon(shape);\r\n\r\n    // Update the name label.\r\n    getNameLabel()->updateLabelGeometry();\r\n\r\n\tsetLabelPosition();\r\n\r\n    getOffPageConnector()->updateInterface();\r\n    emit contentChanged();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SWPortItem::isHierachical()\r\n//-----------------------------------------------------------------------------\r\nbool SWPortItem::isHierarchical() const noexcept\r\n{\r\n    return false;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SWPortItem::onConnect()\r\n//-----------------------------------------------------------------------------\r\nbool SWPortItem::onConnect(ConnectionEndpoint const* other)\r\n{\r\n    // If the port is undefined, try to copy the configuration from the other end point.\r\n    if (!isInvalid() && getType() == ENDPOINT_TYPE_UNDEFINED)\r\n    {\r\n        if (other->getType() == ENDPOINT_TYPE_API)\r\n        {\r\n            apiInterface_ = QSharedPointer<ApiInterface>(new ApiInterface());\r\n            apiInterface_->setName(getNameLabel()->getText());\r\n            apiInterface_->setApiType(other->getApiInterface()->getApiType());\r\n            \r\n            if (other->isHierarchical())\r\n            {\r\n                apiInterface_->setDependencyDirection(other->getApiInterface()->getDependencyDirection());\r\n            }\r\n            else if (other->getApiInterface()->getDependencyDirection() == DEPENDENCY_PROVIDER)\r\n            {\r\n                apiInterface_->setDependencyDirection(DEPENDENCY_REQUESTER);\r\n            }\r\n            else\r\n            {\r\n                apiInterface_->setDependencyDirection(DEPENDENCY_PROVIDER);\r\n            }\r\n\r\n            if (!isInvalid())\r\n            {\r\n                getOwnerComponent()->getVendorExtensions()->append(apiInterface_);\r\n            }\r\n        }\r\n        else if (other->getType() == ENDPOINT_TYPE_COM)\r\n        {\r\n            comInterface_ = QSharedPointer<ComInterface>(new ComInterface());\r\n            comInterface_->setName(getNameLabel()->getText());\r\n            comInterface_->setComType(other->getComInterface()->getComType());\r\n            comInterface_->setTransferType(other->getComInterface()->getTransferType());\r\n\r\n            if (other->isHierarchical())\r\n            {\r\n                comInterface_->setDirection(other->getComInterface()->getDirection());\r\n            }\r\n            else\r\n            {\r\n                DirectionTypes::Direction direction = other->getComInterface()->getDirection();\r\n                if (direction == DirectionTypes::IN)\r\n                {\r\n                    comInterface_->setDirection(DirectionTypes::OUT);\r\n                }\r\n                else if (direction == DirectionTypes::OUT)\r\n                {\r\n                    comInterface_->setDirection(DirectionTypes::IN);\r\n                }\r\n                else if (direction == DirectionTypes::INOUT)\r\n                {\r\n                    comInterface_->setDirection(DirectionTypes::INOUT);\r\n                }\r\n                else\r\n                {\r\n                    Q_ASSERT(false);\r\n                }\r\n            }\r\n\r\n            if (!isInvalid())\r\n            {\r\n                getOwnerComponent()->getVendorExtensions()->append(comInterface_);\r\n            }\r\n        }\r\n\r\n        setType(other->getType());\r\n        updateInterface();\r\n    }\r\n\r\n    return true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SWPortItem::onDisconnect()\r\n//-----------------------------------------------------------------------------\r\nvoid SWPortItem::onDisconnect()\r\n{\r\n    // Undefine the interface if it is temporary.\r\n    if (!isTypeLocked() && !isConnected())\r\n    {\r\n        setTypeDefinition(VLNV());\r\n        updateInterface();\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SWPortItem::isConnectionValid()\r\n//-----------------------------------------------------------------------------\r\nbool SWPortItem::isConnectionValid(ConnectionEndpoint const* other) const\r\n{\r\n    if (!SWConnectionEndpoint::isConnectionValid(other))\r\n    {\r\n        return false;\r\n    }\r\n\r\n    // Disallow normal API connections across different HW.\r\n    if ((getType() == ENDPOINT_TYPE_API || other->getType() == ENDPOINT_TYPE_API) &&\r\n        !other->isHierarchical() &&\r\n        static_cast<SystemComponentItem*>(encompassingComp())->getLinkedHW() !=\r\n        static_cast<SystemComponentItem*>(other->encompassingComp())->getLinkedHW())\r\n    {\r\n        return false;\r\n    }\r\n\r\n    // Check compatibility of the interfaces based on the connection type.\r\n    bool fullyDefined = getType() != ENDPOINT_TYPE_UNDEFINED && other->getType() != ENDPOINT_TYPE_UNDEFINED;\r\n\r\n    if (fullyDefined)\r\n    {\r\n        if (getType() == ENDPOINT_TYPE_API)\r\n        {\r\n            QSharedPointer<ApiInterface> apiIf1 = getApiInterface();\r\n            QSharedPointer<ApiInterface> apiIf2 = other->getApiInterface();\r\n\r\n            // Check if the API types are not compatible.\r\n            if (!apiIf1->getApiType().isEmpty() && !apiIf2->getApiType().isEmpty() &&\r\n                apiIf1->getApiType() != apiIf2->getApiType())\r\n            {\r\n                return false;\r\n            }\r\n\r\n            // If the other one is a hierarchical, then the dependency directions must be the same.\r\n            // Otherwise they must be different (provider <-> requester).\r\n            return ((other->isHierarchical() && apiIf1->getDependencyDirection() == apiIf2->getDependencyDirection()) ||\r\n                    (!other->isHierarchical() && apiIf1->getDependencyDirection() != apiIf2->getDependencyDirection()));\r\n        }\r\n        else if (getType() == ENDPOINT_TYPE_COM)\r\n        {\r\n            QSharedPointer<ComInterface> comIf1 = getComInterface();\r\n            QSharedPointer<ComInterface> comIf2 = other->getComInterface();\r\n\r\n            // Check if the COM types are not compatible.\r\n            if (!comIf1->getComType().isEmpty() && !comIf2->getComType().isEmpty() &&\r\n                comIf1->getComType() != comIf2->getComType())\r\n            {\r\n                return false;\r\n            }\r\n\r\n            // Check if the data types are not compatible.\r\n            if (!comIf1->getTransferType().isEmpty() && !comIf2->getTransferType().isEmpty() &&\r\n                comIf1->getTransferType() != comIf2->getTransferType())\r\n            {\r\n                return false;\r\n            }\r\n\r\n            // If the other one is a hierarchical, then the direction must be the same.\r\n            // Otherwise they must be just compatible (in <-> out or any <-> inout).\r\n            return ((other->isHierarchical() && comIf1->getDirection() == comIf2->getDirection()) ||\r\n                    (!other->isHierarchical() && (comIf1->getDirection() == DirectionTypes::INOUT ||\r\n                                                  comIf2->getDirection() == DirectionTypes::INOUT ||\r\n                                                  comIf1->getDirection() != comIf2->getDirection())));\r\n        }\r\n        else\r\n        {\r\n            Q_ASSERT(false);\r\n            return false;\r\n        }\r\n    }\r\n\r\n    return true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: addConnection()\r\n//-----------------------------------------------------------------------------\r\nvoid SWPortItem::addConnection(GraphicsConnection* connection)\r\n{\r\n    SWConnectionEndpoint::addConnection(connection);\r\n    stubLine_.setVisible(true);\r\n    \r\n    if (connection->isInvalid())\r\n    {\r\n        stubLineDefaultPen_.setColor(Qt::red);\r\n        stubLine_.setPen(stubLineDefaultPen_);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: removeInterconnection()\r\n//-----------------------------------------------------------------------------\r\nvoid SWPortItem::removeConnection(GraphicsConnection* connection)\r\n{\r\n    SWConnectionEndpoint::removeConnection(connection);\r\n\r\n    if (connection->isInvalid())\r\n    {\r\n        // Check if there no other invalid connections.\r\n        if (!hasInvalidConnections())\r\n        {\r\n            if (getType() == ENDPOINT_TYPE_COM)\r\n            {\r\n                stubLineDefaultPen_.setColor(KactusColors::COM_CONNECTION);\r\n            }\r\n            else\r\n            {\r\n                stubLineDefaultPen_.setColor(Qt::black);\r\n            }\r\n\r\n            stubLine_.setPen(stubLineDefaultPen_);\r\n        }\r\n    }\r\n\r\n    if (getConnections().isEmpty())\r\n    {\r\n        stubLine_.setVisible(false);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SWPortItem::itemChange()\r\n//-----------------------------------------------------------------------------\r\nQVariant SWPortItem::itemChange(GraphicsItemChange change, QVariant const& value)\r\n{\r\n    if (change == ItemPositionChange)\r\n    {\r\n        if (!parentItem())\r\n        {\r\n            return snapPointToGrid(value.toPointF());\r\n        }\r\n\r\n        QPointF pos = value.toPointF();\r\n        QRectF parentRect = static_cast<SystemComponentItem*>(parentItem())->rect();\r\n\r\n        if (pos.x() < 0)\r\n        {\r\n            pos.setX(parentRect.left());\r\n        }\r\n        else\r\n        {\r\n            pos.setX(parentRect.right());\r\n        }\r\n\r\n        return snapPointToGrid(pos);\r\n    }\r\n    else if (change == ItemPositionHasChanged)\r\n    {\r\n        if (parentItem())\r\n        {\r\n            checkDirection();\r\n            setLabelPosition();\r\n        }\r\n    }\r\n    else if (change == ItemRotationHasChanged)\r\n    {\r\n        getNameLabel()->setRotation(-rotation());\r\n    }\r\n    else if (change == ItemScenePositionHasChanged)\r\n    {\r\n        // Check if the updates are not disabled.\r\n        if (!static_cast<SystemComponentItem*>(parentItem())->isConnectionUpdateDisabled())\r\n        {\r\n            // Update the connections.\r\n            updateConnectionPositions();\r\n        }\r\n\r\n        // Update the stub length if the parent's parent is a HW mapping item.\r\n        auto mappingItem = dynamic_cast<HWMappingItem*>(parentItem()->parentItem());\r\n\r\n        if (mappingItem != 0)\r\n        {\r\n            if (pos().x() < 0)\r\n            {\r\n                stubLine_.setLine(0, 0, 0, qMin(0.0, mappingItem->sceneBoundingRect().left() - scenePos().x()));\r\n            }\r\n            else\r\n            {\r\n                stubLine_.setLine(0, 0, 0, qMin(0.0, scenePos().x() - mappingItem->sceneBoundingRect().right()));\r\n            }\r\n        }\r\n        else\r\n        {\r\n            stubLine_.setLine(0, 0, 0, -GridSize);\r\n        }\r\n    }\r\n\r\n    return QGraphicsItem::itemChange(change, value);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SWPortItem::isDirectionFixed()\r\n//-----------------------------------------------------------------------------\r\nbool SWPortItem::isDirectionFixed() const noexcept\r\n{\r\n    return true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SWPortItem::mouseMoveEvent()\r\n//-----------------------------------------------------------------------------\r\nvoid SWPortItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event)\r\n{\r\n    // Discard mouse move if the diagram is protected.\r\n    auto diagram = dynamic_cast<DesignDiagram*>(scene());\r\n\r\n    if (diagram != nullptr && diagram->isProtected())\r\n    {\r\n        return;\r\n    }\r\n\r\n    SWConnectionEndpoint::mouseMoveEvent(event);\r\n    static_cast<SystemComponentItem*>(parentItem())->onMovePort(this);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SWPortItem::mousePressEvent()\r\n//-----------------------------------------------------------------------------\r\nvoid SWPortItem::mousePressEvent(QGraphicsSceneMouseEvent *event)\r\n{\r\n    SWConnectionEndpoint::mousePressEvent(event);    \r\n    oldPos_ = pos();\r\n\r\n    // Save old port positions for all ports in the parent component.\r\n    for (QGraphicsItem* item : parentItem()->childItems())\r\n    {\r\n        if (dynamic_cast<SWPortItem*>(item) != nullptr && item != this)\r\n        {\r\n            auto port = static_cast<SWPortItem*>(item);\r\n            oldPortPositions_.insert(port, port->pos());\r\n        }\r\n    }\r\n\r\n    beginUpdateConnectionPositions();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SWPortItem::mouseReleaseEvent()\r\n//-----------------------------------------------------------------------------\r\nvoid SWPortItem::mouseReleaseEvent(QGraphicsSceneMouseEvent* event)\r\n{\r\n    SWConnectionEndpoint::mouseReleaseEvent(event);\r\n\r\n    auto diagram = dynamic_cast<DesignDiagram*>(scene());\r\n\r\n    if (diagram == nullptr)\r\n    {\r\n        // Update the default position in case the graphics are located in other scene than the designer.\r\n        if (comInterface_ != 0)\r\n        {\r\n            comInterface_->setDefaultPos(pos());\r\n        }\r\n        else if (apiInterface_ != 0)\r\n        {\r\n            apiInterface_->setDefaultPos(pos());\r\n        }\r\n\r\n        if (oldPos_ != pos())\r\n        {\r\n            emit moved(this);\r\n        }\r\n\r\n        return;\r\n    }\r\n\r\n    QSharedPointer<QUndoCommand> cmd;\r\n\r\n    // Check if the port position was really changed.\r\n    if (oldPos_ != pos())\r\n    {\r\n        cmd = QSharedPointer<QUndoCommand>(new SWPortMoveCommand(this, oldPos_, diagram));\r\n    }\r\n    else\r\n    {\r\n        cmd = QSharedPointer<QUndoCommand>(new QUndoCommand());\r\n    }\r\n\r\n    // Determine if the other ports changed their position and create undo commands for them.\r\n    QMap<SWPortItem*, QPointF>::iterator cur = oldPortPositions_.begin();\r\n\r\n    while (cur != oldPortPositions_.end())\r\n    {\r\n        if (cur.key()->pos() != cur.value())\r\n        {\r\n            new SWPortMoveCommand(cur.key(), cur.value(), diagram, cmd.data());\r\n        }\r\n\r\n        ++cur;\r\n    }\r\n\r\n    oldPortPositions_.clear();\r\n    \r\n    // End the position update for all connections.\r\n    endUpdateConnectionPositions(cmd.data());\r\n\r\n    // Add the undo command to the edit stack only if it has changes.\r\n    if (cmd->childCount() > 0 || oldPos_ != pos())\r\n    {\r\n        diagram->getEditProvider()->addCommand(cmd);\r\n        cmd->redo();\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SWPortItem::description()\r\n//-----------------------------------------------------------------------------\r\nQString SWPortItem::description() const\r\n{\r\n\tif (isCom())\r\n    {\r\n\t    return comInterface_->description();\r\n    }\r\n    else if (isApi())\r\n    {\r\n        return apiInterface_->description();\r\n    }\r\n    else\r\n    {\r\n        return QString();\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SWPortItem::setDescription()\r\n//-----------------------------------------------------------------------------\r\nvoid SWPortItem::setDescription(QString const& description)\r\n{\r\n\tif (isCom())\r\n    {\r\n\t    comInterface_->setDescription(description);\r\n    }\r\n    else if (isApi())\r\n    {\r\n        apiInterface_->setDescription(description);\r\n    }\r\n\r\n\temit contentChanged();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SWPortItem::initialize()\r\n//-----------------------------------------------------------------------------\r\nvoid SWPortItem::initialize()\r\n{\r\n    stubLine_.setFlag(ItemStacksBehindParent);\r\n    stubLine_.setVisible(false);\r\n\r\n    stubLineDefaultPen_ = stubLine_.pen();\r\n    stubLineDefaultPen_.setWidth(3);\r\n    stubLine_.setPen(stubLineDefaultPen_);\r\n\r\n    SWConnectionEndpoint::initialize();\r\n\r\n    updateInterface();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SWPortItem::onBeginConnect()\r\n//-----------------------------------------------------------------------------\r\nvoid SWPortItem::onBeginConnect()\r\n{\r\n    stubLine_.setVisible(true);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SWPortItem::onEndConnect()\r\n//-----------------------------------------------------------------------------\r\nvoid SWPortItem::onEndConnect()\r\n{\r\n    if (!isConnected())\r\n    {\r\n        stubLine_.setVisible(false);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SWPortItem::setSelectionHighlight()\r\n//-----------------------------------------------------------------------------\r\nvoid SWPortItem::setSelectionHighlight(bool on)\r\n{\r\n    SWConnectionEndpoint::setSelectionHighlight(on);\r\n\r\n    QPen curPen = stubLine_.pen();\r\n\r\n    if (on)\r\n    {\r\n        curPen.setColor(KactusColors::DIAGRAM_SELECTION);\r\n    }\r\n    else\r\n    {\r\n        curPen = stubLineDefaultPen_;\r\n    }\r\n\r\n    stubLine_.setPen(curPen);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SWPortItem::setTypeDefinition()\r\n//-----------------------------------------------------------------------------\r\nvoid SWPortItem::setTypeDefinition(VLNV const& type)\r\n{\r\n    // Disconnect existing connections before setting the type.\r\n    for (GraphicsConnection* conn : getConnections())\r\n    {\r\n        if (conn->endpoint1() != this)\r\n        {\r\n            conn->endpoint1()->removeConnection(conn);\r\n            conn->endpoint1()->onDisconnect();\r\n            conn->endpoint1()->addConnection(conn);\r\n        }\r\n        else\r\n        {\r\n            conn->endpoint2()->removeConnection(conn);\r\n            conn->endpoint2()->onDisconnect();\r\n            conn->endpoint2()->addConnection(conn);\r\n        }\r\n    }\r\n\r\n    // Check if the type is valid.\r\n    if (type.isValid())\r\n    {\r\n        if (type.getType() == VLNV::APIDEFINITION)\r\n        {\r\n            apiInterface_ = QSharedPointer<ApiInterface>(new ApiInterface());\r\n            apiInterface_->setName(getNameLabel()->getText());\r\n            apiInterface_->setApiType(type);\r\n\r\n            getOwnerComponent()->getVendorExtensions()->append(apiInterface_);\r\n\r\n            setType(ENDPOINT_TYPE_API);\r\n            setTypeLocked(true);\r\n        }\r\n        else if (type.getType() == VLNV::COMDEFINITION)\r\n        {\r\n            comInterface_ = QSharedPointer<ComInterface>(new ComInterface());\r\n            comInterface_->setName(getNameLabel()->getText());\r\n            comInterface_->setComType(type);\r\n            getOwnerComponent()->getVendorExtensions()->append(comInterface_);\r\n\r\n            setType(ENDPOINT_TYPE_COM);\r\n            setTypeLocked(true);\r\n        }\r\n    }\r\n    else\r\n    {\r\n        if (apiInterface_ != 0)\r\n        {\r\n            if (!isInvalid())\r\n            {\r\n                getOwnerComponent()->getVendorExtensions()->removeOne(apiInterface_);\r\n            }\r\n\r\n            apiInterface_.clear();\r\n        }\r\n\r\n        if (comInterface_ != 0)\r\n        {\r\n            if (!isInvalid())\r\n            {\r\n                getOwnerComponent()->getVendorExtensions()->removeOne(comInterface_);\r\n            }\r\n\r\n            comInterface_.clear();\r\n        }\r\n\r\n        setType(ENDPOINT_TYPE_UNDEFINED);\r\n        setTypeLocked(false);\r\n    }\r\n\r\n    updateInterface();\r\n\r\n    if (getType() != ENDPOINT_TYPE_UNDEFINED)\r\n    {\r\n        // Undefined endpoints of the connections can now be defined.\r\n        for (GraphicsConnection* conn : getConnections())\r\n        {\r\n            if (conn->endpoint1() != this)\r\n            {\r\n                conn->endpoint1()->onConnect(this);\r\n                conn->endpoint2()->onConnect(conn->endpoint1());\r\n            }\r\n            else\r\n            {\r\n                conn->endpoint2()->onConnect(this);\r\n                conn->endpoint1()->onConnect(conn->endpoint2());\r\n            }\r\n        }\r\n    }\r\n\r\n    for (GraphicsConnection* conn : getConnections())\r\n    {\r\n        conn->validate();\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SWConnectionEndpoint::getTypeDefinition()\r\n//-----------------------------------------------------------------------------\r\nVLNV SWPortItem::getTypeDefinition() const\r\n{\r\n    if (isCom())\r\n    {\r\n        return comInterface_->getComType();\r\n    }\r\n    else if (isApi())\r\n    {\r\n        return apiInterface_->getApiType();\r\n    }\r\n    else\r\n    {\r\n        return VLNV();\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SWPortItem::isExclusive()\r\n//-----------------------------------------------------------------------------\r\nbool SWPortItem::isExclusive() const\r\n{\r\n    // COM interfaces are always exclusive.\r\n    return (getType() == ENDPOINT_TYPE_COM);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SWPortItem::hasInvalidConnections()\r\n//-----------------------------------------------------------------------------\r\nbool SWPortItem::hasInvalidConnections()\r\n{\r\n    // Check if there are no other invalid connections.\r\n    for (GraphicsConnection* otherConn : getConnections())\r\n    {\r\n        if (otherConn->isInvalid())\r\n        {\r\n            return true;\r\n        }\r\n    }\r\n\r\n    return false;\r\n}\r\n\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SWPortItem::setLabelPosition()\r\n//-----------------------------------------------------------------------------\r\nvoid SWPortItem::setLabelPosition()\r\n{\r\n    qreal nameWidth = getNameLabel()->boundingRect().width();\r\n    qreal nameHeight = getNameLabel()->boundingRect().height();\r\n\r\n\tif (pos().x() < 0)\r\n\t{\r\n        getNameLabel()->setPos(nameHeight/2, GridSize);\r\n\t}\r\n\t// Otherwise the port is directed to the right.\r\n\telse\r\n\t{\r\n        getNameLabel()->setPos(-nameHeight/2, GridSize + nameWidth);\r\n\t}\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SWPortItem::checkDirection()\r\n//-----------------------------------------------------------------------------\r\nvoid SWPortItem::checkDirection()\r\n{\r\n\tif (pos().x() < 0)\r\n\t{\r\n\t\tsetDirection(QVector2D(-1.0f, 0.0f));\r\n\t}\r\n\t// Otherwise the port is directed to the right.\r\n\telse\r\n\t{\r\n\t\tsetDirection(QVector2D(1.0f, 0.0f));\r\n\t}\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SWPortItem::getNameLength()\r\n//-----------------------------------------------------------------------------\r\nqreal SWPortItem::getNameLength()\r\n{\r\n    QFont font = getNameLabel()->font();\r\n\r\n\treturn NamelabelWidth::getTextLength(name(), font);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SWPortItem::shortenNameLabel()\r\n//-----------------------------------------------------------------------------\r\nvoid SWPortItem::shortenNameLabel( qreal width )\r\n{\r\n    QFont font = getNameLabel()->font();\r\n\tQString nameLabelText = NamelabelWidth::setNameLabel(name(), font, width);\r\n    getNameLabel()->setText(nameLabelText);\r\n\r\n\tsetLabelPosition();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SWPortItem::isCom()\r\n//-----------------------------------------------------------------------------\r\nbool SWPortItem::isCom() const noexcept\r\n{\r\n    return comInterface_ != nullptr;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SWPortItem::isApi()\r\n//-----------------------------------------------------------------------------\r\nbool SWPortItem::isApi() const noexcept\r\n{\r\n    return apiInterface_ != nullptr;\r\n}\r\n"
  },
  {
    "path": "editors/SystemDesign/SWPortItem.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: SWPortItem.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Joni-Matti Maatta\r\n// Date: 2.5.2012\r\n//\r\n// Description:\r\n// Graphics item for visualizing API/COM interfaces as ports of a component.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef SWPORTITEM_H\r\n#define SWPORTITEM_H\r\n\r\n#include \"SWConnectionEndpoint.h\"\r\n\r\n#include <common/graphicsItems/GraphicsItemTypes.h>\r\n\r\n#include <QSharedPointer>\r\n#include <QPen>\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Graphics item for visualizing API/COM interfaces as ports of a component.\r\n//-----------------------------------------------------------------------------\r\nclass SWPortItem : public SWConnectionEndpoint\r\n{\r\n    Q_OBJECT\r\n\r\npublic:\r\n    enum { Type = GFX_TYPE_SW_PORT_ITEM };\r\n\r\n    /*!\r\n     *  Constructor which creates a graphics item for an undefined interface.\r\n     *\r\n     *    @param [in] name                    Name of the item.\r\n     *    @param [in] containingComponent     Component containing the item.\r\n     *    @param [in] parent                  The parent item.\r\n     */\r\n    SWPortItem(QString const& name, QSharedPointer<Component> containingComponent, QGraphicsItem *parent);\r\n\r\n    /*!\r\n     *  Constructor which creates a graphics item for an API interface.\r\n     *\r\n     *    @param [in] apiIf                   The API interface.\r\n     *    @param [in] containingComponent     Component containing the item.\r\n     *    @param [in] parent                  The parent item.\r\n     */\r\n    SWPortItem(QSharedPointer<ApiInterface> apiIf,\r\n        QSharedPointer<Component> containingComponent = QSharedPointer<Component>(), QGraphicsItem *parent = 0);\r\n\r\n    /*!\r\n     *  Constructor which creates a graphics item for a COM interface.\r\n     *\r\n     *    @param [in] comIf                   The COM interface.\r\n     *    @param [in] containingComponent     Component containing the item.\r\n     *    @param [in] parent                  The parent item.\r\n     */\r\n    SWPortItem(QSharedPointer<ComInterface> comIf,\r\n        QSharedPointer<Component> containingComponent = QSharedPointer<Component>(), QGraphicsItem *parent = 0);\r\n    \r\n    /*!\r\n     *  Destructor.\r\n     */\r\n\t~SWPortItem() final = default;\r\n\r\n    /*!\r\n     *  Called when creating of a connection for this port has begun.\r\n     */\r\n    virtual void onBeginConnect();\r\n\r\n    /*!\r\n     *  Called when creating of a connection has ended.\r\n     */\r\n    virtual void onEndConnect();\r\n\r\n    /*!\r\n     *  Sets the selection highlight on/off.\r\n     *\r\n     *    @param [in] on If true, the selection highlight is turned on. Otherwise it is turned off.\r\n     */\r\n    virtual void setSelectionHighlight(bool on);\r\n\r\n    /*!\r\n     *  Sets the COM/API type. The type of the VLNV determines the type of the endpoint.\r\n     *\r\n     *    @param [in] type The VLNV of the COM/API definition.\r\n     */\r\n    virtual void setTypeDefinition(VLNV const& type);\r\n\r\n    /*!\r\n     *  Returns the currently set COM/API definition.\r\n     */\r\n    virtual VLNV getTypeDefinition() const;\r\n\r\n    int type() const { return Type; }\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // SWConnectionEndpoint implementation.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    /*!\r\n     *  Attaches the endpoint to a connection.\r\n     *\r\n     *    @param [in] connection The connection.\r\n     */\r\n    virtual void addConnection(GraphicsConnection* connection);\r\n\r\n    /*!\r\n     *  Unattaches the endpoint from a connection.\r\n     *\r\n     *    @param [in] connection The connection.\r\n     */\r\n    virtual void removeConnection(GraphicsConnection* connection);\r\n\r\n    /*!\r\n     *  Updates the endpoint interface.\r\n     */\r\n    virtual void updateInterface();\r\n\r\n    /*!\r\n     *  Returns true if the draw direction is fixed and thus, cannot be changed.\r\n     */\r\n    bool isDirectionFixed() const noexcept override;\r\n\r\n    /*!\r\n     *  Returns the name of this port.\r\n     */\r\n    virtual QString name() const;\r\n\r\n\t/*!\r\n     *  Sets the name for the port.\r\n\t *\r\n\t *    @param [in] name The name to set for the port.\r\n\t */\r\n\tvirtual void setName(QString const& name);\r\n\r\n\t/*!\r\n     *  Returns the description of the port.\r\n\t */\r\n\tvirtual QString description() const;\r\n\r\n\t/*! \r\n     *  Sets the description for the port.\r\n\t *\r\n\t *    @param [in] description The description to set.\r\n\t */\r\n\tvirtual void setDescription(QString const& description);\r\n\r\n    /*!\r\n     *  Called when a connection between this and another end point is done.\r\n     *\r\n     *    @param [in] other The other end point of the connection.\r\n     *\r\n     *    @return False if there was an error in the connection. Otherwise true.\r\n     */\r\n    virtual bool onConnect(ConnectionEndpoint const* other);\r\n\r\n    /*!\r\n     *  Called when a connection has been removed from between this and another end point.\r\n     */\r\n    virtual void onDisconnect() override final;\r\n\r\n    /*!\r\n     *  Returns true if a connection is valid between the two endpoints.\r\n     *\r\n     *    @param [in] other The other endpoint.\r\n     *\r\n     *      @remarks Does not take existing connections into account but simply\r\n     *               validates whether a connection between the endpoints would be valid\r\n     *               in a general case.\r\n     */\r\n    virtual bool isConnectionValid(ConnectionEndpoint const* other) const;\r\n\r\n    /*!\r\n     *  Returns true if the endpoint is exclusive, i.e. can only have one connection.\r\n     */\r\n    virtual bool isExclusive() const;\r\n\r\n    /*! \r\n     *  Returns the COM interface model of the endpoint.\r\n     *\r\n     *      @remarks The function returns a null pointer if the endpoint is not a COM interface.\r\n     *               Use isCom() function to check for COM interface support.\r\n     */\r\n    virtual QSharedPointer<ComInterface> getComInterface() const;\r\n\r\n    /*! \r\n     *  Returns the API interface model of the endpoint.\r\n     *\r\n     *      @remarks The function returns a null pointer if the endpoint is not a API interface.\r\n     *               Use isApi() function to check for API interface support.\r\n     */\r\n    virtual QSharedPointer<ApiInterface> getApiInterface() const;\r\n\r\n    /*!\r\n     *  Returns true if the port represents a hierarchical connection.\r\n     */\r\n    bool isHierarchical() const noexcept override;\r\n\r\n\t/*!\r\n\t *  Set the position of the name label.\r\n\t */\r\n\tvoid setLabelPosition();\r\n\r\n\t/*!\r\n\t *  Check the direction of the port and change it if necessary.\r\n\t */\r\n\tvoid checkDirection();\r\n\r\n\t/*!\r\n\t *  Return the correct length of the name label.\r\n\t */\r\n\tvirtual qreal getNameLength();\r\n\r\n\t/*!\r\n\t *  Shorten the name label to better fit the component.\r\n\t *  \r\n\t *    @param [in] width   The width of the shortened name.\r\n\t */\r\n\tvoid shortenNameLabel( qreal width ) final;\r\n\r\n    /*!\r\n     *  Returns true if the endpoint is a COM interface endpoint.\r\n     */\r\n    bool isCom() const noexcept override;\r\n\r\n    /*!\r\n     *  Returns true if the endpoint is an API interface endpoint.\r\n     */\r\n    bool isApi() const noexcept override;\r\n\r\nprotected:\r\n    \r\n    /*!\r\n     *  Item changes.\r\n     *\r\n     *    @param [in] change  The changed graphics item.\r\n     *    @param [in] value   The new value.\r\n     */\r\n    virtual QVariant itemChange(GraphicsItemChange change, QVariant const& value);\r\n    \r\n    /*!\r\n     *  Handler for mouse press events.\r\n     *\r\n     *    @param [in] event   The caught mouse press event.\r\n     */\r\n    virtual void mousePressEvent(QGraphicsSceneMouseEvent *event);\r\n    \r\n    /*!\r\n     *  Handler for mouse move events.\r\n     *\r\n     *    @param [in] event   The mouse movement event.\r\n     */\r\n    virtual void mouseMoveEvent(QGraphicsSceneMouseEvent *event);\r\n\r\n    /*!\r\n     *  Handler for mouse release event.\r\n     *\r\n     *    @param [in] event   The mouse release event.\r\n     */\r\n    virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);\r\n\r\n    /*!\r\n     *  Initializes the port graphics.\r\n     */\r\n    virtual void initialize();\r\n\r\nprivate:\r\n\r\n    /*!\r\n     *  Returns true if the port has invalid connections.\r\n     */\r\n    bool hasInvalidConnections();\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! The COM interface, or null if not set.\r\n    QSharedPointer<ComInterface> comInterface_ = nullptr;\r\n\r\n    //! The API interface, or null if not set.\r\n    QSharedPointer<ApiInterface> apiInterface_ = nullptr;\r\n\r\n    //! The position of the port before mouse move.\r\n    QPointF oldPos_;\r\n\r\n    //! The old positions of the other component ports before mouse move.\r\n    QMap<SWPortItem*, QPointF> oldPortPositions_;\r\n\r\n    //! Stub line for fixing the overdraw issue.\r\n    QGraphicsLineItem stubLine_;\r\n\r\n    //! Default pen for the stub line.\r\n    QPen stubLineDefaultPen_;\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n\r\n#endif // SWPORTITEM_H\r\n"
  },
  {
    "path": "editors/SystemDesign/SystemColumn.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: SystemColumn.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Joni-Matti Maatta\r\n// Date: 31.5.2011\r\n//\r\n// Description:\r\n// System column class for managing SW mapping components in a system design.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"SystemColumn.h\"\r\n\r\n#include <common/graphicsItems/GraphicsItemTypes.h>\r\n\r\n#include <common/graphicsItems/GraphicsConnection.h>\r\n#include <common/graphicsItems/GraphicsColumnLayout.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SystemColumn()\r\n//-----------------------------------------------------------------------------\r\nSystemColumn::SystemColumn(QSharedPointer<ColumnDesc> desc, GraphicsColumnLayout* layout):\r\nGraphicsColumn(desc, layout)\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ~SystemColumn()\r\n//-----------------------------------------------------------------------------\r\nSystemColumn::~SystemColumn()\r\n{\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SystemColumn::isItemAllowed()\r\n//-----------------------------------------------------------------------------\r\nbool SystemColumn::isItemAllowed(QGraphicsItem* item, unsigned int allowedItems) const\r\n{\r\n    if (item->type() == GFX_TYPE_HW_MAPPING_ITEM || item->type() == GFX_TYPE_SW_COMPONENT_ITEM)\r\n    {\r\n        return (allowedItems & ColumnTypes::COMPONENT);\r\n    }\r\n    else if (item->type() == GFX_TYPE_SW_INTERFACE_ITEM)\r\n    {\r\n        return (allowedItems & ColumnTypes::INTERFACE);\r\n    }\r\n    else\r\n    {\r\n        return false;\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SystemColumn::prepareColumnMove()\r\n//-----------------------------------------------------------------------------\r\nvoid SystemColumn::prepareColumnMove()\r\n{\r\n    // Begin the position update for all connections.\r\n    for (QGraphicsItem *item : scene()->items())\r\n    {\r\n        auto conn = dynamic_cast<GraphicsConnection*>(item);\r\n        if (conn != nullptr)\r\n        {\r\n            conn->beginUpdatePosition();\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SystemColumn::createMoveUndoCommand()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<QUndoCommand> SystemColumn::createMoveUndoCommand()\r\n{\r\n    QSharedPointer<QUndoCommand> cmd = GraphicsColumn::createMoveUndoCommand();\r\n\r\n    // End the position update for all connections.\r\n    for (QGraphicsItem *item : scene()->items())\r\n    {\r\n        auto conn = dynamic_cast<GraphicsConnection*>(item);\r\n        if (conn != nullptr)\r\n        {\r\n            conn->endUpdatePosition(cmd.data());\r\n        }\r\n    }\r\n\r\n    return cmd;\r\n}\r\n"
  },
  {
    "path": "editors/SystemDesign/SystemColumn.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: SystemColumn.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Joni-Matti Maatta\r\n// Date: 31.5.2011\r\n//\r\n// Description:\r\n// System column class for managing SW mapping components in a system design.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef SYSTEMCOLUMN_H\r\n#define SYSTEMCOLUMN_H\r\n\r\n#include <common/graphicsItems/GraphicsItemTypes.h>\r\n#include <common/graphicsItems/GraphicsColumn.h>\r\n\r\nclass GraphicsColumnLayout;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! SystemColumn class.\r\n//-----------------------------------------------------------------------------\r\nclass SystemColumn : public GraphicsColumn\r\n{\r\n    Q_OBJECT\r\n\r\npublic:\r\n    enum { Type = GFX_TYPE_SYSTEM_COLUMN };\r\n\r\n    /*!\r\n     *  Constructor.\r\n     *\r\n     *    @param [in] name    The column description.\r\n     *    @param [in] layout  The parent column layout.\r\n     */\r\n    SystemColumn(QSharedPointer<ColumnDesc> desc, GraphicsColumnLayout* layout);\r\n\r\n    /*!\r\n     *  Destructor.\r\n     */\r\n    virtual ~SystemColumn();\r\n\r\n    /*!\r\n     *  Get the type of this column.\r\n     *\r\n     *    @return Number representing the column type.\r\n     */\r\n    int type() const { return Type; }\r\n\r\nprotected:\r\n    /*!\r\n     *  Returns true if the given item is allowed to reside in the column based on the allowed items.\r\n     *\r\n     *    @param [in] item          The item.\r\n     *    @param [in] allowedItems  The allowed items flags.\r\n     */\r\n    virtual bool isItemAllowed(QGraphicsItem* item, unsigned int allowedItems) const;\r\n\r\n    /*!\r\n     *  Prepares for column move.\r\n     */\r\n    virtual void prepareColumnMove();\r\n\r\n    /*!\r\n     *  Creates an undo command for the column move.\r\n     *\r\n     *    @return The created undo command.\r\n     */\r\n    virtual QSharedPointer<QUndoCommand> createMoveUndoCommand();\r\n\r\nprivate:\r\n    // Disable copying.\r\n    SystemColumn(SystemColumn const& rhs);\r\n    SystemColumn& operator=(SystemColumn const& rhs);\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n\r\n#endif // SYSTEMCOLUMN_H\r\n"
  },
  {
    "path": "editors/SystemDesign/SystemComponentItem.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: SystemComponentItem.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Joni-Matti Maatta\r\n// Date: 24.11.2011\r\n//\r\n// Description:\r\n// Base class for all components visualized in a system design.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"SystemComponentItem.h\"\r\n\r\n#include \"SWPortItem.h\"\r\n\r\n#include <common/layouts/VCollisionLayout.h>\r\n\r\n#include <IPXACTmodels/Component/Component.h>\r\n\r\n#include <IPXACTmodels/Design/ComponentInstance.h>\r\n\r\n#include <IPXACTmodels/kactusExtensions/ComInterface.h>\r\n#include <IPXACTmodels/kactusExtensions/ApiInterface.h>\r\n#include <IPXACTmodels/kactusExtensions/ComProperty.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SystemComponentItem::SystemComponentItem()\r\n//-----------------------------------------------------------------------------\r\nSystemComponentItem::SystemComponentItem(QRectF const& size, LibraryInterface* libInterface,\r\n                                         QSharedPointer<ComponentInstance> instance,\r\n\t\t\t\t\t\t\t\t\t\t QSharedPointer<Component> component,\r\n\t\t\t\t\t\t\t\t\t\t QGraphicsItem *parent):\r\nComponentItem(QRectF(), libInterface, instance, component, parent)\r\n{\r\n    setRect(size);\r\n\r\n    positionAPIInterfaceTerminals();\r\n\r\n    positionCOMInterfaceTerminals();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SystemComponentItem::positionAPIInterfaceTerminals()\r\n//-----------------------------------------------------------------------------\r\nvoid SystemComponentItem::positionAPIInterfaceTerminals()\r\n{\r\n    auto apiInterfacePositions = getComponentInstance()->getApiInterfacePositions();\r\n\r\n    if (!getComponentInstance()->isDraft())\r\n    {\r\n        // Create graphics items for API interfaces.\r\n        for (QSharedPointer<ApiInterface> apiIf : componentModel()->getApiInterfaces())\r\n        {\r\n            auto port = new SWPortItem(apiIf, componentModel(), this);\r\n\r\n            // Check if the default position has been specified.\r\n            if (!apiIf->getDefaultPos().isNull())\r\n            {\r\n                port->setPos(apiIf->getDefaultPos());\r\n\r\n                addPortToSideByPosition(port);\r\n            }\r\n            else if (apiInterfacePositions.contains(apiIf->name()))\r\n            {\r\n                port->setPos(apiInterfacePositions.value(apiIf->name()));\r\n                addPortToSideByPosition(port);\r\n            }\r\n            else\r\n            {\r\n                addPortToSideWithLessPorts(port);\r\n            }\r\n        }\r\n    }\r\n    else\r\n    {\r\n        for (QString const& interfaceName : apiInterfacePositions.keys())\r\n        {\r\n            QSharedPointer<ApiInterface> apiInterface(new ApiInterface());\r\n            apiInterface->setName(interfaceName);\r\n\r\n            auto port = new SWPortItem(apiInterface->name(), componentModel(), this);\r\n\r\n            port->setPos(apiInterfacePositions.value(interfaceName));\r\n            addPortToSideByPosition(port);\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SystemComponentItem::positionCOMInterfaceTerminals()\r\n//-----------------------------------------------------------------------------\r\nvoid SystemComponentItem::positionCOMInterfaceTerminals()\r\n{\r\n    auto comInterfacePositions = getComponentInstance()->getComInterfacePositions();\r\n\r\n    if (!getComponentInstance()->isDraft())\r\n    {\r\n        // Create graphics items for COM interfaces.\r\n        for (QSharedPointer<ComInterface> comIf : componentModel()->getComInterfaces())\r\n        {\r\n            auto port = new SWPortItem(comIf, componentModel(), this);\r\n\r\n            // Check if the default position has been specified.\r\n            if (!comIf->getDefaultPos().isNull())\r\n            {\r\n                port->setPos(comIf->getDefaultPos());\r\n                addPortToSideByPosition(port);\r\n            }\r\n            else if (comInterfacePositions.contains(comIf->name()))\r\n            {\r\n                port->setPos(comInterfacePositions.value(comIf->name()));\r\n                addPortToSideByPosition(port);\r\n            }\r\n            else\r\n            {\r\n                addPortToSideWithLessPorts(port);\r\n            }\r\n        }\r\n    }\r\n    else\r\n    {\r\n        for (QString const& interfaceName : comInterfacePositions.keys())\r\n        {\r\n            QSharedPointer<ComInterface> comInterface(new ComInterface());\r\n            comInterface->setName(interfaceName);\r\n\r\n            auto port = new SWPortItem(comInterface->name(), componentModel(), this);\r\n\r\n            port->setPos(comInterfacePositions.value(interfaceName));\r\n            addPortToSideByPosition(port);\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SystemComponentItem::addPort()\r\n//-----------------------------------------------------------------------------\r\nSWPortItem* SystemComponentItem::addPort(QPointF const& pos)\r\n{\r\n    // Determine a unique name for the port.\r\n    QString name = \"interface\";\r\n    unsigned int count = 0;\r\n\r\n    while (getSWPort(name, SWConnectionEndpoint::ENDPOINT_TYPE_COM) != 0 ||\r\n           getSWPort(name, SWConnectionEndpoint::ENDPOINT_TYPE_API) != 0)\r\n    {\r\n        ++count;\r\n        name = \"interface_\" + QString::number(count);\r\n    }\r\n\r\n    // Create the visualization for the bus interface.\r\n    SWPortItem* port = new SWPortItem(name, componentModel(), this);\r\n\r\n    port->setName(name);\r\n    port->setPos(mapFromScene(pos));\r\n\r\n    addPortToSideByPosition(port);\r\n\r\n    getComponentInstance()->updateApiInterfacePosition(name, port->pos());\r\n\r\n    // Update the component size.\r\n    updateSize();\r\n    return port;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SystemComponentItem::addPort()\r\n//-----------------------------------------------------------------------------\r\nvoid SystemComponentItem::addPort(SWPortItem* port)\r\n{\r\n    port->setParentItem(this);\r\n\r\n    if (port->getType() == SWPortItem::ENDPOINT_TYPE_API)\r\n    {\r\n        if (!getComponentInstance()->isDraft())\r\n        {\r\n            QList<QSharedPointer<ApiInterface> > apiInterfaces = componentModel()->getApiInterfaces();\r\n            apiInterfaces.append(port->getApiInterface());\r\n            componentModel()->setApiInterfaces(apiInterfaces);\r\n        }\r\n\r\n        getComponentInstance()->updateApiInterfacePosition(port->name(), port->pos());\r\n    }\r\n    else if (port->getType() == SWPortItem::ENDPOINT_TYPE_COM)\r\n    {\r\n        if (!getComponentInstance()->isDraft())\r\n        {\r\n            QList<QSharedPointer<ComInterface> > comInterfaces = componentModel()->getComInterfaces();\r\n            comInterfaces.append(port->getComInterface());\r\n            componentModel()->setComInterfaces(comInterfaces);\r\n        }\r\n\r\n        getComponentInstance()->updateComInterfacePosition(port->name(), port->pos());\r\n    }\r\n\r\n    // Make preparations.\r\n    addPortToSideByPosition(port);\r\n\r\n    // Update the component size.\r\n    updateSize();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SystemComponentItem::removePort()\r\n//-----------------------------------------------------------------------------\r\nvoid SystemComponentItem::removePort(SWPortItem* port)\r\n{\r\n    leftPorts_.removeAll(port);\r\n    rightPorts_.removeAll(port);\r\n    \r\n\tupdateSize();\r\n\r\n    if (port->getType() == SWPortItem::ENDPOINT_TYPE_API)\r\n    {\r\n        componentModel()->getVendorExtensions()->removeOne(port->getApiInterface());\r\n    }\r\n    else if (port->getType() == SWPortItem::ENDPOINT_TYPE_COM)\r\n    {\r\n        componentModel()->getVendorExtensions()->removeOne(port->getComInterface());\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: setImported()\r\n//-----------------------------------------------------------------------------\r\nvoid SystemComponentItem::setImported(bool imported)\r\n{\r\n    getComponentInstance()->setImported(imported);\r\n    updateComponent();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: isImported()\r\n//-----------------------------------------------------------------------------\r\nbool SystemComponentItem::isImported() const\r\n{\r\n    return getComponentInstance()->isImported();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: onMovePort()\r\n//-----------------------------------------------------------------------------\r\nvoid SystemComponentItem::onMovePort(ConnectionEndpoint* port)\r\n{\r\n    // Remove the port from the stacks (this simplifies code).\r\n    leftPorts_.removeAll(port);\r\n    rightPorts_.removeAll(port);\r\n    \r\n    // Restrict the position so that the port cannot be placed too high.\r\n    port->setPos(snapPointToGrid(port->x(), qMax(MIN_Y_PLACEMENT - port->boundingRect().top(), port->y())));\r\n\r\n    if (port->x() < 0.0)\r\n    {\r\n        portLayout_->updateItemMove(leftPorts_, port, MIN_Y_PLACEMENT);\r\n\r\n\t\tcheckPortLabelSize( port, rightPorts_ );\r\n    }\r\n    else\r\n    {\r\n        portLayout_->updateItemMove(rightPorts_, port, MIN_Y_PLACEMENT);\r\n\r\n\t\tcheckPortLabelSize( port, leftPorts_ );\r\n    }\r\n\r\n    QMap<QString, QPointF> comPositions = getComponentInstance()->getComInterfacePositions();\r\n    QMap<QString, QPointF> apiPositions = getComponentInstance()->getApiInterfacePositions();\r\n    if (port->getComInterface() ||\r\n        (port->getType() == ConnectionEndpoint::ENDPOINT_TYPE_UNDEFINED && comPositions.contains(port->name())))\r\n    {\r\n        getComponentInstance()->updateComInterfacePosition(port->name(), port->pos());\r\n    }\r\n    else if (port->getApiInterface() ||\r\n            (port->getType() == ConnectionEndpoint::ENDPOINT_TYPE_UNDEFINED && apiPositions.contains(port->name())))\r\n    {\r\n        getComponentInstance()->updateApiInterfacePosition(port->name(), port->pos());\r\n    }\r\n\r\n    updateSize();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SystemComponentItem::isConnectionUpdateDisabled()\r\n//-----------------------------------------------------------------------------\r\nbool SystemComponentItem::isConnectionUpdateDisabled() const\r\n{\r\n    return connUpdateDisabled_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SystemComponentItem::setConnectionUpdateDisabled()\r\n//-----------------------------------------------------------------------------\r\nvoid SystemComponentItem::setConnectionUpdateDisabled(bool disabled)\r\n{\r\n    connUpdateDisabled_ = disabled;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SystemComponentItem::getSWPort()\r\n//-----------------------------------------------------------------------------\r\nSWPortItem* SystemComponentItem::getSWPort(QString const& name, SWConnectionEndpoint::EndpointType type) const\r\n{\r\n    for (QGraphicsItem *item : QGraphicsRectItem::childItems())\r\n    {\r\n        if (item->type() == SWPortItem::Type)\r\n        {\r\n            auto port = static_cast<SWPortItem*>(item);\r\n\r\n            if (port->name() == name &&\r\n                (port->getType() == type || port->getType() == SWConnectionEndpoint::ENDPOINT_TYPE_UNDEFINED ||\r\n                 type == SWConnectionEndpoint::ENDPOINT_TYPE_UNDEFINED))\r\n            {\r\n                return port;\r\n            }\r\n        }\r\n    }\r\n\r\n    return nullptr;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SystemComponentItem::getSWPortWithTypeAndDirection()\r\n//-----------------------------------------------------------------------------\r\nSWPortItem* SystemComponentItem::getSWPortMatchingOtherEndPoint(ConnectionEndpoint* otherEndPoint) const\r\n{\r\n    for (QGraphicsItem* item : QGraphicsRectItem::childItems())\r\n    {\r\n        if (item->type() == SWPortItem::Type)\r\n        {\r\n            auto port = dynamic_cast<SWPortItem*>(item);\r\n            if (port && port->getType() == otherEndPoint->getType())\r\n            {\r\n                if ((port->getType() == ConnectionEndpoint::ENDPOINT_TYPE_COM &&\r\n                    port->getComInterface() && otherEndPoint->getComInterface() &&\r\n                    port->getComInterface()->getComType() == otherEndPoint->getComInterface()->getComType() &&\r\n                    port->getComInterface()->getDirection() == otherEndPoint->getComInterface()->getDirection()) ||\r\n                    (port->getType() == ConnectionEndpoint::ENDPOINT_TYPE_API &&\r\n                    port->getApiInterface() && otherEndPoint->getApiInterface() &&\r\n                    port->getApiInterface()->getApiType() == otherEndPoint->getApiInterface()->getApiType() &&\r\n                    port->getApiInterface()->getDependencyDirection() ==\r\n                    otherEndPoint->getApiInterface()->getDependencyDirection()) ||\r\n                    (port->getType() == ConnectionEndpoint::ENDPOINT_TYPE_UNDEFINED))\r\n                {\r\n                    return port;\r\n                }\r\n            }\r\n        }\r\n    }\r\n\r\n    return nullptr;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SystemComponentItem::offsetPortPositions()\r\n//-----------------------------------------------------------------------------\r\nvoid SystemComponentItem::offsetPortPositions(qreal minY)\r\n{\r\n    // Determine the smallest Y from the ports.\r\n    int curMinY = MIN_Y_PLACEMENT;\r\n\r\n    if (!leftPorts_.isEmpty())\r\n    {\r\n        curMinY = leftPorts_.first()->pos().y();\r\n    }\r\n    else if (!rightPorts_.isEmpty())\r\n    {\r\n        curMinY = rightPorts_.first()->pos().y();\r\n    }\r\n\r\n    qreal offset = minY - curMinY;\r\n\r\n    for (ConnectionEndpoint* port : leftPorts_)\r\n    {\r\n        if (port->y() < minY)\r\n        {\r\n            port->setPos(port->x(), port->y() + offset);\r\n        }\r\n    }\r\n\r\n    for (ConnectionEndpoint* port : rightPorts_)\r\n    {\r\n        if (port->y() < minY)\r\n        {\r\n            port->setPos(port->x(), port->y() + offset);\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SystemComponentItem::setPropertyValues()\r\n//-----------------------------------------------------------------------------\r\nvoid SystemComponentItem::setPropertyValues(QMap<QString, QString> const& values)\r\n{\r\n    propertyValues_ = values;\r\n\r\n    // Check that at least all required properties are found in the values.\r\n    for (QSharedPointer<ComProperty const> prop : componentModel()->getSWProperties())\r\n    {\r\n        if (prop->isRequired() && !propertyValues_.contains(prop->name()))\r\n        {\r\n            propertyValues_.insert(prop->name(), prop->getDefaultValue());\r\n        }\r\n    }\r\n\r\n    emit propertyValuesChanged(propertyValues_);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SystemComponentItem::getPropertyValues()\r\n//-----------------------------------------------------------------------------\r\nQMap<QString, QString> SystemComponentItem::getPropertyValues() const\r\n{\r\n    return getComponentInstance()->getPropertyValues();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SystemComponentItem::setImportRef()\r\n//-----------------------------------------------------------------------------\r\nvoid SystemComponentItem::setImportRef(QString const& nameRef)\r\n{\r\n    getComponentInstance()->setImportRef(nameRef);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SystemComponentItem::getImportRef()\r\n//-----------------------------------------------------------------------------\r\nQString SystemComponentItem::getImportRef() const\r\n{\r\n    return getComponentInstance()->getImportRef();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SystemComponentItem::revalidateConnections()\r\n//-----------------------------------------------------------------------------\r\nvoid SystemComponentItem::revalidateConnections()\r\n{\r\n    for (ConnectionEndpoint* endpoint : getEndpoints())\r\n    {\r\n        endpoint->revalidateConnections();\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SystemComponentItem::itemChange()\r\n//-----------------------------------------------------------------------------\r\nQVariant SystemComponentItem::itemChange(GraphicsItemChange change, const QVariant &value)\r\n{\r\n    if (change == ItemParentHasChanged)\r\n    {\r\n        revalidateConnections();\r\n    }\r\n\r\n    return ComponentItem::itemChange(change, value);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SystemComponentItem::setApiInterfacePositions()\r\n//-----------------------------------------------------------------------------\r\nvoid SystemComponentItem::setApiInterfacePositions(QMap<QString, QPointF> const& positions, bool createMissing /*= false*/)\r\n{\r\n    QMapIterator<QString, QPointF> itrPortPos(positions);\r\n\r\n    while (itrPortPos.hasNext())\r\n    {\r\n        itrPortPos.next();\r\n        SWPortItem* port = getSWPort(itrPortPos.key(), SWConnectionEndpoint::ENDPOINT_TYPE_API);\r\n\r\n        // If the port was not found, create it.\r\n        if (port == nullptr)\r\n        {\r\n            if (!createMissing || componentModel()->getVlnv().isValid())\r\n            {\r\n                continue;\r\n            }\r\n\r\n            port = new SWPortItem(itrPortPos.key(), componentModel(), this);\r\n            addPort(port);\r\n        }\r\n\r\n        port->setPos(itrPortPos.value());\r\n        onMovePort(port);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SystemComponentItem::setComInterfacePositions()\r\n//-----------------------------------------------------------------------------\r\nvoid SystemComponentItem::setComInterfacePositions(QMap<QString, QPointF> const& positions, bool createMissing /*= false*/)\r\n{\r\n    QMapIterator<QString, QPointF> itrPortPos(positions);\r\n\r\n    while (itrPortPos.hasNext())\r\n    {\r\n        itrPortPos.next();\r\n        SWPortItem* port = getSWPort(itrPortPos.key(), SWConnectionEndpoint::ENDPOINT_TYPE_COM);\r\n\r\n        // If the port was not found, create it.\r\n        if (port == nullptr)\r\n        {\r\n            if (!createMissing || componentModel()->getVlnv().isValid())\r\n            {\r\n                continue;\r\n            }\r\n\r\n            port = new SWPortItem(itrPortPos.key(), componentModel(), this);\r\n            addPort(port);\r\n        }\r\n\r\n        port->setPos(itrPortPos.value());\r\n        onMovePort(port);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SystemComponentItem::getApiInterfacePositions()\r\n//-----------------------------------------------------------------------------\r\nQMap<QString, QPointF> SystemComponentItem::getApiInterfacePositions() const\r\n{\r\n    QMap<QString, QPointF> positions;\r\n    QListIterator< QSharedPointer<ApiInterface> > itrApiIf(componentModel()->getApiInterfaces());\r\n\r\n    while (itrApiIf.hasNext())\r\n    {\r\n        QSharedPointer<ApiInterface> apiIf = itrApiIf.next();\r\n        positions[apiIf->name()] = getSWPort(apiIf->name(), SWConnectionEndpoint::ENDPOINT_TYPE_API)->pos();\r\n    }\r\n\r\n    return positions;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SystemComponentItem::getComInterfacePositions()\r\n//-----------------------------------------------------------------------------\r\nQMap<QString, QPointF> SystemComponentItem::getComInterfacePositions() const\r\n{\r\n    QMap<QString, QPointF> positions;\r\n    QListIterator< QSharedPointer<ComInterface> > itrComIf(componentModel()->getComInterfaces());\r\n\r\n    while (itrComIf.hasNext())\r\n    {\r\n        QSharedPointer<ComInterface> comIf = itrComIf.next();\r\n        positions[comIf->name()] = getSWPort(comIf->name(), SWConnectionEndpoint::ENDPOINT_TYPE_COM)->pos();\r\n    }\r\n\r\n    return positions;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SystemComponentItem::setPacketized()\r\n//-----------------------------------------------------------------------------\r\nvoid SystemComponentItem::setPackaged()\r\n{\r\n    // Nothing to do here.\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SystemComponentItem::setDraft()\r\n//-----------------------------------------------------------------------------\r\nvoid SystemComponentItem::setDraft()\r\n{\r\n    // Nothing to do here.\r\n}"
  },
  {
    "path": "editors/SystemDesign/SystemComponentItem.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: SystemComponentItem.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Joni-Matti Maatta\r\n// Date: 24.11.2011\r\n//\r\n// Description:\r\n// Base class for all components visualized in a system design.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef SYSTEMCOMPONENTITEM_H\r\n#define SYSTEMCOMPONENTITEM_H\r\n\r\n#include \"SWPortItem.h\"\r\n\r\n#include <common/graphicsItems/ComponentItem.h>\r\n#include <common/layouts/IVGraphicsLayout.h>\r\n\r\nenum PortDirection\r\n{\r\n    PORT_LEFT = 0,\r\n    PORT_RIGHT,\r\n    PORT_BOTTOM\r\n};\r\n\r\nclass HWMappingItem;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! SystemComponentItem class.\r\n//-----------------------------------------------------------------------------\r\nclass SystemComponentItem : public ComponentItem\r\n{\r\n    Q_OBJECT\r\n\r\npublic:\r\n    /*!\r\n     *  Constructor.\r\n     *\r\n     *    @param [in] size            The initial rectangle size.\r\n     *    @param [in] libInterface    The library interface.\r\n     *    @param [in] instance        The component instance.\r\n     *    @param [in] component       The component referenced by the component instance.\r\n     *    @param [in] parent          The parent graphics item.\r\n     */\r\n\tSystemComponentItem(QRectF const& size, LibraryInterface* libInterface,\r\n\t\tQSharedPointer<ComponentInstance> instance,\r\n\t\tQSharedPointer<Component> component,\r\n\t\tQGraphicsItem *parent);\r\n\r\n    /*!\r\n     *  Destructor.\r\n     */\r\n    ~SystemComponentItem() override = default;\r\n\r\n    // Disable copying.\r\n    SystemComponentItem(SystemComponentItem const& rhs) = delete;\r\n    SystemComponentItem& operator=(SystemComponentItem const& rhs) = delete;\r\n\r\n    /*!\r\n     *  Sets the property values.\r\n     *\r\n     *    @param [in] values The property values.\r\n     */ \r\n    void setPropertyValues(QMap<QString, QString> const& values);\r\n\r\n    /*!\r\n     *  Returns the property values.\r\n     */\r\n    QMap<QString, QString> getPropertyValues() const;\r\n\r\n    /*!\r\n     *  Adds a new, empty port to the component.\r\n     *\r\n     *    @param [in] pos The position hint for the port.\r\n     *\r\n     *    @return The newly created port.\r\n     */\r\n    SWPortItem* addPort(QPointF const& pos);\r\n\r\n    /*!\r\n     *  Adds an already created port to the component.\r\n     *\r\n     *    @param [in] port The port to add. Must not be used in any other component.\r\n     */\r\n    void addPort(SWPortItem* port);\r\n\r\n    /*!\r\n     *  Removes the given port from the component.\r\n     *\r\n     *    @param [in] port The port to remove.\r\n     */\r\n    void removePort(SWPortItem* port);\r\n\r\n    /*!\r\n     *  Sets the flag whether the component has been imported or not.\r\n     *\r\n     *    @param [in] imported If true, the component is marked as imported.\r\n     */\r\n    void setImported(bool imported);\r\n\r\n    /*!\r\n     *  Sets the name of the import source instance.\r\n     *\r\n     *    @param [in] nameRef The name of the import source instance.\r\n     */\r\n    void setImportRef(QString const& nameRef);\r\n\r\n    /*!\r\n     *  Returns true if the component has been marked as imported.\r\n     */\r\n    bool isImported() const;\r\n\r\n    /*!\r\n     *  Returns the name of the import source instance.\r\n     */\r\n    QString getImportRef() const;\r\n\r\n    /*!\r\n     *  Called when a port is being moved.\r\n     *\r\n     *    @param [in] port    The port that is being moved.\r\n     */\r\n    virtual void onMovePort(ConnectionEndpoint* port);\r\n\r\n    /*!\r\n     *  Returns true if the connections should not be updated automatically in the port's itemChange() function.\r\n     *  Otherwise false.\r\n     */\r\n    bool isConnectionUpdateDisabled() const;\r\n\r\n    /*!\r\n     *  Sets the connection update disabled/enabled.\r\n     *\r\n     *    @param [in] disabled If true, the connection update is set disabled, otherwise it is enabled.\r\n     */\r\n    void setConnectionUpdateDisabled(bool disabled);\r\n\r\n    /*!\r\n     *  Re-validates existing connections.\r\n     */\r\n    void revalidateConnections();\r\n\r\n    /*!\r\n     *  Retrieves the port with the given name and type (API/COM).\r\n     *\r\n     *    @param [in] name  The name of the port.\r\n     *    @param [in] type  The endpoint type.\r\n     *\r\n     *    @return The corresponding port item, or null if no match was found.\r\n     */\r\n    SWPortItem* getSWPort(QString const& name, SWConnectionEndpoint::EndpointType type) const;\r\n\r\n    /*!\r\n     *  Retrieves the port with properties similar to the selected end point.\r\n     *\r\n     *    @param [in] otherEndPoint   The selected end point.\r\n     *\r\n     *    @return An SW port with similar properties to the selected port.\r\n     */\r\n    SWPortItem* getSWPortMatchingOtherEndPoint(ConnectionEndpoint* otherEndPoint) const;\r\n\r\n    /*!\r\n     *  Returns the underlying HW linked with this component.\r\n     */\r\n    virtual HWMappingItem const* getLinkedHW() const = 0;\r\n\r\n    /*!\r\n     *  Sets the API interface positions.\r\n     *\r\n     *    @param [in] positions      The positions to set.\r\n     *    @param [in] createMissing  If true, the missing bus interfaces are created.\r\n     */\r\n    void setApiInterfacePositions(QMap<QString, QPointF> const& positions, bool createMissing = false);\r\n\r\n    /*!\r\n     *  Sets the COM interface positions.\r\n     *\r\n     *    @param [in] positions      The positions to set.\r\n     *    @param [in] createMissing  If true, the missing bus interfaces are created.\r\n     */\r\n    void setComInterfacePositions(QMap<QString, QPointF> const& positions, bool createMissing = false);\r\n\r\n    /*!\r\n     *  Returns the API interface positions.\r\n     */\r\n    QMap<QString, QPointF> getApiInterfacePositions() const;\r\n\r\n    /*!\r\n     *  Returns the COM interface positions.\r\n     */\r\n    QMap<QString, QPointF> getComInterfacePositions() const;\r\n\r\n    /*!\r\n     *  Marks the component as a packetized component.\r\n     */\r\n    virtual void setPackaged();\r\n\r\n    /*!\r\n     *  Marks the component as a draft component.\r\n     */\r\n    virtual void setDraft();\r\n\r\nsignals:\r\n    //! Occurs when the property values have been changed.\r\n    void propertyValuesChanged(QMap<QString, QString> const& propertyValues);\r\n\r\nprotected:\r\n    QVariant itemChange(GraphicsItemChange change, const QVariant &value);\r\n\r\n\r\n    /*!\r\n     *  Updates the port positions so that they have at minimum the given Y coordinate value.\r\n     */\r\n    void offsetPortPositions(qreal minY);\r\n\r\nprivate:\r\n\r\n    /*!\r\n     *  Position the API interface items for the component item.\r\n     */\r\n    void positionAPIInterfaceTerminals();\r\n\r\n    /*!\r\n     *  Position the COM interface items for the component item.\r\n     */\r\n    void positionCOMInterfaceTerminals();\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! If true, connection updates coming from ports are disabled.\r\n    bool connUpdateDisabled_ = false;\r\n\r\n    //! The set property values.\r\n    QMap<QString, QString> propertyValues_;\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n\r\n#endif // SYSTEMCOMPONENTITEM_H\r\n"
  },
  {
    "path": "editors/SystemDesign/SystemDesignDiagram.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: SystemDesignDiagram.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Joni-Matti Maatta\r\n// Date: 26.2.2011\r\n//\r\n// Description:\r\n// System design diagram to work as a drawing canvas.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"SystemDesignDiagram.h\"\r\n\r\n#include \"SystemColumn.h\"\r\n#include \"HWMappingItem.h\"\r\n#include \"SWComponentItem.h\"\r\n#include \"SystemDesignWidget.h\"\r\n#include \"SWPortItem.h\"\r\n#include \"SWInterfaceItem.h\"\r\n\r\n#include <common/GenericEditProvider.h>\r\n#include <common/dialogs/newObjectDialog/newobjectdialog.h>\r\n#include <common/graphicsItems/GraphicsColumn.h>\r\n#include <common/graphicsItems/GraphicsColumnLayout.h>\r\n#include <common/graphicsItems/CommonGraphicsUndoCommands.h>\r\n#include <common/graphicsItems/ComponentItem.h>\r\n#include <common/graphicsItems/GraphicsColumnUndoCommands.h>\r\n#include <common/graphicsItems/GraphicsColumnAddCommand.h>\r\n#include <common/graphicsItems/GraphicsConnection.h>\r\n#include <common/graphicsItems/ConnectionUndoCommands.h>\r\n#include <common/graphicsItems/GraphicsColumnConstants.h>\r\n\r\n#include <editors/common/DiagramUtil.h>\r\n#include <editors/common/StickyNote/StickyNote.h>\r\n#include <editors/common/Association/Association.h>\r\n\r\n#include <editors/HWDesign/columnview/ColumnEditDialog.h>\r\n#include <editors/HWDesign/HWChangeCommands.h>\r\n#include <editors/HWDesign/OffPageConnectorItem.h>\r\n\r\n#include <editors/SystemDesign/UndoCommands/SystemMoveCommands.h>\r\n#include <editors/SystemDesign/UndoCommands/SystemAddCommands.h>\r\n#include <editors/SystemDesign/UndoCommands/SystemComponentAddCommand.h>\r\n#include <editors/SystemDesign/SystemDetailsEditor/SwitchHWDialog.h>\r\n#include <editors/SystemDesign/ComGraphicsConnection.h>\r\n#include <editors/SystemDesign/UndoCommands/ComConnectionAddCommand.h>\r\n#include <editors/SystemDesign/ApiGraphicsConnection.h>\r\n#include <editors/SystemDesign/UndoCommands/ApiConnectionAddCommand.h>\r\n#include <editors/SystemDesign/UndoCommands/SWInterfaceAddCommand.h>\r\n#include <editors/SystemDesign/UndoCommands/SystemChangeCommands.h>\r\n#include <editors/SystemDesign/UndoCommands/ReplaceSystemComponentCommand.h>\r\n\r\n#include <KactusAPI/include/LibraryInterface.h>\r\n\r\n#include <IPXACTmodels/DesignConfiguration/DesignConfiguration.h>\r\n\r\n#include <IPXACTmodels/kactusExtensions/ApiInterface.h>\r\n#include <IPXACTmodels/kactusExtensions/ComInterface.h>\r\n#include <IPXACTmodels/kactusExtensions/SystemView.h>\r\n#include <IPXACTmodels/kactusExtensions/ComInterconnection.h>\r\n#include <IPXACTmodels/kactusExtensions/ConnectionRoute.h>\r\n#include <IPXACTmodels/kactusExtensions/InterfaceGraphicsData.h>\r\n\r\n#include <IPXACTmodels/common/VLNV.h>\r\n#include <IPXACTmodels/Component/Component.h>\r\n#include <IPXACTmodels/Component/Model.h>\r\n\r\n#include <IPXACTmodels/Design/Design.h>\r\n\r\n#include <QGraphicsScene>\r\n#include <QMimeData>\r\n#include <QMessageBox>\r\n#include <QCoreApplication>\r\n#include <QApplication>\r\n#include <QClipboard>\r\n#include <QUuid>\r\n\r\nQ_DECLARE_METATYPE(SystemDesignDiagram::PortCollectionCopyData)\r\nQ_DECLARE_METATYPE(SystemDesignDiagram::ComponentCollectionCopyData)\r\nQ_DECLARE_METATYPE(SystemDesignDiagram::ColumnCollectionCopyData)\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SystemDesignDiagram::SystemDesignDiagram()\r\n//-----------------------------------------------------------------------------\r\nSystemDesignDiagram::SystemDesignDiagram(bool onlySW, LibraryInterface* lh,\r\n                                         QSharedPointer<IEditProvider> editProvider, SystemDesignWidget* parent):\r\nComponentDesignDiagram(lh, editProvider, parent),\r\nonlySW_(onlySW),\r\ndragType_(DRAG_TYPE_NONE),\r\ndragEndPoint_(0)\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SystemDesignDiagram::updateHierComponent()\r\n//-----------------------------------------------------------------------------\r\nvoid SystemDesignDiagram::updateHierComponent()\r\n{\r\n    // Intentionally empty.\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SystemDesignDiagram::addColumn()\r\n//-----------------------------------------------------------------------------\r\nvoid SystemDesignDiagram::addColumn(QSharedPointer<ColumnDesc> desc)\r\n{\r\n    SystemColumn* column = new SystemColumn(desc, getLayout().data());\r\n\r\n    QSharedPointer<QUndoCommand> cmd(new GraphicsColumnAddCommand(getLayout().data(), column, this));\r\n    getEditProvider()->addCommand(cmd);\r\n    cmd->redo();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SystemDesignDiagram::onCopyAction()\r\n//-----------------------------------------------------------------------------\r\nvoid SystemDesignDiagram::onCopyAction()\r\n{\r\n    if (!isProtected())\r\n    {\r\n        QList<QGraphicsItem*> items = selectedItems();\r\n        int type = getCommonItemType(items);\r\n\r\n        if (type == SWPortItem::Type || type == SWInterfaceItem::Type)\r\n        {\r\n            PortCollectionCopyData collection;\r\n            copyInterfaces(items, collection);\r\n\r\n            QMimeData* mimeData = new QMimeData();\r\n            mimeData->setImageData(QVariant::fromValue(collection));\r\n            QApplication::clipboard()->setMimeData(mimeData);\r\n        }\r\n        else if (type == SWComponentItem::Type)\r\n        {\r\n            ComponentCollectionCopyData collection;\r\n            copySWInstances(items, collection);\r\n\r\n            QMimeData* mimeData = new QMimeData();\r\n            mimeData->setImageData(QVariant::fromValue(collection));\r\n            QApplication::clipboard()->setMimeData(mimeData);\r\n        }\r\n        else if (type == SystemColumn::Type)\r\n        {\r\n            std::sort(items.begin(), items.end(), &sortByX);\r\n\r\n            ColumnCollectionCopyData collection;\r\n\r\n            for (QGraphicsItem const* item : items)\r\n            {\r\n                auto column = static_cast<SystemColumn const*>(item);\r\n\r\n                collection.columns.append(ColumnCopyData());\r\n                ColumnCopyData& columnData = collection.columns.back();\r\n\r\n                columnData.desc = column->getColumnDesc();\r\n\r\n                copySWInstances(column->getItems(), columnData.components);\r\n                copyInterfaces(column->getItems(), columnData.interfaces);\r\n            }\r\n\r\n            QMimeData* mimeData = new QMimeData();\r\n            mimeData->setImageData(QVariant::fromValue(collection));\r\n            QApplication::clipboard()->setMimeData(mimeData);\r\n        }\r\n    }\r\n\r\n    prepareContextMenuActions();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SystemDesignDiagram::onPasteAction()\r\n//-----------------------------------------------------------------------------\r\nvoid SystemDesignDiagram::onPasteAction()\r\n{\r\n    if (!isProtected())\r\n    {\r\n        QList<QGraphicsItem*> items = selectedItems();\r\n        int type = getCommonItemType(items);\r\n\r\n        if (type == SWComponentItem::Type)\r\n        {\r\n            SWComponentItem* targetComp = static_cast<SWComponentItem*>(items[0]);\r\n\r\n            // Paste only to draft components.\r\n            if (!targetComp->componentModel()->getVlnv().isValid())\r\n            {\r\n                QMimeData const* mimedata = QApplication::clipboard()->mimeData();\r\n\r\n                if (mimedata->hasImage() && mimedata->imageData().canConvert<PortCollectionCopyData>())\r\n                {\t\t\t\t\r\n                    PortCollectionCopyData collection = mimedata->imageData().value<PortCollectionCopyData>();\r\n\r\n                    QSharedPointer<QUndoCommand> parentCmd(new QUndoCommand());\r\n                    pasteInterfaces(collection, targetComp, parentCmd.data());\r\n                    getEditProvider()->addCommand(parentCmd);\r\n\r\n                    // Update sidebar view.\r\n                    emit componentSelected(targetComp);\r\n                    emit helpUrlRequested(\"swsysdesign/swinstance.html\");\r\n                }\r\n            }\r\n        }\r\n        else\r\n        {\r\n            // Check the mime data.\r\n            QMimeData const* mimeData = QApplication::clipboard()->mimeData();\r\n\r\n            if (mimeData->hasImage())\r\n            {\r\n                // Allow pasting interfaces to empty design space (columns).\r\n                if (mimeData->imageData().canConvert<PortCollectionCopyData>() && items.empty())\r\n                {\r\n                    // Find a valid column for the interfaces.\r\n                    IGraphicsItemStack* stack = getLayout()->findColumnAt(contextMenuPosition());\r\n\r\n                    if (stack && stack->getContentType() != ColumnTypes::IO)\r\n                    {\r\n                        for (GraphicsColumn* col : getLayout()->getColumns())\r\n                        {\r\n                            if (col->getContentType() == ColumnTypes::IO)\r\n                            {\r\n                                stack = col;\r\n                                break;\r\n                            }\r\n                        }\r\n                    }\r\n\r\n                    if (stack != nullptr)\r\n                    {\r\n                        PortCollectionCopyData collection = mimeData->imageData().value<PortCollectionCopyData>();\r\n\r\n                        QSharedPointer<QUndoCommand> cmd(new QUndoCommand());\r\n                        pasteInterfaces(collection, stack, cmd.data(), true);\r\n                        getEditProvider()->addCommand(cmd);\r\n                    }\r\n                }\r\n                // Allow pasting components to either empty design space (column) or to parent HW.\r\n                else if (mimeData->imageData().canConvert<ComponentCollectionCopyData>() &&\r\n                    (items.empty() || type == HWMappingItem::Type))\r\n                {\r\n                    IGraphicsItemStack* stack = nullptr;\r\n\r\n                    if (type == HWMappingItem::Type)\r\n                    {\r\n                        stack = dynamic_cast<IGraphicsItemStack*>(items[0]);\r\n                    }\r\n                    else\r\n                    {\r\n                        stack = getLayout()->findColumnAt(findCursorPositionMappedToScene());\r\n                    }\r\n\r\n                    if (stack != nullptr)\r\n                    {\r\n                        ComponentCollectionCopyData collection = mimeData->imageData().value<ComponentCollectionCopyData>();\r\n\r\n                        QSharedPointer<QUndoCommand> cmd(new QUndoCommand());\r\n                        pasteSWInstances(collection, stack, cmd.data(), true);\r\n                        getEditProvider()->addCommand(cmd);\r\n                        cmd->redo();\r\n                    }\r\n                }\r\n                else if (mimeData->imageData().canConvert<ColumnCollectionCopyData>() &&\r\n                    (items.empty() || type == SystemColumn::Type))\r\n                {\r\n                    ColumnCollectionCopyData collection = mimeData->imageData().value<ColumnCollectionCopyData>();\r\n\r\n                    pasteColumns(collection);\r\n                }\r\n            }\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SystemDesignDiagram::pasteColumns()\r\n//-----------------------------------------------------------------------------\r\nvoid SystemDesignDiagram::pasteColumns(ColumnCollectionCopyData const collection)\r\n{\r\n    QSharedPointer<QUndoCommand> parentCmd(new QUndoCommand());\r\n\r\n    for (ColumnCopyData const& columnData : collection.columns)\r\n    {\r\n        QSharedPointer<ColumnDesc> copiedColumnDescription (new ColumnDesc(*columnData.desc.data()));\r\n        QString newName = createColumnName(columnData.desc->name());\r\n        copiedColumnDescription->setName(newName);\r\n\r\n        SystemColumn* column = new SystemColumn(copiedColumnDescription, getLayout().data());\r\n\r\n        GraphicsColumnAddCommand* addCommand =\r\n            new GraphicsColumnAddCommand(getLayout().data(), column, this, parentCmd.data());\r\n\r\n        pasteSWInstances(columnData.components, column, parentCmd.data(), false);\r\n        pasteInterfaces(columnData.interfaces, column, parentCmd.data(), false);\r\n\r\n        QPointF columnOldPosition (copiedColumnDescription->getPosition(), 0);\r\n        column->setPos(findCursorPositionMappedToScene());\r\n\r\n        new GraphicsColumnMoveCommand(getLayout().data(), column, columnOldPosition, addCommand);\r\n    }\r\n\r\n    getEditProvider()->addCommand(parentCmd);\r\n    parentCmd->redo();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SystemDesignDiagram::createColumnName()\r\n//-----------------------------------------------------------------------------\r\nQString SystemDesignDiagram::createColumnName(QString const& baseName)\r\n{\r\n    // Determine a unique name by using a running number.\r\n    int runningNumber = 0;\r\n\r\n    QStringList columnNames;\r\n    for (QSharedPointer<ColumnDesc> column : getDesign()->getColumns())\r\n    {\r\n        columnNames.append(column->name());\r\n    }\r\n\r\n    QString format = \"$ComponentName$_$InstanceNumber$\";\r\n    QString name = baseName;\r\n\r\n    while (columnNames.contains(name))\r\n    {\r\n        name = format;\r\n        name.replace(\"$ComponentName$\", baseName);\r\n        name.replace(\"$InstanceNumber$\", QString::number(runningNumber));\r\n\r\n        runningNumber++;\r\n    }\r\n\r\n    return name;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SystemDesignDiagram::onAddAction()\r\n//-----------------------------------------------------------------------------\r\nvoid SystemDesignDiagram::onAddToLibraryAction()\r\n{\r\n    if (singleSelection())\r\n    {\r\n        QGraphicsItem *item = selectedItems().first();\r\n        if (item != nullptr && item->type() == SWComponentItem::Type)\r\n        {\r\n            SystemComponentItem* comp = static_cast<SystemComponentItem*>(item);\r\n            // Request the user to set the vlnv.\r\n            NewObjectDialog dialog(getLibraryInterface(), VLNV::COMPONENT, false, getParent());\r\n            dialog.setVLNV(comp->componentModel()->getVlnv());\r\n            dialog.setWindowTitle(tr(\"Add Component to Library\"));\r\n\r\n            if (dialog.exec() == QDialog::Rejected)\r\n            {\r\n                return;\r\n            }\r\n\r\n            VLNV vlnv = dialog.getVLNV();\r\n            comp->componentModel()->setVlnv(vlnv);\r\n            comp->componentModel()->setHierarchy(dialog.getProductHierarchy());\r\n            comp->componentModel()->setFirmness(dialog.getFirmness());\r\n            comp->componentModel()->setTags(dialog.getTags());\r\n\r\n            if (comp->type() == HWMappingItem::Type)\r\n            {\r\n\t\t\t\t// create new view\r\n\t\t\t\tQSharedPointer<View> newView( new View() );\r\n\r\n\t\t\t\t// depending on the hierarchy level select the name for the view\r\n\t\t\t\tKactusAttribute::ProductHierarchy hier = comp->componentModel()->getHierarchy();\r\n\r\n\t\t\t\tswitch (hier) \r\n\t\t\t\t{\r\n\t\t\t\t\tcase KactusAttribute::IP:\r\n\t\t\t\t\tcase KactusAttribute::SOC:\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\t// set the name\r\n\t\t\t\t\t\tnewView->setName(\"rtl\");\r\n\t\t\t\t\t\tbreak;\r\n\t\t\t\t\t}\r\n\t\t\t\t\tdefault:\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tnewView->setName(\"flat\");\r\n\t\t\t\t\t\tbreak;\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\r\n\t\t\t\tcomp->componentModel()->getModel()->getViews()->append(newView);\r\n            }\r\n\r\n            // Write the model to file.\r\n            getLibraryInterface()->writeModelToFile(dialog.getPath(), comp->componentModel());\r\n\r\n            // Create an undo command.\r\n            QSharedPointer<ComponentPacketizeCommand> cmd(new ComponentPacketizeCommand(this, comp, vlnv));\r\n            getEditProvider()->addCommand(cmd);\r\n            cmd->redo();\r\n\r\n            // Ask the user if he wants to complete the component.\r\n            QMessageBox msgBox(QMessageBox::Question, QCoreApplication::applicationName(),\r\n                \"Do you want to continue packaging the component completely?\",\r\n                QMessageBox::NoButton, getParent());\r\n            msgBox.setInformativeText(\"Pressing Continue opens up the component editor.\");\r\n            QPushButton* btnContinue = msgBox.addButton(tr(\"Continue\"), QMessageBox::ActionRole);\r\n            msgBox.addButton(tr(\"Skip\"), QMessageBox::RejectRole);\r\n\r\n            msgBox.exec();\r\n\r\n            if (msgBox.clickedButton() == btnContinue)\r\n            {\r\n                // Open up the component editor.\r\n                emit openComponent(comp->componentModel()->getVlnv());\r\n            }\r\n        }\r\n    }\r\n}\r\n\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SystemDesignDiagram::openDesignForComponent()\r\n//-----------------------------------------------------------------------------\r\nvoid SystemDesignDiagram::openDesignForComponent(ComponentItem* component, QString const& viewName)\r\n{\r\n    if (component->componentModel()->hasView(viewName))\r\n    {\r\n        emit openSWDesign(component->componentModel()->getVlnv(), viewName);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SystemDesignDiagram::mouseDoubleClickEvent()\r\n//-----------------------------------------------------------------------------\r\nvoid SystemDesignDiagram::mouseDoubleClickEvent(QGraphicsSceneMouseEvent* event)\r\n{\r\n    // Allow double click only when the mode is select.\r\n    if (getMode() != MODE_SELECT)\r\n    {\r\n        return;\r\n    }\r\n\r\n    // Find the item under the cursor.\r\n    QGraphicsItem *item = itemAt(snapPointToGrid(event->scenePos()), QTransform());\r\n\r\n    if (item == nullptr)\r\n    {\r\n        return;\r\n    }\r\n\r\n    item = getBaseItemOf(item);\r\n\r\n    if (dynamic_cast<SystemComponentItem*>(item) != nullptr)\r\n    {\r\n        item->setSelected(true);\r\n        auto comp = static_cast<SystemComponentItem*>(item);\r\n\r\n        if (getLibraryInterface()->contains(comp->componentModel()->getVlnv()))\r\n        {\r\n            openComponentItem(comp);\r\n        }\r\n        else if (!isProtected())\r\n        {\r\n            // Otherwise this is an unpackaged component.\r\n            onAddToLibraryAction();\r\n        }\r\n    }\r\n    else if (item->type() == SystemColumn::Type && !isProtected())\r\n    {\r\n        item->setSelected(true);\r\n        SystemColumn* column = qgraphicsitem_cast<SystemColumn*>(item);\r\n\r\n        ColumnEditDialog dialog(getParent(), onlySW_, column);\r\n\r\n        // System design columns don't have adjustable content settings.\r\n        if (!onlySW_)\r\n        {\r\n            dialog.hideContentSettings();\r\n        }\r\n\r\n        if (dialog.exec() == QDialog::Accepted)\r\n        {\r\n            int columnWidth = GraphicsColumnConstants::SYSTEM_COLUMN_WIDTH;\r\n\r\n            if (onlySW_)\r\n            {\r\n                columnWidth = GraphicsColumnConstants::COMPONENT_COLUMN_WIDTH;\r\n\r\n                if (dialog.getContentType() == ColumnTypes::IO)\r\n                {\r\n                    columnWidth = GraphicsColumnConstants::IO_COLUMN_WIDTH;\r\n                }\r\n            }\r\n\r\n            QSharedPointer<ColumnDesc> desc(new ColumnDesc(dialog.name(), dialog.getContentType(),\r\n                dialog.getAllowedItems(), columnWidth));\r\n\r\n            // Keep the previous width if the content type did not change.\r\n            if (dialog.getContentType() == column->getColumnDesc()->getContentType())\r\n            {\r\n                desc->setWidth(column->getColumnDesc()->getWidth());\r\n            }\r\n\r\n            QSharedPointer<QUndoCommand> cmd(new GraphicsColumnChangeCommand(column, desc, this));\r\n            getEditProvider()->addCommand(cmd);\r\n            cmd->redo();\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: dragEnterEvent()\r\n//-----------------------------------------------------------------------------\r\nvoid SystemDesignDiagram::dragEnterEvent(QGraphicsSceneDragDropEvent * event)\r\n{\r\n    dragType_ = DRAG_TYPE_NONE;\r\n\r\n    if (!isProtected() && event->mimeData()->hasImage())\r\n    {\r\n        event->acceptProposedAction();\r\n\r\n\t\tQVariant data = event->mimeData()->imageData();\r\n\t\tif (!data.canConvert<VLNV>()) {\r\n\t\t\treturn;\r\n\t\t}\r\n\r\n\t\tVLNV vlnv = data.value<VLNV>();\r\n\r\n        if (vlnv.getType() == VLNV::COMPONENT)\r\n        {\r\n            // Determine the component type.\r\n            QSharedPointer<Document> libComp = getLibraryInterface()->getModel(vlnv);\r\n            QSharedPointer<Component> comp = libComp.staticCast<Component>();\r\n\r\n            // component with given vlnv was not found\r\n            if (!comp) {\r\n                emit errorMessage(tr(\"Component with the VLNV %1:%2:%3:%4 was not found in the library.\").arg(\r\n                    vlnv.getVendor()).arg(\r\n                    vlnv.getLibrary()).arg(\r\n                    vlnv.getName()).arg(\r\n                    vlnv.getVersion()));\r\n                return;\r\n            }\r\n\r\n            // Only SW and HW is allowed.\r\n            if (comp->getImplementation() == KactusAttribute::SW)\r\n            {\r\n                dragType_ = DRAG_TYPE_SW;\r\n            }\r\n            else if (comp->getImplementation() == KactusAttribute::HW)\r\n            {\r\n                dragType_ = DRAG_TYPE_HW;\r\n            }\r\n\r\n        }\r\n        else if (vlnv.getType() == VLNV::COMDEFINITION || vlnv.getType() == VLNV::APIDEFINITION)\r\n        {\r\n            dragType_ = DRAG_TYPE_DEFINITION;\r\n        }\r\n        else if (vlnv.getType() == VLNV::DESIGN)\r\n        {\r\n            dragType_ = DRAG_TYPE_DESIGN;\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: dragLeaveEvent()\r\n//-----------------------------------------------------------------------------\r\nvoid SystemDesignDiagram::dragLeaveEvent(QGraphicsSceneDragDropEvent*)\r\n{\r\n    dragType_ = DRAG_TYPE_NONE;\r\n\r\n    if (dragEndPoint_)\r\n    {\r\n        dragEndPoint_->setHighlight(ConnectionEndpoint::HIGHLIGHT_OFF);\r\n        dragEndPoint_ = nullptr;\r\n    }    \r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: dropEvent()\r\n//-----------------------------------------------------------------------------\r\nvoid SystemDesignDiagram::dropEvent(QGraphicsSceneDragDropEvent *event)\r\n{\r\n    if (dragType_ == DRAG_TYPE_NONE)\r\n    {\r\n        return;\r\n    }\r\n\r\n    QVariant data = event->mimeData()->imageData();\r\n\tif (!data.canConvert<VLNV>())\r\n    {\r\n\t\treturn;\r\n\t}\r\n\r\n\tVLNV droppedVLNV = data.value<VLNV>();\r\n    updateDropAction(event);\r\n\r\n    // Check if the dragged item was a valid one.\r\n    if (dragType_ == DRAG_TYPE_SW)\r\n    {\r\n        // Disallow self-instantiation.\r\n        if (droppedVLNV == getEditedComponent()->getVlnv())\r\n        {\r\n            QMessageBox msgBox(QMessageBox::Warning, QCoreApplication::applicationName(),\r\n                tr(\"Component cannot be instantiated to its own design.\"),\r\n                QMessageBox::Ok, getParent());\r\n            msgBox.exec();\r\n            return;\r\n        }\r\n\r\n        // Retrieve the component model.\r\n        QSharedPointer<Document> libComp = getLibraryInterface()->getModel(droppedVLNV);\r\n        QSharedPointer<Component> comp = libComp.staticCast<Component>();\r\n\r\n        // Set the instance name for the new component instance.\r\n        QString instanceName = createInstanceName(comp->getVlnv().getName());\r\n\r\n        // Act based on the selected drop action.\r\n        if (event->dropAction() == Qt::CopyAction)\r\n        {\r\n            // Determine the component stack who gets the component (either HW mapping item or a system column).\r\n            IGraphicsItemStack* stack = nullptr;\r\n\r\n            QList<QGraphicsItem*> itemList = items(event->scenePos());\r\n\r\n            if (!itemList.empty())\r\n            {\r\n                QGraphicsItem* item = itemList.back();\r\n\r\n                if (item != nullptr && item->type() == HWMappingItem::Type)\r\n                {\r\n                    stack = static_cast<HWMappingItem*>(item);\r\n                }\r\n            }\r\n\r\n            if (stack == nullptr)\r\n            {\r\n                stack = getLayout()->findColumnAt(snapPointToGrid(event->scenePos()));\r\n            }\r\n            \r\n            if (stack != nullptr)\r\n\t\t\t{\r\n\t\t\t\t// Create the diagram component.\r\n\t\t\t\tQSharedPointer<ComponentInstance> swInstance = createSWInstance(comp);\r\n\r\n                // Create the SW component item.\r\n                SWComponentItem* item = new SWComponentItem(getLibraryInterface(), comp, swInstance);\r\n                \r\n                item->setPos(stack->mapStackFromScene(snapPointToGrid(event->scenePos())));\r\n                connect(item, SIGNAL(openCSource(ComponentItem*)), this, SIGNAL(openCSource(ComponentItem*)));\r\n                connect(item, SIGNAL(errorMessage(QString const&)), this, SIGNAL(errorMessage(QString const&)));\r\n\r\n                // Create the undo command and execute it.\r\n                QSharedPointer<SystemComponentAddCommand> cmd(new SystemComponentAddCommand(stack, item, this));\r\n\r\n                connect(cmd.data(), SIGNAL(componentInstantiated(ComponentItem*)),\r\n                    this, SIGNAL(componentInstantiated(ComponentItem*)), Qt::UniqueConnection);\r\n                connect(cmd.data(), SIGNAL(componentInstanceRemoved(ComponentItem*)),\r\n                    this, SIGNAL(componentInstanceRemoved(ComponentItem*)), Qt::UniqueConnection);\r\n\r\n                getEditProvider()->addCommand(cmd);\r\n                cmd->redo();\r\n            }\r\n        }\r\n        else if (event->dropAction() == Qt::MoveAction)\r\n        {\r\n            // Replace the underlying component with the new one.\r\n\r\n            // Retrieve the old component (top-most component under the cursor).\r\n            SystemComponentItem* oldCompItem =\r\n                dynamic_cast<SystemComponentItem*>(getTopmostComponent(event->scenePos()));\r\n\r\n            Q_ASSERT(oldCompItem != nullptr);\r\n\r\n            QMessageBox msgBox(QMessageBox::Warning, QCoreApplication::applicationName(),\r\n                tr(\"Component instance '%1' is about to be replaced \"\r\n                \"with an instance of %2. Continue and replace?\").arg(oldCompItem->name(), droppedVLNV.toString()),\r\n                QMessageBox::Yes | QMessageBox::No, getParent());\r\n\r\n            if (msgBox.exec() == QMessageBox::No)\r\n            {\r\n                return;\r\n            }\r\n\r\n\t\t\t// Create the diagram component.\r\n\t\t\tQSharedPointer<ComponentInstance> swInstance = createSWInstance(comp);\r\n\r\n\t\t\t// Create the SW component item.\r\n\t\t\tSWComponentItem* newCompItem = new SWComponentItem(getLibraryInterface(), comp, swInstance);\r\n\r\n            // Perform the replacement.\r\n            QSharedPointer<ReplaceSystemComponentCommand> cmd(new ReplaceSystemComponentCommand(\r\n                oldCompItem, newCompItem, false, oldCompItem->type() == HWMappingItem::Type, getDesign(), this));\r\n\r\n            connect(cmd.data(), SIGNAL(componentInstantiated(ComponentItem*)),\r\n                this, SIGNAL(componentInstantiated(ComponentItem*)), Qt::UniqueConnection);\r\n            connect(cmd.data(), SIGNAL(componentInstanceRemoved(ComponentItem*)),\r\n                this, SIGNAL(componentInstanceRemoved(ComponentItem*)), Qt::UniqueConnection);\r\n\r\n            getEditProvider()->addCommand(cmd);\r\n            cmd->redo();\r\n        }\r\n    }\r\n    else if (dragType_ == DRAG_TYPE_HW)\r\n    {\r\n        // Retrieve the component.\r\n        QSharedPointer<Document> libComp = getLibraryInterface()->getModel(droppedVLNV);\r\n        QSharedPointer<Component> newComponent = libComp.staticCast<Component>();\r\n\r\n        // Check if the component does not have any hierarchical views.\r\n        if (newComponent->getHierViews().isEmpty())\r\n        {\r\n            QMessageBox msgBox(QMessageBox::Warning, QCoreApplication::applicationName(),\r\n                               tr(\"HW component '%1' does not contain any hierarchical views.\\n\"\r\n                               \"In order to add new HW components to the system design, the HW components must \"\r\n                               \"be added to the HW design.\").arg(droppedVLNV.toString()),\r\n QMessageBox::Ok, getParent());\r\n            msgBox.exec();\r\n            return;\r\n        }\r\n\r\n        // Determine a default suggestion for the view name.\r\n        QSettings settings;\r\n        QStringList suggestions = settings.value(\"Policies/SysViewNames\").toStringList();\r\n        \r\n        QString baseViewName = \"\";\r\n        QString viewName = \"\";\r\n\r\n        if (!suggestions.isEmpty())\r\n        {\r\n            baseViewName = suggestions.first();\r\n\r\n            viewName = baseViewName;\r\n            unsigned int runningNumber = 1;\r\n\r\n            while (newComponent->findSystemView(viewName) != nullptr)\r\n            {\r\n                ++runningNumber;\r\n                viewName = baseViewName + QString::number(runningNumber);\r\n            }\r\n        }\r\n\r\n        // Ask the user whether to move or copy the design under the given HW.\r\n        SwitchHWDialog dialog(newComponent, viewName, getLibraryInterface(), getParent());\r\n        dialog.setViewNameSuggestions(suggestions);\r\n        dialog.showHWViewSelector();\r\n\r\n        if (dialog.exec() == QDialog::Rejected)\r\n        {\r\n            return;\r\n        }\r\n\r\n        // Based on the action, either perform copy or move.\r\n        QSharedPointer<SystemView> newView( new SystemView(dialog.getSystemViewName()) );\r\n        newView->setHWViewRef(dialog.getHWViewRef());\r\n\r\n        if (dialog.isCopyActionSelected())\r\n        {\r\n            // Save copies of the design and design configuration.\r\n            VLNV vlnv = dialog.getVLNV();\r\n\r\n            VLNV designVLNV(VLNV::DESIGN, vlnv.getVendor(), vlnv.getLibrary(),\r\n                vlnv.getName() + \".sysdesign\", vlnv.getVersion());\r\n            VLNV desConfVLNV(VLNV::DESIGNCONFIGURATION, vlnv.getVendor(), vlnv.getLibrary(),\r\n                vlnv.getName() + \".sysdesigncfg\", vlnv.getVersion());\r\n\r\n            QSharedPointer<DesignConfiguration> desConf(new DesignConfiguration(*getDesignConfiguration()));\r\n            desConf->setVlnv(desConfVLNV);\r\n            desConf->setDesignRef(designVLNV);\r\n\r\n            QSharedPointer<Design> design = getDesign();\r\n            design->setVlnv(designVLNV);\r\n\r\n            getLibraryInterface()->writeModelToFile(dialog.getPath(), design);\r\n            getLibraryInterface()->writeModelToFile(dialog.getPath(), desConf);\r\n\r\n            // Set the new system view to point to the newly-saved design configuration.\r\n            newView->setHierarchyRef(desConfVLNV);\r\n        }\r\n        else\r\n        {\r\n            // Move is performed by removing the system view from the previous HW component and using\r\n            // the existing VLNV for the hierarchy reference.\r\n            newView->setHierarchyRef(getEditedComponent()->findSystemView(getParent()->getOpenViewName())->getHierarchyRef());\r\n\r\n\t\t\tfor ( QSharedPointer<VendorExtension> extension : *getEditedComponent()->getVendorExtensions() )\r\n\t\t\t{\r\n\t\t\t\tQSharedPointer<SystemView> currentView = extension.dynamicCast<SystemView>();\r\n\r\n\t\t\t\tif ( currentView && currentView->name() == getParent()->getOpenViewName() )\r\n\t\t\t\t{\r\n\t\t\t\t\tgetEditedComponent()->getVendorExtensions()->removeOne(currentView);\r\n\t\t\t\t\tbreak;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\r\n            getLibraryInterface()->writeModelToFile(getEditedComponent());\r\n        }\r\n\r\n        // Add the system view to the new HW component and save.\r\n        newComponent->getVendorExtensions()->append(newView);\r\n        getLibraryInterface()->writeModelToFile(newComponent);\r\n\r\n        // Refresh the design widget.\r\n        getParent()->setDesign(droppedVLNV, dialog.getSystemViewName());\r\n        getParent()->setProtection(false);\r\n        getParent()->refresh();\r\n    }\r\n    else if (dragType_ == DRAG_TYPE_DEFINITION)\r\n    {\r\n        if (dragEndPoint_ != nullptr)\r\n        {\r\n            Q_ASSERT(getLibraryInterface()->contains(droppedVLNV));\r\n\r\n            VLNV vlnv = droppedVLNV;\r\n            vlnv.setType(getLibraryInterface()->getDocumentType(droppedVLNV));\r\n\r\n            // Save old type and set the new one.\r\n            VLNV oldType = dragEndPoint_->getTypeDefinition();\r\n            dragEndPoint_->setTypeDefinition(vlnv);\r\n\r\n            // Create an undo command.\r\n            QSharedPointer<QUndoCommand> cmd(new TypeDefinitionChangeCommand(dragEndPoint_, oldType));\r\n            getEditProvider()->addCommand(cmd);\r\n\r\n            dragEndPoint_->setHighlight(ConnectionEndpoint::HIGHLIGHT_OFF);\r\n            dragEndPoint_ = nullptr;\r\n        }\r\n    }\r\n    else if (dragType_ == DRAG_TYPE_DESIGN)\r\n    {\r\n        // Retrieve the design.\r\n        QSharedPointer<Document> libComp = getLibraryInterface()->getModel(droppedVLNV);\r\n        QSharedPointer<Design> design = libComp.dynamicCast<Design>();\r\n\r\n        // Import elements to the column under cursor.\r\n        IGraphicsItemStack* column = getLayout()->findColumnAt(snapPointToGrid(event->scenePos()));\r\n        importDesign(design, column, event->scenePos());\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SystemDesignDiagram::createSWInstance()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<ComponentInstance> SystemDesignDiagram::createSWInstance(QSharedPointer<Component> comp)\r\n{\r\n\tQSharedPointer<ComponentInstance> swInstance(new ComponentInstance());\r\n\tQString instanceName = createInstanceName(comp->getVlnv().getName());\r\n\tswInstance->setInstanceName(instanceName);\r\n\tswInstance->setComponentRef( QSharedPointer<ConfigurableVLNVReference>(\r\n\t\tnew ConfigurableVLNVReference(comp->getVlnv()) ) );\r\n\r\n\treturn swInstance;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SystemDesignDiagram::getUsedInstanceNames()\r\n//-----------------------------------------------------------------------------\r\nQStringList SystemDesignDiagram::getUsedInstanceNames() const\r\n{\r\n    QStringList usedNames;\r\n\r\n    foreach (QSharedPointer<ComponentInstance> instance, *getDesign()->getComponentInstances())\r\n    {\r\n        usedNames.append(instance->getInstanceName());\r\n    }\r\n\r\n    return usedNames;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SystemDesignDiagram::updateDropAction()\r\n//-----------------------------------------------------------------------------\r\nvoid SystemDesignDiagram::updateDropAction(QGraphicsSceneDragDropEvent* event)\r\n{\r\n    if (dragType_ == DRAG_TYPE_SW)\r\n    {\r\n        // Find the top-most component under the cursor.\r\n        ComponentItem* item = getTopmostComponent(event->scenePos());\r\n\r\n        // If the underlying object is a HW mapping item, accept the drag here.\r\n        // TODO: Alt modifier for MoveAction?\r\n        if (item != nullptr && item->type() == HWMappingItem::Type)\r\n        {\r\n            HWMappingItem* mappingItem = static_cast<HWMappingItem*>(item);\r\n\r\n            if (mappingItem->componentModel()->isCpu())\r\n            {\r\n                event->setDropAction(Qt::CopyAction);\r\n            }\r\n            else\r\n            {\r\n                event->setDropAction(Qt::MoveAction);\r\n            }\r\n        }\r\n        else if (item != nullptr && item->type() == SWComponentItem::Type)\r\n        {\r\n            SWComponentItem* swCompItem = static_cast<SWComponentItem*>(item);\r\n\r\n            if (!swCompItem->isImported())\r\n            {\r\n                event->setDropAction(Qt::MoveAction);\r\n            }\r\n            else\r\n            {\r\n                event->setDropAction(Qt::IgnoreAction);\r\n            }\r\n        }\r\n        else\r\n        {\r\n            // Otherwise check which column should receive the SW component.\r\n            GraphicsColumn* column = getLayout()->findColumnAt(snapPointToGrid(event->scenePos()));\r\n\r\n            if (column != nullptr)\r\n            {\r\n                event->setDropAction(Qt::CopyAction);\r\n            }\r\n            else\r\n            {\r\n                event->setDropAction(Qt::IgnoreAction);\r\n            }\r\n        }\r\n\r\n        event->accept();\r\n    }\r\n    else if (dragType_ == DRAG_TYPE_HW)\r\n    {\r\n        QVariant data = event->mimeData()->imageData();\r\n\r\n        if (!data.canConvert<VLNV>())\r\n        {\r\n            return;\r\n        }\r\n\r\n        VLNV vlnv = data.value<VLNV>();\r\n\r\n        if (vlnv != getEditedComponent()->getVlnv())\r\n        {\r\n            event->setDropAction(Qt::LinkAction);\r\n        }\r\n        else\r\n        {\r\n            event->setDropAction(Qt::IgnoreAction);\r\n        }\r\n\r\n        event->accept();\r\n    }\r\n    else if (dragType_ == DRAG_TYPE_DEFINITION)\r\n    {\r\n        if (dragEndPoint_)\r\n        {\r\n            dragEndPoint_->setHighlight(ConnectionEndpoint::HIGHLIGHT_OFF);\r\n            dragEndPoint_ = nullptr;\r\n        }\r\n\r\n        // Check if there is an endpoint close enough the cursor.\r\n        SWConnectionEndpoint* endpoint =\r\n            DiagramUtil::snapToItem<SWConnectionEndpoint>(event->scenePos(), this, GridSize);\r\n\r\n        if (endpoint != nullptr && !endpoint->isInvalid())\r\n        {\r\n            dragEndPoint_ = endpoint;\r\n        }\r\n\r\n        // Allow the drop event if the end point is undefined or there are no connections\r\n        // and the encompassing component is unpackaged.\r\n        if (dragEndPoint_ != nullptr &&\r\n            (dragEndPoint_->getType() == SWConnectionEndpoint::ENDPOINT_TYPE_UNDEFINED ||\r\n            (!dragEndPoint_->isConnected() && dragEndPoint_->getOwnerComponent() != nullptr)))\r\n        {\r\n            event->setDropAction(Qt::CopyAction);\r\n            dragEndPoint_->setHighlight(SWConnectionEndpoint::HIGHLIGHT_HOVER);\r\n        }\r\n        else\r\n        {\r\n            event->setDropAction(Qt::IgnoreAction);\r\n        }\r\n    }\r\n    else if (dragType_ == DRAG_TYPE_DESIGN)\r\n    {\r\n        event->setDropAction(Qt::CopyAction);\r\n    }\r\n    else\r\n    {\r\n        event->setDropAction(Qt::IgnoreAction);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SystemDesignDiagram::openComponentActionEnabled()\r\n//-----------------------------------------------------------------------------\r\nbool SystemDesignDiagram::openComponentActionEnabled() const\r\n{\r\n    if (!singleSelection())\r\n    {\r\n        return false;\r\n    }\r\n\r\n    bool openEnabled = false;\r\n\r\n    QGraphicsItem* selectedItem = selectedItems().first();\r\n    if (selectedItem->type() == SWComponentItem::Type || selectedItem->type() == HWMappingItem::Type)\r\n    {\r\n        openEnabled = dynamic_cast<ComponentItem*>(selectedItem)->componentModel()->getVlnv().isValid();\r\n    }\r\n\r\n    return openEnabled;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SystemDesignDiagram::selectedItemIsCorrectType()\r\n//-----------------------------------------------------------------------------\r\nbool SystemDesignDiagram::selectedItemIsCorrectType() const\r\n{\r\n    int type = selectedItems().first()->type();\r\n\r\n    return type == SystemColumn::Type || type == SWComponentItem::Type || type == SWPortItem::Type ||\r\n        type == SWInterfaceItem::Type || type == ComGraphicsConnection::Type ||\r\n        type == ApiGraphicsConnection::Type || type == GraphicsConnection::Type || type == StickyNote::Type ||\r\n        type == Association::Type;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SystemDesignDiagram::isHierarchicalComponent()\r\n//-----------------------------------------------------------------------------\r\nbool SystemDesignDiagram::isHierarchicalComponent(QGraphicsItem* item) const\r\n{\r\n    SWComponentItem* component = qgraphicsitem_cast<SWComponentItem*>(item);\r\n    if (component)\r\n    {\r\n        return component->componentModel()->isHierarchical();\r\n    }\r\n\r\n    return false;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SystemDesignDiagram::copyActionEnabled()\r\n//-----------------------------------------------------------------------------\r\nbool SystemDesignDiagram::copyActionEnabled() const\r\n{\r\n    QList<QGraphicsItem*> items = selectedItems();    \r\n    if (items.empty())\r\n    {\r\n        return false;\r\n    }\r\n\r\n    int itemType = getCommonItemType(items);\r\n    return !isProtected() && (itemType == SWPortItem::Type || itemType == SWInterfaceItem::Type || \r\n        itemType == SWComponentItem::Type || itemType == SystemColumn::Type);     \r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SystemDesignDiagram::pasteActionEnabled()\r\n//-----------------------------------------------------------------------------\r\nbool SystemDesignDiagram::pasteActionEnabled() const\r\n{\r\n    QMimeData const* mimeData = QApplication::clipboard()->mimeData();\r\n    \r\n    if (isProtected() || !mimeData || !mimeData->hasImage())\r\n    {\r\n        return false;\r\n    }\r\n\r\n    bool pasteEnabled = false;\r\n\r\n    QList<QGraphicsItem*> items = selectedItems();    \r\n    if (items.empty())\r\n    {\r\n        pasteEnabled = mimeData->imageData().canConvert<ComponentCollectionCopyData>() ||\r\n            mimeData->imageData().canConvert<ColumnCollectionCopyData>() ||\r\n            (onlySW_ && mimeData->imageData().canConvert<PortCollectionCopyData>());\r\n    }\r\n    else\r\n    {\r\n        int type = getCommonItemType(items);\r\n\r\n        if (type == SWComponentItem::Type)\r\n        {\r\n            pasteEnabled = singleSelection() && draftSelected() && \r\n                mimeData->imageData().canConvert<PortCollectionCopyData>();\r\n        }\r\n        else if (type == SystemColumn::Type)\r\n        {\r\n            pasteEnabled = mimeData->imageData().canConvert<ColumnCollectionCopyData>();\r\n        }\r\n        else if (type == HWMappingItem::Type)\r\n        {\r\n            pasteEnabled = singleSelection() && mimeData->imageData().canConvert<ComponentCollectionCopyData>();\r\n        }\r\n    }\r\n\r\n    return pasteEnabled;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SystemDesignDiagram::openComponentByActiveView()\r\n//-----------------------------------------------------------------------------\r\nvoid SystemDesignDiagram::openComponentByActiveView(ComponentItem* comp)\r\n{\r\n    QString viewName = getActiveViewOf(comp);\r\n\r\n    // if view was found\r\n    if (comp->componentModel()->hasView(viewName) && hierarchicalViewsOf(comp).contains(viewName))\r\n    {\r\n        openDesignForComponent(comp, viewName);\r\n    }\r\n    else\r\n    {\r\n        openInComponentEditor(comp);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SystemDesignDiagram::hierarchicalViewsOf()\r\n//-----------------------------------------------------------------------------\r\nQStringList SystemDesignDiagram::hierarchicalViewsOf(ComponentItem* component) const\r\n{\r\n    return component->componentModel()->getHierViews();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SystemDesignDiagram::componentType()\r\n//-----------------------------------------------------------------------------\r\nint SystemDesignDiagram::componentType() const\r\n{\r\n    return SWComponentItem::Type;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SystemDesignDiagram::offpageConnectorType()\r\n//-----------------------------------------------------------------------------\r\nint SystemDesignDiagram::offpageConnectorType() const\r\n{\r\n    return OffPageConnectorItem::Type;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SystemDesignDiagram::connectionType()\r\n//-----------------------------------------------------------------------------\r\nint SystemDesignDiagram::connectionType() const\r\n{\r\n    return GraphicsConnection::Type;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: onSelected()\r\n//-----------------------------------------------------------------------------\r\nvoid SystemDesignDiagram::onSelected(QGraphicsItem* newSelection)\r\n{\r\n    // Activate the correct views when something has been selected.\r\n    if (newSelection)\r\n    { \r\n        // Check if the selected item was a component.\r\n        if (dynamic_cast<ComponentItem*>(newSelection) != nullptr)\r\n        {\r\n            ComponentItem* item = static_cast<ComponentItem*>(newSelection);\r\n            emit componentSelected(item);\r\n\r\n            if (item->componentModel()->getImplementation() == KactusAttribute::HW)\r\n            {\r\n                emit helpUrlRequested(\"swsysdesign/hwmappinginstance.html\");\r\n            }\r\n            else\r\n            {\r\n                emit helpUrlRequested(\"swsysdesign/swinstance.html\");\r\n            }\r\n        }\r\n        else if (dynamic_cast<ConnectionEndpoint*>(newSelection) != nullptr)\r\n        {\r\n            emit interfaceSelected(static_cast<ConnectionEndpoint*>(newSelection));\r\n        }\r\n        else if (dynamic_cast<GraphicsConnection*>(newSelection) != nullptr)\r\n        {\r\n            GraphicsConnection* conn = static_cast<GraphicsConnection*>(newSelection);\r\n            emit connectionSelected(conn);\r\n\r\n            if (conn->getConnectionType() == ConnectionEndpoint::ENDPOINT_TYPE_API)\r\n            {\r\n                emit helpUrlRequested(\"swsysdesign/apiconnection.html\");\r\n            }\r\n            else if (conn->getConnectionType() == ConnectionEndpoint::ENDPOINT_TYPE_COM)\r\n            {\r\n                emit helpUrlRequested(\"swsysdesign/comconnection.html\");\r\n            }\r\n            else\r\n            {\r\n                emit helpUrlRequested(\"swsysdesign/undefinedconnection.html\");\r\n            }\r\n        }\r\n        else\r\n        {\r\n            // Otherwise inform others that nothing is currently selected.\r\n            emit clearItemSelection();\r\n\r\n            if (onlySW_)\r\n            {\r\n                emit helpUrlRequested(\"swsysdesign/swdesign.html\");\r\n            }\r\n            else\r\n            {\r\n                emit helpUrlRequested(\"swsysdesign/systemdesign.html\");\r\n            }\r\n        }\r\n    }\r\n    else\r\n    {\r\n        // Clear the selection.\r\n        emit clearItemSelection();\r\n\r\n        if (onlySW_)\r\n        {\r\n            emit helpUrlRequested(\"swsysdesign/swdesign.html\");\r\n        }\r\n        else\r\n        {\r\n            emit helpUrlRequested(\"swsysdesign/systemdesign.html\");\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SystemDesignDiagram::loadDesign()\r\n//-----------------------------------------------------------------------------\r\nvoid SystemDesignDiagram::loadDesign(QSharedPointer<Design> design)\r\n{\r\n    if (design->getColumns().isEmpty())\r\n    {\r\n        if (onlySW_)\r\n        {\r\n            design->addColumn(QSharedPointer<ColumnDesc>(new ColumnDesc(\r\n                \"Low-level\", ColumnTypes::COMPONENTS, 0, GraphicsColumnConstants::COMPONENT_COLUMN_WIDTH)));\r\n            design->addColumn(QSharedPointer<ColumnDesc>(new ColumnDesc(\r\n                \"Middle-level\", ColumnTypes::COMPONENTS, 0, GraphicsColumnConstants::COMPONENT_COLUMN_WIDTH)));\r\n            design->addColumn(QSharedPointer<ColumnDesc>(new ColumnDesc(\r\n                \"High-level\", ColumnTypes::COMPONENTS, 0, GraphicsColumnConstants::COMPONENT_COLUMN_WIDTH)));\r\n            design->addColumn(QSharedPointer<ColumnDesc>(new ColumnDesc(\r\n                \"Out\", ColumnTypes::IO, 0, GraphicsColumnConstants::IO_COLUMN_WIDTH)));\r\n        }\r\n        else\r\n        {\r\n            design->addColumn(QSharedPointer<ColumnDesc>(new ColumnDesc(\r\n                \"SW Components\", ColumnTypes::COMPONENTS, 0, GraphicsColumnConstants::SYSTEM_COLUMN_WIDTH)));\r\n            design->addColumn(QSharedPointer<ColumnDesc>(new ColumnDesc(\r\n                \"SW Components\", ColumnTypes::COMPONENTS, 0, GraphicsColumnConstants::SYSTEM_COLUMN_WIDTH)));\r\n        }\r\n    }\r\n\r\n    QMultiMap<unsigned int, QSharedPointer<ColumnDesc> > orderedColumns;\r\n    for (QSharedPointer<ColumnDesc> desc : design->getColumns())\r\n    {\r\n        orderedColumns.insert(desc->getPosition(), desc);\r\n    }\r\n\r\n    for (QSharedPointer<ColumnDesc> containedColumn : orderedColumns)\r\n    {\r\n        SystemColumn* column = new SystemColumn(containedColumn, getLayout().data());\r\n        getLayout()->addColumn(column, true);\r\n    }\r\n\r\n    unsigned int colIndex = 0;\r\n\r\n    // Create (HW) component instances.\r\n    if (!onlySW_)\r\n    {\r\n        for (auto const& instance : *design->getComponentInstances())\r\n        {\r\n            QSharedPointer<Document> libComponent = getLibraryInterface()->getModel(*instance->getComponentRef());\r\n            QSharedPointer<Component> component = libComponent.staticCast<Component>();\r\n\r\n            // Only hardware components are applicable in this loop.\r\n            if (instance->isDraft() || component->getImplementation() != KactusAttribute::HW)\r\n            {\r\n                continue;\r\n            }\r\n\r\n            if (!component)\r\n            {\r\n                emit errorMessage(tr(\"The component '%1' instantiated in the design '%2' was not found in \" \r\n                    \"the library\").arg(instance->getComponentRef()->getName(), design->getVlnv().getName()));\r\n\r\n                // Create an unpackaged component so that we can still visualize the component instance->\r\n                component = QSharedPointer<Component>(new Component(*instance->getComponentRef(), getEditedComponent()->getRevision()));\r\n                component->setImplementation(KactusAttribute::HW);\r\n            }\r\n\r\n            HWMappingItem* item = new HWMappingItem(getLibraryInterface(), component, instance); //instance->getConfigurableElementValues());\r\n            if (instance->isImported())\r\n            {\r\n\t\t\t\titem->setImported(instance->isImported());\r\n\t\t\t\titem->setImportRef(instance->getImportRef());\r\n            }\r\n\r\n            item->setPropertyValues(instance->getPropertyValues());\r\n\r\n            connect(item, SIGNAL(errorMessage(QString const&)), this, SIGNAL(errorMessage(QString const&)));\r\n\r\n            // Check if the position is not found.\r\n            if (instance->getPosition().isNull())\r\n            {\r\n                getLayout()->getColumns().at(colIndex)->addItem(item);\r\n                colIndex = (colIndex + 1) % getLayout()->getColumns().size();\r\n            }\r\n            else\r\n            {\r\n                item->setPos(instance->getPosition());\r\n\r\n                GraphicsColumn* column = getLayout()->findColumnAt(instance->getPosition());\r\n\r\n                if (column != nullptr && column->isItemAllowed(item))\r\n                {\r\n                    column->addItem(item, true);\r\n                }\r\n                else\r\n                {\r\n                    getLayout()->getColumns().at(colIndex)->addItem(item);\r\n                    colIndex = (colIndex + 1) % getLayout()->getColumns().size();\r\n                }\r\n            }\r\n\r\n            onComponentInstanceAdded(item);\r\n        }\r\n    }\r\n\r\n    // Create SW instances.\r\n    for (auto const& instance : *design->getComponentInstances())\r\n    {\r\n        QSharedPointer<Component> component;\r\n\r\n        if (!instance->getComponentRef()->isEmpty())\r\n        {\r\n             component = getLibraryInterface()->getModel(*instance->getComponentRef()).dynamicCast<Component>();\r\n\r\n             if (!component && instance->getComponentRef()->isValid())\r\n             {\r\n                 emit errorMessage(tr(\"The SW component '%1' instantiated in the design '%2' was not found in \"\r\n                     \"the library\").arg(instance->getComponentRef()->getName(), design->getVlnv().getName()));\r\n             }           \r\n        }\r\n        \r\n        if(!component)\r\n        {\r\n            // Create an unpackaged component so that we can still visualize the component instance->\r\n            component = QSharedPointer<Component>(new Component(*instance->getComponentRef(), getEditedComponent()->getRevision()));\r\n            component->setImplementation(KactusAttribute::SW);\r\n        }\r\n\r\n        // Only software components are applicable in this loop.\r\n        if (component->getImplementation() != KactusAttribute::SW)\r\n        {\r\n            continue;\r\n        }\r\n\r\n        SWComponentItem* item = new SWComponentItem(getLibraryInterface(), component, instance);\r\n        connect(item, SIGNAL(openCSource(ComponentItem*)), this, SIGNAL(openCSource(ComponentItem*)));\r\n        connect(item, SIGNAL(errorMessage(QString const&)), this, SIGNAL(errorMessage(QString const&)));\r\n\r\n        if (instance->isImported())\r\n        {\r\n\t\t\titem->setImported(instance->isImported());\r\n\t\t\titem->setImportRef(instance->getImportRef());\r\n        }\r\n\r\n        item->setPos(instance->getPosition());\r\n        item->setPropertyValues(instance->getPropertyValues());\r\n        item->setFileSetRef(instance->getFileSetRef());\r\n\r\n        if (instance->isDraft())\r\n        {\r\n            item->setDraft();\r\n        }\r\n\r\n        if (instance->getMapping().isEmpty())\r\n        {\r\n            // Check if the position is not found.\r\n            if (instance->getPosition().isNull())\r\n            {\r\n                getLayout()->getColumns().at(colIndex)->addItem(item);\r\n                colIndex = (colIndex + 1) % getLayout()->getColumns().size();\r\n            }\r\n            else\r\n            {\r\n                GraphicsColumn* column = getLayout()->findColumnAt(instance->getPosition());\r\n\r\n                if (column != nullptr && column->isItemAllowed(item))\r\n                {\r\n                    column->addItem(item, true);\r\n                }\r\n                else\r\n                {\r\n                    getLayout()->getColumns().at(colIndex)->addItem(item);\r\n                    colIndex = (colIndex + 1) % getLayout()->getColumns().size();\r\n                }\r\n            }\r\n        }\r\n        else\r\n        {\r\n            // Otherwise the mapping has been specified. Find the corresponding HW component instance->\r\n            HWMappingItem* mappingItem = getHWComponentByUUID(instance->getMapping());\r\n\r\n            if (mappingItem != nullptr)\r\n            {\r\n                mappingItem->addItem(item, true);\r\n            }\r\n            else\r\n            {\r\n                getLayout()->getColumns().at(colIndex)->addItem(item);\r\n                colIndex = (colIndex + 1) % getLayout()->getColumns().size();\r\n            }\r\n        }\r\n\r\n        onComponentInstanceAdded(item);\r\n    }\r\n\r\n    if (onlySW_)\r\n    {\r\n        loadInterfaces(design);\r\n    }\r\n\r\n    loadApiDependencies(design);\r\n    loadComConnections(design);\r\n\r\n    // Refresh the layout of all HW mapping items.\r\n    if (!onlySW_)\r\n    {\r\n        for (QGraphicsItem* item : items())\r\n        {\r\n            if (item->type() == HWMappingItem::Type)\r\n            {\r\n                HWMappingItem* mappingItem = static_cast<HWMappingItem*>(item);\r\n                mappingItem->updateItemPositions();\r\n            }\r\n        }\r\n    }\r\n\r\n    // Refresh the layout so that all components are placed in correct positions according to the stacking.\r\n    getLayout()->updatePositions();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SystemDesignDiagram::loadInterfaces()\r\n//-----------------------------------------------------------------------------\r\nvoid SystemDesignDiagram::loadInterfaces(QSharedPointer<Design> design)\r\n{\r\n    QStringList componentInterfaceNames;\r\n\r\n    // Create SW interface items for the top-level API and COM interfaces.\r\n    for (QSharedPointer<ApiInterface> apiIf : getEditedComponent()->getApiInterfaces())\r\n    {\r\n        QSharedPointer<InterfaceGraphicsData> graphicsData = findOrCreateInterfaceGraphicsData(design, apiIf->name());\r\n\r\n        SWInterfaceItem* item (new SWInterfaceItem(getEditedComponent(), apiIf, graphicsData));\r\n\r\n        // Add the interface to the first column where it is allowed to be placed.\r\n        addInterfaceItemToLayout(item);\r\n\r\n        componentInterfaceNames.append(apiIf->name());\r\n    }\r\n\r\n    for (QSharedPointer<ComInterface> comIf : getEditedComponent()->getComInterfaces())\r\n    {\r\n        QSharedPointer<InterfaceGraphicsData> graphicsData = findOrCreateInterfaceGraphicsData(design, comIf->name());\r\n\r\n        SWInterfaceItem* item (new SWInterfaceItem(getEditedComponent(), comIf, graphicsData));\r\n\r\n        // Add the interface to the first column where it is allowed to be placed.\r\n        addInterfaceItemToLayout(item);\r\n\r\n        componentInterfaceNames.append(comIf->name());\r\n    }\r\n\r\n    for (QSharedPointer<InterfaceGraphicsData> graphicsData : design->getInterfaceGraphicsData())\r\n    {\r\n        if (!componentInterfaceNames.contains(graphicsData->getName()))\r\n        {\r\n            SWInterfaceItem* draftInterfaceItem (\r\n                new SWInterfaceItem(getEditedComponent(), graphicsData->getName(), graphicsData, 0));\r\n\r\n            addInterfaceItemToLayout(draftInterfaceItem);\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SystemDesignDiagram::findOrCreateInterfaceGraphicsData()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<InterfaceGraphicsData> SystemDesignDiagram::findOrCreateInterfaceGraphicsData(\r\n    QSharedPointer<Design> design, QString const& interfaceName)\r\n{\r\n    foreach (QSharedPointer<InterfaceGraphicsData> graphicsData, design->getInterfaceGraphicsData())\r\n    {\r\n        if (interfaceName == graphicsData->getName())\r\n        {\r\n            return graphicsData;\r\n        }\r\n    }\r\n\r\n    QSharedPointer<InterfaceGraphicsData> newGraphicsData (new InterfaceGraphicsData(interfaceName));\r\n    design->getVendorExtensions()->append(newGraphicsData);\r\n    return newGraphicsData;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SystemDesignDiagram::addInterfaceItemToLayout()\r\n//-----------------------------------------------------------------------------\r\nvoid SystemDesignDiagram::addInterfaceItemToLayout(SWInterfaceItem* item)\r\n{\r\n    GraphicsColumn* targetColumn = getLayout()->findColumnAt(item->scenePos());\r\n    if (targetColumn && targetColumn->isItemAllowed(item))\r\n    {\r\n        targetColumn->addItem(item);\r\n    }\r\n    else\r\n    {\r\n        getLayout()->addItem(item);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SystemDesignDiagram::loadComConnections()\r\n//-----------------------------------------------------------------------------\r\nvoid SystemDesignDiagram::loadComConnections(QSharedPointer<Design> design)\r\n{\r\n    for (QSharedPointer<ComInterconnection> conn : design->getComConnections())\r\n    {\r\n        ConnectionEndpoint* startPoint = findOrCreateEndpointItem(\r\n            conn->getStartInterface(), ConnectionEndpoint::ENDPOINT_TYPE_COM, conn->name(), design);\r\n        ConnectionEndpoint* endPoint = findOrCreateEndpointItem(\r\n            conn->getEndInterface(), ConnectionEndpoint::ENDPOINT_TYPE_COM, conn->name(), design);\r\n\r\n        if (startPoint && endPoint)\r\n        {\r\n            if (conn->isOffPage())\r\n            {\r\n                startPoint = startPoint->getOffPageConnector();\r\n                endPoint = endPoint->getOffPageConnector();\r\n            }\r\n\r\n            QSharedPointer<ConnectionRoute> comRoute = getInterconnectionRoute(conn->name());\r\n\r\n            ComGraphicsConnection* connection =\r\n                new ComGraphicsConnection(startPoint, endPoint, conn, comRoute, true, this);\r\n\r\n            if (comRoute->isOffpage())\r\n            {\r\n                connection->setVisible(false);\r\n            }\r\n\r\n            connect(connection, SIGNAL(errorMessage(QString const&)),\r\n                this, SIGNAL(errorMessage(QString const&)));\r\n\r\n            addItem(connection);\r\n            connection->updatePosition();\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SystemDesignDiagram::findOrCreateInterfaceItem()\r\n//-----------------------------------------------------------------------------\r\nConnectionEndpoint* SystemDesignDiagram::findOrCreateEndpointItem(QSharedPointer<HierInterface> endpointInterface,\r\n    SWConnectionEndpoint::EndpointType type, QString const& connectionName,\r\n    QSharedPointer<Design> containingDesign)\r\n{\r\n    auto interfaceReference = endpointInterface->getBusReference();\r\n    QSharedPointer<ActiveInterface> activeReference = endpointInterface.dynamicCast<ActiveInterface>();\r\n    if (activeReference)\r\n    {\r\n        QString componentReference = activeReference->getComponentReference();\r\n        SystemComponentItem* componentItem = getComponent(componentReference);\r\n        if (!componentItem)\r\n        {\r\n            emit errorMessage(\r\n                tr(\"Component '%1' containing interface '%2' in connection '%3' was not found in the design.\")\r\n                .arg(componentReference).arg(endpointInterface->getBusReference()).arg(connectionName));\r\n        }\r\n        else\r\n        {\r\n            return findOrCreateSWPortItem(componentItem, interfaceReference, type, containingDesign);\r\n        }\r\n    }\r\n    else\r\n    {\r\n        SWInterfaceItem* interfaceEndpoint = getSWInterfaceItem(endpointInterface->getBusReference());\r\n        if (interfaceEndpoint->getType() == ConnectionEndpoint::ENDPOINT_TYPE_COM)\r\n        {\r\n            QSharedPointer<ComInterface> componentCom = getEditedComponent()->getComInterface(interfaceReference);\r\n            if (!componentCom)\r\n            {\r\n                return createDummyInterface(\"COM\", interfaceReference);\r\n            }\r\n        }\r\n        else if (interfaceEndpoint->getType() == ConnectionEndpoint::ENDPOINT_TYPE_API)\r\n        {\r\n            QSharedPointer<ApiInterface> componentApi = getEditedComponent()->getApiInterface(interfaceReference);\r\n            if (!componentApi)\r\n            {\r\n                return createDummyInterface(\"API\", interfaceReference);\r\n            }\r\n        }\r\n\r\n        return interfaceEndpoint;\r\n    }\r\n\r\n    return nullptr;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SystemDesignDiagram::getSWInterfaceItem()\r\n//-----------------------------------------------------------------------------\r\nSWInterfaceItem* SystemDesignDiagram::getSWInterfaceItem(QString const& interfaceName) const\r\n{\r\n    SWInterfaceItem* endPoint = nullptr;\r\n\r\n    for (QGraphicsItem* graphicsItem : items())\r\n    {\r\n        if (graphicsItem->type() == SWInterfaceItem::Type)\r\n        {\r\n            SWInterfaceItem* interfaceItem = qgraphicsitem_cast<SWInterfaceItem*>(graphicsItem);\r\n            if (interfaceItem && interfaceName == interfaceItem->name())\r\n            {\r\n                endPoint = interfaceItem;\r\n                break;\r\n            }\r\n        }\r\n    }\r\n\r\n    return endPoint;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SystemDesignDiagram::createDummyInterface()\r\n//-----------------------------------------------------------------------------\r\nConnectionEndpoint* SystemDesignDiagram::createDummyInterface(QString const& itemType,\r\n    QString const& interfaceReference)\r\n{\r\n    emit errorMessage(tr(\"%1 interface '%2' was not found within the top component\").\r\n        arg(itemType).arg(interfaceReference));\r\n\r\n    QSharedPointer<InterfaceGraphicsData> graphicsData (new InterfaceGraphicsData(interfaceReference));\r\n    getDesign()->getVendorExtensions()->append(graphicsData);\r\n\r\n    ConnectionEndpoint* hierarchicalInterface =\r\n        new SWInterfaceItem(getEditedComponent(), interfaceReference, graphicsData, nullptr);\r\n    hierarchicalInterface->setTemporary(true);\r\n    hierarchicalInterface->updateInterface();\r\n\r\n    return hierarchicalInterface;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SystemDesignDiagram::findOrCreatePortItem()\r\n//-----------------------------------------------------------------------------\r\nConnectionEndpoint* SystemDesignDiagram::findOrCreateSWPortItem(SystemComponentItem* containingItem,\r\n    QString const& interfaceReference, SWConnectionEndpoint::EndpointType type,\r\n    QSharedPointer<Design> containingDesign)\r\n{\r\n    ConnectionEndpoint* portEndpoint = containingItem->getSWPort(interfaceReference, type);\r\n\r\n    if (!portEndpoint)\r\n    {\r\n        QString interfaceType = \"API\";\r\n        if (type == SWConnectionEndpoint::ENDPOINT_TYPE_COM)\r\n        {\r\n            interfaceType = \"COM\";\r\n        }\r\n\r\n        emit errorMessage(tr(\"%1 interface '%2' was not found in the component '%3'\").\r\n            arg(interfaceType, interfaceReference,containingItem->name()));\r\n\r\n        portEndpoint = createMissingPort(interfaceReference, ConnectionEndpoint::ENDPOINT_TYPE_UNDEFINED,\r\n            containingItem, containingDesign);\r\n    }\r\n\r\n    return portEndpoint;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SystemDesignDiagram::getInterconnectionRoute()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<ConnectionRoute> SystemDesignDiagram::getInterconnectionRoute(QString const& interconnectionName)\r\n    const\r\n{\r\n    for (QSharedPointer<ConnectionRoute> route : getDesign()->getRoutes())\r\n    {\r\n        if (route->name() == interconnectionName)\r\n        {\r\n            return route;\r\n        }\r\n    }\r\n\r\n    return QSharedPointer<ConnectionRoute> (new ConnectionRoute(interconnectionName));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SystemDesignDiagram::loadApiDependencies()\r\n//-----------------------------------------------------------------------------\r\nvoid SystemDesignDiagram::loadApiDependencies(QSharedPointer<Design> design)\r\n{\r\n    for (QSharedPointer<ApiInterconnection> dependency: design->getApiConnections())\r\n    {\r\n        ConnectionEndpoint* startPoint = findOrCreateEndpointItem(\r\n            dependency->getStartInterface(), ConnectionEndpoint::ENDPOINT_TYPE_API, dependency->name(), design);\r\n        ConnectionEndpoint* endPoint = findOrCreateEndpointItem(\r\n            dependency->getEndInterface(), ConnectionEndpoint::ENDPOINT_TYPE_API, dependency->name(), design);\r\n\r\n        if (dependency->isOffPage())\r\n        {\r\n            startPoint = startPoint->getOffPageConnector();\r\n            endPoint = endPoint->getOffPageConnector();\r\n        }\r\n\r\n        QSharedPointer<ConnectionRoute> apiRoute = getInterconnectionRoute(dependency->name());\r\n        ApiGraphicsConnection* connection =\r\n            new ApiGraphicsConnection(startPoint, endPoint, dependency, apiRoute, true, this);\r\n\r\n        connection->setImported(dependency->isImported());\r\n\r\n        if (apiRoute->isOffpage())\r\n        {\r\n            connection->setVisible(false);\r\n        }\r\n\r\n        connect(connection, SIGNAL(errorMessage(QString const&)),\r\n            this, SIGNAL(errorMessage(QString const&)));\r\n\r\n        addItem(connection);\r\n        connection->updatePosition();\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: getHWComponent()\r\n//-----------------------------------------------------------------------------\r\nHWMappingItem* SystemDesignDiagram::getHWComponent(QString const& instanceName)\r\n{\r\n    foreach (QGraphicsItem *item, items())\r\n    {\r\n        if (item->type() == HWMappingItem::Type)\r\n        {\r\n            HWMappingItem* comp = qgraphicsitem_cast<HWMappingItem*>(item);\r\n\r\n            if (comp->name() == instanceName)\r\n            {\r\n                return comp;\r\n            }\r\n        }\r\n    }\r\n\r\n    emit errorMessage(tr(\"Component %1 was not found in the design\").arg(instanceName));\r\n    return nullptr;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: getHWComponent()\r\n//-----------------------------------------------------------------------------\r\nHWMappingItem* SystemDesignDiagram::getHWComponentByUUID(QString const& uuid)\r\n{\r\n    foreach (QGraphicsItem *item, items())\r\n    {\r\n        if (item->type() == HWMappingItem::Type)\r\n        {\r\n            HWMappingItem* comp = qgraphicsitem_cast<HWMappingItem*>(item);\r\n\r\n            if (comp->getUuid() == uuid)\r\n            {\r\n                return comp;\r\n            }\r\n        }\r\n    }\r\n\r\n    emit errorMessage(tr(\"Component with UUID %1 was not found in the design\").arg(uuid));\r\n    return nullptr;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SystemDesignDiagram::getComponent()\r\n//-----------------------------------------------------------------------------\r\nSystemComponentItem* SystemDesignDiagram::getComponent(QString const& instanceName)\r\n{\r\n    for (QGraphicsItem *item : items())\r\n    {\r\n        SystemComponentItem* comp = dynamic_cast<SystemComponentItem*>(item);\r\n\r\n        if (comp != nullptr && comp->name() == instanceName)\r\n        {\r\n            return comp;\r\n        }\r\n    }\r\n\r\n    emit errorMessage(tr(\"Component %1 was not found in the design\").arg(instanceName));\r\n    return nullptr;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SystemDesignDiagram::createMissingPort()\r\n//-----------------------------------------------------------------------------\r\nSWPortItem* SystemDesignDiagram::createMissingPort(QString const&  portName, ConnectionEndpoint::EndpointType type,\r\n                                                   SystemComponentItem* component, QSharedPointer<Design> design)\r\n{\r\n    SWPortItem* port = new SWPortItem(portName, component->componentModel(), component);\r\n    component->addPort(port);\r\n\r\n    for (QSharedPointer<ComponentInstance> instance : *design->getComponentInstances())\r\n    {\r\n        if (instance->getInstanceName() == component->name())\r\n        {\r\n            if (type == ConnectionEndpoint::ENDPOINT_TYPE_API)\r\n            {\r\n                port->setPos(instance->getApiInterfacePositions().value(portName));\r\n            }\r\n            else if (type == ConnectionEndpoint::ENDPOINT_TYPE_COM)\r\n            {\r\n                port->setPos(instance->getComInterfacePositions().value(portName));\r\n            }\r\n\r\n            component->onMovePort(port);\r\n            return port;\r\n        }\r\n    }\r\n\r\n    return port;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SystemDesignDiagram::importDesign()\r\n//-----------------------------------------------------------------------------\r\nvoid SystemDesignDiagram::importDesign(QSharedPointer<Design> design, IGraphicsItemStack* stack,\r\n                                       QPointF const& guidePos)\r\n{\r\n    // Map which hold name mappings for SW instances.\r\n    QMap<QString, QString> nameMappings;\r\n\r\n    // Import SW instances.\r\n    for (QSharedPointer<ComponentInstance> instance : *design->getComponentInstances())\r\n    {\r\n        QSharedPointer<Document> libComponent = getLibraryInterface()->getModel(*instance->getComponentRef());\r\n        QSharedPointer<Component> component = libComponent.staticCast<Component>();\r\n\r\n        if (!component)\r\n        {\r\n            emit errorMessage(tr(\"SW component %1 instantiated in the imported design was not \"\r\n                                 \"found in the library\").arg(instance->getComponentRef()->toString()));\r\n\r\n            // Create an unpackaged component so that we can still visualize the component instance->\r\n            component = QSharedPointer<Component>(new Component(*instance->getComponentRef(), getEditedComponent()->getRevision()));\r\n            component->setImplementation(KactusAttribute::SW);\r\n        }\r\n\r\n        // Only software components are applicable in this loop.\r\n        if (component->getImplementation() != KactusAttribute::SW)\r\n        {\r\n            continue;\r\n        }\r\n\r\n        // Determine a unique name for the instance->\r\n        QString instanceName = instance->getInstanceName();\r\n\r\n        if (getComponent(instanceName) != nullptr)\r\n        {\r\n            instanceName = createInstanceName(instanceName);\r\n        }\r\n\r\n        nameMappings.insert(instance->getInstanceName(), instanceName);\r\n\r\n        SWComponentItem* item = new SWComponentItem(getLibraryInterface(), component, instance);\r\n        item->setImported(instance->isImported());\r\n        item->setImportRef(instance->getImportRef());\r\n        item->setPos(stack->mapStackFromScene(guidePos));\r\n        item->setPropertyValues(instance->getPropertyValues());\r\n        item->setFileSetRef(instance->getFileSetRef());\r\n\r\n        connect(item, SIGNAL(openCSource(ComponentItem*)), this, SIGNAL(openCSource(ComponentItem*)));\r\n        connect(item, SIGNAL(errorMessage(QString const&)), this, SIGNAL(errorMessage(QString const&)));\r\n        \r\n        // Add the instance to the specified stack.\r\n        stack->addItem(item);\r\n    }\r\n\r\n    // Import API dependencies.\r\n    for (QSharedPointer<ApiInterconnection> dependency : design->getApiConnections())\r\n    {\r\n        // Find the referenced components.\r\n        QString startComponentReference = dependency->getStartInterface()->getComponentReference();\r\n        QString startApiReference = dependency->getStartInterface()->getBusReference();\r\n\r\n        SystemComponentItem* comp1 = getComponent(nameMappings.value(startComponentReference));\r\n\r\n        if (comp1 == nullptr)\r\n        {\r\n            emit errorMessage(tr(\"Component '%1' was not found in the design\").\r\n                arg(nameMappings.value(startComponentReference)));\r\n            continue;\r\n        }\r\n\r\n        QString endComponentReference = \"\";\r\n        QString endApiReference = dependency->getEndInterface()->getBusReference();\r\n\r\n        SystemComponentItem* comp2 = nullptr;\r\n\r\n        QSharedPointer<ActiveInterface> activeEndInterface =\r\n            dependency->getEndInterface().dynamicCast<ActiveInterface>();\r\n        if (activeEndInterface)\r\n        {\r\n            endComponentReference = activeEndInterface->getComponentReference();\r\n\r\n            comp2 = getComponent(nameMappings.value(endComponentReference));\r\n            if (comp2 == nullptr)\r\n            {\r\n                emit errorMessage(tr(\"Component '%1' was not found in the design\").\r\n                    arg(nameMappings.value(endComponentReference)));\r\n                continue;\r\n            }\r\n        }\r\n\r\n        // Find the connected ports in the components.\r\n        ConnectionEndpoint* port1 = static_cast<SWPortItem*>(comp1->getSWPort(startApiReference,\r\n            SWConnectionEndpoint::ENDPOINT_TYPE_API));\r\n\r\n        if (port1 == nullptr)\r\n        {\r\n            emit errorMessage(tr(\"API interface '%1' was not found in the component '%2'\").\r\n                arg(startApiReference).arg(startComponentReference));\r\n\r\n            port1 = createMissingPort(startApiReference, SWConnectionEndpoint::ENDPOINT_TYPE_API, comp1, design);\r\n        }\r\n\r\n        ConnectionEndpoint* port2 = static_cast<SWPortItem*>(comp2->getSWPort(endApiReference,\r\n            SWConnectionEndpoint::ENDPOINT_TYPE_API));\r\n\r\n        if (port2 == nullptr)\r\n        {\r\n            emit errorMessage(tr(\"API interface '%1' was not found in the component '%2'\").\r\n                arg(endApiReference).arg(endComponentReference));\r\n\r\n            port2 = createMissingPort(endApiReference, SWConnectionEndpoint::ENDPOINT_TYPE_API, comp2, design);\r\n        }\r\n\r\n        if (dependency->isOffPage())\r\n        {\r\n            port1 = port1->getOffPageConnector();\r\n            port2 = port2->getOffPageConnector();\r\n        }\r\n\r\n        QSharedPointer<ConnectionRoute> apiRoute = getInterconnectionRoute(dependency->name());\r\n\r\n        auto connection = new ApiGraphicsConnection(port1, port2, dependency, apiRoute, true, this);\r\n        connection->setImported(dependency->isImported());\r\n\r\n        if (dependency->isOffPage())\r\n        {\r\n            connection->setVisible(false);\r\n        }\r\n\r\n        connect(connection, SIGNAL(errorMessage(QString const&)),\r\n            this, SIGNAL(errorMessage(QString const&)));\r\n\r\n        addItem(connection);\r\n        connection->updatePosition();\r\n    }\r\n\r\n    // Import COM connections.\r\n    for (QSharedPointer<ComInterconnection> conn : design->getComConnections())\r\n    {\r\n        // Find the referenced components.\r\n        QString startComponentReference = conn->getStartInterface()->getComponentReference();\r\n        QString startComReference = conn->getStartInterface()->getBusReference();\r\n\r\n        SystemComponentItem* comp1 = getComponent(nameMappings.value(startComponentReference));\r\n\r\n        if (comp1 == nullptr)\r\n        {\r\n            emit errorMessage(tr(\"Component '%1' was not found in the design\").\r\n                arg(nameMappings.value(startComponentReference)));\r\n            continue;\r\n        }\r\n\r\n        SystemComponentItem* comp2 = nullptr;\r\n\r\n        QString endComponentReference =\"\";\r\n        QString endcomReference = conn->getEndInterface()->getBusReference();\r\n        QSharedPointer<ActiveInterface> activeEndInterface = conn->getEndInterface().dynamicCast<ActiveInterface>();\r\n        if (activeEndInterface)\r\n        {\r\n            endComponentReference = activeEndInterface->getComponentReference();\r\n            comp2 = getComponent(nameMappings.value(endComponentReference));\r\n\r\n            if (comp2 == nullptr)\r\n            {\r\n                emit errorMessage(tr(\"Component '%1' was not found in the design\").arg(\r\n                    nameMappings.value(endComponentReference)));\r\n                continue;\r\n            }\r\n        }\r\n\r\n        // Find the connected ports in the components.\r\n        ConnectionEndpoint* port1 = comp1->getSWPort(startComReference,\r\n            SWConnectionEndpoint::ENDPOINT_TYPE_COM);\r\n\r\n        if (port1 == nullptr)\r\n        {\r\n            emit errorMessage(tr(\"COM interface '%1' was not found in the component '%2'\").\r\n                arg(startComReference).arg(startComponentReference));\r\n            continue;\r\n        }\r\n\r\n        ConnectionEndpoint* port2 = nullptr;\r\n        if (comp2 != nullptr)\r\n        {\r\n            port2 = comp2->getSWPort(endcomReference, SWConnectionEndpoint::ENDPOINT_TYPE_COM);\r\n        }\r\n\r\n        if (port2 == nullptr)\r\n        {\r\n            emit errorMessage(tr(\"API interface '%1' was not found in the component '%2'\").\r\n                arg(endcomReference).arg(endComponentReference));\r\n            continue;\r\n        }\r\n\r\n        if (conn->isOffPage())\r\n        {\r\n            port1 = port1->getOffPageConnector();\r\n            port2 = port2->getOffPageConnector();\r\n        }\r\n\r\n        QSharedPointer<ConnectionRoute> comRoute = getInterconnectionRoute(conn->name());\r\n\r\n        auto connection = new ComGraphicsConnection(port1, port2, conn, comRoute, true, this);\r\n\r\n        if (conn->isOffPage())\r\n        {\r\n            connection->setVisible(false);\r\n        }\r\n\r\n        connect(connection, SIGNAL(errorMessage(QString const&)),\r\n            this, SIGNAL(errorMessage(QString const&)));\r\n\r\n        addItem(connection);\r\n        connection->updatePosition();\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SystemDesignDiagram::createConnection()\r\n//-----------------------------------------------------------------------------\r\nGraphicsConnection* SystemDesignDiagram::createConnection(ConnectionEndpoint* startPoint, \r\n    ConnectionEndpoint* endPoint, bool /*isOffPage*/)\r\n{\r\n    QSharedPointer<ConnectionRoute> route(new ConnectionRoute(\"\"));\r\n\r\n    GraphicsConnection* connection;\r\n\r\n    if (startPoint->isCom() || endPoint->isCom())\r\n    {\r\n        QSharedPointer<ComInterconnection> interconnection(new ComInterconnection());\r\n\r\n        QSharedPointer<HierInterface> startInterface = createEndpointInterface(startPoint);\r\n        interconnection->setInterface(startInterface);\r\n\r\n        QSharedPointer<HierInterface> endInterface = createEndpointInterface(endPoint);\r\n        interconnection->setInterface(endInterface);\r\n\r\n        ComGraphicsConnection* comGraphicsConnection =\r\n            new ComGraphicsConnection(startPoint, endPoint, interconnection, route, false, this);\r\n\r\n        auto connectionName = comGraphicsConnection->createDefaultName();\r\n        comGraphicsConnection->setName(connectionName);\r\n\r\n        connection = comGraphicsConnection;\r\n    }\r\n    else\r\n    {\r\n        QSharedPointer<ApiInterconnection> interconnection (new ApiInterconnection());\r\n\r\n        QSharedPointer<HierInterface> startInterface = createEndpointInterface(startPoint);\r\n        interconnection->setInterface(startInterface);\r\n\r\n        QSharedPointer<HierInterface> endInterface = createEndpointInterface(endPoint);\r\n        interconnection->setInterface(endInterface);\r\n\r\n        ApiGraphicsConnection* apiGraphicsConnection =\r\n            new ApiGraphicsConnection(startPoint, endPoint, interconnection, route, false, this);\r\n\r\n        auto connectionName = apiGraphicsConnection->createDefaultName();\r\n        apiGraphicsConnection->setName(connectionName);\r\n\r\n        connection = apiGraphicsConnection;\r\n    }\r\n\r\n    return connection;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SystemDesignDiagram::createEndpointInterface()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<HierInterface> SystemDesignDiagram::createEndpointInterface(ConnectionEndpoint* connectionPoint)\r\n{\r\n    QString componentReference;\r\n    QString endPointName = connectionPoint->name();\r\n\r\n    SWPortItem* portItem = dynamic_cast<SWPortItem*>(connectionPoint);\r\n    if (portItem)\r\n    {\r\n        componentReference = connectionPoint->encompassingComp()->name();\r\n    }\r\n    else\r\n    {\r\n        SWInterfaceItem* interfaceItem = dynamic_cast<SWInterfaceItem*>(connectionPoint);\r\n        if (interfaceItem)\r\n        {\r\n            componentReference = interfaceItem->getOwnerComponent()->getVlnv().getName();\r\n        }\r\n    }\r\n\r\n    QSharedPointer<HierInterface> endPointInterface;\r\n\r\n    QString editedComponentName = getEditedComponent()->getVlnv().getName();\r\n    if (componentReference == editedComponentName)\r\n    {\r\n        endPointInterface = QSharedPointer<HierInterface> (new HierInterface(endPointName));\r\n    }\r\n    else\r\n    {\r\n        endPointInterface =\r\n            QSharedPointer<ActiveInterface> (new ActiveInterface(componentReference, endPointName));\r\n    }\r\n\r\n    return endPointInterface;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SystemDesignDiagram::createConnection()\r\n//-----------------------------------------------------------------------------\r\nGraphicsConnection* SystemDesignDiagram::createConnection(ConnectionEndpoint* startPoint, QPointF const& endPoint)\r\n{\r\n    GraphicsConnection* connection;\r\n\r\n    if (startPoint->isCom())\r\n    {\r\n        connection = new ComGraphicsConnection(startPoint->scenePos(), startPoint->getDirection(), endPoint,\r\n            QVector2D(0.0f, 0.0f), this);\r\n    }\r\n    else\r\n    {\r\n        connection = new ApiGraphicsConnection(startPoint->scenePos(), startPoint->getDirection(), endPoint,\r\n            QVector2D(0.0f, 0.0f), this);\r\n    }\r\n\r\n    connection->setZValue(1000);\r\n\r\n    return connection;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SystemDesignDiagram::createAddCommandForConnection()\r\n//-----------------------------------------------------------------------------\r\nQUndoCommand* SystemDesignDiagram::createAddCommandForConnection(GraphicsConnection* connection, QUndoCommand* /*parentCommand*/)\r\n{\r\n    ApiGraphicsConnection* apiConnection = dynamic_cast<ApiGraphicsConnection*>(connection);\r\n    if (apiConnection)\r\n    {\r\n        return new ApiConnectionAddCommand(this, apiConnection, getDesign());\r\n    }\r\n    else\r\n    {\r\n        ComGraphicsConnection* comConnection = dynamic_cast<ComGraphicsConnection*>(connection);\r\n        if (comConnection)\r\n        {\r\n            return new ComConnectionAddCommand(this, comConnection, getDesign());\r\n        }\r\n    }\r\n\r\n    return nullptr;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SystemDesignDiagram::addTopLevelInterface()\r\n//-----------------------------------------------------------------------------\r\nvoid SystemDesignDiagram::addTopLevelInterface(GraphicsColumn* column, QPointF const& pos, bool /*isDraft*/)\r\n{\r\n    QString interfaceName = createDraftInterfaceName(\"interface\");\r\n    QSharedPointer<InterfaceGraphicsData> graphicsData (new InterfaceGraphicsData(interfaceName));\r\n\r\n    SWInterfaceItem* newItem = new SWInterfaceItem(getEditedComponent(), interfaceName, graphicsData, 0);\r\n\r\n    newItem->setPos(snapPointToGrid(pos));\r\n\r\n    // Save the positions of the other interfaces.\r\n    QMap<SWInterfaceItem*, QPointF> oldPositions;\r\n\r\n    for (QGraphicsItem* item : column->childItems())\r\n    {\r\n        if (item->type() == SWInterfaceItem::Type)\r\n        {\r\n            SWInterfaceItem* interface = static_cast<SWInterfaceItem*>(item);\r\n            oldPositions.insert(interface, interface->scenePos());\r\n        }\r\n    }\r\n\r\n    QSharedPointer<QUndoCommand> cmd(new SWInterfaceAddCommand(column, newItem, getDesign()));\r\n    cmd->redo();\r\n\r\n    // Determine if the other interfaces changed their position and create undo commands for them.\r\n    QMap<SWInterfaceItem*, QPointF>::iterator cur = oldPositions.begin();\r\n\r\n    while (cur != oldPositions.end())\r\n    {\r\n        if (cur.key()->scenePos() != cur.value())\r\n        {\r\n            new ItemMoveCommand(cur.key(), cur.value(), column, this, cmd.data());\r\n        }\r\n\r\n        ++cur;\r\n    }\r\n\r\n    getEditProvider()->addCommand(cmd);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SystemDesignDiagram::createDraftInterfaceName()\r\n//-----------------------------------------------------------------------------\r\nQString SystemDesignDiagram::createDraftInterfaceName(QString const& baseName) const\r\n{\r\n    // Determine a unique name by using a running number.\r\n    int runningNumber = 0;\r\n\r\n    QStringList interfaceNames;\r\n    for (QSharedPointer<ApiInterface> apiInterface : getEditedComponent()->getApiInterfaces())\r\n    {\r\n        interfaceNames.append(apiInterface->name());\r\n    }\r\n    for (QSharedPointer<ComInterface> comInterface : getEditedComponent()->getComInterfaces())\r\n    {\r\n        interfaceNames.append(comInterface->name());\r\n    }\r\n    for (QSharedPointer<InterfaceGraphicsData> graphicsData : getDesign()->getInterfaceGraphicsData())\r\n    {\r\n        if (!interfaceNames.contains(graphicsData->getName()))\r\n        {\r\n            interfaceNames.append(graphicsData->getName());\r\n        }\r\n    }\r\n\r\n\r\n    QString format = \"$InterfaceName$_$InterfaceNumber$\";\r\n    QString name = baseName;\r\n\r\n    while (interfaceNames.contains(name))\r\n    {\r\n        name = format;\r\n        name.replace(\"$InterfaceName$\", baseName);\r\n        name.replace(\"$InterfaceNumber$\", QString::number(runningNumber));\r\n\r\n        runningNumber++;\r\n    }\r\n\r\n    return name;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SystemDesignDiagram::draftAt()\r\n//-----------------------------------------------------------------------------\r\nvoid SystemDesignDiagram::draftAt(QPointF const& clickedPosition)\r\n{\r\n    // Find the bottom-most item under the cursor.\r\n    QGraphicsItem* item = nullptr;\r\n    QList<QGraphicsItem*> itemList = items(clickedPosition);\r\n\r\n    if (!itemList.empty())\r\n    {\r\n        item = itemList.front();\r\n\r\n        while (item->parentItem() != nullptr && dynamic_cast<SystemComponentItem*>(item) == nullptr)\r\n        {\r\n            item = item->parentItem();\r\n        }\r\n    }\r\n\r\n    // If the item was a SW component, add an undefined interface port to it.\r\n    if (item != nullptr && item->type() == SWComponentItem::Type)\r\n    {\r\n        SWComponentItem* comp = static_cast<SWComponentItem*>(item);\r\n\r\n        // The component is unpackaged if it has an invalid vlnv.\r\n        if (!comp->componentModel()->getVlnv().isValid())\r\n        {\r\n            QMap<SWPortItem*, QPointF> oldPositions;\r\n\r\n            // Save old port positions.\r\n            for (QGraphicsItem* item : comp->childItems())\r\n            {\r\n                if (item->type() == SWPortItem::Type)\r\n                {\r\n                    SWPortItem* port = static_cast<SWPortItem*>(item);\r\n                    oldPositions.insert(port, port->pos());\r\n                }\r\n            }\r\n\r\n            QSharedPointer<QUndoCommand> cmd(new SWPortAddCommand(comp, snapPointToGrid(clickedPosition), this));\r\n            cmd->redo();\r\n\r\n            // Create child undo commands for the changed ports.\r\n            QMap<SWPortItem*, QPointF>::iterator cur = oldPositions.begin();\r\n\r\n            while (cur != oldPositions.end())\r\n            {\r\n                if (cur.key()->pos() != cur.value())\r\n                {\r\n                    new SWPortMoveCommand(cur.key(), cur.value(), this, cmd.data());\r\n                }\r\n\r\n                ++cur;\r\n            }\r\n\r\n            // Add the command to the edit stack.\r\n            getEditProvider()->addCommand(cmd);\r\n        }\r\n    }\r\n    else if (item == nullptr || item->type() == HWMappingItem::Type)\r\n    {\r\n        IGraphicsItemStack* stack = nullptr;\r\n\r\n        if (item != nullptr)\r\n        {\r\n            stack = dynamic_cast<IGraphicsItemStack*>(item);\r\n        }\r\n        else\r\n        {\r\n            stack = getLayout()->findColumnAt(clickedPosition);\r\n        }\r\n\r\n        if (stack != nullptr)\r\n        {\r\n            if (stack->getContentType() == ColumnTypes::COMPONENTS)\r\n            {\r\n                // Determine an unused name for the component instance.\r\n                QString name = createInstanceName(\"instance\");\r\n\r\n                // Create a component model without a valid vlnv.\r\n                QSharedPointer<Component> comp = QSharedPointer<Component>(new Component(VLNV(), getEditedComponent()->getRevision()));\r\n                comp->setImplementation(KactusAttribute::SW);\r\n\r\n\t\t\t\t// Create the corresponding diagram component.\r\n\t\t\t\tQSharedPointer<ComponentInstance> swInstance(new ComponentInstance());\r\n\t\t\t\tswInstance->setInstanceName(name);\r\n                swInstance->setDraft(true);\r\n\r\n                // Create the corresponding SW component item.\r\n                SWComponentItem* swCompItem = new SWComponentItem(getLibraryInterface(), comp, swInstance);\r\n                swCompItem->setDraft();\r\n                swCompItem->setPos(snapPointToGrid(clickedPosition));\r\n\r\n                // Add to the design.\r\n\r\n                connect(swCompItem, SIGNAL(openCSource(ComponentItem*)), this, SIGNAL(openCSource(ComponentItem*)));\r\n                connect(swCompItem, SIGNAL(errorMessage(QString const&)), this, SIGNAL(errorMessage(QString const&)));\r\n\r\n                QSharedPointer<SystemComponentAddCommand> cmd(\r\n                    new SystemComponentAddCommand(stack, swCompItem, this));\r\n\r\n                connect(cmd.data(), SIGNAL(componentInstantiated(ComponentItem*)),\r\n                    this, SIGNAL(componentInstantiated(ComponentItem*)), Qt::UniqueConnection);\r\n                connect(cmd.data(), SIGNAL(componentInstanceRemoved(ComponentItem*)),\r\n                    this, SIGNAL(componentInstanceRemoved(ComponentItem*)), Qt::UniqueConnection);\r\n\r\n                getEditProvider()->addCommand(cmd);\r\n                cmd->redo();\r\n            }\r\n            else if (stack->getContentType() == ColumnTypes::IO)\r\n            {\r\n                GraphicsColumn* column = dynamic_cast<GraphicsColumn*>(stack);\r\n                if (column)\r\n                {\r\n                    addTopLevelInterface(column, clickedPosition);\r\n                }\r\n            }\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SystemDesignDiagram::replace()\r\n//-----------------------------------------------------------------------------\r\nvoid SystemDesignDiagram::replace(ComponentItem* destComp, ComponentItem* sourceComp)\r\n{\r\n    SystemComponentItem* destSystemComponent = dynamic_cast<SystemComponentItem*>(destComp);\r\n    SystemComponentItem* sourceSystemComponent = dynamic_cast<SystemComponentItem*>(sourceComp);\r\n\r\n    if (destSystemComponent && sourceSystemComponent)\r\n    {\r\n        // Perform the replacement. \r\n        QSharedPointer<ReplaceSystemComponentCommand> cmd(new ReplaceSystemComponentCommand(\r\n            destSystemComponent, sourceSystemComponent, true, true, getDesign(), this));\r\n\r\n        connect(cmd.data(), SIGNAL(componentInstantiated(ComponentItem*)),\r\n            this, SIGNAL(componentInstantiated(ComponentItem*)), Qt::UniqueConnection);\r\n        connect(cmd.data(), SIGNAL(componentInstanceRemoved(ComponentItem*)),\r\n            this, SIGNAL(componentInstanceRemoved(ComponentItem*)), Qt::UniqueConnection);\r\n\r\n        getEditProvider()->addCommand(cmd);\r\n        cmd->redo();\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SystemDesignDiagram::copySWInstances()\r\n//-----------------------------------------------------------------------------\r\nvoid SystemDesignDiagram::copySWInstances(QList<QGraphicsItem*> const& items,\r\n                                          ComponentCollectionCopyData &collection)\r\n{\r\n    // Create instance copies.\r\n    for (QGraphicsItem* item : items)\r\n    {\r\n        if (item->type() == SWComponentItem::Type)\r\n        {\r\n            SWComponentItem* comp = dynamic_cast<SWComponentItem*>(item);\r\n\r\n            collection.instances.append(ComponentInstanceCopyData());\r\n            ComponentInstanceCopyData& instance = collection.instances.back();\r\n\r\n            // Take a copy of the component model so that we are not influenced by any changes to the original.\r\n            instance.component = QSharedPointer<Component>(new Component(*comp->componentModel()));\r\n\r\n            QSharedPointer<ComponentInstance> copiedSWInstance = comp->getComponentInstance();\r\n            instance.swInstance = QSharedPointer<ComponentInstance>(new ComponentInstance(*copiedSWInstance));\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SystemDesignDiagram::pasteSWInstances()\r\n//-----------------------------------------------------------------------------\r\nvoid SystemDesignDiagram::pasteSWInstances(ComponentCollectionCopyData const collection, IGraphicsItemStack* stack,\r\n                                           QUndoCommand* cmd, bool useCursorPos)\r\n{\r\n    foreach (ComponentInstanceCopyData const instanceCopy, collection.instances)\r\n    {\r\n        // Create unique name for the component instance.\r\n        QSharedPointer<ComponentInstance> swInstanceCopy (new ComponentInstance(*instanceCopy.swInstance.data()));\r\n\r\n        QString instanceName = createInstanceName(instanceCopy.swInstance->getInstanceName());\r\n        swInstanceCopy->setInstanceName(instanceName);\r\n\r\n        // Take a copy of the component in case of a draft.\r\n        QSharedPointer<Component> component = instanceCopy.component;\r\n        if (!component->getVlnv().isValid())\r\n        {\r\n            component = QSharedPointer<Component>(new Component(*instanceCopy.component));\r\n        }\r\n\r\n        SWComponentItem* comp = new SWComponentItem(getLibraryInterface(), component, swInstanceCopy);\r\n\r\n        if (useCursorPos)\r\n        {\r\n            comp->setPos(findCursorPositionMappedToScene());\r\n        }\r\n        else\r\n        {\r\n            comp->setPos(swInstanceCopy->getPosition());\r\n        }\r\n\r\n        if (swInstanceCopy->isDraft())\r\n        {\r\n            comp->setDraft();\r\n        }\r\n\r\n        IGraphicsItemStack* targetStack = stack;\r\n\r\n        // Check if the stack does not accept the given component.\r\n        if (!stack->isItemAllowed(comp))\r\n        {\r\n            targetStack = 0;\r\n\r\n            // Find the first column that accepts the component.\r\n            for (GraphicsColumn* otherColumn : getLayout()->getColumns())\r\n            {\r\n                if (otherColumn->isItemAllowed(comp))\r\n                {\r\n                    targetStack = otherColumn;\r\n                    break;\r\n                }\r\n            }\r\n        }\r\n\r\n        if (targetStack != nullptr)\r\n        {\r\n            SystemComponentAddCommand* childCmd = new SystemComponentAddCommand(targetStack, comp,  this, cmd);\r\n\r\n            connect(childCmd, SIGNAL(componentInstantiated(ComponentItem*)),\r\n                this, SIGNAL(componentInstantiated(ComponentItem*)), Qt::UniqueConnection);\r\n            connect(childCmd, SIGNAL(componentInstanceRemoved(ComponentItem*)),\r\n                this, SIGNAL(componentInstanceRemoved(ComponentItem*)), Qt::UniqueConnection);\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SystemDesignDiagram::copyInterfaces()\r\n//-----------------------------------------------------------------------------\r\nvoid SystemDesignDiagram::copyInterfaces(QList<QGraphicsItem*> const& items, PortCollectionCopyData& collection)\r\n{\r\n    for (QGraphicsItem* item : items)\r\n    {\r\n        if (item->type() == SWPortItem::Type || item->type() == SWInterfaceItem::Type)\r\n        {\r\n            SWConnectionEndpoint* endpoint = static_cast<SWConnectionEndpoint*>(item);\r\n\r\n            collection.ports.append(PortCopyData());\r\n            PortCopyData& portData = collection.ports.back();\r\n            portData.name = endpoint->name();\r\n            portData.pos = endpoint->pos();\r\n\r\n            if (endpoint->getApiInterface() != nullptr)\r\n            {\r\n                portData.apiInterface = QSharedPointer<ApiInterface>(new ApiInterface(*endpoint->getApiInterface()));\r\n            }\r\n\r\n            if (endpoint->getComInterface() != nullptr)\r\n            {\r\n                portData.comInterface = QSharedPointer<ComInterface>(new ComInterface(*endpoint->getComInterface()));\r\n            }\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SystemDesignDiagram::pasteInterfaces()\r\n//-----------------------------------------------------------------------------\r\nvoid SystemDesignDiagram::pasteInterfaces(PortCollectionCopyData const& collection,\r\n                                          SWComponentItem* targetComp, QUndoCommand* cmd)\r\n{\r\n    for (PortCopyData const& portData : collection.ports)\r\n    {\r\n        // Interface must have a unique name within the component.\r\n        auto uniqueName = portData.name;\t\r\n\r\n        unsigned int count = 0;\r\n\r\n        while(targetComp->getSWPort(uniqueName, SWConnectionEndpoint::ENDPOINT_TYPE_COM) != nullptr ||\r\n              targetComp->getSWPort(uniqueName, SWConnectionEndpoint::ENDPOINT_TYPE_API) != nullptr)\r\n        {\r\n            ++count;\r\n            uniqueName = portData.name + \"_\" + QString::number(count);\t\t\t\r\n        }\r\n\r\n        SWPortItem* port = nullptr;\r\n\r\n        if (portData.apiInterface != nullptr)\r\n        {\r\n            // Create a copy of the API interface.\r\n            QSharedPointer<ApiInterface> apiIf(new ApiInterface(*portData.apiInterface));\r\n            apiIf->setName(uniqueName);\r\n\r\n            port = new SWPortItem(apiIf, targetComp->componentModel(), targetComp);\r\n        }\r\n        else if (portData.comInterface != nullptr)\r\n        {\r\n            QSharedPointer<ComInterface> comIf(new ComInterface(*portData.comInterface));\r\n            comIf->setName(uniqueName);\r\n\r\n            port = new SWPortItem(comIf, targetComp->componentModel(), targetComp);\r\n        }\r\n        else\r\n        {\r\n            port = new SWPortItem(uniqueName, targetComp->componentModel(), targetComp);\r\n        }\r\n\r\n        QPointF pos = snapPointToGrid(targetComp->mapFromScene(findCursorPositionMappedToScene()));\r\n        port->setPos(pos);\r\n\r\n        // Save the positions of the other interfaces.\r\n        QMap<SWPortItem*, QPointF> oldPositions;\r\n\r\n        for (QGraphicsItem* item : targetComp->childItems())\r\n        {\r\n            if (item->type() == SWPortItem::Type)\r\n            {\r\n                SWPortItem* port = static_cast<SWPortItem*>(item);\r\n                oldPositions.insert(port, port->pos());\r\n            }\r\n        }\r\n\r\n        // Run the actual command for pasting the interface.\r\n        QUndoCommand* pasteCmd = new SWPortAddCommand(targetComp, port, this, cmd);\r\n        pasteCmd->redo();\r\n\r\n        // Determine if the other interfaces changed their position and create undo commands for them.\r\n        QMap<SWPortItem*, QPointF>::iterator cur = oldPositions.begin();\r\n\r\n        while (cur != oldPositions.end())\r\n        {\r\n            if (cur.key()->pos() != cur.value())\r\n            {\r\n                new SWPortMoveCommand(cur.key(), cur.value(), this, pasteCmd);\r\n            }\r\n\r\n            ++cur;\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SystemDesignDiagram::pasteInterfaces()\r\n//-----------------------------------------------------------------------------\r\nvoid SystemDesignDiagram::pasteInterfaces(PortCollectionCopyData const& collection, IGraphicsItemStack* stack,\r\n                                          QUndoCommand* cmd, bool useCursorPos)\r\n{\r\n    for (PortCopyData const& portData : collection.ports)\r\n    {\r\n        auto uniqueName = createDraftInterfaceName(portData.name);\r\n\r\n        SWInterfaceItem* interface = nullptr;\r\n\r\n        QSharedPointer<InterfaceGraphicsData> graphicsData(new InterfaceGraphicsData(uniqueName));\r\n\r\n        if (portData.apiInterface != nullptr)\r\n        {\r\n            // Create a copy of the API interface.\r\n            QSharedPointer<ApiInterface> apiIf(new ApiInterface(*portData.apiInterface));\r\n            apiIf->setName(uniqueName);\r\n\r\n            interface = new SWInterfaceItem(getEditedComponent(), apiIf, graphicsData);\r\n        }\r\n        else if (portData.comInterface != nullptr)\r\n        {\r\n            QSharedPointer<ComInterface> comIf(new ComInterface(*portData.comInterface));\r\n            comIf->setName(uniqueName);\r\n\r\n            interface = new SWInterfaceItem(getEditedComponent(), comIf, graphicsData);\r\n        }\r\n        else\r\n        {\r\n            interface = new SWInterfaceItem(getEditedComponent(), uniqueName, graphicsData, 0);\r\n        }\r\n\r\n        if (useCursorPos)\r\n        {\r\n            interface->setPos(contextMenuPosition());\r\n        }\r\n        else\r\n        {\r\n            interface->setPos(portData.pos);\r\n        }\r\n\r\n        // Save the positions of the other interfaces.\r\n        QMap<SWInterfaceItem*, QPointF> oldPositions;\r\n\r\n        for (QGraphicsItem* item : dynamic_cast<SystemColumn*>(stack)->childItems())\r\n        {\r\n            if (item->type() == SWInterfaceItem::Type)\r\n            {\r\n                SWInterfaceItem* interface = static_cast<SWInterfaceItem*>(item);\r\n                oldPositions.insert(interface, interface->scenePos());\r\n            }\r\n        }\r\n\r\n        QUndoCommand* addCommand = new SWInterfaceAddCommand(stack, interface, getDesign(), cmd);\r\n        addCommand->redo();\r\n\r\n        // Determine if the other interfaces changed their position and create undo commands for them.\r\n        QMap<SWInterfaceItem*, QPointF>::iterator cur = oldPositions.begin();\r\n\r\n        while (cur != oldPositions.end())\r\n        {\r\n            if (cur.key()->scenePos() != cur.value())\r\n            {\r\n                new ItemMoveCommand(cur.key(), cur.value(), stack, this, addCommand);\r\n            }\r\n\r\n            ++cur;\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SystemDesignDiagram::createAutoConnector()\r\n//-----------------------------------------------------------------------------\r\nComponentItemAutoConnector* SystemDesignDiagram::createAutoConnector(ComponentItem*) const\r\n{\r\n    return nullptr;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SystemDesignDiagram::getEndPointForItem()\r\n//-----------------------------------------------------------------------------\r\nConnectionEndpoint* SystemDesignDiagram::getEndPointForItem(AutoConnectorItem*, QUndoCommand*)\r\n{\r\n    return nullptr;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SystemDesignDiagram::createConnectionBetweenEndPoints()\r\n//-----------------------------------------------------------------------------\r\nvoid SystemDesignDiagram::createConnectionBetweenEndPoints(ConnectionEndpoint*, ConnectionEndpoint*)\r\n{\r\n    // Intentionally empty.\r\n}\r\n"
  },
  {
    "path": "editors/SystemDesign/SystemDesignDiagram.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: SystemDesignDiagram.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Joni-Matti Maatta\r\n// Date: 23.4.2012\r\n//\r\n// Description:\r\n// System design diagram to work as a drawing canvas.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef SYSTEMDESIGNDIAGRAM_H\r\n#define SYSTEMDESIGNDIAGRAM_H\r\n\r\n#include <common/graphicsItems/ConnectionEndpoint.h>\r\n\r\n#include <editors/common/ComponentDesignDiagram.h>\r\n#include <editors/SystemDesign/SWConnectionEndpoint.h>\r\n\r\n#include <QSharedPointer>\r\n\r\nclass Component;\r\nclass ComponentInstance;\r\nclass Design;\r\nclass LibraryInterface;\r\nclass IGraphicsItemStack;\r\nclass GenericEditProvider;\r\nclass SystemDesignWidget;\r\nclass HWMappingItem;\r\nclass SystemComponentItem;\r\nclass GraphicsConnection;\r\nclass SWComponentItem;\r\nclass SWPortItem;\r\nclass ConnectionRoute;\r\nclass InterfaceGraphicsData;\r\nclass SWInterfaceItem;\r\nclass HierInterface;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! SystemDesignDiagram class.\r\n//-----------------------------------------------------------------------------\r\nclass SystemDesignDiagram : public ComponentDesignDiagram\r\n{\r\n    Q_OBJECT\r\n\r\npublic:\r\n\r\n    //-----------------------------------------------------------------------------\r\n    //! Clipboard copy data for a single API/COM port.\r\n    //-----------------------------------------------------------------------------\r\n\tstruct PortCopyData\r\n\t{\r\n        QString name;                              //!< The name of the interface.\r\n        // Only one of these is valid at one time.\r\n\t\tQSharedPointer<ApiInterface> apiInterface; //!< API interface.\r\n\t\tQSharedPointer<ComInterface> comInterface; //!< COM interface.\r\n        QPointF pos;                               //!< The original position.\r\n\r\n\t\t/*!\r\n         *  Default constructor.\r\n         */\r\n        PortCopyData() : apiInterface(), comInterface()\r\n        {\r\n        }\r\n\r\n        /*!\r\n         *  Constructor.\r\n         */\r\n\t\tPortCopyData(QSharedPointer<ApiInterface> apiInterface, QSharedPointer<ComInterface> comInterface)\r\n            : apiInterface(apiInterface),\r\n              comInterface(comInterface)\r\n        {\r\n        }\r\n\t};\r\n\r\n    //-----------------------------------------------------------------------------\r\n    //! Clipboard copy data for a collection of API/COM ports.\r\n    //-----------------------------------------------------------------------------\r\n    struct PortCollectionCopyData\r\n    {\r\n        QList<PortCopyData> ports;\r\n\r\n        /*!\r\n         *  Constructor.\r\n         */\r\n        PortCollectionCopyData()\r\n            : ports()\r\n        {\r\n        }\r\n    };\r\n\r\n    //-----------------------------------------------------------------------------\r\n    //! Clipboard copy data for a single component instance.\r\n    //-----------------------------------------------------------------------------\r\n    struct ComponentInstanceCopyData\r\n    {\r\n\t\tQSharedPointer<Component> component;    //! The referenced component.\r\n\t\tQSharedPointer<ComponentInstance> swInstance;  //! The instance.\r\n\r\n        ComponentInstanceCopyData():\r\n        component(),\r\n        swInstance()\r\n        {\r\n        }\r\n    };\r\n\r\n    //-----------------------------------------------------------------------------\r\n    //! Clipboard copy data for a collection of copied component instances.\r\n    //-----------------------------------------------------------------------------\r\n    struct ComponentCollectionCopyData\r\n    {\r\n        QList<ComponentInstanceCopyData> instances;\r\n\r\n        /*!\r\n         *  Constructor.\r\n         */\r\n        ComponentCollectionCopyData()\r\n            : instances()\r\n        {\r\n        }\r\n    };\r\n\r\n    //-----------------------------------------------------------------------------\r\n    //! Clipboard copy data for a single column.\r\n    //-----------------------------------------------------------------------------\r\n    struct ColumnCopyData\r\n    {\r\n        QSharedPointer<ColumnDesc> desc;            //!< Column description.\r\n        ComponentCollectionCopyData components;     //!< Components.\r\n        PortCollectionCopyData interfaces;          //!< COM/API interfaces.\r\n\r\n        /*!\r\n         *  Constructor.\r\n         */\r\n        ColumnCopyData()\r\n            : desc(),\r\n              components()/*,\r\n              interfaces()*/\r\n        {\r\n        }\r\n    };\r\n\r\n    //-----------------------------------------------------------------------------\r\n    //! Clipboard copy data for a collection of columns.\r\n    //-----------------------------------------------------------------------------\r\n    struct ColumnCollectionCopyData\r\n    {\r\n        QList<ColumnCopyData> columns;\r\n\r\n        /*!\r\n         *  Constructor.\r\n         */\r\n        ColumnCollectionCopyData()\r\n            : columns()\r\n        {\r\n        }\r\n    };\r\n\r\n    /*!\r\n     *  Constructor.\r\n     *\r\n     *    @param [in] lh            The library interface.\r\n     *    @param [in] editProvider  The edit provider.\r\n     *    @param [in] parent        The parent widget.\r\n     */\r\n    SystemDesignDiagram(bool onlySW, LibraryInterface* lh,\r\n                        QSharedPointer<IEditProvider> editProvider, SystemDesignWidget* parent = 0);\r\n\r\n    /*!\r\n     *  Destructor.\r\n     */\r\n    ~SystemDesignDiagram() final = default;\r\n\r\n    /*!\r\n     *  Reflects the changes in the design to the top-level component.\r\n     */\r\n    virtual void updateHierComponent();\r\n\r\n    /*!\r\n     *  Adds a new column to the diagram.\r\n     *\r\n     *    @param [in] desc The column description.\r\n     */\r\n    void addColumn(QSharedPointer<ColumnDesc> desc);\r\n\r\npublic slots:\r\n\r\n    /*!\r\n     *  Called when copy is selected from the context menu.\r\n     */\r\n\tvoid onCopyAction();\r\n\r\n    /*!\r\n     *  Called when paste is selected from the context menu.\r\n     */\r\n\tvoid onPasteAction();\r\n\r\n    /*!\r\n     *  Called when add to library is selected from the context menu.\r\n     */\r\n\tvirtual void onAddToLibraryAction();\r\n\r\nprotected:\r\n\r\n    /*!\r\n     *  Opens a design for a given component.\r\n     *\r\n     *    @param [in] component   The component whose design to open.\r\n     *    @param [in] viewName    The name of the view to open.\r\n     */\r\n    virtual void openDesignForComponent(ComponentItem* component, QString const& viewName);\r\n\r\n    //! Called when the mouse is double-clicked.\r\n    void mouseDoubleClickEvent(QGraphicsSceneMouseEvent* mouseEvent);\r\n\r\n    //! Called when an drag enters the diagram.\r\n    void dragEnterEvent(QGraphicsSceneDragDropEvent* event);\r\n\r\n    //! Called when the drag leaves the diagram.\r\n    void dragLeaveEvent(QGraphicsSceneDragDropEvent* event);\r\n\r\n    //! Called when an object is dropped to the diagram.\r\n    void dropEvent(QGraphicsSceneDragDropEvent* event);\r\n\r\n\tQSharedPointer<ComponentInstance> createSWInstance(QSharedPointer<Component> comp);\r\n\r\n    //! Updates the dropAction and highlight according to underlying element.\r\n    virtual void updateDropAction(QGraphicsSceneDragDropEvent* event);\r\n\r\n    /*!\r\n     *  Checks if open component action should be enabled.\r\n     *\r\n     *    @return True, if action should be enabled, otherwise false.\r\n     */\r\n    virtual bool openComponentActionEnabled() const;\r\n\r\n    /*!\r\n     *  Check if the selected items are of a type used in the system design.\r\n     *\r\n     *    @return True, if the items are used in system design, false otherwise.\r\n     */\r\n    virtual bool selectedItemIsCorrectType() const;\r\n\r\n    /*!\r\n     *  Checks if the given item is a hierarchical component.\r\n     *\r\n     *    @param [in] item   The item to check.\r\n     *\r\n     *    @return True, if item is a hierarchical component, otherwise false.\r\n     */\r\n    virtual bool isHierarchicalComponent(QGraphicsItem* item) const;\r\n\r\n    /*!\r\n     *  Checks if copy action should be enabled.\r\n     *\r\n     *    @return True, if action should be enabled, otherwise false.\r\n     */\r\n    virtual bool copyActionEnabled() const;\r\n\r\n    /*!\r\n     *  Checks if paste action should be enabled.\r\n     *\r\n     *    @return True, if action should be enabled, otherwise false.\r\n     */\r\n    virtual bool pasteActionEnabled() const;\r\n\r\n    /*!\r\n     *  Opens the given component according to the active view of the component.\r\n     *\r\n     *    @param [in] comp   The component to open.\r\n     */\r\n    virtual void openComponentByActiveView(ComponentItem* comp);\r\n\r\n   /*!\r\n    *  Gets the names of hierarchical views of a component.\r\n    *\r\n    *    @param [in] component   The component whose hierarchical views to get.\r\n    *\r\n    *    @return The names of the hierarchical views.\r\n    */\r\n    virtual QStringList hierarchicalViewsOf(ComponentItem* component) const;\r\n\r\n    /*!\r\n     *  Gets the graphics item type of the components in the diagram.\r\n     *     \r\n     *    @return The type of the components.\r\n     */\r\n    virtual int componentType() const;\r\n\r\n    /*!\r\n     *  Gets the graphics item type of the off page connectors in the diagram.\r\n     *     \r\n     *    @return The type of the components.\r\n     */\r\n    virtual int offpageConnectorType() const;\r\n\r\n    /*!\r\n     *  Gets the graphics item type of the connections in the diagram.\r\n     *     \r\n     *    @return The type of the components.\r\n     */\r\n    virtual int connectionType() const;\r\n\r\nprivate:\r\n    // Disable copying.\r\n    SystemDesignDiagram(SystemDesignDiagram const& rhs);\r\n    SystemDesignDiagram& operator=(SystemDesignDiagram const& rhs);\r\n\r\n    /*!\r\n     *  Called when an item has been selected in the diagram.\r\n     *\r\n     *    @param [in] newSelection The selected item.\r\n     */\r\n    virtual void onSelected(QGraphicsItem* newSelection);\r\n\r\n    /*!\r\n     *  Opens the system design for editing.\r\n     */\r\n    void loadDesign(QSharedPointer<Design> design);\r\n\r\n    /*!\r\n     *  Load interfaces from the component containing the design.\r\n     *\r\n     *    @param [in] design  The selected design.\r\n     */\r\n    void loadInterfaces(QSharedPointer<Design> design);\r\n\r\n    /*!\r\n     *  Get the interface graphics data.\r\n     *\r\n     *    @param [in] design          Design containing the interface.\r\n     *    @param [in] interfaceName   The name of the interface.\r\n     *\r\n     *    @return Graphics data of the interface.\r\n     */\r\n    QSharedPointer<InterfaceGraphicsData> findOrCreateInterfaceGraphicsData(QSharedPointer<Design> design,\r\n        QString const& interfaceName);\r\n\r\n    /*!\r\n     *  Add the interface item to the layout.\r\n     *\r\n     *    @param [in] item    The selected interface item.\r\n     */\r\n    void addInterfaceItemToLayout(SWInterfaceItem* item);\r\n\r\n    /*!\r\n     *  Loads the COM connections from the given design.\r\n     */\r\n    void loadComConnections(QSharedPointer<Design> design);\r\n\r\n    /*!\r\n     *  Find or create an endpoint item for the interface.\r\n     *\r\n     *    @param [in] endpointInterface   The selected end point interface.\r\n     *    @param [in] type                The type of the selected end point.\r\n     *    @param [in] connectionName      Name of the connection containing the end point.\r\n     *    @param [in] containingDesign    The containing design.\r\n     *\r\n     *    @return The endpoint item corresponding to the selected interface.\r\n     */\r\n    ConnectionEndpoint* findOrCreateEndpointItem(QSharedPointer<HierInterface> endpointInterface,\r\n        SWConnectionEndpoint::EndpointType type, QString const& connectionName,\r\n        QSharedPointer<Design> containingDesign);\r\n\r\n    /*!\r\n     *  Get the SW interface item.\r\n     *\r\n     *    @param [in] interfaceName   The name of the SW interface item.\r\n     *\r\n     *    @return The SW interface item matching the selected interface name.\r\n     */\r\n    SWInterfaceItem* getSWInterfaceItem(QString const& interfaceName) const;\r\n\r\n    /*!\r\n     *  Create a dummy interface.\r\n     *\r\n     *    @param [in] itemType            Type of the interface in string format.\r\n     *    @param [in] interfaceReference  The name of the interface.\r\n     *\r\n     *    @return The created dummy interface.\r\n     */\r\n    ConnectionEndpoint* createDummyInterface(QString const& itemType, QString const& interfaceReference);\r\n\r\n    /*!\r\n     *  Find or create a SW port item.\r\n     *\r\n     *    @param [in] containingItem      The item containing the port item.\r\n     *    @param [in] interfaceReference  The name of the port.\r\n     *    @param [in] type                The type of the port.\r\n     *    @param [in] containingDesign    The design containing the port item.\r\n     *\r\n     *    @return The found SW port item.\r\n     */\r\n    ConnectionEndpoint* findOrCreateSWPortItem(SystemComponentItem* containingItem,\r\n        QString const& interfaceReference, SWConnectionEndpoint::EndpointType type,\r\n        QSharedPointer<Design> containingDesign);\r\n\r\n    /*!\r\n     *  Loads the API dependencies from the given design.\r\n     */\r\n    void loadApiDependencies(QSharedPointer<Design> design);\r\n\r\n    /*!\r\n     *  Get the route used by the interconnection.\r\n     *\r\n     *    @param [in] interconnectionName     Name of the selected interconnection.\r\n     *\r\n     *    @return The route used by the selected interconnection.\r\n     */\r\n    QSharedPointer<ConnectionRoute> getInterconnectionRoute(QString const& interconnectionName) const;\r\n\r\n    /*!\r\n     *  Returns the HW component instance with the given name.\r\n     */\r\n    HWMappingItem* getHWComponent(QString const& instanceName);\r\n\r\n    /*!\r\n     *  Returns the HW component instance with the given UUID.\r\n     */\r\n    HWMappingItem* getHWComponentByUUID(QString const& uuid);\r\n\r\n    /*!\r\n     *  Returns the component with the given name (either HW or SW).\r\n     *\r\n     *    @param [in] instanceName The name of the instance to search for.\r\n     *\r\n     *    @return The corresponding component, or null if not found.\r\n     */\r\n    SystemComponentItem* getComponent(QString const& instanceName);\r\n\r\n    /*!\r\n     *  Creates a missing port to the given component item.\r\n     *\r\n     *    @param [in] portName   The name of the port to create.\r\n     *    @param [in] type       The port endpoint type.\r\n     *    @param [in] component  The parent component.\r\n     *    @param [in] design     The design containing related information.\r\n     */\r\n    SWPortItem* createMissingPort(QString const& portName, ConnectionEndpoint::EndpointType type,\r\n                                  SystemComponentItem* component, QSharedPointer<Design> design);\r\n\r\n    /*!\r\n     *  Imports SW instances and related connections from the given design to the diagram.\r\n     *\r\n     *    @param [in] design    The design to import.\r\n     *    @param [in] stack     The stack where to place the imported elements.\r\n     *    @param [in] guidePos  Position used as a guide where to place the imported instances.\r\n     */\r\n    void importDesign(QSharedPointer<Design> design, IGraphicsItemStack* stack, QPointF const& guidePos);\r\n\r\n    /*!\r\n     *  Creates a connection between the given two endpoints.\r\n     *\r\n     *    @param [in] startPoint  The starting connection end point.\r\n     *    @param [in] endPoint    The ending connection end point.\r\n     *    @param [in] isOffPage   Doesn't do anything in SystemDesignDiagram and is present because of inheritance\r\n     *\r\n     *    @return The created connection.\r\n     */\r\n    virtual  GraphicsConnection* createConnection(ConnectionEndpoint* startPoint, ConnectionEndpoint* endPoint, bool isOffPage = false);\r\n\r\n    /*!\r\n     *  Create an interface for an end point.\r\n     *\r\n     *    @param [in] connectionPoint     The selected connection end point.\r\n     *\r\n     *    @return Interface created for the selected end point.\r\n     */\r\n    QSharedPointer<HierInterface> createEndpointInterface(ConnectionEndpoint* connectionPoint);\r\n\r\n    /*!\r\n     *  Creates a connection between the given endpoint and a coordinate point.\r\n     *\r\n     *    @param [in] startPoint  The starting connection end point.\r\n     *    @param [in] endPoint    The ending coordinate point.\r\n     *\r\n     *    @return The created connection.\r\n     */\r\n    virtual GraphicsConnection* createConnection(ConnectionEndpoint* startPoint, QPointF const& endPoint);\r\n\r\n    /*!\r\n     *  Creates an add command for a given connection.\r\n     *\r\n     *    @param [in] connection          The connection to create a command for.     \r\n     *    @param [in] parentUndoCommand   Optional undocommand to set as parent for created child commands.\r\n     *\r\n     *    @return The created add command.\r\n     */\r\n    virtual QUndoCommand* createAddCommandForConnection(GraphicsConnection* connection, QUndoCommand* parentCommand = nullptr);\r\n\r\n    /*!\r\n     *  Adds a new top-level interface to the given diagram column.\r\n     *\r\n     *    @param [in] column      The column where to add the interface.\r\n     *    @param [in] pos         The interface position.\r\n     *    @param [in] isDraft     Determines if Bus Interface is draft or not.\r\n     */\r\n    virtual void addTopLevelInterface(GraphicsColumn* column, QPointF const& pos, bool isDraft = false);\r\n\r\n    /*!\r\n     *  Create a unique name for the interface.\r\n     *\r\n     *    @param [in] baseName    The name from which to create the unique name.\r\n     *\r\n     *    @return A unique name for the interface.\r\n     */\r\n    QString createDraftInterfaceName(QString const& baseName) const;\r\n\r\n    /*!\r\n     *  Handler for draft tool clicks. Creates a draft component instance or a draft interface according to the\r\n     *  clicked position.\r\n     *\r\n     *    @param [in] clickedPosition   The position to create the draft item to.     \r\n     */\r\n    virtual void draftAt(QPointF const& clickedPosition);\r\n\r\n    /*!\r\n     *  Performs the replacing of destination component with source component.\r\n     *\r\n     *    @param [in] destComp        The component to replace.\r\n     *    @param [in] sourceComp      The replacing component.     \r\n     */\r\n    virtual void replace(ComponentItem* destComp, ComponentItem* sourceComp);\r\n\r\n    /*!\r\n     *  Copies SW component instances in a format which can be saved to clipboard.\r\n     *\r\n     *    @param [in]  items       The component instance items to copy.\r\n     *    @param [out] collection  The resulted collection of component instance copy data.\r\n     */\r\n    void copySWInstances(QList<QGraphicsItem*> const& items, ComponentCollectionCopyData &collection);\r\n\r\n    /*!\r\n     *  Copies interfaces in a format which can be saved to clipboard.\r\n     *\r\n     *    @param [in]  items       The interface items to copy.\r\n     *    @param [out] collection  The resulted collection of interface copy data.\r\n     */\r\n    void copyInterfaces(QList<QGraphicsItem*> const& items, PortCollectionCopyData& collection);\r\n\r\n    /*!\r\n     *  Pastes component instances from a copy data collection.\r\n     *\r\n     *    @param [in] collection     The collection of component instance copy data.\r\n     *    @param [in] column         The item stack where to place the instances.\r\n     *    @param [in] cmd            The parent undo command for the paste undo commands.\r\n     *    @param [in] userCursorPos  If true, the instances are placed close to the cursor position.\r\n     *                                 Otherwise the original positions are used.\r\n     */\r\n    void pasteSWInstances(ComponentCollectionCopyData const collection,\r\n                          IGraphicsItemStack* stack, QUndoCommand* cmd, bool useCursorPos);\r\n\r\n    /*!\r\n     *  Pastes interfaces from a copy data collection.\r\n     *\r\n     *    @param [in] collection  The collection of interface copy data.\r\n     *    @param [in] targetComp  The target component. If null, the interfaces are pasted to the top level component.\r\n     *    @param [in] cmd         The parent undo command for the paste undo commands.\r\n     */\r\n    void pasteInterfaces(PortCollectionCopyData const& collection, SWComponentItem* targetComp, QUndoCommand* cmd);\r\n\r\n    /*!\r\n     *  Pastes interfaces from a copy data collection to a top-level item stack.\r\n     *\r\n     *    @param [in] collection     The collection of interface copy data.\r\n     *    @param [in] stack          The target item tack.\r\n     *    @param [in] cmd            The parent undo command for the paste undo commands.\r\n     *    @param [in] userCursorPos  If true, the interfaces are placed close to the cursor position.\r\n     *                                 Otherwise the original positions are used.\r\n     */\r\n    void pasteInterfaces(PortCollectionCopyData const& collection, IGraphicsItemStack* stack, QUndoCommand* cmd,\r\n                         bool useCursorPos);\r\n\r\n    /*!\r\n     *  Pastes columns from a copy data collection.\r\n     *\r\n     *    @param [in] collection  The collection of column copy data.\r\n     */\r\n    void pasteColumns(ColumnCollectionCopyData const collection);\r\n\r\n    /*!\r\n     *  Create a unique name for a column with the given base name.\r\n     *\r\n     *    @param [in] baseName    The base name of the column.\r\n     *\r\n     *    @return A unique column name.\r\n     */\r\n    QString createColumnName(QString const& baseName);\r\n\r\n    //-----------------------------------------------------------------------------\r\n    //! Drag type enumeration.\r\n    //-----------------------------------------------------------------------------\r\n    enum DragType\r\n    {\r\n        DRAG_TYPE_NONE = 0,\r\n        DRAG_TYPE_SW,\r\n        DRAG_TYPE_HW,\r\n        DRAG_TYPE_DEFINITION,\r\n        DRAG_TYPE_DESIGN\r\n    };\r\n\r\n    /*!\r\n     *  Get the names of the contained component instances.\r\n     *\r\n     *    @return A list of the contained component instance names.\r\n     */\r\n    virtual QStringList getUsedInstanceNames() const;\r\n\r\n    /*!\r\n     *  Create auto connection dialog.\r\n     *\r\n     *    @param [in] firstItem   The first item for the auto connector.\r\n     *\r\n     *    @return The auto connector dialog.\r\n     */\r\n    virtual ComponentItemAutoConnector* createAutoConnector(ComponentItem* firstItem) const;\r\n\r\n    /*!\r\n     *  Get the connection end point for the selected auto connector item.\r\n     *\r\n     *    @param [in] connectorItem       The selected auto connector item.\r\n     *    @param [in] parentUndoCommand   Optional undocommand to set as parent for created child commands.\r\n     *\r\n     *    @return The end point item for the selected auto connector item.\r\n     */\r\n    virtual ConnectionEndpoint* getEndPointForItem(AutoConnectorItem* connectorItem, QUndoCommand* parentCommand = nullptr);\r\n\r\n    /*!\r\n     *  Create connection between the selected end points.\r\n     *\r\n     *    @param [in] startPoint  Start point for the connection.\r\n     *    @param [in] endPoint    End point for the connection.\r\n     */\r\n    virtual void createConnectionBetweenEndPoints(ConnectionEndpoint* startPoint, ConnectionEndpoint* endPoint);\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! If true, the widget is used for editing SW designs.\r\n    bool onlySW_;\r\n\r\n    //! Indicates what type of object is being dragged into the diagram.\r\n    DragType dragType_;\r\n\r\n    //! The possible end point under cursor while performing drag.\r\n    SWConnectionEndpoint* dragEndPoint_;\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n\r\n#endif // SYSTEMDESIGNDIAGRAM_H\r\n"
  },
  {
    "path": "editors/SystemDesign/SystemDesignWidget.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: SystemDesignWidget.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Joni-Matti Maatta\r\n// Date: 23.4.2012\r\n//\r\n// Description:\r\n// System design widget.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"SystemDesignWidget.h\"\r\n\r\n#include \"SystemColumn.h\"\r\n#include \"SystemDesignDiagram.h\"\r\n#include \"SWComponentItem.h\"\r\n#include \"SWInterfaceItem.h\"\r\n#include \"HWMappingItem.h\"\r\n\r\n#include <common/GenericEditProvider.h>\r\n#include <common/dialogs/newObjectDialog/newobjectdialog.h>\r\n#include <common/graphicsItems/GraphicsConnection.h>\r\n#include <common/graphicsItems/GraphicsColumnConstants.h>\r\n\r\n#include <editors/HWDesign/columnview/ColumnEditDialog.h>\r\n#include <editors/common/Association/Association.h>\r\n#include <editors/common/StickyNote/StickyNote.h>\r\n#include <editors/common/Association/AssociationRemoveCommand.h>\r\n#include <editors/SystemDesign/ComGraphicsConnection.h>\r\n#include <editors/SystemDesign/UndoCommands/ComConnectionDeleteCommand.h>\r\n#include <editors/SystemDesign/UndoCommands/SWPortDeleteCommand.h>\r\n#include <editors/SystemDesign/UndoCommands/SWInterfaceDeleteCommand.h>\r\n#include <editors/SystemDesign/ApiGraphicsConnection.h>\r\n#include <editors/SystemDesign/UndoCommands/ApiConnectionDeleteCommand.h>\r\n#include <editors/SystemDesign/UndoCommands/SystemMoveCommands.h>\r\n#include <editors/SystemDesign/UndoCommands/SystemDeleteCommands.h>\r\n#include <editors/SystemDesign/UndoCommands/SystemComponentDeleteCommand.h>\r\n\r\n#include <KactusAPI/include/LibraryInterface.h>\r\n#include <library/LibraryUtils.h>\r\n\r\n#include <IPXACTmodels/Component/Component.h>\r\n#include <IPXACTmodels/Design/Design.h>\r\n#include <IPXACTmodels/DesignConfiguration/DesignConfiguration.h>\r\n#include <IPXACTmodels/Component/FileSet.h>\r\n\r\n#include <IPXACTmodels/kactusExtensions/SystemView.h>\r\n\r\n#include <QKeyEvent>\r\n#include <QMessageBox>\r\n#include <QFileInfo>\r\n#include <QCoreApplication>\r\n#include <QDir>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SystemDesignWidget()\r\n//-----------------------------------------------------------------------------\r\nSystemDesignWidget::SystemDesignWidget(bool onlySW, LibraryInterface* lh, QWidget* parent):\r\nDesignWidget(lh, parent),\r\nonlySW_(onlySW)\r\n{\r\n    supportedWindows_ |= INSTANCEWINDOW | INTERFACEWINDOW | CONNECTIONWINDOW | CONFIGURATIONWINDOW;\r\n\r\n    if (!onlySW_)\r\n    {\r\n        supportedWindows_ |= SYSTEM_DETAILS_WINDOW;\r\n    }\r\n\r\n    setDiagram(new SystemDesignDiagram(onlySW, lh, getEditProvider(), this));\r\n}\r\n\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: setDesign()\r\n//-----------------------------------------------------------------------------\r\nbool SystemDesignWidget::setDesign(VLNV const& vlnv, QString const& viewName)\r\n{\r\n    disconnect(getDiagram(), SIGNAL(contentChanged()), this, SIGNAL(contentChanged()));\r\n\r\n    // Check if the vlnv is not valid.\r\n    if (!vlnv.isValid() || vlnv.getType() != VLNV::COMPONENT)\r\n    {\r\n        return false;\r\n    }\r\n\r\n    // Retrieve the model.\r\n    QSharedPointer<Component> system = getLibHandler()->getModel(vlnv).staticCast<Component>();\r\n\r\n    if (system == nullptr)\r\n    {\r\n        return false;\r\n    }\r\n\r\n    // Open the design to the diagram.\r\n    if (!setDesign(system, viewName))\r\n    {\r\n        return false;\r\n    }\r\n\r\n    connect(getDiagram(), SIGNAL(contentChanged()),\r\n        this, SIGNAL(contentChanged()), Qt::UniqueConnection);\r\n    connect(getDiagram(), SIGNAL(modeChanged(DrawMode)),\r\n        this, SIGNAL(modeChanged(DrawMode)), Qt::UniqueConnection);\r\n\r\n\tsetDocumentName(QString(\"%1 (%2)\").arg(getIdentifyingVLNV().getName()).arg(getIdentifyingVLNV().getVersion()));\r\n    if (onlySW_)\r\n    {\r\n        setDocumentType(DocumentType::SW_DESIGN);\r\n    }\r\n    else\r\n    {\r\n        setDocumentType(DocumentType::SYSTEM_DESIGN);\r\n    }\r\n\r\n    // Open in unlocked mode by default only if the version is draft.\r\n    setProtection(vlnv.getVersion() != \"draft\");\r\n\r\n    return true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignWidget::setDesign()\r\n//-----------------------------------------------------------------------------\r\nbool SystemDesignWidget::setDesign(QSharedPointer<Component> comp, const QString& viewName)\r\n{\r\n    VLNV designVLNV;\r\n    QString hwViewRef = \"\";\r\n\r\n    if (onlySW_)\r\n    {\r\n        QSharedPointer<View> view = comp->getModel()->findView(viewName);\r\n\r\n        if (!view)\r\n        {\r\n            return false;\r\n        }\r\n\r\n        designVLNV = comp->getHierRef(viewName);\r\n    }\r\n    else\r\n    {\r\n\t\tQSharedPointer<SystemView> view = comp->findSystemView(viewName);\r\n\r\n        if (!view)\r\n        {\r\n            return false;\r\n        }\r\n\r\n        designVLNV = comp->getHierSystemRef(viewName);\r\n        hwViewRef = view->getHWViewRef();\r\n    }\r\n\r\n    // Check for a valid VLNV type.\r\n    designVLNV.setType(getLibHandler()->getDocumentType(designVLNV));\r\n\r\n    if (!designVLNV.isValid())\r\n    {\r\n        emit errorMessage(tr(\"Component %1 did not contain a view\").arg(comp->getVlnv().getName()));\r\n        return false;\r\n    }\r\n\r\n    QSharedPointer<Design> design;\r\n    QSharedPointer<DesignConfiguration> designConf;\r\n\r\n    // if the component contains a direct reference to a design\r\n    if (designVLNV.getType() == VLNV::DESIGN)\r\n    {\r\n        QSharedPointer<Document> libComp = getLibHandler()->getModel(designVLNV);\t\r\n        design = libComp.staticCast<Design>();\r\n    }\r\n    // if component had reference to a design configuration\r\n    else if (designVLNV.getType() == VLNV::DESIGNCONFIGURATION)\r\n    {\r\n        QSharedPointer<Document> libComp = getLibHandler()->getModel(designVLNV);\r\n        designConf = libComp.staticCast<DesignConfiguration>();\r\n\r\n        designVLNV = designConf->getDesignRef();\r\n\r\n        if (designVLNV.isValid())\r\n        {\r\n            QSharedPointer<Document> libComp = getLibHandler()->getModel(designVLNV);\t\r\n            design = libComp.staticCast<Design>();\r\n        }\r\n\r\n        // if design configuration did not contain a reference to a design.\r\n        if (!design)\r\n        {\r\n            emit errorMessage(tr(\"Component %1 did not contain a view\").arg(\r\n                comp->getVlnv().getName()));\r\n            return false;\r\n        }\r\n    }\r\n\r\n    if (!onlySW_)\r\n    {\r\n        // Update the design.\r\n        updateSystemDesignV2(getLibHandler(), comp->getHierRef(hwViewRef), *design, designConf);\r\n    }\r\n\r\n    if (!getDiagram()->setDesign(comp, viewName, design, designConf))\r\n    {\r\n        return false;\r\n    }\r\n\r\n    return DesignWidget::setDesign(comp, viewName);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: getSupportedDrawModes()\r\n//-----------------------------------------------------------------------------\r\nunsigned int SystemDesignWidget::getSupportedDrawModes() const\r\n{\r\n    if (isProtected())\r\n    {\r\n        return MODE_SELECT;\r\n    }\r\n    else\r\n    {\r\n        return (MODE_SELECT | MODE_CONNECT | MODE_DRAFT | MODE_TOGGLE_OFFPAGE | MODE_LABEL);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: keyPressEvent()\r\n//-----------------------------------------------------------------------------\r\nvoid SystemDesignWidget::keyPressEvent(QKeyEvent* event)\r\n{\r\n    // If the document is protected, skip all delete events.\r\n    if (isProtected())\r\n    {\r\n        return;\r\n    }\r\n\r\n    if (event->key() == Qt::Key_Delete)\r\n    {\r\n        onDeleteSelectedItems();\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SystemDesignWidget::onDeleteSelectedItems()\r\n//-----------------------------------------------------------------------------\r\nvoid SystemDesignWidget::onDeleteSelectedItems()\r\n{\r\n    if (getDiagram()->selectedItems().empty())\r\n    {\r\n        return;\r\n    }\r\n\r\n    QList<QGraphicsItem*> selectedItems = getDiagram()->selectedItems();\r\n    int type = getDiagram()->getCommonItemType(selectedItems);\r\n\r\n    if (type == SystemColumn::Type)\r\n    {\r\n        deleteSelectedSystemColumns(selectedItems);\r\n    }\r\n    else if (type == SWComponentItem::Type)\r\n    {\r\n        deleteSelectedSWComponentItems(selectedItems);\r\n    }\r\n    else if (type == SWPortItem::Type)\r\n    {\r\n        deleteSelectedSWPortItems(selectedItems);\r\n    }\r\n    else if (type == SWInterfaceItem::Type)\r\n    {\r\n        deleteSelectedSWInterfaceItems(selectedItems);\r\n    }\r\n    else if (type == ComGraphicsConnection::Type)\r\n    {\r\n        deleteSelectedComConnectionItems(selectedItems);\r\n    }\r\n    else if (type == ApiGraphicsConnection::Type)\r\n    {\r\n        deleteSelectedApiConnectionItems(selectedItems);\r\n    }\r\n    else if (type == GraphicsConnection::Type)\r\n    {\r\n        deleteSelectedGraphicsConnectionItems(selectedItems);\r\n    }\r\n    else if (type == StickyNote::Type)\r\n    {\r\n        removeSelectedNotes();\r\n    }\r\n    else if (type == Association::Type)\r\n    {\r\n        removeSelectedAssociations();\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SystemDesignWidget::deleteSelectedSystemColumns()\r\n//-----------------------------------------------------------------------------\r\nvoid SystemDesignWidget::deleteSelectedSystemColumns(QList<QGraphicsItem*> selectedItems)\r\n{\r\n    // Ask a confirmation if the user really wants to delete the entire column if it is not empty.\r\n    for (QGraphicsItem* selected : selectedItems)\r\n    {\r\n        SystemColumn* column = static_cast<SystemColumn*>(selected);\r\n\r\n        if (!column->isEmpty())\r\n        {\r\n            // Column cannot be deleted if it contains HW mapping items.\r\n            for (QGraphicsItem* childItem: column->getItems())\r\n            {\r\n                if (childItem->type() == HWMappingItem::Type)\r\n                {\r\n                    QMessageBox msgBox(QMessageBox::Warning, QCoreApplication::applicationName(),\r\n                        tr(\"The columns cannot be removed because they contain underlying HW. \"\r\n                        \"Move underlying HW components to another column before deletion.\"),\r\n                        QMessageBox::Ok, this);\r\n                    msgBox.exec();\r\n                    return;\r\n                }\r\n            }\r\n\r\n            QMessageBox msgBox(QMessageBox::Warning, QCoreApplication::applicationName(),\r\n                tr(\"The columns are not empty. Do you want to \"\r\n                \"delete the columns and all of their contents?\"),\r\n                QMessageBox::Yes | QMessageBox::No, this);\r\n\r\n            if (msgBox.exec() == QMessageBox::No)\r\n            {\r\n                return;\r\n            }\r\n\r\n            break;\r\n        }\r\n    }\r\n\r\n    // Delete the columns.\r\n    getDiagram()->clearSelection();\r\n    QSharedPointer<QUndoCommand> cmd(new QUndoCommand());\r\n\r\n    for (QGraphicsItem* selected : selectedItems)\r\n    {\r\n        SystemColumn* column = static_cast<SystemColumn*>(selected);\r\n        QUndoCommand* childCmd = new SystemColumnDeleteCommand(getDiagram(), column, cmd.data());\r\n        childCmd->redo();\r\n    }\r\n\r\n    getEditProvider()->addCommand(cmd);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SystemDesignWidget::deleteSelectedSWComponentItems()\r\n//-----------------------------------------------------------------------------\r\nvoid SystemDesignWidget::deleteSelectedSWComponentItems(QList<QGraphicsItem*> selectedItems)\r\n{\r\n    getDiagram()->clearSelection();\r\n    QSharedPointer<QUndoCommand> cmd(new QUndoCommand());\r\n\r\n    for (QGraphicsItem* selected : selectedItems)\r\n    {\r\n        SWComponentItem* component = static_cast<SWComponentItem*>(selected);\r\n\r\n        // Only non-imported SW component instances can be deleted.\r\n        if (!component->isImported())\r\n        {\r\n            QSharedPointer<Design> containingDesign = getDiagram()->getDesign();\r\n\r\n            SystemComponentDeleteCommand* childCmd = new SystemComponentDeleteCommand(component,\r\n                getDiagram()->getDesign(), cmd.data());\r\n\r\n            connect(childCmd, SIGNAL(componentInstanceRemoved(ComponentItem*)),\r\n                this, SIGNAL(componentInstanceRemoved(ComponentItem*)), Qt::UniqueConnection);\r\n            connect(childCmd, SIGNAL(componentInstantiated(ComponentItem*)),\r\n                this, SIGNAL(componentInstantiated(ComponentItem*)), Qt::UniqueConnection);\r\n\r\n            childCmd->redo();\r\n\r\n            for(Association* association : component->getAssociations())\r\n            {\r\n                QUndoCommand* associationRemoveCmd =\r\n                    new AssociationRemoveCommand(association, getDiagram(), childCmd);\r\n                associationRemoveCmd->redo();\r\n            }\r\n        }\r\n    }\r\n\r\n    getEditProvider()->addCommand(cmd);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SystemDesignWidget::deleteSelectedSWPortItems()\r\n//-----------------------------------------------------------------------------\r\nvoid SystemDesignWidget::deleteSelectedSWPortItems(QList<QGraphicsItem*> selectedItems)\r\n{\r\n    getDiagram()->clearSelection();\r\n    QSharedPointer<QUndoCommand> cmd(new QUndoCommand());\r\n\r\n    for (QGraphicsItem* selected : selectedItems)\r\n    {\r\n        SWPortItem* port = static_cast<SWPortItem*>(selected);\r\n\r\n        // Ports can be removed only if they are temporary.\r\n        if (port->isTemporary())\r\n        {\r\n            // Delete the port.\r\n            QUndoCommand* childCmd = new SWPortDeleteCommand(port, getDiagram()->getDesign(), cmd.data());\r\n            childCmd->redo();\r\n        }\r\n    }\r\n\r\n    getEditProvider()->addCommand(cmd);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SystemDesignWidget::deleteSelectedSWInterfaceItems()\r\n//-----------------------------------------------------------------------------\r\nvoid SystemDesignWidget::deleteSelectedSWInterfaceItems(QList<QGraphicsItem*> selectedItems)\r\n{\r\n    getDiagram()->clearSelection();\r\n    QSharedPointer<QUndoCommand> cmd(new QUndoCommand());\r\n\r\n    for (QGraphicsItem* selected : selectedItems)\r\n    {\r\n        SWInterfaceItem* interface = static_cast<SWInterfaceItem*>(selected);\r\n\r\n        QUndoCommand* childCmd = new SWInterfaceDeleteCommand(\r\n            interface, getDiagram()->getDesign(), getDiagram()->getEditedComponent(), cmd.data());\r\n        childCmd->redo();\r\n    }\r\n\r\n    getEditProvider()->addCommand(cmd);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SystemDesignWidget::deleteSelectedComConnectionItems()\r\n//-----------------------------------------------------------------------------\r\nvoid SystemDesignWidget::deleteSelectedComConnectionItems(QList<QGraphicsItem*> selectedItems)\r\n{\r\n    getDiagram()->clearSelection();\r\n    QSharedPointer<QUndoCommand> undoCommand(new QUndoCommand());\r\n\r\n    for (QGraphicsItem* selected: selectedItems)\r\n    {\r\n        auto comConnection = static_cast<ComGraphicsConnection*>(selected);\r\n        auto endPoint1 = static_cast<SWConnectionEndpoint*>(comConnection->endpoint1());\r\n        auto endPoint2 = static_cast<SWConnectionEndpoint*>(comConnection->endpoint2());\r\n\r\n        QUndoCommand* childCommand =\r\n            new ComConnectionDeleteCommand(comConnection, getDiagram()->getDesign(), undoCommand.data());\r\n        childCommand->redo();\r\n\r\n        deleteConnectedEndPoint(endPoint1, undoCommand);\r\n        deleteConnectedEndPoint(endPoint2, undoCommand);\r\n    }\r\n\r\n    getEditProvider()->addCommand(undoCommand);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SystemDesignWidget::deleteSelectedApiConnectionItems()\r\n//-----------------------------------------------------------------------------\r\nvoid SystemDesignWidget::deleteSelectedApiConnectionItems(QList<QGraphicsItem*> selectedItems)\r\n{\r\n    getDiagram()->clearSelection();\r\n    QSharedPointer<QUndoCommand> undoCommand(new QUndoCommand());\r\n\r\n    for (QGraphicsItem* selected : selectedItems)\r\n    {\r\n        auto apiConnection = static_cast<ApiGraphicsConnection*>(selected);\r\n        auto endPoint1 = static_cast<SWConnectionEndpoint*>(apiConnection->endpoint1());\r\n        auto endPoint2 = static_cast<SWConnectionEndpoint*>(apiConnection->endpoint2());\r\n\r\n        QUndoCommand* childCommand =\r\n            new ApiConnectionDeleteCommand(apiConnection, getDiagram()->getDesign(), undoCommand.data());\r\n        childCommand->redo();\r\n\r\n        deleteConnectedEndPoint(endPoint1, undoCommand);\r\n        deleteConnectedEndPoint(endPoint2, undoCommand);\r\n    }\r\n\r\n    getEditProvider()->addCommand(undoCommand);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SystemDesignWidget::deleteSelectedGraphicsConnectionItems()\r\n//-----------------------------------------------------------------------------\r\nvoid SystemDesignWidget::deleteSelectedGraphicsConnectionItems(QList<QGraphicsItem*> selectedItems)\r\n{\r\n    getDiagram()->clearSelection();\r\n    QSharedPointer<QUndoCommand> undoCommand(new QUndoCommand());\r\n\r\n    for (QGraphicsItem* selected : selectedItems)\r\n    {\r\n        auto connection = static_cast<GraphicsConnection*>(selected);\r\n        auto endPoint1 = static_cast<SWConnectionEndpoint*>(connection->endpoint1());\r\n        auto endPoint2 = static_cast<SWConnectionEndpoint*>(connection->endpoint2());\r\n\r\n        QUndoCommand* childCommand = new QUndoCommand(undoCommand.data());\r\n        childCommand->redo();\r\n\r\n        deleteConnectedEndPoint(endPoint1, undoCommand);\r\n        deleteConnectedEndPoint(endPoint2, undoCommand);\r\n    }\r\n\r\n    getEditProvider()->addCommand(undoCommand);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SystemDesignWidget::deleteConnectedEndPoint()\r\n//-----------------------------------------------------------------------------\r\nvoid SystemDesignWidget::deleteConnectedEndPoint(SWConnectionEndpoint* endPoint,\r\n    QSharedPointer<QUndoCommand> parentCommand)\r\n{\r\n    if (endPoint->isInvalid())\r\n    {\r\n        QUndoCommand* endPointCommand = nullptr;\r\n        if (endPoint->type() == SWPortItem::Type)\r\n        {\r\n            endPointCommand = new SWPortDeleteCommand(\r\n                static_cast<SWPortItem*>(endPoint), getDiagram()->getDesign(), parentCommand.data());\r\n        }\r\n        else\r\n        {\r\n            endPointCommand = new SWInterfaceDeleteCommand(static_cast<SWInterfaceItem*>(endPoint),\r\n                getDiagram()->getDesign(), getDiagram()->getEditedComponent(), parentCommand.data());\r\n        }\r\n\r\n        endPointCommand->redo();\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: addColumn()\r\n//-----------------------------------------------------------------------------\r\nvoid SystemDesignWidget::addColumn()\r\n{\r\n    if (onlySW_)\r\n    {\r\n        ColumnEditDialog dialog(this, true);\r\n\r\n        if (dialog.exec() == QDialog::Accepted)\r\n        {\r\n            if (dialog.getContentType() == ColumnTypes::IO)\r\n            {\r\n                QSharedPointer<ColumnDesc> desc(new ColumnDesc(\r\n                    dialog.name(), dialog.getContentType(), 0, GraphicsColumnConstants::IO_COLUMN_WIDTH));\r\n                getDiagram()->addColumn(desc);\r\n            }\r\n            else\r\n            {\r\n                QSharedPointer<ColumnDesc> desc(new ColumnDesc(\r\n                    dialog.name(), dialog.getContentType(), 0, GraphicsColumnConstants::COMPONENT_COLUMN_WIDTH));\r\n                getDiagram()->addColumn(desc);\r\n            }\r\n        }\r\n    }\r\n    else\r\n    {\r\n        ColumnEditDialog dialog(this, true);\r\n        dialog.hideContentSettings();\r\n\r\n        if (dialog.exec() == QDialog::Accepted)\r\n        {\r\n            getDiagram()->addColumn(QSharedPointer<ColumnDesc>(new ColumnDesc(dialog.name(),\r\n                ColumnTypes::COMPONENTS, 0, GraphicsColumnConstants::SYSTEM_COLUMN_WIDTH)));\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SystemDesignWidget::getImplementation()\r\n//-----------------------------------------------------------------------------\r\nKactusAttribute::Implementation SystemDesignWidget::getImplementation() const\r\n{\r\n    if (onlySW_)\r\n    {\r\n        return KactusAttribute::SW;\r\n    }\r\n    else\r\n    {\r\n        return KactusAttribute::SYSTEM;\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SystemDesignWidget::saveAs()\r\n//-----------------------------------------------------------------------------\r\nbool SystemDesignWidget::saveAs()\r\n{\r\n    VLNV oldVLNV = getEditedComponent()->getVlnv();\r\n\r\n    // Ask the user for a new VLNV and directory.\r\n\r\n    VLNV vlnv;\r\n    QString directory;\r\n\r\n    if (!NewObjectDialog::saveAsDialog(this, getLibHandler(), oldVLNV, vlnv, directory))\r\n    {\r\n        return false;\r\n    }\r\n\r\n    // create the vlnv for design and design configuration\r\n    VLNV designVLNV(VLNV::DESIGN, vlnv.getVendor(), vlnv.getLibrary(),\r\n                    vlnv.getName().remove(\".comp\") + \".design\", vlnv.getVersion());\r\n    VLNV desConfVLNV(VLNV::DESIGNCONFIGURATION, vlnv.getVendor(), vlnv.getLibrary(),\r\n                     vlnv.getName().remove(\".comp\") + \".designcfg\", vlnv.getVersion());\r\n\r\n    // Make a copy of the hierarchical component.\r\n    QSharedPointer<Component> oldComponent = getEditedComponent();\r\n\r\n    setEditedComponent(QSharedPointer<Component>(new Component(*getEditedComponent())));\r\n    getEditedComponent()->setVlnv(vlnv);\r\n\r\n    QSharedPointer<Design> design;\r\n    QSharedPointer<DesignConfiguration> designConf = getDiagram()->getDesignConfiguration();\r\n\r\n\t// Find the open view.\r\n\tQSharedPointer<SystemView> openView;\r\n\r\n\tfor (QSharedPointer<SystemView> currentView : getEditedComponent()->getSystemViews())\r\n\t{\r\n\t\tif ( getOpenViewName() == currentView->name() )\r\n\t\t{\r\n\t\t\topenView = currentView;\r\n\t\t\tbreak;\r\n\t\t}\r\n\t}\r\n\r\n    // If design configuration is used.\r\n    if (designConf)\r\n    {\r\n        // Make a copy of the design configuration with the new VLNVs.\r\n        designConf = QSharedPointer<DesignConfiguration>(new DesignConfiguration(*designConf));\r\n        designConf->setVlnv(desConfVLNV);\r\n        designConf->setDesignRef(designVLNV);\r\n\r\n\t\topenView->setHierarchyRef( desConfVLNV );\r\n\r\n        // Create design with new design vlnv.\r\n        design = getDiagram()->getDesign();\r\n        design->setVlnv(designVLNV);\r\n    }\r\n    // If component does not use design configuration then it references directly to design.\r\n    else\r\n    {\r\n\t\t// Set component to reference new design.\r\n\t\topenView->setHierarchyRef( designVLNV );\r\n        design = getDiagram()->getDesign();\r\n        design->setVlnv(designVLNV);\r\n    }\r\n\r\n    if (design == 0)\r\n    {\r\n        return false;\r\n    }\r\n\r\n    getDiagram()->updateHierComponent();\r\n\r\n    // get the paths to the original xml file\r\n    QFileInfo sourceInfo(getLibHandler()->getPath(oldComponent->getVlnv()));\r\n    QString sourcePath = sourceInfo.absolutePath();\r\n\r\n\t// Update the file paths and copy necessary files.\r\n\tfor (QSharedPointer<FileSet> fileSet : *oldComponent->getFileSets())\r\n\t{\r\n\t\tfor (QSharedPointer<File> file: *fileSet->getFiles())\r\n\t\t{\r\n\t\t\t// Get the absolute path to the file.\r\n\t\t\tQDir source(sourcePath);\r\n\t\t\tQString absoluteSource = source.absoluteFilePath(file->name());\r\n\r\n\t\t\t// If file is located under the source directory.\r\n\t\t\tif (!file->name().contains(QString(\"../\")))\r\n\t\t\t{\r\n\t\t\t\tQDir target(directory);\r\n\t\t\t\tQString absoluteTarget = target.absoluteFilePath(file->name());\r\n\r\n\t\t\t\tQFileInfo targetInfo(absoluteTarget);\r\n\r\n\t\t\t\ttarget.mkpath(targetInfo.absolutePath());\r\n\t\t\t\tQFile::copy(absoluteSource, absoluteTarget);\r\n\r\n\t\t\t}\r\n\t\t\t// If file is higher in directory hierarchy than the source directory.\r\n\t\t\telse\r\n\t\t\t{\r\n\t\t\t\t// Update the file name.\r\n\t\t\t\tfileSet->changeFileName(file->name(), absoluteSource);\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\r\n    // create the files for the documents\r\n\r\n    bool writeSucceeded = true;\r\n\r\n    getLibHandler()->beginSave();\r\n\r\n    // if design configuration is used then write it.\r\n    if (designConf && !getLibHandler()->writeModelToFile(directory, designConf))\r\n    {\r\n        writeSucceeded = false;\r\n    }\r\n    \r\n    if (!getLibHandler()->writeModelToFile(directory, design))\r\n    {\r\n        writeSucceeded = false;\r\n    }\r\n    if (!getLibHandler()->writeModelToFile(directory, getEditedComponent()))\r\n    {\r\n        writeSucceeded = false;\r\n    }\r\n\r\n    getLibHandler()->endSave();\r\n\r\n    if (writeSucceeded)\r\n    {\r\n        setDocumentName(getEditedComponent()->getVlnv().getName() + \" (\" + \r\n            getEditedComponent()->getVlnv().getVersion() + \")\");\r\n        return TabDocument::saveAs();\r\n    }\r\n    else\r\n    {\r\n        emit errorMessage(tr(\"Error saving design to disk.\"));\r\n        return false;\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SystemDesignWidget::getIdentifyingVLNV()\r\n//-----------------------------------------------------------------------------\r\nVLNV SystemDesignWidget::getIdentifyingVLNV() const\r\n{\r\n    const QSharedPointer<DesignConfiguration> designConf = getDiagram()->getDesignConfiguration();\r\n\r\n    if (designConf)\r\n    {\r\n        return designConf->getDesignRef();\r\n    }\r\n    else\r\n    {\r\n        return getEditedComponent()->getHierRef(getOpenViewName());\r\n    }\r\n}\r\n"
  },
  {
    "path": "editors/SystemDesign/SystemDesignWidget.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: SystemDesignWidget.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Joni-Matti Maatta\r\n// Date: 23.4.2012\r\n//\r\n// Description:\r\n// System design widget.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef SYSTEMDESIGNWIDGET_H\r\n#define SYSTEMDESIGNWIDGET_H\r\n\r\n#include <editors/common/DesignWidget.h>\r\n\r\nclass SWConnectionEndpoint;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! SystemDesignWidget class.\r\n//-----------------------------------------------------------------------------\r\nclass SystemDesignWidget : public DesignWidget\r\n{\r\n    Q_OBJECT\r\n\r\npublic:\r\n    /*!\r\n     *  Constructor.\r\n     */\r\n    SystemDesignWidget(bool onlySW, LibraryInterface* lh, QWidget* parent = 0);\r\n\r\n    /*!\r\n     *  Destructor.\r\n     */\r\n    ~SystemDesignWidget() final = default;\r\n\r\n    /*!\r\n     *  Sets the system identified with the given VLNV as the currently edited one.\r\n     *\r\n     *    @return False if there were errors opening the system; otherwise true.\r\n     */\r\n    bool setDesign(VLNV const& vlnv, QString const& viewName);\r\n    \r\n    /*!\r\n     *  Returns the supported draw modes.\r\n     */\r\n    virtual unsigned int getSupportedDrawModes() const;\r\n\r\n    /*!\r\n     *  Returns the implementation attribute.\r\n     */\r\n    virtual KactusAttribute::Implementation getImplementation() const;\r\n\r\n    /*!\r\n     *  Get the vlnv that can be used to identify the document.\r\n     *\r\n     *    @return The VLNV that identifies the document.\r\n     */\r\n    virtual VLNV getIdentifyingVLNV() const;\r\n\r\npublic slots:\r\n    //! Adds a new column to the diagram.\r\n    virtual void addColumn();\r\n\r\n    //! Saves the design as new object.\r\n    virtual bool saveAs();\r\n\r\n    /*!\r\n     *  Handler for item deletion in the design diagram.\r\n     */\r\n    virtual void onDeleteSelectedItems();\r\n\r\nprotected:\r\n    virtual void keyPressEvent(QKeyEvent* event);\r\n    virtual bool setDesign(QSharedPointer<Component> comp, const QString& viewName);\r\n\r\nprivate:\r\n    // Disable copying.\r\n    SystemDesignWidget(SystemDesignWidget const& rhs);\r\n    SystemDesignWidget& operator=(SystemDesignWidget const& rhs);\r\n\r\n    /*!\r\n     *  Delete the selected system columns items.\r\n     *\r\n     *    @param [in] selectedItems   The selected graphics items.\r\n     */\r\n    void deleteSelectedSystemColumns(QList<QGraphicsItem*> selectedItems);\r\n\r\n    /*!\r\n     *  Delete the selected SW component items.\r\n     *\r\n     *    @param [in] selectedItems   The selected graphics items.\r\n     */\r\n    void deleteSelectedSWComponentItems(QList<QGraphicsItem*> selectedItems);\r\n\r\n    /*!\r\n     *  Delete the selected SW port items.\r\n     *\r\n     *    @param [in] selectedItems   The selected graphics items.\r\n     */\r\n    void deleteSelectedSWPortItems(QList<QGraphicsItem*> selectedItems);\r\n\r\n    /*!\r\n     *  Delete the selected SW interface items.\r\n     *\r\n     *    @param [in] selectedItems   The selected graphics items.\r\n     */\r\n    void deleteSelectedSWInterfaceItems(QList<QGraphicsItem*> selectedItems);\r\n\r\n    /*!\r\n     *  Delete the selected COM connection items.\r\n     *\r\n     *    @param [in] selectedItems   The selected graphics items.\r\n     */\r\n    void deleteSelectedComConnectionItems(QList<QGraphicsItem*> selectedItems);\r\n\r\n    /*!\r\n     *  Delete the selected API connection items.\r\n     *\r\n     *    @param [in] selectedItems   The selected graphics items.\r\n     */\r\n    void deleteSelectedApiConnectionItems(QList<QGraphicsItem*> selectedItems);\r\n\r\n    /*!\r\n     *  Delete the selected graphics connection items.\r\n     *\r\n     *    @param [in] selectedItems   The selected graphics items.\r\n     */\r\n    void deleteSelectedGraphicsConnectionItems(QList<QGraphicsItem*> selectedItems);\r\n\r\n    /*!\r\n     *  Delete the connected end point.\r\n     *\r\n     *    @param [in] endPoint        The selected end point.\r\n     *    @param [in] parentCommand   The parent command.\r\n     */\r\n    void deleteConnectedEndPoint(SWConnectionEndpoint* endPoint, QSharedPointer<QUndoCommand> parentCommand);\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! If true, the widget is used for editing SW designs.\r\n    bool onlySW_;\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n\r\n#endif // SYSTEMDESIGNWIDGET_H\r\n"
  },
  {
    "path": "editors/SystemDesign/SystemDetailsEditor/ExportSWDialog.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ExportSWDialog.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Joni-Matti Maatta\r\n// Date: 31.7.2012\r\n//\r\n// Description:\r\n// Dialog for exporting SW from system design.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"ExportSWDialog.h\"\r\n\r\n#include <KactusAPI/include/LibraryInterface.h>\r\n\r\n#include <IPXACTmodels/Component/Component.h>\r\n\r\n#include <QMessageBox>\r\n#include <QCoreApplication>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ExportSWDialog::ExportSWDialog()\r\n//-----------------------------------------------------------------------------\r\nExportSWDialog::ExportSWDialog(LibraryInterface* lh, QWidget* parent):\r\nQDialog(parent),\r\nlh_(lh),\r\ninfoLabel_(new QLabel(tr(\"Exporting SW requires a new system component to be created.\"), this)),\r\nvlnvEdit_(new VLNVEditor(VLNV::COMPONENT, lh, this, this)),\r\ndirectoryEditor_(new LibrarySelectorWidget(this)),\r\nbuttonBox_(new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, Qt::Horizontal, this)),\r\nlayout_(new QVBoxLayout(this))\r\n{\r\n    setWindowTitle(tr(\"Export SW\"));\r\n\r\n    // Set widget settings.\r\n    vlnvEdit_->setTitle(tr(\"VLNV for the new system component\"));\r\n    vlnvEdit_->addNameExtension(\".sysdesign\");\r\n    vlnvEdit_->addNameExtension(\".sysdesigncfg\");\r\n\r\n    QGroupBox* separator = new QGroupBox(this);\r\n    separator->setFlat(true);\r\n\r\n    directoryEditor_->layout()->setContentsMargins(0,11,0,11);\r\n\r\n    // Create layouts.\r\n    layout_->addWidget(infoLabel_);\r\n    layout_->addSpacing(12);\r\n    layout_->addWidget(vlnvEdit_);\r\n    layout_->addWidget(directoryEditor_);\r\n    layout_->addWidget(separator);\r\n    layout_->addWidget(buttonBox_);\r\n\r\n    // Setup connections.\r\n    connect(buttonBox_->button(QDialogButtonBox::Ok), SIGNAL(clicked()),\r\n        this, SLOT(accept()), Qt::UniqueConnection);\r\n    connect(buttonBox_->button(QDialogButtonBox::Cancel), SIGNAL(clicked()),\r\n        this, SLOT(reject()), Qt::UniqueConnection);\r\n\r\n    connect(vlnvEdit_, SIGNAL(contentChanged()), this, SLOT(updateDirectory()), Qt::UniqueConnection);\r\n    connect(vlnvEdit_, SIGNAL(contentChanged()), this, SLOT(validate()), Qt::UniqueConnection);\r\n\r\n    setFixedHeight(sizeHint().height());\r\n    resize(400, sizeHint().height());\r\n    validate();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ExportSWDialog::~ExportSWDialog()\r\n//-----------------------------------------------------------------------------\r\nExportSWDialog::~ExportSWDialog()\r\n{\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ExportSWDialog::accept()\r\n//-----------------------------------------------------------------------------\r\nvoid ExportSWDialog::accept()\r\n{\r\n    VLNV vlnv = vlnvEdit_->getVLNV();\r\n\r\n    VLNV designVLNV(VLNV::DESIGN, vlnv.getVendor(), vlnv.getLibrary(),\r\n        vlnv.getName() + \".sysdesign\", vlnv.getVersion());\r\n    VLNV desConfVLNV(VLNV::DESIGNCONFIGURATION, vlnv.getVendor(), vlnv.getLibrary(),\r\n        vlnv.getName() + \".sysdesigncfg\", vlnv.getVersion());\r\n\r\n    if (lh_->contains(vlnv))\r\n    {\r\n        QMessageBox msgBox(QMessageBox::Warning, QCoreApplication::applicationName(),\r\n                           tr(\"VLNV %1 already exists in the library.\").arg(vlnv.toString()),\r\n                           QMessageBox::Ok, (QWidget*)parent());\r\n        msgBox.exec();\r\n        return;\r\n    }\r\n\r\n    if (lh_->contains(designVLNV))\r\n    {\r\n        QMessageBox msgBox(QMessageBox::Warning, QCoreApplication::applicationName(),\r\n            tr(\"VLNV %1 already exists in the library.\").arg(designVLNV.toString()),\r\n            QMessageBox::Ok, (QWidget*)parent());\r\n        msgBox.exec();\r\n        return;\r\n    }\r\n\r\n    if (lh_->contains(desConfVLNV))\r\n    {\r\n        QMessageBox msgBox(QMessageBox::Warning, QCoreApplication::applicationName(),\r\n            tr(\"VLNV %1 already exists in the library.\").arg(desConfVLNV.toString()),\r\n            QMessageBox::Ok, (QWidget*)parent());\r\n        msgBox.exec();\r\n        return;\r\n    }\r\n\r\n    QDialog::accept();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ExportSWDialog::getVLNV()\r\n//-----------------------------------------------------------------------------\r\nVLNV ExportSWDialog::getVLNV() const\r\n{\r\n    return vlnvEdit_->getVLNV();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ExportSWDialog::getPath()\r\n//-----------------------------------------------------------------------------\r\nQString ExportSWDialog::getPath() const\r\n{\r\n    return directoryEditor_->getPath();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: updateDirectory()\r\n//-----------------------------------------------------------------------------\r\nvoid ExportSWDialog::updateDirectory()\r\n{\r\n    QString vlnvDir;\r\n\r\n    VLNV vlnv = vlnvEdit_->getVLNV();\r\n\r\n    if (!vlnv.getVendor().isEmpty())\r\n    {\r\n        vlnvDir += \"/\" + vlnv.getVendor();\r\n\r\n        if (!vlnv.getLibrary().isEmpty())\r\n        {\r\n            vlnvDir += \"/\" + vlnv.getLibrary();\r\n\r\n            if (!vlnv.getName().isEmpty())\r\n            {\r\n                vlnvDir += \"/\" + vlnv.getName();\r\n\r\n                if (!vlnv.getVersion().isEmpty())\r\n                {\r\n                    vlnvDir += \"/\" + vlnv.getVersion();\r\n                }\r\n            }\r\n        }\r\n    }\r\n\r\n    directoryEditor_->updatePath(vlnvDir);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ExportSWDialog::validate()\r\n//-----------------------------------------------------------------------------\r\nvoid ExportSWDialog::validate()\r\n{\r\n    QAbstractButton* btnOK = buttonBox_->button(QDialogButtonBox::Ok);\r\n    btnOK->setEnabled(vlnvEdit_->isValid() && directoryEditor_->isValid());\r\n}\r\n"
  },
  {
    "path": "editors/SystemDesign/SystemDetailsEditor/ExportSWDialog.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ExportSWDialog.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Joni-Matti Maatta\r\n// Date: 14.8.2012\r\n//\r\n// Description:\r\n// Dialog for exporting SW from system design.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef EXPORTSWDIALOG_H\r\n#define EXPORTSWDIALOG_H\r\n\r\n#include <common/widgets/vlnvEditor/vlnveditor.h>\r\n#include <common/widgets/LibrarySelectorWidget/LibrarySelectorWidget.h>\r\n\r\n#include <QLabel>\r\n#include <QVBoxLayout>\r\n#include <QDialog>\r\n#include <QDialogButtonBox>\r\n\r\nclass Component;\r\n\r\n//-----------------------------------------------------------------------------\r\n// Dialog for configuring settings how to switch HW for a system design.\r\n//-----------------------------------------------------------------------------\r\nclass ExportSWDialog : public QDialog\r\n{\r\n    Q_OBJECT\r\n\r\npublic:\r\n    /*!\r\n     *  Constructor.\r\n     *\r\n     *    @param [in] lh         The library interface.\r\n     *    @param [in] parent     The parent widget.\r\n     */\r\n    ExportSWDialog(LibraryInterface* lh, QWidget* parent);\r\n\r\n    /*!\r\n     *  Destructor.\r\n     */\r\n    ~ExportSWDialog();\r\n\r\n    /*!\r\n     *  Returns the base VLNV for sysdesign and sysdesigncfg.\r\n     */\r\n    VLNV getVLNV() const;\r\n\r\n    /*!\r\n     *  Returns the selected path for new IP-XACT objects.\r\n     */\r\n    QString getPath() const;\r\n\r\nprivate slots:\r\n    /*!\r\n     *  Called when the user presses OK button.\r\n     */\r\n    virtual void accept();\r\n\r\n    /*!\r\n     *  Updates the directory based on the current VLNV.\r\n     */\r\n    void updateDirectory();\r\n\r\n    /*!\r\n     *  Validates the contents of the dialog and enables/disables the OK button based on the validation result.\r\n     */\r\n    void validate();\r\n\r\nprivate:\r\n    // Disable copying.\r\n    ExportSWDialog(ExportSWDialog const& rhs);\r\n    ExportSWDialog& operator=(ExportSWDialog const& rhs);\r\n    \r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! The library interface.\r\n    LibraryInterface* lh_;\r\n\r\n    //! The new HW component.\r\n    QSharedPointer<Component> component_;\r\n\r\n    //! Label for information text.\r\n    QLabel* infoLabel_;\r\n\r\n    //! VLNV editor for system component VLNV.\r\n    VLNVEditor* vlnvEdit_;\r\n\r\n    //! The editor to select the directory to save to. \r\n    LibrarySelectorWidget* directoryEditor_;\r\n\r\n    //! Button box for OK and Cancel buttons.\r\n    QDialogButtonBox* buttonBox_;\r\n\r\n    //! The layout for the UI widgets.\r\n    QVBoxLayout* layout_;\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n\r\n#endif // EXPORTSWDIALOG_H\r\n"
  },
  {
    "path": "editors/SystemDesign/SystemDetailsEditor/SwitchHWDialog.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: SwitchHWDialog.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Joni-Matti Maatta\r\n// Date: 31.7.2012\r\n//\r\n// Description:\r\n// Dialog for configuring settings how to switch HW for a system design.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"SwitchHWDialog.h\"\r\n\r\n#include <IPXACTmodels/Component/Component.h>\r\n\r\n#include <KactusAPI/include/LibraryInterface.h>\r\n\r\n#include <common/widgets/LineEditEx/LineEditEx.h>\r\n#include <common/widgets/LibrarySelectorWidget/LibrarySelectorWidget.h>\r\n\r\n#include <QMessageBox>\r\n#include <QCoreApplication>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SwitchHWDialog::SwitchHWDialog()\r\n//-----------------------------------------------------------------------------\r\nSwitchHWDialog::SwitchHWDialog(QSharedPointer<Component> component, QString const& viewName,\r\n                               LibraryInterface* lh, QWidget* parent):\r\nQDialog(parent),\r\nlh_(lh),\r\ncomponent_(component),\r\ninfoLabel_(new QLabel(tr(\"Choose how the SW architecture specified in this system design is mapped to new HW.\"),\r\n                      this)),\r\nhwViewRefLabel_(new QLabel(tr(\"HW design configuration to map:\"), this)),\r\nhwViewRefCombo_(new QComboBox(this)),\r\nviewNameLabel_(new QLabel(tr(\"Name of the system view to be created for the mapped HW component:\"), this)),\r\nviewNameEdit_(new LineEditEx(this)),\r\nviewNameMatcher_(),\r\nactionGroupBox_(new QGroupBox(tr(\"Action\"), this)),\r\nactionGroup_(new QButtonGroup(this)),\r\nmoveRadioButton_(new QRadioButton(tr(\"Move system design\"), this)),\r\nmoveDescLabel_(new QLabel(tr(\"Removes the system view from the previously mapped HW and moves it to the new one.\"),\r\n                          this)),\r\ncopyRadioButton_(new QRadioButton(tr(\"Copy as a new system design\"), this)),\r\ncopyDescLabel_(new QLabel(tr(\"Creates an identical copy of the system design with a new VLNV and adds a new \"\r\n                          \"system view to the HW component.\"), this)),\r\nvlnvEdit_(new VLNVEditor(VLNV::DESIGN, lh, this, this)),\r\ndirectoryEditor_(new LibrarySelectorWidget(this)),\r\nbuttonBox_(new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, Qt::Horizontal, this)),\r\nlayout_(new QVBoxLayout(this))\r\n{\r\n    setWindowTitle(tr(\"Switch HW\"));\r\n\r\n    // Set widget settings.\r\n    hwViewRefLabel_->setVisible(false);\r\n    hwViewRefCombo_->setVisible(false);\r\n    hwViewRefCombo_->setEnabled(false);\r\n\r\n    viewNameEdit_->setDisallowedInputs(component->getSystemViewNames());\r\n    viewNameEdit_->setMessageIcon(QPixmap(\":/icons/common/graphics/exclamation.png\"));\r\n    viewNameEdit_->setMessageTemplate(\"System view name '%1' is already in use!\");\r\n    viewNameEdit_->setContentMatcher(&viewNameMatcher_);\r\n    viewNameEdit_->setText(viewName);\r\n\r\n    moveRadioButton_->setChecked(true);\r\n    \r\n    QFont font = moveRadioButton_->font();\r\n    font.setBold(true);\r\n    moveRadioButton_->setFont(font);\r\n    moveRadioButton_->setStyleSheet(\"QRadioButton::indicator { width: 15px; height: 15px; }\");\r\n    copyRadioButton_->setFont(font);\r\n    copyRadioButton_->setStyleSheet(\"QRadioButton::indicator { width: 15px; height: 15px; }\");\r\n\r\n    moveDescLabel_->setStyleSheet(\"QLabel { padding-left: 19px; }\");\r\n    moveDescLabel_->setWordWrap(true);\r\n    copyDescLabel_->setStyleSheet(\"QLabel { padding-left: 19px; }\");\r\n    copyDescLabel_->setWordWrap(true);\r\n\r\n    vlnvEdit_->setTitle(tr(\"VLNV for the new system design and design configuration\"));\r\n    vlnvEdit_->setVisible(false);\r\n    vlnvEdit_->addNameExtension(\".sysdesign\");\r\n    vlnvEdit_->addNameExtension(\".sysdesigncfg\");\r\n\r\n    directoryEditor_->layout()->setContentsMargins(0,11,0,11);\r\n    directoryEditor_->setVisible(false);\r\n\r\n    actionGroup_->addButton(moveRadioButton_);\r\n    actionGroup_->addButton(copyRadioButton_);\r\n\r\n    // Create layouts.\r\n    QVBoxLayout* groupLayout = new QVBoxLayout(actionGroupBox_);\r\n    groupLayout->addWidget(moveRadioButton_);\r\n    groupLayout->addWidget(moveDescLabel_);\r\n    groupLayout->addWidget(copyRadioButton_);\r\n    groupLayout->addWidget(copyDescLabel_);\r\n\r\n    layout_->addWidget(infoLabel_);\r\n    layout_->addSpacing(12);\r\n    layout_->addWidget(hwViewRefLabel_);\r\n    layout_->addWidget(hwViewRefCombo_);\r\n    layout_->addWidget(viewNameLabel_);\r\n    layout_->addWidget(viewNameEdit_);\r\n    layout_->addWidget(actionGroupBox_);\r\n    layout_->addWidget(vlnvEdit_);\r\n    layout_->addWidget(directoryEditor_);\r\n    layout_->addStretch(1);\r\n    layout_->addWidget(buttonBox_);\r\n\r\n    // Setup connections.\r\n    connect(actionGroup_, SIGNAL(buttonClicked(QAbstractButton*)),\r\n            this, SLOT(actionChanged(QAbstractButton*)), Qt::UniqueConnection);\r\n    connect(buttonBox_->button(QDialogButtonBox::Ok), SIGNAL(clicked()),\r\n            this, SLOT(accept()), Qt::UniqueConnection);\r\n    connect(buttonBox_->button(QDialogButtonBox::Cancel), SIGNAL(clicked()),\r\n            this, SLOT(reject()), Qt::UniqueConnection);\r\n\r\n    connect(vlnvEdit_, SIGNAL(contentChanged()), this, SLOT(updateDirectory()), Qt::UniqueConnection);\r\n    connect(vlnvEdit_, SIGNAL(contentChanged()), this, SLOT(validate()), Qt::UniqueConnection);\r\n    connect(viewNameEdit_, SIGNAL(textChanged(QString const&)), this, SLOT(validate()), Qt::UniqueConnection);\r\n\r\n    setFixedHeight(sizeHint().height());\r\n    validate();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SwitchHWDialog::~SwitchHWDialog()\r\n//-----------------------------------------------------------------------------\r\nSwitchHWDialog::~SwitchHWDialog()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SwitchHWDialog::showHWViewSelector()\r\n//-----------------------------------------------------------------------------\r\nvoid SwitchHWDialog::showHWViewSelector()\r\n{\r\n    hwViewRefCombo_->addItems(component_->getHierViews());\r\n    hwViewRefLabel_->setVisible(true);\r\n    hwViewRefCombo_->setVisible(true);\r\n    hwViewRefCombo_->setEnabled(true);\r\n\r\n    layout_->activate();\r\n    setFixedHeight(sizeHint().height());\r\n    validate();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SwitchHWDialog::accept()\r\n//-----------------------------------------------------------------------------\r\nvoid SwitchHWDialog::accept()\r\n{\r\n    // If copy action has been chosen, check if the sysdesign or sysdesigncfg VLNV is already in use.\r\n    if (copyRadioButton_->isChecked())\r\n    {\r\n        VLNV vlnv = vlnvEdit_->getVLNV();\r\n\r\n        VLNV designVLNV(VLNV::DESIGN, vlnv.getVendor(), vlnv.getLibrary(),\r\n                        vlnv.getName() + \".sysdesign\", vlnv.getVersion());\r\n        VLNV desConfVLNV(VLNV::DESIGNCONFIGURATION, vlnv.getVendor(), vlnv.getLibrary(),\r\n                         vlnv.getName() + \".sysdesigncfg\", vlnv.getVersion());\r\n\r\n        if (lh_->contains(designVLNV))\r\n        {\r\n            QMessageBox msgBox(QMessageBox::Warning, QCoreApplication::applicationName(),\r\n                               tr(\"VLNV %1 already exists in the library.\").arg(designVLNV.toString()),\r\n                               QMessageBox::Ok, (QWidget*)parent());\r\n            msgBox.exec();\r\n            return;\r\n        }\r\n\r\n        if (lh_->contains(desConfVLNV))\r\n        {\r\n            QMessageBox msgBox(QMessageBox::Warning, QCoreApplication::applicationName(),\r\n                               tr(\"VLNV %1 already exists in the library.\").arg(desConfVLNV.toString()),\r\n                               QMessageBox::Ok, (QWidget*)parent());\r\n            msgBox.exec();\r\n            return;\r\n        }\r\n    }\r\n\r\n    QDialog::accept();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SwitchHWDialog::actionChanged()\r\n//-----------------------------------------------------------------------------\r\nvoid SwitchHWDialog::actionChanged(QAbstractButton* button)\r\n{\r\n    vlnvEdit_->setVisible(button == copyRadioButton_);\r\n    directoryEditor_->setVisible(button == copyRadioButton_);\r\n    layout_->activate();\r\n    setFixedHeight(sizeHint().height());\r\n\r\n    validate();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SwitchHWDialog::getHWViewRef()\r\n//-----------------------------------------------------------------------------\r\nQString SwitchHWDialog::getHWViewRef() const\r\n{\r\n    return hwViewRefCombo_->currentText();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SwitchHWDialog::getSystemViewName()\r\n//-----------------------------------------------------------------------------\r\nQString SwitchHWDialog::getSystemViewName() const\r\n{\r\n    return viewNameEdit_->text();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SwitchHWDialog::getVLNV()\r\n//-----------------------------------------------------------------------------\r\nVLNV SwitchHWDialog::getVLNV() const\r\n{\r\n    return vlnvEdit_->getVLNV();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SwitchHWDialog::isCopyActionSelected()\r\n//-----------------------------------------------------------------------------\r\nbool SwitchHWDialog::isCopyActionSelected() const\r\n{\r\n    return copyRadioButton_->isChecked();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SwitchHWDialog::getPath()\r\n//-----------------------------------------------------------------------------\r\nQString SwitchHWDialog::getPath() const\r\n{\r\n    return directoryEditor_->getPath();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: updateDirectory()\r\n//-----------------------------------------------------------------------------\r\nvoid SwitchHWDialog::updateDirectory()\r\n{\r\n    QString vlnvDir;\r\n\r\n    VLNV vlnv = vlnvEdit_->getVLNV();\r\n\r\n    if (!vlnv.getVendor().isEmpty())\r\n    {\r\n        vlnvDir += \"/\" + vlnv.getVendor();\r\n\r\n        if (!vlnv.getLibrary().isEmpty())\r\n        {\r\n            vlnvDir += \"/\" + vlnv.getLibrary();\r\n\r\n            if (!vlnv.getName().isEmpty())\r\n            {\r\n                vlnvDir += \"/\" + vlnv.getName();\r\n\r\n                if (!vlnv.getVersion().isEmpty())\r\n                {\r\n                    vlnvDir += \"/\" + vlnv.getVersion();\r\n                }\r\n            }\r\n        }\r\n    }\r\n\r\n    directoryEditor_->updatePath(vlnvDir);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SwitchHWDialog::validate()\r\n//-----------------------------------------------------------------------------\r\nvoid SwitchHWDialog::validate()\r\n{\r\n    QAbstractButton* btnOK = buttonBox_->button(QDialogButtonBox::Ok);\r\n    btnOK->setEnabled(!viewNameEdit_->text().isEmpty() && viewNameEdit_->isInputValid() &&\r\n                      (moveRadioButton_->isChecked() || vlnvEdit_->isValid()) &&\r\n                      (!hwViewRefCombo_->isEnabled() || hwViewRefCombo_->count() > 0) &&\r\n                      directoryEditor_->isValid());\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SwitchHWDialog::setViewNameSuggestions()\r\n//-----------------------------------------------------------------------------\r\nvoid SwitchHWDialog::setViewNameSuggestions(QStringList const& suggestions)\r\n{\r\n    viewNameMatcher_.setItems(suggestions);\r\n}\r\n"
  },
  {
    "path": "editors/SystemDesign/SystemDetailsEditor/SwitchHWDialog.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: SwitchHWDialog.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Joni-Matti Maatta\r\n// Date: 31.7.2012\r\n//\r\n// Description:\r\n// Dialog for configuring settings how to switch HW for a system design.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef SWITCHHWDIALOG_H\r\n#define SWITCHHWDIALOG_H\r\n\r\n#include <common/widgets/vlnvEditor/vlnveditor.h>\r\n#include <common/widgets/assistedLineEdit/BasicLineContentMatcher.h>\r\n\r\n#include <QComboBox>\r\n#include <QRadioButton>\r\n#include <QLabel>\r\n#include <QVBoxLayout>\r\n#include <QDialog>\r\n#include <QButtonGroup>\r\n#include <QDialogButtonBox>\r\n\r\nclass Component;\r\nclass LineEditEx;\r\nclass LibrarySelectorWidget;\r\n//-----------------------------------------------------------------------------\r\n// Dialog for configuring settings how to switch HW for a system design.\r\n//-----------------------------------------------------------------------------\r\nclass SwitchHWDialog : public QDialog\r\n{\r\n    Q_OBJECT\r\n\r\npublic:\r\n    /*!\r\n     *  Constructor.\r\n     *\r\n     *    @param [in] component  The new HW component to which to switch.\r\n     *    @param [in] viewName   The initial name suggestion for the system view.\r\n     *    @param [in] lh         The library interface.\r\n     *    @param [in] parent     The parent widget.\r\n     */\r\n    SwitchHWDialog(QSharedPointer<Component> component, QString const& viewName, LibraryInterface* lh,\r\n                   QWidget* parent);\r\n\r\n    /*!\r\n     *  Destructor.\r\n     */\r\n    ~SwitchHWDialog();\r\n\r\n    /*!\r\n     *  Sets the system view name suggestions.\r\n     *\r\n     *    @param [in] suggestions The list of suggestions.\r\n     */\r\n    void setViewNameSuggestions(QStringList const& suggestions);\r\n\r\n    /*!\r\n     *  Shows a combo box selection for choosing a HW view reference.\r\n     */\r\n    void showHWViewSelector();\r\n\r\n    /*!\r\n     *  Returns the selected HW view reference.\r\n     */\r\n    QString getHWViewRef() const;\r\n\r\n    /*!\r\n     *  Returns the system view name.\r\n     */\r\n    QString getSystemViewName() const;\r\n\r\n    /*!\r\n     *  Returns the base VLNV for sysdesign and sysdesigncfg.\r\n     */\r\n    VLNV getVLNV() const;\r\n\r\n    /*!\r\n     *  Returns the selected path for new IP-XACT objects.\r\n     */\r\n    QString getPath() const;\r\n\r\n    /*!\r\n     *  If true, the design should be copied instead of moving.\r\n     */\r\n    bool isCopyActionSelected() const;\r\n\r\nprivate slots:\r\n    /*!\r\n     *  Called when the user presses OK button.\r\n     */\r\n    virtual void accept();\r\n\r\n    /*!\r\n     *  Called when the action selection has changed.\r\n     *\r\n     *    @param [in] button The action button.\r\n     */\r\n    void actionChanged(QAbstractButton* button);\r\n\r\n    /*!\r\n     *  Updates the directory based on the current VLNV.\r\n     */\r\n    void updateDirectory();\r\n\r\n    /*!\r\n     *  Validates the contents of the dialog and enables/disables the OK button based on the validation result.\r\n     */\r\n    void validate();\r\n\r\nprivate:\r\n    // Disable copying.\r\n    SwitchHWDialog(SwitchHWDialog const& rhs);\r\n    SwitchHWDialog& operator=(SwitchHWDialog const& rhs);\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! The library interface.\r\n    LibraryInterface* lh_;\r\n\r\n    //! The new HW component.\r\n    QSharedPointer<Component> component_;\r\n\r\n    //! Label for information text.\r\n    QLabel* infoLabel_;\r\n\r\n    //! Label for HW view reference.\r\n    QLabel* hwViewRefLabel_;\r\n\r\n    //! Combo box for HW view reference.\r\n    QComboBox* hwViewRefCombo_;\r\n\r\n    //! Label for system view name.\r\n    QLabel* viewNameLabel_;\r\n\r\n    //! Edit box for system view name.\r\n    LineEditEx* viewNameEdit_;\r\n\r\n    //! View name content matcher.\r\n    BasicLineContentMatcher viewNameMatcher_;\r\n\r\n    //! Group box for radio buttons.\r\n    QGroupBox* actionGroupBox_;\r\n\r\n    //! Radio button group.\r\n    QButtonGroup* actionGroup_;\r\n\r\n    //! Radio button for move action.\r\n    QRadioButton* moveRadioButton_;\r\n\r\n    //! Description label for move action.\r\n    QLabel* moveDescLabel_;\r\n\r\n    //! Radio button for copy action.\r\n    QRadioButton* copyRadioButton_;\r\n\r\n    //! Description label for copy action.\r\n    QLabel* copyDescLabel_;\r\n\r\n    //! VLNV editor for design/designcfg VLNV (shown in case of copy action).\r\n    VLNVEditor* vlnvEdit_;\r\n\r\n\t//! The editor to select the directory to save to. \r\n    LibrarySelectorWidget* directoryEditor_;\r\n\r\n    //! Button box for OK and Cancel buttons.\r\n    QDialogButtonBox* buttonBox_;\r\n\r\n    //! The layout for the UI widgets.\r\n    QVBoxLayout* layout_;\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n\r\n#endif // SWITCHHWDIALOG_H\r\n"
  },
  {
    "path": "editors/SystemDesign/SystemDetailsEditor/SystemDetailsEditor.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: SystemDetailsEditor.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Joni-Matti Maatta\r\n// Date: 30.7.2012\r\n//\r\n// Description:\r\n// Docking editor for system details.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"SystemDetailsEditor.h\"\r\n\r\n#include \"SwitchHWDialog.h\"\r\n#include \"ExportSWDialog.h\"\r\n\r\n#include <editors/common/DesignWidget.h>\r\n#include <editors/common/DesignDiagram.h>\r\n\r\n#include <common/dialogs/newObjectDialog/newobjectdialog.h>\r\n\r\n#include <IPXACTmodels/DesignConfiguration/DesignConfiguration.h>\r\n#include <IPXACTmodels/kactusExtensions/SystemView.h>\r\n#include <IPXACTmodels/Design/Design.h>\r\n\r\n#include <KactusAPI/include/LibraryInterface.h>\r\n\r\n#include <QVBoxLayout>\r\n#include <QGridLayout>\r\n#include <QFormLayout>\r\n#include <QMessageBox>\r\n#include <QCoreApplication>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SystemDetailsEditor::SystemDetailsEditor()\r\n//-----------------------------------------------------------------------------\r\nSystemDetailsEditor::SystemDetailsEditor(LibraryInterface* handler, QWidget *parent):\r\nQWidget(parent),\r\nhandler_(handler),\r\nhwRefEditor_(new VLNVEditor(VLNV::COMPONENT, handler, parent, parent->parentWidget())),\r\nviewSelector_(new QComboBox(this)),\r\napplyButton_(new QPushButton(tr(\"Apply\"), this)),\r\nrevertButton_(new QPushButton(tr(\"Revert\"), this)),\r\nremoveMappingButton_(new QPushButton(tr(\"Remove HW\"), this)),\r\nexportButton_(new QPushButton(tr(\"Export SW\"), this)),\r\ncomponent_(),\r\ndesignWidget_(NULL),\r\nsystemView_(0)\r\n{\r\n    hwRefEditor_->setTitle(tr(\"HW component reference\"));\r\n\r\n    setupLayout();\r\n    setupConnections();\r\n    clear();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SystemDetailsEditor::~SystemDetailsEditor()\r\n//-----------------------------------------------------------------------------\r\nSystemDetailsEditor::~SystemDetailsEditor()\r\n{\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SystemDetailsEditor::setSystem()\r\n//-----------------------------------------------------------------------------\r\nvoid SystemDetailsEditor::setSystem(DesignWidget* designWidget)\r\n{\r\n    // if there was a previous design being displayed.\r\n    if (designWidget_)\r\n    {\r\n        designWidget_->disconnect(this);\r\n\r\n        disconnect(viewSelector_, SIGNAL(currentTextChanged(const QString&)),\r\n                   this, SLOT(onViewRefChanged(const QString&)));\r\n    }\r\n\r\n    // connect the new design.\r\n    designWidget_ = designWidget;\r\n    connect(designWidget_, SIGNAL(refreshed()), this, SLOT(onRefresh()), Qt::UniqueConnection);\r\n    \r\n    // Update the HW reference VLNV and view combo box based on the component whose design is being edited.\r\n    component_ = designWidget->getEditedComponent();\r\n    systemView_ = component_->findSystemView(designWidget->getOpenViewName());\r\n\r\n    // Clear the editors initially.\r\n    hwRefEditor_->setVLNV(VLNV());\r\n    viewSelector_->clear();\r\n\r\n    // Fill them only if the component is not a system component (system component is always unmapped).\r\n    if (component_->getImplementation() != KactusAttribute::SYSTEM)\r\n    {\r\n        hwRefEditor_->setVLNV(component_->getVlnv());\r\n        viewSelector_->addItems(component_->getHierViews());\r\n\r\n        if (systemView_ != 0)\r\n        {\r\n            viewSelector_->setCurrentIndex(component_->getHierViews().indexOf(systemView_->getHWViewRef()));\r\n        }\r\n    }\r\n\r\n    hwRefEditor_->setRevisionFilter(true, component_->getRevision());\r\n    hwRefEditor_->setEnabled(!designWidget_->isProtected());\r\n    viewSelector_->setEnabled(!designWidget_->isProtected());\r\n    removeMappingButton_->setEnabled(!designWidget_->isProtected() && \r\n        component_->getImplementation() != KactusAttribute::SYSTEM);\r\n    exportButton_->setEnabled(component_->getImplementation() != KactusAttribute::SYSTEM);\r\n    revertButton_->setDisabled(true);\r\n\r\n    connect(viewSelector_, SIGNAL(currentTextChanged(const QString&)),\r\n            this, SLOT(onViewRefChanged(const QString&)), Qt::UniqueConnection);\r\n\r\n    // display this widget\r\n    //parentWidget()->raise();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SystemDetailsEditor::clear()\r\n//-----------------------------------------------------------------------------\r\nvoid SystemDetailsEditor::clear()\r\n{\r\n    if (designWidget_)\r\n    {\r\n        designWidget_->disconnect(this);\r\n        designWidget_ = 0;\r\n\r\n        disconnect(viewSelector_, SIGNAL(currentTextChanged(const QString&)),\r\n                   this, SLOT(onViewRefChanged(const QString&)));\r\n    }\r\n\r\n    hwRefEditor_->setVLNV(VLNV());\r\n    hwRefEditor_->setDisabled(true);\r\n\r\n    viewSelector_->clear();\r\n    viewSelector_->setDisabled(true);\r\n\r\n    applyButton_->setDisabled(true);\r\n    revertButton_->setDisabled(true);\r\n    removeMappingButton_->setDisabled(true);\r\n    exportButton_->setDisabled(true);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SystemDetailsEditor::onRefresh()\r\n//-----------------------------------------------------------------------------\r\nvoid SystemDetailsEditor::onRefresh()\r\n{\r\n    setSystem(designWidget_);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SystemDetailsEditor::setLocked()\r\n//-----------------------------------------------------------------------------\r\nvoid SystemDetailsEditor::setLocked(bool locked)\r\n{\r\n    hwRefEditor_->setEnabled(!locked);\r\n    viewSelector_->setEnabled(!locked);\r\n    removeMappingButton_->setEnabled(!locked && component_->getImplementation() != KactusAttribute::SYSTEM);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SystemDetailsEditor::setupLayout()\r\n//-----------------------------------------------------------------------------\r\nvoid SystemDetailsEditor::setupLayout()\r\n{\r\n    QGridLayout* buttonLayout = new QGridLayout();\r\n    buttonLayout->addWidget(applyButton_, 0, 0);\r\n    buttonLayout->addWidget(revertButton_, 0, 1);\r\n    buttonLayout->addWidget(exportButton_, 1, 0);\r\n    buttonLayout->addWidget(removeMappingButton_, 1, 1);\r\n\r\n    QFormLayout* selectorLayout = new QFormLayout();\r\n    selectorLayout->addRow(tr(\"HW component view:\"), viewSelector_);\r\n\r\n    QVBoxLayout* topLayout = new QVBoxLayout(this);\r\n    topLayout->addWidget(hwRefEditor_);\r\n    topLayout->addLayout(selectorLayout);\r\n    topLayout->addSpacing(12);\r\n    topLayout->addLayout(buttonLayout);\r\n    topLayout->addStretch(1);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SystemDetailsEditor::setupConnections()\r\n//-----------------------------------------------------------------------------\r\nvoid SystemDetailsEditor::setupConnections()\r\n{\r\n    connect(hwRefEditor_, SIGNAL(vlnvEdited()), this, SLOT(onHWRefChanged()), Qt::UniqueConnection);\r\n    connect(applyButton_, SIGNAL(clicked()), this, SLOT(applyHW()), Qt::UniqueConnection);\r\n    connect(revertButton_, SIGNAL(clicked()), this, SLOT(revert()), Qt::UniqueConnection);\r\n    connect(removeMappingButton_, SIGNAL(clicked()), this, SLOT(removeMapping()), Qt::UniqueConnection);\r\n    connect(exportButton_, SIGNAL(clicked()), this, SLOT(exportSW()), Qt::UniqueConnection);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SystemDetailsEditor::onHWRefChanged()\r\n//-----------------------------------------------------------------------------\r\nvoid SystemDetailsEditor::onHWRefChanged()\r\n{\r\n    disconnect(viewSelector_, SIGNAL(currentTextChanged(const QString&)),\r\n               this, SLOT(onViewRefChanged(const QString&)));\r\n\r\n    viewSelector_->clear();\r\n\r\n    if (hwRefEditor_->isValid())\r\n    {\r\n        QSharedPointer<Document const> libComp = handler_->getModelReadOnly(hwRefEditor_->getVLNV());\r\n        QSharedPointer<Component const> component = libComp.dynamicCast<Component const>();\r\n\r\n        if (component != 0)\r\n        {\r\n            viewSelector_->addItems(component->getHierViews());\r\n        }\r\n    }\r\n\r\n    connect(viewSelector_, SIGNAL(currentTextChanged(const QString&)),\r\n            this, SLOT(onViewRefChanged(const QString&)), Qt::UniqueConnection);\r\n\r\n    bool modified = hwRefEditor_->getVLNV() != component_->getVlnv() ||\r\n                    viewSelector_->currentText() != systemView_->getHWViewRef();\r\n    applyButton_->setEnabled(modified && viewSelector_->count() > 0);\r\n    revertButton_->setEnabled(modified);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SystemDetailsEditor::onViewRefChanged()\r\n//-----------------------------------------------------------------------------\r\nvoid SystemDetailsEditor::onViewRefChanged(QString const& /*viewRef*/)\r\n{\r\n    bool modified = hwRefEditor_->getVLNV() != component_->getVlnv() ||\r\n                    viewSelector_->currentText() != systemView_->getHWViewRef();\r\n\r\n    applyButton_->setEnabled(modified && viewSelector_->count() > 0);\r\n    revertButton_->setEnabled(modified);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SystemDetailsEditor::applyHW()\r\n//-----------------------------------------------------------------------------\r\nvoid SystemDetailsEditor::applyHW()\r\n{\r\n    VLNV componentVLNV = hwRefEditor_->getVLNV();\r\n\r\n    // Check if the component is being switched.\r\n    if (componentVLNV != component_->getVlnv())\r\n    {\r\n        // Verify that the component is found.\r\n        QSharedPointer<Document> libComp = handler_->getModel(componentVLNV);\r\n        QSharedPointer<Component> newComponent = libComp.dynamicCast<Component>();\r\n\r\n        if (newComponent == 0)\r\n        {\r\n            QMessageBox msgBox(QMessageBox::Warning, QCoreApplication::applicationName(),\r\n                               tr(\"No HW component found with the given VLNV.\"),\r\n                               QMessageBox::Ok, (QWidget*)parent());\r\n            msgBox.exec();\r\n            return;\r\n        }\r\n\r\n        // Determine a default suggestion for the view name.\r\n        QSettings settings;\r\n        QStringList suggestions = settings.value(\"Policies/SysViewNames\").toStringList();\r\n\r\n        QString baseViewName = \"\";\r\n        QString viewName = \"\";\r\n\r\n        if (!suggestions.isEmpty())\r\n        {\r\n            baseViewName = suggestions.first();\r\n\r\n            viewName = baseViewName;\r\n            unsigned int runningNumber = 1;\r\n\r\n            while (newComponent->findSystemView(viewName) != 0)\r\n            {\r\n                ++runningNumber;\r\n                viewName = baseViewName + QString::number(runningNumber);\r\n            }\r\n        }\r\n\r\n        // Ask the user whether to move or copy the design under the given HW.\r\n        SwitchHWDialog dialog(newComponent, viewName, handler_, this);\r\n        dialog.setViewNameSuggestions(suggestions);\r\n\r\n        if (dialog.exec() == QDialog::Rejected)\r\n        {\r\n            return;\r\n        }\r\n\r\n        // Based on the action, either perform copy or move.\r\n        QSharedPointer<SystemView> newView( new SystemView(dialog.getSystemViewName() ) );\r\n        newView->setHWViewRef(viewSelector_->currentText());\r\n\r\n        if (dialog.isCopyActionSelected())\r\n        {\r\n            // Save copies of the design and design configuration.\r\n            VLNV vlnv = dialog.getVLNV();\r\n\r\n            VLNV designVLNV(VLNV::DESIGN, vlnv.getVendor(), vlnv.getLibrary(),\r\n                            vlnv.getName() + \".sysdesign\", vlnv.getVersion());\r\n            VLNV desConfVLNV(VLNV::DESIGNCONFIGURATION, vlnv.getVendor(), vlnv.getLibrary(),\r\n                             vlnv.getName() + \".sysdesigncfg\", vlnv.getVersion());\r\n\r\n            QSharedPointer<DesignConfiguration>\r\n                desConf(new DesignConfiguration(*designWidget_->getDiagram()->getDesignConfiguration()));\r\n            desConf->setVlnv(desConfVLNV);\r\n            desConf->setDesignRef(designVLNV);\r\n\r\n            QSharedPointer<Design> design = designWidget_->getDiagram()->getDesign();\r\n\r\n            handler_->writeModelToFile(dialog.getPath(), design);\r\n            handler_->writeModelToFile(dialog.getPath(), desConf);\r\n\r\n            // Set the new system view to point to the newly-saved design configuration.\r\n            newView->setHierarchyRef(desConfVLNV);\r\n        }\r\n        else\r\n        {\r\n            // Move is performed by removing the system view from the previous HW component and using\r\n            // the existing VLNV for the hierarchy reference.\r\n            newView->setHierarchyRef(systemView_->getHierarchyRef());\r\n            \r\n\t\t\tforeach ( QSharedPointer<VendorExtension> extension, *component_->getVendorExtensions() )\r\n\t\t\t{\r\n\t\t\t\tQSharedPointer<SystemView> currentView = extension.dynamicCast<SystemView>();\r\n\r\n\t\t\t\tif ( currentView && currentView->name() == designWidget_->getOpenViewName() )\r\n\t\t\t\t{\r\n\t\t\t\t\tcomponent_->getVendorExtensions()->removeOne( extension );\r\n\t\t\t\t\tbreak;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\r\n            handler_->writeModelToFile(component_);\r\n        }\r\n\r\n        // Add the system view to the new HW component and save.\r\n        newComponent->getVendorExtensions()->append(newView);\r\n        handler_->writeModelToFile(newComponent);\r\n\r\n        // Refresh the design widget.\r\n        designWidget_->setDesign(componentVLNV, dialog.getSystemViewName());\r\n        designWidget_->setProtection(false);\r\n        designWidget_->refresh();\r\n\r\n        component_ = designWidget_->getEditedComponent();\r\n        systemView_ = component_->findSystemView(dialog.getSystemViewName());\r\n    }\r\n    else\r\n    {\r\n        systemView_->setHWViewRef(viewSelector_->currentText());\r\n        designWidget_->refresh();\r\n    }\r\n\r\n    applyButton_->setDisabled(true);\r\n    revertButton_->setDisabled(true);\r\n\r\n    emit contentChanged();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SystemDetailsEditor::revert()\r\n//-----------------------------------------------------------------------------\r\nvoid SystemDetailsEditor::revert()\r\n{\r\n    if (component_->getImplementation() != KactusAttribute::SYSTEM)\r\n    {\r\n        hwRefEditor_->setVLNV(component_->getVlnv());\r\n        onHWRefChanged();\r\n\r\n        if (systemView_ != 0)\r\n        {\r\n            viewSelector_->setCurrentIndex(component_->getHierViews().indexOf(systemView_->getHWViewRef()));\r\n        }\r\n    }\r\n    else\r\n    {\r\n        hwRefEditor_->setVLNV(VLNV());\r\n        onHWRefChanged();\r\n    }\r\n\r\n    applyButton_->setDisabled(true);\r\n    revertButton_->setDisabled(true);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SystemDetailsEditor::removeMapping()\r\n//-----------------------------------------------------------------------------\r\nvoid SystemDetailsEditor::removeMapping()\r\n{\r\n    // Ask the user a VLNV for a system component.\r\n    NewObjectDialog dialog(handler_, VLNV::COMPONENT, false, this);\r\n    dialog.setWindowTitle(tr(\"Set System Component VLNV\"));\r\n\r\n    if (dialog.exec() == QDialog::Rejected)\r\n    {\r\n        return;\r\n    }\r\n\r\n    // Create a new system view for the system design.\r\n    SystemView* newView = new SystemView(designWidget_->getOpenViewName());\r\n    newView->setHierarchyRef(systemView_->getHierarchyRef());\r\n\r\n    // Remove the system view from the previous HW component.\r\n\tforeach( QSharedPointer<SystemView> currentView, component_->getSystemViews() )\r\n\t{\r\n\t\tif ( currentView->name() == designWidget_->getOpenViewName() )\r\n\t\t{\r\n\t\t\tcomponent_->getVendorExtensions()->removeOne( currentView );\r\n\t\t\tbreak;\r\n\t\t}\r\n\t}\r\n\r\n    handler_->writeModelToFile(component_);\r\n\r\n    // Create a new system component and add the system view to it.\r\n    QSharedPointer<Component> newComponent(new Component(dialog.getVLNV(), component_->getRevision()));\r\n    newComponent->setImplementation(KactusAttribute::SYSTEM);\r\n\r\n\tQList<QSharedPointer<SystemView> > newSystemViews = newComponent->getSystemViews();\r\n\tnewSystemViews.append(systemView_);\r\n\tnewComponent->setSystemViews(newSystemViews);\r\n    handler_->writeModelToFile(dialog.getPath(), newComponent);\r\n\r\n    // Refresh the design widget.\r\n    designWidget_->setDesign(dialog.getVLNV(), designWidget_->getOpenViewName());\r\n    designWidget_->setProtection(false);\r\n    designWidget_->refresh();\r\n\r\n    component_ = designWidget_->getEditedComponent();\r\n    systemView_ = component_->findSystemView(designWidget_->getOpenViewName());\r\n\r\n    emit contentChanged();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SystemDetailsEditor::exportSW()\r\n//-----------------------------------------------------------------------------\r\nvoid SystemDetailsEditor::exportSW()\r\n{\r\n    // Ask the user a VLNV for a system component.\r\n    ExportSWDialog dialog(handler_, this);\r\n\r\n    if (dialog.exec() == QDialog::Rejected)\r\n    {\r\n        return;\r\n    }\r\n\r\n    handler_->beginSave();\r\n\r\n    // Save copies of the design and design configuration.\r\n    VLNV vlnv = dialog.getVLNV();\r\n\r\n    VLNV designVLNV(VLNV::DESIGN, vlnv.getVendor(), vlnv.getLibrary(),\r\n                    vlnv.getName() + \".sysdesign\", vlnv.getVersion());\r\n    VLNV desConfVLNV(VLNV::DESIGNCONFIGURATION, vlnv.getVendor(), vlnv.getLibrary(),\r\n                     vlnv.getName() + \".sysdesigncfg\", vlnv.getVersion());\r\n\r\n    QSharedPointer<DesignConfiguration>\r\n        desConf(new DesignConfiguration(*designWidget_->getDiagram()->getDesignConfiguration()));\r\n    desConf->setVlnv(desConfVLNV);\r\n    desConf->setDesignRef(designVLNV);\r\n\r\n    QSharedPointer<Design> design = designWidget_->getDiagram()->getDesign();\r\n    design->setVlnv(designVLNV);\r\n\r\n    // Export only SW instances.\r\n    design->setComponentInstances(QSharedPointer<QList<QSharedPointer<ComponentInstance> > >());\r\n\r\n    foreach (QSharedPointer<ComponentInstance> instance, *design->getComponentInstances())\r\n    {\r\n        instance->setMapping(\"\");\r\n    }\r\n\r\n    handler_->writeModelToFile(dialog.getPath(), design);\r\n    handler_->writeModelToFile(dialog.getPath(), desConf);\r\n\r\n    // Create a new system view for the system design.\r\n    QSharedPointer<SystemView> newView = QSharedPointer<SystemView>( new SystemView(\"system\") );\r\n    newView->setHierarchyRef(desConfVLNV);\r\n\r\n    // Create a new system component and add the system view to it.\r\n    QSharedPointer<Component> newComponent(new Component(vlnv, component_->getRevision()));\r\n    newComponent->setImplementation(KactusAttribute::SYSTEM);\r\n\r\n\tQList<QSharedPointer<SystemView> > newSystemViews;\r\n\tnewSystemViews.append(newView);\r\n    newComponent->setSystemViews(newSystemViews);\r\n    handler_->writeModelToFile(dialog.getPath(), newComponent);\r\n\r\n    handler_->endSave();\r\n}\r\n"
  },
  {
    "path": "editors/SystemDesign/SystemDetailsEditor/SystemDetailsEditor.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: SystemDetailsEditor.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Joni-Matti Maatta\r\n// Date: 30.7.2012\r\n//\r\n// Description:\r\n// Docking editor for system details.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef SYSTEMDETAILSEDITOR_H\r\n#define SYSTEMDETAILSEDITOR_H\r\n\r\n#include <common/widgets/vlnvEditor/vlnveditor.h>\r\n\r\n#include <IPXACTmodels/Component/Component.h>\r\n\r\n#include <QWidget>\r\n#include <QPushButton>\r\n#include <QComboBox>\r\n#include <QSharedPointer>\r\n\r\nclass DesignWidget;\r\nclass SystemView;\r\nclass LibraryInterface;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Docking editor to edit system details.\r\n//-----------------------------------------------------------------------------\r\nclass SystemDetailsEditor : public QWidget\r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\t/*!\r\n     *  Constructor.\r\n\t *\r\n\t *    @param [in] handler The library interface.\r\n\t *    @param [in] parent  The parent widget.\r\n\t */\r\n\tSystemDetailsEditor(LibraryInterface* handler, QWidget *parent);\r\n\t\r\n\t/*!\r\n     *  Destructor.\r\n     */\r\n\tvirtual ~SystemDetailsEditor();\r\n\r\n\t/*!\r\n     *  Set the system to be displayed.\r\n\t *\r\n\t *    @param [in] designWidget The system design widget containing the opened system.\r\n\t */\r\n    void setSystem(DesignWidget* designWidget);\r\n\r\n\t/*!\r\n     *  Clear the contents of this editor.\r\n\t */\r\n\tvoid clear();\r\n\r\npublic slots:\r\n\t//! Handler for design widget's refreshed signal.\r\n\tvoid onRefresh();\r\n\r\n\t//! Set the editor to locked/unlocked mode.\r\n\tvoid setLocked(bool locked);\r\n\r\nsignals:\r\n\t//! Emitted when the editor changes some value.\r\n\tvoid contentChanged();\r\n\r\nprivate slots:\r\n    //! Called when the HW component reference has been changed.\r\n    void onHWRefChanged();\r\n\r\n    //! Called when the view reference has been changed from the combo box.\r\n    void onViewRefChanged(QString const& viewRef);\r\n\r\n    //! Applies the selected HW to the system.\r\n    void applyHW();\r\n\r\n    //! Reverts the changes.\r\n    void revert();\r\n\r\n    //! Removes the HW mapping altogether.\r\n    void removeMapping();\r\n\r\n    //! Exports SW to a new system component.\r\n    void exportSW();\r\n\r\nprivate:\r\n    // Disable copying.\r\n    SystemDetailsEditor(SystemDetailsEditor const& rhs);\r\n    SystemDetailsEditor& operator=(SystemDetailsEditor const& rhs);\r\n\r\n\t/*! \r\n     *  Sets up the layout of this widget.\r\n     */\r\n\tvoid setupLayout();\r\n\r\n\t/*!\r\n     *  Set up the signals between widgets.\r\n     */\r\n\tvoid setupConnections();\r\n    \r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n\t//! Pointer to the instance that manages the library.\r\n\tLibraryInterface* handler_;\r\n\r\n    //! HW reference editor.\r\n    VLNVEditor* hwRefEditor_;\r\n\r\n\t//! Combo box to select the used configuration.\r\n\tQComboBox* viewSelector_;\r\n\r\n    //! Button to apply new HW mapping.\r\n    QPushButton* applyButton_;\r\n\r\n    //! Button to revert to the previously applied HW mapping.\r\n    QPushButton* revertButton_;\r\n\r\n    //! Button to remove mappings.\r\n    QPushButton* removeMappingButton_;\r\n\r\n    //! Button to export SW.\r\n    QPushButton* exportButton_;\r\n\r\n\t//! Pointer to the top component being edited.\r\n\tQSharedPointer<Component> component_;\r\n\r\n\t//! Pointer to the design widget that contains the design.\r\n\tDesignWidget* designWidget_;\r\n\r\n    //! The system view containing the edited system.\r\n    QSharedPointer<SystemView> systemView_;\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n\r\n#endif // SYSTEMDETAILSEDITOR_H\r\n"
  },
  {
    "path": "editors/SystemDesign/UndoCommands/ApiConnectionAddCommand.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ApiConnectionAddCommand.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Mikko Teuho\r\n// Date: 16.02.2016\r\n//\r\n// Description:\r\n// Undo add commands for API connections.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"ApiConnectionAddCommand.h\"\r\n\r\n#include <editors/SystemDesign/ApiGraphicsConnection.h>\r\n#include <editors/SystemDesign/SystemDesignDiagram.h>\r\n#include <editors/SystemDesign/SWPortItem.h>\r\n\r\n#include <common/graphicsItems/ConnectionEndpoint.h>\r\n#include <common/graphicsItems/ComponentItem.h>\r\n\r\n#include <IPXACTmodels/Design/Design.h>\r\n#include <IPXACTmodels/Design/ComponentInstance.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ApiConnectionAddCommand::ApiConnectionAddCommand()\r\n//-----------------------------------------------------------------------------\r\nApiConnectionAddCommand::ApiConnectionAddCommand(QGraphicsScene* scene, ApiGraphicsConnection* connection,\r\n                                                 QSharedPointer<Design> containingDesign, QUndoCommand* parent):\r\nQUndoCommand(parent),\r\nconnection_(connection),\r\nscene_(scene),\r\ndel_(false),\r\ncontainingDesign_(containingDesign)\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ApiConnectionAddCommand::~ApiConnectionAddCommand()\r\n//-----------------------------------------------------------------------------\r\nApiConnectionAddCommand::~ApiConnectionAddCommand()\r\n{\r\n    if (del_)\r\n    {\r\n        delete connection_;\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ApiConnectionAddCommand::undo()\r\n//-----------------------------------------------------------------------------\r\nvoid ApiConnectionAddCommand::undo()\r\n{\r\n    scene_->removeItem(connection_);\r\n    connection_->setSelected(false);\r\n\r\n    connection_->disconnectEnds();\r\n\r\n    QList<QSharedPointer<ApiInterconnection> > apiInterconnections = containingDesign_->getApiConnections();\r\n    apiInterconnections.removeAll(connection_->getInterconnection());\r\n    containingDesign_->setApiConnections(apiInterconnections);\r\n\r\n    containingDesign_->removeRoute(connection_->getRouteExtension());\r\n\r\n    del_ = true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ApiConnectionAddCommand::redo()\r\n//-----------------------------------------------------------------------------\r\nvoid ApiConnectionAddCommand::redo()\r\n{\r\n    if (!scene_->items().contains(connection_))\r\n    {\r\n        scene_->addItem(connection_);\r\n    }\r\n\r\n    if (connection_->connectEnds())\r\n    {\r\n        ConnectionEndpoint* startPoint = connection_->endpoint1();\r\n        ConnectionEndpoint* endPoint = connection_->endpoint2();\r\n\r\n        if (startPoint->getType() == ConnectionEndpoint::ENDPOINT_TYPE_UNDEFINED)\r\n        {\r\n            changePortItemFromComToApi(startPoint);\r\n        }\r\n        else if (endPoint->getType() == ConnectionEndpoint::ENDPOINT_TYPE_UNDEFINED)\r\n        {\r\n            changePortItemFromComToApi(endPoint);\r\n        }\r\n\r\n        QList<QSharedPointer<ApiInterconnection> > apiInterconnections = containingDesign_->getApiConnections();\r\n        apiInterconnections.append(connection_->getInterconnection());\r\n        containingDesign_->setApiConnections(apiInterconnections);\r\n\r\n        containingDesign_->addRoute(connection_->getRouteExtension());\r\n    }\r\n\r\n    del_ = false;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ApiConnectionAddCommand::changePortItemFromApiToCom()\r\n//-----------------------------------------------------------------------------\r\nvoid ApiConnectionAddCommand::changePortItemFromComToApi(ConnectionEndpoint* endPoint)\r\n{\r\n    SWPortItem* endPointPort = dynamic_cast<SWPortItem*>(endPoint);\r\n    if (endPointPort)\r\n    {\r\n        QSharedPointer<ComponentInstance> containingInstance = endPoint->encompassingComp()->getComponentInstance();\r\n\r\n        QMap<QString, QPointF> comPositions = containingInstance->getComInterfacePositions();\r\n\r\n        if (comPositions.contains(endPoint->name()) && comPositions.value(endPoint->name()) == endPoint->pos())\r\n        {\r\n            containingInstance->removeComInterfacePosition(endPoint->name());\r\n        }\r\n\r\n        containingInstance->updateApiInterfacePosition(endPoint->name(), endPoint->pos());\r\n    }\r\n}\r\n"
  },
  {
    "path": "editors/SystemDesign/UndoCommands/ApiConnectionAddCommand.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ApiConnectionAddCommand.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Mikko Teuho\r\n// Date: 16.02.2016\r\n//\r\n// Description:\r\n// Undo add commands for API connections.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef APICONNECTIONADDCOMMAND_H\r\n#define APICONNECTIONADDCOMMAND_H\r\n\r\n#include <QUndoCommand>\r\n#include <QGraphicsItem>\r\n#include <QGraphicsScene>\r\n#include <QObject>\r\n\r\nclass ApiGraphicsConnection;\r\nclass ConnectionEndpoint;\r\n\r\nclass Design;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Undo add commands for API connections.\r\n//-----------------------------------------------------------------------------\r\nclass ApiConnectionAddCommand : public QUndoCommand\r\n{\r\npublic:\r\n\r\n    /*!\r\n     *  Constructor.\r\n     *\r\n     *    @param [in] scene               The scene.\r\n     *    @param [in] conn                The connection to add.\r\n     *    @param [in] containingDesign    The design containing the API interconnection.\r\n     *    @param [in] parent              The parent command.\r\n     */\r\n    ApiConnectionAddCommand(QGraphicsScene* scene, ApiGraphicsConnection* connection,\r\n        QSharedPointer<Design> containingDesign, QUndoCommand* parent = 0);\r\n\r\n    /*!\r\n     *  Destructor.\r\n     */\r\n    ~ApiConnectionAddCommand();\r\n\r\n    /*!\r\n     *  Undoes the command.\r\n     */\r\n    virtual void undo();\r\n\r\n    /*!\r\n     *  Redoes the command.\r\n     */\r\n    virtual void redo();\r\n\r\nprivate:\r\n    // Disable copying.\r\n    ApiConnectionAddCommand(ApiConnectionAddCommand const& rhs);\r\n    ApiConnectionAddCommand& operator=(ApiConnectionAddCommand const& rhs);\r\n\r\n    /*!\r\n     *  Change the port item status from COM interface to API interface.\r\n     *\r\n     *    @param [in] endPoint    The selected port item.\r\n     */\r\n    void changePortItemFromComToApi(ConnectionEndpoint* endPoint);\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! The API interconnection.\r\n    ApiGraphicsConnection* connection_;\r\n\r\n    //! The graphics scene.\r\n    QGraphicsScene* scene_;\r\n\r\n    //! Boolean flag for indicating if the connection should be deleted in the destructor.\r\n    bool del_;\r\n\r\n    //! The design containing the interconnection.\r\n    QSharedPointer<Design> containingDesign_;\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n\r\n#endif // APICONNECTIONADDCOMMAND_H\r\n"
  },
  {
    "path": "editors/SystemDesign/UndoCommands/ApiConnectionDeleteCommand.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ApiConnectionDeleteCommand.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Mikko Teuho\r\n// Date: 16.02.2016\r\n//\r\n// Description:\r\n// Undo delete commands for API connections in system design.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"ApiConnectionDeleteCommand.h\"\r\n\r\n#include <editors/common/Association/Association.h>\r\n#include <editors/common/Association/AssociationRemoveCommand.h>\r\n#include <editors/SystemDesign/ApiGraphicsConnection.h>\r\n\r\n#include <IPXACTmodels/Design/Design.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ApiConnectionDeleteCommand::ApiConnectionDeleteCommand()\r\n//-----------------------------------------------------------------------------\r\nApiConnectionDeleteCommand::ApiConnectionDeleteCommand(ApiGraphicsConnection* connection,\r\n                                                       QSharedPointer<Design> containingDesign,\r\n                                                       QUndoCommand* parent /* = 0 */):\r\nQUndoCommand(parent),\r\nconnection_(connection),\r\nscene_(connection_->scene()),\r\ncontainingDesign_(containingDesign),\r\ndeleteConnection_(true)\r\n{\r\n    foreach (Association* association, connection_->getAssociations())\r\n    {\r\n        new AssociationRemoveCommand(association, scene_, this);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ApiConnectionDeleteCommand::~ApiConnectionDeleteCommand()\r\n//-----------------------------------------------------------------------------\r\nApiConnectionDeleteCommand::~ApiConnectionDeleteCommand()\r\n{\r\n    if (deleteConnection_)\r\n    {\r\n        delete connection_;\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ApiConnectionDeleteCommand::undo()\r\n//-----------------------------------------------------------------------------\r\nvoid ApiConnectionDeleteCommand::undo()\r\n{\r\n    QUndoCommand::undo();\r\n\r\n    scene_->addItem(connection_);\r\n\r\n    if (connection_->connectEnds())\r\n    {\r\n        QSharedPointer<ApiInterconnection> apiConnection = connection_->getInterconnection();\r\n        QList<QSharedPointer<ApiInterconnection> > containedApis = containingDesign_->getApiConnections();\r\n        containedApis.append(apiConnection);\r\n\r\n        containingDesign_->setApiConnections(containedApis);\r\n        containingDesign_->addRoute(connection_->getRouteExtension());\r\n    }\r\n\r\n    scene_->clearSelection();\r\n    deleteConnection_ = false;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ApiConnectionDeleteCommand::redo()\r\n//-----------------------------------------------------------------------------\r\nvoid ApiConnectionDeleteCommand::redo()\r\n{\r\n    connection_->setSelected(false);\r\n    scene_->removeItem(connection_);\r\n\r\n    connection_->disconnectEnds();\r\n\r\n    QSharedPointer<ApiInterconnection> removedConnection = connection_->getInterconnection();\r\n    QList<QSharedPointer<ApiInterconnection> > containedApis = containingDesign_->getApiConnections();\r\n    containedApis.removeAll(removedConnection);\r\n    containingDesign_->setApiConnections(containedApis);\r\n\r\n    containingDesign_->removeRoute(connection_->getRouteExtension());\r\n\r\n    deleteConnection_ = true;\r\n\r\n    QUndoCommand::redo();\r\n}\r\n"
  },
  {
    "path": "editors/SystemDesign/UndoCommands/ApiConnectionDeleteCommand.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ApiConnectionDeleteCommand.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Mikko Teuho\r\n// Date: 16.02.2016\r\n//\r\n// Description:\r\n// Undo delete commands for API connections in system design.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef APICONNECTIONDELETECOMMAND_H\r\n#define APICONNECTIONDELETECOMMAND_H\r\n\r\n#include <QGraphicsScene>\r\n#include <QObject>\r\n#include <QSharedPointer>\r\n#include <QUndoCommand>\r\n\r\nclass ApiGraphicsConnection;\r\n\r\nclass Design;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Undo delete commands for API connections in system design.\r\n//-----------------------------------------------------------------------------\r\nclass ApiConnectionDeleteCommand : public QUndoCommand\r\n{\r\npublic:\r\n    /*!\r\n     *  Constructor.\r\n     *\r\n     *    @param [in] connection          The connection to delete.\r\n     *    @param [in] containingDesign    The design containing the connection.\r\n     *    @param [in] parent              The parent undo command.\r\n     */\r\n    ApiConnectionDeleteCommand(ApiGraphicsConnection* connection, QSharedPointer<Design> containingDesign,\r\n        QUndoCommand* parent = 0);\r\n\r\n    /*!\r\n     *  Destructor.\r\n     */\r\n    ~ApiConnectionDeleteCommand();\r\n\r\n    /*!\r\n     *  Undoes the command.\r\n     */\r\n    virtual void undo();\r\n\r\n    /*!\r\n     *  Redoes the command.\r\n     */\r\n    virtual void redo();\r\n\r\nprivate:\r\n    // Disable copying.\r\n    ApiConnectionDeleteCommand(ApiConnectionDeleteCommand const& rhs);\r\n    ApiConnectionDeleteCommand& operator=(ApiConnectionDeleteCommand const& rhs);\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! The API interconnection.\r\n    ApiGraphicsConnection* connection_;\r\n\r\n    //! The graphics scene.\r\n    QGraphicsScene* scene_;\r\n\r\n    //! The design containing the connection.\r\n    QSharedPointer<Design> containingDesign_;\r\n\r\n    //! Boolean flag for indicating if the connection should be deleted in the destructor.\r\n    bool deleteConnection_;\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n\r\n#endif // APICONNECTIONDELETECOMMAND_H\r\n"
  },
  {
    "path": "editors/SystemDesign/UndoCommands/ApiConnectionExchangeCommand.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ApiConnectionExchangeCommand.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Mikko Teuho\r\n// Date: 03.03.2016\r\n//\r\n// Description:\r\n// Undo command for exchanging API connections.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"ApiConnectionExchangeCommand.h\"\r\n\r\n#include <common/graphicsItems/ConnectionEndpoint.h>\r\n#include <common/graphicsItems/ComponentItem.h>\r\n\r\n#include <editors/SystemDesign/ApiGraphicsConnection.h>\r\n#include <editors/SystemDesign/SWPortItem.h>\r\n#include <editors/SystemDesign/SWInterfaceItem.h>\r\n\r\n#include <IPXACTmodels/Design/HierInterface.h>\r\n#include <IPXACTmodels/Design/ActiveInterface.h>\r\n#include <IPXACTmodels/Design/ComponentInstance.h>\r\n#include <IPXACTmodels/kactusExtensions/ApiInterconnection.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ApiConnectionExchangeCommand::ApiConnectionExchangeCommand()\r\n//-----------------------------------------------------------------------------\r\nApiConnectionExchangeCommand::ApiConnectionExchangeCommand(ApiGraphicsConnection* connection,\r\n                                                           ConnectionEndpoint* oldEndpoint,\r\n                                                           ConnectionEndpoint* newEndpoint, QUndoCommand* parent):\r\nQUndoCommand(parent),\r\nconnection_(connection),\r\noldEndpoint_(oldEndpoint),\r\nnewEndpoint_(newEndpoint),\r\noldInterface_(),\r\nnewInterface_()\r\n{\r\n    createExchangedInterfaces();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ApiConnectionExchangeCommand::createExchangedInterfaces()\r\n//-----------------------------------------------------------------------------\r\nvoid ApiConnectionExchangeCommand::createExchangedInterfaces()\r\n{\r\n    if (connection_->isOffPage())\r\n    {\r\n        ConnectionEndpoint* oldParentPoint = dynamic_cast<ConnectionEndpoint*>(oldEndpoint_->parentItem());\r\n        if (oldParentPoint)\r\n        {\r\n            oldInterface_ = createConnectionInterface(oldParentPoint);\r\n        }\r\n\r\n        ConnectionEndpoint* newParentPoint = dynamic_cast<ConnectionEndpoint*>(newEndpoint_->parentItem());\r\n        if (newParentPoint)\r\n        {\r\n            newInterface_ = createConnectionInterface(newParentPoint);\r\n        }\r\n    }\r\n    else\r\n    {\r\n        oldInterface_ = createConnectionInterface(oldEndpoint_);\r\n        newInterface_ = createConnectionInterface(newEndpoint_);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ApiConnectionExchangeCommand::~ApiConnectionExchangeCommand()\r\n//-----------------------------------------------------------------------------\r\nApiConnectionExchangeCommand::~ApiConnectionExchangeCommand()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ApiConnectionExchangeCommand::undo()\r\n//-----------------------------------------------------------------------------\r\nvoid ApiConnectionExchangeCommand::undo()\r\n{\r\n    QUndoCommand::undo();\r\n\r\n    QSharedPointer<ApiInterconnection> interconnection = connection_->getInterconnection();\r\n\r\n    if (interconnection && oldInterface_)\r\n    {\r\n        if (connection_->endpoint1() == newEndpoint_)\r\n        {\r\n            connection_->setEndpoint1(oldEndpoint_);\r\n\r\n            QSharedPointer<ActiveInterface> oldActiveInterface = oldInterface_.dynamicCast<ActiveInterface>();\r\n            if (oldActiveInterface)\r\n            {\r\n                interconnection->setStartInterface(oldActiveInterface);\r\n            }\r\n        }\r\n        else\r\n        {\r\n            connection_->setEndpoint2(oldEndpoint_);\r\n\r\n            interconnection->setInterface(oldInterface_);\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ApiConnectionExchangeCommand::redo()\r\n//-----------------------------------------------------------------------------\r\nvoid ApiConnectionExchangeCommand::redo()\r\n{\r\n    QSharedPointer<ApiInterconnection> interconnection = connection_->getInterconnection();\r\n\r\n    if (interconnection && newInterface_)\r\n    {\r\n        if (connection_->endpoint1() == oldEndpoint_)\r\n        {\r\n            connection_->setEndpoint1(newEndpoint_);\r\n\r\n            QSharedPointer<ActiveInterface> newActiveInterface = newInterface_.dynamicCast<ActiveInterface>();\r\n            if (newActiveInterface)\r\n            {\r\n                interconnection->setStartInterface(newActiveInterface);\r\n            }\r\n        }\r\n        else\r\n        {\r\n            connection_->setEndpoint2(newEndpoint_);\r\n\r\n            interconnection->setInterface(newInterface_);\r\n        }\r\n    }\r\n\r\n    QUndoCommand::redo();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ApiConnectionExchangeCommand::createConnectionInterface()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<HierInterface> ApiConnectionExchangeCommand::createConnectionInterface(ConnectionEndpoint* endPoint)\r\n{\r\n    SWPortItem* portEndPoint = dynamic_cast<SWPortItem*>(endPoint);\r\n    SWInterfaceItem* interfaceEndPoint = dynamic_cast<SWInterfaceItem*>(endPoint);\r\n    if (portEndPoint)\r\n    {\r\n        QString instanceName = portEndPoint->encompassingComp()->getComponentInstance()->getInstanceName();\r\n        return QSharedPointer<ActiveInterface> (new ActiveInterface(instanceName, endPoint->name()));\r\n    }\r\n    else if (interfaceEndPoint)\r\n    {\r\n        return QSharedPointer<HierInterface> (new HierInterface(endPoint->name()));\r\n    }\r\n\r\n    return QSharedPointer<HierInterface> ();\r\n}\r\n"
  },
  {
    "path": "editors/SystemDesign/UndoCommands/ApiConnectionExchangeCommand.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ApiConnectionExchangeCommand.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Mikko Teuho\r\n// Date: 03.03.2016\r\n//\r\n// Description:\r\n// Undo command for exchanging API connections.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef APICONNECTIONEXCHANGECOMMAND_H\r\n#define APICONNECTIONEXCHANGECOMMAND_H\r\n\r\n#include <QUndoCommand>\r\n#include <QPointF>\r\n#include <QSharedPointer>\r\n\r\nclass ApiGraphicsConnection;\r\nclass ConnectionEndpoint;\r\nclass HierInterface;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Undo command for exchanging API connections.\r\n//-----------------------------------------------------------------------------\r\nclass ApiConnectionExchangeCommand : public QUndoCommand\r\n{\r\npublic:\r\n\r\n    /*!\r\n     *  Constructor.\r\n     *\r\n     *    @param [in] connection      The selected API graphics connection.\r\n     *    @param [in] oldEndpoint     The old endpoint from which to disconnect the connection.\r\n     *    @param [in] newEndpoint     The new endpoint to which to connect the connection.\r\n     *    @param [in] parent          The parent command.\r\n     */\r\n    ApiConnectionExchangeCommand(ApiGraphicsConnection* connection, ConnectionEndpoint* oldEndpoint,\r\n        ConnectionEndpoint* newEndpoint, QUndoCommand* parent = 0);\r\n\r\n    /*!\r\n     *  Destructor.\r\n     */\r\n    ~ApiConnectionExchangeCommand();\r\n\r\n    /*!\r\n     *  Undoes the command.\r\n     */\r\n    virtual void undo();\r\n\r\n    /*!\r\n     *  Redoes the command.\r\n     */\r\n    virtual void redo();\r\n\r\nprivate:\r\n\r\n    // Disable copying.\r\n    ApiConnectionExchangeCommand(ApiConnectionExchangeCommand const& rhs);\r\n    ApiConnectionExchangeCommand& operator=(ApiConnectionExchangeCommand const& rhs);\r\n\r\n    /*!\r\n     *  Create interfaces for the exchanged connection..\r\n     */\r\n    void createExchangedInterfaces();\r\n\r\n    /*!\r\n     *  Create an interface from the selected connection end point.\r\n     *\r\n     *    @param [in] endPoint    The selected connection end point.\r\n     *\r\n     *    @return The created interface.\r\n     */\r\n    QSharedPointer<HierInterface> createConnectionInterface(ConnectionEndpoint* endPoint);\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! The API graphics connection.\r\n    ApiGraphicsConnection* connection_;\r\n\r\n    //! The old endpoint.\r\n    ConnectionEndpoint* oldEndpoint_;\r\n\r\n    //! The new endpoint.\r\n    ConnectionEndpoint* newEndpoint_;\r\n\r\n    //! The old interface.\r\n    QSharedPointer<HierInterface> oldInterface_;\r\n\r\n    //! The new interface.\r\n    QSharedPointer<HierInterface> newInterface_;\r\n};\r\n//-----------------------------------------------------------------------------\r\n\r\n#endif // APICONNECTIONEXCHANGECOMMAND_H\r\n"
  },
  {
    "path": "editors/SystemDesign/UndoCommands/ComConnectionAddCommand.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ComConnectionAddCommand.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Mikko Teuho\r\n// Date: 15.02.2016\r\n//\r\n// Description:\r\n// Undo add commands for COM connections.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"ComConnectionAddCommand.h\"\r\n\r\n#include <editors/SystemDesign/ComGraphicsConnection.h>\r\n#include <editors/SystemDesign/SystemDesignDiagram.h>\r\n#include <editors/SystemDesign/SWPortItem.h>\r\n\r\n#include <common/graphicsItems/ConnectionEndpoint.h>\r\n#include <common/graphicsItems/ComponentItem.h>\r\n\r\n#include <IPXACTmodels/Design/Design.h>\r\n#include <IPXACTmodels/Design/ComponentInstance.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComConnectionAddCommand::ComConnectionAddCommand()\r\n//-----------------------------------------------------------------------------\r\nComConnectionAddCommand::ComConnectionAddCommand(QGraphicsScene* scene, ComGraphicsConnection* connection,\r\n                                                 QSharedPointer<Design> containingDesign, QUndoCommand* parent):\r\nQUndoCommand(parent),\r\nconnection_(connection),\r\nscene_(scene),\r\ndel_(false),\r\ncontainingDesign_(containingDesign)\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComConnectionAddCommand::~ComConnectionAddCommand()\r\n//-----------------------------------------------------------------------------\r\nComConnectionAddCommand::~ComConnectionAddCommand()\r\n{\r\n    if (del_)\r\n    {\r\n        delete connection_;\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComConnectionAddCommand::undo()\r\n//-----------------------------------------------------------------------------\r\nvoid ComConnectionAddCommand::undo()\r\n{\r\n    scene_->removeItem(connection_);\r\n    connection_->setSelected(false);\r\n\r\n    connection_->disconnectEnds();\r\n\r\n    QList<QSharedPointer<ComInterconnection> > comInterconnections = containingDesign_->getComConnections();\r\n    comInterconnections.removeAll(connection_->getInterconnection());\r\n    containingDesign_->setComConnections(comInterconnections);\r\n\r\n    containingDesign_->removeRoute(connection_->getRouteExtension());\r\n\r\n    del_ = true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComConnectionAddCommand::redo()\r\n//-----------------------------------------------------------------------------\r\nvoid ComConnectionAddCommand::redo()\r\n{\r\n    if (!scene_->items().contains(connection_))\r\n    {\r\n        scene_->addItem(connection_);\r\n    }\r\n\r\n    if (connection_->connectEnds())\r\n    {\r\n        ConnectionEndpoint* startPoint = connection_->endpoint1();\r\n        ConnectionEndpoint* endPoint = connection_->endpoint2();\r\n\r\n        if (startPoint->getType() == ConnectionEndpoint::ENDPOINT_TYPE_UNDEFINED)\r\n        {\r\n            changePortItemFromApiToCom(startPoint);\r\n        }\r\n        else if (endPoint->getType() == ConnectionEndpoint::ENDPOINT_TYPE_UNDEFINED)\r\n        {\r\n            changePortItemFromApiToCom(endPoint);\r\n        }\r\n\r\n        QList<QSharedPointer<ComInterconnection> > comInterconnections = containingDesign_->getComConnections();\r\n        comInterconnections.append(connection_->getInterconnection());\r\n        containingDesign_->setComConnections(comInterconnections);\r\n\r\n        containingDesign_->addRoute(connection_->getRouteExtension());\r\n    }\r\n\r\n    del_ = false;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComConnectionAddCommand::changePortItemFromApiToCom()\r\n//-----------------------------------------------------------------------------\r\nvoid ComConnectionAddCommand::changePortItemFromApiToCom(ConnectionEndpoint* endPoint)\r\n{\r\n    SWPortItem* portEndpoint = dynamic_cast<SWPortItem*>(endPoint);\r\n    if (portEndpoint)\r\n    {\r\n        QSharedPointer<ComponentInstance> containingInstance = endPoint->encompassingComp()->getComponentInstance();\r\n\r\n        QMap<QString, QPointF> apiPositions = containingInstance->getApiInterfacePositions();\r\n\r\n        if (apiPositions.contains(endPoint->name()) && apiPositions.value(endPoint->name()) == endPoint->pos())\r\n        {\r\n            containingInstance->removeApiInterfacePosition(endPoint->name());\r\n        }\r\n\r\n        containingInstance->updateComInterfacePosition(endPoint->name(), endPoint->pos());\r\n    }\r\n}\r\n"
  },
  {
    "path": "editors/SystemDesign/UndoCommands/ComConnectionAddCommand.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ComConnectionAddCommand.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Mikko Teuho\r\n// Date: 15.02.2016\r\n//\r\n// Description:\r\n// Undo add commands for COM connections.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef COMCONNECTIONADDCOMMAND_H\r\n#define COMCONNECTIONADDCOMMAND_H\r\n\r\n#include <QUndoCommand>\r\n#include <QGraphicsItem>\r\n#include <QGraphicsScene>\r\n#include <QObject>\r\n\r\nclass ComGraphicsConnection;\r\nclass ConnectionEndpoint;\r\n\r\nclass Design;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Undo add commands for COM connections.\r\n//-----------------------------------------------------------------------------\r\nclass ComConnectionAddCommand : public QUndoCommand\r\n{\r\npublic:\r\n\r\n    /*!\r\n     *  Constructor.\r\n     *\r\n     *    @param [in] scene               The scene.\r\n     *    @param [in] connection          The connection to add.\r\n     *    @param [in] containingDesign    The design containing the connection.\r\n     *    @param [in] parent              The parent command.\r\n     */\r\n    ComConnectionAddCommand(QGraphicsScene* scene, ComGraphicsConnection* connection,\r\n        QSharedPointer<Design> containingDesign, QUndoCommand* parent = 0);\r\n\r\n    /*!\r\n     *  Destructor.\r\n     */\r\n    ~ComConnectionAddCommand();\r\n\r\n    /*!\r\n     *  Undoes the command.\r\n     */\r\n    virtual void undo();\r\n\r\n    /*!\r\n     *  Redoes the command.\r\n     */\r\n    virtual void redo();\r\n\r\nprivate:\r\n    // Disable copying.\r\n    ComConnectionAddCommand(ComConnectionAddCommand const& rhs);\r\n    ComConnectionAddCommand& operator=(ComConnectionAddCommand const& rhs);\r\n\r\n    /*!\r\n     *  Change the port item status from API interface to COM interface.\r\n     *\r\n     *    @param [in] endPoint    The selected port item.\r\n     */\r\n    void changePortItemFromApiToCom(ConnectionEndpoint* endPoint);\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! The COM connection.\r\n    ComGraphicsConnection* connection_;\r\n\r\n    //! The graphics scene.\r\n    QGraphicsScene* scene_;\r\n\r\n    //! Boolean flag for indicating if the connection should be deleted in the destructor.\r\n    bool del_;\r\n\r\n    //! The design containing the interconnection.\r\n    QSharedPointer<Design> containingDesign_;\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n\r\n#endif // COMCONNECTIONADDCOMMAND_H\r\n"
  },
  {
    "path": "editors/SystemDesign/UndoCommands/ComConnectionDeleteCommand.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ComConnectionDeleteCommand.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Mikko Teuho\r\n// Date: 16.02.2016\r\n//\r\n// Description:\r\n// Undo delete commands for COM connections in system design.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"ComConnectionDeleteCommand.h\"\r\n\r\n#include <editors/SystemDesign/ComGraphicsConnection.h>\r\n#include <editors/common/Association/Association.h>\r\n#include <editors/common/Association/AssociationRemoveCommand.h>\r\n\r\n#include <IPXACTmodels/Design/Design.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComConnectionDeleteCommand::ComConnectionDeleteCommand()\r\n//-----------------------------------------------------------------------------\r\nComConnectionDeleteCommand::ComConnectionDeleteCommand(ComGraphicsConnection* connection,\r\n                                                       QSharedPointer<Design> containingDesign,\r\n                                                       QUndoCommand* parent /* = 0 */):\r\nQUndoCommand(parent),\r\nconnection_(connection),\r\nscene_(connection_->scene()),\r\ncontainingDesign_(containingDesign),\r\ndeleteConnection_(true)\r\n{\r\n    foreach(Association* association, connection_->getAssociations())\r\n    {\r\n        new AssociationRemoveCommand(association, scene_, this);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComConnectionDeleteCommand::~ComConnectionDeleteCommand()\r\n//-----------------------------------------------------------------------------\r\nComConnectionDeleteCommand::~ComConnectionDeleteCommand()\r\n{\r\n    if (deleteConnection_)\r\n    {\r\n        delete connection_;\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComConnectionDeleteCommand::undo()\r\n//-----------------------------------------------------------------------------\r\nvoid ComConnectionDeleteCommand::undo()\r\n{\r\n    QUndoCommand::undo();\r\n\r\n    scene_->addItem(connection_);\r\n\r\n    if (connection_->connectEnds())\r\n    {\r\n        QSharedPointer<ComInterconnection> comInterconnection = connection_->getInterconnection();\r\n        QList<QSharedPointer<ComInterconnection> > containedComs = containingDesign_->getComConnections();\r\n        containedComs.append(comInterconnection);\r\n        \r\n        containingDesign_->setComConnections(containedComs);\r\n        containingDesign_->addRoute(connection_->getRouteExtension());\r\n    }\r\n\r\n    scene_->clearSelection();\r\n    deleteConnection_ = false;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComConnectionDeleteCommand::redo()\r\n//-----------------------------------------------------------------------------\r\nvoid ComConnectionDeleteCommand::redo()\r\n{\r\n    connection_->setSelected(false);\r\n    scene_->removeItem(connection_);\r\n\r\n    connection_->disconnectEnds();\r\n\r\n    QSharedPointer<ComInterconnection> comInterconnection = connection_->getInterconnection();\r\n    QList<QSharedPointer<ComInterconnection> > containedComs = containingDesign_->getComConnections();\r\n    containedComs.removeAll(comInterconnection);\r\n    containingDesign_->setComConnections(containedComs);\r\n\r\n    containingDesign_->removeRoute(connection_->getRouteExtension());\r\n\r\n    deleteConnection_ = true;\r\n\r\n    QUndoCommand::redo();\r\n}\r\n"
  },
  {
    "path": "editors/SystemDesign/UndoCommands/ComConnectionDeleteCommand.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ComConnectionDeleteCommand.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Mikko Teuho\r\n// Date: 16.02.2016\r\n//\r\n// Description:\r\n// Undo delete commands for COM connections in system design.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef COMCONNECTIONDELETECOMMAND_H\r\n#define COMCONNECTIONDELETECOMMAND_H\r\n\r\n#include <QGraphicsScene>\r\n#include <QObject>\r\n#include <QSharedPointer>\r\n#include <QUndoCommand>\r\n\r\nclass ComGraphicsConnection;\r\n\r\nclass Design;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Undo delete commands for COM connections in system design.\r\n//-----------------------------------------------------------------------------\r\nclass ComConnectionDeleteCommand : public QUndoCommand\r\n{\r\npublic:\r\n    /*!\r\n     *  Constructor.\r\n     *\r\n     *    @param [in] connection          The connection to delete.\r\n     *    @param [in] containingDesign    The design containing the connection.\r\n     *    @param [in] parent              The parent undo command.\r\n     */\r\n    ComConnectionDeleteCommand(ComGraphicsConnection* connection, QSharedPointer<Design> containingDesign,\r\n        QUndoCommand* parent = 0);\r\n\r\n    /*!\r\n     *  Destructor.\r\n     */\r\n    ~ComConnectionDeleteCommand();\r\n\r\n    /*!\r\n     *  Undoes the command.\r\n     */\r\n    virtual void undo();\r\n\r\n    /*!\r\n     *  Redoes the command.\r\n     */\r\n    virtual void redo();\r\n\r\nprivate:\r\n    // Disable copying.\r\n    ComConnectionDeleteCommand(ComConnectionDeleteCommand const& rhs);\r\n    ComConnectionDeleteCommand& operator=(ComConnectionDeleteCommand const& rhs);\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! The COM interconnection.\r\n    ComGraphicsConnection* connection_;\r\n\r\n    //! The graphics scene.\r\n    QGraphicsScene* scene_;\r\n\r\n    //! The design containing the interconnection.\r\n    QSharedPointer<Design> containingDesign_;\r\n\r\n    //! Boolean flag for indicating if the connection should be deleted in the destructor.\r\n    bool deleteConnection_;\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n\r\n#endif // COMCONNECTIONDELETECOMMAND_H\r\n"
  },
  {
    "path": "editors/SystemDesign/UndoCommands/ComConnectionExchangeCommand.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ComConnectionExchangeCommand.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Mikko Teuho\r\n// Date: 02.03.2016\r\n//\r\n// Description:\r\n// Undo command for exchanging COM connections.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"ComConnectionExchangeCommand.h\"\r\n\r\n#include <common/graphicsItems/ConnectionEndpoint.h>\r\n#include <common/graphicsItems/ComponentItem.h>\r\n\r\n#include <editors/SystemDesign/ComGraphicsConnection.h>\r\n#include <editors/SystemDesign/SWPortItem.h>\r\n#include <editors/SystemDesign/SWInterfaceItem.h>\r\n\r\n#include <IPXACTmodels/Design/HierInterface.h>\r\n#include <IPXACTmodels/Design/ActiveInterface.h>\r\n#include <IPXACTmodels/Design/ComponentInstance.h>\r\n#include <IPXACTmodels/kactusExtensions/ComInterconnection.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComConnectionExchangeCommand::ComConnectionExchangeCommand()\r\n//-----------------------------------------------------------------------------\r\nComConnectionExchangeCommand::ComConnectionExchangeCommand(ComGraphicsConnection* connection,\r\n                                                           ConnectionEndpoint* oldEndpoint,\r\n                                                           ConnectionEndpoint* newEndpoint, QUndoCommand* parent):\r\nQUndoCommand(parent),\r\nconnection_(connection),\r\noldEndpoint_(oldEndpoint),\r\nnewEndpoint_(newEndpoint),\r\noldInterface_(),\r\nnewInterface_()\r\n{\r\n    createExchangedInterfaces();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComConnectionExchangeCommand::createExchangedInterfaces()\r\n//-----------------------------------------------------------------------------\r\nvoid ComConnectionExchangeCommand::createExchangedInterfaces()\r\n{\r\n    if (connection_->isOffPage())\r\n    {\r\n        ConnectionEndpoint* oldParentPoint = dynamic_cast<ConnectionEndpoint*>(oldEndpoint_->parentItem());\r\n        if (oldParentPoint)\r\n        {\r\n            oldInterface_ = createConnectionInterface(oldParentPoint);\r\n        }\r\n\r\n        ConnectionEndpoint* newParentPoint = dynamic_cast<ConnectionEndpoint*>(newEndpoint_->parentItem());\r\n        if (newParentPoint)\r\n        {\r\n            newInterface_ = createConnectionInterface(newParentPoint);\r\n        }\r\n    }\r\n    else\r\n    {\r\n        oldInterface_ = createConnectionInterface(oldEndpoint_);\r\n        newInterface_ = createConnectionInterface(newEndpoint_);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComConnectionExchangeCommand::~ComConnectionExchangeCommand()\r\n//-----------------------------------------------------------------------------\r\nComConnectionExchangeCommand::~ComConnectionExchangeCommand()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComConnectionExchangeCommand::undo()\r\n//-----------------------------------------------------------------------------\r\nvoid ComConnectionExchangeCommand::undo()\r\n{\r\n    QUndoCommand::undo();\r\n\r\n    QSharedPointer<ComInterconnection> interconnection = connection_->getInterconnection();\r\n\r\n    if (interconnection && oldInterface_)\r\n    {\r\n        if (connection_->endpoint1() == newEndpoint_)\r\n        {\r\n            connection_->setEndpoint1(oldEndpoint_);\r\n            \r\n            QSharedPointer<ActiveInterface> oldActiveInterface = oldInterface_.dynamicCast<ActiveInterface>();\r\n            if (oldActiveInterface)\r\n            {\r\n                interconnection->setStartInterface(oldActiveInterface);\r\n            }\r\n        }\r\n        else\r\n        {\r\n            connection_->setEndpoint2(oldEndpoint_);\r\n            \r\n            interconnection->setInterface(oldInterface_);\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComConnectionExchangeCommand::redo()\r\n//-----------------------------------------------------------------------------\r\nvoid ComConnectionExchangeCommand::redo()\r\n{\r\n    QSharedPointer<ComInterconnection> interconnection = connection_->getInterconnection();\r\n\r\n    if (interconnection && newInterface_)\r\n    {\r\n        if (connection_->endpoint1() == oldEndpoint_)\r\n        {\r\n            connection_->setEndpoint1(newEndpoint_);\r\n            \r\n            QSharedPointer<ActiveInterface> newActiveInterface = newInterface_.dynamicCast<ActiveInterface>();\r\n            if (newActiveInterface)\r\n            {\r\n                interconnection->setStartInterface(newActiveInterface);\r\n            }\r\n        }\r\n        else\r\n        {\r\n            connection_->setEndpoint2(newEndpoint_);\r\n            \r\n            interconnection->setInterface(newInterface_);\r\n        }\r\n    }\r\n\r\n    QUndoCommand::redo();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComConnectionExchangeCommand::createConnectionInterface()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<HierInterface> ComConnectionExchangeCommand::createConnectionInterface(ConnectionEndpoint* endPoint)\r\n{\r\n    SWPortItem* portEndPoint = dynamic_cast<SWPortItem*>(endPoint);\r\n    SWInterfaceItem* interfaceEndPoint = dynamic_cast<SWInterfaceItem*>(endPoint);\r\n    if (portEndPoint)\r\n    {\r\n        QString instanceName = portEndPoint->encompassingComp()->getComponentInstance()->getInstanceName();\r\n        return QSharedPointer<ActiveInterface> (new ActiveInterface(instanceName, endPoint->name()));\r\n    }\r\n    else if (interfaceEndPoint)\r\n    {\r\n        return QSharedPointer<HierInterface> (new HierInterface(endPoint->name()));\r\n    }\r\n\r\n    return QSharedPointer<HierInterface> ();\r\n}\r\n"
  },
  {
    "path": "editors/SystemDesign/UndoCommands/ComConnectionExchangeCommand.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ComConnectionExchangeCommand.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Mikko Teuho\r\n// Date: 02.03.2016\r\n//\r\n// Description:\r\n// Undo command for exchanging COM connections.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef COMCONNECTIONEXCHANGECOMMAND_H\r\n#define COMCONNECTIONEXCHANGECOMMAND_H\r\n\r\n#include <QUndoCommand>\r\n#include <QPointF>\r\n#include <QSharedPointer>\r\n\r\nclass ComGraphicsConnection;\r\nclass ConnectionEndpoint;\r\nclass HierInterface;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Undo command for exchanging COM connections.\r\n//-----------------------------------------------------------------------------\r\nclass ComConnectionExchangeCommand : public QUndoCommand\r\n{\r\npublic:\r\n\r\n    /*!\r\n     *  Constructor.\r\n     *\r\n     *    @param [in] connection      The selected COM graphics connection.\r\n     *    @param [in] oldEndpoint     The old endpoint from which to disconnect the connection.\r\n     *    @param [in] newEndpoint     The new endpoint to which to connect the connection.\r\n     *    @param [in] parent          The parent command.\r\n     */\r\n    ComConnectionExchangeCommand(ComGraphicsConnection* connection, ConnectionEndpoint* oldEndpoint,\r\n        ConnectionEndpoint* newEndpoint, QUndoCommand* parent = 0);\r\n\r\n    /*!\r\n     *  Destructor.\r\n     */\r\n    ~ComConnectionExchangeCommand();\r\n\r\n    /*!\r\n     *  Undoes the command.\r\n     */\r\n    virtual void undo();\r\n\r\n    /*!\r\n     *  Redoes the command.\r\n     */\r\n    virtual void redo();\r\n\r\nprivate:\r\n    // Disable copying.\r\n    ComConnectionExchangeCommand(ComConnectionExchangeCommand const& rhs);\r\n    ComConnectionExchangeCommand& operator=(ComConnectionExchangeCommand const& rhs);\r\n\r\n    /*!\r\n     *  Create interfaces for the exchanged connection.\r\n     */\r\n    void createExchangedInterfaces();\r\n\r\n    /*!\r\n     *  Create an interface from the selected connection end point.\r\n     *\r\n     *    @param [in] endPoint    The selected connection end point.\r\n     *\r\n     *    @return The created interface.\r\n     */\r\n    QSharedPointer<HierInterface> createConnectionInterface(ConnectionEndpoint* endPoint);\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! The COM graphics connection.\r\n    ComGraphicsConnection* connection_;\r\n\r\n    //! The old endpoint.\r\n    ConnectionEndpoint* oldEndpoint_;\r\n\r\n    //! The new endpoint.\r\n    ConnectionEndpoint* newEndpoint_;\r\n\r\n    //! The old interface.\r\n    QSharedPointer<HierInterface> oldInterface_;\r\n\r\n    //! The new interface.\r\n    QSharedPointer<HierInterface> newInterface_;\r\n};\r\n//-----------------------------------------------------------------------------\r\n\r\n#endif // COMCONNECTIONEXCHANGECOMMAND_H\r\n"
  },
  {
    "path": "editors/SystemDesign/UndoCommands/ReplaceSystemComponentCommand.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ReplaceSystemComponentCommand.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Mikko Teuho\r\n// Date: 02.03.2016\r\n//\r\n// Description:\r\n// Undo change command for replacing system component item.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"ReplaceSystemComponentCommand.h\"\r\n\r\n#include <common/graphicsItems/CommonGraphicsUndoCommands.h>\r\n#include <common/graphicsItems/ConnectionUndoCommands.h>\r\n#include <common/graphicsItems/ComponentItem.h>\r\n#include <common/graphicsItems/GraphicsConnection.h>\r\n\r\n#include <editors/common/Association/AssociationChangeEndpointCommand.h>\r\n#include <editors/SystemDesign/SystemComponentItem.h>\r\n#include <editors/SystemDesign/SWComponentItem.h>\r\n#include <editors/SystemDesign/ComGraphicsConnection.h>\r\n#include <editors/SystemDesign/ApiGraphicsConnection.h>\r\n\r\n#include <editors/SystemDesign/UndoCommands/SystemMoveCommands.h>\r\n#include <editors/SystemDesign/UndoCommands/SystemComponentDeleteCommand.h>\r\n#include <editors/SystemDesign/UndoCommands/SystemComponentAddCommand.h>\r\n#include <editors/SystemDesign/UndoCommands/ComConnectionExchangeCommand.h>\r\n#include <editors/SystemDesign/UndoCommands/ApiConnectionExchangeCommand.h>\r\n#include <editors/SystemDesign/UndoCommands/ComConnectionDeleteCommand.h>\r\n#include <editors/SystemDesign/UndoCommands/ApiConnectionDeleteCommand.h>\r\n\r\n#include <IPXACTmodels/Design/Design.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ReplaceSystemComponentCommand::ReplaceSystemComponentCommand()\r\n//-----------------------------------------------------------------------------\r\nReplaceSystemComponentCommand::ReplaceSystemComponentCommand(SystemComponentItem* oldComp,\r\n    SystemComponentItem* newComp, bool existing, bool keepOld, QSharedPointer<Design> containingDesign,\r\n    DesignDiagram* diagram, QUndoCommand* parent):\r\nQUndoCommand(parent),\r\noldComp_(oldComp),\r\nnewComp_(newComp),\r\nexisting_(existing),\r\ndiagram_(diagram)\r\n{\r\n    // Create a move/add command for the new component.\r\n    if (existing)\r\n    {\r\n        if (oldComp_->type() == newComp_->type())\r\n        {\r\n            new ItemMoveCommand(newComp_, newComp_->scenePos(), newComp_->getParentStack(), oldComp_->scenePos(),\r\n                oldComp_->getParentStack(), diagram, this);\r\n\r\n            if (keepOld)\r\n            {\r\n                new ItemMoveCommand(oldComp_, oldComp_->scenePos(), oldComp_->getParentStack(),\r\n                    newComp_->scenePos(), newComp_->getParentStack(), diagram, this);\r\n            }\r\n        }\r\n    }\r\n    else\r\n    {\r\n        SystemComponentAddCommand* addCmd =\r\n            new SystemComponentAddCommand(oldComp_->getParentStack(), newComp_, diagram, this);\r\n\r\n        connect(addCmd, SIGNAL(componentInstantiated(ComponentItem*)),\r\n            this, SIGNAL(componentInstantiated(ComponentItem*)), Qt::UniqueConnection);\r\n        connect(addCmd, SIGNAL(componentInstanceRemoved(ComponentItem*)),\r\n            this, SIGNAL(componentInstanceRemoved(ComponentItem*)), Qt::UniqueConnection);\r\n    }\r\n\r\n    changeConnections(oldComp_, newComp_, containingDesign);\r\n\r\n    // Create a delete command for the old component if it should not be kept.\r\n    if (!keepOld)\r\n    {\r\n        SystemComponentDeleteCommand* deleteCmd =\r\n            new SystemComponentDeleteCommand(oldComp_, containingDesign, this);\r\n\r\n        connect(deleteCmd, SIGNAL(componentInstantiated(ComponentItem*)),\r\n            this, SIGNAL(componentInstantiated(ComponentItem*)), Qt::UniqueConnection);\r\n        connect(deleteCmd, SIGNAL(componentInstanceRemoved(ComponentItem*)),\r\n            this, SIGNAL(componentInstanceRemoved(ComponentItem*)), Qt::UniqueConnection);\r\n\r\n        foreach(Association* association, oldComp_->getAssociations())\r\n        {\r\n            new AssociationChangeEndpointCommand(association, oldComp_, newComp_, this);\r\n        }\r\n    }\r\n    else\r\n    {\r\n        changeConnections(newComp_, oldComp_, containingDesign);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ReplaceSystemComponentCommand::changeConnections()\r\n//-----------------------------------------------------------------------------\r\nvoid ReplaceSystemComponentCommand::changeConnections(SystemComponentItem* oldComponent,\r\n    SystemComponentItem* newComponent, QSharedPointer<Design> design)\r\n{\r\n    QVector<QString> connectionNames;\r\n\r\n    for (ConnectionEndpoint* oldEndpoint : oldComponent->getEndpoints())\r\n    {\r\n        if (!oldEndpoint->getConnections().isEmpty() ||\r\n            !oldEndpoint->getOffPageConnector()->getConnections().isEmpty())\r\n        {\r\n            SWPortItem* newEndpoint = newComponent->getSWPortMatchingOtherEndPoint(oldEndpoint);\r\n\r\n            if (newEndpoint != 0)\r\n            {\r\n                // Create a move command to move the port to the same place where it is in the old component.\r\n                new SWPortMoveCommand(newEndpoint, newEndpoint->pos(), oldEndpoint->pos(), diagram_, this);\r\n\r\n                // Exchange connections between the endpoints.\r\n                for (GraphicsConnection* connection : oldEndpoint->getConnections())\r\n                {\r\n                    createConnectionExchangeCommand(connection, oldEndpoint, newEndpoint);\r\n                }\r\n\r\n                for (GraphicsConnection* connection : oldEndpoint->getOffPageConnector()->getConnections())\r\n                {\r\n                    createConnectionExchangeCommand(connection, oldEndpoint->getOffPageConnector(),\r\n                        newEndpoint->getOffPageConnector());\r\n                }\r\n            }\r\n            else\r\n            {\r\n                for (GraphicsConnection* connection : oldEndpoint->getConnections())\r\n                {\r\n                    if (!connectionNames.contains(connection->name()))\r\n                    {\r\n                        createConnectionDeleteCommand(connection, design);\r\n                        connectionNames.append(connection->name());\r\n                    }\r\n                }\r\n                for (GraphicsConnection* connection : oldEndpoint->getOffPageConnector()->getConnections())\r\n                {\r\n                    if (!connectionNames.contains(connection->name()))\r\n                    {\r\n                        createConnectionDeleteCommand(connection, design);\r\n                        connectionNames.append(connection->name());\r\n                    }\r\n                }\r\n            }\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ReplaceSystemComponentCommand::createConnectionExchangeCommand()\r\n//-----------------------------------------------------------------------------\r\nvoid ReplaceSystemComponentCommand::createConnectionExchangeCommand(GraphicsConnection* connection,\r\n    ConnectionEndpoint* oldEndpoint, ConnectionEndpoint* newEndpoint)\r\n{\r\n    ComGraphicsConnection* comConnection = dynamic_cast<ComGraphicsConnection*>(connection);\r\n    ApiGraphicsConnection* apiConnection = dynamic_cast<ApiGraphicsConnection*>(connection);\r\n    if (comConnection)\r\n    {\r\n        new ComConnectionExchangeCommand(comConnection, oldEndpoint, newEndpoint, this);\r\n    }\r\n    else if (apiConnection)\r\n    {\r\n        new ApiConnectionExchangeCommand(apiConnection, oldEndpoint, newEndpoint, this);\r\n    }\r\n    else\r\n    {\r\n        new ConnectionExchangeCommand(connection, oldEndpoint, newEndpoint, this);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ReplaceSystemComponentCommand::createConnectionDeleteCommands()\r\n//-----------------------------------------------------------------------------\r\nvoid ReplaceSystemComponentCommand::createConnectionDeleteCommand(GraphicsConnection* connection,\r\n    QSharedPointer<Design> design)\r\n{\r\n    ComGraphicsConnection* comConnection = dynamic_cast<ComGraphicsConnection*>(connection);\r\n    if (comConnection)\r\n    {\r\n        new ComConnectionDeleteCommand(comConnection, design, this);\r\n    }\r\n    else\r\n    {\r\n        ApiGraphicsConnection* apiConnection = dynamic_cast<ApiGraphicsConnection*>(connection);\r\n        if (apiConnection)\r\n        {\r\n            new ApiConnectionDeleteCommand(apiConnection, design, this);\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ReplaceSystemComponentCommand::~ReplaceSystemComponentCommand()\r\n//-----------------------------------------------------------------------------\r\nReplaceSystemComponentCommand::~ReplaceSystemComponentCommand()\r\n{\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ReplaceSystemComponentCommand::undo()\r\n//-----------------------------------------------------------------------------\r\nvoid ReplaceSystemComponentCommand::undo()\r\n{\r\n    // Execute child commands.\r\n    QUndoCommand::undo();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ReplaceSystemComponentCommand::redo()\r\n//-----------------------------------------------------------------------------\r\nvoid ReplaceSystemComponentCommand::redo()\r\n{\r\n    if (newComp_->type() == oldComp_->type() || !existing_)\r\n    {\r\n        // Place the new component to the exact same location as the old one.\r\n        newComp_->setParentItem(0);\r\n        newComp_->setPos(oldComp_->scenePos());\r\n    }\r\n\r\n    // Execute child commands.\r\n    QUndoCommand::redo();\r\n}\r\n"
  },
  {
    "path": "editors/SystemDesign/UndoCommands/ReplaceSystemComponentCommand.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ReplaceSystemComponentCommand.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Mikko Teuho\r\n// Date: 02.03.2016\r\n//\r\n// Description:\r\n// Undo change command for replacing system component item.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef REPLACESYSTEMCOMPONENTCOMMAND_H\r\n#define REPLACESYSTEMCOMPONENTCOMMAND_H\r\n\r\n#include <IPXACTmodels/common/VLNV.h>\r\n\r\n#include <QUndoCommand>\r\n\r\nclass ComponentItem;\r\nclass SystemComponentItem;\r\nclass Design;\r\nclass ComInterconnection;\r\nclass ApiInterconnection;\r\nclass GraphicsConnection;\r\nclass ConnectionEndpoint;\r\nclass DesignDiagram;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Undo command for replacing a system component instance with another one.\r\n//-----------------------------------------------------------------------------\r\nclass ReplaceSystemComponentCommand : public QObject, public QUndoCommand\r\n{\r\n    Q_OBJECT\r\n\r\npublic:\r\n\r\n\t/*!\r\n\t *  The constructor.\r\n\t *\r\n\t *    @param [in] oldComp             The old system component item.\r\n\t *    @param [in] newComp             The new system component item.\r\n\t *    @param [in] existing            Flag for existence checking.\r\n\t *    @param [in] keepOld             Flag for keeping the old item.\r\n     *    @param [in] containingDesign    The design containing the system component.\r\n     *    @param [in] diagram             Diagram containing the scene of the component items.\r\n\t *    @param [in] parent              Owner of the object.\r\n\t */\r\n    ReplaceSystemComponentCommand(SystemComponentItem* oldComp, SystemComponentItem* newComp, bool existing,\r\n        bool keepOld, QSharedPointer<Design> containingDesign, DesignDiagram* diagram, QUndoCommand* parent = 0);\r\n\r\n\t/*!\r\n     *  Destructor.\r\n     */\r\n\tvirtual ~ReplaceSystemComponentCommand();\r\n\r\n\t/*!\r\n\t *  Undoes the command.\r\n\t */\r\n\tvirtual void undo();\r\n\r\n\t/*! \r\n\t *  Redoes the command.\r\n\t */\r\n\tvirtual void redo();\r\n\r\nsignals:\r\n    //! Emitted when a new component is instantiated to the design.\r\n    void componentInstantiated(ComponentItem*);\r\n\r\n    //! Emitted when a component instance is removed from the design.\r\n    void componentInstanceRemoved(ComponentItem*);\r\n\r\nprivate:\r\n    // Disable copying.\r\n    ReplaceSystemComponentCommand(ReplaceSystemComponentCommand const& rhs);\r\n    ReplaceSystemComponentCommand& operator=(ReplaceSystemComponentCommand const& rhs);\r\n\r\n    /*!\r\n     *  Change the connections of the replaced component item.\r\n     *\r\n     *    @param [in] oldComponent    The component item being changed.\r\n     *    @param [in] newComponent    The new component item.\r\n     *    @param [in] design          The design containing the connections.\r\n     */\r\n    void changeConnections(SystemComponentItem* oldComponent, SystemComponentItem* newComponent,\r\n        QSharedPointer<Design> design);\r\n\r\n    /*!\r\n     *  Create exchange command for the replaced connection.\r\n     *\r\n     *    @param [in] connection      The selected graphics connection.\r\n     *    @param [in] oldEndpoint     The old end point.\r\n     *    @param [in] newEndpoint     The new end point.\r\n     */\r\n    void createConnectionExchangeCommand(GraphicsConnection* connection, ConnectionEndpoint* oldEndpoint,\r\n        ConnectionEndpoint* newEndpoint);\r\n\r\n    /*!\r\n     *  Create delete commands for a selected connection.\r\n     *\r\n     *    @param [in] connection  The selected connection.\r\n     *    @param [in] design      Design containing the selected connection.\r\n     */\r\n    void createConnectionDeleteCommand(GraphicsConnection* connection, QSharedPointer<Design> design);\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n\t//! The old component to replace.\r\n    SystemComponentItem* oldComp_;\r\n\r\n    //! The new component that replaces the old one.\r\n    SystemComponentItem* newComp_;\r\n\r\n    //! Replaced component exists?\r\n    bool existing_;\r\n\r\n    //! Diagram containing the scene of the component items.\r\n    DesignDiagram* diagram_;\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n\r\n#endif // REPLACESYSTEMCOMPONENTCOMMAND_H\r\n"
  },
  {
    "path": "editors/SystemDesign/UndoCommands/SWInterfaceAddCommand.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: SWInterfaceAddCommand.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Mikko Teuho\r\n// Date: 26.02.2016\r\n//\r\n// Description:\r\n// Undo add command for SW interfaces.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"SWInterfaceAddCommand.h\"\r\n\r\n#include <editors/SystemDesign/SWInterfaceItem.h>\r\n\r\n#include <common/graphicsItems/IGraphicsItemStack.h>\r\n\r\n#include <IPXACTmodels/kactusExtensions/InterfaceGraphicsData.h>\r\n\r\n#include <IPXACTmodels/Design/Design.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SWInterfaceAddCommand::SWInterfaceAddCommand()\r\n//-----------------------------------------------------------------------------\r\nSWInterfaceAddCommand::SWInterfaceAddCommand(IGraphicsItemStack* stack, SWInterfaceItem* item,\r\n                                             QSharedPointer<Design> containingDesign, QUndoCommand* parent):\r\nQUndoCommand(parent),\r\ninterfaceItem_(item),\r\napiInterface_(item->getApiInterface()),\r\ncomInterface_(item->getComInterface()),\r\nstack_(stack),\r\ndel_(false),\r\ncontainingDesign_(containingDesign)\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SWInterfaceAddCommand::~SWInterfaceAddCommand()\r\n//-----------------------------------------------------------------------------\r\nSWInterfaceAddCommand::~SWInterfaceAddCommand()\r\n{\r\n    if (del_)\r\n    {\r\n        delete interfaceItem_;\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SWInterfaceAddCommand::undo()\r\n//-----------------------------------------------------------------------------\r\nvoid SWInterfaceAddCommand::undo()\r\n{\r\n    QUndoCommand::undo();\r\n\r\n    // Undefine the interface.\r\n    if (apiInterface_ != 0 || comInterface_ != 0)\r\n    {\r\n        interfaceItem_->undefine();\r\n    }\r\n\r\n    // Remove the item from the column and the scene.\r\n    stack_->removeItem(interfaceItem_);\r\n    interfaceItem_->scene()->removeItem(interfaceItem_);\r\n    del_ = true;\r\n\r\n    QSharedPointer<InterfaceGraphicsData> graphicsData = interfaceItem_->getInterfaceGraphicsData();\r\n    containingDesign_->getVendorExtensions()->removeAll(graphicsData);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SWInterfaceAddCommand::redo()\r\n//-----------------------------------------------------------------------------\r\nvoid SWInterfaceAddCommand::redo()\r\n{\r\n    // Execute child commands.\r\n    QUndoCommand::redo();\r\n\r\n    // Add the item to the column.\r\n    stack_->addItem(interfaceItem_);\r\n    del_ = false;\r\n\r\n    QSharedPointer<InterfaceGraphicsData> graphicsData = interfaceItem_->getInterfaceGraphicsData();\r\n    containingDesign_->getVendorExtensions()->append(graphicsData);\r\n\r\n    // Define the interface.\r\n    if (apiInterface_ != 0)\r\n    {\r\n        interfaceItem_->define(apiInterface_);\r\n    }\r\n    else if (comInterface_ != 0)\r\n    {\r\n        interfaceItem_->define(comInterface_);\r\n    }\r\n}\r\n"
  },
  {
    "path": "editors/SystemDesign/UndoCommands/SWInterfaceAddCommand.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: SWInterfaceAddCommand.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Mikko Teuho\r\n// Date: 26.02.2016\r\n//\r\n// Description:\r\n// Undo add command for SW interfaces.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef SWINTERFACEADDCOMMAND_H\r\n#define SWINTERFACEADDCOMMAND_H\r\n\r\n#include <QUndoCommand>\r\n#include <QGraphicsItem>\r\n#include <QGraphicsScene>\r\n#include <QObject>\r\n\r\nclass IGraphicsItemStack;\r\nclass SWInterfaceItem;\r\nclass ApiInterface;\r\nclass ComInterface;\r\n\r\nclass Design;\r\n\r\n// -----------------------------------------------------------------------------\r\n// ! Undo add command for SW interfaces.\r\n// -----------------------------------------------------------------------------\r\nclass SWInterfaceAddCommand : public QUndoCommand\r\n{\r\npublic:\r\n\r\n    /*!\r\n     *  Constructor.\r\n     *\r\n     *    @param [in] stack               The graphics item stack to which to paste the item.\r\n     *    @param [in] item                The SW interface item to paste.\r\n     *    @param [in] containingDesign    The design containing the interface.\r\n     *    @param [in] parent              The parent command.\r\n     */\r\n    SWInterfaceAddCommand(IGraphicsItemStack* stack, SWInterfaceItem* item,\r\n        QSharedPointer<Design> containingDesign, QUndoCommand* parent = 0);\r\n\r\n    /*!\r\n     *  Destructor.\r\n     */\r\n    ~SWInterfaceAddCommand();\r\n\r\n    /*!\r\n     *  Undoes the command.\r\n     */\r\n    virtual void undo();\r\n\r\n    /*!\r\n     *  Redoes the command.\r\n     */\r\n    virtual void redo();\r\n\r\nprivate:\r\n\r\n    // Disable copying.\r\n    SWInterfaceAddCommand(SWInterfaceAddCommand const& rhs);\r\n    SWInterfaceAddCommand& operator=(SWInterfaceAddCommand const& rhs);\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! The SW interface item.\r\n    SWInterfaceItem* interfaceItem_;\r\n\r\n    //! The API interface (if API).\r\n    QSharedPointer<ApiInterface> apiInterface_;\r\n\r\n    //! The COM interface (if COM).\r\n    QSharedPointer<ComInterface> comInterface_;\r\n\r\n    //! The item's parent component stack.\r\n    IGraphicsItemStack* stack_;\r\n\r\n    //! Boolean flag for indicating if the component should be deleted in the destructor.\r\n    bool del_;\r\n\r\n    //! The design containing the interface.\r\n    QSharedPointer<Design> containingDesign_;\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n\r\n#endif // SWINTERFACEADDCOMMAND_H\r\n"
  },
  {
    "path": "editors/SystemDesign/UndoCommands/SWInterfaceDeleteCommand.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: SWInterfaceDeleteCommand.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Mikko Teuho\r\n// Date: 16.02.2016\r\n//\r\n// Description:\r\n// Undo delete command for SW interface in system design.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"SWInterfaceDeleteCommand.h\"\r\n\r\n#include <common/graphicsItems/GraphicsColumnLayout.h>\r\n\r\n#include <editors/SystemDesign/UndoCommands/ApiConnectionDeleteCommand.h>\r\n#include <editors/SystemDesign/UndoCommands/ComConnectionDeleteCommand.h>\r\n\r\n#include <editors/SystemDesign/ApiGraphicsConnection.h>\r\n#include <editors/SystemDesign/ComGraphicsConnection.h>\r\n#include <editors/SystemDesign/SWInterfaceItem.h>\r\n\r\n#include <IPXACTmodels/Design/Design.h>\r\n#include <IPXACTmodels/kactusExtensions/InterfaceGraphicsData.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SWInterfaceDeleteCommand::SWInterfaceDeleteCommand()\r\n//-----------------------------------------------------------------------------\r\nSWInterfaceDeleteCommand::SWInterfaceDeleteCommand(SWInterfaceItem* interface,\r\n                                                   QSharedPointer<Design> containingDesign,\r\n                                                   QSharedPointer<Component> component, QUndoCommand* parent):\r\nQUndoCommand(parent),\r\ninterfaceItem_(interface),\r\napiInterface_(interface->getApiInterface()),\r\ncomInterface_(interface->getComInterface()),\r\nparent_(dynamic_cast<IGraphicsItemStack*>(interface->parentItem())),\r\nscene_(interface->scene()),\r\ndel_(true),\r\ncontainingDesign_(containingDesign),\r\ncontainingComponent_(component)\r\n{\r\n    if (apiInterface_)\r\n    {\r\n        foreach (GraphicsConnection* connection, interfaceItem_->getConnections())\r\n        {\r\n            ApiGraphicsConnection* apiConnection = dynamic_cast<ApiGraphicsConnection*>(connection);\r\n\r\n            new ApiConnectionDeleteCommand(apiConnection, containingDesign, this);\r\n        }\r\n    }\r\n    else if (comInterface_)\r\n    {\r\n        foreach (GraphicsConnection* connection, interfaceItem_->getConnections())\r\n        {\r\n            ComGraphicsConnection* comConnection = dynamic_cast<ComGraphicsConnection*>(connection);\r\n            new ComConnectionDeleteCommand(comConnection, containingDesign, this);\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ~SWInterfaceDeleteCommand()\r\n//-----------------------------------------------------------------------------\r\nSWInterfaceDeleteCommand::~SWInterfaceDeleteCommand()\r\n{\r\n    if (del_)\r\n    {\r\n        delete interfaceItem_;\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: undo()\r\n//-----------------------------------------------------------------------------\r\nvoid SWInterfaceDeleteCommand::undo()\r\n{\r\n    // Add the interface back to the scene.\r\n    parent_->addItem(interfaceItem_);\r\n    del_ = false;\r\n\r\n    QSharedPointer<InterfaceGraphicsData> graphicsData = interfaceItem_->getInterfaceGraphicsData();\r\n    containingDesign_->getVendorExtensions()->append(graphicsData);\r\n\r\n    // Define the interface.\r\n    if (apiInterface_ != 0)\r\n    {\r\n        interfaceItem_->define(apiInterface_);\r\n\r\n        QList<QSharedPointer<ApiInterface> > interfaces = containingComponent_->getApiInterfaces();\r\n        interfaces.append(apiInterface_);\r\n        containingComponent_->setApiInterfaces(interfaces);\r\n    }\r\n    else if (comInterface_ != 0)\r\n    {\r\n        interfaceItem_->define(comInterface_);\r\n\r\n        QList<QSharedPointer<ComInterface> > interfaces = containingComponent_->getComInterfaces();\r\n        interfaces.append(comInterface_);\r\n        containingComponent_->setComInterfaces(interfaces);\r\n    }\r\n\r\n    // Execute child commands.\r\n    QUndoCommand::undo();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: redo()\r\n//-----------------------------------------------------------------------------\r\nvoid SWInterfaceDeleteCommand::redo()\r\n{\r\n    // Execute child commands.\r\n    QUndoCommand::redo();\r\n\r\n    // Undefine the interface.\r\n    if (apiInterface_ != 0 || comInterface_ != 0)\r\n    {\r\n        interfaceItem_->undefine();\r\n    }\r\n\r\n    if (apiInterface_)\r\n    {\r\n        QList<QSharedPointer<ApiInterface> > interfaces = containingComponent_->getApiInterfaces();\r\n        interfaces.removeAll(apiInterface_);\r\n        containingComponent_->setApiInterfaces(interfaces);\r\n    }\r\n    else if (comInterface_)\r\n    {\r\n        QList<QSharedPointer<ComInterface> > interfaces = containingComponent_->getComInterfaces();\r\n        interfaces.removeAll(comInterface_);\r\n        containingComponent_->setComInterfaces(interfaces);\r\n    }\r\n\r\n    QSharedPointer<InterfaceGraphicsData> graphicsData = interfaceItem_->getInterfaceGraphicsData();\r\n    containingDesign_->getVendorExtensions()->removeAll(graphicsData);\r\n\r\n    // Remove the interface from the scene.\r\n    parent_->removeItem(interfaceItem_);\r\n    scene_->removeItem(interfaceItem_);\r\n    del_ = true;\r\n}\r\n"
  },
  {
    "path": "editors/SystemDesign/UndoCommands/SWInterfaceDeleteCommand.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: SWInterfaceDeleteCommand.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Mikko Teuho\r\n// Date: 16.02.2016\r\n//\r\n// Description:\r\n// Undo delete command for SW interface in system design.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef SWINTERFACEDELETECOMMAND_H\r\n#define SWINTERFACEDELETECOMMAND_H\r\n\r\n#include <QGraphicsScene>\r\n#include <QObject>\r\n#include <QSharedPointer>\r\n#include <QUndoCommand>\r\n\r\nclass IGraphicsItemStack;\r\nclass SWInterfaceItem;\r\nclass ApiInterface;\r\nclass ComInterface;\r\nclass Design;\r\nclass Component;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! SWInterfaceDeleteCommand class.\r\n//-----------------------------------------------------------------------------\r\nclass SWInterfaceDeleteCommand : public QUndoCommand\r\n{\r\npublic:\r\n\r\n    /*!\r\n     *  Constructor.\r\n     *\r\n     *    @param [in] interface           The interface to delete.\r\n     *    @param [in] containingDesign    Design containing the SW interface.\r\n     *    @param [in] component           The component containing the design.\r\n     *    @param [in] parent              The owner of this command.\r\n     */\r\n    SWInterfaceDeleteCommand(SWInterfaceItem* interface, QSharedPointer<Design> containingDesign,\r\n        QSharedPointer<Component> component, QUndoCommand* parent = 0);\r\n\r\n    /*!\r\n     *  Destructor.\r\n     */\r\n    ~SWInterfaceDeleteCommand();\r\n\r\n    /*!\r\n     *  Undoes the command.\r\n     */\r\n    virtual void undo();\r\n\r\n    /*!\r\n     *  Redoes the command.\r\n     */\r\n    virtual void redo();\r\n\r\nprivate:\r\n\r\n    // Disable copying.\r\n    SWInterfaceDeleteCommand(SWInterfaceDeleteCommand const& rhs);\r\n    SWInterfaceDeleteCommand& operator=(SWInterfaceDeleteCommand const& rhs);\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! The interface item.\r\n    SWInterfaceItem* interfaceItem_;\r\n\r\n    //! The API interface (if API).\r\n    QSharedPointer<ApiInterface> apiInterface_;\r\n\r\n    //! The COM interface (if COM).\r\n    QSharedPointer<ComInterface> comInterface_;\r\n\r\n    //! The parent stack.\r\n    IGraphicsItemStack* parent_;\r\n\r\n    //! The graphics scene.\r\n    QGraphicsScene* scene_;\r\n\r\n    //! Boolean flag for indicating if the connection should be deleted in the destructor.\r\n    bool del_;\r\n\r\n    //! The design containing the interface.\r\n    QSharedPointer<Design> containingDesign_;\r\n\r\n    //! The component containing the SW interface.\r\n    QSharedPointer<Component> containingComponent_;\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n\r\n#endif // SWINTERFACEDELETECOMMAND_H\r\n"
  },
  {
    "path": "editors/SystemDesign/UndoCommands/SWInterfaceMoveCommand.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: SWInterfaceMoveCommand.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Mikko Teuho\r\n// Date: 26.02.2016\r\n//\r\n// Description:\r\n// Undo move command for SW interface.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"SWInterfaceMoveCommand.h\"\r\n\r\n#include <editors/SystemDesign/SWInterfaceItem.h>\r\n\r\n#include <IPXACTmodels/kactusExtensions/InterfaceGraphicsData.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SWInterfaceMoveCommand::SWInterfaceMoveCommand()\r\n//-----------------------------------------------------------------------------\r\nSWInterfaceMoveCommand::SWInterfaceMoveCommand(SWInterfaceItem* item, QPointF const& oldPos,\r\n    IGraphicsItemStack* oldStack, DesignDiagram* diagram, QUndoCommand* parent):\r\nItemMoveCommand(item, oldPos, oldStack, diagram, parent),\r\ninterfaceItem_(item),\r\noldPosition_(oldPos),\r\nnewPosition_(item->scenePos())\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SWInterfaceMoveCommand::SWInterfaceMoveCommand()\r\n//-----------------------------------------------------------------------------\r\nSWInterfaceMoveCommand::SWInterfaceMoveCommand(SWInterfaceItem* item, QPointF const& oldPos,\r\n    IGraphicsItemStack* oldStack, QPointF const& newPos, IGraphicsItemStack* newStack, DesignDiagram* diagram,\r\n    QUndoCommand* parent):\r\nItemMoveCommand(item, oldPos, oldStack, newPos, newStack, diagram, parent),\r\ninterfaceItem_(item),\r\noldPosition_(oldPos),\r\nnewPosition_(newPos)\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SWInterfaceMoveCommand::~SWInterfaceMoveCommand()\r\n//-----------------------------------------------------------------------------\r\nSWInterfaceMoveCommand::~SWInterfaceMoveCommand()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SWInterfaceMoveCommand::undo()\r\n//-----------------------------------------------------------------------------\r\nvoid SWInterfaceMoveCommand::undo()\r\n{\r\n    ItemMoveCommand::undo();\r\n\r\n    QSharedPointer<InterfaceGraphicsData> graphicsData = interfaceItem_->getInterfaceGraphicsData();\r\n    graphicsData->setPosition(oldPosition_);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SWInterfaceMoveCommand::redo()\r\n//-----------------------------------------------------------------------------\r\nvoid SWInterfaceMoveCommand::redo()\r\n{\r\n    ItemMoveCommand::redo();\r\n\r\n    QSharedPointer<InterfaceGraphicsData> graphicsData = interfaceItem_->getInterfaceGraphicsData();\r\n    graphicsData->setPosition(newPosition_);\r\n}\r\n"
  },
  {
    "path": "editors/SystemDesign/UndoCommands/SWInterfaceMoveCommand.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: SWInterfaceMoveCommand.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Mikko Teuho\r\n// Date: 26.02.2016\r\n//\r\n// Description:\r\n// Undo move command for SW interface.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef SWINTERFACEMOVECOMMAND_H\r\n#define SWINTERFACEMOVECOMMAND_H\r\n\r\n#include <QUndoCommand>\r\n#include <QGraphicsScene>\r\n#include <QString>\r\n\r\n#include <common/graphicsItems/CommonGraphicsUndoCommands.h>\r\n\r\nclass SWInterfaceItem;\r\nclass DesignDiagram;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Undo move command for SW interface.\r\n//-----------------------------------------------------------------------------\r\nclass SWInterfaceMoveCommand : public ItemMoveCommand\r\n{\r\npublic:\r\n\r\n    /*!\r\n     *  Constructor.\r\n     *\r\n     *    @param [in] item        The item to move.\r\n     *    @param [in] oldPos      The item's old position.\r\n     *    @param [in] oldStack    The item's old stack.\r\n     *    @param [in] diagram     Diagram containing the scene of the interface.\r\n     *    @param [in] parent      The parent command.\r\n     */\r\n    SWInterfaceMoveCommand(SWInterfaceItem* item, QPointF const& oldPos, IGraphicsItemStack* oldStack,\r\n        DesignDiagram* diagram, QUndoCommand* parent = 0);\r\n\r\n    /*!\r\n     *  Constructor.\r\n     *\r\n     *    @param [in] item        The item to move.\r\n     *    @param [in] oldPos      The item's old position.\r\n     *    @param [in] oldStack    The item's old stack.\r\n     *    @param [in] oldPos      The item's new position.\r\n     *    @param [in] oldStack    The item's new stack.\r\n     *    @param [in] diagram     Diagram containing the scene of the interface.\r\n     *    @param [in] parent      The parent command.\r\n     */\r\n    SWInterfaceMoveCommand(SWInterfaceItem* item, QPointF const& oldPos, IGraphicsItemStack* oldStack,\r\n        QPointF const& newPos, IGraphicsItemStack* newStack, DesignDiagram* diagram, QUndoCommand* parent = 0);\r\n\r\n    /*!\r\n     *  Destructor.\r\n     */\r\n    ~SWInterfaceMoveCommand();\r\n\r\n    /*!\r\n     *  Undoes the command.\r\n     */\r\n    virtual void undo();\r\n\r\n    /*!\r\n     *  Redoes the command.\r\n     */\r\n    virtual void redo();\r\n\r\nprivate:\r\n    // Disable copying.\r\n    SWInterfaceMoveCommand(SWInterfaceMoveCommand const& rhs);\r\n    SWInterfaceMoveCommand& operator=(SWInterfaceMoveCommand const& rhs);\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! The item being moved.\r\n    SWInterfaceItem* interfaceItem_;\r\n\r\n    //! The old position of the item.\r\n    QPointF oldPosition_;\r\n\r\n    //! The new position of the item.\r\n    QPointF newPosition_;\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n\r\n#endif // SWINTERFACEMOVECOMMAND_H\r\n"
  },
  {
    "path": "editors/SystemDesign/UndoCommands/SWPortDeleteCommand.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: SWPortDeleteCommand.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Mikko Teuho\r\n// Date: 16.02.2016\r\n//\r\n// Description:\r\n// Undo delete command for SW port item in system design.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"SWPortDeleteCommand.h\"\r\n\r\n#include <editors/SystemDesign/UndoCommands/ComConnectionDeleteCommand.h>\r\n#include <editors/SystemDesign/UndoCommands/ApiConnectionDeleteCommand.h>\r\n\r\n#include <editors/SystemDesign/ApiGraphicsConnection.h>\r\n#include <editors/SystemDesign/ComGraphicsConnection.h>\r\n#include <editors/SystemDesign/SystemComponentItem.h>\r\n#include <editors/SystemDesign/SWPortItem.h>\r\n\r\n#include <IPXACTmodels/Design/ComponentInstance.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SWPortDeleteCommand::SWPortDeleteCommand()\r\n//-----------------------------------------------------------------------------\r\nSWPortDeleteCommand::SWPortDeleteCommand(SWPortItem* port, QSharedPointer<Design> containingDesign,\r\n                                         QUndoCommand* parent):\r\nQUndoCommand(parent),\r\nport_(port),\r\nparent_(static_cast<SystemComponentItem*>(port->parentItem())),\r\nscene_(port->scene()),\r\ndel_(true)\r\n{\r\n    QList<GraphicsConnection*> connections = port_->getConnections();\r\n    connections.append(port_->getOffPageConnector()->getConnections());\r\n\r\n    if (!connections.isEmpty())\r\n    {\r\n        if (port_->getApiInterface())\r\n        {\r\n            foreach (GraphicsConnection* connection, connections)\r\n            {\r\n                ApiGraphicsConnection* apiConnection = dynamic_cast<ApiGraphicsConnection*>(connection);\r\n                new ApiConnectionDeleteCommand(apiConnection, containingDesign, this);\r\n            }\r\n        }\r\n        else if (port_->getComInterface())\r\n        {\r\n            foreach (GraphicsConnection* connection, connections)\r\n            {\r\n                ComGraphicsConnection* comConnection = dynamic_cast<ComGraphicsConnection*>(connection);\r\n                new ComConnectionDeleteCommand(comConnection, containingDesign, this);\r\n            }\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SWPortDeleteCommand::~SWPortDeleteCommand()\r\n//-----------------------------------------------------------------------------\r\nSWPortDeleteCommand::~SWPortDeleteCommand()\r\n{\r\n    if (del_)\r\n    {\r\n        delete port_;\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SWPortDeleteCommand::undo()\r\n//-----------------------------------------------------------------------------\r\nvoid SWPortDeleteCommand::undo()\r\n{\r\n    // Add the endpoint back to the scene.\r\n    scene_->addItem(port_);\r\n\r\n    // Add the endpoint to the parent component.\r\n    parent_->addPort(port_);\r\n    del_ = false;\r\n\r\n    QSharedPointer<ComponentInstance> containingInstance = parent_->getComponentInstance();\r\n    containingInstance->updateApiInterfacePosition(port_->name(), port_->pos());\r\n\r\n    // Execute child commands.\r\n    QUndoCommand::undo();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SWPortDeleteCommand::redo()\r\n//-----------------------------------------------------------------------------\r\nvoid SWPortDeleteCommand::redo()\r\n{\r\n    // Execute child commands.\r\n    QUndoCommand::redo();\r\n\r\n    // Remove the endpoint from the parent component.\r\n    parent_->removePort(port_);\r\n\r\n    QSharedPointer<ComponentInstance> containingInstance = parent_->getComponentInstance();\r\n    QMap<QString, QPointF> apiPositions = containingInstance->getApiInterfacePositions();\r\n    QMap<QString, QPointF> comPositions = containingInstance->getComInterfacePositions();\r\n\r\n    if (apiPositions.contains(port_->name()))    {\r\n        containingInstance->removeApiInterfacePosition(port_->name());\r\n    }\r\n    if (comPositions.contains(port_->name()))\r\n    {\r\n        containingInstance->removeComInterfacePosition(port_->name());\r\n    }\r\n\r\n    // Remove the endpoint from the scene.\r\n    scene_->removeItem(port_);\r\n    del_ = true;\r\n}\r\n"
  },
  {
    "path": "editors/SystemDesign/UndoCommands/SWPortDeleteCommand.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: SWPortDeleteCommand.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Mikko Teuho\r\n// Date: 16.02.2016\r\n//\r\n// Description:\r\n// Undo delete command for SW port item in system design.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef SWPORTDELETECOMMAND_H\r\n#define SWPORTDELETECOMMAND_H\r\n\r\n#include <QUndoCommand>\r\n#include <QGraphicsScene>\r\n#include <QObject>\r\n\r\nclass SWPortItem;\r\nclass SystemComponentItem;\r\nclass Design;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! SWPortDeleteCommand class.\r\n//-----------------------------------------------------------------------------\r\nclass SWPortDeleteCommand : public QUndoCommand\r\n{\r\npublic:\r\n\r\n    /*!\r\n     *  Constructor.\r\n     *\r\n     *    @param [in] port                The port to delete.\r\n     *    @param [in] containingDesign    Design containing the SW port.\r\n     *    @param [in] parent              The owner of this command.\r\n     */\r\n    SWPortDeleteCommand(SWPortItem* port, QSharedPointer<Design> containingDesign, QUndoCommand* parent = 0);\r\n\r\n    /*!\r\n     *  Destructor.\r\n     */\r\n    ~SWPortDeleteCommand();\r\n\r\n    /*!\r\n     *  Undoes the command.\r\n     */\r\n    virtual void undo();\r\n\r\n    /*!\r\n     *  Redoes the command.\r\n     */\r\n    virtual void redo();\r\n\r\nprivate:\r\n\r\n    // Disable copying.\r\n    SWPortDeleteCommand(SWPortDeleteCommand const& rhs);\r\n    SWPortDeleteCommand& operator=(SWPortDeleteCommand const& rhs);\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! The diagram port.\r\n    SWPortItem* port_;\r\n\r\n    //! The port's parent.\r\n    SystemComponentItem* parent_;\r\n\r\n    //! The graphics scene.\r\n    QGraphicsScene* scene_;\r\n\r\n    //! Boolean flag for indicating if the port should be deleted in the destructor.\r\n    bool del_;\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n\r\n#endif // SWPORTDELETECOMMAND_H\r\n"
  },
  {
    "path": "editors/SystemDesign/UndoCommands/SystemAddCommands.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: SystemAddCommands.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Joni-Matti Maatta\r\n// Date: 13.10.2011\r\n//\r\n// Description:\r\n// Undo add commands for system designs.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"SystemAddCommands.h\"\r\n\r\n#include <common/graphicsItems/ComponentItem.h>\r\n\r\n#include <editors/common/DesignDiagram.h>\r\n#include <editors/SystemDesign/HWMappingItem.h>\r\n#include <editors/SystemDesign/SWComponentItem.h>\r\n#include <editors/SystemDesign/SystemColumn.h>\r\n#include <editors/SystemDesign/SystemComponentItem.h>\r\n#include <editors/SystemDesign/SWInterfaceItem.h>\r\n\r\n#include <IPXACTmodels/Design/ComponentInstance.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SWPortAddCommand()\r\n//-----------------------------------------------------------------------------\r\nSWPortAddCommand::SWPortAddCommand(SystemComponentItem* component, QPointF const& pos, DesignDiagram* diagram,\r\n    QUndoCommand* parent):\r\nQUndoCommand(parent),\r\ncomponent_(component),\r\npos_(pos),\r\nport_(0),\r\nscene_(component->scene()),\r\ndel_(false),\r\ndiagram_(diagram)\r\n{\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SWPortAddCommand()\r\n//-----------------------------------------------------------------------------\r\nSWPortAddCommand::SWPortAddCommand(SystemComponentItem* component, SWPortItem* port, DesignDiagram* diagram,\r\n    QUndoCommand* parent):\r\nQUndoCommand(parent),\r\ncomponent_(component),\r\npos_(),\r\nport_(port),\r\nscene_(component->scene()),\r\ndel_(false),\r\ndiagram_(diagram)\r\n{\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ~SWPortAddCommand()\r\n//-----------------------------------------------------------------------------\r\nSWPortAddCommand::~SWPortAddCommand()\r\n{\r\n    if (del_)\r\n    {\r\n        delete port_;\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: undo()\r\n//-----------------------------------------------------------------------------\r\nvoid SWPortAddCommand::undo()\r\n{\r\n    Q_ASSERT(port_ != 0);\r\n\r\n    // Remove the port from the component and from the scene\r\n    component_->removePort(port_);\r\n    scene_->removeItem(port_);\r\n    del_ = true;\r\n\r\n    // Execute child commands.\r\n    QUndoCommand::undo();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: redo()\r\n//-----------------------------------------------------------------------------\r\nvoid SWPortAddCommand::redo()\r\n{\r\n    // Add a port to the component.\r\n    if (port_ == 0)\r\n    {\r\n        port_ = component_->addPort(pos_);\r\n    }\r\n    else\r\n    {\r\n        component_->addPort(port_);\r\n    }\r\n\r\n    del_ = false;\r\n\r\n    // Child commands need not be executed because the other ports change their position\r\n    // in a deterministic way.\r\n    //QUndoCommand::redo();\r\n\r\n    diagram_->resetSceneRectangleForItems();\r\n}\r\n"
  },
  {
    "path": "editors/SystemDesign/UndoCommands/SystemAddCommands.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: SystemAddCommands.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Joni-Matti Maatta\r\n// Date: 13.10.2011\r\n//\r\n// Description:\r\n// Undo add commands for system designs.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef SYSTEMADDCOMMANDS_H\r\n#define SYSTEMADDCOMMANDS_H\r\n\r\n#include <QUndoCommand>\r\n#include <QGraphicsItem>\r\n#include <QGraphicsScene>\r\n#include <QObject>\r\n\r\nclass ComponentItem;\r\nclass IGraphicsItemStack;\r\nclass SystemComponentItem;\r\nclass SWPortItem;\r\nclass DesignDiagram;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! SWPortAddCommand class.\r\n//-----------------------------------------------------------------------------\r\nclass SWPortAddCommand : public QUndoCommand\r\n{\r\npublic:\r\n    /*!\r\n     *  Constructor.\r\n     *\r\n     *    @param [in] component   The component to which to add a port.\r\n     *    @param [in] pos         The position where to add the port.\r\n     *    @param [in] diagram     Diagram containing the scene of the component.\r\n     *    @param [in] parent      The parent command.\r\n     */\r\n    SWPortAddCommand(SystemComponentItem* component, QPointF const& pos, DesignDiagram* diagram,\r\n        QUndoCommand* parent = 0);\r\n\r\n    /*!\r\n     *  Constructor.\r\n     *\r\n     *    @param [in] component   The component to which to add a port.\r\n     *    @param [in] port        The port to add.\r\n     *    @param [in] diagram     Diagram containing the scene of the component.\r\n     *    @param [in] parent      The parent command.\r\n     */\r\n    SWPortAddCommand(SystemComponentItem* component, SWPortItem* port, DesignDiagram* diagram,\r\n        QUndoCommand* parent = 0);\r\n\r\n    /*!\r\n     *  Destructor.\r\n     */\r\n    ~SWPortAddCommand();\r\n\r\n    /*!\r\n     *  Undoes the command.\r\n     */\r\n    virtual void undo();\r\n\r\n    /*!\r\n     *  Redoes the command.\r\n     */\r\n    virtual void redo();\r\n\r\nprivate:\r\n    // Disable copying.\r\n    SWPortAddCommand(SWPortAddCommand const& rhs);\r\n    SWPortAddCommand& operator=(SWPortAddCommand const& rhs);\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! The parent component.\r\n    SystemComponentItem* component_;\r\n\r\n    //! The port position.\r\n    QPointF pos_;\r\n\r\n    //! The diagram port.\r\n    SWPortItem* port_;\r\n\r\n    //! The graphics scene.\r\n    QGraphicsScene* scene_;\r\n\r\n    //! Boolean flag for indicating if the port should be deleted in the destructor.\r\n    bool del_;\r\n\r\n    //! Diagram containing the scene of the component.\r\n    DesignDiagram* diagram_;\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n\r\n#endif // SYSTEMADDCOMMANDS_H\r\n"
  },
  {
    "path": "editors/SystemDesign/UndoCommands/SystemChangeCommands.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: SystemChangeCommands.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Joni-Matti Maatta\r\n// Date: 19.10.2011\r\n//\r\n// Description:\r\n// Undo change commands for system designs.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"SystemChangeCommands.h\"\r\n\r\n#include <common/graphicsItems/CommonGraphicsUndoCommands.h>\r\n#include <common/graphicsItems/ConnectionUndoCommands.h>\r\n#include <common/graphicsItems/ComponentItem.h>\r\n#include <common/graphicsItems/GraphicsConnection.h>\r\n\r\n#include <editors/common/Association/AssociationChangeEndpointCommand.h>\r\n\r\n#include <editors/SystemDesign/UndoCommands/SystemMoveCommands.h>\r\n#include <editors/SystemDesign/UndoCommands/SystemDeleteCommands.h>\r\n#include <editors/SystemDesign/UndoCommands/SystemComponentDeleteCommand.h>\r\n\r\n#include <editors/SystemDesign/SWConnectionEndpoint.h>\r\n#include <editors/SystemDesign/SystemComponentItem.h>\r\n#include <editors/SystemDesign/SWComponentItem.h>\r\n\r\n#include <IPXACTmodels/Design/Design.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: TypeDefinitionChangeCommand()\r\n//-----------------------------------------------------------------------------\r\nTypeDefinitionChangeCommand::TypeDefinitionChangeCommand(SWConnectionEndpoint* endpoint, VLNV const& oldType,\r\n                                                         QUndoCommand* parent):\r\nQUndoCommand(parent),\r\nendpoint_(endpoint),\r\noldType_(oldType),\r\nnewType_(endpoint->getTypeDefinition())\r\n{\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ~TypeDefinitionChangeCommand()\r\n//-----------------------------------------------------------------------------\r\nTypeDefinitionChangeCommand::~TypeDefinitionChangeCommand()\r\n{\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: undo()\r\n//-----------------------------------------------------------------------------\r\nvoid TypeDefinitionChangeCommand::undo()\r\n{\r\n    endpoint_->setTypeDefinition(oldType_);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: redo()\r\n//-----------------------------------------------------------------------------\r\nvoid TypeDefinitionChangeCommand::redo()\r\n{\r\n    endpoint_->setTypeDefinition(newType_);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PropertyValuesChangeCommand()\r\n//-----------------------------------------------------------------------------\r\nPropertyValuesChangeCommand::PropertyValuesChangeCommand(SystemComponentItem* component, \r\n                                                         QMap<QString, QString> const& newPropertyValues, \r\n                                                         QUndoCommand* parent):\r\nQUndoCommand(parent),\r\ncomponent_(component),\r\noldPropertyValues_(component->getPropertyValues()),\r\nnewPropertyValues_(newPropertyValues)\r\n{\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ~PropertyValuesChangeCommand()\r\n//-----------------------------------------------------------------------------\r\nPropertyValuesChangeCommand::~PropertyValuesChangeCommand()\r\n{\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: undo()\r\n//-----------------------------------------------------------------------------\r\nvoid PropertyValuesChangeCommand::undo()\r\n{\r\n    component_->setPropertyValues(oldPropertyValues_);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: redo()\r\n//-----------------------------------------------------------------------------\r\nvoid PropertyValuesChangeCommand::redo()\r\n{\r\n    component_->setPropertyValues(newPropertyValues_);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileSetRefChangeCommand()\r\n//-----------------------------------------------------------------------------\r\nFileSetRefChangeCommand::FileSetRefChangeCommand(SWComponentItem* component, QString const& newFileSetRef,\r\n                                                 QUndoCommand* parent):\r\nQUndoCommand(parent),\r\ncomponent_(component),\r\noldFileSetRef_(component->getFileSetRef()),\r\nnewFileSetRef_(newFileSetRef)\r\n{\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ~FileSetRefChangeCommand()\r\n//-----------------------------------------------------------------------------\r\nFileSetRefChangeCommand::~FileSetRefChangeCommand()\r\n{\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: undo()\r\n//-----------------------------------------------------------------------------\r\nvoid FileSetRefChangeCommand::undo()\r\n{\r\n    component_->setFileSetRef(oldFileSetRef_);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: redo()\r\n//-----------------------------------------------------------------------------\r\nvoid FileSetRefChangeCommand::redo()\r\n{\r\n    component_->setFileSetRef(newFileSetRef_);\r\n}\r\n"
  },
  {
    "path": "editors/SystemDesign/UndoCommands/SystemChangeCommands.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: SystemChangeCommands.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Joni-Matti Maatta\r\n// Date: 19.10.2011\r\n//\r\n// Description:\r\n// Undo change commands for system designs.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef SYSTEMCHANGECOMMANDS_H\r\n#define SYSTEMCHANGECOMMANDS_H\r\n\r\n#include <IPXACTmodels/common/VLNV.h>\r\n\r\n#include <QMap>\r\n#include <QUndoCommand>\r\n\r\nclass ComponentItem;\r\nclass SystemComponentItem;\r\nclass SWComponentItem;\r\nclass SWConnectionEndpoint;\r\n\r\nclass Design;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! TypeDefinitionChangeCommand class.\r\n//-----------------------------------------------------------------------------\r\nclass TypeDefinitionChangeCommand : public QUndoCommand\r\n{\r\npublic:\r\n    /*!\r\n     *  Constructor.\r\n     *\r\n     *    @param [in] endpoint          The SW connection end point.\r\n     *    @param [in] oldBusType        The endpoint's old API/COM type.\r\n     *    @param [in] parent            The parent command.\r\n     */\r\n    TypeDefinitionChangeCommand(SWConnectionEndpoint* endpoint, VLNV const& oldType, QUndoCommand* parent = 0);\r\n\r\n    /*!\r\n     *  Destructor.\r\n     */\r\n    ~TypeDefinitionChangeCommand();\r\n\r\n    /*!\r\n     *  Undoes the command.\r\n     */\r\n    virtual void undo();\r\n\r\n    /*!\r\n     *  Redoes the command.\r\n     */\r\n    virtual void redo();\r\n\r\nprivate:\r\n    // Disable copying.\r\n    TypeDefinitionChangeCommand(TypeDefinitionChangeCommand const& rhs);\r\n    TypeDefinitionChangeCommand& operator=(TypeDefinitionChangeCommand const& rhs);\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! The diagram connection endpoint.\r\n    SWConnectionEndpoint* endpoint_;\r\n\r\n    //! The endpoint's old COM/API type.\r\n    VLNV oldType_;\r\n\r\n    //! The endpoint's new COM/API type.\r\n    VLNV newType_;\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n//! PropertyValuesChangeCommand class.\r\n//-----------------------------------------------------------------------------\r\nclass PropertyValuesChangeCommand : public QUndoCommand\r\n{\r\npublic:\r\n\r\n\t/*!\r\n     *  Constructor.\r\n     *\r\n\t *    @param [in] component        Pointer to the component instance that is being edited.\r\n\t *    @param [in] newConfElements  The new property values for the instance.\r\n\t *    @param [in] parent           Pointer to the owner of this command.\r\n\t */\r\n\tPropertyValuesChangeCommand(SystemComponentItem* component, QMap<QString, QString> const& newPropertyValues, \r\n\t\t                        QUndoCommand* parent = 0);\r\n\r\n\t/*!\r\n     *  Destructor.\r\n     */\r\n\t~PropertyValuesChangeCommand();\r\n\r\n\t/*!\r\n     *  Undoes the command.\r\n     */\r\n    virtual void undo();\r\n\r\n    /*!\r\n     *  Redoes the command.\r\n     */\r\n    virtual void redo();\r\n\r\nprivate:\r\n\t// Disable copying.\r\n\tPropertyValuesChangeCommand(PropertyValuesChangeCommand const& rhs);\r\n\tPropertyValuesChangeCommand& operator=(PropertyValuesChangeCommand const& rhs);\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n\t//! Pointer to the component instance.\r\n\tSystemComponentItem* component_;\r\n\r\n\t//! The old property values.\r\n\tQMap<QString, QString> oldPropertyValues_;\r\n\r\n\t//! The new property values..\r\n\tQMap<QString, QString> newPropertyValues_;\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n//! FileSetRefChangeCommand class.\r\n//-----------------------------------------------------------------------------\r\nclass FileSetRefChangeCommand : public QUndoCommand\r\n{\r\npublic:\r\n\r\n\t/*!\r\n     *  Constructor.\r\n     *\r\n\t *    @param [in] component        Pointer to the component instance that is being edited.\r\n\t *    @param [in] newConfElements  The new file set reference for the instance.\r\n\t *    @param [in] parent           Pointer to the owner of this command.\r\n\t */\r\n\tFileSetRefChangeCommand(SWComponentItem* component, QString const& newFileSetRef, QUndoCommand* parent = 0);\r\n\r\n\t/*!\r\n     *  Destructor.\r\n     */\r\n\t~FileSetRefChangeCommand();\r\n\r\n\t/*!\r\n     *  Undoes the command.\r\n     */\r\n    virtual void undo();\r\n\r\n    /*!\r\n     *  Redoes the command.\r\n     */\r\n    virtual void redo();\r\n\r\nprivate:\r\n\t// Disable copying.\r\n\tFileSetRefChangeCommand(FileSetRefChangeCommand const& rhs);\r\n\tFileSetRefChangeCommand& operator=(FileSetRefChangeCommand const& rhs);\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n\t//! Pointer to the component instance.\r\n\tSWComponentItem* component_;\r\n\r\n\t//! The old file set reference.\r\n    QString oldFileSetRef_;\r\n\r\n    //! The new file set reference.\r\n    QString newFileSetRef_;\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n\r\n#endif // SYSTEMCHANGECOMMANDS_H\r\n"
  },
  {
    "path": "editors/SystemDesign/UndoCommands/SystemComponentAddCommand.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: SystemComponentAddCommand.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Mikko Teuho\r\n// Date: 22.02.2016\r\n//\r\n// Description:\r\n// Undo add command for component items in system designs.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"SystemComponentAddCommand.h\"\r\n\r\n#include <common/graphicsItems/ComponentItem.h>\r\n\r\n#include <editors/common/DesignDiagram.h>\r\n#include <editors/SystemDesign/HWMappingItem.h>\r\n#include <editors/SystemDesign/SWComponentItem.h>\r\n#include <editors/SystemDesign/SystemComponentItem.h>\r\n\r\n#include <IPXACTmodels/Design/Design.h>\r\n#include <IPXACTmodels/Design/ComponentInstance.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SystemComponentAddCommand::SystemComponentAddCommand()\r\n//-----------------------------------------------------------------------------\r\nSystemComponentAddCommand::SystemComponentAddCommand(IGraphicsItemStack* stack, QGraphicsItem* item,\r\n    DesignDiagram* diagram, QUndoCommand* parent):\r\nQUndoCommand(parent),\r\nitem_(item),\r\nstack_(stack),\r\ndel_(false),\r\nnewHwComponentId_(\"\"),\r\ncontainingDesign_(diagram->getDesign()),\r\ndiagram_(diagram)\r\n{\r\n    if (stack_)\r\n    {\r\n        HWMappingItem* hwItem = dynamic_cast<HWMappingItem*>(stack_);\r\n        if (hwItem && hwItem->getComponentInstance())\r\n        {\r\n            newHwComponentId_ = hwItem->getComponentInstance()->getUuid();\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SystemComponentAddCommand::~SystemComponentAddCommand()\r\n//-----------------------------------------------------------------------------\r\nSystemComponentAddCommand::~SystemComponentAddCommand()\r\n{\r\n    if (del_)\r\n    {\r\n        delete item_;\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SystemComponentAddCommand::undo()\r\n//-----------------------------------------------------------------------------\r\nvoid SystemComponentAddCommand::undo()\r\n{\r\n    stack_->removeItem(item_);\r\n    item_->scene()->removeItem(item_);\r\n    del_ = true;\r\n\r\n    if (dynamic_cast<ComponentItem*>(item_) != 0)\r\n    {\r\n        emit componentInstanceRemoved(static_cast<ComponentItem*>(item_));\r\n    }\r\n\r\n    SWComponentItem* swItem = dynamic_cast<SWComponentItem*>(item_);\r\n    if (swItem)\r\n    {\r\n        QSharedPointer<ComponentInstance> swInstance = swItem->getComponentInstance();\r\n        if (swInstance)\r\n        {\r\n            containingDesign_->getComponentInstances()->removeAll(swInstance);\r\n\r\n            if (!newHwComponentId_.isEmpty())\r\n            {\r\n                swInstance->setMapping(\"\");\r\n            }\r\n        }\r\n    }\r\n\r\n    QUndoCommand::undo();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SystemComponentAddCommand::redo()\r\n//-----------------------------------------------------------------------------\r\nvoid SystemComponentAddCommand::redo()\r\n{\r\n    // Add the item to the column.\r\n    stack_->addItem(item_);\r\n    del_ = false;\r\n\r\n    SWComponentItem* swItem = dynamic_cast<SWComponentItem*>(item_);\r\n    if (swItem)\r\n    {\r\n        QSharedPointer<ComponentInstance> swInstance = swItem->getComponentInstance();\r\n        if (swInstance)\r\n        {\r\n            containingDesign_->getComponentInstances()->append(swInstance);\r\n\r\n            if (!newHwComponentId_.isEmpty())\r\n            {\r\n                swInstance->setMapping(newHwComponentId_);\r\n            }\r\n        }\r\n    }\r\n    else\r\n    {\r\n        HWMappingItem* mappingItem = dynamic_cast<HWMappingItem*>(item_);\r\n        if (mappingItem && mappingItem->getComponentInstance())\r\n        {\r\n            containingDesign_->getComponentInstances()->append(mappingItem->getComponentInstance());\r\n        }\r\n    }\r\n\r\n    if (dynamic_cast<ComponentItem*>(item_) != 0)\r\n    {\r\n        emit componentInstantiated(static_cast<ComponentItem*>(item_));\r\n    }\r\n\r\n    // Child commands need not be executed because the other items change their position\r\n    // in a deterministic way.\r\n    //QUndoCommand::redo();\r\n\r\n    diagram_->resetSceneRectangleForItems();\r\n}\r\n"
  },
  {
    "path": "editors/SystemDesign/UndoCommands/SystemComponentAddCommand.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: SystemComponentAddCommand.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Mikko Teuho\r\n// Date: 22.02.2016\r\n//\r\n// Description:\r\n// Undo add command for component items in system designs.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef SYSTEMCOMPONENTADDCOMMAND_H\r\n#define SYSTEMCOMPONENTADDCOMMAND_H\r\n\r\n#include <QUndoCommand>\r\n#include <QGraphicsItem>\r\n#include <QGraphicsScene>\r\n#include <QObject>\r\n\r\nclass ComponentItem;\r\nclass IGraphicsItemStack;\r\nclass SystemComponentItem;\r\nclass Design;\r\nclass DesignDiagram;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Undo add command for component items in system designs.\r\n//-----------------------------------------------------------------------------\r\nclass SystemComponentAddCommand: public QObject, public QUndoCommand\r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n    /*!\r\n     *  Constructor.\r\n     *\r\n     *    @param [in] stack       The graphics item stack to which to add the item.\r\n     *    @param [in] item        The graphics item to add.\r\n     *    @param [in] diagram     Diagram containing the scene of the item.\r\n     *    @param [in] parent      The parent command.\r\n     */\r\n    SystemComponentAddCommand(IGraphicsItemStack* stack, QGraphicsItem* item, DesignDiagram* diagram,\r\n        QUndoCommand* parent = 0);\r\n\r\n    /*!\r\n     *  Destructor.\r\n     */\r\n    ~SystemComponentAddCommand();\r\n\r\n    /*!\r\n     *  Undoes the command.\r\n     */\r\n    virtual void undo();\r\n\r\n    /*!\r\n     *  Redoes the command.\r\n     */\r\n    virtual void redo();\r\n\r\nsignals:\r\n\r\n\t//! Signaled when the component is instantiated to the design.\r\n\tvoid componentInstantiated(ComponentItem* comp);\r\n\r\n\t//! Signaled when the component instance is removed from the design.\r\n\tvoid componentInstanceRemoved(ComponentItem* comp);\r\n\r\nprivate:\r\n    // Disable copying.\r\n    SystemComponentAddCommand(SystemComponentAddCommand const& rhs);\r\n    SystemComponentAddCommand& operator=(SystemComponentAddCommand const& rhs);\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! The graphics item.\r\n    QGraphicsItem* item_;\r\n\r\n    //! The item's parent component stack.\r\n    IGraphicsItemStack* stack_;\r\n\r\n    //! Boolean flag for indicating if the component should be deleted in the destructor.\r\n    bool del_;\r\n\r\n    //! The uuID of the containing HW component instance.\r\n    QString newHwComponentId_;\r\n\r\n    //! The design containing the system component item.\r\n    QSharedPointer<Design> containingDesign_;\r\n\r\n    //! Diagram containing the scene of the item.\r\n    DesignDiagram* diagram_;\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n\r\n#endif // SYSTEMCOMPONENTADDCOMMAND_H\r\n"
  },
  {
    "path": "editors/SystemDesign/UndoCommands/SystemComponentDeleteCommand.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: SystemComponentDeleteCommand.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Mikko Teuho\r\n// Date: 09.02.2016\r\n//\r\n// Description:\r\n// Delete command for component instances in system designs.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"SystemComponentDeleteCommand.h\"\r\n\r\n#include <common/graphicsItems/ComponentItem.h>\r\n#include <common/graphicsItems/GraphicsColumnLayout.h>\r\n#include <common/graphicsItems/GraphicsConnection.h>\r\n\r\n#include <editors/SystemDesign/SWPortItem.h>\r\n#include <editors/SystemDesign/UndoCommands/SystemDeleteCommands.h>\r\n#include <editors/SystemDesign/ApiGraphicsConnection.h>\r\n#include <editors/SystemDesign/UndoCommands/ApiConnectionDeleteCommand.h>\r\n#include <editors/SystemDesign/ComGraphicsConnection.h>\r\n#include <editors/SystemDesign/UndoCommands/ComConnectionDeleteCommand.h>\r\n\r\n#include <IPXACTmodels/Design/Design.h>\r\n#include <IPXACTmodels/Design/ComponentInstance.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SystemComponentDeleteCommand::SystemComponentDeleteCommand()\r\n//-----------------------------------------------------------------------------\r\nSystemComponentDeleteCommand::SystemComponentDeleteCommand(ComponentItem* item,\r\n    QSharedPointer<Design> containingDesign, QUndoCommand* parent /* = 0 */):\r\nQObject(),\r\nQUndoCommand(parent),\r\nitem_(item),\r\nstack_(dynamic_cast<IGraphicsItemStack*>(item->parentItem())),\r\nscene_(item->scene()),\r\ndel_(true),\r\nfirstRun_(true),\r\ncontainingDesign_(containingDesign)\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SystemComponentDeleteCommand::~SystemComponentDeleteCommand()\r\n//-----------------------------------------------------------------------------\r\nSystemComponentDeleteCommand::~SystemComponentDeleteCommand()\r\n{\r\n    if (del_)\r\n    {\r\n        delete item_;\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SystemComponentDeleteCommand::undo()\r\n//-----------------------------------------------------------------------------\r\nvoid SystemComponentDeleteCommand::undo()\r\n{\r\n    // Add the item back to the scene.\r\n    stack_->addItem(item_);\r\n    del_ = false;\r\n\r\n    containingDesign_->getComponentInstances()->append(item_->getComponentInstance());\r\n\r\n    emit componentInstantiated(item_);\r\n\r\n    // Execute child commands.\r\n    QUndoCommand::undo();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SystemComponentDeleteCommand::redo()\r\n//-----------------------------------------------------------------------------\r\nvoid SystemComponentDeleteCommand::redo()\r\n{\r\n    if (firstRun_)\r\n    {\r\n        // Create child commands for removing connections.\r\n        QList<GraphicsConnection*> connections;\r\n\r\n        foreach (QGraphicsItem* childItem, item_->childItems())\r\n        {\r\n            if (childItem->type() != SWPortItem::Type)\r\n            {\r\n                continue;\r\n            }\r\n\r\n            SWPortItem* endpoint = static_cast<SWPortItem*>(childItem);\r\n\r\n            foreach (GraphicsConnection* conn, endpoint->getConnections())\r\n            {\r\n                if (!connections.contains(conn))\r\n                {\r\n                    addConnectionDeleteCommand(conn);\r\n                    connections.append(conn);\r\n                }\r\n            }\r\n\r\n            if (endpoint->getOffPageConnector() != 0)\r\n            {\r\n                foreach (GraphicsConnection* conn, endpoint->getOffPageConnector()->getConnections())\r\n                {\r\n                    if (!connections.contains(conn))\r\n                    {\r\n                        addConnectionDeleteCommand(conn);\r\n                        connections.append(conn);\r\n                    }\r\n                }\r\n            }\r\n        }\r\n\r\n        firstRun_ = false;\r\n    }\r\n\r\n    // Execute child commands.\r\n    QUndoCommand::redo();\r\n\r\n    // Remove the item from the scene.\r\n    stack_->removeItem(item_);\r\n    scene_->removeItem(item_);\r\n    del_ = true;\r\n\r\n    containingDesign_->getComponentInstances()->removeAll(item_->getComponentInstance());\r\n\r\n\r\n    emit componentInstanceRemoved(item_);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SystemComponentDeleteCommand::addConnectionDeleteCommand()\r\n//-----------------------------------------------------------------------------\r\nvoid SystemComponentDeleteCommand::addConnectionDeleteCommand(GraphicsConnection* connection)\r\n{\r\n    ApiGraphicsConnection* apiConnection = dynamic_cast<ApiGraphicsConnection*>(connection);\r\n    if (apiConnection)\r\n    {\r\n        new ApiConnectionDeleteCommand(apiConnection, containingDesign_, this);\r\n    }\r\n    else\r\n    {\r\n        ComGraphicsConnection* comConnection = dynamic_cast<ComGraphicsConnection*>(connection);\r\n        if (comConnection)\r\n        {\r\n            new ComConnectionDeleteCommand(comConnection, containingDesign_, this);\r\n        }\r\n    }\r\n}\r\n"
  },
  {
    "path": "editors/SystemDesign/UndoCommands/SystemComponentDeleteCommand.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: SystemComponentDeleteCommand.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Mikko Teuho\r\n// Date: 09.02.2016\r\n//\r\n// Description:\r\n// Delete command for component instances in system designs.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef SYSTEMCOMPONENTDELETECOMMAND_H\r\n#define SYSTEMCOMPONENTDELETECOMMAND_H\r\n\r\n#include <QGraphicsScene>\r\n#include <QObject>\r\n#include <QSharedPointer>\r\n#include <QUndoCommand>\r\n\r\nclass ComponentItem;\r\nclass IGraphicsItemStack;\r\n\r\nclass Design;\r\nclass GraphicsConnection;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Delete command for component instances in system designs.\r\n//-----------------------------------------------------------------------------\r\nclass SystemComponentDeleteCommand : public QObject, public QUndoCommand\r\n{\r\n    Q_OBJECT\r\n\r\npublic:\r\n    /*!\r\n     *  The constructor.\r\n     *\r\n     *    @param [in] item                The component item to delete.\r\n     *    @param [in] containingDesign    The design containing the system component item.\r\n     *    @param [in] parent              The owner of this command.\r\n     */\r\n    SystemComponentDeleteCommand(ComponentItem* item, QSharedPointer<Design> containingDesign,\r\n        QUndoCommand* parent = 0);\r\n\r\n    /*!\r\n     *  The destructor.\r\n     */\r\n    ~SystemComponentDeleteCommand();\r\n\r\n    /*!\r\n     *  Undoes the command.\r\n     */\r\n    virtual void undo();\r\n\r\n    /*!\r\n     *  Redoes the command.\r\n     */\r\n    virtual void redo();\r\n\r\nsignals:\r\n\t//! Emitted when a new component is instantiated to the design.\r\n\tvoid componentInstantiated(ComponentItem* comp);\r\n\r\n\t//! Emitted when a component instance is removed from the design.\r\n\tvoid componentInstanceRemoved(ComponentItem* comp);\r\n\r\nprivate:\r\n    // Disable copying.\r\n    SystemComponentDeleteCommand(SystemComponentDeleteCommand const& rhs);\r\n    SystemComponentDeleteCommand& operator=(SystemComponentDeleteCommand const& rhs);\r\n\r\n    /*!\r\n     *  Add delete command for the contained interconnection.\r\n     *\r\n     *    @param [in] connection  The selected connection.\r\n     */\r\n    void addConnectionDeleteCommand(GraphicsConnection* connection);\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! The component item.\r\n    ComponentItem* item_;\r\n\r\n    //! The component's parent column.\r\n    IGraphicsItemStack* stack_;\r\n\r\n    //! The graphics scene.\r\n    QGraphicsScene* scene_;\r\n\r\n    //! Boolean flag for indicating if the component should be deleted in the destructor.\r\n    bool del_;\r\n\r\n    //! If true, the command has not been run previously.\r\n    bool firstRun_;\r\n\r\n    //! The design containing the system component item.\r\n    QSharedPointer<Design> containingDesign_;\r\n};\r\n\r\n#endif // SYSTEMCOMPONENTDELETECOMMAND_H\r\n"
  },
  {
    "path": "editors/SystemDesign/UndoCommands/SystemDeleteCommands.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: SystemDeleteCommands.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Joni-Matti Maatta\r\n// Date: 12.10.2011\r\n//\r\n// Description:\r\n// Undo delete commands for system designs.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"SystemDeleteCommands.h\"\r\n\r\n#include <common/graphicsItems/GraphicsColumnLayout.h>\r\n#include <common/graphicsItems/ComponentItem.h>\r\n\r\n#include <editors/common/DesignDiagram.h>\r\n#include <editors/SystemDesign/SystemColumn.h>\r\n#include <editors/SystemDesign/SystemComponentItem.h>\r\n#include <editors/SystemDesign/SWPortItem.h>\r\n#include <editors/SystemDesign/SWInterfaceItem.h>\r\n#include <editors/SystemDesign/SWComponentItem.h>\r\n#include <editors/SystemDesign/ComGraphicsConnection.h>\r\n#include <editors/SystemDesign/UndoCommands/ComConnectionDeleteCommand.h>\r\n#include <editors/SystemDesign/ApiGraphicsConnection.h>\r\n#include <editors/SystemDesign/UndoCommands/ApiConnectionDeleteCommand.h>\r\n#include <editors/SystemDesign/UndoCommands/SystemComponentDeleteCommand.h>\r\n\r\n#include <editors/common/Association/Association.h>\r\n#include <editors/common/Association/AssociationRemoveCommand.h>\r\n\r\n#include <IPXACTmodels/Design/Design.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SystemColumnDeleteCommand()\r\n//-----------------------------------------------------------------------------\r\nSystemColumnDeleteCommand::SystemColumnDeleteCommand(DesignDiagram* diagram, SystemColumn* column,\r\n    QUndoCommand* parent):\r\nQUndoCommand(parent),\r\nlayout_(diagram->getLayout().data()),\r\ngraphicalColumn_(column),\r\ncanDelete_(true),\r\ncontainingDesign_(diagram->getDesign()),\r\nremovedColumn_(getDeletedColumn())\r\n{\r\n    // Create child commands for removing connections.\r\n    QList<GraphicsConnection*> connections;\r\n\r\n    foreach (QGraphicsItem* item, column->childItems())\r\n    {\r\n        if (item->type() == SWComponentItem::Type)\r\n        {\r\n            SWComponentItem* systemComponentItem = static_cast<SWComponentItem*>(item);\r\n\r\n            foreach (QGraphicsItem* childItem, systemComponentItem->childItems())\r\n            {\r\n                if (childItem->type() != SWPortItem::Type)\r\n                {\r\n                    continue;\r\n                }\r\n\r\n                SWPortItem* port = static_cast<SWPortItem*>(childItem);\r\n\r\n                foreach (GraphicsConnection* graphicalConnection, port->getConnections())\r\n                {\r\n                    if (!connections.contains(graphicalConnection))\r\n                    {\r\n                        addConnectionDeleteCommand(graphicalConnection);\r\n                        connections.append(graphicalConnection);\r\n                    }\r\n                }\r\n\r\n                if (port->getOffPageConnector() != 0)\r\n                {\r\n                    foreach (GraphicsConnection* offPageConnection, port->getOffPageConnector()->getConnections())\r\n                    {\r\n                        if (!connections.contains(offPageConnection))\r\n                        {\r\n                            addConnectionDeleteCommand(offPageConnection);\r\n                            connections.append(offPageConnection);\r\n                        }\r\n                    }\r\n                }\r\n            }\r\n            foreach(Association* association, systemComponentItem->getAssociations())\r\n            {\r\n                new AssociationRemoveCommand(association, association->scene(), this);\r\n            }\r\n\r\n            new SystemComponentDeleteCommand(systemComponentItem, containingDesign_, this);\r\n\r\n        }\r\n        else if (item->type() == SWInterfaceItem::Type)\r\n        {\r\n            SWInterfaceItem* interface = static_cast<SWInterfaceItem*>(item);\r\n\r\n            foreach (GraphicsConnection* conn, interface->getConnections())\r\n            {\r\n                if (!connections.contains(conn))\r\n                {\r\n                    addConnectionDeleteCommand(conn);\r\n                    connections.append(conn);\r\n                }\r\n            }\r\n\r\n            if (interface->getOffPageConnector() != 0)\r\n            {\r\n                foreach (GraphicsConnection* conn, interface->getOffPageConnector()->getConnections())\r\n                {\r\n                    if (!connections.contains(conn))\r\n                    {\r\n                        addConnectionDeleteCommand(conn);\r\n                        connections.append(conn);\r\n                    }\r\n                }\r\n            }\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ~SystemColumnDeleteCommand()\r\n//-----------------------------------------------------------------------------\r\nSystemColumnDeleteCommand::~SystemColumnDeleteCommand()\r\n{\r\n    if (canDelete_)\r\n    {\r\n        delete graphicalColumn_;\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: undo()\r\n//-----------------------------------------------------------------------------\r\nvoid SystemColumnDeleteCommand::undo()\r\n{\r\n    // Add the item back to the layout.\r\n    layout_->addColumn(graphicalColumn_);\r\n    canDelete_ = false;\r\n\r\n    containingDesign_->addColumn(removedColumn_);\r\n\r\n    // Execute child commands.\r\n    QUndoCommand::undo();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: redo()\r\n//-----------------------------------------------------------------------------\r\nvoid SystemColumnDeleteCommand::redo()\r\n{\r\n    // Execute child commands.\r\n    QUndoCommand::redo();\r\n\r\n    // Remove the item from the layout.\r\n    layout_->removeColumn(graphicalColumn_);\r\n\r\n    if (removedColumn_)\r\n    {\r\n        containingDesign_->removeColumn(removedColumn_);\r\n    }\r\n\r\n    canDelete_ = true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SystemDeleteCommands::addConnectionDeleteCommand()\r\n//-----------------------------------------------------------------------------\r\nvoid SystemColumnDeleteCommand::addConnectionDeleteCommand(GraphicsConnection* connection)\r\n{\r\n    ApiGraphicsConnection* apiConnection = dynamic_cast<ApiGraphicsConnection*>(connection);\r\n    if (apiConnection)\r\n    {\r\n        new ApiConnectionDeleteCommand(apiConnection, containingDesign_, this);\r\n    }\r\n    else\r\n    {\r\n        ComGraphicsConnection* comConnection = dynamic_cast<ComGraphicsConnection*>(connection);\r\n        if (comConnection)\r\n        {\r\n            new ComConnectionDeleteCommand(comConnection, containingDesign_, this);\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SystemDeleteCommands::getDeletedColumn()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<ColumnDesc> SystemColumnDeleteCommand::getDeletedColumn()\r\n{\r\n    foreach (QSharedPointer<ColumnDesc> column, containingDesign_->getColumns())\r\n    {\r\n        if (column->name() == graphicalColumn_->name())\r\n        {\r\n            return column;\r\n        }\r\n    }\r\n\r\n    return QSharedPointer<ColumnDesc>();\r\n}\r\n"
  },
  {
    "path": "editors/SystemDesign/UndoCommands/SystemDeleteCommands.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: SystemDeleteCommands.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Joni-Matti Maatta\r\n// Date: 12.10.2011\r\n//\r\n// Description:\r\n// Undo delete commands for system designs.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef SYSTEMDELETECOMMANDS_H\r\n#define SYSTEMDELETECOMMANDS_H\r\n\r\n#include <QGraphicsScene>\r\n#include <QObject>\r\n#include <QSharedPointer>\r\n#include <QUndoCommand>\r\n\r\nclass GraphicsConnection;\r\nclass GraphicsColumnLayout;\r\nclass SystemColumn;\r\nclass Design;\r\nclass ColumnDesc;\r\nclass DesignDiagram;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! SystemColumnDeleteCommand class.\r\n//-----------------------------------------------------------------------------\r\nclass SystemColumnDeleteCommand : public QUndoCommand\r\n{\r\npublic:\r\n    /*!\r\n     *  Constructor.\r\n     *\r\n     *    @param [in] diagram     Diagram containing the scene of the column.\r\n     *    @param [in] column      The column to delete.\r\n     *    @param [in] parent      The owner of this command.\r\n     */\r\n    SystemColumnDeleteCommand(DesignDiagram* diagram, SystemColumn* column, QUndoCommand* parent = 0);\r\n\r\n    /*!\r\n     *  Destructor.\r\n     */\r\n    ~SystemColumnDeleteCommand();\r\n\r\n    /*!\r\n     *  Undoes the command.\r\n     */\r\n    virtual void undo();\r\n\r\n    /*!\r\n     *  Redoes the command.\r\n     */\r\n    virtual void redo();\r\n\r\nprivate:\r\n    // Disable copying.\r\n    SystemColumnDeleteCommand(SystemColumnDeleteCommand const& rhs);\r\n    SystemColumnDeleteCommand& operator=(SystemColumnDeleteCommand const& rhs);\r\n\r\n    /*!\r\n     *  Add delete command for the connection.\r\n     *\r\n     *    @param [in] connection  The selected connection.\r\n     */\r\n    void addConnectionDeleteCommand(GraphicsConnection* connection);\r\n\r\n    /*!\r\n     *  Get the removed column.\r\n     *\r\n     *    @return The removed column.\r\n     */\r\n    QSharedPointer<ColumnDesc> getDeletedColumn();\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! The column layout.\r\n    GraphicsColumnLayout* layout_;\r\n\r\n    //! The diagram column.\r\n    SystemColumn* graphicalColumn_;\r\n\r\n    //! Boolean flag for indicating if the column should be deleted in the destructor.\r\n    bool canDelete_;\r\n\r\n    //! The design containing the column.\r\n    QSharedPointer<Design> containingDesign_;\r\n\r\n    //! The removed column.\r\n    QSharedPointer<ColumnDesc> removedColumn_;\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n\r\n#endif // SYSTEMDELETECOMMANDS_H\r\n"
  },
  {
    "path": "editors/SystemDesign/UndoCommands/SystemMoveCommands.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: SystemMoveCommands.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Joni-Matti Maatta\r\n// Date: 17.10.2011\r\n//\r\n// Description:\r\n// Undo move commands for system designs.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"SystemMoveCommands.h\"\r\n\r\n#include <editors/common/DesignDiagram.h>\r\n#include <editors/SystemDesign/SystemComponentItem.h>\r\n\r\n#include <common/graphicsItems/GraphicsConnection.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SWConnectionMoveCommand()\r\n//-----------------------------------------------------------------------------\r\nSWConnectionMoveCommand::SWConnectionMoveCommand(GraphicsConnection* conn, QList<QPointF> const& oldRoute,\r\n                                                 QUndoCommand* parent):\r\nQUndoCommand(parent),\r\nconn_(conn),\r\noldRoute_(oldRoute),\r\nnewRoute_(conn->route())\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ~SWConnectionMoveCommand()\r\n//-----------------------------------------------------------------------------\r\nSWConnectionMoveCommand::~SWConnectionMoveCommand()\r\n{\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: undo()\r\n//-----------------------------------------------------------------------------\r\nvoid SWConnectionMoveCommand::undo()\r\n{\r\n    conn_->setRoute(oldRoute_);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: redo()\r\n//-----------------------------------------------------------------------------\r\nvoid SWConnectionMoveCommand::redo()\r\n{\r\n    conn_->setRoute(newRoute_);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ItemMoveCommand()\r\n//-----------------------------------------------------------------------------\r\nSWPortMoveCommand::SWPortMoveCommand(SWPortItem* port, QPointF const& oldPos, DesignDiagram* diagram,\r\n    QUndoCommand* parent):\r\nQUndoCommand(parent),\r\nport_(port),\r\noldPos_(oldPos),\r\nnewPos_(port->pos()),\r\ndiagram_(diagram)\r\n{\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SWPortMoveCommand::SWPortMoveCommand()\r\n//-----------------------------------------------------------------------------\r\nSWPortMoveCommand::SWPortMoveCommand(SWPortItem* port, QPointF const& oldPos, QPointF const& newPos,\r\n    DesignDiagram* diagram, QUndoCommand* parent):\r\nQUndoCommand(parent),\r\nport_(port),\r\noldPos_(oldPos),\r\nnewPos_(newPos),\r\ndiagram_(diagram)\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ~SWPortMoveCommand()\r\n//-----------------------------------------------------------------------------\r\nSWPortMoveCommand::~SWPortMoveCommand()\r\n{\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: undo()\r\n//-----------------------------------------------------------------------------\r\nvoid SWPortMoveCommand::undo()\r\n{\r\n    SystemComponentItem* comp = static_cast<SystemComponentItem*>(port_->parentItem());\r\n\r\n    port_->setPos(oldPos_);\r\n    comp->onMovePort(port_);\r\n\r\n    // Execute child commands.\r\n    QUndoCommand::undo();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: redo()\r\n//-----------------------------------------------------------------------------\r\nvoid SWPortMoveCommand::redo()\r\n{\r\n    SystemComponentItem* comp = static_cast<SystemComponentItem*>(port_->parentItem());\r\n\r\n    port_->setPos(newPos_);\r\n    comp->onMovePort(port_);\r\n\r\n    // Execute child commands.\r\n    QUndoCommand::redo();\r\n\r\n    diagram_->resetSceneRectangleForItems();\r\n}"
  },
  {
    "path": "editors/SystemDesign/UndoCommands/SystemMoveCommands.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: SystemMoveCommands.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Joni-Matti Maatta\r\n// Date: 17.10.2011\r\n//\r\n// Description:\r\n// Undo move commands for system designs.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef SYSTEMMOVECOMMANDS_H\r\n#define SYSTEMMOVECOMMANDS_H\r\n\r\n#include <QUndoCommand>\r\n#include <QGraphicsScene>\r\n#include <QString>\r\n\r\nclass SWPortItem;\r\nclass GraphicsConnection;\r\nclass DesignDiagram;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! SWConnectionMoveCommand class.\r\n//-----------------------------------------------------------------------------\r\nclass SWConnectionMoveCommand : public QUndoCommand\r\n{\r\npublic:\r\n    /*!\r\n     *  Constructor.\r\n     *\r\n     *    @param [in] conn      The SW connection.\r\n     *    @param [in] oldRoute  The old route of the connection.\r\n     *    @param [in] parent    The parent command.\r\n     */\r\n    SWConnectionMoveCommand(GraphicsConnection* conn, QList<QPointF> const& oldRoute, QUndoCommand* parent = 0);\r\n\r\n    /*!\r\n     *  Destructor.\r\n     */\r\n    ~SWConnectionMoveCommand();\r\n\r\n    /*!\r\n     *  Undoes the command.\r\n     */\r\n    virtual void undo();\r\n\r\n    /*!\r\n     *  Redoes the command.\r\n     */\r\n    virtual void redo();\r\n\r\nprivate:\r\n    // Disable copying.\r\n    SWConnectionMoveCommand(SWConnectionMoveCommand const& rhs);\r\n    SWConnectionMoveCommand& operator=(SWConnectionMoveCommand const& rhs);\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! The SW connection.\r\n    GraphicsConnection* conn_;\r\n\r\n    //! The old route of the connection.\r\n    QList<QPointF> oldRoute_;\r\n\r\n    //! The new route of the connection.\r\n    QList<QPointF> newRoute_;\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n//! SWPortMoveCommand class.\r\n//-----------------------------------------------------------------------------\r\nclass SWPortMoveCommand : public QUndoCommand\r\n{\r\npublic:\r\n    /*!\r\n     *  Constructor.\r\n     *\r\n     *    @param [in] port        The port to move.\r\n     *    @param [in] oldPos      The port's old position.\r\n     *    @param [in] diagram     Diagram containing the scene of the port.\r\n     *    @param [in] parent      The parent command.\r\n     */\r\n    SWPortMoveCommand(SWPortItem* port, QPointF const& oldPos, DesignDiagram* diagram, QUndoCommand* parent = 0);\r\n\r\n    /*!\r\n     *  Constructor.\r\n     *\r\n     *    @param [in] port        The port to move.\r\n     *    @param [in] oldPos      The port's old position.\r\n     *    @param [in] newPos      The port's new position.\r\n     *    @param [in] diagram     Diagram containing the scene of the port.\r\n     *    @param [in] parent      The parent command.\r\n     */\r\n    SWPortMoveCommand(SWPortItem* port, QPointF const& oldPos, QPointF const& newPos, DesignDiagram* diagram,\r\n        QUndoCommand* parent = 0);\r\n\r\n    /*!\r\n     *  Destructor.\r\n     */\r\n    ~SWPortMoveCommand();\r\n\r\n    /*!\r\n     *  Undoes the command.\r\n     */\r\n    virtual void undo();\r\n\r\n    /*!\r\n     *  Redoes the command.\r\n     */\r\n    virtual void redo();\r\n\r\nprivate:\r\n    // Disable copying.\r\n    SWPortMoveCommand(SWPortMoveCommand const& rhs);\r\n    SWPortMoveCommand& operator=(SWPortMoveCommand const& rhs);\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! The port item.\r\n    SWPortItem* port_;\r\n\r\n    //! The old position of the port.\r\n    QPointF oldPos_;\r\n\r\n    //! The new position of the port.\r\n    QPointF newPos_;\r\n\r\n    //! Diagram containing the scene of the port.\r\n    DesignDiagram* diagram_;\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n\r\n#endif // SYSTEMMOVECOMMANDS_H\r\n"
  },
  {
    "path": "editors/common/Association/Associable.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: Associable.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Esko Pekkarinen\n// Date: 10.6.2014\n//\n// Description:\n// Interface for items that can be associated with others.\n//-----------------------------------------------------------------------------\n\n#include \"Associable.h\"\n#include \"Association.h\"\n\n//-----------------------------------------------------------------------------\n// Function: Associable::Associable()\n//-----------------------------------------------------------------------------\nAssociable::Associable():\n    associations_()\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: Associable::~Associable()\n//-----------------------------------------------------------------------------\nAssociable::~Associable()\n{\n    /*foreach(Association* association, associations_)\n    {\n        association->disconnect();\n    }*/\n}\n\n//-----------------------------------------------------------------------------\n// Function: Associable::addAssociation()\n//-----------------------------------------------------------------------------\nvoid Associable::addAssociation(Association* association)\n{\n    if (!associations_.contains(association))\n    {\n        associations_.append(association);\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: Associable::getAssociations()\n//-----------------------------------------------------------------------------\nQList<Association*> Associable::getAssociations() const\n{\n    return associations_;\n}\n\n//-----------------------------------------------------------------------------\n// Function: Associable::positionUpdated()\n//-----------------------------------------------------------------------------\nvoid Associable::positionUpdated()\n{\n    for (auto association : associations_)\n    {\n        association->updateLine();\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: Associable::removeAssociation()\n//-----------------------------------------------------------------------------\nvoid Associable::removeAssociation(Association* association)\n{\n    associations_.removeAll(association);\n}\n"
  },
  {
    "path": "editors/common/Association/Associable.h",
    "content": "//-----------------------------------------------------------------------------\n// File: Associable.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Esko Pekkarinen\n// Date: 10.6.2014\n//\n// Description:\n// Interface for items that can be associated with others.\n//-----------------------------------------------------------------------------\n\n#ifndef ASSOCIABLE_H\n#define ASSOCIABLE_H\n\n#include <QList>\n#include <QPointF>\n\n class Association;\n//-----------------------------------------------------------------------------\n//! Associable class.\n//-----------------------------------------------------------------------------\nclass Associable\n{\npublic:\n\n    //! The constructor.\n    Associable();\n\n    //! The destructor.\n    virtual ~Associable();\n\n    /*!\n     *  Adds a new association to the item.\n     *\n     *    @param [in] association   The association to add.     \n     */\n    virtual void addAssociation(Association* association);\n   \n    /*!\n     *  Removes an association from the item.\n     *\n     *    @param [in] association   The association to remove.     \n     */\n    virtual void removeAssociation(Association* association);\n\n    /*!\n     *  Gets the item associations.\n     *\n     *    @return The associations of the item.\n     */\n    QList<Association*> getAssociations() const;\n\n    /*!\n     *  Defines the connection point for associations in scene coordinates.\n     *     \n     *    @param [in] otherEnd   The position of the other end connection point.\n     *\n     *    @return The connection point of the item.\n     */\n    virtual QPointF connectionPoint(QPointF const& otherEnd = QPointF()) const = 0;\n\nprotected:\n\n    //! Called when the associable item position is changed to update all association lines.\n    virtual void positionUpdated();\n\nprivate:\n\n    //! The associations of the item.\n   QList<Association*> associations_;\n\n};\n\n#endif // ASSOCIABLE_H"
  },
  {
    "path": "editors/common/Association/Association.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: Association.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Esko Pekkarinen\n// Date: 10.6.2014\n//\n// Description:\n// Defines an association between to items in a design.\n//-----------------------------------------------------------------------------\n\n#include \"Association.h\"\n\n#include <IPXACTmodels/kactusExtensions/Kactus2Position.h>\n\n#include <QPen>\n\n//-----------------------------------------------------------------------------\n// Function: QGraphicsLineItem::Association()\n//-----------------------------------------------------------------------------\nAssociation::Association(Associable* startItem, Associable* endItem, \n    QSharedPointer<Kactus2Position> endpointExtension, QGraphicsItem* parent):\n    QGraphicsLineItem(parent),\n    startItem_(startItem),\n    endItem_(endItem),\n    endpointPosition_(endpointExtension)\n{        \n    setFlag(ItemIsSelectable);\n    setPen(QPen(Qt::black, 1, Qt::DashLine));\n\n    setZValue(-1.0);\n\n    updateLine();\n}\n\n//-----------------------------------------------------------------------------\n// Function: QGraphicsLineItem::~Association()\n//-----------------------------------------------------------------------------\nAssociation::~Association()\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: Association::paint()\n//-----------------------------------------------------------------------------\nvoid Association::paint(QPainter* painter, QStyleOptionGraphicsItem const*, QWidget*)\n{\n    if (isSelected()) \n    {\n        painter->setPen(QPen(Qt::blue, 2, Qt::SolidLine));\n    } \n    else\n    {\n        painter->setPen(pen());\n    }\n\n    //updateLine();\n    painter->drawLine(line());\n}\n\n//-----------------------------------------------------------------------------\n// Function: Association::connect()\n//-----------------------------------------------------------------------------\nvoid Association::connect()\n{\n    startItem_->addAssociation(this);\n    endItem_->addAssociation(this);\n}\n\n//-----------------------------------------------------------------------------\n// Function: Association::disconnect()\n//-----------------------------------------------------------------------------\nvoid Association::disconnect()\n{\n    startItem_->removeAssociation(this);\n    endItem_->removeAssociation(this);\n}\n\n//-----------------------------------------------------------------------------\n// Function: Association::setEndItem()\n//-----------------------------------------------------------------------------\nvoid Association::setEndItem(Associable* endItem)\n{\n    endItem_->removeAssociation(this);\n\n    endItem_ = endItem;\n\n    endItem_->addAssociation(this);\n}\n\n//-----------------------------------------------------------------------------\n// Function: Association::getEndpointExtension()\n//-----------------------------------------------------------------------------\nQSharedPointer<Kactus2Position> Association::getEndpointExtension() const\n{\n    return endpointPosition_;\n}\n\n//-----------------------------------------------------------------------------\n// Function: Association::updateLine()\n//-----------------------------------------------------------------------------\nvoid Association::updateLine()\n{\n    QPointF startPoint = startItem_->connectionPoint();\n    QPointF endPoint = endItem_->connectionPoint(startPoint);\n    QLineF centerLine(startPoint, endPoint);\n       \n    prepareGeometryChange();\n    setLine(centerLine);    \n\n    endpointPosition_->setPosition(endPoint);\n}\n"
  },
  {
    "path": "editors/common/Association/Association.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: Association.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Esko Pekkarinen\r\n// Date: 10.6.2014\r\n//\r\n// Description:\r\n// Defines an association between to items in a design.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef ASSOCIATION_H\r\n#define ASSOCIATION_H\r\n\r\n#include <QGraphicsLineItem>\r\n\r\n#include \"Associable.h\"\r\n\r\n#include <common/graphicsItems/GraphicsItemTypes.h>\r\n\r\n#include <QGraphicsItem>\r\n#include <QRectF>\r\n#include <QSharedPointer>\r\n#include <QPainter>\r\n#include <QStyleOption>\r\n#include <QWidget>\r\n\r\nclass Kactus2Position;\r\n//-----------------------------------------------------------------------------\r\n// class Association.\r\n//-----------------------------------------------------------------------------\r\nclass Association: public QGraphicsLineItem\r\n{\r\npublic:\r\n\r\n    enum { Type = GFX_TYPE_DIAGRAM_ASSOCIATION };\r\n\r\n\t/*!\r\n\t *  The constructor.\r\n\t *\r\n\t *    @param [in] startItem   The item at the starting end of the association.\r\n\t *    @param [in] endItem     The item at the end of the association.\r\n\t *    @param [in] parent      The parent item.\r\n\t */\r\n\tAssociation(Associable* startItem, Associable* endItem, QSharedPointer<Kactus2Position> endpointExtension, \r\n        QGraphicsItem* parent = 0);\r\n\r\n\t/*!\r\n\t *  The destructor.\r\n\t*/\r\n\tvirtual ~Association();\r\n\r\n    /*!\r\n     *  Draws the item.\r\n     *\r\n     *    @param [in] painter     The painter to use.\r\n     *    @param [in] option      Painting style options.\r\n     *    @param [in] widget      The widget to paint on.\r\n     */\r\n    void paint(QPainter* painter,  QStyleOptionGraphicsItem const* option, QWidget* widget);\r\n\r\n    //! Identifies the type of the item.\r\n    virtual int type() const { return Type; }\r\n\r\n    //! Connects the association to both ends.  \r\n    void connect();\r\n\r\n    //! Disconnects the association from both ends.     \r\n    void disconnect();\r\n\r\n    //! Updates the line according to end item connection points.\r\n    void updateLine();\r\n\r\n    /*!\r\n     *  Changes the item at the end of the association.\r\n     *\r\n     *    @param [in] endItem   The item to set as the new end item.\r\n     */\r\n    void setEndItem(Associable* endItem);\r\n\r\n    /*!\r\n     *  Gets the vendor extension representing the endpoint position.\r\n     *\r\n     *    @return The endpoint vendor extension.\r\n     */\r\n    QSharedPointer<Kactus2Position> getEndpointExtension() const;\r\n\r\nprivate:\r\n\t// Disable copying.\r\n\tAssociation(Association const& rhs);\r\n\r\n\t// Disable assignment.\r\n\tAssociation& operator=(Association const& rhs);\r\n\r\n\t//-----------------------------------------------------------------------------\r\n\t// Data.\r\n\t//-----------------------------------------------------------------------------\r\n\r\n    //! The item at the starting point of the association.\r\n    Associable* startItem_;\r\n\r\n    //! The item at the ending point of the association.\r\n    Associable* endItem_;\r\n    \r\n    //! Vendor extension for tracking the endpoint position.\r\n    QSharedPointer<Kactus2Position> endpointPosition_;\r\n};\r\n#endif // ASSOCIATION_H\r\n\r\n"
  },
  {
    "path": "editors/common/Association/AssociationAddCommand.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: AssociationAddCommand.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Esko Pekkarinen\r\n// Date: 16.06.2014\r\n//\r\n// Description:\r\n// Add command for association items.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"AssociationAddCommand.h\"\r\n\r\n#include <editors/common/Association/Association.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AssociationAddCommand::AssociationAddCommand()\r\n//-----------------------------------------------------------------------------\r\nAssociationAddCommand::AssociationAddCommand(Association* association, QGraphicsScene* scene, \r\n    QUndoCommand* parent): \r\nQUndoCommand(parent),\r\n    association_(association),\r\n    scene_(scene), \r\n    del_(false)\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AssociationAddCommand::~AssociationAddCommand()\r\n//-----------------------------------------------------------------------------\r\nAssociationAddCommand::~AssociationAddCommand()\r\n{\r\n    if (del_)\r\n    {\r\n        delete association_;\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AssociationAddCommand::undo()\r\n//-----------------------------------------------------------------------------\r\nvoid AssociationAddCommand::undo()\r\n{\r\n    scene_->removeItem(association_);\r\n    del_ = true;\r\n\r\n    association_->disconnect();\r\n\r\n    // Execute child commands.\r\n    QUndoCommand::undo();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AssociationAddCommandredo()\r\n//-----------------------------------------------------------------------------\r\nvoid AssociationAddCommand::redo()\r\n{\r\n    scene_->addItem(association_);\r\n    del_ = false;\r\n\r\n    association_->connect();\r\n\r\n    QUndoCommand::redo();\r\n}\r\n"
  },
  {
    "path": "editors/common/Association/AssociationAddCommand.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: AssociationAddCommand.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Esko Pekkarinen\r\n// Date: 16.06.2014\r\n//\r\n// Description:\r\n// Add command for association items.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef ASSOCIATIONADDCOMMAND_H\r\n#define ASSOCIATIONADDCOMMAND_H\r\n\r\n#include <QUndoCommand>\r\n#include <QGraphicsScene>\r\n#include <QObject>\r\n\r\nclass Association;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! FloatingItemRemoveCommand class.\r\n//-----------------------------------------------------------------------------\r\nclass AssociationAddCommand : public QUndoCommand\r\n{\r\npublic:\r\n    /*!\r\n     *  Constructor.\r\n     *\r\n     *    @param [in] association     The association to add.\r\n     *    @param [in] scene           The scene to add the association to.\r\n     *    @param [in] parent          The parent command.\r\n     */\r\n    AssociationAddCommand(Association* association, QGraphicsScene* scene, QUndoCommand* parent = 0);\r\n\r\n    /*!\r\n     *  Destructor.\r\n     */\r\n    ~AssociationAddCommand();\r\n\r\n    /*!\r\n     *  Undoes the command.\r\n     */\r\n    virtual void undo();\r\n\r\n    /*!\r\n     *  Redoes the command.\r\n     */\r\n    virtual void redo();\r\n\r\nprivate:\r\n    // Disable copying.\r\n    AssociationAddCommand(AssociationAddCommand const& rhs);\r\n    AssociationAddCommand& operator=(AssociationAddCommand const& rhs);\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! The graphics item.\r\n    Association* association_;\r\n\r\n    //! The item's parent scene.\r\n    QGraphicsScene* scene_;\r\n\r\n    //! Boolean flag for indicating if the items should be deleted in the destructor.\r\n    bool del_;\r\n\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n#endif // ASSOCIATIONADDCOMMAND_H"
  },
  {
    "path": "editors/common/Association/AssociationChangeEndpointCommand.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: AssociationChangeEndpointCommand.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Esko Pekkarinen\r\n// Date: 16.06.2014\r\n//\r\n// Description:\r\n// Command for changing the ending item of an association item.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"AssociationChangeEndpointCommand.h\"\r\n\r\n#include <editors/common/Association/Associable.h>\r\n#include <editors/common/Association/Association.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AssociationChangeEndpointCommand()\r\n//-----------------------------------------------------------------------------\r\nAssociationChangeEndpointCommand::AssociationChangeEndpointCommand(Association* association, Associable* oldEndpoint, \r\n    Associable* newEndpoint, QUndoCommand* parent) : \r\n    QUndoCommand(parent), \r\n    association_(association),\r\n    oldEndpoint_(oldEndpoint),\r\n    newEndpoint_(newEndpoint)\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ~AssociationChangeEndpointCommand()\r\n//-----------------------------------------------------------------------------\r\nAssociationChangeEndpointCommand::~AssociationChangeEndpointCommand()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: undo()\r\n//-----------------------------------------------------------------------------\r\nvoid AssociationChangeEndpointCommand::undo()\r\n{\r\n    association_->setEndItem(oldEndpoint_);\r\n\r\n    // Execute child commands.\r\n    QUndoCommand::undo();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: redo()\r\n//-----------------------------------------------------------------------------\r\nvoid AssociationChangeEndpointCommand::redo()\r\n{\r\n    association_->setEndItem(newEndpoint_);\r\n\r\n    // Execute child commands.\r\n    QUndoCommand::redo();\r\n}\r\n"
  },
  {
    "path": "editors/common/Association/AssociationChangeEndpointCommand.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: AssociationChangeEndpointCommand.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Esko Pekkarinen\r\n// Date: 16.06.2014\r\n//\r\n// Description:\r\n// Command for changing the ending item of an association item.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef ASSOCIATIONCHANGEENDPOINTCOMMAND_H\r\n#define ASSOCIATIONCHANGEENDPOINTCOMMAND_H\r\n\r\n#include <QUndoCommand>\r\n#include <QGraphicsScene>\r\n\r\nclass Associable;\r\nclass Association;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! FloatingItemRemoveCommand class.\r\n//-----------------------------------------------------------------------------\r\nclass AssociationChangeEndpointCommand : public QUndoCommand\r\n{\r\npublic:\r\n\r\n    /*!\r\n     *  Constructor.\r\n     *\r\n     *    @param [in] association     The association whose end point to change.\r\n     *    @param [in] oldEndpoint     The previous end point item.\r\n     *    @param [in] newEndpoint     The end point item to set.\r\n     *    @param [in] parent          The parent command.\r\n     */\r\n    AssociationChangeEndpointCommand(Association* association, Associable* oldEndpoint, \r\n        Associable* newEndpoint, QUndoCommand* parent = 0);\r\n\r\n    /*!\r\n     *  Destructor.\r\n     */\r\n    ~AssociationChangeEndpointCommand();\r\n\r\n    /*!\r\n     *  Undoes the command.\r\n     */\r\n    virtual void undo();\r\n\r\n    /*!\r\n     *  Redoes the command.\r\n     */\r\n    virtual void redo();\r\n\r\nprivate:\r\n    // Disable copying.\r\n    AssociationChangeEndpointCommand(AssociationChangeEndpointCommand const& rhs);\r\n    AssociationChangeEndpointCommand& operator=(AssociationChangeEndpointCommand const& rhs);\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! The graphics item.\r\n    Association* association_;\r\n\r\n    //! The previous ending point item.\r\n    Associable* oldEndpoint_;\r\n\r\n    //! The new ending point item.\r\n    Associable* newEndpoint_;\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n#endif // ASSOCIATIONCHANGEENDPOINTCOMMAND_H"
  },
  {
    "path": "editors/common/Association/AssociationRemoveCommand.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: FloatingItemRemoveCommand.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Esko Pekkarinen\r\n// Date: 16.06.2014\r\n//\r\n// Description:\r\n// Remove command for association items.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"AssociationRemoveCommand.h\"\r\n\r\n#include <editors/common/Association/Association.h>\r\n\r\n#include <QGraphicsScene>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AssociationRemoveCommand()\r\n//-----------------------------------------------------------------------------\r\nAssociationRemoveCommand::AssociationRemoveCommand(Association* association, QGraphicsScene* diagram, \r\n    QUndoCommand* parent) : \r\n    QUndoCommand(parent), association_(association),\r\n    scene_(diagram), \r\n    del_(true)\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ~AssociationRemoveCommand()\r\n//-----------------------------------------------------------------------------\r\nAssociationRemoveCommand::~AssociationRemoveCommand()\r\n{\r\n    if (del_)\r\n    {\r\n        delete association_;\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: undo()\r\n//-----------------------------------------------------------------------------\r\nvoid AssociationRemoveCommand::undo()\r\n{\r\n    scene_->addItem(association_);\r\n    del_ = false;\r\n\r\n    association_->connect();\r\n\r\n    // Execute child commands.\r\n    QUndoCommand::undo();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: redo()\r\n//-----------------------------------------------------------------------------\r\nvoid AssociationRemoveCommand::redo()\r\n{\r\n    scene_->removeItem(association_);\r\n    del_ = true;\r\n\r\n    association_->disconnect();\r\n\r\n    QUndoCommand::redo();\r\n}\r\n"
  },
  {
    "path": "editors/common/Association/AssociationRemoveCommand.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: AssociationRemoveCommand.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Esko Pekkarinen\r\n// Date: 16.06.2014\r\n//\r\n// Description:\r\n// Remove command for association items.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef ASSOCIATIONREMOVECOMMAND_H\r\n#define ASSOCIATIONREMOVECOMMAND_H\r\n\r\n#include <QUndoCommand>\r\n#include <QGraphicsScene>\r\n#include <QObject>\r\n\r\nclass Association;\r\nclass DesignDiagram;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! AssociationRemoveCommand class.\r\n//-----------------------------------------------------------------------------\r\nclass AssociationRemoveCommand : public QUndoCommand\r\n{\r\npublic:\r\n    /*!\r\n     *  Constructor.\r\n     *\r\n     *    @param [in] association     The association to remove.\r\n     *    @param [in] scene           The scene from which to remove the association from.\r\n     *    @param [in] parent          The parent command.\r\n     */\r\n    AssociationRemoveCommand(Association* association, QGraphicsScene* scene, QUndoCommand* parent = 0);\r\n\r\n    /*!\r\n     *  Destructor.\r\n     */\r\n    ~AssociationRemoveCommand();\r\n\r\n    /*!\r\n     *  Undoes the command.\r\n     */\r\n    virtual void undo();\r\n\r\n    /*!\r\n     *  Redoes the command.\r\n     */\r\n    virtual void redo();\r\n\r\nprivate:\r\n    // Disable copying.\r\n    AssociationRemoveCommand(AssociationRemoveCommand const& rhs);\r\n    AssociationRemoveCommand& operator=(AssociationRemoveCommand const& rhs);\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! The graphics item.\r\n    Association* association_;\r\n\r\n    //! The item's parent scene.\r\n    QGraphicsScene* scene_;\r\n\r\n    //! Boolean flag for indicating if the items should be deleted in the destructor.\r\n    bool del_;\r\n\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n#endif // ASSOCIATIONREMOVECOMMAND_H"
  },
  {
    "path": "editors/common/ColumnTypes.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ColumnTypes.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Joni-Matti Maatta\r\n// Date: 20.4.2011\r\n//\r\n// Description:\r\n// Common enumerations and other types for the column layout.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef COLUMNTYPES_H\r\n#define COLUMNTYPES_H\r\n\r\nnamespace ColumnTypes\r\n{\r\n    //-----------------------------------------------------------------------------\r\n    //! ColumnContentType enumeration.\r\n    //-----------------------------------------------------------------------------\r\n    enum ColumnContentType\r\n    {\r\n        IO = 0,\r\n        BUSES,\r\n        COMPONENTS,\r\n        MEMORY,\r\n        CUSTOM\r\n    };\r\n\r\n    //-----------------------------------------------------------------------------\r\n    //! ColumnItemType enumeration.\r\n    //-----------------------------------------------------------------------------\r\n    enum ColumnItemType\r\n    {\r\n        NONE = 0,\r\n        INTERFACE = 0x01,\r\n        COMPONENT = 0x02,\r\n        CHANNEL = 0x04,\r\n        BRIDGE = 0x08,\r\n\r\n        TYPE_COUNT = 4\r\n    };\r\n}\r\n\r\n#endif // COLUMNTYPES_H"
  },
  {
    "path": "editors/common/ComponentDesignDiagram.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ComponentDesignDiagram.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Esko Pekkarinen\r\n// Date: 23.6.2014\r\n//\r\n// Description:\r\n// Base class for all component designs.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"ComponentDesignDiagram.h\"\r\n\r\n#include <common/GenericEditProvider.h>\r\n\r\n#include <common/graphicsItems/ComponentItem.h>\r\n#include <common/graphicsItems/ConnectionEndpoint.h>\r\n#include <common/graphicsItems/ConnectionUndoCommands.h>\r\n#include <common/graphicsItems/CommonGraphicsUndoCommands.h>\r\n#include <common/graphicsItems/GraphicsColumn.h>\r\n#include <common/graphicsItems/GraphicsColumnLayout.h>\r\n#include <common/graphicsItems/GraphicsConnection.h>\r\n\r\n#include <editors/common/DiagramUtil.h>\r\n#include <editors/common/DesignWidget.h>\r\n#include <editors/common/ComponentItemAutoConnector/AutoConnectorItem.h>\r\n#include <editors/common/ComponentItemAutoConnector/ComponentItemAutoConnector.h>\r\n\r\n#include <editors/HWDesign/HWConnection.h>\r\n#include <editors/HWDesign/HWAddCommands.h>\r\n#include <editors/HWDesign/undoCommands/ConnectionDeleteCommand.h>\r\n#include <editors/HWDesign/undoCommands/AdHocConnectionDeleteCommand.h>\r\n#include <editors/HWDesign/AdHocConnectionItem.h>\r\n\r\n#include <KactusAPI/include/LibraryHandler.h>\r\n\r\n#include <QGraphicsSceneMouseEvent>\r\n#include <QString>\r\n#include <QMessageBox>\r\n#include <QCoreApplication>\r\n#include <QApplication>\r\n#include <QMenu>\r\n#include <QScrollBar>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentDesignDiagram::ComponentDesignDiagram()\r\n//-----------------------------------------------------------------------------\r\nComponentDesignDiagram::ComponentDesignDiagram(LibraryInterface* lh, QSharedPointer<IEditProvider> editProvider,\r\n    DesignWidget* parent) :\r\n    DesignDiagram(lh, editProvider, parent),\r\n    tempConnection_(0),\r\n    connectionStartPoint_(0),\r\n    tempPotentialEndingEndPoints_(),\r\n    connectionEndPoint_(0),\r\n    sourceComp_(0),\r\n    previouslySelectedItems_(),\r\n    selectAllAction_(tr(\"Select All\"), this),\r\n    copyAction_(tr(\"Copy\"), this),\r\n    pasteAction_(tr(\"Paste\"), this),\r\n    addAction_(tr(\"Add to Library\"), this),\r\n    openComponentAction_(tr(\"Open Component\"), this),\r\n    deleteAction_(tr(\"Delete\"), this),\r\n    openDesignMenu_(tr(\"Open Design\")),\r\n    openAutoConnector_(tr(\"Connect to ...\"), this),\r\n    clickedPosition_(),\r\n    lastMousePress_(Qt::NoButton),\r\n    lastSelectedItemIsAtRightEdge_(false)\r\n{\r\n    connect(this, SIGNAL(selectionChanged()), this, SLOT(onSelectionChanged()));\r\n    connect(editProvider.data(), SIGNAL(modified()), this, SIGNAL(contentChanged()));\r\n\r\n    setupActions();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentDesignDiagram::~ComponentDesignDiagram()\r\n//-----------------------------------------------------------------------------\r\nComponentDesignDiagram::~ComponentDesignDiagram()\r\n{\r\n    disconnect(this, SIGNAL(selectionChanged()), this, SLOT(onSelectionChanged()));\r\n    clearSelection();\r\n    destroyConnections();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentDesignDiagram::clearScene()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentDesignDiagram::clearScene()\r\n{\r\n    clearSelection();\r\n    destroyConnections();\r\n    DesignDiagram::clearScene();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentDesignDiagram::setMode()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentDesignDiagram::setMode(DrawMode mode)\r\n{\r\n    if (getMode() != mode)\r\n    {\r\n        if (getMode() == MODE_CONNECT)\r\n        {\r\n            endConnect();\r\n        }\r\n\r\n        if (mode == MODE_SELECT)\r\n        {\r\n            hideOffPageConnections();\r\n        }\r\n    }\r\n\r\n    DesignDiagram::setMode(mode);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentDesignDiagram::singleSelection()\r\n//-----------------------------------------------------------------------------\r\nbool ComponentDesignDiagram::singleSelection() const\r\n{\r\n    return selectedItems().count() == 1;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: onSelectionChanged()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentDesignDiagram::onSelectionChanged()\r\n{\r\n    ensureOneTypeSelected(previouslySelectedItems_);\r\n    raiseSelectedConnectionToFront();\r\n\r\n    // Retrieve the new selection.\r\n    QList<QGraphicsItem*> nowSelectedItems = selectedItems();\r\n    QGraphicsItem* selectedItem = nullptr;\r\n\r\n    if (!nowSelectedItems.isEmpty())\r\n    {\r\n        selectedItem = nowSelectedItems.first();\r\n    }\r\n\r\n    // If the old selection was an off-page connector, hide its connections.\r\n    // Also hide the previously selected connection if it was an off-page connection.\r\n    foreach(QGraphicsItem * oldSelection, previouslySelectedItems_)\r\n    {\r\n        if (oldSelection->type() == offpageConnectorType())\r\n        {\r\n            ConnectionEndpoint* connector = dynamic_cast<ConnectionEndpoint*>(oldSelection);\r\n\r\n            foreach(GraphicsConnection * connection, connector->getConnections())\r\n            {\r\n                if (connection != selectedItem)\r\n                {\r\n                    connection->hide();\r\n                }\r\n            }\r\n        }\r\n        else if (oldSelection->type() == connectionType() && !nowSelectedItems.contains(oldSelection))\r\n        {\r\n            GraphicsConnection* conn = dynamic_cast<GraphicsConnection*>(oldSelection);\r\n\r\n            if (conn->endpoint1() != nullptr)\r\n            {\r\n                if (conn->endpoint1()->type() == offpageConnectorType())\r\n                {\r\n                    oldSelection->hide();\r\n                }\r\n                else\r\n                {\r\n                    oldSelection->setZValue(-1000);\r\n                }\r\n            }\r\n        }\r\n    }\r\n\r\n    // If the new selection is an off-page connector, show its connections.\r\n    if (selectedItem != nullptr && selectedItem->type() == offpageConnectorType())\r\n    {\r\n        ConnectionEndpoint* connector = dynamic_cast<ConnectionEndpoint*>(selectedItem);\r\n\r\n        foreach(GraphicsConnection * connection, connector->getConnections())\r\n        {\r\n            connection->show();\r\n        }\r\n    }\r\n\r\n    // Save the current selection as the old selection.\r\n    previouslySelectedItems_ = nowSelectedItems;\r\n\r\n    onSelected(selectedItem);\r\n    prepareContextMenuActions();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentDesignDiagram::selectionToFront()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentDesignDiagram::raiseSelectedConnectionToFront()\r\n{\r\n    if (selectedItems().isEmpty())\r\n        return;\r\n\r\n    QGraphicsItem* selectedItem = selectedItems().first();\r\n    if (selectedItem->type() == connectionType())\r\n    {\r\n        selectedItem->setZValue(-900);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentDesignDiagram::onOpenComponentAction()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentDesignDiagram::onOpenComponentAction()\r\n{\r\n    if (singleSelection())\r\n    {\r\n        ComponentItem* component = dynamic_cast<ComponentItem*>(selectedItems().first());\r\n        if (component)\r\n        {\r\n            openInComponentEditor(component);\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentDesignDiagram::onOpenDesignAction()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentDesignDiagram::onOpenDesignAction(QAction* selectedAction)\r\n{\r\n    if (singleSelection())\r\n    {\r\n        ComponentItem* component = dynamic_cast<ComponentItem*>(selectedItems().first());\r\n        if (component)\r\n        {\r\n            QString viewName = selectedAction->data().toString();\r\n\r\n            openDesignForComponent(component, viewName);\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentDesignDiagram::onOpenAutoConnector()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentDesignDiagram::onOpenAutoConnector()\r\n{\r\n    ComponentItemAutoConnector* autoConnector = createAutoConnector(contextMenuItem_);\r\n    if (!autoConnector)\r\n    {\r\n        return;\r\n    }\r\n\r\n    auto currentlyConnectedItems = autoConnector->getConnectedItems();\r\n\r\n    if (autoConnector->exec() == QDialog::Accepted)\r\n    {\r\n        QList<QPair<AutoConnectorItem*, AutoConnectorItem*> > updatedConnections =\r\n            autoConnector->getConnectedItems();\r\n\r\n        removeUnchangedConnectionEditorConnections(currentlyConnectedItems, updatedConnections);\r\n\r\n        // Now currentlyConnectedItems contain connections that have been removed, and updatedConnections\r\n        // contains new connections.\r\n\r\n        // Create top level undocommand\r\n        QSharedPointer<QUndoCommand> topUndo(new QUndoCommand());\r\n\r\n        createAddCommandsForGivenConnections(updatedConnections, topUndo.data());\r\n\r\n        createRemoveCommandsForGivenConnections(currentlyConnectedItems, topUndo.data());\r\n\r\n        if (topUndo->childCount() > 0)\r\n        {\r\n            topUndo->redo();\r\n            getEditProvider()->addCommand(topUndo);\r\n        }\r\n\r\n        // Delete temporary connections.\r\n        for (auto [startItem, endItem] : updatedConnections)\r\n        {\r\n            delete startItem;\r\n            delete endItem;\r\n        }\r\n\r\n        emit contentChanged();\r\n    }\r\n\r\n    for (auto [startItem, endItem] : currentlyConnectedItems)\r\n    {\r\n        delete startItem;\r\n        delete endItem;\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentDesignDiagram::getVisibleNameForComponentItem()\r\n//-----------------------------------------------------------------------------\r\nQString ComponentDesignDiagram::getVisibleNameForComponentItem(ComponentItem* item) const\r\n{\r\n    if (!item->displayName().isEmpty())\r\n    {\r\n        return item->displayName();\r\n    }\r\n    else\r\n    {\r\n        return item->name();\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentDesignDiagram::mousePressEvent()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentDesignDiagram::mousePressEvent(QGraphicsSceneMouseEvent* mouseEvent)\r\n{\r\n    lastMousePress_ = mouseEvent->button();\r\n    lastHoveredEndpoint_ = nullptr; // Prevent invalid recoloring of last hovered endpoint.\r\n\r\n    // if other than left button was pressed return the mode back to select\r\n    if (mouseEvent->button() != Qt::LeftButton)\r\n    {\r\n        endInteraction();\r\n        if (getMode() == MODE_SELECT && mouseEvent->button() == Qt::RightButton)\r\n        {\r\n            setInteractionMode(CONTEXT_MENU);\r\n        }\r\n\r\n        setMode(MODE_SELECT);\r\n        return;\r\n    }\r\n\r\n    if (getMode() == MODE_SELECT)\r\n    {\r\n        // Check if the user pressed Alt over a component switch to replace component mode.\r\n        if (!isProtected() && mouseEvent->modifiers() & Qt::AltModifier)\r\n        {\r\n            beginComponentReplaceDrag(mouseEvent->scenePos());\r\n        }\r\n        else\r\n        {\r\n            calculatePositionVisibilityModifiers();\r\n\r\n            // Handle the mouse press and bring the new selection to front.\r\n            QGraphicsScene::mousePressEvent(mouseEvent);\r\n\r\n            if (singleSelection())\r\n            {\r\n                auto const selectedItem = selectedItems().first();\r\n                auto const firstView = views().first();\r\n                if (selectedItem && firstView)\r\n                {\r\n                    QRectF itemRectangle = selectedItem->sceneBoundingRect();\r\n                    QRectF viewScene = firstView->mapToScene(firstView->rect()).boundingRect();\r\n\r\n                    if (itemRectangle.right() > viewScene.right())\r\n                    {\r\n                        lastSelectedItemIsAtRightEdge_ = true;\r\n                    }\r\n                }\r\n            }\r\n        }\r\n    }\r\n    else if (getMode() == MODE_CONNECT && !isProtected())\r\n    {\r\n        if (mouseEvent->modifiers() & Qt::ShiftModifier)\r\n        {\r\n            setInteractionMode(OFFPAGE);\r\n        }\r\n        else\r\n        {\r\n            setInteractionMode(NORMAL);\r\n        }\r\n\r\n        connectAt(mouseEvent->scenePos());\r\n    }\r\n    else if (getMode() == MODE_INTERFACE && !isProtected())\r\n    {\r\n        addInterfaceAt(mouseEvent->scenePos());\r\n    }\r\n    else if (getMode() == MODE_DRAFT && !isProtected())\r\n    {\r\n        draftAt(mouseEvent->scenePos());\r\n    }\r\n    else if (getMode() == MODE_TOGGLE_OFFPAGE && !isProtected())\r\n    {\r\n        toggleOffPageAt(mouseEvent->scenePos());\r\n    }\r\n    else if (getMode() == MODE_LABEL && !isProtected())\r\n    {\r\n        createNoteAt(mouseEvent->scenePos());\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentDesignDiagram::mouseMoveEvent()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentDesignDiagram::mouseMoveEvent(QGraphicsSceneMouseEvent* mouseEvent)\r\n{\r\n    clickedPosition_ = QCursor::pos();\r\n\r\n    // Check if the connect mode is active.\r\n    if (getMode() == MODE_CONNECT || getMode() == MODE_TOGGLE_OFFPAGE)\r\n    {\r\n        updateConnectionDisplay(mouseEvent->scenePos());\r\n    }\r\n    else if (inReplaceMode())\r\n    {\r\n        updateComponentReplaceDragCursor(mouseEvent->scenePos());\r\n    }\r\n    else if (inAssociationMode())\r\n    {\r\n        updateAssociationCursor(mouseEvent->scenePos());\r\n        updateAssociationLineDraw(mouseEvent->scenePos());\r\n    }\r\n    // Allow moving items only when a single item is selected.\r\n    else if (singleSelection())\r\n    {\r\n        if (lastMousePress_ == Qt::LeftButton)\r\n        {\r\n            ensureMovedItemVisibility(mouseEvent);\r\n        }\r\n\r\n        QGraphicsScene::mouseMoveEvent(mouseEvent);\r\n    }\r\n    // Allow base class event handler to convert move event to hover event.\r\n    else\r\n    {\r\n        QGraphicsScene::mouseMoveEvent(mouseEvent);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentDesignDiagram::getMovedItemRectangle()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentDesignDiagram::ensureMovedItemVisibility(QGraphicsSceneMouseEvent* mouseEvent)\r\n{\r\n    auto const firstView = views().first();\r\n    if (firstView)\r\n    {\r\n        int viewWidth = firstView->width();\r\n        int viewHeight = firstView->height();\r\n\r\n        QScrollBar* horizontalScroll = firstView->horizontalScrollBar();\r\n        QScrollBar* verticalScroll = firstView->verticalScrollBar();\r\n\r\n        auto globalMappedPosition = getParent()->mapFromGlobal(clickedPosition_);\r\n        qreal marginX = getMarginForVisibility(horizontalScroll, globalMappedPosition.x(), viewWidth);\r\n        qreal marginY = getMarginForVisibility(verticalScroll, globalMappedPosition.y(), viewHeight);\r\n\r\n        auto cursorPosition = mouseEvent->scenePos();\r\n        cursorPosition.setX(floor((cursorPosition.x() + visibleModifierX_ + VISIBLEMULTIPLIER_ / 2) / VISIBLEMULTIPLIER_) * VISIBLEMULTIPLIER_);\r\n        cursorPosition.setY(floor((cursorPosition.y() + visibleModifierY_ / 2) / VISIBLEMULTIPLIER_) * VISIBLEMULTIPLIER_);\r\n\r\n        QRectF cursorRectangle(cursorPosition.x() - VISIBLERECTANGLEWIDTH_ / 2, cursorPosition.y() - VISIBLEWRECTANGLEHEIGHT_ / 2, VISIBLERECTANGLEWIDTH_, VISIBLEWRECTANGLEHEIGHT_);\r\n\r\n        firstView->ensureVisible(cursorRectangle, marginX, marginY);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentDesignDiagram::getMarginForVisibility()\r\n//-----------------------------------------------------------------------------\r\nqreal ComponentDesignDiagram::getMarginForVisibility(QScrollBar const* scrollBar, int const& position, qreal const& availableArea) const\r\n{\r\n    qreal marginValue = availableArea / 10;\r\n    qreal marginModifier = getMarginModifierForVisibility(scrollBar, position, availableArea);\r\n\r\n    marginValue = marginValue * marginModifier;\r\n    return marginValue;\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentDesignDiagram::getMarginModifierForVisibility()\r\n//-----------------------------------------------------------------------------\r\nqreal ComponentDesignDiagram::getMarginModifierForVisibility(QScrollBar const* scrollBar, int const& position, qreal const& availableArea) const\r\n{\r\n    qreal marginModifier = 1;\r\n\r\n    if (scrollBar && scrollBar->maximum() > 0)\r\n    {\r\n        qreal scrollBarValue = scrollBar->value();\r\n        qreal scrollBarMaximum = scrollBar->maximum();\r\n        marginModifier = scrollBarValue / scrollBarMaximum;\r\n\r\n        if (position > availableArea / 2)\r\n        {\r\n            marginModifier = 1 - marginModifier;\r\n        }\r\n    }\r\n\r\n    return marginModifier;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentDesignDiagram::getPositionModifierForVisibility()\r\n//-----------------------------------------------------------------------------\r\nqreal ComponentDesignDiagram::getPositionModifierForVisibility(qreal const& clickStartPosition, int const& followWidth, int const& availableWidth, qreal const& margin, qreal const& marginMultiplier) const\r\n{\r\n    qreal modifier = 0;\r\n    if (clickStartPosition <= margin)\r\n    {\r\n        modifier = marginMultiplier * margin + followWidth;\r\n    }\r\n    else if (clickStartPosition >= availableWidth - margin)\r\n    {\r\n        modifier = - marginMultiplier * margin - followWidth;\r\n    }\r\n\r\n    return modifier;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentDesignDiagram::calculateFollowModifiers()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentDesignDiagram::calculatePositionVisibilityModifiers()\r\n{\r\n    visibleModifierX_ = 0;\r\n    visibleModifierY_ = 0;\r\n\r\n    auto const firstView = views().first();\r\n    if (firstView)\r\n    {\r\n        auto movementStartPosition = firstView->mapFromGlobal(QCursor::pos());\r\n\r\n        int positionMultiplier = 20;\r\n        movementStartPosition.setX(floor((movementStartPosition.x() + positionMultiplier / 2) / positionMultiplier) * positionMultiplier);\r\n        movementStartPosition.setY(floor((movementStartPosition.y() + positionMultiplier / 2) / positionMultiplier) * positionMultiplier);\r\n\r\n        qreal viewWidth = firstView->width();\r\n        qreal viewHeight = firstView->height();\r\n\r\n        QScrollBar* horizontalScroll = firstView->horizontalScrollBar();\r\n        QScrollBar* verticalScroll = firstView->verticalScrollBar();\r\n\r\n        auto marginX = getMarginForVisibility(horizontalScroll, movementStartPosition.x(), viewWidth);\r\n        auto marginY = getMarginForVisibility(verticalScroll, movementStartPosition.y(), viewHeight);\r\n\r\n        qreal horizontalMultiplier = 1;\r\n        qreal verticalMultiplier = 1;\r\n\r\n        if (viewWidth > viewHeight)\r\n        {\r\n            verticalMultiplier = viewWidth / viewHeight;\r\n        }\r\n        else\r\n        {\r\n            horizontalMultiplier = viewHeight / viewWidth;\r\n        }\r\n\r\n        visibleModifierX_ = getPositionModifierForVisibility(movementStartPosition.x(), VISIBLERECTANGLEWIDTH_, viewWidth, marginX, horizontalMultiplier);\r\n        visibleModifierY_ = getPositionModifierForVisibility(movementStartPosition.y(), VISIBLEWRECTANGLEHEIGHT_, viewHeight, marginY, verticalMultiplier);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentDesignDiagram::removeUnchangedConnectionEditorConnections()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentDesignDiagram::removeUnchangedConnectionEditorConnections(QList<QPair<AutoConnectorItem*, AutoConnectorItem*> >& originalConnections, QList<QPair<AutoConnectorItem*, AutoConnectorItem*> >& updatedConnections) const\r\n{\r\n    // Remove unchanged connections from updatedConnections and previously connected items\r\n    auto unchangedItemsEnd = std::partition(updatedConnections.begin(), updatedConnections.end(),\r\n        [&originalConnections](QPair<AutoConnectorItem*, AutoConnectorItem*> itemPair)\r\n        {\r\n            for (auto curr_it = originalConnections.begin(); curr_it != originalConnections.end(); curr_it++)\r\n            {\r\n                if (*curr_it->first == *itemPair.first && *curr_it->second == *itemPair.second)\r\n                {\r\n                    // Remove pair from previously connected items\r\n                    delete curr_it->first;\r\n                    delete curr_it->second;\r\n                    originalConnections.erase(curr_it);\r\n                    return true;\r\n                }\r\n            }\r\n\r\n            return false;\r\n        });\r\n\r\n    // Remove unchanged pairs from updated connections.\r\n    std::for_each(updatedConnections.begin(), unchangedItemsEnd,\r\n        [](QPair<AutoConnectorItem*, AutoConnectorItem*> itemPair)\r\n        {\r\n            delete itemPair.first;\r\n            delete itemPair.second;\r\n        });\r\n\r\n    updatedConnections.erase(updatedConnections.begin(), unchangedItemsEnd);\r\n    // originalConnections now only contains connections to be removed and updatedConnections contains connections \r\n    // to be added.\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentDesignDiagram::createAddCommandsForGivenConnections()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentDesignDiagram::createAddCommandsForGivenConnections(\r\n    QList<QPair<AutoConnectorItem*, AutoConnectorItem*> > const& connections, QUndoCommand* parentCommand)\r\n{\r\n    for (auto const& [startPointItem, endPointItem] : connections)\r\n    {\r\n        ConnectionEndpoint* startPoint = getEndPointForItem(startPointItem, parentCommand);\r\n        ConnectionEndpoint* endPoint = getEndPointForItem(endPointItem, parentCommand);\r\n\r\n        auto createdConnection = createConnection(startPoint, endPoint);\r\n\r\n        createAddCommandForConnection(createdConnection, parentCommand);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentDesignDiagram::createRemoveCommandsForGivenConnections()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentDesignDiagram::createRemoveCommandsForGivenConnections(QList<QPair<AutoConnectorItem*, AutoConnectorItem*> > const& connections, QUndoCommand* parentCommand)\r\n{\r\n    for (auto const& [startPointItem, endPointItem] : connections)\r\n    {\r\n        ConnectionEndpoint* startPoint = getEndPointForItem(startPointItem);\r\n        ConnectionEndpoint* endPoint = getEndPointForItem(endPointItem);\r\n\r\n        if (auto connection = getConnectionBetweenEndpoints(startPoint, endPoint))\r\n        {\r\n            if (connection->type() == GraphicsItemTypes::GFX_TYPE_DIAGRAM_ADHOC_CONNECTION)\r\n            {\r\n                new AdHocConnectionDeleteCommand(this, static_cast<AdHocConnectionItem*>(connection), parentCommand);\r\n            }\r\n            else if (connection->type() == GraphicsItemTypes::GFX_TYPE_DIAGRAM_INTERCONNECTION)\r\n            {\r\n                new ConnectionDeleteCommand(this, static_cast<HWConnection*>(connection), parentCommand);\r\n            }\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentDesignDiagram::mouseReleaseEvent()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentDesignDiagram::mouseReleaseEvent(QGraphicsSceneMouseEvent* mouseEvent)\r\n{\r\n    // Check if we're replacing a component.\r\n    if (inReplaceMode())\r\n    {\r\n        endComponentReplaceDrag(mouseEvent->scenePos());\r\n    }\r\n\r\n    else if (canEndAssociation())\r\n    {\r\n        endAssociation(mouseEvent->scenePos());\r\n        return;\r\n    }\r\n\r\n    // process the normal mouse release event\r\n    QGraphicsScene::mouseReleaseEvent(mouseEvent);\r\n\r\n    lastMousePress_ = Qt::NoButton;\r\n    lastSelectedItemIsAtRightEdge_ = false;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: keyReleaseEvent()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentDesignDiagram::keyReleaseEvent(QKeyEvent* event)\r\n{\r\n    // Check if the user ended the off-page connection mode.\r\n    if ((event->key() == Qt::Key_Shift) && inOffPageMode())\r\n    {\r\n        if (hasConnectionStartingPoint() &&\r\n            connectionStartPoint_->getConnections().isEmpty() &&\r\n            connectionStartPoint_->type() == offpageConnectorType())\r\n        {\r\n            connectionStartPoint_->hide();\r\n        }\r\n\r\n        endConnect();\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentDesignDiagram::endConnect()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentDesignDiagram::endConnect()\r\n{\r\n    // Discard the connection that was being drawn.\r\n    discardConnection();\r\n\r\n    // Disable highlights from all end points.\r\n    disableHighlights();\r\n\r\n    // Disable off-page mode.\r\n    setInteractionMode(NORMAL);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: dragMoveEvent()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentDesignDiagram::dragMoveEvent(QGraphicsSceneDragDropEvent* event)\r\n{\r\n    updateDropAction(event);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentDesignDiagram::createContextMenu()\r\n//-----------------------------------------------------------------------------\r\nQMenu* ComponentDesignDiagram::createContextMenu(QPointF const& pos)\r\n{\r\n    QMenu* menu = nullptr;\r\n\r\n    if (contextMenuEnabled())\r\n    {\r\n        QGraphicsItem* item = getBaseItemOf(itemAt(pos, QTransform()));\r\n\r\n        if (!selectedItems().contains(item))\r\n        {\r\n            clearSelection();\r\n\r\n            if (item)\r\n            {\r\n                item->setSelected(true);\r\n            }\r\n        }\r\n\r\n        prepareContextMenuActions();\r\n\r\n        menu = new QMenu(getParent());\r\n        menu->addAction(&selectAllAction_);\r\n        menu->addSeparator();\r\n        menu->addAction(&addAction_);\r\n        menu->addAction(&openComponentAction_);\r\n        menu->addMenu(&openDesignMenu_);\r\n        menu->addSeparator();\r\n        if (addAutoConnectorActionToContextMenu())\r\n        {\r\n            menu->addAction(&openAutoConnector_);\r\n        }\r\n        menu->addSeparator();\r\n        menu->addAction(&copyAction_);\r\n        menu->addAction(&pasteAction_);\r\n        menu->addAction(&deleteAction_);\r\n\r\n        openAutoConnector_.setText(\"Connect to ...\");\r\n\r\n        ComponentItem* compItem = dynamic_cast<ComponentItem*>(item);\r\n        contextMenuItem_ = compItem;\r\n        if (compItem)\r\n        {\r\n            setupAutoconnectText(compItem);\r\n            updateOpenDesignMenuFor(compItem);\r\n        }\r\n    }\r\n\r\n    return menu;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentDesignDiagram::addAutoConnectorActionToContextMenu()\r\n//-----------------------------------------------------------------------------\r\nbool ComponentDesignDiagram::addAutoConnectorActionToContextMenu() const\r\n{\r\n    return false;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentDesignDiagram::updateOpenDesignMenuFor()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentDesignDiagram::updateOpenDesignMenuFor(ComponentItem* compItem)\r\n{\r\n    QString activeViewName = getActiveViewOf(compItem);\r\n    QStringList views = hierarchicalViewsOf(compItem);\r\n\r\n    for (auto const& viewName : views)\r\n    {\r\n        QString actionText = viewName;\r\n        if (viewName == activeViewName)\r\n        {\r\n            actionText.append(\" \");\r\n            actionText.append(tr(\"(active)\"));\r\n        }\r\n        QAction* action = openDesignMenu_.addAction(actionText);\r\n        action->setData(viewName);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentDesignDiagram::setupAutoconnectText()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentDesignDiagram::setupAutoconnectText(ComponentItem* componentItem)\r\n{\r\n    if (openAutoConnector_.isEnabled())\r\n    {\r\n        QString targetName = \"\";\r\n\r\n        if (selectedItems().count() == 1)\r\n        {\r\n            targetName = getEditedComponent()->getVlnv().getName();\r\n        }\r\n        else\r\n        {\r\n            ComponentItem* connectionTarget;\r\n            if (selectedItems().first() == componentItem)\r\n            {\r\n                connectionTarget = dynamic_cast<ComponentItem*>(selectedItems().last());\r\n            }\r\n            else\r\n            {\r\n                connectionTarget = dynamic_cast<ComponentItem*>(selectedItems().first());\r\n            }\r\n\r\n            if (connectionTarget)\r\n            {\r\n                targetName = connectionTarget->displayName();\r\n                if (targetName.isEmpty())\r\n                {\r\n                    targetName = connectionTarget->name();\r\n                }\r\n            }\r\n        }\r\n\r\n        QString actionText = openAutoConnector_.text();\r\n        actionText.replace(\"...\", targetName);\r\n        openAutoConnector_.setText(actionText);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentDesignDiagram::prepareContextMenuActions()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentDesignDiagram::prepareContextMenuActions()\r\n{\r\n    addAction_.setEnabled(addToLibraryActionEnabled());\r\n    openComponentAction_.setEnabled(openComponentActionEnabled());\r\n\r\n    openDesignMenu_.clear();\r\n    openDesignMenu_.setEnabled(openDesignEnabled());\r\n    openAutoConnector_.setEnabled(autoConnectorEnabled());\r\n    copyAction_.setEnabled(copyActionEnabled());\r\n    pasteAction_.setEnabled(pasteActionEnabled());\r\n    deleteAction_.setEnabled(deleteActionEnabled());\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentDesignDiagram::deleteActionEnabled()\r\n//-----------------------------------------------------------------------------\r\nbool ComponentDesignDiagram::deleteActionEnabled() const\r\n{\r\n    return !isProtected() && !selectedItems().isEmpty() && selectedItemIsCorrectType();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentDesignDiagram::addToLibraryActionEnabled()\r\n//-----------------------------------------------------------------------------\r\nbool ComponentDesignDiagram::addToLibraryActionEnabled() const\r\n{\r\n    return !isProtected() && singleSelection() && draftSelected();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentDesignDiagram::openDesignEnabled()\r\n//-----------------------------------------------------------------------------\r\nbool ComponentDesignDiagram::openDesignEnabled() const\r\n{\r\n    return singleSelection() && !draftSelected() && isHierarchicalComponent(selectedItems().first());\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentDesignDiagram::autoConnectorEnabled()\r\n//-----------------------------------------------------------------------------\r\nbool ComponentDesignDiagram::autoConnectorEnabled() const\r\n{\r\n    int itemCount = selectedItems().count();\r\n\r\n    return !isProtected() && (itemCount == 1 || itemCount == 2) &&\r\n        selectedItems().first()->type() == componentType() && selectedItems().last()->type() == componentType();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentDesignDiagram::draftSelected()\r\n//-----------------------------------------------------------------------------\r\nbool ComponentDesignDiagram::draftSelected() const\r\n{\r\n    return !selectedItems().empty() &&\r\n        selectedItems().first()->type() == componentType() &&\r\n        !dynamic_cast<ComponentItem*>(selectedItems().first())->componentModel()->getVlnv().isValid();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentDesignDiagram::openComponentItem()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentDesignDiagram::openComponentItem(ComponentItem* comp)\r\n{\r\n    QStringList hierViews = hierarchicalViewsOf(comp);\r\n\r\n    // if configuration is used and it contains an active view for the instance\r\n\r\n    if (!getActiveViewOf(comp).isEmpty())\r\n    {\r\n        openComponentByActiveView(comp);\r\n    }\r\n    // If the component does not contain any hierarchical views, open the component editor.\r\n    else if (hierViews.isEmpty())\r\n    {\r\n        if (comp->componentModel()->hasViews())\r\n        {\r\n            emit noticeMessage(tr(\"No active view was selected for instance %1, \"\r\n                \"opening component editor.\").arg(comp->name()));\r\n        }\r\n\r\n        openInComponentEditor(comp);\r\n    }\r\n    // Open the first design if there is one or multiple hierarchical view.\r\n    else\r\n    {\r\n        emit noticeMessage(tr(\"No active view was selected for instance %1, \"\r\n            \"opening the only hierarchical view of the component.\").arg(comp->name()));\r\n\r\n        openDesignForComponent(comp, hierViews.first());\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentDesignDiagram::openInComponentEditor()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentDesignDiagram::openInComponentEditor(ComponentItem* comp)\r\n{\r\n    emit openComponent(comp->componentModel()->getVlnv());\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentDesignDiagram::getActiveViewOf()\r\n//-----------------------------------------------------------------------------\r\nQString ComponentDesignDiagram::getActiveViewOf(ComponentItem* compItem) const\r\n{\r\n    QString activeViewName;\r\n    auto instanceName = compItem->name();\r\n\r\n\r\n\r\n    if (QSharedPointer<DesignConfiguration> designConf = getDesignConfiguration();  designConf != nullptr)\r\n    {\r\n\r\n        activeViewName = designConf->getActiveView(compItem->name());\r\n    }\r\n\r\n    return activeViewName;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentDesignDiagram::getActiveViewForEndPoint()\r\n//-----------------------------------------------------------------------------\r\nQString ComponentDesignDiagram::getActiveViewForEndPoint(ConnectionEndpoint* endPoint) const\r\n{\r\n    if (endPoint->isHierarchical())\r\n    {\r\n        return getTopView();\r\n    }\r\n    else\r\n    {\r\n        return getActiveViewOf(endPoint->encompassingComp());\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentDesignDiagram::contextMenuPosition()\r\n//-----------------------------------------------------------------------------\r\nQPoint ComponentDesignDiagram::contextMenuPosition() const\r\n{\r\n    return getParent()->mapFromGlobal(clickedPosition_);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentDesignDiagram::findSceneMappedCursorPosition()\r\n//-----------------------------------------------------------------------------\r\nQPointF ComponentDesignDiagram::findCursorPositionMappedToScene() const\r\n{\r\n    return views().first()->mapToScene(contextMenuPosition());\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentDesignDiagram::setupActions()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentDesignDiagram::setupActions()\r\n{\r\n    getParent()->addAction(&selectAllAction_);\r\n    selectAllAction_.setShortcut(QKeySequence::SelectAll);\r\n    selectAllAction_.setShortcutContext(Qt::WidgetWithChildrenShortcut);\r\n    connect(&selectAllAction_, SIGNAL(triggered()), this, SLOT(selectAll()), Qt::UniqueConnection);\r\n\r\n    getParent()->addAction(&copyAction_);\r\n    copyAction_.setShortcut(QKeySequence::Copy);\r\n    copyAction_.setShortcutContext(Qt::WidgetWithChildrenShortcut);\r\n    connect(&copyAction_, SIGNAL(triggered()), this, SLOT(onCopyAction()), Qt::UniqueConnection);\r\n\r\n    getParent()->addAction(&pasteAction_);\r\n    pasteAction_.setShortcut(QKeySequence::Paste);\r\n    pasteAction_.setShortcutContext(Qt::WidgetWithChildrenShortcut);\r\n    connect(&pasteAction_, SIGNAL(triggered()), this, SLOT(onPasteAction()), Qt::UniqueConnection);\r\n\r\n    getParent()->addAction(&addAction_);\r\n    connect(&addAction_, SIGNAL(triggered()), this, SLOT(onAddToLibraryAction()), Qt::UniqueConnection);\r\n\r\n    getParent()->addAction(&openComponentAction_);\r\n    connect(&openComponentAction_, SIGNAL(triggered()), this, SLOT(onOpenComponentAction()), Qt::UniqueConnection);\r\n\r\n    getParent()->addAction(&deleteAction_);\r\n    deleteAction_.setShortcut(QKeySequence::Delete);\r\n    deleteAction_.setShortcutContext(Qt::WidgetWithChildrenShortcut);\r\n    connect(&deleteAction_, SIGNAL(triggered()), this, SIGNAL(deleteSelectedItems()), Qt::UniqueConnection);\r\n\r\n    connect(&openDesignMenu_, SIGNAL(triggered(QAction*)),\r\n        this, SLOT(onOpenDesignAction(QAction*)), Qt::UniqueConnection);\r\n\r\n    connect(&openAutoConnector_, SIGNAL(triggered()), this, SLOT(onOpenAutoConnector()), Qt::AutoConnection);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: destroyConnections()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentDesignDiagram::destroyConnections()\r\n{\r\n    QList<GraphicsConnection*> connectionList;\r\n    for (QGraphicsItem* item : items())\r\n    {\r\n        GraphicsConnection* graphicsConnection = dynamic_cast<GraphicsConnection*>(item);\r\n        if (graphicsConnection)\r\n        {\r\n            connectionList.append(graphicsConnection);\r\n        }\r\n    }\r\n\r\n    for (GraphicsConnection* graphicsConnection : connectionList)\r\n    {\r\n        removeItem(graphicsConnection);\r\n        delete graphicsConnection;\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentDesignDiagram::connectAt()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentDesignDiagram::connectAt(QPointF const& cursorPosition)\r\n{\r\n    // no items are selected if the mode is connect\r\n    clearSelection();\r\n\r\n    if (!creatingConnection())\r\n    {\r\n        setConnectionStartingPoint(cursorPosition);\r\n\r\n        if (hasConnectionStartingPoint())\r\n        {\r\n            beginCreateConnection(cursorPosition);\r\n        }\r\n    }\r\n    else\r\n    {\r\n        endConnectionTo(cursorPosition);\r\n\r\n        // In off page mode immediately continue with a new connection.\r\n        if (inOffPageMode() && hasConnectionStartingPoint())\r\n        {\r\n            beginCreateConnection(cursorPosition);\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentDesignDiagram::creatingConnection()\r\n//-----------------------------------------------------------------------------\r\nbool ComponentDesignDiagram::creatingConnection() const\r\n{\r\n    return tempConnection_ != nullptr;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentDesignDiagram::setConnectionStartingPoint()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentDesignDiagram::setConnectionStartingPoint(QPointF const& cursorPosition)\r\n{\r\n    // No need to change the starting point in off page mode.\r\n    if (inOffPageMode() && connectionStartPoint_ != nullptr)\r\n    {\r\n        return;\r\n    }\r\n\r\n    // Try to snap to a connection end point.\r\n    ConnectionEndpoint* endpoint = DiagramUtil::snapToItem<ConnectionEndpoint>(cursorPosition, this, GridSize);\r\n\r\n    if (endpoint == nullptr || !endpoint->isVisible())\r\n    {\r\n        connectionStartPoint_ = nullptr;\r\n        return;\r\n    }\r\n\r\n    if (inOffPageMode())\r\n    {\r\n        clearHighlightedEndpoint();\r\n\r\n        if (endpoint->type() != offpageConnectorType())\r\n        {\r\n            endpoint = endpoint->getOffPageConnector();\r\n            endpoint->show();\r\n        }\r\n    }\r\n\r\n    connectionStartPoint_ = endpoint;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentDesignDiagram::hasConnectionStartingPoint()\r\n//-----------------------------------------------------------------------------\r\nbool ComponentDesignDiagram::hasConnectionStartingPoint() const\r\n{\r\n    return connectionStartPoint_ != nullptr;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentDesignDiagram::beginCreateConnection()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentDesignDiagram::beginCreateConnection(QPointF const& startingPoint)\r\n{\r\n    Q_ASSERT(connectionStartPoint_ != nullptr);\r\n\r\n    // Create the connection.\r\n    tempConnection_ = createConnection(connectionStartPoint_, snapPointToGrid(startingPoint));\r\n\r\n    addItem(tempConnection_);\r\n\r\n    // Determine all potential end points to which the starting end point could be connected\r\n    // and highlight them.\r\n    highlightConnectableEndpoints();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentDesignDiagram::highlightConnectableEndpoints()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentDesignDiagram::highlightConnectableEndpoints()\r\n{\r\n    for (QGraphicsItem* item : items())\r\n    {\r\n        ConnectionEndpoint* endpoint = dynamic_cast<ConnectionEndpoint*>(item);\r\n\r\n        if (isPossibleEndpointForCurrentConnection(endpoint))\r\n        {\r\n            endpoint->setHighlight(ConnectionEndpoint::HIGHLIGHT_ALLOWED);\r\n            tempPotentialEndingEndPoints_.append(endpoint);\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentDesignDiagram::isPossibleEndpointForCurrentConnection()\r\n//-----------------------------------------------------------------------------\r\nbool ComponentDesignDiagram::isPossibleEndpointForCurrentConnection(ConnectionEndpoint* endpoint) const\r\n{\r\n    return endpoint != nullptr && endpoint->isVisible() && endpoint != connectionStartPoint_ &&\r\n        endpoint->getOffPageConnector() != connectionStartPoint_ &&\r\n        endpoint->canConnect(connectionStartPoint_) && connectionStartPoint_->canConnect(endpoint);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentDesignDiagram::endConnectionTo()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentDesignDiagram::endConnectionTo(QPointF const& point)\r\n{\r\n    // Disable highlights from all potential end points.\r\n    clearPotentialEndpoints();\r\n\r\n    ConnectionEndpoint* endpoint = DiagramUtil::snapToItem<ConnectionEndpoint>(point, this, GridSize);\r\n\r\n    // Check if there is an end point close enough to the cursor and the\r\n    // end points can be connected together.\r\n    if (isPossibleEndpointForCurrentConnection(endpoint))\r\n    {\r\n        // Check if the connection should be converted to an off-page connection.\r\n        bool firstOffPage = connectionStartPoint_->type() == offpageConnectorType();\r\n        bool secondOffPage = endpoint->type() == offpageConnectorType();\r\n\r\n        if (inOffPageMode() ||\r\n            ((firstOffPage || secondOffPage) && connectionStartPoint_->type() != endpoint->type()))\r\n        {\r\n            if (!firstOffPage)\r\n            {\r\n                connectionStartPoint_ = connectionStartPoint_->getOffPageConnector();\r\n            }\r\n\r\n            if (!secondOffPage)\r\n            {\r\n                endpoint = endpoint->getOffPageConnector();\r\n            }\r\n\r\n            discardConnection();\r\n\r\n            GraphicsConnection* newTempConnection = createConnection(connectionStartPoint_, endpoint, true);\r\n            \r\n            addItem(newTempConnection);\r\n            tempConnection_ = newTempConnection;\r\n        }\r\n\r\n        if (tempConnection_->endpoint1()->canConnect(tempConnection_->endpoint2()) &&\r\n            tempConnection_->endpoint2()->canConnect(tempConnection_->endpoint1()))\r\n        {\r\n            auto cmd = QSharedPointer<QUndoCommand>(createAddCommandForConnection(tempConnection_));\r\n\r\n            if (!cmd)\r\n            {\r\n                discardConnection();\r\n                return;\r\n            }\r\n\r\n            cmd->redo();\r\n\r\n            tempConnection_->fixOverlap();\r\n            if (tempConnection_->endpoint1() && tempConnection_->endpoint2())\r\n            {\r\n                getEditProvider()->addCommand(cmd);\r\n            }\r\n            else\r\n            {\r\n                discardConnection();\r\n                connectionStartPoint_ = nullptr;\r\n            }\r\n            tempConnection_ = nullptr;\r\n        }\r\n        else\r\n        {\r\n            discardConnection();\r\n            connectionStartPoint_ = nullptr;\r\n        }\r\n\r\n        if (!inOffPageMode())\r\n        {\r\n            connectionStartPoint_ = nullptr;\r\n        }\r\n\r\n    }\r\n    // Delete the temporary connection.\r\n    else\r\n    {\r\n        discardConnection();\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentDesignDiagram::getConnectionBetweenEndpoints()\r\n//-----------------------------------------------------------------------------\r\nGraphicsConnection* ComponentDesignDiagram::getConnectionBetweenEndpoints(ConnectionEndpoint* startPoint, ConnectionEndpoint* endPoint)\r\n{\r\n    if (startPoint && endPoint)\r\n    {\r\n        // Check off-page endpoints if no connections are found.\r\n        if (startPoint->getConnections().isEmpty())\r\n        {\r\n            startPoint = startPoint->getOffPageConnector();\r\n        }\r\n\r\n        if (endPoint->getConnections().isEmpty())\r\n        {\r\n            endPoint = endPoint->getOffPageConnector();\r\n        }\r\n\r\n        if (!startPoint || !endPoint)\r\n        {\r\n            return nullptr;\r\n        }\r\n\r\n        for (auto connection : startPoint->getConnections())\r\n        {\r\n            if ((connection->endpoint1() == startPoint && connection->endpoint2() == endPoint) ||\r\n                (connection->endpoint1() == endPoint && connection->endpoint2() == startPoint))\r\n            {\r\n                return connection;\r\n            }\r\n        }\r\n    }\r\n\r\n    return nullptr;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentDesignDiagram::hasConnectionEndingPoint()\r\n//-----------------------------------------------------------------------------\r\nbool ComponentDesignDiagram::hasConnectionEndingPoint() const\r\n{\r\n    return connectionEndPoint_ != nullptr;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentDesignDiagram::discardConnection()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentDesignDiagram::discardConnection()\r\n{\r\n    if (tempConnection_)\r\n    {\r\n        removeItem(tempConnection_);\r\n        delete tempConnection_;\r\n        tempConnection_ = nullptr;\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentDesignDiagram::disableHighlights()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentDesignDiagram::disableHighlights()\r\n{\r\n    // If the starting point is set, disable highlight from it too.\r\n    if (connectionStartPoint_ != nullptr)\r\n    {\r\n        connectionStartPoint_->setHighlight(ConnectionEndpoint::HIGHLIGHT_OFF);\r\n        connectionStartPoint_ = nullptr;\r\n    }\r\n\r\n    clearHighlightedEndpoint();\r\n\r\n    clearPotentialEndpoints();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentDesignDiagram::clearHighlightedEndPoint()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentDesignDiagram::clearHighlightedEndpoint()\r\n{\r\n    if (hasConnectionEndingPoint())\r\n    {\r\n        connectionEndPoint_->setHighlight(ConnectionEndpoint::HIGHLIGHT_OFF);\r\n        connectionEndPoint_ = nullptr;\r\n    }\r\n}\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentDesignDiagram::clearPotentialEndpoints()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentDesignDiagram::clearPotentialEndpoints()\r\n{\r\n    for (ConnectionEndpoint* endpoint : tempPotentialEndingEndPoints_)\r\n    {\r\n        endpoint->setHighlight(ConnectionEndpoint::HIGHLIGHT_OFF);\r\n    }\r\n\r\n    tempPotentialEndingEndPoints_.clear();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentDesignDiagram::addInterfaceAt()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentDesignDiagram::addInterfaceAt(QPointF const& position)\r\n{\r\n    // Find the column under the cursor.\r\n    GraphicsColumn* column = getLayout()->findColumnAt(position);\r\n\r\n    // Add a new diagram interface to the column it it is allowed.\r\n    if (column != nullptr && column->getColumnDesc()->getAllowedItems() & ColumnTypes::INTERFACE)\r\n    {\r\n        addTopLevelInterface(column, position, true);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentDesignDiagram::toggleOffPageAt()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentDesignDiagram::toggleOffPageAt(QPointF const& position)\r\n{\r\n    // Try to snap to a connection end point.\r\n    ConnectionEndpoint const* endpoint = DiagramUtil::snapToItem<ConnectionEndpoint>(position, this, GridSize);\r\n\r\n    QSharedPointer<QUndoCommand> cmd(new QUndoCommand());\r\n\r\n    if (endpoint != nullptr && endpoint->isVisible())\r\n    {\r\n        QList<GraphicsConnection*> connections = endpoint->getConnections();\r\n        if (connections.isEmpty() == false)\r\n        {\r\n            hideOffPageConnections();\r\n\r\n            for (GraphicsConnection* conn : connections)\r\n            {\r\n                toggleConnectionStyle(conn, cmd.data());\r\n            }\r\n        }\r\n    }\r\n    else\r\n    {\r\n        QGraphicsItem* item = itemAt(position, QTransform());\r\n\r\n        GraphicsConnection* connection = dynamic_cast<GraphicsConnection*>(item);\r\n        if (connection)\r\n        {\r\n            toggleConnectionStyle(connection, cmd.data());\r\n        }\r\n    }\r\n\r\n    if (cmd->childCount() > 0)\r\n    {\r\n        getEditProvider()->addCommand(cmd);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: toggleConnectionStyle()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentDesignDiagram::toggleConnectionStyle(GraphicsConnection* conn, QUndoCommand* parentCmd)\r\n{\r\n    Q_ASSERT(parentCmd != nullptr);\r\n    emit clearItemSelection();\r\n\r\n    conn->toggleOffPage();\r\n    new ConnectionToggleOffPageCommand(conn, parentCmd);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentDesignDiagram::hideOffPageConnections()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentDesignDiagram::hideOffPageConnections()\r\n{\r\n    for (QGraphicsItem* item : items())\r\n    {\r\n        GraphicsConnection* connection = dynamic_cast<GraphicsConnection*>(item);\r\n\r\n        if (connection && connection->endpoint1() && connection->endpoint1()->type() == offpageConnectorType())\r\n        {\r\n            connection->hide();\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentDesignDiagram::beginComponentReplaceDrag()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentDesignDiagram::beginComponentReplaceDrag(QPointF const& startpoint)\r\n{\r\n    ComponentItem* sourceComp = getTopmostComponent(startpoint);\r\n\r\n    if (sourceComp)\r\n    {\r\n        sourceComp_ = sourceComp;\r\n        QApplication::setOverrideCursor(Qt::ForbiddenCursor);\r\n        setInteractionMode(REPLACE);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentDesignDiagram::updateComponentReplaceDragCursor()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentDesignDiagram::updateComponentReplaceDragCursor(QPointF const& cursorPosition)\r\n{\r\n    ComponentItem* destComp = getTopmostComponent(cursorPosition);\r\n\r\n    if (destComp != nullptr && destComp != sourceComp_ && componentItemIsAllowedInColumnAtPosition(cursorPosition))\r\n    {\r\n        QApplication::changeOverrideCursor(Qt::ClosedHandCursor);\r\n    }\r\n    else\r\n    {\r\n        QApplication::changeOverrideCursor(Qt::ForbiddenCursor);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentDesignDiagram::componentItemIsAllowedInColumn()\r\n//-----------------------------------------------------------------------------\r\nbool ComponentDesignDiagram::componentItemIsAllowedInColumnAtPosition(QPointF const& cursorPosition) const\r\n{\r\n    QSharedPointer<Component> draggedComponent = sourceComp_->componentModel();\r\n    if (draggedComponent)\r\n    {\r\n        ColumnTypes::ColumnItemType itemType = ColumnTypes::COMPONENT;\r\n\r\n        if (draggedComponent->isTransparentBridge() || draggedComponent->isOpaqueBridge())\r\n        {\r\n            itemType = ColumnTypes::BRIDGE;\r\n        }\r\n        else if (draggedComponent->isChannel())\r\n        {\r\n            itemType = ColumnTypes::CHANNEL;\r\n        }\r\n        else if (draggedComponent->isBus())\r\n        {\r\n            itemType = ColumnTypes::INTERFACE;\r\n        }\r\n\r\n        GraphicsColumn const* column = getLayout()->findColumnAt(cursorPosition);\r\n\r\n        return column->getColumnDesc()->getAllowedItems() & itemType;\r\n    }\r\n\r\n    return false;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentDesignDiagram::endComponentReplaceDrag()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentDesignDiagram::endComponentReplaceDrag(QPointF const& endpoint)\r\n{\r\n    setInteractionMode(NORMAL);\r\n    QApplication::restoreOverrideCursor();\r\n\r\n    if (componentItemIsAllowedInColumnAtPosition(endpoint))\r\n    {\r\n        ComponentItem* destinationComponent = getTopmostComponent(endpoint);\r\n\r\n        if (destinationComponent == nullptr || destinationComponent == sourceComp_)\r\n        {\r\n            return;\r\n        }\r\n\r\n        QMessageBox msgBox(QMessageBox::Warning, QCoreApplication::applicationName(),\r\n            tr(\"Component instance '%1' is about to be switched in place with '%2'. Continue and replace?\").\r\n            arg(destinationComponent->name(), sourceComp_->name()),\r\n            QMessageBox::Yes | QMessageBox::No, getParent());\r\n\r\n        if (msgBox.exec() == QMessageBox::Yes)\r\n        {\r\n            replace(destinationComponent, sourceComp_);\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentDesignDiagram::updateConnectionDisplay()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentDesignDiagram::updateConnectionDisplay(QPointF const& cursorPosition)\r\n{\r\n    if (creatingConnection())\r\n    {\r\n        highlightPotentialEndpointUnderCursor(cursorPosition);\r\n        updateConnectionDraw(cursorPosition);\r\n    }\r\n    else\r\n    {\r\n        highlightEndpointUnderCursor(cursorPosition);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentDesignDiagram::updateConnectionDraw()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentDesignDiagram::updateConnectionDraw(QPointF const& cursorPosition)\r\n{\r\n    Q_ASSERT(tempConnection_->route().isEmpty() == false);\r\n\r\n    GraphicsConnection* updatedConnection = nullptr;\r\n\r\n    if (hasConnectionEndingPoint())\r\n    {\r\n        updatedConnection = createConnection(connectionStartPoint_, connectionEndPoint_);\r\n    }\r\n    else\r\n    {\r\n        updatedConnection = createConnection(connectionStartPoint_, snapPointToGrid(cursorPosition));\r\n    }\r\n\r\n    discardConnection();\r\n\r\n    addItem(updatedConnection);\r\n    tempConnection_ = updatedConnection;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentDesignDiagram::highlightEndpointUnderCursor()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentDesignDiagram::highlightEndpointUnderCursor(QPointF const& cursorPosition)\r\n{\r\n    clearHighlightedEndpoint();\r\n\r\n    // Find out if there is an end point currently under the cursor.\r\n    ConnectionEndpoint* endpoint = DiagramUtil::snapToItem<ConnectionEndpoint>(cursorPosition, this, GridSize);\r\n    if (endpoint != nullptr && endpoint->isVisible())\r\n    {\r\n        connectionEndPoint_ = endpoint;\r\n        connectionEndPoint_->setHighlight(ConnectionEndpoint::HIGHLIGHT_HOVER);\r\n\r\n        if (connectionEndPoint_->type() == offpageConnectorType())\r\n        {\r\n            hideOffPageConnections();\r\n\r\n            for (GraphicsConnection* conn : connectionEndPoint_->getConnections())\r\n            {\r\n                conn->show();\r\n            }\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentDesignDiagram::updateConnectionHighlight()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentDesignDiagram::highlightPotentialEndpointUnderCursor(QPointF const& cursorPosition)\r\n{\r\n    disableCurrentHighlight();\r\n\r\n    // Find out if there is an end point currently under the cursor.\r\n    ConnectionEndpoint* endpoint = DiagramUtil::snapToItem<ConnectionEndpoint>(cursorPosition, this, GridSize);\r\n    if (endpoint != nullptr && tempPotentialEndingEndPoints_.contains(endpoint))\r\n    {\r\n        // Highlight the end point.          \r\n        connectionEndPoint_ = endpoint;\r\n        lastHoveredEndpoint_ = endpoint;\r\n        connectionEndPoint_->setHighlight(ConnectionEndpoint::HIGHLIGHT_HOVER);\r\n    }\r\n    else if (lastHoveredEndpoint_) // Highligh endpoint again, if it wasn't connected the first time.\r\n    {\r\n        lastHoveredEndpoint_->setHighlight(ConnectionEndpoint::HIGHLIGHT_ALLOWED);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentDesignDiagram::disableCurrentHighlight()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentDesignDiagram::disableCurrentHighlight()\r\n{\r\n    if (hasConnectionEndingPoint())\r\n    {\r\n        if (hasConnectionStartingPoint() && connectionEndPoint_ != connectionStartPoint_ &&\r\n            tempPotentialEndingEndPoints_.contains(connectionEndPoint_))\r\n        {\r\n            connectionEndPoint_->setHighlight(ConnectionEndpoint::HIGHLIGHT_ALLOWED);\r\n        }\r\n        else\r\n        {\r\n            connectionEndPoint_->setHighlight(ConnectionEndpoint::HIGHLIGHT_OFF);\r\n        }\r\n\r\n        connectionEndPoint_ = nullptr;\r\n    }\r\n}\r\n"
  },
  {
    "path": "editors/common/ComponentDesignDiagram.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ComponentDesignDiagram.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Esko Pekkarinen\r\n// Date: 23.6.2014\r\n//\r\n// Description:\r\n// Base class for all component designs.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef COMPONENTDESIGNDIAGRAM_H\r\n#define COMPONENTDESIGNDIAGRAM_H\r\n\r\n#include <editors/common/DesignDiagram.h>\r\n\r\n#include <QVector>\r\n#include <QSharedPointer>\r\n#include <QUndoCommand>\r\n#include <QScrollBar>\r\n\r\nclass ComponentItem;\r\nclass ConnectionEndpoint;\r\nclass DesignWidget;\r\nclass GraphicsColumn;\r\nclass GraphicsConnection;\r\nclass LibraryInterface;\r\nclass IEditProvider;\r\nclass AutoConnectorItem;\r\nclass ComponentItemAutoConnector;\r\n\r\n//-----------------------------------------------------------------------------\r\n// ComponentDesignDiagram is a base class for component designs.\r\n//-----------------------------------------------------------------------------\r\nclass ComponentDesignDiagram : public DesignDiagram\r\n{\r\n    Q_OBJECT\r\n\r\npublic:\r\n\r\n    /*!\r\n     *  Constructor.\r\n     */\r\n    ComponentDesignDiagram(LibraryInterface* lh, QSharedPointer<IEditProvider> editProvider, DesignWidget* parent = 0);\r\n\r\n\t//! \\brief The destructor\r\n\tvirtual ~ComponentDesignDiagram();\r\n\r\n    /*!\r\n     *  Clears the scene.\r\n     */\r\n    virtual void clearScene();\r\n\r\n    /*!\r\n     *  Sets the draw mode.\r\n     */\r\n    virtual void setMode(DrawMode mode);\r\n\r\n    /*!\r\n     *  Checks if a single item has been selected.\r\n     *\r\n     *    @return True, if only one item is selected, otherwise false.\r\n     */\r\n    bool singleSelection() const;\r\n\r\nsignals:\r\n\r\n    /*!\r\n     *  Delete the selected graphics items.\r\n     */\r\n    void deleteSelectedItems();\r\n\r\npublic slots:\r\n\r\n    //! Called when the selection changes in the diagram.\r\n    virtual void onSelectionChanged();\r\n    \r\n    //! Sets the selected connection above other connections.\r\n    virtual void raiseSelectedConnectionToFront();\r\n\r\n    //! Called when an item has been selected in the diagram. Updates the context help.\r\n    virtual void onSelected(QGraphicsItem* newSelection) = 0;\r\n\r\n\t//! Called when copy is selected from the context menu.\r\n\tvirtual void onCopyAction() = 0;\r\n\r\n\t//!  Called when paste is selected from the context menu.\r\n\tvirtual void onPasteAction() = 0;\r\n\r\n\t//! Called when add to library is selected from the context menu.\r\n    virtual void onAddToLibraryAction() = 0;\r\n\r\n\t//! Called when open component is selected from the context menu.\r\n\tvirtual void onOpenComponentAction();\r\n\r\n    /*!\r\n     *  Called when open design is selected from the context menu.\r\n     *\r\n     *    @param [in] selectedAction   The action used to select the opened design.\r\n     */\r\n    virtual void onOpenDesignAction(QAction* selectedAction);\r\n\r\n    /*!\r\n     *  Called when the auto connected is selected from the context menu.\r\n     */\r\n    virtual void onOpenAutoConnector();\r\n\r\nprotected:\r\n\r\n    /*!\r\n     *  Opens a design for a given component.\r\n     *\r\n     *    @param [in] component   The component whose design to open.\r\n     *    @param [in] viewName    The name of the view to open.\r\n     */\r\n    virtual void openDesignForComponent(ComponentItem* component, QString const& viewName) = 0;\r\n\r\n    //! Handler for mouse click events.\r\n    virtual void mousePressEvent(QGraphicsSceneMouseEvent *mouseEvent);\r\n\r\n    //! Handler for mouse move events.\r\n    virtual void mouseMoveEvent(QGraphicsSceneMouseEvent *mouseEvent);\r\n\r\n    //! Handler for mouse release events.\r\n    virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *mouseEvent);\r\n\r\n    //! Called when a key has been release.\r\n    virtual void keyReleaseEvent(QKeyEvent *event);\r\n\r\n    //! Ends the drawing of current connection.\r\n    void endConnect();\r\n\r\n    //! Called when mouse moves while dragging an item. Delegates to updateDropAction.\r\n    virtual void dragMoveEvent(QGraphicsSceneDragDropEvent *event);\r\n\r\n    //! Updates the dropAction and highlight according to underlying element.\r\n    virtual void updateDropAction(QGraphicsSceneDragDropEvent* event) = 0;\r\n   \r\n\t/*!\r\n     *  Creates the context menu for function contextMenuEvent().\r\n     *\r\n     *    @param [in] pos Mouse position when the menu is requested.\r\n\t *\r\n\t *    @return The menu with allowed actions or 0 if no menu is allowed or nothing to show.\r\n     */\r\n\tvirtual QMenu* createContextMenu(QPointF const& pos);\r\n\r\n    /*!\r\n     *  Updates the open design sub-menu according to item views.\r\n     *\r\n     *    @param [in] compItem   The component item whose views to display in the sub-menu.\r\n     */\r\n    virtual void updateOpenDesignMenuFor(ComponentItem* compItem);\r\n\r\n    //! Enables/disable context menu actions based on the current selection.\r\n    virtual void prepareContextMenuActions();\r\n\r\n    /*!\r\n     *  Checks if add to library action should be enabled.\r\n     *\r\n     *    @return True, if action should be enabled, otherwise false.\r\n     */\r\n    virtual bool addToLibraryActionEnabled() const;\r\n\r\n    /*!\r\n     *  Checks if open component action should be enabled.\r\n     *\r\n     *    @return True, if action should be enabled, otherwise false.\r\n     */\r\n    virtual bool openComponentActionEnabled() const = 0;\r\n\r\n    /*!\r\n     *  Check if the delete action can be enabled.\r\n     *\r\n     *    @return True, if the delete action should be enabled, otherwise false.\r\n     */\r\n    virtual bool deleteActionEnabled() const;\r\n\r\n    /*!\r\n     *  Check if the selected items are of the correct type for the design diagram.\r\n     *\r\n     *    @return True, if the selected items are used in the design, false otherwise.\r\n     */\r\n    virtual bool selectedItemIsCorrectType() const = 0;\r\n\r\n    /*!\r\n     *  Checks if open design action should be enabled.\r\n     *\r\n     *    @return True, if action should be enabled, otherwise false.\r\n     */\r\n    virtual bool openDesignEnabled() const;\r\n\r\n    /*!\r\n     *  Checks if the auto connector action is enabled.\r\n     *\r\n     *    @return True, if the action is enabled, otherwise false.\r\n     */\r\n    virtual bool autoConnectorEnabled() const;\r\n\r\n    /*!\r\n     *  Checks if the given item is a hierarchical component.\r\n     *\r\n     *    @param [in] item   The item to check.\r\n     *\r\n     *    @return True, if item is a hierarchical component, otherwise false.\r\n     */\r\n    virtual bool isHierarchicalComponent(QGraphicsItem* item) const = 0;\r\n\r\n    /*!\r\n     *  Checks if copy action should be enabled.\r\n     *\r\n     *    @return True, if action should be enabled, otherwise false.\r\n     */\r\n    virtual bool copyActionEnabled() const = 0;\r\n\r\n    /*!\r\n     *  Checks if paste action should be enabled.\r\n     *\r\n     *    @return True, if action should be enabled, otherwise false.\r\n     */\r\n    virtual bool pasteActionEnabled() const = 0;\r\n\r\n    /*!\r\n     *  Checks if current selection is a draft component.\r\n     *\r\n     *    @return Ture, if the current selection is a draft component, otherwise false.\r\n     */\r\n    bool draftSelected() const;\r\n\r\n    /*!\r\n     *  Opens the given component in component editor or design according to the active view of the component.\r\n     *\r\n     *    @param [in] comp   The component to open.\r\n     */\r\n    void openComponentItem(ComponentItem* comp);\r\n\r\n    /*!\r\n     *  Opens the given component in component editor.\r\n     *\r\n     *    @param [in] comp   The component to open.\r\n     */\r\n    void openInComponentEditor(ComponentItem* comp);\r\n\r\n    /*!\r\n     *  Opens the given component according to the active view of the component.\r\n     *\r\n     *    @param [in] comp   The component to open.\r\n     */\r\n    virtual void openComponentByActiveView(ComponentItem* comp) = 0;\r\n\r\n   /*!\r\n    *  Gets the names of hierarchical views of a component.\r\n    *\r\n    *    @param [in] component   The component whose hierarchical views to get.\r\n    *\r\n    *    @return The names of the hierarchical views.\r\n    */\r\n   virtual QStringList hierarchicalViewsOf(ComponentItem* component) const = 0;\r\n\r\n    /*!\r\n     *  Gets the name of the active view for the given component item.\r\n     *\r\n     *    @param [in] compItem   The item whose active view to get.\r\n     *\r\n     *    @return The name of the active view.\r\n     */\r\n    QString getActiveViewOf(ComponentItem* compItem) const;\r\n\r\n    /*!\r\n     *  Get the active view for the item containing the selected end point item.\r\n     *\r\n     *    @param [in] endPoint    The selected end point item.\r\n     *\r\n     *    @return The active view for the item containing the selected end point item.\r\n     */\r\n    QString getActiveViewForEndPoint(ConnectionEndpoint* endPoint) const;\r\n\r\n    /*!\r\n     *  Gets the position where context menu was activated.     \r\n     *\r\n     *    @return The position of the context menu activation.\r\n     */\r\n    QPoint contextMenuPosition() const;\r\n\r\n    /*!\r\n     *  Gets the graphics item type of the components in the diagram.\r\n     *     \r\n     *    @return The type of the components.\r\n     */\r\n    virtual int componentType() const = 0;\r\n\r\n    /*!\r\n     *  Gets the graphics item type of the off page connectors in the diagram.\r\n     *     \r\n     *    @return The type of the components.\r\n     */\r\n    virtual int offpageConnectorType() const = 0;\r\n\r\n    /*!\r\n     *  Gets the graphics item type of the connections in the diagram.\r\n     *     \r\n     *    @return The type of the components.\r\n     */\r\n    virtual int connectionType() const = 0;\r\n\r\n    /*!\r\n     *  Find the cursor position mapped to the current scene.\r\n     *\r\n     *    @return The cursor position mapped to the current scene.\r\n     */\r\n    QPointF findCursorPositionMappedToScene() const;\r\n\r\n    /*!\r\n     *  Get the visible name for the selected component item.\r\n     *\r\n     *    @param [in] item    The selected component item.\r\n     *\r\n     *    @return Visible name of the selected component item.\r\n     */\r\n    QString getVisibleNameForComponentItem(ComponentItem* item) const;\r\n\r\nprivate:\r\n    // Disable copying.\r\n    ComponentDesignDiagram(ComponentDesignDiagram const& rhs);\r\n    ComponentDesignDiagram& operator=(ComponentDesignDiagram const& rhs);\r\n\r\n    //!  Initializes the context menu actions.     \r\n\tvoid setupActions();\r\n\r\n    /*!\r\n     *  Destroys all connections in the diagram.\r\n     */\r\n    void destroyConnections();\r\n\r\n    /*!\r\n     *  Handler for connection tool clicks. Creates a connection to the given position by either \r\n     *  beginning a new connection or ending currently drawn connection to it.     \r\n     *\r\n     *    @param [in] cursorPosition      The position to connect.\r\n     */\r\n    void connectAt(QPointF const& cursorPosition);\r\n\r\n    /*!\r\n     *  Checks if a connection is being drawn.\r\n     *     \r\n     *    @return True, if a connection is being drawn, otherwise false.\r\n     */\r\n    bool creatingConnection() const;\r\n\r\n    /*!\r\n     *  Sets the starting end point for a new connection. If offpage mode is on, the previous starting point\r\n     *  is used, otherwise the starting point is selected based on the clicked cursor position.\r\n     *\r\n     *    @param [in] cursorPosition   The cursor position.     \r\n     */\r\n    void setConnectionStartingPoint(QPointF const& cursorPosition);\r\n\r\n    /*!\r\n     *  Checks if the starting point of current connection is set.\r\n     *\r\n     *    @return True, if the staring point has been set, otherwise false.\r\n     */\r\n    bool hasConnectionStartingPoint() const;\r\n\r\n   /*!\r\n    *  Begins drawing a connection from the given point.\r\n    *\r\n    *    @param [in] startingPoint   The point to start the connection from.    \r\n    */\r\n    void beginCreateConnection(QPointF const& startingPoint);\r\n\r\n    //! Highlights all endpoints that can be connected to the current connection.     \r\n    void highlightConnectableEndpoints();\r\n\r\n    /*!\r\n     *  Checks if an endpoint can be used as the ending point for current connection.\r\n     *\r\n     *    @param [in] endpoint   The endpoint to check.\r\n     *\r\n     *    @return True, if endpoint can be connected to the current connection, otherwise false.\r\n     */\r\n    bool isPossibleEndpointForCurrentConnection(ConnectionEndpoint* endpoint) const;\r\n\r\n    /*!\r\n     *  Creates the currently drawn connection by ending it to the given point.\r\n     *\r\n     *    @param [in] event The ending point.\r\n     */\r\n    void endConnectionTo(QPointF const& point);\r\n\r\n    /*!\r\n     *  Creates a connection between the given two endpoints.\r\n     *\r\n     *    @param [in] startPoint  The starting connection end point.\r\n     *    @param [in] endPoint    The ending connection end point.\r\n     *    @param [in] isOffPage   Determines if connection to be created is off-page or not.\r\n     *    @return The created connection.\r\n     */\r\n    virtual GraphicsConnection* createConnection(ConnectionEndpoint* startPoint, ConnectionEndpoint* endPoint, bool isOffPage = false) = 0;\r\n\r\n    /*!\r\n     *  Creates a connection between the given endpoint and a coordinate point.\r\n     *\r\n     *    @param [in] startPoint  The starting connection end point.\r\n     *    @param [in] endPoint    The ending coordinate point.\r\n     *\r\n     *    @return The created connection.\r\n     */\r\n    virtual GraphicsConnection* createConnection(ConnectionEndpoint* startPoint, QPointF const& endPoint) = 0;\r\n\r\n    /*!\r\n     *  Creates an add command for a given connection.\r\n     *\r\n     *    @param [in] connection  The connection to create a command for.     \r\n     *\r\n     *    @return The created add command.\r\n     */\r\n    virtual QUndoCommand* createAddCommandForConnection(GraphicsConnection* connection, QUndoCommand* parentCommand = nullptr) = 0;\r\n    \r\n    /*!\r\n     *\tGet the connection between two given endpoints.\r\n     *  \r\n     *    @param [in] startPoint  The start endpoint.\r\n     *    @param [in] endPoint    The ending endpoint.   \r\n     *\t    \r\n     * \t    @return The connection between the endpoints, or nullptr if not found or if either endpoint doesn't exist.\r\n     */\r\n    [[nodiscard]] virtual GraphicsConnection* getConnectionBetweenEndpoints(ConnectionEndpoint* startPoint, ConnectionEndpoint* endPoint);\r\n\r\n    /*!\r\n     *  Checks if the ending point of current connection is set.\r\n     *\r\n     *    @return True, if the ending point has been set, otherwise false.\r\n     */\r\n    bool hasConnectionEndingPoint() const;\r\n\r\n    //! Deletes the currently drawn connection.\r\n    void discardConnection();\r\n\r\n    //! Removes all highlights.\r\n    void disableHighlights();\r\n\r\n    //! Clears the highlighting of the currently highlighted endpoint.\r\n    void clearHighlightedEndpoint();\r\n\r\n    //! Removes highlight from possible endpoints for current connection.\r\n    void clearPotentialEndpoints();\r\n\r\n    /*!\r\n     *  Handler for interface tool clicks.\r\n     *\r\n     *    @param [in] position   The interface position.\r\n     */\r\n    void addInterfaceAt(QPointF const& position);\r\n\r\n    /*!\r\n     *  Adds a new top-level interface to the given diagram column.\r\n     *\r\n     *    @param [in] column      The column where to add the interface.\r\n     *    @param [in] pos         The interface position.\r\n     *    @param [in] isDraft     Determines if Top level interface is draft or not.\r\n     */\r\n    virtual void addTopLevelInterface(GraphicsColumn* column, QPointF const& pos, bool isDraft) = 0;\r\n\r\n    /*!\r\n     *  Handler for draft tool clicks. Creates a draft component instance or a draft interface according to the\r\n     *  clicked position.\r\n     *\r\n     *    @param [in] clickedPosition   The position to create the draft item to.     \r\n     */\r\n    virtual void draftAt(QPointF const& clickedPosition) = 0;\r\n\r\n    /*!\r\n     *  Handler for offpage tool clicks. Toggles the connection offpage mode for clicked interface or connection.\r\n     *\r\n     *    @param [in] position   The point to toggle at.     \r\n     */\r\n    void toggleOffPageAt(QPointF const& position);\r\n\r\n    /*!\r\n     *  Toggles the connection style of the given connection between normal and off-page style.\r\n     *\r\n     *    @param [in] conn      The connection.\r\n     *    @param [in] parentCmd The parent undo command.\r\n     */\r\n    void toggleConnectionStyle(GraphicsConnection* conn, QUndoCommand* parentCmd);\r\n\r\n    //! Hides all off-page connections.\r\n    void hideOffPageConnections();\r\n\r\n    /*!\r\n     *  Begins replacing another component with a component at the given position.\r\n     *\r\n     *    @param [in] startpoint   The position to start replacing from.     \r\n     */\r\n    void beginComponentReplaceDrag(QPointF const& startpoint);\r\n\r\n    /*!\r\n     *  Updates the cursor according to design content at the given position while replacing.\r\n     *\r\n     *    @param [in] cursorPosition   The cursor position.\r\n     */\r\n    void updateComponentReplaceDragCursor(QPointF const& cursorPosition);\r\n\r\n    /*!\r\n     *  Check if a component item is allowed in the column located at the selected position.\r\n     *\r\n     *    @param [in] cursorPosition  The selected position.\r\n     *\r\n     *    @return True, if the item is allowed in the column, false otherwise.\r\n     */\r\n    bool componentItemIsAllowedInColumnAtPosition (QPointF const& cursorPosition) const;\r\n\r\n    /*!\r\n     *  Ends the component replace at the given position. If another component is in the given position,\r\n     *  it is replaced with the component being dragged.\r\n     *\r\n     *    @param [in] endpoint   The point to end the replacing.\r\n     */\r\n    void endComponentReplaceDrag(QPointF const& endpoint);\r\n\r\n    /*!\r\n     *  Performs the replacing of destination component with source component.\r\n     *\r\n     *    @param [in] destComp        The component to replace.\r\n     *    @param [in] sourceComp      The replacing component.     \r\n     */\r\n    virtual void replace(ComponentItem* destComp, ComponentItem* sourceComp) = 0;\r\n\r\n    /*!\r\n     *  Updates the currently drawn connection and its highlights.\r\n     *\r\n     *    @param [in] cursorPosition   The position of the cursor.     \r\n     */\r\n    virtual void updateConnectionDisplay(QPointF const& cursorPosition);\r\n\r\n    /*!\r\n     *  Updates the drawing of current connection.\r\n     *\r\n     *    @param [in] cursorPosition   The position of the cursor. Connection ends to it.\r\n     */\r\n    virtual void updateConnectionDraw(QPointF const& cursorPosition);\r\n\r\n    /*!\r\n     *  Updates highlighting of possible endpoints for a new connection.\r\n     *\r\n     *    @param [in] cursorPosition   The position of the cursor. Connection begins from it.\r\n     */\r\n    virtual void highlightEndpointUnderCursor(QPointF const& cursorPosition);\r\n\r\n    /*!\r\n     *  Updates the highlighting of endpoint near the cursor for current connection.\r\n     *\r\n     *    @param [in] cursorPosition   The position of the cursor.\r\n     */\r\n    void highlightPotentialEndpointUnderCursor(QPointF const& cursorPosition);\r\n\r\n    /*!\r\n     *  Removes highlight from the current connection end point.\r\n     */\r\n    void disableCurrentHighlight();\r\n\r\n    /*!\r\n     *  Setup the text for the auto connector action.\r\n     *\r\n     *    @param [in] componentItem   The target of the connection.\r\n     */\r\n    void setupAutoconnectText(ComponentItem* componentItem);\r\n\r\n    /*!\r\n     *  Get the connection end point for the selected auto connector item.\r\n     *\r\n     *    @param [in] connectorItem   The selected auto connector item.\r\n     *\r\n     *    @return The end point item for the selected auto connector item.\r\n     */\r\n    virtual ConnectionEndpoint* getEndPointForItem(AutoConnectorItem* connectorItem, QUndoCommand* parentUndoCommand = nullptr) = 0;\r\n\r\n    /*!\r\n     *  Create connection between the selected end points.\r\n     *\r\n     *    @param [in] startPoint  Start point for the connection.\r\n     *    @param [in] endPoint    End point for the connection.\r\n     */\r\n    virtual void createConnectionBetweenEndPoints(ConnectionEndpoint* startPoint,\r\n        ConnectionEndpoint* endPoint) = 0;\r\n\r\n    /*!\r\n     *  Check if the auto connector should be added to the context menu.\r\n     *\r\n     *    @return True, if the auto connected should be added, false otherwise.\r\n     */\r\n    virtual bool addAutoConnectorActionToContextMenu() const;\r\n\r\n    /*!\r\n     *  Create auto connection dialog.\r\n     *\r\n     *    @param [in] firstItem   The first item for the auto connector.\r\n     *\r\n     *    @return The auto connector dialog.\r\n     */\r\n    virtual ComponentItemAutoConnector* createAutoConnector(ComponentItem* firstItem) const = 0;\r\n\r\n    /*!\r\n     *  Ensure visibility of a moving item.\r\n     *\r\n     *    @param [in] mouseEvent  The mouse event.\r\n     */\r\n    void ensureMovedItemVisibility(QGraphicsSceneMouseEvent* mouseEvent);\r\n\r\n    /*!\r\n     *  Get the margin for keeping selection in view.\r\n     *\t\r\n     *    @param [in] scrollBar       Scrollbar for margin calculations.\r\n     *    @param [in] position        Current position on the same axis as the scrollbar.\r\n     *    @param [in] availableArea   The maximum coordinates of the area.\r\n     *\r\n     *    @return Current margin for the current selection.\r\n     */\r\n    qreal getMarginForVisibility(QScrollBar const* scrollBar, int const& position, qreal const& availableArea) const;\r\n\r\n    /*!\r\n     *  Get the margin modifier for the current margin.\r\n     *\t\r\n     *    @param [in] scrollBar       Scrollbar for margin calculations.\r\n     *    @param [in] position        Current position on the same axis as the scrollbar.\r\n     *    @param [in] availableArea   The maximum coordinates of the area.\r\n     *\r\n     *    @return Modifier for the margin, between 0 and 1.\r\n     */\r\n    qreal getMarginModifierForVisibility(QScrollBar const* scrollBar, int const& position, qreal const& availableArea) const;\r\n\r\n    /*!\r\n     *  Get the clicked position modifier for visibility calculation. \r\n     *\t\r\n     *    @param [in] clickStartPosition  Coordinates of the clicked position.\r\n     *    @param [in] followWidth         Width of the area to be visible.\r\n     *    @param [in] availableWidth      Available width of the area.\r\n     *    @param [in] margin              The margin for visibility check.\r\n     *    @param [in] marginMultiplier    Multiplier for margin.\r\n     *\r\n     *    @return Modifier for visibility coordinates according to the position of the click.\r\n     */\r\n    qreal getPositionModifierForVisibility(qreal const& clickStartPosition, int const& followWidth, int const& availableWidth, qreal const& margin, qreal const& marginMultiplier) const;\r\n\r\n    /*!\r\n     *  Calculate coordinate modifiers for both x and y axis.\r\n     */\r\n    void calculatePositionVisibilityModifiers();\r\n\r\n    /*!\r\n     *\tRemoves pre-existing connections from list returned by connection editor.\r\n     *  \r\n     *    @param [in/out] originalConnections     List containing the original connections. \r\n     *                                              Gets modified to contain only connections to be removed.\r\n     *    @param [in/out] updatedConnections      List containing the connections returned by connection editor. \r\n     *                                              Gets modified to contain only new connections.\r\n     */\r\n    void removeUnchangedConnectionEditorConnections(QList<QPair<AutoConnectorItem*, AutoConnectorItem*> >& originalConnections,\r\n        QList<QPair<AutoConnectorItem*, AutoConnectorItem*> >& updatedConnections) const;\r\n\r\n    /*!\r\n     *\tCreates add commands for given connections.\r\n     *  \r\n     *    @param [in] connections     Connections to create add commands for.\r\n     *    @param [in] parentCommand   The parent command for the created add commands.\r\n     */\r\n    void createAddCommandsForGivenConnections(QList<QPair<AutoConnectorItem*, AutoConnectorItem*> > const& connections, QUndoCommand* parentCommand);\r\n\r\n    /*!\r\n     *\tCreates remove commands for given connections.\r\n     *\r\n     *    @param [in] connections     Connections to create remove commands for.\r\n     *    @param [in] parentCommand   The parent command for the created remove commands.\r\n     */\r\n    void createRemoveCommandsForGivenConnections(QList<QPair<AutoConnectorItem*, AutoConnectorItem*> > const& connections, QUndoCommand* parentCommand);\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! The connection that is being drawn.\r\n    GraphicsConnection* tempConnection_;\r\n\r\n    //! The starting end point of a connection that is being drawn.\r\n    ConnectionEndpoint* connectionStartPoint_;\r\n\r\n    //! The potential end points that can be connected to the starting end point.\r\n    QVector<ConnectionEndpoint*> tempPotentialEndingEndPoints_;\r\n\r\n    //! The highlighted end point to which the connection could be snapped automatically.\r\n    ConnectionEndpoint* connectionEndPoint_;\r\n\r\n    //! The component that is used to replace another component in replace mode.\r\n    ComponentItem* sourceComp_;\r\n    \r\n    //! Old selected items.\r\n    QList<QGraphicsItem*> previouslySelectedItems_;\r\n\r\n    //! Context menu select all action.\r\n    QAction selectAllAction_;\r\n\r\n    //! Context menu copy action.\r\n    QAction copyAction_;\r\n\r\n    //! Context menu paste action.\r\n    QAction pasteAction_;\r\n\r\n    //! Context menu action for adding a draft component to library.\r\n    QAction addAction_;\r\n\r\n    //! Context menu action for opening a component.\r\n    QAction openComponentAction_;\r\n\r\n    //! Context menu action for deleting an item.\r\n    QAction deleteAction_;\r\n\r\n    //! Context menu sub-menu for opening a component design.\r\n    QMenu openDesignMenu_;\r\n\r\n    //! Context menu action for automatically connecting connection end points of two selected components.\r\n    QAction openAutoConnector_;\r\n\r\n    //! Cursor position where the user right-presses to open the context menu.\r\n    QPoint clickedPosition_;\r\n\r\n    //! Modifier for the x-axis in item visibility.\r\n    qreal visibleModifierX_ = 0;\r\n\r\n    //! Modifier for the y-axis in item visibility.\r\n    qreal visibleModifierY_ = 0;\r\n\r\n    //! Width of the visible rectangle in mouse position.\r\n    int const VISIBLERECTANGLEWIDTH_ = 100;\r\n\r\n    //! Height of the visible rectangle in mouse position.\r\n    int const VISIBLEWRECTANGLEHEIGHT_ = 100;\r\n\r\n    //! Multiplier for calculating the position of the mouse.\r\n    int const VISIBLEMULTIPLIER_ = 20;\r\n\r\n    //! The component item that was selected as the origin point of the context menu event.\r\n    ComponentItem* contextMenuItem_;\r\n\r\n    //! The pressed mouse button.\r\n    Qt::MouseButton lastMousePress_;\r\n\r\n    //! Check for moving item to be located in the right edge.\r\n    bool lastSelectedItemIsAtRightEdge_;\r\n\r\n    //! The endpoint which was last hovered over while creating a connection. Used to highligh the enpoint again\r\n    //  after not connecting to it. \r\n    ConnectionEndpoint* lastHoveredEndpoint_ = nullptr;\r\n};\r\n\r\n#endif // COMPONENTDESIGNDIAGRAM_H\r\n"
  },
  {
    "path": "editors/common/ComponentInstanceEditor/ComponentInstanceConfigurableElementsEditor.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: ComponentInstanceConfigurableElementsEditor.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 01.09.2017\n//\n// Description:\n// Editor for configurable elements of a component instance.\n//-----------------------------------------------------------------------------\n\n#include \"ComponentInstanceConfigurableElementsEditor.h\"\n\n#include <editors/common/ComponentInstanceEditor/ConfigurableElementsColumns.h>\n#include <editors/common/ComponentInstanceEditor/ConfigurableElementsFilter.h>\n#include <editors/common/ComponentInstanceEditor/ComponentInstanceConfigurableElementsModel.h>\n\n#include <IPXACTmodels/Component/Component.h>\n#include <IPXACTmodels/Design/ComponentInstance.h>\n\n#include <QVBoxLayout>\n\n//-----------------------------------------------------------------------------\n// Function: ComponentInstanceConfigurableElementsEditor::ComponentInstanceConfigurableElementsEditor()\n//-----------------------------------------------------------------------------\nComponentInstanceConfigurableElementsEditor::ComponentInstanceConfigurableElementsEditor(\n    ExpressionSet parameterExpressions,\n    ExpressionSet moduleParameterExpressions,\n    ExpressionSet defaultExpressions,\n    QAbstractItemModel* completionModel, QWidget *parent):\n    QWidget(parent),\n    parameterEditor_(parameterExpressions, defaultExpressions, completionModel, this),\n    moduleParameterEditor_(moduleParameterExpressions, defaultExpressions, nullptr, this)\n{\n    parameterEditor_.setTitle(tr(\"Parameters\"));\n    connect(&parameterEditor_, SIGNAL(contentChanged()), this, SIGNAL(contentChanged()), Qt::UniqueConnection);\n    connect(&parameterEditor_, SIGNAL(increaseReferences(QString)),\n        this, SIGNAL(increaseReferences(QString const&)), Qt::UniqueConnection);\n    connect(&parameterEditor_, SIGNAL(decreaseReferences(QString)),\n        this, SIGNAL(decreaseReferences(QString const&)), Qt::UniqueConnection);\n\n    moduleParameterEditor_.setTitle(tr(\"Module parameters\"));\n    connect(&moduleParameterEditor_, SIGNAL(contentChanged()), this, SIGNAL(contentChanged()), Qt::UniqueConnection);\n    connect(&moduleParameterEditor_, SIGNAL(increaseReferences(QString)),\n        this, SIGNAL(increaseReferences(QString const&)), Qt::UniqueConnection);\n    connect(&moduleParameterEditor_, SIGNAL(decreaseReferences(QString)),\n        this, SIGNAL(decreaseReferences(QString const&)), Qt::UniqueConnection);\n\n    auto layout = new QVBoxLayout(this);\n    layout->addWidget(&parameterEditor_);\n    layout->addWidget(&moduleParameterEditor_);\n    layout->setContentsMargins(0, 0, 0, 0);\n}\n\n//-----------------------------------------------------------------------------\n// Function: ComponentInstanceConfigurableElementsEditor::setComponent()\n//-----------------------------------------------------------------------------\nvoid ComponentInstanceConfigurableElementsEditor::setComponent(QSharedPointer<Component> component,\n    QSharedPointer<ComponentInstance> instance, QSharedPointer<ViewConfiguration> viewConfiguration,\n    QSharedPointer<IEditProvider> editProvider)\n{\n    parameterEditor_.setEditProvider(editProvider);\n    moduleParameterEditor_.setEditProvider(editProvider);\n    moduleParameterEditor_.clear();\n\n    auto identifier = tr(\"component %1\").arg(component->getVlnv().toString());\n    parameterEditor_.setParameters(identifier, component->getParameters(), component->getChoices(),\n        component->getRevision(), instance->getConfigurableElementValues());\n\n    QSharedPointer<QList<QSharedPointer<Parameter> > > moduleParameters(new QList<QSharedPointer<Parameter> >());\n\n    if (viewConfiguration && !viewConfiguration->getViewReference().isEmpty())\n    {\n        QString referencedView = viewConfiguration->getViewReference();\n        for (QSharedPointer<View> view : *component->getViews())\n        {\n            if (view->name() == referencedView)\n            {\n                QString referencedComponentInstantiation = view->getComponentInstantiationRef();\n                if (!referencedComponentInstantiation.isEmpty())\n                {\n                    for (QSharedPointer<ComponentInstantiation> instantiation : *component->getComponentInstantiations())\n                    {\n                        if (instantiation->name() == referencedComponentInstantiation)\n                        {\n                            for (QSharedPointer<ModuleParameter> moduleParameter : *instantiation->getModuleParameters())\n                            {\n                                moduleParameters->append(moduleParameter);\n                            }\n                        }\n                    }\n                }\n            }\n        }\n\n        moduleParameterEditor_.setParameters(identifier, moduleParameters, component->getChoices(), \n            component->getRevision(), viewConfiguration->getViewConfigurableElements());\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: ComponentInstanceConfigurableElementsEditor::clear()\n//-----------------------------------------------------------------------------\nvoid ComponentInstanceConfigurableElementsEditor::clear() \n{\n    parameterEditor_.clear();\n    moduleParameterEditor_.clear();\n}\n"
  },
  {
    "path": "editors/common/ComponentInstanceEditor/ComponentInstanceConfigurableElementsEditor.h",
    "content": "//-----------------------------------------------------------------------------\n// File: ComponentInstanceConfigurableElementsEditor.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 01.09.2017\n//\n// Description:\n// Editor for configurable elements of a component instance.\n//-----------------------------------------------------------------------------\n\n#ifndef COMPONENTINSTANCECONFIGURABLEELEMENTSEDITOR_H\n#define COMPONENTINSTANCECONFIGURABLEELEMENTSEDITOR_H\n\n#include <editors/common/ComponentInstanceEditor/configurableelementeditor.h>\n#include <editors/common/ExpressionSet.h>\n\n#include <IPXACTmodels/DesignConfiguration/DesignConfiguration.h>\n\n#include <QAbstractItemModel>\n#include <QSharedPointer>\n#include <QWidget>\n\nclass Component;\nclass ComponentInstance;\n\n//-----------------------------------------------------------------------------\n//! Editor for configurable elements of a component instance.\n//-----------------------------------------------------------------------------\nclass ComponentInstanceConfigurableElementsEditor : public QWidget\n{\n\tQ_OBJECT\n\npublic:\n\n\t/*!\n\t *  The constructor.\n\t *\n     *    @param [in] parameterExpressions            The expressions for selecting parameter references.\n     *    @param [in] moduleParameterExpressions      The expressions for selecting module parameter references.\n     *    @param [in] defaultExpressions              The expressions for resolving default values.\n     *    @param [in] completionModel                 The completion model for selecting parameter references.\n\t *    @param [in] parent                          The parent widget.\n\t */\n    ComponentInstanceConfigurableElementsEditor( ExpressionSet parameterExpressions,\n        ExpressionSet moduleParameterExpressions, ExpressionSet defaultExpressions, \n        QAbstractItemModel* completionModel, QWidget *parent);\n\t\n\t/*!\n     *  The destructor.\n     */\n    virtual ~ComponentInstanceConfigurableElementsEditor() = default;\n\n    //! No copying.\tNo assignment.\n    ComponentInstanceConfigurableElementsEditor(const ComponentInstanceConfigurableElementsEditor& other) = delete;\n    ComponentInstanceConfigurableElementsEditor& operator=(const ComponentInstanceConfigurableElementsEditor& other) = delete;\n\n\t/*!\n     *  Set the component instance to be edited.\n\t *\n\t *    @param [in] component           Pointer to the component referenced by the component instance.\n     *    @param [in] instance            Pointer to the component instance to edit.\n     *    @param [in] viewConfiguration   Pointer to the view configuration of the component instance.\n     *    @param [in] editProvider        Pointer to the editing capabilities.\n\t */\n    void setComponent(QSharedPointer<Component> component, QSharedPointer<ComponentInstance> instance,\n        QSharedPointer<ViewConfiguration> viewConfiguration, QSharedPointer<IEditProvider> editProvider);\n\n\t/*!\n     *  Clear the editor from all data.\n\t */\n\tvirtual void clear();\n\nsignals:\n\n    //! Emitted when the content of the editor has changed.\n\tvoid contentChanged();\n\n    /*!\n     *  Increase the amount of references to a parameter with the matching ID.\n     *\n     *    @param [in] id  ID of the parameter, whose references are being increased.\n     */\n    void increaseReferences(QString const& id);\n\n    /*!\n     *  Decrease the amount of references to a parameter with a matching ID.\n     *\n     *    @param [in] id  ID of the parameter, whose references are being decreased.\n     */\n    void decreaseReferences(QString const& id);\n\nprivate:\n\n    //! The editor for component instance parameters.\n\tConfigurableElementEditor parameterEditor_;\n\n    //! The editor for component instance module parameters.\n\tConfigurableElementEditor moduleParameterEditor_;\n\n};\n\n#endif // COMPONENTINSTANCECONFIGURABLEELEMENTSEDITOR_H\n"
  },
  {
    "path": "editors/common/ComponentInstanceEditor/ComponentInstanceConfigurableElementsFilter.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: ComponentInstanceConfigurableElementsFilter.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 23.08.2017\n//\n// Description:\n// A filter class for component instance configurable elements.\n//-----------------------------------------------------------------------------\n\n#include \"ComponentInstanceConfigurableElementsFilter.h\"\n\n#include <editors/common/ComponentInstanceEditor/ConfigurableElementsColumns.h>\n\n//-----------------------------------------------------------------------------\n// Function: ComponentInstanceConfigurableElementsFilter::ComponentInstanceConfigurableElementsFilter()\n//-----------------------------------------------------------------------------\nComponentInstanceConfigurableElementsFilter::ComponentInstanceConfigurableElementsFilter(QObject* parent):\nQSortFilterProxyModel(parent)\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: ComponentInstanceConfigurableElementsFilter::setShowImmediateValues()\n//-----------------------------------------------------------------------------\nvoid ComponentInstanceConfigurableElementsFilter::setShowImmediateValues(bool show)\n{\n    showImmediateValues_ = show;\n    invalidate();\n}\n\n//-----------------------------------------------------------------------------\n// Function: ComponentInstanceConfigurableElementsFilter::filterAcceptsRow()\n//-----------------------------------------------------------------------------\nbool ComponentInstanceConfigurableElementsFilter::filterAcceptsRow(int source_row,\n    QModelIndex const& source_parent) const\n{\n    if (!source_parent.isValid())\n    {\n        QModelIndex categoryIndex = sourceModel()->index(source_row, 0, QModelIndex());\n\n        return sourceModel()->rowCount(categoryIndex) != 0 &&\n            (indexContainsEditableChildren(categoryIndex) || showImmediateValues_);\n    }\n\n    else\n    {\n        QModelIndex itemIndex = sourceModel()->index(source_row, ConfigurableElementsColumns::VALUE, source_parent);\n        return (showImmediateValues_ || itemIndex.flags().testFlag(Qt::ItemIsEditable));\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: ComponentInstanceConfigurableElementsFilter::indexContainsEditableChildren()\n//-----------------------------------------------------------------------------\nbool ComponentInstanceConfigurableElementsFilter::indexContainsEditableChildren(QModelIndex const& index) const\n{\n    QModelIndex nameIndex = index.sibling(index.row(), ConfigurableElementsColumns::NAME);\n    QString indexName = nameIndex.data(Qt::DisplayRole).toString();\n\n    for (int i = 0; i < index.model()->rowCount(index); ++i)\n    {\n        QModelIndex childIndex = sourceModel()->index(i, ConfigurableElementsColumns::VALUE, index);\n        if (childIndex.flags().testFlag(Qt::ItemIsEditable))\n        {\n            return true;\n        }\n    }\n\n    return false;\n}\n\n//-----------------------------------------------------------------------------\n// Function: ComponentInstanceConfigurableElementsFilter::onInvalidateFilter()\n//-----------------------------------------------------------------------------\nvoid ComponentInstanceConfigurableElementsFilter::onInvalidateFilter()\n{\n    invalidate();\n}\n"
  },
  {
    "path": "editors/common/ComponentInstanceEditor/ComponentInstanceConfigurableElementsFilter.h",
    "content": "//-----------------------------------------------------------------------------\n// File: ComponentInstanceConfigurableElementsFilter.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 23.08.2017\n//\n// Description:\n// A filter class for component instance configurable elements.\n//-----------------------------------------------------------------------------\n\n#ifndef COMPONENTINSTANCECONFIGURABLESELEMENTFILTER_H\n#define COMPONENTINSTANCECONFIGURABLESELEMENTFILTER_H\n\n#include <QSortFilterProxyModel>\n#include <QModelIndex>\n\n//-----------------------------------------------------------------------------\n//! A filter class for component instance configurable elements.\n//-----------------------------------------------------------------------------\nclass ComponentInstanceConfigurableElementsFilter : public QSortFilterProxyModel\n{\n    Q_OBJECT\n\npublic:\n   \n    /*!\n     *  The constructor.\n     *\n     *    @param [in] parent  The owner of this filter.\n     */\n    ComponentInstanceConfigurableElementsFilter(QObject* parent);\n\n    /*!\n     *  Destructor.\n     */\n    virtual ~ComponentInstanceConfigurableElementsFilter() = default;\n\nprotected:\n\n    /*!\n     *  Validate the given row on a parent and check if the item should be shown.\n     *\n     *    @param [in] source_row      The row number of the child on the parent.\n     *    @param [in] source_parent   Model index that identifies the parent object.\n     *\n     *    @return True, if the object should be displayed, false otherwise.\n     */\n    virtual bool filterAcceptsRow(int source_row, const QModelIndex &source_parent) const;\n\npublic slots:\n   \n    /*!\n     *  Set the immediate values to be shown or hidden.\n     *\n     *    @param [in] show    Flag for displaying the immediate values.\n     */\n    void setShowImmediateValues(bool show);\n\n    /*!\n     *  Invalidate the filter.\n     */\n    void onInvalidateFilter();\n\nprivate:\n   \n    // Disable copying.\n    ComponentInstanceConfigurableElementsFilter(ComponentInstanceConfigurableElementsFilter const& rhs);\n    ComponentInstanceConfigurableElementsFilter& operator=(ComponentInstanceConfigurableElementsFilter const& rhs);\n\n    /*!\n     *  Check if the selected index contains editable children.\n     *\n     *    @param [in] index   The selected model index.\n     *\n     *    @return True, if the selected index contains editable children, false otherwise.\n     */\n    bool indexContainsEditableChildren(QModelIndex const& index) const;\n\n    //-----------------------------------------------------------------------------\n    // Data.\n    //-----------------------------------------------------------------------------\n\n    //! Flag for displaying configurable elements with immediate values.\n    bool showImmediateValues_ = false;\n};\n\n#endif // COMPONENTINSTANCECONFIGURABLESELEMENTFILTER_H\n"
  },
  {
    "path": "editors/common/ComponentInstanceEditor/ComponentInstanceConfigurableElementsModel.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: ComponentInstanceConfigurableElementsModel.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 17.08.2017\n//\n// Description:\n// Model class to manage the configurable element values of component instances.\n//-----------------------------------------------------------------------------\n\n#include \"ComponentInstanceConfigurableElementsModel.h\"\n\n#include <common/KactusColors.h>\n\n#include <editors/common/ComponentInstanceEditor/ConfigurableElementsColumns.h>\n#include <editors/common/ComponentInstanceEditor/ConfigurableElementsModel.h>\n#include <editors/common/ComponentInstanceEditor/ParameterConfigurableElementsFilter.h>\n#include <editors/common/ComponentInstanceEditor/MissingConfigurableElementsFilter.h>\n#include <editors/common/ComponentInstanceEditor/EditorConfigurableElement.h>\n\n#include <IPXACTmodels/common/Parameter.h>\n#include <IPXACTmodels/common/ModuleParameter.h>\n\n#include <IPXACTmodels/Component/Component.h>\n\n#include <IPXACTmodels/Design/ComponentInstance.h>\n\n#include <IPXACTmodels/DesignConfiguration/ViewConfiguration.h>\n\n//-----------------------------------------------------------------------------\n// Function: ComponentInstanceConfigurableElementsModel::ComponentInstanceConfigurableElementsModel()\n//-----------------------------------------------------------------------------\nComponentInstanceConfigurableElementsModel::ComponentInstanceConfigurableElementsModel(\n    QSharedPointer<ParameterFinder> parameterFinder, QSharedPointer<ConfigurableElementFinder> elementFinder,\n    QSharedPointer<ExpressionFormatter> elementExpressionFormatter,\n    QSharedPointer<ExpressionFormatter> defaultValueFormatter,\n    QSharedPointer<ExpressionParser> elementExpressionParser, QSharedPointer<ExpressionParser> defaultValueParser,\n    QObject* parent):\n    ConfigurableElementsModel(parameterFinder, elementExpressionFormatter, defaultValueFormatter, \n        elementExpressionParser, defaultValueParser, parent),\nelementFinder_(elementFinder)\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: ComponentInstanceConfigurableElementsModel::setParameters()\n//-----------------------------------------------------------------------------\nvoid ComponentInstanceConfigurableElementsModel::setParameters(QSharedPointer<Component> component,\n    QSharedPointer<ComponentInstance> instance, QSharedPointer<ViewConfiguration> viewConfiguration)\n{\n    \n    QSharedPointer<QList<QSharedPointer<ConfigurableElementValue> > > instanceConfigurableElements(\n        new QList<QSharedPointer<ConfigurableElementValue> > ());\n\n    if (instance)\n    {\n        instanceConfigurableElements->append(*instance->getConfigurableElementValues());\n    }\n    if (viewConfiguration)\n    {\n        instanceConfigurableElements->append(*viewConfiguration->getViewConfigurableElements());\n    }\n\n    containingItemName_ = instance->getInstanceName();\n    choices_ = component->getChoices();\n    itemConfigurableElementValues_ = instanceConfigurableElements;\n\n    beginResetModel();\n\n    configurableElements_.clear();\n\n    QSharedPointer<QList<QSharedPointer<Parameter> > > parameters = component->getParameters();\n    if (parameters)\n    {\n        for (QSharedPointer<Parameter> parameterPointer : *parameters)\n        {\n            QString configuratedValue = parameterPointer->getValue();\n            QString evaluatedDefaultValue = evaluateValue(ConfigurableElementsColumns::DEFAULT_VALUE,\n                parameterPointer->getChoiceRef(), parameterPointer->getValue());\n\n            QSharedPointer<EditorConfigurableElement> newElement(new EditorConfigurableElement(\n                parameterPointer, evaluatedDefaultValue, configuratedValue));\n            configurableElements_.append(newElement);\n        }\n    }\n\n    QSharedPointer<QList<QSharedPointer<Parameter> > > moduleParameters =\n        getModuleParameters(component, viewConfiguration);\n    if (moduleParameters)\n    {\n        for (QSharedPointer<Parameter> moduleParameterPointer : *moduleParameters)\n        {\n            QString configuratedValue = moduleParameterPointer->getValue();\n            QString evaluatedDefaultValue = evaluateValue(ConfigurableElementsColumns::DEFAULT_VALUE,\n                moduleParameterPointer->getChoiceRef(), moduleParameterPointer->getValue());\n\n            QSharedPointer<EditorConfigurableElement> newElement(new EditorConfigurableElement(\n                moduleParameterPointer, evaluatedDefaultValue, configuratedValue));\n\n            configurableElements_.append(newElement);\n        }\n    }\n\n    validator_->componentChange(component->getChoices(), component->getRevision());\n\n    restoreStoredConfigurableElements();\n\n    elementFinder_->setConfigurableElementList(configurableElements_);\n\n    endResetModel();\n}\n\n//-----------------------------------------------------------------------------\n// Function: ComponentInstanceConfigurableElementsModel::getModuleParameters()\n//-----------------------------------------------------------------------------\nQSharedPointer<QList<QSharedPointer<Parameter> > > ComponentInstanceConfigurableElementsModel::\n    getModuleParameters(QSharedPointer<Component> component, QSharedPointer<ViewConfiguration> viewConfiguration)\n{\n    QSharedPointer<QList<QSharedPointer<Parameter> > > parameters (new QList<QSharedPointer<Parameter> > ());\n\n    if (viewConfiguration && !viewConfiguration->getViewReference().isEmpty())\n    {\n        QString referencedView = viewConfiguration->getViewReference();\n        for (QSharedPointer<View> view : *component->getViews())\n        {\n            if (view->name() == referencedView)\n            {\n                QString referencedComponentInstantiation = view->getComponentInstantiationRef();\n                if (!referencedComponentInstantiation.isEmpty())\n                {\n                    for (QSharedPointer<ComponentInstantiation> instantiation : *component->getComponentInstantiations())\n                    {\n                        if (instantiation->name() == referencedComponentInstantiation)\n                        {\n                            for (QSharedPointer<ModuleParameter> moduleParameter : *instantiation->getModuleParameters())\n                            {\n                                parameters->append(moduleParameter);\n                            }\n                            break;\n                        }\n                    }\n                }\n\n                break;\n            }\n        }\n    }\n\n    return parameters;\n}\n"
  },
  {
    "path": "editors/common/ComponentInstanceEditor/ComponentInstanceConfigurableElementsModel.h",
    "content": "//-----------------------------------------------------------------------------\n// File: ComponentInstanceConfigurableElementsModel.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 17.08.2017\n//\n// Description:\n// Model class to manage the configurable element values of component instances.\n//-----------------------------------------------------------------------------\n\n#ifndef COMPONENTINSTANCECONFIGURABLEELEMENTSMODEL_H\n#define COMPONENTINSTANCECONFIGURABLEELEMENTSMODEL_H\n\n#include <KactusAPI/include/ExpressionFormatter.h>\n#include <editors/ComponentEditor/common/ConfigurableElementFinder.h>\n#include <editors/common/ComponentInstanceEditor/ConfigurableElementsModel.h>\n\n#include <IPXACTmodels/common/validators/ParameterValidator.h>\n\n#include <IPXACTmodels/DesignConfiguration/DesignConfiguration.h>\n\n#include <QAbstractTableModel>\n#include <QList>\n#include <QString>\n#include <QSharedPointer>\n#include <QSortFilterProxyModel>\n\nclass Parameter;\nclass ModuleParameter;\nclass Choice;\nclass ComponentInstance;\nclass Component;\n\n//-----------------------------------------------------------------------------\n//! Model class to manage the configurable element values of component instances.\n//-----------------------------------------------------------------------------\nclass ComponentInstanceConfigurableElementsModel : public ConfigurableElementsModel\n{\n\tQ_OBJECT\n\npublic:\n\n\t/*!\n\t *  The constructor.\n\t *\n\t *    @param [in] parameterFinder             The parameter finder.\n\t *    @param [in] elementFinder               Configurable elements finder.\n\t *    @param [in] elementExpressionFormatter  Expression formatter for configurable element values.\n\t *    @param [in] defaultValueFormatter       Expression formatter for default values.\n\t *    @param [in] elementExpressionParser     Parser for configurable element values.\n\t *    @param [in] defaultValueParser          Parser for default values.\n\t *    @param [in] parent                      The parent object.\n\t */\n\tComponentInstanceConfigurableElementsModel(QSharedPointer<ParameterFinder> parameterFinder,\n        QSharedPointer<ConfigurableElementFinder> elementFinder,\n        QSharedPointer<ExpressionFormatter> elementExpressionFormatter,\n        QSharedPointer<ExpressionFormatter> defaultValueFormatter,\n        QSharedPointer<ExpressionParser> elementExpressionParser,\n        QSharedPointer<ExpressionParser> defaultValueParser, QObject* parent);\n\n\t/*!\n\t *  The destructor.\n\t */\n    virtual ~ComponentInstanceConfigurableElementsModel() = default;\n\n\t/*!\n\t *  Set the parameters for configurable element values.\n\t *\n\t *    @param [in] component           Pointer to the component referenced by the component instance.\n     *    @param [in] instance            Pointer to the component instance being edited.\n     *    @param [in] viewConfiguration   Pointer to the active view of the instanced component.\n\t */\n    void setParameters(QSharedPointer<Component> component, QSharedPointer<ComponentInstance> instance,\n        QSharedPointer<ViewConfiguration> viewConfiguration);\n\nsignals:\n\n    /*!\n     *  Signal for connecting the root item models to the flag for displaying immediate values.\n     *\n     *    @param [in] show    Flag for displaying the immediate values.\n     */\n    void showImmediateValuesInModels(bool show);\n\n    /*!\n     *  Emitted to invalidate the assigned filter.\n     */\n    void invalidateFilter();\n\nprivate:\n\n    //! No copying. //! No assignment.\n    ComponentInstanceConfigurableElementsModel(const ComponentInstanceConfigurableElementsModel& other);\n    ComponentInstanceConfigurableElementsModel& operator=(const ComponentInstanceConfigurableElementsModel& other);\n\n    /*!\n     *  Get the list of contained module parameters.\n     *\n     *    @param [in] component           The component containing the module parameters.\n     *    @param [in] viewConfiguration   View configuration assigned to the component instance.\n     *\n     *    @return Module parameters contained within the selected view configuration.\n     */\n    QSharedPointer<QList<QSharedPointer<Parameter> > > getModuleParameters(\n        QSharedPointer<Component> component, QSharedPointer<ViewConfiguration> viewConfiguration);\n\n    //-----------------------------------------------------------------------------\n    // Data.\n    //-----------------------------------------------------------------------------\n\n    //! The configurable element finder.\n    QSharedPointer<ConfigurableElementFinder> elementFinder_;\n};\n\n#endif // COMPONENTINSTANCECONFIGURABLEELEMENTSMODEL_H\n"
  },
  {
    "path": "editors/common/ComponentInstanceEditor/ConfigurableElementsColumns.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ConfigurableElementColumns.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Mikko Teuho\r\n// Date: 30.01.2015\r\n//\r\n// Description:\r\n// Common declarations for editing configurable element values.\r\n//-----------------------------------------------------------------------------\r\n\r\nnamespace ConfigurableElementsColumns\r\n{\r\n    //-----------------------------------------------------------------------------\r\n    // Constants defining which column represents what kind of information.\r\n    //-----------------------------------------------------------------------------\r\n    enum Columns\r\n    {\r\n        NAME,               //!< Column for the name of the configurable element.\r\n        VALUE,              //!< Column for the configurable value.\r\n        DEFAULT_VALUE,      //!< Column for the original value of the parameter.\r\n        CHOICE,             //!< Column for the selected choice of the parameter.\r\n        ARRAY_LEFT,         //!< Column for the left side of the parameters array.\r\n        ARRAY_RIGHT,        //!< Column for the right side of the parameters array.\r\n        COLUMN_COUNT\r\n    };\r\n}\r\n"
  },
  {
    "path": "editors/common/ComponentInstanceEditor/ConfigurableElementsFilter.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ConfigurableElementsFilter.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Mikko Teuho\r\n// Date: 30.03.2015\r\n//\r\n// Description:\r\n// A filter class for configurable elements.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"ConfigurableElementsFilter.h\"\r\n\r\n#include <editors/common/ComponentInstanceEditor/ConfigurableElementsColumns.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ConfigurableElementsFilter::ConfigurableElementsFilter()\r\n//-----------------------------------------------------------------------------\r\nConfigurableElementsFilter::ConfigurableElementsFilter(QObject* parent):\r\nQSortFilterProxyModel(parent)\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ConfigurableElementsView::setShowImmediateValues()\r\n//-----------------------------------------------------------------------------\r\nvoid ConfigurableElementsFilter::setShowImmediateValues(bool show)\r\n{\r\n    showImmediateValues_ = show;\r\n    invalidate();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ConfigurableElementsView::onRemoveItem()\r\n//-----------------------------------------------------------------------------\r\nvoid ConfigurableElementsFilter::onRemoveItem(QModelIndex const& filterIndex)\r\n{\r\n    emit removeItem(mapToSource(filterIndex));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ConfigurableElementsFilter::filterAcceptsRow()\r\n//-----------------------------------------------------------------------------\r\nbool ConfigurableElementsFilter::filterAcceptsRow(int source_row, QModelIndex const& source_parent) const\r\n{\r\n    bool itemIsEditable = itemAtIndexIsEditable(source_row, source_parent);\r\n\r\n    return showImmediateValues_ || itemIsEditable;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ConfigurableElementsFilter::itemAtIndexIsEditable()\r\n//-----------------------------------------------------------------------------\r\nbool ConfigurableElementsFilter::itemAtIndexIsEditable(int sourceRow, QModelIndex const& sourceParent) const\r\n{\r\n    QModelIndex itemIndex = sourceModel()->index(sourceRow, ConfigurableElementsColumns::VALUE, sourceParent);\r\n    return itemIndex.flags().testFlag(Qt::ItemIsEditable);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ConfigurableElementsFilter::immediateValuesAreVisible()\r\n//-----------------------------------------------------------------------------\r\nbool ConfigurableElementsFilter::immediateValuesAreVisible() const\r\n{\r\n    return showImmediateValues_;\r\n}\r\n"
  },
  {
    "path": "editors/common/ComponentInstanceEditor/ConfigurableElementsFilter.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ConfigurableElementsFilter.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Mikko Teuho\r\n// Date: 30.03.2015\r\n//\r\n// Description:\r\n// A filter class for configurable elements.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef CONFIGURABLESELEMENTFILTER_H\r\n#define CONFIGURABLESELEMENTFILTER_H\r\n\r\n#include <QSortFilterProxyModel>\r\n#include <QModelIndex>\r\n\r\n//-----------------------------------------------------------------------------\r\n//! A filter class for configurable elements.\r\n//-----------------------------------------------------------------------------\r\nclass ConfigurableElementsFilter : public QSortFilterProxyModel\r\n{\r\n    Q_OBJECT\r\n\r\npublic:\r\n   \r\n    /*!\r\n     *  The constructor.\r\n     *\r\n     *    @param [in] parent  The owner of this filter.\r\n     */\r\n    ConfigurableElementsFilter(QObject* parent);\r\n\r\n    /*!\r\n     *  Destructor.\r\n     */\r\n    virtual ~ConfigurableElementsFilter() = default;\r\n\r\n    // Disable copying.\r\n    ConfigurableElementsFilter(ConfigurableElementsFilter const& rhs) = delete;\r\n    ConfigurableElementsFilter& operator=(ConfigurableElementsFilter const& rhs) = delete;\r\n   \r\nsignals:\r\n\r\n    /*!\r\n     *  Emitted when the user attempts to remove an item.\r\n     *\r\n     *    @param [in] index   The index of the item to be removed.\r\n     */\r\n    void removeItem(QModelIndex const& index);\r\n\r\nprotected:\r\n\r\n    /*!\r\n     *  Validate the given row on a parent and check if the item should be shown.\r\n     *\r\n     *    @param [in] source_row      The row number of the child on the parent.\r\n     *    @param [in] source_parent   Model index that identifies the parent object.\r\n     *\r\n     *    @return True, if the object should be displayed, false otherwise.\r\n     */\r\n    bool filterAcceptsRow(int source_row, const QModelIndex &source_parent) const override;\r\n\r\n    /*!\r\n     *  Check if the immediate values are visible.\r\n     *\r\n     *    @return True, if the immediate values are visible, false otherwise.\r\n     */\r\n    bool immediateValuesAreVisible() const;\r\n\r\n    /*!\r\n     *  Check if the item at the selected index is visible.\r\n     *\r\n     *    @param [in] sourceRow       Row of the selected index.\r\n     *    @param [in] sourceParent    Parent index of the selected item.\r\n     *\r\n     *    @return True, if the indexed item is visible, false otherwise.\r\n     */\r\n    bool itemAtIndexIsEditable(int sourceRow, QModelIndex const& sourceParent) const;\r\n\r\npublic slots:\r\n   \r\n     /*!\r\n      *  Set the flag for displaying the immediate values.\r\n      *\r\n      *    @param [in] show   Flag for displaying the immediate values.\r\n      */\r\n     void setShowImmediateValues(bool show);\r\n\r\n    /*!\r\n     *  Removes an item of the given index from the model.\r\n     *\r\n     *    @param [in] filterIndex     The index of the item to be removed.\r\n     */\r\n    void onRemoveItem(QModelIndex const& filterIndex);\r\n\r\nprivate:\r\n   \r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! Flag for displaying the immediate values.\r\n    bool showImmediateValues_ = false;\r\n};\r\n\r\n#endif // CONFIGURABLESELEMENTFILTER_H\r\n"
  },
  {
    "path": "editors/common/ComponentInstanceEditor/ConfigurableElementsModel.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ConfigurableElementsModel.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 12.08.2011\r\n//\r\n// Description:\r\n// Model class to manage the configurable element values being edited.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"ConfigurableElementsModel.h\"\r\n\r\n#include <common/KactusColors.h>\r\n\r\n#include <KactusAPI/include/ExpressionParser.h>\r\n\r\n#include <editors/common/ComponentInstanceEditor/ConfigurableElementsColumns.h>\r\n\r\n#include <IPXACTmodels/common/Parameter.h>\r\n#include <IPXACTmodels/common/validators/ValueFormatter.h>\r\n#include <IPXACTmodels/common/ConfigurableElementValue.h>\r\n#include <IPXACTmodels/common/Choice.h>\r\n\r\n#include <QStringBuilder>\r\n#include <QIcon>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ConfigurableElementsModel::ConfigurableElementsModel()\r\n//-----------------------------------------------------------------------------\r\nConfigurableElementsModel::ConfigurableElementsModel(QSharedPointer<ParameterFinder> parameterFinder,\r\n    QSharedPointer<ExpressionFormatter> configurableElementExpressionFormatter,\r\n    QSharedPointer<ExpressionFormatter> defaultValueFormatter,\r\n    QSharedPointer<ExpressionParser> configurableElementExpressionParser,\r\n    QSharedPointer<ExpressionParser> defaultValueParser, QObject *parent):\r\nQAbstractItemModel(parent),\r\nParameterizableTable(parameterFinder),\r\nconfigurableElementExpressionFormatter_(configurableElementExpressionFormatter),\r\nconfigurableElementExpressionParser_(configurableElementExpressionParser),\r\ndefaultValueFormatter_(defaultValueFormatter),\r\ndefaultValueParser_(defaultValueParser)\r\n{\r\n    setExpressionParser(configurableElementExpressionParser);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ConfigurableElementsModel::setParameters()\r\n//-----------------------------------------------------------------------------\r\nvoid ConfigurableElementsModel::setParameters(QString const& containingItemName,\r\n    QSharedPointer<QList<QSharedPointer<Parameter> > > parameters,\r\n    QSharedPointer<QList<QSharedPointer<Choice> > > choices,\r\n    Document::Revision docRevision,\r\n    QSharedPointer<QList<QSharedPointer<ConfigurableElementValue> > > storedConfigurableElements)\r\n{\r\n    QSharedPointer<QList<QSharedPointer<Choice> > > noChoices(new QList<QSharedPointer<Choice> >());\r\n    validator_ = QSharedPointer<ParameterValidator>(\r\n        new ParameterValidator(configurableElementExpressionParser_, noChoices, docRevision));\r\n\r\n    containingItemName_ = containingItemName;\r\n    choices_ = choices;\r\n    itemConfigurableElementValues_ = storedConfigurableElements;\r\n\r\n    beginResetModel();\r\n\r\n    configurableElements_.clear();\r\n\r\n    if (parameters)\r\n    {\r\n        for (QSharedPointer<Parameter> parameterPointer : *parameters)\r\n        {\r\n            QString configuratedValue = parameterPointer->getValue();\r\n            QString evaluatedDefaultValue = evaluateValue(ConfigurableElementsColumns::DEFAULT_VALUE,\r\n                parameterPointer->getChoiceRef(), parameterPointer->getValue());\r\n\r\n            QSharedPointer<EditorConfigurableElement> newElement(new EditorConfigurableElement(\r\n                parameterPointer, evaluatedDefaultValue, configuratedValue));\r\n            configurableElements_.append(newElement);\r\n        }\r\n    }\r\n    \r\n    validator_->componentChange(choices, docRevision);\r\n\r\n    restoreStoredConfigurableElements();\r\n\r\n    endResetModel();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ConfigurableElementsModel::clear()\r\n//-----------------------------------------------------------------------------\r\nvoid ConfigurableElementsModel::clear() \r\n{\r\n\tbeginResetModel();\r\n    configurableElements_.clear();\r\n\tendResetModel();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ConfigurableElementsModel::rowCount()\r\n//-----------------------------------------------------------------------------\r\nint ConfigurableElementsModel::rowCount(QModelIndex const& parent) const \r\n{\r\n    if (!parent.isValid())\r\n    {\r\n        return configurableElements_.size();\r\n    }\r\n\r\n    return 0;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ConfigurableElementsModel::columnCount()\r\n//-----------------------------------------------------------------------------\r\nint ConfigurableElementsModel::columnCount(QModelIndex const& /*parent*/) const \r\n{\r\n    return ConfigurableElementsColumns::COLUMN_COUNT;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ConfigurableElementsModel::data()\r\n//-----------------------------------------------------------------------------\r\nQVariant ConfigurableElementsModel::data(QModelIndex const& index, int role) const \r\n{\r\n    if (role == getItemConfigurableElementValuesRole)\r\n    {\r\n        return QVariant::fromValue(getItemConfigurableElementValues());\r\n    }\r\n    else if (role == getConfigurableElementsFromTableRole)\r\n    {\r\n        return QVariant::fromValue(getConfigurableElements());\r\n    }\r\n    else if (!isIndexValid(index))\r\n    {\r\n        return QVariant();\r\n    }\r\n\r\n    QSharedPointer<EditorConfigurableElement> element = configurableElements_.at(index.row());\r\n\r\n    if (role == Qt::ForegroundRole)\r\n    {\r\n        if (element->getEvaluatedDefaultValue().isEmpty())\r\n        {\r\n            return KactusColors::ERROR;\r\n        }\r\n        else if (index.column() == ConfigurableElementsColumns::VALUE && isParameterEditable(index))\r\n        {\r\n            return blackForValidOrRedForInvalidIndex(index);\r\n        }\r\n        else\r\n        {\r\n            return KactusColors::DISABLED_TEXT;\r\n        }\r\n    }\r\n\telse if (role == Qt::DisplayRole) \r\n    {\r\n        return valueForIndex(index);\r\n\t}\r\n    else if (role == Qt::EditRole)\r\n    {\r\n        return expressionOrValueForIndex(index);\r\n    }\r\n    else if (role == Qt::ToolTipRole)\r\n    {\r\n        return tooltipForIndex(index);\r\n    }\r\n    else if (role == Qt::FontRole)\r\n    {\r\n        return italicForEvaluatedValue(index);\r\n    }\r\n    else if (role == Qt::DecorationRole)\r\n    {\r\n        if (index.parent().isValid() && index.column() == ConfigurableElementsColumns::NAME &&\r\n            !element->getReferencedParameter()->getChoiceRef().isEmpty())\r\n        {\r\n            return QIcon(\":/icons/common/graphics/paginator.png\");\r\n        }\r\n    }\r\n    else if (role == deletableElementCheckRole)\r\n    {\r\n        return isElementDeletable(index);\r\n    }\r\n    else if (role == parameterIDRole)\r\n    {\r\n        return parameterIDForIndex(index);\r\n    }\r\n\r\n    return QVariant();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ConfigurableElementsModel::headerData()\r\n//-----------------------------------------------------------------------------\r\nQVariant ConfigurableElementsModel::headerData(int section, Qt::Orientation orientation, int role) const \r\n{\r\n\tif (role == Qt::DisplayRole && orientation == Qt::Horizontal) \r\n    {\r\n        if (section == ConfigurableElementsColumns::NAME)\r\n        {\r\n            return tr(\"Name\");\r\n        }\r\n        else if (section == ConfigurableElementsColumns::VALUE)\r\n        {\r\n            QString valueHeader = tr(\"Value\") % getExpressionSymbol();\r\n            return valueHeader;\r\n        }\r\n        else if (section == ConfigurableElementsColumns::DEFAULT_VALUE)\r\n        {\r\n            return tr(\"Default value\");\r\n        }\r\n        else if (section == ConfigurableElementsColumns::CHOICE)\r\n        {\r\n            return tr(\"Choice\");\r\n        }\r\n        else if (section == ConfigurableElementsColumns::ARRAY_LEFT)\r\n        {\r\n            return tr(\"Array left\");\r\n        }\r\n        else if (section == ConfigurableElementsColumns::ARRAY_RIGHT)\r\n        {\r\n            return tr(\"Array right\");\r\n        }\r\n    }\r\n\r\n    return QVariant();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ConfigurableElementsModel::setData()\r\n//-----------------------------------------------------------------------------\r\nbool ConfigurableElementsModel::setData(QModelIndex const& index, QVariant const& value, int role) \r\n{\r\n    if (!isIndexValid(index))\r\n    {\r\n        return false;\r\n    }\r\n    \r\n    if (role == Qt::EditRole && index.column() == ConfigurableElementsColumns::VALUE)\r\n    {\r\n        QSharedPointer<EditorConfigurableElement> element = configurableElements_.at(index.row());\r\n\r\n        // Return default value or set new value.\r\n        if (!value.isValid() || value.toString().isEmpty() ||\r\n            value.toString() == element->getReferencedParameter()->getValue())\r\n        {\r\n            element->setConfiguratedValue(element->getReferencedParameter()->getValue());\r\n        }\r\n        else\r\n        {\r\n            element->setConfiguratedValue(value.toString());\r\n        }\r\n\r\n        emit dataChanged(index, index);\r\n        emit contentChanged();\r\n        return true;\r\n    }\r\n\r\n    return false;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ConfigurableElementsModel::flags()\r\n//-----------------------------------------------------------------------------\r\nQt::ItemFlags ConfigurableElementsModel::flags(QModelIndex const& index) const \r\n{\r\n\tif (!index.isValid())\r\n    {\r\n\t\treturn Qt::NoItemFlags;\r\n    }\r\n\r\n    if (!isParameterEditable(index))\r\n    {\r\n        return Qt::ItemIsSelectable | Qt::ItemIsEnabled;\r\n    }\r\n\r\n    if (index.column() == ConfigurableElementsColumns::VALUE)\r\n    {\r\n    \treturn Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsEditable;\r\n    }\r\n    else\r\n    {\r\n        return Qt::ItemIsSelectable | Qt::ItemIsEnabled;\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ConfigurableElementsModel::isParameterEditable()\r\n//-----------------------------------------------------------------------------\r\nbool ConfigurableElementsModel::isParameterEditable(QModelIndex const& index) const\r\n{\r\n    if (isIndexValid(index))\r\n    {\r\n        QSharedPointer<EditorConfigurableElement> element = configurableElements_.at(index.row());\r\n\r\n        return (!element->getReferencedParameter()->getValueResolve().isEmpty() &&\r\n            element->getReferencedParameter()->getValueResolve().compare(QStringLiteral(\"immediate\")) != 0);\r\n    }\r\n\r\n    return false;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ConfigurableElementsModel::isValidExpressionColumn()\r\n//-----------------------------------------------------------------------------\r\nbool ConfigurableElementsModel::isValidExpressionColumn(QModelIndex const& index) const\r\n{\r\n    return index.column() == ConfigurableElementsColumns::VALUE ||\r\n        index.column() == ConfigurableElementsColumns::DEFAULT_VALUE;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ConfigurableElementsModel::valueForIndex()\r\n//-----------------------------------------------------------------------------\r\nQVariant ConfigurableElementsModel::valueForIndex(QModelIndex const& index) const\r\n{\r\n    if (!isIndexValid(index))\r\n    {\r\n        return false;\r\n    }\r\n\r\n    QSharedPointer<EditorConfigurableElement> element = configurableElements_.at(index.row());\r\n\r\n    if (index.column() == ConfigurableElementsColumns::NAME)\r\n    {\r\n        return element->getReferencedParameter()->name();\r\n    }\r\n    else if (index.column() == ConfigurableElementsColumns::VALUE)\r\n    {\r\n        return evaluateValue(index.column(), element->getReferencedParameter()->getChoiceRef(),\r\n            element->getConfiguratedValue());\r\n    }\r\n    else if (index.column() == ConfigurableElementsColumns::DEFAULT_VALUE)\r\n    {\r\n        return element->getEvaluatedDefaultValue();\r\n    }\r\n    else if (index.column() == ConfigurableElementsColumns::CHOICE)\r\n    {\r\n        return element->getReferencedParameter()->getChoiceRef();\r\n    }\r\n    else if (index.column() == ConfigurableElementsColumns::ARRAY_LEFT)\r\n    {\r\n        return element->getReferencedParameter()->getArrayLeft();\r\n    }\r\n    else if (index.column() == ConfigurableElementsColumns::ARRAY_RIGHT)\r\n    {\r\n        return element->getReferencedParameter()->getArrayRight();\r\n    }\r\n\r\n    return QVariant();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ConfigurableElementsModel::evaluateValueForIndex()\r\n//-----------------------------------------------------------------------------\r\nQString ConfigurableElementsModel::evaluateValue(int column, QString const& choiceName,\r\n    QString const& value) const\r\n{\r\n    if (!choiceName.isEmpty())\r\n    {\r\n        QSharedPointer<Choice> choice = findChoice(choiceName);\r\n\r\n        if (value.contains(QLatin1Char('{')) && value.contains(QLatin1Char('}')))\r\n        {\r\n            return matchArrayValuesToSelectedChoice(choice, value);\r\n        }\r\n        else\r\n        {\r\n            return findDisplayValueForEnumeration(choice, value);\r\n        }\r\n    }\r\n    else if (column == ConfigurableElementsColumns::VALUE)\r\n    {\r\n        return ParameterizableTable::formattedValueFor(value);\r\n    }\r\n    else\r\n    {\r\n        return formattedValueFor(value);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ConfigurableElementsModel::formattedValueFor()\r\n//-----------------------------------------------------------------------------\r\nQString ConfigurableElementsModel::formattedValueFor(QString const& expression) const\r\n{\r\n    bool isValidExpression = false;\r\n    QString value = defaultValueParser_->parseExpression(expression, &isValidExpression);\r\n    if (isValidExpression)\r\n    {\r\n        ValueFormatter formatter;\r\n        return formatter.format(value,\r\n            defaultValueParser_->baseForExpression(expression));\r\n    }\r\n    else\r\n    {\r\n        return QStringLiteral(\"n/a\");\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ConfigurableElementsModel::findChoice()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<Choice> ConfigurableElementsModel::findChoice(QString const& choiceName) const\r\n{\r\n    for (auto const& choice : *choices_)\r\n    {\r\n        if (choice->name().compare(choiceName) == 0)\r\n        {\r\n            return choice;\r\n        }\r\n    }\r\n\r\n    return QSharedPointer<Choice>(new Choice());\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ConfigurableElementsModel::matchArrayValuesToSelectedChoice()\r\n//-----------------------------------------------------------------------------\r\nQString ConfigurableElementsModel::matchArrayValuesToSelectedChoice(QSharedPointer<Choice> choice,\r\n    QString const& arrayValue) const\r\n{\r\n    QStringList parameterArray = arrayValue.split(',');\r\n    parameterArray.first().remove('{');\r\n    parameterArray.last().remove('}');\r\n\r\n    QStringList resultingArray;\r\n\r\n    for (QString const& value : parameterArray)\r\n    {\r\n        resultingArray.append(findDisplayValueForEnumeration(choice, value));\r\n    }\r\n\r\n    QString choiceValue = resultingArray.join(',');\r\n    choiceValue.prepend('{');\r\n    choiceValue.append('}');\r\n\r\n    return choiceValue;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ConfigurableElementsModel::findDisplayValueForEnumeration()\r\n//-----------------------------------------------------------------------------\r\nQString ConfigurableElementsModel::findDisplayValueForEnumeration(QSharedPointer<Choice> choice,\r\n    QString const& enumerationValue) const\r\n{\r\n    QString value = parseExpressionToDecimal(enumerationValue);\r\n    for (auto const& enumeration : *choice->enumerations())\r\n    {\r\n        if (enumeration->getValue().compare(value) == 0 && !enumeration->getText().isEmpty())\r\n        {\r\n            return enumeration->getText();\r\n        }\r\n    }\r\n\r\n    return value;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ConfigurableElementsModel::expressionOrValueForIndex()\r\n//-----------------------------------------------------------------------------\r\nQVariant ConfigurableElementsModel::expressionOrValueForIndex(QModelIndex const& index) const\r\n{\r\n    if (!isIndexValid(index))\r\n    {\r\n        return false;\r\n    }\r\n\r\n    QSharedPointer<EditorConfigurableElement> element = configurableElements_.at(index.row());\r\n\r\n    if (index.column() == ConfigurableElementsColumns::NAME)\r\n    {\r\n        return element->getReferencedParameter()->name();\r\n    }\r\n    else if (index.column() == ConfigurableElementsColumns::VALUE)\r\n    {\r\n        return element->getConfiguratedValue();\r\n    }\r\n    else if (index.column() == ConfigurableElementsColumns::DEFAULT_VALUE)\r\n    {\r\n        return element->getReferencedParameter()->getValue();\r\n    }\r\n\r\n    return data(index, Qt::DisplayRole);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ConfigurableElementsModel::tooltipForIndex()\r\n//-----------------------------------------------------------------------------\r\nQString ConfigurableElementsModel::tooltipForIndex(QModelIndex const& index) const\r\n{\r\n    if (!isIndexValid(index))\r\n    {\r\n        return QString();\r\n    }\r\n\r\n    QSharedPointer<EditorConfigurableElement> element = configurableElements_.at(index.row());\r\n\r\n    if (element->getEvaluatedDefaultValue().isEmpty())\r\n    {\r\n        return QString(\"This parameter was not found in \" + containingItemName_ + \".\");\r\n    }\r\n    else if (index.column() == ConfigurableElementsColumns::NAME)\r\n    {\r\n        QString tooltip(element->getReferencedParameter()->name());\r\n        if (!element->getReferencedParameter()->getChoiceRef().isEmpty())\r\n        {\r\n            QSharedPointer<Choice> choice = findChoice(element->getReferencedParameter()->getChoiceRef());\r\n            tooltip.append(\"<br>Possible values are:\");\r\n\r\n            for (auto const& enumeration : *choice->enumerations())\r\n            {\r\n                tooltip.append(\"<br>\" % enumeration->getValue());\r\n                if (!enumeration->getText().isEmpty())\r\n                {\r\n                    tooltip.append(\" (\" % enumeration->getText() % \")\");\r\n                }\r\n            }\r\n        }\r\n\r\n        return tooltip;\r\n    }\r\n\r\n    else if (index.column() == ConfigurableElementsColumns::VALUE)\r\n    {\r\n        QString context = containingItemName_;\r\n        QString defaultValue = element->getReferencedParameter()->getValue();\r\n\r\n        QVector<QString> errorList;\r\n\r\n        // Swap the parameter value and validate as if the value was the configurable value.\r\n        element->getReferencedParameter()->setValue(element->getConfiguratedValue());\r\n        validator_->findErrorsIn(errorList, element->getReferencedParameter(), context);\r\n        element->getReferencedParameter()->setValue(defaultValue);\r\n\r\n        if (!errorList.isEmpty())\r\n        {\r\n            return QStringList(errorList.toList()).join(\"\\n\");\r\n        }\r\n        else\r\n        {\r\n            return configurableElementExpressionFormatter_->\r\n                formatReferringExpression(expressionOrValueForIndex(index).toString());\r\n        }\r\n    }\r\n    else if (index.column() == ConfigurableElementsColumns::DEFAULT_VALUE)\r\n    {\r\n        return defaultValueFormatter_->formatReferringExpression(expressionOrValueForIndex(index).toString());\r\n    }\r\n\r\n    return QString();    \r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ConfigurableElementsModel::validateIndex()\r\n//-----------------------------------------------------------------------------\r\nbool ConfigurableElementsModel::validateIndex(QModelIndex const& index) const\r\n{\r\n    if (!isIndexValid(index))\r\n    {\r\n        return false;\r\n    }\r\n\r\n    QSharedPointer<EditorConfigurableElement> element = configurableElements_.at(index.row());\r\n\r\n    if (index.column() == ConfigurableElementsColumns::NAME)\r\n    {\r\n        return validator_->hasValidName(element->getReferencedParameter());\r\n    }\r\n    else if (index.column() == ConfigurableElementsColumns::VALUE)\r\n    {\r\n        QString defaultValue = element->getReferencedParameter()->getValue();\r\n\r\n        element->getReferencedParameter()->setValue(element->getConfiguratedValue());\r\n        bool valid = validator_->hasValidValue(element->getReferencedParameter());\r\n        element->getReferencedParameter()->setValue(defaultValue);\r\n        \r\n        return valid;\r\n    }\r\n\r\n    return true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ConfigurableElementsModel::onRemoveItem()\r\n//-----------------------------------------------------------------------------\r\nvoid ConfigurableElementsModel::onRemoveItem(QString const& elementID, int elementRow)\r\n{\r\n    for (QSharedPointer<EditorConfigurableElement> element: configurableElements_)\r\n    {\r\n        if (element->getReferencedParameter() && element->getReferencedParameter()->getValueId() == elementID)\r\n        {\r\n            beginRemoveRows(QModelIndex(), elementRow, elementRow);\r\n\r\n            configurableElements_.removeOne(element);\r\n\r\n            endRemoveRows();\r\n\r\n            emit contentChanged();\r\n            return;\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ConfigurableElementsModel::onAddItem()\r\n//-----------------------------------------------------------------------------\r\nvoid ConfigurableElementsModel::onAddItem(QString const& elementID, QString const& elementValue, int elementRow)\r\n{\r\n    QSharedPointer<Parameter> unknownParameter = createUnknownParameter(elementID);\r\n\r\n    QSharedPointer<EditorConfigurableElement> unknownElement(new EditorConfigurableElement(\r\n        unknownParameter, QString(), elementValue));\r\n\r\n    beginInsertRows(QModelIndex(), elementRow, elementRow);\r\n\r\n    configurableElements_.insert(elementRow, unknownElement);\r\n\r\n    endInsertRows();\r\n\r\n    QModelIndex firstItemIndex = index(0, ConfigurableElementsColumns::NAME);\r\n    QModelIndex lastItemIndex = index(configurableElements_.size() - 1, ConfigurableElementsColumns::NAME);\r\n\r\n    emit dataChanged(firstItemIndex, lastItemIndex);\r\n    emit contentChanged();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ConfigurableElementsModel::readStoredConfigurableElements()\r\n//-----------------------------------------------------------------------------\r\nvoid ConfigurableElementsModel::restoreStoredConfigurableElements()\r\n{\r\n    if (itemConfigurableElementValues_)\r\n    {\r\n        for (QSharedPointer<ConfigurableElementValue> element : *itemConfigurableElementValues_)\r\n        {\r\n            QSharedPointer<EditorConfigurableElement> storedElement = getStoredConfigurableElement(\r\n                element->getReferenceId());\r\n            if (storedElement)\r\n            {\r\n                storedElement->setConfiguratedValue(element->getConfigurableValue());\r\n            }\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ConfigurableElementsModel::getStoredConfigurableElement()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<EditorConfigurableElement> ConfigurableElementsModel::getStoredConfigurableElement(\r\n    QString const& elementID)\r\n{\r\n    for (auto const& element : configurableElements_)\r\n    {\r\n        if (element->getReferencedParameter() && element->getReferencedParameter()->getValueId() == elementID)\r\n        {\r\n            return element;\r\n        }\r\n    }\r\n\r\n    QSharedPointer<Parameter> newReferencedParameter = createUnknownParameter(elementID);\r\n    QSharedPointer<EditorConfigurableElement> newConfigurableElement(new EditorConfigurableElement(\r\n        newReferencedParameter, QString(), QString()));\r\n    configurableElements_.append(newConfigurableElement);\r\n\r\n    return newConfigurableElement;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ConfigurableElementsModel::createUnknownParameter()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<Parameter> ConfigurableElementsModel::createUnknownParameter(QString const& parameterID)\r\n{\r\n    QSharedPointer<Parameter> newReferencedParameter(new Parameter());\r\n    newReferencedParameter->setName(QStringLiteral(\"Unknown referenced ID\"));\r\n    newReferencedParameter->setValueId(parameterID);\r\n    newReferencedParameter->setValueResolve(QStringLiteral(\"user\"));\r\n\r\n    return newReferencedParameter;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ConfigurableElementsModel::index()\r\n//-----------------------------------------------------------------------------\r\nQModelIndex ConfigurableElementsModel::index(int row, int column, const QModelIndex& ) const\r\n{\r\n    QSharedPointer<EditorConfigurableElement> element = configurableElements_.at(row);\r\n    return createIndex(row, column, element.data());\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ConfigurableElementsModel::parent()\r\n//-----------------------------------------------------------------------------\r\nQModelIndex ConfigurableElementsModel::parent(const QModelIndex &) const\r\n{\r\n    return QModelIndex();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ConfigurableElementsModel::isIndexValid()\r\n//-----------------------------------------------------------------------------\r\nbool ConfigurableElementsModel::isIndexValid(QModelIndex const& index) const\r\n{\r\n    if (index.isValid() && index.row() >= 0 && index.row() < configurableElements_.size())\r\n    {\r\n        return true;\r\n    }\r\n\r\n    return false;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ConfigurableElementsModel::isElementDeletable()\r\n//-----------------------------------------------------------------------------\r\nbool ConfigurableElementsModel::isElementDeletable(QModelIndex const& index) const\r\n{\r\n    QSharedPointer<EditorConfigurableElement> elemenet = configurableElements_.at(index.row());\r\n    return elemenet->getEvaluatedDefaultValue().isEmpty();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ConfigurableElementsModel::getConfigurableElements()\r\n//-----------------------------------------------------------------------------\r\nQList<QSharedPointer<EditorConfigurableElement> > ConfigurableElementsModel::getConfigurableElements() const\r\n{\r\n    return configurableElements_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ConfigurableElementsModel::parameterIDForIndex()\r\n//-----------------------------------------------------------------------------\r\nQString ConfigurableElementsModel::parameterIDForIndex(QModelIndex const& index) const\r\n{\r\n    QSharedPointer<Parameter> referencedParamter = configurableElements_.at(index.row())->getReferencedParameter();\r\n    if (referencedParamter)\r\n    {\r\n        return referencedParamter->getValueId();\r\n    }\r\n\r\n    return QString();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ConfigurableElementsModel::getConfigurableElementValues()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<QList<QSharedPointer<ConfigurableElementValue> > > ConfigurableElementsModel::\r\n    getItemConfigurableElementValues() const\r\n{\r\n    return itemConfigurableElementValues_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ConfigurableElementsModel::emitDataChangeForID()\r\n//-----------------------------------------------------------------------------\r\nvoid ConfigurableElementsModel::emitDataChangeForID(QString const& parameterID, QString const& newValue)\r\n{\r\n    for (int i = 0; i < configurableElements_.size(); ++i)\r\n    {\r\n        QSharedPointer<EditorConfigurableElement> element = configurableElements_.at(i);\r\n        if (element->getReferencedParameter() && element->getReferencedParameter()->getValueId() == parameterID)\r\n        {\r\n            element->setConfiguratedValue(newValue);\r\n\r\n            QModelIndex currentIndex = index(i, ConfigurableElementsColumns::VALUE, QModelIndex());\r\n\r\n            emit(dataChanged(currentIndex, currentIndex));\r\n            return;\r\n        }\r\n    }\r\n}\r\n"
  },
  {
    "path": "editors/common/ComponentInstanceEditor/ConfigurableElementsModel.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ConfigurableElementsModel.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 12.08.2011\r\n//\r\n// Description:\r\n// Model class to manage the configurable element values being edited.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef CONFIGURABLEELEMENTSMODEL_H\r\n#define CONFIGURABLEELEMENTSMODEL_H\r\n\r\n#include <editors/ComponentEditor/common/ParameterizableTable.h>\r\n#include <KactusAPI/include/ExpressionFormatter.h>\r\n#include <editors/ComponentEditor/common/ConfigurableElementFinder.h>\r\n\r\n#include <editors/common/ComponentInstanceEditor/EditorConfigurableElement.h>\r\n\r\n#include <IPXACTmodels/common/validators/ParameterValidator.h>\r\n\r\n#include <QAbstractItemModel>\r\n#include <QList>\r\n#include <QString>\r\n#include <QSharedPointer>\r\n\r\nclass Parameter;\r\nclass Choice;\r\nclass ConfigurableElementValue;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Model class to manage the configurable element values being edited.\r\n//-----------------------------------------------------------------------------\r\nclass ConfigurableElementsModel : public QAbstractItemModel, public ParameterizableTable\r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\r\n    //! The different user roles for data.\r\n    enum configurableElementsRoles\r\n    {\r\n        deletableElementCheckRole = Qt::UserRole,                   //! Checks if an item can be deleted.\r\n        parameterIDRole = Qt::UserRole + 1,                         //! Gets the ID of the referenced parameter.\r\n        getItemConfigurableElementValuesRole = Qt::UserRole + 2,    //! Gets the stored configurable elements.\r\n        getConfigurableElementsFromTableRole = Qt::UserRole + 3     //! Gets the elements from the table.\r\n    };\r\n\r\n\t/*!\r\n\t *  The constructor.\r\n\t *\r\n\t *    @param [in] parameterFinder                         Finds parameters.\r\n\t *    @param [in] configurableElementExpressionFormatter  Formatter for configurable elements.\r\n\t *    @param [in] defaultValueFormatter                   Formatter for default values.\r\n\t *    @param [in] configurableElementExpressionParser     Parses expressions in configurable element values.\r\n\t *    @param [in] defaultValueParser                      Parses expressions in default values.\r\n\t *    @param [in] parent                                  Pointer to the owner of this model.\r\n\t */\r\n\tConfigurableElementsModel(QSharedPointer<ParameterFinder> parameterFinder, \r\n        QSharedPointer<ExpressionFormatter> configurableElementExpressionFormatter,\r\n        QSharedPointer<ExpressionFormatter> defaultValueFormatter,\r\n        QSharedPointer<ExpressionParser> configurableElementExpressionParser,\r\n        QSharedPointer<ExpressionParser> defaultValueParser, QObject *parent);\r\n\t\r\n\t/*!\r\n\t *  The destructor.\r\n\t */\r\n\tvirtual ~ConfigurableElementsModel() = default;\r\n\r\n    //! No copying. //! No assignment.\r\n    ConfigurableElementsModel(const ConfigurableElementsModel& other) = delete;\r\n    ConfigurableElementsModel& operator=(const ConfigurableElementsModel& other) = delete;\r\n\r\n\t/*!\r\n\t *  Set the parameters for configurable element values.\r\n\t *\r\n     *    @param [in] containingItemName          Name of the item containing the configurable element values.\r\n     *    @param [in] parameters                  The configurable parameters.\r\n     *    @param [in] choices                     List of choices available to the configurable element values.\r\n     *    @param [in] storedConfigurableElements  List of previously set configurable element values.\r\n\t */\r\n    void setParameters(QString const& containingItemName,\r\n        QSharedPointer<QList<QSharedPointer<Parameter> > > parameters,\r\n        QSharedPointer<QList<QSharedPointer<Choice> > > choices,\r\n        Document::Revision docRevision,\r\n        QSharedPointer<QList<QSharedPointer<ConfigurableElementValue> > > storedConfigurableElements);\r\n\r\n\t/*!\r\n\t *  Get the number of rows to be displayed.\r\n\t *\r\n\t *    @param [in] parent  Identifies the parent, must always be invalid index.\r\n     *\r\n     *    @return The number of rows to display.\r\n\t */\r\n\tvirtual int rowCount(const QModelIndex& parent = QModelIndex()) const;\r\n\r\n\t/*!\r\n\t *  Get the number of columns to display.\r\n\t *\r\n\t *    @param [in] parent  Identifies the parent, must always be invalid index.\r\n     *\r\n     *    @return The number of columns to display.\r\n\t */\r\n\tvirtual int columnCount(const QModelIndex& parent = QModelIndex()) const;\r\n\r\n\t/*!\r\n\t *  Get the data for specified index in given data role.\r\n\t *\r\n\t *    @param [in] index   Identifies the object that's data is wanted.\r\n\t *    @param [in] role    Identifies the type of data being requested.\r\n     *\r\n     *    @return QVariant that contains the requested data.\r\n\t */\r\n\tvirtual QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const;\r\n\r\n\t/*!\r\n\t *  Get the data for the given header in the given data role.\r\n\t *\r\n\t *    @param [in] section         Identifies the header section.\r\n\t *    @param [in] orientation     Only horizontal header is supported.\r\n\t *    @param [in] role            Identifies the type of the data being requested.\r\n     *\r\n     *    @return QVariant that contains the requested data.\r\n\t */\r\n\tvirtual QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole ) const;\r\n\r\n\t/*!\r\n\t *  Set the data for the specified index.\r\n\t *\r\n\t *    @param [in] index   Identifies the object which data is to be saved.\r\n\t *    @param [in] value   Contains the data to be saved.\r\n\t *    @param [in] role    Identifies the type of the data to be saved.\r\n     *\r\n     *    @return True if data was saved successfully.\r\n\t */\r\n\tvirtual bool setData(const QModelIndex& index, const QVariant& value, int role = Qt::EditRole );\r\n\r\n\t/*!\r\n\t *  Get info on what operations are possible for specified item.\r\n\t *\r\n\t *    @param [in] index   Identifies the item that's operations are requested.\r\n     *\r\n     *    @return Flags containing info on which operations are available for given index.\r\n\t */\r\n\tvirtual Qt::ItemFlags flags(const QModelIndex& index) const;\r\n\r\n    /*!\r\n     *  Get the model index of the specified object.\r\n     *\r\n     *    @param [in] row     Row number of the object.\r\n     *    @param [in] column  Column number of the object.\r\n     *    @param [in] parent  Model index of the parent of the object.\r\n     *\r\n     *    @return QModelIndex that identifies the object.\r\n     */\r\n    QModelIndex index(int row, int column, const QModelIndex& parent = QModelIndex()) const;\r\n\r\n    /*!\r\n     *  Get the model index of the parent of the object.\r\n     *\r\n     *    @param [in] child   Model index that identifies the child of the object.\r\n     *\r\n     *    @return QModelindex that identifies the parent of the given object.\r\n     */\r\n    QModelIndex parent(const QModelIndex& child) const;\r\n\r\n\r\npublic slots:\r\n\r\n\t/*!\r\n\t *  Clear the model.\r\n\t */\r\n\tvoid clear();\r\n\r\n\t/*!\r\n\t *  Handles item removal.\r\n\t *\r\n     *    @param [in] elementID   ID of the referenced parameter.\r\n     *    @param [in] elementRow  Index row of the removed element.\r\n\t */\r\n    void onRemoveItem(QString const& elementID, int elementRow);\r\n\r\n    /*!\r\n     *  Handles the addition of new configurable elements.\r\n     *\r\n     *    @param [in] elementID       ID of the referenced parameter.\r\n     *    @param [in] elementValue    The new configurable value.\r\n     *    @param [in] elementRow      Index row for the new item.\r\n     */\r\n    void onAddItem(QString const& elementID, QString const& elementValue, int elementRow);\r\n\r\n    /*!\r\n     *  Sends a data change signal for the selected configurable element.\r\n     *\r\n     *    @param [in] parameterID     ID of the parameter referenced by the configurable element.\r\n     *    @param [in] newValue        The new value of the configurable element.\r\n     */\r\n    void emitDataChangeForID(QString const& parameterID, QString const& newValue);\r\n\r\n    /*!\r\n     *  Check if the given index is valid.\r\n     *\r\n     *    @param [in] index   The index to be checked.\r\n     *\r\n     *    @return True, if the given index is valid, false otherwise.\r\n     */\r\n    bool isIndexValid(QModelIndex const& index) const;\r\n\r\n    /*!\r\n     *  Get the configurable elements from the table.\r\n     *\r\n     *    @return The configurable elements from the table.\r\n     */\r\n    QList<QSharedPointer<EditorConfigurableElement> > getConfigurableElements() const;\r\n\r\nsignals:\r\n\r\n\t/*!\r\n     *  Emitted when contents of the model changes.\r\n     */\r\n\tvoid contentChanged();\r\n\r\nprotected:\r\n\r\n    /*!\r\n     *  Check if the column index is valid for containing expressions.\r\n     *\r\n     *    @param [in] index   The index being evaluated.\r\n     *\r\n     *    @return     True, if column can have expressions, false otherwise.\r\n     */\r\n    virtual bool isValidExpressionColumn(QModelIndex const& index) const;\r\n\r\n    /*!\r\n     *  Gets a formatted value for a given expression in default value column.\r\n     *\r\n     *    @param [in] expression  The expression which is being formatted.\r\n     *\r\n     *    @return The formatted value for the expression.\r\n     */\r\n    virtual QString formattedValueFor(QString const& expression) const;\r\n\r\n    /*!\r\n     *  Gets the expression for the given index, or plain value if there is no expression.\r\n     *\r\n     *    @param [in] index   The index of target data.\r\n     *\r\n     *    @return     Expression in the given index if there is one, or plain value.\r\n     */\r\n    virtual QVariant expressionOrValueForIndex(QModelIndex const& index) const;\r\n\r\n    /*!\r\n     *  Validates the data in a parameter corresponding to a given column.\r\n     *\r\n     *    @param [in] index   The index whose data to validate.\r\n     *\r\n     *    @return True, if the data in the parameter is valid, otherwise false.\r\n     */\r\n    virtual bool validateIndex(QModelIndex const& index) const;\r\n\r\n    /*!\r\n     *  Restore the previously saved configurable element values to their correct element.\r\n     */\r\n    void restoreStoredConfigurableElements();\r\n\r\n    /*!\r\n     *  Evaluate the value for the given index.\r\n     *\r\n     *    @param [in] column      The column of the required value.\r\n     *    @param [in] choiceName  The name of the choice used in the given value.\r\n     *    @param [in] value       The given value.\r\n     *\r\n     *    @return The true value for the given index, whether it is given using a choice or not.\r\n     */\r\n    QString evaluateValue(int column, QString const& choiceName, QString const& value) const;\r\n\r\n    //! A list of the configurable elements of the model.\r\n    QList<QSharedPointer<EditorConfigurableElement> > configurableElements_;\r\n\r\n    //! A list of the available choices.\r\n    QSharedPointer<QList<QSharedPointer<Choice> > > choices_ = nullptr;\r\n\r\n    //! Name of the containing item.\r\n    QString containingItemName_;\r\n\r\n    //! Validator for parameters.\r\n    QSharedPointer<ParameterValidator> validator_ = nullptr;\r\n\r\n    //! Configurable element values contained within the containing item.\r\n    QSharedPointer<QList<QSharedPointer<ConfigurableElementValue> > > itemConfigurableElementValues_ = nullptr;\r\n\r\nprivate:\r\n\r\n    /*!\r\n     *  Check if the configurable element is editable.\r\n     *\r\n     *    @param [in] parameterIndex  The index of the element.\r\n     *\r\n     *    @return True, if the element can be edited, false otherwise.\r\n     */\r\n    bool isParameterEditable(QModelIndex const& index) const;\r\n\r\n    /*!\r\n     *  Gets the value for the given index.\r\n     *\r\n     *    @param [in] index   The index of target data.\r\n     *\r\n     *    @return     The data in the given index.\r\n     */\r\n    QVariant valueForIndex(QModelIndex const& index) const;\r\n\r\n\r\n    /*!\r\n     *  Finds the currently selected choice.\r\n     *\r\n     *    @param [in] choiceName  The name of the choice to be searched for.\r\n     *\r\n     *    @return The currently selected choice.\r\n     */\r\n    QSharedPointer<Choice> findChoice(QString const& choiceName) const;\r\n\r\n    /*!\r\n     *  Finds the display values for the currently selected enumeration inside an array.\r\n     *\r\n     *    @param [in] choice      The currently selected choice.\r\n     *    @param [in] arrayValue  The value that contains an array.\r\n     *\r\n     *    @return The displayable array value of the enumeration.\r\n     */\r\n    QString matchArrayValuesToSelectedChoice(QSharedPointer<Choice> choice, QString const& arrayValue) const;\r\n\r\n    /*!\r\n     *  Finds the display value for the currently selected enumeration.\r\n     *\r\n     *    @param [in] choice              The currently selected choice.\r\n     *    @param [in] enumerationValue    The current value to be changed into an enumeration.\r\n     *\r\n     *    @return The displayable value of the enumeration.\r\n     */\r\n    QString findDisplayValueForEnumeration(QSharedPointer<Choice> choice, QString const& enumerationValue) const;\r\n\r\n    /*!\r\n     *  Gets the text for the tooltip related to the data in the given index.\r\n     *\r\n     *    @param [in] index   The index of the target data.\r\n     *\r\n     *    @return The corresponding text for a tool tip.\r\n     */\r\n    QString tooltipForIndex(QModelIndex const& index) const;\r\n\r\n\r\n    /*!\r\n     *  Get the selected configurable element.\r\n     *\r\n     *    @param [in] elementID   The id of the element to be searched for.\r\n     *\r\n     *    @return The selected configurable element.\r\n     */\r\n    QSharedPointer<EditorConfigurableElement> getStoredConfigurableElement(QString const& elementID);\r\n\r\n    /*!\r\n     *  Create an unknown parameter.\r\n     *\r\n     *    @param [in] parameterID     ID of the unknown parameter.\r\n     *\r\n     *    @return The created unknown parameter.\r\n     */\r\n    QSharedPointer<Parameter> createUnknownParameter(QString const& parameterID);\r\n\r\n    /*!\r\n     *  Checks if it is possible to delete the element in the given index.\r\n     *\r\n     *    @param [in] index   The given index of the element.\r\n     *\r\n     *    @return True, if the element can be deleted, false otherwise.\r\n     */\r\n    bool isElementDeletable(QModelIndex const& index) const;\r\n\r\n    /*!\r\n     *  Get the referenced parameter ID of the selected index.\r\n     *\r\n     *    @param [in] index   The selected index.\r\n     *\r\n     *    @return Parameter ID of the selected index.\r\n     */\r\n    QString parameterIDForIndex(QModelIndex const& index) const;\r\n\r\n    /*!\r\n     *  Get the configurable elements contained in the model.\r\n     *\r\n     *    @return The configurable elements contained within the model\r\n     */\r\n    QSharedPointer<QList<QSharedPointer<ConfigurableElementValue> > > getItemConfigurableElementValues() const;\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! The formatter for referencing expressions in values.\r\n    QSharedPointer<ExpressionFormatter> configurableElementExpressionFormatter_;\r\n\r\n    //! The parser for referencing expressions in values.\r\n    QSharedPointer<ExpressionParser> configurableElementExpressionParser_;\r\n\r\n    //! The formatter for referencing expressions in default values.\r\n    QSharedPointer<ExpressionFormatter> defaultValueFormatter_;\r\n\r\n    //! The expression parser for default values.\r\n    QSharedPointer<ExpressionParser> defaultValueParser_;\r\n};\r\n\r\n//! Meta types for QVariants.\r\nQ_DECLARE_METATYPE(QSharedPointer<QList<QSharedPointer<ConfigurableElementValue> > >)\r\nQ_DECLARE_METATYPE(QList<QSharedPointer<EditorConfigurableElement> >)\r\n\r\n#endif // CONFIGURABLEELEMENTSMODEL_H\r\n"
  },
  {
    "path": "editors/common/ComponentInstanceEditor/ConfigurableElementsView.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ConfigurableElementsView.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Mikko Teuho\r\n// Date: 30.03.2015\r\n//\r\n// Description:\r\n// A view for configurable element tree model.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"ConfigurableElementsView.h\"\r\n\r\n#include <common/KactusColors.h>\r\n\r\n#include <QMenu>\r\n#include <QPainter>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ConfigurableElementsView::ConfigurableElementsView()\r\n//-----------------------------------------------------------------------------\r\nConfigurableElementsView::ConfigurableElementsView(QWidget* parent):\r\nEditableTableView(parent)\r\n{\r\n    setToolTip(QString());\r\n    removeAction_.setText(tr(\"Remove configurable element\"));\r\n    setSelectionMode(QAbstractItemView::ContiguousSelection);\r\n    setItemsDraggable(false);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ConfigurableElementsView::contextMenuEvent()\r\n//-----------------------------------------------------------------------------\r\nvoid ConfigurableElementsView::contextMenuEvent(QContextMenuEvent* event)\r\n{\r\n    QModelIndex contextMenuIndex = indexAt(event->pos());\r\n    if (!contextMenuIndex.isValid())\r\n    {\r\n        event->accept();\r\n        return;\r\n    }\r\n\r\n    QMenu contextMenu;\r\n    if (contextMenuIndex.isValid())\r\n    {\r\n        contextMenu.addAction(&clearAction_);\r\n        contextMenu.addAction(&copyAction_);\r\n        contextMenu.addAction(&pasteAction_);\r\n    }\r\n\r\n    if (model()->data(contextMenuIndex, Qt::UserRole).toBool())\r\n    {\r\n        removeAction_.setEnabled(true);\r\n        contextMenu.addAction(&removeAction_);\r\n    }\r\n\r\n    contextMenu.exec(event->globalPos());\r\n    event->accept();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ConfigurableElementsView::onClearAction()\r\n//-----------------------------------------------------------------------------\r\nvoid ConfigurableElementsView::onClearAction()\r\n{\r\n    QModelIndex selectedIndex = currentIndex();\r\n    if (selectedIndex.isValid())\r\n    {\r\n        QString oldValue = model()->data(selectedIndex, Qt::EditRole).toString();\r\n        QString newValue(\"\");\r\n\r\n        emit createElementChangeCommand(oldValue, newValue, selectedIndex, model());\r\n    }\r\n}\r\n"
  },
  {
    "path": "editors/common/ComponentInstanceEditor/ConfigurableElementsView.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ConfigurableElementsView.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Mikko Teuho\r\n// Date: 30.03.2015\r\n//\r\n// Description:\r\n// A view for configurable element tree model.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef CONFIGURABLEELEMENTSVIEW_H\r\n#define CONFIGURABLEELEMENTSVIEW_H\r\n\r\n#include <common/views/EditableTableView/editabletableview.h>\r\n\r\n#include <QContextMenuEvent>\r\n#include <QModelIndex>\r\n#include <QAction>\r\n\r\n//-----------------------------------------------------------------------------\r\n//! A tree view for the configurable element tree model.\r\n//-----------------------------------------------------------------------------\r\nclass ConfigurableElementsView : public EditableTableView\r\n{\r\n    Q_OBJECT\r\n\r\npublic:\r\n   \r\n    /*!\r\n     *  The constructor.\r\n     *\r\n     *    @param [in] parent  The owner of this view.\r\n     */\r\n    ConfigurableElementsView(QWidget* parent);\r\n\r\n    /*!\r\n     *  Destructor.\r\n     */\r\n    virtual ~ConfigurableElementsView() = default;\r\n\r\nsignals:\r\n\r\n    /*!\r\n     *  Emitted when a configurable element change command should be created.\r\n     *\r\n     *    @param [in] oldValue    Old value of the indexed element.\r\n     *    @param [in] newValue    New value of the indexed element.\r\n     *    @param [in] index       The selected index.\r\n     *    @param [in] cevModel    Model containing the configurable elements.\r\n     */\r\n    void createElementChangeCommand(QString const& oldValue, QString const& newValue, QModelIndex const& index,\r\n        QAbstractItemModel* cevModel) const;\r\n\r\nprotected:\r\n\r\n    /*!\r\n     *  Handler for context menu events.\r\n     *\r\n     *    @param [in] event   The context menu event.\r\n     */\r\n    virtual void contextMenuEvent(QContextMenuEvent* event);\r\n\r\nprotected slots:\r\n\r\n    /*!\r\n     *  Handles the deleting of the selected cell.\r\n     */\r\n    virtual void onClearAction();\r\n\r\nprivate:\r\n   \r\n    // Disable copying.\r\n    ConfigurableElementsView(ConfigurableElementsView const& rhs);\r\n    ConfigurableElementsView& operator=(ConfigurableElementsView const& rhs);\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n\r\n#endif // CONFIGURABLEELEMENTSVIEW_H\r\n"
  },
  {
    "path": "editors/common/ComponentInstanceEditor/EditorConfigurableElement.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: EditorConfigurableElement.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 30.08.2017\n//\n// Description:\n// Container class for configurable elements in the configurable element value tables.\n//-----------------------------------------------------------------------------\n\n#include \"EditorConfigurableElement.h\"\n\n#include <IPXACTmodels/common/Parameter.h>\n\n//-----------------------------------------------------------------------------\n// Function: EditorConfigurableElement::EditorConfigurableElement()\n//-----------------------------------------------------------------------------\nEditorConfigurableElement::EditorConfigurableElement(QSharedPointer<Parameter> referencedParameter,\n    QString const& evaluatedDefaultValue, QString const& configuratedValue):\nreferencedParameter_(referencedParameter),\nevaluatedDefaultValue_(evaluatedDefaultValue),\nconfiguratedValue_(configuratedValue)\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: EditorConfigurableElement::getReferencedParameter()\n//-----------------------------------------------------------------------------\nQSharedPointer<Parameter> EditorConfigurableElement::getReferencedParameter() const\n{\n    return referencedParameter_;\n}\n\n//-----------------------------------------------------------------------------\n// Function: EditorConfigurableElement::setParameterReference()\n//-----------------------------------------------------------------------------\nvoid EditorConfigurableElement::setParameterReference(QSharedPointer<Parameter> parameter)\n{\n    referencedParameter_ = parameter;\n}\n\n//-----------------------------------------------------------------------------\n// Function: EditorConfigurableElement::getEvaluatedDefaultValue()\n//-----------------------------------------------------------------------------\nQString const& EditorConfigurableElement::getEvaluatedDefaultValue() const\n{\n    return evaluatedDefaultValue_;\n}\n\n//-----------------------------------------------------------------------------\n// Function: EditorConfigurableElement::setEvaluatedDefaultValue()\n//-----------------------------------------------------------------------------\nvoid EditorConfigurableElement::setEvaluatedDefaultValue(QString const& newEvaluatedDefaultValue)\n{\n    evaluatedDefaultValue_ = newEvaluatedDefaultValue;\n}\n\n//-----------------------------------------------------------------------------\n// Function: EditorConfigurableElement::getConfiguratedValue()\n//-----------------------------------------------------------------------------\nQString const& EditorConfigurableElement::getConfiguratedValue() const\n{\n    return configuratedValue_;\n}\n\n//-----------------------------------------------------------------------------\n// Function: EditorConfigurableElement::setConfiguratedValue()\n//-----------------------------------------------------------------------------\nvoid EditorConfigurableElement::setConfiguratedValue(QString const& newConfiguratedValue)\n{\n    configuratedValue_ = newConfiguratedValue;\n}\n"
  },
  {
    "path": "editors/common/ComponentInstanceEditor/EditorConfigurableElement.h",
    "content": "//-----------------------------------------------------------------------------\n// File: EditorConfigurableElement.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 30.08.2017\n//\n// Description:\n// Container class for configurable elements in the configurable element value tables.\n//-----------------------------------------------------------------------------\n\n#ifndef EDITORCONFIGURABLEELEMENT_H\n#define EDITORCONFIGURABLEELEMENT_H\n\n#include <QSharedPointer>\n\nclass Parameter;\n\n//-----------------------------------------------------------------------------\n//! Container class for configurable elements in the configurable element value tables.\n//-----------------------------------------------------------------------------\nclass EditorConfigurableElement\n{\n\npublic:\n\n\t/*!\n\t *  The constructor.\n\t *\n\t *    @param [in] referenceParameter      Parameter referenced by the configurable element.\n\t *    @param [in] evaluatedDefaultValue   Evaluated default value of the referenced parameter.\n\t *    @param [in] configuratedValue       The configurable value.\n\t */\n    EditorConfigurableElement(QSharedPointer<Parameter> referencedParameter, QString const& evaluatedDefaultValue,\n        QString const& configuratedValue);\n\t\n\t/*!\n\t *  The destructor.\n\t */\n    ~EditorConfigurableElement() = default;\n\n    //! No copying. No assignment.\n    EditorConfigurableElement(const EditorConfigurableElement& other) = delete;\n    EditorConfigurableElement& operator=(const EditorConfigurableElement& other) = delete;\n\n    /*!\n     *  Get the referenced parameter.\n     *\n     *    @return The referenced parameter.\n     */\n    QSharedPointer<Parameter> getReferencedParameter() const;\n\n    /*!\n     *  Set a new parameter reference.\n     *\n     *    @param [in] parameter   The new parameter.\n     */\n    void setParameterReference(QSharedPointer<Parameter> parameter);\n\n    /*!\n     *  Get the evaluated parameter default value.\n     *\n     *    @return The evaluated parameter default value.\n     */\n    QString const& getEvaluatedDefaultValue() const;\n\n    /*!\n     *  Set a new evaluated default value.\n     *\n     *    @param [in] newEvaluatedDefaultValue    The new evaluated default value.\n     */\n    void setEvaluatedDefaultValue(QString const& newEvaluatedDefaultValue);\n\n    /*!\n     *  Get the configurable element value.\n     *\n     *    @return The configurable element value.\n     */\n    QString const& getConfiguratedValue() const;\n\n    /*!\n     *  Set a new value for configurable value.\n     *\n     *    @param [in] newConfiguratedValue    The new configurable element value.\n     */\n    void setConfiguratedValue(QString const& newConfiguratedValue);\n\n\nprivate:\n\n    //-----------------------------------------------------------------------------\n    // Data.\n    //-----------------------------------------------------------------------------\n\n    //! The referenced parameter.\n    QSharedPointer<Parameter> referencedParameter_;\n\n    //! Evaluated default value.\n    QString evaluatedDefaultValue_;\n\n    //! The configurable value.\n    QString configuratedValue_;\n\n};\n\n#endif // EDITORCONFIGURABLEELEMENT_H\n"
  },
  {
    "path": "editors/common/ComponentInstanceEditor/MissingConfigurableElementsFilter.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: MissingConfigurableElementsFilter.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 24.08.2017\n//\n// Description:\n// A filter class for displaying only the unknown configurable elements.\n//-----------------------------------------------------------------------------\n\n#include \"MissingConfigurableElementsFilter.h\"\n\n//-----------------------------------------------------------------------------\n// Function: MissingConfigurableElementsFilter::MissingConfigurableElementsFilter()\n//-----------------------------------------------------------------------------\nMissingConfigurableElementsFilter::MissingConfigurableElementsFilter(QObject* parent):\nParameterConfigurableElementsFilter(parent)\n{\n\n}\n\n\n//-----------------------------------------------------------------------------\n// Function: MissingConfigurableElementsFilter::filterAcceptsRow()\n//-----------------------------------------------------------------------------\nbool MissingConfigurableElementsFilter::filterAcceptsRow(int source_row, QModelIndex const& source_parent) const\n{\n    bool itemIsEditable = itemAtIndexIsEditable(source_row, source_parent);\n    bool itemDefaultIsEmpty = isIndexedDefaultValueEmpty(source_row);\n\n    return itemIsEditable && itemDefaultIsEmpty;\n}\n"
  },
  {
    "path": "editors/common/ComponentInstanceEditor/MissingConfigurableElementsFilter.h",
    "content": "//-----------------------------------------------------------------------------\n// File: MissingConfigurableElementsFilter.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 24.08.2017\n//\n// Description:\n// A filter class for displaying only the unknown configurable elements.\n//-----------------------------------------------------------------------------\n\n#ifndef MISSINGCONFIGURABLESELEMENTFILTER_H\n#define MISSINGCONFIGURABLESELEMENTFILTER_H\n\n#include <editors/common/ComponentInstanceEditor/ParameterConfigurableElementsFilter.h>\n\n#include <QSortFilterProxyModel>\n#include <QModelIndex>\n\n//-----------------------------------------------------------------------------\n//! A filter class for displaying unknown configurable elements.\n//-----------------------------------------------------------------------------\nclass MissingConfigurableElementsFilter : public ParameterConfigurableElementsFilter\n{\n    Q_OBJECT\n\npublic:\n   \n    /*!\n     *  The constructor.\n     *\n     *    @param [in] parent  The owner of this filter.\n     */\n    MissingConfigurableElementsFilter(QObject* parent);\n\n    /*!\n     *  Destructor.\n     */\n    virtual ~MissingConfigurableElementsFilter() = default;\n\nprotected:\n\n    /*!\n     *  Validate the given row on a parent and check if the item should be shown.\n     *\n     *    @param [in] source_row      The row number of the child on the parent.\n     *    @param [in] source_parent   Model index that identifies the parent object.\n     *\n     *    @return True, if the object should be displayed, false otherwise.\n     */\n    bool filterAcceptsRow(int source_row, const QModelIndex &source_parent) const final;\n\nprivate:\n   \n    // Disable copying.\n    MissingConfigurableElementsFilter(MissingConfigurableElementsFilter const& rhs);\n    MissingConfigurableElementsFilter& operator=(MissingConfigurableElementsFilter const& rhs);\n};\n\n#endif // MISSINGCONFIGURABLESELEMENTFILTER_H\n"
  },
  {
    "path": "editors/common/ComponentInstanceEditor/ParameterConfigurableElementsFilter.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: ParameterConfigurableElementsFilter.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 05.09.2017\n//\n// Description:\n// A filter class for displaying only the configurable elements with existing referenced parameters.\n//-----------------------------------------------------------------------------\n\n#include \"ParameterConfigurableElementsFilter.h\"\n\n#include <editors/common/ComponentInstanceEditor/ConfigurableElementsColumns.h>\n\n//-----------------------------------------------------------------------------\n// Function: ParameterConfigurableElementsFilter::ParameterConfigurableElementsFilter()\n//-----------------------------------------------------------------------------\nParameterConfigurableElementsFilter::ParameterConfigurableElementsFilter(QObject* parent):\nConfigurableElementsFilter(parent)\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: ParameterConfigurableElementsFilter::filterAcceptsRow()\n//-----------------------------------------------------------------------------\nbool ParameterConfigurableElementsFilter::filterAcceptsRow(int source_row, QModelIndex const& source_parent) const\n{\n    bool showImmediatesOrEditable = ConfigurableElementsFilter::filterAcceptsRow(source_row, source_parent);\n    bool itemDefaultIsEmpty = isIndexedDefaultValueEmpty(source_row);\n\n    return showImmediatesOrEditable && !itemDefaultIsEmpty;\n}\n\n//-----------------------------------------------------------------------------\n// Function: ParameterConfigurableElementsFilter::isIndexedDefaultValueEmpty()\n//-----------------------------------------------------------------------------\nbool ParameterConfigurableElementsFilter::isIndexedDefaultValueEmpty(int sourceRow) const\n{\n    QModelIndex defaultValueIndex = sourceModel()->index(sourceRow, ConfigurableElementsColumns::DEFAULT_VALUE);\n    QString defaultValue = sourceModel()->data(defaultValueIndex, Qt::DisplayRole).toString();\n\n    return defaultValue.isEmpty();\n}\n"
  },
  {
    "path": "editors/common/ComponentInstanceEditor/ParameterConfigurableElementsFilter.h",
    "content": "//-----------------------------------------------------------------------------\n// File: ParameterConfigurableElementsFilter.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 05.09.2017\n//\n// Description:\n// A filter class for displaying only the configurable elements with existing referenced parameters.\n//-----------------------------------------------------------------------------\n\n#ifndef PARAMETERCONFIGURABLESELEMENTFILTER_H\n#define PARAMETERCONFIGURABLESELEMENTFILTER_H\n\n#include <editors/common/ComponentInstanceEditor/ConfigurableElementsFilter.h>\n\n#include <QSortFilterProxyModel>\n#include <QModelIndex>\n\n//-----------------------------------------------------------------------------\n//! A filter class for displaying only the configurable elements with existing referenced parameters.\n//-----------------------------------------------------------------------------\nclass ParameterConfigurableElementsFilter : public ConfigurableElementsFilter\n{\n    Q_OBJECT\n\npublic:\n   \n    /*!\n     *  The constructor.\n     *\n     *    @param [in] parent  The owner of this filter.\n     */\n    ParameterConfigurableElementsFilter(QObject* parent);\n\n    /*!\n     *  Destructor.\n     */\n    virtual ~ParameterConfigurableElementsFilter() = default;\n\n    // Disable copying.\n    ParameterConfigurableElementsFilter(ParameterConfigurableElementsFilter const& rhs) = delete;\n    ParameterConfigurableElementsFilter& operator=(ParameterConfigurableElementsFilter const& rhs) = delete;\n\nprotected:\n\n    /*!\n     *  Validate the given row on a parent and check if the item should be shown.\n     *\n     *    @param [in] source_row      The row number of the child on the parent.\n     *    @param [in] source_parent   Model index that identifies the parent object.\n     *\n     *    @return True, if the object should be displayed, false otherwise.\n     */\n    bool filterAcceptsRow(int source_row, const QModelIndex &source_parent) const override;\n\n    /*!\n     *  Check if the default value of the indexed item is empty.\n     *\n     *    @param [in] sourceRow   Row of the indexed item.\n     *\n     *    @return True, if the default value of the indexed item is empty, false otherwise.\n     */\n    bool isIndexedDefaultValueEmpty(int sourceRow) const;\n   \n};\n\n#endif // PARAMETERCONFIGURABLESELEMENTFILTER_H\n"
  },
  {
    "path": "editors/common/ComponentInstanceEditor/PowerDomainLinkColumns.h",
    "content": "//-----------------------------------------------------------------------------\n// File: ChoiceColumns.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Esko Pekkarinen\n// Date: 19.10.2023\n//\n// Description:\n// Common declarations for editing power domain links in component instance.\n//-----------------------------------------------------------------------------\n\n#ifndef POWERDOMAINLINKCOLUMNS_H\n#define POWERDOMAINLINKCOLUMNS_H\n\nnamespace PowerDomainLinkColumns\n{\n    //! The editable columns in the power domain links editor.\n    enum Column\n    {\n        EXTERNAL_LINK = 0,\n        INTERNAL_LINK,\n        COLUMN_COUNT\n    };\n\n    enum Roles\n    {\n        USER_EDIT_ROLE = Qt::UserRole + 1,\n        USER_DISPLAY_ROLE\n    };\n}\n\n#endif // POWERDOMAINLINKCOLUMNS_H"
  },
  {
    "path": "editors/common/ComponentInstanceEditor/PowerDomainLinkDelegate.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: PowerDomainLinkDelegate.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Esko Pekkarinen\n// Date: 20.10.2023\n//\n// Description:\n// \n//-----------------------------------------------------------------------------\n\n#include \"PowerDomainLinkDelegate.h\"\n#include \"PowerDomainLinkColumns.h\"\n\n#include <common/widgets/EnumCollectionEditor/EnumCollectionEditor.h>\n\n#include <IPXACTmodels/Component/Component.h>\n\n#include <QComboBox>\n#include <QString>\n\n//-----------------------------------------------------------------------------\n// Function: PowerDomainLinkDelegate::PowerDomainLinkDelegate()\n//-----------------------------------------------------------------------------\nPowerDomainLinkDelegate::PowerDomainLinkDelegate(QObject* parent):\nEnumerationEditorConstructorDelegate(parent)\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: PowerDomainLinkDelegate::createEditor()\n//-----------------------------------------------------------------------------\nQWidget* PowerDomainLinkDelegate::createEditor(QWidget* parent, QStyleOptionViewItem const& option, \n    QModelIndex const& index) const\n{\n    if (index.column() == PowerDomainLinkColumns::EXTERNAL_LINK)\n    {\n        auto externalSelector = new QComboBox(parent);\n        externalSelector->setEditable(true);\n        \n        if (externalComponent_.isNull() == false)\n        {\n            externalSelector->addItems(externalComponent_->getPowerDomainNames());\n        }\n        \n        connect(externalSelector, SIGNAL(editingFinished()), this, SLOT(commitAndCloseEditor()), Qt::UniqueConnection);\n\n        return externalSelector;\n    }\n    else if (index.column() == PowerDomainLinkColumns::INTERNAL_LINK )\n    {\n        return EnumerationEditorConstructorDelegate::createEditor(parent, option, index);\n    }\n    return nullptr;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PowerDomainLinkDelegate::setEditorData()\n//-----------------------------------------------------------------------------\nvoid PowerDomainLinkDelegate::setEditorData(QWidget* editor, QModelIndex const& index) const\n{\n    if (index.column() == PowerDomainLinkColumns::EXTERNAL_LINK)\n    {\n        auto edit = qobject_cast<QComboBox*>(editor);\n        Q_ASSERT(edit);\n\n        edit->setCurrentText(index.data(Qt::DisplayRole).toString());\n    }\n    else\n    {\n        EnumerationEditorConstructorDelegate::setEditorData(editor, index);\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: PowerDomainLinkDelegate::setModelData()\n//-----------------------------------------------------------------------------\nvoid PowerDomainLinkDelegate::setModelData(QWidget* editor, QAbstractItemModel* model, QModelIndex const& index) const\n{\n    if (index.column() == PowerDomainLinkColumns::EXTERNAL_LINK)\n    {\n        auto edit = qobject_cast<QComboBox*>(editor);\n        Q_ASSERT(edit);\n\n        model->setData(index, edit->currentText(), Qt::EditRole);\n    }\n    else\n    {\n        EnumerationEditorConstructorDelegate::setModelData(editor, model, index);\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: PowerDomainLinkDelegate::setComponents()\n//-----------------------------------------------------------------------------\nvoid PowerDomainLinkDelegate::setComponents(QSharedPointer<Component> externalComponent, \n    QSharedPointer<Component> internalComponent) noexcept\n{\n    externalComponent_ = externalComponent;\n    internalComponent_ = internalComponent;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PowerDomainLinkDelegate::isEnumerationEditorColumn()\n//-----------------------------------------------------------------------------\nbool PowerDomainLinkDelegate::isEnumerationEditorColumn(QModelIndex const& index) const\n{\n    return index.column() == PowerDomainLinkColumns::INTERNAL_LINK;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PowerDomainLinkDelegate::getCurrentSelection()\n//-----------------------------------------------------------------------------\nQStringList PowerDomainLinkDelegate::getCurrentSelection(QModelIndex const& index) const\n{\n    return index.data(Qt::EditRole).toStringList();\n}\n\n//-----------------------------------------------------------------------------\n// Function: PowerDomainLinkDelegate::getAvailableItems()\n//-----------------------------------------------------------------------------\nQStringList PowerDomainLinkDelegate::getAvailableItems() const\n{\n    if (internalComponent_.isNull())\n    {\n        return QStringList();\n    }\n\n    return internalComponent_->getPowerDomainNames();\n}\n\n//-----------------------------------------------------------------------------\n// Function: PowerDomainLinkDelegate::setEnumerationDataToModel()\n//-----------------------------------------------------------------------------\nvoid PowerDomainLinkDelegate::setEnumerationDataToModel(QModelIndex const& index, \n    QAbstractItemModel* model, QStringList const& selectedItems) const\n{\n    model->setData(index, selectedItems, Qt::EditRole);\n}\n"
  },
  {
    "path": "editors/common/ComponentInstanceEditor/PowerDomainLinkDelegate.h",
    "content": "//-----------------------------------------------------------------------------\n// File: PowerDomainLinkDelegate.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Esko Pekkarinen\n// Date: 20.10.2023\n//\n// Description:\n// \n//-----------------------------------------------------------------------------\n\n#ifndef POWERDOMAINLINKDELEGATE_H\n#define POWERDOMAINLINKDELEGATE_H\n\n#include <editors/ComponentEditor/common/EnumerationEditorConstructorDelegate.h>\n\n#include <QSharedPointer>\n\nclass Component;\n\n//-----------------------------------------------------------------------------\n//! The delegate that provides editors to edit the channels of a component.\n//-----------------------------------------------------------------------------\nclass PowerDomainLinkDelegate : public EnumerationEditorConstructorDelegate\n{\n\tQ_OBJECT\n\npublic:\n\n\t/*! The constructor\n\t *\n\t *    @param [in] component   The component being edited.\n\t *    @param [in] parent      The owner of this delegate.\n\t*/\n\texplicit PowerDomainLinkDelegate(QObject *parent = nullptr);\n\t\n\t//! The destructor\n\t~PowerDomainLinkDelegate() final = default;\n\n    //! No copying\n    PowerDomainLinkDelegate(const PowerDomainLinkDelegate& other) = delete;\n    PowerDomainLinkDelegate& operator=(const PowerDomainLinkDelegate& other) = delete;\n\n\t/*! Create a new editor for the given item\n\t *\n\t *    @param [in] parent  Owner for the editor.\n\t *    @param [in] option  Contains options for the editor.\n\t *    @param [in] index   Model index identifying the item.\n\t *\n\t *    @return The editor to be used to edit the item.\n\t*/\n\tQWidget* createEditor(QWidget* parent, QStyleOptionViewItem const& option,\n        QModelIndex const& index) const final;\n\n\t/*! Set the data for the editor.\n\t *\n\t *    @param [in] editor  The editor where the data is to be set.\n\t *    @param [in] index   Model index identifying the item that's data is to be set.\n\t *\n\t*/\n\tvoid setEditorData(QWidget* editor, QModelIndex const& index) const final;\n\n\t/*! Save the data from the editor to the model.\n\t *\n\t *    @param [in] editor  The editor that contains the data to store.\n\t *    @param [in] model   Model that contains the data structure where data is to be saved to.\n\t *    @param [in] index   Model index identifying the item that's data is to be saved.\n\t *\n\t*/\n\tvoid setModelData(QWidget* editor, QAbstractItemModel* model, \n\t\tQModelIndex const& index) const final;\n\n\tvoid setComponents(QSharedPointer<Component> externalComponent, QSharedPointer<Component> internalComponent) noexcept;\n\nprivate:\n\t\n\n    /*!\n     *  Check if the column is used for enumerations.\n     *\n     *    @param [in] index   The selected index.\n     *\n     *    @return True, if the column is used for editing enumerations, false otherwise.\n     */\n    bool isEnumerationEditorColumn(QModelIndex const& index) const final;\n\n    /*!\n     *  The list of currently selected enumerations in the selected item.\n     *\n     *    @param [in] index   Index of the selected item.\n     *\n     *    @return List of currently selected enumerations.\n     */\n    QStringList getCurrentSelection(QModelIndex const& index) const final;\n\n    /*!\n     *  Get the list of the available enumerations.\n     *\n     *    @return List of the available enumerations.\n     */\n    QStringList getAvailableItems() const final;\n\n    /*!\n     *  Set the selected enumerations to the selected item.\n     *\n     *    @param [in] index           Model index identifying the item that's data is to be saved.\n     *    @param [in] model           Model that contains the data structure where data is to be saved to.\n     *    @param [in] selectedItems   List of the selected enumerations.\n     */\n    void setEnumerationDataToModel(QModelIndex const& index, QAbstractItemModel* model, QStringList const& selectedItems) const final;\n\n    //-----------------------------------------------------------------------------\n    // Data.\n    //-----------------------------------------------------------------------------\n    \n    QSharedPointer<Component> externalComponent_ = nullptr;\n\n\tQSharedPointer<Component> internalComponent_ = nullptr;\n};\n\n#endif // POWERDOMAINLINKDELEGATE_H\n"
  },
  {
    "path": "editors/common/ComponentInstanceEditor/PowerDomainLinkEditor.cpp",
    "content": "\n\n#include \"PowerDomainLinkEditor.h\"\n\n#include <IPXACTmodels/common/Parameter.h>\n\n#include <QHBoxLayout>\n\n//-----------------------------------------------------------------------------\n// Function: PowerDomainLinkEditor::PowerDomainLinkEditor()\n//-----------------------------------------------------------------------------\nPowerDomainLinkEditor::PowerDomainLinkEditor(QWidget* parent):\n    QGroupBox(tr(\"Power domains\"), parent)\n{\n    view_->setItemDelegate(delegate_);\n    view_->setModel(model_);\n    \n    view_->setSelectionBehavior(QAbstractItemView::SelectItems);\n    view_->setSelectionMode(QAbstractItemView::SingleSelection);\n\n    connect(view_, SIGNAL(addItem(QModelIndex const&)), model_, SLOT(addItem(QModelIndex const&)));\n    connect(view_, SIGNAL(removeItem(QModelIndex const&)), model_, SLOT(removeItem(QModelIndex const&)));\n\n    connect(model_, SIGNAL(contentChanged()), this, SIGNAL(contentChanged()));\n\n    setupLayout();\n}\n\n//-----------------------------------------------------------------------------\n// Function: PowerDomainLinkEditor::setContent()\n//-----------------------------------------------------------------------------\nvoid PowerDomainLinkEditor::setContent(ComponentInstance::PowerDomainLink::List powerDomains,\n    QSharedPointer<Component> externalComponent, QSharedPointer<Component> internalComponent) const noexcept\n{\n    model_->setPowerDomains(powerDomains);\n    delegate_->setComponents(externalComponent, internalComponent);\n}\n\n//-----------------------------------------------------------------------------\n// Function: PowerDomainLinkEditor::setupLayout()\n//-----------------------------------------------------------------------------\nvoid PowerDomainLinkEditor::setupLayout()\n{\n    auto layout = new QHBoxLayout(this);\n\n    layout->addWidget(view_);\n}\n"
  },
  {
    "path": "editors/common/ComponentInstanceEditor/PowerDomainLinkEditor.h",
    "content": "//-----------------------------------------------------------------------------\n// File: PowerDomainLinkEditor.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Esko Pekkarinen\n// Date: 19.10.2023\n//\n// Description:\n// \n//-----------------------------------------------------------------------------\n\n#ifndef POWERDOMAINLINKEDITOR_H\n#define POWERDOMAINLINKEDITOR_H\n\n#include <common/views/EditableTableView/editabletableview.h>\n\n#include <IPXACTmodels/Component/Component.h>\n#include <IPXACTmodels/Design/ComponentInstance.h>\n\n#include \"PowerDomainLinkDelegate.h\"\n#include \"PowerDomainLinkModel.h\"\n\n#include <QSharedPointer>\n#include <QGroupBox>\n\nclass Parameter;\n\n//-----------------------------------------------------------------------------\n//! Container class for configurable elements in the configurable element value tables.\n//-----------------------------------------------------------------------------\nclass PowerDomainLinkEditor : public QGroupBox\n{\n\tQ_OBJECT\n\npublic:\n\n\t/*!\n\t *  The constructor.\n\t *\n\t *    @param [in] parent      The parent widget.\n\t */\n    explicit PowerDomainLinkEditor(QWidget* parent);\n\t\n\t/*!\n\t *  The destructor.\n\t */\n    ~PowerDomainLinkEditor() final = default;\n\n    //! No copying. No assignment.\n    PowerDomainLinkEditor(const PowerDomainLinkEditor& other) = delete;\n    PowerDomainLinkEditor& operator=(const PowerDomainLinkEditor& other) = delete;\n\n\tvoid setContent(ComponentInstance::PowerDomainLink::List powerDomains,\n\t\tQSharedPointer<Component> externalComponent, QSharedPointer<Component> internalComponent) const noexcept;\n\nsignals:\n\n\tvoid contentChanged();\n\nprivate:\n\n    //-----------------------------------------------------------------------------\n    // Data.\n    //-----------------------------------------------------------------------------\n\n\n\tEditableTableView* view_ = new EditableTableView(this);\n\n\tPowerDomainLinkModel* model_ = new PowerDomainLinkModel(this);\n\n\tPowerDomainLinkDelegate* delegate_ = new PowerDomainLinkDelegate(this);\n\n\tvoid setupLayout();\n};\n\n#endif // POWERDOMAINLINKEDITOR_H\n"
  },
  {
    "path": "editors/common/ComponentInstanceEditor/PowerDomainLinkModel.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: PowerDomainLinkModel.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Esko Pekkarinen\n// Date: 19.10.2023\n//\n// Description:\n// Model for editing power domain links in a component instance.\n//-----------------------------------------------------------------------------\n\n#include \"PowerDomainLinkModel.h\"\n#include \"PowerDomainLinkColumns.h\"\n\n#include <IPXACTmodels/common/Choice.h>\n#include <IPXACTmodels/common/validators/ChoiceValidator.h>\n\n#include <common/KactusColors.h>\n\n//-----------------------------------------------------------------------------\n// Function: PowerDomainLinkModel::PowerDomainLinkModel()\n//-----------------------------------------------------------------------------\nPowerDomainLinkModel::PowerDomainLinkModel(QObject* parent) :\nQAbstractTableModel(parent)\n{\n \n}\n\n//-----------------------------------------------------------------------------\n// Function: PowerDomainLinkModel::rowCount()\n//-----------------------------------------------------------------------------\nint PowerDomainLinkModel::rowCount(const QModelIndex&) const\n{\n    if (powerDomains_.isNull())\n    {\n    return 0;\n    }\n\n    return powerDomains_->count();\n}\n\n//-----------------------------------------------------------------------------\n// Function: PowerDomainLinkModel::columnCount()\n//-----------------------------------------------------------------------------\nint PowerDomainLinkModel::columnCount(const QModelIndex& /*parent*/) const\n{\n    return PowerDomainLinkColumns::COLUMN_COUNT;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PowerDomainLinkModel::data()\n//-----------------------------------------------------------------------------\nQVariant PowerDomainLinkModel::data(const QModelIndex& index, int role) const\n{\n    if (!index.isValid() || index.row() < 0 || index.row() >= powerDomains_->count())\n    {\n        return QVariant();\n    }\n\n    auto const& domain = powerDomains_->at(index.row());\n\n    if (role == Qt::DisplayRole)\n    {\n        if (index.column() == PowerDomainLinkColumns::EXTERNAL_LINK)\n        {\n            return domain->externalReference_;\n        }\n        else if (index.column() == PowerDomainLinkColumns::INTERNAL_LINK)\n        {\n            return domain->internalReferences_.join(QLatin1Char(','));\n        }\n    }\n    else if (role == Qt::EditRole && index.column() == PowerDomainLinkColumns::INTERNAL_LINK)\n    {\n        return domain->internalReferences_;\n    }\n\n    return QVariant();\n}\n\n//-----------------------------------------------------------------------------\n// Function: PowerDomainLinkModel::headerData()\n//-----------------------------------------------------------------------------\nQVariant PowerDomainLinkModel::headerData(int section, Qt::Orientation orientation, int role) const\n{\n    if (orientation != Qt::Horizontal || role != Qt::DisplayRole || section > columnCount(QModelIndex()))\n    {\n        return QVariant();\n    }\n\n    if (section == PowerDomainLinkColumns::EXTERNAL_LINK)\n    {\n        return tr(\"External domain\");\n    }\n    else if (section == PowerDomainLinkColumns::INTERNAL_LINK)\n    {\n        return tr(\"Internal domain(s)\");\n    }\n\n    return QVariant();\n}\n\n//-----------------------------------------------------------------------------\n// Function: PowerDomainLinkModel::setData()\n//-----------------------------------------------------------------------------\nbool PowerDomainLinkModel::setData(const QModelIndex& index, const QVariant& value, int role)\n{\n    if (!index.isValid() || index.row() < 0 )\n    {\n        return false;\n    }\n\n    auto const& domain = powerDomains_->at(index.row());\n\n    if (role == Qt::EditRole)\n    {\n        if (index.column() == PowerDomainLinkColumns::EXTERNAL_LINK)\n        {\n            domain->externalReference_ = value.toString();\n        }\n        else if (index.column() == PowerDomainLinkColumns::INTERNAL_LINK)\n        {\n            domain->internalReferences_ = value.toStringList();\n        }\n\n        emit dataChanged(index, index);\n        emit contentChanged();\n        return true;\n    }\n\n    return false;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PowerDomainLinkModel::flags()\n//-----------------------------------------------------------------------------\nQt::ItemFlags PowerDomainLinkModel::flags(const QModelIndex& index) const\n{\n    if (!index.isValid())\n    {\n        return Qt::NoItemFlags;\n    }\n    \n    return Qt::ItemIsEditable | Qt::ItemIsEnabled | Qt::ItemIsSelectable;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PowerDomainLinkModel::setPowerDomains()\n//-----------------------------------------------------------------------------\nvoid PowerDomainLinkModel::setPowerDomains(ComponentInstance::PowerDomainLink::List powerDomains) noexcept\n{\n    beginResetModel();\n    powerDomains_ = powerDomains;\n    endResetModel();\n}\n\n//-----------------------------------------------------------------------------\n// Function: PowerDomainLinkModel::addItem()\n//-----------------------------------------------------------------------------\nvoid PowerDomainLinkModel::addItem(const QModelIndex& index)\n{\n    int row = powerDomains_->count();\n\n    if (index.isValid())\n    {\n        row = index.row();\n    }\n    \n    beginInsertRows(QModelIndex(), row, row);\n    \n    QSharedPointer<ComponentInstance::PowerDomainLink> newLink(new ComponentInstance::PowerDomainLink());\n\n    powerDomains_->insert(row, newLink);\n    \n    endInsertRows();\n    \n    emit contentChanged();\n}\n\n//-----------------------------------------------------------------------------\n// Function: PowerDomainLinkModel::removeItem()\n//-----------------------------------------------------------------------------\nvoid PowerDomainLinkModel::removeItem(const QModelIndex& index)\n{\n    if (!index.isValid() || index.row() < 0 || index.row() >= powerDomains_->size())\n    {\n        return;\n    }\n    \n    beginRemoveRows(QModelIndex(), index.row(), index.row());\n    \n    powerDomains_->removeAt(index.row());\n    \n    endRemoveRows();\n    \n    emit contentChanged();\n\n}\n"
  },
  {
    "path": "editors/common/ComponentInstanceEditor/PowerDomainLinkModel.h",
    "content": "//-----------------------------------------------------------------------------\n// File: PowerDomainLinkModel.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Esko Pekkarinen\n// Date: 19.10.2023\n//\n// Description:\n// Model for editing power domain links in a component instance.\n//-----------------------------------------------------------------------------\n\n#ifndef PowerDomainLinkModel_H\n#define PowerDomainLinkModel_H\n\n#include <QObject>\n#include <QAbstractTableModel>\n#include <QVariant>\n#include <QModelIndex>\n#include <QSharedPointer>\n\n#include <IPXACTmodels/Design/ComponentInstance.h>\n\nclass Choice;\nclass ChoiceValidator;\n\n//-----------------------------------------------------------------------------\n//! Model for editing power domain links in a component instance.\n//-----------------------------------------------------------------------------\nclass PowerDomainLinkModel : public QAbstractTableModel\n{\n\tQ_OBJECT\n\npublic:\n    \n    /*!\n     *  Constructor.\n     *\n     *    @param [in] parent      The parent object.\n     */\n    explicit PowerDomainLinkModel(QObject* parent = nullptr);\n    \n    /*!\n     *  Destructor.\n     */\n    ~PowerDomainLinkModel() final = default;\n\n\n    // Disable copying.\n    PowerDomainLinkModel(PowerDomainLinkModel const& rhs) = delete;\n    PowerDomainLinkModel& operator=(PowerDomainLinkModel const& rhs) = delete;\n\n    /*!\n     *  Returns the number of rows in this model.\n     *\n     *    @param [in] parent ModelIndex of the item that's rowCount is requested.\n     */\n    int rowCount(QModelIndex const& parent = QModelIndex()) const final;\n\n    /*!\n     *  Returns the number of rows in this model.\n     *\n     *    @param [in] parent ModelIndex of the item that's rowCount is requested.\n     */\n    int columnCount(QModelIndex const& parent = QModelIndex()) const final;\n\n    /*!\n     *  Returns the data stored for the specified item.\n     *\n     *    @param [in] index  ModelIndex of the wanted item.\n     *    @param [in] role   Specifies what kind of data is requested.\n     */\n    QVariant data(QModelIndex const& index, int role = Qt::DisplayRole) const final;\n    \n    /*!\n     *  Returns the data for the header of the list.\n     *\n     *    @param [in] section      Specifies the column for which the header is requested.\n     *    @param [in] orientation  The orientation of the header, only Qt::Horizontal is supported.\n     *    @param [in] role         Specifies what kind of header data is requested.\n     */\n    QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const final;\n    \n    /*!\n     *  Saves the data to the model for specified item\n     *\n     *    @param [in] index  The model index of the item that's data is to be saved.\n     *    @param [in] value  The data that is to be saved.\n     *    @param [in] role   The role specifies what kind of data should be saved.\n     *\n     *    @return True if saving happened successfully.\n     */\n    bool setData(QModelIndex const& index, const QVariant& value, int role = Qt::EditRole) final;\n    \n    /*!\n     *  Returns the item flags that defines the possible operations for the item.\n     *\n     *    @param [in] index Model index that identifies the item.\n     *\n     *    @return Qt::ItemFlags specify the possible operations for the item.\n     */\n    Qt::ItemFlags flags(QModelIndex const& index) const final;\n\n    void setPowerDomains(ComponentInstance::PowerDomainLink::List powerDomains) noexcept;\n\npublic slots:\n\n    \n    /*!\n     *  A new item should be added to given index.\n     *\n     *    @param [in] index The position where new item should be added at.\n     */\n    void addItem(QModelIndex const& index);\n\n    /*!\n     *  Removes the specified item from the model.\n     *\n     *    @param [in] index The model index of the item to remove.\n     */\n    void removeItem(QModelIndex const& index);\n\nsignals:\n\n    /*!\n     *  Emitted when contents of the model change.\n     */\n\tvoid contentChanged();\n    \n\nprivate:\n    \n    \n    //-----------------------------------------------------------------------------\n    // Data.\n    //-----------------------------------------------------------------------------\n\n    ComponentInstance::PowerDomainLink::List powerDomains_;\n};\n\n#endif // PowerDomainLinkModel_H\n"
  },
  {
    "path": "editors/common/ComponentInstanceEditor/componentinstanceeditor.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: componentinstanceeditor.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 11.08.2011\r\n//\r\n// Description:\r\n// Editor to edit the details of a component instance within a design.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"componentinstanceeditor.h\"\r\n\r\n#include <KactusAPI/include/ExpressionFormatter.h>\r\n#include <KactusAPI/include/MultipleParameterFinder.h>\r\n#include <KactusAPI/include/IPXactSystemVerilogParser.h>\r\n\r\n#include <editors/common/DesignCompletionModel.h>\r\n#include <editors/common/ExpressionSet.h>\r\n\r\n#include <editors/HWDesign/HWChangeCommands.h>\r\n#include <editors/HWDesign/HWComponentItem.h>\r\n\r\n#include <editors/SystemDesign/SystemComponentItem.h>\r\n#include <editors/SystemDesign/SWComponentItem.h>\r\n#include <editors/SystemDesign/UndoCommands/SystemChangeCommands.h>\r\n\r\n#include <IPXACTmodels/Component/Component.h>\r\n#include <IPXACTmodels/common/VLNV.h>\r\n#include <IPXACTmodels/Design/Design.h>\r\n#include <IPXACTmodels/Design/ComponentInstance.h>\r\n#include <IPXACTmodels/DesignConfiguration/ViewConfiguration.h>\r\n\r\n#include <QVBoxLayout>\r\n#include <QDockWidget>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentInstanceEditor::ComponentInstanceEditor()\r\n//-----------------------------------------------------------------------------\r\nComponentInstanceEditor::ComponentInstanceEditor(QWidget *parent):\r\nQWidget(parent)\r\n{\r\n    QSharedPointer<MultipleParameterFinder> parameterFinder(new MultipleParameterFinder());\r\n\tparameterFinder->addFinder(instanceFinder_);\r\n    parameterFinder->addFinder(designParameterFinder_);\r\n\r\n    QSharedPointer<IPXactSystemVerilogParser> parameterParser(new IPXactSystemVerilogParser(parameterFinder));\r\n    ExpressionSet parameterExpressions({ parameterFinder , parameterParser,\r\n        QSharedPointer<ExpressionFormatter>(new ExpressionFormatter(parameterFinder)) });\r\n\r\n    QSharedPointer<IPXactSystemVerilogParser> defaultParser (new IPXactSystemVerilogParser(componentFinder_));\r\n    ExpressionSet defaultExpressions({ componentFinder_, defaultParser,\r\n        QSharedPointer<ExpressionFormatter>(new ExpressionFormatter(componentFinder_)) });\r\n\r\n    QSharedPointer<IPXactSystemVerilogParser> designParameterParser(\r\n        new IPXactSystemVerilogParser(parameterFinder));\r\n\r\n\tauto completionModel = new ComponentParameterModel(parameterFinder, this);\r\n\tcompletionModel->setExpressionParser(parameterParser);\r\n\r\n    configurableElements_ = new ComponentInstanceConfigurableElementsEditor(parameterExpressions, \r\n        defaultExpressions, defaultExpressions, completionModel, this);\r\n\r\n\tsetSizePolicy(QSizePolicy::Preferred, QSizePolicy::Expanding);\r\n\r\n    vlnvDisplayer_->setFlat(true);\r\n    nameGroup_->setFlat(true);\r\n    swGroup_->setFlat(true);\r\n    propertyValueEditor_->setFlat(true);\r\n    powerDomainEditor_->setFlat(true);\r\n\r\n\tvlnvDisplayer_->hide();\r\n\tnameGroup_->hide();\r\n    swGroup_->hide();\r\n\tconfigurableElements_->hide();\r\n    propertyValueEditor_->hide();\r\n    powerDomainEditor_->hide();\r\n\r\n\tvlnvDisplayer_->setTitle(tr(\"Component VLNV\"));\r\n\r\n    setupLayout();\r\n\r\n    connect(configurableElements_, SIGNAL(contentChanged()), this, SIGNAL(contentChanged()), Qt::UniqueConnection);\r\n    connect(nameGroup_, SIGNAL(nameChanged()), this, SLOT(onNameChanged()), Qt::UniqueConnection);\r\n    connect(nameGroup_, SIGNAL(displayNameChanged()), this, SLOT(onDisplayNameChanged()), Qt::UniqueConnection);\r\n    connect(nameGroup_, SIGNAL(descriptionChanged()), this, SLOT(onDescriptionChanged()), Qt::UniqueConnection);\r\n    connect(propertyValueEditor_, SIGNAL(contentChanged()),\r\n            this, SLOT(onPropertyValuesChanged()), Qt::UniqueConnection);            \r\n\r\n    connect(powerDomainEditor_, SIGNAL(contentChanged()), this, SIGNAL(contentChanged()), Qt::UniqueConnection);\r\n\r\n    connect(configurableElements_, SIGNAL(increaseReferences(QString const&)),\r\n        this, SIGNAL(increaseReferences(QString const&)), Qt::UniqueConnection);\r\n    connect(configurableElements_, SIGNAL(decreaseReferences(QString const&)),\r\n        this, SIGNAL(decreaseReferences(QString const&)), Qt::UniqueConnection);\r\n\r\n    clear();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentInstanceEditor::setComponentInstance()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentInstanceEditor::setComponentInstance(ComponentItem* componentItem,\r\n    QSharedPointer<IEditProvider> editProvider, QSharedPointer<Design> design,\r\n    QSharedPointer<DesignConfiguration> designConfiguration, QString const& activeViewName)\r\n{\r\n\tQ_ASSERT(componentItem);\r\n\r\n\t// if previous component has been specified, then disconnect signals to this editor.\r\n\tif (component_)\r\n    {\r\n\t\tcomponent_->disconnect(this);\r\n        component_->disconnect(propertyValueEditor_);\r\n\t\tcomponent_->disconnect(nameGroup_);\r\n        component_->disconnect(fileSetRefCombo_);\r\n\r\n        disconnect(fileSetRefCombo_, SIGNAL(currentTextChanged(QString const&)),\r\n                   this, SLOT(onFileSetRefChanged(QString const&)));\r\n\t}\r\n\r\n    designParameterFinder_->setParameterList(design->getParameters());\r\n    containingDesign_ = design;\r\n\tcomponent_ = componentItem;\r\n    componentFinder_->setComponent(componentItem->componentModel());\r\n\r\n    instanceFinder_->setParameterList(componentItem->componentModel()->getParameters());\r\n    instanceFinder_->setCEVList(componentItem->getComponentInstance()->getConfigurableElementValues());\r\n\r\n    auto instanceViewName = QString();\r\n\r\n    if (designConfiguration)\r\n    {\r\n        instanceViewName = designConfiguration->getActiveView(componentItem->name());\r\n    }\r\n\r\n    activeViewLabel_->parentWidget()->show();\r\n    activeViewLabel_->setText(instanceViewName);\r\n    \r\n    topFinder_->setActiveView(topComponent_->getModel()->findView(activeViewName));    \r\n\r\n\t// set the vlnv of the component to be displayed\r\n    vlnvDisplayer_->setVLNV(componentItem->componentModel()->getVlnv());\r\n\tvlnvDisplayer_->show();\r\n\r\n\tnameGroup_->setName(componentItem->name());\r\n\tnameGroup_->setDisplayName(componentItem->displayName());\r\n\r\n    disconnect(nameGroup_, SIGNAL(descriptionChanged()),\r\n        this, SLOT(onDescriptionChanged()));\r\n    nameGroup_->setDescription(componentItem->description());\r\n    connect(nameGroup_, SIGNAL(descriptionChanged()), this, SLOT(onDescriptionChanged()), Qt::UniqueConnection);\r\n\r\n\tnameGroup_->show();\r\n\r\n    // Show the file set reference if the component is software.\r\n    if (auto swComponent = dynamic_cast<SWComponentItem*>(componentItem);\r\n        swComponent != nullptr)\r\n    {\r\n        fileSetRefCombo_->clear();\r\n        fileSetRefCombo_->addItem(\"\");\r\n        fileSetRefCombo_->addItems(topComponent_->getFileSetNames());\r\n\r\n        int index = fileSetRefCombo_->findText(swComponent->getFileSetRef());\r\n\r\n        if (index != -1)\r\n        {\r\n            fileSetRefCombo_->setCurrentIndex(index);\r\n        }\r\n\r\n        swGroup_->show();\r\n\r\n        connect(swComponent, SIGNAL(fileSetRefChanged(QString const&)),\r\n                this, SLOT(updateFileSetRef(QString const&)), Qt::UniqueConnection);\r\n    }\r\n    else\r\n    {\r\n        swGroup_->hide();\r\n    }\r\n\r\n    // Show the component's property values in case of SW/HW mapping.\r\n\tif (auto swComponent = dynamic_cast<SystemComponentItem*>(componentItem);\r\n        swComponent != nullptr)\r\n    {\r\n        propertyValueEditor_->setData(swComponent->getPropertyValues());\r\n        propertyValueEditor_->setAllowedProperties(swComponent->componentModel()->getSWProperties());\r\n\r\n        propertyValueEditor_->show();\r\n        configurableElements_->hide();\r\n        powerDomainEditor_->hide();\r\n\r\n        connect(swComponent, SIGNAL(propertyValuesChanged(QMap<QString, QString> const&)),\r\n                propertyValueEditor_, SLOT(setData(QMap<QString, QString> const&)), Qt::UniqueConnection);\r\n    }\r\n    else\r\n    {\r\n        propertyValueEditor_->hide();\r\n\r\n        if (designConfiguration)\r\n        {\r\n            QSharedPointer<ViewConfiguration> matchingViewConfiguration =\r\n                designConfiguration->getViewConfiguration(componentItem->getComponentInstance()->getInstanceName());\r\n\r\n            // Show the component's configurable elements in case of HW.\r\n            configurableElements_->setComponent(componentItem->componentModel(), componentItem->getComponentInstance(),\r\n                matchingViewConfiguration, editProvider);\r\n        }\r\n        \r\n        if (design->getRevision() == Document::Revision::Std22)\r\n        {\r\n            powerDomainEditor_->setContent(componentItem->getComponentInstance()->getPowerDomainLinks(),\r\n                topComponent_, componentItem->componentModel());\r\n            powerDomainEditor_->show();\r\n        }\r\n\r\n\t    configurableElements_->show();\r\n\r\n    }\r\n\r\n\tconnect(component_, SIGNAL(nameChanged(QString const&, QString const&)),\r\n\t\t    nameGroup_, SLOT(setName(QString const&)), Qt::UniqueConnection);\r\n\tconnect(component_, SIGNAL(displayNameChanged(QString const&)),\r\n\t\t    nameGroup_, SLOT(setDisplayName(QString const&)), Qt::UniqueConnection);\r\n\tconnect(component_, SIGNAL(descriptionChanged(QString const&)),\r\n\t\t    nameGroup_, SLOT(setDescription(QString const&)), Qt::UniqueConnection);\r\n\r\n    connect(fileSetRefCombo_, SIGNAL(currentTextChanged(QString const&)),\r\n        this, SLOT(onFileSetRefChanged(QString const&)), Qt::UniqueConnection);\r\n\r\n\t// if the connected component is destroyed then clear this editor\r\n\tconnect(component_, SIGNAL(destroyed(ComponentItem*)), this, SLOT(clear()), Qt::UniqueConnection);\r\n\r\n\tparentWidget()->setMaximumHeight(QWIDGETSIZE_MAX);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentInstanceEditor::setContext()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentInstanceEditor::setContext(QSharedPointer<Component> topComponent,\r\n     QSharedPointer<IEditProvider> editProvider)\r\n{\r\n    topFinder_->setComponent(topComponent);\r\n    editProvider_ = editProvider;\r\n    topComponent_ = topComponent;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentInstanceEditor::setProtection()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentInstanceEditor::setProtection(bool locked)\r\n{\r\n    nameGroup_->setEnabled(!locked);\r\n    fileSetRefCombo_->setEnabled(!locked);\r\n    propertyValueEditor_->setEnabled(!locked);\r\n    powerDomainEditor_->setEnabled(!locked);\r\n    configurableElements_->setEnabled(!locked);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentInstanceEditor::setTopComponentActiveView()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentInstanceEditor::setTopComponentActiveView(QSharedPointer<View> activeView)\r\n{\r\n\ttopFinder_->setActiveView(activeView);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentInstanceEditor::clear()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentInstanceEditor::clear()\r\n{\r\n\t// if previous component has been specified, then disconnect signals to this editor.\r\n\tif (component_)\r\n    {\r\n        component_->disconnect(this);\r\n        component_->disconnect(propertyValueEditor_);\r\n        component_->disconnect(nameGroup_);\r\n        component_->disconnect(fileSetRefCombo_);\r\n\r\n        disconnect(fileSetRefCombo_, SIGNAL(currentTextChanged(QString const&)),\r\n                   this, SLOT(onFileSetRefChanged(QString const&)));\r\n\t}\r\n\r\n\tcomponent_ = nullptr;\r\n\tvlnvDisplayer_->hide();\r\n\tnameGroup_->hide();\r\n    swGroup_->hide();\r\n    fileSetRefCombo_->clear();\r\n    propertyValueEditor_->hide();\r\n    powerDomainEditor_->hide();\r\n\tconfigurableElements_->hide();\r\n\tconfigurableElements_->clear();\r\n    activeViewLabel_->parentWidget()->hide();\r\n\r\n\tparentWidget()->setMaximumHeight(20);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentInstanceEditor::onNameChanged()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentInstanceEditor::onNameChanged()\r\n{\r\n    if (component_)\r\n    {\r\n        auto newName = nameGroup_->name();\r\n\r\n        QSharedPointer<ComponentChangeNameCommand> cmd(\r\n            new ComponentChangeNameCommand(component_, newName, containingDesign_));\r\n\r\n        disconnect(component_, SIGNAL(nameChanged(QString const&, QString const&)),\r\n            nameGroup_, SLOT(setName(QString const&)));\r\n\r\n        editProvider_->addCommand(cmd);\r\n        cmd->redo();\r\n\r\n        connect(component_, SIGNAL(nameChanged(QString const&, QString const&)),\r\n            nameGroup_, SLOT(setName(QString const&)), Qt::UniqueConnection);\r\n    }\t\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentInstanceEditor::onDisplayNameChanged()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentInstanceEditor::onDisplayNameChanged()\r\n{\r\n    if (component_)\r\n    {\r\n        QString newDisplayName = nameGroup_->displayName();\r\n\r\n\t    // create command to the undo/redo stack\r\n\t    QSharedPointer<ComponentChangeDisplayNameCommand> cmd(new ComponentChangeDisplayNameCommand(component_, \r\n            newDisplayName));\r\n\r\n\t    disconnect(component_, SIGNAL(displayNameChanged(QString const&)),\r\n            nameGroup_, SLOT(setDisplayName(QString const&)));\r\n\r\n\t    editProvider_->addCommand(cmd);\r\n        cmd->redo();\r\n\r\n\t    connect(component_, SIGNAL(displayNameChanged(QString const&)),\r\n            nameGroup_, SLOT(setDisplayName(QString const&)), Qt::UniqueConnection);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentInstanceEditor::onDescriptionChanged()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentInstanceEditor::onDescriptionChanged()\r\n{\r\n    if (component_)\r\n    {\r\n        QString newDescription = nameGroup_->description();\r\n\r\n        QSharedPointer<ComponentChangeDescriptionNameCommand> cmd(new ComponentChangeDescriptionNameCommand(\r\n            component_, newDescription));\r\n\r\n        disconnect(component_, SIGNAL(descriptionChanged(QString const&)),\r\n            nameGroup_, SLOT(setDescription(QString const&)));\r\n        editProvider_->addCommand(cmd);\r\n        cmd->redo();\r\n        connect(component_, SIGNAL(descriptionChanged(QString const&)),\r\n            nameGroup_, SLOT(setDescription(QString const&)), Qt::UniqueConnection);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentInstanceEditor::onPropertyValuesChanged()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentInstanceEditor::onPropertyValuesChanged()\r\n{\r\n    disconnect(component_, SIGNAL(propertyValuesChanged(QMap<QString, QString> const&)),\r\n               propertyValueEditor_, SLOT(setData(QMap<QString, QString> const&)));\r\n\r\n    auto swComp = static_cast<SystemComponentItem*>(component_);\r\n    QSharedPointer<PropertyValuesChangeCommand> cmd(new PropertyValuesChangeCommand(swComp,\r\n        propertyValueEditor_->getData()));\r\n    editProvider_->addCommand(cmd);\r\n    cmd->redo();\r\n\r\n    connect(component_, SIGNAL(propertyValuesChanged(QMap<QString, QString> const&)),\r\n            propertyValueEditor_, SLOT(setData(QMap<QString, QString> const&)), Qt::UniqueConnection);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentInstanceEditor::onFileSetRefChanged()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentInstanceEditor::onFileSetRefChanged(QString const& fileSetRef)\r\n{\r\n    disconnect(component_, SIGNAL(fileSetRefChanged(QString const&)),\r\n               this, SLOT(updateFileSetRef(QString const&)));\r\n\r\n    auto swComp = static_cast<SWComponentItem*>(component_);\r\n    QSharedPointer<FileSetRefChangeCommand> cmd(new FileSetRefChangeCommand(swComp, fileSetRef));\r\n    editProvider_->addCommand(cmd);\r\n    cmd->redo();\r\n\r\n    connect(component_, SIGNAL(fileSetRefChanged(QString const&)),\r\n            this, SLOT(updateFileSetRef(QString const&)), Qt::UniqueConnection);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentInstanceEditor::updateFileSetRef()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentInstanceEditor::updateFileSetRef(QString const& fileSetRef)\r\n{\r\n    int index = qMax(fileSetRefCombo_->findText(fileSetRef), 0);\r\n    fileSetRefCombo_->setCurrentIndex(index);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentInstanceEditor::setupLayout()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentInstanceEditor::setupLayout()\r\n{\r\n    auto swGroupLayout = new QHBoxLayout(swGroup_);\r\n    swGroupLayout->addWidget(new QLabel(tr(\"File set reference:\"), this));\r\n    swGroupLayout->addWidget(fileSetRefCombo_, 1);\r\n\r\n    auto configurationBox = new QGroupBox(tr(\"Configuration\"), this);\r\n    configurationBox->setFlat(true);\r\n\r\n    auto configurationLayout = new QFormLayout(configurationBox);\r\n    configurationLayout->addRow(tr(\"Active view:\"), activeViewLabel_);\r\n\r\n    auto layout = new QVBoxLayout(this);\r\n    layout->addWidget(vlnvDisplayer_);\r\n    layout->addWidget(nameGroup_);\r\n    layout->addWidget(configurationBox);\r\n    layout->addWidget(powerDomainEditor_);\r\n    layout->addWidget(configurableElements_, 1);\r\n    layout->addWidget(swGroup_);\r\n    layout->addWidget(propertyValueEditor_);\r\n    layout->addStretch();\r\n}\r\n"
  },
  {
    "path": "editors/common/ComponentInstanceEditor/componentinstanceeditor.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: componentinstanceeditor.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 11.08.2011\r\n//\r\n// Description:\r\n// Editor to edit the details of a component instance within a design.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef COMPONENTINSTANCEEDITOR_H\r\n#define COMPONENTINSTANCEEDITOR_H\r\n\r\n#include \"PowerDomainLinkEditor.h\"\r\n\r\n#include <common/IEditProvider.h>\r\n#include <common/widgets/vlnvDisplayer/vlnvdisplayer.h>\r\n#include <common/widgets/nameGroupBox/namegroupbox.h>\r\n\r\n#include <KactusAPI/include/ComponentParameterFinder.h>\r\n#include <KactusAPI/include/ListParameterFinder.h>\r\n#include <KactusAPI/include/ParameterConfigurableElementFinder.h>\r\n\r\n#include <editors/ComponentEditor/software/PropertyValueEditor.h>\r\n#include <editors/ComponentEditor/common/ConfigurableElementFinder.h>\r\n\r\n#include <editors/common/ComponentInstanceEditor/ComponentInstanceConfigurableElementsEditor.h>\r\n#include <editors/common/TopComponentParameterFinder.h>\r\n\r\n#include <QWidget>\r\n#include <QComboBox>\r\n#include <QGroupBox>\r\n#include <QSharedPointer>\r\n\r\nclass ComponentItem;\r\nclass ParameterFinder;\r\nclass TopComponentParameterFinder;\r\nclass Design;\r\nclass DesignCompletionModel;\r\nclass View;\r\nclass ListParameterFinder;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Editor to edit the details of a component instance within a design.\r\n//-----------------------------------------------------------------------------\r\nclass ComponentInstanceEditor : public QWidget\r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\r\n\t/*!\r\n     *  The constructor\r\n\t *\r\n\t *    @param [in] parent Pointer to the owner of this widget.\r\n\t */\r\n\tComponentInstanceEditor(QWidget *parent);\r\n\t\r\n\t//! The destructor.\r\n\tvirtual ~ComponentInstanceEditor() = default;\r\n\r\n    //! No copying.\r\n    ComponentInstanceEditor(const ComponentInstanceEditor& other) = delete;\r\n\r\n    //! No assignment.\r\n    ComponentInstanceEditor& operator=(const ComponentInstanceEditor& other) = delete;\r\n\r\n\t/*!\r\n     *  Set the component to be edited.\r\n\t *\r\n\t *    @param [in] component       Pointer to the component instance being edited.\r\n     *    @param [in] editProvider    Interface for providing editing capabilities (undo & redo).\r\n     *    @param [in] design          Design containing the component instance.\r\n\t */\r\n    void setComponentInstance(ComponentItem* component, QSharedPointer<IEditProvider> editProvider,\r\n        QSharedPointer<Design> design, QSharedPointer<DesignConfiguration> designConfiguration, QString const& activeViewName);\r\n\r\n    /*!\r\n     *  Sets the top component for the instances.\r\n     *\r\n     *    @param [in] topComponent            The top component.\r\n     *    @param [in] editProvider            The generic edit provider.\r\n     */\r\n    void setContext(QSharedPointer<Component> topComponent, QSharedPointer<IEditProvider> editProvider);\r\n\r\n    /*!\r\n     *  Sets the protection state for the instance editor.\r\n     *\r\n     *    @param [in] locked   Locks/unlock the editor.\r\n     */\r\n    void setProtection(bool locked);\r\n\r\npublic slots:\r\n        \r\n    /*!\r\n     *  Sets the active view to use for the top component.\r\n     *\r\n     *    @param [in] activeView   The name of the active view.\r\n     */\r\n    void setTopComponentActiveView(QSharedPointer<View> activeView);\r\n\r\n\t/*!\r\n     *  Clear the editor so no instance details are shown\r\n\t */\r\n\tvoid clear();\r\n\r\nsignals:\r\n\r\n\t/*!\r\n     *  Emitted when contents of the editor changes.\r\n     */\r\n\tvoid contentChanged();\r\n    \r\n    /*!\r\n     *  Increase the amount of references to a parameter with the matching ID.\r\n     *\r\n     *    @param [in] id  ID of the parameter, whose references are being increased.\r\n     */\r\n    void increaseReferences(QString const& id);\r\n\r\n    /*!\r\n     *  Decrease the amount of references to a parameter with a matching ID.\r\n     *\r\n     *    @param [in] id  ID of the parameter, whose references are being decreased.\r\n     */\r\n    void decreaseReferences(QString const& id);\r\n\r\nprivate slots:\r\n\r\n\t//! Handler when user changes the name of the component instance.\r\n    void onNameChanged();\r\n\r\n\t//! Handler when user changes the display name of the component instance.\r\n    void onDisplayNameChanged();\r\n\r\n\t//! Handler when user changes the description of the component instance.\r\n    void onDescriptionChanged();\r\n\r\n    //! Handler when the user changes any property values.\r\n    void onPropertyValuesChanged();\r\n\r\n    //! Handler when the user changes the file set reference.\r\n    void onFileSetRefChanged(QString const& fileSetRef);\r\n\r\n    //! Updates the file set reference when it is changed from the component.\r\n    void updateFileSetRef(QString const& fileSetRef);\r\n\r\nprivate:\r\n    void setupLayout();\r\n\r\n\t//! Pointer to the component instance being edited.\r\n\tComponentItem* component_ = nullptr;\r\n\r\n\t//! The widget to display the vlnv of the component instance\r\n\tVLNVDisplayer* vlnvDisplayer_ = new VLNVDisplayer(this, VLNV(), true);\r\n\r\n\t//! The widget to set the instance name, display name and description.\r\n\tNameGroupBox* nameGroup_ = new NameGroupBox(this, tr(\"Component instance name\"));\r\n\r\n    QLabel* activeViewLabel_ = new QLabel(this);\r\n\r\n\t//! The widget to set the configurable elements of a component instance.\r\n    ComponentInstanceConfigurableElementsEditor* configurableElements_ = nullptr;\r\n\r\n    //! The widget for setting power domain links.\r\n    PowerDomainLinkEditor* powerDomainEditor_ = new PowerDomainLinkEditor(this);\r\n\r\n    //! SW group.\r\n    QGroupBox* swGroup_ = new QGroupBox(tr(\"Software\"), this);\r\n\r\n    //! File set reference combo box.\r\n    QComboBox* fileSetRefCombo_ = new QComboBox(this);\r\n\r\n    //! Property value editor for SW properties.\r\n    PropertyValueEditor* propertyValueEditor_ = new PropertyValueEditor(this);\r\n\r\n\t//! Pointer to the generic edit provider that manages the undo/redo stack.\r\n\tQSharedPointer<IEditProvider> editProvider_ = nullptr;\r\n\r\n    //! Parameter finder for configurable element values.\r\n    QSharedPointer<ParameterConfigurableElementFinder> instanceFinder_ = \r\n        QSharedPointer<ParameterConfigurableElementFinder>(new ParameterConfigurableElementFinder());\r\n\r\n    //! The parameter finder for component instances.\r\n    QSharedPointer<ComponentParameterFinder> componentFinder_ =\r\n        QSharedPointer<ComponentParameterFinder>(new ComponentParameterFinder(nullptr));\r\n\r\n    //! The parameter finder for component instances.\r\n    QSharedPointer<TopComponentParameterFinder> topFinder_ =\r\n        QSharedPointer<TopComponentParameterFinder>(new TopComponentParameterFinder(nullptr));\r\n\r\n    //! The parameter finder for design.\r\n    QSharedPointer<ListParameterFinder> designParameterFinder_ =\r\n        QSharedPointer<ListParameterFinder>(new ListParameterFinder());\r\n\r\n    //! The current top component.\r\n    QSharedPointer<Component> topComponent_ = nullptr;\r\n\r\n    //! The design containing the component instance.\r\n    QSharedPointer<Design> containingDesign_ = nullptr;\r\n};\r\n\r\n#endif // COMPONENTINSTANCEEDITOR_H\r\n"
  },
  {
    "path": "editors/common/ComponentInstanceEditor/configurableelementdelegate.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: configurableelementdelegate.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 12.08.2011\r\n//\r\n// Description:\r\n// Delegate that provides editors to edit the configurable element values.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"configurableelementdelegate.h\"\r\n\r\n#include <common/KactusColors.h>\r\n\r\n#include <KactusAPI/include/IPXactSystemVerilogParser.h>\r\n#include <editors/ComponentEditor/parameters/Array/ArrayView.h>\r\n#include <editors/ComponentEditor/parameters/Array/ParameterArrayModel.h>\r\n#include <editors/ComponentEditor/parameters/Array/ArrayDelegate.h>\r\n\r\n#include <editors/common/ComponentInstanceEditor/ConfigurableElementsColumns.h>\r\n#include <editors/common/ComponentInstanceEditor/ConfigurableElementsModel.h>\r\n#include <editors/HWDesign/undoCommands/ConfigurableElementChangeCommand.h>\r\n#include <editors/HWDesign/undoCommands/ConfigurableElementRemoveCommand.h>\r\n\r\n#include <IPXACTmodels/common/Choice.h>\r\n#include <IPXACTmodels/common/Enumeration.h>\r\n\r\n#include <QPen>\r\n#include <QPainter>\r\n#include <QComboBox>\r\n#include <QScrollArea>\r\n#include <QSharedPointer>\r\n#include <QSortFilterProxyModel>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: configurableelementdelegate::ConfigurableElemenetDelegate()\r\n//-----------------------------------------------------------------------------\r\nConfigurableElementDelegate::ConfigurableElementDelegate(QAbstractItemModel* completionModel,\r\n    QSharedPointer<ParameterFinder> parameterFinder, QSharedPointer<ExpressionFormatter> expressionFormatter,\r\n    QObject *parent) :\r\nChoiceCreatorDelegate(completionModel, parameterFinder, parent),\r\nexpressionFormatter_(expressionFormatter)\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: configurableelementdelegate::setEditProvider()\r\n//-----------------------------------------------------------------------------\r\nvoid ConfigurableElementDelegate::setEditProvider(QSharedPointer<IEditProvider> newEditProvider)\r\n{\r\n    editProvider_ = newEditProvider;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: configurableelementdelegate::createEditor()\r\n//-----------------------------------------------------------------------------\r\nQWidget* ConfigurableElementDelegate::createEditor(QWidget* parent, QStyleOptionViewItem const& option,\r\n    QModelIndex const& index) const\r\n{\r\n    if (index.column() == valueColumn() && valueIsArray(index))\r\n    {\r\n        auto editor = new ArrayView(parent);\r\n\r\n        auto scrollingWidget = new QScrollArea(parent);\r\n        scrollingWidget->setWidgetResizable(true);\r\n        scrollingWidget->setWidget(editor);\r\n        scrollingWidget->parent()->installEventFilter(editor);\r\n\r\n        return scrollingWidget;\r\n    }\r\n\r\n    else\r\n    {\r\n        return ChoiceCreatorDelegate::createEditor(parent, option, index);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: configurableelementdelegate::setEditorData()\r\n//-----------------------------------------------------------------------------\r\nvoid ConfigurableElementDelegate::setEditorData(QWidget* editor, QModelIndex const& index) const\r\n{\r\n    if (index.column() == valueColumn() && valueIsArray(index))\r\n    {\r\n        createArrayEditor(editor, index);\r\n    }\r\n\r\n    else\r\n    {\r\n        ChoiceCreatorDelegate::setEditorData(editor, index);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: configurableelementdelegate::setModelData()\r\n//-----------------------------------------------------------------------------\r\nvoid ConfigurableElementDelegate::setModelData(QWidget* editor, QAbstractItemModel* model,\r\n    QModelIndex const& index) const\r\n{\r\n    QString oldData = model->data(index, Qt::EditRole).toString();\r\n\r\n    if (index.column() == valueColumn() && valueIsArray(index))\r\n    {\r\n        auto scrollWidget = qobject_cast<QScrollArea*>(editor);\r\n        auto arrayTable = qobject_cast<ArrayView*>(scrollWidget->widget());\r\n        auto arrayModel = qobject_cast<ParameterArrayModel*>(arrayTable->model());\r\n\r\n        QString arrayValue = arrayModel->getArrayData();\r\n        model->setData(index, arrayValue, Qt::EditRole);\r\n    }\r\n\r\n    else\r\n    {\r\n        ChoiceCreatorDelegate::setModelData(editor, model, index);\r\n    }\r\n\r\n    QString newData = model->data(index, Qt::EditRole).toString();\r\n    if (oldData != newData)\r\n    {\r\n        createElementChangeCommand(oldData, newData, index, model);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: configurableelementdelegate::createElementChangeCommand()\r\n//-----------------------------------------------------------------------------\r\nvoid ConfigurableElementDelegate::createElementChangeCommand(QString const& oldValue, QString const& newValue,\r\n    QModelIndex const& index, QAbstractItemModel* cevModel) const\r\n{\r\n    QString modifiedNewValue = newValue;\r\n    if (newValue.isEmpty())\r\n    {\r\n        QModelIndex defaultValueIndex = index.sibling(index.row(), ConfigurableElementsColumns::DEFAULT_VALUE);\r\n        modifiedNewValue = defaultValueIndex.data(Qt::EditRole).toString();\r\n\r\n        if (modifiedNewValue == oldValue)\r\n        {\r\n            return;\r\n        }\r\n    }\r\n\r\n    QVariant configurableElements =\r\n        cevModel->data(index, ConfigurableElementsModel::getItemConfigurableElementValuesRole);\r\n\r\n    if (configurableElements.canConvert<QSharedPointer<QList<QSharedPointer<ConfigurableElementValue> > > > ())\r\n    {\r\n        QSharedPointer<QList<QSharedPointer<ConfigurableElementValue> > > itemConfigurableElements =\r\n            configurableElements.value<QSharedPointer<QList<QSharedPointer<ConfigurableElementValue> > > >();\r\n\r\n        QString elementID = cevModel->data(index, ConfigurableElementsModel::parameterIDRole).toString();\r\n\r\n        QModelIndex defaultValueIndex = index.sibling(index.row(), ConfigurableElementsColumns::DEFAULT_VALUE);\r\n        QString defaultValue = cevModel->data(defaultValueIndex, Qt::EditRole).toString();\r\n\r\n        QSharedPointer<ConfigurableElementChangeCommand> elementChangeCommand(new ConfigurableElementChangeCommand(\r\n            elementID, oldValue, modifiedNewValue, defaultValue, itemConfigurableElements));\r\n\r\n        connect(elementChangeCommand.data(), SIGNAL(dataChangedInID(QString const&, QString const&)),\r\n            this, SIGNAL(dataChangedInID(QString const&, QString const&)), Qt::UniqueConnection);\r\n\r\n        if (newValue.isEmpty())\r\n        {\r\n            connect(elementChangeCommand.data(), SIGNAL(increaseReferencesInNewValue(QString const&)),\r\n                this, SLOT(increaseReferencesInNewValue(QString const&)), Qt::UniqueConnection);\r\n            connect(elementChangeCommand.data(), SIGNAL(decreaseReferencesInOldValue(QString const&)),\r\n                this, SLOT(decreaseReferencesInOldValue(QString const&)), Qt::UniqueConnection);\r\n        }\r\n\r\n        addCommandToStackAndRedo(elementChangeCommand);\r\n\r\n        if (!newValue.isEmpty())\r\n        {\r\n            connect(elementChangeCommand.data(), SIGNAL(increaseReferencesInNewValue(QString const&)),\r\n                this, SLOT(increaseReferencesInNewValue(QString const&)), Qt::UniqueConnection);\r\n            connect(elementChangeCommand.data(), SIGNAL(decreaseReferencesInOldValue(QString const&)),\r\n                this, SLOT(decreaseReferencesInOldValue(QString const&)), Qt::UniqueConnection);\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: configurableelementdelegate::onCreateRemoveElementCommands()\r\n//-----------------------------------------------------------------------------\r\nvoid ConfigurableElementDelegate::onCreateRemoveElementCommands(QModelIndexList const& indexes)\r\n{\r\n    if (!indexes.isEmpty())\r\n    {\r\n        QSharedPointer<QUndoCommand> parentCommand(new QUndoCommand());\r\n\r\n        for (QModelIndex const& index : indexes)\r\n        {\r\n            int indexRowCount = index.model()->rowCount(index);\r\n            if (index.parent().isValid() || (!index.parent().isValid() && indexRowCount == 0))\r\n            {\r\n                auto elementRemoveCommand = createElementRemoveCommand(index, parentCommand);\r\n\r\n                connect(elementRemoveCommand, SIGNAL(increaseReferencesInNewValue(QString const&)),\r\n                    this, SLOT(increaseReferencesInNewValue(QString const&)), Qt::UniqueConnection);\r\n                connect(elementRemoveCommand, SIGNAL(decreaseReferencesInOldValue(QString const&)),\r\n                    this, SLOT(decreaseReferencesInOldValue(QString const&)), Qt::UniqueConnection);\r\n            }\r\n        }\r\n\r\n        addCommandToStackAndRedo(parentCommand);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: configurableelementdelegate::onCreateRemoveElementCommands()\r\n//-----------------------------------------------------------------------------\r\nvoid ConfigurableElementDelegate::onCreateRemoveElementCommands(QModelIndex const& index)\r\n{\r\n\tQSharedPointer<QUndoCommand> parentCommand(new QUndoCommand());\r\n\r\n\tif (index.parent().isValid() || (!index.parent().isValid() && index.model()->rowCount(index) == 0))\r\n\t{\r\n\t\tauto elementRemoveCommand = createElementRemoveCommand(index, parentCommand);\r\n\r\n\t\tconnect(elementRemoveCommand, SIGNAL(increaseReferencesInNewValue(QString const&)),\r\n\t\t\tthis, SLOT(increaseReferencesInNewValue(QString const&)), Qt::UniqueConnection);\r\n\t\tconnect(elementRemoveCommand, SIGNAL(decreaseReferencesInOldValue(QString const&)),\r\n\t\t\tthis, SLOT(decreaseReferencesInOldValue(QString const&)), Qt::UniqueConnection);\r\n\t}\r\n\r\n\taddCommandToStackAndRedo(parentCommand);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: configurableelementdelegate::createElementRemoveCommand()\r\n//-----------------------------------------------------------------------------\r\nConfigurableElementRemoveCommand* ConfigurableElementDelegate::createElementRemoveCommand(\r\n    QModelIndex const& index, QSharedPointer<QUndoCommand> parentCommand)\r\n{\r\n    int filteredRow = getFilteredIndexRow(index);\r\n    QString parentName = getIndexedParentName(index.parent());\r\n\r\n    QSharedPointer<QList<QSharedPointer<ConfigurableElementValue> > > itemConfigurableElements =\r\n        getIndexedConfigurableElements(index);\r\n\r\n    QString elementID = index.data(ConfigurableElementsModel::parameterIDRole).toString();\r\n\r\n    auto elementRemoveCommand(new ConfigurableElementRemoveCommand(elementID, filteredRow, parentName,\r\n        itemConfigurableElements, parentCommand.data()));\r\n\r\n    connectElementRemoveCommand(elementRemoveCommand);\r\n\r\n    return elementRemoveCommand;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: configurableelementdelegate::getFilteredIndexRow()\r\n//-----------------------------------------------------------------------------\r\nint ConfigurableElementDelegate::getFilteredIndexRow(QModelIndex const& index) const\r\n{\r\n    QModelIndex modelIndex = index;\r\n\r\n    if (auto filter = dynamic_cast<const QSortFilterProxyModel*>(index.model()); \r\n        filter)\r\n    {\r\n        modelIndex = filter->mapToSource(index);\r\n    }\r\n\r\n    return modelIndex.row();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: configurableelementdelegate::getIndexedParentName()\r\n//-----------------------------------------------------------------------------\r\nQString ConfigurableElementDelegate::getIndexedParentName(QModelIndex const& parentIndex) const\r\n{\r\n    QModelIndex parentNameIndex = parentIndex.sibling(parentIndex.row(), ConfigurableElementsColumns::NAME);\r\n    return parentNameIndex.data().toString();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: configurableelementdelegate::getIndexedConfigurableElements()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<QList<QSharedPointer<ConfigurableElementValue> > > ConfigurableElementDelegate::\r\n    getIndexedConfigurableElements(QModelIndex const& index) const\r\n{\r\n    QSharedPointer<QList<QSharedPointer<ConfigurableElementValue> > > itemConfigurableElements(0);\r\n\r\n    QVariant configurableElements = index.data(ConfigurableElementsModel::getItemConfigurableElementValuesRole);\r\n    if (configurableElements.canConvert<QSharedPointer<QList<QSharedPointer<ConfigurableElementValue> > > > ())\r\n    {\r\n        itemConfigurableElements = configurableElements.value\r\n            <QSharedPointer<QList<QSharedPointer<ConfigurableElementValue> > > > ();\r\n    }\r\n\r\n    return itemConfigurableElements;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: configurableelementdelegate::connectElementRemoveCommand()\r\n//-----------------------------------------------------------------------------\r\nvoid ConfigurableElementDelegate::connectElementRemoveCommand(ConfigurableElementRemoveCommand* removeCommand)\r\n{\r\n    connect(removeCommand, SIGNAL(addConfigurableElement(QString const&, QString const&, int)),\r\n        this, SIGNAL(addConfigurableElement(QString const&, QString const&, int)),\r\n        Qt::UniqueConnection);\r\n    connect(removeCommand, SIGNAL(removeConfigurableElement(QString const&, int)),\r\n        this, SIGNAL(removeConfigurableElement(QString const&, int)), Qt::UniqueConnection);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: configurableelementdelegate::onCreateMultipleElementRemoveCommands()\r\n//-----------------------------------------------------------------------------\r\nvoid ConfigurableElementDelegate::onCreateMultipleElementRemoveCommands(QModelIndexList const& indexes)\r\n{\r\n    if (indexes.isEmpty())\r\n    {\r\n        return;\r\n    }\r\n\r\n    QSharedPointer<QUndoCommand> mainRemoveCommand(new QUndoCommand());\r\n\r\n    for (QModelIndex const& index : indexes)\r\n    {\r\n        if (index.isValid() && !index.parent().isValid())\r\n        {\r\n            QUndoCommand* multipleRemoveCommand(new QUndoCommand(mainRemoveCommand.data()));\r\n            int rowCount = index.model()->rowCount(index);\r\n\r\n            for (int i = rowCount - 1; i >= 0; i = i - 1)\r\n            {\r\n                QModelIndex elementIndex = index.model()->index(i, index.column(), index);\r\n\r\n                if (elementIndex.data(ConfigurableElementsModel::deletableElementCheckRole).toBool())\r\n                {\r\n                    int filteredRow = getFilteredIndexRow(elementIndex);\r\n                    QString parentName = getIndexedParentName(elementIndex.parent());\r\n\r\n                    QSharedPointer<QList<QSharedPointer<ConfigurableElementValue> > > itemConfigurableElements =\r\n                        getIndexedConfigurableElements(elementIndex);\r\n\r\n                    QString elementID = elementIndex.data(ConfigurableElementsModel::parameterIDRole).toString();\r\n\r\n                    auto elementRemoveCommand(new ConfigurableElementRemoveCommand(\r\n                        elementID, filteredRow, parentName, itemConfigurableElements, multipleRemoveCommand));\r\n\r\n                    connect(elementRemoveCommand, SIGNAL(addConfigurableElement(QString const&, QString const&,\r\n                         int)), this, SIGNAL(addConfigurableElement(QString const&, QString const&,\r\n                         int)), Qt::UniqueConnection);\r\n                    connect(elementRemoveCommand, SIGNAL(removeConfigurableElement(QString const&, \r\n                        int)), this, SIGNAL(removeConfigurableElement(QString const&, int)),\r\n                        Qt::UniqueConnection);\r\n                }\r\n            }\r\n        }\r\n    }\r\n\r\n    addCommandToStackAndRedo(mainRemoveCommand);\r\n\r\n    for (int i = 0; i < mainRemoveCommand->childCount(); ++i)\r\n    {\r\n        const QUndoCommand* multipleRemoveCommand = mainRemoveCommand->child(i);\r\n        for (int j = 0; j < multipleRemoveCommand->childCount(); ++j)\r\n        {\r\n            auto removeCommand =\r\n                dynamic_cast<const ConfigurableElementRemoveCommand*>(multipleRemoveCommand->child(i));\r\n            if (removeCommand)\r\n            {\r\n                connect(removeCommand, SIGNAL(increaseReferencesInNewValue(QString const&)),\r\n                    this, SLOT(increaseReferencesInNewValue(QString const&)), Qt::UniqueConnection);\r\n                connect(removeCommand, SIGNAL(decreaseReferencesInOldValue(QString const&)),\r\n                    this, SLOT(decreaseReferencesInOldValue(QString const&)), Qt::UniqueConnection);\r\n            }\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: configurableelementdelegate::addCommandToStackAndRedo()\r\n//-----------------------------------------------------------------------------\r\nvoid ConfigurableElementDelegate::addCommandToStackAndRedo(QSharedPointer<QUndoCommand> newCommand) const\r\n{\r\n    if (editProvider_)\r\n    {\r\n        editProvider_->addCommand(newCommand);\r\n    }\r\n\r\n    newCommand->redo();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: configurableelementdelegate::increaseReferencesInNewValue()\r\n//-----------------------------------------------------------------------------\r\nvoid ConfigurableElementDelegate::increaseReferencesInNewValue(QString const& newValue)\r\n{\r\n    QStringList allParameterIDs = getParameterFinder()->getAllParameterIds();\r\n    for (QString const& valueID : allParameterIDs)\r\n    {\r\n        int referencesToId = newValue.count(valueID);\r\n        for (int i =  0; i < referencesToId; ++i)\r\n        {\r\n            emit increaseReferences(valueID);\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: configurableelementdelegate::decreaseReferencesInOldValue()\r\n//-----------------------------------------------------------------------------\r\nvoid ConfigurableElementDelegate::decreaseReferencesInOldValue(QString const& oldValue)\r\n{\r\n    QStringList allParameterIDs = getParameterFinder()->getAllParameterIds();\r\n    for (QString const& valueID : allParameterIDs)\r\n    {\r\n        int referencesToId = oldValue.count(valueID);\r\n        for (int i =  0; i < referencesToId; ++i)\r\n        {\r\n            emit decreaseReferences(valueID);\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: configurableelementdelegate::setChoices()\r\n//-----------------------------------------------------------------------------\r\nvoid ConfigurableElementDelegate::setChoices(QSharedPointer<QList<QSharedPointer<Choice> > > choices)\r\n{\r\n    ChoiceCreatorDelegate::setChoices(choices);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: configurableelementdelegate::columnAcceptsExpression()\r\n//-----------------------------------------------------------------------------\r\nbool ConfigurableElementDelegate::columnAcceptsExpression(int column) const\r\n{\r\n    return column == ConfigurableElementsColumns::VALUE;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: configurableelementdelegate::choiceNameOnRow()\r\n//-----------------------------------------------------------------------------\r\nQString ConfigurableElementDelegate::choiceNameOnRow(QModelIndex const& index) const\r\n{\r\n    return index.sibling(index.row(), ConfigurableElementsColumns::CHOICE).data(Qt::DisplayRole).toString();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: configurableelementdelegate::valueColumn()\r\n//-----------------------------------------------------------------------------\r\nint ConfigurableElementDelegate::valueColumn() const\r\n{\r\n    return ConfigurableElementsColumns::VALUE;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ConfigurableElementDelegate::descriptionColumn()\r\n//-----------------------------------------------------------------------------\r\nint ConfigurableElementDelegate::descriptionColumn() const\r\n{\r\n    return -1;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: configurableelementdelegate::valueIsArray()\r\n//-----------------------------------------------------------------------------\r\nbool ConfigurableElementDelegate::valueIsArray(QModelIndex const& index) const\r\n{\r\n    QModelIndex arrayLeftIndex = index.sibling(index.row(), ConfigurableElementsColumns::ARRAY_LEFT);\r\n    bool arrayLeftIsOk = true;\r\n    int arrayLeft = arrayLeftIndex.data(Qt::DisplayRole).toInt(&arrayLeftIsOk);\r\n\r\n    QModelIndex arrayRightIndex = index.sibling(index.row(), ConfigurableElementsColumns::ARRAY_RIGHT);\r\n    bool arrayRightIsOk = true;\r\n    int arrayRight = arrayRightIndex.data(Qt::DisplayRole).toInt(&arrayRightIsOk);\r\n\r\n    int arraySize = getArraySize(arrayLeft, arrayRight);\r\n\r\n    return arrayLeftIsOk && arrayRightIsOk && arraySize > 0;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: configurableelementdelegate::updateEditorGeometry()\r\n//-----------------------------------------------------------------------------\r\nvoid ConfigurableElementDelegate::updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option,\r\n    const QModelIndex &index) const\r\n{\r\n    ExpressionDelegate::updateEditorGeometry(editor, option, index);\r\n\r\n    if (index.column() == valueColumn() && valueIsArray(index))\r\n    {\r\n        repositionAndResizeEditor(editor, option, index);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: configurableelementdelegate::repositionAndResizeEditor()\r\n//-----------------------------------------------------------------------------\r\nvoid ConfigurableElementDelegate::repositionAndResizeEditor(QWidget* editor, QStyleOptionViewItem const& option,\r\n    QModelIndex const& index) const\r\n{\r\n    QModelIndex arrayLeftIndex = index.sibling(index.row(), ConfigurableElementsColumns::ARRAY_LEFT);\r\n    int arrayLeft = arrayLeftIndex.data(Qt::DisplayRole).toInt();\r\n    QModelIndex arrayRightIndex = index.sibling(index.row(), ConfigurableElementsColumns::ARRAY_RIGHT);\r\n    int arrayRight = arrayRightIndex.data(Qt::DisplayRole).toInt();\r\n\r\n    int arraySize = getArraySize(arrayLeft, arrayRight);\r\n    int editorMinimumSize = 24 * (arraySize + 1);\r\n\r\n    QPoint nameColumnTopRight = option.rect.topLeft();\r\n    editor->setFixedWidth(editor->parentWidget()->width() - nameColumnTopRight.x());\r\n\r\n    const int PARENT_HEIGHT = editor->parentWidget()->height();\r\n    const int AVAILABLE_HEIGHT_BELOW = PARENT_HEIGHT - option.rect.top();\r\n\r\n    if (AVAILABLE_HEIGHT_BELOW > editorMinimumSize)\r\n    {\r\n        editor->move(option.rect.topLeft());\r\n    }\r\n    else\r\n    {\r\n        int editorNewY = PARENT_HEIGHT - editorMinimumSize;\r\n        if (editorNewY < 0)\r\n        {\r\n            editorNewY = 0;\r\n        }\r\n\r\n        editor->move(option.rect.left(), editorNewY);\r\n    }\r\n\r\n    if (editorMinimumSize > PARENT_HEIGHT)\r\n    {\r\n        editor->setFixedHeight(PARENT_HEIGHT);\r\n    }\r\n    else\r\n    {\r\n        editor->setFixedHeight(editorMinimumSize);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: configurableelementdelegate::createArrayEditor()\r\n//-----------------------------------------------------------------------------\r\nvoid ConfigurableElementDelegate::createArrayEditor(QWidget* editor, QModelIndex const& index) const\r\n{\r\n    auto view = dynamic_cast<ArrayView*>(dynamic_cast<QScrollArea*>(editor)->widget());\r\n\r\n    QModelIndex arrayLeftIndex = index.sibling(index.row(), ConfigurableElementsColumns::ARRAY_LEFT);\r\n    int arrayLeft = arrayLeftIndex.data(Qt::DisplayRole).toInt();\r\n    QModelIndex arrayRightIndex = index.sibling(index.row(), ConfigurableElementsColumns::ARRAY_RIGHT);\r\n    int arrayRight = arrayRightIndex.data(Qt::DisplayRole).toInt();\r\n\r\n    int arraySize = getArraySize(arrayLeft, arrayRight);\r\n\r\n    int arrayStartIndex = arrayLeft;\r\n    if (arrayRight < arrayLeft)\r\n    {\r\n        arrayStartIndex = arrayRight;\r\n    }\r\n\r\n    QSharedPointer<IPXactSystemVerilogParser> expressionParser(new IPXactSystemVerilogParser(getParameterFinder()));\r\n    QSharedPointer<Choice> selectedChoice = findChoice(index);\r\n    auto model = new ParameterArrayModel(arraySize, expressionParser, getParameterFinder(),\r\n        expressionFormatter_, selectedChoice, KactusColors::MANDATORY_FIELD, arrayStartIndex, docRevision_, view);\r\n    \r\n    QModelIndex valueIndex = index.sibling(index.row(), valueColumn());\r\n    QString parameterValue = valueIndex.data(Qt::EditRole).toString();\r\n    model->setArrayData(parameterValue);\r\n\r\n    view->setItemDelegate(new ArrayDelegate(completionModel_, getParameterFinder(), selectedChoice, this->parent()));\r\n\r\n\r\n    view->setItemDelegate(new ArrayDelegate(completionModel_, getParameterFinder(), selectedChoice,\r\n        this->parent()));\r\n    view->setModel(model);\r\n    view->setSortingEnabled(false);\r\n    view->resizeColumnsToContents();\r\n\r\n    connect(view->itemDelegate(), SIGNAL(increaseReferences(QString)),\r\n        this, SIGNAL(increaseReferences(QString)), Qt::UniqueConnection);\r\n    connect(view->itemDelegate(), SIGNAL(decreaseReferences(QString)),\r\n        this, SIGNAL(decreaseReferences(QString)), Qt::UniqueConnection);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: configurableelementdelegate::getArraySize()\r\n//-----------------------------------------------------------------------------\r\nint ConfigurableElementDelegate::getArraySize(int arrayLeft, int arrayRight) const\r\n{\r\n    return abs(arrayLeft - arrayRight) + 1;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: configurableelementdelegate::paint()\r\n//-----------------------------------------------------------------------------\r\nvoid ConfigurableElementDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option,\r\n    const QModelIndex &index) const\r\n{\r\n    int indexRowCount = index.model()->rowCount(index);\r\n    if (!index.parent().isValid() && indexRowCount > 0)\r\n    {\r\n        painter->fillRect(option.rect, KactusColors::STRONG_FIELD);\r\n    }\r\n\r\n\tQStyleOptionViewItem overrideOptions(option);\r\n    overrideOptions.decorationPosition = QStyleOptionViewItem::Right;\r\n\r\n    ChoiceCreatorDelegate::paint(painter, overrideOptions, index);\r\n    \r\n    QPen oldPen = painter->pen();\r\n    QPen newPen(Qt::lightGray);\r\n    newPen.setWidth(1);\r\n    painter->setPen(newPen);\r\n    \r\n    if (index.parent().isValid() || (!index.parent().isValid() && indexRowCount == 0))\r\n    {\r\n        painter->drawLine(overrideOptions.rect.topRight(), overrideOptions.rect.bottomRight());\r\n    }\r\n\r\n    painter->setPen(oldPen);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: configurableelementdelegate::sizeHint()\r\n//-----------------------------------------------------------------------------\r\nQSize ConfigurableElementDelegate::sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const\r\n{\r\n    QSize givenSize = ChoiceCreatorDelegate::sizeHint(option, index);\r\n\r\n    QSize newSize (givenSize.width(), 20);\r\n    return newSize;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ConfigurableElementDelegate::setStdRevision()\r\n//-----------------------------------------------------------------------------\r\nvoid ConfigurableElementDelegate::setStdRevision(Document::Revision docRevision)\r\n{\r\n    docRevision_ = docRevision;\r\n}\r\n"
  },
  {
    "path": "editors/common/ComponentInstanceEditor/configurableelementdelegate.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: configurableelementdelegate.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 12.08.2011\r\n//\r\n// Description:\r\n// Delegate that provides editors to edit the configurable element values.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef CONFIGURABLEELEMENTDELEGATE_H\r\n#define CONFIGURABLEELEMENTDELEGATE_H\r\n\r\n#include <common/IEditProvider.h>\r\n\r\n#include <IPXACTmodels/common/Document.h>\r\n\r\n#include <editors/ComponentEditor/parameters/ChoiceCreatorDelegate.h>\r\n#include <KactusAPI/include/ParameterFinder.h>\r\n#include <KactusAPI/include/ExpressionFormatter.h>\r\n\r\n#include <QWidget>\r\n#include <QSize>\r\n#include <QModelIndex>\r\n\r\nclass Choice;\r\nclass ConfigurableElementValue;\r\nclass ConfigurableElementRemoveCommand;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Delegate that provides editors to edit the configurable element values.\r\n//-----------------------------------------------------------------------------\r\nclass ConfigurableElementDelegate : public ChoiceCreatorDelegate\r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\r\n\t/*!\r\n\t *  The constructor.\r\n\t *\r\n     *    @param [in] completionModel         Model containing the completions used in expression editor.\r\n\t *    @param [in] parameterFinder         Pointer to the parameter finder, used in expression editor.\r\n     *    @param [in] expressionFormatter     Expression formatter, used to change parameter ids to names.\r\n\t *    @param [in] parent                  Pointer to the owner of this delegate.\r\n\t */\r\n\tConfigurableElementDelegate(QAbstractItemModel* completionModel, QSharedPointer<ParameterFinder> parameterFinder,\r\n        QSharedPointer<ExpressionFormatter> expressionFormatter, QObject *parent);\r\n\t\r\n\t/*!\r\n     *  The destructor.\r\n     */\r\n\tvirtual ~ConfigurableElementDelegate() = default;\r\n\r\n    /*!\r\n     *  Set a new edit provider.\r\n     *\r\n     *    @param [in] newEditProvider     The new edit provider.\r\n     */\r\n    void setEditProvider(QSharedPointer<IEditProvider> newEditProvider);\r\n\r\n    /*!\r\n     *  Create a new editor for the given item.\r\n     *\r\n     *    @param [in] parent  Owner of the editor.\r\n     *    @param [in] option  Contains options for the editor.\r\n     *    @param [in] index   Model index identifying the item.\r\n     *\r\n     *    @return Pointer to the editor to be used to edit the item.\r\n     */\r\n    virtual QWidget* createEditor(QWidget* parent, QStyleOptionViewItem const& option, QModelIndex const& index)\r\n        const;\r\n\r\n    /*!\r\n     *  Set the data for the editor.\r\n     *\r\n     *    @param [in] editor  Pointer to the editor where the data is to be set.\r\n     *    @param [in] index   Model index identifying the item that's data is to be set.\r\n     */\r\n    virtual void setEditorData(QWidget* editor, QModelIndex const& index) const;\r\n\r\n    /*!\r\n     *  Save the data from the editor to the model.\r\n     *\r\n     *    @param [in] editor  Pointer to the editor that contains the data to store.\r\n     *    @param [in] model   Model that contains the data structure where data is to be saved to.\r\n     *    @param [in] index   Model index identifying the item that's data is to be saved.\r\n     */\r\n    virtual void setModelData(QWidget* editor, QAbstractItemModel* model, QModelIndex const& index) const;\r\n\r\n    /*!\r\n     *  Set the choices for this delegate.\r\n     *\r\n     *    @param [in] choices     The choices of the current component.\r\n     */\r\n    void setChoices(QSharedPointer<QList<QSharedPointer<Choice> > > choices);\r\n\r\n    /*!\r\n     *  Updates the editor geometry.\r\n     *\r\n     *    @param [in] editor  The editor being updated.\r\n     *    @param [in] option  The options used to update the editor.\r\n     *    @param [in] index   The model index being edited.\r\n     */\r\n    virtual void updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option,\r\n        const QModelIndex &index) const;\r\n\r\n    /*!\r\n     *  Paint the delegate.\r\n     *\r\n     *    @param [in] painter     The painter used.\r\n     *    @param [in] option      The style option in use.\r\n     *    @param [in] index       The current index of the model.\r\n     */\r\n    virtual void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const;\r\n\r\n    /*!\r\n     *  Returns the size needed by the delegate to display the item in index.\r\n     *\r\n     *    @param [in] option  The style information.\r\n     *    @param [in] index   The index of the item.\r\n     *\r\n     *    @return The size needed by the delegate to display the item in index.\r\n     */\r\n    virtual QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const;\r\n\r\n    void setStdRevision(Document::Revision docRevision);\r\n\r\npublic slots:\r\n\r\n    /*!\r\n     *  Handles the creation of a configurable element remove command.\r\n     *\r\n     *    @param [in] indexes     Indexes of the selected configurable elements.\r\n     */\r\n    void onCreateRemoveElementCommands(QModelIndexList const& indexes);\r\n    void onCreateRemoveElementCommands(QModelIndex const& index);\r\n\r\n    /*!\r\n     *  Create remove commands for the sub items of the selected index.\r\n     *\r\n     *    @param [in] indexes     Indexes of the selected configurable elements.\r\n     */\r\n    void onCreateMultipleElementRemoveCommands(QModelIndexList const& indexes);\r\n\r\n    /*!\r\n     *  Create an undo command for configurable element value change.\r\n     *\r\n     *    @param [in] oldValue    Old value of the configurable element.\r\n     *    @param [in] newValue    New value of the configurable element.\r\n     *    @param [in] index       Index of the changed configurable element.\r\n     *    @param [in] cevModel    Model containing the configurable element.\r\n     */\r\n    void createElementChangeCommand(QString const& oldValue, QString const& newValue, QModelIndex const& index,\r\n        QAbstractItemModel* cevModel) const;\r\n\r\nsignals:\r\n\r\n    /*!\r\n     *  Informs the model to emit a data change signal for the selected configurable element.\r\n     *\r\n     *    @param [in] parameterID     ID of the parameter referenced by the selected configurable element.\r\n     *    @param [in] newDataValue    The new configurable element value.\r\n     */\r\n    void dataChangedInID(QString const& parameterID, QString const& newDataValue);\r\n\r\n    /*!\r\n     *  Informs the model that a new configurable element should be added.\r\n     *\r\n     *    @param [in] elementID       ID of the parameter referenced by the new configurable element.\r\n     *    @param [in] elementValue    New value for the configurable element.\r\n     *    @param [in] elementRow      Index row of the new configurable element.\r\n     */\r\n    void addConfigurableElement(QString const& elementID, QString const& elementValue, \r\n        int elementRow);\r\n\r\n    /*!\r\n     *  Informs the model that a configurable element should be removed.\r\n     *\r\n     *    @param [in] elementID   ID of the parameter referenced by the removed configurable element.\r\n     *    @param [in] elementRow  Index row of the selected configurable element.\r\n     */\r\n    void removeConfigurableElement(QString const& elementID, int elementRow);\r\n\r\nprotected:\r\n\r\n    /*!\r\n     *  Checks if the given column supports expressions in the editor.\r\n     *\r\n     *    @param [in] column      The column to check.\r\n     *\r\n     *    @return True, if the cells in the column accept expressions, otherwise false.\r\n     */\r\n    bool columnAcceptsExpression(int column) const;\r\n\r\n    /*!\r\n     *  Gets the name of the choice on the currently selected row.\r\n     *\r\n     *    @param [in] index   The index of the currently selected row.\r\n     *\r\n     *    @return The name of the choice used in the row on the given index.\r\n     */\r\n    virtual QString choiceNameOnRow(QModelIndex const& index) const;\r\n\r\n    /*!\r\n     *  Gets the column number of the value column.\r\n     *\r\n     *    @return The column number of the value column.\r\n     */\r\n    virtual int valueColumn() const;\r\n    \r\n    //! Gets the description column.\r\n    virtual int descriptionColumn() const;\r\n\r\nprivate slots:\r\n\r\n    /*!\r\n     *  Increase the amount of references to parameters made in the selected value.\r\n     *\r\n     *    @param [in] newValue    The selected value.\r\n     */\r\n    void increaseReferencesInNewValue(QString const& newValue);\r\n\r\n    /*!\r\n     *  Decrease the amount of references to parameters made in the selected value.\r\n     *\r\n     *    @param [in] oldValue    The selected value.\r\n     */\r\n    void decreaseReferencesInOldValue(QString const& oldValue);\r\n\r\nprivate:\r\n\r\n\t//! No copying. No assignment.\r\n\tConfigurableElementDelegate(const ConfigurableElementDelegate& other);\r\n\tConfigurableElementDelegate& operator=(const ConfigurableElementDelegate& other);\r\n\r\n    /*!\r\n     *  Check if the value at the given index is an array.\r\n     *\r\n     *    @param [in] index   The index of the current value.\r\n     *\r\n     *    @return True, if the value is an array, false otherwise.\r\n     */\r\n    bool valueIsArray(QModelIndex const& index) const;\r\n\r\n    /*!\r\n     *  Create the editor for the array value.\r\n     *\r\n     *    @param [in] editor  The editor to be changed to array editor.\r\n     *    @param [in] index   The index of the current value.\r\n     */\r\n    void createArrayEditor(QWidget* editor, QModelIndex const& index) const;\r\n\r\n    /*!\r\n     *  Get the size of the array.\r\n     *\r\n     *    @param [in] arrayLeft   The left side of the array.\r\n     *    @param [in] arrayRight  The right side of the array.\r\n     *\r\n     *    @return The size of the array.\r\n     */\r\n    int getArraySize(int arrayLeft, int arrayRight) const;\r\n\r\n    /*!\r\n     *  Repositions the editor to better use the available space. The editor is then resized to best cover the\r\n     *  usable area.\r\n     *\r\n     *    @param [in] editor  The editor to reposition.\r\n     *    @param [in] option  The style options for the editor.\r\n     *    @param [in] index   The current index.\r\n     */\r\n    void repositionAndResizeEditor(QWidget* editor, QStyleOptionViewItem const& option, QModelIndex const& index)\r\n        const;\r\n\r\n\r\n    /*!\r\n     *  Create an element remove command for the selected configurable element.\r\n     *\r\n     *    @param [in] index           Index of the selected configurable element.\r\n     *    @param [in] parentCommand   The parent command.\r\n     *\r\n     *    @return Pointer to the created configurable element remove command.\r\n     */\r\n    ConfigurableElementRemoveCommand* createElementRemoveCommand(QModelIndex const& index,\r\n        QSharedPointer<QUndoCommand> parentCommand);\r\n\r\n    /*!\r\n     *  Get the filtered index row of the selected index.\r\n     *\r\n     *    @param [in] index   The selected index.\r\n     *\r\n     *    @return The filtered index row of the selected index.\r\n     */\r\n    int getFilteredIndexRow(QModelIndex const& index) const;\r\n\r\n    /*!\r\n     *  Get the name of the parent item of the selected configurable element.\r\n     *\r\n     *    @param [in] parentIndex     Parent index of the selected configurable element.\r\n     *\r\n     *    @return Name of the parent item of the selected configurable element.\r\n     */\r\n    QString getIndexedParentName(QModelIndex const& parentIndex) const;\r\n\r\n    /*!\r\n     *  Get a list of configurable element values contained within the item of the selected index.\r\n     *\r\n     *    @param [in] index   The selected index.\r\n     *\r\n     *    @return A list of configurable element values.\r\n     */\r\n    QSharedPointer<QList<QSharedPointer<ConfigurableElementValue> > > getIndexedConfigurableElements(\r\n        QModelIndex const& index) const;\r\n\r\n    /*!\r\n     *  Get the ID of the parameter referenced in the indexed item.\r\n     *\r\n     *    @param [in] index   The selected index.\r\n     *\r\n     *    @return ID of the referenced parameter.\r\n     */\r\n    QString getIndexedElementID(QModelIndex const& index) const;\r\n\r\n    /*!\r\n     *  Connect the selected configurable element remove command.\r\n     *\r\n     *    @param [in] removeCommand   The selected configurable element remove command.\r\n     */\r\n    void connectElementRemoveCommand(ConfigurableElementRemoveCommand* removeCommand);\r\n\r\n    /*!\r\n     *  Add the selected command to the command stack and redo the command.\r\n     *\r\n     *    @param [in] newCommand  The selected command.\r\n     */\r\n    void addCommandToStackAndRedo(QSharedPointer<QUndoCommand> newCommand) const;\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! Expression formatter, used in expressions to change parameter ids into names.\r\n    QSharedPointer<ExpressionFormatter> expressionFormatter_;\r\n\r\n    //! Edit provider for stacking undo commands.\r\n    QSharedPointer<IEditProvider> editProvider_ = nullptr;\r\n\r\n    //! The IP-XACT standard revision in use.\r\n    Document::Revision docRevision_ = Document::Revision::Std14;\r\n};\r\n\r\n#endif // CONFIGURABLEELEMENTDELEGATE_H\r\n"
  },
  {
    "path": "editors/common/ComponentInstanceEditor/configurableelementeditor.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: configurableelementeditor.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 12.08.2011\r\n//\r\n// Description:\r\n// Editor for configurable elements of a component instance.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"configurableelementeditor.h\"\r\n\r\n#include <editors/common/ComponentInstanceEditor/ConfigurableElementsColumns.h>\r\n#include <editors/common/ComponentInstanceEditor/ComponentInstanceConfigurableElementsFilter.h>\r\n\r\n#include <IPXACTmodels/Component/Component.h>\r\n#include <IPXACTmodels/Design/ComponentInstance.h>\r\n\r\n#include <QVBoxLayout>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ConfigurableElementEditor::ConfigurableElementEditor()\r\n//-----------------------------------------------------------------------------\r\nConfigurableElementEditor::ConfigurableElementEditor(\r\n    ExpressionSet parameterExpressions,\r\n    ExpressionSet defaultExpressions, \r\n     QAbstractItemModel* completionModel,\r\n    QWidget *parent) :\r\nQGroupBox(tr(\"Configurable element values\"), parent),\r\nview_(this),\r\ndelegate_(new ConfigurableElementDelegate(completionModel, parameterExpressions.finder, parameterExpressions.formatter, this)),\r\nfilter_(new ConfigurableElementsFilter(this)),\r\nmodel_(new ConfigurableElementsModel(parameterExpressions.finder, parameterExpressions.formatter, defaultExpressions.formatter,\r\n    parameterExpressions.parser, defaultExpressions.parser, this)),\r\nfilterSelection_(new QCheckBox(tr(\"Show immediate values\"), this))\r\n{\r\n    setFlat(true);\r\n\r\n\t// set options for the view\r\n\tview_.setSortingEnabled(true);\r\n    view_.setSelectionBehavior(QAbstractItemView::SelectItems);\r\n    view_.setSelectionMode(QAbstractItemView::SingleSelection);\r\n\r\n    view_.setItemDelegate(delegate_);\r\n\r\n    view_.setModel(filter_);\r\n\r\n    filter_->setSourceModel(model_);\r\n    filter_->setSortCaseSensitivity(Qt::CaseInsensitive);\r\n    \r\n    hideUnnecessaryColumns();\r\n\r\n\tauto topLayout = new QVBoxLayout(this);\r\n\ttopLayout->addWidget(&view_);\r\n    topLayout->addWidget(filterSelection_);\r\n\r\n    connect(&view_, SIGNAL(removeItem(QModelIndex const&)),\r\n        delegate_, SLOT(onCreateRemoveElementCommands(QModelIndex const&)), Qt::UniqueConnection);\r\n\r\n    connect(delegate_, SIGNAL(increaseReferences(QString)),\r\n        this, SIGNAL(increaseReferences(QString const&)), Qt::UniqueConnection);\r\n    connect(delegate_, SIGNAL(decreaseReferences(QString)),\r\n        this, SIGNAL(decreaseReferences(QString const&)), Qt::UniqueConnection);\r\n    \r\n    connect(filterSelection_, SIGNAL(clicked(bool)),\r\n        filter_, SLOT(setShowImmediateValues(bool)), Qt::UniqueConnection);\r\n\r\n    connect(delegate_, SIGNAL(removeConfigurableElement(QString const&, int)),\r\n        this, SLOT(sendSignalForElementRemoval(QString const&, int)), Qt::UniqueConnection);\r\n    connect(delegate_, SIGNAL(dataChangedInID(QString const&, QString const&)),\r\n        model_, SLOT(emitDataChangeForID(QString const&, QString const&)), Qt::UniqueConnection);\r\n\r\n    connect(model_, SIGNAL(contentChanged()), this, SIGNAL(contentChanged()), Qt::UniqueConnection);\r\n\r\n    connect(&view_, SIGNAL(createElementChangeCommand(\r\n        QString const&, QString const&, QModelIndex const&, QAbstractItemModel*)),\r\n        delegate_, SLOT(createElementChangeCommand(\r\n        QString const&, QString const&, QModelIndex const&, QAbstractItemModel*)), Qt::UniqueConnection);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ConfigurableElementEditor::setParameters()\r\n//-----------------------------------------------------------------------------\r\nvoid ConfigurableElementEditor::setParameters(QString const& containingItemName,\r\n    QSharedPointer<QList<QSharedPointer<Parameter> > > parameters,\r\n    QSharedPointer<QList<QSharedPointer<Choice> > > choices,\r\n    Document::Revision docRevision,\r\n    QSharedPointer<QList<QSharedPointer<ConfigurableElementValue> > > storedConfigurableElements)\r\n{\r\n    model_->setParameters(containingItemName, parameters, choices, docRevision, storedConfigurableElements);\r\n    delegate_->setStdRevision(docRevision);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ConfigurableElementEditor::clear()\r\n//-----------------------------------------------------------------------------\r\nvoid ConfigurableElementEditor::clear()\r\n{\r\n    model_->clear();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ConfigurableElementEditor::setEditProvider()\r\n//-----------------------------------------------------------------------------\r\nvoid ConfigurableElementEditor::setEditProvider(QSharedPointer<IEditProvider> editProvider)\r\n{\r\n    delegate_->setEditProvider(editProvider);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ConfigurableElementEditor::hideUnnecessaryColumns()\r\n//-----------------------------------------------------------------------------\r\nvoid ConfigurableElementEditor::hideUnnecessaryColumns()\r\n{\r\n    view_.setAlternatingRowColors(false);\r\n    view_.setColumnHidden(ConfigurableElementsColumns::CHOICE, true);\r\n    view_.setColumnHidden(ConfigurableElementsColumns::ARRAY_LEFT, true);\r\n    view_.setColumnHidden(ConfigurableElementsColumns::ARRAY_RIGHT, true);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: InstantiationConfigurableElementEditor::sendSignalForElementRemoval()\r\n//-----------------------------------------------------------------------------\r\nvoid ConfigurableElementEditor::sendSignalForElementRemoval(QString const& elementID,\r\n    int elementRow)\r\n{\r\n    model_->onRemoveItem(elementID, elementRow);\r\n    filter_->invalidate();\r\n}\r\n"
  },
  {
    "path": "editors/common/ComponentInstanceEditor/configurableelementeditor.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: configurableelementeditor.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 12.08.2011\r\n//\r\n// Description:\r\n// Editor for configurable elements of a component instance.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef CONFIGURABLEELEMENTEDITOR_H\r\n#define CONFIGURABLEELEMENTEDITOR_H\r\n\r\n#include <IPXACTmodels/DesignConfiguration/DesignConfiguration.h>\r\n\r\n#include <KactusAPI/include/ExpressionFormatter.h>\r\n#include <editors/ComponentEditor/common/ConfigurableElementFinder.h>\r\n\r\n#include <editors/common/ExpressionSet.h>\r\n#include <editors/common/ComponentInstanceEditor/ConfigurableElementsModel.h>\r\n#include <editors/common/ComponentInstanceEditor/ConfigurableElementsFilter.h>\r\n#include <editors/common/ComponentInstanceEditor/configurableelementdelegate.h>\r\n#include <editors/common/ComponentInstanceEditor/ConfigurableElementsView.h>\r\n\r\n#include <QAbstractItemModel>\r\n#include <QCompleter>\r\n#include <QGroupBox>\r\n#include <QSharedPointer>\r\n#include <QCheckBox>\r\n#include <QSortFilterProxyModel>\r\n\r\nclass ExpressionParser;\r\nclass ParameterFinder;\r\nclass Component;\r\nclass ComponentInstance;\r\n//-----------------------------------------------------------------------------\r\n//! Editor for configurable elements of a component instance.\r\n//-----------------------------------------------------------------------------\r\nclass ConfigurableElementEditor : public QGroupBox\r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\r\n\t/*!\r\n\t *  The constructor.\r\n\t *\r\n     *    @param [in] parameterExpressions            The expressions for selecting parameter references.\r\n     *    @param [in] defaultExpressions              The expressions for resolving default values.\r\n\t *    @param [in] completionModel                 The completion model for selecting parameter references.\r\n\t *    @param [in] parent                          The parent widget.\r\n\t */\r\n    ConfigurableElementEditor( ExpressionSet parameterExpressions, ExpressionSet defaultExpressions, \r\n        QAbstractItemModel* completionModel, QWidget *parent);\r\n\t\r\n    void setParameters(QString const& containingItemName, \r\n        QSharedPointer<QList<QSharedPointer<Parameter> > > parameters, \r\n        QSharedPointer<QList<QSharedPointer<Choice> > > choices,\r\n        Document::Revision docRevision,\r\n        QSharedPointer<QList<QSharedPointer<ConfigurableElementValue> > > storedConfigurableElements);\r\n\r\n    //! The destructor.\r\n\tvirtual ~ConfigurableElementEditor() = default;\r\n\r\n    //! No copying.\r\n    ConfigurableElementEditor(const ConfigurableElementEditor& other) = delete;\r\n\r\n    //! No assignment.\r\n    ConfigurableElementEditor& operator=(const ConfigurableElementEditor& other) = delete;\r\n\r\n\t/*!\r\n     *  Clear the editor from all data.\r\n\t */\r\n    virtual void clear();;\r\n\r\n    void setEditProvider(QSharedPointer<IEditProvider> editProvider);\r\n\r\nsignals:\r\n\r\n\t//! Emitted when contents of the editor changes.\r\n\tvoid contentChanged();\r\n\r\n    /*!\r\n     *  Increase the amount of references to a parameter corresponding to the ID.\r\n     *\r\n     *    @param [in] id      The ID of the parameter being searched for.\r\n     */\r\n    void increaseReferences(QString const& id);\r\n\r\n    /*!\r\n     *  Decrease the amount of references to a parameter corresponding to the ID.\r\n     *\r\n     *    @param [in] id      The ID of the parameter being searched for.\r\n     */\r\n    void decreaseReferences(QString const& id);\r\n\r\nprivate slots:\r\n\r\n    void sendSignalForElementRemoval(QString const& elementID, int elementRow);\r\n\r\nprotected:\r\n\r\n    /*!\r\n     *  Hide the columns that should not be seen in the configurable elements editor.\r\n     */\r\n    void hideUnnecessaryColumns();\r\n\r\n    //! The widget to display the contents of the model.\r\n    ConfigurableElementsView view_;\r\n\r\n    //! The delegate used in the display widget.\r\n    ConfigurableElementDelegate* delegate_;\r\n\r\n    ConfigurableElementsFilter* filter_;\r\n\r\n    ConfigurableElementsModel* model_;\r\n\r\n    //! The immediate configurable element values filter check box.\r\n    QCheckBox* filterSelection_;\r\n\r\n};\r\n\r\n#endif // CONFIGURABLEELEMENTEDITOR_H\r\n"
  },
  {
    "path": "editors/common/ComponentItemAutoConnector/AutoConnector.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: AutoConnector.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 12.02.2019\n//\n// Description:\n// Automatically connects items of two component items.\n//-----------------------------------------------------------------------------\n\n#include \"AutoConnector.h\"\n\n#include <common/graphicsItems/ComponentItem.h>\n\n#include <editors/common/ComponentItemAutoConnector/ListFiller.h>\n#include <editors/common/ComponentItemAutoConnector/TableAutoConnector.h>\n#include <editors/common/ComponentItemAutoConnector/AutoConnectorConnectionTable.h>\n#include <editors/common/ComponentItemAutoConnector/AutoConnectorConnectionDelegate.h>\n#include <editors/common/ComponentItemAutoConnector/AutoConnectorListFilter.h>\n\n#include <QVBoxLayout>\n#include <QGroupBox>\n#include <QCheckBox>\n#include <QStandardItemModel>\n\n//-----------------------------------------------------------------------------\n// Function: AutoConnector::AutoConnector()\n//-----------------------------------------------------------------------------\nAutoConnector::AutoConnector(ComponentItemAutoConnector::AutoContainer const& firstComponentContainer, \n    ComponentItemAutoConnector::AutoContainer const& secondComponentContainer,\n    ComponentItemAutoConnector::TableTools const& tableToolsContainer,\n    QString const& itemName, QWidget* parent /*= 0*/) :\nQWidget(parent),\nfirstComponentContainer_(firstComponentContainer),\nsecondComponentContainer_(secondComponentContainer),\nconnectorTableTools_(tableToolsContainer),\nfirstListFilter_(),\nsecondListFilter_(),\nfirstItemList_(),\nsecondItemList_(),\nconnectorTable_(),\ntableInitializer_(connectorTableTools_.tableConnector_)\n{\n    setupLayout(firstComponentContainer_.visibleName_, secondComponentContainer_.visibleName_, itemName);\n}\n\n//-----------------------------------------------------------------------------\n// Function: AutoConnector::~AutoConnector()\n//-----------------------------------------------------------------------------\nAutoConnector::~AutoConnector()\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: AutoConnector::getConnectedItems()\n//-----------------------------------------------------------------------------\nQVector<QPair<QString, QString> > AutoConnector::getConnectedItems() const\n{\n    return connectorTable_->getConnectedItems();\n}\n\n//-----------------------------------------------------------------------------\n// Function: AutoConnector::setupLayout()\n//-----------------------------------------------------------------------------\nvoid AutoConnector::setupLayout(QString const& firstComponentName, QString const& secondComponentName, QString const& itemName)\n{\n    firstItemList_ = new QListView(this);\n    secondItemList_ = new QListView(this);\n\n    firstItemList_->setDragEnabled(true);\n    firstItemList_->setDragDropMode(QAbstractItemView::DragOnly);\n    secondItemList_->setDragEnabled(true);\n    secondItemList_->setDragDropMode(QAbstractItemView::DragOnly);\n\n    QCheckBox* firstHideBox(new QCheckBox(tr(\"Hide connected\"), this));\n    QCheckBox* secondHideBox(new QCheckBox(tr(\"Hide connected\"), this));\n\n    firstHideBox->setChecked(true);\n    secondHideBox->setChecked(true);\n\n    QVBoxLayout* firstComponentLayout(new QVBoxLayout());\n    QVBoxLayout* secondComponentLayout(new QVBoxLayout());\n    firstComponentLayout->addWidget(firstItemList_, 1);\n    firstComponentLayout->addWidget(firstHideBox);\n    secondComponentLayout->addWidget(secondItemList_, 1);\n    secondComponentLayout->addWidget(secondHideBox);\n\n    QGroupBox* firstComponentGroup(new QGroupBox(firstComponentName, this));\n    QGroupBox* secondComponentGroup(new QGroupBox(secondComponentName, this));\n    firstComponentGroup->setLayout(firstComponentLayout);\n    secondComponentGroup->setLayout(secondComponentLayout);\n\n    connectorTable_ = new AutoConnectorConnectionTable(firstComponentContainer_.component_, secondComponentContainer_.component_, firstItemList_,\n        secondItemList_, firstComponentName, secondComponentName, connectorTableTools_.itemMatcher_, this);\n    connectorTable_->setItemDelegate(new AutoConnectorConnectionDelegate(\n        firstComponentContainer_.component_, secondComponentContainer_.component_, firstItemList_, secondItemList_, connectorTableTools_.itemMatcher_, this));\n\n    connect(connectorTable_->model(), SIGNAL(dataChanged(const QModelIndex&, const QModelIndex&, const QVector<int> &)),\n        this, SLOT(invalidateListFilters()), Qt::UniqueConnection);\n    connect(connectorTable_->model(), SIGNAL(rowsRemoved(const QModelIndex&, int, int)),\n        this, SLOT(invalidateListFilters()), Qt::UniqueConnection);\n\n    QVBoxLayout* connectedItemsLayout(new QVBoxLayout());\n    connectedItemsLayout->addWidget(connectorTable_);\n\n    QGroupBox* connectedItemsGroup(new QGroupBox(tr(\"Connected \") + itemName));\n    connectedItemsGroup->setAlignment(Qt::AlignHCenter);\n    connectedItemsGroup->setLayout(connectedItemsLayout);\n\n    QHBoxLayout* mainLayout(new QHBoxLayout(this));\n    mainLayout->addWidget(firstComponentGroup);\n    mainLayout->addWidget(connectedItemsGroup, 2);\n    mainLayout->addWidget(secondComponentGroup);\n\n    QStandardItemModel* firstListModel(new QStandardItemModel(this));\n    QStandardItemModel* secondListModel(new QStandardItemModel(this));\n\n    connectorTableTools_.listFiller_->initializeList(firstListModel, firstComponentContainer_.component_);\n    connectorTableTools_.listFiller_->initializeList(secondListModel, secondComponentContainer_.component_);\n\n    firstListFilter_ = new AutoConnectorListFilter(connectorTable_, 0, firstHideBox, this);\n    firstListFilter_->setSourceModel(firstListModel);\n    firstItemList_->setModel(firstListFilter_);\n    secondListFilter_ = new AutoConnectorListFilter(connectorTable_, 1, secondHideBox, this);\n    secondListFilter_->setSourceModel(secondListModel);\n    secondItemList_->setModel(secondListFilter_);\n}\n\n//-----------------------------------------------------------------------------\n// Function: AutoConnector::invalidateListFilters()\n//-----------------------------------------------------------------------------\nvoid AutoConnector::invalidateListFilters()\n{\n    firstListFilter_->invalidate();\n    secondListFilter_->invalidate();\n}\n\n//-----------------------------------------------------------------------------\n// Function: AutoConnector::connectSelectedItems()\n//-----------------------------------------------------------------------------\nvoid AutoConnector::connectSelectedItems()\n{\n    tableInitializer_->connectSelectedFromLists(firstComponentContainer_.component_, \n        secondComponentContainer_.component_, firstItemList_, secondItemList_, connectorTable_, \n        connectorTableTools_.itemMatcher_);\n}\n\n//-----------------------------------------------------------------------------\n// Function: AutoConnector::connectAutomatically()\n//-----------------------------------------------------------------------------\nvoid AutoConnector::connectAutomatically()\n{\n    tableInitializer_->autoConnectItems(connectorTable_, firstComponentContainer_.component_, \n        secondComponentContainer_.component_);\n}\n\n//-----------------------------------------------------------------------------\n// Function: AutoConnector::clearConnectedItems()\n//-----------------------------------------------------------------------------\nvoid AutoConnector::clearConnectedItems()\n{\n    tableInitializer_->clearTable(connectorTable_);\n}\n\n//-----------------------------------------------------------------------------\n// Function: AutoConnector::connectAlreadyConnectedItems()\n//-----------------------------------------------------------------------------\nvoid AutoConnector::connectAlreadyConnectedItems(QSharedPointer<Design> design)\n{\n    tableInitializer_->populateTableWithConnectedItems(connectorTable_, firstComponentContainer_.name_, \n        secondComponentContainer_.name_, firstComponentContainer_.component_, \n        secondComponentContainer_.component_, design);\n    connectorTable_->enableConnectionValidation();\n}\n\n//-----------------------------------------------------------------------------\n// Function: AutoConnector::connectionTableHasInvalidConnections()\n//-----------------------------------------------------------------------------\nbool AutoConnector::connectionTableHasInvalidConnections() const\n{\n    return connectorTable_->hasInvalidConnections();\n}\n"
  },
  {
    "path": "editors/common/ComponentItemAutoConnector/AutoConnector.h",
    "content": "//-----------------------------------------------------------------------------\n// File: AutoConnector.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 12.02.2019\n//\n// Description:\n// Automatically connects items of two component items.\n//-----------------------------------------------------------------------------\n\n#ifndef AUTOCONNECTOR_H\n#define AUTOCONNECTOR_H\n\n#include <editors/common/ComponentItemAutoConnector/ComponentItemAutoConnector.h>\n\n#include <QObject>\n#include <QWidget>\n#include <QListView>\n\nclass Component;\nclass ComponentItem;\nclass AutoConnectorConnectionTable;\nclass ListFiller;\nclass TableAutoConnector;\nclass AutoConnectorListFilter;\nclass TableItemMatcher;\nclass Design;\n\n//-----------------------------------------------------------------------------\n//! Automatically connects items of two component items.\n//-----------------------------------------------------------------------------\nclass AutoConnector : public QWidget\n{\n    Q_OBJECT\n\npublic:\n\n    /*!\n     *  The constructor.\n     *\n     *    @param [in] firstComponentContainer     The first component container.\n     *    @param [in] secondComponentContainer    The second component container.\n     *    @param [in] tableToolsContainer         The table tools container.\n     *    @param [in] itemName                    Name of the items being connected.\n     *    @param [in] parent                      The parent of this widget.\n     */\n    AutoConnector(ComponentItemAutoConnector::AutoContainer const& firstComponentContainer, \n        ComponentItemAutoConnector::AutoContainer const& secondComponentContainer, \n        ComponentItemAutoConnector::TableTools const& tableToolsContainer, QString const& itemName, \n        QWidget* parent = 0);\n\n    /*!\n     *  Destructor.\n     */\n    ~AutoConnector();\n\n    /*!\n     *  Get the list of connected items.\n     *\n     *    @return A list of connected item pairs.\n     */\n    QVector<QPair<QString, QString> > getConnectedItems() const;\n\n    /*!\n     *  Connect the selected items from the item lists.\n     */\n    void connectSelectedItems();\n\n    /*!\n     *  Automatically connect the items.\n     */\n    void connectAutomatically();\n\n    /*!\n     *  Automatically connect the items.\n     */\n    void clearConnectedItems();\n\n    /*!\n     *\tFill the connection table with already connected items.\n     *  \n     *    @param [in] design     The containing design.\n     */\n    void connectAlreadyConnectedItems(QSharedPointer<Design> design);\n\n    /*!\n     *\tChecks if the created connections are valid or not.\n     *  \n     * \t    @return True, if there are invalid connections, otherwise false.\n     */\n    bool connectionTableHasInvalidConnections() const;\n\n    // No copying. No assignments.\n    AutoConnector(AutoConnector const& rhs) = delete;\n    AutoConnector& operator=(AutoConnector const& rhs) = delete;\n\npublic slots:\n\n    /*!\n     *  Invalidate the list filters.\n     */\n    void invalidateListFilters();\n\nprivate:\n\n    /*!\n     *  Setup the layout.\n     *\n     *    @param [in] firstComponentName      Name of the first container.\n     *    @param [in] secondComponentName     Name of the second container.\n     *    @param [in] itemName                Name of the items being connected.\n     */\n    void setupLayout(QString const& firstComponentName, QString const& secondComponentName,\n        QString const& itemName);\n\n    //-----------------------------------------------------------------------------\n    // Data.\n    //-----------------------------------------------------------------------------\n\n    //! The first component.\n    ComponentItemAutoConnector::AutoContainer firstComponentContainer_;\n\n    //! The second component.\n    ComponentItemAutoConnector::AutoContainer secondComponentContainer_;\n\n    //! The component connector table tools.\n    ComponentItemAutoConnector::TableTools connectorTableTools_;\n\n    //! List filter for the first list.\n    AutoConnectorListFilter* firstListFilter_;\n\n    //! List filter for the second list.\n    AutoConnectorListFilter* secondListFilter_;\n\n    //! View of the first item list.\n    QListView* firstItemList_;\n\n    //! View of the second item list.\n    QListView* secondItemList_;\n\n    //! Table containing the item connections.\n    AutoConnectorConnectionTable* connectorTable_;\n\n    //! Used to populate the connection table.\n    QSharedPointer<TableAutoConnector> tableInitializer_;\n};\n\n//-----------------------------------------------------------------------------\n\n#endif // PORTAUTOCONNECTOR_H\n"
  },
  {
    "path": "editors/common/ComponentItemAutoConnector/AutoConnectorConnectionDelegate.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: AutoConnectorConnectionDelegate.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 12.02.2019\n//\n// Description:\n// Delegate that provides widgets for editing connected pairings.\n//-----------------------------------------------------------------------------\n\n#include \"AutoConnectorConnectionDelegate.h\"\n\n#include <editors/common/ComponentItemAutoConnector/TableItemMatcher.h>\n\n//-----------------------------------------------------------------------------\n// Function: AutoConnectorConnectionDelegate::AutoConnectorConnectionDelegate()\n//-----------------------------------------------------------------------------\nAutoConnectorConnectionDelegate::AutoConnectorConnectionDelegate(QSharedPointer<Component> firstComponent,\n    QSharedPointer<Component> secondComponent, QListView* firstList, QListView* secondList,\n    QSharedPointer<TableItemMatcher> itemMatcher, QObject* parent):\nQStyledItemDelegate(parent),\nfirstComponent_(firstComponent),\nsecondComponent_(secondComponent),\nfirstList_(firstList),\nsecondList_(secondList),\nitemMatcher_(itemMatcher)\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: AutoConnectorConnectionDelegate::~AutoConnectorConnectionDelegate()\n//-----------------------------------------------------------------------------\nAutoConnectorConnectionDelegate::~AutoConnectorConnectionDelegate()\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: AutoConnectorConnectionDelegate::createEditor()\n//-----------------------------------------------------------------------------\nQWidget* AutoConnectorConnectionDelegate::createEditor(QWidget* parent, QStyleOptionViewItem const& option,\n    QModelIndex const& index) const\n{\n    if (index.column() == 0)\n    {\n        return createItemSelector(index, firstList_, 1, firstComponent_, secondComponent_, parent);\n    }\n    else if (index.column() == 1)\n    {\n        return createItemSelector(index, secondList_, 0, secondComponent_, firstComponent_, parent);\n    }\n    else\n    {\n        return QStyledItemDelegate::createEditor(parent, option, index);\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: AutoConnectorConnectionDelegate::createItemSelector()\n//-----------------------------------------------------------------------------\nQComboBox* AutoConnectorConnectionDelegate::createItemSelector(QModelIndex const& selectionIndex,\n    QListView* itemList, int comparisonItemColumn, QSharedPointer<Component> itemComponent,\n    QSharedPointer<Component> comparisonItemComponent, QWidget* parent) const\n{\n    QComboBox* combo = new QComboBox(parent);\n    combo->addItem(QString(\"<none>\"));\n\n    if (itemList->model()->rowCount() > 0)\n    {\n        QModelIndex comparisonItemIndex = selectionIndex.sibling(selectionIndex.row(), comparisonItemColumn);\n\n        for (int i = 0; i < itemList->model()->rowCount(); ++i)\n        {\n            QModelIndex itemIndex = itemList->model()->index(i, 0);\n\n            if (itemMatcher_->canDrop(itemIndex, comparisonItemIndex, itemComponent, comparisonItemComponent))\n            {\n                QString itemName = itemIndex.data(Qt::DisplayRole).toString();\n\n                QIcon itemIcon = itemIndex.data(Qt::DecorationRole).value<QIcon>();\n\n                combo->addItem(itemIcon, itemName);\n            }\n        }\n    }\n\n    return combo;\n}\n\n//-----------------------------------------------------------------------------\n// Function: AutoConnectorConnectionDelegate::setEditorData()\n//-----------------------------------------------------------------------------\nvoid AutoConnectorConnectionDelegate::setEditorData(QWidget* editor, QModelIndex const& index) const \n{\n    if (index.column() == 0 || index.column() == 1)\n    {\n        QString itemName = index.data(Qt::DisplayRole).toString();\n        QComboBox* portCombo = qobject_cast<QComboBox*>(editor);\n\n        int comboIndex = portCombo->findText(itemName);\n        if (comboIndex < 0 && !itemName.isEmpty())\n        {\n            QIcon itemIcon = index.data(Qt::DecorationRole).value<QIcon>();\n\n            portCombo->addItem(itemIcon, itemName);\n            portCombo->setCurrentIndex(portCombo->findText(itemName));\n        }\n        else\n        {\n            portCombo->setCurrentIndex(comboIndex);\n        }\n    }\n    else\n    {\n        QStyledItemDelegate::setEditorData(editor, index);\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: AutoConnectorConnectionDelegate::setModelData()\n//-----------------------------------------------------------------------------\nvoid AutoConnectorConnectionDelegate::setModelData(QWidget* editor, QAbstractItemModel* model,\n    QModelIndex const& index) const \n{\n    if (index.column() == 0 || index.column() == 1)\n    {\n        QComboBox* itemCombo = qobject_cast<QComboBox*>(editor);\n        QString itemName = itemCombo->currentText();\n        QIcon itemIcon = itemCombo->itemIcon(itemCombo->currentIndex());\n\n        if (itemName == \"<none>\")\n        {\n            itemName = \"\";\n        }\n\n        model->setData(index, itemIcon, Qt::DecorationRole);\n        model->setData(index, itemName, Qt::DisplayRole);\n    }\n\telse \n    {\n        QStyledItemDelegate::setModelData(editor, model, index);\n\t}\n}\n"
  },
  {
    "path": "editors/common/ComponentItemAutoConnector/AutoConnectorConnectionDelegate.h",
    "content": "//-----------------------------------------------------------------------------\n// File: AutoConnectorConnectionDelegate.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 12.02.2019\n//\n// Description:\n// Delegate that provides widgets for editing connected pairings.\n//-----------------------------------------------------------------------------\n\n#ifndef AUTOCONNECTORCONNECTIONDELEGATE_H\n#define AUTOCONNECTORCONNECTIONDELEGATE_H\n\n#include <QStyledItemDelegate>\n#include <QListView>\n#include <QComboBox>\n\nclass Component;\nclass TableItemMatcher;\n\n//-----------------------------------------------------------------------------\n//! Delegate that provides widgets for editing connected pairings.\n//-----------------------------------------------------------------------------\nclass AutoConnectorConnectionDelegate : public QStyledItemDelegate\n{\n\tQ_OBJECT\n\npublic:\n\n\t/*!\n\t *  The constructor.\n\t *\n     *    @param [in] firstItem       The first component item to be connected.\n     *    @param [in] secondItem      The second component item to be connected.\n     *    @param [in] firstList       View of the first item list.\n     *    @param [in] secondList      View of the second item list.\n     *    @param [in] itemMatcher     Checks for possible matches between two items.\n     *    @param [in] parent          The parent of the object.\n\t */\n    AutoConnectorConnectionDelegate(QSharedPointer<Component> firstComponent,\n        QSharedPointer<Component> secondComponent, QListView* firstList, QListView* secondList,\n        QSharedPointer<TableItemMatcher> itemMatcher, QObject* parent = 0);\n\n\t/*!\n     *  The destructor.\n     */\n    ~AutoConnectorConnectionDelegate();\n\n\t/*!\n     *  Create a new editor for the given item\n\t *\n\t *    @param [in] parent   Owner for the editor.\n\t *    @param [in] option   Contains options for the editor.\n\t *    @param [in] index    Model index identifying the item.\n\t *\n\t *    @return Pointer to the editor to be used to edit the item.\n     */\n\tvirtual QWidget* createEditor(QWidget* parent, QStyleOptionViewItem const& option, \n        QModelIndex const& index) const;\n\n\t/*!\n     *  Set the data for the editor.\n\t *\n\t *    @param [in] editor  Pointer to the editor where the data is to be set.\n\t *    @param [in] index   Model index identifying the item that's data is to be set.\n     */\n\tvirtual void setEditorData(QWidget* editor, QModelIndex const& index) const;\n\n\t/*!\n     *  Save the data from the editor to the model.\n\t *\n\t *    @param [in] editor   Pointer to the editor that contains the data to store.\n\t *    @param [in] model    Model that contains the data structure where data is to be saved to.\n\t *    @param [in] index    Model index identifying the item that's data is to be saved.\n     */\n\tvirtual void setModelData(QWidget* editor, QAbstractItemModel* model, QModelIndex const& index) const;\n\n    //! No copying. No assignment.\n    AutoConnectorConnectionDelegate(const AutoConnectorConnectionDelegate& other) = delete;\n    AutoConnectorConnectionDelegate& operator=(const AutoConnectorConnectionDelegate& other) = delete;\n\nprivate:\n\n    /*!\n     *  Create the selection widget for ports.\n     *\n     *    @param [in] selectionIndex              Index of the item selector.\n     *    @param [in] itemList                    List containing the items of the selected component.\n     *    @param [in] comparisonItemColumn        Column of the comparison item.\n     *    @param [in] itemComponent               Component containing the items of the selected index.\n     *    @param [in] comparisonItemComponent     Component containing the items of the comparison index.\n     *    @param [in] parent                      Parent item of the editor.\n     *\n     *    @return Combobox for component ports.\n     */\n    QComboBox* createItemSelector(QModelIndex const& selectionIndex, QListView* itemList, int comparisonItemColumn,\n        QSharedPointer<Component> itemComponent, QSharedPointer<Component> comparisonItemComponent,\n        QWidget* parent) const;\n\n    //-----------------------------------------------------------------------------\n    // Data.\n    //-----------------------------------------------------------------------------\n\n    //! The first component item to be connected.\n    QSharedPointer<Component> firstComponent_;\n\n    //! The second component item to be connected.\n    QSharedPointer<Component> secondComponent_;\n\n    //! View of the first item list.\n    QListView* firstList_;\n\n    //! View of the second item list.\n    QListView* secondList_;\n\n    //! Checks for possible matches between two items.\n    QSharedPointer<TableItemMatcher> itemMatcher_;\n};\n\n#endif // AUTOCONNECTORCONNECTIONDELEGATE_H\n"
  },
  {
    "path": "editors/common/ComponentItemAutoConnector/AutoConnectorConnectionTable.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: AutoConnectorConnectionTable.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 11.02.2019\n//\n// Description:\n// Table for connected items of two components.\n//-----------------------------------------------------------------------------\n\n#include \"AutoConnectorConnectionTable.h\"\n\n#include <editors/common/ComponentItemAutoConnector/TableItemMatcher.h>\n\n#include <IPXACTmodels/Component/Component.h>\n\n#include <common/KactusColors.h>\n\n#include <QHeaderView>\n#include <QContextMenuEvent>\n#include <QMenu>\n#include <QMimeData>\n\n//-----------------------------------------------------------------------------\n// Function: AutoConnectorConnectionTable::AutoConnectorConnectionTable()\n//-----------------------------------------------------------------------------\nAutoConnectorConnectionTable::AutoConnectorConnectionTable(QSharedPointer<Component> firstComponent,\n    QSharedPointer<Component> secondComponent, QListView* firstList, QListView* secondList,\n    QString const& firstItemName, QString const& secondItemName, QSharedPointer<TableItemMatcher> itemMatcher, QWidget* parent):\nQTableWidget(parent),\nfirstComponent_(firstComponent),\nsecondComponent_(secondComponent),\nfirstItemList_(firstList),\nsecondItemList_(secondList),\ndragSourceList_(),\nremoveRowAction_(new QAction(tr(\"Remove row\"), this)),\naddRowAction_(new QAction(tr(\"Add row\"), this)),\nclearAction_(new QAction(tr(\"Clear\"), this)),\nitemMatcher_(itemMatcher)\n{\n    setDragDropMode(QAbstractItemView::DropOnly);\n\n    verticalHeader()->setSectionResizeMode(QHeaderView::Fixed);\n    verticalHeader()->setDefaultSectionSize(22);\n\n    setColumnCount(2);\n    verticalHeader()->hide();\n    horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch);\n    horizontalHeader()->setStretchLastSection(true);\n\n    QString firstHeader = firstItemName;\n    QString secondHeader = secondItemName;\n    QStringList horizontalHeaders = { firstHeader, secondHeader };\n    setHorizontalHeaderLabels(horizontalHeaders);\n\n    setupActions();\n}\n\n//-----------------------------------------------------------------------------\n// Function: AutoConnectorConnectionTable::setupActions()\n//-----------------------------------------------------------------------------\nvoid AutoConnectorConnectionTable::setupActions()\n{\n    QList<QKeySequence> addRowShortcuts;\n    addRowShortcuts << QKeySequence::InsertLineSeparator << QKeySequence(Qt::SHIFT | Qt::Key_Return);\n\n    addAction(addRowAction_);\n    addRowAction_->setShortcuts(addRowShortcuts);\n    addRowAction_->setShortcutContext(Qt::WidgetShortcut);\n    QString tooltipAddRow = tr(\"Add a new row to table (%1, %2)\")\n        .arg(addRowAction_->shortcuts().at(0).toString(QKeySequence::NativeText))\n        .arg(addRowAction_->shortcuts().at(1).toString(QKeySequence::NativeText));\n    addRowAction_->setToolTip(tooltipAddRow);\n    addRowAction_->setStatusTip(tooltipAddRow);\n    connect(addRowAction_, SIGNAL(triggered()), this, SLOT(onAddRow()), Qt::UniqueConnection);\n\n    addAction(removeRowAction_);\n    removeRowAction_->setShortcut(Qt::SHIFT | Qt::Key_Delete);\n    removeRowAction_->setShortcutContext(Qt::WidgetShortcut);\n    QString tooltipRemoveRow = tr(\"Remove a connection from the table (%1)\")\n        .arg(removeRowAction_->shortcut().toString(QKeySequence::NativeText));\n    removeRowAction_->setToolTip(tooltipRemoveRow);\n    removeRowAction_->setStatusTip(tooltipRemoveRow);\n    connect(removeRowAction_, SIGNAL(triggered()), this, SLOT(onRemoveRow()), Qt::UniqueConnection);\n\n    addAction(clearAction_);\n    clearAction_->setShortcut(QKeySequence::Delete);\n    clearAction_->setShortcutContext(Qt::WidgetShortcut);\n    QString tooltipClear = tr(\"Clear the contents of a cell (%1)\")\n        .arg(clearAction_->shortcut().toString(QKeySequence::NativeText));\n    clearAction_->setToolTip(tooltipClear);\n    clearAction_->setStatusTip(tooltipClear);\n    connect(clearAction_, SIGNAL(triggered()), this, SLOT(onClearCells()), Qt::UniqueConnection);\n}\n\n//-----------------------------------------------------------------------------\n// Function: AutoConnectorConnectionTable::checkDuplicateOrInvalidConnections()\n//-----------------------------------------------------------------------------\nvoid AutoConnectorConnectionTable::checkDuplicateOrInvalidConnections()\n{\n    QSet<QPair<QString, QString> > foundRows;\n    QSet<QPair<QString, QString> > duplicateRows;\n    containsInvalidRows_ = false;\n\n    for (int i = 0; i < rowCount(); ++i)\n    {\n        auto firstColItem = item(i, 0);\n        auto secondColItem = item(i, 1);\n\n        // Valid row, if either column is empty.\n        if (!firstColItem || !secondColItem || firstColItem->text().isEmpty() || secondColItem->text().isEmpty())\n        {\n            if (firstColItem)\n            {\n                firstColItem->setForeground(KactusColors::REGULAR_TEXT);\n            }\n            if (secondColItem)\n            {\n                secondColItem->setForeground(KactusColors::REGULAR_TEXT);\n            }\n\n            continue;\n        }\n\n        auto firstItemText = firstColItem->text();\n        auto secondItemText = secondColItem->text();\n\n        // Compare with previously found rows.\n        if (foundRows.contains({ firstItemText, secondItemText }))\n        {\n            duplicateRows.insert({ firstItemText, secondItemText });\n            continue;\n        }\n            \n        // Check if row items can be connected.\n        if (itemMatcher_->itemsCanBeConnected(firstItemText, firstComponent_, secondItemText, secondComponent_))\n        {\n            firstColItem->setForeground(KactusColors::REGULAR_TEXT);\n            secondColItem->setForeground(KactusColors::REGULAR_TEXT);\n        }\n        else\n        {\n            firstColItem->setForeground(KactusColors::ERROR);\n            secondColItem->setForeground(KactusColors::ERROR);\n            containsInvalidRows_ = true;\n        }\n\n        foundRows.insert({ firstItemText, secondItemText });\n    }\n\n    if (duplicateRows.isEmpty())\n    {\n        return;\n    }\n\n    containsInvalidRows_ = true;\n\n    for (int i = 0; i < rowCount(); ++i)\n    {\n        auto firstColItem = item(i, 0);\n        auto secondColItem = item(i, 1);\n\n        if (!firstColItem || !secondColItem || firstColItem->text().isEmpty() || secondColItem->text().isEmpty())\n        {\n            continue;\n        }\n\n        if (duplicateRows.contains({ firstColItem->text(), secondColItem->text() }))\n        {\n            firstColItem->setForeground(KactusColors::ERROR);\n            secondColItem->setForeground(KactusColors::ERROR);\n        }\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: AutoConnectorConnectionTable::getConnectedItems()\n//-----------------------------------------------------------------------------\nQVector<QPair<QString, QString> > AutoConnectorConnectionTable::getConnectedItems() const\n{\n    QVector<QPair<QString, QString> > fullConnections;\n\n    for (int i = 0; i < rowCount(); ++i)\n    {\n        QTableWidgetItem* firstItem = item(i, 0);\n        QTableWidgetItem* secondItem = item(i, 1);\n        if (firstItem && !firstItem->text().isEmpty() && secondItem && !secondItem->text().isEmpty())\n        {\n            QPair<QString, QString> connection;\n            connection.first = firstItem->text();\n            connection.second = secondItem->text();\n\n            fullConnections.append(connection);\n        }\n    }\n\n    return fullConnections;\n}\n\n//-----------------------------------------------------------------------------\n// Function: AutoConnectorConnectionTable::enableConnectionValidation()\n//-----------------------------------------------------------------------------\nvoid AutoConnectorConnectionTable::enableConnectionValidation()\n{\n    if (!connectionValidationEnabled_)\n    {\n        connect(this, SIGNAL(itemChanged(QTableWidgetItem*)), this, SLOT(onTableItemChanged(QTableWidgetItem*)), Qt::UniqueConnection);\n        connectionValidationEnabled_ = true;\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: AutoConnectorConnectionTable::hasInvalidConnections()\n//-----------------------------------------------------------------------------\nbool AutoConnectorConnectionTable::hasInvalidConnections() const\n{\n    return containsInvalidRows_;\n}\n\n//-----------------------------------------------------------------------------\n// Function: AutoConnectorConnectionTable::contextMenuEvent()\n//-----------------------------------------------------------------------------\nvoid AutoConnectorConnectionTable::contextMenuEvent(QContextMenuEvent *event)\n{\n    QModelIndex index = indexAt(event->pos());\n\n    QMenu menu(this);\n    menu.addAction(addRowAction_);\n\n    if (index.isValid())\n    {\n        menu.addAction(removeRowAction_);\n    }\n\n    menu.exec(event->globalPos());\n}\n\n//-----------------------------------------------------------------------------\n// Function: AutoConnectorConnectionTable::onAddRow()\n//-----------------------------------------------------------------------------\nvoid AutoConnectorConnectionTable::onAddRow()\n{\n    setRowCount(rowCount() + 1);\n}\n\n//-----------------------------------------------------------------------------\n// Function: AutoConnectorConnectionTable::onRemoveRow()\n//-----------------------------------------------------------------------------\nvoid AutoConnectorConnectionTable::onRemoveRow()\n{\n    QModelIndexList indexlist = selectedIndexes();\n    std::sort(indexlist.rbegin(), indexlist.rend()); // Sort in reverese order to remove last indexes first.\n\n    for(QModelIndex const& index : indexlist)\n    {\n        removeRow(index.row());\n    }\n\n    checkDuplicateOrInvalidConnections();\n}\n\n//-----------------------------------------------------------------------------\n// Function: AutoConnectorConnectionTable::onClearCells()\n//-----------------------------------------------------------------------------\nvoid AutoConnectorConnectionTable::onClearCells()\n{\n    QModelIndexList indexList = selectedIndexes();\n    for(QModelIndex const& index : indexList)\n    {\n        model()->setData(index, QVariant(), Qt::DecorationRole);\n        model()->setData(index, QVariant(), Qt::EditRole);\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: AutoConnectorConnectionTable::onTableItemChanged()\n//-----------------------------------------------------------------------------\nvoid AutoConnectorConnectionTable::onTableItemChanged(QTableWidgetItem* item)\n{\n    disconnect(this, SIGNAL(itemChanged(QTableWidgetItem*)), this, SLOT(onTableItemChanged(QTableWidgetItem*)));\n\n    checkDuplicateOrInvalidConnections();\n\n    connect(this, SIGNAL(itemChanged(QTableWidgetItem*)), this, SLOT(onTableItemChanged(QTableWidgetItem*)), Qt::UniqueConnection);\n}\n\n//-----------------------------------------------------------------------------\n// Function: AutoConnectorConnectionTable::dropMimeData()\n//-----------------------------------------------------------------------------\nbool AutoConnectorConnectionTable::dropMimeData(int row, int column, const QMimeData *data, Qt::DropAction action)\n{\n    if (dragSourceList_ && (dragSourceList_ == firstItemList_ || dragSourceList_ == secondItemList_))\n    {\n        int newColumn = column;\n        if (dragSourceList_ == firstItemList_)\n        {\n            newColumn = 0;\n        }\n        else if (dragSourceList_ == secondItemList_)\n        {\n            newColumn = 1;\n        }\n\n        dragSourceList_ = nullptr;\n\n        return QTableWidget::dropMimeData(row, newColumn, data, action);\n    }\n    else\n    {\n        dragSourceList_ = nullptr;\n\n        return false;\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: AutoConnectorConnectionTable::dragEnterEvent()\n//-----------------------------------------------------------------------------\nvoid AutoConnectorConnectionTable::dragEnterEvent(QDragEnterEvent *event)\n{\n    QTableWidget::dragEnterEvent(event);\n\n    dragSourceList_ = qobject_cast<QListView*>(event->source());\n}\n\n//-----------------------------------------------------------------------------\n// Function: AutoConnectorConnectionTable::dragMoveEvent()\n//-----------------------------------------------------------------------------\nvoid AutoConnectorConnectionTable::dragMoveEvent(QDragMoveEvent *event)\n{\n    QTableWidget::dragMoveEvent(event);\n}\n"
  },
  {
    "path": "editors/common/ComponentItemAutoConnector/AutoConnectorConnectionTable.h",
    "content": "//-----------------------------------------------------------------------------\n// File: AutoConnectorConnectionTable.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 11.02.2019\n//\n// Description:\n// Table for connected items of two components.\n//-----------------------------------------------------------------------------\n\n#ifndef AUTOCONNECTORCONNECTIONTABLE_H\n#define AUTOCONNECTORCONNECTIONTABLE_H\n\n#include <QTableWidget>\n#include <QListView>\n#include <QSharedPointer>\n\nclass Component;\nclass TableItemMatcher;\n\n//-----------------------------------------------------------------------------\n//! Table for connected items of two components.\n//-----------------------------------------------------------------------------\nclass AutoConnectorConnectionTable : public QTableWidget\n{\n    Q_OBJECT\n\npublic:\n\n    /*!\n     *  The constructor.\n     *\n     *    @param [in] firstComponent      The first component containing the items to be connected.\n     *    @param [in] secondComponent     The second component containing the items to be connected.\n     *    @param [in] firstList           View of the first item list to be connected.\n     *    @param [in] secondList          View of the second item list to be connected.\n     *    @param [in] firstName           Name of the first item.\n     *    @param [in] secondName          Name of the second item.\n     *    @param [in] itemMatcher         Checks for possible matches between two items.\n     *    @param [in] parent              The parent item.\n     */\n    AutoConnectorConnectionTable(QSharedPointer<Component> firstComponent,\n        QSharedPointer<Component> secondComponent, QListView* firstList, QListView* secondList,\n        QString const& firstItemName, QString const& secondItemName, QSharedPointer<TableItemMatcher> itemMatcher,\n        QWidget* parent = 0);\n\n    /*!\n     *  The destructor.\n     */\n    ~AutoConnectorConnectionTable() = default;\n\n    /*!\n     *  Get the connected items.\n     *\n     *    @return A list of connected item pairs.\n     */\n    QVector<QPair<QString, QString> > getConnectedItems() const;\n\n    /*!\n     *\tEnable validation of created connections. Should only be enabled after table is initialized.\n     */\n    void enableConnectionValidation();\n\n    /*!\n     *\tChecks connected items for invalid connections.\n     *  \n     * \t    @return True, if invalid connections are found, otherwise false.\n     */\n    bool hasInvalidConnections() const;\n\n    // No copying. No assignments.\n    AutoConnectorConnectionTable(AutoConnectorConnectionTable const& rhs) = delete;\n    AutoConnectorConnectionTable& operator=(AutoConnectorConnectionTable const& rhs) = delete;\n\nprotected:\n\n    /*!\n     *  Handles the context menu.\n     *\n     *    @param [in] event   The context menu event.\n     */\n    virtual void contextMenuEvent(QContextMenuEvent *event);\n\n    /*!\n     *  Handles the mime data drop.\n     *\n     *    @param [in] row     Row to drop the mime data to.\n     *    @param [in] column  Column to drop the mime data to.\n     *    @param [in] data    The mime data.\n     *    @param [in] action  The drop action.\n     */\n    virtual bool dropMimeData(int row, int column, const QMimeData *data, Qt::DropAction action);\n\n    /*!\n     *  Handles the events for drag entering this table\n     *\n     *    @param [in] event   The selected drag enter event.\n     */\n    virtual void dragEnterEvent(QDragEnterEvent *event);\n\n    /*!\n     *  Handles the events for drag moving in this table\n     *\n     *    @param [in] event   The selected drag move event.\n     */\n    virtual void dragMoveEvent(QDragMoveEvent *event);\n\nprivate slots:\n\n    /*!\n     *  Handles the row removal.\n     */\n    void onRemoveRow();\n\n    /*!\n     *  Handles the row addition.\n     */\n    void onAddRow();\n\n    /*!\n     *  Handles the cell clearing.\n     */\n    void onClearCells();\n\n    /*!\n     *\tHandles validation of rows in the table, when a cell is changed. Making invalid connections is allowed,\n     *  but they are colored red in the table.\n     */\n    void onTableItemChanged(QTableWidgetItem* item);\n\nprivate:\n\n    /*!\n     *  Setup the available actions.\n     */\n    void setupActions();\n\n    /*!\n     *\tChecks the connector table for invalid or duplicate connections and colors rows accordingly.\n     */\n    void checkDuplicateOrInvalidConnections();\n\n    //-----------------------------------------------------------------------------\n    // Data.\n    //-----------------------------------------------------------------------------\n\n    //! Component containing the first list of items.\n    QSharedPointer<Component> firstComponent_;\n\n    //! Component containing the second list of items.\n    QSharedPointer<Component> secondComponent_;\n\n    //! View of the first item list.\n    QListView* firstItemList_;\n\n    //! View of the second item list.\n    QListView* secondItemList_;\n\n    //! Source view for the drag & drop event.\n    QListView* dragSourceList_;\n\n    //! Action for removing rows.\n    QAction* removeRowAction_;\n\n    //! Action for adding rows.\n    QAction* addRowAction_;\n\n    //! Action for clearing the cells.\n    QAction* clearAction_;\n\n    //! Checks for possible matches between two items.\n    QSharedPointer<TableItemMatcher> itemMatcher_;\n\n    //! Flag indicating if connection validation is enabled.\n    bool connectionValidationEnabled_ = false;\n\n    //! Indicates if the table contains invalid or duplicate rows.\n    bool containsInvalidRows_ = false;\n};\n\n#endif // AUTOCONNECTORCONNECTIONTABLE_H\n"
  },
  {
    "path": "editors/common/ComponentItemAutoConnector/AutoConnectorItem.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: AutoConnectorItem.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 11.02.2019\n//\n// Description:\n// Item used by component item auto connector.\n//-----------------------------------------------------------------------------\n\n#include \"AutoConnectorItem.h\"\n\n//-----------------------------------------------------------------------------\n// Function: AutoConnectorItem::AutoConnectorItem()\n//-----------------------------------------------------------------------------\nAutoConnectorItem::AutoConnectorItem(QString const& itemName, QString const& componentItemName,\n    AutoConnectorItem::ItemType itemType, AutoConnectorItem::ContainerType containerType):\nitemName_(itemName),\ncontainingItemName_(componentItemName),\nitemType_(itemType),\ncontainterType_(containerType)\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: AutoConnectorItem::AutoConnectorItem()\n//-----------------------------------------------------------------------------\nAutoConnectorItem::AutoConnectorItem(const AutoConnectorItem &other):\nitemName_(other.itemName_),\ncontainingItemName_(other.containingItemName_),\nitemType_(other.itemType_)\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: AutoConnectorItem::operator=()\n//-----------------------------------------------------------------------------\nAutoConnectorItem & AutoConnectorItem::operator=(const AutoConnectorItem &other)\n{\n    if (this != &other)\n    {\n        itemName_ = other.itemName_;\n        containingItemName_ = other.containingItemName_;\n        itemType_ = other.itemType_;\n    }\n    return *this;\n}\n\n//-----------------------------------------------------------------------------\n// Function: AutoConnectorItem::operator==()\n//-----------------------------------------------------------------------------\nbool AutoConnectorItem::operator==(const AutoConnectorItem& other) const\n{\n    return itemName_ == other.itemName_ && containingItemName_ == other.containingItemName_ &&\n        itemType_ == other.itemType_ && containterType_ == other.containterType_;\n}\n\n//-----------------------------------------------------------------------------\n// Function: AutoConnectorItem::~AutoConnectorItem()\n//-----------------------------------------------------------------------------\nAutoConnectorItem::~AutoConnectorItem()\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: AutoConnectorItem::getName()\n//-----------------------------------------------------------------------------\nQString AutoConnectorItem::getName() const\n{\n    return itemName_;\n}\n\n//-----------------------------------------------------------------------------\n// Function: AutoConnectorItem::setName()\n//-----------------------------------------------------------------------------\nvoid AutoConnectorItem::setName(QString const& newName)\n{\n    itemName_ = newName;\n}\n\n//-----------------------------------------------------------------------------\n// Function: AutoConnectorItem::getContainingItem()\n//-----------------------------------------------------------------------------\nQString AutoConnectorItem::getContainingItem() const\n{\n    return containingItemName_;\n}\n\n//-----------------------------------------------------------------------------\n// Function: AutoConnectorItem::setContainingItem()\n//-----------------------------------------------------------------------------\nvoid AutoConnectorItem::setContainingItem(QString const& newComponentItem)\n{\n    containingItemName_ = newComponentItem;\n}\n\n//-----------------------------------------------------------------------------\n// Function: AutoConnectorItem::getItemType()\n//-----------------------------------------------------------------------------\nAutoConnectorItem::ItemType AutoConnectorItem::getItemType() const\n{\n    return itemType_;\n}\n\n//-----------------------------------------------------------------------------\n// Function: AutoConnectorItem::setNewItemType()\n//-----------------------------------------------------------------------------\nvoid AutoConnectorItem::setNewItemType(AutoConnectorItem::ItemType newItemType)\n{\n    itemType_ = newItemType;\n}\n\n//-----------------------------------------------------------------------------\n// Function: AutoConnectorItem::getContainterType()\n//-----------------------------------------------------------------------------\nAutoConnectorItem::ContainerType AutoConnectorItem::getContainterType() const\n{\n    return containterType_;\n}\n\n//-----------------------------------------------------------------------------\n// Function: AutoConnectorItem::setNewContainerType()\n//-----------------------------------------------------------------------------\nvoid AutoConnectorItem::setNewContainerType(AutoConnectorItem::ContainerType newContainerType)\n{\n    containterType_ = newContainerType;\n}\n"
  },
  {
    "path": "editors/common/ComponentItemAutoConnector/AutoConnectorItem.h",
    "content": "//-----------------------------------------------------------------------------\n// File: AutoConnectorItem.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 11.02.2019\n//\n// Description:\n// Item used by component item auto connector.\n//-----------------------------------------------------------------------------\n\n#ifndef AUTOCONNECTORITEM_H\n#define AUTOCONNECTORITEM_H\n\n#include <QString>\n\n//-----------------------------------------------------------------------------\n//! Item used by component item auto connector.\n//-----------------------------------------------------------------------------\nclass AutoConnectorItem\n{\n\npublic:\n\n    //! Item type.\n    enum ItemType\n    {\n        PORT,\n        BUS_INTERFACE,\n        INVALID\n    };\n\n    //! Container type.\n    enum ContainerType\n    {\n        TOP_COMPONENT,\n        COMPONENT_ITEM,\n        INVALID_CONTAINER\n    };\n\n    /*!\n     *  The constructor.\n     *\n     *    @param [in] itemName            Name of the connected item.\n     *    @param [in] componentItemName   Name of the containing component item.\n     *    @param [in] itemType            Type of the item.\n     *    @param [in] containerType       Type of the container.\n     */\n    AutoConnectorItem(QString const& itemName, QString const& componentItemName,\n        AutoConnectorItem::ItemType itemType,\n        AutoConnectorItem::ContainerType containerType = AutoConnectorItem::ContainerType::COMPONENT_ITEM);\n\n    /*!\n     *  Copy constructor.\n     */\n    AutoConnectorItem(const AutoConnectorItem &other);\n\n    /*!\n     *  Assignment operator.\n     */\n    AutoConnectorItem &operator=(const AutoConnectorItem &other);\n\n    bool operator==(const AutoConnectorItem& other) const;\n\n    /*!\n     *  The destructor.\n     */\n    ~AutoConnectorItem();\n\n    /*!\n     *  Get the name.\n     *\n     *    @return Name of the item.\n     */\n    QString getName() const;\n\n    /*!\n     *  Set a new name.\n     *\n     *    @param [in] newName     New name for the item.\n     */\n    void setName(QString const& newName);\n\n    /*!\n     *  Get the name of the containing component item.\n     *\n     *    @return The name of the containing component item.\n     */\n    QString getContainingItem() const;\n\n    /*!\n     *  Set the name of the containing component item.\n     *\n     *    @param [in] newComponentItem    New name for the containing component item.\n     */\n    void setContainingItem(QString const& newComponentItem);\n\n    /*!\n     *  Get the type.\n     *\n     *    @return Type of the item.\n     */\n    AutoConnectorItem::ItemType getItemType() const;\n\n    /*!\n     *  Set the type for the item.\n     *\n     *    @param [in] newItemType     New type for the item.\n     */\n    void setNewItemType(AutoConnectorItem::ItemType newItemType);\n\n    /*!\n     *  Get the container type.\n     *\n     *    @return Type of the container.\n     */\n    AutoConnectorItem::ContainerType getContainterType() const;\n\n    /*!\n     *  Set the type for the container.\n     *\n     *    @param [in] newContainerType    New type for the container.\n     */\n    void setNewContainerType(AutoConnectorItem::ContainerType newContainerType);\n\nprivate:\n\n    //-----------------------------------------------------------------------------\n    // Data.\n    //-----------------------------------------------------------------------------\n\n    //! Name of the item.\n    QString itemName_;\n\n    //! Name of the containing component item.\n    QString containingItemName_;\n\n    //! Item type.\n    AutoConnectorItem::ItemType itemType_;\n\n    //! Container type.\n    AutoConnectorItem::ContainerType containterType_;\n};\n\n#endif // AUTOCONNECTORITEM_H\n"
  },
  {
    "path": "editors/common/ComponentItemAutoConnector/AutoConnectorListFilter.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: AutoConnectorListFilter.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 19.02.2019\n//\n// Description:\n// Sorting proxy model for auto connector lists.\n//-----------------------------------------------------------------------------\n\n#include \"AutoConnectorListFilter.h\"\n\n//-----------------------------------------------------------------------------\n// Function: AutoConnectorListFilter::AutoConnectorListFilter()\n//-----------------------------------------------------------------------------\nAutoConnectorListFilter::AutoConnectorListFilter(QTableWidget* itemTable, int const& tableColumn,\n    QCheckBox* hideConnectedBox, QObject* parent):\nQSortFilterProxyModel(parent),\ntableColumn_(tableColumn),\nitemTable_(itemTable),\nhideConnectedBox_(hideConnectedBox)\n{\n    connect(hideConnectedBox, SIGNAL(stateChanged(int)), this, SLOT(invalidate()), Qt::UniqueConnection);\n}\n\n//-----------------------------------------------------------------------------\n// Function: AutoConnectorListFilter::filterAcceptsRow()\n//-----------------------------------------------------------------------------\nbool AutoConnectorListFilter::filterAcceptsRow(int source_row, const QModelIndex& source_parent) const\n{   \n    QModelIndex index = sourceModel()->index(source_row, 0);\n    QString itemName = sourceModel()->data(index).toString();\n\n    if (hideConnectedBox_->isChecked() && itemIsConnected(itemName))\n    {\n        return false;\n    }\n\n    return QSortFilterProxyModel::filterAcceptsRow(source_row, source_parent);\n}\n\n//-----------------------------------------------------------------------------\n// Function: AutoConnectorListFilter::itemIsConnected()\n//-----------------------------------------------------------------------------\nbool AutoConnectorListFilter::itemIsConnected(QString const& itemName) const\n{\n    for (int i = 0; i < itemTable_->rowCount(); ++i)\n    {\n        QTableWidgetItem* tableItem = itemTable_->item(i, tableColumn_);\n        if (tableItem && tableItem->text() == itemName)\n        {\n            return true;\n        }\n    }\n\n    return false;\n}\n"
  },
  {
    "path": "editors/common/ComponentItemAutoConnector/AutoConnectorListFilter.h",
    "content": "//-----------------------------------------------------------------------------\n// File: AutoConnectorListFilter.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 19.02.2019\n//\n// Description:\n// Sorting proxy model for auto connector lists.\n//-----------------------------------------------------------------------------\n\n#ifndef AUTOCONNECTORLISTFILTER_H\n#define AUTOCONNECTORLISTFILTER_H\n\n#include <QSortFilterProxyModel>\n#include <QTableWidget>\n#include <QCheckBox>\n\n//-----------------------------------------------------------------------------\n//! Sorting proxy model for auto connector lists.\n//-----------------------------------------------------------------------------\nclass AutoConnectorListFilter : public QSortFilterProxyModel\n{\n    Q_OBJECT\n\npublic:\n\n\t /*!\n      *  Constructor.\n      *\n      *    @param [in] itemTable       Table containing the connected items.\n      *    @param [in] tableColumn     Column in the connection table.\n      *    @param [in] parent          The parent object.\n      */\n    AutoConnectorListFilter(QTableWidget* itemTable, int const& tableColumn, QCheckBox* hideConnectedBox,\n        QObject* parent = 0);\n\n\t /*!\n      *  Destructor.\n      */\n    virtual ~AutoConnectorListFilter() = default;\n\n    // No copying. No assignments.\n    AutoConnectorListFilter(AutoConnectorListFilter const& rhs) = delete;\n    AutoConnectorListFilter& operator=(AutoConnectorListFilter const& rhs) = delete;\n\nprotected:\n\n    /*!\n\t *  Implementation of the row filtering.\n\t *\n\t *    @param [in] source_row      The row to check for filtering.\n     *    @param [in] source_parent   The parent index of the row.\n     *\n     *    @return True, if the row passes the filters, otherwise false.\n\t */\n    virtual bool filterAcceptsRow(int source_row, const QModelIndex & source_parent) const override;\n\nprivate:\n\n    /*!\n     *  Check if the selected item exists in the connection table.\n     *\n     *    @param [in] itemName    Name of the selected item.\n     *\n     *    @return True, if the item has been connected, false otherwise.\n     */\n    bool itemIsConnected(QString const& itemName) const;\n\n    //-----------------------------------------------------------------------------\n    // Data.\n    //-----------------------------------------------------------------------------\n\n    //! Column in the connection table.\n    int tableColumn_;\n\n    //! Table containing the connected items.\n    QTableWidget* itemTable_;\n\n    //! Informs whether the connected items should be hidden.\n    QCheckBox* hideConnectedBox_;\n};\n\n#endif // AUTOCONNECTORLISTFILTER_H"
  },
  {
    "path": "editors/common/ComponentItemAutoConnector/BusInterfaceItemMatcher.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: BusInterfaceItemMatcher.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 25.02.2019\n//\n// Description:\n// Automatically defines possible matches between two bus interfaces.\n//-----------------------------------------------------------------------------\n\n#include \"BusInterfaceItemMatcher.h\"\n\n#include <KactusAPI/include/BusInterfaceUtilities.h>\n\n#include <KactusAPI/include/LibraryInterface.h>\n\n#include <IPXACTmodels/Component/Component.h>\n#include <IPXACTmodels/Component/BusInterface.h>\n\n#include <IPXACTmodels/BusDefinition/BusDefinition.h>\n\n//-----------------------------------------------------------------------------\n// Function: BusInterfaceItemMatcher::BusInterfaceItemMatcher()\n//-----------------------------------------------------------------------------\nBusInterfaceItemMatcher::BusInterfaceItemMatcher(LibraryInterface* library):\nTableItemMatcher(),\nlibrary_(library)\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: BusInterfaceItemMatcher::itemsCanBeConnected()\n//-----------------------------------------------------------------------------\nbool BusInterfaceItemMatcher::itemsCanBeConnected(QString const& firstItem,\n    QSharedPointer<Component> firstComponent, QString const& secondItem,\n    QSharedPointer<Component> secondComponent) const\n{\n    QSharedPointer<BusInterface> firstBus = firstComponent->getBusInterface(firstItem);\n    QSharedPointer<BusInterface> secondBus = secondComponent->getBusInterface(secondItem);\n    if (firstBus && secondBus)\n    {\n        ConfigurableVLNVReference firstBusDefinitionVLNV = firstBus->getBusType();\n        if (firstBusDefinitionVLNV.isValid())\n        {\n            QSharedPointer<const BusDefinition> firstBusDefinition =\n                library_->getModelReadOnly(firstBusDefinitionVLNV).dynamicCast<const BusDefinition>();\n            if (firstBusDefinition)\n            {\n                General::InterfaceMode busMode = firstBus->getInterfaceMode();\n                General::InterfaceMode secondBusMode = secondBus->getInterfaceMode();\n                if (busMode != General::MONITOR && secondBusMode != General::MONITOR)\n                {\n                    QVector<General::InterfaceMode> compatibleModes = getCompatibleModes(busMode);\n\n                    return compatibleModes.contains(secondBusMode) &&\n                        BusInterfaceUtilities::hasMatchingBusDefinitions(\n                            firstBusDefinition, secondBus->getBusType(), library_);\n                }\n            }\n        }\n    }\n\n    return false;\n}\n\n//-----------------------------------------------------------------------------\n// Function: BusInterfaceItemMatcher::getCompatibleModes()\n//-----------------------------------------------------------------------------\nQVector<General::InterfaceMode> BusInterfaceItemMatcher::getCompatibleModes(General::InterfaceMode busMode) const\n{\n    return General::getCompatibleInterfaceModesForActiveInterface(busMode);\n}\n"
  },
  {
    "path": "editors/common/ComponentItemAutoConnector/BusInterfaceItemMatcher.h",
    "content": "//-----------------------------------------------------------------------------\n// File: BusInterfaceItemMatcher.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 25.02.2019\n//\n// Description:\n// Automatically defines possible matches between two bus interfaces.\n//-----------------------------------------------------------------------------\n\n#ifndef BUSINTERFACEITEMMATCHER_H\n#define BUSINTERFACEITEMMATCHER_H\n\n#include <editors/common/ComponentItemAutoConnector/TableItemMatcher.h>\n\n#include <IPXACTmodels/generaldeclarations.h>\n\n#include <QSharedPointer>\n\nclass Component;\nclass LibraryInterface;\n\n//-----------------------------------------------------------------------------\n//! Automatically defines possible matches between two bus interfaces.\n//-----------------------------------------------------------------------------\nclass BusInterfaceItemMatcher : public TableItemMatcher\n{\npublic:\n\n    /*!\n     *  The constructor.\n     *\n     *    @param [in] library     Access to the document library.\n     */\n    BusInterfaceItemMatcher(LibraryInterface* library);\n\n    /*!\n     *  Destructor.\n     */\n    virtual ~BusInterfaceItemMatcher() = default;\n\n    // No copying. No assignments.\n    BusInterfaceItemMatcher(BusInterfaceItemMatcher const& rhs) = delete;\n    BusInterfaceItemMatcher& operator=(BusInterfaceItemMatcher const& rhs) = delete;\n\nprivate:\n\n    /*!\n     *  Check if the selected items can be connected.\n     *\n     *    @param [in] firstItem           The selected item from the first component.\n     *    @param [in] firstComponent      Component containing the first item.\n     *    @param [in] secondItem          The selected item from the second component.\n     *    @param [in] secondComponent     Component containing the second item.\n     *\n     *    @return True, if the items can be connected, false otherwise.\n     */\n    virtual bool itemsCanBeConnected(QString const& firstItem, QSharedPointer<Component> firstComponent,\n        QString const& secondItem, QSharedPointer<Component> secondComponent) const;\n\n    /*!\n     *  Get connectible bus interface modes for the selected interface mode.\n     *\n     *    @param [in] busMode     The selected bus interface mode.\n     *\n     *    @return List of connectible interface modes.\n     */\n    virtual QVector<General::InterfaceMode> getCompatibleModes(General::InterfaceMode busMode) const;\n\n    //-----------------------------------------------------------------------------\n    // Data.\n    //-----------------------------------------------------------------------------\n\n    //! Access to the document library.\n    LibraryInterface* library_;\n};\n\n//-----------------------------------------------------------------------------\n\n#endif // BUSINTERFACEITEMMATCHER_H\n"
  },
  {
    "path": "editors/common/ComponentItemAutoConnector/BusInterfaceListFiller.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: BusInterfaceListFiller.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 13.02.2019\n//\n// Description:\n// Fills a list with bus interfaces.\n//-----------------------------------------------------------------------------\n\n#include \"BusInterfaceListFiller.h\"\n\n#include <KactusAPI/include/BusInterfaceUtilities.h>\n\n#include <IPXACTmodels/Component/Component.h>\n#include <IPXACTmodels/Component/BusInterface.h>\n\n//-----------------------------------------------------------------------------\n// Function: BusInterfaceListFiller::initializeList()\n//-----------------------------------------------------------------------------\nvoid BusInterfaceListFiller::initializeList(QStandardItemModel* selectedList,\n    QSharedPointer<Component> containingComponent) const\n{\n    for (auto busInterface : *containingComponent->getBusInterfaces())\n    {\n        General::InterfaceMode busMode = busInterface->getInterfaceMode();\n        if (busMode != General::MONITOR)\n        {\n            QIcon modeIcon(BusInterfaceUtilities::getIconPath(busMode));\n            QStandardItem* newBusItem = new QStandardItem(modeIcon, busInterface->name());\n            newBusItem->setEditable(false);\n            selectedList->appendRow(newBusItem);\n        }\n    }\n}\n"
  },
  {
    "path": "editors/common/ComponentItemAutoConnector/BusInterfaceListFiller.h",
    "content": "//-----------------------------------------------------------------------------\n// File: BusInterfaceListFiller.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 13.02.2019\n//\n// Description:\n// Fills a list with bus interfaces.\n//-----------------------------------------------------------------------------\n\n#ifndef BUSINTERFACELISTFILLER_H\n#define BUSINTERFACELISTFILLER_H\n\n#include <editors/common/ComponentItemAutoConnector/ListFiller.h>\n\n#include <IPXACTmodels/generaldeclarations.h>\n\nclass Component;\n\n//-----------------------------------------------------------------------------\n//! Fills a list with bus interfaces.\n//-----------------------------------------------------------------------------\nclass BusInterfaceListFiller : public ListFiller\n{\npublic:\n\n    /*!\n     *  The constructor.\n     */\n    BusInterfaceListFiller() = default;\n\n    /*!\n     *  Destructor.\n     */\n    ~BusInterfaceListFiller() = default;\n\n    /*!\n     *  Populate the selected model with bus interfaces from the selected component.\n     *\n     *    @param [in] selectedList            The selected item model.\n     *    @param [in] containingComponent     The selected component.\n     */\n    virtual void initializeList(QStandardItemModel* selectedList, QSharedPointer<Component> containingComponent)\n        const;\n\n    // No copying. No assignments.\n    BusInterfaceListFiller(BusInterfaceListFiller const& rhs) = delete;\n    BusInterfaceListFiller& operator=(BusInterfaceListFiller const& rhs) = delete;\n};\n\n//-----------------------------------------------------------------------------\n\n#endif // BUSINTERFACELISTFILLER_H\n"
  },
  {
    "path": "editors/common/ComponentItemAutoConnector/BusInterfaceTableAutoConnector.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: BusInterfaceTableAutoConnector.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 13.02.2019\n//\n// Description:\n// Automatically connects bus interfaces of two components.\n//-----------------------------------------------------------------------------\n\n#include \"BusInterfaceTableAutoConnector.h\"\n\n#include <IPXACTmodels/BusDefinition/BusDefinition.h>\n\n#include <IPXACTmodels/Component/Component.h>\n#include <IPXACTmodels/Component/BusInterface.h>\n#include <IPXACTmodels/Design/Design.h>\n\n#include <KactusAPI/include/BusInterfaceUtilities.h>\n\n#include <KactusAPI/include/LibraryInterface.h>\n\n//-----------------------------------------------------------------------------\n// Function: BusInterfaceTableAutoConnector::BusInterfaceTableAutoConnector()\n//-----------------------------------------------------------------------------\nBusInterfaceTableAutoConnector::BusInterfaceTableAutoConnector(LibraryInterface* library):\nTableAutoConnector(),\nlibrary_(library)\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: BusInterfaceTableAutoConnector::findPossibleCombinations()\n//-----------------------------------------------------------------------------\nQVector<QPair<QString, QVector<QString> > > BusInterfaceTableAutoConnector::findPossibleCombinations(\n    QSharedPointer<Component> firstComponent, QSharedPointer<Component> secondComponent) const\n{\n    QVector<QPair<QString, QVector<QString> > > possibleCombinations;\n\n    QSharedPointer<QList<QSharedPointer<BusInterface> > > firstInterfaces = firstComponent->getBusInterfaces();\n    QSharedPointer<QList<QSharedPointer<BusInterface> > > secondInterface = secondComponent->getBusInterfaces();\n\n    for (auto const& currentBus : *firstInterfaces)\n    {\n        if (currentBus->getInterfaceMode() != General::MONITOR)\n        {\n            QVector<QString> connectibleBuses = getConnectableBusInterfaceNames(currentBus, secondInterface);\n\n            if (!connectibleBuses.isEmpty())\n            {\n                QPair<QString, QVector<QString> > newCombinationPair;\n                newCombinationPair.first = currentBus->name();\n                newCombinationPair.second = connectibleBuses;\n\n                possibleCombinations.append(newCombinationPair);\n            }\n        }\n    }\n\n    return possibleCombinations;\n}\n\n//-----------------------------------------------------------------------------\n// Function: BusInterfaceTableAutoConnector::findAlreadyConnectedItems()\n//-----------------------------------------------------------------------------\nQList<QPair<QString, QString > > BusInterfaceTableAutoConnector::findAlreadyConnectedItems(\n    QString const& firstInstanceName, QString const& secondInstanceName,\n    QSharedPointer<Design> design) const\n{\n    QList<QPair<QString, QString > > foundConnections;\n\n    // Find connections between component instance bus interfaces.\n    for (auto const& interconnection : *design->getInterconnections())\n    {\n        auto startInterface = interconnection->getStartInterface();\n\n        auto const& startComponentReference = startInterface->getComponentReference();\n\n        if (startComponentReference == firstInstanceName ||\n            startComponentReference == secondInstanceName)\n        {\n            bool startIsFirst = startComponentReference == firstInstanceName;\n\n            for (auto const& activeInterface : *interconnection->getActiveInterfaces())\n            {\n                if (startIsFirst && activeInterface->getComponentReference() == secondInstanceName)\n                {\n                    foundConnections.emplace_back(startInterface->getBusReference(), activeInterface->getBusReference());\n                }\n                else if (!startIsFirst && activeInterface->getComponentReference() == firstInstanceName)\n                {\n                    foundConnections.emplace_back(activeInterface->getBusReference(), startInterface->getBusReference());\n                }\n            }\n        }\n    }\n\n    return foundConnections;\n}\n\n//-----------------------------------------------------------------------------\n// Function: BusInterfaceTableAutoConnector::getConnectableBusInterfaceNames()\n//-----------------------------------------------------------------------------\nQVector<QString> BusInterfaceTableAutoConnector::getConnectableBusInterfaceNames(\n    QSharedPointer<BusInterface> currentBus,\n    QSharedPointer<QList<QSharedPointer<BusInterface>>> secondItemBusInterfaces) const\n{\n    QVector<QString> possibleInterfaces;\n\n    ConfigurableVLNVReference busReference = currentBus->getBusType();\n    if (busReference.isValid())\n    {\n        QSharedPointer<const BusDefinition> busType =\n            library_->getModelReadOnly(busReference).dynamicCast<const BusDefinition>();\n        if (busType)\n        {\n            General::InterfaceMode busMode = currentBus->getInterfaceMode();\n\n            QVector<General::InterfaceMode> compatibleInterfaces;\n            if (busMode == General::MONITOR)\n            {\n                compatibleInterfaces.append(currentBus->getMonitor()->interfaceMode_);\n            }\n            else\n            {\n                compatibleInterfaces = getCompatibleInterfaceModes(busMode);\n            }\n\n            for (auto comparisonBus : *secondItemBusInterfaces)\n            {\n                if (interfacesAreCompatible(comparisonBus, compatibleInterfaces) &&\n                    BusInterfaceUtilities::hasMatchingBusDefinitions(\n                        busType, comparisonBus->getBusType(), library_))\n                {\n                    possibleInterfaces.append(comparisonBus->name());\n                }\n            }\n        }\n    }\n\n\n    return possibleInterfaces;\n}\n\n//-----------------------------------------------------------------------------\n// Function: BusInterfaceTableAutoConnector::getCompatibleInterfaceModes()\n//-----------------------------------------------------------------------------\nQVector<General::InterfaceMode> BusInterfaceTableAutoConnector::getCompatibleInterfaceModes(\n    General::InterfaceMode const& busMode) const\n{\n    return General::getCompatibleInterfaceModesForActiveInterface(busMode);\n}\n\n//-----------------------------------------------------------------------------\n// Function: BusInterfaceTableAutoConnector::interfacesAreCompatible()\n//-----------------------------------------------------------------------------\nbool BusInterfaceTableAutoConnector::interfacesAreCompatible(QSharedPointer<BusInterface> comparisonBus,\n    QVector<General::InterfaceMode> compatibleModes) const\n{\n    General::InterfaceMode comparisonMode = comparisonBus->getInterfaceMode();\n    if (comparisonMode == General::MONITOR)\n    {\n        return false;\n    }\n\n    return compatibleModes.contains(comparisonMode);\n}\n\n//-----------------------------------------------------------------------------\n// Function: BusInterfaceTableAutoConnector::createTableWidgetItem()\n//-----------------------------------------------------------------------------\nQTableWidgetItem* BusInterfaceTableAutoConnector::createTableWidgetItem(QString const& itemName,\n    QSharedPointer<Component> containingComponent) const\n{\n    QTableWidgetItem* newTableItem = TableAutoConnector::createTableWidgetItem(itemName, containingComponent);\n\n    QSharedPointer<BusInterface> itemBus = containingComponent->getBusInterface(itemName);\n    QIcon busItemIcon(BusInterfaceUtilities::getIconPath(itemBus->getInterfaceMode()));\n\n    newTableItem->setIcon(busItemIcon);\n    return newTableItem;\n}\n"
  },
  {
    "path": "editors/common/ComponentItemAutoConnector/BusInterfaceTableAutoConnector.h",
    "content": "//-----------------------------------------------------------------------------\n// File: BusInterfaceTableAutoConnector.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 13.02.2019\n//\n// Description:\n// Automatically connects bus interfaces of two components.\n//-----------------------------------------------------------------------------\n\n#ifndef BUSINTERFACETABLEAUTOCONNECTOR_H\n#define BUSINTERFACETABLEAUTOCONNECTOR_H\n\n#include <IPXACTmodels/common/ConfigurableVLNVReference.h>\n#include <IPXACTmodels/generaldeclarations.h>\n\n#include <editors/common/ComponentItemAutoConnector/TableAutoConnector.h>\n\nclass BusDefinition;\n\nclass Component;\nclass BusInterface;\nclass Design;\n\nclass LibraryInterface;\n\n//-----------------------------------------------------------------------------\n//! Automatically connects bus interfaces of two components.\n//-----------------------------------------------------------------------------\nclass BusInterfaceTableAutoConnector : public TableAutoConnector\n{\npublic:\n\n    /*!\n     *  The constructor.\n     */\n    BusInterfaceTableAutoConnector(LibraryInterface* library);\n\n    /*!\n     *  Destructor.\n     */\n    virtual ~BusInterfaceTableAutoConnector() = default;\n\n    // No copying. No assignments.\n    BusInterfaceTableAutoConnector(BusInterfaceTableAutoConnector const& rhs) = delete;\n    BusInterfaceTableAutoConnector& operator=(BusInterfaceTableAutoConnector const& rhs) = delete;\n\nprotected:\n\n    /*!\n     *  Create a table item.\n     *\n     *    @param [in] itemName                Name for the table item.\n     *    @param [in] containingComponent     Component containing the selected item.\n     *\n     *    @return The new table item.\n     */\n    virtual QTableWidgetItem* createTableWidgetItem(QString const& itemName,\n        QSharedPointer<Component> containingComponent) const;\n\nprivate:\n\n    /*!\n     *  Find the possible item connections from the selected components.\n     *\n     *    @param [in] firstComponent      The first component.\n     *    @param [in] secondComponent     The second component.\n     *\n     *    @return List of item / possible connected items pairs.\n     */\n    virtual QVector<QPair<QString, QVector<QString> > > findPossibleCombinations(\n        QSharedPointer<Component> firstComponent, QSharedPointer<Component> secondComponent) const;\n\n    /*!\n     *\tFind items that are already connected to populate the connection table with.\n     *  \n     *    @param [in] firstInstanceName   The first component.\n     *    @param [in] secondInstanceName  The second component.\n     *    @param [in] design              The containing design.\n     *\t    \n     * \t    @return List of item connected item pairs.\n     */\n    virtual QList<QPair<QString, QString > > findAlreadyConnectedItems(\n        QString const& firstInstanceName, QString const& secondInstanceName,\n        QSharedPointer<Design> design) const override;\n\n    /*!\n     *  Get the names of the connectible bus interfaces for the selected bus interface.\n     *\n     *    @param [in] currentBus                  The selected bus interface.\n     *    @param [in] secondItemBusInterfaces     List of the available bus interfaces.\n     *\n     *    @return A list of bus interface names connectible to the selected bus interface.\n     */\n    QVector<QString> getConnectableBusInterfaceNames(QSharedPointer<BusInterface> currentBus,\n        QSharedPointer<QList<QSharedPointer<BusInterface> > > secondItemBusInterfaces) const;\n\n    /*!\n     *  Check if the selected bus interface can be connected to the selected mode.\n     *\n     *    @param [in] comparisonBus       The bus interface being compared to.\n     *    @param [in] comparibleModes     List of connectible bus interface modes.\n     *\n     *    @return True, if the selected bus interface can be connected to the selected mode, false otherwise.\n     */\n    bool interfacesAreCompatible(QSharedPointer<BusInterface> comparisonBus,\n        QVector<General::InterfaceMode> compatibleModes) const;\n\n    /*!\n     *  Get connectible bus interface modes for the selected interface mode.\n     *\n     *    @param [in] busMode     The selected bus interface mode.\n     *\n     *    @return List of connectible interface modes.\n     */\n    virtual QVector<General::InterfaceMode> getCompatibleInterfaceModes(General::InterfaceMode const& busMode)\n        const;\n\n    //-----------------------------------------------------------------------------\n    // Data.\n    //-----------------------------------------------------------------------------\n\n    //! Library access.\n    LibraryInterface* library_;\n};\n\n//-----------------------------------------------------------------------------\n\n#endif // BUSINTERFACETABLEAUTOCONNECTOR_H\n"
  },
  {
    "path": "editors/common/ComponentItemAutoConnector/ComponentItemAutoConnector.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: ComponentItemAutoConnector.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 23.01.2019\n//\n// Description:\n// Automatically connects the ports and bus interfaces of two component items.\n//-----------------------------------------------------------------------------\n\n#include \"ComponentItemAutoConnector.h\"\n\n#include <IPXACTmodels/Component/Component.h>\n#include <IPXACTmodels/Design/Design.h>\n\n#include <common/graphicsItems/ComponentItem.h>\n\n#include <editors/common/ComponentItemAutoConnector/AutoConnector.h>\n#include <editors/common/ComponentItemAutoConnector/AutoConnectorItem.h>\n#include <editors/common/ComponentItemAutoConnector/BusInterfaceListFiller.h>\n#include <editors/common/ComponentItemAutoConnector/BusInterfaceTableAutoConnector.h>\n#include <editors/common/ComponentItemAutoConnector/BusInterfaceItemMatcher.h>\n#include <editors/common/ComponentItemAutoConnector/PortListFiller.h>\n#include <editors/common/ComponentItemAutoConnector/PortTableAutoConnector.h>\n#include <editors/common/ComponentItemAutoConnector/PortItemMatcher.h>\n\n#include <QCoreApplication>\n#include <QMessageBox>\n#include <QDialogButtonBox>\n#include <QVBoxLayout>\n#include <QLabel>\n\n//-----------------------------------------------------------------------------\n// Function: ComponentItemAutoConnector::ComponentItemAutoConnector()\n//-----------------------------------------------------------------------------\nComponentItemAutoConnector::ComponentItemAutoConnector(AutoContainer const& firstContainer,\n    AutoContainer const& secondContainer, TableTools const& busTableTools, TableTools const& portTableTools,\n    AutoConnectorItem::ContainerType secondItemType, QSharedPointer<Design> design, QWidget* parent /*= 0*/) :\nQDialog(parent),\nfirstItemName_(firstContainer.name_),\nsecondItemName_(secondContainer.name_),\nconnectButton_(new QPushButton(QIcon(\":/icons/common/graphics/connect.png\"), \"Connect\", this)),\nautoConnectButton_(new QPushButton(QIcon(\":/icons/common/graphics/configuration.png\"), \"Auto connect all\", this)),\nclearButton_(new QPushButton(QIcon(\":/icons/common/graphics/cleanup.png\"), tr(\"Clear\"), this)),\nbusInterfaceConnector_(new AutoConnector(firstContainer, secondContainer, busTableTools, tr(\"bus interfaces\"), this)),\nportConnector_(new AutoConnector(firstContainer, secondContainer, portTableTools, tr(\"ports\"), this)),\ntabs_(this),\nsecondContainerType_(secondItemType),\ndesign_(design)\n{\n    setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);\n\n    setMinimumWidth(1200);\n    setMinimumHeight(720);\n\n    tabs_.addTab(busInterfaceConnector_, QString(tr(\"Bus interfaces\")));\n    tabs_.addTab(portConnector_, QString(tr(\"Ports\")));\n\n    setupLayout();\n\n    if (firstContainer.component_->getBusInterfaces()->isEmpty() &&\n        secondContainer.component_->getBusInterfaces()->isEmpty() &&\n        (!firstContainer.component_->getPorts()->isEmpty() || !secondContainer.component_->getPorts()->isEmpty()))\n    {\n        tabs_.setCurrentWidget(portConnector_);\n    }\n\n    connectAlreadyConnected();\n}\n\n//-----------------------------------------------------------------------------\n// Function: ComponentItemAutoConnector::~ComponentItemAutoConnector()\n//-----------------------------------------------------------------------------\nComponentItemAutoConnector::~ComponentItemAutoConnector()\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: ComponentItemAutoConnector::getConnectedItems()\n//-----------------------------------------------------------------------------\nQVector<QPair<AutoConnectorItem*, AutoConnectorItem* > > ComponentItemAutoConnector::getConnectedItems() const\n{\n    QVector<QPair<AutoConnectorItem*, AutoConnectorItem*> > fullConnections;\n\n    fullConnections += createItemPairs(busInterfaceConnector_, AutoConnectorItem::BUS_INTERFACE);\n    fullConnections += createItemPairs(portConnector_, AutoConnectorItem::PORT);\n\n    return fullConnections;\n}\n\n//-----------------------------------------------------------------------------\n// Function: ComponentItemAutoConnector::createItemPairs()\n//-----------------------------------------------------------------------------\nQVector<QPair<AutoConnectorItem*, AutoConnectorItem*> > ComponentItemAutoConnector::createItemPairs(\n    AutoConnector* connector, AutoConnectorItem::ItemType itemType) const\n{\n    QVector<QPair<AutoConnectorItem*, AutoConnectorItem*> > connectorItemPairs;\n\n    QVector<QPair<QString, QString> > connectionPairs = connector->getConnectedItems();\n    for (auto const& connection : connectionPairs)\n    {\n        AutoConnectorItem* firstItem(new AutoConnectorItem(connection.first, firstItemName_, itemType));\n        AutoConnectorItem* secondItem(\n            new AutoConnectorItem(connection.second, secondItemName_, itemType, secondContainerType_));\n\n        QPair<AutoConnectorItem*, AutoConnectorItem*> newConnection;\n        newConnection.first = firstItem;\n        newConnection.second = secondItem;\n\n        connectorItemPairs.append(newConnection);\n    }\n\n    return connectorItemPairs;\n}\n\n//-----------------------------------------------------------------------------\n// Function: ComponentItemAutoConnector::setupLayout()\n//-----------------------------------------------------------------------------\nvoid ComponentItemAutoConnector::setupLayout()\n{\n    QString introLabel = tr(\"Component instance connector\");\n    QString introText = tr(\"Connect bus interfaces or ports of two component instances.\") +\n        tr(\" Ports or bus interfaces can also be automatically connected. Automatic connections are created using the names of the items.\\n\") +\n        tr(\"Bus interfaces create interconnections and ports create ad-hoc connections.\\n\\n\") +\n        tr(\"Create connections by selecting items in their respective lists and clicking connect, or by dragging and dropping items to the table.\\n\") +\n        tr(\"Connections can be removed by right-clicking on the respective row in the table and selecting 'Remove row'.\");\n    QWidget* introWidget = setupIntroWidget(introLabel, introText);\n\n    QPushButton* okButton(new QPushButton(tr(\"Finish\"), this));\n    connect(okButton, SIGNAL(released()), this, SLOT(onFinishClicked()), Qt::UniqueConnection);\n\n    QPushButton* cancelButton (new QPushButton(tr(\"Cancel\"), this));\n    connect(cancelButton, SIGNAL(released()), this, SLOT(reject()), Qt::UniqueConnection);\n\n    QDialogButtonBox* connectionButtons(new QDialogButtonBox(Qt::Horizontal));\n    connectionButtons->addButton(connectButton_, QDialogButtonBox::ActionRole);\n    connectionButtons->addButton(autoConnectButton_, QDialogButtonBox::ActionRole);\n    connectionButtons->addButton(clearButton_, QDialogButtonBox::ActionRole);\n\n    QDialogButtonBox* buttonBox (new QDialogButtonBox(Qt::Horizontal));\n    buttonBox->addButton(okButton, QDialogButtonBox::ActionRole);\n    buttonBox->addButton(cancelButton, QDialogButtonBox::ActionRole);\n\n    setWindowTitle(\"Connect component instances\");\n\n    connect(connectButton_, SIGNAL(released()), this, SLOT(connectSelectedItems()), Qt::UniqueConnection);\n    connect(autoConnectButton_, SIGNAL(released()), this, SLOT(autoConnectItems()), Qt::UniqueConnection);\n    connect(clearButton_, SIGNAL(released()), this, SLOT(clearConnections()), Qt::UniqueConnection);\n\n    QVBoxLayout* mainLayout (new QVBoxLayout(this));\n    mainLayout->addWidget(introWidget, 0, Qt::AlignTop);\n    mainLayout->addWidget(&tabs_, 1);\n    mainLayout->addWidget(connectionButtons);\n    mainLayout->addWidget(buttonBox);\n}\n\n//-----------------------------------------------------------------------------\n// Function: ComponentItemAutoConnector::connectSelectedItems()\n//-----------------------------------------------------------------------------\nvoid ComponentItemAutoConnector::connectSelectedItems()\n{\n    if (tabs_.currentWidget() == portConnector_)\n    {\n        portConnector_->connectSelectedItems();\n    }\n    else\n    {\n        busInterfaceConnector_->connectSelectedItems();\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: ComponentItemAutoConnector::autoConnectItems()\n//-----------------------------------------------------------------------------\nvoid ComponentItemAutoConnector::autoConnectItems()\n{\n    if (tabs_.currentWidget() == portConnector_)\n    {\n        portConnector_->connectAutomatically();\n    }\n    else\n    {\n        busInterfaceConnector_->connectAutomatically();\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: ComponentItemAutoConnector::onFinishClicked()\n//-----------------------------------------------------------------------------\nvoid ComponentItemAutoConnector::onFinishClicked()\n{\n    if (portConnector_->connectionTableHasInvalidConnections() ||\n        busInterfaceConnector_->connectionTableHasInvalidConnections())\n    {\n        QMessageBox msgBox(QMessageBox::Warning, QCoreApplication::applicationName(),\n            tr(\"Bus interface and/or port connection tables contain one or more invalid or duplicate connections.\"), QMessageBox::Ok, this);\n        msgBox.exec();\n        return;\n    }\n    else\n    {\n        accept();\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: ComponentItemAutoConnector::clearConnections()\n//-----------------------------------------------------------------------------\nvoid ComponentItemAutoConnector::clearConnections()\n{\n    if (tabs_.currentWidget() == portConnector_)\n    {\n        portConnector_->clearConnectedItems();\n    }\n    else\n    {\n        busInterfaceConnector_->clearConnectedItems();\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: ComponentItemAutoConnector::setupIntroWidget()\n//-----------------------------------------------------------------------------\nQWidget* ComponentItemAutoConnector::setupIntroWidget(QString const& introName, QString const& introText) const\n{\n    QLabel* introLabel = new QLabel(introName);\n    QLabel* introTextLabel = new QLabel(introText);\n    QFont introFont = introLabel->font();\n    introFont.setBold(true);\n    introLabel->setFont(introFont);\n\n    QLabel* iconLabel = new QLabel();\n    iconLabel->setPixmap(QPixmap(QString(\":/icons/common/graphics/autoConnect.png\")));\n\n    QVBoxLayout* introTextLayout = new QVBoxLayout();\n    introTextLayout->addWidget(introLabel);\n    introTextLayout->addWidget(introTextLabel);\n\n    QHBoxLayout* mainIntroLayout = new QHBoxLayout();\n    mainIntroLayout->addLayout(introTextLayout, 1);\n    mainIntroLayout->addWidget(iconLabel);\n\n    QWidget* introWidget = new QWidget();\n    introWidget->setStyleSheet(\"background-color: white\");\n    introWidget->setLayout(mainIntroLayout);\n\n    return introWidget;\n}\n\n//-----------------------------------------------------------------------------\n// Function: ComponentItemAutoConnector::connectAlreadyConnected()\n//-----------------------------------------------------------------------------\nvoid ComponentItemAutoConnector::connectAlreadyConnected()\n{\n    portConnector_->connectAlreadyConnectedItems(design_);\n    busInterfaceConnector_->connectAlreadyConnectedItems(design_);\n}\n"
  },
  {
    "path": "editors/common/ComponentItemAutoConnector/ComponentItemAutoConnector.h",
    "content": "//-----------------------------------------------------------------------------\n// File: ComponentItemAutoConnector.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 23.01.2019\n//\n// Description:\n// Automatically connects the ports and bus interfaces of two component items.\n//-----------------------------------------------------------------------------\n\n#ifndef COMPONENTITEMAUTOCONNECTOR_H\n#define COMPONENTITEMAUTOCONNECTOR_H\n\n#include <editors/common/ComponentItemAutoConnector/AutoConnectorItem.h>\n\n#include <QDialog>\n#include <QObject>\n#include <QPushButton>\n#include <QTabWidget>\n\nclass ComponentItem;\nclass AutoConnector;\nclass Component;\nclass TableItemMatcher;\nclass TableAutoConnector;\nclass Design;\nclass ListFiller;\n\n//-----------------------------------------------------------------------------\n//! Automatically connects the ports and bus interfaces of two component items.\n//-----------------------------------------------------------------------------\nclass ComponentItemAutoConnector : public QDialog\n{\n    Q_OBJECT\n\npublic:\n\n    //! Holder for item container data.\n    struct AutoContainer\n    {\n        //! Component containing the items.\n        QSharedPointer<Component> component_;\n\n        //! Name of the container.\n        QString name_;\n\n        //! Visible name of the container.\n        QString visibleName_;\n    };\n\n    //! Holder for required auto connector tools.\n    struct TableTools \n    {\n        //! Table Item matcher.\n        QSharedPointer<TableItemMatcher> itemMatcher_;\n\n        //! Table auto connector.\n        QSharedPointer<TableAutoConnector> tableConnector_;\n\n        //! The table list filler.\n        QSharedPointer<ListFiller> listFiller_;\n    };\n\n    /*!\n     *  The constructor.\n     *\n     *    @param [in] firstContainer      Data for the first container.\n     *    @param [in] secondContainer     Data for the second container.\n     *    @param [in] busTableTools       Auto connector tools for the bus interface item connector.\n     *    @param [in] portTableTools      Auto connector tools for the port item connector.\n     *    @param [in] secondItemType      Type of the second item container.\n     *    @param [in] design              The design containing the items to connect.\n     *    @param [in] parent              The parent of this widget.\n     */\n    ComponentItemAutoConnector(AutoContainer const& firstContainer, AutoContainer const& secondContainer, \n        TableTools const& busTableTools, TableTools const& portTableTools, \n        AutoConnectorItem::ContainerType secondItemType, QSharedPointer<Design> design, QWidget* parent = 0);\n\n    /*!\n     *  Destructor.\n     */\n    ~ComponentItemAutoConnector();\n\n    /*!\n     *  Get the list of connected items.\n     *\n     *    @return A list of item pairs.\n     */\n    QVector<QPair<AutoConnectorItem*, AutoConnectorItem*> > getConnectedItems() const;\n\n    // No copying. No assignments.\n    ComponentItemAutoConnector(ComponentItemAutoConnector const& rhs) = delete;\n    ComponentItemAutoConnector& operator=(ComponentItemAutoConnector const& rhs) = delete;\n\nprivate slots:\n\n    /*!\n     *  Connect the selected items from the item lists.\n     */\n    void connectSelectedItems();\n\n    /*!\n     *  Clear the connected items from the currently selected table.\n     */\n    void clearConnections();\n\n    /*!\n     *  Connect the items of the currently selected table automatically.\n     */\n    void autoConnectItems();\n\n    void onFinishClicked();\n\nprivate:\n\n    /*!\n     *  Setup the layout.\n     */\n    void setupLayout();\n\n    /*!\n     *  Create connected item pairs from the selected connector table.\n     *\n     *    @param [in] connector   The selected connector table.\n     *    @param [in] itemType    Type for the items.\n     *\n     *    @return List of connected item pairs.\n     */\n    QVector<QPair<AutoConnectorItem*, AutoConnectorItem*> > createItemPairs(AutoConnector* connector,\n        AutoConnectorItem::ItemType itemType) const;\n\n    /*!\n     *  Create the intro widget.\n     *\n     *    @param [in] introName   Header for the intro.\n     *    @param [in] introText   Text body for the intro.\n     *\n     *    @return The intro widget.\n     */\n    QWidget* setupIntroWidget(QString const& introName, QString const& introText) const;\n\n    /*!\n     *\tPopulates the connection tables with already connected items.  \n     */\n    void connectAlreadyConnected();\n\n    //-----------------------------------------------------------------------------\n    // Data.\n    //-----------------------------------------------------------------------------\n\n    //! Name of the first component item.\n    QString firstItemName_;\n\n    //! Name of the second component item.\n    QString secondItemName_;\n\n    //! Button for connecting two items.\n    QPushButton* connectButton_;\n\n    //! Button for connecting items automatically.\n    QPushButton* autoConnectButton_;\n\n    //! Button for clearing the connected items table.\n    QPushButton* clearButton_;\n\n    //! Connection editor for bus interfaces.\n    AutoConnector* busInterfaceConnector_;\n\n    //! Connection editor for ports.\n    AutoConnector* portConnector_;\n\n    //! Holds the different editors.\n    QTabWidget tabs_;\n\n    //! Type of the second item container.\n    AutoConnectorItem::ContainerType secondContainerType_;\n\n    //! The design containing the items to connect.\n    QSharedPointer<Design> design_;\n};\n\n//-----------------------------------------------------------------------------\n\n#endif // COMPONENTITEMAUTOCONNECTOR_H\n"
  },
  {
    "path": "editors/common/ComponentItemAutoConnector/HierarchicalBusInterfaceItemMatcher.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: HierarchicalBusInterfaceItemMatcher.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 01.03.2019\n//\n// Description:\n// Automatically defines possible matches between an active and a hierarchical bus interface.\n//-----------------------------------------------------------------------------\n\n#include \"HierarchicalBusInterfaceItemMatcher.h\"\n\n#include <KactusAPI/include/BusInterfaceUtilities.h>\n\n//-----------------------------------------------------------------------------\n// Function: HierarchicalBusInterfaceItemMatcher::HierarchicalBusInterfaceItemMatcher()\n//-----------------------------------------------------------------------------\nHierarchicalBusInterfaceItemMatcher::HierarchicalBusInterfaceItemMatcher(LibraryInterface* library):\nBusInterfaceItemMatcher(library)\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: HierarchicalBusInterfaceItemMatcher::getCompatibleModes()\n//-----------------------------------------------------------------------------\nQVector<General::InterfaceMode> HierarchicalBusInterfaceItemMatcher::getCompatibleModes(\n    General::InterfaceMode busMode) const\n{\n    return General::getCompatibleInterfaceModeForHierarchicalInterface(busMode);\n}\n"
  },
  {
    "path": "editors/common/ComponentItemAutoConnector/HierarchicalBusInterfaceItemMatcher.h",
    "content": "//-----------------------------------------------------------------------------\n// File: HierarchicalBusInterfaceItemMatcher.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 01.03.2019\n//\n// Description:\n// Automatically defines possible matches between an active and a hierarchical bus interface.\n//-----------------------------------------------------------------------------\n\n#ifndef HIERARCHICALBUSINTERFACEITEMMATCHER_H\n#define HIERARCHICALBUSINTERFACEITEMMATCHER_H\n\n#include <IPXACTmodels/generaldeclarations.h>\n\n#include <editors/common/ComponentItemAutoConnector/BusInterfaceItemMatcher.h>\n\nclass LibraryInterface;\n\n//-----------------------------------------------------------------------------\n//! Automatically defines possible matches between an active and a hierarchical bus interface.\n//-----------------------------------------------------------------------------\nclass HierarchicalBusInterfaceItemMatcher : public BusInterfaceItemMatcher\n{\npublic:\n\n    /*!\n     *  The constructor.\n     *\n     *    @param [in] library     Access to the document library.\n     */\n    HierarchicalBusInterfaceItemMatcher(LibraryInterface* library);\n\n    /*!\n     *  Destructor.\n     */\n    virtual ~HierarchicalBusInterfaceItemMatcher() = default;\n\n    // No copying. No assignments.\n    HierarchicalBusInterfaceItemMatcher(HierarchicalBusInterfaceItemMatcher const& rhs) = delete;\n    HierarchicalBusInterfaceItemMatcher& operator=(HierarchicalBusInterfaceItemMatcher const& rhs) = delete;\n\nprivate:\n\n    /*!\n     *  Get connectible bus interface modes for the selected interface mode.\n     *\n     *    @param [in] busMode     The selected bus interface mode.\n     *\n     *    @return List of connectible interface modes.\n     */\n    virtual QVector<General::InterfaceMode> getCompatibleModes(General::InterfaceMode busMode) const;\n};\n\n//-----------------------------------------------------------------------------\n\n#endif // HIERARCHICALBUSINTERFACEITEMMATCHER_H\n"
  },
  {
    "path": "editors/common/ComponentItemAutoConnector/HierarchicalBusInterfaceTableAutoConnector.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: HierarchicalBusInterfaceTableAutoConnector.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 01.03.2019\n//\n// Description:\n// Automatically connects active and hierarchical bus interfaces.\n//-----------------------------------------------------------------------------\n\n#include \"HierarchicalBusInterfaceTableAutoConnector.h\"\n\n#include <IPXACTmodels/Design/Design.h>\n\n//-----------------------------------------------------------------------------\n// Function: HierarchicalBusInterfaceTableAutoConnector::HierarchicalBusInterfaceTableAutoConnector()\n//-----------------------------------------------------------------------------\nHierarchicalBusInterfaceTableAutoConnector::HierarchicalBusInterfaceTableAutoConnector(LibraryInterface* library):\nBusInterfaceTableAutoConnector(library)\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: HierarchicalBusInterfaceTableAutoConnector::getCompatibleInterfaceModes()\n//-----------------------------------------------------------------------------\nQVector<General::InterfaceMode> HierarchicalBusInterfaceTableAutoConnector::getCompatibleInterfaceModes(\n    General::InterfaceMode const& busMode) const\n{\n    return General::getCompatibleInterfaceModeForHierarchicalInterface(busMode);\n}\n\n//-----------------------------------------------------------------------------\n// Function: HierarchicalBusInterfaceTableAutoConnector::findAlreadyConnectedItems()\n//-----------------------------------------------------------------------------\nQList<QPair<QString, QString > > HierarchicalBusInterfaceTableAutoConnector::findAlreadyConnectedItems(QString const& firstInstanceName, QString const& secondInstanceName, QSharedPointer<Design> design) const\n{\n    QList<QPair<QString, QString > > foundConnections;\n\n    for (auto const& interconnection : *design->getInterconnections())\n    {\n        auto startInterface = interconnection->getStartInterface();\n\n        if (startInterface->getComponentReference() == firstInstanceName)\n        {\n            for (auto const& hierInterface : *interconnection->getHierInterfaces())\n            {\n                foundConnections.emplace_back(startInterface->getBusReference(), hierInterface->getBusReference());\n            }\n        }\n    }\n\n    return foundConnections;\n}\n"
  },
  {
    "path": "editors/common/ComponentItemAutoConnector/HierarchicalBusInterfaceTableAutoConnector.h",
    "content": "//-----------------------------------------------------------------------------\n// File: HierarchicalBusInterfaceTableAutoConnector.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 01.03.2019\n//\n// Description:\n// Automatically connects active and hierarchical bus interfaces.\n//-----------------------------------------------------------------------------\n\n#ifndef HIERARCHICALBUSINTERFACETABLEAUTOCONNECTOR_H\n#define HIERARCHICALBUSINTERFACETABLEAUTOCONNECTOR_H\n\n#include <editors/common/ComponentItemAutoConnector/BusInterfaceTableAutoConnector.h>\n\nclass LibraryInterface;\n\n//-----------------------------------------------------------------------------\n//! Automatically connects active and hierarchical bus interfaces.\n//-----------------------------------------------------------------------------\nclass HierarchicalBusInterfaceTableAutoConnector : public BusInterfaceTableAutoConnector\n{\npublic:\n\n    /*!\n     *  The constructor.\n     *\n     *    @param [in] library     Access to the document library.\n     */\n    HierarchicalBusInterfaceTableAutoConnector(LibraryInterface* library);\n\n    /*!\n     *  Destructor.\n     */\n    virtual ~HierarchicalBusInterfaceTableAutoConnector() = default;\n\n    // No copying. No assignments.\n    HierarchicalBusInterfaceTableAutoConnector(HierarchicalBusInterfaceTableAutoConnector const& rhs) = delete;\n    HierarchicalBusInterfaceTableAutoConnector& operator=(HierarchicalBusInterfaceTableAutoConnector const& rhs) =\n        delete;\n\nprivate:\n\n    /*!\n     *  Get connectible bus interface modes for the selected interface mode.\n     *\n     *    @param [in] busMode     The selected bus interface mode.\n     *\n     *    @return List of connectible interface modes.\n     */\n    virtual QVector<General::InterfaceMode> getCompatibleInterfaceModes(General::InterfaceMode const& busMode)\n        const;\n\n    /*!\n     *\tFind items that are already connected to populate the connection table with.\n     *\n     *    @param [in] firstInstanceName   The first component.\n     *    @param [in] secondInstanceName  The second component.\n     *    @param [in] design              The containing design.\n     *\n     * \t    @return List of item connected item pairs.\n     */\n    virtual QList<QPair<QString, QString > > findAlreadyConnectedItems(\n        QString const& firstInstanceName, QString const& secondInstanceName,\n        QSharedPointer<Design> design) const override;\n};\n\n//-----------------------------------------------------------------------------\n\n#endif // HIERARCHICALBUSINTERFACETABLEAUTOCONNECTOR_H\n"
  },
  {
    "path": "editors/common/ComponentItemAutoConnector/HierarchicalPortItemMatcher.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: HierarchicalPortItemMatcher.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 01.03.2019\n//\n// Description:\n// Automatically defines possible matches between an active port and a hierarchical one.\n//-----------------------------------------------------------------------------\n\n#include \"HierarchicalPortItemMatcher.h\"\n\n#include <editors/common/PortUtilities.h>\n\n//-----------------------------------------------------------------------------\n// Function: HierarchicalPortItemMatcher::getConnectableDirections()\n//-----------------------------------------------------------------------------\nQVector<DirectionTypes::Direction> HierarchicalPortItemMatcher::getConnectableDirections(\n    DirectionTypes::Direction portDirection) const\n{\n    return PortUtilities::getConnectableHierarchicalDirections(portDirection);\n}\n"
  },
  {
    "path": "editors/common/ComponentItemAutoConnector/HierarchicalPortItemMatcher.h",
    "content": "//-----------------------------------------------------------------------------\n// File: HierarchicalPortItemMatcher.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 01.03.2019\n//\n// Description:\n// Automatically defines possible matches between an active port and a hierarchical one.\n//-----------------------------------------------------------------------------\n\n#ifndef HIERARCHICALPORTITEMMATCHER_H\n#define HIERARCHICALPORTITEMMATCHER_H\n\n#include <IPXACTmodels/common/DirectionTypes.h>\n\n#include <editors/common/ComponentItemAutoConnector/PortItemMatcher.h>\n\n//-----------------------------------------------------------------------------\n//! Automatically defines possible matches between two ports.\n//-----------------------------------------------------------------------------\nclass HierarchicalPortItemMatcher : public PortItemMatcher\n{\npublic:\n\n    /*!\n     *  The constructor.\n     */\n    HierarchicalPortItemMatcher() = default;\n\n    /*!\n     *  Destructor.\n     */\n    virtual ~HierarchicalPortItemMatcher() = default;\n\n    // No copying. No assignments.\n    HierarchicalPortItemMatcher(HierarchicalPortItemMatcher const& rhs) = delete;\n    HierarchicalPortItemMatcher& operator=(HierarchicalPortItemMatcher const& rhs) = delete;\n\nprivate:\n\n    /*!\n     *  Get connectible port directions for the selected port direction.\n     *\n     *    @param [in] portDirection   The selected port direction.\n     *\n     *    @return List of connectible port directions.\n     */\n    virtual QVector<DirectionTypes::Direction> getConnectableDirections(DirectionTypes::Direction portDirection)\n        const;\n};\n\n//-----------------------------------------------------------------------------\n\n#endif // HIERARCHICALPORTITEMMATCHER_H\n"
  },
  {
    "path": "editors/common/ComponentItemAutoConnector/HierarchicalPortTableAutoConnector.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: HierarchicalPortTableAutoConnector.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 01.03.2019\n//\n// Description:\n// Automatically connects ports of a component item and a top level component.\n//-----------------------------------------------------------------------------\n\n#include \"HierarchicalPortTableAutoConnector.h\"\n\n#include <IPXACTmodels/Design/Design.h>\n\n#include <editors/common/PortUtilities.h>\n\n//-----------------------------------------------------------------------------\n// Function: HierarchicalPortTableAutoConnector::getConnectableDirections()\n//-----------------------------------------------------------------------------\nQVector<DirectionTypes::Direction> HierarchicalPortTableAutoConnector::getConnectableDirections(\n    DirectionTypes::Direction portDirection) const\n{\n    return PortUtilities::getConnectableHierarchicalDirections(portDirection);\n}\n\n//-----------------------------------------------------------------------------\n// Function: HierarchicalPortTableAutoConnector::findAlreadyConnectedItems()\n//-----------------------------------------------------------------------------\nQList<QPair<QString, QString > > HierarchicalPortTableAutoConnector::findAlreadyConnectedItems(\n    QString const& firstInstanceName, QString const& secondInstanceName, QSharedPointer<Design> design) const\n{\n    QList<QPair<QString, QString > > foundConnections;\n\n    // Find connections connecting both instances.\n    for (auto const& adHocConnection : *design->getAdHocConnections())\n    {\n        bool firstComponentInstanceFound = false;\n\n        QSet<QString> firstInstancePorts;\n        QSet<QString> secondInstancePorts;\n\n        for (auto const& portReference : *adHocConnection->getInternalPortReferences())\n        {\n            if (portReference->getComponentRef() == firstInstanceName)\n            {\n                firstComponentInstanceFound = true;\n                firstInstancePorts.insert(portReference->getPortRef());\n            }\n        }\n\n        if (firstComponentInstanceFound)\n        {\n            for (auto const& firstPort : firstInstancePorts)\n            {\n                // All external ports must be connected\n                for (auto const& secondPort : *adHocConnection->getExternalPortReferences())\n                {\n                    foundConnections.emplace_back(firstPort, secondPort->getPortRef());\n                }\n            }\n        }\n    }\n\n    return foundConnections;\n}\n"
  },
  {
    "path": "editors/common/ComponentItemAutoConnector/HierarchicalPortTableAutoConnector.h",
    "content": "//-----------------------------------------------------------------------------\n// File: HierarchicalPortTableAutoConnector.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 01.03.2019\n//\n// Description:\n// Automatically connects ports of a component item and a top level component.\n//-----------------------------------------------------------------------------\n\n#ifndef HIERARCHICALPORTTABLEAUTOCONNECTOR_H\n#define HIERARCHICALPORTTABLEAUTOCONNECTOR_H\n\n#include <IPXACTmodels/common/DirectionTypes.h>\n\n#include <editors/common/ComponentItemAutoConnector/PortTableAutoConnector.h>\n\nclass Design;\n\n//-----------------------------------------------------------------------------\n//! Automatically connects ports of two components.\n//-----------------------------------------------------------------------------\nclass HierarchicalPortTableAutoConnector : public PortTableAutoConnector\n{\npublic:\n\n    /*!\n     *  The constructor.\n     */\n    HierarchicalPortTableAutoConnector() = default;\n\n    /*!\n     *  Destructor.\n     */\n    virtual ~HierarchicalPortTableAutoConnector() = default;\n\n    // No copying. No assignments.\n    HierarchicalPortTableAutoConnector(HierarchicalPortTableAutoConnector const& rhs) = delete;\n    HierarchicalPortTableAutoConnector& operator=(HierarchicalPortTableAutoConnector const& rhs) = delete;\n\nprivate:\n\n    /*!\n     *  Get connectible port directions for the selected port direction.\n     *\n     *    @param [in] portDirection   The selected port direction.\n     *\n     *    @return List of connectible port directions.\n     */\n    virtual QVector<DirectionTypes::Direction> getConnectableDirections(DirectionTypes::Direction portDirection)\n        const;\n\n    /*!\n     *\tFind items that are already connected to populate the connection table with.\n     *\n     *    @param [in] firstInstanceName   The first component.\n     *    @param [in] secondInstanceName  The second component.\n     *    @param [in] design              The containing design.\n     *\n     * \t    @return List of item connected item pairs.\n     */\n    virtual QList<QPair<QString, QString > > findAlreadyConnectedItems(\n        QString const& firstInstanceName, QString const& secondInstanceName,\n        QSharedPointer<Design> design) const override;\n};\n\n//-----------------------------------------------------------------------------\n\n#endif // HIERARCHICALPORTTABLEAUTOCONNECTOR_H\n"
  },
  {
    "path": "editors/common/ComponentItemAutoConnector/ListFiller.h",
    "content": "//-----------------------------------------------------------------------------\n// File: ListFiller.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 12.02.2019\n//\n// Description:\n// Fills a list with desired items.\n//-----------------------------------------------------------------------------\n\n#ifndef LISTFILLER_H\n#define LISTFILLER_H\n\n#include <QStandardItemModel>\n\nclass Component;\n\n//-----------------------------------------------------------------------------\n//! Fills a list with desired items.\n//-----------------------------------------------------------------------------\nclass ListFiller\n{\npublic:\n\n    /*!\n     *  The constructor.\n     *\n     *    @param [in] firstItem   The first component item to be connected.\n     *    @param [in] secondItem  The second component item to be connected.\n     *    @param [in] parent      The parent of this widget.\n     */\n    ListFiller() = default;\n\n    /*!\n     *  Destructor.\n     */\n    virtual ~ListFiller() = default;\n\n    /*!\n     *  Populate the selected model with items from the selected component.\n     *\n     *    @param [in] selectedList            The selected item model.\n     *    @param [in] containingComponent     The selected component.\n     */\n    virtual void initializeList(QStandardItemModel* selectedList, QSharedPointer<Component> containingComponent)\n        const = 0;\n\n    // No copying. No assignments.\n    ListFiller(ListFiller const& rhs) = delete;\n    ListFiller& operator=(ListFiller const& rhs) = delete;\n};\n\n//-----------------------------------------------------------------------------\n\n#endif // AUTOCONNECTORLISTFILLER_H\n"
  },
  {
    "path": "editors/common/ComponentItemAutoConnector/PortItemMatcher.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: PortItemMatcher.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 25.02.2019\n//\n// Description:\n// Automatically defines possible matches between two ports.\n//-----------------------------------------------------------------------------\n\n#include \"PortItemMatcher.h\"\n\n#include <editors/common/PortUtilities.h>\n\n#include <IPXACTmodels/Component/Component.h>\n#include <IPXACTmodels/Component/Port.h>\n\n//-----------------------------------------------------------------------------\n// Function: PortItemMatcher::itemsCanBeConnected()\n//-----------------------------------------------------------------------------\nbool PortItemMatcher::itemsCanBeConnected(QString const& firstItem, QSharedPointer<Component> firstComponent,\n    QString const& secondItem, QSharedPointer<Component> secondComponent) const\n{\n    QSharedPointer<Port> firstPort = firstComponent->getPort(firstItem);\n    QSharedPointer<Port> secondPort = secondComponent->getPort(secondItem);\n    if (firstPort && secondPort)\n    {\n        QVector<DirectionTypes::Direction> connectableDirections =\n            getConnectableDirections(firstPort->getDirection());\n\n        return connectableDirections.contains(secondPort->getDirection());\n    }\n\n    return false;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortItemMatcher::getConnectableDirections()\n//-----------------------------------------------------------------------------\nQVector<DirectionTypes::Direction> PortItemMatcher::getConnectableDirections(\n    DirectionTypes::Direction portDirection) const\n{\n    return PortUtilities::getConnectableDirections(portDirection);\n}\n"
  },
  {
    "path": "editors/common/ComponentItemAutoConnector/PortItemMatcher.h",
    "content": "//-----------------------------------------------------------------------------\n// File: PortItemMatcher.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 25.02.2019\n//\n// Description:\n// Automatically defines possible matches between two ports.\n//-----------------------------------------------------------------------------\n\n#ifndef PORTITEMMATCHER_H\n#define PORTITEMMATCHER_H\n\n#include <editors/common/ComponentItemAutoConnector/TableItemMatcher.h>\n\n#include <IPXACTmodels/common/DirectionTypes.h>\n\n#include <QSharedPointer>\n\nclass Component;\n\n//-----------------------------------------------------------------------------\n//! Automatically defines possible matches between two ports.\n//-----------------------------------------------------------------------------\nclass PortItemMatcher : public TableItemMatcher\n{\npublic:\n\n    /*!\n     *  The constructor.\n     */\n    PortItemMatcher() = default;\n\n    /*!\n     *  Destructor.\n     */\n    virtual ~PortItemMatcher() = default;\n\n    // No copying. No assignments.\n    PortItemMatcher(PortItemMatcher const& rhs) = delete;\n    PortItemMatcher& operator=(PortItemMatcher const& rhs) = delete;\n\nprivate:\n\n    /*!\n     *  Check if the selected items can be connected.\n     *\n     *    @param [in] firstItem           The selected item from the first component.\n     *    @param [in] firstComponent      Component containing the first item.\n     *    @param [in] secondItem          The selected item from the second component.\n     *    @param [in] secondComponent     Component containing the second item.\n     *\n     *    @return True, if the items can be connected, false otherwise.\n     */\n    virtual bool itemsCanBeConnected(QString const& firstItem, QSharedPointer<Component> firstComponent,\n        QString const& secondItem, QSharedPointer<Component> secondComponent) const;\n\n    /*!\n     *  Get connectible port directions for the selected port direction.\n     *\n     *    @param [in] portDirection   The selected port direction.\n     *\n     *    @return List of connectible port directions.\n     */\n    virtual QVector<DirectionTypes::Direction> getConnectableDirections(DirectionTypes::Direction portDirection)\n        const;\n};\n\n//-----------------------------------------------------------------------------\n\n#endif // PORTITEMMATCHER_H\n"
  },
  {
    "path": "editors/common/ComponentItemAutoConnector/PortListFiller.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: PortListFiller.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 12.02.2019\n//\n// Description:\n// Fills a list with ports.\n//-----------------------------------------------------------------------------\n\n#include \"PortListFiller.h\"\n\n#include <editors/common/PortUtilities.h>\n\n#include <IPXACTmodels/Component/Component.h>\n#include <IPXACTmodels/Component/Port.h>\n\n//-----------------------------------------------------------------------------\n// Function: PortListFiller::initializeList()\n//-----------------------------------------------------------------------------\nvoid PortListFiller::initializeList(QStandardItemModel* selectedList,\n    QSharedPointer<Component> containingComponent) const\n{\n    for (auto port : *containingComponent->getPorts())\n    {\n        QString iconPath = PortUtilities::getDirectionIconPath(port->getDirection());\n\n        QStandardItem* portItem = new QStandardItem(QIcon(iconPath), port->name());\n        portItem->setEditable(false);\n\n        selectedList->appendRow(portItem);\n    }\n}\n"
  },
  {
    "path": "editors/common/ComponentItemAutoConnector/PortListFiller.h",
    "content": "//-----------------------------------------------------------------------------\n// File: PortListFiller.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 12.02.2019\n//\n// Description:\n// Fills a list with ports.\n//-----------------------------------------------------------------------------\n\n#ifndef PORTLISTFILLER_H\n#define PORTLISTFILLER_H\n\n#include <IPXACTmodels/common/DirectionTypes.h>\n\n#include <editors/common/ComponentItemAutoConnector/ListFiller.h>\n\nclass Component;\n\n//-----------------------------------------------------------------------------\n//! Fills a list with ports.\n//-----------------------------------------------------------------------------\nclass PortListFiller : public ListFiller\n{\npublic:\n\n    /*!\n     *  The constructor.\n     */\n    PortListFiller() = default;\n\n    /*!\n     *  Destructor.\n     */\n    ~PortListFiller() = default;\n\n    /*!\n     *  Populate the selected model with ports from the selected component.\n     *\n     *    @param [in] selectedList            The selected item model.\n     *    @param [in] containingComponent     The selected component.\n     */\n    virtual void initializeList(QStandardItemModel* selectedList, QSharedPointer<Component> containingComponent)\n        const;\n\n    // No copying. No assignments.\n    PortListFiller(PortListFiller const& rhs) = delete;\n    PortListFiller& operator=(PortListFiller const& rhs) = delete;\n};\n\n//-----------------------------------------------------------------------------\n\n#endif // AUTOCONNECTORLISTFILLER_H\n"
  },
  {
    "path": "editors/common/ComponentItemAutoConnector/PortTableAutoConnector.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: PortTableAutoConnector.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 12.02.2019\n//\n// Description:\n// Automatically connects ports of two components.\n//-----------------------------------------------------------------------------\n\n#include \"PortTableAutoConnector.h\"\n\n#include <editors/common/PortUtilities.h>\n\n#include <IPXACTmodels/Component/Component.h>\n#include <IPXACTmodels/Component/Port.h>\n#include <IPXACTmodels/Design/Design.h>\n\n//-----------------------------------------------------------------------------\n// Function: PortTableAutoConnector::findPossibleCombinations()\n//-----------------------------------------------------------------------------\nQVector<QPair<QString, QVector<QString> > > PortTableAutoConnector::findPossibleCombinations(\n    QSharedPointer<Component> firstComponent, QSharedPointer<Component> secondComponent) const\n{\n    QVector<QPair<QString, QVector<QString> > > possibleCombinations;\n\n    QSharedPointer<QList<QSharedPointer<Port> > > firstPorts = firstComponent->getPorts();\n    QSharedPointer<QList<QSharedPointer<Port> > > secondPorts = secondComponent->getPorts();\n\n    for (auto currentPort : *firstPorts)\n    {\n        QVector<QString> connectablePorts = getConnectablePortNames(currentPort->getDirection(), secondPorts);\n        if (!connectablePorts.isEmpty())\n        {\n            QPair<QString, QVector<QString> > combination;\n            combination.first = currentPort->name();\n            combination.second = connectablePorts;\n\n            possibleCombinations.append(combination);\n        }\n    }\n\n    return possibleCombinations;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortTableAutoConnector::getConnectablePorts()\n//-----------------------------------------------------------------------------\nQVector<QString> PortTableAutoConnector::getConnectablePortNames(DirectionTypes::Direction portDirection,\n    QSharedPointer<QList<QSharedPointer<Port>>> secondItemPorts) const\n{\n    QVector<QString> connectablePorts;\n\n    QVector<DirectionTypes::Direction> connectableDirections = getConnectableDirections(portDirection);\n    if (!connectableDirections.isEmpty())\n    {\n        for (auto comparisonPort : *secondItemPorts)\n        {\n            if (connectableDirections.contains(comparisonPort->getDirection()))\n            {\n                connectablePorts.append(comparisonPort->name());\n            }\n        }\n    }\n\n    return connectablePorts;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortTableAutoConnector::getConnectableDirections()\n//-----------------------------------------------------------------------------\nQVector<DirectionTypes::Direction> PortTableAutoConnector::getConnectableDirections(\n    DirectionTypes::Direction portDirection) const\n{\n    return PortUtilities::getConnectableDirections(portDirection);\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortTableAutoConnector::findAlreadyConnectedItems()\n//-----------------------------------------------------------------------------\nQList<QPair<QString, QString > > PortTableAutoConnector::findAlreadyConnectedItems(QString const& firstInstanceName, QString const& secondInstanceName, QSharedPointer<Design> design) const\n{\n    QList<QPair<QString, QString > > foundConnections;\n\n    // Find connections connecting both instances.\n    for (auto const& adHocConnection : *design->getAdHocConnections())\n    {\n        bool firstComponentInstanceFound = false;\n        bool secondComponentInstanceFound = false;\n        \n        QSet<QString> firstInstancePorts;\n        QSet<QString> secondInstancePorts;\n\n        for (auto const& portReference : *adHocConnection->getInternalPortReferences())\n        {\n            if (portReference->getComponentRef() == firstInstanceName)\n            {\n                firstComponentInstanceFound = true;\n                firstInstancePorts.insert(portReference->getPortRef());\n            }\n            else if (portReference->getComponentRef() == secondInstanceName)\n            {\n                secondComponentInstanceFound = true;\n                secondInstancePorts.insert(portReference->getPortRef());\n            }\n        }\n\n        if (firstComponentInstanceFound && secondComponentInstanceFound)\n        {\n            for (auto const& firstPort : firstInstancePorts)\n            {\n                for (auto const& secondPort : secondInstancePorts)\n                {\n                    foundConnections.emplace_back(firstPort, secondPort);\n                }\n            }\n        }\n    }\n\n    return foundConnections;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortTableAutoConnector::createTableWidgetItem()\n//-----------------------------------------------------------------------------\nQTableWidgetItem* PortTableAutoConnector::createTableWidgetItem(QString const& itemName,\n    QSharedPointer<Component> containingComponent) const\n{\n    QTableWidgetItem* newTableItem = TableAutoConnector::createTableWidgetItem(itemName, containingComponent);\n\n    QSharedPointer<Port> itemPort = containingComponent->getPort(itemName);\n    QIcon portItemIcon(PortUtilities::getDirectionIconPath(itemPort->getDirection()));\n\n    newTableItem->setIcon(portItemIcon);\n    return newTableItem;\n}\n"
  },
  {
    "path": "editors/common/ComponentItemAutoConnector/PortTableAutoConnector.h",
    "content": "//-----------------------------------------------------------------------------\n// File: PortTableAutoConnector.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 12.02.2019\n//\n// Description:\n// Automatically connects ports of two components.\n//-----------------------------------------------------------------------------\n\n#ifndef PORTTABLEAUTOCONNECTOR_H\n#define PORTTABLEAUTOCONNECTOR_H\n\n#include <IPXACTmodels/common/DirectionTypes.h>\n\n#include <editors/common/ComponentItemAutoConnector/TableAutoConnector.h>\n\nclass Component;\nclass Port;\n\n//-----------------------------------------------------------------------------\n//! Automatically connects ports of two components.\n//-----------------------------------------------------------------------------\nclass PortTableAutoConnector : public TableAutoConnector\n{\npublic:\n\n    /*!\n     *  The constructor.\n     */\n    PortTableAutoConnector() = default;\n\n    /*!\n     *  Destructor.\n     */\n    virtual ~PortTableAutoConnector() = default;\n\n    // No copying. No assignments.\n    PortTableAutoConnector(PortTableAutoConnector const& rhs) = delete;\n    PortTableAutoConnector& operator=(PortTableAutoConnector const& rhs) = delete;\n\nprotected:\n\n    /*!\n     *  Create a table item.\n     *\n     *    @param [in] itemName                Name for the table item.\n     *    @param [in] containingComponent     Component containing the selected item.\n     *\n     *    @return The new table item.\n     */\n    virtual QTableWidgetItem* createTableWidgetItem(QString const& itemName,\n        QSharedPointer<Component> containingComponent) const;\n\nprivate:\n\n    /*!\n     *  Find the possible item connections from the selected components.\n     *\n     *    @param [in] firstComponent      The first component.\n     *    @param [in] secondComponent     The second component.\n     *\n     *    @return List of item / possible connected items pairs.\n     */\n    virtual QVector<QPair<QString, QVector<QString> > > findPossibleCombinations(\n        QSharedPointer<Component> firstComponent, QSharedPointer<Component> secondComponent) const;\n\n    /*!\n     *  Find the names of the ports possible to be connected to the selected port.\n     *\n     *    @param [in] protDirection       Direction of the selected port.\n     *    @param [in] secondItemPorts     List of the ports contained within the second component.\n     *\n     *    @return List of connectible port names.\n     */\n    QVector<QString> getConnectablePortNames(DirectionTypes::Direction portDirection,\n        QSharedPointer<QList<QSharedPointer<Port> > > secondItemPorts) const;\n\n    /*!\n     *  Get connectible port directions for the selected port direction.\n     *\n     *    @param [in] portDirection   The selected port direction.\n     *\n     *    @return List of connectible port directions.\n     */\n    virtual QVector<DirectionTypes::Direction> getConnectableDirections(DirectionTypes::Direction portDirection)\n        const;\n\n    /*!\n     *\tFind items that are already connected to populate the connection table with.\n     *\n     *    @param [in] firstInstanceName   The first component.\n     *    @param [in] secondInstanceName  The second component.\n     *    @param [in] design              The containing design.\n     *\n     * \t    @return List of item connected item pairs.\n     */\n    virtual QList<QPair<QString, QString > > findAlreadyConnectedItems(\n        QString const& firstInstanceName, QString const& secondInstanceName,\n        QSharedPointer<Design> design) const override;\n};\n\n//-----------------------------------------------------------------------------\n\n#endif // PORTTABLEAUTOCONNECTOR_H\n"
  },
  {
    "path": "editors/common/ComponentItemAutoConnector/TableAutoConnector.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: TableAutoConnector.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 12.02.2019\n//\n// Description:\n// Automatically connects items of two components.\n//-----------------------------------------------------------------------------\n\n#include \"TableAutoConnector.h\"\n#include \"TableItemMatcher.h\"\n\n#include <IPXACTmodels/Component/Component.h>\n\n#include <editors/ComponentEditor/busInterfaces/portmaps/JaroWinklerAlgorithm.h>\n\n//-----------------------------------------------------------------------------\n// Function: TableAutoConnector::initializeTable()\n//-----------------------------------------------------------------------------\nvoid TableAutoConnector::autoConnectItems(QTableWidget* selectedTable, QSharedPointer<Component> firstComponent,\n    QSharedPointer<Component> secondComponent) const\n{\n    int currentRowCount = selectedTable->rowCount();\n\n    QVector<QPair<QString, QString> > combinations =\n        removeExistingCombinations(getCombinations(firstComponent, secondComponent), selectedTable);\n\n    selectedTable->setRowCount(currentRowCount + combinations.size());\n\n    for (int i = 0; i < combinations.size(); ++i)\n    {\n        QTableWidgetItem* firstItem = createTableWidgetItem(combinations.at(i).first, firstComponent);\n        QTableWidgetItem* secondItem = createTableWidgetItem(combinations.at(i).second, secondComponent);\n\n        selectedTable->setItem(currentRowCount + i, 0, firstItem);\n        selectedTable->setItem(currentRowCount + i, 1, secondItem);\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: TableAutoConnector::getCombinations()\n//-----------------------------------------------------------------------------\nQVector<QPair<QString, QString> > TableAutoConnector::getCombinations(QSharedPointer<Component> firstComponent,\n    QSharedPointer<Component> secondComponent) const\n{\n    QVector<QPair<QString, QString> > combinations;\n\n    QVector<QPair<QString, QVector<QString> > > possibleCombinations =\n        findPossibleCombinations(firstComponent, secondComponent);\n    if (!possibleCombinations.isEmpty())\n    {\n        const double JAROWINKLERTRESHOLD = 0.75;\n\n        for (int i = 0; i < possibleCombinations.size(); ++i)\n        {\n            QString itemToBeConnected = possibleCombinations.at(i).first;\n\n            QMultiMap<double, QString> possibleConnecedItems;\n            for (auto comparisonItem : possibleCombinations.at(i).second)\n            {\n                double jaroDistance =\n                    JaroWinklerAlgorithm::calculateJaroWinklerDistance(itemToBeConnected, comparisonItem);\n                if (jaroDistance >= JAROWINKLERTRESHOLD)\n                {\n                    possibleConnecedItems.insert(jaroDistance, comparisonItem);\n                }\n            }\n\n            if (!possibleConnecedItems.isEmpty())\n            {\n                QPair<QString, QString> portCombination;\n                portCombination.first = itemToBeConnected;\n                portCombination.second = possibleConnecedItems.last();\n\n                combinations.append(portCombination);\n            }\n        }\n    }\n\n    return combinations;\n}\n\n//-----------------------------------------------------------------------------\n// Function: TableAutoConnector::removeExistingCombinations()\n//-----------------------------------------------------------------------------\nQVector<QPair<QString, QString> > TableAutoConnector::removeExistingCombinations(\n    QVector<QPair<QString, QString> > const& combinations, QTableWidget* targetTable) const\n{\n    QVector<QPair<QString, QString> >  existingCombinations;\n\n    for (int i = 0; i < targetTable->rowCount(); ++i)\n    {\n        QPair<QString, QString> singleCombination;\n        singleCombination.first = getTextFromTableItem(i, 0, targetTable);\n        singleCombination.second = getTextFromTableItem(i, 1, targetTable);\n\n        existingCombinations.append(singleCombination);\n    }\n\n    QVector<QPair<QString, QString> > newCombinations;\n\n    for (int i = 0; i < combinations.size(); ++i)\n    {\n        QString combinationFirst = combinations.at(i).first;\n        QString combinationSecond = combinations.at(i).second;\n\n        if (!combinationExistsInTable(combinationFirst, combinationSecond, existingCombinations))\n        {\n            QPair<QString, QString> singleCombination;\n            singleCombination.first = combinationFirst;\n            singleCombination.second = combinationSecond;\n\n            newCombinations.append(singleCombination);\n        }\n    }\n\n    return newCombinations;\n}\n\n//-----------------------------------------------------------------------------\n// Function: TableAutoConnector::getTextFromTableItem()\n//-----------------------------------------------------------------------------\nQString TableAutoConnector::getTextFromTableItem(int const& itemRow, int const& itemColumn,\n    QTableWidget* targetTable) const\n{\n    QTableWidgetItem* tableItem = targetTable->item(itemRow, itemColumn);\n    if (tableItem)\n    {\n        return tableItem->text();\n    }\n    else\n    {\n        return QStringLiteral(\"\");\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: TableAutoConnector::combinationExistsInTable()\n//-----------------------------------------------------------------------------\nbool TableAutoConnector::combinationExistsInTable(QString const& combinationFirst,\n    QString const& combinationSecond, QVector<QPair<QString, QString> > const& existingCombinations) const\n{\n    for (auto const& singleCombination : existingCombinations)\n    {\n        if (singleCombination.first == combinationFirst || singleCombination.second == combinationSecond)\n        {\n            return true;\n        }\n    }\n\n    return false;\n}\n\n//-----------------------------------------------------------------------------\n// Function: TableAutoConnector::createTableWidgetItem()\n//-----------------------------------------------------------------------------\nQTableWidgetItem* TableAutoConnector::createTableWidgetItem(QString const& itemName, QSharedPointer<Component> )\n    const\n{\n    QTableWidgetItem* newItem = new QTableWidgetItem(itemName);\n    return newItem;\n}\n\n//-----------------------------------------------------------------------------\n// Function: TableAutoConnector::clearTable()\n//-----------------------------------------------------------------------------\nvoid TableAutoConnector::clearTable(QTableWidget* selectedTable) const\n{\n    selectedTable->setRowCount(0);\n}\n\n//-----------------------------------------------------------------------------\n// Function: TableAutoConnector::connectSelectedFromLists()\n//-----------------------------------------------------------------------------\nvoid TableAutoConnector::connectSelectedFromLists(QSharedPointer<Component> firstComponent, \n    QSharedPointer<Component> secondComponent, QListView* firstList, QListView* secondList,\n    QTableWidget* targetTable, QSharedPointer<TableItemMatcher> itemMatcher) const\n{\n    QModelIndex firstItemIndex = firstList->currentIndex();\n    QModelIndex secondItemIndex = secondList->currentIndex();\n\n    if (firstItemIndex.isValid() && secondItemIndex.isValid())\n    {\n        QString firstItemName = firstItemIndex.data(Qt::DisplayRole).toString();\n        QIcon firstItemIcon = firstItemIndex.data(Qt::DecorationRole).value<QIcon>();\n\n        QString secondItemName = secondItemIndex.data(Qt::DisplayRole).toString();\n        QIcon secondItemIcon = secondItemIndex.data(Qt::DecorationRole).value<QIcon>();\n\n        if (itemMatcher->itemsCanBeConnected(firstItemName, firstComponent, secondItemName, secondComponent))\n        {\n            QTableWidgetItem* firstItem = new QTableWidgetItem(firstItemIcon, firstItemName);\n            QTableWidgetItem* secondItem = new QTableWidgetItem(secondItemIcon, secondItemName);\n\n            int newRow = targetTable->rowCount();\n\n            targetTable->setRowCount(newRow + 1);\n\n            targetTable->setItem(newRow, 0, firstItem);\n            targetTable->setItem(newRow, 1, secondItem);\n        }\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: TableAutoConnector::populateTableWithConnectedItems()\n//-----------------------------------------------------------------------------\nvoid TableAutoConnector::populateTableWithConnectedItems(QTableWidget* targetTable, \n    QString const& firstInstanceName, QString const& secondInstanceName, QSharedPointer<Component> firstComponent,\n    QSharedPointer<Component> secondComponent, QSharedPointer<Design> design)\n{\n    auto connectedItems = findAlreadyConnectedItems(firstInstanceName, secondInstanceName, design);\n\n    int currentRowCount = targetTable->rowCount();\n\n    targetTable->setRowCount(targetTable->rowCount() + connectedItems.size());\n\n    for (int i = 0; i < connectedItems.size(); ++i)\n    {\n        QTableWidgetItem* firstItem = createTableWidgetItem(connectedItems.at(i).first, firstComponent);\n        QTableWidgetItem* secondItem = createTableWidgetItem(connectedItems.at(i).second, secondComponent);\n\n        targetTable->setItem(currentRowCount + i, 0, firstItem);\n        targetTable->setItem(currentRowCount + i, 1, secondItem);\n    }\n}\n"
  },
  {
    "path": "editors/common/ComponentItemAutoConnector/TableAutoConnector.h",
    "content": "//-----------------------------------------------------------------------------\n// File: TableAutoConnector.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 12.02.2019\n//\n// Description:\n// Automatically connects items of two components.\n//-----------------------------------------------------------------------------\n\n#ifndef TABLEAUTOCONNECTOR_H\n#define TABLEAUTOCONNECTOR_H\n\n#include <QTableWidget>\n#include <QListView>\n\nclass Component;\nclass Design;\nclass TableItemMatcher;\n\n//-----------------------------------------------------------------------------\n//! Automatically connects items of two components.\n//-----------------------------------------------------------------------------\nclass TableAutoConnector\n{\npublic:\n\n    /*!\n     *  The constructor.\n     */\n    TableAutoConnector() = default;\n\n    /*!\n     *  Destructor.\n     */\n    virtual ~TableAutoConnector() = default;\n\n    /*!\n     *  Connect the items from the selected components.\n     *\n     *    @param [in] selectedTable       The selected connection table.\n     *    @param [in] firstComponent      First component.\n     *    @param [in] secondComponent     Second component.\n     */\n    void autoConnectItems(QTableWidget* selectedTable, QSharedPointer<Component> firstComponent,\n        QSharedPointer<Component> secondComponent) const;\n\n    /*!\n     *  Remove the items from the selected table.\n     */\n    void clearTable(QTableWidget* selectedTable) const;\n\n    /*!\n     *  Connect the current items from the selected item lists.\n     *\n     *    @param [in] firstComponent  First component to connect.\n     *    @param [in] secondComponent Second component to connect.\n     *    @param [in] firstList       View of the first item list.\n     *    @param [in] secondList      View of the second item list.\n     *    @param [in] targetTable     The connection table.\n     *    @param [in] itemMatcher     The table item matcher to use. Validates that a connection can be made.\n     */\n    void connectSelectedFromLists(QSharedPointer<Component> firstComponent, \n        QSharedPointer<Component> secondComponent, QListView* firstList, QListView* secondList, \n        QTableWidget* targetTable, QSharedPointer<TableItemMatcher> itemMatcher) const;\n\n    /*!\n     *\tPopulate the connection table with already connected items.\n     *  \n     *    @param [in] targetTable         The target table.\n     *    @param [in] firstInstanceName   The name of the first component.\n     *    @param [in] secondInstanceName  The name of the second component.\n     *    @param [in] firstComponent      The first component to connect.\n     *    @param [in] secondComponent     The second component to connect.\n     *    @param [in] design              The containing desing.\n     */\n    void populateTableWithConnectedItems(QTableWidget* targetTable, QString const& firstInstanceName,\n        QString const& secondInstanceName, QSharedPointer<Component> firstComponent, QSharedPointer<Component> secondComponent, QSharedPointer<Design> design);\n\n    // No copying. No assignments.\n    TableAutoConnector(TableAutoConnector const& rhs) = delete;\n    TableAutoConnector& operator=(TableAutoConnector const& rhs) = delete;\n\nprotected:\n\n    /*!\n     *  Create a table item.\n     *\n     *    @param [in] itemName                Name for the table item.\n     *    @param [in] containingComponent     Component containing the selected item.\n     *\n     *    @return The new table item.\n     */\n    virtual QTableWidgetItem* createTableWidgetItem(QString const& itemName,\n        QSharedPointer<Component> containingComponent) const;\n\nprivate:\n\n    /*!\n     *  Get the item combinations for the selected items.\n     *\n     *    @param [in] firstComponent      The first selected item.\n     *    @param [in] secondComponent     The second selected item.\n     *\n     *    @return List of item name pairs.\n     */\n    QVector<QPair<QString, QString> > getCombinations(QSharedPointer<Component> firstComponent,\n        QSharedPointer<Component> secondComponent) const;\n\n    /*!\n     *  Find the possible item connections from the selected components.\n     *\n     *    @param [in] firstComponent      The first component.\n     *    @param [in] secondComponent     The second component.\n     *\n     *    @return List of item / possible connected items pairs.\n     */\n    virtual QVector<QPair<QString, QVector<QString> > > findPossibleCombinations(\n        QSharedPointer<Component> firstComponent, QSharedPointer<Component> secondComponent) const = 0;\n\n    /*!\n     *\tFind items that are already connected to populate the connection table with.\n     *\n     *    @param [in] firstInstanceName   The first component.\n     *    @param [in] secondInstanceName  The second component.\n     *    @param [in] design              The containing design.\n     *\n     * \t    @return List of item connected item pairs.\n     */\n    virtual QList<QPair<QString, QString > > findAlreadyConnectedItems(\n        QString const& firstInstanceName, QString const& secondInstanceName,\n        QSharedPointer<Design> design) const = 0;\n\n    /*!\n     *  Remove existing connections from the selected list of connections.\n     *\n     *    @param [in] combinations    The selected list of item connections.\n     *    @param [in] targetTable     Connection table.\n     *\n     *    @return List of new connections.\n     */\n    QVector<QPair<QString, QString> > removeExistingCombinations(\n        QVector<QPair<QString, QString> > const& combinations, QTableWidget* targetTable) const;\n\n    /*!\n     *  Get text from the selected table item.\n     *\n     *    @param [in] itemRow         Row of the item.\n     *    @param [in] itemColumn      Column of the item.\n     *    @param [in] targetTable     Table containing the item.\n     *\n     *    @return The selected item text.\n     */\n    QString getTextFromTableItem(int const& itemRow, int const& itemColumn, QTableWidget* targetTable) const;\n\n    /*!\n     *  Check if a connection exists in the connection table.\n     *\n     *    @param [in] combinationFirst        First item of the connection.\n     *    @param [in] combinationSecond       Second item of the connection\n     *    @param [in] existingCombinations    List of existing combinations.\n     *\n     *    @return True, if the connection exists in the connection table, false otherwise.\n     */\n    bool combinationExistsInTable(QString const& combinationFirst, QString const& combinationSecond,\n        QVector<QPair<QString, QString> > const& existingCombinations) const;\n\n};\n\n//-----------------------------------------------------------------------------\n\n#endif // TABLEAUTOCONNECTOR_H\n"
  },
  {
    "path": "editors/common/ComponentItemAutoConnector/TableItemMatcher.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: TableItemMatcher.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 25.02.2019\n//\n// Description:\n// Automatically defines possible matches between two items.\n//-----------------------------------------------------------------------------\n\n#include \"TableItemMatcher.h\"\n\n//-----------------------------------------------------------------------------\n// Function: TableItemMatcher::canDrop()\n//-----------------------------------------------------------------------------\nbool TableItemMatcher::canDrop(QModelIndex const& sourceIndex, QModelIndex const& targetIndex,\n    QSharedPointer<Component> sourceComponent, QSharedPointer<Component> targetComponent) const\n{\n    QString sourceItem = sourceIndex.data(Qt::DisplayRole).toString();\n    QString targetItem = targetIndex.data(Qt::DisplayRole).toString();\n\n    return targetItem.isEmpty() || itemsCanBeConnected(sourceItem, sourceComponent, targetItem, targetComponent);\n}\n"
  },
  {
    "path": "editors/common/ComponentItemAutoConnector/TableItemMatcher.h",
    "content": "//-----------------------------------------------------------------------------\n// File: TableItemMatcher.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 25.02.2019\n//\n// Description:\n// Automatically defines possible matches between two items.\n//-----------------------------------------------------------------------------\n\n#ifndef TABLEITEMMATCHER_H\n#define TABLEITEMMATCHER_H\n\n#include <QTableWidget>\n#include <QModelIndex>\n//#include <QListView>\n\n#include <QSharedPointer>\n\nclass Component;\n\n//-----------------------------------------------------------------------------\n//! Automatically defines possible matches between two items.\n//-----------------------------------------------------------------------------\nclass TableItemMatcher\n{\npublic:\n\n    /*!\n     *  The constructor.\n     */\n    TableItemMatcher() = default;\n\n    /*!\n     *  Destructor.\n     */\n    virtual ~TableItemMatcher() = default;\n\n    /*!\n     *  Check if the item of the selected source index can be connected to the item of the target index.\n     *\n     *    @param [in] sourceIndex         Index of the source item.\n     *    @param [in] targetIndex         Index of the target item.\n     *    @param [in] sourceComponent     Component containing the source item.\n     *    @param [in] targetComponent     Component containing the target item.\n     *\n     *    @return True, if the source item can be connected with the target item, false otherwise.\n     */\n    bool canDrop(QModelIndex const& sourceIndex, QModelIndex const& targetIndex,\n        QSharedPointer<Component> sourceComponent, QSharedPointer<Component> targetComponent) const;\n\n    // No copying. No assignments.\n    TableItemMatcher(TableItemMatcher const& rhs) = delete;\n    TableItemMatcher& operator=(TableItemMatcher const& rhs) = delete;\n\n    /*!\n     *  Check if the selected items can be connected.\n     *\n     *    @param [in] firstItem           The selected item from the first component.\n     *    @param [in] firstComponent      Component containing the first item.\n     *    @param [in] secondItem          The selected item from the second component.\n     *    @param [in] secondComponent     Component containing the second item.\n     *\n     *    @return True, if the items can be connected, false otherwise.\n     */\n    virtual bool itemsCanBeConnected(QString const& firstItem, QSharedPointer<Component> firstComponent,\n        QString const& secondItem, QSharedPointer<Component> secondComponent) const = 0;\n};\n\n//-----------------------------------------------------------------------------\n\n#endif // TABLEITEMMATCHER_H\n"
  },
  {
    "path": "editors/common/ConfigurationEditor/activeviewdelegate.cpp",
    "content": "/* \r\n *  \tCreated on: 26.8.2011\r\n *      Author: Antti Kamppi\r\n * \t\tfilename: activeviewdelegate.cpp\r\n *\t\tProject: Kactus2\r\n */\r\n\r\n#include \"activeviewdelegate.h\"\r\n\r\n#include <QComboBox>\r\n#include <QStringList>\r\n#include <QString>\r\n\r\nActiveViewDelegate::ActiveViewDelegate(QObject *parent):\r\nQStyledItemDelegate(parent) {\r\n\r\n}\r\n\r\nActiveViewDelegate::~ActiveViewDelegate() {\r\n}\r\n\r\nQWidget* ActiveViewDelegate::createEditor( QWidget* parent, \r\n\t\t\t\t\t\t\t\t\t\t  const QStyleOptionViewItem& option, \r\n\t\t\t\t\t\t\t\t\t\t  const QModelIndex& index ) const {\r\n\r\n\tif (index.column() == 1) {\r\n\t\tQComboBox* comboBox = new QComboBox(parent);\r\n\t\treturn comboBox;\r\n\t}\r\n\telse\r\n\t\treturn QStyledItemDelegate::createEditor(parent, option, index);\r\n}\r\n\r\nvoid ActiveViewDelegate::setEditorData( QWidget* editor, const QModelIndex& index ) const {\r\n\r\n\tif (index.column() == 1) {\r\n\t\tQComboBox* comboBox = qobject_cast<QComboBox*>(editor);\r\n\t\tQ_ASSERT(comboBox);\r\n\r\n\t\t// add the possible values for the combo box\r\n\t\tQStringList viewNames = index.model()->data(index, Qt::UserRole).toStringList();\r\n\t\tcomboBox->clear();\r\n\t\tcomboBox->addItems(viewNames);\r\n\t\t\r\n\t\t// find the index of the currently selected item and set it as current.\r\n\t\tQString current = index.model()->data(index, Qt::DisplayRole).toString();\r\n\t\tint selectedIndex = comboBox->findText(current);\r\n\t\tcomboBox->setCurrentIndex(selectedIndex);\r\n\t}\r\n\telse \r\n\t\tQStyledItemDelegate::setEditorData(editor, index);\r\n}\r\n\r\nvoid ActiveViewDelegate::setModelData( QWidget* editor, QAbstractItemModel* model, \r\n\t\t\t\t\t\t\t\t\t  const QModelIndex& index ) const {\r\n\t\t\t\t\t\t\t\t\t\t  \r\n\tif (index.column() == 1) {\r\n\t\tQComboBox* comboBox = qobject_cast<QComboBox*>(editor);\r\n\t\tQ_ASSERT(comboBox);\r\n\r\n\t\tQString text = comboBox->currentText();\r\n\t\tmodel->setData(index, text, Qt::EditRole);\r\n\t}\r\n\telse \r\n\t\tQStyledItemDelegate::setModelData(editor, model, index);\r\n}\r\n\r\n"
  },
  {
    "path": "editors/common/ConfigurationEditor/activeviewdelegate.h",
    "content": "/* \r\n *  \tCreated on: 26.8.2011\r\n *      Author: Antti Kamppi\r\n * \t\tfilename: activeviewdelegate.h\r\n *\t\tProject: Kactus2\r\n */\r\n\r\n#ifndef ACTIVEVIEWDELEGATE_H\r\n#define ACTIVEVIEWDELEGATE_H\r\n\r\n#include <QStyledItemDelegate>\r\n\r\n/*! \\brief Delegate the provides editors to edit the active view of a component instance.\r\n * \r\n */\r\nclass ActiveViewDelegate : public QStyledItemDelegate\r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\r\n\t/*! \\brief The constructor\r\n\t *\r\n\t * \\param parent Pointer to the owner of this delegate.\r\n\t *\r\n\t*/\r\n\tActiveViewDelegate(QObject *parent);\r\n\t\r\n\t//! \\brief The destructor\r\n\tvirtual ~ActiveViewDelegate();\r\n\r\n\t/*! \\brief Create a new editor for the given item\r\n\t *\r\n\t * \\param parent Owner for the editor.\r\n\t * \\param option Contains options for the editor.\r\n\t * \\param index Model index identifying the item.\r\n\t *\r\n\t * \\return Pointer to the editor to be used to edit the item.\r\n\t*/\r\n\tvirtual QWidget* createEditor(QWidget* parent, \r\n\t\tconst QStyleOptionViewItem& option, \r\n\t\tconst QModelIndex& index) const;\r\n\r\n\t/*! \\brief Set the data for the editor.\r\n\t *\r\n\t * \\param editor Pointer to the editor where the data is to be set.\r\n\t * \\param index Model index identifying the item that's data is to be set.\r\n\t *\r\n\t*/\r\n\tvirtual void setEditorData(QWidget* editor, const QModelIndex& index) const;\r\n\r\n\t/*! \\brief Save the data from the editor to the model.\r\n\t *\r\n\t * \\param editor Pointer to the editor that contains the data to store.\r\n\t * \\param model Model that contains the data structure where data is to be saved to.\r\n\t * \\param index Model index identifying the item that's data is to be saved.\r\n\t *\r\n\t*/\r\n\tvirtual void setModelData(QWidget* editor, QAbstractItemModel* model, \r\n\t\tconst QModelIndex& index) const;\r\n\r\nprivate:\r\n\t//! \\brief No copying\r\n\tActiveViewDelegate(const ActiveViewDelegate& other);\r\n\r\n\t//! \\brief No assignment\r\n\tActiveViewDelegate& operator=(const ActiveViewDelegate& other);\r\n};\r\n\r\n#endif // ACTIVEVIEWDELEGATE_H\r\n"
  },
  {
    "path": "editors/common/ConfigurationEditor/activevieweditor.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ActiveViewEditor.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 19.08.2011\r\n//\r\n// Description:\r\n// Editor to set the active views for component instances.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"activevieweditor.h\"\r\n#include \"activeviewdelegate.h\"\r\n\r\n#include <IPXACTmodels/DesignConfiguration/DesignConfiguration.h>\r\n\r\n#include <editors/common/DesignDiagram.h>\r\n#include <editors/common/DesignWidget.h>\r\n\r\n#include <QVBoxLayout>\r\n#include <QSharedPointer>\r\n#include <QHeaderView>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: activevieweditor::ActiveViewEditor()\r\n//-----------------------------------------------------------------------------\r\nActiveViewEditor::ActiveViewEditor(QWidget *parent):\r\nQGroupBox(tr(\"View Configuration\"), parent),\r\nview_(this),\r\nfilter_(this),\r\nmodel_(this)\r\n{\r\n\t// set settings for the view\r\n\tview_.horizontalHeader()->setStretchLastSection(true);\r\n\tview_.horizontalHeader()->setSectionResizeMode(QHeaderView::Interactive);\r\n\tview_.setSelectionMode(QAbstractItemView::SingleSelection);\r\n\tview_.setSelectionBehavior(QAbstractItemView::SelectItems);\r\n\tview_.setEditTriggers(QAbstractItemView::DoubleClicked | \r\n\t\tQAbstractItemView::SelectedClicked | QAbstractItemView::EditKeyPressed);\r\n\tview_.setWordWrap(true);\r\n\tview_.setSortingEnabled(true);\r\n\tview_.setItemDelegate(new ActiveViewDelegate(this));\r\n\tview_.verticalHeader()->hide();\r\n\r\n\t// set up connections between view and models\r\n\tfilter_.setSourceModel(&model_);\r\n\tview_.setModel(&filter_);\r\n\r\n\tQVBoxLayout* layout = new QVBoxLayout(this);\r\n\tlayout->addWidget(&view_, 1);\r\n\r\n\tconnect(&model_, SIGNAL(dataChanged(const QModelIndex&, const QModelIndex&)),\r\n\t\tthis, SIGNAL(contentChanged()), Qt::UniqueConnection);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: activevieweditor::~ActiveViewEditor()\r\n//-----------------------------------------------------------------------------\r\nActiveViewEditor::~ActiveViewEditor()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: activevieweditor::clear()\r\n//-----------------------------------------------------------------------------\r\nvoid ActiveViewEditor::clear()\r\n{\r\n\tmodel_.clear();\r\n\tview_.setDisabled(true);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: activevieweditor::setDesign()\r\n//-----------------------------------------------------------------------------\r\nvoid ActiveViewEditor::setDesign(DesignWidget* designWidget)\r\n{\r\n\r\n\tif (designWidget)\r\n    {\r\n\t\tQSharedPointer<DesignConfiguration> desConf = designWidget->getDiagram()->getDesignConfiguration();\r\n\r\n\t\t// if configuration is not used then view is always disabled\r\n\t\tif (!desConf)\r\n\t\t\tview_.setDisabled(true);\r\n\r\n\t\t// if configuration is used\r\n\t\telse \r\n\t\t\tview_.setDisabled(designWidget->isProtected());\r\n\r\n\t\tmodel_.setDesign(designWidget, desConf);\r\n        view_.resizeRowsToContents();\r\n\t}\r\n\telse\r\n    {\r\n\t\tclear();\r\n\t}\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: activevieweditor::setLocked()\r\n//-----------------------------------------------------------------------------\r\nvoid ActiveViewEditor::setLocked( bool locked )\r\n{\r\n\t// if configuration exists\r\n\tif (model_.hasConfiguration())\r\n    {\r\n\t\tview_.setDisabled(locked);\r\n    }\r\n\r\n\t// if no configuration exists then always disable the view\r\n\telse\r\n    {\r\n\t\tview_.setDisabled(true);\r\n    }\r\n}\r\n"
  },
  {
    "path": "editors/common/ConfigurationEditor/activevieweditor.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ActiveViewEditor.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 19.08.2011\r\n//\r\n// Description:\r\n// Editor to set the active views for component instances.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef ACTIVEVIEWEDITOR_H\r\n#define ACTIVEVIEWEDITOR_H\r\n\r\n#include \"activeviewmodel.h\"\r\n\r\n#include <QGroupBox>\r\n#include <QTableView>\r\n#include <QSortFilterProxyModel>\r\n\r\nclass DesignWidget;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Editor to set the active views for component instances.\r\n//-----------------------------------------------------------------------------\r\nclass ActiveViewEditor : public QGroupBox\r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\r\n    /*!\r\n     *  The constructor\r\n\t *\r\n\t *    @param [in] parent  Pointer to the owner of this widget.\r\n\t */\r\n\tActiveViewEditor(QWidget *parent);\r\n\r\n\t//! The destructor.\r\n\tvirtual ~ActiveViewEditor();\r\n\r\n\t/*!\r\n     *  Set the configuration to be displayed.\r\n\t *\r\n\t *    @param [in] designWidget    Pointer to the design widget used to edit the design.\r\n\t */\r\n    void setDesign(DesignWidget* designWidget);\r\n\r\n\t/*!\r\n     *  Clear the editor's contents.\r\n\t */\r\n\tvoid clear();\r\n\r\n\t/*!\r\n     *  Lock/unlock the editor so user can/can't edit the active views.\r\n\t *\r\n\t *    @param [in] locked  If true then editor is set to locked.\r\n\t */\r\n\tvoid setLocked(bool locked);\r\n\r\nsignals:\r\n\r\n\t//! Emitted when contents of the model change.\r\n\tvoid contentChanged();\r\n\r\nprivate:\r\n\t//! No copying.\r\n\tActiveViewEditor(const ActiveViewEditor& other);\r\n\r\n\t//! No assignment.\r\n\tActiveViewEditor& operator=(const ActiveViewEditor& other);\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n\t//! The view to display the instance names and active views.\r\n\tQTableView view_;\r\n\r\n\t//! The filter to do the sorting of items.\r\n\tQSortFilterProxyModel filter_;\r\n\r\n\t//! The model that contains the instanceName-viewName pairs.\r\n\tActiveViewModel model_;\r\n};\r\n\r\n#endif // ACTIVEVIEWEDITOR_H\r\n"
  },
  {
    "path": "editors/common/ConfigurationEditor/activeviewmodel.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: activeviewmodel.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 24.08.2011\r\n//\r\n// Description:\r\n// Model that contains the items to set the active views for component instances.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"activeviewmodel.h\"\r\n\r\n#include <editors/common/DesignWidget.h>\r\n#include <editors/HWDesign/HWComponentItem.h>\r\n#include <editors/SystemDesign/HWMappingItem.h>\r\n#include <editors/SystemDesign/SWComponentItem.h>\r\n#include <editors/HWDesign/HWChangeCommands.h>\r\n\r\n#include <IPXACTmodels/Component/Component.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// NameSpace ActiveViewColumns\r\n//-----------------------------------------------------------------------------\r\nnamespace ActiveViewColumns\r\n{\r\n    //! Defines the columns for the active views table.\r\n    enum Column\r\n    {\r\n        INSTANCE_NAME = 0,\r\n        ACTIVE_VIEW,\r\n        COLUMN_COUNT\r\n    };\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: activeviewmodel::ActiveViewModel()\r\n//-----------------------------------------------------------------------------\r\nActiveViewModel::ActiveViewModel(QObject *parent):\r\nQAbstractTableModel(parent),\r\ndesignWidget_(NULL),\r\ntable_(),\r\ndesConf_(),\r\ninstances_()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: activeviewmodel::~ActiveViewModel()\r\n//-----------------------------------------------------------------------------\r\nActiveViewModel::~ActiveViewModel()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: activeviewmodel::setDesign()\r\n//-----------------------------------------------------------------------------\r\nvoid ActiveViewModel::setDesign( DesignWidget* designWidget, QSharedPointer<DesignConfiguration> desConf)\r\n{\r\n\tQ_ASSERT(designWidget);\r\n\r\n\t// remove the previous instances and disconnect their signals\r\n\tclear();\r\n\r\n\tdesignWidget_ = designWidget;\r\n\r\n\teditProvider_ = designWidget->getEditProvider();\r\n\r\n\tdesConf_ = desConf;\r\n\t// if design configuration is not used.\r\n\tif (!desConf_)\r\n    {\r\n\t\treturn;\r\n\t}\r\n\r\n\tbeginResetModel();\r\n\r\n\t// Retrieve only those instances that should be shown, depending on the implementation attribute.\r\n    instances_ = designWidget->getInstances();\r\n\r\n\tfor (int i = 0; i < instances_.size(); ++i)\r\n    {\r\n\t\tauto const& instanceName = instances_.at(i)->name();\r\n\t\tauto const& activeView = desConf_->getActiveView(instanceName);\r\n\t\t// if theres a defined active view for the instance.\r\n\t\tif (activeView.isEmpty() == false)\r\n        {\r\n\t\t\ttable_.append(InstanceViewPair(instanceName, activeView));\r\n\t\t}\r\n\t\t// if no active view has been defined.\r\n\t\telse\r\n        {\r\n\t\t\ttable_.append(InstanceViewPair(instanceName));\r\n\t\t}\r\n\r\n\t\tconnect(instances_.at(i), SIGNAL(nameChanged(const QString&, const QString&)),\r\n\t\t\tthis, SLOT(renameInstance(const QString&, const QString&)), Qt::UniqueConnection);\r\n\t\tconnect(instances_.at(i), SIGNAL(destroyed(ComponentItem*)),\r\n\t\t\tthis, SLOT(removeInstance(ComponentItem*)), Qt::UniqueConnection);\r\n\t}\r\n\r\n\tendResetModel();\r\n\r\n\tconnect(designWidget, SIGNAL(componentInstantiated(ComponentItem*)),\r\n\t\tthis, SLOT(addInstance(ComponentItem*)), Qt::UniqueConnection);\r\n\tconnect(designWidget, SIGNAL(componentInstanceRemoved(ComponentItem*)),\r\n\t\tthis, SLOT(removeInstance(ComponentItem*)), Qt::UniqueConnection);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: activeviewmodel::clear()\r\n//-----------------------------------------------------------------------------\r\nvoid ActiveViewModel::clear()\r\n{\r\n\t// if previous design widget has been set then disconnect it\r\n\tif (designWidget_)\r\n    {\r\n\t\tdesignWidget_->disconnect(this);\r\n\t\tdesignWidget_ = 0;\r\n\t}\r\n\r\n\tinstances_.clear();\r\n\r\n\t// clear the pointers\r\n\tdesConf_.clear();\r\n\teditProvider_.clear();\r\n\r\n\tbeginResetModel();\r\n\ttable_.clear();\r\n\tendResetModel();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: activeviewmodel::rowCount()\r\n//-----------------------------------------------------------------------------\r\nint ActiveViewModel::rowCount(const QModelIndex& parent /*= QModelIndex()*/ ) const\r\n{\r\n\tif (parent.isValid())\r\n    {\r\n\t\treturn 0;\r\n    }\r\n\treturn table_.size();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: activeviewmodel::columnCount()\r\n//-----------------------------------------------------------------------------\r\nint ActiveViewModel::columnCount(const QModelIndex& parent /*= QModelIndex()*/ ) const\r\n{\r\n\tif (parent.isValid())\r\n    {\r\n\t\treturn 0;\r\n    }\r\n\treturn 2;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: activeviewmodel::data()\r\n//-----------------------------------------------------------------------------\r\nQVariant ActiveViewModel::data(const QModelIndex& index, int role /*= Qt::DisplayRole*/ ) const\r\n{\r\n\tif (!index.isValid() || index.row() < 0 || index.row() >= table_.size())\r\n    {\r\n\t\treturn QVariant();\r\n    }\r\n\r\n\tif (role == Qt::DisplayRole)\r\n    {\r\n        if (index.column() == ActiveViewColumns::INSTANCE_NAME)\r\n        {\r\n            return table_.at(index.row()).instanceName_;\r\n        }\r\n        else if (index.column() == ActiveViewColumns::ACTIVE_VIEW)\r\n        {\r\n            return table_.at(index.row()).viewName_;\r\n        }\r\n        else\r\n        {\r\n            return QVariant();\r\n        }\r\n\t}\r\n\telse if (role == Qt::UserRole)\r\n    {\r\n\t\t// if the possible view names are requested.\r\n        if (index.column() == ActiveViewColumns::ACTIVE_VIEW)\r\n        {\r\n\t\t\t// search the diagram component that matches the asked instance name.\t\t\t\r\n\t\t\tforeach (ComponentItem* diaComp, instances_)\r\n            {\r\n\t\t\t\t// if instance name matches\r\n\t\t\t\tif (diaComp->name() == table_.at(index.row()).instanceName_)\r\n                {\r\n\t\t\t\t\treturn diaComp->componentModel()->getViewNames();\t\t\t\t\t\r\n\t\t\t\t}\r\n\t\t\t}\r\n\r\n\t\t\t// return the views the component model contains.\r\n            return QVariant();\r\n\t\t}\r\n\t\telse\r\n        {\r\n            return QVariant();\r\n        }\t\t\r\n\t}\r\n\t// is unsupported role\r\n    else\r\n    {\r\n        return QVariant();\r\n    }\t\t\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: activeviewmodel::setData()\r\n//-----------------------------------------------------------------------------\r\nbool ActiveViewModel::setData(const QModelIndex& index, const QVariant& value, int role /*= Qt::EditRole*/ )\r\n{\r\n\tif (!index.isValid())\r\n    {\r\n\t\treturn false;\r\n    }\r\n\telse if (index.row() < 0 || index.row() >= table_.size())\r\n    {\r\n\t\treturn false;\r\n    }\r\n\r\n    QVariant oldValue = data(index);\r\n\r\n    if (role == Qt::EditRole && index.column() == ActiveViewColumns::ACTIVE_VIEW && oldValue != value)\r\n    {\r\n        // create a command to the undo stack\r\n        QSharedPointer<ComponentActiveViewChangeCommand> command =\r\n            QSharedPointer<ComponentActiveViewChangeCommand>(new ComponentActiveViewChangeCommand(\r\n                table_[index.row()].instanceName_, table_[index.row()].viewName_, value.toString(), this));\r\n        editProvider_->addCommand(command);\r\n\r\n        // make the change\r\n        table_[index.row()].viewName_ = value.toString();\r\n\r\n        // save the new active view to the design configuration\r\n        changeViewConfiguration(table_.at(index.row()).instanceName_, table_.at(index.row()).viewName_);\r\n\r\n        emit dataChanged(index, index);\r\n        return true;\r\n\t}\r\n    else\r\n    {\r\n        return false;\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: activeviewmodel::changeViewConfiguration()\r\n//-----------------------------------------------------------------------------\r\nvoid ActiveViewModel::changeViewConfiguration(QString const& instanceName, QString const& newViewName)\r\n{\r\n    if (newViewName.isEmpty())\r\n    {\r\n        desConf_->removeViewConfiguration(instanceName);\r\n        return;\r\n    }\r\n    else\r\n    {\r\n        for(auto const& configuration : *desConf_->getViewConfigurations())\r\n        {\r\n            if (configuration->getInstanceName().compare(instanceName) == 0)\r\n            {\r\n                configuration->setViewReference(newViewName);\r\n                return;\r\n            }\r\n        }\r\n    }\r\n\r\n    QSharedPointer<ViewConfiguration> newConfiguration (new ViewConfiguration(instanceName));\r\n    newConfiguration->setViewReference(newViewName);\r\n    desConf_->getViewConfigurations()->append(newConfiguration);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: activeviewmodel::headerData()\r\n//-----------------------------------------------------------------------------\r\nQVariant ActiveViewModel::headerData(int section, Qt::Orientation orientation, int role /*= Qt::DisplayRole*/ )\r\n    const\r\n{\r\n\tif (role != Qt::DisplayRole)\r\n    {\r\n\t\treturn QVariant();\r\n    }\r\n\telse if (section < 0)\r\n    {\r\n\t\treturn QVariant();\r\n    }\r\n\telse if (orientation != Qt::Horizontal)\r\n    {\r\n\t\treturn QVariant();\r\n    }\r\n\r\n\tif (role == Qt::DisplayRole)\r\n    {\r\n        if (section == ActiveViewColumns::INSTANCE_NAME)\r\n        {\r\n            return tr(\"Instance name\");\r\n\t\t}\r\n        else if (section == ActiveViewColumns::ACTIVE_VIEW)\r\n        {\r\n            return tr(\"Active view\");\r\n        }\r\n        else\r\n        {\r\n            return QVariant();\r\n        }\r\n\t}\r\n\t// if unsupported role\r\n\telse\r\n\t\treturn QVariant();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: activeviewmodel::flags()\r\n//-----------------------------------------------------------------------------\r\nQt::ItemFlags ActiveViewModel::flags(const QModelIndex& index ) const\r\n{\r\n\tif (!index.isValid())\r\n    {\r\n\t\treturn Qt::NoItemFlags;\r\n    }\r\n\r\n\t// the instance name can not be edited.\r\n    else if (index.column() == ActiveViewColumns::INSTANCE_NAME)\r\n    {\r\n\t\treturn Qt::ItemIsEnabled | Qt::ItemIsSelectable;\r\n    }\r\n\r\n\t// active view can be edited.\r\n\telse\r\n    {\r\n\t\treturn Qt::ItemIsEditable | Qt::ItemIsSelectable | Qt::ItemIsEnabled;\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: activeviewmodel::renameInstance()\r\n//-----------------------------------------------------------------------------\r\nvoid ActiveViewModel::renameInstance(const QString& newName,  const QString& oldName)\r\n{\r\n\tInstanceViewPair newItem(oldName);\r\n\t\r\n\t// if instance with same name is not found\r\n\tif (!table_.contains(newItem))\r\n    {\r\n\t\treturn;\r\n    }\r\n\telse\r\n    {\r\n\t\t// find the row of the named instance\r\n\t\tint row = table_.indexOf(newItem);\r\n\t\t\r\n\t\t// remove the configuration for the old name\r\n\t\tdesConf_->removeViewConfiguration(table_[row].instanceName_);\r\n\r\n\t\t// rename the instance\r\n\t\ttable_[row].instanceName_ = newName;\r\n\r\n\t\t// save the new active view to the design configuration\r\n\t\tdesConf_->addViewConfiguration(table_.at(row).instanceName_, table_.at(row).viewName_);\r\n\r\n\t\t// inform views that data has changed\r\n\t\tQModelIndex modelIndex = QAbstractTableModel::index(row, 0, QModelIndex());\r\n\t\temit dataChanged(modelIndex, modelIndex);\r\n\t}\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: activeviewmodel::removeInstance()\r\n//-----------------------------------------------------------------------------\r\nvoid ActiveViewModel::removeInstance( ComponentItem* diaComp )\r\n{\r\n\tif (diaComp)\r\n    {\r\n\t\tInstanceViewPair itemToRemove(diaComp->name());\r\n\t\t\r\n\t\t// if item is found on the table\r\n\t\tif (table_.contains(itemToRemove))\r\n        {\r\n\t\t\tint row = table_.indexOf(itemToRemove);\r\n\t\t\t\r\n\t\t\t// remove the item from the table\r\n\t\t\tbeginRemoveRows(QModelIndex(), row, row);\r\n\t\t\ttable_.removeAt(row);\r\n\t\t\tendRemoveRows();\r\n\r\n\t\t\t// remove the configuration from the design conf\r\n\t\t\tdesConf_->removeViewConfiguration(diaComp->name());\r\n\t\t}\r\n\r\n\t\tif (instances_.contains(diaComp))\r\n        {\r\n\t\t\tinstances_.removeAll(diaComp);\r\n\t\t}\r\n\t\t\r\n\t\t// remove the connections between the diagram component and this model.\r\n\t\tdiaComp->disconnect(this);\r\n\t}\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: activeviewmodel::addInstance()\r\n//-----------------------------------------------------------------------------\r\nvoid ActiveViewModel::addInstance( ComponentItem* diaComp )\r\n{\r\n\t// if instance is already in the model\r\n\tif (instances_.contains(diaComp))\r\n    {\r\n\t\treturn;\r\n    }\r\n\r\n\t// add the pointer to the component instance\r\n\tinstances_.append(diaComp);\r\n\r\n\t// add the item to the model to be displayed\r\n\tInstanceViewPair newItem(diaComp->name());\r\n\r\n\t// if the component only has one view it can be selected as default\r\n\tQStringList viewNames = diaComp->componentModel()->getViewNames();\r\n\tif (viewNames.size() == 1)\r\n    {\r\n\t\t// set the only view as default\r\n\t\tauto viewName = viewNames.first();\r\n\t\tnewItem.viewName_ = viewName;\r\n\t\tdesConf_->addViewConfiguration(diaComp->name(), viewName);\r\n\t}\r\n\r\n\tbeginInsertRows(QModelIndex(), table_.size(), table_.size());\r\n\ttable_.append(newItem);\r\n\tendInsertRows();\r\n\r\n\tconnect(diaComp, SIGNAL(destroyed(ComponentItem*)),\r\n\t\tthis, SLOT(removeInstance(ComponentItem*)), Qt::UniqueConnection);\r\n\tconnect(diaComp, SIGNAL(nameChanged(const QString&, const QString&)),\r\n\t\tthis, SLOT(renameInstance(const QString&, const QString&)), Qt::UniqueConnection);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: activeviewmodel::setActiveView()\r\n//-----------------------------------------------------------------------------\r\nvoid ActiveViewModel::setActiveView( const QString& instanceName, const QString& viewName )\r\n{\r\n\t// search all component instances\r\n\tfor (int i = 0; i < table_.size(); ++i)\r\n    {\r\n\t\t// if instance is found\r\n\t\tif (table_.at(i).instanceName_ == instanceName)\r\n        {\r\n\t\t\t// update the view name on the screen\r\n\t\t\tbeginResetModel();\r\n\t\t\ttable_[i].viewName_ = viewName;\r\n\t\t\tendResetModel();\r\n\t\r\n\t\t\t// update the design configuration\r\n\t\t\tif (desConf_)\r\n            {\r\n                changeViewConfiguration(instanceName, viewName);\r\n\t\t\t}\r\n\t\t\treturn;\r\n\t\t}\r\n\t}\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: activeviewmodel::hasConfiguration()\r\n//-----------------------------------------------------------------------------\r\nbool ActiveViewModel::hasConfiguration() const\r\n{\r\n\t// if design configuration exists \t\t\t\r\n\treturn desConf_ != 0;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: activeviewmodel::InstanceViewPair::InstanceViewPair()\r\n//-----------------------------------------------------------------------------\r\nActiveViewModel::InstanceViewPair::InstanceViewPair(const QString& instanceName, const QString& viewName ):\r\ninstanceName_(instanceName),\r\nviewName_(viewName)\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: activeviewmodel::InstanceViewPair::operator==()\r\n//-----------------------------------------------------------------------------\r\nActiveViewModel::InstanceViewPair::InstanceViewPair(const QString& instanceName ):\r\ninstanceName_(instanceName),\r\nviewName_()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: activeviewmodel::InstanceViewPair::operator==()\r\n//-----------------------------------------------------------------------------\r\nbool ActiveViewModel::InstanceViewPair::operator==(const InstanceViewPair& other ) const\r\n{\r\n\treturn instanceName_ == other.instanceName_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: activeviewmodel::InstanceViewPair::operator!=()\r\n//-----------------------------------------------------------------------------\r\nbool ActiveViewModel::InstanceViewPair::operator!=(const InstanceViewPair& other )\r\n{\r\n\treturn instanceName_ != other.instanceName_;\r\n}\r\n"
  },
  {
    "path": "editors/common/ConfigurationEditor/activeviewmodel.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: activeviewmodel.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 24.08.2011\r\n//\r\n// Description:\r\n// Model that contains the items to set the active views for component instances.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef ACTIVEVIEWMODEL_H\r\n#define ACTIVEVIEWMODEL_H\r\n\r\n#include <IPXACTmodels/DesignConfiguration/DesignConfiguration.h>\r\n\r\n#include <editors/HWDesign/HWComponentItem.h>\r\n\r\n#include <common/IEditProvider.h>\r\n\r\n#include <QAbstractTableModel>\r\n#include <QString>\r\n#include <QList>\r\n#include <QSharedPointer>\r\n\r\nclass DesignWidget;\r\nclass HWComponentItem;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Model that contains the items to set the active views for component instances.\r\n//-----------------------------------------------------------------------------\r\nclass ActiveViewModel : public QAbstractTableModel\r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\r\n\t/*!\r\n     *  The constructor.\r\n\t *\r\n\t *    @param [in] parent  Pointer to the owner of this widget.\r\n\t */\r\n\tActiveViewModel(QObject *parent);\r\n\t\r\n\t//! The destructor.\r\n\tvirtual ~ActiveViewModel();\r\n\r\n\t/*!\r\n     *  Set the design that's active views are edited.\r\n\t *\r\n\t *    @param [in] designWidget    Pointer to the design widget that manages the design.\r\n\t *    @param [in] desConf         Pointer to the configuration to edit.\r\n\t */\r\n\tvoid setDesign(DesignWidget* designWidget, QSharedPointer<DesignConfiguration> desConf);\r\n\r\n\t/*!\r\n     *  Clear the model's contents.\r\n\t */\r\n\tvoid clear();\r\n\r\n\t/*!\r\n     *  Get the number of rows an item contains.\r\n\t *\r\n\t *    @param [in] parent  Identifies the parent that's row count is requested.\r\n\t *\r\n\t *    @return Number of rows the item has.\r\n\t */\r\n\tvirtual int rowCount(const QModelIndex& parent = QModelIndex()) const;\r\n\r\n\t/*!\r\n     *  Get the number of columns the item has to be displayed.\r\n\t *\r\n\t *      *param [in] parent  Identifies the parent that's column count is requested.\r\n\t *\r\n\t *    @return The number of columns to be displayed.\r\n\t */\r\n\tvirtual int columnCount(const QModelIndex& parent = QModelIndex()) const;\r\n\r\n\t/*!\r\n     *  Get the data for specified item.\r\n\t *\r\n\t *    @param [in] index   Specifies the item that's data is requested.\r\n\t *    @param [in] role    The role that defines what kind of data is requested.\r\n\t *\r\n\t *    @return QVariant Contains the data for the item.\r\n\t */\r\n\tvirtual QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const;\r\n\r\n\t/*!\r\n     *  Get the header data for specified header.\r\n\t *\r\n\t *    @param [in] section         The section specifies the row/column number for the header.\r\n\t *    @param [in] orientation     Specified if horizontal or vertical header is wanted.\r\n\t *    @param [in] role            Specifies the type of the requested data.\r\n\t *\r\n\t *    @return QVariant Contains the requested data.\r\n\t */\r\n\tvirtual QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;\r\n\r\n\t/*!\r\n     *  Save the data to the model for specified item\r\n\t *\r\n\t *    @param [in] index   The model index of the item that's data is to be saved.\r\n\t *    @param [in] value   The data that is to be saved.\r\n\t *    @param [in] role    The role specifies what kind of data should be saved.\r\n\t *\r\n\t *    @return True if saving happened successfully.\r\n\t */\r\n\tbool setData(const QModelIndex& index, const QVariant& value, int role = Qt::EditRole);\r\n\r\n\t/*!\r\n     *  Get the item flags that defines the possible operations for the item.\r\n\t *\r\n\t *    @param [in] index   Model index that identifies the item.\r\n\t *\r\n\t *    @return Qt::ItemFlags specify the possible operations for the item.\r\n\t */\r\n\tQt::ItemFlags flags(const QModelIndex& index) const;\r\n\r\n\t/*!\r\n     *  Checks if there is created configuration for this view.\r\n\t *\r\n\t *    @return bool True if configuration exists.\r\n\t */\r\n\tbool hasConfiguration() const;\r\n\r\npublic slots:\r\n\r\n\t/*!\r\n     *  Rename a component instance in the model.\r\n\t *\r\n\t *    @param [in] newName     The new name of the instance.\r\n\t *    @param [in] oldName     The old name of the instance.\r\n\t */\r\n\tvoid renameInstance(const QString& newName, const QString& oldName);\r\n\r\n\t/*!\r\n     *  Remove the instance from the model.\r\n\t *\r\n\t *    @param [in] diaComp     Pointer to the diagram component being removed.\r\n\t */\r\n\tvoid removeInstance(ComponentItem* diaComp);\r\n\r\n\t/*!\r\n     *  Set the active view for given component instance.\r\n\t *  NOTE: Using this function to set the active view for instance does not generate commands to the undo/redo \r\n     *  stack.\r\n\t * \r\n\t *    @param [in] instanceName    Identifies the component instance by name.\r\n\t *    @param [in] viewName        The new view name to be set for instance.\r\n\t */\r\n\tvoid setActiveView(const QString& instanceName, const QString& viewName);\r\n\r\n\t/*!\r\n     *  Add a new component instance to the model.\r\n\t *\r\n\t *    @param [in] diaComp     Pointer to the new component instance.\r\n\t */\r\n\tvoid addInstance(ComponentItem* diaComp);\r\n\r\nprivate:\r\n\r\n\t//! No copying.\r\n\tActiveViewModel(const ActiveViewModel& other);\r\n\r\n\t//! No assignment.\r\n\tActiveViewModel& operator=(const ActiveViewModel& other);\r\n\r\n\t//! The struct to contain the name-viewname pair for the configuration.\r\n\tstruct InstanceViewPair\r\n    {\r\n\t\t//! The name of the component instance.\r\n\t\tQString instanceName_;\r\n\r\n\t\t//! The name of the active view for the component instance.\r\n\t\tQString viewName_;\r\n\r\n\t\t/*!\r\n         *  The struct constructor\r\n\t\t *\r\n\t\t *    @param [in] instanceName    The name for the component instance.\r\n\t\t *    @param [in] viewName        The name of the active view.\r\n\t\t */\r\n\t\tInstanceViewPair(const QString& instanceName, const QString& viewName);\r\n\r\n\t\t/*!\r\n         *  The struct constructor\r\n\t\t *\r\n\t\t *    @param [in] instanceName    The name for the component instance.\r\n\t\t */\r\n\t\tInstanceViewPair(const QString& instanceName);\r\n\r\n\t\t/*!\r\n         *  Operator ==\r\n\t\t *\r\n\t\t *    @param [in] other   Reference to the InstanceViewPair to compare to.\r\n\t\t *\r\n\t\t *    @return bool True if the component instance names are the same.\r\n\t\t */\r\n\t\tbool operator==(const InstanceViewPair& other) const;\r\n\r\n\t\t/*!\r\n         *  Operator != \r\n\t\t *\r\n\t\t *    @param [in] other Reference to the InstanceViewPair to compare to.\r\n\t\t *\r\n\t\t *    @return bool True if the component instance names are different.\r\n\t\t */\r\n\t\tbool operator!=(const InstanceViewPair& other);\r\n\t};\r\n\r\n    /*!\r\n     *  Change the active view from the selected view configuration.\r\n     *\r\n     *    @param [in] instanceName    The name of the selected component instance.\r\n     *    @param [in] newViewName     The new active view.\r\n     */\r\n    void changeViewConfiguration(QString const& instanceName, QString const& newViewName);\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n\t//! Pointer to the design widget that manages the design.\r\n\tDesignWidget* designWidget_;\r\n\r\n\t//! List that contains the items to display.\r\n\tQList<InstanceViewPair> table_;\r\n\r\n\t//! Pointer to the design configuration being edited.\r\n\tQSharedPointer<DesignConfiguration> desConf_;\r\n\r\n\t//! Contains pointers to the component instances being displayed.\r\n\tQList<ComponentItem*> instances_;\r\n\r\n\t//! Pointer to the edit provider that manages the undo stack.\r\n\tQSharedPointer<IEditProvider> editProvider_;\r\n};\r\n\r\n#endif // ACTIVEVIEWMODEL_H\r\n"
  },
  {
    "path": "editors/common/ConfigurationEditor/configurationeditor.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: configurationeditor.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 19.08.2011\r\n//\r\n// Description:\r\n// Editor to edit the design configurations for component.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"configurationeditor.h\"\r\n\r\n#include <KactusAPI/include/VersionHelper.h>\r\n\r\n#include <common/dialogs/createConfigurationDialog/createconfigurationdialog.h>\r\n#include <common/widgets/vlnvDisplayer/vlnvdisplayer.h>\r\n\r\n#include <editors/common/DesignWidget.h>\r\n#include <editors/common/DesignDiagram.h>\r\n\r\n#include <KactusAPI/include/LibraryInterface.h>\r\n\r\n#include <common/widgets/ParameterGroupBox/parametergroupbox.h>\r\n\r\n#include <KactusAPI/include/ListParameterFinder.h>\r\n#include <KactusAPI/include/ExpressionFormatter.h>\r\n\r\n#include <IPXACTmodels/DesignConfiguration/DesignConfiguration.h>\r\n#include <IPXACTmodels/Design/Design.h>\r\n#include <IPXACTmodels/Component/Component.h>\r\n#include <IPXACTmodels/Component/View.h>\r\n#include <IPXACTmodels/Component/DesignConfigurationInstantiation.h>\r\n#include <IPXACTmodels/kactusExtensions/SystemView.h>\r\n\r\n#include <QApplication>\r\n#include <QCoreApplication>\r\n#include <QFileInfo>\r\n#include <QFormLayout>\r\n#include <QGroupBox>\r\n#include <QHBoxLayout>\r\n#include <QVBoxLayout>\r\n#include <QMessageBox>\r\n#include <QStringList>\r\n#include <QList>\r\n#include <QTabWidget>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ConfigurationEditor::ConfigurationEditor()\r\n//-----------------------------------------------------------------------------\r\nConfigurationEditor::ConfigurationEditor(LibraryInterface* handler, QWidget *parent):\r\nQWidget(parent),\r\n    library_(handler),\r\n    addNewButton_(new QPushButton(QIcon(\":icons/common/graphics/add.png\"), \"Add...\", this)),\r\n    configurationSelector_(new QComboBox(this)),\r\n    configurationDisplay_(new VLNVDisplayer(this, VLNV(), true)),    \r\n    activeViewEditor_(new ActiveViewEditor(this)),\r\n    topComponent_(nullptr),\r\n    designWidget_(nullptr)\r\n{\r\n    configurationDisplay_->setFlat(true);\r\n    configurationDisplay_->setTitle(tr(\"Design Configuration VLNV\"));\r\n    configurationDisplay_->setToolTip(tr(\"Add new Design Configuration\"));\r\n\r\n    activeViewEditor_->setFlat(true);\r\n\r\n\tsetuplayout();\r\n\tsetupConnections();\r\n\tclear();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ConfigurationEditor::setConfiguration()\r\n//-----------------------------------------------------------------------------\r\nvoid ConfigurationEditor::setConfiguration(DesignWidget* designWidget)\r\n{\r\n    if (designWidget_)\r\n    {\r\n        designWidget_->disconnect(this);\r\n    }\r\n\r\n    designWidget_ = designWidget;\r\n    topComponent_ = designWidget_->getEditedComponent();\r\n\r\n    connect(designWidget_, SIGNAL(refreshed()),\tthis, SLOT(onRefresh()), Qt::UniqueConnection);\r\n    connect(activeViewEditor_, SIGNAL(contentChanged()), \r\n        designWidget_, SIGNAL(contentChanged()), Qt::UniqueConnection);\r\n\r\n    addNewButton_->setDisabled(designWidget_->isProtected());\r\n\r\n    configurationSelector_->disconnect(this);\r\n    configurationSelector_->clear();\r\n    configurationSelector_->addItems(findPossibleViews());\r\n    configurationSelector_->setCurrentText(designWidget_->getOpenViewName());\r\n\r\n    connect(configurationSelector_, SIGNAL(currentTextChanged(QString const&)),\r\n        this, SIGNAL(configurationChanged(QString const&)), Qt::UniqueConnection);\r\n    connect(configurationSelector_, SIGNAL(currentTextChanged(QString const&)),\r\n        this, SLOT(onConfigurationChanged(QString const&)), Qt::UniqueConnection);\r\n\r\n    activeViewEditor_->setDesign(designWidget_);\r\n\r\n    bool hasConfiguration = designWidget_->getDiagram()->getDesignConfiguration().isNull() == false;\r\n\r\n    configurationDisplay_->setVisible(hasConfiguration);\r\n    if (hasConfiguration)\r\n    {\r\n        configurationDisplay_->setVLNV(designWidget_->getDiagram()->getDesignConfiguration()->getVlnv());\r\n    }\r\n\r\n    // Display this widget.\r\n    //parentWidget()->raise();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ConfigurationEditor::clear()\r\n//-----------------------------------------------------------------------------\r\nvoid ConfigurationEditor::clear()\r\n{\r\n    if (designWidget_)\r\n    {\r\n        designWidget_->disconnect(this);\r\n        designWidget_ = nullptr;\r\n    }\r\n\r\n    configurationSelector_->clear();\r\n\r\n    addNewButton_->setDisabled(true);\r\n\r\n    activeViewEditor_->clear();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ConfigurationEditor::onRefresh()\r\n//-----------------------------------------------------------------------------\r\nvoid ConfigurationEditor::onRefresh()\r\n{\r\n    setConfiguration(designWidget_);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ConfigurationEditor::setLocked()\r\n//-----------------------------------------------------------------------------\r\nvoid ConfigurationEditor::setLocked(bool locked)\r\n{\r\n    addNewButton_->setDisabled(locked);\r\n\r\n    activeViewEditor_->setLocked(locked);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ConfigurationEditor::onAdd()\r\n//-----------------------------------------------------------------------------\r\nvoid ConfigurationEditor::onAdd()\r\n{\r\n\taskSave();\r\n\t\r\n    const KactusAttribute::Implementation designImplementation = designWidget_->getImplementation();\r\n\r\n\t// Create dialog to input the settings for the new configuration.\r\n\tCreateConfigurationDialog dialog(library_, topComponent_, designImplementation, this);\r\n\tif (dialog.exec() == QDialog::Rejected)\r\n    {\r\n\t\treturn;\r\n\t}\r\n\r\n\tQApplication::setOverrideCursor(Qt::WaitCursor);\r\n\r\n    createAndSaveConfiguration(dialog);\r\n\r\n    createTopLevelReferenceToConfiguration(dialog.getConfigurationVLNV(), dialog.getConfigurationName(), \r\n        designImplementation);\r\n\r\n\tdesignWidget_->setDesign(topComponent_->getVlnv(), dialog.getConfigurationName());\r\n\tdesignWidget_->setProtection(false);\r\n\r\n\tsetConfiguration(designWidget_);\r\n\r\n    emit(designConfigurationChanged(designWidget_->getDiagram()->getDesignConfiguration()));\r\n\r\n    QApplication::restoreOverrideCursor();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ConfigurationEditor::createAndSaveConfiguration()\r\n//-----------------------------------------------------------------------------\r\nvoid ConfigurationEditor::createAndSaveConfiguration(CreateConfigurationDialog const& dialog)\r\n{\r\n    QString directoryPath = QFileInfo(library_->getPath(topComponent_->getVlnv())).absolutePath();\r\n\r\n    VLNV designVLNV = dialog.getDesignVLNV();\r\n    VLNV const& configurationVLNV = dialog.getConfigurationVLNV();\r\n\r\n    // Create the configuration.\r\n    QSharedPointer<DesignConfiguration> designConfiguration(new DesignConfiguration(configurationVLNV, topComponent_->getRevision()));\r\n    designConfiguration->setDesignConfigImplementation(KactusAttribute::HW);\r\n    designConfiguration->setVersion(VersionHelper::versionFileStr());\r\n\r\n    // Set the configuration to reference the same design.\r\n    if (dialog.designSelection() == CreateConfigurationDialog::USE_EXISTING)\r\n    {        \r\n        designConfiguration->setDesignRef(designWidget_->getDiagram()->getDesign()->getVlnv());\r\n    }\r\n\r\n    // Create a new design.\r\n    else if (dialog.designSelection() == CreateConfigurationDialog::CREATE_EMPTY)\r\n    {\r\n        QSharedPointer<Design> design = QSharedPointer<Design>(new Design(designVLNV, topComponent_->getRevision()));\r\n        library_->writeModelToFile(directoryPath, design);\r\n\r\n        designConfiguration->setDesignRef(designVLNV);\r\n    }\r\n\r\n    // Copy the design.\r\n    else // CreateConfigurationDialog::CREATE_COPY\r\n    {\r\n        QSharedPointer<Design> design = designWidget_->getDiagram()->getDesign();\r\n        design->setVlnv(designVLNV);\r\n        library_->writeModelToFile(directoryPath, design);\r\n\r\n        designConfiguration->setDesignRef(designVLNV);\r\n    }\r\n\r\n    library_->writeModelToFile(directoryPath, designConfiguration);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ConfigurationEditor::createTopLevelReferenceToConfiguration()\r\n//-----------------------------------------------------------------------------\r\nvoid ConfigurationEditor::createTopLevelReferenceToConfiguration(VLNV const& configurationVLNV, \r\n    QString const& viewName, const KactusAttribute::Implementation designImplementation)\r\n{    \r\n    // create new view for the component and set it to reference to the configuration\r\n    if (designImplementation == KactusAttribute::HW || designImplementation == KactusAttribute::SW)\r\n    {\r\n        QSharedPointer<View> view (new View(viewName));\r\n        view->setDesignConfigurationInstantiationRef(viewName);\r\n        topComponent_->getViews()->append(view);\r\n\r\n        QSharedPointer<DesignConfigurationInstantiation> instantiation(\r\n            new DesignConfigurationInstantiation(viewName));\r\n        QSharedPointer<ConfigurableVLNVReference> configurationReference(\r\n            new ConfigurableVLNVReference(configurationVLNV));\r\n        instantiation->setDesignConfigurationReference(configurationReference);\r\n        topComponent_->getDesignConfigurationInstantiations()->append(instantiation);\r\n    }\r\n    else if (designImplementation == KactusAttribute::SYSTEM)\r\n    {\r\n        QSharedPointer<SystemView> view (new SystemView(viewName));\r\n        view->setHierarchyRef(configurationVLNV);\r\n\r\n        QList<QSharedPointer<SystemView> > componentSystemViews = topComponent_->getSystemViews();\r\n        componentSystemViews.append(view);\r\n        topComponent_->setSystemViews(componentSystemViews);\r\n    }\r\n\r\n    library_->writeModelToFile(topComponent_);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ConfigurationEditor::onConfigurationChanged()\r\n//-----------------------------------------------------------------------------\r\nvoid ConfigurationEditor::onConfigurationChanged(QString const& newConfigName)\r\n{\r\n\taskSave();\r\n\r\n\tif (designWidget_)\r\n    {\r\n\t\tbool wasLocked = designWidget_->isProtected();\r\n\r\n\t\tdesignWidget_->setDesign(topComponent_->getVlnv(), newConfigName);\r\n\t\tdesignWidget_->setProtection(wasLocked);\r\n\r\n\t\tsetConfiguration(designWidget_);\r\n    \r\n        emit(designConfigurationChanged(designWidget_->getDiagram()->getDesignConfiguration()));\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ConfigurationEditor::findPossibleViews()\r\n//-----------------------------------------------------------------------------\r\nQStringList ConfigurationEditor::findPossibleViews()\r\n{\r\n    QStringList hierViewNames;\r\n\r\n    const KactusAttribute::Implementation designImplementation = designWidget_->getImplementation();\r\n    if (designImplementation == KactusAttribute::HW || designImplementation == KactusAttribute::SW)\r\n    {\r\n        hierViewNames = topComponent_->getHierViews();\r\n    }\r\n    else if (designImplementation == KactusAttribute::SYSTEM)\r\n    {\r\n        hierViewNames = topComponent_->getSystemViewNames();\r\n    } \r\n\r\n    VLNV currentDesign = designWidget_->getIdentifyingVLNV();\r\n\r\n    QStringList possibleViews;\r\n    for (QString const& viewName : hierViewNames)\r\n    {\r\n        // the vlnv that the component references\r\n        VLNV viewDesign;\r\n        if (designImplementation == KactusAttribute::HW || designImplementation == KactusAttribute::SW)\r\n        {\r\n            viewDesign = topComponent_->getHierRef(viewName);\r\n        }\r\n        else if (designImplementation ==  KactusAttribute::SYSTEM)\r\n        {\r\n            viewDesign = topComponent_->getHierSystemRef(viewName);\r\n        }\r\n\r\n        if (library_->getDesignVLNV(viewDesign) == currentDesign)\r\n        {\r\n            possibleViews.append(viewName);\r\n        }\r\n    }\r\n\r\n    return possibleViews;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ConfigurationEditor::setuplayout()\r\n//-----------------------------------------------------------------------------\r\nvoid ConfigurationEditor::setuplayout()\r\n{\r\n    QHBoxLayout* buttonLayout = new QHBoxLayout();\r\n    buttonLayout->addWidget(new QLabel(tr(\"Select configuration:\")));\r\n    buttonLayout->addWidget(configurationSelector_, 1);\r\n    buttonLayout->addWidget(addNewButton_);\r\n\r\n    QVBoxLayout* topLayout = new QVBoxLayout(this);    \r\n    topLayout->addLayout(buttonLayout);\r\n    topLayout->addWidget(configurationDisplay_);\r\n    topLayout->addWidget(activeViewEditor_);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ConfigurationEditor::setupConnections()\r\n//-----------------------------------------------------------------------------\r\nvoid ConfigurationEditor::setupConnections()\r\n{\r\n    connect(addNewButton_, SIGNAL(clicked(bool)), this, SLOT(onAdd()), Qt::UniqueConnection);\r\n\r\n    connect(configurationSelector_, SIGNAL(currentTextChanged(QString const&)),\r\n        this, SIGNAL(configurationChanged(QString const&)), Qt::UniqueConnection);\r\n    connect(configurationSelector_, SIGNAL(currentTextChanged(QString const&)),\r\n        this, SLOT(onConfigurationChanged(QString const&)), Qt::UniqueConnection);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ConfigurationEditor::askSave()\r\n//-----------------------------------------------------------------------------\r\nvoid ConfigurationEditor::askSave()\r\n{\r\n\tif (designWidget_ && designWidget_->isModified())\r\n    {\r\n\t\tQMessageBox msgBox(QMessageBox::Warning, QCoreApplication::applicationName(),\r\n\t\t\ttr(\"Do you want to save changes to %1?\").arg(designWidget_->getDocumentName()),\r\n\t\t\tQMessageBox::Yes | QMessageBox::No, this);\r\n\r\n\t\tif (msgBox.exec() == QMessageBox::Yes)\r\n        {\r\n\t\t\tdesignWidget_->save();\r\n        }\r\n\t}\r\n}\r\n"
  },
  {
    "path": "editors/common/ConfigurationEditor/configurationeditor.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: configurationeditor.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 19.08.2011\r\n//\r\n// Description:\r\n// Editor to edit the design configurations for component.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef CONFIGURATIONEDITOR_H\r\n#define CONFIGURATIONEDITOR_H\r\n\r\n#include \"activevieweditor.h\"\r\n\r\n#include <common/dialogs/createConfigurationDialog/createconfigurationdialog.h>\r\n\r\n#include <QComboBox>\r\n#include <QPlainTextEdit>\r\n#include <QPushButton>\r\n#include <QSharedPointer>\r\n#include <QWidget>\r\n\r\nclass DesignWidget;\r\nclass LibraryInterface;\r\nclass Component;\r\nclass View;\r\nclass DesignConfiguration;\r\nclass VLNVDisplayer;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Editor to edit the design configurations for component.\r\n//-----------------------------------------------------------------------------\r\nclass ConfigurationEditor : public QWidget\r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\r\n\t/*!\r\n     *  The constructor.\r\n\t *\r\n\t *    @param [in] handler     The instance that manages the library.\r\n\t *    @param [in] parent      The owner of this widget.\r\n\t */\r\n\tConfigurationEditor(LibraryInterface* handler, QWidget *parent);\r\n\r\n    //! No copying.\r\n    ConfigurationEditor(const ConfigurationEditor& other) = delete;\r\n\r\n\t//! The destructor.\r\n\tvirtual ~ConfigurationEditor() = default;\r\n\r\n    //! No assignment.\r\n    ConfigurationEditor& operator=(const ConfigurationEditor& other) = delete;\r\n\r\n\t/*!\r\n     *  Set the configuration to be displayed.\r\n\t *\r\n\t *    @param [in] designWidget    The design widget used to edit the design.\r\n\t */\r\n    void setConfiguration(DesignWidget* designWidget);\r\n\r\n\t//! Clear the contents of this editor.\r\n\tvoid clear();\r\n\r\npublic slots:\r\n\r\n\t//! Handler for design widget's refreshed signal.\r\n\tvoid onRefresh();\r\n\r\n\t//! Set the editor to locked/unlocked mode.\r\n\tvoid setLocked(bool locked);\r\n\r\nsignals:\r\n\r\n\t//! Emitted when the editor changes some value.\r\n\tvoid contentChanged();\r\n\r\n    //! Emitted when the active configuration changes.\r\n\tvoid configurationChanged(QString const& newConfigName);\r\n\r\n    //! Emitted when the currently active design configuration changes.\r\n    void designConfigurationChanged(QSharedPointer<DesignConfiguration> newConfiguration);\r\n\r\nprivate slots:\r\n\r\n\t//! Handler for add button clicks.\r\n\tvoid onAdd();\r\n\r\n\t/*!\r\n     *  Called when user changes the current configuration.\r\n\t *\r\n\t *    @param [in] newConfigName   The name of the new configuration to display.\r\n\t */\r\n\tvoid onConfigurationChanged(QString const& newConfigName);\r\n\r\nprivate:\r\n    \r\n    /*!\r\n     *  Finds the view names possible for the current design.\r\n     *\r\n     *    @return The possible view names.\r\n     */\r\n    QStringList findPossibleViews();\r\n \r\n    /*!\r\n     *  Creates a new design configuration and saves it in the library.\r\n     *\r\n     *    @param [in] dialog   The dialog containing the configuration details.\r\n     */\r\n    void createAndSaveConfiguration(CreateConfigurationDialog const& dialog);\r\n\r\n    /*!\r\n     *  Creates a reference to the configuration in the top component.\r\n     *\r\n     *    @param [in] configurationVLNV       The VLNV of the configuration.\r\n     *    @param [in] viewName                The name of the view referencing the configuration.\r\n     *    @param [in] designImplementation    The implementation type of the design.\r\n     */\r\n    void createTopLevelReferenceToConfiguration(VLNV const& configurationVLNV, QString const& viewName, \r\n        const KactusAttribute::Implementation designImplementation);\r\n\r\n\t//! Set up the layout of this widget.\r\n\tvoid setuplayout();\r\n\r\n\t//! Set up the signals between widgets.\r\n\tvoid setupConnections();\r\n\r\n\t/*!\r\n     *  Ask user if he wants to save the previous configuration is it was modified.\r\n\t */\r\n\tvoid askSave();\r\n\r\n    /*!\r\n     *  Remove design and design configuration instantiation references from the selected view.\r\n     *\r\n     *    @param [in] viewName    The name of the selected view.\r\n     */\r\n    void removeViewHierarchicalInstantiationRefs(QString const& viewName) const;\r\n\r\n    /*!\r\n     *  Remove a view from component.\r\n     *\r\n     *    @param [in] viewName    The name of the view being removed.\r\n     */\r\n    void removeViewFromComponent(QString const& viewName) const;\r\n\r\n    /*!\r\n     *  Remove a system view from component.\r\n     *\r\n     *    @param [in] viewName    The name of the system view being removed.\r\n     */\r\n    void removeSystemViewFromComponent(QString const& viewName) const;\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n\t//! The instance that manages the library.\r\n\tLibraryInterface* library_;\r\n\r\n\t//! Button to add new configurations to top component.\r\n\tQPushButton* addNewButton_;\r\n\r\n\t//! Combo box to select the current configuration.\r\n\tQComboBox* configurationSelector_;\r\n\r\n    VLNVDisplayer* configurationDisplay_;\r\n\r\n\t//! Editor to select the active view for each component instance.\r\n\tActiveViewEditor* activeViewEditor_;\r\n\r\n\t//! The top component being edited.\r\n\tQSharedPointer<Component> topComponent_;\r\n\r\n\t//! The design widget that contains the design.\r\n\tDesignWidget* designWidget_;\r\n};\r\n\r\n#endif // CONFIGURATIONEDITOR_H\r\n"
  },
  {
    "path": "editors/common/ConnectionEditor/AdHocBoundColumns.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: AdHocBoundColumns.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Esko Pekkarinen\r\n// Date: 14.10.2015\r\n//\r\n// Description:\r\n// Constants for defining common elements in the AdHocBound editing.\r\n//-----------------------------------------------------------------------------\r\n\r\nnamespace AdHocBoundColumns\r\n{\r\n    //! Constants defining which column represents what kind of information.\r\n    enum Columns\r\n    {\r\n        NAME = 0,  //!< Column for the port name.\r\n        LEFT_BOUND,      //!< Column for the port's left bound.\r\n        RIGHT_BOUND,     //!< Column for the port's right bound.\r\n        COLUMN_COUNT\r\n    };\r\n\r\n}\r\n"
  },
  {
    "path": "editors/common/ConnectionEditor/AdHocBoundsModel.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: AdHocBoundsModel.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Joni-Matti Maatta\r\n// Date: 20.2.2012\r\n//\r\n// Description:\r\n// Table model for visualizing ad-hoc bounds for connection ports.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"AdHocBoundsModel.h\"\r\n#include \"AdHocBoundColumns.h\"\r\n\r\n#include <IPXACTmodels/common/PartSelect.h>\r\n#include <IPXACTmodels/Component/Port.h>\r\n#include <IPXACTmodels/Design/AdHocConnection.h>\r\n#include <IPXACTmodels/Design/PortReference.h>\r\n\r\n#include <common/IEditProvider.h>\r\n\r\n#include <editors/common/DesignDiagram.h>\r\n#include <editors/HWDesign/AdHocConnectionItem.h>\r\n#include <editors/HWDesign/HWConnectionEndpoint.h>\r\n#include <editors/HWDesign/HWChangeCommands.h>\r\n#include <editors/HWDesign/undoCommands/AdHocBoundsChangeCommand.h>\r\n\r\n#include <KactusAPI/include/ExpressionParser.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AdHocBoundsModel::AdHocBoundsModel()\r\n//-----------------------------------------------------------------------------\r\nAdHocBoundsModel::AdHocBoundsModel(QObject *parent) :\r\nQAbstractTableModel(parent),\r\neditProvider_()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AdHocBoundsModel::setConnection()\r\n//-----------------------------------------------------------------------------\r\nvoid AdHocBoundsModel::setConnection(QSharedPointer<AdHocConnection> connection,\r\n\tQSharedPointer<endPointParser> firstEndpointParser,\r\n\tQSharedPointer<endPointParser> secondEndpointParser,\r\n    QSharedPointer<IEditProvider> editProvider)\r\n{\r\n    editProvider_ = editProvider;\r\n    connection_ = connection;\r\n\r\n    firstEndpointParser_ = firstEndpointParser;\r\n\tsecondEndpointParser_ = secondEndpointParser;\r\n\r\n    beginResetModel();\r\n    endResetModel();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AdHocBoundsModel::rowCount()\r\n//-----------------------------------------------------------------------------\r\nint AdHocBoundsModel::rowCount(QModelIndex const& parent) const\r\n{\r\n    if (parent.isValid())\r\n    {\r\n        return 0;\r\n    }\r\n\r\n    return getEndpointCount();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AdHocBoundsModel::columnCount()\r\n//-----------------------------------------------------------------------------\r\nint AdHocBoundsModel::columnCount(QModelIndex const& parent) const\r\n{\r\n    if (parent.isValid())\r\n    {\r\n        return 0;\r\n    }\r\n\r\n    return AdHocBoundColumns::COLUMN_COUNT;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AdHocBoundsModel::data()\r\n//-----------------------------------------------------------------------------\r\nQVariant AdHocBoundsModel::data(QModelIndex const& index, int role) const\r\n{\r\n    // Check for invalid index.\r\n    if (!index.isValid() || connection_ == 0 || index.row() > getEndpointCount())\r\n    {\r\n        return QVariant();\r\n    }\r\n\r\n    if (role == Qt::DisplayRole || role == Qt::EditRole)\r\n    {\r\n        return valueForIndex(index);\r\n    }\r\n\r\n    return QVariant();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AdHocBoundsModel::valueForIndex()\r\n//-----------------------------------------------------------------------------\r\nQVariant AdHocBoundsModel::valueForIndex(QModelIndex const& index) const\r\n{\r\n    QSharedPointer<PortReference> port = getEndpoint(index.row());\r\n\r\n    if (index.column() == AdHocBoundColumns::NAME)\r\n    {\r\n        QString portName = port->getPortRef();\r\n        if (port->getComponentRef().isEmpty())\r\n        {\r\n            portName.append(QStringLiteral(\" (external)\"));\r\n        }\r\n\r\n        return portName;\r\n    }\r\n    else if (index.column() == AdHocBoundColumns::LEFT_BOUND)\r\n    {\r\n        QSharedPointer<PartSelect> part = port->getPartSelect();\r\n\r\n        if (part)\r\n        {\r\n            return part->getLeftRange();\r\n        }\r\n        else\r\n        {\r\n            return getOriginalPortLeftBound(port);\r\n        }\r\n    }\r\n    else if (index.column() == AdHocBoundColumns::RIGHT_BOUND)\r\n    {\r\n        QSharedPointer<PartSelect> part = port->getPartSelect();\r\n\r\n        if (part)\r\n        {\r\n            return part->getRightRange();\r\n        }\r\n        else\r\n        {\r\n            return getOriginalPortRightBound(port);\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AdHocBoundsModel::getOriginalPortLeftBound()\r\n//-----------------------------------------------------------------------------\r\nQVariant AdHocBoundsModel::getOriginalPortLeftBound(QSharedPointer<PortReference> port) const\r\n{\r\n\tif (portUsesParser(port, firstEndpointParser_))\r\n\t{\r\n        return getLeftBoundWithParser(port, firstEndpointParser_);\r\n\t}\r\n\telse if (portUsesParser(port, secondEndpointParser_))\r\n\t{\r\n        return getLeftBoundWithParser(port, secondEndpointParser_);\r\n\t}\r\n\r\n    return QString(\"\");\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AdHocBoundsModel::portUsesParser()\r\n//-----------------------------------------------------------------------------\r\nbool AdHocBoundsModel::portUsesParser(QSharedPointer<PortReference> port,\r\n    QSharedPointer<AdHocBoundsModel::endPointParser> endpointParser) const\r\n{\r\n    if (port && endpointParser)\r\n    {\r\n\t\treturn endpointParser->endPoint_ == port->getPortRef() && endpointParser->containingInstanceName_ == port->getComponentRef();\r\n    }\r\n    else\r\n    {\r\n        return false;\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AdHocBoundsModel::getLeftBoundWithParser()\r\n//-----------------------------------------------------------------------------\r\nQVariant AdHocBoundsModel::getLeftBoundWithParser(QSharedPointer<PortReference> port, QSharedPointer<AdHocBoundsModel::endPointParser> endpointParser) const\r\n{\r\n\tif (endpointParser)\r\n\t{\r\n\t\tauto componentPort = endpointParser->instancedComponent_->getPort(port->getPortRef());\r\n\t\tif (componentPort.isNull() == false)\r\n\t\t{\r\n\t\t\treturn endpointParser->instanceParser_->parseExpression(componentPort->getLeftBound());\r\n\t\t}\r\n\t}\r\n\r\n\treturn QString(\"\");\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AdHocBoundsModel::getOriginalPortRightBound()\r\n//-----------------------------------------------------------------------------\r\nQVariant AdHocBoundsModel::getOriginalPortRightBound(QSharedPointer<PortReference> port) const\r\n{\r\n\tif (portUsesParser(port, firstEndpointParser_))\r\n\t{\r\n\t\treturn getRightBoundWithParser(port, firstEndpointParser_);\r\n\t}\r\n\telse if (portUsesParser(port, secondEndpointParser_))\r\n\t{\r\n\t\treturn getRightBoundWithParser(port, secondEndpointParser_);\r\n\t}\r\n\r\n\treturn QString(\"\");\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AdHocBoundsModel::getOriginalPortRightBound()\r\n//-----------------------------------------------------------------------------\r\nQVariant AdHocBoundsModel::getRightBoundWithParser(QSharedPointer<PortReference> port, QSharedPointer<AdHocBoundsModel::endPointParser> endpointParser) const\r\n{\r\n\tif (endpointParser)\r\n\t{\r\n\t\tauto componentPort = endpointParser->instancedComponent_->getPort(port->getPortRef());\r\n\t\tif (componentPort.isNull() == false)\r\n\t\t{\r\n\t\t\treturn endpointParser->instanceParser_->parseExpression(componentPort->getRightBound());\r\n\t\t}\r\n\t}\r\n\r\n\treturn QString(\"\");\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AdHocBoundsModel::headerData()\r\n//-----------------------------------------------------------------------------\r\nQVariant AdHocBoundsModel::headerData(int section, Qt::Orientation orientation, int role) const\r\n{\r\n    if (role != Qt::DisplayRole)\r\n    {\r\n        return QVariant();\r\n    }\r\n\r\n    if (orientation == Qt::Horizontal)\r\n    {\r\n        if (section == AdHocBoundColumns::NAME)\r\n        {\r\n            return tr(\"Port name\");\r\n        }\r\n        else if (section == AdHocBoundColumns::LEFT_BOUND)\r\n        {\r\n            return tr(\"Left Bound\");\r\n        }\r\n        else if (section == AdHocBoundColumns::RIGHT_BOUND)\r\n        {\r\n            return tr(\"Right Bound\");\r\n        }\r\n        else\r\n        {\r\n            return QVariant();\r\n        }\r\n    } \r\n    // Vertical headers get running numbers.\r\n    else\r\n    {\r\n        return section + 1;\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AdHocBoundsModel::setData()\r\n//-----------------------------------------------------------------------------\r\nbool AdHocBoundsModel::setData(QModelIndex const& index, QVariant const& value, int role)\r\n{\r\n    // Check for invalid index.\r\n    if (!index.isValid() || connection_ == 0 || index.row() < 0 || index.row() > getEndpointCount())\r\n    {\r\n        return false;\r\n    }\r\n\r\n    if (role == Qt::EditRole)\r\n    {\r\n        QSharedPointer<PortReference> port = getEndpoint(index.row());\r\n\r\n        QString newLeftValue;\r\n        QString newRightValue;\r\n\r\n        if (index.column() == AdHocBoundColumns::LEFT_BOUND)\r\n        {\r\n            newLeftValue = value.toString();\r\n\r\n            QModelIndex rightSibling = index.sibling(index.row(), AdHocBoundColumns::RIGHT_BOUND);\r\n            newRightValue = rightSibling.data(Qt::EditRole).toString();\r\n        }\r\n        else if (index.column() == AdHocBoundColumns::RIGHT_BOUND)\r\n        {\r\n            newRightValue = value.toString();\r\n\r\n            QModelIndex leftSibling = index.sibling(index.row(), AdHocBoundColumns::LEFT_BOUND);\r\n            newLeftValue = leftSibling.data(Qt::EditRole).toString();\r\n        }\r\n        else\r\n        {\r\n            return false;\r\n        }\r\n\r\n        QSharedPointer<QUndoCommand> boundsChangeCommand(\r\n            new AdHocBoundsChangeCommand(port, newLeftValue, newRightValue));\r\n        editProvider_->addCommand(boundsChangeCommand);\r\n        boundsChangeCommand->redo();\r\n\r\n        emit dataChanged(index, index);\r\n        return true;\r\n    }\r\n\r\n    return false;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AdHocBoundsModel::flags()\r\n//-----------------------------------------------------------------------------\r\nQt::ItemFlags AdHocBoundsModel::flags(QModelIndex const& index) const\r\n{\r\n    if (!index.isValid())\r\n    {\r\n        return Qt::NoItemFlags;\r\n    }\r\n\r\n    if (index.column() == AdHocBoundColumns::NAME)\r\n    {\r\n        return Qt::ItemIsEnabled | Qt::ItemIsSelectable;\r\n    }\r\n    else if (index.column() == AdHocBoundColumns::LEFT_BOUND || index.column() == AdHocBoundColumns::RIGHT_BOUND)\r\n    {\r\n        return Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsEditable;\r\n    }\r\n    \r\n    return Qt::NoItemFlags;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AdHocBoundsModel::getEndpointCount()\r\n//-----------------------------------------------------------------------------\r\nint AdHocBoundsModel::getEndpointCount() const\r\n{\r\n    if (connection_ == 0)\r\n    {\r\n        return 0;\r\n    }\r\n\r\n    return connection_->getInternalPortReferences()->count() +\r\n        connection_->getExternalPortReferences()->count();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: AdHocBoundsModel::getEndpoint()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<PortReference> AdHocBoundsModel::getEndpoint(int row) const\r\n{\r\n    int internalPortCount = connection_->getInternalPortReferences()->count();\r\n    if (row < internalPortCount)\r\n    {\r\n        return connection_->getInternalPortReferences()->at(row);\r\n    }\r\n    else\r\n    {\r\n        return connection_->getExternalPortReferences()->at(row - internalPortCount);\r\n    }\r\n}\r\n"
  },
  {
    "path": "editors/common/ConnectionEditor/AdHocBoundsModel.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: AdHocBoundsModel.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Joni-Matti Maatta\r\n// Date: 20.2.2012\r\n//\r\n// Description:\r\n// Table model for visualizing ad-hoc bounds for component ports.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef ADHOCBOUNDSMODEL_H\r\n#define ADHOCBOUNDSMODEL_H\r\n\r\n#include <QAbstractTableModel>\r\n#include <QSharedPointer>\r\n\r\nclass PortReference;\r\nclass AdHocConnection;\r\nclass IEditProvider;\r\nclass ExpressionParser;\r\nclass Component;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Table model for visualizing ad-hoc visibility for component ports.\r\n//-----------------------------------------------------------------------------\r\nclass AdHocBoundsModel : public QAbstractTableModel\r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\r\n\t//! Container for the end point parser data.\r\n\tstruct endPointParser\r\n\t{\r\n\t\t//! Name of the end point.\r\n\t\tQString endPoint_ = \"\";\r\n\r\n\t\t//! Name of the containing instance.\r\n\t\tQString containingInstanceName_ = \"\";\r\n\r\n\t\t//! Component containing the end point.\r\n\t\tQSharedPointer<Component> instancedComponent_ = nullptr;\r\n\r\n\t\t//! Parser for the component instance.\r\n\t\tQSharedPointer<ExpressionParser> instanceParser_ = nullptr;\r\n\t};\r\n\r\n\t/*!\r\n     *  Constructor.\r\n\t *\r\n     *    @param [in] editProvider  The edit provider managing the undo/redo stack.\r\n\t *    @param [in] parent        The owner of this model.\r\n\t */\r\n\tAdHocBoundsModel(QObject *parent);\r\n\t\r\n\t//! The destructor.\r\n\tvirtual ~AdHocBoundsModel() = default;\r\n\r\n\t/*!\r\n\t *  Sets the ad-hoc connection being edited.\r\n\t *\r\n\t *    @param [in] connection\t\t\tThe ad-hoc connection.\r\n\t *    @param [in] firstEndpointParser\tExpression parser for the first end point.\r\n\t *    @param [in] secondEndpointParser\tExpression parser for the second end point.\r\n\t *    @param [in] editProvider\t\t\tThe edit provider for undo/redo.\r\n\t *\r\n\t *    @return \r\n\t */\r\n\tvoid setConnection(QSharedPointer<AdHocConnection> connection,\r\n\t\tQSharedPointer<endPointParser> firstEndpointParser,\r\n\t\tQSharedPointer<endPointParser> secondEndpointParser,\r\n\t\tQSharedPointer<IEditProvider> editProvider);\r\n\r\n\t/*!\r\n     *  Returns the number of rows in the model.\r\n\t *\r\n\t *    @param [in] parent Model index of the parent of the item.\r\n\t *\r\n\t *    @return Number of rows currently in the model.\r\n\t */\r\n\tvirtual int rowCount(QModelIndex const& parent = QModelIndex()) const;\r\n\r\n\t/*!\r\n     *  Returns the number of columns in the model.\r\n\t *\r\n\t *    @param [in] parent Model index of the parent of the item.\r\n\t *\r\n\t *    @return Number of columns currently in the model.\r\n\t */\r\n\tvirtual int columnCount(QModelIndex const& parent = QModelIndex()) const;\r\n\r\n\t/*!\r\n     *  Returns the data for the specified item for specified role.\r\n\t *\r\n\t *    @param [in] index  Identifies the item that's data is wanted.\r\n\t *    @param [in] role   Specifies what kind of data is wanted\r\n\t *\r\n\t *    @return The data in the requested index.\r\n\t */\r\n\tvirtual QVariant data(QModelIndex const& index, int role = Qt::DisplayRole) const;\r\n\r\n\t/*!\r\n     *  Returns the data for the headers.\r\n\t *\r\n\t *    @param [in] section      The column that's header is wanted\r\n\t *    @param [in] orientation  Only Qt::Horizontal is supported\r\n\t *    @param [in] role         Specified the type of data that is wanted.\r\n\t *\r\n\t *    @return The data to be displayed.\r\n\t */\r\n\tvirtual QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;\r\n\r\n\t/*!\r\n     *  Set the data for specified item.\r\n\t *\r\n\t *    @param [in] index  Specifies the item that's data is modified\r\n\t *    @param [in] value  The value to be set.\r\n\t *    @param [in] role   The role that is trying to modify the data.\r\n\t *\r\n\t *    @return True if data was successfully set, otherwise false.\r\n\t */\r\n\tvirtual bool setData(QModelIndex const& index, QVariant const& value, int role = Qt::EditRole);\r\n\r\n\t/*!\r\n     *  Returns information on how specified item can be handled.\r\n\t *\r\n\t *    @param [in] index Specifies the item that's flags are wanted.\r\n\t *\r\n\t *    @return Qt::ItemFlags that define how object can be handled.\r\n\t */\r\n\tvirtual Qt::ItemFlags flags(QModelIndex const& index) const;\r\n\r\n    \r\nsignals:\r\n\t//! Emitted when contents of the model change\r\n\tvoid contentChanged();\r\n\r\nprivate:\r\n    // Disable copying.\r\n    AdHocBoundsModel(AdHocBoundsModel const& rhs);\r\n    AdHocBoundsModel& operator=(AdHocBoundsModel const& rhs);\r\n\r\n\t/*!\r\n\t *  Get the value for the selected index.\r\n\t *\r\n\t *    @param [in] index\t\tThe selected index.\r\n\t *\r\n\t *    @return Value for the selected index.\r\n\t */\r\n\tQVariant valueForIndex(QModelIndex const& index) const;\r\n\r\n\t/*!\r\n\t *  Get the original left bound value of the selected port.\r\n\t *\r\n\t *    @param [in] port\tThe selected port.\r\n\t *\r\n\t *    @return The original left bound value of the selected port.\r\n\t */\r\n\tQVariant getOriginalPortLeftBound(QSharedPointer<PortReference> port) const;\r\n\r\n\t/*!\r\n\t *  Get the calculated left bound value of the selected port.\r\n\t *\r\n\t *    @param [in] port\t\t\t\tThe selected port.\r\n\t *    @param [in] endpointParser\tParser for the component instance containing the selected port.\r\n\t *\r\n\t *    @return The calculated left bound value of the selected port.\r\n\t */\r\n\tQVariant getLeftBoundWithParser(QSharedPointer<PortReference> port, QSharedPointer<AdHocBoundsModel::endPointParser> endpointParser) const;\r\n\r\n\t/*!\r\n\t *  Get the original right bound value of the selected port.\r\n\t *\r\n\t *    @param [in] port\tThe selected port.\r\n\t *\r\n\t *    @return The original right bound value of the selected port.\r\n\t */\r\n\tQVariant getOriginalPortRightBound(QSharedPointer<PortReference> port) const;\r\n\r\n\t/*!\r\n\t *  Get the calculated right bound value of the selected port.\r\n\t *\r\n\t *    @param [in] port\t\t\t\tThe selected port.\r\n\t *    @param [in] endpointParser\tParser for the component instance containing the selected port.\r\n\t *\r\n\t *    @return The calculated right bound value of the selected port.\r\n\t */\r\n\tQVariant getRightBoundWithParser(QSharedPointer<PortReference> port, QSharedPointer<AdHocBoundsModel::endPointParser> endpointParser) const;\r\n\r\n\t/*!\r\n\t *  Check if the selected port is contained within the selected end point parser.\r\n\t *\r\n\t *    @param [in] port\t\t\t\tThe selected port.\r\n\t *    @param [in] endpointParser\tThe selected end point parser.\r\n\t *\r\n\t *    @return True, if the port is contained within the parser, false otherwise.\r\n\t */\r\n\tbool portUsesParser(QSharedPointer<PortReference> port, QSharedPointer<AdHocBoundsModel::endPointParser> endpointParser) const;\r\n\r\n    /*!\r\n     *  Finds the number of endpoint in the ad-hoc connection.\r\n     *\r\n     *    @return The number of endpoints defined in the connection.\r\n     */\r\n    int getEndpointCount() const;\r\n\r\n    /*!\r\n     *  Gets the port reference on the given row.\r\n     *\r\n     *    @param [in] row   The row to find.\r\n     *\r\n     *    @return The port reference on the given row.\r\n     */\r\n    QSharedPointer<PortReference> getEndpoint(int row) const;\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n\t//! The first end point parser.\r\n\tQSharedPointer<endPointParser> firstEndpointParser_ = nullptr;\r\n\r\n\t//! The second end point parser.\r\n\tQSharedPointer<endPointParser> secondEndpointParser_ = nullptr;\r\n\r\n    //! The edit provider for undo/redo to use.\r\n    QSharedPointer<IEditProvider> editProvider_;\r\n\r\n    //! The ad-hoc connection currently being edited.\r\n    QSharedPointer<AdHocConnection> connection_;\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n\r\n#endif // ADHOCBOUNDSMODEL_H"
  },
  {
    "path": "editors/common/ConnectionEditor/connectioneditor.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: connectioneditor.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 14.10.2011\r\n//\r\n// Description:\r\n// Editor to display/edit details of a connection.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"connectioneditor.h\"\r\n\r\n#include \"AdHocBoundColumns.h\"\r\n\r\n#include <common/IEditProvider.h>\r\n#include <common/graphicsItems/ConnectionUndoCommands.h>\r\n#include <common/graphicsItems/ComponentItem.h>\r\n\r\n#include <editors/common/DesignDiagram.h>\r\n#include <editors/HWDesign/AdHocConnectionItem.h>\r\n#include <editors/HWDesign/HWConnectionEndpoint.h>\r\n#include <editors/HWDesign/HWChangeCommands.h>\r\n\r\n#include <KactusAPI/include/ParameterCache.h>\r\n#include <KactusAPI/include/MultipleParameterFinder.h>\r\n#include <KactusAPI/include/IPXactSystemVerilogParser.h>\r\n#include <KactusAPI/include/LibraryInterface.h>\r\n#include <KactusAPI/include/ListParameterFinder.h>\r\n#include <KactusAPI/include/ParameterConfigurableElementFinder.h>\r\n\r\n#include <IPXACTmodels/generaldeclarations.h>\r\n#include <IPXACTmodels/common/Vector.h>\r\n#include <IPXACTmodels/common/VLNV.h>\r\n#include <IPXACTmodels/common/validators/namevalidator.h>\r\n#include <IPXACTmodels/Component/BusInterface.h>\r\n#include <IPXACTmodels/Component/Component.h>\r\n#include <IPXACTmodels/Component/PortMap.h>\r\n#include <IPXACTmodels/Design/Design.h>\r\n#include <IPXACTmodels/Design/ComponentInstance.h>\r\n#include <IPXACTmodels/AbstractionDefinition/AbstractionDefinition.h>\r\n#include <IPXACTmodels/AbstractionDefinition/PortAbstraction.h>\r\n#include <IPXACTmodels/AbstractionDefinition/WireAbstraction.h>\r\n#include <IPXACTmodels/AbstractionDefinition/TransactionalAbstraction.h>\r\n#include <IPXACTmodels/kactusExtensions/ApiInterface.h>\r\n#include <IPXACTmodels/kactusExtensions/ComInterface.h>\r\n\r\n#include <QFormLayout>\r\n#include <QVBoxLayout>\r\n#include <QSharedPointer>\r\n#include <QHeaderView>\r\n#include <QList>\r\n#include <QStringList>\r\n#include <QSortFilterProxyModel>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ConnectionEditor::ConnectionEditor()\r\n//-----------------------------------------------------------------------------\r\nConnectionEditor::ConnectionEditor(LibraryInterface* library, QWidget *parent):\r\nQWidget(parent),\r\ntype_(this, VLNV(), true),\r\nabsType_(this, VLNV(), true),\r\ninstanceLabel_(tr(\"Connected interfaces:\"), this),\r\nconnectedInstances_(this),\r\nnameGroup_(this),\r\nnameLabel_(tr(\"Name:\"), this),\r\nnameEdit_(this),\r\ndescriptionLabel_(tr(\"Description:\"), this),\r\ndescriptionEdit_(this),\r\nportsLabel_(tr(\"Connected physical ports:\"), this),\r\nportWidget_(this),\r\nconnection_(nullptr),\r\ndiagram_(nullptr),\r\nlibrary_(library),\r\nadHocBoundsTable_(this),\r\nadHocBoundsModel_(this),\r\nconnectionTypeTable_(new QStackedWidget())\r\n{\r\n\tQ_ASSERT(parent);\r\n\tQ_ASSERT(library_);\r\n\r\n\tsetSizePolicy(QSizePolicy::Preferred, QSizePolicy::Expanding);\r\n\r\n\ttype_.setTitle(tr(\"Bus type VLNV\"));\r\n\ttype_.setFlat(true);\r\n\tabsType_.setTitle(tr(\"Abstraction type VLNV\"));\r\n\tabsType_.setFlat(true);\r\n\r\n\tnameGroup_.setTitle(tr(\"Connection name\"));\r\n    nameGroup_.setFlat(true);\r\n\r\n    nameEdit_.setValidator(new NameValidator(&nameEdit_));\r\n\r\n\t// There are always 2 columns.\r\n\tportWidget_.setColumnCount(2);\r\n\tportWidget_.setHorizontalHeaderItem(0, new QTableWidgetItem(tr(\"instance1\")));\r\n\tportWidget_.setHorizontalHeaderItem(1, new QTableWidgetItem(tr(\"instance2\")));\r\n\tportWidget_.horizontalHeader()->setStretchLastSection(true);\r\n\tportWidget_.horizontalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents);\r\n\tportWidget_.verticalHeader()->hide();\r\n\tportWidget_.setEditTriggers(QAbstractItemView::NoEditTriggers);\r\n\r\n\tdescriptionEdit_.setMaximumHeight(50);\r\n\r\n    // Set settings for the table view.\r\n    adHocBoundsTable_.setSortingEnabled(true);\r\n    adHocBoundsTable_.setSelectionMode(QAbstractItemView::SingleSelection);\r\n    adHocBoundsTable_.verticalHeader()->hide();\r\n\r\n    QSortFilterProxyModel* adHocPortProxy = new QSortFilterProxyModel(this);\r\n    adHocPortProxy->setSourceModel(&adHocBoundsModel_);\r\n    adHocBoundsTable_.setModel(adHocPortProxy);\r\n\r\n    adHocBoundsTable_.setColumnWidth(AdHocBoundColumns::LEFT_BOUND, 70);\r\n    adHocBoundsTable_.setColumnWidth(AdHocBoundColumns::RIGHT_BOUND, 70);\r\n    adHocBoundsTable_.horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch);\r\n    adHocBoundsTable_.horizontalHeader()->setSectionResizeMode(AdHocBoundColumns::LEFT_BOUND, QHeaderView::Fixed);\r\n    adHocBoundsTable_.horizontalHeader()->setSectionResizeMode(AdHocBoundColumns::RIGHT_BOUND, QHeaderView::Fixed);\r\n\r\n    connectionTypeTable_->addWidget(&portWidget_);\r\n    connectionTypeTable_->addWidget(&adHocBoundsTable_);\r\n\r\n    setupLayout();\r\n\r\n\tclear();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ConnectionEditor::clear()\r\n//-----------------------------------------------------------------------------\r\nvoid ConnectionEditor::clear()\r\n{\r\n\tif (connection_)\r\n    {\r\n\t\tdisconnect(connection_, SIGNAL(destroyed(GraphicsConnection*)),\tthis, SLOT(clear()));\r\n\t\tdisconnect(connection_, SIGNAL(contentChanged()), this, SLOT(refresh()));\r\n\t\tconnection_ = nullptr;\r\n\t}\r\n\r\n\tdisconnect(&nameEdit_, SIGNAL(editingFinished()), this, SLOT(onNameOrDescriptionChanged()));\r\n\tdisconnect(&descriptionEdit_, SIGNAL(textChanged()), this, SLOT(onNameOrDescriptionChanged()));\r\n\r\n\t// clear the contents of the editors\r\n    type_.setVLNV(VLNV());\r\n    absType_.setVLNV(VLNV());\r\n\tconnectedInstances_.clear();\r\n\tnameEdit_.clear();\r\n\tdescriptionEdit_.clear();\r\n\tportWidget_.clearContents();\r\n    adHocBoundsModel_.setConnection(QSharedPointer<AdHocConnection>(),\r\n        QSharedPointer<AdHocBoundsModel::endPointParser>(),\r\n        QSharedPointer<AdHocBoundsModel::endPointParser>(),\r\n        QSharedPointer<IEditProvider>());\r\n\r\n\t// set objects as hidden\r\n\ttype_.hide();\r\n\tabsType_.hide();\r\n\tinstanceLabel_.hide();\r\n\tconnectedInstances_.hide();\r\n\tnameGroup_.hide();\r\n\tportsLabel_.hide();\r\n    connectionTypeTable_->hide();\r\n\r\n\tparentWidget()->setMaximumHeight(20);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ConnectionEditor::refresh()\r\n//-----------------------------------------------------------------------------\r\nvoid ConnectionEditor::refresh()\r\n{\r\n\tQ_ASSERT(connection_);\r\n\tsetConnection(connection_, diagram_);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ConnectionEditor::setConnection()\r\n//-----------------------------------------------------------------------------\r\nvoid ConnectionEditor::setConnection(GraphicsConnection* connection, DesignDiagram* diagram)\r\n{\r\n\tQ_ASSERT(connection);\r\n\r\n\t//parentWidget()->raise();\r\n\r\n\t// disconnect the previous connection\r\n\tif (connection_)\r\n    {\r\n\t\tdisconnect(connection_, SIGNAL(destroyed(GraphicsConnection*)),\tthis, SLOT(clear()));\r\n\t\tdisconnect(connection_, SIGNAL(contentChanged()), this, SLOT(refresh()));\r\n\t}\r\n\r\n\tconnection_ = connection;\r\n    diagram_ = diagram;\r\n\r\n\tauto endpoint1 = connection->endpoint1();\r\n\tauto endpoint2 = connection->endpoint2();\r\n\tQ_ASSERT(endpoint1);\r\n\r\n    if (!endpoint1 || !endpoint2)\r\n    {\r\n        return;\r\n    }\r\n\r\n\tQSharedPointer<Component> component1 = endpoint1->getOwnerComponent();\r\n\tQSharedPointer<Component> component2 = endpoint2->getOwnerComponent();\r\n\r\n\tQSharedPointer<ListParameterFinder> designFinder(new ListParameterFinder());\r\n\tif (diagram_ && diagram_->getDesign())\r\n\t{\r\n\t\tdesignFinder->setParameterList(diagram_->getDesign()->getParameters());\r\n\t}\r\n\tauto firstInstanceParser = createInstanceParser(component1, endpoint1, designFinder);\r\n\tauto secondInstanceParser = createInstanceParser(component2, endpoint2, designFinder);\r\n\r\n    if (endpoint1->isCom())\r\n    {\r\n        type_.setTitle(tr(\"COM type VLNV\"));\r\n\r\n        if (endpoint2->isCom())\r\n        {\r\n            type_.setVLNV(endpoint1->getComInterface()->getComType());\r\n        }\r\n        else\r\n        {\r\n            type_.setVLNV(VLNV());\r\n        }\r\n    }\r\n    else if (endpoint1->isApi())\r\n    {\r\n        type_.setTitle(tr(\"API type VLNV\"));\r\n\r\n        if (endpoint2->isApi())\r\n        {\r\n            type_.setVLNV(endpoint1->getApiInterface()->getApiType());\r\n        }\r\n        else\r\n        {\r\n            type_.setVLNV(VLNV());\r\n        }\r\n    }\r\n    else if (endpoint1->isBus())\r\n    {\r\n        type_.setTitle(tr(\"Bus type VLNV\"));\r\n        type_.setVLNV(endpoint1->getBusInterface()->getBusType());\r\n        absType_.setVLNV(findAbstractionVLNV(endpoint1, endpoint1->getBusInterface()));\r\n\r\n        setPortMaps(firstInstanceParser, secondInstanceParser);\r\n        portWidget_.scrollToTop();\r\n    }\r\n    else if (endpoint1->isAdHoc())\r\n    {\r\n        auto firstEndPointParser = createAdHocBoundsParser(endpoint1, firstInstanceParser, component1);\r\n        auto secondEndPointParser = createAdHocBoundsParser(endpoint2, secondInstanceParser, component2);\r\n\r\n\t\tauto adHoc = static_cast<AdHocConnectionItem*>(connection_);\r\n        adHocBoundsModel_.setConnection(adHoc->getInterconnection(), firstEndPointParser, secondEndPointParser, diagram->getEditProvider());\r\n        adHocBoundsTable_.resizeRowsToContents();\r\n    }\r\n\r\n\t// set the names of the connected instances\r\n\tconnectedInstances_.setText(QString(\"%1 - %2\").arg(endpoint1->name(), endpoint2->name()));\r\n\r\n\t// set text for the name editor, signal must be disconnected when name is set to avoid loops \r\n\tdisconnect(&nameEdit_, SIGNAL(editingFinished()), this, SLOT(onNameOrDescriptionChanged()));\r\n\tnameEdit_.setText(connection->name());\r\n\tconnect(&nameEdit_, SIGNAL(editingFinished()), this, SLOT(onNameOrDescriptionChanged()), Qt::UniqueConnection);\r\n\r\n\t// display the current description of the interface.\r\n\tdisconnect(&descriptionEdit_, SIGNAL(textChanged()), this, SLOT(onNameOrDescriptionChanged()));\r\n\tdescriptionEdit_.setPlainText(connection->description());\r\n\tconnect(&descriptionEdit_, SIGNAL(textChanged()), this, SLOT(onNameOrDescriptionChanged()), Qt::UniqueConnection);\r\n\r\n\tconnect(connection, SIGNAL(destroyed(GraphicsConnection*)),\tthis, SLOT(clear()), Qt::UniqueConnection);\r\n\tconnect(connection, SIGNAL(contentChanged()), this, SLOT(refresh()), Qt::UniqueConnection);\r\n\r\n    bool locked = diagram_->isProtected();\r\n\t         \r\n    nameEdit_.setDisabled(locked);\r\n    descriptionEdit_.setDisabled(locked);    \r\n    adHocBoundsTable_.setEnabled(!locked);\r\n\r\n    bool isAdHocConnection = connection_->getConnectionType() == ConnectionEndpoint::ENDPOINT_TYPE_ADHOC;\r\n    bool isBus = connection_->getConnectionType() == ConnectionEndpoint::ENDPOINT_TYPE_BUS;\r\n       \t\r\n    nameGroup_.show();    \r\n    instanceLabel_.show();\r\n\tconnectedInstances_.show();\r\n\r\n    type_.setVisible(endpoint1->getType() != ConnectionEndpoint::ENDPOINT_TYPE_UNDEFINED &&\r\n                     endpoint2->getType() != ConnectionEndpoint::ENDPOINT_TYPE_UNDEFINED &&\r\n                     !isAdHocConnection);\r\n\r\n    absType_.setVisible(isBus);\r\n\r\n    portsLabel_.setVisible(isBus || isAdHocConnection);\r\n\r\n    connectionTypeTable_->setVisible(isBus || isAdHocConnection);\r\n    if (isBus)\r\n    {\r\n        connectionTypeTable_->setCurrentIndex(0);\r\n    }\r\n    else if (isAdHocConnection)\r\n    {\r\n        connectionTypeTable_->setCurrentIndex(1);\r\n    }\r\n\r\n    portWidget_.resizeColumnsToContents();\r\n\r\n\tparentWidget()->setMaximumHeight(QWIDGETSIZE_MAX);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: connectioneditor::createAdHocBoundsParser()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<AdHocBoundsModel::endPointParser> ConnectionEditor::createAdHocBoundsParser(\r\n    ConnectionEndpoint const* endPoint,\r\n    QSharedPointer<ExpressionParser> instanceParser,\r\n    QSharedPointer<Component> containingComponent) const\r\n{\r\n\tauto endPointParser = QSharedPointer<AdHocBoundsModel::endPointParser>(new AdHocBoundsModel::endPointParser());\r\n    endPointParser->endPoint_ = endPoint->name();\r\n    endPointParser->instanceParser_ = instanceParser;\r\n    endPointParser->instancedComponent_ = containingComponent;\r\n\r\n\tif (auto containingComponentItem = dynamic_cast<ComponentItem*>(endPoint->parentItem()); containingComponentItem)\r\n\t{\r\n\t\tendPointParser->containingInstanceName_ = containingComponentItem->name();\r\n\t}\r\n\r\n    return endPointParser;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ConnectionEditor::onNameOrDescriptionChanged()\r\n//-----------------------------------------------------------------------------\r\nvoid ConnectionEditor::onNameOrDescriptionChanged()\r\n{\r\n\tQ_ASSERT(connection_);\r\n\r\n\tdisconnect(connection_, SIGNAL(contentChanged()), this, SLOT(refresh()));\t\r\n\r\n\tQSharedPointer<QUndoCommand> cmd(new ConnectionChangeCommand(connection_, nameEdit_.text(), \r\n        descriptionEdit_.toPlainText()));\r\n\r\n\tdiagram_->getEditProvider()->addCommand(cmd);\r\n    cmd->redo();\r\n\r\n\tconnect(connection_, SIGNAL(contentChanged()), this, SLOT(refresh()), Qt::UniqueConnection);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ConnectionEditor::findAbstractionVLNV()\r\n//-----------------------------------------------------------------------------\r\nVLNV ConnectionEditor::findAbstractionVLNV(ConnectionEndpoint* endPoint,\r\n    QSharedPointer<BusInterface> busInterface) const\r\n{\r\n    QString activeView = getActiveViewForEndPoint(endPoint);\r\n    QSharedPointer<AbstractionType> abstraction = busInterface->getAbstractionContainingView(activeView);\r\n\r\n    VLNV definition;\r\n    if (abstraction && abstraction->getAbstractionRef())\r\n    {\r\n        definition = VLNV(*abstraction->getAbstractionRef());\r\n    }\r\n\r\n    return definition;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ConnectionEditor::setPortMaps()\r\n//-----------------------------------------------------------------------------\r\nvoid ConnectionEditor::setPortMaps(\r\n    QSharedPointer<ExpressionParser> firstInstanceParser,\r\n    QSharedPointer<ExpressionParser> secondInstanceParser)\r\n{\r\n\tportWidget_.clearContents();\r\n    portWidget_.setSortingEnabled(false);\r\n    portWidget_.setRowCount(0);\r\n\r\n    Q_ASSERT(connection_);\r\n    if (!connection_)\r\n    {\r\n        return;\r\n    }\r\n\r\n    ConnectionEndpoint* endPoint1 = connection_->endpoint1();\r\n    ConnectionEndpoint* endPoint2 = connection_->endpoint2();\r\n\r\n    QSharedPointer<BusInterface> busIf1 = endPoint1->getBusInterface();\r\n    QSharedPointer<BusInterface> busIf2 = endPoint2->getBusInterface();\r\n\r\n    QSharedPointer<Component> component1 = endPoint1->getOwnerComponent();\r\n    QSharedPointer<Component> component2 = endPoint2->getOwnerComponent();\r\n\r\n    Q_ASSERT(busIf1);\r\n    Q_ASSERT(component1);\r\n    Q_ASSERT(busIf2);\r\n    Q_ASSERT(component2);\r\n\r\n    setTableHeaders();\r\n\r\n    QList<QSharedPointer<PortMap> > portMaps1 = getPortMapsForEndPoint(endPoint1, busIf1);\r\n    QList<QSharedPointer<PortMap> > portMaps2 = getPortMapsForEndPoint(endPoint2, busIf2);\r\n\r\n    // Get the abstraction def for the interfaces.\r\n    VLNV absDefVLNV = findAbstractionVLNV(endPoint1, busIf1);\r\n    \r\n    QSharedPointer<AbstractionDefinition> absDef;\r\n\tauto absDefFinder = QSharedPointer<ListParameterFinder>(new ListParameterFinder());\r\n    auto absDefParser = QSharedPointer<IPXactSystemVerilogParser>(new IPXactSystemVerilogParser(absDefFinder));\r\n    if (library_->getDocumentType(absDefVLNV) == VLNV::ABSTRACTIONDEFINITION)\r\n    {\r\n        absDef = library_->getModel(absDefVLNV).staticCast<AbstractionDefinition>();\r\n\t\tabsDefFinder->setParameterList(absDef->getParameters());\r\n    }\r\n\r\n    General::InterfaceMode mode1 = busIf1->getInterfaceMode();\r\n    General::InterfaceMode mode2 = busIf2->getInterfaceMode();\r\n\r\n\t// find the physical ports mapped to given logical port\r\n\tfor (QString const& logicalPort : getAllLogicalPorts(portMaps1, portMaps2))\r\n    {\r\n\t\tbool validAbstraction = absDef && absDef->hasPort(logicalPort, mode1) && absDef->hasPort(logicalPort, mode2);\r\n\r\n\t\tfor (QSharedPointer<PortMap> map1 : portMaps1)\r\n        {\r\n\t\t\tif (map1->getLogicalPort()->name_.compare(logicalPort) == 0)\r\n            {\r\n\t\t\t\tfor (QSharedPointer<PortMap> map2 : portMaps2)\r\n                {\r\n\t\t\t\t\tif (map2->getLogicalPort()->name_.compare(logicalPort) == 0)\r\n                    {\r\n                        //! TODO: add checking for mapped tied values.\r\n                        if (map1->getLogicalPort() && map1->getPhysicalPort() &&\r\n                            map2->getLogicalPort() && map2->getPhysicalPort())\r\n                        {\r\n\t\t\t\t\t\t\taddMap(map1, component1, busIf1, firstInstanceParser,\r\n                                map2, component2, busIf2, secondInstanceParser,\r\n                                absDef, absDefParser, validAbstraction);\r\n                        }\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\t// Finally, set sorting back on.\r\n\tportWidget_.setSortingEnabled(true);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ConnectionEditor::createInstanceFinder()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<ExpressionParser> ConnectionEditor::createInstanceParser(\r\n    QSharedPointer<Component> component,\r\n    ConnectionEndpoint const* endPoint,\r\n    QSharedPointer<ListParameterFinder> designFinder)\r\n{\r\n\tQSharedPointer<ParameterConfigurableElementFinder> cevFinder(new ParameterConfigurableElementFinder());\r\n    cevFinder->setParameterList(component->getParameters());\r\n\tif (endPoint->parentItem())\r\n\t{\r\n\t\tauto firstComponentItem = dynamic_cast<ComponentItem*>(endPoint->parentItem());\r\n\t\tif (firstComponentItem)\r\n\t\t{\r\n            cevFinder->setCEVList(firstComponentItem->getComponentInstance()->getConfigurableElementValues());\r\n\t\t}\r\n\t}\r\n\r\n\tQString activeView = getActiveViewForEndPoint(endPoint);\r\n\r\n    auto instanceFinder = QSharedPointer<MultipleParameterFinder>(new MultipleParameterFinder());\r\n    instanceFinder->addFinder(cevFinder);\r\n    instanceFinder->addFinder(designFinder);\r\n\r\n\tauto expressionParser = QSharedPointer<IPXactSystemVerilogParser>(new IPXactSystemVerilogParser(instanceFinder));\r\n    return expressionParser;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: connectioneditor::getPortMapsForEndPoint()\r\n//-----------------------------------------------------------------------------\r\nQList<QSharedPointer<PortMap> > ConnectionEditor::getPortMapsForEndPoint(ConnectionEndpoint* endPoint,\r\n    QSharedPointer<BusInterface> busInterface) const\r\n{\r\n    QString activeView;\r\n    if (endPoint->encompassingComp() && endPoint->encompassingComp()->getComponentInstance())\r\n    {\r\n        activeView = getActiveViewForEndPoint(endPoint);\r\n    }\r\n\r\n    return busInterface->getPortMapsForView(activeView);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: connectioneditor::getActiveViewForComponentInstance()\r\n//-----------------------------------------------------------------------------\r\nQString ConnectionEditor::getActiveViewForEndPoint(ConnectionEndpoint const* endPoint) const\r\n{\r\n    QString activeView;\r\n\r\n    if (diagram_)\r\n    {\r\n        if (!endPoint->encompassingComp())\r\n        {\r\n            activeView = diagram_->getTopView();\r\n        }\r\n\r\n        else if (endPoint->encompassingComp() && endPoint->encompassingComp()->getComponentInstance() &&\r\n            diagram_->getDesignConfiguration())\r\n        {\r\n            QSharedPointer<DesignConfiguration> configuration = diagram_->getDesignConfiguration();\r\n            QSharedPointer<ComponentInstance> instance = endPoint->encompassingComp()->getComponentInstance();\r\n            activeView = configuration->getActiveView(instance->getInstanceName());\r\n        }\r\n    }\r\n\r\n    return activeView;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ConnectionEditor::setTableHeaders()\r\n//-----------------------------------------------------------------------------\r\nvoid ConnectionEditor::setTableHeaders()\r\n{\r\n    ComponentItem* componentItem1 = connection_->endpoint1()->encompassingComp();\r\n    if (componentItem1)\r\n    {\r\n        portWidget_.horizontalHeaderItem(0)->setText(componentItem1->name());\r\n    }\r\n    else // if was the interface of a top component\r\n    {\r\n        QSharedPointer<Component> component1 = connection_->endpoint1()->getOwnerComponent();\r\n        portWidget_.horizontalHeaderItem(0)->setText(component1->getVlnv().getName());\r\n    }\r\n\r\n    ComponentItem* componentItem2 = connection_->endpoint2()->encompassingComp();\r\n    if (componentItem2)\r\n    {\r\n        portWidget_.horizontalHeaderItem(1)->setText(componentItem2->name());\r\n    }\r\n    else // if was the interface of a top component\r\n    {\r\n        QSharedPointer<Component> component2 = connection_->endpoint2()->getOwnerComponent();\r\n        portWidget_.horizontalHeaderItem(1)->setText(component2->getVlnv().getName());\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ConnectionEditor::getAllLogicalPorts()\r\n//-----------------------------------------------------------------------------\r\nQStringList ConnectionEditor::getAllLogicalPorts(QList<QSharedPointer<PortMap> > const& portMaps1,\r\n    QList<QSharedPointer<PortMap> > const& portMaps2) const\r\n{\r\n    QStringList logicalNames;\r\n\r\n    for (QSharedPointer<PortMap> map : portMaps1)\r\n    {\r\n        logicalNames.append(map->getLogicalPort()->name_);\r\n    }\r\n    for (QSharedPointer<PortMap> map : portMaps2)\r\n    {\r\n        logicalNames.append(map->getLogicalPort()->name_);\r\n    }\r\n    logicalNames.removeDuplicates();\r\n    \r\n    return logicalNames;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ConnectionEditor::addMap()\r\n//-----------------------------------------------------------------------------\r\nvoid ConnectionEditor::addMap(QSharedPointer<PortMap> portMap1,\r\n    QSharedPointer<Component> component1,\r\n\tQSharedPointer<BusInterface> firstBus,\r\n    QSharedPointer<ExpressionParser> firstParser,\r\n    QSharedPointer<PortMap> portMap2,\r\n    QSharedPointer<Component> component2,\r\n\tQSharedPointer<BusInterface> secondBus,\r\n    QSharedPointer<ExpressionParser> secondParser,\r\n\tQSharedPointer<AbstractionDefinition> absDef,\r\n\tQSharedPointer<ExpressionParser> absDefParser,\r\n    bool validAbstraction)\r\n{\r\n\tauto [firstLeftBound, firstRightBound]  = calculateMappedPhysicalPortBounds(firstParser, portMap1, component1);\r\n\tint left1 = qMax(firstLeftBound, firstRightBound);\r\n\tint right1 = qMin(firstLeftBound, firstRightBound);\r\n\r\n\tauto [secondLeftBound, secondRightBound] = calculateMappedPhysicalPortBounds(secondParser, portMap2, component2);\r\n\tint left2 = qMax(secondLeftBound, secondRightBound);\r\n\tint right2 = qMin(secondLeftBound, secondRightBound);\r\n\r\n    if (portMap1->getLogicalPort()->range_ && portMap2->getLogicalPort()->range_)\r\n    {\r\n\t\tauto [firstLogicalHigh, firstLogicalLow] = calculateMappedLogicalPortBounds(firstParser, portMap1, absDefParser, absDef, firstBus);\r\n\t\tauto [secondLogicalHigh, secondLogicalLow] = calculateMappedLogicalPortBounds(secondParser, portMap2, absDefParser, absDef, secondBus);\r\n\r\n        if (firstLogicalLow > secondLogicalHigh || firstLogicalHigh < secondLogicalLow)\r\n        {\r\n            // If the maps have 0 common logical bits, do not create a row.\r\n            return;\r\n        }\r\n\r\n        // Find the matching ranges for the physical ports based on the logical ranges.\r\n        int logicalHigh = qMin(firstLogicalHigh, secondLogicalHigh);\r\n        int logicalLow = qMax(firstLogicalLow, secondLogicalLow);\r\n\r\n        int firstDownSize = abs(firstLogicalHigh - logicalHigh);\r\n        int firstUpSize = abs(logicalLow - firstLogicalLow);\r\n\r\n        left1 = (left1 - firstDownSize);\r\n        right1 = (right1 + firstUpSize);\r\n\r\n        int secondDownSize = abs(secondLogicalHigh - logicalHigh);\r\n        int secondUpSize = abs(logicalLow - secondLogicalLow);\r\n\r\n        left2 = (left2 - secondDownSize);\r\n        right2 = (right2 + secondUpSize);\r\n    }\r\n\r\n    int size1 = abs(left1 - right1) + 1;\r\n    int size2 = abs(left2 - right2) + 1;\r\n\r\n    bool hasMatchingSizes = (size1 == size2);\r\n    bool phys1IsValid = validAbstraction && hasMatchingSizes && isValidPhysicalPort(portMap1, component1);\r\n    bool phys2IsValid = validAbstraction && hasMatchingSizes && isValidPhysicalPort(portMap2, component2);\r\n\r\n    QTableWidgetItem* port1Item = createPortItem(portMap1->getPhysicalPort()->name_, left1, right1, phys1IsValid);\r\n    QTableWidgetItem* port2Item = createPortItem(portMap2->getPhysicalPort()->name_, left2, right2, phys2IsValid);\r\n\r\n    int row = portWidget_.rowCount();\r\n    portWidget_.insertRow(row);\r\n    portWidget_.setItem(row, 0, port1Item);\r\n    portWidget_.setItem(row, 1, port2Item);   \r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ConnectionEditor::createPortItem()\r\n//-----------------------------------------------------------------------------\r\nQTableWidgetItem* ConnectionEditor::createPortItem(QString const& portName, int left, int right, bool isValid)\r\n{\r\n    QString itemText = portName + QStringLiteral(\"[%1..%2]\").arg(left).arg(right);\r\n\r\n    QTableWidgetItem* portItem = new QTableWidgetItem(itemText);\r\n\r\n    portItem->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);\r\n\r\n    if (isValid)\r\n    {\r\n        portItem->setForeground(QBrush(Qt::black));\r\n    }\r\n    else \r\n    {\r\n        portItem->setForeground(QBrush(Qt::red));\r\n    }\r\n\r\n    return portItem;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: connectioneditor::calculateMappedPortBounds()\r\n//-----------------------------------------------------------------------------\r\nQPair<int, int> ConnectionEditor::calculateMappedPhysicalPortBounds(QSharedPointer<ExpressionParser> parser,\r\n    QSharedPointer<PortMap> containingPortMap, QSharedPointer<Component> containingComponent)\r\n{\r\n    int physicalLeft = 0;\r\n    int physicalRight = 0;\r\n\r\n    QSharedPointer<PortMap::PhysicalPort> physicalPort = containingPortMap->getPhysicalPort();\r\n    if (physicalPort && physicalPort->partSelect_)\r\n    {\r\n        physicalLeft = parser->parseExpression(physicalPort->partSelect_->getLeftRange()).toInt();\r\n        physicalRight = parser->parseExpression(physicalPort->partSelect_->getRightRange()).toInt();\r\n    }\r\n    else if (containingComponent->hasPort(physicalPort->name_))\r\n    {\r\n        QSharedPointer<Port> componentPort = containingComponent->getPort(physicalPort->name_);\r\n        physicalLeft =  parser->parseExpression(componentPort->getLeftBound()).toInt();\r\n        physicalRight = parser->parseExpression(componentPort->getRightBound()).toInt();\r\n    }\r\n\r\n    QPair<int, int> portBounds(physicalLeft, physicalRight);\r\n    return portBounds;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: connectioneditor::isValidPhysicalPort()\r\n//-----------------------------------------------------------------------------\r\nbool ConnectionEditor::isValidPhysicalPort(QSharedPointer<PortMap> containingPortMap,\r\n    QSharedPointer<Component> containingComponent)\r\n{\r\n    return containingComponent->hasPort(containingPortMap->getPhysicalPort()->name_);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: connectioneditor::calculateMappedLogicalPortBounds()\r\n//-----------------------------------------------------------------------------\r\nQPair<int, int> ConnectionEditor::calculateMappedLogicalPortBounds(\r\n    QSharedPointer<ExpressionParser> instanceParser,\r\n    QSharedPointer<PortMap> containingPortMap,\r\n    QSharedPointer<ExpressionParser> absDefParser,\r\n\tQSharedPointer<AbstractionDefinition> absDef,\r\n\tQSharedPointer<BusInterface> busInterface)\r\n{\r\n    int logicalHigh = 0;\r\n    int logicalLow = 0;\r\n\r\n    if (containingPortMap->getLogicalPort()->range_)\r\n    {\r\n        int logicalLeft = instanceParser->parseExpression(containingPortMap->getLogicalPort()->range_->getLeft()).toInt();\r\n        int logicalRight = instanceParser->parseExpression(containingPortMap->getLogicalPort()->range_->getRight()).toInt();\r\n\r\n        logicalHigh = qMax(logicalLeft, logicalRight);\r\n        logicalLow = qMin(logicalLeft, logicalRight);\r\n    }\r\n\telse if (auto portName = containingPortMap->getLogicalPort()->name_;\r\n\t\tabsDef && absDef->hasPort(portName, busInterface->getInterfaceMode()))\r\n    {\r\n\t\tauto logicalPort = absDef->getPort(portName);\r\n\t\tQString logicalWidth = \"\";\r\n\t\tif (logicalPort->hasWire())\r\n\t\t{\r\n\t\t\tlogicalWidth = absDefParser->parseExpression(logicalPort->getWire()->getWidth(busInterface->getInterfaceMode(), busInterface->getSystem()));\r\n\t\t}\r\n\t\telse if (logicalPort->hasTransactional())\r\n\t\t{\r\n\t\t\tlogicalWidth = absDefParser->parseExpression(logicalPort->getTransactional()->getWidth(busInterface->getInterfaceMode(), busInterface->getSystem()));\r\n\t\t}\r\n\r\n        logicalHigh = logicalWidth.toInt() - 1;\r\n    }\r\n\r\n    QPair<int, int> logicalBounds(logicalHigh, logicalLow);\r\n    return logicalBounds;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ConnectionEditor::setupLayout()\r\n//-----------------------------------------------------------------------------\r\nvoid ConnectionEditor::setupLayout()\r\n{\r\n    auto nameLayout = new QGridLayout(&nameGroup_);\r\n    nameLayout->addWidget(&nameLabel_, 0, 0);\r\n    nameLayout->addWidget(&nameEdit_, 0, 1);\r\n    nameLayout->addWidget(&descriptionLabel_, 1, 0);\r\n    nameLayout->addWidget(&descriptionEdit_, 1, 1);\r\n\r\n    QGridLayout* layout = new QGridLayout(this);\r\n    layout->addWidget(&instanceLabel_, 0, 0, 1, 1);\r\n    layout->addWidget(&connectedInstances_, 0, 1, 1, 1);\r\n    layout->addWidget(&type_, 1, 0, 1, 2);\r\n    layout->addWidget(&absType_, 2, 0, 1, 2);\r\n\r\n    layout->addWidget(&nameGroup_, 3, 0, 1, 2);\r\n    layout->addWidget(&portsLabel_, 4, 0, 1, 2);\r\n    layout->addWidget(connectionTypeTable_, 5, 0, 1, 2);\r\n\r\n    layout->setColumnStretch(1, 1);\r\n    layout->setRowStretch(5, 1);\r\n}\r\n"
  },
  {
    "path": "editors/common/ConnectionEditor/connectioneditor.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: connectioneditor.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 14.10.2011\r\n//\r\n// Description:\r\n// Editor to display/edit details of a connection.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef CONNECTIONEDITOR_H\r\n#define CONNECTIONEDITOR_H\r\n\r\n#include \"AdHocBoundsModel.h\"\r\n\r\n#include <common/widgets/vlnvDisplayer/vlnvdisplayer.h>\r\n\r\n#include <IPXACTmodels/Component/PortMap.h>\r\n\r\n#include <IPXACTmodels/generaldeclarations.h>\r\n\r\n#include <QWidget>\r\n#include <QLineEdit>\r\n#include <QLabel>\r\n#include <QTableWidget>\r\n#include <QPlainTextEdit>\r\n#include <QGroupBox>\r\n#include <QString>\r\n#include <QSharedPointer>\r\n#include <QStackedWidget>\r\n\r\nclass DesignDiagram;\r\nclass ExpressionParser;\r\nclass GraphicsConnection;\r\nclass LibraryInterface;\r\nclass BusInterface;\r\nclass Component;\r\nclass ConnectionEndpoint;\r\nclass ComponentInstance;\r\nclass ParameterConfigurableElementFinder;\r\nclass MultipleParameterFinder;\r\nclass ListParameterFinder;\r\nclass AbstractionDefinition;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Editor to display/edit details of a connection.\r\n//-----------------------------------------------------------------------------\r\nclass ConnectionEditor : public QWidget\r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\r\n\t/*! The constructor\r\n\t *\r\n\t *    @param [in] library     The instance that manages the library\r\n     *    @param [in] parent      The owner of this editor.\r\n\t *\r\n\t*/\r\n\tConnectionEditor(LibraryInterface* library, QWidget* parent);\r\n\t\r\n\t//! The destructor\r\n\tvirtual ~ConnectionEditor() = default;\r\n\r\npublic slots:\r\n\r\n\t/*! Set the connection to be edited.\r\n\t *\r\n\t *    @param [in] connection The connection to edit.\r\n\t *\r\n\t*/\r\n\tvoid setConnection(GraphicsConnection* connection, DesignDiagram* diagram);\r\n\r\n\t/*! Clear the editor so no connection details are shown\r\n\t *\r\n\t*/\r\n\tvoid clear();\r\n\r\n\t/*! Refresh the editor contents without changing the connection.\r\n\t *\r\n\t*/\r\n\tvoid refresh();\r\n\r\nprivate slots:\r\n\r\n    //! Called when name or description is edited.\r\n\tvoid onNameOrDescriptionChanged();\r\n\r\nprivate:\r\n\t//! No copying\r\n\tConnectionEditor(const ConnectionEditor& other);\r\n\r\n\t//! No assignment\r\n\tConnectionEditor& operator=(const ConnectionEditor& other);\r\n\r\n    /*!\r\n     *  Finds the VLNV for the bus abstraction.\r\n     *\r\n     *    @param [in] endPoint        The selected bus interface end point.\r\n     *    @param [in] busInterface    The bus interface whose abstraction definition VLNV to find.\r\n     *\r\n     *    @return The VLNV for the given bus interface abstraction definition.\r\n     */\r\n    VLNV findAbstractionVLNV(ConnectionEndpoint* endPoint, QSharedPointer<BusInterface> busInterface) const;\r\n\r\n\t/*!\r\n\t *  Set port maps so that editor displays the connected physical ports.\r\n\t *\r\n\t *    @param [in] firstInstanceParser   Parser for the first connected end point.\r\n\t *    @param [in] secondInstanceParser  Parser for the second connected end point.\r\n\t */\r\n\tvoid setPortMaps(QSharedPointer<ExpressionParser> firstInstanceParser, QSharedPointer<ExpressionParser> secondInstanceParser);\r\n\r\n    /*!\r\n     *  Create an expression parser for the selected component end point.\r\n     *\r\n     *    @param [in] component     Component containing the end point.\r\n     *    @param [in] endPoint      The selected end point.\r\n     *    @param [in] designFinder  Parameter finder for design parameters.\r\n     *\r\n     *    @return Expression parser for the selected end point.\r\n     */\r\n    QSharedPointer<ExpressionParser> createInstanceParser(\r\n        QSharedPointer<Component> component,\r\n        ConnectionEndpoint const* endPoint,\r\n        QSharedPointer<ListParameterFinder> designFinder);\r\n\r\n    /*!\r\n     *  Create an expression parser data set for the selected ad-hoc end point.\r\n     *\r\n     *    @param [in] endPoint              The selected ad-hoc end point.\r\n     *    @param [in] instanceParser        Expression parser for the component instance containing the selected end point.\r\n     *    @param [in] containingComponent   The component containing the end point.\r\n     *\r\n     *    @return Expression parser data set for the selected ad-hoc end point.\r\n     */\r\n    QSharedPointer<AdHocBoundsModel::endPointParser> createAdHocBoundsParser(ConnectionEndpoint const* endPoint,\r\n        QSharedPointer<ExpressionParser> instanceParser,\r\n        QSharedPointer<Component> containingComponent) const;\r\n\r\n    //! Sets the headers for the port connection table.\r\n    void setTableHeaders();\r\n\r\n    /*!\r\n     *  Finds the names of all logical ports mapped in the given port maps.\r\n     *\r\n     *    @param [in] portMaps1   Port maps for first interface.\r\n     *    @param [in] portMaps2   Port maps for second interface.\r\n     *\r\n     *    @return The names of all logical ports.\r\n     */\r\n    QStringList getAllLogicalPorts(QList<QSharedPointer<PortMap> > const& portMaps1, \r\n        QList<QSharedPointer<PortMap> > const& portMaps2) const;\r\n\r\n\t/*!\r\n\t *  Add a mapping for physical ports to port widget for two given port maps.\r\n\t *\r\n\t *    @param [in] portMap1          The first port map.\r\n\t *    @param [in] component1        The component that contains the port map1.\r\n\t *    @param [in] firstBus          The bus interface containing the first port map.\r\n\t *    @param [in] firstParser       Parser for the first component instance.\r\n\t *    @param [in] portMap2          The second port map.\r\n\t *    @param [in] component2        The component that contains the port map2.\r\n\t *    @param [in] secondBus         The bus interface containing the second port map.\r\n\t *    @param [in] secondParser      Parser for the second component instance.\r\n\t *    @param [in] absDef            The used abstraction definition.\r\n\t *    @param [in] absDefParser      Parser for the abstraction definition.\r\n\t *    @param [in] validAbstraction  Flag for valid abstraction definitions.\r\n\t */\r\n\tvoid addMap(QSharedPointer<PortMap> portMap1,\r\n        QSharedPointer<Component> component1,\r\n        QSharedPointer<BusInterface> firstBus,\r\n\t\tQSharedPointer<ExpressionParser> firstParser,\r\n\t\tQSharedPointer<PortMap> portMap2,\r\n        QSharedPointer<Component> component2,\r\n\t\tQSharedPointer<BusInterface> secondBus,\r\n\t\tQSharedPointer<ExpressionParser> secondParser,\r\n        QSharedPointer<AbstractionDefinition> absDef,\r\n        QSharedPointer<ExpressionParser> absDefParser,\r\n        bool validAbstraction);\r\n\r\n    /*!\r\n     *  Creates an item for the port connectivity table.\r\n     *\r\n     *    @param [in] portName    The name of the port.\r\n     *    @param [in] left        The left bound of the port.\r\n     *    @param [in] right       The right bound of the port.\r\n     *    @param [in] isValid     Is the port connectivity valid or not.\r\n     *\r\n     *    @return Item for the port connectivity table representing the given port.\r\n     */\r\n    QTableWidgetItem* createPortItem(QString const& portName, int left, int right, bool isValid);\r\n\r\n    /*!\r\n     *  Calculate mapped physical port bounds.\r\n     *\r\n     *    @param [in] parser                  The used expression parser.\r\n     *    @param [in] containingPortMap       The port map containing the mapped physical port.\r\n     *    @param [in] containingComponent     The component containing the physical port.\r\n     *\r\n     *    @return Integer pair, where the first is the left bound, and the second is the right bound.\r\n     */\r\n    QPair<int, int> calculateMappedPhysicalPortBounds(QSharedPointer<ExpressionParser> parser,\r\n        QSharedPointer<PortMap> containingPortMap, QSharedPointer<Component> containingComponent);\r\n\r\n    /*!\r\n     *  Check if the mapped physical port is not valid.\r\n     *\r\n     *    @param [in] invalid                 The current validity of the connection.\r\n     *    @param [in] containingPortMap       Port map containing the physical port.\r\n     *    @param [in] containingComponent     Component containing the referenced physical port.\r\n     *\r\n     *    @return True, if the physical port is not valid, otherwise false.\r\n     */\r\n    bool isValidPhysicalPort (QSharedPointer<PortMap> containingPortMap,\r\n        QSharedPointer<Component> containingComponent);\r\n\r\n    /*!\r\n     *  Calculate the mapped logical port bounds.\r\n     *\r\n     *    @param [in] instanceParser        Expression parser for the containing component instance.\r\n     *    @param [in] containingPortMap     The port map containing the logical port.\r\n     *    @param [in] absDefParser          Parser for the used abstraction definition.\r\n     *    @param [in] absDef                The used abstraction definition.\r\n     *    @param [in] busInterface          The end point bus interface.\r\n     *\r\n     *    @return Integer pair, where the first value is the higher bound and the second value is the lower bound.\r\n     */\r\n    QPair<int, int> calculateMappedLogicalPortBounds(\r\n        QSharedPointer<ExpressionParser> instanceParser,\r\n        QSharedPointer<PortMap> containingPortMap,\r\n\t\tQSharedPointer<ExpressionParser> absDefParser,\r\n\t\tQSharedPointer<AbstractionDefinition> absDef,\r\n        QSharedPointer<BusInterface> busInterface);\r\n    \r\n    /*!\r\n     *  Sets the editor layout.\r\n     */\r\n    void setupLayout();\r\n\r\n    /*!\r\n     *  Get the port maps for the selected bus interface end point.\r\n     *\r\n     *    @param [in] endPoint        The selected end point.\r\n     *    @param [in] busInterface    The bus interface contained within the selected end point.\r\n     *\r\n     *    @return A list of port maps contained within the selected end point\r\n     */\r\n    QList<QSharedPointer<PortMap> > getPortMapsForEndPoint(ConnectionEndpoint* endPoint,\r\n        QSharedPointer<BusInterface> busInterface) const;\r\n\r\n    /*!\r\n     *  Get the active view for the item containing the selected end point item.\r\n     *\r\n     *    @param [in] endPoint    The selected end point.\r\n     *\r\n     *    @return The name of the active view containing the selected end point item.\r\n     */\r\n    QString getActiveViewForEndPoint(ConnectionEndpoint const* endPoint) const;\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n\t//! Widget to display the connection type (COM/API/bus type).\r\n\tVLNVDisplayer type_;\r\n\r\n\t//! Widget to display the abstraction type.\r\n\tVLNVDisplayer absType_;\r\n\r\n\t//! Label for connected instances.\r\n\tQLabel instanceLabel_;\r\n\r\n\t//! Label to display the connected interfaces.\r\n\tQLabel connectedInstances_;\r\n\r\n\t//! Used to separate the connected interfaces from name edit\r\n\tQGroupBox nameGroup_;\r\n\r\n\t//! Label for connection name.\r\n\tQLabel nameLabel_;\r\n\r\n\t//! Editor to set the name of the interconnection.\r\n\tQLineEdit nameEdit_;\r\n\r\n\t//! Label for description.\r\n\tQLabel descriptionLabel_;\r\n\r\n\t//! Editor for description.\r\n\tQPlainTextEdit descriptionEdit_;\r\n\r\n\t//! Label for port widget.\r\n\tQLabel portsLabel_;\r\n\r\n\t//! Widget to display the port connections.\r\n\tQTableWidget portWidget_;\r\n\r\n\t//! The connection being edited.\r\n\tGraphicsConnection* connection_;\r\n\r\n    //! The diagram containing the connection.\r\n    DesignDiagram* diagram_;\r\n\r\n\t//! The instance that manages the library\r\n\tLibraryInterface* library_;\r\n\r\n    //! The port ad-hoc bounds table.\r\n    QTableView adHocBoundsTable_;\r\n\r\n    //! The ad-hoc bounds model.\r\n    AdHocBoundsModel adHocBoundsModel_;\r\n\r\n    //! Stack containing the connection types.\r\n    QStackedWidget* connectionTypeTable_;\r\n};\r\n\r\n#endif // CONNECTIONEDITOR_H\r\n"
  },
  {
    "path": "editors/common/DefaultRouting.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: DefaultRouting.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Esko Pekkarinen\n// Date: 25.09.2017\n//\n// Description:\n// Default routing creation for design connections.\n//-----------------------------------------------------------------------------\n\n#include \"DefaultRouting.h\"\n\n//-----------------------------------------------------------------------------\n// Function: DefaultRouting::createRoute()\n//-----------------------------------------------------------------------------\nQList<QPointF> DefaultRouting::createRoute(QPointF const& p1, QPointF const& p2, \n    QVector2D const& dir1, QVector2D const& dir2)\n{\n    // If any of directions has x,y = (0,0), then the function \n    // will stuck in the while loop (which means freeze and subsequent crash of the program.\n    Q_ASSERT(!dir1.isNull() || !dir2.isNull());\n\n    // Add the start position to the list of path points.\n    QList<QPointF> points;\n    points.append(p1);\n\n    if (p1 == p2)\n    {\n        return points;\n    }\n\n    // Convert the points to vectors.\n    QVector2D startPos = QVector2D(p1);\n    QVector2D endPos = QVector2D(p2);\n\n    // Sets the start position as the current position.\n    QVector2D curPos = startPos;\n    QVector2D curDir = dir1;\n\n    // Set the target position based on the end point's direction.\n    QVector2D targetPos = QVector2D(p2) + dir2 * MIN_START_LENGTH;\n\n    // Find a route to the target.\n    while (curPos != targetPos)\n    {\n        // Calculate the delta.\n        QVector2D delta = targetPos - curPos;\n        qreal dot = QVector2D::dotProduct(delta, curDir);\n        qreal endDot = QVector2D::dotProduct(delta, dir2);\n\n        // Calculate the projection onto the current direction and the perpendicular part.\n        QVector2D proj = dot * curDir;\n        QVector2D perp = delta - proj;\n\n        // Check if we can draw a direct line to the target from the current position.\n        if (dot > 0.0 && qFuzzyCompare(delta, proj) && endDot <= 0.0)\n        {\n            curPos = targetPos;\n        }\n        else \n        {\n            // Otherwise draw at least some distance to the current direction.\n            // Check if the target is not behind the current position/direction.\n            if (qFuzzyCompare(curPos, startPos))\n            {\n                if (dot > 0.0 && !(endDot > 0.0 && qFuzzyCompare(delta, endDot * dir2)))\n                {\n                    // Draw the length of the projection to the current direction\n                    // or at least the minimum length.\n                    curPos = curPos + curDir * qMax(MIN_START_LENGTH, proj.length());\n                }\n                else\n                {\n                    // Otherwise we just draw the minimum length thub.\n                    curPos = curPos + curDir * MIN_START_LENGTH;\n                }\n            }\n            // Check if the target is in the opposite direction compared to the current\n            // direction and we previously draw the starting thub.\n            else if (dot < 0.0 && qFuzzyCompare(curPos, startPos + curDir * MIN_START_LENGTH))\n            {\n                // Draw to the perpendicular direction at least the minimum length.\n                qreal length = qMax(perp.length(), MIN_LENGTH);\n                QVector2D dir = perp.normalized();\n\n                // Special case when the perpendicular vector would be zero-length.\n                if (dir.isNull())\n                {\n                    // Rotate 90 degrees.\n                    dir = QVector2D(curDir.y(), -curDir.x());\n                }\n\n                curPos = curPos + dir * length;\n                curDir = dir;\n            }\n            else\n            {\n                // Otherwise we just draw to the perpendicular direction as much as we can.\n                if (!perp.isNull())\n                {\n                    curPos = curPos + perp;\n                    curDir = perp.normalized();\n                }\n                else\n                {\n                    // If the perpendicular vector was zero-length, we rotate the current\n                    // direction 90 degrees and draw a minimum length thub to the new direction.\n                    curDir = QVector2D(curDir.y(), -curDir.x());\n                    curPos = curPos + curDir * MIN_LENGTH;\n                }\n            }\n\n            // Check if we would end up in a position where we are right behind the target.\n            QVector2D newDelta = targetPos - curPos;\n            qreal endDot = QVector2D::dotProduct(newDelta, dir2);\n\n            if (endDot > 0.0 && qFuzzyCompare(newDelta, endDot * dir2) &&\n                !qFuzzyCompare(curPos, startPos + curDir * MIN_START_LENGTH))\n            {\n                // Make an adjustment to the current position.\n                curPos += curDir * MIN_LENGTH;\n            }\n        }\n\n        // Add the newly calculated current position to the path.\n        points.append(curPos.toPointF());\n    }\n\n    // Add the last segment if the target position was not the end position.\n    if (!qFuzzyCompare(targetPos, endPos))\n    {\n        points.append(endPos.toPointF());\n    }\n\n    // Simplify path.\n    if (points.size() >= 3)\n    {\n        for (int i = 0; i < points.size() - 2; ++i)\n        {\n            QVector2D delta1 = QVector2D(points.at(i + 1) - points.at(i));\n            QVector2D delta2 = QVector2D(points.at(i + 2) - points.at(i + 1));\n\n            QVector2D deltaProj = QVector2D::dotProduct(delta2, delta1.normalized()) * delta1.normalized();\n\n            // If the path was otherwise ok, just remove parallel lines.\n            if (qFuzzyCompare(deltaProj, delta2))\n            {\n                points.removeAt(i + 1);\n                i--;\n            }                                \n        }\n    }\n\n    return points;\n}\n"
  },
  {
    "path": "editors/common/DefaultRouting.h",
    "content": "//-----------------------------------------------------------------------------\n// File: DefaultRouting.h\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Esko Pekkarinen\n// Date: 25.09.2017\n//\n// Description:\n// Default routing creation for design connections.\n//-----------------------------------------------------------------------------\n\n#ifndef DEFAULTROUTING_H\n#define DEFAULTROUTING_H\n\n#include <QList>\n#include <QPointF>\n#include <QVector2D>\n\n\nnamespace DefaultRouting \n{\n    float const MIN_LENGTH = 10.0f;\n    float const MIN_START_LENGTH = 20.0f;\n\n    /*!\n     *  Creates an optimal route from point p1 to point p2, considering the given start and exit directions.\n     */\n    QList<QPointF> createRoute(QPointF const& p1, QPointF const& p2, QVector2D const& dir1, QVector2D const& dir2);\n\n};\n\n#endif // DEFAULTROUTING_H"
  },
  {
    "path": "editors/common/DesignCompletionModel.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: DesignCompletionModel.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Esko Pekkarinen\r\n// Date: 13.01.2015\r\n//\r\n// Description:\r\n// Completion model for parameter names in a design.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"DesignCompletionModel.h\"\r\n\r\n#include <editors/ComponentEditor/parameters/ComponentParameterColumns.h>\r\n\r\n#include <QIcon>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignCompletionModel::DesignCompletionModel()\r\n//-----------------------------------------------------------------------------\r\nDesignCompletionModel::DesignCompletionModel(QSharedPointer<ParameterFinder> topComponentFinder, \r\n    QSharedPointer<ParameterFinder> parameterFinder, QObject *parent):\r\n    ComponentParameterModel(parameterFinder, parent),\r\n        topFinder_(topComponentFinder)\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignCompletionModel::~DesignCompletionModel()\r\n//-----------------------------------------------------------------------------\r\nDesignCompletionModel::~DesignCompletionModel()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignCompletionModel::data()\r\n//-----------------------------------------------------------------------------\r\nQVariant DesignCompletionModel::data(QModelIndex const& index, int role /*= Qt::DisplayRole*/) const\r\n{\r\n    if (!index.isValid())\r\n    {\r\n        return QVariant();\r\n    }\r\n\r\n    if (role == Qt::DecorationRole && index.column() == ComponentParameterColumns::NAME)\r\n    {\r\n        QString id = data(index.sibling(index.row(), ComponentParameterColumns::ID), Qt::DisplayRole).toString();\r\n        if (topFinder_->hasId(id))\r\n        {\r\n            return QIcon(\":icons/common/graphics/external.png\");\r\n        }\r\n        else\r\n        {\r\n            return QVariant();\r\n        }\r\n    }\r\n\r\n    return ComponentParameterModel::data(index, role);\r\n}\r\n"
  },
  {
    "path": "editors/common/DesignCompletionModel.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: DesignCompletionModel.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Esko Pekkarinen\r\n// Date: 19.03.2015\r\n//\r\n// Description:\r\n// Completion model for parameter names in a design.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef DESIGNCOMPLETIONMODEL_H\r\n#define DESIGNCOMPLETIONMODEL_H\r\n\r\n#include <QAbstractItemModel>\r\n#include <QSharedPointer>\r\n\r\n#include <editors/ComponentEditor/parameters/ComponentParameterModel.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Completion model for parameter names in a design.\r\n//-----------------------------------------------------------------------------\r\nclass DesignCompletionModel : public ComponentParameterModel\r\n{\r\n    Q_OBJECT\r\n\r\npublic:\r\n\r\n\t/*!\r\n\t *  The constructor.\r\n\t *\r\n\t *    @param [in] topComponentFinder      Finder for top component parameters.\r\n\t *    @param [in] parameterFinder         Finder for all available parameters.\r\n\t *    @param [in] parent                  The parent object.\r\n\t */\r\n\tDesignCompletionModel(QSharedPointer<ParameterFinder> topComponentFinder, \r\n        QSharedPointer<ParameterFinder> parameterFinder, QObject *parent);\r\n\r\n\t//! The destructor.\r\n\t~DesignCompletionModel();\r\n\r\n    /*!\r\n     *  Finds the data in the model for the given index.\r\n     *\r\n     *    @param [in] index   The index whose data to find.\r\n     *    @param [in] role    The role describing which aspect of the data to find.\r\n     *\r\n     *    @return The data in the given index.\r\n     */\r\n    virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;\r\n\r\nprivate:\r\n\r\n\t// Disable copying.\r\n\tDesignCompletionModel(DesignCompletionModel const& rhs);\r\n\tDesignCompletionModel& operator=(DesignCompletionModel const& rhs);\r\n\r\n    //! The finder for top component parameters.\r\n    QSharedPointer<ParameterFinder> topFinder_;\r\n};\r\n\r\n#endif // DESIGNCOMPLETIONMODEL_H\r\n"
  },
  {
    "path": "editors/common/DesignDiagram.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: DesignDiagram.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Joni-Matti Maatta\r\n// Date: 24.4.2012\r\n//\r\n// Description:\r\n// Base class for all design diagrams.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"DesignDiagram.h\"\r\n\r\n#include \"DesignWidget.h\"\r\n\r\n#include <common/IEditProvider.h>\r\n\r\n#include <common/graphicsItems/ComponentItem.h>\r\n#include <common/graphicsItems/GraphicsColumnLayout.h>\r\n#include <common/graphicsItems/ConnectionEndpoint.h>\r\n#include <common/graphicsItems/GraphicsColumnConstants.h>\r\n\r\n#include <editors/common/Association/Association.h>\r\n#include <editors/common/diagramgrid.h>\r\n#include <editors/common/StickyNote/StickyNote.h>\r\n#include <editors/common/StickyNote/StickyNoteAddCommand.h>\r\n#include <editors/HWDesign/AdhocEditor/AdHocVisibilityEditor.h>\r\n#include <editors/common/Association/AssociationAddCommand.h>\r\n\r\n#include <KactusAPI/include/LibraryInterface.h>\r\n\r\n#include <IPXACTmodels/Component/Component.h>\r\n#include <IPXACTmodels/Design/Design.h>\r\n#include <IPXACTmodels/common/GenericVendorExtension.h>\r\n#include <IPXACTmodels/kactusExtensions/Kactus2Group.h>\r\n#include <IPXACTmodels/kactusExtensions/Kactus2Position.h>\r\n\r\n#include <QApplication>\r\n#include <QGraphicsItem>\r\n#include <QMenu>\r\n#include <QPainter>\r\n#include <QSharedPointer>\r\n#include <QWidget>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignDiagram::DesignDiagram()\r\n//-----------------------------------------------------------------------------\r\nDesignDiagram::DesignDiagram(LibraryInterface* lh, QSharedPointer<IEditProvider> editProvider, \r\n    DesignWidget* parent) : \r\nQGraphicsScene(parent),\r\nparent_(parent),\r\nlh_(lh),\r\neditProvider_(editProvider),\r\ntopView_(\"\"),\r\ncomponent_(),\r\ndesign_(),\r\ndesignConf_(),\r\nlayout_(new GraphicsColumnLayout(this)),\r\nmode_(MODE_SELECT),\r\nloading_(false),\r\nlocked_(false),\r\ninteractionMode_(NORMAL),\r\nassociationLine_(0)\r\n{\r\n    setSceneRect(0, 0, 100000, 100000);\r\n\r\n    connect(this, SIGNAL(componentInstantiated(ComponentItem*)),\r\n        this, SLOT(onComponentInstanceAdded(ComponentItem*)), Qt::UniqueConnection);\r\n    connect(this, SIGNAL(componentInstanceRemoved(ComponentItem*)),\r\n        this, SLOT(onComponentInstanceRemoved(ComponentItem*)), Qt::UniqueConnection);\t\t\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignDiagram::~DesignDiagram()\r\n//-----------------------------------------------------------------------------\r\nDesignDiagram::~DesignDiagram()\r\n{\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignDiagram::clearScene()\r\n//-----------------------------------------------------------------------------\r\nvoid DesignDiagram::clearScene()\r\n{\r\n    clearLayout();\r\n    clear();    \r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignDiagram::setDesign()\r\n//-----------------------------------------------------------------------------\r\nbool DesignDiagram::setDesign(QSharedPointer<Component> component, QString const& selectedView,\r\n    QSharedPointer<Design> design, QSharedPointer<DesignConfiguration> designConf)\r\n{\r\n    // Deselect items.\r\n    emit clearItemSelection();\r\n    clearSelection();\r\n\r\n    // Clear the edit provider.\r\n    editProvider_->clear();\r\n\r\n    for (auto instanceItem : getInstances())\r\n    {\r\n        instanceItem->disconnect();\r\n    }\r\n\r\n    // Clear the scene.\r\n    clearScene();\r\n    getParent()->clearRelatedVLNVs();\r\n    getParent()->addRelatedVLNV(component->getVlnv());\r\n\r\n    // Set the new component and open the design.\r\n    topView_ = selectedView;\r\n    component_ = component;\r\n    design_ = design;\r\n    designConf_ = designConf;\r\n\r\n    loading_ = true;\r\n    loadDesign(design);\r\n    loadStickyNotes();\r\n\r\n    resetSceneRectangleForItems();\r\n\r\n    loading_ = false;\r\n\r\n    return true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignDiagram::resetSceneRectangleForItems()\r\n//-----------------------------------------------------------------------------\r\nvoid DesignDiagram::resetSceneRectangleForItems()\r\n{\r\n    QRectF requiredRectangle = itemsBoundingRect();\r\n    qreal requiredWidth = requiredRectangle.width() + GraphicsColumnConstants::MIN_Y_PLACEMENT;\r\n    qreal requiredHeight = requiredRectangle.height() + GraphicsColumnConstants::MIN_Y_PLACEMENT;\r\n\r\n    setSceneRect(0, 0, requiredWidth, requiredHeight + GraphicsColumnConstants::MIN_Y_PLACEMENT);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignDiagram::getTopView()\r\n//-----------------------------------------------------------------------------\r\nQString DesignDiagram::getTopView() const\r\n{\r\n    return topView_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignDiagram::attach()\r\n//-----------------------------------------------------------------------------\r\nvoid DesignDiagram::attach(AdHocVisibilityEditor* editor)\r\n{\r\n    connect(this, SIGNAL(contentChanged()), editor, SLOT(onContentChanged()), Qt::UniqueConnection);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignDiagram::detach()\r\n//-----------------------------------------------------------------------------\r\nvoid DesignDiagram::detach(AdHocVisibilityEditor* editor)\r\n{\r\n    disconnect(editor);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignDiagram::setMode()\r\n//-----------------------------------------------------------------------------\r\nvoid DesignDiagram::setMode(DrawMode mode)\r\n{\r\n    if (mode_ != mode)\r\n    {\r\n        mode_ = mode;\r\n\r\n        if (mode_ != MODE_SELECT)\r\n        {\r\n            emit clearItemSelection();\r\n        }\r\n\r\n        emit modeChanged(mode);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignDiagram::setProtection()\r\n//-----------------------------------------------------------------------------\r\nvoid DesignDiagram::setProtection(bool locked)\r\n{\r\n    locked_ = locked;\r\n    clearSelection();\r\n    emit clearItemSelection();\r\n\r\n    setProtectionForStickyNotes();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignDiagram::getMode()\r\n//-----------------------------------------------------------------------------\r\nDrawMode DesignDiagram::getMode() const\r\n{\r\n    return mode_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignDiagram::isProtected()\r\n//-----------------------------------------------------------------------------\r\nbool DesignDiagram::isProtected() const\r\n{\r\n    return locked_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignDiagram::getLibraryInterface()\r\n//-----------------------------------------------------------------------------\r\nLibraryInterface* DesignDiagram::getLibraryInterface() const\r\n{\r\n    return lh_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignDiagram::getEditProvider()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<IEditProvider> DesignDiagram::getEditProvider() const\r\n{\r\n    return editProvider_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignDiagram::getEditedComponent()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<Component> DesignDiagram::getEditedComponent() const\r\n{\r\n    return component_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignDiagram::getDesign()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<Design> DesignDiagram::getDesign() const\r\n{\r\n    return design_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignDiagram::getDesignConfiguration()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<DesignConfiguration> DesignDiagram::getDesignConfiguration() const\r\n{\r\n    return designConf_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignDiagram::onComponentInstanceAdded()\r\n//-----------------------------------------------------------------------------\r\nvoid DesignDiagram::onComponentInstanceAdded(ComponentItem* item)\r\n{\r\n    getParent()->addRelatedVLNV(item->componentModel()->getVlnv());\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignDiagram::onComponentInstanceRemoved()\r\n//-----------------------------------------------------------------------------\r\nvoid DesignDiagram::onComponentInstanceRemoved(ComponentItem* item)\r\n{\r\n    getParent()->removeRelatedVLNV(item->componentModel()->getVlnv());\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignDiagram::onVendorExtensionAdded()\r\n//-----------------------------------------------------------------------------\r\nvoid DesignDiagram::onVendorExtensionAdded(QSharedPointer<VendorExtension> extension)\r\n{\r\n    if (design_ && !design_->getVendorExtensions()->contains(extension))\r\n    {\r\n        design_->getVendorExtensions()->append(extension);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignDiagram::onVendorExtensionRemoved()\r\n//-----------------------------------------------------------------------------\r\nvoid DesignDiagram::onVendorExtensionRemoved(QSharedPointer<VendorExtension> extension)\r\n{\r\n    if (design_)\r\n    {\r\n        design_->getVendorExtensions()->removeAll(extension);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignDiagram::onBeginAssociation()\r\n//-----------------------------------------------------------------------------\r\nvoid DesignDiagram::onBeginAssociation(Associable* startingPoint)\r\n{\r\n    setInteractionMode(ASSOCIATE);\r\n    QApplication::setOverrideCursor(Qt::ArrowCursor);\r\n\r\n    QPointF start = startingPoint->connectionPoint();\r\n    associationLine_ = new QGraphicsLineItem(QLineF(start, start));\r\n    addItem(associationLine_);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignDiagram::onItemModified()\r\n//-----------------------------------------------------------------------------\r\nvoid DesignDiagram::onItemModified(QUndoCommand* undoCommand)\r\n{\r\n    getEditProvider()->addCommand(QSharedPointer<QUndoCommand>(undoCommand));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignDiagram::getUsedInstanceNames()\r\n//-----------------------------------------------------------------------------\r\nQStringList DesignDiagram::getUsedInstanceNames() const\r\n{\r\n    QStringList usedNames;\r\n    for (QSharedPointer<ComponentInstance> instance : *getDesign()->getComponentInstances())\r\n    {\r\n        usedNames.append(instance->getInstanceName());\r\n    }\r\n\r\n    return usedNames;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignDiagram::drawBackground()\r\n//-----------------------------------------------------------------------------\r\nvoid DesignDiagram::drawBackground(QPainter* painter, QRectF const& rect)\r\n{\r\n    painter->setWorldMatrixEnabled(true);\r\n    painter->setPen(QPen(Qt::gray, 0));\r\n\r\n    qreal left = int(rect.left()) - (int(rect.left()) % GridSize );\r\n    qreal top = int(rect.top()) - (int(rect.top()) % GridSize );\r\n\r\n    for (qreal x = left; x < rect.right(); x += GridSize )\r\n    {\r\n        for (qreal y = top; y < rect.bottom(); y += GridSize )\r\n        {\r\n            painter->drawPoint(x, y);\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignDiagram::getTopmostComponent()\r\n//-----------------------------------------------------------------------------\r\nComponentItem* DesignDiagram::getTopmostComponent(QPointF const& pos)\r\n{\r\n    QList<QGraphicsItem*> itemList = items(pos);\r\n\r\n    for (QGraphicsItem* item : itemList)\r\n    {\r\n        ComponentItem* compItem = dynamic_cast<ComponentItem*>(item);\r\n\r\n        if (compItem != 0)\r\n        {\r\n            return compItem;\r\n        }\r\n    }\r\n\r\n    return 0;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignDiagram::getBaseItemOf()\r\n//-----------------------------------------------------------------------------\r\nQGraphicsItem* DesignDiagram::getBaseItemOf(QGraphicsItem* item) const\r\n{\r\n    QGraphicsItem* baseItem = item;\r\n\r\n    while (baseItem != 0 && baseItem->parentItem() != 0 &&\r\n        (baseItem->type() == QGraphicsTextItem::Type || baseItem->type() == QGraphicsPixmapItem::Type))\r\n    {\r\n        baseItem = baseItem->parentItem();\r\n    }\t\r\n\r\n    return baseItem;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignDiagram::createNote()\r\n//-----------------------------------------------------------------------------\r\nvoid DesignDiagram::createNoteAt(QPointF const& position)\r\n{\r\n    StickyNote* note = createStickyNote();\r\n    note->setPos(position);\r\n\r\n    QSharedPointer<StickyNoteAddCommand> cmd = createNoteAddCommand(note);\r\n    cmd->redo(); \r\n    getEditProvider()->addCommand(cmd);\r\n\r\n    clearSelection();\r\n    emit clearItemSelection();\r\n    note->setSelected(true);\r\n    onSelected(note);\r\n\r\n    note->beginEditing();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignDiagram::createContextMenu()\r\n//-----------------------------------------------------------------------------\r\nQMenu* DesignDiagram::createContextMenu(QPointF const&)\r\n{\r\n\treturn 0;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignDiagram::contextMenuEvent()\r\n//-----------------------------------------------------------------------------\r\nvoid DesignDiagram::contextMenuEvent(QGraphicsSceneContextMenuEvent* event)\r\n{\r\n\tQMenu* menu = createContextMenu(event->scenePos());\r\n\tif (menu != 0)\r\n\t{\r\n\t    menu->exec(event->screenPos());\r\n\t    delete menu;\r\n\t}\r\n\tevent->accept();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignDiagram::onShow()\r\n//-----------------------------------------------------------------------------\r\nvoid DesignDiagram::onShow()\r\n{\r\n    // Retrieve the new selection.\r\n    QGraphicsItem *newSelection = 0;\r\n\r\n    if (!selectedItems().isEmpty())\r\n    {\r\n        newSelection = selectedItems().front();\r\n    }\r\n\r\n    onSelected(newSelection);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignDiagram::selectAll()\r\n//-----------------------------------------------------------------------------\r\nvoid DesignDiagram::selectAll()\r\n{\r\n    clearSelection();\r\n\r\n    for (GraphicsColumn* column : getLayout()->getColumns())\r\n    {\r\n        column->setSelected(true);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: onVerticalScroll()\r\n//-----------------------------------------------------------------------------\r\nvoid DesignDiagram::onVerticalScroll(qreal y)\r\n{\r\n    getLayout()->setOffsetY(y);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignDiagram::setVisibilityControlState()\r\n//-----------------------------------------------------------------------------\r\nvoid DesignDiagram::setVisibilityControlState(QString const& name, bool state)\r\n{\r\n    if (name == QLatin1String(\"Sticky Notes\"))\r\n    { \r\n        for (QGraphicsItem* item: items())\r\n        {       \r\n            if (item->type() == StickyNote::Type || item->type() == Association::Type)\r\n            {\r\n                item->setVisible(state);\r\n            }            \r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignDiagram::getInstances()\r\n//-----------------------------------------------------------------------------\r\nQList<ComponentItem*> DesignDiagram::getInstances() const\r\n{\r\n    // the list to store the diagram components to\r\n    QList<ComponentItem*> instances;\r\n\r\n    // ask for all graphics items.\r\n    QList<QGraphicsItem*> graphItems = items();\r\n    for (QGraphicsItem* graphItem : graphItems)\r\n    {\r\n        // make dynamic type conversion\r\n        ComponentItem* diagComp = dynamic_cast<ComponentItem*>(graphItem);\r\n        // if the item was a diagram component then add it to the list.\r\n        if (diagComp) \r\n        {\r\n            instances.append(diagComp);\r\n        }\r\n    }\r\n    return instances;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignDiagram::isLoading()\r\n//-----------------------------------------------------------------------------\r\nbool DesignDiagram::isLoading() const\r\n{\r\n    return loading_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignDiagram::getParent()\r\n//-----------------------------------------------------------------------------\r\nDesignWidget* DesignDiagram::getParent() const\r\n{\r\n    return parent_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignDiagram::ensureOneTypeSelected()\r\n//-----------------------------------------------------------------------------\r\nvoid DesignDiagram::ensureOneTypeSelected(QList<QGraphicsItem*> const& items)\r\n{\r\n    QList<QGraphicsItem*> currentlySelectedItems = selectedItems();\r\n    if (currentlySelectedItems.size() > 1)\r\n    {\r\n        // Check if all selected items have the same type.\r\n        int type = getCommonItemType(currentlySelectedItems);\r\n        if (type == -1)\r\n        {\r\n            // If not, deselect those that are in the new selection but no in the old one.\r\n            for (QGraphicsItem* selectedItem : currentlySelectedItems)\r\n            {\r\n                if (!items.contains(selectedItem))\r\n                {\r\n                    selectedItem->setSelected(false);\r\n                }\r\n            }\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignDiagram::getCommonType()\r\n//-----------------------------------------------------------------------------\r\nint DesignDiagram::getCommonItemType(QList<QGraphicsItem*> const& items)\r\n{\r\n    if (items.empty())\r\n    {\r\n        return -1;\r\n    }\r\n\r\n    int type = items.first()->type();\r\n\r\n    for (int i = 1; i < items.size(); i++)\r\n    {\r\n        if (type != items.at(i)->type())\r\n        {\r\n            return -1;\r\n        }\r\n    }\r\n\r\n    return type;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignDiagram::sortByX()\r\n//-----------------------------------------------------------------------------\r\nbool DesignDiagram::sortByX(QGraphicsItem* lhs, QGraphicsItem* rhs)\r\n{\r\n    return lhs->x() < rhs->x();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignDiagram::getLayout()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<GraphicsColumnLayout> DesignDiagram::getLayout() const\r\n{\r\n    return layout_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignDiagram::createInstanceName()\r\n// Forms a unique identifier for a component instance\r\n//-----------------------------------------------------------------------------\r\nQString DesignDiagram::createInstanceName(QString const& baseName)\r\n{\r\n    QSettings settings; // this reads the application settings automatically\r\n    QString format = settings.value(\"Policies/InstanceNames\", \"\").toString();\r\n    if (format.isEmpty())\r\n    {\r\n        format = \"$ComponentName$_$InstanceNumber$\";\r\n    }\r\n\r\n    // Determine a unique name by using a running number.\r\n    int runningNumber = 0;\r\n\r\n    QStringList instanceNames = getUsedInstanceNames();\r\n\r\n    QString name = format;\r\n    name.replace(\"$ComponentName$\", baseName);\r\n    name.replace(\"$InstanceNumber$\", QString::number(runningNumber));\r\n\r\n    while (instanceNames.contains(name))\r\n    {\r\n        runningNumber++;\r\n\r\n        name = format;\r\n        name.replace(\"$ComponentName$\", baseName);\r\n        name.replace(\"$InstanceNumber$\", QString::number(runningNumber));\r\n    }\r\n\r\n    return name;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignDiagram::setLayout()\r\n//-----------------------------------------------------------------------------\r\nvoid DesignDiagram::clearLayout()\r\n{\r\n    layout_.clear();\r\n    layout_ = QSharedPointer<GraphicsColumnLayout>(new GraphicsColumnLayout(this));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignDiagram::loadStickyNotes()\r\n//-----------------------------------------------------------------------------\r\nvoid DesignDiagram::loadStickyNotes()\r\n{\r\n    for (QSharedPointer<VendorExtension> extension : *design_->getVendorExtensions())\r\n    {\r\n        if (extension->type() == \"kactus2:note\")\r\n        {\r\n            QSharedPointer<Kactus2Group> noteExtension = extension.dynamicCast<Kactus2Group>();\r\n            StickyNote* note = createStickyNote();\r\n            note->setVendorExtension(noteExtension);\r\n\r\n            QSharedPointer<StickyNoteAddCommand> cmd = createNoteAddCommand(note);\r\n            cmd->redo();\r\n                \r\n            loadNoteAssociations(note);          \r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignDiagram::createStickyNote()\r\n//-----------------------------------------------------------------------------\r\nStickyNote* DesignDiagram::createStickyNote()\r\n{\r\n    StickyNote* note = new StickyNote();\r\n    connect(note, SIGNAL(beginAssociation(Associable*)), \r\n        this, SLOT(onBeginAssociation(Associable*)), Qt::UniqueConnection);\r\n    connect(note, SIGNAL(modified(QUndoCommand*)), \r\n        this, SLOT(onItemModified(QUndoCommand*)), Qt::UniqueConnection);\r\n\r\n    return note;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignDiagram::loadNoteAssociations()\r\n//-----------------------------------------------------------------------------\r\nvoid DesignDiagram::loadNoteAssociations(StickyNote* note)\r\n{\r\n    QSharedPointer<Kactus2Group> associations = note->getAssociationExtensions();\r\n\r\n    for (QSharedPointer<VendorExtension> endpoint : associations->getByType(\"kactus2:position\"))\r\n    {\r\n        QSharedPointer<Kactus2Position> extension = endpoint.dynamicCast<Kactus2Position>();\r\n\r\n        QSharedPointer<QUndoCommand> addCommand = createAssociationAddCommand(note, extension);\r\n        addCommand->redo();\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignDiagram::setProtectionForStickyNotes()\r\n//-----------------------------------------------------------------------------\r\nvoid DesignDiagram::setProtectionForStickyNotes()\r\n{\r\n    for (QGraphicsItem* item : items())\r\n    {\r\n        if (item->type() == StickyNote::Type)\r\n        {\r\n            item->setEnabled(!locked_);\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignDiagram::adHocIdentifier()\r\n//-----------------------------------------------------------------------------\r\nQString DesignDiagram::adHocIdentifier() const\r\n{\r\n    return tr(\"top-level\");\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignDiagram::updateAssociationCursor()\r\n//-----------------------------------------------------------------------------\r\nvoid DesignDiagram::updateAssociationCursor(QPointF const& cursorPosition)\r\n{\r\n    bool possibleEndpoint = dynamic_cast<Associable*>(getBaseItemOf(itemAt(cursorPosition, QTransform())));\r\n    if (possibleEndpoint)\r\n    {\r\n        QApplication::changeOverrideCursor(Qt::CrossCursor);\r\n    }\r\n    else\r\n    {\r\n        QApplication::changeOverrideCursor(Qt::ArrowCursor);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignDiagram::updateAssociationLine()\r\n//-----------------------------------------------------------------------------\r\nvoid DesignDiagram::updateAssociationLineDraw(QPointF const& cursorPosition)\r\n{\r\n    QLineF line = associationLine_->line();\r\n    line.setP2(cursorPosition);\r\n    associationLine_->setLine(line);    \r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignDiagram::endAssociation()\r\n//-----------------------------------------------------------------------------\r\nvoid DesignDiagram::endAssociation(QPointF const& endpoint)\r\n{\r\n    QPointF startingPoint = associationLine_->line().p1();\r\n\r\n    endAssociationLineDraw();\r\n\r\n    QGraphicsItem* item = getBaseItemOf(itemAt(startingPoint, QTransform()));\r\n    Associable* startItem = dynamic_cast<Associable*>(item);\r\n\r\n    QSharedPointer<Kactus2Position> endPointExtension(new Kactus2Position(endpoint));\r\n\r\n    QSharedPointer<QUndoCommand> addCommand = createAssociationAddCommand(startItem, endPointExtension);\r\n    addCommand->redo();\r\n    getEditProvider()->addCommand(addCommand);\r\n\r\n    QApplication::restoreOverrideCursor();\r\n    setInteractionMode(NORMAL);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignDiagram::createAssociation()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<QUndoCommand> DesignDiagram::createAssociationAddCommand(Associable* startItem, \r\n    QSharedPointer<Kactus2Position> endPointExtension)\r\n{\r\n    QGraphicsItem* item = getBaseItemOf(itemAt(endPointExtension->position(), QTransform()));\r\n    Associable* endItem = dynamic_cast<Associable*>(item);\r\n\r\n    if (!endItem && item && item->parentItem())\r\n    {\r\n        QGraphicsItem* associableParentItem = item->parentItem();\r\n        endItem = dynamic_cast<Associable*>(associableParentItem);\r\n    }\r\n\r\n    QSharedPointer<QUndoCommand> addCommand(new QUndoCommand());\r\n\r\n    if (canAssociateItems(startItem, endItem))\r\n    {\r\n        Association* association = new Association(startItem, endItem, endPointExtension);\r\n        addCommand = QSharedPointer<AssociationAddCommand>(new AssociationAddCommand(association, this));       \r\n    }\r\n\r\n    return addCommand;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignDiagram::canAssociateItems()\r\n//-----------------------------------------------------------------------------\r\nbool DesignDiagram::canAssociateItems(Associable* startItem, Associable* endItem)\r\n{\r\n    return startItem && endItem && startItem != endItem;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignDiagram::inAssociationMode()\r\n//-----------------------------------------------------------------------------\r\nbool DesignDiagram::inAssociationMode() const\r\n{\r\n    return interactionMode_ == ASSOCIATE;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HWDesignDiagram::associationEnds()\r\n//-----------------------------------------------------------------------------\r\nbool DesignDiagram::canEndAssociation() const\r\n{\r\n    return inAssociationMode() && associationLine_->line().p1() != associationLine_->line().p2();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignDiagram::contextMenuEnabled()\r\n//-----------------------------------------------------------------------------\r\nbool DesignDiagram::contextMenuEnabled() const\r\n{\r\n    return getMode() == MODE_SELECT && interactionMode_ == CONTEXT_MENU;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignDiagram::inReplaceMode()\r\n//-----------------------------------------------------------------------------\r\nbool DesignDiagram::inReplaceMode() const\r\n{\r\n    return interactionMode_ == REPLACE;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignDiagram::setInteractionMode()\r\n//-----------------------------------------------------------------------------\r\nvoid DesignDiagram::setInteractionMode(interactionMode mode)\r\n{\r\n    interactionMode_ = mode;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignDiagram::createNoteAddCommand()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<StickyNoteAddCommand> DesignDiagram::createNoteAddCommand(StickyNote* note)\r\n{\r\n    QSharedPointer<StickyNoteAddCommand> cmd(new StickyNoteAddCommand(note, this, note->pos()));\r\n\r\n    connect(cmd.data(), SIGNAL(addVendorExtension(QSharedPointer<VendorExtension>)),\r\n        this, SLOT(onVendorExtensionAdded(QSharedPointer<VendorExtension>)), Qt::UniqueConnection);\r\n\r\n    connect(cmd.data(), SIGNAL(removeVendorExtension(QSharedPointer<VendorExtension>)),\r\n        this, SLOT(onVendorExtensionRemoved(QSharedPointer<VendorExtension>)), Qt::UniqueConnection);\r\n\r\n    return cmd;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignDiagram::wheelEvent()\r\n//-----------------------------------------------------------------------------\r\nvoid DesignDiagram::wheelEvent(QGraphicsSceneWheelEvent* event)\r\n{\r\n    if (event->modifiers() == Qt::CTRL)\r\n    {\r\n        // Set the zoom level and center the view.\r\n        getParent()->setZoomLevel(getParent()->getZoomLevel() + event->delta() / 12);\r\n\r\n        event->accept();\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignDiagram::endInteraction()\r\n//-----------------------------------------------------------------------------\r\nvoid DesignDiagram::endInteraction()\r\n{\r\n    if (inAssociationMode())\r\n    {\r\n        endAssociationLineDraw();\r\n    }\r\n\r\n    setInteractionMode(NORMAL);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignDiagram::endAssociationLineDraw()\r\n//-----------------------------------------------------------------------------\r\nvoid DesignDiagram::endAssociationLineDraw()\r\n{\r\n    removeItem(associationLine_);\r\n    delete associationLine_;\r\n    associationLine_ = 0;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignDiagram::inOffPageMode()\r\n//-----------------------------------------------------------------------------\r\nbool DesignDiagram::inOffPageMode() const\r\n{\r\n    return interactionMode_ == OFFPAGE;\r\n}\r\n\r\n"
  },
  {
    "path": "editors/common/DesignDiagram.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: DesignDiagram.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Joni-Matti Maatta\r\n// Date: 24.4.2012\r\n//\r\n// Description:\r\n// Base class for all design diagrams.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef DESIGNDIAGRAM_H\r\n#define DESIGNDIAGRAM_H\r\n\r\n#include <editors/HWDesign/AdHocEnabled.h>\r\n#include <editors/common/DrawMode.h>\r\n\r\n#include <IPXACTmodels/DesignConfiguration/DesignConfiguration.h>\r\n\r\n#include <IPXACTmodels/kactusExtensions/ColumnDesc.h>\r\n\r\n#include <QAction>\r\n#include <QGraphicsScene>\r\n#include <QGraphicsSceneContextMenuEvent>\r\n#include <QMenu>\r\n#include <QSharedPointer>\r\n#include <QStringList>\r\n#include <QUndoCommand>\r\n\r\nclass LibraryInterface;\r\nclass GenericEditProvider;\r\nclass Component;\r\nclass ConnectionEndpoint;\r\nclass GraphicsConnection;\r\nclass GraphicsColumnLayout;\r\nclass ComponentItem;\r\nclass Design;\r\nclass VLNV;\r\nclass DesignWidget;\r\nclass Associable;\r\nclass StickyNote;\r\nclass Kactus2Group;\r\nclass Kactus2Position;\r\nclass StickyNoteAddCommand;\r\nclass IEditProvider;\r\nclass AdHocVisibilityEditor;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Base class for all design diagrams.\r\n//-----------------------------------------------------------------------------\r\nclass DesignDiagram : public QGraphicsScene, public AdHocEnabled\r\n{\r\n    Q_OBJECT\r\n\r\npublic:\r\n    /*!\r\n     *  Constructor.\r\n     *\r\n     *    @param [in] lh            The library interface.\r\n     *    @param [in] editProvider  The edit provider.\r\n     *    @param [in] parent        The parent widget.\r\n     */\r\n    DesignDiagram(LibraryInterface* lh, QSharedPointer<IEditProvider> editProvider, DesignWidget* parent = 0);\r\n\r\n    /*!\r\n     *  Destructor.\r\n     */\r\n    virtual ~DesignDiagram();\r\n\r\n    /*!\r\n     *  Clears the scene.\r\n     */\r\n    virtual void clearScene();\r\n\r\n    /*!\r\n     *  Opens a design for editing.\r\n     *\r\n     *    @param [in] component       The component whose design to edit.\r\n     *    @param [in] selectedView    The selected view of the top component.\r\n     *    @param [in] design          The design to edit.\r\n     *    @param [in] designConf      The design configuration if one exists.\r\n     */\r\n    bool setDesign(QSharedPointer<Component> component, QString const& selectedView, QSharedPointer<Design> design,\r\n                   QSharedPointer<DesignConfiguration> designConf = QSharedPointer<DesignConfiguration>());\r\n\r\n    /*!\r\n     *  Reflects the changes in the design to the top-level component.\r\n     */\r\n    virtual void updateHierComponent() = 0;\r\n\r\n    /*!\r\n     *  Recalculate the required width and height of the scene rectangle.\r\n     */\r\n    void resetSceneRectangleForItems();\r\n\r\n    /*!\r\n     *  Attaches the data source to an ad-hoc editor.\r\n     */\r\n    virtual void attach(AdHocVisibilityEditor* editor);\r\n\r\n    /*!\r\n     *  Detaches the data source from the ad-hoc editor.\r\n     */\r\n    virtual void detach(AdHocVisibilityEditor* editor);\r\n\r\n        \r\n    virtual QString adHocIdentifier() const;\r\n\r\n    /*!\r\n     *  Adds an instance name to the list of used instance names.\r\n     *\r\n     *    @param [in] name The name of the instance.\r\n     *\r\n     *      @remarks This function should be called when a component instance is added to the diagram.\r\n     */\r\n    void addInstanceName(QString const& name);\r\n\r\n    /*!\r\n     *  Removes the instance name from the list so the name can be used again in the design.\r\n\t *\r\n\t *    @param name The name of the removed instance.\r\n\t *\r\n     *      @remarks This function should be called when user removes component instance.\r\n\t */\r\n\tvoid removeInstanceName(const QString& name);\r\n\r\n\t/*!\r\n     *  Updates the list of instance names.\r\n\t *\r\n\t *    @param oldName The old name of the component instance.\r\n\t *    @param newName The new name of the component instance.\r\n\t */\r\n\tvoid updateInstanceName(const QString& oldName, const QString& newName);\r\n\r\n    /*!\r\n     *  Changes the state of a visibility control.\r\n     *\r\n     *    @param [in] name   The name of the visibility control.\r\n     *    @param [in] state  The new state for the visibility control.\r\n     */\r\n    virtual void setVisibilityControlState(QString const& name, bool state);\r\n\r\n    /*!\r\n     *  Sets the draw mode of the diagram.\r\n     *\r\n     *    @param [in] mode The draw mode.\r\n     */\r\n    virtual void setMode(DrawMode mode);\r\n\r\n    /*!\r\n     *  Sets the block diagram locked/unlocked.\r\n     *\r\n     *    @param [in] locked If true, the diagram is locked. Otherwise it is unlocked.\r\n     */\r\n    void setProtection(bool locked);\r\n\r\n    /*!\r\n     *  Adds a column to the diagram's layout.\r\n     *\r\n     *    @param [in] desc The column description.\r\n     */\r\n    virtual void addColumn(QSharedPointer<ColumnDesc> desc) = 0;\r\n\r\n    /*!\r\n     *  Returns the current draw mode.\r\n     */\r\n    DrawMode getMode() const;\r\n\r\n    /*!\r\n     *  Returns true if the diagram is being loaded.\r\n     */\r\n    bool isLoading() const;\r\n\r\n    /*!\r\n     *  Returns true if the diagram is in locked state.\r\n     */\r\n    bool isProtected() const;\r\n\r\n    /*!\r\n     *  Returns the library interface.\r\n     */\r\n    LibraryInterface* getLibraryInterface() const;\r\n\r\n    /*!\r\n     *  Returns the parent design widget.\r\n     */\r\n     DesignWidget* getParent() const;\r\n\r\n    /*!\r\n     *  Returns the edit provider.\r\n     */\r\n    virtual QSharedPointer<IEditProvider> getEditProvider() const;\r\n\r\n    /*!\r\n     *  Returns the component whose design is being edited.\r\n     */\r\n    QSharedPointer<Component> getEditedComponent() const;\r\n    \r\n    /*!\r\n     *  Returns the design being edited.\r\n     */ \r\n    QSharedPointer<Design> getDesign() const;\r\n\r\n    /*!\r\n     *  Returns the design configuration.\r\n     */\r\n    QSharedPointer<DesignConfiguration> getDesignConfiguration() const;\r\n\r\n    /*!\r\n     *  Returns a list of instances currently in the design.\r\n     */\r\n    QList<ComponentItem*> getInstances() const;\r\n\r\n    /*!\r\n     *  Ensures that all items in a given list have the same type. Items with different type are unselected.\r\n     *\r\n     *    @param [in] items   The list to check.\r\n     */\r\n    void ensureOneTypeSelected(QList<QGraphicsItem*> const& items);\r\n\r\n    /*!\r\n     *  Returns the type of the given items if they all are of the same type.\r\n     *\r\n     *    @return The common type, or -1 if the items are of different type.\r\n     */\r\n    static int getCommonItemType(QList<QGraphicsItem*> const& items);\r\n\r\n    /*!\r\n     *  Sorts graphics items by X coordinate.\r\n     */\r\n    static bool sortByX(QGraphicsItem* lhs, QGraphicsItem* rhs);\r\n\r\n     /*!\r\n      *  Gets the graphics column layout of the design.\r\n      *\r\n      *    @return The column layout of the design.\r\n      */\r\n     QSharedPointer<GraphicsColumnLayout> getLayout() const;\r\n     \r\n    /*!\r\n     *  Creates a unique instance name with the given base name.\r\n     *\r\n     *    @param [in] baseName The base name for the instance.\r\n     */\r\n    QString createInstanceName(QString const& baseName);\r\n\r\n    /*!\r\n     *  Get the currently active top component view.\r\n     *\r\n     *    @return The currently active top component view.\r\n     */\r\n    QString getTopView() const;\r\n\r\npublic slots:\r\n    //! Called when the diagram is shown.\r\n    void onShow();\r\n\r\n    /*!\r\n     *  Selects all (columns) in the design.\r\n     */\r\n    void selectAll();\r\n\r\n    //! Called when the view has been scrolled vertically.\r\n    virtual void onVerticalScroll(qreal y);\r\n\r\n    //! Called when a component instance is added to the diagram.\r\n    virtual void onComponentInstanceAdded(ComponentItem* item);\r\n\r\n    //! Called when a component instance is remove from the diagram.\r\n    virtual void onComponentInstanceRemoved(ComponentItem* item);\r\n\r\n    //! Called when a vendor extension is added to the design.\r\n    virtual void onVendorExtensionAdded(QSharedPointer<VendorExtension> extension);\r\n\r\n    //! Called when a vendor extension is removed from the design.\r\n    virtual void onVendorExtensionRemoved(QSharedPointer<VendorExtension> extension);\r\n   \r\n    /*!\r\n     *  Called when an association creation is requested.\r\n     *\r\n     *    @param [in] startingPoint   The item requesting the new association.\r\n     */\r\n    void onBeginAssociation(Associable* startingPoint);\r\n\r\n    /*!\r\n     *  Called when an item has been modified.\r\n     *\r\n     *    @param [in] undoCommand   The undo command to undo/redo the modification.\r\n     */\r\n    void onItemModified(QUndoCommand* undoCommand);\r\n\r\nsignals:\r\n    //! Emitted when component with given vlnv should be opened in editor.\r\n    void openComponent(const VLNV& vlnv);\r\n\r\n    //! \\brief Emitted when the user double-clicks a hierarchical SW component.\r\n    void openSWDesign(const VLNV& vlnv, const QString& viewName);\r\n\r\n    //! Emitted when a C source file should be opened for editing.\r\n    void openCSource(ComponentItem* compItem);\r\n\r\n    //! Emitted when user double clicks on a hierarchical component.\r\n    void openDesign(const VLNV& vlnv, const QString& viewName);\r\n\r\n    //! Signaled when the bus with the given vlnv should be opened for editing.\r\n    void openBus(VLNV const& vlnv);\r\n\r\n    //! Signaled when the draw mode has changed.\r\n    void modeChanged(DrawMode mode);\r\n\r\n    //! Signaled when the contents of the diagram have changed.\r\n    void contentChanged();\r\n\r\n    //! Sends an error message to the user.\r\n    void errorMessage(const QString& errorMessage);\r\n\r\n    //! Sends a notification to the user.\r\n    void noticeMessage(const QString& noticeMessage);\r\n\r\n    //! Emitted when a help page should be changed in the context help window.\r\n    void helpUrlRequested(QString const& url);\r\n\r\n    //! Signaled when a new component is instantiated to the design.\r\n    void componentInstantiated(ComponentItem* item);\r\n\r\n    //! Signaled when a component instance is removed from the design.\r\n    void componentInstanceRemoved(ComponentItem* item);\r\n\r\n    //! Signaled when user selects a component on the draw board.\r\n    void componentSelected(ComponentItem* component);\r\n\r\n    //! Signaled when the user selects an interface on the draw board.\r\n    void interfaceSelected(ConnectionEndpoint* endpoint);\r\n\r\n    //! Signaled when the user selects a connection on the draw board.\r\n\tvoid connectionSelected(GraphicsConnection* connection);\r\n\r\n    //! Signaled when all items are deselected.\r\n    void clearItemSelection();\r\n\r\nprotected:\r\n\r\n    virtual void wheelEvent(QGraphicsSceneWheelEvent* event);\r\n\r\n    /*!\r\n     *  Draws the diagram background.\r\n     */\r\n     virtual void drawBackground(QPainter* painter, QRectF const& rect);\r\n\r\n    /*!\r\n     *  Picks the top-most component at the given position.\r\n     *\r\n     *    @param [in] pos The picking positions.\r\n     *\r\n     *    @return The top-most component at the given positions, or 0 if there is no component.\r\n     */\r\n    ComponentItem* getTopmostComponent(QPointF const& pos);\r\n\r\n    /*!\r\n     *  Finds the underlying item of a given item ignoring text labels and pixmap items. \r\n     *\r\n     *  This fixes the problem when the user click above a text label or a pixmap but\r\n     *  actually wants to select the parent item (such as the actual component, not its label).\r\n     *\r\n     *    @param [in] item   The item whose base item to find.\r\n     *\r\n     *    @return The bottom-most item.\r\n     */\r\n    QGraphicsItem* getBaseItemOf(QGraphicsItem* item) const;\r\n\r\n    /*!\r\n     *  Adds a new note to the design.\r\n     *\r\n     *    @param [in] position   The initial position of the note.\r\n     */\r\n    virtual void createNoteAt(QPointF const& position);\r\n\r\n     /*!\r\n     *  Called when an item has been selected in the diagram.\r\n     *\r\n     *    @param [in] newSelection The selected item.\r\n     */\r\n    virtual void onSelected(QGraphicsItem* newSelection) = 0;\r\n\r\n\t/*!\r\n     *  Creates the context menu for function contextMenuEvent().\r\n     *\r\n     *    @param [in] pos Mouse position when the menu is requested.\r\n\t *\r\n\t *    @return The menu with allowed actions or 0 if no menu is allowed.\r\n     */\r\n\tvirtual QMenu* createContextMenu(QPointF const& pos);\r\n\r\n\t/*!\r\n     *  Event handler for receiving context menu events (e.g. right mouse click).\r\n     *\r\n     *    @param [in] event The triggering event.\r\n     */\r\n\tvirtual void contextMenuEvent(QGraphicsSceneContextMenuEvent* event);\r\n\r\n     void updateAssociationCursor(QPointF const& cursorPosition);\r\n\r\n    /*!\r\n     *  Updates the association line.\r\n     *\r\n     *    @param [in] cursorPosition   The current cursor position which becomes the ending point for the line.\r\n     */\r\n    void updateAssociationLineDraw(QPointF const& cursorPosition);\r\n\r\n    /*!\r\n     *  Ends the creation of a new association.\r\n     *\r\n     *    @param [in] endpoint   The ending point of the association.\r\n     */\r\n    void endAssociation(QPointF const& endpoint);\r\n\r\n    //! Ends the drawing of a new association line.\r\n    void endAssociationLineDraw();\r\n\r\n    /*!\r\n     *  Checks if two items can be associated with each other.\r\n     *\r\n     *    @param [in] startItem       The first item.\r\n     *    @param [in] endItem         The second item.\r\n     *\r\n     *    @return True, if the items can be associated, otherwise false.\r\n     */\r\n    bool canAssociateItems(Associable* startItem, Associable* endItem);\r\n\r\n    /*!\r\n     *  Creates a command for adding an association to the diagram.\r\n     *\r\n     *    @param [in] startItem           The item at the starting end of the association.\r\n     *    @param [in] endPointExtension   The vendor extension describing the ending point position.\r\n     *\r\n     *    @return A command for creating an association.\r\n     */\r\n    QSharedPointer<QUndoCommand> createAssociationAddCommand(Associable* startItem, \r\n        QSharedPointer<Kactus2Position> endPointExtension);\r\n\r\n    /*!\r\n     *  Checks if the user is currently creating a new association.\r\n     *\r\n     *    @return True, if an association is being created, otherwise false.\r\n     */\r\n    bool inAssociationMode() const;\r\n\r\n    /*!\r\n     *  Checks if the association can end.\r\n     *\r\n     *    @return True, if an association can end, otherwise false.\r\n     */\r\n    bool canEndAssociation() const;\r\n\r\n    /*!\r\n     *  Checks if context menu can be displayed.     \r\n     *\r\n     *    @return True, if context menu can be displayed, otherwise false.\r\n     */\r\n    bool contextMenuEnabled() const;\r\n\r\n    /*!\r\n     *  Checks if the user is currently replacing a component.\r\n     *\r\n     *    @return True, if a replace is in progress, otherwise false.\r\n     */\r\n    bool inReplaceMode() const;\r\n\r\n    /*!\r\n     *  Checks if the user is currently creating connections in off page mode.\r\n     *\r\n     *    @return True, if off page mode is set, otherwise false.\r\n     */\r\n    bool inOffPageMode() const;\r\n    \r\n    enum interactionMode{\r\n        NORMAL = 0,\r\n        CONTEXT_MENU,\r\n        REPLACE,\r\n        OFFPAGE,\r\n        ASSOCIATE\r\n    };\r\n\r\n    /*!\r\n     *  Sets the interaction mode.\r\n     *\r\n     *    @param [in] mode   The mode to set.\r\n     *     \r\n     */\r\n    void setInteractionMode(interactionMode mode);\r\n\r\n    //! Ends the current interaction mode.\r\n    void endInteraction();\r\n\r\nprivate:\r\n    // Disable copying.\r\n    DesignDiagram(DesignDiagram const& rhs);\r\n    DesignDiagram& operator=(DesignDiagram const& rhs);\r\n\r\n    /*!\r\n     *  Opens the given design for editing.\r\n     *\r\n     *    @param [in] design The design to open.\r\n     */\r\n    virtual void loadDesign(QSharedPointer<Design> design) = 0;\r\n\r\n     //! Clears and resets the current layout.\r\n     void clearLayout();\r\n\r\n    //! Creates sticky notes from vendor extensions.\r\n    void loadStickyNotes();\r\n\r\n    //! Creates a new sticky note.\r\n    StickyNote* createStickyNote();\r\n\r\n    /*!\r\n     *  Creates a command for adding a sticky note to the diagram.\r\n     *\r\n     *    @param [in] note   The note for which to create the command for.\r\n     *\r\n     *    @return The command for adding the note to diagram.\r\n     */\r\n    QSharedPointer<StickyNoteAddCommand> createNoteAddCommand(StickyNote* note);\r\n\r\n    /*!\r\n     *  Loads the associations from a sticky not from a vendor extension.\r\n     *\r\n     *    @param [in] note                    The note for whose associations to load.\r\n     */\r\n     void loadNoteAssociations(StickyNote* note);\r\n\r\n    //! Enables/disables the sticky notes according to design protection state.\r\n    void setProtectionForStickyNotes();\r\n\r\n    /*!\r\n     *  Get the names of the contained component instances.\r\n     *\r\n     *    @return A list of instance names of the contained component instances.\r\n     */\r\n    virtual QStringList getUsedInstanceNames() const;\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! The parent design widget.\r\n    DesignWidget* parent_;\r\n\r\n    //! Library interface.\r\n    LibraryInterface* lh_;\r\n\r\n    //! The edit provider for undo/redo.\r\n    QSharedPointer<IEditProvider> editProvider_;\r\n\r\n    //! The currently active top component view.\r\n    QString topView_;\r\n\r\n    //! The component whose design is being edited.\r\n    QSharedPointer<Component> component_;\r\n\r\n    //! The design being edited.\r\n    QSharedPointer<Design> design_;\r\n\r\n    //! The design configuration.\r\n    QSharedPointer<DesignConfiguration> designConf_;\r\n\r\n    // Graphics column layout.\r\n    QSharedPointer<GraphicsColumnLayout> layout_;\r\n\r\n    //! The current draw mode.\r\n    DrawMode mode_;\r\n\r\n    //! If true, the diagram is being loaded.\r\n    bool loading_;\r\n\r\n    //! If true, the diagram is locked and cannot be modified.\r\n    bool locked_;\r\n\r\n    interactionMode interactionMode_;\r\n\r\n    QGraphicsLineItem* associationLine_;\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n\r\n#endif // DESIGNDIAGRAM_H\r\n"
  },
  {
    "path": "editors/common/DesignDiagramResolver.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: DesignDiagramResolver.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Mikko Teuho\r\n// Date: 04.05.2016\r\n//\r\n// Description:\r\n// Resolver class containing functionality for calculating expressions within design diagrams.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"DesignDiagramResolver.h\"\r\n\r\n#include <KactusAPI/include/IPXactSystemVerilogParser.h>\r\n#include <KactusAPI/include/ComponentParameterFinder.h>\r\n#include <KactusAPI/include/ExpressionFormatter.h>\r\n#include <KactusAPI/include/MultipleParameterFinder.h>\r\n#include <KactusAPI/include/ListParameterFinder.h>\r\n\r\n#include <editors/HWDesign/AdHocItem.h>\r\n#include <editors/HWDesign/HWComponentItem.h>\r\n\r\n#include <IPXACTmodels/Component/Component.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignDiagramResolver::DesignDiagramResolver()\r\n//-----------------------------------------------------------------------------\r\nDesignDiagramResolver::DesignDiagramResolver(QSharedPointer<ListParameterFinder> designParameterFinder):\r\n    designParameterFinder_(designParameterFinder),\r\n    designAndInstanceParameterFinder_(new MultipleParameterFinder()),\r\n    expressionParser_(new IPXactSystemVerilogParser(designAndInstanceParameterFinder_)),\r\n    expressionFormatter_(new ExpressionFormatter(designAndInstanceParameterFinder_)),\r\n    valueFormatter_()\r\n{\r\n    designAndInstanceParameterFinder_->addFinder(designParameterFinder);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignDiagramResolver::setContext()\r\n//-----------------------------------------------------------------------------\r\nvoid DesignDiagramResolver::setContext(QSharedPointer<Component const> component)\r\n{\r\n    designAndInstanceParameterFinder_->removeAllFinders();\r\n\r\n    QSharedPointer<ComponentParameterFinder> newParameterFinder(new ComponentParameterFinder(component));\r\n    designAndInstanceParameterFinder_->addFinder(designParameterFinder_);\r\n    designAndInstanceParameterFinder_->addFinder(newParameterFinder);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignDiagramResolver::parse()\r\n//-----------------------------------------------------------------------------\r\nQString DesignDiagramResolver::parseToConstant(QString const& expression) const\r\n{\r\n    if (expression.isEmpty())\r\n    {\r\n        return QString();\r\n    }\r\n\r\n    return expressionParser_->parseExpression(expression);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignDiagramResolver::resolveAdhocTieOff()\r\n//-----------------------------------------------------------------------------\r\nvoid DesignDiagramResolver::resolveAdhocTieOff(QString const& tieOff, AdHocItem* tieOffPort)\r\n{\r\n    if (tieOffPort && !tieOff.isEmpty())\r\n    {\r\n        QSharedPointer<Component> ownerComponent = tieOffPort->getOwnerComponent();\r\n        \r\n        setContext(ownerComponent);\r\n        QString parsedTieOff = getParsedTieOffValue(tieOff, tieOffPort->name(), ownerComponent);\r\n\r\n        bool canConvertToInt = true; \r\n        parsedTieOff.toInt(&canConvertToInt);\r\n\r\n        int expressionBase = expressionParser_->baseForExpression(tieOff);\r\n        QString tieOffForBase = valueFormatter_.format(parsedTieOff, expressionBase);\r\n        if (tieOffForBase.isEmpty())\r\n        {\r\n            tieOffForBase = tieOff;\r\n        }\r\n\r\n        tieOffPort->changeTieOffLabel(\r\n            expressionFormatter_->formatReferringExpression(tieOff), tieOffForBase, canConvertToInt);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignDiagramResolver::getParsedTieOffValue()\r\n//-----------------------------------------------------------------------------\r\nQString DesignDiagramResolver::getParsedTieOffValue(QString const& tieOffValue, QString const& portName,\r\n    QSharedPointer<Component const> ownerComponent) const\r\n{\r\n    QString parsedTieOff;\r\n    if (QString::compare(tieOffValue, \"default\", Qt::CaseInsensitive) == 0)\r\n    {\r\n        QSharedPointer<Port> adhocPort = ownerComponent->getPort(portName);\r\n        QString portDefaultValue = adhocPort->getDefaultValue();\r\n        parsedTieOff = expressionParser_->parseExpression(portDefaultValue);\r\n    }\r\n    else if (QString::compare(tieOffValue, \"open\", Qt::CaseInsensitive) == 0)\r\n    {\r\n        parsedTieOff = \"\";\r\n    }\r\n    else\r\n    {\r\n        parsedTieOff = expressionParser_->parseExpression(tieOffValue);\r\n    }\r\n\r\n    return parsedTieOff;\r\n}\r\n"
  },
  {
    "path": "editors/common/DesignDiagramResolver.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: DesignDiagramResolver.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Mikko Teuho\r\n// Date: 04.05.2016\r\n//\r\n// Description:\r\n// Resolver class containing functionality for calculating expressions within design diagrams.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef DESIGNDIAGRAMRESOLVER_H\r\n#define DESIGNDIAGRAMRESOLVER_H\r\n\r\n#include <IPXACTmodels/common/validators/ValueFormatter.h>\r\n\r\n#include <QSharedPointer>\r\n\r\nclass ExpressionParser;\r\nclass ComponentParameterFinder;\r\nclass AdHocItem;\r\nclass Component;\r\nclass ExpressionFormatter;\r\nclass MultipleParameterFinder;\r\nclass ListParameterFinder;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Resolver class containing functionality for calculating expressions within design diagrams.\r\n//-----------------------------------------------------------------------------\r\nclass DesignDiagramResolver\r\n{\r\n\r\npublic:\r\n\r\n    /*!\r\n     *  The constructor.\r\n     *\r\n     *    @param [in] designParameterFinder   Locates the design parameters.\r\n     */\r\n    DesignDiagramResolver(QSharedPointer<ListParameterFinder> designParameterFinder);\r\n\r\n    // Disable copying.\r\n    DesignDiagramResolver(DesignDiagramResolver const& rhs) = delete;\r\n    DesignDiagramResolver& operator=(DesignDiagramResolver const& rhs) = delete;\r\n\r\n\t//! The destructor.\r\n    ~DesignDiagramResolver() = default;\r\n\r\n    void setContext(QSharedPointer<Component const> component);\r\n\r\n    QString parseToConstant(QString const& expression) const;\r\n\r\n    /*!\r\n     *  Resolve and draw a symbol for tie off in an ad hoc port item.\r\n     *\r\n     *    @param [in] tieOff      The tie off of the selected port.\r\n     *    @param [in] tieOffPort  The selected port item.\r\n     */\r\n    void resolveAdhocTieOff(QString const& tieOff, AdHocItem* tieOffPort);\r\n\r\nprivate:\r\n\r\n\r\n    /*!\r\n     *  Get the parsed value from a tie off value.\r\n     *\r\n     *    @param [in] tieOffValue     The unparsed tie off value.\r\n     *    @param [in] portName        The ad hoc port name.\r\n     *    @param [in] ownerComponent  The encompassing component of the ad hoc port containing the tie off value.     \r\n     *\r\n     *    @return Parsed tie off value.\r\n     */\r\n    QString getParsedTieOffValue(QString const& tieOffValue,\r\n        QString const& portName, QSharedPointer<Component const> ownerComponent) const;\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! The used design parameter finder.\r\n    QSharedPointer<ListParameterFinder> designParameterFinder_;\r\n\r\n    //! The used design and component instance parameter finder.\r\n    QSharedPointer<MultipleParameterFinder> designAndInstanceParameterFinder_;\r\n\r\n    //! The used expression parser.\r\n    QSharedPointer<ExpressionParser> expressionParser_;\r\n\r\n    //! Used to format expressions from using referenced UUIDs to using referenced parameter names.\r\n    QSharedPointer<ExpressionFormatter> expressionFormatter_;\r\n\r\n    //! Formats the value to the base number of the expression.\r\n    ValueFormatter valueFormatter_;\r\n};\r\n\r\n#endif // DESIGNDIAGRAMRESOLVER_H\r\n"
  },
  {
    "path": "editors/common/DesignParameterReferenceTree/DesignParameterReferenceCounter.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: DesignParameterReferenceCounter.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 06.10.2017\n//\n// Description:\n// Calculates the amount of references made to design parameters.\n//-----------------------------------------------------------------------------\n\n#include \"DesignParameterReferenceCounter.h\"\n\n#include <IPXACTmodels/common/Parameter.h>\n#include <IPXACTmodels/Design/Design.h>\n\n#include <KactusAPI/include/AbstractParameterInterface.h>\n\n//-----------------------------------------------------------------------------\n// Function: DesignParameterReferenceCounter::DesignParameterReferenceCounter()\n//-----------------------------------------------------------------------------\nDesignParameterReferenceCounter::DesignParameterReferenceCounter(QSharedPointer<ParameterFinder> parameterFinder):\nParameterReferenceCounter(parameterFinder),\ndesign_(0)\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: DesignParameterReferenceCounter::setDesign()\n//-----------------------------------------------------------------------------\nvoid DesignParameterReferenceCounter::setDesign(QSharedPointer<Design> newDesign)\n{\n    design_ = newDesign;\n}\n\n//-----------------------------------------------------------------------------\n// Function: DesignParameterReferenceCounter::recalculateReferencesToParameters()\n//-----------------------------------------------------------------------------\nvoid DesignParameterReferenceCounter::recalculateReferencesToParameters(QVector<QString> const& parameterList,\n    AbstractParameterInterface* parameterInterface)\n{\n    for (auto parameterName : parameterList)\n    {\n        int referenceCount = 0;\n        QString parameterID = QString::fromStdString(parameterInterface->getID(parameterName.toStdString()));\n\n        referenceCount += countReferencesInParameters(parameterID, design_->getParameters());\n        referenceCount += countReferencesInComponentInstances(parameterID);\n        referenceCount += countReferencesInAdHocConnections(parameterID, design_->getAdHocConnections());\n\n        parameterInterface->setUsageCount(parameterName.toStdString(), referenceCount);\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: DesignParameterReferenceCounter::countReferencesInComponentInstances()\n//-----------------------------------------------------------------------------\nint DesignParameterReferenceCounter::countReferencesInComponentInstances(QString const& parameterID) const\n{\n    int referenceCounter = 0;\n\n    foreach (QSharedPointer<ComponentInstance> instance, *design_->getComponentInstances())\n    {\n        referenceCounter += countReferencesInSingleComponentInstance(parameterID, instance);\n    }\n\n    return referenceCounter;\n}\n\n//-----------------------------------------------------------------------------\n// Function: DesignParameterReferenceCounter::countReferencesInSingleComponentInstance()\n//-----------------------------------------------------------------------------\nint DesignParameterReferenceCounter::countReferencesInSingleComponentInstance(QString const& parameterID,\n    QSharedPointer<ComponentInstance> instance) const\n{\n    return countReferencesInConfigurableElementValues(parameterID, instance->getConfigurableElementValues());\n}\n\n//-----------------------------------------------------------------------------\n// Function: DesignParameterReferenceCounter::countReferencesInAdHocConnections()\n//-----------------------------------------------------------------------------\nint DesignParameterReferenceCounter::countReferencesInAdHocConnections(QString const& parameterID,\n    QSharedPointer<QList<QSharedPointer<AdHocConnection> > > connections) const\n{\n    int referenceCounter = 0;\n\n    foreach (QSharedPointer<AdHocConnection> connection, *connections)\n    {\n        referenceCounter += countReferencesInSingleAdHocConnection(parameterID, connection);\n    }\n\n    return referenceCounter;\n}\n\n//-----------------------------------------------------------------------------\n// Function: DesignParameterReferenceCounter::countReferencesInSingleAdHocConnection()\n//-----------------------------------------------------------------------------\nint DesignParameterReferenceCounter::countReferencesInSingleAdHocConnection(QString const& parameterID,\n    QSharedPointer<AdHocConnection> connection) const\n{\n    int referenceCounter = 0;\n\n    if (!connection->getInternalPortReferences()->isEmpty() || !connection->getExternalPortReferences()->isEmpty())\n    {\n        referenceCounter += countReferencesInExpression(parameterID, connection->getTiedValue());\n\n        foreach (QSharedPointer<PortReference> port, *connection->getInternalPortReferences())\n        {\n            if (port->getPartSelect())\n            {\n                referenceCounter += countReferencesInPartSelect(parameterID, port->getPartSelect());\n            }\n        }\n        foreach (QSharedPointer<PortReference> port, *connection->getExternalPortReferences())\n        {\n            if (port->getPartSelect())\n            {\n                referenceCounter += countReferencesInPartSelect(parameterID, port->getPartSelect());\n            }\n        }\n    }\n\n    return referenceCounter;\n}\n\n//-----------------------------------------------------------------------------\n// Function: DesignParameterReferenceCounter::countReferencesInPartSelect()\n//-----------------------------------------------------------------------------\nint DesignParameterReferenceCounter::countReferencesInPartSelect(QString const& parameterID,\n    QSharedPointer<PartSelect> partSelect) const\n{\n    int referenceCount = 0;\n\n    if (partSelect)\n    {\n        referenceCount += countReferencesInExpression(parameterID, partSelect->getLeftRange());\n        referenceCount += countReferencesInExpression(parameterID, partSelect->getRightRange());\n    }\n\n    return referenceCount;\n}\n"
  },
  {
    "path": "editors/common/DesignParameterReferenceTree/DesignParameterReferenceCounter.h",
    "content": "//-----------------------------------------------------------------------------\n// File: DesignParameterReferenceCounter.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 06.10.2017\n//\n// Description:\n// Calculates the amount of references made to design parameters.\n//-----------------------------------------------------------------------------\n\n#ifndef DESIGNPARAMETERREFERENCECOUNTER_H\n#define DESIGNPARAMETERREFERENCECOUNTER_H\n\n#include <editors/ComponentEditor/referenceCounter/ParameterReferenceCounter.h>\n\n#include <QVector>\n\nclass Design;\nclass Parameter;\nclass ComponentInstance;\nclass AdHocConnection;\nclass PartSelect;\nclass AbstractParameterInterface;\n\n//-----------------------------------------------------------------------------\n//! Calculates the amount of references made to design parameters.\n//-----------------------------------------------------------------------------\nclass DesignParameterReferenceCounter : public ParameterReferenceCounter\n{\n    Q_OBJECT\n\npublic:\n\n    /*!\n     *  The constructor.\n     *\n     *    @param [in] parameterFinder     Locates the parameters for increasing and decreasing references.\n     */\n    DesignParameterReferenceCounter(QSharedPointer<ParameterFinder> parameterFinder);\n\n    /*!\n     *  The destructor.\n     */\n    ~DesignParameterReferenceCounter() = default;\n\n    /*!\n     *  Set a new design for the reference counter.\n     *\n     *    @param [in] newDesign   The selected design.\n     */\n    void setDesign(QSharedPointer<Design> newDesign);\n\n    /*!\n     *  Count the number of references made to the selected parameter in the contained component instances.\n     *\n     *    @param [in] parameterID     ID of the selected parameter.\n     *\n     *    @return The number of references made to the selected parameter in the contained component instances.\n     */\n    int countReferencesInComponentInstances(QString const& parameterID) const;\n\n    /*!\n     *  Count the number of references made to the selected parameter in a single component instance.\n     *\n     *    @param [in] parameterID     ID of the selected parameter.\n     *    @param [in] instance        The selected component instance.\n     *\n     *    @return The number of references made to the selected parameter in the selected component instance.\n     */\n    int countReferencesInSingleComponentInstance(QString const& parameterID,\n        QSharedPointer<ComponentInstance> instance) const;\n\n    /*!\n     *  Count the number of references made to the selected parameter in the ad hoc connections.\n     *\n     *    @param [in] parameterID     ID of the selected parameter.\n     *    @param [in] connections     The selected ad hoc connections.\n     *\n     *    @return The number of references made to the selected parameter in the ad hoc connections.\n     */\n    int countReferencesInAdHocConnections(QString const& parameterID,\n        QSharedPointer<QList<QSharedPointer<AdHocConnection> > > connections) const;\n\n    /*!\n     *  Count the number of references made to the selected parameter in a single ad hoc connection.\n     *\n     *    @param [in] parameterID     ID of the selected parameter.\n     *    @param [in] connection      The selected ad hoc connection.\n     *\n     *    @return The number of references made to the selected parameter in the selected ad hoc connection.\n     */\n    int countReferencesInSingleAdHocConnection(QString const& parameterID,\n        QSharedPointer<AdHocConnection> connection) const;\n\n    /*!\n     *  Count the number of references made to the selected parameter in a single part select.\n     *\n     *    @param [in] parameterID     ID of the selected parameter.\n     *    @param [in] partSelect      The selected part select.\n     *\n     *    @return The number of references made to the selected parameter in the selected part select.\n     */\n    int countReferencesInPartSelect(QString const& parameterID, QSharedPointer<PartSelect> partSelect) const;\n\npublic slots:\n\n    /*!\n     *  Recalculate references made to the selected parameters.\n     *\n     *    @param [in] parameterList       The selected parameters.\n     *    @param [in] parameterInterface  Interface for accessing parameters.\n     */\n    virtual void recalculateReferencesToParameters(QVector<QString> const& parameterList,\n        AbstractParameterInterface* parameterInterface);\n\nprivate:\n\n\t//! No copying. No assignment.\n    DesignParameterReferenceCounter(const DesignParameterReferenceCounter& other);\n    DesignParameterReferenceCounter& operator=(const DesignParameterReferenceCounter& other);\n\n    //-----------------------------------------------------------------------------\n    // Data.\n    //-----------------------------------------------------------------------------\n\n    //! The design.\n    QSharedPointer<Design> design_;\n};\n\n#endif // DESIGNPARAMETERREFERENCECOUNTER_H\n"
  },
  {
    "path": "editors/common/DesignParameterReferenceTree/DesignParameterReferenceTree.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: DesignParameterReferenceTree.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 28.09.2018\n//\n// Description:\n// Tree widget for displaying references to a parameter within a design.\n//-----------------------------------------------------------------------------\n\n#include \"DesignParameterReferenceTree.h\"\n\n#include <editors/common/DesignParameterReferenceTree/DesignParameterReferenceCounter.h>\n\n#include <IPXACTmodels/Design/Design.h>\n#include <IPXACTmodels/Design/ComponentInstance.h>\n\n//-----------------------------------------------------------------------------\n// Function: DesignParameterReferenceTree::DesignParameterReferenceTree()\n//-----------------------------------------------------------------------------\nDesignParameterReferenceTree::DesignParameterReferenceTree(QSharedPointer<ExpressionFormatter> formatter,\n    QSharedPointer<DesignParameterReferenceCounter> referenceCounter, QWidget* parent):\nParameterReferenceTree(formatter, parent),\ndesign_(0),\nreferenceCounter_(referenceCounter)\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: DesignParameterReferenceTree::~DesignParameterReferenceTree()\n//-----------------------------------------------------------------------------\nDesignParameterReferenceTree::~DesignParameterReferenceTree()\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: DesignParameterReferenceTree::setDesign()\n//-----------------------------------------------------------------------------\nvoid DesignParameterReferenceTree::setDesign(QSharedPointer<Design> newDesign)\n{\n    design_ = newDesign;\n}\n\n//-----------------------------------------------------------------------------\n// Function: DesignParameterReferenceTree::setupTree()\n//-----------------------------------------------------------------------------\nvoid DesignParameterReferenceTree::setupTree()\n{\n    if (design_)\n    {\n        QString targetID = getTargetID();\n\n        if (referenceCounter_->countReferencesInParameters(targetID, design_->getParameters()) > 0)\n        {\n            QTreeWidgetItem* topParametersItem = createTopItem(\"Parameters\");\n            createParameterReferences(design_->getParameters(), topParametersItem);\n        }\n\n        if (referenceCounter_->countReferencesInComponentInstances(targetID) > 0)\n        {\n            createReferencesForComponentInstances();\n        }\n\n        if (referenceCounter_->countReferencesInAdHocConnections(targetID, design_->getAdHocConnections()) > 0)\n        {\n            createReferencesForAdHocConnections();\n        }\n\n        if (topLevelItemCount() == 0)\n        {\n            createTopItem(\"No references found.\");\n        }\n    }\n    else\n    {\n        createTopItem(\"Design does not exist.\");\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: DesignParameterReferenceTree::getReferenceCounter()\n//-----------------------------------------------------------------------------\nQSharedPointer<ParameterReferenceCounter> DesignParameterReferenceTree::getReferenceCounter() const\n{\n    return referenceCounter_;\n}\n\n//-----------------------------------------------------------------------------\n// Function: DesignParameterReferenceTree::createReferencesForComponentInstances()\n//-----------------------------------------------------------------------------\nvoid DesignParameterReferenceTree::createReferencesForComponentInstances()\n{\n    QTreeWidgetItem* instancesItem = createTopItem(QString(\"Component Instances\"));\n\n    foreach (QSharedPointer<ComponentInstance> instance, *design_->getComponentInstances())\n    {\n        if (referenceCounter_->countReferencesInSingleComponentInstance(getTargetID(), instance) > 0)\n        {\n            createReferencesForSingleComponentInstance(instance, instancesItem);\n        }\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: DesignParameterReferenceTree::createReferencesForSingleComponentInstance()\n//-----------------------------------------------------------------------------\nvoid DesignParameterReferenceTree::createReferencesForSingleComponentInstance(\n    QSharedPointer<ComponentInstance> instance, QTreeWidgetItem* instancesItem)\n{\n    QTreeWidgetItem* singleInstanceItem = createMiddleItem(instance->getInstanceName(), instancesItem);\n\n    if (referenceCounter_->countReferencesInConfigurableElementValues(\n        getTargetID(), instance->getConfigurableElementValues()) > 0)\n    {\n        createReferencesForConfigurableElementValues(instance->getConfigurableElementValues(), singleInstanceItem);\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: DesignParameterReferenceTree::createReferencesForAdHocConnections()\n//-----------------------------------------------------------------------------\nvoid DesignParameterReferenceTree::createReferencesForAdHocConnections()\n{\n    QTreeWidgetItem* connectionsItem = createTopItem(QString(\"Ad Hoc Connections\"));\n\n    QString topComponentName(\"Top Component\");\n\n    QMultiMap<QString, QSharedPointer<AdHocConnection> > connectionsInOrder =\n        getAdHocConnectionsInComponentOrder(topComponentName);\n\n    QSharedPointer<QList<QSharedPointer<AdHocConnection> > > topComponentConnections(\n        new QList<QSharedPointer<AdHocConnection> >(connectionsInOrder.values(topComponentName)));\n    connectionsInOrder.remove(topComponentName);\n\n    QString targetID = getTargetID();\n\n    createAdHocItemsForComponent(topComponentName, topComponentConnections, connectionsItem);\n\n    QStringList referencedInstanceList = connectionsInOrder.keys();\n    referencedInstanceList.removeDuplicates();\n    foreach (QString componentName, referencedInstanceList)\n    {\n        QSharedPointer<QList<QSharedPointer<AdHocConnection> > > connections(\n            new QList<QSharedPointer<AdHocConnection> > (connectionsInOrder.values(componentName)));\n        if (!connections->isEmpty())\n        {\n            createAdHocItemsForComponent(componentName, connections, connectionsItem);\n        }\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: DesignParameterReferenceTree::createAdHocItemsForComponent()\n//-----------------------------------------------------------------------------\nvoid DesignParameterReferenceTree::createAdHocItemsForComponent(QString const& componentName,\n    QSharedPointer<QList<QSharedPointer<AdHocConnection> > > connections, QTreeWidgetItem* connectionsItem)\n{\n    QString targetID = getTargetID();\n    if (referenceCounter_->countReferencesInAdHocConnections(targetID, connections) > 0)\n    {\n        QTreeWidgetItem* componentItem = createMiddleItem(componentName, connectionsItem);\n\n        foreach (QSharedPointer<AdHocConnection> singleConnection, *connections)\n        {\n            if (referenceCounter_->countReferencesInSingleAdHocConnection(targetID, singleConnection) > 0)\n            {\n                createReferencesForSingleAdHocConnection(singleConnection, componentItem);\n            }\n        }\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: DesignParameterReferenceTree::DesignParameterReferenceTree()\n//-----------------------------------------------------------------------------\nQMultiMap<QString, QSharedPointer<AdHocConnection> > DesignParameterReferenceTree::getAdHocConnectionsInComponentOrder(\n    QString const& topComponentName) const\n{\n    QMultiMap<QString, QSharedPointer<AdHocConnection> > connectionsInOder;\n\n    foreach (QSharedPointer<AdHocConnection> connection, *design_->getAdHocConnections())\n    {\n        if (connection->getInternalPortReferences()->size() == 1 &&\n            connection->getExternalPortReferences()->isEmpty())\n        {\n            QSharedPointer<PortReference> port = connection->getInternalPortReferences()->first();\n            connectionsInOder.insert(port->getComponentRef(), connection);\n        }\n        else if (connection->getExternalPortReferences()->size() == 1 &&\n            connection->getInternalPortReferences()->isEmpty())\n        {\n            connectionsInOder.insert(topComponentName, connection);\n        }\n    }\n\n    return connectionsInOder;\n}\n\n//-----------------------------------------------------------------------------\n// Function: DesignParameterReferenceTree::createReferencesForSingleAdHocConnection()\n//-----------------------------------------------------------------------------\nvoid DesignParameterReferenceTree::createReferencesForSingleAdHocConnection(\n    QSharedPointer<AdHocConnection> connection, QTreeWidgetItem* componentItem)\n{\n    QSharedPointer<PortReference> connectedPort = getTiedValuePort(connection);\n    QTreeWidgetItem* portItem = createMiddleItem(connectedPort->getPortRef(), componentItem);\n\n    QString targetID = getTargetID();\n    QString tiedValue = connection->getTiedValue();\n    if (!tiedValue.isEmpty() && referenceCounter_->countReferencesInExpression(targetID, tiedValue) > 0)\n    {\n        createItem(QStringLiteral(\"Tied value\"), tiedValue, portItem);\n    }\n\n    if (connectedPort && connectedPort->getPartSelect())\n    {\n        QString portLeftBound = connectedPort->getPartSelect()->getLeftRange();\n        if (referenceCounter_->countReferencesInExpression(targetID, portLeftBound) > 0)\n        {\n            createItem(QStringLiteral(\"Tied value left bound\"), portLeftBound, portItem);\n        }\n\n        QString portRightBound = connectedPort->getPartSelect()->getRightRange();\n        if (referenceCounter_->countReferencesInExpression(targetID, portRightBound) > 0)\n        {\n            createItem(QStringLiteral(\"Tied value right bound\"), portRightBound, portItem);\n        }\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: DesignParameterReferenceTree::getTiedValuePort()\n//-----------------------------------------------------------------------------\nQSharedPointer<PortReference> DesignParameterReferenceTree::getTiedValuePort(\n    QSharedPointer<AdHocConnection> connection) const\n{\n    if (!connection->getInternalPortReferences()->isEmpty())\n    {\n        return connection->getInternalPortReferences()->first();\n    }\n    else if (!connection->getExternalPortReferences()->isEmpty())\n    {\n        return connection->getExternalPortReferences()->first();\n    }\n\n    return QSharedPointer<PortReference>();\n}"
  },
  {
    "path": "editors/common/DesignParameterReferenceTree/DesignParameterReferenceTree.h",
    "content": "//-----------------------------------------------------------------------------\n// File: DesignParameterReferenceTree.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 28.09.2018\n//\n// Description:\n// Tree widget for displaying references to a parameter within a design.\n//-----------------------------------------------------------------------------\n\n#ifndef DESIGNPARAMETERREFERENCETREE_H\n#define DESIGNPARAMETERREFERENCETREE_H\n\n#include <editors/ComponentEditor/parameterReferenceTree/ParameterReferenceTree.h>\n\n#include <QSharedPointer>\n\nclass Design;\nclass ComponentInstance;\nclass DesignParameterReferenceCounter;\nclass AdHocConnection;\nclass PortReference;\n\n//-----------------------------------------------------------------------------\n//! Tree widget for displaying references to a parameter within a design.\n//-----------------------------------------------------------------------------\nclass DesignParameterReferenceTree : public ParameterReferenceTree\n{\n    Q_OBJECT\n\npublic:\n\n    /*!\n     *   The constructor.\n     *\n     *    @param [in] formatter           Formatter for expressions.\n     *    @param [in] referenceCounter    Calculates parameter references.\n     *    @param [in] parent              The parent widget.\n     */\n    DesignParameterReferenceTree(QSharedPointer<ExpressionFormatter> formatter,\n        QSharedPointer<DesignParameterReferenceCounter> referenceCounter, QWidget* parent = 0);\n\n\t/*!\n     *  The destructor.\n     */\n    ~DesignParameterReferenceTree();\n\n    /*!\n     *  Set a new design containing the referable parameters.\n     *\n     *    @param [in] newDesign   The selected design.\n     */\n    void setDesign(QSharedPointer<Design> newDesign);\n\nprivate:\n    \n\t// Disable copying.\n    DesignParameterReferenceTree(DesignParameterReferenceTree const& rhs);\n    DesignParameterReferenceTree& operator=(DesignParameterReferenceTree const& rhs);\n\n    /*!\n     *  Setup the reference tree.\n     */\n    void setupTree();\n\n    /*!\n     *  Get the used parameter reference counter.\n     *\n     *    @return The design parameter reference calculator.\n     */\n    QSharedPointer<ParameterReferenceCounter> getReferenceCounter() const;\n\n    /*!\n     *  Create reference items for the component instances.\n     */\n    void createReferencesForComponentInstances();\n\n    /*!\n     *  Create reference items for a single component instance.\n     *\n     *    @param [in] instance        The selected component instance.\n     *    @param [in] instancesItem   The parent item for the component instance item.\n     */\n    void createReferencesForSingleComponentInstance(QSharedPointer<ComponentInstance> instance,\n        QTreeWidgetItem* instancesItem);\n\n    /*!\n     *  Create reference items for ad hoc connections.\n     */\n    void createReferencesForAdHocConnections();\n\n    /*!\n     *  Get the ad hoc connections in order of their referenced components.\n     *\n     *    @param [in] topComponentName    Identifier for the top component.\n     *\n     *    @return Map containing the name of the referenced component and ad hoc connections.\n     */\n    QMultiMap<QString, QSharedPointer<AdHocConnection> > getAdHocConnectionsInComponentOrder(\n        QString const& topComponentName) const;\n\n    /*!\n     *  Create ad hoc connection reference items for a single component instance.\n     *\n     *    @param [in] componentName       Name of the selected component instance\n     *    @param [in] connections         List of all the ad hoc connections with ports referencing the selected\n     *                                      component.\n     *    @param [in] connectionsItem     The parent item for the component item.\n     */\n    void createAdHocItemsForComponent(QString const& componentName,\n        QSharedPointer<QList<QSharedPointer<AdHocConnection> > > connections, QTreeWidgetItem* connectionsItem);\n\n    /*!\n     *  Create reference items for a single ad hoc connection.\n     *\n     *    @param [in] connection      The selected ad hoc connection.\n     *    @param [in] componentItem   The parent item for the ad hoc connection item.\n     */\n    void createReferencesForSingleAdHocConnection(QSharedPointer<AdHocConnection> connection,\n        QTreeWidgetItem* componentItem);\n\n    /*!\n     *  Get the port for the tied value bounds.\n     *\n     *    @param [in] connection  Ad hoc connection containing the tied value.\n     *\n     *    @return The ad hoc port containing the tied value bounds.\n     */\n    QSharedPointer<PortReference> getTiedValuePort(QSharedPointer<AdHocConnection> connection) const;\n\n    //-----------------------------------------------------------------------------\n    // Data.\n    //-----------------------------------------------------------------------------\n\n    //! The component in which this id is situated.\n    QSharedPointer<Design> design_;\n\n    //! The design parameter reference calculator.\n    QSharedPointer<DesignParameterReferenceCounter> referenceCounter_;\n};\n\n#endif // COMPONENTPARAMETERREFERENCETREE_H\n"
  },
  {
    "path": "editors/common/DesignWidget.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: DesignWidget.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Joni-Matti Maatta\r\n// Date: 12.6.2012\r\n//\r\n// Description:\r\n// Base class for all design widgets.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"DesignWidget.h\"\r\n\r\n\r\n#include <editors/common/ImageExporter.h>\r\n#include <editors/common/DesignDiagram.h>\r\n#include <editors/common/StickyNote/StickyNote.h>\r\n#include <editors/common/StickyNote/StickyNoteRemoveCommand.h>\r\n#include <editors/common/Association/Association.h>\r\n#include <editors/common/Association/AssociationRemoveCommand.h>\r\n\r\n#include <KactusAPI/include/LibraryInterface.h>\r\n\r\n#include <IPXACTmodels/Component/Component.h>\r\n\r\n#include <IPXACTmodels/Design/Design.h>\r\n\r\n#include <QScrollBar>\r\n#include <QVBoxLayout>\r\n#include <QPrinter>\r\n#include <QPrintDialog>\r\n#include <QApplication>\r\n#include <QGraphicsItem>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignWidget::DesignWidget()\r\n//-----------------------------------------------------------------------------\r\nDesignWidget::DesignWidget(LibraryInterface* libHandler, QWidget* parent):\r\nTabDocument(parent, libHandler, DOC_ZOOM_SUPPORT | DOC_DRAW_MODE_SUPPORT | DOC_PRINT_SUPPORT | DOC_PROTECTION_SUPPORT |\r\n    DOC_EDIT_SUPPORT | DOC_VISIBILITY_CONTROL_SUPPORT, 30, 300)\r\n{\r\n    supportedWindows_ |= TabDocument::VENDOREXTENSIONWINDOW;\r\n\r\n    view_->setViewportUpdateMode(QGraphicsView::MinimalViewportUpdate);\r\n    view_->setTransformationAnchor(QGraphicsView::AnchorUnderMouse);\r\n    view_->setAlignment(Qt::AlignLeft | Qt::AlignTop);\r\n\r\n    auto layout = new QVBoxLayout(this);\r\n    layout->addWidget(view_);\r\n\r\n    view_->verticalScrollBar()->setTracking(true);\r\n//     connect(view_->verticalScrollBar(), SIGNAL(valueChanged(int)), this, SLOT(onVerticalScroll(int)));\r\n\r\n\taddVisibilityControl(tr(\"Sticky Notes\"), true);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignWidget::~DesignWidget()\r\n//-----------------------------------------------------------------------------\r\nDesignWidget::~DesignWidget()\r\n{\r\n    view_->verticalScrollBar()->disconnect(this);\r\n\r\n    delete diagram_;\r\n    diagram_ = nullptr;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignWidget::getIdentifyingVLNV()\r\n//-----------------------------------------------------------------------------\r\nVLNV DesignWidget::getIdentifyingVLNV() const \r\n{\r\n    const QSharedPointer<DesignConfiguration> designConf = diagram_->getDesignConfiguration();\r\n\r\n    if (designConf)\r\n    {\r\n        return designConf->getDesignRef();\r\n    }\r\n    else\r\n    {\r\n        return editedComponent_->getHierRef(viewName_);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignWidget::setDiagram()\r\n//-----------------------------------------------------------------------------\r\nvoid DesignWidget::setDiagram(DesignDiagram* diagram)\r\n{\r\n    diagram_ = diagram;\r\n\r\n    connect(diagram_, SIGNAL(openComponent(const VLNV&)),\r\n        this, SIGNAL(openComponent(const VLNV&)), Qt::UniqueConnection);\r\n    connect(diagram_, SIGNAL(openDesign(const VLNV&, const QString&)),\r\n        this, SIGNAL(openDesign(const VLNV&, const QString&)), Qt::UniqueConnection);\r\n    connect(diagram_, SIGNAL(openSWDesign(const VLNV&, QString const&)),\r\n        this, SIGNAL(openSWDesign(const VLNV&, QString const&)), Qt::UniqueConnection);\r\n    connect(diagram_, SIGNAL(openBus(VLNV const&)),\r\n        this, SIGNAL(openBus(VLNV const&)), Qt::UniqueConnection);\r\n    connect(diagram_, SIGNAL(openCSource(ComponentItem*)),\r\n        this, SIGNAL(openCSource(ComponentItem*)), Qt::UniqueConnection);\r\n\r\n    connect(diagram_, SIGNAL(componentSelected(ComponentItem*)),\r\n        this, SIGNAL(componentSelected(ComponentItem*)), Qt::UniqueConnection);\r\n    connect(diagram_, SIGNAL(interfaceSelected(ConnectionEndpoint*)),\r\n        this, SIGNAL(interfaceSelected(ConnectionEndpoint*)), Qt::UniqueConnection);\r\n    connect(diagram_, SIGNAL(connectionSelected(GraphicsConnection*)),\r\n        this, SIGNAL(connectionSelected(GraphicsConnection*)), Qt::UniqueConnection);\r\n    connect(diagram_, SIGNAL(clearItemSelection()),\r\n        this, SIGNAL(clearItemSelection()), Qt::UniqueConnection);\r\n    connect(diagram_, SIGNAL(componentInstantiated(ComponentItem*)),\r\n        this, SIGNAL(componentInstantiated(ComponentItem*)), Qt::UniqueConnection);\r\n    connect(diagram_, SIGNAL(componentInstanceRemoved(ComponentItem*)),\r\n        this, SIGNAL(componentInstanceRemoved(ComponentItem*)), Qt::UniqueConnection);\r\n\r\n    connect(diagram_, SIGNAL(errorMessage(const QString&)),\r\n        this, SIGNAL(errorMessage(const QString&)), Qt::UniqueConnection);\r\n    connect(diagram_, SIGNAL(noticeMessage(const QString&)),\r\n        this, SIGNAL(noticeMessage(const QString&)), Qt::UniqueConnection);\r\n    connect(diagram_, SIGNAL(helpUrlRequested(QString const&)),\r\n        this, SIGNAL(helpUrlRequested(QString const&)), Qt::UniqueConnection);\r\n\r\n    connect(diagram_, SIGNAL(deleteSelectedItems()), this, SLOT(onDeleteSelectedItems()), Qt::UniqueConnection);\r\n\r\n    view_->setScene(diagram_);\r\n    centerViewTo(QPointF(0, 0));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignWidget::setZoomLevel()\r\n//-----------------------------------------------------------------------------\r\nvoid DesignWidget::setZoomLevel(int level)\r\n{\r\n    TabDocument::setZoomLevel(level);\r\n\r\n    double newScale = getZoomLevel() / 100.0;\r\n    QTransform oldMatrix = view_->transform();\r\n    view_->resetTransform();\r\n    view_->translate(oldMatrix.dx(), oldMatrix.dy());\r\n    view_->scale(newScale, newScale);\r\n\r\n    emit zoomChanged();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignWidget::fitInView()\r\n//-----------------------------------------------------------------------------\r\nvoid DesignWidget::fitInView()\r\n{\r\n    QRectF itemRect = diagram_->itemsBoundingRect();\r\n    float scaleX = qMax(0, view_->width() - 10 - view_->verticalScrollBar()->width()) / itemRect.width();\r\n    float scaleY = qMax(0, view_->height() - 10 - view_->horizontalScrollBar()->height()) / itemRect.height();\r\n\r\n    int scaleLevel = int(qMin(scaleX, scaleY) * 10) * 10;\r\n    setZoomLevel(scaleLevel);\r\n\r\n    centerViewTo(itemRect.center());\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignWidget::setMode()\r\n//-----------------------------------------------------------------------------\r\nvoid DesignWidget::setMode(DrawMode mode)\r\n{\r\n    diagram_->setMode(mode);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignWidget::setProtection()\r\n//-----------------------------------------------------------------------------\r\nvoid DesignWidget::setProtection(bool locked)\r\n{\r\n    TabDocument::setProtection(locked);\r\n    diagram_->setProtection(locked);\r\n    diagram_->setMode(MODE_SELECT);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignWidget::refresh()\r\n//-----------------------------------------------------------------------------\r\nvoid DesignWidget::refresh()\r\n{\r\n\tQApplication::setOverrideCursor(QCursor(Qt::WaitCursor));\r\n\r\n    QSharedPointer<Component> comp = getLibHandler()->getModel(editedComponent_->getVlnv()).staticCast<Component>();\r\n\r\n    setDesign(comp, viewName_);\r\n\r\n    // Change modified only if document was refreshed by the document itself, not related document\r\n    if (!refreshWasRequested())\r\n    {\r\n        setModified(false);\r\n    }\r\n\r\n    TabDocument::refresh();\r\n\r\n\tQApplication::restoreOverrideCursor();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignWidget::getOpenDocument()\r\n//-----------------------------------------------------------------------------\r\nVLNV DesignWidget::getOpenDocument() const\r\n{\r\n    if (editedComponent_ != nullptr)\r\n    {\r\n        return editedComponent_->getVlnv();\r\n    }\r\n\r\n    return VLNV();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignWidget::getDocumentVLNV()\r\n//-----------------------------------------------------------------------------\r\nVLNV DesignWidget::getDocumentVLNV() const\r\n{\r\n    return editedComponent_->getVlnv();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignWidget::getEditProvider()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<IEditProvider> DesignWidget::getEditProvider() const\r\n{\r\n    return editProvider_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignWidget::save()\r\n//-----------------------------------------------------------------------------\r\nbool DesignWidget::save()\r\n{\r\n    getDiagram()->updateHierComponent();\r\n\r\n    // Create the design.\r\n    QSharedPointer<Design> design = getDiagram()->getDesign();\r\n    QSharedPointer<DesignConfiguration> designConf = getDiagram()->getDesignConfiguration();\r\n\r\n    if (design == nullptr)\r\n    {\r\n        return false;\r\n    }\r\n\r\n    getLibHandler()->beginSave();\r\n\r\n    bool writeSucceeded = true;\r\n\r\n    // Write the files.\r\n    if (designConf && !getLibHandler()->writeModelToFile(designConf))\r\n    {\r\n        writeSucceeded = false;\r\n    }\r\n\r\n    if (!getLibHandler()->writeModelToFile(design))\r\n    {\r\n        writeSucceeded = false;\r\n    }\r\n\r\n    if (!getLibHandler()->writeModelToFile(editedComponent_))\r\n    {\r\n        writeSucceeded = false;\r\n    }\r\n\r\n    getLibHandler()->endSave();\r\n\r\n    if (writeSucceeded)\r\n    {\r\n        return TabDocument::save();\r\n    }\r\n    else\r\n    {\r\n        emit errorMessage(tr(\"Error saving design to disk.\"));\r\n        return false;\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignWidget::onVerticalScroll()\r\n//-----------------------------------------------------------------------------\r\nvoid DesignWidget::onVerticalScroll(int y)\r\n{\r\n    QPointF pt(0.0, y);\r\n    QTransform mat = view_->transform().inverted();\r\n    diagram_->onVerticalScroll(mat.map(pt).y());\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignWidget::setDesign()\r\n//-----------------------------------------------------------------------------\r\nbool DesignWidget::setDesign(QSharedPointer<Component> component, const QString& viewName)\r\n{\r\n    editedComponent_ = component;\r\n    viewName_ = viewName;\r\n    return true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignWidget::removeSelectedNotes()\r\n//-----------------------------------------------------------------------------\r\nvoid DesignWidget::removeSelectedNotes()\r\n{\r\n    QList<QGraphicsItem*> selectedItems = getDiagram()->selectedItems();\r\n    getDiagram()->clearSelection();\r\n\r\n    QSharedPointer<QUndoCommand> parentCommand(new QUndoCommand());\r\n    for (QGraphicsItem* selected : selectedItems)\r\n    {\r\n        auto note = qgraphicsitem_cast<StickyNote*>(selected);\r\n        auto noteRemoveCommand = new StickyNoteRemoveCommand(note, getDiagram(), parentCommand.data());\r\n\r\n        connect(noteRemoveCommand, SIGNAL(addVendorExtension(QSharedPointer<VendorExtension>)),\r\n            diagram_, SLOT(onVendorExtensionAdded(QSharedPointer<VendorExtension>)), Qt::UniqueConnection);\r\n\r\n        connect(noteRemoveCommand, SIGNAL(removeVendorExtension(QSharedPointer<VendorExtension>)),\r\n            diagram_, SLOT(onVendorExtensionRemoved(QSharedPointer<VendorExtension>)), Qt::UniqueConnection);\r\n\r\n        noteRemoveCommand->redo();\r\n    }\r\n\r\n    getEditProvider()->addCommand(parentCommand);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignWidget::removeSelectedAssociations()\r\n//-----------------------------------------------------------------------------\r\nvoid DesignWidget::removeSelectedAssociations()\r\n{\r\n    QList<QGraphicsItem*> selectedItems = getDiagram()->selectedItems();\r\n    getDiagram()->clearSelection();\r\n\r\n    QSharedPointer<QUndoCommand> parentCommand(new QUndoCommand());\r\n    for (QGraphicsItem* selected : selectedItems)\r\n    {\r\n        auto association = qgraphicsitem_cast<Association*>(selected);\r\n        auto associationRemoveCmd = new AssociationRemoveCommand(association, getDiagram(), parentCommand.data()); \r\n        associationRemoveCmd->redo();\r\n    }\r\n\r\n    getEditProvider()->addCommand(parentCommand);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignWidget::getDiagram()\r\n//-----------------------------------------------------------------------------\r\nDesignDiagram* DesignWidget::getDiagram() const\r\n{\r\n    return diagram_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignWidget::centerViewTo()\r\n//-----------------------------------------------------------------------------\r\nvoid DesignWidget::centerViewTo(QPointF const& centerPoint)\r\n{\r\n    view_->centerOn(centerPoint);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignWidget::getOpenViewName()\r\n//-----------------------------------------------------------------------------\r\nQString DesignWidget::getOpenViewName() const\r\n{\r\n    return viewName_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignWidget::getEditedComponent()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<Component> DesignWidget::getEditedComponent() const\r\n{\r\n    return editedComponent_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignWidget::print()\r\n//-----------------------------------------------------------------------------\r\nvoid DesignWidget::print()\r\n{\r\n    // get the rect that bounds all items on box\r\n    QRectF boundingRect = diagram_->itemsBoundingRect();\r\n\r\n    // avoid clipping of the edges of the objects by increasing the rect a little\r\n    boundingRect.setHeight(boundingRect.height() + 2);\r\n    boundingRect.setWidth(boundingRect.width() + 2);\r\n\r\n    // set the size of the picture\r\n    QPixmap pic(boundingRect.size().toSize());\r\n\r\n    // render the picture for the design\r\n    QPainter picPainter(&pic);\r\n    picPainter.fillRect(pic.rect(), QBrush(Qt::white));\r\n    diagram_->render(&picPainter, pic.rect(), boundingRect.toRect());\r\n\r\n    // create the printer instance, set default settings for it and\r\n    // execute print dialog for user to select the printer and desired options\r\n    QPrinter printer(QPrinter::ScreenResolution);\r\n    printer.setPageOrientation(QPageLayout::Landscape);\r\n    printer.setPageSize(QPageSize::A4);\r\n    QPrintDialog dialog(&printer, this);\r\n\r\n    if (dialog.exec() == QPrintDialog::Accepted)\r\n    {\r\n        // create painter instance to draw the picture for the printer\r\n        QPainter painter(&printer);\r\n        painter.setRenderHints(QPainter::Antialiasing | QPainter::TextAntialiasing |\r\n            QPainter::SmoothPixmapTransform, true);\r\n\r\n        // scale the picture to match the size of the printer page\r\n        QPixmap scaledPixmap = pic.scaled(printer.pageRect(QPrinter::Point).size().toSize(),\r\n            Qt::KeepAspectRatio, Qt::SmoothTransformation);\r\n\r\n        // draw the picture on the printer\r\n        painter.drawPixmap(printer.pageRect(QPrinter::Point).topLeft(), scaledPixmap);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignWidget::exportImage()\r\n//-----------------------------------------------------------------------------\r\nbool DesignWidget::exportImage()\r\n{\r\n    VLNV designVLNV = getIdentifyingVLNV();\r\n    QString libraryPath = getLibHandler()->getDirectoryPath(designVLNV);\r\n    return ImageExporter::exportImage(libraryPath, designVLNV, diagram_, this);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignWidget::setVisibilityControlState()\r\n//-----------------------------------------------------------------------------\r\nvoid DesignWidget::setVisibilityControlState(QString const& name, bool state)\r\n{\r\n    TabDocument::setVisibilityControlState(name, state);\r\n    diagram_->setVisibilityControlState(name, state);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignWidget::getInstances()\r\n//-----------------------------------------------------------------------------\r\nQList<ComponentItem*> DesignWidget::getInstances() const\r\n{\r\n    return diagram_->getInstances();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: showEvent()\r\n//-----------------------------------------------------------------------------\r\nvoid DesignWidget::showEvent(QShowEvent* event)\r\n{\r\n    TabDocument::showEvent(event);\r\n    diagram_->onShow();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignWidget::setEditedComponent()\r\n//-----------------------------------------------------------------------------\r\nvoid DesignWidget::setEditedComponent(QSharedPointer<Component> component)\r\n{\r\n    editedComponent_ = component;\r\n}\r\n"
  },
  {
    "path": "editors/common/DesignWidget.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: DesignWidget.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Joni-Matti Maatta\r\n// Date: 12.6.2012\r\n//\r\n// Description:\r\n// Base class for all design widgets.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef DESIGNWIDGET_H\r\n#define DESIGNWIDGET_H\r\n\r\n#include <common/widgets/tabDocument/TabDocument.h>\r\n#include <IPXACTmodels/kactusExtensions/KactusAttribute.h>\r\n\r\n#include <common/GenericEditProvider.h>\r\n\r\n#include <QGraphicsView>\r\n#include <QWheelEvent>\r\n\r\nclass LibraryInterface;\r\nclass IEditProvider;\r\nclass GenericEditProvider;\r\nclass MainWindow;\r\nclass ComponentItem;\r\nclass ConnectionEndpoint;\r\nclass GraphicsConnection;\r\nclass Component;\r\nclass DesignDiagram;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Base class for all design widgets that are used to show design diagrams.\r\n//-----------------------------------------------------------------------------\r\nclass DesignWidget : public TabDocument\r\n{\r\n    Q_OBJECT\r\n\r\npublic:\r\n    /*!\r\n     *  Constructor.\r\n     */\r\n    DesignWidget(LibraryInterface* libHandler, QWidget* parent = nullptr);\r\n\r\n    /*!\r\n     *  Destructor.\r\n     */\r\n    virtual ~DesignWidget();\r\n\r\n\t/*! \\brief Get the VLNV that can be used to identify the document.\r\n\t * \r\n\t * Design widget returns the VLNV of the design being edited. \r\n\t *\r\n\t * \\return The VLNV that identifies the document.\r\n\t*/\r\n\tvirtual VLNV getIdentifyingVLNV() const;\r\n\r\n    /*!\r\n     *  Sets the diagram used to visualize the design.\r\n     */\r\n    void setDiagram(DesignDiagram* diagram);\r\n\r\n    /*!\r\n     *  Sets a design to be displayed in the design diagram.\r\n     *\r\n     *    @param [in] vlnv      The VLNV of the top-level component.\r\n     *    @param [in] viewName  The name of the view to open.\r\n     *\r\n     *    @return False if there were errors opening the design; otherwise true.\r\n     */\r\n    virtual bool setDesign(VLNV const& vlnv, QString const& viewName) = 0;\r\n\r\n    /*!\r\n     *  Changes the state of a visibility control.\r\n     *\r\n     *    @param [in] name   The name of the visibility control.\r\n     *    @param [in] state  The new state for the visibility control.\r\n     */\r\n    virtual void setVisibilityControlState(QString const& name, bool state);\r\n\r\n    /*!\r\n     *  Refreshes the document view.\r\n     */\r\n    virtual void refresh();\r\n\r\n    /*!\r\n     *  Prints the design.\r\n     */\r\n    virtual void print();\r\n\r\n    /*!\r\n     *  Exports a screenshot of the document as an image file.\r\n     */\r\n    virtual bool exportImage();\r\n\r\n    /*!\r\n     *  Sets the zoom level of the design.\r\n     *\r\n     *    @param [in] level The zoom level in percents.\r\n     */\r\n    virtual void setZoomLevel(int level);\r\n\r\n    /*!\r\n     *  Fits the whole design in view.\r\n     */\r\n    virtual void fitInView();\r\n\r\n    /*!\r\n     *  Sets the draw mode of the design.\r\n     *\r\n     *    @param [in] mode The draw mode.\r\n     */\r\n    virtual void setMode(DrawMode mode);\r\n\r\n    /*!\r\n     *  Sets the protection state of the document.\r\n     *\r\n     *    @param [in] locked True for locked state; false for unlocked.\r\n     */\r\n    virtual void setProtection(bool locked);\r\n\r\n    /*!\r\n     *  Sets the edited component.\r\n     *\r\n     *    @param [in] component The component to set as the edited one.\r\n     */\r\n    void setEditedComponent(QSharedPointer<Component> component);\r\n\r\n    /*!\r\n     *  Returns the VLNV of the currently open system.\r\n     */\r\n    VLNV getOpenDocument() const;\r\n\r\n    /*! \r\n     *  Returns the vlnv of the edited component.\r\n\t */\r\n\tvirtual VLNV getDocumentVLNV() const;\r\n\r\n    /*!\r\n     *  Returns the the top component being edited.\r\n\t*/\r\n\tQSharedPointer<Component> getEditedComponent() const;\r\n\r\n    /*!\r\n     *  Returns the name of the view that is currently open.\r\n\t */\r\n\tQString getOpenViewName() const;\r\n\r\n    /*!\r\n     *  Returns the component instances currently in the design.\r\n     */\r\n    QList<ComponentItem*> getInstances() const;\r\n\r\n    /*!\r\n     *  Returns the edit provider.\r\n     *\r\n     *    @return Base class implementation returns null.\r\n     *\r\n     *      @remarks Edit support should be queried with getFlags().\r\n     */\r\n    QSharedPointer<IEditProvider> getEditProvider() const;\r\n\r\n    /*!\r\n     *  Returns the design diagram.\r\n     */\r\n    DesignDiagram* getDiagram() const;\r\n\r\n    /*!\r\n     *  Returns the implementation attribute.\r\n     */\r\n    virtual KactusAttribute::Implementation getImplementation() const = 0;\r\n\r\n    /*!\r\n     *  Centers the current view to a point.\r\n     *\r\n     *    @param [in] centerPoint   The point to center to.\r\n     */\r\n    void centerViewTo(QPointF const& centerPoint);\r\n\r\npublic slots:\r\n    /*! \r\n     *  Saves the design to disk.\r\n     */\r\n    virtual bool save();\r\n\r\n    /*!\r\n     *  Adds a new column to the diagram.\r\n     */\r\n    virtual void addColumn() = 0;\r\n\r\n    //! Called when the vertical scrollbar is scrolled.\r\n    void onVerticalScroll(int y);\r\n\r\n    /*!\r\n     *  Delete the selected items.\r\n     */\r\n    virtual void onDeleteSelectedItems() = 0;\r\n\r\nsignals:\r\n\r\n    //! Emitted when component with given vlnv should be opened in editor.\r\n    void openComponent(const VLNV& vlnv);\r\n\r\n    //! Emitted when a C source file should be opened for editing.\r\n    void openCSource(ComponentItem* compItem);\r\n\r\n    //! Signaled when the draw mode of the diagram has changed.\r\n    void modeChanged(DrawMode mode);\r\n\r\n    //! Signaled when the zoom level has changed.\r\n    void zoomChanged();\r\n\r\n    //! Signaled when the user selects a component on the draw board.\r\n    void componentSelected(ComponentItem* component);\r\n\r\n    //! Signaled when the user selects an interface on the draw board.\r\n    void interfaceSelected(ConnectionEndpoint* endpoint);\r\n\r\n    //! Signaled when the user selects a connection on the draw board.\r\n    void connectionSelected(GraphicsConnection* connection);\r\n\r\n    //! Signaled when all items are deselected.\r\n    void clearItemSelection();\r\n\r\n    //! \\brief Emitted when a new component is instantiated to the design.\r\n    void componentInstantiated(ComponentItem* comp);\r\n\r\n    //! \\brief Emitted when a component instance is removed from the design.\r\n    void componentInstanceRemoved(ComponentItem* comp);\r\n\r\nprotected:\r\n    void showEvent(QShowEvent* event);\r\n\r\n    virtual bool setDesign(QSharedPointer<Component> component, const QString& viewName);\r\n\r\n    //! Removes all selected sticky notes.\r\n    void removeSelectedNotes();\r\n\r\n    //! Removes all selected associations.\r\n    void removeSelectedAssociations();\r\n\r\nprivate:\r\n    // Disable copying.\r\n    DesignWidget(DesignWidget const& rhs);\r\n    DesignWidget& operator=(DesignWidget const& rhs);\r\n\r\n    enum\r\n    {\r\n        EDIT_HISTORY_SIZE = 50\r\n    };\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! The graphics view for showing the diagram.\r\n    QGraphicsView* view_ = new QGraphicsView(this);\r\n\r\n    //! The component being edited.\r\n    QSharedPointer<Component> editedComponent_ = nullptr;\r\n\r\n    //! The name of the hierarchical view being edited.\r\n    QString viewName_;\r\n\r\n    //! The edit provider.\r\n    QSharedPointer<GenericEditProvider> editProvider_ = \r\n        QSharedPointer<GenericEditProvider>(new GenericEditProvider(EDIT_HISTORY_SIZE));\r\n\r\n    //! The design diagram.\r\n    DesignDiagram* diagram_ = nullptr;\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n\r\n#endif // DESIGNWIDGET_H\r\n"
  },
  {
    "path": "editors/common/DesignWidgetFactory.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: DesignWidgetFactory.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Mikko Teuho\r\n// Date: 11.02.2015\r\n//\r\n// Description:\r\n// Interface for design widget factory.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef DESIGNWIDGETFACTORY_H\r\n#define DESIGNWIDGETFACTORY_H\r\n\r\n#include <editors/common/DesignWidget.h>\r\n\r\n#include <KactusAPI/include/LibraryInterface.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Interface for constructing design widgets.\r\n//-----------------------------------------------------------------------------\r\nclass DesignWidgetFactory\r\n{\r\n    //Q_OBJECT\r\n\r\npublic:\r\n\r\n    /*!\r\n     *  Destructor.\r\n     */\r\n    virtual ~DesignWidgetFactory() {};\r\n\r\n    virtual DesignWidget* makeHWDesignWidget(QWidget* parent = 0) = 0;\r\n};\r\n\r\n#endif // DESIGNWIDGETFACTORY_H\r\n"
  },
  {
    "path": "editors/common/DesignWidgetFactoryImplementation.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: DesignWidgetFactoryImplementation.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Mikko Teuho\r\n// Date: 11.02.2015\r\n//\r\n// Description:\r\n// Class for design widget factory.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"DesignWidgetFactoryImplementation.h\"\r\n\r\n#include <editors/HWDesign/HWDesignWidget.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignWidgetFactoryImplementation::DesignWidgetFactoryImplementation()\r\n//-----------------------------------------------------------------------------\r\nDesignWidgetFactoryImplementation::DesignWidgetFactoryImplementation(LibraryInterface* libInterface,\r\n    QSharedPointer<MultipleParameterFinder> designAndInstanceParameterFinder,\r\n    QSharedPointer<ListParameterFinder> designParameterFinder):\r\nlibInterface_(libInterface),\r\ndesignAndInstanceParameterFinder_(designAndInstanceParameterFinder),\r\ndesignParameterFinder_(designParameterFinder)\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignWidgetFactoryImplementation::~DesignWidgetFactoryImplementation()\r\n//-----------------------------------------------------------------------------\r\nDesignWidgetFactoryImplementation::~DesignWidgetFactoryImplementation()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignWidgetFactoryImplementation::makeHWDesignWidget()\r\n//-----------------------------------------------------------------------------\r\nDesignWidget* DesignWidgetFactoryImplementation::makeHWDesignWidget(QWidget* parent /* = 0 */)\r\n{\r\n    DesignWidget* hwDesignWidget (new HWDesignWidget(\r\n        libInterface_, designAndInstanceParameterFinder_, designParameterFinder_, parent));\r\n\r\n    return hwDesignWidget;\r\n}\r\n"
  },
  {
    "path": "editors/common/DesignWidgetFactoryImplementation.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: DesignWidgetFactoryImplementation.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Mikko Teuho\r\n// Date: 11.02.2015\r\n//\r\n// Description:\r\n// Class for design widget factory.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef DESIGNWIDGETFACTORYIMPLEMENTATION_H\r\n#define DESIGNWIDGETFACTORYIMPLEMENTATION_H\r\n\r\n#include \"DesignWidgetFactory.h\"\r\n\r\n#include <editors/common/DesignWidget.h>\r\n\r\n#include <KactusAPI/include/LibraryInterface.h>\r\n\r\nclass MultipleParameterFinder;\r\nclass ListParameterFinder;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Class for constructing design widgets.\r\n//-----------------------------------------------------------------------------\r\nclass DesignWidgetFactoryImplementation : public DesignWidgetFactory\r\n{\r\n\r\npublic:\r\n    /*!\r\n     *  Constructor.\r\n     *\r\n     *    @param [in] libInterface                        Enables access to the library.\r\n     *    @param [in] designAndInstanceParameterFinder    Parameter finder for design parameter reference tree.\r\n     *    @param [in] designParameterFinder               Locates the design parameters.\r\n     */\r\n    DesignWidgetFactoryImplementation(LibraryInterface* libInterface,\r\n        QSharedPointer<MultipleParameterFinder> designAndInstanceParameterFinder,\r\n        QSharedPointer<ListParameterFinder> designParameterFinder);\r\n\r\n    /*!\r\n     *  Destructor.\r\n     */\r\n    ~DesignWidgetFactoryImplementation();\r\n\r\n    /*!\r\n     *  Make the hardware design widget.\r\n     */\r\n    virtual DesignWidget* makeHWDesignWidget(QWidget* parent = 0);\r\n\r\nprivate:\r\n    // Disable copying.\r\n    DesignWidgetFactoryImplementation(DesignWidgetFactoryImplementation const& rhs);\r\n    DesignWidgetFactoryImplementation& operator=(DesignWidgetFactoryImplementation const& rhs);\r\n\r\n    LibraryInterface* libInterface_;\r\n\r\n    //! Parameter finder for design parameter reference tree.\r\n    QSharedPointer<MultipleParameterFinder> designAndInstanceParameterFinder_;\r\n\r\n    //! Locates the design parameters.\r\n    QSharedPointer<ListParameterFinder> designParameterFinder_;\r\n};\r\n\r\n#endif // DESIGNWIDGETFACTORYIMPLEMENTATION_H\r\n"
  },
  {
    "path": "editors/common/DiagramUtil.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: DiagramUtil.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Joni-Matti Maatta\r\n// Date: 23.3.2011\r\n//\r\n// Description:\r\n// Common diagram utility functions.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef DIAGRAMUTIL_H\r\n#define DIAGRAMUTIL_H\r\n\r\n#include <QGraphicsScene>\r\n#include <QRectF>\r\n#include <QPointF>\r\n\r\n//-----------------------------------------------------------------------------\r\n\r\nnamespace DiagramUtil\r\n{\r\n    /*!\r\n     *  Calculates the squared distance from a point to a bounding rectangle.\r\n     *\r\n     *    @param [in] pt    The point.\r\n     *    @param [in] rect  The bounding rectangle.\r\n     *\r\n     *    @return The squared distance.\r\n     */\r\n    inline qreal getSqDistance(QPointF const& pt, QRectF const& rect);\r\n\r\n    /*!\r\n     *  Snaps the given position to a scene item if it is close enough the position.\r\n     *\r\n     *    @param [in] pos           The position against which to snap.\r\n     *    @param [in] scene         The scene whose items are investigated.\r\n     *    @param [in] snapDistance  The snap distance.\r\n     *\r\n     *    @return The snapped item. If null, there was no item close enough\r\n     *              to the given position.\r\n     */\r\n    template <class T>\r\n    T* snapToItem(QPointF const& pos, QGraphicsScene const* scene, qreal snapDistance);\r\n\r\n    /*!\r\n     *  Clamps the given value to the closest ceil of the given resolution.\r\n     *\r\n     *    @param [in] value       The value to be clamped.\r\n     *    @param [in] resolution  The clamping resolution.\r\n     */\r\n    inline int clampCeil(int value, int resolution);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"DiagramUtil.inl\"\r\n\r\n#endif // DIAGRAMUTIL_H\r\n"
  },
  {
    "path": "editors/common/DiagramUtil.inl",
    "content": "//-----------------------------------------------------------------------------\r\n// File: DiagramUtil.inl\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Joni-Matti Maatta\r\n// Date: 23.3.2011\r\n//\r\n// Description:\r\n// Common diagram utility functions.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"diagramgrid.h\"\r\n\r\nnamespace DiagramUtil\r\n{\r\n    //-----------------------------------------------------------------------------\r\n    // Function: getSqDistance()\r\n    //-----------------------------------------------------------------------------\r\n    qreal getSqDistance(QPointF const& pt, QRectF const& rect)\r\n    {\r\n        qreal sqDist = 0.0;\r\n\r\n        // Determine the distance component in x direction.\r\n        if (pt.x() < rect.left())\r\n        {\r\n            qreal delta = (rect.left() - pt.x());\r\n            sqDist += delta * delta;\r\n        }\r\n        else if (pt.x() > rect.right())\r\n        {\r\n            qreal delta = (pt.x() - rect.right());\r\n            sqDist += delta * delta;\r\n        }\r\n\r\n        // Determine the distance component in y direction.\r\n        if (pt.y() < rect.top())\r\n        {\r\n            qreal delta = (rect.top() - pt.y());\r\n            sqDist += delta * delta;\r\n        }\r\n        else if (pt.y() > rect.bottom())\r\n        {\r\n            qreal delta = (pt.y() - rect.bottom());\r\n            sqDist += delta * delta;\r\n        }\r\n\r\n        return sqDist;\r\n    }\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Function: snapToItem()\r\n    //-----------------------------------------------------------------------------\r\n    template <class T>\r\n    T* snapToItem(QPointF const& pos, QGraphicsScene const* scene, qreal snapDistance)\r\n    {\r\n        qreal sqSnapDistance = snapDistance * snapDistance;\r\n        T* closest = 0;\r\n        qreal closestDist = 0.0;\r\n\r\n        // Go through all items that are of type T.\r\n        foreach(QGraphicsItem* item, scene->items())\r\n        {\r\n            T* obj = dynamic_cast<T*>(item);\r\n\r\n            if (obj != 0)\r\n            {\r\n                // Calculate the distance from the point to the bounding rectangle.\r\n                qreal dist = getSqDistance(pos, obj->sceneBoundingRect());\r\n\r\n                // Check if the item was close enough and if it is the closest one up to this point.\r\n                if (dist <= sqSnapDistance && (closest == 0 || dist < closestDist))\r\n                {\r\n                    closest = obj;\r\n                    closestDist = dist;\r\n                }\r\n            }\r\n        }\r\n\r\n        return closest;\r\n    }\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Function: clampCeil()\r\n    //-----------------------------------------------------------------------------\r\n    int clampCeil(int value, int resolution)\r\n    {\r\n        bool negative = value < 0;\r\n\r\n        value = abs(value);\r\n\r\n        // Check if the value needs to be clamped.\r\n        if (value % resolution != 0)\r\n        {\r\n            value = ((value / resolution) + 1) * resolution;\r\n        }\r\n\r\n        if (negative)\r\n        {\r\n            return -value;\r\n        }\r\n        else\r\n        {\r\n            return value;\r\n        }\r\n    }\r\n}\r\n"
  },
  {
    "path": "editors/common/DocumentNameGroupEditor.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: DocumentNameGroupEditor.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Anton Hagqvist\n// Date: 23.05.2023\n//\n// Description:\n// Editor for document name group.\n//-----------------------------------------------------------------------------\n\n#include \"DocumentNameGroupEditor.h\"\n\n#include <IPXACTmodels/common/Document.h>\n\n#include <KactusAPI/include/LibraryInterface.h>\n\n#include <QVBoxLayout>\n#include <QFormLayout>\n\n//-----------------------------------------------------------------------------\n// Function: DocumentNameGroupEditor::DocumentNameGroupEditor()\n//-----------------------------------------------------------------------------\nDocumentNameGroupEditor::DocumentNameGroupEditor(QWidget* parent) :\n    QGroupBox(parent)\n{\n    connect(&displayNameEditor_, SIGNAL(textEdited(QString const&)), this, SLOT(onDisplayNameChanged()), Qt::UniqueConnection);\n    connect(&shortDescriptionEditor_, SIGNAL(textEdited(QString const&)), this, SLOT(onShortDescriptionChanged()), Qt::UniqueConnection);\n    connect(&descriptionEditor_, SIGNAL(textChanged()), this, SLOT(onDescriptionChanged()), Qt::UniqueConnection);\n    setupLayout();\n}\n\n//-----------------------------------------------------------------------------\n// Function: DocumentNameGroupEditor::setDocumentNameGroup()\n//-----------------------------------------------------------------------------\nvoid DocumentNameGroupEditor::setDocumentNameGroup(QSharedPointer<Document> document, QString const& documentPath)\n{\n    document_ = document;\n    setVlnv(document_->getVlnv());\n\n    displayNameEditor_.setText(document_->getDisplayName());\n    shortDescriptionEditor_.setText(document_->getShortDescription());\n\n    if (!documentPath.isEmpty())\n    {\n        pathTitleLabel_.show();\n        path_.setText(documentPath);\n    }\n    else\n    {\n        pathTitleLabel_.hide();\n        path_.hide();\n    }\n\n    bool showStd22Fields = document_->getRevision() == Document::Revision::Std22;\n\n    displayNameEditor_.setVisible(showStd22Fields);\n    shortDescriptionEditor_.setVisible(showStd22Fields);\n    displayNameTitleLabel_.setVisible(showStd22Fields);\n    shortDescriptionTitleLabel_.setVisible(showStd22Fields);\n\n    descriptionEditor_.setPlainText(document_->getDescription());\n    \n    compatibility_.setText(Document::toString(document_->getRevision()));\n}\n\n//-----------------------------------------------------------------------------\n// Function: DocumentNameGroupEditor::setPlaceholderDescription()\n//-----------------------------------------------------------------------------\nvoid DocumentNameGroupEditor::setPlaceholderDescription(QString const& placeholder)\n{\n    descriptionEditor_.setPlaceholderText(placeholder);\n}\n\n//-----------------------------------------------------------------------------\n// Function: DocumentNameGroupEditor::onDisplayNameChanged()\n//-----------------------------------------------------------------------------\nvoid DocumentNameGroupEditor::onDisplayNameChanged()\n{\n    document_->setDisplayName(displayNameEditor_.text());\n    emit contentChanged();\n}\n\n//-----------------------------------------------------------------------------\n// Function: DocumentNameGroupEditor::onShortDescriptionChanged()\n//-----------------------------------------------------------------------------\nvoid DocumentNameGroupEditor::onShortDescriptionChanged()\n{\n    document_->setShortDescription(shortDescriptionEditor_.text());\n    emit contentChanged();\n}\n\n//-----------------------------------------------------------------------------\n// Function: DocumentNameGroupEditor::onDescriptionChanged()\n//-----------------------------------------------------------------------------\nvoid DocumentNameGroupEditor::onDescriptionChanged()\n{\n    document_->setDescription(descriptionEditor_.toPlainText());\n    emit contentChanged();\n}\n\n//-----------------------------------------------------------------------------\n// Function: DocumentNameGroupEditor::setVlnv()\n//-----------------------------------------------------------------------------\nvoid DocumentNameGroupEditor::setVlnv(VLNV const& vlnv)\n{\n    vendor_.setText(vlnv.getVendor());\n    library_.setText(vlnv.getLibrary());\n    name_.setText(vlnv.getName());\n    version_.setText(vlnv.getVersion());\n\n    if (!vlnv.isValid())\n    {\n        if (vlnv.getVendor().isEmpty())\n        {\n            vendor_.setText(\"unassigned\");\n        }\n        if (vlnv.getLibrary().isEmpty())\n        {\n            library_.setText(\"unassigned\");\n        }\n        if (vlnv.getName().isEmpty())\n        {\n            name_.setText(\"unassigned\");\n        }\n        if (vlnv.getVersion().isEmpty())\n        {\n            version_.setText(\"unassigned\");\n        }\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: DocumentNameGroupEditor::setupLayout()\n//-----------------------------------------------------------------------------\nvoid DocumentNameGroupEditor::setupLayout()\n{\n    QVBoxLayout* topLayout = new QVBoxLayout();\n\n    QFormLayout* docNameGroupInfoLayout = new QFormLayout();\n    docNameGroupInfoLayout->addRow(QStringLiteral(\"Vendor:\"), &vendor_);\n    docNameGroupInfoLayout->addRow(QStringLiteral(\"Library:\"), &library_);\n    docNameGroupInfoLayout->addRow(QStringLiteral(\"Name:\"), &name_);\n    docNameGroupInfoLayout->addRow(QStringLiteral(\"Version:\"), &version_);\n    docNameGroupInfoLayout->addRow(QStringLiteral(\"Compatibility:\"), &compatibility_);\n\n    docNameGroupInfoLayout->addRow(&pathTitleLabel_, &path_);\n    docNameGroupInfoLayout->addRow(&displayNameTitleLabel_, &displayNameEditor_);\n    docNameGroupInfoLayout->addRow(&shortDescriptionTitleLabel_, &shortDescriptionEditor_);\n    \n    QWidget* docNameGroupInfo = new QWidget(this);\n    docNameGroupInfo->setLayout(docNameGroupInfoLayout);\n\n    QGroupBox* descriptionEditorBox = new QGroupBox(QStringLiteral(\"Description\"), this);\n    descriptionEditorBox->setFlat(true);\n    \n    QVBoxLayout* descriptionLayout = new QVBoxLayout(descriptionEditorBox);\n    descriptionLayout->addWidget(&descriptionEditor_);\n\n    topLayout->addWidget(docNameGroupInfo);\n    topLayout->addWidget(descriptionEditorBox);\n    topLayout->setContentsMargins(0, 0, 0, 0);\n    \n    setLayout(topLayout);\n}\n\n"
  },
  {
    "path": "editors/common/DocumentNameGroupEditor.h",
    "content": "//-----------------------------------------------------------------------------\n// File: DocumentNameGroupEditor.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Anton Hagqvist\n// Date: 23.05.2023\n//\n// Description:\n// Editor for document name group.\n//-----------------------------------------------------------------------------\n\n#ifndef DOCUMENTNAMEGROUPEDITOR_H\n#define DOCUMENTNAMEGROUPEDITOR_H\n\n#include <QGroupBox>\n#include <QLabel>\n#include <QPlainTextEdit>\n#include <QLineEdit>\n\nclass BusDefinition;\nclass LibraryInterface;\nclass VLNVDisplayer;\nclass VLNV;\nclass Document;\n\n//-----------------------------------------------------------------------------\n//! Editor for document name group.\n//-----------------------------------------------------------------------------\nclass DocumentNameGroupEditor : public QGroupBox\n{\n    Q_OBJECT\n\npublic:\n\n    /*!\n     *  The constructor.\n     *\n     *    @param [in] library     Interface to the library.\n     *    @param [in] parent      The owner of this widget.\n     */\n    DocumentNameGroupEditor(QWidget *parent = nullptr);\n\n    //! No copying. No assignment.\n    DocumentNameGroupEditor(const DocumentNameGroupEditor& other) = delete;\n    DocumentNameGroupEditor& operator=(const DocumentNameGroupEditor& other) = delete;\n\n    /*!\n     *  The destructor.\n     */\n    virtual ~DocumentNameGroupEditor() = default;\n    \n    /*!\n     *  Sets the document name group information of a document.\n     *\n     *    @param [in] document        The document whose information is set.\n     *    @param [in] documentPath    The path to the document.\n     */\n    void setDocumentNameGroup(QSharedPointer<Document> document, QString const& documentPath);\n\n    /*!\n     *\tSet a placeholder text for description editor.\n     *  \n     *    @param [in] placeholder\t    The placeholder text to set.\n     */\n    void setPlaceholderDescription(QString const& placeholder);\n\nsignals:\n    \n    void contentChanged();\n\nprivate slots:\n\n    void onDisplayNameChanged();\n\n    void onShortDescriptionChanged();\n\n    void onDescriptionChanged();\n\nprivate:\n\n    /*\n     *  Set the VLNV information to their respective child widgets.\n     */\n    void setVlnv(VLNV const& vlnv);\n    \n    /*!\n     *  Set the layout of the widget\n     */\n    void setupLayout();\n\n    //-----------------------------------------------------------------------------\n    // Data.\n    //-----------------------------------------------------------------------------\n    \n    //! The document for this editor.\n    QSharedPointer<Document> document_;\n\n    //! The label to display the vendor.\n    QLabel vendor_;\n\n    //! The label to display the library.\n    QLabel library_;\n\n    //! The label to display the name.\n    QLabel name_;\n\n    //! The label to display the version.\n    QLabel version_;\n\n    //! The label to display the document path.\n    QLabel path_;\n\n    //! The label to display \"Path:\".\n    QLabel pathTitleLabel_ = QLabel(QStringLiteral(\"Path:\"));\n\n    //! The label to display \"Display name:\".\n    QLabel displayNameTitleLabel_ = QLabel(QStringLiteral(\"Display name:\"));\n    \n    //! The label to display \"Short description:\".\n    QLabel shortDescriptionTitleLabel_ = QLabel(QStringLiteral(\"Short description:\"));\n\n    //! The label to display IP-XACT standard version compatibility.\n    QLabel compatibility_;\n\n    //! Editor for document display name.\n    QLineEdit displayNameEditor_;\n\n    //! Editor for document short description.\n    QLineEdit shortDescriptionEditor_;\n    \n    //! Editor for document description.\n    QPlainTextEdit descriptionEditor_;\n};\n\n#endif // DOCUMENTNAMEGROUPEDITOR_H\n"
  },
  {
    "path": "editors/common/DrawMode.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: DrawMode.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Joni-Matti Maatta\r\n// Date: 6.5.2011\r\n//\r\n// Description:\r\n// Draw mode enumeration.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef DRAWMODE_H\r\n#define DRAWMODE_H\r\n\r\n//-----------------------------------------------------------------------------\r\n//! DrawMode enumeration.\r\n//-----------------------------------------------------------------------------\r\nenum DrawMode\r\n{\r\n    MODE_NONE           = 0x00,\r\n    MODE_SELECT         = 0x01,\r\n    MODE_CONNECT        = 0x02,\r\n    MODE_INTERFACE      = 0x04,\r\n    MODE_DRAFT          = 0x08,\r\n    MODE_TOGGLE_OFFPAGE = 0x10,\r\n    MODE_LABEL          = 0x20\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n\r\n#endif // DRAWMODE_H\r\n"
  },
  {
    "path": "editors/common/ExpressionSet.h",
    "content": "//-----------------------------------------------------------------------------\n// File: ExpressionSet.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Esko Pekkarinen\n// Date: 20.6.2023\n//\n// Description:\n// Utilities for providing classes needed in expression handling in a bundle.\n//-----------------------------------------------------------------------------\n\n#ifndef EXPRESSIONSET_H\n#define EXPRESSIONSET_H\n\n#include <KactusAPI/include/ParameterFinder.h>\n#include <KactusAPI/include/ExpressionParser.h>\n#include <KactusAPI/include/ExpressionFormatter.h>\n\n#include <QSharedPointer>\n\nstruct ExpressionSet\n{\n    QSharedPointer<ParameterFinder> finder;\n    QSharedPointer<ExpressionParser> parser;\n    QSharedPointer<ExpressionFormatter> formatter;\n};\n\n//-----------------------------------------------------------------------------\n\n#endif // EXPRESSIONSET_H\n"
  },
  {
    "path": "editors/common/GraphicsItemLabel.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: GraphicsItemLabel.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 27.04.2018\n//\n// Description:\n// Text label for design items.\n//-----------------------------------------------------------------------------\n\n#include \"GraphicsItemLabel.h\"\n#include <QToolTip>\n\n//-----------------------------------------------------------------------------\n// Function: GraphicsItemLabel::GraphicsItemLabel()\n//-----------------------------------------------------------------------------\nGraphicsItemLabel::GraphicsItemLabel(QString const& text, QGraphicsItem* parent /* = 0 */):\nQGraphicsProxyWidget(parent)\n{\n    setText(text);\n    setWidget(textLabel_);\n    textLabel_->setStyleSheet(QStringLiteral(\"QLabel {border: 1px solid gray; padding: 0px 0px 1px 1px;}\"));\n}\n\n//-----------------------------------------------------------------------------\n// Function: GraphicsItemLabel::setText()\n//-----------------------------------------------------------------------------\nvoid GraphicsItemLabel::setText(QString const& newText)\n{\n    textLabel_->setText(newText);\n\n    QFontMetrics fontMetric(textLabel_->font());\n    qreal newWidth = fontMetric.horizontalAdvance(newText);\n    setMaximumWidth(newWidth + 10);\n\n    updateLabelGeometry();\n}\n\n//-----------------------------------------------------------------------------\n// Function: GraphicsItemLabel::getText()\n//-----------------------------------------------------------------------------\nQString GraphicsItemLabel::getText() const\n{\n    return textLabel_->text();\n}\n\n//-----------------------------------------------------------------------------\n// Function: GraphicsItemLabel::updateLabelGeometry()\n//-----------------------------------------------------------------------------\nvoid GraphicsItemLabel::updateLabelGeometry()\n{\n    updateGeometry();\n}\n\n//-----------------------------------------------------------------------------\n// Function: GraphicsItemLabel::hoverMoveEvent()\n//-----------------------------------------------------------------------------\nvoid GraphicsItemLabel::hoverMoveEvent(QGraphicsSceneHoverEvent* /*event*/)\n{\n    QGraphicsItem* tooltip_parent = parentItem();\n    while (tooltip_parent != nullptr)\n    {\n        if (tooltip_parent->toolTip().isEmpty())\n        {\n            tooltip_parent = tooltip_parent->parentItem();\n        }\n        else\n        {\n            QToolTip::showText(QCursor::pos(), tooltip_parent->toolTip());\n            break;\n        }\n    }\n}\n"
  },
  {
    "path": "editors/common/GraphicsItemLabel.h",
    "content": "//-----------------------------------------------------------------------------\n// File: GraphicsItemLabel.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 27.04.2018\n//\n// Description:\n// Text label for design items.\n//-----------------------------------------------------------------------------\n\n#ifndef GRAPHICSITEMLABEL_H\n#define GRAPHICSITEMLABEL_H\n\n#include <QGraphicsProxyWidget>\n#include <QLabel>\n\n//-----------------------------------------------------------------------------\n//! Text label for design items.\n//-----------------------------------------------------------------------------\nclass GraphicsItemLabel : public QGraphicsProxyWidget\n{\npublic:\n\n    /*!\n     *  Constructor.\n     *\n     *    @param [in] text    Text for the label.\n     *    @param [in] parent  Parent item of the label.\n     */\n    GraphicsItemLabel(QString const& text, QGraphicsItem* parent = 0);\n\n    /*!\n     *  Destructor.\n     */\n    ~GraphicsItemLabel() override = default;\n\n    /*!\n     *  Set a new text string for the label.\n     *\n     *    @param [in] newText     The selected text string.\n     */\n    void setText(QString const& newText);\n\n    /*!\n     *  Get the current text string of the label.\n     *\n     *    @return The current text string of the label.\n     */\n    QString getText() const;\n\n    /*!\n     *  Update geometry.\n     */\n    void updateLabelGeometry();\n\nprotected:\n\n    /*!\n     *  Handle hover move event.\n     *\n     *    @param [in] event     the event being processed.\n     *      \n     *      @remarks    The function is reimplemented in order to fix the bug.\n     *                  The bug was lock on certain type of cursor after hovering \n     *                  the GraphicsItemLabel.\n     *                  Reimplemented function only displays tooltip of the first \n                        parent with non-empty tooltip.\n     */\n    void hoverMoveEvent(QGraphicsSceneHoverEvent* event) override;\n\nprivate:\n\n\t//! No copying\n    GraphicsItemLabel(const GraphicsItemLabel& other);\n\t\n    //! No assignment\n    GraphicsItemLabel& operator=(const GraphicsItemLabel& other);\n\n    //-----------------------------------------------------------------------------\n    // Data.\n    //-----------------------------------------------------------------------------\n\n    //! Label containing the text string.\n    QLabel* textLabel_ = new QLabel();\n};\n\n#endif // GRAPHICSITEMLABEL_H\n"
  },
  {
    "path": "editors/common/ImageExporter.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: ImageExporter.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 27.04.2018\n//\n// Description:\n// Exports screen shots of the desired areas as a .png or .svg files.\n//-----------------------------------------------------------------------------\n\n#include \"ImageExporter.h\"\n\n#include <IPXACTmodels/common/VLNV.h>\n\n#include <QFileDialog>\n#include <QSvgGenerator>\n#include <QObject>\n#include <QPainter>\n\n//-----------------------------------------------------------------------------\n// Function: ImageExporter::exportImage()\n//-----------------------------------------------------------------------------\nbool ImageExporter::exportImage(QString const& libraryPath, VLNV const& identifyingVLNV, QGraphicsScene* scene,\n    QWidget* parent)\n{\n    QString exportPath = QFileDialog::getSaveFileName(parent, QObject::tr(\"Save image to file\"), libraryPath,\n        QObject::tr(\"SVG image (*.svg);;JPG image (*.jpg);;PNG image (*.png)\"));\n    QString fileExtension = exportPath.right(3);\n\n    if (exportPath.isEmpty() && !fileExtension.isEmpty() &&\n        (fileExtension.compare(\"SVG\", Qt::CaseInsensitive) == 0 ||\n        fileExtension.compare(\"PNG\", Qt::CaseInsensitive) == 0 ||\n        fileExtension.compare(\"JPG\", Qt::CaseInsensitive) == 0))\n    {\n        return false;\n    }\n\n    QRectF boundingRect = scene->itemsBoundingRect();\n    boundingRect.setHeight(boundingRect.height() + 2);\n    boundingRect.setWidth(boundingRect.width() + 2);\n\n    if (fileExtension.compare(QStringLiteral(\"SVG\"), Qt::CaseInsensitive) == 0)\n    {\n        QString description = QString(QObject::tr(\"Memory design of \")) + identifyingVLNV.toString();\n\n        QSvgGenerator generator;\n        generator.setFileName(exportPath);\n        generator.setSize(boundingRect.size().toSize());\n        generator.setViewBox(boundingRect);\n        generator.setTitle(QObject::tr(\"Memory Design\"));\n        generator.setDescription(description);\n\n        QPainter painter;\n        painter.begin(&generator);\n\n        scene->render(&painter);\n\n        painter.end();\n    }\n    else\n    {\n        QPixmap memoryImage(boundingRect.size().toSize());\n        QPainter picPainter(&memoryImage);\n        picPainter.fillRect(memoryImage.rect(), QBrush(Qt::white));\n        scene->render(&picPainter, memoryImage.rect(), boundingRect.toRect());\n        \n        QFile memoryImageFile(exportPath);\n        memoryImageFile.open(QIODevice::WriteOnly);\n        memoryImage.save(&memoryImageFile);\n    }\n\n    return true;\n}\n"
  },
  {
    "path": "editors/common/ImageExporter.h",
    "content": "//-----------------------------------------------------------------------------\n// File: ImageExporter.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 27.04.2018\n//\n// Description:\n// Exports screen shots of the desired areas as a .png or .svg files.\n//-----------------------------------------------------------------------------\n\n#ifndef IMAGEEXPORTER_H\n#define IMAGEEXPORTER_H\n\nclass VLNV;\n\n#include <QWidget>\n#include <QGraphicsScene>\n\n//-----------------------------------------------------------------------------\n//! Exports screen shots of the desired areas as a .png or .svg files.\n//-----------------------------------------------------------------------------\nnamespace ImageExporter\n{\n    /*!\n     *  Export an image of the selected document.\n     *\n     *    @param [in] libraryPath         Library path of the selected document.\n     *    @param [in] identifyingVLNV     VLNV of the component containing the selected document.\n     *    @param [in] scene               Graphics scene of the selected document.\n     *    @param [in] parent              Parent item for determining the export path.\n     */\n    bool exportImage(QString const& libraryPath, VLNV const& identifyingVLNV, QGraphicsScene* scene,\n        QWidget* parent);\n}\n\n#endif // IMAGEEXPORTER_H\n"
  },
  {
    "path": "editors/common/InterfaceEditor/InterfacePortMapColumns.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: InterfacePortMapColumns.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 16.05.2016\r\n//\r\n// Description:\r\n// Common declarations for interface port map.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef INTERFACEPORTMAPCOLUMNS_H\r\n#define INTERFACEPORTMAPCOLUMNS_H\r\n\r\nnamespace InterfacePortMapColumns\r\n{\r\n    //! Defines the columns for the interface port map table.\r\n    enum Columns\r\n    {\r\n        INTERFACE_LOGICAL_NAME = 0,     //!< Column for the logical port name.\r\n        INTERFACE_PHYSICAL_NAME,        //!< Column for the physical port name.\r\n        INTERFACE_EXCLUDE,              //!< Column for toggling port exclusion.\r\n        INTERFACE_COLUMN_COUNT\r\n    };\r\n}\r\n\r\n#endif //INTERFACEPORTMAPCOLUMNS_H"
  },
  {
    "path": "editors/common/InterfaceEditor/InterfacePortMapDelegate.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: InterfacePortMapDelegate.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Mikko Teuho\r\n// Date: 16.05.2016\r\n//\r\n// Description:\r\n// Delegate for the visualizing port maps of a bus interface.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"InterfacePortMapDelegate.h\"\r\n#include \"InterfacePortMapColumns.h\"\r\n\r\n#include <QApplication>\r\n#include <QMouseEvent>\r\n#include <QPainter>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: InterfacePortMapDelegate::InterfacePortMapDelegate()\r\n//-----------------------------------------------------------------------------\r\nInterfacePortMapDelegate::InterfacePortMapDelegate(QObject *parent):\r\nQStyledItemDelegate(parent),\r\nportMapGroupModify_(false),\r\nportMapGroupState_(Qt::Unchecked)\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: InterfacePortMapDelegate::~InterfacePortMapDelegate()\r\n//-----------------------------------------------------------------------------\r\nInterfacePortMapDelegate::~InterfacePortMapDelegate()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: InterfacePortMapDelegate::paint()\r\n//-----------------------------------------------------------------------------\r\nvoid InterfacePortMapDelegate::paint(QPainter *painter, QStyleOptionViewItem const& option,\r\n    QModelIndex const& index) const\r\n{\r\n\tQStyleOptionViewItem viewItemOption(option);\r\n\r\n    if (index.column() == InterfacePortMapColumns::INTERFACE_EXCLUDE)\r\n    {\r\n        QVariant colourVariant = index.data(Qt::BackgroundRole);\r\n        QColor backGroudColor = colourVariant.value<QColor>();\r\n\r\n        painter->fillRect(option.rect, backGroudColor);\r\n\r\n        const int textMargin = QApplication::style()->pixelMetric(QStyle::PM_FocusFrameHMargin) + 1;\r\n\r\n        QRect newRect = QStyle::alignedRect(option.direction, Qt::AlignCenter,\r\n            QSize(option.decorationSize.width() + 5, option.decorationSize.height()),\r\n            QRect(option.rect.x() + textMargin, option.rect.y(),\r\n            option.rect.width() - (2 * textMargin), option.rect.height()));\r\n\r\n        viewItemOption.rect = newRect;\r\n    }\r\n\r\n    QStyledItemDelegate::paint(painter, viewItemOption, index);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: InterfacePortMapDelegate::editorEvent()\r\n//-----------------------------------------------------------------------------\r\nbool InterfacePortMapDelegate::editorEvent(QEvent* event, QAbstractItemModel* model,\r\n    QStyleOptionViewItem const& option, QModelIndex const& index)\r\n{\r\n    Q_ASSERT(event);\r\n    Q_ASSERT(model);\r\n\r\n    // Always reset the ad-hoc group modify flag.\r\n    if (event->type() == QEvent::MouseButtonRelease)\r\n    {\r\n        portMapGroupModify_ = false;\r\n    }\r\n\r\n    // Make sure that the item is checkable.\r\n    Qt::ItemFlags flags = model->flags(index);\r\n\r\n    if (!(flags & Qt::ItemIsUserCheckable) || !(flags & Qt::ItemIsEnabled))\r\n    {\r\n        return false;\r\n    }\r\n\r\n    // Make sure that we have a check state.\r\n    QVariant value = index.data(Qt::CheckStateRole);\r\n\r\n    if (!value.isValid())\r\n    {\r\n        return false;\r\n    }\r\n\r\n    Qt::CheckState newState = static_cast<Qt::CheckState>(value.toInt());\r\n\r\n    // Handle the mouse button events.\r\n    if (event->type() == QEvent::MouseButtonPress)\r\n    {\r\n        const int textMargin = QApplication::style()->pixelMetric(QStyle::PM_FocusFrameHMargin) + 1;\r\n\r\n        QRect checkRect = QStyle::alignedRect(option.direction, Qt::AlignCenter,\r\n            option.decorationSize,\r\n            QRect(option.rect.x() + (2 * textMargin), option.rect.y(),\r\n            option.rect.width() - (2 * textMargin),\r\n            option.rect.height()));\r\n\r\n        if (!checkRect.contains(static_cast<QMouseEvent*>(event)->pos()))\r\n        {\r\n            return false;\r\n        }\r\n\r\n        newState = (static_cast<Qt::CheckState>(value.toInt()) == Qt::Checked ? Qt::Unchecked : Qt::Checked);\r\n        portMapGroupModify_ = true;\r\n        portMapGroupState_ = newState;\r\n    }\r\n    else if (event->type() == QEvent::MouseMove)\r\n    {\r\n        if (!portMapGroupModify_ || static_cast<Qt::CheckState>(value.toInt()) == portMapGroupState_)\r\n        {\r\n            return false;\r\n        }\r\n\r\n        const int textMargin = QApplication::style()->pixelMetric(QStyle::PM_FocusFrameHMargin) + 1;\r\n\r\n        QRect checkRect = QStyle::alignedRect(option.direction, Qt::AlignCenter,\r\n            option.decorationSize,\r\n            QRect(option.rect.x() + (2 * textMargin), option.rect.y(),\r\n            option.rect.width() - (2 * textMargin),\r\n            option.rect.height()));\r\n\r\n        if (!checkRect.contains(static_cast<QMouseEvent*>(event)->pos()))\r\n        {\r\n            return false;\r\n        }\r\n\r\n        newState = portMapGroupState_;\r\n    }\r\n    else if (event->type() == QEvent::KeyPress)\r\n    {\r\n        if (static_cast<QKeyEvent*>(event)->key() != Qt::Key_Space &&\r\n            static_cast<QKeyEvent*>(event)->key() != Qt::Key_Select)\r\n        {\r\n            return false;\r\n        }\r\n    }\r\n    else\r\n    {\r\n        return false;\r\n    }\r\n\r\n    return model->setData(index, newState, Qt::CheckStateRole);\r\n}\r\n"
  },
  {
    "path": "editors/common/InterfaceEditor/InterfacePortMapDelegate.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: InterfacePortMapDelegate.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Mikko Teuho\r\n// Date: 16.05.2016\r\n//\r\n// Description:\r\n// Delegate for the visualizing port maps of a bus interface.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef INTERFACEPORTMAPDELEGATE_H\r\n#define INTERFACEPORTMAPDELEGATE_H\r\n\r\n#include <QStyledItemDelegate>\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Delegate for the visualizing port maps of a bus interface.\r\n//-----------------------------------------------------------------------------\r\nclass InterfacePortMapDelegate : public QStyledItemDelegate\r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\r\n\t/*!\r\n\t *  The constructor.\r\n     *\r\n\t *    @param [in] parent  Pointer to the owner of this delegate.\r\n\t */\r\n\tInterfacePortMapDelegate(QObject *parent = 0);\r\n\t\r\n\t/*!\r\n     *  The destructor.\r\n     */\r\n    virtual ~InterfacePortMapDelegate();\r\n\r\nprotected:\r\n\r\n    /*!\r\n     *  Paint the editor.\r\n     *\r\n     *    @param [in] painter     The used painter.\r\n     *    @param [in] option      The style options.\r\n     *    @param [in] index       The current index.\r\n     */\r\n    void paint(QPainter *painter, QStyleOptionViewItem const& option, QModelIndex const& index) const;\r\n\r\n    /*!\r\n     *  The editor events.\r\n     *\r\n     *    @param [in] event   The event itself.\r\n     *    @param [in] model   The used item model.\r\n     *    @param [in] option  The style options.\r\n     *    @param [in] index   The current model index.\r\n     */\r\n    bool editorEvent(QEvent* event, QAbstractItemModel* model, QStyleOptionViewItem const& option,\r\n        QModelIndex const& index);\r\n\r\nprivate:\r\n\r\n    // Disable copying.\r\n    InterfacePortMapDelegate(InterfacePortMapDelegate const& rhs);\r\n    InterfacePortMapDelegate& operator=(InterfacePortMapDelegate const& rhs);\r\n\r\n    //! Boolean for port map group modify.\r\n    bool portMapGroupModify_;\r\n\r\n    //! The new state for the group modify.\r\n    Qt::CheckState portMapGroupState_;\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n\r\n#endif // ADHOCVISIBILITYDELEGATE_H\r\n"
  },
  {
    "path": "editors/common/InterfaceEditor/InterfacePortMapModel.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: InterfacePortMapModel.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Mikko Teuho\r\n// Date: 16.05.2016\r\n//\r\n// Description:\r\n// Table model for visualizing interface port maps.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"InterfacePortMapModel.h\"\r\n#include \"InterfacePortMapColumns.h\"\r\n\r\n#include <KactusAPI/include/LibraryInterface.h>\r\n\r\n#include <KactusAPI/include/ComponentParameterFinder.h>\r\n#include <KactusAPI/include/IPXactSystemVerilogParser.h>\r\n\r\n#include <common/graphicsItems/ComponentItem.h>\r\n#include <common/graphicsItems/ConnectionEndpoint.h>\r\n\r\n#include <IPXACTmodels/Component/PortMap.h>\r\n#include <IPXACTmodels/Component/BusInterface.h>\r\n#include <IPXACTmodels/Component/Component.h>\r\n#include <IPXACTmodels/Design/Interconnection.h>\r\n#include <IPXACTmodels/Design/ActiveInterface.h>\r\n#include <IPXACTmodels/Design/Design.h>\r\n#include <IPXACTmodels/AbstractionDefinition/AbstractionDefinition.h>\r\n#include <IPXACTmodels/AbstractionDefinition/PortAbstraction.h>\r\n#include <IPXACTmodels/AbstractionDefinition/TransactionalAbstraction.h>\r\n#include <IPXACTmodels/AbstractionDefinition/WireAbstraction.h>\r\n\r\n#include <common/KactusColors.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: InterfacePortMapModel::InterfacePortMapModel()\r\n//-----------------------------------------------------------------------------\r\nInterfacePortMapModel::InterfacePortMapModel(\r\n    QSharedPointer<ParameterFinder> designParameterFinder,\r\n    LibraryInterface* library,\r\n    QObject* parent):\r\nQAbstractTableModel(parent),\r\nlibraryHandler_(library),\r\nmappingItems_(),\r\ninstanceValueParser_(new IPXactSystemVerilogParser(instanceValueFinder_)),\r\nabsDefValueParser_(new IPXactSystemVerilogParser(absDefValueFinder_)),\r\nactiveInterfaces_(),\r\nendPoint_(),\r\nlocked_(true)\r\n{\r\n    instanceValueFinder_->addFinder(designParameterFinder);\r\n    instanceValueFinder_->addFinder(instanceCEVFinder_);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: InterfacePortMapModel::~InterfacePortMapModel()\r\n//-----------------------------------------------------------------------------\r\nInterfacePortMapModel::~InterfacePortMapModel()\r\n{\r\n\r\n}\r\n//-----------------------------------------------------------------------------\r\n// Function: InterfacePortMapModel::setLock()\r\n//-----------------------------------------------------------------------------\r\nvoid InterfacePortMapModel::setLock(bool locked)\r\n{\r\n    locked_ = locked;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: InterfacePortMapModel::setData()\r\n//-----------------------------------------------------------------------------\r\nvoid InterfacePortMapModel::setInterfaceData(ConnectionEndpoint* busItem,\r\n    QString const& activeView,\r\n    QList<QSharedPointer<ActiveInterface>> activeInterfaces)\r\n{\r\n    beginResetModel();\r\n\r\n    endPoint_ = busItem;\r\n    mappingItems_.clear();\r\n    activeInterfaces_.clear();\r\n\r\n    if (busItem->isBus() && !busItem->isHierarchical())\r\n    {\r\n        activeInterfaces_ = activeInterfaces;\r\n    }\r\n\r\n    if (busItem && busItem->isBus() && busItem->getOwnerComponent() && busItem->getBusInterface())\r\n    {\r\n        QSharedPointer<BusInterface> busInterface = busItem->getBusInterface();\r\n        QList<QSharedPointer<PortMap> > portMaps = busInterface->getPortMapsForView(activeView);\r\n\r\n        // get the abstraction def for the interface\r\n        VLNV absDefVLNV;\r\n        QSharedPointer<AbstractionType> abstraction = busInterface->getAbstractionContainingView(activeView);\r\n        if (abstraction && abstraction->getAbstractionRef())\r\n        {\r\n            absDefVLNV = *abstraction->getAbstractionRef().data();\r\n        }\r\n\r\n        QSharedPointer<AbstractionDefinition> absDef;\r\n        if (libraryHandler_->getDocumentType(absDefVLNV) == VLNV::ABSTRACTIONDEFINITION)\r\n        {\r\n            absDef =  libraryHandler_->getModel(absDefVLNV).staticCast<AbstractionDefinition>();\r\n        }\r\n\r\n        // get the component that contains the selected interface\r\n        QSharedPointer<Component> component = busItem->getOwnerComponent();\r\n        setupFinders(busItem, component, absDef);\r\n\r\n        foreach (QSharedPointer<PortMap> portMap, portMaps)\r\n        {\r\n            if (portMap->getLogicalPort() && portMap->getPhysicalPort())\r\n            {\r\n                MappingItem newItem;\r\n\r\n                QString logicalPortName = portMap->getLogicalPort()->name_;\r\n\r\n                newItem.logicalIsOk_ = absDef && absDef->hasPort(logicalPortName, busInterface->getInterfaceMode());\r\n\r\n                int logicalSize = 1;\r\n                if (portMap->getLogicalPort()->range_ || absDef->hasPort(logicalPortName, busInterface->getInterfaceMode()))\r\n                {\r\n                    auto logicalBounds = getLogicalBounds(busInterface, logicalPortName, portMap, absDef);\r\n\r\n                    logicalSize = abs(logicalBounds.leftBound_.toInt() - logicalBounds.rightBound_.toInt()) + 1;\r\n                    if (logicalSize > 1)\r\n                    {\r\n\t\t\t\t\t\tlogicalPortName += \"[\" + logicalBounds.leftBound_ + \"..\" + logicalBounds.rightBound_ + \"]\";\r\n                    }\r\n                }\r\n\r\n                newItem.logicalPort_ = logicalPortName;\r\n\r\n                // display at least the name of physical port\r\n                QString physicalPortName = portMap->getPhysicalPort()->name_;\r\n                newItem.physicalPortName_ = physicalPortName;\r\n                newItem.physicalIsOk_ = (component && component->hasPort(physicalPortName));\r\n\r\n                int physicalSize = 1;\r\n\r\n                int physicalLeft = 0;\r\n                int physicalRight = 0;\r\n                QSharedPointer<PortMap::PhysicalPort> physicalPort = portMap->getPhysicalPort();\r\n                if (portMap->getPhysicalPort()->partSelect_)\r\n                {\r\n                    physicalLeft = instanceValueParser_->parseExpression(physicalPort->partSelect_->getLeftRange()).toInt();\r\n                    physicalRight = instanceValueParser_->parseExpression(physicalPort->partSelect_->getRightRange()).toInt();\r\n\r\n                    physicalSize = abs(physicalLeft - physicalRight) + 1;\r\n                }\r\n                // if port map does not contain physical vector but port is found on the component\r\n                else if (component->hasPort(physicalPortName))\r\n                {\r\n                    QSharedPointer<Port> componentPort = component->getPort(physicalPortName);\r\n\r\n                    physicalLeft = instanceValueParser_->parseExpression(componentPort->getLeftBound()).toInt();\r\n                    physicalRight = instanceValueParser_->parseExpression(componentPort->getRightBound()).toInt();\r\n\r\n                    physicalSize = abs(physicalLeft - physicalRight) + 1;\r\n                }\r\n\r\n                physicalPortName += \"[\" + QString::number(physicalLeft) + \"..\" + QString::number(physicalRight) + \"]\";\r\n\r\n                if (logicalSize != physicalSize)\r\n                {\r\n                    newItem.logicalIsOk_ = false;\r\n                    newItem.physicalIsOk_ = false;\r\n                }\r\n\r\n                newItem.physicalPort_ = physicalPortName;\r\n\r\n                newItem.isExcluded_ = portIsExcluded(newItem.physicalPortName_);\r\n\r\n                mappingItems_.append(newItem);\r\n            }\r\n        }\r\n    }\r\n\r\n    endResetModel();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: InterfacePortMapModel::setupFinders()\r\n//-----------------------------------------------------------------------------\r\nvoid InterfacePortMapModel::setupFinders(ConnectionEndpoint* busItem, QSharedPointer<Component> component, QSharedPointer<AbstractionDefinition> absDef)\r\n{\r\n\tinstanceCEVFinder_->setParameterList(component->getParameters());\r\n    instanceCEVFinder_->setCEVList(QSharedPointer<QList<QSharedPointer<ConfigurableElementValue> > >());\r\n\tif (busItem->parentItem())\r\n\t{\r\n\t\tauto componentItem = dynamic_cast<ComponentItem*>(busItem->parentItem());\r\n\t\tif (componentItem)\r\n\t\t{\r\n\t\t\tinstanceCEVFinder_->setCEVList(componentItem->getComponentInstance()->getConfigurableElementValues());\r\n\t\t}\r\n\t}\r\n\r\n\tif (absDef)\r\n\t{\r\n\t\tabsDefValueFinder_->setParameterList(absDef->getParameters());\r\n\t}\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: InterfacePortMapModel::getLogicalBounds()\r\n//-----------------------------------------------------------------------------\r\nInterfacePortMapModel::PortBounds InterfacePortMapModel::getLogicalBounds(\r\n    QSharedPointer<BusInterface> busInterface,\r\n    QString const& logicalPortName,\r\n    QSharedPointer<PortMap> portMap,\r\n    QSharedPointer<AbstractionDefinition> absDef) const\r\n{\r\n    InterfacePortMapModel::PortBounds portBounds;\r\n\tif (portMap->getLogicalPort()->range_)\r\n\t{\r\n\t\tportBounds.leftBound_ = instanceValueParser_->parseExpression(portMap->getLogicalPort()->range_->getLeft());\r\n        portBounds.rightBound_ = instanceValueParser_->parseExpression(portMap->getLogicalPort()->range_->getRight());\r\n\t}\r\n\telse if (absDef->hasPort(logicalPortName, busInterface->getInterfaceMode()))\r\n\t{\r\n        auto logicalPort = absDef->getPort(logicalPortName);\r\n        QString logicalWidth = \"\";\r\n        if (logicalPort->hasWire())\r\n        {\r\n            logicalWidth = absDefValueParser_->parseExpression(logicalPort->getWire()->getWidth(busInterface->getInterfaceMode(), busInterface->getSystem()));\r\n        }\r\n        else if (logicalPort->hasTransactional())\r\n        {\r\n            logicalWidth = absDefValueParser_->parseExpression(logicalPort->getTransactional()->getWidth(busInterface->getInterfaceMode(), busInterface->getSystem()));\r\n        }\r\n\r\n        portBounds.leftBound_ = QString::number(logicalWidth.toInt() - 1);\r\n\t}\r\n\r\n    return portBounds;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: InterfacePortMapModel::portIsExcluded()\r\n//-----------------------------------------------------------------------------\r\nbool InterfacePortMapModel::portIsExcluded(QString const& portName) const\r\n{\r\n    foreach (QSharedPointer<ActiveInterface> currentInterface, activeInterfaces_)\r\n    {\r\n        if (currentInterface->getExcludePorts()->contains(portName))\r\n        {\r\n            return true;\r\n        }\r\n    }\r\n\r\n    return false;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: InterfacePortMapModel::rowCount()\r\n//-----------------------------------------------------------------------------\r\nint InterfacePortMapModel::rowCount(QModelIndex const& ) const\r\n{\r\n    return mappingItems_.size();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: InterfacePortMapModel::columnCount()\r\n//-----------------------------------------------------------------------------\r\nint InterfacePortMapModel::columnCount(QModelIndex const& parent) const\r\n{\r\n    if (parent.isValid())\r\n    {\r\n        return 0;\r\n    }\r\n\r\n    return InterfacePortMapColumns::INTERFACE_COLUMN_COUNT;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: InterfacePortMapModel::data()\r\n//-----------------------------------------------------------------------------\r\nQVariant InterfacePortMapModel::data(QModelIndex const& index, int role) const\r\n{\r\n    if (!index.isValid() || index.row() < 0 || index.row() >= mappingItems_.size())\r\n    {\r\n        return QVariant();\r\n    }\r\n\r\n    if (role == Qt::DisplayRole)\r\n    {\r\n        if (index.column() == InterfacePortMapColumns::INTERFACE_LOGICAL_NAME)\r\n        {\r\n            return mappingItems_.at(index.row()).logicalPort_;\r\n        }\r\n        else if (index.column() == InterfacePortMapColumns::INTERFACE_PHYSICAL_NAME)\r\n        {\r\n            return mappingItems_.at(index.row()).physicalPort_;\r\n        }\r\n    }\r\n    else if (role == Qt::CheckStateRole && index.column() == InterfacePortMapColumns::INTERFACE_EXCLUDE)\r\n    {\r\n        if (mappingItems_.at(index.row()).isExcluded_)\r\n        {\r\n            return Qt::Checked;\r\n        }\r\n        else\r\n        {\r\n            return Qt::Unchecked;\r\n        }\r\n    }\r\n    else if (role == Qt::ForegroundRole)\r\n    {\r\n        if ((index.column() == InterfacePortMapColumns::INTERFACE_LOGICAL_NAME &&\r\n            !mappingItems_.at(index.row()).logicalIsOk_) ||\r\n            (index.column() == InterfacePortMapColumns::INTERFACE_PHYSICAL_NAME &&\r\n            !mappingItems_.at(index.row()).physicalIsOk_))\r\n        {\r\n            return KactusColors::ERROR;\r\n        }\r\n    }\r\n    else if (role == Qt::BackgroundRole)\r\n    {\r\n        if (index.column() == InterfacePortMapColumns::INTERFACE_EXCLUDE &&\r\n            (endPoint_->isHierarchical() || activeInterfaces_.isEmpty()))\r\n        {\r\n            return KactusColors::DISABLED_FIELD;\r\n        }\r\n        else\r\n        {\r\n            return KactusColors::REGULAR_FIELD;\r\n        }\r\n    }\r\n    else if (role == Qt::ToolTipRole)\r\n    {\r\n        if (index.column() == InterfacePortMapColumns::INTERFACE_LOGICAL_NAME)\r\n        {\r\n            return mappingItems_.at(index.row()).logicalPort_;\r\n        }\r\n        else if (index.column() == InterfacePortMapColumns::INTERFACE_PHYSICAL_NAME)\r\n        {\r\n            return mappingItems_.at(index.row()).physicalPort_;\r\n        }\r\n        else\r\n        {\r\n            return QString(\"\");\r\n        }\r\n    }\r\n\r\n    return QVariant();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: InterfacePortMapModel::headerData()\r\n//-----------------------------------------------------------------------------\r\nQVariant InterfacePortMapModel::headerData(int section, Qt::Orientation orientation, int role) const\r\n{\r\n    if (orientation == Qt::Horizontal && role == Qt::DisplayRole)\r\n    {\r\n        if (section == InterfacePortMapColumns::INTERFACE_LOGICAL_NAME)\r\n        {\r\n            return tr(\"Logical name\");\r\n        }\r\n        else if (section == InterfacePortMapColumns::INTERFACE_PHYSICAL_NAME)\r\n        {\r\n            return tr(\"Physical name\");\r\n        }\r\n        else if (section == InterfacePortMapColumns::INTERFACE_EXCLUDE)\r\n        {\r\n            return tr(\"Exclude\");\r\n        }\r\n    }\r\n\r\n    return QVariant();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: InterfacePortMapModel::setData()\r\n//-----------------------------------------------------------------------------\r\nbool InterfacePortMapModel::setData(const QModelIndex& index, const QVariant& value, int role)\r\n{\r\n    if (locked_ || !index.isValid() || index.row() < 0 || index.row() >= mappingItems_.size())\r\n    {\r\n        return false;\r\n    }\r\n\r\n    if (role == Qt::CheckStateRole)\r\n    {\r\n        bool excludeValue = (value == Qt::Checked);\r\n\r\n        mappingItems_[index.row()].isExcluded_ = excludeValue;\r\n\r\n        foreach (QSharedPointer<ActiveInterface> currentInterface, activeInterfaces_)\r\n        {\r\n            currentInterface->getExcludePorts()->removeAll(mappingItems_.at(index.row()).physicalPortName_);\r\n            \r\n            if (mappingItems_.at(index.row()).isExcluded_)\r\n            {\r\n                currentInterface->getExcludePorts()->append(mappingItems_.at(index.row()).physicalPortName_);\r\n            }\r\n        }\r\n\r\n        emit dataChanged(index, index);\r\n        emit contentChanged();\r\n\r\n        return true;\r\n    }\r\n    \r\n    return false;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: InterfacePortMapModel::flags()\r\n//-----------------------------------------------------------------------------\r\nQt::ItemFlags InterfacePortMapModel::flags(const QModelIndex& index) const\r\n{\r\n    if (!index.isValid())\r\n    {\r\n        return Qt::NoItemFlags;\r\n    }\r\n\r\n    Qt::ItemFlags itemFlags = Qt::NoItemFlags;\r\n\r\n    if (index.column() == InterfacePortMapColumns::INTERFACE_EXCLUDE)\r\n    {\r\n        if (endPoint_->isHierarchical() || activeInterfaces_.isEmpty())\r\n        {\r\n            itemFlags = Qt::NoItemFlags;\r\n        }\r\n        else\r\n        {\r\n            itemFlags |= Qt::ItemIsUserCheckable;\r\n            \r\n            if (!locked_)\r\n            {\r\n                itemFlags |= Qt::ItemIsEnabled;\r\n            }\r\n        }\r\n    }\r\n\r\n    return itemFlags;\r\n}\r\n"
  },
  {
    "path": "editors/common/InterfaceEditor/InterfacePortMapModel.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: InterfacePortMapModel.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Mikko Teuho\r\n// Date: 16.05.2016\r\n//\r\n// Description:\r\n// Table model for visualizing interface port maps.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef INTERFACEPORTMAPMODEL_H\r\n#define INTERFACEPORTMAPMODEL_H\r\n\r\n#include <QAbstractTableModel>\r\n#include <QSharedPointer>\r\n\r\n#include <KactusAPI/include/ListParameterFinder.h>\r\n#include <KactusAPI/include/ParameterConfigurableElementFinder.h>\r\n#include <KactusAPI/include/MultipleParameterFinder.h>\r\n\r\nclass PortMap;\r\nclass BusInterface;\r\nclass LibraryInterface;\r\nclass ConnectionEndpoint;\r\nclass AbstractionDefinition;\r\nclass Component;\r\nclass ExpressionParser;\r\nclass Design;\r\nclass ActiveInterface;\r\nclass ComponentItem;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Table model for visualizing interface port maps.\r\n//-----------------------------------------------------------------------------\r\nclass InterfacePortMapModel : public QAbstractTableModel\r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\r\n\t/*!\r\n     *  The constructor.\r\n\t *\r\n     *    @param [in] designParameterFinder     Parameter finder for design parameters.\r\n     *    @param [in] library                   The library interface.\r\n     *    @param [in] parent                    Pointer to the owner of this model.\r\n\t */\r\n\tInterfacePortMapModel(QSharedPointer<ParameterFinder> designParameterFinder, LibraryInterface* library, QObject* parent);\r\n\r\n\t/*!\r\n     *  The destructor.\r\n     */\r\n    virtual ~InterfacePortMapModel();\r\n\r\n    void setLock(bool locked);\r\n\r\n    /*!\r\n     *  Sets the interface data source being edited.\r\n     *\r\n     *    @param [in] busItem             The data source.\r\n     *    @param [in] activeView          The active view of the item containing the selected bus item..\r\n     *    @param [in] activeInterfaces    A list of active interfaces containing a reference to the selected item.\r\n     */\r\n\tvoid setInterfaceData(ConnectionEndpoint* busItem,\r\n        QString const& activeView,\r\n\t\tQList<QSharedPointer<ActiveInterface> > activeInterfaces);\r\n\r\n\t/*!\r\n     *  Returns the number of rows in the model.\r\n\t *\r\n\t *    @param [in] parent Model index of the parent of the item. Must be invalid because this is not a\r\n     *                  hierarchical model.\r\n\t *\r\n\t *    @return Number of rows currently in the model.\r\n\t */\r\n\tvirtual int rowCount(QModelIndex const& parent = QModelIndex()) const;\r\n\r\n\t/*!\r\n     *  Returns the number of columns in the model.\r\n\t *\r\n\t *    @param [in] parent Model index of the parent of the item. Must be invalid because this is not a\r\n     *                  hierarchical model.\r\n\t *\r\n\t *    @return Always returns 3.\r\n\t */\r\n\tvirtual int columnCount(QModelIndex const& parent = QModelIndex()) const;\r\n\r\n\t/*!\r\n     *  Returns the data for the specified item for specified role.\r\n\t *\r\n\t *    @param [in] index  Identifies the item that's data is wanted.\r\n\t *    @param [in] role   Specifies what kind of data is wanted\r\n\t *\r\n\t *    @return QVariant containing the data.\r\n\t */\r\n\tvirtual QVariant data(QModelIndex const& index, int role = Qt::DisplayRole) const;\r\n\r\n\t/*!\r\n     *  Returns the data for the headers.\r\n\t *\r\n\t *    @param [in] section      The column that's header is wanted\r\n\t *    @param [in] orientation  Only Qt::Horizontal is supported\r\n\t *    @param [in] role         Specified the type of data that is wanted.\r\n\t *\r\n\t *    @return QVariant containing the data to be displayed.\r\n\t */\r\n\tvirtual QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;\r\n\r\n\t/*!\r\n     *  Set the data for specified item.\r\n\t *\r\n\t *    @param [in] index  Specifies the item that's data is modified\r\n\t *    @param [in] value  The value to be set.\r\n\t *    @param [in] role   The role that is trying to modify the data. Only Qt::EditRole\r\n\t *                         is supported.\r\n\t *\r\n\t *    @return True if data was successfully set.\r\n\t */\r\n\tvirtual bool setData(const QModelIndex& index, const QVariant& value, int role = Qt::EditRole);\r\n\r\n\t/*!\r\n     *  Returns information on how specified item can be handled.\r\n\t *\r\n\t *    @param [in] index Specifies the item that's flags are wanted.\r\n\t *\r\n\t *    @return Qt::ItemFlags that define how object can be handled.\r\n\t */\r\n\tvirtual Qt::ItemFlags flags(const QModelIndex& index) const;\r\n\r\nsignals:\r\n\r\n\t/*!\r\n     *  Emitted when contents of the model change.\r\n     */\r\n\tvoid contentChanged();\r\n\r\nprivate:\r\n    // Disable copying.\r\n    InterfacePortMapModel(InterfacePortMapModel const& rhs);\r\n    InterfacePortMapModel& operator=(InterfacePortMapModel const& rhs);\r\n\r\n    /*!\r\n     *  Check if a given port is excluded.\r\n     *\r\n     *    @param [in] portName    Name of the selected port.\r\n     *\r\n     *    @return True, if the selected port is excluded, otherwise false.\r\n     */\r\n    bool portIsExcluded(QString const& portName) const;\r\n    \r\n    /*!\r\n     *  Setup the parameter finders for the selected end point.\r\n     *\r\n     *    @param [in] busItem       The selected end point.\r\n     *    @param [in] component     The component containing the end point.\r\n     *    @param [in] absDef        Abstraction definition of the end point.\r\n     */\r\n    void setupFinders(ConnectionEndpoint* busItem, QSharedPointer<Component> component, QSharedPointer<AbstractionDefinition> absDef);\r\n\r\n    //! Container for logical port bounds.\r\n    struct PortBounds\r\n    {\r\n        //! The left bound value.\r\n        QString leftBound_ = \"0\";\r\n\r\n\t\t//! The right bound value.\r\n\t\tQString rightBound_ = \"0\";\r\n    };\r\n\r\n    /*!\r\n     *  Get the logical bounds of the selected bus interface.\r\n     *\r\n     *    @param [in] busInterface      The selected bus interface.\r\n     *    @param [in] logicalPortName   Name of the mapped logical port.\r\n     *    @param [in] portMap           Port map containing the logical port.\r\n     *    @param [in] absDef            Abstraction definition of the bus interface.\r\n     *\r\n     *    @return \r\n     */\r\n    PortBounds getLogicalBounds(QSharedPointer<BusInterface> busInterface, QString const& logicalPortName, QSharedPointer<PortMap> portMap, QSharedPointer<AbstractionDefinition> absDef) const;\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! Structure of a port mapping item.\r\n    struct MappingItem\r\n    {\r\n        //! The logical port and its bounds.\r\n        QString logicalPort_;\r\n\r\n        //! Informs whether the logical port is ok or not.\r\n        bool logicalIsOk_;\r\n\r\n        //! The name of the physical port.\r\n        QString physicalPortName_;\r\n\r\n        //! The physical port and its bounds.\r\n        QString physicalPort_;\r\n\r\n        //! Informs whether the physical port is ok or not.\r\n        bool physicalIsOk_;\r\n\r\n        //! Is the mapped port excluded.\r\n        bool isExcluded_;\r\n    };\r\n\r\n    //! The library handler\r\n    LibraryInterface* libraryHandler_;\r\n\r\n    //! List of the mapped port items.\r\n    QList<MappingItem> mappingItems_;\r\n\r\n    //! Parameter finder for component parameters, design parameters and CEVs.\r\n\tQSharedPointer<MultipleParameterFinder> instanceValueFinder_ = QSharedPointer<MultipleParameterFinder>(new MultipleParameterFinder());\r\n\r\n    //! Parameter finder for component parameters and CEVs\r\n    QSharedPointer<ParameterConfigurableElementFinder> instanceCEVFinder_ = QSharedPointer<ParameterConfigurableElementFinder>(new ParameterConfigurableElementFinder());\r\n\r\n\t//! Parameter finder for abstraction definition parameters.\r\n    QSharedPointer<ListParameterFinder> absDefValueFinder_ = QSharedPointer<ListParameterFinder>(new ListParameterFinder());\r\n\r\n    //! The expression parser for a component instance.\r\n    QSharedPointer<ExpressionParser> instanceValueParser_;\r\n\r\n    //! The expression parser for an abstraction definition.\r\n    QSharedPointer<ExpressionParser> absDefValueParser_;\r\n\r\n    //! List of the active interfaces referencing the selected end point.\r\n    QList<QSharedPointer<ActiveInterface> > activeInterfaces_;\r\n\r\n    //! The selected end point.\r\n    ConnectionEndpoint* endPoint_;\r\n\r\n    bool locked_;\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n\r\n#endif // INTERFACEPORTMAPMODEL_H"
  },
  {
    "path": "editors/common/InterfaceEditor/interfaceeditor.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: interfaceeditor.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 10.10.2011\r\n//\r\n// Description:\r\n// Editor to display/edit the details of a bus/api/com interface.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"interfaceeditor.h\"\r\n\r\n#include <common/IEditProvider.h>\r\n#include <common/graphicsItems/ComponentItem.h>\r\n#include <common/views/EditableTableView/editabletableview.h>\r\n\r\n#include <editors/common/InterfaceEditor/InterfacePortMapModel.h>\r\n#include <editors/common/InterfaceEditor/InterfacePortMapDelegate.h>\r\n#include <editors/common/InterfaceEditor/InterfacePortMapColumns.h>\r\n\r\n#include <editors/HWDesign/HWConnectionEndpoint.h>\r\n#include <editors/HWDesign/HWChangeCommands.h>\r\n\r\n#include <IPXACTmodels/generaldeclarations.h>\r\n\r\n#include <IPXACTmodels/common/DirectionTypes.h>\r\n\r\n#include <IPXACTmodels/Component/BusInterface.h>\r\n\r\n#include <IPXACTmodels/Design/ActiveInterface.h>\r\n#include <IPXACTmodels/Design/Design.h>\r\n#include <IPXACTmodels/Design/HierInterface.h>\r\n#include <IPXACTmodels/Design/Interconnection.h>\r\n\r\n#include <IPXACTmodels/DesignConfiguration/DesignConfiguration.h>\r\n\r\n#include <IPXACTmodels/common/validators/namevalidator.h>\r\n\r\n#include <IPXACTmodels/kactusExtensions/ApiInterface.h>\r\n#include <IPXACTmodels/kactusExtensions/ComInterface.h>\r\n#include <IPXACTmodels/kactusExtensions/ComDefinition.h>\r\n\r\n#include <QVBoxLayout>\r\n#include <QHeaderView>\r\n\r\nnamespace\r\n{\r\n    enum INTERFACE_TYPE {\r\n        BUS = 0,\r\n        COM, \r\n        API,\r\n        NO_TYPE\r\n    };\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: interfaceeditor::InterfaceEditor()\r\n//-----------------------------------------------------------------------------\r\nInterfaceEditor::InterfaceEditor(QWidget *parent, LibraryInterface* handler):\r\nQStackedWidget(parent),\r\nactiveTopView_(),\r\nlibrary_(handler),\r\nbusType_(this, VLNV(), true),\r\nabsType_(this, VLNV(), true),\r\nbusNameEditor_(this),\r\nmodeSelector_(this),\r\nportMapsView_(this),\r\nportMapsModel_(new InterfacePortMapModel(designParameterFinder_, handler, this)),\r\nbusDescriptionEditor_(this),\r\ncomType_(this, VLNV(), true),\r\ncomNameEditor_(this),\r\ntransferTypeCombo_(this),\r\ncomDirectionCombo_(this),\r\ncomDescriptionEditor_(this),\r\napiType_(this, VLNV(), true),\r\napiNameEditor_(this),\r\ndependencyDirCombo_(this),\r\napiDescriptionEditor_(this),\r\npropertyValueEditor_(this),\r\ninterface_(0),\r\ncontainingDesign_(),\r\ncontainingConfiguration_(),\r\neditProvider_()\r\n{\r\n    Q_ASSERT(parent);\r\n    Q_ASSERT(handler);\r\n\r\n\tsetSizePolicy(QSizePolicy::Preferred, QSizePolicy::Expanding);       \r\n\r\n    setupBusEditor();\r\n    setupComEditor();\r\n    setupApiEditor();\r\n    insertWidget(NO_TYPE, new QWidget(this));\r\n\r\n\tclear();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: interfaceeditor::setInterface()\r\n//-----------------------------------------------------------------------------\r\nvoid InterfaceEditor::setInterface(ConnectionEndpoint* interface, QSharedPointer<Design> containingDesign,\r\n    QSharedPointer<DesignConfiguration> configuration, QString const& activeTopView,\r\n    QSharedPointer<IEditProvider> editProvider, bool locked)\r\n{\r\n\tQ_ASSERT(interface);\r\n\r\n\t//parentWidget()->raise();\r\n\r\n\t// disconnect the previous interface\r\n\tif (interface_)\r\n    {\r\n\t\tdisconnect(interface_, SIGNAL(destroyed(ConnectionEndpoint*)), this, SLOT(clear()));\r\n\t\tdisconnect(interface_, SIGNAL(contentChanged()), this, SLOT(refresh()));\r\n\t}\r\n\r\n    activeTopView_ = activeTopView;\r\n\tinterface_ = interface;\r\n    containingDesign_ = containingDesign;\r\n    containingConfiguration_ = configuration;\r\n    editProvider_ = editProvider;\r\n    locked_ = locked;\r\n\r\n    designParameterFinder_->setParameterList(containingDesign_->getParameters());\r\n\r\n    // Fill the rest of the editors based on the interface type.\r\n    if (interface_->isBus())\r\n    {\r\n        disconnect(&modeSelector_, SIGNAL(currentTextChanged(QString const&)),\r\n            this, SLOT(onInterfaceModeChanged(QString const&)));\r\n        modeSelector_.clear();\r\n\r\n        // set the possible modes to the mode editor\r\n        if (containingDesign->getRevision() == Document::Revision::Std22)\r\n        {\r\n            modeSelector_.addItems(General::INTERFACE_MODES_2022.values());\r\n        }\r\n        else\r\n        {\r\n            modeSelector_.addItems(General::INTERFACE_MODES.values());\r\n        }\r\n\r\n        connect(&modeSelector_, SIGNAL(currentTextChanged(QString const&)),\r\n            this, SLOT(onInterfaceModeChanged(QString const&)), Qt::UniqueConnection);\r\n\r\n        setBusInterface();\r\n    }\r\n    else if (interface_->isApi())\r\n    {\r\n        setApiInterface();\r\n    }\r\n    else if (interface_->isCom())\r\n    {\r\n        setComInterface();\r\n    }\r\n    else\r\n    {\r\n        setCurrentIndex(NO_TYPE);\r\n    }\r\n\r\n\tconnect(interface_, SIGNAL(destroyed(ConnectionEndpoint*)), this, SLOT(clear()), Qt::UniqueConnection);\r\n\tconnect(interface_, SIGNAL(contentChanged()), this, SLOT(refresh()), Qt::UniqueConnection);\r\n\r\n    bool editingEnabled = !locked_ && (interface_->isTemporary() || !interface_->isTypeLocked());\r\n\r\n    busNameEditor_.setEnabled(editingEnabled);\r\n    busDescriptionEditor_.setReadOnly(!editingEnabled);\r\n    modeSelector_.setEnabled(editingEnabled);\r\n    portMapsModel_->setLock(locked_);\r\n\r\n    apiNameEditor_.setEnabled(editingEnabled);\r\n    dependencyDirCombo_.setEnabled(editingEnabled);\r\n    transferTypeCombo_.setEnabled(editingEnabled);\r\n    apiDescriptionEditor_.setReadOnly(!editingEnabled);\r\n\r\n    comNameEditor_.setEnabled(editingEnabled);\r\n    comDirectionCombo_.setEnabled(editingEnabled);\r\n    comDescriptionEditor_.setReadOnly(!editingEnabled);\r\n    propertyValueEditor_.setLock(locked_);    \r\n\r\n\tparentWidget()->setMaximumHeight(QWIDGETSIZE_MAX);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: interfaceeditor::refresh()\r\n//-----------------------------------------------------------------------------\r\nvoid InterfaceEditor::refresh()\r\n{\r\n    Q_ASSERT(interface_);\r\n    setInterface(interface_, containingDesign_, containingConfiguration_, activeTopView_, editProvider_, locked_);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: interfaceeditor::clear()\r\n//-----------------------------------------------------------------------------\r\nvoid InterfaceEditor::clear()\r\n{\r\n    if (interface_)\r\n    {\r\n        disconnect(interface_, SIGNAL(destroyed(ConnectionEndpoint*)), this, SLOT(clear()));\r\n        disconnect(interface_, SIGNAL(contentChanged()), this, SLOT(refresh()));\r\n\r\n        interface_ = 0;\r\n        editProvider_.clear();\r\n    }\r\n\r\n    setCurrentIndex(NO_TYPE);\r\n\r\n    parentWidget()->setMaximumHeight(20);    \r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: interfaceeditor::onInterfaceModeChanged()\r\n//-----------------------------------------------------------------------------\r\nvoid InterfaceEditor::onInterfaceModeChanged(QString const& newMode)\r\n{\r\n\tQ_ASSERT(interface_);\r\n\r\n\tdisconnect(interface_, SIGNAL(contentChanged()), this, SLOT(refresh()));\r\n\r\n\tQSharedPointer<QUndoCommand> cmd(new EndpointChangeCommand(static_cast<HWConnectionEndpoint*>(interface_), \r\n        General::str2Interfacemode(newMode, General::INTERFACE_MODE_COUNT)));\r\n\r\n\teditProvider_->addCommand(cmd);\r\n    cmd->redo();\r\n\r\n\tconnect(interface_, SIGNAL(contentChanged()), this, SLOT(refresh()), Qt::UniqueConnection);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: interfaceeditor::onInterfaceNameChanged()\r\n//-----------------------------------------------------------------------------\r\nvoid InterfaceEditor::onInterfaceNameChanged(QString const& newName)\r\n{\r\n\tQ_ASSERT(interface_);\r\n\t\r\n    disconnect(interface_, SIGNAL(contentChanged()), this, SLOT(refresh()));\t\r\n\r\n\tQSharedPointer<QUndoCommand> cmd(new EndpointNameChangeCommand(interface_, newName, getDesignInterfaces()));\r\n\teditProvider_->addCommand(cmd);\r\n    cmd->redo();\r\n\t\r\n\tconnect(interface_, SIGNAL(contentChanged()), this, SLOT(refresh()), Qt::UniqueConnection);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: interfaceeditor::onDescriptionChanged()\r\n//-----------------------------------------------------------------------------\r\nvoid InterfaceEditor::onDescriptionChanged()\r\n{    \r\n\tQ_ASSERT(interface_);\r\n\r\n    QString interfaceDescription;\r\n    if (interface_->isBus())\r\n    {\r\n        interfaceDescription = busDescriptionEditor_.toPlainText();\r\n    }\r\n    else if (interface_->isCom())\r\n    {\r\n        interfaceDescription = comDescriptionEditor_.toPlainText();\r\n    }\r\n    else if (interface_->isApi())\r\n    {\r\n        interfaceDescription = apiDescriptionEditor_.toPlainText();\r\n    }\r\n\r\n\tdisconnect(interface_, SIGNAL(contentChanged()), this, SLOT(refresh()));\r\n\r\n\tQSharedPointer<QUndoCommand> cmd(new EndpointDescChangeCommand(interface_, interfaceDescription));\r\n\teditProvider_->addCommand(cmd);\r\n    cmd->redo();\r\n\r\n\tconnect(interface_, SIGNAL(contentChanged()), this, SLOT(refresh()), Qt::UniqueConnection);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: InterfaceEditor::onDependencyDirectionChanged()\r\n//-----------------------------------------------------------------------------\r\nvoid InterfaceEditor::onDependencyDirectionChanged(QString const& newDir)\r\n{\r\n    disconnect(interface_, SIGNAL(contentChanged()), this, SLOT(refresh()));\r\n\r\n    QSharedPointer<QUndoCommand> cmd(new EndpointDependencyDirectionChangeCommand(interface_,\r\n        str2DependencyDirection(newDir, DEPENDENCY_PROVIDER)));\r\n\r\n    editProvider_->addCommand(cmd);\r\n    cmd->redo();\r\n\r\n    connect(interface_, SIGNAL(contentChanged()), this, SLOT(refresh()), Qt::UniqueConnection);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: InterfaceEditor::onComDirectionChanged()\r\n//-----------------------------------------------------------------------------\r\nvoid InterfaceEditor::onComDirectionChanged(QString const& newDir)\r\n{\r\n    disconnect(interface_, SIGNAL(contentChanged()), this, SLOT(refresh()));\r\n\r\n    QSharedPointer<QUndoCommand> cmd(new EndpointComDirectionChangeCommand(interface_,\r\n        DirectionTypes::str2Direction(newDir, DirectionTypes::IN)));\r\n\r\n    editProvider_->addCommand(cmd);\r\n    cmd->redo();\r\n\r\n    connect(interface_, SIGNAL(contentChanged()), this, SLOT(refresh()), Qt::UniqueConnection);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: InterfaceEditor::onComTransferTypeChanged()\r\n//-----------------------------------------------------------------------------\r\nvoid InterfaceEditor::onComTransferTypeChanged(QString const& newTransferType)\r\n{\r\n    disconnect(interface_, SIGNAL(contentChanged()), this, SLOT(refresh()));\r\n\r\n    QSharedPointer<QUndoCommand> cmd(new EndpointTransferTypeChangeCommand(interface_, newTransferType));\r\n    editProvider_->addCommand(cmd);\r\n    cmd->redo();\r\n\r\n    connect(interface_, SIGNAL(contentChanged()), this, SLOT(refresh()), Qt::UniqueConnection);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: InterfaceEditor::onComPropertyValuesChanged()\r\n//-----------------------------------------------------------------------------\r\nvoid InterfaceEditor::onComPropertyValuesChanged()\r\n{\r\n    disconnect(interface_, SIGNAL(contentChanged()), this, SLOT(refresh()));\r\n\r\n    QSharedPointer<QUndoCommand> cmd(new EndpointPropertyValuesChangeCommand(interface_,\r\n        propertyValueEditor_.getData()));\r\n    editProvider_->addCommand(cmd);\r\n    cmd->redo();\r\n\r\n    connect(interface_, SIGNAL(contentChanged()), this, SLOT(refresh()), Qt::UniqueConnection);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: InterfaceEditor::setBusInterface()\r\n//-----------------------------------------------------------------------------\r\nvoid InterfaceEditor::setBusInterface()\r\n{\r\n    Q_ASSERT(interface_->getBusInterface());\r\n    \r\n    busType_.setVLNV(interface_->getBusInterface()->getBusType());\r\n\r\n    setNameAndDescription(&busNameEditor_, &busDescriptionEditor_);\r\n\r\n    QString activeView = activeTopView_;\r\n    if (interface_->encompassingComp() && containingConfiguration_)\r\n    {\r\n        activeView = containingConfiguration_->getActiveView(interface_->encompassingComp()->name());\r\n    }\r\n\r\n    VLNV absVLNV;\r\n    if (interface_->getBusInterface() && interface_->getBusInterface()->getAbstractionContainingView(activeView))\r\n    {\r\n        QSharedPointer<AbstractionType> abstraction =\r\n            interface_->getBusInterface()->getAbstractionContainingView(activeView);\r\n        absVLNV = *abstraction->getAbstractionRef().data();\r\n    }\r\n\r\n    absType_.setVLNV(absVLNV);\r\n\r\n    // Set selection for mode editor, signal must be disconnected when mode is set to avoid loops.\r\n    disconnect(&modeSelector_, SIGNAL(currentTextChanged(QString const&)),\r\n        this, SLOT(onInterfaceModeChanged(QString const&)));\r\n\r\n    int index = modeSelector_.findText(General::interfaceMode2Str(interface_->getBusInterface()->getInterfaceMode()));\r\n    modeSelector_.setCurrentIndex(index);\r\n\r\n    connect(&modeSelector_, SIGNAL(currentTextChanged(QString const&)),\r\n        this, SLOT(onInterfaceModeChanged(QString const&)), Qt::UniqueConnection);\r\n\r\n    portMapsModel_->setInterfaceData(interface_, activeView, getActiveInterfaces());\r\n\r\n    setCurrentIndex(BUS);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: InterfaceEditor::setNameAndDescription()\r\n//-----------------------------------------------------------------------------\r\nvoid InterfaceEditor::setNameAndDescription(QLineEdit* nameEditor, QPlainTextEdit* descriptionEditor)\r\n{\r\n    // Set text for the name editor, signal must be disconnected when name is set to avoid loops.\r\n    disconnect(nameEditor, SIGNAL(textEdited(QString const&)), this, SLOT(onInterfaceNameChanged(QString const&)));\r\n    nameEditor->setText(interface_->name());\r\n    connect(nameEditor, SIGNAL(textEdited(QString const&)), this, SLOT(onInterfaceNameChanged(QString const&)),\r\n        Qt::UniqueConnection);\r\n\r\n    disconnect(descriptionEditor, SIGNAL(textChanged()), this, SLOT(onDescriptionChanged()));\r\n    descriptionEditor->setPlainText(interface_->description());\r\n    connect(descriptionEditor, SIGNAL(textChanged()), this, SLOT(onDescriptionChanged()), Qt::UniqueConnection);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: interfaceeditor::getActiveInterfaces()\r\n//-----------------------------------------------------------------------------\r\nQList<QSharedPointer<ActiveInterface> > InterfaceEditor::getActiveInterfaces() const\r\n{\r\n    if (interface_->encompassingComp() == 0)\r\n    {\r\n        return QList<QSharedPointer<ActiveInterface> >();\r\n    }\r\n\r\n    QList<QSharedPointer<ActiveInterface> > endPointInterfaces;\r\n\r\n    for (QSharedPointer<Interconnection> connection : *containingDesign_->getInterconnections())\r\n    {\r\n        QSharedPointer<ActiveInterface> startInterface = connection->getStartInterface();\r\n\r\n        if (activeInterfaceReferencesBusInterface(startInterface))\r\n        {\r\n            endPointInterfaces.append(startInterface);\r\n        }\r\n\r\n        for (QSharedPointer<ActiveInterface> currentInterface : *connection->getActiveInterfaces())\r\n        {\r\n            if (activeInterfaceReferencesBusInterface(currentInterface))\r\n            {\r\n                endPointInterfaces.append(currentInterface);\r\n            }\r\n        }\r\n    }\r\n\r\n    return endPointInterfaces;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: interfaceeditor::activeInterfaceReferencesBusInterface()\r\n//-----------------------------------------------------------------------------\r\nbool InterfaceEditor::activeInterfaceReferencesBusInterface(QSharedPointer<ActiveInterface> currentInterface) const\r\n{\r\n    return currentInterface->getComponentReference().compare(interface_->encompassingComp()->name()) == 0 &&\r\n        currentInterface->getBusReference().compare(interface_->name()) == 0;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: InterfaceEditor::getDesignInterfaces()\r\n//-----------------------------------------------------------------------------\r\nQList<QSharedPointer<HierInterface> > InterfaceEditor::getDesignInterfaces() const\r\n{\r\n    QList<QSharedPointer<HierInterface> > interfaces;\r\n\r\n    if (interface_->isHierarchical())\r\n    {\r\n        for (QSharedPointer<Interconnection> connection : *containingDesign_->getInterconnections())\r\n        {\r\n            QSharedPointer<ActiveInterface> startInterface = connection->getStartInterface();\r\n\r\n            for (QSharedPointer<HierInterface> currentHierInterface : *connection->getHierInterfaces())\r\n            {\r\n                if (currentHierInterface->getBusReference().compare(interface_->name()) == 0)\r\n                {\r\n                    interfaces.append(currentHierInterface);\r\n                }\r\n            }\r\n        }\r\n    }\r\n    else\r\n    {\r\n        for (QSharedPointer<ActiveInterface> activeInteface : getActiveInterfaces())\r\n        {\r\n            interfaces.append(activeInteface);\r\n        }\r\n    }\r\n\r\n    return interfaces;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: InterfaceEditor::setComInterface()\r\n//-----------------------------------------------------------------------------\r\nvoid InterfaceEditor::setComInterface()\r\n{\r\n    Q_ASSERT(interface_->getComInterface());\r\n\r\n    VLNV comType = interface_->getComInterface()->getComType();\r\n\r\n    comType_.setVLNV(comType);\r\n\r\n    // set text for the name editor, signal must be disconnected when name is set to avoid loops \r\n    setNameAndDescription(&comNameEditor_, &comDescriptionEditor_);\r\n\r\n    // Fill in the possible values of the data type.\r\n    disconnect(&transferTypeCombo_, SIGNAL(currentTextChanged(QString const&)),\r\n        this, SLOT(onComTransferTypeChanged(QString const&)));\r\n\r\n    transferTypeCombo_.clear();\r\n    transferTypeCombo_.addItem(\"\");\r\n\r\n    QSharedPointer<ComDefinition const> comDefinition;\r\n    if (comType.isValid())\r\n    {\r\n        comDefinition = library_->getModelReadOnly(comType).dynamicCast<ComDefinition const>();\r\n    }\r\n\r\n    if (comDefinition != 0)\r\n    {\r\n        transferTypeCombo_.addItems(*comDefinition->getTransferTypes());\r\n        transferTypeCombo_.setCurrentIndex(transferTypeCombo_.findText(interface_->getComInterface()->getTransferType()));\r\n    }\r\n\r\n    connect(&transferTypeCombo_, SIGNAL(currentTextChanged(QString const&)),\r\n        this, SLOT(onComTransferTypeChanged(QString const&)), Qt::UniqueConnection);\r\n\r\n    // Set selection for COM direction.\r\n    disconnect(&comDirectionCombo_, SIGNAL(currentTextChanged(QString const&)),\r\n        this, SLOT(onComDirectionChanged(QString const&)));\r\n\r\n    comDirectionCombo_.setCurrentIndex(comDirectionCombo_.findText(DirectionTypes::direction2Str(\r\n        interface_->getComInterface()->getDirection())));\r\n\r\n    connect(&comDirectionCombo_, SIGNAL(currentTextChanged(QString const&)),\r\n        this, SLOT(onComDirectionChanged(QString const&)), Qt::UniqueConnection);\r\n\r\n    // Set property values and try to read the allowed properties from the COM definition if valid.\r\n    disconnect(&propertyValueEditor_, SIGNAL(contentChanged()), this, SLOT(onComPropertyValuesChanged()));\r\n\r\n    propertyValueEditor_.setData(interface_->getComInterface()->getPropertyValues());\r\n\r\n    if (comDefinition != 0)\r\n    {\r\n        propertyValueEditor_.setAllowedProperties(comDefinition->getProperties());\r\n    }\r\n\r\n    connect(&propertyValueEditor_, SIGNAL(contentChanged()),\r\n        this, SLOT(onComPropertyValuesChanged()), Qt::UniqueConnection);\r\n\r\n    setCurrentIndex(COM);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: InterfaceEditor::setApiInterface()\r\n//-----------------------------------------------------------------------------\r\nvoid InterfaceEditor::setApiInterface()\r\n{\r\n    Q_ASSERT(interface_->getApiInterface());\r\n\r\n    apiType_.setVLNV(interface_->getApiInterface()->getApiType());\r\n\r\n    setNameAndDescription(&apiNameEditor_, &apiDescriptionEditor_);\r\n\r\n    disconnect(&dependencyDirCombo_, SIGNAL(currentTextChanged(QString const&)),\r\n        this, SLOT(onDependencyDirectionChanged(QString const&)));\r\n\r\n    dependencyDirCombo_.setCurrentIndex(dependencyDirCombo_.findText(\r\n        dependencyDirection2Str(interface_->getApiInterface()->getDependencyDirection())));\r\n\r\n    connect(&dependencyDirCombo_, SIGNAL(currentTextChanged(QString const&)),\r\n        this, SLOT(onDependencyDirectionChanged(QString const&)), Qt::UniqueConnection);\r\n\r\n    setCurrentIndex(API);    \r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: InterfaceEditor::setupBusEditor()\r\n//-----------------------------------------------------------------------------\r\nvoid InterfaceEditor::setupBusEditor()\r\n{\r\n    busNameEditor_.setValidator(new NameValidator(&busNameEditor_));\r\n\r\n    busType_.setTitle(tr(\"Bus type VLNV\"));\r\n    busType_.setFlat(true);\r\n\r\n    absType_.setTitle(tr(\"Abstraction type VLNV\"));\r\n    absType_.setFlat(true);\r\n\r\n    portMapsView_.setSortingEnabled(true);\r\n    portMapsView_.setSelectionMode(QAbstractItemView::SingleSelection);\r\n    portMapsView_.verticalHeader()->hide();\r\n\r\n    portMapsView_.resizeColumnsToContents();\r\n\r\n    portMapsView_.setContextMenuPolicy(Qt::NoContextMenu);\r\n    portMapsView_.setAlternatingRowColors(false);\r\n    portMapsView_.horizontalHeader()->setStretchLastSection(true);\r\n\r\n    portMapsView_.setItemDelegate(new InterfacePortMapDelegate(this));\r\n\r\n    QSortFilterProxyModel* sortProxy = new QSortFilterProxyModel(this);\r\n    sortProxy->setSourceModel(portMapsModel_);\r\n    portMapsView_.setModel(sortProxy);\r\n\r\n    connect(portMapsModel_, SIGNAL(contentChanged()), this, SIGNAL(contentChanged()), Qt::UniqueConnection);\r\n\r\n    QGroupBox* nameAndModeGroup = new QGroupBox(tr(\"Bus interface name\"), this);\r\n    nameAndModeGroup->setFlat(true);\r\n\r\n    QFormLayout* nameLayout = new QFormLayout(nameAndModeGroup);\r\n    nameLayout->addRow(tr(\"Name:\"), &busNameEditor_);\r\n    nameLayout->addRow(tr(\"Interface mode:\"), &modeSelector_);\r\n    nameLayout->addRow(tr(\"Description:\"), &busDescriptionEditor_);\r\n\r\n    QGroupBox* portMapGroup = new QGroupBox(tr(\"Port maps\"), this);\r\n    portMapGroup->setFlat(true);\r\n\r\n    QVBoxLayout* portMapLayout = new QVBoxLayout(portMapGroup);\r\n    portMapLayout->addWidget(&portMapsView_);\r\n\r\n    QWidget* busTypeEditor(new QWidget(this));\r\n    QVBoxLayout* busLayout(new QVBoxLayout(busTypeEditor));\r\n    busLayout->addWidget(&busType_);\r\n    busLayout->addWidget(&absType_);\r\n    busLayout->addWidget(nameAndModeGroup);\r\n    busLayout->addWidget(portMapGroup, 1, Qt::AlignTop);\r\n\r\n    insertWidget(BUS, busTypeEditor);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: InterfaceEditor::setupComEditor()\r\n//-----------------------------------------------------------------------------\r\nvoid InterfaceEditor::setupComEditor()\r\n{\r\n    comType_.setTitle(tr(\"COM type VLNV\"));\r\n    comType_.setFlat(true);\r\n\r\n    comNameEditor_.setValidator(new NameValidator(&comNameEditor_));\r\n\r\n    comDirectionCombo_.addItem(\"in\");\r\n    comDirectionCombo_.addItem(\"out\");\r\n    comDirectionCombo_.addItem(\"inout\");\r\n\r\n    QGroupBox* nameAndTypeGroup = new QGroupBox(tr(\"COM interface name\"), this);\r\n    nameAndTypeGroup->setFlat(true);\r\n\r\n    QFormLayout* nameLayout = new QFormLayout(nameAndTypeGroup);\r\n    nameLayout->addRow(tr(\"Name:\"), &comNameEditor_);\r\n    nameLayout->addRow(tr(\"Transfer type:\"), &transferTypeCombo_);\r\n    nameLayout->addRow(tr(\"Direction:\"), &comDirectionCombo_);\r\n    nameLayout->addRow(tr(\"Description:\"), &comDescriptionEditor_);\r\n\r\n    QWidget* comTypeEditor = new QWidget(this);\r\n    QVBoxLayout* comLayout = new QVBoxLayout(comTypeEditor);\r\n    comLayout->addWidget(&comType_);\r\n    comLayout->addWidget(nameAndTypeGroup); \r\n    comLayout->addWidget(&propertyValueEditor_, 1);\r\n\r\n    insertWidget(COM, comTypeEditor);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: InterfaceEditor::setupApiEditor()\r\n//-----------------------------------------------------------------------------\r\nvoid InterfaceEditor::setupApiEditor()\r\n{\r\n    apiType_.setTitle(tr(\"API type VLNV\"));\r\n    apiType_.setFlat(true);\r\n\r\n    apiNameEditor_.setValidator(new NameValidator(&apiNameEditor_));\r\n\r\n    dependencyDirCombo_.addItem(\"requester\");\r\n    dependencyDirCombo_.addItem(\"provider\");\r\n\r\n    QGroupBox* nameAndDirectionGroup = new QGroupBox(tr(\"API interface name\"), this);\r\n    nameAndDirectionGroup->setFlat(true);\r\n\r\n    QFormLayout* nameLayout = new QFormLayout(nameAndDirectionGroup);\r\n    nameLayout->addRow(tr(\"Name:\"), &apiNameEditor_);\r\n    nameLayout->addRow(tr(\"Dependency direction:\"), &dependencyDirCombo_);\r\n    nameLayout->addRow(tr(\"Description:\"), &apiDescriptionEditor_);\r\n\r\n    QWidget* apiTypeEditor = new QWidget(this);\r\n    QVBoxLayout* apiLayout = new QVBoxLayout(apiTypeEditor);\r\n    apiLayout->addWidget(&apiType_);\r\n    apiLayout->addWidget(nameAndDirectionGroup);\r\n\r\n    insertWidget(API, apiTypeEditor);\r\n}\r\n"
  },
  {
    "path": "editors/common/InterfaceEditor/interfaceeditor.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: interfaceeditor.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 10.10.2011\r\n//\r\n// Description:\r\n// Editor to display/edit the details of a bus/api/com interface.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef INTERFACEEDITOR_H\r\n#define INTERFACEEDITOR_H\r\n\r\n#include <common/widgets/vlnvDisplayer/vlnvdisplayer.h>\r\n\r\n#include <editors/ComponentEditor/software/PropertyValueEditor.h>\r\n\r\n#include <KactusAPI/include/LibraryInterface.h>\r\n#include <KactusAPI/include/ListParameterFinder.h>\r\n\r\n#include <QWidget>\r\n#include <QLineEdit>\r\n#include <QComboBox>\r\n#include <QLabel>\r\n#include <QPlainTextEdit>\r\n#include <QStackedWidget>\r\n\r\nclass ActiveInterface;\r\nclass ComDefinition;\r\nclass Design;\r\nclass HierInterface;\r\nclass ConnectionEndpoint;\r\nclass EditableTableView;\r\nclass IEditProvider;\r\nclass InterfacePortMapModel;\r\nclass DesignConfiguration;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Editor to display/edit the details of a bus/api/com interface.\r\n//-----------------------------------------------------------------------------\r\nclass InterfaceEditor : public QStackedWidget\r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\r\n\t/*!\r\n     *  The constructor.\r\n\t *\r\n\t *    @param [in] parent      The owner of this widget.\r\n     *    @param [in] handler     The library handler.\r\n\t */\r\n\tInterfaceEditor(QWidget *parent, LibraryInterface* handler);\r\n\t\r\n\t//! The destructor.\r\n\tvirtual ~InterfaceEditor() = default;\r\n\r\n\t/*!\r\n     *  Set the interface for the editor.\r\n\t *\r\n\t *    @param [in] interface           The interface to edit.\r\n     *    @param [in] containingDesign    The design containing the end point.\r\n     *    @param [in] configuration       Design configuration of the design.\r\n     *    @param [in] activeTopView       The currently active top component view.\r\n\t */\r\n\tvoid setInterface(ConnectionEndpoint* interface, QSharedPointer<Design> containingDesign,\r\n        QSharedPointer<DesignConfiguration> configuration, QString const& activeTopView,\r\n        QSharedPointer<IEditProvider> editProvider, bool locked);\r\n\r\nsignals:\r\n\r\n    //! Informs of a content change in the editor.\r\n    void contentChanged();\r\n\r\npublic slots:\r\n\r\n\t//! Refresh the editor contents without changing the interface.\r\n\tvoid refresh();\r\n\r\n\t//! Clear the editor so no interface details are shown\r\n    void clear();\r\n\r\nprivate slots:\r\n\r\n\t/*!\r\n     *  Handler for change in interface name.\r\n\t *\r\n\t *    @param [in] newName     The new name of the interface.\r\n\t */\r\n\tvoid onInterfaceNameChanged(QString const& newName);\r\n\r\n\t/*!\r\n     *  Handler for change in interface mode.\r\n\t *\r\n\t *    @param [in] newMode     The new mode of the interface.\r\n\t */\r\n\tvoid onInterfaceModeChanged(QString const& newMode);\r\n\r\n\t/*!\r\n     *  Handler for changes in the description editor.\r\n\t */\r\n\tvoid onDescriptionChanged();\r\n\r\n    //! Handler for changes in dependency direction.\r\n    void onDependencyDirectionChanged(QString const& newDir);\r\n\r\n    //! Handler for changes in COM direction.\r\n    void onComDirectionChanged(QString const& newDir);\r\n\r\n    //! Handler for changes in COM transfer type.\r\n    void onComTransferTypeChanged(QString const& newTransferType);\r\n\r\n    //! Handler for changes in COM property values.\r\n    void onComPropertyValuesChanged();\r\n\r\nprivate:\r\n\t//! No copying.\r\n\tInterfaceEditor(const InterfaceEditor& other);\r\n\r\n\t//! No assignment.\r\n\tInterfaceEditor& operator=(const InterfaceEditor& other);\r\n\r\n    // Sets the editor for editing a bus interface.\r\n    void setBusInterface();\r\n        \r\n    /*!\r\n     *  Sets the name and description of the interface to the given editors.\r\n     *\r\n     *    @param [in] nameEditor          The name editor to use.\r\n     *    @param [in] descriptionEditor   The description editor to use.\r\n     */\r\n    void setNameAndDescription(QLineEdit* nameEditor, QPlainTextEdit* descriptionEditor);\r\n\r\n    /*!\r\n     *  Get a list of active interfaces referencing the selected interface.\r\n     *\r\n     *    @return A list of active interfaces referencing the selected interface.\r\n     */\r\n    QList<QSharedPointer<ActiveInterface> > getActiveInterfaces() const;\r\n\r\n    /*!\r\n     *  Check if the selected active interface contains a reference to the selected end point.\r\n     *\r\n     *    @param [in] currentInterface    The selected active interface.\r\n     *    @param [in] endPoint            The selected end point.\r\n     *\r\n     *    @return True, if the active interface contains a reference to the end point, otherwise false.\r\n     */\r\n    bool activeInterfaceReferencesBusInterface(QSharedPointer<ActiveInterface> currentInterface) const;\r\n\r\n    QList<QSharedPointer<HierInterface> > getDesignInterfaces() const;\r\n\r\n    // Sets the editor for editing a COM interface.\r\n    void setComInterface();\r\n\r\n    // Sets the editor for editing an API interface.\r\n    void setApiInterface();\r\n\r\n    // Initializes the editor for editing a bus interface.\r\n    void setupBusEditor();\r\n\r\n    // Initializes the editor for editing a COM interface.\r\n    void setupComEditor();\r\n\r\n    // Initializes the editor for editing an API interface.\r\n    void setupApiEditor();\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! Parameter finder for design parameters.\r\n    QSharedPointer<ListParameterFinder> designParameterFinder_ = QSharedPointer<ListParameterFinder>(new ListParameterFinder());\r\n\r\n    //! The currently active top component view.\r\n    QString activeTopView_;\r\n\r\n    //! The instance that manages the library.\r\n    LibraryInterface* library_;\r\n\r\n\t//! Widget to display the bus type.\r\n\tVLNVDisplayer busType_;\r\n\r\n\t//! Widget to display the abstraction type.\r\n\tVLNVDisplayer absType_;\r\n\r\n    //! The editor for the bus interface name.\r\n    QLineEdit busNameEditor_;\r\n\r\n    //! The editor for the interface mode.\r\n    QComboBox modeSelector_;\r\n\r\n    //! The view for the port mappings.\r\n    EditableTableView portMapsView_;\r\n\r\n    //! The model for the port mappings.\r\n    InterfacePortMapModel* portMapsModel_;\r\n\r\n    //! Editor for the description of the interface.\r\n    QPlainTextEdit busDescriptionEditor_;\r\n\r\n    //! Widget to display the COM type.\r\n    VLNVDisplayer comType_;\r\n\r\n    //! The editor for the COM interface name.\r\n    QLineEdit comNameEditor_;\r\n    \r\n    //! Data type editor for COM interface.\r\n    QComboBox transferTypeCombo_;\r\n\r\n    //! The editor for the COM direction.\r\n    QComboBox comDirectionCombo_;\r\n\r\n    //! Editor for the description of the COM interface.\r\n    QPlainTextEdit comDescriptionEditor_;\r\n\r\n    //! Widget to display the API type.\r\n    VLNVDisplayer apiType_;\r\n\r\n    //! The editor for the api interface name.\r\n    QLineEdit apiNameEditor_;\r\n\r\n    //! The editor for dependency direction.\r\n    QComboBox dependencyDirCombo_;\r\n\r\n    //! Editor for the description of the interface.\r\n    QPlainTextEdit apiDescriptionEditor_;\r\n\r\n    //! Property value editor for SW properties.\r\n    PropertyValueEditor propertyValueEditor_;\r\n\r\n    //! The interface being edited.\r\n    ConnectionEndpoint* interface_;\r\n\r\n    //! The design containing the selected interface.\r\n    QSharedPointer<Design> containingDesign_;\r\n\r\n    //! The active design configuration.\r\n    QSharedPointer<DesignConfiguration> containingConfiguration_;\r\n\r\n    //! Undo/redo manager to use.\r\n    QSharedPointer<IEditProvider> editProvider_;\r\n\r\n    //! Set when the widget should be locked.\r\n    bool locked_;\r\n};\r\n\r\n#endif // INTERFACEEDITOR_H\r\n"
  },
  {
    "path": "editors/common/NamelabelWidth.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: NamelabelWidth.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Mikko Teuho\r\n// Date: 5.11.2014\r\n//\r\n// Description:\r\n// Label width calculator for ConnectionEndPoints derived classes.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"NamelabelWidth.h\"\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: NamelabelWidth::NamelabelWidth\r\n//-----------------------------------------------------------------------------\r\nNamelabelWidth::NamelabelWidth()\r\n{\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: NamelabelWidth::~NamelabelWidth\r\n//-----------------------------------------------------------------------------\r\nNamelabelWidth::~NamelabelWidth()\r\n{\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: NamelabelWidth::getTextLength\r\n//-----------------------------------------------------------------------------\r\nqreal NamelabelWidth::getTextLength( QString text, QFont font )\r\n{\r\n\tQFontMetrics fontMetrics(font);\r\n\r\n\treturn fontMetrics.horizontalAdvance( text );\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: NamelabelWidth::setNameLabel\r\n//-----------------------------------------------------------------------------\r\nQString NamelabelWidth::setNameLabel( QString labelName, QFont font, qreal width )\r\n{\r\n\tQFontMetrics fontMetrics(font);\r\n\tqreal shortWidth = fontMetrics.horizontalAdvance(labelName);\r\n\tQString shortLabel = labelName;\r\n\r\n\tif ( shortWidth + MIDDLE + PADDING > width )\r\n\t{\r\n\t    for (int i = 1; i < labelName.size(); ++i)\r\n    \t{\r\n\t    \tshortLabel = labelName.left(labelName.size() - i);\r\n\t\t    shortWidth = fontMetrics.horizontalAdvance(shortLabel);\r\n\r\n    \t\tif ( shortWidth + MIDDLE + PADDING < width  )\r\n\t    \t{\r\n\t\t    \t// Replace the last letters with ...\r\n\t\t\t    return shortLabel.left(shortLabel.size() - 2) + \"...\";\r\n    \t\t}\r\n\t    }\r\n\t}\r\n\r\n\treturn shortLabel;\r\n}"
  },
  {
    "path": "editors/common/NamelabelWidth.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: NamelabelWidth.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Mikko Teuho\r\n// Date: 5.11.2014\r\n//\r\n// Description:\r\n// Label width calculator for ConnectionEndPoints derived classes.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef NAMELABELWIDTH_H\r\n#define NAMELABELWIDTH_H\r\n\r\n#include <QFontMetrics>\r\n#include <QFont>\r\n\r\n//-----------------------------------------------------------------------------\r\n//! NamelabelWidth class.\r\n//-----------------------------------------------------------------------------\r\nclass NamelabelWidth\r\n{\r\npublic:\r\n\t/*!\r\n\t *  Constructor.\r\n\t */\r\n\tNamelabelWidth();\r\n\r\n\t/*!\r\n\t *  Destructor.\r\n\t */\r\n\t~NamelabelWidth();\r\n\r\n\t/*!\r\n\t *  Return the length of the given text.\r\n\t *    @param [in] text   The text used.\r\n\t *    @param [in] font   The font used in the text.\r\n\t */\r\n\tstatic qreal getTextLength (QString text, QFont font );\r\n\r\n\t/*!\r\n\t *  Shortens the given label name according to the given width.\r\n\t *\r\n\t *    @param [in] labelName   The text in the label.\r\n\t *    @param [in] font        The font used in the label.\r\n\t *    @param [in] width       The width to which the label will be shortened.\r\n\t */\r\n\tstatic QString setNameLabel (QString labelName, QFont font, qreal width);\r\n\r\nprivate:\r\n\t//! The size of the middle section of the component, with padding of labels taken into account.\r\n\tstatic const int middleColumn = 20+20;\r\n\r\n\tstatic const int MIDDLE = 10;\r\n\tstatic const int PADDING = 10;\r\n};\r\n\r\n#endif // NAMELABELWIDTH_H\r\n"
  },
  {
    "path": "editors/common/PortUtilities.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: PortUtilities.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Mikko Teuho\n// Date: 26.02.2019\n//\n// Description:\n// Utilities for port compatibilities.\n//-----------------------------------------------------------------------------\n\n#include \"PortUtilities.h\"\n\n//-----------------------------------------------------------------------------\n// Function: PortItemMatcher::getConnectableDirections()\n//-----------------------------------------------------------------------------\nQVector<DirectionTypes::Direction> PortUtilities::getConnectableDirections(\n    DirectionTypes::Direction portDirection)\n{\n    //! In -> Out & InOut & phantom\n    //! Out -> In & InOut & phantom\n    //! InOut -> InOut & phantom\n    //! Phantom -> In & Out & InOut & Phantom\n    QVector<DirectionTypes::Direction> connectableDirections;\n    if (portDirection == DirectionTypes::IN)\n    {\n        connectableDirections = { DirectionTypes::OUT, DirectionTypes::INOUT, DirectionTypes::DIRECTION_PHANTOM };\n    }\n    else if (portDirection == DirectionTypes::OUT)\n    {\n        connectableDirections = { DirectionTypes::IN, DirectionTypes::INOUT, DirectionTypes::DIRECTION_PHANTOM };\n    }\n    else if (portDirection == DirectionTypes::INOUT)\n    {\n        connectableDirections =\n        { DirectionTypes::IN, DirectionTypes::OUT, DirectionTypes::INOUT, DirectionTypes::DIRECTION_PHANTOM };\n    }\n    else if (portDirection == DirectionTypes::DIRECTION_PHANTOM)\n    {\n        connectableDirections =\n        { DirectionTypes::IN, DirectionTypes::OUT, DirectionTypes::INOUT, DirectionTypes::DIRECTION_PHANTOM };\n    }\n\n    return connectableDirections;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortUtilities::getConnectableHierarchicalDirections()\n//-----------------------------------------------------------------------------\nQVector<DirectionTypes::Direction> PortUtilities::getConnectableHierarchicalDirections(\n    DirectionTypes::Direction portDirection)\n{\n    QVector<DirectionTypes::Direction> connectableDirections;\n\n    connectableDirections.append(portDirection);\n\n    return connectableDirections;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PortUtilities::getDirectionIconPath()\n//-----------------------------------------------------------------------------\nQString PortUtilities::getDirectionIconPath(DirectionTypes::Direction portDirection)\n{\n    QString iconPath = \":icons/common/graphics/cross.png\";\n    if (portDirection == DirectionTypes::IN)\n    {\n        iconPath = \":icons/common/graphics/input.png\";\n    }\n    else if (portDirection == DirectionTypes::OUT)\n    {\n        iconPath = \":icons/common/graphics/output.png\";\n    }\n    else if (portDirection == DirectionTypes::INOUT)\n    {\n        iconPath = \":icons/common/graphics/inout.png\";\n    }\n    else if (portDirection == DirectionTypes::DIRECTION_PHANTOM)\n    {\n        iconPath = \":icons/common/graphics/phantom.png\";\n    }\n\n    return iconPath;\n}\n"
  },
  {
    "path": "editors/common/PortUtilities.h",
    "content": "//-----------------------------------------------------------------------------\n// File: PortUtilities.h\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Mikko Teuho\n// Date: 26.02.2019\n//\n// Description:\n// Utilities for port compatibilities.\n//-----------------------------------------------------------------------------\n\n#ifndef PORTUTILITIES_H\n#define PORTUTILITIES_H\n\n#include <IPXACTmodels/common/DirectionTypes.h>\n\n#include <QVector>\n\n//-----------------------------------------------------------------------------\n//! Utilities for port compatibilities.\n//-----------------------------------------------------------------------------\nnamespace PortUtilities\n{\n    /*!\n     *  Get the list of port directions connectible to the selected port direction.\n     *\n     *    @param [in] portDirection   The selected port direction.\n     *\n     *    @return List of connectible port directions.\n     */\n    QVector<DirectionTypes::Direction> getConnectableDirections(DirectionTypes::Direction portDirection);\n\n    /*!\n     *  Get the list of hierarchical port directions connectible to the selected port direction.\n     *\n     *    @param [in] portDirection   The selected port direction.\n     *\n     *    @return List of hierarchical connectible port directions.\n     */\n    QVector<DirectionTypes::Direction> getConnectableHierarchicalDirections(\n        DirectionTypes::Direction portDirection);\n\n    /*!\n     *  Get the path for the icon matching the selected port direction.\n     *\n     *    @param [in] portDirection   The selected port direction.\n     *\n     *    @return Path containing the icon for the selected port direction.\n     */\n    QString getDirectionIconPath(DirectionTypes::Direction portDirection);\n}\n\n//-----------------------------------------------------------------------------\n\n#endif // PORTUTILITIES_H\n"
  },
  {
    "path": "editors/common/StickyNote/ColorFillTextItem.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: ColorFillTextItem.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Esko Pekkarinen\n// Date: 5.2.2014\n//\n// Description:\n// Graphic item for text editing with color filled background.\n//-----------------------------------------------------------------------------\n\n#include \"ColorFillTextItem.h\"\n\n#include <QPainter>\n#include <QStyleOptionGraphicsItem>\n\n#include <QObject>\n#include <QTextDocument>\n\n//-----------------------------------------------------------------------------\n// Function: ColorFillTextItem::ColorFillTextItem()\n//-----------------------------------------------------------------------------\nColorFillTextItem::ColorFillTextItem(QGraphicsItem* parent):\nQGraphicsTextItem(parent),\nfillColor_()\n{ \n    setFlag(ItemIsFocusable);\n    setTextInteractionFlags(Qt::TextEditorInteraction);  \n}\n\n//-----------------------------------------------------------------------------\n// Function: ColorFillTextItem::~ColorFillTextItem()\n//-----------------------------------------------------------------------------\nColorFillTextItem::~ColorFillTextItem()\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: ColorFillTextItem::setFill()\n//-----------------------------------------------------------------------------\nvoid ColorFillTextItem::setFill(QColor const& color)\n{\n    fillColor_ = color;\n}\n\n//-----------------------------------------------------------------------------\n// Function: ColorFillTextItem::paint()\n//-----------------------------------------------------------------------------\nvoid ColorFillTextItem::paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget)\n{\n    painter->fillRect(boundingRect(), QBrush(fillColor_)); \n    \n    QGraphicsTextItem::paint(painter, option, widget);\n}\n\n//-----------------------------------------------------------------------------\n// Function: ColorFillTextItem::focusOutEvent()\n//-----------------------------------------------------------------------------\nvoid ColorFillTextItem::focusOutEvent(QFocusEvent *event)\n{\n    if (document()->isModified())\n    {\n        emit contentChanged();\n        document()->setModified(false);\n    }\n\n    QGraphicsTextItem::focusOutEvent(event);\n}\n"
  },
  {
    "path": "editors/common/StickyNote/ColorFillTextItem.h",
    "content": "//-----------------------------------------------------------------------------\n// File: ColorFillTextItem.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Esko Pekkarinen\n// Date: 5.2.2014\n//\n// Description:\n// Graphic item for text editing with color filled background.\n//-----------------------------------------------------------------------------\n\n#ifndef COLORFILLTEXTITEM_H\n#define COLORFILLTEXTITEM_H\n\n#include <QGraphicsRectItem>\n#include <QGraphicsTextItem>\n#include <QFocusEvent>\n\n//-----------------------------------------------------------------------------\n//! ColorFillTextItem class.\n//-----------------------------------------------------------------------------\nclass ColorFillTextItem : public QGraphicsTextItem\n{\n    Q_OBJECT\n\npublic:\n\n    /*!\n     *  The constructor.\n     *\n     *    @param [in] parent   The parent item.\n     */\n    explicit ColorFillTextItem(QGraphicsItem* parent = 0);\n\n    //! The destructor.\n    virtual ~ColorFillTextItem();\n\n    /*!\n     *  Sets the background fill color.\n     *\n     *    @param [in] color   The background color to set.\n     *\n     *    @return \n     */\n    void setFill(QColor const& color);\n\n    //! Draws the item.\n    virtual void paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget );\n\n\nprotected:\n\n    //! Called when item loses focus.\n    virtual void focusOutEvent(QFocusEvent *event);\n\nsignals:\n\n    //! Emitted when the text changes.\n    void contentChanged();\n\nprivate:\n\n    //! Disable copying.\n    ColorFillTextItem(ColorFillTextItem const& rhs);\n\n    //! Disable assignment.\n    ColorFillTextItem& operator=(ColorFillTextItem const& rhs);\n\n    //! The background fill color.\n    QColor fillColor_;\n};\n\n#endif // COLORFILLTEXTITEM_H"
  },
  {
    "path": "editors/common/StickyNote/StickyNote.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: StickyNote.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Esko Pekkarinen\n// Date: 5.2.2014\n//\n// Description:\n// Sticky note for designs.\n//-----------------------------------------------------------------------------\n\n#include \"StickyNote.h\"\n\n#include \"ColorFillTextItem.h\"\n#include \"StickyNoteMoveCommand.h\"\n#include \"StickyNoteEditCommand.h\"\n\n#include <common/GenericEditProvider.h>\n#include <common/KactusColors.h>\n\n#include <editors/common/diagramgrid.h>\n#include <editors/common/Association/Association.h>\n\n#include <IPXACTmodels/utilities/XmlUtils.h>\n#include <IPXACTmodels/common/VendorExtension.h>\n#include <IPXACTmodels/kactusExtensions/Kactus2Group.h>\n#include <IPXACTmodels/kactusExtensions/Kactus2Position.h>\n#include <IPXACTmodels/kactusExtensions/Kactus2Value.h>\n\n#include <QGraphicsPixmapItem>\n#include <QObject>\n#include <QPainter>\n#include <QPixmap>\n#include <QPolygonF>\n#include <QStyleOptionGraphicsItem>\n#include <QSharedPointer>\n#include <QDateTime>\n\n\n//-----------------------------------------------------------------------------\n// Function: StickyNote::StickyNote()\n//-----------------------------------------------------------------------------\nStickyNote::StickyNote(QGraphicsItem* parent):\n    QGraphicsItemGroup(parent),\n    Associable(),\n    oldPos_(),\n    extension_(new Kactus2Group(QStringLiteral(\"kactus2:note\"))),\n    positionExtension_(new Kactus2Position(QPointF())),\n    contentExtension_(new Kactus2Value(QStringLiteral(\"kactus2:content\"), QString())),\n    associationExtensions_(new Kactus2Group(QStringLiteral(\"kactus2:associations\"))),\n    timestampExtension_(new Kactus2Value(QStringLiteral(\"kactus2:timestamp\"), QString())),\n    textArea_(0),\n    timeLabel_(0),\n    associationButton_(0)\n{\n    extension_->addToGroup(positionExtension_);\n    extension_->addToGroup(contentExtension_);\n    extension_->addToGroup(associationExtensions_);    \n    extension_->addToGroup(timestampExtension_);\n\n    setItemOptions();\n    createGluedEdge();\n    createWritableArea();\n    createAssociationButton();    \n\n    setTimestamp(getFormattedTimestamp());    \n\n    connect(textArea_, SIGNAL(contentChanged()), this, SLOT(onTextEdited()), Qt::UniqueConnection);\n}\n\n//-----------------------------------------------------------------------------\n// Function: StickyNote::beginEditing()\n//-----------------------------------------------------------------------------\nvoid StickyNote::beginEditing()\n{\n    textArea_->setFocus();\n}\n\n//-----------------------------------------------------------------------------\n// Function: StickyNote::mousePressEvent()\n//-----------------------------------------------------------------------------\nvoid StickyNote::mousePressEvent(QGraphicsSceneMouseEvent* event)\n{\n    oldPos_ = pos();\n    QGraphicsItemGroup::mousePressEvent(event);\n}\n\n//-----------------------------------------------------------------------------\n// Function: DesignLabel::mouseReleaseEvent()\n//-----------------------------------------------------------------------------\nvoid StickyNote::mouseReleaseEvent(QGraphicsSceneMouseEvent * event)\n{\n    QGraphicsItemGroup::mouseReleaseEvent(event);\n\n    if (positionChanged())\n    {\n        StickyNoteMoveCommand* moveCommand(new StickyNoteMoveCommand(this, oldPos_));\n        emit modified(moveCommand);\n    }\n    else if (hitsAssociationButton(event->pos()))\n    {\n        emit beginAssociation(this);\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: StickyNote::positionChanged()\n//-----------------------------------------------------------------------------\nbool StickyNote::positionChanged()\n{\n    return pos() != oldPos_;\n}\n\n//-----------------------------------------------------------------------------\n// Function: StickyNote::itemChange()\n//-----------------------------------------------------------------------------\nQVariant StickyNote::itemChange(GraphicsItemChange change, const QVariant& value)\n{\n    if (change == ItemPositionChange)\n    {\n        // Assert that the new position does not overlap the column headers.\n        QPointF newPosition = snapPointToGrid(value.toPointF());\n        newPosition.setY(qMax(newPosition.y(), 31.0));\n\n        positionExtension_->setPosition(newPosition);\n        return newPosition;\n    }\n    if (change == ItemPositionHasChanged)\n    {\n        positionUpdated();\n    }\n\n    return QGraphicsItemGroup::itemChange(change, value);\n}\n\n//-----------------------------------------------------------------------------\n// Function: StickyNote::getVendorExtension()\n//-----------------------------------------------------------------------------\nQSharedPointer<VendorExtension> StickyNote::getVendorExtension() const\n{\n    return extension_;\n}\n\n//-----------------------------------------------------------------------------\n// Function: StickyNote::addAssociation()\n//-----------------------------------------------------------------------------\nvoid StickyNote::addAssociation(Association* association)\n{\n    Associable::addAssociation(association);\n    associationExtensions_->addToGroup(association->getEndpointExtension());\n}\n\n//-----------------------------------------------------------------------------\n// Function: StickyNote::removeAssociation()\n//-----------------------------------------------------------------------------\nvoid StickyNote::removeAssociation(Association* association)\n{\n    Associable::removeAssociation(association);\n    associationExtensions_->removeFromGroup(association->getEndpointExtension());\n}\n\n//-----------------------------------------------------------------------------\n// Function: ComponentItem::connectionPoint()\n//-----------------------------------------------------------------------------\nQPointF StickyNote::connectionPoint(QPointF const&) const\n{\n    return mapToScene(boundingRect().center());\n}\n\n//-----------------------------------------------------------------------------\n// Function: StickyNote::getAssociationExtensions()\n//-----------------------------------------------------------------------------\nQSharedPointer<Kactus2Group> StickyNote::getAssociationExtensions() const\n{\n    return associationExtensions_;\n}\n\n//-----------------------------------------------------------------------------\n// Function: StickyNote::setVendorExtension()\n//-----------------------------------------------------------------------------\nvoid StickyNote::setVendorExtension(QSharedPointer<Kactus2Group> extension)\n{\n    extension_ = extension;\n\n    if (extension->getByType(QStringLiteral(\"kactus2:position\")).isEmpty() == false)\n    {\n        positionExtension_ =\n            extension->getByType(QStringLiteral(\"kactus2:position\")).first().dynamicCast<Kactus2Position>();\n        setPos(positionExtension_->position());\n    }\n    else\n    {\n        extension_->addToGroup(positionExtension_);\n    }\n    \n    if (extension->getByType(QStringLiteral(\"kactus2:content\")).isEmpty() == false)\n    {\n        contentExtension_ =\n            extension->getByType(QStringLiteral(\"kactus2:content\")).first().dynamicCast<Kactus2Value>();\n        setText(contentExtension_->value());\n    }\n    else\n    {\n        extension_->addToGroup(contentExtension_);\n    }\n\n    if (extension->getByType(QStringLiteral(\"kactus2:associations\")).isEmpty() == false)\n    {\n        associationExtensions_ =\n            extension->getByType(QStringLiteral(\"kactus2:associations\")).first().dynamicCast<Kactus2Group>();\n     }\n    else\n    {\n        extension_->addToGroup(associationExtensions_);\n    }\n\n    if (extension->getByType(QStringLiteral(\"kactus2:timestamp\")).isEmpty() == false)\n    {\n        timestampExtension_ =\n            extension->getByType(QStringLiteral(\"kactus2:timestamp\")).first().dynamicCast<Kactus2Value>();\n        setTimestamp(timestampExtension_->value());\n    }\n    else\n    {\n        extension_->addToGroup(timestampExtension_);\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: StickyNote::setText()\n//-----------------------------------------------------------------------------\nvoid StickyNote::setText(QString const& text)\n{\n    contentExtension_->setValue(text);\n    textArea_->setPlainText(text);   \n}\n\n//-----------------------------------------------------------------------------\n// Function: StickyNote::setTimestamp()\n//-----------------------------------------------------------------------------\nvoid StickyNote::setTimestamp(QString const& timestamp)\n{\n    timestampExtension_->setValue(timestamp);\n    timeLabel_->setText(timestamp);\n}\n\n//-----------------------------------------------------------------------------\n// Function: StickyNote::onTextEdited()\n//-----------------------------------------------------------------------------\nvoid StickyNote::onTextEdited()\n{\n    QString timestamp = getFormattedTimestamp();\n    \n    StickyNoteEditCommand* command = new StickyNoteEditCommand(this, \n        textArea_->toPlainText(), contentExtension_->value(), timestamp, timestampExtension_->value());\n    \n    command->redo();\n\n    emit modified(command);    \n}\n\n//-----------------------------------------------------------------------------\n// Function: StickyNote::setItemOptions()\n//-----------------------------------------------------------------------------\nvoid StickyNote::setItemOptions()\n{\n    setFlag(ItemIsMovable);\n    setFlag(ItemIsSelectable);\n    setFlag(ItemIsFocusable);\n    setFlag(ItemSendsGeometryChanges);\n\n    setHandlesChildEvents(false);\n}\n\n//-----------------------------------------------------------------------------\n// Function: StickyNote::createGluedEdge()\n//-----------------------------------------------------------------------------\nvoid StickyNote::createGluedEdge()\n{\n    QColor topColor = KactusColors::STICKY_NOTE_BACKGROUND.darker(103);\n\n    QGraphicsRectItem* glueEdge = new QGraphicsRectItem(0, 0, DEFAULT_WIDTH, TOP_OFFSET);\n    QPen outlinePen(Qt::black, 0, Qt::NoPen);    \n    glueEdge->setPen(outlinePen);\n    glueEdge->setBrush(topColor);\n\n    addToGroup(glueEdge);\n\n    timeLabel_ = new QGraphicsSimpleTextItem();\n    timeLabel_->setBrush(Qt::gray);\n    timeLabel_->setPos(5, TOP_OFFSET/2 - QFontMetrics(timeLabel_->font()).height()/2);\n    addToGroup(timeLabel_);\n}\n\n//-----------------------------------------------------------------------------\n// Function: StickyNote::createWritableArea()\n//-----------------------------------------------------------------------------\nvoid StickyNote::createWritableArea()\n{\n    textArea_ = new ColorFillTextItem();\n    textArea_->setFill(KactusColors::STICKY_NOTE_BACKGROUND);\n    textArea_->setTextWidth(DEFAULT_WIDTH);\n    textArea_->setPos(0, TOP_OFFSET);\n\n    addToGroup(textArea_);\n}\n\n//-----------------------------------------------------------------------------\n// Function: StickyNote::createAssociationButton()\n//-----------------------------------------------------------------------------\nvoid StickyNote::createAssociationButton()\n{\n    QPixmap pixmap(\":/icons/common/graphics/pin--plus.png\");\n    associationButton_ = new QGraphicsPixmapItem(pixmap, this);\n    associationButton_->setToolTip(QObject::tr(\"Click to add a new association to a component.\"));\n    associationButton_->setPos(DEFAULT_WIDTH - associationButton_->boundingRect().width(), 0);\n    associationButton_->setZValue(1.0);\n}\n\n//-----------------------------------------------------------------------------\n// Function: StickyNote::clickedAssociationButton()\n//-----------------------------------------------------------------------------\nbool StickyNote::hitsAssociationButton(QPointF const& clickPosition) const\n{\n    QPolygonF buttonArea = mapFromItem(associationButton_, associationButton_->boundingRect());\n    return buttonArea.containsPoint(clickPosition, Qt::OddEvenFill);\n}\n\n//-----------------------------------------------------------------------------\n// Function: StickyNote::getFormattedTimestamp()\n//-----------------------------------------------------------------------------\nQString StickyNote::getFormattedTimestamp()\n{\n    return QDateTime::currentDateTime().toString(\"dd.MM.yyyy hh:mm\");\n}\n"
  },
  {
    "path": "editors/common/StickyNote/StickyNote.h",
    "content": "//-----------------------------------------------------------------------------\n// File: StickyNote.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Esko Pekkarinen\n// Date: 5.2.2014\n//\n// Description:\n// Sticky note for designs.\n//-----------------------------------------------------------------------------\n\n#ifndef STICKYNOTE_H\n#define STICKYNOTE_H\n\n#include <QGraphicsItemGroup>\n\n#include <common/graphicsItems/GraphicsItemTypes.h>\n\n#include <editors/common/diagramgrid.h>\n#include <editors/common/Association/Associable.h>\n\n#include <QDomNode>\n#include <QGraphicsSceneMouseEvent>\n#include <QUndoCommand>\n\nclass VendorExtension;\nclass Kactus2Group;\nclass Kactus2Position;\nclass Kactus2Value;\nclass ColorFillTextItem;\n\n//-----------------------------------------------------------------------------\n//! DesignLabel class.\n//-----------------------------------------------------------------------------\nclass StickyNote : public QObject, public QGraphicsItemGroup, public Associable\n{\n    Q_OBJECT\n\npublic:\n\n    static const int TOP_OFFSET = 20;\n    static const int DEFAULT_WIDTH = GridSize * 8 * 2;\n\n    enum { Type = GFX_TYPE_DIAGRAM_STICKY_NOTE };\n\n    /*!\n     *  The constructor.\n     *\n     *    @param [in] parent      The parent item.\n     */\n    explicit StickyNote(QGraphicsItem* parent = 0);\n\n    //! The destructor.\n    virtual ~StickyNote() = default;\n\n    //! Disable copying.\n    StickyNote(StickyNote const& rhs) = delete;\n\n    //! Disable assignment.\n    StickyNote& operator=(StickyNote const& rhs) = delete;\n\n    /*!\n     *  Begins the editing of the note.\n     */\n    void beginEditing();\n\n    /*!\n     *  Gets the vendor extension visualized by the note.\n     *\n     *    @return The vendor extension visualized by the note.\n     */\n    QSharedPointer<VendorExtension> getVendorExtension() const;\n\n    //! The item type identifier.\n    virtual int type() const { return Type; }\n\n    /*!\n     *  Adds a new association to the item.\n     *\n     *    @param [in] association   The association to add.     \n     */\n    virtual void addAssociation(Association* association);\n\n    /*!\n     *  Removes an association from the item.\n     *\n     *    @param [in] association   The association to remove.     \n     */\n    virtual void removeAssociation(Association* association);    \n\n    /*!\n     *  Defines the connection point for associations in scene coordinates.\n     *     \n     *    @param [in] otherEnd   The position of the other end connection point.\n     *\n     *    @return The connection point of the item.\n     */\n    virtual QPointF connectionPoint(QPointF const& otherEnd = QPointF()) const;\n\n    //! Gets the vendor extension for the associations of the note.\n    QSharedPointer<Kactus2Group> getAssociationExtensions() const;\n\n    /*!\n     *  Set the vendor extension for the sticky note to use for storing the data. \n     *  Existing values for position, content, associations and timestamp will be read to the note .\n     *\n     *    @param [in] extension   The vendor extension to set.\n     */\n    void setVendorExtension(QSharedPointer<Kactus2Group> extension);\n\n    /*!\n     *  Sets the note text.\n     *\n     *    @param [in] text   The text to set.\n     */\n    void setText(QString const& text);\n\n    /*!\n     *  Sets the note timestamp.\n     *\n     *    @param [in] timestamp   The timestamp to set.\n     */\n    void setTimestamp(QString const& timestamp);\n\nsignals:\n   \n    //! Emitted when a new association should be created for the item.\n    void beginAssociation(Associable* originator);\n\n\n    /*!\n     *  Emitted when the note has been modified.\n     *\n     *    @param [in] undoCommand   The undo command to undo/redo the modification.\n     */\n    void modified(QUndoCommand* undoCommand);\n\nprotected:\n\n    //! Handler for mouse press events.\n    virtual void mousePressEvent(QGraphicsSceneMouseEvent* event);\n\n    //! Handler for mouse release event.\n    virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent* event);\n\n    /*!\n     *  Checks if the item's position has changed as a result of a mouse drag.\n     *\n     *    @return True, if the position has changed, otherwise false.\n     */\n    bool positionChanged();\n\n    /*!\n     *  Handler for item state changes.\n     *\n     *    @param [in] change      The parameter of the item changing.\n     *    @param [in] value       The new value of the parameter.\n     *\n     *    @return The set new value.\n     */\n    virtual QVariant itemChange(GraphicsItemChange change, const QVariant& value);\n\nprivate slots:\n\n    //! Called when the note text has changed.\n    virtual void onTextEdited();\n\nprivate:\n\n     //! Initializes the item flags.     \n    void setItemOptions();\n\n    //! Creates the glued edge at the top of the note.\n    void createGluedEdge();\n\n    //! Creates the writing area of the note.\n    void createWritableArea();\n\n    //! Creates a button for initiating an association.\n    void createAssociationButton();\n\n    /*!\n     *  Checks if clicking a given position hits the association button.\n     *\n     *    @param [in] clickPosition   The position of the click.\n     *\n     *    @return True, if the click hits the association button, otherwise false.\n     */\n    bool hitsAssociationButton(QPointF const& clickPosition) const;   \n    \n    /*!\n     *  Gets the timestamp for current time and date as formatted string.\n     *\n     *    @return Current time and date.\n     */\n    QString getFormattedTimestamp();\n\n    //-----------------------------------------------------------------------------\n    // Data.\n    //-----------------------------------------------------------------------------\n\n    //! The position of the item before move.\n    QPointF oldPos_;\n\n    //! The vendor extension represented by the note.\n    QSharedPointer<Kactus2Group> extension_;\n\n    //! The vendor extension containing the position of the note.\n    QSharedPointer<Kactus2Position> positionExtension_;\n\n    //! The vendor extension containing the text of the note.\n    QSharedPointer<Kactus2Value> contentExtension_;\n\n    //! The vendor extension containing the text of the note.\n    QSharedPointer<Kactus2Group> associationExtensions_;\n\n    //! The vendor extension containing the timestamp of the note.\n    QSharedPointer<Kactus2Value> timestampExtension_;\n\n    //! Editor item for the notes.\n    ColorFillTextItem* textArea_;\n\n    //! Label for displaying the edit timestamp.\n    QGraphicsSimpleTextItem* timeLabel_;\n\n    //! Item acting as a button for creating new associations.\n    QGraphicsPixmapItem* associationButton_;\n};\n\n#endif // STICKYNOTE_H"
  },
  {
    "path": "editors/common/StickyNote/StickyNoteAddCommand.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: FloatingItemAddCommand.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Esko Pekkarinen\r\n// Date: 30.05.2014\r\n//\r\n// Description:\r\n// Add command for sticky note items.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"StickyNoteAddCommand.h\"\r\n\r\n#include \"StickyNote.h\"\r\n\r\n#include <IPXACTmodels/common/VendorExtension.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: StickyNoteAddCommand()\r\n//-----------------------------------------------------------------------------\r\nStickyNoteAddCommand::StickyNoteAddCommand(StickyNote* note, QGraphicsScene* scene, QPointF position,\r\n    QUndoCommand* parent) : QUndoCommand(parent), note_(note),\r\n    scene_(scene), position_(position), del_(false)\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ~StickyNoteAddCommand()\r\n//-----------------------------------------------------------------------------\r\nStickyNoteAddCommand::~StickyNoteAddCommand()\r\n{\r\n    if (del_)\r\n    {\r\n        delete note_;\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: undo()\r\n//-----------------------------------------------------------------------------\r\nvoid StickyNoteAddCommand::undo()\r\n{\r\n    // Remove the item from the stack and the scene.\r\n    scene_->removeItem(note_);\r\n    del_ = true;\r\n\r\n    emit removeVendorExtension(note_->getVendorExtension());\r\n\r\n    // Execute child commands.\r\n    QUndoCommand::undo();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: redo()\r\n//-----------------------------------------------------------------------------\r\nvoid StickyNoteAddCommand::redo()\r\n{\r\n    // Add the item to the stack.\r\n    scene_->addItem(note_);\r\n    note_->setPos(position_);    \r\n\r\n    del_ = false;\r\n\r\n    emit addVendorExtension(note_->getVendorExtension());\r\n\r\n    QUndoCommand::redo();\r\n}\r\n"
  },
  {
    "path": "editors/common/StickyNote/StickyNoteAddCommand.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: FloatingItemAddCommand.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Esko Pekkarinen\r\n// Date: 30.05.2014\r\n//\r\n// Description:\r\n// Add command for sticky note items.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef STICKYNOTEADDCOMMAND_H\r\n#define STICKYNOTEADDCOMMAND_H\r\n\r\n#include <QUndoCommand>\r\n\r\n#include <IPXACTmodels/common/VendorExtension.h>\r\n\r\n#include <QGraphicsItem>\r\n#include <QGraphicsScene>\r\n#include <QObject>\r\n#include <QPointF>\r\n#include <QSharedPointer>\r\n\r\nclass StickyNote;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! StickyNoteAddCommand class.\r\n//-----------------------------------------------------------------------------\r\nclass StickyNoteAddCommand : public QObject, public QUndoCommand\r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n    /*!\r\n     *  Constructor.\r\n     *\r\n     *    @param [in] item        The item to add.\r\n     *    @param [in] scene       The scene to which to add the item.\r\n     *    @param [in] position    The initial position of the item.\r\n     *    @param [in] parent      The parent command.\r\n     */\r\n    StickyNoteAddCommand(StickyNote* noteItem, QGraphicsScene* scene, QPointF position, QUndoCommand* parent = 0);\r\n\r\n    /*!\r\n     *  Destructor.\r\n     */\r\n    ~StickyNoteAddCommand();\r\n\r\n    /*!\r\n     *  Undoes the command.\r\n     */\r\n    virtual void undo();\r\n\r\n    /*!\r\n     *  Redoes the command.\r\n     */\r\n    virtual void redo();\r\n\r\nsignals:\r\n\r\n    void addVendorExtension(QSharedPointer<VendorExtension>);\r\n\r\n    void removeVendorExtension(QSharedPointer<VendorExtension>);\r\n\r\nprivate:\r\n    // Disable copying.\r\n    StickyNoteAddCommand(StickyNoteAddCommand const& rhs);\r\n    StickyNoteAddCommand& operator=(StickyNoteAddCommand const& rhs);\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! The graphics item.\r\n    StickyNote* note_;\r\n\r\n    //! The item's parent column.\r\n    QGraphicsScene* scene_;\r\n\r\n    //! The item's initial position.\r\n    QPointF position_;\r\n\r\n    //! Boolean flag for indicating if the item should be deleted in the destructor.\r\n    bool del_;\r\n\r\n};\r\n\r\n#endif //STICKYNOTEADDCOMMAND_H"
  },
  {
    "path": "editors/common/StickyNote/StickyNoteEditCommand.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: StickyNoteEditCommand.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Esko Pekkarinen\r\n// Date: 30.06.2014\r\n//\r\n// Description:\r\n// Edit command for sticky note items.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"StickyNoteEditCommand.h\"\r\n\r\n#include \"StickyNote.h\"\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: StickyNoteEditCommand()\r\n//-----------------------------------------------------------------------------\r\nStickyNoteEditCommand::StickyNoteEditCommand(StickyNote* noteItem, \r\n    QString const& newText, QString const& oldText, \r\n    QString const& newTimestamp, QString const& oldTimestamp, \r\n    QUndoCommand* parent) : \r\n    QUndoCommand(parent),\r\n    note_(noteItem),\r\n    newText_(newText),\r\n    oldText_(oldText),\r\n    newTimestamp_(newTimestamp),\r\n    oldTimestamp_(oldTimestamp)\r\n{\r\n  \r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ~StickyNoteEditCommand()\r\n//-----------------------------------------------------------------------------\r\nStickyNoteEditCommand::~StickyNoteEditCommand()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: undo()\r\n//-----------------------------------------------------------------------------\r\nvoid StickyNoteEditCommand::undo()\r\n{\r\n    note_->setText(oldText_);\r\n    note_->setTimestamp(oldTimestamp_);\r\n\r\n    // Execute child commands.\r\n    QUndoCommand::undo();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: redo()\r\n//-----------------------------------------------------------------------------\r\nvoid StickyNoteEditCommand::redo()\r\n{\r\n    note_->setText(newText_);\r\n    note_->setTimestamp(newTimestamp_);\r\n\r\n    QUndoCommand::redo();\r\n}\r\n"
  },
  {
    "path": "editors/common/StickyNote/StickyNoteEditCommand.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: StickyNoteEditCommand.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Esko Pekkarinen\r\n// Date: 30.06.2014\r\n//\r\n// Description:\r\n// Edit command for sticky note items.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef STICKYNOTEEDITCOMMAND_H\r\n#define STICKYNOTEEDITCOMMAND_H\r\n\r\n#include <QUndoCommand>\r\n\r\n#include <QString>\r\n#include <QSharedPointer>\r\n\r\nclass StickyNote;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! StickyNoteEditCommand class.\r\n//-----------------------------------------------------------------------------\r\nclass StickyNoteEditCommand : public QUndoCommand\r\n{\r\npublic:\r\n\r\n    /*!\r\n     *  <Description>.\r\n     *\r\n     *    @param [in] noteItem        The updated note.\r\n     *    @param [in] newText         The new text on the note.\r\n     *    @param [in] oldText         The previous text on the note.\r\n     *    @param [in] newTimestamp    The edit timestamp.\r\n     *    @param [in] oldTimestamp    The previous edit timestamp.\r\n     *    @param [in] parent          The parent command.\r\n     */\r\n    StickyNoteEditCommand(StickyNote* noteItem, QString const& newText, QString const& oldText, \r\n        QString const& newTimestamp, QString const& oldTimestamp, QUndoCommand* parent = 0);\r\n\r\n    /*!\r\n     *  Destructor.\r\n     */\r\n    ~StickyNoteEditCommand();\r\n\r\n    /*!\r\n     *  Undoes the command.\r\n     */\r\n    virtual void undo();\r\n\r\n    /*!\r\n     *  Redoes the command.\r\n     */\r\n    virtual void redo();\r\n\r\nprivate:\r\n    // Disable copying.\r\n    StickyNoteEditCommand(StickyNoteEditCommand const& rhs);\r\n    StickyNoteEditCommand& operator=(StickyNoteEditCommand const& rhs);\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! The graphics item.\r\n    StickyNote* note_;\r\n\r\n    //! The note's updated text content.\r\n    QString newText_;\r\n\r\n    //! The note's previous text content.\r\n    QString oldText_;\r\n\r\n    //! The note's updated timestamp.\r\n    QString newTimestamp_;\r\n\r\n    //! The note's previous timestamp.\r\n    QString oldTimestamp_;\r\n\r\n};\r\n\r\n#endif //STICKYNOTEEDITCOMMAND_H"
  },
  {
    "path": "editors/common/StickyNote/StickyNoteMoveCommand.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: StickyNoteMoveCommand.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Esko Pekkarinen\r\n// Date: 30.05.2014\r\n//\r\n// Description:\r\n// Move command for floating items.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"StickyNoteMoveCommand.h\"\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: StickyNoteMoveCommand()\r\n//-----------------------------------------------------------------------------\r\nStickyNoteMoveCommand::StickyNoteMoveCommand(QGraphicsItem* item, QPointF const& oldPos, QUndoCommand* parent)\r\n    : QUndoCommand(parent),\r\n    item_(item),\r\n    oldPos_(oldPos),\r\n    newPos_(item->scenePos())\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ~StickyNoteMoveCommand()\r\n//-----------------------------------------------------------------------------\r\nStickyNoteMoveCommand::~StickyNoteMoveCommand()\r\n{\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: undo()\r\n//-----------------------------------------------------------------------------\r\nvoid StickyNoteMoveCommand::undo()\r\n{\r\n    item_->setPos(oldPos_);\r\n\r\n    // Execute child commands.\r\n    QUndoCommand::undo();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: redo()\r\n//-----------------------------------------------------------------------------\r\nvoid StickyNoteMoveCommand::redo()\r\n{\r\n    item_->setPos(newPos_);\r\n\r\n    // Execute child commands.\r\n    QUndoCommand::redo();\r\n}"
  },
  {
    "path": "editors/common/StickyNote/StickyNoteMoveCommand.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: StickyNoteMoveCommand.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Esko Pekkarinen\r\n// Date: 30.05.2014\r\n//\r\n// Description:\r\n// Move command for floating items.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef STICKYNOTEMOVECOMMAND_H\r\n#define STICKYNOTEMOVECOMMAND_H\r\n\r\n#include <QUndoCommand>\r\n#include <QGraphicsItem>\r\n#include <QGraphicsScene>\r\n#include <QObject>\r\n#include <QPointF>\r\n\r\n//-----------------------------------------------------------------------------\r\n//! StickyNoteMoveCommand class.\r\n//-----------------------------------------------------------------------------\r\nclass StickyNoteMoveCommand : public QUndoCommand\r\n{\r\npublic:\r\n    /*!\r\n     *  Constructor.\r\n     *\r\n     *    @param [in] item      The item to move.\r\n     *    @param [in] oldPos    The item's old position.\r\n     *    @param [in] parent    The parent command.\r\n     */\r\n    StickyNoteMoveCommand(QGraphicsItem* item, QPointF const& oldPos,  QUndoCommand* parent = 0);\r\n\r\n    /*!\r\n     *  Destructor.\r\n     */\r\n    ~StickyNoteMoveCommand();\r\n\r\n    /*!\r\n     *  Undoes the command.\r\n     */\r\n    virtual void undo();\r\n\r\n    /*!\r\n     *  Redoes the command.\r\n     */\r\n    virtual void redo();\r\n\r\nprivate:\r\n    // Disable copying.\r\n    StickyNoteMoveCommand(StickyNoteMoveCommand const& rhs);\r\n    StickyNoteMoveCommand& operator=(StickyNoteMoveCommand const& rhs);\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! The graphics item.\r\n    QGraphicsItem* item_;\r\n\r\n    //! The old position of the item.\r\n    QPointF oldPos_;\r\n\r\n    //! The new position of the item.\r\n    QPointF newPos_;\r\n\r\n};\r\n//-----------------------------------------------------------------------------\r\n\r\n#endif // STICKYNOTEMOVECOMMAND_H"
  },
  {
    "path": "editors/common/StickyNote/StickyNoteRemoveCommand.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: FloatingItemRemoveCommand.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Esko Pekkarinen\r\n// Date: 30.05.2014\r\n//\r\n// Description:\r\n// Remove command for floating items.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"StickyNoteRemoveCommand.h\"\r\n\r\n#include <editors/common/Association/AssociationRemoveCommand.h>\r\n\r\n#include <IPXACTmodels/common/VendorExtension.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FloatingItemRemoveCommand()\r\n//-----------------------------------------------------------------------------\r\nStickyNoteRemoveCommand::StickyNoteRemoveCommand(StickyNote* noteItem, QGraphicsScene* scene, \r\n    QUndoCommand* parent) : \r\n    QUndoCommand(parent), note_(noteItem),\r\n    scene_(scene), \r\n    del_(true)\r\n{\r\n    foreach(Association* association, noteItem->getAssociations())\r\n    {\r\n        new AssociationRemoveCommand(association, scene_, this);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ~FloatingItemRemoveCommand()\r\n//-----------------------------------------------------------------------------\r\nStickyNoteRemoveCommand::~StickyNoteRemoveCommand()\r\n{\r\n    if (del_)\r\n    {\r\n        delete note_;\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: undo()\r\n//-----------------------------------------------------------------------------\r\nvoid StickyNoteRemoveCommand::undo()\r\n{\r\n    scene_->addItem(note_);\r\n    del_ = false;\r\n\r\n    emit addVendorExtension(note_->getVendorExtension());\r\n\r\n    // Execute child commands.\r\n    QUndoCommand::undo();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: redo()\r\n//-----------------------------------------------------------------------------\r\nvoid StickyNoteRemoveCommand::redo()\r\n{\r\n    scene_->removeItem(note_);\r\n    del_ = true;\r\n\r\n    emit removeVendorExtension(note_->getVendorExtension());\r\n\r\n    QUndoCommand::redo();\r\n}\r\n"
  },
  {
    "path": "editors/common/StickyNote/StickyNoteRemoveCommand.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: StickyNoteRemoveCommand.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Esko Pekkarinen\r\n// Date: 30.05.2014\r\n//\r\n// Description:\r\n// Remove command for sticky note items.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef STICKYNOTEREMOVECOMMAND_H\r\n#define STICKYNOTEREMOVECOMMAND_H\r\n\r\n#include \"StickyNote.h\"\r\n\r\n#include <IPXACTmodels/common/VendorExtension.h>\r\n\r\n#include <QUndoCommand>\r\n#include <QGraphicsItem>\r\n#include <QGraphicsScene>\r\n#include <QObject>\r\n#include <QSharedPointer>\r\n\r\n//-----------------------------------------------------------------------------\r\n//! FloatingItemRemoveCommand class.\r\n//-----------------------------------------------------------------------------\r\nclass StickyNoteRemoveCommand : public QObject, public QUndoCommand\r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n    /*!\r\n     *  Constructor.\r\n     *\r\n     *    @param [in] item        The item to remove.\r\n     *    @param [in] parent      The parent command.\r\n     */\r\n    StickyNoteRemoveCommand(StickyNote* noteItem, QGraphicsScene* diagram, QUndoCommand* parent = 0);\r\n\r\n    /*!\r\n     *  Destructor.\r\n     */\r\n    ~StickyNoteRemoveCommand();\r\n\r\n    /*!\r\n     *  Undoes the command.\r\n     */\r\n    virtual void undo();\r\n\r\n    /*!\r\n     *  Redoes the command.\r\n     */\r\n    virtual void redo();\r\n\r\nsignals:\r\n\r\n    void addVendorExtension(QSharedPointer<VendorExtension>);\r\n\r\n    void removeVendorExtension(QSharedPointer<VendorExtension>);\r\n\r\nprivate:\r\n    // Disable copying.\r\n    StickyNoteRemoveCommand(StickyNoteRemoveCommand const& rhs);\r\n    StickyNoteRemoveCommand& operator=(StickyNoteRemoveCommand const& rhs);\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! The graphics item.\r\n    StickyNote* note_;\r\n\r\n    //! The item's parent scene.\r\n    QGraphicsScene* scene_;\r\n\r\n    //! Boolean flag for indicating if the items should be deleted in the destructor.\r\n    bool del_;\r\n\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n#endif // STICKYNOTEREMOVECOMMAND_H"
  },
  {
    "path": "editors/common/TopComponentParameterFinder.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: TopComponentParameterFinder.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Esko Pekkarinen\r\n// Date: 18.03.2015\r\n//\r\n// Description:\r\n// Parameter finder for design top component.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"TopComponentParameterFinder.h\"\r\n\r\n#include <IPXACTmodels/Component/Component.h>\r\n#include <IPXACTmodels/Component/View.h>\r\n#include <IPXACTmodels/Component/ComponentInstantiation.h>\r\n#include <IPXACTmodels/common/Parameter.h>\r\n#include <IPXACTmodels/common/ModuleParameter.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: TopComponentParameterFinder::TopComponentParameterFinder()\r\n//-----------------------------------------------------------------------------\r\nTopComponentParameterFinder::TopComponentParameterFinder(QSharedPointer<Component> component):\r\ncomponent_(component)\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: TopComponentParameterFinder::TopComponentParameterFinder()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<Parameter> TopComponentParameterFinder::getParameterWithID(QStringView parameterId) const\r\n{\r\n    if (!component_.isNull())\r\n    {\r\n        for (QSharedPointer<Parameter> parameter : *component_->getParameters())\r\n        {\r\n            if (parameter->getValueId() == parameterId)\r\n            {\r\n                return parameter;\r\n            }\r\n        }\r\n\r\n        for (QSharedPointer<Parameter> viewParameter : activeViewParameters())\r\n        {\r\n            if (viewParameter->getValueId() == parameterId)\r\n            {\r\n                return viewParameter;\r\n            }\r\n        }\r\n    }\r\n\r\n    return QSharedPointer<Parameter>(new Parameter());\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: TopComponentParameterFinder::hasId()\r\n//-----------------------------------------------------------------------------\r\nbool TopComponentParameterFinder::hasId(QStringView id) const\r\n{\r\n    if (!component_.isNull())\r\n    {\r\n        for (QSharedPointer<Parameter> parameter : *component_->getParameters())\r\n        {\r\n            if (parameter->getValueId() == id)\r\n            {\r\n                return true;\r\n            }\r\n        }\r\n\r\n        for (QSharedPointer<Parameter> viewParameter : activeViewParameters())\r\n        {\r\n            if (viewParameter->getValueId() == id)\r\n            {\r\n                return true;\r\n            }\r\n        }\r\n    }\r\n\r\n    return false;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: TopComponentParameterFinder::nameForId()\r\n//-----------------------------------------------------------------------------\r\nQString TopComponentParameterFinder::nameForId(QStringView id) const\r\n{\r\n    return  getParameterWithID(id)->name();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: TopComponentParameterFinder::valueForId()\r\n//-----------------------------------------------------------------------------\r\nQString TopComponentParameterFinder::valueForId(QStringView id) const\r\n{\r\n    return  getParameterWithID(id)->getValue();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: TopComponentParameterFinder::getAllParameterIds()\r\n//-----------------------------------------------------------------------------\r\nQStringList TopComponentParameterFinder::getAllParameterIds() const\r\n{\r\n    QStringList allParameterIds;\r\n\r\n    if (!component_.isNull())\r\n    {\r\n        for (QSharedPointer<Parameter> parameter : *component_->getParameters())\r\n        {\r\n            allParameterIds.append(parameter->getValueId());\r\n        }\r\n\r\n        for (QSharedPointer<Parameter> parameter : activeViewParameters())\r\n        {\r\n            allParameterIds.append(parameter->getValueId());\r\n        }\r\n    }\r\n\r\n    return allParameterIds;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: TopComponentParameterFinder::getNumberOfParameters()\r\n//-----------------------------------------------------------------------------\r\nint TopComponentParameterFinder::getNumberOfParameters() const\r\n{\r\n    return getAllParameterIds().size();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: TopComponentParameterFinder::setComponent()\r\n//-----------------------------------------------------------------------------\r\nvoid TopComponentParameterFinder::setComponent(QSharedPointer<Component> component)\r\n{\r\n    component_ = component;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: TopComponentParameterFinder::setActiveView()\r\n//-----------------------------------------------------------------------------\r\nvoid TopComponentParameterFinder::setActiveView(QSharedPointer<View> view)\r\n{\r\n    activeView_ = view;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: TopComponentParameterFinder::registerParameterModel()\r\n//-----------------------------------------------------------------------------\r\nvoid TopComponentParameterFinder::registerParameterModel(QAbstractItemModel const* /*model*/)\r\n{\r\n    // Nothing to do.\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: TopComponentParameterFinder::activeViewParameters()\r\n//-----------------------------------------------------------------------------\r\nQList<QSharedPointer<Parameter> > TopComponentParameterFinder::activeViewParameters() const\r\n{\r\n    QList<QSharedPointer<Parameter> > viewParameters;\r\n\r\n    if (!activeView_)\r\n    {\r\n        return viewParameters;\r\n    }\r\n\r\n    QSharedPointer<ComponentInstantiation> instantiation = component_->getModel()->\r\n        findComponentInstantiation(activeView_->getComponentInstantiationRef());\r\n\r\n    if (!instantiation)\r\n    {\r\n        return viewParameters;\r\n    }\r\n\r\n    viewParameters.append(*instantiation->getParameters());\r\n\r\n    for (QSharedPointer<ModuleParameter> parameter : *instantiation->getModuleParameters())\r\n    {\r\n        viewParameters.append(parameter);\r\n    }\r\n\r\n    return viewParameters;\r\n}\r\n"
  },
  {
    "path": "editors/common/TopComponentParameterFinder.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: TopComponentParameterFinder.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Esko Pekkarinen\r\n// Date: 18.03.2015\r\n//\r\n// Description:\r\n// Parameter finder for design top component.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef TOPCOMPONENTPARAMETERFINDER_H\r\n#define TOPCOMPONENTPARAMETERFINDER_H\r\n\r\n#include <KactusAPI/include/ParameterFinder.h>\r\n\r\nclass Component;\r\nclass View;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Parameter finder for design top component.\r\n//-----------------------------------------------------------------------------\r\nclass TopComponentParameterFinder : public ParameterFinder\r\n{\r\npublic:\r\n\r\n    /*!\r\n     *  Constructor.\r\n     *\r\n     *    @param [in] component   The component which parameters are being searched for.\r\n     */\r\n    explicit TopComponentParameterFinder(QSharedPointer<Component> component);\r\n\r\n    /*!\r\n     *  Destructor.\r\n     */\r\n    ~TopComponentParameterFinder() final = default;\r\n\r\n    //! No copying\r\n    TopComponentParameterFinder(const TopComponentParameterFinder& other) = delete;\r\n\r\n    //! No assignment\r\n    TopComponentParameterFinder& operator=(const TopComponentParameterFinder& other) = delete;\r\n\r\n    /*!\r\n     *  Get the parameter with the given id.\r\n     *\r\n     *    @param [in] parameterId     The id of the parameter being searched for.\r\n     */\r\n    QSharedPointer<Parameter> getParameterWithID(QStringView parameterId) const final;\r\n\r\n    /*!\r\n     *  Checks if a parameter with the given id exists.\r\n     *\r\n     *    @param [in] id      The id to search for.\r\n     *\r\n     *    @return True, if the parameter with the given id exists, otherwise false.\r\n     */\r\n    bool hasId(QStringView id) const final;\r\n\r\n    /*!\r\n     *  Finds the name of the parameter with the given id.\r\n     *\r\n     *    @param [in] id      The id to search for.\r\n     *\r\n     *    @return The name of the parameter.\r\n     */\r\n    QString nameForId(QStringView id) const final;\r\n\r\n    /*!\r\n     *  Finds the value of the parameter with the given id.\r\n     *\r\n     *    @param [in] id      The id of the parameter to search for.\r\n     *\r\n     *    @return The value of the parameter.\r\n     */\r\n    QString valueForId(QStringView id) const final;\r\n\r\n    /*!\r\n     *  Gets all of the ids of components parameters.\r\n     *\r\n     *    @return A list containing all of the ids.\r\n     */\r\n    QStringList getAllParameterIds() const final;\r\n\r\n    /*!\r\n     *  Gets the number of parameters in the component.\r\n     *\r\n     *    @return The number of parameters in the component.\r\n     */\r\n    int getNumberOfParameters() const final;\r\n\r\n    /*!\r\n     *  Set a new component for the parameter finder.\r\n     *\r\n     *    @param [in] component   The new component.\r\n     */\r\n    void setComponent(QSharedPointer<Component> component);\r\n\r\n    /*!\r\n     *  Sets the active view to use for the component.\r\n     *\r\n     *    @param [in] view   The name of the active view.\r\n     */\r\n    void setActiveView(QSharedPointer<View> view);\r\n    \r\n    /*!\r\n     *  Registers a parameter model that can modify parameters for the finder.\r\n     *\r\n     *    @param [in] model   The model to register.\r\n     */\r\n    void registerParameterModel(QAbstractItemModel const* model) final;\r\n\r\nprivate:\r\n\r\n\r\n    /*!\r\n     *  Finds all the parameters in the active view.\r\n     *\r\n     *    @return The parameters in active view.\r\n     */\r\n    QList<QSharedPointer<Parameter> > activeViewParameters() const;\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! The parameters are searched from this component.\r\n    QSharedPointer<Component> component_;\r\n\r\n    //! The active view of the component.\r\n    QSharedPointer<View> activeView_;\r\n};\r\n\r\n#endif // TOPCOMPONENTPARAMETERFINDER_H\r\n"
  },
  {
    "path": "editors/common/VendorExtensionEditor/VendorExtensionAttributesEditor/VendorExtensionAttributesColumns.h",
    "content": "//-----------------------------------------------------------------------------\n// File: VendorExtensionAttributesColumns.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 20.03.2019\n//\n// Description:\n// Common declarations for editing vendor extension attributes.\n//-----------------------------------------------------------------------------\n\nnamespace VendorExtensionAttributesColumns\n{\n    //! The editable columns in the attributes.\n    enum columns\n    {\n        TYPE = 0,\n        VALUE,\n        COLUMN_COUNT,\n    };\n}\n"
  },
  {
    "path": "editors/common/VendorExtensionEditor/VendorExtensionAttributesEditor/VendorExtensionAttributesModel.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: VendorExtensionAttributesModel.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 20.03.2019\n//\n// Description:\n// Model for editing vendor extension attributes.\n//-----------------------------------------------------------------------------\n\n#include \"VendorExtensionAttributesModel.h\"\n\n#include <common/KactusColors.h>\n\n#include <editors/common/VendorExtensionEditor/VendorExtensionAttributesEditor/VendorExtensionAttributesColumns.h>\n\n#include <IPXACTmodels/common/GenericVendorExtension.h>\n\n//-----------------------------------------------------------------------------\n// Function: VendorExtensionAttributesModel::VendorExtensionAttributesModel()\n//-----------------------------------------------------------------------------\nVendorExtensionAttributesModel::VendorExtensionAttributesModel(GenericVendorExtension* genericExtension,\n    QObject* parent) :\nQAbstractTableModel(parent),\nattributes_(genericExtension->getAttributes())\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: VendorExtensionAttributesModel::~VendorExtensionAttributesModel()\n//-----------------------------------------------------------------------------\nVendorExtensionAttributesModel::~VendorExtensionAttributesModel()\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: VendorExtensionAttributesModel::columnCount()\n//-----------------------------------------------------------------------------\nint VendorExtensionAttributesModel::columnCount(const QModelIndex& parent) const\n{\n    if (parent.isValid())\n    {\n        return 0;\n    }\n\n    return VendorExtensionAttributesColumns::COLUMN_COUNT;\n}\n\n//-----------------------------------------------------------------------------\n// Function: VendorExtensionAttributesModel::rowCount()\n//-----------------------------------------------------------------------------\nint VendorExtensionAttributesModel::rowCount(const QModelIndex &parent) const\n{\n    if (parent.isValid())\n    {\n        return 0;\n    }\n\n    return attributes_.count();\n}\n\n//-----------------------------------------------------------------------------\n// Function: VendorExtensionAttributesModel::headerData()\n//-----------------------------------------------------------------------------\nQVariant VendorExtensionAttributesModel::headerData(int section, Qt::Orientation orientation, int role) const\n{\n    if (orientation == Qt::Horizontal && role == Qt::DisplayRole)\n    {\n        if (section == VendorExtensionAttributesColumns::TYPE)\n        {\n            return tr(\"Type\");\n        }\n        else if (section == VendorExtensionAttributesColumns::VALUE)\n        {\n            return tr(\"Value\");\n        }\n    }\n\n    return QVariant();\n}\n\n//-----------------------------------------------------------------------------\n// Function: VendorExtensionAttributesModel::data()\n//-----------------------------------------------------------------------------\nQVariant VendorExtensionAttributesModel::data(const QModelIndex &index, int role) const\n{\n    if (indexIsNotValid(index))\n    {\n        return QVariant();\n    }\n\n    if (role == Qt::DisplayRole || role == Qt::EditRole || role == Qt::ToolTipRole)\n    {\n        return valueForIndex(index);\n    }\n    else if (role == Qt::BackgroundRole)\n    {\n        if (index.column() == VendorExtensionAttributesColumns::TYPE)\n        {\n            return KactusColors::MANDATORY_FIELD;\n        }\n        else\n        {\n            return KactusColors::REGULAR_FIELD;\n        }\n    }\n\n    return QVariant();\n}\n\n//-----------------------------------------------------------------------------\n// Function: VendorExtensionAttributesModel::setData()\n//-----------------------------------------------------------------------------\nbool VendorExtensionAttributesModel::setData(const QModelIndex &index, const QVariant &value, int role)\n{\n    if (indexIsNotValid(index))\n    {\n        return false;\n    }\n\n    if (role == Qt::EditRole && (index.column() == VendorExtensionAttributesColumns::TYPE ||\n        index.column() == VendorExtensionAttributesColumns::VALUE))\n    {\n        QPair<QString, QString> newPair = attributes_.at(index.row());\n        QString newValue = value.toString();\n\n        if (index.column() == VendorExtensionAttributesColumns::TYPE && !newValue.isEmpty() &&\n            !nameExistsInAttributes(newValue))\n        {\n            newPair.first = newValue;\n        }\n        else if (index.column() == VendorExtensionAttributesColumns::VALUE)\n        {\n            newPair.second = newValue;\n        }\n        else\n        {\n            return false;\n        }\n\n        attributes_.replace(index.row(), newPair);\n    }\n\n    emit dataChanged(index, index);\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: VendorExtensionAttributesModel::flags()\n//-----------------------------------------------------------------------------\nQt::ItemFlags VendorExtensionAttributesModel::flags(QModelIndex const& index) const\n{\n    if (indexIsNotValid(index))\n    {\n        return Qt::NoItemFlags;\n    }\n\n    return Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsEditable;\n}\n\n//-----------------------------------------------------------------------------\n// Function: VendorExtensionAttributesModel::isNotValidIndex()\n//-----------------------------------------------------------------------------\nbool VendorExtensionAttributesModel::indexIsNotValid(QModelIndex const& index) const\n{\n    return !index.isValid() || index.row() < 0 || index.row() >= attributes_.size() || index.column() < 0 ||\n        index.column() >= VendorExtensionAttributesColumns::COLUMN_COUNT;\n}\n\n//-----------------------------------------------------------------------------\n// Function: VendorExtensionAttributesModel::valueForIndex()\n//-----------------------------------------------------------------------------\nQVariant VendorExtensionAttributesModel::valueForIndex(QModelIndex const& index) const\n{\n    if (index.column() == VendorExtensionAttributesColumns::TYPE ||\n        index.column() == VendorExtensionAttributesColumns::VALUE)\n    {\n        QPair<QString, QString> indexedAttribute =  attributes_.at(index.row());\n\n        if (index.column() == VendorExtensionAttributesColumns::TYPE)\n        {\n            return indexedAttribute.first;\n        }\n        else if (index.column() == VendorExtensionAttributesColumns::VALUE)\n        {\n            return indexedAttribute.second;\n        }\n    }\n    \n    return QVariant();\n}\n\n//-----------------------------------------------------------------------------\n// Function: VendorExtensionAttributesModel::onAddItem()\n//-----------------------------------------------------------------------------\nvoid VendorExtensionAttributesModel::onAddItem(QModelIndex const& index)\n{\n    int row = rowCount();\n    if (index.isValid())\n    {\n        row = index.row();\n    }\n\n    beginInsertRows(QModelIndex(), row, row);\n\n    QPair<QString, QString> newAttribute;\n    newAttribute.first = getUniqueNameForNewAttribute();\n    attributes_.append(newAttribute);\n\n    endInsertRows();\n\n    emit contentChanged();\n}\n\n//-----------------------------------------------------------------------------\n// Function: VendorExtensionAttributesModel::getUniqueNameForNewAttribute()\n//-----------------------------------------------------------------------------\nQString VendorExtensionAttributesModel::getUniqueNameForNewAttribute() const\n{\n    QString newAttributeName = QStringLiteral(\"attribute\");\n    QString changingName = newAttributeName + QStringLiteral(\"_\");\n\n    int cycleCount = 0;\n    while (nameExistsInAttributes(newAttributeName))\n    {\n        newAttributeName = changingName;\n        newAttributeName.append(QString::number(cycleCount));\n        cycleCount++;\n    }\n\n    return newAttributeName;\n}\n\n//-----------------------------------------------------------------------------\n// Function: VendorExtensionAttributesModel::nameExistsInAttributes()\n//-----------------------------------------------------------------------------\nbool VendorExtensionAttributesModel::nameExistsInAttributes(QString const& attributeName) const\n{\n    for (auto const& attribute : attributes_)\n    {\n        if (attribute.first == attributeName)\n        {\n            return true;\n        }\n    }\n\n    return false;\n}\n\n//-----------------------------------------------------------------------------\n// Function: VendorExtensionAttributesModel::onRemoveItem()\n//-----------------------------------------------------------------------------\nvoid VendorExtensionAttributesModel::onRemoveItem(QModelIndex const& index)\n{\n    if (index.isValid())\n    {\n        int row = index.row();\n        \n        beginRemoveRows(QModelIndex(), row, row);\n        attributes_.removeAt(row);\n        endRemoveRows();\n\n        emit contentChanged();\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: VendorExtensionAttributesModel::getAttributes()\n//-----------------------------------------------------------------------------\nQVector<QPair<QString, QString> > VendorExtensionAttributesModel::getAttributes() const\n{\n    return attributes_;\n}\n"
  },
  {
    "path": "editors/common/VendorExtensionEditor/VendorExtensionAttributesEditor/VendorExtensionAttributesModel.h",
    "content": "//-----------------------------------------------------------------------------\n// File: VendorExtensionAttributesModel.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 20.03.2019\n//\n// Description:\n// Model for editing vendor extension attributes.\n//-----------------------------------------------------------------------------\n\n#ifndef VENDOREXTENSIONATTRIBUTESMODEL_H\n#define VENDOREXTENSIONATTRIBUTESMODEL_H\n\n#include <QAbstractTableModel>\n\nclass GenericVendorExtension;\n\n//-----------------------------------------------------------------------------\n// class ParameterArrayModel.\n//-----------------------------------------------------------------------------\nclass VendorExtensionAttributesModel : public QAbstractTableModel\n{\n\tQ_OBJECT\n\npublic:\n\n    /*!\n     *  The constructor.\n     *\n     *    @param [in] genericExtension    Generic extension containing the edited attributes.\n     *    @param [in] parent              The parent of this model.\n     */\n    VendorExtensionAttributesModel(GenericVendorExtension* genericExtension, QObject* parent = 0);\n\n    /*!\n     *  The destructor.\n     */\n    ~VendorExtensionAttributesModel();\n\n    /*!\n     *  Returns the amount of columns in the model.\n     *\n     *    @param [in] parent  If given, the column count of the children of the given parent is returned.\n     *\n     *    @return The amount of columns.\n     */\n    int columnCount(const QModelIndex &parent = QModelIndex()) const;\n\n    /*!\n     *  Returns the amount of rows in the model.\n     *\n     *    @param [in] parent  If given, the row count of the children of the given parent is returned.\n     *\n     *    @return The amount of rows.\n     */\n    int rowCount(const QModelIndex &parent = QModelIndex()) const;\n\n    /*!\n     *  Retrieves the header data for the given column (row headers are not supported in this model).\n     *\n     *    @param [in] section         The column from which the index is retrieved.\n     *    @param [in] orientation     Whether the header is horizontal or vertical.\n     *    @param [in] role            The role for which the header is retrieved.\n     *\n     *    @return The header data.\n     */\n    QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;\n\n    /*!\n     *  Retrieves the data for the appropriate role at the given index.\n     *\n     *    @param [in] index   The index of data to be returned.\n     *    @param [in] role    The role for which data is returned.\n     *\n     *    @return The requested data.\n     */\n    QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;\n\n    /*!\n     *  Sets the data at the given index.\n     *\n     *    @param [in] index   The index at which the data is set.\n     *    @param [in] value   The new value to being set.\n     *    @param [in] role    The role for which the data is set.\n     *\n     *    @return True, if data was set successfully, otherwise false.\n     */\n    bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole);\n\n    /*!\n     *  Returns the flags for an object at the given index.\n     *\n     *    @param [in] index   The index of the object queried.\n     *\n     *    @return The relevant flags.\n     */\n    Qt::ItemFlags flags(QModelIndex const& index) const;\n\n    /*!\n     *  Get the edited attributes.\n     *\n     *    @return The edited attributes.\n     */\n    QVector<QPair<QString, QString> > getAttributes() const;\n\n    // Disable copying. // Disable assignment.\n    VendorExtensionAttributesModel(VendorExtensionAttributesModel const& rhs) = delete;\n    VendorExtensionAttributesModel& operator=(VendorExtensionAttributesModel const& rhs) = default;\n\nsignals:\n    //! Emitted when the model content has changed.\n    void contentChanged();\n\npublic slots:\n\n    /*!\n     *  Called when a new enumeration should be added to the model.\n     *\n     *    @param [in] index   The index to add the enumeration to.\n     */\n    void onAddItem(QModelIndex const& index);\n\n    /*!\n     *  Called when an enumeration should be removed from the model.\n     *\n     *    @param [in] index   The index to remove the enumeration from.\n     */\n    void onRemoveItem(QModelIndex const& index);\n\nprivate:\n\n\n    /*!\n     *  Check if the index is valid.\n     *\n     *    @param [in] index   The index being checked.\n     *\n     *    @return True if the index is not valid, otherwise false.\n     */\n    bool indexIsNotValid(QModelIndex const& index) const;\n\n    /*!\n     *  Gets the value of the array in the given index.\n     *\n     *    @param [in] index   The index of the value.\n     *\n     *    @return The data in the given index.\n     */\n    QVariant valueForIndex(QModelIndex const& index) const;\n\n    /*!\n     *  Get a unique type name for a new attribute.\n     *\n     *    @return A unique type name.\n     */\n    QString getUniqueNameForNewAttribute() const;\n\n    /*!\n     *  Check if the selected type name exists in the current attributes.\n     *\n     *    @param [in] attributeName   The selected type name.\n     *\n     *    @return True, if the name exists in the selected attributes, false otherwise.\n     */\n    bool nameExistsInAttributes(QString const& attributeName) const;\n\n    //-----------------------------------------------------------------------------\n    // Data.\n    //-----------------------------------------------------------------------------\n\n    //! List of attribute type / value pairs.\n    QVector<QPair<QString, QString> > attributes_;\n};\n\n#endif // VENDOREXTENSIONATTRIBUTESMODEL_H\n"
  },
  {
    "path": "editors/common/VendorExtensionEditor/VendorExtensionColumns.h",
    "content": "//-----------------------------------------------------------------------------\n//-----------------------------------------------------------------------------\n// File: VendorExtensionColumns.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Esko Pekkarinen\n// Date: 05.12.2018\n//\n// Description:\n// Common declarations for editing vendor extensions.\n//-----------------------------------------------------------------------------\n\nnamespace VendorExtensionColumns\n{\n    //-----------------------------------------------------------------------------\n    // Constants defining which column represents what kind of information.\n    //-----------------------------------------------------------------------------\n    enum Columns\n    {\n        NAMESPACE,          //! Column for the name space of the vendor extension.\n        NAME,               //! Column for the name of the vendor extension.\n        ATTRIBUTES,         //! Column for attributes of the vendor extension.\n        VALUE,              //! Column for the configurable value.\n        DESCRIPTION,        //! Column for description.\n        COLUMN_COUNT\n    };\n}\n"
  },
  {
    "path": "editors/common/VendorExtensionEditor/VendorExtensionsDelegate.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: VendorExtensionsDelegate.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 16.01.2019\n//\n// Description:\n// The delegate to provide editors to add/remove/edit the vendor extensions.\n//-----------------------------------------------------------------------------\n\n#include \"VendorExtensionsDelegate.h\"\n\n#include <common/views/EditableTableView/editabletableview.h>\n\n#include <editors/common/VendorExtensionEditor/VendorExtensionsGeneral.h>\n#include <editors/common/VendorExtensionEditor/VendorExtensionColumns.h>\n#include <editors/common/VendorExtensionEditor/VendorExtensionAttributesEditor/VendorExtensionAttributesModel.h>\n\n#include <IPXACTmodels/common/VendorExtension.h>\n#include <IPXACTmodels/common/GenericVendorExtension.h>\n\n#include <QScrollArea>\n#include <QLineEdit>\n#include <QPainter>\n\n//-----------------------------------------------------------------------------\n// Function: VendorExtensionsDelegate::VendorExtensionsDelegate()\n//-----------------------------------------------------------------------------\nVendorExtensionsDelegate::VendorExtensionsDelegate(QObject* parent):\nQStyledItemDelegate(parent)\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: VendorExtensionsDelegate::~VendorExtensionsDelegate()\n//-----------------------------------------------------------------------------\nVendorExtensionsDelegate::~VendorExtensionsDelegate()\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: VendorExtensionsDelegate::createEditor()\n//-----------------------------------------------------------------------------\nQWidget* VendorExtensionsDelegate::createEditor(QWidget* parent, QStyleOptionViewItem const& option,\n    QModelIndex const& index) const\n{\n    if (index.column() == VendorExtensionColumns::NAMESPACE || index.column() == VendorExtensionColumns::NAME ||\n        index.column() == VendorExtensionColumns::VALUE || index.column() == VendorExtensionColumns::DESCRIPTION)\n    {\n        QLineEdit* lineEdit = new QLineEdit(parent);\n        return lineEdit;\n    }\n    else if (index.column() == VendorExtensionColumns::ATTRIBUTES)\n    {\n        EditableTableView* editor = new EditableTableView(parent);\n        editor->setAlternatingRowColors(false);\n        editor->setSelectionBehavior(QAbstractItemView::SelectItems);\n        editor->setSelectionMode(QAbstractItemView::ContiguousSelection);\n        editor->setSortingEnabled(false);\n        editor->setItemsDraggable(false);\n\n        QScrollArea* scrollingWidget = new QScrollArea(parent);\n        scrollingWidget->setWidgetResizable(true);\n        scrollingWidget->setWidget(editor);\n        scrollingWidget->parent()->installEventFilter(editor);\n\n        return scrollingWidget;\n    }\n    else\n    {\n        return QStyledItemDelegate::createEditor(parent, option, index);\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: VendorExtensionsDelegate::setEditorData()\n//-----------------------------------------------------------------------------\nvoid VendorExtensionsDelegate::setEditorData(QWidget* editor, QModelIndex const& index) const\n{\n    if (index.column() == VendorExtensionColumns::NAMESPACE || index.column() == VendorExtensionColumns::NAME ||\n        index.column() == VendorExtensionColumns::VALUE || index.column() == VendorExtensionColumns::DESCRIPTION)\n    {\n        QLineEdit* edit = qobject_cast<QLineEdit*>(editor);\n        Q_ASSERT(edit);\n\n        const QString text = index.data(Qt::DisplayRole).toString();\n        edit->setText(text);\n    }\n    else if (index.column() == VendorExtensionColumns::ATTRIBUTES)\n    {\n        EditableTableView* view = dynamic_cast<EditableTableView*>(dynamic_cast<QScrollArea*>(editor)->widget());\n\n        QVariant genericVariant = index.model()->data(index, VendorExtensionsGeneral::getGenericExtensionRole);\n        if (genericVariant.canConvert<GenericVendorExtension*>())\n        {\n            GenericVendorExtension* genericExtension = genericVariant.value<GenericVendorExtension*>();\n            VendorExtensionAttributesModel* attributesModel = new VendorExtensionAttributesModel(genericExtension);\n\n            view->setModel(attributesModel);\n\n            connect(attributesModel, SIGNAL(contentChanged()),\n                this, SIGNAL(contentChanged()), Qt::UniqueConnection);\n            connect(attributesModel, SIGNAL(dataChanged(const QModelIndex&, const QModelIndex&)),\n                this, SIGNAL(contentChanged()), Qt::UniqueConnection);\n\n            connect(view, SIGNAL(addItem(const QModelIndex&)),\n                attributesModel, SLOT(onAddItem(const QModelIndex&)), Qt::UniqueConnection);\n            connect(view, SIGNAL(removeItem(const QModelIndex&)),\n                attributesModel, SLOT(onRemoveItem(const QModelIndex&)), Qt::UniqueConnection);\n        }\n    }\n    else\n    {\n        QStyledItemDelegate::setEditorData(editor, index);\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: VendorExtensionsDelegate::setModelData()\n//-----------------------------------------------------------------------------\nvoid VendorExtensionsDelegate::setModelData(QWidget* editor, QAbstractItemModel* model, QModelIndex const& index)\n    const\n{\n    if (index.column() == VendorExtensionColumns::NAMESPACE || index.column() == VendorExtensionColumns::NAME ||\n        index.column() == VendorExtensionColumns::VALUE || index.column() == VendorExtensionColumns::DESCRIPTION)\n    {\n        QLineEdit* edit = qobject_cast<QLineEdit*>(editor);\n        Q_ASSERT(edit);\n\n        QString text = edit->text();\n        model->setData(index, text, Qt::EditRole);\n    }\n    else if (index.column() == VendorExtensionColumns::ATTRIBUTES)\n    {\n        EditableTableView* view = dynamic_cast<EditableTableView*>(dynamic_cast<QScrollArea*>(editor)->widget());\n        VendorExtensionAttributesModel* attributeModel =\n            qobject_cast<VendorExtensionAttributesModel*>(view->model());\n\n        QVector<QPair<QString, QString> > newAttributes = attributeModel->getAttributes();\n        QVariant data = QVariant::fromValue(newAttributes);\n\n        model->setData(index, data, Qt::EditRole);\n    }\n    else\n    {\n        QStyledItemDelegate::setModelData(editor, model, index);\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: memorymapsdelegate::paint()\n//-----------------------------------------------------------------------------\nvoid VendorExtensionsDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option,\n    const QModelIndex &index) const\n{\n    QStyledItemDelegate::paint(painter, option, index);\n\n    QPen oldPen = painter->pen();\n    QPen newPen(Qt::lightGray);\n    newPen.setWidth(1);\n    painter->setPen(newPen);\n\n    if (index.column() != VendorExtensionColumns::DESCRIPTION)\n    {\n        painter->drawLine(option.rect.topRight(), option.rect.bottomRight());\n    }\n\n    painter->setPen(oldPen);\n}\n\n\n//-----------------------------------------------------------------------------\n// Function: ParameterDelegate::updateEditorGeometry()\n//-----------------------------------------------------------------------------\nvoid VendorExtensionsDelegate::updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option,\n    const QModelIndex &index) const\n{\n    QStyledItemDelegate::updateEditorGeometry(editor, option, index);\n\n    if (index.column() == VendorExtensionColumns::ATTRIBUTES)\n    {\n        repositionAndResizeEditor(editor, option);\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: VendorExtensionsDelegate::repositionAndResizeEditor()\n//-----------------------------------------------------------------------------\nvoid VendorExtensionsDelegate::repositionAndResizeEditor(QWidget* editor, QStyleOptionViewItem const& option) const\n{\n    int editorMinimumSize = 400;\n    editor->setFixedWidth(180);\n\n    const int PARENT_HEIGHT = editor->parentWidget()->height();\n    const int AVAILABLE_HEIGHT_BELOW = PARENT_HEIGHT - option.rect.top();\n\n    if (AVAILABLE_HEIGHT_BELOW > editorMinimumSize)\n    {\n        editor->move(option.rect.topLeft());\n    }\n    else\n    {\n        int editorNewY = PARENT_HEIGHT - editorMinimumSize;\n        if (editorNewY <= 0)\n        {\n            editorNewY = 0;\n        }\n\n        editor->move(option.rect.left(), editorNewY);\n    }\n\n    if (editorMinimumSize > PARENT_HEIGHT)\n    {\n        editor->setFixedHeight(PARENT_HEIGHT);\n    }\n    else\n    {\n        editor->setFixedHeight(editorMinimumSize);\n    }\n}"
  },
  {
    "path": "editors/common/VendorExtensionEditor/VendorExtensionsDelegate.h",
    "content": "//-----------------------------------------------------------------------------\n// File: VendorExtensionsDelegate.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 16.01.2019\n//\n// Description:\n// The delegate to provide editors to add/remove/edit the vendor extensions.\n//-----------------------------------------------------------------------------\n\n#ifndef VENDOREXTENSIONSDELEGATE_H\n#define VENDOREXTENSIONSDELEGATE_H\n\n#include <QStyledItemDelegate>\n#include <QSharedPointer>\n\n//-----------------------------------------------------------------------------\n//! The delegate to provide editors to add/remove/edit the vendor extensions.\n//-----------------------------------------------------------------------------\nclass VendorExtensionsDelegate : public QStyledItemDelegate\n{\n\tQ_OBJECT\n\npublic:\n\n\t/*!\n     *  The constructor\n\t *\n\t *    @param [in] parent      The owner of the delegate.\n\t */\n    VendorExtensionsDelegate(QObject *parent);\n\t\n\t/*!\n     *  The destructor.\n     */\n    virtual ~VendorExtensionsDelegate();\n\n\t/*!\n     *  Create a new editor for the given item\n\t *\n\t *    @param [in] parent  Owner for the editor.\n\t *    @param [in] option  Contains options for the editor.\n\t *    @param [in] index   Model index identifying the item.\n\t *\n\t *    @return The editor to be used to edit the item.\n     */\n\tvirtual QWidget* createEditor(QWidget* parent, QStyleOptionViewItem const& option, QModelIndex const& index)\n        const;\n\n\t/*!\n     *  Set the data for the editor.\n\t *\n\t *    @param [in] editor  The editor where the data is to be set.\n\t *    @param [in] index   Model index identifying the item that's data is to be set.\n     */\n\tvirtual void setEditorData(QWidget* editor, QModelIndex const& index) const;\n\n\t/*!\n     *  Save the data from the editor to the model.\n\t *\n\t *    @param [in] editor  The editor that contains the data to store.\n\t *    @param [in] model   Model that contains the data structure where data is to be saved to.\n\t *    @param [in] index   Model index identifying the item that's data is to be saved.\n     */\n\tvirtual void setModelData(QWidget* editor, QAbstractItemModel* model, QModelIndex const& index) const;\n\n    /*!\n     *  Paint the vendor extension rows.\n     *\n     *    @param [in] painter     The used painter.\n     *    @param [in] option      Available style options.\n     *    @param [in] index       The current index.\n     */\n    virtual void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const;\n\n    /*!\n     *  Updates the editor geometry.\n     *\n     *    @param [in] editor  The editor being updated.\n     *    @param [in] option  The options used to update the editor.\n     *    @param [in] index   The model index being edited.\n     */\n    virtual void updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option,\n        const QModelIndex &index) const;\n\n    //! No copying. No assignment.\n    VendorExtensionsDelegate(const VendorExtensionsDelegate& other) = delete;\n    VendorExtensionsDelegate& operator=(const VendorExtensionsDelegate& other) = delete;\n\nsignals:\n\n    /*!\n     *  Informs a change in the edited document.\n     */\n    void contentChanged();\n\nprivate:\n\t\n    /*!\n     *  Repositions the editor if there is not enough space under the default position. The editor is then resized\n     *  to use the available space.\n     *\n     *    @param [in] editor  The editor to reposition.\n     *    @param [in] option  The style options for the editor.\n     *    @param [in] index   The current index.\n     */\n    void repositionAndResizeEditor(QWidget* editor, QStyleOptionViewItem const& option) const;\n};\n\n#endif // VENDOREXTENSIONSDELEGATE_H\n"
  },
  {
    "path": "editors/common/VendorExtensionEditor/VendorExtensionsEditor.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: VendorExtensionsEditor.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Antti Kamppi\n// Date: 10.10.2011\n//\n// Description:\n// Editor to display/edit vendor extensions.\n//-----------------------------------------------------------------------------\n\n#include \"VendorExtensionsEditor.h\"\n\n#include <common/views/EditableTreeView/EditableTreeView.h>\n#include <common/widgets/tabDocument/TabDocument.h>\n\n#include <editors/common/VendorExtensionEditor/VendorExtensionsModel.h>\n#include <editors/common/VendorExtensionEditor/VendorExtensionsFilter.h>\n#include <editors/common/VendorExtensionEditor/VendorExtensionsDelegate.h>\n#include <editors/common/VendorExtensionEditor/VendorExtensionColumns.h>\n\n#include <IPXACTmodels/common/Extendable.h>\n\n#include <QSortFilterProxyModel>\n#include <QStyledItemDelegate>\n#include <QVBoxLayout>\n#include <QHeaderView>\n\n//-----------------------------------------------------------------------------\n// Function: VendorExtensionsEditor::VendorExtensionsEditor()\n//-----------------------------------------------------------------------------\nVendorExtensionsEditor::VendorExtensionsEditor(QWidget *parent) :\nQWidget(parent),\nextensionsView_(new EditableTreeView(true, QString(tr(\"Add vendor extension\")), QString(tr(\"Add child element\")),\n    QString(tr(\"Remove row\")), QString(tr(\"Remove all child elements\")), this)),\nextensionsModel_(new VendorExtensionsModel(this)),\nsummaryLabel_(new QLabel(this))\n{\n    extensionsView_->setSortingEnabled(false);\n\n    extensionsView_->setSelectionMode(QAbstractItemView::ContiguousSelection);\n\n    QVBoxLayout* layout = new QVBoxLayout(this);\n    layout->addWidget(summaryLabel_, 0, Qt::AlignCenter);\n    layout->addWidget(extensionsView_);\n\n    VendorExtensionsDelegate* extensionDelegate = new VendorExtensionsDelegate(this);\n    extensionsView_->setItemDelegate(extensionDelegate);\n\n    VendorExtensionsFilter* newFilter(new VendorExtensionsFilter(this));\n    newFilter->setSourceModel(extensionsModel_);\n    extensionsView_->setModel(newFilter);\n\n    connect(extensionsView_, SIGNAL(addItems(QModelIndexList const&)),\n        newFilter, SLOT(onAddItem(QModelIndexList const&)), Qt::UniqueConnection);\n    connect(extensionsView_, SIGNAL(addSubItem(QModelIndexList const&)),\n        newFilter, SLOT(onAddSubItem(QModelIndexList const&)), Qt::UniqueConnection);\n    connect(extensionsView_, SIGNAL(removeSelectedItems(QModelIndexList const&)),\n        newFilter, SLOT(onRemoveSelectedRows(QModelIndexList const&)), Qt::UniqueConnection);\n    connect(extensionsView_, SIGNAL(removeAllSubItems(QModelIndexList const&)),\n        newFilter, SLOT(onRemoveAllSubItemsFromIndexes(QModelIndexList const&)), Qt::UniqueConnection);\n\n    connect(newFilter, SIGNAL(addItem(QModelIndex const&)),\n        extensionsModel_, SLOT(onAddItem(QModelIndex const&)), Qt::UniqueConnection);\n    connect(newFilter, SIGNAL(addSubItem(QModelIndex const&)),\n        extensionsModel_, SLOT(onAddSubItem(QModelIndex const&)), Qt::UniqueConnection);\n    connect(newFilter, SIGNAL(removeItem(QModelIndex const&)),\n        extensionsModel_, SLOT(onRemoveItem(QModelIndex const&)), Qt::UniqueConnection);\n    connect(newFilter, SIGNAL(removeAllSubItemsFromIndex(QModelIndex const&)),\n        extensionsModel_, SLOT(onRemoveAllSubItems(QModelIndex const&)), Qt::UniqueConnection);\n\n    connect(extensionsModel_, SIGNAL(contentChanged()), this, SIGNAL(contentChanged()), Qt::UniqueConnection);\n\n    connect(extensionDelegate, SIGNAL(contentChanged()), this, SIGNAL(contentChanged()), Qt::UniqueConnection);\n\n    extensionsView_->header()->setStretchLastSection(true);\n\n\tsetDisabled(true);\n}\n\n//-----------------------------------------------------------------------------\n// Function: VendorExtensionsEditor::setLocked()\n//-----------------------------------------------------------------------------\nvoid VendorExtensionsEditor::setLocked(bool locked)\n{\n    setDisabled(locked);\n}\n\n//-----------------------------------------------------------------------------\n// Function: VendorExtensionsEditor::setContext()\n//-----------------------------------------------------------------------------\nvoid VendorExtensionsEditor::setContext(TabDocument* doc)\n{\n    setLocked(doc->isProtected());\n\n    disconnect(this, SIGNAL(contentChanged()), 0, 0);\n    connect(this, SIGNAL(contentChanged()), doc, SIGNAL(contentChanged()), Qt::UniqueConnection);\n}\n\n//-----------------------------------------------------------------------------\n// Function: VendorExtensionsEditor::clear()\n//-----------------------------------------------------------------------------\nvoid VendorExtensionsEditor::clear()\n{\n    disconnect(this, SIGNAL(contentChanged()), 0, 0);\n\n    extensionsModel_->clear();\n\n   // parentWidget()->setMaximumHeight(20);    \n}\n\n//-----------------------------------------------------------------------------\n// Function: VendorExtensionsEditor::changeVendorExtensions()\n//-----------------------------------------------------------------------------\nvoid VendorExtensionsEditor::changeVendorExtensions(QString const& containingID,\n    QSharedPointer<Extendable> extensionItem)\n{\n    //parentWidget()->raise();\n\n    summaryLabel_->setText(containingID);\n    summaryLabel_->setAlignment(Qt::AlignCenter);\n\n    extensionsModel_->setVendorExtensions(extensionItem->getVendorExtensions());\n\n    //parentWidget()->setMaximumHeight(QWIDGETSIZE_MAX);\n\n    for (int i = 0; i < VendorExtensionColumns::COLUMN_COUNT; ++i)\n    {\n        extensionsView_->resizeColumnToContents(i);\n    }\n}\n"
  },
  {
    "path": "editors/common/VendorExtensionEditor/VendorExtensionsEditor.h",
    "content": "//-----------------------------------------------------------------------------\n// File: VendorExtensionsEditor.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Esko Pekkarinen\n// Date: 05.12.2018\n//\n// Description:\n// Editor to display/edit vendor extensions.\n//-----------------------------------------------------------------------------\n\n#ifndef VENDOREXTENSIONSEDITOR_H\n#define VENDOREXTENSIONSEDITOR_H\n\n#include <QList>\n#include <QSharedPointer>\n#include <QWidget>\n#include <QLabel>\n\nclass EditableTreeView;\nclass VendorExtensionsModel;\nclass VendorExtension;\nclass TabDocument;\nclass Extendable;\n\n//-----------------------------------------------------------------------------\n//! Editor to display/edit vendor extensions.\n//-----------------------------------------------------------------------------\nclass VendorExtensionsEditor : public QWidget\n{\n    Q_OBJECT\n\npublic:\n\n\t/*!\n     *  The constructor.\n\t *\n\t *    @param [in] parent      The owner of this widget.     \n\t */\n\tVendorExtensionsEditor(QWidget *parent);\n\t\n\t//! The destructor.\n\tvirtual ~VendorExtensionsEditor() = default;\n\n    //! No copying.\n    VendorExtensionsEditor(const VendorExtensionsEditor& other) = delete;\n\n    //! No assignment.\n    VendorExtensionsEditor& operator=(const VendorExtensionsEditor& other) = delete;\n\n    /*!\n     * Locks/Unlocks the editor.\n     *\n     *    @param [in] locked  The lock state to set.\n     */\n    void setLocked(bool locked);\n    \n    /*!\n     * Set the context for the editor.\n     *\n     *    @param [in] doc  The document widget whose vendor extensions are being edited.     \n     */\n     void setContext(TabDocument* doc);\n\nsignals:\n\n    //! Informs of a content change in the editor.\n    void contentChanged();\n\npublic slots:\n\n\t//! Clear the editor so no extensions are shown\n    void clear();\n\n    /*!\n     *  Change the vendor extensions of the vendor extensions editor.\n     *\n     *    @param [in] containingID    ID for the vendor extensions editor.\n     *    @param [in] extensionItem   The item containing the selected vendor extensions.\n     */\n    void changeVendorExtensions(QString const& containingID, QSharedPointer<Extendable> extensionItem);\n\nprivate:\n\n    //-----------------------------------------------------------------------------\n    // Data.\n    //-----------------------------------------------------------------------------\n\n    //! The view for the vendor extensions table.\n    EditableTreeView* extensionsView_;\n\n    //! The model for the vendor extensions.\n    VendorExtensionsModel* extensionsModel_;\n\n    //! Holds the ID for the editor.\n    QLabel* summaryLabel_;\n};\n\n#endif // VENDOREXTENSIONSEDITOR_H\n"
  },
  {
    "path": "editors/common/VendorExtensionEditor/VendorExtensionsFilter.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: VendorExtensionsFilter.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 11.03.2019\n//\n// Description:\n// Sorting proxy model for vendor extensions editor.\n//-----------------------------------------------------------------------------\n\n#include \"VendorExtensionsFilter.h\"\n\n#include <editors/common/VendorExtensionEditor/VendorExtensionColumns.h>\n\n#include <IPXACTmodels/common/VendorExtension.h>\n\n//-----------------------------------------------------------------------------\n// Function: VendorExtensionsFilter::VendorExtensionsFilter()\n//-----------------------------------------------------------------------------\nVendorExtensionsFilter::VendorExtensionsFilter(QObject* parent) :\nEditableTreeSortFilter(parent)\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: VendorExtensionsFilter::filterAcceptsRow()\n//-----------------------------------------------------------------------------\nbool VendorExtensionsFilter::filterAcceptsRow(int source_row, const QModelIndex& source_parent) const\n{\n    QModelIndex nameIndex = sourceModel()->index(source_row, VendorExtensionColumns::NAME, source_parent);\n    QModelIndex nameSpaceIndex =\n        sourceModel()->index(source_row, VendorExtensionColumns::NAMESPACE, source_parent);\n\n    QString itemName = sourceModel()->data(nameIndex).toString();\n    QString itemSpace = sourceModel()->data(nameSpaceIndex).toString();\n\n    if (itemName.contains(\"Description\", Qt::CaseInsensitive) ||\n        itemSpace.startsWith(\"kactus2\", Qt::CaseInsensitive))\n    {\n        return false;\n    }\n    else\n    {\n        return EditableTreeSortFilter::filterAcceptsRow(source_row, source_parent);\n    }\n}\n"
  },
  {
    "path": "editors/common/VendorExtensionEditor/VendorExtensionsFilter.h",
    "content": "//-----------------------------------------------------------------------------\n// File: VendorExtensionsFilter.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 11.03.2019\n//\n// Description:\n// Sorting proxy model for vendor extensions editor.\n//-----------------------------------------------------------------------------\n\n#ifndef VENDOREXTENSIONSFILTER_H\n#define VENDOREXTENSIONSFILTER_H\n\n#include <common/views/EditableTreeView/EditableTreeSortFilter.h>\n\n#include <QSortFilterProxyModel>\n\n//-----------------------------------------------------------------------------\n//! Sorting proxy model for vendor extensions editor.\n//-----------------------------------------------------------------------------\nclass VendorExtensionsFilter : public EditableTreeSortFilter\n{\n    Q_OBJECT\n\npublic:\n\n\t /*!\n      *  Constructor.\n      *\n      *    @param [in] parent          The parent object.\n      */\n    VendorExtensionsFilter(QObject* parent = 0);\n\n\t /*!\n      *  Destructor.\n      */\n    virtual ~VendorExtensionsFilter() = default;\n\n    // No copying. No assignments.\n    VendorExtensionsFilter(VendorExtensionsFilter const& rhs) = delete;\n    VendorExtensionsFilter& operator=(VendorExtensionsFilter const& rhs) = delete;\n\nprotected:\n\n    /*!\n\t *  Implementation of the row filtering.\n\t *\n\t *    @param [in] source_row      The row to check for filtering.\n     *    @param [in] source_parent   The parent index of the row.\n     *\n     *    @return True, if the row passes the filters, otherwise false.\n\t */\n    virtual bool filterAcceptsRow(int source_row, const QModelIndex & source_parent) const override;\n};\n\n#endif // VENDOREXTENSIONSFILTER_H"
  },
  {
    "path": "editors/common/VendorExtensionEditor/VendorExtensionsGeneral.h",
    "content": "//-----------------------------------------------------------------------------\n// File: VendorExtensionsGeneral.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 21.03.2019\n//\n// Description:\n// General enumerations for vendor extensions editor.\n//-----------------------------------------------------------------------------\n\n#include <QVector>\n#include <QPair>\n#include <QString>\n\n#include <QMetaType>\n\nnamespace VendorExtensionsGeneral\n{\n    //! The different user roles for data.\n    enum vendorExtensionEditorRoles\n    {\n        getGenericExtensionRole = Qt::UserRole  //! Gets the generic vendor extension.\n    };\n}\n"
  },
  {
    "path": "editors/common/VendorExtensionEditor/VendorExtensionsModel.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: VendorExtensionsModel.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Esko Pekkarinen\n// Date: 05.12.2018\n//\n// Description:\n// Model class to manage the vendor extension values being edited.\n//-----------------------------------------------------------------------------\n\n#include \"VendorExtensionsModel.h\"\n\n#include <common/KactusColors.h>\n\n#include <editors/common/VendorExtensionEditor/VendorExtensionsGeneral.h>\n#include <editors/common/VendorExtensionEditor/VendorExtensionColumns.h>\n\n#include <IPXACTmodels/common/VendorExtension.h>\n#include <IPXACTmodels/common/GenericVendorExtension.h>\n\n//-----------------------------------------------------------------------------\n// Function: VendorExtensionsModel::VendorExtensionsModel()\n//-----------------------------------------------------------------------------\nVendorExtensionsModel::VendorExtensionsModel(QObject *parent) :\nQAbstractItemModel(parent),\nvendorExtensions_(nullptr),\nemptyExtension_()\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: VendorExtensionsModel::setVendorExtensions()\n//-----------------------------------------------------------------------------\nvoid VendorExtensionsModel::setVendorExtensions(\n    QSharedPointer<QList<QSharedPointer<VendorExtension> > > extensions)\n{\n    beginResetModel();\n    vendorExtensions_ = extensions;\n    endResetModel();\n}\n\n//-----------------------------------------------------------------------------\n// Function: VendorExtensionsModel::clear()\n//-----------------------------------------------------------------------------\nvoid VendorExtensionsModel::clear() \n{\n\tbeginResetModel();\n    vendorExtensions_.clear();\n\tendResetModel();\n}\n\n//-----------------------------------------------------------------------------\n// Function: VendorExtensionsModel::rowCount()\n//-----------------------------------------------------------------------------\nint VendorExtensionsModel::rowCount(QModelIndex const& parent) const \n{\n    if (vendorExtensions_.isNull() == false)\n    {\n        if (!parent.isValid())\n        {\n            return vendorExtensions_->size();\n        }\n        else\n        {\n            VendorExtension* genericParent = static_cast<VendorExtension*>(parent.internalPointer());\n            GenericVendorExtension* genericExtension = dynamic_cast<GenericVendorExtension*>(genericParent);\n\n            if (genericExtension)\n            {\n                return genericExtension->getChildExtensions().count();\n            }\n        }\n    }\n\n    return 0;\n}\n\n//-----------------------------------------------------------------------------\n// Function: VendorExtensionsModel::columnCount()\n//-----------------------------------------------------------------------------\nint VendorExtensionsModel::columnCount(QModelIndex const& /*parent*/) const \n{\n    return VendorExtensionColumns::COLUMN_COUNT;\n}\n\n//-----------------------------------------------------------------------------\n// Function: VendorExtensionsModel::data()\n//-----------------------------------------------------------------------------\nQVariant VendorExtensionsModel::data(QModelIndex const& index, int role) const \n{\n    if (!isIndexValid(index))\n    {\n        return QVariant();\n    }\n    \n    if (role == VendorExtensionsGeneral::getGenericExtensionRole)\n    {\n        return QVariant::fromValue(getExtensionForIndex(index));\n    }\n    else if (role == Qt::ForegroundRole)\n    {\n        if (indexIsEditable(index))\n        {\n            return KactusColors::REGULAR_TEXT;\n        }        \n        else\n        {\n            return KactusColors::DISABLED_TEXT;\n        }\n    }\n    else if (role == Qt::DisplayRole || role == Qt::ToolTipRole)\n    {\n        return valueForIndex(index);\n\t}\n    else if (role == Qt::BackgroundRole)\n    {\n        if (mandatoryColumn(index))\n        {\n            return KactusColors::MANDATORY_FIELD;\n        }\n        else\n        {\n            return KactusColors::REGULAR_FIELD;\n        }\n    }\n\n    return QVariant();\n}\n\n//-----------------------------------------------------------------------------\n// Function: VendorExtensionsModel::valueForIndex()\n//-----------------------------------------------------------------------------\nQVariant VendorExtensionsModel::valueForIndex(QModelIndex const& index) const\n{\n    VendorExtension* extension = static_cast<VendorExtension*>(index.internalPointer());\n    GenericVendorExtension* genericExtension = dynamic_cast<GenericVendorExtension*>(extension);\n\n    if (index.column() == VendorExtensionColumns::NAMESPACE)\n    {\n        if (!genericExtension)\n        {\n            return extension->type().split(\":\").first();\n        }\n        else\n        {\n            return genericExtension->nameSpace();\n        }\n    }\n    else if (index.column() == VendorExtensionColumns::NAME)\n    {\n        if (!genericExtension)\n        {\n            return extension->type().split(\":\").last();\n        }\n        else\n        {\n            return genericExtension->name();\n        }\n    }\n    else if (index.column() == VendorExtensionColumns::ATTRIBUTES)\n    {\n        if (genericExtension)\n        {\n            QStringList typeList;\n            for (auto attribute : genericExtension->getAttributes())\n            {\n                typeList.append(attribute.first);\n            }\n\n            return typeList.join(\",\");\n        }\n    }\n    else if (index.column() == VendorExtensionColumns::VALUE)\n    {\n        if (!genericExtension)\n        {\n            return QStringLiteral(\"N/A\");\n        }\n        else\n        {\n            return genericExtension->value();\n        }\n    }\n    else if (index.column() == VendorExtensionColumns::DESCRIPTION && genericExtension)\n    {\n        return genericExtension->getDescription();\n    }\n\n    return QVariant();\n}\n\n//-----------------------------------------------------------------------------\n// Function: VendorExtensionsModel::mandatoryColumn()\n//-----------------------------------------------------------------------------\nbool VendorExtensionsModel::mandatoryColumn(QModelIndex const& index) const\n{\n    return index.column() == VendorExtensionColumns::NAMESPACE || index.column() == VendorExtensionColumns::NAME;\n}\n\n//-----------------------------------------------------------------------------\n// Function: VendorExtensionsModel::getExtensionForIndex()\n//-----------------------------------------------------------------------------\nGenericVendorExtension* VendorExtensionsModel::getExtensionForIndex(QModelIndex const& index) const\n{\n    VendorExtension* indexExtension = static_cast<VendorExtension*>(index.internalPointer());\n    return dynamic_cast<GenericVendorExtension*>(indexExtension);\n}\n\n//-----------------------------------------------------------------------------\n// Function: VendorExtensionsModel::headerData()\n//-----------------------------------------------------------------------------\nQVariant VendorExtensionsModel::headerData(int section, Qt::Orientation orientation, int role) const \n{\n\tif (role == Qt::DisplayRole && orientation == Qt::Horizontal) \n    {\n        if (section == VendorExtensionColumns::NAMESPACE)\n        {\n            return tr(\"Namespace\");\n        }\n        else if (section == VendorExtensionColumns::NAME)\n        {\n            return tr(\"Name\");\n        }\n        else if (section == VendorExtensionColumns::ATTRIBUTES)\n        {\n            return tr(\"Attributes\");\n        }\n        else if (section == VendorExtensionColumns::VALUE)\n        {            \n            return tr(\"Value\");\n        }\n        else if (section == VendorExtensionColumns::DESCRIPTION)\n        {\n            return tr(\"Description\");\n        }\n    }\n\n    return QVariant();\n}\n\n//-----------------------------------------------------------------------------\n// Function: VendorExtensionsModel::setData()\n//-----------------------------------------------------------------------------\nbool VendorExtensionsModel::setData(QModelIndex const& index, QVariant const& value, int role) \n{\n    if (!isIndexValid(index))\n    {\n        return false;\n    }\n    \n    if (role == Qt::EditRole && indexIsEditable(index))\n    {\n        GenericVendorExtension* genericExtension = getExtensionForIndex(index);\n        if (genericExtension && index.column() == VendorExtensionColumns::NAMESPACE && !value.toString().isEmpty())\n        {\n            genericExtension->setNameSpace(value.toString());\n        }\n        else if (genericExtension &&\n            index.column() == VendorExtensionColumns::NAME && value.toString().isEmpty() == false)\n        {\n            genericExtension->setName(value.toString());\n        }\n        else if (genericExtension && index.column() == VendorExtensionColumns::ATTRIBUTES)\n        {\n            QVector<QPair<QString, QString> > newAttributes = value.value<QVector<QPair<QString, QString> > >();\n            genericExtension->setNewAttributes(newAttributes);\n        }\n        else if (genericExtension && index.column() == VendorExtensionColumns::VALUE)\n        {\n            genericExtension->setValue(value.toString());\n        }\n        else if (genericExtension && index.column() == VendorExtensionColumns::DESCRIPTION)\n        {\n            genericExtension->setDescription(value.toString());\n        }\n        else\n        {\n            return false;\n        }\n\n        emit dataChanged(index, index);\n        emit contentChanged();\n        return true;\n    }\n\n    return false;\n}\n\n//-----------------------------------------------------------------------------\n// Function: VendorExtensionsModel::flags()\n//-----------------------------------------------------------------------------\nQt::ItemFlags VendorExtensionsModel::flags(QModelIndex const& index) const \n{\n\tif (!index.isValid())\n    {\n\t\treturn Qt::NoItemFlags;\n    }\n\n    if (indexIsEditable(index))\n    {\n        return Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsEditable;\n    }\n \n    return Qt::ItemIsSelectable | Qt::ItemIsEnabled;\n}\n\n//-----------------------------------------------------------------------------\n// Function: VendorExtensionsModel::indexIsEditable()\n//-----------------------------------------------------------------------------\nbool VendorExtensionsModel::indexIsEditable(QModelIndex const& index) const\n{\n    GenericVendorExtension* genericExtension = getExtensionForIndex(index);\n    if (genericExtension)\n    {\n        return true;\n    }\n    else\n    {\n        return false;\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: VendorExtensionsModel::onAddItem()\n//-----------------------------------------------------------------------------\nvoid VendorExtensionsModel::onAddItem(QModelIndex const& index)\n{\n    if (vendorExtensions_.isNull())\n    {\n        return;\n    }\n\n    QString newExtensionName = QStringLiteral(\"unnamed\");\n\n    QSharedPointer<GenericVendorExtension> newExtension(new GenericVendorExtension());\n    newExtension->setNameSpace(newExtensionName);\n    newExtension->setName(newExtensionName);\n\n    int row = vendorExtensions_->size();\n    if (isIndexValid(index))\n    {\n        row = index.row();\n    }\n\n    beginInsertRows(QModelIndex(), row, row);\n    vendorExtensions_->insert(row, newExtension);\n    endInsertRows();\n\n    emit contentChanged();\n}\n\n//-----------------------------------------------------------------------------\n// Function: VendorExtensionsModel::onAddSubItem()\n//-----------------------------------------------------------------------------\nvoid VendorExtensionsModel::onAddSubItem(QModelIndex const& index)\n{\n    if (vendorExtensions_.isNull() || !indexIsEditable(index))\n    {\n        return;\n    }\n\n    GenericVendorExtension* indexedExtension = getExtensionForIndex(index);\n    if (indexedExtension)\n    {\n        GenericVendorExtension* newChildExtension(new GenericVendorExtension());\n        newChildExtension->setNameSpace(indexedExtension->nameSpace());\n        newChildExtension->setName(QStringLiteral(\"unnamed\"));\n        newChildExtension->setParent(indexedExtension);\n        int childExtensionCount = indexedExtension->getChildExtensions().count();\n        \n        beginInsertRows(index, childExtensionCount, childExtensionCount);\n        indexedExtension->getChildExtensions().append(newChildExtension);\n        endInsertRows();\n\n        emit contentChanged();\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: VendorExtensionsModel::onRemoveItem()\n//-----------------------------------------------------------------------------\nvoid VendorExtensionsModel::onRemoveItem(QModelIndex const& index)\n{\n    if (!index.isValid() || !indexIsEditable(index))\n    {\n        return;\n    }\n\n    QModelIndex parentIndex = index.parent();\n    if (parentIndex.isValid())\n    {\n        GenericVendorExtension* genericParent = getExtensionForIndex(parentIndex);\n        if (genericParent)\n        {\n            beginRemoveRows(parentIndex, index.row(), index.row());\n            genericParent->getChildExtensions().removeAt(index.row());\n            endRemoveRows();\n        }\n    }\n    else\n    {\n        beginRemoveRows(QModelIndex(), index.row(), index.row());\n        vendorExtensions_->removeAt(index.row());\n        endRemoveRows();\n    }\n\n    emit contentChanged();\n}\n\n//-----------------------------------------------------------------------------\n// Function: VendorExtensionsModel::onRemoveAllSubItems()\n//-----------------------------------------------------------------------------\nvoid VendorExtensionsModel::onRemoveAllSubItems(QModelIndex const& index)\n{\n    if (vendorExtensions_.isNull() || !indexIsEditable(index))\n    {\n        return;\n    }\n\n    GenericVendorExtension* genericExtension = getExtensionForIndex(index);\n    if (genericExtension)\n    {\n        int startIndex = 0;\n        int endIndex = genericExtension->getChildExtensions().count() - 1;\n\n        if (genericExtension->hasDescription())\n        {\n            int descriptionIndex = genericExtension->getDescriptionIndex();\n            int secondStartIndex = -1;\n            int secondEndIndex = -1;\n\n            if (descriptionIndex == startIndex)\n            {\n                startIndex++;\n            }\n            else if (descriptionIndex == endIndex)\n            {\n                endIndex--;\n            }\n            else\n            {\n                endIndex = descriptionIndex - 1;\n                secondStartIndex = descriptionIndex + 1;\n                secondEndIndex = genericExtension->getChildExtensions().count() - 1;\n\n                beginRemoveRows(index, secondStartIndex, secondEndIndex);\n                genericExtension->removeIndexedChildExtensions(secondStartIndex, secondEndIndex);\n                endRemoveRows();\n\n                emit contentChanged();\n            }\n        }\n        \n        if (startIndex <= endIndex)\n        {\n            beginRemoveRows(index, startIndex, endIndex);\n            genericExtension->removeIndexedChildExtensions(startIndex, endIndex);\n            endRemoveRows();\n\n            emit contentChanged();\n        }\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: VendorExtensionsModel::index()\n//-----------------------------------------------------------------------------\nQModelIndex VendorExtensionsModel::index(int row, int column, const QModelIndex& parent) const\n{\n    if (!vendorExtensions_.isNull())\n    {\n        if (parent.isValid())\n        {\n            VendorExtension* parentExtension = static_cast<VendorExtension*>(parent.internalPointer());\n            GenericVendorExtension* genericParent = dynamic_cast<GenericVendorExtension*>(parentExtension);\n            if (genericParent)\n            {\n                GenericVendorExtension* indexData = genericParent->getChildExtensions()[row];\n                return createIndex(row, column, indexData);\n            }\n        }\n        else\n        {\n            QSharedPointer<VendorExtension> extension = vendorExtensions_->at(row);\n            QSharedPointer<GenericVendorExtension> generic = extension.dynamicCast<GenericVendorExtension>();\n            if (generic)\n            {\n                return createIndex(row, column, generic.data());\n            }\n            else\n            {\n                return createIndex(row, column, extension.data());\n            }\n        }\n    }\n\n    return createIndex(row, column, nullptr);\n}\n\n//-----------------------------------------------------------------------------\n// Function: VendorExtensionsModel::parent()\n//-----------------------------------------------------------------------------\nQModelIndex VendorExtensionsModel::parent(const QModelIndex& child) const\n{\n    if (!vendorExtensions_.isNull() && child.isValid())\n    {\n        for (auto rootItem : *vendorExtensions_)\n        {\n            if (rootItem.data() == child.internalPointer())\n            {\n                return QModelIndex();\n            }\n        }\n\n        return createParentIndexForChildExtension(child);\n    }\n\n    return QModelIndex();\n}\n\n//-----------------------------------------------------------------------------\n// Function: VendorExtensionsModel::createParentIndexForChildExtension()\n//-----------------------------------------------------------------------------\nQModelIndex VendorExtensionsModel::createParentIndexForChildExtension(QModelIndex const& childIndex) const\n{\n    GenericVendorExtension* childExtension = static_cast<GenericVendorExtension*>(childIndex.internalPointer());\n\n    GenericVendorExtension* parentExtension = childExtension->getParent();\n\n    int parentRow = 0;\n    if (parentExtension->getParent())\n    {\n        parentRow = getRowForItem(parentExtension);\n    }\n    else\n    {\n        parentRow = getRowForRootItem(parentExtension);\n    }\n\n    return createIndex(parentRow, 0, parentExtension);\n}\n\n//-----------------------------------------------------------------------------\n// Function: VendorExtensionsModel::getRowForItem()\n//-----------------------------------------------------------------------------\nint VendorExtensionsModel::getRowForItem(GenericVendorExtension* extensionItem) const\n{\n    GenericVendorExtension* parentItem = extensionItem->getParent();\n    for (int i = 0; i < parentItem->getChildExtensions().count(); ++i)\n    {\n        if (parentItem->getChildExtensions().at(i)->isSame(*extensionItem))\n        {\n            return i;\n        }\n    }\n\n    return -1;\n}\n\n//-----------------------------------------------------------------------------\n// Function: VendorExtensionsModel::getRowForRootItem()\n//-----------------------------------------------------------------------------\nint VendorExtensionsModel::getRowForRootItem(GenericVendorExtension* parentItem) const\n{\n    for (int i = 0; i < vendorExtensions_->size(); ++i)\n    {\n        QSharedPointer<GenericVendorExtension> genericRoot =\n            vendorExtensions_->at(i).dynamicCast<GenericVendorExtension>();\n        if (genericRoot && genericRoot.data() == parentItem)\n        {\n            return i;\n        }\n    }\n\n    return -1;\n}\n\n//-----------------------------------------------------------------------------\n// Function: VendorExtensionsModel::isIndexValid()\n//-----------------------------------------------------------------------------\nbool VendorExtensionsModel::isIndexValid(QModelIndex const& index) const\n{\n    if (index.isValid() && index.row() >= 0 && vendorExtensions_.isNull() == false)\n    {\n        if (index.parent().isValid())\n        {\n            GenericVendorExtension* genericParent =\n                static_cast<GenericVendorExtension*>(index.parent().internalPointer());\n            return index.row() < genericParent->getChildExtensions().count();\n        }\n        else if (index.row() < vendorExtensions_->size())\n        {\n            return true;\n        }\n    }\n\n    return false;\n}\n"
  },
  {
    "path": "editors/common/VendorExtensionEditor/VendorExtensionsModel.h",
    "content": "//-----------------------------------------------------------------------------\n// File: VendorExtensionsModel.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Esko Pekkarinen\n// Date: 05.12.2018\n//\n// Description:\n// Model class to manage the vendor extension values being edited.\n//-----------------------------------------------------------------------------\n\n#ifndef VENDOREXTENSIONSMODEL_H\n#define VENDOREXTENSIONSMODEL_H\n\n#include <IPXACTmodels/common/GenericVendorExtension.h>\n\n#include <QAbstractItemModel>\n#include <QList>\n#include <QString>\n#include <QSharedPointer>\n\nclass VendorExtension;\n\n//-----------------------------------------------------------------------------\n//! Model class to manage the vendor extension values being edited.\n//-----------------------------------------------------------------------------\nclass VendorExtensionsModel : public QAbstractItemModel\n{\n\tQ_OBJECT\n\npublic:\n\n\t/*!\n\t *  The constructor.\n\t *\n\t *    @param [in] parent  The owner of this model.\n\t */\n\tVendorExtensionsModel(QObject *parent);\n\t\n\t/*!\n\t *  The destructor.\n\t */\n\tvirtual ~VendorExtensionsModel() = default;\n\n    //! No copying.\n    VendorExtensionsModel(const VendorExtensionsModel& other) = delete;\n\n    //! No assignment.\n    VendorExtensionsModel& operator=(const VendorExtensionsModel& other) = delete;\n\n\t/*!\n\t *  Set the vendor extensions to edit.\n\t *\n     *    @param [in] extensions The vendor extensions to view/edit.\n\t */\n    void setVendorExtensions(QSharedPointer<QList<QSharedPointer<VendorExtension> > > extensions);\n\n\t/*!\n\t *  Get the number of rows to be displayed.\n\t *\n\t *    @param [in] parent  Identifies the parent, must always be invalid index.\n     *\n     *    @return The number of rows to display.\n\t */\n\tvirtual int rowCount(const QModelIndex& parent = QModelIndex()) const;\n\n\t/*!\n\t *  Get the number of columns to display.\n\t *\n\t *    @param [in] parent  Identifies the parent, must always be invalid index.\n     *\n     *    @return The number of columns to display.\n\t */\n\tvirtual int columnCount(const QModelIndex& parent = QModelIndex()) const;\n\n\t/*!\n\t *  Get the data for specified index in given data role.\n\t *\n\t *    @param [in] index   Identifies the object that's data is wanted.\n\t *    @param [in] role    Identifies the type of data being requested.\n     *\n     *    @return QVariant that contains the requested data.\n\t */\n\tvirtual QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const;\n\n\t/*!\n\t *  Get the data for the given header in the given data role.\n\t *\n\t *    @param [in] section         Identifies the header section.\n\t *    @param [in] orientation     Only horizontal header is supported.\n\t *    @param [in] role            Identifies the type of the data being requested.\n     *\n     *    @return QVariant that contains the requested data.\n\t */\n\tvirtual QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole ) const;\n\n\t/*!\n\t *  Set the data for the specified index.\n\t *\n\t *    @param [in] index   Identifies the object which data is to be saved.\n\t *    @param [in] value   Contains the data to be saved.\n\t *    @param [in] role    Identifies the type of the data to be saved.\n     *\n     *    @return True if data was saved successfully.\n\t */\n\tvirtual bool setData(const QModelIndex& index, const QVariant& value, int role = Qt::EditRole );\n\n\t/*!\n\t *  Get info on what operations are possible for specified item.\n\t *\n\t *    @param [in] index   Identifies the item that's operations are requested.\n     *\n     *    @return Flags containing info on which operations are available for given index.\n\t */\n\tvirtual Qt::ItemFlags flags(const QModelIndex& index) const;\n\n    /*!\n     *  Get the model index of the specified object.\n     *\n     *    @param [in] row     Row number of the object.\n     *    @param [in] column  Column number of the object.\n     *    @param [in] parent  Model index of the parent of the object.\n     *\n     *    @return QModelIndex that identifies the object.\n     */\n    QModelIndex index(int row, int column, const QModelIndex& parent = QModelIndex()) const;\n\n    /*!\n     *  Get the model index of the parent of the object.\n     *\n     *    @param [in] child   Model index that identifies the child of the object.\n     *\n     *    @return QModelindex that identifies the parent of the given object.\n     */\n    QModelIndex parent(const QModelIndex& child) const;\n\npublic slots:\n\n\t/*!\n\t *  Clear the model.\n\t */\n\tvoid clear();\n\n    /*!\n     *  Handles the addition of a new item.\n     *\n     *    @param [in] index   The index to add the new item.\n     */\n    void onAddItem(QModelIndex const& index);\n\n    /*!\n     *  Handles item removal.\n     *\n     *    @param [in] index   The index to remove the item from.\n     */\n    void onRemoveItem(QModelIndex const& index);\n\n    /*!\n     *  Handles the addition of a new sub item.\n     *\n     *    @param [in] index   The parent index for the new sub item.\n     */\n    void onAddSubItem(QModelIndex const& index);\n\n    /*!\n     *  Remove all the sub items from the selected item.\n     *\n     *    @param [in] index   Index of the selected item.\n     */\n    void onRemoveAllSubItems(QModelIndex const& index);\n\nsignals:\n\n\t/*!\n     *  Emitted when contents of the model changes.\n     */\n\tvoid contentChanged();\n\nprivate:\n\n    /*!\n    *  Check if the given index is valid.\n    *\n    *    @param [in] index   The index to be checked.\n    *\n    *    @return True, if the given index is valid, false otherwise.\n    */\n    bool isIndexValid(QModelIndex const& index) const;\n\n    /*!\n    * Check if the index content can be edited by the user.\n    *\n    *    @param [in] index  The index to check.\n    *\n    *    @return True, if the index content is editable, otherwise false.\n    */\n    bool indexIsEditable(QModelIndex const& index) const;\n\n    /*!\n     *  Get the value for item in the selected index.\n     *\n     *    @param [in] index   The selected index.\n     *\n     *    @return Value of the selected index.\n     */\n    QVariant valueForIndex(QModelIndex const& index) const;\n\n    /*!\n     *  Get the generic extension of the selected index.\n     *\n     *    @param [in] index   The selected index.\n     *\n     *    @return Generic vendor extension of the selected index.\n     */\n    GenericVendorExtension* getExtensionForIndex(QModelIndex const& index) const;\n\n    /*!\n     *  Create a parent index for the selected child index.\n     *\n     *    @param [in] childIndex  The selected child index.\n     *\n     *    @return The created parent index.\n     */\n    QModelIndex createParentIndexForChildExtension(QModelIndex const& childIndex) const;\n\n    /*!\n     *  Get the row of the selected extension item.\n     *\n     *    @param [in] extensionItem   The selected extension item.\n     *\n     *    @return Row of the selected extension item.\n     */\n    int getRowForItem(GenericVendorExtension* extensionItem) const;\n\n    /*!\n     *  Get the row of the selected root extension item.\n     *\n     *    @param [in] parentItem  The selected root extension item.\n     *\n     *    @return Row of the selected rot extension item.\n     */\n    int getRowForRootItem(GenericVendorExtension* parentItem) const;\n\n    /*!\n     *  Check if the column of the selected index is mandatory.\n     *\n     *    @param [in] index   The selected index.\n     *\n     *    @return True, if the column is mandatory, false otherwise.\n     */\n    bool mandatoryColumn(QModelIndex const& index) const;\n\n    //-----------------------------------------------------------------------------\n    // Data.\n    //-----------------------------------------------------------------------------\n\n    //! A list of the vendor extensions of the model.\n    QSharedPointer<QList<QSharedPointer<VendorExtension> > > vendorExtensions_;\n\n    //! Empty generic vendor extension for comparisons.\n    GenericVendorExtension emptyExtension_;\n};\n\n#endif // VENDOREXTENSIONSMODEL_H\n"
  },
  {
    "path": "editors/common/diagramgrid.h",
    "content": "#ifndef DIAGRAMGRID_H\r\n#define DIAGRAMGRID_H\r\n\r\n#include <QPointF>\r\n\r\nstatic constexpr int GridSize = 10;\r\n\r\n/*! \\brief Snaps the given QPointF to the diagram grid\r\n *\r\n */\r\ninline constexpr QPointF snapPointToGrid(const QPointF& point)\r\n{\r\n    return QPointF((point / GridSize).toPoint() * GridSize);\r\n}\r\n\r\n/*! \\brief Snaps the given coordinates to the diagram grid\r\n *\r\n */\r\ninline constexpr QPointF snapPointToGrid(qreal x, qreal y)\r\n{\r\n    return snapPointToGrid(QPointF(x, y));\r\n}\r\n\r\n#endif // DIAGRAMGRID_H\r\n"
  },
  {
    "path": "executable/assets/peripherals.txt",
    "content": "Analog.AmbiqApollo4_ADC\nAnalog.EOSS3_ADC\nAnalog.IMXRT_ADC\nAnalog.MAX32650_ADC\nAnalog.STM32_ADC\nAnalog.STM32F0_ADC\nAnalog.Xilinx_XADC\nBus.GaislerAHBPlugAndPlayInfo\nBus.GaislerAPBController\nCache.PL310\nCAN.MPFS_CAN\nCAN.STMCAN\nCRC.STM32F0_CRC\nCrypto.AthenaX5200\nDMA.EFR32MG12_LDMA\nDMA.EOSS3_SPI_DMA\nDMA.EOSS3_SystemDMABridge\nDMA.MPFS_PDMA\nDMA.STM32DMA\nDMA.STM32DMA2D\nDMA.STM32G0DMA\nDMA.STM32LDMA\nDMA.TegraDma\nDMA.TegraDmaHost1X\nDMA.UDMA\nDMA.VybridDma\nDynamic.SubobjectTester\nGPIOPort.AmbiqApollo4_GPIO\nGPIOPort.CC2538_GPIO\nGPIOPort.EFMGPIOPort\nGPIOPort.EFR32_GPIOPort\nGPIOPort.Emios\nGPIOPort.GaislerGPIO\nGPIOPort.IMXRT_GPIO\nGPIOPort.LiteX_ControlAndStatus\nGPIOPort.LiteX_GPIO\nGPIOPort.MAX32650_GPIO\nGPIOPort.MiV_CoreGPIO\nGPIOPort.MPFS_GPIO\nGPIOPort.Murax_GPIO\nGPIOPort.NRF52840_GPIO\nGPIOPort.NRF52840_GPIOTasksEvents\nGPIOPort.NXPGPIOPort\nGPIOPort.OpenTitan_GPIO\nGPIOPort.PULP_APB_GPIO\nGPIOPort.SiFive_GPIO\nGPIOPort.STM32F1GPIOPort\nGPIOPort.STM32_GPIOPort\nGPIOPort.XilinxGPIOPS\nI2C.Cadence_I2C\nI2C.EFM32GGI2CController\nI2C.EFR32_I2CController\nI2C.LiteX_I2C\nI2C.MAX32650_I2C\nI2C.MPFS_I2C\nI2C.NRF52840_I2C\nI2C.OpenCoresI2C\nI2C.OpenTitan_I2C\nI2C.PULP_uDMA_I2C\nI2C.STM32F4_I2C\nI2C.STM32F7_I2C\nI2C.TegraDVC\nI2C.TegraI2CController\nI2C.VybridI2C\nInput.FT5336\nInput.FusionF0710A\nInput.PL050\nInput.PS2Keyboard\nInput.PS2Mouse\nIRQControllers.AIC\nIRQControllers.CoreLevelInterruptor\nIRQControllers.EOSS3_IntrCtrl\nIRQControllers.EXTI\nIRQControllers.GaislerMIC\nIRQControllers.GIC\nIRQControllers.IOAPIC\nIRQControllers.LAPIC\nIRQControllers.MPC5567_INTC\nIRQControllers.MSCM\nIRQControllers.NVIC\nIRQControllers.OpenTitan_PlatformLevelInterruptController\nIRQControllers.PL190\nIRQControllers.PlatformLevelInterruptController\nIRQControllers.PULP_EventController\nIRQControllers.PULP_InterruptController\nIRQControllers.SIC\nMemory.ArrayMemory\nMemoryControllers.ESAMemoryController\nMemoryControllers.OpenTitan_ROMController\nMemoryControllers.OpenTitan_SRAMController\nMemory.MappedMemory\nMiscellaneous.AmbiqApollo4_BootromLogger\nMiscellaneous.AmbiqApollo4_PowerController\nMiscellaneous.AmbiqApollo4_Security\nMiscellaneous.ArmSysCtl\nMiscellaneous.BitAccess\nMiscellaneous.BitBanding\nMiscellaneous.Button\nMiscellaneous.CC2538_Cryptoprocessor\nMiscellaneous.CombinedInput\nMiscellaneous.DWT\nMiscellaneous.EFR32_CMU\nMiscellaneous.EmulatorController\nMiscellaneous.EOSS3_FlexibleFusionEngine\nMiscellaneous.EOSS3_PacketFIFO\nMiscellaneous.ExternalWindowMMU\nMiscellaneous.IMX_TRNG\nMiscellaneous.K6xF_MCG\nMiscellaneous.K6xF_RNG\nMiscellaneous.K6xF_SIM\nMiscellaneous.LED\nMiscellaneous.LiteX_MMCM\nMiscellaneous.LiteX_SoC_Controller\nMiscellaneous.LiteX_SoC_Controller_CSR32\nMiscellaneous.MAX32650_GCR\nMiscellaneous.MAX32650_PWRSEQ\nMiscellaneous.MAX32650_TPU\nMiscellaneous.MPFS_DDRMock\nMiscellaneous.MPFS_SystemServices\nMiscellaneous.NRF52840_CLOCK\nMiscellaneous.NRF52840_ECB\nMiscellaneous.NRF52840_EGU\nMiscellaneous.NRF52840_PPI\nMiscellaneous.NRF52840_RNG\nMiscellaneous.OpenTitan_AES\nMiscellaneous.OpenTitan_AlertHandler\nMiscellaneous.OpenTitan_BigNumberAccelerator\nMiscellaneous.OpenTitan_ClockManager\nMiscellaneous.OpenTitan_CSRNG\nMiscellaneous.OpenTitan_EntropySource\nMiscellaneous.OpenTitan_HMAC\nMiscellaneous.OpenTitan_KeyManager\nMiscellaneous.OpenTitan_KMAC\nMiscellaneous.OpenTitan_LifeCycleController\nMiscellaneous.OpenTitan_OneTimeProgrammableMemoryController\nMiscellaneous.OpenTitan_PowerManager\nMiscellaneous.OpenTitan_ResetManager\nMiscellaneous.OpenTitan_SystemResetControl\nMiscellaneous.OpenTitan_VerilatorSwTestStatus\nMiscellaneous.Quark_SystemControlSubsystem\nMiscellaneous.S32K_SCG\nMiscellaneous.SAM_TRNG\nMiscellaneous.SEMA4\nMiscellaneous.SnoopControlUnit\nMiscellaneous.STM32F4_RCC\nMiscellaneous.STM32F4_RNG\nMiscellaneous.STM32H7_RCC\nMiscellaneous.STM32L0_PWR\nMiscellaneous.STM32L0_RCC\nMiscellaneous.STM32_PWR\nMiscellaneous.STM32_SYSCFG\nMiscellaneous.WindowIOMMU\nMocks.DummySPISlave\nMocks.EchoI2CDevice\nMocks.EmptyPeripheral\nMocks.MachineTestPeripheral\nMocks.MockCPU\nMocks.MockExternal\nMocks.MockGPIOByNumberConnectorPeripheral\nMocks.MockIrqSender\nMocks.MockPeripheralUsingReferenceAttribute\nMocks.MockPeripheralWithBoolAttribute\nMocks.MockPeripheralWithEnumAttribute\nMocks.MockPeripheralWithNumericalAttrubute\nMocks.MockPeripheralWithObjectAttribute\nMocks.MockPeripheralWithProtectedConstructor\nMocks.MockPeripheralWithRangeAttribute\nMocks.MockPeripheralWithStringAttribute\nMocks.MockReceiver\nMocks.MockRegister\nMocks.NullRegister\nMTD.CC2538FlashController\nMTD.DummySPIFlash\nMTD.EFR32xg13FlashController\nMTD.FSLNAND\nMTD.MPFS_eNVM\nMTD.OpenTitan_FlashController\nMTD.STM32L0_FlashController\nNetwork.CadenceGEM\nNetwork.ENC28J60\nNetwork.EthernetPhysicalLayer\nNetwork.FastEthernetController\nNetwork.GaislerEth\nNetwork.K6xF_Ethernet\nNetwork.LiteX_Ethernet\nNetwork.LiteX_Ethernet_CSR32\nNetwork.SMC91X\nNetwork.SynopsysEthernetMAC\nPCI.MPFS_PCIe\nPCI.PCIeRootComplex\nPCI.VersatilePCI\nPython.PythonPeripheral\nSD.LiteSDCard\nSD.LiteSDCard_CSR32\nSD.MPFS_SDController\nSD.SDHCI\nSD.SunxiMMC\nSensors.ADXL372\nSensors.ArduCAMMini2MPPlus\nSensors.BMP180\nSensors.DummySensor\nSensors.HiMaxHM01B0\nSensors.LIS2DS12\nSensors.LSM303DLHC_Accelerometer\nSensors.LSM303DLHC_Gyroscope\nSensors.LSM330_Accelerometer\nSensors.LSM330_Gyroscope\nSensors.LSM9DS1_IMU\nSensors.LSM9DS1_Magnetic\nSensors.MAX30208\nSensors.MC3635\nSensors.PAC1934\nSensors.PULP_uDMA_Camera\nSensors.SI70xx\nSensors.TI_LM74\nSensors.TMP103\nSiLabs.EFM32xG1xBDeviceInformation\nSiLabs.EFM32xGDeviceInformation\nSiLabs.EFR32DeviceInformation\nSiLabs.EFR32_GPCRC\nSiLabs.EFR32xG12DeviceInformation\nSiLabs.EZR32DeviceInformation\nSound.EOSS3_Voice\nSound.LiteX_I2S_Master\nSound.LiteX_I2S_Slave\nSound.NRF52840_I2S\nSound.NRF52840_PDM\nSound.PULP_I2S\nSPI.AmbiqApollo4_IOMaster\nSPI.Cadence_SPI\nSPI.Cadence_xSPI\nSPI.CC2538_SSI\nSPI.DesignWare_SPI\nSPI.HiFive_SPI\nSPI.IMXRT_FlexSPI\nSPI.IMXRT_LPSPI\nSPI.LiteX_SPI\nSPI.LiteX_SPI_Flash\nSPI.MAX32650_SPI\nSPI.Micron_MT25Q\nSPI.MPFS_QSPI\nSPI.MPFS_SPI\nSPI.NRF52840_SPI\nSPI.OpenTitan_SpiHost\nSPI.PicoRV_SPI\nSPI.PULP_uDMA_SPI\nSPI.Quark_SPI\nSPI.SPILoopback\nSPI.STM32SPI\nSPI.XilinxQSPI\nStorage.VirtIOBlockDevice\nTimers.AmbiqApollo4_RTC\nTimers.AmbiqApollo4_SystemTimer\nTimers.AmbiqApollo4_Timer\nTimers.Atmel91SystemTimer\nTimers.Cadence_TTC\nTimers.CC2538SleepTimer\nTimers.CC2538Watchdog\nTimers.CortexAGlobalTimer\nTimers.CortexAPrivateTimer\nTimers.Efm32Timer\nTimers.EFR32_RTCC\nTimers.EFR32_Timer\nTimers.EOSS3_SimplePeriodicTimer\nTimers.GaislerGPTimer\nTimers.IMX_GPTimer\nTimers.IMXRT_PWM\nTimers.LiteX_CPUTimer\nTimers.LiteX_Timer\nTimers.LiteX_Timer64\nTimers.LiteX_Timer_CSR32\nTimers.MAX32650_RTC\nTimers.MAX32650_Timer\nTimers.MAX32650_WDT\nTimers.MiV_CoreTimer\nTimers.MPFS_RTC\nTimers.MPFS_Timer\nTimers.MPFS_Watchdog\nTimers.Murax_Timer\nTimers.NRF52840_RTC\nTimers.NRF52840_Timer\nTimers.NRF52840_Watchdog\nTimers.OpenTitan_AonTimer\nTimers.OpenTitan_Timer\nTimers.PeriodicInterruptTimer\nTimers.PL031\nTimers.PULP_Timer\nTimers.S32K_LPIT\nTimers.S32K_LPTMR\nTimers.SP804\nTimers.STM32F4_RTC\nTimers.STM32_IndependentWatchdog\nTimers.STM32L0_LpTimer\nTimers.STM32_Timer\nTimers.SunxiHighSpeedTimer\nTimers.SunxiTimer\nTimers.TegraTimer\nTimers.TegraUsecTimer\nUART.Atmel91DebugUnit\nUART.Cadence_UART\nUART.EFM32_UART\nUART.EFR32_USART\nUART.GaislerUART\nUART.ImxUart\nUART.K6xF_UART\nUART.LEUART\nUART.LiteX_UART\nUART.LiteX_UART64\nUART.LowPower_Timer\nUART.LowPower_UART\nUART.MAX32650_UART\nUART.MiV_CoreUART\nUART.MPC5567_UART\nUART.Murax_UART\nUART.NRF52840_UART\nUART.NS16550\nUART.OpenTitan_UART\nUART.PicoSoC_SimpleUART\nUART.PL011\nUART.Potato_UART\nUART.PULP_uDMA_UART\nUART.SAMD5_UART\nUART.SAM_USART\nUART.SemihostingUart\nUART.SiFive_UART\nUART.STM32F7_USART\nUART.STM32_UART\nUART.STM32W_UART\nUART.TrivialUart\nUART.USBSerialPort_S3B\nUSBDeprecated.EHCIHostController\nUSBDeprecated.ISP1761\nUSBDeprecated.UsbHub\nUSBDeprecated.USBKeyboard\nUSBDeprecated.USBMouse\nUSB.MPFS_USB\nUSB.ValentyUSB\nVerilated.BaseDoubleWordVerilatedPeripheral\nVerilated.CFUVerilatedPeripheral\nVerilated.VerilatedRiscV32\nVerilated.VerilatedUART\nVideo.LiteX_Framebuffer_CSR32\nVideo.PL110\nVideo.STM32LTDC\nVideo.TegraDisplay\nVideo.TegraSyncpts\nVideo.VybridDCU\nWireless.CC1200\nWireless.CC2520\nWireless.CC2538RF\nWireless.EmberRadio\nWireless.NRF52840_Radio\nX86.Quark_GPIOController\nX86.Quark_PWM\n"
  },
  {
    "path": "executable/templates/defaultTemplateConfiguration.json",
    "content": "{\n    \"Templates\": [\n        {\n            \"name\": \"example\",\n            \"template\": \"templates/exampleTemplate.py\",\n            \"targetPath\": \"python_peripherals\"\n        }\n    ]\n}\n"
  },
  {
    "path": "executable/templates/exampleTemplate.py",
    "content": ""
  },
  {
    "path": "executable/upgrade.cfg",
    "content": "// DO NOT MODIFY!\r\nVERSION 2.0.1.0\r\nADD Platform/PluginsPath String Plugins\r\nADD Platform/HelpPath String Help\r\nADD Library/Locations StringList Library\r\nADD Library/DefaultLocation String Library\r\nADD FilterWidget/Hidden Boolean false\r\nADD Policies/InstanceNames String $ComponentName$_$InstanceNumber$\r\nADD Policies/HWViewNames StringList hierarchical,structural\r\nADD Policies/SWViewNames StringList software\r\nADD Policies/SysViewNames StringList system\r\nADD Editor/IndentWidth Integer 4\r\nADD Editor/IndentStyle Integer 1\r\nADD Editor/Font Font Courier New,10\r\nADD Editor/Highlight/Keywords HighlightStyle blue\r\nADD Editor/Highlight/Preprocessor HighlightStyle blue\r\nADD Editor/Highlight/Strings HighlightStyle #a30000\r\nADD Editor/Highlight/SinglelineComments HighlightStyle green\r\nADD Editor/Highlight/MultilineComments HighlightStyle green\r\nADD Editor/Highlight/APITypes HighlightStyle blue\r\nADD Editor/Highlight/APIFunc HighlightStyle purple,bold\r\nADD Workspaces/Default/WindowState ByteArray \\0\\0\\0\\xff\\0\\0\\0\\0\\xfd\\0\\0\\0\\x4\\0\\0\\0\\0\\0\\0\\x1H\\0\\0\\x4\\x33\\xfc\\x2\\0\\0\\0\\x2\\xfb\\0\\0\\0\\xe\\0L\\0i\\0\\x62\\0r\\0\\x61\\0r\\0y\\x1\\0\\0\\0g\\0\\0\\x3Y\\0\\0\\x1\\\\\\0\\xff\\xff\\xff\\xfb\\0\\0\\0 \\0\\x43\\0o\\0m\\0p\\0o\\0n\\0\\x65\\0n\\0t\\0P\\0r\\0\\x65\\0v\\0i\\0\\x65\\0w\\x1\\0\\0\\x3\\xc4\\0\\0\\0\\xd6\\0\\0\\0\\x8e\\0\\xff\\xff\\xff\\0\\0\\0\\x1\\0\\0\\x1&\\0\\0\\x4\\x33\\xfc\\x2\\0\\0\\0\\x6\\xfb\\0\\0\\0\\x1e\\0I\\0n\\0s\\0t\\0\\x61\\0n\\0\\x63\\0\\x65\\0 \\0\\x45\\0\\x64\\0i\\0t\\0o\\0r\\0\\0\\0\\0g\\0\\0\\0\\x14\\0\\0\\0\\x14\\0\\0\\0\\x14\\xfb\\0\\0\\0\\\"\\0\\x41\\0\\x64\\0-\\0h\\0o\\0\\x63\\0 \\0V\\0i\\0s\\0i\\0\\x62\\0i\\0l\\0i\\0t\\0y\\0\\0\\0\\0\\x7f\\0\\0\\0\\x14\\0\\0\\0\\x14\\0\\0\\0\\x14\\xfb\\0\\0\\0(\\0\\x43\\0o\\0n\\0\\x66\\0i\\0g\\0u\\0r\\0\\x61\\0t\\0i\\0o\\0n\\0 \\0\\x65\\0\\x64\\0i\\0t\\0o\\0r\\0\\0\\0\\0\\x97\\0\\0\\x2\\xd0\\0\\0\\0\\xc5\\0\\xff\\xff\\xff\\xfb\\0\\0\\0\\x32\\0H\\0W\\0 \\0M\\0\\x61\\0p\\0p\\0i\\0n\\0g\\0 \\0\\x44\\0\\x65\\0t\\0\\x61\\0i\\0l\\0s\\0 \\0\\x45\\0\\x64\\0i\\0t\\0o\\0r\\0\\0\\0\\x3k\\0\\0\\0\\xff\\0\\0\\0\\xff\\0\\xff\\xff\\xff\\xfb\\0\\0\\0 \\0I\\0n\\0t\\0\\x65\\0r\\0\\x66\\0\\x61\\0\\x63\\0\\x65\\0 \\0\\x45\\0\\x64\\0i\\0t\\0o\\0r\\0\\0\\0\\x4n\\0\\0\\0\\x14\\0\\0\\0\\x14\\0\\0\\0\\x14\\xfb\\0\\0\\0\\\"\\0\\x43\\0o\\0n\\0n\\0\\x65\\0\\x63\\0t\\0i\\0o\\0n\\0 \\0\\x45\\0\\x64\\0i\\0t\\0o\\0r\\0\\0\\0\\x4\\x86\\0\\0\\0\\x14\\0\\0\\0\\x14\\0\\0\\0\\x14\\0\\0\\0\\x2\\0\\0\\x6@\\0\\0\\0\\x63\\xfc\\x1\\0\\0\\0\\x1\\xfb\\0\\0\\0\\b\\0M\\0\\x65\\0n\\0u\\x1\\0\\0\\0\\0\\0\\0\\x6@\\0\\0\\0\\0\\0\\xff\\xff\\xff\\0\\0\\0\\x3\\0\\0\\x4\\xf4\\0\\0\\0\\xd6\\xfc\\x1\\0\\0\\0\\x3\\xfb\\0\\0\\0\\f\\0O\\0u\\0t\\0p\\0u\\0t\\x1\\0\\0\\x1L\\0\\0\\x3\\x82\\0\\0\\0P\\0\\xff\\xff\\xff\\xfb\\0\\0\\0\\x18\\0\\x43\\0o\\0n\\0t\\0\\x65\\0x\\0t\\0 \\0H\\0\\x65\\0l\\0p\\x1\\0\\0\\x4\\xd2\\0\\0\\x1n\\0\\0\\0P\\0\\xff\\xff\\xff\\xfb\\0\\0\\0\\x1c\\0\\x41\\0\\x64\\0\\x64\\0r\\0\\x65\\0s\\0s\\0 \\0\\x45\\0\\x64\\0i\\0t\\0o\\0r\\0\\0\\0\\0\\0\\xff\\xff\\xff\\xff\\0\\0\\x1*\\0\\xff\\xff\\xff\\0\\0\\x4\\xf4\\0\\0\\x3Y\\0\\0\\0\\x4\\0\\0\\0\\x4\\0\\0\\0\\x1\\0\\0\\0\\x2\\xfc\\0\\0\\0\\0\r\nADD Workspaces/Default/Geometry ByteArray \\x1\\xd9\\xd0\\xcb\\0\\x1\\0\\0\\xff\\xff\\xff\\xf8\\xff\\xff\\xff\\xf8\\0\\0\\x6G\\0\\0\\x4\\xb7\\0\\0\\x1 \\0\\0\\0\\xe3\\0\\0\\x5\\x1f\\0\\0\\x3\\xe2\\0\\0\\0\\0\\x2\\0\r\nADD Workspaces/Default/WindowPosition Point -8 -8\r\nADD Workspaces/Default/ConfigurationVisibility Boolean true\r\nADD Workspaces/Default/SystemDetailsVisibility Boolean true\r\nADD Workspaces/Default/ConnectionVisibility Boolean true\r\nADD Workspaces/Default/InstanceVisibility Boolean true\r\nADD Workspaces/Default/AdHocVisibility Boolean true\r\nADD Workspaces/Default/AddressVisibility Boolean false\r\nADD Workspaces/Default/InterfaceVisibility Boolean true\r\nADD Workspaces/Default/LibraryVisibility Boolean true\r\nADD Workspaces/Default/OutputVisibility Boolean true\r\nADD Workspaces/Default/ContextHelpVisibility Boolean true\r\nADD Workspaces/Default/PreviewVisibility Boolean true\r\nADD Workspaces/Default/DesignParameterVisibility Boolean true\r\nADD Workspaces/Design/WindowState ByteArray \\0\\0\\0\\xff\\0\\0\\0\\0\\xfd\\0\\0\\0\\x4\\0\\0\\0\\0\\0\\0\\x1H\\0\\0\\x4\\x33\\xfc\\x2\\0\\0\\0\\x2\\xfb\\0\\0\\0\\xe\\0L\\0i\\0\\x62\\0r\\0\\x61\\0r\\0y\\x1\\0\\0\\0g\\0\\0\\x3Y\\0\\0\\x1\\\\\\0\\xff\\xff\\xff\\xfb\\0\\0\\0 \\0\\x43\\0o\\0m\\0p\\0o\\0n\\0\\x65\\0n\\0t\\0P\\0r\\0\\x65\\0v\\0i\\0\\x65\\0w\\x1\\0\\0\\x3\\xc4\\0\\0\\0\\xd6\\0\\0\\0\\x8e\\0\\xff\\xff\\xff\\0\\0\\0\\x1\\0\\0\\x1&\\0\\0\\x4\\x33\\xfc\\x2\\0\\0\\0\\x6\\xfb\\0\\0\\0(\\0\\x43\\0o\\0n\\0\\x66\\0i\\0g\\0u\\0r\\0\\x61\\0t\\0i\\0o\\0n\\0 \\0\\x65\\0\\x64\\0i\\0t\\0o\\0r\\0\\0\\0\\0g\\0\\0\\x1\\xb5\\0\\0\\0\\xc5\\0\\xff\\xff\\xff\\xfb\\0\\0\\0\\x1e\\0I\\0n\\0s\\0t\\0\\x61\\0n\\0\\x63\\0\\x65\\0 \\0\\x45\\0\\x64\\0i\\0t\\0o\\0r\\0\\0\\0\\x2 \\0\\0\\0\\x14\\0\\0\\0\\x14\\0\\0\\0\\x14\\xfb\\0\\0\\0 \\0I\\0n\\0t\\0\\x65\\0r\\0\\x66\\0\\x61\\0\\x63\\0\\x65\\0 \\0\\x45\\0\\x64\\0i\\0t\\0o\\0r\\0\\0\\0\\x2\\x38\\0\\0\\0\\x14\\0\\0\\0\\x14\\0\\0\\0\\x14\\xfb\\0\\0\\0\\\"\\0\\x43\\0o\\0n\\0n\\0\\x65\\0\\x63\\0t\\0i\\0o\\0n\\0 \\0\\x45\\0\\x64\\0i\\0t\\0o\\0r\\0\\0\\0\\x2P\\0\\0\\0\\x14\\0\\0\\0\\x14\\0\\0\\0\\x14\\xfb\\0\\0\\0\\x32\\0H\\0W\\0 \\0M\\0\\x61\\0p\\0p\\0i\\0n\\0g\\0 \\0\\x44\\0\\x65\\0t\\0\\x61\\0i\\0l\\0s\\0 \\0\\x45\\0\\x64\\0i\\0t\\0o\\0r\\0\\0\\0\\x2h\\0\\0\\x2\\x32\\0\\0\\0\\xff\\0\\xff\\xff\\xff\\xfb\\0\\0\\0\\\"\\0\\x41\\0\\x64\\0-\\0h\\0o\\0\\x63\\0 \\0V\\0i\\0s\\0i\\0\\x62\\0i\\0l\\0i\\0t\\0y\\0\\0\\0\\x2\\xe3\\0\\0\\x1\\x87\\0\\0\\0\\x14\\0\\0\\0\\x14\\0\\0\\0\\x2\\0\\0\\x6@\\0\\0\\0\\x63\\xfc\\x1\\0\\0\\0\\x1\\xfb\\0\\0\\0\\b\\0M\\0\\x65\\0n\\0u\\x1\\0\\0\\0\\0\\0\\0\\x6@\\0\\0\\0\\0\\0\\xff\\xff\\xff\\0\\0\\0\\x3\\0\\0\\x4\\xf4\\0\\0\\0\\xd6\\xfc\\x1\\0\\0\\0\\x3\\xfb\\0\\0\\0\\f\\0O\\0u\\0t\\0p\\0u\\0t\\x1\\0\\0\\x1L\\0\\0\\x3&\\0\\0\\0P\\0\\xff\\xff\\xff\\xfb\\0\\0\\0\\x18\\0\\x43\\0o\\0n\\0t\\0\\x65\\0x\\0t\\0 \\0H\\0\\x65\\0l\\0p\\x1\\0\\0\\x4v\\0\\0\\x1\\xca\\0\\0\\0P\\0\\xff\\xff\\xff\\xfb\\0\\0\\0\\x1c\\0\\x41\\0\\x64\\0\\x64\\0r\\0\\x65\\0s\\0s\\0 \\0\\x45\\0\\x64\\0i\\0t\\0o\\0r\\0\\0\\0\\0\\0\\xff\\xff\\xff\\xff\\0\\0\\x1*\\0\\xff\\xff\\xff\\0\\0\\x4\\xf4\\0\\0\\x3Y\\0\\0\\0\\x4\\0\\0\\0\\x4\\0\\0\\0\\x1\\0\\0\\0\\x2\\xfc\\0\\0\\0\\0\r\nADD Workspaces/Design/Geometry ByteArray \\x1\\xd9\\xd0\\xcb\\0\\x1\\0\\0\\xff\\xff\\xff\\xf8\\xff\\xff\\xff\\xf8\\0\\0\\x6G\\0\\0\\x4\\xb7\\0\\0\\x1 \\0\\0\\0\\xe3\\0\\0\\x5\\x1f\\0\\0\\x3\\xe2\\0\\0\\0\\0\\x2\\0\r\nADD Workspaces/Design/WindowPosition Point -8 -8\r\nADD Workspaces/Design/ConfigurationVisibility Boolean true\r\nADD Workspaces/Design/SystemDetailsVisibility Boolean true\r\nADD Workspaces/Design/ConnectionVisibility Boolean true\r\nADD Workspaces/Design/InstanceVisibility Boolean true\r\nADD Workspaces/Design/AdHocVisibility Boolean false\r\nADD Workspaces/Design/AddressVisibility Boolean false\r\nADD Workspaces/Design/InterfaceVisibility Boolean true\r\nADD Workspaces/Design/LibraryVisibility Boolean true\r\nADD Workspaces/Design/OutputVisibility Boolean true\r\nADD Workspaces/Design/ContextHelpVisibility Boolean true\r\nADD Workspaces/Design/PreviewVisibility Boolean true\r\nADD Workspaces/Design/DesignParameterVisibility Boolean true\r\nADD Workspaces/CurrentWorkspace String Default\r\n\r\nVERSION 2.1.172.0\r\nCOPY Library/Locations Library/ActiveLocations\r\n\r\nVERSION 2.1.376.0\r\nADD FileTypes/cSource String c;h\r\nADD FileTypes/cppSource String cpp;hpp;cxx;hxx;cc;hh;h\r\nADD FileTypes/vhdlSource String vhdl;vhd\r\nADD FileTypes/asmSource String s;asm\r\nADD FileTypes/eSource String \r\nADD FileTypes/sopcInfoFile String sopcinfo\r\nADD FileTypes/OVASource String\r\nADD FileTypes/perlSource String pl\r\nADD FileTypes/pslSource String\r\nADD FileTypes/vhdlSource-87 String\r\nADD FileTypes/vhdlSource-93 String\r\nADD FileTypes/systemVerilogSource String sv\r\nADD FileTypes/systemVerilogSource-3.0 String\r\nADD FileTypes/systemVerilogSource-3.1 String\r\nADD FileTypes/systemVerilogSource-3.1a String\r\nADD FileTypes/verilogSource String v\r\nADD FileTypes/verilogSource-95 String\r\nADD FileTypes/verilogSource-2001 String\r\nADD FileTypes/SVASource String\r\nADD FileTypes/tclSource String tcl\r\nADD FileTypes/veraSource String \r\nADD FileTypes/systemCSource String\r\nADD FileTypes/systemCSource-2.0 String\r\nADD FileTypes/systemCSource-2.0.1 String\r\nADD FileTypes/systemCSource-2.1 String\r\nADD FileTypes/systemCSource-2.2 String\r\nADD FileTypes/unknown String\r\nADD FileTypes/SDC String sdc\r\nADD FileTypes/unelaboratedHdl String\r\nADD FileTypes/swObject String elf\r\nADD FileTypes/swObjectLibrary String\r\nADD FileTypes/executableHdl String sof\r\nADD FileTypes/verilogBinaryLibrary String\r\nADD FileTypes/vhdlBinaryLibrary String\r\nADD FileTypes/htmlFile String htm;html\r\nADD FileTypes/picture String png;gif;jpg;jpeg\r\nADD FileTypes/makefile String\r\nADD FileTypes/shellScript String sh\r\nADD FileTypes/pdfFile String pdf\r\nADD FileTypes/textFile String txt\r\nADD FileTypes/BSPFile String bsp\r\nADD FileTypes/ModelsimScript String do\r\n\r\nVERSION 2.3.0.0\r\nADD Workspaces/Design/LibraryFilters/Type/ShowComponents Boolean true\r\nADD Workspaces/Design/LibraryFilters/Type/ShowBuses Boolean true\r\nADD Workspaces/Design/LibraryFilters/Type/ShowAdvanced Boolean false\r\nADD Workspaces/Design/LibraryFilters/Implementation/ShowHW Boolean true\r\nADD Workspaces/Design/LibraryFilters/Implementation/ShowSW Boolean true\r\nADD Workspaces/Design/LibraryFilters/Implementation/ShowSystem Boolean true\r\nADD Workspaces/Design/LibraryFilters/Hierarchy/ShowGlobal Boolean true\r\nADD Workspaces/Design/LibraryFilters/Hierarchy/ShowProduct Boolean true\r\nADD Workspaces/Design/LibraryFilters/Hierarchy/ShowBoard Boolean true\r\nADD Workspaces/Design/LibraryFilters/Hierarchy/ShowChip Boolean true\r\nADD Workspaces/Design/LibraryFilters/Hierarchy/ShowSoC Boolean true\r\nADD Workspaces/Design/LibraryFilters/Hierarchy/ShowIP Boolean true\r\nADD Workspaces/Design/LibraryFilters/Firmness/ShowTemplates Boolean true\r\nADD Workspaces/Design/LibraryFilters/Firmness/ShowMutable Boolean true\r\nADD Workspaces/Design/LibraryFilters/Firmness/ShowFixed Boolean true\r\nADD Workspaces/Default/LibraryFilters/Type/ShowComponents Boolean true\r\nADD Workspaces/Default/LibraryFilters/Type/ShowBuses Boolean true\r\nADD Workspaces/Default/LibraryFilters/Type/ShowAdvanced Boolean false\r\nADD Workspaces/Default/LibraryFilters/Implementation/ShowHW Boolean true\r\nADD Workspaces/Default/LibraryFilters/Implementation/ShowSW Boolean true\r\nADD Workspaces/Default/LibraryFilters/Implementation/ShowSystem Boolean true\r\nADD Workspaces/Default/LibraryFilters/Hierarchy/ShowGlobal Boolean true\r\nADD Workspaces/Default/LibraryFilters/Hierarchy/ShowProduct Boolean true\r\nADD Workspaces/Default/LibraryFilters/Hierarchy/ShowBoard Boolean true\r\nADD Workspaces/Default/LibraryFilters/Hierarchy/ShowChip Boolean true\r\nADD Workspaces/Default/LibraryFilters/Hierarchy/ShowSoC Boolean true\r\nADD Workspaces/Default/LibraryFilters/Hierarchy/ShowIP Boolean true\r\nADD Workspaces/Default/LibraryFilters/Firmness/ShowTemplates Boolean true\r\nADD Workspaces/Default/LibraryFilters/Firmness/ShowMutable Boolean true\r\nADD Workspaces/Default/LibraryFilters/Firmness/ShowFixed Boolean true\r\n\r\nVERSION 2.4.0.0\r\nADD FileTypes/padsPart String p\r\nADD FileTypes/padsCAEDecal String c\r\nADD FileTypes/padsPCBDecal String d\r\n\r\nVERSION 2.4.17.0\r\nADD FileTypes/quartusPinFile String pin\r\nADD FileTypes/quartusProjectFile String qsf\r\n\r\nVERSION 2.5.0.0\r\nRENAME FileTypes/cSource FileTypes/cSource/Extensions\r\nRENAME FileTypes/cppSource FileTypes/cppSource/Extensions\r\nRENAME FileTypes/vhdlSource FileTypes/vhdlSource/Extensions\r\nRENAME FileTypes/asmSource FileTypes/asmSource/Extensions\r\nRENAME FileTypes/eSource FileTypes/eSource/Extensions\r\nRENAME FileTypes/sopcInfoFile FileTypes/sopcInfoFile/Extensions\r\nRENAME FileTypes/OVASource FileTypes/OVASource/Extensions\r\nRENAME FileTypes/perlSource FileTypes/perlSource/Extensions\r\nRENAME FileTypes/pslSource FileTypes/pslSource/Extensions\r\nRENAME FileTypes/vhdlSource-87 FileTypes/vhdlSource-87/Extensions\r\nRENAME FileTypes/vhdlSource-93 FileTypes/vhdlSource-93/Extensions\r\nRENAME FileTypes/systemVerilogSource FileTypes/systemVerilogSource/Extensions\r\nRENAME FileTypes/systemVerilogSource-3.0 FileTypes/systemVerilogSource-3.0/Extensions\r\nRENAME FileTypes/systemVerilogSource-3.1 FileTypes/systemVerilogSource-3.1/Extensions\r\nRENAME FileTypes/systemVerilogSource-3.1a FileTypes/systemVerilogSource-3.1a/Extensions\r\nRENAME FileTypes/verilogSource FileTypes/verilogSource/Extensions\r\nRENAME FileTypes/verilogSource-95 FileTypes/verilogSource-95/Extensions\r\nRENAME FileTypes/verilogSource-2001 FileTypes/verilogSource-2001/Extensions\r\nRENAME FileTypes/SVASource FileTypes/SVASource/Extensions\r\nRENAME FileTypes/tclSource FileTypes/tclSource/Extensions\r\nRENAME FileTypes/veraSource FileTypes/veraSource/Extensions\r\nRENAME FileTypes/systemCSource FileTypes/systemCSource/Extensions\r\nRENAME FileTypes/systemCSource-2.0 FileTypes/systemCSource-2.0/Extensions\r\nRENAME FileTypes/systemCSource-2.0.1 FileTypes/systemCSource-2.0.1/Extensions\r\nRENAME FileTypes/systemCSource-2.1 FileTypes/systemCSource-2.1/Extensions\r\nRENAME FileTypes/systemCSource-2.2 FileTypes/systemCSource-2.2/Extensions\r\nRENAME FileTypes/unknown FileTypes/unknown/Extensions\r\nRENAME FileTypes/SDC FileTypes/SDC/Extensions\r\nRENAME FileTypes/unelaboratedHdl FileTypes/unelaboratedHdl/Extensions\r\nRENAME FileTypes/swObject FileTypes/swObject/Extensions\r\nRENAME FileTypes/swObjectLibrary FileTypes/swObjectLibrary/Extensions\r\nRENAME FileTypes/executableHdl FileTypes/executableHdl/Extensions\r\nRENAME FileTypes/verilogBinaryLibrary FileTypes/verilogBinaryLibrary/Extensions\r\nRENAME FileTypes/vhdlBinaryLibrary FileTypes/vhdlBinaryLibrary/Extensions\r\nRENAME FileTypes/htmlFile FileTypes/htmlFile/Extensions\r\nRENAME FileTypes/picture FileTypes/picture/Extensions\r\nRENAME FileTypes/makefile FileTypes/makefile/Extensions\r\nRENAME FileTypes/shellScript FileTypes/shellScript/Extensions\r\nRENAME FileTypes/pdfFile FileTypes/pdfFile/Extensions\r\nRENAME FileTypes/textFile FileTypes/textFile/Extensions\r\nRENAME FileTypes/BSPFile FileTypes/BSPFile/Extensions\r\nRENAME FileTypes/ModelsimScript FileTypes/ModelsimScript/Extensions\r\nRENAME FileTypes/padsPart FileTypes/padsPart/Extensions\r\nRENAME FileTypes/padsCAEDecal FileTypes/padsCAEDecal/Extensions\r\nRENAME FileTypes/padsPCBDecal FileTypes/padsPCBDecal/Extensions\r\nRENAME FileTypes/quartusPinFile FileTypes/quartusPinFile/Extensions\r\nRENAME FileTypes/quartusProjectFile FileTypes/quartusProjectFile/Extensions\r\nADD FileTypes/cSource/Executable String\r\nADD FileTypes/cppSource/Executable String\r\nADD FileTypes/vhdlSource/Executable String\r\nADD FileTypes/asmSource/Executable String\r\nADD FileTypes/eSource/Executable String\r\nADD FileTypes/sopcInfoFile/Executable String\r\nADD FileTypes/OVASource/Executable String\r\nADD FileTypes/perlSource/Executable String\r\nADD FileTypes/pslSource/Executable String\r\nADD FileTypes/vhdlSource-87/Executable String\r\nADD FileTypes/vhdlSource-93/Executable String\r\nADD FileTypes/systemVerilogSource/Executable String\r\nADD FileTypes/systemVerilogSource-3.0/Executable String\r\nADD FileTypes/systemVerilogSource-3.1/Executable String\r\nADD FileTypes/systemVerilogSource-3.1a/Executable String\r\nADD FileTypes/verilogSource/Executable String\r\nADD FileTypes/verilogSource-95/Executable String\r\nADD FileTypes/verilogSource-2001/Executable String\r\nADD FileTypes/SVASource/Executable String\r\nADD FileTypes/tclSource/Executable String\r\nADD FileTypes/veraSource/Executable String\r\nADD FileTypes/systemCSource/Executable String\r\nADD FileTypes/systemCSource-2.0/Executable String\r\nADD FileTypes/systemCSource-2.0.1/Executable String\r\nADD FileTypes/systemCSource-2.1/Executable String\r\nADD FileTypes/systemCSource-2.2/Executable String\r\nADD FileTypes/unknown/Executable String\r\nADD FileTypes/SDC/Executable String\r\nADD FileTypes/unelaboratedHdl/Executable String\r\nADD FileTypes/swObject/Executable String\r\nADD FileTypes/swObjectLibrary/Executable String\r\nADD FileTypes/executableHdl/Executable String\r\nADD FileTypes/verilogBinaryLibrary/Executable String\r\nADD FileTypes/vhdlBinaryLibrary/Executable String\r\nADD FileTypes/htmlFile/Executable String\r\nADD FileTypes/picture/Executable String\r\nADD FileTypes/makefile/Executable String\r\nADD FileTypes/shellScript/Executable String\r\nADD FileTypes/pdfFile/Executable String\r\nADD FileTypes/textFile/Executable String\r\nADD FileTypes/BSPFile/Executable String bsp\r\nADD FileTypes/ModelsimScript/Executable String\r\nADD FileTypes/padsPart/Executable String\r\nADD FileTypes/padsCAEDecal/Executable String\r\nADD FileTypes/padsPCBDecal/Executable String\r\nADD FileTypes/quartusPinFile/Executable String\r\nADD FileTypes/quartusProjectFile/Executable String\r\n\r\nVERSION 2.6.842.0\r\nADD Workspaces/Default/ComponentEditorFilters/HW/Global/File_sets Boolean true\r\nADD Workspaces/Default/ComponentEditorFilters/HW/Global/Choices Boolean true\r\nADD Workspaces/Default/ComponentEditorFilters/HW/Global/Model_parameters Boolean true\r\nADD Workspaces/Default/ComponentEditorFilters/HW/Global/Parameters Boolean true\r\nADD Workspaces/Default/ComponentEditorFilters/HW/Global/Memory_maps Boolean true\r\nADD Workspaces/Default/ComponentEditorFilters/HW/Global/Address_spaces Boolean true\r\nADD Workspaces/Default/ComponentEditorFilters/HW/Global/Views Boolean true\r\nADD Workspaces/Default/ComponentEditorFilters/HW/Global/Software_views Boolean true\r\nADD Workspaces/Default/ComponentEditorFilters/HW/Global/System_views Boolean true\r\nADD Workspaces/Default/ComponentEditorFilters/HW/Global/Ports Boolean true\r\nADD Workspaces/Default/ComponentEditorFilters/HW/Global/Bus_interfaces Boolean true\r\nADD Workspaces/Default/ComponentEditorFilters/HW/Global/Channels Boolean true\r\nADD Workspaces/Default/ComponentEditorFilters/HW/Global/Cpus Boolean true\r\nADD Workspaces/Default/ComponentEditorFilters/HW/Global/Other_clock_drivers Boolean true\r\nADD Workspaces/Default/ComponentEditorFilters/HW/Global/COM_interfaces Boolean true\r\nADD Workspaces/Default/ComponentEditorFilters/HW/Global/Software_properties Boolean true\r\nADD Workspaces/Default/ComponentEditorFilters/HW/Product/File_sets Boolean true\r\nADD Workspaces/Default/ComponentEditorFilters/HW/Product/Choices Boolean true\r\nADD Workspaces/Default/ComponentEditorFilters/HW/Product/Model_parameters Boolean true\r\nADD Workspaces/Default/ComponentEditorFilters/HW/Product/Parameters Boolean true\r\nADD Workspaces/Default/ComponentEditorFilters/HW/Product/Memory_maps Boolean true\r\nADD Workspaces/Default/ComponentEditorFilters/HW/Product/Address_spaces Boolean true\r\nADD Workspaces/Default/ComponentEditorFilters/HW/Product/Views Boolean true\r\nADD Workspaces/Default/ComponentEditorFilters/HW/Product/Software_views Boolean true\r\nADD Workspaces/Default/ComponentEditorFilters/HW/Product/System_views Boolean true\r\nADD Workspaces/Default/ComponentEditorFilters/HW/Product/Ports Boolean true\r\nADD Workspaces/Default/ComponentEditorFilters/HW/Product/Bus_interfaces Boolean true\r\nADD Workspaces/Default/ComponentEditorFilters/HW/Product/Channels Boolean true\r\nADD Workspaces/Default/ComponentEditorFilters/HW/Product/Cpus Boolean true\r\nADD Workspaces/Default/ComponentEditorFilters/HW/Product/Other_clock_drivers Boolean true\r\nADD Workspaces/Default/ComponentEditorFilters/HW/Product/COM_interfaces Boolean true\r\nADD Workspaces/Default/ComponentEditorFilters/HW/Product/Software_properties Boolean true\r\nADD Workspaces/Default/ComponentEditorFilters/HW/Board/File_sets Boolean true\r\nADD Workspaces/Default/ComponentEditorFilters/HW/Board/Choices Boolean true\r\nADD Workspaces/Default/ComponentEditorFilters/HW/Board/Model_parameters Boolean true\r\nADD Workspaces/Default/ComponentEditorFilters/HW/Board/Parameters Boolean true\r\nADD Workspaces/Default/ComponentEditorFilters/HW/Board/Memory_maps Boolean true\r\nADD Workspaces/Default/ComponentEditorFilters/HW/Board/Address_spaces Boolean true\r\nADD Workspaces/Default/ComponentEditorFilters/HW/Board/Views Boolean true\r\nADD Workspaces/Default/ComponentEditorFilters/HW/Board/Software_views Boolean true\r\nADD Workspaces/Default/ComponentEditorFilters/HW/Board/System_views Boolean true\r\nADD Workspaces/Default/ComponentEditorFilters/HW/Board/Ports Boolean true\r\nADD Workspaces/Default/ComponentEditorFilters/HW/Board/Bus_interfaces Boolean true\r\nADD Workspaces/Default/ComponentEditorFilters/HW/Board/Channels Boolean true\r\nADD Workspaces/Default/ComponentEditorFilters/HW/Board/Cpus Boolean true\r\nADD Workspaces/Default/ComponentEditorFilters/HW/Board/Other_clock_drivers Boolean true\r\nADD Workspaces/Default/ComponentEditorFilters/HW/Board/COM_interfaces Boolean true\r\nADD Workspaces/Default/ComponentEditorFilters/HW/Board/Software_properties Boolean true\r\nADD Workspaces/Default/ComponentEditorFilters/HW/Chip/File_sets Boolean true\r\nADD Workspaces/Default/ComponentEditorFilters/HW/Chip/Choices Boolean true\r\nADD Workspaces/Default/ComponentEditorFilters/HW/Chip/Model_parameters Boolean true\r\nADD Workspaces/Default/ComponentEditorFilters/HW/Chip/Parameters Boolean true\r\nADD Workspaces/Default/ComponentEditorFilters/HW/Chip/Memory_maps Boolean true\r\nADD Workspaces/Default/ComponentEditorFilters/HW/Chip/Address_spaces Boolean true\r\nADD Workspaces/Default/ComponentEditorFilters/HW/Chip/Views Boolean true\r\nADD Workspaces/Default/ComponentEditorFilters/HW/Chip/Software_views Boolean true\r\nADD Workspaces/Default/ComponentEditorFilters/HW/Chip/System_views Boolean true\r\nADD Workspaces/Default/ComponentEditorFilters/HW/Chip/Ports Boolean true\r\nADD Workspaces/Default/ComponentEditorFilters/HW/Chip/Bus_interfaces Boolean true\r\nADD Workspaces/Default/ComponentEditorFilters/HW/Chip/Channels Boolean true\r\nADD Workspaces/Default/ComponentEditorFilters/HW/Chip/Cpus Boolean true\r\nADD Workspaces/Default/ComponentEditorFilters/HW/Chip/Other_clock_drivers Boolean true\r\nADD Workspaces/Default/ComponentEditorFilters/HW/Chip/COM_interfaces Boolean true\r\nADD Workspaces/Default/ComponentEditorFilters/HW/Chip/Software_properties Boolean true\r\nADD Workspaces/Default/ComponentEditorFilters/HW/Soc/File_sets Boolean true\r\nADD Workspaces/Default/ComponentEditorFilters/HW/Soc/Choices Boolean true\r\nADD Workspaces/Default/ComponentEditorFilters/HW/Soc/Model_parameters Boolean true\r\nADD Workspaces/Default/ComponentEditorFilters/HW/Soc/Parameters Boolean true\r\nADD Workspaces/Default/ComponentEditorFilters/HW/Soc/Memory_maps Boolean true\r\nADD Workspaces/Default/ComponentEditorFilters/HW/Soc/Address_spaces Boolean true\r\nADD Workspaces/Default/ComponentEditorFilters/HW/Soc/Views Boolean true\r\nADD Workspaces/Default/ComponentEditorFilters/HW/Soc/Software_views Boolean true\r\nADD Workspaces/Default/ComponentEditorFilters/HW/Soc/System_views Boolean true\r\nADD Workspaces/Default/ComponentEditorFilters/HW/Soc/Ports Boolean true\r\nADD Workspaces/Default/ComponentEditorFilters/HW/Soc/Bus_interfaces Boolean true\r\nADD Workspaces/Default/ComponentEditorFilters/HW/Soc/Channels Boolean true\r\nADD Workspaces/Default/ComponentEditorFilters/HW/Soc/Cpus Boolean true\r\nADD Workspaces/Default/ComponentEditorFilters/HW/Soc/Other_clock_drivers Boolean true\r\nADD Workspaces/Default/ComponentEditorFilters/HW/Soc/COM_interfaces Boolean true\r\nADD Workspaces/Default/ComponentEditorFilters/HW/Soc/Software_properties Boolean true\r\nADD Workspaces/Default/ComponentEditorFilters/HW/IP/File_sets Boolean true\r\nADD Workspaces/Default/ComponentEditorFilters/HW/IP/Choices Boolean true\r\nADD Workspaces/Default/ComponentEditorFilters/HW/IP/Model_parameters Boolean true\r\nADD Workspaces/Default/ComponentEditorFilters/HW/IP/Parameters Boolean true\r\nADD Workspaces/Default/ComponentEditorFilters/HW/IP/Memory_maps Boolean true\r\nADD Workspaces/Default/ComponentEditorFilters/HW/IP/Address_spaces Boolean true\r\nADD Workspaces/Default/ComponentEditorFilters/HW/IP/Views Boolean true\r\nADD Workspaces/Default/ComponentEditorFilters/HW/IP/Software_views Boolean true\r\nADD Workspaces/Default/ComponentEditorFilters/HW/IP/System_views Boolean true\r\nADD Workspaces/Default/ComponentEditorFilters/HW/IP/Ports Boolean true\r\nADD Workspaces/Default/ComponentEditorFilters/HW/IP/Bus_interfaces Boolean true\r\nADD Workspaces/Default/ComponentEditorFilters/HW/IP/Channels Boolean true\r\nADD Workspaces/Default/ComponentEditorFilters/HW/IP/Cpus Boolean true\r\nADD Workspaces/Default/ComponentEditorFilters/HW/IP/Other_clock_drivers Boolean true\r\nADD Workspaces/Default/ComponentEditorFilters/HW/IP/COM_interfaces Boolean true\r\nADD Workspaces/Default/ComponentEditorFilters/HW/IP/Software_properties Boolean true\r\nADD Workspaces/Default/ComponentEditorFilters/HW/Prodhier_count/File_sets Boolean true\r\nADD Workspaces/Default/ComponentEditorFilters/HW/Prodhier_count/Choices Boolean true\r\nADD Workspaces/Default/ComponentEditorFilters/HW/Prodhier_count/Model_parameters Boolean true\r\nADD Workspaces/Default/ComponentEditorFilters/HW/Prodhier_count/Parameters Boolean true\r\nADD Workspaces/Default/ComponentEditorFilters/HW/Prodhier_count/Memory_maps Boolean true\r\nADD Workspaces/Default/ComponentEditorFilters/HW/Prodhier_count/Address_spaces Boolean true\r\nADD Workspaces/Default/ComponentEditorFilters/HW/Prodhier_count/Views Boolean true\r\nADD Workspaces/Default/ComponentEditorFilters/HW/Prodhier_count/Software_views Boolean true\r\nADD Workspaces/Default/ComponentEditorFilters/HW/Prodhier_count/System_views Boolean true\r\nADD Workspaces/Default/ComponentEditorFilters/HW/Prodhier_count/Ports Boolean true\r\nADD Workspaces/Default/ComponentEditorFilters/HW/Prodhier_count/Bus_interfaces Boolean true\r\nADD Workspaces/Default/ComponentEditorFilters/HW/Prodhier_count/Channels Boolean true\r\nADD Workspaces/Default/ComponentEditorFilters/HW/Prodhier_count/Cpus Boolean true\r\nADD Workspaces/Default/ComponentEditorFilters/HW/Prodhier_count/Other_clock_drivers Boolean true\r\nADD Workspaces/Default/ComponentEditorFilters/HW/Prodhier_count/COM_interfaces Boolean true\r\nADD Workspaces/Default/ComponentEditorFilters/HW/Prodhier_count/Software_properties Boolean true\r\nADD Workspaces/Default/ComponentEditorFilters/SW/File_sets Boolean true\r\nADD Workspaces/Default/ComponentEditorFilters/SW/Choices Boolean true\r\nADD Workspaces/Default/ComponentEditorFilters/SW/Parameters Boolean true\r\nADD Workspaces/Default/ComponentEditorFilters/SW/Software_views Boolean true\r\nADD Workspaces/Default/ComponentEditorFilters/SW/COM_interfaces Boolean true\r\nADD Workspaces/Default/ComponentEditorFilters/SW/API_interfaces Boolean true\r\nADD Workspaces/Default/ComponentEditorFilters/SW/Software_properties Boolean true\r\nADD Workspaces/Design/ComponentEditorFilters/HW/Global/File_sets Boolean true\r\nADD Workspaces/Design/ComponentEditorFilters/HW/Global/Choices Boolean true\r\nADD Workspaces/Design/ComponentEditorFilters/HW/Global/Model_parameters Boolean true\r\nADD Workspaces/Design/ComponentEditorFilters/HW/Global/Parameters Boolean true\r\nADD Workspaces/Design/ComponentEditorFilters/HW/Global/Memory_maps Boolean true\r\nADD Workspaces/Design/ComponentEditorFilters/HW/Global/Address_spaces Boolean true\r\nADD Workspaces/Design/ComponentEditorFilters/HW/Global/Views Boolean true\r\nADD Workspaces/Design/ComponentEditorFilters/HW/Global/Software_views Boolean true\r\nADD Workspaces/Design/ComponentEditorFilters/HW/Global/System_views Boolean true\r\nADD Workspaces/Design/ComponentEditorFilters/HW/Global/Ports Boolean true\r\nADD Workspaces/Design/ComponentEditorFilters/HW/Global/Bus_interfaces Boolean true\r\nADD Workspaces/Design/ComponentEditorFilters/HW/Global/Channels Boolean true\r\nADD Workspaces/Design/ComponentEditorFilters/HW/Global/Cpus Boolean true\r\nADD Workspaces/Design/ComponentEditorFilters/HW/Global/Other_clock_drivers Boolean true\r\nADD Workspaces/Design/ComponentEditorFilters/HW/Global/COM_interfaces Boolean true\r\nADD Workspaces/Design/ComponentEditorFilters/HW/Global/Software_properties Boolean true\r\nADD Workspaces/Design/ComponentEditorFilters/HW/Product/File_sets Boolean true\r\nADD Workspaces/Design/ComponentEditorFilters/HW/Product/Choices Boolean true\r\nADD Workspaces/Design/ComponentEditorFilters/HW/Product/Model_parameters Boolean true\r\nADD Workspaces/Design/ComponentEditorFilters/HW/Product/Parameters Boolean true\r\nADD Workspaces/Design/ComponentEditorFilters/HW/Product/Memory_maps Boolean true\r\nADD Workspaces/Design/ComponentEditorFilters/HW/Product/Address_spaces Boolean true\r\nADD Workspaces/Design/ComponentEditorFilters/HW/Product/Views Boolean true\r\nADD Workspaces/Design/ComponentEditorFilters/HW/Product/Software_views Boolean true\r\nADD Workspaces/Design/ComponentEditorFilters/HW/Product/System_views Boolean true\r\nADD Workspaces/Design/ComponentEditorFilters/HW/Product/Ports Boolean true\r\nADD Workspaces/Design/ComponentEditorFilters/HW/Product/Bus_interfaces Boolean true\r\nADD Workspaces/Design/ComponentEditorFilters/HW/Product/Channels Boolean true\r\nADD Workspaces/Design/ComponentEditorFilters/HW/Product/Cpus Boolean true\r\nADD Workspaces/Design/ComponentEditorFilters/HW/Product/Other_clock_drivers Boolean true\r\nADD Workspaces/Design/ComponentEditorFilters/HW/Product/COM_interfaces Boolean true\r\nADD Workspaces/Design/ComponentEditorFilters/HW/Product/Software_properties Boolean true\r\nADD Workspaces/Design/ComponentEditorFilters/HW/Board/File_sets Boolean true\r\nADD Workspaces/Design/ComponentEditorFilters/HW/Board/Choices Boolean true\r\nADD Workspaces/Design/ComponentEditorFilters/HW/Board/Model_parameters Boolean true\r\nADD Workspaces/Design/ComponentEditorFilters/HW/Board/Parameters Boolean true\r\nADD Workspaces/Design/ComponentEditorFilters/HW/Board/Memory_maps Boolean true\r\nADD Workspaces/Design/ComponentEditorFilters/HW/Board/Address_spaces Boolean true\r\nADD Workspaces/Design/ComponentEditorFilters/HW/Board/Views Boolean true\r\nADD Workspaces/Design/ComponentEditorFilters/HW/Board/Software_views Boolean true\r\nADD Workspaces/Design/ComponentEditorFilters/HW/Board/System_views Boolean true\r\nADD Workspaces/Design/ComponentEditorFilters/HW/Board/Ports Boolean true\r\nADD Workspaces/Design/ComponentEditorFilters/HW/Board/Bus_interfaces Boolean true\r\nADD Workspaces/Design/ComponentEditorFilters/HW/Board/Channels Boolean true\r\nADD Workspaces/Design/ComponentEditorFilters/HW/Board/Cpus Boolean true\r\nADD Workspaces/Design/ComponentEditorFilters/HW/Board/Other_clock_drivers Boolean true\r\nADD Workspaces/Design/ComponentEditorFilters/HW/Board/COM_interfaces Boolean true\r\nADD Workspaces/Design/ComponentEditorFilters/HW/Board/Software_properties Boolean true\r\nADD Workspaces/Design/ComponentEditorFilters/HW/Chip/File_sets Boolean true\r\nADD Workspaces/Design/ComponentEditorFilters/HW/Chip/Choices Boolean true\r\nADD Workspaces/Design/ComponentEditorFilters/HW/Chip/Model_parameters Boolean true\r\nADD Workspaces/Design/ComponentEditorFilters/HW/Chip/Parameters Boolean true\r\nADD Workspaces/Design/ComponentEditorFilters/HW/Chip/Memory_maps Boolean true\r\nADD Workspaces/Design/ComponentEditorFilters/HW/Chip/Address_spaces Boolean true\r\nADD Workspaces/Design/ComponentEditorFilters/HW/Chip/Views Boolean true\r\nADD Workspaces/Design/ComponentEditorFilters/HW/Chip/Software_views Boolean true\r\nADD Workspaces/Design/ComponentEditorFilters/HW/Chip/System_views Boolean true\r\nADD Workspaces/Design/ComponentEditorFilters/HW/Chip/Ports Boolean true\r\nADD Workspaces/Design/ComponentEditorFilters/HW/Chip/Bus_interfaces Boolean true\r\nADD Workspaces/Design/ComponentEditorFilters/HW/Chip/Channels Boolean true\r\nADD Workspaces/Design/ComponentEditorFilters/HW/Chip/Cpus Boolean true\r\nADD Workspaces/Design/ComponentEditorFilters/HW/Chip/Other_clock_drivers Boolean true\r\nADD Workspaces/Design/ComponentEditorFilters/HW/Chip/COM_interfaces Boolean true\r\nADD Workspaces/Design/ComponentEditorFilters/HW/Chip/Software_properties Boolean true\r\nADD Workspaces/Design/ComponentEditorFilters/HW/Soc/File_sets Boolean true\r\nADD Workspaces/Design/ComponentEditorFilters/HW/Soc/Choices Boolean true\r\nADD Workspaces/Design/ComponentEditorFilters/HW/Soc/Model_parameters Boolean true\r\nADD Workspaces/Design/ComponentEditorFilters/HW/Soc/Parameters Boolean true\r\nADD Workspaces/Design/ComponentEditorFilters/HW/Soc/Memory_maps Boolean true\r\nADD Workspaces/Design/ComponentEditorFilters/HW/Soc/Address_spaces Boolean true\r\nADD Workspaces/Design/ComponentEditorFilters/HW/Soc/Views Boolean true\r\nADD Workspaces/Design/ComponentEditorFilters/HW/Soc/Software_views Boolean true\r\nADD Workspaces/Design/ComponentEditorFilters/HW/Soc/System_views Boolean true\r\nADD Workspaces/Design/ComponentEditorFilters/HW/Soc/Ports Boolean true\r\nADD Workspaces/Design/ComponentEditorFilters/HW/Soc/Bus_interfaces Boolean true\r\nADD Workspaces/Design/ComponentEditorFilters/HW/Soc/Channels Boolean true\r\nADD Workspaces/Design/ComponentEditorFilters/HW/Soc/Cpus Boolean true\r\nADD Workspaces/Design/ComponentEditorFilters/HW/Soc/Other_clock_drivers Boolean true\r\nADD Workspaces/Design/ComponentEditorFilters/HW/Soc/COM_interfaces Boolean true\r\nADD Workspaces/Design/ComponentEditorFilters/HW/Soc/Software_properties Boolean true\r\nADD Workspaces/Design/ComponentEditorFilters/HW/IP/File_sets Boolean true\r\nADD Workspaces/Design/ComponentEditorFilters/HW/IP/Choices Boolean true\r\nADD Workspaces/Design/ComponentEditorFilters/HW/IP/Model_parameters Boolean true\r\nADD Workspaces/Design/ComponentEditorFilters/HW/IP/Parameters Boolean true\r\nADD Workspaces/Design/ComponentEditorFilters/HW/IP/Memory_maps Boolean true\r\nADD Workspaces/Design/ComponentEditorFilters/HW/IP/Address_spaces Boolean true\r\nADD Workspaces/Design/ComponentEditorFilters/HW/IP/Views Boolean true\r\nADD Workspaces/Design/ComponentEditorFilters/HW/IP/Software_views Boolean true\r\nADD Workspaces/Design/ComponentEditorFilters/HW/IP/System_views Boolean true\r\nADD Workspaces/Design/ComponentEditorFilters/HW/IP/Ports Boolean true\r\nADD Workspaces/Design/ComponentEditorFilters/HW/IP/Bus_interfaces Boolean true\r\nADD Workspaces/Design/ComponentEditorFilters/HW/IP/Channels Boolean true\r\nADD Workspaces/Design/ComponentEditorFilters/HW/IP/Cpus Boolean true\r\nADD Workspaces/Design/ComponentEditorFilters/HW/IP/Other_clock_drivers Boolean true\r\nADD Workspaces/Design/ComponentEditorFilters/HW/IP/COM_interfaces Boolean true\r\nADD Workspaces/Design/ComponentEditorFilters/HW/IP/Software_properties Boolean true\r\nADD Workspaces/Design/ComponentEditorFilters/HW/Prodhier_count/File_sets Boolean true\r\nADD Workspaces/Design/ComponentEditorFilters/HW/Prodhier_count/Choices Boolean true\r\nADD Workspaces/Design/ComponentEditorFilters/HW/Prodhier_count/Model_parameters Boolean true\r\nADD Workspaces/Design/ComponentEditorFilters/HW/Prodhier_count/Parameters Boolean true\r\nADD Workspaces/Design/ComponentEditorFilters/HW/Prodhier_count/Memory_maps Boolean true\r\nADD Workspaces/Design/ComponentEditorFilters/HW/Prodhier_count/Address_spaces Boolean true\r\nADD Workspaces/Design/ComponentEditorFilters/HW/Prodhier_count/Views Boolean true\r\nADD Workspaces/Design/ComponentEditorFilters/HW/Prodhier_count/Software_views Boolean true\r\nADD Workspaces/Design/ComponentEditorFilters/HW/Prodhier_count/System_views Boolean true\r\nADD Workspaces/Design/ComponentEditorFilters/HW/Prodhier_count/Ports Boolean true\r\nADD Workspaces/Design/ComponentEditorFilters/HW/Prodhier_count/Bus_interfaces Boolean true\r\nADD Workspaces/Design/ComponentEditorFilters/HW/Prodhier_count/Channels Boolean true\r\nADD Workspaces/Design/ComponentEditorFilters/HW/Prodhier_count/Cpus Boolean true\r\nADD Workspaces/Design/ComponentEditorFilters/HW/Prodhier_count/Other_clock_drivers Boolean true\r\nADD Workspaces/Design/ComponentEditorFilters/HW/Prodhier_count/COM_interfaces Boolean true\r\nADD Workspaces/Design/ComponentEditorFilters/HW/Prodhier_count/Software_properties Boolean true\r\nADD Workspaces/Design/ComponentEditorFilters/SW/File_sets Boolean true\r\nADD Workspaces/Design/ComponentEditorFilters/SW/Choices Boolean true\r\nADD Workspaces/Design/ComponentEditorFilters/SW/Parameters Boolean true\r\nADD Workspaces/Design/ComponentEditorFilters/SW/Software_views Boolean true\r\nADD Workspaces/Design/ComponentEditorFilters/SW/COM_interfaces Boolean true\r\nADD Workspaces/Design/ComponentEditorFilters/SW/API_interfaces Boolean true\r\nADD Workspaces/Design/ComponentEditorFilters/SW/Software_properties Boolean true\r\n\r\nVERSION 2.7.219.0\r\nRENAME Workspaces/Default/ComponentEditorFilters/HW/Global/File_sets Workspaces/Default/ComponentEditorFilters/HW/Flat/File_sets\r\nRENAME Workspaces/Default/ComponentEditorFilters/HW/Global/Choices Workspaces/Default/ComponentEditorFilters/HW/Flat/Choices\r\nRENAME Workspaces/Default/ComponentEditorFilters/HW/Global/Model_parameters Workspaces/Default/ComponentEditorFilters/HW/Flat/Model_parameters\r\nRENAME Workspaces/Default/ComponentEditorFilters/HW/Global/Parameters Workspaces/Default/ComponentEditorFilters/HW/Flat/Parameters\r\nRENAME Workspaces/Default/ComponentEditorFilters/HW/Global/Memory_maps Workspaces/Default/ComponentEditorFilters/HW/Flat/Memory_maps\r\nRENAME Workspaces/Default/ComponentEditorFilters/HW/Global/Address_spaces Workspaces/Default/ComponentEditorFilters/HW/Flat/Address_spaces\r\nRENAME Workspaces/Default/ComponentEditorFilters/HW/Global/Views Boolean Workspaces/Default/ComponentEditorFilters/HW/Flat/Views Boolean\r\nRENAME Workspaces/Default/ComponentEditorFilters/HW/Global/Software_views Workspaces/Default/ComponentEditorFilters/HW/Flat/Software_views\r\nRENAME Workspaces/Default/ComponentEditorFilters/HW/Global/System_views Workspaces/Default/ComponentEditorFilters/HW/Flat/System_views\r\nRENAME Workspaces/Default/ComponentEditorFilters/HW/Global/Ports Workspaces/Default/ComponentEditorFilters/HW/Flat/Ports\r\nRENAME Workspaces/Default/ComponentEditorFilters/HW/Global/Bus_interfaces Workspaces/Default/ComponentEditorFilters/HW/Flat/Bus_interfaces\r\nRENAME Workspaces/Default/ComponentEditorFilters/HW/Global/Channels Boolean Workspaces/Default/ComponentEditorFilters/HW/Flat/Channels Boolean\r\nRENAME Workspaces/Default/ComponentEditorFilters/HW/Global/Cpus Workspaces/Default/ComponentEditorFilters/HW/Flat/Cpus\r\nRENAME Workspaces/Default/ComponentEditorFilters/HW/Global/Other_clock_drivers Workspaces/Default/ComponentEditorFilters/HW/Flat/Other_clock_drivers\r\nRENAME Workspaces/Default/ComponentEditorFilters/HW/Global/COM_interfaces Workspaces/Default/ComponentEditorFilters/HW/Flat/COM_interfaces\r\nRENAME Workspaces/Default/ComponentEditorFilters/HW/Global/Software_properties Workspaces/Default/ComponentEditorFilters/HW/Flat/Software_properties\r\nRENAME Workspaces/Design/ComponentEditorFilters/HW/Global/File_sets Workspaces/Design/ComponentEditorFilters/HW/Flat/File_sets\r\nRENAME Workspaces/Design/ComponentEditorFilters/HW/Global/Choices Workspaces/Design/ComponentEditorFilters/HW/Flat/Choices\r\nRENAME Workspaces/Design/ComponentEditorFilters/HW/Global/Model_parameters Workspaces/Design/ComponentEditorFilters/HW/Flat/Model_parameters\r\nRENAME Workspaces/Design/ComponentEditorFilters/HW/Global/Parameters Workspaces/Design/ComponentEditorFilters/HW/Flat/Parameters\r\nRENAME Workspaces/Design/ComponentEditorFilters/HW/Global/Memory_maps Workspaces/Design/ComponentEditorFilters/HW/Flat/Memory_maps\r\nRENAME Workspaces/Design/ComponentEditorFilters/HW/Global/Address_spaces Workspaces/Design/ComponentEditorFilters/HW/Flat/Address_spaces\r\nRENAME Workspaces/Design/ComponentEditorFilters/HW/Global/Views Boolean Workspaces/Design/ComponentEditorFilters/HW/Flat/Views Boolean\r\nRENAME Workspaces/Design/ComponentEditorFilters/HW/Global/Software_views Workspaces/Design/ComponentEditorFilters/HW/Flat/Software_views\r\nRENAME Workspaces/Design/ComponentEditorFilters/HW/Global/System_views Workspaces/Design/ComponentEditorFilters/HW/Flat/System_views\r\nRENAME Workspaces/Design/ComponentEditorFilters/HW/Global/Ports Workspaces/Design/ComponentEditorFilters/HW/Flat/Ports\r\nRENAME Workspaces/Design/ComponentEditorFilters/HW/Global/Bus_interfaces Workspaces/Design/ComponentEditorFilters/HW/Flat/Bus_interfaces\r\nRENAME Workspaces/Design/ComponentEditorFilters/HW/Global/Channels Boolean Workspaces/Design/ComponentEditorFilters/HW/Flat/Channels Boolean\r\nRENAME Workspaces/Design/ComponentEditorFilters/HW/Global/Cpus Workspaces/Design/ComponentEditorFilters/HW/Flat/Cpus\r\nRENAME Workspaces/Design/ComponentEditorFilters/HW/Global/Other_clock_drivers Workspaces/Design/ComponentEditorFilters/HW/Flat/Other_clock_drivers\r\nRENAME Workspaces/Design/ComponentEditorFilters/HW/Global/COM_interfaces Workspaces/Design/ComponentEditorFilters/HW/Flat/COM_interfaces\r\nRENAME Workspaces/Design/ComponentEditorFilters/HW/Global/Software_properties Workspaces/Design/ComponentEditorFilters/HW/Flat/Software_properties\r\n\r\nVERSION 2.7.615.0\r\nADD Workspaces/Default/ComponentEditorFilters/HW/Flat/Remap_states Boolean true\r\nADD Workspaces/Default/ComponentEditorFilters/HW/Product/Remap_states Boolean true\r\nADD Workspaces/Default/ComponentEditorFilters/HW/Board/Remap_states Boolean true\r\nADD Workspaces/Default/ComponentEditorFilters/HW/Chip/Remap_states Boolean true\r\nADD Workspaces/Default/ComponentEditorFilters/HW/Soc/Remap_states Boolean true\r\nADD Workspaces/Default/ComponentEditorFilters/HW/IP/Remap_states Boolean true\r\nADD Workspaces/Design/ComponentEditorFilters/HW/Flat/Remap_states Boolean true\r\nADD Workspaces/Design/ComponentEditorFilters/HW/Product/Remap_states Boolean true\r\nADD Workspaces/Design/ComponentEditorFilters/HW/Board/Remap_states Boolean true\r\nADD Workspaces/Design/ComponentEditorFilters/HW/Chip/Remap_states Boolean true\r\nADD Workspaces/Design/ComponentEditorFilters/HW/Soc/Remap_states Boolean true\r\nADD Workspaces/Design/ComponentEditorFilters/HW/IP/Remap_states Boolean true\r\n\r\nVERSION 2.8.0.0\r\nADD General/showExitScreen Boolean true\r\n\r\nVERSION 2.8.630.0\r\nREMOVE Workspaces/Default/ComponentEditorFilters/HW/Flat/Model_parameters\r\nREMOVE Workspaces/Default/ComponentEditorFilters/HW/Product/Model_parameters\r\nREMOVE Workspaces/Default/ComponentEditorFilters/HW/Board/Model_parameters\r\nREMOVE Workspaces/Default/ComponentEditorFilters/HW/Chip/Model_parameters\r\nREMOVE Workspaces/Default/ComponentEditorFilters/HW/Soc/Model_parameters\r\nREMOVE Workspaces/Default/ComponentEditorFilters/HW/IP/Model_parameters\r\nREMOVE Workspaces/Design/ComponentEditorFilters/HW/Flat/Model_parameters\r\nREMOVE Workspaces/Design/ComponentEditorFilters/HW/Product/Model_parameters\r\nREMOVE Workspaces/Design/ComponentEditorFilters/HW/Board/Model_parameters\r\nREMOVE Workspaces/Design/ComponentEditorFilters/HW/Chip/Model_parameters\r\nREMOVE Workspaces/Design/ComponentEditorFilters/HW/Soc/Model_parameters\r\nREMOVE Workspaces/Design/ComponentEditorFilters/HW/IP/Model_parameters\r\nADD Workspaces/Default/ComponentEditorFilters/HW/Flat/Instantiations Boolean true\r\nADD Workspaces/Default/ComponentEditorFilters/HW/Product/Instantiations Boolean true\r\nADD Workspaces/Default/ComponentEditorFilters/HW/Board/Instantiations Boolean true\r\nADD Workspaces/Default/ComponentEditorFilters/HW/Chip/Instantiations Boolean true\r\nADD Workspaces/Default/ComponentEditorFilters/HW/Soc/Instantiations Boolean true\r\nADD Workspaces/Default/ComponentEditorFilters/HW/IP/Instantiations Boolean true\r\nADD Workspaces/Design/ComponentEditorFilters/HW/Flat/Instantiations Boolean true\r\nADD Workspaces/Design/ComponentEditorFilters/HW/Product/Instantiations Boolean true\r\nADD Workspaces/Design/ComponentEditorFilters/HW/Board/Instantiations Boolean true\r\nADD Workspaces/Design/ComponentEditorFilters/HW/Chip/Instantiations Boolean true\r\nADD Workspaces/Design/ComponentEditorFilters/HW/Soc/Instantiations Boolean true\r\nADD Workspaces/Design/ComponentEditorFilters/HW/IP/Instantiations Boolean true\r\n\r\nVERSION 3.0.30.0\r\nADD Workspaces/Default/AdHocEditorVisibility Boolean true\r\nADD Workspaces/Design/AdHocEditorVisibility Boolean true\r\n\r\nVERSION 3.3.340.0\r\nADD Workspaces/Default/LibraryFilters/Type/ShowCatalogs Boolean true\r\nADD Workspaces/Design/LibraryFilters/Type/ShowCatalogs Boolean true\r\nADD Workspaces/Default/LibraryFilters/Type/ShowApis Boolean true\r\nADD Workspaces/Design/LibraryFilters/Type/ShowApis Boolean true\r\n\r\nVERSION 3.3.780.0\r\nADD Workspaces/Default/ComponentEditorFilters/HW/Flat/Instantiations Boolean true\r\nADD Workspaces/Default/ComponentEditorFilters/HW/Product/Instantiations Boolean true\r\nADD Workspaces/Default/ComponentEditorFilters/HW/Board/Instantiations Boolean true\r\nADD Workspaces/Default/ComponentEditorFilters/HW/Chip/Instantiations Boolean true\r\nADD Workspaces/Default/ComponentEditorFilters/HW/Soc/Instantiations Boolean true\r\nADD Workspaces/Default/ComponentEditorFilters/HW/IP/Instantiations Boolean true\r\nADD Workspaces/Design/ComponentEditorFilters/HW/Flat/Instantiations Boolean true\r\nADD Workspaces/Design/ComponentEditorFilters/HW/Product/Instantiations Boolean true\r\nADD Workspaces/Design/ComponentEditorFilters/HW/Board/Instantiations Boolean true\r\nADD Workspaces/Design/ComponentEditorFilters/HW/Chip/Instantiations Boolean true\r\nADD Workspaces/Design/ComponentEditorFilters/HW/Soc/Instantiations Boolean true\r\nADD Workspaces/Design/ComponentEditorFilters/HW/IP/Instantiations Boolean true\r\nADD Workspaces/Default/ComponentEditorFilters/SW/Instantiations Boolean true\r\nADD Workspaces/Design/ComponentEditorFilters/SW/Instantiations Boolean true\r\nADD Workspaces/Default/ComponentEditorFilters/HW/Flat/Views Boolean true\r\nADD Workspaces/Default/ComponentEditorFilters/HW/Product/Views Boolean true\r\nADD Workspaces/Default/ComponentEditorFilters/HW/Board/Views Boolean true\r\nADD Workspaces/Default/ComponentEditorFilters/HW/Chip/Views Boolean true\r\nADD Workspaces/Default/ComponentEditorFilters/HW/Soc/Views Boolean true\r\nADD Workspaces/Default/ComponentEditorFilters/HW/IP/Views Boolean true\r\nADD Workspaces/Design/ComponentEditorFilters/HW/Flat/Views Boolean true\r\nADD Workspaces/Design/ComponentEditorFilters/HW/Product/Views Boolean true\r\nADD Workspaces/Design/ComponentEditorFilters/HW/Board/Views Boolean true\r\nADD Workspaces/Design/ComponentEditorFilters/HW/Chip/Views Boolean true\r\nADD Workspaces/Design/ComponentEditorFilters/HW/Soc/Views Boolean true\r\nADD Workspaces/Design/ComponentEditorFilters/HW/IP/Views Boolean true\r\nADD Workspaces/Default/ComponentEditorFilters/HW/Flat/Channels Boolean true\r\nADD Workspaces/Default/ComponentEditorFilters/HW/Product/Channels Boolean true\r\nADD Workspaces/Default/ComponentEditorFilters/HW/Board/Channels Boolean true\r\nADD Workspaces/Default/ComponentEditorFilters/HW/Chip/Channels Boolean true\r\nADD Workspaces/Default/ComponentEditorFilters/HW/Soc/Channels Boolean true\r\nADD Workspaces/Default/ComponentEditorFilters/HW/IP/Channels Boolean true\r\nADD Workspaces/Design/ComponentEditorFilters/HW/Flat/Channels Boolean true\r\nADD Workspaces/Design/ComponentEditorFilters/HW/Product/Channels Boolean true\r\nADD Workspaces/Design/ComponentEditorFilters/HW/Board/Channels Boolean true\r\nADD Workspaces/Design/ComponentEditorFilters/HW/Chip/Channels Boolean true\r\nADD Workspaces/Design/ComponentEditorFilters/HW/Soc/Channels Boolean true\r\nADD Workspaces/Design/ComponentEditorFilters/HW/IP/Channels Boolean true\r\nADD Workspaces/Default/ComponentEditorFilters/HW/Flat/Remap_states Boolean true\r\nADD Workspaces/Default/ComponentEditorFilters/HW/Product/Remap_states Boolean true\r\nADD Workspaces/Default/ComponentEditorFilters/HW/Board/Remap_states Boolean true\r\nADD Workspaces/Default/ComponentEditorFilters/HW/Chip/Remap_states Boolean true\r\nADD Workspaces/Default/ComponentEditorFilters/HW/Soc/Remap_states Boolean true\r\nADD Workspaces/Default/ComponentEditorFilters/HW/IP/Remap_states Boolean true\r\nADD Workspaces/Design/ComponentEditorFilters/HW/Flat/Remap_states Boolean true\r\nADD Workspaces/Design/ComponentEditorFilters/HW/Product/Remap_states Boolean true\r\nADD Workspaces/Design/ComponentEditorFilters/HW/Board/Remap_states Boolean true\r\nADD Workspaces/Design/ComponentEditorFilters/HW/Chip/Remap_states Boolean true\r\nADD Workspaces/Design/ComponentEditorFilters/HW/Soc/Remap_states Boolean true\r\nADD Workspaces/Design/ComponentEditorFilters/HW/IP/Remap_states Boolean true\r\nADD Workspaces/Default/ComponentEditorFilters/SW/Views Boolean true\r\nADD Workspaces/Design/ComponentEditorFilters/SW/Views Boolean true\r\nREMOVE Workspaces/Default/ComponentEditorFilters/HW/Flat/Software_views\r\nREMOVE Workspaces/Default/ComponentEditorFilters/HW/Product/Software_views \r\nREMOVE Workspaces/Default/ComponentEditorFilters/HW/Board/Software_views\r\nREMOVE Workspaces/Default/ComponentEditorFilters/HW/Chip/Software_views\r\nREMOVE Workspaces/Default/ComponentEditorFilters/HW/Soc/Software_views\r\nREMOVE Workspaces/Default/ComponentEditorFilters/HW/IP/Software_views\r\nREMOVE Workspaces/Design/ComponentEditorFilters/HW/Flat/Software_views \r\nREMOVE Workspaces/Design/ComponentEditorFilters/HW/Product/Software_views\r\nREMOVE Workspaces/Design/ComponentEditorFilters/HW/Board/Software_views\r\nREMOVE Workspaces/Design/ComponentEditorFilters/HW/Chip/Software_views\r\nREMOVE Workspaces/Design/ComponentEditorFilters/HW/Soc/Software_views\r\nREMOVE Workspaces/Design/ComponentEditorFilters/HW/IP/Software_views\r\nREMOVE Workspaces/Default/ComponentEditorFilters/SW/Software_views\r\nREMOVE Workspaces/Design/ComponentEditorFilters/SW/Software_views\r\n\r\nVERSION 3.4.116.0\r\nADD Workspaces/Default/ComponentEditorFilters/HW/Flat/Indirect_interfaces Boolean true\r\nADD Workspaces/Default/ComponentEditorFilters/HW/Product/Indirect_interfaces Boolean true\r\nADD Workspaces/Default/ComponentEditorFilters/HW/Board/Indirect_interfaces Boolean true\r\nADD Workspaces/Default/ComponentEditorFilters/HW/Chip/Indirect_interfaces Boolean true\r\nADD Workspaces/Default/ComponentEditorFilters/HW/Soc/Indirect_interfaces Boolean true\r\nADD Workspaces/Default/ComponentEditorFilters/HW/IP/Indirect_interfaces Boolean true\r\nADD Workspaces/Design/ComponentEditorFilters/HW/Flat/Indirect_interfaces Boolean true\r\nADD Workspaces/Design/ComponentEditorFilters/HW/Product/Indirect_interfaces Boolean true\r\nADD Workspaces/Design/ComponentEditorFilters/HW/Board/Indirect_interfaces Boolean true\r\nADD Workspaces/Design/ComponentEditorFilters/HW/Chip/Indirect_interfaces Boolean true\r\nADD Workspaces/Design/ComponentEditorFilters/HW/Soc/Indirect_interfaces Boolean true\r\nADD Workspaces/Design/ComponentEditorFilters/HW/IP/Indirect_interfaces Boolean true\r\n\r\nVERSION 3.6.120.0\r\nADD Workspaces/Default/VendorExtensionVisibility Boolean false\r\nADD Workspaces/Design/VendorExtensionVisibility Boolean false\r\n\r\nVERSION 3.6.180.0\r\nADD Workspaces/Default/ComponentEditorFilters/HW/Flat/Reset_types Boolean true\r\nADD Workspaces/Default/ComponentEditorFilters/HW/Product/Reset_types Boolean true\r\nADD Workspaces/Default/ComponentEditorFilters/HW/Board/Reset_types Boolean true\r\nADD Workspaces/Default/ComponentEditorFilters/HW/Chip/Reset_types Boolean true\r\nADD Workspaces/Default/ComponentEditorFilters/HW/Soc/Reset_types Boolean true\r\nADD Workspaces/Default/ComponentEditorFilters/HW/IP/Reset_types Boolean true\r\nADD Workspaces/Design/ComponentEditorFilters/HW/Flat/Reset_types Boolean true\r\nADD Workspaces/Design/ComponentEditorFilters/HW/Product/Reset_types Boolean true\r\nADD Workspaces/Design/ComponentEditorFilters/HW/Board/Reset_types Boolean true\r\nADD Workspaces/Design/ComponentEditorFilters/HW/Chip/Reset_types Boolean true\r\nADD Workspaces/Design/ComponentEditorFilters/HW/Soc/Reset_types Boolean true\r\nADD Workspaces/Design/ComponentEditorFilters/HW/IP/Reset_types Boolean true\r\n\r\nVERSION 3.8.595\r\nADD Workspaces/Default/ScriptVisibility Boolean true\r\nADD Workspaces/Design/ScriptVisibility Boolean true\r\n\r\nVERSION 3.9.571.0\r\nREMOVE General/showExitScreen\r\n\r\nVERSION 3.11.269.0\r\nREMOVE Workspaces/Default/AdHocVisibility\r\nREMOVE Workspaces/Design/AdHocVisibility\r\n\r\nVERSION 3.11.355.0\r\nREMOVE Workspaces/Default/PreviewVisibility\r\nREMOVE Workspaces/Design/PreviewVisibility\r\n\r\nVERSION 3.11.392.0\r\nADD PreviewWidget/Hidden Boolean false\r\n\r\nVERSION 3.11.422.0\r\nREMOVE Workspaces/Default/ScriptVisibility\r\nREMOVE Workspaces/Design/ScriptVisibility\r\n\r\nVERSION 3.12.24.0\r\nADD FileTypes/vhdlSource2002 String vhdl;vhd\r\nADD FileTypes/vhdlSource2008 String vhdl;vhd\r\nADD FileTypes/systemVerilogSource-2009 String sv\r\nADD FileTypes/systemVerilogSource-2012 String sv\r\nADD FileTypes/systemVerilogSource-2017 String sv\r\nADD FileTypes/vhdlAmsSource String\r\nADD FileTypes/verilogAmsSource String\r\nADD FileTypes/systemCAmsSource String\r\nADD FileTypes/libertySource String\r\nADD FileTypes/spiceSource String\r\nADD FileTypes/systemRDL String\r\nADD FileTypes/systemRDL-1.0 String\r\nADD FileTypes/systemRDL-2.0 String\r\nADD FileTypes/systemCSource-2.3 String\r\nADD FileTypes/systemCSourceBinaryLibrary String\r\n\r\nVERSION 3.12.102.0\r\nADD General/Revision String 1685-2022\r\n\r\nVERSION 3.12.672.0\r\nADD Workspaces/Default/LibraryFilters/Validity/ShowValid Boolean true\r\nADD Workspaces/Default/LibraryFilters/Validity/ShowErrors Boolean true\r\nADD Workspaces/Design/LibraryFilters/Validity/ShowValid Boolean true\r\nADD Workspaces/Design/LibraryFilters/Validity/ShowErrors Boolean true\r\n\r\nVERSION 3.12.1134.0\r\nADD Workspaces/Default/LibraryFilters/Revision/ShowStd14 Boolean true\r\nADD Workspaces/Default/LibraryFilters/Revision/ShowStd22 Boolean true\r\nADD Workspaces/Design/LibraryFilters/Revision/ShowStd14 Boolean true\r\nADD Workspaces/Design/LibraryFilters/Revision/ShowStd22 Boolean true\r\n\r\nVERSION 3.13.79\r\nADD General/EditorLocking Boolean false\r\n\r\nVERSION 3.13.525.0\r\nADD Workspaces/Default/ComponentEditorFilters/HW/Flat/Power_domains Boolean true\r\nADD Workspaces/Default/ComponentEditorFilters/HW/Product/Power_domains Boolean true\r\nADD Workspaces/Default/ComponentEditorFilters/HW/Board/Power_domains Boolean true\r\nADD Workspaces/Default/ComponentEditorFilters/HW/Chip/Power_domains Boolean true\r\nADD Workspaces/Default/ComponentEditorFilters/HW/Soc/Power_domains Boolean true\r\nADD Workspaces/Default/ComponentEditorFilters/HW/IP/Power_domains Boolean true\r\nADD Workspaces/Design/ComponentEditorFilters/HW/Flat/Power_domains Boolean true\r\nADD Workspaces/Design/ComponentEditorFilters/HW/Product/Power_domains Boolean true\r\nADD Workspaces/Design/ComponentEditorFilters/HW/Board/Power_domains Boolean true\r\nADD Workspaces/Design/ComponentEditorFilters/HW/Chip/Power_domains Boolean true\r\nADD Workspaces/Design/ComponentEditorFilters/HW/Soc/Power_domains Boolean true\r\nADD Workspaces/Design/ComponentEditorFilters/HW/IP/Power_domains Boolean true\r\n\r\nADD Workspaces/Default/ComponentEditorFilters/HW/Flat/Modes Boolean true\r\nADD Workspaces/Default/ComponentEditorFilters/HW/Product/Modes Boolean true\r\nADD Workspaces/Default/ComponentEditorFilters/HW/Board/Modes Boolean true\r\nADD Workspaces/Default/ComponentEditorFilters/HW/Chip/Modes Boolean true\r\nADD Workspaces/Default/ComponentEditorFilters/HW/Soc/Modes Boolean true\r\nADD Workspaces/Default/ComponentEditorFilters/HW/IP/Modes Boolean true\r\nADD Workspaces/Design/ComponentEditorFilters/HW/Flat/Modes Boolean true\r\nADD Workspaces/Design/ComponentEditorFilters/HW/Product/Modes Boolean true\r\nADD Workspaces/Design/ComponentEditorFilters/HW/Board/Modes Boolean true\r\nADD Workspaces/Design/ComponentEditorFilters/HW/Chip/Modes Boolean true\r\nADD Workspaces/Design/ComponentEditorFilters/HW/Soc/Modes Boolean true\r\nADD Workspaces/Design/ComponentEditorFilters/HW/IP/Modes Boolean true\r\n\r\nADD Workspaces/Default/ComponentEditorFilters/HW/Flat/Type_definitions Boolean true\r\nADD Workspaces/Default/ComponentEditorFilters/HW/Product/Type_definitions Boolean true\r\nADD Workspaces/Default/ComponentEditorFilters/HW/Board/Type_definitions Boolean true\r\nADD Workspaces/Default/ComponentEditorFilters/HW/Chip/Type_definitions Boolean true\r\nADD Workspaces/Default/ComponentEditorFilters/HW/Soc/Type_definitions Boolean true\r\nADD Workspaces/Default/ComponentEditorFilters/HW/IP/Type_definitions Boolean true\r\nADD Workspaces/Design/ComponentEditorFilters/HW/Flat/Type_definitions Boolean true\r\nADD Workspaces/Design/ComponentEditorFilters/HW/Product/Type_definitions Boolean true\r\nADD Workspaces/Design/ComponentEditorFilters/HW/Board/Type_definitions Boolean true\r\nADD Workspaces/Design/ComponentEditorFilters/HW/Chip/Type_definitions Boolean true\r\nADD Workspaces/Design/ComponentEditorFilters/HW/Soc/Type_definitions Boolean true\r\nADD Workspaces/Design/ComponentEditorFilters/HW/IP/Type_definitions Boolean true"
  },
  {
    "path": "kactus.qrc",
    "content": "<RCC>\n    <qresource prefix=\"/icons\">\n        <file>common/graphics/hw-component.png</file>\n        <file>common/graphics/hier-hw-component.png</file>\n        <file>common/graphics/hw-design.png</file>\n        <file>common/graphics/hier-sw-component.png</file>\n        <file>common/graphics/sw-component48x48.png</file>\n        <file>common/graphics/sw-design48x48.png</file>\n        <file>common/graphics/system-component.png</file>\n        <file>common/graphics/abs-def.png</file>\n        <file>common/graphics/bus-def.png</file>\n        <file>common/graphics/file-new.png</file>\n        <file>common/graphics/file-save.png</file>\n        <file>common/graphics/file-save-as.png</file>\n        <file>common/graphics/file-save_all.png</file>\n        <file>common/graphics/file-print.png</file>\n        <file>common/graphics/tool-interconnection.png</file>\n        <file>common/graphics/tool-select.png</file>\n        <file>common/graphics/tool-interface.png</file>\n        <file>common/graphics/tool-drafting.png</file>\n        <file>common/graphics/tool-toggle_offpage.png</file>\n        <file>common/graphics/exclamation.png</file>\n        <file>common/graphics/remove.png</file>\n        <file>common/graphics/add.png</file>\n        <file>common/graphics/vhdl_gen.png</file>\n        <file>common/graphics/refresh.png</file>\n        <file>common/graphics/import.png</file>\n        <file>common/graphics/checkIntegrity.png</file>\n        <file>common/graphics/diagram-add-column.png</file>\n        <file>common/graphics/view-zoom_in.png</file>\n        <file>common/graphics/view-zoom_out.png</file>\n        <file>common/graphics/view-zoom_original.png</file>\n        <file>common/graphics/view-fit_best.png</file>\n        <file>common/graphics/system-exit.png</file>\n        <file>common/graphics/system-about.png</file>\n        <file>common/graphics/system-help.png</file>\n        <file>common/graphics/mcapi-endpoint.png</file>\n        <file>common/graphics/mcapi-endpoint_handle.png</file>\n        <file>common/graphics/mcapi-func.png</file>\n        <file>common/graphics/mcapi-node.png</file>\n        <file>common/graphics/mcapi-port.png</file>\n        <file>common/graphics/mcapi-type.png</file>\n        <file>common/graphics/connect.png</file>\n        <file>common/graphics/hierarchy.png</file>\n        <file>common/graphics/hierarchy-blue.png</file>\n        <file>common/graphics/imported.png</file>\n        <file>common/graphics/cleanup.png</file>\n        <file>common/graphics/new-com_definition.png</file>\n        <file>common/graphics/new-api_definition.png</file>\n        <file>common/graphics/appicon.png</file>\n        <file>common/graphics/settings-general.png</file>\n        <file>common/graphics/settings-code_editor.png</file>\n        <file>common/graphics/settings-file_types.png</file>\n        <file>common/graphics/settings-plugins.png</file>\n        <file>common/graphics/settings-environment_vars.png</file>\n        <file>common/graphics/triangle_arrow_down.png</file>\n        <file>common/graphics/triangle_arrow_right.png</file>\n        <file>common/graphics/protection-locked.png</file>\n        <file>common/graphics/protection-unlocked.png</file>\n        <file>common/graphics/edit-undo.png</file>\n        <file>common/graphics/edit-redo.png</file>\n        <file>common/graphics/edit.png</file>\n        <file>common/graphics/configuration.png</file>\n        <file>common/graphics/documentation.png</file>\n        <file>common/graphics/dockSelect.png</file>\n        <file>common/graphics/workspace.png</file>\n        <file>common/graphics/visibility.png</file>\n        <file>common/graphics/library.png</file>\n        <file>common/graphics/library-refresh.png</file>\n        <file>common/graphics/library-config.png</file>\n        <file>common/graphics/naming-policy.png</file>\n        <file>common/graphics/traffic-light_green.png</file>\n        <file>common/graphics/traffic-light_red.png</file>\n        <file>common/graphics/traffic-light_yellow.png</file>\n        <file>common/graphics/traffic-light_gray.png</file>\n        <file>common/graphics/traffic-light_green_gray.png</file>\n        <file>common/graphics/dependency_oneway.png</file>\n        <file>common/graphics/dependency_twoway.png</file>\n        <file>common/graphics/dependency_manual.png</file>\n        <file>common/graphics/dependency_auto.png</file>\n        <file>common/graphics/diff.png</file>\n        <file>common/graphics/external.png</file>\n        <file>common/graphics/plugin-source_analyzer.png</file>\n        <file>common/graphics/control-play.png</file>\n        <file>common/graphics/control-stop.png</file>\n        <file>common/graphics/output.png</file>\n        <file>common/graphics/input.png</file>\n        <file>common/graphics/inout.png</file>\n        <file>common/graphics/phantom.png</file>\n        <file>common/graphics/cross.png</file>\n        <file>common/graphics/grey_cross.png</file>\n        <file>common/graphics/balloon.png</file>\n        <file>common/graphics/pin--plus.png</file>\n        <file>common/graphics/star.png</file>\n        <file>common/graphics/viewConfiguration.png</file>\n        <file>common/graphics/memoryDesigner.png</file>\n        <file>common/graphics/addressSpaceFilter.png</file>\n        <file>common/graphics/compressMemoryItems.png</file>\n        <file>common/graphics/compressFields.png</file>\n        <file>common/graphics/extendFields.png</file>\n        <file>common/graphics/filterSegments.png</file>\n        <file>common/graphics/filterAddressBlocks.png</file>\n        <file>common/graphics/filterRegisters.png</file>\n        <file>common/graphics/filterFields.png</file>\n        <file>common/graphics/filterUnconnectedMemoryItems.png</file>\n        <file>common/graphics/opened-folder.png</file>\n        <file>common/graphics/catalog.png</file>\n        <file>common/graphics/generatorChain.png</file>\n        <file>common/graphics/exclamation--frame.png</file>\n        <file>common/graphics/paginator.png</file>\n        <file>common/graphics/export.png</file>\n        <file>common/graphics/delete.png</file>\n        <file>common/graphics/file.png</file>\n        <file>common/graphics/arrowRight.png</file>\n        <file>common/graphics/settings-visibilities.png</file>\n        <file>common/graphics/checkMark.png</file>\n        <file>common/graphics/busInterfaceMaster.png</file>\n        <file>common/graphics/busInterfaceMirroredMaster.png</file>\n        <file>common/graphics/busInterfaceMirroredSlave.png</file>\n        <file>common/graphics/busInterfaceMirroredSystem.png</file>\n        <file>common/graphics/busInterfaceMonitor.png</file>\n        <file>common/graphics/busInterfaceSlave.png</file>\n        <file>common/graphics/busInterfaceSystem.png</file>\n        <file>common/graphics/autoConnect.png</file>\n        <file>common/graphics/provides.png</file>\n        <file>common/graphics/requires.png</file>\n        <file>common/graphics/requires_provides.png</file>\n        <file>common/graphics/script-save.png</file>\n        <file>common/graphics/script-save-as.png</file>\n        <file>common/graphics/script-run-all.png</file>\n        <file>common/graphics/script-run-file.png</file>\n        <file>common/graphics/script-new.png</file>\n        <file>common/graphics/filter.png</file>\n        <file>common/graphics/box.png</file>\n        <file>common/graphics/circuit.png</file>\n        <file>common/graphics/chip.png</file>\n        <file>common/graphics/soc.png</file>\n        <file>common/graphics/square.png</file>\n        <file>common/graphics/capacitor.png</file>\n        <file>common/graphics/transistor.png</file>\n        <file>common/graphics/fixed.png</file>\n        <file>common/graphics/mutable.png</file>\n        <file>common/graphics/template.png</file>\n        <file>common/graphics/check-all.png</file>\n        <file>common/graphics/uncheck-all.png</file>\n        <file>common/graphics/code-file.png</file>\n        <file>common/graphics/puzzle.png</file>\n        <file>common/graphics/hw-component-edit.png</file>\n        <file>common/graphics/preview.png</file>\n        <file>common/graphics/hide.png</file>\n        <file>common/graphics/adhoc.png</file>\n        <file>common/graphics/mapping.png</file>\n        <file>common/graphics/log.png</file>\n        <file>common/graphics/automation.png</file>\n        <file>common/graphics/ruler.png</file>\n        <file>common/graphics/search.png</file>\n        <file>common/graphics/fail.png</file>\n        <file>common/graphics/pass.png</file>\n        <file>common/graphics/filterMemoryOverlap.png</file>\n        <file>common/graphics/interconnectGenerator.png</file>\n    </qresource>\n    <qresource prefix=\"/\">\n        <file>common/graphics/splash.png</file>\n    </qresource>\n</RCC>\n"
  },
  {
    "path": "kactusGenerators/DocumentGenerator/DocumentationWriter.cpp",
    "content": "// File: DocumentationWriter.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Anton Hagqvist\n// Date: 12.4.2023\n//\n// Description:\n// Base class for documentation writers\n//-----------------------------------------------------------------------------\n\n\n#include \"DocumentationWriter.h\"\n\n#include <IPXACTmodels/Component/AddressBlock.h>\n#include <IPXACTmodels/Component/Register.h>\n#include <IPXACTmodels/Component/RegisterFile.h>\n#include <IPXACTmodels/Component/MemoryMap.h>\n#include <IPXACTmodels/Component/Field.h>\n#include <IPXACTmodels/Component/BusInterface.h>\n\n#include <KactusAPI/include/ExpressionFormatter.h>\n#include <KactusAPI/include/LibraryInterface.h>\n#include <KactusAPI/include/ListParameterFinder.h>\n\n#include <QList>\n#include <QString>\n#include <QSharedPointer>\n#include <QTextStream>\n\nconst QStringList DocumentationWriter::ADDRESS_BLOCK_HEADERS = {\n    QStringLiteral(\"Usage\"),\n    QStringLiteral(\"Base address [AUB]\"),\n    QStringLiteral(\"Range [AUB]\"),\n    QStringLiteral(\"Width [AUB]\"),\n    QStringLiteral(\"Access\"),\n    QStringLiteral(\"Volatile\")\n};\n\nconst QStringList DocumentationWriter::DEFAULT_FILE_BUILDER_HEADERS = {\n    QStringLiteral(\"File type\"),\n    QStringLiteral(\"Command\"),\n    QStringLiteral(\"Flags\"),\n    QStringLiteral(\"Replace default flags\")\n};\n\nconst QStringList DocumentationWriter::FIELD_HEADERS = {\n    QStringLiteral(\"Field name\"),\n    QStringLiteral(\"Offset [bits]\"),\n    QStringLiteral(\"Width [bits]\"),\n    QStringLiteral(\"Volatile\"),\n    QStringLiteral(\"Access\"),\n    QStringLiteral(\"Resets\"),\n    QStringLiteral(\"Description\")\n};\n\nconst QStringList DocumentationWriter::FILE_HEADERS = {\n    QStringLiteral(\"File name\"),\n    QStringLiteral(\"Logical name\"),\n    QStringLiteral(\"Build command\"),\n    QStringLiteral(\"Build flags\"),\n    QStringLiteral(\"Specified file types\"),\n    QStringLiteral(\"Description\")\n};\n\nconst QStringList DocumentationWriter::PARAMETER_HEADERS = {\n    QStringLiteral(\"Name\"),\n    QStringLiteral(\"Type\"),\n    QStringLiteral(\"Value\"),\n    QStringLiteral(\"Resolve\"),\n    QStringLiteral(\"Bit vector left\"),\n    QStringLiteral(\"Bit vector right\"),\n    QStringLiteral(\"Array left\"),\n    QStringLiteral(\"Array right\"),\n    QStringLiteral(\"Description\")\n};\n\nconst QStringList DocumentationWriter::MODULE_PARAMETER_HEADERS = {\n    QStringLiteral(\"Name\"),\n    QStringLiteral(\"Type\"),\n    QStringLiteral(\"Value\"),\n    QStringLiteral(\"Data type\"),\n    QStringLiteral(\"Usage type\"),\n    QStringLiteral(\"Resolve\"),\n    QStringLiteral(\"Bit vector left\"),\n    QStringLiteral(\"Bit vector right\"),\n    QStringLiteral(\"Array left\"),\n    QStringLiteral(\"Array right\"),\n    QStringLiteral(\"Description\")\n};\n\nconst QStringList DocumentationWriter::PORT_HEADERS = {\n    QStringLiteral(\"Name\"),\n    QStringLiteral(\"Direction\"),\n    QStringLiteral(\"Left bound\"),\n    QStringLiteral(\"Right bound\"),\n    QStringLiteral(\"Port type\"),\n    QStringLiteral(\"Type definition\"),\n    QStringLiteral(\"Default value\"),\n    QStringLiteral(\"Array left\"),\n    QStringLiteral(\"Array right\"),\n    QStringLiteral(\"Description\")\n};\n\nconst QStringList DocumentationWriter::REGISTER_HEADERS = {\n    QStringLiteral(\"Offset [AUB]\"),\n    QStringLiteral(\"Size [bits]\"),\n    QStringLiteral(\"Dimension\"),\n    QStringLiteral(\"Volatile\"),\n    QStringLiteral(\"Access\")\n};\n\nconst QStringList DocumentationWriter::REGISTER_FILE_HEADERS = {\n    QStringLiteral(\"Description\"),\n    QStringLiteral(\"Offset [AUB]\"),\n    QStringLiteral(\"Range [AUB]\"),\n    QStringLiteral(\"Dimension\"),\n};\n\nconst QStringList DocumentationWriter::DESIGN_INSTANCE_HEADERS = {\n    QStringLiteral(\"Instance name\"),\n    QStringLiteral(\"Component type\"),\n    QStringLiteral(\"Configurable values\"),\n    QStringLiteral(\"Active view\"),\n    QStringLiteral(\"Description\")\n};\n\n//-----------------------------------------------------------------------------\n// Function: DocumentationWriter::DocumentationWriter()\n//-----------------------------------------------------------------------------\nDocumentationWriter::DocumentationWriter(ExpressionFormatter* formatter, ExpressionFormatterFactory* expressionFormatterFactory) :\n    expressionFormatter_(formatter),\n    expressionFormatterFactory_(expressionFormatterFactory),\n    targetPath_(),\n    imagesPath_()\n{\n}\n\n//-----------------------------------------------------------------------------\n// Function: DocumentationWriter::setTargetPath()\n//-----------------------------------------------------------------------------\nvoid DocumentationWriter::setTargetPath(QString const& path)\n{\n    targetPath_ = path;\n}\n\n//-----------------------------------------------------------------------------\n// Function: DocumentationWriter::getTargetPath()\n//-----------------------------------------------------------------------------\nQString DocumentationWriter::getTargetPath() const\n{\n    return targetPath_;\n}\n\n//-----------------------------------------------------------------------------\n// Function: DocumentationWriter::setImagesPath()\n//-----------------------------------------------------------------------------\nvoid DocumentationWriter::setImagesPath(QString const& path)\n{\n    imagesPath_ = path;\n}\n\n//-----------------------------------------------------------------------------\n// Function: DocumentationWriter::getImagesPath()\n//-----------------------------------------------------------------------------\nQString DocumentationWriter::getImagesPath() const\n{\n    return imagesPath_;\n}\n\n//-----------------------------------------------------------------------------\n// Function: DocumentationWriter::getMemoryMapAddressBlocks()\n//-----------------------------------------------------------------------------\nQList<QSharedPointer<AddressBlock>> DocumentationWriter::getMemoryMapAddressBlocks(QSharedPointer<MemoryMap> memoryMap) const\n{\n    QList<QSharedPointer <AddressBlock> > addressBlocks;\n    for (auto const& memoryMapItem : *memoryMap->getMemoryBlocks())\n    {\n        QSharedPointer<AddressBlock> addressItem = memoryMapItem.dynamicCast<AddressBlock>();\n\n        if (addressItem)\n        {\n            addressBlocks.append(addressItem);\n        }\n    }\n\n    return addressBlocks;\n}\n\n//-----------------------------------------------------------------------------\n// Function: DocumentationWriter::getAddressBlockRegisters()\n//-----------------------------------------------------------------------------\nQList<QSharedPointer<Register> > DocumentationWriter::getRegisters(\n    QSharedPointer<QList<QSharedPointer<RegisterBase> > > registerData) const\n{\n    QList <QSharedPointer <Register> > registers;\n    for (auto const& registerModelItem : *registerData)\n    {\n        QSharedPointer <Register> registerItem = registerModelItem.dynamicCast<Register>();\n\n        if (registerItem)\n        {\n            registers.append(registerItem);\n        }\n    }\n\n    return registers;\n}\n\nQList<QSharedPointer<RegisterFile> > DocumentationWriter::getRegisterFiles(\n    QSharedPointer<QList<QSharedPointer<RegisterBase> > > registerData) const\n{\n    QList<QSharedPointer<RegisterFile > > registerFiles;\n\n    for (auto const& registerDataItem : *registerData)\n    {\n        if (auto registerFileItem = registerDataItem.dynamicCast<RegisterFile>(); registerFileItem)\n        {\n            registerFiles.append(registerFileItem);\n        }\n    }\n    \n    return registerFiles;\n}\n\n//-----------------------------------------------------------------------------\n// Function: DocumentationWriter::getFieldResetInfo()\n//-----------------------------------------------------------------------------\nQString DocumentationWriter::getFieldResetInfo(QSharedPointer<Field> field, QString const& separator) const\n{\n    QString resetInfo = \"\";\n\n    for (auto const& singleReset : *field->getResets())\n    {\n        if (singleReset != field->getResets()->first())\n        {\n            resetInfo.append(separator);\n        }\n\n        QString resetTypeReference = singleReset->getResetTypeReference();\n        if (resetTypeReference.isEmpty())\n        {\n            resetTypeReference = QLatin1String(\"HARD\");\n        }\n\n        QString resetValue = expressionFormatter_->formatReferringExpression(singleReset->getResetValue());\n\n        resetInfo.append(resetTypeReference + \" : \" + resetValue);\n    }\n\n    return resetInfo;\n}\n\n//-----------------------------------------------------------------------------\n// Function: DocumentationWriter::createDesignInstanceFormatter()\n//-----------------------------------------------------------------------------\nQSharedPointer<ExpressionFormatter> DocumentationWriter::createDesignInstanceFormatter(\n    QSharedPointer<Design> design, QSharedPointer<Component> component)\n{\n    return QSharedPointer<ExpressionFormatter>(\n        expressionFormatterFactory_->createDesignInstanceFormatter(component, design));\n}\n\nvoid DocumentationWriter::writeReferencedComponentInstantiation(QTextStream& stream,\n    QSharedPointer<ComponentInstantiation> instantiation,\n    QSharedPointer<ExpressionFormatter> instantiationFormatter,\n    ParameterList moduleParameters, ParameterList parameters)\n{\n    writeImplementationDetails(stream, instantiation);\n    writeFileSetReferences(stream, instantiation);\n    writeFileBuildCommands(stream, instantiation, instantiationFormatter);\n    writeModuleParameterTable(stream, QString(\"Module parameters:\"),\n        moduleParameters, instantiationFormatter);\n    writeParameterTable(stream, QString(\"Parameters:\"), parameters,\n        instantiationFormatter);\n}\n\nvoid DocumentationWriter::writeReferencedDesignConfigurationInstantiation(QTextStream& stream,\n    QSharedPointer<ListParameterFinder> configurationFinder,\n    QSharedPointer<DesignConfigurationInstantiation> instantiation,\n    QSharedPointer<ExpressionFormatter> instantiationFormatter, LibraryInterface* libraryHandler)\n{\n    if (auto const& configurationVLNV = instantiation->getDesignConfigurationReference(); configurationVLNV)\n    {\n        QSharedPointer<Document> configurationDocument = libraryHandler->getModel(*configurationVLNV);\n        if (configurationDocument)\n        {\n            QSharedPointer<DesignConfiguration> configuration =\n                configurationDocument.dynamicCast<DesignConfiguration>();\n\n            if (configuration)\n            {\n                configurationFinder->setParameterList(configuration->getParameters());\n\n                QString header = QString(\"Parameters of the referenced design configuration %1:\").\n                    arg(configurationVLNV->toString());\n                QSharedPointer<ExpressionFormatter> configurationFormatter(new ExpressionFormatter(configurationFinder));\n\n                writeParameterTable(stream, header, configuration->getParameters(), configurationFormatter);\n                writeConfigurableElementValues(stream,\n                    instantiation->getDesignConfigurationReference(), instantiationFormatter);\n            }\n        }\n    }\n\n    writeParameterTable(stream, QString(\"Design configuration instantiation parameters:\"),\n        instantiation->getParameters(), instantiationFormatter);\n}\n\n//-----------------------------------------------------------------------------\n// Function: DocumentationWriter::writeReferencedDesignInstantiation()\n//-----------------------------------------------------------------------------\nvoid DocumentationWriter::writeReferencedDesignInstantiation(QTextStream& stream,\n    QSharedPointer<ConfigurableVLNVReference> designVLNV, QSharedPointer<Design> instantiatedDesign,\n    QSharedPointer<ExpressionFormatter> designFormatter, QSharedPointer<ExpressionFormatter> instantiationFormatter)\n{\n    QString header = QString(\"Parameters of the referenced design %1:\").arg(designVLNV->toString());\n    writeParameterTable(stream, header, instantiatedDesign->getParameters(), designFormatter);\n\n    writeConfigurableElementValues(stream, designVLNV, instantiationFormatter);\n}\n\n//-----------------------------------------------------------------------------\n// Function: DocumentationWriter::writeAddressBlockInfo()\n//-----------------------------------------------------------------------------\nvoid DocumentationWriter::writeAddressBlockInfo(QTextStream& stream, QSharedPointer<AddressBlock> addressBlock)\n{\n    QStringList addressBlockInfoValues(QStringList()\n        << addressBlock->description()\n        << General::usage2Str(addressBlock->getUsage())\n        << expressionFormatter_->formatReferringExpression(addressBlock->getBaseAddress())\n        << expressionFormatter_->formatReferringExpression(addressBlock->getRange())\n        << expressionFormatter_->formatReferringExpression(addressBlock->getWidth())\n        << AccessTypes::access2Str(addressBlock->getAccess())\n        << addressBlock->getVolatile()\n    );\n\n    QStringList addressBlockInfoNames(QStringList()\n        << \"Description\" << ADDRESS_BLOCK_HEADERS\n    );\n\n    writeInfoParagraph(stream, addressBlockInfoNames, addressBlockInfoValues);\n}\n\n//-----------------------------------------------------------------------------\n// Function: DocumentationWriter::writeSingleRegister()\n//-----------------------------------------------------------------------------\nvoid DocumentationWriter::writeSingleRegister(QTextStream& stream, QSharedPointer<Register> reg, QList<int> subHeaderNumbers, int& registerDataNumber)\n{\n    writeSubHeader(stream, subHeaderNumbers, QStringLiteral(\"Register \") + reg->name(), 3);\n\n    QStringList registerInfoValues(QStringList()\n        << reg->description()\n        << expressionFormatter_->formatReferringExpression(reg->getAddressOffset())\n        << expressionFormatter_->formatReferringExpression(reg->getSize())\n        << expressionFormatter_->formatReferringExpression(reg->getDimension())\n        << reg->getVolatile()\n        << AccessTypes::access2Str(reg->getAccess())\n    );\n\n    QStringList registerInfoNames(QStringList()\n        << QStringLiteral(\"Description\")\n        << REGISTER_HEADERS\n    );\n\n    writeInfoParagraph(stream, registerInfoNames, registerInfoValues);\n\n    writeFields(stream, reg, subHeaderNumbers);\n    ++registerDataNumber;\n}\n\n//-----------------------------------------------------------------------------\n// Function: DocumentationWriter::writeRegisterFileInfo()\n//-----------------------------------------------------------------------------\nvoid DocumentationWriter::writeRegisterFileInfo(QTextStream& stream, QSharedPointer<RegisterFile> registerFile)\n{\n    QStringList registerInfoValues(QStringList()\n        << registerFile->description()\n        << expressionFormatter_->formatReferringExpression(registerFile->getAddressOffset())\n        << expressionFormatter_->formatReferringExpression(registerFile->getRange())\n        << expressionFormatter_->formatReferringExpression(registerFile->getDimension())\n    );\n\n    writeInfoParagraph(stream, REGISTER_FILE_HEADERS, registerInfoValues);\n}\n\n//-----------------------------------------------------------------------------\n// Function: DocumentationWriter::writeSingleField()\n//-----------------------------------------------------------------------------\nvoid DocumentationWriter::writeSingleField(QTextStream& stream, QSharedPointer<Field> field)\n{\n    QStringList fieldInfoTextValues(QStringList()\n        << expressionFormatter_->formatReferringExpression(field->getBitOffset())\n        << expressionFormatter_->formatReferringExpression(field->getBitWidth())\n        << field->getVolatile().toString()\n        << AccessTypes::access2Str(field->getAccess())\n        << getFieldResetInfo(field, \", \")\n        << field->description()\n    );\n\n    QStringList fieldInfoTextNames = FIELD_HEADERS;\n    fieldInfoTextNames.pop_front();\n\n    writeInfoParagraph(stream, fieldInfoTextNames, fieldInfoTextValues);\n\n    writeFieldEnumerations(stream, field);\n}\n\n//-----------------------------------------------------------------------------\n// Function: DocumentationWriter::writeInterfaceInfo()\n//-----------------------------------------------------------------------------\nvoid DocumentationWriter::writeInterfaceInfo(QTextStream& stream, QSharedPointer<BusInterface> interface,\n    bool hasPorts)\n{\n    auto const interfaceMode = General::interfaceMode2Str(interface->getInterfaceMode());\n    QStringList absDefinitionVlnvs;\n\n    for (auto const& absDef : *interface->getAbstractionTypes())\n    {\n        absDefinitionVlnvs << absDef->getAbstractionRef()->toString();\n    }\n\n    QStringList interfaceInfoNames(QStringList()\n        << QStringLiteral(\"Description\")\n        << QStringLiteral(\"Interface mode\")\n    );\n\n    QStringList interfaceInfoValues(QStringList()\n        << interface->description()\n        << interfaceMode\n    );\n\n    if (interfaceMode == QStringLiteral(\"system\"))\n    {\n        interfaceInfoNames << QStringLiteral(\"System group\");\n        interfaceInfoValues << interface->getSystem();\n    }\n\n    interfaceInfoNames\n        << QStringLiteral(\"Bus definition\")\n        << QStringLiteral(\"Abstraction definitions\")\n        << QStringLiteral(\"Ports used in this interface\");\n\n    interfaceInfoValues\n        << interface->getBusType().toString()\n        << absDefinitionVlnvs.join(\", \")\n        << (hasPorts ? QStringLiteral(\"\") : QStringLiteral(\"None\"));\n\n    writeInfoParagraph(stream, interfaceInfoNames, interfaceInfoValues);\n}\n"
  },
  {
    "path": "kactusGenerators/DocumentGenerator/DocumentationWriter.h",
    "content": "//-----------------------------------------------------------------------------\n// File: DocumentationWriter.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Anton Hagqvist\n// Date: 12.4.2023\n//\n// Description:\n// Base class for documentation writers\n//-----------------------------------------------------------------------------\n\n#ifndef DOCUMENTATIONWRITER_H\n#define DOCUMENTATIONWRITER_H\n\n#include <KactusAPI/include/ExpressionFormatterFactory.h>\n\n#include <IPXACTmodels/DesignConfiguration/DesignConfiguration.h>\n\n#include <QTextStream>\n#include <QString>\n#include <QSharedPointer>\n\nclass ExpressionFormatter;\nclass AddressBlock;\nclass Register;\nclass Design;\nclass Field;\nclass MemoryMap;\nclass Parameter;\nclass ComponentInstantiation;\nclass ListParameterFinder;\nclass DesignConfigurationInstantiation;\nclass ConfigurableVLNVReference;\nclass RegisterFile;\nclass RegisterBase;\n\nusing ParameterList = QSharedPointer<QList<QSharedPointer<Parameter> > >;\n\nclass DocumentationWriter\n{\npublic:\n\n    //! Table header constants\n    static const QStringList ADDRESS_BLOCK_HEADERS;\n\n    static const QStringList DEFAULT_FILE_BUILDER_HEADERS;\n\n    static const QStringList FIELD_HEADERS;\n    \n    static const QStringList FILE_HEADERS;\n\n    static const QStringList PARAMETER_HEADERS;\n\n    static const QStringList MODULE_PARAMETER_HEADERS;\n\n    static const QStringList PORT_HEADERS;\n\n    static const QStringList REGISTER_HEADERS;\n\n    static const QStringList REGISTER_FILE_HEADERS;\n\n    static const QStringList DESIGN_INSTANCE_HEADERS;\n    \n    DocumentationWriter(ExpressionFormatter* formatter, ExpressionFormatterFactory* expressionFormatterFactory);\n    virtual ~DocumentationWriter() = default;\n\n    /*!\n     *  Write the document header.\n     *\n     *    @param [in] stream  The text stream to write the header into.\n     */\n    virtual void writeHeader(QTextStream& stream) = 0;\n    \n    /*!\n     *  Write a header for the component.\n     *\n     *    @param [in] stream  The text stream to write the header into.\n     */\n    virtual void writeComponentHeader(QTextStream& stream) = 0;\n    \n    /*!\n     *  Write the component info.\n     *\n     *    @param [in] stream  The text stream to write into.\n     */\n    virtual void writeComponentInfo(QTextStream& stream) = 0;\n\n    /*!\n     *  Write component kactus2 attributes.\n     *\n     *    @param [in] stream              The text stream to write into.\n     *    @param [in] subHeaderNumber     The current subheader number.\n     */\n    virtual void writeKactusAttributes(QTextStream& stream, int subHeaderNumber) = 0;\n\n    /*!\n     *  Write the table of contents header.\n     *\n     *    @param [in] stream  The text stream to write into.\n     */\n    virtual void writeTableOfContentsHeader(QTextStream& stream) = 0;\n\n    /*!\n     *  Write the table of contents of the current component.\n     *\n     *    @param [in] stream  The text stream to write into.\n     */\n    virtual void writeTableOfContents(QTextStream& stream) = 0;\n\n    /*!\n     *  Write the parameters of the component.\n     *\n     *    @param [in] stream              The text stream to write into.\n     *    @param [in] subHeaderNumber     The current subheader number.\n     */\n    virtual void writeParameters(QTextStream& stream, int subHeaderNumber) = 0;\n\n    /*!\n     *  Write the memory maps of the component.\n     *\n     *    @param [in] stream              The text stream to write into.\n     *    @param [in] subHeaderNumber     The current subheader number.\n     */\n    virtual void writeMemoryMaps(QTextStream& stream, int subHeaderNumber) = 0;\n\n    /*!\n     *  Write the given address blocks.\n     *\n     *    @param [in] stream              The text stream to write into.\n     *    @param [in] addressBlocks       The address blocks to be written.\n     *    @param [in] subHeaderNumber     The current subheader number.\n     *    @param [in] memoryMapNumber     The current memory map number.\n     */\n    virtual void writeAddressBlocks(QTextStream& stream, QList<QSharedPointer <AddressBlock> > addressBlocks,\n        int subHeaderNumber, int memoryMapNumber) = 0;\n    \n    /*!\n     *  Write the given register files\n     *\n     *    @param [in] stream               The text stream to write into.\n     *    @param [in] registerFiles        The registers to be written.\n     *    @param [in] subHeaderNumbers     The current subheader number.\n     *    @param [out] registerDataNumber  The current address block number.\n     */\n    virtual void writeRegisterFiles(QTextStream& stream,\n        QList<QSharedPointer<RegisterFile> > registerFiles,\n        QList<int> subHeaderNumbers, int& registerDataNumber) = 0;\n\n    /*!\n     *  Write the given registers.\n     *\n     *    @param [in] stream              The text stream to write into.\n     *    @param [in] registers           The registers to be written.\n     *    @param [in] subHeaderNumber     The current subheader number.\n     *    @param [in] memoryMapNumber     The current memory map number.\n     *    @param [in] addressBlockNumber  The current address block number.\n     */\n    virtual void writeRegisters(QTextStream& stream, QList<QSharedPointer <Register> > registers,\n        int subHeaderNumber, int memoryMapNumber, int addressBlockNumber, int& registerDataNumber) = 0;\n\n    /*!\n     *  Write the given register fields.\n     *\n     *    @param [in] stream              The text stream to write into.\n     *    @param [in] register            The register whose fields are to be written.\n     */\n    virtual void writeFields(QTextStream& stream, QSharedPointer <Register> currentRegister,\n        QList<int> registerSubHeaderNumbers) = 0;\n\n    /*!\n     *  Write the ports of the component.\n     *\n     *    @param [in] stream              The text stream to write into.\n     *    @param [in] subHeaderNumber     The current subheader number.\n     */\n    virtual void writePorts(QTextStream& stream, int subHeaderNumber) = 0;\n\n    /*!\n     *  Write the bus interfaces of the component.\n     *\n     *    @param [in] stream              The text stream to write into.\n     *    @param [in] subHeaderNumber     The current subheader number.\n     */\n    virtual void writeInterfaces(QTextStream& stream, int& subHeaderNumber) = 0;\n\n    /*!\n     *  Write the file sets of the component.\n     *\n     *    @param [in] stream              The text stream to write into.\n     *    @param [in] subHeaderNumber     The current subheader number.\n     */\n    virtual void writeFileSets(QTextStream& stream, int& subHeaderNumber) = 0;\n\n    /*!\n     *  Set the number of the component in the hierarchy.\n     *\n     *    @param [in] componentNumber     The new component number.\n     */\n    virtual void setComponentNumber(int componentNumber) = 0;\n\n    /*!\n     *  Write a referenced component subheader.\n     *\n     *    @param [in] stream              The text stream to write into.\n     *    @param [in] subHeaderNumber     The current subheader number.\n     *    @param [in] headerText          The displayed header text.\n     *    @param [in] headerId            The id for referencing within the document.\n     */\n    virtual void writeSubHeader(QTextStream& stream, int subHeaderNumber,\n        QString const& headerText, QString const& headerId) const = 0;\n    \n    /*!\n     *  Write a non-referenced component subheader with specified header level.\n     *\n     *    @param [in] stream              The text stream to write into.\n     *    @param [in] subHeaderNumbers    The subheader numbers.\n     *    @param [in] title               The displayed header text.\n     *    @param [in] headerId            The id for referencing within the document.\n     */\n    virtual void writeSubHeader(QTextStream& stream, QList<int> const& subHeaderNumbers,\n        QString const& title, int level) const = 0;\n\n    /*!\n     *  Write a description text.\n     *\n     *    @param [in] stream              The text stream to write into.\n     *    @param [in] description         The description to write.\n     */\n    virtual void writeDescription(QTextStream& stream, QString const& description) = 0;\n\n    /*!\n     *  Write an error text to the document.\n     *\n     *    @param [in] stream              The text stream to write into..\n     *    @param [in] message             The description to write.\n     */\n    virtual void writeErrorMessage(QTextStream& stream, QString const& message) = 0;\n\n    /*!\n     *  Write the document contained within the selected VLNV.\n     *\n     *    @param [in] stream                  Text stream to write the document.\n     *    @param [in] documentType            Type of the document.\n     *    @param [in] vlnvReference           VLNV of the selected document.\n     */\n    virtual void writeDocumentReference(QTextStream& stream, QString const& documentType,\n        QSharedPointer<ConfigurableVLNVReference> vlnvReference) = 0;\n\n    /*!\n     *  Write the design diagram.\n     *\n     *    @param [in] stream                  Text stream to write the diagram to.\n     *    @param [in] title                   Diagram title.\n     *    @param [in] link                    Diagram picture link or path.\n     *    @param [in] altText                 Diagram alt text.\n     */\n    virtual void writeDiagram(QTextStream& stream, QString const& title,\n        QString const& link, QString const& altText) = 0;\n\n    /*!\n     *  Write the component instances contained within the selected design.\n     *\n     *    @param [in] stream          Text stream to write the component instances.\n     *    @param [in] design          The selected design.\n     *    @param [in] configuration   The selected design configuration.\n     */\n    virtual void writeDesignInstances(QTextStream& stream, QSharedPointer<Design> design,\n        QSharedPointer<DesignConfiguration> configuration) = 0;\n\n    /*!\n     *  Write the end of the document, if the format requires it.\n     *\n     *    @param [in] stream  The text stream to write the documentation into.\n     */\n    virtual void writeEndOfDocument(QTextStream& stream) = 0;\n\n    /*!\n     *  Write the referenced component instantiation.\n     *\n     *    @param [in] stream                  Text stream to write the component instantiation.\n     *    @param [in] instantiation           The component instantiation.\n     *    @param [in] instantiationFormatter  The component instantiation formatter.\n     *    @param [in] moduleParameters        The instantiation module parameters.\n     *    @param [in] parameters              The instantiation parameters.\n     */\n    void writeReferencedComponentInstantiation(\n        QTextStream& stream,\n        QSharedPointer<ComponentInstantiation> instantiation,\n        QSharedPointer<ExpressionFormatter> instantiationFormatter,\n        ParameterList moduleParameters,\n        ParameterList parameters);\n\n    /*!\n     *  Write the referenced design configuration instantiation.\n     *\n     *    @param [in] stream                  Text stream to write the component instantiation.\n     *    @param [in] configurationFinder     The parameter finder for the instantiation.\n     *    @param [in] instantiationFormatter  The instantiation formatter.\n     */\n    void writeReferencedDesignConfigurationInstantiation(QTextStream& stream,\n        QSharedPointer<ListParameterFinder> configurationFinder,\n        QSharedPointer<DesignConfigurationInstantiation> instantiation,\n        QSharedPointer<ExpressionFormatter> instantiationFormatter,\n        LibraryInterface* libraryHandler);\n\n    /*!\n     *  Write the referenced design instantiation.\n     *\n     *    @param [in] stream                  Text stream to write the component instantiation.\n     *    @param [in] designVLNV              The VLNV of the design instantiation.\n     *    @param [in] instantiatedDesign      The instantiated design.\n     *    @param [in] designFormatter         Expression formatter for the design.\n     *    @param [in] instantiationFormatter  Expression formatter for the instantiation.\n     */\n    void writeReferencedDesignInstantiation(QTextStream& stream,\n        QSharedPointer<ConfigurableVLNVReference> designVLNV,\n        QSharedPointer<Design> instantiatedDesign,\n        QSharedPointer<ExpressionFormatter> designFormatter,\n        QSharedPointer<ExpressionFormatter> instantiationFormatter);\n\n    /*!\n     *  Sets the target path for the document.\n     *\n     *    @param [in] path    The new target path.\n     */\n    void setTargetPath(QString const& path);\n\n    /*!\n     *  Get the target path of the document.\n     *\n     *    @returns The target path.\n     */\n    QString getTargetPath() const;\n    \n    /*!\n     *  Sets the images path.\n     *\n     *    @param [in] path    The new images path.\n     */\n    void setImagesPath(QString const& path);\n\n    /*!\n     *  Get the path of the images folder.\n     *\n     *    @returns The image folder path.\n     */\n    QString getImagesPath() const;\n\nprotected:\n\n    /*!\n     *  Writes the implementation details of a component instantiation.\n     *\n     *    @param [in] stream          Text stream to write to.\n     *    @param [in] instantiation   The component instantiation.\n     */\n    virtual void writeImplementationDetails(QTextStream& stream,\n        QSharedPointer<ComponentInstantiation> instantiation) = 0;\n\n    /*!\n     *  Writes the file set references contained within a component instantiation.\n     *\n     *    @param [in] stream          Text stream to write to.\n     *    @param [in] instantiation   The component instantiation.\n        */\n    virtual void writeFileSetReferences(QTextStream& stream,\n        QSharedPointer<ComponentInstantiation> instantiation) = 0;\n\n    /*!\n        *  Writes the file build commands of a component instantiation.\n        *\n        *    @param [in] stream          Text stream to write to.\n        *    @param [in] instantiation   The component instantiation.\n        *    @param [in] formatter       The expression formatter for the component instantiation.\n        */\n    virtual void writeFileBuildCommands(QTextStream& stream, QSharedPointer<ComponentInstantiation> instantiation,\n        QSharedPointer<ExpressionFormatter> formatter) = 0;\n\n    /*!\n     *  Writes given parameters to a table.\n     *\n     *    @param [in] stream          Text stream to write to.\n     *    @param [in] tableHeading    The heading above the table.\n     *    @param [in] parameters      The parameters to be written.\n     *    @param [in] formatter       The expression formatter for the parameters.\n     */\n    virtual void writeParameterTable(QTextStream& stream, QString const& tableHeading,\n        QSharedPointer<QList<QSharedPointer<Parameter> > > parameters,\n        QSharedPointer<ExpressionFormatter> formatter) = 0;\n    \n    /*!\n     *  Writes given module parameters to a table.\n     *\n     *    @param [in] stream              Text stream to write to.\n     *    @param [in] tableHeading        The heading above the table.\n     *    @param [in] moduleParameters    The module parameters to be written.\n     *    @param [in] formatter           The expression formatter for the parameters.\n     */\n    virtual void writeModuleParameterTable(QTextStream& stream, QString const& tableHeading,\n        QSharedPointer<QList<QSharedPointer<Parameter> > > moduleParameters,\n        QSharedPointer<ExpressionFormatter> formatter) = 0;\n\n    /*!\n     *  Writes the configurable element values of a VLNV.\n     *\n     *    @param [in] stream                  Text stream to write the document.\n     *    @param [in] vlnvReference           Configurable VLNV containing the selected configurable element\n     *                                          values.\n     *    @param [in] instantiationFormatter  Expression formatter for the configurable element values.\n     */\n    virtual void writeConfigurableElementValues(QTextStream& stream,\n        QSharedPointer<ConfigurableVLNVReference> vlnvReference,\n        QSharedPointer<ExpressionFormatter> formatter) = 0;\n\n    /*!\n     *  Write a paragraph in which specific information is listed.\n     *\n     *    @param [in] stream              The text stream to write into.\n     *    @param [in] names               The info item names.\n     *    @param [in] values              The info item values.\n     */\n    virtual void writeInfoParagraph(QTextStream& stream, QStringList const& names, QStringList const& values) = 0;\n\n    /*!\n     *  Writes the enumerations of a field.\n     *\n     *    @param [in] stream              The text stream to write into.\n     *    @param [in] field               The field which enumerations are written.\n     */\n    virtual void writeFieldEnumerations(QTextStream& stream, QSharedPointer<Field> field) = 0;\n\n    /*!\n     *  Finds the address blocks of a memory map.\n     *      \n     *    @param [in] memoryMap       The memory map.\n     * \n     *    @returns The memory map address blocks.\n     */\n    QList<QSharedPointer <AddressBlock> > getMemoryMapAddressBlocks(QSharedPointer<MemoryMap> memoryMap) const;\n\n    /*!\n     *  Finds the registers from some register data.\n     *\n     *    @param [in] registerData    The register data.\n     *\n     *    @returns The registers of the register data.\n     */\n    QList<QSharedPointer <Register> > getRegisters(\n        QSharedPointer<QList<QSharedPointer<RegisterBase> > > registerData) const;\n\n    /*!\n     *  Finds the register files from some register data.\n     *\n     *    @param [in] registerData    The register data.\n     *\n     *    @returns The register files of the register data.\n     */\n    QList<QSharedPointer <RegisterFile> > getRegisterFiles(\n        QSharedPointer<QList<QSharedPointer<RegisterBase> > > registerData) const;\n\n    /*!\n     *  Finds the field reset info of a register field.\n     *\n     *    @param [in] field       The register field.\n     *\n     *    @returns The field reset info of the field.\n     */\n    QString getFieldResetInfo(QSharedPointer<Field> field, QString const& separator = \"<br>\") const;\n\n    /*!\n     *  Creates an expression formatter for a component contained within a design.\n     *\n     *    @param [in] design         The design.\n     *    @param [in] component      The component.\n     *\n     *    @returns An expression formatter for .\n     */\n    QSharedPointer<ExpressionFormatter> createDesignInstanceFormatter(QSharedPointer<Design> design,\n        QSharedPointer<Component> component);\n\n    /*!\n     *  Writes info about an address block.\n     *\n     *    @param [in] stream              The text stream to write into.\n     *    @param [in] addressBlock        The address block to write about.\n     */\n    void writeAddressBlockInfo(QTextStream& stream, QSharedPointer<AddressBlock> addressBlock);\n\n    /*!\n     *  Writes info about a single register.\n     *\n     *    @param [in] stream              The text stream to write into.\n     *    @param [in] reg                 The register to be written.\n     *    @param [in] subHeaderNumbers    The subheader numbers to write in the subheader.\n     *    @param [in] registerDataNumber  The current address block register data number.\n     */\n    void writeSingleRegister(QTextStream& stream, QSharedPointer<Register> reg, QList<int> subHeaderNumbers,\n        int& registerDataNumber);\n\n    /*!\n     *  Writes info about a register file.\n     *\n     *    @param [in] stream              The text stream to write into.\n     *    @param [in] registerFile        The register file to be written.\n     */\n    void writeRegisterFileInfo(QTextStream& stream, QSharedPointer<RegisterFile> registerFile);\n\n    /*!\n     *  Writes a single field.\n     *\n     *    @param [in] stream              The text stream to write into.\n     *    @param [in] field               The field to be written.\n     */\n    void writeSingleField(QTextStream& stream, QSharedPointer<Field> field);\n\n    /*!\n     *  Writes information about a bus interface.\n     *\n     *    @param [in] stream              The text stream to write into.\n     *    @param [in] interface           The interface to be written.\n     *    @param [in] hasPorts            Flag that indicates if interface has ports.\n     */\n    void writeInterfaceInfo(QTextStream& stream, QSharedPointer<BusInterface> interface, bool hasPorts);\n\nprivate:\n    //! The expression formatter, used to change parameter IDs into names.\n    ExpressionFormatter* expressionFormatter_;\n\n    //! The factory for creating expression formatters.\n    ExpressionFormatterFactory* expressionFormatterFactory_;\n\n    //! The path the document is written to.\n    QString targetPath_;\n\n    //! The image save path\n    QString imagesPath_;\n};\n\n#endif // DOCUMENTATIONWRITER_H\n"
  },
  {
    "path": "kactusGenerators/DocumentGenerator/HtmlWriter.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: HtmlWriter.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Anton Hagqvist\n// Date: 12.4.2023\n//\n// Description:\n// Writes HTML documentation of a component.\n//-----------------------------------------------------------------------------\n\n#include \"HtmlWriter.h\"\n\n#include <IPXACTmodels/Component/Component.h>\n#include <IPXACTmodels/Component/MemoryMap.h>\n#include <IPXACTmodels/Component/AddressBlock.h>\n#include <IPXACTmodels/Component/Register.h>\n#include <IPXACTmodels/Component/RegisterFile.h>\n#include <IPXACTmodels/Component/Field.h>\n#include <IPXACTmodels/Component/BusInterface.h>\n#include <IPXACTmodels/Component/FileSet.h>\n#include <IPXACTmodels/Component/ComponentInstantiation.h>\n#include <IPXACTmodels/Component/EnumeratedValue.h>\n#include <IPXACTmodels/DesignConfiguration/DesignConfiguration.h>\n\n#include <KactusAPI/include/ExpressionFormatter.h>\n#include <KactusAPI/include/LibraryInterface.h>\n#include <KactusAPI/include/ListParameterFinder.h>\n\n#include <QDateTime>\n#include <QFileInfo>\n#include <QSettings>\n\nnamespace HTML\n{\n    const QString SPACE(\"&nbsp;\");\n\n    const QString INDENT(\"&nbsp;&nbsp;&nbsp;\");\n\n    const QString TABLE(\"<table frame=\\\"box\\\" rules=\\\"all\\\" border=\\\"1\\\" cellPadding=\\\"3\\\" title=\\\"\");\n\n    const QString DOCTYPE(\"<!DOCTYPE html PUBLIC \\\"-//W3C//DTD HTML 4.01//EN\\\" \"\n        \"\\\"http://www.w3.org/TR/html4/strict.dtd\\\">\");\n\n    const QString ENCODING(\"<meta http-equiv=\\\"Content-Type\\\" content=\\\"text/html; charset=utf-8\\\">\");\n}\n\n//-----------------------------------------------------------------------------\n// Function: HtmlWriter::HtmlWriter()\n//-----------------------------------------------------------------------------\nHtmlWriter::HtmlWriter(QSharedPointer<Component> component, ExpressionFormatter* formatter,\n    ExpressionFormatterFactory* expressionFormatterFactory,\n    LibraryInterface* libraryHandler, int componentNumber) :\n    DocumentationWriter(formatter, expressionFormatterFactory),\n    expressionFormatter_(formatter),\n    libraryHandler_(libraryHandler),\n    component_(component),\n    componentNumber_(componentNumber)\n{\n    vlnvString_ = component_->getVlnv().toString();\n}\n\n//-----------------------------------------------------------------------------\n// Function: HtmlWriter::~HtmlWriter()\n//-----------------------------------------------------------------------------\nHtmlWriter::~HtmlWriter()\n{\n}\n\n//-----------------------------------------------------------------------------\n// Function: HtmlWriter::writeHeader()\n//-----------------------------------------------------------------------------\nvoid HtmlWriter::writeHeader(QTextStream& stream)\n{\n    QSettings settings;\n    \n    // write the top of the html document\n    stream << HTML::DOCTYPE << Qt::endl;\n    stream << \"<html>\" << Qt::endl;\n    stream << indent(1) << \"<head>\" << Qt::endl;\n    stream << indent(1) << HTML::ENCODING << Qt::endl;\n    stream << indent(2) <<\"<title>Kactus2 generated documentation for component \" <<\n        component_->getVlnv().getName() << \" \" << component_->getVlnv().getVersion() << \"</title>\" << Qt::endl;\n    stream << indent(1) << \"</head>\" << Qt::endl;\n    stream << indent(1) << \"<body>\" << Qt::endl;\n    stream << indent(2) << \"<h6>This document was generated by Kactus2 on \" <<\n        QDateTime::currentDateTime().toString(\"dd.MM.yyyy hh:mm:ss\") << \" by user \" <<\n        settings.value(\"General/Username\").toString() << \"</h6>\" << Qt::endl;\n}\n\n//-----------------------------------------------------------------------------\n// Function: HtmlWriter::writeComponentHeader()\n//-----------------------------------------------------------------------------\nvoid HtmlWriter::writeComponentHeader(QTextStream& stream)\n{\n    stream << indent(2) << \"<h1><a id=\\\"\" << vlnvString_ << \"\\\">\" << componentNumber_ << \". Component \" <<\n        component_->getVlnv().toString(\" - \") << \"</a></h1>\" << Qt::endl;\n}\n\n//-----------------------------------------------------------------------------\n// Function: HtmlWriter::writeComponentInfo()\n//-----------------------------------------------------------------------------\nvoid HtmlWriter::writeComponentInfo(QTextStream& stream)\n{\n    stream << indent(2) << \"<p>\" << Qt::endl;\n\n    stream << indent(2) << \"<img src=\\\"\" << getImagesPath().split(\"/\").back() << \"/\"\n        << component_->getVlnv().toString(\".\") << \".png\\\" alt=\\\"\"\n        << component_->getVlnv().toString(\" - \") << \" preview picture\\\"><br>\" << Qt::endl;\n\n    // if component has description, write it\n    if (!component_->getDescription().isEmpty())\n    {\n        stream << indent(2) << \"<strong>Description:</strong> \" << component_->getDescription()\n            << \"<br>\" << Qt::endl;\n    }\n\n    // print relative path to the xml file\n    QFileInfo compXmlInfo(libraryHandler_->getPath(component_->getVlnv()));\n    QString relativeXmlPath = General::getRelativePath(getTargetPath(), compXmlInfo.absoluteFilePath());\n    stream << indent(2) << \"<strong>IP-Xact file: </strong><a href=\\\"\" <<\n        relativeXmlPath << \"\\\">\" << compXmlInfo.fileName() <<\n        \"</a><br>\" << Qt::endl;\n\n    stream << indent(2) << \"</p>\" << Qt::endl;\n}\n\n//-----------------------------------------------------------------------------\n// Function: HtmlWriter::writeKactusAttributes()\n//-----------------------------------------------------------------------------\nvoid HtmlWriter::writeKactusAttributes(QTextStream& stream, int subHeaderNumber)\n{\n    writeSubHeader(stream, subHeaderNumber, \"Kactus2 attributes\", \"attributes\");\n\n    stream << indent(2) << \"<p>\" << Qt::endl;\n    stream << indent(3) << \"<strong>\" << HTML::INDENT << \"Product hierarchy: </strong>\" <<\n        KactusAttribute::hierarchyToString(component_->getHierarchy()) << \"<br>\" << Qt::endl;\n\n    stream << indent(3) << \"<strong>\" << HTML::INDENT << \"Component implementation: </strong>\" <<\n        KactusAttribute::implementationToString(component_->getImplementation()) << \"<br>\" << Qt::endl;\n\n    stream << indent(3) << \"<strong>\" << HTML::INDENT << \"Component firmness: </strong>\" <<\n        KactusAttribute::firmnessToString(component_->getFirmness()) << \"<br>\" << Qt::endl;\n\n    stream << indent(2) << \"</p>\" << Qt::endl;\n}\n\n//-----------------------------------------------------------------------------\n// Function: HtmlWriter::writeTableOfContentsHeader()\n//-----------------------------------------------------------------------------\nvoid HtmlWriter::writeTableOfContentsHeader(QTextStream& stream)\n{\n    stream << indent(2) << \"<p>\" << Qt::endl;\n    stream << indent(2) << \"<strong>Table of contents</strong><br>\" << Qt::endl;\n    stream << indent(2) << \"</p>\" << Qt::endl;\n}\n\n//-----------------------------------------------------------------------------\n// Function: HtmlWriter::writeTableOfContents()\n//-----------------------------------------------------------------------------\nvoid HtmlWriter::writeTableOfContents(QTextStream& stream)\n{\n    QString vlnvHeader = \"\\t\\t\" + HTML::INDENT + \"<a href=\\\"#\" + component_->getVlnv().toString();\n\n    stream << indent(2) << \"<a href=\\\"#\" << component_->getVlnv().toString() << \"\\\">\"\n        << componentNumber_ << \". Component\" << HTML::SPACE << component_->getVlnv().toString(\" - \")\n        << \"</a><br>\" << Qt::endl;\n\n    // subHeader is running number that counts the number of sub headers for component\n    int subHeader = 1;\n\n    // component always has kactus parameters\n    stream << vlnvHeader << \".kts_params\\\">\" << componentNumber_ << \".\" << subHeader\n        << \". Kactus2 attributes</a><br>\" << Qt::endl;\n    ++subHeader;\n\n    if (component_->hasParameters())\n    {\n        stream << vlnvHeader << \".parameters\\\">\" << componentNumber_ << \".\" << subHeader <<\n            \". General parameters</a><br>\" << Qt::endl;\n        ++subHeader;\n    }\n\n    if (!component_->getMemoryMaps()->isEmpty())\n    {\n        stream << vlnvHeader << \".memoryMaps\\\">\" << componentNumber_ << \".\" << subHeader\n            << \". Memory maps</a><br>\" << Qt::endl;\n        ++subHeader;\n    }\n\n    if (component_->hasPorts())\n    {\n        stream << vlnvHeader << \".ports\\\">\" << componentNumber_ << \".\" << subHeader\n            << \". Ports</a><br>\" << Qt::endl;\n        ++subHeader;\n    }\n\n    if (component_->hasInterfaces())\n    {\n        stream << vlnvHeader << \".interfaces\\\">\" << componentNumber_ << \".\" << subHeader\n            << \". Bus interfaces</a><br>\" <<\n            Qt::endl;\n        ++subHeader;\n    }\n\n    if (component_->hasFileSets())\n    {\n        stream << vlnvHeader << \".fileSets\\\">\" << componentNumber_ << \".\" << subHeader\n            << \". File sets</a><br>\" << Qt::endl;\n        ++subHeader;\n    }\n\n    if (component_->hasViews())\n    {\n        stream << vlnvHeader << \".views\\\">\" << componentNumber_ << \".\" << subHeader\n            << \". Views</a><br>\" << Qt::endl;\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: HtmlWriter::writeParameters()\n//-----------------------------------------------------------------------------\nvoid HtmlWriter::writeParameters(QTextStream& stream, int subHeaderNumber)\n{\n    writeSubHeader(stream, subHeaderNumber, \"General parameters\", \"parameters\");\n\n    // Write table element\n    stream << indent(3) << HTML::TABLE << \"List of parameters defined for the component\\\">\" << Qt::endl;\n\n    // Write header row\n    writeTableHeader(stream, DocumentationWriter::PARAMETER_HEADERS, 4);\n\n    // Write parameters\n    for (auto const& parameter : *component_->getParameters())\n    {\n        QStringList paramFields(QStringList()\n            << parameter->name()\n            << parameter->getType()\n            << expressionFormatter_->formatReferringExpression(parameter->getValue())\n            << parameter->getValueResolve()\n            << expressionFormatter_->formatReferringExpression(parameter->getVectorLeft())\n            << expressionFormatter_->formatReferringExpression(parameter->getVectorRight())\n            << expressionFormatter_->formatReferringExpression(parameter->getArrayLeft())\n            << expressionFormatter_->formatReferringExpression(parameter->getArrayRight())\n            << parameter->description()\n        );\n\n        writeTableRow(stream, paramFields, 4);\n    }\n\n    stream << indent(3) << \"</table>\" << Qt::endl;\n}\n\n//-----------------------------------------------------------------------------\n// Function: HtmlWriter::writeMemoryMaps()\n//-----------------------------------------------------------------------------\nvoid HtmlWriter::writeMemoryMaps(QTextStream& stream, int subHeaderNumber)\n{\n    if (component_->getMemoryMaps()->isEmpty())\n    {\n        return;\n    }\n\n    writeSubHeader(stream, subHeaderNumber, \"Memory maps\", \"memoryMaps\");\n\n    const QList<QSharedPointer<MemoryMap> > componentMemoryMaps = *component_->getMemoryMaps().data();\n    int memoryMapNumber = 1;\n\n    for (auto const& memoryMap : componentMemoryMaps)\n    {\n        QList subHeaderNumbers({\n            componentNumber_,\n            subHeaderNumber,\n            memoryMapNumber,\n        });\n\n        writeSubHeader(stream, subHeaderNumbers, QStringLiteral(\"Memory map \") + memoryMap->name(), 3);\n\n        // Write memory map info.\n        writeInfoParagraph(\n            stream,\n            { QStringLiteral(\"Description\"), QStringLiteral(\"Address unit bits (AUB)\") },\n            { memoryMap->description(), memoryMap->getAddressUnitBits() }\n        );\n\n        QList <QSharedPointer <AddressBlock> > addressBlocks = getMemoryMapAddressBlocks(memoryMap);\n        writeAddressBlocks(stream, addressBlocks, subHeaderNumber, memoryMapNumber);\n\n        ++memoryMapNumber;\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: HtmlWriter::writeAddressBlocks()\n//-----------------------------------------------------------------------------\nvoid HtmlWriter::writeAddressBlocks(QTextStream& stream, QList<QSharedPointer<AddressBlock>> addressBlocks,\n    int subHeaderNumber, int memoryMapNumber)\n{\n    if (addressBlocks.isEmpty())\n    {\n        return;\n    }\n\n    int addressBlockNumber = 1;\n\n    for (auto const& addressBlock : addressBlocks)\n    {        \n        QList subHeaderNumbers({\n            componentNumber_,\n            subHeaderNumber,\n            memoryMapNumber,\n            addressBlockNumber\n        });\n        \n        writeSubHeader(stream, subHeaderNumbers, QStringLiteral(\"Address block \") + addressBlock->name(), 3);\n\n        writeAddressBlockInfo(stream, addressBlock);\n\n        // Running number to number address block registers and register files\n        int registerDataNumber = 1;\n\n        // Write address block registers\n        if (auto const addressBlockRegisters = getRegisters(addressBlock->getRegisterData());\n            !addressBlockRegisters.isEmpty())\n        {\n            QString registerTableText = QStringLiteral(\"Address block '\") + addressBlock->name() +\n                QStringLiteral(\"' contains the following registers:\");\n\n            writeSubHeader(stream, QList<int>(), registerTableText, 4);\n\n            writeRegisters(stream, addressBlockRegisters, subHeaderNumber,\n                memoryMapNumber, addressBlockNumber, registerDataNumber);\n        }\n\n        // Write address block register files\n        if (auto const addressBlockRegisterFiles = getRegisterFiles(addressBlock->getRegisterData());\n            !addressBlockRegisterFiles.isEmpty())\n        {\n            QString registerFilesSubText = QStringLiteral(\"Address block '\") + addressBlock->name()\n                + QStringLiteral(\"' contains the following register files:\");\n            writeSubHeader(stream, QList<int>(), registerFilesSubText, 4);\n\n            writeRegisterFiles(stream, addressBlockRegisterFiles, subHeaderNumbers, registerDataNumber);\n        }\n\n        ++addressBlockNumber;\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: HtmlWriter::writeRegisters()\n//-----------------------------------------------------------------------------\nvoid HtmlWriter::writeRegisters(QTextStream& stream, QList<QSharedPointer<Register> > registers,\n    int subHeaderNumber, int memoryMapNumber, int addressBlockNumber, int& registerDataNumber)\n{\n    if (registers.isEmpty())\n    {\n        return;\n    }\n\n    // Write table with all address block registers.\n    writeRegisterTable(stream, registers);\n    \n    // Write each register separately.\n    for (auto const& currentRegister : registers)\n    {\n        QList subHeaderNumbers({\n            componentNumber_,\n            subHeaderNumber,\n            memoryMapNumber,\n            addressBlockNumber,\n            registerDataNumber\n        });\n\n        writeSingleRegister(stream, currentRegister, subHeaderNumbers, registerDataNumber);\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: HtmlWriter::writeRegisterFiles()\n//-----------------------------------------------------------------------------\nvoid HtmlWriter::writeRegisterFiles(QTextStream& stream,\n    QList<QSharedPointer<RegisterFile> > registerFiles,\n    QList<int> subHeaderNumbers, int& registerDataNumber)\n{\n    for (auto const& registerFile : registerFiles)\n    {\n        QList registerFileSubHeaderNumbers(subHeaderNumbers);\n        registerFileSubHeaderNumbers.append(registerDataNumber);\n\n        writeSubHeader(stream, registerFileSubHeaderNumbers,\n            QStringLiteral(\"Register file \") + registerFile->name(), 3);\n\n        writeRegisterFileInfo(stream, registerFile);\n\n        auto const registerData = registerFile->getRegisterData();\n        auto const registersInFile = getRegisters(registerData);\n\n        int subRegisterDataNumber = 1;\n\n        if (!registersInFile.isEmpty())\n        {\n            writeSubHeader(stream, {}, QStringLiteral(\"Register file \")\n                + registerFile->name() + QStringLiteral(\" contains the following registers:\"), 4);\n            writeRegisterTable(stream, registersInFile);\n        }\n\n        // Write register file registers.\n        for (auto const& reg : registersInFile)\n        {\n            // Sub-registers need their own subheader number, as the hierarchy ends here.\n            QList newSubHeaderNumbers(registerFileSubHeaderNumbers);\n            newSubHeaderNumbers.append(subRegisterDataNumber);\n            writeSingleRegister(stream, reg, newSubHeaderNumbers, registerDataNumber);\n            subRegisterDataNumber++;\n        }\n\n        // Write the register files of the current register file recursively.\n        for (auto const& regFile : getRegisterFiles(registerData))\n        {\n            // Note: subRegisterDataNumber is passed to the recursive function call.\n            // The value of registerDataNumber stays constant for the same parent register file.\n            writeRegisterFiles(stream, QList({ regFile }), registerFileSubHeaderNumbers, subRegisterDataNumber);\n            subRegisterDataNumber++;\n        }\n\n        registerDataNumber++;\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: HtmlWriter::writeFields()\n//-----------------------------------------------------------------------------\nvoid HtmlWriter::writeFields(QTextStream& stream, QSharedPointer<Register> currentRegister,\n    QList<int> registerSubHeaderNumbers)\n{\n    if (currentRegister->getFields()->isEmpty())\n    {\n        return;\n    }\n\n    // Write all register fields in one table.\n    writeFieldTable(stream, currentRegister);\n\n    int fieldNumber = 1;\n\n    for (auto const& field : *currentRegister->getFields())\n    {\n        QList fieldSubHeaderNumbers = registerSubHeaderNumbers;\n        fieldSubHeaderNumbers << fieldNumber;\n\n        writeSubHeader(stream, fieldSubHeaderNumbers, QStringLiteral(\"Field \") + field->name(), 3);\n        writeSingleField(stream, field);\n\n        ++fieldNumber;\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: HtmlWriter::writePorts()\n//-----------------------------------------------------------------------------\nvoid HtmlWriter::writePorts(QTextStream& stream, int subHeaderNumber)\n{\n    writeSubHeader(stream, subHeaderNumber, \"Ports\", \"ports\");\n\n    const QList<QSharedPointer<Port> > ports = *component_->getPorts().data();\n    QString tableTitle = \"List of all ports the component has.\";\n    \n    writePortTable(stream, tableTitle, ports);\n}\n\n//-----------------------------------------------------------------------------\n// Function: HtmlWriter::writeInterfaces()\n//-----------------------------------------------------------------------------\nvoid HtmlWriter::writeInterfaces(QTextStream& stream, int& subHeaderNumber)\n{\n    writeSubHeader(stream, subHeaderNumber, \"Bus interfaces\", \"interfaces\");\n\n    int interfaceNumber = 1;\n\n    for (auto const& interface : *component_->getBusInterfaces())\n    {\n        QList subHeaderNumbers({\n            componentNumber_,\n            subHeaderNumber,\n            interfaceNumber,\n        });\n\n        writeSubHeader(stream, subHeaderNumbers, QStringLiteral(\"Bus interface \") + interface->name(), 3);\n\n        auto const ports = component_->getPortsMappedInInterface(interface->name());\n        \n        writeInterfaceInfo(stream, interface, !ports.isEmpty());\n\n        if (!ports.isEmpty())\n        {\n            writePortTable(stream, \"\", ports);\n        }\n\n        ++interfaceNumber;\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: HtmlWriter::writeFileSets()\n//-----------------------------------------------------------------------------\nvoid HtmlWriter::writeFileSets(QTextStream& stream, int& subHeaderNumber)\n{\n    writeSubHeader(stream, subHeaderNumber, \"File sets\", \"fileSets\");\n\n    const QList<QSharedPointer<FileSet> > fileSets = *component_->getFileSets();\n\n    int fileSetNumber = 1;\n\n    for (auto const& fileSet : fileSets)\n    {\n        writeSubHeader(stream, QList({ componentNumber_, subHeaderNumber, fileSetNumber }),\n            QStringLiteral(\"File set \") + fileSet->name(), 3);\n\n        stream << indent(3) << \"<p>\" << Qt::endl;\n\n        // description\n        if (!fileSet->description().isEmpty())\n        {\n            stream << indent(3) << HTML::INDENT << \"<strong>Description:</strong> \" <<\n                fileSet->description() << \"<br>\" << Qt::endl;\n        }\n\n        // identifiers\n        writeFileSetGroupdIdentifiers(stream, fileSet);\n\n        // Default file builders table\n        writeDefaultFileBuilders(stream, fileSet);\n\n        writeFiles(stream, fileSet, subHeaderNumber, fileSetNumber);\n\n        ++fileSetNumber;\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: HtmlWriter::setComponentNumber()\n//-----------------------------------------------------------------------------\nvoid HtmlWriter::setComponentNumber(int componentNumber)\n{\n    componentNumber_ = componentNumber;\n}\n\n//-----------------------------------------------------------------------------\n// Function: HtmlWriter::writeSubHeader()\n//-----------------------------------------------------------------------------\nvoid HtmlWriter::writeSubHeader(QTextStream& stream, int subHeaderNumber,\n    QString const& headerText, QString const& headerId) const\n{\n    stream << \"\\t\\t<h2><a id=\\\"\" << component_->getVlnv().toString() << \".\" << headerId << \"\\\">\" <<\n        componentNumber_ << \".\" << subHeaderNumber << \" \" << headerText << \"</a></h2>\" << Qt::endl;\n}\n\n//-----------------------------------------------------------------------------\n// Function: HtmlWriter::writeSubHeader()\n//-----------------------------------------------------------------------------\nvoid HtmlWriter::writeSubHeader(QTextStream& stream, QList<int> const& subHeaderNumbers,\n    QString const& title, int level) const\n{\n    // Writes the header level\n    QString headerTag = QStringLiteral(\"<h\") + QString::number(level) + QStringLiteral(\">\");\n    QString headerClosingTag = QStringLiteral(\"</h\") + QString::number(level) + QStringLiteral(\">\");\n\n    QStringList subHeaderNumberParts;\n    for (int number : subHeaderNumbers)\n    {\n        subHeaderNumberParts << QString::number(number);\n    }\n\n    QString headerTitle = title;\n\n    if (!subHeaderNumberParts.isEmpty())\n    {\n        headerTitle = subHeaderNumberParts.join(\".\") + \" \" + title;\n    }\n\n    stream << indent(3) << headerTag << headerTitle << headerClosingTag << Qt::endl;\n}\n\n//-----------------------------------------------------------------------------\n// Function: HtmlWriter::writeDescription()\n//-----------------------------------------------------------------------------\nvoid HtmlWriter::writeDescription(QTextStream& stream, QString const& description)\n{\n    stream << indent(3) << \"<p>\" << Qt::endl;\n    if (!description.isEmpty())\n    {\n        stream << indent(3) << HTML::INDENT << \"<strong>Description:</strong> \" <<\n            description << \"<br>\" << Qt::endl;\n    }\n    stream << indent(3) << \"</p>\" << Qt::endl;\n}\n\n//-----------------------------------------------------------------------------\n// Function: HtmlWriter::writeInfoParagraph()\n//-----------------------------------------------------------------------------\nvoid HtmlWriter::writeInfoParagraph(QTextStream& stream, QStringList const& names, QStringList const& values)\n{\n    stream << indent(3) << \"<p>\" << Qt::endl;\n\n    for (auto i = 0; i < names.length(); ++i)\n    {\n        stream << indent(3) << HTML::INDENT << \"<strong>\" << names.at(i) << \":</strong> \"\n            << values.at(i) << \"<br>\" << Qt::endl;\n    }\n\n    stream << indent(3) << \"</p>\" << Qt::endl;\n}\n\n//-----------------------------------------------------------------------------\n// Function: HtmlWriter::writeErrorMessage()\n//-----------------------------------------------------------------------------\nvoid HtmlWriter::writeErrorMessage(QTextStream& stream, QString const& message)\n{\n    stream << indent(3) << \"<p>\" << Qt::endl;\n    stream << indent(3) << \"<strong><font color=red>\" << message << \"</font></strong><br>\" << Qt::endl;\n    stream << indent(3) << \"</p>\" << Qt::endl;\n}\n\n//-----------------------------------------------------------------------------\n// Function: HtmlWriter::writeDocumentReference()\n//-----------------------------------------------------------------------------\nvoid HtmlWriter::writeDocumentReference(QTextStream& stream, QString const& documentType,\n    QSharedPointer<ConfigurableVLNVReference> vlnvReference)\n{\n    if (!vlnvReference)\n    {\n        return;\n    }\n\n    if (!libraryHandler_->getModelReadOnly(*vlnvReference))\n    {\n        QString errorMsg(QObject::tr(\"VLNV: %1 was not found in library.\").arg(vlnvReference->toString()));\n        writeErrorMessage(stream, errorMsg);\n        return;\n    }\n\n    stream << indent(3) << \"<p>\" << Qt::endl;\n    stream << indent(4) << HTML::INDENT <<\n        \"<strong>\" << documentType << \": </strong>\" << vlnvReference->toString() << \"<br>\" << Qt::endl;\n\n    QFileInfo vlnvXMLInfo(libraryHandler_->getPath(*vlnvReference));\n    QString relativeXmlPath = General::getRelativePath(getTargetPath(), vlnvXMLInfo.absoluteFilePath());\n\n    stream << indent(4) << HTML::INDENT << \"<strong>\" <<\n        \"IP-Xact file: </strong><a href=\\\"\" << relativeXmlPath << \"\\\">\" << vlnvXMLInfo.fileName() <<\n        \"</a><br>\" << Qt::endl;\n\n    stream << indent(3) << \"</p>\" << Qt::endl;\n}\n\n//-----------------------------------------------------------------------------\n// Function: HtmlWriter::writeDiagram()\n//-----------------------------------------------------------------------------\nvoid HtmlWriter::writeDiagram(QTextStream& stream, QString const& title,\n    QString const& link, QString const& altText)\n{\n    stream << indent(3) << title << \"<br>\" << Qt::endl;\n    stream << indent(3) << \"<img src=\\\"\" << link << \"\\\" alt=\\\"\" << altText << \"\\\"><br>\" << Qt::endl;\n}\n\n//-----------------------------------------------------------------------------\n// Function: HtmlWriter::writeDesignInstances()\n//-----------------------------------------------------------------------------\nvoid HtmlWriter::writeDesignInstances(QTextStream& stream, QSharedPointer<Design> design,\n    QSharedPointer<DesignConfiguration> configuration)\n{\n    if (design->getComponentInstances()->isEmpty())\n    {\n        return;\n    }\n\n    QString instanceTitle = QString(\"Component instances within design %1\").arg(design->getVlnv().toString());\n    stream << indent(3) << \"<br>\" << Qt::endl;\n    stream << indent(3) << instanceTitle << \":<br>\" << Qt::endl;\n    \n    stream << indent(3) << HTML::TABLE << \"\\\">\" << Qt::endl;\n    \n    writeTableHeader(stream, DocumentationWriter::DESIGN_INSTANCE_HEADERS, 3);\n\n    for (auto const& instance : *design->getComponentInstances())\n    {\n        QStringList rowCells(QStringList()\n            << instance->getInstanceName()\n            << \"<a href=\\\"\" + instance->getComponentRef()->toString(\":\") + \"\\\">\"\n                + instance->getComponentRef()->toString(\" - \") + \"</a>\"\n            << getComponentInstanceConfigurableElements(instance, design)\n            << (configuration && configuration->getDesignRef() == design->getVlnv()\n                ? configuration->getActiveView(instance->getInstanceName())\n                : QStringLiteral(\"\"))\n        );\n\n        writeTableRow(stream, rowCells, 4);\n    }\n\n    stream << indent(3) << \"</table>\" << Qt::endl;\n}\n\n//-----------------------------------------------------------------------------\n// Function: HtmlWriter::writeEndOfDocument()\n//-----------------------------------------------------------------------------\nvoid HtmlWriter::writeEndOfDocument(QTextStream& stream)\n{\n    stream << indent(1) << \"</body>\" << Qt::endl;\n    stream << \"</html>\" << Qt::endl;\n}\n\n//-----------------------------------------------------------------------------\n// Function: HtmlWriter::indent()\n//-----------------------------------------------------------------------------\nQString HtmlWriter::indent(int n) const\n{\n    auto tab = QStringLiteral(\"\\t\");\n    return tab.repeated(n);\n}\n\n//-----------------------------------------------------------------------------\n// Function: HtmlWriter::writeRegisterTable()\n//-----------------------------------------------------------------------------\nvoid HtmlWriter::writeRegisterTable(QTextStream& stream, QList<QSharedPointer<Register>> registers)\n{\n    QStringList allRegistersTableHeader;\n    allRegistersTableHeader << QStringLiteral(\"Register name\");\n    allRegistersTableHeader.append(DocumentationWriter::REGISTER_HEADERS);\n\n    stream << indent(3) << HTML::TABLE << \"\" << \"\\\">\" << Qt::endl;\n    writeTableHeader(stream, allRegistersTableHeader, 4);\n\n    for (auto const& currentRegister : registers)\n    {\n        QStringList registerInfoTableRowCells(QStringList()\n            << currentRegister->name()\n            << expressionFormatter_->formatReferringExpression(currentRegister->getAddressOffset())\n            << expressionFormatter_->formatReferringExpression(currentRegister->getSize())\n            << expressionFormatter_->formatReferringExpression(currentRegister->getDimension())\n            << currentRegister->getVolatile()\n            << AccessTypes::access2Str(currentRegister->getAccess())\n        );\n\n        writeTableRow(stream, registerInfoTableRowCells, 4);\n    }\n\n    stream << indent(3) << \"</table>\" << Qt::endl;\n}\n\n//-----------------------------------------------------------------------------\n// Function: HtmlWriter::writeFieldTable()\n//-----------------------------------------------------------------------------\nvoid HtmlWriter::writeFieldTable(QTextStream& stream, QSharedPointer<Register> reg)\n{\n    stream << indent(3) << \"<h4>Register '\" << reg->name() << \"' contains the following fields:</h4>\" <<\n        Qt::endl;\n\n    QString tableTitle = \"List of fields contained within register \" + reg->name() + \".\";\n    stream << indent(3) << HTML::TABLE << tableTitle << \"\\\">\" << Qt::endl;\n\n    writeTableHeader(stream, DocumentationWriter::FIELD_HEADERS, 4);\n\n    for (auto const& field : *reg->getFields())\n    {\n        QStringList fieldTableCells(QStringList()\n            << \"<a id=\\\"\" + vlnvString_ + \".field.\" + field->name() + \"\\\">\" + field->name() + \"</a>\"\n            << expressionFormatter_->formatReferringExpression(field->getBitOffset())\n            << expressionFormatter_->formatReferringExpression(field->getBitWidth())\n            << field->getVolatile().toString()\n            << AccessTypes::access2Str(field->getAccess())\n            << getFieldResetInfo(field)\n            << field->description()\n        );\n\n        writeTableRow(stream, fieldTableCells, 4);\n    }\n\n    stream << indent(3) << \"</table>\" << Qt::endl;\n}\n\n//-----------------------------------------------------------------------------\n// Function: HtmlWriter::writeFieldEnumerations()\n//-----------------------------------------------------------------------------\nvoid HtmlWriter::writeFieldEnumerations(QTextStream& stream, QSharedPointer<Field> field)\n{\n    auto const enumerations = field->getEnumeratedValues();\n\n    if (enumerations->isEmpty())\n    {\n        return;\n    }\n\n    writeSubHeader(stream, {}, \"Enumerations:\", 4);\n\n    stream << indent(3) << HTML::TABLE << \"\" << \"\\\">\" << Qt::endl;\n\n    writeTableHeader(stream, { \"Name\", \"Value\" }, 4);\n\n    for (auto const& enumeration : *enumerations)\n    {\n        writeTableRow(stream, { enumeration->name(), enumeration->getValue() }, 4);\n    }\n    stream << indent(3) << \"</table>\" << Qt::endl;\n}\n\n//-----------------------------------------------------------------------------\n// Function: HtmlWriter::writeTableRow()\n//-----------------------------------------------------------------------------\nvoid HtmlWriter::writeTableRow(QTextStream& stream, QStringList const& cells, int indentation) const\n{\n    stream << indent(indentation) << \"<tr>\" << Qt::endl;\n    \n    for (auto const& field : cells)\n    {\n        stream << indent(indentation + 1) << \"<td>\" << field << \"</td>\" << Qt::endl;\n    }\n\n    stream << indent(indentation) << \"</tr>\" << Qt::endl;\n}\n\n//-----------------------------------------------------------------------------\n// Function: HtmlWriter::writeTableHeader()\n//-----------------------------------------------------------------------------\nvoid HtmlWriter::writeTableHeader(QTextStream& stream, QStringList const& headerCells, int indentation) const\n{\n    stream << indent(indentation) << \"<tr>\" << Qt::endl;\n\n    for (auto const& fields : headerCells)\n    {\n        stream << indent(indentation + 1) << \"<th>\" << fields << \"</th>\" << Qt::endl;\n    }\n\n    stream << indent(indentation) << \"</tr>\" << Qt::endl;\n}\n\n//-----------------------------------------------------------------------------\n// Function: HtmlWriter::writePortTable()\n//-----------------------------------------------------------------------------\nvoid HtmlWriter::writePortTable(QTextStream& stream, QString const& tableTitle,\n    QList<QSharedPointer<Port>> ports) const\n{\n    stream << indent(3) << HTML::TABLE << tableTitle << \"\\\">\" << Qt::endl;\n\n    writeTableHeader(stream, DocumentationWriter::PORT_HEADERS, 4);\n\n    for (auto const& port : ports)\n    {\n        QStringList portTableCells(QStringList()\n            << \"<a id=\\\"\" + vlnvString_ + \".port.\" + port->name() + \"\\\">\" + port->name() + \"</a>\"\n            << DirectionTypes::direction2Str(port->getDirection())\n            << expressionFormatter_->formatReferringExpression(port->getLeftBound())\n            << expressionFormatter_->formatReferringExpression(port->getRightBound())\n            << port->getTypeName()\n            << port->getTypeDefinition(port->getTypeName())\n            << expressionFormatter_->formatReferringExpression(port->getDefaultValue())\n            << expressionFormatter_->formatReferringExpression(port->getArrayLeft())\n            << expressionFormatter_->formatReferringExpression(port->getArrayRight())\n            << port->description()\n        );\n\n        writeTableRow(stream, portTableCells, 4);\n    }\n\n    stream << indent(3) << \"</table>\" << Qt::endl;\n}\n\n//-----------------------------------------------------------------------------\n// Function: HtmlWriter::writeFileSetGroupdIdentifiers()\n//-----------------------------------------------------------------------------\nvoid HtmlWriter::writeFileSetGroupdIdentifiers(QTextStream& stream, QSharedPointer<FileSet> fileSet) const\n{\n    stream << indent(3) << HTML::INDENT << \"<strong>Identifiers:</strong> \";\n    \n    QStringList groups = *fileSet->getGroups();\n    \n    stream << groups.join(\", \") << \"<br>\" << Qt::endl;\n}\n\n//-----------------------------------------------------------------------------\n// Function: HtmlWriter::writeDefaultFileBuilders()\n//-----------------------------------------------------------------------------\nvoid HtmlWriter::writeDefaultFileBuilders(QTextStream& stream, QSharedPointer<FileSet> fileSet) const\n{\n    const auto defaultFileBuilders = fileSet->getDefaultFileBuilders();\n\n    if (defaultFileBuilders->isEmpty())\n    {\n        stream << indent(3) << \"</p>\" << Qt::endl;\n        return;\n    }\n\n    stream << indent(3) << HTML::INDENT << \"<strong>Default file builders:</strong>\" << Qt::endl;\n    stream << indent(3) << \"</p>\" << Qt::endl;\n\n    QString tableTitle = QStringLiteral(\"Default file build commands\");\n    stream << indent(3) << HTML::TABLE << tableTitle << \"\\\">\" << Qt::endl;\n\n    writeTableHeader(stream, DocumentationWriter::DEFAULT_FILE_BUILDER_HEADERS, 4);\n\n    for (auto const& defaultBuilder : *defaultFileBuilders)\n    {\n        QStringList builderCells(QStringList()\n            << defaultBuilder->getFileType().type_\n            << defaultBuilder->getCommand()\n            << defaultBuilder->getFlags()\n            << expressionFormatter_->formatReferringExpression(defaultBuilder->getReplaceDefaultFlags())\n        );\n\n        writeTableRow(stream, builderCells, 4);\n    }\n\n    stream << indent(3) << \"</table>\" << Qt::endl;\n}\n\n//-----------------------------------------------------------------------------\n// Function: HtmlWriter::writeFiles()\n//-----------------------------------------------------------------------------\nvoid HtmlWriter::writeFiles(QTextStream& stream, QSharedPointer<FileSet> fileSet,\n    int subHeaderNumber, int fileSetNumber)\n{\n    QList<QSharedPointer<File> > files = *fileSet->getFiles();\n\n    if (files.isEmpty())\n    {\n        return;\n    }\n\n    int filesSubHeaderNumber = 1;\n\n    QList filesSubHeaderNumbers({\n        componentNumber_,\n        subHeaderNumber,\n        fileSetNumber,\n        filesSubHeaderNumber\n    });\n\n    writeSubHeader(stream, filesSubHeaderNumbers, \"Files\", 4);\n\n    QString tableTitle = QStringLiteral(\"List of files contained in this file set.\");\n    stream << indent(3) << HTML::TABLE << tableTitle << \"\\\">\" << Qt::endl;\n\n    writeTableHeader(stream, DocumentationWriter::FILE_HEADERS, 4);\n\n    for (auto const& file : files)\n    {\n        writeSingleFile(stream, file);\n    }\n\n    stream << indent(3) << \"</table>\" << Qt::endl;\n}\n\n//-----------------------------------------------------------------------------\n// Function: HtmlWriter::writeSingleFile()\n//-----------------------------------------------------------------------------\nvoid HtmlWriter::writeSingleFile(QTextStream& stream, QSharedPointer<File> file) const\n{\n    QString relativeFilePath = file->name();\n    QString absFilePath = General::getAbsolutePath(libraryHandler_->getPath(component_->getVlnv()),\n        relativeFilePath);\n\n    QFileInfo fileInfo(absFilePath);\n\n    // get relative path from html file to the file\n    QFileInfo htmlInfo(getTargetPath());\n    QString pathFromDocToFile = General::getRelativePath(getTargetPath(), absFilePath);\n\n    QSharedPointer<BuildCommand> buildCommand = file->getBuildCommand();\n\n    QStringList fileTypes;\n    for (auto const& fileType : *file->getFileTypes())\n    {\n        fileTypes.append(fileType.type_);\n    }\n\n    QStringList fileTableCells(QStringList()\n        << \"<a href=\\\"\" + pathFromDocToFile + \"\\\">\" + file->name() + \"</a>\"\n        << file->getLogicalName()\n        << (buildCommand ? buildCommand->getCommand() : QStringLiteral(\"\"))\n        << (buildCommand ? buildCommand->getFlags() : QStringLiteral(\"\"))\n        << fileTypes.join(\",<br>\")\n        << file->getDescription()\n    );\n\n    writeTableRow(stream, fileTableCells, 4);\n}\n\n//-----------------------------------------------------------------------------\n// Function: HtmlWriter::writeImplementationDetails()\n//-----------------------------------------------------------------------------\nvoid HtmlWriter::writeImplementationDetails(QTextStream& stream,\n    QSharedPointer<ComponentInstantiation> instantiation)\n{\n    QString language = instantiation->getLanguage();\n    QString library = instantiation->getLibraryName();\n    QString package = instantiation->getPackageName();\n    QString module = instantiation->getModuleName();\n    QString architecture = instantiation->getArchitectureName();\n    QString configuration = instantiation->getConfigurationName();\n\n    if (language.isEmpty() && library.isEmpty() && package.isEmpty() && module.isEmpty() &&\n        architecture.isEmpty() && configuration.isEmpty())\n    {\n        return;\n    }\n\n    stream << indent(3) << \"<p>\" << Qt::endl;\n\n    if (!language.isEmpty())\n    {\n        stream << indent(4) << HTML::INDENT << \"<strong>Language: </strong>\" <<\n            language;\n\n        if (instantiation->isLanguageStrict())\n        {\n            stream << \" <strong>strict</strong>\";\n        }\n\n        stream << \"<br>\" << Qt::endl;\n    }\n    if (!library.isEmpty())\n    {\n        stream << indent(4) << HTML::INDENT << \"<strong>Library: </strong>\" <<\n            library << \"<br>\" << Qt::endl;\n    }\n    if (!package.isEmpty())\n    {\n        stream << indent(4) << HTML::INDENT << \"<strong>Package: </strong>\" <<\n            package << \"<br>\" << Qt::endl;\n    }\n    if (!module.isEmpty())\n    {\n        stream << indent(4) << HTML::INDENT << \"<strong>Module name: </strong>\" <<\n            module << \"<br>\" << Qt::endl;\n    }\n    if (!architecture.isEmpty())\n    {\n        stream << indent(4) << HTML::INDENT <<\n            \"<strong>Architecture: </strong>\" << architecture << \"<br>\" << Qt::endl;\n    }\n    if (!configuration.isEmpty())\n    {\n        stream << indent(4) << HTML::INDENT <<\n            \"<strong>Configuration: </strong>\" << configuration << \"<br>\" << Qt::endl;\n    }\n\n    stream << indent(3) << \"</p>\" << Qt::endl;\n}\n\n//-----------------------------------------------------------------------------\n// Function: HtmlWriter::writeFileSetReferences()\n//-----------------------------------------------------------------------------\nvoid HtmlWriter::writeFileSetReferences(QTextStream& stream, QSharedPointer<ComponentInstantiation> instantiation)\n{\n    auto fileSetRefs = instantiation->getFileSetReferences();\n\n    if (fileSetRefs->isEmpty())\n    {\n        return;\n    }\n\n    stream << indent(3) << \"<p>\" << Qt::endl;\n    stream << indent(4) << \"File sets contained in this component instantiation: </strong>\" <<\n        Qt::endl;\n    stream << indent(3) << \"</p>\" << Qt::endl;\n\n    stream << indent(3) << \"<ul>\" << Qt::endl;\n\n    for (auto const& fileSetRef : *fileSetRefs)\n    {\n        stream << indent(4) << \"<li><a href=\\\"#\" << component_->getVlnv().toString() <<\n            \".fileSet.\" << fileSetRef->getReference() << \"\\\">\" << fileSetRef->getReference() << \n            \"</a></li>\" << Qt::endl;\n    }\n\n    stream << indent(3) << \"</ul>\" << Qt::endl;\n}\n\n//-----------------------------------------------------------------------------\n// Function: HtmlWriter::writeFileBuildCommands()\n//-----------------------------------------------------------------------------\nvoid HtmlWriter::writeFileBuildCommands(QTextStream& stream, QSharedPointer<ComponentInstantiation> instantiation,\n    QSharedPointer<ExpressionFormatter> instantiationFormatter)\n{\n    if (instantiation->getDefaultFileBuilders()->isEmpty())\n    {\n        return;\n    }\n\n    stream << indent(3) << \"<p>Default file build commands:</p>\" << Qt::endl;\n\n    stream << indent(3) << HTML::TABLE << \"\\\">\" << Qt::endl;\n    writeTableHeader(stream, DocumentationWriter::DEFAULT_FILE_BUILDER_HEADERS, 3);\n\n    for (auto const& defaultBuilder : *instantiation->getDefaultFileBuilders())\n    {\n        QStringList builderCells(QStringList()\n            << defaultBuilder->getFileType().type_\n            << defaultBuilder->getCommand()\n            << defaultBuilder->getFlags()\n            << instantiationFormatter->formatReferringExpression(defaultBuilder->getReplaceDefaultFlags())\n        );\n\n        writeTableRow(stream, builderCells, 4);\n    }\n\n    stream << indent(3) << \"</table>\" << Qt::endl;\n}\n\n//-----------------------------------------------------------------------------\n// Function: HtmlWriter::writeConfigurableElementValues()\n//-----------------------------------------------------------------------------\nvoid HtmlWriter::writeConfigurableElementValues(QTextStream& stream,\n    QSharedPointer<ConfigurableVLNVReference> vlnvReference,\n    QSharedPointer<ExpressionFormatter> instantiationFormatter)\n{\n    if (!vlnvReference || !vlnvReference->getConfigurableElementValues() ||\n        vlnvReference->getConfigurableElementValues()->isEmpty())\n    {\n        return;\n    }\n\n    stream << indent(3) << \"<p>Configurable element values:</p>\" << Qt::endl;\n\n    QStringList paramHeaders({ QStringLiteral(\"Name\"), QStringLiteral(\"Value\") });\n    \n    stream << indent(3) << HTML::TABLE << \"\\\">\" << Qt::endl;\n    writeTableHeader(stream, paramHeaders, 3);\n\n    for (auto const& element : *vlnvReference->getConfigurableElementValues())\n    {\n        QStringList rowCells(QStringList()\n            << instantiationFormatter->formatReferringExpression(element->getReferenceId())\n            << instantiationFormatter->formatReferringExpression(element->getConfigurableValue())\n        );\n        writeTableRow(stream, rowCells, 4);\n    }\n\n    stream << indent(3) << \"</table>\" << Qt::endl;\n}\n\nvoid HtmlWriter::writeModuleParameterTable(QTextStream& stream, QString const& tableHeading,\n    QSharedPointer<QList<QSharedPointer<Parameter> > > moduleParameters,\n    QSharedPointer<ExpressionFormatter> formatter)\n{\n    if (!moduleParameters || moduleParameters->isEmpty())\n    {\n        return;\n    }\n\n    stream << indent(3) << \"<p><strong>\" << tableHeading << \"</strong></p>\" << Qt::endl;\n\n    stream << indent(3) << HTML::TABLE << \"\\\">\" << Qt::endl;\n    writeTableHeader(stream, DocumentationWriter::MODULE_PARAMETER_HEADERS, 4);\n\n    for (auto const& parameter : *moduleParameters)\n    {\n        QSharedPointer<ModuleParameter> moduleParameter = parameter.dynamicCast<ModuleParameter>();\n\n        QStringList paramCells(QStringList()\n            << moduleParameter->name()\n            << moduleParameter->getType()\n            << formatter->formatReferringExpression(moduleParameter->getValue())\n            << moduleParameter->getDataType()\n            << moduleParameter->getUsageType()\n            << moduleParameter->getValueResolve()\n            << formatter->formatReferringExpression(moduleParameter->getVectorLeft())\n            << formatter->formatReferringExpression(moduleParameter->getVectorRight())\n            << formatter->formatReferringExpression(moduleParameter->getArrayLeft())\n            << formatter->formatReferringExpression(moduleParameter->getArrayRight())\n            << moduleParameter->description()\n        );\n\n        writeTableRow(stream, paramCells, 4);\n    }\n\n    stream << indent(3) << \"</table>\" << Qt::endl;\n}\n\n//-----------------------------------------------------------------------------\n// Function: HtmlWriter::getComponentInstanceConfigurableElements()\n//-----------------------------------------------------------------------------\nQString HtmlWriter::getComponentInstanceConfigurableElements(QSharedPointer<ComponentInstance> instance,\n    QSharedPointer<Design> design)\n{\n    QString cell;\n    VLNV componentVLNV = *instance->getComponentRef();\n\n    QSharedPointer<Document> libComp = libraryHandler_->getModel(componentVLNV);\n    QSharedPointer<Component> component = libComp.staticCast<Component>();\n\n    QSharedPointer<ExpressionFormatter> equationFormatter = createDesignInstanceFormatter(design, component);\n\n    QSharedPointer<QList<QSharedPointer<ConfigurableElementValue> > >  confElements =\n        instance->getConfigurableElementValues();\n\n    for (auto const& element : *confElements)\n    {\n        QString configurableElementID = element->getReferenceId();\n        QString configurableElementName = equationFormatter->formatReferringExpression(configurableElementID);\n\n        if (configurableElementID == configurableElementName)\n        {\n            cell.append(QStringLiteral(\"<font color=red>Unknown</font>\"));\n        }\n        else\n        {\n            cell.append(configurableElementName);\n        }\n\n        cell.append(\" = \" + equationFormatter->formatReferringExpression(element->getConfigurableValue()));\n\n        if (element != confElements->last())\n        {\n            cell.append(QStringLiteral(\"<br>\"));\n        }\n    }\n\n    return cell;\n}\n\n//-----------------------------------------------------------------------------\n// Function: HtmlWriter::writeParameterTable()\n//-----------------------------------------------------------------------------\nvoid HtmlWriter::writeParameterTable(QTextStream& stream, QString const& tableHeading,\n    ParameterList parameters, QSharedPointer<ExpressionFormatter> formatter)\n{\n    if (!parameters || parameters->isEmpty())\n    {\n        return;\n    }\n\n    stream << indent(3) << \"<p><strong>\" << tableHeading << \"</strong></p>\" << Qt::endl;\n\n    stream << indent(3) << HTML::TABLE <<\"\\\">\" << Qt::endl;\n\n    writeTableHeader(stream, DocumentationWriter::PARAMETER_HEADERS, 4);\n\n    for (auto const& parameter : *parameters)\n    {\n        QStringList paramCells(QStringList()\n            << parameter->name()\n            << parameter->getType()\n            << formatter->formatReferringExpression(parameter->getValue())\n            << parameter->getValueResolve()\n            << formatter->formatReferringExpression(parameter->getVectorLeft())\n            << formatter->formatReferringExpression(parameter->getVectorRight())\n            << formatter->formatReferringExpression(parameter->getArrayLeft())\n            << formatter->formatReferringExpression(parameter->getArrayRight())\n            << parameter->description()\n        );\n\n        writeTableRow(stream, paramCells, 4);\n    }\n\n    stream << indent(3) << \"</table>\" << Qt::endl;\n}\n"
  },
  {
    "path": "kactusGenerators/DocumentGenerator/HtmlWriter.h",
    "content": "//-----------------------------------------------------------------------------\n// File: HtmlWriter.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Anton Hagqvist\n// Date: 12.4.2023\n//\n// Description:\n// Writes HTML documentation\n//-----------------------------------------------------------------------------\n\n#ifndef HTMLWRITER_H\n#define HTMLWRITER_H\n\n#include <IPXACTmodels/Component/Component.h>\n#include <IPXACTmodels/DesignConfiguration/DesignConfiguration.h>\n\n#include <kactusGenerators/DocumentGenerator/DocumentationWriter.h>\n\n#include <QTextStream>\n#include <QSharedPointer>\n\nclass ExpressionFormatter;\nclass LibraryInterface;\nclass AddressBlock;\nclass MemoryMap;\nclass Register;\nclass Field;\nclass ListParameterFinder;\nclass ComponentInstantiation;\n\nclass HtmlWriter : public DocumentationWriter\n{\npublic:\n    HtmlWriter(QSharedPointer<Component> component, ExpressionFormatter* formatter,\n        ExpressionFormatterFactory* expressionFormatterFactory,\n        LibraryInterface* libraryHhandler, int componentNumber);\n\n    ~HtmlWriter() override;\n\n    /*!\n     *  Write the document header.\n     *\n     *    @param [in] stream  The text stream to write the header into.\n     */\n    void writeHeader(QTextStream& stream) override;\n\n    /*!\n     *  Write a header for the component.\n     *\n     *    @param [in] stream  The text stream to write the header into.\n     */\n    void writeComponentHeader(QTextStream& stream) override;\n\n    /*!\n     *  Write the component info.\n     *\n     *    @param [in] stream  The text stream to write into.\n     */\n    void writeComponentInfo(QTextStream& stream) override;\n    \n    /*!\n     *  Write component kactus2 attributes.\n     *\n     *    @param [in] stream              The text stream to write into.\n     *    @param [in] subHeaderNumber     The current subheader number.\n     */\n    void writeKactusAttributes(QTextStream& stream, int subHeaderNumber) override;\n\n    /*!\n     *  Write the table of contents header.\n     *\n     *    @param [in] stream  The text stream to write into.\n     */\n    void writeTableOfContentsHeader(QTextStream& stream) override;\n\n    /*!\n     *  Write the table of contents of the current component.\n     *\n     *    @param [in] stream  The text stream to write into.\n     */\n    void writeTableOfContents(QTextStream& stream) override;\n\n    /*!\n     *  Write the parameters of the component\n     *\n     *    @param [in] stream              The text stream to write into.\n     *    @param [in] subHeaderNumber     The current subheader number.\n     */\n    void writeParameters(QTextStream& stream, int subHeaderNumber) override;\n\n    /*!\n     *  Write the memory maps of the component\n     *\n     *    @param [in] stream              The text stream to write into.\n     *    @param [in] subHeaderNumber     The current subheader number.\n     */\n    void writeMemoryMaps(QTextStream& stream, int subHeaderNumber) override;\n\n    /*!\n     *  Write the given address blocks\n     *\n     *    @param [in] stream              The text stream to write into.\n     *    @param [in] addressBlocks       The address blocks to be written.\n     *    @param [in] subHeaderNumber     The current subheader number.\n     *    @param [in] memoryMapNumber     The current memory map number.\n     */\n    void writeAddressBlocks(QTextStream& stream, QList<QSharedPointer <AddressBlock> > addressBlocks,\n        int subHeaderNumber, int memoryMapNumber) override;\n\n    /*!\n     *  Write the given registers\n     *\n     *    @param [in] stream              The text stream to write into.\n     *    @param [in] registers           The registers to be written.\n     *    @param [in] subHeaderNumber     The current subheader number.\n     *    @param [in] memoryMapNumber     The current memory map number.\n     *    @param [in] addressBlockNumber  The current address block number.\n     */\n    void writeRegisters(QTextStream& stream, QList<QSharedPointer <Register> > registers,\n        int subHeaderNumber, int memoryMapNumber, int addressBlockNumber, int& registerDataNumber) override;\n\n    void writeRegisterFiles(QTextStream& stream,\n        QList<QSharedPointer<RegisterFile> > registerFiles,\n        QList<int> subHeaderNumbers, int& registerDataNumber) override;\n\n    /*!\n     *  Write the given register fields\n     *\n     *    @param [in] stream              The text stream to write into.\n     *    @param [in] register            The register whose fields are to be written.\n     */\n    void writeFields(QTextStream& stream, QSharedPointer <Register> currentRegister,\n        QList<int> registerSubHeaderNumbers) override;\n\n    /*!\n     *  Write the ports of the component\n     *\n     *    @param [in] stream              The text stream to write into.\n     *    @param [in] subHeaderNumber     The current subheader number.\n     */\n    void writePorts(QTextStream& stream, int subHeaderNumber) override;\n\n    /*!\n     *  Write the bus interfaces of the component\n     *\n     *    @param [in] stream              The text stream to write into.\n     *    @param [in] subHeaderNumber     The current subheader number.\n     */\n    void writeInterfaces(QTextStream& stream, int& subHeaderNumber) override;\n\n    /*!\n     *  Write the file sets of the component\n     *\n     *    @param [in] stream              The text stream to write into.\n     *    @param [in] subHeaderNumber     The current subheader number.\n     */\n    void writeFileSets(QTextStream& stream, int& subHeaderNumber) override;\n\n    /*!\n     *  Set the number of the component in the hierarchy\n     *\n     *    @param [in] componentNumber     The new component number.\n     */\n    void setComponentNumber(int componentNumber) override;\n\n    /*!\n     *  Write a referenced component subheader\n     *\n     *    @param [in] stream              The text stream to write into.\n     *    @param [in] subHeaderNumber     The current subheader number.\n     *    @param [in] headerText          The displayed header text.\n     *    @param [in] headerId            The id for referencing within the document.\n     */\n    void writeSubHeader(QTextStream& stream, int subHeaderNumber,\n        QString const& headerText, QString const& headerId) const override;\n\n    /*!\n     *  Write a non-referenced component subheader with specified header level\n     *\n     *    @param [in] stream              The text stream to write into.\n     *    @param [in] subHeaderNumbers    The subheader numbers.\n     *    @param [in] title               The displayed header text.\n     *    @param [in] headerId            The id for referencing within the document.\n     */\n    void writeSubHeader(QTextStream& stream, QList<int> const& subHeaderNumbers,\n        QString const& title, int level) const override;\n\n    /*!\n     *  Write a description text\n     *\n     *    @param [in] stream              The text stream to write into.\n     *    @param [in] description         The description to write.\n     */\n    void writeDescription(QTextStream& stream, QString const& description) override;\n\n    /*!\n     *  Write a paragraph in which specific information is listed.\n     *\n     *    @param [in] stream              The text stream to write into.\n     *    @param [in] names               The info item names.\n     *    @param [in] values              The info item values.\n     */\n    void writeInfoParagraph(QTextStream& stream, QStringList const& names, QStringList const& values) override;\n\n    /*!\n     *  Write an error text to the document.\n     *\n     *    @param [in] stream              The text stream to write into..\n     *    @param [in] message             The description to write.\n     */\n    void writeErrorMessage(QTextStream& stream, QString const& message) override;\n\n    /*!\n     *  Write the document contained within the selected VLNV.\n     *\n     *    @param [in] stream                  Text stream to write the document.\n     *    @param [in] documentType            Type of the document.\n     *    @param [in] vlnvReference           VLNV of the selected document.\n     */\n    void writeDocumentReference(QTextStream& stream, QString const& documentType,\n        QSharedPointer<ConfigurableVLNVReference> vlnvReference) override;\n\n    /*!\n     *  Write the design diagram.\n     *\n     *    @param [in] stream                  Text stream to write the diagram to.\n     *    @param [in] title                   Diagram title.\n     *    @param [in] link                    Diagram picture link or path.\n     *    @param [in] altText                 Diagram alt text.\n     */\n    void writeDiagram(QTextStream& stream, QString const& title, QString const& link, QString const& altText)\n        override;\n    \n    /*!\n     *  Write the component instances contained within the selected design.\n     *\n     *    @param [in] stream          Text stream to write the component instances.\n     *    @param [in] design          The selected design.\n     *    @param [in] configuration   The selected design configuration.\n     */\n    void writeDesignInstances(QTextStream& stream, QSharedPointer<Design> design,\n        QSharedPointer<DesignConfiguration> configuration) override;\n\n    /*!\n     *  Write the end of the HTML document.\n     *\n     *    @param [in] stream  The text stream to write the documentation into.\n     */\n    void writeEndOfDocument(QTextStream& stream) override;\n\nprivate:\n    \n    /*!\n     *  Returns n tabs for HTML indentation.\n     *\n     *    @param [in] n       The number of tabs.\n     * \n     *    @returns n tabs.\n     */\n    QString indent(int n) const;\n    \n    /*!\n     *  Writes a table of registers.\n     *\n     *    @param [in] stream              The text stream to write into.\n     *    @param [in] registers           The registers to be written.\n     */\n    void writeRegisterTable(QTextStream& stream, QList<QSharedPointer<Register> >registers);\n\n    /*!\n     *  Writes a table of register fields.\n     *\n     *    @param [in] stream       The text stream to write into.\n     *    @param [in] reg          The register whose fields are written.\n     */\n    void writeFieldTable(QTextStream& stream, QSharedPointer<Register> reg);\n\n    /*!\n     *  Writes the enumerations of a field.\n     *\n     *    @param [in] stream              The text stream to write into.\n     *    @param [in] field               The field which enumerations are written.\n     */\n    void writeFieldEnumerations(QTextStream& stream, QSharedPointer<Field> field) override;\n\n    /*!\n     *  Writes a row with specified cells to a HTML table with chosen indentation.\n     *  Indentation is the number of tabs for the parent element.\n     *\n     *    @param [in] stream          Text stream to write to.\n     *    @param [in] cells           Table row cells.\n     *    @param [in] indentation     The table element indentation.\n     */\n    void writeTableRow(QTextStream& stream, QStringList const& cells, int indentation) const;\n\n    /*!\n     *  Writes the table header row with chosen indentation. \n     *  Indentation should be one more than table element indentation.\n     *\n     *    @param [in] stream          Text stream to write to.\n     *    @param [in] headerCells     The table headers.\n     *    @param [in] indentation     The table element indentation.\n     */\n    void writeTableHeader(QTextStream& stream, QStringList const& headerCells, int indentation) const;\n\n    /*!\n     *  Writes a port table for specified ports.\n     *\n     *    @param [in] stream          Text stream to write to.\n     *    @param [in] ports           The ports to be written.\n     */\n    void writePortTable(QTextStream& stream, QString const& tableTitle,\n        QList<QSharedPointer<Port> > ports) const;\n    \n    /*!\n     *  Writes group identifiers for a file set.\n     *\n     *    @param [in] stream          Text stream to write to.\n     *    @param [in] fileSet         File set to write identifiers for.\n     */\n    void writeFileSetGroupdIdentifiers(QTextStream& stream, QSharedPointer<FileSet> fileSet) const;\n\n    /*!\n     *  Writes the default file builders for a file set.\n     *\n     *    @param [in] stream          Text stream to write to.\n     *    @param [in] fileSet         File set to write file builders for.\n     */\n    void writeDefaultFileBuilders(QTextStream& stream, QSharedPointer<FileSet> fileSet) const;\n\n    /*!\n     *  Writes the files of a file set.\n     *\n     *    @param [in] stream          Text stream to write to.\n     *    @param [in] fileSet         File set whose files will be written.\n     *    @param [in] subHeaderNumber The current subheader number.\n     *    @param [in] fileSetNumber   The current file set number.\n     */\n    void writeFiles(QTextStream& stream, QSharedPointer<FileSet> fileSet,\n        int subHeaderNumber, int fileSetNumber);\n\n    /*!\n     *  Writes a specified file of a file set.\n     *\n     *    @param [in] stream          Text stream to write to.\n     *    @param [in] file            File to be written.\n     */\n    void writeSingleFile(QTextStream& stream, QSharedPointer<File> file) const;\n\n    /*!\n     *  Writes the implementation details of a component instantiation.\n     *\n     *    @param [in] stream          Text stream to write to.\n     *    @param [in] instantiation   The component instantiation.\n     */\n    void writeImplementationDetails(QTextStream& stream,\n        QSharedPointer<ComponentInstantiation> instantiation) override;\n\n    /*!\n     *  Writes the file set references contained within a component instantiation.\n     *\n     *    @param [in] stream          Text stream to write to.\n     *    @param [in] instantiation   The component instantiation.\n     */\n    void writeFileSetReferences(QTextStream& stream,\n        QSharedPointer<ComponentInstantiation> instantiation) override;\n\n    /*!\n     *  Writes the file build commands of a component instantiation.\n     *\n     *    @param [in] stream          Text stream to write to.\n     *    @param [in] instantiation   The component instantiation.\n     *    @param [in] formatter       The expression formatter for the component instantiation.\n     */\n    void writeFileBuildCommands(QTextStream& stream, QSharedPointer<ComponentInstantiation> instantiation,\n        QSharedPointer<ExpressionFormatter> instantiationFormatter) override;\n\n    /*!\n     *  Writes given parameters to a table.\n     *\n     *    @param [in] stream          Text stream to write to.\n     *    @param [in] tableHeading    The heading above the table\n     *    @param [in] parameters      The parameters to be written.\n     *    @param [in] formatter       The expression formatter for the parameters.\n     */\n    void writeParameterTable(QTextStream& stream, QString const& tableHeading,\n        QSharedPointer<QList<QSharedPointer<Parameter> > > parameters,\n        QSharedPointer<ExpressionFormatter> formatter) override;\n\n    /*!\n     *  Writes given module parameters to a table.\n     *\n     *    @param [in] stream              Text stream to write to.\n     *    @param [in] tableHeading        The heading above the table.\n     *    @param [in] moduleParameters    The module parameters to be written.\n     *    @param [in] formatter           The expression formatter for the parameters.\n     */\n    void writeModuleParameterTable(QTextStream& stream, QString const& tableHeading,\n        QSharedPointer<QList<QSharedPointer<Parameter> > > moduleParameters,\n        QSharedPointer<ExpressionFormatter> formatter) override;\n\n    /*!\n     *  Writes the configurable element values of a VLNV.\n     *\n     *    @param [in] stream                  Text stream to write the document.\n     *    @param [in] vlnvReference           Configurable VLNV containing the selected configurable element\n     *                                          values.\n     *    @param [in] instantiationFormatter  Expression formatter for the configurable element values.\n     */\n    void writeConfigurableElementValues(QTextStream& stream,\n        QSharedPointer<ConfigurableVLNVReference> vlnvReference,\n        QSharedPointer<ExpressionFormatter> instantiationFormatter) override;\n\n    /*!\n     *  Gets the configurable element values of a component instance as a line-broken string.\n     *\n     *    @param [in] stream          Text stream to write the document.\n     *    @param [in] instance        The component instance.\n     *    @param [in] design          The design in which the component instance is.\n     */\n    QString getComponentInstanceConfigurableElements(QSharedPointer<ComponentInstance> instance,\n        QSharedPointer<Design> design);\n\n    //-----------------------------------------------------------------------------\n    // Data.\n    //-----------------------------------------------------------------------------\n    \n    //! The expression formatter, used to change parameter IDs into names.\n    ExpressionFormatter* expressionFormatter_;\n\n    //! The library handler\n    LibraryInterface* libraryHandler_;\n\n    //! The current component\n    QSharedPointer<Component> component_;\n\n    //! Component number for table of contents\n    int componentNumber_;\n\n    //! Stringified VLNV of the component\n    QString vlnvString_;\n};\n\n#endif // HTMLWRITER_H"
  },
  {
    "path": "kactusGenerators/DocumentGenerator/MarkdownWriter.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: MarkdownWriter.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Anton Hagqvist\n// Date: 12.4.2023\n//\n// Description:\n// Writes markdown documentation of a component.\n//-----------------------------------------------------------------------------\n\n#include \"MarkdownWriter.h\"\n\n#include <IPXACTmodels/Component/Component.h>\n#include <IPXACTmodels/Component/MemoryMap.h>\n#include <IPXACTmodels/Component/AddressBlock.h>\n#include <IPXACTmodels/Component/Register.h>\n#include <IPXACTmodels/Component/RegisterFile.h>\n#include <IPXACTmodels/Component/Field.h>\n#include <IPXACTmodels/Component/BusInterface.h>\n#include <IPXACTmodels/Component/FileSet.h>\n#include <IPXACTmodels/Component/EnumeratedValue.h>\n#include <IPXACTmodels/Design/Design.h>\n\n#include <IPXACTmodels/DesignConfiguration/DesignConfiguration.h>\n\n#include <KactusAPI/include/ExpressionFormatter.h>\n#include <KactusAPI/include/LibraryInterface.h>\n#include <KactusAPI/include/ListParameterFinder.h>\n\n#include <QFileInfo>\n#include <QDateTime>\n#include <QSettings>\n#include <QString>\n\n//-----------------------------------------------------------------------------\n// Function: MarkdownWriter::MarkdownWriter()\n//-----------------------------------------------------------------------------\nMarkdownWriter::MarkdownWriter(QSharedPointer<Component> component, ExpressionFormatter* formatter,\n    ExpressionFormatterFactory* expressionFormatterFactory,\n    LibraryInterface* libraryHandler, int componentNumber) :\n    DocumentationWriter(formatter, expressionFormatterFactory),\n    expressionFormatter_(formatter),\n    libraryHandler_(libraryHandler),\n    component_(component),\n    componentNumber_(componentNumber)\n{\n    vlnvString_ = component_->getVlnv().toString();\n}\n\n//-----------------------------------------------------------------------------\n// Function: MarkdownWriter::~MarkdownWriter()\n//-----------------------------------------------------------------------------\nMarkdownWriter::~MarkdownWriter()\n{\n}\n\n//-----------------------------------------------------------------------------\n// Function: MarkdownWriter::writeHeader()\n//-----------------------------------------------------------------------------\nvoid MarkdownWriter::writeHeader(QTextStream& stream)\n{\n    QSettings settings;\n    \n    // Write markdown header\n    stream << \"###### This document was generated by Kactus2 on \" \n        << QDateTime::currentDateTime().toString(\"dd.MM.yyyy hh:mm:ss\")\n        << \" by user \" << settings.value(\"General/Username\").toString()\n        << \"  \" << Qt::endl << Qt::endl;\n}\n\n//-----------------------------------------------------------------------------\n// Function: MarkdownWriter::writeComponentHeader()\n//-----------------------------------------------------------------------------\nvoid MarkdownWriter::writeComponentHeader(QTextStream& stream)\n{\n    // For empty line between table of contents and first component\n    if (componentNumber_ == 1)\n    {\n        stream << Qt::endl;\n    }\n    \n    stream << \"# \" << componentNumber_ << \". Component \" << vlnvString_ \n        << \"<a id=\\\"\" << vlnvString_ << \"\\\">  \" << Qt::endl << Qt::endl;\n}\n\n//-----------------------------------------------------------------------------\n// Function: MarkdownWriter::writeComponentInfo()\n//-----------------------------------------------------------------------------\nvoid MarkdownWriter::writeComponentInfo(QTextStream& stream)\n{\n    stream << \"![Component \" << component_->getVlnv().toString(\".\") << \"](\"\n        << getImagesPath().split(\"/\").back() << \"/\"\n        << component_->getVlnv().toString(\".\") << \".png)\" << Qt::endl << Qt::endl;\n\n    if (auto const& description = component_->getDescription(); !description.isEmpty())\n    {\n        writeDescription(stream, description);\n    }\n    \n    // print relative path to the xml file\n    QFileInfo compXmlInfo(libraryHandler_->getPath(component_->getVlnv()));\n    QString relativeXmlPath = General::getRelativePath(getTargetPath(), compXmlInfo.absoluteFilePath());\n\n    stream << \"**IP-Xact file:** \" << \"[\" << compXmlInfo.fileName() << \"](\" << relativeXmlPath << \")  \"\n        << Qt::endl << Qt::endl;\n}\n\n//-----------------------------------------------------------------------------\n// Function: MarkdownWriter::writeKactusAttributes()\n//-----------------------------------------------------------------------------\nvoid MarkdownWriter::writeKactusAttributes(QTextStream& stream, int subHeaderNumber)\n{\n    writeSubHeader(stream, subHeaderNumber, \"Kactus2 attributes\", \"attributes\");\n\n    stream << \"**Product hierarchy:** \" <<\n        KactusAttribute::hierarchyToString(component_->getHierarchy()) << \"  \" << Qt::endl\n        << \"**Component implementation:** \" <<\n        KactusAttribute::implementationToString(component_->getImplementation()) << \"  \" << Qt::endl\n        << \"**Component firmness:** \" <<\n        KactusAttribute::firmnessToString(component_->getFirmness()) << \"  \" << Qt::endl << Qt::endl;\n}\n\n//-----------------------------------------------------------------------------\n// Function: MarkdownWriter::writeTableOfContentsHeader()\n//-----------------------------------------------------------------------------\nvoid MarkdownWriter::writeTableOfContentsHeader(QTextStream& stream)\n{\n    stream << \"**Table of contents**  \" << Qt::endl << Qt::endl;\n}\n\n//-----------------------------------------------------------------------------\n// Function: MarkdownWriter::writeTableOfContents()\n//-----------------------------------------------------------------------------\nvoid MarkdownWriter::writeTableOfContents(QTextStream& stream)\n{\n    // Write component header\n    stream << componentNumber_ << \". [\" << \"Component \" << component_->getVlnv().toString(\" - \") << \"]\" <<\n        \"(#\" << vlnvString_ << \")  \" << Qt::endl;\n\n    // subHeader is running number that counts the number of sub headers for component\n    int subHeader = 1;\n\n    // Write component subheaders. Component has at least kactus attributes.\n    stream << \"\\t\" << componentNumber_ << \".\" << subHeader << \". \" << \"[Kactus2 attributes\" <<\n        \"](#\" << vlnvString_ << \".attributes)  \" << Qt::endl;\n\n    ++subHeader;\n\n    if (component_->hasParameters())\n    {\n        stream << \"\\t\" << componentNumber_ << \".\" << subHeader << \". \" << \"[General parameters]\" <<\n            \"(#\" << vlnvString_ << \".parameters)  \" << Qt::endl;\n        ++subHeader;\n    }\n\n    if (!component_->getMemoryMaps()->isEmpty())\n    {\n        stream << \"\\t\" << componentNumber_ << \".\" << subHeader << \". \" << \"[Memory maps]\" <<\n            \"(#\" << vlnvString_ << \".memoryMaps)  \" << Qt::endl;\n        ++subHeader;\n    }\n\n    if (component_->hasPorts())\n    {\n        stream << \"\\t\" << componentNumber_ << \".\" << subHeader << \". \" << \"[Ports]\" <<\n            \"(#\" << vlnvString_ << \".ports)  \" << Qt::endl;\n        ++subHeader;\n    }\n    \n    if (component_->hasInterfaces())\n    {\n        stream << \"\\t\" << componentNumber_ << \".\" << subHeader << \". \" << \"[Bus interfaces]\" <<\n            \"(#\" << vlnvString_ << \".interfaces)  \" << Qt::endl;\n        ++subHeader;\n    }\n    \n    if (component_->hasFileSets())\n    {\n        stream << \"\\t\" << componentNumber_ << \".\" << subHeader << \". \" << \"[File sets]\" <<\n            \"(#\" << vlnvString_ << \".fileSets)  \" << Qt::endl;\n        ++subHeader;\n    }\n\n    if (component_->hasViews())\n    {\n        stream << \"\\t\" << componentNumber_ << \".\" << subHeader << \". \" << \"[Views]\" <<\n            \"(#\" << vlnvString_ << \".views)  \" << Qt::endl;\n        ++subHeader;\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: MarkdownWriter::writeParameters()\n//-----------------------------------------------------------------------------\nvoid MarkdownWriter::writeParameters(QTextStream& stream, int subHeaderNumber)\n{\n    writeSubHeader(stream, subHeaderNumber, \"General parameters\", \"parameters\");\n    \n    writeTableHeader(stream, DocumentationWriter::PARAMETER_HEADERS);\n\n    for (auto const& parameter : *component_->getParameters())\n    {\n        QStringList paramCells(QStringList()\n            << parameter->name()\n            << parameter->getType()\n            << expressionFormatter_->formatReferringExpression(parameter->getValue())\n            << parameter->getValueResolve()\n            << expressionFormatter_->formatReferringExpression(parameter->getVectorLeft())\n            << expressionFormatter_->formatReferringExpression(parameter->getVectorRight())\n            << expressionFormatter_->formatReferringExpression(parameter->getArrayLeft())\n            << expressionFormatter_->formatReferringExpression(parameter->getArrayRight())\n            << parameter->description()\n        );\n\n        writeTableRow(stream, paramCells);\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: MarkdownWriter::writeMemoryMaps()\n//-----------------------------------------------------------------------------\nvoid MarkdownWriter::writeMemoryMaps(QTextStream& stream, int subHeaderNumber)\n{\n    if (component_->getMemoryMaps()->isEmpty())\n    {\n        return;\n    }\n    \n    writeSubHeader(stream, subHeaderNumber, \"Memory maps\", \"memoryMaps\");\n\n    const QList<QSharedPointer<MemoryMap> > componentMemoryMaps = *component_->getMemoryMaps();\n    int memoryMapNumber = 1;\n\n    for (auto const& memoryMap : componentMemoryMaps)\n    {\n        QList subHeaderNumbers({\n            componentNumber_,\n            subHeaderNumber,\n            memoryMapNumber\n        });\n\n        writeSubHeader(stream, subHeaderNumbers, QStringLiteral(\"Memory map \") + memoryMap->name(), 3);\n\n        // Memory map description and address unit bits\n        if (!memoryMap->description().isEmpty())\n        {\n            writeDescription(stream, memoryMap->description());\n        }\n        \n        stream << \"**Address unit bits (AUB):** \" << memoryMap->getAddressUnitBits()\n            << \"  \" << Qt::endl << Qt::endl;\n\n        QList<QSharedPointer <AddressBlock> > addressBlocks = getMemoryMapAddressBlocks(memoryMap);\n        writeAddressBlocks(stream, addressBlocks, subHeaderNumber, memoryMapNumber);\n\n        ++memoryMapNumber;\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: MarkdownWriter::writeAddressBlocks()\n//-----------------------------------------------------------------------------\nvoid MarkdownWriter::writeAddressBlocks(QTextStream& stream, QList<QSharedPointer<AddressBlock>> addressBlocks,\n    int subHeaderNumber, int memoryMapNumber)\n{\n    if (addressBlocks.isEmpty())\n    {\n        return;\n    }\n\n    int addressBlockNumber = 1;\n\n    for (auto const& addressBlock : addressBlocks)\n    {\n        QList subHeaderNumbers({\n            componentNumber_,\n            subHeaderNumber,\n            memoryMapNumber,\n            addressBlockNumber\n        });\n          \n        writeSubHeader(stream, subHeaderNumbers, QStringLiteral(\"Address block \") + addressBlock->name(), 3);\n\n        writeAddressBlockInfo(stream, addressBlock);\n        \n        // Running number to number address block registers and register files\n        int registerDataNumber = 1;\n\n        // Write address block registers\n        if (auto const addressBlockRegisters = getRegisters(addressBlock->getRegisterData());\n            !addressBlockRegisters.isEmpty())\n        {\n            QString registerTableText = QStringLiteral(\"Address block '\") + addressBlock->name() +\n                QStringLiteral(\"' contains the following registers:\");\n            \n            writeSubHeader(stream, QList<int>(), registerTableText, 4);\n            \n            writeRegisters(stream, addressBlockRegisters, subHeaderNumber,\n                memoryMapNumber, addressBlockNumber, registerDataNumber);\n        }\n\n        // Write address block register files\n        if (auto const addressBlockRegisterFiles = getRegisterFiles(addressBlock->getRegisterData());\n            !addressBlockRegisterFiles.isEmpty())\n        {\n            QString registerFilesSubText = QStringLiteral(\"Address block '\") + addressBlock->name()\n                + QStringLiteral(\"' contains the following register files:\");\n            writeSubHeader(stream, QList<int>(), registerFilesSubText, 4);\n\n            writeRegisterFiles(stream, addressBlockRegisterFiles, subHeaderNumbers, registerDataNumber);\n        }\n\n        ++addressBlockNumber;\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: MarkdownWriter::writeRegisterFiles()\n//-----------------------------------------------------------------------------\nvoid MarkdownWriter::writeRegisterFiles(QTextStream& stream, QList<QSharedPointer<RegisterFile > > registerFiles,\n    QList<int> subHeaderNumbers, int& registerDataNumber)\n{\n    for (auto const& registerFile : registerFiles)\n    {\n        QList registerFileSubHeaderNumbers(subHeaderNumbers);\n        registerFileSubHeaderNumbers.append(registerDataNumber);\n\n        writeSubHeader(stream, registerFileSubHeaderNumbers,\n            QStringLiteral(\"Register file \") + registerFile->name(), 3);\n\n        writeRegisterFileInfo(stream, registerFile);\n        \n        auto const registerData = registerFile->getRegisterData();\n\n        int subRegisterDataNumber = 1;\n\n        auto const registersInFile = getRegisters(registerData);\n\n        if (!registersInFile.isEmpty())\n        {\n            writeSubHeader(stream, {}, QStringLiteral(\"Register file \")\n                + registerFile->name() + QStringLiteral(\" contains the following registers:\"), 4);\n            writeRegisterTable(stream, registersInFile);\n        }\n\n        // Write register file registers.\n        for (auto const& reg : registersInFile)\n        {\n            // Sub-registers need their own subheader number, as the hierarchy ends here.\n            QList newSubHeaderNumbers(registerFileSubHeaderNumbers);\n            newSubHeaderNumbers.append(subRegisterDataNumber);\n            writeSingleRegister(stream, reg, newSubHeaderNumbers, registerDataNumber);\n            subRegisterDataNumber++;\n        }\n\n        // Write the register files of the current register file recursively.\n        for (auto const& regFile : getRegisterFiles(registerData))\n        {\n            // Note: subRegisterDataNumber is passed to the recursive function call.\n            // The value of registerDataNumber stays constant for the same parent register file.\n            writeRegisterFiles(stream, QList({ regFile }), registerFileSubHeaderNumbers, subRegisterDataNumber);\n            subRegisterDataNumber++;\n        }\n\n        registerDataNumber++;\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: MarkdownWriter::writeRegisters()\n//-----------------------------------------------------------------------------\nvoid MarkdownWriter::writeRegisters(QTextStream& stream, QList<QSharedPointer<Register > > registers,\n    int subHeaderNumber, int memoryMapNumber, int addressBlockNumber, int& registerDataNumber)\n{\n    if (registers.isEmpty())\n    {\n        return;\n    }\n\n    // Write table with all registers of the address block.\n    writeRegisterTable(stream, registers);\n\n    // Write each register separately.\n    for (auto const& currentRegister : registers)\n    {\n        QList subHeaderNumbers({\n            componentNumber_,\n            subHeaderNumber,\n            memoryMapNumber,\n            addressBlockNumber,\n            registerDataNumber\n        });\n\n        writeSingleRegister(stream, currentRegister, subHeaderNumbers, registerDataNumber);\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: MarkdownWriter::writeFields()\n//-----------------------------------------------------------------------------\nvoid MarkdownWriter::writeFields(QTextStream& stream, QSharedPointer<Register> currentRegister,\n    QList<int> registerSubHeaderNumbers)\n{\n    if (currentRegister->getFields()->isEmpty())\n    {\n        return;\n    }\n\n    // Write all register fields in one table.\n    writeFieldTable(stream, currentRegister);\n\n    int fieldNumber = 1;\n\n    for (auto const& field : *currentRegister->getFields())\n    {\n        QList fieldSubHeaderNumbers = registerSubHeaderNumbers;\n        fieldSubHeaderNumbers << fieldNumber;\n\n        writeSubHeader(stream, fieldSubHeaderNumbers, QStringLiteral(\"Field \") + field->name(), 3);\n        writeSingleField(stream, field);\n\n        ++fieldNumber;\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: MarkdownWriter::writePorts()\n//-----------------------------------------------------------------------------\nvoid MarkdownWriter::writePorts(QTextStream& stream, int subHeaderNumber)\n{\n    writeSubHeader(stream, subHeaderNumber, \"Ports\", \"ports\");\n\n    const QList<QSharedPointer<Port> > ports = *component_->getPorts();\n\n    writePortTable(stream, ports);\n}\n\n//-----------------------------------------------------------------------------\n// Function: MarkdownWriter::writeInterfaces()\n//-----------------------------------------------------------------------------\nvoid MarkdownWriter::writeInterfaces(QTextStream& stream, int& subHeaderNumber)\n{\n    writeSubHeader(stream, subHeaderNumber, \"Bus interfaces\", \"interfaces\");\n\n    int interfaceNumber = 1;\n\n    for (auto const& interface : *component_->getBusInterfaces())\n    {        \n        QList subHeaderNumbers({ componentNumber_, subHeaderNumber, interfaceNumber });\n\n        writeSubHeader(stream, subHeaderNumbers, QStringLiteral(\"Bus interface \") + interface->name(), 3);\n        \n        auto const ports = component_->getPortsMappedInInterface(interface->name());\n        \n        writeInterfaceInfo(stream, interface, !ports.isEmpty());\n\n        if (!ports.isEmpty())\n        {\n            writePortTable(stream, ports);\n        }\n        \n        ++interfaceNumber;\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: MarkdownWriter::writeFileSets()\n//-----------------------------------------------------------------------------\nvoid MarkdownWriter::writeFileSets(QTextStream& stream, int& subHeaderNumber)\n{\n    writeSubHeader(stream, subHeaderNumber, \"File sets\", \"fileSets\");\n\n    const QList<QSharedPointer<FileSet> > fileSets = *component_->getFileSets();\n\n    int fileSetNumber = 1;\n\n    for (auto const& fileSet : fileSets)\n    {\n        writeSubHeader(stream, QList({ componentNumber_, subHeaderNumber, fileSetNumber }),\n            QStringLiteral(\"File set \") + fileSet->name(), 3);\n\n        // description\n        if (!fileSet->description().isEmpty())\n        {\n            writeDescription(stream, fileSet->description());\n        }\n\n        // identifiers\n        writeFileSetGroupdIdentifiers(stream, fileSet);\n\n        // Default file builders table\n        writeDefaultFileBuilders(stream, fileSet);\n\n        writeFiles(stream, fileSet, subHeaderNumber, fileSetNumber);\n\n        ++fileSetNumber;\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: MarkdownWriter::setComponentNumber()\n//-----------------------------------------------------------------------------\nvoid MarkdownWriter::setComponentNumber(int componentNumber)\n{\n    componentNumber_ = componentNumber;\n}\n\n//-----------------------------------------------------------------------------\n// Function: MarkdownWriter::writeSubHeader()\n//-----------------------------------------------------------------------------\nvoid MarkdownWriter::writeSubHeader(QTextStream& stream, int subHeaderNumber,\n    QString const& headerText, QString const& headerId) const\n{\n    stream << \"## \" << componentNumber_ << \".\" << subHeaderNumber << \" \" << headerText << \" <a id=\\\"\" <<\n        vlnvString_ << \".\" << headerId << \"\\\">  \" << Qt::endl << Qt::endl;\n}\n\n//-----------------------------------------------------------------------------\n// Function: MarkdownWriter::writeSubHeader()\n//-----------------------------------------------------------------------------\nvoid MarkdownWriter::writeSubHeader(QTextStream& stream, QList<int> const& subHeaderNumbers,\n    QString const& title, int level) const\n{\n    // Writes the header level\n    QString headerTag = QStringLiteral(\"#\").repeated(level) + \" \";\n\n    QStringList subHeaderNumberParts;\n    for (int number : subHeaderNumbers)\n    {\n        subHeaderNumberParts << QString::number(number);\n    }\n    \n    QString headerTitle = title;\n\n    if (!subHeaderNumberParts.isEmpty())\n    {\n        headerTitle = subHeaderNumberParts.join(\".\") + \" \" + title;\n    }\n\n    stream << headerTag << headerTitle << \"  \" << Qt::endl << Qt::endl;\n}\n\n//-----------------------------------------------------------------------------\n// Function: MarkdownWriter::writeInfoParagraph()\n//-----------------------------------------------------------------------------\nvoid MarkdownWriter::writeInfoParagraph(QTextStream& stream, QStringList const& names, QStringList const& values)\n{\n    for (auto i = 0; i < names.length(); ++i)\n    {\n        stream << \"**\" << names.at(i) << \":** \" << values.at(i) << \"  \" << Qt::endl;\n    }\n\n    stream << Qt::endl;\n}\n\n//-----------------------------------------------------------------------------\n// Function: MarkdownWriter::writeErrorMessage()\n//-----------------------------------------------------------------------------\nvoid MarkdownWriter::writeErrorMessage(QTextStream& stream, QString const& message)\n{\n    stream << \"<span style=\\\"color:red\\\">\" << message << \"</span>  \" << Qt::endl;\n}\n\n//-----------------------------------------------------------------------------\n// Function: MarkdownWriter::writeDocumentReference()\n//-----------------------------------------------------------------------------\nvoid MarkdownWriter::writeDocumentReference(QTextStream& stream, QString const& documentType,\n    QSharedPointer<ConfigurableVLNVReference> vlnvReference)\n{\n    if (!vlnvReference)\n    {\n        return;\n    }\n\n    if (!libraryHandler_->getModelReadOnly(*vlnvReference.data()))\n    {\n        QString errorMsg(QObject::tr(\"VLNV: %1 was not found in library.\").arg(vlnvReference->toString()));\n        writeErrorMessage(stream, errorMsg);\n        return;\n    }\n\n    stream << \"**\" << documentType << \":** \" << vlnvReference->toString() << \"  \" << Qt::endl;\n\n    QFileInfo vlnvXMLInfo(libraryHandler_->getPath(*vlnvReference.data()));\n    QString relativeXmlPath = General::getRelativePath(getTargetPath(), vlnvXMLInfo.absoluteFilePath());\n\n    stream << \"**IP-Xact file:** [\" << vlnvXMLInfo.fileName() << \"](\" << relativeXmlPath << \")  \" << Qt::endl;\n}\n\n//-----------------------------------------------------------------------------\n// Function: MarkdownWriter::writeDiagram()\n//-----------------------------------------------------------------------------\nvoid MarkdownWriter::writeDiagram(QTextStream& stream, QString const& title,\n    QString const& link,QString const& altText)\n{\n    stream << title << \"  \" << Qt::endl;\n    stream << \"![\" << altText << \"](\" << link << \")  \" << Qt::endl << Qt::endl;\n}\n\n//-----------------------------------------------------------------------------\n// Function: MarkdownWriter::writeDesignInstances()\n//-----------------------------------------------------------------------------\nvoid MarkdownWriter::writeDesignInstances(QTextStream& stream, QSharedPointer<Design> design,\n    QSharedPointer<DesignConfiguration> configuration)\n{\n    if (design->getComponentInstances()->isEmpty())\n    {\n        return;\n    }\n    \n    QString instanceTitle = QString(\"Component instances within design %1\").arg(design->getVlnv().toString());\n\n    stream << instanceTitle << \":  \" << Qt::endl << Qt::endl;\n\n    writeTableHeader(stream, DocumentationWriter::DESIGN_INSTANCE_HEADERS);\n\n    for (auto const& instance : *design->getComponentInstances())\n    {\n        QStringList rowCells(QStringList()\n            << instance->getInstanceName()\n            << \"[\" + instance->getComponentRef()->toString(\" - \") + \"](#\" \n                + instance->getComponentRef()->toString(\":\") + \")\"\n            << getComponentInstanceConfigurableElements(instance, design)\n            << (configuration && configuration->getDesignRef() == design->getVlnv()\n                ? configuration->getActiveView(instance->getInstanceName())\n                : QStringLiteral(\"\"))\n        );\n\n        writeTableRow(stream, rowCells);\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: MarkdownWriter::writeEndOfDocument()\n//-----------------------------------------------------------------------------\nvoid MarkdownWriter::writeEndOfDocument(QTextStream& /*stream*/)\n{\n}\n\n//-----------------------------------------------------------------------------\n// Function: MarkdownWriter::writeRegisterTable()\n//-----------------------------------------------------------------------------\nvoid MarkdownWriter::writeRegisterTable(QTextStream& stream, QList<QSharedPointer<Register>> registers) const\n{\n    QStringList allRegistersTableHeader;\n    allRegistersTableHeader << QStringLiteral(\"Register name\");\n    allRegistersTableHeader << DocumentationWriter::REGISTER_HEADERS;\n\n    writeTableHeader(stream, allRegistersTableHeader);\n\n    for (auto const& currentRegister : registers)\n    {\n        QStringList registersTableRowCells(QStringList()\n            << currentRegister->name()\n            << expressionFormatter_->formatReferringExpression(currentRegister->getAddressOffset())\n            << expressionFormatter_->formatReferringExpression(currentRegister->getSize())\n            << expressionFormatter_->formatReferringExpression(currentRegister->getDimension())\n            << currentRegister->getVolatile()\n            << AccessTypes::access2Str(currentRegister->getAccess())\n        );\n\n        writeTableRow(stream, registersTableRowCells);\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: MarkdownWriter::writeFieldTable()\n//-----------------------------------------------------------------------------\nvoid MarkdownWriter::writeFieldTable(QTextStream& stream, QSharedPointer<Register> reg) const\n{\n    QString headerTitle = QStringLiteral(\"Register '\")\n        + reg->name()\n        + QStringLiteral(\"' contains the following fields:\");\n\n    writeSubHeader(stream, QList <int>(), headerTitle, 4);\n    writeTableHeader(stream, DocumentationWriter::FIELD_HEADERS);\n\n    for (auto const& field : *reg->getFields())\n    {\n        QStringList fieldTableCells(QStringList()\n            << field->name() + \" <a id=\\\"\" + vlnvString_ + \".field.\" + field->name() + \"\\\">\"\n            << expressionFormatter_->formatReferringExpression(field->getBitOffset())\n            << expressionFormatter_->formatReferringExpression(field->getBitWidth())\n            << field->getVolatile().toString()\n            << AccessTypes::access2Str(field->getAccess())\n            << getFieldResetInfo(field)\n            << field->description()\n        );\n\n        writeTableRow(stream, fieldTableCells);\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: MarkdownWriter::writeFieldEnumerations()\n//-----------------------------------------------------------------------------\nvoid MarkdownWriter::writeFieldEnumerations(QTextStream& stream, QSharedPointer<Field> field)\n{\n    auto const enumerations = field->getEnumeratedValues();\n\n    if (enumerations->isEmpty())\n    {\n        return;\n    }\n\n    writeSubHeader(stream, {}, \"Enumerations:\", 4);\n\n    writeTableHeader(stream, { \"Name\", \"Value\" });\n    \n    for (auto const& enumeration : *enumerations)\n    {\n        writeTableRow(stream, { enumeration->name(), enumeration->getValue() });\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: MarkdownWriter::writeTableRow()\n//-----------------------------------------------------------------------------\nvoid MarkdownWriter::writeTableRow(QTextStream& stream, QStringList const& cells) const\n{\n    for (auto const& cell : cells)\n    {\n        stream << \"|\" << cell;\n    }\n\n    stream << \"|  \" << Qt::endl;\n}\n\n//-----------------------------------------------------------------------------\n// Function: MarkdownWriter::writeTableSeparator()\n//-----------------------------------------------------------------------------\nvoid MarkdownWriter::writeTableSeparator(QTextStream& stream, int columns) const\n{\n    QString tableSeparator(\":---- \");   // :--- aligns text in cells to the left\n    QStringList tableSeparators = tableSeparator.repeated(columns).split(\" \", Qt::SkipEmptyParts);\n    writeTableRow(stream, tableSeparators);\n}\n\n//-----------------------------------------------------------------------------\n// Function: MarkdownWriter::writeTableHeader()\n//-----------------------------------------------------------------------------\nvoid MarkdownWriter::writeTableHeader(QTextStream& stream, QStringList const& headers) const\n{\n    writeTableRow(stream, headers);\n    writeTableSeparator(stream, headers.length());\n}\n\n//-----------------------------------------------------------------------------\n// Function: MarkdownWriter::writePortTable()\n//-----------------------------------------------------------------------------\nvoid MarkdownWriter::writePortTable(QTextStream& stream, QList<QSharedPointer<Port>> ports) const\n{\n    writeTableHeader(stream, DocumentationWriter::PORT_HEADERS);\n\n    for (auto const& port : ports)\n    {\n        QStringList portTableCells(QStringList()\n            << port->name() + \" <a id=\\\"\" + vlnvString_ + \".port.\" + port->name() + \"\\\">\"\n            << DirectionTypes::direction2Str(port->getDirection())\n            << expressionFormatter_->formatReferringExpression(port->getLeftBound())\n            << expressionFormatter_->formatReferringExpression(port->getRightBound())\n            << port->getTypeName()\n            << port->getTypeDefinition(port->getTypeName())\n            << expressionFormatter_->formatReferringExpression(port->getDefaultValue())\n            << expressionFormatter_->formatReferringExpression(port->getArrayLeft())\n            << expressionFormatter_->formatReferringExpression(port->getArrayRight())\n            << port->description()\n        );\n\n        writeTableRow(stream, portTableCells);\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: MarkdownWriter::writeDescription()\n//-----------------------------------------------------------------------------\nvoid MarkdownWriter::writeDescription(QTextStream& stream, QString const& description)\n{\n    stream << \"**Description:** \" << description << \"  \" << Qt::endl << Qt::endl;\n}\n\n//-----------------------------------------------------------------------------\n// Function: MarkdownWriter::writeFileSetGroupdIdentifiers()\n//-----------------------------------------------------------------------------\nvoid MarkdownWriter::writeFileSetGroupdIdentifiers(QTextStream& stream, QSharedPointer<FileSet> fileSet) const\n{\n    stream << \"**Identifiers:** \";\n\n    QStringList groups = *fileSet->getGroups();\n    \n    stream << groups.join(\", \") << \"  \" << Qt::endl << Qt::endl;\n}\n\n//-----------------------------------------------------------------------------\n// Function: MarkdownWriter::writeDefaultFileBuilders()\n//-----------------------------------------------------------------------------\nvoid MarkdownWriter::writeDefaultFileBuilders(QTextStream& stream, QSharedPointer<FileSet> fileSet) const\n{\n    const auto defaultFileBuilders = fileSet->getDefaultFileBuilders();\n\n    if (defaultFileBuilders->isEmpty())\n    {\n        return;\n    }\n\n    stream << \"**Default file builders:**  \" << Qt::endl << Qt::endl;\n    \n    writeTableHeader(stream, DocumentationWriter::DEFAULT_FILE_BUILDER_HEADERS);\n\n    for (auto const& defaultBuilder : *defaultFileBuilders)\n    {\n        QStringList builderCells(QStringList()\n            << defaultBuilder->getFileType().type_\n            << defaultBuilder->getCommand()\n            << defaultBuilder->getFlags()\n            << expressionFormatter_->formatReferringExpression(defaultBuilder->getReplaceDefaultFlags())\n        );\n        \n        writeTableRow(stream, builderCells);\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: MarkdownWriter::writeFiles()\n//-----------------------------------------------------------------------------\nvoid MarkdownWriter::writeFiles(QTextStream& stream, QSharedPointer<FileSet> fileSet,\n    int subHeaderNumber, int fileSetNumber)\n{\n    QList<QSharedPointer<File> > files = *fileSet->getFiles();\n\n    if (files.isEmpty())\n    {\n        return;\n    }\n\n    int filesSubHeaderNumber = 1;\n\n    QList filesSubHeaderNumbers({\n        componentNumber_,\n        subHeaderNumber,\n        fileSetNumber,\n        filesSubHeaderNumber\n    });\n\n    writeSubHeader(stream, filesSubHeaderNumbers, \"Files\", 4);\n\n    writeTableHeader(stream, DocumentationWriter::FILE_HEADERS);\n\n    for (auto const& file : files)\n    {\n        writeSingleFile(stream, file);\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: MarkdownWriter::writeSingleFile()\n//-----------------------------------------------------------------------------\nvoid MarkdownWriter::writeSingleFile(QTextStream& stream, QSharedPointer<File> file) const\n{\n    QString relativeFilePath = file->name();\n    QString absFilePath = General::getAbsolutePath(libraryHandler_->getPath(component_->getVlnv()),\n        relativeFilePath);\n\n    QFileInfo fileInfo(absFilePath);\n\n    // get relative path from html file to the file\n    QFileInfo htmlInfo(getTargetPath());\n    QString pathFromDocToFile = General::getRelativePath(getTargetPath(), absFilePath);\n\n    QSharedPointer<BuildCommand> buildCommand = file->getBuildCommand();\n\n    QStringList fileTypes;\n    for (auto const& fileType : *file->getFileTypes())\n    {\n        fileTypes.append(fileType.type_);\n    }\n\n    QStringList fileTableCells(QStringList()\n        << \"[\" + fileInfo.fileName() + \"]\" + \"(\" + pathFromDocToFile + \")\"\n        << file->getLogicalName()\n        << (buildCommand ? buildCommand->getCommand() : QStringLiteral(\"\"))\n        << (buildCommand ? buildCommand->getFlags() : QStringLiteral(\"\"))\n        << fileTypes.join(\",<br>\")\n        << file->getDescription()\n    );\n\n    writeTableRow(stream, fileTableCells);\n}\n\n//-----------------------------------------------------------------------------\n// Function: MarkdownWriter::writeImplementationDetails()\n//-----------------------------------------------------------------------------\nvoid MarkdownWriter::writeImplementationDetails(QTextStream& stream,\n    QSharedPointer<ComponentInstantiation> instantiation)\n{\n    if (QString language = instantiation->getLanguage(); !language.isEmpty())\n    {\n        stream << \"**Language:** \" << language;\n\n        if (instantiation->isLanguageStrict())\n        {\n            stream << \" **strict**\";\n        }\n\n        stream << \"  \" << Qt::endl << Qt::endl;\n    }\n    \n    if (QString library = instantiation->getLibraryName(); !library.isEmpty())\n    {\n        stream << \"**Library:** \" << library << \"  \" << Qt::endl << Qt::endl;\n    }\n\n    if (QString package = instantiation->getPackageName(); !package.isEmpty())\n    {\n        stream << \"**Package:** \" << package << \"  \" << Qt::endl << Qt::endl;\n    }\n\n    if (QString module = instantiation->getModuleName(); !module.isEmpty())\n    {\n        stream << \"**Module name:** \" << module << \"  \" << Qt::endl << Qt::endl;\n    }\n\n    if (QString architecture = instantiation->getArchitectureName(); !architecture.isEmpty())\n    {\n        stream << \"**Architecture:** \" << architecture << \"  \" << Qt::endl << Qt::endl;\n    }\n\n    if (QString configuration = instantiation->getConfigurationName(); !configuration.isEmpty())\n    {\n        stream << \"**Configuration:** \" << configuration << \"  \" << Qt::endl << Qt::endl;\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: MarkdownWriter::writeFileSetReferences()\n//-----------------------------------------------------------------------------\nvoid MarkdownWriter::writeFileSetReferences(QTextStream& stream,\n    QSharedPointer<ComponentInstantiation> instantiation)\n{\n    auto fileSetRefs = instantiation->getFileSetReferences();\n\n    if (fileSetRefs->isEmpty())\n    {\n        return;\n    }\n\n    stream << \"**File sets containend in this instantiation:**  \" << Qt::endl;\n\n    for (auto const& fileSetRef : *fileSetRefs)\n    {\n        stream << \"- [\" << fileSetRef->getReference() << \"](#\" << vlnvString_ << \".fileSet.\" << \n            fileSetRef->getReference() << \")  \" << Qt::endl;\n    }\n\n    stream << Qt::endl;\n}\n\n//-----------------------------------------------------------------------------\n// Function: MarkdownWriter::writeFileBuildCommands()\n//-----------------------------------------------------------------------------\nvoid MarkdownWriter::writeFileBuildCommands(QTextStream& stream,\n    QSharedPointer<ComponentInstantiation> instantiation, QSharedPointer<ExpressionFormatter> formatter)\n{\n    if (instantiation->getDefaultFileBuilders()->isEmpty())\n    {\n        return;\n    }\n\n    stream << \"**Default file build commands:**  \" << Qt::endl << Qt::endl;\n\n    writeTableHeader(stream, DocumentationWriter::DEFAULT_FILE_BUILDER_HEADERS);\n\n    for (auto const& defaultBuilder : *instantiation->getDefaultFileBuilders())\n    {\n        QStringList builderCells(QStringList()\n            << defaultBuilder->getFileType().type_\n            << defaultBuilder->getCommand()\n            << defaultBuilder->getFlags()\n            << formatter->formatReferringExpression(defaultBuilder->getReplaceDefaultFlags())\n        );\n\n        writeTableRow(stream, builderCells);\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: MarkdownWriter::writeParameterTable()\n//-----------------------------------------------------------------------------\nvoid MarkdownWriter::writeParameterTable(QTextStream& stream, QString const& tableHeading,\n    ParameterList parameters, QSharedPointer<ExpressionFormatter> formatter)\n{\n    if (!parameters || parameters->isEmpty())\n    {\n        return;\n    }\n\n    stream << \"**\" << tableHeading << \"**  \" << Qt::endl << Qt::endl;\n\n    writeTableHeader(stream, DocumentationWriter::PARAMETER_HEADERS);\n\n    for (auto const& parameter : *parameters)\n    {\n        QStringList paramCells(QStringList()\n            << parameter->name()\n            << parameter->getType()\n            << formatter->formatReferringExpression(parameter->getValue())\n            << parameter->getValueResolve()\n            << formatter->formatReferringExpression(parameter->getVectorLeft())\n            << formatter->formatReferringExpression(parameter->getVectorRight())\n            << formatter->formatReferringExpression(parameter->getArrayLeft())\n            << formatter->formatReferringExpression(parameter->getArrayRight())\n            << parameter->description()\n        );\n\n        writeTableRow(stream, paramCells);\n    }\n\n    stream << Qt::endl;\n}\n\nvoid MarkdownWriter::writeModuleParameterTable(QTextStream& stream, QString const& tableHeading,\n    QSharedPointer<QList<QSharedPointer<Parameter> > > moduleParameters,\n    QSharedPointer<ExpressionFormatter> formatter)\n{\n    if (!moduleParameters || moduleParameters->isEmpty())\n    {\n        return;\n    }\n    \n    stream << \"**\" << tableHeading << \"**  \" << Qt::endl << Qt::endl;\n\n    writeTableHeader(stream, DocumentationWriter::MODULE_PARAMETER_HEADERS);\n\n    for (auto const& parameter : *moduleParameters)\n    {\n        QSharedPointer<ModuleParameter> moduleParameter = parameter.dynamicCast<ModuleParameter>();\n\n        QStringList paramCells(QStringList()\n            << moduleParameter->name()\n            << moduleParameter->getType()\n            << formatter->formatReferringExpression(moduleParameter->getValue())\n            << moduleParameter->getDataType()\n            << moduleParameter->getUsageType()\n            << moduleParameter->getValueResolve()\n            << formatter->formatReferringExpression(moduleParameter->getVectorLeft())\n            << formatter->formatReferringExpression(moduleParameter->getVectorRight())\n            << formatter->formatReferringExpression(moduleParameter->getArrayLeft())\n            << formatter->formatReferringExpression(moduleParameter->getArrayRight())\n            << moduleParameter->description()\n        );\n\n        writeTableRow(stream, paramCells);\n    }\n\n    stream << Qt::endl;\n}\n\n//-----------------------------------------------------------------------------\n// Function: MarkdownWriter::writeConfigurableElementValues()\n//-----------------------------------------------------------------------------\nvoid MarkdownWriter::writeConfigurableElementValues(QTextStream& stream,\n    QSharedPointer<ConfigurableVLNVReference> vlnvReference,\n    QSharedPointer<ExpressionFormatter> instantiationFormatter)\n{\n    if (!vlnvReference || !vlnvReference->getConfigurableElementValues() ||\n        vlnvReference->getConfigurableElementValues()->isEmpty())\n    {\n        return;\n    }\n\n    stream << \"Configurable element values:  \" << Qt::endl << Qt::endl;\n\n    QStringList paramHeaders({ QStringLiteral(\"Name\"), QStringLiteral(\"Value\") });\n    writeTableHeader(stream, paramHeaders);\n\n    for (auto const& element : *vlnvReference->getConfigurableElementValues())\n    {\n        QStringList rowCells(QStringList()\n            << instantiationFormatter->formatReferringExpression(element->getReferenceId())\n            << instantiationFormatter->formatReferringExpression(element->getConfigurableValue())\n        );\n        writeTableRow(stream, rowCells);\n    }\n\n    stream << Qt::endl;\n}\n\n//-----------------------------------------------------------------------------\n// Function: MarkdownWriter::getComponentInstanceConfigurableElements()\n//-----------------------------------------------------------------------------\nQString MarkdownWriter::getComponentInstanceConfigurableElements(QSharedPointer<ComponentInstance> instance,\n    QSharedPointer<Design> design)\n{\n    QString cell;\n    VLNV componentVLNV = *instance->getComponentRef();\n\n    QSharedPointer<Document> libComp = libraryHandler_->getModel(componentVLNV);\n    QSharedPointer<Component> component = libComp.staticCast<Component>();\n    \n    QSharedPointer<ExpressionFormatter> equationFormatter = createDesignInstanceFormatter(design, component);\n\n    QSharedPointer<QList<QSharedPointer<ConfigurableElementValue> > >  confElements =\n        instance->getConfigurableElementValues();\n\n    for (auto const& element : *confElements)\n    {\n        QString configurableElementID = element->getReferenceId();\n        QString configurableElementName = equationFormatter->formatReferringExpression(configurableElementID);\n\n        if (configurableElementID == configurableElementName)\n        {\n            cell.append(QStringLiteral(\"<span style=\\\"color: red\\\">Unknown</span>\"));\n        }\n        else\n        {\n            cell.append(configurableElementName);\n        }\n\n        cell.append(\" = \" + equationFormatter->formatReferringExpression(element->getConfigurableValue()));\n        \n        if (element != confElements->last())\n        {\n            cell.append(QStringLiteral(\"<br>\"));\n        }\n    }\n\n    return cell;\n}\n"
  },
  {
    "path": "kactusGenerators/DocumentGenerator/MarkdownWriter.h",
    "content": "//-----------------------------------------------------------------------------\n// File: MarkdownWriter.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Anton Hagqvist\n// Date: 12.4.2023\n//\n// Description:\n// Writes markdown documentation\n//-----------------------------------------------------------------------------\n\n#ifndef MARKDOWNWRITER_H\n#define MARKDOWNWRITER_H\n\n#include <IPXACTmodels/Component/Component.h>\n#include <IPXACTmodels/Component/MemoryMap.h>\n#include <IPXACTmodels/Component/AddressBlock.h>\n#include <IPXACTmodels/Component/Register.h>\n#include <IPXACTmodels/Component/Field.h>\n\n#include <IPXACTmodels/DesignConfiguration/DesignConfiguration.h>\n\n#include <kactusGenerators/DocumentGenerator/DocumentationWriter.h>\n\n#include <QTextStream>\n#include <QSharedPointer>\n#include <QList>\n\nclass ExpressionFormatter;\nclass Port;\nclass LibraryInterface;\nclass ComponentInstantiation;\nclass ListParameterFinder;\n\nclass MarkdownWriter : public DocumentationWriter\n{\npublic:\n    MarkdownWriter(QSharedPointer<Component> component, ExpressionFormatter* formatter,\n        ExpressionFormatterFactory* expressionFormatterFactory,\n        LibraryInterface* libraryHhandler, int componentNumber);\n\n    ~MarkdownWriter() override;\n\n    /*!\n     *  Write the document header.\n     *\n     *    @param [in] stream  The text stream to write the header into.\n     */\n    void writeHeader(QTextStream& stream) override;\n\n    /*!\n     *  Write a header for the component.\n     *\n     *    @param [in] stream  The text stream to write the header into.\n     */\n    void writeComponentHeader(QTextStream& stream) override;\n\n    /*!\n     *  Write the component info.\n     *\n     *    @param [in] stream  The text stream to write into.\n     */\n    void writeComponentInfo(QTextStream& stream) override;\n\n    /*!\n     *  Write component kactus2 attributes.\n     *\n     *    @param [in] stream              The text stream to write into.\n     *    @param [in] subHeaderNumber     The current subheader number.\n     */\n    void writeKactusAttributes(QTextStream& stream, int subHeaderNumber) override;\n\n    /*!\n     *  Write the table of contents header.\n     *\n     *    @param [in] stream  The text stream to write into.\n     */\n    void writeTableOfContentsHeader(QTextStream& stream) override;\n\n    /*!\n     *  Write the table of contents of the current component.\n     *\n     *    @param [in] stream  The text stream to write into.\n     */\n    void writeTableOfContents(QTextStream& stream) override;\n\n    /*!\n     *  Write the parameters of the component\n     *\n     *    @param [in] stream              The text stream to write into.\n     *    @param [in] subHeaderNumber     The current subheader number.\n     */\n    void writeParameters(QTextStream& stream, int subHeaderNumber) override;\n\n    /*!\n     *  Write the memory maps of the component\n     *\n     *    @param [in] stream              The text stream to write into.\n     *    @param [in] subHeaderNumber     The current subheader number.\n     */\n    void writeMemoryMaps(QTextStream& stream, int subHeaderNumber) override;\n\n    /*!\n     *  Write the given address blocks\n     *\n     *    @param [in] stream              The text stream to write into.\n     *    @param [in] addressBlocks       The address blocks to be written.\n     *    @param [in] subHeaderNumber     The current subheader number.\n     *    @param [in] memoryMapNumber     The current memory map number.\n     */\n    void writeAddressBlocks(QTextStream& stream, QList<QSharedPointer <AddressBlock> > addressBlocks,\n        int subHeaderNumber,int memoryMapNumber) override;\n\n    /*!\n     *  Write the given register files\n     *\n     *    @param [in] stream               The text stream to write into.\n     *    @param [in] registerFiles        The registers to be written.\n     *    @param [in] subHeaderNumbers     The current subheader number.\n     *    @param [out] registerDataNumber  The current address block number.\n     */\n    void writeRegisterFiles(QTextStream& stream,\n        QList<QSharedPointer<RegisterFile> > registerFiles,\n        QList<int> subHeaderNumbers, int& registerDataNumber) override;\n\n    /*!\n     *  Write the given registers\n     *\n     *    @param [in] stream              The text stream to write into.\n     *    @param [in] registers           The registers to be written.\n     *    @param [in] subHeaderNumber     The current subheader number.\n     *    @param [in] memoryMapNumber     The current memory map number.\n     *    @param [in] addressBlockNumber  The current address block number.\n     */\n    void writeRegisters(QTextStream& stream, QList<QSharedPointer <Register> > registers,\n        int subHeaderNumber, int memoryMapNumber, int addressBlockNumber, int& registerDataNumber) override;\n\n    /*!\n     *  Write the given register fields\n     *\n     *    @param [in] stream                     The text stream to write into.\n     *    @param [in] register                   The register whose fields are to be written.\n     *    @param [in] registerSubHeaderNumbers   The parent register's subheader numbering.\n     */\n    void writeFields(QTextStream& stream, QSharedPointer <Register> currentRegister,\n        QList<int> registerSubHeaderNumbers) override;\n\n    /*!\n     *  Write the ports of the component\n     *\n     *    @param [in] stream              The text stream to write into.\n     *    @param [in] subHeaderNumber     The current subheader number.\n     */\n    void writePorts(QTextStream& stream, int subHeaderNumber) override;\n\n    /*!\n     *  Write the bus interfaces of the component\n     *\n     *    @param [in] stream              The text stream to write into.\n     *    @param [in] subHeaderNumber     The current subheader number.\n     */\n    void writeInterfaces(QTextStream& stream, int& subHeaderNumber) override;\n\n    /*!\n     *  Write the file sets of the component\n     *\n     *    @param [in] stream              The text stream to write into.\n     *    @param [in] subHeaderNumber     The current subheader number.\n     */\n    void writeFileSets(QTextStream& stream, int& subHeaderNumber) override;\n\n    /*!\n     *  Set the number of the component in the hierarchy\n     *\n     *    @param [in] componentNumber     The new component number.\n     */\n    void setComponentNumber(int componentNumber) override;\n\n    /*!\n     *  Write a referenced component subheader\n     *\n     *    @param [in] stream              The text stream to write into.\n     *    @param [in] subHeaderNumber     The current subheader number.\n     *    @param [in] headerText          The displayed header text.\n     *    @param [in] headerId            The id for referencing within the document.\n     */\n    void writeSubHeader(QTextStream& stream, int subHeaderNumber,\n        QString const& title, QString const& headerId) const override;\n\n    /*!\n     *  Write a non-referenced component subheader with specified header level\n     *\n     *    @param [in] stream              The text stream to write into.\n     *    @param [in] subHeaderNumbers    The subheader numbers.\n     *    @param [in] title               The displayed header text.\n     *    @param [in] headerId            The id for referencing within the document.\n     */\n    void writeSubHeader(QTextStream& stream, QList<int> const& subHeaderNumbers,\n        QString const& title, int level) const override;\n\n    /*!\n     *  Write a description text\n     *\n     *    @param [in] stream              The text stream to write into.\n     *    @param [in] description         The description to write.\n     */\n    void writeDescription(QTextStream& stream, QString const& description) override;\n\n    /*!\n     *  Write a paragraph in which specific information is listed.\n     *\n     *    @param [in] stream              The text stream to write into.\n     *    @param [in] names               The info item names.\n     *    @param [in] values              The info item values.\n     */\n    void writeInfoParagraph(QTextStream& stream, QStringList const& names, QStringList const& values) override;\n\n    /*!\n     *  Write an error text to the document.\n     *\n     *    @param [in] stream              The text stream to write into..\n     *    @param [in] message             The description to write.\n     */\n    void writeErrorMessage(QTextStream& stream, QString const& message) override;\n\n    /*!\n     *  Write the document contained within the selected VLNV.\n     *\n     *    @param [in] stream                  Text stream to write the document.\n     *    @param [in] documentType            Type of the document.\n     *    @param [in] vlnvReference           VLNV of the selected document.\n     */\n    void writeDocumentReference(QTextStream& stream, QString const& documentType,\n        QSharedPointer<ConfigurableVLNVReference> vlnvReference) override;\n\n    /*!\n     *  Write the design diagram.\n     *\n     *    @param [in] stream                  Text stream to write the diagram to.\n     *    @param [in] title                   Diagram title.\n     *    @param [in] link                    Diagram picture link or path.\n     *    @param [in] altText                 Diagram alt text.\n     */\n    void writeDiagram(QTextStream& stream, QString const& title, QString const& link, QString const& altText)\n        override;\n\n    /*!\n     *  Write the component instances contained within the selected design.\n     *\n     *    @param [in] stream          Text stream to write the component instances.\n     *    @param [in] design          The selected design.\n     *    @param [in] configuration   The selected design configuration.\n     */\n    void writeDesignInstances(QTextStream& stream, QSharedPointer<Design> design,\n        QSharedPointer<DesignConfiguration> configuration) override;\n\n    /*!\n     *  Empty function for markdown writing.\n     *\n     *    @param [in] stream  The text stream to write the documentation into.\n     */\n    void writeEndOfDocument(QTextStream& stream) override;\n\nprivate:\n\n    /*!\n     *  Writes a table of registers.\n     *\n     *    @param [in] stream              The text stream to write into.\n     *    @param [in] registers           The registers to be written.\n     */\n    void writeRegisterTable(QTextStream& stream, QList<QSharedPointer<Register> >registers) const;\n\n    /*!\n     *  Writes a table of register fields.\n     *\n     *    @param [in] stream       The text stream to write into.\n     *    @param [in] reg          The register whose fields are written.\n     */\n    void writeFieldTable(QTextStream& stream, QSharedPointer<Register> reg) const;\n\n    /*!\n     *  Writes the enumerations of a field.\n     *\n     *    @param [in] stream              The text stream to write into.\n     *    @param [in] field               The field which enumerations are written.\n     */\n    void writeFieldEnumerations(QTextStream& stream, QSharedPointer<Field> field) override;\n\n    /*!\n     *  Writes a table row with specified cells to a MD table.\n     *\n     *    @param [in] stream          Text stream to write to.\n     *    @param [in] cells           Table row cells.\n     */\n    void writeTableRow(QTextStream& stream, QStringList const& cells) const;\n\n    /*!\n     *  Writes a table separator to a MD table.\n     *\n     *    @param [in] stream          Text stream to write to.\n     *    @param [in] columns         Number of columns.\n     */\n    void writeTableSeparator(QTextStream& stream, int columns) const;\n\n    /*!\n     *  Writes the table header cells and the separator.\n     *\n     *    @param [in] stream          Text stream to write to.\n     *    @param [in] headers         The table headers.\n     */\n    void writeTableHeader(QTextStream& stream, QStringList const& headers) const;\n\n    /*!\n     *  Writes a port table for specified ports.\n     *\n     *    @param [in] stream          Text stream to write to.\n     *    @param [in] ports           The ports to be written.\n     */\n    void writePortTable(QTextStream& stream, QList<QSharedPointer<Port> > ports) const;\n\n    /*!\n     *  Writes group identifiers for a file set.\n     *\n     *    @param [in] stream          Text stream to write to.\n     *    @param [in] fileSet         File set to write identifiers for.\n     */\n    void writeFileSetGroupdIdentifiers(QTextStream& stream, QSharedPointer<FileSet> fileSet) const;\n\n    /*!\n     *  Writes the default file builders for a file set.\n     *\n     *    @param [in] stream          Text stream to write to.\n     *    @param [in] fileSet         File set to write file builders for.\n     */\n    void writeDefaultFileBuilders(QTextStream& stream, QSharedPointer<FileSet> fileSet) const;\n\n    /*!\n     *  Writes the files of a file set.\n     *\n     *    @param [in] stream          Text stream to write to.\n     *    @param [in] fileSet         File set whose files will be written.\n     *    @param [in] subHeaderNumber The current subheader number.\n     *    @param [in] fileSetNumber   The current file set number.\n     */\n    void writeFiles(QTextStream& stream, QSharedPointer<FileSet> fileSet,\n        int subHeaderNumber, int fileSetNumber);\n\n    /*!\n     *  Writes a specified file of a file set.\n     *\n     *    @param [in] stream          Text stream to write to.\n     *    @param [in] file            File to be written.\n     */\n    void writeSingleFile(QTextStream& stream, QSharedPointer<File> file) const;\n\n    /*!\n     *  Writes the implementation details of a component instantiation.\n     *\n     *    @param [in] stream          Text stream to write to.\n     *    @param [in] instantiation   The component instantiation.\n     */\n    void writeImplementationDetails(QTextStream& stream,\n        QSharedPointer<ComponentInstantiation> instantiation) override;\n    \n    /*!\n     *  Writes the file set references contained within a component instantiation.\n     *\n     *    @param [in] stream          Text stream to write to.\n     *    @param [in] instantiation   The component instantiation.\n     */\n    void writeFileSetReferences(QTextStream& stream,\n        QSharedPointer<ComponentInstantiation> instantiation) override;\n\n    /*!\n     *  Writes the file build commands of a component instantiation.\n     *\n     *    @param [in] stream          Text stream to write to.\n     *    @param [in] instantiation   The component instantiation.\n     *    @param [in] formatter       The expression formatter for the component instantiation.\n     */\n    void writeFileBuildCommands(QTextStream& stream, QSharedPointer<ComponentInstantiation> instantiation,\n        QSharedPointer<ExpressionFormatter> formatter) override;\n\n    /*!\n     *  Writes given parameters to a table.\n     *\n     *    @param [in] stream          Text stream to write to.\n     *    @param [in] tableHeading    The heading above the table\n     *    @param [in] parameters      The parameters to be written.\n     *    @param [in] formatter       The expression formatter for the parameters.\n     */\n    void writeParameterTable(QTextStream& stream, QString const& tableHeading,\n        QSharedPointer<QList<QSharedPointer<Parameter> > > parameters,\n        QSharedPointer<ExpressionFormatter> formatter) override;\n\n    /*!\n     *  Writes given module parameters to a table.\n     *\n     *    @param [in] stream              Text stream to write to.\n     *    @param [in] tableHeading        The heading above the table.\n     *    @param [in] moduleParameters    The module parameters to be written.\n     *    @param [in] formatter           The expression formatter for the parameters.\n     */\n    void writeModuleParameterTable(QTextStream& stream, QString const& tableHeading,\n        QSharedPointer<QList<QSharedPointer<Parameter> > > moduleParameters,\n        QSharedPointer<ExpressionFormatter> formatter) override;\n\n    /*!\n     *  Writes the configurable element values of a VLNV.\n     *\n     *    @param [in] stream                  Text stream to write the document.\n     *    @param [in] vlnvReference           Configurable VLNV containing the selected configurable element\n     *                                          values.\n     *    @param [in] instantiationFormatter  Expression formatter for the configurable element values.\n     */\n    void writeConfigurableElementValues(QTextStream& stream,\n        QSharedPointer<ConfigurableVLNVReference> vlnvReference,\n        QSharedPointer<ExpressionFormatter> instantiationFormatter) override;\n\n    /*!\n     *  Gets the configurable element values of a component instance as a line-broken string.\n     * \n     *    @param [in] stream          Text stream to write the document.\n     *    @param [in] instance        The component instance.        \n     *    @param [in] design          The design in which the component instance is.      \n     */\n    QString getComponentInstanceConfigurableElements(QSharedPointer<ComponentInstance> instance,\n        QSharedPointer<Design> design);\n\n    //-----------------------------------------------------------------------------\n    // Data.\n    //-----------------------------------------------------------------------------\n\n    //! The expression formatter, used to change parameter IDs into names.\n    ExpressionFormatter* expressionFormatter_;\n\n    //! The library handler\n    LibraryInterface* libraryHandler_;\n\n    //! Stringified VLNV of the component\n    QString vlnvString_;\n    \n    //! The current component\n    QSharedPointer<Component> component_;\n\n    //! Component number in the hierarchy\n    int componentNumber_;\n};\n\n#endif // MARKDOWNWRITER_H"
  },
  {
    "path": "kactusGenerators/DocumentGenerator/documentgenerator.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: documentgenerator.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Antti Kamppi\r\n// Date: 19.09.2011\r\n//\r\n// Description:\r\n// Generates a HTML document.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"documentgenerator.h\"\r\n\r\n#include <KactusAPI/include/utils.h>\r\n#include <KactusAPI/include/ListParameterFinder.h>\r\n#include <KactusAPI/include/MultipleParameterFinder.h>\r\n\r\n#include <common/widgets/componentPreviewBox/ComponentPreviewBox.h>\r\n\r\n#include <kactusGenerators/DocumentGenerator/MarkdownWriter.h>\r\n#include <kactusGenerators/DocumentGenerator/HtmlWriter.h>\r\n\r\n#include <editors/common/DesignWidget.h>\r\n#include <editors/common/DesignWidgetFactory.h>\r\n#include <editors/common/DesignDiagram.h>\r\n\r\n#include <IPXACTmodels/common/Document.h>\r\n#include <IPXACTmodels/common/DirectionTypes.h>\r\n#include <IPXACTmodels/common/Parameter.h>\r\n#include <IPXACTmodels/Component/Port.h>\r\n#include <IPXACTmodels/Component/BusInterface.h>\r\n#include <IPXACTmodels/Component/FileSet.h>\r\n#include <IPXACTmodels/common/FileBuilder.h>\r\n#include <IPXACTmodels/Component/File.h>\r\n#include <IPXACTmodels/Component/BuildCommand.h>\r\n#include <IPXACTmodels/Component/AddressBlock.h>\r\n#include <IPXACTmodels/Component/Register.h>\r\n#include <IPXACTmodels/Component/Field.h>\r\n#include <IPXACTmodels/Component/MemoryMap.h>\r\n\r\n#include <IPXACTmodels/kactusExtensions/KactusAttribute.h>\r\n#include <IPXACTmodels/Design/Design.h>\r\n#include <IPXACTmodels/DesignConfiguration/DesignConfiguration.h>\r\n\r\n#include <QString>\r\n#include <QDir>\r\n#include <QFile>\r\n#include <QDateTime>\r\n#include <QSettings>\r\n#include <QVariant>\r\n#include <QFileInfo>\r\n#include <QMap>\r\n#include <QMessageBox>\r\n#include <QPainter>\r\n#include <QPixmap>\r\n#include <QRectF>\r\n#include <QPointF>\r\n#include <QBrush>\r\n#include <QSharedPointer>\r\n#include <QApplication>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: documentgenerator::DocumentGenerator()\r\n//-----------------------------------------------------------------------------\r\nDocumentGenerator::DocumentGenerator(LibraryInterface* handler, const VLNV& vlnv,\r\n    DesignWidgetFactory* designWidgetFactory, ExpressionFormatterFactory* expressionFormatterFactory,\r\n    int componentNumber, QWidget* parent) :\r\n    libraryHandler_(handler),\r\n    component_(),\r\n    componentNumber_(componentNumber),\r\n    targetPath_(),\r\n    expressionFormatterFactory_(expressionFormatterFactory),\r\n    childInstances_(),\r\n    parentWidget_(parent),\r\n    expressionFormatter_(),\r\n    designWidgetFactory_(designWidgetFactory),\r\n    writer_(nullptr),\r\n    mdWriter_(nullptr),\r\n    htmlWriter_(nullptr),\r\n    componentFinder_(nullptr),\r\n    currentFormat_(DocumentFormat::MD),\r\n    imagesPath_()\r\n{\r\n    Q_ASSERT(handler);\r\n    Q_ASSERT(parent);\r\n\r\n    // parse the model for the component\r\n    component_ = libraryHandler_->getModel(vlnv).dynamicCast<Component>();\r\n\r\n    componentFinder_ = QSharedPointer<ComponentParameterFinder>(new ComponentParameterFinder(component_));\r\n    expressionFormatter_ = expressionFormatterFactory_->makeExpressionFormatter(component_);\r\n\r\n    if (!component_)\r\n    {\r\n       emit errorMessage(\"VLNV was not found in the library.\");\r\n       return;\r\n    }\r\n\r\n    htmlWriter_ = new HtmlWriter(component_, expressionFormatter_, expressionFormatterFactory_,\r\n        libraryHandler_, componentNumber_);\r\n\r\n    mdWriter_ = new MarkdownWriter(component_, expressionFormatter_, expressionFormatterFactory_,\r\n        libraryHandler_, componentNumber_);\r\n\r\n    writer_ = mdWriter_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: documentgenerator::~DocumentGenerator()\r\n//-----------------------------------------------------------------------------\r\nDocumentGenerator::~DocumentGenerator()\r\n{\r\n    delete htmlWriter_;\r\n    htmlWriter_ = nullptr;\r\n\r\n    delete mdWriter_;\r\n    mdWriter_ = nullptr;\r\n\r\n    writer_ = nullptr;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: documentgenerator::parseChildItems()\r\n//-----------------------------------------------------------------------------\r\nvoid DocumentGenerator::parseChildItems(QList<VLNV>& objects, int& currentComponentNumber)\r\n{\r\n    // ask the component for it's hierarchical references\r\n    QList<VLNV> refs = component_->getHierRefs();\r\n    for (auto const& ref : refs)\r\n    {\r\n        QSharedPointer<Design> design = libraryHandler_->getDesign(ref);\r\n        if (!design)\r\n        {\r\n            continue;\r\n        }\r\n\r\n        for (auto const& instance : *design->getComponentInstances())\r\n        {\r\n            if (!objects.contains(*instance->getComponentRef()) &&\r\n                libraryHandler_->getDocumentType(*instance->getComponentRef()) == VLNV::COMPONENT)\r\n            {\r\n                // create a new instance of document generator and add it to child list\r\n                objects.append(*instance->getComponentRef());\r\n                \r\n                currentComponentNumber++;\r\n\r\n                QSharedPointer<DocumentGenerator> docGenerator(new DocumentGenerator(libraryHandler_,\r\n                    *instance->getComponentRef(), designWidgetFactory_, expressionFormatterFactory_,\r\n                    currentComponentNumber, parentWidget_));\r\n\r\n                docGenerator->setFormat(currentFormat_);\r\n                docGenerator->parseChildItems(objects, currentComponentNumber);\r\n\r\n                connect(docGenerator.data(), SIGNAL(errorMessage(const QString&)),\r\n                    this, SIGNAL(errorMessage(const QString&)), Qt::UniqueConnection);\r\n                connect(docGenerator.data(), SIGNAL(noticeMessage(const QString&)),\r\n                    this, SIGNAL(noticeMessage(const QString&)), Qt::UniqueConnection);\r\n    \r\n                childInstances_.append(docGenerator);\r\n            }\r\n        }\r\n    }\r\n}\r\n\r\nvoid DocumentGenerator::setFormat(DocumentFormat format)\r\n{\r\n    if (format == DocumentFormat::HTML)\r\n    {\r\n        writer_ = htmlWriter_;\r\n    }\r\n    else if (format == DocumentFormat::MD)\r\n    {\r\n        writer_ = mdWriter_;\r\n    }\r\n\r\n    currentFormat_ = format;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: documentgenerator::writeDocumentation()\r\n//-----------------------------------------------------------------------------\r\nvoid DocumentGenerator::writeDocumentation(QTextStream& stream, QString targetPath)\r\n{\r\n    QApplication::setOverrideCursor(Qt::WaitCursor);\r\n    QApplication::processEvents();\r\n\r\n    if (!component_)\r\n    {\r\n        emit errorMessage(\"VLNV was not found in the library.\");\r\n        return;\r\n    }\r\n\r\n    Q_ASSERT(libraryHandler_->contains(component_->getVlnv()));\r\n    Q_ASSERT(libraryHandler_->getDocumentType(component_->getVlnv()) == VLNV::COMPONENT);\r\n\r\n    // this function can only be called for the top document generator\r\n    Q_ASSERT(parentWidget_);\r\n\r\n    // list of objects that have already been processed to avoid duplicates\r\n    QList<VLNV> objects;\r\n    objects.append(component_->getVlnv());\r\n\r\n    // Component number\r\n    int currentComponentNumber = 1;\r\n\r\n    parseChildItems(objects, currentComponentNumber);\r\n\r\n    targetPath_ = targetPath;\r\n\r\n    QFileInfo docInfo(targetPath_);\r\n\r\n    imagesPath_ = docInfo.absolutePath() + \"/images\";\r\n    \r\n    if (QDir imageDir(imagesPath_); !imageDir.exists())\r\n    {\r\n        imageDir.mkdir(imagesPath_);\r\n    }\r\n\r\n    writeHeader(stream);\r\n\r\n    writer_->writeTableOfContentsHeader(stream);\r\n\r\n    writeTableOfContents(stream);\r\n\r\n    QStringList pictureList;\r\n\r\n    // write the actual documentation for the top component\r\n    writeDocumentation(stream, targetPath_, pictureList);\r\n\r\n    writer_->writeEndOfDocument(stream);\r\n\r\n    QApplication::restoreOverrideCursor();\r\n\r\n    // ask user if he wants to save the generated documentation into object metadata\r\n    QMessageBox::StandardButton button = QMessageBox::question(parentWidget_, \r\n        tr(\"Save generated documentation to metadata?\"),\r\n        tr(\"Would you like to save the generated documentation to IP-Xact\"\r\n        \" metadata?\"), QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes);\r\n\r\n    // if the generated file is saved\r\n    if (button == QMessageBox::Yes)\r\n    {\r\n        QString xmlPath = libraryHandler_->getPath(component_->getVlnv());\r\n\r\n        // get the relative path to add to file set\r\n        QString relativePath = General::getRelativePath(xmlPath, targetPath_);\r\n\r\n        QString fileSetName(\"Documentation\");\r\n        QSharedPointer<FileSet> documentationFileSet = component_->getFileSet(fileSetName);\r\n\r\n        // if the documentation file set was not found. Create one\r\n        if (!documentationFileSet)\r\n        {\r\n            documentationFileSet = QSharedPointer<FileSet>(new FileSet(fileSetName, QString(\"documentation\")));\r\n            component_->getFileSets()->append(documentationFileSet);\r\n        }\r\n\r\n        QSettings settings;\r\n\r\n        QString docFileType = \"\";\r\n        if (currentFormat_ == DocumentFormat::HTML)\r\n        {\r\n            docFileType = \"html\";\r\n        }\r\n        else if (currentFormat_ == DocumentFormat::MD)\r\n        {\r\n            docFileType = \"markdown\";\r\n        }\r\n\r\n        // create a new file and add it to file set\r\n        QSharedPointer<File> docFile = documentationFileSet->addFile(relativePath, settings);\r\n        Q_ASSERT(docFile);\r\n        docFile->setIncludeFile(false);\r\n        docFile->setDescription(tr(\"File that contains the documentation \"\r\n            \"for this component and subcomponents\"));\r\n\r\n        if (!docFile->matchesFileType(docFileType))\r\n        {\r\n            docFile->getFileTypes()->append(FileType(docFileType));\r\n        }\r\n\r\n        // add all created pictures to the file set\r\n        for (auto const& pictureName : pictureList)\r\n        {\r\n            QString relativePicPath = General::getRelativePath(xmlPath, pictureName);\r\n            QString picFileType = \"pngImage\";\r\n\r\n            QSharedPointer<File> picFile = documentationFileSet->addFile(relativePicPath, settings);\r\n            Q_ASSERT(picFile);\r\n            picFile->setIncludeFile(false);\r\n            picFile->setDescription(tr(\"Preview picture needed by the documentation.\"));\r\n\r\n            if (!picFile->matchesFileType(picFileType))\r\n            {\r\n                picFile->getFileTypes()->append(FileType(picFileType));\r\n            }\r\n        }\r\n\r\n        libraryHandler_->writeModelToFile(component_);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: documentgenerator::writeHeader()\r\n//-----------------------------------------------------------------------------\r\nvoid DocumentGenerator::writeHeader(QTextStream& stream)\r\n{\r\n    writer_->writeHeader(stream);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: documentgenerator::writeTableOfContents()\r\n//-----------------------------------------------------------------------------\r\nvoid DocumentGenerator::writeTableOfContents(QTextStream& stream)\r\n{\r\n    writer_->setComponentNumber(componentNumber_);\r\n    writer_->writeTableOfContents(stream);\r\n\r\n    // tell each child to write it's table of contents\r\n    for (auto const &generator : childInstances_)\r\n    {\r\n        generator->writeTableOfContents(stream);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: documentgenerator::writeDocumentation()\r\n//-----------------------------------------------------------------------------\r\nvoid DocumentGenerator::writeDocumentation(QTextStream& stream, const QString& targetPath,\r\n    QStringList& filesToInclude)\r\n{\r\n    writer_->setTargetPath(targetPath);\r\n    writer_->setImagesPath(imagesPath_);\r\n    targetPath_ = targetPath;\r\n\r\n    // write the component header, picture and info\r\n    writer_->writeComponentHeader(stream);\r\n\r\n    createComponentPicture(filesToInclude);\r\n\r\n    writer_->writeComponentInfo(stream);\r\n\r\n    int subHeaderNumber = 1;\r\n\r\n    writeKactusAttributes(stream, subHeaderNumber);\r\n    writeParameters(stream, subHeaderNumber);\r\n    writeMemoryMaps(stream, subHeaderNumber);\r\n    writePorts(stream, subHeaderNumber);\r\n    writeInterfaces(stream, subHeaderNumber);\r\n    writeFileSets(stream, subHeaderNumber);\r\n    writeViews(stream, subHeaderNumber, filesToInclude);\r\n\r\n    // tell each child to write it's documentation\r\n    for (auto const& generator : childInstances_)\r\n    {\r\n        generator->setImagesPath(imagesPath_);\r\n        generator->writeDocumentation(stream, targetPath, filesToInclude);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: documentgenerator::writeKactusAttributes()\r\n//-----------------------------------------------------------------------------\r\nvoid DocumentGenerator::writeKactusAttributes(QTextStream& stream, int& subHeaderNumber)\r\n{\r\n    writer_->writeKactusAttributes(stream, subHeaderNumber);\r\n    ++subHeaderNumber;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: documentgenerator::writeParameters()\r\n//-----------------------------------------------------------------------------\r\nvoid DocumentGenerator::writeParameters(QTextStream& stream, int& subHeaderNumber)\r\n{\r\n    if (component_->hasParameters())\r\n    {\r\n        writer_->writeParameters(stream, subHeaderNumber);\r\n        ++subHeaderNumber;\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: documentgenerator::writeMemoryMaps()\r\n//-----------------------------------------------------------------------------\r\nvoid DocumentGenerator::writeMemoryMaps(QTextStream& stream, int& subHeaderNumber)\r\n{\r\n    if (!component_->getMemoryMaps()->isEmpty())\r\n    {\r\n        writer_->writeMemoryMaps(stream, subHeaderNumber);\r\n        ++subHeaderNumber;\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: documentgenerator::writeAddressBlock()\r\n//-----------------------------------------------------------------------------\r\nvoid DocumentGenerator::writeAddressBlocks(QList<QSharedPointer<AddressBlock> > addressBlocks,\r\n    QTextStream& stream, int subHeaderNumber, int memoryMapNumber)\r\n{\r\n    writer_->writeAddressBlocks(stream, addressBlocks, subHeaderNumber, memoryMapNumber);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: documentgenerator::writeRegisters()\r\n//-----------------------------------------------------------------------------\r\nvoid DocumentGenerator::writeRegisters(QList<QSharedPointer<Register> > registers, QTextStream& stream,\r\n    int subHeaderNumber, int memoryMapNumber, int addressBlockNumber, int registerDataNumber)\r\n{\r\n    writer_->writeRegisters(stream, registers, subHeaderNumber, memoryMapNumber,\r\n        addressBlockNumber, registerDataNumber);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: documentgenerator::writeFields()\r\n//-----------------------------------------------------------------------------\r\nvoid DocumentGenerator::writeFields(QSharedPointer<Register> currentRegister,\r\n    QTextStream& stream, QList<int> subHeaderNumbers)\r\n{\r\n    writer_->writeFields(stream, currentRegister, subHeaderNumbers);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: documentgenerator::writePorts()\r\n//-----------------------------------------------------------------------------\r\nvoid DocumentGenerator::writePorts(QTextStream& stream, int& subHeaderNumber)\r\n{\r\n    if (component_->hasPorts())\r\n    {\r\n        writer_->writePorts(stream, subHeaderNumber);\r\n        ++subHeaderNumber;\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: documentgenerator::writeInterfaces()\r\n//-----------------------------------------------------------------------------\r\nvoid DocumentGenerator::writeInterfaces(QTextStream& stream, int& subHeaderNumber)\r\n{\r\n    if (component_->hasInterfaces())\r\n    {\r\n        writer_->writeInterfaces(stream, subHeaderNumber);\r\n        ++subHeaderNumber;\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: documentgenerator::writeFileSets()\r\n//-----------------------------------------------------------------------------\r\nvoid DocumentGenerator::writeFileSets(QTextStream& stream, int& subHeaderNumber)\r\n{\r\n    if (component_->hasFileSets())\r\n    {\r\n        writer_->writeFileSets(stream, subHeaderNumber);\r\n        ++subHeaderNumber;\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: documentgenerator::writeViews()\r\n//-----------------------------------------------------------------------------\r\nvoid DocumentGenerator::writeViews(QTextStream& stream, int& subHeaderNumber, QStringList& pictureList)\r\n{\r\n    if (!component_->hasViews())\r\n    {\r\n        return;\r\n    }\r\n\r\n    writer_->writeSubHeader(stream, subHeaderNumber, \"Views\", \"views\");\r\n\r\n    int viewNumber = 1;\r\n\r\n    for (auto const& view : *component_->getViews())\r\n    {\r\n        writeSingleView(stream, view, subHeaderNumber, viewNumber, pictureList);\r\n        ++viewNumber;\r\n    }\r\n\r\n    ++subHeaderNumber;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: documentgenerator::writeEndOfDocument()\r\n//-----------------------------------------------------------------------------\r\nvoid DocumentGenerator::writeEndOfDocument(QTextStream& stream)\r\n{\r\n    writer_->writeEndOfDocument(stream);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: documentgenerator::setImagesPath()\r\n//-----------------------------------------------------------------------------\r\nvoid DocumentGenerator::setImagesPath(QString const& path)\r\n{\r\n    imagesPath_ = path;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: documentgenerator::writeSingleView()\r\n//-----------------------------------------------------------------------------\r\nvoid DocumentGenerator::writeSingleView(QTextStream& stream, QSharedPointer<View> view,\r\n    int const& subHeaderNumber, int const& viewNumber, QStringList& pictureList)\r\n{\r\n    QList subHeaderNumbers({ componentNumber_, subHeaderNumber, viewNumber });\r\n    writer_->writeSubHeader(stream, subHeaderNumbers, \"View: \" + view->name(), 3);\r\n\r\n    if (auto const& description = view->description(); !description.isEmpty())\r\n    {\r\n        writer_->writeDescription(stream, description);\r\n    }\r\n    \r\n    int instantiationNumber = 1;\r\n\r\n    \r\n    if (QString viewComponentInstantiationRef = view->getComponentInstantiationRef();\r\n        !viewComponentInstantiationRef.isEmpty())\r\n    {\r\n        writeReferencedComponentInstantiation(stream,\r\n            viewComponentInstantiationRef, subHeaderNumber, viewNumber, instantiationNumber);\r\n        instantiationNumber++;\r\n    }\r\n\r\n    if (QString viewDesignConfigurationInstantiationRef = view->getDesignConfigurationInstantiationRef();\r\n        !viewDesignConfigurationInstantiationRef.isEmpty())\r\n    {\r\n        writeReferencedDesignConfigurationInstantiation(stream,\r\n           viewDesignConfigurationInstantiationRef, subHeaderNumber, viewNumber, instantiationNumber);\r\n        instantiationNumber++;\r\n    }\r\n\r\n    if (QString viewDesignInstantiationRef = view->getDesignInstantiationRef();\r\n        !viewDesignInstantiationRef.isEmpty())\r\n    {\r\n        writeReferencedDesignInstantiation(stream, viewDesignInstantiationRef,\r\n            subHeaderNumber, viewNumber, instantiationNumber);\r\n        instantiationNumber++;\r\n    }\r\n\r\n    if (view->isHierarchical())\r\n    {\r\n        writeDesign(stream, view, pictureList);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: documentgenerator::writeReferencedComponentInstantiation()\r\n//-----------------------------------------------------------------------------\r\nvoid DocumentGenerator::writeReferencedComponentInstantiation(QTextStream& stream,\r\n    QString const& instantiationReference, int const& subHeaderNumber,\r\n    int const& viewNumber, int const& instantiationNumber)\r\n{\r\n    writer_->writeSubHeader(stream, QList({ componentNumber_, subHeaderNumber, viewNumber, instantiationNumber }),\r\n        \"Component instantiation: \" + instantiationReference, 4);\r\n\r\n    QSharedPointer<ComponentInstantiation> instantiation = getComponentInstantiation(instantiationReference);\r\n    if (!instantiation)\r\n    {\r\n        QString errorMsg(tr(\"Referenced component instantiation %1 was not found.\").\r\n            arg(instantiationReference));\r\n        writer_->writeErrorMessage(stream, errorMsg);\r\n        emit errorMessage(errorMsg);\r\n        return;\r\n    }\r\n\r\n    if (auto const& description = instantiation->description(); !description.isEmpty())\r\n    {\r\n        writer_->writeDescription(stream, description);\r\n    }\r\n\r\n    QSharedPointer<ListParameterFinder> parameterFinder(new ListParameterFinder());\r\n    ParameterList parameters = instantiation->getParameters();\r\n    parameterFinder->setParameterList(parameters);\r\n\r\n    QSharedPointer<ListParameterFinder> moduleParameterFinder(new ListParameterFinder());\r\n    auto moduleParameters = getModuleParametersAsParameters(instantiation->getModuleParameters());\r\n    moduleParameterFinder->setParameterList(moduleParameters);\r\n\r\n    QSharedPointer<MultipleParameterFinder> instantiationParameterFinder(new MultipleParameterFinder());\r\n    instantiationParameterFinder->addFinder(componentFinder_);\r\n    instantiationParameterFinder->addFinder(parameterFinder);\r\n    instantiationParameterFinder->addFinder(moduleParameterFinder);\r\n\r\n    QSharedPointer<ExpressionFormatter> instantiationFormatter(\r\n        new ExpressionFormatter(instantiationParameterFinder));\r\n\r\n    QString moduleParameterToolTip = QString(\"Module parameters of component instantiation \") +\r\n        instantiation->name();\r\n    QString parameterToolTip = QString(\"Parameters of component instantiation \") + instantiation->name();\r\n\r\n    writer_->writeReferencedComponentInstantiation(stream, instantiation, instantiationFormatter,\r\n       moduleParameters, parameters);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: documentgenerator::writeReferencedDesignConfigurationInstantiation()\r\n//-----------------------------------------------------------------------------\r\nvoid DocumentGenerator::writeReferencedDesignConfigurationInstantiation(QTextStream& stream,\r\n    QString const& configurationReference, int const& subHeaderNumber, int const& viewNumber,\r\n    int const& instantiationNumber)\r\n{\r\n    writer_->writeSubHeader(stream, QList({ componentNumber_, subHeaderNumber, viewNumber, instantiationNumber }),\r\n        \"Design configuration instantiation: \" + configurationReference, 4);\r\n\r\n    QSharedPointer<DesignConfigurationInstantiation> instantiation =\r\n        getDesignConfigurationInstantiation(configurationReference);\r\n\r\n    if (!instantiation)\r\n    {\r\n        QString errorMessage(tr(\"Referenced design configuration instantiation %1 was not found.\").\r\n            arg(configurationReference));\r\n        writer_->writeErrorMessage(stream, errorMessage);\r\n        return;\r\n    }\r\n    \r\n    if (auto const& description = instantiation->description(); !description.isEmpty())\r\n    {\r\n        writer_->writeDescription(stream, description);\r\n    }\r\n\r\n    QSharedPointer<ListParameterFinder> configurationInstantiationParameterFinder(new ListParameterFinder());\r\n    configurationInstantiationParameterFinder->setParameterList(instantiation->getParameters());\r\n\r\n    QSharedPointer<ListParameterFinder> configurationFinder(new ListParameterFinder());\r\n\r\n    QSharedPointer<MultipleParameterFinder> instantiationParameterFinder(new MultipleParameterFinder());\r\n    instantiationParameterFinder->addFinder(componentFinder_);\r\n    instantiationParameterFinder->addFinder(configurationInstantiationParameterFinder);\r\n    instantiationParameterFinder->addFinder(configurationFinder);\r\n\r\n    QSharedPointer<ExpressionFormatter> instantiationFormatter(new ExpressionFormatter(instantiationParameterFinder));\r\n\r\n    writer_->writeDocumentReference(stream, QString(\"Design configuration\"),\r\n        instantiation->getDesignConfigurationReference());\r\n\r\n    writer_->writeReferencedDesignConfigurationInstantiation(stream, configurationFinder,\r\n        instantiation, instantiationFormatter, libraryHandler_);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: documentgenerator::writeReferencedDesignInstantiation()\r\n//-----------------------------------------------------------------------------\r\nvoid DocumentGenerator::writeReferencedDesignInstantiation(QTextStream& stream,\r\n    QString const& designReference,int const& subHeaderNumber,\r\n    int const& viewNumber, int const& instantiationNumber)\r\n{\r\n    writer_->writeSubHeader(stream, QList({ componentNumber_, subHeaderNumber, viewNumber, instantiationNumber }),\r\n        \"Design instantiation: \" + designReference, 4);\r\n    \r\n    QSharedPointer<DesignInstantiation> instantiation = getDesignInstantiation(designReference);\r\n\r\n    if (!instantiation)\r\n    {\r\n        QString errorMessage(tr(\"Referenced design configuration instantiation %1 was not found.\").\r\n            arg(designReference));\r\n        writer_->writeErrorMessage(stream, errorMessage);\r\n        return;\r\n    }\r\n    \r\n    if (auto const& description = instantiation->description(); !description.isEmpty())\r\n    {\r\n        writer_->writeDescription(stream, description);\r\n    }\r\n\r\n    QSharedPointer<ConfigurableVLNVReference> designVLNV = instantiation->getDesignReference();\r\n\r\n    writer_->writeDocumentReference(stream, QString(\"Design\"), designVLNV);\r\n\r\n    if (!designVLNV)\r\n    {\r\n        return;\r\n    }\r\n\r\n    QSharedPointer<ListParameterFinder> designFinder(new ListParameterFinder());\r\n    QSharedPointer<MultipleParameterFinder> instantiationParameterFinder(new MultipleParameterFinder());\r\n    instantiationParameterFinder->addFinder(componentFinder_);\r\n    instantiationParameterFinder->addFinder(designFinder);\r\n\r\n    QSharedPointer<ExpressionFormatter> instantiationFormatter(new ExpressionFormatter(instantiationParameterFinder));\r\n\r\n    QSharedPointer<Document> designDocument =\r\n        libraryHandler_->getModel(*instantiation->getDesignReference());\r\n\r\n    if (!designDocument)\r\n    {\r\n        return;\r\n    }\r\n\r\n    QSharedPointer<Design> instantiatedDesign = designDocument.dynamicCast<Design>();\r\n\r\n    if (instantiatedDesign)\r\n    {\r\n        designFinder->setParameterList(instantiatedDesign->getParameters());\r\n\r\n        QString header = QString(\"Parameters of the referenced design %1:\").arg(designVLNV->toString());\r\n        QSharedPointer<ExpressionFormatter> designFormatter(new ExpressionFormatter(designFinder));\r\n\r\n        writer_->writeReferencedDesignInstantiation(stream, designVLNV, instantiatedDesign,\r\n            designFormatter, instantiationFormatter);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: documentgenerator::writeDesign()\r\n//-----------------------------------------------------------------------------\r\nvoid DocumentGenerator::writeDesign(QTextStream& stream, QSharedPointer<View> view, QStringList& pictureList)\r\n{\r\n    QSharedPointer<DesignConfiguration> configuration = getDesignConfiguration(view);\r\n    QSharedPointer<Design> design = getDesign(view, configuration);\r\n\r\n    if (view->isHierarchical() && !design)\r\n    {\r\n        QString errorMessage = QString(\"Design reference %1 does not contain a valid design.\").\r\n            arg(view->getDesignInstantiationRef());\r\n        writer_->writeErrorMessage(stream, errorMessage);\r\n        return;\r\n    }\r\n\r\n    QString designPicPath = imagesPath_\r\n        + (imagesPath_.isEmpty() ? QStringLiteral(\"\") : QStringLiteral(\"/\"))\r\n        + component_->getVlnv().toString(\".\")\r\n        + QStringLiteral(\".\")\r\n        + view->name()\r\n        + QStringLiteral(\".png\");\r\n\r\n    createDesignPicture(pictureList, view->name(), designPicPath);\r\n\r\n    QString designDiagramTitle = QString(\"Diagram of design %1:\").arg(design->getVlnv().toString());\r\n    QString designDiagramAltText = QString(\"View: %1 preview picture\").arg(view->name());\r\n    QString relativePicPath = imagesPath_.split(\"/\").back()\r\n        + \"/\"\r\n        + component_->getVlnv().toString(\".\")\r\n        + QStringLiteral(\".\")\r\n        + view->name()\r\n        + QStringLiteral(\".png\");\r\n\r\n    writer_->writeDiagram(stream, designDiagramTitle, relativePicPath, designDiagramAltText);\r\n    writer_->writeDesignInstances(stream, design, configuration);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: documentgenerator::createDesignPicture()\r\n//-----------------------------------------------------------------------------\r\nvoid DocumentGenerator::createDesignPicture(QStringList& pictureList,\r\n    QString const& viewName, QString const& designPicPath)\r\n{\r\n    DesignWidget* designWidget(designWidgetFactory_->makeHWDesignWidget());\r\n\r\n    designWidget->hide();\r\n    designWidget->setDesign(component_->getVlnv(), viewName);\r\n\r\n    QFile designPicFile(designPicPath);\r\n\r\n    if (designPicFile.exists())\r\n    {\r\n        designPicFile.remove();\r\n    }\r\n\r\n    // get the rect that bounds all items on box\r\n    QRectF boundingRect = designWidget->getDiagram()->itemsBoundingRect();\r\n    boundingRect.setHeight(boundingRect.height() + 2);\r\n    boundingRect.setWidth(boundingRect.width() + 2);\r\n\r\n    // set the size of the picture\r\n    QPixmap designPic(boundingRect.size().toSize());\r\n\r\n    // create the picture for the component\r\n    QPainter painter(&designPic);\r\n    painter.fillRect(designPic.rect(), QBrush(Qt::white));\r\n    designWidget->getDiagram()->render(&painter, designPic.rect(), boundingRect.toRect());\r\n    if (!designPic.save(&designPicFile, \"PNG\"))\r\n    {\r\n        emit errorMessage(tr(\"Could not save picture %1\").arg(designPicPath));\r\n    }\r\n    else\r\n    {\r\n        pictureList.append(designPicPath);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: documentgenerator::getDesignInstantiation()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<DesignInstantiation> DocumentGenerator::getDesignInstantiation(\r\n    QString const& designReference) const\r\n{\r\n    for(auto const& instantiation : *component_->getDesignInstantiations())\r\n    {\r\n        if (instantiation->name() == designReference)\r\n        {\r\n            return instantiation;\r\n        }\r\n    }\r\n\r\n    return QSharedPointer<DesignInstantiation>();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: documentgenerator::getComponentInstantiation()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<ComponentInstantiation> DocumentGenerator::getComponentInstantiation(\r\n    QString const& instantiationReference) const\r\n{\r\n    for (auto const& instantiation : *component_->getComponentInstantiations())\r\n    {\r\n        if (instantiation->name() == instantiationReference)\r\n        {\r\n            return instantiation;\r\n        }\r\n    }\r\n\r\n    return QSharedPointer<ComponentInstantiation>(nullptr);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: documentgenerator::getModuleParametersAsParameters()\r\n//-----------------------------------------------------------------------------\r\nParameterList DocumentGenerator::getModuleParametersAsParameters(\r\n    QSharedPointer<QList<QSharedPointer<ModuleParameter> > > moduleParameters) const\r\n{\r\n    ParameterList newModuleParameters(\r\n        new QList<QSharedPointer<Parameter> >());\r\n\r\n    for (QSharedPointer<Parameter> parameter : *moduleParameters)\r\n    {\r\n        newModuleParameters->append(parameter);\r\n    }\r\n\r\n    return newModuleParameters;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: documentgenerator::getDesignConfigurationInstantiation()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<DesignConfigurationInstantiation> DocumentGenerator::getDesignConfigurationInstantiation(\r\n    QString const& instantiationReference) const\r\n{\r\n    for (auto const& instantiation : *component_->getDesignConfigurationInstantiations())\r\n    {\r\n        if (instantiation->name() == instantiationReference)\r\n        {\r\n           return instantiation;\r\n        }\r\n    }\r\n\r\n    return QSharedPointer<DesignConfigurationInstantiation>();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: documentgenerator::getDesignConfiguration()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<DesignConfiguration> DocumentGenerator::getDesignConfiguration(QSharedPointer<View> view) const\r\n{\r\n    QSharedPointer<DesignConfiguration> designConf(nullptr);\r\n\r\n    QSharedPointer<DesignConfigurationInstantiation> configurationInstantiation =\r\n        getDesignConfigurationInstantiation(view->getDesignConfigurationInstantiationRef());\r\n    \r\n    if (!configurationInstantiation)\r\n    {\r\n        return designConf;\r\n    }\r\n\r\n    QSharedPointer<ConfigurableVLNVReference> configurationVLNV =\r\n        configurationInstantiation->getDesignConfigurationReference();\r\n    if (configurationVLNV)\r\n    {\r\n        QSharedPointer<Document> configurationDocument =\r\n            libraryHandler_->getModel(*configurationVLNV.data());\r\n        if (configurationDocument && configurationVLNV->getType() == VLNV::DESIGNCONFIGURATION)\r\n        {\r\n            designConf = configurationDocument.dynamicCast<DesignConfiguration>();\r\n        }\r\n    }\r\n\r\n    return designConf;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: documentgenerator::getDesign()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<Design> DocumentGenerator::getDesign(QSharedPointer<View> view,\r\n    QSharedPointer<DesignConfiguration> configuration) const\r\n{\r\n    QSharedPointer<ConfigurableVLNVReference> designVLNV(nullptr);\r\n    if (!view->getDesignInstantiationRef().isEmpty())\r\n    {\r\n        QSharedPointer<DesignInstantiation> designInstantiation =\r\n            getDesignInstantiation(view->getDesignInstantiationRef());\r\n        if (designInstantiation)\r\n        {\r\n            designVLNV = designInstantiation->getDesignReference();\r\n        }\r\n    }\r\n\r\n    if (!designVLNV && configuration)\r\n    {\r\n        VLNV referenceVLNV = configuration->getDesignRef();\r\n        if (referenceVLNV.isValid() && referenceVLNV.getType() == VLNV::DESIGN)\r\n        {\r\n            designVLNV = QSharedPointer<ConfigurableVLNVReference>(new ConfigurableVLNVReference(referenceVLNV));\r\n        }\r\n    }\r\n\r\n    if (designVLNV)\r\n    {\r\n        QSharedPointer<Document> designDocument = libraryHandler_->getModel(*designVLNV.data());\r\n        if (designDocument && designVLNV->getType() == VLNV::DESIGN)\r\n        {\r\n            QSharedPointer<Design> design = designDocument.dynamicCast<Design>();\r\n            return design;\r\n        }\r\n    }\r\n\r\n    return QSharedPointer<Design>();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: documentgenerator::createComponentPicture()\r\n//-----------------------------------------------------------------------------\r\nvoid DocumentGenerator::createComponentPicture(QStringList& pictureList)\r\n{\r\n    ComponentPreviewBox compBox(libraryHandler_);\r\n    compBox.hide();\r\n    compBox.setComponent(component_);\r\n\r\n    QString compPicPath = imagesPath_\r\n        + \"/\"\r\n        + component_->getVlnv().toString(\".\")\r\n        + \".png\";\r\n\r\n    QFile compPicFile(compPicPath);\r\n\r\n    if (compPicFile.exists())\r\n    {\r\n        compPicFile.remove();\r\n    }\r\n\r\n    // get the rect that bounds all items on box\r\n    QRectF boundingRect = compBox.itemsBoundingRect();\r\n    boundingRect.setHeight(boundingRect.height() + 2);\r\n    boundingRect.setWidth(boundingRect.width() + 2);\r\n\r\n    // set the size of the picture\r\n    QPixmap compPic(boundingRect.size().toSize());\r\n\r\n    // create the picture for the component\r\n    QPainter painter(&compPic);\r\n    painter.fillRect(compPic.rect(), QBrush(Qt::white));\r\n    compBox.scene()->render(&painter, compPic.rect(), boundingRect.toRect());\r\n    if (!compPic.save(&compPicFile, \"PNG\"))\r\n    {\r\n        emit errorMessage(tr(\"Could not save picture %1\").arg(compPicPath));\r\n    }\r\n    else\r\n    {\r\n        pictureList.append(compPicPath);\r\n    }\r\n}\r\n"
  },
  {
    "path": "kactusGenerators/DocumentGenerator/documentgenerator.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: DocumentGenerator.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 19.09.2011\r\n//\r\n// Description:\r\n// Generates documentation for a component and its associated items.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef DOCUMENTGENERATOR_H\r\n#define DOCUMENTGENERATOR_H\r\n\r\n#include <kactusGenerators/DocumentGenerator/DocumentationWriter.h>\r\n\r\n#include <KactusAPI/include/ExpressionFormatterFactory.h>\r\n#include <KactusAPI/include/ExpressionFormatter.h>\r\n#include <KactusAPI/include/ComponentParameterFinder.h>\r\n\r\n#include <editors/common/DesignWidgetFactory.h>\r\n\r\n#include <KactusAPI/include/LibraryInterface.h>\r\n\r\n#include <IPXACTmodels/DesignConfiguration/DesignConfiguration.h>\r\n#include <IPXACTmodels/common/VLNV.h>\r\n#include <IPXACTmodels/Component/Component.h>\r\n\r\n#include <QTextStream>\r\n#include <QList>\r\n#include <QSharedPointer>\r\n#include <QStringList>\r\n#include <QWidget>\r\n\r\nclass AddressBlock;\r\nclass Register;\r\nclass Field;\r\nclass View;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Generates documentation for a component and its associated items.\r\n//-----------------------------------------------------------------------------\r\nclass DocumentGenerator : public QObject\r\n{\r\n    Q_OBJECT\r\n\r\npublic:\r\n\r\n    enum DocumentFormat\r\n    {\r\n        HTML,\r\n        MD\r\n    };\r\n\r\n    /*!\r\n     *  The constructor.\r\n     *\r\n     *    @param [in] handler                     Library, where the components reside.\r\n     *    @param [in] vlnv                        VLNV of the component or design.\r\n     *    @param [in] designWidgetFactory         Factory for making design widgets.\r\n     *    @param [in] expressionFormatterFactory  Factory for making expression formatters.\r\n     *    @param [in] componentNumber             Component number for current generator\r\n     *    @param [in] parent                      The parent widget of the generator.\r\n     */\r\n    DocumentGenerator(LibraryInterface* handler, const VLNV& vlnv, DesignWidgetFactory* designWidgetFactory,\r\n        ExpressionFormatterFactory* expressionFormatterFactory, int componentNumber, QWidget* parent);\r\n    \r\n    /*!\r\n     *  The destructor\r\n     */\r\n    virtual ~DocumentGenerator();\r\n    \r\n    /*!\r\n     *  Set the document format\r\n     *\r\n     *    @param [in] format          The document file format\r\n     */\r\n    void setFormat(DocumentFormat format);\r\n\r\n    /*!\r\n     *  Write the documentation to the selected stream.\r\n     *\r\n     *    @param [in] stream          The stream where to write.\r\n     *    @param [in] targetPath      The path where the document will be placed.\r\n     */\r\n    void writeDocumentation(QTextStream& stream, QString targetPath);\r\n\r\n    /*!\r\n     *  Write the document header.\r\n     *\r\n     *    @param [in] stream  The text stream to write the header into.\r\n     */\r\n    void writeHeader(QTextStream& stream);\r\n\r\n    /*!\r\n     *  Write the table of contents for the component the generator is working on.\r\n     *\r\n     *    @param [in] componentNumber     The number for this component.\r\n     *    @param [in] stream              The text stream to write the table of contents into.\r\n     */\r\n    void writeTableOfContents(QTextStream& stream);\r\n\r\n    /*!\r\n     *  Write the documentation for the given component.\r\n     *\r\n     *    @param [in] stream          The text stream to write the documentation into.\r\n     *    @param [in] targetPath      File path to the file to be written.\r\n     *    @param [in] filesToInclude  List of file names that contain pictures needed to display the document.\r\n     */\r\n    void writeDocumentation(QTextStream& stream, const QString& targetPath, QStringList& filesToInclude);\r\n\r\n    /*!\r\n     *  Write the kactus2 attributes of the component.\r\n     *\r\n     *    @param [in] stream              The text stream to write the documentation into.\r\n     *    @param [in] subHeaderNumber     The number that defines the sub-header.\r\n     */\r\n    void writeKactusAttributes(QTextStream& stream, int& subHeaderNumber);\r\n\r\n    /*!\r\n     *  Write the parameters of the component.\r\n     *\r\n     *    @param [in] stream              The text stream to write the documentation into.\r\n     *    @param [in] subHeaderNumber     The number that defines the sub-header.\r\n     */\r\n    void writeParameters(QTextStream& stream, int& subHeaderNumber);\r\n\r\n    /*!\r\n     *  Write the memory maps of the component.\r\n     *\r\n     *    @param [in] stream              The text stream to write the documentation into.\r\n     *    @param [in] subHeaderNumber     The number that defines the sub header.\r\n     */\r\n    void writeMemoryMaps(QTextStream& stream, int& subHeaderNumber);\r\n\r\n    /*!\r\n     *  Write the address blocks of the memory map.\r\n     *\r\n     *    @param [in] addressBlocks       The list of the address blocks.\r\n     *    @param [in] stream              The text stream to write the documentation into.\r\n     *    @param [in] subHeaderNumber     The number that defines the sub header.\r\n     *    @param [in] memoryMapNumber     The number for the memory map, whose address blocks are written.\r\n     */\r\n    void writeAddressBlocks(QList <QSharedPointer <AddressBlock> > addressBlocks, QTextStream& stream,\r\n        int subHeaderNumber, int memoryMapNumber);\r\n\r\n    /*!\r\n     *  Write the registers of the address block.\r\n     *\r\n     *    @param [in] registers           The list of registers.\r\n     *    @param [in] stream              The text stream to write the documentation into.\r\n     *    @param [in] subHeaderNumber     The number that defines the sub header.\r\n     *    @param [in] memoryMapNumber     The number that defines the memory map.\r\n     *    @param [in] addressBlockNumber  The number that defines the address block.\r\n     */\r\n    void writeRegisters(QList <QSharedPointer <Register> > registers, QTextStream& stream, int subHeaderNumber,\r\n        int memoryMapNumber, int addressBlockNumber, int registerDataNumber);\r\n\r\n    /*!\r\n     *  Write the fields of the register.\r\n     *\r\n     *    @param [in] currentRegister     The register, whose fields are to be written.\r\n     *    @param [in] stream              The text stream to write the documentation into.\r\n     */\r\n    void writeFields(QSharedPointer <Register> currentRegister, QTextStream& stream, QList<int> subHeaderNumbers);\r\n\r\n    /*!\r\n     *  Write the ports of the component.\r\n     *\r\n     *    @param [in] stream              The text stream to write the documentation into.\r\n     *    @param [in] subHeaderNumber     The number that defines the sub header.\r\n     */\r\n    void writePorts(QTextStream& stream, int& subHeaderNumber);\r\n\r\n    /*!\r\n     *  Write the interfaces of the component.\r\n     *\r\n     *    @param [in] stream              The text stream to write the documentation into.\r\n     *    @param [in] subHeaderNumber     The number that defines the sub header.\r\n     */\r\n    void writeInterfaces(QTextStream& stream, int& subHeaderNumber);\r\n\r\n    /*!\r\n     *  Write the file sets of the component.\r\n     *\r\n     *    @param [in] stream              The text stream to write the documentation into.\r\n     *    @param [in] subHeaderNumber     The number that defines the sub header.\r\n     */\r\n    void writeFileSets(QTextStream& stream, int& subHeaderNumber);\r\n\r\n    /*!\r\n     *  Write the views of the component.\r\n     *\r\n     *    @param [in] stream              The text stream to write the component views.\r\n     *    @param [in] subHeaderNumber     The number that defines the sub header.\r\n     *    @param [in] pictureList         List of file names to add the pictures of the referenced designs to.\r\n     */\r\n    void writeViews(QTextStream& stream, int& subHeaderNumber, QStringList& pictureList);\r\n    \r\n    /*!\r\n     *  Write the end of the document, if the format requires it.\r\n     *\r\n     *    @param [in] stream  The text stream to write the documentation into.\r\n     */\r\n    void writeEndOfDocument(QTextStream& stream);\r\n\r\n    /*!\r\n     *  Sets the images folder path.\r\n     *\r\n     *    @param [in] path    The new images path.\r\n     */\r\n    void setImagesPath(QString const& path);\r\n\r\nsignals:\r\n\r\n    /*!\r\n     *  Print an error message to the user.\r\n     *\r\n     *    @param [in] errorMessage    Selected error message.\r\n     */\r\n    void errorMessage(const QString& errorMessage);\r\n\r\n    /*!\r\n     *  Print a notification to the user.\r\n     *\r\n     *    @param [in] noticeMessage   Selected notification.\r\n     */\r\n    void noticeMessage(const QString& noticeMessage);\r\n\r\nprivate:\r\n    //! No copying. No assignment\r\n    DocumentGenerator(const DocumentGenerator& other);\r\n    DocumentGenerator& operator=(const DocumentGenerator& other);\r\n\r\n    /*!\r\n     *  Write the selected view.\r\n     *\r\n     *    @param [in] stream              The text stream to write the view.\r\n     *    @param [in] view                The selected view.\r\n     *    @param [in] subHeaderNumber     Number for the sub header.\r\n     *    @param [in] viewNumber          Number defining the selected view.\r\n     *    @param [in] pictureList         List of file names to add the pictures of the referenced designs to.\r\n     */\r\n    void writeSingleView(QTextStream& stream, QSharedPointer<View> view,\r\n        int const& subHeaderNumber, int const& viewNumber, QStringList& pictureList);\r\n\r\n    /*!\r\n     *  Write the referenced component instantiation.\r\n     *\r\n     *    @param [in] stream                  Text stream to write the component instantiation.\r\n     *    @param [in] instantiationReference  Name of the selected component instantiation.\r\n     *    @param [in] subHeaderNumber         Number for the sub header.\r\n     *    @param [in] viewNumber              Number defining the selected view.\r\n     *    @param [in] instantiationNumber     Number defining the component instantiation.\r\n     */\r\n    void writeReferencedComponentInstantiation(QTextStream& stream, QString const& instantiationReference,\r\n        int const& subHeaderNumber, int const& viewNumber, int const& instantiationNumber);\r\n\r\n    /*!\r\n     *  Write the referenced design configuration instantiation.\r\n     *\r\n     *    @param [in] stream                  Text stream to write the component instantiation.\r\n     *    @param [in] configurationReference  Name of the selected design configuration instantiation.\r\n     *    @param [in] subHeaderNumber         Number for the sub header.\r\n     *    @param [in] viewNumber              Number defining the selected view.\r\n     *    @param [in] instantiationNumber     Number defining the component instantiation.\r\n     */\r\n    void writeReferencedDesignConfigurationInstantiation(QTextStream& stream,\r\n        QString const& configurationReference, int const& subHeaderNumber, int const& viewNumber,\r\n        int const& instantiationNumber);\r\n    /*!\r\n     *  Write the referenced design instantiation.\r\n     *\r\n     *    @param [in] stream                  Text stream to write the component instantiation.\r\n     *    @param [in] designReference         Name of the selected design instantiation.\r\n     *    @param [in] subHeaderNumber         Number for the sub header.\r\n     *    @param [in] viewNumber              Number defining the selected view.\r\n     *    @param [in] instantiationNumber     Number defining the component instantiation.\r\n     */\r\n    void writeReferencedDesignInstantiation(QTextStream& stream, QString const& designReference,\r\n        int const& subHeaderNumber, int const& viewNumber, int const& instantiationNumber);\r\n\r\n    /*!\r\n        *  Write the design diagram referenced by the design instantiation or the design configuration.\r\n        *\r\n        *    @param [in] stream          Text stream to write the design diagram.\r\n        *    @param [in] viewTabs        Design diagram indentation in the file.\r\n        *    @param [in] view            View containing the design and design configuration references.\r\n        *    @param [in] pictureList     List of file names to add the pictures of the referenced designs to.\r\n        */\r\n    void writeDesign(QTextStream& stream, QSharedPointer<View> view, QStringList& pictureList);\r\n\r\n    /*!\r\n    *  Create a picture for the design\r\n    *\r\n    *    @param [in] pictureList     List of file names to add the path of the created picture to.\r\n    *    @param [in] viewName        Name of the view to create the design picture for.\r\n    */\r\n    void createDesignPicture(QStringList& pictureList, QString const& viewName, QString const& designPicPath);\r\n\r\n    /*!\r\n     *  Get the selected design instantiation.\r\n     *\r\n     *    @param [in] designReference     Name of the selected design instantiation.\r\n     *\r\n     *    @return The design instantiation \r\n     */\r\n    QSharedPointer<DesignInstantiation> getDesignInstantiation(QString const& designReference) const;\r\n\r\n    /*!\r\n     *  Get the referenced component instantiation.\r\n     *\r\n     *    @param [in] instantiationReference  Name of the selected component instantiation.\r\n     *\r\n     *    @return Component instantiation containing the selected name.\r\n     */\r\n    QSharedPointer<ComponentInstantiation> getComponentInstantiation(QString const& instantiationReference) const;\r\n\r\n    /*!\r\n     *  Get the selected module parameters as a list of parameters.\r\n     *\r\n     *    @param [in] moduleParameters    The selected module parameters.\r\n     *\r\n     *    @return The module parameters as a list of parameters\r\n     */\r\n    QSharedPointer<QList<QSharedPointer<Parameter> > > getModuleParametersAsParameters(\r\n        QSharedPointer<QList<QSharedPointer<ModuleParameter> > > moduleParameters) const;\r\n\r\n    /*!\r\n     *  Get the selected design configuration instantiation.\r\n     *\r\n     *    @param [in] instantiationReference  Name of the selected design configuration instantiation.\r\n     * \r\n     *    @return The selected design configuration instantiation\r\n     */\r\n    QSharedPointer<DesignConfigurationInstantiation> getDesignConfigurationInstantiation(\r\n        QString const& instantiationReference) const;\r\n\r\n    /*!\r\n     *  Get the design configuration referenced by the selected view.\r\n     *\r\n     *    @param [in] view    The selected view.\r\n     *\r\n     *    @return The design configuration referenced by the selected view.\r\n     */\r\n    QSharedPointer<DesignConfiguration> getDesignConfiguration(QSharedPointer<View> view) const;\r\n\r\n    /*!\r\n     *  Get the design referenced by the selected view.\r\n     *\r\n     *    @param [in] view    The selected view.\r\n     *\r\n     *    @return The design referenced by the selected view.\r\n     */\r\n    QSharedPointer<Design> getDesign(QSharedPointer<View> view, QSharedPointer<DesignConfiguration> configuration)\r\n        const;\r\n\r\n    /*!\r\n     *  Parse the child items for the document generator.\r\n     *\r\n     *    @param [in] objects     List of objects that have already been parsed so there won't be duplicate\r\n     *                              components in the generated document.\r\n     */\r\n    void parseChildItems(QList<VLNV>& objects, int& currentComponentNumber);\r\n\r\n    /*!\r\n     *  Create a picture for the component.\r\n     *\r\n     *    @param [in] pictureList     List of file names to add the path of the created picture to.\r\n     */\r\n    void createComponentPicture(QStringList& pictureList);\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n    \r\n    //! Pointer to the instance that manages the library.\r\n    LibraryInterface* libraryHandler_;\r\n\r\n    //! Pointer to the component whose documentation this generator writes.\r\n    QSharedPointer<Component> component_;\r\n\r\n    //! The running number that used for writing the numbered headers.\r\n    int componentNumber_;\r\n\r\n    //! The file path to the documentation file being written.\r\n    QString targetPath_;\r\n\r\n    //! The factory for creating expression formatters.\r\n    ExpressionFormatterFactory* expressionFormatterFactory_;\r\n    \r\n    //! List contains pointers to the document generators under this generator.\r\n    QList<QSharedPointer<DocumentGenerator> > childInstances_;\r\n\r\n    //! Pointer to the instance that owns the top document generator.\r\n    QWidget* parentWidget_;\r\n\r\n    //! The expression formatter, used to change parameter IDs into names.\r\n    ExpressionFormatter* expressionFormatter_;\r\n\r\n    //! Factory for constructing design widgets used to create a picture of the design diagram.\r\n    DesignWidgetFactory* designWidgetFactory_;\r\n\r\n    //! The active writer\r\n    DocumentationWriter* writer_;\r\n\r\n    //! Writer for markdown\r\n    DocumentationWriter* mdWriter_;\r\n\r\n    //! Writer for HTML\r\n    DocumentationWriter* htmlWriter_;\r\n\r\n    //! Parameter finder for the documented component.\r\n    QSharedPointer<ComponentParameterFinder> componentFinder_;\r\n\r\n    //! The current document format\r\n    DocumentFormat currentFormat_;\r\n\r\n    //! The image save path\r\n    QString imagesPath_;\r\n};\r\n\r\n#endif // DOCUMENTGENERATOR_H\r\n"
  },
  {
    "path": "library/HierarchyView/hierarchyfilter.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: hierarchyfilter.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Antti Kamppi\r\n// Date: 1.7.2011\r\n//\r\n// Description:\r\n// The class that does the filtering and sorting of items for the library hierarchy view.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"hierarchyfilter.h\"\r\n\r\n#include \"../LibraryFilter.h\"\r\n#include \"hierarchyitem.h\"\r\n\r\n#include <IPXACTmodels/Component/Component.h>\r\n\r\n#include <KactusAPI/include/LibraryInterface.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HierarchyFilter::HierarchyFilter()\r\n//-----------------------------------------------------------------------------\r\nHierarchyFilter::HierarchyFilter(LibraryInterface* libraryAccess, QObject *parent):\r\nLibraryFilter(libraryAccess, parent)\r\n{\r\n    setRecursiveFilteringEnabled(false);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HierarchyFilter::filterAcceptsRow()\r\n//-----------------------------------------------------------------------------\r\nbool HierarchyFilter::filterAcceptsRow(int sourceRow, QModelIndex const& sourceParent) const\r\n{\r\n\t// find the hierarchy item\r\n\tQModelIndex itemIndex = sourceModel()->index(sourceRow, 0, sourceParent);\r\n\r\n\t// root item is always ok\r\n\tif (!itemIndex.isValid())\r\n    {\r\n\t\treturn true;\r\n    }\r\n\r\n\tauto item = static_cast<HierarchyItem const*>(itemIndex.internalPointer());\r\n\r\n    if (checkValidity(item->isValid()) == false)\r\n    {\r\n        return false;\r\n    }\r\n\r\n    // Display only non-duplicate children of root.\r\n    if (item->parentIsRoot() && item->isDuplicate())\r\n    {\r\n        return false;\r\n    }\r\n    \r\n    if (auto document = getLibraryInterface()->getModelReadOnly(item->getVLNV()); \r\n        !document || checkRevision(document->getRevision()) == false || checkTags(document) == false)\r\n    {\r\n        return false;\r\n    }\r\n\r\n    if (HierarchyItem::ObjectType itemType = item->type(); \r\n        itemType == HierarchyItem::COMPONENT && !type().components_)\r\n    {\r\n        return false;\r\n    }\r\n\r\n    else if (itemType == HierarchyItem::CATALOG && !type().catalogs_)\r\n    {\r\n        return false;\r\n    }\r\n\r\n    else if (itemType == HierarchyItem::APIDEFINITION || itemType == HierarchyItem::COMDEFINITION)\r\n    {\r\n        if (!type().apis_ || !implementation().sw_)\r\n        {\r\n            return false;\r\n        }\r\n\r\n    }\r\n\r\n    else if (itemType == HierarchyItem::BUSDEFINITION || itemType == HierarchyItem::ABSDEFINITION)\r\n    {\r\n        if (!type().buses_ || !implementation().hw_)\r\n        {\r\n            return false;\r\n        }\r\n    }\r\n\r\n    if (QSharedPointer<Component const> component = item->component(); \r\n        component && (!checkFirmness(component) || !checkImplementation(component) || !checkHierarchy(component)))\r\n    {\r\n        return false;\r\n    }\r\n\r\n    return QSortFilterProxyModel::filterAcceptsRow(sourceRow, sourceParent);\r\n}\r\n"
  },
  {
    "path": "library/HierarchyView/hierarchyfilter.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: hierarchyfilter.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Antti Kamppi\r\n// Date: 1.7.2011\r\n//\r\n// Description:\r\n// The class that does the filtering and sorting of items for the library hierarchy view.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef HIERARCHYFILTER_H\r\n#define HIERARCHYFILTER_H\r\n\r\n#include \"../LibraryFilter.h\"\r\n\r\n#include <KactusAPI/include/utils.h>\r\n\r\n#include <QSharedPointer>\r\n#include <QString>\r\n\r\nclass Component;\r\nclass LibraryInterface;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! The class that does the filtering and sorting of items for the library hierarchy view.\r\n//-----------------------------------------------------------------------------\r\nclass HierarchyFilter : public LibraryFilter \r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\r\n\t/*! The constructor\r\n\t *\r\n     *    @param [in] libraryAccess   Access interface to the library.\r\n\t *    @param [in] parent          Pointer to the owner of this filter.\r\n     */\r\n    HierarchyFilter(LibraryInterface* libraryAccess, QObject *parent);\r\n\r\n\t//! The destructor\r\n\tvirtual ~HierarchyFilter() = default;\r\n\r\n    //! No copying\r\n    HierarchyFilter(const HierarchyFilter& other) = delete;\r\n\r\n    //! No assignment\r\n    HierarchyFilter& operator=(const HierarchyFilter& other) = delete;\r\n\r\nprotected:\r\n\r\n\t/*! Validate the given row on a parent and check if item should be shown.\r\n\t *\r\n\t *    @param [in]  source_row     The row number of the child on the parent.\r\n\t *    @param [in]  source_parent  Model index that identifies the parent object.\r\n\t *\r\n\t *    @return bool True if object should be displayed.\r\n\t*/\r\n\tvirtual bool filterAcceptsRow(int sourceRow, QModelIndex const& sourceParent) const override final;\r\n\r\n};\r\n\r\n#endif // HIERARCHYFILTER_H\r\n"
  },
  {
    "path": "library/HierarchyView/hierarchyview.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: hierarchyview.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Antti Kamppi\r\n// Date: 01.07.2011\r\n//\r\n// Description:\r\n// HierarchyView displays the filtered contents from hierarchy filter.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"hierarchyview.h\"\r\n\r\n#include \"hierarchyfilter.h\"\r\n#include \"hierarchyitem.h\"\r\n\r\n#include <KactusAPI/include/LibraryInterface.h>\r\n\r\n#include <IPXACTmodels/BusDefinition/BusDefinition.h>\r\n#include <IPXACTmodels/Component/Component.h>\r\n\r\n#include <QApplication>\r\n#include <QDesktopServices>\r\n#include <QDrag>\r\n#include <QFileInfo>\r\n#include <QItemSelectionModel>\r\n#include <QMenu>\r\n#include <QMimeData>\r\n#include <QStyledItemDelegate>\r\n#include <QUrl>\r\n#include <QVariant>\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Custom item delegate to handle spacing of items.\r\n//-----------------------------------------------------------------------------\r\nclass HierarchyItemDelegate : public QStyledItemDelegate\r\n{\r\npublic:\r\n    HierarchyItemDelegate(QObject* parent) : QStyledItemDelegate(parent) {}\r\n\r\n    virtual QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const\r\n    {\r\n        return QStyledItemDelegate::sizeHint(option, index) + QSize(0, 10);\r\n    }\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HierarchyView::HierarchyView()\r\n//-----------------------------------------------------------------------------\r\nHierarchyView::HierarchyView(QWidget *parent, LibraryInterface* handler, HierarchyFilter* filter):\r\n    ExpandingTreeView(parent),\r\n    handler_(handler),\r\n    filter_(filter),\r\n    startPos_(),\r\n    dragIndex_(),\r\n    openDesignAction_(new QAction(tr(\"Open HW Design\"), this)),\r\n    openMemoryDesignAction_(new QAction(tr(\"Open Memory Design\"), this)),\r\n    openSWDesignAction_(new QAction(tr(\"Open SW Design\"), this)),\r\n    openComponentAction_(new QAction(tr(\"Open Component\"), this)),\r\n    openCatalogAction_(new QAction(tr(\"Open Catalog\"), this)),\r\n    createNewDesignAction_(new QAction(tr(\"New HW Design...\"), this)),\r\n    createNewSWDesignAction_(new QAction(tr(\"New SW Design...\"), this)),\r\n    createNewSystemDesignAction_(new QAction(tr(\"New System Design...\"), this)),\r\n    deleteAction_(new QAction(tr(\"Delete Item...\"), this)), \r\n    exportAction_(new QAction(tr(\"Export...\"), this)),\r\n    showErrorsAction_(new QAction(tr(\"Show Errors...\"), this)),\r\n    openBusAction_(new QAction(tr(\"Open Bus\"), this)),\r\n    addSignalsAction_(new QAction(tr(\"New Abstraction Definition...\"), this)),\r\n    openComDefAction_(new QAction(tr(\"Open COM Definition\"), this)),\r\n    openApiDefAction_(new QAction(tr(\"Open API Definition\"), this)),\r\n    openSystemAction_(new QAction(tr(\"Open System Design\"), this)),\r\n    openXmlAction_(new QAction(tr(\"Open XML File\"), this)),\r\n    openContainingFolderAction_(new QAction(tr(\"Open Containing Folder\"), this))\r\n{\r\n    setIconSize(QSize(24, 24));\r\n    setItemDelegate(new HierarchyItemDelegate(this));\r\n\r\n    // the view can be sorted\r\n    setSortingEnabled(true);\r\n\r\n\t// user can select items in the view\r\n\tsetSelectionBehavior(QAbstractItemView::SelectItems);\r\n\r\n\t// only one item can be selected at a time\r\n\tsetSelectionMode(QAbstractItemView::SingleSelection);\r\n\r\n\t// Items can not be edited\r\n\tsetEditTriggers(QAbstractItemView::NoEditTriggers);\r\n\r\n\t// user can't expand/collapse items in a normal way because the \r\n\t// event handler for mouse press events has been reimplemented\r\n\tsetItemsExpandable(false);\r\n\r\n\tsetupActions();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HierarchyView::~HierarchyView()\r\n//-----------------------------------------------------------------------------\r\nHierarchyView::~HierarchyView()\r\n{\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HierarchyView::setupActions()\r\n//-----------------------------------------------------------------------------\r\nvoid HierarchyView::setupActions()\r\n{\r\n\topenDesignAction_->setStatusTip(tr(\"Open a HW design\"));\r\n\topenDesignAction_->setToolTip(tr(\"Open a HW design\"));\r\n\tconnect(openDesignAction_, SIGNAL(triggered()), this, SLOT(onOpenDesign()), Qt::UniqueConnection);\r\n\r\n    openMemoryDesignAction_->setStatusTip(tr(\"Open a memory design\"));\r\n    openMemoryDesignAction_->setToolTip(tr(\"Open a memory design\"));\r\n    connect(openMemoryDesignAction_, SIGNAL(triggered()), this, SLOT(onOpenMemoryDesign()), Qt::UniqueConnection);\r\n\r\n    openSWDesignAction_->setStatusTip(tr(\"Open a SW design\"));\r\n    openSWDesignAction_->setToolTip(tr(\"Open a SW design\"));\r\n    connect(openSWDesignAction_, SIGNAL(triggered()), this, SLOT(onOpenDesign()), Qt::UniqueConnection);\r\n\r\n\topenComponentAction_->setStatusTip(tr(\"Open component editor\"));\r\n\topenComponentAction_->setToolTip(tr(\"Open component editor\"));\r\n\tconnect(openComponentAction_, SIGNAL(triggered()), this, SLOT(onOpenItem()), Qt::UniqueConnection);\r\n\r\n    openCatalogAction_->setStatusTip(tr(\"Open catalog editor\"));\r\n    openCatalogAction_->setToolTip(tr(\"Open catalog editor\"));\r\n    connect(openCatalogAction_, SIGNAL(triggered()), this, SLOT(onOpenItem()), Qt::UniqueConnection);\r\n\r\n\tcreateNewDesignAction_->setStatusTip(tr(\"Create new HW design\"));\r\n\tcreateNewDesignAction_->setToolTip(tr(\"Create new HW design\"));\r\n\tconnect(createNewDesignAction_, SIGNAL(triggered()), this, SLOT(onCreateDesign()), Qt::UniqueConnection);\r\n\r\n    createNewSWDesignAction_->setStatusTip(tr(\"Create new SW design\"));\r\n    createNewSWDesignAction_->setToolTip(tr(\"Create new SW design\"));\r\n    connect(createNewSWDesignAction_, SIGNAL(triggered()), this, SLOT(onCreateSWDesign()), Qt::UniqueConnection);\r\n\r\n    createNewSystemDesignAction_->setStatusTip(tr(\"Create new System design\"));\r\n    createNewSystemDesignAction_->setToolTip(tr(\"Create new System design\"));\r\n    connect(createNewSystemDesignAction_, SIGNAL(triggered()),\r\n        this, SLOT(onCreateSystemDesign()), Qt::UniqueConnection);\r\n\r\n    deleteAction_->setStatusTip(tr(\"Delete item from the library\"));\r\n    deleteAction_->setToolTip(tr(\"Delete the item from the library\"));\r\n    connect(deleteAction_, SIGNAL(triggered()),\tthis, SLOT(onDeleteAction()), Qt::UniqueConnection);\r\n\r\n\texportAction_->setStatusTip(tr(\"Export item and it's sub-items to another location\"));\r\n\texportAction_->setToolTip(tr(\"Export item and it's sub-items to another location\"));\r\n\tconnect(exportAction_, SIGNAL(triggered()), this, SLOT(onExportAction()), Qt::UniqueConnection);\r\n\r\n    showErrorsAction_->setStatusTip(tr(\"Show all errors of the item\"));\r\n    showErrorsAction_->setToolTip(tr(\"Show all errors of the item\"));\r\n    connect(showErrorsAction_, SIGNAL(triggered()), this, SLOT(onShowErrors()), Qt::UniqueConnection);\r\n\r\n\topenBusAction_->setStatusTip(tr(\"Open the bus in bus editor\"));\r\n\topenBusAction_->setToolTip(tr(\"Open the bus in bus editor\"));\r\n\tconnect(openBusAction_, SIGNAL(triggered()), this, SLOT(onOpenItem()), Qt::UniqueConnection);\r\n\r\n\taddSignalsAction_->setStatusTip(tr(\"Create new abstraction definition for the bus\"));\r\n\taddSignalsAction_->setToolTip(tr(\"Create new abstraction definition for the bus\"));\r\n\tconnect(addSignalsAction_, SIGNAL(triggered()), this, SLOT(onAddSignals()), Qt::UniqueConnection);\r\n\r\n    openComDefAction_->setStatusTip(tr(\"Open the COM definition in an editor\"));\r\n    openComDefAction_->setToolTip(tr(\"Open the COM definition in an editor\"));\r\n    connect(openComDefAction_, SIGNAL(triggered()), this, SLOT(onOpenItem()), Qt::UniqueConnection);\r\n\r\n    openApiDefAction_->setStatusTip(tr(\"Open the API definition in an editor\"));\r\n    openApiDefAction_->setToolTip(tr(\"Open the API definition in an editor\"));\r\n    connect(openApiDefAction_, SIGNAL(triggered()), this, SLOT(onOpenItem()), Qt::UniqueConnection);\r\n\r\n\topenSystemAction_->setStatusTip(tr(\"Open system design for editing\"));\r\n\topenSystemAction_->setToolTip(tr(\"Open system design for editing\"));\r\n\tconnect(openSystemAction_, SIGNAL(triggered()), this, SLOT(onOpenDesign()), Qt::UniqueConnection);\r\n\r\n\tconnect(openXmlAction_, SIGNAL(triggered()), this, SLOT(onOpenXml()), Qt::UniqueConnection);\r\n\r\n    connect(openContainingFolderAction_, SIGNAL(triggered()),\r\n        this, SLOT(onOpenContainingFolder()), Qt::UniqueConnection);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HierarchyView::onOpenItem()\r\n//-----------------------------------------------------------------------------\r\nvoid HierarchyView::onOpenItem()\r\n{\r\n\tfor (QModelIndex const& index : selectedIndexes())\r\n    {\r\n\t\temit openItem(filter_->mapToSource(index));\r\n\t}\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HierarchyView::onOpenDesign()\r\n//-----------------------------------------------------------------------------\r\nvoid HierarchyView::onOpenDesign()\r\n{\r\n    for (QModelIndex const& index : selectedIndexes())\r\n    {\r\n        emit openDesign(filter_->mapToSource(index));\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HierarchyView::onOpenMemoryDesign()\r\n//-----------------------------------------------------------------------------\r\nvoid HierarchyView::onOpenMemoryDesign()\r\n{\r\n    for (QModelIndex const& index : selectedIndexes())\r\n    {\r\n        emit openMemoryDesign(filter_->mapToSource(index));\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HierarchyView::onCreateDesign()\r\n//-----------------------------------------------------------------------------\r\nvoid HierarchyView::onCreateDesign()\r\n{\r\n\temit createNewDesign(filter_->mapToSource(currentIndex()));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HierarchyView::onCreateSWDesign()\r\n//-----------------------------------------------------------------------------\r\nvoid HierarchyView::onCreateSWDesign()\r\n{\r\n    emit createNewSWDesign(filter_->mapToSource(currentIndex()));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HierarchyView::onCreateSystemDesign()\r\n//-----------------------------------------------------------------------------\r\nvoid HierarchyView::onCreateSystemDesign()\r\n{\r\n    emit createNewSystemDesign(filter_->mapToSource(currentIndex()));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HierarchyView::onAddSignals()\r\n//-----------------------------------------------------------------------------\r\nvoid HierarchyView::onAddSignals()\r\n{\r\n\temit createNewAbsDef(filter_->mapToSource(currentIndex()));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HierarchyView::onCreateBus()\r\n//-----------------------------------------------------------------------------\r\nvoid HierarchyView::onCreateBus()\r\n{\r\n\temit createNewBus(filter_->mapToSource(currentIndex()));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HierarchyView::onDeleteAction()\r\n//-----------------------------------------------------------------------------\r\nvoid HierarchyView::onDeleteAction()\r\n{\t\r\n    emit deleteItem(filter_->mapToSource(currentIndex()));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HierarchyView::onExportAction()\r\n//-----------------------------------------------------------------------------\r\nvoid HierarchyView::onExportAction()\r\n{\r\n\tfor (QModelIndex const& index : selectedIndexes())\r\n    {\r\n\t\temit exportItem(filter_->mapToSource(index));\r\n\t}\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HierarchyView::onShowErrors()\r\n//-----------------------------------------------------------------------------\r\nvoid HierarchyView::onShowErrors()\r\n{\r\n    emit showErrors(filter_->mapToSource(currentIndex()));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HierarchyView::onOpenXml()\r\n//-----------------------------------------------------------------------------\r\nvoid HierarchyView::onOpenXml()\r\n{\r\n\tQModelIndex const index = filter_->mapToSource(currentIndex());\r\n\tHierarchyItem* item = static_cast<HierarchyItem*>(index.internalPointer());\r\n\tVLNV vlnv = item->getVLNV();\r\n\r\n\tQString xmlPath = handler_->getPath(vlnv);\r\n\t// open the file in operating system's default editor\r\n\tQDesktopServices::openUrl(QUrl::fromLocalFile(xmlPath));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HierarchyView::onOpenContainingFolder()\r\n//-----------------------------------------------------------------------------\r\nvoid HierarchyView::onOpenContainingFolder()\r\n{\r\n    QModelIndex const index = filter_->mapToSource(currentIndex());\r\n    HierarchyItem* item = static_cast<HierarchyItem*>(index.internalPointer());\r\n    VLNV vlnv = item->getVLNV();\r\n\r\n    QString path = QFileInfo(handler_->getPath(vlnv)).absolutePath();\r\n    \r\n    // Open the folder in the operating system's default file browser.\r\n    QDesktopServices::openUrl(QUrl::fromLocalFile(path));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HierarchyView::contextMenuEvent()\r\n//-----------------------------------------------------------------------------\r\nvoid HierarchyView::contextMenuEvent(QContextMenuEvent* event)\r\n{\r\n\t// accept the event so it is not passed forwards\r\n\tevent->accept();\r\n\r\n\tQModelIndex current = currentIndex();\r\n\tQModelIndexList indexes = selectedIndexes();\r\n\r\n\t// if nothing was chosen\r\n\tif (!current.isValid())\r\n    {\r\n\t\treturn;\r\n\t}\r\n\r\n\t// get original model index so internalPointer can be used\r\n\tQModelIndex const sourceIndex = filter_->mapToSource(current);\r\n\r\n\tHierarchyItem* item = static_cast<HierarchyItem*>(sourceIndex.internalPointer());\r\n\tVLNV vlnv = item->getVLNV();\r\n\r\n\t// create a menu to show contextMenu actions\r\n\tQMenu menu(this);\r\n\r\n\t// if item can be identified as single item\r\n\tif (vlnv.isValid())\r\n    {\r\n\t\t// parse the model\r\n\t\tQSharedPointer<Document const> libComp = handler_->getModelReadOnly(vlnv);\r\n        Q_ASSERT_X(libComp, \"HierarchyView::contextMenuEvent()\", \"Object was not found in library.\");\r\n\r\n        QMenu* menuNew = 0;\r\n\r\n        if (libComp)\r\n        {\r\n            // if component\r\n            if (item->type() == HierarchyItem::COMPONENT)\r\n            {\r\n                QSharedPointer<Component const> component = libComp.staticCast<Component const>();\r\n\r\n                // depending on the type of the component\r\n                if (component->getImplementation() == KactusAttribute::SYSTEM)\r\n                {\r\n                    menu.addAction(openComponentAction_);\r\n                }\r\n\r\n                else if (component->getImplementation() == KactusAttribute::SW)\r\n                {\r\n                    menu.addAction(openComponentAction_);\r\n\r\n                    menu.addSeparator();\r\n\r\n                    if (indexes.size() == 1)\r\n                    {\r\n                        menuNew = menu.addMenu(tr(\"Add\"));\r\n                        menuNew->addAction(createNewSWDesignAction_);\r\n                    }\r\n                }\r\n\r\n                else\r\n                {\r\n                    menu.addAction(openComponentAction_);\r\n                    menu.addSeparator();\r\n\r\n                    // Add create actions if only one object is selected.\r\n                    if (indexes.size() == 1)\r\n                    {\r\n                        menuNew = menu.addMenu(tr(\"Add\"));\r\n                        menuNew->addAction(createNewDesignAction_);\r\n                        menuNew->addAction(createNewSWDesignAction_);\r\n\r\n                        // Add New System Design action only if the component contains hierarchical HW views.\r\n                        if (!component->getHierViews().isEmpty())\r\n                        {\r\n                            menuNew->addAction(createNewSystemDesignAction_);\r\n                        }\r\n                    }\r\n                }\r\n            }\r\n            else if (item->type() == HierarchyItem::CATALOG)\r\n            {\r\n                menu.addAction(openCatalogAction_);\r\n            }\r\n            else if (item->type() == HierarchyItem::BUSDEFINITION)\r\n            {\r\n                menu.addAction(openBusAction_);\r\n                menuNew = menu.addMenu(tr(\"Add\"));\r\n                menuNew->addAction(addSignalsAction_);\r\n            }\r\n            else if (item->type() == HierarchyItem::ABSDEFINITION)\r\n            {\r\n                menu.addAction(openBusAction_);\r\n            }\r\n            else if (item->type() == HierarchyItem::COMDEFINITION)\r\n            {\r\n                menu.addAction(openComDefAction_);\r\n            }\r\n            else if (item->type() == HierarchyItem::APIDEFINITION)\r\n            {\r\n                menu.addAction(openApiDefAction_);\r\n            }\r\n            else if (item->type() == HierarchyItem::HW_DESIGN)\r\n            {\r\n                menu.addAction(openDesignAction_);\r\n                menu.addAction(openMemoryDesignAction_);\r\n            }\r\n            else if (item->type() == HierarchyItem::SW_DESIGN)\r\n            {\r\n                menu.addAction(openSWDesignAction_);\r\n            }\r\n            else if (item->type() == HierarchyItem::SYS_DESIGN)\r\n            {\r\n                menu.addAction(openSystemAction_);\r\n            }\r\n        }\r\n\r\n        // Insert the New menu to the popup menu if it was created.\r\n        if (menuNew != 0)\r\n        {\r\n            menu.addSeparator();\r\n            menu.addMenu(menuNew);\r\n        }\r\n\r\n        menu.addSeparator();\r\n\r\n        if (!item->isValid())\r\n        {\r\n            menu.addAction(showErrorsAction_);\r\n        }\r\n\r\n        menu.addAction(openContainingFolderAction_);\r\n        menu.addAction(openXmlAction_);\r\n    }\r\n\r\n    menu.addAction(exportAction_);\r\n    menu.addAction(deleteAction_);\r\n\r\n\tmenu.exec(event->globalPos());\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HierarchyView::mouseDoubleClickEvent()\r\n//-----------------------------------------------------------------------------\r\nvoid HierarchyView::mouseDoubleClickEvent(QMouseEvent* event)\r\n{\r\n\t// accept the event so it is not passed forwards\r\n\tevent->accept();\r\n\r\n\tQModelIndex origIndex = indexAt(event->pos());\r\n\r\n\t// get original model index so internalPointer can be used\r\n\tQModelIndex sourceIndex = filter_->mapToSource(origIndex);\r\n\r\n\tif (sourceIndex.isValid())\r\n    {\r\n        HierarchyItem* item = static_cast<HierarchyItem*>(sourceIndex.internalPointer());\r\n        if (item->type() == HierarchyItem::HW_DESIGN ||\r\n            item->type() == HierarchyItem::SW_DESIGN ||\r\n            item->type() == HierarchyItem::SYS_DESIGN)\r\n        {\r\n            emit openDesign(sourceIndex);\r\n        }\r\n        else\r\n        {\r\n            emit openItem(sourceIndex);\t\t\r\n        }\r\n\r\n\t\t// select the object even if the instance column was clicked\r\n\t\tQModelIndex indexToSelect = model()->index(origIndex.row(), 0, origIndex.parent());\r\n\t\tsetCurrentIndex(indexToSelect);\r\n\t}\r\n\r\n\t// let the default handler process the event\r\n\tQTreeView::mouseDoubleClickEvent(event);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HierarchyView::mousePressEvent()\r\n//-----------------------------------------------------------------------------\r\nvoid HierarchyView::mousePressEvent(QMouseEvent *event)\r\n{\r\n\tstartPos_ = event->pos();\r\n\tQModelIndex index = indexAt(startPos_);\r\n\r\n\t// check if the object is already expanded or not\r\n\tbool expanded = false;\r\n\tif (index.isValid())\r\n    {\r\n\t\texpanded = isExpanded(index);\r\n\t}\r\n\r\n\tif (event->button() == Qt::LeftButton)\r\n    {\r\n\t\tdragIndex_ = filter_->mapToSource(index);\r\n\r\n\t\t// left click expands/collapses items, right click shows context menu\r\n\t\tif (expanded)\r\n        {\r\n\t\t\tcollapse(index);\r\n\t\t}\r\n\t\telse\r\n        {\r\n\t\t\texpand(index);\r\n\t\t}\r\n\t}\r\n\r\n\tQTreeView::mousePressEvent(event);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HierarchyView::mouseReleaseEvent()\r\n//-----------------------------------------------------------------------------\r\nvoid HierarchyView::mouseReleaseEvent(QMouseEvent* event)\r\n{\r\n\tQModelIndex index = indexAt(event->pos());\r\n\t\r\n\tif (index.isValid() && index.column() == 0)\r\n    {\r\n\t\tQModelIndex sourceIndex = filter_->mapToSource(index);\r\n\t\tHierarchyItem* item = static_cast<HierarchyItem*>(sourceIndex.internalPointer());\r\n\t\temit componentSelected(item->getVLNV());\r\n\t}\r\n\r\n\tQTreeView::mouseReleaseEvent(event);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HierarchyView::mouseMoveEvent()\r\n//-----------------------------------------------------------------------------\r\nvoid HierarchyView::mouseMoveEvent(QMouseEvent* event)\r\n{\r\n\t// if left mouse button is pressed down\r\n\tif (event->buttons() & Qt::LeftButton)\r\n    {\r\n\t\t// calculate the distance of the drag\r\n\t\tint distance = (event->pos() - startPos_).manhattanLength();\r\n\r\n\t\t// make sure the drag distance is large enough to start the drag\r\n\t\tif (distance >= QApplication::startDragDistance())\r\n        {\r\n\t\t\t// find the item that is being dragged\r\n\t\t\tHierarchyItem* item = static_cast<HierarchyItem*>(dragIndex_.internalPointer());\r\n            if (item != 0)\r\n            {\r\n\t\t\t    VLNV vlnv = item->getVLNV();\r\n\r\n\t\t\t    // if vlnv is valid\r\n\t\t\t    if (vlnv.isValid())\r\n                {\r\n\t\t\t\t    QDrag *drag = new QDrag(this);\r\n\t\t\t\t    QMimeData *mimeData = new QMimeData;\r\n\r\n\t\t\t\t    QVariant data = QVariant::fromValue(vlnv);\r\n\r\n\t\t\t\t    mimeData->setImageData(data);\r\n\t\t\t\t    drag->setMimeData(mimeData);\r\n\t\t\t\t    drag->exec(Qt::MoveAction | Qt::CopyAction | Qt::LinkAction);\r\n\t\t\t    }\r\n            }\r\n\t\t}\r\n\t}\r\n\tQTreeView::mouseMoveEvent(event);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HierarchyView::setCurrentIndex()\r\n//-----------------------------------------------------------------------------\r\nvoid HierarchyView::setCurrentIndex(QModelIndex const& index)\r\n{\r\n\tQModelIndex temp = index;\r\n\t\r\n\t// expand the whole tree up to the index\r\n\twhile (temp.parent().isValid())\r\n    {\r\n\t\ttemp = temp.parent();\r\n\t\texpand(temp);\r\n\t}\r\n\r\n\t// use the default implementation\r\n\tQTreeView::setCurrentIndex(index);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HierarchyView::setSelectedIndexes()\r\n//-----------------------------------------------------------------------------\r\nvoid HierarchyView::setSelectedIndexes(QModelIndexList const& indexes)\r\n{\r\n\t// clear any previously selected items\r\n\tclearSelection();\r\n\r\n\tfor (QModelIndex const& index : indexes)\r\n    {\t\t\r\n        if (index.isValid())\r\n        {\r\n            selectionModel()->select(index, QItemSelectionModel::Select);\r\n\r\n            QModelIndex temp = index;\r\n            expand(temp);\r\n\r\n            // expand the whole tree up to the index\r\n            while (temp.parent().isValid())\r\n            {\r\n                temp = temp.parent();\r\n                expand(temp);\r\n            }\r\n        }\r\n\t}\r\n}\r\n"
  },
  {
    "path": "library/HierarchyView/hierarchyview.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: hierarchyview.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Antti Kamppi\r\n// Date: 01.07.2011\r\n//\r\n// Description:\r\n// HierarchyView displays the filtered contents from hierarchy filter.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef HIERARCHYVIEW_H\r\n#define HIERARCHYVIEW_H\r\n\r\n#include <common/views/ExpandingTreeView/ExpandingTreeView.h>\r\n\r\n#include <IPXACTmodels/common/VLNV.h>\r\n\r\n#include <QTreeView>\r\n#include <QPoint>\r\n#include <QAction>\r\n#include <QContextMenuEvent>\r\n#include <QMouseEvent>\r\n\r\nclass LibraryInterface;\r\nclass HierarchyFilter;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! HierarchyView displays the filtered contents from hierarchy filter.\r\n//-----------------------------------------------------------------------------\r\nclass HierarchyView : public ExpandingTreeView\r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\r\n\t/*! The constructor\r\n\t *\r\n\t *    @param [in] parent      The owner of this widget.\r\n\t *    @param [in] handler     The instance that manages the library.\r\n\t *    @param [in] filter      The instance that does sorting and filtering.\r\n\t*/\r\n\tHierarchyView(QWidget *parent, LibraryInterface* handler, HierarchyFilter* filter);\r\n\t\r\n\t//! The destructor\r\n\tvirtual ~HierarchyView();\r\n\r\n\t/*! Select the item with given indexes in the view.\r\n\t *\r\n\t *    @param [in] indexes List in model indexes to select.\r\n\t*/\r\n\tvoid setSelectedIndexes(const QModelIndexList& indexes);\r\n\r\npublic slots:\r\n\r\n\t//! Open component editor\r\n\tvoid onOpenItem();\r\n\r\n    void onOpenDesign();\r\n\r\n    void onOpenMemoryDesign();\r\n\r\n\t//! Create new design\r\n\tvoid onCreateDesign();\r\n\r\n    //! Create new SW design\r\n    void onCreateSWDesign();\r\n\r\n    //! Create new system design\r\n    void onCreateSystemDesign();\r\n    \r\n    //! Delete item from library.\r\n    void onDeleteAction();\r\n\r\n\t//! Called when user selects \"Export item and sub-items\" in contextMenu\r\n\tvoid onExportAction();\r\n\r\n\t/*! Set the index to be the current index and select and expand it.\r\n\t *\r\n\t *    @param [in] index Specified the index to be set as the current index.\r\n\t *\r\n\t*/\r\n\tvirtual void setCurrentIndex(QModelIndex const& index);\r\n\r\n\t//! Create new abstraction definition for selected bus definition.\r\n\tvoid onAddSignals();\r\n\r\n\t//! Create new bus definition and abstraction definition.\r\n\tvoid onCreateBus();\r\n\r\n    //! Open the xml of the selected IP-Xact element.\r\n\tvoid onOpenXml();\r\n\r\n    //! Opens the folder that contains the IP-XACT object.\r\n    void onOpenContainingFolder();\r\n\r\n    //! Called when the user chooses Show Errors from the context menu.\r\n    void onShowErrors();\r\n\r\nsignals:\r\n\r\n\t//! Open the given object in the component editor\r\n\tvoid openItem(QModelIndex const& index);\r\n    \r\n    //! Open the given object in the component editor\r\n    void openDesign(QModelIndex const& index);\r\n\r\n    void openMemoryDesign(QModelIndex const& index);\r\n\r\n\t//! create new bus\r\n\tvoid createNewBus(QModelIndex const& index);\r\n\r\n\t//! Create new abstraction definition for given bus definition.\r\n\tvoid createNewAbsDef(QModelIndex const& index);\r\n\r\n\t//! Create new design\r\n\tvoid createNewDesign(QModelIndex const& index);\r\n\r\n    //! Create new SW design.\r\n    void createNewSWDesign(QModelIndex const& index);\r\n\r\n    //! Create new system design.\r\n    void createNewSystemDesign(QModelIndex const& index);\r\n\r\n    //! Delete the selected item\r\n    void deleteItem(QModelIndex const& index);\r\n\r\n\t//! Export the selected item and it's sub-items.\r\n\tvoid exportItem(QModelIndex const& index);\r\n\r\n    //! Shows errors about the selected item.\r\n    void showErrors(QModelIndex const& index);\r\n\r\n\t//! Signal is emitted when component is selected in the view.\r\n\tvoid componentSelected(const VLNV& vlnv);\r\n\r\n\t//! A drag operation has been initiated.\r\n\tvoid dragInitiated(QModelIndex const& index);\r\n\r\n\t//! Send error message to user.\r\n\tvoid errorMessage(const QString& message);\r\n\r\n\t//! Send notification to user.\r\n\tvoid noticeMessage(const QString& message);\r\n\r\nprotected:\r\n\r\n\t/*! Handler for the context menu events.\r\n     *\r\n     *    @param [in] event The contextMenuEvent to be handled.\r\n    */\r\n    virtual void contextMenuEvent(QContextMenuEvent* event);\r\n\r\n\t//! The event handler for mouse double clicks\r\n\tvirtual void mouseDoubleClickEvent(QMouseEvent * event);\r\n\r\n\t//! The event handler for mousePress events\r\n\tvirtual void mousePressEvent(QMouseEvent *event);\r\n\r\n\t//! The event handler for mouseMove events\r\n\tvirtual void mouseMoveEvent(QMouseEvent *event);\r\n\r\n\t//! The event handler for mouse release events\r\n\tvirtual void mouseReleaseEvent(QMouseEvent * event);\r\n\r\nprivate:\r\n\t//! No copying\r\n\tHierarchyView(const HierarchyView& other);\r\n\r\n\t//! No assignment\r\n\tHierarchyView& operator=(const HierarchyView& other);\r\n\r\n\t//! Set up the actions for the context menu\r\n\tvoid setupActions();\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n\t//! The instance that manages the library.\r\n\tLibraryInterface* handler_;\r\n\r\n\t//! The instance that does the filtering and sorting\r\n\tHierarchyFilter* filter_;\r\n\r\n\t//! The starting position for drag\r\n\tQPoint startPos_;\r\n\r\n\t//! The index that is selected to be dragged\r\n\tQModelIndex dragIndex_;\r\n\r\n    //-----------------------------------------------------------------------------\r\n    //  The actions for the contextMenu\r\n    //-----------------------------------------------------------------------------\r\n\r\n\t//! Open the hierarchical design of a component\r\n\tQAction* openDesignAction_;\r\n\r\n    //! Open the memory design of a component\r\n    QAction* openMemoryDesignAction_;\r\n\r\n    //! Open the SW design of a component\r\n    QAction* openSWDesignAction_;\r\n\r\n\t//! Open the component editor\r\n\tQAction* openComponentAction_;\r\n\r\n    //! Open the catalog editor.\r\n    QAction* openCatalogAction_;\r\n\r\n\t//! Create new design for a component\r\n\tQAction* createNewDesignAction_;\r\n\r\n    //! Create new SW design for a component\r\n    QAction* createNewSWDesignAction_;\r\n\r\n    //! Create new system design for a component\r\n    QAction* createNewSystemDesignAction_;\r\n\r\n    //! Delete the item from the library\r\n    QAction* deleteAction_;\r\n\r\n\t//! Export the item(s) to a new location in file system\r\n\tQAction* exportAction_;\r\n\r\n    //! Show errors about the item.\r\n    QAction* showErrorsAction_;\r\n\r\n\t//! Open the bus editor\r\n\tQAction* openBusAction_;\r\n\r\n\t//! Create new abstraction definition for bus definition.\r\n\tQAction* addSignalsAction_;\r\n\r\n\t//! Open the COM definition editor\r\n    QAction* openComDefAction_;\r\n\r\n    //! Open the API definition editor\r\n    QAction* openApiDefAction_;\r\n\r\n    //! Open an existing system for editing.\r\n\tQAction* openSystemAction_;\r\n\r\n\t//! Open an existing software platform.\r\n\tQAction* openPlatformAction_;\r\n\r\n\t//! Open a software application\r\n\tQAction* openApplicationAction_;\r\n\r\n    //! Open end point to be edited\r\n    QAction* openEndpointAction_;\r\n\r\n    //! Open the xml file to be viewed by the user.\r\n\tQAction* openXmlAction_;\r\n\r\n    //! Action to open the containing folder.\r\n    QAction* openContainingFolderAction_;\r\n};\r\n\r\n#endif // HIERARCHYVIEW_H\r\n"
  },
  {
    "path": "library/HierarchyView/hierarchywidget.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: hierarchywidget.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Antti Kamppi\r\n// Date: 01.07.2011\r\n//\r\n// Description:\r\n// The container for hierarchy view and hierarchy filter.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"hierarchywidget.h\"\r\n#include \"hierarchymodel.h\"\r\n#include \"hierarchyitem.h\"\r\n\r\n#include <QHBoxLayout>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HierarchyWidget::HierarchyWidget()\r\n//-----------------------------------------------------------------------------\r\nHierarchyWidget::HierarchyWidget(LibraryInterface* handler, HierarchyModel* dataModel, QWidget *parent):\r\nQWidget(parent), \r\nfilter_(new HierarchyFilter(handler, this)),\r\nview_(this, handler, filter_),\r\nmodel_(dataModel)\r\n{\r\n\tQ_ASSERT_X(handler, \"HierarchyWidget constructor\", \"Null LibraryInterface pointer given as parameter\");\r\n\tQ_ASSERT_X(dataModel, \"HierarchyWidget constructor\", \"Null HierarchyModel pointer given as parameter\");\r\n\r\n\tQHBoxLayout* layout = new QHBoxLayout(this);\r\n\tlayout->addWidget(&view_);\r\n\tlayout->setContentsMargins(0, 0, 0, 0);\r\n\r\n    //filter_->setRecursiveFilteringEnabled(true);\r\n    filter_->setSourceModel(dataModel);    \r\n\r\n\tview_.setModel(filter_);\r\n\r\n\tview_.sortByColumn(0, Qt::AscendingOrder);\r\n\tview_.setColumnWidth(0, 200);\r\n\r\n\tsetupConnections(dataModel);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HierarchyWidget::~HierarchyWidget()\r\n//-----------------------------------------------------------------------------\r\nHierarchyWidget::~HierarchyWidget()\r\n{\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HierarchyWidget::selectItems()\r\n//-----------------------------------------------------------------------------\r\nvoid HierarchyWidget::selectItems(VLNV const& vlnv)\r\n{\r\n\t// if vlnv is not valid\r\n\tif (!vlnv.isValid())\r\n    {\r\n\t\t// do not select anything\r\n\t\tview_.clearSelection();\r\n\t}\r\n\r\n\t// convert the model indexes to view indexes\r\n\tQModelIndexList viewIndexes;\r\n\tfor (QModelIndex const& index : model_->findIndexes(vlnv))\r\n    {\r\n\t\tif (index.isValid())\r\n        {\r\n\t\t\tviewIndexes.append(filter_->mapFromSource(index));\r\n        }\r\n\t}\r\n\r\n    if (viewIndexes.isEmpty() == false)\r\n    {\r\n        view_.setCurrentIndex(viewIndexes.first());\r\n    }\r\n\r\n\tview_.setSelectedIndexes(viewIndexes);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HierarchyWidget::getFilter()\r\n//-----------------------------------------------------------------------------\r\nLibraryFilter* HierarchyWidget::getFilter() const\r\n{\r\n    return filter_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HierarchyWidget::onSearchTextChanged()\r\n//-----------------------------------------------------------------------------\r\nvoid HierarchyWidget::onSearchTextChanged(QString const& text)\r\n{\r\n    filter_->setFilterRegularExpression(QRegularExpression(text, QRegularExpression::CaseInsensitiveOption));\r\n    filter_->setRecursiveFilteringEnabled(text.isEmpty() == false);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HierarchyWidget::setupConnections()\r\n//-----------------------------------------------------------------------------\r\nvoid HierarchyWidget::setupConnections(HierarchyModel* dataModel)\r\n{\r\n    connect(&view_, SIGNAL(errorMessage(const QString&)),\r\n        this, SIGNAL(errorMessage(const QString&)), Qt::UniqueConnection);\r\n\r\n    connect(&view_, SIGNAL(noticeMessage(const QString&)),\r\n        this, SIGNAL(noticeMessage(const QString&)), Qt::UniqueConnection);\r\n\r\n    // connect the view to the tree model\r\n    connect(&view_, SIGNAL(openItem(const QModelIndex&)),\r\n        dataModel, SLOT(onOpenItem(const QModelIndex&)), Qt::UniqueConnection);\r\n\r\n    connect(&view_, SIGNAL(openDesign(const QModelIndex&)),\r\n        dataModel, SLOT(onOpenDesign(const QModelIndex&)), Qt::UniqueConnection);\r\n\r\n    connect(&view_, SIGNAL(openMemoryDesign(const QModelIndex&)),\r\n        dataModel, SLOT(onOpenMemoryDesign(const QModelIndex&)), Qt::UniqueConnection);\r\n\r\n    connect(&view_, SIGNAL(createNewDesign(const QModelIndex&)),\r\n        dataModel, SLOT(onCreateNewDesign(const QModelIndex&)), Qt::UniqueConnection);\r\n\r\n    connect(&view_, SIGNAL(createNewSWDesign(const QModelIndex&)),\r\n        dataModel, SLOT(onCreateNewSWDesign(const QModelIndex&)), Qt::UniqueConnection);\r\n\r\n    connect(&view_, SIGNAL(createNewSystemDesign(const QModelIndex&)),\r\n        dataModel, SLOT(onCreateNewSystemDesign(const QModelIndex&)), Qt::UniqueConnection);\r\n\r\n    connect(&view_, SIGNAL(createNewAbsDef(const QModelIndex&)),\r\n        dataModel, SLOT(onCreateNewAbsDef(const QModelIndex&)), Qt::UniqueConnection);\r\n\r\n    connect(&view_, SIGNAL(deleteItem(QModelIndex const&)),\r\n        dataModel, SLOT(onDeleteItem(QModelIndex const&)), Qt::UniqueConnection);\r\n\r\n    connect(&view_, SIGNAL(exportItem(const QModelIndex&)),\r\n        dataModel, SLOT(onExportItem(const QModelIndex&)), Qt::UniqueConnection);\r\n\r\n    connect(&view_, SIGNAL(showErrors(const QModelIndex&)),\r\n        dataModel, SLOT(onShowErrors(const QModelIndex&)), Qt::UniqueConnection);\r\n\r\n    connect(&view_, SIGNAL(componentSelected(const VLNV&)),\r\n        this, SIGNAL(componentSelected(const VLNV&)), Qt::UniqueConnection);\r\n\r\n    connect(dataModel, SIGNAL(invalidateFilter()), filter_, SLOT(invalidate()), Qt::UniqueConnection);\r\n}\r\n"
  },
  {
    "path": "library/HierarchyView/hierarchywidget.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: hierarchywidget.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Antti Kamppi\r\n// Date: 01.07.2011\r\n//\r\n// Description:\r\n// The container for hierarchy view and hierarchy filter.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef HIERARCHYWIDGET_H\r\n#define HIERARCHYWIDGET_H\r\n\r\n#include \"hierarchyview.h\"\r\n#include \"hierarchyfilter.h\"\r\n\r\n#include <IPXACTmodels/common/VLNV.h>\r\n\r\n#include <QWidget>\r\n\r\nclass HierarchyModel;\r\nclass LibraryInterface;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! The container for hierarchy view and hierarchy filter.\r\n//-----------------------------------------------------------------------------\r\nclass HierarchyWidget : public QWidget\r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\r\n\t/*! The constructor\r\n\t * \r\n\t *    @param [in] parent      The owner of this widget.\r\n\t *    @param [in] handler     The instance that manages library.\r\n\t *    @param [in] dataModel   The model that provides data to view and filter.\r\n\t */\r\n    HierarchyWidget(LibraryInterface* handler, HierarchyModel* dataModel, QWidget* parent);\r\n\t\r\n\t//! The destructor\r\n\tvirtual ~HierarchyWidget();\r\n\r\n\t/*! Select the library items that represent the given vlnv.\r\n\t *\r\n\t *    @param [in] vlnv Identifies the objects to select.\r\n\t */\r\n\tvoid selectItems(const VLNV& vlnv);\r\n    \t\r\n    /*!\r\n     *  Gets the filter for the tree model.\r\n     *\r\n     *    @return The filter in use.\r\n     */\r\n    LibraryFilter* getFilter() const;\r\n\r\nsignals:\r\n\r\n\t//! Send an error message to be printed to user.\r\n\tvoid errorMessage(const QString& msg);\r\n\r\n\t//! Send a notification to be printed to user.\r\n\tvoid noticeMessage(const QString& msg);\r\n\r\n\t//! The specified component has been selected in the view.\r\n\tvoid componentSelected(const VLNV& vlnv);\r\n\r\npublic slots:\r\n\r\n\tvoid onSearchTextChanged(QString const& text);\r\n\r\nprivate:\r\n\t//! No copying\r\n\tHierarchyWidget(const HierarchyWidget& other);\r\n\r\n\t//! No assignment\r\n\tHierarchyWidget& operator=(const HierarchyWidget& other);\r\n\r\n\t//! Set up the connections between child widgets\r\n\tvoid setupConnections(HierarchyModel* dataModel);\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n\t//! The filter to sort and filter the components.\r\n\tHierarchyFilter* filter_;\r\n\r\n\t//! The view to display the library components.\r\n\tHierarchyView view_;\r\n\r\n\t//! The model that contains the items to display.\r\n\tHierarchyModel* model_;\r\n};\r\n\r\n#endif // HIERARCHYWIDGET_H\r\n"
  },
  {
    "path": "library/ItemExporter.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: ItemExporter.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Mikko Teuho\n// Date: 25.03.2019\n//\n// Description:\n// Exports the selected library items.\n//-----------------------------------------------------------------------------\n\n#include \"ItemExporter.h\"\n\n#include \"MessageMediator.h\"\n#include \"ObjectExportDialog.h\"\n\n#include \"LibraryItemSelectionFactory.h\"\n\n#include <KactusAPI/include/DocumentFileAccess.h>\n\n#include <IPXACTmodels/Component/Component.h>\n#include <IPXACTmodels/Component/FileSet.h>\n#include <IPXACTmodels/Component/File.h>\n\n#include <QMessageBox>\n\n//-----------------------------------------------------------------------------\n// Function: ItemExporter::ItemExporter()\n//-----------------------------------------------------------------------------\nItemExporter::ItemExporter(LibraryInterface* libraryAccess,\n    QWidget* dialogParentWidget, QObject* parent):\nQObject(parent),\nlibraryAccess_(libraryAccess),\ndialogParentWidget_(dialogParentWidget)\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: ItemExporter::onExportItem()\n//-----------------------------------------------------------------------------\nvoid ItemExporter::onExportItem(VLNV const& vlnv)\n{\n    onExportItems(QList<VLNV>() << vlnv);\n}\n\n//-----------------------------------------------------------------------------\n// Function: ItemExporter::onExportItems()\n//-----------------------------------------------------------------------------\nvoid ItemExporter::onExportItems(const QList<VLNV> vlnvs)\n{\n    if (vlnvs.isEmpty())\n    {\n        return;\n    }\n\n    // get the current working directory and save it to be restored in the end of the function\n    QDir savedWorkingDirectory = QDir::current();\n\n    ObjectExportDialog* exportDialog = new ObjectExportDialog(dialogParentWidget_);\n    LibraryItemSelectionFactory::constructItemsForSelectionDialog(libraryAccess_, exportDialog, vlnvs);\n\n    if (exportDialog->exec() == QDialog::Rejected)\n    {\n        return;\n    }\n\n    QString destinationPath = exportDialog->getTargetDirectory();\n\n    DocumentStatistics exportStatistics = exportSelectedObjects(exportDialog->getSelectedItems(), destinationPath);\n\n    emit noticeMessage(createExportMessage(exportStatistics, destinationPath));\n\n    QDir::setCurrent(savedWorkingDirectory.absolutePath());\n}\n\n//-----------------------------------------------------------------------------\n// Function: ItemExporter::exportSelectedObjects()\n//-----------------------------------------------------------------------------\nItemExporter::DocumentStatistics ItemExporter::exportSelectedObjects(\n    QVector<ObjectSelectionListItem*> const& exportedItems, QString const& destinationPath)\n{\n    FileList handledFiles;\n    QDir destinationFolder(destinationPath);\n\n    InputSelection userSelections;\n    DocumentStatistics exportStatistics;\n\n    bool exportSuccess = false;\n\n    for (int i = 0; i < exportedItems.count(); i++)\n    {\n        ObjectSelectionListItem const* exportedItem = exportedItems.at(i);\n        exportSuccess = false;\n        if (exportedItem->getType() == ObjectSelectionListItem::VLNVOJBECT)\n        {\n            QSharedPointer<Document> vlnvDocument = libraryAccess_->getModel(exportedItem->getVLNV());\n            QSharedPointer<Component> component = vlnvDocument.dynamicCast<Component>();\n            if (component)\n            {\n                QVector<ObjectSelectionListItem const*> exportedComponentFiles =\n                    getExportedFilesForComponent(i, exportedItems);\n\n                exportSuccess = exportComponent(component, exportedComponentFiles, destinationFolder, handledFiles,\n                    userSelections, exportStatistics);\n            }\n            else\n            {\n                exportSuccess =\n                    exportObject(destinationFolder, exportedItem->getVLNV(), handledFiles, userSelections);\n            }\n\n            if (exportSuccess)\n            {\n                exportStatistics.documentCount++;\n            }\n        }\n    }\n\n    return exportStatistics;\n}\n\n//-----------------------------------------------------------------------------\n// Function: ItemExporter::getExportedFilesForComponent()\n//-----------------------------------------------------------------------------\nQVector<ObjectSelectionListItem const*> ItemExporter::getExportedFilesForComponent(int const& componentIndex,\n    QVector<ObjectSelectionListItem *> const& exportedItems) const\n{\n    QVector<ObjectSelectionListItem const*> exportedFiles;\n\n    for (int i = componentIndex + 1; i < exportedItems.count(); ++i)\n    {\n        ObjectSelectionListItem const* exportedItem = exportedItems.at(i);\n        if (exportedItem->getType() == ObjectSelectionListItem::FILE)\n        {\n            exportedFiles.append(exportedItem);\n        }\n        else if (exportedItem->getType() == ObjectSelectionListItem::VLNVOJBECT)\n        {\n            QSharedPointer<const Document> vlnvDocument =\n                libraryAccess_->getModelReadOnly(exportedItem->getVLNV());\n            if (!vlnvDocument.dynamicCast<const Component>().isNull())\n            {\n                break;\n            }\n        }\n    }\n\n    return exportedFiles;\n}\n\n//-----------------------------------------------------------------------------\n// Function: ItemExporter::exportComponent()\n//-----------------------------------------------------------------------------\nbool ItemExporter::exportComponent(QSharedPointer<Component> component,\n    QVector<ObjectSelectionListItem const *> exportedComponentFiles, QDir const& destinationFolder,\n    FileList& handledFiles, InputSelection & selections, DocumentStatistics& exportStatistics)\n{\n    QString documentPath = libraryAccess_->getPath(component->getVlnv());\n    QFileInfo documentFileInfo(documentPath);\n    if (handledFiles.contains(documentFileInfo))\n    {\n        return false;\n    }\n    else\n    {\n        handledFiles.append(documentFileInfo);\n    }\n\n    QSharedPointer<Document> cloneDocument = component->clone();\n    if (!cloneDocument)\n    {\n        return false;\n    }\n\n    QSharedPointer<Component> cloneComponent = cloneDocument.dynamicCast<Component>();\n    if (!cloneComponent)\n    {\n        return false;\n    }\n\n    const QDir savedWorkingDir = QDir::current();\n\n    QDir::setCurrent(destinationFolder.absolutePath());\n\n    QDir vlnvTargetDirectory;\n    QString directoryPath = component->getVlnv().toString(\"/\");\n    if (!vlnvTargetDirectory.mkpath(directoryPath))\n    {\n        emit errorMessage(tr(\"Could not create directory structure, aborting.\"));\n        QDir::setCurrent(savedWorkingDir.absolutePath());\n        return false;\n    }\n\n    vlnvTargetDirectory.setPath(directoryPath);\n\n    QString targetDirectoryPath = vlnvTargetDirectory.absolutePath();\n    QDir::setCurrent(targetDirectoryPath);\n\n    QString cloneFileName =\n        cloneComponent->getVlnv().getName() + '.' + cloneComponent->getVlnv().getVersion() + \".xml\";\n\n    QFileInfo cloneComponentInfo(cloneFileName);\n    bool createCloneComponent = true;\n    if (QFile::exists(cloneFileName) && !setActionForExistingFile(cloneFileName, selections))\n    {\n        createCloneComponent = false;\n    }\n\n    //! Copy selected files.\n    for (auto file : exportedComponentFiles)\n    {\n        if (copyFile(ObjectSelectionListItem::FILE, QFileInfo(file->getPath()), component->getVlnv(),\n            vlnvTargetDirectory, handledFiles, selections))\n        {\n            exportStatistics.fileCount++;\n        }\n    }\n\n    //! Change the path of the contained, unselected files.\n    QString originalDirectoryPath = libraryAccess_->getDirectoryPath(component->getVlnv());\n    for (auto fileSet : *cloneComponent->getFileSets())\n    {\n        for (auto currentFile : *fileSet->getFiles())\n        {\n            if (!QFile::exists(currentFile->name()))\n            {\n                QFileInfo currentFileInfo(currentFile->name());\n                if (QFile::exists(currentFileInfo.fileName()))\n                {\n                    currentFile->setName(currentFileInfo.fileName());\n                }\n                else\n                {\n                    changeFilePath(currentFile, fileSet, component, originalDirectoryPath, vlnvTargetDirectory);\n                }\n            }\n        }\n    }\n\n    if (createCloneComponent)\n    {\n        // Bypass library since exported items are not stored in library.\n\n        if (DocumentFileAccess::writeDocument(cloneComponent, cloneFileName) == false)\n        {\n            emit errorMessage(QObject::tr(\"Could not open file %1 for writing.\").arg(cloneFileName));\n        }\n    }\n\n    QDir::setCurrent(savedWorkingDir.absolutePath());\n    return createCloneComponent;\n}\n\n//-----------------------------------------------------------------------------\n// Function: ItemExporter::changeFilePath()\n//-----------------------------------------------------------------------------\nvoid ItemExporter::changeFilePath(QSharedPointer<File> file, QSharedPointer<FileSet> containingFileSet,\n    QSharedPointer<Component> originalComponent, QString const& originalComponentPath,\n    QDir const& destinationFolder)\n{\n    for (auto fileSet : *originalComponent->getFileSets())\n    {\n        if (fileSet->name() == containingFileSet->name())\n        {\n            for (auto originalFile : *fileSet->getFiles())\n            {\n                if (file->name() == originalFile->name())\n                {\n                    QString originalPath = originalComponentPath + '/' + originalFile->name();\n                    QString directoryRelativePath = destinationFolder.relativeFilePath(originalPath);\n\n                    file->setName(directoryRelativePath);\n                }\n            }\n        }\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: ItemExporter::exportObject()\n//-----------------------------------------------------------------------------\nbool ItemExporter::exportObject(QDir const& destinationFolder, VLNV const& vlnv, FileList& handledFiles,\n    InputSelection &selections)\n{\n    if (libraryAccess_->contains(vlnv) == false)\n    {\n        return false;\n    }\n\n    const QDir savedWorkingDir = QDir::current();\n\n    QDir::setCurrent(destinationFolder.absolutePath());\n\n    QDir vlnvTargetDirectory;\n    QString directoryPath = vlnv.toString(\"/\");\n    if (!vlnvTargetDirectory.mkpath(directoryPath))\n    {\n        emit errorMessage(tr(\"Could not create directory structure, aborting.\"));\n        QDir::setCurrent(savedWorkingDir.absolutePath());\n        return false;\n    }\n\n    vlnvTargetDirectory.setPath(directoryPath);\n\n    QString documentPath = libraryAccess_->getPath(vlnv);\n    QFileInfo documentFileInfo(documentPath);\n\n    bool fileWasExported = copyFile(ObjectSelectionListItem::VLNVOJBECT, documentFileInfo, vlnv,\n        vlnvTargetDirectory, handledFiles, selections);\n\n    QDir::setCurrent(savedWorkingDir.absolutePath());\n    return fileWasExported;\n}\n\n//-----------------------------------------------------------------------------\n// Function: ItemExporter::copyFile()\n//-----------------------------------------------------------------------------\nbool ItemExporter::copyFile(ObjectSelectionListItem::ItemType itemType, QFileInfo const& source,\n    VLNV const& containingVLNV, QDir& targetDirectory, FileList& handledFiles, InputSelection& selections)\n{\n    if (handledFiles.contains(source))\n    {\n        return false;\n    }\n\n    if (source.exists() == false)\n    {\n        QString message(tr(\"Could not find file: %1\").arg(source.fileName()));\n        if (itemType == ObjectSelectionListItem::FILE)\n        {\n            message += QStringLiteral(\" in component \") + containingVLNV.toString();\n        }\n\n        emit errorMessage(message);\n        return false;\n    }\n\n    // Add file to handledFiles list to indicate that we don't need to check later in possible recursive calls.\n    handledFiles.append(source);\n\n    // save the current directory to be restored at the end of the function\n    QDir savedCurrentDir = QDir::current();\n\n    QString targetFileName = source.fileName();\n    QDir::setCurrent(targetDirectory.absolutePath());\n    if (QFile::exists(targetFileName))\n    {\n        if (!setActionForExistingFile(targetFileName, selections))\n        {\n            QDir::setCurrent(savedCurrentDir.absolutePath());\n            return false;\n        }\n    }\n\n    QFile sourceFile(source.filePath());\n\n    if (!sourceFile.copy(targetFileName))\n    {\n        emit errorMessage(tr(\"File %1 couldn't be copied\").arg(source.fileName()));\n    }\n\n    // restore the current directory to the state it was before this function\n    QDir::setCurrent(savedCurrentDir.absolutePath());\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: ItemExporter::setActionForExistingFile()\n//-----------------------------------------------------------------------------\nbool ItemExporter::setActionForExistingFile(QString const& targetFileName, InputSelection& selections) const\n{\n    QMessageBox::StandardButton answer = QMessageBox::No;\n\n    if (selections.noToAll)\n    {\n        answer = QMessageBox::No;\n    }\n    else if (selections.yesToAll)\n    {\n        answer = QMessageBox::Yes;\n    }\n    else\n    {\n        // If \"yes to all\" or \"no to all\" has not been clicked, ask user what to do.\n        answer = QMessageBox::question(dialogParentWidget_, tr(\"Overwrite file?\"),\n            tr(\"The file %1 already exists, would you like to overwrite the file?\").arg(targetFileName),\n            QMessageBox::Yes | QMessageBox::No | QMessageBox::YesToAll | QMessageBox::NoToAll,\n            QMessageBox::No);\n\n        if (answer == QMessageBox::YesToAll)\n        {\n            selections.yesToAll = true;\n        }\n        else if (answer == QMessageBox::NoToAll)\n        {\n            selections.noToAll = true;\n        }\n    }\n\n    if (answer == QMessageBox::Yes || answer == QMessageBox::YesToAll)\n    {\n        QFile fileToOverwrite(targetFileName);\n        fileToOverwrite.remove();\n    }\n    else if (answer == QMessageBox::No || answer == QMessageBox::NoToAll)\n    {\n        return false;\n    }\n\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: ItemExporter::createExportMessage()\n//-----------------------------------------------------------------------------\nQString ItemExporter::createExportMessage(DocumentStatistics const& exportStatistics,\n    QString const& destinationPath) const\n{\n    QString exportMessage = \"Exported \";\n\n    if (exportStatistics.documentCount > 0)\n    {\n        exportMessage += QString(\"%1 VLNV item(s)\").arg(QString::number(exportStatistics.documentCount));\n\n        if (exportStatistics.fileCount > 0)\n        {\n            exportMessage += QString(\" and %1 file(s)\").arg(QString::number(exportStatistics.fileCount));\n        }\n    }\n    else if (exportStatistics.fileCount > 0)\n    {\n        exportMessage += QString(\"%1 file(s)\").arg(QString::number(exportStatistics.fileCount));\n    }\n    else\n    {\n        exportMessage += \"0 items\";\n    }\n\n    exportMessage += QString(\" to %1.\").arg(destinationPath);\n\n    return exportMessage;\n}\n"
  },
  {
    "path": "library/ItemExporter.h",
    "content": "//-----------------------------------------------------------------------------\n// File: ItemExporter.h\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Mikko Teuho\n// Date: 25.03.2019\n//\n// Description:\n// Exports the selected library items.\n//-----------------------------------------------------------------------------\n\n#ifndef ITEMEXPORTER_H\n#define ITEMEXPORTER_H\n\n#include \"ObjectSelectionListItem.h\"\n\n#include <IPXACTmodels/common/VLNV.h>\n\n#include <QDir>\n#include <QFileInfo>\n#include <QObject>\n#include <QString>\n#include <QWidget>\n\nusing FileList = QVector<QFileInfo>;\n\nclass LibraryInterface;\nclass Component;\nclass File;\nclass FileSet;\n\n//-----------------------------------------------------------------------------\n//! Exports the selected library items.\n//-----------------------------------------------------------------------------\nclass ItemExporter : public QObject\n{\n    Q_OBJECT\n\npublic:\n\n    /*!\n     *  The constructor.\n     *\n     *    @param [in] libraryAccess       Access to the library.\n     *    @param [in] dialogParentWidget  Parent widget for the export dialog.\n     *    @param [in] parent              The parent object.\n     */\n    ItemExporter(LibraryInterface* libraryAccess, \n        QWidget* dialogParentWidget, QObject* parent = nullptr);\n\n    /*!\n     *  The destructor.\n     */\n    virtual ~ItemExporter() = default;\n\n    //! No copying. No assignment.\n    ItemExporter(const ItemExporter &other) = delete;\n    ItemExporter &operator=(const ItemExporter &other) = delete;\n\npublic slots:\n\n    /*!\n     *  Export a library item and it's subitems to a new location.\n     *\n     *    @param [in] vlnv    VLNV tag that identifies the top item to export.\n     */\n    void onExportItem(VLNV const& vlnv);\n\n    /*!\n     *  Export a group of items to a new location\n     *\n     *    @param [in] vlnvs   QList containing the VLNVs that are to be exported.\n     */\n    void onExportItems(const QList<VLNV> vlnvs);\n\nsignals:\n\n    //! Emit a notice message to be printed to user.\n    void noticeMessage(const QString& message);\n\n    //! Emit an error message to be printed to user.\n    void errorMessage(const QString& message);\n\nprivate:\n\n    //! Struct for collecting document statistics e.g. in export.\n    struct DocumentStatistics\n    {\n        int fileCount = 0;\n        int documentCount = 0;\n    };\n\n    struct InputSelection\n    {\n        bool yesToAll = false;\n        bool noToAll = false;\n    };\n\n    /*!\n     *  Export the selected objects.\n     *\n     *    @param [in] exportedItems       The selected items to be exported.\n     *    @param [in] destinationPath     The export destination path.\n     *\n     *    @return The count of the exported items in a pair of 1. VLNVs and 2. files.\n     */\n    DocumentStatistics exportSelectedObjects(QVector<ObjectSelectionListItem*> const& exportedItems,\n        QString const& destinationPath);\n\n    /*!\n     *  Get the selected exported files of the current component.\n     *\n     *    @param [in] componentIndex  Index of the selected component.\n     *    @param [in] exportedItems   List of all the selected export items.\n     *\n     *    @return List of the exported files of the current component.\n     */\n    QVector<ObjectSelectionListItem const*> getExportedFilesForComponent(int const& componentIndex,\n        QVector<ObjectSelectionListItem*> const& exportedItems) const;\n\n    /*!\n     *  Export the selected component document.\n     *\n     *    @param [in] component               The selected component.\n     *    @param [in] exportedComponentFiles  Selected files to be exported with the component.\n     *    @param [in] destinationFolder       Destination folder for the export.\n     *    @param [in] handledFiles            List of exported files.\n     *    @param [in] selections              Selections for overwriting existing files.\n     *    @param [in] exportStatistics        Export statistics.\n     *\n     *    @return True, if the export was a success, false otherwise.\n     */\n    bool exportComponent(QSharedPointer<Component> component,\n        QVector<ObjectSelectionListItem const*> exportedComponentFiles, QDir const& destinationFolder,\n        FileList& handledFiles, InputSelection & selections, DocumentStatistics& exportStatistics);\n\n    /*!\n     *  Change the path of the selected file.\n     *\n     *    @param [in] file                    The selected file.\n     *    @param [in] containingFileSet       File set containing the file.\n     *    @param [in] originalComponent       The original component.\n     *    @param [in] originalComponentPath   Path to the original component.\n     *    @param [in] destinationFolder       Destination folder for the export.\n     */\n    void changeFilePath(QSharedPointer<File> file, QSharedPointer<FileSet> containingFileSet,\n        QSharedPointer<Component> originalComponent, QString const& originalComponentPath,\n        QDir const& destinationFolder);\n\n    /*!\n     *  Export the selected VLNV object.\n     *\n     *    @param [in] destinationFolder   Destination folder for the export.\n     *    @param [in] vlnv                VLNV of the exported item.\n     *    @param [in] handledFiles        List of the files that have been handled.\n     *    @param [in] selections          Container for yes/no to all status.\n     *\n     *    @return True, if the selected VLNV object was exported, false otherwise.\n     */\n    bool exportObject(QDir const& destinationFolder, VLNV const& vlnv, FileList& handledFiles,\n        InputSelection &selections);\n    \n    /*!\n     *  Copy a single file.\n     *\n     *    @param [in] itemType                Type of the copied file.\n     *    @param [in] source                  The source file to be copied\n     *    @param [in] containingVLNV          VLNV of the containing document.\n     *    @param [in/out] targetDirectory     The directory where the file is copied to.\n     *    @param [in/out] handledFiles        List of files that have been copied\n     *    @param [in/out] yesToAll            Info if user has selected \"yes to all\" to overwrite\n     *    @param [in/out] noToAll             Info is user has selected \"No to all\" to overwrite\n     *\n     *    @return True, if the file was copied, false otherwise.\n     */\n    bool copyFile(ObjectSelectionListItem::ItemType itemType, QFileInfo const& source, VLNV const& containingVLNV,\n        QDir& targetDirectory, FileList& handledFiles, InputSelection& selections);\n\n    /*!\n     *  Set the action for overwriting an existing file.\n     *\n     *    @param [in] targetFileName  Name of the selected file.\n     *    @param [in] selections      Selections made for overwriting an existing file.\n     *\n     *    @return True, if the existing file is to be overwritten, false otherwise.\n     */\n    bool setActionForExistingFile(QString const& targetFileName, InputSelection& selections) const;\n\n    /*!\n     *  Create the export message.\n     *\n     *    @param [in] vlnvCount           The amount of exported VLNV items.\n     *    @param [in] fileCount           The amount of exported files.\n     *    @param [in] destinationPath     The export destination.\n     *\n     *    @return The constructed export message.\n     */\n    QString createExportMessage(DocumentStatistics const& exportStatistics, QString const& destinationPath) const;\n\n    //-----------------------------------------------------------------------------\n    // Data.\n    //-----------------------------------------------------------------------------\n\n    \n    //! Access to the library.\n    LibraryInterface* libraryAccess_;\n\n    //! Parent widget for the export dialog.\n    QWidget* dialogParentWidget_;\n};\n\n#endif // ITEMEXPORTER_H\n"
  },
  {
    "path": "library/LibraryErrorModel.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: LibraryErrorModel.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Joni-Matti Maatta\r\n// Date: 04.09.2012\r\n//\r\n// Description:\r\n// Library error model.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"LibraryErrorModel.h\"\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LibraryErrorModel::LibraryErrorModel()\r\n//-----------------------------------------------------------------------------\r\nLibraryErrorModel::LibraryErrorModel(QObject* parent): QAbstractTableModel(parent), errors_(), errorSources_()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LibraryErrorModel::addErrors()\r\n//-----------------------------------------------------------------------------\r\nvoid LibraryErrorModel::addErrors(QVector<QString> const& errorList, QString const& vlnv)\r\n{\r\n    beginResetModel();\r\n    errors_ += errorList;\r\n\r\n\r\n    int errorCount = errorList.count();\r\n    for (int i = 0; i < errorCount; i++)\r\n    {\r\n        errorSources_.append(vlnv);\r\n    }\r\n\r\n    endResetModel();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LibraryErrorModel::clear()\r\n//-----------------------------------------------------------------------------\r\nvoid LibraryErrorModel::clear()\r\n{\r\n    errors_.clear();\r\n    errorSources_.clear();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LibraryErrorModel::rowCount()\r\n//-----------------------------------------------------------------------------\r\nint LibraryErrorModel::rowCount(QModelIndex const& parent) const\r\n{\r\n    if (parent.isValid())\r\n    {\r\n        return 0;\r\n    }\r\n\r\n    return errors_.count();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LibraryErrorModel::columnCount()\r\n//-----------------------------------------------------------------------------\r\nint LibraryErrorModel::columnCount(QModelIndex const& parent) const\r\n{\r\n    if (parent.isValid())\r\n    {\r\n        return 0;\r\n    }\r\n\r\n    return COLUMN_COUNT;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LibraryErrorModel::data()\r\n//-----------------------------------------------------------------------------\r\nQVariant LibraryErrorModel::data(QModelIndex const& index, int role) const\r\n{\r\n    // Check for invalid index.\r\n    if (!index.isValid() || index.row() < 0 || role != Qt::DisplayRole)\r\n    {\r\n        return QVariant();\r\n    }\r\n\r\n    if (index.column() == COLUMN_NUMBER)\r\n    {\r\n        return index.row() + 1;\r\n    }\r\n    else if (index.column() == DESCRIPTION)\r\n    {\r\n        return errors_.at(index.row());\r\n    }\r\n    else if (index.column() == VLNV_COLUMN)\r\n    {\r\n        return errorSources_.at(index.row());\r\n    }\r\n\r\n    return QVariant();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LibraryErrorModel::headerData()\r\n//-----------------------------------------------------------------------------\r\nQVariant LibraryErrorModel::headerData(int section, Qt::Orientation orientation, int role) const\r\n{\r\n    if (role != Qt::DisplayRole && orientation != Qt::Vertical)\r\n    {\r\n        return QVariant();\r\n    }\r\n\r\n    if (section == COLUMN_NUMBER)\r\n    {\r\n        return \"#\";\r\n    }\r\n    else if (section == DESCRIPTION)\r\n    {\r\n        return tr(\"Description\");\r\n    }\r\n    else if (section == VLNV_COLUMN)\r\n    {\r\n        return tr(\"Document\");\r\n    }\r\n\r\n    return QVariant();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LibraryErrorModel::flags()\r\n//-----------------------------------------------------------------------------\r\nQt::ItemFlags LibraryErrorModel::flags(QModelIndex const& index) const\r\n{\r\n    if (!index.isValid())\r\n    {\r\n        return Qt::NoItemFlags;\r\n    }\r\n\r\n    return Qt::ItemIsEnabled;\r\n}\r\n"
  },
  {
    "path": "library/LibraryErrorModel.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: LibraryErrorModel.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Joni-Matti Maatta\r\n// Date: 04.09.2012\r\n//\r\n// Description:\r\n// Library error model.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef LIBRARYERRORMODEL_H\r\n#define LIBRARYERRORMODEL_H\r\n\r\n\r\n#include <QAbstractTableModel>\r\n#include <QMap>\r\n#include <QList>\r\n#include <QString>\r\n#include <QSharedPointer>\r\n#include <QStringList>\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Library error model.\r\n//-----------------------------------------------------------------------------\r\nclass LibraryErrorModel : public QAbstractTableModel\r\n{\r\n    Q_OBJECT\r\n\r\npublic:\r\n    /*!\r\n     *  Constructor.\r\n     *\r\n     *    @param [in] parent The owner of this model.\r\n     */\r\n    LibraryErrorModel(QObject* parent);\r\n    \r\n    /*!\r\n     *  The destructor.\r\n     */\r\n    virtual ~LibraryErrorModel() = default;\r\n\r\n    // Disable copying.\r\n    LibraryErrorModel(LibraryErrorModel const& rhs) = delete;\r\n    LibraryErrorModel& operator=(LibraryErrorModel const& rhs) = delete;\r\n\r\n    /*!\r\n     *  Adds errors to the model.\r\n     */\r\n    void addErrors(QVector<QString> const& errorList, QString const& vlnv);\r\n\r\n    //! Clear all errors.\r\n    void clear();\r\n\r\n    /*!\r\n     *  Returns the number of rows to be displayed.\r\n     *\r\n     *    @param [in] parent Identifies the parent. Must always be a invalid index.\r\n     */\r\n    virtual int rowCount(const QModelIndex& parent = QModelIndex()) const override final;\r\n\r\n    /*!\r\n     *  Returns the number of columns to display.\r\n     *\r\n     *    @param [in] parent Identifies the parent. Must always be a invalid index.\r\n     */\r\n    virtual int columnCount(const QModelIndex& parent = QModelIndex()) const override final;\r\n\r\n    /*!\r\n     *  Returns that data for specified index in given data role.\r\n     *\r\n     *    @param [in] index  Identifies the object that's data is wanted.\r\n     *    @param [in] role   Identifies the type of data being requested.\r\n     *\r\n     *    @return QVariant containing the requested data.\r\n     */\r\n    virtual QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override final;\r\n\r\n    /*!\r\n     *  Returns the data for given header in given data role.\r\n     *\r\n     *    @param [in] section      Identifies the header section.\r\n     *    @param [in] orientation  Only Qt::Horizontal is supported.\r\n     *    @param [in] role         Identifies the type of the data being requested.\r\n     *\r\n     *    @return QVariant contains the requested data.\r\n     */\r\n    virtual QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole ) const \r\n        override final;\r\n\r\n    /*!\r\n     *  Retrieves info on what operations are possible for specified item.\r\n     *\r\n     *    @param [in] index Identifies the item that's operations are requested.\r\n     *\r\n     *    @return Item flags containing info on which operations are available for the given index.\r\n     */\r\n    virtual Qt::ItemFlags flags(const QModelIndex& index) const override final;\r\n\r\nprivate:\r\n\r\n    //-----------------------------------------------------------------------------\r\n    //! Column enumeration.\r\n    //-----------------------------------------------------------------------------\r\n    enum Column\r\n    {\r\n        COLUMN_NUMBER = 0,\r\n        DESCRIPTION,\r\n        VLNV_COLUMN,\r\n        COLUMN_COUNT\r\n    };\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! The list of errors.\r\n    QVector<QString> errors_;\r\n\r\n    QStringList errorSources_;\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n\r\n#endif // LIBRARYERRORMODEL_H\r\n"
  },
  {
    "path": "library/LibraryFilter.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: LibraryFilter.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Esko Pekkarinen\r\n// Date: 10.03.2015\r\n//\r\n// Description:\r\n// Base class for library filters.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"LibraryFilter.h\"\r\n\r\n#include \"LibraryItem.h\"\r\n\r\n#include <IPXACTmodels/Component/Component.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LibraryFilter::LibraryFilter()\r\n//-----------------------------------------------------------------------------\r\nLibraryFilter::LibraryFilter(LibraryInterface* libraryAccess, QObject *parent):\r\nQSortFilterProxyModel(parent), \r\n    libraryAccess_(libraryAccess)\r\n{\r\n\t// set settings for filter\r\n\tsetSortLocaleAware(true);\r\n\tsetSortCaseSensitivity(Qt::CaseInsensitive);\r\n\r\n    Q_ASSERT(libraryAccess_);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LibraryFilter::onFiltersChanged()\r\n//-----------------------------------------------------------------------------\r\nvoid LibraryFilter::onFiltersChanged(Utils::FilterOptions const& filters)\r\n{\r\n    firmness_ = filters.firmness;\r\n    implementation_ = filters.implementation;\r\n    type_ = filters.type;\r\n    hierarchy_ = filters.hierarchy;\r\n    revision_ = filters.revision;\r\n    validity_ = filters.validity;\r\n    invalidateFilter();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LibraryFilter::onFirmnessChanged()\r\n//-----------------------------------------------------------------------------\r\nvoid LibraryFilter::onFirmnessChanged(Utils::FirmnessOptions const& options)\r\n{\r\n\tfirmness_ = options;\r\n\tinvalidateFilter();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LibraryFilter::onImplementationChanged()\r\n//-----------------------------------------------------------------------------\r\nvoid LibraryFilter::onImplementationChanged(Utils::ImplementationOptions const& options)\r\n{\r\n\timplementation_ = options;\r\n\tinvalidateFilter();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LibraryFilter::onTypeChanged()\r\n//-----------------------------------------------------------------------------\r\nvoid LibraryFilter::onTypeChanged(Utils::TypeOptions const& options)\r\n{\r\n\ttype_ = options;\r\n\tinvalidateFilter();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LibraryFilter::onHierarchyChanged()\r\n//-----------------------------------------------------------------------------\r\nvoid LibraryFilter::onHierarchyChanged(Utils::HierarchyOptions const& options)\r\n{\r\n\thierarchy_ = options;\r\n\tinvalidateFilter();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LibraryFilter::onRevisionChanged()\r\n//-----------------------------------------------------------------------------\r\nvoid LibraryFilter::onRevisionChanged(Utils::RevisionOptions const& options)\r\n{\r\n    revision_ = options;\r\n    invalidateFilter();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LibraryFilter::onValidityChanged()\r\n//-----------------------------------------------------------------------------\r\nvoid LibraryFilter::onValidityChanged(Utils::ValidityOptions const& options)\r\n{\r\n    validity_ = options;\r\n    invalidateFilter();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LibraryFilter::onTagFilterChanged()\r\n//-----------------------------------------------------------------------------\r\nvoid LibraryFilter::onTagFilterChanged(QVector<TagData> filteredTags)\r\n{\r\n    tags_ = filteredTags;\r\n    invalidateFilter();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LibraryFilter::Firmness()\r\n//-----------------------------------------------------------------------------\r\nUtils::FirmnessOptions LibraryFilter::firmness() const\r\n{\r\n    return firmness_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LibraryFilter::Implementation()\r\n//-----------------------------------------------------------------------------\r\nUtils::ImplementationOptions LibraryFilter::implementation() const\r\n{\r\n    return implementation_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LibraryFilter::Type()\r\n//-----------------------------------------------------------------------------\r\nUtils::TypeOptions LibraryFilter::type() const\r\n{\r\n    return type_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LibraryFilter::checkFirmness()\r\n//-----------------------------------------------------------------------------\r\nbool LibraryFilter::checkFirmness(QSharedPointer<Component const> component) const\r\n{\r\n\tQ_ASSERT(component);\r\n\r\n    if (component->getImplementation() == KactusAttribute::SW)\r\n    {\r\n        return true;\r\n    }\r\n\r\n    KactusAttribute::Firmness componentFirmness = component->getFirmness();\r\n    if (componentFirmness == KactusAttribute::TEMPLATE)\r\n    {\r\n        return firmness_.templates_;\r\n    }\r\n    else if (componentFirmness == KactusAttribute::MUTABLE)\r\n    {\r\n        return firmness_.mutable_;\r\n    }\r\n    else if (componentFirmness == KactusAttribute::FIXED)\r\n    {\r\n        return firmness_.fixed_;\r\n    }\r\n    else\r\n    {\r\n        return false;\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LibraryFilter::checkImplementation()\r\n//-----------------------------------------------------------------------------\r\nbool LibraryFilter::checkImplementation(QSharedPointer<Component const> component) const\r\n{\r\n    Q_ASSERT(component);\r\n\r\n    KactusAttribute::Implementation componentImplementation = component->getImplementation();\r\n    if (componentImplementation == KactusAttribute::HW)\r\n    {\r\n        // if the HW component contains system views then it should be considered also as system\r\n        if (component->hasSystemViews())\r\n        {\r\n            return implementation_.hw_ || implementation_.system_;\r\n        }\r\n\r\n        // if the component is pure HW \r\n        return implementation_.hw_;\r\n    }\r\n    else if (componentImplementation == KactusAttribute::SW)\r\n    {\r\n        return implementation_.sw_;\r\n    }\r\n    else if (componentImplementation == KactusAttribute::SYSTEM)\r\n    {\r\n        return implementation_.system_;\r\n    }\r\n    else\r\n    {\r\n        return false;\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LibraryFilter::checkHierarchy()\r\n//-----------------------------------------------------------------------------\r\nbool LibraryFilter::checkHierarchy(QSharedPointer<Component const> component) const\r\n{\r\n\tQ_ASSERT(component);\r\n\r\n    if (component->getImplementation() == KactusAttribute::SW)\r\n    {\r\n        return true;\r\n    }\r\n\r\n    KactusAttribute::ProductHierarchy componentHierarchy = component->getHierarchy();\r\n    if (componentHierarchy == KactusAttribute::FLAT)\r\n    {\r\n        return hierarchy_.flat_;\r\n    }\r\n    else if (componentHierarchy ==  KactusAttribute::PRODUCT)\r\n    {\r\n        return hierarchy_.product_;\r\n    }\r\n    else if (componentHierarchy == KactusAttribute::BOARD)\r\n    {\r\n        return hierarchy_.board_;\r\n    }\r\n    else if (componentHierarchy == KactusAttribute::CHIP)\r\n    {\r\n        return hierarchy_.chip_;\r\n    }\r\n    else if (componentHierarchy == KactusAttribute::SOC)\r\n    {\r\n        return hierarchy_.soc_;\r\n    }\r\n    else if (componentHierarchy == KactusAttribute::IP)\r\n    {\r\n        return hierarchy_.ip_;\r\n    }\r\n    else \r\n    {\r\n        return false;\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LibraryFilter::checkRevision()\r\n//-----------------------------------------------------------------------------\r\nbool LibraryFilter::checkRevision(Document::Revision revision) const\r\n{\r\n    switch (revision)\r\n    {\r\n        case Document::Revision::Std14: return revision_.std14_;\r\n        case Document::Revision::Std22: return revision_.std22_;\r\n        case Document::Revision::Unknown: return true;\r\n    }\r\n\r\n    return false;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LibraryFilter::checkValidity()\r\n//-----------------------------------------------------------------------------\r\nbool LibraryFilter::checkValidity(bool isValid) const\r\n{\r\n    return (isValid && validity_.valid_) || (isValid == false && validity_.invalid_);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LibraryFilter::checkTags()\r\n//-----------------------------------------------------------------------------\r\nbool LibraryFilter::checkTags(QSharedPointer<Document const> document) const\r\n{\r\n    int tagCount = tags_.size();\r\n    if (tagCount == 0)\r\n    {\r\n        return true;\r\n    }\r\n\r\n    QVector<TagData> documentTags = document->getTags();\r\n    if (documentTags.size() < tagCount)\r\n    {\r\n        return false;\r\n    }\r\n\r\n    int documentTagCounter = 0;\r\n    for (auto const& singleDocumentTag : documentTags)\r\n    {\r\n        if (tags_.contains(singleDocumentTag))\r\n        {\r\n            documentTagCounter++;\r\n            if (documentTagCounter == tagCount)\r\n            {\r\n                return true;\r\n            }\r\n        }\r\n    }\r\n\r\n    return false;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LibraryFilter::documentContainsTag()\r\n//-----------------------------------------------------------------------------\r\nbool LibraryFilter::documentContainsTag(QSharedPointer<Document const> document, TagData const& tag) const\r\n{\r\n    for (auto documentTag : document->getTags())\r\n    {\r\n        if (documentTag.name_ == tag.name_ && documentTag.color_ == tag.color_)\r\n        {\r\n            return true;\r\n        }\r\n    }\r\n\r\n    return false;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LibraryFilter::getLibraryInterface()\r\n//-----------------------------------------------------------------------------\r\nLibraryInterface* LibraryFilter::getLibraryInterface() const\r\n{\r\n    return libraryAccess_;\r\n}\r\n"
  },
  {
    "path": "library/LibraryFilter.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: LibraryFilter.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Esko Pekkarinen\r\n// Date: 10.03.2015\r\n//\r\n// Description:\r\n// Base class for library filters.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef LIBRARYFILTER_H\r\n#define LIBRARYFILTER_H\r\n\r\n#include <KactusAPI/include/utils.h>\r\n\r\n#include <IPXACTmodels/common/TagData.h>\r\n#include <IPXACTmodels/Component/Component.h>\r\n#include <IPXACTmodels/kactusExtensions/KactusAttribute.h>\r\n\r\n#include <QSharedPointer>\r\n#include <QSortFilterProxyModel>\r\n#include <QString>\r\n\r\nclass LibraryInterface;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Base class for library filters.\r\n//-----------------------------------------------------------------------------\r\nclass LibraryFilter : public QSortFilterProxyModel\r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\r\n    /*!\r\n     *  The constructor.\r\n     *\r\n     *    @param [in] libraryAccess   Access to the library.\r\n     *    @param [in] parent          The parent object.\r\n     *\r\n     *    @return <Description>.\r\n     */\r\n    LibraryFilter(LibraryInterface* libraryAccess, QObject *parent = 0);\r\n\r\n\t//! The destructor\r\n    virtual ~LibraryFilter() = default;\r\n\r\n    //! No copying\r\n    LibraryFilter(const LibraryFilter& other) = delete;\r\n\r\n    //! No assignment\r\n    LibraryFilter& operator=(const LibraryFilter& other) = delete;\r\n\r\npublic slots:\r\n\r\n    //! Handler for when all options are changed.\r\n    void onFiltersChanged(Utils::FilterOptions const& filters);\r\n\r\n\t//! Handler for when firmness options change.\r\n\tvoid onFirmnessChanged(Utils::FirmnessOptions const& options);\r\n\r\n\t//! Handler for when implementation options change.\r\n\tvoid onImplementationChanged(Utils::ImplementationOptions const& options);\r\n\r\n\t//! Handler for when type options change.\r\n\tvoid onTypeChanged(Utils::TypeOptions const& options);\r\n\r\n\t//! Handler for when hierarchy options change.\r\n\tvoid onHierarchyChanged(Utils::HierarchyOptions const& options);\r\n\r\n    //! Handler for when revision options change.\r\n    void onRevisionChanged(Utils::RevisionOptions const& options);\r\n\r\n    //! Handler for when validity options change.\r\n    void onValidityChanged(Utils::ValidityOptions const& options);\r\n\r\n    /*!\r\n     *  Handler for changing the filtered tags.\r\n     *\r\n     *    @param [in] filteredTags    The new visible tags.\r\n     */\r\n    void onTagFilterChanged(QVector<TagData> filteredTags);\r\n\r\nprotected:\r\n\r\n\t/*! Checks if the row should be shown in the view or not.\r\n\t *\r\n\t *    @param [in]  sourceRow       Specifies the row number of the item\r\n\t *    @param [in]  sourceParent    Specifies the parent of the item.\r\n\t *\r\n\t *    @return True if item is shown.\r\n\t*/\r\n\tvirtual bool filterAcceptsRow(int sourceRow, QModelIndex const& sourceParent) const = 0;\r\n    \r\n    /*!\r\n     *  Gets the current firmness filter.\r\n     *\r\n     *    @return The firmness filter.\r\n     */\r\n    Utils::FirmnessOptions firmness() const;\r\n    \r\n    /*!\r\n     *  Gets the current implementation filter.\r\n     *\r\n     *    @return The implementation filter.\r\n     */\r\n    Utils::ImplementationOptions implementation() const;\r\n         \r\n    /*!\r\n     *  Gets the current VLNV type filter.\r\n     *\r\n     *    @return The VLNV type filter.\r\n     */   \r\n    Utils::TypeOptions type() const;\r\n\r\n    //! Check the firmness matching.\r\n\tbool checkFirmness(QSharedPointer<Component const> component) const;\r\n\r\n\t//! Check the implementation matching.\r\n\tbool checkImplementation(QSharedPointer<Component const> component) const;\r\n\r\n\t//! Check the hierarchy matching.\r\n\tbool checkHierarchy(QSharedPointer<Component const> component) const;\r\n\r\n    //! Check the revision matching.\r\n    bool checkRevision(Document::Revision revision) const;\r\n    /*!\r\n     * \r\n     *  Check the validity of the selected document.\r\n     *\r\n     *    @param [in] document    The selected document.\r\n     *\r\n     *    @return True, if the document is valid, false otherwise.\r\n     */\r\n    bool checkValidity(bool isValid) const;\r\n\r\n    /*!\r\n     *  Check the tag matching of the selected document.\r\n     *\r\n     *    @param [in] document    The selected document.\r\n     *\r\n     *    @return True, if the tags match the visible tags, false otherwise.\r\n     */\r\n    bool checkTags(QSharedPointer<Document const> document) const;\r\n\r\n    /*!\r\n     *  Get the access to the library.\r\n     *\r\n     *    @return Access to the library.\r\n     */\r\n    LibraryInterface* getLibraryInterface() const;\r\n\r\nprivate:\r\n\r\n    /*!\r\n     *  Check if a document contains the selected tag.\r\n     *\r\n     *    @param [in] document    The selected document.\r\n     *    @param [in] tag         The selected tag.\r\n     *\r\n     *    @return True, if the selected document contains the selected tag, false otherwise.\r\n     */\r\n    bool documentContainsTag(QSharedPointer<Document const> document, TagData const& tag) const;\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n\t//! Contains filters for re-usability\r\n\tUtils::FirmnessOptions firmness_;\r\n\r\n\t//! Contains filters for firmness\r\n\tUtils::ImplementationOptions implementation_;\r\n\r\n\t//! Contains filters for type\r\n\tUtils::TypeOptions type_;\r\n \r\n\t//! Contains filters for hierarchy\r\n\tUtils::HierarchyOptions hierarchy_; \r\n\r\n    //! Contains filters for revision\r\n    Utils::RevisionOptions revision_;\r\n\r\n    //! Contains filters for validity\r\n    Utils::ValidityOptions validity_;\r\n\r\n    //! List of the visible tags.\r\n    QVector<TagData> tags_;\r\n\r\n    //! Access to the library.\r\n    LibraryInterface* libraryAccess_;\r\n};\r\n\r\n#endif // LIBRARYFILTER_H\r\n"
  },
  {
    "path": "library/LibraryItemSelectionFactory.cpp",
    "content": "#include \"LibraryItemSelectionFactory.h\"\n\n#include <IPXACTmodels/generaldeclarations.h>\n#include <IPXACTmodels/AbstractionDefinition/AbstractionDefinition.h>\n#include <IPXACTmodels/Component/Component.h>\n#include <IPXACTmodels/DesignConfiguration/DesignConfiguration.h>\n\n//-----------------------------------------------------------------------------\n// Function: LibraryItemSelectionFactory::constructItemsForSelectionDialog()\n//-----------------------------------------------------------------------------\nvoid LibraryItemSelectionFactory::constructItemsForSelectionDialog(LibraryInterface* library,\n    ObjectSelectionDialog* dialog, QList<VLNV> const& vlvns)\n{\n    for (VLNV const& vlnv : vlvns)\n    {\n        if (library->contains(vlnv) == false)\n        {\n            continue;\n        }\n\n        dialog->createItem(vlnv.toString(), vlnv, true);\n\n        VLNV::IPXactType vlnvType = vlnv.getType();\n        if (vlnvType == VLNV::COMPONENT)\n        {\n            Details::addComponentFilesAndDesignItems(library, dialog, vlnv);\n        }\n\n        else if (vlnvType == VLNV::DESIGNCONFIGURATION)\n        {\n            Details::addDesignItemForConfiguration(library, dialog, vlnv);\n        }\n\n        else if (vlnvType == VLNV::BUSDEFINITION)\n        {\n            Details::addAbstractionDefinitionItems(library, dialog, vlnv);\n        }\n\n        else if (vlnvType == VLNV::ABSTRACTIONDEFINITION)\n        {\n            Details::addBusDefintionItemIfOnlyAbstraction(library, dialog, vlnv);\n        }\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: LibraryItemSelectionFactory::addComponentFilesAndDesignItems()\n//-----------------------------------------------------------------------------\nvoid LibraryItemSelectionFactory::Details::addComponentFilesAndDesignItems(LibraryInterface* library,\n    ObjectSelectionDialog* dialog,\n    VLNV const& componentVLNV)\n{\n    QSharedPointer<const Component> component =\n        library->getModelReadOnly(componentVLNV).staticCast<const Component>();\n\n    for (VLNV const& ref : component->getHierRefs())\n    {\n        if (library->contains(ref))\n        {\n            dialog->createItem(ref.toString(), ref);\n\n            if (library->getDocumentType(ref) == VLNV::DESIGNCONFIGURATION)\n            {\n                Details::addDesignItemForConfiguration(library, dialog, ref);\n            }\n        }\n    }\n\n    // Ask the component for all it's file references.\n    QString componentPath = library->getPath(componentVLNV);\n    for (QString const& relativeFilePath : component->getDependentFiles())\n    {\n        QString absoluteFilePath = General::getAbsolutePath(componentPath, relativeFilePath);\n        if (!absoluteFilePath.isEmpty())\n        {\n            dialog->createItem(absoluteFilePath);\n        }\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: LibraryItemSelectionFactory::addDesignItemForConfiguration()\n//-----------------------------------------------------------------------------\nvoid LibraryItemSelectionFactory::Details::addDesignItemForConfiguration(LibraryInterface* library,\n    ObjectSelectionDialog* dialog, VLNV const& configurationVLNV)\n{\n    VLNV designVLNV =\n        library->getModelReadOnly(configurationVLNV).staticCast<const DesignConfiguration>()->getDesignRef();\n    if (library->contains(designVLNV))\n    {\n        dialog->createItem(designVLNV.toString(), designVLNV);\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: LibraryItemSelectionFactory::addAbstractionDefinitionItems()\n//-----------------------------------------------------------------------------\nvoid LibraryItemSelectionFactory::Details::addAbstractionDefinitionItems(LibraryInterface* library,\n    ObjectSelectionDialog* dialog, VLNV const& busDefinitionVLNV)\n{\n    QList<VLNV> absDefVLNVs;\n    library->getChildren(absDefVLNVs, busDefinitionVLNV);\n\n    // If a bus definition is selected then ask to selected all it's abstraction definitions also.\n    for (VLNV const& absDefVLNV : absDefVLNVs)\n    {\n        if (library->contains(absDefVLNV))\n        {\n            dialog->createItem(absDefVLNV.toString(), absDefVLNV);\n        }\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: LibraryItemSelectionFactory::addBusDefintionItemIfOnlyAbstraction()\n//-----------------------------------------------------------------------------\nvoid LibraryItemSelectionFactory::Details::addBusDefintionItemIfOnlyAbstraction(LibraryInterface* library,\n    ObjectSelectionDialog* dialog, VLNV const& abstractionVLNV)\n{\n    VLNV busVLNV =\n        library->getModelReadOnly(abstractionVLNV).staticCast<const AbstractionDefinition>()->getBusType();\n\n    if (library->contains(busVLNV))\n    {\n        QList<VLNV> absDefVLNVs;\n        library->getChildren(absDefVLNVs, busVLNV);\n\n        // if theres only this abs def for the bus def\n        if (absDefVLNVs.size() == 1 && absDefVLNVs.first() == abstractionVLNV)\n        {\n            dialog->createItem(busVLNV.toString(), busVLNV);\n        }\n    }\n}\n"
  },
  {
    "path": "library/LibraryItemSelectionFactory.h",
    "content": "#ifndef LIBRARYITEMSELECTIONFACTORY_H\n#define LIBRARYITEMSELECTIONFACTORY_H\n\n#include \"LibraryInterface.h\"\n\n#include \"ObjectSelectionDialog.h\"\n\n#include <IPXACTmodels/common/VLNV.h>\n\n#include <QList>\n\nnamespace LibraryItemSelectionFactory\n{\n    /*!\n     *  Construct the items for the selection dialog.\n     *\n     *    @param [in] dialog    The selection dialog.\n     *    @param [in] vlvns     List of selectable VLNVs.\n     */\n   void constructItemsForSelectionDialog(LibraryInterface* library, ObjectSelectionDialog* dialog,\n                                         QList<VLNV> const& vlvns);\n\n   namespace Details\n   {\n        void addComponentFilesAndDesignItems(LibraryInterface *library, ObjectSelectionDialog* dialog,\n            VLNV const& componentVLNV);\n\n        void addDesignItemForConfiguration(LibraryInterface* library, ObjectSelectionDialog* dialog,\n            VLNV const& configurationVLNV);\n\n        void addAbstractionDefinitionItems(LibraryInterface* library, ObjectSelectionDialog* dialog,\n            VLNV const& busDefinitionVLNV);\n\n        void addBusDefintionItemIfOnlyAbstraction(LibraryInterface* library, ObjectSelectionDialog* dialog,\n            VLNV const& abstractionVLNV);\n   }\n}\n\n#endif // LIBRARYITEMSELECTIONFACTORY_H\n"
  },
  {
    "path": "library/LibraryTreeFilter.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: librarytreefilter.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Antti Kamppi\r\n// Date: 20.12.2010\r\n//\r\n// Description:\r\n// The class that does the filtering and sorting of items for the library tree view.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"LibraryTreeFilter.h\"\r\n\r\n#include \"LibraryItem.h\"\r\n#include \"LibraryInterface.h\"\r\n\r\n#include <IPXACTmodels/common/Document.h>\r\n#include <IPXACTmodels/Design/Design.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LibraryTreeFilter::LibraryTreeFilter()\r\n//-----------------------------------------------------------------------------\r\nLibraryTreeFilter::LibraryTreeFilter(LibraryInterface* handler, QObject *parent):\r\nLibraryFilter(handler, parent)\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LibraryTreeFilter::filterAcceptsRow()\r\n//-----------------------------------------------------------------------------\r\nbool LibraryTreeFilter::filterAcceptsRow(int sourceRow, const QModelIndex& sourceParent) const\r\n{\r\n    auto itemIndex = sourceModel()->index(sourceRow, 0, sourceParent);\r\n\r\n    // root item is always ok.\r\n    if (!itemIndex.isValid())\r\n    {\r\n        return true;\r\n    }\r\n\r\n    auto item = static_cast<LibraryItem*>(itemIndex.internalPointer());\r\n\r\n    for (VLNV const& vlnv : item->getVLNVs())\r\n    {\r\n        if (checkType(vlnv) && filterRegularExpression().match(vlnv.toString()).hasMatch() &&\r\n            checkValidity(item->isValid()))\r\n        {\r\n            return true;\r\n        }\r\n    }\r\n\r\n    return false;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LibraryTreeFilter::checkType()\r\n//-----------------------------------------------------------------------------\r\nbool LibraryTreeFilter::checkType(VLNV const& vlnv) const\r\n{\r\n    auto libraryAccess = getLibraryInterface();\r\n\r\n    VLNV::IPXactType documentType = libraryAccess->getDocumentType(vlnv);\r\n    QSharedPointer<Document const> document = libraryAccess->getModelReadOnly(vlnv);\r\n    \r\n    if (document == nullptr)\r\n    {\r\n        return false;\r\n    }\r\n\r\n    if (checkRevision(document->getRevision()) == false)\r\n    {\r\n        return false;\r\n    }\r\n\r\n    if (checkTags(document) == false)\r\n    {\r\n        return false;\r\n    }\r\n\r\n    if (documentType == VLNV::COMPONENT && type().components_)\r\n    {\r\n        QSharedPointer<Component const> component = document.staticCast<Component const>();\r\n\r\n        if (checkImplementation(component) && checkHierarchy(component) &&\r\n            checkFirmness(component))\r\n        {\r\n            return true;\r\n        }\r\n    }\r\n\r\n    else if (documentType == VLNV::CATALOG && type().catalogs_)\r\n    {\r\n        return true;\r\n    }\r\n\r\n    else if ((documentType == VLNV::BUSDEFINITION || documentType == VLNV::ABSTRACTIONDEFINITION) &&\r\n        type().buses_)\r\n    {\r\n        if (implementation().hw_)\r\n        {\r\n            return true;\r\n        }\r\n    }\r\n\r\n    else if ((documentType == VLNV::COMDEFINITION || documentType == VLNV::APIDEFINITION) &&\r\n        type().apis_)\r\n    {\r\n        return true;\r\n    }\r\n\r\n    else if (documentType == VLNV::DESIGN)\r\n    {\r\n        QSharedPointer<Design> design = libraryAccess->getDesign(vlnv);\r\n\r\n        if (type().advanced_ || (type().components_ && implementation().sw_ &&\r\n            design->getImplementation() == KactusAttribute::SW))\r\n        {\r\n            return true;\r\n        }\r\n    }\r\n\r\n    else if (documentType == VLNV::DESIGNCONFIGURATION && type().advanced_)\r\n    {\r\n        return true;\r\n    }\r\n\r\n    return false;\r\n}\r\n"
  },
  {
    "path": "library/LibraryTreeFilter.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: librarytreefilter.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Antti Kamppi\r\n// Date: 20.12.2010\r\n//\r\n// Description:\r\n// The class that does the filtering and sorting of items for the library tree view.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef LIBRARYTREEFILTER_H\r\n#define LIBRARYTREEFILTER_H\r\n\r\n#include \"LibraryFilter.h\"\r\n\r\nclass LibraryInterface;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! The class that does the filtering and sorting of items for the library tree view.\r\n//-----------------------------------------------------------------------------\r\nclass LibraryTreeFilter : public LibraryFilter\r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\r\n    /*! The constructor\r\n     *\r\n     *    @param [in]  handler    The instance that manages the library.\r\n     *    @param [in]  parent     The owner of this widget.\r\n     *\r\n    */\r\n    LibraryTreeFilter(LibraryInterface* handler, QObject *parent = 0);\r\n\r\n\t//! The destructor\r\n    virtual ~LibraryTreeFilter() = default;\r\n\r\n    //! No copying\r\n    LibraryTreeFilter(const LibraryTreeFilter& other) = delete;\r\n\r\n    //! No assignment\r\n    LibraryTreeFilter& operator=(const LibraryTreeFilter& other) = delete;\r\n\r\nprotected:\r\n\r\n\t/*! Checks if the row should be shown in the view or not.\r\n\t *\r\n\t *    @param [in]  sourceRow      Specifies the row number of the item\r\n\t *    @param [in]  sourceParent   Specifies the parent of the item.\r\n\t *\r\n\t *    @return True if item is shown, otherwise false.\r\n\t*/\r\n\tvirtual bool filterAcceptsRow(int sourceRow, QModelIndex const& sourceParent) const override final;\r\n\r\nprivate:\r\n\r\n\t/*!\r\n\t *  Checks if the VLNV should be shown in the view or not based on filters.\r\n\t *\r\n\t *    @param [in] vlnv\t\tThe VLNV to check.\r\n\t *\r\n\t *    @return True, if the VLNV should be shown, otherwise false.\r\n\t */\r\n\tbool checkType(VLNV const& vlnv) const;\r\n\r\n};\r\n\r\n#endif // LIBRARYTREEFILTER_H\r\n"
  },
  {
    "path": "library/LibraryTreeView.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: librarytreeview.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Antti Kamppi\r\n// Date: 20.12.2010\r\n//\r\n// Description:\r\n// The widget to display the library in a tree.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"LibraryTreeView.h\"\r\n#include \"LibraryItem.h\"\r\n#include \"LibraryInterface.h\"\r\n\r\n#include <IPXACTmodels/common/VLNV.h>\r\n#include <IPXACTmodels/common/Document.h>\r\n\r\n#include <IPXACTmodels/Component/Component.h>\r\n\r\n#include <IPXACTmodels/kactusExtensions/KactusAttribute.h>\r\n\r\n#include <QApplication>\r\n#include <QDesktopServices>\r\n#include <QDrag>\r\n#include <QFileInfo>\r\n#include <QHeaderView>\r\n#include <QMenu>\r\n#include <QMessageBox>\r\n#include <QMimeData>\r\n#include <QUrl>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LibraryTreeView::LibraryTreeView()\r\n//-----------------------------------------------------------------------------\r\nLibraryTreeView::LibraryTreeView(LibraryInterface* handler, LibraryTreeFilter* filter, QWidget* parent):\r\n    ExpandingTreeView(parent),\r\n    handler_(handler),\r\n    filter_(filter),\r\n    startPos_(),\r\n    dragIndex_(),\r\n    openHWDesignAction_(new QAction(tr(\"Open HW Design\"), this)),\r\n    openHWDesignMenu_(new QMenu(tr(\"Open HW Design\"), this)),\r\n    openSWDesignAction_(new QAction(tr(\"Open SW Design\"), this)),\r\n    openMemoryDesignAction_(new QAction(tr(\"Open Memory Design\"), this)),\r\n    openMemoryDesignMenu_(new QMenu(tr(\"Open Memory Design\"), this)),\r\n    openComponentAction_(new QAction(tr(\"Open Component\"), this)),\r\n    createNewDesignAction_(new QAction(tr(\"New HW Design...\"), this)),\r\n    createNewSWDesignAction_(new QAction(tr(\"New SW Design...\"), this)),\r\n    createNewSystemDesignAction_(new QAction(tr(\"New System Design...\"), this)),\r\n    deleteAction_(new QAction(tr(\"Delete Item...\"), this)), \r\n    exportAction_(new QAction(tr(\"Export...\"), this)),  \r\n    showErrorsAction_(new QAction(tr(\"Show Errors...\"), this)),\r\n    openBusAction_(new QAction(tr(\"Open\"), this)),\r\n    openCatalogAction_(new QAction(tr(\"Open Catalog\"), this)),\r\n    addSignalsAction_(new QAction(tr(\"New Abstraction Definition...\"), this)),\r\n    openComDefAction_(new QAction(tr(\"Open\"), this)),\r\n    openApiDefAction_(new QAction(tr(\"Open\"), this)),\r\n    openSystemAction_(new QAction(tr(\"Open System Design\"), this)),\r\n\topenSystemMenu_(new QMenu(tr(\"Open System Design\"), this)),\r\n    openXmlAction_(new QAction(tr(\"Open XML File\"), this)),\r\n    openContainingFolderAction_(new QAction(tr(\"Open Containing Folder\"), this)),\r\n    expandChilds_(new QAction(tr(\"Expand Branches\"), this)),\r\n    collapseChilds_(new QAction(tr(\"Collapse Branches\"), this)),\r\n    expandAllAction_(new QAction(tr(\"Expand All\"), this)),\r\n    collapseAllAction_(new QAction(tr(\"Collapse All\"), this))\r\n{\r\n\tQ_ASSERT_X(filter, \"LibraryTreeView constructor\", \"Null filter pointer given\");\r\n\r\n    setIconSize(QSize(20, 20));\r\n\r\n\tsetSortingEnabled(true);\r\n\r\n\tsetSelectionBehavior(QAbstractItemView::SelectItems);\r\n\tsetSelectionMode(QAbstractItemView::SingleSelection);\r\n\r\n\t// Items can not be edited.\r\n\tsetEditTriggers(QAbstractItemView::NoEditTriggers);\r\n\r\n\tsetupActions();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LibraryTreeView::contextMenuEvent()\r\n//-----------------------------------------------------------------------------\r\nvoid LibraryTreeView::contextMenuEvent(QContextMenuEvent* event)\r\n{\r\n\tevent->accept();\r\n\r\n\tQModelIndex current = currentIndex();\r\n\tif (!current.isValid())\r\n    {\r\n\t\treturn;\r\n\t}\r\n\r\n    QMenu menu(this);\r\n  \r\n    // Get original model index so internalPointer can be used.\r\n    QModelIndex sourceIndex = filter_->mapToSource(current);\r\n\tVLNV vlnv = static_cast<LibraryItem*>(sourceIndex.internalPointer())->getVLNV();\r\n\r\n\tif (vlnv.isValid())\r\n    {\r\n\t\tQSharedPointer<Document const> document = handler_->getModelReadOnly(vlnv);\r\n\r\n        if (document)\r\n        {\r\n            VLNV::IPXactType documentType = handler_->getDocumentType(vlnv);\r\n            if (documentType == VLNV::COMPONENT)\r\n            {\r\n                QSharedPointer<Component const> component = document.staticCast<Component const>();\r\n\r\n                menu.addAction(openComponentAction_);\r\n\r\n                // depending on the type of the component\r\n                if (component->getImplementation() == KactusAttribute::SYSTEM)\r\n                {\r\n                    if (component->hasSystemViews())\r\n                    {\r\n\t\t\t\t\t\tsetupSystemActionsForContextMenu(component, menu);\r\n                    }\r\n                }\r\n                else\r\n                {\r\n                    QMenu* menuNew = menu.addMenu(tr(\"Add\"));\r\n\r\n                    if (component->getImplementation() == KactusAttribute::HW)\r\n                    {\r\n                        QStringList hierarchicalViewNames = component->getHierViews();\r\n                        if (!hierarchicalViewNames.isEmpty())\r\n                        {\r\n                            openHWDesignMenu_->clear();\r\n                            openMemoryDesignMenu_->clear();\r\n                            openSystemMenu_->clear();\r\n\r\n                            for (QString const& viewName : hierarchicalViewNames)\r\n                            {\r\n                                openHWDesignMenu_->addAction(new QAction(viewName, openHWDesignMenu_));\r\n                                openMemoryDesignMenu_->addAction(new QAction(viewName, openMemoryDesignMenu_));\r\n                            }\r\n\r\n                            if (hierarchicalViewNames.count() == 1)\r\n                            {\r\n                                menu.addAction(openHWDesignAction_);\r\n                                connect(openHWDesignAction_, SIGNAL(triggered()),\r\n                                    openHWDesignMenu_->actions().first(), SLOT(trigger()));\r\n\r\n                                menu.addAction(openMemoryDesignAction_);\r\n                                connect(openMemoryDesignAction_, SIGNAL(triggered()),\r\n                                    openMemoryDesignMenu_->actions().first(), SLOT(trigger()));\r\n                            }\r\n                            else\r\n                            {\r\n                                menu.addMenu(openHWDesignMenu_);\r\n                                menu.addMenu(openMemoryDesignMenu_);\r\n                            }\r\n                        }\r\n\r\n                        if (component->hasSystemViews())\r\n                        {\r\n                            setupSystemActionsForContextMenu(component, menu);\r\n                        }\r\n\r\n                        menuNew->addAction(createNewDesignAction_);\r\n\r\n                        // Add New System Design action only if the component contains hierarchical HW views.\r\n                        if (!component->getHierViews().isEmpty())\r\n                        {\r\n                            menuNew->addAction(createNewSystemDesignAction_);\r\n                        }\r\n                    }\r\n\r\n                    for (QSharedPointer<View> view : *component->getViews())\r\n                    {\r\n                        VLNV reference = component->getModel()->getHierRef(view->name());\r\n\r\n                        QSharedPointer<const Document> document = handler_->getModelReadOnly(reference);\r\n\r\n                        if (document && document->getImplementation() == KactusAttribute::SW)\r\n                        {\r\n                            menu.addAction(openSWDesignAction_);\r\n                            break;\r\n                        }\r\n                    }\r\n\r\n                    menu.addSeparator();\r\n\r\n                    menuNew->addAction(createNewSWDesignAction_);\r\n                    menu.addMenu(menuNew);\r\n                }\r\n            }\r\n\r\n            else if (documentType == VLNV::ABSTRACTIONDEFINITION)\r\n            {\r\n                menu.addAction(openBusAction_);\r\n            }\r\n\r\n            else if (documentType == VLNV::BUSDEFINITION)\r\n            {\r\n                menu.addAction(openBusAction_);\r\n                menu.addSeparator();\r\n\r\n                QMenu* menuNew = menu.addMenu(tr(\"Add\"));\r\n                menuNew->addAction(addSignalsAction_);\r\n                menu.addMenu(menuNew);\r\n            }\r\n\r\n            else if (documentType == VLNV::CATALOG)\r\n            {\r\n                menu.addAction(openCatalogAction_);\r\n            }\r\n\r\n            else if (documentType == VLNV::COMDEFINITION)\r\n            {\r\n                menu.addAction(openComDefAction_);\r\n            }\r\n\r\n            else if (documentType == VLNV::APIDEFINITION)\r\n            {\r\n                menu.addAction(openApiDefAction_);\r\n            }\r\n        }\r\n\r\n        menu.addSeparator();\r\n\r\n        if (!handler_->isValid(vlnv))\r\n        {\r\n            menu.addAction(showErrorsAction_);\r\n        }\r\n\r\n        menu.addAction(openContainingFolderAction_);\r\n\t\tmenu.addAction(openXmlAction_);\r\n\t}\r\n\r\n\tmenu.addAction(exportAction_);\r\n\tmenu.addAction(deleteAction_);\r\n\r\n    menu.addSeparator();\r\n    if (model()->rowCount(current) > 0)\r\n    {\r\n        menu.addAction(expandChilds_);\r\n        menu.addAction(collapseChilds_);\r\n    }\r\n    menu.addAction(expandAllAction_);\r\n    menu.addAction(collapseAllAction_);\r\n\r\n\tmenu.exec(event->globalPos());\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LibraryTreeView::setupSystemActionsForContextMenu()\r\n//-----------------------------------------------------------------------------\r\nvoid LibraryTreeView::setupSystemActionsForContextMenu(QSharedPointer<Component const> component, QMenu& menu)\r\n{\r\n\tauto systemViews = component->getSystemViewNames();\r\n\tfor (auto viewName : systemViews)\r\n\t{\r\n\t\topenSystemMenu_->addAction(new QAction(viewName, openSystemMenu_));\r\n\t}\r\n\r\n\tif (systemViews.count() == 1)\r\n\t{\r\n\t\tmenu.addAction(openSystemAction_);\r\n\t\tconnect(openSystemAction_, SIGNAL(triggered()), openSystemMenu_->actions().first(), SLOT(trigger()));\r\n\t}\r\n\telse\r\n\t{\r\n\t\tmenu.addMenu(openSystemMenu_);\r\n\t}\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LibraryTreeView::onDeleteAction()\r\n//-----------------------------------------------------------------------------\r\nvoid LibraryTreeView::onDeleteAction()\r\n{\t\r\n\temit deleteItem(filter_->mapToSource(currentIndex()));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LibraryTreeView::onExportAction()\r\n//-----------------------------------------------------------------------------\r\nvoid LibraryTreeView::onExportAction()\r\n{\r\n\temit exportItem(filter_->mapToSource(currentIndex()));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LibraryTreeView::mouseDoubleClickEvent()\r\n//-----------------------------------------------------------------------------\r\nvoid LibraryTreeView::mouseDoubleClickEvent(QMouseEvent* event)\r\n{\r\n\t// accept the event so it is not passed forwards\r\n\tevent->accept();\r\n\r\n\tQModelIndex current = currentIndex();\r\n\tif (!current.isValid())\r\n    {\r\n\t\treturn;\r\n\t}\r\n\r\n\temit openComponent(filter_->mapToSource(current));\r\n\r\n\t// let the default handler process the event\r\n\tQTreeView::mouseDoubleClickEvent(event);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LibraryTreeView::mousePressEvent()\r\n//-----------------------------------------------------------------------------\r\nvoid LibraryTreeView::mousePressEvent(QMouseEvent* event)\r\n{\r\n\tstartPos_ = event->pos();\r\n\tQModelIndex index = indexAt(startPos_);\r\n\r\n    if (event->button() == Qt::LeftButton)\r\n    {\r\n        dragIndex_ = filter_->mapToSource(index);\r\n    }\r\n\r\n\tsetCurrentIndex(index);\r\n\r\n    bool previouslyExpanded = isExpanded(index);\r\n    QTreeView::mousePressEvent(event);\r\n\r\n    // Change expand state if the click did not change it otherwise.\r\n    if (event->button() == Qt::LeftButton && index.isValid() && (isExpanded(index) == previouslyExpanded))\r\n    {\r\n        setExpanded(index, !previouslyExpanded);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LibraryTreeView::mouseReleaseEvent()\r\n//-----------------------------------------------------------------------------\r\nvoid LibraryTreeView::mouseReleaseEvent(QMouseEvent* event)\r\n{\r\n\t// find the clicked index\r\n\tQModelIndex index = indexAt(event->pos());\r\n\tif (index.isValid())\r\n    {\r\n\t\tQModelIndex sourceIndex = filter_->mapToSource(index);\r\n\t\tLibraryItem* item = static_cast<LibraryItem*>(sourceIndex.internalPointer());\r\n\r\n\t\t// if item contains a single vlnv\r\n        VLNV vlnv = item->getVLNV();\r\n\t\tif (vlnv.isValid())\r\n        {\r\n\t\t\temit itemSelected(vlnv);\r\n\t\t}\r\n\t}\r\n\r\n\tQTreeView::mouseReleaseEvent(event);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LibraryTreeView::mouseMoveEvent()\r\n//-----------------------------------------------------------------------------\r\nvoid LibraryTreeView::mouseMoveEvent(QMouseEvent* event)\r\n{\r\n\t// if left mouse button is pressed down\r\n\tif (event->buttons() & Qt::LeftButton)\r\n    {\r\n\t\tint dragDistance = (event->pos() - startPos_).manhattanLength();\r\n\r\n\t\t// make sure the drag distance is large enough to start the drag.\r\n\t\tif (dragDistance >= QApplication::startDragDistance())\r\n        {\r\n\t\t\tLibraryItem* item = static_cast<LibraryItem*>(dragIndex_.internalPointer());\r\n\r\n            if (item != 0)\r\n            {\r\n\t\t\t    VLNV vlnv = item->getVLNV();\r\n    \t\t\t\r\n\t\t\t    // if vlnv is valid\r\n\t\t\t    if (vlnv.isValid())\r\n                {\r\n\t\t\t\t    QMimeData* mimeData = new QMimeData;\r\n\t\t\t\t    mimeData->setImageData(QVariant::fromValue(vlnv));\r\n\r\n                    QDrag* drag = new QDrag(this);\r\n\t\t\t\t    drag->setMimeData(mimeData);\r\n\t\t\t\t    drag->exec(Qt::MoveAction | Qt::CopyAction | Qt::LinkAction);\r\n\t\t\t    }\r\n            }\r\n\t\t}\r\n\t}\r\n\tQTreeView::mouseMoveEvent(event);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LibraryTreeView::setCurrentIndex()\r\n//-----------------------------------------------------------------------------\r\nvoid LibraryTreeView::setCurrentIndex(QModelIndex const& index)\r\n{\r\n\t// Expand the tree to full length all the way from the root.\r\n\tQModelIndex temp = index;\r\n\r\n\twhile (temp.parent().isValid())\r\n    {\r\n\t\ttemp = temp.parent();\r\n\t\texpand(temp);\r\n\t}\r\n\r\n\tQTreeView::setCurrentIndex(index);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LibraryTreeView::onOpenDesign()\r\n//-----------------------------------------------------------------------------\r\nvoid LibraryTreeView::onOpenDesign(QAction* viewAction)\r\n{\r\n\temit openDesign(filter_->mapToSource(currentIndex()), viewAction->text());\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LibraryTreeView::onOpenSWDesign()\r\n//-----------------------------------------------------------------------------\r\nvoid LibraryTreeView::onOpenSWDesign()\r\n{\r\n    emit openSWDesign(filter_->mapToSource(currentIndex()));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: librarytreeview::onOpenMemoryDesign()\r\n//-----------------------------------------------------------------------------\r\nvoid LibraryTreeView::onOpenMemoryDesign(QAction* viewAction)\r\n{\r\n    emit openMemoryDesign(filter_->mapToSource(currentIndex()), viewAction->text());\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LibraryTreeView::onOpenSystemDesign()\r\n//-----------------------------------------------------------------------------\r\nvoid LibraryTreeView::onOpenSystemDesign(QAction* viewAction)\r\n{\r\n\temit openSystemDesign(filter_->mapToSource(currentIndex()), viewAction->text());\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LibraryTreeView::onOpenComponent()\r\n//-----------------------------------------------------------------------------\r\nvoid LibraryTreeView::onOpenComponent()\r\n{\r\n\temit openComponent(filter_->mapToSource(currentIndex()));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LibraryTreeView::onCreateDesign()\r\n//-----------------------------------------------------------------------------\r\nvoid LibraryTreeView::onCreateDesign()\r\n{\r\n\temit createNewDesign(filter_->mapToSource(currentIndex()));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LibraryTreeView::onCreateSWDesign()\r\n//-----------------------------------------------------------------------------\r\nvoid LibraryTreeView::onCreateSWDesign()\r\n{\r\n    emit createNewSWDesign(filter_->mapToSource(currentIndex()));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LibraryTreeView::onCreateSystemDesign()\r\n//-----------------------------------------------------------------------------\r\nvoid LibraryTreeView::onCreateSystemDesign()\r\n{\r\n    emit createNewSystemDesign(filter_->mapToSource(currentIndex()));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LibraryTreeView::onOpenBus()\r\n//-----------------------------------------------------------------------------\r\nvoid LibraryTreeView::onOpenBus()\r\n{\r\n\temit openBus(filter_->mapToSource(currentIndex()));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LibraryTreeView::onOpenCatalog()\r\n//-----------------------------------------------------------------------------\r\nvoid LibraryTreeView::onOpenCatalog()\r\n{\r\n    emit openCatalog(filter_->mapToSource(currentIndex()));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LibraryTreeView::onCreateBus()\r\n//-----------------------------------------------------------------------------\r\nvoid LibraryTreeView::onCreateBus()\r\n{\r\n\temit createBus(filter_->mapToSource(currentIndex()));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LibraryTreeView::onAddSignals()\r\n//-----------------------------------------------------------------------------\r\nvoid LibraryTreeView::onAddSignals()\r\n{\r\n\temit createAbsDef(filter_->mapToSource(currentIndex()));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LibraryTreeView::onOpenComDef()\r\n//-----------------------------------------------------------------------------\r\nvoid LibraryTreeView::onOpenComDef()\r\n{\r\n    emit openComDef(filter_->mapToSource(currentIndex()));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LibraryTreeView::onOpenApiDef()\r\n//-----------------------------------------------------------------------------\r\nvoid LibraryTreeView::onOpenApiDef()\r\n{\r\n    emit openApiDef(filter_->mapToSource(currentIndex()));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LibraryTreeView::onShowErrors()\r\n//-----------------------------------------------------------------------------\r\nvoid LibraryTreeView::onShowErrors()\r\n{\r\n    emit showErrors(filter_->mapToSource(currentIndex()));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LibraryTreeView::onOpenXml()\r\n//-----------------------------------------------------------------------------\r\nvoid LibraryTreeView::onOpenXml()\r\n{\r\n\tQModelIndex index = filter_->mapToSource(currentIndex());\r\n\tLibraryItem* item = static_cast<LibraryItem*>(index.internalPointer());\r\n\t\r\n    VLNV vlnv = item->getVLNV();\r\n\tif (vlnv.isValid())\r\n    {\r\n\t\t// open the file in operating system's default editor\r\n\t\tQDesktopServices::openUrl(QUrl::fromLocalFile(handler_->getPath(vlnv)));\r\n\t}\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LibraryTreeView::onOpenContainingFolder()\r\n//-----------------------------------------------------------------------------\r\nvoid LibraryTreeView::onOpenContainingFolder()\r\n{\r\n    QModelIndex index = filter_->mapToSource(currentIndex());\r\n    LibraryItem* item = static_cast<LibraryItem*>(index.internalPointer());\r\n    \r\n    VLNV vlnv = item->getVLNV();\r\n    if (vlnv.isValid())\r\n    {\r\n        QString path = QFileInfo(handler_->getPath(vlnv)).absolutePath();\r\n\r\n        // Open the folder in the operating system's default file browser.\r\n        QDesktopServices::openUrl(QUrl::fromLocalFile(path));\r\n    }    \r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LibraryTreeView::onExpandBranches()\r\n//-----------------------------------------------------------------------------\r\nvoid LibraryTreeView::onExpandBranches()\r\n{\r\n    QModelIndex index = currentIndex();\r\n\r\n    setExpanded(index, true);\r\n    setChildrenExpandStates(index, true);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LibraryTreeView::onCollapseBranches()\r\n//-----------------------------------------------------------------------------\r\nvoid LibraryTreeView::onCollapseBranches()\r\n{\r\n    QModelIndex index = currentIndex();\r\n\r\n    setChildrenExpandStates(index, false);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LibraryTreeView::setChildrenExpandStates()\r\n//-----------------------------------------------------------------------------\r\nvoid LibraryTreeView::setChildrenExpandStates(QModelIndex index, bool expanded)\r\n{\r\n    if (index.isValid())\r\n    {\r\n        int childCount = model()->rowCount(index);\r\n        for (int i = 0; i < childCount; i++)\r\n        {\r\n            QModelIndex childIndex = model()->index(i, 0, index);\r\n            setExpanded(childIndex, expanded);\r\n            setChildrenExpandStates(childIndex, expanded);\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LibraryTreeView::setupActions()\r\n//-----------------------------------------------------------------------------\r\nvoid LibraryTreeView::setupActions()\r\n{\r\n    openHWDesignMenu_->setStatusTip(tr(\"Open a HW design\"));\r\n    openHWDesignMenu_->setToolTip(tr(\"Open a HW design\"));\r\n    connect(openHWDesignMenu_, SIGNAL(triggered(QAction*)),\tthis, SLOT(onOpenDesign(QAction*)), Qt::UniqueConnection);\r\n\r\n    openSWDesignAction_->setStatusTip(tr(\"Open a SW design\"));\r\n    openSWDesignAction_->setToolTip(tr(\"Open a SW design\"));\r\n    connect(openSWDesignAction_, SIGNAL(triggered()), this, SLOT(onOpenSWDesign()), Qt::UniqueConnection);\r\n\r\n    openMemoryDesignMenu_->setStatusTip(tr(\"Open a Memory design\"));\r\n    openMemoryDesignMenu_->setToolTip(tr(\"Open a Memory design\"));\r\n    connect(openMemoryDesignMenu_, SIGNAL(triggered(QAction*)),\tthis, SLOT(onOpenMemoryDesign(QAction*)),\r\n        Qt::UniqueConnection);\r\n\r\n    openComponentAction_->setStatusTip(tr(\"Open component editor\"));\r\n    openComponentAction_->setToolTip(tr(\"Open component editor\"));\r\n    connect(openComponentAction_, SIGNAL(triggered()), this, SLOT(onOpenComponent()), Qt::UniqueConnection);\r\n\r\n    createNewDesignAction_->setStatusTip(tr(\"Create new HW design\"));\r\n    createNewDesignAction_->setToolTip(tr(\"Create new HW design\"));\r\n    connect(createNewDesignAction_, SIGNAL(triggered()), this, SLOT(onCreateDesign()), Qt::UniqueConnection);\r\n\r\n    createNewSWDesignAction_->setStatusTip(tr(\"Create new SW design\"));\r\n    createNewSWDesignAction_->setToolTip(tr(\"Create new SW design\"));\r\n    connect(createNewSWDesignAction_, SIGNAL(triggered()), this, SLOT(onCreateSWDesign()), Qt::UniqueConnection);\r\n\r\n    createNewSystemDesignAction_->setStatusTip(tr(\"Create new system design\"));\r\n    createNewSystemDesignAction_->setToolTip(tr(\"Create new system design\"));\r\n    connect(createNewSystemDesignAction_, SIGNAL(triggered()),\r\n        this, SLOT(onCreateSystemDesign()), Qt::UniqueConnection);\r\n\r\n    deleteAction_->setStatusTip(tr(\"Delete item from the library\"));\r\n    deleteAction_->setToolTip(tr(\"Delete the item from the library\"));\r\n    connect(deleteAction_, SIGNAL(triggered()),\tthis, SLOT(onDeleteAction()), Qt::UniqueConnection);\r\n\r\n    exportAction_->setStatusTip(tr(\"Export item and it's sub-items to another location\"));\r\n    exportAction_->setToolTip(tr(\"Export item and it's sub-items to another location\"));\r\n    connect(exportAction_, SIGNAL(triggered()), this, SLOT(onExportAction()), Qt::UniqueConnection);\r\n\r\n    showErrorsAction_->setStatusTip(tr(\"Show all errors of the item\"));\r\n    showErrorsAction_->setToolTip(tr(\"Show all errors of the item\"));\r\n    connect(showErrorsAction_, SIGNAL(triggered()), this, SLOT(onShowErrors()), Qt::UniqueConnection);\r\n\r\n    openBusAction_->setStatusTip(tr(\"Open\"));\r\n    openBusAction_->setToolTip(tr(\"Open\"));\r\n    connect(openBusAction_, SIGNAL(triggered()), this, SLOT(onOpenBus()), Qt::UniqueConnection);\r\n\r\n    openCatalogAction_->setStatusTip(tr(\"Open a catalog\"));\r\n    openCatalogAction_->setToolTip(tr(\"Open a catalog\"));\r\n    connect(openCatalogAction_, SIGNAL(triggered()), this, SLOT(onOpenCatalog()), Qt::UniqueConnection);\r\n\r\n    addSignalsAction_->setStatusTip(tr(\"Create new abstraction definition for the bus\"));\r\n    addSignalsAction_->setToolTip(tr(\"Create new abstraction definition for the bus\"));\r\n    connect(addSignalsAction_, SIGNAL(triggered()),\tthis, SLOT(onAddSignals()), Qt::UniqueConnection);\r\n\r\n    openComDefAction_->setStatusTip(tr(\"Open\"));\r\n    openComDefAction_->setToolTip(tr(\"Open\"));\r\n    connect(openComDefAction_, SIGNAL(triggered()), this, SLOT(onOpenComDef()), Qt::UniqueConnection);\r\n\r\n    openApiDefAction_->setStatusTip(tr(\"Open\"));\r\n    openApiDefAction_->setToolTip(tr(\"Open\"));\r\n    connect(openApiDefAction_, SIGNAL(triggered()), this, SLOT(onOpenApiDef()), Qt::UniqueConnection);\r\n\r\n\topenSystemMenu_->setStatusTip(tr(\"Open a system design\"));\r\n    openSystemMenu_->setToolTip(tr(\"Open a system design\"));\r\n\tconnect(openSystemMenu_, SIGNAL(triggered(QAction*)), this, SLOT(onOpenSystemDesign(QAction*)), Qt::UniqueConnection);\r\n\r\n    connect(openXmlAction_, SIGNAL(triggered()), this, SLOT(onOpenXml()), Qt::UniqueConnection);\r\n\r\n    connect(openContainingFolderAction_, SIGNAL(triggered()),\r\n        this, SLOT(onOpenContainingFolder()), Qt::UniqueConnection);\r\n\r\n    connect(expandChilds_, SIGNAL(triggered()), this, SLOT(onExpandBranches()), Qt::UniqueConnection);\r\n\r\n    connect(collapseChilds_, SIGNAL(triggered()), this, SLOT(onCollapseBranches()), Qt::UniqueConnection);\r\n\r\n    connect(expandAllAction_, SIGNAL(triggered()), this, SLOT(expandAll()), Qt::UniqueConnection);\r\n\r\n    connect(collapseAllAction_, SIGNAL(triggered()), this, SLOT(collapseAll()), Qt::UniqueConnection);\r\n\r\n}\r\n"
  },
  {
    "path": "library/LibraryTreeView.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: librarytreeview.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Antti Kamppi\r\n// Date: 20.12.2010\r\n//\r\n// Description:\r\n// The widget to display the library in a tree.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef LIBRARYTREEVIEW_H\r\n#define LIBRARYTREEVIEW_H\r\n\r\n#include \"LibraryTreeFilter.h\"\r\n\r\n#include <common/views/ExpandingTreeView/ExpandingTreeView.h>\r\n\r\n#include <QTreeView>\r\n#include <QContextMenuEvent>\r\n#include <QAction>\r\n#include <QPoint>\r\n#include <QModelIndex>\r\n#include <QMouseEvent>\r\n\r\nclass LibraryInterface;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! The widget to display the library in a tree.\r\n//-----------------------------------------------------------------------------\r\nclass LibraryTreeView : public ExpandingTreeView\r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\r\n\t/*! The constructor\r\n\t* \r\n\t*    @param [in] handler  The instance that manages the library.\r\n\t*    @param [in] filter   The class that does the filtering for the view.\r\n\t*    @param [in] parent   The owner of this widget.\r\n\t*\r\n\t*/\r\n\tLibraryTreeView(LibraryInterface* handler, LibraryTreeFilter* filter, QWidget* parent = 0);\r\n\r\n\t//! The destructor.\r\n\tvirtual ~LibraryTreeView() = default;\r\n\r\nsignals:\r\n\r\n\t//! Open the selected hierarchical design\r\n\tvoid openDesign(QModelIndex const& index, QString const& viewName);\r\n\r\n\t//! Open the SW design of a component\r\n\tvoid openSWDesign(QModelIndex const& index);\r\n\r\n    //! Open the Memory design of a HW design.\r\n    void openMemoryDesign(QModelIndex const& index, QString const& viewName);\r\n\r\n\t//! Open the system design of a component\r\n\tvoid openSystemDesign(QModelIndex const& index, QString const& viewName);\r\n\r\n\t//! Open the given object in the component editor\r\n\tvoid openComponent(QModelIndex const& index);\r\n\r\n\t//! Create new design\r\n\tvoid createNewDesign(QModelIndex const& index);\r\n\r\n\t//! Create new SW design\r\n\tvoid createNewSWDesign(QModelIndex const& index);\r\n\r\n\t//! Create new system design\r\n\tvoid createNewSystemDesign(QModelIndex const& index);\r\n\r\n\t//! Delete the selected item\r\n\tvoid deleteItem(QModelIndex const& index);\r\n\r\n\t//! Export the selected item and it's sub-items.\r\n\tvoid exportItem(QModelIndex const& index);\r\n\r\n\t//! Shows errors about the selected item.\r\n\tvoid showErrors(QModelIndex const& index);\r\n\r\n\t//! Open bus definition in an editor\r\n\tvoid openBus(QModelIndex const& index);\r\n\r\n    //! Open catalog in an editor\r\n    void openCatalog(QModelIndex const& index);\r\n\r\n\t//! Open COM definition in an editor\r\n\tvoid openComDef(QModelIndex const& index);\r\n\r\n\t//! Open API definition in an editor\r\n\tvoid openApiDef(QModelIndex const& index);\r\n\r\n\t//! Create a new bus definition\r\n\tvoid createBus(QModelIndex const& index);\r\n\r\n\t//! Create a new abstraction definition for given bus def.\r\n\tvoid createAbsDef(QModelIndex const& index);\r\n\r\n\t//! A drag operation has been initiated.\r\n\tvoid dragInitiated(QModelIndex const& index);\r\n\r\n\t//! Emitted when a library item identifying single vlnv is selected.\r\n\tvoid itemSelected(const VLNV& vlnv);\r\n\r\n\t//! Send error message to user.\r\n\tvoid errorMessage(QString const& message);\r\n\r\n\t//! Send notification to user.\r\n\tvoid noticeMessage(QString const& message);\r\n\r\npublic slots:\r\n\r\n    //! Open a hierarchical component\r\n    void onOpenDesign(QAction* viewAction);\r\n\r\n    //! Open the SW design of a component\r\n    void onOpenSWDesign();\r\n\r\n    //! Open the Memory design of a HW design.\r\n    void onOpenMemoryDesign(QAction* viewAction);\r\n\r\n    //! Open the system design of a component\r\n\tvoid onOpenSystemDesign(QAction* viewAction);\r\n\r\n    //! Open component editor\r\n    void onOpenComponent();\r\n\r\n    //! Create new design\r\n    void onCreateDesign();\r\n\r\n    //! Create new SW design\r\n    void onCreateSWDesign();\r\n\r\n    //! Create new SW design\r\n    void onCreateSystemDesign();\r\n\r\n    //! Called when user selects \"Delete item\" in contextMenu\r\n    void onDeleteAction();\r\n\r\n    //! Called when user selects \"Export item and sub-items\" in contextMenu\r\n    void onExportAction();\r\n\r\n    //! Open bus.\r\n    void onOpenBus();\r\n\r\n    //! Open catalog.\r\n    void onOpenCatalog();\r\n\r\n    //! Open COM definition.\r\n    void onOpenComDef();\r\n\r\n    //! Open API definition.\r\n    void onOpenApiDef();\r\n\r\n    //! Create new bus.\r\n    void onCreateBus();\r\n\r\n    //! Create new abstraction definition for selected bus definition.\r\n    void onAddSignals();\r\n\r\n    /*! Set the index to be the current index and select and expand it.\r\n    *\r\n    *    @param [in] index Specified the index to be set as the current index.\r\n    */\r\n    virtual void setCurrentIndex(QModelIndex const& index);\r\n\r\n    //! Open the xml of the selected IP-Xact element.\r\n    void onOpenXml();\r\n\r\n    //! Opens the folder that contains the IP-XACT object.\r\n    void onOpenContainingFolder();\r\n\r\n    //! Called when the user chooses Show Errors from the context menu.\r\n    void onShowErrors();\r\n\r\nprotected:\r\n\r\n    //! The event handler for mouse double clicks\r\n    virtual void mouseDoubleClickEvent(QMouseEvent * event);\r\n\r\n    //! The event handler for mousePress events\r\n    virtual void mousePressEvent(QMouseEvent *event);\r\n\r\n    //! The event handler for mouseMove events\r\n    virtual void mouseMoveEvent(QMouseEvent *event);\r\n\r\n    //! The event handler for mouse release events\r\n    virtual void mouseReleaseEvent(QMouseEvent* event);\r\n\r\n    /*! Handler for the context menu events.\r\n    *\r\n    *    @param [in] event The contextMenuEvent to be handled.\r\n    */\r\n    virtual void contextMenuEvent(QContextMenuEvent* event);\r\n\r\nprivate slots:\r\n    \r\n    //! Called when all the children of the current index should be expanded.\r\n    void onExpandBranches();\r\n\r\n    //! Called when all the children of the current index should be collapsed.\r\n    void onCollapseBranches();\r\n\r\nprivate:\r\n\r\n    //! No assignment\r\n\tLibraryTreeView(const LibraryTreeView& other);\r\n\r\n\t//! No copying\r\n\tLibraryTreeView& operator=(const LibraryTreeView& other);\r\n\r\n    //! Expands/collapses all child indexes recursively.\r\n    void setChildrenExpandStates(QModelIndex index, bool expanded);\r\n\r\n    //! Set up the actions for the context menu\r\n    void setupActions();\r\n\r\n\t/*!\r\n\t *  Setup the system actions for a context menu.\r\n\t *\r\n\t *    @param [in] component\t\tThe component containing the system views.\r\n\t *    @param [in] menu\t\t\tThe context menu.\r\n\t */\r\n\tvoid setupSystemActionsForContextMenu(QSharedPointer<Component const> component, QMenu& menu);\r\n\r\n\t//! The instance that gives the xml objects.\r\n\tLibraryInterface* handler_;\r\n\r\n\t//! The filter that is used to transform model indexes \r\n\tLibraryTreeFilter* filter_;\r\n\r\n\t//! The starting position for drag\r\n\tQPoint startPos_;\r\n\r\n\t//! The index that is selected to be dragged\r\n\tQModelIndex dragIndex_;\r\n\r\n\t/**********************************************************************/\r\n\t// The actions for the contextMenu\r\n\r\n\t//! Open the hierarchical design of a component. Single action if only one view available, otherwise a menu.\r\n    QAction* openHWDesignAction_;\r\n\tQMenu* openHWDesignMenu_;\r\n\r\n\t//! Open the SW design of a component\r\n\tQAction* openSWDesignAction_;\r\n\r\n    //! Action for opening a memory design. Single action if only one view is available, otherwise a menu.\r\n    QAction* openMemoryDesignAction_;\r\n    QMenu* openMemoryDesignMenu_;\r\n\r\n\t//! Open the component editor\r\n\tQAction* openComponentAction_;\r\n\r\n\t//! Create new design for a component\r\n\tQAction* createNewDesignAction_;\r\n\r\n\t//! Create new SW design for a component.\r\n\tQAction* createNewSWDesignAction_;\r\n\r\n\t//! Create new system design for a component.\r\n\tQAction* createNewSystemDesignAction_;\r\n\r\n\t//! Delete the item from the library\r\n\tQAction* deleteAction_;\r\n\r\n\t//! Export the item(s) to a new location in file system\r\n\tQAction* exportAction_;\r\n\r\n\t//! Show errors about the item.\r\n\tQAction* showErrorsAction_;\r\n\r\n\t//! Open a bus definition\r\n\tQAction* openBusAction_;\r\n   \r\n    //! Open a catalog.\r\n    QAction* openCatalogAction_;\r\n\r\n\t//! Create new abstraction definition for bus definition.\r\n\tQAction* addSignalsAction_;\r\n\r\n\t//! Open a COM definition\r\n\tQAction* openComDefAction_;\r\n\r\n\t//! Open an API definition\r\n\tQAction* openApiDefAction_;\r\n\r\n\t//! Open an existing system for editing.\r\n\tQAction* openSystemAction_;\r\n\tQMenu* openSystemMenu_;\r\n\r\n\t//! Open the xml file to be viewed by the user.\r\n\tQAction* openXmlAction_;\r\n\r\n    //! Action to open the containing folder.\r\n    QAction* openContainingFolderAction_;\r\n\r\n    //! Action for recursively expand all child indexes of the selected index.\r\n    QAction* expandChilds_;\r\n\r\n    //! Action for recursively collapse all child indexes of the selected index.\r\n    QAction* collapseChilds_;\r\n\r\n    //! Action to expand the whole library tree.\r\n    QAction* expandAllAction_;\r\n\r\n    //! Action to collapse the whole library tree\r\n    QAction* collapseAllAction_;\r\n};\r\n\r\n#endif // LIBRARYTREEVIEW_H\r\n"
  },
  {
    "path": "library/LibraryTreeWidget.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: librarytreewidget.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Antti Kamppi\r\n// Date: 20.12.2010\r\n//\r\n// Description:\r\n// LibraryTreeWidget is the widget that displays the library content in a tree.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"LibraryTreeWidget.h\"\r\n#include \"LibraryTreeView.h\"\r\n#include \"LibraryTreeModel.h\"\r\n\r\n#include <QObject>\r\n#include <QVBoxLayout>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LibraryTreeWidget::LibraryTreeWidget()\r\n//-----------------------------------------------------------------------------\r\nLibraryTreeWidget::LibraryTreeWidget(LibraryInterface* handler, LibraryTreeModel* dataModel, QWidget* parent):\r\nQWidget(parent),\r\n    filter_(new LibraryTreeFilter(handler, this)),\r\n    view_(handler, filter_, this),\r\n    dataModel_(dataModel)\r\n{\r\n    filter_->setSourceModel(dataModel);\r\n    filter_->setRecursiveFilteringEnabled(true);\r\n\r\n\t// set view to use LibraryTreeFilter as source model\r\n\tview_.setModel(filter_);\r\n\r\n\t// the layout to manage the visible items in the widget\r\n\tQVBoxLayout* layout = new QVBoxLayout(this);\r\n\tlayout->addWidget(&view_);\r\n\tlayout->setContentsMargins(0, 0, 0, 0);\r\n\r\n\tsetupConnections(dataModel);\r\n\r\n\tview_.sortByColumn(0, Qt::AscendingOrder);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LibraryTreeWidget::~LibraryTreeWidget()\r\n//-----------------------------------------------------------------------------\r\nLibraryTreeWidget::~LibraryTreeWidget()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LibraryTreeWidget::selectItem()\r\n//-----------------------------------------------------------------------------\r\nvoid LibraryTreeWidget::selectItem(VLNV const& vlnv)\r\n{\t\r\n\t// if vlnv is not valid\r\n\tif (!vlnv.isValid())\r\n    {\r\n\t\tview_.clearSelection();\r\n\t}\r\n\t\r\n\t// find the item to be selected\r\n\tLibraryItem* item = dataModel_->getRoot()->findItem(vlnv);\r\n\r\n\t// If item is not found then print an error message telling user that library is corrupted.\r\n\tif (!item)\r\n    {\r\n\t\temit errorMessage(tr(\"Selected item was not found, library is corrupted.\"));\r\n\t\treturn;\r\n\t}\r\n\r\n\t// create an index to the item\r\n\tQModelIndex filteredIndex = filter_->mapFromSource(dataModel_->index(item));\r\n\t\r\n\t// tell view to select the item\r\n\tview_.setCurrentIndex(filteredIndex);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LibraryTreeWidget::getFilter()\r\n//-----------------------------------------------------------------------------\r\nLibraryFilter* LibraryTreeWidget::getFilter() const\r\n{\r\n    return filter_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LibraryTreeWidget::onSearchTextChanged()\r\n//-----------------------------------------------------------------------------\r\nvoid LibraryTreeWidget::onSearchTextChanged(QString const& text)\r\n{\r\n    filter_->setFilterRegularExpression(QRegularExpression(text, QRegularExpression::CaseInsensitiveOption));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LibraryTreeWidget::setupConnections()\r\n//-----------------------------------------------------------------------------\r\nvoid LibraryTreeWidget::setupConnections(LibraryTreeModel* dataModel)\r\n{\r\n    connect(&view_, SIGNAL(errorMessage(QString const&)),\r\n        this, SIGNAL(errorMessage(QString const&)), Qt::UniqueConnection);\r\n\r\n    connect(&view_, SIGNAL(noticeMessage(QString const&)),\r\n        this, SIGNAL(noticeMessage(QString const&)), Qt::UniqueConnection);\r\n\r\n    // connect the view to the tree model\r\n    connect(&view_, SIGNAL(openComponent(QModelIndex const&)),\r\n        dataModel, SLOT(onOpenDocument(QModelIndex const&)), Qt::UniqueConnection);\r\n\r\n    connect(&view_, SIGNAL(openDesign(QModelIndex const&, QString const&)),\r\n        dataModel, SLOT(onOpenDesign(QModelIndex const&, QString const&)), Qt::UniqueConnection);\r\n\r\n    connect(&view_, SIGNAL(openMemoryDesign(const QModelIndex&, QString const&)),\r\n        dataModel, SLOT(onOpenMemoryDesign(const QModelIndex&, QString const&)), Qt::UniqueConnection);\r\n\r\n    connect(&view_, SIGNAL(openSWDesign(QModelIndex const&)),\r\n        dataModel, SLOT(onOpenSWDesign(QModelIndex const&)), Qt::UniqueConnection);\r\n\r\n    connect(&view_, SIGNAL(openSystemDesign(QModelIndex const&, QString const&)), dataModel, SLOT(onOpenSystemDesign(QModelIndex const&, QString const&)), Qt::UniqueConnection);\r\n\r\n    connect(&view_, SIGNAL(createNewDesign(QModelIndex const&)),\r\n        dataModel, SLOT(onCreateNewDesign(QModelIndex const&)), Qt::UniqueConnection);\r\n\r\n    connect(&view_, SIGNAL(createNewSWDesign(QModelIndex const&)),\r\n        dataModel, SLOT(onCreateNewSWDesign(QModelIndex const&)), Qt::UniqueConnection);\r\n\r\n    connect(&view_, SIGNAL(createNewSystemDesign(QModelIndex const&)),\r\n        dataModel, SLOT(onCreateNewSystemDesign(QModelIndex const&)), Qt::UniqueConnection);\r\n\r\n    connect(&view_, SIGNAL(openBus(QModelIndex const&)),\r\n        dataModel, SLOT(onOpenDocument(QModelIndex const&)), Qt::UniqueConnection);\r\n\r\n    connect(&view_, SIGNAL(openCatalog(QModelIndex const&)),\r\n        dataModel, SLOT(onOpenDocument(QModelIndex const&)), Qt::UniqueConnection);\r\n\r\n    connect(&view_, SIGNAL(createAbsDef(QModelIndex const&)),\r\n        dataModel, SLOT(onCreateAbsDef(QModelIndex const&)), Qt::UniqueConnection);\r\n\r\n    connect(&view_, SIGNAL(openComDef(QModelIndex const&)),\r\n        dataModel, SLOT(onOpenDocument(QModelIndex const&)), Qt::UniqueConnection);\r\n\r\n    connect(&view_, SIGNAL(openApiDef(QModelIndex const&)),\r\n        dataModel, SLOT(onOpenDocument(QModelIndex const&)), Qt::UniqueConnection);\r\n\r\n    connect(&view_, SIGNAL(deleteItem(QModelIndex const&)),\r\n        dataModel, SLOT(onDeleteItem(QModelIndex const&)), Qt::UniqueConnection);\r\n\r\n    connect(&view_, SIGNAL(exportItem(QModelIndex const&)),\r\n        dataModel, SLOT(onExportItem(QModelIndex const&)), Qt::UniqueConnection);\r\n\r\n    connect(&view_, SIGNAL(showErrors(QModelIndex const&)),\r\n        dataModel, SLOT(onShowErrors(QModelIndex const&)), Qt::UniqueConnection);\r\n\r\n    connect(&view_, SIGNAL(itemSelected(const VLNV&)),\r\n        this, SIGNAL(itemSelected(const VLNV&)), Qt::UniqueConnection);\r\n\r\n    connect(dataModel, SIGNAL(invalidateFilter()), filter_, SLOT(invalidate()), Qt::UniqueConnection);\r\n}\r\n"
  },
  {
    "path": "library/LibraryTreeWidget.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: librarytreewidget.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Antti Kamppi\r\n// Date: 20.12.2010\r\n//\r\n// Description:\r\n// LibraryTreeWidget is the widget that displays the library content in a tree.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef LIBRARYTREEWIDGET_H\r\n#define LIBRARYTREEWIDGET_H\r\n\r\n#include \"LibraryTreeView.h\"\r\n\r\n#include <IPXACTmodels/common/VLNV.h>\r\n\r\n#include <QWidget>\r\n\r\nclass LibraryTreeModel;\r\nclass LibraryInterface;\r\nclass LibraryTreeFilter;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! LibraryTreeWidget is the widget that displays the library content in a tree.\r\n//-----------------------------------------------------------------------------\r\nclass LibraryTreeWidget : public QWidget\r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\r\n\t/*! The constructor\r\n\t *\r\n\t *  Constructs the library tree view and the filter model for the tree view\r\n\t *  and connects the view and filter model to the dataModel.\r\n\t * \r\n\t *    @param [in] handler    The instance that manages the library.\r\n\t *    @param [in] dataModel  The dataModel instance that holds the data to be displayed in the view.\r\n\t *    @param [in] parent     The owner of this widget.\r\n\t */\r\n    LibraryTreeWidget(LibraryInterface* handler, LibraryTreeModel* dataModel, QWidget* parent);\r\n\r\n    //! The destructor\r\n    virtual ~LibraryTreeWidget();\r\n\r\n\t/*! Select the library item that is identified by the vlnv.\r\n\t *\r\n\t *    @param [in] vlnv The vlnv that identifies the libraryItem to select.\r\n\t*/\r\n\tvoid selectItem(VLNV const& vlnv);\r\n\r\n    /*!\r\n     *  Gets the filter for the tree model.\r\n     *\r\n     *    @return The filter in use.\r\n     */\r\n    LibraryFilter* getFilter() const;\r\n\r\nsignals:\r\n\r\n\t//! Print a notification to the user\r\n\tvoid noticeMessage(const QString& msg);\r\n\r\n\t//! Print an error message to the user\r\n\tvoid errorMessage(const QString& msg);\r\n\r\n\t//! Emitted when an item identifying unique vlnv is selected.\r\n\tvoid itemSelected(const VLNV& vlnv);\r\n\r\npublic slots:\r\n\r\n    void onSearchTextChanged(QString const& text);\r\n\r\nprivate:\r\n\r\n\t//! No copying.\r\n\tLibraryTreeWidget(const LibraryTreeWidget& other);\r\n\r\n\t//! No assignment.\r\n\tLibraryTreeWidget& operator=(const LibraryTreeWidget& other);\r\n\r\n\t//! Set up the connections between child widgets.\r\n\tvoid setupConnections(LibraryTreeModel* dataModel);\r\n   \r\n    //! The filter between the view and data model.\r\n    LibraryTreeFilter* filter_;\r\n\r\n\t//! The table view to display the search results.\r\n\tLibraryTreeView view_;\r\n\r\n\t//! The model for the filter.\r\n\tLibraryTreeModel* dataModel_;\r\n\r\n};\r\n\r\n#endif // LIBRARYTREEWIDGET_H\r\n"
  },
  {
    "path": "library/LibraryUtils.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: LibraryUtils.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Joni-Matti Maatta\r\n// Date: 22.6.2011\r\n//\r\n// Description:\r\n// Library utility functions.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"LibraryUtils.h\"\r\n\r\n#include <IPXACTmodels/Component/Component.h>\r\n#include <IPXACTmodels/Design/Design.h>\r\n#include <IPXACTmodels/DesignConfiguration/DesignConfiguration.h>\r\n\r\n#include <IPXACTmodels/common/VLNV.h>\r\n\r\n#include <KactusAPI/include/LibraryInterface.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: getDesign()\r\n//-----------------------------------------------------------------------------\r\nbool getDesign(LibraryInterface* lh, VLNV& designVLNV,\r\n               QSharedPointer<Design const>& design, QSharedPointer<DesignConfiguration const>& designConf)\r\n{\r\n    designVLNV.setType(lh->getDocumentType(designVLNV));\r\n\r\n    if (!designVLNV.isValid())\r\n    {\r\n        return false;\r\n    }\r\n\r\n    // Check if the component contains a direct reference to a design.\r\n    if (designVLNV.getType() == VLNV::DESIGN)\r\n    {\r\n        design = lh->getModelReadOnly(designVLNV).staticCast<Design const>();\r\n    }\r\n    // Otherwise check if the component had reference to a design configuration.\r\n    else if (designVLNV.getType() == VLNV::DESIGNCONFIGURATION)\r\n    {\r\n        designConf = lh->getModelReadOnly(designVLNV).staticCast<DesignConfiguration const>();\r\n\r\n        designVLNV = designConf->getDesignRef();\r\n        if (designVLNV.isValid())\r\n        {\r\n            design = lh->getModelReadOnly(designVLNV).staticCast<Design const>();\r\n        }\r\n\r\n        // If design configuration did not contain a reference to a design.\r\n        if (!design)\r\n        {\r\n            return false;\r\n        }\r\n    }\r\n    // If referenced view was not found.\r\n    else\r\n    {\r\n        return false;\r\n    }\r\n\r\n    return true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: getConnectionIndex()\r\n//-----------------------------------------------------------------------------\r\nint getConnectionIndex(QList<Interconnection> const& connections, QString const& name)\r\n{\r\n    // Search for a match in the list.\r\n    for (int i = 0; i < connections.size(); ++i)\r\n    {\r\n        if (connections.at(i).name() == name)\r\n        {\r\n            return i;\r\n        }\r\n    }\r\n\r\n    return -1;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: getInstanceIndex()\r\n//-----------------------------------------------------------------------------\r\nint getInstanceIndex(QList<QSharedPointer<ComponentInstance> > instances, QString const& instanceName)\r\n{\r\n    // Search for a match in the list.\r\n    for (int i = 0; i < instances.size(); ++i)\r\n    {\r\n        if (instances.at(i)->getInstanceName() == instanceName)\r\n        {\r\n            return i;\r\n        }\r\n    }\r\n\r\n    return -1;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: getInstanceIndexByUUID()\r\n//-----------------------------------------------------------------------------\r\nint getInstanceIndexByUUID(QList<QSharedPointer<ComponentInstance> > instances, QString const& uuid)\r\n{\r\n    // Search for a match in the list.\r\n    for (int i = 0; i < instances.size(); ++i)\r\n    {\r\n        if (instances.at(i)->getUuid() == uuid)\r\n        {\r\n            return i;\r\n        }\r\n    }\r\n\r\n    return -1;\r\n}\r\n\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: getInstanceIndex()\r\n//-----------------------------------------------------------------------------\r\nint getInstanceIndex(QList<QSharedPointer<ComponentInstance> > instances, QString const& importRef,\r\n                     QString const& mapping)\r\n{\r\n    // Search for a match in the list.\r\n    for (int i = 0; i < instances.size(); ++i)\r\n    {\r\n        if (instances[i]->getImportRef() == importRef && instances[i]->getMapping() == mapping)\r\n        {\r\n            return i;\r\n        }\r\n    }\r\n\r\n    return -1;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: parseProgrammableElements()\r\n//-----------------------------------------------------------------------------\r\nvoid parseProgrammableElementsV2(LibraryInterface* lh, VLNV designVLNV,\r\n                                 QList<QSharedPointer<ComponentInstance> >& elements)\r\n{\r\n    QSharedPointer<Design const> compDesign;\r\n    QSharedPointer<DesignConfiguration const> designConf;\r\n\r\n    // The received type is always VLNV::DESIGN so it must be asked from the\r\n    // library handler to make sure the type is correct.\r\n    designVLNV.setType(lh->getDocumentType(designVLNV));\r\n\r\n    if (!getDesign(lh, designVLNV, compDesign, designConf))\r\n    {\r\n        return;\r\n    }\r\n\r\n    // Go through all component instances and search for programmable elements.\r\n    foreach (QSharedPointer<ComponentInstance> instance, *compDesign->getComponentInstances())\r\n    {\r\n        if (!instance->isDraft())\r\n        {\r\n            QSharedPointer<Document> libComp = lh->getModel(*instance->getComponentRef());\r\n            QSharedPointer<Component> childComp = libComp.staticCast<Component>();\r\n\r\n            if (childComp)\r\n            {\r\n                // Add the component to the system design only if it is a leaf component and has a CPU\r\n                // or COM interfaces.\r\n                if ((!childComp->isHierarchical() && childComp->isCpu()) || !childComp->getComInterfaces().isEmpty())\r\n                {\r\n                    QSharedPointer<ComponentInstance> copy(new ComponentInstance(*instance));\r\n\r\n                    // Determine a unique name for the instance->\r\n                    QString instanceName = instance->getInstanceName();\r\n                    int runningNumber = 1;\r\n\r\n                    while (getInstanceIndex(elements, instanceName) != -1)\r\n                    {\r\n                        instanceName = instance->getInstanceName() + \"_\" + QString::number(runningNumber);\r\n                    }\r\n\r\n                    copy->setInstanceName(instanceName);\r\n                    elements.append(copy);\r\n                }\r\n                else\r\n                {\r\n                    QString view = \"\";\r\n\r\n                    if (designConf != 0)\r\n                    {\r\n                        view = designConf->getActiveView(instance->getInstanceName());\r\n                    }\r\n\r\n                    // Otherwise parse the hierarchical components recursively.\r\n                    parseProgrammableElementsV2(lh, childComp->getHierRef(view), elements);\r\n                }\r\n            }\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: addNewInstances()\r\n//-----------------------------------------------------------------------------\r\nvoid addNewInstancesV2(LibraryInterface* lh, QList<QSharedPointer<ComponentInstance> > elements,\r\n                       QSharedPointer<QList<QSharedPointer<ComponentInstance> > > hwInstances,\r\n                       QList<QSharedPointer<ComponentInstance> > swInstances,\r\n                       QList<QSharedPointer<ApiInterconnection> > apiDependencies)\r\n{\r\n    for (QSharedPointer<ComponentInstance> element : elements)\r\n    {\r\n        // Duplicate the component instance and set its import reference.\r\n        QSharedPointer<ComponentInstance> instance(new ComponentInstance(element->getInstanceName(), \r\n            element->getComponentRef()));\r\n\r\n        instance->setDisplayName(element->displayName());\r\n        instance->setDescription(element->description()),\r\n        instance->setUuid(element->getUuid());\r\n        instance->setImported(true);\r\n\r\n        // Import SW components from SW design if found.\r\n        QSharedPointer<Document const> libComp = lh->getModelReadOnly(*instance->getComponentRef());\r\n        QSharedPointer<Component const> component = libComp.staticCast<Component const>();\r\n\r\n        // Only hardware components are applicable in this loop.\r\n        if (component->getImplementation() != KactusAttribute::HW)\r\n        {\r\n            continue;\r\n        }\r\n\r\n        // Add the newly created HW component to the list of HW instances.\r\n        hwInstances->append(instance);\r\n\r\n        if (component != 0 && component->hasViews())\r\n        {\r\n            QSharedPointer<Design const> swDesign;\r\n            QSharedPointer<DesignConfiguration const> swDesignConf;\r\n\r\n            VLNV designVLNV = component->getHierRef();\r\n            if (!getDesign(lh, designVLNV, swDesign, swDesignConf))\r\n            {\r\n                continue;\r\n            }\r\n\r\n            for (QSharedPointer<ComponentInstance> instance : *swDesign->getComponentInstances())\r\n            {\r\n                QSharedPointer<ConfigurableVLNVReference> ref = instance->getComponentRef();\r\n\r\n                QSharedPointer<Document> componentDoc = lh->getModel(*ref.data());\r\n                QSharedPointer<Component> swComponent = componentDoc.dynamicCast<Component>();\r\n\r\n                // Only software components are applicable in this loop.\r\n                if (!instance->isDraft() &&\r\n                    (!swComponent || swComponent->getImplementation() != KactusAttribute::SW))\r\n                {\r\n                    continue;\r\n                }\r\n\r\n                instance->setPosition(QPointF());\r\n                instance->setImported(true);\r\n                instance->setMapping(element->getUuid());\r\n                swInstances.append(instance);\r\n            }\r\n\r\n            for (QSharedPointer<ApiInterconnection> dependency : swDesign->getApiConnections())\r\n            {\r\n                apiDependencies.append(dependency);\r\n            }\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: generateSystemDesign()\r\n//-----------------------------------------------------------------------------\r\nvoid generateSystemDesignV2(LibraryInterface* lh, VLNV const& designVLNV, Design& sysDesign)\r\n{\r\n    // Parse all programmable elements from the HW component.\r\n    QList<QSharedPointer<ComponentInstance> > elements;\r\n    parseProgrammableElementsV2(lh, designVLNV, elements);\r\n\r\n    // Add them as instances to the system design.\r\n    QSharedPointer<QList<QSharedPointer<ComponentInstance> > > \r\n        hwInstances(new QList<QSharedPointer<ComponentInstance> >());\r\n    QList<QSharedPointer<ComponentInstance> > swInstances;\r\n    QList<QSharedPointer<ApiInterconnection> > apiDependencies;\r\n    addNewInstancesV2(lh, elements, hwInstances, swInstances, apiDependencies);\r\n\r\n    sysDesign.setComponentInstances(hwInstances);\r\n    sysDesign.getComponentInstances()->append(swInstances);\r\n    sysDesign.setApiConnections(apiDependencies);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: getMatchingApiDependency()\r\n//-----------------------------------------------------------------------------\r\nint getMatchingApiDependency(QList<QSharedPointer<ApiInterconnection> > apiDependencies,\r\n                             QList<QSharedPointer<ComponentInstance> > swInstances,\r\n                             QSharedPointer<ApiInterconnection> dependency, QString const& mapping) \r\n{\r\n    int index = -1;\r\n\r\n    // Retrieve the full names for the connected components in the system design.\r\n    QString startComponentReference = dependency->getStartInterface()->getComponentReference();\r\n    QString startApiReference = dependency->getStartInterface()->getBusReference();\r\n    int instanceIndex1 = getInstanceIndex(swInstances, startComponentReference, mapping);\r\n\r\n    if (instanceIndex1 == -1)\r\n    {\r\n        return -1;\r\n    }\r\n    \r\n    int instanceIndex2 = -1;\r\n\r\n    QString endComponentReference = \"\";\r\n    QString endApiReference = dependency->getEndInterface()->getBusReference();\r\n    QSharedPointer<ActiveInterface> activeEndInterface =\r\n        dependency->getEndInterface().dynamicCast<ActiveInterface>();\r\n    if (activeEndInterface)\r\n    {\r\n        instanceIndex2 = getInstanceIndex(swInstances, endComponentReference, mapping);\r\n    }\r\n\r\n    if (instanceIndex2 == -1)\r\n    {\r\n        return -1;\r\n    }\r\n\r\n    // Search for a match in the list.\r\n    for (int i = 0; i < apiDependencies.size(); ++i)\r\n    {\r\n        QSharedPointer<ActiveInterface> listStartInterface = apiDependencies.at(i)->getStartInterface();\r\n        QSharedPointer<ActiveInterface> listEndInterface =\r\n            apiDependencies.at(i)->getEndInterface().dynamicCast<ActiveInterface>();\r\n        if (listEndInterface)\r\n        {\r\n            if (listStartInterface->getComponentReference() == swInstances[instanceIndex1]->getInstanceName() &&\r\n                listEndInterface->getComponentReference() == swInstances[instanceIndex2]->getInstanceName() &&\r\n                listStartInterface->getBusReference() == startApiReference &&\r\n                listEndInterface->getBusReference() == endApiReference)\r\n            {\r\n                index = i;\r\n                break;\r\n            }\r\n        }\r\n        else\r\n        {\r\n            break;\r\n        }\r\n\r\n    }\r\n\r\n    return index;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: updateSystemDesign()\r\n//-----------------------------------------------------------------------------\r\nvoid updateSystemDesignV2(LibraryInterface* lh, VLNV const& hwDesignVLNV, Design& sysDesign,\r\n                          QSharedPointer<DesignConfiguration> designConf)\r\n{\r\n    // Parse all programmable elements from the HW design.\r\n    QList<QSharedPointer<ComponentInstance> >  elements;\r\n    parseProgrammableElementsV2(lh, hwDesignVLNV, elements);\r\n\r\n    // Reflect changes in the programmable elements to the system design.\r\n    QSharedPointer<QList<QSharedPointer<ComponentInstance> > > \r\n        hwInstances(new QList<QSharedPointer<ComponentInstance> >());\r\n    QList<QSharedPointer<ComponentInstance> > swInstances;\r\n    QList<QSharedPointer<ApiInterconnection> > apiDependencies;\r\n\r\n    // 1. PHASE: Check already existing elements against the new list and remove those that\r\n    // are no longer part of the new element list.\r\n    for (QSharedPointer<ComponentInstance> hwInstance : *sysDesign.getComponentInstances())\r\n    {\r\n        QSharedPointer<ConfigurableVLNVReference> ref = hwInstance->getComponentRef();\r\n\r\n        QSharedPointer<Document> componentDoc = lh->getModel(*ref.data());\r\n        QSharedPointer<Component> hwComponent = componentDoc.dynamicCast<Component>();\r\n\r\n        // Only hardware components are applicable in this loop.\r\n        if (!hwComponent || hwComponent->getImplementation() != KactusAttribute::HW)\r\n        {\r\n            continue;\r\n        }\r\n\r\n        // Imported ones should be checked.\r\n        if (hwInstance->isImported())\r\n        {\r\n            // Search for the corresponding element in the new list based on the UUID.\r\n            int index = getInstanceIndexByUUID(elements, hwInstance->getUuid());\r\n\r\n            // If the element was removed, it is not added to the updated design.\r\n            if (index == -1)\r\n            {\r\n                continue;\r\n            }\r\n\r\n            QSharedPointer<ComponentInstance> instanceCopy(new ComponentInstance(*hwInstance));\r\n            instanceCopy->setComponentRef(elements[index]->getComponentRef());\r\n            hwInstances->append(instanceCopy);\r\n\r\n            // Remove the element from the element list since it has been processed.\r\n            elements.removeAt(index);\r\n        }\r\n        else\r\n        {\r\n            // Non-imported instances are always kept.\r\n            hwInstances->append(hwInstance);\r\n        }\r\n    }\r\n\r\n    // 2. PHASE: Add fresh new elements.\r\n    for (QSharedPointer<ComponentInstance> element : elements)\r\n    {\r\n        // Duplicate the component instance and set its kts_hw_ref.\r\n        QSharedPointer<ComponentInstance> instance(new ComponentInstance(element->getInstanceName(),\r\n            element->getComponentRef()));\r\n        instance->setDisplayName(element->displayName());\r\n        instance->setDescription(element->description()); \r\n        instance->setUuid(element->getUuid());\r\n\r\n        instance->setImported(true);\r\n        instance->setImportRef(hwDesignVLNV.toString() + \"_\" + element->getInstanceName());\r\n\r\n        hwInstances->append(instance);\r\n    }\r\n\r\n    QList<QSharedPointer<ComponentInstance> > oldSWInstances;\r\n    QList<QSharedPointer<ApiInterconnection> > oldApiDependencies = sysDesign.getApiConnections();\r\n\r\n    // 3. PHASE: Copy non-imported instances from the old list to the new list.\r\n    for (QSharedPointer<ComponentInstance> swInstance : *sysDesign.getComponentInstances())\r\n    {\r\n        QSharedPointer<ConfigurableVLNVReference> ref = swInstance->getComponentRef();\r\n\r\n        QSharedPointer<Document> componentDoc = lh->getModel(*ref.data());\r\n        QSharedPointer<Component> swComponent = componentDoc.dynamicCast<Component>();\r\n\r\n        // Only software components are applicable in this loop.\r\n        if (!swInstance->isDraft() &&\r\n            (!swComponent || swComponent->getImplementation() != KactusAttribute::SW))\r\n        {\r\n            continue;\r\n        }\r\n\r\n        swInstances.append(swInstance);\r\n\r\n        oldSWInstances.append(swInstance);\r\n    }\r\n\r\n    // 4. PHASE: Parse SW designs from active SW views to retrieve the imported SW instances.\r\n    for (QSharedPointer<ComponentInstance> hwInstance : *hwInstances)\r\n    {\r\n        QSharedPointer<Document const> libComp = lh->getModelReadOnly(*hwInstance->getComponentRef());\r\n        QSharedPointer<Component const> component = libComp.staticCast<Component const>();\r\n\r\n        QString viewName = \"\";\r\n\r\n        if (designConf != 0)\r\n        {\r\n            viewName = designConf->getActiveView(hwInstance->getInstanceName());\r\n        }\r\n\r\n        if (component != 0)\r\n        {\r\n            QSharedPointer<Design const> swDesign;\r\n            QSharedPointer<DesignConfiguration const> swDesignConf;\r\n\r\n            VLNV designVLNV = component->getHierRef(viewName);\r\n\r\n            if (!getDesign(lh, designVLNV, swDesign, swDesignConf))\r\n            {\r\n                continue;\r\n            }\r\n\r\n            for (QSharedPointer<ComponentInstance> swInstance : *swDesign->getComponentInstances())\r\n            {\r\n                QSharedPointer<ConfigurableVLNVReference> ref = swInstance->getComponentRef();\r\n\r\n                QSharedPointer<Document> componentDoc = lh->getModel(*ref.data());\r\n                QSharedPointer<Component> swComponent = componentDoc.dynamicCast<Component>();\r\n\r\n                // Only software components are applicable in this loop.\r\n                if (!swInstance->isDraft() &&\r\n                    (!swComponent || swComponent->getImplementation() != KactusAttribute::SW))\r\n                {\r\n                    continue;\r\n                }\r\n\r\n                // Check if the instance already exists in the old system design.\r\n                int index = getInstanceIndex(oldSWInstances, swInstance->getInstanceName(), hwInstance->getUuid());\r\n\r\n                if (index != -1 && oldSWInstances[index]->isImported())\r\n                {\r\n                    swInstance = oldSWInstances[index];\r\n                    swInstance->setComponentRef(swInstance->getComponentRef());\r\n\r\n                    swInstances.append(swInstance);\r\n                    oldSWInstances.removeAt(index);\r\n                }\r\n                else\r\n                {\r\n                    // Otherwise add the SW instance as a fresh new one.\r\n                    swInstance->setPosition(QPointF());\r\n                    swInstance->setImportRef(swInstance->getInstanceName());\r\n                    swInstance->setMapping(hwInstance->getUuid());\r\n                    swInstance->setDisplayName(swInstance->getInstanceName());\r\n                    swInstance->setInstanceName(hwInstance->getInstanceName() + \"_\" + swInstance->getInstanceName());\r\n                    swInstances.append(swInstance);\r\n                }\r\n            }\r\n\r\n            for (QSharedPointer<ApiInterconnection> dependency : swDesign->getApiConnections())\r\n            {\r\n                int connIndex = getMatchingApiDependency(oldApiDependencies, swInstances,\r\n                                                         dependency, hwInstance->getInstanceName());\r\n\r\n                if (connIndex != -1 && oldApiDependencies[connIndex]->isImported())\r\n                {\r\n                    apiDependencies.append(oldApiDependencies[connIndex]);\r\n                    oldApiDependencies.removeAt(connIndex);\r\n                }\r\n                else\r\n                {\r\n                    dependency->setName(hwInstance->getInstanceName() + \"_\" + dependency->name());\r\n                    QSharedPointer<ActiveInterface> startInterface = dependency->getStartInterface();\r\n                    QString startInterfaceComponentRef = hwInstance->getInstanceName() + \"_\" +\r\n                        startInterface->getComponentReference();\r\n\r\n                    QSharedPointer<ActiveInterface> newStartInterface (\r\n                        new ActiveInterface(startInterfaceComponentRef, startInterface->getBusReference()));\r\n                    dependency->setStartInterface(newStartInterface);\r\n\r\n                    QSharedPointer<ActiveInterface> activeEndInterface =\r\n                        dependency->getEndInterface().dynamicCast<ActiveInterface>();\r\n                    if (activeEndInterface)\r\n                    {\r\n                        QString endInterfaceComponentRef =\r\n                            hwInstance->getInstanceName() + \"_\" + activeEndInterface->getComponentReference();\r\n\r\n                        QSharedPointer<ActiveInterface> newEndInterface (\r\n                            new ActiveInterface(endInterfaceComponentRef, activeEndInterface->getBusReference()));\r\n                        dependency->setInterface(newEndInterface);\r\n                    }\r\n\r\n                    dependency->setImported(true);\r\n                    apiDependencies.append(dependency);\r\n                }\r\n            }\r\n        }\r\n    }\r\n\r\n    // 5. PHASE: Copy non-imported API dependencies from the old list to the new list.\r\n    foreach (QSharedPointer<ApiInterconnection> dependency, oldApiDependencies)\r\n    {\r\n        if (!dependency->isImported())\r\n        {\r\n            apiDependencies.append(dependency);\r\n        }\r\n    }\r\n\r\n    sysDesign.setComponentInstances(hwInstances);\r\n    sysDesign.getComponentInstances()->append(swInstances);\r\n    sysDesign.setApiConnections(apiDependencies);\r\n}\r\n"
  },
  {
    "path": "library/LibraryUtils.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: LibraryUtils.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Joni-Matti Maatta\r\n// Date: 22.6.2011\r\n//\r\n// Description:\r\n// Library utility functions.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef LIBRARYUTILS_H\r\n#define LIBRARYUTILS_H\r\n\r\n#include <QString>\r\n#include <QSharedPointer>\r\n\r\nclass VLNV;\r\nclass Component;\r\nclass Design;\r\nclass DesignConfiguration;\r\nclass LibraryInterface;\r\n\r\n//-----------------------------------------------------------------------------\r\n\r\n/*!\r\n *  Creates a flattened system design based on the given component. This function\r\n *  searches for programmable elements, creates corresponding SW components and\r\n *  generates a system design.\r\n *\r\n *    @param [in]  lh         The library interface.\r\n *    @param [in]  component  The component.\r\n *    @param [out] sysDesign  The resulted system design.\r\n */\r\nvoid generateSystemDesignV2(LibraryInterface* lh, VLNV const& designVLNV, Design& sysDesign);\r\n\r\n/*!\r\n *  Updates the system design based on the given component. This function reflects\r\n *  the changes in the HW component and its software mappings to the given system design.\r\n *\r\n *    @param [in]    lh         The library interface.\r\n *    @param [in,out] sysDesign  The system design to update.\r\n */\r\nvoid updateSystemDesignV2(LibraryInterface* lh, VLNV const& designVLNV, Design& sysDesign,\r\n                          QSharedPointer<DesignConfiguration> designConf);\r\n\r\n//-----------------------------------------------------------------------------\r\n\r\n#endif // LIBRARYUTILS_H\r\n"
  },
  {
    "path": "library/LibraryWidget.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: LibraryWidget.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Esko Pekkarinen\n// Date: 13.05.2017\n//\n// Description:\n// Widget for holding all IP-XACT library widgets.\n//-----------------------------------------------------------------------------\n\n#include \"LibraryWidget.h\"\n\n#include <common/ui/GraphicalMessageMediator.h>\n\n#include \"LibraryErrorModel.h\"\n\n#include \"LibraryTreeWidget.h\"\n#include \"LibraryHandler.h\"\n\n#include <KactusAPI/include/hierarchymodel.h>\n\n#include \"objectremovedialog.h\"\n#include \"ObjectSelectionListItem.h\"\n#include \"LibraryItemSelectionFactory.h\"\n\n#include <common/dialogs/newObjectDialog/newobjectdialog.h>\n\n#include \"HierarchyView/hierarchywidget.h\"\n\n#include \"VLNVDialer/vlnvdialer.h\"\n\n#include <QTabWidget>\n#include <QVBoxLayout>\n#include <QSplitter>\n\n//-----------------------------------------------------------------------------\n// Function: LibraryWidget::LibraryWidget()\n//-----------------------------------------------------------------------------\nLibraryWidget::LibraryWidget(LibraryHandler* library, MessageMediator* messageChannel, QWidget *parent): QWidget(parent),\n    dialer_(new VLNVDialer(this)),\n    library_(library),\n    itemExporter_(library_, this, this),\n    hierarchyWidget_(new HierarchyWidget(library_, library_->getHierarchyModel(), this)),\n    treeWidget_(new LibraryTreeWidget(library_, library_->getTreeModel(), this)),\n    searchBar_(new QLineEdit(this)),\n    previewWidget_(new ComponentPreviewBox(library, this)),\n    previewHideButton_(new QPushButton(QString(), this)),\n    integrityWidget_(nullptr),\n    hidePreview_(false)\n{\n    GraphicalMessageMediator* guiChannel = dynamic_cast<GraphicalMessageMediator*>(messageChannel);\n    if (guiChannel)\n    {        \n        connect(guiChannel, SIGNAL(statusMessage(QString const&)), \n            this, SIGNAL(statusMessage(QString const&)));\n    }\n\n    connectLibraryFilter(hierarchyWidget_->getFilter());\n    connectLibraryFilter(treeWidget_->getFilter());\n\n    searchBar_->setPlaceholderText(tr(\"Search\"));\n    searchBar_->addAction(QIcon(\":/icons/common/graphics/search.png\"), QLineEdit::LeadingPosition);\n    searchBar_->setClearButtonEnabled(true);\n\n    connect(searchBar_, SIGNAL(textChanged(QString const&)),\n        hierarchyWidget_, SLOT(onSearchTextChanged(QString const&)), Qt::UniqueConnection);\n    connect(searchBar_, SIGNAL(textChanged(QString const&)),\n        treeWidget_, SLOT(onSearchTextChanged(QString const&)), Qt::UniqueConnection);\n\n    QSettings settings;\n    hidePreview_ = !settings.value(\"PreviewWidget/Hidden\", true).toBool();\n\n    previewHideButton_->setFlat(true);\n    previewHideButton_->setToolTip(tr(\"Show preview\"));\n\n    onPreviewShowHideClick();\n\n    connect(hierarchyWidget_, SIGNAL(componentSelected(const VLNV&)),\n        library_, SIGNAL(itemSelected(const VLNV&)), Qt::UniqueConnection);\n    \n    connect(library_->getHierarchyModel(), SIGNAL(showErrors(const VLNV)),\n        this, SLOT(onShowErrors(const VLNV)), Qt::UniqueConnection);\n\n    connect(treeWidget_, SIGNAL(itemSelected(const VLNV&)),\n        library_, SIGNAL(itemSelected(const VLNV&)), Qt::UniqueConnection);\n    \n    auto treeModel = library_->getTreeModel();\n\n    connect(treeModel, SIGNAL(errorMessage(const QString&)),\n        this, SIGNAL(errorMessage(const QString&)), Qt::UniqueConnection);\n    connect(treeModel, SIGNAL(noticeMessage(const QString&)),\n        this, SIGNAL(noticeMessage(const QString&)), Qt::UniqueConnection);\n\n    connect(treeModel, SIGNAL(showErrors(const VLNV)),\n        this, SLOT(onShowErrors(const VLNV)), Qt::UniqueConnection);\n\n    connect(treeModel, SIGNAL(createAbsDef(const VLNV&)),\n        this, SLOT(onCreateAbsDef(const VLNV&)), Qt::UniqueConnection);\n    connect(treeModel, SIGNAL(createDesign(const VLNV&)),\n        this, SLOT(onCreateDesign(const VLNV&)), Qt::UniqueConnection);\n\n    connect(treeModel, SIGNAL(createSWDesign(const VLNV&)),\n        this, SIGNAL(createSWDesign(const VLNV&)), Qt::UniqueConnection);\n    connect(treeModel, SIGNAL(createSystemDesign(const VLNV&)),\n        this, SIGNAL(createSystemDesign(const VLNV&)), Qt::UniqueConnection);\n\n    connect(treeModel, SIGNAL(removeVLNV(const QList<VLNV>)),\n        this, SLOT(onRemoveVLNV(const QList<VLNV>)), Qt::UniqueConnection);\n    connect(treeModel, SIGNAL(exportItems(const QList<VLNV>)),\n       &itemExporter_, SLOT(onExportItems(const QList<VLNV>)), Qt::UniqueConnection);\n\n    auto hierarchyModel = library_->getHierarchyModel();\n    connect(hierarchyModel, SIGNAL(errorMessage(const QString&)),\n        this, SIGNAL(errorMessage(QString const&)), Qt::UniqueConnection);\n    connect(hierarchyModel, SIGNAL(removeVLNV(QList<VLNV>)),\n        this, SLOT(onRemoveVLNV(QList<VLNV>)), Qt::UniqueConnection);\n\n    connect(hierarchyModel, SIGNAL(createAbsDef(const VLNV&)),\n        this, SLOT(onCreateAbsDef(const VLNV&)), Qt::UniqueConnection);\n    connect(hierarchyModel, SIGNAL(createDesign(const VLNV&)),\n        this, SLOT(onCreateDesign(const VLNV&)), Qt::UniqueConnection);\n\n    connect(hierarchyModel, SIGNAL(createSWDesign(const VLNV&)),\n        this, SIGNAL(createSWDesign(const VLNV&)), Qt::UniqueConnection);\n    connect(hierarchyModel, SIGNAL(createSystemDesign(const VLNV&)),\n        this, SIGNAL(createSystemDesign(const VLNV&)), Qt::UniqueConnection);\n\n    connect(hierarchyModel, SIGNAL(exportItem(VLNV const&)),\n         &itemExporter_, SLOT(onExportItem(VLNV const&)), Qt::UniqueConnection);\n\n     connect(&itemExporter_, SIGNAL(noticeMessage(const QString&)),\n          this, SIGNAL(noticeMessage(QString const&)), Qt::UniqueConnection);\n\n     connect(&itemExporter_, SIGNAL(errorMessage(const QString&)),\n         this, SIGNAL(errorMessage(QString const&)), Qt::UniqueConnection);\n\n     connect(library_, SIGNAL(itemSelected(const VLNV&)),\n         previewWidget_, SLOT(setComponent(const VLNV&)), Qt::UniqueConnection);\n\n     connect(previewHideButton_, SIGNAL(clicked(bool)), \n         this, SLOT(onPreviewShowHideClick()), Qt::UniqueConnection);\n\n    setupLayout();\n} \n\n//-----------------------------------------------------------------------------\n// Function: LibraryWidget::getLibraryHandler()\n//-----------------------------------------------------------------------------\nLibraryHandler* LibraryWidget::getLibraryHandler() const\n{\n    return library_;\n}\n\n//-----------------------------------------------------------------------------\n// Function: LibraryWidget::loadFilterSettings()\n//-----------------------------------------------------------------------------\nvoid LibraryWidget::loadFilterSettings(QSettings& settings)\n{\n    dialer_->loadFilterSettings(settings);\n}\n\n//-----------------------------------------------------------------------------\n// Function: LibraryWidget::saveFilterSettings()\n//-----------------------------------------------------------------------------\nvoid LibraryWidget::saveFilterSettings(QSettings& settings) const\n{\n    dialer_->saveFilterSettings(settings);\n}\n\n//-----------------------------------------------------------------------------\n// Function: LibraryWidget::selectComponent()\n//-----------------------------------------------------------------------------\nvoid LibraryWidget::selectComponent(VLNV const& componentVLNV) const\n{\n    treeWidget_->selectItem(componentVLNV);\n    hierarchyWidget_->selectItems(componentVLNV);\n    previewWidget_->setComponent(componentVLNV);\n}\n\n//-----------------------------------------------------------------------------\n// Function: LibraryWidget::onShowErrors()\n//-----------------------------------------------------------------------------\nvoid LibraryWidget::onShowErrors(VLNV const& vlnv)\n{\n    if (vlnv.isValid() == false || library_->contains(vlnv) == false)\n    {\n        return;\n    }\n\n    QSharedPointer<Document> document = library_->getModel(vlnv);\n\n    // Show error list in a dialog.\n    TableViewDialog* dialog = new TableViewDialog(this);\n    dialog->setWindowTitle(tr(\"Errors in %1\").arg(vlnv.toString()));\n    dialog->setDescription(tr(\"<b>Integrity check</b><br>The following errors were found.\"));\n    dialog->resize(700, 350);\n\n    LibraryErrorModel* model = new LibraryErrorModel(dialog);\n    model->addErrors(library_->findErrorsInDocument(document, library_->getPath(vlnv)), vlnv.toString());\n\n    dialog->show();\n\n    dialog->setModel(model);\n\n    connect(dialog, SIGNAL(finished(int)), dialog, SLOT(deleteLater()));\n}\n\n//-----------------------------------------------------------------------------\n// Function: LibraryWidget::onCreateAbsDef()\n//-----------------------------------------------------------------------------\nvoid LibraryWidget::onCreateAbsDef(VLNV const& busDefVLNV)\n{\n    if (busDefVLNV.isValid() == false)\n    {\n        return;\n    }\n\n    Q_ASSERT(library_->getDocumentType(busDefVLNV) == VLNV::BUSDEFINITION);\n    Q_ASSERT(library_->contains(busDefVLNV));\n\n    QFileInfo busDefInfo(library_->getPath(busDefVLNV));\n    QString directory = busDefInfo.absolutePath();\n\n    emit createAbsDef(busDefVLNV, directory);\n}\n\n//-----------------------------------------------------------------------------\n// Function: LibraryWidget::onCreateDesign()\n//-----------------------------------------------------------------------------\nvoid LibraryWidget::onCreateDesign(VLNV const& vlnv)\n{\n    emit createDesignForExistingComponent(vlnv);\n}\n\n//-----------------------------------------------------------------------------\n// Function: LibraryWidget::onGenerateIntegrityReport()\n//-----------------------------------------------------------------------------\nvoid LibraryWidget::onGenerateIntegrityReport()\n{\n    if (!integrityWidget_)\n     {\n         integrityWidget_ = new TableViewDialog(this);\n         integrityWidget_->setWindowTitle(tr(\"Library Integrity Report\"));\n         integrityWidget_->setDescription(tr(\"<b>Integrity check</b><br>The following errors were found.\"));\n         integrityWidget_->resize(1000, 800);\n\n         LibraryErrorModel* model = new LibraryErrorModel(integrityWidget_);\n\n         for (auto const& vlnv : library_->getAllVLNVs())\n         {\n             if (library_->isValid(vlnv) == false)\n             {\n                 model->addErrors(library_->findErrorsInDocument(library_->getModel(vlnv), library_->getPath(vlnv)), vlnv.toString());\n             }\n         }\n\n         integrityWidget_->setModel(model);\n\n         integrityWidget_->show();\n\n         connect(integrityWidget_, SIGNAL(finished(int)), this, SLOT(onCloseIntegrityReport()));\n     }\n\n     integrityWidget_->raise();\n}\n//-----------------------------------------------------------------------------\n// Function: LibraryWidget::closeIntegrityReport()\n//-----------------------------------------------------------------------------\nvoid LibraryWidget::onCloseIntegrityReport()\n{\n      integrityWidget_->deleteLater();\n      integrityWidget_ = 0;\n}\n\n//-----------------------------------------------------------------------------\n// Function: LibraryWidget::onRemoveVLNV()\n//-----------------------------------------------------------------------------\nvoid LibraryWidget::onRemoveVLNV(const QList<VLNV> vlnvs)\n{\n    // create the dialog to select which items to remove\n    ObjectRemoveDialog removeDialog(this);\n    LibraryItemSelectionFactory::constructItemsForSelectionDialog(library_, &removeDialog, vlnvs);\n\n    if (removeDialog.exec() == QDialog::Rejected)\n    {\n        return;\n    }\n\n    QList<VLNV> removedVLNVs;\n    QStringList removedFilePaths;\n    for (ObjectSelectionListItem const* removedItem : removeDialog.getSelectedItems())\n    {\n        if (removedItem->getType() == ObjectSelectionListItem::VLNVOJBECT)\n        {\n            removedVLNVs.append(removedItem->getVLNV());\n        }\n        else if (removedItem->getType() == ObjectSelectionListItem::FILE)\n        {\n            QFileInfo fileInfo(removedItem->getPath());\n            if (fileInfo.exists())\n            {\n                removedFilePaths.append(removedItem->getPath());\n            }\n        }\n    }\n\n    library_->removeObjects(removedVLNVs);\n\n    for (auto const& path : removedFilePaths)\n    {\n        QFile file(path);\n        if (file.remove() == false)\n        {\n           emit errorMessage(tr(\"File %1 could not be removed from the file system.\").arg(path));\n        }\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: LibraryWidget::onPreviewHideShowClick()\n//-----------------------------------------------------------------------------\nvoid LibraryWidget::onPreviewShowHideClick()\n{\n    hidePreview_ = !hidePreview_;\n    previewWidget_->setHidden(hidePreview_);\n\n    if (hidePreview_)\n    {\n        previewHideButton_->setToolTip(tr(\"Show preview\"));\n        previewHideButton_->setIcon(QIcon(\":icons/common/graphics/preview.png\"));\n    }\n    else\n    {\n        previewHideButton_->setToolTip(tr(\"Hide preview\"));\n        previewHideButton_->setIcon(QIcon(\":icons/common/graphics/hide.png\"));\n    }\n\n    QSettings settings;\n    settings.setValue(\"PreviewWidget/Hidden\", hidePreview_);\n}\n\n//-----------------------------------------------------------------------------\n// Function: LibraryWidget::connectVLNVFilter()\n//-----------------------------------------------------------------------------\nvoid LibraryWidget::connectLibraryFilter(LibraryFilter* filter) const\n{\n    connect(dialer_, SIGNAL(firmnessChanged(const Utils::FirmnessOptions&)),\n        filter, SLOT(onFirmnessChanged(const Utils::FirmnessOptions&)), Qt::UniqueConnection);\n    connect(dialer_, SIGNAL(implementationChanged(const Utils::ImplementationOptions&)),\n        filter, SLOT(onImplementationChanged(const Utils::ImplementationOptions&)), Qt::UniqueConnection);\n    connect(dialer_, SIGNAL(hierarchyChanged(const Utils::HierarchyOptions&)),\n        filter, SLOT(onHierarchyChanged(const Utils::HierarchyOptions&)), Qt::UniqueConnection);\n    connect(dialer_, SIGNAL(typeChanged(const Utils::TypeOptions&)),\n        filter, SLOT(onTypeChanged(const Utils::TypeOptions&)), Qt::UniqueConnection);\n    connect(dialer_, SIGNAL(revisionChanged(const Utils::RevisionOptions&)),\n        filter, SLOT(onRevisionChanged(const Utils::RevisionOptions&)), Qt::UniqueConnection);\n    connect(dialer_, SIGNAL(validityChanged(const Utils::ValidityOptions&)),\n        filter, SLOT(onValidityChanged(const Utils::ValidityOptions&)), Qt::UniqueConnection);\n    connect(dialer_, SIGNAL(filtersChanged(Utils::FilterOptions const&)),\n        filter, SLOT(onFiltersChanged(Utils::FilterOptions const&)), Qt::UniqueConnection);\n    connect(dialer_, SIGNAL(tagFiltersChanged(QVector<TagData>)),\n        filter, SLOT(onTagFilterChanged(QVector<TagData>)), Qt::UniqueConnection);\n}\n\n//-----------------------------------------------------------------------------\n// Function: LibraryWidget::setupLayout()\n//-----------------------------------------------------------------------------\nvoid LibraryWidget::setupLayout()\n{\n    auto libraryGroup = new QWidget(this);\n\n    auto navigationTabs = new QTabWidget(this);\n    navigationTabs->addTab(treeWidget_, tr(\"VLNV Tree\"));\n    navigationTabs->addTab(hierarchyWidget_, tr(\"Hierarchy\"));\n\n    searchBar_->setContentsMargins(2, 0, 4, 0);\n\n    auto libraryLayout = new QVBoxLayout(libraryGroup);\n    libraryLayout->addWidget(navigationTabs, 1);\n    libraryLayout->addWidget(searchBar_);\n    libraryLayout->addWidget(dialer_);\n    libraryLayout->setSpacing(2);\n    libraryLayout->setContentsMargins(0, 0, 0, 0);\n\n    auto previewGroup = new QWidget(this);\n\n    auto previewLayout = new QGridLayout(previewGroup);\n\n    auto previewLabel = new QLabel(tr(\"Component Preview\"), this);\n\n    previewLayout->addWidget(previewLabel, 0, 0, 1, 1);\n    previewLayout->addWidget(previewHideButton_, 0, 1, 1, 1, Qt::AlignRight);\n    previewLayout->addWidget(previewWidget_, 1, 0, 1, 2);\n    previewLayout->setContentsMargins(4, 0, 4, 0);\n\n    auto viewSplit = new QSplitter(this);\n    viewSplit->setOrientation(Qt::Vertical);\n    viewSplit->addWidget(libraryGroup);\n    viewSplit->addWidget(previewGroup);\n    viewSplit->setStretchFactor(0, 4);\n    viewSplit->setContentsMargins(0, 0, 0, 0);\n\n    auto handle = viewSplit->handle(1);\n    auto handleLayout = new QVBoxLayout(handle);\n    handleLayout->setSpacing(0);\n    handleLayout->setContentsMargins(2, 0, 0, 0);\n\n    auto line = new QFrame(handle);\n    line->setLineWidth(2);\n    line->setMidLineWidth(2);\n    line->setFrameShape(QFrame::HLine);\n    line->setFrameShadow(QFrame::Sunken);\n    handleLayout->addWidget(line);\n\n    viewSplit->setHandleWidth(10);\n\n    auto containerLayout = new QVBoxLayout(this);\n    containerLayout->addWidget(viewSplit, 1);\n    containerLayout->setSpacing(0);\n    containerLayout->setContentsMargins(0, 0, 0, 0);\n}\n"
  },
  {
    "path": "library/LibraryWidget.h",
    "content": "//-----------------------------------------------------------------------------\n// File: LibraryWidget.h\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Esko Pekkarinen\n// Date: 13.05.2017\n//\n// Description:\n// Widget for holding all IP-XACT library widgets.\n//-----------------------------------------------------------------------------\n\n#ifndef LIBRARYWIDGET_H\n#define LIBRARYWIDGET_H\n\n#include <QWidget>\n#include <QStatusBar>\n#include <QProgressBar>\n\n#include <KactusAPI/include/utils.h>\n\n#include <IPXACTmodels/common/VLNV.h>\n#include <IPXACTmodels/common/TagData.h>\n#include <IPXACTmodels/kactusExtensions/KactusAttribute.h>\n\n#include <common/widgets/componentPreviewBox/ComponentPreviewBox.h>\n\n#include \"TableViewDialog.h\"\n\n#include \"ItemExporter.h\"\n\n#include <QSettings>\n\nclass LibraryHandler;\n\nclass VLNVDialer;\nclass HierarchyWidget;\nclass LibraryFilter;\nclass LibraryTreeWidget;\nclass MessageMediator;\n\n//-----------------------------------------------------------------------------\n//! Widget for holding all IP-XACT library widgets.\n//-----------------------------------------------------------------------------\nclass LibraryWidget : public QWidget\n{\n    Q_OBJECT\npublic:\n\n    /*! The constructor.\n     *\n     *    @param [in] library    The IP-XACT library interface.\n     *    @param [in] parent     The parent widget.\n    */\n    LibraryWidget(LibraryHandler* library, MessageMediator* messageChannel, QWidget* parent = 0);\n\n    //! The destructor.\n    virtual ~LibraryWidget() = default;\n\n    /*! Gets the handle for library access.\n     *\n     *    @return     The library access handle.\n    */\n    LibraryHandler* getLibraryHandler() const;\n    \n    /*!\n     *  Set filter settings for the library.\n     *\n     *    @param [in] settings    Settings containing the library filters.\n     */\n    void loadFilterSettings(QSettings& settings);\n\n    /*!\n     *  Save settings for dock widget filters.\n     *\n     *    @param [in] settings    The settings.\n     */\n    void saveFilterSettings(QSettings& settings) const;\n\n    /*!\n     *  Selects the given VLNV in all library views.\n     *\n     *    @param [in] componentVLNV   The VLVN to select.\n     */\n    void selectComponent(VLNV const& componentVLNV) const;\n\nsignals:\n\n    //! Emit a notice message to be printed to user.\n    void noticeMessage(const QString& message);\n\n    //! Emit an error message to be printed to user.\n    void errorMessage(const QString& message);\n\n    //! Signal that user wants to create a new abstraction definition for given bus definition.\n    void createAbsDef(VLNV const& busDefVLNV, const QString& directory);\n\n    //! Signal that user wants to create a new design for the given component.\n    void createDesignForExistingComponent(VLNV const& vlnv);\n\n    //! Signal that user wants to create a new SW design for the given component.\n    void createSWDesign(VLNV const& vlnv);\n\n    //! Signal that user wants to create a new system design for the given component.\n    void createSystemDesign(VLNV const& vlnv);\n\n    void statusMessage(QString const& message);\n\npublic slots:\n\n    /*!\n     *  Shows errors about the library item with the given VLNV.\n     *\n     *    @param [in] vlnv The VLNV of the library item.\n     */\n    void onShowErrors(VLNV const& vlnv);\n    \n    /*! Create a new abstraction definition for given bus definition.\n     *\n     *    @param [in] busDefVLNV Identifies the bus definition to create the abs def for.\n     *\n     */\n    void onCreateAbsDef(VLNV const& busDefVLNV);\n\n    /*! Create new design with given vlnv.\n     *\n     *    @param [in] vlnv The vlnv that identifies the design.\n     *\n    */\n    void onCreateDesign(VLNV const& vlnv);\n\n    //!  Shows a report of all errors within the library items.\n    void onGenerateIntegrityReport();\n\n    void onCloseIntegrityReport();\n\n    void onRemoveVLNV(const QList<VLNV>);\n\n    //! Hides/shows the component preview.\n    void onPreviewShowHideClick();\n\nprivate:\n    //! No copying\n    LibraryWidget(const LibraryWidget& other);\n\n    //! No assignment\n    LibraryWidget& operator=(const LibraryWidget& other);\n\n    /*! Connects the given filter to the filtering widget.\n     *\n     *    @param [in} filter     The filter to connect.\n    */\n    void connectLibraryFilter(LibraryFilter* filter) const;\n\n    //! Sets the widget layout.\n    void setupLayout();\n\n    //-----------------------------------------------------------------------------\n    //! Data\n    //-----------------------------------------------------------------------------\n\n    //! Widget with filtering options for the library.\n    VLNVDialer* dialer_ ;\n\n    //! The instance to manage library access.\n    LibraryHandler* library_;\n\n    ItemExporter itemExporter_;\n\n    //! The widget that contains the GUI items for the hierarchy tab.\n    HierarchyWidget* hierarchyWidget_;\n\n    //! The widget containing the library items in a tree-like view.\n    LibraryTreeWidget* treeWidget_;\n\n    //! The search bar for library items.\n    QLineEdit* searchBar_;\n\n    //! The widget that contains the component preview.\n    ComponentPreviewBox* previewWidget_;\n\n    //! Button for hiding/showing component preview.\n    QPushButton* previewHideButton_;\n\n    //! Widget for showing integrity report on-demand.\n    TableViewDialog* integrityWidget_;\n\n    bool hidePreview_;\n\n};\n\n#endif // LIBRARYWIDGET_H\n"
  },
  {
    "path": "library/ObjectExportDialog.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: ObjectExportDialog.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 04.07.2017\n//\n// Description:\n// Dialog for selecting the exported items.\n//-----------------------------------------------------------------------------\n\n#include \"ObjectExportDialog.h\"\n\n#include <QLabel>\n#include <QFileDialog>\n\n//-----------------------------------------------------------------------------\n// Function: ObjectExportDialog::ObjectExportDialog()\n//-----------------------------------------------------------------------------\nObjectExportDialog::ObjectExportDialog(QWidget* parent, Qt::WindowFlags f):\nObjectSelectionDialog(tr(\"Export\"), QStringLiteral(\":icons/common/graphics/export.png\"),\n    QStringLiteral(\":icons/common/graphics/arrowRight.png\"), tr(\"Select items to be exported\"), parent, f),\nfolderPathEditor_(QString(), this),\nfolderBrowseButton_(QIcon(\":icons/common/graphics/opened-folder.png\"), QString(), this),\ncurrentPath_(QString())\n{\n    setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);\n\n    QString styleSheet(\"*[mandatoryField=\\\"true\\\"] { background-color: LemonChiffon; }\");\n    setStyleSheet(styleSheet);\n\n    disableOkButton();\n    setupLayout();\n    connectSignals();\n}\n\n//-----------------------------------------------------------------------------\n// Function: ObjectExportDialog::~ObjectExportDialog()\n//-----------------------------------------------------------------------------\nObjectExportDialog::~ObjectExportDialog()\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: ObjectExportDialog::connectSignals()\n//-----------------------------------------------------------------------------\nvoid ObjectExportDialog::connectSignals()\n{\n    ObjectSelectionDialog::connectSignals();\n\n    connect(&folderBrowseButton_, SIGNAL(clicked()), this, SLOT(onBrowseTarget()), Qt::UniqueConnection);\n    connect(&folderPathEditor_, SIGNAL(textChanged(const QString&)),\n        this, SLOT(onDestinationFolderChanged(const QString&)), Qt::UniqueConnection);\n}\n\n//-----------------------------------------------------------------------------\n// Function: ObjectExportDialog::onBrowseTarget()\n//-----------------------------------------------------------------------------\nvoid ObjectExportDialog::onBrowseTarget()\n{\n    QFileDialog browseDialog(this, tr(\"Select destination folder for export\"), currentPath_);\n    browseDialog.setFileMode(QFileDialog::Directory);\n    if (browseDialog.exec() == QDialog::Accepted)\n    {\n        QStringList selectedFiles = browseDialog.selectedFiles();\n\n        if (!selectedFiles.isEmpty())\n        {\n            QString selectedFolder = selectedFiles.first();\n            onDestinationFolderChanged(selectedFolder);\n        }\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: ObjectExportDialog::onDestinationFolderChanged()\n//-----------------------------------------------------------------------------\nvoid ObjectExportDialog::onDestinationFolderChanged(const QString& newDestination)\n{\n    folderPathEditor_.setText(newDestination);\n    currentPath_ = newDestination;\n\n    QPalette pathPalette = folderPathEditor_.palette();\n    \n    if (QFileInfo(newDestination).isDir())\n    {\n        pathPalette.setColor(QPalette::Text, Qt::black);\n        enableOkButton();\n    }\n    else\n    {\n        pathPalette.setColor(QPalette::Text, Qt::red);\n        disableOkButton();\n    }\n\n    folderPathEditor_.setPalette(pathPalette);\n}\n\n//-----------------------------------------------------------------------------\n// Function: ObjectExportDialog::getTargetDirectory()\n//-----------------------------------------------------------------------------\nQString ObjectExportDialog::getTargetDirectory() const\n{\n    return currentPath_;\n}\n\n//-----------------------------------------------------------------------------\n// Function: ObjectExportDialog::setupLayout()\n//-----------------------------------------------------------------------------\nvoid ObjectExportDialog::setupLayout()\n{\n    QString introLabel = tr(\"Export\");\n    QString introText = tr(\"Export the selected items to the destination folder. \") +\n        tr(\" The original files will be retained in their containing folders.\\n\") +\n        tr(\"Selected files are exported to the folder of their containing component.\") +\n        tr(\" Unselected files are given paths to their original location.\");\n    QWidget* introWidget = setupIntroWidget(introLabel, introText);\n\n    QString folderToolTip(tr(\"The destination folder for the export.\"));\n    QLabel* folderLabel = new QLabel(tr(\"Destination folder:\"), this);\n    folderLabel->setToolTip(folderToolTip);\n    folderPathEditor_.setToolTip(folderToolTip);\n    folderPathEditor_.setProperty(\"mandatoryField\", true);\n    folderBrowseButton_.setToolTip(\"Browse.\");\n\n    QHBoxLayout* folderBrowseLayout = new QHBoxLayout();\n    folderBrowseLayout->addWidget(folderLabel);\n    folderBrowseLayout->addWidget(&folderPathEditor_);\n    folderBrowseLayout->addWidget(&folderBrowseButton_);\n\n    QHBoxLayout* buttonLayout = setupButtonLayout();\n\n    QVBoxLayout* overallLayout = new QVBoxLayout(this);\n    overallLayout->addWidget(introWidget);\n    overallLayout->addLayout(folderBrowseLayout, 0);\n    overallLayout->addWidget(getItemList(), 1);\n    overallLayout->addLayout(buttonLayout, 0);\n}\n"
  },
  {
    "path": "library/ObjectExportDialog.h",
    "content": "//-----------------------------------------------------------------------------\n// File: ObjectExportDialog.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 04.07.2017\n//\n// Description:\n// Dialog for selecting the exported items.\n//-----------------------------------------------------------------------------\n\n#ifndef OBJECTEXPORTDIALOG_H\n#define OBJECTEXPORTDIALOG_H\n\n#include \"ObjectSelectionDialog.h\"\n\n#include <QPushButton>\n#include <QLineEdit>\n\n//-----------------------------------------------------------------------------\n//! Dialog for selecting the exported items.\n//-----------------------------------------------------------------------------\nclass ObjectExportDialog : public ObjectSelectionDialog\n{\n\tQ_OBJECT\n\npublic:\n\n    /*!\n\t *  The Constructor.\n\t *\n\t *    @param [in] parent          The parent widget.\n\t *    @param [in] f               Widget flags for the dialog.\n\t */\n\tObjectExportDialog(QWidget* parent = 0, Qt::WindowFlags f = Qt::WindowFlags());\n\n    /*!\n\t *  The destructor.\n\t */\n    virtual ~ObjectExportDialog();\n\n    /*!\n     *  Get the path to the destination directory.\n     *\n     *    @return The path to the destination directory.\n     */\n    QString getTargetDirectory() const;\n\nprivate slots:\n\n    /*!\n     *  Open up a dialog for selecting the destination path for the export.\n     */\n    void onBrowseTarget();\n\n    /*!\n     *  Handles the changes in the changing of the destination path.\n     *\n     *    @param [in] newDestination  The new destination path.\n     */\n    void onDestinationFolderChanged(const QString& newDestination);\n\nprotected:\n\n    /*!\n     *  Connect the signals for folder browsing.\n     */\n    virtual void connectSignals();\n\n    /*!\n     *  Setup the dialog layout.\n     */\n    virtual void setupLayout();\n\nprivate:\n\n\t//! No copying. No assignment.\n    ObjectExportDialog(const ObjectExportDialog& other);\n    ObjectExportDialog& operator=(const ObjectExportDialog& other);\n\n    //-----------------------------------------------------------------------------\n    // Data.\n    //-----------------------------------------------------------------------------\n\n    //! Editor for the destination folder.\n    QLineEdit folderPathEditor_;\n\n    //! Button for browsing the destination folder.\n    QPushButton folderBrowseButton_;\n\n    //! The current path.\n    QString currentPath_;\n};\n\n#endif // OBJECTEXPORTDIALOG_H\n"
  },
  {
    "path": "library/ObjectSelectionDialog.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: ObjectSelectionDialog.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 14.07.2017\n//\n// Description:\n// Dialog for selecting the items.\n//-----------------------------------------------------------------------------\n\n#include \"ObjectSelectionDialog.h\"\n\n#include \"ObjectSelectionListItem.h\"\n\n#include <QHBoxLayout>\n#include <QVBoxLayout>\n#include <QIcon>\n#include <QLabel>\n\n//-----------------------------------------------------------------------------\n// Function: ObjectSelectionDialog::ObjectSelectionDialog()\n//-----------------------------------------------------------------------------\nObjectSelectionDialog::ObjectSelectionDialog(QString const& okButtonText, QString const& iconPath,\n    QString const& okIconPath, QString const& windowTitle, QWidget* parent, Qt::WindowFlags f):\nQDialog(parent, f),\ndialogIconPath_(iconPath),\nokButton_(okButtonText, this),\ncancelButton_(tr(\"Cancel\"), this),\ncheckAllBox_(tr(\"Select/deselect all\"), this),\nitemList_(this),\nbusDefinitionIcon_(\":icons/common/graphics/bus-def.png\"),\nabstractionDefinition_(\":icons/common/graphics/abs-def.png\"),\ncomponentIcon_(\":icons/common/graphics/hw-component.png\"),\ndesignIcon_(\":icons/common/graphics/hw-design.png\"),\ndesignConfigurationIcon_(\":icons/common/graphics/configuration.png\"),\ngeneratorChainIcon_(\":icons/common/graphics/generatorChain.png\"),\nabstractorIcon_(\":icons/common/graphics/connect.png\"),\ncatalogIcon_(\":icons/common/graphics/catalog.png\"),\ncomDefinitionIcon_(\":icons/common/graphics/new-com_definition.png\"),\napiDefinitionIcon_(\":icons/common/graphics/new-api_definition.png\"),\nfileIcon_(\":icons/common/graphics/file.png\")\n{\n    okButton_.setIcon(QIcon(okIconPath));\n    checkAllBox_.setChecked(true);\n\n    setWindowTitle(windowTitle);\n    connectSignals();\n}\n\n//-----------------------------------------------------------------------------\n// Function: ObjectSelectionDialog::~ObjectSelectionDialog()\n//-----------------------------------------------------------------------------\nObjectSelectionDialog::~ObjectSelectionDialog()\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: ObjectSelectionDialog::connectSignals()\n//-----------------------------------------------------------------------------\nvoid ObjectSelectionDialog::connectSignals()\n{\n    connect(&okButton_, SIGNAL(clicked(bool)), this, SLOT(accept()), Qt::UniqueConnection);\n    connect(&cancelButton_, SIGNAL(clicked(bool)), this, SLOT(reject()), Qt::UniqueConnection);\n    connect(&checkAllBox_, SIGNAL(stateChanged(int)), this, SLOT(onCheckAllChanged(int)), Qt::UniqueConnection);\n    connect(&itemList_, SIGNAL(itemClicked(QListWidgetItem*)),\n        this, SLOT(onItemClicked(QListWidgetItem*)), Qt::UniqueConnection);\n}\n\n//-----------------------------------------------------------------------------\n// Function: ObjectSelectionDialog::sizeHint()\n//-----------------------------------------------------------------------------\nQSize ObjectSelectionDialog::sizeHint() const\n{\n\treturn QSize(700, 700);\n}\n\n//-----------------------------------------------------------------------------\n// Function: ObjectSelectionDialog::createItem()\n//-----------------------------------------------------------------------------\nvoid ObjectSelectionDialog::createItem(const QString& path, const VLNV& vlnv, bool locked)\n{\n    if (!itemExistsInList(path, vlnv))\n    {\n        QIcon usedIcon = getUsedIcon(vlnv);\n\n        ObjectSelectionListItem* newItem = new ObjectSelectionListItem(usedIcon, path, locked, vlnv);\n        itemList_.addItem(newItem);\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: ObjectSelectionDialog::itemExistsInList()\n//-----------------------------------------------------------------------------\nbool ObjectSelectionDialog::itemExistsInList(QString const& itemPath, VLNV const& itemVLNV) const\n{\n    for (int i = 0; i < itemList_.count(); ++i)\n    {\n        ObjectSelectionListItem* listItem = dynamic_cast<ObjectSelectionListItem*>(itemList_.item(i));\n        if (listItem && listItem->getPath() == itemPath && listItem->getVLNV() == itemVLNV)\n        {\n            return true;\n        }\n    }\n\n    return false;\n}\n\n//-----------------------------------------------------------------------------\n// Function: ObjectSelectionDialog::getUsedIcon()\n//-----------------------------------------------------------------------------\nQIcon ObjectSelectionDialog::getUsedIcon(const VLNV& itemVLNV) const\n{\n    QIcon usedIcon = fileIcon_;\n\n    if (itemVLNV.isValid())\n    {\n        if (itemVLNV.getType() == VLNV::BUSDEFINITION)\n        {\n            usedIcon = busDefinitionIcon_;\n        }\n        else if (itemVLNV.getType() == VLNV::ABSTRACTIONDEFINITION)\n        {\n            usedIcon = abstractionDefinition_;\n        }\n        else if (itemVLNV.getType() == VLNV::COMPONENT)\n        {\n            usedIcon = componentIcon_;\n        }\n        else if (itemVLNV.getType() == VLNV::DESIGN)\n        {\n            usedIcon = designIcon_;\n        }\n        else if (itemVLNV.getType() == VLNV::DESIGNCONFIGURATION)\n        {\n            usedIcon = designConfigurationIcon_;\n        }\n        else if (itemVLNV.getType() == VLNV::GENERATORCHAIN)\n        {\n            usedIcon = generatorChainIcon_;\n        }\n        else if (itemVLNV.getType() == VLNV::ABSTRACTOR)\n        {\n            usedIcon = abstractorIcon_;\n        }\n        else if (itemVLNV.getType() == VLNV::CATALOG)\n        {\n            usedIcon = catalogIcon_;\n        }\n        else if (itemVLNV.getType() == VLNV::COMDEFINITION)\n        {\n            usedIcon = comDefinitionIcon_;\n        }\n        else if (itemVLNV.getType() == VLNV::APIDEFINITION)\n        {\n            usedIcon = apiDefinitionIcon_;\n        }\n    }\n\n    return usedIcon;\n}\n\n//-----------------------------------------------------------------------------\n// Function: ObjectSelectionDialog::onCheckAllChanged()\n//-----------------------------------------------------------------------------\nvoid ObjectSelectionDialog::onCheckAllChanged(int checkAllState)\n{\n    Qt::CheckState newCheckState = Qt::Checked;\n    if (checkAllState == Qt::Unchecked)\n    {\n        newCheckState = Qt::Unchecked;\n    }\n\n    for (int listIndex = 0; listIndex < itemList_.count(); ++listIndex)\n    {\n        ObjectSelectionListItem* listItem = dynamic_cast<ObjectSelectionListItem*>(itemList_.item(listIndex));\n        if (listItem && !listItem->itemIsLocked())\n        {\n            listItem->setCheckState(newCheckState);\n        }\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: ObjectSelectionDialog::onItemClicked()\n//-----------------------------------------------------------------------------\nvoid ObjectSelectionDialog::onItemClicked(QListWidgetItem* currentItem)\n{\n    ObjectSelectionListItem* listItem = dynamic_cast<ObjectSelectionListItem*>(currentItem);\n    if (listItem && !listItem->itemIsLocked())\n    {\n        Qt::CheckState currentItemCheckState = listItem->checkState();\n        if (currentItemCheckState == Qt::Checked)\n        {\n            listItem->setCheckState(Qt::Unchecked);\n        }\n        else\n        {\n            listItem->setCheckState(Qt::Checked);\n        }\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: ObjectSelectionDialog::getItemsToExport()\n//-----------------------------------------------------------------------------\nQVector<ObjectSelectionListItem*> ObjectSelectionDialog::getSelectedItems() const\n{\n    QVector<ObjectSelectionListItem*> exportedItems;\n\n    for (int listIndex = 0; listIndex < itemList_.count(); ++listIndex)\n    {\n        ObjectSelectionListItem* exportItem = dynamic_cast<ObjectSelectionListItem*>(itemList_.item(listIndex));\n        if (exportItem && exportItem->checkState() == Qt::Checked)\n        {\n            exportedItems.append(exportItem);\n        }\n    }\n\n    return exportedItems;\n}\n\n//-----------------------------------------------------------------------------\n// Function: ObjectSelectionDialog::enableOkButton()\n//-----------------------------------------------------------------------------\nvoid ObjectSelectionDialog::enableOkButton()\n{\n    okButton_.setEnabled(true);\n}\n\n//-----------------------------------------------------------------------------\n// Function: ObjectSelectionDialog::disableOkButton()\n//-----------------------------------------------------------------------------\nvoid ObjectSelectionDialog::disableOkButton()\n{\n    okButton_.setEnabled(false);\n}\n\n//-----------------------------------------------------------------------------\n// Function: ObjectSelectionDialog::setupIntroWidget()\n//-----------------------------------------------------------------------------\nQWidget* ObjectSelectionDialog::setupIntroWidget(QString const& introName, QString const& introText) const\n{\n    QLabel* introLabel = new QLabel(introName);\n    QLabel* introTextLabel = new QLabel(introText);\n    QFont introFont = introLabel->font();\n    introFont.setBold(true);\n    introLabel->setFont(introFont);\n\n    QLabel* iconLabel = new QLabel();\n    iconLabel->setPixmap(QPixmap(dialogIconPath_));\n\n    QVBoxLayout* introTextLayout = new QVBoxLayout();\n    introTextLayout->addWidget(introLabel);\n    introTextLayout->addWidget(introTextLabel);\n\n    QHBoxLayout* mainIntroLayout = new QHBoxLayout();\n    mainIntroLayout->addLayout(introTextLayout, 1);\n    mainIntroLayout->addWidget(iconLabel);\n\n    QWidget* introWidget = new QWidget();\n    introWidget->setStyleSheet(\"background-color: white\");\n    introWidget->setLayout(mainIntroLayout);\n\n    return introWidget;\n}\n\n//-----------------------------------------------------------------------------\n// Function: ObjectSelectionDialog::setupButtonLayout()\n//-----------------------------------------------------------------------------\nQHBoxLayout* ObjectSelectionDialog::setupButtonLayout()\n{\n    QHBoxLayout* buttonLayout = new QHBoxLayout();\n    buttonLayout->addWidget(&checkAllBox_, 0, Qt::AlignLeft);\n    buttonLayout->addStretch();\n    buttonLayout->addWidget(&okButton_, 0, Qt::AlignRight);\n    buttonLayout->addWidget(&cancelButton_, 0, Qt::AlignRight);\n\n    return buttonLayout;\n}\n\n//-----------------------------------------------------------------------------\n// Function: ObjectSelectionDialog::getItemList()\n//-----------------------------------------------------------------------------\nQListWidget* ObjectSelectionDialog::getItemList()\n{\n    return &itemList_;\n}\n"
  },
  {
    "path": "library/ObjectSelectionDialog.h",
    "content": "//-----------------------------------------------------------------------------\n// File: ObjectSelectionDialog.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 14.07.2017\n//\n// Description:\n// Dialog for selecting the items.\n//-----------------------------------------------------------------------------\n\n#ifndef OBJECTSELECTIONDIALOG_H\n#define OBJECTSELECTIONDIALOG_H\n\n#include <IPXACTmodels/common/VLNV.h>\n\n#include <KactusAPI/KactusAPIGlobal.h>\n\n#include <QDialog>\n#include <QPushButton>\n#include <QLineEdit>\n#include <QSize>\n#include <QCheckBox>\n#include <QListWidget>\n\n#include <QVBoxLayout>\n#include <QHBoxLayout>\n#include <QWidget>\n\nclass ObjectSelectionListItem;\n\n//-----------------------------------------------------------------------------\n//! Dialog for selecting the items.\n//-----------------------------------------------------------------------------\nclass ObjectSelectionDialog : public QDialog\n{\n    Q_OBJECT\n\npublic:\n\n    /*!\n\t *  The Constructor.\n\t *\n     *    @param [in] okButtonText    QString containing the text for the ok button.\n     *    @param [in] iconPath        Path to the icon used by the selection dialog.\n     *    @param [in] okIconPath      Path to the icon used by the ok button.\n     *    @param [in] windowTitle     Window title of the selection dialog.\n\t *    @param [in] parent          The parent widget.\n\t *    @param [in] f               Widget flags for the dialog.\n\t */\n    ObjectSelectionDialog(QString const& okButtonText, QString const& iconPath, QString const& okIconPath,\n        QString const& windowTitle, QWidget* parent = 0, Qt::WindowFlags f = Qt::WindowFlags());\n\n    /*!\n\t *  The destructor.\n\t */\n    virtual ~ObjectSelectionDialog();\n\n    /*!\n     *  Create a list widget item for the dialog.\n     *\n     *    @param [in] path    Location path of the item file.\n     *    @param [in] vlnv    VLNV of the item.\n     *    @param [in] locked  Value for separating exportable items.\n     */\n    void createItem(const QString& path, const VLNV& vlnv = VLNV(), bool locked = false);\n\n\t/*!\n     *  Get the size hint of this dialog.\n\t *\n     *    @return QSize contains the desired size for this dialog.\n     */\n\tvirtual QSize sizeHint() const;\n\n    /*!\n     *  Get the items to be exported.\n     *\n     *    @return A list of items to be exported.\n     */\n    QVector<ObjectSelectionListItem*> getSelectedItems() const;\n\nprivate slots:\n\n    /*!\n     *  Handles the selection of all the items in the list.\n     *\n     *    @param [in] checkAllState   The new state of the items.\n     */\n    void onCheckAllChanged(int checkAllState);\n\n    /*!\n     *  [Description].\n     *\n     *    @param [in] currentItem   [Description].\n     */\n    void onItemClicked(QListWidgetItem* currentItem);\n\nprotected:\n\n    /*!\n     *  Connect the signals.\n     */\n    virtual void connectSignals();\n\n    /*!\n     *  Enable the ok button.\n     */\n    void enableOkButton();\n\n    /*!\n     *  Disable the ok button.\n     */\n    void disableOkButton();\n\n    /*!\n     *  Construct the intro labels for the dialog.\n     *\n     *    @param [in] introName   Name of the introduction.\n     *    @param [in] introText   Text explaining the use of this selection dialog.\n     *\n     *    @return QWidget containing the information of the selection dialog.\n     */\n    QWidget* setupIntroWidget(QString const& introName, QString const& introText) const;\n\n    /*!\n     *  Setup the layout for the buttons used in the selection dialog.\n     *\n     *    @return The layout containing the dialog buttons.\n     */\n    QHBoxLayout* setupButtonLayout();\n\n    /*!\n     *  Get the list widget containing the selectable items.\n     *\n     *    @return The list widget containing the selectable items.\n     */\n    QListWidget* getItemList();\n    \n    /*!\n     *  Setup the dialog layout.\n     */\n    virtual void setupLayout() = 0;\n\nprivate:\n\n\t//! No copying. No assignment.\n    ObjectSelectionDialog(const ObjectSelectionDialog& other);\n    ObjectSelectionDialog& operator=(const ObjectSelectionDialog& other);\n\n    /*!\n     *  Get the icon used by the selected item VLNV.\n     *\n     *    @param [in] itemVLNV    VLNV of the selected item.\n     *\n     *    @return Icon corresponding to the selected VLNV.\n     */\n    QIcon getUsedIcon(const VLNV& itemVLNV) const;\n\n    /*!\n     *  Check if an item exists in the list.\n     *\n     *    @param [in] itemPath    Path of the selected item.\n     *    @param [in] itemVLNV    VLNV of the selected item.\n     *\n     *    @return True, if the item exists in the list, false otherwise.\n     */\n    bool itemExistsInList(QString const& itemPath, VLNV const& itemVLNV) const;\n\n    //-----------------------------------------------------------------------------\n    // Data.\n    //-----------------------------------------------------------------------------\n\n    //! Path to the icon used by the selection dialog.\n    QString dialogIconPath_;\n\n\t//! Ok button to accept the dialog.\n\tQPushButton okButton_;\n\n\t//! Cancel button to reject the dialog.\n\tQPushButton cancelButton_;\n\n\t//! Check box to select/deselect all items.\n    QCheckBox checkAllBox_;\n\n    //! List containing the items of the selection dialog.\n    QListWidget itemList_;\n\n    //! Icon used by bus definitions.\n    QIcon busDefinitionIcon_;\n\n    //! Icon used by abstraction definitions.\n    QIcon abstractionDefinition_;\n\n    //! Icon used by components.\n    QIcon componentIcon_;\n\n    //! Icon used by designs.\n    QIcon designIcon_;\n\n    //! Icon used by design configurations.\n    QIcon designConfigurationIcon_;\n\n    //! Icon used by generator chains.\n    QIcon generatorChainIcon_;\n\n    //! Icon used by abstractors.\n    QIcon abstractorIcon_;\n\n    //! Icon used by catalogues.\n    QIcon catalogIcon_;\n\n    //! Icon used by COM definitions.\n    QIcon comDefinitionIcon_;\n\n    //! Icon used by API definitions.\n    QIcon apiDefinitionIcon_;\n\n    //! Icon used by files.\n    QIcon fileIcon_;\n};\n\n#endif // OBJECTEXPORTDIALOG_H\n"
  },
  {
    "path": "library/ObjectSelectionListItem.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: ObjectSelectionListItem.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 07.07.2017\n//\n// Description:\n// List item for VLNVs and files.\n//-----------------------------------------------------------------------------\n\n// #include \"ObjectExportListItem.h\"\n#include \"ObjectSelectionListItem.h\"\n\n//-----------------------------------------------------------------------------\n// Function: ObjectSelectionListItem::ObjectSelectionListItem()\n//-----------------------------------------------------------------------------\nObjectSelectionListItem::ObjectSelectionListItem(QIcon itemIcon, QString const& itemPath, bool isLocked,\n    VLNV vlnv):\nQListWidgetItem(itemIcon, itemPath),\nitemVlnv_(vlnv),\nitemPath_(itemPath),\ntype_(VLNVOJBECT),\nlocked_(isLocked)\n{\n    if (!vlnv.isValid())\n    {\n        type_ = ObjectSelectionListItem::FILE;\n    }\n\n    setCheckState(Qt::Checked);\n\n    setFlags(Qt::NoItemFlags);\n    if (!isLocked)\n    {\n        setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable);\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: ObjectSelectionListItem::~ObjectSelectionListItem()\n//-----------------------------------------------------------------------------\nObjectSelectionListItem::~ObjectSelectionListItem()\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: ObjectSelectionListItem::getVLNV()\n//-----------------------------------------------------------------------------\nVLNV ObjectSelectionListItem::getVLNV() const\n{\n    return itemVlnv_;\n}\n\n//-----------------------------------------------------------------------------\n// Function: ObjectSelectionListItem::getPath()\n//-----------------------------------------------------------------------------\nQString ObjectSelectionListItem::getPath() const\n{\n    return itemPath_;\n}\n\n//-----------------------------------------------------------------------------\n// Function: ObjectSelectionListItem::getType()\n//-----------------------------------------------------------------------------\nObjectSelectionListItem::ItemType ObjectSelectionListItem::getType() const\n{\n    return type_;\n}\n\n//-----------------------------------------------------------------------------\n// Function: ObjectSelectionListItem::itemIsLocked()\n//-----------------------------------------------------------------------------\nbool ObjectSelectionListItem::itemIsLocked() const\n{\n    return locked_;\n}\n"
  },
  {
    "path": "library/ObjectSelectionListItem.h",
    "content": "//-----------------------------------------------------------------------------\n// File: ObjectSelectionListItem.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 07.07.2017\n//\n// Description:\n// List item for VLNVs and files.\n//-----------------------------------------------------------------------------\n\n#ifndef OBJECTSELECTIONLISTITEM_H\n#define OBJECTSELECTIONLISTITEM_H\n\n#include <IPXACTmodels/common/VLNV.h>\n\n#include <QIcon>\n#include <QListWidgetItem>\n\n//-----------------------------------------------------------------------------\n//! List item for VLNVs and files.\n//-----------------------------------------------------------------------------\nclass ObjectSelectionListItem : public QListWidgetItem\n{\n\npublic:\n\n    //! Type of the item.\n    enum ItemType\n    {\n        VLNVOJBECT = 0,     // VLNV object item.\n        FILE                // file item.\n    };\n\n\t/*!\n     *  The constructor.\n\t *\n     *    @param [in] itemIcon    Icon used by the item.\n     *    @param [in] itemPath    File path of the item.\n     *    @param [in] isLocked    The lock status of the item.\n     *    @param [in] vlnv        VLNV associated with the item.\n\t *\n     */\n    ObjectSelectionListItem(QIcon itemIcon, QString const& itemPath, bool isLocked, VLNV vlnv = VLNV());\n\n\t/*!\n     *  The destructor.\n     */\n    virtual ~ObjectSelectionListItem();\n\n    /*!\n     *  Get the VLNV associated with the item.\n     *\n     *    @return The VLNV of the item.\n     */\n    VLNV getVLNV() const;\n\n    /*!\n     *  Get the file path of the item.\n     *\n     *    @return The file path of the item.\n     */\n    QString getPath() const;\n\n    /*!\n     *  Get the item type.\n     *\n     *    @return The type of the item.\n     */\n    ObjectSelectionListItem::ItemType getType() const;\n\n    /*!\n     *  Check if the item is locked.\n     *\n     *    @return True, if the item is locked, false otherwise.\n     */\n    bool itemIsLocked() const;\n\nprivate:\n\n    //! No copying. No assignment.\n    ObjectSelectionListItem(const ObjectSelectionListItem& other);\n    ObjectSelectionListItem& operator=(const ObjectSelectionListItem& other);\n\n    //-----------------------------------------------------------------------------\n    // Data.\n    //-----------------------------------------------------------------------------\n\n    //! VLNV associated with the item.\n    VLNV itemVlnv_;\n\n    //! File path of the item.\n    QString itemPath_;\n\n    //! Type of the item.\n    ObjectSelectionListItem::ItemType type_;\n\n    //! Lock status of the item.\n    bool locked_;\n};\n\n#endif // OBJECTSELECTIONLISTITEM_H\n"
  },
  {
    "path": "library/TableViewDialog.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: TableViewDialog.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Joni-Matti Maatta\n// Date: 04.09.2012\n//\n// Description:\n// Generic table view dialog with close button.\n//-----------------------------------------------------------------------------\n\n#include \"TableViewDialog.h\"\n\n#include <QVBoxLayout>\n#include <QHeaderView>\n#include <QDialogButtonBox>\n#include <QPushButton>\n#include <QSizePolicy>\n\n//-----------------------------------------------------------------------------\n// Function: TableViewDialog::TableViewDialog()\n//-----------------------------------------------------------------------------\nTableViewDialog::TableViewDialog(QWidget* parent):\nQDialog(parent),\n    label_(new QLabel(\"\", this)),\n    view_(new QTableView(this)),\n    sortProxy_(new QSortFilterProxyModel(this))\n{\n    setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);\n\n    view_->setSortingEnabled(true);\n    view_->setModel(sortProxy_);\n    view_->horizontalHeader()->setStretchLastSection(true);\n    view_->horizontalHeader()->setDefaultAlignment(Qt::AlignLeft);\n    view_->setWordWrap(true);    \n    view_->verticalHeader()->hide();\n\n    setupLayout();\n}\n\n//-----------------------------------------------------------------------------\n// Function: TableViewDialog::~TableViewDialog()\n//-----------------------------------------------------------------------------\nTableViewDialog::~TableViewDialog()\n{\n}\n\n//-----------------------------------------------------------------------------\n// Function: TableViewDialog::setDescription()\n//-----------------------------------------------------------------------------\nvoid TableViewDialog::setDescription(QString const& desc)\n{\n    label_->setText(desc);\n}\n\n//-----------------------------------------------------------------------------\n// Function: TableViewDialog::setModel()\n//-----------------------------------------------------------------------------\nvoid TableViewDialog::setModel(QAbstractTableModel* model)\n{\n    sortProxy_->setSourceModel(model);\n\n    view_->resizeColumnToContents(0);\n    view_->setColumnWidth(1, 500);\n    view_->resizeColumnToContents(2);\n    view_->resizeRowsToContents();\n}\n\n//-----------------------------------------------------------------------------\n// Function: TableViewDialog::setupLayout()\n//-----------------------------------------------------------------------------\nvoid TableViewDialog::setupLayout()\n{\n    QWidget* introWidget = new QWidget(this);\n    QHBoxLayout* introLayout = new QHBoxLayout(introWidget);\n    introLayout->addWidget(label_, 9);\n    QLabel* errorIcon = new QLabel(this);\n    errorIcon->setPixmap(QPixmap(\":/icons/common/graphics/checkIntegrity.png\"));\n    introLayout->addWidget(errorIcon, 1, Qt::AlignRight);    \n\n    QPalette introPalette = introWidget->palette();\n    introPalette.setColor(QPalette::Window, Qt::white);\n    introWidget->setPalette(introPalette);\n    introWidget->setAutoFillBackground(true);\n\n    QDialogButtonBox* buttonBox = new QDialogButtonBox(QDialogButtonBox::Close, Qt::Horizontal, this);\n    connect(buttonBox->button(QDialogButtonBox::Close), SIGNAL(clicked()),\n        this, SLOT(accept()), Qt::UniqueConnection);\n\n    QVBoxLayout* layout = new QVBoxLayout(this);\n    layout->addWidget(introWidget);\n    layout->addWidget(view_, 1);\n    layout->addWidget(buttonBox);\n}\n"
  },
  {
    "path": "library/TableViewDialog.h",
    "content": "//-----------------------------------------------------------------------------\n// File: TableViewDialog.h\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Joni-Matti Maatta\n// Date: 04.09.2012\n//\n// Description:\n// Generic table view dialog with close button.\n//-----------------------------------------------------------------------------\n\n#ifndef TABLEVIEWDIALOG_H\n#define TABLEVIEWDIALOG_H\n\n#include <QDialog>\n#include <QTableView>\n#include <QLabel>\n#include <QAbstractTableModel>\n#include <QSortFilterProxyModel>\n\n//-----------------------------------------------------------------------------\n//! Generic table view dialog with close button.\n//-----------------------------------------------------------------------------\nclass TableViewDialog : public QDialog\n{\npublic:\n    /*!\n     *  Constructor.\n     */\n    TableViewDialog(QWidget* parent);\n\n    /*!\n     *  Destructor.\n     */\n    ~TableViewDialog();\n\n    /*!\n     *  Sets the description text for the table view.\n     *\n     *    @param [in] desc The description text.\n     */\n    void setDescription(QString const& desc);\n\n    /*!\n     *  Sets the model used for the table view.\n     *\n     *    @param [in] model The model to set.\n     */\n    void setModel(QAbstractTableModel* model);\n\nprivate:\n    // Disable copying.\n    TableViewDialog(TableViewDialog const& rhs);\n    TableViewDialog& operator=(TableViewDialog const& rhs);\n\n    //! Setup widget layout.\n    void setupLayout();\n\n    //-----------------------------------------------------------------------------\n    // Data.\n    //-----------------------------------------------------------------------------\n\n    //! Description label.\n    QLabel* label_;\n\n    //! The table view.\n    QTableView* view_;\n\n    //! Sort filter.\n    QSortFilterProxyModel* sortProxy_;\n};\n\n#endif // TABLEVIEWDIALOG_H\n"
  },
  {
    "path": "library/VLNVDialer/FilterGroup.cpp",
    "content": "// File: FilterGroup.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Esko Pekkarinen\n// Date: 24.04.2023\n//\n// Description:\n// Base class for library filter groups\n//-----------------------------------------------------------------------------\n\n\n#include \"FilterGroup.h\"\n\n//-----------------------------------------------------------------------------\n// Function: FilterGroup::FilterGroup()\n//-----------------------------------------------------------------------------\nFilterGroup::FilterGroup(QString const& title, QWidget *parent):\nQGroupBox(title, parent)\n{\n    setFlat(true);\n}\n\n//-----------------------------------------------------------------------------\n// Function: FilterGroup::setupButton()\n//-----------------------------------------------------------------------------\nvoid FilterGroup::setupButton(QPushButton* button, QString const& tooltip)\n{\n    button->setToolTip(tooltip);\n    button->setFlat(true);\n    button->setCheckable(true);\n\n    const int ICON_SIZE = 24;\n    button->setMinimumHeight(ICON_SIZE);\n    button->setIconSize(QSize(ICON_SIZE, ICON_SIZE));\n}\n"
  },
  {
    "path": "library/VLNVDialer/FilterGroup.h",
    "content": "//-----------------------------------------------------------------------------\n// File: FilterGroup.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Esko Pekkarinen\n// Date: 24.04.2023\n//\n// Description:\n// Base class for library filter groups\n//-----------------------------------------------------------------------------\n\n#ifndef FILTERGROUP_H\n#define FILTERGROUP_H\n\n#include <QGroupBox>\n#include <QPushButton>\n\n//-----------------------------------------------------------------------------\n//! Base class for library filter groups.\n//-----------------------------------------------------------------------------\nclass FilterGroup : public QGroupBox\n{\n\tQ_OBJECT\n\npublic:\n\n\t/*!\n     *  The constructor\n\t *\n\t *    @param [in] parent The owner of this widget.\n\t */\n\tFilterGroup(QString const& title, QWidget *parent);\n\n    //! No copying. No assignment.\n\tFilterGroup(const FilterGroup& other) = delete;\n\tFilterGroup& operator=(const FilterGroup& other) = delete;\n\n\t/*!\n     *  The destructor\n     */\n\tvirtual ~FilterGroup() = default;\n\n\t/*!\n\t *  Select/clear all filters.\n\t *\n\t *    @param [in] select     If true, all filters are set, otherwise all filters are cleared.\n\t */\n\tvirtual void selectAll(bool select) = 0;\n\nprotected:\n\n\t//! Setups the filter button.\n    void setupButton(QPushButton* button, QString const& tooltip);\n};\n\n#endif // FILTERGROUP_H\n"
  },
  {
    "path": "library/VLNVDialer/RevisionGroup.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: RevisionGroup.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Esko Pekkarinen\n// Date: 05.12.2023\n//\n// Description:\n// Contains the check boxes to set the revision options for VLNVDialer.\n//-----------------------------------------------------------------------------\n\n#include \"RevisionGroup.h\"\n\n#include <KactusAPI/include/utils.h>\n\n#include <common/widgets/tagEditor/FlowLayout.h>\n\n//-----------------------------------------------------------------------------\n// Function: RevisionGroup::RevisionGroup()\n//-----------------------------------------------------------------------------\nRevisionGroup::RevisionGroup(QWidget *parent):\nFilterGroup(tr(\"IP-XACT version\"), parent)\n{\n    setupButton(&std14Button_, tr(\"Valid\"));\n    setupButton(&std22Button_, tr(\"Errors\"));\n\n    std14Button_.setChecked(true);\n    std22Button_.setChecked(true);\n\n    connect(&std14Button_, SIGNAL(clicked(bool)), this, SLOT(onStd14Changed(bool)), Qt::UniqueConnection);\n    connect(&std22Button_, SIGNAL(clicked(bool)), this, SLOT(onStd22Changed(bool)), Qt::UniqueConnection);\n\n    auto layout = new FlowLayout(this, 2, 1, 1);\n    layout->addWidget(&std14Button_);\n    layout->addWidget(&std22Button_);\n}\n\n//-----------------------------------------------------------------------------\n// Function: RevisionGroup::setRevision()\n//-----------------------------------------------------------------------------\nvoid RevisionGroup::setRevision(Utils::RevisionOptions options)\n{    \n    std14Button_.setChecked(options.std14_);\n    std22Button_.setChecked(options.std22_);\n\n    options_ = options;\n    emit optionsChanged(options_);\n}\n\n//-----------------------------------------------------------------------------\n// Function: RevisionGroup::getRevision()\n//-----------------------------------------------------------------------------\nUtils::RevisionOptions RevisionGroup::getRevision() const\n{\n    Utils::RevisionOptions options;\n    options.std14_ = std14Button_.isChecked();\n    options.std22_ = std22Button_.isChecked();\n\n    return options;\n}\n\n//-----------------------------------------------------------------------------\n// Function: RevisionGroup::selectAll()\n//-----------------------------------------------------------------------------\nvoid RevisionGroup::selectAll(bool select)\n{\n    Utils::RevisionOptions options;\n    options.std14_ = select;\n    options.std22_ = select;\n\n    setRevision(options);\n}\n\n//-----------------------------------------------------------------------------\n// Function: RevisionGroup::onStd14Changed()\n//-----------------------------------------------------------------------------\nvoid RevisionGroup::onStd14Changed(bool checked)\n{\n\toptions_.std14_ = checked;\n\temit optionsChanged(options_);\n}\n\n//-----------------------------------------------------------------------------\n// Function: RevisionGroup::onStd22Changed()\n//-----------------------------------------------------------------------------\nvoid RevisionGroup::onStd22Changed(bool checked)\n{\n\toptions_.std22_ = checked;\n\temit optionsChanged(options_);\n}\n"
  },
  {
    "path": "library/VLNVDialer/RevisionGroup.h",
    "content": "//-----------------------------------------------------------------------------\n// File: RevisionGroup.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Esko Pekkarinen\n// Date: 05.12.2023\n//\n// Description:\n// Contains the check boxes to set the revision options for VLNVDialer.\n//-----------------------------------------------------------------------------\n\n#ifndef REVISION_GROUP_H\n#define REVISION_GROUP_H\n\n#include \"FilterGroup.h\"\n\n#include <KactusAPI/include/utils.h>\n\n#include <QGroupBox>\n#include <QPushButton>\n\n//-----------------------------------------------------------------------------\n//! Contains the check boxes to set the re-usability options for VLNVDialer.\n//-----------------------------------------------------------------------------\nclass RevisionGroup : public FilterGroup\n{\n    Q_OBJECT\n\npublic:\n\n\t/*!\n     *  The constructor\n\t *\n\t *    @param [in] parent The owner of this widget.\n     */\n\texplicit RevisionGroup(QWidget *parent);\n\t\n\t/*!\n     *  The destructor\n     */\n\tvirtual ~RevisionGroup() = default;\n\n    /*!\n     *  Sets new validity options.\n     *\n     *    @param [in] options   The options to set.\n     */\n    void setRevision(Utils::RevisionOptions options);\n\n    /*!\n     *  Gets the selected validity options.\n     *\n     *    @return Selected validity options.\n     */\n    [[nodiscard]] Utils::RevisionOptions getRevision() const;\n\n    /*!\n     *  Select/clear all filters.\n     *\n     *    @param [in] select     If true, all filters are set, otherwise all filters are cleared.\n     */\n\tvoid selectAll(bool select) final;\n\nsignals:\n\n\t/*!\n     *  Emitted when one of the check boxes changes state.\n     */\n\tvoid optionsChanged(Utils::RevisionOptions const& options);\n\nprivate slots:\n\n\t/*!\n     *  Handler for valid check box state changes.\n     */\n\tvoid onStd14Changed(bool checked);\n\n\t/*!\n     *  Handler for non-valid check box state changes.\n     */\n\tvoid onStd22Changed(bool checked);\n\n\nprivate:\n\n\t//! Check box to select std 14 items in/out of search results.\n    QPushButton std14Button_{ QString(\"2014\"), this };\n\n\t//! Check box to select std 22 items in/out of search results.\n    QPushButton std22Button_{ QString(\"2022\"), this };\n\n\t//! Contains the current revision settings.\n    Utils::RevisionOptions options_{};\n};\n\n#endif // REVISION_GROUP_H\n"
  },
  {
    "path": "library/VLNVDialer/ValidityGroup.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: ValidityGroup.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Esko Pekkarinen\n// Date: 12.09.2023\n//\n// Description:\n// Contains the check boxes to set the validity options for VLNVDialer.\n//-----------------------------------------------------------------------------\n\n#include \"ValidityGroup.h\"\n\n#include <KactusAPI/include/utils.h>\n\n#include <common/widgets/tagEditor/FlowLayout.h>\n\n//-----------------------------------------------------------------------------\n// Function: ValidityGroup::ValidityGroup()\n//-----------------------------------------------------------------------------\nValidityGroup::ValidityGroup(QWidget *parent):\nFilterGroup(tr(\"Correctness\"), parent),\nvalidBox_(QIcon(\":/icons/common/graphics/pass.png\"), QString(), this),\nnonvalidBox_(QIcon(\":/icons/common/graphics/fail.png\"), QString(), this),\noptions_()\n{\n    setupButton(&validBox_, tr(\"Valid\"));\n    setupButton(&nonvalidBox_, tr(\"Errors\"));\n\n    validBox_.setChecked(true);\n    nonvalidBox_.setChecked(true);\n\n    connect(&validBox_, SIGNAL(clicked(bool)), this, SLOT(onValidChanged(bool)), Qt::UniqueConnection);\n    connect(&nonvalidBox_, SIGNAL(clicked(bool)), this, SLOT(onNonvalidChanged(bool)), Qt::UniqueConnection);\n\n    auto layout = new FlowLayout(this, 2, 1, 1);\n    layout->addWidget(&validBox_);\n    layout->addWidget(&nonvalidBox_);\n}\n\n//-----------------------------------------------------------------------------\n// Function: ValidityGroup::setFirmness()\n//-----------------------------------------------------------------------------\nvoid ValidityGroup::setValidity(Utils::ValidityOptions options)\n{    \n    validBox_.setChecked(options.valid_);\n    nonvalidBox_.setChecked(options.invalid_);\n\n    options_ = options;\n    emit optionsChanged(options_);\n}\n\n//-----------------------------------------------------------------------------\n// Function: ValidityGroup::getFirmness()\n//-----------------------------------------------------------------------------\nUtils::ValidityOptions ValidityGroup::getValidity() const\n{\n    Utils::ValidityOptions options;\n    options.valid_ = validBox_.isChecked();\n    options.invalid_ = nonvalidBox_.isChecked();\n\n    return options;\n}\n\n//-----------------------------------------------------------------------------\n// Function: ValidityGroup::selectAll()\n//-----------------------------------------------------------------------------\nvoid ValidityGroup::selectAll(bool select)\n{\n    Utils::ValidityOptions options;\n    options.valid_ = select;\n    options.invalid_ = select;\n\n    setValidity(options);\n}\n\n//-----------------------------------------------------------------------------\n// Function: ValidityGroup::onValidChanged()\n//-----------------------------------------------------------------------------\nvoid ValidityGroup::onValidChanged(bool checked)\n{\n\toptions_.valid_ = checked;\n\temit optionsChanged(options_);\n}\n\n//-----------------------------------------------------------------------------\n// Function: ValidityGroup::onNonvalidChanged()\n//-----------------------------------------------------------------------------\nvoid ValidityGroup::onNonvalidChanged(bool checked)\n{\n\toptions_.invalid_ = checked;\n\temit optionsChanged(options_);\n}\n"
  },
  {
    "path": "library/VLNVDialer/ValidityGroup.h",
    "content": "//-----------------------------------------------------------------------------\n// File: ValidityGroup.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Esko Pekkarinen\n// Date: 12.09.2023\n//\n// Description:\n// Contains the check boxes to set the validity options for VLNVDialer.\n//-----------------------------------------------------------------------------\n\n#ifndef VALIDITYGROUP_H\n#define VALIDITYGROUP_H\n\n#include \"FilterGroup.h\"\n\n#include <KactusAPI/include/utils.h>\n\n#include <QGroupBox>\n#include <QPushButton>\n\n//-----------------------------------------------------------------------------\n//! Contains the check boxes to set the re-usability options for VLNVDialer.\n//-----------------------------------------------------------------------------\nclass ValidityGroup : public FilterGroup\n{\n\tQ_OBJECT\n\npublic:\n\n\t/*!\n     *  The constructor\n\t *\n\t *    @param [in] parent The owner of this widget.\n     */\n\tValidityGroup(QWidget *parent);\n\t\n\t/*!\n     *  The destructor\n     */\n\tvirtual ~ValidityGroup() = default;\n\n    //! No copying. No assignment.\n    ValidityGroup(const ValidityGroup& other) = delete;\n    ValidityGroup& operator=(const ValidityGroup& other) = delete;\n\n    /*!\n     *  Sets new validity options.\n     *\n     *    @param [in] options   The options to set.\n     */\n    void setValidity(Utils::ValidityOptions options);\n\n    /*!\n     *  Gets the selected validity options.\n     *\n     *    @return Selected validity options.\n     */\n    Utils::ValidityOptions getValidity() const;\n\n    /*!\n     *  Select/clear all filters.\n     *\n     *    @param [in] select     If true, all filters are set, otherwise all filters are cleared.\n     */\n\tvoid selectAll(bool select) override final;\n\nsignals:\n\n\t/*!\n     *  Emitted when one of the check boxes changes state.\n     */\n\tvoid optionsChanged(const Utils::ValidityOptions& options);\n\nprivate slots:\n\n\t/*!\n     *  Handler for valid check box state changes.\n     */\n\tvoid onValidChanged(bool checked);\n\n\t/*!\n     *  Handler for non-valid check box state changes.\n     */\n\tvoid onNonvalidChanged(bool checked);\n\n\nprivate:\n\n\t//! Check box to select valid items in/out of search results.\n\tQPushButton validBox_;\n\n\t//! Check box to select invalid items in/out of search results.\n\tQPushButton nonvalidBox_;\n\n\t//! Contains the current validity settings.\n\tUtils::ValidityOptions options_;\n};\n\n#endif // VALIDITYGROUP_H\n"
  },
  {
    "path": "library/VLNVDialer/dialerwidget.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: dialerwidget.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Antti Kamppi\r\n// Date: 11.07.2011\r\n//\r\n// Description:\r\n// Contains the combo boxes to set search settings for vlnv-fields.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"dialerwidget.h\"\r\n\r\n#include <KactusAPI/include/LibraryItem.h>\r\n\r\n#include <QCompleter>\r\n#include <QFormLayout>\r\n#include <QGridLayout>\r\n#include <QGroupBox>\r\n#include <QLabel>\r\n#include <QRegularExpression>\r\n#include <QRegularExpressionValidator>\r\n#include <QStringList>\r\n#include <QVBoxLayout>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DialerWidget::DialerWidget()\r\n//-----------------------------------------------------------------------------\r\nDialerWidget::DialerWidget(QWidget *parent):\r\nQWidget(parent),\r\nvendorBox_(this),\r\nlibraryBox_(this),\r\nnameBox_(this),\r\nversionBox_(this),\r\nroot_(0),\r\nvendors_(),\r\nlibraries_(),\r\nnames_(),\r\nversions_()\r\n{\r\n\tvendorBox_.setEditable(true);\r\n\tlibraryBox_.setEditable(true);\r\n\tnameBox_.setEditable(true);\r\n\tversionBox_.setEditable(true);\r\n\r\n    vendorBox_.completer()->setCompletionMode(QCompleter::PopupCompletion);\r\n    libraryBox_.completer()->setCompletionMode(QCompleter::PopupCompletion);\r\n    nameBox_.completer()->setCompletionMode(QCompleter::PopupCompletion);\r\n    versionBox_.completer()->setCompletionMode(QCompleter::PopupCompletion);\r\n\r\n\t// set validator to accept only valid names and special characters '?' and '*'\r\n\tQRegularExpression regExp(QString(\"[a-zA-Z0-9:_\\\\-\\\\.\\\\*\\\\?]*\"), QRegularExpression::CaseInsensitiveOption);\r\n\tQRegularExpressionValidator* validator = new QRegularExpressionValidator(regExp, this);\r\n\tvendorBox_.setValidator(validator);\r\n\tlibraryBox_.setValidator(validator);\r\n\tnameBox_.setValidator(validator);\r\n\tversionBox_.setValidator(validator);\r\n\r\n    setupLayout();\r\n\r\n\tconnectBoxes();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DialerWidget::~DialerWidget()\r\n//-----------------------------------------------------------------------------\r\nDialerWidget::~DialerWidget()\r\n{\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DialerWidget::setRootItem()\r\n//-----------------------------------------------------------------------------\r\nvoid DialerWidget::setRootItem(const LibraryItem* rootItem)\r\n{\r\n\troot_ = rootItem;\r\n\trefreshVendors();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DialerWidget::refreshVendors()\r\n//-----------------------------------------------------------------------------\r\nvoid DialerWidget::refreshVendors()\r\n{\r\n\tQ_ASSERT(root_);\r\n\r\n\t// get currently selected vendor search condition\r\n\tconst QString vendorText = vendorBox_.currentText();\r\n\r\n\tvendorBox_.disconnect();\r\n\tvendorBox_.clear();\r\n\tvendors_.clear();\r\n\r\n\tvendors_ = root_->getVendors();\r\n\r\n    QStringList vendorList;\r\n    for (LibraryItem const* item : vendors_) \r\n    {\r\n        vendorList.append(item->name());\r\n    }\r\n    vendorList.removeDuplicates();\r\n\r\n\tvendorBox_.addItem(QString());\r\n\tvendorBox_.addItems(vendorList);\r\n\tvendorBox_.setEditText(vendorText);\r\n\r\n\tconnect(&vendorBox_, SIGNAL(editTextChanged(const QString&)),\r\n\t\tthis, SLOT(onVendorChanged(const QString&)), Qt::UniqueConnection);\r\n\r\n\tonVendorChanged(vendorText);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DialerWidget::onVendorChanged()\r\n//-----------------------------------------------------------------------------\r\nvoid DialerWidget::onVendorChanged(QString const& vendorText)\r\n{\r\n\tQ_ASSERT(root_);\r\n\r\n\t// get currently selected library search condition\r\n\tconst QString libraryText = libraryBox_.currentText();\r\n\r\n\tlibraryBox_.disconnect();\r\n\tlibraryBox_.clear();\r\n\tlibraries_.clear();\r\n\r\n\tQString vendorExp = vendorText + \".*\";\r\n\r\n\tQRegularExpression regExp(vendorExp, QRegularExpression::CaseInsensitiveOption | QRegularExpression::DotMatchesEverythingOption);\r\n\tQRegularExpressionValidator validator(regExp, this);\r\n\r\n\t// get the library items from the vendors that matched \r\n\tint pos = 0;\r\n\tfor (LibraryItem const* item : vendors_)\r\n    {\r\n\t\tQString vendor = item->name();\r\n\t\tif (validator.validate(vendor, pos) == QValidator::Acceptable)\r\n        {\r\n\t\t\tlibraries_ += item->getLibraries();\r\n\t\t}\r\n\t}\r\n\r\n\t// add the library names to the combo box\r\n\tQStringList libraryList;\r\n    for (LibraryItem const* item : libraries_)\r\n    {\r\n        libraryList.append(item->name());\r\n    }\r\n    libraryList.removeDuplicates();\r\n\r\n\tlibraryBox_.addItem(QString());\r\n\tlibraryBox_.addItems(libraryList);\r\n\tlibraryBox_.setEditText(libraryText);\r\n\r\n\tconnect(&libraryBox_, SIGNAL(editTextChanged(const QString&)),\r\n\t\tthis, SLOT(onLibraryChanged(const QString&)), Qt::UniqueConnection);\r\n\r\n\temit vendorChanged(vendorExp);\r\n\tonLibraryChanged(libraryText);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DialerWidget::onLibraryChanged()\r\n//-----------------------------------------------------------------------------\r\nvoid DialerWidget::onLibraryChanged(QString const& libraryText)\r\n{\r\n\tQ_ASSERT(root_);\r\n\r\n\t// get currently selected name search condition\r\n\tconst QString nameText = nameBox_.currentText();\r\n\r\n\tnameBox_.disconnect();\r\n\tnameBox_.clear();\r\n\tnames_.clear();\r\n\r\n\tQString libraryExp = libraryText + \".*\";\r\n\r\n\tQRegularExpression regExp(libraryExp, QRegularExpression::CaseInsensitiveOption);\r\n\tQRegularExpressionValidator validator(regExp, this);\r\n\r\n    int pos = 0;\r\n    for (LibraryItem const* item : libraries_)\r\n    {\r\n        QString library = item->name();\r\n        if (validator.validate(library, pos) == QValidator::Acceptable)\r\n        {\r\n            names_ += item->getNames();\r\n        }\r\n    }\r\n\t\r\n\t// add the names to the combo box\r\n\tQStringList nameList;\r\n    for (LibraryItem const* item : names_)\r\n    {\r\n        nameList.append(item->name());\r\n    }\r\n    nameList.removeDuplicates();\r\n\r\n\tnameBox_.addItem(QString());\r\n\tnameBox_.addItems(nameList);\r\n\tnameBox_.setEditText(nameText);\r\n\r\n\tconnect(&nameBox_, SIGNAL(editTextChanged(const QString&)),\r\n\t\tthis, SLOT(onNameChanged(const QString&)), Qt::UniqueConnection);\r\n\r\n\temit libraryChanged(libraryExp);\r\n\tonNameChanged(nameText);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DialerWidget::onNameChanged()\r\n//-----------------------------------------------------------------------------\r\nvoid DialerWidget::onNameChanged(QString const& nameText)\r\n{\r\n\tQ_ASSERT(root_);\r\n\r\n\t// get currently selected version condition\r\n\tconst QString versionText = versionBox_.currentText();\r\n\r\n\tversionBox_.disconnect();\r\n\tversionBox_.clear();\r\n\tversions_.clear();\r\n\r\n\tQString nameExp = nameText + \".*\";\r\n\r\n\tQRegularExpression regExp(nameExp, QRegularExpression::CaseInsensitiveOption);\r\n\tQRegularExpressionValidator validator(regExp, this);\r\n\r\n\tint pos = 0;\r\n\tfor (LibraryItem const* item : names_)\r\n    {\r\n        QString name = item->name();\r\n        if (validator.validate(name, pos) == QValidator::Acceptable)\r\n        {\r\n            versions_ += item->getVersions();\r\n        }\r\n    }\r\n\r\n\t// add the names to the combo box\r\n\tQStringList versionList;\r\n    for (LibraryItem const* item : versions_)\r\n    {\r\n        versionList.append(item->name());\r\n    }\r\n    versionList.removeDuplicates();\r\n\r\n\tversionBox_.addItem(QString());\r\n\tversionBox_.addItems(versionList);\r\n\tversionBox_.setEditText(versionText);\r\n\t\r\n\tconnect(&versionBox_, SIGNAL(editTextChanged(const QString&)),\r\n\t\tthis, SLOT(onVersionChanged(const QString&)), Qt::UniqueConnection);\r\n\r\n\temit nameChanged(nameExp);\r\n\tonVersionChanged(versionText);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DialerWidget::onVersionChanged()\r\n//-----------------------------------------------------------------------------\r\nvoid DialerWidget::onVersionChanged(QString const& versionText)\r\n{\r\n\tQ_ASSERT(root_);\r\n\r\n\tQString version = versionText + \".*\";\r\n\r\n\temit versionChanged(version);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DialerWidget::setupLayout()\r\n//-----------------------------------------------------------------------------\r\nvoid DialerWidget::setupLayout()\r\n{\r\n    vendorBox_.setMaxVisibleItems(25);\r\n    vendorBox_.setMinimumWidth(80);\r\n\r\n    libraryBox_.setMaxVisibleItems(25);\r\n    libraryBox_.setMinimumWidth(80);\r\n\r\n    nameBox_.setMaxVisibleItems(25);\r\n    nameBox_.setMinimumWidth(80);\r\n\r\n    versionBox_.setMaxVisibleItems(25);\r\n    versionBox_.setMinimumWidth(80);\r\n\r\n    QVBoxLayout* topLayout = new QVBoxLayout(this);\r\n\r\n    QGroupBox* filtersGroup = new QGroupBox(tr(\"VLNV\"), this);\r\n\tfiltersGroup->setFlat(true);\r\n\r\n    QFormLayout* layout = new QFormLayout(filtersGroup);\r\n    layout->addRow(tr(\"Vendor:\"), &vendorBox_);\r\n    layout->addRow(tr(\"Library:\"), &libraryBox_);\r\n    layout->addRow(tr(\"Name:\"), &nameBox_);\r\n    layout->addRow(tr(\"Version:\"), &versionBox_);\r\n\r\n    layout->setSpacing(2);\r\n    layout->setContentsMargins(4, 2, 4, 2);\r\n\r\n    topLayout->setContentsMargins(0, 0, 0, 0);\r\n\r\n    topLayout->addWidget(filtersGroup);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DialerWidget::connectBoxes()\r\n//-----------------------------------------------------------------------------\r\nvoid DialerWidget::connectBoxes()\r\n{\r\n    connect(&vendorBox_, SIGNAL(editTextChanged(const QString&)),\r\n        this, SLOT(onVendorChanged(const QString&)), Qt::UniqueConnection);\r\n    connect(&libraryBox_, SIGNAL(editTextChanged(const QString&)),\r\n        this, SLOT(onLibraryChanged(const QString&)), Qt::UniqueConnection);\r\n    connect(&nameBox_, SIGNAL(editTextChanged(const QString&)),\r\n        this, SLOT(onNameChanged(const QString&)), Qt::UniqueConnection);\r\n    connect(&versionBox_, SIGNAL(editTextChanged(const QString&)),\r\n        this, SLOT(onVersionChanged(const QString&)), Qt::UniqueConnection);\r\n}\r\n"
  },
  {
    "path": "library/VLNVDialer/dialerwidget.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: dialerwidget.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Antti Kamppi\r\n// Date: 11.07.2011\r\n//\r\n// Description:\r\n// Contains the combo boxes to set search settings for vlnv-fields.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef DIALERWIDGET_H\r\n#define DIALERWIDGET_H\r\n\r\n#include <QWidget>\r\n#include <QString>\r\n#include <QComboBox>\r\n#include <QVector>\r\n\r\nclass LibraryItem;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Contains the combo boxes to set search settings for vlnv-fields.\r\n//-----------------------------------------------------------------------------\r\nclass DialerWidget : public QWidget\r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\r\n\t/*!\r\n     *  The constructor.\r\n\t *\r\n\t *    @param [in] parent  The owner of this widget.\r\n\t */\r\n\tDialerWidget(QWidget *parent);\r\n\t\r\n\t/*!\r\n     *  The destructor.\r\n     */\r\n\tvirtual ~DialerWidget();\r\n\r\n\t/*!\r\n     *  Set the root item used to create the suggestions for dialer.\r\n\t *\r\n\t *    @param [in] rootItem    The root item of the library.\r\n\t */\r\n\tvoid setRootItem(const LibraryItem* rootItem);\r\n\r\nsignals:\r\n\r\n\t/*!\r\n     *  Emitted when the text in vendor combobox is changed.\r\n     */\r\n\tvoid vendorChanged(QString const& vendorText);\r\n\r\n\t/*!\r\n     *  Emitted when the text in library combobox is changed.\r\n     */\r\n\tvoid libraryChanged(QString const& libraryText);\r\n\r\n\t/*!\r\n     *  Emitted when the text in name combobox is changed.\r\n     */\r\n\tvoid nameChanged(QString const& nameText);\r\n\r\n\t/*!\r\n     *  Emitted when the text in version combobox is changed.\r\n     */\r\n\tvoid versionChanged(QString const& versionText);\r\n\r\npublic slots:\r\n\r\n\t/*!\r\n     *  Refresh the vendor list\r\n     */\r\n\tvoid refreshVendors();\r\n\r\nprivate slots:\r\n\r\n\t/*!\r\n     *  Handler when the text in vendor combobox is changed.\r\n     */\r\n\tvoid onVendorChanged(QString const& vendorText);\r\n\r\n\t/*!\r\n     *  Handler when the text in library combobox is changed.\r\n     */\r\n\tvoid onLibraryChanged(QString const& libraryText);\r\n\r\n\t/*!\r\n     *  Handler when the text in name combobox is changed.\r\n     */\r\n\tvoid onNameChanged(QString const& nameText);\r\n\r\n\t/*!\r\n     *  Handler when the text in version combobox is changed.\r\n     */\r\n\tvoid onVersionChanged(QString const& versionText);\r\n\r\nprivate:\r\n\t//! No copying.\r\n\tDialerWidget(const DialerWidget& other);\r\n\tDialerWidget& operator=(const DialerWidget& other);\r\n\r\n    /*!\r\n     *  Setup the layout.\r\n     */\r\n    void setupLayout();\r\n\r\n\t/*!\r\n     *  Connect signals from combo boxes.\r\n     */\r\n\tvoid connectBoxes();\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n\t//! Box to set the vendor rules for search.\r\n\tQComboBox vendorBox_;\r\n\r\n\t//! Box to set the library rules for search.\r\n\tQComboBox libraryBox_;\r\n\r\n\t//! Box to set the name rules for search.\r\n\tQComboBox nameBox_;\r\n\r\n\t//! Box to set the version rules for search.\r\n\tQComboBox versionBox_;\r\n\r\n\t//! The root item of the library.\r\n\tconst LibraryItem* root_;\r\n\r\n\t//! The library items that represent vendors.\r\n\tQVector<LibraryItem*> vendors_;\r\n\r\n\t//! The library items that represent libraries.\r\n\tQVector<LibraryItem*> libraries_;\r\n\r\n\t//! The library items that represent names.\r\n\tQVector<LibraryItem*> names_;\r\n\r\n\t//! The library items that represent versions.\r\n\tQVector<LibraryItem*> versions_;\r\n};\r\n\r\n#endif // DIALERWIDGET_H\r\n"
  },
  {
    "path": "library/VLNVDialer/filterwidget.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: filterwidget.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Antti Kamppi\r\n// Date: 11.07.2011\r\n//\r\n// Description:\r\n// Contains the widgets to set the filter options for VLNVDialer.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"filterwidget.h\"\r\n\r\n#include <QVBoxLayout>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FilterWidget::FilterWidget()\r\n//-----------------------------------------------------------------------------\r\nFilterWidget::FilterWidget(QWidget *parent):\r\nQWidget(parent),\r\nfirmness_(this),\r\nimplementation_(this),\r\ntype_(this),\r\nhierarchy_(this),\r\nvalidity_(this),\r\nrevision_(this)\r\n{\r\n\tQVBoxLayout* layout = new QVBoxLayout(this);\r\n\tlayout->addWidget(&type_);\r\n\tlayout->addWidget(&implementation_);\r\n\tlayout->addWidget(&hierarchy_);\r\n    layout->addWidget(&firmness_);\r\n    layout->addWidget(&validity_);\r\n    layout->addWidget(&revision_);\r\n\tlayout->addStretch();\r\n\tlayout->setSpacing(0);\r\n\tlayout->setContentsMargins(0, 0, 0, 0);\r\n\r\n\tconnect(&firmness_, SIGNAL(optionsChanged(const Utils::FirmnessOptions&)),\r\n\t\tthis, SIGNAL(firmnessChanged(const Utils::FirmnessOptions&)), Qt::UniqueConnection);\r\n\tconnect(&implementation_, SIGNAL(optionsChanged(const Utils::ImplementationOptions&)),\r\n\t\tthis, SIGNAL(implementationChanged(const Utils::ImplementationOptions&)), Qt::UniqueConnection);\r\n\tconnect(&type_, SIGNAL(optionsChanged(const Utils::TypeOptions&)),\r\n\t\tthis, SIGNAL(typeChanged(const Utils::TypeOptions&)), Qt::UniqueConnection);\r\n\tconnect(&hierarchy_, SIGNAL(optionsChanged(const Utils::HierarchyOptions&)),\r\n\t\tthis, SIGNAL(hierarchyChanged(const Utils::HierarchyOptions&)), Qt::UniqueConnection);\r\n    connect(&revision_, SIGNAL(optionsChanged(const Utils::RevisionOptions&)),\r\n        this, SIGNAL(revisionChanged(const Utils::RevisionOptions&)), Qt::UniqueConnection);\r\n    connect(&validity_, SIGNAL(optionsChanged(const Utils::ValidityOptions&)),\r\n               this, SIGNAL(validityChanged(const Utils::ValidityOptions&)), Qt::UniqueConnection);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FilterWidget::setFilters()\r\n//-----------------------------------------------------------------------------\r\nvoid FilterWidget::setFilters(Utils::FilterOptions options)\r\n{\r\n    blockSignals(true);\r\n    type_.setTypes(options.type);  \r\n    implementation_.setImplementation(options.implementation);  \r\n    hierarchy_.setHierarchy(options.hierarchy);  \r\n    firmness_.setFirmness(options.firmness);\r\n    revision_.setRevision(options.revision);\r\n    validity_.setValidity(options.validity);\r\n    blockSignals(false);\r\n\r\n    emit optionsChanged(options);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FilterWidget::getFilters()\r\n//-----------------------------------------------------------------------------\r\nUtils::FilterOptions FilterWidget::getFilters() const\r\n{\r\n    Utils::FilterOptions options;\r\n    options.type = type_.getTypes();\r\n    options.implementation = implementation_.getImplementation();\r\n    options.hierarchy = hierarchy_.getHierarchy();\r\n    options.firmness = firmness_.getFirmness();\r\n    options.revision = revision_.getRevision();\r\n    options.validity = validity_.getValidity();\r\n    return options;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FilterWidget::selectAll()\r\n//-----------------------------------------------------------------------------\r\nvoid FilterWidget::selectAll(bool select)\r\n{\r\n    type_.selectAll(select);\r\n    implementation_.selectAll(select);\r\n    hierarchy_.selectAll(select);\r\n    firmness_.selectAll(select);\r\n    revision_.selectAll(select);\r\n    validity_.selectAll(select);\r\n}\r\n"
  },
  {
    "path": "library/VLNVDialer/filterwidget.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: filterwidget.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Antti Kamppi\r\n// Date: 11.07.2011\r\n//\r\n// Description:\r\n// Contains the widgets to set the filter options for VLNVDialer.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef FILTERWIDGET_H\r\n#define FILTERWIDGET_H\r\n\r\n#include <KactusAPI/include/utils.h>\r\n\r\n#include \"firmnessgroup.h\"\r\n#include \"implementationgroup.h\"\r\n#include \"typegroup.h\"\r\n#include \"hierarchygroup.h\"\r\n#include \"RevisionGroup.h\"\r\n#include \"ValidityGroup.h\"\r\n\r\n#include <QWidget>\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Contains the widgets to set the filter options for VLNVDialer.\r\n//-----------------------------------------------------------------------------\r\nclass FilterWidget : public QWidget\r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\r\n\t/*!\r\n     *  The constructor\r\n\t *\r\n\t *    @param [in] parent The owner of this widget.\r\n\t */\r\n\tFilterWidget(QWidget *parent);\r\n\t\r\n\t/*!\r\n     *  The destructor.\r\n     */\r\n\tvirtual ~FilterWidget() = default;\r\n\r\n    //! No copying. No assignment.\r\n    FilterWidget(const FilterWidget& other) = delete;\r\n    FilterWidget& operator=(const FilterWidget& other) = delete;\r\n\r\n    /*!\r\n     *  Setup the filters.\r\n     *\r\n     *    @param [in] options     New filter options.\r\n     */\r\n    void setFilters(Utils::FilterOptions options);\r\n\r\n    /*!\r\n     *  Get the filters.\r\n     *\r\n     *    @return The current filter options.\r\n     */\r\n    Utils::FilterOptions getFilters() const;\r\n\r\n    /*!\r\n     *  Select/clear all filters.\r\n     *\r\n     *    @param [in] select     If true, all filters are set, otherwise all filters are cleared.\r\n     */\r\n\tvoid selectAll(bool select);\r\n\r\nsignals:\r\n\r\n\t/*!\r\n     *  Emitted when re-usability options change.\r\n     */\r\n\tvoid firmnessChanged(const Utils::FirmnessOptions& options);\r\n\r\n\t/*!\r\n     *  Emitted when firmness options change.\r\n     */\r\n\tvoid implementationChanged(const Utils::ImplementationOptions& options);\r\n\r\n\t/*!\r\n     *  Emitted when type options change.\r\n     */\r\n\tvoid typeChanged(const Utils::TypeOptions& options);\r\n\r\n\t/*!\r\n     *  Emitted when hierarchy options change.\r\n     */\r\n\tvoid hierarchyChanged(const Utils::HierarchyOptions& options);\r\n\r\n    /*!\r\n     *  Emitted when revision options change.\r\n     */\r\n    void revisionChanged(const Utils::RevisionOptions& options);\r\n\r\n    /*!\r\n     *  Emitted when validity options change.\r\n     */\r\n    void validityChanged(const Utils::ValidityOptions& options);\r\n\r\n    /*!\r\n     *  Emitted when all options change.\r\n     */\r\n    void optionsChanged(Utils::FilterOptions const& options);\r\n\r\nprivate:\r\n\r\n\t//! Contains items to select the re-usability options.\r\n\tFirmnessGroup firmness_;\r\n\r\n\t//! Contains items to select the firmness options.\r\n\tImplementationGroup implementation_;\r\n\r\n\t//! Contains items to select the type options.\r\n\tTypeGroup type_;\r\n\r\n\t//! Contains items to select the hierarchy options.\r\n\tHierarchyGroup hierarchy_;\r\n\r\n    //! Contains items to select the validity options.\r\n    ValidityGroup validity_;\r\n\r\n    //! Contains items to select the revision options.\r\n    RevisionGroup revision_;\r\n};\r\n\r\n#endif // FILTERWIDGET_H\r\n"
  },
  {
    "path": "library/VLNVDialer/firmnessgroup.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: firmnessgroup.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Antti Kamppi\r\n// Date: 11.07.2011\r\n//\r\n// Description:\r\n// Contains the check boxes to set the re-usability options for VLNVDialer.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"firmnessgroup.h\"\r\n\r\n#include <KactusAPI/include/utils.h>\r\n\r\n#include <common/widgets/tagEditor/FlowLayout.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FirmnessGroup::FirmnessGroup()\r\n//-----------------------------------------------------------------------------\r\nFirmnessGroup::FirmnessGroup(QWidget *parent):\r\nFilterGroup(tr(\"Firmness\"), parent),\r\ntemplateBox_(QIcon(\":/icons/common/graphics/template.png\"), QString(), this),\r\nmutableBox_(QIcon(\":/icons/common/graphics/mutable.png\"), QString(), this),\r\nfixedBox_(QIcon(\":/icons/common/graphics/fixed.png\"), QString(), this),\r\noptions_()\r\n{\r\n    setupButton(&templateBox_, tr(\"Template\"));\r\n    setupButton(&mutableBox_, tr(\"Mutable\"));\r\n    setupButton(&fixedBox_, tr(\"Fixed\"));\r\n\r\n\ttemplateBox_.setChecked(true);\r\n\tmutableBox_.setChecked(true);\r\n\tfixedBox_.setChecked(true);\r\n\r\n    connect(&templateBox_, SIGNAL(clicked(bool)), this, SLOT(onTemplateChanged(bool)), Qt::UniqueConnection);\r\n    connect(&mutableBox_, SIGNAL(clicked(bool)), this, SLOT(onMutableChanged(bool)), Qt::UniqueConnection);\r\n    connect(&fixedBox_, SIGNAL(clicked(bool)), this, SLOT(onConfigurationChanged(bool)), Qt::UniqueConnection);\r\n\r\n    auto layout = new FlowLayout(this, 2, 1, 1);\r\n    layout->addWidget(&templateBox_);\r\n    layout->addWidget(&mutableBox_);\r\n    layout->addWidget(&fixedBox_);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FirmnessGroup::setFirmness()\r\n//-----------------------------------------------------------------------------\r\nvoid FirmnessGroup::setFirmness(Utils::FirmnessOptions options)\r\n{    \r\n    templateBox_.setChecked(options.templates_);\r\n    mutableBox_.setChecked(options.mutable_);\r\n    fixedBox_.setChecked(options.fixed_);\r\n\r\n    options_ = options;\r\n    emit optionsChanged(options_);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FirmnessGroup::getFirmness()\r\n//-----------------------------------------------------------------------------\r\nUtils::FirmnessOptions FirmnessGroup::getFirmness() const\r\n{\r\n    Utils::FirmnessOptions options;\r\n    options.templates_ = templateBox_.isChecked();\r\n    options.mutable_ = mutableBox_.isChecked();\r\n    options.fixed_ = fixedBox_.isChecked();\r\n    return options;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FirmnessGroup::selectAll()\r\n//-----------------------------------------------------------------------------\r\nvoid FirmnessGroup::selectAll(bool select)\r\n{\r\n    Utils::FirmnessOptions options;\r\n    options.templates_ = select;\r\n    options.mutable_ = select;\r\n    options.fixed_ = select;\r\n\r\n    setFirmness(options);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FirmnessGroup::onTemplateChanged()\r\n//-----------------------------------------------------------------------------\r\nvoid FirmnessGroup::onTemplateChanged(bool checked)\r\n{\r\n\toptions_.templates_ = checked;\r\n\temit optionsChanged(options_);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FirmnessGroup::onMutableChanged()\r\n//-----------------------------------------------------------------------------\r\nvoid FirmnessGroup::onMutableChanged(bool checked)\r\n{\r\n\toptions_.mutable_ = checked;\r\n\temit optionsChanged(options_);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FirmnessGroup::onConfigurationChanged()\r\n//-----------------------------------------------------------------------------\r\nvoid FirmnessGroup::onConfigurationChanged(bool checked)\r\n{\r\n\toptions_.fixed_ = checked;\r\n\temit optionsChanged(options_);\r\n}\r\n"
  },
  {
    "path": "library/VLNVDialer/firmnessgroup.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: firmnessgroup.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Antti Kamppi\r\n// Date: 11.07.2011\r\n//\r\n// Description:\r\n// Contains the check boxes to set the re-usability options for VLNVDialer.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef FIRMNESSGROUP_H\r\n#define FIRMNESSGROUP_H\r\n\r\n#include \"FilterGroup.h\"\r\n\r\n#include <KactusAPI/include/utils.h>\r\n\r\n#include <QGroupBox>\r\n#include <QPushButton>\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Contains the check boxes to set the re-usability options for VLNVDialer.\r\n//-----------------------------------------------------------------------------\r\nclass FirmnessGroup : public FilterGroup\r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\r\n\t/*!\r\n     *  The constructor\r\n\t *\r\n\t *    @param [in] parent The owner of this widget.\r\n     */\r\n\tFirmnessGroup(QWidget *parent);\r\n\t\r\n\t/*!\r\n     *  The destructor\r\n     */\r\n\tvirtual ~FirmnessGroup() = default;\r\n\r\n    //! No copying. No assignment.\r\n    FirmnessGroup(const FirmnessGroup& other) = delete;\r\n    FirmnessGroup& operator=(const FirmnessGroup& other) = delete;\r\n\r\n    /*!\r\n     *  Sets new firmness options.\r\n     *\r\n     *    @param [in] options   The options to set.\r\n     */\r\n    void setFirmness(Utils::FirmnessOptions options);\r\n\r\n    /*!\r\n     *  Gets the selected firmness options.\r\n     *\r\n     *    @return Selected firmness options.\r\n     */\r\n    Utils::FirmnessOptions getFirmness() const;\r\n\r\n    /*!\r\n     *  Select/clear all filters.\r\n     *\r\n     *    @param [in] select     If true, all filters are set, otherwise all filters are cleared.\r\n     */\r\n\tvoid selectAll(bool select) override final;\r\n\r\nsignals:\r\n\r\n\t/*!\r\n     *  Emitted when one of the check boxes changes state.\r\n     */\r\n\tvoid optionsChanged(const Utils::FirmnessOptions& options);\r\n\r\nprivate slots:\r\n\r\n\t/*!\r\n     *  Handler for template check box state changes.\r\n     */\r\n\tvoid onTemplateChanged(bool checked);\r\n\r\n\t/*!\r\n     *  Handler for mutable check box state changes.\r\n     */\r\n\tvoid onMutableChanged(bool checked);\r\n\r\n\t/*!\r\n     *  Handler for configuration check box state changes.\r\n     */\r\n\tvoid onConfigurationChanged(bool checked);\r\n\r\nprivate:\r\n\r\n\t//! Check box to select templates in/out of search results.\r\n\tQPushButton templateBox_;\r\n\r\n\t//! Check box to select mutable in/out of search results.\r\n\tQPushButton mutableBox_;\r\n\r\n\t//! Check box to select fixed in/out of search results.\r\n\tQPushButton fixedBox_;\r\n\r\n\t//! Contains the current re-usability settings.\r\n\tUtils::FirmnessOptions options_;\r\n};\r\n\r\n#endif // FIRMNESSGROUP_H\r\n"
  },
  {
    "path": "library/VLNVDialer/hierarchygroup.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: hierarchygroup.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Antti Kamppi\r\n// Date: 11.07.2011\r\n//\r\n// Description:\r\n// Contains the check boxes to set the hierarchy options for VLNVDialer.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"hierarchygroup.h\"\r\n\r\n#include <KactusAPI/include/utils.h>\r\n\r\n#include <common/widgets/tagEditor/FlowLayout.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HierarchyGroup::HierarchyGroup()\r\n//-----------------------------------------------------------------------------\r\nHierarchyGroup::HierarchyGroup(QWidget *parent):\r\n\tFilterGroup(tr(\"Product Hierarchy\"), parent),\r\nflatBox_(QIcon(\":icons/common/graphics/square.png\"), QString(), this),\r\nproductBox_(QIcon(\":icons/common/graphics/box.png\"), QString(), this),\r\nboardBox_(QIcon(\":icons/common/graphics/circuit.png\"), QString(), this),\r\nchipBox_(QIcon(\":icons/common/graphics/chip.png\"), QString(), this),\r\nsocBox_(QIcon(\":icons/common/graphics/soc.png\"), QString(), this),\r\nipBox_(QIcon(\":icons/common/graphics/capacitor.png\"), QString(), this),\r\noptions_()\r\n{\r\n    setupButton(&flatBox_, tr(\"Flat\"));\r\n    setupButton(&productBox_, tr(\"Product\"));\r\n    setupButton(&boardBox_, tr(\"Board\"));\r\n    setupButton(&chipBox_, tr(\"Chip\"));\r\n    setupButton(&socBox_, tr(\"SoC\"));\r\n\tsetupButton(&ipBox_, tr(\"IP\"));\r\n\r\n\tauto layout = new FlowLayout(this, 2, 1, 1);\r\n\tlayout->addWidget(&productBox_);\r\n\tlayout->addWidget(&boardBox_);\r\n\tlayout->addWidget(&chipBox_);\r\n\tlayout->addWidget(&socBox_);\r\n    layout->addWidget(&ipBox_);\r\n    layout->addWidget(&flatBox_);\r\n\r\n\tflatBox_.setChecked(true);\r\n\tproductBox_.setChecked(true);\r\n\tboardBox_.setChecked(true);\r\n\tchipBox_.setChecked(true);\r\n\tsocBox_.setChecked(true);\r\n\tipBox_.setChecked(true);\r\n\r\n\tconnect(&flatBox_, SIGNAL(clicked(bool)), this, SLOT(onFlatChange(bool)), Qt::UniqueConnection);\r\n\tconnect(&productBox_, SIGNAL(clicked(bool)), this, SLOT(onProductChange(bool)), Qt::UniqueConnection);\r\n\tconnect(&boardBox_, SIGNAL(clicked(bool)), this, SLOT(onBoardChange(bool)), Qt::UniqueConnection);\r\n\tconnect(&chipBox_, SIGNAL(clicked(bool)), this, SLOT(onChipChange(bool)), Qt::UniqueConnection);\r\n\tconnect(&socBox_, SIGNAL(clicked(bool)), this, SLOT(onSocChange(bool)), Qt::UniqueConnection);\r\n\tconnect(&ipBox_, SIGNAL(clicked(bool)),\tthis, SLOT(onIpChange(bool)), Qt::UniqueConnection);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HierarchyGroup::setHierarchy()\r\n//-----------------------------------------------------------------------------\r\nvoid HierarchyGroup::setHierarchy(Utils::HierarchyOptions options)\r\n{\r\n    flatBox_.setChecked(options.flat_);\r\n    productBox_.setChecked(options.product_);\r\n    boardBox_.setChecked(options.board_);    \r\n    chipBox_.setChecked(options.chip_);\r\n    socBox_.setChecked(options.soc_);\r\n    ipBox_.setChecked(options.ip_);\r\n\r\n    options_ = options;\r\n    emit optionsChanged(options_);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HierarchyGroup::getHierarchy()\r\n//-----------------------------------------------------------------------------\r\nUtils::HierarchyOptions HierarchyGroup::getHierarchy() const\r\n{\r\n    Utils::HierarchyOptions options;\r\n    options.flat_ = flatBox_.isChecked();\r\n    options.product_ = productBox_.isChecked();\r\n    options.board_ = boardBox_.isChecked();\r\n    options.chip_ = chipBox_.isChecked();\r\n    options.soc_ = socBox_.isChecked();\r\n    options.ip_ = ipBox_.isChecked();\r\n    return options;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HierarchyGroup::selectAll()\r\n//-----------------------------------------------------------------------------\r\nvoid HierarchyGroup::selectAll(bool select)\r\n{\r\n    Utils::HierarchyOptions options;\r\n    options.flat_ = select;\r\n    options.product_ = select;\r\n    options.board_ = select;\r\n    options.chip_ = select;\r\n    options.soc_ = select;\r\n    options.ip_ = select;\r\n\r\n\tsetHierarchy(options);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HierarchyGroup::onFlatChange()\r\n//-----------------------------------------------------------------------------\r\nvoid HierarchyGroup::onFlatChange(bool checked)\r\n{\r\n\toptions_.flat_ = checked;\r\n\temit optionsChanged(options_);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HierarchyGroup::onProductChange()\r\n//-----------------------------------------------------------------------------\r\nvoid HierarchyGroup::onProductChange(bool checked)\r\n{\r\n\toptions_.product_ = checked;\r\n\temit optionsChanged(options_);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HierarchyGroup::onBoardChange()\r\n//-----------------------------------------------------------------------------\r\nvoid HierarchyGroup::onBoardChange(bool checked)\r\n{\r\n\toptions_.board_ = checked;\r\n\temit optionsChanged(options_);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HierarchyGroup::onChipChange()\r\n//-----------------------------------------------------------------------------\r\nvoid HierarchyGroup::onChipChange(bool checked)\r\n{\r\n\toptions_.chip_ = checked;\r\n\temit optionsChanged(options_);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HierarchyGroup::onSocChange()\r\n//-----------------------------------------------------------------------------\r\nvoid HierarchyGroup::onSocChange(bool checked)\r\n{\r\n\toptions_.soc_ = checked;\r\n\temit optionsChanged(options_);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HierarchyGroup::onIpChange()\r\n//-----------------------------------------------------------------------------\r\nvoid HierarchyGroup::onIpChange(bool checked)\r\n{\r\n\toptions_.ip_ = checked;\r\n\temit optionsChanged(options_);\r\n}"
  },
  {
    "path": "library/VLNVDialer/hierarchygroup.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: hierarchygroup.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Antti Kamppi\r\n// Date: 11.07.2011\r\n//\r\n// Description:\r\n// Contains the check boxes to set the hierarchy options for VLNVDialer.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef HIERARCHYGROUP_H\r\n#define HIERARCHYGROUP_H\r\n\r\n#include \"FilterGroup.h\"\r\n\r\n#include <KactusAPI/include/utils.h>\r\n\r\n#include <QGroupBox>\r\n#include <QPushButton>\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Contains the check boxes to set the hierarchy options for VLNVDialer.\r\n//-----------------------------------------------------------------------------\r\nclass HierarchyGroup : public FilterGroup\r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\r\n\t/*!\r\n     *  The constructor.\r\n\t *\r\n\t *    @param [in] parent The owner of this widget.\r\n\t */\r\n\tHierarchyGroup(QWidget *parent);\r\n\t\r\n\t/*!\r\n     *  The destructor.\r\n     */\r\n\tvirtual ~HierarchyGroup() = default;\r\n\r\n    //! No copying. No assignment.\r\n    HierarchyGroup(const HierarchyGroup& other) = delete;\r\n    HierarchyGroup& operator=(const HierarchyGroup& other) = delete;\r\n\r\n    /*!\r\n     *  Sets new hierarchy options.\r\n     *\r\n     *    @param [in] options   The options to set.\r\n     */\r\n    void setHierarchy(Utils::HierarchyOptions options);\r\n\r\n    /*!\r\n     *  Gets the selected hierarchy options.\r\n     *\r\n     *    @return Selected hierarchy options.\r\n     */\r\n    Utils::HierarchyOptions getHierarchy() const;\r\n\r\n\t/*!\r\n\t *  Select/clear all filters.\r\n\t *\r\n\t *    @param [in] select     If true, all filters are set, otherwise all filters are cleared.\r\n\t */\r\n\tvoid selectAll(bool select) override final;\r\n\r\nsignals:\r\n\r\n\t/*!\r\n     *  Emitted when hierarchy options change.\r\n     */\r\n\tvoid optionsChanged(const Utils::HierarchyOptions& options);\r\n\r\nprivate slots:\r\n\r\n\t/*!\r\n     *  Handler for global box state changes.\r\n     */\r\n\tvoid onFlatChange(bool checked);\r\n\r\n\t/*!\r\n     *  Handler for product box state changes.\r\n     */\r\n\tvoid onProductChange(bool checked);\r\n\r\n\t/*!\r\n     *  Handler for board box state changes.\r\n     */\r\n\tvoid onBoardChange(bool checked);\r\n\r\n\t/*!\r\n     *  Handler for chip box state changes.\r\n     */\r\n\tvoid onChipChange(bool checked);\r\n\r\n\t/*!\r\n     *  Handler for soc box state changes.\r\n     */\r\n\tvoid onSocChange(bool checked);\r\n\r\n\t/*!\r\n     *  Handler for ip box state changes.\r\n     */\r\n\tvoid onIpChange(bool checked);\r\n\r\nprivate:\r\n\r\n\t//! Check box to select global components in/out of search results.\r\n\tQPushButton flatBox_;\r\n\r\n\t//! Check box to select product components in/out of search results.\r\n\tQPushButton productBox_;\r\n\r\n\t//! Check box to select board components in/out of search results.\r\n\tQPushButton boardBox_;\r\n\r\n\t//! Check box to select chip components in/out of search results.\r\n\tQPushButton chipBox_;\r\n\r\n\t//! Check box to select SoC components in/out of search results.\r\n\tQPushButton socBox_;\r\n\r\n\t//! Check box to select IP components in/out of search results.\r\n\tQPushButton ipBox_;\r\n\r\n\t//! Contains the current search settings for hierarchy\r\n\tUtils::HierarchyOptions options_;\r\n};\r\n\r\n#endif // HIERARCHYGROUP_H\r\n"
  },
  {
    "path": "library/VLNVDialer/implementationgroup.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: implementationgroup.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Antti Kamppi\r\n// Date: 11.07.2011\r\n//\r\n// Description:\r\n// Contains check boxes to set the implementation options for VLNVDialer.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"implementationgroup.h\"\r\n\r\n#include <common/widgets/tagEditor/FlowLayout.h>\r\n\r\n#include <QIcon>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ImplementationGroup::ImplementationGroup()\r\n//-----------------------------------------------------------------------------\r\nImplementationGroup::ImplementationGroup(QWidget* parent) :\r\n    FilterGroup(tr(\"Implementation\"), parent),\r\n    hwBox_(QIcon(\":icons/common/graphics/transistor.png\"), QString(), this),\r\n    swBox_(QIcon(\":icons/common/graphics/sw-component48x48.png\"), QString(), this),\r\n    systemBox_(QIcon(\":icons/common/graphics/system-component.png\"), QString(), this),\r\n    options_()\r\n{\r\n    setupButton(&hwBox_, tr(\"HW\"));\r\n    setupButton(&swBox_, tr(\"SW\"));\r\n    setupButton(&systemBox_, tr(\"System\"));\r\n\r\n    hwBox_.setChecked(true);\r\n\tswBox_.setChecked(true);\r\n\tsystemBox_.setChecked(true);\r\n\r\n\tconnect(&hwBox_, SIGNAL(clicked(bool)),\tthis, SLOT(onHWChanged(bool)), Qt::UniqueConnection);\r\n\tconnect(&swBox_, SIGNAL(clicked(bool)),\tthis, SLOT(onSWChanged(bool)), Qt::UniqueConnection);\r\n\tconnect(&systemBox_, SIGNAL(clicked(bool)),\tthis, SLOT(onSystemChanged(bool)), Qt::UniqueConnection);\r\n\r\n    setupLayout();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ImplementationGroup::setImplementation()\r\n//-----------------------------------------------------------------------------\r\nvoid ImplementationGroup::setImplementation(Utils::ImplementationOptions options)\r\n{\r\n    hwBox_.setChecked(options.hw_);\r\n    swBox_.setChecked(options.sw_);\r\n    systemBox_.setChecked(options.system_);\r\n\r\n    options_ = options;\r\n    emit optionsChanged(options_);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ImplementationGroup::getImplementation()\r\n//-----------------------------------------------------------------------------\r\nUtils::ImplementationOptions ImplementationGroup::getImplementation() const\r\n{\r\n    Utils::ImplementationOptions options;\r\n    options.hw_ = hwBox_.isChecked();\r\n    options.sw_ = swBox_.isChecked();\r\n    options.system_ = systemBox_.isChecked();\r\n    return options;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ImplementationGroup::selectAll()\r\n//-----------------------------------------------------------------------------\r\nvoid ImplementationGroup::selectAll(bool select)\r\n{\r\n    Utils::ImplementationOptions options;\r\n    options.hw_ = select;\r\n    options.sw_ = select;\r\n    options.system_ = select;\r\n    \r\n    setImplementation(options);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ImplementationGroup::onHWChanged()\r\n//-----------------------------------------------------------------------------\r\nvoid ImplementationGroup::onHWChanged(bool checked)\r\n{\r\n\toptions_.hw_ = checked;\r\n\temit optionsChanged(options_);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ImplementationGroup::onSWChanged()\r\n//-----------------------------------------------------------------------------\r\nvoid ImplementationGroup::onSWChanged(bool checked)\r\n{\r\n\toptions_.sw_ = checked;\r\n\temit optionsChanged(options_);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ImplementationGroup::onSystemChanged()\r\n//-----------------------------------------------------------------------------\r\nvoid ImplementationGroup::onSystemChanged(bool checked)\r\n{\r\n\toptions_.system_ = checked;\r\n\temit optionsChanged(options_);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: TypeGroup::setupLayout()\r\n//-----------------------------------------------------------------------------\r\nvoid ImplementationGroup::setupLayout()\r\n{\r\n    auto layout = new FlowLayout(this, 2, 1, 1);\r\n    layout->addWidget(&hwBox_);\r\n    layout->addWidget(&swBox_);\r\n    layout->addWidget(&systemBox_);\r\n    //layout->setSpacing(0);\r\n    //layout->setColumnStretch(3, 1);\r\n    //layout->setContentsMargins(4, 4, 4, 4);\r\n}\r\n\r\n"
  },
  {
    "path": "library/VLNVDialer/implementationgroup.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: implementationgroup.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Antti Kamppi\r\n// Date: 11.07.2011\r\n//\r\n// Description:\r\n// Contains check boxes to set the implementation options for VLNVDialer.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef IMPLEMENTATIONGROUP_H\r\n#define IMPLEMENTATIONGROUP_H\r\n\r\n#include \"FilterGroup.h\"\r\n\r\n#include <KactusAPI/include/utils.h>\r\n\r\n#include <QPushButton>\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Contains check boxes to set the implementation options for VLNVDialer.\r\n//-----------------------------------------------------------------------------\r\nclass ImplementationGroup : public FilterGroup\r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\r\n\t/*!\r\n     *  The constructor\r\n\t *\r\n\t *    @param [in] parent The owner of this widget.\r\n\t */\r\n\tImplementationGroup(QWidget *parent);\r\n\t\r\n\t/*!\r\n     *  The destructor.\r\n     */\r\n\tvirtual ~ImplementationGroup() = default;\r\n\r\n    //! No copying. No assignment.\r\n    ImplementationGroup(const ImplementationGroup& other) = delete;\r\n    ImplementationGroup& operator=(const ImplementationGroup& other) = delete;\r\n\r\n    /*!\r\n     *  Sets new implementation options.\r\n     *\r\n     *    @param [in] options   The options to set.\r\n     */\r\n    void setImplementation(Utils::ImplementationOptions options);\r\n\r\n    /*!\r\n     *  Gets the selected implementation options.\r\n     *\r\n     *    @return Selected implementation options.\r\n     */\r\n    Utils::ImplementationOptions getImplementation() const;\r\n\r\n\t/*!\r\n\t *  Select/clear all filters.\r\n\t *\r\n\t *    @param [in] select     If true, all filters are set, otherwise all filters are cleared.\r\n\t */\r\n    void selectAll(bool select) override final;\r\n\r\nsignals:\r\n\r\n\t/*!\r\n     *  Emitted when implementation options changes state.\r\n     */\r\n\tvoid optionsChanged(const Utils::ImplementationOptions& options);\r\n\r\nprivate slots:\r\n\r\n\t/*!\r\n     *  Handler for hwBox state changes.\r\n     */\r\n\tvoid onHWChanged(bool checked);\r\n\r\n\t/*!\r\n     *  Handler for swBox state changes.\r\n     */\r\n\tvoid onSWChanged(bool checked);\r\n\r\n\t/*!\r\n     *  Handler for systemBox state changes.\r\n     */\r\n\tvoid onSystemChanged(bool checked);\r\n\r\nprivate:\r\n\r\n\t//! Setup the widget layout.\r\n    void setupLayout();\r\n\r\n\t//! Check box to select hardware components in/out of search results.\r\n\tQPushButton hwBox_;\r\n\r\n\t//! Check box to select software component in/out of search results.\r\n\tQPushButton swBox_;\r\n\r\n\t//! Check box to select system components in/out of search results.\r\n\tQPushButton systemBox_;\r\n\r\n\t//! Contains the current search settings.\r\n\tUtils::ImplementationOptions options_;\r\n};\r\n\r\n#endif // IMPLEMENTATIONGROUP_H\r\n"
  },
  {
    "path": "library/VLNVDialer/typegroup.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: typegroup.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Antti Kamppi\r\n// Date: 11.07.2011\r\n//\r\n// Description:\r\n// Contains the check boxes to set the type options for VLNVDialer.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"typegroup.h\"\r\n\r\n#include <common/widgets/tagEditor/FlowLayout.h>\r\n\r\n#include <QIcon>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: TypeGroup::TypeGroup()\r\n//-----------------------------------------------------------------------------\r\nTypeGroup::TypeGroup(QWidget *parent):\r\nFilterGroup(tr(\"Type\"), parent),\r\ncomponentBox_(QIcon(\":icons/common/graphics/hw-component.png\"), QString(), this),\r\nbusBox_(QIcon(\":icons/common/graphics/bus-def.png\"), QString(), this),\r\ncatalogBox_(QIcon(\":icons/common/graphics/catalog.png\"), QString(), this),\r\napiComBox_(QIcon(\":icons/common/graphics/new-com_definition.png\"), QString(), this),\r\nadvancedBox_(QIcon(\":icons/common/graphics/hw-design.png\"), QString(), this),\r\noptions_()\r\n{\r\n    setupButton(&componentBox_, tr(\"Component\"));\r\n    setupButton(&busBox_, tr(\"Bus\"));\r\n    setupButton(&catalogBox_, tr(\"Catalog\"));\r\n    setupButton(&apiComBox_, tr(\"API/COM definition\"));\r\n    setupButton(&advancedBox_, tr(\"Advanced\"));\r\n\r\n\tcomponentBox_.setChecked(true);\r\n\tbusBox_.setChecked(true);\r\n    catalogBox_.setChecked(true);\r\n    apiComBox_.setChecked(true);\r\n\tadvancedBox_.setChecked(false);\r\n\r\n\tconnect(&componentBox_, SIGNAL(clicked(bool)), this, SLOT(onComponentChange(bool)), Qt::UniqueConnection);\r\n\tconnect(&busBox_, SIGNAL(clicked(bool)), this, SLOT(onBusChange(bool)), Qt::UniqueConnection);\r\n    connect(&catalogBox_, SIGNAL(clicked(bool)), this, SLOT(onCatalogChange(bool)), Qt::UniqueConnection);\r\n\tconnect(&apiComBox_, SIGNAL(clicked(bool)), this, SLOT(onApiComChange(bool)), Qt::UniqueConnection);\r\n    connect(&advancedBox_, SIGNAL(clicked(bool)), this, SLOT(onAdvancedChange(bool)), Qt::UniqueConnection);    \r\n\r\n    setupLayout();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: TypeGroup::setType()\r\n//-----------------------------------------------------------------------------\r\nvoid TypeGroup::setTypes(Utils::TypeOptions options)\r\n{\r\n    componentBox_.setChecked(options.components_);\r\n    busBox_.setChecked(options.buses_);\r\n    catalogBox_.setChecked(options.catalogs_);\r\n    apiComBox_.setChecked(options.apis_);\r\n    advancedBox_.setChecked(options.advanced_);\r\n\r\n    options_ = options;\r\n    emit optionsChanged(options_);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: TypeGroup::getType()\r\n//-----------------------------------------------------------------------------\r\nUtils::TypeOptions TypeGroup::getTypes() const\r\n{\r\n    Utils::TypeOptions options;\r\n    options.components_ = componentBox_.isChecked();\r\n    options.buses_ = busBox_.isChecked();\r\n    options.catalogs_ = catalogBox_.isChecked();\r\n    options.apis_ = apiComBox_.isChecked();\r\n    options.advanced_ = advancedBox_.isChecked();\r\n\r\n    return options;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: TypeGroup::selectAll()\r\n//-----------------------------------------------------------------------------\r\nvoid TypeGroup::selectAll(bool select)\r\n{\r\n    Utils::TypeOptions options;\r\n    options.components_ = select;\r\n    options.buses_ = select;\r\n    options.catalogs_ = select;\r\n    options.apis_ = select;\r\n    options.advanced_ = select;\r\n\r\n    setTypes(options);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: TypeGroup::onComponentChange()\r\n//-----------------------------------------------------------------------------\r\nvoid TypeGroup::onComponentChange(bool checked)\r\n{\r\n\toptions_.components_ = checked;\r\n\temit optionsChanged(options_);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: TypeGroup::onBusChange()\r\n//-----------------------------------------------------------------------------\r\nvoid TypeGroup::onBusChange(bool checked)\r\n{\r\n\toptions_.buses_ = checked;\r\n\temit optionsChanged(options_);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: TypeGroup::onCatalogChange()\r\n//-----------------------------------------------------------------------------\r\nvoid TypeGroup::onCatalogChange(bool checked)\r\n{\r\n    options_.catalogs_ = checked;\r\n    emit optionsChanged(options_);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: TypeGroup::onApiComChange()\r\n//-----------------------------------------------------------------------------\r\nvoid TypeGroup::onApiComChange(bool checked)\r\n{\r\n    options_.apis_ = checked;\r\n    emit optionsChanged(options_);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: TypeGroup::onAdvancedChange()\r\n//-----------------------------------------------------------------------------\r\nvoid TypeGroup::onAdvancedChange(bool checked)\r\n{\r\n\toptions_.advanced_ = checked;\r\n\temit optionsChanged(options_);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: TypeGroup::setupLayout()\r\n//-----------------------------------------------------------------------------\r\nvoid TypeGroup::setupLayout()\r\n{\r\n    auto* layout = new FlowLayout(this, 2, 1, 1);\r\n    layout->addWidget(&busBox_);\r\n    layout->addWidget(&catalogBox_);\r\n    layout->addWidget(&componentBox_);\r\n    layout->addWidget(&apiComBox_);\r\n    layout->addWidget(&advancedBox_);\r\n}\r\n"
  },
  {
    "path": "library/VLNVDialer/typegroup.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: typegroup.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Antti Kamppi\r\n// Date: 11.07.2011\r\n//\r\n// Description:\r\n// Contains the check boxes to set the type options for VLNVDialer.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef TYPEGROUP_H\r\n#define TYPEGROUP_H\r\n\r\n#include \"FilterGroup.h\"\r\n\r\n#include <KactusAPI/include/utils.h>\r\n\r\n#include <QGroupBox>\r\n#include <QPushButton>\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Contains the check boxes to set the type options for VLNVDialer.\r\n//-----------------------------------------------------------------------------\r\nclass TypeGroup : public FilterGroup\r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\r\n\t/*!\r\n     *  The constructor\r\n\t *\r\n\t *    @param [in] parent The owner of this widget.\r\n\t */\r\n\tTypeGroup(QWidget *parent);\r\n\t\r\n\t/*!\r\n     *  The destructor\r\n     */\r\n\tvirtual ~TypeGroup() = default;\r\n\r\n    //! No copying. No assignment.\r\n    TypeGroup(const TypeGroup& other) = delete;\r\n    TypeGroup& operator=(const TypeGroup& other) = delete;\r\n\r\n    /*!\r\n     *  Sets new type options.\r\n     *\r\n     *    @param [in] options   The options to set.\r\n     */\r\n    void setTypes(Utils::TypeOptions options);\r\n\r\n    /*!\r\n     *  Gets the selected type options.\r\n     *\r\n     *    @return Selected type options.\r\n     */\r\n    Utils::TypeOptions getTypes() const;\r\n\r\n\r\n    void selectAll(bool select) override final;\r\n\r\nsignals:\r\n\r\n\t/*!\r\n     *  Emitted when type settings change.\r\n     */\r\n\tvoid optionsChanged(const Utils::TypeOptions& options);\r\n\r\nprivate slots:\r\n\r\n\t/*!\r\n     *  Handler for componentBox state changes.\r\n     */\r\n    void onComponentChange(bool checked);\r\n\r\n\t/*!\r\n     *  Handler for busApiBox state changes.\r\n     */\r\n    void onBusChange(bool checked);\r\n\r\n    /*!\r\n     *  Handler for catalog state changes.\r\n     */\r\n    void onCatalogChange(bool checked);\r\n\r\n    /*!\r\n     *  Handler for Api/Com state changes.\r\n     */\r\n    void onApiComChange(bool checked);\r\n\r\n    /*!\r\n     *  Handler for advancedBox state changes.\r\n     */\r\n    void onAdvancedChange(bool checked);\r\n\r\nprivate:\r\n\r\n    //! Setup the widget layout.\r\n    void setupLayout();\r\n\r\n\t//! Check box to select components in/out of search results.\r\n\tQPushButton componentBox_;\r\n\r\n\t//! Check box to select buses/APIs in/out of search results.\r\n    QPushButton busBox_;\r\n\r\n    //! Check box to select buses/APIs in/out of search results.\r\n    QPushButton catalogBox_;\r\n\r\n    //! Check box to select buses/APIs in/out of search results.\r\n    QPushButton apiComBox_;\r\n\r\n\t//! Check box to select other IP-Xact types in/out of search results.\r\n    QPushButton advancedBox_;\r\n\r\n\t//! Contains the current search settings for type.\r\n\tUtils::TypeOptions options_;\r\n};\r\n\r\n#endif // TYPEGROUP_H\r\n"
  },
  {
    "path": "library/VLNVDialer/vlnvdialer.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: vlnvdialer.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Antti Kamppi\r\n// Date: 11.07.2011\r\n//\r\n// Description:\r\n// VLNVDialer is used to set options that specify what objects to display in library.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"vlnvdialer.h\"\r\n\r\n#include <QLabel>\r\n#include <QGridLayout>\r\n#include <QIcon>\r\n#include <QSettings>\r\n\r\n#include <common/widgets/tagEditor/TagSelectorContainer.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VLNVDialer::VLNVDialer()\r\n//-----------------------------------------------------------------------------\r\nVLNVDialer::VLNVDialer(QWidget *parent):\r\n    QWidget(parent),\r\n    hideButton_(QIcon(\":/icons/common/graphics/filter.png\"), QString(), this),\r\n    selectAllButton_(QIcon(\":/icons/common/graphics/check-all.png\"), QString(), this),\r\n    filters_(this),\r\n    tagGroup_(tr(\"Tags\"), this),\r\n    tagFilter_(new TagSelectorContainer(this))\r\n{\r\n    hideButton_.setToolTip(tr(\"Show/hide Filters\"));\r\n    hideButton_.setFlat(true);\r\n\r\n    selectAllButton_.setToolTip(tr(\"Select all\"));\r\n    selectAllButton_.setFlat(true);\r\n\r\n    tagGroup_.setFlat(true);\r\n\r\n\t// check if the filters were visible or not previously\r\n\tQSettings settings;\r\n\thideFilters_ = !settings.value(\"FilterWidget/Hidden\", false).toBool();\r\n\tonHideShowClick();\r\n\r\n    connect(&hideButton_, SIGNAL(clicked(bool)), this, SLOT(onHideShowClick()), Qt::UniqueConnection);\r\n    connect(&selectAllButton_, SIGNAL(clicked(bool)), this, SLOT(onSelectAll()), Qt::UniqueConnection);\r\n\r\n\tconnect(&filters_, SIGNAL(firmnessChanged(const Utils::FirmnessOptions&)),\r\n\t\tthis, SIGNAL(firmnessChanged(const Utils::FirmnessOptions&)), Qt::UniqueConnection);\r\n\tconnect(&filters_, SIGNAL(implementationChanged(const Utils::ImplementationOptions&)),\r\n\t\tthis, SIGNAL(implementationChanged(const Utils::ImplementationOptions&)), Qt::UniqueConnection);\r\n\tconnect(&filters_, SIGNAL(typeChanged(const Utils::TypeOptions&)),\r\n\t\tthis, SIGNAL(typeChanged(const Utils::TypeOptions&)), Qt::UniqueConnection);\r\n\tconnect(&filters_, SIGNAL(hierarchyChanged(const Utils::HierarchyOptions&)),\r\n\t\tthis, SIGNAL(hierarchyChanged(const Utils::HierarchyOptions&)), Qt::UniqueConnection);\r\n    connect(&filters_, SIGNAL(revisionChanged(Utils::RevisionOptions const&)),\r\n        this, SIGNAL(revisionChanged(Utils::RevisionOptions const&)), Qt::UniqueConnection);\r\n    connect(&filters_, SIGNAL(validityChanged(Utils::ValidityOptions const&)),\r\n            this, SIGNAL(validityChanged(Utils::ValidityOptions const&)), Qt::UniqueConnection);\r\n    connect(&filters_, SIGNAL(optionsChanged(Utils::FilterOptions const&)),\r\n        this, SIGNAL(filtersChanged(Utils::FilterOptions const&)), Qt::UniqueConnection);\r\n  \r\n    connect(tagFilter_, SIGNAL(contentChanged()), this, SLOT(onHandleTagFilterChange()), Qt::UniqueConnection);\r\n\r\n    setupLayout();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VLNVDialer::loadFilterSettings()\r\n//-----------------------------------------------------------------------------\r\nvoid VLNVDialer::loadFilterSettings(QSettings& settings)\r\n{\r\n    Utils::FilterOptions filters;\r\n    settings.beginGroup(\"LibraryFilters\");\r\n    settings.beginGroup(\"Type\");\r\n    filters.type.components_ = settings.value(\"ShowComponents\", true).toBool();\r\n    filters.type.buses_ = settings.value(\"ShowBuses\", true).toBool();\r\n    filters.type.catalogs_ = settings.value(\"ShowCatalogs\", true).toBool();\r\n    filters.type.apis_ = settings.value(\"ShowApis\", true).toBool();\r\n    filters.type.advanced_ = settings.value(\"ShowAdvanced\", false).toBool();\r\n    settings.endGroup();\r\n    settings.beginGroup(\"Implementation\");\r\n    filters.implementation.hw_ = settings.value(\"ShowHW\", true).toBool();\r\n    filters.implementation.sw_ = settings.value(\"ShowSW\", true).toBool();\r\n    filters.implementation.system_ = settings.value(\"ShowSystem\", true).toBool();\r\n    settings.endGroup();\r\n    settings.beginGroup(\"Hierarchy\");\r\n    filters.hierarchy.flat_ = settings.value(\"ShowGlobal\", true).toBool();\r\n    filters.hierarchy.product_ = settings.value(\"ShowProduct\", true).toBool();\r\n    filters.hierarchy.board_ = settings.value(\"ShowBoard\", true).toBool();\r\n    filters.hierarchy.chip_ = settings.value(\"ShowChip\", true).toBool();\r\n    filters.hierarchy.soc_ = settings.value(\"ShowSoC\", true).toBool();\r\n    filters.hierarchy.ip_ = settings.value(\"ShowIP\", true).toBool();\r\n    settings.endGroup();\r\n    settings.beginGroup(\"Firmness\");\r\n    filters.firmness.templates_ = settings.value(\"ShowTemplates\", true).toBool();\r\n    filters.firmness.mutable_ = settings.value(\"ShowMutable\", true).toBool();\r\n    filters.firmness.fixed_ = settings.value(\"ShowFixed\", true).toBool();\r\n    settings.endGroup();\r\n    settings.beginGroup(\"Validity\");\r\n    filters.validity.valid_ = settings.value(\"ShowValid\", true).toBool();\r\n    filters.validity.invalid_ = settings.value(\"ShowErrors\", true).toBool();\r\n    settings.endGroup();\r\n    settings.beginGroup(\"Revision\");\r\n    filters.revision.std14_ = settings.value(\"ShowStd14\", true).toBool();\r\n    filters.revision.std22_ = settings.value(\"ShowStd22\", true).toBool();\r\n    settings.endGroup();\r\n\r\n    filters_.setFilters(filters);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VLNVDialer::saveFilterSettings()\r\n//-----------------------------------------------------------------------------\r\nvoid VLNVDialer::saveFilterSettings(QSettings& settings) const\r\n{\r\n    Utils::FilterOptions filters = filters_.getFilters();\r\n\r\n    // Save filters.\r\n    settings.beginGroup(\"LibraryFilters\");\r\n    settings.beginGroup(\"Type\");\r\n    settings.setValue(\"ShowComponents\", filters.type.components_);\r\n    settings.setValue(\"ShowBuses\", filters.type.buses_);\r\n    settings.setValue(\"ShowCatalogs\", filters.type.catalogs_);\r\n    settings.setValue(\"ShowApis\", filters.type.apis_);\r\n    settings.setValue(\"ShowAdvanced\", filters.type.advanced_);\r\n    settings.endGroup();\r\n    settings.beginGroup(\"Implementation\");\r\n    settings.setValue(\"ShowHW\", filters.implementation.hw_);\r\n    settings.setValue(\"ShowSW\", filters.implementation.sw_);\r\n    settings.setValue(\"ShowSystem\", filters.implementation.system_);\r\n    settings.endGroup();\r\n    settings.beginGroup(\"Hierarchy\");\r\n    settings.setValue(\"ShowGlobal\", filters.hierarchy.flat_);\r\n    settings.setValue(\"ShowProduct\", filters.hierarchy.product_);\r\n    settings.setValue(\"ShowBoard\", filters.hierarchy.board_);\r\n    settings.setValue(\"ShowChip\", filters.hierarchy.chip_);\r\n    settings.setValue(\"ShowSoC\", filters.hierarchy.soc_);\r\n    settings.setValue(\"ShowIP\", filters.hierarchy.ip_);\r\n    settings.endGroup();\r\n    settings.beginGroup(\"Firmness\");\r\n    settings.setValue(\"ShowTemplates\", filters.firmness.templates_);\r\n    settings.setValue(\"ShowMutable\", filters.firmness.mutable_);\r\n    settings.setValue(\"ShowFixed\", filters.firmness.fixed_);\r\n    settings.endGroup(); // Firmness\r\n    settings.beginGroup(\"Validity\");\r\n    settings.setValue(\"ShowValid\", filters.validity.valid_);\r\n    settings.setValue(\"ShowErrors\", filters.validity.invalid_);\r\n    settings.endGroup(); // Validity\r\n    settings.beginGroup(\"Revision\");\r\n    settings.setValue(\"ShowStd14\", filters.revision.std14_);\r\n    settings.setValue(\"ShowStd22\", filters.revision.std22_);\r\n    settings.endGroup(); // Revision\r\n    settings.endGroup(); // LibraryFilters\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: vlnvdialer::onHandleTagFilterChange()\r\n//-----------------------------------------------------------------------------\r\nvoid VLNVDialer::onHandleTagFilterChange()\r\n{\r\n    QVector<TagData> filteredTags = tagFilter_->getTags();\r\n    emit tagFiltersChanged(filteredTags);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VLNVDialer::onHideShowClick()\r\n//-----------------------------------------------------------------------------\r\nvoid VLNVDialer::onHideShowClick()\r\n{\r\n\thideFilters_ = !hideFilters_;\r\n\r\n    filters_.setHidden(hideFilters_);\r\n    tagGroup_.setHidden(hideFilters_);\r\n\r\n    if (hideFilters_)\r\n    {\r\n        hideButton_.setToolTip(tr(\"Show filters\"));\r\n    }\r\n    else\r\n    {\r\n        hideButton_.setToolTip(tr(\"Hide filters\"));\r\n    }\r\n\r\n    QSettings settings;\r\n    settings.setValue(\"FilterWidget/Hidden\", hideFilters_);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VLNVDialer::onSelectAll()\r\n//-----------------------------------------------------------------------------\r\nvoid VLNVDialer::onSelectAll()\r\n{\r\n    allSelected_ = !allSelected_;\r\n    if (allSelected_)\r\n    {\r\n        selectAllButton_.setToolTip(\"Clear all\");\r\n        selectAllButton_.setIcon(QIcon(\":/icons/common/graphics/uncheck-all.png\"));\r\n    }\r\n    else\r\n    {\r\n        selectAllButton_.setToolTip(\"Select all\");\r\n        selectAllButton_.setIcon(QIcon(\":/icons/common/graphics/check-all.png\"));\r\n    }\r\n\r\n    filters_.selectAll(allSelected_);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VLNVDialer::setupLayout()\r\n//-----------------------------------------------------------------------------\r\nvoid VLNVDialer::setupLayout()\r\n{\r\n    QVBoxLayout* tagGroupLayout(new QVBoxLayout());\r\n    tagGroupLayout->addWidget(tagFilter_);\r\n\r\n    tagGroup_.setLayout(tagGroupLayout);\r\n\r\n    QGridLayout* layout = new QGridLayout(this);\r\n    layout->addWidget(new QLabel(tr(\"Library Filters\"), this), 0, 0, 1, 1, Qt::AlignLeft);\r\n    layout->addWidget(&hideButton_, 0, 1, 1, 1, Qt::AlignRight);\r\n    layout->addWidget(&selectAllButton_, 0, 2, 1, 1, Qt::AlignRight);\r\n    layout->addWidget(&filters_, 2, 0, 1, 3);\r\n    layout->addWidget(&tagGroup_, 3, 0, 1, 3);\r\n\r\n    layout->setColumnStretch(0, 1);\r\n    layout->setSpacing(0);\r\n    layout->setContentsMargins(4, 4, 4, 4);\r\n}\r\n"
  },
  {
    "path": "library/VLNVDialer/vlnvdialer.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: vlnvdialer.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Antti Kamppi\r\n// Date: 11.07.2011\r\n//\r\n// Description:\r\n// VLNVDialer is used to set options that specify what objects to display in library.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef VLNVDIALER_H\r\n#define VLNVDIALER_H\r\n\r\n#include \"dialerwidget.h\"\r\n#include \"filterwidget.h\"\r\n\r\n#include <IPXACTmodels/common/TagData.h>\r\n\r\n#include <KactusAPI/include/utils.h>\r\n\r\n#include <QWidget>\r\n#include <QGroupBox>\r\n#include <QPushButton>\r\n#include <QString>\r\n#include <QSettings>\r\n\r\nclass TagContainer;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! VLNVDialer is used to set options that specify what objects to display in library.\r\n//-----------------------------------------------------------------------------\r\nclass VLNVDialer : public QWidget\r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\r\n\t/*! The constructor\r\n\t *\r\n\t *    @param [in] parent The owner of this widget.\r\n\t *\r\n\t*/\r\n\tVLNVDialer(QWidget *parent);\r\n\t\r\n\t//! The destructor\r\n\tvirtual ~VLNVDialer() = default;\r\n\r\n    //! No copying\r\n    VLNVDialer(VLNVDialer const& other) = delete;\r\n\r\n    //! No assignment\r\n    VLNVDialer& operator=(VLNVDialer const& other) = delete;\r\n\r\n\t/*!\r\n\t *  Set filter settings for the library.\r\n\t *\r\n\t *    @param [in] settings    Settings containing the library filters.\r\n\t */\r\n\tvoid loadFilterSettings(QSettings& settings);\r\n\r\n\t/*!\r\n\t *  Save settings for dock widget filters.\r\n\t *\r\n\t *    @param [in] settings    The settings.\r\n\t */\r\n\tvoid saveFilterSettings(QSettings& settings) const;\r\n\r\nsignals:\r\n\r\n\t//! Emitted when re-usability options change.\r\n\tvoid firmnessChanged(Utils::FirmnessOptions const& options);\r\n\r\n\t//! Emitted when firmness options change.\r\n\tvoid implementationChanged(Utils::ImplementationOptions const& options);\r\n\r\n\t//! Emitted when type options change.\r\n\tvoid typeChanged(Utils::TypeOptions const& options);\r\n\r\n\t//! Emitted when hierarchy options change.\r\n\tvoid hierarchyChanged(Utils::HierarchyOptions const& options);\r\n\r\n    //! Emitted when revision options change.\r\n    void revisionChanged(Utils::RevisionOptions const& options);\r\n\r\n    //! Emitted when validity options change.\r\n    void validityChanged(Utils::ValidityOptions const& options);\r\n\r\n    //! Emitted when all options change.\r\n    void filtersChanged(Utils::FilterOptions const&);\r\n\r\n    /*!\r\n     *  Informs of tag filter change.\r\n     *\r\n     *    @param [in] tagFilters  The new visible tags.\r\n     */\r\n    void tagFiltersChanged(QVector<TagData> tagFilters);\r\n\r\nprivate slots:\r\n\r\n    /*!\r\n     *  Handler for changing visible tags.\r\n     */\r\n    void onHandleTagFilterChange();\r\n\r\n\t//! Handler for hide/show button clicks.\r\n\tvoid onHideShowClick();\r\n\r\n\t//! Handler for select/clear button clicks.\r\n\tvoid onSelectAll();\r\n\r\nprivate:\r\n\r\n\t//! Setup the widget layout.\r\n    void setupLayout();\r\n\r\n    //-----------------------------------------------------------------------------\r\n\t// Data.\r\n\t//-----------------------------------------------------------------------------\r\n\t\t\r\n    //! Button to hide/show filters.\r\n    QPushButton hideButton_;\r\n\r\n    //! Button to hide/show filters.\r\n    QPushButton selectAllButton_;\r\n\r\n\t//! Contains the items to set filters for search.\r\n\tFilterWidget filters_;\r\n\r\n\t//! Group box for tag filters.\r\n    QGroupBox tagGroup_;\r\n\r\n    //! Tag filter.\r\n    TagContainer* tagFilter_;\r\n\r\n\t//! Contains the value to know if filters are currently hidden or visible.\r\n\tbool hideFilters_ = false;\r\n\r\n\t//! Contains the value to know if all filters are selected or cleared.\r\n\tbool allSelected_ = false;\r\n};\r\n\r\n#endif // VLNVDIALER_H\r\n"
  },
  {
    "path": "library/objectremovedialog.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ObjectRemoveDialog.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 08.08.2011\r\n//\r\n// Description:\r\n// Dialog for selecting items to be removed.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"objectremovedialog.h\"\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: objectremovedialog::ObjectRemoveDialog()\r\n//-----------------------------------------------------------------------------\r\nObjectRemoveDialog::ObjectRemoveDialog(QWidget *parent, Qt::WindowFlags f):\r\nObjectSelectionDialog(tr(\"Delete\"), QStringLiteral(\":icons/common/graphics/delete.png\"),\r\n    QStringLiteral(\":icons/common/graphics/cross.png\"), tr(\"Select items to delete\"), parent, f)\r\n{\r\n    setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);\r\n\r\n    setupLayout();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: objectremovedialog::~ObjectRemoveDialog()\r\n//-----------------------------------------------------------------------------\r\nObjectRemoveDialog::~ObjectRemoveDialog()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: objectremovedialog::setupLayout()\r\n//-----------------------------------------------------------------------------\r\nvoid ObjectRemoveDialog::setupLayout()\r\n{\r\n    QString introLabel = tr(\"Delete\");\r\n    QString introText = tr(\"Delete the selected items. The items will be removed from the library and the hard drive.\");\r\n    QWidget* introWidget = setupIntroWidget(introLabel, introText);\r\n\r\n    QVBoxLayout* overallLayout = new QVBoxLayout(this);\r\n    overallLayout->addWidget(introWidget);\r\n    overallLayout->addWidget(getItemList(), 1);\r\n    overallLayout->addLayout(setupButtonLayout());\r\n}\r\n"
  },
  {
    "path": "library/objectremovedialog.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ObjectRemoveDialog.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 08.08.2011\r\n//\r\n// Description:\r\n// Dialog for selecting items to be removed.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef OBJECTREMOVEDIALOG_H\r\n#define OBJECTREMOVEDIALOG_H\r\n\r\n#include \"ObjectSelectionDialog.h\"\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Dialog for selecting items to be removed.\r\n//-----------------------------------------------------------------------------\r\nclass ObjectRemoveDialog : public ObjectSelectionDialog\r\n{\r\n    Q_OBJECT\r\n\r\npublic:\r\n\r\n\t/*!\r\n     *  The constructor.\r\n\t *\r\n\t *    @param [in] parent  Pointer to the owner of this dialog.\r\n\t *    @param [in] f       Widget flags for the dialog.\r\n\t *\r\n\t */\r\n\tObjectRemoveDialog(QWidget *parent = 0, Qt::WindowFlags f = Qt::WindowFlags());\r\n\t\r\n\t/*!\r\n     *  The destructor\r\n     */\r\n\tvirtual ~ObjectRemoveDialog();\r\n\r\nprotected:\r\n\r\n    /*!\r\n     *  Setup the layout for the dialog.\r\n     */\r\n    virtual void setupLayout();\r\n\r\nprivate:\r\n\r\n\t//! No copying. No assignment.\r\n\tObjectRemoveDialog(const ObjectRemoveDialog& other);\r\n\tObjectRemoveDialog& operator=(const ObjectRemoveDialog& other);\r\n};\r\n\r\n#endif // OBJECTREMOVEDIALOG_H\r\n"
  },
  {
    "path": "mainwindow/CommandLineParser.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: CommandLineParser.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Esko Pekkarinen\n// Date: 21.02.2018\n//\n// Description:\n// Utilities for parsing and executing command line arguments.\n//-----------------------------------------------------------------------------\n\n#include \"CommandLineParser.h\"\n\n#include <KactusAPI/include/MessageMediator.h>\n#include <KactusAPI/KactusAPI.h>\n\n#include <QCoreApplication>\n#include <QCommandLineParser>\n#include <QStringList>\n\nconst QHash<CommandLineParser::Option, CommandLineParser::OptionData > CommandLineParser::CLI_OPTS = {\n    {\n        CommandLineParser::Option::NoGui, \n        CommandLineParser::OptionData{QChar('c'), QStringLiteral(\"no-gui\"), \n            QStringLiteral(\"Run in interactive command-line mode.\")}\n    },\n    {\n        CommandLineParser::Option::InputScript, \n        CommandLineParser::OptionData{QChar('i'), QStringLiteral(\"input-script\"),\n            QStringLiteral(\"Run script then exit.\"), QStringLiteral(\"script path\")}\n    },\n};\n\n//-----------------------------------------------------------------------------\n// Function: CommandLineParser::CommandLineParser()\n//-----------------------------------------------------------------------------\nCommandLineParser::CommandLineParser() : optionParser_(), preReadDone_(false)\n{\n    optionParser_.addHelpOption();\n    optionParser_.addVersionOption();\n\n    for (auto const& option : CLI_OPTS.values())\n    {\n        QCommandLineOption newOpt({ option.character, option.shortName }, option.description);\n        \n        if (option.valueName.isEmpty() == false)\n        {\n            newOpt.setValueName(option.valueName);\n        }\n\n        optionParser_.addOption(newOpt);\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: CommandLineParser::readArguments()\n//-----------------------------------------------------------------------------\nvoid CommandLineParser::readArguments(QStringList const& arguments)\n{\n    optionParser_.parse(arguments);\n    preReadDone_ = true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: CommandLineParser::commandlineMode()\n//-----------------------------------------------------------------------------\nbool CommandLineParser::commandlineMode() const\n{\n    return optionIsSet(Option::NoGui);\n}\n\n//-----------------------------------------------------------------------------\n// Function: CommandLineParser::runScriptMode()\n//-----------------------------------------------------------------------------\nbool CommandLineParser::runScriptMode() const\n{\n    return optionIsSet(Option::InputScript);\n}\n\n//-----------------------------------------------------------------------------\n// Function: CommandLineParser::versionMode()\n//-----------------------------------------------------------------------------\nbool CommandLineParser::versionMode() const\n{\n    return optionParser_.isSet(QStringLiteral(\"version\"));\n}\n\n//-----------------------------------------------------------------------------\n// Function: CommandLineParser::process()\n//-----------------------------------------------------------------------------\nint CommandLineParser::process(QStringList const& arguments, MessageMediator* messageChannel)\n{\n    if (preReadDone_ == false)\n    {\n        optionParser_.parse(arguments);\n    }\n\n    if (versionMode())\n    {\n        QString versionText = KactusAPI::getVersion() +\n            \" Copyright (C) 2025 Tampere University\\n\" +\n            \"License GPL2: GNU GPL version 2 <https://gnu.org/licenses/gpl.html>\\n\";\n        \n        messageChannel->showMessage(versionText);\n        return 0;\n    }\n\n    if (optionIsSet(Option::InputScript))\n    {\n        auto scriptPath = getOptionValue(Option::InputScript);\n\n        if (scriptPath.isEmpty())\n        {\n            messageChannel->showFailure(\"Error: No script path given\");\n            return 1;\n        }\n        else if (QFile::exists(scriptPath) == false)\n        {\n            messageChannel->showFailure(\"Error: Invalid script path\");\n            return 1;\n        }\n    }\n\n    optionParser_.process(arguments);\n    return 0;\n}\n\n//-----------------------------------------------------------------------------\n// Function: CommandLineParser::getOptionParser()\n//-----------------------------------------------------------------------------\nQString CommandLineParser::getOptionValue(CommandLineParser::Option option) const\n{\n    return optionParser_.value(CLI_OPTS[option].shortName);\n}\n\n//-----------------------------------------------------------------------------\n// Function: CommandLineParser::optionIsSet()\n//-----------------------------------------------------------------------------\nbool CommandLineParser::optionIsSet(Option option) const\n{\n    return optionParser_.isSet(CLI_OPTS[option].shortName);\n}\n"
  },
  {
    "path": "mainwindow/CommandLineParser.h",
    "content": "//-----------------------------------------------------------------------------\n// File: CommandLineParser.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Esko Pekkarinen\n// Date: 21.02.2018\n//\n// Description:\n// Utilities for parsing and executing command line arguments.\n//-----------------------------------------------------------------------------\n\n#ifndef COMMANDLINEPARSER\n#define COMMANDLINEPARSER\n\n#include <QCommandLineParser>\n#include <QStringList>\n\nclass LibraryInterface;\nclass MessageMediator;\n\n//-----------------------------------------------------------------------------\n//! Utilities for parsing and executing command line arguments.\n//-----------------------------------------------------------------------------\nclass CommandLineParser\n{\npublic:\n    \n    // Data for storing CLI options\n\n    enum class Option\n    {\n        NoGui,\n        InputScript\n    };\n\n    struct OptionData\n    {\n        QChar character;\n        QString shortName;\n        QString description;\n        QString valueName;\n    };\n\n    static const QHash<Option, OptionData> CLI_OPTS;\n\n    // The constructor.\n    CommandLineParser();\n\n    // The destructor.\n    ~CommandLineParser() = default;\n\n    /*!\n     *  Reads the given arguments. \n     *  The arguments can then be checked before processing with argumentsValid() and helpOrVersionOptionSet().\n     *\n     *    @param [in] arguments   The arguments to read.\n     */\n    void readArguments(QStringList const& arguments);\n\n    /*!\n     *  Checks if the command-line option is set.\n     *\n     *    @return True, if command-line option is set, otherwise false.\n     */\n    bool commandlineMode() const;\n\n    /*!\n     *\tChecks if the run a script mode is set.\n     *\t    \n     *    @return True, if the mode is set, otherwise false.\n     */\n    bool runScriptMode() const;\n\n    bool versionMode() const;\n\n    /*!\n     *  Processes the given command line arguments and executes accordingly.\n     *\n     *    @param [in] arguments       The command line arguments to process.\n     *    @param [in] messageChannel  Interface for output and error messages.     \n     *\n     *    @return 0 for a successful run, any other value for errors.\n     */\n    int process(QStringList const& arguments, MessageMediator* messageChannel);\n\n    /*!\n     *\tGet the user provided value of given command line option.\n     *  \n     *    @param [in] option     The option whose value to get.\n     *\t    \n     *    @return The user provide value for given option.\n     */\n    QString getOptionValue(CommandLineParser::Option option) const;\n\n    /*!\n     *\tTells if a given option is set.\n     *  \n     *    @param [in] option     The option to check.\n     *\t    \n     *    @return True, if the option is set, otherwise false.\n     */\n    bool optionIsSet(CommandLineParser::Option option) const;\n   \nprivate:\n\n    /*!\n     *  Get the usage help text.\n     *\n     *    @return The usage help text.\n     */\n    QString helpText();\n\n    // Parser for command-line options.\n    QCommandLineParser optionParser_;   \n\n    // Flag to indicate if arguments are read before process();\n    bool preReadDone_;\n};\n\n#endif \n"
  },
  {
    "path": "mainwindow/DeleteWorkspaceDialog.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: DeleteWorkspaceDialog.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Joni-Matti Maatta\r\n// Date: 24.1.2012\r\n//\r\n// Description:\r\n// Dialog for deleting workspaces.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"DeleteWorkspaceDialog.h\"\r\n\r\n#include <QHBoxLayout>\r\n#include <QVBoxLayout>\r\n#include <QLabel>\r\n#include <QMessageBox>\r\n#include <QCoreApplication>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DeleteWorkspaceDialog()\r\n//-----------------------------------------------------------------------------\r\nDeleteWorkspaceDialog::DeleteWorkspaceDialog(QWidget* parent) : QDialog(parent), workspaceCombo_(0), btnOk_(0)\r\n{\r\n    // Create the name label and field.\r\n    QLabel* nameLabel = new QLabel(tr(\"Workspace:\"), this);\r\n    workspaceCombo_ = new QComboBox(this);\r\n\r\n    QHBoxLayout* nameLayout = new QHBoxLayout();\r\n    nameLayout->addWidget(nameLabel);\r\n    nameLayout->addWidget(workspaceCombo_, 1);\r\n\r\n    // Create the info label.\r\n    QLabel* infoLabel = new QLabel(tr(\"Notice: The default workspace and the currently active workspace cannot be deleted.\"), this);\r\n    infoLabel->setWordWrap(true);\r\n\r\n    // Create the dialog buttons.\r\n    btnOk_ = new QPushButton(tr(\"OK\") , this);\r\n    btnOk_->setEnabled(false);\r\n    QPushButton* btnCancel = new QPushButton(tr(\"Cancel\"), this);\r\n\r\n    QHBoxLayout* buttonLayout = new QHBoxLayout();\r\n    buttonLayout->addStretch(1);\r\n    buttonLayout->addWidget(btnOk_);\r\n    buttonLayout->addWidget(btnCancel);\r\n\r\n    // Create the main mainLayout.\r\n    QVBoxLayout* mainLayout = new QVBoxLayout(this);\r\n    mainLayout->addLayout(nameLayout);\r\n    mainLayout->addWidget(infoLabel);\r\n    mainLayout->addLayout(buttonLayout);\r\n\r\n    connect(btnOk_, SIGNAL(clicked()), this, SLOT(accept()));\r\n    connect(btnCancel, SIGNAL(clicked()), this, SLOT(reject()));\r\n\r\n    setWindowTitle(tr(\"Delete Workspace\"));\r\n    setFixedWidth(300);\r\n    setFixedHeight(sizeHint().height());\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: name()\r\n//----------------------------------------------------------------------------- \r\nQString DeleteWorkspaceDialog::name() const\r\n{\r\n    return workspaceCombo_->currentText();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: addWorkspaceName()\r\n//-----------------------------------------------------------------------------\r\nvoid DeleteWorkspaceDialog::addWorkspaceName(QString const& name)\r\n{\r\n    workspaceCombo_->addItem(name);\r\n    workspaceCombo_->setCurrentIndex(0);\r\n    btnOk_->setEnabled(true);\r\n}\r\n"
  },
  {
    "path": "mainwindow/DeleteWorkspaceDialog.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: DeleteWorkspaceDialog.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Joni-Matti Maatta\r\n// Date: 24.1.2012\r\n//\r\n// Description:\r\n// Dialog for deleting workspaces.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef DELETEWORKSPACEDIALOG_H\r\n#define DELETEWORKSPACEDIALOG_H\r\n\r\n#include <QDialog>\r\n#include <QComboBox>\r\n#include <QPushButton>\r\n\r\n//-----------------------------------------------------------------------------\r\n//! DeleteWorkspaceDialog class\r\n//-----------------------------------------------------------------------------\r\nclass DeleteWorkspaceDialog : public QDialog\r\n{\r\n    Q_OBJECT\r\n\r\npublic:\r\n    /*!\r\n     *  Constructor which initializes the dialog.\r\n     *\r\n     *    @param [in] parent   The parent widget.\r\n     */\r\n    DeleteWorkspaceDialog(QWidget* parent = 0);\r\n\r\n    /*!\r\n     *  Destructor.\r\n     */\r\n    ~DeleteWorkspaceDialog() = default;\r\n\r\n    /*!\r\n     *  Adds a workspace name to the dialog.\r\n     *\r\n     *    @param [in] name The name of the existing workspace.\r\n     */\r\n    void addWorkspaceName(QString const& name);\r\n\r\n    /*!\r\n     *  Returns the name of the workspace to delete.\r\n     */\r\n    QString name() const;\r\n\r\nprivate:\r\n    // Disable copying.\r\n    DeleteWorkspaceDialog(DeleteWorkspaceDialog const& rhs);\r\n    DeleteWorkspaceDialog& operator=(DeleteWorkspaceDialog const& rhs);\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! Combo box for selecting the workspace to delete.\r\n    QComboBox* workspaceCombo_;\r\n\r\n    //! The OK button.\r\n    QPushButton* btnOk_;\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n\r\n#endif // DELETEWORKSPACEDIALOG_H\r\n"
  },
  {
    "path": "mainwindow/DockWidgetHandler.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: DockWidgetHandler.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Mikko Teuho\n// Date: 10.10.2017\n//\n// Description:\n// Manages the dockable widgets for the main window.\n//-----------------------------------------------------------------------------\n\n#include \"DockWidgetHandler.h\"\n\n#include <mainwindow/MessageConsole/messageconsole.h>\n\n#include <Help/HelpSystem/HelpWindow.h>\n#include <Help/HelpSystem/ContextHelpBrowser.h>\n\n#include <library/LibraryWidget.h>\n#include <KactusAPI/include/LibraryHandler.h>\n\n#include <common/ui/GraphicalMessageMediator.h>\n\n#include <common/widgets/ParameterGroupBox/parametergroupbox.h>\n#include <common/graphicsItems/ConnectionEndpoint.h>\n\n#include <editors/ComponentEditor/componenteditor.h>\n#include <KactusAPI/include/ListParameterFinder.h>\n#include <KactusAPI/include/ExpressionFormatter.h>\n#include <KactusAPI/include/MultipleParameterFinder.h>\n#include <editors/ComponentEditor/parameterReferenceTree/ParameterReferenceTreeWindow.h>\n#include <KactusAPI/include/ParametersInterface.h>\n\n#include <editors/common/DesignParameterReferenceTree/DesignParameterReferenceCounter.h>\n#include <editors/common/DesignParameterReferenceTree/DesignParameterReferenceTree.h>\n#include <editors/common/ComponentInstanceEditor/componentinstanceeditor.h>\n#include <editors/common/ConfigurationEditor/configurationeditor.h>\n#include <editors/common/InterfaceEditor/interfaceeditor.h>\n#include <editors/common/ConnectionEditor/connectioneditor.h>\n#include <editors/common/VendorExtensionEditor/VendorExtensionsEditor.h>\n\n#include <editors/HWDesign/AdHocItem.h>\n#include <editors/HWDesign/HWDesignWidget.h>\n#include <editors/HWDesign/HWDesignDiagram.h>\n#include <editors/HWDesign/AdhocEditor/AdhocEditor.h>\n#include <editors/SystemDesign/SystemDesignWidget.h>\n#include <editors/SystemDesign/SystemDetailsEditor/SystemDetailsEditor.h>\n\n#include <QActionGroup>\n#include <QList>\n#include <QString>\n#include <QHelpEngine>\n#include <QApplication>\n\nnamespace \n{\n    const QMap<TabDocument::SupportedWindows, QString> DOCK_SETTINGS =\n    {\n        { TabDocument::CONFIGURATIONWINDOW, \"ConfigurationVisibility\" },\n        { TabDocument::SYSTEM_DETAILS_WINDOW, \"SystemDetailsVisibility\" },\n        { TabDocument::CONNECTIONWINDOW, \"ConnectionVisibility\" },\n        { TabDocument::INSTANCEWINDOW, \"InstanceVisibility\" },\n        { TabDocument::ADHOC_WINDOW, \"AdHocEditorVisibility\" },\n        { TabDocument::INTERFACEWINDOW, \"InterfaceVisibility\" },\n        { TabDocument::LIBRARYWINDOW, \"LibraryVisibility\" },\n        { TabDocument::OUTPUTWINDOW, \"OutputVisibility\" },\n        { TabDocument::CONTEXT_HELP_WINDOW, \"ContextHelpVisibility\" },\n        { TabDocument::DESIGNPARAMETERSWINDOW, \"DesignParameterVisibility\" },\n        { TabDocument::VENDOREXTENSIONWINDOW, \"VendorExtensionVisibility\" }\n    };\n};\n\n//-----------------------------------------------------------------------------\n// Function: DockWidgetHandler::DockWidgetHandler()\n//-----------------------------------------------------------------------------\nDockWidgetHandler::DockWidgetHandler(\n    LibraryHandler* library,\n    MessageMediator* messageChannel, \n    QToolBar* leftToolbar,\n    QToolBar* rightToolbar,\n    QMainWindow* parent) :\nQObject(parent),\n    libraryHandler_(library),\n    libraryDock_(0),\n    libraryWidget_(0),\n    console_(0),\n    consoleDock_(0),\n    contextHelpBrowser_(0),\n    contextHelpDock_(0),\n    designParameterReferenceCounter_(0),\n    designParametersEditor_(0),\n    designParameterDock_(0),\n    designParameterTree_(0),\n    designParameterFinder_(new ListParameterFinder()),\n    designAndInstancesParameterFinder_(new MultipleParameterFinder()),\n    instanceEditor_(0),\n    instanceDock_(0),\n    adhocEditor_(0),\n    adhocDock_(0),\n    configurationEditor_(0),\n    configurationDock_(0),\n    systemDetailsEditor_(0),\n    systemDetailsDock_(0),\n    interfaceEditor_(0),\n    interfaceDock_(0),\n    connectionEditor_(0),\n    connectionDock_(0),\n    extensionDock_(0),\n    extensionEditor_(0),\n    helpWnd_(0),\n    docks_(),\n    visibilityControls_(),\n    visibilities_(),\n    leftToolbar_(leftToolbar),\n    rightToolbar_(rightToolbar),\n    leftActions_(new QActionGroup(this)),\n    rightActions_(new QActionGroup(this)),\n    mainWindow_(parent),\n    messageChannel_(messageChannel)\n{\n     leftActions_->setExclusionPolicy(QActionGroup::ExclusionPolicy::ExclusiveOptional);\n     rightActions_->setExclusionPolicy(QActionGroup::ExclusionPolicy::ExclusiveOptional);\n}\n\n//-----------------------------------------------------------------------------\n// Function: DockWidgetHandler::setupDockWidgets()\n//-----------------------------------------------------------------------------\nvoid DockWidgetHandler::setupDockWidgets()\n{\n    setupMessageConsole();\n    setupContextHelp();\n    setupLibraryDock();\n    setupDesignParametersEditor();\n    setupInstanceEditor();\n    setupAdHocEditor();\n    setupConfigurationEditor();\n    setupSystemDetailsEditor();\n    setupInterfaceEditor();\n    setupConnectionEditor();\n    setupVendorExtensionEditor();\n\n    docks_ =\n    {\n        { TabDocument::CONFIGURATIONWINDOW, configurationDock_ },\n        { TabDocument::SYSTEM_DETAILS_WINDOW, systemDetailsDock_ },\n        { TabDocument::CONNECTIONWINDOW, connectionDock_ },\n        { TabDocument::INSTANCEWINDOW, instanceDock_ },\n        { TabDocument::ADHOC_WINDOW, adhocDock_ },\n        { TabDocument::INTERFACEWINDOW, interfaceDock_ },\n        { TabDocument::LIBRARYWINDOW, libraryDock_ },\n        { TabDocument::OUTPUTWINDOW, consoleDock_ },\n        { TabDocument::CONTEXT_HELP_WINDOW, contextHelpDock_ },\n        { TabDocument::DESIGNPARAMETERSWINDOW, designParameterDock_ },\n        { TabDocument::VENDOREXTENSIONWINDOW, extensionDock_ }\n    };\n\n    for (auto const& dock : docks_)\n    {\n        auto viewAction = dock->toggleViewAction();\n        viewAction->setIcon(dock->windowIcon());\n        viewAction->setCheckable(true);\n\n        connect(viewAction, SIGNAL(toggled(bool)), dock, SLOT(setVisible(bool)), Qt::UniqueConnection);\n        connect(dock, SIGNAL(dockLocationChanged(Qt::DockWidgetArea)),\n            this, SLOT(onDockLocationChanged(Qt::DockWidgetArea)), Qt::UniqueConnection);\n\n        auto visibilityAction = new QAction(this);\n        visibilityAction->setText(dock->windowTitle());\n        visibilityAction->setCheckable(true);\n\n        visibilityControls_.insert(docks_.key(dock), visibilityAction);\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: DockWidgetHandler::addVisibilityActions()\n//-----------------------------------------------------------------------------\nvoid DockWidgetHandler::setupVisibilityActionMenu(QMenu& visibilityMenu)\n{\n    for (auto const& control : visibilityControls_)\n    {\n        visibilityMenu.addAction(control);\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: DockWidgetHandler::getLibraryHandler()\n//-----------------------------------------------------------------------------\nLibraryHandler* DockWidgetHandler::getLibraryHandler() const\n{\n    return libraryHandler_;\n}\n\n//-----------------------------------------------------------------------------\n// Function: DockWidgetHandler::loadVisiblities()\n//-----------------------------------------------------------------------------\nvoid DockWidgetHandler::loadVisiblities(QSettings const& settings)\n{\n    for (auto i = DOCK_SETTINGS.cbegin(); i != DOCK_SETTINGS.cend(); ++i)\n    {\n        const bool VISIBLE = settings.value(i.value(), true).toBool();\n        const auto TYPE = i.key();\n\n        visibilities_.insert(TYPE, VISIBLE);\n        visibilityControls_[TYPE]->setChecked(VISIBLE);\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: DockWidgetHandler::saveVisibilitySettings()\n//-----------------------------------------------------------------------------\nvoid DockWidgetHandler::saveVisibilitySettings(QSettings& settings) const\n{\n    for (auto i = DOCK_SETTINGS.cbegin(); i != DOCK_SETTINGS.cend(); ++i)\n    {\n        settings.setValue(i.value(), visibilities_.value(i.key()));\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: DockWidgetHandler::loadFilterSettings()\n//-----------------------------------------------------------------------------\nvoid DockWidgetHandler::loadFilterSettings(QSettings& settings)\n{\n    libraryWidget_->loadFilterSettings(settings);\n}\n\n//-----------------------------------------------------------------------------\n// Function: DockWidgetHandler::saveFilterSettings()\n//-----------------------------------------------------------------------------\nvoid DockWidgetHandler::saveFilterSettings(QSettings& settings) const\n{\n    libraryWidget_->saveFilterSettings(settings);\n}\n\n//-----------------------------------------------------------------------------\n// Function: DockWidgetHandler::applySettings()\n//-----------------------------------------------------------------------------\nvoid DockWidgetHandler::applySettings()\n{\n    // Nothing to do.\n}\n\n//-----------------------------------------------------------------------------\n// Function: DockWidgetHandler::setupMessageConsole()\n//-----------------------------------------------------------------------------\nvoid DockWidgetHandler::setupMessageConsole()\n{\n    consoleDock_ = new QDockWidget(tr(\"Output\"), mainWindow_);\n    consoleDock_->setObjectName(tr(\"Output\"));\n    consoleDock_->setWindowIcon(QIcon(\":icons/common/graphics/log.png\"));\n    consoleDock_->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea | Qt::BottomDockWidgetArea);\n    consoleDock_->setFeatures(QDockWidget::DockWidgetClosable | QDockWidget::DockWidgetMovable | \n        QDockWidget::DockWidgetFloatable);\n\n    console_ = new MessageConsole(consoleDock_);\n    consoleDock_->setWidget(console_);\n    mainWindow_->addDockWidget(Qt::BottomDockWidgetArea, consoleDock_);\n\n    auto guiChannel = dynamic_cast<GraphicalMessageMediator*>(messageChannel_);\n    if (guiChannel)\n    {\n        connect(guiChannel, SIGNAL(noticeMessage(QString const&)),\n            console_, SLOT(onNoticeMessage(QString const&)), Qt::UniqueConnection);\n        connect(guiChannel, SIGNAL(errorMessage(QString const&)),\n            console_, SLOT(onErrorMessage(QString const&)), Qt::UniqueConnection);\n    }\n\n    connect(this, SIGNAL(errorMessage(const QString&)),\n        console_, SLOT(onErrorMessage(const QString&)), Qt::UniqueConnection);\n    connect(this, SIGNAL(noticeMessage(const QString&)),\n        console_, SLOT(onNoticeMessage(const QString&)), Qt::UniqueConnection);\n\n    // Force console visible on new messages.\n    connect(this, SIGNAL(errorMessage(const QString&)), consoleDock_, SLOT(show()), Qt::UniqueConnection);    \n}\n\n//-----------------------------------------------------------------------------\n// Function: DockWidgetHandler::setupContextHelp()\n//-----------------------------------------------------------------------------\nvoid DockWidgetHandler::setupContextHelp()\n{\n    // Create the dock widget for the context help.\n    contextHelpDock_ = new QDockWidget(tr(\"Context Help\"), mainWindow_);\n    contextHelpDock_->setObjectName(tr(\"Context Help\"));\n    contextHelpDock_->setWindowIcon(QIcon(\":icons/common/graphics/system-help.png\"));\n    contextHelpDock_->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea | Qt::BottomDockWidgetArea);\n    contextHelpDock_->setFeatures(QDockWidget::DockWidgetClosable | QDockWidget::DockWidgetMovable |\n        QDockWidget::DockWidgetFloatable);\n\n    // Initialize the help engine.\n    QSettings settings;\n    QString helpPath = settings.value(\"Platform/HelpPath\", \"Help\").toString();\n\n    QDir helpDirectory(helpPath);\n    if (helpDirectory.isRelative())\n    {\n        helpPath.prepend(QLatin1Char('/'));\n        helpPath.prepend(QCoreApplication::applicationDirPath());        \n    }  \n\n    QHelpEngine* helpEngine = new QHelpEngine(helpPath + \"/Kactus2Help.qhc\", mainWindow_);\n    helpEngine->setupData();\n\n    // Create the help window.\n    helpWnd_ = new HelpWindow(helpEngine, mainWindow_);\n\n    // Create the context help browser.\n    contextHelpBrowser_ = new ContextHelpBrowser(helpEngine, \"qthelp://com.tut.kactus2.2.0/doc\",\n        contextHelpDock_);\n\n    QColor bgColor = QApplication::palette().color(QPalette::Window);\n    QString style = QString(\"QTextBrowser { border: 5px solid transparent; \"\n        \"background-color: #%1}\").arg(bgColor.rgb() & 0x00FFFFFF, 0, 16);\n    contextHelpBrowser_->setStyleSheet(style);\n\n    contextHelpDock_->setWidget(contextHelpBrowser_);\n    mainWindow_->addDockWidget(Qt::RightDockWidgetArea, contextHelpDock_);\n\n    connect(this, SIGNAL(helpUrlRequested(QString const&)),\n        contextHelpBrowser_, SLOT(onHelpRequested(QString const&)), Qt::UniqueConnection);\n    contextHelpBrowser_->onHelpRequested(\"welcome.html\");\n}\n\n//-----------------------------------------------------------------------------\n// Function: DockWidgetHandler::setupLibraryDock()\n//-----------------------------------------------------------------------------\nvoid DockWidgetHandler::setupLibraryDock()\n{\n    // set up the dock widget for the library\n    libraryDock_ = new QDockWidget(tr(\"IP-XACT Library\"), mainWindow_);\n    libraryDock_->setObjectName(tr(\"Library\"));\n    libraryDock_->setWindowIcon(QIcon(\":icons/common/graphics/library.png\"));\n    libraryDock_->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);\n    libraryDock_->setFeatures(QDockWidget::DockWidgetClosable | QDockWidget::DockWidgetMovable |\n        QDockWidget::DockWidgetFloatable);\n\n    // create a container widget for dialer and library display\n    libraryWidget_ = new LibraryWidget(libraryHandler_, messageChannel_, mainWindow_);\n\n    libraryDock_->setWidget(libraryWidget_);\n    mainWindow_->addDockWidget(Qt::LeftDockWidgetArea, libraryDock_);\n\n    connect(this, SIGNAL(generateIntegrityReport()), libraryWidget_,\n        SLOT(onGenerateIntegrityReport()), Qt::UniqueConnection);\n\n    connect(libraryWidget_, SIGNAL(createAbsDef(const VLNV&, const QString&)),\n        mainWindow_, SLOT(createAbsDef(const VLNV&, const QString&)), Qt::UniqueConnection);\n\n    connect(libraryWidget_, SIGNAL(createDesignForExistingComponent(const VLNV&)),\n        mainWindow_, SLOT(createDesignForExistingComponent(const VLNV&)), Qt::UniqueConnection);\n\n    connect(libraryWidget_, SIGNAL(createSWDesign(const VLNV&)),\n        mainWindow_, SLOT(createSWDesign(const VLNV&)), Qt::UniqueConnection);\n\n    connect(libraryWidget_, SIGNAL(createSystemDesign(const VLNV&)),\n        mainWindow_, SLOT(createSystemDesign(const VLNV&)), Qt::UniqueConnection);\n\n\n    connect(libraryWidget_, SIGNAL(statusMessage(QString const&)),\n        this, SIGNAL(statusMessage(QString const&)));\n}\n\n//-----------------------------------------------------------------------------\n// Function: DockWidgetHandler::setupDesignParametersEditor()\n//-----------------------------------------------------------------------------\nvoid DockWidgetHandler::setupDesignParametersEditor()\n{\n    designParameterDock_ = new QDockWidget(tr(\"Design Parameters\"), mainWindow_);\n    designParameterDock_->setObjectName(tr(\"Design Parameters dock\"));\n    designParameterDock_->setAllowedAreas(Qt::BottomDockWidgetArea);\n    designParameterDock_->setFeatures(QDockWidget::DockWidgetClosable | QDockWidget::DockWidgetMovable |\n        QDockWidget::DockWidgetFloatable);\n\n    QSharedPointer<ExpressionFormatter> formatter(new ExpressionFormatter(designParameterFinder_));\n    QSharedPointer<ExpressionFormatter> referenceTreeFormatter(\n        new ExpressionFormatter(designAndInstancesParameterFinder_));\n    designAndInstancesParameterFinder_->addFinder(designParameterFinder_);\n\n    designParameterReferenceCounter_ = QSharedPointer<DesignParameterReferenceCounter>(\n        new DesignParameterReferenceCounter(designParameterFinder_));\n\n    designParameterTree_ =\n        new DesignParameterReferenceTree(referenceTreeFormatter, designParameterReferenceCounter_, mainWindow_);\n\n    // Set placeholder std revision here, real revision is set when the editor parameters are set in\n    // documentChanged and refreshDesignDocument.\n    designParametersEditor_ = new ParameterGroupBox(QSharedPointer<QList<QSharedPointer<Parameter> > >(),\n        QSharedPointer<QList<QSharedPointer<Choice> > >(), designParameterFinder_, formatter, Document::Revision::Std14, mainWindow_);\n\n    ParameterReferenceTreeWindow* designParameterReferenceWindow =\n        new ParameterReferenceTreeWindow(designParameterTree_, designParametersEditor_);\n\n    designParameterDock_->setWidget(designParametersEditor_);\n    mainWindow_->addDockWidget(Qt::BottomDockWidgetArea, designParameterDock_);\n\n    connect(designParametersEditor_, SIGNAL(contentChanged()),\n        this, SIGNAL(designChanged()), Qt::UniqueConnection);\n\n    connect(designParametersEditor_, SIGNAL(increaseReferences(QString)), \n        designParameterReferenceCounter_.data(), SLOT(increaseReferenceCount(QString)), Qt::UniqueConnection);\n    connect(designParametersEditor_, SIGNAL(decreaseReferences(QString)),\n        designParameterReferenceCounter_.data(), SLOT(decreaseReferenceCount(QString)), Qt::UniqueConnection);\n    connect(designParametersEditor_, SIGNAL(openReferenceTree(QString const&, QString const&)),\n        designParameterReferenceWindow, SLOT(openReferenceTree(QString const&, QString const&)),\n        Qt::UniqueConnection);\n\n    connect(designParametersEditor_,\n        SIGNAL(recalculateReferencesToParameters(QVector<QString> const&, AbstractParameterInterface*)),\n        designParameterReferenceCounter_.data(),\n        SLOT(recalculateReferencesToParameters(QVector<QString> const&, AbstractParameterInterface*)),\n        Qt::UniqueConnection);\n}\n\n//-----------------------------------------------------------------------------\n// Function: DockWidgetHandler::setupInstanceEditor()\n//-----------------------------------------------------------------------------\nvoid DockWidgetHandler::setupInstanceEditor()\n{\n    instanceDock_ = new QDockWidget(tr(\"Component Instance Details\"), mainWindow_);\n    instanceDock_->setObjectName(tr(\"Instance Editor\"));\n    instanceDock_->setWindowIcon(QIcon(\":icons/common/graphics/hw-component-edit.png\"));\n    instanceDock_->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);\n    instanceDock_->setFeatures(QDockWidget::DockWidgetClosable | QDockWidget::DockWidgetMovable |\n        QDockWidget::DockWidgetFloatable);\n\n    instanceEditor_ = new ComponentInstanceEditor(instanceDock_);\n    instanceDock_->setWidget(instanceEditor_);\n    mainWindow_->addDockWidget(Qt::RightDockWidgetArea, instanceDock_);\n\n    connect(instanceEditor_, SIGNAL(contentChanged()), this, SIGNAL(designChanged()), Qt::UniqueConnection);\n    connect(instanceEditor_, SIGNAL(increaseReferences(QString)),\n        designParameterReferenceCounter_.data(), SLOT(increaseReferenceCount(QString)), Qt::UniqueConnection);\n    connect(instanceEditor_, SIGNAL(decreaseReferences(QString)),\n        designParameterReferenceCounter_.data(), SLOT(decreaseReferenceCount(QString)), Qt::UniqueConnection);\n}\n\n//-----------------------------------------------------------------------------\n// Function: DockWidgetHandler::setupAdHocEditor()\n//-----------------------------------------------------------------------------\nvoid DockWidgetHandler::setupAdHocEditor()\n{\n    adhocDock_ = new QDockWidget(tr(\"Ad-hoc Port Editor\"), mainWindow_);\n    adhocDock_->setObjectName(tr(\"Ad-hoc Port Editor\"));\n    adhocDock_->setWindowIcon(QIcon(\":icons/common/graphics/adhoc.png\"));\n    adhocDock_->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);\n    adhocDock_->setFeatures(QDockWidget::DockWidgetClosable | QDockWidget::DockWidgetMovable |\n        QDockWidget::DockWidgetFloatable);\n\n    adhocEditor_ = new AdhocEditor(designParameterFinder_, adhocDock_);\n    adhocDock_->setWidget(adhocEditor_);\n    mainWindow_->addDockWidget(Qt::RightDockWidgetArea, adhocDock_);\n\n    connect(adhocEditor_, SIGNAL(increaseReferences(QString const&)), \n        designParameterReferenceCounter_.data(), SLOT(increaseReferenceCount(QString const&)),\n        Qt::UniqueConnection);\n    connect(adhocEditor_, SIGNAL(decreaseReferences(QString const&)),\n        designParameterReferenceCounter_.data(), SLOT(decreaseReferenceCount(QString const&)),\n        Qt::UniqueConnection);\n\n    connect(adhocEditor_, SIGNAL(contentChanged()), this, SIGNAL(designChanged()), Qt::UniqueConnection);\n}\n\n//-----------------------------------------------------------------------------\n// Function: DockWidgetHandler::setupConfigurationEditor()\n//-----------------------------------------------------------------------------\nvoid DockWidgetHandler::setupConfigurationEditor()\n{\n    configurationDock_ = new QDockWidget(tr(\"Design Configuration Details\"), mainWindow_);\n    configurationDock_->setObjectName(tr(\"Configuration editor\"));\n    configurationDock_->setWindowIcon(QIcon(\":icons/common/graphics/hierarchy-blue.png\"));\n    configurationDock_->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);\n    configurationDock_->setFeatures(QDockWidget::DockWidgetClosable | QDockWidget::DockWidgetMovable |\n        QDockWidget::DockWidgetFloatable);\n\n    configurationEditor_ = new ConfigurationEditor(libraryHandler_, configurationDock_);\n    configurationDock_->setWidget(configurationEditor_);\n    mainWindow_->addDockWidget(Qt::RightDockWidgetArea, configurationDock_);\n\n    connect(configurationEditor_, SIGNAL(contentChanged()), this, SIGNAL(designChanged()), Qt::UniqueConnection);\n}\n\n//-----------------------------------------------------------------------------\n// Function: DockWidgetHandler::setupSystemDetailsEditor()\n//-----------------------------------------------------------------------------\nvoid DockWidgetHandler::setupSystemDetailsEditor()\n{\n    systemDetailsDock_ = new QDockWidget(tr(\"HW Mapping Details\"), mainWindow_);\n    systemDetailsDock_->setObjectName(tr(\"HW Mapping Details Editor\"));\n    systemDetailsDock_->setWindowIcon(QIcon(\":icons/common/graphics/mapping.png\"));\n    systemDetailsDock_->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);\n    systemDetailsDock_->setFeatures(QDockWidget::DockWidgetClosable | QDockWidget::DockWidgetMovable |\n        QDockWidget::DockWidgetFloatable);\n\n    systemDetailsEditor_ = new SystemDetailsEditor(libraryHandler_, systemDetailsDock_);\n    systemDetailsDock_->setWidget(systemDetailsEditor_);\n    mainWindow_->addDockWidget(Qt::RightDockWidgetArea, systemDetailsDock_);\n\n    connect(systemDetailsEditor_, SIGNAL(contentChanged()), this, SIGNAL(designChanged()), Qt::UniqueConnection);\n}\n\n//-----------------------------------------------------------------------------\n// Function: DockWidgetHandler::setupInterfaceEditor()\n//-----------------------------------------------------------------------------\nvoid DockWidgetHandler::setupInterfaceEditor()\n{\n    interfaceDock_ = new QDockWidget(tr(\"Interface Editor\"), mainWindow_);\n    interfaceDock_->setObjectName(tr(\"Interface Editor\"));\n    interfaceDock_->setWindowIcon(QIcon(\":icons/common/graphics/tool-interface.png\"));\n    interfaceDock_->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);\n    interfaceDock_->setFeatures(QDockWidget::DockWidgetClosable | QDockWidget::DockWidgetMovable |\n        QDockWidget::DockWidgetFloatable);\n\n    interfaceEditor_ = new InterfaceEditor(interfaceDock_, libraryHandler_);\n    interfaceDock_->setWidget(interfaceEditor_);\n    mainWindow_->addDockWidget(Qt::RightDockWidgetArea, interfaceDock_);\n\n    connect(interfaceEditor_, SIGNAL(contentChanged()), this, SIGNAL(designChanged()), Qt::UniqueConnection);\n}\n\n//-----------------------------------------------------------------------------\n// Function: DockWidgetHandler::setupConnectionEditor()\n//-----------------------------------------------------------------------------\nvoid DockWidgetHandler::setupConnectionEditor()\n{\n    connectionDock_ = new QDockWidget(tr(\"Connection Editor\"), mainWindow_);\n    connectionDock_->setObjectName(tr(\"Connection Editor\"));\n    connectionDock_->setWindowIcon(QIcon(\":icons/common/graphics/tool-interconnection.png\"));\n    connectionDock_->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);\n    connectionDock_->setFeatures(QDockWidget::DockWidgetClosable | QDockWidget::DockWidgetMovable |\n        QDockWidget::DockWidgetFloatable);\n\n    connectionEditor_ = new ConnectionEditor(libraryHandler_, connectionDock_);\n    connectionDock_->setWidget(connectionEditor_);\n    mainWindow_->addDockWidget(Qt::RightDockWidgetArea, connectionDock_);\n}\n\n//-----------------------------------------------------------------------------\n// Function: DockWidgetHandler::setupVendorExtensionEditor()\n//-----------------------------------------------------------------------------\nvoid DockWidgetHandler::setupVendorExtensionEditor()\n{\n    extensionDock_ = new QDockWidget(tr(\"Vendor Extensions (experimental)\"), mainWindow_);\n    extensionDock_->setObjectName(tr(\"Vendor Extension Editor\"));\n    extensionDock_->setWindowIcon(QIcon(\":icons/common/graphics/puzzle.png\"));\n    extensionDock_->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea | Qt::BottomDockWidgetArea);\n    extensionDock_->setFeatures(QDockWidget::DockWidgetClosable | QDockWidget::DockWidgetMovable |\n        QDockWidget::DockWidgetFloatable);\n\n    extensionEditor_ = new VendorExtensionsEditor(connectionDock_);\n    extensionDock_->setWidget(extensionEditor_);\n    mainWindow_->addDockWidget(Qt::RightDockWidgetArea, extensionDock_);\n}\n\n\n//-----------------------------------------------------------------------------\n// Function: DockWidgetHandler::clearItemSelection()\n//-----------------------------------------------------------------------------\nvoid DockWidgetHandler::clearItemSelection(HWDesignWidget* designWidget)\n{\n    if (designWidget != 0)\n    {\n        QSharedPointer<Design> containedDesign = designWidget->getDiagram()->getDesign();\n\n        adhocEditor_->setVisibilityData(designWidget->getDiagram(), containedDesign,\n            designWidget->getEditProvider(), designWidget->isProtected());\n    }\n    else\n    {\n        adhocEditor_->clearVisibilityData();\n    }\n\n    instanceEditor_->clear();\n    interfaceEditor_->clear();\n    connectionEditor_->clear();\n    adhocEditor_->clearPortData();\n}\n\n//-----------------------------------------------------------------------------\n// Function: DockWidgetHandler::selectComponent()\n//-----------------------------------------------------------------------------\nvoid DockWidgetHandler::selectComponent(QWidget* currentTabWidget, ComponentItem* component)\n{\n    connectionEditor_->clear();\n    interfaceEditor_->clear();\n    adhocEditor_->clearPortData();\n\n    DesignWidget* designWidget(0);\n\n    HWDesignWidget* hwDesignWidget = dynamic_cast<HWDesignWidget*>(currentTabWidget);\n    if (hwDesignWidget)\n    {\n        designWidget = hwDesignWidget;\n    }\n    else\n    {\n        SystemDesignWidget* systemDesignWidget = dynamic_cast<SystemDesignWidget*>(currentTabWidget);\n        designWidget = systemDesignWidget;\n    }\n\n    QSharedPointer<Design> containingDesign = designWidget->getDiagram()->getDesign();\n\n    // Update the instance and ad-hoc visibility editors.\n    instanceEditor_->setComponentInstance(component, designWidget->getEditProvider(), containingDesign,\n        designWidget->getDiagram()->getDesignConfiguration(), designWidget->getOpenViewName());\n\n    HWComponentItem* hwComponent = dynamic_cast<HWComponentItem*>(component);\n    if (hwComponent != 0)\n    {\n        adhocEditor_->setVisibilityData(hwComponent, containingDesign, designWidget->getEditProvider(),\n            designWidget->isProtected());\n    }\n    else\n    {\n        adhocEditor_->clearVisibilityData();\n    }\n\n    VLNV componentVLNV = component->componentModel()->getVlnv();\n    libraryWidget_->selectComponent(componentVLNV);\n}\n\n//-----------------------------------------------------------------------------\n// Function: DockWidgetHandler::selectConnectionInterface()\n//-----------------------------------------------------------------------------\nvoid DockWidgetHandler::selectConnectionInterface(QWidget* currentTabWidget, ConnectionEndpoint* interface)\n{\n    adhocEditor_->clearVisibilityData();\n    connectionEditor_->clear();\n    instanceEditor_->clear();\n\n    if (!interface->isAdHoc())\n    {\n        DesignWidget* designWidget = dynamic_cast<DesignWidget*>(currentTabWidget);\n        if (designWidget)\n        {\n            interfaceEditor_->setInterface(interface, designWidget->getDiagram()->getDesign(),\n                designWidget->getDiagram()->getDesignConfiguration(), designWidget->getOpenViewName(),\n                designWidget->getEditProvider(), designWidget->isProtected());\n        }\n\n        adhocEditor_->clearPortData();\n    }\n    else\n    {\n        AdHocItem* adhocEndPoint = dynamic_cast<AdHocItem*>(interface);\n        if (adhocEndPoint)\n        {\n            HWDesignWidget* hwDesignWidget = dynamic_cast<HWDesignWidget*>(currentTabWidget);\n            if (hwDesignWidget)\n            {\n                HWDesignDiagram* hwDiagram = dynamic_cast<HWDesignDiagram*>(hwDesignWidget->getDiagram());\n                if (hwDiagram)\n                {\n                    adhocEditor_->setPortData(adhocEndPoint, hwDiagram, hwDesignWidget->getEditProvider());\n\n                    auto dataSource = dynamic_cast<AdHocEnabled*>(adhocEndPoint->encompassingComp());\n                    if (dataSource == nullptr)\n                    {\n                        dataSource = hwDiagram;\n                    }\n\n                    adhocEditor_->setVisibilityData(dataSource, hwDiagram->getDesign(), hwDesignWidget->getEditProvider(),\n                        hwDesignWidget->isProtected());\n                }\n            }\n        }\n        else\n        {\n            adhocEditor_->clearPortData();\n        }\n\n        interfaceEditor_->clear();\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: DockWidgetHandler::selectGraphicsConnection()\n//-----------------------------------------------------------------------------\nvoid DockWidgetHandler::selectGraphicsConnection(QWidget* currentTabWidget, GraphicsConnection* connection)\n{\n    DesignWidget* designWidget = dynamic_cast<DesignWidget*>(currentTabWidget);\n\n    Q_ASSERT(connection);\n    adhocEditor_->clearVisibilityData();\n    adhocEditor_->clearPortData();\n    instanceEditor_->clear();\n    interfaceEditor_->clear();\n    connectionEditor_->setConnection(connection, designWidget->getDiagram());\n}\n\n//-----------------------------------------------------------------------------\n// Function: DockWidgetHandler::updateWindows()\n//-----------------------------------------------------------------------------\nvoid DockWidgetHandler::updateWindows(QWidget* currentTabWidget)\n{\n    for (auto i = docks_.cbegin(); i != docks_.cend(); ++i)\n    {\n        updateWindowAndControlVisibility(currentTabWidget, i.key(), i.value());\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: DockWidgetHandler::updateWindowAndControlVisibility()\n//-----------------------------------------------------------------------------\nvoid DockWidgetHandler::updateWindowAndControlVisibility(QWidget* currentTabWidget,\n    TabDocument::SupportedWindows windowType, QDockWidget* dock)\n{\n    QAction* showAction = dock->toggleViewAction();\n\n    bool allowedToShow = isSupportedWindowType(currentTabWidget, windowType);\n    bool wantedToShow = visibilities_.value(windowType);\n\n    visibilityControls_[windowType]->setVisible(allowedToShow);\n    showAction->setVisible(allowedToShow && wantedToShow);\n    showAction->setChecked(allowedToShow && wantedToShow);\n}\n\n//-----------------------------------------------------------------------------\n// Function: DockWidgetHandler::isSupportedWindowType()\n//-----------------------------------------------------------------------------\nbool DockWidgetHandler::isSupportedWindowType(QWidget* currentTabWidget,\n    TabDocument::SupportedWindows windowType) const\n{\n    return currentlySupportedWindows(currentTabWidget) & windowType;\n}\n\n//-----------------------------------------------------------------------------\n// Function: DockWidgetHandler::currentlySupportedWindows()\n//-----------------------------------------------------------------------------\nunsigned int DockWidgetHandler::currentlySupportedWindows(QWidget* currentTabWidget) const\n{\n    unsigned int windows = defaultWindows();\n\n    TabDocument* doc = dynamic_cast<TabDocument*>(currentTabWidget);\n    if (doc != nullptr)\n    {\n        windows = doc->getSupportedWindows();\n    }\n\n    return windows;\n}\n\n//-----------------------------------------------------------------------------\n// Function: DockWidgetHandler::defaultWindows()\n//-----------------------------------------------------------------------------\nunsigned int DockWidgetHandler::defaultWindows() const\n{\n    return TabDocument::OUTPUTWINDOW | TabDocument::LIBRARYWINDOW | TabDocument::CONTEXT_HELP_WINDOW;\n}\n\n//-----------------------------------------------------------------------------\n// Function: DockWidgetHandler::documentChanged()\n//-----------------------------------------------------------------------------\nvoid DockWidgetHandler::documentChanged(TabDocument* doc)\n{    \n    ComponentEditor* componentEditor = dynamic_cast<ComponentEditor*>(doc);\n    DesignWidget* designwidget = dynamic_cast<DesignWidget*>(doc);\n\n    disconnect(extensionEditor_, SLOT(changeVendorExtensions(QString const&, QSharedPointer<Extendable>)));\n\n    if (doc)\n    {\n        connect(doc, SIGNAL(changeVendorExtensions(QString const&, QSharedPointer<Extendable>)),\n            extensionEditor_, SLOT(changeVendorExtensions(QString const&, QSharedPointer<Extendable>)));\n    }\n\n    if (componentEditor)\n    {\n        extensionEditor_->setContext(doc);\n\n        QSharedPointer<Component> editedComponent = componentEditor->getComponent();\n        QString extensionsID = QLatin1String(\"Component: \") + editedComponent->getVlnv().toString();\n\n        extensionEditor_->changeVendorExtensions(extensionsID, editedComponent);\n    }\n    else if(designwidget)\n    {\n        extensionEditor_->setContext(doc);\n\n        QSharedPointer<Design> editedDesign = designwidget->getDiagram()->getDesign();\n        QString extensionsID = QLatin1String(\"Design: \") + editedDesign->getVlnv().toString();\n\n        extensionEditor_->changeVendorExtensions(extensionsID, editedDesign);\n    }\n    else\n    {\n        extensionEditor_->clear();\n    }\n\n    // set the configuration manager to edit the active design\n    if (designwidget)\n    {\n        configurationEditor_->setConfiguration(designwidget);\n\n        QSharedPointer<Document> topItem = libraryHandler_->getModel(doc->getDocumentVLNV());\n        QSharedPointer<Component> topComponent = topItem.dynamicCast<Component>();\n        if (topComponent)\n        {\n            instanceEditor_->setContext(topComponent, designwidget->getDiagram()->getEditProvider());\n            instanceEditor_->setTopComponentActiveView(\n                topComponent->getModel()->findView(designwidget->getOpenViewName()));\n            instanceEditor_->setProtection(designwidget->isProtected());\n\n            QSharedPointer<Design> design = designwidget->getDiagram()->getDesign();\n            designParametersEditor_->setDisabled(designwidget->isProtected());\n            designParametersEditor_->setNewParameters(design->getParameters(), nullptr, design->getRevision());\n            designParameterTree_->setDesign(design);\n            designParameterReferenceCounter_->setDesign(design);\n\n            setupDesignParameterFinder(design);\n        }\n\n        if (doc->getSupportedWindows() & TabDocument::SYSTEM_DETAILS_WINDOW)\n        {\n            systemDetailsEditor_->setSystem(designwidget);\n        }\n        else\n        {\n            systemDetailsEditor_->clear();\n        }\n    }\n    // active tab is not design widget so clear the editors associated with design widget\n    else\n    {\n        configurationEditor_->clear();\n        systemDetailsEditor_->clear();\n        instanceEditor_->clear();\n        adhocEditor_->clearVisibilityData();\n        adhocEditor_->clearPortData();\n        interfaceEditor_->clear();\n        connectionEditor_->clear();\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: DockWidgetHandler::setupDesignParameterFinder()\n//-----------------------------------------------------------------------------\nvoid DockWidgetHandler::setupDesignParameterFinder(QSharedPointer<Design> newDesign)\n{\n    designParameterFinder_->setParameterList(newDesign->getParameters());\n\n    designAndInstancesParameterFinder_->removeAllFinders();\n    designAndInstancesParameterFinder_->addFinder(designParameterFinder_);\n\n    if (!newDesign->getComponentInstances()->isEmpty())\n    {\n        QList<QSharedPointer<const Component> > componentsWithFinders;\n\n        for (QSharedPointer<ComponentInstance> instance : *newDesign->getComponentInstances())\n        {\n            QSharedPointer<const Document> referencedDocument =\n                libraryHandler_->getModelReadOnly(*instance->getComponentRef().data());\n            if (referencedDocument)\n            {\n                QSharedPointer<const Component> instancedComponent =\n                    referencedDocument.dynamicCast<const Component>();\n                if (instancedComponent && !componentsWithFinders.contains(instancedComponent))\n                {\n                    QSharedPointer<ComponentParameterFinder> instanceFinder(\n                        new ComponentParameterFinder(instancedComponent));\n                    designAndInstancesParameterFinder_->addFinder(instanceFinder);\n\n                    componentsWithFinders.append(instancedComponent);\n                }\n            }\n        }\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: DockWidgetHandler::connectVisibilityControls()\n//-----------------------------------------------------------------------------\nvoid DockWidgetHandler::connectVisibilityControls()\n{\n    connect(visibilityControls_[TabDocument::OUTPUTWINDOW], SIGNAL(toggled(bool)),\n        this, SLOT(onOutputAction(bool)), Qt::UniqueConnection);\n    connect(visibilityControls_[TabDocument::CONTEXT_HELP_WINDOW], SIGNAL(toggled(bool)),\n        this, SLOT(onContextHelpAction(bool)), Qt::UniqueConnection);\n    connect(visibilityControls_[TabDocument::LIBRARYWINDOW], SIGNAL(toggled(bool)),\n        this, SLOT(onLibraryAction(bool)), Qt::UniqueConnection);\n    connect(visibilityControls_[TabDocument::CONFIGURATIONWINDOW], SIGNAL(toggled(bool)),\n        this, SLOT(onConfigurationAction(bool)), Qt::UniqueConnection);\n    connect(visibilityControls_[TabDocument::SYSTEM_DETAILS_WINDOW], SIGNAL(toggled(bool)),\n        this, SLOT(onSystemDetailsAction(bool)), Qt::UniqueConnection);\n    connect(visibilityControls_[TabDocument::CONNECTIONWINDOW], SIGNAL(toggled(bool)),\n        this, SLOT(onConnectionAction(bool)), Qt::UniqueConnection);\n    connect(visibilityControls_[TabDocument::INTERFACEWINDOW], SIGNAL(toggled(bool)),\n        this, SLOT(onInterfaceAction(bool)), Qt::UniqueConnection);\n    connect(visibilityControls_[TabDocument::INSTANCEWINDOW], SIGNAL(toggled(bool)),\n        this, SLOT(onInstanceAction(bool)), Qt::UniqueConnection);\n    connect(visibilityControls_[TabDocument::DESIGNPARAMETERSWINDOW], SIGNAL(toggled(bool)),\n        this, SLOT(onDesignParametersAction(bool)), Qt::UniqueConnection);\n    connect(visibilityControls_[TabDocument::ADHOC_WINDOW], SIGNAL(toggled(bool)),\n        this, SLOT(onAdHocEditorAction(bool)), Qt::UniqueConnection);\n    connect(visibilityControls_[TabDocument::VENDOREXTENSIONWINDOW], SIGNAL(toggled(bool)),\n        this, SLOT(onVendorExtensionVisibilityAction(bool)), Qt::UniqueConnection);\n}\n\n//-----------------------------------------------------------------------------\n// Function: DockWidgetHandler::disconnectVisibilityControls()\n//-----------------------------------------------------------------------------\nvoid DockWidgetHandler::disconnectVisibilityControls()\n{\n    disconnect(visibilityControls_[TabDocument::OUTPUTWINDOW], SIGNAL(toggled(bool)),\n        this, SLOT(onOutputAction(bool)));\n    disconnect(visibilityControls_[TabDocument::CONTEXT_HELP_WINDOW], SIGNAL(toggled(bool)),\n        this, SLOT(onContextHelpAction(bool)));\n    disconnect(visibilityControls_[TabDocument::LIBRARYWINDOW], SIGNAL(toggled(bool)),\n        this, SLOT(onLibraryAction(bool)));\n    disconnect(visibilityControls_[TabDocument::CONFIGURATIONWINDOW], SIGNAL(toggled(bool)),\n        this, SLOT(onConfigurationAction(bool)));\n    disconnect(visibilityControls_[TabDocument::SYSTEM_DETAILS_WINDOW], SIGNAL(toggled(bool)),\n        this, SLOT(onSystemDetailsAction(bool)));\n    disconnect(visibilityControls_[TabDocument::CONNECTIONWINDOW], SIGNAL(toggled(bool)),\n        this, SLOT(onConnectionAction(bool)));\n    disconnect(visibilityControls_[TabDocument::INTERFACEWINDOW], SIGNAL(toggled(bool)),\n        this, SLOT(onInterfaceAction(bool)));\n    disconnect(visibilityControls_[TabDocument::INSTANCEWINDOW], SIGNAL(toggled(bool)),\n        this, SLOT(onInstanceAction(bool)));\n    disconnect(visibilityControls_[TabDocument::DESIGNPARAMETERSWINDOW], SIGNAL(toggled(bool)),\n        this, SLOT(onDesignParametersAction(bool)));\n    disconnect(visibilityControls_[TabDocument::ADHOC_WINDOW], SIGNAL(toggled(bool)),\n        this, SLOT(onAdHocEditorAction(bool)));\n    disconnect(visibilityControls_[TabDocument::VENDOREXTENSIONWINDOW], SIGNAL(toggled(bool)),\n        this, SLOT(onVendorExtensionVisibilityAction(bool)));\n}\n\n//-----------------------------------------------------------------------------\n// Function: DockWidgetHandler::onOutputAction()\n//-----------------------------------------------------------------------------\nvoid DockWidgetHandler::onOutputAction( bool show )\n{\n    emit adjustVisibilityInWindow(TabDocument::OUTPUTWINDOW, show);\n}\n\n//-----------------------------------------------------------------------------\n// Function: DockWidgetHandler::onContextHelpAction()\n//-----------------------------------------------------------------------------\nvoid DockWidgetHandler::onContextHelpAction( bool show )\n{\n    emit adjustVisibilityInWindow(TabDocument::CONTEXT_HELP_WINDOW, show);\n}\n\n//-----------------------------------------------------------------------------\n// Function: DockWidgetHandler::onLibraryAction()\n//-----------------------------------------------------------------------------\nvoid DockWidgetHandler::onLibraryAction( bool show )\n{\n    emit adjustVisibilityInWindow(TabDocument::LIBRARYWINDOW, show);\n}\n\n//-----------------------------------------------------------------------------\n// Function: DockWidgetHandler::onConfigurationAction()\n//-----------------------------------------------------------------------------\nvoid DockWidgetHandler::onConfigurationAction( bool show )\n{\n    emit adjustVisibilityInWindow(TabDocument::CONFIGURATIONWINDOW, show);\n}\n\n//-----------------------------------------------------------------------------\n// Function: DockWidgetHandler::onSystemDetailsAction()\n//-----------------------------------------------------------------------------\nvoid DockWidgetHandler::onSystemDetailsAction( bool show )\n{\n    emit adjustVisibilityInWindow(TabDocument::SYSTEM_DETAILS_WINDOW, show);\n}\n\n//-----------------------------------------------------------------------------\n// Function: DockWidgetHandler::onConnectionAction()\n//-----------------------------------------------------------------------------\nvoid DockWidgetHandler::onConnectionAction( bool show )\n{\n    emit adjustVisibilityInWindow(TabDocument::CONNECTIONWINDOW, show);\n}\n\n//-----------------------------------------------------------------------------\n// Function: DockWidgetHandler::onVendorExtensionVisibilityAction()\n//-----------------------------------------------------------------------------\nvoid DockWidgetHandler::onVendorExtensionVisibilityAction(bool show)\n{\n    emit adjustVisibilityInWindow(TabDocument::VENDOREXTENSIONWINDOW, show);\n}\n\n//-----------------------------------------------------------------------------\n// Function: DockWidgetHandler::onInterfaceAction()\n//-----------------------------------------------------------------------------\nvoid DockWidgetHandler::onInterfaceAction( bool show )\n{\n    emit adjustVisibilityInWindow(TabDocument::INTERFACEWINDOW, show);\n}\n\n//-----------------------------------------------------------------------------\n// Function: DockWidgetHandler::onAdHocEditorAction()\n//-----------------------------------------------------------------------------\nvoid DockWidgetHandler::onAdHocEditorAction(bool show)\n{\n    emit adjustVisibilityInWindow(TabDocument::ADHOC_WINDOW, show);\n}\n\n//-----------------------------------------------------------------------------\n// Function: DockWidgetHandler::onInstanceAction()\n//-----------------------------------------------------------------------------\nvoid DockWidgetHandler::onInstanceAction( bool show )\n{\n    emit adjustVisibilityInWindow(TabDocument::INSTANCEWINDOW, show);\n}\n\n//-----------------------------------------------------------------------------\n// Function: DockWidgetHandler::onDesignParametersAction()\n//-----------------------------------------------------------------------------\nvoid DockWidgetHandler::onDesignParametersAction(bool show)\n{\n    emit adjustVisibilityInWindow(TabDocument::DESIGNPARAMETERSWINDOW, show);\n}\n\n//-----------------------------------------------------------------------------\n// Function: DockWidgetHandler::onDockLocationChanged()\n//-----------------------------------------------------------------------------\nvoid DockWidgetHandler::onDockLocationChanged(Qt::DockWidgetArea area)\n{\n    auto const& dock = qobject_cast<QDockWidget*>(sender());\n    auto action = dock->toggleViewAction();\n\n    placeActionInToolbar(action, area);\n}\n\n//-----------------------------------------------------------------------------\n// Function: DockWidgetHandler::setWindowVisibilityForSupportedWindow()\n//-----------------------------------------------------------------------------\nvoid DockWidgetHandler::setWindowVisibilityForSupportedWindow(QWidget* currentTabWidget,\n    TabDocument::SupportedWindows type, bool show)\n{\n    if (isSupportedWindowType(currentTabWidget, type))\n    {\n        setWindowVisibility(type, show);\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: DockWidgetHandler::setWindowVisibility()\n//-----------------------------------------------------------------------------\nvoid DockWidgetHandler::setWindowVisibility(TabDocument::SupportedWindows windowType, bool show)\n{\n    visibilities_.insert(windowType, show);\n\n    visibilityControls_[windowType]->setChecked(show);\n    docks_[windowType]->toggleViewAction()->setVisible(show);\n    docks_[windowType]->setVisible(show);\n}\n\n//-----------------------------------------------------------------------------\n// Function: DockWidgetHandler::placeActionInToolbar()\n//-----------------------------------------------------------------------------\nvoid DockWidgetHandler::placeActionInToolbar(QAction* action, Qt::DockWidgetArea area)\n{\n    if ((area == Qt::LeftDockWidgetArea && leftActions_->actions().contains(action)) ||\n        (area == Qt::RightDockWidgetArea && rightActions_->actions().contains(action)))\n    {\n        return;\n    }\n\n    leftActions_->removeAction(action);\n    leftToolbar_->removeAction(action);\n\n    rightActions_->removeAction(action);\n    rightToolbar_->removeAction(action);\n\n    if (area == Qt::LeftDockWidgetArea)\n    {\n        leftActions_->addAction(action);\n        leftToolbar_->addAction(action);\n    }\n    else if (area == Qt::RightDockWidgetArea)\n    {\n        rightActions_->addAction(action);\n        rightToolbar_->addAction(action);\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: DockWidgetHandler::changeProtection()\n//-----------------------------------------------------------------------------\nvoid DockWidgetHandler::changeProtection(TabDocument* doc, bool locked)\n{\n    extensionEditor_->setLocked(locked);\n\n    DesignWidget* designwidget = dynamic_cast<DesignWidget*>(doc);\n    if (designwidget)\n    {\n        // update the editors to match the locked state\n        configurationEditor_->setLocked(locked);\n        instanceEditor_->setProtection(locked);\n        designParametersEditor_->setDisabled(locked);\n\n        if (designwidget->getSupportedWindows() & TabDocument::SYSTEM_DETAILS_WINDOW)\n        {\n            systemDetailsEditor_->setLocked(locked);\n        }\n    }\n    else\n    {        \n        configurationEditor_->setLocked(true);\n        systemDetailsEditor_->setLocked(true);\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: DockWidgetHandler::getDesignAndInstanceParameterFinder()\n//-----------------------------------------------------------------------------\nQSharedPointer<MultipleParameterFinder> DockWidgetHandler::getDesignAndInstanceParameterFinder() const\n{\n    return designAndInstancesParameterFinder_;\n}\n\n//-----------------------------------------------------------------------------\n// Function: DockWidgetHandler::getDesignParameterFinder()\n//-----------------------------------------------------------------------------\nQSharedPointer<ListParameterFinder> DockWidgetHandler::getDesignParameterFinder() const\n{\n    return designParameterFinder_;\n}\n\n//-----------------------------------------------------------------------------\n// Function: DockWidgetHandler::refreshDesignDocument()\n//-----------------------------------------------------------------------------\nvoid DockWidgetHandler::refreshDesignDocument(QWidget* currentTabWidget)\n{\n    TabDocument* doc = static_cast<TabDocument*>(currentTabWidget);\n   \n    DesignWidget* designWidget = dynamic_cast<DesignWidget*>(doc);\n    if (designWidget)\n    {\n        QSharedPointer<Document> topItem = libraryHandler_->getModel(doc->getDocumentVLNV());\n        QSharedPointer<Component> topComponent = topItem.dynamicCast<Component>();\n\n        instanceEditor_->setContext(topComponent, designWidget->getDiagram()->getEditProvider());\n\n        QSharedPointer<Design> design = designWidget->getDiagram()->getDesign();\n        designParametersEditor_->setNewParameters(design->getParameters(), nullptr, design->getRevision());\n        designParameterTree_->setDesign(design);\n        designParameterReferenceCounter_->setDesign(design);\n\n        setupDesignParameterFinder(design);\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: DockWidgetHandler::showHelp()\n//-----------------------------------------------------------------------------\nvoid DockWidgetHandler::showHelp()\n{\n    helpWnd_->show();\n}\n"
  },
  {
    "path": "mainwindow/DockWidgetHandler.h",
    "content": "//-----------------------------------------------------------------------------\n// File: DockWidgetHandler.h\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Mikko Teuho\n// Date: 10.10.2017\n//\n// Description:\n// Manages the dockable widgets for the main window.\n//-----------------------------------------------------------------------------\n\n#ifndef DOCKWIDGETHANDLER_H\n#define DOCKWIDGETHANDLER_H\n\n#include <KactusAPI/include/utils.h>\n#include <common/widgets/tabDocument/TabDocument.h>\n#include <editors/PythonSourceEditor/PythonSourceEditor.h>\n\nclass LibraryHandler;\nclass LibraryWidget;\nclass MessageConsole;\nclass ContextHelpBrowser;\nclass DesignParameterReferenceCounter;\nclass ParameterGroupBox;\nclass DesignParameterReferenceTree;\nclass ListParameterFinder;\nclass MultipleParameterFinder;\nclass ComponentInstanceEditor;\nclass AdhocEditor;\nclass ConfigurationEditor;\nclass SystemDetailsEditor;\nclass InterfaceEditor;\nclass ConnectionEditor;\nclass HelpWindow;\nclass HWDesignWidget;\nclass ComponentItem;\nclass ConnectionEndpoint;\nclass GraphicsConnection;\nclass Design;\nclass MessageMediator;\nclass VendorExtensionsEditor;\nclass ScriptingConsole;\n\n#include <QSharedPointer>\n#include <QDockWidget>\n#include <QObject>\n#include <QMainWindow>\n#include <QSettings>\n\n//-----------------------------------------------------------------------------\n//! Manages the dockable widgets for the main window.\n//-----------------------------------------------------------------------------\nclass DockWidgetHandler: public QObject\n{\n    Q_OBJECT\n\npublic:\n\n    /*!\n     *  The constructor.\n     *\n     *    @param [in] library         The used IP-XACT library.\n     *    @param [in] messageChannel  The message channel for notifications and errors.\n     *    @param [in] leftToolbar     The left side toolbar in mainwindow.\n     *    @param [in] rightToolbar    The right side toolbar in mainwindow.\n     *    @param [in] parent          The main window.\n     */\n    DockWidgetHandler(LibraryHandler* library, MessageMediator* messageChannel, \n        QToolBar* leftToolbar, QToolBar* rightToolbar, QMainWindow* parent);\n\n    /*!\n     *  The destructor.\n     */\n    virtual ~DockWidgetHandler() = default;\n\n    //! No copying. No Assignment.\n    DockWidgetHandler(const DockWidgetHandler& other) = delete;\n    DockWidgetHandler& operator=(const DockWidgetHandler& other) = delete;\n\n    /*!\n     *  Setup the dock widgets.\n     */\n    void setupDockWidgets();\n\n    /*!\n     *  Setup the visibility actions for the visibility menu.\n     *\n     *    @param [in] visibilityMenu  The visibility menu.\n     */\n    void setupVisibilityActionMenu(QMenu& visibilityMenu);\n\n    /*!\n     *  Get the library handler created by the library widget.\n     *\n     *    @return The library handler.\n     */\n    LibraryHandler* getLibraryHandler() const;\n\n    /*!\n     *  Load the visibilities for the dockable items.\n     *\n     *    @param [in] settings    Settings containing the visibilities for the dockable items.\n     */\n    void loadVisiblities(QSettings const& settings);\n\n    /*!\n     *  Save settings for dock widget visibilities.\n     *\n     *    @param [in] settings    The settings.\n     */\n    void saveVisibilitySettings(QSettings& settings) const;\n\n    /*!\n     *  Set filter settings for the library.\n     *\n     *    @param [in] settings    Settings containing the library filters.\n     */\n    void loadFilterSettings(QSettings& settings);\n\n    /*!\n     *  Save settings for dock widget filters.\n     *\n     *    @param [in] settings    The settings.\n     */\n    void saveFilterSettings(QSettings& settings) const;\n\n    //! Apply the current application settings to widgets.\n    void applySettings();\n\n    /*!\n     *  Clear the item selection in design.\n     *\n     *    @param [in] designWidget    Design widget containing the HW design.\n     */\n    void clearItemSelection(HWDesignWidget* designWidget);\n\n    /*!\n     *  Select a component item in design.\n     *\n     *    @param [in] currentTabWidget    The currently active tab widget.\n     *    @param [in] component           The selected component item.\n     */\n    void selectComponent(QWidget* currentTabWidget, ComponentItem* component);\n\n    /*!\n     *  Select a connection interface.\n     *\n     *    @param [in] currentTabWidget    The currently active tab widget.\n     *    @param [in] interface           The selected interface.\n     */\n    void selectConnectionInterface(QWidget* currentTabWidget, ConnectionEndpoint* interface);\n\n    /*!\n     *  Select a connection item.\n     *\n     *    @param [in] currentTabWidget    The currently active tab widget.\n     *    @param [in] connection          The selected connection item.\n     */\n    void selectGraphicsConnection(QWidget* currentTabWidget, GraphicsConnection* connection);\n\n    /*!\n     *  Update the visibility of the dock widgets.\n     *\n     *    @param [in] tabCount            Number of items in the tab queue.\n     *    @param [in] currentTabWidget    The currently active tab widget.\n     */\n    void updateWindows(QWidget* currentTabWidget);\n\n    /*!\n     *  Update the visibility of the selected dock widget.\n     *\n     *    @param [in] currentTabWidget    The currently active tab widget.\n     *    @param [in] windowType          Type selected dock widget.\n     *    @param [in] dock                The selected dock widget.\n     */\n    void updateWindowAndControlVisibility(QWidget* currentTabWidget,\n        TabDocument::SupportedWindows windowType, QDockWidget* dock);\n\n    /*!\n     *  Handle the change of the currently active tab document.\n     *\n     *    @param [in] doc     The new active tab document.\n     */\n    void documentChanged(TabDocument* doc);\n\n    /*!\n     *  Connect the dock widget visibility controls.\n     */\n    void connectVisibilityControls();\n\n    /*!\n     *  Disconnect the dock widget visibility controls.\n     */\n    void disconnectVisibilityControls();\n\n    /*!\n     *  Set visibility for the supported window types.\n     *\n     *    @param [in] currentTabWidget    The currently active tab widget.\n     *    @param [in] type                Type of the selected dock widget.\n     *    @param [in] show                The new visibility value.\n     */\n    void setWindowVisibilityForSupportedWindow(QWidget* currentTabWidget,\n        TabDocument::SupportedWindows type, bool show);\n\n    /*!\n     *  Change the locking status of the dock widgets.\n     *\n     *    @param [in] doc     The currently active tab document.\n     *    @param [in] locked  The new lock value.\n     */\n    void changeProtection(TabDocument* doc, bool locked);\n\n    /*!\n     *  Get the design parameter reference tree finder.\n     *\n     *    @return The design parameter reference tree finder.\n     */\n    QSharedPointer<MultipleParameterFinder> getDesignAndInstanceParameterFinder() const;\n\n    /*!\n     *  Get the design parameter finder.\n     *\n     *    @return The design parameter finder.\n     */\n    QSharedPointer<ListParameterFinder> getDesignParameterFinder() const;\n\n    /*!\n     *  Refresh the design document.\n     *\n     *    @param [in] currentTabWidget    The currently active tab widget.\n     */\n    void refreshDesignDocument(QWidget* currentTabWidget);\n\n    /*!\n     *  Setup the design parameter finder.\n     *\n     *    @param [in] newDesign   The design of the currently active design tab document.\n     */\n    void setupDesignParameterFinder(QSharedPointer<Design> newDesign);\n\npublic slots:\n\n    /*!\n     *  Handles the display of the help window.\n     */\n    void showHelp();\n\nsignals:\n\n    /*!\n     *  Transfers error messages between the main window and the message console.\n     *\n     *    @param [in] message     The error message.\n     */\n    void errorMessage(QString const& message);\n\n    /*!\n     *  Transfers notice messages between the main window and the message console.\n     *\n     *    @param [in] message     The notice message.\n     */\n    void noticeMessage(QString const& message);\n\n    void statusMessage(QString const& message);\n\n    /*!\n     *  Transfers URL context help requirement between the main window and the message console.\n     *\n     *    @param [in] message     The URL required for the context help window.\n     */\n    void helpUrlRequested(QString const& helpURL);\n\n    /*!\n     *  Transfers design change information from the main window to the dock widgets.\n     */\n    void designChanged();\n\n    /*!\n     *  Transfers the visibility change in the selected dock widget type to main window in order to receive\n     *  required tab document data.\n     *\n     *    @param [in] type    Type of the selected dock widget.\n     *    @param [in] show    Value for the display of the dock widget.\n     */\n    void adjustVisibilityInWindow(TabDocument::SupportedWindows type, bool show);\n\n    void generateIntegrityReport();\n\nprivate slots:\n\n    /*!\n     *  Handles the action for the visibility of the output dock widget.\n     *\n     *    @param [in] show    Value for the visibility of the output dock widget.\n     */\n    void onOutputAction(bool show);\n\n    /*!\n     *  Handles the action for the visibility of the context help dock widget.\n     *\n     *    @param [in] show    Value for the visibility of the context help dock widget.\n     */\n    void onContextHelpAction(bool show);\n\n    /*!\n     *  Handles the action for the visibility of the library dock widget.\n     *\n     *    @param [in] show    Value for the visibility of the library dock widget.\n     */\n    void onLibraryAction(bool show);\n\n    /*!\n     *  Handles the action for the visibility of the design configuration dock widget.\n     *\n     *    @param [in] show    Value for the visibility of the design configuration dock widget.\n     */\n    void onConfigurationAction(bool show);\n\n    /*!\n     *  Handles the action for the visibility of the system details dock widget.\n     *\n     *    @param [in] show    Value for the visibility of the system details dock widget.\n     */\n    void onSystemDetailsAction(bool show);\n\n    /*!\n     *  Handles the action for the visibility of the connection editor dock widget.\n     *\n     *    @param [in] show    Value for the visibility of the connection editor dock widget.\n     */\n    void onConnectionAction(bool show);\n\n    /*!\n    *  Handles the action for the visibility of the vendor extension editor dock widget.\n    *\n    *    @param [in] show    Value for the visibility of the vendor extension editor dock widget.\n    */\n    void onVendorExtensionVisibilityAction(bool show);\n\n    /*!\n     *  Handles the action for the visibility of the interface editor dock widget.\n     *\n     *    @param [in] show    Value for the visibility of the interface editor dock widget.\n     */\n    void onInterfaceAction(bool show);\n\n    /*!\n     *  Handles the action for the visibility of the component instance dock widget.\n     *\n     *    @param [in] show    Value for the visibility of the component instance dock widget.\n     */\n    void onInstanceAction(bool show);\n\n    /*!\n     *  Handles the action for the visibility of the design parameters editor dock widget.\n     *\n     *    @param [in] show    Value for the visibility of the design parameters editor dock widget.\n     */\n    void onDesignParametersAction(bool show);\n\n    /*!\n     *  Handles the action for the visibility of the ad hoc port editor dock widget.\n     *\n     *    @param [in] show    Value for the visibility of the ad hoc port editor dock widget.\n     */\n    void onAdHocEditorAction(bool show);\n\n    /*!\n     *  Handles the change for the dock position.\n     *\n     *    @param [in] area    The area where the dock has been positioned.\n     */\n    void onDockLocationChanged(Qt::DockWidgetArea area);\n\n\nprivate:\n\n    /*!\n     *  Setup the message console and the containing output dock widget.\n     */\n    void setupMessageConsole();\n\n    /*!\n     *  Setup the context help dock widget.\n     */\n    void setupContextHelp();\n\n    /*!\n     *  Setup the library dock widget.\n     */\n    void setupLibraryDock();\n\n    /*!\n     *  Setup the design parameters editor dock widget.\n     */\n    void setupDesignParametersEditor();\n\n    /*!\n     *  Setup the component instance editor dock widget.\n     */\n    void setupInstanceEditor();\n\n    /*!\n     *  Setup the ad hoc port editor dock widget.\n     */\n    void setupAdHocEditor();\n    \n    /*!\n     *  Setup the design configuration editor dock widget.\n     */\n    void setupConfigurationEditor();\n    \n    /*!\n     *  Setup the system details editor dock widget.\n     */\n    void setupSystemDetailsEditor();\n    \n    /*!\n     *  Setup the interface editor dock widget.\n     */\n    void setupInterfaceEditor();\n    \n    /*!\n     *  Setup the connection editor dock widget.\n     */\n    void setupConnectionEditor();\n\n    /*!\n    *  Setup the vendor extension editor dock widget.\n    */\n    void setupVendorExtensionEditor();\n\n    /*!\n     *  Check if the selected window type is supported by the currently active tab widget.\n     *\n     *    @param [in] tabCount            Number of items in the tab queue.\n     *    @param [in] currentTabWidget    The currently active tab widget.\n     *    @param [in] windowType          Type of the selected window.\n     *\n     *    @return True, if the window type is supported by the active document, false otherwise.\n     */\n    bool isSupportedWindowType(QWidget* currentTabWidget,\n        TabDocument::SupportedWindows windowType) const;\n\n    /*!\n     *  Get the supported windows for the currently active tab widget.\n     *\n     *    @param [in] currentTabWidget    The currently active tab widget.\n     *\n     *    @return The currently supported dock widgets.\n     */\n    unsigned int currentlySupportedWindows(QWidget* currentTabWidget) const;\n\n    /*!\n     *  Get the dock widgets that are visible regardless of the currently active tad document.\n     *\n     *    @return The default dock widgets.\n     */\n    unsigned int defaultWindows() const;\n\n    /*!\n     *  Set the visibility for the selected dock widget.\n     *\n     *    @param [in] windowType  The type of the selected dock widget.\n     *    @param [in] show        The new visibility value.\n     */\n    void setWindowVisibility(TabDocument::SupportedWindows windowType, bool show);\n\n\n    /*!\n     * Places the visibility control action in the correct toolbar.\n     *\n     *    @param [in] action   The action to place in the toolbar.\n     *    @param [in] area     The area where the related dock widget is located.\n     *\n     *    @return \n     */\n     void placeActionInToolbar(QAction* action, Qt::DockWidgetArea area);\n\n    //-----------------------------------------------------------------------------\n    // Data.\n    //-----------------------------------------------------------------------------\n\n    //! The instance that manages the IP-XACT library\n    LibraryHandler *libraryHandler_;\n\n    //! The dock widget that contains the library widgets.\n    QDockWidget* libraryDock_;\n\n    //! The widget containing library navigation.\n    LibraryWidget* libraryWidget_;\n\n    //! The widget to print errors and notifications to user.\n    MessageConsole* console_;\n\n    //! The dock widget that contains the console.\n    QDockWidget* consoleDock_;\n\n    //! Context help browser.\n    ContextHelpBrowser* contextHelpBrowser_;\n\n    //! The dock widget for the context help browser.\n    QDockWidget* contextHelpDock_;\n\n    //! Reference counter for design parameters.\n    QSharedPointer<DesignParameterReferenceCounter> designParameterReferenceCounter_;\n\n    //! Editor for design parameters.\n    ParameterGroupBox* designParametersEditor_;\n\n    //! Dock widget for the design parameters editor.\n    QDockWidget* designParameterDock_;\n\n    //! Reference tree containing the design parameter references.\n    DesignParameterReferenceTree* designParameterTree_;\n\n    //! Parameter finder for design parameters.\n    QSharedPointer<ListParameterFinder> designParameterFinder_;\n\n    //! Parameter finder for design parameter reference tree.\n    QSharedPointer<MultipleParameterFinder> designAndInstancesParameterFinder_;\n\n    //! The widget to edit the settings of a component instance.\n    ComponentInstanceEditor* instanceEditor_;\n\n    //! The dock widget that contains the instance editor.\n    QDockWidget* instanceDock_;\n\n    //! Ad hoc editor.\n    AdhocEditor* adhocEditor_;\n\n    //! The ad hoc dock widget.\n    QDockWidget* adhocDock_;\n\n    //! The widget to edit the configuration of designs.\n    ConfigurationEditor* configurationEditor_;\n\n    //! The dock widget that contains the configuration editor.\n    QDockWidget* configurationDock_;\n\n    //! The widget to edit system details.\n    SystemDetailsEditor* systemDetailsEditor_;\n\n    //! The dock widget for the system details editor.\n    QDockWidget* systemDetailsDock_;\n\n    //! The widget to edit the interfaces\n    InterfaceEditor* interfaceEditor_;\n\n    //! The dock widget that contains the interface editor.\n    QDockWidget* interfaceDock_;\n\n    //! The widget to edit the connection\n    ConnectionEditor* connectionEditor_;\n\n    //! The dock widget that contains the connection editor.\n    QDockWidget* connectionDock_;\n\n\n    //! The dock widget that contains the vendor extension editor.\n    QDockWidget* extensionDock_;\n\n    //! The editor for vendor extensions.\n    VendorExtensionsEditor* extensionEditor_;\n\n    //! The help window.\n    HelpWindow* helpWnd_;\n\n    //! All the dock widgets.\n    QMap<TabDocument::SupportedWindows, QDockWidget*> docks_;\n\n    //! Visibility control actions for the dock widgets.\n    QMap<TabDocument::SupportedWindows, QAction*> visibilityControls_;\n\n    //! Contains the visibility for the windows.\n    //! Used to maintain the visibility information when windows are hidden by change of the active document.\n    QMap<TabDocument::SupportedWindows, bool> visibilities_;\n\n    //! The left side toolbar.\n    QToolBar* leftToolbar_;\n\n    //! The right side toolbar.\n    QToolBar* rightToolbar_;\n\n    //! Action group for left side toolbar.\n    QActionGroup* leftActions_;\n\n    //! Action group for right side toolbar.\n    QActionGroup* rightActions_;\n\n    //! The main window that should contain all of the dock widgets constructed in here.\n    QMainWindow* mainWindow_;\n\n    MessageMediator* messageChannel_;\n    \n};\n\n#endif // DOCKWIDGETHANDLER_H\n"
  },
  {
    "path": "mainwindow/DrawingBoard/DrawingBoard.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: DrawingBoard.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Joni-Matti Maatta\r\n// Date: 28.3.2012\r\n//\r\n// Description:\r\n// The drawing board for holding various IP-XACT documents.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"DrawingBoard.h\"\r\n\r\n#include <common/widgets/tabDocument/TabDocument.h>\r\n\r\n#include <IPXACTmodels/common/VLNV.h>\r\n\r\n#include <QCoreApplication>\r\n#include <QKeyEvent>\r\n#include <QObject>\r\n#include <QMessageBox>\r\n#include <QMenu>\r\n#include <QTabBar>\r\n#include <QSettings>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DrawingBoard::DrawingBoard()\r\n//-----------------------------------------------------------------------------\r\nDrawingBoard::DrawingBoard(QWidget* parent) : QTabWidget(parent)\r\n{\r\n    connect(this, SIGNAL(tabCloseRequested(int)), this, SLOT(closeAndRemoveDocument(int)), Qt::UniqueConnection);\r\n\r\n    tabBar()->installEventFilter(this);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DrawingBoard::addAndOpenDocument()\r\n//-----------------------------------------------------------------------------\r\nvoid DrawingBoard::addAndOpenDocument(TabDocument* doc)\r\n{    \r\n    // Open in unlocked mode by default if locking isn't enabled in settings.\r\n    QSettings settings; \r\n    doc->setProtection(settings.value(\"General/EnableLocking\").toBool());\r\n\r\n    connect(doc, SIGNAL(errorMessage(QString const&)),\r\n        this, SIGNAL(errorMessage(QString const&)), Qt::UniqueConnection);\r\n    connect(doc, SIGNAL(noticeMessage(QString const&)),\r\n        this, SIGNAL(noticeMessage(QString const&)), Qt::UniqueConnection);\r\n\r\n    connect(doc, SIGNAL(helpUrlRequested(QString const&)),\r\n        this, SIGNAL(helpUrlRequested(QString const&)), Qt::UniqueConnection);\r\n\r\n    connect(doc, SIGNAL(contentChanged()), this, SIGNAL(documentContentChanged()), Qt::UniqueConnection);\r\n    connect(doc, SIGNAL(modifiedChanged(bool)), this, SIGNAL(documentModifiedChanged(bool)), Qt::UniqueConnection);\r\n    connect(doc, SIGNAL(documentSaved(TabDocument*)),\r\n        this, SLOT(onDocumentSaved(TabDocument*)), Qt::UniqueConnection);\r\n    connect(doc, SIGNAL(titleChanged(TabDocument*, QString const&)),\r\n        this, SLOT(onDocumentTitleChanged(TabDocument*, QString const&)), Qt::UniqueConnection);\r\n\r\n    if (doc->getEditProvider() != 0)\r\n    {\r\n        connect(doc->getEditProvider().data(), SIGNAL(editStateChanged()), this, SIGNAL(documentEditStateChanged()));\r\n    }\r\n\r\n    addTab(doc, doc->getTitle());\r\n    setCurrentWidget(doc);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DrawingBoard::applySettings()\r\n//-----------------------------------------------------------------------------\r\nvoid DrawingBoard::applySettings()\r\n{\r\n    QSettings settings;\r\n\r\n    // Apply the settings to the open documents.\r\n    for (int i = 0; i < count(); ++i)\r\n    {\r\n        TabDocument* doc = static_cast<TabDocument*>(widget(i));\r\n        Q_ASSERT(doc != 0);\r\n\r\n        doc->applySettings(settings);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DrawingBoard::saveCurrentDocument()\r\n//-----------------------------------------------------------------------------\r\nvoid DrawingBoard::saveCurrentDocument()\r\n{\r\n    TabDocument* doc = static_cast<TabDocument*>(currentWidget());\r\n\r\n    if (doc != 0 && shouldSave(doc))\r\n    {\r\n        doc->save();\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DrawingBoard::saveCurrentDocumentAs()\r\n//-----------------------------------------------------------------------------\r\nvoid DrawingBoard::saveCurrentDocumentAs()\r\n{\r\n    TabDocument* doc = static_cast<TabDocument*>(currentWidget());\r\n\r\n    if (doc != 0 && shouldSave(doc) && doc->saveAs())\r\n    {\r\n        doc->refresh();\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DrawingBoard::saveAll()\r\n//-----------------------------------------------------------------------------\r\nvoid DrawingBoard::saveAll()\r\n{\r\n    // Go through all documents and save those that have been modified.\r\n    for (int i = 0; i < count(); ++i)\r\n    {\r\n        TabDocument* doc = static_cast<TabDocument*>(widget(i));\r\n\r\n        if (doc != 0 && doc->isModified())\r\n        {\r\n            if (!shouldSave(doc))\r\n            {\r\n                return;\r\n            }\r\n\r\n            doc->save();\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DrawingBoard::printCurrentDocument()\r\n//-----------------------------------------------------------------------------\r\nvoid DrawingBoard::printCurrentDocument()\r\n{\r\n    TabDocument* doc = static_cast<TabDocument*>(currentWidget());\r\n    Q_ASSERT(doc != 0);\r\n\r\n    doc->print();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DrawingBoard::exportCurrentDocumentAsImage()\r\n//-----------------------------------------------------------------------------\r\nvoid DrawingBoard::exportCurrentDocumentAsImage()\r\n{\r\n    TabDocument* document = static_cast<TabDocument*>(currentWidget());\r\n    if (document)\r\n    {\r\n        bool exportSucceeds = document->exportImage();\r\n        QString documentTitle = document->getTitle();\r\n        if (exportSucceeds)\r\n        {\r\n            emit noticeMessage(QStringLiteral(\"Image export complete for \") + documentTitle);\r\n        }\r\n        else\r\n        {\r\n            emit errorMessage(QStringLiteral(\"Failed to export image of \") + documentTitle);\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DrawingBoard::refreshCurrentDocument()\r\n//-----------------------------------------------------------------------------\r\nvoid DrawingBoard::refreshCurrentDocument()\r\n{\r\n    TabDocument* doc = static_cast<TabDocument*>(currentWidget());\r\n\r\n    if (doc == 0)\r\n    {\r\n        return;\r\n    }\r\n\r\n    if (!doc->fileExists())\r\n    {\r\n        QString warningText = tr(\"The document has been deleted.\");\r\n\r\n        QMessageBox msgBox(QMessageBox::Warning, QCoreApplication::applicationName(), warningText,\r\n            QMessageBox::Close, this);\r\n\r\n        if (msgBox.exec() == QMessageBox::Yes)\r\n        {\r\n            doc->save();\r\n        }\r\n\r\n        delete doc;\r\n\r\n        return;\r\n    }\r\n\r\n    if (doc->isModified())\r\n    {\r\n        QVector<QString> errorList;\r\n        bool documentIsValid = doc->validate(errorList);\r\n\r\n        QString warningText = tr(\"The document has been modified. Save changes before refresh?\");\r\n\r\n        if (!documentIsValid)\r\n        {\r\n            QString errorText = tr(\"%1 error(s) located within the document.\").arg(QString::number(errorList.size()));\r\n            warningText.append(\"\\n\" + errorText);\r\n        }\r\n\r\n        QMessageBox msgBox(QMessageBox::Warning, QCoreApplication::applicationName(), warningText,\r\n            QMessageBox::Yes | QMessageBox::No, this);\r\n        \r\n        if (!documentIsValid)\r\n        {\r\n            QString errorText = \"* \" + QStringList(errorList.toList()).join(\"\\n* \");\r\n            msgBox.setDetailedText(errorText);\r\n        }\r\n\r\n        if (msgBox.exec() == QMessageBox::Yes)\r\n        {\r\n            doc->save();\r\n        }\r\n    }\r\n\r\n    doc->refresh();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DrawingBoard::closeAndRemoveDocument()\r\n//-----------------------------------------------------------------------------\r\nvoid DrawingBoard::closeAndRemoveDocument(int index)\r\n{\t\r\n    Q_ASSERT(widget(index) != 0);\r\n    TabDocument* document = static_cast<TabDocument*>(widget(index));\r\n\r\n    // If the document has been modified, ask a confirmation from the user.\r\n    if (document->isModified())\r\n    {\r\n        QMessageBox msgBox(QMessageBox::Warning, QCoreApplication::applicationName(),\r\n            \"Do you want to save changes to \" + document->getDocumentName() + \"?\",\r\n            QMessageBox::Yes | QMessageBox::No | QMessageBox::Cancel, this);\r\n\r\n        int saveChanges = msgBox.exec();\r\n        if (saveChanges == QMessageBox::Yes)\r\n        {\r\n            // Try to save and if it fails, cancel the close operation.\r\n            if (!document->save())\r\n            {\r\n                return;\r\n            }\r\n        }\r\n        else if (saveChanges == QMessageBox::No)\r\n        {\r\n            document->setModified(false);\r\n        }\r\n        else if (saveChanges == QMessageBox::Cancel)\r\n        {\r\n            // Cancel the close operation.\r\n            return;\r\n        }\r\n    }\r\n\r\n    // Deleting a document will automatically remove the associated tab from this widget.\r\n    // Using removeTab() triggers showEvent() in the next tab before deleted() \r\n    // triggers MainWindow::onClearItemSelection. This wrong order of triggers would cause the instance \r\n    // details editor in design editor to appear empty for a previously selected component.\r\n    delete document;\r\n    document = 0;\r\n\r\n    if (count() == 0)\r\n    {\r\n        emit lastDocumentClosed();\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DrawingBoard::closeAll()\r\n//-----------------------------------------------------------------------------\r\nvoid DrawingBoard::closeAll()\r\n{\r\n    int tabCount = count();\r\n    for (int i = tabCount - 1; i >= 0; i--)\r\n    {\r\n        closeAndRemoveDocument(i);\r\n\r\n        if (i != count())\r\n        {\r\n            return;\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DrawingBoard::eventFilter()\r\n//-----------------------------------------------------------------------------\r\nbool DrawingBoard::event(QEvent* event)\r\n{\r\n    if (event->type() == QEvent::KeyPress)\r\n    {\r\n        QKeyEvent* keyEvent = static_cast<QKeyEvent*>(event);\r\n\r\n        if (keyEvent->modifiers() == Qt::ControlModifier)\r\n        {\r\n            if (keyEvent->key() == Qt::Key_Tab)\r\n            {\r\n                int nextPage = (currentIndex() + 1) % count();\r\n                setCurrentIndex(nextPage);\r\n                return true;\r\n            }\r\n            else if (keyEvent->key() == Qt::Key_W)\r\n            {\r\n                if (currentIndex() >= 0 && currentIndex() < count())\r\n                {\r\n                    emit tabCloseRequested(currentIndex());\r\n                }\r\n\r\n                return true;\r\n            }\r\n        }\r\n    }\r\n\r\n    return QTabWidget::event(event);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DrawingBoard::eventFilter()\r\n//-----------------------------------------------------------------------------\r\nbool DrawingBoard::eventFilter(QObject* target, QEvent* event)\r\n{\r\n    if (target == tabBar() && event->type() == QEvent::ContextMenu)\r\n    {\r\n        QContextMenuEvent* menuEvent = static_cast<QContextMenuEvent*>(event);\r\n        \r\n        QMenu contextMenu;\r\n        contextMenu.addAction(tr(\"Close All Tabs\"), this, SLOT(closeAll()));\r\n        contextMenu.exec(menuEvent->globalPos());\r\n        return true;\r\n    }\r\n\r\n    return QTabWidget::eventFilter(target, event);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DrawingBoard::onDocumentNameChanged()\r\n//-----------------------------------------------------------------------------\r\nvoid DrawingBoard::onDocumentTitleChanged(TabDocument* document, QString const& newTitle)\r\n{\r\n    int index = indexOf(document);\r\n\r\n    if (index >= 0)\r\n    {\r\n        setTabText(index, newTitle);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DrawingBoard::onDocumentSaved()\r\n//-----------------------------------------------------------------------------\r\nvoid DrawingBoard::onDocumentSaved(TabDocument* doc)\r\n{\r\n    VLNV savedVLNV = doc->getDocumentVLNV();\r\n\r\n    int documentCount =  count();\r\n    for (int i = 0; i < documentCount; i++)\r\n    {\r\n        TabDocument* otherDoc = static_cast<TabDocument*>(widget(i));\r\n\r\n        if (otherDoc != doc && otherDoc->getRelatedVLNVs().contains(savedVLNV))\r\n        {\r\n            otherDoc->requestRefresh();\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DrawingBoard::shouldSave()\r\n//-----------------------------------------------------------------------------\r\nbool DrawingBoard::shouldSave(TabDocument* doc)\r\n{\r\n    bool save = true;\r\n    QVector<QString> errorList;\r\n\r\n    if (!doc->validate(errorList))\r\n    {\r\n        // If the document contained errors, inform the user and give options to save or cancel.\r\n        QMessageBox msgBox(QMessageBox::Warning, QCoreApplication::applicationName(),\r\n            tr(\"Document %1 contained %2 error(s). The document can be saved but \"\r\n            \"may not be opened with other IP-XACT tools. Continue save?\").arg(doc->getDocumentName(), \r\n            QString::number(errorList.size())), QMessageBox::Yes | QMessageBox::No, this);\r\n\r\n        msgBox.setDetailedText(\"The document contained the following error(s):\\n* \" +\r\n            QStringList(errorList.toList()).join(\"\\n* \"));\r\n\r\n        save = (msgBox.exec() == QMessageBox::Yes);\r\n    }\r\n\r\n    return save;\r\n}\r\n"
  },
  {
    "path": "mainwindow/DrawingBoard/DrawingBoard.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: DrawingBoard.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Joni-Matti Maatta\r\n// Date: 28.3.2012\r\n//\r\n// Description:\r\n// The drawing board for holding various IP-XACT documents.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef DRAWINGBOARD_H\r\n#define DRAWINGBOARD_H\r\n\r\n#include <QTabWidget>\r\n\r\nclass TabDocument;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! The drawing board for holding various IP-XACT documents.\r\n//-----------------------------------------------------------------------------\r\nclass DrawingBoard : public QTabWidget\r\n{\r\n    Q_OBJECT\r\n\r\npublic:\r\n    /*!\r\n     *  The constructor.\r\n     *\r\n     *    @param [in] parent  The parent widget.\r\n     */\r\n    DrawingBoard(QWidget* parent = 0);\r\n\r\n    //! The destructor.\r\n    virtual ~DrawingBoard() = default;\r\n       \r\n    /*!\r\n     *  Registers a tab document (connects common signals etc.).\r\n     *\r\n     *    @param [in] doc            The document to register.\r\n     */\r\n    void addAndOpenDocument(TabDocument* doc);\r\n\r\n    //! Apply program settings to all open documents.\r\n    void applySettings();\r\n\r\npublic slots:\r\n    \r\n    //! Saves the currently open document.\r\n    void saveCurrentDocument();\r\n\r\n    //! Saves the currently open document under a different name.\r\n    void saveCurrentDocumentAs();\r\n\r\n    //! Saves all open documents.\r\n    void saveAll();\r\n\r\n    //! Prints the currently open document.\r\n    void printCurrentDocument();\r\n\r\n    /*!\r\n     *  Exports the currently open document as a screenshot.\r\n     */\r\n    void exportCurrentDocumentAsImage();\r\n\r\n    //! Refreshes the currently open document.\r\n    void refreshCurrentDocument();\r\n\r\n    /*!\r\n     *  Closes and removes the document at given index.\r\n     *\r\n     *    @param [in] index   The document index to close.\r\n     */\r\n    void closeAndRemoveDocument(int index);\r\n\r\n    //! Closes all open documents.\r\n    void closeAll();\r\n\r\nprotected:\r\n    \r\n    /*!\r\n     *  Filters and handles keyboard shortcut events.\r\n     */\r\n    virtual bool event(QEvent* event);\r\n\r\n    /*!\r\n     *  Filters the events for given target. Used to create context menu for closing tabs.\r\n     *\r\n     *    @param [in] target      The target object whose event to filter.\r\n     *    @param [in] event       The event captured before passing to target.\r\n     *\r\n     *    @return True, if the event was filtered and should not be passed further, otherwise false.\r\n     */\r\n    virtual bool eventFilter(QObject* target, QEvent* event);\r\n\r\nsignals:\r\n    \r\n    //! Emitted to notify the user of an error.\r\n    void errorMessage(QString const& message);\r\n\r\n    //! Emitted to notify the user.\r\n    void noticeMessage(QString const& message);\r\n\r\n    //! Emitted to request opening a help url.\r\n    void helpUrlRequested(QString const& url);\r\n\r\n    //! Emitted when document content has changed.\r\n    void documentContentChanged();\r\n \r\n    //! Emitted when document modified state has changed.\r\n    void documentModifiedChanged(bool);\r\n\r\n    //! Emitted when document undo/redo state has changed.\r\n    void documentEditStateChanged();\r\n\r\n    //! Emitted when the last document has been closed.\r\n    void lastDocumentClosed();\r\n\r\nprivate slots:\r\n\r\n    //! Called when the title of a document changes.\r\n    void onDocumentTitleChanged(TabDocument* document, QString const& newTitle);\r\n\r\n    //! Called when a document has been saved.\r\n    void onDocumentSaved(TabDocument* doc);\r\n\r\nprivate:\r\n    // Disable copying.\r\n    DrawingBoard(DrawingBoard const& rhs);\r\n    DrawingBoard& operator=(DrawingBoard const& rhs);\r\n   \r\n    /*!\r\n     *  Checks if the current document should be saved. If the document contains errors, prompts the user.\r\n     *\r\n     *    @param [in] doc   The document to save.\r\n     *\r\n     *    @return True, if the document should be saved, otherwise false.\r\n     */\r\n    bool shouldSave(TabDocument* doc);\r\n\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n\r\n#endif // DRAWINGBOARD_H\r\n"
  },
  {
    "path": "mainwindow/ExitScreen.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ExitScreen.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Esko Pekkarinen\r\n// Date: 12.06.2015\r\n//\r\n// Description:\r\n// Exit screen for Kactus2.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"ExitScreen.h\"\r\n\r\n#include <QPalette>\r\n#include <QLabel>\r\n#include <QBitmap>\r\n#include <QTimer>\r\n#include <QVBoxLayout>\r\n#include <QCheckBox>\r\n#include <QSettings>\r\n\r\n#define CLOSE_TIME 11\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ExitScreen::ExitScreen()\r\n//-----------------------------------------------------------------------------\r\nExitScreen::ExitScreen(QWidget* parent) : QDialog(parent), \r\n    closeCounter_(CLOSE_TIME), \r\n    countdownLabel_(new QLabel(this))\r\n{\r\n    setFixedSize(600, 400);\r\n    setWindowFlags(windowFlags() | Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint | Qt::X11BypassWindowManagerHint);\r\n\r\n    QPalette defaultPalette = palette();\r\n    defaultPalette.setBrush(QPalette::Background, QBrush(QImage(\":/common/graphics/splash.png\")));\r\n    setPalette(defaultPalette);\r\n\r\n    QLabel* feedbackText = new QLabel(tr(\"Thank you for using Kactus2.<br >\"\r\n    \"Please give us 3 minutes and help us make Kactus2 even better. \"\r\n    \"Visit our feedback page at:<br>\"), this);\r\n    \r\n    feedbackText->setAlignment(Qt::AlignCenter);\r\n\r\n    QFont feedbackTextFont = feedbackText->font();\r\n    feedbackTextFont.setPixelSize(12);\r\n    feedbackTextFont.setBold(true);\r\n    feedbackText->setFont(feedbackTextFont);\r\n\r\n    QLabel* feedbackUrl = new QLabel(tr(\r\n    \"<a href=\\\"http://funbase.cs.tut.fi/feedback\\\">http://funbase.cs.tut.fi/feedback</a>\"), this);\r\n\r\n    feedbackUrl->setAlignment(Qt::AlignCenter);\r\n    feedbackUrl->setOpenExternalLinks(true);\r\n\r\n    QFont urlFont = feedbackUrl->font();\r\n    urlFont.setPixelSize(14);\r\n    urlFont.setBold(true);\r\n    feedbackUrl->setFont(urlFont);\r\n\r\n    QCheckBox* hideCheckBox = new QCheckBox(tr(\"Do not show this window again\"), this);\r\n    connect(hideCheckBox, SIGNAL(toggled(bool)), this, SLOT(onShowHideToggled(bool)));\r\n\r\n    QVBoxLayout* layout = new QVBoxLayout(this);\r\n    layout->addSpacing(220);\r\n    layout->addWidget(feedbackText);\r\n    layout->addWidget(feedbackUrl);\r\n    layout->addStretch();\r\n    layout->addWidget(countdownLabel_, 1, Qt::AlignBottom | Qt::AlignCenter);\r\n    layout->addWidget(hideCheckBox);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ExitScreen::~ExitScreen()\r\n//-----------------------------------------------------------------------------\r\nExitScreen::~ExitScreen()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ExitScreen::showEvent()\r\n//-----------------------------------------------------------------------------\r\nvoid ExitScreen::showEvent(QShowEvent* event)\r\n{\r\n    QDialog::showEvent(event);\r\n\r\n    QTimer* timer = new QTimer(this);\r\n    timer->setInterval(1000);\r\n\r\n    connect(timer, SIGNAL(timeout()), this, SLOT(onTimerExpired()));\r\n    timer->start();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ExitScreen::onTimerExpired()\r\n//-----------------------------------------------------------------------------\r\nvoid ExitScreen::onTimerExpired()\r\n{\r\n    closeCounter_--;\r\n\r\n    if (closeCounter_ <= 0)\r\n    {\r\n        accept();\r\n    }\r\n\r\n    countdownLabel_->setText(tr(\"This window will close in %1 seconds\").arg(closeCounter_));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ExitScreen::onShowHideToggled()\r\n//-----------------------------------------------------------------------------\r\nvoid ExitScreen::onShowHideToggled(bool hide)\r\n{\r\n    QSettings settings;\r\n    settings.setValue(\"General/showExitScreen\", !hide);\r\n}\r\n"
  },
  {
    "path": "mainwindow/ExitScreen.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ExitScreen.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Esko Pekkarinen\r\n// Date: 12.06.2015\r\n//\r\n// Description:\r\n// Exit screen for Kactus2.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef EXITSCREEN_H\r\n#define EXITSCREEN_H\r\n\r\n#include <QDialog>\r\n#include <QLabel>\r\n\r\n//-----------------------------------------------------------------------------\r\n//! ExitScreen class.\r\n//-----------------------------------------------------------------------------\r\nclass ExitScreen : public QDialog\r\n{\r\n    Q_OBJECT\r\npublic:\r\n\r\n    /*!\r\n     *  Constructor.\r\n     */\r\n    ExitScreen(QWidget* parent = 0);\r\n\r\n    /*!\r\n     *  Destructor.\r\n     */\r\n    ~ExitScreen();\r\n\r\nprotected:\r\n\r\n    virtual void showEvent(QShowEvent* event);\r\n\r\nprivate slots:\r\n\r\n    void onTimerExpired();\r\n\r\n    void onShowHideToggled(bool hide);\r\n\r\nprivate:\r\n    // Disable copying.\r\n    ExitScreen(ExitScreen const& rhs);\r\n    ExitScreen& operator=(ExitScreen const& rhs);\r\n\r\n    //! Countdown to automatic close.\r\n    int closeCounter_;\r\n\r\n    //! Label for displaying countdown timer.\r\n    QLabel* countdownLabel_;\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n\r\n#endif // EXITSCREEN_H\r\n"
  },
  {
    "path": "mainwindow/MessageConsole/messageconsole.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: messageconsole.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 22.02.2011\r\n//\r\n// Description:\r\n// This widget is used to print event information to the user.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"messageconsole.h\"\r\n\r\n#include <common/KactusColors.h>\r\n\r\n#include <QMenu>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MessageConsole::MessageConsole()\r\n//-----------------------------------------------------------------------------\r\nMessageConsole::MessageConsole(QWidget *parent):\r\nQPlainTextEdit(parent),\r\n    copyAction_(tr(\"Copy\"), this),\r\n    selectAllAction_(tr(\"Select all\"), this),\r\n    clearAction_(tr(\"Clear\"), this)\r\n{\r\n\tsetReadOnly(true);\r\n    setUndoRedoEnabled(false);\r\n\r\n\tcopyAction_.setDisabled(true);\r\n\r\n\tconnect(&copyAction_, SIGNAL(triggered()), this, SLOT(copy()), Qt::UniqueConnection);\r\n\tconnect(&selectAllAction_, SIGNAL(triggered()), this, SLOT(selectAll()), Qt::UniqueConnection);\r\n\tconnect(&clearAction_, SIGNAL(triggered()),\tthis, SLOT(clear()), Qt::UniqueConnection);\r\n\tconnect(this, SIGNAL(copyAvailable(bool)), &copyAction_, SLOT(setEnabled(bool)), Qt::UniqueConnection);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MessageConsole::onErrorMessage()\r\n//-----------------------------------------------------------------------------\r\nvoid MessageConsole::onErrorMessage(QString const& message)\r\n{\r\n\tif (message.isEmpty())\r\n    {\r\n\t\treturn;\r\n\t}\r\n\r\n\tmoveCursor(QTextCursor::End);\r\n\r\n\t// errors are printed in red color\r\n\tsetTextColor(KactusColors::ERROR);\r\n    appendPlainText(message);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MessageConsole::onNoticeMessage()\r\n//-----------------------------------------------------------------------------\r\nvoid MessageConsole::onNoticeMessage(QString const& message)\r\n{\r\n\tif (message.isEmpty())\r\n    {\r\n\t\treturn;\r\n\t}\r\n\r\n\tmoveCursor(QTextCursor::End);\r\n\r\n\t// notices are printed in blue\r\n\tsetTextColor(KactusColors::REGULAR_MESSAGE);\r\n\tappendPlainText(message);\r\n\r\n    viewport()->update();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MessageConsole::contextMenuEvent()\r\n//-----------------------------------------------------------------------------\r\nvoid MessageConsole::contextMenuEvent(QContextMenuEvent* event)\r\n{\r\n\tQMenu menu;\r\n\tmenu.addAction(&copyAction_);\r\n\tmenu.addAction(&selectAllAction_);\r\n\tmenu.addAction(&clearAction_);\r\n\r\n\tmenu.exec(event->globalPos());\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MessageConsole::setTextColor()\r\n//-----------------------------------------------------------------------------\r\nvoid MessageConsole::setTextColor(QColor const& color)\r\n{\r\n    QTextCharFormat format = currentCharFormat();\r\n    format.setForeground(QBrush(color));\r\n    setCurrentCharFormat(format);\r\n}\r\n"
  },
  {
    "path": "mainwindow/MessageConsole/messageconsole.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: messageconsole.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 22.02.2011\r\n//\r\n// Description:\r\n// This widget is used to print event information to the user.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef MESSAGECONSOLE_H\r\n#define MESSAGECONSOLE_H\r\n\r\n#include <QPlainTextEdit>\r\n#include <QAction>\r\n#include <QContextMenuEvent>\r\n\r\n//-----------------------------------------------------------------------------\r\n//! This widget is used to print event information to the user.\r\n//-----------------------------------------------------------------------------\r\nclass MessageConsole : public QPlainTextEdit\r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\r\n\t/*! The constructor\r\n\t *\r\n\t *    @param [in] parent     The owner of this widget\r\n\t *\r\n\t*/\r\n\texplicit MessageConsole(QWidget *parent);\r\n\r\n\t//! The destructor\r\n\tvirtual ~MessageConsole() = default;\r\n\r\n    //! No copying\r\n    MessageConsole(const MessageConsole& other) = delete;\r\n\r\n    //! No assignment\r\n    MessageConsole& operator=(const MessageConsole& other) = delete;\r\n\r\npublic slots:\r\n\r\n\t/*! Prints an error message to the text edit.\r\n\t *\r\n\t *    @param [in] message     The message to print.\r\n\t*/\r\n\tvoid onErrorMessage(QString const& message);\r\n\r\n\t/*! Prints a notice message to the text edit.\r\n\t *\r\n\t *    @param [in] message  The message to print.\r\n\t*/\r\n\tvoid onNoticeMessage(QString const& message);\r\n\r\nprotected:\r\n\r\n\t//! Event handler for context menu requests.\r\n\tvirtual void contextMenuEvent(QContextMenuEvent* event);\r\n\r\nprivate:\r\n\r\n    /*! Set the color for text to be printed.\r\n     *\r\n     *    @param [in] color  The color to apply to text.\r\n    */\r\n    void setTextColor(QColor const& color);\r\n\t\r\n    //! Copy the selected text to the clip board.\r\n\tQAction copyAction_;\r\n\r\n\t//! Select all text in the text edit.\r\n\tQAction selectAllAction_;\r\n\r\n\t//! Clear all text from the text edit.\r\n\tQAction clearAction_;\r\n};\r\n\r\n#endif // MESSAGECONSOLE_H\r\n"
  },
  {
    "path": "mainwindow/NewPages/NewApiDefinitionPage.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: NewApiDefinitionPage.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Joni-Matti Maatta\r\n// Date: 17.4.2012\r\n//\r\n// Description:\r\n// New API definition page.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"NewApiDefinitionPage.h\"\r\n\r\n#include <KactusAPI/include/LibraryInterface.h>\r\n\r\n#include <common/widgets/vlnvEditor/vlnveditor.h>\r\n\r\n#include <QVBoxLayout>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: NewApiDefinitionPage()\r\n//-----------------------------------------------------------------------------\r\nNewApiDefinitionPage::NewApiDefinitionPage(LibraryInterface* libInterface, QWidget* parentDlg):\r\nNewPage(libInterface, VLNV::APIDEFINITION, tr(\"New API definition\"), tr(\"Creates an API definition\"), parentDlg)\r\n{\r\n    QVBoxLayout* topLayout = dynamic_cast<QVBoxLayout*>(layout());\r\n    topLayout->addStretch(1);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: validate()\r\n//-----------------------------------------------------------------------------\r\nbool NewApiDefinitionPage::validate()\r\n{\r\n    // Check if the VLNV already exists.    \r\n    bool valid = NewPage::validate();    \r\n\r\n    if (!valid)\r\n    {\r\n        showErrorForReservedVLVN(vlnvEditor_->getVLNV());\r\n    }\r\n\r\n    return valid;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: apply()\r\n//-----------------------------------------------------------------------------\r\nvoid NewApiDefinitionPage::apply()\r\n{\r\n    emit createApiDefinition(vlnvEditor_->getVLNV(), selectedRevision(), selectedPath());\r\n}\r\n"
  },
  {
    "path": "mainwindow/NewPages/NewApiDefinitionPage.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: NewApiDefinitionPage.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Joni-Matti Maatta\r\n// Date: 17.4.2012\r\n//\r\n// Description:\r\n// New API definition page.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef NEWAPIDEFINITIONPAGE_H\r\n#define NEWAPIDEFINITIONPAGE_H\r\n\r\n#include \"NewPage.h\"\r\n\r\nclass LibraryInterface;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! NewApiDefinitionPage class.\r\n//-----------------------------------------------------------------------------\r\nclass NewApiDefinitionPage : public NewPage\r\n{\r\n    Q_OBJECT\r\n\r\npublic:\r\n    /*!\r\n     *  Constructor.\r\n     *\r\n     *    @param [in] libInterface The library interface.\r\n     *    @param [in] parentDlg    The parent dialog.\r\n     */\r\n    NewApiDefinitionPage(LibraryInterface* libInterface, QWidget* parentDlg);\r\n\r\n    /*!\r\n     *  Destructor.\r\n     */\r\n    virtual ~NewApiDefinitionPage() = default;\r\n\r\n    // Disable copying.\r\n    NewApiDefinitionPage(NewApiDefinitionPage const& rhs) = delete;\r\n    NewApiDefinitionPage& operator=(NewApiDefinitionPage const& rhs) = delete;\r\n\r\n    /*!\r\n     *  Validates the contents of the page thoroughly.\r\n     *\r\n     *    @return True, if the contents are valid. False, if they are invalid.\r\n     *\r\n     *      @remarks Showing message boxes for errors is allowed.\r\n     */\r\n    bool validate() final;\r\n\r\n    /*!\r\n     *  Applies the changes that were done in the page.\r\n     */\r\n    void apply() final;\r\n\r\n\r\nsignals:\r\n    //! Signaled when a API definition should be created.\r\n    void createApiDefinition(VLNV const& vlnv, Document::Revision revision, QString const& directory);\r\n\r\n       \r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n\r\n#endif // NEWAPIDEFINITIONPAGE_H\r\n"
  },
  {
    "path": "mainwindow/NewPages/NewBusDefinitionPage.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: newbuspage.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Antti Kamppi\r\n// Date: 20.06.2011\r\n//\r\n// Description:\r\n// New bus page.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"NewBusDefinitionPage.h\"\r\n\r\n#include <common/widgets/vlnvEditor/vlnveditor.h>\r\n\r\n#include <KactusAPI/include/LibraryInterface.h>\r\n\r\n#include <QHBoxLayout>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: NewBusPage()\r\n//-----------------------------------------------------------------------------\r\nNewBusDefinitionPage::NewBusDefinitionPage(LibraryInterface* libHandler, QWidget *parentDlg):\r\nNewPage(libHandler, VLNV::BUSDEFINITION, tr(\"New Bus Definition\"), tr(\"Creates a new bus definition\"), parentDlg)\r\n{\r\n\tQ_ASSERT_X(libHandler, \"NewBusPage constructor\", \"Null LibraryInterface pointer given as parameter\");\t\r\n    \r\n    QVBoxLayout* topLayout = dynamic_cast<QVBoxLayout*>(layout());\r\n    topLayout->addStretch(1);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: validate()\r\n//-----------------------------------------------------------------------------\r\nbool NewBusDefinitionPage::validate()\r\n{\r\n    // Check if any of the VLNVs already exists.\r\n    bool validVLNV = NewPage::validate();\r\n\r\n    if (!validVLNV)\r\n    {        \r\n        showErrorForReservedVLVN(vlnvEditor_->getVLNV());\r\n    }\r\n\r\n\treturn validVLNV;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: apply()\r\n//-----------------------------------------------------------------------------\r\nvoid NewBusDefinitionPage::apply()\r\n{\r\n\t emit createBus(vlnvEditor_->getVLNV(), selectedRevision(), selectedPath());\r\n}\r\n"
  },
  {
    "path": "mainwindow/NewPages/NewBusDefinitionPage.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: newbuspage.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Antti Kamppi\r\n// Date: 20.06.2011\r\n//\r\n// Description:\r\n// New bus page.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef NEWBUSPAGE_H\r\n#define NEWBUSPAGE_H\r\n\r\n#include \"NewPage.h\"\r\n\r\nclass LibraryInterface;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! New bus page.\r\n//-----------------------------------------------------------------------------\r\nclass NewBusDefinitionPage : public NewPage \r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\r\n\tNewBusDefinitionPage(LibraryInterface* libHandler, QWidget *parent);\r\n\t\r\n\t//! The destructor.\r\n\tvirtual ~NewBusDefinitionPage() = default;\r\n\r\n    //! No copying.\r\n    NewBusDefinitionPage(const NewBusDefinitionPage& other) = delete;\r\n\r\n    //! No assignment.\r\n    NewBusDefinitionPage& operator=(const NewBusDefinitionPage& other) = delete;\r\n\r\n    /*!\r\n     *  Validates the contents of the page thoroughly.\r\n     *\r\n     *    @return True, if the contents are valid. False, if they are invalid.\r\n     *\r\n     *      @remarks Showing message boxes for errors is allowed.\r\n     */\r\n    bool validate() final;\r\n\r\n    /*!\r\n     *  Applies the changes that were done in the page.\r\n     */\r\n    void apply() final;\r\n\r\nsignals:\r\n\r\n\t//! Signaled when new bus should be created.\r\n\tvoid createBus(VLNV const& vlnv, Document::Revision revision, QString const& directory);  \r\n\r\n};\r\n\r\n#endif // NEWBUSPAGE_H\r\n"
  },
  {
    "path": "mainwindow/NewPages/NewCatalogPage.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: NewCatalogPage.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Esko Pekkarinen\n// Date: 01.02.2017\n//\n// Description:\n// New Catalog page.\n//-----------------------------------------------------------------------------\n\n#include \"NewCatalogPage.h\"\n\n#include <KactusAPI/include/LibraryInterface.h>\n\n#include <common/widgets/vlnvEditor/vlnveditor.h>\n\n#include <QVBoxLayout>\n\n//-----------------------------------------------------------------------------\n// Function: NewCatalogPage()\n//-----------------------------------------------------------------------------\nNewCatalogPage::NewCatalogPage(LibraryInterface* libInterface, QWidget* parentDlg):\nNewPage(libInterface, VLNV::CATALOG, tr(\"New Catalog\"), tr(\"Creates a catalog for organizing IP\"), parentDlg)\n{\n    QVBoxLayout* topLayout = dynamic_cast<QVBoxLayout*>(layout());\n    topLayout->addStretch(1);\n}\n\n//-----------------------------------------------------------------------------\n// Function: validate()\n//-----------------------------------------------------------------------------\nbool NewCatalogPage::validate()\n{\n    // Check if the VLNV already exists.    \n    bool valid = NewPage::validate();    \n\n    if (!valid)\n    {\n        showErrorForReservedVLVN(vlnvEditor_->getVLNV());\n    }\n\n    return valid;\n}\n\n//-----------------------------------------------------------------------------\n// Function: apply()\n//-----------------------------------------------------------------------------\nvoid NewCatalogPage::apply()\n{\n    emit createCatalog(vlnvEditor_->getVLNV(), selectedRevision(), selectedPath());\n}\n"
  },
  {
    "path": "mainwindow/NewPages/NewCatalogPage.h",
    "content": "//-----------------------------------------------------------------------------\n// File: NewCatalogPage.h\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Esko Pekkarinen\n// Date: 01.02.2017\n//\n// Description:\n// New Catalog page.\n//-----------------------------------------------------------------------------\n\n#ifndef NEWCATALOGPAGE_H\n#define NEWCATALOGPAGE_H\n\n#include \"NewPage.h\"\n\nclass LibraryInterface;\n\n//-----------------------------------------------------------------------------\n//! NewCatalogPage class.\n//-----------------------------------------------------------------------------\nclass NewCatalogPage : public NewPage\n{\n    Q_OBJECT\n\npublic:\n    /*!\n     *  Constructor.\n     *\n     *    @param [in] libInterface The library interface.\n     *    @param [in] parentDlg    The parent dialog.\n     */\n    NewCatalogPage(LibraryInterface* libInterface, QWidget* parentDlg);\n\n    /*!\n     *  Destructor.\n     */\n    virtual ~NewCatalogPage() = default;\n\n    // Disable copying.\n    NewCatalogPage(NewCatalogPage const& rhs) = delete;\n    NewCatalogPage& operator=(NewCatalogPage const& rhs) = delete;\n\n    /*!\n     *  Validates the contents of the page thoroughly.\n     *\n     *    @return True, if the contents are valid. False, if they are invalid.\n     *\n     *      @remarks Showing message boxes for errors is allowed.\n     */\n    bool validate() final;\n\n    /*!\n     *  Applies the changes that were done in the page.\n     */\n    void apply() final;\n\n\nsignals:\n    //! Signaled when a API definition should be created.\n    void createCatalog(VLNV const& vlnv, Document::Revision revision, QString const& directory);\n\n};\n\n//-----------------------------------------------------------------------------\n\n#endif // NEWCATALOGPAGE_H\n"
  },
  {
    "path": "mainwindow/NewPages/NewComDefinitionPage.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: NewComDefinitionPage.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Joni-Matti Maatta\r\n// Date: 17.4.2012\r\n//\r\n// Description:\r\n// New COM definition page.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"NewComDefinitionPage.h\"\r\n\r\n#include <KactusAPI/include/LibraryInterface.h>\r\n\r\n#include <common/widgets/vlnvEditor/vlnveditor.h>\r\n\r\n#include <QVBoxLayout>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: NewComDefinitionPage()\r\n//-----------------------------------------------------------------------------\r\nNewComDefinitionPage::NewComDefinitionPage(LibraryInterface* libInterface, QWidget* parentDlg):\r\nNewPage(libInterface, VLNV::COMDEFINITION, tr(\"New COM definition\"), tr(\"Creates a communication definition\"),\r\n    parentDlg)\r\n{\r\n    QVBoxLayout* topLayout = dynamic_cast<QVBoxLayout*>(layout());\r\n    topLayout->addStretch(1);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: validate()\r\n//-----------------------------------------------------------------------------\r\nbool NewComDefinitionPage::validate()\r\n{\r\n    // Check if the VLNV already exists.    \r\n    bool validVLNV = NewPage::validate();\r\n\r\n    if (!validVLNV)\r\n    {        \r\n        showErrorForReservedVLVN(vlnvEditor_->getVLNV());     \r\n    }\r\n\r\n    return validVLNV;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: apply()\r\n//-----------------------------------------------------------------------------\r\nvoid NewComDefinitionPage::apply()\r\n{\r\n    emit createComDefinition(vlnvEditor_->getVLNV(),selectedRevision(), selectedPath());\r\n}\r\n"
  },
  {
    "path": "mainwindow/NewPages/NewComDefinitionPage.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: NewComDefinitionPage.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Joni-Matti Maatta\r\n// Date: 17.4.2012\r\n//\r\n// Description:\r\n// New COM definition page.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef NEWCOMDEFINITIONPAGE_H\r\n#define NEWCOMDEFINITIONPAGE_H\r\n\r\n#include \"NewPage.h\"\r\n\r\n#include <common/widgets/vlnvEditor/vlnveditor.h>\r\n\r\nclass LibraryInterface;\r\n//-----------------------------------------------------------------------------\r\n//! NewComDefinitionPage class.\r\n//-----------------------------------------------------------------------------\r\nclass NewComDefinitionPage : public NewPage\r\n{\r\n    Q_OBJECT\r\n\r\npublic:\r\n    /*!\r\n     *  Constructor.\r\n     *\r\n     *    @param [in] libInterface The library interface.\r\n     *    @param [in] parentDlg    The parent dialog.\r\n     */\r\n    NewComDefinitionPage(LibraryInterface* libInterface, QWidget* parentDlg);\r\n\r\n    /*!\r\n     *  Destructor.\r\n     */\r\n    virtual ~NewComDefinitionPage() = default;\r\n\r\n    // Disable copying.\r\n    NewComDefinitionPage(NewComDefinitionPage const& rhs) = delete;\r\n    NewComDefinitionPage& operator=(NewComDefinitionPage const& rhs) = delete;\r\n\r\n    /*!\r\n     *  Validates the contents of the page thoroughly.\r\n     *\r\n     *    @return True, if the contents are valid. False, if they are invalid.\r\n     *\r\n     *      @remarks Showing message boxes for errors is allowed.\r\n     */\r\n    bool validate() final;\r\n\r\n    /*!\r\n     *  Applies the changes that were done in the page.\r\n     */\r\n    void apply() final;\r\n\r\nsignals:\r\n    //! Signaled when a COM definition should be created.\r\n    void createComDefinition(VLNV const& vlnv, Document::Revision revision, QString const& directory);\r\n\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n\r\n#endif // NEWCOMDEFINITIONPAGE_H\r\n"
  },
  {
    "path": "mainwindow/NewPages/NewComponentPage.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: NewComponentPage.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Joni-Matti Maatta\r\n// Date: 9.6.2011\r\n//\r\n// Description:\r\n// New component property page.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"NewComponentPage.h\"\r\n\r\n#include <common/widgets/vlnvEditor/vlnveditor.h>\r\n#include <common/widgets/kactusAttributeEditor/KactusAttributeEditor.h>\r\n\r\n#include <IPXACTmodels/common/VLNV.h>\r\n#include <KactusAPI/include/LibraryInterface.h>\r\n\r\n#include <QVBoxLayout>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: NewComponentPage()\r\n//-----------------------------------------------------------------------------\r\nNewComponentPage::NewComponentPage(LibraryInterface* libInterface, QWidget* parentDlg):\r\nNewPage(libInterface, VLNV::COMPONENT, tr(\"New HW Component\"),\r\n    tr(\"Creates a flat (non-hierarchical) HW component\"), parentDlg),\r\nattributeEditor_(new KactusAttributeEditor(this))\r\n{\r\n    connect(attributeEditor_, SIGNAL(productHierarchyChanged()), this, SLOT(onProductHierarchyChanged()));\r\n\r\n    vlnvEditor_->setImplementationFilter(true, KactusAttribute::HW);\r\n\r\n    // Setup the layout.\r\n    QVBoxLayout* widgetLayout = dynamic_cast<QVBoxLayout*>(layout());\r\n    Q_ASSERT(widgetLayout);\r\n    widgetLayout->addSpacing(12);\r\n    widgetLayout->insertWidget(3, attributeEditor_);\r\n    widgetLayout->addStretch(1);\r\n\r\n    onProductHierarchyChanged();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: validate()\r\n//-----------------------------------------------------------------------------\r\nbool NewComponentPage::validate()\r\n{\r\n    bool valid = NewPage::validate();\r\n\r\n    // Check if the VLNV already exists.\r\n    if (!valid)\r\n    {        \r\n        showErrorForReservedVLVN(vlnvEditor_->getVLNV());     \r\n    }\r\n\r\n    return valid;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: apply()\r\n//-----------------------------------------------------------------------------\r\nvoid NewComponentPage::apply()\r\n{\r\n    emit createComponent(attributeEditor_->getProductHierarchy(), attributeEditor_->getFirmness(),\r\n        attributeEditor_->getTags(), vlnvEditor_->getVLNV(), selectedRevision() ,selectedPath());\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: onPageChange()\r\n//-----------------------------------------------------------------------------\r\nbool NewComponentPage::onPageChange()\r\n{\r\n    // Discard the VLNV and reset the attributes.\r\n    attributeEditor_->setAttributes(KactusAttribute::FLAT, KactusAttribute::TEMPLATE, QVector<TagData>());\r\n    onProductHierarchyChanged();\r\n    return NewPage::onPageChange();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: NewComponentPage::getProductHierarchy()\r\n//-----------------------------------------------------------------------------\r\nKactusAttribute::ProductHierarchy NewComponentPage::getProductHierarchy() const\r\n{\r\n    return attributeEditor_->getProductHierarchy();\r\n}\r\n"
  },
  {
    "path": "mainwindow/NewPages/NewComponentPage.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: NewComponentPage.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Joni-Matti Maatta\r\n// Date: 9.6.2011\r\n//\r\n// Description:\r\n// New component property page.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef NEWCOMPONENTPAGE_H\r\n#define NEWCOMPONENTPAGE_H\r\n\r\n#include \"NewPage.h\"\r\n\r\n#include <IPXACTmodels/common/TagData.h>\r\n\r\n#include <IPXACTmodels/kactusExtensions/KactusAttribute.h>\r\n\r\nclass LibraryInterface;\r\nclass KactusAttributeEditor;\r\nclass VLNV;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! NewComponentPage class.\r\n//-----------------------------------------------------------------------------\r\nclass NewComponentPage : public NewPage\r\n{\r\n    Q_OBJECT\r\n\r\npublic:\r\n\r\n    /*!\r\n     *  The constructor.\r\n     *\r\n     *    @param [in] libInterface    The library interface.\r\n     *    @param [in] parentDlg       The parent dialog.\r\n     */\r\n    NewComponentPage(LibraryInterface* libInterface, QWidget* parentDlg);\r\n\r\n    /*!\r\n     *  The destructor.\r\n     */\r\n    virtual ~NewComponentPage() = default;\r\n\r\n    // Disable copying.\r\n    NewComponentPage(NewComponentPage const& rhs) = delete;\r\n    NewComponentPage& operator=(NewComponentPage const& rhs) = delete;\r\n\r\n\r\n    /*!\r\n     *  Validates the contents of the page thoroughly.\r\n     *\r\n     *    @return True, if the contents are valid. False, if they are invalid.\r\n     *\r\n     *      @remarks Showing message boxes for errors is allowed.\r\n     */\r\n    bool validate() final;\r\n\r\n    /*!\r\n     *  Applies the changes that were done in the page.\r\n     */\r\n    void apply() final;\r\n\r\n    /*!\r\n     *  Called when the page is to be changed and this page would be hidden.\r\n     *\r\n     *    @return False, if the page change should be rejected. Otherwise true.\r\n     */\r\n    bool onPageChange() final;\r\n\r\nsignals:\r\n\r\n    /*!\r\n     *  Signaled when a component should be created.\r\n     */\r\n    void createComponent(KactusAttribute::ProductHierarchy prodHier, KactusAttribute::Firmness firmness,\r\n        QVector<TagData> tags, VLNV const& vlnv, Document::Revision revision, QString const& directory);\r\n\r\nprotected:\r\n\r\n    KactusAttribute::ProductHierarchy getProductHierarchy() const final;\r\n\r\nprivate:\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! Attribute editor.\r\n    KactusAttributeEditor* attributeEditor_;\r\n\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n\r\n#endif // NEWCOMPONENTPAGE_H\r\n"
  },
  {
    "path": "mainwindow/NewPages/NewDesignPage.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: NewDesignPage.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Joni-Matti Maatta\r\n// Date: 9.6.2011\r\n//\r\n// Description:\r\n// New design property page.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"NewDesignPage.h\"\r\n\r\n#include <KactusAPI/include/LibraryInterface.h>\r\n\r\n#include <common/widgets/vlnvEditor/vlnveditor.h>\r\n#include <common/widgets/kactusAttributeEditor/KactusAttributeEditor.h>\r\n\r\n#include <QVBoxLayout>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: NewDesignPage()\r\n//-----------------------------------------------------------------------------\r\nNewDesignPage::NewDesignPage(LibraryInterface* libInterface, QWidget* parentDlg):\r\nNewPage(libInterface, VLNV::COMPONENT, tr(\"New HW Design\"), tr(\"Creates a hierarchical HW design\"), parentDlg),\r\n    attributeEditor_(new KactusAttributeEditor(this))\r\n{\r\n    connect(attributeEditor_, SIGNAL(productHierarchyChanged()), this, SLOT(onProductHierarchyChanged()));\r\n\r\n    // Create the VLNV editor.\r\n    vlnvEditor_->setImplementationFilter(true, KactusAttribute::HW);\r\n\r\n    // Setup the layout.\r\n    QVBoxLayout* widgetLayout = dynamic_cast<QVBoxLayout*>(layout());\r\n    Q_ASSERT(widgetLayout);\r\n    widgetLayout->insertWidget(3, attributeEditor_);   \r\n    widgetLayout->addStretch(1);\r\n\r\n    onProductHierarchyChanged();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: validate()\r\n//-----------------------------------------------------------------------------\r\nbool NewDesignPage::validate()\r\n{\r\n    VLNV vlnv = vlnvEditor_->getVLNV();\r\n    bool validVLNV = NewPage::validate();\r\n\r\n    VLNV designVLNV(VLNV::DESIGN, vlnv.getVendor(), vlnv.getLibrary(),\r\n        vlnv.getName().remove(\".comp\") + \".design\", vlnv.getVersion());\r\n    VLNV desConfVLNV(VLNV::DESIGNCONFIGURATION, vlnv.getVendor(), vlnv.getLibrary(),\r\n        vlnv.getName().remove(\".comp\") + \".designcfg\", vlnv.getVersion());\r\n\r\n    // Check if any of the VLNVs already exists.\r\n    if (!validVLNV)\r\n    {\r\n        showErrorForReservedVLVN(vlnv);\r\n        return false;\r\n    }\r\n\r\n    if (!isUnusedVLNV(designVLNV))\r\n    {\r\n        showErrorForReservedVLVN(designVLNV);\r\n        return false;\r\n    }\r\n\r\n    if (!isUnusedVLNV(desConfVLNV))\r\n    {\r\n        showErrorForReservedVLVN(desConfVLNV);\r\n        return false;\r\n    }    \r\n\r\n    return true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: apply()\r\n//-----------------------------------------------------------------------------\r\nvoid NewDesignPage::apply()\r\n{\r\n    emit createDesign(attributeEditor_->getProductHierarchy(), attributeEditor_->getFirmness(),\r\n        attributeEditor_->getTags(), vlnvEditor_->getVLNV(), selectedRevision(), selectedPath());\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: onPageChange()\r\n//-----------------------------------------------------------------------------\r\nbool NewDesignPage::onPageChange()\r\n{\r\n    // Discard the VLNV and reset the attributes.\r\n    attributeEditor_->setAttributes(KactusAttribute::FLAT, KactusAttribute::TEMPLATE, QVector<TagData>());\r\n    onProductHierarchyChanged();\r\n    return NewPage::onPageChange();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: NewDesignPage::getProductHierarchy()\r\n//-----------------------------------------------------------------------------\r\nKactusAttribute::ProductHierarchy NewDesignPage::getProductHierarchy() const\r\n{\r\n    return attributeEditor_->getProductHierarchy();\r\n}\r\n"
  },
  {
    "path": "mainwindow/NewPages/NewDesignPage.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: NewDesignPage.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Joni-Matti Maatta\r\n// Date: 9.6.2011\r\n//\r\n// Description:\r\n// New design property page.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef NEWDESIGNPAGE_H\r\n#define NEWDESIGNPAGE_H\r\n\r\n#include \"NewPage.h\"\r\n\r\n#include <IPXACTmodels/common/TagData.h>\r\n\r\n#include <IPXACTmodels/kactusExtensions/KactusAttribute.h>\r\n\r\nclass KactusAttributeEditor;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! NewDesignPage class.\r\n//-----------------------------------------------------------------------------\r\nclass NewDesignPage : public NewPage\r\n{\r\n    Q_OBJECT\r\n\r\npublic:\r\n    /*!\r\n     *  Constructor.\r\n     *\r\n     *    @param [in] libInterface The library interface.\r\n     *    @param [in] parentDlg    The parent dialog.\r\n     */\r\n    NewDesignPage(LibraryInterface* libInterface, QWidget* parentDlg);\r\n\r\n    /*!\r\n     *  Destructor.\r\n     */\r\n    virtual ~NewDesignPage() = default;\r\n\r\n    // Disable copying.\r\n    NewDesignPage(NewDesignPage const& rhs) = delete;\r\n    NewDesignPage& operator=(NewDesignPage const& rhs) = delete;\r\n\r\n    /*!\r\n     *  Validates the contents of the page thoroughly.\r\n     *\r\n     *    @return True, if the contents are valid. False, if they are invalid.\r\n     *\r\n     *      @remarks Showing message boxes for errors is allowed.\r\n     */\r\n    bool validate() final;\r\n\r\n    /*!\r\n     *  Applies the changes that were done in the page.\r\n     */\r\n    void apply() final;\r\n\r\n    /*!\r\n     *  Called when the page is to be changed and this page would be hidden.\r\n     *\r\n     *    @return False, if the page change should be rejected. Otherwise true.\r\n     */\r\n    bool onPageChange() final;\r\n    \r\n\r\nsignals:\r\n    //! Signaled when a design should be created.\r\n    void createDesign(KactusAttribute::ProductHierarchy prodHier, KactusAttribute::Firmness firmness,\r\n        QVector<TagData> tags, VLNV const& vlnv, Document::Revision revision, QString const& directory);\r\n\r\nprotected:\r\n\r\n    KactusAttribute::ProductHierarchy getProductHierarchy() const final;\r\n\r\nprivate:\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! Attribute editor.\r\n    KactusAttributeEditor* attributeEditor_;\r\n\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n\r\n#endif // NEWDESIGNPAGE_H\r\n"
  },
  {
    "path": "mainwindow/NewPages/NewPage.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: NewPage.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Esko Pekkarinen\r\n// Date: 28.8.2013\r\n//\r\n// Description:\r\n// Base class for all New pages.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"NewPage.h\"\r\n\r\n#include <common/widgets/vlnvEditor/vlnveditor.h>\r\n#include <common/widgets/LibrarySelectorWidget/LibrarySelectorWidget.h>\r\n\r\n#include <IPXACTmodels/common/Document.h>\r\n#include <IPXACTmodels/common/VLNV.h>\r\n#include <KactusAPI/include/LibraryInterface.h>\r\n\r\n#include <QVBoxLayout>\r\n#include <QFont>\r\n#include <QCoreApplication>\r\n#include <QMessageBox>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: NewPage()\r\n//-----------------------------------------------------------------------------\r\nNewPage::NewPage(LibraryInterface* libInterface, VLNV::IPXactType vlnvType, QString title, QString description,\r\n    QWidget* parentDlg):\r\nPropertyPageView(),\r\nvlnvEditor_(new VLNVEditor(vlnvType, libInterface, parentDlg, this)),\r\nlibInterface_(libInterface),\r\nrevisionSelector_(new QComboBox(this)),\r\nlibrarySelector_(new LibrarySelectorWidget(this)),\r\ntitleLabel_(new QLabel(title,this)),\r\ndescLabel_(new QLabel(description,this))\r\n{   \r\n    QFont font = titleLabel_->font();\r\n    font.setPointSize(12);\r\n    font.setBold(true);\r\n    titleLabel_->setFont(font);\r\n\r\n    revisionSelector_->addItem(Document::toString(Document::Revision::Std22));\r\n    revisionSelector_->addItem(Document::toString(Document::Revision::Std14));\r\n\r\n    QSettings settings;\r\n    auto defaultRevision = settings.value(\"General/Revision\", Document::toString(Document::Revision::Std22)).toString();\r\n    revisionSelector_->setCurrentText(defaultRevision);\r\n\r\n    connect(vlnvEditor_, SIGNAL(contentChanged()), this, SIGNAL(contentChanged()));\r\n    connect(vlnvEditor_, SIGNAL(contentChanged()), this, SLOT(updateDirectory()));\r\n\r\n\tconnect(librarySelector_, SIGNAL(contentChanged()), this, SIGNAL(contentChanged()));\r\n\r\n    setupLayout();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: prevalidate()\r\n//-----------------------------------------------------------------------------\r\nbool NewPage::prevalidate() const\r\n{\r\n    return (vlnvEditor_->isValid() && librarySelector_->isValid());\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: validate()\r\n//-----------------------------------------------------------------------------\r\nbool NewPage::validate()\r\n{\r\n    Q_ASSERT(prevalidate());\r\n\r\n    return isUnusedVLNV(vlnvEditor_->getVLNV());\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: onPageChange()\r\n//-----------------------------------------------------------------------------\r\nbool NewPage::onPageChange()\r\n{\r\n    // Discard the VLNV and reset the attributes.\r\n    librarySelector_->reset();\r\n    \r\n    vlnvEditor_->setVLNV(VLNV());\r\n    return true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: updateDirectory()\r\n//-----------------------------------------------------------------------------\r\nvoid NewPage::updateDirectory()\r\n{\r\n    QString vlnvDir;\r\n\r\n    VLNV vlnv = vlnvEditor_->getVLNV();\r\n\r\n    if (!vlnv.getVendor().isEmpty())\r\n    {\r\n        vlnvDir += \"/\" + vlnv.getVendor();\r\n\r\n        if (!vlnv.getLibrary().isEmpty())\r\n        {\r\n            vlnvDir += \"/\" + vlnv.getLibrary();\r\n\r\n            if (!vlnv.getName().isEmpty())\r\n            {\r\n                vlnvDir += \"/\" + vlnv.getName();\r\n\r\n                if (!vlnv.getVersion().isEmpty())\r\n                {\r\n                    vlnvDir += \"/\" + vlnv.getVersion();\r\n                }\r\n            }\r\n        }\r\n    }\r\n\r\n    librarySelector_->updatePath(vlnvDir);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: NewPage::onProductHierarchyChanged()\r\n//-----------------------------------------------------------------------------\r\nvoid NewPage::onProductHierarchyChanged()\r\n{\r\n    // Update the VLNV's library field if it is either empty or any of the predefined ones.\r\n    VLNV vlnv = vlnvEditor_->getVLNV();\r\n\r\n    if (vlnv.getLibrary().isEmpty())\r\n    {\r\n        vlnv.setLibrary(KactusAttribute::hierarchyToString(getProductHierarchy()).toLower());\r\n    }\r\n    else if (KactusAttribute::hierarchyFrom(vlnv.getLibrary().toLower()) != KactusAttribute::KTS_PRODHIER_COUNT)\r\n    {\r\n        vlnv.setLibrary(KactusAttribute::hierarchyToString(getProductHierarchy()).toLower());\r\n    }\r\n\r\n    vlnvEditor_->setVLNV(vlnv);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: NewPage::getProductHierarchy()\r\n//-----------------------------------------------------------------------------\r\nKactusAttribute::ProductHierarchy NewPage::getProductHierarchy() const\r\n{\r\n    return KactusAttribute::KTS_PRODHIER_COUNT;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: NewPage::isUnusedVLNV()\r\n//-----------------------------------------------------------------------------\r\nbool NewPage::isUnusedVLNV(VLNV const& vlnv) const\r\n{\r\n    return !libInterface_->contains(vlnv);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: NewPage::selectedPath()\r\n//-----------------------------------------------------------------------------\r\nQString NewPage::selectedPath() const\r\n{\r\n    return librarySelector_->getPath();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: NewPage::showErrorForReservedVLVN()\r\n//-----------------------------------------------------------------------------\r\nvoid NewPage::showErrorForReservedVLVN(VLNV const& vlnv)\r\n{\r\n    QString type = type2Show(vlnv.getType());\r\n    QMessageBox msgBox(QMessageBox::Critical, QCoreApplication::applicationName(),\r\n        tr(\"The %1 cannot be created because the VLNV %2\" \r\n        \" already exists in the library.\").arg(type, vlnv.toString()), QMessageBox::Ok, this);\r\n    msgBox.exec();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: NewPage::type2Show()\r\n//-----------------------------------------------------------------------------\r\nQString NewPage::type2Show(VLNV::IPXactType const& type)\r\n{\r\n    return VLNV::IPXactType2String(type);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: NewPage::selectedRevision()\r\n//-----------------------------------------------------------------------------\r\nDocument::Revision NewPage::selectedRevision() const\r\n{\r\n    return Document::toRevision(revisionSelector_->currentText());\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: setupLayout()\r\n//-----------------------------------------------------------------------------\r\nvoid NewPage::setupLayout()\r\n{\r\n    auto revisionLayout = new QHBoxLayout();\r\n    revisionLayout->addWidget(new QLabel(tr(\"Revision: \"), this));\r\n    revisionLayout->addWidget(revisionSelector_, 1);\r\n  \r\n    auto layout = new QVBoxLayout(this);\r\n    layout->addWidget(titleLabel_);\r\n    layout->addWidget(descLabel_);\r\n    layout->addSpacing(12);\r\n    layout->addWidget(vlnvEditor_);\r\n    layout->addLayout(revisionLayout);\r\n    layout->addWidget(librarySelector_);\r\n}\r\n"
  },
  {
    "path": "mainwindow/NewPages/NewPage.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: NewPage.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Esko Pekkarinen\r\n// Date: 28.8.2013\r\n//\r\n// Description:\r\n// Base class for all New pages.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef NEWPAGE_H\r\n#define NEWPAGE_H\r\n\r\n#include <common/dialogs/propertyPageDialog/PropertyPageView.h>\r\n\r\n#include <IPXACTmodels/common/Document.h>\r\n#include <IPXACTmodels/common/VLNV.h>\r\n#include <IPXACTmodels/kactusExtensions/KactusAttribute.h>\r\n\r\n#include <QLabel>\r\n#include <QComboBox>\r\n\r\nclass LibraryInterface;\r\nclass VLNVEditor;\r\nclass LibrarySelectorWidget;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! NewPage class.\r\n//-----------------------------------------------------------------------------\r\nclass NewPage : public PropertyPageView\r\n{\r\n    Q_OBJECT\r\n\r\npublic:\r\n    /*!\r\n     *  Constructor.\r\n     *\r\n     *    @param [in] libInterface The library interface.\r\n     *    @param [in] parentDlg    The parent dialog.\r\n     */\r\n    NewPage(LibraryInterface* libInterface, VLNV::IPXactType vlnvType, QString title = QString(), \r\n        QString description = QString(), QWidget* parentDlg = 0);\r\n\r\n    /*!\r\n     *  Destructor.\r\n     */\r\n    virtual ~NewPage() = default;\r\n\r\n    // Disable copying.\r\n    NewPage(NewPage const& rhs) = delete;\r\n    NewPage& operator=(NewPage const& rhs) = delete;\r\n\r\n    /*!\r\n     *  Pre-validates the contents of the page. This is used for enabling/disabling the OK button.\r\n     *\r\n     *    @return True, if the contents are valid and OK button should be enabled.\r\n     *              False, if the contents are invalid and OK button should be disabled.\r\n     *\r\n     *      @remarks Must not show any message boxes.\r\n     */\r\n    virtual bool prevalidate() const;\r\n\r\n    /*!\r\n     *  Validates the contents of the page thoroughly.\r\n     *\r\n     *    @return True, if the contents are valid. False, if they are invalid.\r\n     *\r\n     *      @remarks Showing message boxes for errors is allowed.\r\n     */\r\n    virtual bool validate();\r\n\r\n    /*!\r\n     *  Called when the page is to be changed and this page would be hidden.\r\n     *\r\n     *    @return False, if the page change should be rejected. Otherwise true.\r\n     */\r\n    virtual bool onPageChange();\r\n    \r\npublic slots:\r\n\r\n    /*!\r\n     *  Updates the directory based on the VLNV.\r\n     */\r\n    void updateDirectory();\r\n\r\n    //! Updates the VLNV library based on selected product hierarchy.\r\n    void onProductHierarchyChanged();\r\n\r\nprotected:\r\n    \r\n    /*!\r\n     *  Gets the selected product hierarchy level, if selected.\r\n     *\r\n     *    @return The selected product hierarchy.\r\n     */\r\n    virtual KactusAttribute::ProductHierarchy getProductHierarchy() const;\r\n\r\n    /*!\r\n     *  Checks if the given VLNV is not found in the library.\r\n     *\r\n     *    @param [in] vlnv   The VLNV to check.\r\n     *\r\n     *    @return True, if the VLNV is not already in the library, otherwise false.\r\n     */\r\n    bool isUnusedVLNV(VLNV const& vlnv) const;\r\n\r\n    /*!\r\n     *  Gets the selected path within the library.\r\n     *\r\n     *    @return The selected path.\r\n     */\r\n    QString selectedPath() const;\r\n\r\n    /*!\r\n     *  Shows an error message for a VLNV already found in the library.\r\n     *\r\n     *    @param [in] vlnv    The reserved VLNV.     \r\n     */\r\n    void showErrorForReservedVLVN(VLNV const& vlnv);\r\n\r\n    /*!\r\n     *  Gets the name of the VLNV type\r\n     *\r\n     *    @param [in] type    The type whose name to get.\r\n     *\r\n     *    @return The name of the VLNV document type.\r\n     */\r\n    QString type2Show(VLNV::IPXactType const& type);\r\n\r\n    /*!\r\n     *  Gets the selected document revision.\r\n     *\r\n     *    @return The selected IP-XACT revision.\r\n     */\r\n    Document::Revision selectedRevision() const;\r\n\r\n    //! VLNV editor.\r\n    VLNVEditor* vlnvEditor_;\r\n\r\n    //! The library interface.\r\n    LibraryInterface* libInterface_;\r\n\r\nprivate:\r\n\r\n    /*!\r\n     *  Sets the basic layout for the page.\r\n     */\r\n    void setupLayout();\r\n\r\n    //! IP-XACT standard revision selector.\r\n    QComboBox* revisionSelector_;\r\n\r\n    //! Library selector.\r\n    LibrarySelectorWidget* librarySelector_;\r\n\r\n    //! Page title.\r\n    QLabel* titleLabel_;\r\n    \r\n    //! Page description.\r\n    QLabel* descLabel_;\r\n\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n\r\n#endif // NEWPAGE_H\r\n"
  },
  {
    "path": "mainwindow/NewPages/NewSWComponentPage.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: NewSWComponentPage.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Joni-Matti Maatta\r\n// Date: 24.8.2011\r\n//\r\n// Description:\r\n// New SW component page.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"NewSWComponentPage.h\"\r\n\r\n#include <common/widgets/vlnvEditor/vlnveditor.h>\r\n\r\n#include <IPXACTmodels/common/VLNV.h>\r\n#include <IPXACTmodels/kactusExtensions/KactusAttribute.h>\r\n\r\n#include <KactusAPI/include/LibraryInterface.h>\r\n\r\n#include <QVBoxLayout>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: NewSWComponentPage()\r\n//-----------------------------------------------------------------------------\r\nNewSWComponentPage::NewSWComponentPage(LibraryInterface* libInterface, QWidget* parentDlg):\r\nNewPage(libInterface, VLNV::COMPONENT, tr(\"New SW Component\"), tr(\"Creates a SW component\"), parentDlg)\r\n{\r\n    vlnvEditor_->setImplementationFilter(true, KactusAttribute::SW);\r\n\r\n    QVBoxLayout* topLayout = dynamic_cast<QVBoxLayout*>(layout());\r\n    topLayout->addStretch(1);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: validate()\r\n//-----------------------------------------------------------------------------\r\nbool NewSWComponentPage::validate()\r\n{\r\n    bool valid = NewPage::validate();\r\n\r\n    // Check if the VLNV already exists.\r\n    if (!valid)\r\n    {        \r\n        showErrorForReservedVLVN(vlnvEditor_->getVLNV());\r\n    }\r\n\r\n    return valid;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: apply()\r\n//-----------------------------------------------------------------------------\r\nvoid NewSWComponentPage::apply()\r\n{\r\n    emit createSWComponent(vlnvEditor_->getVLNV(), selectedRevision(), selectedPath());\r\n}\r\n"
  },
  {
    "path": "mainwindow/NewPages/NewSWComponentPage.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: NewSWComponentPage.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Joni-Matti Maatta\r\n// Date: 24.8.2011\r\n//\r\n// Description:\r\n// New SW component page.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef NEWSWCOMPONENTPAGE_H\r\n#define NEWSWCOMPONENTPAGE_H\r\n\r\n#include \"NewPage.h\"\r\n\r\nclass LibraryInterface;\r\nclass VLNV;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! NewSWComponentPage class.\r\n//-----------------------------------------------------------------------------\r\nclass NewSWComponentPage : public NewPage\r\n{\r\n    Q_OBJECT\r\n\r\npublic:\r\n    /*!\r\n     *  Constructor.\r\n     *\r\n     *    @param [in] libInterface The library interface.\r\n     *    @param [in] parentDlg    The parent dialog.\r\n     */\r\n    NewSWComponentPage(LibraryInterface* libInterface, QWidget* parentDlg);\r\n\r\n    /*!\r\n     *  Destructor.\r\n     */\r\n    virtual ~NewSWComponentPage() = default;\r\n\r\n    // Disable copying.\r\n    NewSWComponentPage(NewSWComponentPage const& rhs) = delete;\r\n    NewSWComponentPage& operator=(NewSWComponentPage const& rhs) = delete;\r\n\r\n    /*!\r\n     *  Validates the contents of the page thoroughly.\r\n     *\r\n     *    @return True, if the contents are valid. False, if they are invalid.\r\n     *\r\n     *      @remarks Showing message boxes for errors is allowed.\r\n     */\r\n    bool validate() final;\r\n\r\n    /*!\r\n     *  Applies the changes that were done in the page.\r\n     */\r\n    void apply() final;\r\n\r\n\r\nsignals:\r\n    //! Signaled when a SW component should be created.\r\n    void createSWComponent(VLNV const& vlnv, Document::Revision revision, QString const& directory);\r\n\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n\r\n#endif // NEWSWCOMPONENTPAGE_H\r\n"
  },
  {
    "path": "mainwindow/NewPages/NewSWDesignPage.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: NewSWDesignPage.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Joni-Matti Maatta\r\n// Date: 14.11.2011\r\n//\r\n// Description:\r\n// New software design page.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"NewSWDesignPage.h\"\r\n\r\n#include <KactusAPI/include/LibraryInterface.h>\r\n\r\n#include <common/widgets/vlnvEditor/vlnveditor.h>\r\n\r\n#include <QVBoxLayout>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: NewSWDesignPage()\r\n//-----------------------------------------------------------------------------\r\nNewSWDesignPage::NewSWDesignPage(LibraryInterface* libInterface, QWidget* parentDlg):\r\nNewPage(libInterface, VLNV::COMPONENT, tr(\"New SW Design\"), tr(\"Creates a hierarchical SW design\"), parentDlg)\r\n{    \r\n    // Create the VLNV editor.\r\n    vlnvEditor_->setImplementationFilter(true, KactusAttribute::SW);\r\n\r\n    QVBoxLayout* topLayout = dynamic_cast<QVBoxLayout*>(layout());\r\n    topLayout->addStretch(1);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: validate()\r\n//-----------------------------------------------------------------------------\r\nbool NewSWDesignPage::validate()\r\n{\r\n    // Check if the VLNV already exists.\r\n    VLNV vlnv = vlnvEditor_->getVLNV();\r\n    bool validVLNV = NewPage::validate();\r\n\r\n    VLNV designVLNV(VLNV::DESIGN, vlnv.getVendor(), vlnv.getLibrary(),\r\n        vlnv.getName().remove(\".comp\") + \".design\", vlnv.getVersion());\r\n\r\n    // Check if any of the VLNVs already exists.\r\n    if (!validVLNV)\r\n    {\r\n        showErrorForReservedVLVN(vlnv);\r\n        return false;\r\n    }\r\n\r\n    if (!isUnusedVLNV(designVLNV))\r\n    {\r\n        showErrorForReservedVLVN(designVLNV);       \r\n        return false;\r\n    }\r\n\r\n    return true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: apply()\r\n//-----------------------------------------------------------------------------\r\nvoid NewSWDesignPage::apply()\r\n{\r\n    emit createSWDesign(vlnvEditor_->getVLNV(), selectedRevision(), selectedPath());\r\n}\r\n\r\n"
  },
  {
    "path": "mainwindow/NewPages/NewSWDesignPage.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: NewSWDesignPage.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Joni-Matti Maatta\r\n// Date: 14.11.2011\r\n//\r\n// Description:\r\n// New software design page.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef NEWSWDESIGNPAGE_H\r\n#define NEWSWDESIGNPAGE_H\r\n\r\n#include \"NewPage.h\"\r\n\r\nclass LibraryInterface;\r\n//-----------------------------------------------------------------------------\r\n//! NewSWDesignPage class.\r\n//-----------------------------------------------------------------------------\r\nclass NewSWDesignPage : public NewPage\r\n{\r\n    Q_OBJECT\r\n\r\npublic:\r\n    /*!\r\n     *  Constructor.\r\n     *\r\n     *    @param [in] libInterface The library interface.\r\n     *    @param [in] parentDlg    The parent dialog.\r\n     */\r\n    NewSWDesignPage(LibraryInterface* libInterface, QWidget* parentDlg);\r\n\r\n    /*!\r\n     *  Destructor.\r\n     */\r\n    virtual ~NewSWDesignPage() = default;\r\n\r\n    // Disable copying.\r\n    NewSWDesignPage(NewSWDesignPage const& rhs) = delete;\r\n    NewSWDesignPage& operator=(NewSWDesignPage const& rhs) = delete;\r\n\r\n    /*!\r\n     *  Validates the contents of the page thoroughly.\r\n     *\r\n     *    @return True, if the contents are valid. False, if they are invalid.\r\n     *\r\n     *      @remarks Showing message boxes for errors is allowed.\r\n     */\r\n    bool validate() final;\r\n\r\n    /*!\r\n     *  Applies the changes that were done in the page.\r\n     */\r\n    void apply() final;\r\n\r\nsignals:\r\n    //! Signaled when a design should be created.\r\n    void createSWDesign(VLNV const& vlnv, Document::Revision revision, QString const& directory);\r\n\r\n    \r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n\r\n\r\n#endif // NEWSWDESIGNPAGE_H\r\n"
  },
  {
    "path": "mainwindow/NewPages/NewSystemPage.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: NewSystemPage.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Joni-Matti Maatta\r\n// Date: 9.6.2011\r\n//\r\n// Description:\r\n// New system property page.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"NewSystemPage.h\"\r\n\r\n#include <KactusAPI/include/LibraryItem.h>\r\n#include <KactusAPI/include/LibraryInterface.h>\r\n\r\n#include <common/widgets/vlnvEditor/vlnveditor.h>\r\n\r\n#include <IPXACTmodels/Component/Component.h>\r\n\r\n#include <QVBoxLayout>\r\n#include <QHeaderView>\r\n#include <QPushButton>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: NewSystemPage::NewSystemPage()\r\n//-----------------------------------------------------------------------------\r\nNewSystemPage::NewSystemPage(LibraryInterface* libInterface, QWidget* parent):\r\nNewPage(libInterface, VLNV::COMPONENT, tr(\"New System\"), tr(\"Creates SW architecture that can be mapped to HW\"), parent),\r\n    optionGroupBox_(new QGroupBox(tr(\"Mapping options\"), this)),\r\n    unmapRadioButton_(new QRadioButton(tr(\"Leave initially unmapped\"), this)),\r\n    mapRadioButton_(new QRadioButton(tr(\"Map to specific HW now\"), this)),\r\n    compTreeWidget_(new QTreeWidget(this)),             \r\n    viewComboBox_(new QComboBox(this))\r\n{\r\n    vlnvEditor_->setImplementationFilter(true, KactusAttribute::SYSTEM);\r\n    vlnvEditor_->addNameExtension(\".sysdesign\");\r\n    vlnvEditor_->addNameExtension(\".sysdesigncfg\");\r\n\r\n    QButtonGroup* actionGroup(new QButtonGroup(this));\r\n    actionGroup->addButton(unmapRadioButton_);\r\n    actionGroup->addButton(mapRadioButton_);\r\n\r\n    QFont buttonFont = unmapRadioButton_->font();\r\n    buttonFont.setBold(true);    \r\n    unmapRadioButton_->setFont(buttonFont);\r\n    mapRadioButton_->setFont(buttonFont);\r\n\r\n    QString buttonStyle = QStringLiteral(\"QRadioButton::indicator { width: 15px; height: 15px; }\");\r\n    unmapRadioButton_->setStyleSheet(buttonStyle);\r\n    mapRadioButton_->setStyleSheet(buttonStyle);\r\n\r\n    initializeHWComponentSelectionWidget(libInterface);\r\n\r\n    unmapRadioButton_->setChecked(true);\r\n\r\n    setupLayout();\r\n\r\n    connect(actionGroup, SIGNAL(buttonClicked(QAbstractButton*)),\r\n        this, SLOT(actionChanged(QAbstractButton*)), Qt::UniqueConnection);\r\n\r\n    connect(compTreeWidget_, SIGNAL(currentItemChanged(QTreeWidgetItem*, QTreeWidgetItem*)),\r\n        this, SLOT(onTreeItemChanged(QTreeWidgetItem*, QTreeWidgetItem*)));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: NewSystemPage::prevalidate()\r\n//-----------------------------------------------------------------------------\r\nbool NewSystemPage::prevalidate() const\r\n{\r\n    if (mapRadioButton_->isChecked())\r\n    {\r\n        if (compTreeWidget_->currentItem() == 0)\r\n        {\r\n            return false;\r\n        }\r\n\r\n        QVariant data = compTreeWidget_->currentItem()->data(0, Qt::UserRole);\r\n\r\n        return (!data.isNull() && data.value<VLNV>().isValid() && NewPage::prevalidate());\r\n    }\r\n    else\r\n    {\r\n        return NewPage::prevalidate();\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: NewSystemPage::validate()\r\n//-----------------------------------------------------------------------------\r\nbool NewSystemPage::validate()\r\n{\r\n    Q_ASSERT(prevalidate());\r\n\r\n    VLNV vlnv = vlnvEditor_->getVLNV();\r\n    bool validVLNV = NewPage::validate();\r\n\r\n    VLNV designVLNV(VLNV::DESIGN, vlnv.getVendor(), vlnv.getLibrary(),\r\n        vlnv.getName().remove(\".comp\") + \".sysdesign\", vlnv.getVersion());\r\n    VLNV desConfVLNV(VLNV::DESIGNCONFIGURATION, vlnv.getVendor(), vlnv.getLibrary(),\r\n        vlnv.getName().remove(\".comp\") + \".sysdesigncfg\", vlnv.getVersion());\r\n\r\n    // Check if any of the VLNVs already exists.\r\n    if (unmapRadioButton_->isChecked() && !validVLNV)\r\n    {\r\n        showErrorForReservedVLVN(vlnv);\r\n        return false;\r\n    }\r\n\r\n    if (!isUnusedVLNV(designVLNV))\r\n    {\r\n        showErrorForReservedVLVN(designVLNV);\r\n        return false;\r\n    }\r\n\r\n    if (!isUnusedVLNV(desConfVLNV))\r\n    {\r\n        showErrorForReservedVLVN(desConfVLNV);        \r\n        return false;\r\n    }    \r\n\r\n    return true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: NewSystemPage::apply()\r\n//-----------------------------------------------------------------------------\r\nvoid NewSystemPage::apply()\r\n{\r\n    // Create the system in a different way based on the mapping option selection.\r\n    if (mapRadioButton_->isChecked())\r\n    {\r\n        Q_ASSERT(compTreeWidget_->currentItem() != 0);\r\n        QVariant data = compTreeWidget_->currentItem()->data(0, Qt::UserRole);\r\n\r\n        emit createSystem(data.value<VLNV>(), viewComboBox_->currentText(),\r\n            vlnvEditor_->getVLNV(), selectedRevision(), selectedPath());\r\n    }\r\n    else\r\n    {\r\n        emit createSystem(VLNV(), QString(), vlnvEditor_->getVLNV(), selectedRevision(), selectedPath());\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: NewSystemPage::onPageChange()\r\n//-----------------------------------------------------------------------------\r\nbool NewSystemPage::onPageChange()\r\n{\r\n    // Discard the VLNV and collapse the tree widget.\r\n    compTreeWidget_->collapseAll();\r\n    compTreeWidget_->setCurrentItem(nullptr);\r\n\r\n    return NewPage::onPageChange();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: NewSystemPage::onTreeItemChanged()\r\n//-----------------------------------------------------------------------------\r\nvoid NewSystemPage::onTreeItemChanged(QTreeWidgetItem* current, QTreeWidgetItem*)\r\n{\r\n    if (current != nullptr)\r\n    {\r\n        // Check if the item has a VLNV (i.e. is a leaf item).\r\n        QVariant data = current->data(0, Qt::UserRole);\r\n\r\n        if (!data.isNull())\r\n        {\r\n            VLNV vlnv = data.value<VLNV>();\r\n\r\n            // Add all available hierarchical views to the view combo box.\r\n            QSharedPointer<Component> component = libInterface_->getModel(vlnv).staticCast<Component>();\r\n\r\n            viewComboBox_->clear();\r\n            viewComboBox_->addItems(component->getHierViews());\r\n        }\r\n    }\r\n\r\n    emit contentChanged();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: NewSystemPage::actionChanged()\r\n//-----------------------------------------------------------------------------\r\nvoid NewSystemPage::actionChanged(QAbstractButton* button)\r\n{\r\n    if (button == unmapRadioButton_)\r\n    {\r\n        compTreeWidget_->setCurrentItem(0);\r\n        viewComboBox_->clear();\r\n    }\r\n\r\n    emit contentChanged();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: NewSystemPage::initializeHWComponentSelectionWidget()\r\n//-----------------------------------------------------------------------------\r\nvoid NewSystemPage::initializeHWComponentSelectionWidget(LibraryInterface* libInterface)\r\n{\r\n    compTreeWidget_->setColumnCount(1);\r\n    compTreeWidget_->setSelectionBehavior(QAbstractItemView::SelectItems);\r\n    compTreeWidget_->header()->close();\r\n    compTreeWidget_->setIconSize(QSize(20, 20));\r\n\r\n    LibraryItem const* rootItem = libInterface->getTreeRoot();\r\n\r\n    const int itemCount = rootItem->getNumberOfChildren();\r\n    for (int i = 0; i < itemCount; i++)\r\n    {\r\n        QTreeWidgetItem* child = createChildRecursively(rootItem->child(i));\r\n        if (child)\r\n        {\r\n            compTreeWidget_->addTopLevelItem(child);\r\n        }\r\n    }\r\n\r\n    compTreeWidget_->sortItems(0, Qt::AscendingOrder);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: NewSystemPage::createChildRecursively()\r\n//-----------------------------------------------------------------------------\r\nQTreeWidgetItem* NewSystemPage::createChildRecursively(LibraryItem const* libraryItem) const\r\n{\r\n    // Only hierarchical HW components are added.\r\n    if (!libraryItem->hasChildren())\r\n    {\r\n        VLNV vlnv = libraryItem->getVLNV();\r\n\r\n        if (vlnv.isValid() && vlnv.getType() == VLNV::COMPONENT)\r\n        {\r\n            QSharedPointer<Component> component = libInterface_->getModel(vlnv).staticCast<Component>();\r\n\r\n            if (component->getImplementation() == KactusAttribute::HW && !component->getHierViews().isEmpty())\r\n            {\r\n                QTreeWidgetItem* leafItem = new QTreeWidgetItem();\r\n                leafItem->setText(0, libraryItem->name());\r\n\r\n                leafItem->setData(0, Qt::UserRole, QVariant::fromValue(vlnv));\r\n                leafItem->setIcon(0, QIcon(\":icons/common/graphics/hier-hw-component.png\"));\r\n\r\n                return leafItem;\r\n            }\r\n        }\r\n    }\r\n\r\n    // Recursively add its children if this is not the leaf level.\r\n    else\r\n    {\r\n        QTreeWidgetItem* intermediateItem = new QTreeWidgetItem();\r\n        intermediateItem->setText(0, libraryItem->name());\r\n\r\n        const int childCount = libraryItem->getNumberOfChildren();\r\n        for (int i = 0; i < childCount; i++)\r\n        {\r\n            QTreeWidgetItem* childItem = createChildRecursively(libraryItem->child(i));  \r\n            if (childItem)\r\n            {\r\n                intermediateItem->addChild(childItem);\r\n            }\r\n        }\r\n        \r\n        // Discard items with no content to show.\r\n        if (intermediateItem->childCount() == 0)\r\n        {\r\n            delete intermediateItem;\r\n            intermediateItem = 0;\r\n        }\r\n\r\n        return intermediateItem;\r\n    }\r\n\r\n    return 0;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: NewSystemPage::setupLayout()\r\n//-----------------------------------------------------------------------------\r\nvoid NewSystemPage::setupLayout()\r\n{\r\n    QString labelStyle = QStringLiteral(\"QLabel { padding-left: 19px; }\");\r\n\r\n    QLabel* unmappedLabel = new QLabel(tr(\"Creates an unmapped SW architecture. \"\r\n        \"A new system component will be created.\"), this);\r\n    unmappedLabel->setStyleSheet(labelStyle);\r\n    unmappedLabel->setWordWrap(true);\r\n\r\n    QLabel* mappedLabel = new QLabel(tr(\"Creates a SW architecture and maps it to selected top-level HW. \"\r\n        \"A system view will be created for the HW component to reference the new system design.\"), this);\r\n    mappedLabel->setStyleSheet(labelStyle);\r\n    mappedLabel->setWordWrap(true);\r\n\r\n    QLabel* treeLabel = new QLabel(tr(\"Select top-level HW component:\"), this);\r\n\r\n    QVBoxLayout* optionsLayout = new QVBoxLayout(optionGroupBox_);\r\n    optionsLayout->addWidget(unmapRadioButton_);\r\n    optionsLayout->addWidget(unmappedLabel);\r\n    optionsLayout->addWidget(mapRadioButton_);\r\n    optionsLayout->addWidget(mappedLabel);\r\n    optionsLayout->addWidget(treeLabel);\r\n    optionsLayout->addWidget(compTreeWidget_, 1);\r\n\r\n    QHBoxLayout* viewLayout = new QHBoxLayout();\r\n    QLabel* viewLabel = new QLabel(tr(\"Select view of top-level HW component:\"), this);\r\n    viewLayout->addWidget(viewLabel);\r\n    viewLayout->addWidget(viewComboBox_, 1);\r\n    \r\n    optionsLayout->addLayout(viewLayout);\r\n\r\n    // Finalize inherited NewPage layout.\r\n    QVBoxLayout* topLayout = dynamic_cast<QVBoxLayout*>(layout());\r\n    topLayout->addWidget(optionGroupBox_);\r\n\r\n    treeLabel->setDisabled(true);\r\n    compTreeWidget_->setDisabled(true);\r\n    viewLabel->setDisabled(true);\r\n    viewComboBox_->setDisabled(true);\r\n\r\n    connect(mapRadioButton_, SIGNAL(toggled(bool)), treeLabel, SLOT(setEnabled(bool)), Qt::UniqueConnection);\r\n    connect(mapRadioButton_, SIGNAL(toggled(bool)), compTreeWidget_, SLOT(setEnabled(bool)), Qt::UniqueConnection);\r\n    connect(mapRadioButton_, SIGNAL(toggled(bool)), viewLabel, SLOT(setEnabled(bool)), Qt::UniqueConnection);\r\n    connect(mapRadioButton_, SIGNAL(toggled(bool)), viewComboBox_, SLOT(setEnabled(bool)), Qt::UniqueConnection);\r\n}\r\n"
  },
  {
    "path": "mainwindow/NewPages/NewSystemPage.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: NewSystemPage.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Joni-Matti Maatta\r\n// Date: 9.6.2011\r\n//\r\n// Description:\r\n// New system property page.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef NEWSYSTEMPAGE_H\r\n#define NEWSYSTEMPAGE_H\r\n\r\n#include \"NewPage.h\"\r\n\r\n#include <QTreeWidget>\r\n#include <QComboBox>\r\n#include <QGroupBox>\r\n#include <QRadioButton>\r\n#include <QButtonGroup>\r\n#include <QLabel>\r\n\r\nclass LibraryInterface;\r\nclass LibraryItem;\r\nclass VLNV;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! NewSystemPage class.\r\n//-----------------------------------------------------------------------------\r\nclass NewSystemPage : public NewPage\r\n{\r\n    Q_OBJECT\r\n\r\npublic:\r\n    /*!\r\n     *  Constructor.\r\n     *\r\n     *    @param [in] libInterface    The library interface.\r\n     *    @param [in] parent          The parent widget.\r\n     */\r\n    NewSystemPage(LibraryInterface* libInterface, QWidget* parent);\r\n\r\n    /*!\r\n     *  Destructor.\r\n     */\r\n    virtual ~NewSystemPage() = default;\r\n\r\n    // Disable copying.\r\n    NewSystemPage(NewSystemPage const& rhs) = delete;\r\n    NewSystemPage& operator=(NewSystemPage const& rhs) = delete;\r\n\r\n    /*!\r\n     *  Pre-validates the contents of the page. This is used for enabling/disabling the OK button.\r\n     *\r\n     *    @return True, if the contents are valid and OK button should be enabled.\r\n     *              False, if the contents are invalid and OK button should be disabled.\r\n     *\r\n     *      @remarks Must not show any message boxes.\r\n     */\r\n    bool prevalidate() const final;\r\n\r\n    /*!\r\n     *  Validates the contents of the page thoroughly.\r\n     *\r\n     *    @return True, if the contents are valid. False, if they are invalid.\r\n     *\r\n     *      @remarks Showing message boxes for errors is allowed.\r\n     */\r\n    bool validate() final;\r\n\r\n    /*!\r\n     *  Applies the changes that were done in the page.\r\n     */\r\n    void apply() final;\r\n\r\n    /*!\r\n     *  Called when the page is to be changed and this page would be hidden.\r\n     *\r\n     *    @return False, if the page change should be rejected. Otherwise true.\r\n     */\r\n    bool onPageChange() final;\r\n\r\npublic slots:\r\n\r\n    /*!\r\n     *  Called when the item in the tree widget has changed.\r\n     */\r\n    void onTreeItemChanged(QTreeWidgetItem* cur, QTreeWidgetItem*);\r\n\r\nsignals:\r\n    //! Signaled when a system design should be created.\r\n    void createSystem(VLNV const& compVLNV, QString const& viewName,\r\n                      VLNV const& sysVLNV, Document::Revision revision, QString const& directory);\r\n\r\nprivate slots:\r\n    //! Called when radio button for mapping options selection is clicked.\r\n    void actionChanged(QAbstractButton* button);\r\n\r\nprivate:\r\n\r\n    /*!\r\n     *  Initializes the top component selection listing for HW mapping.\r\n     *\r\n     *    @param [in] libInterface   The library interface.\r\n     */\r\n    void initializeHWComponentSelectionWidget(LibraryInterface* libInterface);\r\n\r\n    /*!\r\n     *  Creates an item for selection widget for the given library item finding child items recursively.\r\n     *\r\n     *    @param [in] libraryItem   The library item to create the item for.\r\n     *\r\n     *    @return The item for selection widget.\r\n     */\r\n    QTreeWidgetItem* createChildRecursively(LibraryItem const* libraryItem) const;\r\n\r\n    //! Sets the page layout.\r\n    void setupLayout();\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! Group box for radio buttons.\r\n    QGroupBox* optionGroupBox_;\r\n\r\n    //! Radio button for empty SW architecture action.\r\n    QRadioButton* unmapRadioButton_;\r\n\r\n    //! Radio button for map HW action.\r\n    QRadioButton* mapRadioButton_;\r\n\r\n    //! Component selection tree widget.\r\n    QTreeWidget* compTreeWidget_;\r\n\r\n    //! View selection combo box.\r\n    QComboBox* viewComboBox_;\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n\r\n#endif // NEWSYSTEMPAGE_H\r\n"
  },
  {
    "path": "mainwindow/NewWorkspaceDialog.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: NewWorkspaceDialog.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Joni-Matti Maatta\r\n// Date: 24.1.2012\r\n//\r\n// Description:\r\n// Dialog for creating new workspaces.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"NewWorkspaceDialog.h\"\r\n\r\n#include <QGridLayout>\r\n#include <QLabel>\r\n#include <QMessageBox>\r\n#include <QCoreApplication>\r\n#include <QSettings>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: NewWorkspaceDialog()\r\n//-----------------------------------------------------------------------------\r\nNewWorkspaceDialog::NewWorkspaceDialog(QWidget* parent) : QDialog(parent), nameEdit_(0), btnOk_(0)\r\n{\r\n    // Create the name label and field.\r\n    QLabel* nameLabel = new QLabel(tr(\"Name:\"), this);\r\n    nameEdit_ = new QLineEdit(this);\r\n\r\n    // Create the dialog buttons.\r\n    btnOk_ = new QPushButton(tr(\"OK\") , this);\r\n    QPushButton* btnCancel = new QPushButton(tr(\"Cancel\"), this);\r\n\r\n    QHBoxLayout* buttonLayout = new QHBoxLayout();\r\n    buttonLayout->addStretch(1);\r\n    buttonLayout->addWidget(btnOk_);\r\n    buttonLayout->addWidget(btnCancel);\r\n\r\n    // Create the main layout.\r\n    QGridLayout* layout = new QGridLayout(this);\r\n    layout->addWidget(nameLabel, 0, 0, 1, 1);\r\n    layout->addWidget(nameEdit_, 0, 1, 1, 1);\r\n    layout->addLayout(buttonLayout, 1, 0, 1, 2);\r\n\r\n    connect(btnOk_, SIGNAL(clicked()), this, SLOT(accept()));\r\n    connect(btnCancel, SIGNAL(clicked()), this, SLOT(reject()));\r\n    connect(nameEdit_, SIGNAL(textChanged(QString const&)), this, SLOT(onContentChanged()));\r\n\r\n    setWindowTitle(tr(\"New Workspace\"));\r\n    setFixedSize(sizeHint());\r\n    onContentChanged();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: name()\r\n//----------------------------------------------------------------------------- \r\nQString NewWorkspaceDialog::name() const\r\n{\r\n    return nameEdit_->text();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: accept()\r\n//-----------------------------------------------------------------------------\r\nvoid NewWorkspaceDialog::accept()\r\n{\r\n    // Validate the name.\r\n    QSettings settings;\r\n    if (settings.contains(\"Workspaces/\" + nameEdit_->text() + \"/Geometry\"))\r\n    {\r\n        QMessageBox msgBox(QMessageBox::Warning, QCoreApplication::applicationName(),\r\n                           tr(\"Workspace '%1' already exists.\").arg(nameEdit_->text()),\r\n                           QMessageBox::Ok, this);\r\n        msgBox.exec();\r\n        return;\r\n    }\r\n\r\n    QDialog::accept();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: onContentChanged()\r\n//-----------------------------------------------------------------------------\r\nvoid NewWorkspaceDialog::onContentChanged()\r\n{\r\n    btnOk_->setEnabled(!nameEdit_->text().isEmpty());\r\n}\r\n"
  },
  {
    "path": "mainwindow/NewWorkspaceDialog.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: NewWorkspaceDialog.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Joni-Matti Maatta\r\n// Date: 24.1.2012\r\n//\r\n// Description:\r\n// Dialog for creating new workspaces.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef NEWWORKSPACEDIALOG_H\r\n#define NEWWORKSPACEDIALOG_H\r\n\r\n#include <QDialog>\r\n#include <QLineEdit>\r\n#include <QPushButton>\r\n\r\n//-----------------------------------------------------------------------------\r\n//! NewWorkspaceDialog class\r\n//-----------------------------------------------------------------------------\r\nclass NewWorkspaceDialog : public QDialog\r\n{\r\n    Q_OBJECT\r\n\r\npublic:\r\n    /*!\r\n     *  Constructor which initializes the dialog.\r\n     *\r\n     *    @param [in] parent   The parent widget.\r\n     */\r\n    NewWorkspaceDialog(QWidget* parent = 0);\r\n\r\n    /*!\r\n     *  Destructor.\r\n     */\r\n    ~NewWorkspaceDialog() = default;\r\n\r\n    /*!\r\n     *  Returns the contents of the name field.\r\n     */\r\n    QString name() const;\r\n\r\npublic slots:\r\n    void accept();\r\n\r\n    //! Called when the contents of the name field have changed.\r\n    void onContentChanged();\r\n\r\nprivate:\r\n    // Disable copying.\r\n    NewWorkspaceDialog(NewWorkspaceDialog const& rhs);\r\n    NewWorkspaceDialog& operator=(NewWorkspaceDialog const& rhs);\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! Line edit for the name of the new workspace.\r\n    QLineEdit* nameEdit_;\r\n\r\n    //! The OK button.\r\n    QPushButton* btnOk_;\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n\r\n#endif // NEWWORKSPACEDIALOG_H\r\n"
  },
  {
    "path": "mainwindow/Ribbon/Ribbon.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: Ribbon.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Joni-Matti Maatta\r\n// Date: 06.02.2013\r\n//\r\n// Description:\r\n// Ribbon toolbar.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"Ribbon.h\"\r\n#include \"RibbonTheme.h\"\r\n#include \"RibbonGroup.h\"\r\n\r\n#include <QPainter>\r\n#include <QResizeEvent>\r\n#include <QScrollBar>\r\n#include <QColor>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Ribbon::Ribbon()\r\n//-----------------------------------------------------------------------------\r\nRibbon::Ribbon(QWidget* parent /*= 0*/):\r\n\tQToolBar(parent)\r\n{\r\n    setObjectName(\"Ribbon\");\r\n\r\n\tsetFixedHeight(RIBBONHEIGHT);\r\n\r\n\tsetMovable(false);\r\n\tsetFloatable(false);\r\n\r\n    setContentsMargins(0, 0, 0, 0);\r\n\r\n    layout()->setSpacing(CONTAINER_SPACING);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Ribbon::addGroup()\r\n//-----------------------------------------------------------------------------\r\nQAction* Ribbon::addGroup(RibbonGroup* group)\r\n{\r\n\treturn addWidget(group);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: Ribbon::paintEvent()\r\n//-----------------------------------------------------------------------------\r\nvoid Ribbon::paintEvent(QPaintEvent* /*event*/)\r\n{\r\n    QPainter painter(this);\r\n    painter.setRenderHints(QPainter::Antialiasing);\r\n    painter.fillRect(rect(), RibbonTheme::GRADIENTBOTTOM);\r\n}\r\n\r\n"
  },
  {
    "path": "mainwindow/Ribbon/Ribbon.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: Ribbon.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Joni-Matti Maatta\r\n// Date: 06.02.2013\r\n//\r\n// Description:\r\n// Ribbon toolbar.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef RIBBON_H\r\n#define RIBBON_H\r\n\r\n#include <QWidget>\r\n#include <QColor>\r\n#include <QHBoxLayout>\r\n#include <QScrollArea>\r\n\r\n#include <QPushButton>\r\n#include <QToolBar>\r\n\r\nclass RibbonGroup;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Ribbon toolbar.\r\n//-----------------------------------------------------------------------------\r\nclass Ribbon : public QToolBar\r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n    /*!\r\n     *  Constructor.\r\n     *\r\n     *    @param [in] parent The parent widget.\r\n     */\r\n    Ribbon(QWidget* parent = 0);\r\n\r\n    /*!\r\n     *  Destructor.\r\n     */\r\n    virtual ~Ribbon() = default;\r\n\r\n    // Disable copying.\r\n    Ribbon(Ribbon const& rhs) = delete;\r\n    Ribbon& operator=(Ribbon const& rhs) = delete;\r\n\r\n    /*!\r\n     *  Adds a group to the ribbon.\r\n     *\r\n     *    @param [in] title The title for the group.\r\n     */\r\n    QAction* addGroup(RibbonGroup* group);\r\n\r\nprotected:\r\n    //! Draws the ribbon background.\r\n    virtual void paintEvent(QPaintEvent* event);\r\n\r\nprivate:\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n\r\n\t//! Spacing amount for the container.\r\n\tstatic const int CONTAINER_SPACING = 1;\r\n\r\n\t//! The height of the ribbon.\r\n    static const int RIBBONHEIGHT = 64;\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n\r\n#endif // RIBBON_H\r\n"
  },
  {
    "path": "mainwindow/Ribbon/RibbonGroup.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: RibbonGroup.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Joni-Matti Maatta\r\n// Date: 06.02.2013\r\n//\r\n// Description:\r\n// Ribbon group class.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"RibbonGroup.h\"\r\n#include \"Ribbon.h\"\r\n#include \"RibbonTheme.h\"\r\n\r\n#include <QPainter>\r\n#include <QToolButton>\r\n#include <QEvent>\r\n#include <QActionEvent>\r\n#include <QAction>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: RibbonGroup::RibbonGroup()\r\n//-----------------------------------------------------------------------------\r\nRibbonGroup::RibbonGroup(QString const& title, Ribbon* parent):\r\nQToolBar(parent),\r\ntitle_(title)\r\n{\r\n    const int BOTTOM_MARGIN = 10;\r\n\tconst int TOP_MARGIN = 10;\r\n\r\n\tsetIconSize(QSize(32, 32));\r\n    setContentsMargins(0, TOP_MARGIN, 0, BOTTOM_MARGIN);\r\n\tlayout()->setContentsMargins(0, TOP_MARGIN, 0, BOTTOM_MARGIN);\r\n\r\n\tQString style = \r\n\t\t\"QToolBar { margin-top: %1px; margin-left: %1px; margin-right: %1px; margin-bottom: %1px;}\";\r\n\tsetStyleSheet(style.arg(QString::number(HMARGIN)));\r\n\r\n\tQFontMetrics metrics(font());\r\n\tsetMinimumWidth(metrics.horizontalAdvance(title_) +  TITLE_MARGIN);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: RibbonGroup::paintEvent()\r\n//-----------------------------------------------------------------------------\r\nvoid RibbonGroup::paintEvent(QPaintEvent* /*event*/)\r\n{\r\n    QPainter painter(this);\r\n\r\n    painter.setRenderHints(QPainter::Antialiasing);\r\n    painter.fillRect(rect(), RibbonTheme::GRADIENTTOP);\r\n\r\n    // Draw a nice frame around the group area.\r\n\tpainter.setPen(QPen(RibbonTheme::GROUPTITLEGRADIENTTOP, 1));\r\n    painter.drawRect(rect());\r\n\r\n    // Draw the title background.\r\n    QRect titleRect = rect();\r\n    titleRect.setTop(rect().height() - TITLE_HEIGHT);\r\n\r\n    painter.fillRect(titleRect, RibbonTheme::GROUPTITLEGRADIENTBOTTOM);\r\n\r\n    // Draw the title text.\r\n    QTextOption opt;\r\n    opt.setAlignment(Qt::AlignCenter);\r\n\r\n\tpainter.setPen(QPen(RibbonTheme::GROUPTITLETEXT));\r\n    painter.drawText(titleRect, title_, opt);\r\n}\r\n"
  },
  {
    "path": "mainwindow/Ribbon/RibbonGroup.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: RibbonGroup.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Joni-Matti Maatta\r\n// Date: 06.02.2013\r\n//\r\n// Description:\r\n// Ribbon group class.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef RIBBONGROUP_H\r\n#define RIBBONGROUP_H\r\n\r\n#include <QWidget>\r\n#include <QMenu>\r\n#include <QToolBar>\r\n\r\nclass Ribbon;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Ribbon group class.\r\n//-----------------------------------------------------------------------------\r\nclass RibbonGroup : public QToolBar\r\n{\r\n    Q_OBJECT\r\n\r\npublic:\r\n    /*!\r\n     *  Constructor.\r\n     *\r\n     *    @param [in] title   The group title.\r\n     *    @param [in] parent  The parent ribbon.\r\n     */\r\n    RibbonGroup(QString const& title, Ribbon* parent);\r\n\r\n    /*!\r\n     *  Destructor.\r\n     */\r\n    virtual ~RibbonGroup() = default;\r\n\r\n    // Disable copying.\r\n    RibbonGroup(RibbonGroup const& rhs) = delete;\r\n    RibbonGroup& operator=(RibbonGroup const& rhs) = delete;\r\n\r\nprotected:\r\n    //! Draws the group.\r\n    virtual void paintEvent(QPaintEvent* event);\r\n\r\nprivate:\r\n\r\n    enum\r\n    {\r\n        TITLE_MARGIN = 10,\r\n        TITLE_HEIGHT = 21,\r\n        MIN_LARGE_BUTTON_WIDTH = 56,\r\n        HMARGIN = 1\r\n    };\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! The title text.\r\n    QString title_;\r\n\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n\r\n#endif // RIBBONGROUP_H\r\n"
  },
  {
    "path": "mainwindow/Ribbon/RibbonTheme.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: RibbonTheme.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 26.11.2014\r\n//\r\n// Description:\r\n// Namespace for the ribbon colorization.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef RIBBONTHEME_H\r\n#define RIBBONTHEME_H\r\n\r\n#include <QColor>\r\n\r\nnamespace RibbonTheme\r\n{\r\n    const QColor GRADIENTTOP(218, 225, 233);\r\n    const QColor GRADIENTBOTTOM(160, 193, 226);\r\n\tconst QColor GROUPTITLEGRADIENTTOP(33, 135, 237);\r\n\tconst QColor GROUPTITLEGRADIENTBOTTOM(17, 127, 237);\r\n\tconst QColor GROUPTITLETEXT = Qt::white;\r\n}\r\n\r\n#endif // RIBBONTHEME_H\r\n"
  },
  {
    "path": "mainwindow/SaveHierarchy/DocumentTreeBuilder.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: DocumentTreeBuilder.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Esko Pekkarinen\r\n// Date: 18.05.2015\r\n//\r\n// Description:\r\n// Creates an object tree from IP-XACT documents.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"DocumentTreeBuilder.h\"\r\n\r\n#include <KactusAPI/include/LibraryInterface.h>\r\n\r\n#include <IPXACTmodels/Component/Component.h>\r\n#include <IPXACTmodels/Design/Design.h>\r\n#include <IPXACTmodels/DesignConfiguration/DesignConfiguration.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DocumentTreeBuilder::DocumentTreeBuilder()\r\n//-----------------------------------------------------------------------------\r\nDocumentTreeBuilder::DocumentTreeBuilder(LibraryInterface* library):\r\nlibrary_(library)\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DocumentTreeBuilder::~DocumentTreeBuilder()\r\n//-----------------------------------------------------------------------------\r\nDocumentTreeBuilder::~DocumentTreeBuilder()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DocumentTreeBuilder::createFrom()\r\n//-----------------------------------------------------------------------------\r\nQObject* DocumentTreeBuilder::createFrom(VLNV const& root) const\r\n{\r\n    QObject* rootNode;\r\n\r\n    if (library_->contains(root))\r\n    {\r\n        if (library_->getDocumentType(root) == VLNV::COMPONENT)\r\n        { \r\n            rootNode = createFromComponent(root);\r\n        }\r\n        else if (library_->getDocumentType(root) == VLNV::DESIGN)\r\n        {\r\n            rootNode = createFromDesign(root);\r\n        }\r\n        else if (library_->getDocumentType(root) == VLNV::DESIGNCONFIGURATION)\r\n        {\r\n            rootNode = createFromDesignConfiguration(root);\r\n        }\r\n        else\r\n        {\r\n            rootNode = new QObject();\r\n            rootNode->setObjectName(root.toString());\r\n        }\r\n    }\r\n    else\r\n    {\r\n        rootNode = new QObject();\r\n        rootNode->setObjectName(root.toString());\r\n    }\r\n\r\n    return rootNode;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DocumentTreeBuilder::createFromComponent()\r\n//-----------------------------------------------------------------------------\r\nQObject* DocumentTreeBuilder::createFromComponent(VLNV const& root) const\r\n{\r\n    QObject* componentNode = new QObject();\r\n    componentNode->setObjectName(root.toString());\r\n    componentNode->setProperty(\"VLNVType\", \"Component\");\r\n\r\n    QSharedPointer<Document const> component = library_->getModelReadOnly(root);\r\n    QSharedPointer<Component const> rootComponent = component.dynamicCast<Component const>();\r\n\r\n    if (rootComponent->getImplementation() == KactusAttribute::SW)\r\n    {\r\n        componentNode->setProperty(\"implementation\", \"SW\");\r\n    }\r\n    else\r\n    {\r\n        componentNode->setProperty(\"implementation\", \"HW\");\r\n    }\r\n\r\n    QList<VLNV> hierarchyReferences = rootComponent->getHierRefs();\r\n    foreach (VLNV reference, hierarchyReferences)\r\n    {\r\n        if (library_->contains(reference))\r\n        {\r\n            if (library_->getDocumentType(reference) == VLNV::DESIGNCONFIGURATION)\r\n            {\r\n                QObject* designConfigNode = createFromDesignConfiguration(reference);\r\n                designConfigNode->setParent(componentNode);\r\n            }\r\n            else if (library_->getDocumentType(reference) == VLNV::DESIGN)\r\n            {\r\n                QObject* designNode = createFromDesign(reference);\r\n                designNode->setParent(componentNode);\r\n            }\r\n        }\r\n    }\r\n\r\n    return componentNode;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DocumentTreeBuilder::createFromDesignConfiguration()\r\n//-----------------------------------------------------------------------------\r\nQObject* DocumentTreeBuilder::createFromDesignConfiguration(VLNV const& designConfiguration) const\r\n{\r\n    QObject* designConfigNode = new QObject(0);\r\n    designConfigNode->setObjectName(designConfiguration.toString());\r\n    designConfigNode->setProperty(\"VLNVType\", \"DesignConfiguration\");\r\n\r\n    QSharedPointer<Document const> configModel = library_->getModelReadOnly(designConfiguration);\r\n    QSharedPointer<DesignConfiguration const> configuration = configModel.dynamicCast<DesignConfiguration const>();\r\n\r\n    VLNV designRef = configuration->getDesignRef();\r\n\r\n    if (library_->contains(designRef))\r\n    {\r\n        QObject* designNode = createFromDesign(designRef);\r\n        designNode->setParent(designConfigNode);\r\n    }\r\n\r\n    return designConfigNode;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DocumentTreeBuilder::createFromDesign()\r\n//-----------------------------------------------------------------------------\r\nQObject* DocumentTreeBuilder::createFromDesign(VLNV const& designRef) const\r\n{\r\n    QObject* designNode = new QObject(0);\r\n    designNode->setObjectName(designRef.toString());\r\n    designNode->setProperty(\"VLNVType\", \"Design\");\r\n\r\n    QSharedPointer<Document const> designModel = library_->getModelReadOnly(designRef);\r\n    QSharedPointer<Design const> design = designModel.dynamicCast<Design const>();\r\n\r\n    if (design->getDesignImplementation() == KactusAttribute::SW)\r\n    {\r\n        designNode->setProperty(\"implementation\", \"SW\");\r\n    }\r\n    else if (design->getDesignImplementation() == KactusAttribute::SYSTEM)\r\n    {\r\n        designNode->setProperty(\"implementation\", \"System\");\r\n    }\r\n    else\r\n    {\r\n        designNode->setProperty(\"implementation\", \"HW\");\r\n    }\r\n\r\n    foreach (QSharedPointer<ComponentInstance> hwInstance, *design->getComponentInstances())\r\n    {\r\n        QObject* instanceNode = createFrom(*hwInstance->getComponentRef());\r\n        instanceNode->setParent(designNode);\r\n\r\n        instanceNode->setProperty(\"instanceName\", hwInstance->getInstanceName());\r\n    }\r\n\r\n    return designNode;\r\n}\r\n"
  },
  {
    "path": "mainwindow/SaveHierarchy/DocumentTreeBuilder.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: DocumentTreeBuilder.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Esko Pekkarinen\r\n// Date: 18.05.2015\r\n//\r\n// Description:\r\n// Creates an object tree from IP-XACT documents.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef DOCUMNENTREEBUILDER_H\r\n#define DOCUMNENTREEBUILDER_H\r\n\r\n#include <IPXACTmodels/common/VLNV.h>\r\n\r\n#include <QList>\r\n\r\nclass DesignConfiguration;\r\nclass LibraryInterface;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Creates an object tree from IP-XACT documents.\r\n//-----------------------------------------------------------------------------\r\nclass DocumentTreeBuilder \r\n{\r\npublic:\r\n\r\n\t/*!\r\n\t *  The constructor.\r\n\t *\r\n\t *    @param [in] library   The current IP-XACT library.\r\n\t */\r\n\tDocumentTreeBuilder(LibraryInterface* library);\r\n\r\n\t//! The destructor.\r\n\t~DocumentTreeBuilder();\r\n\r\n    /*!\r\n     *  Creates an object tree starting at the given document.\r\n     *\r\n     *    @param [in] root   The VLNV of the root document.\r\n     *\r\n     *    @return The object tree representing the document tree.\r\n     */\r\n    QObject* createFrom(VLNV const& root) const;\r\n\r\nprivate:\r\n\r\n\t// Disable copying.\r\n\tDocumentTreeBuilder(DocumentTreeBuilder const& rhs);\r\n\tDocumentTreeBuilder& operator=(DocumentTreeBuilder const& rhs);\r\n    \r\n    /*!\r\n     *  Creates an object tree starting at the given component.\r\n     *\r\n     *    @param [in] root   The VLNV of the component document.\r\n     *\r\n     *    @return The object tree representing the document tree starting at the component.\r\n     */\r\n    QObject* createFromComponent(VLNV const &root) const;\r\n        \r\n    /*!\r\n     *  Creates an object tree starting at the given design configuration.\r\n     *\r\n     *    @param [in] designConfiguration     The VLNV of the design configuration document.\r\n     *\r\n     *    @return The object tree representing the document tree starting at the design configuration.\r\n     */\r\n    QObject* createFromDesignConfiguration(VLNV const& designConfiguration) const;\r\n        \r\n    /*!\r\n     *  Creates an object tree starting at the given design.\r\n     *\r\n     *    @param [in] designRef       The VLNV of the design document.\r\n     *\r\n     *    @return The object tree representing the document tree starting at the design.\r\n     */\r\n    QObject* createFromDesign(VLNV const& designRef) const;\r\n\r\n    //! The IP-XACT library in use.\r\n    LibraryInterface* library_;\r\n};\r\n\r\n#endif // DOCUMNENTREEBUILDER_H\r\n"
  },
  {
    "path": "mainwindow/SaveHierarchy/HierarchicalSaveBuildStrategy.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: HierarchicalSaveBuildStrategy.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Esko Pekkarinen\r\n// Date: 20.05.2015\r\n//\r\n// Description:\r\n// Builds a tree model for saving documents hierarchically.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"HierarchicalSaveBuildStrategy.h\"\r\n\r\n#include \"HierarchicalSaveColumns.h\"\r\n\r\n#include \"SaveAsItem.h\"\r\n\r\n#include <KactusAPI/include/LibraryInterface.h>\r\n\r\n#include <IPXACTmodels/Design/Design.h>\r\n\r\n#include <IPXACTmodels/DesignConfiguration/DesignConfiguration.h>\r\n\r\n#include <IPXACTmodels/Component/Component.h>\r\n\r\n#include <IPXACTmodels/kactusExtensions/SystemView.h>\r\n\r\n#include <QFileInfo>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HierarchicalSaveBuildStrategy::HierarchicalSaveBuildStrategy()\r\n//-----------------------------------------------------------------------------\r\nHierarchicalSaveBuildStrategy::HierarchicalSaveBuildStrategy(LibraryInterface* library, QObject* parent): \r\nQObject(parent), library_(library), saveMode_(CURRENT_DIRECTORY), savePath_()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HierarchicalSaveBuildStrategy::~HierarchicalSaveBuildStrategy()\r\n//-----------------------------------------------------------------------------\r\nHierarchicalSaveBuildStrategy::~HierarchicalSaveBuildStrategy()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HierarchicalSaveBuildStrategy::build()\r\n//-----------------------------------------------------------------------------\r\nQTreeWidgetItem* HierarchicalSaveBuildStrategy::build(QObject* rootObject) const\r\n{\r\n    if (rootObject && rootObject->property(\"VLNVType\") != \"DesignConfiguration\")\r\n    {\r\n        return createItemAndItsChildren(rootObject);\r\n    }\r\n    else\r\n    {\r\n        return new QTreeWidgetItem();\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SaveHierarchyDialog::saveItem()\r\n//-----------------------------------------------------------------------------\r\nvoid HierarchicalSaveBuildStrategy::saveItem(QTreeWidgetItem* item) const\r\n{\r\n    if (shouldSaveItem(item))\r\n    {\r\n        VLNV oldVLNV = VLNV(VLNV::COMPONENT, item->text(HierarchicalSaveColumns::VLNV));\r\n        oldVLNV.setType(library_->getDocumentType(oldVLNV));\r\n\r\n        VLNV newVLNV = VLNV(oldVLNV.getType(), item->text(HierarchicalSaveColumns::SAVE_AS_VLNV));\r\n\r\n        if (library_->contains(oldVLNV))\r\n        {\r\n            QSharedPointer<Document> newModel = library_->getModel(oldVLNV);\r\n            newModel->setVlnv(newVLNV);\r\n\r\n            int childCount = item->childCount();\r\n            for (int i = 0; i < childCount; i++)\r\n            {\r\n                QTreeWidgetItem* childItem = item->child(i);\r\n\r\n                if (shouldSaveItem(childItem))\r\n                {\r\n                    updateReferencesFromTo(newModel, childItem);\r\n                    saveItem(childItem);\r\n                }\r\n            }\r\n\r\n            saveToLibrary(oldVLNV, newModel);\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HierarchicalSaveBuildStrategy::setSaveMode()\r\n//-----------------------------------------------------------------------------\r\nvoid HierarchicalSaveBuildStrategy::setSaveMode(SaveMode mode)\r\n{\r\n    saveMode_ = mode;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HierarchicalSaveBuildStrategy::setSavePath()\r\n//-----------------------------------------------------------------------------\r\nvoid HierarchicalSaveBuildStrategy::setSavePath(QString const& path)\r\n{\r\n    savePath_ = path;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HierarchicalSaveBuildStrategy::createItemAndItsChildren()\r\n//-----------------------------------------------------------------------------\r\nQTreeWidgetItem* HierarchicalSaveBuildStrategy::createItemAndItsChildren(QObject* rootObject) const\r\n{\r\n    QTreeWidgetItem* rootItem = createItem(rootObject);\r\n\r\n    createChildItems(rootObject, rootItem);\r\n\r\n    return rootItem;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HierarchicalSaveBuildStrategy::createItem()\r\n//-----------------------------------------------------------------------------\r\nQTreeWidgetItem* HierarchicalSaveBuildStrategy::createItem(QObject* object) const\r\n{\r\n    QTreeWidgetItem* item = new SaveAsItem(0);\r\n\r\n    QString vlnvString = object->objectName();\r\n    QRegularExpression vlnvExpression(\"^(.+?):(.+?):(.+?):(.+?)$\");\r\n\r\n    QRegularExpressionMatch vlnvMatch = vlnvExpression.match(vlnvString);\r\n\r\n    if (!vlnvMatch.hasMatch())\r\n    {\r\n        setInvalid(item);\r\n    }\r\n    else\r\n    {\r\n        item->setText(HierarchicalSaveColumns::VLNV, vlnvString);\r\n        setIcon(object, item);\r\n\r\n        QString suggestedVLNV = generateUnusedVLNV(vlnvMatch.captured());\r\n        item->setText(HierarchicalSaveColumns::SAVE_AS_VLNV, suggestedVLNV);\r\n    }\r\n\r\n    item->setCheckState(HierarchicalSaveColumns::SAVE_AS_VLNV, Qt::Checked);\r\n    item->setFlags(item->flags() | Qt::ItemIsEditable);\r\n\r\n    return item;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HierarchicalSaveBuildStrategy::setInvalid()\r\n//-----------------------------------------------------------------------------\r\nvoid HierarchicalSaveBuildStrategy::setInvalid(QTreeWidgetItem* item) const\r\n{\r\n    item->setText(HierarchicalSaveColumns::VLNV, QObject::tr(\"Item not found\"));\r\n    item->setIcon(HierarchicalSaveColumns::VLNV, QIcon(\":/icons/common/graphics/exclamation.png\"));\r\n    item->setText(HierarchicalSaveColumns::SAVE_AS_VLNV, \":::\");\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HierarchicalSaveBuildStrategy::setIcon()\r\n//-----------------------------------------------------------------------------\r\nvoid HierarchicalSaveBuildStrategy::setIcon(QObject* object, QTreeWidgetItem* item) const\r\n{\r\n    if (object->property(\"VLNVType\") == \"Component\")\r\n    {\r\n        if (object->property(\"implementation\") == \"HW\")\r\n        {\r\n            item->setIcon(HierarchicalSaveColumns::VLNV, QIcon(\":/icons/common/graphics/hw-component.png\"));\r\n        }\r\n        else\r\n        {\r\n            item->setIcon(HierarchicalSaveColumns::VLNV, QIcon(\":/icons/common/graphics/sw-component48x48.png\"));\r\n        }\r\n    }\r\n    else\r\n    {\r\n        if (object->property(\"implementation\") == \"HW\" || object->property(\"implementation\") == \"System\")\r\n        {\r\n            item->setIcon(HierarchicalSaveColumns::VLNV, QIcon(\":/icons/common/graphics/hw-design.png\"));\r\n        }\r\n        else\r\n        {\r\n            item->setIcon(HierarchicalSaveColumns::VLNV, QIcon(\":/icons/common/graphics/sw-design48x48.png\"));\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HierarchicalSaveBuildStrategy::generateUnusedVLNV()\r\n//-----------------------------------------------------------------------------\r\nQString HierarchicalSaveBuildStrategy::generateUnusedVLNV(QString const& previousVLNV) const\r\n{\r\n    QString newVlnv = previousVLNV;\r\n\r\n    QRegularExpression trailingNumber(\"\\\\d+$\");\r\n    QRegularExpressionMatch numberMatch = trailingNumber.match(previousVLNV);\r\n\r\n    if (!numberMatch.hasMatch())\r\n    {\r\n        newVlnv.append(\"_1\");\r\n        numberMatch = trailingNumber.match(newVlnv);\r\n    }\r\n\r\n    while (numberMatch.hasMatch() && library_->contains(VLNV(VLNV::COMPONENT, newVlnv)))\r\n    {\r\n        QString nextNumber = QString::number(numberMatch.captured().toInt() + 1);\r\n        newVlnv.replace(newVlnv.length() - numberMatch.capturedLength(), numberMatch.capturedLength(), nextNumber);\r\n\r\n        numberMatch = trailingNumber.match(newVlnv);\r\n    }\r\n\r\n    return newVlnv;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HierarchicalSaveBuildStrategy::createChildItems()\r\n//-----------------------------------------------------------------------------\r\nvoid HierarchicalSaveBuildStrategy::createChildItems(QObject* object, QTreeWidgetItem* treeItem) const\r\n{\r\n    foreach (QObject* child, object->children())\r\n    {\r\n        if (child->property(\"VLNVType\") == \"DesignConfiguration\")\r\n        {\r\n            foreach (QObject* designNode, child->children())\r\n            {\r\n                QTreeWidgetItem* childItem = build(designNode);\r\n                treeItem->addChild(childItem);\r\n            }\r\n        }\r\n        else if (hasNoChildWithVLNV(treeItem, child->objectName()))\r\n        {\r\n            QTreeWidgetItem* childItem = build(child);\r\n            treeItem->addChild(childItem);\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HierarchicalSaveBuildStrategy::hasNoChildWithVLNV()\r\n//-----------------------------------------------------------------------------\r\nbool HierarchicalSaveBuildStrategy::hasNoChildWithVLNV(QTreeWidgetItem* item, QString const& vlnv) const\r\n{\r\n    int childCount = item->childCount();\r\n    for (int i = 0; i < childCount; i++)\r\n    {\r\n        if (item->child(i)->text(HierarchicalSaveColumns::VLNV) == vlnv)\r\n        {\r\n            return false;\r\n        }\r\n    }\r\n\r\n    return true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HierarchicalSaveBuildStrategy::shouldSaveItem()\r\n//-----------------------------------------------------------------------------\r\nbool HierarchicalSaveBuildStrategy::shouldSaveItem(QTreeWidgetItem* item) const\r\n{\r\n    return item && item->checkState(HierarchicalSaveColumns::SAVE_AS_VLNV) == Qt::Checked;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HierarchicalSaveBuildStrategy::updateReferencesTo()\r\n//-----------------------------------------------------------------------------\r\nvoid HierarchicalSaveBuildStrategy::updateReferencesFromTo(QSharedPointer<Document> model, \r\n    QTreeWidgetItem* childItem) const\r\n{\r\n    VLNV childVLNV = VLNV(VLNV::COMPONENT, childItem->text(HierarchicalSaveColumns::VLNV));\r\n    childVLNV.setType(library_->getDocumentType(childVLNV));\r\n\r\n    VLNV newChildVLNV = VLNV(childVLNV.getType(), childItem->text(HierarchicalSaveColumns::SAVE_AS_VLNV));\r\n\r\n    if (model->getVlnv().getType() == VLNV::COMPONENT)\r\n    {\r\n        updateComponentReferences(model.dynamicCast<Component>(), childVLNV, newChildVLNV);\r\n    }\r\n    else if (model->getVlnv().getType() == VLNV::DESIGN)\r\n    {\r\n        updateDesignReferences(model.dynamicCast<Design>(), childVLNV, newChildVLNV);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SaveHierarchyDialog::updateComponentReferences()\r\n//-----------------------------------------------------------------------------\r\nvoid HierarchicalSaveBuildStrategy::updateComponentReferences(QSharedPointer<Component> component, \r\n    VLNV const& reference, VLNV const& updatedReference) const\r\n{\r\n    foreach (QSharedPointer<View> view, *component->getViews())\r\n    {\r\n        if (view->isHierarchical())\r\n        {\r\n            VLNV hierarchyReference;\r\n\r\n            QString designConfigurationName = view->getDesignConfigurationInstantiationRef();\r\n            foreach(QSharedPointer<DesignConfigurationInstantiation> instantiation, \r\n                *component->getDesignConfigurationInstantiations())\r\n            {\r\n                if (instantiation->name() == designConfigurationName)\r\n                {\r\n                    hierarchyReference = *instantiation->getDesignConfigurationReference();\r\n\r\n                    QSharedPointer<Document> configModel = library_->getModel(hierarchyReference);\r\n                    QSharedPointer<DesignConfiguration> config = configModel.dynamicCast<DesignConfiguration>(); \r\n\r\n                    VLNV configVLNV(VLNV::DESIGNCONFIGURATION, updatedReference.toString());\r\n                    configVLNV.setName(configVLNV.getName() + \"cfg\");\r\n\r\n                    config->setVlnv(configVLNV);\r\n                    config->setDesignRef(updatedReference);\r\n\r\n                    instantiation->getDesignConfigurationReference()->setVendor(configVLNV.getVendor());\r\n                    instantiation->getDesignConfigurationReference()->setLibrary(configVLNV.getLibrary());\r\n                    instantiation->getDesignConfigurationReference()->setName(configVLNV.getName());\r\n                    instantiation->getDesignConfigurationReference()->setVersion(configVLNV.getVersion());\r\n\r\n                    saveToLibrary(hierarchyReference, config);\r\n\r\n                    break;\r\n                }\r\n            }\r\n\r\n            QString designName = view->getDesignInstantiationRef();\r\n            foreach(QSharedPointer<DesignInstantiation> instantiation, *component->getDesignInstantiations())\r\n            {\r\n                if (instantiation->name() == designName)\r\n                {\r\n                    instantiation->getDesignReference()->setVendor(updatedReference.getVendor());\r\n                    instantiation->getDesignReference()->setLibrary(updatedReference.getLibrary());\r\n                    instantiation->getDesignReference()->setName(updatedReference.getName());\r\n                    instantiation->getDesignReference()->setVersion(updatedReference.getVersion());\r\n                    break;\r\n                }\r\n            }\r\n        }\r\n    }\r\n\r\n    foreach (QSharedPointer<SystemView> view, component->getSystemViews())\r\n    {\r\n        QSharedPointer<Document> configModel = library_->getModel(view->getHierarchyRef());\r\n        QSharedPointer<DesignConfiguration> config = configModel.dynamicCast<DesignConfiguration>(); \r\n\r\n        if (view->getHierarchyRef() == reference)\r\n        {\r\n            view->setHierarchyRef(updatedReference);\r\n        }\r\n        else if (config && config->getDesignRef() == reference)\r\n        {\r\n            VLNV configVLNV(VLNV::DESIGNCONFIGURATION, updatedReference.toString());\r\n            configVLNV.setName(configVLNV.getName() + \"cfg\");\r\n\r\n            config->setVlnv(configVLNV);\r\n            config->setDesignRef(updatedReference);\r\n\r\n            view->setHierarchyRef(configVLNV);\r\n\r\n            saveToLibrary(view->getHierarchyRef(), config);\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SaveHierarchyDialog::updateDesignReferences()\r\n//-----------------------------------------------------------------------------\r\nvoid HierarchicalSaveBuildStrategy::updateDesignReferences(QSharedPointer<Design> design,\r\n    VLNV childVLNV, VLNV newChildVLNV) const\r\n{\r\n    foreach (QSharedPointer<ComponentInstance> instance, *design->getComponentInstances())\r\n    {\r\n        if (*instance->getComponentRef() == childVLNV)\r\n        {\r\n            instance->setComponentRef(QSharedPointer<ConfigurableVLNVReference>(new ConfigurableVLNVReference(newChildVLNV)));\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SaveHierarchyDialog::saveToLibrary()\r\n//-----------------------------------------------------------------------------\r\nvoid HierarchicalSaveBuildStrategy::saveToLibrary(VLNV const& previousReference,\r\n    QSharedPointer<Document> model) const\r\n{\r\n    if (!library_->contains(model->getVlnv()))\r\n    {\r\n        QString path;\r\n        if (saveMode_ == CURRENT_DIRECTORY)\r\n        {\r\n            QFileInfo fileinfo(library_->getPath(previousReference));\r\n            path = fileinfo.absolutePath();\r\n        }\r\n        else if (saveMode_ == SINGLE_DIRECTORY)\r\n        {\r\n            path = savePath_;\r\n        }\r\n        else //if (saveMode_ == COMMON_ROOT_DIRECTORY)\r\n        {\r\n            path = savePath_ + \"/\" + model->getVlnv().toString(\"/\");\r\n        }\r\n\r\n        library_->writeModelToFile(path, model);\r\n    }\r\n\r\n    emit itemSaved();\r\n}\r\n"
  },
  {
    "path": "mainwindow/SaveHierarchy/HierarchicalSaveBuildStrategy.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: HierarchicalSaveBuildStrategy.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Esko Pekkarinen\r\n// Date: 20.05.2015\r\n//\r\n// Description:\r\n// Builds a tree model for saving documents hierarchically.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef HIERARCHICALSAVEBUILDSTRATEGY_H\r\n#define HIERARCHICALSAVEBUILDSTRATEGY_H\r\n\r\n#include <QTreeWidgetItem>\r\n\r\n#include <QObject>\r\n\r\nclass LibraryInterface;\r\n\r\nclass Component;\r\nclass Design;\r\nclass Document;\r\nclass LibraryInterface;\r\nclass LibrarySelectorWidget;\r\nclass VLNV;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Builds a tree model for saving documents hierarchically.\r\n//-----------------------------------------------------------------------------\r\nclass HierarchicalSaveBuildStrategy : public QObject\r\n{\r\n    Q_OBJECT\r\npublic:\r\n\r\n    enum SaveMode\r\n    {\r\n        CURRENT_DIRECTORY = 0,\r\n        COMMON_ROOT_DIRECTORY,\r\n        SINGLE_DIRECTORY\r\n    };\r\n\r\n\t/*!\r\n\t *  The constructor.\r\n\t *\r\n\t *    @param [in] library   The document library in use.\r\n\t */\r\n\tHierarchicalSaveBuildStrategy(LibraryInterface* library, QObject* parent = 0);\r\n\r\n\t//! The destructor.\r\n\t~HierarchicalSaveBuildStrategy();\r\n\r\n    /*!\r\n     *  Creates a tree model from the given object tree.\r\n     *\r\n     *    @param [in] rootObject   The root object.\r\n     *\r\n     *    @return Root item of the document tree.\r\n     */\r\n    QTreeWidgetItem* build(QObject* rootObject) const;\r\n\r\n    /*!\r\n     *  Saves the documents in the tree and updates all references.\r\n     *\r\n     *    @param [in] item   The root item to start the save from.\r\n     */\r\n    void saveItem(QTreeWidgetItem* item) const;\r\n\r\n    /*!\r\n     *  Sets the saving mode specifying the save location.\r\n     *\r\n     *    @param [in] mode   The selected mode.\r\n     */\r\n    void setSaveMode(HierarchicalSaveBuildStrategy::SaveMode mode);\r\n\r\n    /*!\r\n     *  Sets the save path.\r\n     *\r\n     *    @param [in] path   The path to set.\r\n     */\r\n    void setSavePath(QString const& path);\r\n\r\nsignals:\r\n\r\n    //! Emitted when an item has been saved in the library.\r\n    void itemSaved() const;\r\n\r\nprivate:\r\n\r\n\t// Disable copying.\r\n\tHierarchicalSaveBuildStrategy(HierarchicalSaveBuildStrategy const& rhs);\r\n\tHierarchicalSaveBuildStrategy& operator=(HierarchicalSaveBuildStrategy const& rhs);\r\n   \r\n    /*!\r\n     *  Creates an item and its children.\r\n     *\r\n     *    @param [in] rootObject   The object in the document tree to represent in the item.\r\n     *\r\n     *    @return The created tree item.\r\n     */\r\n    QTreeWidgetItem* createItemAndItsChildren(QObject* rootObject) const;\r\n\r\n    /*!\r\n     *  Creates an item.\r\n     *\r\n     *    @param [in] object   The object in the document tree to represent in the item.\r\n     *\r\n     *    @return The created tree item.\r\n     */\r\n    QTreeWidgetItem* createItem(QObject* object) const;\r\n\r\n    /*!\r\n     *  Sets an item to be invalid.\r\n     *\r\n     *    @param [in] item   The item to set invalid.\r\n     */\r\n    void setInvalid(QTreeWidgetItem* item) const;\r\n\r\n    /*!\r\n     *  Sets the appropriate icon for the item.\r\n     *\r\n     *    @param [in] object      The object in the document tree representing the item.\r\n     *    @param [in] item        The item whose icon to set.\r\n     */\r\n    void setIcon(QObject* object, QTreeWidgetItem* item) const;\r\n\r\n    /*!\r\n     *  Generates an unused VLVN.\r\n     *\r\n     *    @param [in] previousVLNV   The base VLNV for generation.\r\n     *\r\n     *    @return The generated unique VLNV.\r\n     */\r\n    QString generateUnusedVLNV(QString const& previousVLNV) const;\r\n\r\n    /*!\r\n     *  Creates child items for an item.\r\n     *\r\n     *    @param [in] object       The object in the document tree representing the item.\r\n     *    @param [in] treeItem     The item whose children to create.\r\n     */\r\n    void createChildItems(QObject* object, QTreeWidgetItem* treeItem) const;\r\n\r\n    /*!\r\n     *  Checks if an item has no children with the given VLNV.\r\n     *\r\n     *    @param [in] item   The item to check.\r\n     *    @param [in] vlnv   The VLNV to search for.\r\n     *\r\n     *    @return True, if no child has the given VLNV, otherwise false.\r\n     */\r\n    bool hasNoChildWithVLNV(QTreeWidgetItem* item, QString const& vlnv) const;\r\n\r\n    /*!\r\n     *  Checks if the given item should be saved.\r\n     *\r\n     *    @param [in] item   The item to check.\r\n     *\r\n     *    @return True, if the item is to be saved, otherwise false.\r\n     */\r\n    bool shouldSaveItem(QTreeWidgetItem* item) const;\r\n\r\n    /*!\r\n     *  Updates all references from the given document to the given child item.\r\n     *\r\n     *    @param [in] model       The document model to update.\r\n     *    @param [in] childItem   The child item to update the references to.\r\n     */\r\n    void updateReferencesFromTo(QSharedPointer<Document> model, QTreeWidgetItem* childItem) const;\r\n\r\n    /*!\r\n     *  Updates all references in a component to another.\r\n     *\r\n     *    @param [in] component           The component whose references to update.\r\n     *    @param [in] reference           The reference to update.\r\n     *    @param [in] updatedReference    The new reference.\r\n     */\r\n    void updateComponentReferences(QSharedPointer<Component> component, VLNV const& reference, VLNV const& updatedReference) const;\r\n\r\n    /*!\r\n     *  Updates all references in a design to another.\r\n     *\r\n     *    @param [in] design              The design whose references to update.\r\n     *    @param [in] childVLNV           The reference to update.\r\n     *    @param [in] newChildVLNV        The new reference.\r\n     */\r\n    void updateDesignReferences(QSharedPointer<Design> design, VLNV childVLNV, VLNV newChildVLNV) const;\r\n\r\n    /*!\r\n     *  Saves a document model to the library.\r\n     *\r\n     *    @param [in] previousReference   The earlier VLNV of the document model.\r\n     *    @param [in] model               The document model to save.\r\n     */\r\n    void saveToLibrary(VLNV const& previousReference, QSharedPointer<Document> model) const;\r\n \r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! The used document library.\r\n    LibraryInterface* library_;\r\n\r\n    //! The selected save mode.\r\n    SaveMode saveMode_;\r\n\r\n    //! The selected path to save to.\r\n    QString savePath_;\r\n};\r\n\r\n#endif // HIERARCHICALSAVEBUILDSTRATEGY_H\r\n"
  },
  {
    "path": "mainwindow/SaveHierarchy/HierarchicalSaveColumns.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: HierarchicalSaveColumns.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Esko Pekkarinen\r\n// Date: 20.05.2015\r\n//\r\n// Description:\r\n// Common definitions for hierarchical save model.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef HIERARCHICAL_SAVE_COLUMNS_H\r\n#define HIERARCHICAL_SAVE_COLUMNS_H\r\n\r\nnamespace HierarchicalSaveColumns\r\n{\r\n    //! Defines the columns for the hierarchical save tree.\r\n    enum Column\r\n    {\r\n        \r\n        VLNV = 0,\r\n        SAVE_AS_VLNV,\r\n        SAVE,\r\n        COLUMN_COUNT\r\n    };\r\n}\r\n\r\n#endif //HIERARCHICAL_SAVE_COLUMNS_H"
  },
  {
    "path": "mainwindow/SaveHierarchy/SaveAsItem.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: SaveAsItem.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Esko Pekkarinen\r\n// Date: 27.05.2015\r\n//\r\n// Description:\r\n// Tree item for representing a hierarchical save row.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"SaveAsItem.h\"\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SaveAsItem::SaveAsItem()\r\n//-----------------------------------------------------------------------------\r\nSaveAsItem::SaveAsItem(QTreeWidgetItem *parent): QTreeWidgetItem(parent)\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SaveAsItem::~SaveAsItem()\r\n//-----------------------------------------------------------------------------\r\nSaveAsItem::~SaveAsItem()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SaveAsItem::setData()\r\n//-----------------------------------------------------------------------------\r\nvoid SaveAsItem::setData(int column, int role, QVariant const& value)\r\n{\r\n    if (column == 1 && role == Qt::CheckStateRole)\r\n    {\r\n        bool unchecked = (value.toBool() == false);\r\n\r\n        if (unchecked || !parent() || parent()->checkState(column) == Qt::Checked) \r\n        {\r\n            QTreeWidgetItem::setData(column, role, value);\r\n        }\r\n\r\n        for (int i = 0; i < childCount(); i++)\r\n        {\r\n            child(i)->setData(column, role, value);\r\n            child(i)->setDisabled(unchecked);\r\n        }\r\n    }\r\n    else\r\n    {\r\n        QTreeWidgetItem::setData(column, role, value);\r\n    }\r\n}\r\n"
  },
  {
    "path": "mainwindow/SaveHierarchy/SaveAsItem.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: SaveAsItem.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Esko Pekkarinen\r\n// Date: 27.05.2015\r\n//\r\n// Description:\r\n// Tree item for representing a hierarchical save row.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef SAVEASITEM_H\r\n#define SAVEASITEM_H\r\n\r\n#include <QTreeWidgetItem>\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Tree item for representing a hierarchical save row.\r\n//-----------------------------------------------------------------------------\r\nclass SaveAsItem : public QTreeWidgetItem\r\n{\r\npublic:\r\n\r\n    /*!\r\n     *  The constructor.\r\n     *\r\n     *    @param [in] parent   The parent item.\r\n     */\r\n    SaveAsItem(QTreeWidgetItem* parent);\r\n    \r\n    //! The destructor.\r\n    virtual ~SaveAsItem();\r\n\r\n    /*!\r\n     *  Sets the data in the item.\r\n     *\r\n     *    @param [in] column      The column whose data to set.\r\n     *    @param [in] role        The data role to set.\r\n     *    @param [in] value       The value to set.\r\n     */\r\n    virtual void setData(int column, int role, QVariant const& value);\r\n\r\nprivate:\r\n\r\n    // Disable copying.\r\n    SaveAsItem(SaveAsItem const& rhs);\r\n    SaveAsItem& operator=(SaveAsItem const& rhs);\r\n};\r\n\r\n#endif // SAVEASITEM_H\r\n"
  },
  {
    "path": "mainwindow/SaveHierarchy/SaveHierarchyDelegate.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: SaveHierarchyDelegate.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Esko Pekkarinen\r\n// Date: 22.05.2015\r\n//\r\n// Description:\r\n// Delegate class for save hierarchy document selection.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"SaveHierarchyDelegate.h\"\r\n#include \"HierarchicalSaveColumns.h\"\r\n\r\n#include <KactusAPI/include/LibraryInterface.h>\r\n\r\n#include <common/widgets/vlnvEditor/vlnveditor.h>\r\n#include <common/KactusColors.h>\r\n\r\n#include <QPainter>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SaveHierarchyDelegate::SaveHierarchyDelegate()\r\n//-----------------------------------------------------------------------------\r\nSaveHierarchyDelegate::SaveHierarchyDelegate(LibraryInterface* library, QObject* parent): \r\nQStyledItemDelegate(parent), library_(library)\r\n{\r\n    \r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SaveHierarchyDelegate::~SaveHierarchyDelegate()\r\n//-----------------------------------------------------------------------------\r\nSaveHierarchyDelegate::~SaveHierarchyDelegate()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SaveHierarchyDelegate::createEditor()\r\n//-----------------------------------------------------------------------------\r\nQWidget* SaveHierarchyDelegate::createEditor(QWidget* parent, QStyleOptionViewItem const& /*option*/, \r\n    QModelIndex const& index) const\r\n{\r\n    if (index.column() == HierarchicalSaveColumns::SAVE_AS_VLNV)\r\n    {\r\n        VLNV originalVLNV(VLNV::COMPONENT, index.sibling(index.row(), \r\n            HierarchicalSaveColumns::VLNV).data().toString());\r\n        VLNV::IPXactType type = library_->getDocumentType(originalVLNV);\r\n\r\n        VLNVEditor* editor = new VLNVEditor(type, library_, parent->window(), parent);\r\n        editor->setTitle(tr(\"Enter new VLNV\"));\r\n        editor->setFlat(false);\r\n\r\n        editor->setFixedHeight(editor->sizeHint().height());\r\n        editor->setAutoFillBackground(true);\r\n\r\n        QPalette palette = editor->palette();\r\n        palette.setColor(editor->backgroundRole(), QColor(\"whiteSmoke\"));\r\n        editor->setPalette(palette);\r\n\r\n        return editor;\r\n    }\r\n    else\r\n    {\r\n        return 0;\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SaveHierarchyDelegate::setEditorData()\r\n//-----------------------------------------------------------------------------\r\nvoid SaveHierarchyDelegate::setEditorData(QWidget* editor, QModelIndex const& index) const\r\n{\r\n    if (index.column() != HierarchicalSaveColumns::SAVE_AS_VLNV)\r\n    {\r\n        return;\r\n    }\r\n    else\r\n    {\r\n        VLNVEditor* vlnvEditor = dynamic_cast<VLNVEditor*>(editor);\r\n        VLNV targetVlnv(VLNV::COMPONENT, index.data().toString());\r\n        VLNV::IPXactType type = library_->getDocumentType(targetVlnv);\r\n        targetVlnv.setType(type);\r\n        vlnvEditor->setVLNV(targetVlnv);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SaveHierarchyDelegate::setModelData()\r\n//-----------------------------------------------------------------------------\r\nvoid SaveHierarchyDelegate::setModelData(QWidget* editor, QAbstractItemModel* model, QModelIndex const& index) const\r\n{\r\n    if (index.column() != HierarchicalSaveColumns::SAVE_AS_VLNV)\r\n    {\r\n        return;\r\n    }\r\n    else\r\n    {\r\n        VLNVEditor* vlnvEditor = dynamic_cast<VLNVEditor*>(editor);        \r\n\r\n        model->setData(index, vlnvEditor->getVLNV().toString());\r\n\r\n        if (!vlnvEditor->getVLNV().isValid() || library_->contains(vlnvEditor->getVLNV()))\r\n        {\r\n            model->setData(index, KactusColors::ERROR, Qt::ForegroundRole);\r\n        }\r\n        else\r\n        {\r\n            model->setData(index, KactusColors::REGULAR_TEXT, Qt::ForegroundRole);\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SaveHierarchyDelegate::sizeHint()\r\n//-----------------------------------------------------------------------------\r\nQSize SaveHierarchyDelegate::sizeHint(QStyleOptionViewItem const& option, QModelIndex const& index) const\r\n{\r\n    return QStyledItemDelegate::sizeHint(option, index) + QSize(0, 5);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SaveHierarchyDelegate::paint()\r\n//-----------------------------------------------------------------------------\r\nvoid SaveHierarchyDelegate::paint(QPainter* painter, QStyleOptionViewItem const& option, \r\n    QModelIndex const& index) const\r\n{\r\n    QStyledItemDelegate::paint(painter, option, index);\r\n\r\n    painter->save();\r\n\r\n    QPen newPen(Qt::lightGray);\r\n    newPen.setWidth(1);\r\n\r\n    painter->setPen(newPen);\r\n    painter->drawLine(option.rect.topRight(), option.rect.bottomRight());\r\n\r\n    painter->restore();\r\n}\r\n"
  },
  {
    "path": "mainwindow/SaveHierarchy/SaveHierarchyDelegate.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: SaveHierarchyDelegate.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Esko Pekkarinen\r\n// Date: 22.05.2015\r\n//\r\n// Description:\r\n// Delegate class for save hierarchy document selection.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef SAVEHIERARCHYDELEGATE_H\r\n#define SAVEHIERARCHYDELEGATE_H\r\n\r\n#include <QStyledItemDelegate>\r\n\r\nclass LibraryInterface;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Delegate class for save hierarchy document selection.\r\n//-----------------------------------------------------------------------------\r\nclass SaveHierarchyDelegate : public QStyledItemDelegate\r\n{\r\npublic:\r\n\r\n\t/*!\r\n\t *  The constructor.\r\n\t *\r\n\t *    @param [in] library     The document library to use.\r\n\t *    @param [in] parent      The parent object.\r\n\t */\r\n\tSaveHierarchyDelegate(LibraryInterface* library, QObject* parent);\r\n\r\n\t//! The destructor.\r\n\tvirtual ~SaveHierarchyDelegate();\r\n\r\n    /*! Create a new editor for the given item\r\n\t *\r\n\t *    @param [in] parent      Owner for the editor.\r\n\t *    @param [in] option      Contains options for the editor.\r\n\t *    @param [in] index       Model index identifying the item.\r\n\t *\r\n\t *    @return The editor to be used to edit the item.\r\n\t*/\r\n    virtual QWidget* createEditor(QWidget* parent, QStyleOptionViewItem const& option, QModelIndex const& index) const;\r\n  \r\n    /*! Set the data for the editor.\r\n\t *\r\n\t *    @param [in] editor      The editor where the data is to be set.\r\n\t *    @param [in] index       Model index identifying the item that's data is to be set.\r\n\t *\r\n\t*/\r\n    virtual void setEditorData(QWidget* editor,  QModelIndex const& index) const;\r\n\r\n    /*! Save the data from the editor to the model.\r\n\t *\r\n\t *    @param [in] editor      The editor that contains the data to store.\r\n\t *    @param [in] model       Model that contains the data structure where data is to be saved to.\r\n\t *    @param [in] index       Model index identifying the item that's data is to be saved.\r\n\t *\r\n\t*/\r\n    virtual void setModelData(QWidget* editor, QAbstractItemModel* model, QModelIndex const& index) const;\r\n\r\n    /*!\r\n     *  Finds the preferred size for an item.\r\n     *\r\n     *    @param [in] option      Style options for the item.\r\n     *    @param [in] index       The model index whose size to find.\r\n     *\r\n     *    @return The preferred size for the item.\r\n     */\r\n    virtual QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const;\r\n\r\n    /*!\r\n     *  Draws an item.\r\n     *\r\n     *    @param [in] painter     The painter to use for drawing.\r\n     *    @param [in] option      Style options for the item.\r\n     *    @param [in] index       The item to draw.\r\n     */\r\n    virtual void paint(QPainter *painter, QStyleOptionViewItem const& option, QModelIndex const& index) const;\r\n\r\nprivate:\r\n\r\n\t// Disable copying.\r\n\tSaveHierarchyDelegate(SaveHierarchyDelegate const& rhs);\r\n\tSaveHierarchyDelegate& operator=(SaveHierarchyDelegate const& rhs);\r\n   \r\n    //! The used document library.\r\n    LibraryInterface* library_;\r\n};\r\n\r\n#endif // SAVEHIERARCHYDELEGATE_H\r\n"
  },
  {
    "path": "mainwindow/SaveHierarchy/SaveHierarchyDialog.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: SaveHierarchyDialog.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Esko Pekkarinen\r\n// Date: 21.05.2015\r\n//\r\n// Description:\r\n// Dialog for hierarchical save setup.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"SaveHierarchyDialog.h\"\r\n#include \"SaveHierarchyDelegate.h\"\r\n\r\n#include \"HierarchicalSaveBuildStrategy.h\"\r\n#include \"HierarchicalSaveColumns.h\"\r\n\r\n#include <KactusAPI/include/LibraryInterface.h>\r\n\r\n#include <common/widgets/LibrarySelectorWidget/LibrarySelectorWidget.h>\r\n\r\n#include <QApplication>\r\n#include <QDialogButtonBox>\r\n#include <QGroupBox>\r\n#include <QProgressBar>\r\n#include <QRadioButton>\r\n#include <QVBoxLayout>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SaveHierarchyDialog::SaveHierarchyDialog()\r\n//-----------------------------------------------------------------------------\r\nSaveHierarchyDialog::SaveHierarchyDialog(QObject* rootObject, LibraryInterface* library, QWidget *parent)\r\n    : QDialog(parent), documentSelectionView_(new QTreeWidget(this)), saveProgressBar_(new QProgressBar(this)), \r\n    directoryEditor_(new LibrarySelectorWidget(this)), library_(library),\r\n    documentSelectionBuilder_(library, this)\r\n{\r\n    setWindowTitle(tr(\"Save hierarchy\"));\r\n\r\n    documentSelectionView_->addTopLevelItem(documentSelectionBuilder_.build(rootObject));\r\n    documentSelectionView_->setColumnCount(2);\r\n    documentSelectionView_->expandAll();\r\n    \r\n    documentSelectionView_->setAlternatingRowColors(true);\r\n\r\n    documentSelectionView_->setItemDelegate(new SaveHierarchyDelegate(library, this));\r\n\r\n    QStringList selectionHeaders;\r\n    selectionHeaders << tr(\"VLNV hierarchy\") << tr(\"Save As\");\r\n    documentSelectionView_->setHeaderLabels(selectionHeaders);\r\n\r\n    documentSelectionView_->setColumnWidth(0, 400);\r\n\r\n    directoryEditor_->setEnabled(false);\r\n\r\n    resize(800, 600);\r\n\r\n    setupLayout();\r\n\r\n    connect(&documentSelectionBuilder_, SIGNAL(itemSaved()), this, SLOT(onItemSaved()), Qt::UniqueConnection);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SaveHierarchyDialog::~SaveHierarchyDialog()\r\n//-----------------------------------------------------------------------------\r\nSaveHierarchyDialog::~SaveHierarchyDialog()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SaveHierarchyDialog::accept()\r\n//-----------------------------------------------------------------------------\r\nvoid SaveHierarchyDialog::accept()\r\n{\r\n    QApplication::setOverrideCursor(Qt::WaitCursor);\r\n\r\n    int checkedItems = findNumberOfCheckedItems(documentSelectionView_->topLevelItem(0));\r\n    saveProgressBar_->setMaximum(checkedItems);\r\n\r\n    if (directoryEditor_->isEnabled())\r\n    {\r\n        documentSelectionBuilder_.setSavePath(directoryEditor_->getPath());\r\n    }\r\n\r\n    library_->beginSave();\r\n    documentSelectionBuilder_.saveItem(documentSelectionView_->topLevelItem(0));\r\n    library_->endSave();\r\n\r\n    QDialog::accept();\r\n\r\n    QApplication::restoreOverrideCursor();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SaveHierarchyDialog::onSaveModeChanged()\r\n//-----------------------------------------------------------------------------\r\nvoid SaveHierarchyDialog::onSetSaveModeToCurrent(bool enabled)\r\n{\r\n    if (enabled)\r\n    {\r\n        documentSelectionBuilder_.setSaveMode(HierarchicalSaveBuildStrategy::CURRENT_DIRECTORY);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SaveHierarchyDialog::onSetSaveModeToCommonRoot()\r\n//-----------------------------------------------------------------------------\r\nvoid SaveHierarchyDialog::onSetSaveModeToCommonRoot(bool enabled)\r\n{\r\n    if (enabled)\r\n    {\r\n        documentSelectionBuilder_.setSaveMode(HierarchicalSaveBuildStrategy::COMMON_ROOT_DIRECTORY);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SaveHierarchyDialog::onSetSaveModeToSingleDirectory()\r\n//-----------------------------------------------------------------------------\r\nvoid SaveHierarchyDialog::onSetSaveModeToSingleDirectory(bool enabled)\r\n{\r\n    if (enabled)\r\n    {\r\n        documentSelectionBuilder_.setSaveMode(HierarchicalSaveBuildStrategy::SINGLE_DIRECTORY);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SaveHierarchyDialog::onItemSaved()\r\n//-----------------------------------------------------------------------------\r\nvoid SaveHierarchyDialog::onItemSaved()\r\n{\r\n    saveProgressBar_->setValue(saveProgressBar_->value() +1);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SaveHierarchyDialog::numberOfCheckedItems()\r\n//-----------------------------------------------------------------------------\r\nint SaveHierarchyDialog::findNumberOfCheckedItems(QTreeWidgetItem* item)\r\n{\r\n    int count = 0;\r\n\r\n    if (item->checkState(HierarchicalSaveColumns::SAVE_AS_VLNV) == Qt::Checked)\r\n    {\r\n        count++;\r\n\r\n        int childCount = item->childCount();\r\n        for (int i = 0; i < childCount; i++)\r\n        {\r\n            count += findNumberOfCheckedItems(item->child(i));\r\n        }\r\n    }\t\r\n\r\n    return count;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SaveHierarchyDialog::setupLayout()\r\n//-----------------------------------------------------------------------------\r\nvoid SaveHierarchyDialog::setupLayout()\r\n{\r\n\r\n    QDialogButtonBox* dialogControls = new QDialogButtonBox(this);\r\n    dialogControls->addButton(tr(\"Save\"), QDialogButtonBox::AcceptRole);\r\n    dialogControls->addButton(QDialogButtonBox::Cancel);\r\n\r\n    QGroupBox* documentTreeGroup = new QGroupBox(tr(\"Select documents to save\"), this);\r\n    QVBoxLayout* documentLayout = new QVBoxLayout(documentTreeGroup); \r\n    documentLayout->addWidget(documentSelectionView_);\r\n\r\n    QGroupBox* directorySelectionGroup = new QGroupBox(tr(\"Select save location\"), this);\r\n\r\n    QRadioButton* originalButton = new QRadioButton(tr(\"Save in original directories.\"), directorySelectionGroup);\r\n    QRadioButton* newRootButton = new QRadioButton(tr(\"Save in subdirectories under a given root directory.\"), \r\n        directorySelectionGroup);\r\n    QRadioButton* singleDirectoryButton = new QRadioButton(tr(\"Save all in one directory.\"), \r\n        directorySelectionGroup);\r\n    originalButton->setChecked(true);\r\n\r\n    QVBoxLayout* selectionLayout = new QVBoxLayout(directorySelectionGroup); \r\n    selectionLayout->addWidget(originalButton);\r\n    selectionLayout->addWidget(newRootButton);\r\n    selectionLayout->addWidget(singleDirectoryButton);\r\n    selectionLayout->addWidget(directoryEditor_);\r\n\r\n    saveProgressBar_->setAlignment(Qt::AlignCenter);\r\n    saveProgressBar_->setMinimum(0);\r\n\r\n    QVBoxLayout* topLayout = new QVBoxLayout(this);\r\n    topLayout->addWidget(documentTreeGroup);\r\n    topLayout->addWidget(directorySelectionGroup);\r\n    topLayout->addWidget(saveProgressBar_);\r\n    topLayout->addWidget(dialogControls);\r\n\r\n    connect(dialogControls, SIGNAL(accepted()), this, SLOT(accept()), Qt::UniqueConnection);\r\n    connect(dialogControls, SIGNAL(rejected()), this, SLOT(reject()), Qt::UniqueConnection);\r\n\r\n    connect(originalButton, SIGNAL(toggled(bool)), directoryEditor_, SLOT(setDisabled(bool)), Qt::UniqueConnection);\r\n\r\n    connect(originalButton, SIGNAL(toggled(bool)), \r\n        this, SLOT(onSetSaveModeToCurrent(bool)), Qt::UniqueConnection);\r\n    connect(newRootButton, SIGNAL(toggled(bool)), \r\n        this, SLOT(onSetSaveModeToCommonRoot(bool)), Qt::UniqueConnection);\r\n    connect(singleDirectoryButton, SIGNAL(toggled(bool)), \r\n        this, SLOT(onSetSaveModeToSingleDirectory(bool)), Qt::UniqueConnection);\r\n}\r\n"
  },
  {
    "path": "mainwindow/SaveHierarchy/SaveHierarchyDialog.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: SaveHierarchyDialog.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Esko Pekkarinen\r\n// Date: 21.05.2015\r\n//\r\n// Description:\r\n// Dialog for hierarchical save setup.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef SAVEHIERARCHYDIALOG_H\r\n#define SAVEHIERARCHYDIALOG_H\r\n\r\n#include <QDialog>\r\n\r\n#include <QObject>\r\n#include <QProgressBar>\r\n#include <QTreeWidget>\r\n\r\n#include \"HierarchicalSaveBuildStrategy.h\"\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Dialog for hierarchical save setup.\r\n//-----------------------------------------------------------------------------\r\nclass SaveHierarchyDialog : public QDialog\r\n{\r\n    Q_OBJECT\r\npublic:\r\n    //! The constructor.\r\n    SaveHierarchyDialog(QObject* rootObject, LibraryInterface* library, QWidget *parent);\r\n\r\n    //! The destructor.\r\n    ~SaveHierarchyDialog();\r\n\r\npublic slots:\r\n\r\n    //! Called when the save button is clicked.\r\n    virtual void accept();\r\n\r\nprivate slots:\r\n\r\n    //! Called when saving to current directories is selected.\r\n    void onSetSaveModeToCurrent(bool enabled);\r\n\r\n    //! Called when saving to new root directory is selected.\r\n    void onSetSaveModeToCommonRoot(bool enabled);\r\n\r\n    //! Called when saving to a single directory is selected.\r\n    void onSetSaveModeToSingleDirectory(bool enabled);\r\n\r\n    //! Called when an item has been saved.\r\n    void onItemSaved();\r\n\r\nprivate:\r\n    // Disable copying.\r\n    SaveHierarchyDialog(SaveHierarchyDialog const& rhs);\r\n    SaveHierarchyDialog& operator=(SaveHierarchyDialog const& rhs);\r\n\r\n    \r\n    /*!\r\n     *  Finds the number of checked items under a given tree item.\r\n     *\r\n     *    @param [in] item   The item to start the count from.\r\n     *\r\n     *    @return The number of checked items under the item including the item itself.\r\n     */\r\n    int findNumberOfCheckedItems(QTreeWidgetItem* item);\r\n\r\n    //! Sets the dialog layout.\r\n    void setupLayout();\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! View for selecting and editing the documents to save.\r\n    QTreeWidget* documentSelectionView_;\r\n\r\n    //! Progress bar for showing save progression.\r\n    QProgressBar* saveProgressBar_;\r\n\r\n    //! Selector for save location within libraries.\r\n    LibrarySelectorWidget* directoryEditor_;\r\n\r\n    //! The document library in use.\r\n    LibraryInterface* library_;\r\n\r\n    //! The building strategy for the document tree.\r\n    HierarchicalSaveBuildStrategy documentSelectionBuilder_;\r\n};\r\n\r\n#endif // SAVEHIERARCHYDIALOG_H\r\n"
  },
  {
    "path": "mainwindow/SplashScreen.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: SplashScreen.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Joni-Matti Maatta\r\n// Date: 24.5.2011\r\n//\r\n// Description:\r\n// Kactus2 splash screen.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"SplashScreen.h\"\r\n\r\n#include <QPainter>\r\n#include <QLabel>\r\n#include <QBitmap>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SplashScreen::SplashScreen()\r\n//-----------------------------------------------------------------------------\r\nSplashScreen::SplashScreen(QString const& versionString):\r\nQSplashScreen(QPixmap(\":/common/graphics/splash.png\")),\r\n    versionString_(versionString)\r\n{\r\n    setWindowFlags(windowFlags() | Qt::WindowStaysOnTopHint | Qt::X11BypassWindowManagerHint);\r\n    setCursor(Qt::PointingHandCursor);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: drawContents()\r\n//-----------------------------------------------------------------------------\r\nvoid SplashScreen::drawContents(QPainter *painter)\r\n{\r\n    // Draw the version text.\r\n    painter->setPen(QPen(Qt::black, 1));\r\n\r\n    QFont font = painter->font();\r\n    font.setPixelSize(14);\r\n    font.setBold(true);\r\n    painter->setFont(font);\r\n\r\n    painter->drawText(QRectF(5, 220, 590, 35), Qt::AlignCenter,\r\n        tr(\"Version %1\\nQt version %2\")\r\n        .arg(versionString_, qVersion()));\r\n\r\n    // Draw the other information.\r\n    font.setPixelSize(12);\r\n    font.setBold(false);\r\n    painter->setFont(font);\r\n \r\n    painter->drawText(QRectF(5, 240, 590, 160), Qt::AlignCenter,\r\n        QString::fromLatin1(\"Copyright 2010-2026 Tampere University,\\n\"\r\n                            \"Korkeakoulunkatu 10, FI-33720 Tampere, Finland\\n\"\r\n                            \"https://research.tuni.fi/system-on-chip/tools\\n\"\r\n                            \"kactus2@tuni.fi\\n\"\r\n                            \"Kactus2 is available for dual licensing.\\n\"\r\n                            \"This software is licensed under the General Public License Version 2.\\n\"\r\n                            \"Contributors: Antti Kamppi, Esko Pekkarinen, Janne Virtanen, Joni-Matti Maatta, \\n\"\r\n                            \"Juho Jrvinen, Lauri Matilainen, Mikko Teuho, Timo D. Hmlinen, Anton Hagqvist, Vasilii Feshchenko\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SplashScreen::mousePressEvent()\r\n//-----------------------------------------------------------------------------\r\nvoid SplashScreen::mousePressEvent( QMouseEvent* event )\r\n{\r\n    event->accept();\r\n    close();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SplashScreen::keyPressEvent()\r\n//-----------------------------------------------------------------------------\r\nvoid SplashScreen::keyPressEvent(QKeyEvent* event)\r\n{\r\n    event->accept();\r\n    close();\r\n}\r\n"
  },
  {
    "path": "mainwindow/SplashScreen.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: SplashScreen.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Joni-Matti Maatta\r\n// Date: 24.5.2011\r\n//\r\n// Description:\r\n// Kactus 2 splash screen.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef SPLASHSCREEN_H\r\n#define SPLASHSCREEN_H\r\n\r\n#include <QSplashScreen>\r\n#include <QMouseEvent>\r\n#include <QKeyEvent>\r\n\r\n//-----------------------------------------------------------------------------\r\n//! SplashScreen class.\r\n//-----------------------------------------------------------------------------\r\nclass SplashScreen : public QSplashScreen\r\n{\r\npublic:\r\n    /*!\r\n     *  Constructor.\r\n     */\r\n    explicit SplashScreen(QString const& versionString);\r\n\r\n    // Disable copying.\r\n    SplashScreen(SplashScreen const& rhs) = delete;\r\n    SplashScreen& operator=(SplashScreen const& rhs) = delete;\r\n\r\n    /*!\r\n     *  Destructor.\r\n     */\r\n    ~SplashScreen() final = default;\r\n\r\nprotected:\r\n    //! Draws the contents of the splash screen.\r\n    virtual void drawContents(QPainter *painter);\r\n\r\n    //! Event handler for mouse clicks\r\n    virtual void mousePressEvent(QMouseEvent* event);\r\n\r\n    //! Handler for key press events\r\n    virtual void keyPressEvent(QKeyEvent* event);\r\n\r\nprivate:\r\n\r\n    //! Current version to display.\r\n    QString versionString_;\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n\r\n#endif // SPLASHSCREEN_H\r\n"
  },
  {
    "path": "mainwindow/WorkspaceSettings.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: Workspace.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Esko Pekkarinen\n// Date: 21.04.2023\n//\n// Description:\n// Stores and loads all workspace related settings for the application.\n//-----------------------------------------------------------------------------\n\n#include \"WorkspaceSettings.h\"\n\n#include \"NewWorkspaceDialog.h\"\n#include \"DeleteWorkspaceDialog.h\"\n\n#include <IPXACTmodels/kactusExtensions/KactusAttribute.h>\n\n#include <editors/ComponentEditor/componenteditor.h>\n\n#include <QActionGroup>\n#include <QSettings>\n#include <QMenu>\n\n//-----------------------------------------------------------------------------\n// Function: Workspace::saveSettings()\n//-----------------------------------------------------------------------------\nWorkspaceSettings::WorkspaceSettings(QMainWindow* mainWindow, DockWidgetHandler* docks): \n    QObject(mainWindow),\n    mainWindow_(mainWindow),\n    docks_(docks)\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: Workspace::getCurrentWorkspace()\n//-----------------------------------------------------------------------------\nQString WorkspaceSettings::getCurrentWorkspace() const\n{\n    return activeWorkspace_;\n}\n\n//-----------------------------------------------------------------------------\n// Function: Workspace::onNewWorkspace()\n//-----------------------------------------------------------------------------\nQStringList WorkspaceSettings::getWorkspaces() const\n{\n    QSettings settings;\n    settings.beginGroup(\"Workspaces\");\n    QStringList workspaceIDs = settings.childGroups();\n    settings.endGroup();\n\n    return workspaceIDs;\n}\n\n//-----------------------------------------------------------------------------\n// Function: Workspace::saveSettings()\n//-----------------------------------------------------------------------------\nvoid WorkspaceSettings::saveSettings() const\n{\n    QSettings settings;\n\n    // Save the active workspace.\n    settings.setValue(\"Workspaces/CurrentWorkspace\", activeWorkspace_);\n    saveWorkspace(activeWorkspace_);\n}\n\n//-----------------------------------------------------------------------------\n// Function: Workspace::restoreSettings()\n//-----------------------------------------------------------------------------\nvoid WorkspaceSettings::restoreSettings()\n{\n    QSettings settings;\n\n    // Create default workspaces if the workspaces registry group is not found.\n    settings.beginGroup(\"Workspaces\");\n    bool createDefaultWorkspaces = settings.childGroups().isEmpty();\n    settings.endGroup();\n\n    if (createDefaultWorkspaces)\n    {\n        docks_->loadFilterSettings(settings);\n\n        createNewWorkspace(\"Default\");\n        createNewWorkspace(\"Design\");\n    }\n\n    // Load the active workspace.\n    activeWorkspace_ = settings.value(\"Workspaces/CurrentWorkspace\", QString(\"Default\")).toString();\n    loadWorkspace(activeWorkspace_);\n}\n\n//-----------------------------------------------------------------------------\n// Function: Workspace::saveWorkspace()\n//-----------------------------------------------------------------------------\nvoid WorkspaceSettings::saveWorkspace(QString const& workspaceName) const\n{\n    QSettings settings;\n\n    // Create the registry group name.\n    QString keyName = \"Workspaces/\" + workspaceName;\n\n    // Save the geometry and state of windows.\n    settings.beginGroup(keyName);\n\n    settings.setValue(\"WindowState\", mainWindow_->saveState());\n    settings.setValue(\"Geometry\", mainWindow_->saveGeometry());\n    settings.setValue(\"WindowPosition\", mainWindow_->pos());\n\n    docks_->saveFilterSettings(settings);\n    docks_->saveVisibilitySettings(settings);\n\n    settings.endGroup(); // Workspaces/workspaceName\n}\n\n//-----------------------------------------------------------------------------\n// Function: Workspace::loadWorkspace()\n//-----------------------------------------------------------------------------\nvoid WorkspaceSettings::loadWorkspace(QString const& workspaceName)\n{\n    QSettings settings;\n\n    // Create the registry key name.\n    QString keyName = \"Workspaces/\" + workspaceName;\n    settings.beginGroup(keyName);\n\n    // Set the window to normal state (this fixed a weird error with window state).\n    mainWindow_->setWindowState(Qt::WindowNoState);\n\n    if (settings.contains(\"WindowPosition\"))\n    {\n        mainWindow_->move(settings.value(\"WindowPosition\").toPoint());\n    }\n\n    if (settings.contains(\"Geometry\"))\n    {\n        mainWindow_->restoreGeometry(settings.value(\"Geometry\").toByteArray());\n    }\n\n    if (settings.contains(\"WindowState\"))\n    {\n        mainWindow_->restoreState(settings.value(\"WindowState\").toByteArray());\n    }\n\n    docks_->loadVisiblities(settings);\n    docks_->loadFilterSettings(settings);\n\n    settings.setValue(\"Workspaces/CurrentWorkspace\", workspaceName);\n    activeWorkspace_ =  workspaceName;\n    emit workspaceChanged(activeWorkspace_);\n}\n\n//-----------------------------------------------------------------------------\n// Function: Workspace::createNewWorkspace()\n//-----------------------------------------------------------------------------\nvoid WorkspaceSettings::createNewWorkspace(QString const& workspaceName) const\n{\n    saveWorkspace(workspaceName);\n\n    QString workspacePath = \"Workspaces/\" + workspaceName;\n\n    QSettings settings;\n\n    settings.beginGroup(workspacePath);\n    settings.beginGroup(\"ComponentEditorFilters\");\n    settings.beginGroup(\"HW\");\n    for (unsigned int i = 0; i < KactusAttribute::KTS_PRODHIER_COUNT; ++i)\n    {\n        auto hierarchy = static_cast<KactusAttribute::ProductHierarchy>(i);\n\n        settings.beginGroup(KactusAttribute::hierarchyToString(hierarchy));\n\n        for (QString const& itemName : ComponentEditor::getHwItemNames())\n        {\n            settings.setValue(itemName, true);\n        }\n\n        settings.endGroup(); // hierarchy\n    }\n    settings.endGroup(); // HW\n\n    settings.beginGroup(\"SW\");\n    for (QString const& itemName : ComponentEditor::getSwItemNames())\n    {\n        settings.setValue(itemName, true);\n    }\n    settings.endGroup(); // SW\n\n    settings.endGroup(); // ComponentEditorFilters\n    settings.endGroup(); // Workspaces/workspaceName\n}\n\n//-----------------------------------------------------------------------------\n// Function: Workspace::updateWorkspaceMenu()\n//-----------------------------------------------------------------------------\nvoid WorkspaceSettings::updateWorkspaceMenu(QMenu* workspaceMenu) const\n{\n    // Create the workspace menu based on the settings.\n    workspaceMenu->clear();\n\n    QString currentWorkspace = getCurrentWorkspace();\n\n    QActionGroup* workspaceGroup = new QActionGroup(mainWindow_);\n    workspaceGroup->setExclusive(true);\n    for (QString const& workspaceName : getWorkspaces())\n    {\n        QAction* action = new QAction(workspaceName, mainWindow_);\n        action->setCheckable(true);\n        action->setChecked(workspaceName == currentWorkspace);\n\n        workspaceGroup->addAction(action);\n        workspaceMenu->addAction(action);\n    }\n\n    connect(workspaceGroup, SIGNAL(triggered(QAction*)), this, SLOT(onWorkspaceChanged(QAction*)));\n\n    // Add actions for creating and deleting new workspaces.\n    auto addAction = new QAction(tr(\"New Workspace...\"), mainWindow_);\n    connect(addAction, SIGNAL(triggered()), this, SLOT(onNewWorkspace()), Qt::UniqueConnection);\n\n    auto deleteAction = new QAction(tr(\"Delete Workspace...\"), mainWindow_);\n    connect(deleteAction, SIGNAL(triggered()), this, SLOT(onDeleteWorkspace()), Qt::UniqueConnection);\n\n    workspaceMenu->addSeparator();\n    workspaceMenu->addAction(addAction);\n    workspaceMenu->addAction(deleteAction);\n}\n\n//-----------------------------------------------------------------------------\n// Function: MainWindow::onWorkspaceChanged()\n//-----------------------------------------------------------------------------\nvoid WorkspaceSettings::onWorkspaceChanged(QAction* action)\n{\n    QString workspaceName = action->text();\n\n    saveWorkspace(activeWorkspace_);\n    loadWorkspace(workspaceName);\n}\n\n//-----------------------------------------------------------------------------\n// Function: Workspace::onNewWorkspace()\n//-----------------------------------------------------------------------------\nvoid WorkspaceSettings::onNewWorkspace()\n{\n    NewWorkspaceDialog saveDialog(mainWindow_);\n\n    if (saveDialog.exec() == QDialog::Accepted)\n    {\n        saveWorkspace(activeWorkspace_);\n\n        QString newWorkspace = saveDialog.name();\n\n        createNewWorkspace(newWorkspace);\n        copyComponentEditorSettings(newWorkspace);\n        saveWorkspace(newWorkspace);\n\n        loadWorkspace(newWorkspace);\n\n        emit requestMenuUpdate();\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: Workspace::onDeleteWorkspace()\n//-----------------------------------------------------------------------------\nvoid WorkspaceSettings::onDeleteWorkspace()\n{\n    DeleteWorkspaceDialog saveDialog(mainWindow_);\n\n    // Fill in the dialog with existing workspace names.\n    for (QString const& workspace : getWorkspaces())\n    {\n        if (workspace != \"Default\" && workspace != activeWorkspace_)\n        {\n            saveDialog.addWorkspaceName(workspace);\n        }\n    }\n\n    // Execute the dialog.\n    if (saveDialog.exec() == QDialog::Accepted)\n    {\n        QSettings settings;\n        settings.remove(\"Workspaces/\" + saveDialog.name());\n        emit requestMenuUpdate();\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: Workspace::copyComponentEditorSettings()\n//-----------------------------------------------------------------------------\nvoid WorkspaceSettings::copyComponentEditorSettings(QString const& workspaceName) const\n{\n    QSettings settings;\n    settings.beginGroup(\"Workspaces\");\n\n    QString sourceWorkspacePath = activeWorkspace_ + \"/ComponentEditorFilters/HW/\";\n    QString targetWorkspacePath = workspaceName + \"/ComponentEditorFilters/HW/\";\n\n    for (unsigned int i = 0; i < KactusAttribute::KTS_PRODHIER_COUNT; ++i)\n    {\n        auto hierarchy = static_cast<KactusAttribute::ProductHierarchy>(i);\n        QString hwHierarchyName(KactusAttribute::hierarchyToString(hierarchy) + \"/\");\n\n        for (QString const& name : ComponentEditor::getHwItemNames())\n        {\n            settings.setValue(targetWorkspacePath + hwHierarchyName + name, \n                settings.value(sourceWorkspacePath + hwHierarchyName + name).toBool());\n        }\n    }\n\n    sourceWorkspacePath = activeWorkspace_ + \"/ComponentEditorFilters/SW/\";\n    targetWorkspacePath = workspaceName + \"/ComponentEditorFilters/SW/\";\n\n    for (QString const& name : ComponentEditor::getSwItemNames())\n    {\n        settings.setValue(targetWorkspacePath + name, settings.value(sourceWorkspacePath + name).toBool());\n    }\n\n    settings.endGroup(); // Workspaces\n}\n"
  },
  {
    "path": "mainwindow/WorkspaceSettings.h",
    "content": "//-----------------------------------------------------------------------------\n// File: Workspace.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Esko Pekkarinen\n// Date: 21.04.2023\n//\n// Description:\n// Stores and loads all workspace related settings for the application.\n//-----------------------------------------------------------------------------\n\n#ifndef WORKSPACE_H\n#define WORKSPACE_H\n\n#include <QObject>\n#include <QAction>\n#include <QMainWindow>\n\n#include \"DockWidgetHandler.h\"\n\n//-----------------------------------------------------------------------------\n//! Workspace class\n//-----------------------------------------------------------------------------\nclass WorkspaceSettings : public QObject\n{\n\tQ_OBJECT\n\npublic:\n\n\t/*!\n\t *  The constructor.\n\t *\n     *    @param [in] mainWindow\tThe mainwindow of the application.\n     *    @param [in] docks\t\tThe DockWidgetHandler which holds the visibility and filter settings.\n\t * \n\t */\n\tWorkspaceSettings(QMainWindow* mainWindow, DockWidgetHandler* docks);\n\n\t//! The destructor.\n\tvirtual ~WorkspaceSettings() = default;\n\n    // Disable copying.\n\tWorkspaceSettings(WorkspaceSettings const& rhs) = delete;\n\tWorkspaceSettings& operator=(WorkspaceSettings const& rhs) = delete;\n\n\t//! Gets the currently active workspace name.\n    QString getCurrentWorkspace() const;\n\n\t//! Gets the list of available workspace names.\n    QStringList getWorkspaces() const;\n\n\t/*!\n\t *  Stores the workspace settings.\n\t */\n\tvoid saveSettings() const;\n\n\t/*!\n\t *  Restores the workspace settings.\n\t*/\n\tvoid restoreSettings();\n\n\t/*!\n\t *  Saves the settings for the given workspace.\n\t *\n\t *    @param [in] workspaceName The name of the workspace.\n\t */\n\tvoid saveWorkspace(QString const& workspaceName) const;\n\n\t/*!\n\t *  Loads the settings for the given workspace and sets it as active workspace.\n\t *\n\t *    @param [in] workspaceName The name of the workspace.\n\t */\n\tvoid loadWorkspace(QString const& workspaceName);\n\n\t/*!\n\t *  Creates a new workspace.\n\t *\n\t *    @param [in] workspaceName   The name of the new workspace.\n\t */\n\tvoid createNewWorkspace(QString const& workspaceName) const;\n\n    void updateWorkspaceMenu(QMenu* workspaceMenu) const;\n\nsignals:\n\n\t//! Emitted when workspace menu needs to be updated.\n\tvoid requestMenuUpdate();\n\n\t//! Emitted when workspace has been changed.\n\tvoid workspaceChanged(QString const& workspace);\n\nprivate slots:\n\n\t/*!\n\t *  Changes the active workspace.\n\t */\n    void onWorkspaceChanged(QAction* action);\n\n\t/*!\n\t *  Creates a new workspace, requesting a name for the workspace from the user using a dialog.\n\t */\n\tvoid onNewWorkspace();\n\n\t/*!\n\t *  Deletes a workspace, asking the user which workspace to delete using a dialog.\n\t */\n\tvoid onDeleteWorkspace();\n\nprivate:\n\n\t/*!\n\t *  Copy the component editor settings from the current workspace.\n\t *\n\t *    @param [in] workspaceName   The name of the new workspace.\n\t */\n\tvoid copyComponentEditorSettings(QString const& workspaceName) const;\n\n\t//-----------------------------------------------------------------------------\n\t// Data.\n\t//-----------------------------------------------------------------------------\n\n\t//! The main window of the application.\n\tQMainWindow* mainWindow_;\n\n\t//! DockWidgetHandler which holds the visibility and filter settings.\n\tDockWidgetHandler* docks_;\n\n\t//! The name of the currently active workspace.\n\tQString activeWorkspace_ = QString(\"Default\");\n\n};\n\n//-----------------------------------------------------------------------------\n\n#endif // WORKSPACE_H\n"
  },
  {
    "path": "mainwindow/main.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: main.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Joni-Matti Maatta\r\n// Date: 24.5.2011\r\n//\r\n// Description:\r\n// Kactus2 main entry point.\r\n//-----------------------------------------------------------------------------\r\n\r\n#define PY_SSIZE_T_CLEAN\r\n#include <Python.h>\r\n\r\n#include \"mainwindow.h\"\r\n\r\n#include \"CommandLineParser.h\"\r\n#include \"SplashScreen.h\"\r\n\r\n#include <KactusAPI/include/MessageMediator.h>\r\n#include <KactusAPI/include/ConsoleMediator.h>\r\n#include <common/ui/GraphicalMessageMediator.h>\r\n\r\n#include <KactusAPI/KactusAPI.h>\r\n\r\n#include <KactusAPI/include/VersionHelper.h>\r\n\r\n#include <KactusAPI/include/LibraryHandler.h>\r\n\r\n#include <KactusAPI/include/PluginManager.h>\r\n#include <KactusAPI/include/PluginUtilityAdapter.h>\r\n\r\n#include <settings/SettingsUpdater.h>\r\n\r\n#include <QApplication>\r\n#include <QPalette>\r\n#include <QTimer>\r\n#include <QObject>\r\n\r\n\r\n#include <iostream>\r\n\r\n#include \"PythonAPI/PythonInterpreter.h\"\r\n#include \"PythonAPI/StdInputListener.h\"\r\n#include \"PythonAPI/FileChannel.h\"\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Private utility functions for main.\r\n//-----------------------------------------------------------------------------\r\nnamespace\r\n{\r\n    //-----------------------------------------------------------------------------\r\n    // Function: startGui()\r\n    //-----------------------------------------------------------------------------\r\n    bool startGui(int argc)\r\n    {\r\n        return argc == 1;\r\n    }\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Function: createApplication()\r\n    //-----------------------------------------------------------------------------\r\n    QCoreApplication* createApplication(int &argc, char* argv[])\r\n    {\r\n        QCoreApplication* application = nullptr; \r\n        if (startGui(argc))\r\n        {\r\n            QApplication* guiApplication = new QApplication(argc, argv);        \r\n\r\n            // Set the palette to use nice pastel colors.\r\n            QPalette palette = guiApplication->palette();\r\n            palette.setColor(QPalette::Active, QPalette::Highlight, QColor(33, 135, 237));\r\n            palette.setColor(QPalette::Disabled, QPalette::Highlight, QColor(166, 200, 234));\r\n            palette.setColor(QPalette::Inactive, QPalette::Highlight, QColor(166, 200, 234));\r\n            guiApplication->setPalette(palette);\r\n\r\n            application =  guiApplication;\r\n        }\r\n        else\r\n        {\r\n            application = new QCoreApplication(argc, argv);\r\n        }\r\n\r\n        // Set the identification tags for the application.\r\n        QCoreApplication::setOrganizationDomain(QStringLiteral(\"tut.fi\"));\r\n        QCoreApplication::setOrganizationName(QStringLiteral(\"TUT\"));\r\n        QCoreApplication::setApplicationName(QStringLiteral(\"Kactus2\"));\r\n        QCoreApplication::setApplicationVersion(VersionHelper::createVersionString());\r\n\r\n        return application;\r\n    }\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Function: loadPlugins()\r\n    //-----------------------------------------------------------------------------\r\n    void loadPlugins(QSettings const& settings)\r\n    {        \r\n        QStringList pluginsPath = settings.value(QStringLiteral(\"Platform/PluginsPath\"), \r\n            QStringList(QStringLiteral(\"Plugins\"))).toStringList();\r\n        PluginManager::getInstance().setPluginPaths(pluginsPath);\r\n    }\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Function: createMessageMediator()\r\n    //-----------------------------------------------------------------------------\r\n    MessageMediator* createMessageMediator(int argc)\r\n    {\r\n        if (startGui(argc))\r\n        {\r\n            return new GraphicalMessageMediator();\r\n        }\r\n        else\r\n        {\r\n            return new ConsoleMediator();\r\n        }\r\n    }\r\n};\r\n\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: main()\r\n//-----------------------------------------------------------------------------\r\nint main(int argc, char *argv[])\r\n{\r\n    Q_INIT_RESOURCE(kactus);\r\n\r\n    QScopedPointer<QCoreApplication> application(createApplication(argc, argv));\r\n    QScopedPointer<MessageMediator> mediator(createMessageMediator(argc));\r\n\r\n    QSettings::setDefaultFormat(QSettings::IniFormat);\r\n\r\n    QSettings settings;\r\n    SettingsUpdater::runUpgrade(settings, mediator.data());\r\n\r\n    loadPlugins(settings);\r\n\r\n    auto& library = LibraryHandler::getInstance();\r\n    library.setOutputChannel(mediator.data());\r\n\r\n    QScopedPointer<KactusAPI> coreAPI(new KactusAPI(mediator.data()));\r\n\r\n    wchar_t *program = Py_DecodeLocale(argv[0], NULL);\r\n    if (program == NULL)\r\n    {\r\n       // errorChannel_->write(QString(\"Fatal error: cannot decode application name.\"));\r\n        return false;\r\n    }\r\n\r\n    Py_SetProgramName(program);\r\n    PyMem_RawFree(program);\r\n\r\n    if (startGui(argc))\r\n    {\r\n        // Create the main window and close the splash after 1.5 seconds.\r\n        MainWindow mainWindow(&library, mediator.data());\r\n\r\n#ifdef Q_OS_WIN\r\n        // Separate console from gui and autoclose console if not launched from command line.\r\n        FreeConsole();\r\n#endif\r\n\r\n        // the release mode\r\n#ifdef NDEBUG\r\n\r\n        // Show the splash screen.\r\n        SplashScreen splash(VersionHelper::createVersionString());\r\n        splash.show();\r\n        splash.showMessage(\"\");\r\n\r\n        application->processEvents();\r\n\r\n        QTimer::singleShot(1500, &splash, SLOT(close()));\r\n        QTimer::singleShot(1500, &mainWindow, SLOT(show()));\r\n        QTimer::singleShot(1600, &mainWindow, SLOT(onLibrarySearch()));\r\n\r\n        // the debug mode\r\n#else\r\n\r\n        mainWindow.show();    \r\n        QCoreApplication::processEvents();\r\n        mainWindow.onLibrarySearch();\r\n\r\n#endif\r\n\r\n        return QCoreApplication::exec();\r\n    }\r\n\r\n    else // Run console.\r\n    {        \r\n        QStringList arguments = application->arguments();\r\n        CommandLineParser parser;\r\n\r\n        // Check for arg errors\r\n        if (parser.process(arguments, mediator.data()))\r\n        {\r\n            return 1;\r\n        }\r\n        \r\n        QScopedPointer<FileChannel> outChannel(new FileChannel(stdout));\r\n        QScopedPointer<FileChannel> errChannel(new FileChannel(stderr));\r\n\r\n        // Excecute according to mode\r\n        if (parser.versionMode())\r\n        {\r\n            return 0;\r\n        }\r\n        else if (parser.commandlineMode()) // Start interactive CLI mode\r\n        {\r\n            library.searchForIPXactFiles();\r\n\r\n            bool interactive = isatty(fileno(stdin));\r\n            PythonInterpreter console(outChannel.data(), errChannel.data(), interactive, application.data());\r\n\r\n            if (console.initialize(interactive) == false)\r\n            {\r\n                return 1;\r\n            }\r\n\r\n            QScopedPointer<StdInputListener> listener(new StdInputListener(&console, application.data()));\r\n            QObject::connect(listener.data(), SIGNAL(inputFailure()), application.data(), SLOT(quit()));\r\n            return application->exec();\r\n        }\r\n        else if (parser.runScriptMode()) // Run script and exit\r\n        {\r\n            library.searchForIPXactFiles();\r\n\r\n            bool interactive = isatty(fileno(stdin));\r\n            PythonInterpreter console(outChannel.data(), errChannel.data(), false, application.data());\r\n\r\n            if (console.initialize(interactive) == false)\r\n            {\r\n                return 1;\r\n            }\r\n\r\n            auto scriptPath = parser.getOptionValue(CommandLineParser::Option::InputScript);\r\n            return console.runFile(scriptPath);\r\n        }\r\n\r\n        return 1;\r\n    }   \r\n}\r\n"
  },
  {
    "path": "mainwindow/mainwindow.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: mainwindow.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Joni-Matti Maatta\r\n// Date: 24.2.2011\r\n//\r\n// Description:\r\n// The main window of Kactus2.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"mainwindow.h\"\r\n\r\n#include \"SplashScreen.h\"\r\n\r\n#include \"VersionHelper.h\"\r\n\r\n#include <mainwindow/DockWidgetHandler.h>\r\n#include <mainwindow/Ribbon/Ribbon.h>\r\n#include <mainwindow/Ribbon/RibbonGroup.h>\r\n#include <mainwindow/NewPages/NewCatalogPage.h>\r\n#include <mainwindow/NewPages/NewComponentPage.h>\r\n#include <mainwindow/NewPages/NewDesignPage.h>\r\n#include <mainwindow/NewPages/NewSWComponentPage.h>\r\n#include <mainwindow/NewPages/NewSWDesignPage.h>\r\n#include <mainwindow/NewPages/NewSystemPage.h>\r\n#include <mainwindow/NewPages/NewComDefinitionPage.h>\r\n#include <mainwindow/NewPages/NewApiDefinitionPage.h>\r\n#include <mainwindow/NewPages/NewBusDefinitionPage.h>\r\n#include <mainwindow/DrawingBoard/DrawingBoard.h>\r\n#include <mainwindow/SaveHierarchy/DocumentTreeBuilder.h>\r\n#include <mainwindow/SaveHierarchy/SaveHierarchyDialog.h>\r\n\r\n#include <common/NameGenerationPolicy.h>\r\n#include <common/dialogs/LibrarySettingsDialog/LibrarySettingsDialog.h>\r\n#include <common/dialogs/NewDesignDialog/NewDesignDialog.h>\r\n#include <common/dialogs/newObjectDialog/newobjectdialog.h>\r\n#include <common/dialogs/listSelectDialog/ListSelectDialog.h>\r\n#include <common/dialogs/propertyPageDialog/PropertyPageDialog.h>\r\n#include <common/graphicsItems/ComponentItem.h>\r\n#include <common/graphicsItems/GraphicsColumnConstants.h>\r\n#include <common/widgets/assistedTextEdit/HighlightStyleDesc.h>\r\n\r\n#include <KactusAPI/KactusAPI.h>\r\n\r\n#include <editors/common/DesignWidgetFactoryImplementation.h>\r\n#include <editors/HWDesign/HWDesignWidget.h>\r\n#include <editors/HWDesign/HWDesignDiagram.h>\r\n#include <editors/SystemDesign/SystemDesignWidget.h>\r\n#include <editors/SystemDesign/SystemDesignDiagram.h>\r\n#include <editors/MemoryDesigner/MemoryDesignDocument.h>\r\n\r\n#include <editors/InterconnectGenerator/InterconnectGeneratorDialog.h>\r\n#include <KactusAPI/include/InterconnectGenerator.h>\r\n\r\n#include <editors/AbstractionDefinitionEditor/AbstractionDefinitionEditor.h>\r\n#include <editors/ApiDefinitionEditor/ApiDefinitionEditor.h>\r\n#include <editors/BusDefinitionEditor/BusDefinitionEditor.h>\r\n#include <editors/ComDefinitionEditor/ComDefinitionEditor.h>\r\n#include <editors/CatalogEditor/CatalogEditor.h>\r\n#include <editors/ComponentEditor/componenteditor.h>\r\n#include <editors/CSourceEditor/CSourceWidget.h>\r\n#include <KactusAPI/include/ExpressionFormatterFactoryImplementation.h>\r\n#include <editors/ConfigurationTools/ViewConfigurer.h>\r\n\r\n#include <KactusAPI/include/IGeneratorPlugin.h>\r\n#include <KactusAPI/include/PluginUtilityAdapter.h>\r\n// #include <Plugins/PluginSystem/ConsolePluginUtility.h>\r\n\r\n#include <settings/SettingsDialog.h>\r\n\r\n\r\n#include <wizards/ComponentWizard/ComponentWizard.h>\r\n#include <wizards/ImportWizard/ImportWizard.h>\r\n\r\n#include <kactusGenerators/DocumentGenerator/documentgenerator.h>\r\n\r\n#include <KactusAPI/include/LibraryHandler.h>\r\n#include <library/LibraryUtils.h>\r\n\r\n#include <IPXACTmodels/common/VLNV.h>\r\n#include <IPXACTmodels/common/ConfigurableVLNVReference.h>\r\n\r\n#include <IPXACTmodels/Catalog/Catalog.h>\r\n\r\n#include <IPXACTmodels/Component/Component.h>\r\n#include <IPXACTmodels/Component/Model.h>\r\n#include <IPXACTmodels/Component/FileSet.h>\r\n#include <IPXACTmodels/Component/File.h>\r\n#include <IPXACTmodels/Component/View.h>\r\n\r\n#include <IPXACTmodels/Design/Design.h>\r\n#include <IPXACTmodels/DesignConfiguration/DesignConfiguration.h>\r\n#include <IPXACTmodels/AbstractionDefinition/AbstractionDefinition.h>\r\n#include <IPXACTmodels/BusDefinition/BusDefinition.h>\r\n\r\n#include <IPXACTmodels/kactusExtensions/ComDefinition.h>\r\n#include <IPXACTmodels/kactusExtensions/ApiDefinition.h>\r\n#include <IPXACTmodels/kactusExtensions/ApiInterface.h>\r\n#include <IPXACTmodels/kactusExtensions/SystemView.h>\r\n\r\n#include <QCoreApplication>\r\n#include <QApplication>\r\n#include <QSettings>\r\n#include <QStringList>\r\n#include <QMenu>\r\n#include <QAction>\r\n#include <QFileDialog>\r\n#include <QDockWidget>\r\n#include <QMessageBox>\r\n#include <QFileInfo>\r\n#include <QFile>\r\n#include <QTextStream>\r\n#include <QUrl>\r\n#include <QCursor>\r\n#include <QDesktopServices>\r\n#include <QPainter>\r\n#include <QDateTime>\r\n#include <QStatusBar>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MainWindow::MainWindow()\r\n//-----------------------------------------------------------------------------\r\nMainWindow::MainWindow(LibraryHandler* library, MessageMediator* messageChannel, QWidget *parent):\r\nQMainWindow(parent),\r\nlibraryHandler_(library),\r\ndesignTabs_(0),\r\nleftToolbar_(new QToolBar(this)),\r\nrightToolbar_(new QToolBar(this)),\r\ndockHandler_(new DockWidgetHandler(library, messageChannel, leftToolbar_, rightToolbar_, this)),\r\nribbon_(0), \r\nstatusBar_(new QStatusBar(this)),\r\nscriptEditor_(new PythonSourceEditor(this)),\r\nactNew_(0),\r\nactMainSave_(0),\r\nactSave_(0),\r\nactSaveAs_(0),\r\nactSaveHierarchy_(0),\r\nactPrint_(0),\r\nactImageExport_(0),\r\neditGroup_(0),\r\nactUndo_(0),\r\nactRedo_(0),\r\nactLibraryLocations_(0),\r\nactLibrarySearch_(0),\r\nactCheckIntegrity_(0),\r\ngenerationGroup_(0),\r\npluginActionGroup_(0),\r\nactGenDocumentation_(0),\r\nactRunImport_(0),\r\ndiagramToolsGroup_(0),\r\nactAddColumn_(0),\r\nactToolSelect_(0),\r\nactToolConnect_(0),\r\nactToolInterface_(0),\r\nactToolDraft_(0),\r\nactToolToggleOffPage_(0),\r\nactToolLabel_(0),\r\nactZoomIn_(0),\r\nactZoomOut_(0),\r\nactZoomOriginal_(0),\r\nactFitInView_(0),\r\nactVisibleDocks_(0),\r\nactVisibilityControl_(0),\r\nopenMemoryDesignerAction_(0),\r\nopenInterconnectGenerator_(0),\r\nactWorkspaces_(0),\r\nprotectGroup_(0),\r\nactRefresh_(0),\r\nactProtect_(0),\r\nactSettings_(0),\r\nactAbout_(0),\r\nactHelp_(0),\r\nactExit_(0),\r\nconfigurationToolsGroup_(0),\r\nactionConfigureViews_(0),\r\nfilteringGroup_(0),\r\nactionFilterAddressSpaceChains_(0),\r\nactionCondenseMemoryItems_(0),\r\nactionCondenseFieldItems_(0),\r\nactionExtendFieldItems_(0),\r\nactionFilterSegments_(0),\r\nactionFilterAddressBlocks_(0),\r\nactionFilterRegisters_(0),\r\nactionFilterFields_(0),\r\nactionFilterUnconnectedMemoryItems_(0),\r\nwindowsMenu_(this),\r\nvisibilityMenu_(this),\r\nworkspaceMenu_(this),\r\nworkspace_(this, dockHandler_),\r\nmessageChannel_(messageChannel)\r\n{    \r\n    setWindowTitle(QCoreApplication::applicationName());\r\n    setWindowIcon(QIcon(\":icons/common/graphics/appicon.png\"));\r\n\r\n    // By default, the window is 1024x768 and set to maximized state.\r\n    resize(1024, 768);\r\n    setWindowState(Qt::WindowMaximized);\r\n\r\n    QString defaultStyleSheet(\r\n        \"QCheckBox::indicator:unchecked { image: url(:icons/common/graphics/traffic-light_gray.png);}\"\r\n        \"QCheckBox::indicator:indeterminate { image: url(:icons/common/graphics/traffic-light_green_gray.png);}\"\r\n        \"QCheckBox::indicator:checked { image: url(:icons/common/graphics/traffic-light_green.png);}\"\r\n        \"QGroupBox::title { subcontrol-origin: margin; margin: 0 8px; }\"\r\n        \"QGroupBox::indicator:unchecked {image: url(:icons/common/graphics/traffic-light_gray.png);}\"        \r\n        \"QGroupBox::indicator:checked {image: url(:icons/common/graphics/traffic-light_green.png);}\"\r\n        \"QTableView::indicator:checked {image: url(:icons/common/graphics/checkMark.png);}\"\r\n        \"QTableView::indicator:unchecked {image: none;}\"\r\n        \"QDockWidget::title {background-color: #89B6E2; font-size: 18pt; padding-left: 2px; padding-top: 2px;}\"\r\n        \"*[mandatoryField=\\\"true\\\"] { background-color: LemonChiffon; }\");\r\n    setStyleSheet(defaultStyleSheet);\r\n\r\n    setupToolbars();\r\n    setContextMenuPolicy(Qt::NoContextMenu);\r\n\r\n    // Setup windows.\r\n    setupDrawBoard();\r\n    dockHandler_->setupDockWidgets();\r\n    connectDockHandler();\r\n    setupAndConnectLibraryHandler();\r\n\r\n    setStatusBar(statusBar_);\r\n\r\n    // some actions need the editors so set them up before the actions\r\n    setupActions();\r\n\r\n    // Restore program settings.\r\n    restoreSettings();\r\n\r\n    // don't display empty editors\r\n    updateWindows();\r\n\r\n\r\n    QSplitter* mainSplit = new QSplitter(Qt::Horizontal ,this);\r\n    mainSplit->addWidget(designTabs_);\r\n    mainSplit->addWidget(scriptEditor_);\r\n    scriptEditor_->setVisible(false);\r\n\r\n    setCentralWidget(mainSplit);\r\n\r\n    setCorner(Qt::BottomLeftCorner, Qt::LeftDockWidgetArea);\r\n    setCorner(Qt::BottomRightCorner, Qt::RightDockWidgetArea);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ~MainWindow()\r\n//-----------------------------------------------------------------------------\r\nMainWindow::~MainWindow()\r\n{\r\n    saveSettings();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: mainwindow::onLibrarySearch()\r\n//-----------------------------------------------------------------------------\r\nvoid MainWindow::onLibrarySearch()\r\n{\r\n    QApplication::setOverrideCursor(Qt::WaitCursor);\r\n    libraryHandler_->searchForIPXactFiles();\r\n    QApplication::restoreOverrideCursor();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: restoreSettings()\r\n//-----------------------------------------------------------------------------\r\nvoid MainWindow::restoreSettings()\r\n{\r\n    workspace_.restoreSettings();\r\n    updateWorkspaceMenu();\r\n    actWorkspaces_->setText(workspace_.getCurrentWorkspace());\r\n\r\n    dockHandler_->applySettings();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: saveSettings()\r\n//-----------------------------------------------------------------------------\r\nvoid MainWindow::saveSettings()\r\n{\r\n    workspace_.saveSettings();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: updateWorkspaceMenu()\r\n//-----------------------------------------------------------------------------\r\nvoid MainWindow::updateWorkspaceMenu()\r\n{\r\n    workspace_.updateWorkspaceMenu(&workspaceMenu_);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: loadWorkspace()\r\n//-----------------------------------------------------------------------------\r\nvoid MainWindow::loadWorkspace(QString const& workspaceName)\r\n{\r\n    workspace_.loadWorkspace(workspaceName);\r\n\r\n    updateWindows();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: mainwindow::setupActions()\r\n//-----------------------------------------------------------------------------\r\nvoid MainWindow::setupActions()\r\n{\r\n    // the action to create a new hierarchical component\r\n    actNew_ = new QAction(QIcon(\":/icons/common/graphics/file-new.png\"), QString(), this);\r\n    actNew_->setShortcut(QKeySequence::New);\r\n    QString tooltipNew = tr(\"New (%1)\").arg(actNew_->shortcut().toString(QKeySequence::NativeText));\r\n    actNew_->setToolTip(tooltipNew);\r\n    connect(actNew_, SIGNAL(triggered()), this, SLOT(createNew()));\r\n\r\n    actSave_ = new QAction(QIcon(\":/icons/common/graphics/file-save.png\"), QString(\"Save\"), this);\r\n    actSave_->setShortcut(QKeySequence::Save);\r\n    QString tooltipSave = tr(\"Save (%1)\").arg(actSave_->shortcut().toString(QKeySequence::NativeText));\r\n    actSave_->setToolTip(tooltipSave);\r\n    actSave_->setEnabled(false);\r\n    connect(actSave_, SIGNAL(triggered()), designTabs_, SLOT(saveCurrentDocument()));\r\n    connect(designTabs_, SIGNAL(documentModifiedChanged(bool)),\r\n        actSave_, SLOT(setEnabled(bool)), Qt::UniqueConnection);\r\n\r\n\tactMainSave_ = new QAction(QIcon(\":/icons/common/graphics/file-save.png\"), QString(), this);\r\n\tactMainSave_->setToolTip(tooltipSave);\r\n\tactMainSave_->setEnabled(true);\r\n\tconnect(actMainSave_, SIGNAL(triggered()), this, SLOT(passSaveToActSave()));\r\n\r\n    actSaveAs_ = new QAction(QIcon(\":/icons/common/graphics/file-save-as.png\"), QString(\"Save as\"), this);\r\n    actSaveAs_->setShortcut(QKeySequence::SaveAs);\r\n    QString tooltipSaveAs = tr(\"Save As\");\r\n    actSaveAs_->setToolTip(tooltipSaveAs);\r\n    actSaveAs_->setEnabled(false);\r\n    connect(actSaveAs_, SIGNAL(triggered()), designTabs_, SLOT(saveCurrentDocumentAs()));\r\n\r\n    actSaveAll_ = new QAction(QIcon(\":/icons/common/graphics/file-save_all.png\"),\r\n        QString(\"Save all\"), this);\r\n    actSaveAll_->setShortcut(QKeySequence(\"Ctrl+Shift+S\"));\r\n    QString tooltipSaveAll = tr(\"Save All (%1)\").arg(actSaveAll_->shortcut().toString(QKeySequence::NativeText));\r\n    actSaveAll_->setToolTip(tooltipSaveAll);\r\n    actSaveAll_->setStatusTip(tooltipSaveAll);\r\n    connect(actSaveAll_, SIGNAL(triggered()), this, SLOT(saveAll()));\r\n\r\n    actSaveHierarchy_ = new QAction(QIcon(\":/icons/common/graphics/file-save_all.png\"),\r\n        tr(\"Save Hierarchy\"), this);\r\n    actSaveHierarchy_->setEnabled(false);\r\n    connect(actSaveHierarchy_, SIGNAL(triggered()), this, SLOT(saveCurrentDocumentHierarchy()));\r\n\r\n    auto saveMenu = new QMenu(this);\r\n    saveMenu->addAction(actSave_);\r\n    saveMenu->addAction(actSaveAs_);\r\n    saveMenu->addAction(actSaveAll_);\r\n    saveMenu->addAction(actSaveHierarchy_);\r\n\tactMainSave_->setMenu(saveMenu);\r\n\r\n    actPrint_ = new QAction(QIcon(\":/icons/common/graphics/file-print.png\"), QString(), this);\r\n    actPrint_->setShortcut(QKeySequence::Print);\r\n    QString tooltipPrint = tr(\"Print (%1)\").arg(actPrint_->shortcut().toString(QKeySequence::NativeText));\r\n    actPrint_->setToolTip(tooltipPrint);\r\n    actPrint_->setStatusTip(tooltipPrint);\r\n    actPrint_->setEnabled(false);\r\n    connect(actPrint_, SIGNAL(triggered()), designTabs_, SLOT(printCurrentDocument()));\r\n\r\n    actImageExport_ = new QAction(QIcon(\":/icons/common/graphics/export.png\"), tr(\"Export image\"), this);\r\n    actImageExport_->setEnabled(false);\r\n    connect(actImageExport_, SIGNAL(triggered()), designTabs_, SLOT(exportCurrentDocumentAsImage()));\r\n\r\n    actUndo_ = new QAction(QIcon(\":/icons/common/graphics/edit-undo.png\"), QString(), this);\r\n    actUndo_->setShortcut(QKeySequence::Undo);\r\n    QString tooltipUndo = tr(\"Undo (%1)\").arg(actUndo_->shortcut().toString(QKeySequence::NativeText));\r\n    actUndo_->setToolTip(tooltipUndo);\r\n    actUndo_->setStatusTip(tooltipUndo);\r\n    connect(actUndo_, SIGNAL(triggered()), this, SLOT(undo()));\r\n\r\n    actRedo_ = new QAction(QIcon(\":/icons/common/graphics/edit-redo.png\"), QString(), this);\r\n    actRedo_->setShortcut(QKeySequence::Redo);\r\n    QString tooltipRedo = tr(\"Redo (%1)\").arg(actRedo_->shortcut().toString(QKeySequence::NativeText));\r\n    actRedo_->setToolTip(tooltipRedo);\r\n    actRedo_->setStatusTip(tooltipRedo);\r\n    connect(actRedo_, SIGNAL(triggered()), this, SLOT(redo()));\r\n\r\n    actLibraryLocations_ = new QAction(QIcon(\":/icons/common/graphics/library-config.png\"),\r\n        tr(\"Configure Library\"), this);\r\n    connect(actLibraryLocations_, SIGNAL(triggered()), this, SLOT(setLibraryLocations()), Qt::UniqueConnection);\r\n\r\n    // the action to search for IP-Xact documents in file system\r\n    actLibrarySearch_ = new QAction(QIcon(\":/icons/common/graphics/library-refresh.png\"),\r\n        tr(\"Refresh Library\"), this);\r\n    connect(actLibrarySearch_, SIGNAL(triggered()),\tthis, SLOT(onLibrarySearch()), Qt::UniqueConnection);\r\n\r\n    // Check the library integrity\r\n    actCheckIntegrity_ = new QAction(QIcon(\":/icons/common/graphics/checkIntegrity.png\"),\r\n        tr(\"View Library Integrity Report\"), this);\r\n    connect(actCheckIntegrity_, SIGNAL(triggered()),\r\n        dockHandler_, SIGNAL(generateIntegrityReport()), Qt::UniqueConnection);\r\n\r\n    // initialize the action to generate documentation for the component/design\r\n    actGenDocumentation_ = new QAction(QIcon(\":icons/common/graphics/documentation.png\"),\r\n        tr(\"Documentation\"), this);\r\n    connect(actGenDocumentation_, SIGNAL(triggered()), this, SLOT(generateDoc()), Qt::UniqueConnection);\r\n\r\n    generationMenu_ = new QMenu(this);\r\n\r\n    actGenerate_ = new QAction(QIcon(\":icons/common/graphics/automation.png\"), tr(\"Run Generator\"), this);   \r\n    actGenerate_->setMenu(generationMenu_);\r\n    connect(actGenerate_, SIGNAL(triggered()), this, SLOT(onGenerate()), Qt::UniqueConnection);\r\n\r\n    pluginActionGroup_ = new QActionGroup(this);\r\n\r\n    // initialize the action to run import wizard for component.\r\n    actRunImport_ = new QAction(QIcon(\":icons/common/graphics/import.png\"), tr(\"Import File to Component\"), this);\r\n    connect(actRunImport_, SIGNAL(triggered()), this, SLOT(onRunImportWizard()), Qt::UniqueConnection);\r\n\r\n    // Initialize the action to set draw mode to selection mode.\r\n    actToolSelect_ = new QAction(QIcon(\":/icons/common/graphics/tool-select.png\"), tr(\"Select Tool\"), this);\r\n    actToolSelect_->setCheckable(true);\r\n    actToolSelect_->setChecked(true);\r\n\r\n    // Initialize the action to add a new column.\r\n    actAddColumn_ = new QAction(QIcon(\":/icons/common/graphics/diagram-add-column.png\"), tr(\"Add Column\"), this);\r\n    connect(actAddColumn_, SIGNAL(triggered()), this, SLOT(addColumn()), Qt::UniqueConnection);\r\n\r\n    // Initialize the action to set draw mode to connection mode.\r\n    actToolConnect_ = new QAction(QIcon(\":/icons/common/graphics/tool-interconnection.png\"),\r\n        QString(), this);\r\n    actToolConnect_->setCheckable(true);\r\n    actToolConnect_->setShortcut(QKeySequence(Qt::CTRL | Qt::Key_Space));\r\n    QString tooltipToolConnect = tr(\"Interconnection Tool (%1)\").arg(actToolConnect_->shortcut().toString(QKeySequence::NativeText));\r\n    actToolConnect_->setToolTip(tooltipToolConnect);\r\n    actToolConnect_->setStatusTip(tooltipToolConnect);\r\n\r\n    // Initialize the action to set draw mode to interface mode.\r\n    actToolInterface_ = new QAction(QIcon(\":/icons/common/graphics/tool-interface.png\"), tr(\"Interface Tool\"), this);\r\n    actToolInterface_->setCheckable(true);\r\n\r\n    actToolDraft_ = new QAction(QIcon(\":/icons/common/graphics/tool-drafting.png\"), QString(), this);\r\n    actToolDraft_->setCheckable(true);\r\n    actToolDraft_->setShortcut(QKeySequence(Qt::CTRL | Qt::Key_D));\r\n    QString tooltipToolDraft = tr(\"Drafting Tool (%1)\").arg(actToolDraft_->shortcut().toString(QKeySequence::NativeText));\r\n    actToolDraft_->setToolTip(tooltipToolDraft);\r\n    actToolDraft_->setStatusTip(tooltipToolDraft);\r\n\r\n    actToolToggleOffPage_ = new QAction(QIcon(\":/icons/common/graphics/tool-toggle_offpage.png\"),\r\n        QString(), this);\r\n    actToolToggleOffPage_->setCheckable(true);\r\n    actToolToggleOffPage_->setShortcut(QKeySequence(Qt::CTRL | Qt::Key_E));\r\n    QString tooltipToolToggleOffPage = tr(\"Toggle Off-Page Tool (%1)\").arg(actToolToggleOffPage_->shortcut().toString(QKeySequence::NativeText));\r\n    actToolToggleOffPage_->setToolTip(tooltipToolToggleOffPage);\r\n    actToolToggleOffPage_->setStatusTip(tooltipToolToggleOffPage);\r\n\r\n    actToolLabel_ = new QAction(QIcon(\":/icons/common/graphics/balloon.png\"), QString(), this);\r\n    actToolLabel_->setCheckable(true);\r\n    actToolLabel_->setShortcut(QKeySequence(Qt::CTRL | Qt::Key_Q));\r\n    QString tooltipToolLabel = tr(\"Sticky Note Tool (%1)\").arg(actToolLabel_->shortcut().toString(QKeySequence::NativeText));\r\n    actToolLabel_->setToolTip(tooltipToolLabel);\r\n    actToolLabel_->setStatusTip(tooltipToolLabel);\r\n\r\n    modeActionGroup_ = new QActionGroup(this);\r\n    modeActionGroup_->setExclusive(true);\r\n    modeActionGroup_->addAction(actToolSelect_);\r\n    modeActionGroup_->addAction(actToolConnect_);\r\n    modeActionGroup_->addAction(actToolInterface_);\r\n    modeActionGroup_->addAction(actToolDraft_);\r\n    modeActionGroup_->addAction(actToolToggleOffPage_);\r\n    modeActionGroup_->addAction(actToolLabel_);\r\n    connect(modeActionGroup_, SIGNAL(triggered(QAction *)), this, SLOT(drawModeChange(QAction *)));\r\n\r\n    //! Initialize the action to condense memory graphics items.\r\n    actionCondenseMemoryItems_ = new QAction(QIcon(\":icons/common/graphics/compressMemoryItems.png\"),\r\n        tr(\"Compress Memory Items\"), this);\r\n    actionCondenseMemoryItems_->setCheckable(true);\r\n    connect(actionCondenseMemoryItems_, SIGNAL(triggered(bool)),\r\n        this, SLOT(onCondenseMemoryItems(bool)), Qt::UniqueConnection);\r\n\r\n    //! Initialize the action to filter chained address space memory connections.\r\n    actionFilterAddressSpaceChains_ = new QAction(QIcon(\":/icons/common/graphics/addressSpaceFilter.png\"),\r\n        tr(\"Address Space Filter\"), this);\r\n    actionFilterAddressSpaceChains_->setCheckable(true);\r\n    connect(actionFilterAddressSpaceChains_, SIGNAL(triggered(bool)),\r\n        this, SLOT(onFilterAddressSpaceChains(bool)), Qt::UniqueConnection);\r\n\r\n    //! Initialize the action to condense field graphics items.\r\n    actionCondenseFieldItems_ = new QAction(QIcon(\":icons/common/graphics/compressFields.png\"),\r\n        tr(\"Compress Field Items\"), this);\r\n    connect(actionCondenseFieldItems_, SIGNAL(triggered()),\r\n        this, SLOT(onCondenseFieldItems()), Qt::UniqueConnection);\r\n\r\n    //! Initialize the action to extend field graphics items.\r\n    actionExtendFieldItems_ = new QAction(QIcon(\":icons/common/graphics/extendFields.png\"),\r\n        tr(\"Extend Field Items\"), this);\r\n    connect(actionExtendFieldItems_, SIGNAL(triggered()), this, SLOT(onExtendFieldItems()), Qt::UniqueConnection);\r\n\r\n    //! Initialize the action to filter address space segments.\r\n    actionFilterSegments_ = new QAction(QIcon(\":icons/common/graphics/filterSegments.png\"),\r\n        tr(\"Filter Segments\"), this);\r\n    actionFilterSegments_->setCheckable(true);\r\n    connect(actionFilterSegments_, SIGNAL(triggered(bool)),\r\n        this, SLOT(onFilterSegments(bool)), Qt::UniqueConnection);\r\n\r\n    //! Initialize the action to filter memory map address blocks.\r\n    actionFilterAddressBlocks_ = new QAction(QIcon(\":icons/common/graphics/filterAddressBlocks.png\"),\r\n        tr(\"Filter Address Blocks\"), this);\r\n    actionFilterAddressBlocks_->setCheckable(true);\r\n    connect(actionFilterAddressBlocks_, SIGNAL(triggered(bool)),\r\n        this, SLOT(onFilterAddressBlocks(bool)), Qt::UniqueConnection);\r\n\r\n    //! Initialize the action to filter address block registers.\r\n    actionFilterRegisters_ = new QAction(QIcon(\":icons/common/graphics/filterRegisters.png\"),\r\n        tr(\"Filter Registers\"), this);\r\n    actionFilterRegisters_->setCheckable(true);\r\n    connect(actionFilterRegisters_, SIGNAL(triggered(bool)),\r\n        this, SLOT(onFilterRegisters(bool)), Qt::UniqueConnection);\r\n\r\n    //! Initialize the action to filter register fields.\r\n    actionFilterFields_ = new QAction(QIcon(\":icons/common/graphics/filterFields.png\"), tr(\"Filter Fields\"), this);\r\n    actionFilterFields_->setCheckable(true);\r\n    connect(actionFilterFields_, SIGNAL(triggered(bool)), this, SLOT(onFilterFields(bool)), Qt::UniqueConnection);\r\n\r\n    //! Initialize the action to filter unconnected memory items.\r\n    actionFilterUnconnectedMemoryItems_ = new QAction(QIcon(\r\n        \":icons/common/graphics/filterUnconnectedMemoryItems.png\"), tr(\"Filter unconnected items\"), this);\r\n    actionFilterUnconnectedMemoryItems_->setCheckable(true);\r\n    connect(actionFilterUnconnectedMemoryItems_, SIGNAL(triggered(bool)),\r\n        this, SLOT(onFilterUnconnectedMemoryItems(bool)), Qt::UniqueConnection);\r\n\r\n    //! Initialize the action to filter memory overlap items.\r\n    actionFilterMemoryOverlap_ = new QAction(QIcon(\":icons/common/graphics/filterMemoryOverlap.png\"),\r\n        tr(\"Filter memory overlap markers\"), this);\r\n    actionFilterMemoryOverlap_->setCheckable(true);\r\n    connect(actionFilterMemoryOverlap_, SIGNAL(triggered(bool)), \r\n        this, SLOT(onFilterMemoryOverlapItems(bool)), Qt::UniqueConnection);\r\n\r\n    // Initialize the action to zoom in.\r\n    actZoomIn_ = new QAction(QIcon(\":/icons/common/graphics/view-zoom_in.png\"), tr(\"Zoom In\"), this);\r\n    actZoomIn_->setEnabled(false);\r\n    actZoomIn_->setVisible(false);\r\n    connect(actZoomIn_, SIGNAL(triggered()), this, SLOT(zoomIn()));\r\n\r\n    // Initialize the action to zoom out.\r\n    actZoomOut_ = new QAction(QIcon(\":/icons/common/graphics/view-zoom_out.png\"), tr(\"Zoom Out\"), this);\r\n    actZoomOut_->setEnabled(false);\r\n    actZoomOut_->setVisible(false);\r\n    connect(actZoomOut_, SIGNAL(triggered()), this, SLOT(zoomOut()));\r\n\r\n    // Initialize the action to reset the zoom to original 1:1 ratio.\r\n    actZoomOriginal_ = new QAction(QIcon(\":/icons/common/graphics/view-zoom_original.png\"),\r\n        tr(\"Original 1:1 Zoom\"), this);\r\n    actZoomOriginal_->setEnabled(false);\r\n    actZoomOriginal_->setVisible(false);\r\n    connect(actZoomOriginal_, SIGNAL(triggered()), this, SLOT(zoomOriginal()));\r\n\r\n    // Initialize the action to fit the document into the view.\r\n    actFitInView_ = new QAction(QIcon(\":/icons/common/graphics/view-fit_best.png\"),\r\n        tr(\"Fit Document to View\"), this);\r\n    actFitInView_->setEnabled(false);\r\n    actFitInView_->setVisible(false);\r\n    connect(actFitInView_, SIGNAL(triggered()), this, SLOT(fitInView()));\r\n\r\n    // the action for user to select the visible docks\r\n    actVisibleDocks_ = new QAction(QIcon(\":icons/common/graphics/dockSelect.png\"), tr(\"Visible Windows\"), this);\r\n    actVisibleDocks_->setMenu(&windowsMenu_);\r\n    connect(actVisibleDocks_, SIGNAL(triggered()), this, SLOT(selectVisibleDocks()), Qt::UniqueConnection);\r\n\r\n    actVisibleScript_ = new QAction(tr(\"Script editor\"), this);\r\n    actVisibleScript_->setCheckable(true);\r\n    actVisibleScript_->setChecked(false);\r\n    connect(actVisibleScript_, SIGNAL(toggled(bool)), scriptEditor_, SLOT(setVisible(bool)));\r\n\r\n\r\n    // Initialize the action to manage visibility control.\r\n    actVisibilityControl_ = new QAction(QIcon(\":icons/common/graphics/visibility.png\"), tr(\"Visibility Control\"), this);\r\n    actVisibilityControl_->setEnabled(false);\r\n    actVisibilityControl_->setVisible(false);\r\n    actVisibilityControl_->setMenu(&visibilityMenu_);\r\n    connect(actVisibilityControl_, SIGNAL(triggered()), this, SLOT(openVisibilityControlMenu()), Qt::UniqueConnection);\r\n    connect(&visibilityMenu_, SIGNAL(triggered(QAction*)), this, SLOT(onVisibilityControlToggled(QAction*)));\r\n\r\n    // Initialize the action for opening memory designer.\r\n    openMemoryDesignerAction_ = new QAction(QIcon(\":icons/common/graphics/memoryDesigner.png\"), tr(\"Memory Designer\"), this);\r\n    openMemoryDesignerAction_->setVisible(false);\r\n    connect(openMemoryDesignerAction_, SIGNAL(triggered()), this, SLOT(openMemoryDesign()), Qt::UniqueConnection);\r\n\r\n    // Initialize the action for opening interconnect generator.\r\n    openInterconnectGenerator_ = new QAction(QIcon(\":icons/common/graphics/interconnectGenerator.png\"), tr(\"Interconnect Generator\"), this);\r\n    openInterconnectGenerator_->setVisible(false);\r\n    connect(openInterconnectGenerator_, SIGNAL(triggered()), this, SLOT(onInterconnectGenerate()), Qt::UniqueConnection);\r\n\r\n    // Initialize the action to manage workspaces.\r\n    actWorkspaces_ = new QAction(QIcon(\":icons/common/graphics/workspace.png\"),\ttr(\"Workspaces\"), this);\r\n    connect(actWorkspaces_, SIGNAL(triggered()), this, SLOT(openWorkspaceMenu()), Qt::UniqueConnection);\r\n    actWorkspaces_->setMenu(&workspaceMenu_);\r\n\r\n    actRefresh_ = new QAction(QIcon(\":/icons/common/graphics/refresh.png\"), QString(), this);\r\n    actRefresh_->setShortcut(QKeySequence(\"F5\"));\r\n    QString tooltipRefresh = tr(\"Refresh (%1)\").arg(actRefresh_->shortcut().toString(QKeySequence::NativeText));\r\n    actRefresh_->setToolTip(tooltipRefresh);\r\n    actRefresh_->setStatusTip(tooltipRefresh);\r\n    connect(actRefresh_, SIGNAL(triggered(bool)), designTabs_, SLOT(refreshCurrentDocument()));\r\n\r\n    actProtect_ = new QAction(QIcon(\":/icons/common/graphics/protection-unlocked.png\"), QString(), this);\r\n    actProtect_->setCheckable(true);\r\n    actProtect_->setEnabled(false);\r\n    actProtect_->setShortcut(QKeySequence(\"Ctrl+L\"));\r\n    QString tooltipProtect = tr(\"Unlocked (%1)\").arg(actProtect_->shortcut().toString(QKeySequence::NativeText));\r\n    actProtect_->setToolTip(tooltipProtect);\r\n    actProtect_->setStatusTip(tooltipProtect);\r\n    connect(actProtect_, SIGNAL(triggered(bool)), this, SLOT(changeProtection(bool)));\r\n\r\n    // Initialize the action to open Kactus2 settings.\r\n    actSettings_ = new QAction(QIcon(\":/icons/common/graphics/settings-general.png\"), tr(\"Settings\"), this);\r\n    connect(actSettings_, SIGNAL(triggered()), this, SLOT(openSettings()));\r\n\r\n    // Initialize the action to open the about box.\r\n    actAbout_ = new QAction(QIcon(\":/icons/common/graphics/system-about.png\"), tr(\"About\"), this);\r\n    connect(actAbout_, SIGNAL(triggered()), this, SLOT(showAbout()), Qt::UniqueConnection);\r\n\r\n    // Initialize the action to open the help window.\r\n    actHelp_ = new QAction(QIcon(\":/icons/common/graphics/system-help.png\"), QString(), this);\r\n    actHelp_->setShortcut(QKeySequence::HelpContents);\r\n    QString tooltipHelp = tr(\"Help (%1)\").arg(actHelp_->shortcut().toString(QKeySequence::NativeText));\r\n    actHelp_->setToolTip(tooltipHelp);\r\n    actHelp_->setStatusTip(tooltipHelp);\r\n    connect(actHelp_, SIGNAL(triggered()), dockHandler_, SLOT(showHelp()), Qt::UniqueConnection);\r\n\r\n    // Initialize the action to exit the program.\r\n    actExit_ = new QAction(QIcon(\":/icons/common/graphics/system-exit.png\"), tr(\"Exit\"), this);\r\n    connect(actExit_, SIGNAL(triggered()), this, SLOT(close()), Qt::UniqueConnection);\r\n\r\n    actionConfigureViews_ = new QAction(QIcon(\":/icons/common/graphics/viewConfiguration.png\"),\r\n        tr(\"View Configuration\"), this);\r\n    connect(actionConfigureViews_, SIGNAL(triggered()), this, SLOT(onConfigureViews()), Qt::UniqueConnection);\r\n\r\n    connectVisibilityControls();\r\n\r\n    setupMenus();\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: mainwindow::passSaveToActSave()\r\n//-----------------------------------------------------------------------------\r\nvoid MainWindow::passSaveToActSave()\r\n{\r\n    if (actSave_->isEnabled())\r\n    {\r\n        actSave_->trigger();\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: mainwindow::onAdjustVisibilityInWindow()\r\n//-----------------------------------------------------------------------------\r\nvoid MainWindow::onAdjustVisibilityInWindow(TabDocument::SupportedWindows type, bool show)\r\n{\r\n    int tabCount = designTabs_->count();\r\n    QWidget* currentWidget = nullptr;\r\n    if (tabCount > 0)\r\n    {\r\n        currentWidget = designTabs_->currentWidget();\r\n    }\r\n\r\n    dockHandler_->setWindowVisibilityForSupportedWindow(currentWidget, type, show);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: setupMenus()\r\n//-----------------------------------------------------------------------------\r\nvoid MainWindow::setupMenus()\r\n{\r\n    ribbon_ = new Ribbon(this);\r\n    addToolBar(Qt::TopToolBarArea, ribbon_);\r\n\r\n    // The \"File\" group.\r\n    RibbonGroup* fileGroup = new RibbonGroup(tr(\"File\"), ribbon_);\r\n    fileGroup->addAction(actNew_);\r\n    fileGroup->addAction(actMainSave_);\r\n    fileGroup->addAction(actPrint_);\r\n    fileGroup->addAction(actImageExport_);\r\n    fileGroup->addAction(actRunImport_);\r\n\r\n    ribbon_->addGroup(fileGroup);\r\n    actRunImport_->setVisible(false);\r\n    actRunImport_->setEnabled(false);\r\n\r\n    // The \"Library\" group.\r\n    RibbonGroup* libGroup = new RibbonGroup(tr(\"Library\"), ribbon_);\r\n    libGroup->addAction(actLibraryLocations_);\r\n    libGroup->addAction(actLibrarySearch_);\r\n    libGroup->addAction(actCheckIntegrity_);\r\n    ribbon_->addGroup(libGroup);\r\n\r\n    // The \"protection\" group\r\n    protectGroup_ = new RibbonGroup(tr(\"Protection\"), ribbon_);\r\n    protectGroup_->addAction(actProtect_);\r\n\r\n    protectAction_ = ribbon_->addGroup(protectGroup_); \r\n    protectAction_->setVisible(false);\r\n\r\n    // The \"Edit\" group.\r\n    editGroup_ = new RibbonGroup(tr(\"Edit\"), ribbon_);\r\n    editGroup_->addAction(actRefresh_);\r\n    editGroup_->addAction(actUndo_);\r\n    editGroup_->addAction(actRedo_);\r\n\r\n    editAction_ = ribbon_->addGroup(editGroup_);\r\n    editAction_->setVisible(false);\r\n    editAction_->setEnabled(false);\r\n\r\n    // The \"Generation\" group.\r\n    generationGroup_ = new RibbonGroup(tr(\"Generation\"), ribbon_);\r\n    generationGroup_->addAction(actGenerate_);\r\n\r\n    generationAction_ = ribbon_->addGroup(generationGroup_);\r\n    generationAction_->setVisible(false);\r\n    generationAction_->setEnabled(false);\r\n\r\n    createGeneratorPluginActions();\r\n\r\n    //! The \"Diagram Tools\" group.\r\n    diagramToolsGroup_ = new RibbonGroup(tr(\"Diagram Tools\"), ribbon_);\r\n    diagramToolsGroup_->addAction(actToolSelect_);\r\n    diagramToolsGroup_->addAction(actToolConnect_);\r\n    diagramToolsGroup_->addAction(actToolInterface_);\r\n    diagramToolsGroup_->addAction(actToolDraft_);\r\n    diagramToolsGroup_->addAction(actToolToggleOffPage_);\r\n    diagramToolsGroup_->addAction(actToolLabel_);\r\n    diagramToolsGroup_->addAction(actAddColumn_);\r\n\r\n    diagramToolsAction_ = ribbon_->addGroup(diagramToolsGroup_);\r\n    diagramToolsAction_->setVisible(false);\r\n\r\n    //! The \"Filtering tools\" group.\r\n    filteringGroup_ = new RibbonGroup(tr(\"Filtering Tools\"), ribbon_);\r\n    filteringGroup_->addAction(actionFilterSegments_);\r\n    filteringGroup_->addAction(actionFilterAddressBlocks_);\r\n    filteringGroup_->addAction(actionFilterRegisters_);\r\n    filteringGroup_->addAction(actionFilterFields_);\r\n    filteringGroup_->addAction(actionFilterUnconnectedMemoryItems_);\r\n    filteringGroup_->addAction(actionFilterAddressSpaceChains_);\r\n    filteringGroup_->addAction(actionCondenseMemoryItems_);\r\n    filteringGroup_->addAction(actionCondenseFieldItems_);\r\n    filteringGroup_->addAction(actionExtendFieldItems_);\r\n    filteringGroup_->addAction(actionFilterMemoryOverlap_);\r\n\r\n    filteringAction_ = ribbon_->addGroup(filteringGroup_);\r\n    filteringAction_->setVisible(false);\r\n    filteringAction_->setEnabled(true);\r\n\r\n    //! The \"View\" group.\r\n    RibbonGroup* viewGroup = new RibbonGroup(tr(\"View\"), ribbon_);\r\n    viewGroup->addAction(actVisibleDocks_);\r\n    viewGroup->addAction(actZoomIn_);\r\n    viewGroup->addAction(actZoomOut_);\r\n    viewGroup->addAction(actZoomOriginal_);\r\n    viewGroup->addAction(actFitInView_);\r\n    viewGroup->addAction(actVisibilityControl_);\r\n\r\n    ribbon_->addGroup(viewGroup);\r\n\r\n    //! The \"Configuration tools\" group.\r\n    configurationToolsGroup_ = new RibbonGroup(tr(\"Configuration Tools\"), ribbon_);\r\n    configurationToolsGroup_->addAction(actionConfigureViews_);\r\n    configurationToolsGroup_->addAction(openMemoryDesignerAction_);\r\n    configurationToolsGroup_->addAction(openInterconnectGenerator_);\r\n\r\n    configurationToolsAction_ = ribbon_->addGroup(configurationToolsGroup_);\r\n    configurationToolsAction_->setVisible(false);\r\n    configurationToolsAction_->setEnabled(false);\r\n\r\n    //! The \"Workspace\" group.\r\n    RibbonGroup* workspacesGroup = new RibbonGroup(tr(\"Workspace\"), ribbon_);\r\n    workspacesGroup->addAction(actWorkspaces_);\r\n    workspacesGroup->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);\r\n    ribbon_->addGroup(workspacesGroup);\r\n\r\n    connect(&workspace_, SIGNAL(requestMenuUpdate()), this, SLOT(updateWorkspaceMenu()), Qt::UniqueConnection);\r\n    connect(&workspace_, SIGNAL(workspaceChanged(QString const&)), \r\n        this, SLOT(onWorkspaceChanged(QString const&)), Qt::UniqueConnection);\r\n\r\n    //! The \"System\" group.\r\n    RibbonGroup* sysGroup = new RibbonGroup(tr(\"System\"), ribbon_);\r\n    sysGroup->addAction(actSettings_);\r\n    sysGroup->addAction(actHelp_);\r\n    sysGroup->addAction(actAbout_);\r\n    sysGroup->addAction(actExit_);\r\n\r\n    ribbon_->addGroup(sysGroup);\r\n\r\n\r\n    // the menu to display the dock widgets\r\n    windowsMenu_.addAction(actVisibleScript_);\r\n    windowsMenu_.addSeparator();\r\n    dockHandler_->setupVisibilityActionMenu(windowsMenu_);\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MainWindow::setupToolbars()\r\n//-----------------------------------------------------------------------------\r\nvoid MainWindow::setupToolbars()\r\n{\r\n    QString toolbarStyle = \"background-color: #DAE1E9\";\r\n\r\n    leftToolbar_->setObjectName(\"leftToolBar\");\r\n    leftToolbar_->setOrientation(Qt::Vertical);\r\n    leftToolbar_->setMovable(false);\r\n    leftToolbar_->setIconSize(QSize(32, 32));\r\n    leftToolbar_->setStyleSheet(toolbarStyle);\r\n\r\n    addToolBar(Qt::LeftToolBarArea, leftToolbar_);\r\n\r\n    rightToolbar_->setObjectName(\"rightToolbar\");\r\n    rightToolbar_->setOrientation(Qt::Vertical);\r\n    rightToolbar_->setMovable(false);\r\n    rightToolbar_->setIconSize(QSize(32, 32));\r\n    rightToolbar_->setStyleSheet(toolbarStyle);\r\n\r\n    addToolBar(Qt::RightToolBarArea, rightToolbar_);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MainWindow::setupDrawBoard()\r\n//-----------------------------------------------------------------------------\r\nvoid MainWindow::setupDrawBoard()\r\n{\r\n    designTabs_ = new DrawingBoard();\r\n    designTabs_->setMovable(true);\r\n    designTabs_->setTabsClosable(true);\r\n\r\n\r\n    connect(designTabs_, SIGNAL(lastDocumentClosed()), this, SLOT(onLastDocumentClosed()), Qt::UniqueConnection);\r\n    connect(designTabs_, SIGNAL(currentChanged(int)), this, SLOT(onDocumentChanged(int)), Qt::UniqueConnection);\r\n\r\n    connect(designTabs_, SIGNAL(documentContentChanged()), this, SLOT(updateMenuStrip()), Qt::UniqueConnection);\r\n    connect(designTabs_, SIGNAL(documentEditStateChanged()), this, SLOT(updateMenuStrip()));\r\n\r\n    connect(designTabs_, SIGNAL(helpUrlRequested(QString const&)),\r\n        this, SIGNAL(helpUrlRequested(QString const&)), Qt::UniqueConnection);\r\n\r\n    connect(designTabs_, SIGNAL(errorMessage(const QString&)),\r\n        dockHandler_, SIGNAL(errorMessage(const QString&)), Qt::UniqueConnection);\r\n    connect(designTabs_, SIGNAL(noticeMessage(const QString&)),\r\n        dockHandler_, SIGNAL(noticeMessage(const QString&)), Qt::UniqueConnection);\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: mainwindow::connectDockHandler()\r\n//-----------------------------------------------------------------------------\r\nvoid MainWindow::connectDockHandler()\r\n{\r\n    connect(this, SIGNAL(errorMessage(QString const&)),\r\n        dockHandler_, SIGNAL(errorMessage(QString const&)), Qt::UniqueConnection);\r\n    connect(this, SIGNAL(noticeMessage(QString const&)),\r\n        dockHandler_, SIGNAL(noticeMessage(QString const&)), Qt::UniqueConnection);\r\n\r\n    connect(this, SIGNAL(helpUrlRequested(QString const&)),\r\n        dockHandler_, SIGNAL(helpUrlRequested(QString const&)), Qt::UniqueConnection);\r\n\r\n    connect(dockHandler_, SIGNAL(designChanged()), this, SLOT(onDesignChanged()), Qt::UniqueConnection);\r\n\r\n    connect(dockHandler_, SIGNAL(statusMessage(QString const&)),\r\n        statusBar_, SLOT(showMessage(QString const&)));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: mainwindow::setupAndConnectLibraryHandler()\r\n//-----------------------------------------------------------------------------\r\nvoid MainWindow::setupAndConnectLibraryHandler()\r\n{\r\n    connect(libraryHandler_, SIGNAL(openDesign(const VLNV&, const QString&)),\r\n        this, SLOT(openHWDesign(const VLNV&, const QString&)));\r\n    connect(libraryHandler_, SIGNAL(openMemoryDesign(const VLNV&, const QString&)),\r\n        this, SLOT(openMemoryDesign(const VLNV&, const QString&)));\r\n\r\n    connect(libraryHandler_, SIGNAL(openComponent(const VLNV&)),\r\n        this, SLOT(openComponent(const VLNV&)), Qt::UniqueConnection);\r\n    connect(libraryHandler_, SIGNAL(openCatalog(const VLNV&)),\r\n        this, SLOT(openCatalog(const VLNV&)), Qt::UniqueConnection);\r\n    connect(libraryHandler_, SIGNAL(openSWDesign(const VLNV&, QString const&)),\r\n        this, SLOT(openSWDesign(const VLNV&, QString const&)), Qt::UniqueConnection);\r\n    connect(libraryHandler_, SIGNAL(openSystemDesign(const VLNV&, QString const&)),\r\n        this, SLOT(openSystemDesign(const VLNV&, QString const&)), Qt::UniqueConnection);\r\n    connect(libraryHandler_, SIGNAL(openBus(const VLNV&)),\r\n        this, SLOT(openBus(const VLNV&)), Qt::UniqueConnection);\r\n    connect(libraryHandler_, SIGNAL(openAbsDef(const VLNV&)),\r\n        this, SLOT(openAbsDef(const VLNV&)), Qt::UniqueConnection);\r\n    connect(libraryHandler_, SIGNAL(openComDefinition(const VLNV&)),\r\n        this, SLOT(openComDefinition(const VLNV&)), Qt::UniqueConnection);\r\n    connect(libraryHandler_, SIGNAL(openApiDefinition(const VLNV&)),\r\n        this, SLOT(openApiDefinition(const VLNV&)), Qt::UniqueConnection);\r\n\r\n    connect(libraryHandler_, SIGNAL(openApiDefinition(const VLNV&)),\r\n        this, SLOT(openApiDefinition(const VLNV&)), Qt::UniqueConnection);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: mainwindow::onDesignChanged()\r\n//-----------------------------------------------------------------------------\r\nvoid MainWindow::onDesignChanged()\r\n{\r\n    // find the currently open editor\r\n    QWidget* widget = designTabs_->currentWidget();\r\n\r\n    // if editor was found\r\n    if (widget)\r\n    {\r\n        DesignWidget* editor = dynamic_cast<DesignWidget*>(widget);\r\n\r\n        // if editor is design widget then set it to be modified.\r\n        if (editor)\r\n        {\r\n            editor->setModified(true);\r\n            updateMenuStrip();\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MainWindow::saveCurrentDocumentHierarchy()\r\n//-----------------------------------------------------------------------------\r\nvoid MainWindow::saveCurrentDocumentHierarchy()\r\n{\r\n    TabDocument* currentDocument = dynamic_cast<TabDocument*>(designTabs_->currentWidget());\r\n\r\n    if (currentDocument)\r\n    {\r\n        DocumentTreeBuilder documentTreeBuilder(libraryHandler_);\r\n        QObject* documentRoot = documentTreeBuilder.createFrom(currentDocument->getDocumentVLNV());\r\n\r\n        SaveHierarchyDialog saveDialog(documentRoot, libraryHandler_, this);\r\n        saveDialog.exec();\r\n\r\n        delete documentRoot;\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: mainwindow::onClearItemSelection()\r\n//-----------------------------------------------------------------------------\r\nvoid MainWindow::onClearItemSelection()\r\n{\r\n    HWDesignWidget* designWidget = dynamic_cast<HWDesignWidget*>(designTabs_->currentWidget());\r\n\r\n    dockHandler_->clearItemSelection(designWidget);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: mainwindow::onComponentSelected()\r\n//-----------------------------------------------------------------------------\r\nvoid MainWindow::onComponentSelected(ComponentItem* component)\r\n{\r\n    Q_ASSERT(component);\r\n\r\n    dockHandler_->selectComponent(designTabs_->currentWidget(), component);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: mainwindow::onInterfaceSelected()\r\n//-----------------------------------------------------------------------------\r\nvoid MainWindow::onInterfaceSelected(ConnectionEndpoint* interface)\r\n{\r\n    Q_ASSERT(interface);\r\n\r\n    dockHandler_->selectConnectionInterface(designTabs_->currentWidget(), interface);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: onConnectionSelected()\r\n//-----------------------------------------------------------------------------\r\nvoid MainWindow::onConnectionSelected(GraphicsConnection* connection)\r\n{\r\n    dockHandler_->selectGraphicsConnection(designTabs_->currentWidget(), connection);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: updateMenuStrip()\r\n//-----------------------------------------------------------------------------\r\nvoid MainWindow::updateMenuStrip()\r\n{\r\n    QSettings settings;\r\n    TabDocument* doc = static_cast<TabDocument*>(designTabs_->currentWidget());\r\n    bool unlocked = doc != 0 && (!(doc->getFlags() & TabDocument::DOC_PROTECTION_SUPPORT) || !doc->isProtected());\r\n\r\n    bool isHWComp = false;\r\n    ComponentEditor* componentEditor = dynamic_cast<ComponentEditor*>(doc);\r\n    if (componentEditor)\r\n    {\r\n        isHWComp = componentEditor->isHWImplementation();\r\n    }\r\n\r\n    bool isHWDesign = dynamic_cast<HWDesignWidget*>(doc) != 0;\r\n    bool isSystemDesign = dynamic_cast<SystemDesignWidget*>(doc) != 0;\r\n\r\n    MemoryDesignDocument* memoryDocument = dynamic_cast<MemoryDesignDocument*>(doc);\r\n    bool isMemoryDesign = memoryDocument != 0;\r\n    \r\n    actSave_->setEnabled(doc != 0 && doc->isModified());\r\n    actSaveAs_->setEnabled(doc != 0);\r\n    actSaveHierarchy_->setEnabled(componentEditor || dynamic_cast<DesignWidget*>(doc));\r\n    actPrint_->setEnabled(doc != 0 && (doc->getFlags() & TabDocument::DOC_PRINT_SUPPORT));\r\n    actImageExport_->setEnabled(doc != 0 && doc->getFlags() & TabDocument::DOC_PRINT_SUPPORT);\r\n\r\n    generationAction_->setEnabled(unlocked);\r\n    generationAction_->setVisible(doc != 0 && (componentEditor != 0 || isHWDesign || isSystemDesign));\r\n\r\n    actGenDocumentation_->setEnabled((isHWDesign|| isHWComp) && unlocked);\r\n    actGenDocumentation_->setVisible((isHWDesign|| isHWComp));\r\n\r\n    actGenerate_->setEnabled(unlocked);\r\n    actGenerate_->setVisible(doc != 0 && (componentEditor != 0 || isHWDesign || isSystemDesign));\r\n\r\n    actRunImport_->setEnabled(isHWComp && unlocked);\r\n    actRunImport_->setVisible(isHWComp);\r\n\r\n    openMemoryDesignerAction_->setVisible(isHWDesign);\r\n    openInterconnectGenerator_->setVisible(isHWDesign);\r\n\r\n    configurationToolsAction_->setEnabled(unlocked);\r\n    configurationToolsAction_->setVisible(doc != 0 && (isHWComp || isHWDesign));\r\n    actionConfigureViews_->setEnabled(unlocked);\r\n    actionConfigureViews_->setVisible(isHWDesign || isHWComp);\r\n\r\n    editAction_->setVisible(doc != 0);\r\n    editAction_->setEnabled(doc != 0 && unlocked);\r\n    actUndo_->setVisible(doc != 0 && doc->getEditProvider() != 0);\r\n    actRedo_->setVisible(doc != 0 && doc->getEditProvider() != 0);\r\n    actUndo_->setEnabled(doc != 0 && doc->getEditProvider() != 0 && doc->getEditProvider()->canUndo());\r\n    actRedo_->setEnabled(doc != 0 && doc->getEditProvider() != 0 && doc->getEditProvider()->canRedo());\r\n\r\n    diagramToolsAction_->setVisible(doc != 0 && (doc->getFlags() & TabDocument::DOC_DRAW_MODE_SUPPORT));\r\n    diagramToolsAction_->setEnabled(doc != 0 && (doc->getFlags() & TabDocument::DOC_DRAW_MODE_SUPPORT) &&\r\n        !doc->isProtected());\r\n    actToolSelect_->setEnabled(doc != 0 && (doc->getSupportedDrawModes() & MODE_SELECT));\r\n    actToolConnect_->setEnabled(doc != 0 && (doc->getSupportedDrawModes() & MODE_CONNECT));\r\n    actToolInterface_->setEnabled(doc != 0 && (doc->getSupportedDrawModes() & MODE_INTERFACE));\r\n    actToolDraft_->setEnabled(doc != 0 && (doc->getSupportedDrawModes() & MODE_DRAFT));\r\n    actToolToggleOffPage_->setEnabled(doc != 0 && (doc->getSupportedDrawModes() & MODE_TOGGLE_OFFPAGE));\r\n    actToolLabel_->setEnabled(doc != 0 && (doc->getSupportedDrawModes() & MODE_LABEL));\r\n\r\n    bool oldProtectionState = actProtect_->isChecked();\r\n\r\n    protectAction_->setVisible(doc != 0 && (doc->getFlags() & TabDocument::DOC_PROTECTION_SUPPORT) &&\r\n        settings.value(\"General/EnableLocking\").toBool());\r\n    actProtect_->setEnabled(doc != 0 && (doc->getFlags() & TabDocument::DOC_PROTECTION_SUPPORT));\r\n    actProtect_->setChecked(doc != 0 && (doc->getFlags() & TabDocument::DOC_PROTECTION_SUPPORT) &&\r\n        doc->isProtected());\r\n\r\n    if (oldProtectionState != actProtect_->isChecked())\r\n        onProtectionChanged(actProtect_->isChecked());\r\n\r\n    actVisibilityControl_->setEnabled(doc != 0 && (doc->getFlags() & TabDocument::DOC_VISIBILITY_CONTROL_SUPPORT));\r\n    actVisibilityControl_->setVisible(doc != 0 && (doc->getFlags() & TabDocument::DOC_VISIBILITY_CONTROL_SUPPORT));\r\n\r\n    setPluginVisibilities();\r\n\r\n    updateZoomTools();\r\n\r\n    if (isMemoryDesign)\r\n    {\r\n        generationAction_->setVisible(false);\r\n\r\n        actionFilterAddressSpaceChains_->setChecked(memoryDocument->addressSpaceChainsAreFiltered());\r\n        actionCondenseMemoryItems_->setChecked(memoryDocument->memoryItemsAreCondensed());\r\n        actionFilterSegments_->setChecked(memoryDocument->addressSpaceSegmentsAreFilterted());\r\n        actionFilterAddressBlocks_->setChecked(memoryDocument->addressBlocksAreFiltered());\r\n        actionFilterRegisters_->setChecked(memoryDocument->addressBlockRegistersAreFiltered());\r\n        actionFilterFields_->setChecked(memoryDocument->fieldsAreFiltered());\r\n        actionFilterUnconnectedMemoryItems_->setChecked(memoryDocument->unconnectedMemoryItemsAreFiltered());\r\n        actionFilterMemoryOverlap_->setChecked(memoryDocument->memoryOverlapItemsAreFiltered());\r\n    }\r\n\r\n    filteringAction_->setVisible(isMemoryDesign);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: saveAll()\r\n//-----------------------------------------------------------------------------\r\nvoid MainWindow::saveAll()\r\n{\r\n    designTabs_->saveAll();\r\n\r\n    TabDocument* doc = static_cast<TabDocument*>(designTabs_->currentWidget());\r\n    actSave_->setEnabled(doc && doc->isModified());\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: addColumn()\r\n//-----------------------------------------------------------------------------\r\nvoid MainWindow::addColumn()\r\n{\r\n    QWidget* curWidget = designTabs_->currentWidget();\r\n    DesignWidget* designWidget = dynamic_cast<DesignWidget*>(curWidget);\r\n\r\n    if (designWidget != 0)\r\n    {\r\n        designWidget->addColumn();\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MainWindow::runGeneratorPlugin()\r\n//-----------------------------------------------------------------------------\r\nvoid MainWindow::runGeneratorPlugin(QAction* action)\r\n{\r\n    TabDocument* doc = static_cast<TabDocument*>(designTabs_->currentWidget());\r\n\r\n    // Inform user that unsaved changes must be saved before continuing.\r\n    if (doc->isModified())\r\n    {\r\n        QMessageBox msgBox(QMessageBox::Warning, QCoreApplication::applicationName(),\r\n            \"The document \" + doc->getDocumentName() + \" has unsaved changes and needs to be \"\r\n            \"saved before generators can be run. Save and continue?\",\r\n            QMessageBox::Yes | QMessageBox::No, this);\r\n\r\n        if (msgBox.exec() == QMessageBox::No || !doc->save())\r\n        {\r\n            return;\r\n        }\r\n    }\r\n\r\n    // Retrieve the library component.\r\n    VLNV compVLNV = doc->getDocumentVLNV();\r\n    VLNV desVLNV = doc->getIdentifyingVLNV();\r\n    QString viewName;\r\n\r\n    // if the design is supported by the document type\r\n    KactusAttribute::Implementation implementation = KactusAttribute::HW;\r\n    DesignWidget* desWidget = qobject_cast<DesignWidget*>(doc);\r\n    if (desWidget)\r\n    {\r\n        // the vlnvs must be for different objects\r\n        Q_ASSERT(compVLNV != desVLNV);\r\n\r\n        // find the design config is one exists\r\n        viewName = desWidget->getOpenViewName();\r\n        implementation = desWidget->getImplementation();\r\n    }\r\n\r\n    // Retrieve the plugin pointer from the action.\r\n    IGeneratorPlugin* plugin = reinterpret_cast<IGeneratorPlugin*>(action->data().value<void*>());\r\n    Q_ASSERT(plugin != 0);\r\n\r\n    KactusAPI::runGenerator(plugin, compVLNV, viewName, QString(), implementation, this);\r\n\r\n    // Refresh the document.\r\n    doc->refresh();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MainWindow::generateDoc()\r\n//-----------------------------------------------------------------------------\r\nvoid MainWindow::generateDoc()\r\n{\r\n    emit noticeMessage(QString(\"Document generation started at %1.\").arg(\r\n        QDateTime::currentDateTime().toString(\"dd.MM.yyyy hh:mm:ss\")));\r\n\r\n    // get the vlnv of the current component\r\n    TabDocument* doc = static_cast<TabDocument*>(designTabs_->currentWidget());\r\n    Q_ASSERT(doc);\r\n    VLNV vlnv = doc->getDocumentVLNV();\r\n    Q_ASSERT(vlnv.isValid());\r\n\r\n    // if changes have been made to the component\r\n    if (doc->isModified())\r\n    {\r\n        QMessageBox::information(this, QCoreApplication::applicationName(),\r\n            tr(\"Changes have been made to the component. Save the changes before generating documentation.\"));\r\n        return;\r\n    }\r\n\r\n    const QString XMLPath = libraryHandler_->getPath(vlnv);\r\n    QFileInfo xmlInfo(XMLPath);\r\n\r\n    QString targetPath = QFileDialog::getSaveFileName(NULL, tr(\"Save the documentation to...\"),\r\n        xmlInfo.absolutePath(), tr(\"markdown (*.md);;web pages (*.html)\"));\r\n\r\n    if (targetPath.isEmpty())\r\n    {\r\n        emit noticeMessage(tr(\"Generation aborted.\"));\r\n        return;\r\n    }\r\n\r\n    QFile targetFile(targetPath);\r\n    if (!targetFile.open(QFile::WriteOnly))\r\n    {\r\n        emit errorMessage(tr(\"Could not open file %1 for writing.\").arg(targetPath));\r\n        emit noticeMessage(tr(\"Generation aborted.\"));\r\n        return;\r\n    }\r\n\r\n    std::unordered_map<QString, DocumentGenerator::DocumentFormat> formats =\r\n    {\r\n        {QString(\"md\"), DocumentGenerator::MD},\r\n        {QString(\"html\"), DocumentGenerator::HTML}\r\n    };\r\n\r\n    DocumentGenerator::DocumentFormat docFormat = formats.at(targetPath.split(\".\").back());\r\n\r\n    QTextStream stream(&targetFile);\r\n\r\n    DesignWidgetFactoryImplementation designWidgetFactory(libraryHandler_,\r\n        dockHandler_->getDesignAndInstanceParameterFinder(), dockHandler_->getDesignParameterFinder());\r\n\r\n    ExpressionFormatterFactoryImplementation expressionFormatterFactory;\r\n\r\n    DocumentGenerator generator(libraryHandler_, vlnv, &designWidgetFactory, &expressionFormatterFactory, 1, this);\r\n    generator.setFormat(docFormat);\r\n\r\n    connect(&generator, SIGNAL(errorMessage(const QString&)),\r\n        dockHandler_, SIGNAL(errorMessage(const QString&)), Qt::UniqueConnection);\r\n    connect(&generator, SIGNAL(noticeMessage(const QString&)),\r\n        dockHandler_, SIGNAL(noticeMessage(const QString&)), Qt::UniqueConnection);\r\n\r\n    generator.writeDocumentation(stream, targetPath);\r\n    targetFile.close();\r\n\r\n    emit noticeMessage(QString(\"Generation complete.\"));\r\n\r\n    // open the generated document in user's default browser\r\n    QDesktopServices::openUrl(QUrl::fromLocalFile(targetPath));\r\n\r\n    // if the editor was component editor then it must be refreshed to make the changes to metadata visible\r\n    ComponentEditor* compEditor = dynamic_cast<ComponentEditor*>(doc);\r\n\r\n    if (compEditor)\r\n    {\r\n        designTabs_->refreshCurrentDocument();\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: zoomIn()\r\n//-----------------------------------------------------------------------------\r\nvoid MainWindow::zoomIn()\r\n{\r\n    TabDocument* doc = static_cast<TabDocument*>(designTabs_->currentWidget());\r\n    Q_ASSERT(doc->getFlags() & TabDocument::DOC_ZOOM_SUPPORT);\r\n    doc->setZoomLevel(doc->getZoomLevel() + 10);\r\n    updateZoomTools();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: zoomOut()\r\n//-----------------------------------------------------------------------------\r\nvoid MainWindow::zoomOut()\r\n{\r\n    TabDocument* doc = static_cast<TabDocument*>(designTabs_->currentWidget());\r\n    Q_ASSERT(doc->getFlags() & TabDocument::DOC_ZOOM_SUPPORT);\r\n    doc->setZoomLevel(doc->getZoomLevel() - 10);\r\n    updateZoomTools();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: zoomOriginal()\r\n//-----------------------------------------------------------------------------\r\nvoid MainWindow::zoomOriginal()\r\n{\r\n    TabDocument* doc = static_cast<TabDocument*>(designTabs_->currentWidget());\r\n    Q_ASSERT(doc->getFlags() & TabDocument::DOC_ZOOM_SUPPORT);\r\n    doc->setZoomLevel(100);\r\n    updateZoomTools();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: fitInView()\r\n//-----------------------------------------------------------------------------\r\nvoid MainWindow::fitInView()\r\n{\r\n    TabDocument* doc = static_cast<TabDocument*>(designTabs_->currentWidget());\r\n    Q_ASSERT(doc->getFlags() & TabDocument::DOC_ZOOM_SUPPORT);\r\n    doc->fitInView();\r\n    updateZoomTools();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: drawModeChange()\r\n//-----------------------------------------------------------------------------\r\nvoid MainWindow::drawModeChange(QAction *action)\r\n{\r\n    TabDocument* doc = static_cast<TabDocument*>(designTabs_->currentWidget());\r\n\r\n    if (action == actToolSelect_)\r\n    {\r\n        doc->setMode(MODE_SELECT);\r\n    }\r\n    else if (action == actToolConnect_)\r\n    {\r\n        doc->setMode(MODE_CONNECT);\r\n    }\r\n    else if (action == actToolInterface_)\r\n    {\r\n        doc->setMode(MODE_INTERFACE);\r\n    }\r\n    else if (action == actToolDraft_)\r\n    {\r\n        doc->setMode(MODE_DRAFT);\r\n    }\r\n    else if (action == actToolToggleOffPage_)\r\n    {\r\n        doc->setMode(MODE_TOGGLE_OFFPAGE);\r\n    }\r\n    else if (action == actToolLabel_)\r\n    {\r\n        doc->setMode(MODE_LABEL);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: onDrawModeChanged()\r\n//-----------------------------------------------------------------------------\r\nvoid MainWindow::onDrawModeChanged(DrawMode mode)\r\n{\r\n    TabDocument* doc = static_cast<TabDocument*>(designTabs_->currentWidget());\r\n\r\n    if (doc != 0 && (doc->getFlags() & TabDocument::DOC_DRAW_MODE_SUPPORT))\r\n    {\r\n        if (mode == MODE_SELECT)\r\n        {\r\n            doc->setCursor(Qt::ArrowCursor);\r\n        }\r\n        else\r\n        {\r\n            doc->setCursor(Qt::CrossCursor);\r\n        }\r\n    }\r\n\r\n    actToolSelect_->setChecked(mode == MODE_SELECT);\r\n    actToolConnect_->setChecked(mode == MODE_CONNECT);\r\n    actToolInterface_->setChecked(mode == MODE_INTERFACE);\r\n    actToolDraft_->setChecked(mode == MODE_DRAFT);\r\n    actToolToggleOffPage_->setChecked(mode == MODE_TOGGLE_OFFPAGE);\r\n    actToolLabel_->setChecked(mode == MODE_LABEL);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MainWindow::onLastDocumentClosed()\r\n//-----------------------------------------------------------------------------\r\nvoid MainWindow::onLastDocumentClosed()\r\n{\r\n    updateWindows();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MainWindow::onDocumentChanged()\r\n//-----------------------------------------------------------------------------\r\nvoid MainWindow::onDocumentChanged(int index)\r\n{\r\n    TabDocument* doc = static_cast<TabDocument*>(designTabs_->widget(index));\r\n\r\n    // update the menu\r\n    if (doc)\r\n    {\r\n        updateWindows();\r\n        updateVisibilityControlMenu(doc);\r\n    }\r\n\r\n    dockHandler_->documentChanged(doc);\r\n\r\n    // Reset the draw mode to select.\r\n    if (doc != 0 && (doc->getFlags() & TabDocument::DOC_DRAW_MODE_SUPPORT))\r\n    {\r\n        doc->setMode(MODE_SELECT);\r\n    }\r\n    else\r\n    {\r\n        onDrawModeChanged(MODE_SELECT);\r\n    }\r\n\r\n    // Update the menu strip.\r\n    updateMenuStrip();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: closeEvent()\r\n//-----------------------------------------------------------------------------\r\nvoid MainWindow::closeEvent(QCloseEvent* event)\r\n{\r\n    // disconnect the signals that would otherwise change the window states to be saved.\r\n    disconnectVisibilityControls();\r\n\r\n    // Go through all tab documents and ask the user what to do if they are not saved.\r\n    designTabs_->closeAll();\r\n\r\n    if (designTabs_->count() != 0)\r\n    {\r\n        event->ignore();\r\n        return;\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: updateZoomTools()\r\n//-----------------------------------------------------------------------------\r\nvoid MainWindow::updateZoomTools()\r\n{\r\n    TabDocument* doc = static_cast<TabDocument*>(designTabs_->currentWidget());\r\n    bool canZoom = doc != 0 && (doc->getFlags() & TabDocument::DOC_ZOOM_SUPPORT);\r\n\r\n    actZoomIn_->setVisible(canZoom);\r\n    actZoomOut_->setVisible(canZoom);\r\n    actZoomOriginal_->setVisible(canZoom);\r\n    actFitInView_->setVisible(canZoom);\r\n\r\n    actZoomIn_->setEnabled(canZoom && doc->getZoomLevel() < doc->getMaxZoomLevel());\r\n    actZoomOut_->setEnabled(canZoom && doc->getZoomLevel() > doc->getMinZoomLevel());\r\n    actZoomOriginal_->setEnabled(canZoom);\r\n    actFitInView_->setEnabled(canZoom);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: createNew()\r\n//-----------------------------------------------------------------------------\r\nvoid MainWindow::createNew()\r\n{\r\n    // Create a property page dialog to work as a \"New\" dialog.\r\n    PropertyPageDialog dialog(QSize(48, 48), 1, PropertyPageDialog::VIEW_ICONS,\r\n                              PropertyPageDialog::APPLY_CURRENT, this);\r\n    dialog.setFixedWidth(620);\r\n    dialog.setWindowTitle(tr(\"New\"));\r\n\r\n    NewBusDefinitionPage* busPage = new NewBusDefinitionPage(libraryHandler_, &dialog);\r\n    connect(busPage, SIGNAL(createBus(VLNV const&, Document::Revision, QString const&)),\r\n        this, SLOT(createBus(VLNV const&, Document::Revision, QString const&)), Qt::UniqueConnection);\r\n    dialog.addPage(QIcon(\":icons/common/graphics/bus-def.png\"), tr(\"Bus Definition\"), busPage);\r\n\r\n    NewCatalogPage* catalogPage = new NewCatalogPage(libraryHandler_, &dialog);\r\n    connect(catalogPage, SIGNAL(createCatalog(VLNV const&, Document::Revision, QString const&)),\r\n        this, SLOT(createCatalog(VLNV const&, Document::Revision, QString const&)), Qt::UniqueConnection);\r\n    dialog.addPage(QIcon(\":icons/common/graphics/catalog.png\"), tr(\"Catalog\"), catalogPage);\r\n\r\n    // Add pages to the dialog.\r\n    NewComponentPage* compPage = new NewComponentPage(libraryHandler_, &dialog);\r\n    connect(compPage, SIGNAL(createComponent(KactusAttribute::ProductHierarchy, KactusAttribute::Firmness,\r\n            QVector<TagData>, VLNV const&, Document::Revision, QString const&)),\r\n        this, SLOT(createComponent(KactusAttribute::ProductHierarchy, KactusAttribute::Firmness,\r\n            QVector<TagData>, VLNV const&, Document::Revision, QString const&)));\r\n    dialog.addPage(QIcon(\":icons/common/graphics/hw-component.png\"), tr(\"HW Component\"), compPage);\r\n\r\n    NewDesignPage* designPage = new NewDesignPage(libraryHandler_, &dialog);\r\n    connect(designPage, SIGNAL(createDesign(KactusAttribute::ProductHierarchy, KactusAttribute::Firmness,\r\n            QVector<TagData>, VLNV const&, Document::Revision, QString const&)),\r\n        this, SLOT(createDesign(KactusAttribute::ProductHierarchy, KactusAttribute::Firmness,\r\n            QVector<TagData>, VLNV const&, Document::Revision, QString const&)));\r\n    dialog.addPage(QIcon(\":icons/common/graphics/hw-design.png\"), tr(\"HW Design\"), designPage);\r\n\r\n    NewSWComponentPage* swCompPage = new NewSWComponentPage(libraryHandler_, &dialog);\r\n    connect(swCompPage, SIGNAL(createSWComponent(VLNV const&, Document::Revision, QString const&)),\r\n        this, SLOT(createSWComponent(VLNV const&, Document::Revision, QString const&)));\r\n    dialog.addPage(QIcon(\":icons/common/graphics/sw-component48x48.png\"), tr(\"SW Component\"), swCompPage);\r\n\r\n    NewSWDesignPage* swDesignPage = new NewSWDesignPage(libraryHandler_, &dialog);\r\n    connect(swDesignPage, SIGNAL(createSWDesign(VLNV const&, Document::Revision, QString const&)),\r\n            this, SLOT(createSWDesign(VLNV const&, Document::Revision, QString const&)), Qt::UniqueConnection);\r\n    dialog.addPage(QIcon(\":icons/common/graphics/sw-design48x48.png\"), tr(\"SW Design\"), swDesignPage);\r\n\r\n    NewSystemPage* sysPage = new NewSystemPage(libraryHandler_, &dialog);\r\n    connect(sysPage, SIGNAL(createSystem(VLNV const&, QString const&, VLNV const&, Document::Revision, QString const&)),\r\n        this, SLOT(createSystem(VLNV const&, QString const&, VLNV const&, Document::Revision, QString const&)));\r\n    dialog.addPage(QIcon(\":icons/common/graphics/system-component.png\"), tr(\"System\"), sysPage);\r\n\r\n    NewApiDefinitionPage* apiDefPage = new NewApiDefinitionPage(libraryHandler_, &dialog);\r\n    connect(apiDefPage, SIGNAL(createApiDefinition(VLNV const&, Document::Revision, QString const&)),\r\n        this, SLOT(createApiDefinition(VLNV const&, Document::Revision, QString const&)), Qt::UniqueConnection);\r\n    dialog.addPage(QIcon(\":icons/common/graphics/new-api_definition.png\"), tr(\"API Definition\"), apiDefPage);\r\n\r\n    NewComDefinitionPage* comDefPage = new NewComDefinitionPage(libraryHandler_, &dialog);\r\n    connect(comDefPage, SIGNAL(createComDefinition(VLNV const&, Document::Revision, QString const&)),\r\n            this, SLOT(createComDefinition(VLNV const&, Document::Revision, QString const&)), Qt::UniqueConnection);\r\n    dialog.addPage(QIcon(\":icons/common/graphics/new-com_definition.png\"), tr(\"COM Definition\"), comDefPage);\r\n\r\n    dialog.finalizePages();\r\n\r\n    dialog.exec();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: mainwindow::createComponent()\r\n//-----------------------------------------------------------------------------\r\nvoid MainWindow::createComponent(KactusAttribute::ProductHierarchy prodHier, KactusAttribute::Firmness firmness,\r\n    QVector<TagData> tags, VLNV const& vlnv, Document::Revision revision, QString const& directory)\r\n{\r\n    Q_ASSERT(vlnv.isValid());\r\n\r\n    // Create a component.\r\n    QSharedPointer<Component> component = QSharedPointer<Component>(new Component(vlnv, revision));\r\n\r\n    // Set Kactus attributes.\r\n    component->setHierarchy(prodHier);\r\n    component->setFirmness(firmness);\r\n    component->setTags(tags);\r\n    component->setImplementation(KactusAttribute::HW);\r\n\r\n    component->setVersion(VersionHelper::versionFileStr());\r\n\r\n    // Create the file.\r\n    if (!libraryHandler_->writeModelToFile(directory, component))\r\n    {\r\n        emit errorMessage(\"Error saving file to disk.\");\r\n        return;\r\n    }\r\n\r\n    runComponentWizard(component, directory);\r\n\r\n    // Open the component editor.\r\n    openComponent(vlnv);\r\n\r\n    unlockNewlyCreatedDocument(vlnv);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: mainwindow::createDesign()\r\n//-----------------------------------------------------------------------------\r\nvoid MainWindow::createDesign(KactusAttribute::ProductHierarchy prodHier, KactusAttribute::Firmness firmness,\r\n    QVector<TagData> tags, VLNV const& vlnv, Document::Revision revision, QString const& directory)\r\n{\r\n    Q_ASSERT(vlnv.isValid());\r\n\r\n    VLNV designVLNV(VLNV::DESIGN, vlnv.getVendor(), vlnv.getLibrary(),\r\n        vlnv.getName().remove(\".comp\") + \".design\", vlnv.getVersion());\r\n    VLNV desConfVLNV(VLNV::DESIGNCONFIGURATION, vlnv.getVendor(), vlnv.getLibrary(),\r\n        vlnv.getName().remove(\".comp\") + \".designcfg\", vlnv.getVersion());\r\n\r\n    // Create a component and a hierarchical view .\r\n    QSharedPointer<Component> component(new Component(vlnv, revision));\r\n\r\n    // Set Kactus2 attributes.\r\n    component->setHierarchy(prodHier);\r\n    component->setFirmness(firmness);\r\n    component->setTags(tags);\r\n\r\n    component->setImplementation(KactusAttribute::HW);\r\n    component->setVersion(VersionHelper::versionFileStr());\r\n\r\n    QSharedPointer<View> newHierarchicalView(new View());\r\n    newHierarchicalView->setName(NameGenerationPolicy::hierarchicalViewName());\r\n\r\n    QSharedPointer<ConfigurableVLNVReference> tempReference (new ConfigurableVLNVReference(desConfVLNV));\r\n\r\n    QSharedPointer<DesignConfigurationInstantiation> hierarchicalInstantiation\r\n        (new DesignConfigurationInstantiation(desConfVLNV.getName() + \"_\" + desConfVLNV.getVersion()));\r\n    hierarchicalInstantiation->setDesignConfigurationReference(tempReference);\r\n\r\n    newHierarchicalView->setDesignConfigurationInstantiationRef(hierarchicalInstantiation->name());\r\n\r\n    component->getDesignConfigurationInstantiations()->append(hierarchicalInstantiation);\r\n    component->getViews()->append(newHierarchicalView);\r\n\r\n    QStringList viewNames = component->getHierViews();\r\n    Q_ASSERT(!viewNames.isEmpty());\r\n\r\n    // Create the design and design configuration.\r\n    QSharedPointer<Design> design(new Design(designVLNV, revision));\r\n    design->setDesignImplementation(KactusAttribute::HW);\r\n    design->setVersion(VersionHelper::versionFileStr());\r\n\r\n    QSharedPointer<DesignConfiguration> designConf(new DesignConfiguration(desConfVLNV, revision));\r\n    designConf->setDesignRef(designVLNV);\r\n    designConf->setDesignConfigImplementation(KactusAttribute::HW);\r\n    designConf->setVersion(VersionHelper::versionFileStr());\r\n\r\n    // Create the files.\r\n    libraryHandler_->beginSave();\r\n\r\n    bool success = true;\r\n\r\n    if (!libraryHandler_->writeModelToFile(directory, designConf))\r\n    {\r\n        success = false;\r\n    }\r\n\r\n    if (!libraryHandler_->writeModelToFile(directory, design))\r\n    {\r\n        success = false;\r\n    }\r\n\r\n    if (!libraryHandler_->writeModelToFile(directory, component))\r\n    {\r\n        success = false;\r\n    }\r\n\r\n    libraryHandler_->endSave();\r\n\r\n    if (success)\r\n    {\r\n        // Open the design.\r\n        openHWDesign(vlnv, viewNames.first());\r\n\r\n        unlockNewlyCreatedDocument(vlnv);\r\n    }\r\n    else\r\n    {\r\n        emit errorMessage(\"Error saving files to disk.\");\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MainWindow::createDesignForExistingComponent()\r\n//-----------------------------------------------------------------------------\r\nvoid MainWindow::createDesignForExistingComponent(VLNV const& vlnv)\r\n{\r\n    Q_ASSERT(libraryHandler_->contains(vlnv));\r\n    Q_ASSERT(libraryHandler_->getDocumentType(vlnv) == VLNV::COMPONENT);\r\n\r\n    // Retrieve the component to which the design will be created.\r\n    QSharedPointer<Document> libComp = libraryHandler_->getModel(vlnv);\r\n    QSharedPointer<Component> component = libComp.staticCast<Component>();\r\n\r\n    // Ask the user the VLNV, target path and view name.\r\n    NewDesignDialog dialog(libraryHandler_, component, KactusAttribute::HW, this);\r\n    dialog.setVLNV(VLNV(VLNV::DESIGN, component->getVlnv().getVendor(), component->getVlnv().getLibrary(), \"\", \"\"));\r\n\r\n    QSettings settings;\r\n    QStringList suggestions = settings.value(\"Policies/HWViewNames\").toStringList();\r\n    dialog.setViewNameSuggestions(suggestions);\r\n    component->setVersion(VersionHelper::versionFileStr());\r\n\r\n    QString baseViewName = \"\";\r\n    QString viewName = \"\";\r\n\r\n    if (!suggestions.isEmpty())\r\n    {\r\n        baseViewName = suggestions.first();\r\n\r\n        viewName = baseViewName;\r\n        unsigned int runningNumber = 1;\r\n\r\n        for (QSharedPointer<View> view : *component->getViews())\r\n        {\r\n            if (view->name() == viewName)\r\n            {\r\n                ++runningNumber;\r\n                viewName = baseViewName + QString::number(runningNumber);\r\n            }\r\n        }\r\n    }\r\n\r\n    dialog.setViewName(viewName);\r\n\r\n    if (dialog.exec() == QDialog::Rejected)\r\n    {\r\n        return;\r\n    }\r\n\r\n    // Create the view.\r\n    QSharedPointer<View> view (new View(dialog.getViewName()));\r\n\r\n    VLNV designConfigVLNV = dialog.getDesignConfVLNV();\r\n    QSharedPointer<DesignConfigurationInstantiation> hierarchyInstantiation\r\n        (new DesignConfigurationInstantiation(NameGenerationPolicy::designConfigurationInstantiationName(dialog.getQualifierName())));\r\n    hierarchyInstantiation->setDesignConfigurationReference(\r\n        QSharedPointer<ConfigurableVLNVReference>( new ConfigurableVLNVReference( designConfigVLNV ) ) );\r\n\r\n    view->setDesignConfigurationInstantiationRef(hierarchyInstantiation->name());\r\n\r\n    component->getViews()->append(view);\r\n    component->getDesignConfigurationInstantiations()->append(hierarchyInstantiation);\r\n\r\n    // Create the design and design configuration objects.\r\n    QSharedPointer<DesignConfiguration> designConf(new DesignConfiguration(dialog.getDesignConfVLNV(), component->getRevision()));\r\n    designConf->setDesignRef(dialog.getDesignVLNV());\r\n    designConf->setDesignConfigImplementation(KactusAttribute::HW);\r\n    designConf->setVersion(VersionHelper::versionFileStr());\r\n\r\n    QSharedPointer<Design> newDesign = QSharedPointer<Design>(new Design(dialog.getDesignVLNV(), component->getRevision()));\r\n    newDesign->setDesignImplementation(KactusAttribute::HW);\r\n    newDesign->setVersion(VersionHelper::versionFileStr());\r\n\r\n    newDesign->addColumn(QSharedPointer<ColumnDesc>(new ColumnDesc(\r\n        \"IO\", ColumnTypes::IO, 0, GraphicsColumnConstants::IO_COLUMN_WIDTH)));\r\n    newDesign->addColumn(QSharedPointer<ColumnDesc>(new ColumnDesc(\r\n        \"Buses\", ColumnTypes::BUSES, 0, GraphicsColumnConstants::COMPONENT_COLUMN_WIDTH)));\r\n    newDesign->addColumn(QSharedPointer<ColumnDesc>(new ColumnDesc(\r\n        \"Components\", ColumnTypes::COMPONENTS, 0, GraphicsColumnConstants::COMPONENT_COLUMN_WIDTH)));\r\n    newDesign->addColumn(QSharedPointer<ColumnDesc>(new ColumnDesc(\r\n        \"IO\", ColumnTypes::IO, 0, GraphicsColumnConstants::IO_COLUMN_WIDTH)));\r\n\r\n    libraryHandler_->beginSave();\r\n\r\n    bool success = true;\r\n\r\n    if (!libraryHandler_->writeModelToFile(dialog.getPath(), newDesign))\r\n    {\r\n        success = false;\r\n    }\r\n\r\n    if (!libraryHandler_->writeModelToFile(dialog.getPath(), designConf))\r\n    {\r\n        success = false;\r\n    }\r\n\r\n    if (!libraryHandler_->writeModelToFile(component))\r\n    {\r\n        success = false;\r\n    }\r\n\r\n    libraryHandler_->endSave();\r\n\r\n    if (success)\r\n    {\r\n        // Open the design.\r\n        openHWDesign(vlnv, view->name());\r\n\r\n        unlockNewlyCreatedDocument(vlnv);\r\n\r\n    }\r\n    else\r\n    {\r\n        emit errorMessage(\"Error saving files to disk.\");\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MainWindow::unlockNewlyCreatedDocument()\r\n//-----------------------------------------------------------------------------\r\nvoid MainWindow::unlockNewlyCreatedDocument(VLNV const& vlnv)\r\n{\r\n    TabDocument* document = dynamic_cast<TabDocument*>(designTabs_->currentWidget());\r\n    if (document && document->getIdentifyingVLNV() == vlnv)\r\n    {\r\n        document->setProtection(false);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: mainwindow::createCatalog()\r\n//-----------------------------------------------------------------------------\r\nvoid MainWindow::createCatalog(VLNV const& catalogVLNV, Document::Revision revision, QString const& directory)\r\n{\r\n    Q_ASSERT(catalogVLNV.isValid());\r\n\r\n    // Create the catalog.\r\n    QSharedPointer<Catalog> catalog = QSharedPointer<Catalog>(new Catalog(catalogVLNV, revision));\r\n    catalog->setVersion(VersionHelper::versionFileStr());\r\n\r\n    // create the file for the abstraction definition\r\n    if (!libraryHandler_->writeModelToFile(directory, catalog))\r\n    {\r\n        emit errorMessage(\"Error saving files to disk.\");\r\n        return;\r\n    }\r\n\r\n    // Open the catalog editor.\r\n    openCatalog(catalogVLNV);\r\n\r\n    unlockNewlyCreatedDocument(catalogVLNV);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MainWindow::createSWDesign()\r\n//-----------------------------------------------------------------------------\r\nvoid MainWindow::createSWDesign(VLNV const& vlnv, Document::Revision revision, QString const& directory)\r\n{\r\n    Q_ASSERT(vlnv.isValid());\r\n\r\n    VLNV designVLNV(VLNV::DESIGN, vlnv.getVendor(), vlnv.getLibrary(),\r\n        vlnv.getName().remove(\".comp\") + \".swdesign\", vlnv.getVersion());\r\n    VLNV desConfVLNV(VLNV::DESIGNCONFIGURATION, vlnv.getVendor(), vlnv.getLibrary(),\r\n        vlnv.getName().remove(\".comp\") + \".swdesigncfg\", vlnv.getVersion());\r\n\r\n    // Create a component and a hierarchical view .\r\n    QSharedPointer<Component> component(new Component(vlnv, revision));\r\n\r\n    // Set Kactus attributes.\r\n    component->setImplementation(KactusAttribute::SW);\r\n    component->setVersion(VersionHelper::versionFileStr());\r\n\r\n    // Create the view.\r\n    QSharedPointer<View> view (new View(\"software\"));\r\n\r\n    QSharedPointer<ConfigurableVLNVReference> tempReference (new ConfigurableVLNVReference(desConfVLNV));\r\n\r\n    QSharedPointer<DesignConfigurationInstantiation> hierarchicalInstantiation\r\n        (new DesignConfigurationInstantiation(desConfVLNV.getName() + \"_\" + desConfVLNV.getVersion()));\r\n    hierarchicalInstantiation->setDesignConfigurationReference(tempReference);\r\n\r\n    view->setDesignConfigurationInstantiationRef(hierarchicalInstantiation->name());\r\n\r\n    component->getDesignConfigurationInstantiations()->append(hierarchicalInstantiation);\r\n    component->getViews()->append(view);\r\n\r\n    // Create the design and design configuration.\r\n    QSharedPointer<Design> design(new Design(designVLNV, revision));\r\n    design->setDesignImplementation(KactusAttribute::SW);\r\n    design->setVersion(VersionHelper::versionFileStr());\r\n\r\n    QSharedPointer<DesignConfiguration> designConf(new DesignConfiguration(desConfVLNV, revision));\r\n    designConf->setDesignRef(designVLNV);\r\n    designConf->setDesignConfigImplementation(KactusAttribute::SW);\r\n    designConf->setVersion(VersionHelper::versionFileStr());\r\n\r\n    design->addColumn(QSharedPointer<ColumnDesc>(new ColumnDesc(\"Low-level\", ColumnTypes::COMPONENTS, 0,\r\n        GraphicsColumnConstants::COMPONENT_COLUMN_WIDTH)));\r\n    design->addColumn(QSharedPointer<ColumnDesc>(new ColumnDesc(\"Middle-level\", ColumnTypes::COMPONENTS, 0,\r\n        GraphicsColumnConstants::COMPONENT_COLUMN_WIDTH)));\r\n    design->addColumn(QSharedPointer<ColumnDesc>(new ColumnDesc(\"High-level\", ColumnTypes::COMPONENTS, 0,\r\n        GraphicsColumnConstants::COMPONENT_COLUMN_WIDTH)));\r\n    design->addColumn(QSharedPointer<ColumnDesc>(new ColumnDesc(\"Out\", ColumnTypes::IO, 0,\r\n        GraphicsColumnConstants::IO_COLUMN_WIDTH)));\r\n\r\n    // Create the files.\r\n    libraryHandler_->beginSave();\r\n\r\n    bool success = true;\r\n\r\n    if (!libraryHandler_->writeModelToFile(directory, designConf))\r\n    {\r\n        success = false;\r\n    }\r\n\r\n    if (!libraryHandler_->writeModelToFile(directory, design))\r\n    {\r\n        success = false;\r\n    }\r\n\r\n    if (!libraryHandler_->writeModelToFile(directory, component))\r\n    {\r\n        success = false;\r\n    }\r\n\r\n    libraryHandler_->endSave();\r\n\r\n    if (success)\r\n    {\r\n        // Open the design.\r\n        openSWDesign(vlnv, view->name());\r\n        unlockNewlyCreatedDocument(vlnv);\r\n    }\r\n    else\r\n    {\r\n        emit errorMessage(\"Error saving files to disk.\");\r\n\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MainWindow::createSWDesign()\r\n//-----------------------------------------------------------------------------\r\nvoid MainWindow::createSWDesign(VLNV const& vlnv)\r\n{\r\n    Q_ASSERT(libraryHandler_->contains(vlnv));\r\n    Q_ASSERT(libraryHandler_->getDocumentType(vlnv) == VLNV::COMPONENT);\r\n\r\n    // Retrieve the component to which the SW design will be created.\r\n    QSharedPointer<Document> libComp = libraryHandler_->getModel(vlnv);\r\n    QSharedPointer<Component> component = libComp.staticCast<Component>();\r\n\r\n    // Ask the user the VLNV, target path and view name.\r\n    NewDesignDialog dialog(libraryHandler_, component, KactusAttribute::SW, this);\r\n    dialog.setVLNV(VLNV(VLNV::DESIGN, component->getVlnv().getVendor(), component->getVlnv().getLibrary(), \"\", \"\"));\r\n\r\n    QSettings settings;\r\n    QStringList suggestions = settings.value(\"Policies/SWViewNames\").toStringList();\r\n    dialog.setViewNameSuggestions(suggestions);\r\n\r\n    QString baseViewName = \"\";\r\n    QString viewName = \"\";\r\n\r\n    if (!suggestions.isEmpty())\r\n    {\r\n        baseViewName = suggestions.first();\r\n\r\n        viewName = baseViewName;\r\n        unsigned int runningNumber = 1;\r\n\r\n        for (QSharedPointer<View> swView : *component->getViews())\r\n        {\r\n            if (swView->name() == viewName)\r\n            {\r\n                ++runningNumber;\r\n                viewName = baseViewName + QString::number(runningNumber);\r\n            }\r\n        }\r\n    }\r\n\r\n    dialog.setViewName(viewName);\r\n\r\n    if (dialog.exec() == QDialog::Rejected)\r\n    {\r\n        return;\r\n    }\r\n\r\n    // Create the view.\r\n    QSharedPointer<View> view (new View(dialog.getViewName()));\r\n\r\n    QSharedPointer<ConfigurableVLNVReference> tempReference (new ConfigurableVLNVReference(dialog.getDesignConfVLNV()));\r\n\r\n    QSharedPointer<DesignConfigurationInstantiation> hierarchicalInstantiation\r\n        (new DesignConfigurationInstantiation(dialog.getDesignConfVLNV().getName() + \"_\" + dialog.getDesignConfVLNV().getVersion()));\r\n    hierarchicalInstantiation->setDesignConfigurationReference(tempReference);\r\n\r\n    view->setDesignConfigurationInstantiationRef(hierarchicalInstantiation->name());\r\n\r\n    component->getDesignConfigurationInstantiations()->append(hierarchicalInstantiation);\r\n    component->getViews()->append(view);\r\n\r\n    component->setVersion(VersionHelper::versionFileStr());\r\n\r\n    // Create the design and design configuration objects.\r\n    QSharedPointer<DesignConfiguration> designConf(new DesignConfiguration(dialog.getDesignConfVLNV(), component->getRevision()));\r\n    designConf->setDesignRef(dialog.getDesignVLNV());\r\n    designConf->setDesignConfigImplementation(KactusAttribute::SW);\r\n    designConf->setVersion(VersionHelper::versionFileStr());\r\n\r\n    QSharedPointer<Design> newDesign(new Design(dialog.getDesignVLNV(), component->getRevision()));\r\n    newDesign->setDesignImplementation(KactusAttribute::SW);\r\n    newDesign->setVersion(VersionHelper::versionFileStr());\r\n\r\n    if (component->getImplementation() == KactusAttribute::SW)\r\n    {\r\n        newDesign->addColumn(QSharedPointer<ColumnDesc>(new ColumnDesc(\r\n            \"Low-level\", ColumnTypes::COMPONENTS, 0, GraphicsColumnConstants::COMPONENT_COLUMN_WIDTH)));\r\n        newDesign->addColumn(QSharedPointer<ColumnDesc>(new ColumnDesc(\r\n            \"Middle-level\", ColumnTypes::COMPONENTS, 0,GraphicsColumnConstants::COMPONENT_COLUMN_WIDTH)));\r\n        newDesign->addColumn(QSharedPointer<ColumnDesc>(new ColumnDesc(\r\n            \"High-level\", ColumnTypes::COMPONENTS, 0, GraphicsColumnConstants::COMPONENT_COLUMN_WIDTH)));\r\n        newDesign->addColumn(QSharedPointer<ColumnDesc>(new ColumnDesc(\r\n            \"Out\", ColumnTypes::IO, 0, GraphicsColumnConstants::IO_COLUMN_WIDTH)));\r\n    }\r\n    else\r\n    {\r\n        newDesign->addColumn(QSharedPointer<ColumnDesc>(new ColumnDesc(\r\n            \"Pre-mapped SW\", ColumnTypes::COMPONENTS, 0, GraphicsColumnConstants::COMPONENT_COLUMN_WIDTH)));\r\n        newDesign->addColumn(QSharedPointer<ColumnDesc>(new ColumnDesc(\r\n            \"Pre-mapped SW\", ColumnTypes::COMPONENTS, 0, GraphicsColumnConstants::COMPONENT_COLUMN_WIDTH)));\r\n    }\r\n\r\n    libraryHandler_->beginSave();\r\n\r\n    bool success = true;\r\n\r\n    if (!libraryHandler_->writeModelToFile(dialog.getPath(), newDesign))\r\n    {\r\n        success = false;\r\n    }\r\n\r\n    if (!libraryHandler_->writeModelToFile(dialog.getPath(), designConf))\r\n    {\r\n        success = false;\r\n    }\r\n\r\n    if (!libraryHandler_->writeModelToFile(component))\r\n    {\r\n        success = false;\r\n    }\r\n\r\n    libraryHandler_->endSave();\r\n\r\n    if (success)\r\n    {\r\n        // Open the design.\r\n        openSWDesign(vlnv, view->name());\r\n\r\n        unlockNewlyCreatedDocument(vlnv);\r\n    }\r\n    else\r\n    {\r\n        emit errorMessage(\"Error saving files to disk.\");\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: openSettings()\r\n//-----------------------------------------------------------------------------\r\nvoid MainWindow::openSettings()\r\n{\r\n    SettingsDialog dialog(this);\r\n\r\n    if (dialog.exec() == QDialog::Accepted)\r\n    {\r\n        designTabs_->applySettings();\r\n        updateGeneratorPluginActions();\r\n        dockHandler_->applySettings();\r\n        scriptEditor_->applySettings();\r\n        updateMenuStrip();\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: mainwindow::createSystem()\r\n//-----------------------------------------------------------------------------\r\nvoid MainWindow::createSystem(VLNV const& compVLNV, QString const& viewName, VLNV const& sysVLNV,\r\n    Document::Revision revision, QString const& directory)\r\n{\r\n    Q_ASSERT(sysVLNV.isValid());\r\n\r\n    libraryHandler_->beginSave();\r\n\r\n    VLNV designVLNV(VLNV::DESIGN, sysVLNV.getVendor(), sysVLNV.getLibrary(),\r\n        sysVLNV.getName().remove(\".comp\") + \".sysdesign\", sysVLNV.getVersion());\r\n    VLNV desConfVLNV(VLNV::DESIGNCONFIGURATION, sysVLNV.getVendor(), sysVLNV.getLibrary(),\r\n        sysVLNV.getName().remove(\".comp\") + \".sysdesigncfg\", sysVLNV.getVersion());\r\n\r\n    QSharedPointer<Component> parentComp;\r\n\r\n    // Check if mapping information was given.\r\n    if (compVLNV.isValid())\r\n    {\r\n        // Retrieve the component to which the system design will be based on.\r\n        parentComp = libraryHandler_->getModel(compVLNV).staticCast<Component>();\r\n        Q_ASSERT(parentComp != 0);\r\n    }\r\n    else\r\n    {\r\n        // Otherwise create a system component to encapsulate the system design.\r\n        parentComp = QSharedPointer<Component>(new Component(sysVLNV, revision));\r\n        parentComp->setHierarchy(KactusAttribute::PRODUCT);\r\n        parentComp->setFirmness(KactusAttribute::FIXED);\r\n        parentComp->setImplementation(KactusAttribute::SYSTEM);\r\n        parentComp->setVersion(VersionHelper::versionFileStr());\r\n    }\r\n\r\n    // Create the system view to the system design.\r\n    QString sysViewName = \"system\";\r\n    unsigned int runningNumber = 1;\r\n\r\n    while (parentComp->findSystemView(sysViewName) != 0)\r\n    {\r\n        ++runningNumber;\r\n        sysViewName = \"system\" + QString::number(runningNumber);\r\n    }\r\n\r\n    QSharedPointer<SystemView> systemView (new SystemView(sysViewName));\r\n    systemView->setHierarchyRef(desConfVLNV);\r\n    systemView->setHWViewRef(viewName);\r\n\r\n    QList<QSharedPointer<SystemView> > systemViews = parentComp->getSystemViews();\r\n    systemViews.append(systemView);\r\n    parentComp->setSystemViews(systemViews);\r\n\r\n    // Flat-out the hierarchy to form the system design.\r\n    QSharedPointer<Design> sysDesign(new Design(designVLNV, revision));\r\n    sysDesign->setDesignImplementation(KactusAttribute::SYSTEM);\r\n    sysDesign->setVersion(VersionHelper::versionFileStr());\r\n\r\n    sysDesign->addColumn(QSharedPointer<ColumnDesc>(new ColumnDesc(\"SW Components\", ColumnTypes::COMPONENTS, 0,\r\n        GraphicsColumnConstants::SYSTEM_COLUMN_WIDTH)));\r\n    sysDesign->addColumn(QSharedPointer<ColumnDesc>(new ColumnDesc(\"SW Components\", ColumnTypes::COMPONENTS, 0,\r\n        GraphicsColumnConstants::SYSTEM_COLUMN_WIDTH)));\r\n\r\n    generateSystemDesignV2(libraryHandler_, parentComp->getHierRef(viewName), *sysDesign);\r\n\r\n    // Create the design configuration.\r\n    QSharedPointer<DesignConfiguration> designConf(new DesignConfiguration(desConfVLNV, revision));\r\n    designConf->setDesignRef(designVLNV);\r\n    designConf->setDesignConfigImplementation(KactusAttribute::SYSTEM);\r\n    designConf->setVersion(VersionHelper::versionFileStr());\r\n\r\n    // Create the files.\r\n    bool success = true;\r\n\r\n    if (!libraryHandler_->writeModelToFile(directory, designConf))\r\n    {\r\n        success = false;\r\n    }\r\n\r\n    if (!libraryHandler_->writeModelToFile(directory, sysDesign))\r\n    {\r\n        success = false;\r\n    }\r\n\r\n    if (compVLNV.isValid())\r\n    {\r\n        if (!libraryHandler_->writeModelToFile(parentComp))\r\n        {\r\n            success = false;\r\n        }\r\n    }\r\n    else\r\n    {\r\n        if (!libraryHandler_->writeModelToFile(directory, parentComp))\r\n        {\r\n            success = false;\r\n        }\r\n    }\r\n\r\n    libraryHandler_->endSave();\r\n\r\n    if (success)\r\n    {\r\n        openSystemDesign(parentComp->getVlnv(), sysViewName);\r\n\r\n        unlockNewlyCreatedDocument(parentComp->getVlnv());\r\n    }\r\n    else\r\n    {\r\n        emit errorMessage(\"Error saving files to disk.\");\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MainWindow::createSWDesign()\r\n//-----------------------------------------------------------------------------\r\nvoid MainWindow::createSystemDesign(VLNV const& vlnv)\r\n{\r\n    Q_ASSERT(libraryHandler_->contains(vlnv));\r\n    Q_ASSERT(libraryHandler_->getDocumentType(vlnv) == VLNV::COMPONENT);\r\n\r\n    libraryHandler_->beginSave();\r\n\r\n    // Retrieve the component to which the system design will be created.\r\n    QSharedPointer<Document> libComp = libraryHandler_->getModel(vlnv);\r\n    QSharedPointer<Component> component = libComp.staticCast<Component>();\r\n    component->setVersion(VersionHelper::versionFileStr());\r\n\r\n    // Ask the user the VLNV, target path and view name.\r\n    NewDesignDialog dialog(libraryHandler_, component, KactusAttribute::SYSTEM, this);\r\n    dialog.setVLNV(VLNV(VLNV::DESIGN, component->getVlnv().getVendor(), component->getVlnv().getLibrary(), \"\", \"\"));\r\n\r\n    QSettings settings;\r\n    QStringList suggestions = settings.value(\"Policies/SysViewNames\").toStringList();\r\n    dialog.setViewNameSuggestions(suggestions);\r\n\r\n    QString baseViewName = \"\";\r\n    QString viewName = \"\";\r\n\r\n    if (!suggestions.isEmpty())\r\n    {\r\n        baseViewName = suggestions.first();\r\n\r\n        viewName = baseViewName;\r\n        unsigned int runningNumber = 1;\r\n\r\n        while (component->findSystemView(viewName) != 0)\r\n        {\r\n            ++runningNumber;\r\n            viewName = baseViewName + QString::number(runningNumber);\r\n        }\r\n    }\r\n\r\n    dialog.setViewName(viewName);\r\n\r\n    if (dialog.exec() == QDialog::Rejected)\r\n    {\r\n        return;\r\n    }\r\n\r\n    // Create the view.\r\n    QSharedPointer<SystemView> view (new SystemView(dialog.getViewName()));\r\n    view->setHierarchyRef(dialog.getDesignConfVLNV());\r\n    view->setHWViewRef(component->getHierViews().first());\r\n\r\n    QList<QSharedPointer<SystemView> > systemViews = component->getSystemViews();\r\n    systemViews.append(view);\r\n    component->setSystemViews(systemViews);\r\n\r\n    // Create the design and design configuration objects to the same folder as the component.\r\n    QSharedPointer<DesignConfiguration> designConf(new DesignConfiguration(dialog.getDesignConfVLNV(), component->getRevision()));\r\n    designConf->setDesignRef(dialog.getDesignVLNV());\r\n    designConf->setDesignConfigImplementation(KactusAttribute::SYSTEM);\r\n    designConf->setVersion(VersionHelper::versionFileStr());\r\n\r\n    QSharedPointer<Design> newDesign = QSharedPointer<Design>(new Design(dialog.getDesignVLNV(), component->getRevision()));\r\n    newDesign->setDesignImplementation(KactusAttribute::SYSTEM);\r\n    newDesign->setVersion(VersionHelper::versionFileStr());\r\n\r\n    newDesign->addColumn(QSharedPointer<ColumnDesc>(new ColumnDesc(\"SW Components\", ColumnTypes::COMPONENTS, 0,\r\n        GraphicsColumnConstants::SYSTEM_COLUMN_WIDTH)));\r\n    newDesign->addColumn(QSharedPointer<ColumnDesc>(new ColumnDesc(\"SW Components\", ColumnTypes::COMPONENTS, 0,\r\n        GraphicsColumnConstants::SYSTEM_COLUMN_WIDTH)));\r\n\r\n    generateSystemDesignV2(libraryHandler_, component->getHierRef(), *newDesign);\r\n\r\n    bool success = true;\r\n\r\n    if (!libraryHandler_->writeModelToFile(dialog.getPath(), newDesign))\r\n    {\r\n        success = false;\r\n    }\r\n\r\n    if (!libraryHandler_->writeModelToFile(dialog.getPath(), designConf))\r\n    {\r\n        success = false;\r\n    }\r\n\r\n    if (!libraryHandler_->writeModelToFile(component))\r\n    {\r\n        success = false;\r\n    }\r\n\r\n    libraryHandler_->endSave();\r\n\r\n    if (success)\r\n    {\r\n        // Open the design.\r\n        QString viewName = view->name();\r\n        openSystemDesign(vlnv, viewName);\r\n\r\n        unlockNewlyCreatedDocument(vlnv);\r\n    }\r\n    else\r\n    {\r\n        emit errorMessage(\"Error saving files to disk.\");\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: mainwindow::createBus()\r\n//-----------------------------------------------------------------------------\r\nvoid MainWindow::createBus(VLNV const& vlnv, Document::Revision revision, QString const& directory)\r\n{\r\n    Q_ASSERT(vlnv.isValid());\r\n    Q_ASSERT(!directory.isEmpty());\r\n\r\n    // create the vlnvs that identify the bus definition and abstraction definition\r\n    VLNV busVLNV = vlnv;\r\n    busVLNV.setType(VLNV::BUSDEFINITION);\r\n\r\n    Q_ASSERT(!libraryHandler_->contains(busVLNV));\r\n\r\n    VLNV absVLNV = busVLNV;\r\n\r\n    // remove the possible .busDef from the end of the name field\r\n    QString absDefName = busVLNV.getName();\r\n    absDefName = absDefName.remove(\".busDef\", Qt::CaseInsensitive);\r\n\r\n    absVLNV.setName(absDefName + \".absDef\");\r\n    absVLNV.setType(VLNV::ABSTRACTIONDEFINITION);\r\n\r\n    // by default the abs def and bus def are saved to same directory\r\n    QString absDirectory = directory;\r\n\r\n    if (libraryHandler_->contains(absVLNV))\r\n    {\r\n        VLNV newAbsDefVLNV;\r\n\r\n        if (!NewObjectDialog::saveAsDialog(this, libraryHandler_, absVLNV, newAbsDefVLNV, absDirectory,\r\n            \"Set VLNV for abstraction definition\"))\r\n        {\r\n            // if user canceled\r\n            return;\r\n        }\r\n        // save the created abstraction definition vlnv\r\n        absVLNV = newAbsDefVLNV;\r\n    }\r\n\r\n    // Create a bus definition.\r\n    QSharedPointer<BusDefinition> busDef = QSharedPointer<BusDefinition>(new BusDefinition(busVLNV, revision));\r\n    busDef->setVersion(VersionHelper::versionFileStr());\r\n\r\n    // Create the file for the bus definition.\r\n    bool success = true;\r\n\r\n    if (!libraryHandler_->writeModelToFile(directory, busDef))\r\n    {\r\n        success = false;\r\n    }\r\n\r\n    // create an abstraction definition\r\n    QSharedPointer<AbstractionDefinition> absDef = QSharedPointer<AbstractionDefinition>(\r\n        new AbstractionDefinition(absVLNV, revision));\r\n    absDef->setVersion(VersionHelper::versionFileStr());\r\n\r\n    // set reference from abstraction definition to bus definition\r\n    absDef->setBusType(busVLNV);\r\n\r\n    // create the file for the abstraction definition\r\n    if (!libraryHandler_->writeModelToFile(absDirectory, absDef))\r\n    {\r\n        success = false;\r\n    }\r\n\r\n    if (success)\r\n    {\r\n        // Open the bus editor.\r\n        openBus(busVLNV);\r\n\r\n        unlockNewlyCreatedDocument(busVLNV);\r\n    }\r\n    else\r\n    {\r\n        emit errorMessage(\"Error saving files to disk.\");\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: mainwindow::createAbsDef()\r\n//-----------------------------------------------------------------------------\r\nvoid MainWindow::createAbsDef( const VLNV& busDefVLNV, const QString& directory )\r\n{\r\n    Q_ASSERT(busDefVLNV.isValid());\r\n    Q_ASSERT(!directory.isEmpty());\r\n\r\n    auto busDef = libraryHandler_->getModelReadOnly(busDefVLNV);\r\n\r\n    VLNV absVLNV = busDefVLNV;\r\n\r\n    // remove the possible .busDef from the end of the name field\r\n    QString absDefName = busDefVLNV.getName();\r\n    absDefName = absDefName.remove(\".busDef\", Qt::CaseInsensitive);\r\n\r\n    absVLNV.setName(absDefName + \".absDef\");\r\n    absVLNV.setType(VLNV::ABSTRACTIONDEFINITION);\r\n\r\n    // by default the abs def and bus def are saved to same directory\r\n    QString absDirectory = directory;\r\n\r\n    if (libraryHandler_->contains(absVLNV))\r\n    {\r\n        VLNV newAbsDefVLNV;\r\n\r\n        if (!NewObjectDialog::saveAsDialog(this, libraryHandler_, absVLNV, newAbsDefVLNV, absDirectory,\r\n            \"Set VLNV for abstraction definition\"))\r\n        {\r\n            // if user canceled\r\n            return;\r\n        }\r\n        // save the created abstraction definition vlnv\r\n        absVLNV = newAbsDefVLNV;\r\n    }\r\n\r\n    // create an abstraction definition\r\n    auto absDef = QSharedPointer<AbstractionDefinition>(new AbstractionDefinition(absVLNV, busDef->getRevision()));\r\n    absDef->setVersion(VersionHelper::versionFileStr());\r\n\r\n    // set reference from abstraction definition to bus definition\r\n    absDef->setBusType(busDefVLNV);\r\n\r\n    // create the file for the abstraction definition\r\n    if (!libraryHandler_->writeModelToFile(absDirectory, absDef))\r\n    {\r\n        emit errorMessage(\"Error saving files to disk.\");\r\n        return;\r\n    }\r\n\r\n    // Open the bus editor.\r\n    openAbsDef(absVLNV);\r\n\r\n    unlockNewlyCreatedDocument(absVLNV);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MainWindow::createComDefinition()\r\n//-----------------------------------------------------------------------------\r\nvoid MainWindow::createComDefinition(VLNV const& vlnv, Document::Revision revision, QString const& directory)\r\n{\r\n    Q_ASSERT(vlnv.isValid());\r\n    Q_ASSERT(!directory.isEmpty());\r\n\r\n    // Create an empty COM definition and save it.\r\n    QSharedPointer<ComDefinition> comDef(new ComDefinition(vlnv, revision));\r\n    comDef->setVersion(VersionHelper::versionFileStr());\r\n\r\n    if (!libraryHandler_->writeModelToFile(directory, comDef))\r\n    {\r\n        emit errorMessage(\"Error saving files to disk.\");\r\n        return;\r\n    }\r\n\r\n    // Open the COM definition.\r\n    openComDefinition(vlnv);\r\n    unlockNewlyCreatedDocument(vlnv);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MainWindow::createApiDefinition()\r\n//-----------------------------------------------------------------------------\r\nvoid MainWindow::createApiDefinition(VLNV const& vlnv, Document::Revision revision, QString const& directory)\r\n{\r\n    Q_ASSERT(vlnv.isValid());\r\n    Q_ASSERT(!directory.isEmpty());\r\n\r\n    VLNV apiDefVLNV = vlnv;\r\n\r\n    // Create an empty API definition and save it.\r\n    QSharedPointer<ApiDefinition> apiDef(new ApiDefinition(apiDefVLNV, revision));\r\n    apiDef->setVersion(VersionHelper::versionFileStr());\r\n\r\n    if (!libraryHandler_->writeModelToFile(directory, apiDef))\r\n    {\r\n        emit errorMessage(\"Error saving files to disk.\");\r\n        return;\r\n    }\r\n\r\n    // Open the API definition.\r\n    openApiDefinition(apiDefVLNV);\r\n    unlockNewlyCreatedDocument(vlnv);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: mainwindow::openBus()\r\n//-----------------------------------------------------------------------------\r\nvoid MainWindow::openBus(const VLNV& busDefVLNV)\r\n{\r\n    if (isOpen(busDefVLNV, TabDocument::DocumentType::BUS_DEFINITION) || !busDefVLNV.isValid())\r\n    {\r\n        return;\r\n    }\r\n\r\n    // Editor for given vlnv was not yet open so create one for it\r\n    QSharedPointer<BusDefinition> busDef;\r\n\r\n    if (libraryHandler_->contains(busDefVLNV) &&\r\n        libraryHandler_->getDocumentType(busDefVLNV) == VLNV::BUSDEFINITION)\r\n    {\r\n        busDef = libraryHandler_->getModel(busDefVLNV).dynamicCast<BusDefinition>();\r\n    }\r\n    else\r\n    {\r\n        emit errorMessage(tr(\"Bus definition %1 was not found in the library\").arg(busDefVLNV.toString()));\r\n        return;\r\n    }\r\n\r\n    BusDefinitionEditor* editor = new BusDefinitionEditor(this, libraryHandler_, busDef);\r\n\r\n    designTabs_->addAndOpenDocument(editor);\r\n}\r\n\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: mainwindow::openAbsDef()\r\n//-----------------------------------------------------------------------------\r\nvoid MainWindow::openAbsDef(const VLNV& absDefVLNV)\r\n{\r\n    if (isOpen(absDefVLNV, TabDocument::DocumentType::ABSTRACTION_DEFINITION) || !absDefVLNV.isValid())\r\n    {\r\n        return;\r\n    }\r\n\r\n    // Check if the abstraction editor is already open and activate it.\r\n    for (int i = 0; i < designTabs_->count(); i++)\r\n    {\r\n        TabDocument* editor = dynamic_cast<TabDocument*>(designTabs_->widget(i));\r\n\r\n        if (editor && editor->getDocumentVLNV() == absDefVLNV)\r\n        {\r\n            designTabs_->setCurrentIndex(i);\r\n            return;\r\n        }\r\n    }\r\n\r\n    QSharedPointer<AbstractionDefinition> absDef;\r\n\r\n    if (absDefVLNV.isValid())\r\n    {\r\n        if (libraryHandler_->contains(absDefVLNV) &&\r\n            libraryHandler_->getDocumentType(absDefVLNV) == VLNV::ABSTRACTIONDEFINITION)\r\n        {\r\n            absDef = libraryHandler_->getModel(absDefVLNV).staticCast<AbstractionDefinition>();\r\n        }\r\n        else\r\n        {\r\n            emit errorMessage(tr(\"Abstraction definition %1 was not found in the library\").arg(\r\n                absDefVLNV.toString()));\r\n            return;\r\n        }\r\n    }\r\n\r\n\r\n    auto editor = new AbstractionDefinitionEditor(this, libraryHandler_, absDef, absDef->getRevision());\r\n\r\n    designTabs_->addAndOpenDocument(editor);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MainWindow::openCatalog()\r\n//-----------------------------------------------------------------------------\r\nvoid MainWindow::openCatalog(const VLNV& vlnv)\r\n{\r\n    if (isOpen(vlnv, TabDocument::DocumentType::CATALOG))\r\n    {\r\n        return;\r\n    }\r\n \r\n    if (!libraryHandler_->contains(vlnv))\r\n    {\r\n        emit errorMessage(tr(\"VLNV %1 was not found in the library\").arg(vlnv.toString()));\r\n        return;            \r\n    }\r\n\r\n    QSharedPointer<Catalog> catalog = libraryHandler_->getModel(vlnv).dynamicCast<Catalog>();\r\n    if (catalog == 0)\r\n    {\r\n        emit errorMessage(tr(\"Document could not be opened for Catalog\"));\r\n        return;\r\n    }\r\n\r\n    CatalogEditor* editor = new CatalogEditor(libraryHandler_, catalog, this);\r\n\r\n    connect(editor, SIGNAL(openCatalog(const VLNV&)),\r\n        this, SLOT(openCatalog(const VLNV&)), Qt::UniqueConnection);\r\n\r\n    connect(editor, SIGNAL(openBus(const VLNV&)),\r\n        this, SLOT(openBus(const VLNV&)), Qt::UniqueConnection);\r\n\r\n    connect(editor, SIGNAL(openAbsDef(const VLNV&)),\r\n        this, SLOT(openAbsDef(const VLNV&)), Qt::UniqueConnection);\r\n\r\n    connect(editor, SIGNAL(openComponent(const VLNV&)),\r\n        this, SLOT(openComponent(const VLNV&)), Qt::UniqueConnection);\r\n\r\n    designTabs_->addAndOpenDocument(editor);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: openDesign()\r\n//-----------------------------------------------------------------------------\r\nvoid MainWindow::openHWDesign(VLNV const& vlnv, QString const& viewName)\r\n{\r\n    // The vlnv must always be for a component.\r\n    Q_ASSERT(libraryHandler_->getDocumentType(vlnv) == VLNV::COMPONENT);\r\n\r\n    QSharedPointer<Component> comp = libraryHandler_->getModel(vlnv).staticCast<Component>();\r\n\r\n    // Check if the design is already open.\r\n    VLNV refVLNV = comp->getHierRef(viewName);\r\n    VLNV designVLNV = libraryHandler_->getDesignVLNV(refVLNV);\r\n    if (isOpen(designVLNV, TabDocument::DocumentType::HW_DESIGN) || hasInvalidReferences(comp->getHierRefs(), vlnv))\r\n    {\r\n        return;\r\n    }\r\n\r\n    QSharedPointer<Design> newDesign = libraryHandler_->getDesign(designVLNV);\r\n    dockHandler_->setupDesignParameterFinder(newDesign);\r\n\r\n    DesignWidgetFactoryImplementation factory(libraryHandler_,\r\n        dockHandler_->getDesignAndInstanceParameterFinder(), dockHandler_->getDesignParameterFinder());\r\n    DesignWidget* designWidget = factory.makeHWDesignWidget(this);\r\n\r\n    // open the design in the designWidget\r\n    designWidget->setDesign(vlnv, viewName);\r\n\r\n    // if the design could not be opened\r\n    if (designWidget->getOpenDocument().isEmpty())\r\n    {\r\n        delete designWidget;\r\n        return;\r\n    }\r\n\r\n    connect(designWidget, SIGNAL(zoomChanged()), this, SLOT(updateZoomTools()), Qt::UniqueConnection);\r\n    connect(designWidget, SIGNAL(modeChanged(DrawMode)),\r\n        this, SLOT(onDrawModeChanged(DrawMode)), Qt::UniqueConnection);\r\n\r\n    connect(designWidget, SIGNAL(destroyed(QObject*)), this, SLOT(onClearItemSelection()), Qt::UniqueConnection);\r\n\r\n    connect(designWidget, SIGNAL(openDesign(const VLNV&, const QString&)),\r\n        this, SLOT(openHWDesign(const VLNV&, const QString&)));\r\n    connect(designWidget, SIGNAL(openComponent(const VLNV&)),\r\n        this, SLOT(openComponent(const VLNV&)), Qt::UniqueConnection);\r\n    connect(designWidget, SIGNAL(openBus(VLNV const&)),\r\n        this, SLOT(openBus(VLNV const&)), Qt::UniqueConnection);\r\n\r\n    connect(designWidget, SIGNAL(componentSelected(ComponentItem*)),\r\n        this, SLOT(onComponentSelected(ComponentItem*)), Qt::UniqueConnection);\r\n    connect(designWidget, SIGNAL(interfaceSelected(ConnectionEndpoint*)),\r\n        this, SLOT(onInterfaceSelected(ConnectionEndpoint*)), Qt::UniqueConnection);\r\n    connect(designWidget, SIGNAL(connectionSelected(GraphicsConnection*)),\r\n        this, SLOT(onConnectionSelected(GraphicsConnection*)), Qt::UniqueConnection);\r\n\r\n    connect(designWidget, SIGNAL(clearItemSelection()),\r\n        this, SLOT(onClearItemSelection()), Qt::UniqueConnection);\r\n    connect(designWidget, SIGNAL(refreshed()), this, SLOT(onDesignDocumentRefreshed()), Qt::UniqueConnection);\r\n\r\n    designTabs_->addAndOpenDocument(designWidget);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MainWindow::openMemoryDesign()\r\n//-----------------------------------------------------------------------------\r\nvoid MainWindow::openMemoryDesign()\r\n{\r\n    TabDocument* doc = static_cast<TabDocument*>(designTabs_->currentWidget());\r\n\r\n    if (doc)\r\n    {\r\n        DesignWidget* currentDesignWidget = static_cast<DesignWidget*>(doc);\r\n        if (currentDesignWidget)\r\n        {\r\n            QString activeView = currentDesignWidget->getOpenViewName();\r\n            libraryHandler_->onOpenMemoryDesign(doc->getDocumentVLNV(), activeView);\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MainWindow::openMemoryDesign()\r\n//-----------------------------------------------------------------------------\r\nvoid MainWindow::openMemoryDesign(VLNV const& vlnv, QString const& viewName)\r\n{\r\n    // the vlnv must always be for a component\r\n    Q_ASSERT(libraryHandler_->getDocumentType(vlnv) == VLNV::COMPONENT);\r\n\r\n    QSharedPointer<Component> comp = libraryHandler_->getModel(vlnv).staticCast<Component>();\r\n\r\n    // check if the design is already open\r\n    if (isOpen(vlnv, TabDocument::DocumentType::MEMORY_DESIGN))\r\n    {\r\n        return;\r\n    }\r\n\r\n    // make sure that all component's hierarchy refs are valid\r\n    // if there was at least one invalid reference then do not open the design\r\n    if (hasInvalidReferences(comp->getHierRefs(), vlnv))\r\n    {\r\n        return;\r\n    }\r\n\r\n    QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));\r\n\r\n    MemoryDesignDocument* memoryDesignWidget = new MemoryDesignDocument(libraryHandler_, this);\r\n\r\n    connect(memoryDesignWidget, SIGNAL(errorMessage(const QString&)),\r\n        dockHandler_, SIGNAL(errorMessage(const QString&)), Qt::UniqueConnection);\r\n\r\n    if (!memoryDesignWidget->setDesign(vlnv, viewName))\r\n    {\r\n        QApplication::restoreOverrideCursor();\r\n        delete memoryDesignWidget;\r\n        return;\r\n    }\r\n\r\n    connect(memoryDesignWidget, SIGNAL(zoomChanged()), this, SLOT(updateZoomTools()), Qt::UniqueConnection);\r\n\r\n    connect(memoryDesignWidget, SIGNAL(destroyed(QObject*)), this, SLOT(onClearItemSelection()), Qt::UniqueConnection);\r\n\r\n//     connect(memoryDesignWidget, SIGNAL(clearItemSelection()),\r\n//         libraryHandler_, SLOT(onClearSelection()), Qt::UniqueConnection);\r\n\r\n    connect(memoryDesignWidget, SIGNAL(clearItemSelection()), this, SLOT(onClearItemSelection()), Qt::UniqueConnection);\r\n\r\n    connect(memoryDesignWidget, SIGNAL(openComponentDocument(VLNV const&, QVector<QString>)),\r\n        this, SLOT(onOpenComponentItem(const VLNV&, QVector<QString>)), Qt::UniqueConnection);\r\n\r\n    designTabs_->addAndOpenDocument(memoryDesignWidget);\r\n\r\n    QApplication::restoreOverrideCursor();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: mainwindow::onInterconnectGenerate()\r\n//-----------------------------------------------------------------------------\r\n\r\nvoid MainWindow::onInterconnectGenerate()\r\n{\r\n    auto doc = static_cast<TabDocument*>(designTabs_->currentWidget());\r\n\r\n    if (!doc || doc->isProtected())\r\n    {\r\n        return;\r\n    }\r\n    auto designWidget = static_cast<DesignWidget*>(doc);\r\n\r\n    InterconnectGeneration::Dialog interconnectDialog(designWidget, libraryHandler_, messageChannel_, this);\r\n    if (interconnectDialog.exec() == QDialog::Accepted) {\r\n        auto config = interconnectDialog.getConfig();\r\n        if (!config) {\r\n            return;\r\n        }\r\n        auto const& startingPoints = interconnectDialog.getSelectedStartingPoints();\r\n        auto const& endPoints = interconnectDialog.getSelectedEndpoints();\r\n\r\n        bool generateRtl = interconnectDialog.rtlGenerationSelected();\r\n\r\n        LibraryInterface* lib = KactusAPI::getLibrary();\r\n        auto interconGen = InterconnectGeneration::Generator(lib, messageChannel_);\r\n        interconGen.generate(config, startingPoints, endPoints, generateRtl);\r\n        doc->refresh();\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: mainwindow::onOpenComponentItem()\r\n//-----------------------------------------------------------------------------\r\nvoid MainWindow::onOpenComponentItem(const VLNV& componentVLNV, QVector<QString> identifierChain)\r\n{\r\n    openComponent(componentVLNV);\r\n\r\n    if (!identifierChain.isEmpty())\r\n    {\r\n        TabDocument* doc = static_cast<TabDocument*>(designTabs_->currentWidget());\r\n        if (doc)\r\n        {\r\n            ComponentEditor* componentEditor = dynamic_cast<ComponentEditor*>(doc);\r\n            if (componentEditor)\r\n            {\r\n                componentEditor->openItemEditor(identifierChain);\r\n            }\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: openSWDesign()\r\n//-----------------------------------------------------------------------------\r\nvoid MainWindow::openSWDesign(const VLNV& vlnv, QString const& viewName)\r\n{\r\n    // the vlnv must always be for a component\r\n    Q_ASSERT(libraryHandler_->getDocumentType(vlnv) == VLNV::COMPONENT);\r\n\r\n    QSharedPointer<Component> comp = libraryHandler_->getModel(vlnv).staticCast<Component>();\r\n\r\n    // check if the design is already open\r\n    VLNV refVLNV = comp->getHierRef(viewName);\r\n    VLNV designVLNV = libraryHandler_->getDesignVLNV(refVLNV);\r\n    if (isOpen(designVLNV, TabDocument::DocumentType::SW_DESIGN))\r\n    {\r\n        return;\r\n    }\r\n\r\n    SystemDesignWidget* designWidget = new SystemDesignWidget(true, libraryHandler_, this);\r\n\r\n    connect(designWidget, SIGNAL(errorMessage(const QString&)),\r\n        dockHandler_, SIGNAL(errorMessage(const QString&)), Qt::UniqueConnection);\r\n    connect(designWidget, SIGNAL(noticeMessage(const QString&)),\r\n        dockHandler_, SIGNAL(noticeMessage(const QString&)), Qt::UniqueConnection);\r\n\r\n    if (!designWidget->setDesign(vlnv, viewName))\r\n    {\r\n        delete designWidget;\r\n        return;\r\n    }\r\n\r\n    disconnect(designWidget, SIGNAL(errorMessage(const QString&)),\r\n        dockHandler_, SIGNAL(errorMessage(const QString&)));\r\n    disconnect(designWidget, SIGNAL(noticeMessage(const QString&)),\r\n        dockHandler_, SIGNAL(noticeMessage(const QString&)));\r\n\r\n    connect(designWidget, SIGNAL(openComponent(const VLNV&)),\r\n        this, SLOT(openComponent(const VLNV&)), Qt::UniqueConnection);\r\n    connect(designWidget, SIGNAL(openSWDesign(const VLNV&, const QString&)),\r\n        this, SLOT(openSWDesign(const VLNV&, const QString&)));\r\n    connect(designWidget, SIGNAL(openCSource(ComponentItem*)),\r\n        this, SLOT(openCSource(ComponentItem*)), Qt::UniqueConnection);\r\n\r\n    connect(designWidget, SIGNAL(componentSelected(ComponentItem*)),\r\n        this, SLOT(onComponentSelected(ComponentItem*)), Qt::UniqueConnection);\r\n    connect(designWidget, SIGNAL(interfaceSelected(ConnectionEndpoint*)),\r\n        this, SLOT(onInterfaceSelected(ConnectionEndpoint*)), Qt::UniqueConnection);\r\n    connect(designWidget, SIGNAL(connectionSelected(GraphicsConnection*)),\r\n        this, SLOT(onConnectionSelected(GraphicsConnection*)), Qt::UniqueConnection);\r\n    connect(designWidget, SIGNAL(destroyed(QObject*)), this, SLOT(onClearItemSelection()), Qt::UniqueConnection);\r\n//     connect(designWidget, SIGNAL(clearItemSelection()),\r\n//         libraryHandler_, SLOT(onClearSelection()), Qt::UniqueConnection);\r\n    connect(designWidget, SIGNAL(clearItemSelection()), this, SLOT(onClearItemSelection()), Qt::UniqueConnection);\r\n\r\n    connect(designWidget, SIGNAL(refreshed()), this, SLOT(onDesignDocumentRefreshed()), Qt::UniqueConnection);\r\n    connect(designWidget, SIGNAL(zoomChanged()), this, SLOT(updateZoomTools()), Qt::UniqueConnection);\r\n    connect(designWidget, SIGNAL(modeChanged(DrawMode)),\r\n        this, SLOT(onDrawModeChanged(DrawMode)), Qt::UniqueConnection);\r\n    connect(designWidget, SIGNAL(modifiedChanged(bool)), actSave_, SLOT(setEnabled(bool)), Qt::UniqueConnection);\r\n\r\n    designTabs_->addAndOpenDocument(designWidget);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: openSystemDesign()\r\n//-----------------------------------------------------------------------------\r\nvoid MainWindow::openSystemDesign(VLNV const& vlnv, QString const& viewName)\r\n{\r\n    // the vlnv must always be for a component\r\n    Q_ASSERT(libraryHandler_->getDocumentType(vlnv) == VLNV::COMPONENT);\r\n\r\n    QSharedPointer<Component> comp = libraryHandler_->getModel(vlnv).staticCast<Component>();\r\n\r\n    // check if the design is already open\r\n    VLNV refVLNV = comp->getHierSystemRef(viewName);\r\n    VLNV designVLNV = libraryHandler_->getDesignVLNV(refVLNV);\r\n    if (isOpen(designVLNV, TabDocument::DocumentType::SYSTEM_DESIGN))\r\n    {\r\n        return;\r\n    }\r\n\r\n    QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));\r\n\r\n    SystemDesignWidget* designWidget = new SystemDesignWidget(false, libraryHandler_, this);\r\n\r\n    connect(designWidget, SIGNAL(errorMessage(const QString&)),\r\n        dockHandler_, SIGNAL(errorMessage(const QString&)), Qt::UniqueConnection);\r\n    connect(designWidget, SIGNAL(noticeMessage(const QString&)),\r\n        dockHandler_, SIGNAL(noticeMessage(const QString&)), Qt::UniqueConnection);\r\n\r\n    if (!designWidget->setDesign(vlnv, viewName))\r\n    {\r\n        delete designWidget;\r\n        QApplication::restoreOverrideCursor();\r\n        return;\r\n    }\r\n\r\n    disconnect(designWidget, SIGNAL(errorMessage(const QString&)),\r\n        dockHandler_, SIGNAL(errorMessage(const QString&)));\r\n    disconnect(designWidget, SIGNAL(noticeMessage(const QString&)),\r\n        dockHandler_, SIGNAL(noticeMessage(const QString&)));\r\n\r\n    connect(designWidget, SIGNAL(openComponent(const VLNV&)),\r\n        this, SLOT(openComponent(const VLNV&)), Qt::UniqueConnection);\r\n    connect(designWidget, SIGNAL(openSWDesign(const VLNV&, const QString&)),\r\n        this, SLOT(openSWDesign(const VLNV&, const QString&)));\r\n    connect(designWidget, SIGNAL(openCSource(ComponentItem*)),\r\n        this, SLOT(openCSource(ComponentItem*)), Qt::UniqueConnection);\r\n\r\n    connect(designWidget, SIGNAL(componentSelected(ComponentItem*)),\r\n        this, SLOT(onComponentSelected(ComponentItem*)), Qt::UniqueConnection);\r\n    connect(designWidget, SIGNAL(interfaceSelected(ConnectionEndpoint*)),\r\n        this, SLOT(onInterfaceSelected(ConnectionEndpoint*)), Qt::UniqueConnection);\r\n    connect(designWidget, SIGNAL(connectionSelected(GraphicsConnection*)),\r\n        this, SLOT(onConnectionSelected(GraphicsConnection*)), Qt::UniqueConnection);\r\n    connect(designWidget, SIGNAL(destroyed(QObject*)),\r\n        this, SLOT(onClearItemSelection()), Qt::UniqueConnection);\r\n//     connect(designWidget, SIGNAL(clearItemSelection()),\r\n//         libraryHandler_, SLOT(onClearSelection()), Qt::UniqueConnection);\r\n    connect(designWidget, SIGNAL(clearItemSelection()),\r\n        this, SLOT(onClearItemSelection()), Qt::UniqueConnection);\r\n\r\n    connect(designWidget, SIGNAL(refreshed()), this, SLOT(onDesignDocumentRefreshed()), Qt::UniqueConnection);\r\n    connect(designWidget, SIGNAL(zoomChanged()), this, SLOT(updateZoomTools()), Qt::UniqueConnection);\r\n    connect(designWidget, SIGNAL(modeChanged(DrawMode)),\r\n        this, SLOT(onDrawModeChanged(DrawMode)), Qt::UniqueConnection);\r\n    connect(designWidget, SIGNAL(modifiedChanged(bool)),\r\n        actSave_, SLOT(setEnabled(bool)), Qt::UniqueConnection);\r\n\r\n    designTabs_->addAndOpenDocument(designWidget);\r\n\r\n    QApplication::restoreOverrideCursor();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: mainwindow::openComponent()\r\n//-----------------------------------------------------------------------------\r\nvoid MainWindow::openComponent(VLNV const& vlnv)\r\n{\r\n\r\n    QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));\r\n\r\n    QSharedPointer<Component> component;\r\n\r\n    if (libraryHandler_->contains(vlnv))\r\n    {\r\n        component = libraryHandler_->getModel(vlnv).dynamicCast<Component>();\r\n    }\r\n    else\r\n    {\r\n        emit errorMessage(tr(\"VLNV %1 was not found in the library\").arg(vlnv.toString()));\r\n        QApplication::restoreOverrideCursor();\r\n        return;\r\n    }\r\n\r\n    if (!component)\r\n    {\r\n        emit errorMessage(tr(\"Document could not be opened for Component\"));\r\n        QApplication::restoreOverrideCursor();\r\n        return;\r\n    }\r\n\r\n    ComponentEditor* editor = new ComponentEditor(libraryHandler_, component, this);\r\n\r\n    if (isOpen(vlnv, editor->getDocType()))\r\n    {\r\n        QApplication::restoreOverrideCursor();\r\n        return;\r\n    }\r\n\r\n    connect(editor, SIGNAL(openCSource(QString const&, QSharedPointer<Component>)),\r\n            this , SLOT(openCSource(QString const&, QSharedPointer<Component>)), Qt::UniqueConnection);\r\n    connect(editor, SIGNAL(openDesign(const VLNV&, const QString&)),\r\n        this, SLOT(openHWDesign(const VLNV&, const QString&)), Qt::UniqueConnection);\r\n    connect(editor, SIGNAL(openBus(const VLNV&)),\r\n        this, SLOT(openBus(const VLNV&)), Qt::UniqueConnection);\r\n    connect(editor, SIGNAL(openAbsDef(const VLNV&)),\r\n        this, SLOT(openAbsDef(const VLNV&)), Qt::UniqueConnection);\r\n    connect(editor, SIGNAL(openComDefinition(const VLNV&)),\r\n        this, SLOT(openComDefinition(const VLNV&)), Qt::UniqueConnection);\r\n    connect(editor, SIGNAL(openSWDesign(const VLNV&, const QString&)),\r\n        this, SLOT(openSWDesign(const VLNV&, const QString&)), Qt::UniqueConnection);\r\n    connect(editor, SIGNAL(openSystemDesign(const VLNV&, const QString&)),\r\n        this, SLOT(openSystemDesign(const VLNV&, const QString&)), Qt::UniqueConnection);\r\n\r\n    designTabs_->addAndOpenDocument(editor);\r\n\r\n    QApplication::restoreOverrideCursor();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MainWindow::openComDefinition()\r\n//-----------------------------------------------------------------------------\r\nvoid MainWindow::openComDefinition(VLNV const& vlnv)\r\n{\r\n    if (isOpen(vlnv, TabDocument::DocumentType::COM_DEFINITION))\r\n    {\r\n        return;\r\n    }\r\n\r\n    // Editor was not yet open so create it.\r\n    QSharedPointer<ComDefinition> comDef;\r\n\r\n    if (libraryHandler_->contains(vlnv))\r\n    {\r\n        comDef = libraryHandler_->getModel(vlnv).dynamicCast<ComDefinition>();\r\n    }\r\n    else\r\n    {\r\n        emit errorMessage(tr(\"VLNV %1 was not found in the library\").arg(vlnv.toString()));\r\n        return;\r\n    }\r\n\r\n    if (comDef == 0)\r\n    {\r\n        emit errorMessage(tr(\"Document could not be opened for COM Definition\"));\r\n        return;\r\n    }\r\n\r\n    ComDefinitionEditor* editor = new ComDefinitionEditor(this, libraryHandler_, comDef);\r\n\r\n    designTabs_->addAndOpenDocument(editor);\r\n}\r\n\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MainWindow::openApiDefinition()\r\n//-----------------------------------------------------------------------------\r\nvoid MainWindow::openApiDefinition(VLNV const& vlnv)\r\n{\r\n    if (isOpen(vlnv, TabDocument::DocumentType::API_DEFINITION))\r\n    {\r\n        return;\r\n    }\r\n\r\n    // Editor was not yet open so create it.\r\n    QSharedPointer<ApiDefinition> apiDef;\r\n\r\n    if (libraryHandler_->contains(vlnv))\r\n    {\r\n        apiDef = libraryHandler_->getModel(vlnv).dynamicCast<ApiDefinition>();\r\n    }\r\n    else\r\n    {\r\n        emit errorMessage(tr(\"VLNV %1 was not found in the library\").arg(vlnv.toString()));\r\n        return;\r\n    }\r\n\r\n    if (apiDef == 0)\r\n    {\r\n        emit errorMessage(tr(\"Document could not be opened for API Definition\"));\r\n        return;\r\n    }\r\n\r\n    ApiDefinitionEditor* editor = new ApiDefinitionEditor(this, libraryHandler_, apiDef);\r\n\r\n    designTabs_->addAndOpenDocument(editor);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MainWindow::isOpen()\r\n//-----------------------------------------------------------------------------\r\nbool MainWindow::isOpen(VLNV const& vlnv, TabDocument::DocumentType const& type) const\r\n{\r\n    if (!vlnv.isValid())\r\n    {\r\n        return false;\r\n    }\r\n\r\n    for (int i = 0; i < designTabs_->count(); i++)\r\n    {\r\n        TabDocument* document = dynamic_cast<TabDocument*>(designTabs_->widget(i));\r\n\r\n        // if the document is already open is some tab\r\n        if (document && document->getIdentifyingVLNV() == vlnv && document->getDocType() == type)\r\n        {\r\n            designTabs_->setCurrentIndex(i);\r\n            return true;\r\n        }\r\n    }\r\n    // document was not open\r\n    return false;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: mainwindow::updateWindows()\r\n//-----------------------------------------------------------------------------\r\nvoid MainWindow::updateWindows()\r\n{\r\n    dockHandler_->updateWindows(designTabs_->currentWidget());\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MainWindow::updateVisibilityControlMenu()\r\n//-----------------------------------------------------------------------------\r\nvoid MainWindow::updateVisibilityControlMenu(TabDocument* document)\r\n{\r\n    visibilityMenu_.clear();\r\n\r\n    QActionGroup* group = new QActionGroup(this);\r\n    group->setExclusive(false);\r\n\r\n    QMapIterator<QString, bool> iter(document->getVisibilityControls());\r\n    while (iter.hasNext())\r\n    {\r\n        iter.next();\r\n\r\n        QAction* action = new QAction(iter.key(), this);\r\n        action->setCheckable(true);\r\n        action->setChecked(iter.value());\r\n\r\n        group->addAction(action);\r\n        visibilityMenu_.addAction(action);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MainWindow::connectVisibilityControls()\r\n//-----------------------------------------------------------------------------\r\nvoid MainWindow::connectVisibilityControls()\r\n{\r\n    connect(dockHandler_, SIGNAL(adjustVisibilityInWindow(TabDocument::SupportedWindows, bool)),\r\n        this, SLOT(onAdjustVisibilityInWindow(TabDocument::SupportedWindows, bool)), Qt::UniqueConnection);\r\n    dockHandler_->connectVisibilityControls();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MainWindow::disconnectVisibilityControls()\r\n//-----------------------------------------------------------------------------\r\nvoid MainWindow::disconnectVisibilityControls()\r\n{\r\n    disconnect(dockHandler_, SIGNAL(adjustVisibilityInWindow(TabDocument::SupportedWindows, bool)),\r\n        this, SLOT(onAdjustVisibilityInWindow(TabDocument::SupportedWindows, bool)));\r\n    dockHandler_->disconnectVisibilityControls();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: openCSource()\r\n//-----------------------------------------------------------------------------\r\nvoid MainWindow::openCSource(ComponentItem* compItem)\r\n{\r\n    Q_ASSERT(compItem != 0);\r\n\r\n    QSharedPointer<FileSet> fileSet = compItem->componentModel()->getFileSet(\"cSources\");\r\n\r\n    if (fileSet == 0 || fileSet->getFiles()->count() == 0)\r\n    {\r\n        return;\r\n    }\r\n\r\n    QString filename;\r\n\r\n    if (fileSet->getFiles()->count() > 1)\r\n    {\r\n        // Show a dialog for selecting what source file to open.\r\n        ListSelectDialog saveDialog(this);\r\n        saveDialog.setWindowTitle(tr(\"Open Source\"));\r\n        saveDialog.setDescription(tr(\"Select C source file to open:\"));\r\n\r\n        for (QSharedPointer<File> file : *fileSet->getFiles())\r\n        {\r\n            saveDialog.addItem(new QListWidgetItem(file->name()));\r\n        }\r\n\r\n        if (saveDialog.exec() == QDialog::Rejected)\r\n        {\r\n            return;\r\n        }\r\n\r\n        filename = saveDialog.getSelectedItem()->text();\r\n    }\r\n    else\r\n    {\r\n        // Otherwise there is only one possibility.\r\n        filename = fileSet->getFiles()->first()->name();\r\n    }\r\n\r\n    if (compItem->componentModel()->getVlnv().isValid())\r\n    {\r\n        filename = General::getAbsolutePath(libraryHandler_->getPath(compItem->componentModel()->getVlnv()),\r\n            filename);\r\n    }\r\n\r\n    openCSource(filename, compItem->componentModel());\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MainWindow::openCSource()\r\n//-----------------------------------------------------------------------------\r\nvoid MainWindow::openCSource(QString const& filename, QSharedPointer<Component> component)\r\n{\r\n    // Check if the source is already open and activate it.\r\n    for (int i = 0; i < designTabs_->count(); i++)\r\n    {\r\n        CSourceWidget* sourceWidget = dynamic_cast<CSourceWidget*>(designTabs_->widget(i));\r\n\r\n        if (sourceWidget != 0 && sourceWidget->getSourceFile() == filename)\r\n        {\r\n            designTabs_->setCurrentIndex(i);\r\n            return;\r\n        }\r\n    }\r\n\r\n    // Otherwise make sure that the file exists.\r\n    if (!QFile::exists(filename))\r\n    {\r\n        QMessageBox msgBox(QMessageBox::Critical, QCoreApplication::applicationName(),\r\n            \"The source file \" + filename + \" is not found!\", QMessageBox::Ok, this);\r\n        msgBox.exec();\r\n        return;\r\n    }\r\n\r\n    // Open the source to a view.\r\n    CSourceWidget* sourceWidget = new CSourceWidget(filename, component, libraryHandler_, this, this);\r\n    designTabs_->addAndOpenDocument(sourceWidget);\r\n\r\n    dynamic_cast<TabDocument*>(designTabs_->currentWidget())->setProtection(false);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: changeProtection()\r\n//-----------------------------------------------------------------------------\r\nvoid MainWindow::changeProtection(bool locked)\r\n{\r\n    TabDocument* doc = static_cast<TabDocument*>(designTabs_->currentWidget());\r\n\r\n    // if there is no currently selected tab\r\n    if (!doc)\r\n    {\r\n        return;\r\n    }\r\n\r\n    VLNV docVLNV = doc->getDocumentVLNV();\r\n    Q_ASSERT(docVLNV.isValid());\r\n\r\n    // if user set the document to be locked and it has been modified\r\n    if (locked)\r\n    {\r\n        if (doc->isModified())\r\n        {\r\n            // ask user if he wants to save the changes made to document\r\n            QMessageBox msgBox(QMessageBox::Warning, QCoreApplication::applicationName(),\r\n                tr(\"The document has been modified. The changes need to be saved before the \"\r\n                \"document can be locked. Save changes and continue?\"), QMessageBox::Yes | QMessageBox::No, this);\r\n\r\n            // if user does not want to save or save can't be done\r\n            if (msgBox.exec() == QMessageBox::No || !doc->save())\r\n            {\r\n                actProtect_->setChecked(false);\r\n                return;\r\n            }\r\n        }\r\n        // lock the document\r\n        doc->setProtection(locked);\r\n    }\r\n\r\n    //If user wants to unlock the document.\r\n    else\r\n    {\r\n        // The list containing tabs for the same document.\r\n        QVector<TabDocument*> otherDocs;\r\n\r\n        // If the same document has been edited in another editor.\r\n        TabDocument* docToSave = 0;\r\n\r\n        for (int i = 0; i < designTabs_->count(); i++)\r\n        {\r\n            TabDocument* otherDoc = static_cast<TabDocument*>(designTabs_->widget(i));\r\n            Q_ASSERT(otherDoc);\r\n\r\n            // if the other document is for the same component\r\n            if (otherDoc != doc && otherDoc->getDocumentVLNV() == docVLNV)\r\n            {\r\n                otherDocs.append(otherDoc);\r\n\r\n                // If there is a document that is not locked and has been modified.\r\n                if (!otherDoc->isProtected() && otherDoc->isModified())\r\n                {\r\n                    // there should only be one doc at a time that can be modified\r\n                    Q_ASSERT(!docToSave);\r\n\r\n                    // this was the document that was modified\r\n                    docToSave = otherDoc;\r\n                }\r\n            }\r\n        }\r\n\r\n        // if there was document that was unlocked and modified\r\n        if (docToSave)\r\n        {\r\n            // Ask the user if he wants to save and switch locks.\r\n            QMessageBox msgBox(QMessageBox::Warning, QCoreApplication::applicationName(),\r\n                tr(\"The document is being edited in another tab and has unsaved changes. Changes need to be saved \"\r\n                   \"before this tab can be unlocked. Save changes and switch locks?\"),\r\n                QMessageBox::Yes | QMessageBox::No, this);\r\n\r\n            // Restore the lock if the user canceled.\r\n            if (msgBox.exec() == QMessageBox::No)\r\n            {\r\n                actProtect_->setChecked(true);\r\n                return;\r\n            }\r\n\r\n            // if the document could not be saved\r\n            if (!docToSave->save())\r\n            {\r\n                return;\r\n            }\r\n        }\r\n\r\n        bool previouslyUnlocked = doc->isPreviouslyUnlocked();\r\n\r\n        // User wanted to unlock this doc so go through other documents to see if they were unlocked.\r\n        for (TabDocument* otherDoc : otherDocs)\r\n        {\r\n            otherDoc->setProtection(true);\r\n\r\n            if (otherDoc->isPreviouslyUnlocked())\r\n            {\r\n                previouslyUnlocked = true;\r\n            }\r\n        }\r\n\r\n        if (!previouslyUnlocked)\r\n        {\r\n            QString message = tr(\"Are you sure you want to unlock the document?\\n\");\r\n            QString detailMsg = \"\";\r\n\r\n            // If edited document was component and has been instantiated in other components, print them.\r\n            if (docVLNV.isValid() && libraryHandler_->getDocumentType(docVLNV) == VLNV::COMPONENT)\r\n            {\r\n                QList<VLNV> list;\r\n                int refCount = libraryHandler_->getOwners(list, docVLNV);\r\n                if (refCount > 0)\r\n                {\r\n                    message += tr(\"Changes to the document can affect %1 other documents.\").arg(refCount);\r\n\r\n                    detailMsg += tr(\"The component has been instantiated in the following %1 component(s):\\n\").arg(\r\n                        refCount);\r\n                    for (VLNV const& owner : list)\r\n                    {\r\n                        detailMsg += \"* \" + owner.toString() + \"\\n\";\r\n                    }\r\n                }\r\n                else\r\n                {\r\n                    message += tr(\"Changes to the document can affect other documents. \");\r\n                }\r\n            }\r\n            else\r\n            {\r\n                message += tr(\"Changes to the document can affect other documents. \");\r\n            }\r\n\r\n            message += \"If you choose yes, this will not be asked next time for this document.\";\r\n\r\n            // Ask verification from the user.\r\n            QMessageBox msgBox(QMessageBox::Warning, QCoreApplication::applicationName(), message,\r\n                QMessageBox::Yes | QMessageBox::No, this);\r\n\r\n            msgBox.setDetailedText(detailMsg);\r\n\r\n            // if user did not want to unlock the document\r\n            if (msgBox.exec() == QMessageBox::No)\r\n            {\r\n                actProtect_->setChecked(true);\r\n                return;\r\n            }\r\n        }\r\n\r\n        // mark the other documents also unlocked to keep the unlock history in sync.\r\n        for (TabDocument* otherDoc : otherDocs)\r\n        {\r\n            otherDoc->setPreviouslyUnlocked();\r\n        }\r\n\r\n        // Unlock the document.\r\n        doc->setProtection(locked);\r\n    }\r\n\r\n    dockHandler_->changeProtection(doc, locked);\r\n\r\n    // Clear the item selection since the current instance is no longer valid.\r\n    onClearItemSelection();\r\n\r\n    onProtectionChanged(locked);\r\n\r\n    updateMenuStrip();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: onProtectionChanged()\r\n//-----------------------------------------------------------------------------\r\nvoid MainWindow::onProtectionChanged(bool locked)\r\n{\r\n    if (locked)\r\n    {\r\n        actProtect_->setIcon(QIcon(\":icons/common/graphics/protection-locked.png\"));\r\n        actProtect_->setText(tr(\"Locked (Ctrl+L)\"));\r\n    }\r\n    else\r\n    {\r\n        actProtect_->setIcon(QIcon(\":icons/common/graphics/protection-unlocked.png\"));\r\n        actProtect_->setText(tr(\"Unlocked (Ctrl+L)\"));\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: undo()\r\n//-----------------------------------------------------------------------------\r\nvoid MainWindow::undo()\r\n{\r\n    TabDocument* doc = static_cast<TabDocument*>(designTabs_->currentWidget());\r\n\r\n    if (doc != 0)\r\n    {\r\n        doc->getEditProvider()->undo();\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: redo()\r\n//-----------------------------------------------------------------------------\r\nvoid MainWindow::redo()\r\n{\r\n    TabDocument* doc = static_cast<TabDocument*>(designTabs_->currentWidget());\r\n\r\n    if (doc != 0)\r\n    {\r\n        doc->getEditProvider()->redo();\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: mainwindow::createSWComponent()\r\n//-----------------------------------------------------------------------------\r\nvoid MainWindow::createSWComponent(VLNV const& vlnv, Document::Revision revision, QString const& directory)\r\n{\r\n    Q_ASSERT(vlnv.isValid());\r\n\r\n    // Create a component.\r\n    QSharedPointer<Component> component = QSharedPointer<Component>(new Component(vlnv, revision));\r\n    component->setVersion(VersionHelper::versionFileStr());\r\n\r\n    // Set Kactus attributes.\r\n    component->setImplementation(KactusAttribute::SW);\r\n\r\n    // Create the file.\r\n    if (!libraryHandler_->writeModelToFile(directory, component))\r\n    {\r\n        emit errorMessage(\"Error saving files to disk.\");\r\n        return;\r\n    }\r\n\r\n    runComponentWizard(component, directory);\r\n\r\n    openComponent(vlnv);\r\n\r\n    unlockNewlyCreatedDocument(vlnv);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: showAbout()\r\n//-----------------------------------------------------------------------------\r\nvoid MainWindow::showAbout()\r\n{\r\n    SplashScreen* splash = new SplashScreen(VersionHelper::createVersionString());\r\n    splash->setAttribute(Qt::WA_DeleteOnClose);\r\n    splash->setWindowFlags(splash->windowFlags() & ~(Qt::WindowStaysOnTopHint | Qt::X11BypassWindowManagerHint));\r\n    splash->move(this->mapToGlobal(this->rect().center() - splash->rect().center()));\r\n    splash->setWindowModality(Qt::ApplicationModal);\r\n    splash->show();\r\n    splash->showMessage(\"\");\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: mainwindow::selectVisibleDocks()\r\n//-----------------------------------------------------------------------------\r\nvoid MainWindow::selectVisibleDocks()\r\n{\r\n    windowsMenu_.exec(QCursor::pos());\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: mainwindow::hideEvent()\r\n//-----------------------------------------------------------------------------\r\nvoid MainWindow::hideEvent( QHideEvent* event )\r\n{\r\n    disconnectVisibilityControls();\r\n    QMainWindow::hideEvent(event);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: mainwindow::showEvent()\r\n//-----------------------------------------------------------------------------\r\nvoid MainWindow::showEvent( QShowEvent* event )\r\n{\r\n    connectVisibilityControls();\r\n    QMainWindow::showEvent(event);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: openWorkspaceMenu()\r\n//-----------------------------------------------------------------------------\r\nvoid MainWindow::openWorkspaceMenu()\r\n{\r\n    workspaceMenu_.exec(QCursor::pos());\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MainWindow::onWorkspaceChanged()\r\n//-----------------------------------------------------------------------------\r\nvoid MainWindow::onWorkspaceChanged(QString const& workspace)\r\n{\r\n    actWorkspaces_->setText(workspace);\r\n\r\n    designTabs_->applySettings();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: openVisibilityControlMenu()\r\n//-----------------------------------------------------------------------------\r\nvoid MainWindow::openVisibilityControlMenu()\r\n{\r\n    visibilityMenu_.exec(QCursor::pos());\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: onVisibilityControlToggled()\r\n//-----------------------------------------------------------------------------\r\nvoid MainWindow::onVisibilityControlToggled(QAction* action)\r\n{\r\n    TabDocument* doc = static_cast<TabDocument*>(designTabs_->currentWidget());\r\n    Q_ASSERT(doc != 0);\r\n\r\n    doc->setVisibilityControlState(action->text(), !doc->getVisibilityControls().value(action->text()));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MainWindow::isDesignOpen()\r\n//-----------------------------------------------------------------------------\r\nbool MainWindow::isDesignOpen(VLNV const& vlnv, KactusAttribute::Implementation implementation) const\r\n{\r\n    if (vlnv.isValid())\r\n    {\r\n        for (int i = 0; i < designTabs_->count(); i++)\r\n        {\r\n            DesignWidget* designWidget = dynamic_cast<DesignWidget*>(designTabs_->widget(i));\r\n\r\n            if (designWidget != 0 && designWidget->getOpenDocument() == vlnv &&\r\n                designWidget->getImplementation() == implementation)\r\n            {\r\n                designTabs_->setCurrentIndex(i);\r\n                return true;\r\n            }\r\n        }\r\n    }\r\n\r\n    return false;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MainWindow::hasInvalidReferences()\r\n//-----------------------------------------------------------------------------\r\nbool MainWindow::hasInvalidReferences(QList<VLNV> hierRefs, VLNV const& referencingVlnv)\r\n{\r\n    bool invalidReferences = false;\r\n    for (VLNV const& ref : hierRefs)\r\n    {\r\n        // if the hierarchy referenced object is not found in library\r\n        if (!libraryHandler_->contains(ref))\r\n        {\r\n            emit errorMessage(tr(\"Component %1 has hierarchical reference to object %2,\"\r\n                \" which is not found in library. Component is not valid and can not \"\r\n                \"be opened in design view. Edit component with component editor to \"\r\n                \"remove invalid references.\").arg(referencingVlnv.toString(\":\")).arg(ref.toString(\":\")));\r\n            invalidReferences = true;\r\n        }\r\n\r\n        // if the reference is to a wrong object type\r\n        else if (libraryHandler_->getDocumentType(ref) != VLNV::DESIGN &&\r\n            libraryHandler_->getDocumentType(ref) != VLNV::DESIGNCONFIGURATION)\r\n        {\r\n            emit errorMessage(tr(\"Component %1 has hierarchical reference to object %2,\"\r\n                \" which is not design or design configuration. Component is not valid and\"\r\n                \" can not be opened in design view. Edit component with component editor to\"\r\n                \" remove invalid references.\").arg(referencingVlnv.toString(\":\")).arg(ref.toString(\":\")));\r\n            invalidReferences = true;\r\n        }\r\n\r\n        // if the reference is for a design configuration then check that also\r\n        // the design is found\r\n        else if (libraryHandler_->getDocumentType(ref) == VLNV::DESIGNCONFIGURATION)\r\n        {\r\n            VLNV designVLNV = libraryHandler_->getDesignVLNV(ref);\r\n\r\n            QSharedPointer<Document> libComp2 = libraryHandler_->getModel(ref);\r\n            QSharedPointer<DesignConfiguration> desConf = libComp2.staticCast<DesignConfiguration>();\r\n            VLNV refToDesign = desConf->getDesignRef();\r\n\r\n            // if the referenced design was not found in the library\r\n            if (!designVLNV.isValid())\r\n            {\r\n                emit errorMessage(tr(\"Component %1 has hierarchical reference to object %2, \"\r\n                    \"which is design configuration and references to design %3. This \"\r\n                    \"design is not found in library so component can not be opened in \"\r\n                    \"design view. Edit component with component editor to remove invalid references\").arg(\r\n                    referencingVlnv.toString(\":\"), ref.toString(\":\"), refToDesign.toString(\":\")));\r\n                invalidReferences = true;\r\n            }\r\n        }\r\n    }\r\n\r\n    return invalidReferences;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MainWindow::setLibraryLocations()\r\n//-----------------------------------------------------------------------------\r\nvoid MainWindow::setLibraryLocations()\r\n{\r\n    QSettings settings;\r\n    LibrarySettingsDialog dialog(settings, this);\r\n    connect(&dialog, SIGNAL(scanLibrary()), this, SLOT(onLibrarySearch()), Qt::UniqueConnection);\r\n\r\n    dialog.exec();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MainWindow::onGenerate()\r\n//-----------------------------------------------------------------------------\r\nvoid MainWindow::onGenerate()\r\n{\r\n    generationMenu_->exec(QCursor::pos());\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MainWindow::onRunImportWizard()\r\n//-----------------------------------------------------------------------------\r\nvoid MainWindow::onRunImportWizard()\r\n{\r\n    TabDocument* doc = static_cast<TabDocument*>(designTabs_->currentWidget());\r\n\r\n    if (!doc || doc->isProtected())\r\n    {\r\n        return;\r\n    }\r\n\r\n    if (doc->isModified())\r\n    {\r\n        QMessageBox msgBox(QMessageBox::Warning, QCoreApplication::applicationName(),\r\n            tr(\"The document has been modified. The changes need to be saved before the \"\r\n            \"import wizard can be run. Save changes and continue?\"),\r\n            QMessageBox::Yes | QMessageBox::No, this);\r\n\r\n        // if user does not want to save or save can't be done\r\n        if (msgBox.exec() == QMessageBox::No || !doc->save())\r\n        {\r\n            return;\r\n        }\r\n    }\r\n\r\n    VLNV vlnv = doc->getIdentifyingVLNV();\r\n    QSharedPointer<Component> component = libraryHandler_->getModel(vlnv).dynamicCast<Component>();\r\n\r\n    if (component)\r\n    {\r\n        ImportWizard wizard(component, libraryHandler_, this);\r\n\r\n        if (wizard.exec() == QDialog::Accepted)\r\n        {\r\n            if (libraryHandler_->writeModelToFile(wizard.getComponent()))\r\n            {\r\n                doc->refresh();\r\n            }\r\n            else\r\n            {\r\n                emit errorMessage(\"Error saving file to disk.\");\r\n            }\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MainWindow::createGeneratorPluginActions()\r\n//-----------------------------------------------------------------------------\r\nvoid MainWindow::createGeneratorPluginActions()\r\n{\r\n    generationMenu_->clear();\r\n    \r\n    generationMenu_->addAction(actGenDocumentation_);\r\n\r\n    for (IPlugin* plugin : PluginManager::getInstance().getActivePlugins())\r\n    {\r\n        IGeneratorPlugin* genPlugin = dynamic_cast<IGeneratorPlugin*>(plugin);\r\n\r\n        if (genPlugin != 0)\r\n        {\r\n            // Add a small overlay icon to the plugin icon to visualize that this is a plugin.\r\n            QIcon pluginBaseIcon = genPlugin->getIcon();\r\n\r\n            QPixmap icon(32, 32);\r\n            icon.fill(Qt::transparent);\r\n\r\n            QPainter painter(&icon);\r\n            painter.drawPixmap(0, 0, pluginBaseIcon.pixmap(32, 32));\r\n\r\n            QAction* action = new QAction(icon, genPlugin->getName(), this);\r\n            action->setData(QVariant::fromValue((void*)genPlugin));\r\n\r\n            generationMenu_->addAction(action);\r\n            pluginActionGroup_->addAction(action);\r\n        }\r\n    }\r\n\r\n    connect(pluginActionGroup_, SIGNAL(triggered(QAction*)),\r\n            this, SLOT(runGeneratorPlugin(QAction*)), Qt::UniqueConnection);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MainWindow::updateGeneratorPluginActions()\r\n//-----------------------------------------------------------------------------\r\nvoid MainWindow::updateGeneratorPluginActions()\r\n{\r\n    // Remove all plugin actions.\r\n    QList<QAction*> actions = generationGroup_->actions();\r\n\r\n    for (QAction* action : actions)\r\n    {\r\n        // Check if the action contains the plugin pointer.\r\n        if (action->data().value<void*>() != 0)\r\n        {\r\n            pluginActionGroup_->removeAction(action);\r\n            generationGroup_->removeAction(action);\r\n            delete action;\r\n        }\r\n    }\r\n\r\n    // Recreate the plugin actions.\r\n    createGeneratorPluginActions();\r\n\r\n    setPluginVisibilities();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MainWindow::runComponentWizard()\r\n//-----------------------------------------------------------------------------\r\nvoid MainWindow::runComponentWizard(QSharedPointer<Component> component, QString const& directory)\r\n{\r\n    // Open the component wizard.\r\n    ComponentWizard wizard(component, directory, libraryHandler_, this);\r\n\r\n    QString styleSheet(\"*[mandatoryField=\\\"true\\\"] { background-color: LemonChiffon; }\");\r\n    wizard.setStyleSheet(styleSheet);\r\n\r\n    if (wizard.exec() == QDialog::Accepted)\r\n    {\r\n        // Save wizard changes.\r\n        if (!libraryHandler_->writeModelToFile(wizard.getComponent()))\r\n        {\r\n            emit errorMessage(\"Error saving file to disk.\");\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: mainwindow::setPluginVisibilities()\r\n//-----------------------------------------------------------------------------\r\nvoid MainWindow::setPluginVisibilities()\r\n{\r\n    TabDocument* doc = static_cast<TabDocument*>(designTabs_->currentWidget());\r\n\r\n    // Enable/disable the plugin generator actions based on the component being edited in the document.\r\n    VLNV compVLNV;\r\n    VLNV desVLNV;\r\n    QSharedPointer<Component const> component;\r\n    QSharedPointer<Design const> design;\r\n    QSharedPointer<DesignConfiguration const> designConfiguration;\r\n\r\n    if (doc)\r\n    {\r\n        compVLNV = doc->getDocumentVLNV();\r\n        desVLNV = doc->getIdentifyingVLNV();\r\n        QSharedPointer<Document const> libComp = libraryHandler_->getModelReadOnly(compVLNV);\r\n        component = libComp.dynamicCast<Component const>();\r\n\r\n        if (component)\r\n        {\r\n            // if the design is supported by the document type\r\n            DesignWidget* desWidget = qobject_cast<DesignWidget*>(doc);\r\n            if (desWidget)\r\n            {\r\n                // design is the object that identifies the editor\r\n                QSharedPointer<Document const> libDes = libraryHandler_->getModelReadOnly(desVLNV);\r\n                design = libDes.dynamicCast<Design const>();\r\n\r\n                // find the design config is one exists\r\n                QString viewName = desWidget->getOpenViewName();\r\n\r\n                // The name must exist!\r\n                Q_ASSERT(!viewName.isEmpty());\r\n\r\n                VLNV desConfVLNV;\r\n\r\n                // the implementation defines where to search for the hierarchy ref\r\n                switch (desWidget->getImplementation())\r\n                {\r\n                case KactusAttribute::HW:\r\n                case KactusAttribute::SW:\r\n                    {\r\n                        desConfVLNV = component->getHierRef(viewName);\r\n                        break;\r\n                    }\r\n                case KactusAttribute::SYSTEM:\r\n                    {\r\n                        desConfVLNV = component->getHierSystemRef(viewName);\r\n                        break;\r\n                    }\r\n                default:\r\n                    {\r\n                        Q_ASSERT(false);\r\n                        return;\r\n                    }\r\n                }\r\n\r\n                // if the hierarchy ref is not directly to the design but design config is in between\r\n                if (desConfVLNV.isValid() && desConfVLNV != desVLNV)\r\n                {\r\n                     QSharedPointer<Document const> libDesConf = libraryHandler_->getModelReadOnly(desConfVLNV);\r\n                     designConfiguration = libDesConf.dynamicCast<DesignConfiguration const>();\r\n                }\r\n            }\r\n        }\r\n    }\r\n\r\n    for (QAction* action : pluginActionGroup_->actions())\r\n    {\r\n        IGeneratorPlugin* plugin = reinterpret_cast<IGeneratorPlugin*>(action->data().value<void*>());\r\n        Q_ASSERT(plugin != 0);\r\n\r\n        action->setVisible(component != 0 && plugin->checkGeneratorSupport(component, design, designConfiguration));\r\n    }\r\n\r\n\r\n    bool isGenerationGroupVisible = false;\r\n    for (QAction* action : generationGroup_->actions())\r\n    {\r\n        if (action->isVisible())\r\n        {\r\n            isGenerationGroupVisible = true;\r\n            break;\r\n        }\r\n    }\r\n\r\n    generationAction_->setVisible(isGenerationGroupVisible && doc);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: mainwindow::onDesignDocumentRefreshed()\r\n//-----------------------------------------------------------------------------\r\nvoid MainWindow::onDesignDocumentRefreshed()\r\n{\r\n    dockHandler_->refreshDesignDocument(designTabs_->currentWidget());\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: mainwindow::onConfigureViews()\r\n//-----------------------------------------------------------------------------\r\nvoid MainWindow::onConfigureViews()\r\n{\r\n    TabDocument* doc = static_cast<TabDocument*>(designTabs_->currentWidget());\r\n\r\n    if (!doc || doc->isProtected())\r\n    {\r\n        return;\r\n    }\r\n\r\n    if (doc->isModified())\r\n    {\r\n        QMessageBox msgBox(QMessageBox::Warning, QCoreApplication::applicationName(), tr(\"The document has been \"\r\n            \"modified. The changes need to be saved before the import wizard can be run. Save changes and \"\r\n            \"continue?\"), QMessageBox::Yes | QMessageBox::No, this);\r\n\r\n        if (msgBox.exec() == QMessageBox::No || !doc->save())\r\n        {\r\n            return;\r\n        }\r\n    }\r\n\r\n    VLNV componentVLNV = doc->getDocumentVLNV();\r\n    VLNV designVLNV = doc->getIdentifyingVLNV();\r\n\r\n    QSharedPointer<Component> currentComponent = libraryHandler_->getModel(componentVLNV).dynamicCast<Component>();\r\n    QSharedPointer<Design> libraryDesign;\r\n    QSharedPointer<DesignConfiguration> libraryDesignConfiguration;\r\n\r\n    DesignWidget* desWidget = qobject_cast<DesignWidget*>(doc);\r\n    QString viewName (\"\");\r\n\r\n    if (desWidget && componentVLNV != designVLNV)\r\n    {\r\n        libraryDesign = libraryHandler_->getModel(designVLNV).dynamicCast<Design>();\r\n\r\n        viewName = desWidget->getOpenViewName();\r\n\r\n        VLNV designConfigurationVLNV;\r\n\r\n        if (desWidget->getImplementation() == KactusAttribute::HW)\r\n        {\r\n            designConfigurationVLNV = currentComponent->getHierRef(viewName);\r\n        }\r\n        else\r\n        {\r\n            return;\r\n        }\r\n\r\n        if (designConfigurationVLNV.isValid() && designConfigurationVLNV != designVLNV)\r\n        {\r\n            libraryDesignConfiguration = libraryHandler_->getModel(designConfigurationVLNV).\r\n                dynamicCast<DesignConfiguration>();\r\n        }\r\n    }\r\n\r\n    if (currentComponent)\r\n    {\r\n        ViewConfigurer configurer(currentComponent, libraryDesign, libraryDesignConfiguration, libraryHandler_,\r\n            viewName);\r\n\r\n        if (configurer.exec() == QDialog::Accepted)\r\n        {\r\n            doc->refresh();\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: mainwindow::onCondenseMemoryItems()\r\n//-----------------------------------------------------------------------------\r\nvoid MainWindow::onCondenseMemoryItems(bool condenseMemoryItems)\r\n{\r\n    MemoryDesignDocument* memoryDocument = dynamic_cast<MemoryDesignDocument*>(designTabs_->currentWidget());\r\n    if (memoryDocument && !memoryDocument->isProtected())\r\n    {\r\n        memoryDocument->setCondenseMemoryItems(condenseMemoryItems);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: mainwindow::onFilterAddressSpaceChains()\r\n//-----------------------------------------------------------------------------\r\nvoid MainWindow::onFilterAddressSpaceChains(bool filterChains)\r\n{\r\n    MemoryDesignDocument* memoryDocument = dynamic_cast<MemoryDesignDocument*>(designTabs_->currentWidget());\r\n    if (memoryDocument && !memoryDocument->isProtected())\r\n    {\r\n        memoryDocument->filterAddressSpaceChains(filterChains);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: mainwindow::onCondenseFieldItems()\r\n//-----------------------------------------------------------------------------\r\nvoid MainWindow::onCondenseFieldItems()\r\n{\r\n    MemoryDesignDocument* memoryDocument = dynamic_cast<MemoryDesignDocument*>(designTabs_->currentWidget());\r\n    if (memoryDocument && !memoryDocument->isProtected())\r\n    {\r\n        memoryDocument->condenseFieldItems();\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: mainwindow::onExtendFieldItems()\r\n//-----------------------------------------------------------------------------\r\nvoid MainWindow::onExtendFieldItems()\r\n{\r\n    MemoryDesignDocument* memoryDocument = dynamic_cast<MemoryDesignDocument*>(designTabs_->currentWidget());\r\n    if (memoryDocument && !memoryDocument->isProtected())\r\n    {\r\n        memoryDocument->extendFieldItems();\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: mainwindow::onFilterSegments()\r\n//-----------------------------------------------------------------------------\r\nvoid MainWindow::onFilterSegments(bool filterSegments)\r\n{\r\n    MemoryDesignDocument* memoryDocument = dynamic_cast<MemoryDesignDocument*>(designTabs_->currentWidget());\r\n    if (memoryDocument && !memoryDocument->isProtected())\r\n    {\r\n        memoryDocument->filterAddressSpaceSegments(filterSegments);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: mainwindow::onFilterAddressBlocks()\r\n//-----------------------------------------------------------------------------\r\nvoid MainWindow::onFilterAddressBlocks(bool filterBlocks)\r\n{\r\n    MemoryDesignDocument* memoryDocument = dynamic_cast<MemoryDesignDocument*>(designTabs_->currentWidget());\r\n    if (memoryDocument && !memoryDocument->isProtected())\r\n    {\r\n        memoryDocument->filterAddressBlocks(filterBlocks);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: mainwindow::onFilterRegisters()\r\n//-----------------------------------------------------------------------------\r\nvoid MainWindow::onFilterRegisters(bool filterRegisters)\r\n{\r\n    MemoryDesignDocument* memoryDocument = dynamic_cast<MemoryDesignDocument*>(designTabs_->currentWidget());\r\n    if (memoryDocument && !memoryDocument->isProtected())\r\n    {\r\n        memoryDocument->filterAddressBlockRegisters(filterRegisters);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: mainwindow::onFilterFields()\r\n//-----------------------------------------------------------------------------\r\nvoid MainWindow::onFilterFields(bool filterFields)\r\n{\r\n    MemoryDesignDocument* memoryDocument = dynamic_cast<MemoryDesignDocument*>(designTabs_->currentWidget());\r\n    if (memoryDocument && !memoryDocument->isProtected())\r\n    {\r\n        memoryDocument->filterFields(filterFields);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: mainwindow::onFilterUnconnectedMemoryItems()\r\n//-----------------------------------------------------------------------------\r\nvoid MainWindow::onFilterUnconnectedMemoryItems(bool filterUnconnected)\r\n{\r\n    MemoryDesignDocument* memoryDocument = dynamic_cast<MemoryDesignDocument*>(designTabs_->currentWidget());\r\n    if (memoryDocument && !memoryDocument->isProtected())\r\n    {\r\n        memoryDocument->filterUnconnectedMemoryItems(filterUnconnected);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: MainWindow::onFilterMemoryOverlapItems()\r\n//-----------------------------------------------------------------------------\r\nvoid MainWindow::onFilterMemoryOverlapItems(bool filterOverlap)\r\n{\r\n    MemoryDesignDocument* memoryDocument = dynamic_cast<MemoryDesignDocument*>(designTabs_->currentWidget());\r\n    if (memoryDocument && !memoryDocument->isProtected())\r\n    {\r\n        memoryDocument->filterMemoryOverlapItems(filterOverlap);\r\n    }\r\n}\r\n"
  },
  {
    "path": "mainwindow/mainwindow.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: mainwindow.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Joni-Matti Maatta\r\n// Date: 24.2.2011\r\n//\r\n// Description:\r\n// The main window of Kactus2.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef MAINWINDOW_H\r\n#define MAINWINDOW_H\r\n\r\n#include <KactusAPI/include/PluginManager.h>\r\n\r\n#include <common/widgets/tabDocument/TabDocument.h>\r\n\r\n#include <editors/common/DrawMode.h>\r\n\r\n#include <IPXACTmodels/common/Document.h>\r\n#include <IPXACTmodels/common/TagData.h>\r\n\r\n#include <IPXACTmodels/kactusExtensions/KactusAttribute.h>\r\n\r\n#include \"WorkspaceSettings.h\"\r\n\r\n#include <QMainWindow>\r\n#include <QActionGroup>\r\n#include <QMenu>\r\n#include <QShowEvent>\r\n#include <QHideEvent>\r\n\r\nclass Component;\r\nclass VLNV;\r\n\r\nclass LibraryHandler;\r\nclass ComponentItem;\r\nclass DrawingBoard;\r\nclass ConnectionEndpoint;\r\nclass GraphicsConnection;\r\nclass Ribbon;\r\nclass RibbonGroup;\r\nclass DockWidgetHandler;\r\nclass MessageMediator;\r\nclass PythonSourceEditor;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! The main window of Kactus2.\r\n//-----------------------------------------------------------------------------\r\nclass MainWindow : public QMainWindow\r\n{\r\n    Q_OBJECT\r\n\r\npublic:\r\n\r\n    /*!\r\n     *  The constructor.\r\n     *\r\n     *    @param [in] library   The used IP-XACT library instance.\r\n     *    @param [in] parent    The parent widget.\r\n     */\r\n    MainWindow(LibraryHandler* library, MessageMediator* messageChannel, QWidget *parent = 0);\r\n    \r\n\t/*!\r\n     *  The destructor.\r\n     */\r\n\tvirtual ~MainWindow();\r\n\r\npublic slots:\r\n    /*!\r\n     *  Opens the \"New\" dialog.\r\n     */\r\n    void createNew();\r\n\r\n    /*!\r\n     *  Opens the source file of the given component.\r\n     *\r\n     *    @param [in] compItem The component item.\r\n     */\r\n    void openCSource(ComponentItem* compItem);\r\n\r\n    /*!\r\n     *  Opens the specific C source file of the given component.\r\n     *\r\n     *    @param [in] filename   The name of the file to open.\r\n     *    @param [in] component  The component containing the file.\r\n     */\r\n    void openCSource(QString const& filename, QSharedPointer<Component> component);\r\n\r\n    /*!\r\n     *  Opens a HW design.\r\n     *\r\n     *    @param [in] vlnv           The VLNV of the top-level component.\r\n     *    @param [in] viewName       The name of the view to open.\r\n     */\r\n    void openHWDesign(VLNV const& vlnv = VLNV(), QString const& viewName = QString());\r\n\r\n    /*!\r\n     *  Opens the memory design of the current HW design.\r\n     *  \r\n     */\r\n    void openMemoryDesign(); \r\n\r\n    /*!\r\n     *  Opens the memory design of the HW design specified by the component VLNV and view name.\r\n     *  \r\n     *    @param [in] vlnv            The VLNV of the top-level component.\r\n     *    @param [in] viewName        Name of the view to open.\r\n     */\r\n    void openMemoryDesign(const VLNV& vlnv, const QString& viewName = QString());    \r\n\r\n    /*!\r\n     *  Opens a SW design.\r\n     *\r\n     *    @param [in] vlnv           The VLNV of the top-level component.\r\n     *    @param [in] viewName       The name of the view to open.\r\n     */\r\n\tvoid openSWDesign(const VLNV& vlnv = VLNV(), QString const& viewName = QString());\r\n\r\n    /*!\r\n     *  Opens a system design.\r\n     *\r\n     *    @param [in] vlnv           The VLNV of the system component whose system design to open.\r\n     *    @param [in] viewName       The name of the view to open.\r\n     */\r\n    void openSystemDesign(VLNV const &vlnv, QString const& viewName = QString());\r\n\r\n    /*!\r\n     *  Open bus to be edited.\r\n\t *\r\n\t *    @param [in] busDefVLNV      Identifies the bus definition.\r\n\t */\r\n\tvoid openBus(const VLNV& busDefVLNV);\r\n\r\n    void openAbsDef(const VLNV& absDefVLNV);\r\n    /*!\r\n     *  Open catalog editor to edit catalog details.\r\n\t *\r\n\t *    @param [in] vlnv           Identifies the catalog to edit.\r\n\t */\r\n\tvoid openCatalog(const VLNV& vlnv);\r\n\r\n\t/*!\r\n     *  Open component editor to edit a component details.\r\n\t *\r\n\t *    @param [in] vlnv           Identifies the component to edit.\r\n\t */\r\n\tvoid openComponent(const VLNV& vlnv);\r\n\r\n    /*!\r\n     *  Opens a COM definition for editing.\r\n     *\r\n     *    @param [in] vlnv           The VLNV of the COM definition to open.\r\n     */\r\n    void openComDefinition(VLNV const& vlnv);\r\n\r\n    /*!\r\n     *  Opens an API definition for editing.\r\n     *\r\n     *    @param [in] vlnv           The VLNV of the API definition to open.\r\n     */\r\n    void openApiDefinition(VLNV const& vlnv);\r\n\r\n    //! Called when user closes the last design tab.\r\n    void onLastDocumentClosed();\r\n\r\n    //! Called when the user has selected another tab.\r\n    void onDocumentChanged(int index);\r\n\r\n\t/*!\r\n     *  Search the file system for new IP-Xact libraries.\r\n\t *\r\n\t *  This slot is called when user clicks to search for IP-Xact files.\r\n\t */\r\n\tvoid onLibrarySearch();\r\n\r\n\t/*!\r\n     *  Called when user selects a component on the draw board.\r\n\t *\r\n\t *    @param [in] component   Pointer to the DiagramComponent instance that is selected.\r\n\t */\r\n\tvoid onComponentSelected(ComponentItem* component);\r\n\r\n\t/*!\r\n     *  Called when user selects an interface on the draw board.\r\n\t *\r\n\t *    @param [in] interface   Pointer to the interface instance that is selected.\r\n\t */\r\n\tvoid onInterfaceSelected(ConnectionEndpoint* interface);\r\n\r\n\t/*!\r\n     *  Called when user selects a connection on the draw board.\r\n\t *\r\n\t *    @param [in] connection  Pointer to the connection that was selected.\r\n\t */\r\n\tvoid onConnectionSelected(GraphicsConnection* connection);\r\n\r\n    //! Called when the menu strip needs to be updated.\r\n    void updateMenuStrip();\r\n\r\n    //! Called when the zoom has changed.\r\n    void updateZoomTools();\r\n\r\n    //! Saves all modified documents.\r\n    void saveAll();\r\n\r\n    //! Adds a new column to the current HW/System design.\r\n    void addColumn();\r\n\r\n\t//! Generates the documentation for the current component/design.\r\n\tvoid generateDoc();\r\n\r\n    /*!\r\n     *  Runs the plugin generator specified by the given action.\r\n     *\r\n     *    @param [in] action The action corresponding to the plugin.\r\n     */\r\n    void runGeneratorPlugin(QAction* action);\r\n\r\n    //! Zooms in the current document.\r\n    void zoomIn();\r\n\r\n    //! Zooms out the current document.\r\n    void zoomOut();\r\n\r\n    //! Resets the zoom of the current document to the original 1:1 ratio.\r\n    void zoomOriginal();\r\n\r\n    //! Fits the current document fully in view.\r\n    void fitInView();\r\n\r\n    //! Undoes one operation in the current document.\r\n    void undo();\r\n\r\n    //! Redoes one operation in the current document.\r\n    void redo();\r\n\r\n    //! Called when the draw mode has changed.\r\n    void onDrawModeChanged(DrawMode mode);\r\n    void drawModeChange(QAction *action);\r\n\r\n    //! Called when the state of the protection button changes.\r\n    void onProtectionChanged(bool locked);\r\n\r\n    //! Changes the protection of the current document.\r\n    void changeProtection(bool locked);\r\n\r\n    /*!\r\n     *  Creates a new component to the library.\r\n     *\r\n     *    @param [in] prodHier    The product hierarchy attribute.\r\n     *    @param [in] firmness\tThe firmness attribute.\r\n     *    @param [in] tags        Document tags.\r\n     *    @param [in] vlnv        The component's VLNV.\r\n     *    @param [in] revision    The IP-XACT standard revision to comply to.\r\n     *    @param [in] directory   The directory where to save the component.\r\n     *\r\n     *      @remarks The component editor is opened automatically after successful creation.\r\n     */\r\n    void createComponent(KactusAttribute::ProductHierarchy prodHier, KactusAttribute::Firmness firmness,\r\n        QVector<TagData> tags, VLNV const& vlnv, Document::Revision revision, QString const& directory);\r\n\r\n    /*!\r\n     *  Creates a SW component to the library.\r\n     *\r\n     *    @param [in] vlnv        The component's VLNV.\r\n     *    @param [in] revision    The IP-XACT standard revision to comply to.\r\n     *    @param [in] directory   The directory where to save the component.\r\n     *\r\n     *      @remarks The component editor is opened automatically after successful creation.\r\n     */\r\n    void createSWComponent(VLNV const& vlnv, Document::Revision revision, QString const& directory);\r\n\r\n    /*!\r\n     *  Creates a new design.\r\n     *\r\n     *    @param [in] prodHier    The product hierarchy attribute.\r\n     *    @param [in] firmness\tThe firmness attribute.\r\n     *    @param [in] tags        Document tags.\r\n     *    @param [in] vlnv        The component's VLNV.\r\n     *    @param [in] revision    The IP-XACT standard revision to comply to.\r\n     *    @param [in] directory   The directory where to save the component.\r\n     *\r\n     *      @remarks The HW design editor is opened automatically after successful creation.\r\n     */\r\n    void createDesign(KactusAttribute::ProductHierarchy prodHier, KactusAttribute::Firmness firmness,\r\n        QVector<TagData> tags, VLNV const& vlnv, Document::Revision revision, QString const& directory);\r\n\r\n    /*!\r\n     *  Creates a new design for an existing component.\r\n     *\r\n     *    @param [in] vlnv        The component's VLNV.\r\n     *\r\n     *      @remarks The HW design editor is opened automatically after successful creation.\r\n     */\r\n    void createDesignForExistingComponent(VLNV const& vlnv);\r\n\r\n    void unlockNewlyCreatedDocument(VLNV const& vlnv);\r\n\r\n    /*!\r\n     *  Creates a new Catalog\r\n     *\r\n     *    @param [in] catalogVLNV The VLNV for the catalog.\r\n     *    @param [in] revision    The IP-XACT standard revision to comply to.\r\n     *    @param [in] directory   The directory where to save the catalog.\r\n     */\r\n    void createCatalog(VLNV const& catalogVLNV, Document::Revision revision, QString const& directory);\r\n\r\n    /*!\r\n     *  Creates a new hierarchical SW component with an SW design.\r\n     *\r\n     *    @param [in] vlnv        The component's VLNV.\r\n     *    @param [in] revision    The IP-XACT standard revision to comply to.\r\n     *    @param [in] directory   The directory where to save the component.\r\n     *\r\n     *      @remarks The SW design editor is opened automatically after successful creation.\r\n     */\r\n    void createSWDesign(VLNV const& vlnv, Document::Revision revision, QString const& directory);\r\n\r\n    /*!\r\n     *  Creates a SW design for an existing component.\r\n     *\r\n     *    @param [in] vlnv        The component's VLNV.\r\n     *\r\n     *      @remarks The SW design editor is opened automatically after successful creation.\r\n     */\r\n    void createSWDesign(VLNV const& vlnv);\r\n\r\n    /*!\r\n     *  Creates a new system design.\r\n     *\r\n     *    @param [in] compVLNV   The VLNV of an existing component.\r\n     *    @param [in] viewName   The name of the view to which the system design will be based on.\r\n     *    @param [in] sysVLNV    The VLNV of the system to be created.\r\n     *    @param [in] revision   The IP-XACT standard revision to comply to.\r\n     *    @param [in] directory  The directory where to save the system.\r\n     */\r\n    void createSystem(VLNV const& compVLNV, QString const& viewName, VLNV const& sysVLNV,\r\n        Document::Revision , QString const& directory);\r\n\r\n    void createSystemDesign(VLNV const& vlnv);\r\n\r\n    /*!\r\n     *  Creates a new bus definition and abstraction definition\r\n\t *\r\n     *    @param [in] vlnv        The vlnv for the bus definition\r\n     *    @param [in] revision    The IP-XACT standard revision to comply to.\r\n\t *    @param [in] directory   The directory where to save the bus definition and abstraction definition.\r\n\t */\r\n\tvoid createBus(VLNV const& vlnv, Document::Revision revision, QString const& directory);\r\n\r\n\t/*!\r\n     *  Creates a new abstraction definition for given bus definition.\r\n\t *\r\n\t *    @param [in] busDefVLNV      Identifies the bus definition.\r\n\t *    @param [in] directory       The directory where to save the abstraction definition.\r\n\t */\r\n\tvoid createAbsDef(const VLNV& busDefVLNV, const QString& directory);\r\n\r\n    /*!\r\n     *  Creates a new COM definition.\r\n     *\r\n     *    @param [in] vlnv        VLNV for the COM definition.\r\n     *    @param [in] revision    The IP-XACT standard revision to comply to.\r\n     *    @param [in] directory   The directory where to save the design.\r\n     *\r\n     *      @remarks The COM definition editor is opened automatically after successful creation.\r\n     */\r\n    void createComDefinition(VLNV const& vlnv, Document::Revision revision, QString const& directory);\r\n\r\n    /*!\r\n     *  Creates a new API definition.\r\n     *\r\n     *    @param [in] vlnv        VLNV for the API definition.\r\n     *    @param [in] revision    The IP-XACT standard revision to comply to.\r\n     *    @param [in] directory   The directory where to save the design.\r\n     *\r\n     *      @remarks The API definition editor is opened automatically after successful creation.\r\n     */\r\n    void createApiDefinition(VLNV const& vlnv, Document::Revision revision, QString const& directory);\r\n\r\n    /*!\r\n     *  Opens the settings dialog.\r\n     */\r\n    void openSettings();\r\n\r\n    /*!\r\n     *  Shows the about box.\r\n     */\r\n    void showAbout();\r\n\r\nsignals:\r\n\r\n\t//! Print a notice message to the user.\r\n\tvoid noticeMessage(const QString& msg);\r\n\r\n\t//! Print an error message to the user.\r\n\tvoid errorMessage(const QString& msg);\r\n\r\n    //! Emitted when a help page should be changed in the context help window.\r\n    void helpUrlRequested(QString const& url);\r\n\r\nprotected:\r\n\r\n\t//! Called when the user requests to close the program.\r\n    virtual void closeEvent(QCloseEvent* event);\r\n\r\n\t//! Called when user i.e minimizes the main window.\r\n\tvirtual void hideEvent(QHideEvent* event);\r\n\r\n\t//! Called when user i.e maximizes the main window after it has been minimized.\r\n\tvirtual void showEvent(QShowEvent* event);\r\n\r\n\r\nprivate slots:\r\n\r\n    /*!\r\n     *  Save button checks from the save if a document can be saved.\r\n     */\r\n    void passSaveToActSave();\r\n\r\n\t//! Handler for design widget's clearItemSelection signal.\r\n\tvoid onClearItemSelection();\r\n\r\n\t//! Handler for signals that inform that design has changed.\r\n\tvoid onDesignChanged();\r\n\r\n    //! Saves the document hierarchy under current document.\r\n    void saveCurrentDocumentHierarchy();\r\n\r\n\t//! Create a pop up menu to select which dock widgets to display.\r\n\tvoid selectVisibleDocks();\r\n\r\n    //! Opens the visibility control menu.\r\n    void openVisibilityControlMenu();\r\n\r\n    //! Opens the workspace management menu.\r\n    void openWorkspaceMenu();\r\n\r\n    /*!\r\n     *  Handles the situation when a workspace has been changed.\r\n     */\r\n    void onWorkspaceChanged(QString const& workspace);\r\n\r\n    /*!\r\n     *  Handles the toggling of visibility controls.\r\n     */\r\n    void onVisibilityControlToggled(QAction*);\r\n\r\n    //! Opens a dialog for setting library locations.\r\n    void setLibraryLocations();\r\n\r\n    void onGenerate();\r\n\r\n    //! Runs an import wizard for the currently open component.\r\n    void onRunImportWizard();\r\n\r\n    /*!\r\n     *  Update the instance editor, when the design document is refreshed.\r\n     */\r\n    void onDesignDocumentRefreshed();\r\n\r\n    /*!\r\n     *  Configure the used views.\r\n     */\r\n    void onConfigureViews();\r\n\r\n    /*!\r\n     *  Set the filtering of chained address space memory connections within a memory design.\r\n     *\r\n     *    @param [in] filterChains    Value for the filter.\r\n     */\r\n    void onFilterAddressSpaceChains(bool filterChains);\r\n\r\n    /*!\r\n     *  Set the condensing of memory graphics items within a memory design.\r\n     *\r\n     *    @param [in] condenseMemoryItems     Value for condensing the memory graphics items.\r\n     */\r\n    void onCondenseMemoryItems(bool condenseMemoryItems);\r\n\r\n    /*!\r\n     *  Condense all the field graphics items to their original width.\r\n     */\r\n    void onCondenseFieldItems();\r\n\r\n    /*!\r\n     *  Extend all the field graphics items to fully display their name label.\r\n     */\r\n    void onExtendFieldItems();\r\n\r\n    /*!\r\n     *  Set the filtering of address space segments within a memory design.\r\n     *\r\n     *    @param [in] filterSegments  Value for the filter.\r\n     */\r\n    void onFilterSegments(bool filterSegments);\r\n\r\n    /*!\r\n     *  Set the filtering of address blocks within a memory design.\r\n     *\r\n     *    @param [in] filterBlocks    Value for the filter.\r\n     */\r\n    void onFilterAddressBlocks(bool filterBlocks);\r\n\r\n    /*!\r\n     *  Set the filtering of registers within a memory design.\r\n     *\r\n     *    @param [in] filterRegisters     Value for the filter.\r\n     */\r\n    void onFilterRegisters(bool filterRegisters);\r\n\r\n    /*!\r\n     *  Set the filtering of fields within a memory design.\r\n     *\r\n     *    @param [in] filterFields    Value for the filter.\r\n     */\r\n    void onFilterFields(bool filterFields);\r\n\r\n    /*!\r\n     *  Set the filtering of the unconnected memory items within a memory design.\r\n     *\r\n     *    @param [in] filterUnconnected   Value for the filter.\r\n     */\r\n    void onFilterUnconnectedMemoryItems(bool filterUnconnected);\r\n\r\n    /*!\r\n     *  Set the filtering of the memory overlap items within a memory design.\r\n     *\r\n     *    @param [in] filterOverlap   Value for the filter.\r\n     */\r\n    void onFilterMemoryOverlapItems(bool filterOverlap);\r\n\r\n    /*!\r\n     *  Open the document containing the selected component and select the identified component item editor.\r\n     *\r\n     *    @param [in] componentVLNV       VLNV of the selected component.\r\n     *    @param [in] identifierChain     List of string identifying the selected component item.\r\n     */\r\n    void onOpenComponentItem(const VLNV& componentVLNV, QVector<QString> identifierChain);\r\n\r\n    /*!\r\n     *  Adjust the visibility of the selected dock widget.\r\n     *\r\n     *    @param [in] type    Type of the selected dock widget.\r\n     *    @param [in] show    New value for the visibility of the dock widget.\r\n     */\r\n    void onAdjustVisibilityInWindow(TabDocument::SupportedWindows type, bool show);\r\n\r\n    /*!\r\n     *  Updates the workspace menu.\r\n     */\r\n    void updateWorkspaceMenu();\r\n\r\n    /*!\r\n     *  Opens interconnect generator dialog.\r\n     */\r\n    void onInterconnectGenerate();\r\n\r\nprivate:\r\n\t// Disable copying.\r\n\tMainWindow(MainWindow const& rhs);\r\n    MainWindow& operator=(MainWindow const& rhs);\r\n\r\n    /*!\r\n     *  Returns true if a design with the given vlnv is already open.\r\n     *\r\n     *      @remarks If the design is already open, it is displayed.\r\n     */\r\n    bool isDesignOpen(VLNV const& vlnv, KactusAttribute::Implementation implementation) const;\r\n\r\n    /*!\r\n     *  Checks if the given list of VLVNs contain invalid references.\r\n     *\r\n     *    @param [in] hierRefs            The list of VLNVs to check\r\n     *    @param [in] referencingVlnv     The referencing VLNV.\r\n     *\r\n     *    @return True, if at least one invalid reference is found, otherwise false.\r\n     */\r\n    bool hasInvalidReferences(QList<VLNV> hierRefs, VLNV const& referencingVlnv);\r\n\r\n    /*!\r\n     *  Restores the program's settings.\r\n\t */\r\n\tvoid restoreSettings();\r\n\r\n\t/*! \r\n     *  Save the program's settings.\r\n\t */\r\n\tvoid saveSettings();\r\n\r\n    /*!\r\n     *  Restores the settings for the given workspace.\r\n     *\r\n     *    @param [in] workspaceName The name of the workspace.\r\n     */\r\n    void loadWorkspace(QString const& workspaceName);\r\n\r\n\t/*!\r\n     *  Set up the actions in the tool bars\r\n\t */\r\n\tvoid setupActions();\r\n\r\n\t/*!\r\n     *  Set up the menus for the main window.\r\n\t *\r\n\t *  This function is used by the setupActions() after it has created the actions for the menus and should not\r\n     *  be called directly.\r\n\t */\r\n\tvoid setupMenus();\r\n\r\n    void setupToolbars();\r\n\r\n    /*!\r\n     *  Adds generator plugin actions to the generation group.\r\n     */\r\n    void createGeneratorPluginActions();\r\n\r\n    /*!\r\n     *  Updates the generation group.\r\n     */\r\n    void updateGeneratorPluginActions();\r\n\r\n\t/*!\r\n     *  Set up the drawing view where hierarchical components are edited.\r\n\t */\r\n\tvoid setupDrawBoard();\r\n\r\n    /*!\r\n     *  Connect the necessary signals of the dock widget handler.\r\n     */\r\n    void connectDockHandler();\r\n\r\n    /*!\r\n     *  Get the library handler from the dock widget handler and connected the necessary signals.\r\n     */\r\n    void setupAndConnectLibraryHandler();\r\n\r\n\t/*!\r\n     *  Check if a document with the given vlnv is already open.\r\n\t *\r\n\t *    @param [in] vlnv    The vlnv that identifies the document.\r\n\t * \r\n\t *      @remark If a document with given vlnv is open then the document is shown.\r\n\t * \r\n\t *    @return True if the document was already open.\r\n\t */\r\n\tbool isOpen(const VLNV& vlnv, TabDocument::DocumentType const& type) const;\r\n\r\n\t/*!\r\n\t *  Update the windows menu to contain the supported windows and visibility of the windows.\r\n\t */\r\n    void updateWindows();\r\n\r\n    /*!\r\n     *  Updates the visibility control menu according to the open document.\r\n     *\r\n     *    @param [in] document   The currently open document.\r\n     */\r\n    void updateVisibilityControlMenu(TabDocument* document);\r\n\r\n    /*!\r\n     *  Connects all the visibility controls for windows.     \r\n     */\r\n    void connectVisibilityControls();\r\n\r\n    /*!\r\n     *  Disconnects all the visibility controls for windows.     \r\n     */\r\n    void disconnectVisibilityControls();\r\n\r\n    /*!\r\n     *  Runs the component editor for the given component.\r\n     *\r\n     *    @param [in] component   The component to run the wizard for.\r\n     *    @param [in] directory   The directory containing the component xml file.\r\n     */\r\n    void runComponentWizard(QSharedPointer<Component> component, QString const& directory);\r\n    \r\n\r\n\t/*!\r\n\t *  Set the visibilities for the plug ins.\r\n\t */\r\n\tvoid setPluginVisibilities();\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n\t//! The instance that manages the IP-Xact library\r\n    LibraryHandler *libraryHandler_;\r\n    \r\n\t//! Contains the open documents as each in it's own tab.\r\n\tDrawingBoard* designTabs_;\r\n\r\n    QToolBar* leftToolbar_;\r\n\r\n    QToolBar* rightToolbar_;\r\n\r\n    //! The dock widget handler.\r\n    DockWidgetHandler* dockHandler_;\r\n\r\n\t/*******************************************************************/\r\n\t// the actions in the menus\r\n\r\n    Ribbon* ribbon_;\r\n\r\n\r\n    QStatusBar* statusBar_;\r\n\r\n\r\n    PythonSourceEditor* scriptEditor_;\r\n\r\n\t//! Create a new document in the IP-Xact library\r\n\tQAction* actNew_;\r\n\r\n    //! Action for containing all the save actions.\r\n    QAction* actMainSave_;\r\n\r\n    //! Action to save the current design.\r\n    QAction* actSave_;\r\n\r\n\t//! Action to save the current design as new object\r\n\tQAction* actSaveAs_;\r\n\r\n    QAction* actSaveHierarchy_;\r\n\r\n    //! Action to save all designs.\r\n    QAction* actSaveAll_;\r\n\r\n    //! Action to print the current document.\r\n    QAction* actPrint_;\r\n\r\n    //! Action to export an image of the current document.\r\n    QAction* actImageExport_;\r\n\r\n    //! The Edit group.\r\n    RibbonGroup* editGroup_;\r\n\r\n    //! Action for controlling edit group visibility.\r\n    QAction* editAction_ = nullptr;\r\n\r\n    //! Action to undo an operation.\r\n    QAction* actUndo_;\r\n\r\n    //! Action to redo an operation.\r\n    QAction* actRedo_;\r\n\r\n    //! Action to set library locations.\r\n    QAction* actLibraryLocations_;\r\n\r\n\t//! Search for IP-Xact files in the file system\r\n\tQAction* actLibrarySearch_;\r\n\r\n\t//! Check the library integrity\r\n\tQAction* actCheckIntegrity_;\r\n\r\n    //! The generation group.\r\n    RibbonGroup* generationGroup_;\r\n\r\n    //! Action for controlling generation group visibility.\r\n    QAction* generationAction_ = nullptr;\r\n\r\n    //! Action group for plugin generators.\r\n    QActionGroup* pluginActionGroup_;\r\n\r\n\t//! Action to generate the documentation for a component.\r\n\tQAction* actGenDocumentation_;\r\n\r\n    QAction* actGenerate_ = nullptr;\r\n\r\n\r\n    //! Action to run import wizard.\r\n    QAction* actRunImport_;\r\n\r\n    //! The Diagram Tools group.\r\n    RibbonGroup* diagramToolsGroup_;\r\n\r\n    //! Action for controlling diagram tools visibility.\r\n    QAction* diagramToolsAction_ = nullptr;\r\n\r\n    //! Action to add a new column to the current diagram.\r\n    QAction* actAddColumn_;\r\n\r\n    //! Action to select objects in a diagram.\r\n    QAction* actToolSelect_;\r\n\r\n    //! Action to draw connections in a diagram.\r\n    QAction* actToolConnect_;\r\n\r\n    //! Action to add interfaces in a diagram.\r\n    QAction* actToolInterface_;\r\n\r\n    //! Action to drafting.\r\n    QAction* actToolDraft_;\r\n\r\n    //! Action to toggle off-page connection in a diagram.\r\n    QAction* actToolToggleOffPage_;\r\n\r\n    //! Action to create labels.\r\n    QAction* actToolLabel_;\r\n\r\n    //! Action to zoom in.\r\n    QAction* actZoomIn_;\r\n\r\n    //! Action to zoom out.\r\n    QAction* actZoomOut_;\r\n\r\n    //! Action to reset the zoom to original 1:1 mapping.\r\n    QAction* actZoomOriginal_;\r\n\r\n    //! Action to adjust zoom to fit the document fully in view.\r\n    QAction* actFitInView_;\r\n\r\n\t//! Action to select which dock widgets are visible.\r\n\tQAction* actVisibleDocks_;\r\n\r\n    QAction* actVisibleScript_ = nullptr;\r\n\r\n    //! Action to manage visibility control.\r\n    QAction* actVisibilityControl_;\r\n\r\n    //! Action to open memory designer.\r\n    QAction* openMemoryDesignerAction_;\r\n\r\n    //! Action to open interconnect generator.\r\n    QAction* openInterconnectGenerator_;\r\n\r\n    //! Action to manage the workspaces.\r\n    QAction* actWorkspaces_;\r\n\r\n    //! The protection group.\r\n    RibbonGroup* protectGroup_; \r\n\r\n    //! Action for controlling protection visibility.\r\n    QAction* protectAction_ = nullptr;\r\n\r\n    //! Action to refresh the current document.\r\n    QAction* actRefresh_;\r\n\r\n    //! Action to set protection on/off.\r\n    QAction* actProtect_;\r\n\r\n    //! Action to open Kactus2 settings.\r\n    QAction* actSettings_;\r\n\r\n    //! Action to show the about box.\r\n    QAction* actAbout_;\r\n\r\n    //! Action to show the help window.\r\n    QAction* actHelp_;\r\n\r\n    //! Action to exit the program.\r\n    QAction* actExit_;\r\n\r\n    QActionGroup* modeActionGroup_;\r\n\r\n    //! The group for configuration tools.\r\n    RibbonGroup* configurationToolsGroup_;\r\n\r\n    //! Action for controlling configurationGroup visibility.\r\n    QAction* configurationToolsAction_ = nullptr;\r\n\r\n    //! The action to configure the views.\r\n    QAction* actionConfigureViews_;\r\n\r\n    //! The group for filtering tools.\r\n    RibbonGroup* filteringGroup_;\r\n\r\n    //! Action for controlling filtering visibility.\r\n    QAction* filteringAction_ = nullptr;\r\n\r\n    //! The action to filter chained address space memory connections in a memory designer.\r\n    QAction* actionFilterAddressSpaceChains_;\r\n\r\n    //! The action to condense memory graphics items in a memory designer.\r\n    QAction* actionCondenseMemoryItems_;\r\n\r\n    //! The action to condense field graphics items in a memory designer.\r\n    QAction* actionCondenseFieldItems_;\r\n\r\n    //! The action to extend field graphics items in a memory designer.\r\n    QAction* actionExtendFieldItems_;\r\n\r\n    //! The action to filter address space segments in a memory designer.\r\n    QAction* actionFilterSegments_;\r\n\r\n    //! The action to filter address blocks in a memory designer.\r\n    QAction* actionFilterAddressBlocks_;\r\n\r\n    //! The action to filter registers in a memory designer.\r\n    QAction* actionFilterRegisters_;\r\n\r\n    //! The action to filter fields in a memory designer.\r\n    QAction* actionFilterFields_;\r\n\r\n    //! The action to filter unconnected memory items in a memory design.\r\n    QAction* actionFilterUnconnectedMemoryItems_;\r\n\r\n    //! Action to toggle visibility of memory overlap items in memory designer.\r\n    QAction* actionFilterMemoryOverlap_ = nullptr;\r\n\r\n    QMenu* generationMenu_ = nullptr;\r\n\r\n\t//! The menu containing the actions to select which windows to display.\r\n\tQMenu windowsMenu_;\r\n\r\n    //! Menu which contains the actions for visibility control.\r\n    QMenu visibilityMenu_;\r\n\r\n    //! Menu which contains the actions for managing workspaces.\r\n    QMenu workspaceMenu_;\r\n\r\n    //! Settings for workspaces.\r\n    WorkspaceSettings workspace_;\r\n\r\n    MessageMediator* messageChannel_;\r\n    \r\n};\r\n\r\n#endif // MAINWINDOW_H\r\n"
  },
  {
    "path": "paper.bib",
    "content": "@INPROCEEDINGS{DEV,\r\nauthor={A. Kamppi and L. Matilainen and J. M. Maatta and E. Salminen and T. D. Hamalainen and M. Hannikainen},\r\nbooktitle={Digital System Design (DSD), 2011 14th Euromicro Conference on},\r\ntitle={Kactus2: Environment for Embedded Product Development Using IP-XACT and MCAPI},\r\nyear={2011},\r\npages={262-265},\r\ndoi={10.1109/DSD.2011.36},\r\nmonth={Aug},}\r\n\r\n@ARTICLE{IP-XACT,\r\njournal={IEEE Std 1685-2014 (Revision of IEEE Std 1685-2009)},\r\ntitle={IEEE Standard for IP-XACT, Standard Structure for Packaging, Integrating, and Reusing IP within Tool Flows},\r\nyear={2014},\r\npages={1-510},\r\ndoi={10.1109/IEEESTD.2014.6898803},\r\nmonth={Sept},}\r\n\r\n"
  },
  {
    "path": "paper.md",
    "content": "---\r\ntitle: 'Kactus2: A graphical EDA tool built on the IP-XACT standard'\r\ntags:\r\n  - IP-XACT\r\n  - EDA\r\n  - Design\r\n  - FPGA\r\n  - Hardware\r\n  - Intellectual Property\r\n  - reuse\r\n  - mpsoc\r\nauthors:\r\n - name: Antti Kamppi\r\n   affiliation: 1\r\n - name: Esko Pekkarinen\r\n   affiliation: 1\r\n - name: Janne Virtanen\r\n   affiliation: 1\r\n - name: Joni-Matti Mtt\r\n   affiliation: 1\r\n - name: Juho Jrvinen\r\n   affiliation: 1\r\n - name: Lauri Matilainen\r\n   affiliation: 1\r\n - name: Mikko Teuho\r\n   affiliation: 1\r\n - name: Timo D. Hmlinen\r\n   affiliation: 1\r\naffiliations:\r\n - name: Tampere University of Technology\r\n   index: 1\r\ndate: 11 November 2016\r\nbibliography: paper.bib\r\n---\r\n\r\n# Summary\r\n\r\nKactus2 is a graphical electronic design automation (EDA) tool [@DEV] for packing and assembling building blocks for application-specific integrated circuits (ASIC) and field-programmable gate arrays (FPGA). Thus, the target audience is mostly hardware developers, but also co-operation with software development is enabled through software integration.\r\n\r\nThe core functionality of Kactus2 is creating and reusing intellectual property. This can be done for individual components as well as designs and hierarchies incorporating multiple component instances. In addition, the tool supports configuration for improving reusability. Furthermore, Kactus2 features integration support such as HDL generation and memory visualization.\r\n\r\nKactus2 is based on IEEE 1685-2014 \"IP-XACT\" standard [@IP-XACT], which defines an XML format for documents describing the components, designs and configurations. Ideally, this enables vendor independent integration between standard compatible tools. The IP-XACT standard is complex and versatile, but Kactus2 hides most of the complexity and offers the users the easiest to use tool to accomplish IP-XACT related EDA tasks. In addition, Kactus2 includes extensions for software components, software on hardware mapping and API abstraction, as well as physical product hierarchy including printed circuit board level. \r\n\r\nStructurally Kactus2 consists of a core and plugins. The latter implement, for example, import from legacy code (e.g. Verilog, VHDL) and generation of source code for hardware synthesis and software development. Current generators produce Verilog, VHDL, PADS PCB parts as well as C memory map headers. Kactus2 utilizes Qt5 user interface library. Supported platforms are Windows and Linux.\r\n\r\n# References\r\n\r\n"
  },
  {
    "path": "resource.h",
    "content": "//{{NO_DEPENDENCIES}}\n// Microsoft Visual C++ generated include file.\n// Used by Kactus2.rc\n//\n#define IDB_PNG1                        101\n#define IDB_PNG2                        102\n#define IDB_PNG3                        103\n#define IDB_PNG4                        104\n#define IDB_PNG5                        105\n#define IDB_PNG6                        106\n#define IDR_ACCELERATOR1                107\n#define IDR_FILE1                       108\n\n// Next default values for new objects\n// \n#ifdef APSTUDIO_INVOKED\n#ifndef APSTUDIO_READONLY_SYMBOLS\n#define _APS_NEXT_RESOURCE_VALUE        111\n#define _APS_NEXT_COMMAND_VALUE         40002\n#define _APS_NEXT_CONTROL_VALUE         1001\n#define _APS_NEXT_SYMED_VALUE           101\n#endif\n#endif\n"
  },
  {
    "path": "settings/CodeEditorSettingsPage.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: CodeEditorSettingsPage.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Joni-Matti Maatta\r\n// Date: 14.6.2011\r\n//\r\n// Description:\r\n// Code editor settings property page.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"CodeEditorSettingsPage.h\"\r\n\r\n#include <common/widgets/assistedTextEdit/AssistedTextEdit.h>\r\n\r\n#include <QHBoxLayout>\r\n#include <QVBoxLayout>\r\n#include <QDir>\r\n#include <QPushButton>\r\n#include <QFileDialog>\r\n#include <QLabel>\r\n#include <QGroupBox>\r\n#include <QCoreApplication>\r\n#include <QMessageBox>\r\n#include <QRegularExpression>\r\n#include <QRegularExpressionValidator>\r\n#include <QGridLayout>\r\n#include <QColorDialog>\r\n#include <QMetaType>\r\n#include <QFormLayout>\r\n\r\nnamespace\r\n{\r\n    //! Style names to show in the page.\r\n    QString const STYLE_NAMES[] =\r\n    {\r\n        \"Keywords\",\r\n        \"Preprocessor\",\r\n        \"Strings\",\r\n        \"Single-line Comments\",\r\n        \"Multi-line Comments\",\r\n        \"API Data Types\",\r\n        \"API Functions\",\r\n        \"Language Specific\"\r\n    };\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: CodeEditorSettingsPage()\r\n//-----------------------------------------------------------------------------\r\nCodeEditorSettingsPage::CodeEditorSettingsPage(QSettings& settings) : \r\nSettingsPage(settings),\r\n    indentWidthEdit_(0),\r\n    fontCombo_(new QFontComboBox()),\r\n    fontSizeCombo_(new QComboBox()),\r\n    highlightTypeList_(new QListWidget()),\r\n    colorBox_(new ColorBox(QSize(32, 32))),\r\n    boldCheckBox_(new QCheckBox()),\r\n    italicCheckBox_(new QCheckBox()),\r\n    previewBox_(new ColorBox(QSize(200, 64))),\r\n    styles_()\r\n{\r\n    fontCombo_->setWritingSystem(QFontDatabase::Latin);\r\n\r\n    fontSizeCombo_->setMaxVisibleItems(MAX_FONT_SIZE - MIN_FONT_SIZE + 1);\r\n\r\n    for (int size = MIN_FONT_SIZE; size <= MAX_FONT_SIZE; ++size)\r\n    {\r\n        fontSizeCombo_->addItem(QString::number(size));\r\n    }\r\n\r\n    for (int i = 0; i < LanguageHighlighter::STYLE_COUNT; ++i)\r\n    {\r\n        highlightTypeList_->addItem(STYLE_NAMES[i]);\r\n    }\r\n\r\n    previewBox_->setFixedSize(QSize(QWIDGETSIZE_MAX, QWIDGETSIZE_MAX));    \r\n    previewBox_->setColor(Qt::white);\r\n    previewBox_->setText(\"AaBbCcXxYyZz\");\r\n\r\n    setupLayout();\r\n\r\n    connect(fontCombo_, SIGNAL(currentFontChanged(QFont const&)), this, SLOT(updateSample()));\r\n    connect(fontSizeCombo_, SIGNAL(currentIndexChanged(int)), this, SLOT(updateSample()));\r\n    connect(boldCheckBox_, SIGNAL(stateChanged(int)), this, SLOT(updateSample()));\r\n    connect(italicCheckBox_, SIGNAL(stateChanged(int)), this, SLOT(updateSample()));\r\n\r\n    connect(highlightTypeList_, SIGNAL(currentItemChanged(QListWidgetItem*, QListWidgetItem*)),\r\n        this, SLOT(onSelectStyle(QListWidgetItem*, QListWidgetItem*)));\r\n\r\n    connect(colorBox_, SIGNAL(clicked()), this, SLOT(selectColor()));\r\n\r\n    loadSettings();\r\n\r\n    highlightTypeList_->setCurrentRow(0);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: validate()\r\n//-----------------------------------------------------------------------------\r\nbool CodeEditorSettingsPage::validate()\r\n{\r\n    Q_ASSERT(prevalidate());\r\n\r\n    if (indentWidthEdit_->text().isEmpty() || indentWidthEdit_->text().toInt() < 1 ||\r\n        indentWidthEdit_->text().toInt() > 60)\r\n    {\r\n        QMessageBox msgBox(QMessageBox::Critical, QCoreApplication::applicationName(),\r\n                           tr(\"Please enter an indent width between 1 and 60.\"), QMessageBox::Ok, this);\r\n        msgBox.exec();\r\n        return false;\r\n    }\r\n\r\n    return true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: apply()\r\n//-----------------------------------------------------------------------------\r\nvoid CodeEditorSettingsPage::apply()\r\n{\r\n    // Store the current style's settings to the data structure.\r\n    int row = highlightTypeList_->currentRow();\r\n    styles_[row].bold = boldCheckBox_->isChecked();\r\n    styles_[row].italic = italicCheckBox_->isChecked();\r\n    styles_[row].color = colorBox_->getColor();\r\n\r\n    // Save the settings.\r\n    settings().setValue(\"Editor/IndentWidth\", indentWidthEdit_->text().toInt());\r\n    \r\n    if (indentStyleRadioButtons_[INDENT_STYLE_SPACES]->isChecked())\r\n    {\r\n        settings().setValue(\"Editor/IndentStyle\", INDENT_STYLE_SPACES);\r\n    }\r\n    else\r\n    {\r\n        settings().setValue(\"Editor/IndentStyle\", INDENT_STYLE_TAB);\r\n    }\r\n\r\n    QFont font = fontCombo_->currentFont();\r\n    font.setPointSize(fontSizeCombo_->currentText().toInt());\r\n    settings().setValue(\"Editor/Font\", QVariant::fromValue(font));\r\n\r\n    for (int i = 0; i < LanguageHighlighter::STYLE_COUNT; ++i)\r\n    {\r\n        settings().setValue(\"Editor/Highlight/\" + \r\n            LanguageHighlighter::getStyleName(static_cast<LanguageHighlighter::StyleType>(i)),\r\n            QVariant::fromValue(styles_[i]));\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: selectColor()\r\n//-----------------------------------------------------------------------------\r\nvoid CodeEditorSettingsPage::selectColor()\r\n{\r\n    QColorDialog dialog(this);\r\n    dialog.setCurrentColor(colorBox_->getColor());\r\n\r\n    if (dialog.exec() == QDialog::Accepted)\r\n    {\r\n        colorBox_->setColor(dialog.currentColor());\r\n        updateSample();\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: updateSample()\r\n//-----------------------------------------------------------------------------\r\nvoid CodeEditorSettingsPage::updateSample()\r\n{\r\n    previewBox_->setTextColor(colorBox_->getColor());\r\n\r\n    QFont font = fontCombo_->currentFont();\r\n    font.setPointSize(fontSizeCombo_->currentText().toInt());\r\n    font.setBold(boldCheckBox_->isChecked());\r\n    font.setItalic(italicCheckBox_->isChecked());\r\n\r\n    previewBox_->setTextFont(font);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: onSelectStyle()\r\n//-----------------------------------------------------------------------------\r\nvoid CodeEditorSettingsPage::onSelectStyle(QListWidgetItem* cur, QListWidgetItem* prev)\r\n{\r\n    int prevRow = highlightTypeList_->row(prev);\r\n    int curRow = highlightTypeList_->row(cur);\r\n\r\n    if (prevRow >= 0)\r\n    {\r\n        // Save the previous style.\r\n        styles_[prevRow].bold = boldCheckBox_->isChecked();\r\n        styles_[prevRow].italic = italicCheckBox_->isChecked();\r\n        styles_[prevRow].color = colorBox_->getColor();\r\n    }\r\n\r\n    // Import the settings from the new style.\r\n    colorBox_->setColor(styles_[curRow].color);\r\n    boldCheckBox_->setChecked(styles_[curRow].bold);\r\n    italicCheckBox_->setChecked(styles_[curRow].italic);\r\n\r\n    updateSample();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: CodeEditorSettingsPage::setupLayout()\r\n//-----------------------------------------------------------------------------\r\nvoid CodeEditorSettingsPage::setupLayout()\r\n{\r\n    // Create the indentation group and all of its widgets.\r\n    QGroupBox* indentGroup = new QGroupBox(tr(\"Indentation\"), this);\r\n\r\n    QLabel* indentWidthLabel = new QLabel(tr(\"Indent width:\"), indentGroup);\r\n    indentWidthEdit_ = new QLineEdit(indentGroup);\r\n    indentWidthEdit_->setFixedWidth(40);\r\n    indentWidthEdit_->setValidator(new QRegularExpressionValidator(QRegularExpression(\"^\\\\d+$\"), this));\r\n\r\n    QHBoxLayout* widthLayout = new QHBoxLayout();\r\n    widthLayout->addWidget(indentWidthLabel);\r\n    widthLayout->addWidget(indentWidthEdit_);\r\n    widthLayout->addStretch(1);\r\n\r\n    indentStyleRadioButtons_[INDENT_STYLE_TAB] = new QRadioButton(tr(\"Use tabs\"), indentGroup);\r\n    indentStyleRadioButtons_[INDENT_STYLE_SPACES] = new QRadioButton(tr(\"Use spaces\"), indentGroup);\r\n\r\n    QVBoxLayout* indentLayout = new QVBoxLayout(indentGroup);    \r\n    indentLayout->addWidget(indentStyleRadioButtons_[INDENT_STYLE_TAB]);\r\n    indentLayout->addWidget(indentStyleRadioButtons_[INDENT_STYLE_SPACES]);\r\n    indentLayout->addLayout(widthLayout);\r\n\r\n    QGroupBox* fontGroup = new QGroupBox(tr(\"Font\"), this);\r\n\r\n    QFormLayout* fontAndSizeLayout = new QFormLayout(fontGroup);\r\n    fontAndSizeLayout->addRow(tr(\"Font:\"), fontCombo_);\r\n    fontAndSizeLayout->addRow(tr(\"Size:\"), fontSizeCombo_);\r\n\r\n    highlightTypeList_->setFixedWidth(208);\r\n\r\n    QGroupBox* highlightGroup = new QGroupBox(tr(\"Syntax highlighting\"), this);\r\n\r\n    QFormLayout* syntaxOptionsLayout = new QFormLayout();    \r\n    syntaxOptionsLayout->addRow(tr(\"Bold:\"), boldCheckBox_);\r\n    syntaxOptionsLayout->addRow(tr(\"Italic:\"), italicCheckBox_);\r\n    syntaxOptionsLayout->addRow(tr(\"Color:\"), colorBox_);\r\n    syntaxOptionsLayout->addRow(tr(\"Preview:\"), previewBox_);\r\n\r\n    QGridLayout* highlightLayout = new QGridLayout(highlightGroup);\r\n    highlightLayout->addWidget(highlightTypeList_, 0, 0, 1, 1);\r\n    highlightLayout->addLayout(syntaxOptionsLayout, 0, 1, 1, 1);\r\n\r\n    // Setup the layout.\r\n    QGridLayout* topLayout = new QGridLayout(this);\r\n    topLayout->addWidget(fontGroup, 0, 0, 1, 1);\r\n    topLayout->addWidget(indentGroup, 0, 1, 1, 1);\r\n    topLayout->addWidget(highlightGroup, 1, 0, 1, 2);\r\n    topLayout->setColumnStretch(0, 1);\r\n    topLayout->setColumnStretch(1, 1);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: loadSettings()\r\n//-----------------------------------------------------------------------------\r\nvoid CodeEditorSettingsPage::loadSettings()\r\n{\r\n    // Load indentation settings.\r\n    unsigned int width = settings().value(\"Editor/IndentWidth\", 4).toInt();\r\n    indentWidthEdit_->setText(QString::number(width));\r\n\r\n    IndentStyle style = static_cast<IndentStyle>(settings().value(\"Editor/IndentStyle\",\r\n                                                                 INDENT_STYLE_SPACES).toInt());\r\n\r\n    indentStyleRadioButtons_[style]->setChecked(true);\r\n    indentStyleRadioButtons_[1 - style]->setChecked(false);\r\n\r\n    // Load font and highlight settings.\r\n    QFont font = settings().value(\"Editor/Font\", QVariant::fromValue(QFont(\"Courier New\", 10))).value<QFont>();\r\n    fontCombo_->setCurrentFont(font);\r\n    fontSizeCombo_->setCurrentIndex(font.pointSize() - MIN_FONT_SIZE);\r\n\r\n    for (int i = 0; i < LanguageHighlighter::STYLE_COUNT; ++i)\r\n    {\r\n        styles_[i] = settings().value(\"Editor/Highlight/\" + \r\n            LanguageHighlighter::getStyleName(static_cast<LanguageHighlighter::StyleType>(i)),\r\n            QVariant::fromValue(LanguageHighlighter::DEFAULT_STYLES[i])).value<HighlightStyleDesc>();\r\n    }\r\n}\r\n"
  },
  {
    "path": "settings/CodeEditorSettingsPage.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: CodeEditorSettingsPage.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Joni-Matti Maatta\r\n// Date: 14.6.2011\r\n//\r\n// Description:\r\n// Code editor settings property page.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef CODEEDITORSETTINGSPAGE_H\r\n#define CODEEDITORSETTINGSPAGE_H\r\n\r\n#include \"SettingsPage.h\"\r\n#include <common/widgets/colorBox/ColorBox.h>\r\n#include <common/widgets/assistedTextEdit/HighlightStyleDesc.h>\r\n\r\n#include <Plugins/common/LanguageHighlighter.h>\r\n\r\n#include <QLineEdit>\r\n#include <QSettings>\r\n#include <QRadioButton>\r\n#include <QFontComboBox>\r\n#include <QComboBox>\r\n#include <QListWidget>\r\n#include <QFrame>\r\n#include <QCheckBox>\r\n\r\n//-----------------------------------------------------------------------------\r\n//! CodeEditorSettingsPage class.\r\n//-----------------------------------------------------------------------------\r\nclass CodeEditorSettingsPage : public SettingsPage\r\n{\r\n    Q_OBJECT\r\n\r\npublic:\r\n    /*!\r\n     *  Constructor.\r\n     *\r\n     *    @param [in/out] settings The settings store.\r\n     */\r\n    CodeEditorSettingsPage(QSettings& settings);\r\n\r\n    /*!\r\n     *  Destructor.\r\n     */\r\n    virtual ~CodeEditorSettingsPage() = default;\r\n\r\n    // Disable copying.\r\n    CodeEditorSettingsPage(CodeEditorSettingsPage const& rhs) = delete;\r\n\r\n    CodeEditorSettingsPage& operator=(CodeEditorSettingsPage const& rhs) = delete;\r\n\r\n    /*!\r\n     *  Validates the contents of the page thoroughly.\r\n     *\r\n     *    @return True, if the contents are valid. False, if they are invalid.\r\n     *\r\n     *      @remarks Showing message boxes for errors is allowed.\r\n     */\r\n    virtual bool validate()  override final;\r\n\r\n    /*!\r\n     *  Applies the changes that were done in the page.\r\n     */\r\n    virtual void apply()  override final;\r\n\r\npublic slots:\r\n    //! Requests the user to select a color.\r\n    void selectColor();\r\n\r\n    /*!\r\n     *  Called when a different highlight style is selected from the list box.\r\n     */\r\n    void onSelectStyle(QListWidgetItem* cur, QListWidgetItem* prev);\r\n\r\n    /*!\r\n     *  Updates the highlight sample.\r\n     */\r\n    void updateSample();\r\n\r\nprivate:\r\n    \r\n    //! Sets the page layout.\r\n    void setupLayout();\r\n\r\n    /*!\r\n     *  Loads the current settings.\r\n     */\r\n    void loadSettings();\r\n\r\n    enum\r\n    {\r\n        MIN_FONT_SIZE = 6,\r\n        MAX_FONT_SIZE = 24\r\n    };\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! Indent width edit.\r\n    QLineEdit* indentWidthEdit_;\r\n\r\n    //! Indentation style radio buttons.\r\n    QRadioButton* indentStyleRadioButtons_[2];\r\n\r\n    //! Font combobox.\r\n    QFontComboBox* fontCombo_;\r\n\r\n    //! Font size combobox.\r\n    QComboBox* fontSizeCombo_;\r\n\r\n    //! Highlight type listbox.\r\n    QListWidget* highlightTypeList_;\r\n\r\n    //! Color box for showing the currently selected color.\r\n    ColorBox* colorBox_;\r\n\r\n    //! Check box for bold style.\r\n    QCheckBox* boldCheckBox_;\r\n\r\n    //! Check box for italic style.\r\n    QCheckBox* italicCheckBox_;\r\n\r\n    //! Color box for showing a sample of the highlighted text.\r\n    ColorBox* previewBox_;\r\n\r\n    //! The current (non-saved) highlight styles.\r\n    HighlightStyleDesc styles_[LanguageHighlighter::STYLE_COUNT];\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n\r\n#endif // CODEEDITORSETTINGSPAGE_H\r\n"
  },
  {
    "path": "settings/ComponentEditorSettingsPage.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ComponentEditorSettingsPage.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 11.11.2014\r\n//\r\n// Description:\r\n// Component editor property settings page.\r\n//-----------------------------------------------------------------------------\r\n#include \"ComponentEditorSettingsPage.h\"\r\n\r\n#include <IPXACTmodels/kactusExtensions/KactusAttribute.h>\r\n\r\n#include <QVBoxLayout>\r\n#include <QHBoxLayout>\r\n#include <QHeaderView>\r\n#include <QTabWidget>\r\n#include <QLabel>\r\n#include <QComboBox>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditorSettingsPage::ComponentEditorSettingsPage()\r\n//-----------------------------------------------------------------------------\r\nComponentEditorSettingsPage::ComponentEditorSettingsPage(QSettings &settings) : \r\nSettingsPage(settings)\r\n{\r\n\tloadSettings();\r\n\tsetupLayout();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditorSettingsPage::apply()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentEditorSettingsPage::apply()\r\n{\r\n\tSettingsPage::settings().beginGroup(\"Workspaces\");\r\n\r\n\tQStringList workspaceNames = SettingsPage::settings().childGroups();\r\n\r\n\tfor (int workspaceIndex = 0; workspaceIndex < workspaceNames.size(); ++workspaceIndex)\r\n\t{\r\n\t\tSettingsPage::settings().beginGroup(workspaceNames.at(workspaceIndex) + \"/ComponentEditorFilters\");\r\n\r\n\t\tapplyHwSettings(workspaceIndex);\r\n\r\n\t\tapplySwSettings(workspaceIndex);\r\n\r\n\t\tSettingsPage::settings().endGroup(); // workspace/ComponentEditorFilters.\r\n\t}\r\n\r\n\tSettingsPage::settings().endGroup(); // Workspaces.\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditorSettingsPage::applyHwSettings()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentEditorSettingsPage::applyHwSettings(int workspaceIndex) const\r\n{\r\n\tSettingsPage::settings().beginGroup(\"HW\");\r\n\r\n\tfor (unsigned int hierarchyIndex = 0; hierarchyIndex < KactusAttribute::KTS_PRODHIER_COUNT; ++hierarchyIndex)\r\n\t{\r\n    \tauto val = static_cast<KactusAttribute::ProductHierarchy>(hierarchyIndex);\r\n\t    SettingsPage::settings().beginGroup(KactusAttribute::hierarchyToString(val));\r\n\r\n    \tQStringList hwCheckboxNames = SettingsPage::settings().childKeys();\r\n\t    for (int checkBoxIndex = 0; checkBoxIndex < \r\n\t\t    workspaceHwCheckBoxes_.at(workspaceIndex).at(hierarchyIndex).size();  ++checkBoxIndex)\r\n    \t{\r\n\t    \t// hwCheckboxNames contains the child keys of hierarchies.\r\n\t\t    // wsHwCheckBoxes_ has keys in the same order as hierachyKeys (see loadSettings function).\r\n    \t\tif (hwCheckboxNames.size() == workspaceHwCheckBoxes_.at(workspaceIndex).at(hierarchyIndex).size())\r\n\t    \t{\r\n\t\t    \tSettingsPage::settings().setValue(hwCheckboxNames.at(checkBoxIndex), \r\n\t\t\t    \tworkspaceHwCheckBoxes_.at(workspaceIndex).at(hierarchyIndex).at(checkBoxIndex)->isChecked());\r\n    \t\t}\r\n\t    }\r\n    \tSettingsPage::settings().endGroup(); // hierarchy group.\r\n\t}\r\n\r\n\tSettingsPage::settings().endGroup(); // HW.\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditorSettingsPage::applySwSettings()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentEditorSettingsPage::applySwSettings(int workspaceIndex) const\r\n{\r\n\tSettingsPage::settings().beginGroup(\"SW\");\r\n\r\n\tQStringList swCheckboxNames = SettingsPage::settings().childKeys();\r\n\r\n\tfor (int checkBoxIndex = 0; checkBoxIndex < workspaceSwCheckBoxes_.at(workspaceIndex).size(); ++checkBoxIndex)\r\n\t{\r\n\t\tif (swCheckboxNames.size() == workspaceSwCheckBoxes_.at(workspaceIndex).size())\r\n\t\t{\r\n\t\t\tSettingsPage::settings().setValue(swCheckboxNames.at(checkBoxIndex), \r\n\t\t\t\tworkspaceSwCheckBoxes_.at(workspaceIndex).at(checkBoxIndex)->isChecked());\r\n\t\t}\r\n\t}\r\n\r\n\tSettingsPage::settings().endGroup(); // SW\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditorSettingsPage::onHwHorizonSelectAll()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentEditorSettingsPage::onHwHorizonSelectAll(int rowIndex)\r\n{\r\n\tbool checkBoxChecked = false;\r\n\r\n\tfor (int columnIndex = 0; columnIndex < workspaceHwCheckBoxes_.at(currentWorkspaceIndex_).size(); \r\n\t\t++columnIndex)\r\n\t{\r\n\t\tif (!workspaceHwCheckBoxes_.at(currentWorkspaceIndex_).at(columnIndex).at(rowIndex)->isChecked())\r\n\t\t{\r\n\t\t\tcheckBoxChecked = true;\r\n\t\t\tbreak;\r\n\t\t}\r\n\t}\r\n\r\n\tfor (int columnIndex = 0; columnIndex < workspaceHwCheckBoxes_.at(currentWorkspaceIndex_).size(); \r\n\t\t++columnIndex)\r\n\t{\r\n\t\tworkspaceHwCheckBoxes_.at(currentWorkspaceIndex_).at(columnIndex).at(rowIndex)->\r\n\t\t\tsetChecked(checkBoxChecked);\r\n\t}\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditorSettingsPage::onHwVerticalSelectAll()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentEditorSettingsPage::onHwVerticalSelectAll(int columnIndex)\r\n{\r\n\tbool checkBoxChecked = false;\r\n\r\n\tfor (int rowIndex = 0; rowIndex < workspaceHwCheckBoxes_.at(currentWorkspaceIndex_).at(columnIndex).size();\r\n\t\t++rowIndex)\r\n\t{\r\n\t\tif (!workspaceHwCheckBoxes_.at(currentWorkspaceIndex_).at(columnIndex).at(rowIndex)->isChecked())\r\n\t\t{\r\n\t\t\tcheckBoxChecked = true;\r\n\t\t\tbreak;\r\n\t\t}\r\n\t}\r\n\r\n\tfor (int rowIndex = 0; rowIndex < workspaceHwCheckBoxes_.at(currentWorkspaceIndex_).at(columnIndex).size();\r\n\t\t++rowIndex)\r\n\t{\r\n\t\tworkspaceHwCheckBoxes_.at(currentWorkspaceIndex_).at(columnIndex).at(rowIndex)->\r\n\t\t\tsetChecked(checkBoxChecked);\r\n\t}\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditorSettingsPage::onSwHorizonSelectAll()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentEditorSettingsPage::onSwHorizonSelectAll(int rowIndex)\r\n{\r\n\tif (workspaceSwCheckBoxes_.at(currentWorkspaceIndex_).at(rowIndex)->isChecked())\r\n\t{\r\n\t\tworkspaceSwCheckBoxes_.at(currentWorkspaceIndex_).at(rowIndex)->setChecked(false);\r\n\t}\r\n\telse\r\n\t{\r\n\t\tworkspaceSwCheckBoxes_.at(currentWorkspaceIndex_).at(rowIndex)->setChecked(true);\r\n\t}\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditorSettingsPage::onSwVerticalSelectAll()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentEditorSettingsPage::onSwVerticalSelectAll()\r\n{\r\n\tbool checkBoxChecked = false;\r\n\r\n\tfor (int rowIndex = 0; rowIndex < workspaceSwCheckBoxes_.at(currentWorkspaceIndex_).size(); ++rowIndex)\r\n\t{\r\n\t\tif (!workspaceSwCheckBoxes_.at(currentWorkspaceIndex_).at(rowIndex)->isChecked())\r\n\t\t{\r\n\t\t\tcheckBoxChecked = true;\r\n\t\t\tbreak;\r\n\t\t}\r\n\t}\r\n\r\n\tfor (int rowIndex = 0; rowIndex < workspaceSwCheckBoxes_.at(currentWorkspaceIndex_).size(); ++rowIndex)\r\n\t{\r\n\t\tworkspaceSwCheckBoxes_.at(currentWorkspaceIndex_).at(rowIndex)->setChecked(checkBoxChecked);\r\n\t}\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditorSettingsPage::setupLayout()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentEditorSettingsPage::setupLayout()\r\n{\r\n\tSettingsPage::settings().beginGroup(\"Workspaces\");\r\n\r\n\tQString currentWorkspaceName = SettingsPage::settings().value(\"CurrentWorkspace\").toString();\r\n\tQStringList workspaceNames = SettingsPage::settings().childGroups();\r\n\r\n\tSettingsPage::settings().endGroup(); // Workspaces\r\n\r\n\tQStackedWidget* workspaces = createWorkspacePages(currentWorkspaceName, workspaceNames);\r\n\r\n\tQComboBox* workspaceCombo = new QComboBox;\r\n\tworkspaceCombo->addItems(workspaceNames);\r\n\r\n\tconnect(workspaceCombo, SIGNAL(activated(int)), workspaces, SLOT(setCurrentIndex(int)));\r\n\tconnect(workspaceCombo, SIGNAL(activated(int)), this, SLOT(onWorkspaceChanged(int)));\r\n\r\n\tQHBoxLayout* topLayout = new QHBoxLayout;\r\n\tQLabel* workspaceLabel = new QLabel(tr(\"Select workspace:\"));\r\n\ttopLayout->addWidget(workspaceLabel);\r\n\ttopLayout->addWidget(workspaceCombo);\r\n\ttopLayout->addStretch(1);\r\n\r\n\tQVBoxLayout* workspaceLayout = new QVBoxLayout(this);\r\n\tworkspaceLayout->addLayout(topLayout);\r\n\tworkspaceLayout->addWidget(workspaces);\r\n\r\n\tonWorkspaceChanged(workspaceNames.indexOf(currentWorkspaceName));\r\n\tworkspaceCombo->setCurrentIndex(currentWorkspaceIndex_);\r\n\tworkspaces->setCurrentIndex(currentWorkspaceIndex_);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditorSettingsPage::createWorkspacePages()\r\n//-----------------------------------------------------------------------------\r\nQStackedWidget* ComponentEditorSettingsPage::createWorkspacePages(QString currentWorkspaceName, \r\n\tQStringList workspaceNames)\r\n{\r\n\tSettingsPage::settings().beginGroup(\"Workspaces\");\r\n\r\n\tSettingsPage::settings().beginGroup(currentWorkspaceName + \"/ComponentEditorFilters/HW/Flat\");\r\n\tQStringList hwCheckBoxNames = SettingsPage::settings().childKeys();\r\n\tSettingsPage::settings().endGroup(); // workspaceName/ComponentEditorFilters/HW\r\n\r\n\tSettingsPage::settings().beginGroup(currentWorkspaceName + \"/ComponentEditorFilters/SW\");\r\n\tQStringList swCheckBoxNames = SettingsPage::settings().childKeys();\r\n\tSettingsPage::settings().endGroup(); // workspaceName/ComponentEditorFilters/SW\r\n\r\n\tSettingsPage::settings().endGroup(); // Workspaces\r\n\t\r\n\tQStringList hierarchyNames = getHierarchyNames();\r\n\tchangeNameSeparators(hwCheckBoxNames);\r\n\tchangeNameSeparators(swCheckBoxNames);\r\n\tQStackedWidget* workspaces = new QStackedWidget;\r\n\r\n\tfor (int workspaceIndex = 0; workspaceIndex < workspaceNames.size(); ++workspaceIndex)\r\n\t{\r\n\t    QTableWidget* hwTable = new QTableWidget (hwCheckBoxNames.size(), hierarchyNames.size());\r\n\t\tsetHwTable(hwTable, hierarchyNames, hwCheckBoxNames, workspaceIndex);\r\n\r\n\t\tQTableWidget* swTable = new QTableWidget (swCheckBoxNames.size(), 1);\r\n\t\tQStringList swHeader(\"Global\");\r\n\t\tsetSwTable(swTable, swHeader, swCheckBoxNames, workspaceIndex);\r\n\t\t\r\n\t\tQTabWidget* wareTab = new QTabWidget;\r\n\t    wareTab->addTab(hwTable, \"Hardware\");\r\n    \twareTab->addTab(swTable, \"Software\");\r\n\r\n\t\tworkspaces->addWidget(wareTab);\r\n\t}\r\n\r\n\treturn workspaces;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditorSettingsPage::getHierarchyNames()\r\n//-----------------------------------------------------------------------------\r\nQStringList ComponentEditorSettingsPage::getHierarchyNames() const\r\n{\r\n\tQStringList hierarchyNames;\r\n\r\n\tfor (unsigned int hierarchyIndex = 0; hierarchyIndex < KactusAttribute::KTS_PRODHIER_COUNT; ++hierarchyIndex)\r\n\t{\r\n\t\tauto val = static_cast<KactusAttribute::ProductHierarchy>(hierarchyIndex);\r\n\t\thierarchyNames.append(KactusAttribute::hierarchyToString(val));\r\n\t}\r\n\t\r\n\treturn hierarchyNames;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditorSettingsPage::changeNameSeparators()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentEditorSettingsPage::changeNameSeparators(QStringList& checkBoxNames)\r\n{\r\n\tstd::for_each(checkBoxNames.begin(), checkBoxNames.end(), [](auto& name) { name.replace(\"_\", \" \"); });\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditorSettingsPage::setHwTable()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentEditorSettingsPage::setHwTable(QTableWidget* table, QStringList horizontalHeaders,\r\n\tQStringList verticalHeaders, int workspaceIndex)\r\n{\r\n\ttable->setHorizontalHeaderLabels(horizontalHeaders);\r\n\ttable->setVerticalHeaderLabels(verticalHeaders);\r\n\r\n\tQList <QList <QCheckBox*> > hwCheckBoxes = workspaceHwCheckBoxes_.at(workspaceIndex);\r\n\r\n\tauto const COLUMN_COUNT = hwCheckBoxes.size();\r\n\tfor (int column = 0; column < COLUMN_COUNT; ++column)\r\n    {\r\n        auto const ROW_COUNT = hwCheckBoxes.at(column).size();\r\n\t\tfor (int row = 0; row < ROW_COUNT; ++row)\r\n\t\t{\r\n\t\t\ttable->setCellWidget(row, column, centeredCheckBox(hwCheckBoxes.at(column).at(row)));\r\n\t\t}\r\n\t}\r\n\r\n\ttable->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch);\r\n\ttable->verticalHeader()->setSectionResizeMode(QHeaderView::Stretch);\r\n\ttable->setCornerButtonEnabled(false);\r\n\r\n\ttable->setSelectionMode(QAbstractItemView::NoSelection);\r\n\ttable->horizontalHeader()->setSelectionMode(QAbstractItemView::SingleSelection);\r\n\ttable->verticalHeader()->setSelectionMode(QAbstractItemView::SingleSelection);\r\n\r\n\tconnect(table->horizontalHeader(), SIGNAL(sectionClicked(int)), this, SLOT(onHwVerticalSelectAll(int)));\r\n\tconnect(table->verticalHeader(), SIGNAL(sectionClicked(int)), this, SLOT(onHwHorizonSelectAll(int)));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditorSettingsPage::setSwTable()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentEditorSettingsPage::setSwTable(QTableWidget* table, QStringList horizontalHeaders, \r\n\tQStringList verticalHeaders, int workspaceIndex)\r\n{\r\n\ttable->setHorizontalHeaderLabels(horizontalHeaders);\r\n\ttable->setVerticalHeaderLabels(verticalHeaders);\r\n\r\n\tQList <QCheckBox*> swCheckBoxes = workspaceSwCheckBoxes_.at(workspaceIndex);\r\n\r\n    auto const ROW_COUNT = swCheckBoxes.size();\r\n\tfor (int rowIndex = 0; rowIndex < ROW_COUNT; ++rowIndex)\r\n\t{\r\n\t\ttable->setCellWidget(rowIndex, 0, centeredCheckBox(swCheckBoxes.at(rowIndex)));\r\n\t}\r\n\r\n\ttable->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch);\r\n\ttable->setCornerButtonEnabled(false);\r\n\r\n\ttable->setSelectionMode(QAbstractItemView::NoSelection);\r\n\ttable->horizontalHeader()->setSelectionMode(QAbstractItemView::SingleSelection);\r\n\ttable->verticalHeader()->setSelectionMode(QAbstractItemView::SingleSelection);\r\n\r\n\tconnect(table->horizontalHeader(), SIGNAL(sectionClicked(int)), this, SLOT(onSwVerticalSelectAll()));\r\n\tconnect(table->verticalHeader(), SIGNAL(sectionClicked(int)), this, SLOT(onSwHorizonSelectAll(int)));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditorSettingsPage::centeredCheckBox()\r\n//-----------------------------------------------------------------------------\r\nQWidget* ComponentEditorSettingsPage::centeredCheckBox(QCheckBox* checkBox)\r\n{\r\n\tauto checkboxWidget = new QWidget;\r\n\tauto cellLayout = new QHBoxLayout(checkboxWidget);\r\n\tcellLayout->addWidget(checkBox);\r\n    cellLayout->setAlignment(Qt::AlignCenter);\r\n    cellLayout->setContentsMargins(0, 0, 0, 0);\r\n\tcheckboxWidget->setLayout(cellLayout);\r\n\r\n\treturn checkboxWidget;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditorSettingsPage::onWorkspaceChanged()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentEditorSettingsPage::onWorkspaceChanged(int workspaceIndex)\r\n{\r\n\tcurrentWorkspaceIndex_ = workspaceIndex;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditorSettingsPage::loadSettings()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentEditorSettingsPage::loadSettings()\r\n{\r\n\tSettingsPage::settings().beginGroup(\"Workspaces\");\r\n\tQStringList workspaceNames = SettingsPage::settings().childGroups();\r\n\r\n\tfor (auto const& workspaceName : workspaceNames)\r\n\t{\r\n\t\tQList <QList <QCheckBox*> > hardwareCheckBoxes;\r\n\r\n\t\tSettingsPage::settings().beginGroup(workspaceName + \"/ComponentEditorFilters\");\r\n\t\tSettingsPage::settings().beginGroup(\"HW\");\r\n\r\n\t\tfor (unsigned int hierarchyIndex = 0; hierarchyIndex < KactusAttribute::KTS_PRODHIER_COUNT;\r\n\t\t\t ++hierarchyIndex)\r\n\t\t{\r\n\t\t\tauto val = static_cast<KactusAttribute::ProductHierarchy>(hierarchyIndex);\r\n\t\t\tSettingsPage::settings().beginGroup(KactusAttribute::hierarchyToString(val));\r\n\r\n\t\t\thardwareCheckBoxes.append(setCheckBoxes());\r\n\r\n\t\t\tSettingsPage::settings().endGroup(); // Hierarchy group.\r\n\t\t}\r\n\r\n\t\tworkspaceHwCheckBoxes_.append(hardwareCheckBoxes);\r\n\r\n\t\tSettingsPage::settings().endGroup(); // HW.\r\n\r\n\t\tSettingsPage::settings().beginGroup(\"SW\");\r\n\r\n\t\tworkspaceSwCheckBoxes_.append(setCheckBoxes());\r\n\r\n\t\tSettingsPage::settings().endGroup(); // SW\r\n\t\tSettingsPage::settings().endGroup(); // workspaceName/ComponentEditorFilters.\r\n\t}\r\n\r\n\tSettingsPage::settings().endGroup(); // Workspaces.\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentEditorSettingsPage::setCheckBoxes()\r\n//-----------------------------------------------------------------------------\r\nQList <QCheckBox*> ComponentEditorSettingsPage::setCheckBoxes()\r\n{\r\n\tQList <QCheckBox*> checkBoxes;\r\n    QString checkBoxStyle(\"QCheckBox::indicator:unchecked { image: none}\"\r\n        \"QCheckBox::indicator:checked {image: url(:icons/common/graphics/checkMark.png);}\");   \r\n\r\n\tfor (QString const& name : SettingsPage::settings().childKeys())\r\n\t{\r\n\t\tauto checkBox = new QCheckBox(this);\r\n        checkBox->setStyleSheet(checkBoxStyle);\r\n\r\n\t\tcheckBox->setChecked(settings().value(name, true).toBool());\r\n\t\tcheckBoxes.append(checkBox);\r\n\t}\r\n\r\n\treturn checkBoxes;\r\n}\r\n"
  },
  {
    "path": "settings/ComponentEditorSettingsPage.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ComponentEditorSettingsPage.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 11.11.2014\r\n//\r\n// Description:\r\n// Component editor property settings page.\r\n//-----------------------------------------------------------------------------\r\n#ifndef COMPONENTEDITORSETTINGSPAGE_H\r\n#define COMPONENTEDITORSETTINGSPAGE_H\r\n\r\n#include \"SettingsPage.h\"\r\n#include \"ComponentEditorSettingsPage.h\"\r\n\r\n#include <QCheckBox>\r\n#include <QTableWidget>\r\n#include <QStackedWidget>\r\n\r\nclass ComponentEditorSettingsPage : public SettingsPage\r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\tComponentEditorSettingsPage(QSettings &settings);\r\n\t\r\n\tvirtual ~ComponentEditorSettingsPage() = default;\r\n\r\n    //! Disable copying.\r\n    ComponentEditorSettingsPage(ComponentEditorSettingsPage const& rhs) = delete;\r\n    ComponentEditorSettingsPage& operator=(ComponentEditorSettingsPage const& rhs) = delete;\r\n\r\n\t/*!\r\n\t *  Applies the changes that were done to the page.\r\n\t */\r\n\tvirtual void apply() override final;\r\n\r\npublic slots:\r\n\r\n\t/*!\r\n\t *  Select all hardware check boxes from the selected row.\r\n\t *\r\n\t *    @param [in] rowIndex   The selected row.\r\n\t */\r\n\tvoid onHwHorizonSelectAll(int rowIndex);\r\n\r\n\t/*!\r\n\t *  Select all hardware check boxes from the selected column.\r\n\t *\r\n\t *    @param [in] columnIndex   The selected column.\r\n\t */\r\n\tvoid onHwVerticalSelectAll(int columnIndex);\r\n\r\n\t/*!\r\n\t *  Select all software check boxes from the selected row.\r\n\t *\r\n\t *    @param [in] rowIndex   The selected row.\r\n\t */\r\n\tvoid onSwHorizonSelectAll(int rowIndex);\r\n\r\n\t/*!\r\n\t *  Select all software check boxes from the selected column.\r\n\t *\r\n\t *    @param [in] columnIndex   If software would have hierarchy, this selects it.\r\n\t */\r\n    void onSwVerticalSelectAll();\r\n\r\n\t/*!\r\n\t *  Change the workspace index.\r\n\t *\r\n\t *    @param [in] workspaceIndex   The index value of the new workspace.\r\n\t */\r\n\tvoid onWorkspaceChanged(int workspaceIndex);\r\n\r\nprivate:\r\n\r\n\t/*!\r\n\t *  Apply the hardware settings.\r\n\t *\r\n\t *    @param [in] workspaceIndex   The current workspace index.\r\n\t */\r\n\tvoid applyHwSettings(int workspaceIndex) const;\r\n\r\n    /*!\r\n     *  Apply the software settings.\r\n     *\r\n     *    @param [in] workspaceIndex   The current workspace index.\r\n     */\r\n    void applySwSettings(int workspaceIndex) const;\r\n\r\n\t/*!\r\n\t *  Setup the layout.\r\n\t */\r\n\tvoid setupLayout();\r\n\r\n\t/*!\r\n\t *  Setup the table for the layout.\r\n\t */\r\n\tQStackedWidget* createWorkspacePages(QString currentWorkspaceName, QStringList workspaceNames);\r\n\r\n\t/*!\r\n\t *  Get the names of the hierarchies.\r\n\t */\r\n\tQStringList getHierarchyNames() const;\r\n\r\n\t/*!\r\n\t *  Set the check box names to correct format.\r\n\t *\r\n\t *    @param [in/out] checkBoxNames   List of names to be changed.\r\n\t */\r\n\tvoid changeNameSeparators(QStringList& checkBoxNames);\r\n\r\n    /*!\r\n\t *  Set the hardware table.\r\n\t *\r\n\t *    @param [in] table               The table.\r\n\t *    @param [in] horizontalHeaders   Horizontal headers for the table.\r\n\t *    @param [in] verticalHeaders     Vertical headers for the table.\r\n\t *    @param [in] workspaceIndex      Current workspace index.\r\n\t */\r\n\tvoid setHwTable(QTableWidget* table, QStringList horizontalHeaders, QStringList verticalHeaders, \r\n\t\tint workspaceIndex);\r\n\r\n\t/*!\r\n\t *  Set the software table.\r\n\t *\r\n\t *    @param [in] table               The table.\r\n\t *    @param [in] horizontalHeaders   Horizontal headers for the table.\r\n\t *    @param [in] verticalHeaders     Vertical headers for the table.\r\n\t *    @param [in] workspaceIndex      Current workspace index.\r\n\t */\r\n\tvoid setSwTable(QTableWidget* table, QStringList horizontalHeaders, QStringList verticalHeaders, \r\n\t\tint workspaceIndex);\r\n\t\r\n\t/*!\r\n\t *  Center the check box to a table cell.\r\n\t *\r\n\t *    @param [in] checkBox   Check box to be centered.\r\n\t */\r\n\tQWidget* centeredCheckBox(QCheckBox* checkBox);\r\n\t\r\n\t/*!\r\n\t *  Loads the current settings.\r\n\t */\r\n\tvoid loadSettings();\r\n\r\n\t/*!\r\n\t *  Set the check boxes to their respective lists.\r\n\t *\r\n\t *    @param [in] checkBoxes   The current usable check box list.\r\n\t */\r\n\tQList <QCheckBox*> setCheckBoxes();\r\n\r\n\t//! All the hardware check boxes used by all the workspaces. Structured as workspace.hierarchy.checkboxes.\r\n\tQList <QList <QList <QCheckBox*> > > workspaceHwCheckBoxes_;\r\n\r\n\t//! All the software check boxes used by all the workspaces. Structured as workspace.checkboxes.\r\n\tQList <QList <QCheckBox*> > workspaceSwCheckBoxes_;\r\n\r\n\t//! The current workspace index.\r\n\tint currentWorkspaceIndex_ = 0;\r\n};\r\n\r\n#endif // COMPONENTEDITORSETTINGSPAGE_H\r\n"
  },
  {
    "path": "settings/FileTypeColumns.h",
    "content": "//-----------------------------------------------------------------------------\n// File: FileTypeColumns.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Esko Pekkarinen\n// Date: 13.03.2017\n//\n// Description:\n// Common declarations for editing file type table columns.\n//-----------------------------------------------------------------------------\n\n#ifndef FILE_TYPE_COLUMNS_H\n#define FILE_TYPE_COLUMNS_H\n\nnamespace FileTypeColumns\n{\n    //! Defines the columns for the file types table.\n    enum Columns\n    {\n        NAME = 0,        \n        EXTENSIONS,\n        EXECUTABLE,\n        EDITABLE_IN_KACTUS,\n        COLUMN_COUNT\n    };\n}\n\n#endif //FILE_TYPE_COLUMNS_H"
  },
  {
    "path": "settings/FileTypeSettingsPage.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: FileTypeSettingsPage.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Joni-Matti Maatta\r\n// Date: 13.6.2011\r\n//\r\n// Description:\r\n// General settings property page.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"FileTypeSettingsPage.h\"\r\n\r\n#include \"FileTypesDelegate.h\"\r\n\r\n#include <QFormLayout>\r\n#include <QGroupBox>\r\n#include <QLabel>\r\n#include <QSizePolicy>\r\n#include <QVBoxLayout>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileTypeSettingsPage::FileTypeSettingsPage()\r\n//-----------------------------------------------------------------------------\r\nFileTypeSettingsPage::FileTypeSettingsPage(QSettings& settings):\r\nSettingsPage(settings),\r\n    model_(settings, this),\r\n    proxyModel_(this),\r\n    view_(this),\r\n    ignoredExtensionsEdit_(this)\r\n{\r\n    proxyModel_.setSourceModel(&model_);\r\n\r\n    view_.setItemDelegate(new FileTypesDelegate(this));\r\n    view_.setModel(&proxyModel_);\r\n    view_.setSortingEnabled(true);\r\n    view_.sortByColumn(0, Qt::AscendingOrder);\r\n\r\n    ignoredExtensionsEdit_.setText(settings.value(\"FileTypes/IgnoredExtensions\").toString());\r\n    ignoredExtensionsEdit_.setToolTip(\r\n        tr(\"Specify all file extensions that should be ignored in file dependency analysis. \"\r\n        \"Multiple values can be given separated by a semi-colon e.g. \\\"jpg;png\\\".\"));\r\n\r\n    QGroupBox* typesBox = new QGroupBox(tr(\"File types\"), this);\r\n    QVBoxLayout* typeLayout = new QVBoxLayout(typesBox);\r\n    typeLayout->addWidget(&view_, 1);\r\n\r\n    QFormLayout* ignoreTypeLayout = new QFormLayout();\r\n    ignoreTypeLayout->addRow(tr(\"Ignored extensions:\"), &ignoredExtensionsEdit_);\r\n\r\n    QVBoxLayout* topLayout = new QVBoxLayout(this);\r\n    topLayout->addWidget(typesBox);\r\n    topLayout->addLayout(ignoreTypeLayout);\r\n\r\n    connect(&view_, SIGNAL(addItem(const QModelIndex&)),\r\n            &model_, SLOT(onAddItem(const QModelIndex&)), Qt::UniqueConnection);\r\n    connect(&view_, SIGNAL(removeItem(const QModelIndex&)),\r\n            &model_, SLOT(onRemoveItem(const QModelIndex&)), Qt::UniqueConnection);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileTypeSettingsPage::apply()\r\n//-----------------------------------------------------------------------------\r\nvoid FileTypeSettingsPage::apply()\r\n{\r\n    model_.apply(settings());\r\n    settings().setValue(\"FileTypes/IgnoredExtensions\", ignoredExtensionsEdit_.text());\r\n}\r\n"
  },
  {
    "path": "settings/FileTypeSettingsPage.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: FileTypeSettingsPage.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Joni-Matti Maatta\r\n// Date: 20.2.2012\r\n//\r\n// Description:\r\n// File type settings property page.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef FILETYPESETTINGSPAGE_H\r\n#define FILETYPESETTINGSPAGE_H\r\n\r\n#include \"FileTypesModel.h\"\r\n\r\n#include \"SettingsPage.h\"\r\n#include \"filetypesview.h\"\r\n\r\n#include <QLineEdit>\r\n#include <QSettings>\r\n#include <QSortFilterProxyModel>\r\n\r\n//-----------------------------------------------------------------------------\r\n//! FileTypeSettingsPage class.\r\n//-----------------------------------------------------------------------------\r\nclass FileTypeSettingsPage : public SettingsPage\r\n{\r\n    Q_OBJECT\r\n\r\npublic:\r\n    /*!\r\n     *  Constructor.\r\n     *\r\n     *    @param [in/out] settings The settings store.\r\n     */\r\n    FileTypeSettingsPage(QSettings& settings);\r\n\r\n    /*!\r\n     *  Destructor.\r\n     */\r\n    virtual ~FileTypeSettingsPage() = default;\r\n\r\n    // Disable copying.\r\n    FileTypeSettingsPage(FileTypeSettingsPage const& rhs) = delete;\r\n    FileTypeSettingsPage& operator=(FileTypeSettingsPage const& rhs) = delete;\r\n\r\n    /*!\r\n     *  Applies the changes that were done in the page.\r\n     */\r\n    virtual void apply() override final;\r\n\r\nprivate:\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! The file types data model.\r\n    FileTypesModel model_;\r\n\r\n    //! Proxy model for sorting.\r\n    QSortFilterProxyModel proxyModel_;\r\n\r\n    //! The table view for file types.\r\n    FileTypesView view_;\r\n\r\n    //! Line edit for ignored extensions.\r\n    QLineEdit ignoredExtensionsEdit_;\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n\r\n#endif // FILETYPESETTINGSPAGE_H\r\n"
  },
  {
    "path": "settings/FileTypesDelegate.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: FileTypesDelegate.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Joni-Matti Maatta\r\n// Date: 20.02.2013\r\n//\r\n// Description:\r\n// Delegate which provides widgets for the file types settings view.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"FileTypesDelegate.h\"\r\n\r\n#include \"FileTypeColumns.h\"\r\n\r\n#include <IPXACTmodels/common/FileType.h>\r\n\r\n#include <QComboBox>\r\n#include <QLineEdit>\r\n#include <QStringList>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileTypesDelegate::FileTypesDelegate()\r\n//-----------------------------------------------------------------------------\r\nFileTypesDelegate::FileTypesDelegate(QObject* parent): \r\n    QStyledItemDelegate(parent)\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileTypesDelegate::createEditor()\r\n//-----------------------------------------------------------------------------\r\nQWidget* FileTypesDelegate::createEditor(QWidget* parent, QStyleOptionViewItem const& option, QModelIndex const& index) const\r\n{\r\n    if (index.column() == FileTypeColumns::NAME)\r\n    {\r\n        QComboBox* combo = new QComboBox(parent);\r\n\r\n        // Get all file types that have been defined already.\r\n        QStringList usedTypes = index.model()->data(index, Qt::UserRole).toStringList();\r\n        usedTypes.append(FileTypes::FILE_TYPES);\r\n        usedTypes.append(FileTypes::FILE_TYPES_2022);\r\n        usedTypes.removeDuplicates();\r\n\r\n        combo->addItems(usedTypes);\r\n        combo->setEditable(true);\r\n        return combo;\r\n    }\r\n\r\n    else if (index.column() == FileTypeColumns::EXTENSIONS)\r\n    {\r\n        QLineEdit* line = new QLineEdit(parent);\r\n        return line;\r\n    }\r\n\r\n    return QStyledItemDelegate::createEditor(parent, option, index);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileTypesDelegate::setEditorData()\r\n//-----------------------------------------------------------------------------\r\nvoid FileTypesDelegate::setEditorData(QWidget* editor, const QModelIndex& index) const\r\n{\r\n    if (index.column() == FileTypeColumns::NAME)\r\n    {\r\n        QComboBox* combo = qobject_cast<QComboBox*>(editor);\r\n        Q_ASSERT_X(combo, \"FileTypesDelegate::setEditorData\", \"Type conversion failed for QComboBox\");\r\n\r\n        QString text = index.model()->data(index, Qt::DisplayRole).toString();\r\n        combo->setEditText(text);\r\n    }\r\n\r\n    else if (index.column() == FileTypeColumns::EXTENSIONS)\r\n    {\r\n        QLineEdit* line = qobject_cast<QLineEdit*>(editor);\r\n        Q_ASSERT_X(line, \"FileTypesDelegate::setEditorData\", \"Type conversion failed for QLineEdit\");\r\n\r\n        QString text = index.model()->data(index, Qt::DisplayRole).toString();\r\n        line->setText(text);\r\n    }\r\n\r\n    else\r\n    {\r\n        QStyledItemDelegate::setEditorData(editor, index);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileTypesDelegate::setModelData()\r\n//-----------------------------------------------------------------------------\r\nvoid FileTypesDelegate::setModelData(QWidget* editor, QAbstractItemModel* model, QModelIndex const& index) const\r\n{\r\n    if (index.column() == FileTypeColumns::NAME)\r\n    {\r\n        QComboBox* combo = qobject_cast<QComboBox*>(editor);\r\n        Q_ASSERT_X(combo, \"FileTypesDelegate::setEditorData\", \"Type conversion failed for QComboBox\");\r\n\r\n        QString text = combo->currentText();\r\n        model->setData(index, text, Qt::EditRole);\r\n    }\r\n\r\n    else if (index.column() == FileTypeColumns::EXTENSIONS)\r\n    {\r\n        QLineEdit* line = qobject_cast<QLineEdit*>(editor);\r\n        Q_ASSERT_X(line, \"FileTypesDelegate::setEditorData\", \"Type conversion failed for QLineEdit\");\r\n\r\n        QString text = line->text();\r\n        model->setData(index, text, Qt::EditRole);\r\n    }\r\n\r\n    else\r\n    {\r\n        QStyledItemDelegate::setModelData(editor, model, index);\r\n    }\r\n}\r\n"
  },
  {
    "path": "settings/FileTypesDelegate.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: FileTypesDelegate.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Joni-Matti Maatta\r\n// Date: 20.02.2013\r\n//\r\n// Description:\r\n// Delegate which provides widgets for the file types settings view.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef FILETYPESDELEGATE_H\r\n#define FILETYPESDELEGATE_H\r\n\r\n#include <QStyledItemDelegate>\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Delegate which provides widgets for the file types settings view.\r\n//-----------------------------------------------------------------------------\r\nclass FileTypesDelegate : public QStyledItemDelegate\r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\t/*!\r\n\t *  Constructor.\r\n     *\r\n\t *    @param [in] revision\tThe applied IP-XACT standard.\r\n\t *    @param [in] parent\t\tPointer to the owner of this instance.\r\n\t */\r\n\tFileTypesDelegate(QObject* parent = nullptr);\r\n\t\r\n\t/*!\r\n     *  Destructor.\r\n     */\r\n\tvirtual ~FileTypesDelegate() = default;\r\n\r\n\t// Disable copying.\r\n\tFileTypesDelegate(FileTypesDelegate const& rhs) = delete;\r\n\tFileTypesDelegate& operator=(FileTypesDelegate const& rhs) = delete;\r\n\r\n\t/*!\r\n     *  Creates a new editor for the given item.\r\n\t *\r\n\t *    @param [in] parent  Owner for the editor.\r\n\t *    @param [in] option  Contains options for the editor.\r\n\t *    @param [in] index   Model index identifying the item.\r\n\t *\r\n\t *    @return The editor to be used to edit the item.\r\n\t */\r\n\tvirtual QWidget* createEditor(QWidget* parent, QStyleOptionViewItem const& option, \r\n\t\t                          QModelIndex const& index) const;\r\n\r\n\t/*!\r\n     *  Sets the data for the editor.\r\n\t *\r\n\t *    @param [in] editor  Pointer to the editor where the data is to be set.\r\n\t *    @param [in] index   Model index identifying the item that's data is to be set.\r\n\t */\r\n\tvirtual void setEditorData(QWidget* editor, const QModelIndex& index) const;\r\n\r\n\t/*!\r\n     *  Saves the data from the editor to the model.\r\n\t *\r\n\t *    @param [in] editor  Pointer to the editor that contains the data to store.\r\n\t *    @param [in] model   Model that contains the data structure where data is to be saved to.\r\n\t *    @param [in] index   Model index identifying the item that's data is to be saved.\r\n\t *\r\n\t */\r\n\tvirtual void setModelData(QWidget* editor, QAbstractItemModel* model, \r\n\t\t                      QModelIndex const& index) const;\r\n\r\n};\r\n\r\n#endif // FILETYPESDELEGATE_H\r\n"
  },
  {
    "path": "settings/FileTypesModel.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: FileTypesModel.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Joni-Matti Maatta\r\n// Date: 20.02.2013\r\n//\r\n// Description:\r\n// Model for file types data.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"FileTypesModel.h\"\r\n#include \"FileTypeColumns.h\"\r\n\r\n#include <QStringList>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileTypesModel::FileTypesModel()\r\n//-----------------------------------------------------------------------------\r\nFileTypesModel::FileTypesModel(QSettings& settings, QObject *parent): QAbstractTableModel(parent)\r\n{\r\n    // Parse existing file types from settings.\r\n    beginResetModel();\r\n    settings.beginGroup(\"FileTypes\");\r\n\r\n    for (QString const& typeName : settings.childGroups())\r\n    {\r\n        settings.beginGroup(typeName);\r\n        FileTypeEntry entry;\r\n\t\tentry.name = typeName;\r\n\t\tentry.editInKactus = settings.value(\"EditInKactus\").toBool();\r\n        entry.extensions = settings.value(\"Extensions\").toString();\r\n\t\tentry.executable = settings.value(\"Executable\").toString();\r\n\r\n        entries_.append(entry);\r\n        settings.endGroup();\r\n    }\r\n\r\n    settings.endGroup();\r\n    endResetModel();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileTypesModel::rowCount()\r\n//-----------------------------------------------------------------------------\r\nint FileTypesModel::rowCount(QModelIndex const& parent) const\r\n{\r\n    if (parent.isValid())\r\n    {\r\n        return 0;\r\n    }\r\n\r\n    return entries_.size();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileTypesModel::columnCount()\r\n//-----------------------------------------------------------------------------\r\nint FileTypesModel::columnCount(QModelIndex const& parent) const\r\n{\r\n    if (parent.isValid())\r\n    {\r\n        return 0;\r\n    }\r\n\r\n    return FileTypeColumns::COLUMN_COUNT;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileTypesModel::data()\r\n//-----------------------------------------------------------------------------\r\nQVariant FileTypesModel::data(QModelIndex const& index, int role) const\r\n{\r\n    // Check for invalid index.\r\n    if (!index.isValid() || index.row() < 0 || index.row() >= entries_.size())\r\n    {\r\n        return QVariant();\r\n    }\r\n\r\n    if (role == Qt::DisplayRole || role == Qt::EditRole)\r\n    {\r\n        FileTypeEntry const& entry = entries_.at(index.row());\r\n\r\n        if (index.column() == FileTypeColumns::NAME)\r\n        {\r\n            return entry.name;\r\n        }\r\n        else if (index.column() == FileTypeColumns::EDITABLE_IN_KACTUS)\r\n        {\r\n            return entry.editInKactus;\r\n        }\r\n        else if (index.column() == FileTypeColumns::EXTENSIONS)\r\n        {\r\n            return entry.extensions;\r\n        }\r\n        else if (index.column() == FileTypeColumns::EXECUTABLE)\r\n        {\r\n            return entry.executable;\r\n        }\r\n        else\r\n        {\r\n            return QVariant();\r\n        }\r\n    }\r\n\r\n\telse if (role == Qt::UserRole)\r\n    {\r\n        QStringList specifiedFileTypes;\r\n        for (FileTypeEntry const& entry : entries_) \r\n        {\r\n            specifiedFileTypes.append(entry.name);\r\n        }\r\n\r\n        return specifiedFileTypes;\r\n\t}\r\n\r\n    return QVariant();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileTypesModel::headerData()\r\n//-----------------------------------------------------------------------------\r\nQVariant FileTypesModel::headerData(int section, Qt::Orientation orientation, int role) const\r\n{\r\n    if (role == Qt::DisplayRole && orientation == Qt::Horizontal)\r\n    {\r\n        if (section == FileTypeColumns::NAME)\r\n        {\r\n            return tr(\"File type\");\r\n        }\r\n        else if (section == FileTypeColumns::EDITABLE_IN_KACTUS)\r\n        {\r\n            return tr(\"Edit in Kactus2\");\r\n        }\r\n        else if (section == FileTypeColumns::EXTENSIONS)\r\n        {\r\n            return tr(\"Extensions\");\r\n        }\r\n        else if (section == FileTypeColumns::EXECUTABLE)\r\n        {\r\n            return tr(\"Execute with\");\r\n        }\r\n        else\r\n        {\r\n            return QVariant();\r\n        }\r\n    }\r\n\r\n    return QVariant();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileTypesModel::setData()\r\n//-----------------------------------------------------------------------------\r\nbool FileTypesModel::setData(const QModelIndex& index, const QVariant& value, int role)\r\n{\r\n    // Check for invalid index.\r\n    if (!index.isValid() || index.row() < 0 || index.row() >= entries_.size())\r\n    {\r\n        return false;\r\n    }\r\n\r\n    if (role == Qt::EditRole)\r\n    {\r\n        if (index.column() == FileTypeColumns::NAME)\r\n        {\r\n            QString name = value.toString();\r\n\r\n            // if the file type has already been defined\r\n            for (const FileTypesModel::FileTypeEntry& entry : entries_)\r\n            {\r\n                if (entry.name.compare(name, Qt::CaseInsensitive) == 0)\r\n                {\r\n                    return false;\r\n                }\r\n            }\r\n\r\n            entries_[index.row()].name = name;\r\n        }\r\n        else if (index.column() == FileTypeColumns::EDITABLE_IN_KACTUS)\r\n        {\r\n            entries_[index.row()].editInKactus = value.toBool();\r\n        }\r\n        else if (index.column() == FileTypeColumns::EXTENSIONS)\r\n        {\r\n            entries_[index.row()].extensions = value.toString();\r\n        }\r\n        else if (index.column() ==  FileTypeColumns::EXECUTABLE)\r\n        {\r\n            entries_[index.row()].executable = value.toString();\r\n        }\r\n        else\r\n        {\r\n            return false;\r\n        }\r\n\r\n        emit dataChanged(index, index);\r\n        return true;\r\n    }\r\n\r\n    return false;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileTypesModel::flags()\r\n//-----------------------------------------------------------------------------\r\nQt::ItemFlags FileTypesModel::flags(QModelIndex const& index) const\r\n{\r\n    if (!index.isValid())\r\n    {\r\n        return Qt::NoItemFlags;\r\n    }\r\n\r\n    return Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsEditable;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileTypesModel::onAddRow()\r\n//-----------------------------------------------------------------------------\r\nvoid FileTypesModel::onAddRow()\r\n{\r\n    beginInsertRows(QModelIndex(), entries_.size(), entries_.size());\r\n    entries_.append(FileTypeEntry());\r\n    endInsertRows();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileTypesModel::onRemoveRow()\r\n//-----------------------------------------------------------------------------\r\nvoid FileTypesModel::onRemoveRow(int row)\r\n{\r\n    // Check if the row is invalid.\r\n    if (row < 0 || row >= entries_.size())\r\n    {\r\n        return;\r\n    }\r\n\r\n    // Remove the entry at the given row.\r\n    beginRemoveRows(QModelIndex(), row, row);\r\n    entries_.removeAt(row);\r\n    endRemoveRows();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileTypesModel::onAddItem()\r\n//-----------------------------------------------------------------------------\r\nvoid FileTypesModel::onAddItem(const QModelIndex& index)\r\n{\r\n    int row = entries_.size();\r\n\r\n    // If the index is valid then add the item to the correct position.\r\n    if (index.isValid())\r\n    {\r\n        row = index.row();\r\n    }\r\n\r\n    // Insert a new empty file type entry.\r\n    beginInsertRows(QModelIndex(), row, row);\r\n    entries_.insert(row, FileTypeEntry());\r\n    endInsertRows();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileTypesModel::onRemoveItem()\r\n//-----------------------------------------------------------------------------\r\nvoid FileTypesModel::onRemoveItem(const QModelIndex& index)\r\n{\r\n    if (!index.isValid())\r\n    {\r\n        return;\r\n    }\r\n\r\n    // Make sure the row number if valid.\r\n    if (index.row() < 0 || index.row() >= entries_.size())\r\n    {\r\n        return;\r\n    }\r\n\r\n    // Remove the entry at the row specified by the index.\r\n    beginRemoveRows(QModelIndex(), index.row(), index.row());\r\n    entries_.removeAt(index.row());\r\n    endRemoveRows();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: FileTypesModel::apply()\r\n//-----------------------------------------------------------------------------\r\nvoid FileTypesModel::apply(QSettings& settings)\r\n{\r\n\t// first clear all previous defined file types to remove duplicates\r\n\tsettings.remove(\"FileTypes\");\r\n\r\n    settings.beginGroup(\"FileTypes\");\r\n    for (FileTypeEntry const& entry : entries_)\r\n    {\r\n\t\tsettings.beginGroup(entry.name);\r\n\t\tsettings.setValue(\"EditInKactus\", entry.editInKactus);\r\n        settings.setValue(\"Extensions\", entry.extensions);\r\n\t\tsettings.setValue(\"Executable\", entry.executable);\r\n        settings.endGroup();\r\n    }\r\n    settings.endGroup();\r\n}\r\n"
  },
  {
    "path": "settings/FileTypesModel.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: FileTypesModel.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Joni-Matti Maatta\r\n// Date: 20.02.2013\r\n//\r\n// Description:\r\n// Model for file types data.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef FILETYPESMODEL_H\r\n#define FILETYPESMODEL_H\r\n\r\n#include <QAbstractTableModel>\r\n#include <QMap>\r\n#include <QList>\r\n#include <QString>\r\n#include <QSettings>\r\n#include <QSharedPointer>\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Data model for the address editor.\r\n//-----------------------------------------------------------------------------\r\nclass FileTypesModel : public QAbstractTableModel\r\n{\r\n    Q_OBJECT\r\n\r\npublic:\r\n\r\n    /*!\r\n     *  Constructor which loads the model from settings.\r\n     *\r\n     *    @param [in] settings  The settings store.\r\n     *    @param [in] parent    The owner of this model.\r\n     *\r\n     */\r\n    FileTypesModel(QSettings& settings, QObject* parent);\r\n    \r\n    /*!\r\n     *  The destructor.\r\n     */\r\n    virtual ~FileTypesModel() = default;\r\n\r\n    // Disable copying.\r\n    FileTypesModel(FileTypesModel const& rhs) = delete;\r\n    FileTypesModel& operator=(FileTypesModel const& rhs) = delete;\r\n\r\n    /*!\r\n     *  Saves the model to settings.\r\n     *\r\n     *    @param [in,out] settings  The settings store.\r\n     */\r\n    void apply(QSettings& settings);\r\n\r\n    /*!\r\n     *  Returns the number of rows to be displayed.\r\n     *\r\n     *    @param [in] parent Identifies the parent. Must always be a invalid index.\r\n     */\r\n    virtual int rowCount(const QModelIndex& parent = QModelIndex()) const;\r\n\r\n    /*!\r\n     *  Returns the number of columns to display.\r\n     *\r\n     *    @param [in] parent Identifies the parent. Must always be a invalid index.\r\n     */\r\n    virtual int columnCount(const QModelIndex& parent = QModelIndex()) const;\r\n\r\n    /*!\r\n     *  Returns that data for specified index in given data role.\r\n     *  \r\n     *  Qt::UserRole returns QStringList containing the file types that are already defined.\r\n     *\r\n     *    @param [in] index  Identifies the object that's data is wanted.\r\n     *    @param [in] role   Identifies the type of data being requested.\r\n     *\r\n     *    @return QVariant containing the requested data.\r\n     */\r\n    virtual QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const;\r\n\r\n    /*!\r\n     *  Returns the data for given header in given data role.\r\n     *\r\n     *    @param [in] section      Identifies the header section.\r\n     *    @param [in] orientation  Only Qt::Horizontal is supported.\r\n     *    @param [in] role         Identifies the type of the data being requested.\r\n     *\r\n     *    @return QVariant contains the requested data.\r\n     */\r\n    virtual QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole ) const;\r\n\r\n    /*!\r\n     *  Sets the data for specified index.\r\n     *\r\n     *    @param [in] index  Identifies the object that's data is to be saved.\r\n     *    @param [in] value  Contains the data to be saved.\r\n     *    @param [in] role   Identifies the type of the data to be saved.\r\n     *\r\n     *    @return True if data was saved successfully.\r\n     */\r\n    virtual bool setData(const QModelIndex& index, const QVariant& value, int role = Qt::EditRole );\r\n\r\n    /*!\r\n     *  Retrieves info on what operations are possible for specified item.\r\n     *\r\n     *    @param [in] index Identifies the item that's operations are requested.\r\n     *\r\n     *    @return Item flags containing info on which operations are available for the given index.\r\n     */\r\n    virtual Qt::ItemFlags flags(const QModelIndex& index) const;\r\n\r\npublic slots:\r\n\t/*!\r\n     *  Adds a new empty row to the model.\r\n\t */\r\n\tvoid onAddRow();\r\n\r\n    /*!\r\n     *  Removes a row from the model.\r\n\t *\r\n\t *    @param [in] row Specifies the row to remove.\r\n\t */\r\n\tvoid onRemoveRow(int row);\r\n\r\n\t/*!\r\n     *  Called when a new item should be added to given index.\r\n\t *\r\n\t *    @param [in] index The position where new item should be added at.\r\n\t */\r\n\tvoid onAddItem(const QModelIndex& index);\r\n\r\n\t/*! \r\n     *  An item should be removed from the model.\r\n\t * \r\n\t *    @param [in] index Identifies the item that should be removed.\r\n\t */\r\n\tvoid onRemoveItem(const QModelIndex& index);\r\n\r\nprivate:\r\n\r\n    //-----------------------------------------------------------------------------\r\n    //! FileTypeEntry structure.\r\n    //-----------------------------------------------------------------------------\r\n    struct FileTypeEntry\r\n    {\r\n\t\tQString name;       //!< The file type name.\r\n\t\tbool editInKactus;\t//!< True, if edited in Kactus rather than some other application.\r\n        QString extensions; //!< The extensions for this file type.\r\n        QString executable; //!< The executable to run this file type.\r\n\r\n        /*!\r\n         *  Default constructor.\r\n         */\r\n        FileTypeEntry() : name(), editInKactus(false), extensions(), executable()\r\n        {\r\n        }\r\n    };\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! The file type entries.\r\n    QList<FileTypeEntry> entries_;\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n\r\n#endif // FILETYPESMODEL_H\r\n"
  },
  {
    "path": "settings/GeneralSettingsPage.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: GeneralSettingsPage.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Joni-Matti Maatta\r\n// Date: 13.6.2011\r\n//\r\n// Description:\r\n// General settings property page.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"GeneralSettingsPage.h\"\r\n\r\n#include <KactusAPI/include/utils.h>\r\n\r\n#include <IPXACTmodels/common/Document.h>\r\n\r\n#include <QCoreApplication>\r\n#include <QFormLayout>\r\n#include <QLabel>\r\n#include <QMessageBox>\r\n#include <QSettings>\r\n#include <QCheckBox>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: GeneralSettingsPage()\r\n//-----------------------------------------------------------------------------\r\nGeneralSettingsPage::GeneralSettingsPage(QSettings& settings):\r\nSettingsPage(settings),\r\nusernameEdit_(new QLineEdit(this)),\r\nrevisionEdit_(new QComboBox(this)),\r\nlockEnabledBox_(new QCheckBox(this))\r\n{\r\n    QString username = settings.value(\"General/Username\", Utils::getCurrentUser()).toString();\r\n    usernameEdit_->setText(username);\r\n\r\n    revisionEdit_->addItem(Document::toString(Document::Revision::Std22));\r\n    revisionEdit_->addItem(Document::toString(Document::Revision::Std14));\r\n\r\n    auto defaultRevision = settings.value(\"General/Revision\", Document::toString(Document::Revision::Std22)).toString();\r\n    revisionEdit_->setCurrentText(defaultRevision);\r\n\r\n    bool lockEnabled = settings.value(\"General/EnableLocking\", false).toBool();\r\n    lockEnabledBox_->setChecked(lockEnabled);\r\n\r\n    // Setup the layout.\r\n    auto layout = new QFormLayout(this);\r\n    layout->addRow(tr(\"Settings file:\"), new QLabel(settings.fileName(), this));\r\n    layout->addRow(tr(\"User name:\"), usernameEdit_);\r\n    layout->addRow(tr(\"Default IP-XACT version:\"), revisionEdit_);\r\n    layout->addRow(tr(\"Enable editor locking:\"), lockEnabledBox_);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: validate()\r\n//-----------------------------------------------------------------------------\r\nbool GeneralSettingsPage::validate()\r\n{\r\n    Q_ASSERT(prevalidate());\r\n\r\n    // Check for a valid username.\r\n    if (usernameEdit_->text().isEmpty())\r\n    {\r\n        QMessageBox msgBox(QMessageBox::Warning, QCoreApplication::applicationName(),\r\n                           tr(\"The user name must be set.\"), QMessageBox::Ok, this);\r\n        msgBox.exec();\r\n        return false;\r\n    }\r\n\r\n    return true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: apply()\r\n//-----------------------------------------------------------------------------\r\nvoid GeneralSettingsPage::apply()\r\n{\r\n    // Save the settings.\r\n    settings().setValue(\"General/Username\", usernameEdit_->text());\r\n    settings().setValue(\"General/Revision\", revisionEdit_->currentText());\r\n    settings().setValue(\"General/EnableLocking\", lockEnabledBox_->isChecked());\r\n}\r\n"
  },
  {
    "path": "settings/GeneralSettingsPage.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: GeneralSettingsPage.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Joni-Matti Maatta\r\n// Date: 13.6.2011\r\n//\r\n// Description:\r\n// General settings property page.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef GENERALSETTINGSPAGE_H\r\n#define GENERALSETTINGSPAGE_H\r\n\r\n#include \"SettingsPage.h\"\r\n\r\n#include <QComboBox>\r\n#include <QLineEdit>\r\n#include <QSettings>\r\n\r\nclass QCheckBox;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! GeneralSettingsPage class.\r\n//-----------------------------------------------------------------------------\r\nclass GeneralSettingsPage : public SettingsPage\r\n{\r\n    Q_OBJECT\r\n\r\npublic:\r\n    /*!\r\n     *  Constructor.\r\n     *\r\n     *    @param [in/out] settings The settings store.\r\n     */\r\n    GeneralSettingsPage(QSettings& settings);\r\n\r\n    /*!\r\n     *  Destructor.\r\n     */\r\n    virtual ~GeneralSettingsPage() = default;\r\n\r\n    // Disable copying.\r\n    GeneralSettingsPage(GeneralSettingsPage const& rhs) = delete;\r\n    GeneralSettingsPage& operator=(GeneralSettingsPage const& rhs) = delete;\r\n\r\n    /*!\r\n     *  Validates the contents of the page thoroughly.\r\n     *\r\n     *    @return True, if the contents are valid. False, if they are invalid.\r\n     *\r\n     *      @remarks Showing message boxes for errors is allowed.\r\n     */\r\n    virtual bool validate() override final;\r\n\r\n    /*!\r\n     *  Applies the changes that were done in the page.\r\n     */\r\n    virtual void apply() override final;\r\n\r\nprivate:\r\n\r\n    //! Username line edit.\r\n    QLineEdit* usernameEdit_;\r\n\r\n    //! Default revision selector.\r\n    QComboBox* revisionEdit_;\r\n\r\n    //! Checkbox for enabling/disabling the editor lock feature.\r\n    QCheckBox* lockEnabledBox_;\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n\r\n#endif // GENERALSETTINGSPAGE_H\r\n"
  },
  {
    "path": "settings/NamingPolicySettingsPage.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: NamingPolicySettingsPage.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Joni-Matti Maatta\r\n// Date: 13.6.2011\r\n//\r\n// Description:\r\n// General settings property page.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"NamingPolicySettingsPage.h\"\r\n\r\n#include <common/widgets/listManager/listmanager.h>\r\n#include <common/widgets/SnippetTextEdit/SnippetTextEdit.h>\r\n\r\n#include <QCoreApplication>\r\n#include <QDir>\r\n#include <QFileDialog>\r\n#include <QFormLayout>\r\n#include <QLabel>\r\n#include <QMessageBox>\r\n#include <QPushButton>\r\n#include <QVBoxLayout>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: NamingPolicySettingsPage()\r\n//-----------------------------------------------------------------------------\r\nNamingPolicySettingsPage::NamingPolicySettingsPage(QSettings& settings):\r\nSettingsPage(settings),\r\n    categories_(),\r\n    curCategoryIndex_(-1),\r\n    categoryCombo_(new QComboBox(this)),\r\n    valuesList_(new ListManager(tr(\"Suggested values\"), this)),\r\n    formatGroup_(new QGroupBox(tr(\"Format\"), this)),\r\n    formatEdit_(new SnippetTextEdit(this))\r\n{\r\n    // Add categories.\r\n    categories_.append(PolicyCategory(\"Policies/InstanceNames\", \"Component Instance Names\", POLICY_FORMAT));\r\n    categories_.back().magicWords.append(\"ComponentName\");\r\n    categories_.back().magicWords.append(\"InstanceNumber\");\r\n\r\n    categories_.append(PolicyCategory(\"Policies/HWViewNames\", \"HW View Names\", POLICY_ENUMERATION));\r\n    categories_.append(PolicyCategory(\"Policies/SWViewNames\", \"SW View Names\", POLICY_ENUMERATION));\r\n    categories_.append(PolicyCategory(\"Policies/SysViewNames\", \"System View Names\", POLICY_ENUMERATION));\r\n\r\n    QVBoxLayout* formatLayout = new QVBoxLayout(formatGroup_);\r\n    formatLayout->addWidget(formatEdit_);\r\n\r\n    // Setup the layout.\r\n    QFormLayout* policyLayout = new QFormLayout();\r\n    policyLayout->addRow(tr(\"Naming policy:\"), categoryCombo_);\r\n\r\n    QVBoxLayout* topLayout = new QVBoxLayout(this);\r\n    topLayout->addLayout(policyLayout);\r\n    topLayout->addWidget(valuesList_);\r\n    topLayout->addWidget(formatGroup_);\r\n    topLayout->addStretch(1);\r\n\r\n    // Setup connections.\r\n    connect(categoryCombo_, SIGNAL(currentIndexChanged(int)), \r\n        this, SLOT(onCategoryChanged(int)), Qt::UniqueConnection);\r\n\r\n    // Read current values from settings and fill in the combo box.\r\n    for (int i = 0; i < categories_.size(); ++i)\r\n    {\r\n        PolicyCategory& category = categories_[i];\r\n        category.values = settings.value(category.key).toStringList();\r\n        categoryCombo_->addItem(category.name);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: apply()\r\n//-----------------------------------------------------------------------------\r\nvoid NamingPolicySettingsPage::apply()\r\n{\r\n    saveCurrentValues();\r\n\r\n    foreach (PolicyCategory const& category, categories_)\r\n    {\r\n        settings().setValue(category.key, category.values);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: NamingPolicySettingsPage::onCategoryChanged()\r\n//-----------------------------------------------------------------------------\r\nvoid NamingPolicySettingsPage::onCategoryChanged(int index)\r\n{\r\n    // Save the values of the previously selected category.\r\n    saveCurrentValues();\r\n\r\n    // Update the widgets based on the category type and content.\r\n    if (categories_.at(index).type == POLICY_ENUMERATION)\r\n    {\r\n        valuesList_->initialize(categories_.at(index).values);\r\n\r\n        formatGroup_->setVisible(false);\r\n        valuesList_->setVisible(true);\r\n    }\r\n    else\r\n    {\r\n        formatEdit_->clearMagicWords();\r\n        formatEdit_->addMagicWords(categories_.at(index).magicWords);\r\n\r\n        if (categories_.at(index).values.isEmpty())\r\n        {\r\n            formatEdit_->clear();\r\n        }\r\n        else\r\n        {\r\n            formatEdit_->setPlainText(categories_.at(index).values.first());\r\n        }\r\n\r\n        formatGroup_->setVisible(true);\r\n        valuesList_->setVisible(false);\r\n    }\r\n\r\n    curCategoryIndex_ = index;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: NamingPolicySettingsPage::saveCurrentValues()\r\n//-----------------------------------------------------------------------------\r\nvoid NamingPolicySettingsPage::saveCurrentValues()\r\n{\r\n    if (curCategoryIndex_ != -1)\r\n    {\r\n        if (categories_.at(curCategoryIndex_).type == POLICY_ENUMERATION)\r\n        {\r\n            categories_[curCategoryIndex_].values = valuesList_->items();\r\n        }\r\n        else\r\n        {\r\n            categories_[curCategoryIndex_].values = QStringList(formatEdit_->toPlainText());\r\n        }\r\n    }\r\n}\r\n"
  },
  {
    "path": "settings/NamingPolicySettingsPage.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: NamingPolicySettingsPage.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Joni-Matti Maatta\r\n// Date: 13.6.2011\r\n//\r\n// Description:\r\n// settings property page for specifying naming policies.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef NAMINGPOLICYSETTINGSPAGE_H\r\n#define NAMINGPOLICYSETTINGSPAGE_H\r\n\r\n#include \"SettingsPage.h\"\r\n\r\n#include <QComboBox>\r\n#include <QLabel>\r\n#include <QSettings>\r\n#include <QPlainTextEdit>\r\n#include <QGroupBox>\r\n\r\nclass ListManager;\r\nclass SnippetTextEdit;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! NamingPolicySettingsPage class.\r\n//-----------------------------------------------------------------------------\r\nclass NamingPolicySettingsPage : public SettingsPage\r\n{\r\n    Q_OBJECT\r\n\r\npublic:\r\n    /*!\r\n     *  Constructor.\r\n     *\r\n     *    @param [in/out] settings The settings store.\r\n     */\r\n    NamingPolicySettingsPage(QSettings& settings);\r\n\r\n    /*!\r\n     *  Destructor.\r\n     */\r\n    virtual ~NamingPolicySettingsPage() = default;\r\n\r\n    // Disable copying.\r\n    NamingPolicySettingsPage(NamingPolicySettingsPage const& rhs) = delete;\r\n    NamingPolicySettingsPage& operator=(NamingPolicySettingsPage const& rhs) = delete;\r\n\r\n    /*!\r\n     *  Applies the changes that were done in the page.\r\n     */\r\n    virtual void apply() override final;\r\n\r\nprivate slots:\r\n    /*!\r\n     *  Updates the widget contents according to the new category selection.\r\n     *\r\n     *    @param [in] index The category index.\r\n     */\r\n    void onCategoryChanged(int index);\r\n\r\n    /*!\r\n     *  Saves the values of the currently selected category.\r\n     */\r\n    void saveCurrentValues();\r\n\r\nprivate:\r\n\r\n    //-----------------------------------------------------------------------------\r\n    //! Policy type enumeration.\r\n    //-----------------------------------------------------------------------------\r\n    enum PolicyType\r\n    {\r\n        POLICY_ENUMERATION = 0,\r\n        POLICY_FORMAT\r\n    };\r\n\r\n    //-----------------------------------------------------------------------------\r\n    //! Policy category structure.\r\n    //-----------------------------------------------------------------------------\r\n    struct PolicyCategory\r\n    {\r\n        QString key;            //!< The name of the settings key.\r\n        QString name;           //!< The name of the policy category.\r\n        PolicyType type;        //!< The policy type for the category.\r\n        QStringList values;     //!< The allowed value(s) for the policy.\r\n        QStringList magicWords; //!< Available magic words. Only relevant if policy type is POLICY_FORMAT.\r\n\r\n        /*!\r\n         *  Constructor.\r\n         */\r\n        explicit PolicyCategory(QString const& key, QString const& name, PolicyType type)\r\n            : key(key),\r\n              name(name),\r\n              type(type),\r\n              values()\r\n        {\r\n        }\r\n    };\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! Policy categories data.\r\n    QList<PolicyCategory> categories_;\r\n\r\n    //! The index of the currently selected category.\r\n    int curCategoryIndex_;\r\n\r\n    //! Element selection combo box.\r\n    QComboBox* categoryCombo_;\r\n\r\n    //! Label for suggested names.\r\n    QLabel* valuesLabel_;\r\n\r\n    //! Suggested names list edit.\r\n    ListManager* valuesList_;\r\n\r\n    //! Label for naming format edit.\r\n    QGroupBox* formatGroup_;\r\n\r\n    //! Text box for naming format.\r\n    SnippetTextEdit* formatEdit_;\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n\r\n#endif // NAMINGPOLICYSETTINGSPAGE_H\r\n"
  },
  {
    "path": "settings/NewPluginsDialog.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: NewPluginsDialog.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Esko Pekkarinen\r\n// Date: 14.1.2014\r\n//\r\n// Description:\r\n// Dialog for displaying new plugins.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"NewPluginsDialog.h\"\r\n\r\n\r\n#include <KactusAPI/include/IPlugin.h>\r\n#include <KactusAPI/include/IGeneratorPlugin.h>\r\n#include <KactusAPI/include/ISourceAnalyzerPlugin.h>\r\n#include <KactusAPI/include/ImportPlugin.h>\r\n\r\n#include \"PluginInfoWidget.h\"\r\n\r\n#include <QPushButton>\r\n#include <QVBoxLayout>\r\n\r\nnamespace\r\n{   \r\n    enum Roles\r\n    {\r\n        PLUGIN_POINTER_ROLE = Qt::UserRole, //<! Pointer to the plugin.\r\n        PLUGIN_STACK_INDEX_ROLE             //<! Index of the plugin in detail stack.\r\n    };\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: NewPluginsDialog::NewPluginsDialog()\r\n//-----------------------------------------------------------------------------\r\nNewPluginsDialog::NewPluginsDialog(QWidget* parent)\r\n    : QDialog(parent),\r\n      pluginsList_(this),\r\n      detailsStack_(this),\r\n      buttonBox_(QDialogButtonBox::Ok, Qt::Horizontal, this)\r\n{\r\n    setWindowTitle(tr(\"New plugins found\"));    \r\n\r\n    connect(buttonBox_.button(QDialogButtonBox::Ok), SIGNAL(clicked()),\r\n            this, SLOT(accept()), Qt::UniqueConnection);\r\n    connect(buttonBox_.button(QDialogButtonBox::Cancel), SIGNAL(clicked()),\r\n        this, SLOT(reject()), Qt::UniqueConnection);\r\n    connect(&pluginsList_, SIGNAL(currentItemChanged(QListWidgetItem*, QListWidgetItem*)),\r\n            this, SLOT(selectionChanged()), Qt::UniqueConnection);\r\n\r\n    setupLayout();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: NewPluginsDialog::selectionChanged()\r\n//-----------------------------------------------------------------------------\r\nvoid NewPluginsDialog::selectionChanged()\r\n{\r\n    int index = pluginsList_.currentItem()->data(PLUGIN_STACK_INDEX_ROLE).value<int>();\r\n    detailsStack_.setCurrentIndex(index);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: NewPluginsDialog::addPlugin()\r\n//-----------------------------------------------------------------------------\r\nvoid NewPluginsDialog::addPlugin(IPlugin* plugin)\r\n{\r\n    QListWidgetItem* item = new QListWidgetItem(plugin->getName() + \" (\" + plugin->getVersion() + \")\");\r\n    item->setData(PLUGIN_POINTER_ROLE, QVariant::fromValue(static_cast<void*>(plugin)));\r\n    item->setData(PLUGIN_STACK_INDEX_ROLE, detailsStack_.count());\r\n\r\n    // Set icon for plugin.\r\n    IGeneratorPlugin* generator = dynamic_cast<IGeneratorPlugin*>(plugin);\r\n    if (generator != 0)\r\n    {\r\n        item->setIcon(generator->getIcon());\r\n    }\r\n    else if(dynamic_cast<ISourceAnalyzerPlugin*>(plugin) != 0)\r\n    {\r\n        item->setIcon(QIcon(\":icons/common/graphics/plugin-source_analyzer.png\"));\r\n    }\r\n    else if(dynamic_cast<ImportPlugin*>(plugin) != 0)\r\n    {\r\n        item->setIcon(QIcon(\":icons/common/graphics/import.png\"));\r\n    }\r\n\r\n    pluginsList_.addItem(item);    \r\n    detailsStack_.addWidget(new PluginInfoWidget(plugin));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: NewPluginsDialog::addPlugin()\r\n//-----------------------------------------------------------------------------\r\nvoid NewPluginsDialog::addPlugins(QList<IPlugin*> plugins)\r\n{\r\n    foreach(IPlugin* plugin, plugins)\r\n    {\r\n        addPlugin(plugin);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: NewPluginsDialog::setupLayout()\r\n//-----------------------------------------------------------------------------\r\nvoid NewPluginsDialog::setupLayout()\r\n{\r\n    resize(400, 300);        \r\n    \r\n    QVBoxLayout* layout = new QVBoxLayout(this);\r\n    layout->addWidget(&pluginsList_, 1);\r\n    layout->addWidget(&detailsStack_);\r\n    layout->addWidget(&buttonBox_, 0, Qt::AlignHCenter);    \r\n}\r\n\r\n"
  },
  {
    "path": "settings/NewPluginsDialog.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: NewPluginsDialog.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Esko Pekkarinen\r\n// Date: 14.1.2014\r\n//\r\n// Description:\r\n// Dialog for displaying new plugins.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef NEWPLUGINSDIALOG_H\r\n#define NEWPLUGINSDIALOG_H\r\n\r\n#include <QListWidget>\r\n#include <QDialog>\r\n#include <QStackedWidget>\r\n#include <QDialogButtonBox>\r\n\r\nclass PluginManager;\r\nclass IPlugin;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Plugin list dialog.\r\n//-----------------------------------------------------------------------------\r\nclass NewPluginsDialog : public QDialog\r\n{\r\n    Q_OBJECT\r\n\r\npublic:\r\n    /*!\r\n     *  Constructor.\r\n     *\r\n     *    @param [in] parent     The parent widget.\r\n     */\r\n    NewPluginsDialog(QWidget* parent);\r\n\r\n    /*!\r\n     *  Destructor.\r\n     */\r\n    virtual ~NewPluginsDialog() = default;\r\n\r\n    //! Disable copying.\r\n    NewPluginsDialog(NewPluginsDialog const& rhs) = delete;\r\n    NewPluginsDialog& operator=(NewPluginsDialog const& rhs) = delete;\r\n\r\n    /*!\r\n     *  Adds a plugin to the plugin list.\r\n     *\r\n     *    @param [in] plugin The plugin to add.\r\n     */\r\n    void addPlugin(IPlugin* plugin);\r\n\r\n    /*!\r\n     *  Adds plugins to the plugin list.\r\n     *\r\n     *    @param [in] plugins The plugins to add.\r\n     */\r\n    void addPlugins(QList<IPlugin*> plugins);\r\n\r\nprivate slots:\r\n\r\n    //! Called when the plugin selection has changed.\r\n    void selectionChanged();\r\n\r\nprivate:\r\n    //! Sets the widget layout.\r\n    void setupLayout();\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! Plugins list widget.\r\n    QListWidget pluginsList_;\r\n\r\n    //! Stack for displaying information of the selected plugin.\r\n    QStackedWidget detailsStack_;\r\n\r\n    //! Button box.\r\n    QDialogButtonBox buttonBox_;\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n\r\n#endif // NEWPLUGINSDIALOG_H\r\n"
  },
  {
    "path": "settings/PluginInfoWidget.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: PluginInfoWidget.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Esko Pekkarinen\r\n// Date: 13.1.2014\r\n//\r\n// Description:\r\n// Widget for displaying plugin information.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"PluginInfoWidget.h\"\r\n\r\n#include <QFormLayout>\r\n#include <QLabel>\r\n#include <QGridLayout>\r\n#include <QGroupBox>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PluginInfoWidget::PluginInfoWidget()\r\n//-----------------------------------------------------------------------------\r\nPluginInfoWidget::PluginInfoWidget(IPlugin* plugin, QWidget *parent) : \r\nQWidget(parent),\r\nplugin_(plugin)\r\n{\r\n    setupLayout();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PluginInfoWidget::setupLayout()\r\n//-----------------------------------------------------------------------------\r\nvoid PluginInfoWidget::setupLayout()\r\n{\r\n    auto masterLayout(new QVBoxLayout(this));\r\n\r\n    if (plugin_)\r\n    {\r\n        auto topLayout(new QFormLayout());\r\n        topLayout->addRow(tr(\"Name:\"), new QLabel(plugin_->getName(), this));    \r\n        topLayout->addRow(tr(\"Version:\"), new QLabel(plugin_->getVersion(), this));\r\n        topLayout->addRow(tr(\"Vendor:\"), new QLabel(plugin_->getVendor(), this));\r\n        topLayout->addRow(tr(\"Licensed to:\"), new QLabel(plugin_->getLicenseHolder(), this));\r\n        topLayout->addRow(tr(\"License:\"), new QLabel(plugin_->getLicense(), this));\r\n\r\n        QLabel* descriptionLabel = new QLabel(plugin_->getDescription(), this);\r\n        descriptionLabel->setWordWrap(true); \r\n        topLayout->addRow(tr(\"Description:\"), descriptionLabel);\r\n\r\n        masterLayout->addLayout(topLayout);\r\n\r\n\t\tQWidget* settingsWidget = plugin_->getSettingsWidget();\r\n        if (settingsWidget)\r\n        {\r\n            settingsWidget->setParent(this);\r\n\r\n            settingsWidget->setContentsMargins(0, 0, 0, 0);\r\n\r\n\t\t\tauto groupLayout(new QVBoxLayout());\r\n            groupLayout->addWidget(settingsWidget);\r\n            \r\n\t\t\tauto settingsGroup(new QGroupBox(\"Settings\", this));\r\n            settingsGroup->setLayout(groupLayout);\r\n\r\n\t\t\tgroupLayout->setContentsMargins(0, 0, 0, 0);\r\n            settingsGroup->setContentsMargins(0, 0, 0, 0);\r\n\r\n            masterLayout->addWidget(settingsGroup, 2);\r\n        }\r\n        else\r\n        {\r\n            masterLayout->addStretch(2);\r\n        }\r\n    }\r\n}\r\n"
  },
  {
    "path": "settings/PluginInfoWidget.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: PluginInfoWidget.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Esko Pekkarinen\r\n// Date: 13.1.2014\r\n//\r\n// Description:\r\n// Widget for displaying plugin information.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef PLUGININFOWIDGET_H\r\n#define PLUGININFOWIDGET_H\r\n\r\n#include \"IPlugin.h\"\r\n\r\n#include <QWidget>\r\n\r\n//-----------------------------------------------------------------------------\r\n// class PluginInfoWidget.\r\n//-----------------------------------------------------------------------------\r\nclass PluginInfoWidget : public QWidget\r\n{\r\npublic:\r\n    \r\n    /*!\r\n     *  <Description>.\r\n     *\r\n     *    @param [in] plugin   The plugin whose information to display.\r\n     *    @param [in] parent   The parent widget.\r\n     *\r\n     *    @return \r\n     */\r\n    PluginInfoWidget(IPlugin* plugin = nullptr, QWidget *parent = nullptr);\r\n\r\n    //! The destructor.\r\n    virtual ~PluginInfoWidget() = default;\r\n\r\nprivate:\r\n    \r\n    //! Sets the widget layout.\r\n    void setupLayout();\r\n\r\n    //! The plugins whose information is displayed in this widget.\r\n    IPlugin* plugin_;\r\n};\r\n\r\n#endif // PLUGININFOWIDGET_H\r\n"
  },
  {
    "path": "settings/PluginSettingsPage.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: PluginSettingsPage.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Joni-Matti Maatta\r\n// Date: 19.02.2013\r\n//\r\n// Description:\r\n// Settings page for adjusting plugin settings.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"PluginSettingsPage.h\"\r\n\r\n#include <KactusAPI/include/IPlugin.h>\r\n#include <KactusAPI/include/IGeneratorPlugin.h>\r\n#include <KactusAPI/include/ISourceAnalyzerPlugin.h>\r\n#include <KactusAPI/include/ImportPlugin.h>\r\n#include <settings/PluginInfoWidget.h>\r\n#include <settings/NewPluginsDialog.h>\r\n\r\n#include <IPXACTmodels/utilities/XmlUtils.h>\r\n\r\n#include <QApplication>\r\n#include <QVBoxLayout>\r\n#include <QLabel>\r\n#include <QGroupBox>\r\n\r\nnamespace\r\n{   \r\n    //! Enumeration for model roles.\r\n    enum Roles\r\n    {\r\n        PLUGIN_POINTER_ROLE = Qt::UserRole, //<! Pointer to the plugin.\r\n        PLUGIN_STACK_INDEX_ROLE             //<! Index of the plugin in stacks.\r\n    };\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PluginSettingsPage::PluginSettingsPage()\r\n//-----------------------------------------------------------------------------\r\nPluginSettingsPage::PluginSettingsPage(QSettings& settings):\r\nSettingsPage(settings),\r\n    settings_(settings),\r\n    pluginDirSelector_(QApplication::applicationDirPath(), \r\n        settings.value(\"Platform/PluginsPath\", QStringList(\"Plugins\")).toStringList(), this),\r\n    pluginsTree_(this), \r\n    infoStack_(this),\r\n    directoriesChanged_(false)\r\n{\r\n    // Initialize the widgets and create the layout.\r\n    pluginDirSelector_.setPersistentDirectory(\"Plugins\");\r\n    pluginDirSelector_.setPersistentDirectory(\"plugins\");\r\n\r\n    pluginsTree_.setObjectName(\"PluginsTree\");\r\n    QString stylesheet(\"QTreeView#PluginsTree::indicator:unchecked {image: url(:icons/common/graphics/traffic-light_gray.png);}\"\r\n        \"QTreeView#PluginsTree::indicator:checked {image: url(:icons/common/graphics/traffic-light_green.png);}\");\r\n    pluginsTree_.setStyleSheet(stylesheet);\r\n\r\n    pluginsTree_.setHeaderHidden(true);\r\n    pluginsTree_.setColumnCount(1);\r\n    pluginsTree_.setSelectionBehavior(QAbstractItemView::SelectItems);    \r\n\r\n    setupLayout();\r\n\r\n    refreshPluginsTree();\r\n\r\n    connect(&pluginDirSelector_, SIGNAL(contentChanged()),\r\n        this, SLOT(onDirectoriesChanged()), Qt::UniqueConnection);    \r\n\r\n    connect(&pluginsTree_, SIGNAL(currentItemChanged(QTreeWidgetItem*, QTreeWidgetItem*)),\r\n        this, SLOT(onTreeItemChanged(QTreeWidgetItem*, QTreeWidgetItem*)));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PluginSettingsPage::validate()\r\n//-----------------------------------------------------------------------------\r\nbool PluginSettingsPage::validate()\r\n{\r\n    for (int i = 0; i < pluginsTree_.topLevelItemCount(); ++i)\r\n    {\r\n        QTreeWidgetItem* categoryRoot = pluginsTree_.topLevelItem(i);\r\n\r\n        for (int j = 0; j < categoryRoot->childCount(); ++j)\r\n        {\r\n            QTreeWidgetItem* item = categoryRoot->child(j);\r\n\r\n            // Retrieve the plugin pointer from the data.\r\n            IPlugin* plugin = static_cast<IPlugin*>(item->data(0, PLUGIN_POINTER_ROLE).value<void*>());\r\n            Q_ASSERT(plugin != 0);\r\n\r\n            if (plugin->getSettingsModel() &&!plugin->getSettingsModel()->validateSettings())\r\n            {\r\n                return false;\r\n            }\r\n        }\r\n    }\r\n\r\n    return true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PluginSettingsPage::apply()\r\n//-----------------------------------------------------------------------------\r\nvoid PluginSettingsPage::apply()\r\n{\r\n    if (directoriesChanged_ || settings_.value(\"Platform/PluginsPath\").toString().isEmpty())\r\n    {\r\n        // Save the new plugins directories and update plugin manager.\r\n        settings_.setValue(\"Platform/PluginsPath\", pluginDirSelector_.getDirectories());\r\n        PluginManager::getInstance().setPluginPaths(pluginDirSelector_.getDirectories());\r\n    }\r\n\r\n    settings_.beginGroup(\"PluginSettings\");\r\n\r\n    // Save settings and active state for each individual plugin.\r\n    for (int i = 0; i < pluginsTree_.topLevelItemCount(); ++i)\r\n    {\r\n        QTreeWidgetItem* categoryRoot = pluginsTree_.topLevelItem(i);\r\n\r\n        for (int j = 0; j < categoryRoot->childCount(); ++j)\r\n        {\r\n            QTreeWidgetItem* item = categoryRoot->child(j);\r\n\r\n            // Retrieve the plugin pointer from the data.\r\n            IPlugin* plugin = static_cast<IPlugin*>(item->data(0, PLUGIN_POINTER_ROLE).value<void*>());\r\n            Q_ASSERT(plugin != 0);\r\n\r\n            // Save the active state.\r\n            settings_.beginGroup(XmlUtils::removeWhiteSpace(plugin->getName()));\r\n            settings_.setValue(\"Active\", item->checkState(0) == Qt::Checked);\r\n\r\n            if (plugin->getSettingsModel())\r\n            {\r\n                plugin->getSettingsModel()->saveSettings(settings_);\r\n            }\r\n\r\n            settings_.endGroup();\r\n        }\r\n    }\r\n\r\n    settings_.endGroup();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PluginSettingsPage::onTreeItemChanged()\r\n//-----------------------------------------------------------------------------\r\nvoid PluginSettingsPage::onTreeItemChanged(QTreeWidgetItem* current, QTreeWidgetItem* /*prev*/)\r\n{\r\n    int index = 0;\r\n\r\n    if (current != nullptr)\r\n    {\r\n        index = current->data(0, PLUGIN_STACK_INDEX_ROLE).toInt();\r\n    }\r\n\r\n    Q_ASSERT(index < infoStack_.count());\r\n    infoStack_.setCurrentIndex(index);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PluginSettingsPage::createCategoryItem()\r\n//-----------------------------------------------------------------------------\r\nQTreeWidgetItem* PluginSettingsPage::createCategoryItem(QString const& text, QIcon const& icon)\r\n{\r\n    QTreeWidgetItem* item = new QTreeWidgetItem();\r\n    item->setText(0, text);\r\n    item->setIcon(0, icon);\r\n    item->setData(0, PLUGIN_STACK_INDEX_ROLE, 0);\r\n\r\n    // Use bold font for category items.\r\n    QFont rootFont = item->font(0);\r\n    rootFont.setBold(true);\r\n    item->setFont(0, rootFont);\r\n\r\n    pluginsTree_.addTopLevelItem(item);\r\n    return item;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PluginSettingsPage::createItem()\r\n//-----------------------------------------------------------------------------\r\nQTreeWidgetItem* PluginSettingsPage::createPluginItem(IPlugin* plugin)\r\n{\r\n    QTreeWidgetItem* item = new QTreeWidgetItem();\r\n    item->setText(0, plugin->getName() + \" (\" + plugin->getVersion() + \")\");\r\n\r\n    if (settings_.value(\"Active\", true).toBool())\r\n    {\r\n        item->setCheckState(0, Qt::Checked);\r\n    }\r\n    else\r\n    {\r\n        item->setCheckState(0, Qt::Unchecked);\r\n    }\r\n\r\n    item->setData(0, PLUGIN_POINTER_ROLE, QVariant::fromValue(static_cast<void*>(plugin)));\r\n    item->setData(0, PLUGIN_STACK_INDEX_ROLE, infoStack_.count());\r\n\r\n    infoStack_.addWidget(new PluginInfoWidget(plugin));\r\n\r\n    return item;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PluginSettingsPage::onDirectoriesChanged()\r\n//-----------------------------------------------------------------------------\r\nvoid PluginSettingsPage::onDirectoriesChanged()\r\n{\r\n    directoriesChanged_ = true;\r\n    refreshPluginsTree(true);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PluginSettingsPage::refreshPluginsTree()\r\n//-----------------------------------------------------------------------------\r\nvoid PluginSettingsPage::refreshPluginsTree(bool displayChanges)\r\n{\r\n    QApplication::setOverrideCursor(Qt::WaitCursor);\r\n    \r\n    QList<IPlugin*> newPlugins;\r\n    QList<IPlugin*> oldPlugins = PluginManager::getInstance().getAllPlugins();    \r\n    \r\n    resetStacks();\r\n    pluginsTree_.clear();\r\n\r\n    // Create the category items.\r\n    QTreeWidgetItem* generatorsItem = createCategoryItem(tr(\"Generators\"),\r\n        QIcon(\":icons/common/graphics/configuration.png\"));\r\n    QTreeWidgetItem* analyzersItem = createCategoryItem(tr(\"Source Analyzers\"),\r\n        QIcon(\":icons/common/graphics/plugin-source_analyzer.png\"));\r\n    QTreeWidgetItem* importItems = createCategoryItem(tr(\"Import Plugins\"),\r\n        QIcon(\":icons/common/graphics/import.png\"));\r\n\r\n    // Enumerate all plugins and add them to the correct root.\r\n    QList<IPlugin*> plugins = PluginManager::findPluginsInPaths(pluginDirSelector_.getDirectories());\r\n\r\n    settings_.beginGroup(\"PluginSettings\");\r\n    for (IPlugin* plugin : plugins)\r\n    {\r\n        settings_.beginGroup(XmlUtils::removeWhiteSpace(plugin->getName()));\r\n\r\n        // Create the tree item.\r\n        QTreeWidgetItem* pluginItem = createPluginItem(plugin);\r\n\r\n        // Add item under the right parent.\r\n        if (dynamic_cast<IGeneratorPlugin*>(plugin) != 0)\r\n        {\r\n            pluginItem->setIcon(0, dynamic_cast<IGeneratorPlugin*>(plugin)->getIcon());\r\n            generatorsItem->addChild(pluginItem);\r\n        }\r\n        else if (dynamic_cast<ISourceAnalyzerPlugin*>(plugin) != 0)\r\n        {\r\n            analyzersItem->addChild(pluginItem);\r\n        }\r\n        else if(dynamic_cast<ImportPlugin*>(plugin) != 0)\r\n        {\r\n            importItems->addChild(pluginItem);\r\n        }\r\n\r\n        // Check if the plugin has not been visible before.\r\n        if (displayChanges && !oldPlugins.contains(plugin))\r\n        {    \r\n            newPlugins.append(plugin);          \r\n        }\r\n\r\n        settings_.endGroup();\r\n    }\r\n\r\n    settings_.endGroup();\r\n\r\n    pluginsTree_.expandAll();\r\n\r\n    QApplication::restoreOverrideCursor();\r\n\r\n    if (displayChanges && newPlugins.size() > 0)\r\n    {\r\n        NewPluginsDialog pluginDialog(this);\r\n        pluginDialog.addPlugins(newPlugins);\r\n        pluginDialog.exec();\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PluginSettingsPage::resetStacks()\r\n//-----------------------------------------------------------------------------\r\nvoid PluginSettingsPage::resetStacks()\r\n{\r\n    while (infoStack_.count() > 0)\r\n    {\r\n        infoStack_.removeWidget(infoStack_.widget(0));\r\n    }\r\n\r\n    infoStack_.addWidget(new PluginInfoWidget());\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PluginSettingsPage::setupLayout()\r\n//-----------------------------------------------------------------------------\r\nvoid PluginSettingsPage::setupLayout()\r\n{\r\n    pluginDirSelector_.setMinimumHeight(120);\r\n    pluginDirSelector_.setMinimumWidth(240);\r\n\r\n\tauto infoLayout = new QVBoxLayout();\r\n    infoLayout->addWidget(&infoStack_);\r\n\r\n\tauto infoGroup = new QGroupBox(tr(\"Plugin general information\"), this);\r\n    infoGroup->setLayout(infoLayout);\r\n    infoGroup->setFlat(true);\r\n\r\n    auto layout = new QGridLayout(this);\r\n    layout->addWidget(new QLabel(tr(\"Plugin directories:\"), this), 0, 0, 1, 1);\r\n    layout->addWidget(new QLabel(tr(\"Available plugins:\"), this), 0, 1, 1, 1);\r\n    layout->addWidget(&pluginDirSelector_, 1, 0, 1, 1);\r\n    layout->addWidget(&pluginsTree_, 1, 1, 1, 1);\r\n    layout->addWidget(infoGroup, 2, 0, 1, 2);\r\n\r\n    layout->setRowStretch(1, 2);\r\n}\r\n"
  },
  {
    "path": "settings/PluginSettingsPage.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: PluginSettingsPage.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Joni-Matti Maatta\r\n// Date: 19.02.2013\r\n//\r\n// Description:\r\n// Settings page for adjusting plugin settings.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef PLUGINSETTINGSPAGE_H\r\n#define PLUGINSETTINGSPAGE_H\r\n\r\n#include \"SettingsPage.h\"\r\n\r\n#include <common/widgets/DirectoryListSelector/DirectoryListSelector.h>\r\n#include <KactusAPI/include/PluginManager.h>\r\n\r\n#include <QTreeWidget>\r\n#include <QPlainTextEdit>\r\n#include <QSettings>\r\n#include <QStackedWidget>\r\n//-----------------------------------------------------------------------------\r\n//! PluginSettingsPage class.\r\n//-----------------------------------------------------------------------------\r\nclass PluginSettingsPage : public SettingsPage\r\n{\r\n    Q_OBJECT\r\n\r\npublic:\r\n    /*!\r\n     *  Constructor.\r\n     *\r\n     *    @param [in/out] settings   The settings store.\r\n     */\r\n    PluginSettingsPage(QSettings& settings);\r\n\r\n    /*!\r\n     *  Destructor.\r\n     */\r\n    virtual  ~PluginSettingsPage() = default;\r\n\r\n    //! Disable copying.\r\n    PluginSettingsPage(PluginSettingsPage const& rhs) = delete;\r\n\r\n    PluginSettingsPage& operator=(PluginSettingsPage const& rhs) = delete;\r\n\r\n    /*!\r\n     *  Validates the contents of the page thoroughly.\r\n     *\r\n     *    @return True, if the contents are valid. False, if they are invalid.\r\n     *\r\n     *      @remarks Showing message boxes for errors is allowed.\r\n     */\r\n    virtual bool validate() override final;\r\n\r\n    /*!\r\n     *  Applies the changes that were done in the page.\r\n     */\r\n    virtual void apply() override final;\r\n\r\nprivate slots:\r\n    /*!\r\n     *  Updates the correct settings in view when the tree item selection has changed.\r\n     */\r\n    void onTreeItemChanged(QTreeWidgetItem* current, QTreeWidgetItem* prev);\r\n\r\n    /*!\r\n     *  Updates the plugins tree when plugins directories have changed.\r\n     */\r\n    void onDirectoriesChanged();\r\n\r\nprivate:\r\n    //! Sets the page layout.\r\n    void setupLayout();\r\n\r\n    /*!\r\n     *  Updates the plugins tree.\r\n     */\r\n    void refreshPluginsTree(bool displayChanges = false);\r\n    \r\n    /*!\r\n     *  Resets the general information and settings stacks for plugins.\r\n     *\r\n     */\r\n    void resetStacks();\r\n\r\n\r\n    /*!\r\n     *  Creates a new category item to the tree.\r\n     *\r\n     *    @param [in] text  Category title text.\r\n     *    @param [in] icon  Icon for the category.\r\n     */\r\n    QTreeWidgetItem* createCategoryItem(QString const& text, QIcon const& icon);\r\n\r\n    /*!\r\n     *  Creates a new plugin item to the tree.\r\n     *\r\n     *    @param [in] plugin   Target plugin for the item.\r\n     *\r\n     *    @return The created tree item.\r\n     */\r\n    QTreeWidgetItem* createPluginItem(IPlugin* plugin);\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! The settings store.\r\n    QSettings& settings_;\r\n\r\n    //! The plugins directories editor.\r\n    DirectoryListSelector pluginDirSelector_;\r\n\r\n    //! The plugins tree widget.\r\n    QTreeWidget pluginsTree_;\r\n\r\n    //! The plugin info stack.\r\n    QStackedWidget infoStack_;\r\n\r\n    //! Flag for indicating changes in plugin directories.    \r\n    bool directoriesChanged_;\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n\r\n#endif // PLUGINSETTINGSPAGE_H\r\n"
  },
  {
    "path": "settings/SettingsDialog.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: SettingsDialog.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Joni-Matti Maatta\r\n// Date: 10.6.2011\r\n//\r\n// Description:\r\n// Settings dialog.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"SettingsDialog.h\"\r\n\r\n#include \"GeneralSettingsPage.h\"\r\n#include \"CodeEditorSettingsPage.h\"\r\n#include \"NamingPolicySettingsPage.h\"\r\n#include \"PluginSettingsPage.h\"\r\n#include \"FileTypeSettingsPage.h\"\r\n#include \"k2envvariablesettingspage.h\"\r\n#include \"ComponentEditorSettingsPage.h\"\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SettingsDialog()\r\n//-----------------------------------------------------------------------------\r\nSettingsDialog::SettingsDialog(QWidget* parent): \r\nPropertyPageDialog(QSize(24, 24), 1, VIEW_LIST, APPLY_ALL, parent)\r\n{\r\n    setWindowTitle(tr(\"Settings\"));\r\n\r\n    addPage(QIcon(\":icons/common/graphics/configuration.png\"), tr(\"General\"),\r\n        new GeneralSettingsPage(settings_));\r\n\r\n    addPage(QIcon(\":icons/common/graphics/naming-policy.png\"), tr(\"Naming Policies\"),\r\n        new NamingPolicySettingsPage(settings_));\r\n\r\n\taddPage(QIcon(\":icons/common/graphics/settings-code_editor.png\"), tr(\"Code Editor\"),\r\n            new CodeEditorSettingsPage(settings_));\r\n\r\n    addPage(QIcon(\":icons/common/graphics/settings-visibilities.png\"), tr(\"Component Editor Visibilities\"),\r\n        new ComponentEditorSettingsPage(settings_));\r\n\r\n    addPage(QIcon(\":icons/common/graphics/settings-file_types.png\"), tr(\"File Types\"),\r\n            new FileTypeSettingsPage(settings_));\r\n\r\n    addPage(QIcon(\":icons/common/graphics/settings-plugins.png\"), tr(\"Plugins\"),\r\n            new PluginSettingsPage(settings_));\r\n\r\n\t addPage(QIcon(\":icons/common/graphics/settings-environment_vars.png\"), tr(\"Environment variables\"),\r\n\t\t new K2EnvVariableSettingsPage(settings_));\r\n\r\n    finalizePages();\r\n    resize(sizeHint().width(), minimumHeight());\r\n}\r\n"
  },
  {
    "path": "settings/SettingsDialog.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: SettingsDialog.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Joni-Matti Maatta\r\n// Date: 10.6.2011\r\n//\r\n// Description:\r\n// Settings dialog.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef SETTINGSDIALOG_H\r\n#define SETTINGSDIALOG_H\r\n\r\n#include <common/dialogs/propertyPageDialog/PropertyPageDialog.h>\r\n\r\n#include <QSettings>\r\n\r\n//-----------------------------------------------------------------------------\r\n//! SettingsDialog class.\r\n//-----------------------------------------------------------------------------\r\nclass SettingsDialog : public PropertyPageDialog\r\n{\r\n    Q_OBJECT\r\n\r\npublic:\r\n    /*!\r\n     *  Constructor.\r\n     *\r\n     *    @param [in] parent    The parent widget.\r\n     */\r\n    SettingsDialog(QWidget* parent = 0);\r\n\r\n    /*!\r\n     *  Destructor.\r\n     */\r\n    virtual ~SettingsDialog() = default;\r\n\r\n    // Disable copying.\r\n    SettingsDialog(SettingsDialog const& rhs) = delete;\r\n    SettingsDialog& operator=(SettingsDialog const& rhs) = delete;\r\n\r\nprivate:\r\n\r\n    //! The settings store.\r\n    QSettings settings_;\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n\r\n#endif // SETTINGSDIALOG_H\r\n"
  },
  {
    "path": "settings/SettingsPage.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: SettingsPage.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Esko Pekkarinen\r\n// Date: 01.07.2014\r\n//\r\n// Description:\r\n// Base class for all settings pages.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"SettingsPage.h\"\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SettingsPage()\r\n//-----------------------------------------------------------------------------\r\nSettingsPage::SettingsPage(QSettings& settings) : \r\n    PropertyPageView(),\r\n    settings_(settings)    \r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: onPageChange()\r\n//-----------------------------------------------------------------------------\r\nbool SettingsPage::onPageChange()\r\n{\r\n    // Do not change the page if the settings are invalid.\r\n    return validate();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SettingsPage::settings()\r\n//-----------------------------------------------------------------------------\r\nQSettings& SettingsPage::settings() const\r\n{\r\n    return settings_;\r\n}\r\n"
  },
  {
    "path": "settings/SettingsPage.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: SettingsPage.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Esko Pekkarinen\r\n// Date: 01.07.2014\r\n//\r\n// Description:\r\n// Base class for all settings pages.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef SETTINGSPAGE_H\r\n#define SETTINGSPAGE_H\r\n\r\n#include <common/dialogs/propertyPageDialog/PropertyPageView.h>\r\n\r\n#include <QSettings>\r\n\r\n//-----------------------------------------------------------------------------\r\n//! SettingsPage class.\r\n//-----------------------------------------------------------------------------\r\nclass SettingsPage : public PropertyPageView\r\n{\r\n    Q_OBJECT\r\npublic:\r\n    /*!\r\n     *  Constructor.\r\n     *\r\n     *    @param [in/out] settings The settings store.\r\n     */\r\n    SettingsPage(QSettings& settings);\r\n\r\n    /*!\r\n     *  Destructor.\r\n     */\r\n    virtual ~SettingsPage() = default;\r\n\r\n    // Disable copying.\r\n    SettingsPage(SettingsPage const& rhs) = delete;\r\n    SettingsPage& operator=(SettingsPage const& rhs) = delete;\r\n\r\n    /*!\r\n     *  Called when the page is to be changed and this page would be hidden.\r\n     *\r\n     *    @return False, if the page change should be rejected. Otherwise true.\r\n     */\r\n    virtual bool onPageChange();\r\n\r\nprotected:\r\n\r\n    /*!\r\n     *  Returns the settings to the subclasses.\r\n     *\r\n     */\r\n    QSettings& settings() const;\r\n\r\nprivate:\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! The settings store.\r\n    QSettings& settings_;\r\n\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n\r\n#endif // SETTINGSPAGE_H\r\n"
  },
  {
    "path": "settings/SettingsUpdater.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: SettingsUpdater.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Joni-Matti Maatta\r\n// Date: 15.01.2013\r\n//\r\n// Description:\r\n// Settings updater which upgrades Kactus2 settings up-to-date based on a configuration file.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"SettingsUpdater.h\"\r\n\r\n#include <KactusAPI/include/VersionHelper.h>\r\n\r\n#include <common/widgets/assistedTextEdit/HighlightStyleDesc.h>\r\n\r\n#include <QString>\r\n#include <QStringList>\r\n#include <QMessageBox>\r\n#include <QCoreApplication>\r\n#include <QVariant>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SettingsUpdater::runUpgrade()\r\n//-----------------------------------------------------------------------------\r\nvoid SettingsUpdater::runUpgrade(QSettings& settings, MessageMediator* mediator)\r\n{   \r\n    qRegisterMetaType<HighlightStyleDesc>(\"HighlightStyleDesc\");\r\n\r\n    // Retrieve the version number of the settings file and check if it is not up-to-date.\r\n    QString settingsVersion = \r\n        settings.value(QStringLiteral(\"Platform/Version\"), QStringLiteral(\"1.5.0.0\")).toString();\r\n\r\n    if (!Details::isVersionOlderThan(settingsVersion, VersionHelper::versionFull()))\r\n    {\r\n        // Already up-to-date.\r\n        return;\r\n    }\r\n\r\n    // Run the upgrade based on the configuration file.\r\n    QFile* configurationFile = Details::openConfigurationFile(mediator);\r\n\r\n    QTextStream fileStream(configurationFile);\r\n\r\n    QString versionIterator = QString();\r\n    while (!fileStream.atEnd())\r\n    {\r\n        QString line = fileStream.readLine();\r\n\r\n        QTextStream lineStream(&line);\r\n\r\n        // Read the command token.\r\n        QString action;\r\n        lineStream >> action;\r\n        action = action.toLower();\r\n\r\n        // Skip comments.\r\n        if (action.startsWith(QLatin1String(\"//\")))\r\n        {\r\n            continue;\r\n        }\r\n\r\n        // Update to next found version.\r\n        if (action == QLatin1String(\"version\"))\r\n        {\r\n            lineStream >> versionIterator;\r\n        }\r\n        // Otherwise check whether the current version patch needs to be applied.\r\n        else if (Details::isVersionOlderThan(settingsVersion, versionIterator))\r\n        {\r\n            // Perform the upgrade operation based on the command token.\r\n            if (action.compare(QLatin1String(\"add\")) == 0)\r\n            {\r\n                QString key;\r\n                lineStream >> key;\r\n                lineStream.skipWhiteSpace();\r\n\r\n                if (!settings.contains(key))\r\n                {\r\n                    settings.setValue(key, Details::parseVariant(lineStream));\r\n                }\r\n            }\r\n            else if (action.compare(QLatin1String(\"remove\")) == 0)\r\n            {\r\n                QString key;\r\n                lineStream >> key;\r\n\r\n                if (settings.contains(key))\r\n                {\r\n                    settings.remove(key);\r\n                }\r\n            }\r\n            else if (action.compare(QLatin1String(\"rename\")) == 0)\r\n            {\r\n                QString oldKey;\r\n                QString newKey;\r\n                lineStream >> oldKey >> newKey;\r\n\r\n                QVariant value = settings.value(oldKey);\r\n                settings.remove(oldKey);\r\n                settings.setValue(newKey, value);\r\n            }\r\n            else if (action.compare(QLatin1String(\"copy\")) == 0)\r\n            {\r\n                QString srcKey;\r\n                QString destKey;\r\n                lineStream >> srcKey >> destKey;\r\n\r\n                QVariant value = settings.value(srcKey);\r\n                settings.setValue(destKey, value);\r\n            }\r\n        }\r\n    }\r\n\r\n    configurationFile->close();\r\n    delete configurationFile;\r\n    configurationFile = 0;\r\n\r\n    // Finally update the settings version.\r\n    settings.setValue(QStringLiteral(\"Platform/Version\"), VersionHelper::versionFull());\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SettingsUpdater::Details::isVersionOlderThan()\r\n//-----------------------------------------------------------------------------\r\nbool SettingsUpdater::Details::isVersionOlderThan(QString const& version, QString const& comparison)\r\n{\r\n    QStringList numbers1 = version.split(QLatin1Char('.'));\r\n    QStringList numbers2 = comparison.split(QLatin1Char('.'));\r\n\r\n    for (int i = 0; i < 4; ++i)\r\n    {\r\n        if (numbers1.at(i).toUInt() != numbers2.at(i).toUInt())\r\n        {\r\n            return numbers1.at(i).toUInt() < numbers2.at(i).toUInt();\r\n        }\r\n    }\r\n\r\n    return false;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SettingsUpdater::Details::openConfigurationFile()\r\n//-----------------------------------------------------------------------------\r\nQFile* SettingsUpdater::Details::openConfigurationFile(MessageMediator* mediator)\r\n{        \r\n    QFile* configurationFile = new QFile(QStringLiteral(\"./upgrade.cfg\"));\r\n\r\n    if (!configurationFile->exists())\r\n    {\r\n        configurationFile->setFileName(QCoreApplication::applicationDirPath() + QStringLiteral(\"/upgrade.cfg\"));\r\n    }\r\n    \r\n#ifdef Q_OS_LINUX\r\n    if (!configurationFile->exists())\r\n    {\r\n        configurationFile->setFileName(QStringLiteral(\"/usr/share/kactus2/upgrade.cfg\"));\r\n    }\r\n#endif\r\n\r\n    if (!configurationFile->open(QIODevice::ReadOnly))\r\n    {\r\n       mediator->showFailure(QObject::tr(\"Settings upgrade configuration file 'upgrade.cfg' was not found. \"\r\n           \"Restoring default settings.\"));\r\n    }\r\n\r\n    return configurationFile;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: SettingsUpdater::Details::parseVariant()\r\n//-----------------------------------------------------------------------------\r\nQVariant SettingsUpdater::Details::parseVariant(QTextStream& lineStream)\r\n{\r\n    // Retrieve the variant type.\r\n    QString type;\r\n    lineStream >> type;\r\n    lineStream.skipWhiteSpace();\r\n\r\n    if (type.compare(QLatin1String(\"StringList\")) == 0)\r\n    {\r\n        return lineStream.readAll().split(QLatin1Char(','));\r\n    }\r\n    else if (type.compare(QLatin1String(\"String\")) == 0)\r\n    {\r\n        return lineStream.readAll();\r\n    }\r\n    else if (type.compare(QLatin1String(\"Size\")) == 0)\r\n    {\r\n        int w = 0;\r\n        int h = 0;\r\n        lineStream >> w >> h;\r\n        return QSize(w, h);\r\n    }\r\n    else if (type.compare(QLatin1String(\"Point\")) == 0)\r\n    {\r\n        int x = 0;\r\n        int y = 0;\r\n        lineStream >> x >> y;\r\n        return QPoint(x, y);\r\n    }\r\n    else if (type.compare(QLatin1String(\"Integer\")) == 0)\r\n    {\r\n        int i = 0;\r\n        lineStream >> i;\r\n        return i;\r\n    }\r\n    else if (type.compare(QLatin1String(\"Boolean\")) == 0)\r\n    {\r\n        QString value;\r\n        lineStream >> value;\r\n        return bool(value.compare(QLatin1String(\"true\")) == 0);\r\n    }\r\n    else if (type.compare(QLatin1String(\"Font\")) == 0)\r\n    {\r\n        QStringList arguments = lineStream.readAll().split(QLatin1Char(','));\r\n        return QFont(arguments.first(), arguments.last().toInt());\r\n    }\r\n    else if (type.compare(QLatin1String(\"HighlightStyle\")) == 0)\r\n    {\r\n        QStringList arguments = lineStream.readAll().split(QLatin1Char(','));\r\n        return QVariant::fromValue(HighlightStyleDesc(QColor(arguments.first()), \r\n            arguments.contains(QStringLiteral(\"bold\")),\r\n            arguments.contains(QStringLiteral(\"italic\"))));\r\n    }\r\n    else if (type.compare(QLatin1String(\"ByteArray\")) == 0)\r\n    {\r\n        return QVariant(lineStream.readAll().toLatin1());\r\n    }\r\n\r\n    Q_ASSERT(false);\r\n    return QVariant();\r\n}\r\n"
  },
  {
    "path": "settings/SettingsUpdater.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: SettingsUpdater.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Joni-Matti Maatta\r\n// Date: 15.01.2013\r\n//\r\n// Description:\r\n// Settings updater which upgrades Kactus2 settings up-to-date based on a configuration file.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef SETTINGSUPDATER_H\r\n#define SETTINGSUPDATER_H\r\n\r\n#include <KactusAPI/include/MessageMediator.h>\r\n\r\n#include <QFile>\r\n#include <QVariant>\r\n#include <QTextStream>\r\n#include <QSettings>\r\n\r\nnamespace SettingsUpdater\r\n{\r\n    /*!\r\n     *  Upgrades the settings if not up-to-date.\r\n     */\r\n    void runUpgrade(QSettings& settings, MessageMediator* mediator);\r\n\r\n    namespace Details\r\n    {\r\n\r\n        /*!\r\n         *  Compares version numbers.\r\n         *\r\n         *    @param [in] version     The version to compare.\r\n         *    @param [in] comparison  The version to compare against.\r\n         *\r\n         *    @return True, if the first version is older than the comparison.\r\n         */\r\n        bool isVersionOlderThan(QString const& version, QString const& comparison);\r\n        \r\n        /*!\r\n        *  Open the configuration file for reading.\r\n        *\r\n        *    @param [in] parent   The parent widget.\r\n        *\r\n        *    @return The open configuration file.\r\n        */\r\n        QFile* openConfigurationFile(MessageMediator* mediator);\r\n\r\n        /*!\r\n         *  Parses a QVariant from the given text stream.\r\n         *\r\n         *    @param [in] lineStream  The source text stream.\r\n         *\r\n         *    @return The parsed QVariant.\r\n         */\r\n        QVariant parseVariant(QTextStream& lineStream);\r\n    }\r\n}\r\n#endif // SETTINGSUPDATER_H\r\n"
  },
  {
    "path": "settings/filetypesview.cpp",
    "content": "/* \r\n *\tCreated on:\t4.4.2013\r\n *\tAuthor:\t\tAntti Kamppi\r\n *\tFile name:\tfiletypesview.cpp\r\n *\tProject:\t\tKactus 2\r\n*/\r\n\r\n#include \"filetypesview.h\"\r\n#include <IPXACTmodels/common/FileType.h>\r\n\r\n#include <QMenu>\r\n\r\nFileTypesView::FileTypesView(QWidget *parent):\r\nEditableTableView(parent) {\r\n\r\n\t// user can only select one item at a time\r\n\tsetSelectionMode(QAbstractItemView::SingleSelection);\r\n}\r\n\r\nvoid FileTypesView::contextMenuEvent( QContextMenuEvent* event ) {\r\n\tpressedPoint_ = event->pos();\r\n\r\n\tQModelIndex index = indexAt(pressedPoint_);\r\n\r\n\tQMenu menu(this);\r\n\tmenu.addAction(&addAction_);\r\n\r\n\t// if at least one valid item is selected\r\n\tif (index.isValid()) {\r\n\r\n\t\t// find the index for the file type column, this is in case the user clicked some\r\n\t\t// other column than file type\r\n\t\tQModelIndex fileTypeIndex = index.model()->index(index.row(), 0, QModelIndex());\r\n\t\tQString selectedFileType = fileTypeIndex.model()->data(fileTypeIndex, Qt::DisplayRole).toString();\r\n\r\n\t\t// if the file type is user defined and not one of the file types specified\r\n\t\t// by IP-XACT standard\r\n\t\tif (!FileTypes::isIpXactFileType(selectedFileType, Document::Revision::Std22))\r\n        {\r\n\t\t\tmenu.addAction(&removeAction_); \r\n\t\t\t\r\n\t\t\tmenu.addAction(&clearAction_);\r\n\t\t}\r\n\t\t// if the file type was defined by IP-XACT standard\r\n\t\telse {\r\n\r\n\t\t\t// if user selected some other column than the file type column, it can be cleared\r\n\t\t\tif (index.column() != 0) {\r\n\t\t\t\tmenu.addAction(&clearAction_);\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tmenu.addAction(&copyAction_);\r\n\t}\r\n\tmenu.addAction(&pasteAction_);\r\n\r\n\tif (importExportAllowed()) \r\n    {\r\n        menu.addSeparator();\r\n\t\tmenu.addAction(&importAction_);\r\n\t\tmenu.addAction(&exportAction_);\r\n\t}\r\n\r\n\tmenu.exec(event->globalPos());\r\n\r\n\tevent->accept();\r\n}\r\n\r\nvoid FileTypesView::keyPressEvent( QKeyEvent* event ) {\r\n\t// call the base class implementation\r\n\tQTableView::keyPressEvent(event);\r\n\r\n\tQModelIndex selected = currentIndex();\r\n\r\n\tif (event->matches(QKeySequence::Copy))\r\n    {\r\n\t\tonCopyAction();\r\n\t}\r\n\tif (event->matches(QKeySequence::Paste))\r\n    {\r\n\t\tonPasteAction();\r\n\t}\r\n\tif (event->matches(QKeySequence::Delete))\r\n    {\r\n\t\t// if user had selected the file type column\r\n\t\tif (selected.column() == 0) \r\n        {\r\n\t\t\t// if the file type is one of the standard ones, it can't be cleared\r\n\t\t\tQString selectedFileType = selected.model()->data(selected, Qt::DisplayRole).toString();\r\n\t\t\tif (FileTypes::isIpXactFileType(selectedFileType, Document::Revision::Std22))\r\n            {\r\n\t\t\t\treturn;\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tonClearAction();\r\n\t}\r\n\tif (event->matches(QKeySequence::InsertLineSeparator))\r\n    {\r\n\t\tonAddAction();\r\n\t}\r\n}\r\n"
  },
  {
    "path": "settings/filetypesview.h",
    "content": "/* \r\n *\tCreated on:\t4.4.2013\r\n *\tAuthor:\t\tAntti Kamppi\r\n *\tFile name:\tfiletypesview.h\r\n *\tProject:\t\tKactus 2\r\n*/\r\n\r\n#ifndef FILETYPESVIEW_H\r\n#define FILETYPESVIEW_H\r\n\r\n#include <common/views/EditableTableView/editabletableview.h>\r\n\r\n/*! \\brief A view for the file type settings in the settings dialog.\r\n *\r\n */\r\nclass FileTypesView : public EditableTableView {\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\r\n\t/*! \\brief The constructor.\r\n\t *\r\n\t * Method: \t\tFileTypesView\r\n\t * Full name:\tFileTypesView::FileTypesView\r\n\t * Access:\t\tprivate \r\n\t *\r\n\t * \\param parent Pointer to the owner of the view.\r\n\t *\r\n\t*/\r\n\tFileTypesView(QWidget *parent);\r\n\t\r\n\t//! \\brief The destructor.\r\n    virtual ~FileTypesView() = default;\r\n\r\n    //! \\brief No copying\r\n    FileTypesView(const FileTypesView& other) = delete;\r\n\r\n    //! \\brief No assignment\r\n    FileTypesView& operator=(const FileTypesView& other) = delete;\r\n\r\nprotected:\r\n\r\n\t//! \\brief Handler for context menu events\r\n\tvirtual void contextMenuEvent(QContextMenuEvent* event) override final;\r\n\r\n\t//! \\brief Handler for key press events\r\n\tvirtual void keyPressEvent(QKeyEvent* event) override final;\r\n\r\n};\r\n\r\n#endif // FILETYPESVIEW_H\r\n"
  },
  {
    "path": "settings/k2envvariablesettingspage.cpp",
    "content": "/* \r\n *\tCreated on:\t24.5.2013\r\n *\tAuthor:\t\tAntti Kamppi\r\n *\tFile name:\tk2envvariablesettingspage.cpp\r\n *\tProject:    Kactus2\r\n*/\r\n\r\n#include \"k2envvariablesettingspage.h\"\r\n#include <common/delegates/LineEditDelegate/lineeditdelegate.h>\r\n#include \"k2envvarmodel.h\"\r\n\r\n#include <QCoreApplication>\r\n#include <QMessageBox>\r\n#include <QSettings>\r\n#include <QVBoxLayout>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: K2EnvVariableSettingsPage::K2EnvVariableSettingsPage()\r\n//-----------------------------------------------------------------------------\r\nK2EnvVariableSettingsPage::K2EnvVariableSettingsPage(QSettings& settings):\r\nSettingsPage(settings),\r\n    view_(new EditableTableView(this)),\r\n    model_(new K2EnvVarModel(settings, this)) \r\n{\r\n\tview_->setAllowImportExport(false);\r\n\tview_->setItemsDraggable(false);\r\n\tview_->setSortingEnabled(false);\r\n\tview_->setItemDelegate(new LineEditDelegate(this));\r\n\r\n\tview_->setModel(model_);\r\n\r\n\tQVBoxLayout* layout = new QVBoxLayout(this);    \r\n\tlayout->addWidget(view_);\r\n\r\n\tconnect(view_, SIGNAL(addItem(const QModelIndex&)),\r\n        model_, SLOT(onAddItem(const QModelIndex&)), Qt::UniqueConnection);\r\n\tconnect(view_, SIGNAL(removeItem(const QModelIndex&)),\r\n\t\tmodel_, SLOT(onRemoveItem(const QModelIndex&)), Qt::UniqueConnection);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: K2EnvVariableSettingsPage::apply()\r\n//-----------------------------------------------------------------------------\r\nvoid K2EnvVariableSettingsPage::apply()\r\n{\r\n\tmodel_->apply(settings());\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: K2EnvVariableSettingsPage::prevalidate()\r\n//-----------------------------------------------------------------------------\r\nbool K2EnvVariableSettingsPage::prevalidate() const\r\n{\r\n\treturn !model_->containsEmptyVariables();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: K2EnvVariableSettingsPage::validate()\r\n//-----------------------------------------------------------------------------\r\nbool K2EnvVariableSettingsPage::validate()\r\n{\r\n\tif (!prevalidate())\r\n    {\r\n\t\tQMessageBox::critical(this, QCoreApplication::applicationName(),\r\n            tr(\"All environment variables must have defined name.\"));\r\n\t\treturn false;\r\n\t}\r\n\r\n\treturn true;\r\n}\r\n"
  },
  {
    "path": "settings/k2envvariablesettingspage.h",
    "content": "/* \r\n *\tCreated on:\t24.5.2013\r\n *\tAuthor:\t\tAntti Kamppi\r\n *\tFile name:\tk2envvariablesettingspage.h\r\n *\tProject:\t\tKactus 2\r\n*/\r\n\r\n#ifndef K2ENVVARIABLESETTINGSPAGE_H\r\n#define K2ENVVARIABLESETTINGSPAGE_H\r\n\r\n#include \"SettingsPage.h\"\r\n#include <common/views/EditableTableView/editabletableview.h>\r\n\r\n#include <QSettings>\r\n\r\nclass K2EnvVarModel;\r\n\r\n/*! \\brief Displays the Kactus2 environment variables in settings dialog.\r\n *\r\n */\r\nclass K2EnvVariableSettingsPage : public SettingsPage \r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\r\n\tK2EnvVariableSettingsPage(QSettings& settings);\r\n\t\r\n\t//! \\brief The destructor.\r\n\tvirtual ~K2EnvVariableSettingsPage() = default;\r\n\r\n\t/*! \\brief Apply the changes made in the settings page.\r\n\t *\r\n\t * Method: \t\tapply\r\n\t * Full name:\tK2EnvVariableSettingsPage::apply\r\n\t * Access:\t\tvirtual public \r\n\t *\r\n\t*/\r\n\tvirtual void apply() override final;\r\n\r\n    /*! \\brief Checks that all variables have a defined name.\r\n     *\r\n     * Method: \t\tprevalidate\r\n     * Full name:\tK2EnvVariableSettingsPage::prevalidate\r\n     * Access:\t\tvirtual public \r\n     *\r\n     *\r\n     * \\return False if at least one variable name is empty.\r\n    */\r\n    virtual bool prevalidate() const override final;\r\n\r\n    /*! \\brief Checks that all variables have a defined name. \r\n     *\r\n     * If at least one name is empty, an error dialog is displayed.\r\n     *\r\n     * Method: \t\tvalidate\r\n     * Full name:\tK2EnvVariableSettingsPage::validate\r\n     * Access:\t\tvirtual public \r\n     *\r\n     *\r\n     * \\return False if at least one variable name is empty.\r\n    */\r\n    virtual bool validate() override final;\r\n\r\nprivate:\r\n\r\n\t//! \\brief No copying\r\n\tK2EnvVariableSettingsPage(const K2EnvVariableSettingsPage& other);\r\n\r\n\t//! \\brief No assignment\r\n\tK2EnvVariableSettingsPage& operator=(const K2EnvVariableSettingsPage& other);\r\n\r\n\t//! \\brief Displays the environment variables.\r\n\tEditableTableView* view_;\r\n\r\n\t//! \\brief The model which manages the environment variables.\r\n\tK2EnvVarModel* model_;\r\n};\r\n\r\n#endif // K2ENVVARIABLESETTINGSPAGE_H\r\n"
  },
  {
    "path": "settings/k2envvarmodel.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: k2envvarmodel.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 05.06.2013\r\n//\r\n// Description:\r\n// Manages the K2 environment variables displayed in the settings dialog.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"k2envvarmodel.h\"\r\n#include <KactusAPI/include/IPlugin.h>\r\n#include <KactusAPI/include/PluginManager.h>\r\n\r\n#include <common/KactusColors.h>\r\n\r\n#include <QColor>\r\n#include <QStringList>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: K2EnvVarModel::K2EnvVarModel()\r\n//-----------------------------------------------------------------------------\r\nK2EnvVarModel::K2EnvVarModel(QSettings& settings, QObject *parent): QAbstractTableModel(parent), table_()\r\n{\r\n    loadData(settings);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: K2EnvVarModel::apply()\r\n//-----------------------------------------------------------------------------\r\nvoid K2EnvVarModel::apply(QSettings& settings)\r\n{\r\n    // first clear all previously defined variables to remove duplicates\r\n    settings.remove(QStringLiteral(\"K2Variables\"));\r\n\r\n    QStringList variableNames;\r\n\r\n    foreach (K2EnvVarModel::EnvSetting const& envVar, table_)\r\n    {\r\n        // unnamed variables are not stored\r\n        if (envVar.name_.isEmpty() == false)\r\n        {\r\n            variableNames.append(envVar.name_);\r\n\r\n            // save the settings for the variable name\r\n            settings.setValue(QStringLiteral(\"K2Variables/\") + envVar.name_ + QStringLiteral(\"/value\"),\r\n                envVar.value_);\r\n            settings.setValue(QStringLiteral(\"K2Variables/\") + envVar.name_ + QStringLiteral(\"/suffix\"),\r\n                envVar.fileSuffix_);\r\n            settings.setValue(QStringLiteral(\"K2Variables/\") + envVar.name_ + QStringLiteral(\"/description\"),\r\n                envVar.description_);\r\n        }\r\n    }\r\n\r\n    settings.setValue(QStringLiteral(\"K2Variables/variableNames\"), variableNames);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: K2EnvVarModel::rowCount()\r\n//-----------------------------------------------------------------------------\r\nint K2EnvVarModel::rowCount(QModelIndex const& parent) const\r\n{\r\n    if (parent.isValid())\r\n    {\r\n        return 0;\r\n    }\r\n\r\n    return table_.size();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: K2EnvVarModel::columnCount()\r\n//-----------------------------------------------------------------------------\r\nint K2EnvVarModel::columnCount(QModelIndex const& parent) const\r\n{\r\n    if (parent.isValid())\r\n    {\r\n        return 0;\r\n    }\r\n\r\n    return K2EnvVarModel::COLUMN_COUNT;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: K2EnvVarModel::flags()\r\n//-----------------------------------------------------------------------------\r\nQt::ItemFlags K2EnvVarModel::flags( const QModelIndex& index ) const\r\n{\r\n    if (index.isValid() == false || index.row() < 0 || index.row() >= table_.size())\r\n    {\r\n        return Qt::NoItemFlags;\r\n    }\r\n\r\n    Qt::ItemFlags flags = Qt::ItemIsSelectable | Qt::ItemIsEnabled;\r\n\r\n    if ((index.column() == K2EnvVarModel::NAME_COLUMN || index.column() == K2EnvVarModel::DESCRIPTION_COLUMN) &&\r\n        table_.at(index.row()).fromPlugin_ == false)\r\n    {\r\n        flags |= Qt::ItemIsEditable;\r\n    }\r\n    else if (index.column() ==K2EnvVarModel::VALUE_COLUMN)\r\n    {\r\n        flags |= Qt::ItemIsEditable;\r\n    }\r\n\r\n    return flags;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: K2EnvVarModel::headerData()\r\n//-----------------------------------------------------------------------------\r\nQVariant K2EnvVarModel::headerData(int section, Qt::Orientation orientation, int role) const\r\n{\r\n    if (orientation != Qt::Horizontal)\r\n    {\r\n        return QVariant();\r\n    }\r\n\r\n    if (Qt::DisplayRole == role)\r\n    {\r\n        if (section == K2EnvVarModel::NAME_COLUMN)\r\n        {\r\n            return tr(\"Name\");\r\n        }\r\n        else if (section == K2EnvVarModel::VALUE_COLUMN)\r\n        {\r\n            return tr(\"Value\");\r\n        }\r\n        else if (section == K2EnvVarModel::FILE_SUFFIX_COLUMN)\r\n        {\r\n            return tr(\"File Suffix\");\r\n        }\r\n        else if (section == K2EnvVarModel::DESCRIPTION_COLUMN)\r\n        {\r\n            return tr(\"Description\");\r\n        }\r\n    }\r\n\r\n    return QVariant();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: K2EnvVarModel::data()\r\n//-----------------------------------------------------------------------------\r\nQVariant K2EnvVarModel::data(QModelIndex const& index, int role) const\r\n{\r\n    if (index.isValid() == false || index.row() < 0 || index.row() >= table_.size())\r\n    {\r\n        return QVariant();\r\n    }\r\n\r\n    if (Qt::DisplayRole == role)\r\n    {\r\n        if (index.column() == K2EnvVarModel::NAME_COLUMN)\r\n        {\r\n            return table_.at(index.row()).name_;\r\n        }\r\n        else if (index.column() == K2EnvVarModel::VALUE_COLUMN)\r\n        {\r\n            return table_.at(index.row()).value_;\r\n        }\r\n        else if (index.column() == K2EnvVarModel::FILE_SUFFIX_COLUMN)\r\n        {\r\n            return table_.at(index.row()).fileSuffix_;\r\n        }\r\n        else if (index.column() == K2EnvVarModel::DESCRIPTION_COLUMN)\r\n        {\r\n            return table_.at(index.row()).description_;\r\n        }\r\n        else\r\n        {\r\n            return QVariant();\r\n        }\r\n    }\r\n    else if (Qt::BackgroundRole == role)\r\n    {\r\n        if (index.column() == K2EnvVarModel::NAME_COLUMN)\r\n        {\r\n            return KactusColors::MANDATORY_FIELD;\r\n        }\r\n        else\r\n        {\r\n            return KactusColors::REGULAR_FIELD;\r\n        }\r\n    }\r\n\r\n    return QVariant();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: K2EnvVarModel::setData()\r\n//-----------------------------------------------------------------------------\r\nbool K2EnvVarModel::setData(QModelIndex const& index, const QVariant& value, int role)\r\n{\r\n    if (index.isValid() == false || index.row() < 0 || index.row() >= table_.size())\r\n    {\r\n        return false;\r\n    }\r\n\r\n    if (Qt::EditRole == role)\r\n    {\r\n        if (index.column() == K2EnvVarModel::NAME_COLUMN)\r\n        {\r\n            // plugin variable's name can't be modified\r\n            if (table_[index.row()].fromPlugin_)\r\n            {\r\n                return false;\r\n            }\r\n\r\n            QString newName = value.toString();\r\n\r\n            // if a variable with the name already exists\r\n            K2EnvVarModel::EnvSetting testVar(newName, QString(), QString(), QString(), false);\r\n            if (table_.contains(testVar))\r\n            {\r\n                return false;\r\n            }\r\n\r\n            table_[index.row()].name_ = newName;\r\n        }\r\n\r\n        else if (index.column() == K2EnvVarModel::VALUE_COLUMN)\r\n        {\r\n            table_[index.row()].value_ = value.toString();\r\n\r\n        }\r\n\r\n        else if (index.column() == K2EnvVarModel::FILE_SUFFIX_COLUMN)\r\n        {\r\n            // plugin variable's file suffix can't be modified\r\n            if (table_[index.row()].fromPlugin_)\r\n            {\r\n                return false;\r\n            }\r\n\r\n            table_[index.row()].fileSuffix_ = value.toString();\r\n        }\r\n\r\n        else if (index.column() == K2EnvVarModel::DESCRIPTION_COLUMN)\r\n        {\r\n            // plugin variable's description can't be modified\r\n            if (table_[index.row()].fromPlugin_) {\r\n                return false;\r\n            }\r\n\r\n            table_[index.row()].description_ = value.toString();\r\n\r\n        }\r\n\r\n        else\r\n        {\r\n            return false;\r\n        }\r\n\r\n        emit dataChanged(index, index);\r\n        return true;\r\n    }\r\n    else\r\n    {\r\n        return false;\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: K2EnvVarModel::onAddItem()\r\n//-----------------------------------------------------------------------------\r\nvoid K2EnvVarModel::onAddItem(QModelIndex const& index)\r\n{\r\n    int row = table_.size();\r\n\r\n    // if the index is valid then add the item to the correct position\r\n    if (index.isValid())\r\n    {\r\n        row = index.row();\r\n    }\r\n\r\n    beginInsertRows(QModelIndex(), row, row);\r\n    table_.insert(row, K2EnvVarModel::EnvSetting());\r\n    endInsertRows();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: K2EnvVarModel::onRemoveItem()\r\n//-----------------------------------------------------------------------------\r\nvoid K2EnvVarModel::onRemoveItem(QModelIndex const& index)\r\n{\r\n    // don't remove anything if index is invalid\r\n    if (!index.isValid() || index.row() < 0 || index.row() >= table_.size())\r\n    {\r\n        return;\r\n    }\r\n\r\n    // remove the specified item\r\n    beginRemoveRows(QModelIndex(), index.row(), index.row());\r\n    table_.removeAt(index.row());\r\n    endRemoveRows();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: K2EnvVarModel::containsEmptyVariables()\r\n//-----------------------------------------------------------------------------\r\nbool K2EnvVarModel::containsEmptyVariables() const\r\n{\r\n    foreach (K2EnvVarModel::EnvSetting const& envVar, table_)\r\n    {\r\n        if (envVar.name_.isEmpty())\r\n        {\r\n            return true;\r\n        }\r\n    }\r\n\r\n    // no empty variables defined\r\n    return false;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: K2EnvVarModel::loadData()\r\n//-----------------------------------------------------------------------------\r\nvoid K2EnvVarModel::loadData(QSettings& settings)\r\n{\r\n    beginResetModel();\r\n\r\n    // find the variables required by the active plugins\r\n    QList<IPlugin::ExternalProgramRequirement> pluginRequirements;\r\n    foreach (IPlugin* plugin, PluginManager::getInstance().getActivePlugins())\r\n    {\r\n        pluginRequirements.append(plugin->getProgramRequirements());\r\n    }\r\n\r\n    // add the plugin variables to the list\r\n    QStringList usedNames;\r\n    foreach (IPlugin::ExternalProgramRequirement const& req, pluginRequirements)\r\n    {\r\n        // do not add variables with no name\r\n        // if same variable is used by several plugins then add it only once\r\n        if (req.name_.isEmpty() == false && !usedNames.contains(req.name_))\r\n        {\r\n            usedNames.append(req.name_);\r\n\r\n            // add the variable\r\n            K2EnvVarModel::EnvSetting envVar(req.name_, QString(), req.filters_, req.description_, true);\r\n            table_.append(envVar);\r\n        }\r\n    }\r\n\r\n    // list of the variable names\r\n    QStringList variableNames = settings.value(QStringLiteral(\"K2Variables/variableNames\")).toStringList();\r\n\r\n    // find the settings for each variable\r\n    foreach(QString const& name, variableNames)\r\n    {\r\n        // create the variable from the settings\r\n        QString value = settings.value(\r\n            QStringLiteral(\"K2Variables/\") + name + QStringLiteral(\"/value\")).toString();\r\n        QString suffix = settings.value(\r\n            QStringLiteral(\"K2Variables/\") + name + QStringLiteral(\"/suffix\")).toString();\r\n        QString desc = settings.value(\r\n            QStringLiteral(\"K2Variables/\") + name + QStringLiteral(\"/description\")).toString();\r\n\r\n        K2EnvVarModel::EnvSetting envVar(name, value, suffix, desc, false);\r\n\r\n        // if the variable was defined by the plugins\r\n        if (table_.contains(envVar))\r\n        {\r\n            // other settings are defined by the plugins but value is set by settings\r\n            int index = table_.indexOf(envVar);\r\n            table_[index].value_ = envVar.value_;\r\n        }\r\n        // if the variable is new and not defined by the plugins\r\n        else\r\n        {\r\n            table_.append(envVar);\r\n        }\r\n    }\r\n\r\n    // Sort the variables before showing them\r\n    std::sort(table_.begin(), table_.end());\r\n\r\n    endResetModel();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: K2EnvVarModel::EnvSetting::EnvSetting()\r\n//-----------------------------------------------------------------------------\r\nK2EnvVarModel::EnvSetting::EnvSetting(QString const& name,\r\n    QString const& value,\r\n    QString const& fileSuffix, \r\n    QString const& description,\r\n    bool fromPlugin ):\r\nname_(name),\r\n    value_(value),\r\n    fileSuffix_(fileSuffix),\r\n    description_(description),\r\n    fromPlugin_(fromPlugin)\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: K2EnvVarModel::EnvSetting::EnvSetting()\r\n//-----------------------------------------------------------------------------\r\nK2EnvVarModel::EnvSetting::EnvSetting():\r\nname_(),\r\nvalue_(),\r\nfileSuffix_(),\r\ndescription_(),\r\nfromPlugin_(false)\r\n{\r\n}\r\n\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: K2EnvVarModel::EnvSetting::operator<()\r\n//-----------------------------------------------------------------------------\r\nbool K2EnvVarModel::EnvSetting::operator<( const EnvSetting& other ) const\r\n{\r\n    return name_.compare(other.name_, Qt::CaseInsensitive) < 0;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: K2EnvVarModel::EnvSetting::operator==()\r\n//-----------------------------------------------------------------------------\r\nbool K2EnvVarModel::EnvSetting::operator==( const EnvSetting& other ) const\r\n{\r\n    return name_.compare(other.name_, Qt::CaseInsensitive) == 0;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: K2EnvVarModel::EnvSetting::operator!=()\r\n//-----------------------------------------------------------------------------\r\nbool K2EnvVarModel::EnvSetting::operator!=( const EnvSetting& other ) const\r\n{\r\n    return name_.compare(other.name_, Qt::CaseInsensitive) != 0;\r\n}\r\n"
  },
  {
    "path": "settings/k2envvarmodel.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: k2envvarmodel.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Antti Kamppi\r\n// Date: 05.06.2013\r\n//\r\n// Description:\r\n// Manages the K2 environment variables displayed in the settings dialog.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef K2ENVVARMODEL_H\r\n#define K2ENVVARMODEL_H\r\n\r\n#include <KactusAPI/include/PluginManager.h>\r\n\r\n#include <QAbstractTableModel>\r\n#include <QSettings>\r\n#include <QList>\r\n\r\n//-----------------------------------------------------------------------------\r\n//!  Manages the K2 environment variables displayed in the settings dialog.\r\n//-----------------------------------------------------------------------------\r\nclass K2EnvVarModel : public QAbstractTableModel\r\n{\r\n    Q_OBJECT\r\n\r\npublic:\r\n\r\n    //! Defines the used columns\r\n    enum Columns\r\n    {\r\n        NAME_COLUMN    = 0,\r\n        VALUE_COLUMN,\r\n        FILE_SUFFIX_COLUMN,\r\n        DESCRIPTION_COLUMN,\r\n        COLUMN_COUNT\r\n    };\r\n\r\n    K2EnvVarModel(QSettings& settings, QObject *parent);\r\n    \r\n    //! The destructor.\r\n    virtual ~K2EnvVarModel() = default;\r\n\r\n    //! No copying\r\n    K2EnvVarModel(const K2EnvVarModel& other) = delete;\r\n\r\n    //! No assignment\r\n    K2EnvVarModel& operator=(const K2EnvVarModel& other) = delete;\r\n\r\n    /*!\r\n     *  Save the model to settings.\r\n     *\r\n     *    @param [in] settings    The settings to store to.\r\n     */\r\n    void apply(QSettings& settings);\r\n\r\n    /*! Get the number of rows an item contains.\r\n     *\r\n     *    @param [in] parent Identifies the parent that's row count is requested.\r\n     *\r\n     *    @return Number of rows the item has.\r\n    */\r\n    virtual int rowCount(QModelIndex const& parent = QModelIndex()) const override final;\r\n\r\n    /*! Get the number of columns the item has to be displayed.\r\n     *\r\n     *    @param [in] parent Identifies the parent that's column count is requested.\r\n     *\r\n     *    @return The number of columns to be displayed.\r\n    */\r\n    virtual int columnCount(QModelIndex const& parent = QModelIndex()) const override final;\r\n\r\n    /*! Get the item flags that defines the possible operations for the item.\r\n     *\r\n     *    @param [in] index Model index that identifies the item.\r\n     *\r\n     *    @return Flags specify the possible operations for the item.\r\n    */\r\n    virtual Qt::ItemFlags flags(QModelIndex const& index) const override final;\r\n\r\n    /*! Get the header data for specified header.\r\n     *\r\n     *    @param [in] section The section specifies the row/column number for the header.\r\n     *    @param [in] orientation Specified if horizontal or vertical header is wanted.\r\n     *    @param [in] role Specifies the type of the requested data.\r\n     *\r\n     *    @return The requested data.\r\n    */\r\n    virtual QVariant headerData(int section, Qt::Orientation orientation, \r\n        int role = Qt::DisplayRole) const override final;\r\n\r\n    /*! Get the data for specified item.\r\n     *\r\n     *    @param [in] index Specifies the item that's data is requested.\r\n     *    @param [in] role The role that defines what kind of data is requested.\r\n     *\r\n     *    @return The data for the item.\r\n    */\r\n    virtual QVariant data(QModelIndex const& index, int role = Qt::DisplayRole) const override final;\r\n\r\n    /*! Save the data to the model for specified item\r\n     *\r\n     *    @param [in] index The model index of the item that's data is to be saved.\r\n     *    @param [in] value The data that is to be saved.\r\n     *    @param [in] role The role specifies what kind of data should be saved.\r\n     *\r\n     *    @return True if saving happened successfully.\r\n    */\r\n    virtual bool setData(QModelIndex const& index, const QVariant& value, \r\n        int role = Qt::EditRole) override final;\r\n    /*!\r\n     *  Check that all variables have at least the name defined.\r\n     *\r\n     *    @return True if all defined variables contain a name, otherwise false.\r\n     */\r\n    bool containsEmptyVariables() const;\r\n\r\npublic slots:\r\n\r\n    /*! Add a new item to the given index.\r\n     *\r\n     *    @param [in] index The index identifying the position for new item.\r\n     *\r\n    */\r\n    virtual void onAddItem(QModelIndex const& index);\r\n\r\n    /*! Remove the item in the given index.\r\n     *\r\n     *    @param [in] index The index identifying the item to remove.\r\n     */\r\n    virtual void onRemoveItem(QModelIndex const& index);\r\n\r\nprivate:\r\n    \r\n\r\n    // Loads the model data in place.\r\n    void loadData(QSettings& settings);\r\n\r\n    //! The settings for a single environment variable\r\n    struct EnvSetting {\r\n\r\n        //! The name of the variable.\r\n        QString name_;\r\n\r\n        //! The value for the variable.\r\n        QString value_;\r\n\r\n        //! If the variable if a file path then this is used to define the file suffix.\r\n        QString fileSuffix_;\r\n\r\n        //! Textual description of the variable.\r\n        QString description_;\r\n\r\n        //! Set to true if the variable is requested by the pluging.\r\n        bool fromPlugin_;\r\n\r\n        /*! The constructor.\r\n         *\r\n         *    @param [in] name        The name for the variable.\r\n         *    @param [in] value       The value for the variable.\r\n         *    @param [in] fileSuffix  The file suffix.\r\n         *    @param [in] description Textual description for the variable.\r\n         *    @param [in] fromPlugin  Defines whether the variable is requested by the plugins.\r\n         *\r\n        */\r\n        explicit EnvSetting(QString const& name, \r\n            QString const& value,\r\n            QString const& fileSuffix,\r\n            QString const& description,\r\n            bool fromPlugin);\r\n\r\n        //! The default constructor.\r\n        EnvSetting();\r\n\r\n        //! The destructor.\r\n        ~EnvSetting() = default;\r\n        \r\n        //! Copy constructor\r\n        EnvSetting(const EnvSetting& other) = default;\r\n\r\n        //! Assignment operator\r\n        EnvSetting& operator=(const EnvSetting& other) = default;\r\n\r\n        //! Operator <\r\n        bool operator<(const EnvSetting& other) const;\r\n\r\n        //! Operator ==\r\n        bool operator==(const EnvSetting& other) const;\r\n\r\n        //! Operator !=\r\n        bool operator!=(const EnvSetting& other) const;\r\n    };\r\n\r\n    //! The list of the environment variables which is displayed/edited.\r\n    QList<EnvSetting> table_;\r\n};\r\n\r\n#endif // K2ENVVARMODEL_H\r\n"
  },
  {
    "path": "tests/Core/ComparatorTest.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ComparatorTest.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Esko Pekkarinen\r\n// Date: 21.10.2014\r\n//\r\n// Description:\r\n// Base class for all comparator unit tests.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"ComparatorTest.h\"\r\n\r\n#include <QtTest>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComparatorTest::ComparatorTest()\r\n//-----------------------------------------------------------------------------\r\nComparatorTest::ComparatorTest()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComparatorTest::~ComparatorTest()\r\n//-----------------------------------------------------------------------------\r\nComparatorTest::~ComparatorTest()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComparatorTest::createTestInputsForStringValues()\r\n//-----------------------------------------------------------------------------\r\nvoid ComparatorTest::createTestInputsForStringValues()\r\n{\r\n    QTest::addColumn<QString>(\"referenceValue\");\r\n    QTest::addColumn<QString>(\"subjectValue\");\r\n    QTest::addColumn<bool>(\"expectedComparison\");\r\n\r\n    QTest::newRow(\"Same values\") <<\"0\" << \"0\" << true;\r\n    QTest::newRow(\"Different values\") << \"0\" << \"1\" << false;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComparatorTest::createTestInputForStringListValues()\r\n//-----------------------------------------------------------------------------\r\nvoid ComparatorTest::createTestInputForStringListValues()\r\n{\r\n    QTest::addColumn<QStringList>(\"referenceList\");\r\n    QTest::addColumn<QStringList>(\"subjectList\");\r\n    QTest::addColumn<bool>(\"expectedComparison\");\r\n\r\n    QTest::newRow(\"Identical lists\") << QStringList(\"0\") << QStringList(\"0\") << true;\r\n    QTest::newRow(\"Different lists\") << QStringList(\"0\") << QStringList(\"1\") << false;\r\n\r\n    QStringList shortList;\r\n    shortList << \"0\" << \"1\";\r\n\r\n    QStringList longList;\r\n    longList << \"0\" << \"1\" << \"2\" << \"3\" << \"4\" << \"5\";\r\n\r\n    QTest::newRow(\"Different size lists\") << shortList << longList << false;\r\n\r\n    QStringList inOrder;\r\n    inOrder << \"0\" << \"1\" << \"2\" << \"3\";\r\n\r\n    QStringList outOfOrder;\r\n    outOfOrder << \"1\" << \"3\" << \"0\" << \"2\";\r\n\r\n    QTest::newRow(\"Lists in different order\") << inOrder << outOfOrder << true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComparatorTest::verifyDiffResultIs()\r\n//-----------------------------------------------------------------------------\r\nvoid ComparatorTest::verifyDiffElementAndType(QSharedPointer<IPXactDiff> diff, QString const& expectedElement, \r\n    QString const& expectedName, IPXactDiff::DiffType expectedType) const\r\n{\r\n    QCOMPARE(diff->element(), expectedElement);\r\n    QCOMPARE(diff->name(), expectedName);\r\n    QVERIFY2(diff->changeType() == expectedType, \"Diff returned wrong type.\");\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComparatorTest::verifyModificationIs()\r\n//-----------------------------------------------------------------------------\r\nvoid ComparatorTest::verifyModificationIs(IPXactDiff::Modification const& modification, \r\n    QString const& element, QString const& previousValue, QString const& newValue) const\r\n{\r\n    QCOMPARE(modification.modifiedElement, element);\r\n    QCOMPARE(modification.previousValue, previousValue);\r\n    QCOMPARE(modification.newValue, newValue);\r\n}"
  },
  {
    "path": "tests/Core/ComparatorTest.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ComparatorTest.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Esko Pekkarinen\r\n// Date: 21.10.2014\r\n//\r\n// Description:\r\n// Base class for all comparator unit tests.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef COMPARATORTEST_H\r\n#define COMPARATORTEST_H\r\n\r\n\r\n#include <QSharedPointer>\r\n\r\n#include <wizards/common/IPXactDiff.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Base class for all comparator unit tests.\r\n//-----------------------------------------------------------------------------\r\nclass ComparatorTest \r\n{    \r\n    \r\npublic:\r\n    ComparatorTest();\r\n\r\n    virtual ~ComparatorTest();\r\n   \r\nprotected:\r\n\r\n    virtual void createTestInputsForStringValues();\r\n\r\n    virtual void createTestInputForStringListValues();\r\n\r\n    virtual void verifyDiffElementAndType(QSharedPointer<IPXactDiff> diff, QString const& expectedElement,\r\n        QString const& expectedName, IPXactDiff::DiffType expectedType) const;\r\n\r\n    virtual void verifyModificationIs(IPXactDiff::Modification const& modification, QString const& element, \r\n        QString const& previousValue, QString const& newValue) const;\r\n};\r\n\r\n#endif // COMPARATORTEST_H\r\n"
  },
  {
    "path": "tests/Core/Core.pro",
    "content": "#-----------------------------------------------------------------------------\n# File: Core.pro\n#-----------------------------------------------------------------------------\n# Project: Kactus2\n# Author: Esko Pekkarinen\n# Date: 08.05.2018\n#\n# Description:\n# Qt project file template for running unit tests for Kactus2 core.\n#-----------------------------------------------------------------------------\n\nTEMPLATE = subdirs\n\nCONFIG += testcase\nSUBDIRS += \\\n# tst_CommandLineParser.pro \\\n            tst_SystemVerilogExpressionParser.pro \\\n            tst_IPXactSystemVerilogParser.pro \\\n            tst_ParameterCompleter.pro \\\n            tst_ExpressionEditor.pro \\\n            tst_ValueFormatter.pro \\\n            tst_ComponentParameterModel.pro \\\n            tst_ParameterReferenceTree.pro \\\n            tst_VLNVComparator.pro \\\n            tst_ViewComparator.pro \\\n            tst_PortComparator.pro \\\n            tst_ComponentComparator.pro \\\n            tst_FieldGraphItem.pro \\\n            tst_RegisterGraphItem.pro \\\n            tst_AddressBlockGraphItem.pro \\\n            tst_MemoryMapGraphItem.pro \\\n            tst_HierarchicalSaveBuildStrategy.pro \\\n            tst_DocumentTreeBuilder.pro \\\n            tst_DocumentGenerator.pro \\\n            tst_MarkdownGenerator.pro \\\n            tst_MasterSlavePathSearch.pro\n"
  },
  {
    "path": "tests/Core/tst_AddressBlockGraphItem.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: tst_AddressBlockGraphItem.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Esko Pekkarinen\r\n// Date: 14.04.2015\r\n//\r\n// Description:\r\n// Unit test for class AddressBlockGraphItem.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include <QtTest>\r\n\r\n#include <editors/ComponentEditor/memoryMaps/memoryMapsVisualizer/addressblockgraphitem.h>\r\n#include <editors/ComponentEditor/memoryMaps/memoryMapsVisualizer/registergraphitem.h>\r\n#include <editors/ComponentEditor/visualization/memorygapitem.h>\r\n\r\n#include <KactusAPI/include/NullParser.h>\r\n#include <KactusAPI/include/SystemVerilogExpressionParser.h>\r\n\r\n#include <IPXACTmodels/Component/AddressBlock.h>\r\n#include <IPXACTmodels/Component/Register.h>\r\n#include <IPXACTmodels/Component/RegisterBase.h>\r\n\r\nclass tst_AddressBlockGraphItem : public QObject\r\n{\r\n    Q_OBJECT\r\n\r\npublic:\r\n    tst_AddressBlockGraphItem();\r\n    \r\nprivate slots:\r\n\r\n    void testConstructor();\r\n\r\n    void testAddressBlockWithRegister();\r\n\r\n    void testRegisterInSecondAddress();\r\n\r\n    void testEmptyAfterLastRegister();\r\n\r\n    void testExpressions();\r\n\r\nprivate:\r\n    void expandItem(AddressBlockGraphItem* memoryMapItem);\r\n\r\n    QList<MemoryGapItem*> findMemoryGaps(AddressBlockGraphItem* memoryMapItem);\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_AddressBlockGraphItem::tst_AddressBlockGraphItem()\r\n//-----------------------------------------------------------------------------\r\ntst_AddressBlockGraphItem::tst_AddressBlockGraphItem()\r\n{\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_AddressBlockGraphItem::testConstructor()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_AddressBlockGraphItem::testConstructor()\r\n{\r\n    QSharedPointer<AddressBlock> addressBlock(new AddressBlock());\r\n    addressBlock->setName(\"testBlock\");\r\n    addressBlock->setBaseAddress(0);\r\n    addressBlock->setRange(\"1\");\r\n\r\n    QSharedPointer<ExpressionParser> noParser(new NullParser());\r\n\r\n    AddressBlockGraphItem* addressBlockItem = new AddressBlockGraphItem(addressBlock, noParser, 0);\r\n    \r\n\r\n    QCOMPARE(addressBlockItem->name(), QString(\"testBlock\"));\r\n    QCOMPARE(addressBlockItem->getOffset(), quint64(0));\r\n    QCOMPARE(addressBlockItem->getLastAddress(), quint64(0));\r\n    QCOMPARE(addressBlockItem->getDisplayOffset(), quint64(0));\r\n    QCOMPARE(addressBlockItem->getDisplayLastAddress(), quint64(0));\r\n\r\n    QCOMPARE(addressBlockItem->pos().y(), qreal(0));\r\n\r\n    delete addressBlockItem;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_AddressBlockGraphItem::testMemoryMapWithAddressBlock()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_AddressBlockGraphItem::testAddressBlockWithRegister()\r\n{\r\n    QSharedPointer<AddressBlock> addressBlock(new AddressBlock());\r\n    addressBlock->setBaseAddress(0);\r\n    addressBlock->setRange(\"1\");\r\n\r\n    QSharedPointer<ExpressionParser> noParser(new NullParser());\r\n\r\n    AddressBlockGraphItem* addressBlockItem = new AddressBlockGraphItem(addressBlock, noParser, 0);\r\n    addressBlockItem->setAddressableUnitBits(8);\r\n\r\n    QList<QSharedPointer<RegisterBase> > registers;\r\n    QSharedPointer<Register> reg(new Register());\r\n    reg->setAddressOffset(\"0\");\r\n    reg->setSize(\"8\");\r\n    registers.append(reg);\r\n    addressBlock->getRegisterData()->append(registers);\r\n\r\n    RegisterGraphItem* registerItem = new RegisterGraphItem(reg, noParser, addressBlockItem);\r\n    addressBlockItem->addChild(registerItem);\r\n    addressBlockItem->redoChildLayout();\r\n    \r\n\r\n    QCOMPARE(addressBlockItem->getOffset(), quint64(0));\r\n    QCOMPARE(addressBlockItem->getLastAddress(), quint64(0));\r\n    QCOMPARE(addressBlockItem->getDisplayOffset(), quint64(0));\r\n    QCOMPARE(addressBlockItem->getDisplayLastAddress(), quint64(0));\r\n\r\n    QVERIFY(!registerItem->isVisible());\r\n\r\n    expandItem(addressBlockItem);\r\n\r\n    QVERIFY(registerItem->isVisible());\r\n    QCOMPARE(registerItem->pos().x(), qreal(MemoryVisualizationItem::CHILD_INDENTATION));\r\n    QCOMPARE(registerItem->pos().y(), qreal(VisualizerItem::DEFAULT_HEIGHT));\r\n    QCOMPARE(registerItem->getOffset(), quint64(0));\r\n    QCOMPARE(registerItem->getLastAddress(), quint64(0));\r\n    QCOMPARE(registerItem->getDisplayOffset(), quint64(0));\r\n    QCOMPARE(registerItem->getDisplayLastAddress(), quint64(0));\r\n\r\n    delete addressBlockItem;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_AddressBlockGraphItem::testRegisterInSecondAddress()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_AddressBlockGraphItem::testRegisterInSecondAddress()\r\n{\r\n    QSharedPointer<AddressBlock> addressBlock(new AddressBlock());\r\n    addressBlock->setBaseAddress(0);\r\n    addressBlock->setRange(\"2\");\r\n\r\n    QSharedPointer<ExpressionParser> noParser(new NullParser());\r\n\r\n    AddressBlockGraphItem* addressBlockItem = new AddressBlockGraphItem(addressBlock, noParser, 0);\r\n    addressBlockItem->setAddressableUnitBits(8);\r\n\r\n    QList<QSharedPointer<RegisterBase> > registers;\r\n    QSharedPointer<Register> reg(new Register());\r\n    reg->setAddressOffset(\"1\");\r\n    reg->setSize(\"8\");\r\n    registers.append(reg);\r\n    addressBlock->getRegisterData()->append(registers);\r\n\r\n    RegisterGraphItem* registerItem = new RegisterGraphItem(reg, noParser, addressBlockItem);\r\n    addressBlockItem->addChild(registerItem);\r\n    \r\n    addressBlockItem->redoChildLayout();\r\n    expandItem(addressBlockItem);\r\n\r\n    QList<MemoryGapItem*> gaps = findMemoryGaps(addressBlockItem);\r\n    QCOMPARE(gaps.count(), 1);\r\n\r\n    MemoryGapItem* initialGap = gaps.first();\r\n    QVERIFY(!initialGap->isConflicted());\r\n    QCOMPARE(initialGap->name(), QString(\"Reserved\"));\r\n    QCOMPARE(initialGap->pos().x(), qreal(MemoryVisualizationItem::CHILD_INDENTATION));\r\n    QCOMPARE(initialGap->pos().y(), qreal(VisualizerItem::DEFAULT_HEIGHT));\r\n    QCOMPARE(initialGap->getDisplayOffset(), quint64(0));\r\n    QCOMPARE(initialGap->getDisplayLastAddress(), quint64(0));\r\n\r\n    QVERIFY(registerItem->isVisible());\r\n    QCOMPARE(registerItem->pos().x(), qreal(MemoryVisualizationItem::CHILD_INDENTATION));\r\n    QCOMPARE(registerItem->pos().y(), qreal(2*VisualizerItem::DEFAULT_HEIGHT));\r\n    QCOMPARE(registerItem->getOffset(), quint64(1));\r\n    QCOMPARE(registerItem->getLastAddress(), quint64(1));\r\n    QCOMPARE(registerItem->getDisplayOffset(), quint64(1));\r\n    QCOMPARE(registerItem->getDisplayLastAddress(), quint64(1));\r\n\r\n    delete addressBlockItem;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_AddressBlockGraphItem::testEmptyAfterLastRegister()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_AddressBlockGraphItem::testEmptyAfterLastRegister()\r\n{\r\n    QSharedPointer<AddressBlock> addressBlock(new AddressBlock());\r\n    addressBlock->setBaseAddress(0);\r\n    addressBlock->setRange(\"2\");\r\n\r\n    QSharedPointer<ExpressionParser> noParser(new NullParser());\r\n\r\n    AddressBlockGraphItem* addressBlockItem = new AddressBlockGraphItem(addressBlock, noParser, 0);\r\n    addressBlockItem->setAddressableUnitBits(8);\r\n\r\n    QList<QSharedPointer<RegisterBase> > registers;\r\n    QSharedPointer<Register> reg(new Register());\r\n    reg->setAddressOffset(\"0\");\r\n    reg->setSize(\"8\");\r\n    registers.append(reg);\r\n    addressBlock->getRegisterData()->append(registers);\r\n\r\n\r\n    RegisterGraphItem* registerItem = new RegisterGraphItem(reg, noParser, addressBlockItem);\r\n    addressBlockItem->addChild(registerItem);\r\n\r\n    addressBlockItem->redoChildLayout();\r\n    expandItem(addressBlockItem);\r\n\r\n    QList<MemoryGapItem*> gaps = findMemoryGaps(addressBlockItem);\r\n    QCOMPARE(gaps.count(), 1);\r\n\r\n    QVERIFY(registerItem->isVisible());\r\n    QCOMPARE(registerItem->pos().x(), qreal(MemoryVisualizationItem::CHILD_INDENTATION));\r\n    QCOMPARE(registerItem->pos().y(), qreal(VisualizerItem::DEFAULT_HEIGHT));\r\n    QCOMPARE(registerItem->getOffset(), quint64(0));\r\n    QCOMPARE(registerItem->getLastAddress(), quint64(0));\r\n    QCOMPARE(registerItem->getDisplayOffset(), quint64(0));\r\n    QCOMPARE(registerItem->getDisplayLastAddress(), quint64(0));\r\n\r\n    MemoryGapItem* firstGap = gaps.first();\r\n    QVERIFY(!firstGap->isConflicted());\r\n    QCOMPARE(firstGap->name(), QString(\"Reserved\"));\r\n    QCOMPARE(firstGap->pos().x(), qreal(MemoryVisualizationItem::CHILD_INDENTATION));\r\n    QCOMPARE(firstGap->pos().y(), qreal(2*VisualizerItem::DEFAULT_HEIGHT));\r\n    QCOMPARE(firstGap->getDisplayOffset(), quint64(1));\r\n    QCOMPARE(firstGap->getDisplayLastAddress(), quint64(1));\r\n    delete addressBlockItem;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_AddressBlockGraphItem::testExpressions()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_AddressBlockGraphItem::testExpressions()\r\n{\r\n    QSharedPointer<AddressBlock> addressBlock(new AddressBlock());\r\n    addressBlock->setBaseAddress(\"1+1\");\r\n    addressBlock->setRange(\"4*2\");\r\n    addressBlock->setWidth(\"16+16\");\r\n\r\n    QSharedPointer<ExpressionParser> expressionParser(new SystemVerilogExpressionParser());\r\n\r\n    AddressBlockGraphItem* addressBlockItem = new AddressBlockGraphItem(addressBlock, expressionParser, 0);\r\n    addressBlockItem->setAddressableUnitBits(8);\r\n\r\n\r\n    QCOMPARE(addressBlockItem->getBitWidth(), 32);\r\n    QCOMPARE(addressBlockItem->getDisplayOffset(), quint64(2));\r\n    QCOMPARE(addressBlockItem->getDisplayLastAddress(), quint64(9));\r\n\r\n    delete addressBlockItem;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_MemoryMapGraphItem::expandItem()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_AddressBlockGraphItem::expandItem(AddressBlockGraphItem* addressBlockItem)\r\n{\r\n    GraphicsExpandCollapseItem* expander(0);\r\n    foreach (QGraphicsItem* item, addressBlockItem->childItems())\r\n    {\r\n        if (dynamic_cast<GraphicsExpandCollapseItem*>(item) != 0)\r\n        {\r\n            expander = dynamic_cast<GraphicsExpandCollapseItem*>(item);\r\n            expander->expand();\r\n            return;\r\n        }\r\n    }\r\n}\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_AddressBlockGraphItem::findMemoryGaps()\r\n//-----------------------------------------------------------------------------\r\nQList<MemoryGapItem*> tst_AddressBlockGraphItem::findMemoryGaps(AddressBlockGraphItem* memoryMapItem)\r\n{\r\n    QList<MemoryGapItem*> gaps;\r\n    foreach (QGraphicsItem* child, memoryMapItem->childItems())\r\n    {\r\n        if (dynamic_cast<MemoryGapItem*>(child))\r\n        {\r\n            gaps.append(dynamic_cast<MemoryGapItem*>(child));\r\n        }\r\n    }\r\n\r\n    return gaps;\r\n}\r\n\r\nQTEST_MAIN(tst_AddressBlockGraphItem)\r\n\r\n#include \"tst_AddressBlockGraphItem.moc\"\r\n"
  },
  {
    "path": "tests/Core/tst_AddressBlockGraphItem.pri",
    "content": "# ----------------------------------------------------\r\n# This file is generated by the Qt Visual Studio Tools.\r\n# ------------------------------------------------------\r\n\r\nHEADERS += ../../editors/ComponentEditor/memoryMaps/memoryMapsVisualizer/MemoryBlockGraphItem.h \\\r\n    ../../editors/ComponentEditor/memoryMaps/memoryMapsVisualizer/addressblockgraphitem.h \\\r\n    ../../common/graphicsItems/expandableitem.h \\\r\n    ../../editors/ComponentEditor/visualization/AddressableItem.h \\\r\n    ../../editors/ComponentEditor/visualization/fieldgapitem.h \\\r\n    ../../common/graphicsItems/graphicsexpandcollapseitem.h \\\r\n    ../../editors/ComponentEditor/visualization/memorygapitem.h \\\r\n    ../../editors/ComponentEditor/visualization/memoryvisualizationitem.h \\\r\n    ../../editors/ComponentEditor/memoryMaps/memoryMapsVisualizer/registergraphitem.h \\\r\n    ../../common/graphicsItems/visualizeritem.h\r\nSOURCES += ../../editors/ComponentEditor/memoryMaps/memoryMapsVisualizer/MemoryBlockGraphItem.cpp \\\r\n    ../../editors/ComponentEditor/memoryMaps/memoryMapsVisualizer/addressblockgraphitem.cpp \\\r\n    ../../common/graphicsItems/expandableitem.cpp \\\r\n    ../../editors/ComponentEditor/visualization/AddressableItem.cpp \\\r\n    ../../editors/ComponentEditor/visualization/fieldgapitem.cpp \\\r\n    ../../common/graphicsItems/graphicsexpandcollapseitem.cpp \\\r\n    ../../editors/ComponentEditor/visualization/memorygapitem.cpp \\\r\n    ../../editors/ComponentEditor/visualization/memoryvisualizationitem.cpp \\\r\n    ../../editors/ComponentEditor/memoryMaps/memoryMapsVisualizer/registergraphitem.cpp \\\r\n    ../../common/graphicsItems/visualizeritem.cpp \\\r\n    ./tst_AddressBlockGraphItem.cpp\r\n"
  },
  {
    "path": "tests/Core/tst_AddressBlockGraphItem.pro",
    "content": "#-----------------------------------------------------------------------------\r\n# File: tst_AddressBlockGraphItem.pro\r\n#-----------------------------------------------------------------------------\r\n# Project: Kactus 2\r\n# Author: Esko Pekkarinen\r\n# Date: 20.03.2015\r\n#\r\n# Description:\r\n# Qt project file template for running unit tests for AddressBlockGraphItem.\r\n#-----------------------------------------------------------------------------\r\n\r\nTEMPLATE = app\r\n\r\nTARGET = tst_AddressBlockGraphItem\r\n\r\nDEFINES+=KACTUS2_EXPORTS\r\n\r\nQT += core xml gui testlib widgets\r\nCONFIG += c++11 testcase console\r\n\r\nQMAKE_EXPORTED_VARIABLES += MAKE_TESTARGS\r\nMAKE_TESTARGS.name = TESTARGS\r\nMAKE_TESTARGS.value = \"-platform offscreen\"\r\n\r\nwin32:CONFIG(release, debug|release) {\r\n    LIBS += -L$$PWD/../../executable/ -lIPXACTmodels -lKactusAPI\r\n    DESTDIR = ./release\r\n}\r\nelse:win32:CONFIG(debug, debug|release) {\r\n    LIBS += -L$$PWD/../../executable/ -lIPXACTmodelsd -lKactusAPId\r\n    DESTDIR = ./debug\r\n}\r\nelse:unix {\r\n    LIBS += -L$$PWD/../../executable/ -lIPXACTmodels -lKactusAPI\r\n    DESTDIR = ./release\r\n}\r\n\r\nINCLUDEPATH += $$PWD/../../\r\nINCLUDEPATH += $$PWD/../../executable\r\nINCLUDEPATH += $$DESTDIR\r\n\r\nDEPENDPATH += $$PWD/../../\r\nDEPENDPATH += $$PWD/../../executable\r\nDEPENDPATH += .\r\n\r\nOBJECTS_DIR += $$DESTDIR\r\n\r\nMOC_DIR += ./generatedFiles\r\nUI_DIR += ./generatedFiles\r\nRCC_DIR += ./generatedFiles\r\ninclude(tst_AddressBlockGraphItem.pri)\r\n"
  },
  {
    "path": "tests/Core/tst_CommandLineParser.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: tst_CommandLineParser.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Esko Pekkarinen\n// Date: 28.03.2018\n//\n// Description:\n// Unit test for class CommandLineParser.\n//-----------------------------------------------------------------------------\n\n#include <QtTest>\n\n#include <tests/MockObjects/PluginMock.h>\n\n#include <KactusAPI/KactusAPI.h>\n#include <KactusAPI/include/PluginManager.h>\n#include <Plugins/PluginSystem/GeneratorPlugin/MessagePasser.h>\n\n#include <mainwindow/CommandLineParser.h>\n\nclass tst_CommandLineParser : public QObject\n{\n    Q_OBJECT\n\npublic:\n    tst_CommandLineParser();\n\npublic slots:\n\n    void writeToLog(QString const& msg);\n\nprivate:\n    MessagePasser mediator_;\n    PluginMock* testPlugin_;\n    QStringList log_;\n\nprivate slots:\n    void initTestCase();\n    void cleanup();\n    void cleanupTestCase();\n\n    void testShowVersion();\n    void testShowVersion_data();\n\n    void testRunPluginCommand();\n    void testPluginHelp();\n\n    void testShowUsage();\n    void testShowUsage_data();\n\n};\n\ntst_CommandLineParser::tst_CommandLineParser(): QObject(0),\n    mediator_(),\n    testPlugin_(new PluginMock()),\n    log_()\n{\n    connect(&mediator_, SIGNAL(noticeMessage(QString const&)), this, SLOT(writeToLog(QString const&)));\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_CommandLineParser::writeToLog()\n//-----------------------------------------------------------------------------\nvoid tst_CommandLineParser::writeToLog(QString const& msg)\n{\n    log_.append(msg);\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_CommandLineParser::initTestCase()\n//-----------------------------------------------------------------------------\nvoid tst_CommandLineParser::initTestCase()\n{\n    QSettings testSettings(\"tst_CommandLineParser.ini\");\n    QSettings::setDefaultFormat(QSettings::IniFormat);\n\n    PluginManager& plugins = PluginManager::getInstance();\n    plugins.addPlugin(testPlugin_);\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_CommandLineParser::cleanup()\n//-----------------------------------------------------------------------------\nvoid tst_CommandLineParser::cleanup()\n{\n    log_.clear();\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_CommandLineParser::cleanupTestCase()\n//-----------------------------------------------------------------------------\nvoid tst_CommandLineParser::cleanupTestCase()\n{\n    delete testPlugin_;\n}\n\n\n//-----------------------------------------------------------------------------\n// Function: tst_CommandLineParser::testShowVersion()\n//-----------------------------------------------------------------------------\nvoid tst_CommandLineParser::testShowVersion()\n{\n    QFETCH(QString, input);\n\n    QStringList arguments = input.split(QLatin1Char(' '));\n    CommandLineParser parser;\n    parser.process(arguments, &mediator_);\n\n    QString expected = KactusAPI::getVersion() + QStringLiteral(\" Copyright (C) 2023 Tampere University\\n\"\n        \"License GPL2: GNU GPL version 2 <https://gnu.org/licenses/gpl.html>\\n\");\n\n    QCOMPARE(log_.count(), 1);\n    QCOMPARE(log_.first(), expected);\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_CommandLineParser::testShowVersion_data()\n//-----------------------------------------------------------------------------\nvoid tst_CommandLineParser::testShowVersion_data()\n{\n    QTest::addColumn<QString>(\"input\");\n\n    QTest::newRow(\"-v option\") << \"tst_CommandLineParser -v\";\n    QTest::newRow(\"--version option\") << \"tst_CommandLineParser --version\";\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_CommandLineParser::testRunPluginCommand()\n//-----------------------------------------------------------------------------\nvoid tst_CommandLineParser::testRunPluginCommand()\n{\n    QString input(\"testApp mock\");\n\n    CommandLineParser parser; \n    parser.process(input.split(QLatin1Char(' ')), &mediator_);\n\n    QFile settingsFile(\"tst_CommandLineParser.ini\");\n    if (settingsFile.exists())\n    {\n        settingsFile.remove();\n    }\n\n    QVERIFY(settingsFile.exists() == false);\n    QCOMPARE(log_.count(), 1);\n    QCOMPARE(log_.first(), QStringLiteral(\"mock\"));\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_CommandLineParser::testPluginHelp()\n//-----------------------------------------------------------------------------\nvoid tst_CommandLineParser::testPluginHelp()\n{\n    QString input(\"testApp mock -h\");\n\n    CommandLineParser parser; \n    parser.process(input.split(QLatin1Char(' ')), &mediator_);\n\n    QFile settingsFile(\"tst_CommandLineParser.ini\");\n    if (settingsFile.exists())\n    {\n        settingsFile.remove();\n    }\n\n    QVERIFY(settingsFile.exists() == false);\n    QCOMPARE(log_.count(), 1);\n    QCOMPARE(log_.first(), QStringLiteral(\"mock -h\"));\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_CommandLineParser::testShowUsage()\n//-----------------------------------------------------------------------------\nvoid tst_CommandLineParser::testShowUsage()\n{\n    QFETCH(QString, input);\n\n    QStringList arguments = input.split(QLatin1Char(' '));\n    CommandLineParser parser;\n    parser.process(arguments, &mediator_);\n\n    QString expected(\n        \"Usage: Kactus2 <command> [options]\\n\"\n        \"Kactus2 is a design environment for IP-XACT based SoC design.\\n\"\n        \"Running Kactus2 without any options opens the graphical user interface.\\n\"\n        \"\\n\"\n        \"Arguments:\\n\"\n        \"  command         The command to run.\\n\"\n        \"\\n\"\n        \"The available commands are:\\n\"\n        \"  mock\\n\"\n        \"\\n\"\n        \"The command may require additional options. See 'Kactus2 <command> -h'\\n\"\n        \"for command-specific information.\\n\"\n        \"\\n\"\n        \"Options:\\n\"\n        \"  -h, --help  Displays this help.\\n\"\n        \"  -v, --version   Displays version information.\\n\"\n    );\n\n    QCOMPARE(log_.count(), 1);\n    QCOMPARE(log_.first(), expected);\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_CommandLineParser::testShowUsage_data()\n//-----------------------------------------------------------------------------\nvoid tst_CommandLineParser::testShowUsage_data()\n{\n    QTest::addColumn<QString>(\"input\");\n\n    QTest::newRow(\"-h option\") << \"tst_CommandLineParser -h\";\n    QTest::newRow(\"--help option\") << \"tst_CommandLineParser --help\";\n}\nQTEST_MAIN(tst_CommandLineParser)\n\n#include \"tst_CommandLineParser.moc\"\n"
  },
  {
    "path": "tests/Core/tst_CommandLineParser.pri",
    "content": "# ----------------------------------------------------\n# This file is generated by the Qt Visual Studio Add-in.\n# ------------------------------------------------------\n\nHEADERS += ../../Plugins/PluginSystem/PluginManager.h \\\n    ../../Plugins/PluginSystem/PluginUtilityAdapter.h \\\n    ../MockObjects/LibraryMock.h \\\n    ../../mainwindow/CommandLineParser.h \\\n    ../../Plugins/PluginSystem/GeneratorPlugin/MessagePasser.h \\\n    ../MockObjects/PluginMock.h\nSOURCES += ../../Plugins/PluginSystem/PluginManager.cpp \\\n    ../../mainwindow/CommandLineParser.cpp \\\n    ../../Plugins/PluginSystem/GeneratorPlugin/MessagePasser.cpp \\\n    ../MockObjects/LibraryMock.cpp \\\n    ../../Plugins/PluginSystem/PluginUtilityAdapter.cpp \\\n    ./tst_CommandLineParser.cpp \\\n    ../MockObjects/PluginMock.cpp\n"
  },
  {
    "path": "tests/Core/tst_CommandLineParser.pro",
    "content": "#-----------------------------------------------------------------------------\n# File: tst_CommandLineParser.pro\n#-----------------------------------------------------------------------------\n# Project: Kactus2\n# Author: Esko Pekkarinen\n# Date: 28.03.2018\n#\n# Description:\n# Qt project file template for running unit tests for a single module.\n#-----------------------------------------------------------------------------\n\nTEMPLATE = app\n\nTARGET = tst_CommandLineParser\n\nQT += core xml gui testlib widgets\nCONFIG += c++11 testcase console\n\nQMAKE_EXPORTED_VARIABLES += MAKE_TESTARGS\nMAKE_TESTARGS.name = TESTARGS\nMAKE_TESTARGS.value = \"-platform offscreen\"\n\nwin32:CONFIG(release, debug|release) {\n    LIBS += -L$$PWD/../../executable/ -lIPXACTmodels\n    DESTDIR = ./release\n}\nelse:win32:CONFIG(debug, debug|release) {\n    LIBS += -L$$PWD/../../executable/ -lIPXACTmodelsd\n    DESTDIR = ./debug\n}\nelse:unix {\n    LIBS += -L$$PWD/../../executable/ -lIPXACTmodels\n    DESTDIR = ./release\n}\n\nINCLUDEPATH += $$DESTDIR\nINCLUDEPATH += ../../\n\nDEPENDPATH += .\nDEPENDPATH += ../../\n\nOBJECTS_DIR += $$DESTDIR\n\nMOC_DIR += ./generatedFiles\nUI_DIR += ./generatedFiles\nRCC_DIR += ./generatedFiles\ninclude(tst_CommandLineParser.pri)\n"
  },
  {
    "path": "tests/Core/tst_ComponentComparator.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: tst_ComponentComparator.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Esko Pekkarinen\r\n// Date: 16.10.2014\r\n//\r\n// Description:\r\n// Unit test for class ComponentComparator.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include <QtTest>\r\n\r\n#include <QSharedPointer>\r\n\r\n#include <IPXACTmodels/Component/Component.h>\r\n#include <IPXACTmodels/Component/Model.h>\r\n#include <IPXACTmodels/common/VLNV.h>\r\n\r\n#include <wizards/common/ComponentComparator/ComponentComparator.h>\r\n#include <wizards/common/IPXactDiff.h>\r\n\r\n#include \"ComparatorTest.h\"\r\n\r\nclass tst_ComponentComparator : public QObject, public ComparatorTest\r\n{\r\n    Q_OBJECT\r\n\r\npublic:\r\n    tst_ComponentComparator();\r\n\r\nprivate slots:\r\n    void initTestCase();\r\n    void cleanupTestCase();\r\n\r\n    void testComparingTwoNullsAreEquivalent();\r\n    void testComparingNullToEmptyElementIsNotEquivalent();\r\n    void testComparingWithSelfIsEquivalent();\r\n\r\n    void testComparingWithDifferentVLNVIsNotEqual();\r\n    void testComparingWithDifferentVLNVIsNotEqual_data();\r\n\r\n    void testViewInOneComponentIsNotEqual();\r\n    void testDifferentViewsIsNotEqual();\r\n    \r\n    void testDifferentNumberOfViewsIsNotEqual();\r\n \r\n    void testDiffOfTwoNullsIsNoChange();\r\n\r\n    void testDiffToSameComponentIsNoChange();\r\n    void testDiffToNullReferenceIsAdd();\r\n    void testDiffToNullComponentIsRemove();\r\n\r\n    void testDiffViewInSubjectComponentIsAdd();\r\n    void testDiffViewInReferenceComponentIsRemove();\r\n    void testDiffToSameViewIsNoChange();\r\n\r\n    void testDiffMultipleViewsChanged();\r\n\r\nprivate:\r\n\r\n    ComponentComparator* makeComparator();\r\n\r\n    //! The comparator to test.\r\n    ComponentComparator* comparator_;\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ComponentComparator::tst_ComponentComparator()\r\n//-----------------------------------------------------------------------------\r\ntst_ComponentComparator::tst_ComponentComparator()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ComponentComparator::initTestCase()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ComponentComparator::initTestCase()\r\n{\r\n    comparator_ = makeComparator();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ComponentComparator::cleanupTestCase()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ComponentComparator::cleanupTestCase()\r\n{\r\n    delete comparator_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ComponentComparator::makeComparator()\r\n//-----------------------------------------------------------------------------\r\nComponentComparator* tst_ComponentComparator::makeComparator()\r\n{\r\n    return new ComponentComparator;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ComponentComparator::testComparingTwoNullsAreEquivalent()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ComponentComparator::testComparingTwoNullsAreEquivalent()\r\n{\r\n    QVERIFY2(comparator_->compare(QSharedPointer<Component>(0), QSharedPointer<Component>(0)),\r\n        \"Two nulls should be equal.\");\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ComponentComparator::testComparingNullToEmptyElementIsNotEquivalent()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ComponentComparator::testComparingNullToEmptyElementIsNotEquivalent()\r\n{\r\n    QSharedPointer<Component> component(new Component(VLNV(), Document::Revision::Std14));\r\n\r\n    QVERIFY2(!comparator_->compare(QSharedPointer<Component>(0), component), \r\n        \"Comparison to null should not be equal.\");\r\n    QVERIFY2(!comparator_->compare(component, QSharedPointer<Component>(0)), \r\n        \"Comparison to null should not be equal.\");\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ComponentComparator::testComparingWithSelfIsEquivalent()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ComponentComparator::testComparingWithSelfIsEquivalent()\r\n{\r\n    QSharedPointer<Component> component(new Component(VLNV(), Document::Revision::Std14));\r\n    QVERIFY2(comparator_->compare(component, component), \"Comparing with self should be equal.\");\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ComponentComparator::testComparingWithDifferentVLNVIsNotEqual()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ComponentComparator::testComparingWithDifferentVLNVIsNotEqual()\r\n{\r\n    QFETCH(QString, vlnv);    \r\n\r\n    QSharedPointer<Component> reference(new Component(VLNV(VLNV::COMPONENT, \"TUT:Tests:TestComponent:1.0\"), Document::Revision::Std14));   \r\n    QSharedPointer<Component> component(new Component(VLNV(VLNV::COMPONENT, vlnv), Document::Revision::Std14));   \r\n\r\n    QVERIFY2(!comparator_->compare(reference, component), \"Components with different VLVN should not be equal.\");\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ComponentComparator::testComparingWithDifferentVLNVIsNotEqual_data()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ComponentComparator::testComparingWithDifferentVLNVIsNotEqual_data()\r\n{\r\n    QTest::addColumn<QString>(\"vlnv\");    \r\n\r\n    QTest::newRow(\"Empty VLNV\")  << \":::\";\r\n    QTest::newRow(\"Different vendor\") << \"X:Tests:TestComponent:1.0\";\r\n    QTest::newRow(\"Different library\") << \"TUT:X:TestComponent:1.0\";\r\n    QTest::newRow(\"Different name\") << \"TUT:Tests:X:1.0\";\r\n    QTest::newRow(\"Different version\") << \"TUT:Tests:TestComponent:X\";\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ComponentComparator::testViewInOneComponentIsNotEqual()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ComponentComparator::testViewInOneComponentIsNotEqual()\r\n{\r\n    QSharedPointer<Component> reference(new Component(VLNV(), Document::Revision::Std14));\r\n    reference->getViews()->append(QSharedPointer<View>(new View()));\r\n\r\n    QSharedPointer<Component> component(new Component(VLNV(), Document::Revision::Std14));\r\n\r\n    QVERIFY2(!comparator_->compare(reference, component), \r\n        \"Components with view in other should not be equal.\");\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ComponentComparator::testDifferentViewsIsNotEqual()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ComponentComparator::testDifferentViewsIsNotEqual()\r\n{\r\n    QSharedPointer<Component> reference(new Component(VLNV(), Document::Revision::Std14));\r\n    reference->getViews()->append(QSharedPointer<View>(new View(\"view1\")));\r\n    reference->getViews()->append(QSharedPointer<View>(new View(\"view2\")));\r\n\r\n    QSharedPointer<Component> component(new Component(VLNV(), Document::Revision::Std14));\r\n    component->getViews()->append(QSharedPointer<View>(new View(\"view1\")));\r\n    component->getViews()->append(QSharedPointer<View>(new View(\"unknown view\")));\r\n\r\n    QVERIFY2(!comparator_->compare(reference, component), \r\n        \"Components with different views should not be equal.\");\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ComponentComparator::testDifferentNumberOfViewsIsNotEqual()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ComponentComparator::testDifferentNumberOfViewsIsNotEqual()\r\n{\r\n    QSharedPointer<Component> reference(new Component(VLNV(), Document::Revision::Std14));\r\n    reference->getViews()->append(QSharedPointer<View>(new View(\"0\")));\r\n\r\n    QSharedPointer<Component> component(new Component(VLNV(), Document::Revision::Std14));\r\n    component->getViews()->append(QSharedPointer<View>(new View(\"0\")));\r\n    component->getViews()->append(QSharedPointer<View>(new View(\"1\")));\r\n\r\n    QVERIFY2(!comparator_->compare(reference, component), \r\n        \"Components with views in different order should be equal.\");\r\n}\r\n\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ComponentComparator::testDiffOfTwoNullsIsNoChange()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ComponentComparator::testDiffOfTwoNullsIsNoChange()\r\n{\r\n    QList<QSharedPointer<IPXactDiff> > diff = comparator_->diff(QSharedPointer<Component>(0), \r\n        QSharedPointer<Component>(0));\r\n\r\n    QCOMPARE(diff.count(), 1);\r\n    verifyDiffElementAndType(diff.first(), \"component\", \"\", IPXactDiff::NO_CHANGE);   \r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ComponentComparator::testDiffToSameComponentIsNoChange()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ComponentComparator::testDiffToSameComponentIsNoChange()\r\n{\r\n    QSharedPointer<Component> component(new Component(VLNV(), Document::Revision::Std14));\r\n\r\n    QList<QSharedPointer<IPXactDiff> > diff = comparator_->diff(component, component);\r\n\r\n    QCOMPARE(diff.count(), 1);\r\n    verifyDiffElementAndType(diff.first(), \"component\", \"\", IPXactDiff::NO_CHANGE);   \r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ComponentComparator::testDiffToNullReferenceIsAdd()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ComponentComparator::testDiffToNullReferenceIsAdd()\r\n{\r\n    QSharedPointer<Component> component(new Component(VLNV(), Document::Revision::Std14));\r\n\r\n    QList<QSharedPointer<IPXactDiff> > diff = comparator_->diff(QSharedPointer<Component>(0), component);\r\n\r\n    QCOMPARE(diff.count(), 1);\r\n    verifyDiffElementAndType(diff.first(), \"component\", \"\", IPXactDiff::ADD);     \r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ComponentComparator::testDiffToNullComponentIsRemove()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ComponentComparator::testDiffToNullComponentIsRemove()\r\n{\r\n    QSharedPointer<Component> component(new Component(VLNV(), Document::Revision::Std14));\r\n\r\n    QList<QSharedPointer<IPXactDiff> > diff = comparator_->diff(component, QSharedPointer<Component>(0));\r\n\r\n    QCOMPARE(diff.count(), 1);\r\n    verifyDiffElementAndType(diff.first(), \"component\", \"\", IPXactDiff::REMOVE);   \r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ComponentComparator::testDiffViewInSubjectComponentIsAdd()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ComponentComparator::testDiffViewInSubjectComponentIsAdd()\r\n{\r\n    QSharedPointer<Component> reference(new Component(VLNV(), Document::Revision::Std14));\r\n    \r\n    QSharedPointer<Component> subject(new Component(VLNV(), Document::Revision::Std14));\r\n    subject->getViews()->append(QSharedPointer<View>(new View(\"testView\")));\r\n\r\n    QList<QSharedPointer<IPXactDiff> > diff = comparator_->diff(reference, subject);\r\n\r\n    QCOMPARE(diff.count(), 1);\r\n    verifyDiffElementAndType(diff.first(), \"view\", \"testView\", IPXactDiff::ADD);   \r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ComponentComparator::testDiffViewInReferenceComponentIsRemove()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ComponentComparator::testDiffViewInReferenceComponentIsRemove()\r\n{\r\n    QSharedPointer<Component> reference(new Component(VLNV(), Document::Revision::Std14));\r\n    reference->getViews()->append(QSharedPointer<View>(new View(\"testView\")));\r\n\r\n    QSharedPointer<Component> subject(new Component(VLNV(), Document::Revision::Std14));\r\n\r\n    QList<QSharedPointer<IPXactDiff> > diff = comparator_->diff(reference, subject);\r\n\r\n    QCOMPARE(diff.count(), 1);\r\n    verifyDiffElementAndType(diff.first(), \"view\", \"testView\", IPXactDiff::REMOVE);   \r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ComponentComparator::testDiffToSameViewIsNoChange()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ComponentComparator::testDiffToSameViewIsNoChange()\r\n{\r\n    QSharedPointer<Component> reference(new Component(VLNV(), Document::Revision::Std14));\r\n    reference->getViews()->append(QSharedPointer<View>(new View()));\r\n\r\n    QSharedPointer<Component> subject(new Component(VLNV(), Document::Revision::Std14));\r\n    subject->getViews()->append(QSharedPointer<View>(new View()));\r\n\r\n    QList<QSharedPointer<IPXactDiff> > diff = comparator_->diff(reference, subject);\r\n\r\n    QCOMPARE(diff.count(), 1);\r\n    verifyDiffElementAndType(diff.first(), \"component\", \"\", IPXactDiff::NO_CHANGE);   \r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ComponentComparator::testDiffMultipleViewsChanged()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ComponentComparator::testDiffMultipleViewsChanged()\r\n{\r\n    QSharedPointer<Component> reference(new Component(VLNV(), Document::Revision::Std14));\r\n    reference->getViews()->append(QSharedPointer<View>(new View(\"view1\")));\r\n    reference->getViews()->append(QSharedPointer<View>(new View(\"view2\")));\r\n\r\n    QSharedPointer<Component> subject(new Component(VLNV(), Document::Revision::Std14));\r\n    subject->getViews()->append(QSharedPointer<View>(new View(\"view2\")));    \r\n    subject->getViews()->first()->addEnvIdentifier(\r\n        QSharedPointer<View::EnvironmentIdentifier>(new View::EnvironmentIdentifier(QStringLiteral(\"lang\"))));\r\n    subject->getViews()->append(QSharedPointer<View>(new View(\"view3\")));    \r\n    subject->getViews()->append(QSharedPointer<View>(new View(\"view4\")));    \r\n\r\n    QList<QSharedPointer<IPXactDiff> > diff = comparator_->diff(reference, subject);\r\n\r\n    QCOMPARE(diff.count(), 4);\r\n\r\n    verifyDiffElementAndType(diff.at(0), \"view\", \"view1\", IPXactDiff::REMOVE);\r\n    verifyDiffElementAndType(diff.at(1), \"view\", \"view2\", IPXactDiff::MODIFICATION);\r\n    verifyDiffElementAndType(diff.at(2), \"view\", \"view3\", IPXactDiff::ADD);\r\n    verifyDiffElementAndType(diff.at(3), \"view\", \"view4\", IPXactDiff::ADD);\r\n}\r\n\r\n\r\nQTEST_APPLESS_MAIN(tst_ComponentComparator)\r\n\r\n#include \"tst_ComponentComparator.moc\"\r\n    "
  },
  {
    "path": "tests/Core/tst_ComponentComparator.pri",
    "content": "# ----------------------------------------------------\r\n# This file is generated by the Qt Visual Studio Add-in.\r\n# ------------------------------------------------------\r\n\r\nHEADERS += ./ComparatorTest.h \\\r\n    ../../wizards/common/ComponentComparator/ComponentComparator.h \\\r\n    ../../wizards/common/IPXactDiff.h \\\r\n    ../../wizards/common/IPXactElementComparator.h \\\r\n    ../../wizards/common/ListComparator.h \\\r\n    ../../wizards/common/ParameterComparator/ParameterComparator.h \\\r\n    ../../wizards/common/PortComparator/PortComparator.h \\\r\n    ../../wizards/common/VLNVComparator/VLNVComparator.h \\\r\n    ../../wizards/common/ViewComparator/ViewComparator.h\r\n\r\nSOURCES += ./ComparatorTest.cpp \\\r\n    ../../wizards/common/ComponentComparator/ComponentComparator.cpp \\\r\n    ../../wizards/common/IPXactDiff.cpp \\\r\n    ../../wizards/common/ParameterComparator/ParameterComparator.cpp \\\r\n    ../../wizards/common/PortComparator/PortComparator.cpp \\\r\n    ../../wizards/common/VLNVComparator/VLNVComparator.cpp \\\r\n    ../../wizards/common/ViewComparator/ViewComparator.cpp \\\r\n    ./tst_ComponentComparator.cpp\r\n"
  },
  {
    "path": "tests/Core/tst_ComponentComparator.pro",
    "content": "#-----------------------------------------------------------------------------\r\n# File: tst_ComponentComparator.pro\r\n#-----------------------------------------------------------------------------\r\n# Project: Kactus 2\r\n# Author: Esko Pekkarinen\r\n# Date: 16.10.2014\r\n#\r\n# Description:\r\n# Qt project file template for running unit tests for a ComponentComparator.\r\n#-----------------------------------------------------------------------------\r\n\r\nTEMPLATE = app\r\n\r\nTARGET = tst_ComponentComparator\r\n\r\nQT += core xml testlib\r\nQT -= gui\r\n\r\nCONFIG += c++11 testcase console\r\n\r\nwin32:CONFIG(release, debug|release) {\r\n    LIBS += -L$$PWD/../../executable/ -lIPXACTmodels\r\n    DESTDIR = ./release\r\n}\r\nelse:win32:CONFIG(debug, debug|release) {\r\n    LIBS += -L$$PWD/../../executable/ -lIPXACTmodelsd\r\n    DESTDIR = ./debug\r\n}\r\nelse:unix {\r\n    LIBS += -L$$PWD/../../executable/ -lIPXACTmodels\r\n    DESTDIR = ./release\r\n}\r\n\r\nINCLUDEPATH += $$PWD/../\r\nINCLUDEPATH += $$PWD/../../\r\nINCLUDEPATH += $$PWD/../../executable\r\nINCLUDEPATH += $$PWD/../../executable/Plugins\r\nINCLUDEPATH += $$DESTDIR\r\n\r\nDEPENDPATH += $$PWD/../../\r\nDEPENDPATH += $$PWD/../../executable\r\nDEPENDPATH += $$PWD/../../executable/Plugins\r\n\r\nOBJECTS_DIR += $$DESTDIR\r\n\r\nMOC_DIR += ./generatedFiles\r\nUI_DIR += ./generatedFiles\r\nRCC_DIR += ./generatedFiles\r\ninclude(tst_ComponentComparator.pri)\r\n"
  },
  {
    "path": "tests/Core/tst_ComponentParameterModel.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: tst_ComponentParameterModel.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Esko Pekkarinen\r\n// Date: 13.01.2015\r\n//\r\n// Description:\r\n// Unit test for class ComponentParameterModel.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include <QtTest>\r\n\r\n#include <QModelIndex>\r\n#include <QVariant>\r\n\r\n#include <editors/ComponentEditor/parameters/ComponentParameterModel.h>\r\n#include <editors/ComponentEditor/parameters/ComponentParameterColumns.h>\r\n\r\n#include <KactusAPI/include/IPXactSystemVerilogParser.h>\r\n\r\n#include <KactusAPI/include/ComponentParameterFinder.h>\r\n\r\n#include <IPXACTmodels/Component/Component.h>\r\n#include <IPXACTmodels/common/Parameter.h>\r\n\r\nclass tst_ComponentParameterModel : public QObject\r\n{\r\n    Q_OBJECT\r\n\r\npublic:\r\n    tst_ComponentParameterModel();\r\n\r\nprivate slots:\r\n    void testHasRowForEachTopLevelParameter();\r\n    void testHasRowForEachTopLevelParameter_data();     \r\n    void testHasColumnForNameAndId();\r\n    void testFunctionAsValue();\r\n\r\nprivate:\r\n    ComponentParameterModel* make(QSharedPointer<Component> component);\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ComponentParameterModel::()\r\n//-----------------------------------------------------------------------------\r\ntst_ComponentParameterModel::tst_ComponentParameterModel()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ComponentParameterModel::testHasRowForEachTopLevelParameter()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ComponentParameterModel::testHasRowForEachTopLevelParameter()\r\n{\r\n    QFETCH(int, parameterCount);\r\n\r\n    QList<QSharedPointer<Parameter> > parameters;\r\n\r\n    for (int i = 0; i < parameterCount; i++)\r\n    {\r\n        parameters.append(QSharedPointer<Parameter>(new Parameter()));\r\n    }\r\n\r\n    QSharedPointer<Component> component(new Component(VLNV(), Document::Revision::Std14));\r\n    component->getParameters()->append(parameters);\r\n\r\n    ComponentParameterModel* model = make(component);\r\n\r\n    QCOMPARE(model->rowCount(), parameterCount);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ComponentParameterModel::testHasRowForEachTopLevelParameter_data()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ComponentParameterModel::testHasRowForEachTopLevelParameter_data()\r\n{\r\n    QTest::addColumn<int>(\"parameterCount\");\r\n\r\n    QTest::newRow(\"no parameters\") << 0;\r\n    QTest::newRow(\"single parameter\") << 1;\r\n    QTest::newRow(\"multiple parameters\") << 4;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ComponentParameterModel::testHasColumnForNameValueAndId()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ComponentParameterModel::testHasColumnForNameAndId()\r\n{\r\n    QSharedPointer<Parameter> testParameter(new Parameter());\r\n    testParameter->setName(\"testParameter\");\r\n    testParameter->setValueId(\"testId\");\r\n    testParameter->setValue(\"1\");\r\n\r\n    QList<QSharedPointer<Parameter> > parameters;\r\n    parameters.append(testParameter);\r\n   \r\n    QSharedPointer<Component> component(new Component(VLNV(), Document::Revision::Std14));\r\n    component->getParameters()->append(parameters);\r\n\r\n    ComponentParameterModel* model = make(component);\r\n\r\n    QCOMPARE(model->columnCount(), 2);\r\n    QCOMPARE(model->data(model->index(0, ComponentParameterColumns::NAME)).toString(), QString(\"testParameter\"));\r\n    QCOMPARE(model->data(model->index(0, ComponentParameterColumns::ID)).toString(), QString(\"testId\"));\r\n\r\n    QCOMPARE(model->data(QModelIndex()).toString(), QString(\"\"));\r\n    QCOMPARE(model->data(model->index(42, ComponentParameterColumns::NAME)).toString(), QString(\"\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ComponentParameterModel::testFunctionAsValue()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ComponentParameterModel::testFunctionAsValue()\r\n{\r\n    QSharedPointer<Parameter> testParameter(new Parameter());\r\n    testParameter->setName(\"testParameter\");\r\n    testParameter->setValueId(\"testId\");\r\n    testParameter->setValue(\"1+1\");\r\n\r\n    QList<QSharedPointer<Parameter> > parameters;\r\n    parameters.append(testParameter);\r\n\r\n    QSharedPointer<Component> component(new Component(VLNV(), Document::Revision::Std14));\r\n    component->getParameters()->append(parameters);\r\n\r\n    ComponentParameterModel* model = make(component);\r\n\r\n    QCOMPARE(model->data(model->index(0, ComponentParameterColumns::NAME)).toString(), QString(\"testParameter\"));\r\n    QCOMPARE(model->data(model->index(0, ComponentParameterColumns::ID)).toString(), QString(\"testId\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ComponentParameterModel::make()\r\n//-----------------------------------------------------------------------------\r\nComponentParameterModel* tst_ComponentParameterModel::make(QSharedPointer<Component> component)\r\n{\r\n    QSharedPointer<ParameterFinder> parameterFinder(new ComponentParameterFinder(component));\r\n\r\n    ComponentParameterModel* model = new ComponentParameterModel(parameterFinder, this);\r\n    \r\n    QSharedPointer<ExpressionParser> parser(new IPXactSystemVerilogParser(parameterFinder));\r\n    model->setExpressionParser(parser);\r\n    \r\n    return model;\r\n}\r\n\r\nQTEST_APPLESS_MAIN(tst_ComponentParameterModel)\r\n\r\n#include \"tst_ComponentParameterModel.moc\"\r\n"
  },
  {
    "path": "tests/Core/tst_ComponentParameterModel.pri",
    "content": "# ----------------------------------------------------\r\n# This file is generated by the Qt Visual Studio Tools.\r\n# ------------------------------------------------------\r\n\r\nHEADERS += ../../editors/ComponentEditor/parameters/ComponentParameterColumns.h \\\r\n    ../../editors/ComponentEditor/common/ParameterizableTable.h \\\r\n    ../../IPXACTmodels/common/validators/ValueFormatter.h \\\r\n    ../../editors/ComponentEditor/parameters/ComponentParameterModel.h \\\r\n    ../../editors/ComponentEditor/common/ReferencingTableModel.h\r\nSOURCES += ../../editors/ComponentEditor/parameters/ComponentParameterModel.cpp \\\r\n    ../../editors/ComponentEditor/common/ParameterizableTable.cpp \\\r\n    ../../editors/ComponentEditor/common/ReferencingTableModel.cpp \\\r\n    ../../IPXACTmodels/common/validators/ValueFormatter.cpp \\\r\n    ./tst_ComponentParameterModel.cpp\r\n"
  },
  {
    "path": "tests/Core/tst_ComponentParameterModel.pro",
    "content": "#-----------------------------------------------------------------------------\r\n# File: tst_ComponentParameterModel.pro\r\n#-----------------------------------------------------------------------------\r\n# Project: Kactus 2\r\n# Author: Esko Pekkarinen\r\n# Date: 24.7.2014\r\n#\r\n# Description:\r\n# Qt project file template for running unit tests for ComponentParameterModel.\r\n#-----------------------------------------------------------------------------\r\n\r\nTEMPLATE = app\r\n\r\nTARGET = tst_ComponentParameterModel\r\n\r\nQT += core gui xml testlib\r\n\r\nCONFIG += c++11 testcase console\r\nDEFINES += IPXACTMODELS_LIB\r\n\r\nwin32:CONFIG(release, debug|release) {\r\n    LIBS += -L$$PWD/../../executable/ -lIPXACTmodels -lKactusAPI\r\n    DESTDIR = ./release\r\n}\r\nelse:win32:CONFIG(debug, debug|release) {\r\n    LIBS += -L$$PWD/../../executable/ -lIPXACTmodelsd -lKactusAPId\r\n    DESTDIR = ./debug\r\n}\r\nelse:unix {\r\n    LIBS += -L$$PWD/../../executable/ -lIPXACTmodels -lKactusAPI\r\n    DESTDIR = ./release\r\n}\r\n\r\nINCLUDEPATH += $$PWD/../../\r\nINCLUDEPATH += $$DESTDIR\r\n\r\nDEPENDPATH += $$PWD/../../\r\nDEPENDPATH += .\r\n\r\nOBJECTS_DIR += $$DESTDIR\r\n\r\nMOC_DIR += ./generatedFiles\r\nUI_DIR += ./generatedFiles\r\nRCC_DIR += ./generatedFiles\r\ninclude(tst_ComponentParameterModel.pri)\r\n"
  },
  {
    "path": "tests/Core/tst_DocumentGenerator.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: tst_DocumentGenerator.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 10.02.2015\r\n//\r\n// Description:\r\n// Unit test for class documentGenerator.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include <QtTest>\r\n\r\n#include <kactusGenerators/DocumentGenerator/documentgenerator.h>\r\n#include <kactusGenerators/DocumentGenerator/HtmlWriter.h>\r\n\r\n#include <tests/MockObjects/LibraryMock.h>\r\n#include <tests/MockObjects/DesignWidgetFactoryMock.h>\r\n#include <tests/MockObjects/HWDesignWidgetMock.h>\r\n\r\n#include <KactusAPI/include/ExpressionFormatterFactoryImplementation.h>\r\n\r\n#include <KactusAPI/include/utils.h>\r\n\r\n#include <IPXACTmodels/Component/BusInterface.h>\r\n#include <IPXACTmodels/Component/Component.h>\r\n#include <IPXACTmodels/Component/FileSet.h>\r\n#include <IPXACTmodels/Component/Model.h>\r\n#include <IPXACTmodels/Component/Port.h>\r\n#include <IPXACTmodels/Component/PortMap.h>\r\n#include <IPXACTmodels/Component/View.h>\r\n#include <IPXACTmodels/Component/MemoryMap.h>\r\n#include <IPXACTmodels/Component/AddressBlock.h>\r\n#include <IPXACTmodels/Component/Register.h>\r\n#include <IPXACTmodels/Component/Field.h>\r\n#include <IPXACTmodels/Component/RegisterFile.h>\r\n#include <IPXACTmodels/Component/EnumeratedValue.h>\r\n\r\n#include <IPXACTmodels/Design/Design.h>\r\n\r\n#include <IPXACTmodels/common/Parameter.h>\r\n#include <IPXACTmodels/common/VLNV.h>\r\n\r\n#include <QWidget>\r\n\r\nclass tst_DocumentGenerator : public QObject\r\n{\r\n    Q_OBJECT\r\n\r\npublic:\r\n    tst_DocumentGenerator();\r\n\r\nprivate slots:\r\n    \r\n    void initTestCase();\r\n    void cleanupTestCase();\r\n    void init();\r\n    void cleanup();\r\n    //! Test cases.\r\n\r\n    void testInvalidVlnvInConstructor();\r\n\r\n    void testFileHeaderIsWritten();\r\n    void testTableOfContentsIsWrittenWithOnlyTopComponent();\r\n\r\n    void testAttributesWrittenWithOnlyTopComponent();\r\n    void testParametersWrittenWithOnlyTopComponent();\r\n\r\n    void testMemoryMapsWrittenWithTopComponent();\r\n    void testAddressBlocksWrittenWithTopComponent();\r\n    void testExpressionsInAddressBlocks();\r\n    void testRegistersWrittenWithTopComponent();\r\n    void testAddressBlockRegisterFilesWrittenWithTopComponent();\r\n    void testFieldsWrittenWithTopComponent();\r\n    void testMemoryMapToFieldWrittenWithTopComponent();\r\n\r\n    void testPortsWrittenWithOnlyTopComponent();\r\n\r\n    void testBusInterfacesWrittenWithoutPorts();\r\n\r\n    void testFileSetsWrittenForTopComponent();\r\n\r\n    void testViewsWrittenForTopComponent();\r\n\r\n    void testDesignIsWritten();\r\n\r\n    void testEndOfDocumentWrittenForTopComponent();\r\n\r\nprivate:\r\n\r\n    /*!\r\n     *  Create the generator used in most test cases.\r\n     */\r\n    DocumentGenerator* createTestGenerator();\r\n\r\n    /*!\r\n     *  Read the output file of the generator.\r\n     */\r\n    void readOutputFile();\r\n\r\n    /*!\r\n     *  Compare output to expected output.\r\n     */\r\n    void checkOutputFile(QString const& expectedOutput);\r\n\r\n    /*!\r\n     *  Create a model parameter used in the tests.\r\n     *\r\n     *      @param [in] name            Name of the parameter.\r\n     *      @param [in] dataType        Data type of the parameter.\r\n     *      @param [in] value           Value of the parameter.\r\n     *      @param [in] description     Description of the parameter.\r\n     *      @param [in] uuID            Id of the parameter.\r\n     */\r\n   /* QSharedPointer<ModelParameter> createTestModelParameter(QString const& name, QString const& dataType,\r\n        QString const& value, QString const& description, QString const& uuID, QString const& arrayLeft,\r\n        QString const& arrayRight);*/\r\n\r\n    /*!\r\n     *  Create a parameter used in the tests.\r\n     *\r\n     *      @param [in] name            Name of the parameter.\r\n     *      @param [in] value           Value of the parameter.\r\n     *      @param [in] description     Description of the parameter.\r\n     *      @param [in] uuID            Id of the parameter.\r\n     */\r\n    QSharedPointer<Parameter> createTestParameter(QString const& name, QString const& value,\r\n        QString const& description, QString const& uuID, QString const& arrayLeft, QString const& arrayRight);\r\n\r\n    /*!\r\n     *  Create a port used in the tests.\r\n     *\r\n     *      @param [in] name            Name of the port.\r\n     *      @param [in] leftBound       The left bound of the port.\r\n     *      @param [in] rightBound      The right bound of the port.\r\n     *      @param [in] defaultValue    The default value of the port.\r\n     */\r\n    QSharedPointer<Port> createTestPort(QString const& name, QString const& leftBound, QString const& rightBound,\r\n        QString const& defaultValue, QString const& arrayLeft, QString const& arrayRight);\r\n\r\n    /*!\r\n     *  Create a map for configurable element values.\r\n     *\r\n     *      @param [in] component   The component, whose configurable element values are being created.\r\n     */\r\n    QList<QSharedPointer<ConfigurableElementValue> > createConfigurableElementvalues(QSharedPointer <Component> component);\r\n\r\n    QSharedPointer<Field> createTestField (QString const& name, QString const& description, QString const& offset,\r\n        QString const& width);\r\n\r\n    QSharedPointer<Register> createTestRegister (QString const& name, QString const& offset, QString const& size,\r\n        QString const& dimension, QString const& description);\r\n\r\n    QSharedPointer<AddressBlock> createTestAddressBlock (QString const& name, QString const& description,\r\n        QString const& baseAddress, QString const& range, QString const& width,\r\n        QList <QSharedPointer <Register> > registers);\r\n    \r\n    QSharedPointer<AddressBlock> createAddressBlockWithRegisterData(QString const& name, QString const& description,\r\n        QString const& baseAddress, QString const& range, QString const& width,\r\n        QList <QSharedPointer <RegisterBase> > registerData);\r\n\r\n    QSharedPointer<MemoryMap> createTestMemoryMap(QString const& name, QString const& description, \r\n        int addressUnitbits, QList<QSharedPointer <AddressBlock> > addressBlocks);\r\n\r\n    //! Get the string used to describe a space.\r\n    QString getSpaceString();\r\n\r\n    //! Get the string used to describe an indent.\r\n    QString getIndentString();\r\n\r\n    //! Get the string used to describe a table.\r\n    QString getTableString();\r\n\r\n    //! Get the string used to describe the encoding.\r\n    QString getEncodingString();\r\n\r\n    //! Get the string used to describe the document type.\r\n    QString getDoctypeString();\r\n\r\n    //! Get the string used to describe valid w3c strict.\r\n    QString getValidW3CStrictString();\r\n\r\n    QSharedPointer<Component> topComponent_;\r\n\r\n    VLNV topComponentVlnv_;\r\n\r\n    QString output_;\r\n\r\n    QDateTime generationTime_;\r\n\r\n    LibraryMock library_;\r\n\r\n    DesignWidgetFactoryMock designWidgetFactory_;\r\n\r\n    ExpressionFormatterFactoryImplementation expressionFormatterFactory_;\r\n\r\n    QString targetPath_;\r\n\r\n    QWidget* generatorParentWidget_;\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_DocumentGenerator::tst_DocumentGenerator()\r\n//-----------------------------------------------------------------------------\r\ntst_DocumentGenerator::tst_DocumentGenerator() :\r\ntopComponent_(), topComponentVlnv_(), output_(), generationTime_(), library_(this), designWidgetFactory_(&library_),\r\n    expressionFormatterFactory_(), targetPath_(\"./generatorOutput.html\"), generatorParentWidget_(new QWidget)\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_DocumentGenerator::initTestCase()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_DocumentGenerator::initTestCase()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_DocumentGenerator::cleanupTestCase()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_DocumentGenerator::cleanupTestCase()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_DocumentGenerator::init()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_DocumentGenerator::init()\r\n{\r\n    VLNV vlnv(VLNV::COMPONENT, \"Test\", \"TestLibrary\", \"TestComponent\", \"1.0\");\r\n    topComponentVlnv_ = vlnv;\r\n    topComponent_ = QSharedPointer<Component>(new Component(topComponentVlnv_, Document::Revision::Std14));\r\n\r\n    library_.clear();\r\n\r\n    QVERIFY(!QFile::exists(targetPath_));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_DocumentGenerator::cleanup()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_DocumentGenerator::cleanup()\r\n{\r\n    topComponent_.clear();\r\n    output_.clear();\r\n\r\n    QFile::remove(targetPath_);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_DocumentGenerator::()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_DocumentGenerator::testInvalidVlnvInConstructor()\r\n{\r\n    VLNV invalidVlnv(VLNV::COMPONENT, \"invalid\", \"library\", \"component\", \"0\");\r\n\r\n    DocumentGenerator generator (&library_, invalidVlnv, &designWidgetFactory_,\r\n        &expressionFormatterFactory_, 1, generatorParentWidget_);\r\n\r\n    QSignalSpy spy(&generator, SIGNAL(errorMessage(QString const&)));\r\n\r\n    QFile targetFile(targetPath_);\r\n    targetFile.open(QFile::WriteOnly);\r\n    QTextStream stream(&targetFile);\r\n    \r\n    generator.setFormat(DocumentGenerator::HTML);\r\n    generator.writeDocumentation(stream, targetPath_);\r\n\r\n    targetFile.close();\r\n\r\n    QCOMPARE(spy.count(), 1);\r\n    QCOMPARE(spy.takeFirst().at(0).toString(), QString(\"VLNV was not found in the library.\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_DocumentGenerator::testFileHeaderIsPrinted()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_DocumentGenerator::testFileHeaderIsWritten()\r\n{\r\n    QCoreApplication::setOrganizationName(\"TUT\");\r\n    QCoreApplication::setApplicationName(\"TestRunner\");\r\n    QSettings settings;\r\n    settings.setValue(\"General/Username\", \"testUser\");\r\n\r\n    QScopedPointer<DocumentGenerator> generator(createTestGenerator());\r\n\r\n    QFile targetFile(targetPath_);\r\n    targetFile.open(QFile::WriteOnly);\r\n    QTextStream stream(&targetFile);\r\n    \r\n    generationTime_ = QDateTime::currentDateTime();\r\n    generator->setFormat(DocumentGenerator::DocumentFormat::HTML);\r\n    generator->writeHeader(stream);\r\n\r\n    targetFile.close();\r\n\r\n    QString expectedOutput(getDoctypeString() + \"\\n\"\r\n    \"<html>\\n\"\r\n        \"\\t<head>\\n\"\r\n        \"\\t\" + getEncodingString() + \"\\n\"\r\n            \"\\t\\t<title>Kactus2 generated documentation for component \" + topComponent_->getVlnv().getName() +\r\n            \" \" + topComponent_->getVlnv().getVersion() + \"</title>\\n\"\r\n        \"\\t</head>\\n\"\r\n        \"\\t<body>\\n\"\r\n            \"\\t\\t<h6>This document was generated by Kactus2 on \" +\r\n            generationTime_.toString(\"dd.MM.yyyy hh:mm:ss\") + \" by user testUser</h6>\\n\");\r\n\r\n    checkOutputFile(expectedOutput);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_DocumentGenerator::testTableOfContentsIsWrittenWithOnlyTopComponent()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_DocumentGenerator::testTableOfContentsIsWrittenWithOnlyTopComponent()\r\n{\r\n    QList <QSharedPointer<Parameter> > componentParameters;\r\n    QSharedPointer<Parameter> parameter = createTestParameter(\"parameter\", \"1\", \"\", \"P-ID\", \"\", \"\");\r\n    componentParameters.append(parameter);\r\n\r\n    QList <QSharedPointer <Register> > registers;\r\n    QSharedPointer <Register> testRegister = createTestRegister(\"register\", \"1\", \"1\", \"1\", \"\");\r\n    QSharedPointer <Field> testField = createTestField(\"field\", \"\", \"1\", \"8\");\r\n    testRegister->getFields()->append(testField);\r\n    registers.append(testRegister);\r\n\r\n    QList <QSharedPointer <AddressBlock> > addressBlocks;\r\n    QSharedPointer <AddressBlock> testAddressBlock = createTestAddressBlock(\"addressBlock\", \"\", \"'h0\", \"4\", \"32\",\r\n        registers);\r\n    addressBlocks.append(testAddressBlock);\r\n\r\n    QList <QSharedPointer <MemoryMap> > memoryMaps;\r\n    QSharedPointer<MemoryMap> testMemoryMap = createTestMemoryMap(\"memoryMap\", \"\", 8, addressBlocks);\r\n    memoryMaps.append(testMemoryMap);\r\n\r\n    QSharedPointer<Port> port = createTestPort(\"port\", \"10\", \"1\", \"\", \"\", \"\");\r\n\r\n    QSharedPointer<BusInterface> busInterface (new BusInterface());\r\n    busInterface->setName(\"busInterface\");\r\n\r\n    QSharedPointer<FileSet> fileset (new FileSet(\"fileSet\"));\r\n\r\n    QSharedPointer<View> view (new View(\"view\"));\r\n\r\n    topComponent_->getParameters()->append(componentParameters);\r\n    topComponent_->getPorts()->append(port);\r\n    topComponent_->getBusInterfaces()->append(busInterface);\r\n    topComponent_->getFileSets()->append(fileset);\r\n    topComponent_->getViews()->append(view);\r\n    topComponent_->getMemoryMaps()->append(memoryMaps);\r\n\r\n    QScopedPointer<DocumentGenerator> generator(createTestGenerator());\r\n\r\n    QFile targetFile(targetPath_);\r\n    targetFile.open(QFile::WriteOnly);\r\n    QTextStream stream(&targetFile);\r\n\r\n    unsigned int runningNumber = 0;\r\n\r\n    generator->setFormat(DocumentGenerator::DocumentFormat::HTML);\r\n    generator->writeTableOfContents(stream);\r\n\r\n    targetFile.close();\r\n\r\n    QString expectedOutput(\r\n        \"\\t\\t<a href=\\\"#\" + topComponent_->getVlnv().toString() + \"\\\">1. Component\" + getSpaceString() +\r\n        topComponent_->getVlnv().getVendor() + \" - \" + topComponent_->getVlnv().getLibrary() + \" - \" +\r\n        topComponent_->getVlnv().getName() + \" - \" + topComponent_->getVlnv().getVersion() + \"</a><br>\\n\"\r\n        \"\\t\\t\" + getIndentString() + \"<a href=\\\"#\" + topComponent_->getVlnv().toString() +\r\n        \".kts_params\\\">1.1. Kactus2 attributes</a><br>\\n\"\r\n        \"\\t\\t\" + getIndentString() + \"<a href=\\\"#\" + topComponent_->getVlnv().toString() +\r\n        \".parameters\\\">1.2. General parameters</a><br>\\n\"\r\n        \"\\t\\t\" + getIndentString() + \"<a href=\\\"#\" + topComponent_->getVlnv().toString() +\r\n        \".memoryMaps\\\">1.3. Memory maps</a><br>\\n\"\r\n        \"\\t\\t\" + getIndentString() + \"<a href=\\\"#\" + topComponent_->getVlnv().toString() +\r\n        \".ports\\\">1.4. Ports</a><br>\\n\"\r\n        \"\\t\\t\" + getIndentString() + \"<a href=\\\"#\" + topComponent_->getVlnv().toString() +\r\n        \".interfaces\\\">1.5. Bus interfaces</a><br>\\n\"\r\n        \"\\t\\t\" + getIndentString() + \"<a href=\\\"#\" + topComponent_->getVlnv().toString() +\r\n        \".fileSets\\\">1.6. File sets</a><br>\\n\"\r\n        \"\\t\\t\" + getIndentString() + \"<a href=\\\"#\" + topComponent_->getVlnv().toString() +\r\n        \".views\\\">1.7. Views</a><br>\\n\"\r\n            );\r\n\r\n    checkOutputFile(expectedOutput);\r\n}\r\n\r\nvoid tst_DocumentGenerator::testAttributesWrittenWithOnlyTopComponent()\r\n{\r\n    topComponent_->setHierarchy(KactusAttribute::FLAT);\r\n    topComponent_->setImplementation(KactusAttribute::SW);\r\n    topComponent_->setFirmness(KactusAttribute::FIXED);\r\n\r\n    QScopedPointer<DocumentGenerator> generator(createTestGenerator());\r\n\r\n    int subHeaderNumber = 1;\r\n\r\n    QFile targetFile(targetPath_);\r\n    targetFile.open(QFile::WriteOnly);\r\n    QTextStream stream(&targetFile);\r\n\r\n    generator->setFormat(DocumentGenerator::DocumentFormat::HTML);\r\n    generator->writeKactusAttributes(stream, subHeaderNumber);\r\n\r\n    targetFile.close();\r\n\r\n    QString expectedOutput(\r\n        \"\\t\\t<h2><a id=\\\"\" + topComponent_->getVlnv().toString() + \".attributes\\\">1.1 Kactus2 attributes</a></h2>\\n\"\r\n        \"\\t\\t<p>\\n\"\r\n        \"\\t\\t\\t<strong>\" + getIndentString() + \"Product hierarchy: </strong>\" +\r\n        KactusAttribute::hierarchyToString(topComponent_->getHierarchy()) + \"<br>\\n\"\r\n        \"\\t\\t\\t<strong>\" + getIndentString() + \"Component implementation: </strong>\" +\r\n        KactusAttribute::implementationToString(topComponent_->getImplementation()) + \"<br>\\n\"\r\n        \"\\t\\t\\t<strong>\" + getIndentString() + \"Component firmness: </strong>\" +\r\n        KactusAttribute::firmnessToString(topComponent_->getFirmness()) + \"<br>\\n\"\r\n        \"\\t\\t</p>\\n\"\r\n    );\r\n\r\n    checkOutputFile(expectedOutput);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_DocumentGenerator::testParametersWrittenWithOnlyTopComponent()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_DocumentGenerator::testParametersWrittenWithOnlyTopComponent()\r\n{\r\n    QSharedPointer <Parameter> parameter = createTestParameter(\"parameter\", \"10\", \"Description\", \"ID_parameter\",\r\n        \"1\", \"0\");\r\n    QSharedPointer <Parameter> refParameter = createTestParameter(\"refParameter\", \"ID_parameter\", \"Describe this\",\r\n        \"ID-refer\", \"\", \"\");\r\n\r\n    topComponent_->getParameters()->append(parameter);\r\n    topComponent_->getParameters()->append(refParameter);\r\n    topComponent_->setHierarchy(KactusAttribute::FLAT);\r\n\r\n    QScopedPointer<DocumentGenerator> generator(createTestGenerator());\r\n\r\n    QFile targetFile(targetPath_);\r\n    targetFile.open(QFile::WriteOnly);\r\n    QTextStream stream(&targetFile);\r\n\r\n    int subHeaderNumber = 2;\r\n\r\n    generator->setFormat(DocumentGenerator::DocumentFormat::HTML);\r\n    generator->writeParameters(stream, subHeaderNumber);\r\n\r\n    targetFile.close();\r\n\r\n    QString expectedOutput(\r\n        \"\\t\\t<h2><a id=\\\"\" + topComponent_->getVlnv().toString() + \".parameters\\\">1.2 General parameters</a></h2>\\n\"\r\n        \"\\t\\t\\t\" + getTableString() + \"List of parameters defined for the component\\\">\\n\"\r\n        \"\\t\\t\\t\\t<tr>\\n\"\r\n        \"\\t\\t\\t\\t\\t<th>Name</th>\\n\"\r\n        \"\\t\\t\\t\\t\\t<th>Type</th>\\n\"\r\n        \"\\t\\t\\t\\t\\t<th>Value</th>\\n\"\r\n        \"\\t\\t\\t\\t\\t<th>Resolve</th>\\n\"\r\n        \"\\t\\t\\t\\t\\t<th>Bit vector left</th>\\n\"\r\n        \"\\t\\t\\t\\t\\t<th>Bit vector right</th>\\n\"\r\n        \"\\t\\t\\t\\t\\t<th>Array left</th>\\n\"\r\n        \"\\t\\t\\t\\t\\t<th>Array right</th>\\n\"\r\n        \"\\t\\t\\t\\t\\t<th>Description</th>\\n\"\r\n        \"\\t\\t\\t\\t</tr>\\n\"\r\n        \"\\t\\t\\t\\t<tr>\\n\"\r\n        \"\\t\\t\\t\\t\\t<td>\" + parameter->name() + \"</td>\\n\"\r\n        \"\\t\\t\\t\\t\\t<td>\" + parameter->getType() + \"</td>\\n\"\r\n        \"\\t\\t\\t\\t\\t<td>\" + parameter->getValue() + \"</td>\\n\"\r\n        \"\\t\\t\\t\\t\\t<td>\" + parameter->getValueResolve() + \"</td>\\n\"\r\n        \"\\t\\t\\t\\t\\t<td>\" + parameter->getVectorLeft() + \"</td>\\n\"\r\n        \"\\t\\t\\t\\t\\t<td>\" + parameter->getVectorRight() + \"</td>\\n\"\r\n        \"\\t\\t\\t\\t\\t<td>\" + parameter->getArrayLeft() + \"</td>\\n\"\r\n        \"\\t\\t\\t\\t\\t<td>\" + parameter->getArrayRight() + \"</td>\\n\"\r\n        \"\\t\\t\\t\\t\\t<td>\" + parameter->description() + \"</td>\\n\"\r\n        \"\\t\\t\\t\\t</tr>\\n\"\r\n        \"\\t\\t\\t\\t<tr>\\n\"\r\n        \"\\t\\t\\t\\t\\t<td>\" + refParameter->name() + \"</td>\\n\"\r\n        \"\\t\\t\\t\\t\\t<td></td>\\n\"\r\n        \"\\t\\t\\t\\t\\t<td>parameter</td>\\n\"        \r\n        \"\\t\\t\\t\\t\\t<td></td>\\n\"\r\n        \"\\t\\t\\t\\t\\t<td></td>\\n\"\r\n        \"\\t\\t\\t\\t\\t<td></td>\\n\"\r\n        \"\\t\\t\\t\\t\\t<td></td>\\n\"\r\n        \"\\t\\t\\t\\t\\t<td></td>\\n\"\r\n        \"\\t\\t\\t\\t\\t<td>\" + refParameter->description() + \"</td>\\n\"\r\n        \"\\t\\t\\t\\t</tr>\\n\"\r\n        \"\\t\\t\\t</table>\"\r\n        );\r\n\r\n    checkOutputFile(expectedOutput);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_DocumentGenerator::testMemoryMapsWrittenWithTopComponent()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_DocumentGenerator::testMemoryMapsWrittenWithTopComponent()\r\n{\r\n    QList <QSharedPointer <AddressBlock> > addressBlocks;\r\n\r\n    QSharedPointer<MemoryMap> memoryMap = createTestMemoryMap(\"memoryMap\", \"example Description\", 8, addressBlocks);\r\n\r\n    topComponent_->getMemoryMaps()->append(memoryMap);\r\n\r\n    QScopedPointer<DocumentGenerator> generator(createTestGenerator());\r\n\r\n    QFile targetFile(targetPath_);\r\n    targetFile.open(QFile::WriteOnly);\r\n    QTextStream stream(&targetFile);\r\n\r\n    int subHeaderNumber = 1;\r\n\r\n    generator->writeMemoryMaps(stream, subHeaderNumber);\r\n\r\n    targetFile.close();\r\n\r\n    QString expectedOutput(\r\n        \"\\t\\t<h2><a id=\\\"\" + topComponent_->getVlnv().toString() + \".memoryMaps\\\">1.1 Memory maps</a></h2>\\n\"\r\n        \"\\t\\t\\t<h3>1.1.1 Memory map \" + memoryMap->name() + \"</h3>\\n\"\r\n        \"\\t\\t\\t<p>\\n\"\r\n        \"\\t\\t\\t\" + getIndentString() + \"<strong>Description:</strong> \" + memoryMap->description() + \"<br>\\n\"\r\n        \"\\t\\t\\t\" + getIndentString() + \"<strong>Address unit bits (AUB):</strong> \" + \r\n        memoryMap->getAddressUnitBits() + \"<br>\\n\"\r\n        \"\\t\\t\\t</p>\"\r\n        );\r\n\r\n    checkOutputFile(expectedOutput);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_DocumentGenerator::testAddressBlocksWrittenWithTopComponent()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_DocumentGenerator::testAddressBlocksWrittenWithTopComponent()\r\n{\r\n    QList <QSharedPointer <Register> > registers;\r\n    QSharedPointer <Register> testRegister = createTestRegister(\"register\", \"4\", \"2\", \"2\", \"\");\r\n    QSharedPointer <Register> testRegister2 = createTestRegister(\"register2\", \"8\", \"16\", \"2\", \"\");\r\n    registers.append(testRegister);\r\n    registers.append(testRegister2);\r\n\r\n    QList <QSharedPointer <AddressBlock> > addressBlocks;\r\n    QSharedPointer <AddressBlock> testAddressBlock = createTestAddressBlock(\"addressBlock\", \"example\", \"'h0\", \"4\",\r\n        \"32\", registers);\r\n    addressBlocks.append(testAddressBlock);\r\n\r\n    QScopedPointer<DocumentGenerator> generator(createTestGenerator());\r\n\r\n    QFile targetFile(targetPath_);\r\n    targetFile.open(QFile::WriteOnly);\r\n    QTextStream stream(&targetFile);\r\n\r\n    int subHeaderNumber = 1;\r\n\r\n    generator->writeAddressBlocks(addressBlocks, stream, subHeaderNumber, subHeaderNumber);\r\n\r\n    targetFile.close();\r\n    \r\n    QString expectedOutput(\r\n        \"\\t\\t\\t<h3>1.1.1.1 Address block \" + testAddressBlock->name() + \"</h3>\\n\"\r\n        \"\\t\\t\\t<p>\\n\"\r\n        \"\\t\\t\\t\" + getIndentString() + \"<strong>Description:</strong> \" + testAddressBlock->description() + \"<br>\\n\"\r\n        \"\\t\\t\\t\" + getIndentString() + \"<strong>Usage:</strong> \" + General::usage2Str(testAddressBlock->getUsage()) + \"<br>\\n\"\r\n        \"\\t\\t\\t\" + getIndentString() + \"<strong>Base address [AUB]:</strong> \" + testAddressBlock->getBaseAddress() + \"<br>\\n\"\r\n        \"\\t\\t\\t\" + getIndentString() + \"<strong>Range [AUB]:</strong> \" + testAddressBlock->getRange() + \"<br>\\n\"\r\n        \"\\t\\t\\t\" + getIndentString() + \"<strong>Width [AUB]:</strong> \" + testAddressBlock->getWidth() + \"<br>\\n\"\r\n        \"\\t\\t\\t\" + getIndentString() + \"<strong>Access:</strong> \" + AccessTypes::access2Str(testAddressBlock->getAccess()) + \"<br>\\n\"\r\n        \"\\t\\t\\t\" + getIndentString() + \"<strong>Volatile:</strong> \" + testAddressBlock->getVolatile() + \"<br>\\n\"\r\n        \"\\t\\t\\t</p>\\n\"\r\n        \"\\t\\t\\t<h4>Address block '\" + testAddressBlock->name() + \"' contains the following registers:</h4>\\n\"\r\n        \"\\t\\t\\t\" + getTableString() + \"\\\">\\n\"\r\n        \"\\t\\t\\t\\t<tr>\\n\"\r\n        \"\\t\\t\\t\\t\\t<th>Register name</th>\\n\"\r\n        \"\\t\\t\\t\\t\\t<th>Offset [AUB]</th>\\n\"\r\n        \"\\t\\t\\t\\t\\t<th>Size [bits]</th>\\n\"\r\n        \"\\t\\t\\t\\t\\t<th>Dimension</th>\\n\"\r\n        \"\\t\\t\\t\\t\\t<th>Volatile</th>\\n\"\r\n        \"\\t\\t\\t\\t\\t<th>Access</th>\\n\"\r\n        \"\\t\\t\\t\\t</tr>\\n\"\r\n        \"\\t\\t\\t\\t<tr>\\n\"\r\n        \"\\t\\t\\t\\t\\t<td>\" + testRegister->name() + \"</td>\\n\"\r\n        \"\\t\\t\\t\\t\\t<td>\" + testRegister->getAddressOffset() + \"</td>\\n\"\r\n        \"\\t\\t\\t\\t\\t<td>\" + testRegister->getSize() + \"</td>\\n\"\r\n        \"\\t\\t\\t\\t\\t<td>\" + testRegister->getDimension() + \"</td>\\n\"\r\n        \"\\t\\t\\t\\t\\t<td>\" + testRegister->getVolatile() + \"</td>\\n\"\r\n        \"\\t\\t\\t\\t\\t<td>\" + AccessTypes::access2Str(testRegister->getAccess()) + \"</td>\\n\"\r\n        \"\\t\\t\\t\\t</tr>\\n\"\r\n        \"\\t\\t\\t\\t<tr>\\n\"\r\n        \"\\t\\t\\t\\t\\t<td>\" + testRegister2->name() + \"</td>\\n\"\r\n        \"\\t\\t\\t\\t\\t<td>\" + testRegister2->getAddressOffset() + \"</td>\\n\"\r\n        \"\\t\\t\\t\\t\\t<td>\" + testRegister2->getSize() + \"</td>\\n\"\r\n        \"\\t\\t\\t\\t\\t<td>\" + testRegister2->getDimension() + \"</td>\\n\"\r\n        \"\\t\\t\\t\\t\\t<td>\" + testRegister2->getVolatile() + \"</td>\\n\"\r\n        \"\\t\\t\\t\\t\\t<td>\" + AccessTypes::access2Str(testRegister2->getAccess()) + \"</td>\\n\"\r\n        \"\\t\\t\\t\\t</tr>\\n\"\r\n        \"\\t\\t\\t</table>\\n\"\r\n        );\r\n\r\n    checkOutputFile(expectedOutput);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_DocumentGenerator::testExpressionsInAddressBlocks()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_DocumentGenerator::testExpressionsInAddressBlocks()\r\n{\r\n    QSharedPointer <Parameter> targetParameter = createTestParameter(\"target\", \"4\", \"\", \"ID_TARGET\", \"\", \"\");\r\n\r\n    QList <QSharedPointer <AddressBlock> > addressBlocks;\r\n    QSharedPointer <AddressBlock> testAddressBlock = createTestAddressBlock(\"addressBlock\", \"example\", \"'h0\",\r\n        \"ID_TARGET\", \"ID_TARGET + 2\", QList <QSharedPointer <Register> > ());\r\n    addressBlocks.append(testAddressBlock);\r\n\r\n    topComponent_->getParameters()->append(targetParameter);\r\n\r\n    QScopedPointer<DocumentGenerator> generator(createTestGenerator());\r\n\r\n    QFile targetFile(targetPath_);\r\n    targetFile.open(QFile::WriteOnly);\r\n    QTextStream stream(&targetFile);\r\n\r\n    int subHeaderNumber = 1;\r\n\r\n    generator->writeAddressBlocks(addressBlocks, stream, subHeaderNumber, subHeaderNumber);\r\n\r\n    targetFile.close();\r\n\r\n    QString expectedOutput(\r\n        \"\\t\\t\\t<h3>1.1.1.1 Address block \" + testAddressBlock->name() + \"</h3>\\n\"\r\n        \"\\t\\t\\t<p>\\n\"\r\n        \"\\t\\t\\t\" + getIndentString() + \"<strong>Description:</strong> \" + testAddressBlock->description() + \"<br>\\n\"\r\n        \"\\t\\t\\t\" + getIndentString() + \"<strong>Usage:</strong> \" + General::usage2Str(testAddressBlock->getUsage()) + \"<br>\\n\"\r\n        \"\\t\\t\\t\" + getIndentString() + \"<strong>Base address [AUB]:</strong> 'h0<br>\\n\"\r\n        \"\\t\\t\\t\" + getIndentString() + \"<strong>Range [AUB]:</strong> target<br>\\n\"\r\n        \"\\t\\t\\t\" + getIndentString() + \"<strong>Width [AUB]:</strong> target + 2<br>\\n\"\r\n        \"\\t\\t\\t\" + getIndentString() + \"<strong>Access:</strong> \" + AccessTypes::access2Str(testAddressBlock->getAccess()) + \"<br>\\n\"\r\n        \"\\t\\t\\t\" + getIndentString() + \"<strong>Volatile:</strong> \" + testAddressBlock->getVolatile() + \"<br>\\n\"\r\n        \"\\t\\t\\t</p>\\n\"\r\n        );\r\n\r\n    checkOutputFile(expectedOutput);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_DocumentGenerator::testRegistersWrittenWithTopComponent()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_DocumentGenerator::testRegistersWrittenWithTopComponent()\r\n{\r\n    QList <QSharedPointer <Register> > registers;\r\n    QSharedPointer <Register> testRegister = createTestRegister(\"register\", \"4\", \"2\", \"2\", \"exampleDescription\");\r\n    registers.append(testRegister);\r\n\r\n    QScopedPointer<DocumentGenerator> generator(createTestGenerator());\r\n\r\n    QFile targetFile(targetPath_);\r\n    targetFile.open(QFile::WriteOnly);\r\n    QTextStream stream(&targetFile);\r\n\r\n    int subHeaderNumber = 1;\r\n\r\n    generator->writeRegisters(registers, stream, subHeaderNumber, subHeaderNumber, subHeaderNumber, subHeaderNumber);\r\n\r\n    targetFile.close();\r\n\r\n    QString expectedOutput(\r\n        \"\\t\\t\\t<h3>1.1.1.1.1 Register \" + testRegister->name() + \"</h3>\\n\"\r\n        \"\\t\\t\\t<p>\\n\"\r\n        \"\\t\\t\\t\" + getIndentString() + \"<strong>Description:</strong> \" + testRegister->description() + \"<br>\\n\"\r\n        \"\\t\\t\\t\" + getIndentString() + \"<strong>Offset [AUB]:</strong> \" + testRegister->getAddressOffset() + \"<br>\\n\"\r\n        \"\\t\\t\\t\" + getIndentString() + \"<strong>Size [bits]:</strong> \" + testRegister->getSize() + \"<br>\\n\"\r\n        \"\\t\\t\\t\" + getIndentString() + \"<strong>Dimension:</strong> \" + testRegister->getDimension() + \"<br>\\n\"\r\n        \"\\t\\t\\t\" + getIndentString() + \"<strong>Volatile:</strong> \" + testRegister->getVolatile() + \"<br>\\n\"\r\n        \"\\t\\t\\t\" + getIndentString() + \"<strong>Access:</strong> \" + AccessTypes::access2Str(testRegister->getAccess()) + \"<br>\\n\"\r\n        \"\\t\\t\\t</p>\\n\"\r\n        );\r\n\r\n    checkOutputFile(expectedOutput);\r\n}\r\n\r\nvoid tst_DocumentGenerator::testAddressBlockRegisterFilesWrittenWithTopComponent()\r\n{\r\n    QSharedPointer<RegisterFile> testRegisterFileParent(new RegisterFile(\"testRegisterFileParent\", \"8\", \"16\"));\r\n    QSharedPointer<RegisterFile> testRegisterFileChild(new RegisterFile(\"testRegisterFileChild\", \"64\", \"512\"));\r\n\r\n    testRegisterFileParent->setDescription(\"this is a description\");\r\n\r\n    QSharedPointer<Register> registerInParentRegisterFile = createTestRegister(\"testRegister\", \"4\", \"2\", \"0\", \"example description\");\r\n    QSharedPointer<Register> registerInChildRegisterFile = createTestRegister(\"testRegister2\", \"8\", \"2\", \"0\", \"example description2\");\r\n\r\n    QSharedPointer<QList <QSharedPointer<RegisterBase> > > childRegisterData(new QList<QSharedPointer<RegisterBase> >({ registerInChildRegisterFile }));\r\n    testRegisterFileChild->setRegisterData(childRegisterData);\r\n\r\n    QSharedPointer<QList <QSharedPointer<RegisterBase> > > parentRegisterData(new QList<QSharedPointer<RegisterBase> >({ testRegisterFileChild, registerInParentRegisterFile }));\r\n    testRegisterFileParent->setRegisterData(parentRegisterData);\r\n\r\n    QSharedPointer<QList<QSharedPointer<RegisterBase> > >addressBlockRegisterData(new QList < QSharedPointer<RegisterBase> >({ testRegisterFileParent }));\r\n    auto testAddressBlock = createAddressBlockWithRegisterData(\"testAddressBlock\", \"address block description\", \"'h0\", \"4\", \"32\", *addressBlockRegisterData);\r\n\r\n    QList <QSharedPointer <AddressBlock> > addressBlocks;\r\n    addressBlocks.append(testAddressBlock);\r\n\r\n    QScopedPointer<DocumentGenerator> generator(createTestGenerator());\r\n\r\n    QFile targetFile(targetPath_);\r\n    targetFile.open(QFile::WriteOnly);\r\n    QTextStream stream(&targetFile);\r\n\r\n    int subHeaderNumber = 1;\r\n\r\n    generator->writeAddressBlocks(addressBlocks, stream, subHeaderNumber, subHeaderNumber);\r\n\r\n    targetFile.close();\r\n\r\n    QString expectedOutput(\r\n        \"\\t\\t\\t<h3>1.1.1.1 Address block testAddressBlock</h3>\\n\"\r\n        \"\\t\\t\\t<p>\\n\"\r\n        \"\\t\\t\\t\" + getIndentString() + \"<strong>Description:</strong> \" + testAddressBlock->description() + \"<br>\\n\"\r\n        \"\\t\\t\\t\" + getIndentString() + \"<strong>Usage:</strong> \" + General::usage2Str(testAddressBlock->getUsage()) + \"<br>\\n\"\r\n        \"\\t\\t\\t\" + getIndentString() + \"<strong>Base address [AUB]:</strong> 'h0<br>\\n\"\r\n        \"\\t\\t\\t\" + getIndentString() + \"<strong>Range [AUB]:</strong> 4<br>\\n\"\r\n        \"\\t\\t\\t\" + getIndentString() + \"<strong>Width [AUB]:</strong> 32<br>\\n\"\r\n        \"\\t\\t\\t\" + getIndentString() + \"<strong>Access:</strong> \" + AccessTypes::access2Str(testAddressBlock->getAccess()) + \"<br>\\n\"\r\n        \"\\t\\t\\t\" + getIndentString() + \"<strong>Volatile:</strong> \" + testAddressBlock->getVolatile() + \"<br>\\n\"\r\n        \"\\t\\t\\t</p>\\n\"\r\n        \"\\t\\t\\t<h4>Address block 'testAddressBlock' contains the following register files:</h4>\\n\"\r\n        \"\\t\\t\\t<h3>1.1.1.1.1 Register file testRegisterFileParent</h3>\\n\"\r\n        \"\\t\\t\\t<p>\\n\"\r\n        \"\\t\\t\\t\" + getIndentString() + \"<strong>Description:</strong> this is a description<br>\\n\"\r\n        \"\\t\\t\\t\" + getIndentString() + \"<strong>Offset [AUB]:</strong> \" + testRegisterFileParent->getAddressOffset() + \"<br>\\n\"\r\n        \"\\t\\t\\t\" + getIndentString() + \"<strong>Range [AUB]:</strong> \" + testRegisterFileParent->getRange() + \"<br>\\n\"\r\n        \"\\t\\t\\t\" + getIndentString() + \"<strong>Dimension:</strong> <br>\\n\"\r\n        \"\\t\\t\\t</p>\\n\"\r\n        \"\\t\\t\\t<h4>Register file testRegisterFileParent contains the following registers:</h4>\\n\"\r\n        \"\\t\\t\\t\" + getTableString() + \"\\\">\\n\"\r\n        \"\\t\\t\\t\\t<tr>\\n\"\r\n        \"\\t\\t\\t\\t\\t<th>Register name</th>\\n\"\r\n        \"\\t\\t\\t\\t\\t<th>Offset [AUB]</th>\\n\"\r\n        \"\\t\\t\\t\\t\\t<th>Size [bits]</th>\\n\"\r\n        \"\\t\\t\\t\\t\\t<th>Dimension</th>\\n\"\r\n        \"\\t\\t\\t\\t\\t<th>Volatile</th>\\n\"\r\n        \"\\t\\t\\t\\t\\t<th>Access</th>\\n\"\r\n        \"\\t\\t\\t\\t</tr>\\n\"\r\n        \"\\t\\t\\t\\t<tr>\\n\"\r\n        \"\\t\\t\\t\\t\\t<td>\" + registerInParentRegisterFile->name() + \"</td>\\n\"\r\n        \"\\t\\t\\t\\t\\t<td>\" + registerInParentRegisterFile->getAddressOffset() + \"</td>\\n\"\r\n        \"\\t\\t\\t\\t\\t<td>\" + registerInParentRegisterFile->getSize() + \"</td>\\n\"\r\n        \"\\t\\t\\t\\t\\t<td>\" + registerInParentRegisterFile->getDimension() + \"</td>\\n\"\r\n        \"\\t\\t\\t\\t\\t<td>\" + registerInParentRegisterFile->getVolatile() + \"</td>\\n\"\r\n        \"\\t\\t\\t\\t\\t<td>\" + AccessTypes::access2Str(registerInParentRegisterFile->getAccess()) + \"</td>\\n\"\r\n        \"\\t\\t\\t\\t</tr>\\n\"\r\n        \"\\t\\t\\t</table>\\n\"\r\n        \"\\t\\t\\t<h3>1.1.1.1.1.1 Register testRegister</h3>\\n\"\r\n        \"\\t\\t\\t<p>\\n\"\r\n        \"\\t\\t\\t\" + getIndentString() + \"<strong>Description:</strong> \" + registerInParentRegisterFile->description() + \"<br>\\n\"\r\n        \"\\t\\t\\t\" + getIndentString() + \"<strong>Offset [AUB]:</strong> \" + registerInParentRegisterFile->getAddressOffset() + \"<br>\\n\"\r\n        \"\\t\\t\\t\" + getIndentString() + \"<strong>Size [bits]:</strong> \" + registerInParentRegisterFile->getSize() + \"<br>\\n\"\r\n        \"\\t\\t\\t\" + getIndentString() + \"<strong>Dimension:</strong> \" + registerInParentRegisterFile->getDimension() + \"<br>\\n\"\r\n        \"\\t\\t\\t\" + getIndentString() + \"<strong>Volatile:</strong> \" + registerInParentRegisterFile->getVolatile() + \"<br>\\n\"\r\n        \"\\t\\t\\t\" + getIndentString() + \"<strong>Access:</strong> \" + AccessTypes::access2Str(registerInParentRegisterFile->getAccess()) + \"<br>\\n\"\r\n        \"\\t\\t\\t</p>\\n\"\r\n        \"\\t\\t\\t<h3>1.1.1.1.1.2 Register file testRegisterFileChild</h3>\\n\"\r\n        \"\\t\\t\\t<p>\\n\"\r\n        \"\\t\\t\\t\" + getIndentString() + \"<strong>Description:</strong> \" + testRegisterFileChild->description() + \"<br>\\n\"\r\n        \"\\t\\t\\t\" + getIndentString() + \"<strong>Offset [AUB]:</strong> \" + testRegisterFileChild->getAddressOffset() + \"<br>\\n\"\r\n        \"\\t\\t\\t\" + getIndentString() + \"<strong>Range [AUB]:</strong> \" + testRegisterFileChild->getRange() + \"<br>\\n\"\r\n        \"\\t\\t\\t\" + getIndentString() + \"<strong>Dimension:</strong> <br>\\n\"\r\n        \"\\t\\t\\t</p>\\n\"\r\n        \"\\t\\t\\t<h4>Register file testRegisterFileChild contains the following registers:</h4>\\n\"\r\n        \"\\t\\t\\t\" + getTableString() + \"\\\">\\n\"\r\n        \"\\t\\t\\t\\t<tr>\\n\"\r\n        \"\\t\\t\\t\\t\\t<th>Register name</th>\\n\"\r\n        \"\\t\\t\\t\\t\\t<th>Offset [AUB]</th>\\n\"\r\n        \"\\t\\t\\t\\t\\t<th>Size [bits]</th>\\n\"\r\n        \"\\t\\t\\t\\t\\t<th>Dimension</th>\\n\"\r\n        \"\\t\\t\\t\\t\\t<th>Volatile</th>\\n\"\r\n        \"\\t\\t\\t\\t\\t<th>Access</th>\\n\"\r\n        \"\\t\\t\\t\\t</tr>\\n\"\r\n        \"\\t\\t\\t\\t<tr>\\n\"\r\n        \"\\t\\t\\t\\t\\t<td>\" + registerInChildRegisterFile->name() + \"</td>\\n\"\r\n        \"\\t\\t\\t\\t\\t<td>\" + registerInChildRegisterFile->getAddressOffset() + \"</td>\\n\"\r\n        \"\\t\\t\\t\\t\\t<td>\" + registerInChildRegisterFile->getSize() + \"</td>\\n\"\r\n        \"\\t\\t\\t\\t\\t<td>\" + registerInChildRegisterFile->getDimension() + \"</td>\\n\"\r\n        \"\\t\\t\\t\\t\\t<td>\" + registerInChildRegisterFile->getVolatile() + \"</td>\\n\"\r\n        \"\\t\\t\\t\\t\\t<td>\" + AccessTypes::access2Str(registerInChildRegisterFile->getAccess()) + \"</td>\\n\"\r\n        \"\\t\\t\\t\\t</tr>\\n\"\r\n        \"\\t\\t\\t</table>\\n\"\r\n        \"\\t\\t\\t<h3>1.1.1.1.1.2.1 Register testRegister2</h3>\\n\"\r\n        \"\\t\\t\\t<p>\\n\"\r\n        \"\\t\\t\\t\" + getIndentString() + \"<strong>Description:</strong> \" + registerInChildRegisterFile->description() + \"<br>\\n\"\r\n        \"\\t\\t\\t\" + getIndentString() + \"<strong>Offset [AUB]:</strong> \" + registerInChildRegisterFile->getAddressOffset() + \"<br>\\n\"\r\n        \"\\t\\t\\t\" + getIndentString() + \"<strong>Size [bits]:</strong> \" + registerInChildRegisterFile->getSize() + \"<br>\\n\"\r\n        \"\\t\\t\\t\" + getIndentString() + \"<strong>Dimension:</strong> \" + registerInChildRegisterFile->getDimension() + \"<br>\\n\"\r\n        \"\\t\\t\\t\" + getIndentString() + \"<strong>Volatile:</strong> \" + registerInChildRegisterFile->getVolatile() + \"<br>\\n\"\r\n        \"\\t\\t\\t\" + getIndentString() + \"<strong>Access:</strong> \" + AccessTypes::access2Str(registerInChildRegisterFile->getAccess()) + \"<br>\\n\"\r\n        \"\\t\\t\\t</p>\\n\"\r\n    );\r\n\r\n    checkOutputFile(expectedOutput);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_DocumentGenerator::testFieldsWrittenWithTopComponent()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_DocumentGenerator::testFieldsWrittenWithTopComponent()\r\n{\r\n    QSharedPointer<Field> testField = createTestField(\"testField\", \"Example Field\", \"2\", \"8\");    \r\n    QSharedPointer<FieldReset> resetValue(new FieldReset());\r\n    resetValue->setResetValue(\"testReset\");\r\n    resetValue->setResetMask(\"testMask\");\r\n\r\n    testField->getResets()->append(resetValue);\r\n\r\n    QSharedPointer<QList<QSharedPointer<EnumeratedValue> > > enumerations(new QList<QSharedPointer <EnumeratedValue > >());\r\n    QSharedPointer<EnumeratedValue> testEnumeratedValue(new EnumeratedValue(\"testEnumeration\", \"1\"));\r\n    enumerations->append(testEnumeratedValue);\r\n\r\n    testField->setEnumeratedValues(enumerations);\r\n\r\n    QSharedPointer<Register> fieldRegister =createTestRegister(\"FieldRegister\", \"10\", \"10\", \"10\", \"\");\r\n    fieldRegister->getFields()->append(testField);\r\n\r\n    QScopedPointer<DocumentGenerator> generator(createTestGenerator());\r\n\r\n    QFile targetFile(targetPath_);\r\n    targetFile.open(QFile::WriteOnly);\r\n    QTextStream stream(&targetFile);\r\n\r\n    generator->writeFields(fieldRegister, stream, { 1, 1, 1, 1, 1 });\r\n\r\n    targetFile.close();\r\n\r\n    QString expectedOutput(\r\n        \"\\t\\t\\t<h4>Register '\" + fieldRegister->name() + \"' contains the following fields:</h4>\\n\"\r\n        \"\\t\\t\\t\" + getTableString() + \"List of fields contained within register \" + fieldRegister->name() +\r\n        \".\\\">\\n\"\r\n        \"\\t\\t\\t\\t<tr>\\n\"\r\n        \"\\t\\t\\t\\t\\t<th>Field name</th>\\n\"\r\n        \"\\t\\t\\t\\t\\t<th>Offset [bits]</th>\\n\"\r\n        \"\\t\\t\\t\\t\\t<th>Width [bits]</th>\\n\"\r\n        \"\\t\\t\\t\\t\\t<th>Volatile</th>\\n\"\r\n        \"\\t\\t\\t\\t\\t<th>Access</th>\\n\"\r\n        \"\\t\\t\\t\\t\\t<th>Resets</th>\\n\"        \r\n        \"\\t\\t\\t\\t\\t<th>Description</th>\\n\"\r\n        \"\\t\\t\\t\\t</tr>\\n\"\r\n        \"\\t\\t\\t\\t<tr>\\n\"\r\n        \"\\t\\t\\t\\t\\t<td><a id=\\\"\" + topComponent_->getVlnv().toString() + \".field.\" + testField->name() +\r\n        \"\\\">\" + testField->name() + \"</a></td>\\n\"\r\n        \"\\t\\t\\t\\t\\t<td>\" + testField->getBitOffset() + \"</td>\\n\"\r\n        \"\\t\\t\\t\\t\\t<td>\" + testField->getBitWidth() + \"</td>\\n\"\r\n        \"\\t\\t\\t\\t\\t<td>\" + testField->getVolatile().toString() + \"</td>\\n\"\r\n        \"\\t\\t\\t\\t\\t<td>\" + AccessTypes::access2Str(testField->getAccess()) + \"</td>\\n\"\r\n        \"\\t\\t\\t\\t\\t<td>HARD : testReset</td>\\n\"        \r\n        \"\\t\\t\\t\\t\\t<td>\" + testField->description() + \"</td>\\n\"\r\n        \"\\t\\t\\t\\t</tr>\\n\"\r\n        \"\\t\\t\\t</table>\\n\"\r\n        \"\\t\\t\\t<h3>1.1.1.1.1.1 Field \" + testField->name() + \"</h3>\\n\"\r\n        \"\\t\\t\\t<p>\\n\"\r\n        \"\\t\\t\\t\" + getIndentString() + \"<strong>Offset [bits]:</strong> \" + testField->getBitOffset() + \"<br>\\n\"\r\n        \"\\t\\t\\t\" + getIndentString() + \"<strong>Width [bits]:</strong> \" + testField->getBitWidth() + \"<br>\\n\"\r\n        \"\\t\\t\\t\" + getIndentString() + \"<strong>Volatile:</strong> \" + testField->getVolatile().toString() + \"<br>\\n\"\r\n        \"\\t\\t\\t\" + getIndentString() + \"<strong>Access:</strong> \" + AccessTypes::access2Str(testField->getAccess()) + \"<br>\\n\"\r\n        \"\\t\\t\\t\" + getIndentString() + \"<strong>Resets:</strong> HARD : testReset<br>\\n\"\r\n        \"\\t\\t\\t\" + getIndentString() + \"<strong>Description:</strong> \" + testField->description() + \"<br>\\n\"\r\n        \"\\t\\t\\t</p>\\n\"\r\n        \"\\t\\t\\t<h4>Enumerations:</h4>\\n\"\r\n        \"\\t\\t\\t\" + getTableString() + \"\\\">\\n\"\r\n        \"\\t\\t\\t\\t<tr>\\n\"\r\n        \"\\t\\t\\t\\t\\t<th>Name</th>\\n\"\r\n        \"\\t\\t\\t\\t\\t<th>Value</th>\\n\"\r\n        \"\\t\\t\\t\\t</tr>\\n\"\r\n        \"\\t\\t\\t\\t<tr>\\n\"\r\n        \"\\t\\t\\t\\t\\t<td>testEnumeration</td>\\n\"\r\n        \"\\t\\t\\t\\t\\t<td>1</td>\\n\"\r\n        \"\\t\\t\\t\\t</tr>\\n\"\r\n        \"\\t\\t\\t</table>\\n\"\r\n        );\r\n\r\n    checkOutputFile(expectedOutput);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_DocumentGenerator::testMemoryMapToFieldWrittenWithTopComponent()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_DocumentGenerator::testMemoryMapToFieldWrittenWithTopComponent()\r\n{\r\n    QSharedPointer<Field> testField = createTestField(\"testField\", \"\", \"2\", \"8\");\r\n    QSharedPointer<FieldReset> resetValue(new FieldReset());\r\n    resetValue->setResetValue(\"8'h3\");\r\n    resetValue->setResetMask(\"00000011\");\r\n\r\n    testField->getResets()->append(resetValue);\r\n\r\n    QList <QSharedPointer <Register> > registers;\r\n    QSharedPointer<Register> testRegister = createTestRegister(\"testRegister\", \"10\", \"4\", \"2\", \"Describing reg.\");\r\n    testRegister->getFields()->append(testField);\r\n    registers.append(testRegister);\r\n\r\n    QList <QSharedPointer <AddressBlock> > addressBlocks;\r\n    QSharedPointer <AddressBlock> testAddressBlock = createTestAddressBlock(\"testAddress\", \"Describe.\", \"'h0\", \"4\",\r\n        \"32\", registers);\r\n    addressBlocks.append(testAddressBlock);\r\n\r\n    QList <QSharedPointer <MemoryMap> > memoryMaps;\r\n    QSharedPointer <MemoryMap> testMemoryMap = createTestMemoryMap(\"testMemoryMap\", \"\", 8, addressBlocks);\r\n    memoryMaps.append(testMemoryMap);\r\n\r\n    topComponent_->getMemoryMaps()->append(memoryMaps);\r\n\r\n    QScopedPointer<DocumentGenerator> generator(createTestGenerator());\r\n\r\n    QFile targetFile(targetPath_);\r\n    targetFile.open(QFile::WriteOnly);\r\n    QTextStream stream(&targetFile);\r\n\r\n    int subHeaderNumber = 1;\r\n\r\n    generator->writeMemoryMaps(stream, subHeaderNumber);\r\n\r\n    targetFile.close();\r\n\r\n    QString expectedOutput(\r\n        \"\\t\\t<h2><a id=\\\"\" + topComponent_->getVlnv().toString() + \".memoryMaps\\\">1.1 Memory maps</a></h2>\\n\"\r\n        \"\\t\\t\\t<h3>1.1.1 Memory map \" + testMemoryMap->name() + \"</h3>\\n\"\r\n        \"\\t\\t\\t<p>\\n\"\r\n        \"\\t\\t\\t\" + getIndentString() + \"<strong>Description:</strong> \" +\r\n        testMemoryMap->description() + \"<br>\\n\"\r\n        \"\\t\\t\\t\" + getIndentString() + \"<strong>Address unit bits (AUB):</strong> \" +\r\n        testMemoryMap->getAddressUnitBits() + \"<br>\\n\"\r\n        \"\\t\\t\\t</p>\\n\"\r\n        \"\\t\\t\\t<h3>1.1.1.1 Address block \" + testAddressBlock->name() + \"</h3>\\n\"\r\n        \"\\t\\t\\t<p>\\n\"\r\n        \"\\t\\t\\t\" + getIndentString() + \"<strong>Description:</strong> \" + testAddressBlock->description() + \"<br>\\n\"\r\n        \"\\t\\t\\t\" + getIndentString() + \"<strong>Usage:</strong> \" + General::usage2Str(testAddressBlock->getUsage()) + \"<br>\\n\"\r\n        \"\\t\\t\\t\" + getIndentString() + \"<strong>Base address [AUB]:</strong> \" + testAddressBlock->getBaseAddress() + \"<br>\\n\"\r\n        \"\\t\\t\\t\" + getIndentString() + \"<strong>Range [AUB]:</strong> \" + testAddressBlock->getRange() + \"<br>\\n\"\r\n        \"\\t\\t\\t\" + getIndentString() + \"<strong>Width [AUB]:</strong> \" + testAddressBlock->getWidth() + \"<br>\\n\"\r\n        \"\\t\\t\\t\" + getIndentString() + \"<strong>Access:</strong> \" + AccessTypes::access2Str(testAddressBlock->getAccess()) + \"<br>\\n\"\r\n        \"\\t\\t\\t\" + getIndentString() + \"<strong>Volatile:</strong> \" + testAddressBlock->getVolatile() + \"<br>\\n\"\r\n        \"\\t\\t\\t</p>\\n\"\r\n        \"\\t\\t\\t<h4>Address block '\" + testAddressBlock->name() + \"' contains the following registers:</h4>\\n\"\r\n        \"\\t\\t\\t\" + getTableString() +\"\\\">\\n\"\r\n        \"\\t\\t\\t\\t<tr>\\n\"\r\n        \"\\t\\t\\t\\t\\t<th>Register name</th>\\n\"\r\n        \"\\t\\t\\t\\t\\t<th>Offset [AUB]</th>\\n\"\r\n        \"\\t\\t\\t\\t\\t<th>Size [bits]</th>\\n\"\r\n        \"\\t\\t\\t\\t\\t<th>Dimension</th>\\n\"\r\n        \"\\t\\t\\t\\t\\t<th>Volatile</th>\\n\"\r\n        \"\\t\\t\\t\\t\\t<th>Access</th>\\n\"\r\n        \"\\t\\t\\t\\t</tr>\\n\"\r\n        \"\\t\\t\\t\\t<tr>\\n\"\r\n        \"\\t\\t\\t\\t\\t<td>\" + testRegister->name() + \"</td>\\n\"\r\n        \"\\t\\t\\t\\t\\t<td>\" + testRegister->getAddressOffset() + \"</td>\\n\"\r\n        \"\\t\\t\\t\\t\\t<td>\" + testRegister->getSize() + \"</td>\\n\"\r\n        \"\\t\\t\\t\\t\\t<td>\" + testRegister->getDimension() + \"</td>\\n\"\r\n        \"\\t\\t\\t\\t\\t<td>\" + testRegister->getVolatile() + \"</td>\\n\"\r\n        \"\\t\\t\\t\\t\\t<td>\" + AccessTypes::access2Str(testRegister->getAccess()) + \"</td>\\n\"\r\n        \"\\t\\t\\t\\t</tr>\\n\"\r\n        \"\\t\\t\\t</table>\\n\"\r\n        \"\\t\\t\\t<h3>1.1.1.1.1 Register \" + testRegister->name() + \"</h3>\\n\"\r\n        \"\\t\\t\\t<p>\\n\"\r\n        \"\\t\\t\\t\" + getIndentString() + \"<strong>Description:</strong> \" + testRegister->description() + \"<br>\\n\"\r\n        \"\\t\\t\\t\" + getIndentString() + \"<strong>Offset [AUB]:</strong> \" + testRegister->getAddressOffset() + \"<br>\\n\"\r\n        \"\\t\\t\\t\" + getIndentString() + \"<strong>Size [bits]:</strong> \" + testRegister->getSize() + \"<br>\\n\"\r\n        \"\\t\\t\\t\" + getIndentString() + \"<strong>Dimension:</strong> \" + testRegister->getDimension() + \"<br>\\n\"\r\n        \"\\t\\t\\t\" + getIndentString() + \"<strong>Volatile:</strong> \" + testRegister->getVolatile() + \"<br>\\n\"\r\n        \"\\t\\t\\t\" + getIndentString() + \"<strong>Access:</strong> \" + AccessTypes::access2Str(testRegister->getAccess()) + \"<br>\\n\"\r\n        \"\\t\\t\\t</p>\\n\"\r\n        \"\\t\\t\\t<h4>Register '\" + testRegister->name() + \"' contains the following fields:</h4>\\n\"\r\n        \"\\t\\t\\t\" + getTableString() + \"List of fields contained within register \" + testRegister->name() +\r\n        \".\\\">\\n\"\r\n        \"\\t\\t\\t\\t<tr>\\n\"\r\n        \"\\t\\t\\t\\t\\t<th>Field name</th>\\n\"\r\n        \"\\t\\t\\t\\t\\t<th>Offset [bits]</th>\\n\"\r\n        \"\\t\\t\\t\\t\\t<th>Width [bits]</th>\\n\"\r\n        \"\\t\\t\\t\\t\\t<th>Volatile</th>\\n\"\r\n        \"\\t\\t\\t\\t\\t<th>Access</th>\\n\"\r\n        \"\\t\\t\\t\\t\\t<th>Resets</th>\\n\"        \r\n        \"\\t\\t\\t\\t\\t<th>Description</th>\\n\"\r\n        \"\\t\\t\\t\\t</tr>\\n\"\r\n        \"\\t\\t\\t\\t<tr>\\n\"\r\n        \"\\t\\t\\t\\t\\t<td><a id=\\\"\" + topComponent_->getVlnv().toString() + \".field.\" +\r\n        testField->name() + \"\\\">\" + testField->name() + \"</a></td>\\n\"\r\n        \"\\t\\t\\t\\t\\t<td>\" + testField->getBitOffset() + \"</td>\\n\"\r\n        \"\\t\\t\\t\\t\\t<td>\" + testField->getBitWidth() + \"</td>\\n\"\r\n        \"\\t\\t\\t\\t\\t<td>\" + testField->getVolatile().toString() + \"</td>\\n\"\r\n        \"\\t\\t\\t\\t\\t<td>\" + AccessTypes::access2Str(testField->getAccess()) + \"</td>\\n\"\r\n        \"\\t\\t\\t\\t\\t<td>HARD : 8'h3</td>\\n\"        \r\n        \"\\t\\t\\t\\t\\t<td>\" + testField->description() + \"</td>\\n\"\r\n        \"\\t\\t\\t\\t</tr>\\n\"\r\n        \"\\t\\t\\t</table>\\n\"\r\n        );\r\n\r\n    checkOutputFile(expectedOutput);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_DocumentGenerator::testPortsWrittenWithOnlyTopComponent()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_DocumentGenerator::testPortsWrittenWithOnlyTopComponent()\r\n{\r\n    QList <QSharedPointer <Parameter> > componentParameters;\r\n    QSharedPointer <Parameter> parameter = createTestParameter(\"parameter\", \"10\", \"Description\", \"ID_parameter\",\r\n        \"\", \"\");\r\n    componentParameters.append(parameter);\r\n\r\n    QSharedPointer <Port> portRef = createTestPort(\"portRef\", \"ID_parameter\", \"4\", \"ID_parameter\", \"2\",\r\n        \"ID_parameter\");\r\n\r\n    topComponent_->getPorts()->append(portRef);\r\n\r\n    topComponent_->getParameters()->append(componentParameters);\r\n\r\n    QScopedPointer<DocumentGenerator> generator(createTestGenerator());\r\n\r\n    QFile targetFile(targetPath_);\r\n    targetFile.open(QFile::WriteOnly);\r\n    QTextStream stream(&targetFile);\r\n\r\n    int subHeaderNumber = 1;\r\n    \r\n    generator->writePorts(stream, subHeaderNumber);\r\n\r\n    targetFile.close();\r\n\r\n    QString expectedOutput(\r\n        \"\\t\\t<h2><a id=\\\"\" + topComponent_->getVlnv().toString() + \".ports\\\">1.1 Ports</a></h2>\\n\"\r\n        \"\\t\\t\\t\" + getTableString() + \"List of all ports the component has.\\\">\\n\"\r\n        \"\\t\\t\\t\\t<tr>\\n\"\r\n        \"\\t\\t\\t\\t\\t<th>Name</th>\\n\"\r\n        \"\\t\\t\\t\\t\\t<th>Direction</th>\\n\"\r\n        \"\\t\\t\\t\\t\\t<th>Left bound</th>\\n\"\r\n        \"\\t\\t\\t\\t\\t<th>Right bound</th>\\n\"\r\n        \"\\t\\t\\t\\t\\t<th>Port type</th>\\n\"\r\n        \"\\t\\t\\t\\t\\t<th>Type definition</th>\\n\"\r\n        \"\\t\\t\\t\\t\\t<th>Default value</th>\\n\"\r\n        \"\\t\\t\\t\\t\\t<th>Array left</th>\\n\"\r\n        \"\\t\\t\\t\\t\\t<th>Array right</th>\\n\"\r\n        \"\\t\\t\\t\\t\\t<th>Description</th>\\n\"\r\n        \"\\t\\t\\t\\t</tr>\\n\"\r\n        \"\\t\\t\\t\\t<tr>\\n\"\r\n        \"\\t\\t\\t\\t\\t<td><a id=\\\"\" + topComponent_->getVlnv().toString() + \".port.\" + portRef->name() + \"\\\">\" +\r\n        portRef->name() + \"</a></td>\\n\"\r\n        \"\\t\\t\\t\\t\\t<td>\" + DirectionTypes::direction2Str(portRef->getDirection()) + \"</td>\\n\"\r\n        \"\\t\\t\\t\\t\\t<td>parameter</td>\\n\"\r\n        \"\\t\\t\\t\\t\\t<td>\" + portRef->getRightBound() + \"</td>\\n\"\r\n        \"\\t\\t\\t\\t\\t<td>\" + portRef->getTypeName() + \"</td>\\n\"\r\n        \"\\t\\t\\t\\t\\t<td>\" + portRef->getTypeDefinition(portRef->getTypeName()) + \"</td>\\n\"\r\n        \"\\t\\t\\t\\t\\t<td>parameter</td>\\n\"\r\n        \"\\t\\t\\t\\t\\t<td>\" + portRef->getArrayLeft() + \"</td>\\n\"\r\n        \"\\t\\t\\t\\t\\t<td>parameter</td>\\n\"\r\n        \"\\t\\t\\t\\t\\t<td>\" + portRef->description() + \"</td>\\n\"\r\n        \"\\t\\t\\t\\t</tr>\\n\"\r\n        \"\\t\\t\\t</table>\\n\");\r\n\r\n    checkOutputFile(expectedOutput);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_DocumentGenerator::testBusInterfacesWrittenWithoutPorts()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_DocumentGenerator::testBusInterfacesWrittenWithoutPorts()\r\n{\r\n    QSharedPointer <BusInterface> busInterface (new BusInterface);\r\n    busInterface->setName(\"interface\");\r\n    busInterface->setInterfaceMode(General::MASTER);\r\n    \r\n    QSharedPointer <BusInterface> busInterfaceWithSystemMode (new BusInterface);\r\n    busInterfaceWithSystemMode->setName(\"interface2\");\r\n    busInterfaceWithSystemMode->setInterfaceMode(General::SYSTEM);\r\n    busInterfaceWithSystemMode->setSystem(\"systemGroup\");\r\n    \r\n    VLNV firstVlnv(VLNV::COMPONENT, \"Test\", \"TestLibrary\", \"FirstComponent\", \"1.0\");\r\n    QSharedPointer<ConfigurableVLNVReference> absDefVlnv(new ConfigurableVLNVReference(firstVlnv));\r\n\r\n    QSharedPointer<AbstractionType> absDef(new AbstractionType);\r\n    absDef->setAbstractionRef(absDefVlnv);\r\n\r\n    VLNV secondVlnv(VLNV::COMPONENT, \"Test\", \"TestLibrary\", \"SecondComponent\", \"1.0\");\r\n    QSharedPointer<ConfigurableVLNVReference> absDefVlnv2(new ConfigurableVLNVReference(secondVlnv));\r\n\r\n    QSharedPointer<AbstractionType> absDef2(new AbstractionType);\r\n    absDef2->setAbstractionRef(absDefVlnv2);\r\n\r\n    QSharedPointer<QList<QSharedPointer<AbstractionType> > > abstractionDefs(new QList<QSharedPointer<AbstractionType> >);\r\n    abstractionDefs->append(absDef);\r\n    abstractionDefs->append(absDef2);\r\n\r\n    QSharedPointer<QList<QSharedPointer<AbstractionType> > > abstractionDefs2(new QList<QSharedPointer<AbstractionType> >);\r\n    abstractionDefs2->append(absDef2);\r\n\r\n    busInterface->setAbstractionTypes(abstractionDefs);\r\n    busInterfaceWithSystemMode->setAbstractionTypes(abstractionDefs2);\r\n\r\n    VLNV firstBusDefVlnv(VLNV::COMPONENT, \"Test\", \"TestLibrary\", \"FirstBusDef\", \"1.0\");\r\n    ConfigurableVLNVReference busDef1(firstBusDefVlnv);\r\n    \r\n    VLNV secondBusDefVlnv(VLNV::COMPONENT, \"Test\", \"TestLibrary\", \"SecondBusDef\", \"1.0\");\r\n    ConfigurableVLNVReference busDef2(secondBusDefVlnv);\r\n\r\n    busInterface->setBusType(busDef1);\r\n    busInterfaceWithSystemMode->setBusType(busDef2);\r\n\r\n    topComponent_->getBusInterfaces()->append(busInterface);\r\n    topComponent_->getBusInterfaces()->append(busInterfaceWithSystemMode);\r\n\r\n    QScopedPointer<DocumentGenerator> generator(createTestGenerator());\r\n\r\n    QFile targetFile(targetPath_);\r\n    targetFile.open(QFile::WriteOnly);\r\n    QTextStream stream(&targetFile);\r\n\r\n    int subHeaderNumber = 1;\r\n\r\n    generator->writeInterfaces(stream, subHeaderNumber);\r\n\r\n    targetFile.close();\r\n\r\n    QString expectedOutput(\r\n        \"\\t\\t<h2><a id=\\\"\" + topComponent_->getVlnv().toString() + \".interfaces\\\">1.1 Bus interfaces</a></h2>\\n\"\r\n        \"\\t\\t\\t<h3>1.1.1 Bus interface \" + busInterface->name() + \"</h3>\\n\"\r\n        \"\\t\\t\\t<p>\\n\"\r\n        \"\\t\\t\\t\" + getIndentString() + \"<strong>Description:</strong> \" + busInterface->description() + \"<br>\\n\"\r\n        \"\\t\\t\\t\" + getIndentString() + \"<strong>Interface mode:</strong> \" +\r\n        General::interfaceMode2Str(busInterface->getInterfaceMode()) + \"<br>\\n\"\r\n        \"\\t\\t\\t\" + getIndentString() + \"<strong>Bus definition:</strong> Test:TestLibrary:FirstBusDef:1.0<br>\\n\"\r\n        \"\\t\\t\\t\" + getIndentString() + \"<strong>Abstraction definitions:</strong> Test:TestLibrary:FirstComponent:1.0, Test:TestLibrary:SecondComponent:1.0<br>\\n\"\r\n        \"\\t\\t\\t\" + getIndentString() + \"<strong>Ports used in this interface:</strong> None<br>\\n\"\r\n        \"\\t\\t\\t</p>\\n\"\r\n        \"\\t\\t\\t<h3>1.1.2 Bus interface \" + busInterfaceWithSystemMode->name() + \"</h3>\\n\"\r\n        \"\\t\\t\\t<p>\\n\"\r\n        \"\\t\\t\\t\" + getIndentString() + \"<strong>Description:</strong> \" + busInterfaceWithSystemMode->description() + \"<br>\\n\"\r\n        \"\\t\\t\\t\" + getIndentString() + \"<strong>Interface mode:</strong> system<br>\\n\"\r\n        \"\\t\\t\\t\" + getIndentString() + \"<strong>System group:</strong> systemGroup<br>\\n\"\r\n        \"\\t\\t\\t\" + getIndentString() + \"<strong>Bus definition:</strong> Test:TestLibrary:SecondBusDef:1.0<br>\\n\"\r\n        \"\\t\\t\\t\" + getIndentString() + \"<strong>Abstraction definitions:</strong> Test:TestLibrary:SecondComponent:1.0<br>\\n\"\r\n        \"\\t\\t\\t\" + getIndentString() + \"<strong>Ports used in this interface:</strong> None<br>\\n\"\r\n        \"\\t\\t\\t</p>\\n\"\r\n        );\r\n\r\n    checkOutputFile(expectedOutput);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_DocumentGenerator::testFileSetsWrittenForTopComponent()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_DocumentGenerator::testFileSetsWrittenForTopComponent()\r\n{\r\n    QScopedPointer<DocumentGenerator> generator(createTestGenerator());\r\n\r\n    QSharedPointer<FileSet> testFileSet(new FileSet);\r\n    testFileSet->setName(\"testFileSet\");\r\n    testFileSet->setDescription(\"example description\");\r\n\r\n    QSharedPointer <QStringList> testFileSetGroups(new QStringList({ \"documentation\", \"testing\" }));\r\n\r\n    testFileSet->setGroups(testFileSetGroups);\r\n\r\n    QSharedPointer<FileBuilder> testFileBuilder(new FileBuilder);\r\n    testFileBuilder->setFileType(\"vhdlSource\");\r\n    testFileBuilder->setCommand(\"vcom\");\r\n\r\n    QSharedPointer<File> testFile1(new File);\r\n    testFile1->setName(\"testFile1.vhd\");\r\n    testFile1->setDescription(\"a test file 1\");\r\n    testFile1->addFileType(\"vhdlSource\");\r\n    testFile1->addFileType(\"vhdlSource-87\");\r\n    testFile1->setLogicalName(\"testLogicalName\");\r\n\r\n    QSharedPointer<BuildCommand> testFile1BuildCommand(new BuildCommand);\r\n    testFile1BuildCommand->setCommand(\"vcom\");\r\n    testFile1BuildCommand->setFlags(\"\");\r\n    testFile1->setBuildcommand(testFile1BuildCommand);\r\n\r\n    QSharedPointer<File> testFile2(new File);\r\n    testFile2->setName(\"testFile2.v\");\r\n    testFile2->setDescription(\"a test file 2\");\r\n    testFile2->addFileType(\"verilogSource\");\r\n    testFile2->addFileType(\"vhdlSource\");\r\n\r\n    QSharedPointer<BuildCommand> testFile2BuildCommand(new BuildCommand);\r\n    testFile2BuildCommand->setCommand(\"make\");\r\n    testFile2BuildCommand->setFlags(\"--verbose\");\r\n    testFile2->setBuildcommand(testFile2BuildCommand);\r\n\r\n    testFileSet->addFile(testFile1);\r\n    testFileSet->addFile(testFile2);\r\n\r\n    testFileBuilder->setFlags(\"\");\r\n\r\n    QSharedPointer<QList <QSharedPointer<FileBuilder>>> defaultFileBuilders(new QList<QSharedPointer<FileBuilder> >({ testFileBuilder }));\r\n    testFileSet->setDefaultFileBuilders(defaultFileBuilders);\r\n    topComponent_->getFileSets()->append(testFileSet);\r\n\r\n    QString testFile1AbsPath = General::getAbsolutePath(library_.getPath(topComponent_->getVlnv()), testFile1->name());\r\n    QString testFile1PathFromDoc = General::getRelativePath(targetPath_, testFile1AbsPath);\r\n\r\n    QString testFile2AbsPath = General::getAbsolutePath(library_.getPath(topComponent_->getVlnv()), testFile2->name());\r\n    QString testFile2PathFromDoc = General::getRelativePath(targetPath_, testFile2AbsPath);\r\n\r\n    QFile targetFile(targetPath_);\r\n    targetFile.open(QFile::WriteOnly);\r\n    QTextStream stream(&targetFile);\r\n\r\n    int subHeaderNumber = 1;\r\n\r\n    generator->writeFileSets(stream, subHeaderNumber);\r\n\r\n    targetFile.close();\r\n\r\n    QString groups = testFileSet->getGroups()->join(\", \");\r\n\r\n    QString expectedOutput(\r\n        \"\\t\\t<h2><a id=\\\"\" + topComponent_->getVlnv().toString() + \".fileSets\\\">1.1 File sets</a></h2>\\n\"\r\n        \"\\t\\t\\t<h3>1.1.1 File set \" + testFileSet->name() + \"</h3>\\n\"\r\n        \"\\t\\t\\t<p>\\n\"\r\n        \"\\t\\t\\t\" + getIndentString() + \"<strong>Description:</strong> \" + testFileSet->description() + \"<br>\\n\"\r\n        \"\\t\\t\\t\" + getIndentString() + \"<strong>Identifiers:</strong> \" + groups + \"<br>\\n\"\r\n        \"\\t\\t\\t\" + getIndentString() + \"<strong>Default file builders:</strong>\\n\"\r\n        \"\\t\\t\\t</p>\\n\"\r\n        \"\\t\\t\\t\" + getTableString() + \"Default file build commands\" + \"\\\">\\n\"\r\n        \"\\t\\t\\t\\t<tr>\\n\"\r\n        \"\\t\\t\\t\\t\\t<th>File type</th>\\n\"\r\n        \"\\t\\t\\t\\t\\t<th>Command</th>\\n\"\r\n        \"\\t\\t\\t\\t\\t<th>Flags</th>\\n\"\r\n        \"\\t\\t\\t\\t\\t<th>Replace default flags</th>\\n\"\r\n        \"\\t\\t\\t\\t</tr>\\n\"\r\n        \"\\t\\t\\t\\t<tr>\\n\"\r\n        \"\\t\\t\\t\\t\\t<td>\" + testFileBuilder->getFileType().type_ + \"</td>\\n\"\r\n        \"\\t\\t\\t\\t\\t<td>\" + testFileBuilder->getCommand() + \"</td>\\n\"\r\n        \"\\t\\t\\t\\t\\t<td>\" + testFileBuilder->getFlags() + \"</td>\\n\"\r\n        \"\\t\\t\\t\\t\\t<td>\" + testFileBuilder->getReplaceDefaultFlags() + \"</td>\\n\"\r\n        \"\\t\\t\\t\\t</tr>\\n\"\r\n        \"\\t\\t\\t</table>\\n\"\r\n        \"\\t\\t\\t<h4>1.1.1.1 Files</h4>\\n\"\r\n        \"\\t\\t\\t\" + getTableString() + \"List of files contained in this file set.\" + \"\\\">\\n\"\r\n        \"\\t\\t\\t\\t<tr>\\n\"\r\n        \"\\t\\t\\t\\t\\t<th>File name</th>\\n\"\r\n        \"\\t\\t\\t\\t\\t<th>Logical name</th>\\n\"\r\n        \"\\t\\t\\t\\t\\t<th>Build command</th>\\n\"\r\n        \"\\t\\t\\t\\t\\t<th>Build flags</th>\\n\"\r\n        \"\\t\\t\\t\\t\\t<th>Specified file types</th>\\n\"\r\n        \"\\t\\t\\t\\t\\t<th>Description</th>\\n\"\r\n        \"\\t\\t\\t\\t</tr>\\n\"\r\n        \"\\t\\t\\t\\t<tr>\\n\"\r\n        \"\\t\\t\\t\\t\\t<td><a href=\\\"\" + testFile1PathFromDoc + \"\\\">\" + testFile1->name() + \"</a></td>\\n\"\r\n        \"\\t\\t\\t\\t\\t<td>\" + testFile1->getLogicalName() + \"</td>\\n\"\r\n        \"\\t\\t\\t\\t\\t<td>\" + testFile1->getBuildCommand()->getCommand() + \"</td>\\n\"\r\n        \"\\t\\t\\t\\t\\t<td>\" + testFile1->getBuildCommand()->getFlags() + \"</td>\\n\"\r\n        \"\\t\\t\\t\\t\\t<td>\" + testFile1->getFileTypeNames().join(\",<br>\") + \"</td>\\n\"\r\n        \"\\t\\t\\t\\t\\t<td>\" + testFile1->getDescription() + \"</td>\\n\"\r\n        \"\\t\\t\\t\\t</tr>\\n\"\r\n        \"\\t\\t\\t\\t<tr>\\n\"\r\n        \"\\t\\t\\t\\t\\t<td><a href=\\\"\" + testFile2PathFromDoc + \"\\\">\" + testFile2->name() + \"</a></td>\\n\"\r\n        \"\\t\\t\\t\\t\\t<td>\" + testFile2->getLogicalName() + \"</td>\\n\"\r\n        \"\\t\\t\\t\\t\\t<td>\" + testFile2->getBuildCommand()->getCommand() + \"</td>\\n\"\r\n        \"\\t\\t\\t\\t\\t<td>\" + testFile2->getBuildCommand()->getFlags() + \"</td>\\n\"\r\n        \"\\t\\t\\t\\t\\t<td>\" + testFile2->getFileTypeNames().join(\",<br>\") + \"</td>\\n\"\r\n        \"\\t\\t\\t\\t\\t<td>\" + testFile2->getDescription() + \"</td>\\n\"\r\n        \"\\t\\t\\t\\t</tr>\\n\"\r\n        \"\\t\\t\\t</table>\\n\"\r\n    );\r\n\r\n    checkOutputFile(expectedOutput);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_DocumentGenerator::testViewsWrittenForTopComponent()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_DocumentGenerator::testViewsWrittenForTopComponent()\r\n{\r\n    QSharedPointer<View> flatView(new View(\"testView\"));\r\n\r\n    topComponent_->getViews()->append(flatView);\r\n\r\n    VLNV firstVlnv(VLNV::COMPONENT, \"Test\", \"TestLibrary\", \"FirstComponent\", \"1.0\");\r\n    QSharedPointer<ConfigurableVLNVReference> instanceVLNV(new ConfigurableVLNVReference(firstVlnv));\r\n    QSharedPointer<ComponentInstance> firstInstance(new ComponentInstance(\"firstInstance\", instanceVLNV));\r\n\r\n    QSharedPointer<Component> refComponent = QSharedPointer<Component>(new Component(firstVlnv, Document::Revision::Std14));\r\n\r\n    QList <QSharedPointer<Parameter> > componentParameters;\r\n\r\n    QSharedPointer<Parameter> targetParameter = createTestParameter(\"firstParameter\", \"10\",\r\n        \"\", \"ID_TARGET\", \"\", \"\");\r\n\r\n    QSharedPointer<ModuleParameter> testModuleParameter(new ModuleParameter);\r\n    testModuleParameter->setName(\"testModuleParameter\");\r\n    testModuleParameter->setValue(\"1\");\r\n    testModuleParameter->setDescription(\"module param description\");\r\n    testModuleParameter->setDataType(\"testDataType\");\r\n    testModuleParameter->setType(\"int\");\r\n    testModuleParameter->setUsageType(\"typed\");\r\n\r\n    QSharedPointer<ComponentInstantiation> componentInstantiation(new ComponentInstantiation());\r\n    componentInstantiation->setName(\"testInstantiation\");\r\n    componentInstantiation->getParameters()->append(targetParameter);\r\n    componentInstantiation->getModuleParameters()->append(testModuleParameter);\r\n    componentInstantiation->setLanguage(\"C\");\r\n    componentInstantiation->setLanguageStrictness(true);\r\n    componentInstantiation->setLibraryName(\"testLibrary\");\r\n    componentInstantiation->setPackageName(\"testPackage\");\r\n    componentInstantiation->setModuleName(\"testModuleName\");\r\n\r\n\r\n    topComponent_->getComponentInstantiations()->append(componentInstantiation);\r\n    flatView->setComponentInstantiationRef(\"testInstantiation\");\r\n    \r\n\r\n    QFile targetFile(targetPath_);\r\n    targetFile.open(QFile::WriteOnly);\r\n    QTextStream stream(&targetFile);\r\n\r\n    int subHeaderNumber = 1;\r\n    QStringList pictureList;\r\n\r\n    QScopedPointer<DocumentGenerator> generator(createTestGenerator());\r\n\r\n    generator->writeViews(stream, subHeaderNumber, pictureList);\r\n\r\n    targetFile.close();\r\n\r\n    QString expectedOutput(\r\n        \"\\t\\t<h2><a id=\\\"\" + topComponent_->getVlnv().toString() + \".views\\\">1.1 Views</a></h2>\\n\"\r\n        \"\\t\\t\\t<h3>1.1.1 View: testView</h3>\\n\"\r\n        \"\\t\\t\\t<h4>1.1.1.1 Component instantiation: testInstantiation</h4>\\n\"\r\n        \"\\t\\t\\t<p>\\n\"\r\n        \"\\t\\t\\t\\t&nbsp;&nbsp;&nbsp;<strong>Language: </strong>C <strong>strict</strong><br>\\n\" \r\n        \"\\t\\t\\t\\t&nbsp;&nbsp;&nbsp;<strong>Library: </strong>testLibrary<br>\\n\" \r\n        \"\\t\\t\\t\\t&nbsp;&nbsp;&nbsp;<strong>Package: </strong>testPackage<br>\\n\" \r\n        \"\\t\\t\\t\\t&nbsp;&nbsp;&nbsp;<strong>Module name: </strong>testModuleName<br>\\n\" \r\n        \"\\t\\t\\t</p>\\n\"\r\n        \"\\t\\t\\t<p><strong>Module parameters:</strong></p>\\n\"\r\n        \"\\t\\t\\t<table frame=\\\"box\\\" rules=\\\"all\\\" border=\\\"1\\\" cellPadding=\\\"3\\\" title=\\\"\\\">\\n\"\r\n        \"\\t\\t\\t\\t<tr>\\n\"\r\n        \"\\t\\t\\t\\t\\t<th>Name</th>\\n\"\r\n        \"\\t\\t\\t\\t\\t<th>Type</th>\\n\"\r\n        \"\\t\\t\\t\\t\\t<th>Value</th>\\n\"\r\n        \"\\t\\t\\t\\t\\t<th>Data type</th>\\n\"\r\n        \"\\t\\t\\t\\t\\t<th>Usage type</th>\\n\"\r\n        \"\\t\\t\\t\\t\\t<th>Resolve</th>\\n\"\r\n        \"\\t\\t\\t\\t\\t<th>Bit vector left</th>\\n\"\r\n        \"\\t\\t\\t\\t\\t<th>Bit vector right</th>\\n\"\r\n        \"\\t\\t\\t\\t\\t<th>Array left</th>\\n\"\r\n        \"\\t\\t\\t\\t\\t<th>Array right</th>\\n\"\r\n        \"\\t\\t\\t\\t\\t<th>Description</th>\\n\"\r\n        \"\\t\\t\\t\\t</tr>\\n\"\r\n        \"\\t\\t\\t\\t<tr>\\n\"\r\n        \"\\t\\t\\t\\t\\t<td>testModuleParameter</td>\\n\"\r\n        \"\\t\\t\\t\\t\\t<td>int</td>\\n\"\r\n        \"\\t\\t\\t\\t\\t<td>1</td>\\n\"\r\n        \"\\t\\t\\t\\t\\t<td>testDataType</td>\\n\"\r\n        \"\\t\\t\\t\\t\\t<td>typed</td>\\n\"\r\n        \"\\t\\t\\t\\t\\t<td>\" + testModuleParameter->getValueResolve() + \"</td>\\n\"\r\n        \"\\t\\t\\t\\t\\t<td>\" + testModuleParameter->getVectorLeft() + \"</td>\\n\"\r\n        \"\\t\\t\\t\\t\\t<td>\" + testModuleParameter->getVectorRight() + \"</td>\\n\"\r\n        \"\\t\\t\\t\\t\\t<td>\" + testModuleParameter->getArrayLeft() + \"</td>\\n\"\r\n        \"\\t\\t\\t\\t\\t<td>\" + testModuleParameter->getArrayRight() + \"</td>\\n\"\r\n        \"\\t\\t\\t\\t\\t<td>\" + testModuleParameter->description() + \"</td>\\n\"\r\n        \"\\t\\t\\t\\t</tr>\\n\"\r\n        \"\\t\\t\\t</table>\\n\"\r\n        \"\\t\\t\\t<p><strong>Parameters:</strong></p>\\n\"\r\n        \"\\t\\t\\t<table frame=\\\"box\\\" rules=\\\"all\\\" border=\\\"1\\\" cellPadding=\\\"3\\\" title=\\\"\\\">\\n\"\r\n        \"\\t\\t\\t\\t<tr>\\n\"\r\n        \"\\t\\t\\t\\t\\t<th>Name</th>\\n\"\r\n        \"\\t\\t\\t\\t\\t<th>Type</th>\\n\"\r\n        \"\\t\\t\\t\\t\\t<th>Value</th>\\n\"\r\n        \"\\t\\t\\t\\t\\t<th>Resolve</th>\\n\"\r\n        \"\\t\\t\\t\\t\\t<th>Bit vector left</th>\\n\"\r\n        \"\\t\\t\\t\\t\\t<th>Bit vector right</th>\\n\"\r\n        \"\\t\\t\\t\\t\\t<th>Array left</th>\\n\"\r\n        \"\\t\\t\\t\\t\\t<th>Array right</th>\\n\"\r\n        \"\\t\\t\\t\\t\\t<th>Description</th>\\n\"\r\n        \"\\t\\t\\t\\t</tr>\\n\"\r\n        \"\\t\\t\\t\\t<tr>\\n\"\r\n        \"\\t\\t\\t\\t\\t<td>firstParameter</td>\\n\"\r\n        \"\\t\\t\\t\\t\\t<td></td>\\n\"\r\n        \"\\t\\t\\t\\t\\t<td>10</td>\\n\"\r\n        \"\\t\\t\\t\\t\\t<td></td>\\n\"\r\n        \"\\t\\t\\t\\t\\t<td></td>\\n\"\r\n        \"\\t\\t\\t\\t\\t<td></td>\\n\"\r\n        \"\\t\\t\\t\\t\\t<td></td>\\n\"\r\n        \"\\t\\t\\t\\t\\t<td></td>\\n\"\r\n        \"\\t\\t\\t\\t\\t<td></td>\\n\"\r\n        \"\\t\\t\\t\\t</tr>\\n\"\r\n        \"\\t\\t\\t</table>\\n\"\r\n        );\r\n\r\n    checkOutputFile(expectedOutput);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_DocumentGenerator::testHierarchicalDesignIsWritten()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_DocumentGenerator::testDesignIsWritten()\r\n{\r\n    VLNV designVlnv(VLNV::DESIGN, \"Test\", \"TestLibrary\", \"TestDesign\", \"1.0\");\r\n    QSharedPointer<Design> design = QSharedPointer<Design>(new Design(designVlnv, Document::Revision::Std14));\r\n    library_.writeModelToFile(\"C:/Test/TestLibrary/TestDesign/1.0/TestDesign.1.0.xml\", design);\r\n    library_.addComponent(design);\r\n\r\n    VLNV firstVlnv (VLNV::COMPONENT, \"Test\", \"TestLibrary\", \"FirstComponent\", \"1.0\");\r\n    QSharedPointer<Component> refComponent = QSharedPointer<Component>(new Component(firstVlnv, Document::Revision::Std14));\r\n\r\n    QList <QSharedPointer<Parameter> > componentParameters;\r\n\r\n    QSharedPointer<Parameter> targetParameter = createTestParameter(\"firstParameter\", \"10\", \"\", \"ID_TARGET\", \"\",\r\n        \"\");\r\n    QSharedPointer<Parameter> referParameter = createTestParameter(\"referer\", \"ID_TARGET\", \"\", \"ID-REF\", \"\", \"\");\r\n    componentParameters.append(targetParameter);\r\n    componentParameters.append(referParameter);\r\n\r\n    refComponent->getParameters()->append(componentParameters);\r\n\r\n    library_.addComponent(refComponent);\r\n\r\n    QSharedPointer<ConfigurableVLNVReference> instanceVLNV(new ConfigurableVLNVReference(firstVlnv));\r\n    QSharedPointer<ComponentInstance> firstInstance(new ComponentInstance(\"firstInstance\", instanceVLNV));\r\n    firstInstance->getConfigurableElementValues()->append(createConfigurableElementvalues(refComponent));\r\n    \r\n    design->getComponentInstances()->append(firstInstance);\r\n\r\n    QSharedPointer<View> hierarchicalView(new View);\r\n    hierarchicalView->setName(\"HierarchicalView\");\r\n    hierarchicalView->setDesignInstantiationRef(\"design_instantiation\");\r\n    topComponent_->getViews()->append(hierarchicalView);\r\n\r\n    QSharedPointer<DesignInstantiation> designInstantiation(new DesignInstantiation(\"design_instantiation\"));\r\n    designInstantiation->setDesignReference(\r\n        QSharedPointer<ConfigurableVLNVReference>(new ConfigurableVLNVReference(designVlnv)));\r\n\r\n    topComponent_->getDesignInstantiations()->append(designInstantiation);\r\n\r\n    QScopedPointer<DocumentGenerator> generator(createTestGenerator());\r\n\r\n    QFile targetFile(targetPath_);\r\n    targetFile.open(QFile::WriteOnly);\r\n    QTextStream stream(&targetFile);\r\n\r\n    int subHeaderNumber = 1;\r\n    QStringList files;\r\n\r\n    generator->writeViews(stream, subHeaderNumber, files);\r\n\r\n    targetFile.close();\r\n\r\n    QString expectedOutput(\r\n        \"\\t\\t<h2><a id=\\\"Test:TestLibrary:TestComponent:1.0.views\\\">1.1 Views</a></h2>\\n\"\r\n        \"\\t\\t\\t<h3>1.1.1 View: HierarchicalView</h3>\\n\"\r\n        \"\\t\\t\\t<h4>1.1.1.1 Design instantiation: design_instantiation</h4>\\n\"\r\n        \"\\t\\t\\t<p>\\n\"\r\n        \"\\t\\t\\t\\t&nbsp;&nbsp;&nbsp;<strong>Design: </strong>Test:TestLibrary:TestDesign:1.0<br>\\n\"\r\n        \"\\t\\t\\t\\t&nbsp;&nbsp;&nbsp;<strong>IP-Xact file: </strong><a href=\\\"\\\">TestDesign.1.0.xml</a><br>\\n\"\r\n        \"\\t\\t\\t</p>\\n\"\r\n        \"\\t\\t\\tDiagram of design Test:TestLibrary:TestDesign:1.0:<br>\\n\"\r\n        \"\\t\\t\\t<img src=\\\"/Test.TestLibrary.TestComponent.1.0.HierarchicalView.png\\\" alt=\\\"View: HierarchicalView preview picture\\\"><br>\\n\"\r\n        \"\\t\\t\\t<br>\\n\"\r\n        );\r\n\r\n    readOutputFile();\r\n\r\n    checkOutputFile(expectedOutput);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_DocumentGenerator::testEndOfDocumentWrittenForTopComponent()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_DocumentGenerator::testEndOfDocumentWrittenForTopComponent()\r\n{\r\n    QScopedPointer<DocumentGenerator> generator(createTestGenerator());\r\n\r\n    QFile targetFile(targetPath_);\r\n    targetFile.open(QFile::WriteOnly);\r\n    QTextStream stream(&targetFile);\r\n\r\n    generator->writeEndOfDocument(stream);\r\n\r\n    targetFile.close();\r\n\r\n    QString expectedOutput(\r\n        \"\\t</body>\\n\"\r\n        \"</html>\\n\"\r\n        );\r\n\r\n    checkOutputFile(expectedOutput);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_DocumentGenerator::createTestGenerator()\r\n//-----------------------------------------------------------------------------\r\nDocumentGenerator* tst_DocumentGenerator::createTestGenerator()\r\n{\r\n    library_.writeModelToFile(\"C:/Test/TestLibrary/TestComponent/1.0/TestComponent.1.0.xml\", topComponent_);\r\n    library_.addComponent(topComponent_);\r\n\r\n    int componentNumber = 1;\r\n\r\n    DocumentGenerator* generator (new DocumentGenerator(&library_, topComponentVlnv_, &designWidgetFactory_, \r\n        &expressionFormatterFactory_, componentNumber, generatorParentWidget_));\r\n\r\n    generator->setFormat(DocumentGenerator::HTML);\r\n    return generator;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_DocumentGenerator::readOutputFile()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_DocumentGenerator::readOutputFile()\r\n{\r\n    QFile outputFile(targetPath_);\r\n\r\n    QVERIFY(outputFile.open(QIODevice::ReadOnly));\r\n\r\n    output_ = outputFile.readAll();\r\n    outputFile.close();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_DocumentGenerator::checkOutputFile()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_DocumentGenerator::checkOutputFile(QString const& expectedOutput)\r\n{\r\n    readOutputFile();\r\n\r\n    if (!output_.contains(expectedOutput))\r\n    {\r\n        QStringList outputLines = output_.split(\"\\n\");\r\n        QStringList expectedLines = expectedOutput.split(\"\\n\");\r\n\r\n        QVERIFY(outputLines.count() >= expectedLines.count());\r\n\r\n        int lineOffset = outputLines.indexOf(expectedLines.first());\r\n\r\n        if (lineOffset == -1)\r\n        {\r\n            readOutputFile();\r\n            QCOMPARE(output_, expectedOutput);\r\n        }\r\n        else\r\n        {\r\n            int lineCount = expectedLines.count();\r\n            for (int i = 0; i < lineCount; i++)\r\n            {\r\n                QCOMPARE(outputLines.at(i + lineOffset), expectedLines.at(i));\r\n            }\r\n        }\r\n    }\r\n    else if (output_.count(expectedOutput) != 1)\r\n    {\r\n        QVERIFY2(false, QString(expectedOutput + \" was found \" + QString::number(output_.count(expectedOutput)) +\r\n            \" times in output.\").toLocal8Bit());\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_DocumentGenerator::createTestParameter()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<Parameter> tst_DocumentGenerator::createTestParameter(QString const& name, QString const& value,\r\n    QString const& description, QString const& uuID, QString const& arrayLeft, QString const& arrayRight)\r\n{\r\n    QSharedPointer<Parameter> parameter (new Parameter);\r\n    parameter->setName(name);\r\n    parameter->setValue(value);\r\n    parameter->setDescription(description);\r\n    parameter->setValueId(uuID);\r\n    parameter->setArrayLeft(arrayLeft);\r\n    parameter->setArrayRight(arrayRight);\r\n\r\n    return parameter;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_DocumentGenerator::createTestPort()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<Port> tst_DocumentGenerator::createTestPort(QString const& name, QString const& leftBound,\r\n    QString const& rightBound, QString const& defaultValue, QString const& arrayLeft, QString const& arrayRight)\r\n{\r\n    QSharedPointer<Port> newPort (new Port);\r\n    newPort->setDirection(DirectionTypes::DIRECTION_PHANTOM);\r\n    newPort->setName(name);\r\n    newPort->setLeftBound(leftBound);\r\n    newPort->setRightBound(rightBound);\r\n    newPort->setDefaultValue(defaultValue);\r\n    newPort->setArrayLeft(arrayLeft);\r\n    newPort->setArrayRight(arrayRight);\r\n\r\n    return newPort;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_DocumentGenerator::createConfigurableElementvalues()\r\n//-----------------------------------------------------------------------------\r\nQList<QSharedPointer<ConfigurableElementValue> > tst_DocumentGenerator::createConfigurableElementvalues(QSharedPointer <Component> component)\r\n{    \r\n    ExpressionFormatter* refExpressionFormatter = expressionFormatterFactory_.makeExpressionFormatter(component);\r\n\r\n    QList<QSharedPointer<ConfigurableElementValue> > instanceConfigurableElementValues;\r\n\r\n    foreach (QSharedPointer<Parameter> parameter, *component->getParameters())\r\n    {\r\n        instanceConfigurableElementValues.append(QSharedPointer<ConfigurableElementValue>(\r\n            new ConfigurableElementValue(refExpressionFormatter->formatReferringExpression(parameter->getValue()), parameter->name())));\r\n    }\r\n\r\n    delete refExpressionFormatter;\r\n    refExpressionFormatter = 0;\r\n\r\n    return instanceConfigurableElementValues;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_DocumentGenerator::createTestField()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer <Field> tst_DocumentGenerator::createTestField(QString const& name, QString const& description,\r\n    QString const& offset, QString const& width)\r\n{\r\n    QSharedPointer <Field> testField (new Field);\r\n    testField->setName(name);\r\n    testField->setDescription(description);\r\n    testField->setBitOffset(offset);\r\n    testField->setBitWidth(width);\r\n    testField->setVolatile(false);\r\n    testField->setAccess(AccessTypes::READ_ONLY);\r\n\r\n    return testField;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_DocumentGenerator::createTestRegister()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer <Register> tst_DocumentGenerator::createTestRegister(QString const& name, QString const& offset,\r\n    QString const& dimension, QString const& size, QString const& description)\r\n{\r\n    QSharedPointer<Register> testRegister (new Register);\r\n    testRegister->setName(name);\r\n    testRegister->setAddressOffset(offset);\r\n    testRegister->setSize(size);\r\n    testRegister->setDimension(dimension);\r\n    testRegister->setDescription(description);\r\n    testRegister->setVolatile(true);\r\n    testRegister->setAccess(AccessTypes::READ_WRITE);\r\n    //testRegister->setRegisterValue(\"2\");\r\n    //testRegister->setRegisterMask(\"4\");\r\n\r\n    return testRegister;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_DocumentGenerator::createTestAddressBlock()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer <AddressBlock> tst_DocumentGenerator::createTestAddressBlock(QString const& name,\r\n    QString const& description, QString const& baseAddress, QString const& range, QString const& width,\r\n    QList<QSharedPointer<Register> > registers)\r\n{\r\n    QSharedPointer <AddressBlock> testAddressBlock(new AddressBlock);\r\n    testAddressBlock->setName(name);\r\n    testAddressBlock->setUsage(General::REGISTER);\r\n    testAddressBlock->setDescription(description);\r\n    testAddressBlock->setBaseAddress(baseAddress);\r\n    testAddressBlock->setRange(range);\r\n    testAddressBlock->setWidth(width);\r\n    testAddressBlock->setAccess(AccessTypes::READ_WRITE);\r\n    testAddressBlock->setVolatile(true);\r\n\r\n    foreach (QSharedPointer<RegisterBase> testRegister, registers)\r\n    {\r\n        testAddressBlock->getRegisterData()->append(testRegister);\r\n    }\r\n\r\n    return testAddressBlock;\r\n}\r\n\r\nQSharedPointer<AddressBlock> tst_DocumentGenerator::createAddressBlockWithRegisterData(QString const& name,\r\n    QString const& description, QString const& baseAddress, QString const& range,\r\n    QString const& width, QList<QSharedPointer<RegisterBase>> registerData)\r\n{\r\n    QSharedPointer <AddressBlock> testAddressBlock(new AddressBlock);\r\n    testAddressBlock->setName(name);\r\n    testAddressBlock->setUsage(General::REGISTER);\r\n    testAddressBlock->setDescription(description);\r\n    testAddressBlock->setBaseAddress(baseAddress);\r\n    testAddressBlock->setRange(range);\r\n    testAddressBlock->setWidth(width);\r\n    testAddressBlock->setAccess(AccessTypes::READ_WRITE);\r\n    testAddressBlock->setVolatile(true);\r\n\r\n    for (QSharedPointer<RegisterBase> testRegisterData : registerData)\r\n    {\r\n        testAddressBlock->getRegisterData()->append(testRegisterData);\r\n    }\r\n\r\n    return testAddressBlock;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_DocumentGenerator::createTestMemoryMap()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer <MemoryMap> tst_DocumentGenerator::createTestMemoryMap(QString const& name,\r\n    QString const& descprition, int addressUnitbits, QList<QSharedPointer<AddressBlock> > addressBlocks)\r\n{\r\n    QSharedPointer<MemoryMap> memoryMap(new MemoryMap);\r\n    memoryMap->setName(name);\r\n    memoryMap->setAddressUnitBits(QString::number(addressUnitbits));\r\n    memoryMap->setDescription(descprition);\r\n\r\n    foreach (QSharedPointer <AddressBlock> includedAddressBlock, addressBlocks)\r\n    {\r\n        memoryMap->getMemoryBlocks()->append(includedAddressBlock);\r\n    }\r\n\r\n    return memoryMap;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_DocumentGenerator::getSpaceString()\r\n//-----------------------------------------------------------------------------\r\nQString tst_DocumentGenerator::getSpaceString()\r\n{\r\n    return QString(\"&nbsp;\");\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_DocumentGenerator::getIndentString()\r\n//-----------------------------------------------------------------------------\r\nQString tst_DocumentGenerator::getIndentString()\r\n{\r\n    return QString(\"&nbsp;&nbsp;&nbsp;\");\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_DocumentGenerator::getTableString()\r\n//-----------------------------------------------------------------------------\r\nQString tst_DocumentGenerator::getTableString()\r\n{\r\n    return QString(\"<table frame=\\\"box\\\" rules=\\\"all\\\" border=\\\"1\\\" cellPadding=\\\"3\\\" title=\\\"\");\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_DocumentGenerator::getEncodingString()\r\n//-----------------------------------------------------------------------------\r\nQString tst_DocumentGenerator::getEncodingString()\r\n{\r\n    return QString(\"<meta http-equiv=\\\"Content-Type\\\" content=\\\"text/html; charset=utf-8\\\">\");\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_DocumentGenerator::getDoctypeString()\r\n//-----------------------------------------------------------------------------\r\nQString tst_DocumentGenerator::getDoctypeString()\r\n{\r\n    return QString(\"<!DOCTYPE html PUBLIC \\\"-//W3C//DTD HTML 4.01//EN\\\" \\\"http://www.w3.org/TR/html4/strict.dtd\\\">\");\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_DocumentGenerator::getValidW3CStrictString()\r\n//-----------------------------------------------------------------------------\r\nQString tst_DocumentGenerator::getValidW3CStrictString()\r\n{\r\n    return QString(\"\\t\\t<p>\\n\"\r\n        \"\\t\\t\\t<a href=\\\"https://validator.w3.org/#validate_by_upload\\\">\\n\"\r\n        \"\\t\\t\\t<img src=\\\"http://www.w3.org/Icons/valid-html401\\\"\"\r\n        \"alt=\\\"Valid HTML 4.01 Strict\\\" height=\\\"31\\\"\"\r\n        \"width=\\\"88\\\">\\n\"\r\n        \"\\t\\t\\t</a>\\n\"\r\n        \"\\t\\t</p>\\n\");\r\n}\r\n\r\nQTEST_MAIN(tst_DocumentGenerator)\r\n\r\n#include \"tst_DocumentGenerator.moc\"\r\n"
  },
  {
    "path": "tests/Core/tst_DocumentGenerator.pri",
    "content": "# ----------------------------------------------------\r\n# This file is generated by the Qt Visual Studio Tools.\r\n# ------------------------------------------------------\r\n\r\n# This is a reminder that you are using a generated .pro file.\r\n# Remove it when you are finished editing this file.\r\n\r\n\r\nHEADERS += ../../editors/HWDesign/undoCommands/AdHocConnectionAddCommand.h \\\r\n    ../../editors/HWDesign/undoCommands/AdHocConnectionDeleteCommand.h \\\r\n    ../../editors/HWDesign/AdHocEnabled.h \\\r\n    ../../editors/HWDesign/undoCommands/AdHocTieOffConnectionDeleteCommand.h \\\r\n    ../../editors/HWDesign/undoCommands/AdHocVisibilityChangeCommand.h \\\r\n    ../../editors/common/Association/Associable.h \\\r\n    ../../editors/common/Association/Association.h \\\r\n    ../../editors/common/Association/AssociationAddCommand.h \\\r\n    ../../editors/common/Association/AssociationChangeEndpointCommand.h \\\r\n    ../../editors/common/Association/AssociationRemoveCommand.h \\\r\n    ../../editors/common/ComponentItemAutoConnector/AutoConnectorItem.h \\\r\n    ../../editors/common/ComponentItemAutoConnector/BusInterfaceItemMatcher.h \\\r\n    ../../editors/common/ComponentItemAutoConnector/BusInterfaceListFiller.h \\\r\n    ../../editors/common/ComponentItemAutoConnector/BusInterfaceTableAutoConnector.h \\\r\n    ../../common/graphicsItems/CommonGraphicsUndoCommands.h \\\r\n    ../../editors/HWDesign/undoCommands/ComponentInstancePasteCommand.h \\\r\n    ../../editors/HWDesign/undoCommands/ComponentItemMoveCommand.h \\\r\n    ../../editors/HWDesign/undoCommands/ConnectionDeleteCommand.h \\\r\n    ../../common/graphicsItems/ConnectionUndoCommands.h \\\r\n    ../../editors/common/DefaultRouting.h \\\r\n    ../../editors/common/DesignDiagramResolver.h \\\r\n    ../MockObjects/DesignWidgetFactoryMock.h \\\r\n    ../../common/widgets/tagEditor/FlowLayout.h \\\r\n    ../../common/graphicsItems/GraphicsColumnAddCommand.h \\\r\n    ../../common/graphicsItems/GraphicsColumnUndoCommands.h \\\r\n    ../../editors/common/GraphicsItemLabel.h \\\r\n    ../../editors/HWDesign/HWAddCommands.h \\\r\n    ../../editors/HWDesign/undoCommands/HWColumnAddCommand.h \\\r\n    ../../editors/SystemDesign/HWMappingItem.h \\\r\n    ../../editors/HWDesign/HWMoveCommands.h \\\r\n    ../../editors/common/ComponentItemAutoConnector/HierarchicalBusInterfaceItemMatcher.h \\\r\n    ../../editors/common/ComponentItemAutoConnector/HierarchicalBusInterfaceTableAutoConnector.h \\\r\n    ../../editors/common/ComponentItemAutoConnector/HierarchicalPortItemMatcher.h \\\r\n    ../../editors/common/ComponentItemAutoConnector/HierarchicalPortTableAutoConnector.h \\\r\n    ../../kactusGenerators/DocumentGenerator/HtmlWriter.h \\\r\n    ../../editors/common/ImageExporter.h \\\r\n    ../../editors/ComponentEditor/busInterfaces/portmaps/JaroWinklerAlgorithm.h \\\r\n    ../../common/widgets/assistedLineEdit/LineContentAssistWidget.h \\\r\n    ../../kactusGenerators/DocumentGenerator/MarkdownWriter.h \\\r\n    ../../editors/ComponentEditor/common/MasterExpressionEditor.h \\\r\n    ../../editors/common/NamelabelWidth.h \\\r\n    ../../editors/ComponentEditor/common/ParameterizableTable.h \\\r\n    ../../editors/common/ComponentItemAutoConnector/PortItemMatcher.h \\\r\n    ../../editors/common/ComponentItemAutoConnector/PortListFiller.h \\\r\n    ../../editors/ComponentEditor/busInterfaces/portmaps/PortMapHeaderView.h \\\r\n    ../../editors/ComponentEditor/busInterfaces/portmaps/PortMapSortFilter.h \\\r\n    ../../editors/ComponentEditor/busInterfaces/portmaps/PortMappingColumns.h \\\r\n    ../../editors/HWDesign/undoCommands/PortPasteCommand.h \\\r\n    ../../editors/common/ComponentItemAutoConnector/PortTableAutoConnector.h \\\r\n    ../../editors/common/PortUtilities.h \\\r\n    ../../editors/common/StickyNote/StickyNoteEditCommand.h \\\r\n    ../../editors/common/StickyNote/StickyNoteMoveCommand.h \\\r\n    ../../editors/HWDesign/WarningSymbol.h \\\r\n    ../../editors/HWDesign/ActiveBusInterfaceItem.h \\\r\n    ../../editors/HWDesign/ActivePortItem.h \\\r\n    ../../editors/HWDesign/AdHocConnectionItem.h \\\r\n    ../../editors/HWDesign/AdHocItem.h \\\r\n    ../../common/widgets/assistedLineEdit/AssistedLineEdit.h \\\r\n    ../../editors/common/ComponentItemAutoConnector/AutoConnector.h \\\r\n    ../../editors/common/ComponentItemAutoConnector/AutoConnectorConnectionDelegate.h \\\r\n    ../../editors/common/ComponentItemAutoConnector/AutoConnectorConnectionTable.h \\\r\n    ../../editors/common/ComponentItemAutoConnector/AutoConnectorListFilter.h \\\r\n    ../../editors/HWDesign/BusInterfaceDialog.h \\\r\n    ../../editors/HWDesign/BusInterfaceEndPoint.h \\\r\n    ../../editors/ComponentEditor/busInterfaces/portmaps/BusInterfacePortMapTab.h \\\r\n    ../../common/widgets/colorBox/ColorBox.h \\\r\n    ../../editors/common/StickyNote/ColorFillTextItem.h \\\r\n    ../../editors/HWDesign/columnview/ColumnEditDialog.h \\\r\n    ../../editors/HWDesign/undoCommands/ComponentDeleteCommand.h \\\r\n    ../../editors/common/ComponentDesignDiagram.h \\\r\n    ../../common/graphicsItems/ComponentItem.h \\\r\n    ../../editors/common/ComponentItemAutoConnector/ComponentItemAutoConnector.h \\\r\n    ../../editors/ComponentEditor/parameters/ComponentParameterModel.h \\\r\n    ../../common/widgets/componentPreviewBox/ComponentPreviewBox.h \\\r\n    ../../editors/common/ComponentInstanceEditor/ConfigurableElementsView.h \\\r\n    ../../common/graphicsItems/ConnectionEndpoint.h \\\r\n    ../../editors/common/DesignDiagram.h \\\r\n    ../../editors/common/DesignWidget.h \\\r\n    ../../common/views/EditableTreeView/EditableTreeSortFilter.h \\\r\n    ../../common/views/EditableTreeView/EditableTreeView.h \\\r\n    ../../editors/ComponentEditor/common/ExpressionDelegate.h \\\r\n    ../../editors/ComponentEditor/common/ExpressionEditor.h \\\r\n    ../../editors/ComponentEditor/common/ExpressionLineEditor.h \\\r\n    ../../common/GenericEditProvider.h \\\r\n    ../../common/graphicsItems/GraphicsColumn.h \\\r\n    ../../common/graphicsItems/GraphicsColumnLayout.h \\\r\n    ../../common/graphicsItems/GraphicsConnection.h \\\r\n    ../../editors/HWDesign/HWChangeCommands.h \\\r\n    ../../editors/HWDesign/columnview/HWColumn.h \\\r\n    ../../editors/HWDesign/undoCommands/HWComponentAddCommand.h \\\r\n    ../../editors/HWDesign/HWComponentItem.h \\\r\n    ../../editors/HWDesign/HWConnection.h \\\r\n    ../../editors/HWDesign/HWConnectionEndpoint.h \\\r\n    ../../editors/HWDesign/HWDesignDiagram.h \\\r\n    ../MockObjects/HWDesignWidgetMock.h \\\r\n    ../../editors/HWDesign/HierarchicalBusInterfaceItem.h \\\r\n    ../../editors/HWDesign/HierarchicalPortItem.h \\\r\n    ../../common/IEditProvider.h \\\r\n    ../../common/widgets/kactusAttributeEditor/KactusAttributeEditor.h \\\r\n    ../MockObjects/LibraryMock.h \\\r\n    ../../common/widgets/LibrarySelectorWidget/LibrarySelectorWidget.h \\\r\n    ../../common/dialogs/LibrarySettingsDialog/LibrarySettingsDialog.h \\\r\n    ../../editors/ComponentEditor/common/MultilineDescriptionDelegate.h \\\r\n    ../../editors/HWDesign/OffPageConnectorItem.h \\\r\n    ../../editors/ComponentEditor/busInterfaces/portmaps/PhysicalPortMappingTableModel.h \\\r\n    ../../editors/ComponentEditor/busInterfaces/portmaps/PhysicalPortMappingTableView.h \\\r\n    ../../editors/ComponentEditor/busInterfaces/portmaps/PortListSortProxyModel.h \\\r\n    ../../editors/ComponentEditor/busInterfaces/portmaps/PortMapAutoConnector.h \\\r\n    ../../editors/ComponentEditor/busInterfaces/portmaps/PortMapDelegate.h \\\r\n    ../../editors/ComponentEditor/busInterfaces/portmaps/PortMapModel.h \\\r\n    ../../editors/ComponentEditor/busInterfaces/portmaps/PortMapView.h \\\r\n    ../../editors/ComponentEditor/busInterfaces/portmaps/PortMappingTableModel.h \\\r\n    ../../editors/ComponentEditor/busInterfaces/portmaps/PortMappingTableView.h \\\r\n    ../../editors/ComponentEditor/common/ReferencingTableModel.h \\\r\n    ../../editors/HWDesign/undoCommands/ReplaceComponentCommand.h \\\r\n    ../../editors/SystemDesign/SWComponentItem.h \\\r\n    ../../editors/SystemDesign/SWConnectionEndpoint.h \\\r\n    ../../editors/SystemDesign/SWPortItem.h \\\r\n    ../../editors/HWDesign/SelectItemTypeDialog.h \\\r\n    ../../editors/common/StickyNote/StickyNote.h \\\r\n    ../../editors/common/StickyNote/StickyNoteAddCommand.h \\\r\n    ../../editors/common/StickyNote/StickyNoteRemoveCommand.h \\\r\n    ../../editors/SystemDesign/SystemComponentItem.h \\\r\n    ../../common/widgets/tabDocument/TabDocument.h \\\r\n    ../../common/widgets/tagEditor/TagCompleterModel.h \\\r\n    ../../common/widgets/tagEditor/TagContainer.h \\\r\n    ../../common/widgets/tagEditor/TagDisplay.h \\\r\n    ../../common/widgets/tagEditor/TagEditor.h \\\r\n    ../../common/widgets/tagEditor/TagEditorContainer.h \\\r\n    ../../common/widgets/tagEditor/TagLabel.h \\\r\n    ../../common/widgets/tagEditor/TagSelector.h \\\r\n    ../../common/widgets/tagEditor/TagSelectorContainer.h \\\r\n    ../../editors/common/ConfigurationEditor/activeviewmodel.h \\\r\n    ../../kactusGenerators/DocumentGenerator/documentgenerator.h \\\r\n    ../../common/views/EditableTableView/editabletableview.h \\\r\n    ../../common/widgets/LibrarySelectorWidget/LibraryPathEditor/librarypatheditor.h \\\r\n    ../../common/widgets/LibrarySelectorWidget/LibraryPathSelector/librarypathselector.h \\\r\n    ../../common/validators/LibraryPathValidator/librarypathvalidator.h \\\r\n    ../../common/dialogs/LibrarySettingsDialog/librarysettingsdelegate.h \\\r\n    ../../common/delegates/LineEditDelegate/lineeditdelegate.h \\\r\n    ../../common/dialogs/newObjectDialog/newobjectdialog.h \\\r\n    ../../editors/ComponentEditor/itemvisualizer.h \\\r\n    ../../common/widgets/vlnvEditor/vlnveditor.h\r\nSOURCES += ../../editors/HWDesign/ActiveBusInterfaceItem.cpp \\\r\n    ../../editors/HWDesign/ActivePortItem.cpp \\\r\n    ../../editors/HWDesign/undoCommands/AdHocConnectionAddCommand.cpp \\\r\n    ../../editors/HWDesign/undoCommands/AdHocConnectionDeleteCommand.cpp \\\r\n    ../../editors/HWDesign/AdHocConnectionItem.cpp \\\r\n    ../../editors/HWDesign/AdHocEnabled.cpp \\\r\n    ../../editors/HWDesign/AdHocItem.cpp \\\r\n    ../../editors/HWDesign/undoCommands/AdHocTieOffConnectionDeleteCommand.cpp \\\r\n    ../../editors/HWDesign/undoCommands/AdHocVisibilityChangeCommand.cpp \\\r\n    ../../common/widgets/assistedLineEdit/AssistedLineEdit.cpp \\\r\n    ../../editors/common/Association/Associable.cpp \\\r\n    ../../editors/common/Association/Association.cpp \\\r\n    ../../editors/common/Association/AssociationAddCommand.cpp \\\r\n    ../../editors/common/Association/AssociationChangeEndpointCommand.cpp \\\r\n    ../../editors/common/Association/AssociationRemoveCommand.cpp \\\r\n    ../../editors/common/ComponentItemAutoConnector/AutoConnector.cpp \\\r\n    ../../editors/common/ComponentItemAutoConnector/AutoConnectorConnectionDelegate.cpp \\\r\n    ../../editors/common/ComponentItemAutoConnector/AutoConnectorConnectionTable.cpp \\\r\n    ../../editors/common/ComponentItemAutoConnector/AutoConnectorItem.cpp \\\r\n    ../../editors/common/ComponentItemAutoConnector/AutoConnectorListFilter.cpp \\\r\n    ../../editors/HWDesign/BusInterfaceDialog.cpp \\\r\n    ../../editors/HWDesign/BusInterfaceEndPoint.cpp \\\r\n    ../../editors/common/ComponentItemAutoConnector/BusInterfaceItemMatcher.cpp \\\r\n    ../../editors/common/ComponentItemAutoConnector/BusInterfaceListFiller.cpp \\\r\n    ../../editors/ComponentEditor/busInterfaces/portmaps/BusInterfacePortMapTab.cpp \\\r\n    ../../editors/common/ComponentItemAutoConnector/BusInterfaceTableAutoConnector.cpp \\\r\n    ../../common/widgets/colorBox/ColorBox.cpp \\\r\n    ../../editors/common/StickyNote/ColorFillTextItem.cpp \\\r\n    ../../editors/HWDesign/columnview/ColumnEditDialog.cpp \\\r\n    ../../common/graphicsItems/CommonGraphicsUndoCommands.cpp \\\r\n    ../../editors/HWDesign/undoCommands/ComponentDeleteCommand.cpp \\\r\n    ../../editors/common/ComponentDesignDiagram.cpp \\\r\n    ../../editors/HWDesign/undoCommands/ComponentInstancePasteCommand.cpp \\\r\n    ../../common/graphicsItems/ComponentItem.cpp \\\r\n    ../../editors/common/ComponentItemAutoConnector/ComponentItemAutoConnector.cpp \\\r\n    ../../editors/HWDesign/undoCommands/ComponentItemMoveCommand.cpp \\\r\n    ../../editors/ComponentEditor/parameters/ComponentParameterModel.cpp \\\r\n    ../../common/widgets/componentPreviewBox/ComponentPreviewBox.cpp \\\r\n    ../../editors/common/ComponentInstanceEditor/ConfigurableElementsView.cpp \\\r\n    ../../editors/HWDesign/undoCommands/ConnectionDeleteCommand.cpp \\\r\n    ../../common/graphicsItems/ConnectionEndpoint.cpp \\\r\n    ../../common/graphicsItems/ConnectionUndoCommands.cpp \\\r\n    ../../editors/common/DefaultRouting.cpp \\\r\n    ../../editors/common/DesignDiagram.cpp \\\r\n    ../../editors/common/DesignDiagramResolver.cpp \\\r\n    ../../editors/common/DesignWidget.cpp \\\r\n    ../../kactusGenerators/DocumentGenerator/DocumentationWriter.cpp \\\r\n    ../MockObjects/DesignWidgetFactoryMock.cpp \\\r\n    ../../common/views/EditableTreeView/EditableTreeSortFilter.cpp \\\r\n    ../../common/views/EditableTreeView/EditableTreeView.cpp \\\r\n    ../../editors/ComponentEditor/common/ExpressionDelegate.cpp \\\r\n    ../../editors/ComponentEditor/common/ExpressionEditor.cpp \\\r\n    ../../editors/ComponentEditor/common/ExpressionLineEditor.cpp \\\r\n    ../../common/widgets/tagEditor/FlowLayout.cpp \\\r\n    ../../common/GenericEditProvider.cpp \\\r\n    ../../common/graphicsItems/GraphicsColumn.cpp \\\r\n    ../../common/graphicsItems/GraphicsColumnAddCommand.cpp \\\r\n    ../../common/graphicsItems/GraphicsColumnLayout.cpp \\\r\n    ../../common/graphicsItems/GraphicsColumnUndoCommands.cpp \\\r\n    ../../common/graphicsItems/GraphicsConnection.cpp \\\r\n    ../../editors/common/GraphicsItemLabel.cpp \\\r\n    ../../editors/HWDesign/HWAddCommands.cpp \\\r\n    ../../editors/HWDesign/HWChangeCommands.cpp \\\r\n    ../../editors/HWDesign/columnview/HWColumn.cpp \\\r\n    ../../editors/HWDesign/undoCommands/HWColumnAddCommand.cpp \\\r\n    ../../editors/HWDesign/undoCommands/HWComponentAddCommand.cpp \\\r\n    ../../editors/HWDesign/HWComponentItem.cpp \\\r\n    ../../editors/HWDesign/HWConnection.cpp \\\r\n    ../../editors/HWDesign/HWConnectionEndPoint.cpp \\\r\n    ../../editors/HWDesign/HWDesignDiagram.cpp \\\r\n    ../MockObjects/HWDesignWidgetMock.cpp \\\r\n    ../../editors/SystemDesign/HWMappingItem.cpp \\\r\n    ../../editors/HWDesign/HWMoveCommands.cpp \\\r\n    ../../editors/HWDesign/HierarchicalBusInterfaceItem.cpp \\\r\n    ../../editors/common/ComponentItemAutoConnector/HierarchicalBusInterfaceItemMatcher.cpp \\\r\n    ../../editors/common/ComponentItemAutoConnector/HierarchicalBusInterfaceTableAutoConnector.cpp \\\r\n    ../../editors/HWDesign/HierarchicalPortItem.cpp \\\r\n    ../../editors/common/ComponentItemAutoConnector/HierarchicalPortItemMatcher.cpp \\\r\n    ../../editors/common/ComponentItemAutoConnector/HierarchicalPortTableAutoConnector.cpp \\\r\n    ../../kactusGenerators/DocumentGenerator/HtmlWriter.cpp \\\r\n    ../../editors/common/ImageExporter.cpp \\\r\n    ../../editors/ComponentEditor/busInterfaces/portmaps/JaroWinklerAlgorithm.cpp \\\r\n    ../../common/widgets/kactusAttributeEditor/KactusAttributeEditor.cpp \\\r\n    ../MockObjects/LibraryMock.cpp \\\r\n    ../../common/widgets/LibrarySelectorWidget/LibrarySelectorWidget.cpp \\\r\n    ../../common/dialogs/LibrarySettingsDialog/LibrarySettingsDialog.cpp \\\r\n    ../../common/widgets/assistedLineEdit/LineContentAssistWidget.cpp \\\r\n    ../../kactusGenerators/DocumentGenerator/MarkdownWriter.cpp \\\r\n    ../../editors/ComponentEditor/common/MasterExpressionEditor.cpp \\\r\n    ../../editors/ComponentEditor/common/MultilineDescriptionDelegate.cpp \\\r\n    ../../editors/common/NamelabelWidth.cpp \\\r\n    ../../editors/HWDesign/OffPageConnectorItem.cpp \\\r\n    ../../editors/ComponentEditor/common/ParameterizableTable.cpp \\\r\n    ../../editors/ComponentEditor/busInterfaces/portmaps/PhysicalPortMappingTableModel.cpp \\\r\n    ../../editors/ComponentEditor/busInterfaces/portmaps/PhysicalPortMappingTableView.cpp \\\r\n    ../../editors/common/ComponentItemAutoConnector/PortItemMatcher.cpp \\\r\n    ../../editors/common/ComponentItemAutoConnector/PortListFiller.cpp \\\r\n    ../../editors/ComponentEditor/busInterfaces/portmaps/PortListSortProxyModel.cpp \\\r\n    ../../editors/ComponentEditor/busInterfaces/portmaps/PortMapAutoConnector.cpp \\\r\n    ../../editors/ComponentEditor/busInterfaces/portmaps/PortMapDelegate.cpp \\\r\n    ../../editors/ComponentEditor/busInterfaces/portmaps/PortMapHeaderView.cpp \\\r\n    ../../editors/ComponentEditor/busInterfaces/portmaps/PortMapModel.cpp \\\r\n    ../../editors/ComponentEditor/busInterfaces/portmaps/PortMapSortFilter.cpp \\\r\n    ../../editors/ComponentEditor/busInterfaces/portmaps/PortMapView.cpp \\\r\n    ../../editors/ComponentEditor/busInterfaces/portmaps/PortMappingTableModel.cpp \\\r\n    ../../editors/ComponentEditor/busInterfaces/portmaps/PortMappingTableView.cpp \\\r\n    ../../editors/HWDesign/undoCommands/PortPasteCommand.cpp \\\r\n    ../../editors/common/ComponentItemAutoConnector/PortTableAutoConnector.cpp \\\r\n    ../../editors/common/PortUtilities.cpp \\\r\n    ../../editors/HWDesign/PortmapDialog.cpp \\\r\n    ../../editors/ComponentEditor/common/ReferencingTableModel.cpp \\\r\n    ../../editors/HWDesign/undoCommands/ReplaceComponentCommand.cpp \\\r\n    ../../editors/SystemDesign/SWComponentItem.cpp \\\r\n    ../../editors/SystemDesign/SWConnectionEndpoint.cpp \\\r\n    ../../editors/SystemDesign/SWPortItem.cpp \\\r\n    ../../editors/HWDesign/SelectItemTypeDialog.cpp \\\r\n    ../../editors/common/StickyNote/StickyNote.cpp \\\r\n    ../../editors/common/StickyNote/StickyNoteAddCommand.cpp \\\r\n    ../../editors/common/StickyNote/StickyNoteEditCommand.cpp \\\r\n    ../../editors/common/StickyNote/StickyNoteMoveCommand.cpp \\\r\n    ../../editors/common/StickyNote/StickyNoteRemoveCommand.cpp \\\r\n    ../../editors/SystemDesign/SystemComponentItem.cpp \\\r\n    ../../editors/SystemDesign/UndoCommands/SystemMoveCommands.cpp \\\r\n    ../../common/widgets/tabDocument/TabDocument.cpp \\\r\n    ../../editors/common/ComponentItemAutoConnector/TableAutoConnector.cpp \\\r\n    ../../editors/common/ComponentItemAutoConnector/TableItemMatcher.cpp \\\r\n    ../../common/widgets/tagEditor/TagCompleterModel.cpp \\\r\n    ../../common/widgets/tagEditor/TagContainer.cpp \\\r\n    ../../common/widgets/tagEditor/TagDisplay.cpp \\\r\n    ../../common/widgets/tagEditor/TagEditor.cpp \\\r\n    ../../common/widgets/tagEditor/TagEditorContainer.cpp \\\r\n    ../../common/widgets/tagEditor/TagLabel.cpp \\\r\n    ../../common/widgets/tagEditor/TagSelector.cpp \\\r\n    ../../common/widgets/tagEditor/TagSelectorContainer.cpp \\\r\n    ../../editors/HWDesign/undoCommands/TopAdHocVisibilityChangeCommand.cpp \\\r\n    ../../common/widgets/vlnvEditor/VLNVContentMatcher.cpp \\\r\n    ../../common/widgets/vlnvEditor/VLNVDataTree.cpp \\\r\n    ../../editors/HWDesign/WarningSymbol.cpp \\\r\n    ../../editors/common/ConfigurationEditor/activeviewmodel.cpp \\\r\n    ../../kactusGenerators/DocumentGenerator/documentgenerator.cpp \\\r\n    ../../common/views/EditableTableView/editabletableview.cpp \\\r\n    ../../common/widgets/LibrarySelectorWidget/LibraryPathEditor/librarypatheditor.cpp \\\r\n    ../../common/widgets/LibrarySelectorWidget/LibraryPathSelector/librarypathselector.cpp \\\r\n    ../../common/validators/LibraryPathValidator/librarypathvalidator.cpp \\\r\n    ../../common/dialogs/LibrarySettingsDialog/librarysettingsdelegate.cpp \\\r\n    ../../common/delegates/LineEditDelegate/lineeditdelegate.cpp \\\r\n    ../../common/dialogs/newObjectDialog/newobjectdialog.cpp \\\r\n    ../../common/widgets/vlnvEditor/vlnveditor.cpp \\\r\n    ../../editors/ComponentEditor/itemvisualizer.cpp \\\r\n    ./tst_documentGenerator.cpp\r\n"
  },
  {
    "path": "tests/Core/tst_DocumentGenerator.pro",
    "content": "TEMPLATE = app\r\n\r\nTARGET = tst_DocumentGenerator\r\n\r\nQT += core xml gui widgets testlib printsupport svg\r\nCONFIG += c++11 testcase console\r\n\r\nQMAKE_EXPORTED_VARIABLES += MAKE_TESTARGS\r\nMAKE_TESTARGS.name = TESTARGS\r\nMAKE_TESTARGS.value = \"-platform offscreen\"\r\n\r\nwin32:CONFIG(release, debug|release) {\r\n    LIBS += -L../../executable/ -lIPXACTmodels -lKactusAPI\r\n    DESTDIR = ./release\r\n}\r\nelse:win32:CONFIG(debug, debug|release) {\r\n    LIBS += -L../../executable/ -lIPXACTmodelsd -lKactusAPId\r\n    DESTDIR = ./debug\r\n}\r\nelse:unix {\r\n    LIBS += -L../../executable/ -lIPXACTmodels -lKactusAPI\r\n    DESTDIR = ./release\r\n}\r\n\r\n#DESTDIR = ./release\r\n\r\nINCLUDEPATH += $$DESTDIR\r\nINCLUDEPATH += $$PWD/../../\r\nINCLUDEPATH += $$PWD/../../KactusAPI/include\r\n\r\nDEPENDPATH += .\r\nDEPENDPATH += ../../\r\n\r\nOBJECTS_DIR += $$DESTDIR\r\n\r\nMOC_DIR += ./generatedFiles\r\nUI_DIR += ./generatedFiles\r\nRCC_DIR += ./generatedFiles\r\ninclude(tst_DocumentGenerator.pri)\r\n"
  },
  {
    "path": "tests/Core/tst_DocumentTreeBuilder.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: tst_DocumentTreeBuilder.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Esko Pekkarinen\r\n// Date: 18.05.2015\r\n//\r\n// Description:\r\n// Unit test for class DocumentTreeBuilder.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include <QtTest>\r\n#include <QSharedPointer>\r\n\r\n#include <mainwindow/SaveHierarchy/DocumentTreeBuilder.h>\r\n\r\n#include <tests/MockObjects/LibraryMock.h>\r\n\r\n#include <IPXACTmodels/Component/Component.h>\r\n\r\n#include <IPXACTmodels/Design/Design.h>\r\n\r\n#include <IPXACTmodels/DesignConfiguration/DesignConfiguration.h>\r\n\r\n#include <IPXACTmodels/common/VLNV.h>\r\n\r\nclass tst_DocumentTreeBuilder : public QObject\r\n{\r\n    Q_OBJECT\r\n\r\npublic:\r\n    tst_DocumentTreeBuilder();\r\n\r\n    ~tst_DocumentTreeBuilder();\r\n\r\nprivate slots:\r\n    void cleanup();\r\n    \r\n    void testUnknownReferenceResultsInEmptyNode();\r\n    void testReferenceResultsInListWithReference();\r\n\r\n    void testHierarchicalReferenceToDesign();\r\n\r\n    void testHierarchicalReferenceToDesignConfiguration();\r\n\r\n    void testHierarchicalReferenceToInstanceInDesign();\r\n    void testReferenceToInstanceInDesignWithoutDesignConfiguration();\r\n\r\n    void testDesignInInstantiatedComponent();\r\n    \r\n    void testMultipleInstances();\r\n    \r\n    void testStartFromDesign();\r\n    void testStartFromDesignConfiguration();\r\n\r\nprivate:\r\n    \r\n    QSharedPointer<Component> createTopComponent();\r\n    \r\n    VLNV topComponentVLNV();\r\n\r\n    QSharedPointer<Design> createDesign();\r\n\r\n    VLNV topDesignVLNV();\r\n\r\n    QSharedPointer<DesignConfiguration> createDesignConfiguration();\r\n\r\n    VLNV topDesignConfigurationVLNV();\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    LibraryMock* library_;\r\n\r\n    DocumentTreeBuilder* builder_;\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_DocumentTreeBuilder::tst_DocumentTreeBuilder()\r\n//-----------------------------------------------------------------------------\r\ntst_DocumentTreeBuilder::tst_DocumentTreeBuilder(): library_(new LibraryMock(this)), \r\n    builder_(new DocumentTreeBuilder(library_))\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_DocumentTreeBuilder::~tst_DocumentTreeBuilder()\r\n//-----------------------------------------------------------------------------\r\ntst_DocumentTreeBuilder::~tst_DocumentTreeBuilder()\r\n{\r\n    delete builder_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_DocumentTreeBuilder::cleanup()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_DocumentTreeBuilder::cleanup()\r\n{\r\n    library_->clear();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_DocumentTreeBuilder::testUnknownReferenceResultsInEmptyNode()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_DocumentTreeBuilder::testUnknownReferenceResultsInEmptyNode()\r\n{\r\n    VLNV nonExistingVLNV(VLNV::COMPONENT, \"TestVendor\", \"TestLibrary\", \"TestComponent\", \"TestVersion\");\r\n\r\n    QObject* rootObject = builder_->createFrom(nonExistingVLNV);\r\n\r\n    QCOMPARE(rootObject->objectName(), nonExistingVLNV.toString());\r\n    QCOMPARE(rootObject->children().count(), 0);\r\n    delete rootObject;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_DocumentTreeBuilder::testReferenceResultsInListWithReference()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_DocumentTreeBuilder::testReferenceResultsInListWithReference()\r\n{\r\n    createTopComponent();\r\n\r\n    QObject* rootObject = builder_->createFrom(topComponentVLNV());\r\n\r\n    QCOMPARE(rootObject->objectName(), topComponentVLNV().toString());\r\n    QCOMPARE(rootObject->children().count(), 0);\r\n    QCOMPARE(rootObject->property(\"VLNVType\").toString(), QString(\"Component\"));\r\n\r\n    delete rootObject;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_DocumentTreeBuilder::testHierarchicalReferenceToDesign()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_DocumentTreeBuilder::testHierarchicalReferenceToDesign()\r\n{\r\n    QSharedPointer<Component> component = createTopComponent();\r\n    createDesign();\r\n\r\n    QSharedPointer<View> hierarchicalView(new View());\r\n    hierarchicalView->setDesignInstantiationRef(\"rtl_design\");\r\n    component->getViews()->append(hierarchicalView);\r\n\r\n    QSharedPointer<DesignInstantiation> testInstantiation(new DesignInstantiation(\"rtl_design\"));\r\n    QSharedPointer<ConfigurableVLNVReference> designReference(new ConfigurableVLNVReference(topDesignVLNV()));\r\n    testInstantiation->setDesignReference(designReference);\r\n    component->getDesignInstantiations()->append(testInstantiation);\r\n\r\n    QObject* rootObject = builder_->createFrom(topComponentVLNV());\r\n\r\n    QCOMPARE(rootObject->objectName(), topComponentVLNV().toString());\r\n    QCOMPARE(rootObject->children().count(), 1);\r\n    QCOMPARE(rootObject->property(\"VLNVType\").toString(), QString(\"Component\"));\r\n\r\n    QObject* designObject = rootObject->children().first();\r\n    QCOMPARE(designObject->objectName(), topDesignVLNV().toString());\r\n    QCOMPARE(designObject->property(\"VLNVType\").toString(), QString(\"Design\"));\r\n\r\n    delete rootObject;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_DocumentTreeBuilder::testHierarchicalReferenceToDesignConfiguration()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_DocumentTreeBuilder::testHierarchicalReferenceToDesignConfiguration()\r\n{\r\n    QSharedPointer<Component> component = createTopComponent();\r\n    createDesign();\r\n    createDesignConfiguration();\r\n\r\n    QSharedPointer<View> hierarchicalView(new View());\r\n    hierarchicalView->setDesignConfigurationInstantiationRef(\"rtl_design_config\");\r\n    component->getViews()->append(hierarchicalView);\r\n\r\n    QSharedPointer<DesignConfigurationInstantiation> testConfiguration(\r\n        new DesignConfigurationInstantiation(\"rtl_design_config\"));\r\n    QSharedPointer<ConfigurableVLNVReference> configurationRef(new ConfigurableVLNVReference(\r\n        topDesignConfigurationVLNV()));\r\n    testConfiguration->setDesignConfigurationReference(configurationRef);\r\n    component->getDesignConfigurationInstantiations()->append(testConfiguration);\r\n\r\n    QObject* rootObject = builder_->createFrom(topComponentVLNV());\r\n\r\n    QCOMPARE(rootObject->objectName(), topComponentVLNV().toString());\r\n    QCOMPARE(rootObject->children().count(), 1);\r\n    QCOMPARE(rootObject->property(\"VLNVType\").toString(), QString(\"Component\"));\r\n\r\n    QObject* designConfigurationObject = rootObject->children().first();\r\n    QCOMPARE(designConfigurationObject->objectName(), topDesignConfigurationVLNV().toString());\r\n    QCOMPARE(designConfigurationObject->children().count(), 1);\r\n    QCOMPARE(designConfigurationObject->property(\"VLNVType\").toString(), QString(\"DesignConfiguration\"));\r\n\r\n    QObject* designObject = designConfigurationObject->children().first();\r\n    QCOMPARE(designObject->objectName(), topDesignVLNV().toString());\r\n    QCOMPARE(designObject->children().count(), 0);\r\n    QCOMPARE(designObject->property(\"VLNVType\").toString(), QString(\"Design\"));\r\n\r\n    delete rootObject;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_DocumentTreeBuilder::testHierarchicalReferenceToInstanceInDesign()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_DocumentTreeBuilder::testHierarchicalReferenceToInstanceInDesign()\r\n{\r\n    QSharedPointer<Component> component = createTopComponent();\r\n    QSharedPointer<Design> design = createDesign();\r\n    createDesignConfiguration();\r\n\r\n    VLNV instanceVLNV(VLNV::COMPONENT, \"TestVendor\", \"TestLibrary\", \"TestInstance\", \"TestVersion\");\r\n    QSharedPointer<Component> instanceComponent(new Component(instanceVLNV, Document::Revision::Std14));\r\n    library_->addComponent(instanceComponent);\r\n\r\n    QSharedPointer<ComponentInstance> instance(new ComponentInstance());\r\n    instance->setInstanceName(\"instance1\");\r\n    instance->setComponentRef(QSharedPointer<ConfigurableVLNVReference>(new ConfigurableVLNVReference(instanceVLNV)));\r\n    design->getComponentInstances()->append(instance);\r\n    \r\n    QSharedPointer<View> hierarchicalView(new View());\r\n    hierarchicalView->setDesignConfigurationInstantiationRef(\"configuration\");\r\n    component->getViews()->append(hierarchicalView);\r\n\r\n    QSharedPointer<DesignConfigurationInstantiation> testConfiguration(\r\n        new DesignConfigurationInstantiation(\"configuration\"));\r\n    QSharedPointer<ConfigurableVLNVReference> configurationRef(new ConfigurableVLNVReference(\r\n        topDesignConfigurationVLNV()));\r\n    testConfiguration->setDesignConfigurationReference(configurationRef);\r\n    component->getDesignConfigurationInstantiations()->append(testConfiguration);\r\n\r\n    QObject* rootObject = builder_->createFrom(topComponentVLNV());\r\n    QCOMPARE(rootObject->children().count(), 1);\r\n\r\n    QObject* designConfigurationObject = rootObject->children().first();\r\n    QCOMPARE(designConfigurationObject->children().count(), 1);\r\n\r\n    QObject* designObject = designConfigurationObject->children().first();\r\n    QCOMPARE(designObject->children().count(), 1);\r\n\r\n    QObject* instanceObject = designObject->children().first();\r\n    QCOMPARE(instanceObject->children().count(), 0);\r\n    QCOMPARE(instanceObject->objectName(), instanceVLNV.toString());\r\n    QCOMPARE(instanceObject->property(\"instanceName\").toString(), QString(\"instance1\"));\r\n\r\n    delete rootObject;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_DocumentTreeBuilder::testReferenceToInstanceInDesignWithoutDesignConfiguration()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_DocumentTreeBuilder::testReferenceToInstanceInDesignWithoutDesignConfiguration()\r\n{\r\n    QSharedPointer<Component> component = createTopComponent();\r\n    QSharedPointer<Design> design = createDesign();\r\n\r\n    QSharedPointer<View> hierarchicalView(new View());\r\n    hierarchicalView->setDesignInstantiationRef(\"rtl_design\");\r\n    component->getViews()->append(hierarchicalView);\r\n   \r\n    QSharedPointer<DesignInstantiation> testInstantiation(new DesignInstantiation(\"rtl_design\"));\r\n    QSharedPointer<ConfigurableVLNVReference> designReference(new ConfigurableVLNVReference(topDesignVLNV()));\r\n    testInstantiation->setDesignReference(designReference);\r\n    component->getDesignInstantiations()->append(testInstantiation);\r\n\r\n    VLNV instanceVLNV(VLNV::COMPONENT, \"TestVendor\", \"TestLibrary\", \"TestInstance\", \"TestVersion\");\r\n    QSharedPointer<Component> instanceComponent(new Component(instanceVLNV, Document::Revision::Std14));\r\n    library_->addComponent(instanceComponent);\r\n\r\n    QSharedPointer<ComponentInstance> instance(new ComponentInstance());\r\n    instance->setInstanceName(\"instance1\");\r\n    instance->setComponentRef(QSharedPointer<ConfigurableVLNVReference>(new ConfigurableVLNVReference(instanceVLNV)));\r\n    design->getComponentInstances()->append(instance);\r\n\r\n    QObject* rootObject = builder_->createFrom(topComponentVLNV());\r\n    QCOMPARE(rootObject->children().count(), 1);\r\n\r\n    QObject* designObject = rootObject->children().first();\r\n    QCOMPARE(designObject->children().count(), 1);\r\n\r\n    QObject* instanceObject = designObject->children().first();\r\n    QCOMPARE(instanceObject->children().count(), 0);\r\n    QCOMPARE(instanceObject->objectName(), instanceVLNV.toString());\r\n    QCOMPARE(instanceObject->property(\"instanceName\").toString(), QString(\"instance1\"));\r\n    QCOMPARE(instanceObject->property(\"activeView\").toString(), QString(\"\"));\r\n\r\n    delete rootObject;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_DocumentTreeBuilder::testDesignInInstantiatedComponent()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_DocumentTreeBuilder::testDesignInInstantiatedComponent()\r\n{\r\n    QSharedPointer<Component> topComponent = createTopComponent();\r\n    QSharedPointer<Design> design = createDesign();\r\n\r\n    QSharedPointer<View> topView(new View());\r\n    topView->setDesignInstantiationRef(\"top_design\");\r\n    topComponent->getViews()->append(topView);\r\n\r\n    QSharedPointer<DesignInstantiation> topDesignInstantiation(new DesignInstantiation(\"top_design\"));\r\n    QSharedPointer<ConfigurableVLNVReference> designReference(new ConfigurableVLNVReference(topDesignVLNV()));\r\n    topDesignInstantiation->setDesignReference(designReference);\r\n    topComponent->getDesignInstantiations()->append(topDesignInstantiation);\r\n\r\n    VLNV instanceVLNV(VLNV::COMPONENT, \"TestVendor\", \"TestLibrary\", \"TestInstance\", \"TestVersion\");\r\n    QSharedPointer<Component> instanceComponent(new Component(instanceVLNV, Document::Revision::Std14));\r\n    library_->addComponent(instanceComponent);\r\n\r\n    QSharedPointer<ComponentInstance> componentInstance(new ComponentInstance());\r\n    componentInstance->setInstanceName(\"instance1\");\r\n    componentInstance->setComponentRef(QSharedPointer<ConfigurableVLNVReference>(\r\n        new ConfigurableVLNVReference(instanceVLNV)));\r\n    design->getComponentInstances()->append(componentInstance);\r\n\r\n    VLNV instanceDesignVLNV(VLNV::DESIGN, \"TestVendor\", \"TestLibrary\", \"BottomDesign\", \"TestVersion\");\r\n    QSharedPointer<Design> instanceDesign(new Design(instanceDesignVLNV, Document::Revision::Std14));\r\n    library_->addComponent(instanceDesign);\r\n\r\n    VLNV bottomInstanceVLNV(VLNV::COMPONENT, \"TestVendor\", \"TestLibrary\", \"TestBottomInstance\", \"TestVersion\");\r\n    QSharedPointer<Component> bottomComponent(new Component(bottomInstanceVLNV, Document::Revision::Std14));\r\n    library_->addComponent(bottomComponent);\r\n\r\n    QSharedPointer<ComponentInstance> bottomInstance(new ComponentInstance());\r\n    bottomInstance->setInstanceName(\"bottomInstance\");\r\n    bottomInstance->setComponentRef(QSharedPointer<ConfigurableVLNVReference>(\r\n        new ConfigurableVLNVReference(bottomInstanceVLNV)));\r\n    instanceDesign->getComponentInstances()->append(bottomInstance);\r\n\r\n    QSharedPointer<View> bottomView(new View());\r\n    bottomView->setDesignInstantiationRef(\"bottom_design\");\r\n    instanceComponent->getViews()->append(bottomView);\r\n\r\n    QSharedPointer<DesignInstantiation> bottomInstantiation(new DesignInstantiation(\"bottom_design\"));\r\n    QSharedPointer<ConfigurableVLNVReference> bottomReference(new ConfigurableVLNVReference(instanceDesignVLNV));\r\n    bottomInstantiation->setDesignReference(bottomReference);\r\n    instanceComponent->getDesignInstantiations()->append(bottomInstantiation);\r\n    \r\n    QObject* rootObject = builder_->createFrom(topComponentVLNV());\r\n\r\n    QCOMPARE(rootObject->children().count(), 1);\r\n\r\n    QObject* designObject = rootObject->children().first();\r\n    QCOMPARE(designObject->children().count(), 1);\r\n\r\n    QObject* instanceObject = designObject->children().first();\r\n    QCOMPARE(instanceObject->children().count(), 1);\r\n\r\n    QObject* instanceDesignObject = instanceObject->children().first();\r\n    QCOMPARE(instanceDesignObject->objectName(), instanceDesignVLNV.toString());\r\n    QCOMPARE(instanceDesignObject->children().count(), 1);\r\n\r\n    QObject* bottomObject = instanceDesignObject->children().first();\r\n    QCOMPARE(bottomObject->children().count(), 0);\r\n    QCOMPARE(bottomObject->objectName(), bottomInstanceVLNV.toString());\r\n\r\n    delete rootObject;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_DocumentTreeBuilder::testMultipleInstances()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_DocumentTreeBuilder::testMultipleInstances()\r\n{\r\n    QSharedPointer<Component> component = createTopComponent();\r\n    QSharedPointer<Design> design = createDesign();\r\n\r\n    QSharedPointer<View> hierarchicalView(new View());\r\n    hierarchicalView->setDesignInstantiationRef(\"rtl_design\");\r\n    component->getViews()->append(hierarchicalView);\r\n\r\n    QSharedPointer<DesignInstantiation> testInstantiation(new DesignInstantiation(\"rtl_design\"));\r\n    QSharedPointer<ConfigurableVLNVReference> designReference(new ConfigurableVLNVReference(topDesignVLNV()));\r\n    testInstantiation->setDesignReference(designReference);\r\n    component->getDesignInstantiations()->append(testInstantiation);\r\n\r\n    VLNV instanceVLNV(VLNV::COMPONENT, \"TestVendor\", \"TestLibrary\", \"TestInstance\", \"TestVersion\");\r\n    QSharedPointer<Component> instanceComponent(new Component(instanceVLNV, Document::Revision::Std14));\r\n    library_->addComponent(instanceComponent);\r\n\r\n    const int INSTANCE_COUNT = 3;\r\n    for (int i = 0; i < INSTANCE_COUNT; i++)\r\n    {\r\n        QSharedPointer<ComponentInstance> instance(new ComponentInstance());\r\n        instance->setInstanceName(\"instance\" + QString::number(i));\r\n        instance->setComponentRef(QSharedPointer<ConfigurableVLNVReference>(\r\n            new ConfigurableVLNVReference(instanceVLNV)));\r\n         design->getComponentInstances()->append(instance);\r\n    }\r\n\r\n    QObject* rootObject = builder_->createFrom(topComponentVLNV());\r\n\r\n    QCOMPARE(rootObject->children().count(), 1);\r\n\r\n    QObject* designObject = rootObject->children().first();\r\n    QCOMPARE(designObject->children().count(), INSTANCE_COUNT);\r\n\r\n    delete rootObject;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_DocumentTreeBuilder::testStartFromDesign()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_DocumentTreeBuilder::testStartFromDesign()\r\n{\r\n    QSharedPointer<Design> design = createDesign();\r\n\r\n    VLNV instanceVLNV(VLNV::COMPONENT, \"TestVendor\", \"TestLibrary\", \"TestInstance\", \"TestVersion\");\r\n    QSharedPointer<Component> instanceComponent(new Component(instanceVLNV, Document::Revision::Std14));\r\n    library_->addComponent(instanceComponent);\r\n\r\n    QSharedPointer<ComponentInstance> instance(new ComponentInstance());\r\n    instance->setInstanceName(\"instance1\");\r\n    instance->setComponentRef(QSharedPointer<ConfigurableVLNVReference>(new ConfigurableVLNVReference(instanceVLNV)));\r\n    design->getComponentInstances()->append(instance);\r\n\r\n    QObject* rootObject = builder_->createFrom(topDesignVLNV());\r\n    QCOMPARE(rootObject->children().count(), 1);\r\n    QCOMPARE(rootObject->objectName(), topDesignVLNV().toString());\r\n\r\n    QObject* instanceObject = rootObject->children().first();\r\n    QCOMPARE(instanceObject->children().count(), 0);\r\n    QCOMPARE(instanceObject->objectName(), instanceVLNV.toString());\r\n\r\n    delete rootObject;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_DocumentTreeBuilder::testStartFromDesignConfiguration()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_DocumentTreeBuilder::testStartFromDesignConfiguration()\r\n{\r\n    QSharedPointer<Design> design = createDesign();\r\n\r\n    VLNV instanceVLNV(VLNV::COMPONENT, \"TestVendor\", \"TestLibrary\", \"TestInstance\", \"TestVersion\");\r\n    QSharedPointer<Component> instanceComponent(new Component(instanceVLNV, Document::Revision::Std14));\r\n    library_->addComponent(instanceComponent);\r\n\r\n    QSharedPointer<ComponentInstance> instance(new ComponentInstance());\r\n    instance->setInstanceName(\"instance1\");\r\n    instance->setComponentRef(QSharedPointer<ConfigurableVLNVReference>(new ConfigurableVLNVReference(instanceVLNV)));\r\n    design->getComponentInstances()->append(instance);\r\n\r\n    createDesignConfiguration();\r\n\r\n    QObject* rootObject = builder_->createFrom(topDesignConfigurationVLNV());\r\n    QCOMPARE(rootObject->children().count(), 1);\r\n    QCOMPARE(rootObject->objectName(), topDesignConfigurationVLNV().toString());\r\n\r\n    QObject* designObject = rootObject->children().first();\r\n    QCOMPARE(designObject->children().count(), 1);\r\n    QCOMPARE(designObject->objectName(), topDesignVLNV().toString());\r\n\r\n    QObject* instanceObject = designObject->children().first();\r\n    QCOMPARE(instanceObject->children().count(), 0);\r\n    QCOMPARE(instanceObject->objectName(), instanceVLNV.toString());\r\n\r\n    delete rootObject;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_DocumentTreeBuilder::createTopComponent()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<Component> tst_DocumentTreeBuilder::createTopComponent()\r\n{\r\n    QSharedPointer<Component> component(new Component(topComponentVLNV(), Document::Revision::Std14));\r\n    library_->addComponent(component);\r\n\r\n    return component;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_DocumentTreeBuilder::topComponentVLNV()\r\n//-----------------------------------------------------------------------------\r\nVLNV tst_DocumentTreeBuilder::topComponentVLNV()\r\n{\r\n    return VLNV(VLNV::COMPONENT, \"TestVendor\", \"TestLibrary\", \"TestComponent\", \"TestVersion\");\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_DocumentTreeBuilder::createDesign()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<Design> tst_DocumentTreeBuilder::createDesign()\r\n{\r\n    QSharedPointer<Design> design(new Design(topDesignVLNV(), Document::Revision::Std14));\r\n    library_->addComponent(design);\r\n\r\n    return design;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_DocumentTreeBuilder::topDesignVLNV()\r\n//-----------------------------------------------------------------------------\r\nVLNV tst_DocumentTreeBuilder::topDesignVLNV()\r\n{\r\n    return VLNV(VLNV::DESIGN, \"TestVendor\", \"TestLibrary\", \"TestDesign\", \"TestVersion\");\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_DocumentTreeBuilder::createDesignConfiguration()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<DesignConfiguration> tst_DocumentTreeBuilder::createDesignConfiguration()\r\n{\r\n    QSharedPointer<DesignConfiguration> designConfiguration(new DesignConfiguration(topDesignConfigurationVLNV(), Document::Revision::Std14));\r\n    designConfiguration->setDesignRef(topDesignVLNV());\r\n    library_->addComponent(designConfiguration);\r\n\r\n    return designConfiguration;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_DocumentTreeBuilder::topDesignConfigurationVLNV()\r\n//-----------------------------------------------------------------------------\r\nVLNV tst_DocumentTreeBuilder::topDesignConfigurationVLNV()\r\n{\r\n    return VLNV(VLNV::DESIGNCONFIGURATION, \"TestVendor\", \"TestLibrary\", \"TestDesignConfig\", \"TestVersion\");\r\n}\r\n\r\nQTEST_APPLESS_MAIN(tst_DocumentTreeBuilder)\r\n\r\n#include \"tst_DocumentTreeBuilder.moc\"\r\n"
  },
  {
    "path": "tests/Core/tst_DocumentTreeBuilder.pri",
    "content": "# ----------------------------------------------------\r\n# This file is generated by the Qt Visual Studio Add-in.\r\n# ------------------------------------------------------\r\n\r\nHEADERS += ../../mainwindow/SaveHierarchy/DocumentTreeBuilder.h \\\r\n    ../MockObjects/LibraryMock.h\r\nSOURCES += ../../mainwindow/SaveHierarchy/DocumentTreeBuilder.cpp \\\r\n    ../MockObjects/LibraryMock.cpp \\\r\n    ./tst_DocumentTreeBuilder.cpp\r\n"
  },
  {
    "path": "tests/Core/tst_DocumentTreeBuilder.pro",
    "content": "#-----------------------------------------------------------------------------\r\n# File: unittest.pro\r\n#-----------------------------------------------------------------------------\r\n# Project: Kactus 2\r\n# Author: Esko Pekkarinen\r\n# Date: 24.7.2014\r\n#\r\n# Description:\r\n# Qt project file template for running unit tests for a single module.\r\n#-----------------------------------------------------------------------------\r\n\r\nTEMPLATE = app\r\n\r\nTARGET = tst_DocumentTreeBuilder\r\n\r\nQT += core xml gui testlib\r\nCONFIG += c++11 testcase console\r\n\r\nwin32:CONFIG(release, debug|release) {\r\n    LIBS += -L$$PWD/../../executable/ -lIPXACTmodels\r\n    DESTDIR = ./release\r\n}\r\nelse:win32:CONFIG(debug, debug|release) {\r\n    LIBS += -L$$PWD/../../executable/ -lIPXACTmodelsd\r\n    DESTDIR = ./debug\r\n}\r\nelse:unix {\r\n    LIBS += -L$$PWD/../../executable/ -lIPXACTmodels\r\n    DESTDIR = ./release\r\n}\r\n\r\nINCLUDEPATH += $$DESTDIR\r\nINCLUDEPATH += ../../\r\n\r\nDEPENDPATH += .\r\nDEPENDPATH += ../../\r\n\r\nOBJECTS_DIR += $$DESTDIR\r\n\r\nMOC_DIR += ./generatedFiles\r\nUI_DIR += ./generatedFiles\r\nRCC_DIR += ./generatedFiles\r\ninclude(tst_DocumentTreeBuilder.pri)\r\n"
  },
  {
    "path": "tests/Core/tst_ExpressionEditor.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: tst_ExpressionEditor.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Esko Pekkarinen\r\n// Date: 18.12.2014\r\n//\r\n// Description:\r\n// Unit test for class ExpressionEditor.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include <QtTest>\r\n\r\n#include <QAbstractItemView>\r\n#include <QCompleter>\r\n#include <QLineEdit>\r\n\r\n#include <editors/ComponentEditor/common/ExpressionEditor.h>\r\n#include <KactusAPI/include/IPXactSystemVerilogParser.h>\r\n\r\n#include <KactusAPI/include/ComponentParameterFinder.h>\r\n\r\n#include <editors/ComponentEditor/parameters/ComponentParameterModel.h>\r\n\r\n#include <IPXACTmodels/Component/Component.h>\r\n\r\nQ_DECLARE_METATYPE(Qt::Key);\r\n\r\nclass tst_ExpressionEditor : public QObject\r\n{\r\n    Q_OBJECT\r\n\r\npublic:\r\n    tst_ExpressionEditor();\r\n\r\nprivate slots:\r\n\r\n    void testWithoutSettingCompleter();\r\n    \r\n    void testSelectedCompletionIsAppendedToText();\r\n\r\n    void testWordUnderCursorIsCompleted();\r\n    void testWordUnderCursorIsCompleted_data();\r\n\r\n    void testNoCompletionIsShownForEmptyInput();\r\n    void testCompletionsAreShownOnCtrlSpace();\r\n\r\n    void testExpressionInitialization();\r\n    void testExpressionInitialization_data();\r\n\r\n    void testExpressionIsUpdatedForSelectedCompletion();\r\n    void testExpressionIsUpdatedForSelectedCompletion_data();\r\n\r\n    void testCompletionChangesWithCursor();\r\n\r\n    void testCompleteChangesInAllValuesWithKeyNavigation();\r\n    void testCompleteChangesInAllValuesWithKeyNavigation_data();\r\n\r\n    void testCompleteChangesInAllValuesWithMouseNavigation();\r\n\r\n    void testCutCopyPasteIsDisabled();\r\n    void testCutCopyPasteIsDisabled_data();\r\n\r\n    void testAutomaticCompletionForSingleOption();\r\n\r\n    void testColorsAreSetWhenWritingText();\r\n\r\n    void testColorsAreSetWhenRemovingText();\r\n\r\n    void testEditingInTheMiddleOfReferenceName();\r\n    \r\n    void testRemovingExpression();\r\n    void testRemovingReference();\r\n    void testRemovingReferenceWithBackSpaceAndDelete();\r\n\r\n    void testReplaceReferenceWithAnother();\r\n\r\n    void testRemoveAndReplaceSelection();\r\n    void testRemoveAndReplaceSelectionWithReference();\r\n    void testRemoveAndReplaceSelectionWithReference_data();\r\n\r\n    void testEditingConstantExpression();\r\n    void testEditingConstantExpression_data();\r\n\r\n    void testComparisonOperators();\r\n    void testComparisonOperators_data();\r\n\r\n    void testReferencesInModifiedComparison();\r\n\r\nprivate:\r\n\r\n    ExpressionEditor* createEditorWithoutFinder();\r\n    ExpressionEditor* createEditorForComponent(QSharedPointer<Component> component);\r\n\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ExpressionEditor::tst_ExpressionEditor()\r\n//-----------------------------------------------------------------------------\r\ntst_ExpressionEditor::tst_ExpressionEditor()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ExpressionEditor::testWithoutSettingCompleter()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ExpressionEditor::testWithoutSettingCompleter()\r\n{\r\n    ExpressionEditor* editor = createEditorWithoutFinder();\r\n\r\n    QTest::keyClicks(editor, \"one t\");\r\n\r\n    QCOMPARE(editor->toPlainText(), QString(\"one t\"));\r\n\r\n    delete editor;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ExpressionEditor::testSelectedCompletionIsAppendedToText()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ExpressionEditor::testSelectedCompletionIsAppendedToText()\r\n{\r\n    ExpressionEditor* editor = createEditorWithoutFinder();\r\n\r\n    QStringList availableWords;\r\n    availableWords << \"one\" << \"two\";\r\n\r\n    QCompleter* completer = new QCompleter(availableWords);\r\n    editor->setAppendingCompleter(completer);\r\n\r\n    QTest::keyClicks(editor, \"one t\");\r\n\r\n    QCOMPARE(editor->getExpression(), QString(\"one \"));\r\n\r\n    QVERIFY2(completer->popup()->isVisible(), \"Completer popup not visible.\");\r\n    QCOMPARE(completer->currentCompletion(), QString(\"two\"));\r\n\r\n    QTest::keyClick(completer->popup(), Qt::Key_Down);\r\n    QTest::keyClick(completer->popup(), Qt::Key_Return);\r\n\r\n    QCOMPARE(editor->toPlainText(), QString(\"one two\"));\r\n    QCOMPARE(editor->getExpression(), QString(\"one two\"));\r\n\r\n    delete editor;\r\n    delete completer;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ExpressionEditor::testWordUnderCursorIsCompleted()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ExpressionEditor::testWordUnderCursorIsCompleted()\r\n{\r\n    QFETCH(QString, initialText);\r\n    QFETCH(int, selectedPosition);\r\n    QFETCH(QString, input);\r\n    QFETCH(QString, expectedCompletion);\r\n    QFETCH(QString, expectedFinalText);\r\n\r\n    ExpressionEditor* editor = createEditorWithoutFinder();\r\n\r\n    QStringList availableWords;\r\n    availableWords << \"one\" << \"two\";\r\n\r\n    QCompleter* completer = new QCompleter(availableWords);\r\n    editor->setAppendingCompleter(completer);\r\n\r\n    editor->setExpression(initialText);\r\n    \r\n    QSignalSpy referenceUpdaterSpy(editor, SIGNAL(increaseReference(QString const&)));\r\n    \r\n    QTextCursor cursor = editor->textCursor();\r\n    cursor.setPosition(selectedPosition);\r\n    editor->setTextCursor(cursor);\r\n\r\n    QTest::keyClicks(editor, input);\r\n\r\n    QVERIFY2(completer->popup()->isVisible(), \"Completer popup not visible.\");\r\n    QCOMPARE(completer->currentCompletion(), expectedCompletion);\r\n\r\n    QTest::keyClick(completer->popup(), Qt::Key_Down);\r\n    QTest::keyClick(completer->popup(), Qt::Key_Return);\r\n\r\n    QCOMPARE(editor->toPlainText(), expectedFinalText);\r\n    QCOMPARE(editor->getExpression(), expectedFinalText);\r\n\r\n    QCOMPARE(referenceUpdaterSpy.count(), 1);\r\n    QCOMPARE(referenceUpdaterSpy.first().first().toString(), expectedCompletion);\r\n\r\n    delete editor;\r\n    delete completer;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ExpressionEditor::testWordUnderCursorIsCompleted_data()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ExpressionEditor::testWordUnderCursorIsCompleted_data()\r\n{\r\n    QTest::addColumn<QString>(\"initialText\");\r\n    QTest::addColumn<int>(\"selectedPosition\");\r\n    QTest::addColumn<QString>(\"input\");\r\n    QTest::addColumn<QString>(\"expectedCompletion\");\r\n    QTest::addColumn<QString>(\"expectedFinalText\");\r\n\r\n    QTest::newRow(\"Complete first word\") << \"o word\" << 1 << \"n\" << \"one\" << \"one word\";\r\n\r\n    QTest::newRow(\"Complete first word before plus\") << \"o+1\" << 1 << \"n\" << \"one\" << \"one+1\";\r\n    QTest::newRow(\"Complete first word before minus\") << \"o-1\" << 1 << \"n\" << \"one\" << \"one-1\";\r\n    QTest::newRow(\"Complete first word before multiply\") << \"o*1\" << 1 << \"n\" << \"one\" << \"one*1\";\r\n    QTest::newRow(\"Complete first word before power\") << \"o**1\" << 1 << \"n\" << \"one\" << \"one**1\";\r\n    QTest::newRow(\"Complete first word before division\") << \"o/1\" << 1 << \"n\" << \"one\" << \"one/1\";\r\n\r\n    QTest::newRow(\"Complete first word after opening parenthesis\") << \"1+(o\" << 4 << \"n\" << \"one\" << \"1+(one\";\r\n    QTest::newRow(\"Complete word in parentheses\") << \"(t)\" << 2 << \"w\" << \"two\" << \"(two)\";\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ExpressionEditor::testNoCompletionIsShownForEmptyInput()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ExpressionEditor::testNoCompletionIsShownForEmptyInput()\r\n{\r\n    ExpressionEditor* editor = createEditorWithoutFinder();\r\n\r\n    QStringList availableWords(\"one\");\r\n\r\n    QCompleter* completer = new QCompleter(availableWords);\r\n    editor->setAppendingCompleter(completer);\r\n\r\n    editor->setText(\"\");\r\n\r\n    QVERIFY2(!completer->popup()->isVisible(), \"Completer popup should not be visible before editing.\");\r\n\r\n    QTest::keyClicks(editor, \"o\");\r\n    QTest::keyClick(editor, Qt::Key_Backspace);\r\n\r\n    QVERIFY2(!completer->popup()->isVisible(), \"Completer popup should not be visible for emptied editor.\");\r\n\r\n    delete editor;\r\n    delete completer;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ExpressionEditor::testCompletionsAreShownOnCtrlSpace()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ExpressionEditor::testCompletionsAreShownOnCtrlSpace()\r\n{\r\n    ExpressionEditor* editor = createEditorWithoutFinder();\r\n\r\n    QStringList availableWords(\"one\");\r\n\r\n    QCompleter* completer = new QCompleter(availableWords);\r\n    editor->setAppendingCompleter(completer);\r\n\r\n    QVERIFY2(!completer->popup()->isVisible(), \"Completer popup should not be visible before editing.\");\r\n\r\n    QTest::keyClick(editor, Qt::Key_Space, Qt::ControlModifier);\r\n\r\n    QVERIFY2(completer->popup()->isVisible(), \"Completer popup should be visible when Ctrl+Space is pressed.\");\r\n\r\n    QCOMPARE(editor->toPlainText(), QString(\"\"));\r\n\r\n    delete editor;\r\n    delete completer;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ExpressionEditor::testExpressionInitialization()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ExpressionEditor::testExpressionInitialization()\r\n{\r\n    QFETCH(QString, parameterName);\r\n    QFETCH(QString, parameterId);\r\n    QFETCH(QString, expression);\r\n    QFETCH(QString, expectedDisplayText);\r\n    QFETCH(Qt::GlobalColor, expectedColor);\r\n\r\n    QSharedPointer<Parameter> testParameter(new Parameter());\r\n    testParameter->setName(parameterName);\r\n    testParameter->setValueId(parameterId);\r\n    testParameter->setValue(\"32\");\r\n\r\n    QList<QSharedPointer<Parameter> > parameters;\r\n    parameters.append(testParameter);\r\n\r\n    QSharedPointer<Component> targetComponent(new Component(VLNV(), Document::Revision::Std14));\r\n    targetComponent->getParameters()->append(parameters);\r\n\r\n    ExpressionEditor* editor = createEditorForComponent(targetComponent);\r\n\r\n    editor->setExpression(expression);\r\n\r\n    QCOMPARE(editor->toPlainText(), expectedDisplayText);\r\n    QCOMPARE(editor->getExpression(), expression);\r\n    QCOMPARE(editor->textColor(), expectedColor);\r\n\r\n    delete editor;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ExpressionEditor::testExpressionInitialization_data()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ExpressionEditor::testExpressionInitialization_data()\r\n{\r\n    QTest::addColumn<QString>(\"parameterName\");\r\n    QTest::addColumn<QString>(\"parameterId\");\r\n    QTest::addColumn<QString>(\"expression\");\r\n    QTest::addColumn<QString>(\"expectedDisplayText\");\r\n    QTest::addColumn<Qt::GlobalColor>(\"expectedColor\");\r\n\r\n    QTest::newRow(\"Parameter id is replaced with name and shown in darkGreen\") << \"testParameter\" << \"id\" \r\n        << \"id\" << \"testParameter\" << Qt::darkGreen;\r\n\r\n    QTest::newRow(\"Parameter id can be uuid\") << \"testParameter\" << \"uuid_12345678_90ab_cdef_ffff_abcdef000000\" \r\n        << \"uuid_12345678_90ab_cdef_ffff_abcdef000000\" << \"testParameter\" << Qt::darkGreen;\r\n\r\n    QTest::newRow(\"Constant is written in black\") << \"testParameter\" << \"id\" \r\n        << \"1\" << \"1\" << Qt::black;\r\n\r\n    QTest::newRow(\"Constant with size and base is written in black\") << \"testParameter\" << \"id\" \r\n        << \"8'hFF\" << \"8'hFF\" << Qt::black;\r\n\r\n    QTest::newRow(\"String is written in black\") << \"testParameter\" << \"id\" \r\n        << \"\\\"testParameter\\\"\" << \"\\\"testParameter\\\"\" << Qt::black;\r\n\r\n    QTest::newRow(\"Operator is shown in black\") << \"testParameter\" << \"id\" \r\n        << \"+\" << \"+\" << Qt::black;\r\n\r\n    QTest::newRow(\"Non-referencing word is shown in red\") << \"testParameter\" << \"id\" \r\n        << \"nonReferencing\" << \"nonReferencing\" << Qt::red;\r\n\r\n    QTest::newRow(\"Parameter id is not replaced if part of other word\") << \"testParameter\" << \"id\" \r\n        << \"pid + 1\" << \"pid + 1\" << Qt::black;\r\n\r\n    QTest::newRow(\"Math function is shown in black\") << \"testParameter\" << \"id\"\r\n        << \"$pow\" << \"$pow\" << Qt::black;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ExpressionEditor::testExpressionIsUpdatedForSelectedCompletion()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ExpressionEditor::testExpressionIsUpdatedForSelectedCompletion()\r\n{\r\n    QFETCH(QString, initialExpression);\r\n    QFETCH(QString, input);\r\n    QFETCH(QString, expectedExpression);\r\n    QFETCH(QString, expectedDisplayText);\r\n\r\n    QUuid uuid(\"{12345678-90ab-cdef-ffff-abcdef000000}\");\r\n\r\n    QString uuidString = uuid.toString();\r\n    uuidString.remove('{');\r\n    uuidString.remove('}');\r\n    uuidString.replace('-','_');\r\n    uuidString.prepend(\"uuid_\");\r\n\r\n    QSharedPointer<Parameter> uuidParameter(new Parameter());\r\n    uuidParameter->setName(\"alpha\");\r\n    uuidParameter->setValueId(uuidString);\r\n    uuidParameter->setValue(\"a\");\r\n\r\n    QSharedPointer<Parameter> testParameter(new Parameter());\r\n    testParameter->setName(\"testParameter\");\r\n    testParameter->setValueId(\"id\");\r\n    testParameter->setValue(\"32\");\r\n\r\n    QList<QSharedPointer<Parameter> > parameters;\r\n    parameters.append(uuidParameter);\r\n    parameters.append(testParameter);\r\n\r\n    QSharedPointer<Component> targetComponent(new Component(VLNV(), Document::Revision::Std14));\r\n    targetComponent->getParameters()->append(parameters);\r\n\r\n    ExpressionEditor* editor = createEditorForComponent(targetComponent);\r\n\r\n    editor->setExpression(initialExpression);\r\n\r\n    QTest::keyClick(editor, Qt::Key_End);\r\n    QTest::keyClicks(editor, input);\r\n\r\n    QTest::keyClick(editor->completer()->popup(), Qt::Key_Down);\r\n    QTest::keyClick(editor->completer()->popup(), Qt::Key_Return);\r\n\r\n    editor->finishEditingCurrentWord();\r\n\r\n    QCOMPARE(editor->toPlainText(), expectedDisplayText);\r\n    QCOMPARE(editor->getExpression(), expectedExpression);\r\n\r\n    delete editor;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ExpressionEditor::testExpressionIsUpdatedForSelectedCompletion_data()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ExpressionEditor::testExpressionIsUpdatedForSelectedCompletion_data()\r\n{\r\n    QTest::addColumn<QString>(\"initialExpression\");\r\n    QTest::addColumn<QString>(\"input\");\r\n    QTest::addColumn<QString>(\"expectedExpression\");\r\n    QTest::addColumn<QString>(\"expectedDisplayText\");\r\n\r\n    QTest::newRow(\"Parameter id is replaced with name\") << \"\" << \"te\" << \"id\" << \"testParameter\";\r\n\r\n    QTest::newRow(\"Adding text does not remove id\") << \"id\" << \"-8\" << \"id-8\" << \"testParameter-8\";\r\n\r\n    QTest::newRow(\"Adding another reference does not remove id\") << \"id\" << \"+testP\" \r\n        << \"id+id\" << \"testParameter+testParameter\";\r\n\r\n    QTest::newRow(\"Uuid as parameter id\") << \"uuid_12345678_90ab_cdef_ffff_abcdef000000\" << \"-1\" \r\n        << \"uuid_12345678_90ab_cdef_ffff_abcdef000000-1\" << \"alpha-1\";\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ExpressionEditor::testCompletionChangesWithCursor()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ExpressionEditor::testCompletionChangesWithCursor()\r\n{\r\n    QSharedPointer<Parameter> testParameter(new Parameter());\r\n    testParameter->setName(\"testParameter\");\r\n    testParameter->setValueId(\"id\");\r\n    testParameter->setValue(\"32\");\r\n\r\n    QList<QSharedPointer<Parameter> > parameters;\r\n    parameters.append(testParameter);\r\n\r\n    QSharedPointer<Component> targetComponent(new Component(VLNV(), Document::Revision::Std14));\r\n    targetComponent->getParameters()->append(parameters);\r\n\r\n    ExpressionEditor* editor = createEditorForComponent(targetComponent);\r\n\r\n    editor->show();\r\n    QVERIFY(QTest::qWaitForWindowActive(editor, 5000));\r\n\r\n    editor->setExpression(\"id+1+id+\\\"text\\\"\");\r\n\r\n    QTextCursor cursor = editor->textCursor();\r\n    cursor.setPosition(4);\r\n\r\n    QTest::mouseClick(editor->viewport(), Qt::LeftButton, Qt::NoModifier, editor->cursorRect(cursor).center());\r\n\r\n    QVERIFY2(editor->completer()->popup()->isVisible(), \"Completer popup should be visible after clicking a word.\");\r\n    QCOMPARE(editor->completer()->currentCompletion(), QString(\"testParameter\"));\r\n\r\n    cursor.setPosition(testParameter->name().length() + 1);\r\n\r\n    QTest::mouseClick(editor->viewport(), Qt::LeftButton, Qt::NoModifier, editor->cursorRect(cursor).center());\r\n\r\n    QVERIFY2(!editor->completer()->popup()->isVisible(), \"Completer popup should not be visible after clicking a constant.\");\r\n\r\n    delete editor;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ExpressionEditor::testCompleteChangesInAllValuesWithKeyNavigationRight()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ExpressionEditor::testCompleteChangesInAllValuesWithKeyNavigation()\r\n{\r\n    QFETCH(QString, expectedValue);\r\n    QFETCH(QList<Qt::Key>, keysUsed);\r\n    QFETCH(int, numberOfRounds);\r\n\r\n    ExpressionEditor* editor = createEditorWithoutFinder();\r\n\r\n    editor->show();\r\n    QVERIFY(QTest::qWaitForWindowActive(editor, 5000));\r\n\r\n    editor->setExpression(\"1+1+1+1\");\r\n    QTextCursor cursor = editor->textCursor();\r\n    cursor.setPosition(0);\r\n\r\n    QTest::keyClick(editor, keysUsed.at(0));\r\n\r\n    for (int i = 0; i < numberOfRounds; ++i)\r\n    {\r\n        for (int j = 1; j < keysUsed.size(); ++j)\r\n        {\r\n            QTest::keyClick(editor, keysUsed.at(j));\r\n            if (keysUsed.at(j) == Qt::Key_Delete)\r\n            {\r\n                QTest::keyClicks(editor, \"20\");\r\n            }\r\n        }\r\n    }\r\n\r\n    editor->finishEditingCurrentWord();\r\n\r\n    QCOMPARE(editor->toPlainText(), expectedValue);\r\n    QCOMPARE(editor->getExpression(), expectedValue);\r\n\r\n    delete editor;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ExpressionEditor::testCompleteChangesInAllValuesWithKeyNavigation_data()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ExpressionEditor::testCompleteChangesInAllValuesWithKeyNavigation_data()\r\n{\r\n    QTest::addColumn<QString>(\"expectedValue\");\r\n    QTest::addColumn<QList < Qt::Key > >(\"keysUsed\");\r\n    QTest::addColumn<int>(\"numberOfRounds\");\r\n\r\n    QList<Qt::Key> keysUsedInTest;\r\n    keysUsedInTest << Qt::Key_Home << Qt::Key_Delete << Qt::Key_Right;\r\n    QTest::newRow(\"Complete all changes when using right key to navigate\") << \"20+20+20+20\" << keysUsedInTest << 4;\r\n\r\n    keysUsedInTest.clear();\r\n    keysUsedInTest << Qt::Key_End << Qt::Key_Left << Qt::Key_Delete << Qt::Key_Left << Qt::Key_Left << Qt::Key_Left;\r\n    QTest::newRow(\"Complete all changes when using left key to navigate\") << \"20+20+20+20\" << keysUsedInTest << 4;\r\n\r\n    keysUsedInTest.clear();\r\n    keysUsedInTest << Qt::Key_End << Qt::Key_Left << Qt::Key_Delete << Qt::Key_Home << Qt::Key_Delete;\r\n    QTest::newRow(\"Complete all changes when using end and home keys to navigate\") << \"20+1+1+20\" << keysUsedInTest << 1;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ExpressionEditor::testCompleteChangesInAllValuesWithMouseNavigation()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ExpressionEditor::testCompleteChangesInAllValuesWithMouseNavigation()\r\n{\r\n    ExpressionEditor* editor = createEditorWithoutFinder();\r\n    editor->show();\r\n    QVERIFY(QTest::qWaitForWindowActive(editor));\r\n\r\n    editor->setExpression(\"1+1+1+1\");\r\n    QTextCursor cursor = editor->textCursor();\r\n\r\n    cursor.setPosition(0);\r\n    QPoint clickPoint = editor->cursorRect(cursor).center();\r\n    QTest::mouseClick(editor->viewport(), Qt::LeftButton, Qt::NoModifier, clickPoint);\r\n    QTest::keyClick(editor, Qt::Key_Delete);\r\n    QTest::keyClicks(editor, \"20\");\r\n\r\n    cursor.setPosition(5);\r\n    clickPoint = editor->cursorRect(cursor).center();\r\n    QTest::mouseClick(editor->viewport(), Qt::LeftButton, Qt::NoModifier, clickPoint);\r\n    QTest::keyClick(editor, Qt::Key_Delete);\r\n    QTest::keyClicks(editor, \"20\");\r\n\r\n    cursor.setPosition(3);\r\n    clickPoint = editor->cursorRect(cursor).center();\r\n    QTest::mouseClick(editor->viewport(), Qt::LeftButton, Qt::NoModifier, clickPoint);\r\n    QTest::keyClick(editor, Qt::Key_Delete);\r\n    QTest::keyClicks(editor, \"20\");\r\n\r\n    editor->finishEditingCurrentWord();\r\n\r\n    QString expectedValue(\"20+20+20+1\");\r\n\r\n    QCOMPARE(editor->toPlainText(), expectedValue);\r\n    QCOMPARE(editor->getExpression(), expectedValue);\r\n\r\n    delete editor;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ExpressionEditor::testCutCopyPasteIsDisabled()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ExpressionEditor::testCutCopyPasteIsDisabled()\r\n{\r\n    QFETCH(Qt::Key, keyForCopying);\r\n    QFETCH(QString, expectedValue);\r\n\r\n    ExpressionEditor* editor = createEditorWithoutFinder();\r\n    editor->show();\r\n    QVERIFY(QTest::qWaitForWindowActive(editor));\r\n\r\n    editor->setExpression(\"1+2+2+1\");\r\n    QTextCursor cursor = editor->textCursor();\r\n\r\n    QTest::keyClick(editor, Qt::Key_Home);\r\n    QTest::keyClick(editor, Qt::Key_Right);\r\n    for (int i = 0; i < 4; i++)\r\n    {\r\n        QTest::keyClick(editor, Qt::Key_Right, Qt::ShiftModifier);\r\n    }\r\n    QTest::keyClick(editor, keyForCopying, Qt::ControlModifier);\r\n\r\n    QTest::keyClick(editor, Qt::Key_End);\r\n    QTest::keyClick(editor, Qt::Key_V, Qt::ControlModifier);\r\n\r\n    editor->finishEditingCurrentWord();\r\n\r\n    //QCOMPARE(editor->toPlainText(), expectedValue);\r\n    //QCOMPARE(editor->getExpression(), expectedValue);\r\n\r\n    delete editor;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ExpressionEditor::testCutCopyPasteIsDisabled_data()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ExpressionEditor::testCutCopyPasteIsDisabled_data()\r\n{\r\n    QTest::addColumn<Qt::Key>(\"keyForCopying\");\r\n    QTest::addColumn<QString>(\"expectedValue\");\r\n\r\n    QTest::newRow(\"Copying is disabled inside the editor\") << Qt::Key_C << \"1+2+2+1+2+2\";\r\n    QTest::newRow(\"Cutting is disabled inside the editor\") << Qt::Key_X << \"1+1+2+2\";\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ExpressionEditor::testAutomaticCompletionForSingleOption(()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ExpressionEditor::testAutomaticCompletionForSingleOption()\r\n{\r\n    QSharedPointer<Parameter> testParameter(new Parameter());\r\n    testParameter->setName(\"testParameter\");\r\n    testParameter->setValueId(\"id\");\r\n\r\n    QSharedPointer<Parameter> nonUniqueParameter(new Parameter());\r\n    nonUniqueParameter->setName(\"none\");\r\n    nonUniqueParameter->setValueId(\"noId\");\r\n\r\n    QSharedPointer<Parameter> nonUniqueParameter2(new Parameter());\r\n    nonUniqueParameter->setName(\"none2\");\r\n    nonUniqueParameter->setValueId(\"noId2\");\r\n\r\n    QList<QSharedPointer<Parameter> > parameters;\r\n    parameters.append(testParameter);\r\n\r\n    QSharedPointer<Component> targetComponent(new Component(VLNV(), Document::Revision::Std14));\r\n    targetComponent->getParameters()->append(parameters);\r\n\r\n    ExpressionEditor* editor = createEditorForComponent(targetComponent);\r\n\r\n    QTest::keyClicks(editor, \"testParameter \");\r\n\r\n    QCOMPARE(editor->getExpression(), QString(\"id \"));\r\n\r\n    QTextCursor cursor = editor->textCursor();\r\n    cursor.movePosition(QTextCursor::PreviousCharacter);\r\n    QCOMPARE(cursor.charFormat().foreground().color(), Qt::darkGreen);\r\n\r\n    editor->setExpression(\"\");\r\n\r\n    QTest::keyClicks(editor, \"none \");\r\n\r\n    QCOMPARE(editor->getExpression(), QString(\"none \"));\r\n\r\n    cursor = editor->textCursor();\r\n    cursor.movePosition(QTextCursor::PreviousCharacter);\r\n    QCOMPARE(cursor.charFormat().foreground().color(), Qt::red);\r\n\r\n    delete editor;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ExpressionEditor::testColorsAreSetWhenWritingText()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ExpressionEditor::testColorsAreSetWhenWritingText()\r\n{\r\n    QSharedPointer<Parameter> testParameter(new Parameter());\r\n    testParameter->setName(\"testParameter\");\r\n    testParameter->setValueId(\"id\");\r\n    testParameter->setValue(\"32\");\r\n\r\n    QList<QSharedPointer<Parameter> > parameters;\r\n    parameters.append(testParameter);\r\n\r\n    QSharedPointer<Component> targetComponent(new Component(VLNV(), Document::Revision::Std14));\r\n    targetComponent->getParameters()->append(parameters);\r\n\r\n    ExpressionEditor* editor = createEditorForComponent(targetComponent);\r\n\r\n    QTest::keyClicks(editor, \"tes\");\r\n\r\n    QTest::keyClick(editor->completer()->popup(), Qt::Key_Down);\r\n    QTest::keyClick(editor->completer()->popup(), Qt::Key_Return);\r\n\r\n    QCOMPARE(editor->getExpression(), QString(\"id\"));\r\n    QCOMPARE(editor->textCursor().charFormat().foreground().color(), Qt::darkGreen);\r\n\r\n    QTest::keyClicks(editor, \"+\");\r\n\r\n    QCOMPARE(editor->getExpression(), QString(\"id+\"));\r\n    QCOMPARE(editor->textCursor().charFormat().foreground().color(), Qt::black);\r\n\r\n    QTest::keyClicks(editor, \"8\");\r\n    QCOMPARE(editor->textCursor().charFormat().foreground().color(), Qt::black);\r\n\r\n    QTest::keyClicks(editor, \"'hff\");\r\n    QCOMPARE(editor->textCursor().charFormat().foreground().color(), Qt::black);\r\n\r\n    QTest::keyClicks(editor, \"-testParameter\");\r\n\r\n    QCOMPARE(editor->getExpression(), QString(\"id+8'hff-\"));\r\n    QCOMPARE(editor->textCursor().charFormat().foreground().color(), Qt::black);\r\n\r\n    QTest::keyClicks(editor, \" \");\r\n\r\n    QCOMPARE(editor->getExpression(), QString(\"id+8'hff-id \"));\r\n\r\n    QTextCursor cursor = editor->textCursor();\r\n    cursor.movePosition(QTextCursor::PreviousCharacter);\r\n    QCOMPARE(cursor.charFormat().foreground().color(), Qt::darkGreen);\r\n\r\n    QTest::keyClicks(editor, \"+ \\\"text\\\"\");\r\n\r\n    editor->finishEditingCurrentWord();\r\n\r\n    QCOMPARE(editor->getExpression(), QString(\"id+8'hff-id + \\\"text\\\"\"));\r\n    QCOMPARE(editor->textCursor().charFormat().foreground().color(), Qt::black);\r\n\r\n    delete editor;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ExpressionEditor::testColorsAreSetWhenRemovingText()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ExpressionEditor::testColorsAreSetWhenRemovingText()\r\n{\r\n    QSharedPointer<Parameter> testParameter(new Parameter());\r\n    testParameter->setName(\"testParameter\");\r\n    testParameter->setValueId(\"id\");\r\n    testParameter->setValue(\"32\");\r\n\r\n    QList<QSharedPointer<Parameter> > parameters;\r\n    parameters.append(testParameter);\r\n\r\n    QSharedPointer<Component> targetComponent(new Component(VLNV(), Document::Revision::Std14));\r\n    targetComponent->getParameters()->append(parameters);\r\n\r\n    ExpressionEditor* editor = createEditorForComponent(targetComponent);\r\n\r\n    QSignalSpy referenceDecreases(editor, SIGNAL(decreaseReference(QString const&)));\r\n\r\n    QTest::keyClicks(editor, \"tes\");\r\n\r\n    QTest::keyClick(editor->completer()->popup(), Qt::Key_Down);\r\n    QTest::keyClick(editor->completer()->popup(), Qt::Key_Return);\r\n\r\n    QCOMPARE(editor->getExpression(), QString(\"id\"));\r\n    QCOMPARE(editor->textCursor().charFormat().foreground().color(), Qt::darkGreen);\r\n\r\n    QTest::keyClick(editor, Qt::Key_Backspace);\r\n\r\n    QCOMPARE(editor->getExpression(), QString(\"id\"));\r\n\r\n    QTest::keyClicks(editor, \" \");\r\n\r\n    QCOMPARE(editor->getExpression(), QString(\"testParamete \"));\r\n    QCOMPARE(referenceDecreases.first().first().toString(), QString(\"id\"));\r\n\r\n    QTextCursor cursor = editor->textCursor();\r\n    cursor.movePosition(QTextCursor::PreviousWord);\r\n    QCOMPARE(cursor.charFormat().foreground().color(), Qt::red);\r\n\r\n    delete editor;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ExpressionEditor::testEditingInTheMiddleOfReferenceName()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ExpressionEditor::testEditingInTheMiddleOfReferenceName()\r\n{\r\n    QSharedPointer<Parameter> testParameter(new Parameter());\r\n    testParameter->setName(\"testParameter\");\r\n    testParameter->setValueId(\"id\");\r\n    testParameter->setValue(\"32\");\r\n\r\n    QList<QSharedPointer<Parameter> > parameters;\r\n    parameters.append(testParameter);\r\n\r\n    QSharedPointer<Component> targetComponent(new Component(VLNV(), Document::Revision::Std14));\r\n    targetComponent->getParameters()->append(parameters);\r\n\r\n    ExpressionEditor* editor = createEditorForComponent(targetComponent);\r\n    QSignalSpy referenceDecreases(editor, SIGNAL(decreaseReference(QString const&)));\r\n\r\n    editor->setExpression(\"id\");\r\n    \r\n    QTextCursor cursor = editor->textCursor();\r\n    cursor.setPosition(4);\r\n    editor->setTextCursor(cursor);\r\n\r\n    QTest::keyClick(editor, Qt::Key_Space);\r\n    QCOMPARE(editor->toPlainText(), QString(\"test Parameter\"));\r\n    QCOMPARE(editor->getExpression(), QString(\"test Parameter\"));\r\n\r\n    QCOMPARE(referenceDecreases.first().count(), 1);\r\n\r\n    QTest::keyClick(editor, Qt::Key_Delete);\r\n    editor->finishEditingCurrentWord();\r\n    QCOMPARE(editor->toPlainText(), QString(\"test arameter\"));\r\n    QCOMPARE(editor->getExpression(), QString(\"test arameter\"));\r\n\r\n    QTest::keyClick(editor, Qt::Key_Backspace);\r\n    editor->finishEditingCurrentWord();\r\n    QCOMPARE(editor->toPlainText(), QString(\"testarameter\"));\r\n    QCOMPARE(editor->getExpression(), QString(\"testarameter\"));\r\n\r\n    QTest::keyClicks(editor, \"+P\");\r\n    editor->finishEditingCurrentWord();\r\n    QCOMPARE(editor->toPlainText(), QString(\"test+Parameter\"));\r\n    QCOMPARE(editor->getExpression(), QString(\"test+Parameter\"));\r\n\r\n    delete editor;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ExpressionEditor::testRemovingExpression()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ExpressionEditor::testRemovingExpression()\r\n{\r\n    QSharedPointer<Component> emptyComponent(new Component(VLNV(), Document::Revision::Std14));\r\n\r\n    ExpressionEditor* editor = createEditorForComponent(emptyComponent);\r\n    editor->setExpression(\"8'hff*2\");\r\n\r\n    QSignalSpy referenceDecreases(editor, SIGNAL(decreaseReference(QString const&)));\r\n\r\n    QTextCursor cursor = editor->textCursor();\r\n    cursor.movePosition(QTextCursor::End);\r\n    editor->setTextCursor(cursor);\r\n\r\n    for (int i = 0; i < 7; i++)\r\n    {    \r\n        QTest::keyClick(editor, Qt::Key_Backspace);\r\n    }\r\n\r\n    QCOMPARE(editor->toPlainText(), QString(\"\"));\r\n    QCOMPARE(editor->getExpression(), QString(\"\"));\r\n    QCOMPARE(referenceDecreases.count(), 0);\r\n\r\n\r\n    editor->setExpression(\"2*2+2/2\");\r\n\r\n    cursor.movePosition(QTextCursor::Start);\r\n    editor->setTextCursor(cursor);\r\n\r\n    for (int i = 0; i < 7; i++)\r\n    {    \r\n        QTest::keyClick(editor, Qt::Key_Delete);\r\n    }\r\n\r\n    QCOMPARE(editor->toPlainText(), QString(\"\"));\r\n    QCOMPARE(editor->getExpression(), QString(\"\"));\r\n    QCOMPARE(referenceDecreases.count(), 0);\r\n\r\n    delete editor;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ExpressionEditor::testRemovingReference()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ExpressionEditor::testRemovingReference()\r\n{\r\n    QSharedPointer<Parameter> testParameter(new Parameter());\r\n    testParameter->setName(\"testParameter\");\r\n    testParameter->setValueId(\"id\");\r\n    testParameter->setValue(\"32\");\r\n\r\n    QList<QSharedPointer<Parameter> > parameters;\r\n    parameters.append(testParameter);\r\n\r\n    QSharedPointer<Component> targetComponent(new Component(VLNV(), Document::Revision::Std14));\r\n    targetComponent->getParameters()->append(parameters);\r\n\r\n    ExpressionEditor* editor = createEditorForComponent(targetComponent);\r\n\r\n    QSignalSpy referenceDecreases(editor, SIGNAL(decreaseReference(QString const&)));\r\n\r\n    editor->setExpression(\"id\");\r\n\r\n    QTextCursor cursor = editor->textCursor();\r\n    cursor.movePosition(QTextCursor::End);\r\n    editor->setTextCursor(cursor);\r\n\r\n    QTest::keyClick(editor, Qt::Key_Backspace);\r\n\r\n    QCOMPARE(editor->toPlainText(), QString(\"testParamete\"));\r\n    QCOMPARE(editor->getExpression(), QString(\"id\"));\r\n\r\n    editor->finishEditingCurrentWord();\r\n\r\n    QCOMPARE(editor->toPlainText(), QString(\"testParamete\"));\r\n    QCOMPARE(editor->getExpression(), QString(\"testParamete\"));\r\n\r\n    editor->setExpression(\"id\");\r\n\r\n    cursor.movePosition(QTextCursor::Start);\r\n    editor->setTextCursor(cursor);\r\n\r\n    QTest::keyClick(editor, Qt::Key_Delete);\r\n\r\n    QCOMPARE(editor->toPlainText(), QString(\"estParameter\"));\r\n    QCOMPARE(editor->getExpression(), QString(\"id\"));\r\n\r\n    editor->finishEditingCurrentWord();\r\n\r\n    QCOMPARE(editor->toPlainText(), QString(\"estParameter\"));\r\n    QCOMPARE(editor->getExpression(), QString(\"estParameter\"));\r\n\r\n    delete editor;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ExpressionEditor::testRemovingReferenceWithBackSpaceAndDelete()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ExpressionEditor::testRemovingReferenceWithBackSpaceAndDelete()\r\n{\r\n    QSharedPointer<Parameter> testParameter(new Parameter());\r\n    testParameter->setName(\"testParameter\");\r\n    testParameter->setValueId(\"id\");\r\n    testParameter->setValue(\"32\");\r\n\r\n    QList<QSharedPointer<Parameter> > parameters;\r\n    parameters.append(testParameter);\r\n\r\n    QSharedPointer<Component> targetComponent(new Component(VLNV(), Document::Revision::Std14));\r\n    targetComponent->getParameters()->append(parameters);\r\n\r\n    ExpressionEditor* editor = createEditorForComponent(targetComponent);\r\n\r\n    QSignalSpy referenceDecreases(editor, SIGNAL(decreaseReference(QString const&)));\r\n\r\n    editor->setExpression(\"id\");\r\n\r\n    QTextCursor cursor = editor->textCursor();\r\n    cursor.movePosition(QTextCursor::End);\r\n    editor->setTextCursor(cursor);\r\n\r\n    const int numberOfCharacters = QString(\"testParameter\").length();\r\n    for (int i = 0; i < numberOfCharacters; i++)\r\n    {    \r\n        QTest::keyClick(editor, Qt::Key_Backspace);\r\n    }\r\n    \r\n    QCOMPARE(editor->toPlainText(), QString(\"\"));\r\n    QCOMPARE(editor->getExpression(), QString(\"\"));\r\n\r\n    QCOMPARE(referenceDecreases.first().first().toString(), QString(\"id\"));\r\n\r\n\r\n    referenceDecreases.clear();\r\n    editor->setExpression(\"id\");\r\n\r\n    cursor.movePosition(QTextCursor::Start);\r\n    editor->setTextCursor(cursor);\r\n\r\n    for (int i = 0; i < numberOfCharacters; i++)\r\n    {    \r\n        QTest::keyClick(editor, Qt::Key_Delete);\r\n    }\r\n\r\n    QCOMPARE(editor->toPlainText(), QString(\"\"));\r\n    QCOMPARE(editor->getExpression(), QString(\"\"));\r\n\r\n    QCOMPARE(referenceDecreases.first().first().toString(), QString(\"id\"));\r\n\r\n    delete editor;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ExpressionEditor::testReplaceReferenceWithAnother()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ExpressionEditor::testReplaceReferenceWithAnother()\r\n{\r\n    QSharedPointer<Parameter> testParameter(new Parameter());\r\n    testParameter->setName(\"testParameter\");\r\n    testParameter->setValueId(\"id\");\r\n    testParameter->setValue(\"32\");\r\n\r\n    QSharedPointer<Parameter> otherParameter(new Parameter());\r\n    otherParameter->setName(\"testParameter2\");\r\n    otherParameter->setValueId(\"otherId\");\r\n    otherParameter->setValue(\"32\");\r\n\r\n    QList<QSharedPointer<Parameter> > parameters;\r\n    parameters.append(testParameter);\r\n    parameters.append(otherParameter);\r\n\r\n    QSharedPointer<Component> targetComponent(new Component(VLNV(), Document::Revision::Std14));\r\n    targetComponent->getParameters()->append(parameters);\r\n\r\n    ExpressionEditor* editor = createEditorForComponent(targetComponent);\r\n\r\n    QSignalSpy referenceIncreases(editor, SIGNAL(increaseReference(QString const&)));\r\n    QSignalSpy referenceDecreases(editor, SIGNAL(decreaseReference(QString const&)));\r\n\r\n    editor->setExpression(\"id\");\r\n    \r\n    QTextCursor cursor = editor->textCursor();\r\n    cursor.movePosition(QTextCursor::End);\r\n    editor->setTextCursor(cursor);\r\n\r\n    QTest::keyClicks(editor, \"2\");\r\n\r\n    QVERIFY(editor->completer()->popup()->isVisible());\r\n    QTest::keyClick(editor->completer()->popup(), Qt::Key_Down);\r\n    QTest::keyClick(editor->completer()->popup(), Qt::Key_Return);\r\n\r\n    QCOMPARE(editor->toPlainText(), QString(\"testParameter2\"));\r\n    QCOMPARE(editor->getExpression(), QString(\"otherId\"));\r\n\r\n    QCOMPARE(referenceIncreases.first().first().toString(), QString(\"otherId\"));\r\n    QCOMPARE(referenceDecreases.first().first().toString(), QString(\"id\"));\r\n\r\n    delete editor;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ExpressionEditor::testRemoveAndReplaceSelection()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ExpressionEditor::testRemoveAndReplaceSelection()\r\n{\r\n    QSharedPointer<Component> emptyComponent(new Component(VLNV(), Document::Revision::Std14));\r\n\r\n    ExpressionEditor* editor = createEditorForComponent(emptyComponent);\r\n\r\n    editor->setExpression(\"8'hff+8'hff\");\r\n\r\n    QTextCursor cursor = editor->textCursor();\r\n    cursor.movePosition(QTextCursor::Start, QTextCursor::MoveAnchor);\r\n    cursor.setPosition(5, QTextCursor::KeepAnchor);\r\n    editor->setTextCursor(cursor);\r\n\r\n    QTest::keyClick(editor, Qt::Key_Delete);\r\n    editor->finishEditingCurrentWord();\r\n\r\n    QCOMPARE(editor->toPlainText(), QString(\"+8'hff\"));\r\n    QCOMPARE(editor->getExpression(), QString(\"+8'hff\"));\r\n\r\n    cursor = editor->textCursor();\r\n    cursor.movePosition(QTextCursor::Start, QTextCursor::MoveAnchor);\r\n    cursor.movePosition(QTextCursor::End, QTextCursor::KeepAnchor);\r\n    editor->setTextCursor(cursor);\r\n\r\n    QVERIFY(editor->textCursor().hasSelection());\r\n    QTest::keyClicks(editor, \"abc\");\r\n\r\n    editor->finishEditingCurrentWord();\r\n\r\n    QCOMPARE(editor->toPlainText(), QString(\"abc\"));\r\n    QCOMPARE(editor->getExpression(), QString(\"abc\"));\r\n\r\n    delete editor;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ExpressionEditor::testRemoveAndReplaceSelectionWithReference()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ExpressionEditor::testRemoveAndReplaceSelectionWithReference()\r\n{\r\n    QFETCH(QString, initialExpression);    \r\n    QFETCH(QString, selectedText);\r\n    QFETCH(Qt::Key, input);\r\n    QFETCH(QString, expectedText);\r\n    QFETCH(QString, expectedExpression);\r\n    QFETCH(int, numberOfReferencesInSelection);\r\n\r\n    QSharedPointer<Parameter> testParameter(new Parameter());\r\n    testParameter->setName(\"testParameter\");\r\n    testParameter->setValueId(\"veryLongReferenceName\");\r\n    testParameter->setValue(\"32\");\r\n\r\n    QList<QSharedPointer<Parameter> > parameters;\r\n    parameters.append(testParameter);\r\n\r\n    QSharedPointer<Component> targetComponent(new Component(VLNV(), Document::Revision::Std14));\r\n    targetComponent->getParameters()->append(parameters);\r\n\r\n    ExpressionEditor* editor = createEditorForComponent(targetComponent);\r\n    QSignalSpy referenceDecreases(editor, SIGNAL(decreaseReference(QString const&)));\r\n\r\n    editor->setExpression(initialExpression);\r\n\r\n    QTextCursor cursor = editor->textCursor();\r\n    cursor.setPosition(editor->toPlainText().indexOf(selectedText), QTextCursor::MoveAnchor);\r\n    cursor.setPosition(cursor.position() + selectedText.length(), QTextCursor::KeepAnchor);\r\n    editor->setTextCursor(cursor);\r\n\r\n    QTest::keyClick(editor, input);\r\n    editor->finishEditingCurrentWord();\r\n\r\n    QCOMPARE(editor->toPlainText(), expectedText);\r\n    QCOMPARE(editor->getExpression(), expectedExpression);\r\n    QCOMPARE(referenceDecreases.count(), numberOfReferencesInSelection);\r\n\r\n    delete editor;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ExpressionEditor::testRemoveAndReplaceSelectionWithReference_data()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ExpressionEditor::testRemoveAndReplaceSelectionWithReference_data()\r\n{\r\n    QTest::addColumn<QString>(\"initialExpression\");    \r\n    QTest::addColumn<QString>(\"selectedText\");\r\n    QTest::addColumn<Qt::Key>(\"input\");\r\n    QTest::addColumn<QString>(\"expectedText\");\r\n    QTest::addColumn<QString>(\"expectedExpression\");\r\n    QTest::addColumn<int>(\"numberOfReferencesInSelection\");\r\n\r\n    QTest::newRow(\"delete whole expression\") << \"veryLongReferenceName+veryLongReferenceName\" << \r\n        \"testParameter+testParameter\" << Qt::Key_Delete << \"\" << \"\" << 2;\r\n\r\n    QTest::newRow(\"delete reference from expression\") << \"veryLongReferenceName+1\" << \r\n        \"testParameter+\" << Qt::Key_Delete << \"1\" << \"1\" << 1;\r\n\r\n    QTest::newRow(\"delete part of reference\") << \"1+veryLongReferenceName+1\" << \r\n        \"Parameter\" << Qt::Key_Delete << \"1+test+1\" << \"1+test+1\" << 1;\r\n\r\n    QTest::newRow(\"delete part of reference\") << \"veryLongReferenceName+1+2\" << \r\n        \"Parameter+1\" << Qt::Key_Delete << \"test+2\" << \"test+2\" << 1;\r\n\r\n    QTest::newRow(\"delete parts from two references\") << \"veryLongReferenceName+veryLongReferenceName\" << \r\n        \"Parameter+t\" << Qt::Key_Delete << \"testestParameter\" << \"testestParameter\" << 2;\r\n\r\n    QTest::newRow(\"replace reference\") << \"veryLongReferenceName\" << \r\n        \"testParameter\" << Qt::Key_0 << \"0\" << \"0\" << 1;\r\n\r\n    QTest::newRow(\"replace part of reference\") << \"veryLongReferenceName\" << \r\n        \"test\" << Qt::Key_1 << \"1Parameter\" << \"1Parameter\" << 1;\r\n\r\n    QTest::newRow(\"replace parts of two references\") << \"veryLongReferenceName+veryLongReferenceName\" << \r\n        \"Parameter+t\" << Qt::Key_T << \"testtestParameter\" << \"testtestParameter\" << 2;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ExpressionEditor::testEditingConstantExpression()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ExpressionEditor::testEditingConstantExpression()\r\n{\r\n    QFETCH(QString, initialExpression);\r\n    QFETCH(int, indexForInput);\r\n    QFETCH(QString, input);\r\n    QFETCH(QString, expectedExpression);\r\n\r\n    QSharedPointer<Component> emptyComponent(new Component(VLNV(), Document::Revision::Std14));\r\n\r\n    ExpressionEditor* editor = createEditorForComponent(emptyComponent);\r\n\r\n    editor->setExpression(initialExpression);\r\n\r\n    QTextCursor cursor = editor->textCursor();\r\n    cursor.setPosition(indexForInput);\r\n    editor->setTextCursor(cursor);\r\n\r\n    QTest::keyClicks(editor, input);\r\n\r\n    editor->finishEditingCurrentWord();\r\n\r\n    QCOMPARE(editor->toPlainText(), expectedExpression);\r\n    QCOMPARE(editor->getExpression(), expectedExpression);\r\n\r\n    delete editor;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ExpressionEditor::testEditingConstantExpression_data()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ExpressionEditor::testEditingConstantExpression_data()\r\n{\r\n    QTest::addColumn<QString>(\"initialExpression\");\r\n    QTest::addColumn<int>(\"indexForInput\");\r\n    QTest::addColumn<QString>(\"input\");\r\n    QTest::addColumn<QString>(\"expectedExpression\");\r\n\r\n    QTest::newRow(\"Inserting space before last term\") << \"1+1\" << 2 << \" \" << \"1+ 1\";\r\n    QTest::newRow(\"Inserting operator in constant term\") << \"11\" << 1 << \"+\" << \"1+1\";\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ExpressionEditor::testComparisonOperators()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ExpressionEditor::testComparisonOperators()\r\n{\r\n    QFETCH(QString, input);\r\n\r\n    QSharedPointer<Component> emptyComponent(new Component(VLNV(), Document::Revision::Std14));\r\n\r\n    ExpressionEditor* editor = createEditorForComponent(emptyComponent);\r\n\r\n    editor->setExpression(\"\");\r\n\r\n    QTextCursor cursor = editor->textCursor();\r\n    cursor.setPosition(0);\r\n    editor->setTextCursor(cursor);\r\n\r\n    QTest::keyClicks(editor, input);\r\n\r\n    editor->finishEditingCurrentWord();\r\n\r\n    QCOMPARE(editor->toPlainText(), input);\r\n    QCOMPARE(editor->getExpression(), input);\r\n\r\n    delete editor;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ExpressionEditor::testComparisonOperators_data()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ExpressionEditor::testComparisonOperators_data()\r\n{\r\n    QTest::addColumn<QString>(\"input\");\r\n\r\n    QTest::newRow(\"Inserting greater than -operator\") << \"4>3\";\r\n    QTest::newRow(\"Inserting greater than -operator\") << \"4> 3\";\r\n    QTest::newRow(\"Inserting greater than -operator\") << \"4 >3\";\r\n    QTest::newRow(\"Inserting greater than -operator\") << \"4 > 3\";\r\n\r\n    QTest::newRow(\"Inserting lesser than -operator\") << \"4<3\";\r\n    QTest::newRow(\"Inserting lesser than -operator\") << \"4< 3\";\r\n    QTest::newRow(\"Inserting lesser than -operator\") << \"4 <3\";\r\n    QTest::newRow(\"Inserting lesser than -operator\") << \"4 < 3\";\r\n\r\n    QTest::newRow(\"Inserting equals-operator\") << \"3==3\";\r\n    QTest::newRow(\"Inserting equals-operator\") << \"3== 3\";\r\n    QTest::newRow(\"Inserting equals-operator\") << \"3 ==3\";\r\n    QTest::newRow(\"Inserting equals-operator\") << \"3 == 3\";\r\n\r\n    QTest::newRow(\"Inserting greater than or equals -operator\") << \"4>=3\";\r\n    QTest::newRow(\"Inserting greater than or equals -operator\") << \"3>= 3\";\r\n    QTest::newRow(\"Inserting greater than or equals -operator\") << \"3 >=3\";\r\n    QTest::newRow(\"Inserting greater than or equals -operator\") << \"2 >= 3\";\r\n\r\n    QTest::newRow(\"Inserting lesser than or equals -operator\") << \"4<=3\";\r\n    QTest::newRow(\"Inserting lesser than or equals -operator\") << \"3<= 3\";\r\n    QTest::newRow(\"Inserting lesser than or equals -operator\") << \"3 <=3\";\r\n    QTest::newRow(\"Inserting lesser than or equals -operator\") << \"2 <= 3\";\r\n\r\n    QTest::newRow(\"Inserting not equals -operator\") << \"4!=3\";\r\n    QTest::newRow(\"Inserting not equals -operator\") << \"3!= 3\";\r\n    QTest::newRow(\"Inserting not equals -operator\") << \"3 !=3\";\r\n    QTest::newRow(\"Inserting not equals -operator\") << \"2 != 3\";\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ExpressionEditor::testReferencesInModifiedComparison()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ExpressionEditor::testReferencesInModifiedComparison()\r\n{\r\n    QSharedPointer<Parameter> testParameter(new Parameter());\r\n    testParameter->setName(\"testParameter\");\r\n    testParameter->setValueId(\"id\");\r\n    testParameter->setValue(\"10\");\r\n\r\n    QSharedPointer<Component> targetComponent(new Component(VLNV(), Document::Revision::Std14));\r\n    targetComponent->getParameters()->append(testParameter);\r\n\r\n    ExpressionEditor* editor = createEditorForComponent(targetComponent);\r\n\r\n    QSignalSpy referenceDecreases(editor, SIGNAL(decreaseReference(QString const&)));\r\n\r\n    editor->setExpression(\"id+2\");\r\n\r\n    QTextCursor cursor = editor->textCursor();\r\n    cursor.movePosition(QTextCursor::End);\r\n    editor->setTextCursor(cursor);\r\n\r\n    QTest::keyClick(editor, Qt::Key_Left);\r\n    QTest::keyClick(editor, Qt::Key_Backspace);\r\n\r\n    editor->finishEditingCurrentWord();\r\n\r\n    QCOMPARE(editor->toPlainText(), QString(\"testParameter2\"));\r\n    QCOMPARE(editor->getExpression(), QString(\"testParameter2\"));\r\n\r\n    //QCOMPARE(referenceDecreases.size(), 1);\r\n\r\n    delete editor;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ExpressionEditor::createEditorWithoutResolver()\r\n//-----------------------------------------------------------------------------\r\nExpressionEditor* tst_ExpressionEditor::createEditorWithoutFinder()\r\n{\r\n    return new ExpressionEditor(QSharedPointer<ParameterFinder>());\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ExpressionEditor::createEditorForComponent()\r\n//-----------------------------------------------------------------------------\r\nExpressionEditor* tst_ExpressionEditor::createEditorForComponent(QSharedPointer<Component> component)\r\n{\r\n    QSharedPointer<ParameterFinder> finder(new ComponentParameterFinder(component));\r\n\r\n    ComponentParameterModel* parameterModel = new ComponentParameterModel(finder, 0);\r\n    parameterModel->setExpressionParser(QSharedPointer<IPXactSystemVerilogParser>(new IPXactSystemVerilogParser(finder)));\r\n\r\n    QCompleter* completer = new QCompleter(this);\r\n    completer->setModel(parameterModel);\r\n    \r\n    ExpressionEditor* editor = new ExpressionEditor(finder);\r\n    editor->setAppendingCompleter(completer);\r\n\r\n    completer->setParent(editor);\r\n    return editor;\r\n}\r\n\r\n\r\nQTEST_MAIN(tst_ExpressionEditor)\r\n\r\n#include \"tst_ExpressionEditor.moc\"\r\n"
  },
  {
    "path": "tests/Core/tst_ExpressionEditor.pri",
    "content": "# ----------------------------------------------------\r\n# This file is generated by the Qt Visual Studio Tools.\r\n# ------------------------------------------------------\r\n\r\n\r\nHEADERS += ../../editors/ComponentEditor/common/MasterExpressionEditor.h \\\r\n    ../../editors/ComponentEditor/common/ParameterizableTable.h \\\r\n    ../../editors/ComponentEditor/parameters/ComponentParameterModel.h \\\r\n    ../../editors/ComponentEditor/common/ExpressionEditor.h \\\r\n    ../../editors/ComponentEditor/common/ReferencingTableModel.h\r\nSOURCES += ../../editors/ComponentEditor/parameters/ComponentParameterModel.cpp \\\r\n    ../../editors/ComponentEditor/common/ExpressionEditor.cpp \\\r\n    ../../editors/ComponentEditor/common/MasterExpressionEditor.cpp \\\r\n    ../../editors/ComponentEditor/common/ParameterizableTable.cpp \\\r\n    ../../editors/ComponentEditor/common/ReferencingTableModel.cpp \\\r\n    ./tst_ExpressionEditor.cpp\r\n"
  },
  {
    "path": "tests/Core/tst_ExpressionEditor.pro",
    "content": "#-----------------------------------------------------------------------------\r\n# File: tst_ExpressionEditor.pro\r\n#-----------------------------------------------------------------------------\r\n# Project: Kactus 2\r\n# Author: Esko Pekkarinen\r\n# Date: 18.12.2014\r\n#\r\n# Description:\r\n# Qt project file template for running unit tests for ExpressionEditor.\r\n#-----------------------------------------------------------------------------\r\n\r\nTEMPLATE = app\r\n\r\nTARGET = tst_ExpressionEditor\r\n\r\nQT += core xml gui testlib widgets\r\nCONFIG += c++11 testcase console\r\n\r\nQMAKE_EXPORTED_VARIABLES += MAKE_TESTARGS\r\nMAKE_TESTARGS.name = TESTARGS\r\nMAKE_TESTARGS.value = \"-platform offscreen\"\r\n\r\nwin32:CONFIG(release, debug|release) {\r\n    LIBS += -L$$PWD/../../executable/ -lIPXACTmodels -lKactusAPI\r\n    DESTDIR = ./release\r\n}\r\nelse:win32:CONFIG(debug, debug|release) {\r\n    LIBS += -L$$PWD/../../executable/ -lIPXACTmodelsd -lKactusAPId\r\n    DESTDIR = ./debug\r\n}\r\nelse:unix {\r\n    LIBS += -L$$PWD/../../executable/ -lIPXACTmodels -lKactusAPI\r\n    DESTDIR = ./release\r\n}\r\n\r\nINCLUDEPATH += $$PWD/../../\r\nINCLUDEPATH += $$DESTDIR\r\n\r\nDEPENDPATH += $$PWD/../../\r\nDEPENDPATH += .\r\n\r\nOBJECTS_DIR += $$DESTDIR\r\n\r\nMOC_DIR += ./generatedFiles\r\nUI_DIR += ./generatedFiles\r\nRCC_DIR += ./generatedFiles\r\n\r\ninclude(tst_ExpressionEditor.pri)\r\n"
  },
  {
    "path": "tests/Core/tst_FieldGraphItem.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: tst_FieldGraphItem.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Esko Pekkarinen\r\n// Date: 14.04.2015\r\n//\r\n// Description:\r\n// Unit test for class FieldGraphItem.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include <QtTest>\r\n\r\n#include <editors/ComponentEditor/memoryMaps/memoryMapsVisualizer/fieldgraphitem.h>\r\n#include <editors/ComponentEditor/visualization/memorygapitem.h>\r\n#include <KactusAPI/include/ExpressionParser.h>\r\n#include <KactusAPI/include/SystemVerilogExpressionParser.h>\r\n#include <KactusAPI/include/NullParser.h>\r\n\r\n#include <IPXACTmodels/Component/Field.h>\r\n\r\nclass tst_FieldGraphItem : public QObject\r\n{\r\n    Q_OBJECT\r\n\r\npublic:\r\n    tst_FieldGraphItem();\r\n    \r\nprivate slots:\r\n\r\n    void testConstructor();\r\n\r\n    void testExpressions();\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_FieldGraphItem::tst_FieldGraphItem()\r\n//-----------------------------------------------------------------------------\r\ntst_FieldGraphItem::tst_FieldGraphItem()\r\n{\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_FieldGraphItem::testConstructor()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_FieldGraphItem::testConstructor()\r\n{\r\n    QSharedPointer<Field> testField(new Field());\r\n    testField->setName(\"testField\");\r\n    testField->setBitOffset(\"0\");\r\n    testField->setBitWidth(\"2\");\r\n\r\n    QSharedPointer<ExpressionParser> noParser(new NullParser());\r\n\r\n    FieldGraphItem* FieldItem = new FieldGraphItem(testField, noParser, 0);    \r\n\r\n    QCOMPARE(FieldItem->name(), QString(\"testField\"));\r\n    QCOMPARE(FieldItem->getOffset(), quint64(0));\r\n    QCOMPARE(FieldItem->getLastAddress(), quint64(1));\r\n    QCOMPARE(FieldItem->getDisplayOffset(), quint64(1));\r\n    QCOMPARE(FieldItem->getDisplayLastAddress(), quint64(0));\r\n\r\n    QCOMPARE(FieldItem->pos().y(), qreal(0));\r\n\r\n    delete FieldItem;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_FieldGraphItem::testExpressions()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_FieldGraphItem::testExpressions()\r\n{\r\n    QSharedPointer<Field> testField(new Field());\r\n    testField->setBitOffset(\"1+1\");\r\n    testField->setBitWidth(\"2*2\");\r\n\r\n    QSharedPointer<ExpressionParser> parser(new SystemVerilogExpressionParser());\r\n\r\n    FieldGraphItem* FieldItem = new FieldGraphItem(testField, parser, 0);    \r\n\r\n    QCOMPARE(FieldItem->getBitWidth(), 4);\r\n    QCOMPARE(FieldItem->getOffset(), quint64(2));\r\n    QCOMPARE(FieldItem->getLastAddress(), quint64(5));\r\n    QCOMPARE(FieldItem->getDisplayOffset(), quint64(5));\r\n    QCOMPARE(FieldItem->getDisplayLastAddress(), quint64(2));\r\n\r\n    QCOMPARE(FieldItem->pos().y(), qreal(0));\r\n\r\n    delete FieldItem;\r\n}\r\n\r\nQTEST_MAIN(tst_FieldGraphItem)\r\n\r\n#include \"tst_FieldGraphItem.moc\"\r\n"
  },
  {
    "path": "tests/Core/tst_FieldGraphItem.pri",
    "content": "# ----------------------------------------------------\r\n# This file is generated by the Qt Visual Studio Tools.\r\n# ------------------------------------------------------\r\n\r\nHEADERS += ../../common/graphicsItems/expandableitem.h \\\r\n    ../../editors/ComponentEditor/visualization/fieldgapitem.h \\\r\n    ../../editors/ComponentEditor/visualization/AddressableItem.h \\\r\n    ../../editors/ComponentEditor/memoryMaps/memoryMapsVisualizer/fieldgraphitem.h \\\r\n    ../../common/graphicsItems/graphicsexpandcollapseitem.h \\\r\n    ../../editors/ComponentEditor/visualization/memorygapitem.h \\\r\n    ../../editors/ComponentEditor/visualization/memoryvisualizationitem.h \\\r\n    ../../editors/ComponentEditor/memoryMaps/memoryMapsVisualizer/registergraphitem.h \\\r\n    ../../common/graphicsItems/visualizeritem.h\r\nSOURCES += ../../common/graphicsItems/expandableitem.cpp \\\r\n    ../../editors/ComponentEditor/visualization/fieldgapitem.cpp \\\r\n    ../../editors/ComponentEditor/visualization/AddressableItem.cpp \\\r\n    ../../editors/ComponentEditor/memoryMaps/memoryMapsVisualizer/fieldgraphitem.cpp \\\r\n    ../../common/graphicsItems/graphicsexpandcollapseitem.cpp \\\r\n    ../../editors/ComponentEditor/visualization/memorygapitem.cpp \\\r\n    ../../editors/ComponentEditor/visualization/memoryvisualizationitem.cpp \\\r\n    ../../editors/ComponentEditor/memoryMaps/memoryMapsVisualizer/registergraphitem.cpp \\\r\n    ../../common/graphicsItems/visualizeritem.cpp \\\r\n    ./tst_FieldGraphItem.cpp\r\n"
  },
  {
    "path": "tests/Core/tst_FieldGraphItem.pro",
    "content": "#-----------------------------------------------------------------------------\r\n# File: tst_FieldGraphItem.pro\r\n#-----------------------------------------------------------------------------\r\n# Project: Kactus 2\r\n# Author: Esko Pekkarinen\r\n# Date: 28.04.2015\r\n#\r\n# Description:\r\n# Qt project file template for running unit tests for AddressBlockGraphItem.\r\n#-----------------------------------------------------------------------------\r\n\r\nTEMPLATE = app\r\n\r\nTARGET = tst_FieldGraphItem\r\n\r\nDEFINES+=KACTUS2_EXPORTS\r\n\r\nQT += core xml gui testlib widgets\r\nCONFIG += c++11 testcase console\r\n\r\nQMAKE_EXPORTED_VARIABLES += MAKE_TESTARGS\r\nMAKE_TESTARGS.name = TESTARGS\r\nMAKE_TESTARGS.value = \"-platform offscreen\"\r\n\r\nwin32:CONFIG(release, debug|release) {\r\n    LIBS += -L$$PWD/../../executable/ -lIPXACTmodels -lKactusAPI\r\n    DESTDIR = ./release\r\n}\r\nelse:win32:CONFIG(debug, debug|release) {\r\n    LIBS += -L$$PWD/../../executable/ -lIPXACTmodelsd -lKactusAPId\r\n    DESTDIR = ./debug\r\n}\r\nelse:unix {\r\n    LIBS += -L$$PWD/../../executable/ -lIPXACTmodels -lKactusAPI\r\n    DESTDIR = ./release\r\n}\r\n\r\nINCLUDEPATH += $$PWD/../../\r\nINCLUDEPATH += $$PWD/../../executable\r\nINCLUDEPATH += $$DESTDIR\r\n\r\nDEPENDPATH += $$PWD/../../\r\nDEPENDPATH += $$PWD/../../executable\r\nDEPENDPATH += .\r\n\r\nOBJECTS_DIR += $$DESTDIR\r\n\r\nMOC_DIR += ./generatedFiles\r\nUI_DIR += ./generatedFiles\r\nRCC_DIR += ./generatedFiles\r\ninclude(tst_FieldGraphItem.pri)\r\n"
  },
  {
    "path": "tests/Core/tst_HierarchicalSaveBuildStrategy.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: tst_HierarchicalSaveBuildStrategy.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Esko Pekkarinen\r\n// Date: 20.05.2015\r\n//\r\n// Description:\r\n// Unit test for class HierarchicalSaveBuildStrategy.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include <QtTest>\r\n\r\n#include <tests/MockObjects/LibraryMock.h>\r\n\r\n#include <mainwindow/SaveHierarchy/HierarchicalSaveBuildStrategy.h>\r\n#include <mainwindow/SaveHierarchy/HierarchicalSaveColumns.h>\r\n\r\n#include <IPXACTmodels/Component/Component.h>\r\n#include <IPXACTmodels/common/VLNV.h>\r\n\r\nclass tst_HierarchicalSaveBuildStrategy : public QObject\r\n{\r\n    Q_OBJECT\r\n\r\npublic:\r\n    tst_HierarchicalSaveBuildStrategy();\r\n\r\nprivate slots:\r\n\r\n    void cleanup();\r\n\r\n    void testNullParameter();\r\n\r\n    void testVLNVIsSetAndVersionIsUpdated();\r\n\r\n    void testVLNVIsSetAndVersionIsUpdated_data();\r\n\r\n    void testSuggestedNameDoesNotYetExistInLibrary();\r\n\r\n    void testItemsAreCreatedOnlyForComponentsAndDesign();\r\n\r\n    void testMultipleInstancesCreatesOneItem();\r\n\r\n    void testDesignAndDesignConfiguration();\r\n\r\n    void testCheckingIsRecursive();\r\n\r\n    void testItemCannotBeCheckedIfParentNotChecked();\r\n\r\nprivate:\r\n\r\n    QTreeWidgetItem* buildFrom(QObject* rootObject);\r\n\r\n    LibraryMock* library_;\r\n    \r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_HierarchicalSaveBuildStrategy::tst_HierarchicalSaveBuildStrategy()\r\n//-----------------------------------------------------------------------------\r\ntst_HierarchicalSaveBuildStrategy::tst_HierarchicalSaveBuildStrategy(): library_(new LibraryMock(this))\r\n{\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_HierarchicalSaveBuildStrategy::tst_HierarchicalSaveBuildStrategy()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_HierarchicalSaveBuildStrategy::cleanup()\r\n{\r\n    library_->clear();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_HierarchicalSaveBuildStrategy::testNullParameter()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_HierarchicalSaveBuildStrategy::testNullParameter()\r\n{\r\n    HierarchicalSaveBuildStrategy strategy(0);\r\n\r\n    QTreeWidgetItem* rootItem = strategy.build(0);\r\n\r\n    delete rootItem;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_HierarchicalSaveBuildStrategy::testVLNVIsSetAndVersionIsUpdated()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_HierarchicalSaveBuildStrategy::testVLNVIsSetAndVersionIsUpdated()\r\n{\r\n    QFETCH(QString, vlnv);\r\n    QFETCH(QString, expectedItemName);\r\n    QFETCH(QString, expectedUpdatedVlnv);\r\n\r\n    QObject* rootObject = new QObject(0);\r\n    rootObject->setObjectName(vlnv);\r\n    rootObject->setProperty(\"VLNVType\", \"Component\");\r\n\r\n    VLNV existingVLNV(VLNV::COMPONENT, vlnv);\r\n    QSharedPointer<Component> existingComponent(new Component(existingVLNV, Document::Revision::Std14));\r\n    library_->addComponent(existingComponent);\r\n\r\n    QTreeWidgetItem* rootItem = buildFrom(rootObject);\r\n        \r\n    QCOMPARE(rootItem->columnCount(), 2);\r\n\r\n    QCOMPARE(rootItem->text(HierarchicalSaveColumns::VLNV), expectedItemName);\r\n    QCOMPARE(rootItem->text(HierarchicalSaveColumns::SAVE_AS_VLNV), expectedUpdatedVlnv);\r\n\r\n    QCOMPARE(rootItem->checkState(HierarchicalSaveColumns::SAVE_AS_VLNV), Qt::Checked);\r\n    QVERIFY(rootItem->flags() & Qt::ItemIsEditable);\r\n    \r\n    delete rootObject;\r\n    delete rootItem;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_HierarchicalSaveBuildStrategy::testVLNVIsSetAndVersionIsUpdated_data()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_HierarchicalSaveBuildStrategy::testVLNVIsSetAndVersionIsUpdated_data()\r\n{\r\n    QTest::addColumn<QString>(\"vlnv\");\r\n    QTest::addColumn<QString>(\"expectedItemName\");\r\n    QTest::addColumn<QString>(\"expectedUpdatedVlnv\");\r\n\r\n    QTest::newRow(\"empty string\") << \"\" << \"Item not found\" << \":::\";\r\n    QTest::newRow(\"empty vlnv\") << \":::\" << \"Item not found\" << \":::\";\r\n\r\n    QTest::newRow(\"version with number is incremented\") << \"TestVendor:TestLibrary:TestVLNV:1.0\" << \r\n        \"TestVendor:TestLibrary:TestVLNV:1.0\" << \"TestVendor:TestLibrary:TestVLNV:1.1\";\r\n\r\n    QTest::newRow(\"version with increasing amount of digits\") << \"TestVendor:TestLibrary:TestVLNV:1.9\" << \r\n        \"TestVendor:TestLibrary:TestVLNV:1.9\" << \"TestVendor:TestLibrary:TestVLNV:1.10\";\r\n\r\n    QTest::newRow(\"version with characters appends a number\") << \"TestVendor:TestLibrary:TestVLNV:draft\" << \r\n        \"TestVendor:TestLibrary:TestVLNV:draft\" << \"TestVendor:TestLibrary:TestVLNV:draft_1\";\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_HierarchicalSaveBuildStrategy::testSuggestedNameDoesNotYetExistInLibrary()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_HierarchicalSaveBuildStrategy::testSuggestedNameDoesNotYetExistInLibrary()\r\n{\r\n    VLNV originalVLNV(VLNV::COMPONENT, \"TestVendor:TestLibrary:TestComponent:1.0\");\r\n    QSharedPointer<Component> originalComponent(new Component(originalVLNV, Document::Revision::Std14));\r\n    library_->addComponent(originalComponent);\r\n\r\n    QObject* rootObject = new QObject(0);\r\n    rootObject->setObjectName(\"TestVendor:TestLibrary:TestComponent:1.0\");\r\n    rootObject->setProperty(\"VLNVType\", \"Component\");\r\n\r\n    VLNV existingVLNV(VLNV::COMPONENT, \"TestVendor:TestLibrary:TestComponent:1.1\");\r\n    QSharedPointer<Component> existingComponent(new Component(existingVLNV, Document::Revision::Std14));\r\n    library_->addComponent(existingComponent);\r\n\r\n    QTreeWidgetItem* rootItem = buildFrom(rootObject);\r\n\r\n    rootItem->setData(HierarchicalSaveColumns::SAVE_AS_VLNV, Qt::CheckStateRole, Qt::Unchecked);\r\n\r\n    QCOMPARE(rootItem->text(HierarchicalSaveColumns::SAVE_AS_VLNV), QString(\"TestVendor:TestLibrary:TestComponent:1.2\"));\r\n\r\n    delete rootObject;\r\n    delete rootItem;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_HierarchicalSaveBuildStrategy::testItemsAreCreatedOnlyForComponentsAndDesign()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_HierarchicalSaveBuildStrategy::testItemsAreCreatedOnlyForComponentsAndDesign()\r\n{\r\n    QObject* rootObject = new QObject(0);\r\n    rootObject->setObjectName(\"TestVendor:TestLibrary:TestComponent:1.0\");\r\n    rootObject->setProperty(\"VLNVType\", \"Component\");\r\n\r\n    QObject* designConfigurationObject = new QObject(rootObject);\r\n    designConfigurationObject->setObjectName(\"TestVendor:TestLibrary:TestConfiguration:1.0\");\r\n    designConfigurationObject->setProperty(\"VLNVType\", \"DesignConfiguration\");\r\n\r\n    QObject* designObject = new QObject(designConfigurationObject);\r\n    designObject->setObjectName(\"TestVendor:TestLibrary:TestDesign:1.0\");\r\n    designObject->setProperty(\"VLNVType\", \"Design\");\r\n    \r\n    QObject* instanceObject = new QObject(designObject);\r\n    instanceObject->setObjectName(\"TestVendor:TestLibrary:TestInstance:1.0\");\r\n    instanceObject->setProperty(\"VLNVType\", \"Component\");\r\n\r\n    QTreeWidgetItem* rootItem = buildFrom(rootObject);\r\n\r\n    QCOMPARE(rootItem->childCount(), 1);\r\n   \r\n    QTreeWidgetItem* designItem = rootItem->child(0);\r\n    QCOMPARE(designItem->text(HierarchicalSaveColumns::VLNV), QString(\"TestVendor:TestLibrary:TestDesign:1.0\"));\r\n    QCOMPARE(designItem->childCount(), 1);\r\n\r\n    QTreeWidgetItem* instanceItem = designItem->child(0);\r\n    QCOMPARE(instanceItem->text(HierarchicalSaveColumns::VLNV), QString(\"TestVendor:TestLibrary:TestInstance:1.0\"));\r\n    QCOMPARE(instanceItem->childCount(), 0);\r\n\r\n    delete rootObject;\r\n    delete rootItem;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_HierarchicalSaveBuildStrategy::testItemsAreCreatedOnlyForComponentsAndDesign()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_HierarchicalSaveBuildStrategy::testMultipleInstancesCreatesOneItem()\r\n{\r\n    QObject* rootObject = new QObject(0);\r\n    rootObject->setObjectName(\"TestVendor:TestLibrary:TestDesign:1.0\");\r\n    rootObject->setProperty(\"VLNVType\", \"Design\");\r\n\r\n    QObject* instanceObject = new QObject(rootObject);\r\n    instanceObject->setObjectName(\"TestVendor:TestLibrary:TestInstance:1.0\");\r\n    instanceObject->setProperty(\"VLNVType\", \"Component\");\r\n\r\n    QObject* instanceDoubleObject = new QObject(rootObject);\r\n    instanceDoubleObject->setObjectName(\"TestVendor:TestLibrary:TestInstance:1.0\");\r\n    instanceDoubleObject->setProperty(\"VLNVType\", \"Component\");\r\n\r\n    QObject* otherInstance = new QObject(rootObject);\r\n    otherInstance->setObjectName(\"TestVendor:TestLibrary:TestInstance:1.1\");\r\n    otherInstance->setProperty(\"VLNVType\", \"Component\");  \r\n    \r\n    QTreeWidgetItem* rootItem = buildFrom(rootObject);\r\n\r\n    QCOMPARE(rootItem->text(HierarchicalSaveColumns::VLNV), QString(\"TestVendor:TestLibrary:TestDesign:1.0\"));\r\n    QCOMPARE(rootItem->childCount(), 2);\r\n\r\n    QTreeWidgetItem* combinedItem = rootItem->child(0);\r\n    QCOMPARE(combinedItem->text(HierarchicalSaveColumns::VLNV), QString(\"TestVendor:TestLibrary:TestInstance:1.0\"));\r\n    QCOMPARE(combinedItem->childCount(), 0);\r\n\r\n    QTreeWidgetItem* otherInstanceItem = rootItem->child(1);\r\n    QCOMPARE(otherInstanceItem->text(HierarchicalSaveColumns::VLNV), \r\n        QString(\"TestVendor:TestLibrary:TestInstance:1.1\"));\r\n    QCOMPARE(otherInstanceItem->childCount(), 0);\r\n\r\n    delete rootObject;\r\n    delete rootItem;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_HierarchicalSaveBuildStrategy::testDesignAndDesignConfiguration()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_HierarchicalSaveBuildStrategy::testDesignAndDesignConfiguration()\r\n{\r\n    QObject* rootObject = new QObject(0);\r\n    rootObject->setObjectName(\"TestVendor:TestLibrary:TestComponent:1.0\");\r\n    rootObject->setProperty(\"VLNVType\", \"Component\");\r\n\r\n    QObject* designConfigurationObject = new QObject(rootObject);\r\n    designConfigurationObject->setObjectName(\"TestVendor:TestLibrary:TestConfiguration:1.0\");\r\n    designConfigurationObject->setProperty(\"VLNVType\", \"DesignConfiguration\");\r\n\r\n    QObject* designObject = new QObject(designConfigurationObject);\r\n    designObject->setObjectName(\"TestVendor:TestLibrary:TestDesign:1.0\");\r\n    designObject->setProperty(\"VLNVType\", \"Design\");\r\n\r\n    QObject* otherDesign = new QObject(rootObject);\r\n    otherDesign->setObjectName(\"TestVendor:TestLibrary:TestDesign:2.1\");\r\n    otherDesign->setProperty(\"VLNVType\", \"Design\");\r\n\r\n    QTreeWidgetItem* rootItem = buildFrom(rootObject);\r\n\r\n    QCOMPARE(rootItem->text(HierarchicalSaveColumns::VLNV), QString(\"TestVendor:TestLibrary:TestComponent:1.0\"));\r\n    QCOMPARE(rootItem->childCount(), 2);\r\n\r\n    QTreeWidgetItem* configuredDesign = rootItem->child(0);\r\n    QCOMPARE(configuredDesign->text(HierarchicalSaveColumns::VLNV), QString(\"TestVendor:TestLibrary:TestDesign:1.0\"));\r\n    QCOMPARE(configuredDesign->childCount(), 0);\r\n\r\n    QTreeWidgetItem* otherDesignItem = rootItem->child(1);\r\n    QCOMPARE(otherDesignItem->text(HierarchicalSaveColumns::VLNV), \r\n        QString(\"TestVendor:TestLibrary:TestDesign:2.1\"));\r\n    QCOMPARE(otherDesignItem->childCount(), 0);\r\n\r\n    delete rootObject;\r\n    delete rootItem;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_HierarchicalSaveBuildStrategy::testCheckingIsRecursive()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_HierarchicalSaveBuildStrategy::testCheckingIsRecursive()\r\n{\r\n    QObject* rootObject = new QObject(0);\r\n    rootObject->setObjectName(\"TestVendor:TestLibrary:TestComponent:1.0\");\r\n    rootObject->setProperty(\"VLNVType\", \"Component\");\r\n\r\n    QObject* designObject = new QObject(rootObject);\r\n    designObject->setObjectName(\"TestVendor:TestLibrary:TestDesign:1.0\");\r\n    designObject->setProperty(\"VLNVType\", \"Design\");\r\n\r\n    QObject* otherDesign = new QObject(rootObject);\r\n    otherDesign->setObjectName(\"TestVendor:TestLibrary:TestDesign:2.1\");\r\n    otherDesign->setProperty(\"VLNVType\", \"Design\");\r\n\r\n    QTreeWidgetItem* rootItem = buildFrom(rootObject);\r\n    QCOMPARE(rootItem->childCount(), 2);\r\n\r\n    rootItem->setData(HierarchicalSaveColumns::SAVE_AS_VLNV, Qt::CheckStateRole, Qt::Unchecked);\r\n    QCOMPARE(rootItem->child(0)->checkState(HierarchicalSaveColumns::SAVE_AS_VLNV), Qt::Unchecked);\r\n    QCOMPARE(rootItem->child(1)->checkState(HierarchicalSaveColumns::SAVE_AS_VLNV), Qt::Unchecked);\r\n\r\n    rootItem->setData(HierarchicalSaveColumns::SAVE_AS_VLNV, Qt::CheckStateRole, Qt::Checked);\r\n    QCOMPARE(rootItem->child(0)->checkState(HierarchicalSaveColumns::SAVE_AS_VLNV), Qt::Checked);\r\n    QCOMPARE(rootItem->child(1)->checkState(HierarchicalSaveColumns::SAVE_AS_VLNV), Qt::Checked);\r\n\r\n    delete rootObject;\r\n    delete rootItem;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_HierarchicalSaveBuildStrategy::testItemCannotBeCheckedIfParentNotChecked()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_HierarchicalSaveBuildStrategy::testItemCannotBeCheckedIfParentNotChecked()\r\n{\r\n    QObject* rootObject = new QObject(0);\r\n    rootObject->setObjectName(\"TestVendor:TestLibrary:TestComponent:1.0\");\r\n    rootObject->setProperty(\"VLNVType\", \"Component\");\r\n\r\n    QObject* designObject = new QObject(rootObject);\r\n    designObject->setObjectName(\"TestVendor:TestLibrary:TestDesign:1.0\");\r\n    designObject->setProperty(\"VLNVType\", \"Design\");\r\n\r\n    QTreeWidgetItem* rootItem = buildFrom(rootObject);\r\n\r\n    rootItem->setData(HierarchicalSaveColumns::SAVE_AS_VLNV, Qt::CheckStateRole, Qt::Unchecked);\r\n\r\n    QTreeWidgetItem* childItem = rootItem->child(0);\r\n    childItem->setData(HierarchicalSaveColumns::SAVE_AS_VLNV, Qt::CheckStateRole, Qt::Checked);\r\n\r\n    QCOMPARE(childItem->checkState(HierarchicalSaveColumns::SAVE_AS_VLNV), Qt::Unchecked);\r\n\r\n    delete rootObject;\r\n    delete rootItem;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_HierarchicalSaveBuildStrategy::buildFrom()\r\n//-----------------------------------------------------------------------------\r\nQTreeWidgetItem* tst_HierarchicalSaveBuildStrategy::buildFrom(QObject* rootObject)\r\n{\r\n    HierarchicalSaveBuildStrategy strategy(library_);\r\n    return strategy.build(rootObject);\r\n}\r\n\r\nQTEST_MAIN(tst_HierarchicalSaveBuildStrategy)\r\n\r\n#include \"tst_HierarchicalSaveBuildStrategy.moc\"\r\n"
  },
  {
    "path": "tests/Core/tst_HierarchicalSaveBuildStrategy.pri",
    "content": "# ----------------------------------------------------\r\n# This file is generated by the Qt Visual Studio Add-in.\r\n# ------------------------------------------------------\r\n\r\nHEADERS += ../../mainwindow/SaveHierarchy/SaveAsItem.h \\\r\n    ../../mainwindow/SaveHierarchy/HierarchicalSaveBuildStrategy.h \\\r\n    ../MockObjects/LibraryMock.h \\\r\n    ../../mainwindow/SaveHierarchy/HierarchicalSaveColumns.h\r\nSOURCES += ../../mainwindow/SaveHierarchy/HierarchicalSaveBuildStrategy.cpp \\\r\n    ../MockObjects/LibraryMock.cpp \\\r\n    ../../mainwindow/SaveHierarchy/SaveAsItem.cpp \\\r\n    ./tst_HierarchicalSaveBuildStrategy.cpp\r\n"
  },
  {
    "path": "tests/Core/tst_HierarchicalSaveBuildStrategy.pro",
    "content": "#-----------------------------------------------------------------------------\r\n# File: unittest.pro\r\n#-----------------------------------------------------------------------------\r\n# Project: Kactus 2\r\n# Author: Esko Pekkarinen\r\n# Date: 20.05.2015\r\n#\r\n# Description:\r\n# Qt project file template for running unit tests for HierarchicalSaveBuildStrategy.\r\n#-----------------------------------------------------------------------------\r\n\r\nTEMPLATE = app\r\n\r\nTARGET = tst_HierarchicalSaveBuildStrategy\r\n\r\nQT += core xml gui testlib widgets\r\nCONFIG += c++11 testcase console\r\n\r\nQMAKE_EXPORTED_VARIABLES += MAKE_TESTARGS\r\nMAKE_TESTARGS.name = TESTARGS\r\nMAKE_TESTARGS.value = \"-platform offscreen\"\r\n\r\nwin32:CONFIG(release, debug|release) {\r\n    LIBS += -L$$PWD/../../executable/ -lIPXACTmodels\r\n    DESTDIR = ./release\r\n}\r\nelse:win32:CONFIG(debug, debug|release) {\r\n    LIBS += -L$$PWD/../../executable/ -lIPXACTmodelsd\r\n    DESTDIR = ./debug\r\n}\r\nelse:unix {\r\n    LIBS += -L$$PWD/../../executable/ -lIPXACTmodels\r\n    DESTDIR = ./release\r\n}\r\n\r\nINCLUDEPATH += $$DESTDIR\r\nINCLUDEPATH += ../../\r\n\r\nDEPENDPATH += .\r\nDEPENDPATH += ../../\r\n\r\nOBJECTS_DIR += $$DESTDIR\r\n\r\nMOC_DIR += ./generatedFiles\r\nUI_DIR += ./generatedFiles\r\nRCC_DIR += ./generatedFiles\r\ninclude(tst_HierarchicalSaveBuildStrategy.pri)\r\n"
  },
  {
    "path": "tests/Core/tst_IPXactSystemVerilogParser.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: tst_IPXactSystemVerilogParser.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Esko Pekkarinen\r\n// Date: 02.12.2014\r\n//\r\n// Description:\r\n// Unit test for class IPXactSystemVerilogParser.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include <QtTest>\r\n#include <QSharedPointer>\r\n\r\n#include <KactusAPI/include/IPXactSystemVerilogParser.h>\r\n\r\n#include <KactusAPI/include/ComponentParameterFinder.h>\r\n#include <KactusAPI/include/ParameterCache.h>\r\n\r\n#include <IPXACTmodels/Component/AddressBlock.h>\r\n#include <IPXACTmodels/Component/BusInterface.h>\r\n#include <IPXACTmodels/Component/Component.h>\r\n#include <IPXACTmodels/Component/MemoryMap.h>\r\n#include <IPXACTmodels/Component/MemoryBlockBase.h>\r\n#include <IPXACTmodels/Component/Model.h>\r\n#include <IPXACTmodels/Component/Register.h>\r\n\r\n#include <IPXACTmodels/common/Parameter.h>\r\n\r\n\r\nclass tst_IPXactSystemVerilogParser : public QObject\r\n{\r\n    Q_OBJECT\r\n\r\npublic:\r\n    tst_IPXactSystemVerilogParser();\r\n\r\nprivate slots:\r\n\r\n    void testParseConstant();\r\n    void testParseConstant_data();\r\n\r\n    void testExpressionWithUnknownReference();\r\n    void testParameterWithoutId();\r\n    void testParameterWithGeneratedId();\r\n\r\n    void testExpressionWithParameterReferences();\r\n    void testExpressionWithParameterReferences_data();\r\n\r\n    void testExpressionWithRegisterParameterReferences();\r\n    void testExpressionWithRegisterParameterReferences_data();\r\n\r\n    void testExpressionWithBusInterfaceParameterReferences();\r\n    void testExpressionWithBusInterfaceParameterReferences_data();\r\n\r\n    void testParameterDefinedUsingOtherParameter();\r\n    void testParameterDefinedUsingOtherParameter_data();\r\n\r\n    void testLoopTerminatesEventually();\r\n\r\n    void testReferenceToStringInExpression();\r\n\r\n    void testGetBaseForExpression();\r\n\r\n    void testExpressionWithRealValueParameterReferences();\r\n    void testExpressionWithRealValueParameterReferences_data();\r\n\r\n    void testExpressionComparison();\r\n    void testExpressionComparison_data();\r\n\r\n    void testLongReferenceChainPerformance();\r\n    void testLongReferenceChainPerformance_data();\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_IPXactSystemVerilogParser::tst_IPXactSystemVerilogParser()\r\n//-----------------------------------------------------------------------------\r\ntst_IPXactSystemVerilogParser::tst_IPXactSystemVerilogParser()\r\n{\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_IPXactSystemVerilogParser::testParseConstant()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_IPXactSystemVerilogParser::testParseConstant()\r\n{   \r\n    QFETCH(QString, expression);\r\n    QFETCH(QString, expectedResult);\r\n    QFETCH(bool, expectedValid);\r\n\r\n    QSharedPointer<Component> emptyComponent(new Component(VLNV(), Document::Revision::Std14));\r\n\r\n    IPXactSystemVerilogParser parser(QSharedPointer<ParameterFinder>(new ComponentParameterFinder(emptyComponent)));\r\n\r\n    bool valid = false;\r\n    QString result = parser.parseExpression(expression, &valid);\r\n\r\n    QCOMPARE(valid, expectedValid);\r\n    if (expectedValid)\r\n    {\r\n        QCOMPARE(result, expectedResult);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_IPXactSystemVerilogParser::testParseConstant_data()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_IPXactSystemVerilogParser::testParseConstant_data()\r\n{\r\n    QTest::addColumn<QString>(\"expression\");\r\n    QTest::addColumn<QString>(\"expectedResult\");\r\n    QTest::addColumn<bool>(\"expectedValid\");\r\n\r\n    QTest::newRow(\"Boolean true is valid\") << \"true\" << \"1\" << true;\r\n    QTest::newRow(\"Boolean false is valid\") << \"false\" << \"0\" << true;\r\n\r\n    QTest::newRow(\"Decimal value 1 is valid\") << \"1\" << \"1\" << true;\r\n\r\n    QTest::newRow(\"Hexadecimal value 0xff is invalid\") << \"0xff\" << \"x\" << false;\r\n    QTest::newRow(\"Hexadecimal value #ff is invalid\") << \"#ff\" << \"x\" << false;\r\n    QTest::newRow(\"Hexadecimal value ff is invalid\") << \"ff\" << \"x\" << false;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_IPXactSystemVerilogParser::testExpressionWithUnknownReference()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_IPXactSystemVerilogParser::testExpressionWithUnknownReference()\r\n{\r\n    QSharedPointer<Component> emptyComponent(new Component(VLNV(), Document::Revision::Std14));\r\n\r\n    IPXactSystemVerilogParser parser(QSharedPointer<ParameterFinder>(new ComponentParameterFinder(emptyComponent)));\r\n\r\n    QCOMPARE(parser.parseExpression(QString(\"unknownParameter\")), QString(\"x\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_IPXactSystemVerilogParser::testParameterWithoutId()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_IPXactSystemVerilogParser::testParameterWithoutId()\r\n{\r\n    QSharedPointer<Component> testComponent(new Component(VLNV(), Document::Revision::Std14));\r\n    QSharedPointer<Parameter> firstParameter(new Parameter());\r\n    firstParameter->setValueId(\"\");\r\n    firstParameter->setValue(\"1\");\r\n    testComponent->getParameters()->append(firstParameter);\r\n\r\n    IPXactSystemVerilogParser parser(QSharedPointer<ParameterFinder>(new ComponentParameterFinder(testComponent)));\r\n\r\n    QCOMPARE(parser.parseExpression(QString(\"unknownParameter\")), QString(\"x\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_IPXactSystemVerilogParser::testParameterWithGeneratedId()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_IPXactSystemVerilogParser::testParameterWithGeneratedId()\r\n{\r\n    QSharedPointer<Component> testComponent(new Component(VLNV(), Document::Revision::Std14));\r\n    QSharedPointer<Parameter> firstParameter(new Parameter());\r\n    firstParameter->setValue(\"1\");\r\n    testComponent->getParameters()->append(firstParameter);\r\n\r\n    IPXactSystemVerilogParser parser(QSharedPointer<ParameterFinder>(new ComponentParameterFinder(testComponent)));\r\n\r\n    QCOMPARE(parser.isPlainValue(firstParameter->getValueId()), false);\r\n    QCOMPARE(parser.parseExpression(firstParameter->getValueId()), QString(\"1\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_IPXactSystemVerilogParser::testExpressionWithParameterReferences()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_IPXactSystemVerilogParser::testExpressionWithParameterReferences()\r\n{\r\n    QFETCH(QString, expression);\r\n    QFETCH(QString, expectedResult);\r\n    QFETCH(bool, expectedValid);\r\n\r\n    QSharedPointer<Component> testComponent(new Component(VLNV(), Document::Revision::Std14));\r\n    QSharedPointer<Parameter> firstParameter(new Parameter());\r\n    firstParameter->setValueId(\"one\");\r\n    firstParameter->setValue(\"1\");\r\n    testComponent->getParameters()->append(firstParameter);\r\n\r\n    QSharedPointer<Parameter> secondParameter(new Parameter());\r\n    secondParameter->setValueId(\"two\");\r\n    secondParameter->setValue(\"2\");\r\n    testComponent->getParameters()->append(secondParameter);\r\n\r\n    IPXactSystemVerilogParser parser(QSharedPointer<ParameterFinder>(new ComponentParameterFinder(testComponent)));\r\n    \r\n    bool valid = false;\r\n    QString result = parser.parseExpression(expression, &valid);\r\n\r\n    QCOMPARE(valid, expectedValid);\r\n    if (expectedValid)\r\n    {\r\n        QCOMPARE(result, expectedResult);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_IPXactSystemVerilogParser::testExpressionWithParameterReferences_data()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_IPXactSystemVerilogParser::testExpressionWithParameterReferences_data()\r\n{\r\n    QTest::addColumn<QString>(\"expression\");\r\n    QTest::addColumn<QString>(\"expectedResult\");\r\n    QTest::addColumn<bool>(\"expectedValid\");\r\n\r\n    QTest::newRow(\"Parameter value only\") << \"one\" << \"1\" << true;\r\n    QTest::newRow(\"Parameter value plus constant decimal\") << \"one + 1\" << \"2\" << true;\r\n    QTest::newRow(\"Parameter value plus parameter value\") << \"one + one\" << \"2\" << true;\r\n    QTest::newRow(\"Parameter value multiplied\") << \"4*one\" << \"4\" << true;\r\n\r\n    QTest::newRow(\"Parameter value negated\") << \"~one\" << \"-2\" << true;\r\n\r\n    QTest::newRow(\"Reference to unknown parameter\") << \"unknown\" << \"x\"  << false;\r\n    QTest::newRow(\"Parameter value plus unknown parameter value\") << \"one + unknown\" << \"x\" << false;\r\n\r\n    QTest::newRow(\"Two parameters\") << \"one + two\" << \"3\"  << true;\r\n    QTest::newRow(\"Clog2 of parameter\") << \"$clog2(two)+1\" << \"2\"  << true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_IPXactSystemVerilogParser::testExpressionWithRegisterParameterReferences()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_IPXactSystemVerilogParser::testExpressionWithRegisterParameterReferences()\r\n{\r\n    QFETCH(QString, expression);\r\n    QFETCH(QString, expectedResult);\r\n    QFETCH(bool, expectedValid);\r\n\r\n    QSharedPointer<Component> testComponent(new Component(VLNV(), Document::Revision::Std14));\r\n\r\n    QSharedPointer<MemoryMap> memoryMap(new MemoryMap());\r\n    testComponent->getMemoryMaps()->append(memoryMap);\r\n\r\n    QSharedPointer<AddressBlock> addressBlock(new AddressBlock());\r\n    memoryMap->getMemoryBlocks()->append(addressBlock);\r\n\r\n    QSharedPointer<Parameter> firstParameter(new Parameter());\r\n    firstParameter->setValueId(\"one\");\r\n    firstParameter->setValue(\"1\");\r\n\r\n    QSharedPointer<Register> register1(new Register());\r\n    register1->getParameters()->append(firstParameter);\r\n    addressBlock->getRegisterData()->append(register1);\r\n\r\n    QSharedPointer<Parameter> secondParameter(new Parameter());\r\n    secondParameter->setValueId(\"two\");\r\n    secondParameter->setValue(\"2\");\r\n\r\n    QSharedPointer<Register> register2(new Register());    \r\n    register2->getParameters()->append(secondParameter);\r\n\r\n    addressBlock->getRegisterData()->append(register2);\r\n\r\n    IPXactSystemVerilogParser parser(QSharedPointer<ParameterFinder>(new ComponentParameterFinder(testComponent)));\r\n    \r\n    bool valid = false;\r\n    QString result = parser.parseExpression(expression, &valid);\r\n\r\n    QCOMPARE(valid, expectedValid);\r\n    if (expectedValid)\r\n    {\r\n        QCOMPARE(result, expectedResult);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_IPXactSystemVerilogParser::testExpressionWithRegisterParameterReferences_data()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_IPXactSystemVerilogParser::testExpressionWithRegisterParameterReferences_data()\r\n{\r\n    testExpressionWithParameterReferences_data();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_IPXactSystemVerilogParser::testExpressionWithBusInterfaceParameterReferences()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_IPXactSystemVerilogParser::testExpressionWithBusInterfaceParameterReferences()\r\n{\r\n    QFETCH(QString, expression);\r\n    QFETCH(QString, expectedResult);\r\n    QFETCH(bool, expectedValid);\r\n\r\n    QSharedPointer<Component> testComponent(new Component(VLNV(), Document::Revision::Std14));\r\n    QSharedPointer<Parameter> firstParameter(new Parameter());\r\n    firstParameter->setValueId(\"one\");\r\n    firstParameter->setValue(\"1\");\r\n\r\n    QSharedPointer<Parameter> secondParameter(new Parameter());\r\n    secondParameter->setValueId(\"two\");\r\n    secondParameter->setValue(\"2\");\r\n\r\n    QSharedPointer<BusInterface> busInterface1(new BusInterface());\r\n    busInterface1->getParameters()->append(firstParameter);\r\n    testComponent->getBusInterfaces()->append(busInterface1);\r\n\r\n    QSharedPointer<BusInterface> busInterface2(new BusInterface());\r\n    busInterface2->setName(\"busIf\");\r\n    busInterface2->getParameters()->append(secondParameter);\r\n    testComponent->getBusInterfaces()->append(busInterface2);\r\n\r\n    IPXactSystemVerilogParser parser(QSharedPointer<ParameterFinder>(new ComponentParameterFinder(testComponent)));\r\n\r\n    bool valid = false;\r\n    QString result = parser.parseExpression(expression, &valid);\r\n\r\n    QCOMPARE(valid, expectedValid);\r\n    if (expectedValid)\r\n    {\r\n        QCOMPARE(result, expectedResult);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_IPXactSystemVerilogParser::testExpressionWithBusInterfaceParameterReferences_data()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_IPXactSystemVerilogParser::testExpressionWithBusInterfaceParameterReferences_data()\r\n{\r\n    testExpressionWithParameterReferences_data();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_IPXactSystemVerilogParser::testParameterDefinedUsingOtherParameter()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_IPXactSystemVerilogParser::testParameterDefinedUsingOtherParameter()\r\n{\r\n    QFETCH(QString, expression);\r\n    QFETCH(QString, expectedResult);\r\n\r\n    QSharedPointer<Component> testComponent(new Component(VLNV(), Document::Revision::Std14));\r\n    QSharedPointer<Parameter> firstParameter(new Parameter());\r\n    firstParameter->setValueId(\"first\");\r\n    firstParameter->setValue(\"1\");\r\n    testComponent->getParameters()->append(firstParameter);\r\n\r\n    QSharedPointer<Parameter> secondParameter(new Parameter());\r\n    secondParameter->setValueId(\"second\");\r\n    secondParameter->setValue(\"2*first\");\r\n    testComponent->getParameters()->append(secondParameter);\r\n\r\n    QSharedPointer<Parameter> thirdParameter(new Parameter());\r\n    thirdParameter->setValueId(\"third\");\r\n    thirdParameter->setValue(\"second**second\");\r\n    testComponent->getParameters()->append(thirdParameter);\r\n\r\n    IPXactSystemVerilogParser parser(QSharedPointer<ParameterFinder>(new ComponentParameterFinder(testComponent)));\r\n\r\n    QCOMPARE(parser.parseExpression(expression), QString(expectedResult));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_IPXactSystemVerilogParser::testParameterDefinedUsingOtherParameter_data()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_IPXactSystemVerilogParser::testParameterDefinedUsingOtherParameter_data()\r\n{\r\n    QTest::addColumn<QString>(\"expression\");\r\n    QTest::addColumn<QString>(\"expectedResult\");\r\n\r\n    QTest::newRow(\"Parameter defined using other parameter\") << \"second\" << \"2\";\r\n    QTest::newRow(\"Parameter value is evaluated before other operations\") << \"second**3\" << \"8\";\r\n    QTest::newRow(\"Expressions in parameter values are evaluated before further evaluation\") << \"third\" << \"4\";\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_IPXactSystemVerilogParser::testLoopTerminatesEventually()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_IPXactSystemVerilogParser::testLoopTerminatesEventually()\r\n{\r\n    QSharedPointer<Component> testComponent(new Component(VLNV(), Document::Revision::Std14));\r\n    QSharedPointer<Parameter> firstParameter(new Parameter());\r\n    firstParameter->setValueId(\"first\");\r\n    firstParameter->setValue(\"second\");\r\n    testComponent->getParameters()->append(firstParameter);\r\n\r\n    QSharedPointer<Parameter> secondParameter(new Parameter());\r\n    secondParameter->setValueId(\"second\");\r\n    secondParameter->setValue(\"first\");\r\n    testComponent->getParameters()->append(secondParameter);\r\n\r\n    IPXactSystemVerilogParser parser(QSharedPointer<ParameterFinder>(new ComponentParameterFinder(testComponent)));\r\n\r\n    QTRY_COMPARE_WITH_TIMEOUT(parser.parseExpression(QString(\"second\")), QString(\"x\"), 3000);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_IPXactSystemVerilogParser::testReferenceToString()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_IPXactSystemVerilogParser::testReferenceToStringInExpression()\r\n{\r\n    QSharedPointer<Component> testComponent(new Component(VLNV(), Document::Revision::Std14));\r\n    QSharedPointer<Parameter> firstParameter(new Parameter());\r\n    firstParameter->setValueId(\"first\");\r\n    firstParameter->setValue(\"\\\"text\\\"\");\r\n    testComponent->getParameters()->append(firstParameter);\r\n\r\n    QSharedPointer<Parameter> secondParameter(new Parameter());\r\n    secondParameter->setValueId(\"second\");\r\n    secondParameter->setValue(\"first + 2\");\r\n    testComponent->getParameters()->append(secondParameter);\r\n\r\n    IPXactSystemVerilogParser parser(QSharedPointer<ParameterFinder>(new ComponentParameterFinder(testComponent)));\r\n\r\n    QCOMPARE(parser.parseExpression(QString(\"first\")), QString(\"\\\"text\\\"\"));\r\n    QCOMPARE(parser.parseExpression(QString(\"second\")), QString(\"x\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_IPXactSystemVerilogParser::testGetBaseForExpression()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_IPXactSystemVerilogParser::testGetBaseForExpression()\r\n{\r\n    QSharedPointer<Component> testComponent(new Component(VLNV(), Document::Revision::Std14));\r\n    QSharedPointer<Parameter> firstParameter(new Parameter());\r\n    firstParameter->setValueId(\"first\");\r\n    firstParameter->setValue(\"'h1\");\r\n    testComponent->getParameters()->append(firstParameter);\r\n\r\n    IPXactSystemVerilogParser parser(QSharedPointer<ParameterFinder>(new ComponentParameterFinder(testComponent)));\r\n\r\n    QCOMPARE(parser.baseForExpression(QString(\"2*first\")), 16);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_IPXactSystemVerilogParser::testExpressionWithRealParameterReferences()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_IPXactSystemVerilogParser::testExpressionWithRealValueParameterReferences()\r\n{\r\n    QFETCH(QString, expression);\r\n    QFETCH(QString, expectedResult);\r\n\r\n    QSharedPointer<Component> testComponent(new Component(VLNV(), Document::Revision::Std14));\r\n    QSharedPointer<Parameter> firstParameter(new Parameter());\r\n    firstParameter->setValueId(\"firstValue\");\r\n    firstParameter->setValue(\"30\");\r\n    testComponent->getParameters()->append(firstParameter);\r\n\r\n    QSharedPointer<Parameter> secondParameter(new Parameter());\r\n    secondParameter->setValueId(\"secondValue\");\r\n    secondParameter->setValue(\"0.751\");\r\n    testComponent->getParameters()->append(secondParameter);\r\n\r\n    IPXactSystemVerilogParser parser(QSharedPointer<ParameterFinder>(new ComponentParameterFinder(testComponent)));\r\n\r\n    QCOMPARE(parser.parseExpression(expression), expectedResult);   \r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_IPXactSystemVerilogParser::testExpressionWithRealParameterReferences_data()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_IPXactSystemVerilogParser::testExpressionWithRealValueParameterReferences_data()\r\n{\r\n    QTest::addColumn<QString>(\"expression\");\r\n    QTest::addColumn<QString>(\"expectedResult\");\r\n\r\n    QTest::newRow(\"Two parameters multiplication, integer and floating point\") <<\r\n        \"firstValue * secondValue\" << \"22.530\";\r\n    QTest::newRow(\"Parameters division, integer and floating point\") << \"firstValue / secondValue\" << \"39\";\r\n    QTest::newRow(\"Parameters addition, integer and floating point\") << \"firstValue + secondValue\" << \"30.751\";\r\n    QTest::newRow(\"Parameters subtraction, integer and floating point\") << \"firstValue - secondValue\" << \"29.249\";\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_IPXactSystemVerilogParser::testExpressionComparison()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_IPXactSystemVerilogParser::testExpressionComparison()\r\n{\r\n    QFETCH(QString, valueOne);\r\n    QFETCH(QString, valueTwo);\r\n    QFETCH(QString, expression);\r\n    QFETCH(int, expectedResult);\r\n\r\n    QSharedPointer<Component> testComponent(new Component(VLNV(), Document::Revision::Std14));\r\n    QSharedPointer<Parameter> firstParameter(new Parameter());\r\n    firstParameter->setValueId(\"firstValue\");\r\n    firstParameter->setValue(valueOne);\r\n    testComponent->getParameters()->append(firstParameter);\r\n\r\n    QSharedPointer<Parameter> secondParameter(new Parameter());\r\n    secondParameter->setValueId(\"secondValue\");\r\n    secondParameter->setValue(valueTwo);\r\n    testComponent->getParameters()->append(secondParameter);\r\n\r\n    IPXactSystemVerilogParser parser(QSharedPointer<ParameterFinder>(new ComponentParameterFinder(testComponent)));\r\n\r\n    QCOMPARE(parser.parseExpression(expression).toInt(), expectedResult);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_IPXactSystemVerilogParser::testExpressionComparison_data()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_IPXactSystemVerilogParser::testExpressionComparison_data()\r\n{\r\n    QTest::addColumn<QString>(\"valueOne\");\r\n    QTest::addColumn<QString>(\"valueTwo\");\r\n    QTest::addColumn<QString>(\"expression\");\r\n    QTest::addColumn<int>(\"expectedResult\");\r\n\r\n    QTest::newRow(\"Value 1 is greater than value 2 returns 1\") << \"10\" << \"4*2\" << \"firstValue > secondValue\" << 1;\r\n    QTest::newRow(\"Value 2 is greater than value 1 returns 0\") << \"10\" << \"4*2\" << \"secondValue > firstValue\" << 0;\r\n\r\n    QTest::newRow(\"Value 1 is lesser than value 2 returns 0\") << \"10\" << \"4*2\" << \"firstValue < secondValue\" << 0;\r\n    QTest::newRow(\"Value 2 is lesser than value 1 returns 1\") << \"10\" << \"4*2\" << \"secondValue < firstValue\" << 1;\r\n\r\n    QTest::newRow(\"Value 1 + value 2 is greater than value 1 returns 1\") << \"10\" << \"4*2\" <<\r\n        \"firstValue + secondValue > firstValue\" << 1;\r\n    QTest::newRow(\"Value 1 + value 2 is lesser than value 1 returns 0\") << \"10\" << \"4*2\" <<\r\n        \"firstValue + secondValue < firstValue\" << 0;\r\n\r\n    QTest::newRow(\"Single value: 10 is equal to 10 returns 1\") << \"10\" << \"10\" << \"firstValue==secondValue\" << 1;\r\n    QTest::newRow(\"Single value: 10 is equal to 2 returns 0\") << \"10\" << \"2\" << \"firstValue==secondValue\" << 0;\r\n\r\n    QTest::newRow(\"Expression: 10+2 is equal to 2*6 returns 1\") <<  \"10\" << \"2\" <<\r\n        \"firstValue+secondValue==secondValue*6\" << 1;\r\n    QTest::newRow(\"Expression: 10+2+1 is equal to 2*6 returns 0\") << \"10\" << \"2\" <<\r\n        \"firstValue+secondValue+1==secondValue*2\" << 0;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_IPXactSystemVerilogParser::testLongReferenceChainPerformance()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_IPXactSystemVerilogParser::testLongReferenceChainPerformance()\r\n{\r\n    QFETCH(int, chainLength);\r\n    QFETCH(bool, useCache);\r\n\r\n    QSharedPointer<Component> testComponent(new Component(VLNV(), Document::Revision::Std14));\r\n\r\n    QSharedPointer<Parameter> firstParameter(new Parameter());\r\n    firstParameter->setValueId(\"id_0\");\r\n    firstParameter->setValue(\"0\");\r\n    testComponent->getParameters()->append(firstParameter);\r\n\r\n    for (int i = 1; i <= chainLength; i++)\r\n    {\r\n        QSharedPointer<Parameter> nextParamter(new Parameter());\r\n        nextParamter->setValueId(\"id_\" + QString::number(i));\r\n        nextParamter->setValue(QString(\"id_%1 + 1\").arg(i-1));\r\n        testComponent->getParameters()->append(nextParamter);\r\n    }\r\n\r\n    QSharedPointer<ParameterFinder> finder;\r\n    if (useCache)\r\n    {\r\n        finder = QSharedPointer<ParameterFinder>(new ParameterCache(testComponent));\r\n    }\r\n    else\r\n    {\r\n        finder = QSharedPointer<ParameterFinder>(new ComponentParameterFinder(testComponent));\r\n    }\r\n\r\n    IPXactSystemVerilogParser parser(QSharedPointer<ParameterFinder>(new ComponentParameterFinder(testComponent)));\r\n\r\n    QBENCHMARK\r\n    {\r\n        QTRY_COMPARE(parser.parseExpression(QString(\"id_%1\").arg(chainLength)).toInt(), chainLength);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_IPXactSystemVerilogParser::testLongReferenceChainPerformance_data()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_IPXactSystemVerilogParser::testLongReferenceChainPerformance_data()\r\n{\r\n    QTest::addColumn<int>(\"chainLength\");\r\n    QTest::addColumn<bool>(\"useCache\");\r\n\r\n    QTest::newRow(\"Chain of 1 parameter, no cache\") << 1 << false;\r\n    QTest::newRow(\"Chain of 1 parameter, cached\") << 1 << true;\r\n\r\n    QTest::newRow(\"Chain of 5 parameters, no cache\") << 5 << false;\r\n    QTest::newRow(\"Chain of 5 parameters, cached\") << 5 << true;\r\n\r\n    QTest::newRow(\"Chain of 20 parameters, no cache\") << 20 << false;\r\n    QTest::newRow(\"Chain of 20 parameters, cached\") << 20 << true;\r\n}\r\n\r\nQTEST_MAIN(tst_IPXactSystemVerilogParser)\r\n\r\n#include \"tst_IPXactSystemVerilogParser.moc\"\r\n"
  },
  {
    "path": "tests/Core/tst_IPXactSystemVerilogParser.pri",
    "content": "# ----------------------------------------------------\r\n# This file is generated by the Qt Visual Studio Add-in.\r\n# ------------------------------------------------------\r\n\r\nSOURCES += ./tst_IPXactSystemVerilogParser.cpp\r\n"
  },
  {
    "path": "tests/Core/tst_IPXactSystemVerilogParser.pro",
    "content": "#-----------------------------------------------------------------------------\r\n# File: tst_IPXactSystemVerilogParser.pro\r\n#-----------------------------------------------------------------------------\r\n# Project: Kactus 2\r\n# Author: Esko Pekkarinen\r\n# Date: 02.12.2014\r\n#\r\n# Description:\r\n# Qt project file template for running unit tests for IPXactSystemVerilogParser.\r\n#-----------------------------------------------------------------------------\r\n\r\nTEMPLATE = app\r\n\r\nTARGET = tst_IPXactSystemVerilogParser\r\n\r\nQT += core xml testlib\r\nQT -= gui widgets\r\nCONFIG += c++11 testcase console\r\n\r\nwin32:CONFIG(release, debug|release) {\r\n    LIBS += -L$$PWD/../../executable/ -lIPXACTmodels -lKactusAPI\r\n    DESTDIR = ./release\r\n}\r\nelse:win32:CONFIG(debug, debug|release) {\r\n    LIBS += -L$$PWD/../../executable/ -lIPXACTmodelsd -lKactusAPId\r\n    DESTDIR = ./debug\r\n}\r\nelse:unix {\r\n    LIBS += -L$$PWD/../../executable/ -lIPXACTmodels -lKactusAPI\r\n    DESTDIR = ./release\r\n}\r\n\r\nINCLUDEPATH += $$PWD/../../\r\nINCLUDEPATH += $$PWD/../../executable\r\nINCLUDEPATH += $$DESTDIR\r\n\r\nDEPENDPATH += $$PWD/../../\r\nDEPENDPATH += $$PWD/../../executable\r\nDEPENDPATH += .\r\n\r\nOBJECTS_DIR += $$DESTDIR\r\n\r\nMOC_DIR += ./generatedFiles\r\nUI_DIR += ./generatedFiles\r\nRCC_DIR += ./generatedFiles\r\ninclude(tst_IPXactSystemVerilogParser.pri)\r\n"
  },
  {
    "path": "tests/Core/tst_MarkdownGenerator.cpp",
    "content": "#include <QtTest>\n\n#include <kactusGenerators/DocumentGenerator/documentgenerator.h>\n\n#include <tests/MockObjects/LibraryMock.h>\n#include <tests/MockObjects/DesignWidgetFactoryMock.h>\n#include <tests/MockObjects/HWDesignWidgetMock.h>\n\n#include <KactusAPI/include/ExpressionFormatterFactoryImplementation.h>\n\n#include <KactusAPI/include/utils.h>\n\n#include <IPXACTmodels/Component/BusInterface.h>\n#include <IPXACTmodels/Component/Component.h>\n#include <IPXACTmodels/Component/FileSet.h>\n#include <IPXACTmodels/Component/Model.h>\n#include <IPXACTmodels/Component/Port.h>\n#include <IPXACTmodels/Component/PortMap.h>\n#include <IPXACTmodels/Component/View.h>\n#include <IPXACTmodels/Component/MemoryMap.h>\n#include <IPXACTmodels/Component/AddressBlock.h>\n#include <IPXACTmodels/Component/Register.h>\n#include <IPXACTmodels/Component/Field.h>\n#include <IPXACTmodels/Component/RegisterFile.h>\n#include <IPXACTmodels/Component/EnumeratedValue.h>\n\n#include <IPXACTmodels/Design/Design.h>\n\n#include <IPXACTmodels/common/Parameter.h>\n#include <IPXACTmodels/common/VLNV.h>\n\n#include <QWidget>\n#include <QList>\n\nclass tst_MarkdownGenerator : public QObject\n{\n    Q_OBJECT\n\npublic:\n    tst_MarkdownGenerator();\n\nprivate slots:\n    void initTestCase();\n    void cleanupTestCase();\n    void init();\n    void cleanup();\n\n    void testInvalidVlnvInConstructor();\n\n    void testFileHeaderIsWritten();\n    void testTableOfContentsIsWrittenWithOnlyTopComponent();\n\n    void testAttributesWrittenWithOnlyTopComponent();\n    void testParametersWrittenWithOnlyTopComponent();\n\n    void testMemoryMapsWrittenWithTopComponent();\n    void testAddressBlocksWrittenWithTopComponent();\n    void testExpressionsInAddressBlocks();\n    void testRegistersWrittenWithTopComponent();\n    void testAddressBlockRegisterFilesWrittenWithTopComponent();\n    void testFieldsWrittenWithTopComponent();\n    void testMemoryMapToFieldWrittenWithTopComponent();\n\n    void testPortsWrittenWithOnlyTopComponent();\n\n    void testBusInterfacesWrittenWithoutPorts();\n\n    void testFileSetsWrittenForTopComponent();\n\n    void testViewsWrittenForTopComponent();\n\n    void testDesignIsWritten();\n\n    void testEndOfDocumentWrittenForTopComponent();\n\nprivate:\n    /*!\n        *  Create the generator used in most test cases.\n        */\n    DocumentGenerator* createTestGenerator();\n\n    /*!\n        *  Read the output file of the generator.\n        */\n    void readOutputFile();\n\n    /*!\n        *  Compare expected output to the actual output\n        */\n    void checkOutputFile(QString const& expectedOutput);\n\n    /*!\n        *  Create a parameter used in the tests.\n        *\n        *      @param [in] name            Name of the parameter.\n        *      @param [in] value           Value of the parameter.\n        *      @param [in] description     Description of the parameter.\n        *      @param [in] uuID            Id of the parameter.\n        */\n    QSharedPointer<Parameter> createTestParameter(QString const& name, QString const& value,\n        QString const& description, QString const& uuID, QString const& arrayLeft, QString const& arrayRight);\n\n    /*!\n        *  Create a port used in the tests.\n        *\n        *      @param [in] name            Name of the port.\n        *      @param [in] leftBound       The left bound of the port.\n        *      @param [in] rightBound      The right bound of the port.\n        *      @param [in] defaultValue    The default value of the port.\n        */\n    QSharedPointer<Port> createTestPort(QString const& name, QString const& leftBound, QString const& rightBound,\n        QString const& defaultValue, QString const& arrayLeft, QString const& arrayRight);\n\n    /*!\n        *  Create a map for configurable element values.\n        *\n        *      @param [in] component   The component, whose configurable element values are being created.\n        */\n    QList<QSharedPointer<ConfigurableElementValue> > createConfigurableElementvalues(QSharedPointer <Component> component);\n\n    QSharedPointer<Field> createTestField(QString const& name, QString const& description, QString const& offset,\n        QString const& width);\n\n    QSharedPointer<Register> createTestRegister(QString const& name, QString const& offset, QString const& size,\n        QString const& dimension, QString const& description);\n\n    QSharedPointer<AddressBlock> createTestAddressBlock(QString const& name, QString const& description,\n        QString const& baseAddress, QString const& range, QString const& width,\n        QList <QSharedPointer <Register> > registers);\n\n    QSharedPointer<AddressBlock> createAddressBlockWithRegisterData(QString const& name, QString const& description,\n        QString const& baseAddress, QString const& range, QString const& width,\n        QList <QSharedPointer <RegisterBase> > registerData);\n\n    QSharedPointer<MemoryMap> createTestMemoryMap(QString const& name, QString const& description,\n        int addressUnitbits, QList<QSharedPointer <AddressBlock> > addressBlocks);\n\n    //! Get the string used to describe a space.\n    QString getSpaceString();\n\n    //! Get the string used to describe a table.\n    QString getTableString();\n\n    //! Get the string used to describe the encoding.\n    QString getEncodingString();\n\n    //! Get the string used to describe the document type.\n    QString getDoctypeString();\n\n    //! Get the string used to describe valid w3c strict.\n    QString getValidW3CStrictString();\n\n    QSharedPointer<Component> topComponent_;\n\n    VLNV topComponentVlnv_;\n\n    QString output_;\n\n    QDateTime generationTime_;\n\n    LibraryMock library_;\n\n    DesignWidgetFactoryMock designWidgetFactory_;\n\n    ExpressionFormatterFactoryImplementation expressionFormatterFactory_;\n\n    QString targetPath_;\n\n    QWidget* generatorParentWidget_;\n};\n\ntst_MarkdownGenerator::tst_MarkdownGenerator() :\n    topComponent_(),\n    topComponentVlnv_(),\n    output_(),\n    generationTime_(),\n    library_(this),\n    designWidgetFactory_(&library_),\n    expressionFormatterFactory_(),\n    targetPath_(\"./generatorOutput.md\"),\n    generatorParentWidget_(new QWidget)\n{\n}\n\nvoid tst_MarkdownGenerator::initTestCase()\n{\n    topComponentVlnv_ = VLNV(VLNV::COMPONENT, \"Test\", \"TestLibrary\", \"TestComponent\", \"1.0\");\n}\n\nvoid tst_MarkdownGenerator::cleanupTestCase()\n{\n}\n\nvoid tst_MarkdownGenerator::init()\n{\n    topComponent_ = QSharedPointer<Component>(new Component(topComponentVlnv_, Document::Revision::Std14));\n    library_.clear();\n\n    QVERIFY(!QFile::exists(targetPath_));\n}\n\nvoid tst_MarkdownGenerator::cleanup()\n{\n    topComponent_.clear();\n    output_.clear();\n\n    QFile::remove(targetPath_);\n}\n\nvoid tst_MarkdownGenerator::testInvalidVlnvInConstructor()\n{\n    VLNV invalidVlnv(VLNV::COMPONENT, \"invalid\", \"library\", \"component\", \"0\");\n    \n    DocumentGenerator generator(&library_, invalidVlnv, &designWidgetFactory_,\n        &expressionFormatterFactory_, 1, generatorParentWidget_);\n    \n    QSignalSpy spy(&generator, SIGNAL(errorMessage(QString const&)));\n    \n    QFile targetFile(targetPath_);\n    targetFile.open(QFile::WriteOnly);\n    QTextStream stream(&targetFile);\n    \n    generator.writeDocumentation(stream, targetPath_);\n    \n    targetFile.close();\n\n    QCOMPARE(spy.count(), 1);\n    QCOMPARE(spy.takeFirst().at(0).toString(), QString(\"VLNV was not found in the library.\"));\n}\n\nvoid tst_MarkdownGenerator::testFileHeaderIsWritten()\n{\n    QCoreApplication::setOrganizationName(\"TUT\");\n    QCoreApplication::setApplicationName(\"TestRunner\");\n    QSettings settings;\n    settings.setValue(\"General/Username\", \"testUser\");\n\n    QScopedPointer<DocumentGenerator> generator(createTestGenerator());\n\n    QFile targetFile(targetPath_);\n    targetFile.open(QFile::WriteOnly);\n    QTextStream stream(&targetFile);\n\n    generationTime_ = QDateTime::currentDateTime();\n\n    generator->writeHeader(stream);\n    targetFile.close();\n\n    QString expectedOutput(\n        \"###### This document was generated by Kactus2 on \" +\n        generationTime_.toString(\"dd.MM.yyyy hh:mm:ss\") + \" by user testUser  \\n\"\n        \"\\n\"\n    );\n\n    checkOutputFile(expectedOutput);\n}\n\nvoid tst_MarkdownGenerator::testTableOfContentsIsWrittenWithOnlyTopComponent()\n{\n    QList <QSharedPointer<Parameter> > componentParameters;\n    QSharedPointer<Parameter> parameter = createTestParameter(\"parameter\", \"1\", \"\", \"P-ID\", \"\", \"\");\n    componentParameters.append(parameter);\n\n    QList <QSharedPointer <Register> > registers;\n    QSharedPointer <Register> testRegister = createTestRegister(\"register\", \"1\", \"1\", \"1\", \"\");\n    QSharedPointer <Field> testField = createTestField(\"field\", \"\", \"1\", \"8\");\n    testRegister->getFields()->append(testField);\n    registers.append(testRegister);\n\n    QList <QSharedPointer <AddressBlock> > addressBlocks;\n    QSharedPointer <AddressBlock> testAddressBlock = createTestAddressBlock(\"addressBlock\", \"\", \"'h0\", \"4\", \"32\",\n        registers);\n    addressBlocks.append(testAddressBlock);\n\n    QList <QSharedPointer <MemoryMap> > memoryMaps;\n    QSharedPointer<MemoryMap> testMemoryMap = createTestMemoryMap(\"memoryMap\", \"\", 8, addressBlocks);\n    memoryMaps.append(testMemoryMap);\n\n    QSharedPointer<Port> port = createTestPort(\"port\", \"10\", \"1\", \"\", \"\", \"\");\n\n    QSharedPointer<BusInterface> busInterface(new BusInterface());\n    busInterface->setName(\"busInterface\");\n\n    QSharedPointer<FileSet> fileset(new FileSet(\"fileSet\"));\n\n    QSharedPointer<View> view(new View(\"view\"));\n\n    topComponent_->getParameters()->append(componentParameters);\n    topComponent_->getPorts()->append(port);\n    topComponent_->getBusInterfaces()->append(busInterface);\n    topComponent_->getFileSets()->append(fileset);\n    topComponent_->getViews()->append(view);\n    topComponent_->getMemoryMaps()->append(memoryMaps);\n\n    QScopedPointer<DocumentGenerator> generator(createTestGenerator());\n\n    QFile targetFile(targetPath_);\n    targetFile.open(QFile::WriteOnly);\n    QTextStream stream(&targetFile);\n\n    generator->writeTableOfContents(stream);\n\n    targetFile.close();\n    \n    QString expectedOutput(\n        \"1. [Component \" + topComponent_->getVlnv().getVendor() + \" - \" + topComponent_->getVlnv().getLibrary() +\n        \" - \" + topComponent_->getVlnv().getName() + \" - \" + topComponent_->getVlnv().getVersion() + \"]\" +\n        \"(#\" + topComponent_->getVlnv().toString() + \")  \" + \"\\n\"\n\n        \"\\t\" + \"1.1. [Kactus2 attributes](#\" + topComponent_->getVlnv().toString() + \".attributes)\" + \"  \" + \"\\n\" +\n        \"\\t\" + \"1.2. [General parameters](#\" + topComponent_->getVlnv().toString() + \".parameters)\" + \"  \" + \"\\n\" +\n        \"\\t\" + \"1.3. [Memory maps](#\" + topComponent_->getVlnv().toString() + \".memoryMaps)\" + \"  \" + \"\\n\" +\n        \"\\t\" + \"1.4. [Ports](#\" + topComponent_->getVlnv().toString() + \".ports)\" + \"  \" + \"\\n\" +\n        \"\\t\" + \"1.5. [Bus interfaces](#\" + topComponent_->getVlnv().toString() + \".interfaces)\" + \"  \" + \"\\n\" +\n        \"\\t\" + \"1.6. [File sets](#\" + topComponent_->getVlnv().toString() + \".fileSets)\" + \"  \" + \"\\n\" +\n        \"\\t\" + \"1.7. [Views](#\" + topComponent_->getVlnv().toString() + \".views)\" + \"  \" + \"\\n\"\n    );\n\n    checkOutputFile(expectedOutput);\n}\n\nvoid tst_MarkdownGenerator::testAttributesWrittenWithOnlyTopComponent()\n{\n    topComponent_->setHierarchy(KactusAttribute::FLAT);\n    topComponent_->setImplementation(KactusAttribute::SW);\n    topComponent_->setFirmness(KactusAttribute::FIXED);\n\n    QScopedPointer<DocumentGenerator> generator(createTestGenerator());\n\n    int subHeaderNumber = 1;\n\n    QFile targetFile(targetPath_);\n    targetFile.open(QFile::WriteOnly);\n    QTextStream stream(&targetFile);\n\n    generator->writeKactusAttributes(stream, subHeaderNumber);\n\n    targetFile.close();\n\n    QString expectedOutput(\n        \"## 1.1 Kactus2 attributes <a id=\\\"\" + topComponent_->getVlnv().toString() + \".attributes\\\">  \\n\"\n        \"\\n\"\n        \"**Product hierarchy:** Flat  \\n\"\n        \"**Component implementation:** SW  \\n\"\n        \"**Component firmness:** Fixed  \\n\"\n        \"\\n\"\n    );\n\n    checkOutputFile(expectedOutput);\n}\n\nvoid tst_MarkdownGenerator::testParametersWrittenWithOnlyTopComponent()\n{\n    QSharedPointer <Parameter> parameter = createTestParameter(\"parameter\", \"10\", \"Description\", \"ID_parameter\",\n        \"1\", \"0\");\n    QSharedPointer <Parameter> refParameter = createTestParameter(\"refParameter\", \"ID_parameter\", \"Describe this\",\n        \"ID-refer\", \"\", \"\");\n\n    topComponent_->getParameters()->append(parameter);\n    topComponent_->getParameters()->append(refParameter);\n\n    QScopedPointer<DocumentGenerator> generator(createTestGenerator());\n\n    QFile targetFile(targetPath_);\n    targetFile.open(QFile::WriteOnly);\n    QTextStream stream(&targetFile);\n\n    int subHeaderNumber = 2;\n    \n    generator->writeParameters(stream, subHeaderNumber);\n\n    targetFile.close();\n\n    QString vlnvString(topComponent_->getVlnv().toString());\n\n    QString expectedOutput(\n        \"## 1.2 General parameters <a id=\\\"\" + vlnvString + \".parameters\\\">  \\n\"\n        \"\\n\"\n        \"|Name|Type|Value|Resolve|Bit vector left|Bit vector right|Array left|Array right|Description|  \\n\"\n        \"|:----|:----|:----|:----|:----|:----|:----|:----|:----|  \\n\"\n        \"|\" + parameter->name() + \"|\" + parameter->getType() + \"|\" +\n            parameter->getValue() + \"|\" + parameter->getValueResolve()  + \"|\" +\n            parameter->getVectorLeft() + \"|\" + parameter->getVectorRight() + \"|\" +\n            parameter->getArrayLeft() + \"|\" + parameter->getArrayRight() + \"|\" +\n            parameter->description() + \"|  \\n\"\n        \"|\" + refParameter->name() + \"|\" + \"\" + \"|\" +\n            \"parameter\" + \"|\" + \"\" + \"|\" +\n            \"\" + \"|\" + \"\" + \"|\" +\n            \"\" + \"|\" + \"\" + \"|\" +\n            refParameter->description() + \"|  \\n\"\n    );\n\n    checkOutputFile(expectedOutput);\n}\n\nvoid tst_MarkdownGenerator::testMemoryMapsWrittenWithTopComponent()\n{\n    QList <QSharedPointer <AddressBlock> > addressBlocks;\n\n    QSharedPointer<MemoryMap> memoryMap = createTestMemoryMap(\"memoryMap\", \"example Description\", 8, addressBlocks);\n\n    topComponent_->getMemoryMaps()->append(memoryMap);\n\n    QScopedPointer<DocumentGenerator> generator(createTestGenerator());\n\n    QFile targetFile(targetPath_);\n    targetFile.open(QFile::WriteOnly);\n    QTextStream stream(&targetFile);\n\n    int subHeaderNumber = 1;\n\n    generator->writeMemoryMaps(stream, subHeaderNumber);\n\n    targetFile.close();\n\n    QString expectedOutput(\n        \"## 1.1 Memory maps <a id=\\\"\" + topComponent_->getVlnv().toString() + \".memoryMaps\\\">  \\n\"\n        \"\\n\"\n        \"### 1.1.1 Memory map \" + memoryMap->name() + \"  \\n\"\n        \"\\n\"\n        \"**Description:** \" + memoryMap->description() + \"  \\n\"\n        \"\\n\"\n        \"**Address unit bits (AUB):** \" + memoryMap->getAddressUnitBits() + \"  \\n\"\n        \"\\n\"\n    );\n\n    checkOutputFile(expectedOutput);\n}\n\nvoid tst_MarkdownGenerator::testAddressBlocksWrittenWithTopComponent()\n{\n    QList <QSharedPointer <Register> > registers;\n    QSharedPointer <Register> testRegister = createTestRegister(\"register\", \"4\", \"2\", \"2\", \"\");\n    QSharedPointer <Register> testRegister2 = createTestRegister(\"register2\", \"8\", \"16\", \"2\", \"\");\n    registers.append(testRegister);\n    registers.append(testRegister2);\n\n    QList <QSharedPointer <AddressBlock> > addressBlocks;\n    QSharedPointer <AddressBlock> testAddressBlock = createTestAddressBlock(\"addressBlock\", \"example\", \"'h0\", \"4\",\n        \"32\", registers);\n    addressBlocks.append(testAddressBlock);\n\n    QScopedPointer<DocumentGenerator> generator(createTestGenerator());\n\n    QFile targetFile(targetPath_);\n    targetFile.open(QFile::WriteOnly);\n    QTextStream stream(&targetFile);\n\n    int subHeaderNumber = 1;\n\n    generator->writeAddressBlocks(addressBlocks, stream, subHeaderNumber, subHeaderNumber);\n\n    targetFile.close();\n\n    QString expectedOutput(\n        \"### 1.1.1.1 Address block \" + testAddressBlock->name() + \"  \\n\"\n        \"\\n\"\n        \"**Description:** \" + testAddressBlock->description() + \"  \\n\"\n        \"**Usage:** \" + General::usage2Str(testAddressBlock->getUsage()) + \"  \\n\"\n        \"**Base address [AUB]:** \" + testAddressBlock->getBaseAddress() + \"  \\n\"\n        \"**Range [AUB]:** \" + testAddressBlock->getRange() + \"  \\n\"\n        \"**Width [AUB]:** \" + testAddressBlock->getWidth() + \"  \\n\"\n        \"**Access:** \" + AccessTypes::access2Str(testAddressBlock->getAccess()) + \"  \\n\"\n        \"**Volatile:** \" + testAddressBlock->getVolatile() + \"  \\n\"\n        \"\\n\"\n        \"#### Address block '\" + testAddressBlock->name() + \"' contains the following registers:  \\n\"\n        \"\\n\"\n        \"|Register name|Offset [AUB]|Size [bits]|Dimension|Volatile|Access|  \\n\"\n        \"|:----|:----|:----|:----|:----|:----|  \\n\"\n        \"|\" + testRegister->name() +\n            \"|\" + testRegister->getAddressOffset() +\n            \"|\" + testRegister->getSize() +\n            \"|\" + testRegister->getDimension() +\n            \"|\" + testRegister->getVolatile() +\n            \"|\" + AccessTypes::access2Str(testRegister->getAccess()) + \"|  \\n\"\n        \"|\" + testRegister2->name() +\n            \"|\" + testRegister2->getAddressOffset() +\n            \"|\" + testRegister2->getSize() +\n            \"|\" + testRegister2->getDimension() +\n            \"|\" + testRegister2->getVolatile() +\n            \"|\" + AccessTypes::access2Str(testRegister2->getAccess()) + \"|  \\n\"\n    );\n\n    checkOutputFile(expectedOutput);\n}\n\nvoid tst_MarkdownGenerator::testExpressionsInAddressBlocks()\n{\n    QSharedPointer <Parameter> targetParameter = createTestParameter(\"target\", \"4\", \"\", \"ID_TARGET\", \"\", \"\");\n\n    QList <QSharedPointer <AddressBlock> > addressBlocks;\n    QSharedPointer <AddressBlock> testAddressBlock = createTestAddressBlock(\"addressBlock\", \"example\", \"'h0\",\n        \"ID_TARGET\", \"ID_TARGET + 2\", QList <QSharedPointer <Register> >());\n    addressBlocks.append(testAddressBlock);\n\n    topComponent_->getParameters()->append(targetParameter);\n\n    QScopedPointer<DocumentGenerator> generator(createTestGenerator());\n\n    QFile targetFile(targetPath_);\n    targetFile.open(QFile::WriteOnly);\n    QTextStream stream(&targetFile);\n\n    int subHeaderNumber = 1;\n\n    generator->writeAddressBlocks(addressBlocks, stream, subHeaderNumber, subHeaderNumber);\n\n    targetFile.close();\n\n    QString expectedOutput(\n        \"### 1.1.1.1 Address block \" + testAddressBlock->name() + \"  \\n\"\n        \"\\n\"\n        \"**Description:** \" + testAddressBlock->description() + \"  \\n\"\n        \"**Usage:** \" + General::usage2Str(testAddressBlock->getUsage()) + \"  \\n\"\n        \"**Base address [AUB]:** 'h0  \\n\"\n        \"**Range [AUB]:** target  \\n\"\n        \"**Width [AUB]:** target + 2  \\n\"\n        \"**Access:** \" + AccessTypes::access2Str(testAddressBlock->getAccess()) + \"  \\n\"\n        \"**Volatile:** \" + testAddressBlock->getVolatile() + \"  \\n\"\n        \"\\n\"\n    );\n\n    checkOutputFile(expectedOutput);\n}\n\nvoid tst_MarkdownGenerator::testRegistersWrittenWithTopComponent()\n{\n    QList <QSharedPointer <Register> > registers;\n    QSharedPointer <Register> testRegister = createTestRegister(\"register\", \"4\", \"2\", \"2\", \"exampleDescription\");\n    registers.append(testRegister);\n\n    QScopedPointer<DocumentGenerator> generator(createTestGenerator());\n\n    QFile targetFile(targetPath_);\n    targetFile.open(QFile::WriteOnly);\n    QTextStream stream(&targetFile);\n\n    int subHeaderNumber = 1;\n\n    generator->writeRegisters(registers, stream, subHeaderNumber, subHeaderNumber, subHeaderNumber, subHeaderNumber);\n\n    targetFile.close();\n\n    QString expectedOutput(\n        \"### 1.1.1.1.1 Register \" + testRegister->name() + \"  \\n\"\n        \"\\n\"\n        \"**Description:** \" + testRegister->description() + \"  \\n\"\n        \"**Offset [AUB]:** \" + testRegister->getAddressOffset() + \"  \\n\"\n        \"**Size [bits]:** \" + testRegister->getSize() + \"  \\n\"\n        \"**Dimension:** \" + testRegister->getDimension() + \"  \\n\"\n        \"**Volatile:** \" + testRegister->getVolatile() + \"  \\n\"\n        \"**Access:** \" + AccessTypes::access2Str(testRegister->getAccess()) + \"  \\n\"\n        \"\\n\"\n    );\n\n    checkOutputFile(expectedOutput);\n}\n\nvoid tst_MarkdownGenerator::testAddressBlockRegisterFilesWrittenWithTopComponent()\n{\n    QSharedPointer<RegisterFile> testRegisterFileParent(new RegisterFile(\"testRegisterFileParent\", \"8\", \"16\"));\n    QSharedPointer<RegisterFile> testRegisterFileChild(new RegisterFile(\"testRegisterFileChild\", \"64\", \"512\"));\n\n    testRegisterFileParent->setDescription(\"Register file description\");\n\n    QSharedPointer<Register> registerInParentRegisterFile = createTestRegister(\"testRegister\", \"4\", \"2\", \"0\", \"example description\");\n    QSharedPointer<Register> registerInChildRegisterFile = createTestRegister(\"testRegister2\", \"8\", \"2\", \"0\", \"example description2\");\n\n    QSharedPointer<QList <QSharedPointer<RegisterBase> > > childRegisterData(new QList<QSharedPointer<RegisterBase> >({ registerInChildRegisterFile }));\n    testRegisterFileChild->setRegisterData(childRegisterData);\n\n    QSharedPointer<QList <QSharedPointer<RegisterBase> > > parentRegisterData(new QList<QSharedPointer<RegisterBase> >({ testRegisterFileChild, registerInParentRegisterFile }));\n    testRegisterFileParent->setRegisterData(parentRegisterData);\n\n    QSharedPointer<QList<QSharedPointer<RegisterBase> > >addressBlockRegisterData(new QList < QSharedPointer<RegisterBase> >({ testRegisterFileParent }));\n    auto testAddressBlock = createAddressBlockWithRegisterData(\"testAddressBlock\", \"address block description\", \"'h0\", \"4\", \"32\", *addressBlockRegisterData);\n\n    QList <QSharedPointer <AddressBlock> > addressBlocks;\n    addressBlocks.append(testAddressBlock);\n\n    QScopedPointer<DocumentGenerator> generator(createTestGenerator());\n\n    QFile targetFile(targetPath_);\n    targetFile.open(QFile::WriteOnly);\n    QTextStream stream(&targetFile);\n\n    int subHeaderNumber = 1;\n\n    generator->writeAddressBlocks(addressBlocks, stream, subHeaderNumber, subHeaderNumber);\n\n    targetFile.close();\n\n    QString expectedOutput(\n        \"### 1.1.1.1 Address block testAddressBlock  \\n\"\n        \"\\n\"\n        \"**Description:** \" + testAddressBlock->description() + \"  \\n\"\n        \"**Usage:** \" + General::usage2Str(testAddressBlock->getUsage()) + \"  \\n\"\n        \"**Base address [AUB]:** 'h0  \\n\"\n        \"**Range [AUB]:** 4  \\n\"\n        \"**Width [AUB]:** 32  \\n\"\n        \"**Access:** \" + AccessTypes::access2Str(testAddressBlock->getAccess()) + \"  \\n\"\n        \"**Volatile:** \" + testAddressBlock->getVolatile() + \"  \\n\"\n        \"\\n\"\n        \"#### Address block 'testAddressBlock' contains the following register files:  \\n\"\n        \"\\n\"\n        \"### 1.1.1.1.1 Register file testRegisterFileParent  \\n\"\n        \"\\n\"\n        \"**Description:** Register file description  \\n\"\n        \"**Offset [AUB]:** 8  \\n\"\n        \"**Range [AUB]:** 16  \\n\"\n        \"**Dimension:**   \\n\"\n        \"\\n\"\n        \"#### Register file testRegisterFileParent contains the following registers:  \\n\"\n        \"\\n\"\n        \"|Register name|Offset [AUB]|Size [bits]|Dimension|Volatile|Access|  \\n\"\n        \"|:----|:----|:----|:----|:----|:----|  \\n\"\n        \"|\" + registerInParentRegisterFile->name() +\n        \"|\" + registerInParentRegisterFile->getAddressOffset() +\n        \"|\" + registerInParentRegisterFile->getSize() +\n        \"|\" + registerInParentRegisterFile->getDimension() +\n        \"|\" + registerInParentRegisterFile->getVolatile() +\n        \"|\" + AccessTypes::access2Str(registerInParentRegisterFile->getAccess()) + \"|  \\n\"\n        \"### 1.1.1.1.1.1 Register testRegister  \\n\"\n        \"\\n\"\n        \"**Description:** \" + registerInParentRegisterFile->description() + \"  \\n\"\n        \"**Offset [AUB]:** \" + registerInParentRegisterFile->getAddressOffset() + \"  \\n\"\n        \"**Size [bits]:** \" + registerInParentRegisterFile->getSize() + \"  \\n\"\n        \"**Dimension:** \" + registerInParentRegisterFile->getDimension() + \"  \\n\"\n        \"**Volatile:** \" + registerInParentRegisterFile->getVolatile() + \"  \\n\"\n        \"**Access:** \" + AccessTypes::access2Str(registerInParentRegisterFile->getAccess()) + \"  \\n\"\n        \"\\n\"\n        \"### 1.1.1.1.1.2 Register file testRegisterFileChild  \\n\"\n        \"\\n\"\n        \"**Description:**   \\n\"\n        \"**Offset [AUB]:** 64  \\n\"\n        \"**Range [AUB]:** 512  \\n\"\n        \"**Dimension:**   \\n\"\n        \"\\n\"\n        \"#### Register file testRegisterFileChild contains the following registers:  \\n\"\n        \"\\n\"\n        \"|Register name|Offset [AUB]|Size [bits]|Dimension|Volatile|Access|  \\n\"\n        \"|:----|:----|:----|:----|:----|:----|  \\n\"\n        \"|\" + registerInChildRegisterFile->name() +\n        \"|\" + registerInChildRegisterFile->getAddressOffset() +\n        \"|\" + registerInChildRegisterFile->getSize() +\n        \"|\" + registerInChildRegisterFile->getDimension() +\n        \"|\" + registerInChildRegisterFile->getVolatile() +\n        \"|\" + AccessTypes::access2Str(registerInChildRegisterFile->getAccess()) + \"|  \\n\"\n        \"### 1.1.1.1.1.2.1 Register testRegister2  \\n\"\n        \"\\n\"\n        \"**Description:** \" + registerInChildRegisterFile->description() + \"  \\n\"\n        \"**Offset [AUB]:** \" + registerInChildRegisterFile->getAddressOffset() + \"  \\n\"\n        \"**Size [bits]:** \" + registerInChildRegisterFile->getSize() + \"  \\n\"\n        \"**Dimension:** \" + registerInChildRegisterFile->getDimension() + \"  \\n\"\n        \"**Volatile:** \" + registerInChildRegisterFile->getVolatile() + \"  \\n\"\n        \"**Access:** \" + AccessTypes::access2Str(registerInChildRegisterFile->getAccess()) + \"  \\n\"\n        \"\\n\"\n    );\n\n    checkOutputFile(expectedOutput);\n}\n\nvoid tst_MarkdownGenerator::testFieldsWrittenWithTopComponent()\n{\n    QSharedPointer<Field> testField = createTestField(\"testField\", \"Example Field\", \"2\", \"8\");\n    QSharedPointer<FieldReset> resetValue(new FieldReset());\n    resetValue->setResetValue(\"testReset\");\n    resetValue->setResetMask(\"testMask\");\n\n    testField->getResets()->append(resetValue);\n\n    QSharedPointer<QList<QSharedPointer<EnumeratedValue> > > enumerations(new QList<QSharedPointer <EnumeratedValue > >());\n    QSharedPointer<EnumeratedValue> testEnumeratedValue(new EnumeratedValue(\"testEnumeration\", \"1\"));\n    enumerations->append(testEnumeratedValue);\n    \n    testField->setEnumeratedValues(enumerations);\n\n    QSharedPointer<Register> fieldRegister = createTestRegister(\"FieldRegister\", \"10\", \"10\", \"10\", \"\");\n    fieldRegister->getFields()->append(testField);\n\n    QScopedPointer<DocumentGenerator> generator(createTestGenerator());\n\n    QFile targetFile(targetPath_);\n    targetFile.open(QFile::WriteOnly);\n    QTextStream stream(&targetFile);\n\n    generator->writeFields(fieldRegister, stream, {1, 1, 1, 1, 1});\n\n    targetFile.close();\n\n    QString expectedOutput(\n        \"#### Register '\" + fieldRegister->name() + \"' contains the following fields:  \\n\"\n        \"\\n\"\n        \"|Field name|Offset [bits]|Width [bits]|Volatile|Access|Resets|Description|  \\n\"\n        \"|:----|:----|:----|:----|:----|:----|:----|  \\n\"\n        \"|\" + testField->name() + \" <a id=\\\"\" + topComponent_->getVlnv().toString() + \n            \".field.\" + testField->name() + \"\\\">\"\n        \"|\" + testField->getBitOffset() +\n        \"|\" + testField->getBitWidth() +\n        \"|\" + testField->getVolatile().toString() +\n        \"|\" + AccessTypes::access2Str(testField->getAccess()) +\n        \"|\" + \"HARD : testReset\" +\n        \"|\" + testField->description() + \"|  \\n\"\n        \"### 1.1.1.1.1.1 Field \" + testField->name() + \"  \\n\"\n        \"\\n\"\n        \"**Offset [bits]:** \" + testField->getBitOffset() + \"  \\n\"\n        \"**Width [bits]:** \" + testField->getBitWidth() + \"  \\n\"\n        \"**Volatile:** \" + testField->getVolatile().toString() + \"  \\n\"\n        \"**Access:** \" + AccessTypes::access2Str(testField->getAccess()) + \"  \\n\"\n        \"**Resets:** HARD : testReset  \\n\"\n        \"**Description:** \" + testField->description() + \"  \\n\"\n        \"\\n\"\n        \"#### Enumerations:  \\n\"\n        \"\\n\"\n        \"|Name|Value|  \\n\"\n        \"|:----|:----|  \\n\"\n        \"|testEnumeration|1|  \\n\"\n    );\n\n    checkOutputFile(expectedOutput);\n}\n\nvoid tst_MarkdownGenerator::testMemoryMapToFieldWrittenWithTopComponent()\n{\n    QSharedPointer<Field> testField = createTestField(\"testField\", \"\", \"2\", \"8\");\n    QSharedPointer<FieldReset> resetValue(new FieldReset());\n    resetValue->setResetValue(\"8'h3\");\n    resetValue->setResetMask(\"00000011\");\n\n    testField->getResets()->append(resetValue);\n\n    QList <QSharedPointer <Register> > registers;\n    QSharedPointer<Register> testRegister = createTestRegister(\"testRegister\", \"10\", \"4\", \"2\", \"Describing reg.\");\n    testRegister->getFields()->append(testField);\n    registers.append(testRegister);\n\n    QList <QSharedPointer <AddressBlock> > addressBlocks;\n    QSharedPointer <AddressBlock> testAddressBlock = createTestAddressBlock(\"testAddress\", \"Describe.\", \"'h0\", \"4\",\n        \"32\", registers);\n    addressBlocks.append(testAddressBlock);\n\n    QList <QSharedPointer <MemoryMap> > memoryMaps;\n    QSharedPointer <MemoryMap> testMemoryMap = createTestMemoryMap(\"testMemoryMap\", \"\", 8, addressBlocks);\n    memoryMaps.append(testMemoryMap);\n\n    topComponent_->getMemoryMaps()->append(memoryMaps);\n\n    QScopedPointer<DocumentGenerator> generator(createTestGenerator());\n\n    QFile targetFile(targetPath_);\n    targetFile.open(QFile::WriteOnly);\n    QTextStream stream(&targetFile);\n\n    int subHeaderNumber = 1;\n\n    generator->writeMemoryMaps(stream, subHeaderNumber);\n\n    targetFile.close();\n\n    QString vlnvString(topComponent_->getVlnv().toString());\n\n    QString expectedOutput(\n        \"## 1.1 Memory maps <a id=\\\"\" + vlnvString + \".memoryMaps\\\">  \\n\"\n        \"\\n\"\n        \"### 1.1.1 Memory map \" + testMemoryMap->name() + \"  \\n\"\n        \"\\n\"\n        \"**Address unit bits (AUB):** \" + testMemoryMap->getAddressUnitBits() + \"  \\n\"\n        \"\\n\"\n        \"### 1.1.1.1 Address block \" + testAddressBlock->name() + \"  \\n\"\n        \"\\n\"\n        \"**Description:** \" + testAddressBlock->description() + \"  \\n\"\n        \"**Usage:** \" + General::usage2Str(testAddressBlock->getUsage()) + \"  \\n\"\n        \"**Base address [AUB]:** \" + testAddressBlock->getBaseAddress() + \"  \\n\"\n        \"**Range [AUB]:** \" + testAddressBlock->getRange() + \"  \\n\"\n        \"**Width [AUB]:** \" + testAddressBlock->getWidth() + \"  \\n\"\n        \"**Access:** \" + AccessTypes::access2Str(testAddressBlock->getAccess()) + \"  \\n\"\n        \"**Volatile:** \" + testAddressBlock->getVolatile() + \"  \\n\"\n        \"\\n\"\n        \"#### Address block '\" + testAddressBlock->name() + \"' contains the following registers:  \\n\"\n        \"\\n\"\n        \"|Register name|Offset [AUB]|Size [bits]|Dimension|Volatile|Access|  \\n\"\n        \"|:----|:----|:----|:----|:----|:----|  \\n\"\n        \"|\" + testRegister->name() +\n        \"|\" + testRegister->getAddressOffset() +\n        \"|\" + testRegister->getSize() +\n        \"|\" + testRegister->getDimension() +\n        \"|\" + testRegister->getVolatile() +\n        \"|\" + AccessTypes::access2Str(testRegister->getAccess()) + \"|  \\n\"\n        \"### 1.1.1.1.1 Register \" + testRegister->name() + \"  \\n\"\n        \"\\n\"\n        \"**Description:** \" + testRegister->description() + \"  \\n\"\n        \"**Offset [AUB]:** \" + testRegister->getAddressOffset() + \"  \\n\"\n        \"**Size [bits]:** \" + testRegister->getSize() + \"  \\n\"\n        \"**Dimension:** \" + testRegister->getDimension() + \"  \\n\"\n        \"**Volatile:** \" + testRegister->getVolatile() + \"  \\n\"\n        \"**Access:** \" + AccessTypes::access2Str(testRegister->getAccess()) + \"  \\n\"\n        \"\\n\"\n        \"#### Register '\" + testRegister->name() + \"' contains the following fields:  \\n\"\n        \"\\n\"\n        \"|Field name|Offset [bits]|Width [bits]|Volatile|Access|Resets|Description|  \\n\"\n        \"|:----|:----|:----|:----|:----|:----|:----|  \\n\"\n        \"|\" + testField->name() + \" <a id=\\\"\" + topComponent_->getVlnv().toString() +\n        \".field.\" + testField->name() + \"\\\">\"\n        \"|\" + testField->getBitOffset() +\n        \"|\" + testField->getBitWidth() +\n        \"|\" + testField->getVolatile().toString() +\n        \"|\" + AccessTypes::access2Str(testField->getAccess()) +\n        \"|\" + \"HARD : 8'h3\" +\n        \"|\" + testField->description() + \"|  \\n\"\n    );\n\n    checkOutputFile(expectedOutput);\n}\n\nvoid tst_MarkdownGenerator::testPortsWrittenWithOnlyTopComponent()\n{\n    QList <QSharedPointer <Parameter> > componentParameters;\n    QSharedPointer <Parameter> parameter = createTestParameter(\"parameter\", \"10\", \"Description\", \"ID_parameter\",\n        \"\", \"\");\n    componentParameters.append(parameter);\n\n    QSharedPointer <Port> portRef = createTestPort(\"portRef\", \"ID_parameter\", \"4\", \"ID_parameter\", \"2\",\n        \"ID_parameter\");\n\n    topComponent_->getPorts()->append(portRef);\n\n    topComponent_->getParameters()->append(componentParameters);\n\n    QScopedPointer<DocumentGenerator> generator(createTestGenerator());\n\n    QFile targetFile(targetPath_);\n    targetFile.open(QFile::WriteOnly);\n    QTextStream stream(&targetFile);\n\n    int subHeaderNumber = 1;\n\n    generator->writePorts(stream, subHeaderNumber);\n\n    targetFile.close();\n\n    QString expectedOutput(\n        \"## 1.1 Ports <a id=\\\"\" + topComponent_->getVlnv().toString() + \".ports\\\">  \\n\"\n        \"\\n\"\n        \"|Name|Direction|Left bound|Right bound|Port type|Type definition|Default value|\"\n        \"Array left|Array right|Description|  \\n\"\n        \"|:----|:----|:----|:----|:----|:----|:----|:----|:----|:----|  \\n\"\n        \"|\" + portRef->name() + \" <a id=\\\"\" + topComponent_->getVlnv().toString() + \".port.\"\n        + portRef->name() + \"\\\">\" +\n        \"|\" + DirectionTypes::direction2Str(portRef->getDirection()) +\n        \"|\" + \"parameter\" +\n        \"|\" + portRef->getRightBound() +\n        \"|\" + portRef->getTypeName() +\n        \"|\" + portRef->getTypeDefinition(portRef->getTypeName()) +\n        \"|\" + \"parameter\" +\n        \"|\" + portRef->getArrayLeft() +\n        \"|\" + \"parameter\" +\n        \"|\" + portRef->description() + \"|  \\n\"\n    );\n\n    checkOutputFile(expectedOutput);\n}\n\nvoid tst_MarkdownGenerator::testBusInterfacesWrittenWithoutPorts()\n{\n    QSharedPointer <BusInterface> busInterface(new BusInterface);\n    busInterface->setName(\"interface\");\n    busInterface->setInterfaceMode(General::MASTER);\n\n    QSharedPointer <BusInterface> busInterfaceWithSystemMode(new BusInterface);\n    busInterfaceWithSystemMode->setName(\"interface2\");\n    busInterfaceWithSystemMode->setInterfaceMode(General::SYSTEM);\n    busInterfaceWithSystemMode->setSystem(\"systemGroup\");\n\n    VLNV firstVlnv(VLNV::COMPONENT, \"Test\", \"TestLibrary\", \"FirstComponent\", \"1.0\");\n    QSharedPointer<ConfigurableVLNVReference> absDefVlnv(new ConfigurableVLNVReference(firstVlnv));\n\n    QSharedPointer<AbstractionType> absDef(new AbstractionType);\n    absDef->setAbstractionRef(absDefVlnv);\n\n    VLNV secondVlnv(VLNV::COMPONENT, \"Test\", \"TestLibrary\", \"SecondComponent\", \"1.0\");\n    QSharedPointer<ConfigurableVLNVReference> absDefVlnv2(new ConfigurableVLNVReference(secondVlnv));\n\n    QSharedPointer<AbstractionType> absDef2(new AbstractionType);\n    absDef2->setAbstractionRef(absDefVlnv2);\n\n    QSharedPointer<QList<QSharedPointer<AbstractionType> > > abstractionDefs(new QList<QSharedPointer<AbstractionType> >);\n    abstractionDefs->append(absDef);\n    abstractionDefs->append(absDef2);\n\n    QSharedPointer<QList<QSharedPointer<AbstractionType> > > abstractionDefs2(new QList<QSharedPointer<AbstractionType> >);\n    abstractionDefs2->append(absDef2);\n\n    busInterface->setAbstractionTypes(abstractionDefs);\n    busInterfaceWithSystemMode->setAbstractionTypes(abstractionDefs2);\n\n    VLNV firstBusDefVlnv(VLNV::COMPONENT, \"Test\", \"TestLibrary\", \"FirstBusDef\", \"1.0\");\n    ConfigurableVLNVReference busDef1(firstBusDefVlnv);\n\n    VLNV secondBusDefVlnv(VLNV::COMPONENT, \"Test\", \"TestLibrary\", \"SecondBusDef\", \"1.0\");\n    ConfigurableVLNVReference busDef2(secondBusDefVlnv);\n\n    busInterface->setBusType(busDef1);\n    busInterfaceWithSystemMode->setBusType(busDef2);\n\n    topComponent_->getBusInterfaces()->append(busInterface);\n    topComponent_->getBusInterfaces()->append(busInterfaceWithSystemMode);\n\n    QScopedPointer<DocumentGenerator> generator(createTestGenerator());\n\n    QFile targetFile(targetPath_);\n    targetFile.open(QFile::WriteOnly);\n    QTextStream stream(&targetFile);\n\n    int subHeaderNumber = 1;\n\n    generator->writeInterfaces(stream, subHeaderNumber);\n\n    targetFile.close();\n\n    QString expectedOutput(\n        \"## 1.1 Bus interfaces <a id=\\\"\" + topComponent_->getVlnv().toString() + \".interfaces\\\">  \\n\"\n        \"\\n\"\n        \"### 1.1.1 Bus interface \" + busInterface->name() + \"  \\n\"\n        \"\\n\"\n        \"**Description:**   \\n\"\n        \"**Interface mode:** \" + General::interfaceMode2Str(busInterface->getInterfaceMode()) + \"  \\n\"\n        \"**Bus definition:** Test:TestLibrary:FirstBusDef:1.0  \\n\"\n        \"**Abstraction definitions:** Test:TestLibrary:FirstComponent:1.0, Test:TestLibrary:SecondComponent:1.0  \\n\"\n        \"**Ports used in this interface:** None  \\n\"\n        \"\\n\"\n        \"### 1.1.2 Bus interface \" + busInterfaceWithSystemMode->name() + \"  \\n\"\n        \"\\n\"\n        \"**Description:**   \\n\"\n        \"**Interface mode:** system  \\n\"\n        \"**System group:** systemGroup  \\n\"\n        \"**Bus definition:** Test:TestLibrary:SecondBusDef:1.0  \\n\"\n        \"**Abstraction definitions:** Test:TestLibrary:SecondComponent:1.0  \\n\"\n        \"**Ports used in this interface:** None  \\n\"\n    );\n\n    checkOutputFile(expectedOutput);\n}\n\nvoid tst_MarkdownGenerator::testFileSetsWrittenForTopComponent()\n{\n    QScopedPointer<DocumentGenerator> generator(createTestGenerator());\n\n    QSharedPointer<FileSet> testFileSet(new FileSet);\n    testFileSet->setName(\"testFileSet\");\n    testFileSet->setDescription(\"example description\");\n    \n    QSharedPointer <QStringList> testFileSetGroups(new QStringList({ \"documentation\", \"testing\" }));\n    \n    testFileSet->setGroups(testFileSetGroups);\n\n    QSharedPointer<FileBuilder> testFileBuilder(new FileBuilder);\n    testFileBuilder->setFileType(\"vhdlSource\");\n    testFileBuilder->setCommand(\"vcom\");\n\n    QSharedPointer<File> testFile1(new File);\n    testFile1->setName(\"testFile1.vhd\");\n    testFile1->setDescription(\"a test file 1\");\n    testFile1->addFileType(\"vhdlSource\");\n    testFile1->addFileType(\"vhdlSource-87\");\n    testFile1->setLogicalName(\"testLogicalName\");\n    \n    QSharedPointer<BuildCommand> testFile1BuildCommand(new BuildCommand);\n    testFile1BuildCommand->setCommand(\"vcom\");\n    testFile1BuildCommand->setFlags(\"\");\n    testFile1->setBuildcommand(testFile1BuildCommand);\n\n    QSharedPointer<File> testFile2(new File);\n    testFile2->setName(\"testFile2.v\");\n    testFile2->setDescription(\"a test file 2\");\n    testFile2->addFileType(\"verilogSource\");\n    testFile2->addFileType(\"vhdlSource\");\n\n    QSharedPointer<BuildCommand> testFile2BuildCommand(new BuildCommand);\n    testFile2BuildCommand->setCommand(\"make\");\n    testFile2BuildCommand->setFlags(\"--verbose\");\n    testFile2->setBuildcommand(testFile2BuildCommand);\n\n    testFileSet->addFile(testFile1);\n    testFileSet->addFile(testFile2);\n\n    testFileBuilder->setFlags(\"\");\n\n    QSharedPointer<QList <QSharedPointer<FileBuilder>>> defaultFileBuilders(new QList<QSharedPointer<FileBuilder> >({ testFileBuilder }));\n    testFileSet->setDefaultFileBuilders(defaultFileBuilders);\n    topComponent_->getFileSets()->append(testFileSet);\n\n    QString testFile1AbsPath = General::getAbsolutePath(library_.getPath(topComponent_->getVlnv()), testFile1->name());\n    QString testFile1PathFromDoc = General::getRelativePath(targetPath_, testFile1AbsPath);\n    \n    QString testFile2AbsPath = General::getAbsolutePath(library_.getPath(topComponent_->getVlnv()), testFile2->name());\n    QString testFile2PathFromDoc = General::getRelativePath(targetPath_, testFile2AbsPath);\n\n    QFile targetFile(targetPath_);\n    targetFile.open(QFile::WriteOnly);\n    QTextStream stream(&targetFile);\n\n    int subHeaderNumber = 1;\n\n    generator->writeFileSets(stream, subHeaderNumber);\n\n    targetFile.close();\n\n    QString groups = testFileSet->getGroups()->join(\", \");\n\n    QString expectedOutput(\n        \"## 1.1 File sets <a id=\\\"\" + topComponent_->getVlnv().toString() + \".fileSets\\\">  \\n\"\n        \"\\n\"\n        \"### 1.1.1 File set \" + testFileSet->name() + \"  \\n\"\n        \"\\n\"\n        \"**Description:** \" + testFileSet->description() + \"  \\n\"\n        \"\\n\"\n        \"**Identifiers:** \" + groups + \"  \\n\"\n        \"\\n\"\n        \"**Default file builders:**  \\n\"\n        \"\\n\"\n        \"|File type|Command|Flags|Replace default flags|  \\n\"\n        \"|:----|:----|:----|:----|  \\n\"\n        \"|vhdlSource|vcom|||  \\n\"\n        \"#### 1.1.1.1 Files  \\n\"\n        \"\\n\"\n        \"|File name|Logical name|Build command|Build flags|Specified file types|Description|  \\n\"\n        \"|:----|:----|:----|:----|:----|:----|  \\n\"\n        \"|[\" + testFile1->name() + \"](\" + testFile1PathFromDoc + \")\"\n            \"|\" + testFile1->getLogicalName() +\n            \"|\" + testFile1->getBuildCommand()->getCommand() +\n            \"|\" + testFile1->getBuildCommand()->getFlags() +\n            \"|\" + testFile1->getFileTypeNames().join(\",<br>\") +\n            \"|\" + testFile1->getDescription() + \"|  \\n\"\n        \"|[\" + testFile2->name() + \"](\" + testFile2PathFromDoc + \")\"\n            \"|\" + testFile2->getLogicalName() +\n            \"|\" + testFile2->getBuildCommand()->getCommand() +\n            \"|\" + testFile2->getBuildCommand()->getFlags() +\n            \"|\" + testFile2->getFileTypeNames().join(\",<br>\") +\n            \"|\" + testFile2->getDescription() + \"|  \\n\"\n    );\n\n    checkOutputFile(expectedOutput);\n}\n\nvoid tst_MarkdownGenerator::testViewsWrittenForTopComponent()\n{\n    QSharedPointer<View> flatView(new View(\"testView\"));\n\n    topComponent_->getViews()->append(flatView);\n\n    VLNV firstVlnv(VLNV::COMPONENT, \"Test\", \"TestLibrary\", \"FirstComponent\", \"1.0\");\n    QSharedPointer<ConfigurableVLNVReference> instanceVLNV(new ConfigurableVLNVReference(firstVlnv));\n    QSharedPointer<ComponentInstance> firstInstance(new ComponentInstance(\"firstInstance\", instanceVLNV));\n\n    QSharedPointer<Component> refComponent = QSharedPointer<Component>(new Component(firstVlnv, Document::Revision::Std14));\n\n    QList <QSharedPointer<Parameter> > componentParameters;\n\n    QSharedPointer<Parameter> targetParameter = createTestParameter(\"firstParameter\", \"10\",\n        \"\", \"ID_TARGET\", \"\", \"\");\n\n    QSharedPointer<ModuleParameter> testModuleParameter(new ModuleParameter);\n    testModuleParameter->setName(\"testModuleParameter\");\n    testModuleParameter->setValue(\"1\");\n    testModuleParameter->setDescription(\"module param description\");\n    testModuleParameter->setDataType(\"testDataType\");\n    testModuleParameter->setType(\"int\");\n    testModuleParameter->setUsageType(\"typed\");\n\n    QSharedPointer<ComponentInstantiation> componentInstantiation(new ComponentInstantiation());\n    componentInstantiation->setName(\"testInstantiation\");\n    componentInstantiation->setLanguage(\"C\");\n    componentInstantiation->setLanguageStrictness(true);\n    componentInstantiation->setLibraryName(\"testLibrary\");\n    componentInstantiation->setPackageName(\"testPackage\");\n    componentInstantiation->setModuleName(\"testModuleName\");\n\n    componentInstantiation->getParameters()->append(targetParameter);\n    componentInstantiation->getModuleParameters()->append(testModuleParameter);\n\n    topComponent_->getComponentInstantiations()->append(componentInstantiation);\n    flatView->setComponentInstantiationRef(\"testInstantiation\");\n\n    QFile targetFile(targetPath_);\n    targetFile.open(QFile::WriteOnly);\n    QTextStream stream(&targetFile);\n\n    int subHeaderNumber = 1;\n    QStringList pictureList;\n\n    QScopedPointer<DocumentGenerator> generator(createTestGenerator());\n\n    generator->writeViews(stream, subHeaderNumber, pictureList);\n\n    targetFile.close();\n\n    QString expectedOutput(\n        \"## 1.1 Views <a id=\\\"\" + topComponent_->getVlnv().toString() + \".views\\\">  \\n\"\n        \"\\n\"\n        \"### 1.1.1 View: testView  \\n\"\n        \"\\n\"\n        \"#### 1.1.1.1 Component instantiation: testInstantiation  \\n\"\n        \"\\n\"\n        \"**Language:** C **strict**  \\n\"\n        \"\\n\"\n        \"**Library:** testLibrary  \\n\"\n        \"\\n\"\n        \"**Package:** testPackage  \\n\"\n        \"\\n\"\n        \"**Module name:** testModuleName  \\n\"\n        \"\\n\"\n        \"**Module parameters:**  \\n\"\n        \"\\n\"\n        \"|Name|Type|Value|Data type|Usage type|Resolve|Bit vector left|Bit vector right|Array left|Array right|Description|  \\n\"\n        \"|:----|:----|:----|:----|:----|:----|:----|:----|:----|:----|:----|  \\n\"\n        \"|testModuleParameter|int|1|testDataType|typed||||||module param description|  \\n\"\n        \"\\n\"\n        \"**Parameters:**  \\n\"\n        \"\\n\"\n        \"|Name|Type|Value|Resolve|Bit vector left|Bit vector right|Array left|Array right|Description|  \\n\"\n        \"|:----|:----|:----|:----|:----|:----|:----|:----|:----|  \\n\"\n        \"|firstParameter||10|||||||  \\n\"\n    );\n\n    checkOutputFile(expectedOutput);\n}\n\nvoid tst_MarkdownGenerator::testDesignIsWritten()\n{\n    VLNV designVlnv(VLNV::DESIGN, \"Test\", \"TestLibrary\", \"TestDesign\", \"1.0\");\n    QSharedPointer<Design> design = QSharedPointer<Design>(new Design(designVlnv, Document::Revision::Std14));\n    library_.writeModelToFile(\"C:/Test/TestLibrary/TestDesign/1.0/TestDesign.1.0.xml\", design);\n    library_.addComponent(design);\n\n    VLNV firstVlnv(VLNV::COMPONENT, \"Test\", \"TestLibrary\", \"FirstComponent\", \"1.0\");\n    QSharedPointer<Component> refComponent = QSharedPointer<Component>(new Component(firstVlnv, Document::Revision::Std14));\n\n    QList <QSharedPointer<Parameter> > componentParameters;\n\n    QSharedPointer<Parameter> targetParameter = createTestParameter(\"firstParameter\", \"10\", \"\", \"ID_TARGET\", \"\",\n        \"\");\n    QSharedPointer<Parameter> referParameter = createTestParameter(\"referer\", \"ID_TARGET\", \"\", \"ID-REF\", \"\", \"\");\n    componentParameters.append(targetParameter);\n    componentParameters.append(referParameter);\n\n    refComponent->getParameters()->append(componentParameters);\n\n    library_.addComponent(refComponent);\n\n    QSharedPointer<ConfigurableVLNVReference> instanceVLNV(new ConfigurableVLNVReference(firstVlnv));\n    QSharedPointer<ComponentInstance> firstInstance(new ComponentInstance(\"firstInstance\", instanceVLNV));\n    firstInstance->getConfigurableElementValues()->append(createConfigurableElementvalues(refComponent));\n\n    design->getComponentInstances()->append(firstInstance);\n\n    QSharedPointer<View> hierarchicalView(new View);\n    hierarchicalView->setName(\"HierarchicalView\");\n    hierarchicalView->setDesignInstantiationRef(\"design_instantiation\");\n    \n    \n    topComponent_->getViews()->append(hierarchicalView);\n\n    QSharedPointer<DesignInstantiation> designInstantiation(new DesignInstantiation(\"design_instantiation\"));\n    designInstantiation->setDesignReference(\n        QSharedPointer<ConfigurableVLNVReference>(new ConfigurableVLNVReference(designVlnv)));\n\n    QScopedPointer<DocumentGenerator> generator(createTestGenerator());\n    \n    topComponent_->getDesignInstantiations()->append(designInstantiation);\n\n    QFile targetFile(targetPath_);\n    targetFile.open(QFile::WriteOnly);\n    QTextStream stream(&targetFile);\n\n    int subHeaderNumber = 1;\n    QStringList files;\n\n    generator->writeViews(stream, subHeaderNumber, files);\n\n    targetFile.close();\n\n    QString expectedOutput(\n        \"## 1.1 Views <a id=\\\"Test:TestLibrary:TestComponent:1.0.views\\\">  \\n\"\n        \"\\n\"\n        \"### 1.1.1 View: HierarchicalView  \\n\"\n        \"\\n\"\n        \"#### 1.1.1.1 Design instantiation: design_instantiation  \\n\"\n        \"\\n\"\n        \"**Design:** Test:TestLibrary:TestDesign:1.0  \\n\"\n        \"**IP-Xact file:** [TestDesign.1.0.xml]()  \\n\"\n        \"Diagram of design Test:TestLibrary:TestDesign:1.0:  \\n\"\n        \"![View: HierarchicalView preview picture](/Test.TestLibrary.TestComponent.1.0.HierarchicalView.png)  \\n\"\n    );\n\n    checkOutputFile(expectedOutput);\n}\n\nvoid tst_MarkdownGenerator::testEndOfDocumentWrittenForTopComponent()\n{\n}\n\nDocumentGenerator* tst_MarkdownGenerator::createTestGenerator()\n{\n    library_.writeModelToFile(\"C:/Test/TestLibrary/TestComponent/1.0/TestComponent.1.0.xml\", topComponent_);\n    library_.addComponent(topComponent_);\n\n    DocumentGenerator* generator(new DocumentGenerator(&library_, topComponentVlnv_, &designWidgetFactory_,\n        &expressionFormatterFactory_, 1, generatorParentWidget_));\n\n    generator->setFormat(DocumentGenerator::DocumentFormat::MD);\n    return generator;\n}\n\nvoid tst_MarkdownGenerator::readOutputFile()\n{\n    QFile outputFile(targetPath_);\n\n    QVERIFY(outputFile.open(QIODevice::ReadOnly));\n\n    output_ = outputFile.readAll();\n    outputFile.close();\n}\n\nvoid tst_MarkdownGenerator::checkOutputFile(QString const& expectedOutput)\n{\n    readOutputFile();\n\n    if (!output_.contains(expectedOutput))\n    {\n        QStringList outputLines = output_.split(\"\\n\");\n        QStringList expectedLines = expectedOutput.split(\"\\n\");\n\n        QVERIFY(outputLines.count() >= expectedLines.count());\n\n        int lineOffset = outputLines.indexOf(expectedLines.first());\n\n        if (lineOffset == -1)\n        {\n            readOutputFile();\n            QCOMPARE(output_, expectedOutput);\n        }\n        else\n        {\n            int lineCount = expectedLines.count();\n            for (int i = 0; i < lineCount; i++)\n            {\n                QCOMPARE(outputLines.at(i + lineOffset), expectedLines.at(i));\n            }\n        }\n    }\n    else if (output_.count(expectedOutput) != 1)\n    {\n        QVERIFY2(false, QString(expectedOutput + \" was found \" + QString::number(output_.count(expectedOutput)) +\n            \" times in output.\").toLocal8Bit());\n    }\n}\n\nQSharedPointer<Parameter> tst_MarkdownGenerator::createTestParameter(QString const& name, QString const& value, QString const& description, QString const& uuID, QString const& arrayLeft, QString const& arrayRight)\n{\n    QSharedPointer<Parameter> parameter(new Parameter);\n    parameter->setName(name);\n    parameter->setValue(value);\n    parameter->setDescription(description);\n    parameter->setValueId(uuID);\n    parameter->setArrayLeft(arrayLeft);\n    parameter->setArrayRight(arrayRight);\n\n    return parameter;\n}\n\nQSharedPointer<Port> tst_MarkdownGenerator::createTestPort(QString const& name, QString const& leftBound, QString const& rightBound, QString const& defaultValue, QString const& arrayLeft, QString const& arrayRight)\n{\n    QSharedPointer<Port> newPort(new Port);\n    newPort->setDirection(DirectionTypes::DIRECTION_PHANTOM);\n    newPort->setName(name);\n    newPort->setLeftBound(leftBound);\n    newPort->setRightBound(rightBound);\n    newPort->setDefaultValue(defaultValue);\n    newPort->setArrayLeft(arrayLeft);\n    newPort->setArrayRight(arrayRight);\n\n    return newPort;\n}\n\nQList<QSharedPointer<ConfigurableElementValue>> tst_MarkdownGenerator::createConfigurableElementvalues(QSharedPointer<Component> component)\n{\n    ExpressionFormatter* refExpressionFormatter = expressionFormatterFactory_.makeExpressionFormatter(component);\n\n    QList<QSharedPointer<ConfigurableElementValue> > instanceConfigurableElementValues;\n\n    foreach(QSharedPointer<Parameter> parameter, *component->getParameters())\n    {\n        instanceConfigurableElementValues.append(QSharedPointer<ConfigurableElementValue>(\n            new ConfigurableElementValue(refExpressionFormatter->formatReferringExpression(parameter->getValue()), parameter->name())));\n    }\n\n    delete refExpressionFormatter;\n    refExpressionFormatter = nullptr;\n\n    return instanceConfigurableElementValues;\n}\n\nQSharedPointer<Field> tst_MarkdownGenerator::createTestField(QString const& name, QString const& description, QString const& offset, QString const& width)\n{\n    QSharedPointer <Field> testField(new Field);\n    testField->setName(name);\n    testField->setDescription(description);\n    testField->setBitOffset(offset);\n    testField->setBitWidth(width);\n    testField->setVolatile(false);\n    testField->setAccess(AccessTypes::READ_ONLY);\n\n    return testField;\n}\n\nQSharedPointer<Register> tst_MarkdownGenerator::createTestRegister(QString const& name, QString const& offset, QString const& size, QString const& dimension, QString const& description)\n{\n    QSharedPointer<Register> testRegister(new Register);\n    testRegister->setName(name);\n    testRegister->setAddressOffset(offset);\n    testRegister->setSize(size);\n    testRegister->setDimension(dimension);\n    testRegister->setDescription(description);\n    testRegister->setVolatile(true);\n    testRegister->setAccess(AccessTypes::READ_WRITE);\n\n    return testRegister;\n}\n\nQSharedPointer<AddressBlock> tst_MarkdownGenerator::createTestAddressBlock(QString const& name, QString const& description, QString const& baseAddress, QString const& range, QString const& width, QList<QSharedPointer<Register>> registers)\n{\n    QSharedPointer <AddressBlock> testAddressBlock(new AddressBlock);\n    testAddressBlock->setName(name);\n    testAddressBlock->setUsage(General::REGISTER);\n    testAddressBlock->setDescription(description);\n    testAddressBlock->setBaseAddress(baseAddress);\n    testAddressBlock->setRange(range);\n    testAddressBlock->setWidth(width);\n    testAddressBlock->setAccess(AccessTypes::READ_WRITE);\n    testAddressBlock->setVolatile(true);\n\n    for (QSharedPointer<RegisterBase> testRegister : registers)\n    {\n        testAddressBlock->getRegisterData()->append(testRegister);\n    }\n\n    return testAddressBlock;\n}\n\nQSharedPointer<AddressBlock> tst_MarkdownGenerator::createAddressBlockWithRegisterData(QString const& name,\n    QString const& description, QString const& baseAddress, QString const& range,\n    QString const& width, QList<QSharedPointer<RegisterBase>> registers)\n{\n    QSharedPointer <AddressBlock> testAddressBlock(new AddressBlock);\n    testAddressBlock->setName(name);\n    testAddressBlock->setUsage(General::REGISTER);\n    testAddressBlock->setDescription(description);\n    testAddressBlock->setBaseAddress(baseAddress);\n    testAddressBlock->setRange(range);\n    testAddressBlock->setWidth(width);\n    testAddressBlock->setAccess(AccessTypes::READ_WRITE);\n    testAddressBlock->setVolatile(true);\n\n    for (QSharedPointer<RegisterBase> testRegister : registers)\n    {\n        testAddressBlock->getRegisterData()->append(testRegister);\n    }\n\n    return testAddressBlock;\n}\n\nQSharedPointer<MemoryMap> tst_MarkdownGenerator::createTestMemoryMap(QString const& name, QString const& description, int addressUnitbits, QList<QSharedPointer<AddressBlock>> addressBlocks)\n{\n    QSharedPointer<MemoryMap> memoryMap(new MemoryMap);\n    memoryMap->setName(name);\n    memoryMap->setAddressUnitBits(QString::number(addressUnitbits));\n    memoryMap->setDescription(description);\n\n    for (QSharedPointer<AddressBlock> includedAddressBlock : addressBlocks)\n    {\n        memoryMap->getMemoryBlocks()->append(includedAddressBlock);\n    }\n\n    return memoryMap;\n}\n\nQString tst_MarkdownGenerator::getSpaceString()\n{\n    return QString();\n}\n\nQString tst_MarkdownGenerator::getTableString()\n{\n    return QString();\n}\n\nQString tst_MarkdownGenerator::getEncodingString()\n{\n    return QString();\n}\n\nQString tst_MarkdownGenerator::getDoctypeString()\n{\n    return QString();\n}\n\nQString tst_MarkdownGenerator::getValidW3CStrictString()\n{\n    return QString();\n}\n\nQTEST_MAIN(tst_MarkdownGenerator)\n\n#include \"tst_MarkdownGenerator.moc\""
  },
  {
    "path": "tests/Core/tst_MarkdownGenerator.pri",
    "content": "# ----------------------------------------------------\n# This file is generated by the Qt Visual Studio Tools.\n# ------------------------------------------------------\n\n# This is a reminder that you are using a generated .pro file.\n# Remove it when you are finished editing this file.\n\n\nHEADERS += ../../editors/HWDesign/undoCommands/AdHocConnectionAddCommand.h \\\n    ../../editors/HWDesign/undoCommands/AdHocConnectionDeleteCommand.h \\\n    ../../editors/HWDesign/AdHocEnabled.h \\\n    ../../editors/HWDesign/undoCommands/AdHocTieOffConnectionDeleteCommand.h \\\n    ../../editors/HWDesign/undoCommands/AdHocVisibilityChangeCommand.h \\\n    ../../editors/common/Association/Associable.h \\\n    ../../editors/common/Association/Association.h \\\n    ../../editors/common/Association/AssociationAddCommand.h \\\n    ../../editors/common/Association/AssociationChangeEndpointCommand.h \\\n    ../../editors/common/Association/AssociationRemoveCommand.h \\\n    ../../editors/common/ComponentItemAutoConnector/AutoConnectorItem.h \\\n    ../../editors/common/ComponentItemAutoConnector/BusInterfaceItemMatcher.h \\\n    ../../editors/common/ComponentItemAutoConnector/BusInterfaceListFiller.h \\\n    ../../editors/common/ComponentItemAutoConnector/BusInterfaceTableAutoConnector.h \\\n    ../../common/graphicsItems/CommonGraphicsUndoCommands.h \\\n    ../../editors/HWDesign/undoCommands/ComponentInstancePasteCommand.h \\\n    ../../editors/HWDesign/undoCommands/ComponentItemMoveCommand.h \\\n    ../../editors/HWDesign/undoCommands/ConnectionDeleteCommand.h \\\n    ../../common/graphicsItems/ConnectionUndoCommands.h \\\n    ../../editors/common/DefaultRouting.h \\\n    ../../editors/common/DesignDiagramResolver.h \\\n    ../../kactusGenerators/DocumentGenerator/DocumentationWriter.h \\\n    ../../kactusGenerators/DocumentGenerator/HtmlWriter.h \\\n    ../../kactusGenerators/DocumentGenerator/MarkdownWriter.h \\\n    ../MockObjects/DesignWidgetFactoryMock.h \\\n    ../../common/widgets/tagEditor/FlowLayout.h \\\n    ../../common/graphicsItems/GraphicsColumnAddCommand.h \\\n    ../../common/graphicsItems/GraphicsColumnUndoCommands.h \\\n    ../../editors/common/GraphicsItemLabel.h \\\n    ../../editors/HWDesign/HWAddCommands.h \\\n    ../../editors/HWDesign/undoCommands/HWColumnAddCommand.h \\\n    ../../editors/SystemDesign/HWMappingItem.h \\\n    ../../editors/HWDesign/HWMoveCommands.h \\\n    ../../editors/common/ComponentItemAutoConnector/HierarchicalBusInterfaceItemMatcher.h \\\n    ../../editors/common/ComponentItemAutoConnector/HierarchicalBusInterfaceTableAutoConnector.h \\\n    ../../editors/common/ComponentItemAutoConnector/HierarchicalPortItemMatcher.h \\\n    ../../editors/common/ComponentItemAutoConnector/HierarchicalPortTableAutoConnector.h \\\n    ../../editors/common/ImageExporter.h \\\n    ../../editors/ComponentEditor/busInterfaces/portmaps/JaroWinklerAlgorithm.h \\\n    ../../common/widgets/assistedLineEdit/LineContentAssistWidget.h \\\n    ../../editors/ComponentEditor/common/MasterExpressionEditor.h \\\n    ../../editors/common/NamelabelWidth.h \\\n    ../../editors/ComponentEditor/common/ParameterizableTable.h \\\n    ../../editors/common/ComponentItemAutoConnector/PortItemMatcher.h \\\n    ../../editors/common/ComponentItemAutoConnector/PortListFiller.h \\\n    ../../editors/ComponentEditor/busInterfaces/portmaps/PortMapHeaderView.h \\\n    ../../editors/ComponentEditor/busInterfaces/portmaps/PortMapSortFilter.h \\\n    ../../editors/ComponentEditor/busInterfaces/portmaps/PortMappingColumns.h \\\n    ../../editors/HWDesign/undoCommands/PortPasteCommand.h \\\n    ../../editors/common/ComponentItemAutoConnector/PortTableAutoConnector.h \\\n    ../../editors/common/PortUtilities.h \\\n    ../../editors/common/StickyNote/StickyNoteEditCommand.h \\\n    ../../editors/common/StickyNote/StickyNoteMoveCommand.h \\\n    ../../editors/HWDesign/WarningSymbol.h \\\n    ../../editors/HWDesign/ActiveBusInterfaceItem.h \\\n    ../../editors/HWDesign/ActivePortItem.h \\\n    ../../editors/HWDesign/AdHocConnectionItem.h \\\n    ../../editors/HWDesign/AdHocItem.h \\\n    ../../common/widgets/assistedLineEdit/AssistedLineEdit.h \\\n    ../../editors/common/ComponentItemAutoConnector/AutoConnector.h \\\n    ../../editors/common/ComponentItemAutoConnector/AutoConnectorConnectionDelegate.h \\\n    ../../editors/common/ComponentItemAutoConnector/AutoConnectorConnectionTable.h \\\n    ../../editors/common/ComponentItemAutoConnector/AutoConnectorListFilter.h \\\n    ../../editors/HWDesign/BusInterfaceDialog.h \\\n    ../../editors/HWDesign/BusInterfaceEndPoint.h \\\n    ../../editors/ComponentEditor/busInterfaces/portmaps/BusInterfacePortMapTab.h \\\n    ../../common/widgets/colorBox/ColorBox.h \\\n    ../../editors/common/StickyNote/ColorFillTextItem.h \\\n    ../../editors/HWDesign/columnview/ColumnEditDialog.h \\\n    ../../editors/HWDesign/undoCommands/ComponentDeleteCommand.h \\\n    ../../editors/common/ComponentDesignDiagram.h \\\n    ../../common/graphicsItems/ComponentItem.h \\\n    ../../editors/common/ComponentItemAutoConnector/ComponentItemAutoConnector.h \\\n    ../../editors/ComponentEditor/parameters/ComponentParameterModel.h \\\n    ../../common/widgets/componentPreviewBox/ComponentPreviewBox.h \\\n    ../../editors/common/ComponentInstanceEditor/ConfigurableElementsView.h \\\n    ../../common/graphicsItems/ConnectionEndpoint.h \\\n    ../../editors/common/DesignDiagram.h \\\n    ../../editors/common/DesignWidget.h \\\n    ../../common/views/EditableTreeView/EditableTreeSortFilter.h \\\n    ../../common/views/EditableTreeView/EditableTreeView.h \\\n    ../../editors/ComponentEditor/common/ExpressionDelegate.h \\\n    ../../editors/ComponentEditor/common/ExpressionEditor.h \\\n    ../../editors/ComponentEditor/common/ExpressionLineEditor.h \\\n    ../../common/GenericEditProvider.h \\\n    ../../common/graphicsItems/GraphicsColumn.h \\\n    ../../common/graphicsItems/GraphicsColumnLayout.h \\\n    ../../common/graphicsItems/GraphicsConnection.h \\\n    ../../editors/HWDesign/HWChangeCommands.h \\\n    ../../editors/HWDesign/columnview/HWColumn.h \\\n    ../../editors/HWDesign/undoCommands/HWComponentAddCommand.h \\\n    ../../editors/HWDesign/HWComponentItem.h \\\n    ../../editors/HWDesign/HWConnection.h \\\n    ../../editors/HWDesign/HWConnectionEndpoint.h \\\n    ../../editors/HWDesign/HWDesignDiagram.h \\\n    ../MockObjects/HWDesignWidgetMock.h \\\n    ../../editors/HWDesign/HierarchicalBusInterfaceItem.h \\\n    ../../editors/HWDesign/HierarchicalPortItem.h \\\n    ../../common/IEditProvider.h \\\n    ../../common/widgets/kactusAttributeEditor/KactusAttributeEditor.h \\\n    ../MockObjects/LibraryMock.h \\\n    ../../common/widgets/LibrarySelectorWidget/LibrarySelectorWidget.h \\\n    ../../common/dialogs/LibrarySettingsDialog/LibrarySettingsDialog.h \\\n    ../../editors/ComponentEditor/common/MultilineDescriptionDelegate.h \\\n    ../../editors/HWDesign/OffPageConnectorItem.h \\\n    ../../editors/ComponentEditor/busInterfaces/portmaps/PhysicalPortMappingTableModel.h \\\n    ../../editors/ComponentEditor/busInterfaces/portmaps/PhysicalPortMappingTableView.h \\\n    ../../editors/ComponentEditor/busInterfaces/portmaps/PortListSortProxyModel.h \\\n    ../../editors/ComponentEditor/busInterfaces/portmaps/PortMapAutoConnector.h \\\n    ../../editors/ComponentEditor/busInterfaces/portmaps/PortMapDelegate.h \\\n    ../../editors/ComponentEditor/busInterfaces/portmaps/PortMapModel.h \\\n    ../../editors/ComponentEditor/busInterfaces/portmaps/PortMapView.h \\\n    ../../editors/ComponentEditor/busInterfaces/portmaps/PortMappingTableModel.h \\\n    ../../editors/ComponentEditor/busInterfaces/portmaps/PortMappingTableView.h \\\n    ../../editors/ComponentEditor/common/ReferencingTableModel.h \\\n    ../../editors/HWDesign/undoCommands/ReplaceComponentCommand.h \\\n    ../../editors/SystemDesign/SWComponentItem.h \\\n    ../../editors/SystemDesign/SWConnectionEndpoint.h \\\n    ../../editors/SystemDesign/SWPortItem.h \\\n    ../../editors/HWDesign/SelectItemTypeDialog.h \\\n    ../../editors/common/StickyNote/StickyNote.h \\\n    ../../editors/common/StickyNote/StickyNoteAddCommand.h \\\n    ../../editors/common/StickyNote/StickyNoteRemoveCommand.h \\\n    ../../editors/SystemDesign/SystemComponentItem.h \\\n    ../../common/widgets/tabDocument/TabDocument.h \\\n    ../../common/widgets/tagEditor/TagCompleterModel.h \\\n    ../../common/widgets/tagEditor/TagContainer.h \\\n    ../../common/widgets/tagEditor/TagDisplay.h \\\n    ../../common/widgets/tagEditor/TagEditor.h \\\n    ../../common/widgets/tagEditor/TagEditorContainer.h \\\n    ../../common/widgets/tagEditor/TagLabel.h \\\n    ../../common/widgets/tagEditor/TagSelector.h \\\n    ../../common/widgets/tagEditor/TagSelectorContainer.h \\\n    ../../editors/common/ConfigurationEditor/activeviewmodel.h \\\n    ../../kactusGenerators/DocumentGenerator/documentgenerator.h \\\n    ../../common/views/EditableTableView/editabletableview.h \\\n    ../../common/widgets/LibrarySelectorWidget/LibraryPathEditor/librarypatheditor.h \\\n    ../../common/widgets/LibrarySelectorWidget/LibraryPathSelector/librarypathselector.h \\\n    ../../common/validators/LibraryPathValidator/librarypathvalidator.h \\\n    ../../common/dialogs/LibrarySettingsDialog/librarysettingsdelegate.h \\\n    ../../common/delegates/LineEditDelegate/lineeditdelegate.h \\\n    ../../common/dialogs/newObjectDialog/newobjectdialog.h \\\n    ../../editors/ComponentEditor/itemvisualizer.h \\\n    ../../common/widgets/vlnvEditor/vlnveditor.h\nSOURCES += ../../editors/HWDesign/ActiveBusInterfaceItem.cpp \\\n    ../../editors/HWDesign/ActivePortItem.cpp \\\n    ../../editors/HWDesign/undoCommands/AdHocConnectionAddCommand.cpp \\\n    ../../editors/HWDesign/undoCommands/AdHocConnectionDeleteCommand.cpp \\\n    ../../editors/HWDesign/AdHocConnectionItem.cpp \\\n    ../../editors/HWDesign/AdHocEnabled.cpp \\\n    ../../editors/HWDesign/AdHocItem.cpp \\\n    ../../editors/HWDesign/undoCommands/AdHocTieOffConnectionDeleteCommand.cpp \\\n    ../../editors/HWDesign/undoCommands/AdHocVisibilityChangeCommand.cpp \\\n    ../../common/widgets/assistedLineEdit/AssistedLineEdit.cpp \\\n    ../../editors/common/Association/Associable.cpp \\\n    ../../editors/common/Association/Association.cpp \\\n    ../../editors/common/Association/AssociationAddCommand.cpp \\\n    ../../editors/common/Association/AssociationChangeEndpointCommand.cpp \\\n    ../../editors/common/Association/AssociationRemoveCommand.cpp \\\n    ../../editors/common/ComponentItemAutoConnector/AutoConnector.cpp \\\n    ../../editors/common/ComponentItemAutoConnector/AutoConnectorConnectionDelegate.cpp \\\n    ../../editors/common/ComponentItemAutoConnector/AutoConnectorConnectionTable.cpp \\\n    ../../editors/common/ComponentItemAutoConnector/AutoConnectorItem.cpp \\\n    ../../editors/common/ComponentItemAutoConnector/AutoConnectorListFilter.cpp \\\n    ../../editors/HWDesign/BusInterfaceDialog.cpp \\\n    ../../editors/HWDesign/BusInterfaceEndPoint.cpp \\\n    ../../editors/common/ComponentItemAutoConnector/BusInterfaceItemMatcher.cpp \\\n    ../../editors/common/ComponentItemAutoConnector/BusInterfaceListFiller.cpp \\\n    ../../editors/ComponentEditor/busInterfaces/portmaps/BusInterfacePortMapTab.cpp \\\n    ../../editors/common/ComponentItemAutoConnector/BusInterfaceTableAutoConnector.cpp \\\n    ../../common/widgets/colorBox/ColorBox.cpp \\\n    ../../editors/common/StickyNote/ColorFillTextItem.cpp \\\n    ../../editors/HWDesign/columnview/ColumnEditDialog.cpp \\\n    ../../common/graphicsItems/CommonGraphicsUndoCommands.cpp \\\n    ../../editors/HWDesign/undoCommands/ComponentDeleteCommand.cpp \\\n    ../../editors/common/ComponentDesignDiagram.cpp \\\n    ../../editors/HWDesign/undoCommands/ComponentInstancePasteCommand.cpp \\\n    ../../common/graphicsItems/ComponentItem.cpp \\\n    ../../editors/common/ComponentItemAutoConnector/ComponentItemAutoConnector.cpp \\\n    ../../editors/HWDesign/undoCommands/ComponentItemMoveCommand.cpp \\\n    ../../editors/ComponentEditor/parameters/ComponentParameterModel.cpp \\\n    ../../common/widgets/componentPreviewBox/ComponentPreviewBox.cpp \\\n    ../../editors/common/ComponentInstanceEditor/ConfigurableElementsView.cpp \\\n    ../../editors/HWDesign/undoCommands/ConnectionDeleteCommand.cpp \\\n    ../../common/graphicsItems/ConnectionEndpoint.cpp \\\n    ../../common/graphicsItems/ConnectionUndoCommands.cpp \\\n    ../../editors/common/DefaultRouting.cpp \\\n    ../../editors/common/DesignDiagram.cpp \\\n    ../../editors/common/DesignDiagramResolver.cpp \\\n    ../../editors/common/DesignWidget.cpp \\\n    ../../kactusGenerators/DocumentGenerator/DocumentationWriter.cpp \\\n    ../../kactusGenerators/DocumentGenerator/HtmlWriter.cpp \\\n    ../../kactusGenerators/DocumentGenerator/MarkdownWriter.cpp \\\n    ../MockObjects/DesignWidgetFactoryMock.cpp \\\n    ../../common/views/EditableTreeView/EditableTreeSortFilter.cpp \\\n    ../../common/views/EditableTreeView/EditableTreeView.cpp \\\n    ../../editors/ComponentEditor/common/ExpressionDelegate.cpp \\\n    ../../editors/ComponentEditor/common/ExpressionEditor.cpp \\\n    ../../editors/ComponentEditor/common/ExpressionLineEditor.cpp \\\n    ../../common/widgets/tagEditor/FlowLayout.cpp \\\n    ../../common/GenericEditProvider.cpp \\\n    ../../common/graphicsItems/GraphicsColumn.cpp \\\n    ../../common/graphicsItems/GraphicsColumnAddCommand.cpp \\\n    ../../common/graphicsItems/GraphicsColumnLayout.cpp \\\n    ../../common/graphicsItems/GraphicsColumnUndoCommands.cpp \\\n    ../../common/graphicsItems/GraphicsConnection.cpp \\\n    ../../editors/common/GraphicsItemLabel.cpp \\\n    ../../editors/HWDesign/HWAddCommands.cpp \\\n    ../../editors/HWDesign/HWChangeCommands.cpp \\\n    ../../editors/HWDesign/columnview/HWColumn.cpp \\\n    ../../editors/HWDesign/undoCommands/HWColumnAddCommand.cpp \\\n    ../../editors/HWDesign/undoCommands/HWComponentAddCommand.cpp \\\n    ../../editors/HWDesign/HWComponentItem.cpp \\\n    ../../editors/HWDesign/HWConnection.cpp \\\n    ../../editors/HWDesign/HWConnectionEndPoint.cpp \\\n    ../../editors/HWDesign/HWDesignDiagram.cpp \\\n    ../MockObjects/HWDesignWidgetMock.cpp \\\n    ../../editors/SystemDesign/HWMappingItem.cpp \\\n    ../../editors/HWDesign/HWMoveCommands.cpp \\\n    ../../editors/HWDesign/HierarchicalBusInterfaceItem.cpp \\\n    ../../editors/common/ComponentItemAutoConnector/HierarchicalBusInterfaceItemMatcher.cpp \\\n    ../../editors/common/ComponentItemAutoConnector/HierarchicalBusInterfaceTableAutoConnector.cpp \\\n    ../../editors/HWDesign/HierarchicalPortItem.cpp \\\n    ../../editors/common/ComponentItemAutoConnector/HierarchicalPortItemMatcher.cpp \\\n    ../../editors/common/ComponentItemAutoConnector/HierarchicalPortTableAutoConnector.cpp \\\n    ../../editors/common/ImageExporter.cpp \\\n    ../../editors/ComponentEditor/busInterfaces/portmaps/JaroWinklerAlgorithm.cpp \\\n    ../../common/widgets/kactusAttributeEditor/KactusAttributeEditor.cpp \\\n    ../MockObjects/LibraryMock.cpp \\\n    ../../common/widgets/LibrarySelectorWidget/LibrarySelectorWidget.cpp \\\n    ../../common/dialogs/LibrarySettingsDialog/LibrarySettingsDialog.cpp \\\n    ../../common/widgets/assistedLineEdit/LineContentAssistWidget.cpp \\\n    ../../editors/ComponentEditor/common/MasterExpressionEditor.cpp \\\n    ../../editors/ComponentEditor/common/MultilineDescriptionDelegate.cpp \\\n    ../../editors/common/NamelabelWidth.cpp \\\n    ../../editors/HWDesign/OffPageConnectorItem.cpp \\\n    ../../editors/ComponentEditor/common/ParameterizableTable.cpp \\\n    ../../editors/ComponentEditor/busInterfaces/portmaps/PhysicalPortMappingTableModel.cpp \\\n    ../../editors/ComponentEditor/busInterfaces/portmaps/PhysicalPortMappingTableView.cpp \\\n    ../../editors/common/ComponentItemAutoConnector/PortItemMatcher.cpp \\\n    ../../editors/common/ComponentItemAutoConnector/PortListFiller.cpp \\\n    ../../editors/ComponentEditor/busInterfaces/portmaps/PortListSortProxyModel.cpp \\\n    ../../editors/ComponentEditor/busInterfaces/portmaps/PortMapAutoConnector.cpp \\\n    ../../editors/ComponentEditor/busInterfaces/portmaps/PortMapDelegate.cpp \\\n    ../../editors/ComponentEditor/busInterfaces/portmaps/PortMapHeaderView.cpp \\\n    ../../editors/ComponentEditor/busInterfaces/portmaps/PortMapModel.cpp \\\n    ../../editors/ComponentEditor/busInterfaces/portmaps/PortMapSortFilter.cpp \\\n    ../../editors/ComponentEditor/busInterfaces/portmaps/PortMapView.cpp \\\n    ../../editors/ComponentEditor/busInterfaces/portmaps/PortMappingTableModel.cpp \\\n    ../../editors/ComponentEditor/busInterfaces/portmaps/PortMappingTableView.cpp \\\n    ../../editors/HWDesign/undoCommands/PortPasteCommand.cpp \\\n    ../../editors/common/ComponentItemAutoConnector/PortTableAutoConnector.cpp \\\n    ../../editors/common/PortUtilities.cpp \\\n    ../../editors/HWDesign/PortmapDialog.cpp \\\n    ../../editors/ComponentEditor/common/ReferencingTableModel.cpp \\\n    ../../editors/HWDesign/undoCommands/ReplaceComponentCommand.cpp \\\n    ../../editors/SystemDesign/SWComponentItem.cpp \\\n    ../../editors/SystemDesign/SWConnectionEndpoint.cpp \\\n    ../../editors/SystemDesign/SWPortItem.cpp \\\n    ../../editors/HWDesign/SelectItemTypeDialog.cpp \\\n    ../../editors/common/StickyNote/StickyNote.cpp \\\n    ../../editors/common/StickyNote/StickyNoteAddCommand.cpp \\\n    ../../editors/common/StickyNote/StickyNoteEditCommand.cpp \\\n    ../../editors/common/StickyNote/StickyNoteMoveCommand.cpp \\\n    ../../editors/common/StickyNote/StickyNoteRemoveCommand.cpp \\\n    ../../editors/SystemDesign/SystemComponentItem.cpp \\\n    ../../editors/SystemDesign/UndoCommands/SystemMoveCommands.cpp \\\n    ../../common/widgets/tabDocument/TabDocument.cpp \\\n    ../../editors/common/ComponentItemAutoConnector/TableAutoConnector.cpp \\\n    ../../editors/common/ComponentItemAutoConnector/TableItemMatcher.cpp \\\n    ../../common/widgets/tagEditor/TagCompleterModel.cpp \\\n    ../../common/widgets/tagEditor/TagContainer.cpp \\\n    ../../common/widgets/tagEditor/TagDisplay.cpp \\\n    ../../common/widgets/tagEditor/TagEditor.cpp \\\n    ../../common/widgets/tagEditor/TagEditorContainer.cpp \\\n    ../../common/widgets/tagEditor/TagLabel.cpp \\\n    ../../common/widgets/tagEditor/TagSelector.cpp \\\n    ../../common/widgets/tagEditor/TagSelectorContainer.cpp \\\n    ../../editors/HWDesign/undoCommands/TopAdHocVisibilityChangeCommand.cpp \\\n    ../../common/widgets/vlnvEditor/VLNVContentMatcher.cpp \\\n    ../../common/widgets/vlnvEditor/VLNVDataTree.cpp \\\n    ../../editors/HWDesign/WarningSymbol.cpp \\\n    ../../editors/common/ConfigurationEditor/activeviewmodel.cpp \\\n    ../../kactusGenerators/DocumentGenerator/documentgenerator.cpp \\\n    ../../common/views/EditableTableView/editabletableview.cpp \\\n    ../../common/widgets/LibrarySelectorWidget/LibraryPathEditor/librarypatheditor.cpp \\\n    ../../common/widgets/LibrarySelectorWidget/LibraryPathSelector/librarypathselector.cpp \\\n    ../../common/validators/LibraryPathValidator/librarypathvalidator.cpp \\\n    ../../common/dialogs/LibrarySettingsDialog/librarysettingsdelegate.cpp \\\n    ../../common/delegates/LineEditDelegate/lineeditdelegate.cpp \\\n    ../../common/dialogs/newObjectDialog/newobjectdialog.cpp \\\n    ../../common/widgets/vlnvEditor/vlnveditor.cpp \\\n    ../../editors/ComponentEditor/itemvisualizer.cpp \\\n    ./tst_MarkdownGenerator.cpp\n"
  },
  {
    "path": "tests/Core/tst_MarkdownGenerator.pro",
    "content": "#-----------------------------------------------------------------------------\n# File: tst_MarkdownGenerator.pro\n#-----------------------------------------------------------------------------\n# Project: Kactus2\n# Author: Anton Hagqvist\n# Date: 11.4.2023\n#\n# Description:\n# Qt project file for markdown generator\n#-----------------------------------------------------------------------------\n\nTEMPLATE = app\n\nTARGET = tst_MarkdownGenerator\n\nQT += core xml gui widgets testlib printsupport svg\nCONFIG += c++11 testcase console\n\nQMAKE_EXPORTED_VARIABLES += MAKE_TESTARGS\nMAKE_TESTARGS.name = TESTARGS\nMAKE_TESTARGS.value = \"-platform offscreen\"\n\nwin32:CONFIG(release, debug|release) {\n    LIBS += -L../../executable/ -lIPXACTmodels -lKactusAPI\n    DESTDIR = ./release\n}\nelse:win32:CONFIG(debug, debug|release) {\n    LIBS += -L../../executable/ -lIPXACTmodelsd -lKactusAPId\n    DESTDIR = ./debug\n}\nelse:unix {\n    LIBS += -L../../executable/ -lIPXACTmodels -lKactusAPI\n    DESTDIR = ./release\n}\n\n#DESTDIR = ./release\n\nINCLUDEPATH += $$DESTDIR\nINCLUDEPATH += ../../\nINCLUDEPATH += ../../KactusAPI/include\n\nDEPENDPATH += .\nDEPENDPATH += ../../\n\nOBJECTS_DIR += $$DESTDIR\n\nMOC_DIR += ./generatedFiles\nUI_DIR += ./generatedFiles\nRCC_DIR += ./generatedFiles\ninclude(tst_MarkdownGenerator.pri)\n"
  },
  {
    "path": "tests/Core/tst_MasterSlavePathSearch.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: tst_MasterSlavePathSearch.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Mikko Teuho\n// Date: 26.03.2018\n//\n// Description:\n// Unit test for class MasterSlavePathSearch.\n//-----------------------------------------------------------------------------\n\n#include <editors/MemoryDesigner/MasterSlavePathSearch.h>\n#include <editors/MemoryDesigner/ConnectivityGraph.h>\n\n#include <editors/MemoryDesigner/ConnectivityComponent.h>\n#include <editors/MemoryDesigner/ConnectivityInterface.h>\n#include <editors/MemoryDesigner/ConnectivityConnection.h>\n#include <editors/MemoryDesigner/MemoryItem.h>\n\n#include <QtTest>\n\nnamespace PathSearchSpace\n{\n    QString const MASTERMODE = \"master\";\n    QString const SLAVEMODE = \"slave\";\n    QString const INITIATORMODE = \"initiator\";\n    QString const TARGETMODE = \"target\";\n    QString const MIRROREDMASTERMODE = \"mirroredMaster\";\n    QString const MIRROREDSLAVEMODE = \"mirroredSlave\";\n    QString const MIRROREDINITIATORMODE = \"mirroredInitiator\";\n    QString const MIRROREDTARGETMODE = \"mirroredTarget\";\n}\n\nclass tst_MasterSlavePathSearch : public QObject\n{\n    Q_OBJECT\n\npublic:\n    tst_MasterSlavePathSearch();\n\nprivate slots:\n\n    void init();\n    void cleanup();\n\n    void testItemsWithoutConnections();\n\n    void testSpaceMapConnection();\n\n    void testAddressSpaceConnection();\n\n    void testSpaceChainConnectionWithChainedItemsToDifferentMemoryMaps();\n\n    void testContainedConnectionsAreNotExamined();\n\n    void testOpaqueBridgeConnection();\n\nprivate:\n\n    QSharedPointer<ConnectivityGraph> testGraph_;\n\n    MasterSlavePathSearch pathSearcher_;\n\n    QSharedPointer<ConnectivityInterface> createInterfaceWithMemoryItem(QString const& interfaceName,\n        QString const& mode, QSharedPointer<ConnectivityComponent> containingInstance, bool hierarchical) const;\n\n    QSharedPointer<ConnectivityInterface> createTargetInterfaceWithConnectedSubspaceMap(\n        QString const& interfaceName,\n        QSharedPointer<ConnectivityComponent> containingInstance,\n        QString const& connectedInitiatorName,\n        bool hierarchical) const;\n\n    void addLocalConnection(QSharedPointer<ConnectivityInterface> masterInterface);\n};\n\n//-----------------------------------------------------------------------------\n// Function: tst_MasterSlavePathSearch::tst_MasterSlavePathSearch()\n//-----------------------------------------------------------------------------\ntst_MasterSlavePathSearch::tst_MasterSlavePathSearch()\n{\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_MasterSlavePathSearch::init()\n//-----------------------------------------------------------------------------\nvoid tst_MasterSlavePathSearch::init()\n{\n    testGraph_ = QSharedPointer<ConnectivityGraph>(new ConnectivityGraph());\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_MasterSlavePathSearch::cleanup()\n//-----------------------------------------------------------------------------\nvoid tst_MasterSlavePathSearch::cleanup()\n{\n    testGraph_.clear();\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_MasterSlavePathSearch::testItemsWithoutConnections()\n//-----------------------------------------------------------------------------\nvoid tst_MasterSlavePathSearch::testItemsWithoutConnections()\n{\n    QSharedPointer<ConnectivityComponent> testComponent1(new ConnectivityComponent(\"testComponent1\"));\n    QSharedPointer<ConnectivityComponent> testComponent2(new ConnectivityComponent(\"testComponent2\"));\n\n    QSharedPointer<ConnectivityInterface> testSpaceInterface =\n        createInterfaceWithMemoryItem(\"testInterface1\", PathSearchSpace::MASTERMODE, testComponent1, false);\n\n    QSharedPointer<ConnectivityInterface> testMapInterface =\n        createInterfaceWithMemoryItem(\"testInterface2\", PathSearchSpace::SLAVEMODE, testComponent2, false);\n\n    testGraph_->getInstances().append(testComponent1);\n    testGraph_->getInstances().append(testComponent2);\n    testGraph_->getInterfaces().append(testSpaceInterface);\n    testGraph_->getInterfaces().append(testMapInterface);\n\n    QVector<QVector<QSharedPointer<ConnectivityInterface const> > > paths =\n        pathSearcher_.findMasterSlavePaths(testGraph_, false);\n\n    QCOMPARE(paths.count(), 0);\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_MasterSlavePathSearch::testSpaceMapConnection()\n//-----------------------------------------------------------------------------\nvoid tst_MasterSlavePathSearch::testSpaceMapConnection()\n{\n    QSharedPointer<ConnectivityComponent> testComponent1(new ConnectivityComponent(\"testComponent1\"));\n    QSharedPointer<ConnectivityComponent> testComponent2(new ConnectivityComponent(\"testComponent2\"));\n\n    QSharedPointer<ConnectivityInterface> testSpaceInterface =\n        createInterfaceWithMemoryItem(\"testInterface1\", PathSearchSpace::MASTERMODE, testComponent1, false);\n\n    QSharedPointer<ConnectivityInterface> testMapInterface =\n        createInterfaceWithMemoryItem(\"testInterface2\", PathSearchSpace::SLAVEMODE, testComponent2, false);\n\n    testGraph_->getInstances().append(testComponent1);\n    testGraph_->getInstances().append(testComponent2);\n    testGraph_->getInterfaces().append(testSpaceInterface);\n    testGraph_->getInterfaces().append(testMapInterface);\n\n    QSharedPointer<ConnectivityConnection> testConnection(\n        new ConnectivityConnection(\"testConnection\", testSpaceInterface, testMapInterface));\n\n    testGraph_->getConnections().append(testConnection);\n\n    QVector<QVector<QSharedPointer<ConnectivityInterface const> > > paths =\n        pathSearcher_.findMasterSlavePaths(testGraph_, false);\n\n    QCOMPARE(paths.count(), 1);\n    QCOMPARE(paths.first().count(), 2);\n    QCOMPARE(paths.first().first(), QSharedPointer<ConnectivityInterface const>(testSpaceInterface));\n    QCOMPARE(paths.first().last(), QSharedPointer<ConnectivityInterface const>(testMapInterface));\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_MasterSlavePathSearch::testItemsWithAddressSpaceConnection()\n//-----------------------------------------------------------------------------\nvoid tst_MasterSlavePathSearch::testAddressSpaceConnection()\n{\n    QSharedPointer<ConnectivityComponent> testSpaceComponent1(new ConnectivityComponent(\"testSpaceComponent1\"));\n    QSharedPointer<ConnectivityComponent> testSpaceComponent2(new ConnectivityComponent(\"testSpaceComponent2\"));\n    QSharedPointer<ConnectivityComponent> testMapComponent(new ConnectivityComponent(\"testMapComponent\"));\n\n    QSharedPointer<ConnectivityInterface> testSpaceInterface1 = createInterfaceWithMemoryItem(\n        \"testSpaceInterface1\", PathSearchSpace::MASTERMODE, testSpaceComponent1, false);\n\n    QSharedPointer<ConnectivityInterface> testSpaceInterface2 = createInterfaceWithMemoryItem(\n        \"testSpaceInterface2\", PathSearchSpace::MASTERMODE, testSpaceComponent2, true);\n\n    QSharedPointer<ConnectivityInterface> testMapInterface =\n        createInterfaceWithMemoryItem(\"testMapInterface\", PathSearchSpace::SLAVEMODE, testMapComponent, false);\n\n    testGraph_->getInstances().append(testSpaceComponent1);\n    testGraph_->getInstances().append(testSpaceComponent2);\n    testGraph_->getInstances().append(testMapComponent);\n    testGraph_->getInterfaces().append(testSpaceInterface1);\n    testGraph_->getInterfaces().append(testSpaceInterface2);\n    testGraph_->getInterfaces().append(testMapInterface);\n\n    QSharedPointer<ConnectivityConnection> testHierarchicalConnection(new ConnectivityConnection(\n        \"instanceToHierarchicalSpaceConnection\", testSpaceInterface1, testSpaceInterface2));\n    QSharedPointer<ConnectivityConnection> testSpaceMapConnection(new ConnectivityConnection(\n        \"testSpaceMapConnection\", testSpaceInterface2, testMapInterface));\n\n    testGraph_->getConnections().append(testHierarchicalConnection);\n    testGraph_->getConnections().append(testSpaceMapConnection);\n\n    QVector<QVector<QSharedPointer<ConnectivityInterface const> > > paths =\n        pathSearcher_.findMasterSlavePaths(testGraph_, false);\n\n    QCOMPARE(paths.count(), 1);\n    QCOMPARE(paths.first().count(), 3);\n    QCOMPARE(paths.first().at(0), QSharedPointer<ConnectivityInterface const>(testSpaceInterface1));\n    QCOMPARE(paths.first().at(1), QSharedPointer<ConnectivityInterface const>(testSpaceInterface2));\n    QCOMPARE(paths.first().at(2), QSharedPointer<ConnectivityInterface const>(testMapInterface));\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_MasterSlavePathSearch::testSpaceChainConnectionWithChainedItemsToDifferentMemoryMaps()\n//-----------------------------------------------------------------------------\nvoid tst_MasterSlavePathSearch::testSpaceChainConnectionWithChainedItemsToDifferentMemoryMaps()\n{\n    QSharedPointer<ConnectivityComponent> spaceComponent1(new ConnectivityComponent(\"spaceComponent1\"));\n    QSharedPointer<ConnectivityComponent> spaceComponent2(new ConnectivityComponent(\"spaceComponent2\"));\n    QSharedPointer<ConnectivityComponent> mapComponent1(new ConnectivityComponent(\"mapComponent1\"));\n    QSharedPointer<ConnectivityComponent> mapComponent2(new ConnectivityComponent(\"mapComponent2\"));\n\n    QSharedPointer<ConnectivityInterface> spaceInterface1 =\n        createInterfaceWithMemoryItem(\"spaceInterface1\", PathSearchSpace::MASTERMODE, spaceComponent1, false);\n\n    QSharedPointer<ConnectivityInterface> spaceInterface2 =\n        createInterfaceWithMemoryItem(\"spaceInterface2\", PathSearchSpace::MASTERMODE, spaceComponent2, true);\n\n    QSharedPointer<ConnectivityInterface> mapInterface1 =\n        createInterfaceWithMemoryItem(\"mapInterface1\", PathSearchSpace::SLAVEMODE, mapComponent1, false);\n\n    QSharedPointer<ConnectivityInterface> mapInterface2 =\n        createInterfaceWithMemoryItem(\"mapInterface2\", PathSearchSpace::SLAVEMODE, mapComponent2, false);\n\n    testGraph_->getInstances().append(spaceComponent1);\n    testGraph_->getInstances().append(spaceComponent2);\n    testGraph_->getInstances().append(mapComponent1);\n    testGraph_->getInstances().append(mapComponent2);\n\n    testGraph_->getInterfaces().append(spaceInterface1);\n    testGraph_->getInterfaces().append(spaceInterface2);\n    testGraph_->getInterfaces().append(mapInterface1);\n    testGraph_->getInterfaces().append(mapInterface2);\n\n    QSharedPointer<ConnectivityConnection> spaceChain(\n        new ConnectivityConnection(\"spaceChain\", spaceInterface1, spaceInterface2));\n    QSharedPointer<ConnectivityConnection> spaceToMap(\n        new ConnectivityConnection(\"spaceToMap\", spaceInterface1, mapInterface1));\n    QSharedPointer<ConnectivityConnection> hierarchicalToMap(\n        new ConnectivityConnection(\"hierarchicalToMap\", spaceInterface2, mapInterface2));\n\n    testGraph_->getConnections().append(spaceChain);\n    testGraph_->getConnections().append(spaceToMap);\n    testGraph_->getConnections().append(hierarchicalToMap);\n    addLocalConnection(spaceInterface2);\n\n    QVector<QVector<QSharedPointer<ConnectivityInterface const> > > paths =\n        pathSearcher_.findMasterSlavePaths(testGraph_, false);\n\n    QCOMPARE(paths.count(), 3);\n\n    QVector<QSharedPointer<ConnectivityInterface const> > hierarchicalPath= paths.first();\n    QVector<QSharedPointer<ConnectivityInterface const> > spaceMapPath = paths.at(1);\n    QVector<QSharedPointer<ConnectivityInterface const> > localPath = paths.last();\n\n    QCOMPARE(hierarchicalPath.count(), 3);\n    QCOMPARE(hierarchicalPath.at(0), QSharedPointer<ConnectivityInterface const>(spaceInterface1));\n    QCOMPARE(hierarchicalPath.at(1), QSharedPointer<ConnectivityInterface const>(spaceInterface2));\n    QCOMPARE(hierarchicalPath.at(2), QSharedPointer<ConnectivityInterface const>(mapInterface2));\n    QCOMPARE(spaceMapPath.count(), 3);\n    QCOMPARE(spaceMapPath.at(0), QSharedPointer<ConnectivityInterface const>(spaceInterface2));\n    QCOMPARE(spaceMapPath.at(1), QSharedPointer<ConnectivityInterface const>(spaceInterface1));\n    QCOMPARE(spaceMapPath.at(2), QSharedPointer<ConnectivityInterface const>(mapInterface1));\n    QCOMPARE(localPath.count(), 2);\n    QCOMPARE(localPath.at(0), QSharedPointer<ConnectivityInterface const>(spaceInterface2));\n    QCOMPARE(localPath.at(1), QSharedPointer<ConnectivityInterface const>(spaceInterface2));\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_MasterSlavePathSearch::testContainedConnectionsAreNotExamined()\n//-----------------------------------------------------------------------------\nvoid tst_MasterSlavePathSearch::testContainedConnectionsAreNotExamined()\n{\n    QSharedPointer<ConnectivityComponent> spaceComponent1(new ConnectivityComponent(\"spaceComponent1\"));\n    QSharedPointer<ConnectivityComponent> spaceComponent2(new ConnectivityComponent(\"spaceComponent2\"));\n    QSharedPointer<ConnectivityComponent> mapComponent1(new ConnectivityComponent(\"mapComponent1\"));\n\n    QSharedPointer<ConnectivityInterface> spaceInterface1 =\n        createInterfaceWithMemoryItem(\"spaceInterface1\", PathSearchSpace::MASTERMODE, spaceComponent1, false);\n\n    QSharedPointer<ConnectivityInterface> spaceInterface2 =\n        createInterfaceWithMemoryItem(\"spaceInterface2\", PathSearchSpace::MASTERMODE, spaceComponent2, true);\n\n    QSharedPointer<ConnectivityInterface> mapInterface1 =\n        createInterfaceWithMemoryItem(\"mapInterface1\", PathSearchSpace::SLAVEMODE, mapComponent1, false);\n\n    testGraph_->getInstances().append(spaceComponent1);\n    testGraph_->getInstances().append(spaceComponent2);\n    testGraph_->getInstances().append(mapComponent1);\n\n    testGraph_->getInterfaces().append(spaceInterface1);\n    testGraph_->getInterfaces().append(spaceInterface2);\n    testGraph_->getInterfaces().append(mapInterface1);\n\n    QSharedPointer<ConnectivityConnection> spaceChain(\n        new ConnectivityConnection(\"spaceChain\", spaceInterface1, spaceInterface2));\n    QSharedPointer<ConnectivityConnection> spaceToMap(\n        new ConnectivityConnection(\"spaceToMap\", spaceInterface2, mapInterface1));\n\n    testGraph_->getConnections().append(spaceChain);\n    testGraph_->getConnections().append(spaceToMap);\n\n    QVector<QVector<QSharedPointer<ConnectivityInterface const> > > paths =\n        pathSearcher_.findMasterSlavePaths(testGraph_, false);\n\n    QCOMPARE(paths.count(), 1);\n    QCOMPARE(paths.first().size(), 3);\n    QCOMPARE(paths.first().at(0), QSharedPointer<ConnectivityInterface const>(spaceInterface1));\n    QCOMPARE(paths.first().at(1), QSharedPointer<ConnectivityInterface const>(spaceInterface2));\n    QCOMPARE(paths.first().at(2), QSharedPointer<ConnectivityInterface const>(mapInterface1));\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_MasterSlavePathSearch::testOpaqueBridgeConnection()\n//-----------------------------------------------------------------------------\nvoid tst_MasterSlavePathSearch::testOpaqueBridgeConnection()\n{\n    // Test path search from initiator component initiator to target component target through opaque bridge component.\n    QSharedPointer<ConnectivityComponent> initiatorComponent(new ConnectivityComponent(\"initiatorComp\"));\n    QSharedPointer<ConnectivityComponent> targetComponent(new ConnectivityComponent(\"targetComp\"));\n    QSharedPointer<ConnectivityComponent> bridgeComponent(new ConnectivityComponent(\"bridgeComp\"));\n\n    QSharedPointer<ConnectivityInterface> testInitiatorInterface =\n        createInterfaceWithMemoryItem(\"initiatorInterface\", PathSearchSpace::INITIATORMODE, initiatorComponent, false);\n\n    QSharedPointer<ConnectivityInterface> testTargetInterface =\n        createInterfaceWithMemoryItem(\"targetInterface\", PathSearchSpace::TARGETMODE, targetComponent, false);\n\n    QString initiatorName = \"bridgeInitiator\";\n    QSharedPointer<ConnectivityInterface> testBridgeInitiator = createInterfaceWithMemoryItem(initiatorName, PathSearchSpace::INITIATORMODE, bridgeComponent, false);\n    QSharedPointer<ConnectivityInterface> testBridgeTarget = createTargetInterfaceWithConnectedSubspaceMap(\"bridgeTarget\", bridgeComponent, initiatorName, false);\n\n    testBridgeInitiator->setBridged();\n    testBridgeTarget->setBridged();\n\n    testGraph_->getInstances().append(initiatorComponent);\n    testGraph_->getInstances().append(targetComponent);\n    testGraph_->getInstances().append(bridgeComponent);\n\n    testGraph_->getInterfaces().append(testInitiatorInterface);\n    testGraph_->getInterfaces().append(testTargetInterface);\n    testGraph_->getInterfaces().append(testBridgeInitiator);\n    testGraph_->getInterfaces().append(testBridgeTarget);\n\n    QSharedPointer<ConnectivityConnection> initiatorToBridge(\n        new ConnectivityConnection(\"initToBridge\", testInitiatorInterface, testBridgeTarget));\n    QSharedPointer<ConnectivityConnection> internalBridge(\n        new ConnectivityConnection(\"internalBridge\", testBridgeTarget, testBridgeInitiator));\n    QSharedPointer<ConnectivityConnection> bridgeToTarget(\n        new ConnectivityConnection(\"bridgeToTarget\", testBridgeInitiator, testTargetInterface));\n\n    testGraph_->getConnections().append(initiatorToBridge);\n    testGraph_->getConnections().append(internalBridge);\n    testGraph_->getConnections().append(bridgeToTarget);\n\n    QVector<QVector<QSharedPointer<ConnectivityInterface const> > > paths = pathSearcher_.findMasterSlavePaths(testGraph_, false);\n\n    QCOMPARE(paths.count(), 1);\n    QCOMPARE(paths.first().count(), 4);\n    QCOMPARE(paths.first().first(), QSharedPointer<ConnectivityInterface const>(testInitiatorInterface));\n    QCOMPARE(paths.first().last(), QSharedPointer<ConnectivityInterface const>(testTargetInterface));\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_MasterSlavePathSearch::createInterfaceWithMemoryItem()\n//-----------------------------------------------------------------------------\nQSharedPointer<ConnectivityInterface> tst_MasterSlavePathSearch::createInterfaceWithMemoryItem(\n    QString const& interfaceName, QString const& mode, QSharedPointer<ConnectivityComponent> containingInstance,\n    bool isHierarchical) const\n{\n    QString memoryType(\"memoryMap\");\n    if (mode.contains(PathSearchSpace::MASTERMODE, Qt::CaseInsensitive) ||\n        mode.contains(PathSearchSpace::INITIATORMODE, Qt::CaseInsensitive))\n    {\n        memoryType = \"addressSpace\";\n    }\n\n    QString memoryItemName = interfaceName + \"_\" + memoryType;\n    QSharedPointer<MemoryItem> testMemoryItem(new MemoryItem(memoryItemName, memoryType));\n\n    QSharedPointer<ConnectivityInterface> testInterface(new ConnectivityInterface(interfaceName));\n    testInterface->setConnectedMemory(testMemoryItem);\n    testInterface->setMode(General::str2Interfacemode(mode, General::INTERFACE_MODE_COUNT));\n    if (containingInstance)\n    {\n        testInterface->setInstance(containingInstance);\n    }\n    if (isHierarchical)\n    {\n        testInterface->setHierarchical();\n    }\n\n    return testInterface;\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_MasterSlavePathSearch::createTargetInterfaceWithConnectedSubspaceMap()\n//-----------------------------------------------------------------------------\nQSharedPointer<ConnectivityInterface> tst_MasterSlavePathSearch::createTargetInterfaceWithConnectedSubspaceMap(\n    QString const& interfaceName,\n    QSharedPointer<ConnectivityComponent> containingInstance,\n    QString const& connectedInitiatorName,\n    bool hierarchical) const\n{\n    QSharedPointer<ConnectivityInterface> testBridgeTarget = createInterfaceWithMemoryItem(interfaceName, PathSearchSpace::TARGETMODE, containingInstance, hierarchical);\n\n    QString subspaceType = \"subspaceMap\";\n    QString subspaceMapName = interfaceName + \"_\" + subspaceType;\n\n    QSharedPointer<MemoryItem> testSubspace(new MemoryItem(subspaceMapName, subspaceType));\n    testSubspace->setInitiatorReference(connectedInitiatorName);\n\n    testBridgeTarget->getConnectedMemory()->addChild(testSubspace);\n    return testBridgeTarget;\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_MasterSlavePathSearch::addLocalConnection()\n//-----------------------------------------------------------------------------\nvoid tst_MasterSlavePathSearch::addLocalConnection(QSharedPointer<ConnectivityInterface> masterInterface)\n{\n    if (General::interfaceMode2Str(masterInterface->getMode()) != PathSearchSpace::MASTERMODE)\n    {\n        return;\n    }\n\n    QString localConnectionName = masterInterface->getName() + QStringLiteral(\"_to_local_memory_map_\");\n\n    QSharedPointer<ConnectivityConnection> localConnection(\n        new ConnectivityConnection(localConnectionName, masterInterface, masterInterface));\n    testGraph_->getConnections().append(localConnection);\n}\n\nQTEST_APPLESS_MAIN(tst_MasterSlavePathSearch)\n\n#include \"tst_MasterSlavePathSearch.moc\"\n"
  },
  {
    "path": "tests/Core/tst_MasterSlavePathSearch.pri",
    "content": "# ----------------------------------------------------\n# This file is generated by the Qt Visual Studio Add-in.\n# ------------------------------------------------------\n\nHEADERS += ../../editors/MemoryDesigner/ConnectivityComponent.h \\\n    ../../editors/MemoryDesigner/ConnectivityConnection.h \\\n    ../../editors/MemoryDesigner/ConnectivityGraph.h \\\n    ../../editors/MemoryDesigner/ConnectivityInterface.h \\\n    ../../editors/MemoryDesigner/MasterSlavePathSearch.h \\\n    ../../editors/MemoryDesigner/MemoryItem.h\nSOURCES += ../../editors/MemoryDesigner/ConnectivityComponent.cpp \\\n    ../../editors/MemoryDesigner/ConnectivityConnection.cpp \\\n    ../../editors/MemoryDesigner/ConnectivityGraph.cpp \\\n    ../../editors/MemoryDesigner/ConnectivityInterface.cpp \\\n    ../../editors/MemoryDesigner/MasterSlavePathSearch.cpp \\\n    ../../editors/MemoryDesigner/MemoryItem.cpp \\\n    ./tst_MasterSlavePathSearch.cpp\n"
  },
  {
    "path": "tests/Core/tst_MasterSlavePathSearch.pro",
    "content": "#-----------------------------------------------------------------------------\n# File: tst_MasterSlavePathSearch.pro\n#-----------------------------------------------------------------------------\n# Project: Kactus 2\n# Author: Mikko Teuho\n# Date: 26.03.2018\n#\n# Description:\n# Qt project file for running unit tests in memory designer.\n#-----------------------------------------------------------------------------\n\nTEMPLATE = app\n\nTARGET = tst_MasterSlavePathSearch\n\nQT += core xml gui testlib\nCONFIG += c++11 testcase console\n\nwin32:CONFIG(release, debug|release) {\n    LIBS += -L$$PWD/../../executable/ -lIPXACTmodels\n    DESTDIR = ./release\n}\nelse:win32:CONFIG(debug, debug|release) {\n    LIBS += -L$$PWD/../../executable/ -lIPXACTmodelsd\n    DESTDIR = ./debug\n}\nelse:unix {\n    LIBS += -L$$PWD/../../executable/ -lIPXACTmodels\n    DESTDIR = ./release\n}\n\nINCLUDEPATH += $$PWD/../../\nINCLUDEPATH += $$DESTDIR\n\nDEPENDPATH += $$PWD/../../\nDEPENDPATH += .\n\nOBJECTS_DIR += $$DESTDIR\n\nMOC_DIR += ./generatedFiles\nUI_DIR += ./generatedFiles\nRCC_DIR += ./generatedFiles\ninclude(tst_MasterSlavePathSearch.pri)\n"
  },
  {
    "path": "tests/Core/tst_MemoryMapGraphItem.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: tst_MemoryMapGraphItem.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Esko Pekkarinen\r\n// Date: 14.04.2015\r\n//\r\n// Description:\r\n// Unit test for class MemoryMapGraphItem.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include <QtTest>\r\n\r\n#include <editors/ComponentEditor/memoryMaps/memoryMapsVisualizer/addressblockgraphitem.h>\r\n#include <editors/ComponentEditor/memoryMaps/memoryMapsVisualizer/memorymapgraphitem.h>\r\n#include <editors/ComponentEditor/visualization/memorygapitem.h>\r\n\r\n#include <KactusAPI/include/NullParser.h>\r\n#include <KactusAPI/include/SystemVerilogExpressionParser.h>\r\n\r\n#include <IPXACTmodels/Component/AddressBlock.h>\r\n#include <IPXACTmodels/Component/MemoryMap.h>\r\n#include <IPXACTmodels/Component/MemoryBlockBase.h>\r\n\r\nclass tst_MemoryMapGraphItem : public QObject\r\n{\r\n    Q_OBJECT\r\n\r\npublic:\r\n    tst_MemoryMapGraphItem();\r\n    \r\nprivate slots:\r\n\r\n    void testConstructor();\r\n\r\n    void testMemoryMapWithAddressBlock();\r\n    \r\n    void testMemoryMapWithConsecutiveAddressBlocks();\r\n  \r\n    void testGapBetweenTwoAddressBlocks();\r\n\r\n    void testPartiallyOverlappingAddressBlocks();\r\n\r\n    void testFullyOverlappingAddressBlocks();\r\n\r\n    void testMultipleBlocksOverlapping();\r\n\r\n    void testTwoBlocksCompletelyOverlappingThird();\r\n\r\n    void testTwoOverlappingBlocksInsideThrid();\r\n\r\n    void testIdenticalBlocksOverlappingThird();\r\n\r\n    void testConsecutiveBlocksInsideThird();\r\n\r\n    void testExpressions();\r\n\r\nprivate:\r\n    MemoryMapGraphItem* createMemoryBlockBase(QSharedPointer<MemoryMap> memoryMap);\r\n\r\n    QSharedPointer<AddressBlock> createAddressBlock(QString const& name, QString const& baseAddress, QString const& range, int bitWidth);\r\n\r\n    void expandItem(MemoryMapGraphItem* memoryMapItem);\r\n\r\n    QList<MemoryGapItem*> findMemoryGaps(MemoryMapGraphItem* memoryMapItem);\r\n   \r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_MemoryMapGraphItem::tst_MemoryMapGraphItem()\r\n//-----------------------------------------------------------------------------\r\ntst_MemoryMapGraphItem::tst_MemoryMapGraphItem()\r\n{\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_MemoryMapGraphItem::testConstructor()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_MemoryMapGraphItem::testConstructor()\r\n{\r\n    QSharedPointer<MemoryMap> memoryMap(new MemoryMap());\r\n    memoryMap->setName(\"testMap\");\r\n    memoryMap->setAddressUnitBits(\"8\");\r\n\r\n    MemoryMapGraphItem* memoryMapItem = createMemoryBlockBase(memoryMap);\r\n\r\n    QCOMPARE(memoryMapItem->name(), QString(\"testMap\"));\r\n    QCOMPARE(memoryMapItem->getOffset(), quint64(0));\r\n    QCOMPARE(memoryMapItem->getLastAddress(), quint64(0));\r\n    QCOMPARE(memoryMapItem->getDisplayOffset(), quint64(0));\r\n    QCOMPARE(memoryMapItem->getDisplayLastAddress(), quint64(0));\r\n\r\n    QCOMPARE(memoryMapItem->getAddressUnitSize(), uint(8));\r\n    QCOMPARE(memoryMapItem->getBitWidth(), 0);\r\n\r\n    QCOMPARE(memoryMapItem->pos().y(), qreal(0));\r\n\r\n    delete memoryMapItem;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_MemoryMapGraphItem::testMemoryMapWithAddressBlock()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_MemoryMapGraphItem::testMemoryMapWithAddressBlock()\r\n{\r\n    QSharedPointer<MemoryMap> memoryMap(new MemoryMap());\r\n    memoryMap->setName(\"testMap\");\r\n    memoryMap->setAddressUnitBits(\"8\");\r\n\r\n    QSharedPointer<AddressBlock> addressBlock = createAddressBlock(\"testAddressBlock\", \"8\", \"1\", 8);\r\n\r\n    QList<QSharedPointer<MemoryBlockBase> > addressBlocks;\r\n    addressBlocks.append(addressBlock);\r\n    memoryMap->getMemoryBlocks()->append(addressBlocks);\r\n    \r\n    MemoryMapGraphItem* memoryMapItem = createMemoryBlockBase(memoryMap);\r\n\r\n    QSharedPointer<ExpressionParser> noParser(new NullParser());\r\n\r\n    AddressBlockGraphItem* addressBlockItem = new AddressBlockGraphItem(addressBlock, noParser, memoryMapItem);\r\n    memoryMapItem->addChild(addressBlockItem);\r\n    \r\n    memoryMapItem->updateDisplay();\r\n    memoryMapItem->redoChildLayout();\r\n\r\n    QCOMPARE(memoryMapItem->name(), QString(\"testMap\"));\r\n    QCOMPARE(memoryMapItem->getOffset(), quint64(8));\r\n    QCOMPARE(memoryMapItem->getLastAddress(), quint64(8));\r\n    QCOMPARE(memoryMapItem->getDisplayOffset(), quint64(8));\r\n    QCOMPARE(memoryMapItem->getDisplayLastAddress(), quint64(8));\r\n\r\n    QVERIFY(!addressBlockItem->isVisible());\r\n\r\n    expandItem(memoryMapItem);\r\n\r\n    QVERIFY(addressBlockItem->isVisible());\r\n    QVERIFY(!addressBlockItem->isConflicted());\r\n    QCOMPARE(addressBlockItem->pos().x(), qreal(MemoryVisualizationItem::CHILD_INDENTATION));\r\n    QCOMPARE(addressBlockItem->pos().y(), qreal(VisualizerItem::DEFAULT_HEIGHT));\r\n\r\n    delete memoryMapItem;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_MemoryMapGraphItem::testMemoryMapWithConsecutiveAddressBlocks()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_MemoryMapGraphItem::testMemoryMapWithConsecutiveAddressBlocks()\r\n{\r\n    QSharedPointer<MemoryMap> memoryMap(new MemoryMap());\r\n    memoryMap->setAddressUnitBits(\"8\");\r\n\r\n    QSharedPointer<AddressBlock> firstBlock = createAddressBlock(\"firstAddressBlock\", \"0\", \"1\", 8);\r\n    QSharedPointer<AddressBlock> secondBlock = createAddressBlock(\"secondAddressBlock\", \"1\", \"1\", 8);\r\n\r\n    QList<QSharedPointer<MemoryBlockBase> > addressBlocks;\r\n    addressBlocks.append(firstBlock);\r\n    addressBlocks.append(secondBlock);\r\n    memoryMap->getMemoryBlocks()->append(addressBlocks);\r\n\r\n    MemoryMapGraphItem* memoryMapItem = createMemoryBlockBase(memoryMap);\r\n\r\n    QSharedPointer<ExpressionParser> noParser(new NullParser());\r\n\r\n    AddressBlockGraphItem* firstBlockItem = new AddressBlockGraphItem(firstBlock, noParser, memoryMapItem);\r\n    AddressBlockGraphItem* secondBlockItem = new AddressBlockGraphItem(secondBlock, noParser, memoryMapItem);\r\n    memoryMapItem->addChild(firstBlockItem);\r\n    memoryMapItem->addChild(secondBlockItem);\r\n\r\n    memoryMapItem->updateDisplay();\r\n    memoryMapItem->redoChildLayout();\r\n\r\n    QCOMPARE(memoryMapItem->getOffset(), quint64(0));\r\n    QCOMPARE(memoryMapItem->getLastAddress(), quint64(1));\r\n    QCOMPARE(memoryMapItem->getDisplayOffset(), quint64(0));\r\n    QCOMPARE(memoryMapItem->getDisplayLastAddress(), quint64(1));\r\n\r\n    expandItem(memoryMapItem);\r\n\r\n    QVERIFY(firstBlockItem->isVisible());\r\n    QCOMPARE(firstBlockItem->pos().x(), qreal(MemoryVisualizationItem::CHILD_INDENTATION));\r\n    QCOMPARE(firstBlockItem->pos().y(), qreal(VisualizerItem::DEFAULT_HEIGHT));\r\n\r\n    QVERIFY(secondBlockItem->isVisible());\r\n    QCOMPARE(secondBlockItem->pos().x(), qreal(MemoryVisualizationItem::CHILD_INDENTATION));\r\n    QCOMPARE(secondBlockItem->pos().y(), qreal(2*VisualizerItem::DEFAULT_HEIGHT));\r\n\r\n    delete memoryMapItem;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_MemoryMapGraphItem::testGapBetweenTwoAddressBlocks()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_MemoryMapGraphItem::testGapBetweenTwoAddressBlocks()\r\n{\r\n    QSharedPointer<MemoryMap> memoryMap(new MemoryMap());\r\n    memoryMap->setAddressUnitBits(\"8\");\r\n\r\n    QSharedPointer<AddressBlock> firstBlock = createAddressBlock(\"firstAddressBlock\", \"0\", \"1\", 8);\r\n    QSharedPointer<AddressBlock> lastBlock = createAddressBlock(\"lastAddressBlock\", \"2\", \"1\", 8);\r\n\r\n    QList<QSharedPointer<MemoryBlockBase> > addressBlocks;\r\n    addressBlocks.append(firstBlock);\r\n    addressBlocks.append(lastBlock);\r\n    memoryMap->getMemoryBlocks()->append(addressBlocks);\r\n\r\n    MemoryMapGraphItem* memoryMapItem = createMemoryBlockBase(memoryMap);\r\n\r\n    QSharedPointer<ExpressionParser> noParser(new NullParser());\r\n\r\n    AddressBlockGraphItem* firstBlockItem = new AddressBlockGraphItem(firstBlock, noParser, memoryMapItem);\r\n    AddressBlockGraphItem* secondBlockItem = new AddressBlockGraphItem(lastBlock, noParser, memoryMapItem);\r\n    memoryMapItem->addChild(firstBlockItem);\r\n    memoryMapItem->addChild(secondBlockItem);\r\n\r\n    memoryMapItem->redoChildLayout();   \r\n\r\n    expandItem(memoryMapItem);\r\n\r\n    QVERIFY(firstBlockItem->isVisible());\r\n    QCOMPARE(firstBlockItem->pos().x(), qreal(MemoryVisualizationItem::CHILD_INDENTATION));\r\n    QCOMPARE(firstBlockItem->pos().y(), qreal(VisualizerItem::DEFAULT_HEIGHT));\r\n    QCOMPARE(firstBlockItem->getDisplayOffset(), quint64(0));\r\n    QCOMPARE(firstBlockItem->getDisplayLastAddress(), quint64(0));\r\n\r\n    MemoryGapItem* gap = findMemoryGaps(memoryMapItem).first();\r\n\r\n    QVERIFY(gap->isVisible());\r\n    QVERIFY(!gap->isConflicted());\r\n    QCOMPARE(gap->name(), QString(\"Reserved\"));\r\n    QCOMPARE(gap->pos().x(), qreal(MemoryVisualizationItem::CHILD_INDENTATION));\r\n    QCOMPARE(gap->pos().y(), qreal(2*VisualizerItem::DEFAULT_HEIGHT));\r\n    QCOMPARE(gap->getDisplayOffset(), quint64(1));\r\n    QCOMPARE(gap->getDisplayLastAddress(), quint64(1));\r\n\r\n    QVERIFY(secondBlockItem->isVisible());\r\n    QCOMPARE(secondBlockItem->pos().x(), qreal(MemoryVisualizationItem::CHILD_INDENTATION));\r\n    QCOMPARE(secondBlockItem->pos().y(), qreal(3*VisualizerItem::DEFAULT_HEIGHT));\r\n    QCOMPARE(secondBlockItem->getDisplayOffset(), quint64(2));\r\n    QCOMPARE(secondBlockItem->getDisplayLastAddress(), quint64(2));\r\n\r\n    delete memoryMapItem;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_MemoryMapGraphItem::testPartiallyOverlappingAddressBlocks()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_MemoryMapGraphItem::testPartiallyOverlappingAddressBlocks()\r\n{\r\n    QSharedPointer<MemoryMap> memoryMap(new MemoryMap());\r\n    memoryMap->setAddressUnitBits(\"8\");\r\n\r\n    QSharedPointer<AddressBlock> firstBlock = createAddressBlock(\"firstAddressBlock\", \"0\", \"2\", 8);\r\n    QSharedPointer<AddressBlock> secondBlock = createAddressBlock(\"secondAddressBlock\", \"1\", \"2\", 8);\r\n\r\n    QList<QSharedPointer<MemoryBlockBase> > addressBlocks;\r\n    addressBlocks.append(firstBlock);\r\n    addressBlocks.append(secondBlock);\r\n    memoryMap->getMemoryBlocks()->append(addressBlocks);\r\n\r\n    MemoryMapGraphItem* memoryMapItem = createMemoryBlockBase(memoryMap);\r\n\r\n    QSharedPointer<ExpressionParser> noParser(new NullParser());\r\n\r\n    AddressBlockGraphItem* firstBlockItem = new AddressBlockGraphItem(firstBlock, noParser, memoryMapItem);\r\n    firstBlockItem->setAddressableUnitBits(8);\r\n\r\n    AddressBlockGraphItem* secondBlockItem = new AddressBlockGraphItem(secondBlock, noParser, memoryMapItem);\r\n    secondBlockItem->setAddressableUnitBits(8);\r\n\r\n    memoryMapItem->addChild(firstBlockItem);\r\n    memoryMapItem->addChild(secondBlockItem);\r\n\r\n    memoryMapItem->updateDisplay();\r\n    memoryMapItem->redoChildLayout();\r\n\r\n    expandItem(memoryMapItem);\r\n\r\n    QVERIFY(firstBlockItem->isVisible());\r\n    QCOMPARE(firstBlockItem->pos().x(), qreal(MemoryVisualizationItem::CHILD_INDENTATION));\r\n    QCOMPARE(firstBlockItem->pos().y(), qreal(VisualizerItem::DEFAULT_HEIGHT));\r\n    QCOMPARE(firstBlockItem->getDisplayOffset(), quint64(0));\r\n    QCOMPARE(firstBlockItem->getDisplayLastAddress(), quint64(1));\r\n\r\n    QVERIFY(secondBlockItem->isVisible());\r\n    QCOMPARE(secondBlockItem->pos().x(), qreal(MemoryVisualizationItem::CHILD_INDENTATION));\r\n    QCOMPARE(secondBlockItem->pos().y(), qreal(2*VisualizerItem::DEFAULT_HEIGHT));\r\n    QCOMPARE(secondBlockItem->getDisplayOffset(), quint64(1));\r\n    QCOMPARE(secondBlockItem->getDisplayLastAddress(), quint64(2));\r\n\r\n    delete memoryMapItem;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_MemoryMapGraphItem::testFullyOverlappingAddressBlocks()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_MemoryMapGraphItem::testFullyOverlappingAddressBlocks()\r\n{\r\n    QSharedPointer<MemoryMap> memoryMap(new MemoryMap());\r\n    memoryMap->setAddressUnitBits(\"8\");\r\n\r\n    QSharedPointer<AddressBlock> firstBlock = createAddressBlock(\"firstAddressBlock\", \"0\", \"1\", 8);\r\n    QSharedPointer<AddressBlock> secondBlock = createAddressBlock(\"secondAddressBlock\", \"0\", \"1\", 8);\r\n\r\n    QList<QSharedPointer<MemoryBlockBase> > addressBlocks;\r\n    addressBlocks.append(firstBlock);\r\n    addressBlocks.append(secondBlock);\r\n    memoryMap->getMemoryBlocks()->append(addressBlocks);\r\n\r\n    MemoryMapGraphItem* memoryMapItem = createMemoryBlockBase(memoryMap);\r\n\r\n    QSharedPointer<ExpressionParser> noParser(new NullParser());\r\n\r\n    AddressBlockGraphItem* firstBlockItem = new AddressBlockGraphItem(firstBlock, noParser, memoryMapItem);\r\n    AddressBlockGraphItem* secondBlockItem = new AddressBlockGraphItem(secondBlock, noParser, memoryMapItem);\r\n    memoryMapItem->addChild(firstBlockItem);\r\n    memoryMapItem->addChild(secondBlockItem);\r\n\r\n    memoryMapItem->redoChildLayout();\r\n\r\n    expandItem(memoryMapItem);\r\n\r\n    QVERIFY(firstBlockItem->isVisible());\r\n    QCOMPARE(firstBlockItem->pos().x(), qreal(MemoryVisualizationItem::CHILD_INDENTATION));\r\n    QCOMPARE(firstBlockItem->pos().y(), qreal(2*VisualizerItem::DEFAULT_HEIGHT));\r\n    QCOMPARE(firstBlockItem->getDisplayOffset(), quint64(0));\r\n    QCOMPARE(firstBlockItem->getDisplayLastAddress(), quint64(0));\r\n\r\n    QVERIFY(secondBlockItem->isVisible());\r\n    QCOMPARE(secondBlockItem->pos().x(), qreal(MemoryVisualizationItem::CHILD_INDENTATION));\r\n    QCOMPARE(secondBlockItem->pos().y(), qreal(VisualizerItem::DEFAULT_HEIGHT));\r\n    QCOMPARE(secondBlockItem->getDisplayOffset(), quint64(0));\r\n    QCOMPARE(secondBlockItem->getDisplayLastAddress(), quint64(0));\r\n\r\n    delete memoryMapItem;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_MemoryMapGraphItem::testMultipleBlocksOverlapping()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_MemoryMapGraphItem::testMultipleBlocksOverlapping()\r\n{\r\n    QSharedPointer<MemoryMap> memoryMap(new MemoryMap());\r\n    memoryMap->setName(\"testMap\");\r\n    memoryMap->setAddressUnitBits(\"8\");\r\n\r\n    QSharedPointer<AddressBlock> largeBlock = createAddressBlock(\"largeAddressBlock\", \"0\", \"4\", 8);\r\n    QSharedPointer<AddressBlock> firstOverlappingBlock = createAddressBlock(\"firstOverlap\", \"1\", \"1\", 8);\r\n    QSharedPointer<AddressBlock> seconOverlappingBlock = createAddressBlock(\"secondOverlap\", \"3\", \"1\", 8);\r\n\r\n    QList<QSharedPointer<MemoryBlockBase> > addressBlocks;\r\n    addressBlocks.append(largeBlock);\r\n    addressBlocks.append(firstOverlappingBlock);\r\n    addressBlocks.append(seconOverlappingBlock);\r\n    memoryMap->getMemoryBlocks()->append(addressBlocks);\r\n\r\n    MemoryMapGraphItem* memoryMapItem = createMemoryBlockBase(memoryMap);\r\n\r\n    QSharedPointer<ExpressionParser> noParser(new NullParser());\r\n\r\n    AddressBlockGraphItem* largeAddressBlock = new AddressBlockGraphItem(largeBlock, noParser, memoryMapItem);\r\n    AddressBlockGraphItem* firstOverlap = new AddressBlockGraphItem(firstOverlappingBlock, noParser, memoryMapItem);\r\n    AddressBlockGraphItem* secondOverlap = new AddressBlockGraphItem(seconOverlappingBlock, noParser, memoryMapItem);\r\n    memoryMapItem->addChild(largeAddressBlock);\r\n    memoryMapItem->addChild(firstOverlap);\r\n    memoryMapItem->addChild(secondOverlap);\r\n\r\n    memoryMapItem->redoChildLayout();\r\n\r\n    expandItem(memoryMapItem);\r\n\r\n    QList<MemoryGapItem*> conflictedAreas = findMemoryGaps(memoryMapItem);\r\n    QCOMPARE(conflictedAreas.count(), 0);\r\n\r\n    QVERIFY(largeAddressBlock->isVisible());\r\n    QVERIFY(largeAddressBlock->isConflicted());\r\n    QCOMPARE(largeAddressBlock->pos().x(), qreal(MemoryVisualizationItem::CHILD_INDENTATION));\r\n    QCOMPARE(largeAddressBlock->pos().y(), qreal(VisualizerItem::DEFAULT_HEIGHT));\r\n    QCOMPARE(largeAddressBlock->getDisplayOffset(), quint64(0));\r\n    QCOMPARE(largeAddressBlock->getDisplayLastAddress(), quint64(3));\r\n\r\n    QVERIFY(firstOverlap->isVisible());  \r\n    QVERIFY(firstOverlap->isConflicted());\r\n    QCOMPARE(firstOverlap->pos().x(), qreal(MemoryVisualizationItem::CHILD_INDENTATION));\r\n    QCOMPARE(firstOverlap->pos().y(), qreal(2*VisualizerItem::DEFAULT_HEIGHT));\r\n    QCOMPARE(firstOverlap->getDisplayOffset(), quint64(1));\r\n    QCOMPARE(firstOverlap->getDisplayLastAddress(), quint64(1));\r\n\r\n    QVERIFY(secondOverlap->isVisible());\r\n    QVERIFY(secondOverlap->isConflicted());\r\n    QCOMPARE(secondOverlap->pos().x(), qreal(MemoryVisualizationItem::CHILD_INDENTATION));\r\n    QCOMPARE(secondOverlap->pos().y(), qreal(3*VisualizerItem::DEFAULT_HEIGHT));\r\n    QCOMPARE(secondOverlap->getDisplayOffset(), quint64(3));\r\n    QCOMPARE(secondOverlap->getDisplayLastAddress(), quint64(3));\r\n\r\n    delete memoryMapItem;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_MemoryMapGraphItem::testTwoBlocksCompletelyOverlappingThird()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_MemoryMapGraphItem::testTwoBlocksCompletelyOverlappingThird()\r\n{\r\n    QSharedPointer<MemoryMap> memoryMap(new MemoryMap());\r\n    memoryMap->setName(\"testMap\");\r\n    memoryMap->setAddressUnitBits(\"8\");\r\n\r\n    QSharedPointer<AddressBlock> firstBlock = createAddressBlock(\"firstAddressBlock\", \"0\", \"2\", 8);\r\n    QSharedPointer<AddressBlock> overlappedBlock = createAddressBlock(\"overlappedBlock\", \"1\", \"2\", 8);\r\n    QSharedPointer<AddressBlock> lastBlock = createAddressBlock(\"secondAddressBlock\", \"2\", \"2\", 8);\r\n\r\n    QList<QSharedPointer<MemoryBlockBase> > addressBlocks;\r\n    addressBlocks.append(firstBlock);\r\n    addressBlocks.append(overlappedBlock);\r\n    addressBlocks.append(lastBlock);\r\n    memoryMap->getMemoryBlocks()->append(addressBlocks);\r\n\r\n    MemoryMapGraphItem* memoryMapItem = createMemoryBlockBase(memoryMap);\r\n\r\n    QSharedPointer<ExpressionParser> noParser(new NullParser());\r\n\r\n    AddressBlockGraphItem* firstBlockItem = new AddressBlockGraphItem(firstBlock, noParser, memoryMapItem);\r\n    AddressBlockGraphItem* overlappedItem = new AddressBlockGraphItem(overlappedBlock, noParser, memoryMapItem);\r\n    AddressBlockGraphItem* lastBlockItem = new AddressBlockGraphItem(lastBlock, noParser, memoryMapItem);\r\n    memoryMapItem->addChild(firstBlockItem);\r\n    memoryMapItem->addChild(lastBlockItem);\r\n    memoryMapItem->addChild(overlappedItem);\r\n\r\n    memoryMapItem->updateDisplay(); \r\n    memoryMapItem->redoChildLayout();\r\n\r\n    expandItem(memoryMapItem);\r\n\r\n    QList<MemoryGapItem*> conflictedAreas = findMemoryGaps(memoryMapItem);\r\n    QCOMPARE(conflictedAreas.count(), 0);\r\n\r\n    QVERIFY(firstBlockItem->isConflicted());\r\n    QCOMPARE(firstBlockItem->pos().x(), qreal(MemoryVisualizationItem::CHILD_INDENTATION));\r\n    QCOMPARE(firstBlockItem->pos().y(), qreal(VisualizerItem::DEFAULT_HEIGHT));\r\n    QCOMPARE(firstBlockItem->getDisplayOffset(), quint64(0));\r\n    QCOMPARE(firstBlockItem->getDisplayLastAddress(), quint64(1));\r\n\r\n    QVERIFY(overlappedItem->isConflicted());    \r\n    QCOMPARE(overlappedItem->pos().x(), qreal(MemoryVisualizationItem::CHILD_INDENTATION));\r\n    QCOMPARE(overlappedItem->pos().y(), qreal(2*VisualizerItem::DEFAULT_HEIGHT));\r\n \r\n    QCOMPARE(lastBlockItem->pos().x(), qreal(MemoryVisualizationItem::CHILD_INDENTATION));\r\n    QCOMPARE(lastBlockItem->pos().y(), qreal(3*VisualizerItem::DEFAULT_HEIGHT));\r\n    QCOMPARE(lastBlockItem->getDisplayOffset(), quint64(2));\r\n    QCOMPARE(lastBlockItem->getDisplayLastAddress(), quint64(3));\r\n\r\n    delete memoryMapItem;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_MemoryMapGraphItem::testTwoOverlappingBlocksInsideThrid()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_MemoryMapGraphItem::testTwoOverlappingBlocksInsideThrid()\r\n{\r\n    QSharedPointer<MemoryMap> memoryMap(new MemoryMap());\r\n    memoryMap->setName(\"testMap\");\r\n    memoryMap->setAddressUnitBits(\"8\");\r\n\r\n    QSharedPointer<AddressBlock> largeAddressBlock = createAddressBlock(\"containerBlock\", \"0\", \"4\", 8);\r\n    QSharedPointer<AddressBlock> firstOverlappingBlock = createAddressBlock(\"firstOverlap\", \"1\", \"2\", 8);\r\n    QSharedPointer<AddressBlock> secondOverlappingBlock = createAddressBlock(\"secondOverlap\", \"2\", \"2\", 8);\r\n\r\n    QList<QSharedPointer<MemoryBlockBase> > addressBlocks;\r\n    addressBlocks.append(largeAddressBlock);\r\n    addressBlocks.append(firstOverlappingBlock);\r\n    addressBlocks.append(secondOverlappingBlock);\r\n    memoryMap->getMemoryBlocks()->append(addressBlocks);\r\n\r\n    MemoryMapGraphItem* memoryMapItem = createMemoryBlockBase(memoryMap);\r\n\r\n    QSharedPointer<ExpressionParser> noParser(new NullParser());\r\n\r\n    AddressBlockGraphItem* containerBlock = new AddressBlockGraphItem(largeAddressBlock, noParser, memoryMapItem);\r\n    AddressBlockGraphItem* firstOverlap = new AddressBlockGraphItem(firstOverlappingBlock, noParser, memoryMapItem);\r\n    AddressBlockGraphItem* secondOverlap = new AddressBlockGraphItem(secondOverlappingBlock, noParser, memoryMapItem);\r\n    memoryMapItem->addChild(containerBlock);\r\n    memoryMapItem->addChild(firstOverlap);\r\n    memoryMapItem->addChild(secondOverlap);\r\n\r\n    memoryMapItem->redoChildLayout();\r\n\r\n    expandItem(memoryMapItem);\r\n\r\n    QList<MemoryGapItem*> conflictedAreas = findMemoryGaps(memoryMapItem);\r\n    QCOMPARE(conflictedAreas.count(), 0);\r\n\r\n    QVERIFY(containerBlock->isConflicted());\r\n    QCOMPARE(containerBlock->pos().x(), qreal(MemoryVisualizationItem::CHILD_INDENTATION));\r\n    QCOMPARE(containerBlock->pos().y(), qreal(VisualizerItem::DEFAULT_HEIGHT));\r\n    QCOMPARE(containerBlock->getDisplayOffset(), quint64(0));\r\n    QCOMPARE(containerBlock->getDisplayLastAddress(), quint64(3));\r\n\r\n    QVERIFY(firstOverlap->isConflicted());\r\n    QCOMPARE(firstOverlap->pos().x(), qreal(MemoryVisualizationItem::CHILD_INDENTATION));\r\n    QCOMPARE(firstOverlap->pos().y(), qreal(2*VisualizerItem::DEFAULT_HEIGHT));\r\n\r\n    QVERIFY(secondOverlap->isConflicted());    \r\n    QCOMPARE(secondOverlap->pos().x(), qreal(MemoryVisualizationItem::CHILD_INDENTATION));\r\n    QCOMPARE(secondOverlap->pos().y(), qreal(3*VisualizerItem::DEFAULT_HEIGHT));\r\n\r\n    delete memoryMapItem;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_MemoryMapGraphItem::testIdenticalBlocksOverlappingThird()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_MemoryMapGraphItem::testIdenticalBlocksOverlappingThird()\r\n{\r\n    QSharedPointer<MemoryMap> memoryMap(new MemoryMap());\r\n    memoryMap->setAddressUnitBits(\"8\");\r\n\r\n    QSharedPointer<AddressBlock> uniqueBlock = createAddressBlock(\"unique\", \"0\", \"2\", 8);\r\n    QSharedPointer<AddressBlock> twin1 = createAddressBlock(\"firstTwin\", \"1\", \"2\", 8);\r\n    QSharedPointer<AddressBlock> twin2 = createAddressBlock(\"secondTwin\", \"1\", \"2\", 8);\r\n\r\n    QList<QSharedPointer<MemoryBlockBase> > addressBlocks;\r\n    addressBlocks.append(uniqueBlock);\r\n    addressBlocks.append(twin1);\r\n    addressBlocks.append(twin2);\r\n    memoryMap->getMemoryBlocks()->append(addressBlocks);\r\n\r\n    MemoryMapGraphItem* memoryMapItem = createMemoryBlockBase(memoryMap);\r\n\r\n    QSharedPointer<ExpressionParser> noParser(new NullParser());\r\n\r\n    AddressBlockGraphItem* unique = new AddressBlockGraphItem(uniqueBlock, noParser, memoryMapItem);\r\n    unique->setAddressableUnitBits(8);\r\n\r\n    AddressBlockGraphItem* firstTwin = new AddressBlockGraphItem(twin1, noParser, memoryMapItem);\r\n    firstTwin->setAddressableUnitBits(8);\r\n\r\n    AddressBlockGraphItem* secondTwin = new AddressBlockGraphItem(twin2, noParser, memoryMapItem);\r\n    secondTwin->setAddressableUnitBits(8);\r\n\r\n    memoryMapItem->addChild(unique);\r\n    memoryMapItem->addChild(firstTwin);\r\n    memoryMapItem->addChild(secondTwin);\r\n\r\n    memoryMapItem->redoChildLayout();\r\n\r\n    expandItem(memoryMapItem);\r\n\r\n    QList<MemoryGapItem*> conflictedAreas = findMemoryGaps(memoryMapItem);\r\n    QCOMPARE(conflictedAreas.count(), 0);\r\n\r\n    QVERIFY(unique->isConflicted());\r\n    QCOMPARE(unique->pos().x(), qreal(MemoryVisualizationItem::CHILD_INDENTATION));\r\n    QCOMPARE(unique->pos().y(), qreal(VisualizerItem::DEFAULT_HEIGHT));\r\n    QCOMPARE(unique->getDisplayOffset(), quint64(0));\r\n    QCOMPARE(unique->getDisplayLastAddress(), quint64(1));\r\n\r\n    QVERIFY(firstTwin->isConflicted());\r\n    QCOMPARE(firstTwin->pos().x(), qreal(MemoryVisualizationItem::CHILD_INDENTATION));\r\n    QCOMPARE(firstTwin->pos().y(), qreal(3*VisualizerItem::DEFAULT_HEIGHT));\r\n    QCOMPARE(firstTwin->getDisplayOffset(), quint64(1));\r\n    QCOMPARE(firstTwin->getDisplayLastAddress(), quint64(2));\r\n\r\n    QVERIFY(secondTwin->isConflicted());    \r\n    QCOMPARE(secondTwin->pos().x(), qreal(MemoryVisualizationItem::CHILD_INDENTATION));\r\n    QCOMPARE(secondTwin->pos().y(), qreal(2*VisualizerItem::DEFAULT_HEIGHT));\r\n    QCOMPARE(secondTwin->getDisplayOffset(), quint64(1));\r\n    QCOMPARE(secondTwin->getDisplayLastAddress(), quint64(2));\r\n\r\n    delete memoryMapItem;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_MemoryMapGraphItem::testConsecutiveBlocksInsideThird()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_MemoryMapGraphItem::testConsecutiveBlocksInsideThird()\r\n{\r\n    QSharedPointer<MemoryMap> memoryMap(new MemoryMap());\r\n    memoryMap->setAddressUnitBits(\"8\");\r\n\r\n    QSharedPointer<AddressBlock> containerBlock = createAddressBlock(\"container\", \"0\", \"5\", 8);\r\n    QSharedPointer<AddressBlock> firstInsideBlock = createAddressBlock(\"firstInsider\", \"1\", \"2\", 8);\r\n    QSharedPointer<AddressBlock> secondInsideBlock = createAddressBlock(\"secondInsider\", \"3\", \"2\", 8);\r\n\r\n    QList<QSharedPointer<MemoryBlockBase> > addressBlocks;\r\n    addressBlocks.append(containerBlock);\r\n    addressBlocks.append(firstInsideBlock);\r\n    addressBlocks.append(secondInsideBlock);\r\n    memoryMap->getMemoryBlocks()->append(addressBlocks);\r\n\r\n    MemoryMapGraphItem* memoryMapItem = createMemoryBlockBase(memoryMap);\r\n\r\n    QSharedPointer<ExpressionParser> noParser(new NullParser());\r\n\r\n    AddressBlockGraphItem* container = new AddressBlockGraphItem(containerBlock, noParser, memoryMapItem);\r\n    AddressBlockGraphItem* firstInsider = new AddressBlockGraphItem(firstInsideBlock, noParser, memoryMapItem);\r\n    AddressBlockGraphItem* secondInsider = new AddressBlockGraphItem(secondInsideBlock, noParser, memoryMapItem);\r\n    memoryMapItem->addChild(container);\r\n    memoryMapItem->addChild(firstInsider);\r\n    memoryMapItem->addChild(secondInsider);\r\n\r\n    memoryMapItem->redoChildLayout();\r\n\r\n    expandItem(memoryMapItem);\r\n\r\n    QList<MemoryGapItem*> conflictedAreas = findMemoryGaps(memoryMapItem);\r\n    QCOMPARE(conflictedAreas.count(), 0);\r\n\r\n    QVERIFY(container->isConflicted());\r\n    QCOMPARE(container->pos().x(), qreal(MemoryVisualizationItem::CHILD_INDENTATION));\r\n    QCOMPARE(container->pos().y(), qreal(VisualizerItem::DEFAULT_HEIGHT));\r\n    QCOMPARE(container->getDisplayOffset(), quint64(0));\r\n    QCOMPARE(container->getDisplayLastAddress(), quint64(4));\r\n\r\n    QVERIFY(firstInsider->isConflicted());\r\n    QCOMPARE(firstInsider->pos().x(), qreal(MemoryVisualizationItem::CHILD_INDENTATION));\r\n    QCOMPARE(firstInsider->pos().y(), qreal(2*VisualizerItem::DEFAULT_HEIGHT));\r\n    QCOMPARE(firstInsider->getDisplayOffset(), quint64(1));\r\n    QCOMPARE(firstInsider->getDisplayLastAddress(), quint64(2));\r\n\r\n    QVERIFY(secondInsider->isConflicted());    \r\n    QCOMPARE(secondInsider->pos().x(), qreal(MemoryVisualizationItem::CHILD_INDENTATION));\r\n    QCOMPARE(secondInsider->pos().y(), qreal(3*VisualizerItem::DEFAULT_HEIGHT));\r\n    QCOMPARE(secondInsider->getDisplayOffset(), quint64(3));\r\n    QCOMPARE(secondInsider->getDisplayLastAddress(), quint64(4));\r\n\r\n    delete memoryMapItem;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_MemoryMapGraphItem::testExpressions()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_MemoryMapGraphItem::testExpressions()\r\n{\r\n    QSharedPointer<MemoryMap> memoryMap(new MemoryMap());\r\n    memoryMap->setAddressUnitBits(\"8\");\r\n\r\n    QSharedPointer<AddressBlock> parametrizedBlock = createAddressBlock(\"container\", \"'h2\", \"'h2+'h2\", 8);\r\n\r\n    QList<QSharedPointer<MemoryBlockBase> > addressBlocks;\r\n    addressBlocks.append(parametrizedBlock);\r\n    memoryMap->getMemoryBlocks()->append(addressBlocks);\r\n\r\n    QSharedPointer<ExpressionParser> expressionParser(new SystemVerilogExpressionParser());\r\n\r\n    MemoryMapGraphItem* memoryMapItem = new MemoryMapGraphItem(memoryMap, memoryMap, expressionParser, 0);\r\n\r\n    AddressBlockGraphItem* parametrizedItem = new AddressBlockGraphItem(parametrizedBlock, expressionParser, memoryMapItem);\r\n    memoryMapItem->addChild(parametrizedItem);\r\n    \r\n    memoryMapItem->updateDisplay();    \r\n\r\n    QCOMPARE(memoryMapItem->getDisplayOffset(), quint64(2));\r\n    QCOMPARE(memoryMapItem->getDisplayLastAddress(), quint64(5));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_MemoryMapGraphItem::createMemoryBlockBase()\r\n//-----------------------------------------------------------------------------\r\nMemoryMapGraphItem* tst_MemoryMapGraphItem::createMemoryBlockBase(QSharedPointer<MemoryMap> memoryMap)\r\n{\r\n    QSharedPointer<ExpressionParser> expressionParser(new SystemVerilogExpressionParser());\r\n    MemoryMapGraphItem* memoryMapItem = new MemoryMapGraphItem(memoryMap, memoryMap, expressionParser, 0);\r\n    memoryMapItem->updateDisplay();\r\n\r\n    return memoryMapItem;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_MemoryMapGraphItem::createAddressBlock()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<AddressBlock> tst_MemoryMapGraphItem::createAddressBlock(QString const& name, \r\n    QString const& baseAddress, QString const& range, int bitWidth)\r\n{\r\n    QSharedPointer<AddressBlock> addressBlock(new AddressBlock());\r\n    addressBlock->setName(name);\r\n    addressBlock->setBaseAddress(baseAddress);\r\n    addressBlock->setRange(range);\r\n    addressBlock->setWidth(QString::number(bitWidth));\r\n\r\n    return addressBlock;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_MemoryMapGraphItem::expandItem()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_MemoryMapGraphItem::expandItem(MemoryMapGraphItem* memoryMapItem)\r\n{\r\n    GraphicsExpandCollapseItem* expander(0);\r\n    foreach (QGraphicsItem* item, memoryMapItem->childItems())\r\n    {\r\n        if (dynamic_cast<GraphicsExpandCollapseItem*>(item) != 0)\r\n        {\r\n            expander = dynamic_cast<GraphicsExpandCollapseItem*>(item);\r\n            expander->expand();\r\n            return;\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_MemoryMapGraphItem::findMemoryGap()\r\n//-----------------------------------------------------------------------------\r\nQList<MemoryGapItem*> tst_MemoryMapGraphItem::findMemoryGaps(MemoryMapGraphItem* memoryMapItem)\r\n{\r\n    QList<MemoryGapItem*> gaps;\r\n    foreach (QGraphicsItem* child, memoryMapItem->childItems())\r\n    {\r\n        if (dynamic_cast<MemoryGapItem*>(child))\r\n        {\r\n            gaps.append(dynamic_cast<MemoryGapItem*>(child));\r\n        }\r\n    }\r\n\r\n    return gaps;\r\n}\r\n\r\nQTEST_MAIN(tst_MemoryMapGraphItem)\r\n\r\n#include \"tst_MemoryMapGraphItem.moc\"\r\n"
  },
  {
    "path": "tests/Core/tst_MemoryMapGraphItem.pri",
    "content": "# ----------------------------------------------------\r\n# This file is generated by the Qt Visual Studio Tools.\r\n# ------------------------------------------------------\r\n\r\nHEADERS += ../../editors/ComponentEditor/memoryMaps/memoryMapsVisualizer/addressblockgraphitem.h \\\r\n    ../../common/graphicsItems/expandableitem.h \\\r\n    ../../editors/ComponentEditor/visualization/AddressableItem.h \\\r\n    ../../common/graphicsItems/graphicsexpandcollapseitem.h \\\r\n    ../../editors/ComponentEditor/visualization/memorygapitem.h \\\r\n    ../../editors/ComponentEditor/memoryMaps/memoryMapsVisualizer/memorymapgraphitem.h \\\r\n    ../../editors/ComponentEditor/visualization/memoryvisualizationitem.h \\\r\n    ../../common/graphicsItems/visualizeritem.h \\\r\n    ../../editors/ComponentEditor/memoryMaps/memoryMapsVisualizer/MemoryBlockGraphItem.h\r\nSOURCES += ../../editors/ComponentEditor/memoryMaps/memoryMapsVisualizer/MemoryBlockGraphItem.cpp \\\r\n    ../../editors/ComponentEditor/memoryMaps/memoryMapsVisualizer/addressblockgraphitem.cpp \\\r\n    ../../common/graphicsItems/expandableitem.cpp \\\r\n    ../../editors/ComponentEditor/visualization/AddressableItem.cpp \\\r\n    ../../common/graphicsItems/graphicsexpandcollapseitem.cpp \\\r\n    ../../editors/ComponentEditor/visualization/memorygapitem.cpp \\\r\n    ../../editors/ComponentEditor/memoryMaps/memoryMapsVisualizer/memorymapgraphitem.cpp \\\r\n    ../../editors/ComponentEditor/visualization/memoryvisualizationitem.cpp \\\r\n    ../../common/graphicsItems/visualizeritem.cpp \\\r\n    ./tst_MemoryMapGraphItem.cpp\r\n"
  },
  {
    "path": "tests/Core/tst_MemoryMapGraphItem.pro",
    "content": "#-----------------------------------------------------------------------------\r\n# File: tst_MemoryMapGraphItem.pro\r\n#-----------------------------------------------------------------------------\r\n# Project: Kactus 2\r\n# Author: Esko Pekkarinen\r\n# Date: 16.04.2015\r\n#\r\n# Description:\r\n# Qt project file template for running unit tests for MemoryMapGraphItem.\r\n#-----------------------------------------------------------------------------\r\n\r\nTEMPLATE = app\r\n\r\nTARGET = tst_MemoryMapGraphItem\r\n\r\nDEFINES+=KACTUS2_EXPORTS\r\n\r\nQT += core xml gui testlib widgets\r\nCONFIG += c++11 testcase console\r\n\r\nQMAKE_EXPORTED_VARIABLES += MAKE_TESTARGS\r\nMAKE_TESTARGS.name = TESTARGS\r\nMAKE_TESTARGS.value = \"-platform offscreen\"\r\n\r\nwin32:CONFIG(release, debug|release) {\r\n    LIBS += -L$$PWD/../../executable/ -lIPXACTmodels -lKactusAPI\r\n    DESTDIR = ./release\r\n}\r\nelse:win32:CONFIG(debug, debug|release) {\r\n    LIBS += -L$$PWD/../../executable/ -lIPXACTmodelsd -lKactusAPId\r\n    DESTDIR = ./debug\r\n}\r\nelse:unix {\r\n    LIBS += -L$$PWD/../../executable/ -lIPXACTmodels -lKactusAPI\r\n    DESTDIR = ./release\r\n}\r\n\r\nINCLUDEPATH += $$PWD/../../\r\nINCLUDEPATH += $$PWD/../../executable\r\nINCLUDEPATH += $$DESTDIR\r\n\r\nDEPENDPATH += $$PWD/../../\r\nDEPENDPATH += $$PWD/../../executable\r\nDEPENDPATH += .\r\n\r\nOBJECTS_DIR += $$DESTDIR\r\n\r\nMOC_DIR += ./generatedFiles\r\nUI_DIR += ./generatedFiles\r\nRCC_DIR += ./generatedFiles\r\ninclude(tst_MemoryMapGraphItem.pri)\r\n"
  },
  {
    "path": "tests/Core/tst_ParameterCompleter.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: tst_ParameterCompleter.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Esko Pekkarinen\r\n// Date: 07.01.2015\r\n//\r\n// Description:\r\n// Unit test for class ParameterCompleter.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include <QtTest>\r\n#include <QCompleter>\r\n\r\n#include <KactusAPI/include/ParameterFinder.h>\r\n\r\n#include <KactusAPI/include/ComponentParameterFinder.h>\r\n\r\n#include <editors/ComponentEditor/parameters/ComponentParameterModel.h>\r\n\r\n#include <IPXACTmodels/Component/Component.h>\r\n\r\n\r\nclass tst_ParameterCompleter : public QObject\r\n{\r\n    Q_OBJECT\r\n\r\npublic:\r\n    tst_ParameterCompleter();\r\n\r\nprivate slots:\r\n    void testNameIsFoundAsCompletion();\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ParameterCompleter::()\r\n//-----------------------------------------------------------------------------\r\ntst_ParameterCompleter::tst_ParameterCompleter()\r\n{\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ParameterCompleter::testNameIsFoundAsCompletion()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ParameterCompleter::testNameIsFoundAsCompletion()\r\n{\r\n    QSharedPointer<Parameter> testParameter(new Parameter());\r\n    testParameter->setName(\"param\");\r\n    testParameter->setValue(\"32\");\r\n\r\n    QList<QSharedPointer<Parameter> > parameters;\r\n    parameters.append(testParameter);\r\n\r\n    QSharedPointer<Component> targetComponent(new Component(VLNV(), Document::Revision::Std14));\r\n    targetComponent->getParameters()->append(parameters);\r\n\r\n    QSharedPointer<ParameterFinder> parameterFinder(new ComponentParameterFinder(targetComponent));\r\n\r\n    ComponentParameterModel* model = new ComponentParameterModel(parameterFinder, this);\r\n\r\n    QCompleter* completer = new QCompleter(this);\r\n    completer->setModel(model);\r\n\r\n    QCOMPARE(completer->completionCount(), 1);\r\n    QCOMPARE(completer->currentCompletion(), QString(\"param\"));\r\n}\r\n\r\nQTEST_MAIN(tst_ParameterCompleter)\r\n\r\n#include \"tst_ParameterCompleter.moc\"\r\n"
  },
  {
    "path": "tests/Core/tst_ParameterCompleter.pri",
    "content": "# ----------------------------------------------------\r\n# This file is generated by the Qt Visual Studio Tools.\r\n# ------------------------------------------------------\r\n\r\nHEADERS += ../../editors/ComponentEditor/parameters/ComponentParameterColumns.h \\\r\n    ../../editors/ComponentEditor/common/ParameterizableTable.h \\\r\n    ../../editors/ComponentEditor/parameters/ComponentParameterModel.h \\\r\n    ../../editors/ComponentEditor/common/ReferencingTableModel.h\r\nSOURCES += ../../editors/ComponentEditor/parameters/ComponentParameterModel.cpp \\\r\n    ../../editors/ComponentEditor/common/ParameterizableTable.cpp \\\r\n    ../../editors/ComponentEditor/common/ReferencingTableModel.cpp \\\r\n    ./tst_ParameterCompleter.cpp\r\n"
  },
  {
    "path": "tests/Core/tst_ParameterCompleter.pro",
    "content": "#-----------------------------------------------------------------------------\r\n# File: tst_ParameterCompleter.pro\r\n#-----------------------------------------------------------------------------\r\n# Project: Kactus 2\r\n# Author: Esko Pekkarinen\r\n# Date: 07.01.2015\r\n#\r\n# Description:\r\n# Qt project file template for running unit tests for class ParameterCompleter.\r\n#-----------------------------------------------------------------------------\r\n\r\nTEMPLATE = app\r\n\r\nTARGET = tst_ParameterCompleter\r\n\r\nQT += core xml gui testlib widgets\r\nCONFIG += c++11 testcase console\r\n\r\nQMAKE_EXPORTED_VARIABLES += MAKE_TESTARGS\r\nMAKE_TESTARGS.name = TESTARGS\r\nMAKE_TESTARGS.value = \"-platform offscreen\"\r\n\r\nwin32:CONFIG(release, debug|release) {\r\n    LIBS += -L$$PWD/../../executable/ -lIPXACTmodels -lKactusAPI\r\n    DESTDIR = ./release\r\n}\r\nelse:win32:CONFIG(debug, debug|release) {\r\n    LIBS += -L$$PWD/../../executable/ -lIPXACTmodelsd -lKactusAPId\r\n    DESTDIR = ./debug\r\n}\r\nelse:unix {\r\n    LIBS += -L$$PWD/../../executable/ -lIPXACTmodels -lKactusAPI\r\n    DESTDIR = ./release\r\n}\r\n\r\nINCLUDEPATH += $$PWD/../../\r\nINCLUDEPATH += $$PWD/../../executable\r\nINCLUDEPATH += $$DESTDIR\r\n\r\nDEPENDPATH += $$PWD/../../\r\nDEPENDPATH += $$PWD/../../executable\r\nDEPENDPATH += .\r\n\r\nOBJECTS_DIR += $$DESTDIR\r\n\r\nMOC_DIR += ./generatedFiles\r\nUI_DIR += ./generatedFiles\r\nRCC_DIR += ./generatedFiles\r\ninclude(tst_ParameterCompleter.pri)\r\n"
  },
  {
    "path": "tests/Core/tst_ParameterReferenceTree.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: tst_ParameterReferenceTree.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 21.01.2015\r\n//\r\n// Description:\r\n// Unit test for class ParameterReferenceTree.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include <QtTest>\r\n\r\n#include <common/KactusColors.h>\r\n\r\n#include <editors/ComponentEditor/parameterReferenceTree/ParameterReferenceTree.h>\r\n#include <editors/ComponentEditor/parameterReferenceTree/ComponentParameterReferenceTree.h>\r\n#include <editors/ComponentEditor/referenceCounter/ComponentParameterReferenceCounter.h>\r\n\r\n#include <KactusAPI/include/ExpressionFormatter.h>\r\n#include <KactusAPI/include/ComponentParameterFinder.h>\r\n\r\n#include <IPXACTmodels/common/Parameter.h>\r\n#include <IPXACTmodels/common/ModuleParameter.h>\r\n#include <IPXACTmodels/common/FileBuilder.h>\r\n\r\n#include <IPXACTmodels/Component/Component.h>\r\n#include <IPXACTmodels/Component/Model.h>\r\n#include <IPXACTmodels/Component/MemoryMapBase.h>\r\n#include <IPXACTmodels/Component/MemoryMap.h>\r\n#include <IPXACTmodels/Component/MemoryRemap.h>\r\n#include <IPXACTmodels/Component/AddressBlock.h>\r\n#include <IPXACTmodels/Component/Register.h>\r\n#include <IPXACTmodels/Component/Field.h>\r\n#include <IPXACTmodels/Component/FieldReset.h>\r\n#include <IPXACTmodels/Component/WriteValueConstraint.h>\r\n#include <IPXACTmodels/Component/BusInterface.h>\r\n#include <IPXACTmodels/Component/MirroredTargetInterface.h>\r\n#include <IPXACTmodels/Component/InitiatorInterface.h>\r\n#include <IPXACTmodels/Component/AddressSpace.h>\r\n#include <IPXACTmodels/Component/RemapState.h>\r\n#include <IPXACTmodels/Component/RemapPort.h>\r\n#include <IPXACTmodels/Component/View.h>\r\n#include <IPXACTmodels/Component/ComponentInstantiation.h>\r\n#include <IPXACTmodels/Component/FileSet.h>\r\n#include <IPXACTmodels/Component/File.h>\r\n#include <IPXACTmodels/Component/BuildCommand.h>\r\n\r\n#include <QSharedPointer>\r\n\r\nclass tst_ParameterReferenceTree : public QObject\r\n{\r\n    Q_OBJECT\r\n\r\npublic:\r\n    tst_ParameterReferenceTree();\r\n\r\nprivate slots:\r\n    void testEmptyComponentInConstructor();\r\n    void testColumnCount();\r\n    void testNoReferencesFoundAddsOneRow();\r\n\r\n    void testReferenceInFileSetFileBuilderAddsFiveRows();\r\n\r\n    void testReferenceInFileBuildCommandAddsSixRows();\r\n\r\n    void testReferenceInParameterValueAddsThreeRows();\r\n    void testMultipleReferencesInOneParameter();\r\n    void testMultipleReferencesInMultipleParameters();\r\n\r\n    void testReferenceAsAnExpressionInParameter();\r\n    void testMultipleReferencesInSameExpression();\r\n\r\n    void testReferenceInViewParameterValueAddsFiveRows();\r\n    void testReferenceInViewModuleParameterValueAddsFiveRows();\r\n\r\n    void testReferenceInComponentInstantiationFileBuilderAddsFiveRows();\r\n\r\n    void testReferenceInPortRightboundAddsThreeRows();\r\n    void testReferenceInPortArraysAddsThreeRows();\r\n\r\n    void testReferenceInAddressBlockBaseAddressAddsSevenRows();\r\n    void testReferenceInAddressBlockNoReferenceInRegister();\r\n\r\n    void testReferenceInRegisterDimensionAddsNineRows();\r\n    void testReferenceInRegisterIsPresentAddsNineRows();\r\n    void testReferenceInMultipleRegistersInTwoAddressBlocks();\r\n    void testRegisterwithNoReferences();\r\n\r\n    void testReferenceInAddressSpaceAddressBlockAddsSixRows();\r\n    void testReferenceInAddressSpaceSegmentAddsSixRows();\r\n\r\n    void testReferenceInRegisterFieldAddsElevenRows();\r\n\r\n    void testReferenceInBusInterfaceParameterAddsFourRows();\r\n\r\n    void testReferenceInBusInterfaceMasterAddsFourRows();\r\n\r\n    void testReferenceInBusInterfaceMirroredSlaveAddsFourRows();\r\n\r\n    void testReferenceInRemapStateAddsFourRows();\r\n\r\n    void testRerefencesInMultiplePlaces();\r\n\r\nprivate:\r\n    QSharedPointer<Parameter> createTestParameter(QString const& name, QString const& value, \r\n        QString const& bitWidthLeft, QString const& bitWidthRight, QString const& arrayLeft,\r\n        QString const& arrayRight);\r\n\r\n    QSharedPointer<ModuleParameter> createTestModuleParameter(QString const& name, QString const& value,\r\n        QString const& bitWidthLeft, QString const& bitWidthRight, QString const& arrayLeft,\r\n        QString const& arrayRight);\r\n\r\n    QSharedPointer<Port> createTestPort(QString const& name, QString const& leftExpression,\r\n        QString const& rightExpression, QString const& defaultValue, QString const& arrayLeft,\r\n        QString const& arrayRight);\r\n\r\n    QSharedPointer<Register> createTestRegister(QString const& name, QString const& offSet,\r\n        QString const& dimension);\r\n\r\n    QSharedPointer<AddressBlock> createTestAddressBlock(QString const& name, QString const& baseAddress,\r\n        QString const& range, QString const& width);\r\n\r\n    QSharedPointer<MemoryMap> createTestMemoryMap(QString const& name);\r\n\r\n    QSharedPointer<MemoryRemap> createTestMemoryRemap(QString const& name);\r\n\r\n    QSharedPointer<Field> createTestField(QString const& name, QString const& offset, QString const& width,\r\n        QString const& presenceExpression);\r\n\r\n    QSharedPointer<FieldReset> createTestFieldReset(QString const& resetValue, QString const& resetMask);\r\n\r\n    QSharedPointer<AddressSpace> createTestAddressSpace(QString const& name);\r\n\r\n    QSharedPointer<FileBuilder> createTestFileBuilder(QString const& fileType, QString const& replaceDefaultFlags);\r\n\r\n    QSharedPointer<FileSet> createTestFileSet(QString const& name, QSharedPointer<FileBuilder> builder);\r\n\r\n    QSharedPointer<BuildCommand> createTestBuildCommand(QString const& replaceDefaultFlags);\r\n\r\n    QSharedPointer<File> createTestFile(QString const& name, QSharedPointer<BuildCommand> buildCommand);\r\n\r\n    QSharedPointer<ExpressionFormatter> createTestExpressionFormatter(QSharedPointer<Component> component);   \r\n\r\n    ComponentParameterReferenceTree* createTestTree(QSharedPointer<Component> component);\r\n\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ParameterReferenceTree::tst_ParameterReferenceTree()\r\n//-----------------------------------------------------------------------------\r\ntst_ParameterReferenceTree::tst_ParameterReferenceTree()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ParameterReferenceTree::testEmptyComponentInConstructor()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ParameterReferenceTree::testEmptyComponentInConstructor()\r\n{\r\n    QSharedPointer<Component> component(0);\r\n\r\n    QScopedPointer<ComponentParameterReferenceTree> tree(createTestTree(component));\r\n    tree->openReferenceTree(QString());\r\n\r\n    QCOMPARE(tree->topLevelItemCount(), 1);\r\n    QCOMPARE(tree->topLevelItem(0)->childCount(), 0);\r\n    QCOMPARE(tree->topLevelItem(0)->text(ParameterReferenceTree::ITEM_NAME),\r\n        QStringLiteral(\"Component does not exist.\"));\r\n    QCOMPARE(tree->topLevelItem(0)->text(ParameterReferenceTree::ITEM_EXPRESSION), QString());\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ParameterReferenceTree::testColumnCount()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ParameterReferenceTree::testColumnCount()\r\n{\r\n    QSharedPointer<Component> component(new Component(VLNV(), Document::Revision::Std14));\r\n\r\n    QScopedPointer<ComponentParameterReferenceTree> tree(createTestTree(component));\r\n\r\n    QCOMPARE(tree->columnCount(), 2);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ParameterReferenceTree::testNoReferencesFoundAddsOneRow()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ParameterReferenceTree::testNoReferencesFoundAddsOneRow()\r\n{\r\n    QSharedPointer <Parameter> searched(new Parameter);\r\n    searched->setName(\"searchedParameter\");\r\n    searched->setValueId(\"searched\");\r\n\r\n    // Parameter: No references.\r\n    QSharedPointer<Parameter> paramRef = createTestParameter(\"ref1\", \"\", \"\", \"\", \"test\", \"test\");\r\n\r\n    // Parameter in view: No references.\r\n    QSharedPointer<Parameter> viewParameter = createTestParameter(\"viewParamRef\", \"test\", \"\", \"\", \"\", \"\");\r\n\r\n    QSharedPointer<ComponentInstantiation> instantiation(new ComponentInstantiation(\"instantiation\"));\r\n    instantiation->getParameters()->append(viewParameter);\r\n\r\n    QSharedPointer<View> viewRef (new View(\"viewRef\"));\r\n    viewRef->setComponentInstantiationRef(instantiation->name());\r\n\r\n    // Port: No references.\r\n    QSharedPointer<Port> portRef = createTestPort(\"portRef\", \"\", \"test\", \"test\", \"\", \"\");\r\n\r\n    // Memory Maps: No references.\r\n    QSharedPointer<Register> registerRef = createTestRegister(\"registerRef\", \"test\", \"test\");\r\n\r\n    QSharedPointer<AddressBlock> addressRef = createTestAddressBlock(\"addressBlockRef\", \"test\", \"\", \"4\");\r\n    addressRef->getRegisterData()->append(registerRef);\r\n\r\n    QSharedPointer<MemoryMap> memoryMapRef = createTestMemoryMap(\"memoryMapRef\");\r\n    memoryMapRef->getMemoryBlocks()->append(addressRef);\r\n\r\n    // Address space: No references.\r\n    QSharedPointer <AddressBlock> spaceBlock = createTestAddressBlock(\"spaceBlockRef\", \"test\", \"\", \"15\");\r\n\r\n    QSharedPointer<MemoryMapBase> spaceMemMap (new MemoryMapBase(\"spaceMemMap\"));\r\n    spaceMemMap->getMemoryBlocks()->append(spaceBlock);\r\n\r\n    QSharedPointer<AddressSpace> addressSpaceRef (new AddressSpace(\"addressSpaceRef\"));\r\n    addressSpaceRef->setLocalMemoryMap(spaceMemMap);\r\n\r\n    QSharedPointer<Component> component(new Component(VLNV(), Document::Revision::Std14));\r\n    component->getParameters()->append(searched);\r\n    component->getParameters()->append(paramRef);\r\n    component->getViews()->append(viewRef);\r\n    component->getComponentInstantiations()->append(instantiation);\r\n    component->getPorts()->append(portRef);\r\n    component->getMemoryMaps()->append(memoryMapRef);\r\n    component->getAddressSpaces()->append(addressSpaceRef);\r\n\r\n    QScopedPointer<ComponentParameterReferenceTree> tree(createTestTree(component));\r\n    tree->openReferenceTree(QStringLiteral(\"searched\"));\r\n\r\n    QCOMPARE(tree->topLevelItemCount(), 1);\r\n    QCOMPARE(tree->topLevelItem(0)->text(ParameterReferenceTree::ITEM_NAME),\r\n        QStringLiteral(\"No references found.\"));\r\n    QCOMPARE(tree->topLevelItem(0)->text(ParameterReferenceTree::ITEM_EXPRESSION), QString());\r\n    QCOMPARE(tree->topLevelItem(0)->childCount(), 0);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ParameterReferenceTree::testReferenceInFileSetFileBuilderAddsFourRows()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ParameterReferenceTree::testReferenceInFileSetFileBuilderAddsFiveRows()\r\n{\r\n    QSharedPointer<Parameter> searched(new Parameter);\r\n    searched->setName(\"searchedParameter\");\r\n    searched->setValueId(\"searched\");\r\n\r\n    QSharedPointer<FileBuilder> referencingFileBuilder = createTestFileBuilder(\"testBuilder\", \"searched\");\r\n    QSharedPointer<FileSet> referencingFileSet = createTestFileSet(\"testSet\", referencingFileBuilder);\r\n\r\n    QSharedPointer<Component> component(new Component(VLNV(), Document::Revision::Std14));\r\n    component->getParameters()->append(searched);\r\n    component->getFileSets()->append(referencingFileSet);\r\n\r\n    QSharedPointer<ExpressionFormatter> expressionFormatter = createTestExpressionFormatter(component);\r\n\r\n    QScopedPointer<ComponentParameterReferenceTree> tree(createTestTree(component));\r\n    tree->openReferenceTree(QStringLiteral(\"searched\"));\r\n\r\n    QCOMPARE(tree->topLevelItemCount(), 1);\r\n    QCOMPARE(tree->topLevelItem(0)->text(ParameterReferenceTree::ITEM_NAME), QStringLiteral(\"File sets\"));\r\n    QCOMPARE(tree->topLevelItem(0)->text(ParameterReferenceTree::ITEM_EXPRESSION), QString());\r\n\r\n    QCOMPARE(tree->topLevelItem(0)->childCount(), 1);\r\n    QCOMPARE(tree->topLevelItem(0)->child(0)->text(ParameterReferenceTree::ITEM_NAME), \r\n        referencingFileSet->name());\r\n    QCOMPARE(tree->topLevelItem(0)->child(0)->text(ParameterReferenceTree::ITEM_EXPRESSION), QString());\r\n\r\n    QCOMPARE(tree->topLevelItem(0)->child(0)->childCount(), 1);\r\n    QCOMPARE(tree->topLevelItem(0)->child(0)->child(0)->text(ParameterReferenceTree::ITEM_NAME),\r\n        QStringLiteral(\"Default file build commands\"));\r\n    QCOMPARE(tree->topLevelItem(0)->child(0)->child(0)->text(ParameterReferenceTree::ITEM_EXPRESSION), QString());\r\n\r\n    QCOMPARE(tree->topLevelItem(0)->child(0)->child(0)->childCount(), 1);\r\n    QCOMPARE(tree->topLevelItem(0)->child(0)->child(0)->child(0)->text(ParameterReferenceTree::ITEM_NAME),\r\n        QStringLiteral(\"File type: \") + referencingFileBuilder->getFileType().type_);\r\n    QCOMPARE(tree->topLevelItem(0)->child(0)->child(0)->child(0)->text(ParameterReferenceTree::ITEM_EXPRESSION),\r\n        QString());\r\n\r\n    QCOMPARE(tree->topLevelItem(0)->child(0)->child(0)->child(0)->childCount(), 1);\r\n    QCOMPARE(tree->topLevelItem(0)->child(0)->child(0)->child(0)->child(0)->text(ParameterReferenceTree::ITEM_NAME),\r\n        QStringLiteral(\"Replace default flags\"));\r\n    QCOMPARE(tree->topLevelItem(0)->child(0)->child(0)->child(0)->child(0)->text(\r\n        ParameterReferenceTree::ITEM_EXPRESSION),\r\n        expressionFormatter->formatReferringExpression(referencingFileBuilder->getReplaceDefaultFlags()));\r\n\r\n    QCOMPARE(tree->topLevelItem(0)->child(0)->child(0)->child(0)->child(0)->childCount(), 0);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ParameterReferenceTree::testReferenceInFileBuildCommandAddsSixRows()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ParameterReferenceTree::testReferenceInFileBuildCommandAddsSixRows()\r\n{\r\n    QSharedPointer<Parameter> searched(new Parameter);\r\n    searched->setName(\"searchedParameter\");\r\n    searched->setValueId(\"searched\");\r\n\r\n    QSharedPointer<BuildCommand> referencingBuild = createTestBuildCommand(\"searched * Saitama\");\r\n\r\n    QSharedPointer<File> referencingFile = createTestFile(\"One\", referencingBuild);\r\n\r\n    QSharedPointer<FileSet> referencingFileSet = createTestFileSet(\"testSet\", QSharedPointer<FileBuilder>());\r\n    referencingFileSet->getFiles()->append(referencingFile);\r\n\r\n    QSharedPointer<Component> component(new Component(VLNV(), Document::Revision::Std14));\r\n    component->getParameters()->append(searched);\r\n    component->getFileSets()->append(referencingFileSet);\r\n\r\n    QSharedPointer<ExpressionFormatter> expressionFormatter = createTestExpressionFormatter(component);\r\n\r\n    QScopedPointer<ComponentParameterReferenceTree> tree(createTestTree(component));\r\n    tree->openReferenceTree(QStringLiteral(\"searched\"));\r\n\r\n    QCOMPARE(tree->topLevelItemCount(), 1);\r\n\r\n    QTreeWidgetItem* topItem = tree->topLevelItem(0);\r\n    QCOMPARE(topItem->text(ParameterReferenceTree::ITEM_NAME), QStringLiteral(\"File sets\"));\r\n    QCOMPARE(topItem->text(ParameterReferenceTree::ITEM_EXPRESSION), QString());\r\n    QCOMPARE(topItem->childCount(), 1);\r\n\r\n    QTreeWidgetItem* fileSetItem = topItem->child(0);\r\n    QCOMPARE(fileSetItem->text(ParameterReferenceTree::ITEM_NAME), referencingFileSet->name());\r\n    QCOMPARE(fileSetItem->text(ParameterReferenceTree::ITEM_EXPRESSION), QString());\r\n    QCOMPARE(fileSetItem->childCount(), 1);\r\n\r\n    QTreeWidgetItem* filesItem = fileSetItem->child(0);\r\n    QCOMPARE(filesItem->text(ParameterReferenceTree::ITEM_NAME), QStringLiteral(\"Files\"));\r\n    QCOMPARE(filesItem->text(ParameterReferenceTree::ITEM_EXPRESSION), QString());\r\n    QCOMPARE(filesItem->childCount(), 1);\r\n\r\n    QTreeWidgetItem* singleFileItem = filesItem->child(0);\r\n    QCOMPARE(singleFileItem->text(ParameterReferenceTree::ITEM_NAME), referencingFile->name());\r\n    QCOMPARE(singleFileItem->text(ParameterReferenceTree::ITEM_EXPRESSION), QString());\r\n    QCOMPARE(singleFileItem->childCount(), 1);\r\n\r\n    QTreeWidgetItem* buildCommandItem = singleFileItem->child(0);\r\n    QCOMPARE(buildCommandItem->text(ParameterReferenceTree::ITEM_NAME), QStringLiteral(\"Build command\"));\r\n    QCOMPARE(buildCommandItem->text(ParameterReferenceTree::ITEM_EXPRESSION), QString());\r\n    QCOMPARE(buildCommandItem->childCount(), 1);\r\n\r\n    QTreeWidgetItem* flagsItem = buildCommandItem->child(0);\r\n    QCOMPARE(flagsItem->text(ParameterReferenceTree::ITEM_NAME), QStringLiteral(\"Replace default flags\"));\r\n    QCOMPARE(flagsItem->text(ParameterReferenceTree::ITEM_EXPRESSION),\r\n        expressionFormatter->formatReferringExpression(referencingBuild->getReplaceDefaultFlags()));\r\n    QCOMPARE(flagsItem->childCount(), 0);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ParameterReferenceTree::testParameterReferenceAddsThreeRows()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ParameterReferenceTree::testReferenceInParameterValueAddsThreeRows()\r\n{\r\n    QSharedPointer<Parameter> searched(new Parameter);\r\n    searched->setName(\"searchedParameter\");\r\n    searched->setValueId(\"searched\");\r\n\r\n    QList <QSharedPointer<Parameter> > componentParameters;\r\n    QSharedPointer<Parameter> referencingParameter = createTestParameter(\r\n        \"referencingParameter\", \"searched\", \"\", \"\", \"\", \"\");\r\n    componentParameters.append(referencingParameter);\r\n\r\n    componentParameters.append(searched);\r\n\r\n    QSharedPointer<Component> component(new Component(VLNV(), Document::Revision::Std14));\r\n    component->getParameters()->append(componentParameters);\r\n\r\n    QSharedPointer<ExpressionFormatter> expressionFormatter = createTestExpressionFormatter(component);\r\n\r\n    QScopedPointer<ComponentParameterReferenceTree> tree(createTestTree(component));\r\n    tree->openReferenceTree(QStringLiteral(\"searched\"));\r\n\r\n    QCOMPARE(tree->topLevelItemCount(), 1);\r\n    QCOMPARE(tree->topLevelItem(0)->text(ParameterReferenceTree::ITEM_NAME), QStringLiteral(\"Parameters\"));\r\n    QCOMPARE(tree->topLevelItem(0)->text(ParameterReferenceTree::ITEM_EXPRESSION), QString());\r\n\r\n    QCOMPARE(tree->topLevelItem(0)->childCount(), 1);\r\n    QCOMPARE(tree->topLevelItem(0)->child(0)->text(ParameterReferenceTree::ITEM_NAME), \r\n        referencingParameter->name());\r\n    QCOMPARE(tree->topLevelItem(0)->child(0)->text(ParameterReferenceTree::ITEM_EXPRESSION), QString());\r\n\r\n    QCOMPARE(tree->topLevelItem(0)->child(0)->childCount(), 1);\r\n    QCOMPARE(tree->topLevelItem(0)->child(0)->child(0)->text(ParameterReferenceTree::ITEM_NAME), QStringLiteral(\"Value\"));\r\n    QCOMPARE(tree->topLevelItem(0)->child(0)->child(0)->text(ParameterReferenceTree::ITEM_EXPRESSION),\r\n        expressionFormatter->formatReferringExpression(referencingParameter->getValue()));\r\n\r\n    QCOMPARE(tree->topLevelItem(0)->child(0)->child(0)->childCount(), 0);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ParameterReferenceTree::testMultipleReferencesInParameter()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ParameterReferenceTree::testMultipleReferencesInOneParameter()\r\n{\r\n    QSharedPointer<Parameter> searched(new Parameter);\r\n    searched->setName(\"searchedParameter\");\r\n    searched->setValueId(\"searched\");\r\n\r\n    QList <QSharedPointer<Parameter> > componentParameters;\r\n    componentParameters.append(searched);\r\n    // Four references in a parameter\r\n    QSharedPointer<Parameter> referencer = createTestParameter(\"refParam\", \"searched\", \"searched\", \"searched\",\r\n        \"searched\", \"searched\");\r\n    componentParameters.append(referencer);\r\n\r\n    QSharedPointer<Component> component(new Component(VLNV(), Document::Revision::Std14));\r\n    component->getParameters()->append(componentParameters);\r\n\r\n    QSharedPointer<ExpressionFormatter> expressionFormatter = createTestExpressionFormatter(component);\r\n\r\n    QScopedPointer<ComponentParameterReferenceTree> tree(createTestTree(component));\r\n    tree->openReferenceTree(QStringLiteral(\"searched\"));\r\n\r\n    QCOMPARE(tree->topLevelItemCount(), 1);\r\n    QCOMPARE(tree->topLevelItem(0)->text(ParameterReferenceTree::ITEM_NAME), QStringLiteral(\"Parameters\"));\r\n    QCOMPARE(tree->topLevelItem(0)->text(ParameterReferenceTree::ITEM_EXPRESSION), QString());\r\n\r\n    QCOMPARE(tree->topLevelItem(0)->childCount(), 1);\r\n    QCOMPARE(tree->topLevelItem(0)->child(0)->text(ParameterReferenceTree::ITEM_NAME), referencer->name());\r\n    QCOMPARE(tree->topLevelItem(0)->child(0)->text(ParameterReferenceTree::ITEM_EXPRESSION), QString());\r\n\r\n    QCOMPARE(tree->topLevelItem(0)->child(0)->childCount(), 5);\r\n    QCOMPARE(tree->topLevelItem(0)->child(0)->child(0)->text(ParameterReferenceTree::ITEM_NAME),\r\n        QStringLiteral(\"Value\"));\r\n    QCOMPARE(tree->topLevelItem(0)->child(0)->child(0)->text(ParameterReferenceTree::ITEM_EXPRESSION),\r\n        expressionFormatter->formatReferringExpression(referencer->getValue()));\r\n\r\n    QCOMPARE(tree->topLevelItem(0)->child(0)->child(1)->text(ParameterReferenceTree::ITEM_NAME),\r\n        QStringLiteral(\"Bit Width Left\"));\r\n    QCOMPARE(tree->topLevelItem(0)->child(0)->child(1)->text(ParameterReferenceTree::ITEM_EXPRESSION),\r\n        expressionFormatter->formatReferringExpression(referencer->getVectorLeft()));\r\n\r\n    QCOMPARE(tree->topLevelItem(0)->child(0)->child(2)->text(ParameterReferenceTree::ITEM_NAME),\r\n        QStringLiteral(\"Bit Width Right\"));\r\n    QCOMPARE(tree->topLevelItem(0)->child(0)->child(2)->text(ParameterReferenceTree::ITEM_EXPRESSION),\r\n        expressionFormatter->formatReferringExpression(referencer->getVectorRight()));\r\n\r\n    QCOMPARE(tree->topLevelItem(0)->child(0)->child(3)->text(ParameterReferenceTree::ITEM_NAME),\r\n        QStringLiteral(\"Array Left\"));\r\n    QCOMPARE(tree->topLevelItem(0)->child(0)->child(3)->text(ParameterReferenceTree::ITEM_EXPRESSION),\r\n        expressionFormatter->formatReferringExpression(referencer->getAttribute(\"kactus2:arrayLeft\")));\r\n\r\n    QCOMPARE(tree->topLevelItem(0)->child(0)->child(4)->text(ParameterReferenceTree::ITEM_NAME),\r\n        QStringLiteral(\"Array Right\"));\r\n    QCOMPARE(tree->topLevelItem(0)->child(0)->child(4)->text(ParameterReferenceTree::ITEM_EXPRESSION),\r\n        expressionFormatter->formatReferringExpression(referencer->getAttribute(\"kactus2:arrayRight\")));\r\n\r\n    QCOMPARE(tree->topLevelItem(0)->child(0)->child(0)->childCount(), 0);\r\n    QCOMPARE(tree->topLevelItem(0)->child(0)->child(1)->childCount(), 0);\r\n    QCOMPARE(tree->topLevelItem(0)->child(0)->child(2)->childCount(), 0);\r\n    QCOMPARE(tree->topLevelItem(0)->child(0)->child(3)->childCount(), 0);\r\n    QCOMPARE(tree->topLevelItem(0)->child(0)->child(4)->childCount(), 0);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ParameterReferenceTree::testMultipleReferencesInMultipleParameters()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ParameterReferenceTree::testMultipleReferencesInMultipleParameters()\r\n{\r\n    QSharedPointer <Parameter> searched(new Parameter);\r\n    searched->setName(\"searchedParameter\");\r\n    searched->setValueId(\"searched\");\r\n\r\n    QList <QSharedPointer<Parameter> > componentParameters;\r\n    componentParameters.append(searched);\r\n\r\n    // Two references, in array size and array offset.\r\n    QSharedPointer<Parameter> firstRef = createTestParameter(\"ref1\", \"\", \"\", \"\", \"searched\", \"searched\");\r\n    componentParameters.append(firstRef);\r\n    // Three references, in bit width, array size and array offset.\r\n    QSharedPointer<Parameter> secondRef = createTestParameter(\"ref2\", \"\", \"searched\", \"\", \"searched\", \"searched\");\r\n    componentParameters.append(secondRef);\r\n\r\n    QSharedPointer<Component> component(new Component(VLNV(), Document::Revision::Std14));\r\n    component->getParameters()->append(componentParameters);\r\n\r\n    QSharedPointer<ExpressionFormatter> expressionFormatter = createTestExpressionFormatter(component);\r\n\r\n    QScopedPointer<ComponentParameterReferenceTree> tree(createTestTree(component));\r\n    tree->openReferenceTree(QStringLiteral(\"searched\"));\r\n\r\n    QCOMPARE(tree->topLevelItemCount(), 1);\r\n    QCOMPARE(tree->topLevelItem(0)->text(ParameterReferenceTree::ITEM_NAME), QStringLiteral(\"Parameters\"));\r\n    QCOMPARE(tree->topLevelItem(0)->text(ParameterReferenceTree::ITEM_EXPRESSION), QString());\r\n\r\n    QCOMPARE(tree->topLevelItem(0)->childCount(), 2);\r\n    QCOMPARE(tree->topLevelItem(0)->child(0)->text(ParameterReferenceTree::ITEM_NAME), firstRef->name());\r\n    QCOMPARE(tree->topLevelItem(0)->child(0)->text(ParameterReferenceTree::ITEM_EXPRESSION), QString());\r\n    QCOMPARE(tree->topLevelItem(0)->child(1)->text(ParameterReferenceTree::ITEM_NAME), secondRef->name());\r\n    QCOMPARE(tree->topLevelItem(0)->child(1)->text(ParameterReferenceTree::ITEM_EXPRESSION), QString());\r\n\r\n    QCOMPARE(tree->topLevelItem(0)->child(0)->childCount(), 2);\r\n    QCOMPARE(tree->topLevelItem(0)->child(0)->child(0)->text(ParameterReferenceTree::ITEM_NAME),\r\n        QStringLiteral(\"Array Left\"));\r\n    QCOMPARE(tree->topLevelItem(0)->child(0)->child(0)->text(ParameterReferenceTree::ITEM_EXPRESSION),\r\n        expressionFormatter->formatReferringExpression(firstRef->getAttribute(\"kactus2:arrayLeft\")));\r\n    QCOMPARE(tree->topLevelItem(0)->child(0)->child(1)->text(ParameterReferenceTree::ITEM_NAME),\r\n        QStringLiteral(\"Array Right\"));\r\n    QCOMPARE(tree->topLevelItem(0)->child(0)->child(1)->text(ParameterReferenceTree::ITEM_EXPRESSION),\r\n        expressionFormatter->formatReferringExpression(firstRef->getAttribute(\"kactus2:arrayRight\")));\r\n\r\n    QCOMPARE(tree->topLevelItem(0)->child(0)->child(0)->childCount(), 0);\r\n    QCOMPARE(tree->topLevelItem(0)->child(0)->child(1)->childCount(), 0);\r\n\r\n    QCOMPARE(tree->topLevelItem(0)->child(1)->childCount(), 3);\r\n    QCOMPARE(tree->topLevelItem(0)->child(1)->child(0)->text(ParameterReferenceTree::ITEM_NAME),\r\n        QStringLiteral(\"Bit Width Left\"));\r\n    QCOMPARE(tree->topLevelItem(0)->child(1)->child(0)->text(ParameterReferenceTree::ITEM_EXPRESSION),\r\n        expressionFormatter->formatReferringExpression(secondRef->getVectorLeft()));\r\n\r\n    QCOMPARE(tree->topLevelItem(0)->child(1)->child(1)->text(ParameterReferenceTree::ITEM_NAME),\r\n        QStringLiteral(\"Array Left\"));\r\n    QCOMPARE(tree->topLevelItem(0)->child(1)->child(1)->text(ParameterReferenceTree::ITEM_EXPRESSION),\r\n        expressionFormatter->formatReferringExpression(secondRef->getAttribute(\"kactus2:arrayLeft\")));\r\n\r\n    QCOMPARE(tree->topLevelItem(0)->child(1)->child(2)->text(ParameterReferenceTree::ITEM_NAME),\r\n        QStringLiteral(\"Array Right\"));\r\n    QCOMPARE(tree->topLevelItem(0)->child(1)->child(2)->text(ParameterReferenceTree::ITEM_EXPRESSION),\r\n        expressionFormatter->formatReferringExpression(secondRef->getAttribute(\"kactus2:arrayRight\")));\r\n\r\n    QCOMPARE(tree->topLevelItem(0)->child(1)->child(0)->childCount(), 0);\r\n    QCOMPARE(tree->topLevelItem(0)->child(1)->child(1)->childCount(), 0);\r\n    QCOMPARE(tree->topLevelItem(0)->child(1)->child(2)->childCount(), 0);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ParameterReferenceTree::testReferenceAsAnExpressionInParameter()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ParameterReferenceTree::testReferenceAsAnExpressionInParameter()\r\n{\r\n    QSharedPointer<Parameter> searched(new Parameter);\r\n    searched->setName(\"searchedParameter\");\r\n    searched->setValueId(\"searched\");\r\n\r\n    QList <QSharedPointer<Parameter> > componentParameters;\r\n    componentParameters.append(searched);\r\n\r\n    // One reference, in value.\r\n    QSharedPointer<Parameter> firstRef = createTestParameter(\"ref\", \"search + searched\", \"\", \"\", \"\", \"\");\r\n    componentParameters.append(firstRef);\r\n\r\n    QSharedPointer<Component> component(new Component(VLNV(), Document::Revision::Std14));\r\n    component->getParameters()->append(componentParameters);\r\n\r\n    QSharedPointer<ExpressionFormatter> expressionFormatter = createTestExpressionFormatter(component);\r\n\r\n    QScopedPointer<ComponentParameterReferenceTree> tree(createTestTree(component));\r\n    tree->openReferenceTree(QStringLiteral(\"searched\"));\r\n\r\n    QCOMPARE(tree->topLevelItemCount(), 1);\r\n    QCOMPARE(tree->topLevelItem(0)->text(ParameterReferenceTree::ITEM_NAME), QStringLiteral(\"Parameters\"));\r\n    QCOMPARE(tree->topLevelItem(0)->text(ParameterReferenceTree::ITEM_EXPRESSION), QString());\r\n\r\n    QCOMPARE(tree->topLevelItem(0)->childCount(), 1);\r\n    QCOMPARE(tree->topLevelItem(0)->child(0)->text(ParameterReferenceTree::ITEM_NAME), firstRef->name());\r\n    QCOMPARE(tree->topLevelItem(0)->child(0)->text(ParameterReferenceTree::ITEM_EXPRESSION), QString());\r\n\r\n    QCOMPARE(tree->topLevelItem(0)->child(0)->childCount(), 1);\r\n    QCOMPARE(tree->topLevelItem(0)->child(0)->child(0)->text(ParameterReferenceTree::ITEM_NAME),\r\n        QStringLiteral(\"Value\"));\r\n    QCOMPARE(tree->topLevelItem(0)->child(0)->child(0)->text(ParameterReferenceTree::ITEM_EXPRESSION),\r\n        expressionFormatter->formatReferringExpression(firstRef->getValue()));\r\n\r\n    QCOMPARE(tree->topLevelItem(0)->child(0)->child(0)->childCount(), 0);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ParameterReferenceTree::testMultipleReferencesInSameExpression()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ParameterReferenceTree::testMultipleReferencesInSameExpression()\r\n{\r\n    QSharedPointer<Parameter> searched(new Parameter);\r\n    searched->setName(\"searchedParameter\");\r\n    searched->setValueId(\"searched\");\r\n\r\n    QList <QSharedPointer<Parameter> > componentParameters;\r\n    componentParameters.append(searched);\r\n\r\n    // Three references, in value.\r\n    QSharedPointer<Parameter> firstRef = createTestParameter(\"ref\", \"searched + searched * searched\", \"\", \"\", \"\",\r\n        \"\");\r\n    componentParameters.append(firstRef);\r\n\r\n    QSharedPointer<Component> component(new Component(VLNV(), Document::Revision::Std14));\r\n    component->getParameters()->append(componentParameters);\r\n\r\n    QSharedPointer<ExpressionFormatter> expressionFormatter = createTestExpressionFormatter(component);\r\n\r\n    QScopedPointer<ComponentParameterReferenceTree> tree(createTestTree(component));\r\n    tree->openReferenceTree(QStringLiteral(\"searched\"));\r\n\r\n    QCOMPARE(tree->topLevelItemCount(), 1);\r\n    QCOMPARE(tree->topLevelItem(0)->text(ParameterReferenceTree::ITEM_NAME), QStringLiteral(\"Parameters\"));\r\n    QCOMPARE(tree->topLevelItem(0)->text(ParameterReferenceTree::ITEM_EXPRESSION), QString());\r\n\r\n    QCOMPARE(tree->topLevelItem(0)->childCount(), 1);\r\n    QCOMPARE(tree->topLevelItem(0)->child(0)->text(ParameterReferenceTree::ITEM_NAME), firstRef->name());\r\n    QCOMPARE(tree->topLevelItem(0)->child(0)->text(ParameterReferenceTree::ITEM_EXPRESSION), QString());\r\n\r\n    QCOMPARE(tree->topLevelItem(0)->child(0)->childCount(), 1);\r\n    QCOMPARE(tree->topLevelItem(0)->child(0)->child(0)->text(ParameterReferenceTree::ITEM_NAME),\r\n        QStringLiteral(\"Value\"));\r\n    QCOMPARE(tree->topLevelItem(0)->child(0)->child(0)->text(ParameterReferenceTree::ITEM_EXPRESSION),\r\n        expressionFormatter->formatReferringExpression(firstRef->getValue()));\r\n\r\n    QCOMPARE(tree->topLevelItem(0)->child(0)->child(0)->childCount(), 0);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ParameterReferenceTree::testReferenceInViewParameterValueAddsFiveRows()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ParameterReferenceTree::testReferenceInViewParameterValueAddsFiveRows()\r\n{\r\n    QSharedPointer<Parameter> searched(new Parameter);\r\n    searched->setName(\"searchedParameter\");\r\n    searched->setValueId(\"searched\");\r\n\r\n    // One reference, in array offset.\r\n    QSharedPointer<Parameter> paramRef = createTestParameter(\"paramRef\", \"searched\", \"\", \"\", \"\", \"\");\r\n\r\n    QSharedPointer<ComponentInstantiation> componentInstantiation (new ComponentInstantiation(\"componentI\"));\r\n    componentInstantiation->getParameters()->append(paramRef);\r\n\r\n    QSharedPointer<View> viewRef(new View(\"viewRef\"));\r\n    viewRef->setComponentInstantiationRef(componentInstantiation->name());\r\n\r\n    QSharedPointer<Component> component(new Component(VLNV(), Document::Revision::Std14));\r\n    component->getParameters()->append(searched);\r\n    component->getViews()->append(viewRef);\r\n    component->getComponentInstantiations()->append(componentInstantiation);\r\n\r\n    QSharedPointer<ExpressionFormatter> expressionFormatter = createTestExpressionFormatter(component);\r\n\r\n    QScopedPointer<ComponentParameterReferenceTree> tree(createTestTree(component));\r\n    tree->openReferenceTree(QStringLiteral(\"searched\"));\r\n        \r\n    QCOMPARE(tree->topLevelItemCount(), 1);\r\n    QTreeWidgetItem* instantiationsItem = tree->topLevelItem(0);\r\n    QCOMPARE(instantiationsItem->text(ParameterReferenceTree::ITEM_NAME), QStringLiteral(\"Instantiations\"));\r\n    QCOMPARE(instantiationsItem->text(ParameterReferenceTree::ITEM_EXPRESSION), QString());   \r\n    QCOMPARE(instantiationsItem->background(ParameterReferenceTree::ITEM_EXPRESSION).color(),\r\n        KactusColors::STRONG_FIELD);\r\n\r\n    QTreeWidgetItem* componentInstantiationsItem = instantiationsItem->child(0);\r\n    QCOMPARE(componentInstantiationsItem->text(ParameterReferenceTree::ITEM_NAME), \r\n        QStringLiteral(\"Component instantiations\"));\r\n    QCOMPARE(componentInstantiationsItem->text(ParameterReferenceTree::ITEM_EXPRESSION), QString());\r\n\r\n    QCOMPARE(componentInstantiationsItem->childCount(), 1);\r\n    QTreeWidgetItem* singleComponentInstantiationItem = componentInstantiationsItem->child(0);\r\n    QCOMPARE(singleComponentInstantiationItem->text(ParameterReferenceTree::ITEM_NAME),\r\n        componentInstantiation->name());\r\n    QCOMPARE(singleComponentInstantiationItem->text(ParameterReferenceTree::ITEM_EXPRESSION), QString());\r\n\r\n    QCOMPARE(singleComponentInstantiationItem->childCount(), 1);\r\n    QTreeWidgetItem* viewParametersItem = singleComponentInstantiationItem->child(0);\r\n    QCOMPARE(viewParametersItem->text(ParameterReferenceTree::ITEM_NAME), QStringLiteral(\"Parameters\"));\r\n    QCOMPARE(viewParametersItem->text(ParameterReferenceTree::ITEM_EXPRESSION), QString());\r\n    QCOMPARE(viewParametersItem->background(ParameterReferenceTree::ITEM_EXPRESSION).color(),\r\n        KactusColors::STRONG_FIELD);\r\n\r\n    QCOMPARE(singleComponentInstantiationItem->childCount(), 1);\r\n    QTreeWidgetItem* parameterItem = viewParametersItem->child(0);\r\n    QCOMPARE(parameterItem->text(ParameterReferenceTree::ITEM_NAME), paramRef->name());\r\n    QCOMPARE(parameterItem->text(ParameterReferenceTree::ITEM_EXPRESSION), QString());\r\n\r\n    QCOMPARE(parameterItem->childCount(), 1);\r\n    QTreeWidgetItem* valueItem = parameterItem->child(0);\r\n    QCOMPARE(valueItem->text(ParameterReferenceTree::ITEM_NAME), QStringLiteral(\"Value\"));\r\n    QCOMPARE(valueItem->text(ParameterReferenceTree::ITEM_EXPRESSION),\r\n        expressionFormatter->formatReferringExpression(paramRef->getValue()));\r\n\r\n    QCOMPARE(valueItem->childCount(), 0);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ParameterReferenceTree::testReferenceInViewModuleParameterValueAddsFiveRows()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ParameterReferenceTree::testReferenceInViewModuleParameterValueAddsFiveRows()\r\n{\r\n    QSharedPointer<Parameter> searched(new Parameter());\r\n    searched->setName(\"searchedParameter\");\r\n    searched->setValueId(\"searched\");\r\n\r\n    QSharedPointer<Component> component(new Component(VLNV(), Document::Revision::Std14));\r\n    component->getParameters()->append(searched);  \r\n\r\n    QSharedPointer<ModuleParameter> moduleParameterRef(new ModuleParameter());\r\n    moduleParameterRef->setName(\"paramRef\");\r\n    moduleParameterRef->setValue(searched->getValueId());\r\n\r\n    QSharedPointer<ComponentInstantiation> instantiation (new ComponentInstantiation(\"compInstantiation\"));\r\n    instantiation->getModuleParameters()->append(moduleParameterRef);\r\n\r\n    QSharedPointer<View> viewRef(new View(\"viewRef\"));\r\n    viewRef->setComponentInstantiationRef(instantiation->name());\r\n\r\n    component->getViews()->append(viewRef);\r\n    component->getComponentInstantiations()->append(instantiation);\r\n\r\n    QSharedPointer<ExpressionFormatter> expressionFormatter = createTestExpressionFormatter(component);\r\n\r\n    QScopedPointer<ComponentParameterReferenceTree> tree(createTestTree(component));\r\n    tree->openReferenceTree(QStringLiteral(\"searched\"));\r\n\r\n    QCOMPARE(tree->topLevelItemCount(), 1);\r\n    QTreeWidgetItem* instantiationsItem = tree->topLevelItem(0);\r\n\r\n    QCOMPARE(instantiationsItem->text(ParameterReferenceTree::ITEM_NAME), QStringLiteral(\"Instantiations\"));\r\n    QCOMPARE(instantiationsItem->text(ParameterReferenceTree::ITEM_EXPRESSION), QString());\r\n    QCOMPARE(instantiationsItem->background(ParameterReferenceTree::ITEM_EXPRESSION).color(), \r\n        KactusColors::STRONG_FIELD);\r\n\r\n    QTreeWidgetItem* componentInstantiationsItem = instantiationsItem->child(0);\r\n    QCOMPARE(componentInstantiationsItem->text(ParameterReferenceTree::ITEM_NAME), \r\n        QStringLiteral(\"Component instantiations\"));\r\n    QCOMPARE(componentInstantiationsItem->text(ParameterReferenceTree::ITEM_EXPRESSION), QString());\r\n  \r\n    QCOMPARE(componentInstantiationsItem->childCount(), 1);\r\n    QTreeWidgetItem* singleInstantiationItem = componentInstantiationsItem->child(0);\r\n    QCOMPARE(singleInstantiationItem->text(ParameterReferenceTree::ITEM_NAME), instantiation->name());\r\n    QCOMPARE(singleInstantiationItem->text(ParameterReferenceTree::ITEM_EXPRESSION), QString());\r\n\r\n    QCOMPARE(singleInstantiationItem->childCount(), 1);\r\n    QTreeWidgetItem* viewModuleParametersItem = singleInstantiationItem->child(0);\r\n    QCOMPARE(viewModuleParametersItem->text(ParameterReferenceTree::ITEM_NAME),\r\n        QStringLiteral(\"Module Parameters\"));\r\n    QCOMPARE(viewModuleParametersItem->text(ParameterReferenceTree::ITEM_EXPRESSION), QString());\r\n    QCOMPARE(viewModuleParametersItem->background(ParameterReferenceTree::ITEM_EXPRESSION).color(), \r\n        KactusColors::STRONG_FIELD);\r\n\r\n    QCOMPARE(singleInstantiationItem->childCount(), 1);\r\n    QTreeWidgetItem* parameterItem = viewModuleParametersItem->child(0);\r\n    QCOMPARE(parameterItem->text(ParameterReferenceTree::ITEM_NAME), moduleParameterRef->name());\r\n    QCOMPARE(parameterItem->text(ParameterReferenceTree::ITEM_EXPRESSION), QString());\r\n\r\n    QCOMPARE(parameterItem->childCount(), 1);\r\n    QTreeWidgetItem* valueItem = parameterItem->child(0);\r\n    QCOMPARE(valueItem->text(ParameterReferenceTree::ITEM_NAME), QStringLiteral(\"Value\"));\r\n    QCOMPARE(valueItem->text(ParameterReferenceTree::ITEM_EXPRESSION),\r\n        expressionFormatter->formatReferringExpression(moduleParameterRef->getValue()));\r\n\r\n    QCOMPARE(valueItem->childCount(), 0);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ParameterReferenceTree::testReferenceInComponentInstantiationFileBuilderAddsFiveRows()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ParameterReferenceTree::testReferenceInComponentInstantiationFileBuilderAddsFiveRows()\r\n{\r\n    QSharedPointer<Parameter> searched(new Parameter());\r\n    searched->setName(\"searchedParameter\");\r\n    searched->setValueId(\"searched\");\r\n\r\n    QSharedPointer<Component> component(new Component(VLNV(), Document::Revision::Std14));\r\n    component->getParameters()->append(searched);  \r\n\r\n    QSharedPointer<FileBuilder> instantiationFileBuilder = createTestFileBuilder(\"systemCSource\", \"searched-2\");\r\n\r\n    QSharedPointer<ComponentInstantiation> instantiation (new ComponentInstantiation(\"compInstantiation\"));\r\n    instantiation->getDefaultFileBuilders()->append(instantiationFileBuilder);\r\n\r\n    QSharedPointer<View> viewRef(new View(\"viewRef\"));\r\n    viewRef->setComponentInstantiationRef(instantiation->name());\r\n\r\n    component->getViews()->append(viewRef);\r\n    component->getComponentInstantiations()->append(instantiation);\r\n\r\n    QSharedPointer<ExpressionFormatter> expressionFormatter = createTestExpressionFormatter(component);\r\n\r\n    QScopedPointer<ComponentParameterReferenceTree> tree(createTestTree(component));\r\n    tree->openReferenceTree(QStringLiteral(\"searched\"));\r\n\r\n    QCOMPARE(tree->topLevelItemCount(), 1);\r\n    QTreeWidgetItem* instantiationsItem = tree->topLevelItem(0);\r\n    QCOMPARE(instantiationsItem->text(ParameterReferenceTree::ITEM_NAME), \r\n        QStringLiteral(\"Instantiations\"));\r\n    QCOMPARE(instantiationsItem->text(ParameterReferenceTree::ITEM_EXPRESSION), QString());\r\n    QCOMPARE(instantiationsItem->background(ParameterReferenceTree::ITEM_EXPRESSION).color(),\r\n        KactusColors::STRONG_FIELD);\r\n\r\n    QTreeWidgetItem* componentInstantiationsItem = instantiationsItem->child(0);\r\n    QCOMPARE(componentInstantiationsItem->text(ParameterReferenceTree::ITEM_NAME), \r\n        QStringLiteral(\"Component instantiations\"));\r\n    QCOMPARE(componentInstantiationsItem->text(ParameterReferenceTree::ITEM_EXPRESSION), QString());\r\n\r\n    QCOMPARE(componentInstantiationsItem->childCount(), 1);\r\n    QTreeWidgetItem* singleInstantiationItem = componentInstantiationsItem->child(0);\r\n    QCOMPARE(singleInstantiationItem->text(ParameterReferenceTree::ITEM_NAME), instantiation->name());\r\n    QCOMPARE(singleInstantiationItem->text(ParameterReferenceTree::ITEM_EXPRESSION), QString());\r\n\r\n    QCOMPARE(singleInstantiationItem->childCount(), 1);\r\n    QTreeWidgetItem* defaultFileBuildersItem = singleInstantiationItem->child(0);\r\n    QCOMPARE(defaultFileBuildersItem->text(ParameterReferenceTree::ITEM_NAME),\r\n        QStringLiteral(\"Default file build commands\"));\r\n    QCOMPARE(defaultFileBuildersItem->text(ParameterReferenceTree::ITEM_EXPRESSION), QString());\r\n\r\n    QCOMPARE(defaultFileBuildersItem->childCount(), 1);\r\n    QTreeWidgetItem* fileBuilderItem = defaultFileBuildersItem->child(0);\r\n    QCOMPARE(fileBuilderItem->text(ParameterReferenceTree::ITEM_NAME),\r\n        QStringLiteral(\"File type: \") + instantiationFileBuilder->getFileType().type_);\r\n    QCOMPARE(fileBuilderItem->text(ParameterReferenceTree::ITEM_EXPRESSION), QString());\r\n\r\n    QCOMPARE(fileBuilderItem->childCount(), 1);\r\n    QTreeWidgetItem* replaceFlagsItem = fileBuilderItem->child(0);\r\n    QCOMPARE(replaceFlagsItem->text(ParameterReferenceTree::ITEM_NAME), QStringLiteral(\"Replace default flags\"));\r\n    QCOMPARE(replaceFlagsItem->text(ParameterReferenceTree::ITEM_EXPRESSION),\r\n        expressionFormatter->formatReferringExpression(instantiationFileBuilder->getReplaceDefaultFlags()));\r\n\r\n    QCOMPARE(replaceFlagsItem->childCount(), 0);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ParameterReferenceTree::testReferenceInPortRightboundAddsThreeRows()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ParameterReferenceTree::testReferenceInPortRightboundAddsThreeRows()\r\n{\r\n    QSharedPointer<Parameter> searched(new Parameter);\r\n    searched->setName(\"searchedParameter\");\r\n    searched->setValueId(\"searched\");\r\n\r\n    QList < QSharedPointer<Parameter> > componentParameters;\r\n    componentParameters.append(searched);\r\n\r\n    QSharedPointer<Port> portRef = createTestPort(\"portRef\", \"\", \"searched\", \"\", \"\", \"\");\r\n\r\n    QSharedPointer<Component> component(new Component(VLNV(), Document::Revision::Std14));\r\n    component->getPorts()->append(portRef);\r\n    component->getParameters()->append(componentParameters);\r\n\r\n    QSharedPointer<ExpressionFormatter> expressionFormatter = createTestExpressionFormatter(component);\r\n  \r\n    QScopedPointer<ComponentParameterReferenceTree> tree(createTestTree(component));\r\n    tree->openReferenceTree(QStringLiteral(\"searched\"));\r\n\r\n    QCOMPARE(tree->topLevelItemCount(), 1);\r\n    QCOMPARE(tree->topLevelItem(0)->text(ParameterReferenceTree::ITEM_NAME), QStringLiteral(\"Ports\"));\r\n    QCOMPARE(tree->topLevelItem(0)->text(ParameterReferenceTree::ITEM_EXPRESSION), QString());\r\n\r\n    QCOMPARE(tree->topLevelItem(0)->childCount(), 1);\r\n    QCOMPARE(tree->topLevelItem(0)->child(0)->text(ParameterReferenceTree::ITEM_NAME), portRef->name());\r\n    QCOMPARE(tree->topLevelItem(0)->child(0)->text(ParameterReferenceTree::ITEM_EXPRESSION), QString());\r\n\r\n    QCOMPARE(tree->topLevelItem(0)->child(0)->childCount(), 1);\r\n    QCOMPARE(tree->topLevelItem(0)->child(0)->child(0)->text(ParameterReferenceTree::ITEM_NAME),\r\n        QStringLiteral(\"Right Bound\"));\r\n    QCOMPARE(tree->topLevelItem(0)->child(0)->child(0)->text(ParameterReferenceTree::ITEM_EXPRESSION),\r\n        expressionFormatter->formatReferringExpression(portRef->getRightBound()));\r\n\r\n    QCOMPARE(tree->topLevelItem(0)->child(0)->child(0)->childCount(), 0);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ParameterReferenceTree::testReferenceInPortArraysAddsThreeRows()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ParameterReferenceTree::testReferenceInPortArraysAddsThreeRows()\r\n{\r\n    QSharedPointer<Parameter> searched(new Parameter);\r\n    searched->setName(\"searchedParameter\");\r\n    searched->setValueId(\"searched\");\r\n\r\n    QList<QSharedPointer<Parameter> > componentParameters;\r\n    componentParameters.append(searched);\r\n\r\n    QSharedPointer<Port> portRef = createTestPort(\"portRef\", \"\", \"\", \"\", \"searched\", \"searched\");\r\n    \r\n    QSharedPointer<Component> component(new Component(VLNV(), Document::Revision::Std14));\r\n    component->getPorts()->append(portRef);\r\n    component->getParameters()->append(componentParameters);\r\n\r\n    QSharedPointer<ExpressionFormatter> expressionFormatter = createTestExpressionFormatter(component);\r\n\r\n    QScopedPointer<ComponentParameterReferenceTree> tree(createTestTree(component));\r\n    tree->openReferenceTree(QStringLiteral(\"searched\"));\r\n\r\n    QCOMPARE(tree->topLevelItemCount(), 1);\r\n    QCOMPARE(tree->topLevelItem(0)->text(ParameterReferenceTree::ITEM_NAME), QStringLiteral(\"Ports\"));\r\n    QCOMPARE(tree->topLevelItem(0)->text(ParameterReferenceTree::ITEM_EXPRESSION), QString());\r\n\r\n    QCOMPARE(tree->topLevelItem(0)->childCount(), 1);\r\n    QCOMPARE(tree->topLevelItem(0)->child(0)->text(ParameterReferenceTree::ITEM_NAME), portRef->name());\r\n    QCOMPARE(tree->topLevelItem(0)->child(0)->text(ParameterReferenceTree::ITEM_EXPRESSION), QString());\r\n\r\n    QCOMPARE(tree->topLevelItem(0)->child(0)->childCount(), 2);\r\n    QCOMPARE(tree->topLevelItem(0)->child(0)->child(0)->text(ParameterReferenceTree::ITEM_NAME),\r\n        QStringLiteral(\"Array Left\"));\r\n    QCOMPARE(tree->topLevelItem(0)->child(0)->child(0)->text(ParameterReferenceTree::ITEM_EXPRESSION),\r\n        QStringLiteral(\"searchedParameter\"));\r\n    QCOMPARE(tree->topLevelItem(0)->child(0)->child(0)->childCount(), 0);\r\n\r\n    QCOMPARE(tree->topLevelItem(0)->child(0)->child(1)->text(ParameterReferenceTree::ITEM_NAME),\r\n        QStringLiteral(\"Array Right\"));\r\n    QCOMPARE(tree->topLevelItem(0)->child(0)->child(1)->text(ParameterReferenceTree::ITEM_EXPRESSION),\r\n        QStringLiteral(\"searchedParameter\"));\r\n    QCOMPARE(tree->topLevelItem(0)->child(0)->child(1)->childCount(), 0);\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ParameterReferenceTree::testReferenceInAddressBlockBaseAddressAddsSevenRows()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ParameterReferenceTree::testReferenceInAddressBlockBaseAddressAddsSevenRows()\r\n{\r\n    QSharedPointer<Parameter> searched(new Parameter);\r\n    searched->setName(\"searchedParameter\");\r\n    searched->setValueId(\"searched\");\r\n\r\n    QSharedPointer<AddressBlock> addressRef = createTestAddressBlock(\"addressBlockRef\", \"searched\", \"2\", \"32\");\r\n\r\n    QSharedPointer<MemoryMap> memoryMapRef = createTestMemoryMap(\"memoryMapRef\");\r\n    memoryMapRef->getMemoryBlocks()->append(addressRef);\r\n\r\n    QSharedPointer<Component> component(new Component(VLNV(), Document::Revision::Std14));\r\n    component->getParameters()->append(searched);\r\n    component->getMemoryMaps()->append(memoryMapRef);\r\n\r\n    QSharedPointer<ExpressionFormatter> expressionFormatter = createTestExpressionFormatter(component);\r\n\r\n    QScopedPointer<ComponentParameterReferenceTree> tree(createTestTree(component));\r\n    tree->openReferenceTree(QStringLiteral(\"searched\"));\r\n\r\n    QCOMPARE(tree->topLevelItemCount(), 1);\r\n    QCOMPARE(tree->topLevelItem(0)->text(ParameterReferenceTree::ITEM_NAME), QStringLiteral(\"Memory maps\"));\r\n    QCOMPARE(tree->topLevelItem(0)->text(ParameterReferenceTree::ITEM_EXPRESSION), QString());\r\n\r\n    QCOMPARE(tree->topLevelItem(0)->childCount(), 1);\r\n    QCOMPARE(tree->topLevelItem(0)->child(0)->text(ParameterReferenceTree::ITEM_NAME), memoryMapRef->name());\r\n    QCOMPARE(tree->topLevelItem(0)->child(0)->text(ParameterReferenceTree::ITEM_EXPRESSION), QString());\r\n\r\n    QCOMPARE(tree->topLevelItem(0)->child(0)->childCount(), 1);\r\n    QCOMPARE(tree->topLevelItem(0)->child(0)->child(0)->text(ParameterReferenceTree::ITEM_NAME),\r\n        QStringLiteral(\"Memory remaps\"));\r\n    QCOMPARE(tree->topLevelItem(0)->child(0)->child(0)->text(ParameterReferenceTree::ITEM_EXPRESSION), QString());\r\n\r\n    QCOMPARE(tree->topLevelItem(0)->child(0)->child(0)->childCount(), 1);\r\n    QCOMPARE(tree->topLevelItem(0)->child(0)->child(0)->child(0)->text(ParameterReferenceTree::ITEM_NAME),\r\n        QStringLiteral(\"Default\"));\r\n    QCOMPARE(tree->topLevelItem(0)->child(0)->child(0)->child(0)->text(ParameterReferenceTree::ITEM_EXPRESSION),\r\n        QString());\r\n\r\n    QCOMPARE(tree->topLevelItem(0)->child(0)->child(0)->child(0)->childCount(), 1);\r\n    QCOMPARE(tree->topLevelItem(0)->child(0)->child(0)->child(0)->child(0)->text(ParameterReferenceTree::ITEM_NAME),\r\n        QStringLiteral(\"Address blocks\"));\r\n    QCOMPARE(tree->topLevelItem(0)->child(0)->child(0)->child(0)->child(0)->text(\r\n        ParameterReferenceTree::ITEM_EXPRESSION), QString());\r\n\r\n    QCOMPARE(tree->topLevelItem(0)->child(0)->child(0)->child(0)->child(0)->childCount(), 1);\r\n    QCOMPARE(tree->topLevelItem(0)->child(0)->child(0)->child(0)->child(0)->child(0)->text(\r\n        ParameterReferenceTree::ITEM_NAME), addressRef->name());\r\n    QCOMPARE(tree->topLevelItem(0)->child(0)->child(0)->child(0)->child(0)->child(0)->text(\r\n        ParameterReferenceTree::ITEM_EXPRESSION), QString());\r\n\r\n    QCOMPARE(tree->topLevelItem(0)->child(0)->child(0)->child(0)->child(0)->child(0)->childCount(), 1);\r\n    QCOMPARE(tree->topLevelItem(0)->child(0)->child(0)->child(0)->child(0)->child(0)->child(0)->text(\r\n        ParameterReferenceTree::ITEM_NAME), QStringLiteral(\"Base Address\"));\r\n    QCOMPARE(tree->topLevelItem(0)->child(0)->child(0)->child(0)->child(0)->child(0)->child(0)->text(\r\n        ParameterReferenceTree::ITEM_EXPRESSION), expressionFormatter->formatReferringExpression(\r\n        addressRef->getBaseAddress()));\r\n\r\n    QCOMPARE(tree->topLevelItem(0)->child(0)->child(0)->child(0)->child(0)->child(0)->child(0)->childCount(), 0);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ParameterReferenceTree::testReferenceInAddressBlockNoReferenceInRegister()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ParameterReferenceTree::testReferenceInAddressBlockNoReferenceInRegister()\r\n{\r\n    QSharedPointer<Parameter> searched(new Parameter);\r\n    searched->setName(\"searchedParameter\");\r\n    searched->setValueId(\"searched\");\r\n\r\n    QList < QSharedPointer <Parameter> > componentParameters;\r\n    componentParameters.append(searched);\r\n\r\n    QSharedPointer<Register> registerRef = createTestRegister(\"registerRef\", \"test\", \"testing\");\r\n\r\n    QSharedPointer<AddressBlock> addressRef = createTestAddressBlock(\"addressBlockRef\", \"searched\", \"2\", \"32\");\r\n    addressRef->getRegisterData()->append(registerRef);\r\n\r\n    QSharedPointer<MemoryRemap> memoryRemapRef = createTestMemoryRemap(\"memoryRemapRef\");\r\n    memoryRemapRef->getMemoryBlocks()->append(addressRef);\r\n\r\n    QSharedPointer<MemoryMap> memoryMapRef = createTestMemoryMap(\"memoryMapRef\");\r\n    memoryMapRef->getMemoryRemaps()->append(memoryRemapRef);\r\n\r\n    QSharedPointer<Component> component(new Component(VLNV(), Document::Revision::Std14));\r\n    component->getMemoryMaps()->append(memoryMapRef);\r\n    component->getParameters()->append(componentParameters);\r\n\r\n    QSharedPointer<ExpressionFormatter> expressionFormatter = createTestExpressionFormatter(component);\r\n\r\n    QScopedPointer<ComponentParameterReferenceTree> tree(createTestTree(component));\r\n    tree->openReferenceTree(QStringLiteral(\"searched\"));\r\n\r\n    QCOMPARE(tree->topLevelItemCount(), 1);\r\n    QCOMPARE(tree->topLevelItem(0)->text(ParameterReferenceTree::ITEM_NAME), QStringLiteral(\"Memory maps\"));\r\n    QCOMPARE(tree->topLevelItem(0)->text(ParameterReferenceTree::ITEM_EXPRESSION), QString());\r\n\r\n    QCOMPARE(tree->topLevelItem(0)->childCount(), 1);\r\n    QCOMPARE(tree->topLevelItem(0)->child(0)->text(ParameterReferenceTree::ITEM_NAME), memoryMapRef->name());\r\n    QCOMPARE(tree->topLevelItem(0)->child(0)->text(ParameterReferenceTree::ITEM_EXPRESSION), QString());\r\n\r\n    QCOMPARE(tree->topLevelItem(0)->child(0)->childCount(), 1);\r\n    QCOMPARE(tree->topLevelItem(0)->child(0)->child(0)->text(ParameterReferenceTree::ITEM_NAME),\r\n        QStringLiteral(\"Memory remaps\"));\r\n    QCOMPARE(tree->topLevelItem(0)->child(0)->child(0)->text(ParameterReferenceTree::ITEM_EXPRESSION), QString());\r\n\r\n    QCOMPARE(tree->topLevelItem(0)->child(0)->child(0)->childCount(), 1);\r\n    QCOMPARE(tree->topLevelItem(0)->child(0)->child(0)->child(0)->text(ParameterReferenceTree::ITEM_NAME),\r\n        QStringLiteral(\"memoryRemapRef\"));\r\n    QCOMPARE(tree->topLevelItem(0)->child(0)->child(0)->child(0)->text(ParameterReferenceTree::ITEM_EXPRESSION),\r\n        QString());\r\n\r\n    QCOMPARE(tree->topLevelItem(0)->child(0)->child(0)->child(0)->childCount(), 1);\r\n    QCOMPARE(tree->topLevelItem(0)->child(0)->child(0)->child(0)->child(0)->text(ParameterReferenceTree::ITEM_NAME),\r\n        QStringLiteral(\"Address blocks\"));\r\n    QCOMPARE(tree->topLevelItem(0)->child(0)->child(0)->child(0)->child(0)->text(\r\n        ParameterReferenceTree::ITEM_EXPRESSION), QString());\r\n\r\n    QCOMPARE(tree->topLevelItem(0)->child(0)->child(0)->child(0)->child(0)->childCount(), 1);\r\n    QCOMPARE(tree->topLevelItem(0)->child(0)->child(0)->child(0)->child(0)->child(0)->text(\r\n        ParameterReferenceTree::ITEM_NAME), addressRef->name());\r\n    QCOMPARE(tree->topLevelItem(0)->child(0)->child(0)->child(0)->child(0)->child(0)->text(\r\n        ParameterReferenceTree::ITEM_EXPRESSION), QString());\r\n\r\n    QCOMPARE(tree->topLevelItem(0)->child(0)->child(0)->child(0)->child(0)->child(0)->childCount(), 1);\r\n    QCOMPARE(tree->topLevelItem(0)->child(0)->child(0)->child(0)->child(0)->child(0)->child(0)->text(\r\n        ParameterReferenceTree::ITEM_NAME), QStringLiteral(\"Base Address\"));\r\n    QCOMPARE(tree->topLevelItem(0)->child(0)->child(0)->child(0)->child(0)->child(0)->child(0)->text(\r\n        ParameterReferenceTree::ITEM_EXPRESSION), expressionFormatter->formatReferringExpression(\r\n        addressRef->getBaseAddress()));\r\n\r\n    QCOMPARE(tree->topLevelItem(0)->child(0)->child(0)->child(0)->child(0)->child(0)->child(0)->childCount(), 0);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ParameterReferenceTree::testReferenceInRegisterDimensionAddsEightRows()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ParameterReferenceTree::testReferenceInRegisterDimensionAddsNineRows()\r\n{\r\n    QSharedPointer<Parameter> searched(new Parameter);\r\n    searched->setName(\"searchedParameter\");\r\n    searched->setValueId(\"searched\");\r\n\r\n    QList < QSharedPointer <Parameter> > componentParameters;\r\n    componentParameters.append(searched);\r\n\r\n    QSharedPointer<Register> registerRef = createTestRegister(\"registerRef\", \"test\", \"searched\");\r\n\r\n    QSharedPointer<AddressBlock> addressRef = createTestAddressBlock(\"addressBlockRef\", \"test\", \"\", \"\");\r\n    addressRef->getRegisterData()->append(registerRef);\r\n\r\n    QSharedPointer<MemoryMap> memoryMapRef = createTestMemoryMap(\"memoryMapRef\");\r\n    memoryMapRef->getMemoryBlocks()->append(addressRef);\r\n\r\n    QSharedPointer<Component> component(new Component(VLNV(), Document::Revision::Std14));\r\n    component->getMemoryMaps()->append(memoryMapRef);\r\n    component->getParameters()->append(componentParameters);\r\n\r\n    QSharedPointer<ExpressionFormatter> expressionFormatter = createTestExpressionFormatter(component);\r\n\r\n    QScopedPointer<ComponentParameterReferenceTree> tree(createTestTree(component));\r\n    tree->openReferenceTree(QStringLiteral(\"searched\"));\r\n\r\n    QCOMPARE(tree->topLevelItemCount(), 1);\r\n    QTreeWidgetItem* memoryMapsItem = tree->topLevelItem(0);\r\n    QCOMPARE(memoryMapsItem->text(ParameterReferenceTree::ITEM_NAME), QStringLiteral(\"Memory maps\"));\r\n    QCOMPARE(memoryMapsItem->text(ParameterReferenceTree::ITEM_EXPRESSION), QString());\r\n\r\n    QCOMPARE(memoryMapsItem->childCount(), 1);\r\n    QTreeWidgetItem* memoryMapItem = memoryMapsItem->child(0);\r\n    QCOMPARE(memoryMapItem->text(ParameterReferenceTree::ITEM_NAME), memoryMapRef->name());\r\n    QCOMPARE(memoryMapItem->text(ParameterReferenceTree::ITEM_EXPRESSION), QString());\r\n\r\n    QCOMPARE(memoryMapItem->childCount(), 1);\r\n    QTreeWidgetItem* remapsItem = memoryMapItem->child(0);\r\n    QCOMPARE(remapsItem->text(ParameterReferenceTree::ITEM_NAME), QStringLiteral(\"Memory remaps\"));\r\n    QCOMPARE(remapsItem->text(ParameterReferenceTree::ITEM_EXPRESSION), QString());\r\n\r\n    QCOMPARE(remapsItem->childCount(), 1);\r\n    QTreeWidgetItem* defaultRemap = remapsItem->child(0);\r\n    QCOMPARE(defaultRemap->text(ParameterReferenceTree::ITEM_NAME), QStringLiteral(\"Default\"));\r\n    QCOMPARE(defaultRemap->text(ParameterReferenceTree::ITEM_EXPRESSION), QString());\r\n\r\n    QCOMPARE(defaultRemap->childCount(), 1);\r\n    QTreeWidgetItem* addressBlocksItem = defaultRemap->child(0);\r\n    QCOMPARE(addressBlocksItem->text(ParameterReferenceTree::ITEM_NAME), QStringLiteral(\"Address blocks\"));\r\n    QCOMPARE(addressBlocksItem->text(ParameterReferenceTree::ITEM_EXPRESSION), QString());\r\n\r\n    QCOMPARE(addressBlocksItem->childCount(), 1);\r\n    QTreeWidgetItem* addressBlock = addressBlocksItem->child(0);\r\n    QCOMPARE(addressBlock->text(ParameterReferenceTree::ITEM_NAME), addressRef->name());\r\n    QCOMPARE(addressBlock->text(ParameterReferenceTree::ITEM_EXPRESSION), QString());\r\n\r\n    QCOMPARE(addressBlock->childCount(), 1);\r\n    QTreeWidgetItem* registerListItem = addressBlock->child(0);\r\n    QCOMPARE(registerListItem->text(ParameterReferenceTree::ITEM_NAME), QStringLiteral(\"Registers\"));\r\n    QCOMPARE(registerListItem->text(ParameterReferenceTree::ITEM_EXPRESSION), QString());\r\n\r\n    QTreeWidgetItem* registerItem = registerListItem->child(0);\r\n    QCOMPARE(registerItem->text(ParameterReferenceTree::ITEM_NAME), registerRef->name());\r\n    QCOMPARE(registerItem->text(ParameterReferenceTree::ITEM_EXPRESSION), QString());\r\n\r\n    QCOMPARE(registerItem->childCount(), 1);\r\n    QTreeWidgetItem* dimensionItem = registerItem->child(0);\r\n    QCOMPARE(dimensionItem->text(ParameterReferenceTree::ITEM_NAME), QStringLiteral(\"Dimension\"));\r\n    QCOMPARE(dimensionItem->text(ParameterReferenceTree::ITEM_EXPRESSION),\r\n        expressionFormatter->formatReferringExpression(registerRef->getDimension()));\r\n\r\n    QCOMPARE(dimensionItem->childCount(), 0);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ParameterReferenceTree::testReferenceInRegisterIsPresentAddsEightRows()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ParameterReferenceTree::testReferenceInRegisterIsPresentAddsNineRows()\r\n{\r\n    QSharedPointer<Parameter> searched(new Parameter);\r\n    searched->setName(\"searchedParameter\");\r\n    searched->setValueId(\"searched\");\r\n\r\n    QList < QSharedPointer <Parameter> > componentParameters;\r\n    componentParameters.append(searched);\r\n\r\n    QSharedPointer<Register> registerRef = createTestRegister(\"registerRef\", \"test\", \"1\");\r\n    registerRef->setIsPresent(\"searched\");\r\n\r\n    QSharedPointer<AddressBlock> addressRef = createTestAddressBlock(\"addressBlockRef\", \"test\", \"\", \"\");\r\n    addressRef->getRegisterData()->append(registerRef);\r\n\r\n    QSharedPointer<MemoryMap> memoryMapRef = createTestMemoryMap(\"memoryMapRef\");\r\n    memoryMapRef->getMemoryBlocks()->append(addressRef);\r\n\r\n    QSharedPointer<Component> component(new Component(VLNV(), Document::Revision::Std14));\r\n    component->getMemoryMaps()->append(memoryMapRef);\r\n    component->getParameters()->append(componentParameters);\r\n\r\n    QSharedPointer<ExpressionFormatter> expressionFormatter = createTestExpressionFormatter(component);\r\n\r\n    QScopedPointer<ComponentParameterReferenceTree> tree(createTestTree(component));\r\n    tree->openReferenceTree(QStringLiteral(\"searched\"));\r\n\r\n    QCOMPARE(tree->topLevelItemCount(), 1);\r\n    QTreeWidgetItem* memoryMapsItem = tree->topLevelItem(0);\r\n    QCOMPARE(memoryMapsItem->text(ParameterReferenceTree::ITEM_NAME), QStringLiteral(\"Memory maps\"));\r\n    QCOMPARE(memoryMapsItem->text(ParameterReferenceTree::ITEM_EXPRESSION), QString());\r\n\r\n    QCOMPARE(memoryMapsItem->childCount(), 1);\r\n    QTreeWidgetItem* memoryMapItem = memoryMapsItem->child(0);\r\n    QCOMPARE(memoryMapItem->text(ParameterReferenceTree::ITEM_NAME), memoryMapRef->name());\r\n    QCOMPARE(memoryMapItem->text(ParameterReferenceTree::ITEM_EXPRESSION), QString());\r\n\r\n    QCOMPARE(memoryMapItem->childCount(), 1);\r\n    QTreeWidgetItem* remapsItem = memoryMapItem->child(0);\r\n    QCOMPARE(remapsItem->text(ParameterReferenceTree::ITEM_NAME), QStringLiteral(\"Memory remaps\"));\r\n    QCOMPARE(remapsItem->text(ParameterReferenceTree::ITEM_EXPRESSION), QString());\r\n\r\n    QCOMPARE(remapsItem->childCount(), 1);\r\n    QTreeWidgetItem* defaultRemap = remapsItem->child(0);\r\n    QCOMPARE(defaultRemap->text(ParameterReferenceTree::ITEM_NAME), QStringLiteral(\"Default\"));\r\n    QCOMPARE(defaultRemap->text(ParameterReferenceTree::ITEM_EXPRESSION), QString());\r\n\r\n    QCOMPARE(defaultRemap->childCount(), 1);\r\n    QTreeWidgetItem* addressBlocksItem = defaultRemap->child(0);\r\n    QCOMPARE(addressBlocksItem->text(ParameterReferenceTree::ITEM_NAME), QStringLiteral(\"Address blocks\"));\r\n    QCOMPARE(addressBlocksItem->text(ParameterReferenceTree::ITEM_EXPRESSION), QString());\r\n\r\n    QCOMPARE(addressBlocksItem->childCount(), 1);\r\n    QTreeWidgetItem* addressBlock = addressBlocksItem->child(0);\r\n    QCOMPARE(addressBlock->text(ParameterReferenceTree::ITEM_NAME), addressRef->name());\r\n    QCOMPARE(addressBlock->text(ParameterReferenceTree::ITEM_EXPRESSION), QString());\r\n\r\n    QCOMPARE(addressBlock->childCount(), 1);\r\n    QTreeWidgetItem* registerListItem = addressBlock->child(0);\r\n    QCOMPARE(registerListItem->text(ParameterReferenceTree::ITEM_NAME), QStringLiteral(\"Registers\"));\r\n    QCOMPARE(registerListItem->text(ParameterReferenceTree::ITEM_EXPRESSION), QString());\r\n\r\n    QTreeWidgetItem* registerItem = registerListItem->child(0);\r\n    QCOMPARE(registerItem->text(ParameterReferenceTree::ITEM_NAME), registerRef->name());\r\n    QCOMPARE(registerItem->text(ParameterReferenceTree::ITEM_EXPRESSION), QString());\r\n\r\n    QCOMPARE(registerItem->childCount(), 1);\r\n    QTreeWidgetItem* isPresentItem = registerItem->child(0);\r\n    QCOMPARE(isPresentItem->text(ParameterReferenceTree::ITEM_NAME), QStringLiteral(\"Is present\"));\r\n    QCOMPARE(isPresentItem->text(ParameterReferenceTree::ITEM_EXPRESSION),\r\n        expressionFormatter->formatReferringExpression(registerRef->getIsPresent()));\r\n\r\n    QCOMPARE(isPresentItem->childCount(), 0);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ParameterReferenceTree::testReferenceInMultipleRegisters()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ParameterReferenceTree::testReferenceInMultipleRegistersInTwoAddressBlocks()\r\n{\r\n    QSharedPointer<Parameter> searched(new Parameter);\r\n    searched->setName(\"searchedParameter\");\r\n    searched->setValueId(\"searched\");\r\n\r\n    QList<QSharedPointer<Parameter> > componentParameters;\r\n    componentParameters.append(searched);\r\n\r\n    QSharedPointer <Register> registerOne_1 = createTestRegister(\"registerOne_1\", \"\", \"searched\");\r\n    QSharedPointer <Register> registerTwo_1 = createTestRegister(\"registerTwo_1\", \"searched\", \"\");\r\n\r\n    QSharedPointer <AddressBlock> addressBlockOne = createTestAddressBlock(\"addressBlockOne\", \"\", \"\", \"\");\r\n    addressBlockOne->getRegisterData()->append(registerOne_1);\r\n    addressBlockOne->getRegisterData()->append(registerTwo_1);\r\n\r\n    QSharedPointer <Register> registerOne_2 = createTestRegister(\"registerOne_2\", \"searched\", \"searched\");\r\n\r\n    QSharedPointer <AddressBlock> addressBlockTwo = createTestAddressBlock(\"addressBlockTwo\", \"\", \"\", \"\");\r\n    addressBlockTwo->getRegisterData()->append(registerOne_2);\r\n\r\n    QSharedPointer<MemoryMap> memoryMapRef = createTestMemoryMap(\"memoryMapRef\");\r\n    memoryMapRef->getMemoryBlocks()->append(addressBlockOne);\r\n    memoryMapRef->getMemoryBlocks()->append(addressBlockTwo);\r\n\r\n    QSharedPointer<Component> component(new Component(VLNV(), Document::Revision::Std14));\r\n    component->getMemoryMaps()->append(memoryMapRef);\r\n    component->getParameters()->append(componentParameters);\r\n\r\n    QSharedPointer<ExpressionFormatter> expressionFormatter = createTestExpressionFormatter(component);\r\n\r\n    QScopedPointer<ComponentParameterReferenceTree> tree(createTestTree(component));\r\n    tree->openReferenceTree(QStringLiteral(\"searched\"));\r\n\r\n    QCOMPARE(tree->topLevelItemCount(), 1);\r\n\r\n    QCOMPARE(tree->topLevelItem(0)->text(ParameterReferenceTree::ITEM_NAME), QStringLiteral(\"Memory maps\"));\r\n    QCOMPARE(tree->topLevelItem(0)->text(ParameterReferenceTree::ITEM_EXPRESSION), QString());\r\n    QCOMPARE(tree->topLevelItem(0)->childCount(), 1);\r\n\r\n    QCOMPARE(tree->topLevelItem(0)->child(0)->text(ParameterReferenceTree::ITEM_NAME), memoryMapRef->name());\r\n    QCOMPARE(tree->topLevelItem(0)->child(0)->text(ParameterReferenceTree::ITEM_EXPRESSION), QString());\r\n    QCOMPARE(tree->topLevelItem(0)->child(0)->childCount(), 1);\r\n\r\n    QCOMPARE(tree->topLevelItem(0)->child(0)->child(0)->text(ParameterReferenceTree::ITEM_NAME),\r\n        QStringLiteral(\"Memory remaps\"));\r\n    QCOMPARE(tree->topLevelItem(0)->child(0)->child(0)->text(ParameterReferenceTree::ITEM_EXPRESSION), QString());\r\n    QCOMPARE(tree->topLevelItem(0)->child(0)->child(0)->childCount(), 1);\r\n\r\n    QCOMPARE(tree->topLevelItem(0)->child(0)->child(0)->child(0)->text(ParameterReferenceTree::ITEM_NAME),\r\n        QStringLiteral(\"Default\"));\r\n    QCOMPARE(tree->topLevelItem(0)->child(0)->child(0)->child(0)->text(ParameterReferenceTree::ITEM_EXPRESSION),\r\n        QString());\r\n    QCOMPARE(tree->topLevelItem(0)->child(0)->child(0)->child(0)->childCount(), 1);\r\n\r\n    QCOMPARE(tree->topLevelItem(0)->child(0)->child(0)->child(0)->child(0)->text(ParameterReferenceTree::ITEM_NAME),\r\n        QStringLiteral(\"Address blocks\"));\r\n    QCOMPARE(tree->topLevelItem(0)->child(0)->child(0)->child(0)->child(0)->text(\r\n        ParameterReferenceTree::ITEM_EXPRESSION), QString());\r\n    QCOMPARE(tree->topLevelItem(0)->child(0)->child(0)->child(0)->child(0)->childCount(), 2);\r\n\r\n    QCOMPARE(tree->topLevelItem(0)->child(0)->child(0)->child(0)->child(0)->child(0)->text(\r\n        ParameterReferenceTree::ITEM_NAME), addressBlockOne->name());\r\n    QCOMPARE(tree->topLevelItem(0)->child(0)->child(0)->child(0)->child(0)->child(0)->text(\r\n        ParameterReferenceTree::ITEM_EXPRESSION), QString());\r\n\r\n    QCOMPARE(tree->topLevelItem(0)->child(0)->child(0)->child(0)->child(0)->child(0)->childCount(), 1);\r\n    QTreeWidgetItem* registerListItem =\r\n        tree->topLevelItem(0)->child(0)->child(0)->child(0)->child(0)->child(0)->child(0);\r\n    QCOMPARE(registerListItem->text(ParameterReferenceTree::ITEM_NAME), QStringLiteral(\"Registers\"));\r\n    QCOMPARE(registerListItem->text(ParameterReferenceTree::ITEM_EXPRESSION), QString());\r\n    QCOMPARE(registerListItem->childCount(), 2);\r\n\r\n    QTreeWidgetItem* registerItemOne = registerListItem->child(0);\r\n    QCOMPARE(registerItemOne->text(ParameterReferenceTree::ITEM_NAME), registerOne_1->name());\r\n    QCOMPARE(registerItemOne->text(ParameterReferenceTree::ITEM_EXPRESSION), QString());\r\n    QCOMPARE(registerItemOne->childCount(), 1);\r\n\r\n    QTreeWidgetItem* registerOneDimensionItem = registerItemOne->child(0);\r\n    QCOMPARE(registerOneDimensionItem->text(ParameterReferenceTree::ITEM_NAME), QStringLiteral(\"Dimension\"));\r\n    QCOMPARE(registerOneDimensionItem->text(ParameterReferenceTree::ITEM_EXPRESSION),\r\n        expressionFormatter->formatReferringExpression(registerOne_1->getDimension()));\r\n    QCOMPARE(registerOneDimensionItem->childCount(), 0);\r\n\r\n    QTreeWidgetItem* registerItemTwo = registerListItem->child(1);\r\n    QCOMPARE(registerItemTwo->text(ParameterReferenceTree::ITEM_NAME), registerTwo_1->name());\r\n    QCOMPARE(registerItemTwo->text(ParameterReferenceTree::ITEM_EXPRESSION), QString());\r\n    QCOMPARE(registerItemTwo->childCount(), 1);\r\n\r\n    QTreeWidgetItem* offsetItem = registerItemTwo->child(0);\r\n    QCOMPARE(offsetItem->text(ParameterReferenceTree::ITEM_NAME), QStringLiteral(\"Offset\"));\r\n    QCOMPARE(offsetItem->text(ParameterReferenceTree::ITEM_EXPRESSION),\r\n        expressionFormatter->formatReferringExpression(registerTwo_1->getAddressOffset()));\r\n\r\n    QCOMPARE(tree->topLevelItem(0)->child(0)->child(0)->child(0)->child(0)->child(1)->text(\r\n        ParameterReferenceTree::ITEM_NAME), addressBlockTwo->name());\r\n    QCOMPARE(tree->topLevelItem(0)->child(0)->child(0)->child(0)->child(0)->child(1)->text(\r\n        ParameterReferenceTree::ITEM_EXPRESSION), QString());\r\n    QCOMPARE(tree->topLevelItem(0)->child(0)->child(0)->child(0)->child(0)->child(1)->childCount(), 1);\r\n\r\n    registerListItem = tree->topLevelItem(0)->child(0)->child(0)->child(0)->child(0)->child(1)->child(0);\r\n    QCOMPARE(registerListItem->text(ParameterReferenceTree::ITEM_NAME), QStringLiteral(\"Registers\"));\r\n    QCOMPARE(registerListItem->text(ParameterReferenceTree::ITEM_EXPRESSION), QString());\r\n    QCOMPARE(registerListItem->childCount(), 1);\r\n\r\n    registerItemOne = registerListItem->child(0);\r\n    QCOMPARE(registerItemOne->text(ParameterReferenceTree::ITEM_NAME), registerOne_2->name());\r\n    QCOMPARE(registerItemOne->text(ParameterReferenceTree::ITEM_EXPRESSION), QString());\r\n    QCOMPARE(registerItemOne->childCount(), 2);\r\n\r\n    offsetItem = registerItemOne->child(0);\r\n    QCOMPARE(offsetItem->text(ParameterReferenceTree::ITEM_NAME), QStringLiteral(\"Offset\"));\r\n    QCOMPARE(offsetItem->text(ParameterReferenceTree::ITEM_EXPRESSION),\r\n        expressionFormatter->formatReferringExpression(registerOne_2->getAddressOffset()));\r\n    QCOMPARE(offsetItem->childCount(), 0);\r\n\r\n    QTreeWidgetItem* dimensionItem = registerItemOne->child(1);\r\n    QCOMPARE(dimensionItem->text(ParameterReferenceTree::ITEM_NAME), QStringLiteral(\"Dimension\"));\r\n    QCOMPARE(dimensionItem->text(ParameterReferenceTree::ITEM_EXPRESSION),\r\n        expressionFormatter->formatReferringExpression(registerOne_2->getDimension()));\r\n    QCOMPARE(dimensionItem->childCount(), 0);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ParameterReferenceTree::testUnreferencingRegister()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ParameterReferenceTree::testRegisterwithNoReferences()\r\n{\r\n    QSharedPointer<Parameter> searched(new Parameter);\r\n    searched->setName(\"searchedParameter\");\r\n    searched->setValueId(\"searched\");\r\n\r\n    QList <QSharedPointer<Parameter> > componentParameters;\r\n    componentParameters.append(searched);\r\n\r\n    QSharedPointer <Register> noRefRegister = createTestRegister(\"noRefRegister\", \"test\", \"test\");\r\n    QSharedPointer <Register> refRegister = createTestRegister(\"refRegister\", \"test\", \"searched\");\r\n\r\n    QSharedPointer <AddressBlock> addressBlockRef = createTestAddressBlock(\"addressBlockRef\", \"\", \"\", \"\");\r\n    addressBlockRef->getRegisterData()->append(refRegister);\r\n    addressBlockRef->getRegisterData()->append(noRefRegister);\r\n\r\n    QSharedPointer<MemoryMap> memoryMapRef = createTestMemoryMap(\"memoryMapRef\");\r\n    memoryMapRef->getMemoryBlocks()->append(addressBlockRef);\r\n\r\n    QSharedPointer<Component> component(new Component(VLNV(), Document::Revision::Std14));\r\n    component->getMemoryMaps()->append(memoryMapRef);\r\n    component->getParameters()->append(componentParameters);\r\n\r\n    QSharedPointer<ExpressionFormatter> expressionFormatter = createTestExpressionFormatter(component);\r\n\r\n    QScopedPointer<ComponentParameterReferenceTree> tree(createTestTree(component));\r\n    tree->openReferenceTree(QStringLiteral(\"searched\"));\r\n    \r\n    QCOMPARE(tree->topLevelItemCount(), 1);\r\n    QCOMPARE(tree->topLevelItem(0)->text(ParameterReferenceTree::ITEM_NAME), QStringLiteral(\"Memory maps\"));\r\n    QCOMPARE(tree->topLevelItem(0)->text(ParameterReferenceTree::ITEM_EXPRESSION), QString());\r\n\r\n    QCOMPARE(tree->topLevelItem(0)->childCount(), 1);\r\n    QCOMPARE(tree->topLevelItem(0)->child(0)->text(ParameterReferenceTree::ITEM_NAME), memoryMapRef->name());\r\n    QCOMPARE(tree->topLevelItem(0)->child(0)->text(ParameterReferenceTree::ITEM_EXPRESSION), QString());\r\n\r\n    QCOMPARE(tree->topLevelItem(0)->child(0)->childCount(), 1);\r\n    QCOMPARE(tree->topLevelItem(0)->child(0)->child(0)->text(ParameterReferenceTree::ITEM_NAME),\r\n        QStringLiteral(\"Memory remaps\"));\r\n    QCOMPARE(tree->topLevelItem(0)->child(0)->child(0)->text(ParameterReferenceTree::ITEM_EXPRESSION), QString());\r\n\r\n    QCOMPARE(tree->topLevelItem(0)->child(0)->childCount(), 1);\r\n    QCOMPARE(tree->topLevelItem(0)->child(0)->child(0)->child(0)->text(ParameterReferenceTree::ITEM_NAME),\r\n        QStringLiteral(\"Default\"));\r\n    QCOMPARE(tree->topLevelItem(0)->child(0)->child(0)->child(0)->text(ParameterReferenceTree::ITEM_EXPRESSION),\r\n        QString());\r\n\r\n    QCOMPARE(tree->topLevelItem(0)->child(0)->child(0)->child(0)->childCount(), 1);\r\n    QCOMPARE(tree->topLevelItem(0)->child(0)->child(0)->child(0)->child(0)->text(ParameterReferenceTree::ITEM_NAME),\r\n        QStringLiteral(\"Address blocks\"));\r\n    QCOMPARE(tree->topLevelItem(0)->child(0)->child(0)->child(0)->child(0)->text(\r\n        ParameterReferenceTree::ITEM_EXPRESSION), QString());\r\n\r\n    QCOMPARE(tree->topLevelItem(0)->child(0)->child(0)->child(0)->childCount(), 1);\r\n    QCOMPARE(tree->topLevelItem(0)->child(0)->child(0)->child(0)->child(0)->child(0)->text(\r\n        ParameterReferenceTree::ITEM_NAME), addressBlockRef->name());\r\n    QCOMPARE(tree->topLevelItem(0)->child(0)->child(0)->child(0)->child(0)->child(0)->text(\r\n        ParameterReferenceTree::ITEM_EXPRESSION), QString());\r\n    QCOMPARE(tree->topLevelItem(0)->child(0)->child(0)->child(0)->child(0)->child(0)->childCount(), 1);\r\n\r\n    QTreeWidgetItem* registerListItem =\r\n        tree->topLevelItem(0)->child(0)->child(0)->child(0)->child(0)->child(0)->child(0);\r\n    QCOMPARE(registerListItem->text(ParameterReferenceTree::ITEM_NAME), QStringLiteral(\"Registers\"));\r\n    QCOMPARE(registerListItem->text(ParameterReferenceTree::ITEM_EXPRESSION), QString());\r\n    QCOMPARE(registerListItem->childCount(), 1);\r\n\r\n    QTreeWidgetItem* registerItem = registerListItem->child(0);\r\n    QCOMPARE(registerItem->text(ParameterReferenceTree::ITEM_NAME), QString(refRegister->name()));\r\n    QCOMPARE(registerItem->text(ParameterReferenceTree::ITEM_EXPRESSION), QString());\r\n    QCOMPARE(registerItem->childCount(), 1);\r\n\r\n    QTreeWidgetItem* dimensionItem = registerItem->child(0);\r\n    QCOMPARE(dimensionItem->text(ParameterReferenceTree::ITEM_NAME), QStringLiteral(\"Dimension\"));\r\n    QCOMPARE(dimensionItem->text(ParameterReferenceTree::ITEM_EXPRESSION),\r\n        expressionFormatter->formatReferringExpression(refRegister->getDimension()));\r\n    QCOMPARE(dimensionItem->childCount(), 0);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ParameterReferenceTree::testReferenceInAddressSpaceAddressBlockAddsSixRows()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ParameterReferenceTree::testReferenceInAddressSpaceAddressBlockAddsSixRows()\r\n{\r\n    QSharedPointer<Parameter> searched(new Parameter);\r\n    searched->setName(\"searchedParameter\");\r\n    searched->setValueId(\"searched\");\r\n\r\n    QList <QSharedPointer<Parameter> > componentParameters;\r\n    componentParameters.append(searched);\r\n\r\n    QSharedPointer <AddressBlock> addressBlockRef = createTestAddressBlock(\"addressBlockRef\", \"searched\", \"\", \"\");\r\n\r\n    QSharedPointer<MemoryMapBase> localMemoryMap (new MemoryMapBase(\"localMemMap\"));\r\n    localMemoryMap->getMemoryBlocks()->append(addressBlockRef);\r\n\r\n    QSharedPointer <AddressSpace> addressSpaceRef = createTestAddressSpace(\"addressSpaceRef\");\r\n    addressSpaceRef->setLocalMemoryMap(localMemoryMap);\r\n\r\n    QSharedPointer<Component> component(new Component(VLNV(), Document::Revision::Std14));\r\n    component->getAddressSpaces()->append(addressSpaceRef);\r\n\r\n    QSharedPointer<ExpressionFormatter> expressionFormatter = createTestExpressionFormatter(component);\r\n\r\n    QScopedPointer<ComponentParameterReferenceTree> tree(createTestTree(component));\r\n    tree->openReferenceTree(QStringLiteral(\"searched\"));\r\n\r\n    QCOMPARE(tree->topLevelItemCount(), 1);\r\n    QCOMPARE(tree->topLevelItem(0)->text(ParameterReferenceTree::ITEM_NAME), QStringLiteral(\"Address Spaces\"));\r\n    QCOMPARE(tree->topLevelItem(0)->text(ParameterReferenceTree::ITEM_EXPRESSION), QString());\r\n\r\n    QCOMPARE(tree->topLevelItem(0)->childCount(), 1);\r\n    QCOMPARE(tree->topLevelItem(0)->child(0)->text(ParameterReferenceTree::ITEM_NAME), addressSpaceRef->name());\r\n    QCOMPARE(tree->topLevelItem(0)->child(0)->text(ParameterReferenceTree::ITEM_EXPRESSION), QString());\r\n\r\n    QCOMPARE(tree->topLevelItem(0)->child(0)->childCount(), 1);\r\n    QCOMPARE(tree->topLevelItem(0)->child(0)->child(0)->text(ParameterReferenceTree::ITEM_NAME),\r\n        localMemoryMap->name());\r\n    QCOMPARE(tree->topLevelItem(0)->child(0)->child(0)->text(ParameterReferenceTree::ITEM_EXPRESSION), QString());\r\n\r\n    QCOMPARE(tree->topLevelItem(0)->child(0)->childCount(), 1);\r\n    QCOMPARE(tree->topLevelItem(0)->child(0)->child(0)->child(0)->text(ParameterReferenceTree::ITEM_NAME),\r\n        QStringLiteral(\"Address blocks\"));\r\n    QCOMPARE(tree->topLevelItem(0)->child(0)->child(0)->child(0)->text(ParameterReferenceTree::ITEM_EXPRESSION),\r\n        QString());\r\n\r\n    QCOMPARE(tree->topLevelItem(0)->child(0)->child(0)->child(0)->childCount(), 1);\r\n    QCOMPARE(tree->topLevelItem(0)->child(0)->child(0)->child(0)->child(0)->text(ParameterReferenceTree::ITEM_NAME),\r\n        addressBlockRef->name());\r\n    QCOMPARE(tree->topLevelItem(0)->child(0)->child(0)->child(0)->child(0)->text(\r\n        ParameterReferenceTree::ITEM_EXPRESSION), QString());\r\n\r\n    QCOMPARE(tree->topLevelItem(0)->child(0)->child(0)->child(0)->child(0)->childCount(), 1);\r\n    QCOMPARE(tree->topLevelItem(0)->child(0)->child(0)->child(0)->child(0)->child(0)->text(\r\n        ParameterReferenceTree::ITEM_NAME), QStringLiteral(\"Base Address\"));\r\n    QCOMPARE(tree->topLevelItem(0)->child(0)->child(0)->child(0)->child(0)->child(0)->text(\r\n        ParameterReferenceTree::ITEM_EXPRESSION), expressionFormatter->formatReferringExpression(\r\n        addressBlockRef->getBaseAddress()));\r\n\r\n    QCOMPARE(tree->topLevelItem(0)->child(0)->child(0)->child(0)->child(0)->child(0)->childCount(), 0);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ParameterReferenceTree::testReferenceInAddressSpaceSegmentAddsSixRows()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ParameterReferenceTree::testReferenceInAddressSpaceSegmentAddsSixRows()\r\n{\r\n    QSharedPointer <AddressSpace> addressSpace = createTestAddressSpace(\"addressSpace\");\r\n    addressSpace->setWidth(\"searched\");\r\n    addressSpace->setRange(\"searched+1\");\r\n\r\n    QSharedPointer<Component> component(new Component(VLNV(), Document::Revision::Std14));\r\n    component->getAddressSpaces()->append(addressSpace);\r\n\r\n    QSharedPointer<Segment> testSegment(new Segment());\r\n    testSegment->setName(\"testSegment\");\r\n    testSegment->setOffset(\"searched\");\r\n    testSegment->setRange(\"searched+2\");\r\n\r\n    addressSpace->getSegments()->append(testSegment);\r\n\r\n    QSharedPointer<ExpressionFormatter> expressionFormatter = createTestExpressionFormatter(component);\r\n\r\n    QScopedPointer<ComponentParameterReferenceTree> tree(createTestTree(component));\r\n    tree->openReferenceTree(QStringLiteral(\"searched\"));\r\n\r\n    QCOMPARE(tree->topLevelItemCount(), 1);\r\n    QTreeWidgetItem* addressSpacesItem = tree->topLevelItem(0);\r\n    QCOMPARE(addressSpacesItem->text(ParameterReferenceTree::ITEM_NAME), QStringLiteral(\"Address Spaces\"));\r\n    QCOMPARE(addressSpacesItem->text(ParameterReferenceTree::ITEM_EXPRESSION), QString());\r\n\r\n    QCOMPARE(tree->topLevelItem(0)->childCount(), 1);\r\n    QTreeWidgetItem* testSpaceItem = tree->topLevelItem(0)->child(0);\r\n    QCOMPARE(testSpaceItem->text(ParameterReferenceTree::ITEM_NAME), QStringLiteral(\"addressSpace\"));\r\n    QCOMPARE(testSpaceItem->text(ParameterReferenceTree::ITEM_EXPRESSION), QString());\r\n\r\n    QCOMPARE(testSpaceItem->childCount(), 3);\r\n\r\n    QTreeWidgetItem* widthItem = testSpaceItem->child(0);\r\n    QCOMPARE(widthItem->text(ParameterReferenceTree::ITEM_NAME), QStringLiteral(\"Width\"));\r\n    QCOMPARE(widthItem->text(ParameterReferenceTree::ITEM_EXPRESSION), QStringLiteral(\"searched\"));\r\n\r\n    QTreeWidgetItem* rangeItem = testSpaceItem->child(1);\r\n    QCOMPARE(rangeItem->text(ParameterReferenceTree::ITEM_NAME), QStringLiteral(\"Range\"));\r\n    QCOMPARE(rangeItem->text(ParameterReferenceTree::ITEM_EXPRESSION), QStringLiteral(\"searched+1\"));\r\n\r\n    QTreeWidgetItem* segmentsItem = testSpaceItem->child(2);\r\n    QCOMPARE(segmentsItem->text(ParameterReferenceTree::ITEM_NAME), QStringLiteral(\"Segments\"));\r\n    QCOMPARE(segmentsItem->text(ParameterReferenceTree::ITEM_EXPRESSION), QString());\r\n   \r\n    QCOMPARE(segmentsItem->childCount(), 1);\r\n    QTreeWidgetItem* singleSegmentItem = segmentsItem->child(0);\r\n    QCOMPARE(singleSegmentItem->text(ParameterReferenceTree::ITEM_NAME), QStringLiteral(\"testSegment\"));\r\n    QCOMPARE(singleSegmentItem->text(ParameterReferenceTree::ITEM_EXPRESSION), QString());\r\n\r\n    QCOMPARE(singleSegmentItem->childCount(), 2);\r\n    QTreeWidgetItem* segmentOffsetItem = singleSegmentItem->child(0);\r\n    QCOMPARE(segmentOffsetItem->text(ParameterReferenceTree::ITEM_NAME), QStringLiteral(\"Offset\"));\r\n    QCOMPARE(segmentOffsetItem->text(ParameterReferenceTree::ITEM_EXPRESSION), QStringLiteral(\"searched\"));\r\n    QCOMPARE(segmentOffsetItem->childCount(), 0);\r\n\r\n    QTreeWidgetItem* segmentRangeItem = singleSegmentItem->child(1);\r\n    QCOMPARE(segmentRangeItem->text(ParameterReferenceTree::ITEM_NAME), QStringLiteral(\"Range\"));\r\n    QCOMPARE(segmentRangeItem->text(ParameterReferenceTree::ITEM_EXPRESSION), QStringLiteral(\"searched+2\"));\r\n    QCOMPARE(segmentRangeItem->childCount(), 0);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ParameterReferenceTree::testReferenceInRegisterFieldAddsTenRows()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ParameterReferenceTree::testReferenceInRegisterFieldAddsElevenRows()\r\n{\r\n    QSharedPointer<Parameter> searched(new Parameter);\r\n    searched->setName(\"searchedParameter\");\r\n    searched->setValueId(\"searched\");\r\n\r\n    QList <QSharedPointer<Parameter> > componentParameters;\r\n    componentParameters.append(searched);\r\n\r\n    QSharedPointer<WriteValueConstraint> refWriteConstraint (new WriteValueConstraint());\r\n    refWriteConstraint->setType(WriteValueConstraint::MIN_MAX);\r\n    refWriteConstraint->setMinimum(\"searched - 1\");\r\n    refWriteConstraint->setMaximum(\"searched + 1\");\r\n\r\n    QSharedPointer<Field> refField = createTestField(\"fieldRef\", \"searched\", \"nothing\", \"searched\");\r\n    refField->setWriteConstraint(refWriteConstraint);\r\n\r\n    QSharedPointer<FieldReset> testReset = createTestFieldReset(\"searched\", \"searched\");\r\n    refField->getResets()->append(testReset);\r\n\r\n    QSharedPointer <Register> refRegister = createTestRegister(\"refRegister\", \"test\", \"test\");\r\n    refRegister->getFields()->append(refField);\r\n\r\n    QSharedPointer <AddressBlock> addressBlockRef = createTestAddressBlock(\"addressBlockRef\", \"\", \"\", \"\");\r\n    addressBlockRef->getRegisterData()->append(refRegister);\r\n\r\n    QSharedPointer<MemoryRemap> memoryRemapRef = createTestMemoryRemap(\"memoryRemapRef\");\r\n    memoryRemapRef->getMemoryBlocks()->append(addressBlockRef);\r\n\r\n    QSharedPointer<MemoryMap> memoryMapRef = createTestMemoryMap(\"memoryMapRef\");\r\n    memoryMapRef->getMemoryRemaps()->append(memoryRemapRef);\r\n\r\n    QSharedPointer<Component> component(new Component(VLNV(), Document::Revision::Std14));\r\n    component->getMemoryMaps()->append(memoryMapRef);\r\n    component->getParameters()->append(componentParameters);\r\n\r\n    QSharedPointer<ExpressionFormatter> expressionFormatter = createTestExpressionFormatter(component);\r\n\r\n    QScopedPointer<ComponentParameterReferenceTree> tree(createTestTree(component));\r\n    tree->openReferenceTree(QStringLiteral(\"searched\"));\r\n\r\n    QCOMPARE(tree->topLevelItemCount(), 1);\r\n    QCOMPARE(tree->topLevelItem(0)->text(ParameterReferenceTree::ITEM_NAME), QStringLiteral(\"Memory maps\"));\r\n    QCOMPARE(tree->topLevelItem(0)->text(ParameterReferenceTree::ITEM_EXPRESSION), QString());\r\n\r\n    QCOMPARE(tree->topLevelItem(0)->childCount(), 1);\r\n    QCOMPARE(tree->topLevelItem(0)->child(0)->text(ParameterReferenceTree::ITEM_NAME), memoryMapRef->name());\r\n    QCOMPARE(tree->topLevelItem(0)->child(0)->text(ParameterReferenceTree::ITEM_EXPRESSION), QString());\r\n\r\n    QCOMPARE(tree->topLevelItem(0)->child(0)->childCount(), 1);\r\n    QCOMPARE(tree->topLevelItem(0)->child(0)->child(0)->text(ParameterReferenceTree::ITEM_NAME),\r\n        QStringLiteral(\"Memory remaps\"));\r\n    QCOMPARE(tree->topLevelItem(0)->child(0)->child(0)->text(ParameterReferenceTree::ITEM_EXPRESSION), QString());\r\n\r\n    QCOMPARE(tree->topLevelItem(0)->child(0)->child(0)->childCount(), 1);\r\n    QCOMPARE(tree->topLevelItem(0)->child(0)->child(0)->child(0)->text(ParameterReferenceTree::ITEM_NAME),\r\n        QStringLiteral(\"memoryRemapRef\"));\r\n    QCOMPARE(tree->topLevelItem(0)->child(0)->child(0)->child(0)->text(ParameterReferenceTree::ITEM_EXPRESSION),\r\n        QString());\r\n\r\n    QCOMPARE(tree->topLevelItem(0)->child(0)->child(0)->child(0)->childCount(), 1);\r\n    QCOMPARE(tree->topLevelItem(0)->child(0)->child(0)->child(0)->child(0)->text(ParameterReferenceTree::ITEM_NAME),\r\n        QStringLiteral(\"Address blocks\"));\r\n    QCOMPARE(tree->topLevelItem(0)->child(0)->child(0)->child(0)->child(0)->text(\r\n        ParameterReferenceTree::ITEM_EXPRESSION), QString());\r\n    \r\n    QCOMPARE(tree->topLevelItem(0)->child(0)->child(0)->child(0)->child(0)->childCount(), 1);\r\n    QCOMPARE(tree->topLevelItem(0)->child(0)->child(0)->child(0)->child(0)->child(0)->text(\r\n        ParameterReferenceTree::ITEM_NAME), addressBlockRef->name());\r\n    QCOMPARE(tree->topLevelItem(0)->child(0)->child(0)->child(0)->child(0)->child(0)->text(\r\n        ParameterReferenceTree::ITEM_EXPRESSION), QString());\r\n    QCOMPARE(tree->topLevelItem(0)->child(0)->child(0)->child(0)->child(0)->child(0)->childCount(), 1);\r\n\r\n    QTreeWidgetItem* registerListItem =\r\n        tree->topLevelItem(0)->child(0)->child(0)->child(0)->child(0)->child(0)->child(0);\r\n    QCOMPARE(registerListItem->text(ParameterReferenceTree::ITEM_NAME), QStringLiteral(\"Registers\"));\r\n    QCOMPARE(registerListItem->text(ParameterReferenceTree::ITEM_EXPRESSION), QString());\r\n    QCOMPARE(registerListItem->childCount(), 1);\r\n\r\n    QTreeWidgetItem* registerItem = registerListItem->child(0);\r\n    QCOMPARE(registerItem->text(ParameterReferenceTree::ITEM_NAME), refRegister->name());\r\n    QCOMPARE(registerItem->text(ParameterReferenceTree::ITEM_EXPRESSION), QString());\r\n    QCOMPARE(registerItem->childCount(), 1);\r\n\r\n    QTreeWidgetItem* fieldListItem = registerItem->child(0);\r\n    QCOMPARE(fieldListItem->text(ParameterReferenceTree::ITEM_NAME), QStringLiteral(\"Fields\"));\r\n    QCOMPARE(fieldListItem->text(ParameterReferenceTree::ITEM_EXPRESSION), QString());\r\n    QCOMPARE(fieldListItem->childCount(), 1);\r\n\r\n    QTreeWidgetItem* fieldItem = fieldListItem->child(0);\r\n    QCOMPARE(fieldItem->text(ParameterReferenceTree::ITEM_NAME), refField->name());\r\n    QCOMPARE(fieldItem->text(ParameterReferenceTree::ITEM_EXPRESSION), QString());\r\n    QCOMPARE(fieldItem->childCount(), 5);\r\n\r\n    QTreeWidgetItem* offsetItem = fieldItem->child(0);\r\n    QCOMPARE(offsetItem->text(ParameterReferenceTree::ITEM_NAME), QStringLiteral(\"Offset\"));\r\n    QCOMPARE(offsetItem->text(ParameterReferenceTree::ITEM_EXPRESSION),\r\n        expressionFormatter->formatReferringExpression(refField->getBitOffset()));\r\n    QCOMPARE(offsetItem->childCount(), 0);\r\n\r\n    QTreeWidgetItem* isPresentItem = fieldItem->child(1);\r\n    QCOMPARE(isPresentItem->text(ParameterReferenceTree::ITEM_NAME), QStringLiteral(\"Is Present\"));\r\n    QCOMPARE(isPresentItem->text(ParameterReferenceTree::ITEM_EXPRESSION),\r\n        expressionFormatter->formatReferringExpression(refField->getIsPresent()));\r\n    QCOMPARE(isPresentItem->childCount(), 0);\r\n\r\n    QTreeWidgetItem* resetsItem = fieldItem->child(2);\r\n    QCOMPARE(resetsItem->text(ParameterReferenceTree::ITEM_NAME), QStringLiteral(\"Resets\"));\r\n    QCOMPARE(resetsItem->childCount(), 1);\r\n\r\n    QTreeWidgetItem* hardResetItem = resetsItem->child(0);\r\n    QCOMPARE(hardResetItem->text(ParameterReferenceTree::ITEM_NAME), QLatin1String(\"HARD\"));\r\n    QCOMPARE(hardResetItem->childCount(), 2);\r\n\r\n    QTreeWidgetItem* hardResetValue = hardResetItem->child(0);\r\n    QCOMPARE(hardResetValue->text(ParameterReferenceTree::ITEM_NAME), QLatin1String(\"Reset value\"));\r\n    QCOMPARE(hardResetValue->text(ParameterReferenceTree::ITEM_EXPRESSION),\r\n        expressionFormatter->formatReferringExpression(testReset->getResetValue()));\r\n    QCOMPARE(hardResetValue->childCount(), 0);\r\n\r\n    QTreeWidgetItem* hardResetMask = hardResetItem->child(1);\r\n    QCOMPARE(hardResetMask->text(ParameterReferenceTree::ITEM_NAME), QLatin1String(\"Reset mask\"));\r\n    QCOMPARE(hardResetMask->text(ParameterReferenceTree::ITEM_EXPRESSION),\r\n        expressionFormatter->formatReferringExpression(testReset->getResetMask()));\r\n    QCOMPARE(hardResetMask->childCount(), 0);\r\n\r\n    QTreeWidgetItem* constraintMinItem = fieldItem->child(3);\r\n    QCOMPARE(constraintMinItem->text(ParameterReferenceTree::ITEM_NAME),\r\n        QStringLiteral(\"Write constraint minimum\"));\r\n    QCOMPARE(constraintMinItem->text(ParameterReferenceTree::ITEM_EXPRESSION),\r\n        expressionFormatter->formatReferringExpression(refField->getWriteConstraint()->getMinimum()));\r\n    QCOMPARE(constraintMinItem->childCount(), 0);\r\n\r\n    QTreeWidgetItem* constraintMaxItem = fieldItem->child(4);\r\n    QCOMPARE(constraintMaxItem->text(ParameterReferenceTree::ITEM_NAME),\r\n        QStringLiteral(\"Write constraint maximum\"));\r\n    QCOMPARE(constraintMaxItem->text(ParameterReferenceTree::ITEM_EXPRESSION),\r\n        expressionFormatter->formatReferringExpression(refField->getWriteConstraint()->getMaximum()));\r\n    QCOMPARE(constraintMaxItem->childCount(), 0);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ParameterReferenceTree::testReferenceInBusInterfaceParameterAddsFourRows()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ParameterReferenceTree::testReferenceInBusInterfaceParameterAddsFourRows()\r\n{\r\n    QSharedPointer<Parameter> searched = createTestParameter(\"searchedParameter\", \"\", \"\", \"\", \"\", \"\");\r\n    searched->setValueId(\"searched\");\r\n\r\n    QList <QSharedPointer<Parameter> > componentParameters;\r\n    componentParameters.append(searched);\r\n\r\n    QSharedPointer<Parameter> busIFParameter = createTestParameter(\"busIFParameterRef\", \"\", \"\", \"\", \"searched\", \"\");\r\n\r\n    QSharedPointer<BusInterface> refBusInterface(new BusInterface);\r\n    refBusInterface->setName(\"refBusInterface\");\r\n    refBusInterface->getParameters()->append(busIFParameter);\r\n\r\n    QSharedPointer<Component> component(new Component(VLNV(), Document::Revision::Std14));\r\n    component->getParameters()->append(componentParameters);\r\n    component->getBusInterfaces()->append(refBusInterface);\r\n\r\n    QSharedPointer<ExpressionFormatter> expressionFormatter = createTestExpressionFormatter(component);\r\n\r\n    QScopedPointer<ComponentParameterReferenceTree> tree(createTestTree(component));\r\n    tree->openReferenceTree(QStringLiteral(\"searched\"));\r\n\r\n    QCOMPARE(tree->topLevelItemCount(), 1);\r\n    QCOMPARE(tree->topLevelItem(0)->text(ParameterReferenceTree::ITEM_NAME), QStringLiteral(\"Bus Interfaces\"));\r\n    QCOMPARE(tree->topLevelItem(0)->text(ParameterReferenceTree::ITEM_EXPRESSION), QString());\r\n\r\n    QTreeWidgetItem* busInterfaceItem = tree->topLevelItem(0)->child(0);\r\n    QCOMPARE(tree->topLevelItem(0)->childCount(), 1);\r\n    QCOMPARE(busInterfaceItem->text(ParameterReferenceTree::ITEM_NAME), refBusInterface->name());\r\n    QCOMPARE(busInterfaceItem->text(ParameterReferenceTree::ITEM_EXPRESSION), QString());\r\n\r\n    QTreeWidgetItem* parametersItem = busInterfaceItem->child(0);\r\n    QCOMPARE(busInterfaceItem->childCount(), 1);\r\n    QCOMPARE(parametersItem->text(ParameterReferenceTree::ITEM_NAME), QStringLiteral(\"Parameters\"));\r\n    QCOMPARE(parametersItem->text(ParameterReferenceTree::ITEM_EXPRESSION), QString());\r\n\r\n    QTreeWidgetItem* busInterfaceParameterItem = parametersItem->child(0);\r\n    QCOMPARE(busInterfaceParameterItem->text(ParameterReferenceTree::ITEM_NAME), busIFParameter->name());\r\n    QCOMPARE(busInterfaceParameterItem->text(ParameterReferenceTree::ITEM_EXPRESSION), QString());\r\n\r\n    QTreeWidgetItem* arrayItem = busInterfaceParameterItem->child(0);\r\n    QCOMPARE(busInterfaceParameterItem->childCount(), 1);\r\n    QCOMPARE(arrayItem->text(ParameterReferenceTree::ITEM_NAME), QStringLiteral(\"Array Left\"));\r\n    QCOMPARE(arrayItem->text(ParameterReferenceTree::ITEM_EXPRESSION),\r\n        expressionFormatter->formatReferringExpression(busIFParameter->getAttribute(\"kactus2:arrayLeft\")));\r\n\r\n    QCOMPARE(arrayItem->childCount(), 0);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ParameterReferenceTree::testReferenceInBusInterfaceMasterAddsFourRows()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ParameterReferenceTree::testReferenceInBusInterfaceMasterAddsFourRows()\r\n{\r\n    QSharedPointer<Parameter> searched = createTestParameter(\"searchedParameter\", \"4\", \"\", \"\", \"\", \"\");\r\n    searched->setValueId(\"searched\");\r\n    QList<QSharedPointer<Parameter> > componentParameters;\r\n    componentParameters.append(searched);\r\n\r\n    QSharedPointer<InitiatorInterface> masterInterface (new InitiatorInterface);\r\n    masterInterface->setBaseAddress(searched->getValueId());\r\n\r\n    QSharedPointer<BusInterface> masterBus(new BusInterface);\r\n    masterBus->setName(\"masterBus\");\r\n    masterBus->setMaster(masterInterface);\r\n    masterBus->setInterfaceMode(General::MASTER);\r\n\r\n    QSharedPointer<BusInterface> mirroredMaster(new BusInterface);\r\n    mirroredMaster->setName(\"mirroredMaster\");\r\n    mirroredMaster->setMaster(masterInterface);\r\n    mirroredMaster->setInterfaceMode(General::MIRRORED_MASTER);\r\n\r\n    QSharedPointer<Component> component(new Component(VLNV(), Document::Revision::Std14));\r\n    component->getParameters()->append(componentParameters);\r\n    component->getBusInterfaces()->append(masterBus);\r\n    component->getBusInterfaces()->append(mirroredMaster);\r\n\r\n    QSharedPointer<ExpressionFormatter> expressionFormatter = createTestExpressionFormatter(component);\r\n\r\n    QScopedPointer<ComponentParameterReferenceTree> tree(createTestTree(component));\r\n    tree->openReferenceTree(QStringLiteral(\"searched\"));\r\n\r\n    QCOMPARE(tree->topLevelItemCount(), 1);\r\n    QCOMPARE(tree->topLevelItem(0)->text(ParameterReferenceTree::ITEM_NAME), QStringLiteral(\"Bus Interfaces\"));\r\n    QCOMPARE(tree->topLevelItem(0)->text(ParameterReferenceTree::ITEM_EXPRESSION), QString());\r\n\r\n    QCOMPARE(tree->topLevelItem(0)->childCount(), 1);\r\n    QCOMPARE(tree->topLevelItem(0)->child(0)->text(ParameterReferenceTree::ITEM_NAME), masterBus->name());\r\n    QCOMPARE(tree->topLevelItem(0)->child(0)->text(ParameterReferenceTree::ITEM_EXPRESSION), QString());\r\n\r\n    QCOMPARE(tree->topLevelItem(0)->child(0)->childCount(), 1);\r\n    QCOMPARE(tree->topLevelItem(0)->child(0)->child(0)->text(ParameterReferenceTree::ITEM_NAME),\r\n        QStringLiteral(\"Master Interface\"));\r\n    QCOMPARE(tree->topLevelItem(0)->child(0)->child(0)->text(ParameterReferenceTree::ITEM_EXPRESSION), QString());\r\n\r\n    QCOMPARE(tree->topLevelItem(0)->child(0)->child(0)->childCount(), 1);\r\n    QCOMPARE(tree->topLevelItem(0)->child(0)->child(0)->child(0)->text(ParameterReferenceTree::ITEM_NAME),\r\n        QStringLiteral(\"Base Address\"));\r\n    QCOMPARE(tree->topLevelItem(0)->child(0)->child(0)->child(0)->text(ParameterReferenceTree::ITEM_EXPRESSION),\r\n        expressionFormatter->formatReferringExpression(masterInterface->getBaseAddress()));\r\n\r\n    QCOMPARE(tree->topLevelItem(0)->child(0)->child(0)->child(0)->childCount(), 0);\r\n\r\n    // No base address in mirrored master.\r\n//     QCOMPARE(tree->topLevelItem(0)->child(1)->text(ParameterReferenceTree::ITEM_NAME), mirroredMaster->name());\r\n//     QCOMPARE(tree->topLevelItem(0)->child(1)->text(ParameterReferenceTree::ITEM_EXPRESSION), QString());\r\n// \r\n//     QCOMPARE(tree->topLevelItem(0)->child(1)->childCount(), 1);\r\n//     QCOMPARE(tree->topLevelItem(0)->child(1)->child(0)->text(ParameterReferenceTree::ITEM_NAME),\r\n//         QStringLiteral(\"Mirrored Master Interface\"));\r\n//     QCOMPARE(tree->topLevelItem(0)->child(1)->child(0)->text(ParameterReferenceTree::ITEM_EXPRESSION), QString());\r\n// \r\n//     QCOMPARE(tree->topLevelItem(0)->child(1)->child(0)->childCount(), 1);\r\n//     QCOMPARE(tree->topLevelItem(0)->child(1)->child(0)->child(0)->text(ParameterReferenceTree::ITEM_NAME),\r\n//         QStringLiteral(\"Base Address\"));\r\n//     QCOMPARE(tree->topLevelItem(0)->child(1)->child(0)->child(0)->text(ParameterReferenceTree::ITEM_EXPRESSION),\r\n//         expressionFormatter->formatReferringExpression(masterInterface->getBaseAddress()));\r\n// \r\n//     QCOMPARE(tree->topLevelItem(0)->child(1)->child(0)->child(0)->childCount(), 0);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ParameterReferenceTree::testReferenceInBusInterfaceMirroredSlaveAddsFourRows()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ParameterReferenceTree::testReferenceInBusInterfaceMirroredSlaveAddsFourRows()\r\n{\r\n    QSharedPointer<Parameter> searched = createTestParameter(\"searchedParameter\", \"\", \"\", \"\", \"\", \"\");\r\n    searched->setValueId(\"searched\");\r\n\r\n    QList <QSharedPointer<Parameter> > componentParameters;\r\n    componentParameters.append(searched);\r\n    \r\n    QSharedPointer<BusInterface> refBusInterface(new BusInterface);\r\n    refBusInterface->setName(\"refBusInterface\");\r\n\r\n    refBusInterface->setInterfaceMode(General::MIRRORED_SLAVE);\r\n\r\n    QSharedPointer<MirroredTargetInterface> mirrorSlave(new MirroredTargetInterface);\r\n    mirrorSlave->setRange(searched->getValueId());\r\n    refBusInterface->setMirroredSlave(mirrorSlave);\r\n\r\n    QSharedPointer<Component> component(new Component(VLNV(), Document::Revision::Std14));\r\n    component->getParameters()->append(componentParameters);\r\n    component->getBusInterfaces()->append(refBusInterface);\r\n\r\n    QSharedPointer<ExpressionFormatter> expressionFormatter = createTestExpressionFormatter(component);\r\n\r\n    QScopedPointer<ComponentParameterReferenceTree> tree(createTestTree(component));\r\n    tree->openReferenceTree(QStringLiteral(\"searched\"));\r\n\r\n    QCOMPARE(tree->topLevelItemCount(), 1);\r\n    QCOMPARE(tree->topLevelItem(0)->text(ParameterReferenceTree::ITEM_NAME), QStringLiteral(\"Bus Interfaces\"));\r\n    QCOMPARE(tree->topLevelItem(0)->text(ParameterReferenceTree::ITEM_EXPRESSION), QString());\r\n\r\n    QCOMPARE(tree->topLevelItem(0)->childCount(), 1);\r\n    QCOMPARE(tree->topLevelItem(0)->child(0)->text(ParameterReferenceTree::ITEM_NAME), refBusInterface->name());\r\n    QCOMPARE(tree->topLevelItem(0)->child(0)->text(ParameterReferenceTree::ITEM_EXPRESSION), QString());\r\n\r\n    QCOMPARE(tree->topLevelItem(0)->child(0)->childCount(), 1);\r\n    QCOMPARE(tree->topLevelItem(0)->child(0)->child(0)->text(ParameterReferenceTree::ITEM_NAME),\r\n        QStringLiteral(\"Mirrored Slave Interface\"));\r\n    QCOMPARE(tree->topLevelItem(0)->child(0)->child(0)->text(ParameterReferenceTree::ITEM_EXPRESSION), QString());\r\n\r\n    QCOMPARE(tree->topLevelItem(0)->child(0)->child(0)->childCount(), 1);\r\n    QCOMPARE(tree->topLevelItem(0)->child(0)->child(0)->child(0)->text(ParameterReferenceTree::ITEM_NAME),\r\n        QStringLiteral(\"Range\"));\r\n    QCOMPARE(tree->topLevelItem(0)->child(0)->child(0)->child(0)->text(ParameterReferenceTree::ITEM_EXPRESSION),\r\n        expressionFormatter->formatReferringExpression(mirrorSlave->getRange()));\r\n\r\n    QCOMPARE(tree->topLevelItem(0)->child(0)->child(0)->child(0)->childCount(), 0);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ParameterReferenceTree::testReferenceInRemapStateAddsFourRows()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ParameterReferenceTree::testReferenceInRemapStateAddsFourRows()\r\n{\r\n    QSharedPointer<Parameter> searched(new Parameter);\r\n    searched->setName(\"searchedParameter\");\r\n    searched->setValueId(\"searched\");\r\n\r\n    QSharedPointer<RemapPort> refRemapPort(new RemapPort);\r\n    refRemapPort->setPortNameRef(\"remapPort\");\r\n    refRemapPort->setPortIndex(\"1\");\r\n    refRemapPort->setValue(\"searched\");\r\n\r\n    QSharedPointer<RemapPort> secondRemapPort(new RemapPort);\r\n    secondRemapPort->setPortNameRef(\"remapPort\");\r\n    secondRemapPort->setPortIndex(\"3\");\r\n    secondRemapPort->setValue(\"searched + 1\");\r\n\r\n    QSharedPointer<RemapPort> thirdRemapPort(new RemapPort);\r\n    thirdRemapPort->setPortNameRef(\"otherRemapPort\");\r\n    thirdRemapPort->setValue(\"searched * 2\");\r\n\r\n    QSharedPointer<RemapState> refRemapState(new RemapState());\r\n    refRemapState->setName(\"refRemapState\");\r\n    refRemapState->getRemapPorts()->append(refRemapPort);\r\n    refRemapState->getRemapPorts()->append(secondRemapPort);\r\n    refRemapState->getRemapPorts()->append(thirdRemapPort);\r\n\r\n    QSharedPointer<Component> component(new Component(VLNV(), Document::Revision::Std14));\r\n    component->getParameters()->append(searched);\r\n    component->getRemapStates()->append(refRemapState);\r\n\r\n    QSharedPointer<ExpressionFormatter> formatter = createTestExpressionFormatter(component);\r\n\r\n    QScopedPointer<ComponentParameterReferenceTree> tree(createTestTree(component));\r\n    tree->openReferenceTree(QStringLiteral(\"searched\"));\r\n\r\n    QCOMPARE(tree->topLevelItemCount(), 1);\r\n    QCOMPARE(tree->topLevelItem(0)->text(ParameterReferenceTree::ITEM_NAME), QStringLiteral(\"Remap States\"));\r\n    QCOMPARE(tree->topLevelItem(0)->text(ParameterReferenceTree::ITEM_EXPRESSION), QString());\r\n    QCOMPARE(tree->topLevelItem(0)->childCount(), 1);\r\n\r\n    QCOMPARE(tree->topLevelItem(0)->child(0)->text(ParameterReferenceTree::ITEM_NAME),\r\n        QStringLiteral(\"refRemapState\"));\r\n    QCOMPARE(tree->topLevelItem(0)->child(0)->text(ParameterReferenceTree::ITEM_EXPRESSION), QString());\r\n    QCOMPARE(tree->topLevelItem(0)->child(0)->childCount(), 1);\r\n\r\n    QCOMPARE(tree->topLevelItem(0)->child(0)->child(0)->text(ParameterReferenceTree::ITEM_NAME),\r\n        QStringLiteral(\"Remap Ports\"));\r\n    QCOMPARE(tree->topLevelItem(0)->child(0)->child(0)->text(ParameterReferenceTree::ITEM_EXPRESSION), QString());\r\n    QCOMPARE(tree->topLevelItem(0)->child(0)->child(0)->childCount(), 3);\r\n\r\n    QCOMPARE(tree->topLevelItem(0)->child(0)->child(0)->child(0)->text(ParameterReferenceTree::ITEM_NAME),\r\n        QStringLiteral(\"remapPort[1]\"));\r\n    QCOMPARE(tree->topLevelItem(0)->child(0)->child(0)->child(0)->text(ParameterReferenceTree::ITEM_EXPRESSION),\r\n        QStringLiteral(\"searchedParameter\"));\r\n    QCOMPARE(tree->topLevelItem(0)->child(0)->child(0)->child(0)->childCount(), 0);\r\n\r\n    QCOMPARE(tree->topLevelItem(0)->child(0)->child(0)->child(1)->text(ParameterReferenceTree::ITEM_NAME),\r\n        QStringLiteral(\"remapPort[3]\"));\r\n    QCOMPARE(tree->topLevelItem(0)->child(0)->child(0)->child(1)->text(ParameterReferenceTree::ITEM_EXPRESSION),\r\n        QStringLiteral(\"searchedParameter + 1\"));\r\n    QCOMPARE(tree->topLevelItem(0)->child(0)->child(0)->child(1)->childCount(), 0);\r\n\r\n    QCOMPARE(tree->topLevelItem(0)->child(0)->child(0)->child(2)->text(ParameterReferenceTree::ITEM_NAME),\r\n        QStringLiteral(\"otherRemapPort\"));\r\n    QCOMPARE(tree->topLevelItem(0)->child(0)->child(0)->child(2)->text(ParameterReferenceTree::ITEM_EXPRESSION),\r\n        QStringLiteral(\"searchedParameter * 2\"));\r\n    QCOMPARE(tree->topLevelItem(0)->child(0)->child(0)->child(2)->childCount(), 0);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ParameterReferenceTree::testReferencesInMultiplePlaces()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ParameterReferenceTree::testRerefencesInMultiplePlaces()\r\n{\r\n    QSharedPointer<Parameter> searched(new Parameter);\r\n    searched->setName(\"searchedParameter\");\r\n    searched->setValueId(\"searched\");\r\n\r\n    QSharedPointer<Parameter> paramRef = createTestParameter(\"ref1\", \"\", \"\", \"\", \"searched\", \"searched\");\r\n\r\n    // View: One reference: in parameter.\r\n    QSharedPointer<Parameter> viewParamRef = createTestParameter(\"viewParamRef\", \"searched\", \"\", \"\", \"\", \"\");\r\n\r\n    QSharedPointer<FileBuilder> instantiationBuilder = createTestFileBuilder(\"Lordgenome\", \"searched + Lazengann\");\r\n\r\n    QSharedPointer<ComponentInstantiation> componentInstantiation (new ComponentInstantiation(\"compInstantiation\"));\r\n    componentInstantiation->getParameters()->append(viewParamRef);\r\n    componentInstantiation->getDefaultFileBuilders()->append(instantiationBuilder);\r\n\r\n    QSharedPointer<View> viewRef (new View(\"viewRef\"));\r\n    viewRef->setComponentInstantiationRef(componentInstantiation->name());\r\n\r\n    // Port: One reference, in default value.\r\n    QSharedPointer<Port> portRef = createTestPort(\"portRef\", \"\", \"test\", \"searched\", \"\", \"\");\r\n\r\n    QSharedPointer<WriteValueConstraint> constraintRef (new WriteValueConstraint());\r\n    constraintRef->setType(WriteValueConstraint::MIN_MAX);\r\n    constraintRef->setMinimum(\"Saitama\");\r\n    constraintRef->setMaximum(\"searched + Saitama\");\r\n\r\n    QSharedPointer<Field> refField = createTestField(\"fieldRef\", \"\", \"searched\", \"\");\r\n    refField->setWriteConstraint(constraintRef);\r\n\r\n    QSharedPointer<FieldReset> testReset = createTestFieldReset(\"1\", \"searched\");\r\n    testReset->setResetTypeReference(\"SOFT\");\r\n    refField->getResets()->append(testReset);\r\n\r\n    // Register: One reference, in offset\r\n    QSharedPointer<Register> registerRef = createTestRegister(\"registerRef\", \"searched\", \"test\");\r\n    registerRef->getFields()->append(refField);\r\n\r\n    QSharedPointer<AddressBlock> addressRef = createTestAddressBlock(\"addressBlockRef\", \"'h4\", \"searched\", \"10\");\r\n    addressRef->getRegisterData()->append(registerRef);\r\n\r\n    QSharedPointer<MemoryMap> memoryMapRef = createTestMemoryMap(\"memoryMapRef\");\r\n    memoryMapRef->getMemoryBlocks()->append(addressRef);\r\n\r\n    QSharedPointer<Parameter> busIFParameter = createTestParameter(\"busIFParameterRef\", \"searched\", \"\", \"\", \"\", \"\");\r\n\r\n    QSharedPointer<MirroredTargetInterface> mirrorSlave(new MirroredTargetInterface);\r\n    mirrorSlave->setRange(searched->getValueId());\r\n\r\n    QSharedPointer<BusInterface> refBusInterface(new BusInterface);\r\n    refBusInterface->setName(\"refBusInterface\");\r\n    refBusInterface->getParameters()->append(busIFParameter);\r\n    refBusInterface->setInterfaceMode(General::MIRRORED_SLAVE);\r\n    refBusInterface->setMirroredSlave(mirrorSlave);\r\n\r\n    QSharedPointer<InitiatorInterface> masterInterface(new InitiatorInterface);\r\n    masterInterface->setBaseAddress(searched->getValueId() + \"*2\");\r\n\r\n    QSharedPointer<BusInterface> masterBus(new BusInterface);\r\n    masterBus->setInterfaceMode(General::MASTER);\r\n    masterBus->setMaster(masterInterface);\r\n\r\n    QSharedPointer <AddressBlock> spaceBlockRef = createTestAddressBlock(\"spaceBlockRef\", \"searched\", \"\", \"\");\r\n\r\n    QSharedPointer<MemoryMapBase> localMemoryMap (new MemoryMapBase(\"localMemMap\"));\r\n    localMemoryMap->getMemoryBlocks()->append(spaceBlockRef);\r\n\r\n    QSharedPointer <AddressSpace> addressSpaceRef = createTestAddressSpace(\"addressSpaceRef\");\r\n    addressSpaceRef->setLocalMemoryMap(localMemoryMap);\r\n\r\n    QSharedPointer<RemapPort> refRemapPort(new RemapPort);\r\n    refRemapPort->setPortNameRef(\"remapPort\");\r\n    refRemapPort->setPortIndex(\"2\");\r\n    refRemapPort->setValue(\"searched\");\r\n\r\n    QSharedPointer<RemapState> refRemapState(new RemapState());\r\n    refRemapState->setName(\"refRemapState\");\r\n    refRemapState->getRemapPorts()->append(refRemapPort);\r\n\r\n    QSharedPointer<BuildCommand> referencingBuildCommand = createTestBuildCommand(\"searched+Dandy\");\r\n    QSharedPointer<File> referencingFile = createTestFile(\"referencingFile\", referencingBuildCommand);\r\n\r\n    QSharedPointer<FileBuilder> refFileBuilder = createTestFileBuilder(\"systemCSource\", \"searched+1\");\r\n    QSharedPointer<FileSet> refFileSet = createTestFileSet(\"refFiles\", refFileBuilder);\r\n    refFileSet->getFiles()->append(referencingFile);\r\n\r\n    QSharedPointer<Component> component(new Component(VLNV(), Document::Revision::Std14));\r\n    component->getFileSets()->append(refFileSet);\r\n    component->getParameters()->append(searched);\r\n    component->getParameters()->append(paramRef);\r\n    component->getViews()->append(viewRef);\r\n    component->getComponentInstantiations()->append(componentInstantiation);\r\n    component->getPorts()->append(portRef);\r\n    component->getMemoryMaps()->append(memoryMapRef);\r\n    component->getBusInterfaces()->append(refBusInterface);\r\n    component->getBusInterfaces()->append(masterBus);\r\n    component->getAddressSpaces()->append(addressSpaceRef);\r\n    component->getRemapStates()->append(refRemapState);\r\n\r\n    QSharedPointer<ExpressionFormatter> expressionFormatter = createTestExpressionFormatter(component);\r\n\r\n    QScopedPointer<ComponentParameterReferenceTree> tree(createTestTree(component));\r\n    tree->openReferenceTree(QStringLiteral(\"searched\"));\r\n\r\n    QCOMPARE(tree->topLevelItemCount(), 8);\r\n\r\n    //! Test file sets.\r\n    QCOMPARE(tree->topLevelItem(0)->text(ParameterReferenceTree::ITEM_NAME), QStringLiteral(\"File sets\"));\r\n    QCOMPARE(tree->topLevelItem(0)->text(ParameterReferenceTree::ITEM_EXPRESSION), QString());\r\n\r\n    QCOMPARE(tree->topLevelItem(0)->childCount(), 1);\r\n    QCOMPARE(tree->topLevelItem(0)->child(0)->text(ParameterReferenceTree::ITEM_NAME), refFileSet->name());\r\n    QCOMPARE(tree->topLevelItem(0)->child(0)->text(ParameterReferenceTree::ITEM_EXPRESSION), QString());\r\n\r\n    QCOMPARE(tree->topLevelItem(0)->child(0)->childCount(), 2);\r\n    QCOMPARE(tree->topLevelItem(0)->child(0)->child(0)->text(ParameterReferenceTree::ITEM_NAME),\r\n        QStringLiteral(\"Default file build commands\"));\r\n    QCOMPARE(tree->topLevelItem(0)->child(0)->child(0)->text(ParameterReferenceTree::ITEM_EXPRESSION), QString());\r\n\r\n    QCOMPARE(tree->topLevelItem(0)->child(0)->child(0)->childCount(), 1);\r\n    QCOMPARE(tree->topLevelItem(0)->child(0)->child(0)->child(0)->text(ParameterReferenceTree::ITEM_NAME),\r\n        QStringLiteral(\"File type: \") + refFileBuilder->getFileType().type_);\r\n    QCOMPARE(tree->topLevelItem(0)->child(0)->child(0)->child(0)->text(ParameterReferenceTree::ITEM_EXPRESSION),\r\n        QString());\r\n\r\n    QCOMPARE(tree->topLevelItem(0)->child(0)->child(0)->child(0)->childCount(), 1);\r\n    QCOMPARE(tree->topLevelItem(0)->child(0)->child(0)->child(0)->child(0)->text(ParameterReferenceTree::ITEM_NAME),\r\n        QStringLiteral(\"Replace default flags\"));\r\n    QCOMPARE(tree->topLevelItem(0)->child(0)->child(0)->child(0)->child(0)->text(\r\n        ParameterReferenceTree::ITEM_EXPRESSION),\r\n        expressionFormatter->formatReferringExpression(refFileBuilder->getReplaceDefaultFlags()));\r\n\r\n    QCOMPARE(tree->topLevelItem(0)->child(0)->child(0)->child(0)->child(0)->childCount(), 0);\r\n\r\n    QTreeWidgetItem* filesItem = tree->topLevelItem(0)->child(0)->child(1);\r\n    QCOMPARE(filesItem->text(ParameterReferenceTree::ITEM_NAME), QStringLiteral(\"Files\"));\r\n    QCOMPARE(filesItem->text(ParameterReferenceTree::ITEM_EXPRESSION), QString());\r\n    QCOMPARE(filesItem->childCount(), 1);\r\n\r\n    QTreeWidgetItem* singleFileItem = filesItem->child(0);\r\n    QCOMPARE(singleFileItem->text(ParameterReferenceTree::ITEM_NAME), referencingFile->name());\r\n    QCOMPARE(singleFileItem->text(ParameterReferenceTree::ITEM_EXPRESSION), QString());\r\n    QCOMPARE(singleFileItem->childCount(), 1);\r\n\r\n    QTreeWidgetItem* buildCommandItem = singleFileItem->child(0);\r\n    QCOMPARE(buildCommandItem->text(ParameterReferenceTree::ITEM_NAME), QStringLiteral(\"Build command\"));\r\n    QCOMPARE(buildCommandItem->text(ParameterReferenceTree::ITEM_EXPRESSION), QString());\r\n    QCOMPARE(buildCommandItem->childCount(), 1);\r\n\r\n    QTreeWidgetItem* flagsItem = buildCommandItem->child(0);\r\n    QCOMPARE(flagsItem->text(ParameterReferenceTree::ITEM_NAME), QStringLiteral(\"Replace default flags\"));\r\n    QCOMPARE(flagsItem->text(ParameterReferenceTree::ITEM_EXPRESSION),\r\n        expressionFormatter->formatReferringExpression(referencingBuildCommand->getReplaceDefaultFlags()));\r\n    QCOMPARE(flagsItem->childCount(), 0);\r\n\r\n    //! Test parameters.\r\n    QCOMPARE(tree->topLevelItem(1)->text(ParameterReferenceTree::ITEM_NAME), QStringLiteral(\"Parameters\"));\r\n    QCOMPARE(tree->topLevelItem(1)->text(ParameterReferenceTree::ITEM_EXPRESSION), QString());\r\n\r\n    QCOMPARE(tree->topLevelItem(1)->childCount(), 1);\r\n    QCOMPARE(tree->topLevelItem(1)->child(0)->text(ParameterReferenceTree::ITEM_NAME), paramRef->name());\r\n    QCOMPARE(tree->topLevelItem(1)->child(0)->text(ParameterReferenceTree::ITEM_EXPRESSION), QString());\r\n\r\n    QCOMPARE(tree->topLevelItem(1)->child(0)->childCount(), 2);\r\n    QCOMPARE(tree->topLevelItem(1)->child(0)->child(0)->text(ParameterReferenceTree::ITEM_NAME),\r\n        QStringLiteral(\"Array Left\"));\r\n    QCOMPARE(tree->topLevelItem(1)->child(0)->child(0)->text(ParameterReferenceTree::ITEM_EXPRESSION),\r\n        expressionFormatter->formatReferringExpression(paramRef->getAttribute(\"kactus2:arrayLeft\")));\r\n    QCOMPARE(tree->topLevelItem(1)->child(0)->child(0)->childCount(), 0);\r\n\r\n    QCOMPARE(tree->topLevelItem(1)->child(0)->child(1)->text(ParameterReferenceTree::ITEM_NAME),\r\n        QStringLiteral(\"Array Right\"));\r\n    QCOMPARE(tree->topLevelItem(1)->child(0)->child(1)->text(ParameterReferenceTree::ITEM_EXPRESSION),\r\n        expressionFormatter->formatReferringExpression(paramRef->getAttribute(\"kactus2:arrayRight\")));\r\n    QCOMPARE(tree->topLevelItem(1)->child(0)->child(1)->childCount(), 0);\r\n\r\n    //! Test memory maps.\r\n    QCOMPARE(tree->topLevelItem(2)->text(ParameterReferenceTree::ITEM_NAME), QStringLiteral(\"Memory maps\"));\r\n    QCOMPARE(tree->topLevelItem(2)->text(ParameterReferenceTree::ITEM_EXPRESSION), QString());\r\n\r\n    QCOMPARE(tree->topLevelItem(2)->childCount(), 1);\r\n    QCOMPARE(tree->topLevelItem(2)->child(0)->text(ParameterReferenceTree::ITEM_NAME), memoryMapRef->name());\r\n    QCOMPARE(tree->topLevelItem(2)->child(0)->text(ParameterReferenceTree::ITEM_EXPRESSION), QString());\r\n\r\n    QCOMPARE(tree->topLevelItem(2)->child(0)->childCount(), 1);\r\n    QCOMPARE(tree->topLevelItem(2)->child(0)->child(0)->text(ParameterReferenceTree::ITEM_NAME),\r\n        QStringLiteral(\"Memory remaps\"));\r\n    QCOMPARE(tree->topLevelItem(2)->child(0)->child(0)->text(ParameterReferenceTree::ITEM_EXPRESSION), QString());\r\n\r\n    QCOMPARE(tree->topLevelItem(2)->child(0)->childCount(), 1);\r\n    QCOMPARE(tree->topLevelItem(2)->child(0)->child(0)->child(0)->text(ParameterReferenceTree::ITEM_NAME),\r\n        QStringLiteral(\"Default\"));\r\n    QCOMPARE(tree->topLevelItem(2)->child(0)->child(0)->child(0)->text(ParameterReferenceTree::ITEM_EXPRESSION),\r\n        QString());\r\n\r\n    QCOMPARE(tree->topLevelItem(2)->child(0)->child(0)->child(0)->childCount(), 1);\r\n    QCOMPARE(tree->topLevelItem(2)->child(0)->child(0)->child(0)->child(0)->text(ParameterReferenceTree::ITEM_NAME),\r\n        QStringLiteral(\"Address blocks\"));\r\n    QCOMPARE(tree->topLevelItem(2)->child(0)->child(0)->child(0)->child(0)->text(\r\n        ParameterReferenceTree::ITEM_EXPRESSION), QString());\r\n\r\n    QCOMPARE(tree->topLevelItem(2)->child(0)->child(0)->child(0)->childCount(), 1);\r\n    QCOMPARE(tree->topLevelItem(2)->child(0)->child(0)->child(0)->child(0)->child(0)->text(\r\n        ParameterReferenceTree::ITEM_NAME), addressRef->name());\r\n    QCOMPARE(tree->topLevelItem(2)->child(0)->child(0)->child(0)->child(0)->child(0)->text(\r\n        ParameterReferenceTree::ITEM_EXPRESSION), QString());\r\n\r\n    QCOMPARE(tree->topLevelItem(2)->child(0)->child(0)->child(0)->child(0)->child(0)->childCount(), 2);\r\n    QCOMPARE(tree->topLevelItem(2)->child(0)->child(0)->child(0)->child(0)->child(0)->child(0)->text(\r\n        ParameterReferenceTree::ITEM_NAME), QStringLiteral(\"Range\"));\r\n    QCOMPARE(tree->topLevelItem(2)->child(0)->child(0)->child(0)->child(0)->child(0)->child(0)->text(\r\n        ParameterReferenceTree::ITEM_EXPRESSION), expressionFormatter->formatReferringExpression(\r\n        addressRef->getRange()));\r\n    QCOMPARE(tree->topLevelItem(2)->child(0)->child(0)->child(0)->child(0)->child(0)->child(0)->childCount(), 0);\r\n\r\n    QTreeWidgetItem* registerListItem =\r\n        tree->topLevelItem(2)->child(0)->child(0)->child(0)->child(0)->child(0)->child(1);\r\n    QCOMPARE(registerListItem->text(ParameterReferenceTree::ITEM_NAME), QStringLiteral(\"Registers\"));\r\n    QCOMPARE(registerListItem->text(ParameterReferenceTree::ITEM_EXPRESSION), QString());\r\n    QCOMPARE(registerListItem->childCount(), 1);\r\n\r\n    QTreeWidgetItem* registerItem = registerListItem->child(0);\r\n    QCOMPARE(registerItem->text(ParameterReferenceTree::ITEM_NAME), registerRef->name());\r\n    QCOMPARE(registerItem->text(ParameterReferenceTree::ITEM_EXPRESSION), QString());\r\n    QCOMPARE(registerItem->childCount(), 2);\r\n\r\n    //! Test registers.\r\n    QTreeWidgetItem* offsetItem = registerItem->child(0);\r\n    QCOMPARE(offsetItem->text(ParameterReferenceTree::ITEM_NAME), QStringLiteral(\"Offset\"));\r\n    QCOMPARE(offsetItem->text(ParameterReferenceTree::ITEM_EXPRESSION),\r\n        expressionFormatter->formatReferringExpression(registerRef->getAddressOffset()));\r\n    QCOMPARE(offsetItem->childCount(), 0);\r\n\r\n    //! Test register fields.\r\n    QTreeWidgetItem* fieldListItem = registerItem->child(1);\r\n    QCOMPARE(fieldListItem->text(ParameterReferenceTree::ITEM_NAME), QStringLiteral(\"Fields\"));\r\n    QCOMPARE(fieldListItem->text(ParameterReferenceTree::ITEM_EXPRESSION), QString());\r\n    QCOMPARE(fieldListItem->childCount(), 1);\r\n\r\n    QTreeWidgetItem* fieldItem = fieldListItem->child(0);\r\n    QCOMPARE(fieldItem->text(ParameterReferenceTree::ITEM_NAME), refField->name());\r\n    QCOMPARE(fieldItem->text(ParameterReferenceTree::ITEM_EXPRESSION), QString());\r\n    QCOMPARE(fieldItem->childCount(), 3);\r\n\r\n    QTreeWidgetItem* widthItem = fieldItem->child(0);\r\n    QCOMPARE(widthItem->text(ParameterReferenceTree::ITEM_NAME), QStringLiteral(\"Width\"));\r\n    QCOMPARE(widthItem->text(ParameterReferenceTree::ITEM_EXPRESSION),\r\n        expressionFormatter->formatReferringExpression(refField->getBitWidth()));\r\n    QCOMPARE(widthItem->childCount(), 0);\r\n\r\n    QTreeWidgetItem* resetsItem = fieldItem->child(1);\r\n    QCOMPARE(resetsItem->text(ParameterReferenceTree::ITEM_NAME), QStringLiteral(\"Resets\"));\r\n    QCOMPARE(resetsItem->text(ParameterReferenceTree::ITEM_EXPRESSION), QString());\r\n    QCOMPARE(resetsItem->childCount(), 1);\r\n\r\n    QTreeWidgetItem* softResetItem = resetsItem->child(0);\r\n    QCOMPARE(softResetItem->text(ParameterReferenceTree::ITEM_NAME), QStringLiteral(\"SOFT\"));\r\n    QCOMPARE(softResetItem->text(ParameterReferenceTree::ITEM_EXPRESSION), QString());\r\n    QCOMPARE(softResetItem->childCount(), 1);\r\n    \r\n    QTreeWidgetItem* softResetMaskItem = softResetItem->child(0);\r\n    QCOMPARE(softResetMaskItem->text(ParameterReferenceTree::ITEM_NAME), QStringLiteral(\"Reset mask\"));\r\n    QCOMPARE(softResetMaskItem->text(ParameterReferenceTree::ITEM_EXPRESSION),\r\n        expressionFormatter->formatReferringExpression(testReset->getResetMask()));\r\n    QCOMPARE(softResetMaskItem->childCount(), 0);\r\n\r\n    QTreeWidgetItem* maxConstraintItem = fieldItem->child(2);\r\n    QCOMPARE(maxConstraintItem->text(ParameterReferenceTree::ITEM_NAME),\r\n        QStringLiteral(\"Write constraint maximum\"));\r\n    QCOMPARE(maxConstraintItem->text(ParameterReferenceTree::ITEM_EXPRESSION),\r\n        expressionFormatter->formatReferringExpression(refField->getWriteConstraint()->getMaximum()));\r\n    QCOMPARE(maxConstraintItem->childCount(), 0);\r\n\r\n    //! Test address Spaces.\r\n    QCOMPARE(tree->topLevelItem(3)->text(ParameterReferenceTree::ITEM_NAME), QStringLiteral(\"Address Spaces\"));\r\n    QCOMPARE(tree->topLevelItem(3)->text(ParameterReferenceTree::ITEM_EXPRESSION), QString());\r\n\r\n    QCOMPARE(tree->topLevelItem(3)->childCount(), 1);\r\n    QCOMPARE(tree->topLevelItem(3)->child(0)->text(ParameterReferenceTree::ITEM_NAME), addressSpaceRef->name());\r\n    QCOMPARE(tree->topLevelItem(3)->child(0)->text(ParameterReferenceTree::ITEM_EXPRESSION), QString());\r\n\r\n    QCOMPARE(tree->topLevelItem(3)->childCount(), 1);\r\n    QCOMPARE(tree->topLevelItem(3)->child(0)->child(0)->text(ParameterReferenceTree::ITEM_NAME),\r\n        localMemoryMap->name());\r\n    QCOMPARE(tree->topLevelItem(3)->child(0)->child(0)->text(ParameterReferenceTree::ITEM_EXPRESSION), QString());\r\n\r\n    QCOMPARE(tree->topLevelItem(3)->child(0)->child(0)->childCount(), 1);\r\n    QCOMPARE(tree->topLevelItem(3)->child(0)->child(0)->child(0)->text(ParameterReferenceTree::ITEM_NAME),\r\n        QStringLiteral(\"Address blocks\"));\r\n    QCOMPARE(tree->topLevelItem(3)->child(0)->child(0)->child(0)->text(ParameterReferenceTree::ITEM_EXPRESSION),\r\n        QString());\r\n\r\n    QCOMPARE(tree->topLevelItem(3)->child(0)->child(0)->child(0)->childCount(), 1);\r\n    QCOMPARE(tree->topLevelItem(3)->child(0)->child(0)->child(0)->child(0)->text(ParameterReferenceTree::ITEM_NAME),\r\n        spaceBlockRef->name());\r\n    QCOMPARE(tree->topLevelItem(3)->child(0)->child(0)->child(0)->child(0)->text(\r\n        ParameterReferenceTree::ITEM_EXPRESSION), QString());\r\n\r\n    QCOMPARE(tree->topLevelItem(3)->child(0)->child(0)->child(0)->child(0)->childCount(), 1);\r\n    QCOMPARE(tree->topLevelItem(3)->child(0)->child(0)->child(0)->child(0)->child(0)->text(\r\n        ParameterReferenceTree::ITEM_NAME), QStringLiteral(\"Base Address\"));\r\n    QCOMPARE(tree->topLevelItem(3)->child(0)->child(0)->child(0)->child(0)->child(0)->text(\r\n        ParameterReferenceTree::ITEM_EXPRESSION), expressionFormatter->formatReferringExpression(\r\n        spaceBlockRef->getBaseAddress()));\r\n    QCOMPARE(tree->topLevelItem(3)->child(0)->child(0)->child(0)->child(0)->child(0)->childCount(), 0);\r\n\r\n    //! Test views.\r\n    QTreeWidgetItem* instantiationsItem = tree->topLevelItem(4);\r\n    QCOMPARE(instantiationsItem->text(ParameterReferenceTree::ITEM_NAME), QStringLiteral(\"Instantiations\"));\r\n    QCOMPARE(instantiationsItem->text(ParameterReferenceTree::ITEM_EXPRESSION), QString());\r\n\r\n    QCOMPARE(instantiationsItem->childCount(), 1);\r\n    QTreeWidgetItem* componentInstantiationsItem = instantiationsItem->child(0);\r\n    QCOMPARE(componentInstantiationsItem->text(ParameterReferenceTree::ITEM_NAME),\r\n        QStringLiteral(\"Component instantiations\"));\r\n    QCOMPARE(componentInstantiationsItem->text(ParameterReferenceTree::ITEM_EXPRESSION), QString());\r\n\r\n    QCOMPARE(componentInstantiationsItem->childCount(), 1);\r\n    QTreeWidgetItem* singleComponentInstantiationItem = componentInstantiationsItem->child(0);\r\n    QCOMPARE(singleComponentInstantiationItem->text(ParameterReferenceTree::ITEM_NAME),\r\n        componentInstantiation->name());\r\n    QCOMPARE(singleComponentInstantiationItem->text(ParameterReferenceTree::ITEM_EXPRESSION), QString());\r\n\r\n    QCOMPARE(singleComponentInstantiationItem->childCount(), 2);\r\n    QTreeWidgetItem* parametersItem = singleComponentInstantiationItem->child(0);\r\n    QCOMPARE(parametersItem->text(ParameterReferenceTree::ITEM_NAME), QStringLiteral(\"Parameters\"));\r\n    QCOMPARE(parametersItem->text(ParameterReferenceTree::ITEM_EXPRESSION), QString());\r\n\r\n    QCOMPARE(parametersItem->childCount(), 1);\r\n    QTreeWidgetItem* viewParameterItem = parametersItem->child(0);\r\n    QCOMPARE(viewParameterItem->text(ParameterReferenceTree::ITEM_NAME), viewParamRef->name());\r\n    QCOMPARE(viewParameterItem->text(ParameterReferenceTree::ITEM_EXPRESSION), QString());\r\n\r\n    QCOMPARE(viewParameterItem->childCount(), 1);\r\n    QTreeWidgetItem* valueItem = viewParameterItem->child(0);\r\n    QCOMPARE(valueItem->text(ParameterReferenceTree::ITEM_NAME),\r\n        QStringLiteral(\"Value\"));\r\n    QCOMPARE(valueItem->text(ParameterReferenceTree::ITEM_EXPRESSION),\r\n        expressionFormatter->formatReferringExpression(viewParamRef->getValue()));\r\n    QCOMPARE(valueItem->childCount(), 0);\r\n\r\n    QTreeWidgetItem* defaultFileBuildersItem = singleComponentInstantiationItem->child(1);\r\n    QCOMPARE(defaultFileBuildersItem->text(ParameterReferenceTree::ITEM_NAME),\r\n        QStringLiteral(\"Default file build commands\"));\r\n    QCOMPARE(defaultFileBuildersItem->text(ParameterReferenceTree::ITEM_EXPRESSION), QString());\r\n\r\n    QCOMPARE(defaultFileBuildersItem->childCount(), 1);\r\n    QTreeWidgetItem* fileBuilderItem = defaultFileBuildersItem->child(0);\r\n    QCOMPARE(fileBuilderItem->text(ParameterReferenceTree::ITEM_NAME),\r\n        QStringLiteral(\"File type: \") + instantiationBuilder->getFileType().type_);\r\n    QCOMPARE(fileBuilderItem->text(ParameterReferenceTree::ITEM_EXPRESSION), QString());\r\n\r\n    QCOMPARE(fileBuilderItem->childCount(), 1);\r\n    QTreeWidgetItem* replaceFlagsItem = fileBuilderItem->child(0);\r\n    QCOMPARE(replaceFlagsItem->text(ParameterReferenceTree::ITEM_NAME), QStringLiteral(\"Replace default flags\"));\r\n    QCOMPARE(replaceFlagsItem->text(ParameterReferenceTree::ITEM_EXPRESSION),\r\n        expressionFormatter->formatReferringExpression(instantiationBuilder->getReplaceDefaultFlags()));\r\n\r\n    QCOMPARE(replaceFlagsItem->childCount(), 0);\r\n\r\n    //! Test ports.\r\n    QCOMPARE(tree->topLevelItem(5)->text(ParameterReferenceTree::ITEM_NAME), QStringLiteral(\"Ports\"));\r\n    QCOMPARE(tree->topLevelItem(5)->text(ParameterReferenceTree::ITEM_EXPRESSION), QString());\r\n\r\n    QCOMPARE(tree->topLevelItem(5)->childCount(), 1);\r\n    QCOMPARE(tree->topLevelItem(5)->child(0)->text(ParameterReferenceTree::ITEM_NAME), portRef->name());\r\n    QCOMPARE(tree->topLevelItem(5)->child(0)->text(ParameterReferenceTree::ITEM_EXPRESSION), QString());\r\n\r\n    QCOMPARE(tree->topLevelItem(5)->child(0)->childCount(), 1);\r\n    QCOMPARE(tree->topLevelItem(5)->child(0)->child(0)->text(ParameterReferenceTree::ITEM_NAME),\r\n        QStringLiteral(\"Default Value\"));\r\n    QCOMPARE(tree->topLevelItem(5)->child(0)->child(0)->text(ParameterReferenceTree::ITEM_EXPRESSION),\r\n        expressionFormatter->formatReferringExpression(portRef->getDefaultValue()));\r\n    QCOMPARE(tree->topLevelItem(5)->child(0)->child(0)->childCount(), 0);\r\n\r\n    //! Test bus interfaces.\r\n    QCOMPARE(tree->topLevelItem(6)->text(ParameterReferenceTree::ITEM_NAME), QStringLiteral(\"Bus Interfaces\"));\r\n    QCOMPARE(tree->topLevelItem(6)->text(ParameterReferenceTree::ITEM_EXPRESSION), QString());\r\n\r\n    QCOMPARE(tree->topLevelItem(6)->childCount(), 2);\r\n    QTreeWidgetItem* busInterfaceItem = tree->topLevelItem(6)->child(0);\r\n    QCOMPARE(busInterfaceItem->text(ParameterReferenceTree::ITEM_NAME), refBusInterface->name());\r\n    QCOMPARE(busInterfaceItem->text(ParameterReferenceTree::ITEM_EXPRESSION), QString());\r\n\r\n    QCOMPARE(busInterfaceItem->childCount(), 2);\r\n\r\n    //! Test mirrored slave.\r\n    QCOMPARE(busInterfaceItem->child(0)->text(ParameterReferenceTree::ITEM_NAME),\r\n        QStringLiteral(\"Mirrored Slave Interface\"));\r\n    QCOMPARE(busInterfaceItem->child(0)->text(ParameterReferenceTree::ITEM_EXPRESSION), QString());\r\n\r\n    QCOMPARE(tree->topLevelItem(6)->child(0)->child(0)->childCount(), 1);\r\n    QCOMPARE(tree->topLevelItem(6)->child(0)->child(0)->child(0)->text(ParameterReferenceTree::ITEM_NAME),\r\n        QStringLiteral(\"Range\"));\r\n    QCOMPARE(tree->topLevelItem(6)->child(0)->child(0)->child(0)->text(ParameterReferenceTree::ITEM_EXPRESSION),\r\n        expressionFormatter->formatReferringExpression(mirrorSlave->getRange()));\r\n    QCOMPARE(tree->topLevelItem(6)->child(0)->child(0)->child(0)->childCount(), 0);\r\n\r\n    //! Test bus interface parameters.\r\n    QTreeWidgetItem* busInterfaceParametersItem = busInterfaceItem->child(1);\r\n    QCOMPARE(busInterfaceParametersItem->text(ParameterReferenceTree::ITEM_NAME),\r\n        QStringLiteral(\"Parameters\"));\r\n    QCOMPARE(busInterfaceParametersItem->text(ParameterReferenceTree::ITEM_EXPRESSION), QString());\r\n\r\n    QTreeWidgetItem* parameterItem = busInterfaceParametersItem->child(0);\r\n    QCOMPARE(parameterItem->text(ParameterReferenceTree::ITEM_NAME),\r\n        busIFParameter->name());\r\n    QCOMPARE(parameterItem->text(ParameterReferenceTree::ITEM_EXPRESSION), QString());\r\n    \r\n    QCOMPARE(parameterItem->childCount(), 1);\r\n    QCOMPARE(parameterItem->child(0)->text(ParameterReferenceTree::ITEM_NAME),\r\n        QStringLiteral(\"Value\"));\r\n    QCOMPARE(parameterItem->child(0)->text(ParameterReferenceTree::ITEM_EXPRESSION),\r\n        expressionFormatter->formatReferringExpression(busIFParameter->getValue()));\r\n\r\n    QCOMPARE(parameterItem->child(0)->childCount(), 0);\r\n\r\n    //! Test master interface.\r\n    QCOMPARE(tree->topLevelItem(6)->child(1)->text(ParameterReferenceTree::ITEM_NAME), masterBus->name());\r\n    QCOMPARE(tree->topLevelItem(6)->child(1)->text(ParameterReferenceTree::ITEM_EXPRESSION), QString());\r\n\r\n    QCOMPARE(tree->topLevelItem(6)->child(1)->childCount(), 1);\r\n    QCOMPARE(tree->topLevelItem(6)->child(1)->child(0)->text(ParameterReferenceTree::ITEM_NAME),\r\n        QStringLiteral(\"Master Interface\"));\r\n    QCOMPARE(tree->topLevelItem(6)->child(1)->child(0)->text(ParameterReferenceTree::ITEM_EXPRESSION), QString());\r\n\r\n    QCOMPARE(tree->topLevelItem(6)->child(1)->child(0)->childCount(), 1);\r\n    QCOMPARE(tree->topLevelItem(6)->child(1)->child(0)->child(0)->text(ParameterReferenceTree::ITEM_NAME),\r\n        QStringLiteral(\"Base Address\"));\r\n    QCOMPARE(tree->topLevelItem(6)->child(1)->child(0)->child(0)->text(ParameterReferenceTree::ITEM_EXPRESSION),\r\n        expressionFormatter->formatReferringExpression(masterInterface->getBaseAddress()));\r\n\r\n    QCOMPARE(tree->topLevelItem(6)->child(1)->child(0)->child(0)->childCount(), 0);\r\n\r\n    //! Test remap states.\r\n    QCOMPARE(tree->topLevelItem(7)->text(ParameterReferenceTree::ITEM_NAME), QStringLiteral(\"Remap States\"));\r\n    QCOMPARE(tree->topLevelItem(7)->text(ParameterReferenceTree::ITEM_EXPRESSION), QString());\r\n    QCOMPARE(tree->topLevelItem(7)->childCount(), 1);\r\n\r\n    QCOMPARE(tree->topLevelItem(7)->child(0)->text(ParameterReferenceTree::ITEM_NAME),\r\n        QStringLiteral(\"refRemapState\"));\r\n    QCOMPARE(tree->topLevelItem(7)->child(0)->text(ParameterReferenceTree::ITEM_EXPRESSION), QString());\r\n    QCOMPARE(tree->topLevelItem(7)->child(0)->childCount(), 1);\r\n\r\n    QCOMPARE(tree->topLevelItem(7)->child(0)->child(0)->text(ParameterReferenceTree::ITEM_NAME),\r\n        QStringLiteral(\"Remap Ports\"));\r\n    QCOMPARE(tree->topLevelItem(7)->child(0)->child(0)->text(ParameterReferenceTree::ITEM_EXPRESSION), QString());\r\n    QCOMPARE(tree->topLevelItem(7)->child(0)->child(0)->childCount(), 1);\r\n\r\n    QCOMPARE(tree->topLevelItem(7)->child(0)->child(0)->child(0)->text(ParameterReferenceTree::ITEM_NAME),\r\n        QStringLiteral(\"remapPort[2]\"));\r\n    QCOMPARE(tree->topLevelItem(7)->child(0)->child(0)->child(0)->text(ParameterReferenceTree::ITEM_EXPRESSION),\r\n        QStringLiteral(\"searchedParameter\"));\r\n    QCOMPARE(tree->topLevelItem(7)->child(0)->child(0)->child(0)->childCount(), 0);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ParameterReferenceTree::createTestParameter()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<Parameter> tst_ParameterReferenceTree::createTestParameter(QString const& name,\r\n    QString const& value, QString const& bitWidthLeft, QString const& bitWidthRight, QString const& arrayLeft,\r\n    QString const& arrayRight)\r\n{\r\n    QSharedPointer<Parameter> referencingParameter(new Parameter);\r\n    referencingParameter->setName(name);\r\n    referencingParameter->setValue(value);\r\n    referencingParameter->setVectorLeft(bitWidthLeft);\r\n    referencingParameter->setVectorRight(bitWidthRight);\r\n    referencingParameter->setAttribute(\"kactus2:arrayLeft\", arrayLeft);\r\n    referencingParameter->setAttribute(\"kactus2:arrayRight\", arrayRight);\r\n\r\n    return referencingParameter;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ParameterReferenceTree::createTestModuleParameter()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<ModuleParameter> tst_ParameterReferenceTree::createTestModuleParameter(QString const& name,\r\n    QString const& value, QString const& bitWidthLeft, QString const& bitWidthRight, QString const& arrayLeft,\r\n    QString const& arrayRight)\r\n{\r\n    QSharedPointer<ModuleParameter> referencingModuleParameter(new ModuleParameter());\r\n    referencingModuleParameter->setName(name);\r\n    referencingModuleParameter->setValue(value);\r\n    referencingModuleParameter->setVectorLeft(bitWidthLeft);\r\n    referencingModuleParameter->setVectorRight(bitWidthRight);\r\n    referencingModuleParameter->setAttribute(\"kactus2:arrayLeft\", arrayLeft);\r\n    referencingModuleParameter->setAttribute(\"kactus2:arrayRight\", arrayRight);\r\n\r\n    return referencingModuleParameter;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ParameterReferenceTree::createTestPort()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<Port> tst_ParameterReferenceTree::createTestPort(QString const& name, QString const& leftExpression,\r\n    QString const& rightExpression, QString const& defaultValue, QString const& arrayLeft,\r\n    QString const& arrayRight)\r\n{\r\n    QSharedPointer<Port> referencingPort(new Port);\r\n    referencingPort->setName(name);\r\n    referencingPort->setLeftBound(leftExpression);\r\n    referencingPort->setRightBound(rightExpression);\r\n    referencingPort->setDefaultValue(defaultValue);\r\n    referencingPort->setArrayLeft(arrayLeft);\r\n    referencingPort->setArrayRight(arrayRight);\r\n\r\n    return referencingPort;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ParameterReferenceTree::createTestRegister()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<Register> tst_ParameterReferenceTree::createTestRegister(QString const& name, QString const& offSet,\r\n    QString const& dimension)\r\n{\r\n    QSharedPointer<Register> registerRef(new Register);\r\n    registerRef->setName(name);\r\n    registerRef->setAddressOffset(offSet);\r\n    registerRef->setDimension(dimension);\r\n\r\n    return registerRef;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ParameterReferenceTree::createTestAddressBlock()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<AddressBlock> tst_ParameterReferenceTree::createTestAddressBlock(QString const& name,\r\n    QString const& baseAddress, QString const& range, QString const& width)\r\n{\r\n    QSharedPointer<AddressBlock> addressRef(new AddressBlock);\r\n    addressRef->setName(name);\r\n    addressRef->setBaseAddress(baseAddress);\r\n    addressRef->setRange(range);\r\n    addressRef->setWidth(width);\r\n\r\n    return addressRef;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ParameterReferenceTree::createTestMemoryMap()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<MemoryMap> tst_ParameterReferenceTree::createTestMemoryMap(QString const& name)\r\n{\r\n    QSharedPointer<MemoryMap> memoryMapRef(new MemoryMap);\r\n    memoryMapRef->setName(name);\r\n\r\n    return memoryMapRef;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ParameterReferenceTree::createTestMemoryRemap()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<MemoryRemap> tst_ParameterReferenceTree::createTestMemoryRemap(QString const& name)\r\n{\r\n    QSharedPointer<MemoryRemap> memoryRemapRef(new MemoryRemap);\r\n    memoryRemapRef->setName(name);\r\n\r\n    return memoryRemapRef;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ParameterReferenceTree::createTestField()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<Field> tst_ParameterReferenceTree::createTestField(QString const& name, QString const& offset,\r\n    QString const& width, QString const& presenceExpression)\r\n{\r\n    QSharedPointer<Field> fieldRef(new Field);\r\n    fieldRef->setName(name);\r\n    fieldRef->setBitOffset(offset);\r\n    fieldRef->setBitWidth(width);\r\n    fieldRef->setIsPresent(presenceExpression);\r\n\r\n    return fieldRef;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ParameterReferenceTree::createTestFieldReset()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<FieldReset> tst_ParameterReferenceTree::createTestFieldReset(QString const& resetValue,\r\n    QString const& resetMask)\r\n{\r\n    QSharedPointer<FieldReset> testReset(new FieldReset());\r\n    testReset->setResetValue(resetValue);\r\n    testReset->setResetMask(resetMask);\r\n\r\n    return testReset;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ParameterReferenceTree::createTestAddressSpace()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<AddressSpace> tst_ParameterReferenceTree::createTestAddressSpace(QString const& name)\r\n{\r\n    QSharedPointer<AddressSpace> addressSpaceRef(new AddressSpace);\r\n    addressSpaceRef->setName(name);\r\n\r\n    return addressSpaceRef;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ParameterReferenceTree::createTestFileBuilder()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<FileBuilder> tst_ParameterReferenceTree::createTestFileBuilder(QString const& fileType,\r\n    QString const& replaceDefaultFlags)\r\n{\r\n    QSharedPointer<FileBuilder> fileBuilderReference(new FileBuilder(fileType));\r\n    fileBuilderReference->setReplaceDefaultFlags(replaceDefaultFlags);\r\n\r\n    return fileBuilderReference;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ParameterReferenceTree::createTestFileSet()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<FileSet> tst_ParameterReferenceTree::createTestFileSet(QString const& name,\r\n    QSharedPointer<FileBuilder> builder)\r\n{\r\n    QSharedPointer<FileSet> referencingFileSet (new FileSet(name));\r\n\r\n    if (builder)\r\n    {\r\n        referencingFileSet->getDefaultFileBuilders()->append(builder);\r\n    }\r\n\r\n    return referencingFileSet;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ParameterReferenceTree::createTestBuildCommand()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<BuildCommand> tst_ParameterReferenceTree::createTestBuildCommand(QString const& replaceDefaultFlags)\r\n{\r\n    QSharedPointer<BuildCommand> newCommand (new BuildCommand());\r\n    newCommand->setReplaceDefaultFlags(replaceDefaultFlags);\r\n\r\n    return newCommand;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ParameterReferenceTree::createTestFile()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<File> tst_ParameterReferenceTree::createTestFile(QString const& name,\r\n    QSharedPointer<BuildCommand> buildCommand)\r\n{\r\n    QSharedPointer<File> newFile (new File(name));\r\n    newFile->setBuildcommand(buildCommand);\r\n\r\n    return newFile;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ParameterReferenceTree::createTestExpressionFormatter()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<ExpressionFormatter> tst_ParameterReferenceTree::createTestExpressionFormatter(\r\n    QSharedPointer<Component> component)\r\n{\r\n    QSharedPointer<ParameterFinder> parameterFinder(new ComponentParameterFinder(component));\r\n    QSharedPointer<ExpressionFormatter> expressionFormatter (new ExpressionFormatter(parameterFinder));\r\n\r\n    return expressionFormatter;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ParameterReferenceTree::createTestTree()\r\n//-----------------------------------------------------------------------------\r\nComponentParameterReferenceTree* tst_ParameterReferenceTree::createTestTree(QSharedPointer<Component> component)\r\n{\r\n    QSharedPointer<ParameterFinder> finder(new ComponentParameterFinder(component));\r\n\r\n    ComponentParameterReferenceTree* tree = new ComponentParameterReferenceTree(component, \r\n        createTestExpressionFormatter(component), \r\n        QSharedPointer<ComponentParameterReferenceCounter>(\r\n        new ComponentParameterReferenceCounter(finder, component)), 0);\r\n\r\n    return tree;\r\n}\r\n\r\nQTEST_MAIN(tst_ParameterReferenceTree)\r\n\r\n\r\n\r\n#include \"tst_ParameterReferenceTree.moc\"\r\n"
  },
  {
    "path": "tests/Core/tst_ParameterReferenceTree.pri",
    "content": "# ----------------------------------------------------\r\n# This file is generated by the Qt Visual Studio Tools.\r\n# ------------------------------------------------------\r\n\r\nHEADERS += ../../common/KactusColors.h \\\r\n    ../../editors/ComponentEditor/referenceCounter/ComponentParameterReferenceCounter.h \\\r\n    ../../editors/ComponentEditor/parameterReferenceTree/ComponentParameterReferenceTree.h \\\r\n    ../../editors/ComponentEditor/referenceCounter/ParameterReferenceCounter.h \\\r\n    ../../editors/ComponentEditor/parameterReferenceTree/ParameterReferenceTree.h \\\r\n    ../../editors/ComponentEditor/referenceCounter/ReferenceCounter.h\r\nSOURCES += ../../editors/ComponentEditor/referenceCounter/ComponentParameterReferenceCounter.cpp \\\r\n    ../../editors/ComponentEditor/parameterReferenceTree/ComponentParameterReferenceTree.cpp \\\r\n    ../../editors/ComponentEditor/referenceCounter/ParameterReferenceCounter.cpp \\\r\n    ../../editors/ComponentEditor/parameterReferenceTree/ParameterReferenceTree.cpp \\\r\n    ./tst_ParameterReferenceTree.cpp\r\n"
  },
  {
    "path": "tests/Core/tst_ParameterReferenceTree.pro",
    "content": "#-----------------------------------------------------------------------------\r\n# File: tst_ParameterReferenceTree.pro\r\n#-----------------------------------------------------------------------------\r\n# Project: Kactus 2\r\n# Author: Mikko Teuho\r\n# Date: 21.01.2015\r\n#\r\n# Description:\r\n# Qt project file template for running unit tests for a ParameterReferenceTree.\r\n#-----------------------------------------------------------------------------\r\n\r\nTEMPLATE = app\r\n\r\nTARGET = tst_ParameterReferenceTree\r\n\r\nQT += core xml gui testlib widgets\r\nCONFIG += c++11 testcase console\r\n\r\nQMAKE_EXPORTED_VARIABLES += MAKE_TESTARGS\r\nMAKE_TESTARGS.name = TESTARGS\r\nMAKE_TESTARGS.value = \"-platform offscreen\"\r\n\r\nwin32:CONFIG(release, debug|release) {\r\n    LIBS += -L$$PWD/../../executable/ -lIPXACTmodels -lKactusAPI\r\n    DESTDIR = ./release\r\n}\r\nelse:win32:CONFIG(debug, debug|release) {\r\n    LIBS += -L$$PWD/../../executable/ -lIPXACTmodelsd -lKactusAPId\r\n    DESTDIR = ./debug\r\n}\r\nelse:unix {\r\n    LIBS += -L$$PWD/../../executable/ -lIPXACTmodels -lKactusAPI\r\n    DESTDIR = ./release\r\n}\r\n\r\nINCLUDEPATH += $$PWD/../../\r\nINCLUDEPATH += $$PWD/../../executable\r\nINCLUDEPATH += $$DESTDIR\r\n\r\nDEPENDPATH += $$PWD/../../\r\nDEPENDPATH += $$PWD/../../executable\r\nDEPENDPATH += .\r\n\r\nOBJECTS_DIR += $$DESTDIR\r\n\r\nMOC_DIR += ./generatedFiles\r\nUI_DIR += ./generatedFiles\r\nRCC_DIR += ./generatedFiles\r\ninclude(tst_ParameterReferenceTree.pri)\r\n"
  },
  {
    "path": "tests/Core/tst_PortComparator.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: tst_PortComparator.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Esko Pekkarinen\r\n// Date: 24.10.2014\r\n//\r\n// Description:\r\n// Unit test for class PortComparator.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include <QtTest>\r\n\r\n#include <QSharedPointer>\r\n\r\n#include <IPXACTmodels/Component/Port.h>\r\n\r\n#include <wizards/common/PortComparator/PortComparator.h>\r\n#include <wizards/common/IPXactDiff.h>\r\n\r\n#include \"ComparatorTest.h\"\r\n\r\nQ_DECLARE_METATYPE(DirectionTypes::Direction)\r\n\r\nclass tst_PortComparator : public QObject, public ComparatorTest\r\n{\r\n    Q_OBJECT\r\n\r\npublic:\r\n    tst_PortComparator();\r\n\r\nprivate slots:\r\n    void initTestCase();\r\n    void cleanupTestCase();\r\n\r\n    void testComparingTwoNullsIsEqual();\r\n    void testComparisonToNullIsNotEqual();\r\n    void testComparingWithSelfIsEqual();\r\n\r\n    void testElementComparison();\r\n    void testElementComparison_data();\r\n\r\n    void testDirectionComparison();\r\n    void testDirectionComparison_data();\r\n\r\n    void testLeftBoundComparison();\r\n    void testLeftBoundComparison_data();\r\n\r\n    void testRightBoundComparison();\r\n    void testRightBoundComparison_data();\r\n\r\n    void testComparingTwoEmptyListsIsEqual();\r\n    void testComparingWithSameListIsEqual();\r\n\r\n    void testPortInOneListIsNotEqual();\r\n    void testSimilarPortsIsEqual();\r\n    void testDifferentPortsIsNotEqual();\r\n\r\n    void testMultiplePortsWithOneDifferenceIsNotEqual();\r\n    void testPortsInDifferentOrderIsEqual();\r\n\r\n    void testDiffElementChange();\r\n    void testDiffElementChange_data();\r\n\r\n    void testDiffPorts();\r\n   \r\n    void testDiffPortsInDifferentOrderIsNoChange();\r\n\r\n    void testDiffOfTwoEmptyListsIsNoChange();\r\n    void testDiffToSameComponentIsNoChange();\r\n\r\nprivate:\r\n    \r\n    PortComparator* makeComparator();\r\n\r\n    void addPort(QList<QSharedPointer<Port> >& list, QString const& name) const;\r\n\r\n    void setElementInPort(QString const& element, QString const& value, QSharedPointer<Port> port);\r\n\r\n    QStringList getElements() const;\r\n\r\n    PortComparator* comparator_;\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_PortComparator::tst_PortComparator()\r\n//-----------------------------------------------------------------------------\r\ntst_PortComparator::tst_PortComparator()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_PortComparator::initTestCase()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_PortComparator::initTestCase()\r\n{\r\n    comparator_ = makeComparator();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_PortComparator::cleanupTestCase()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_PortComparator::cleanupTestCase()\r\n{\r\n    delete comparator_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_PortComparator::makeComparator()\r\n//-----------------------------------------------------------------------------\r\nPortComparator* tst_PortComparator::makeComparator()\r\n{\r\n    return new PortComparator;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_PortComparator::testComparingTwoNullsIsEqual()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_PortComparator::testComparingTwoNullsIsEqual()\r\n{\r\n    QVERIFY2(comparator_->compare(QSharedPointer<Port>(0), \r\n        QSharedPointer<Port>(0)), \"Two nulls should be equal.\");\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_PortComparator::testComparisonToNullIsNotEqual()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_PortComparator::testComparisonToNullIsNotEqual()\r\n{\r\n    QSharedPointer<Port> port(new Port());\r\n\r\n    QVERIFY2(!comparator_->compare(QSharedPointer<Port>(0), port), \r\n        \"Comparison to null should not be equal.\");\r\n    QVERIFY2(!comparator_->compare(port, QSharedPointer<Port>(0)), \r\n        \"Comparison to null should not be equal.\");\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_PortComparator::testComparingWithSelfIsEqual()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_PortComparator::testComparingWithSelfIsEqual()\r\n{\r\n    QSharedPointer<Port> port(new Port());\r\n    QVERIFY2(comparator_->compare(port, port), \"Comparing with self should be equal.\");\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_PortComparator::testElementComparison()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_PortComparator::testElementComparison()\r\n{\r\n    QStringList elements;\r\n    elements << \"name\" << getElements();\r\n\r\n    QFETCH(QString, referenceValue);\r\n    QFETCH(QString, subjectValue);\r\n    QFETCH(bool, expectedComparison);\r\n\r\n    foreach(QString const& element, elements)\r\n    {\r\n        QSharedPointer<Port> reference(new Port());\r\n        setElementInPort(element, referenceValue, reference);\r\n        \r\n        QSharedPointer<Port> subject(new Port());\r\n        setElementInPort(element, subjectValue, subject);\r\n\r\n        QVERIFY2(comparator_->compare(reference, subject) == expectedComparison,\r\n            QString(\"%1 '%2' does not match '%3'\").arg(element, referenceValue, subjectValue).toLocal8Bit());\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_PortComparator::testNameComparison_data()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_PortComparator::testElementComparison_data()\r\n{\r\n    createTestInputsForStringValues();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_PortComparator::testDirectionComparison()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_PortComparator::testDirectionComparison()\r\n{\r\n    QFETCH(DirectionTypes::Direction, referenceDirection);\r\n    QFETCH(DirectionTypes::Direction, subjectDirection);\r\n    QFETCH(bool, expectedComparison);\r\n\r\n    QSharedPointer<Port> reference(new Port());\r\n    reference->setDirection(referenceDirection);\r\n\r\n    QSharedPointer<Port> subject(new Port());\r\n    subject->setDirection(subjectDirection);\r\n\r\n    QVERIFY2(comparator_->compare(reference, subject) == expectedComparison,\r\n        QString(\"Comparing direction '%1' to '%2' yields unexpected result\").arg(DirectionTypes::direction2Str(referenceDirection),\r\n        DirectionTypes::direction2Str(subjectDirection)).toLocal8Bit());\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_PortComparator::testDirectionComparison_data()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_PortComparator::testDirectionComparison_data()\r\n{\r\n    QTest::addColumn<DirectionTypes::Direction>(\"referenceDirection\");\r\n    QTest::addColumn<DirectionTypes::Direction>(\"subjectDirection\");\r\n    QTest::addColumn<bool>(\"expectedComparison\");\r\n\r\n    QTest::newRow(\"Both in\") << DirectionTypes::IN << DirectionTypes::IN << true;\r\n    QTest::newRow(\"Both out\") << DirectionTypes::OUT << DirectionTypes::OUT << true;\r\n    QTest::newRow(\"Both inout\") << DirectionTypes::INOUT << DirectionTypes::INOUT << true;\r\n    QTest::newRow(\"In and out\") << DirectionTypes::IN << DirectionTypes::OUT << false;\r\n    QTest::newRow(\"In and inout\") << DirectionTypes::IN << DirectionTypes::INOUT << false;\r\n    QTest::newRow(\"out and phantom\") << DirectionTypes::OUT << DirectionTypes::DIRECTION_PHANTOM << false;\r\n    QTest::newRow(\"out and inout\") << DirectionTypes::OUT << DirectionTypes::INOUT << false;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_PortComparator::testLeftBoundComparison()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_PortComparator::testLeftBoundComparison()\r\n{\r\n    QFETCH(QString, referenceValue);\r\n    QFETCH(QString, subjectValue);\r\n    QFETCH(bool, expectedComparison);\r\n\r\n    QSharedPointer<Port> reference(new Port());\r\n    reference->setLeftBound(referenceValue);\r\n\r\n    QSharedPointer<Port> subject(new Port());\r\n    subject->setLeftBound(subjectValue);\r\n\r\n    QVERIFY2(comparator_->compare(reference, subject) == expectedComparison,\r\n        QString(\"Comparing left bound '%1' to '%2' yields unexpected result\").arg(referenceValue,\r\n        subjectValue).toLocal8Bit());\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_PortComparator::testLeftBoundComparison()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_PortComparator::testLeftBoundComparison_data()\r\n{\r\n    QTest::addColumn<QString>(\"referenceValue\");\r\n    QTest::addColumn<QString>(\"subjectValue\");\r\n    QTest::addColumn<bool>(\"expectedComparison\");\r\n\r\n    QTest::newRow(\"Both zero\") << \"0\" << \"0\" << true;\r\n    QTest::newRow(\"Both negative\") << \"-1\" << \"-1\" << true;\r\n    QTest::newRow(\"Zero and one\") << \"0\" << \"1\" << false;\r\n    QTest::newRow(\"One and one\") << \"1\" << \"1\" << true;\r\n    QTest::newRow(\"One and negative one\") << \"1\" << \"-1\" << false;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_PortComparator::testRightBoundComparison()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_PortComparator::testRightBoundComparison()\r\n{\r\n    QFETCH(QString, referenceValue);\r\n    QFETCH(QString, subjectValue);\r\n    QFETCH(bool, expectedComparison);\r\n\r\n    QSharedPointer<Port> reference(new Port());\r\n    reference->setRightBound(referenceValue);\r\n\r\n    QSharedPointer<Port> subject(new Port());\r\n    subject->setRightBound(subjectValue);\r\n\r\n    QVERIFY2(comparator_->compare(reference, subject) == expectedComparison,\r\n        QString(\"Comparing right bound '%1' to '%2' yields unexpected result\").arg(referenceValue,\r\n        subjectValue).toLocal8Bit());\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_PortComparator::testRightBoundComparison_data()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_PortComparator::testRightBoundComparison_data()\r\n{\r\n    testLeftBoundComparison_data();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_PortComparator::testComparingTwoEmptyListsIsEqual()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_PortComparator::testComparingTwoEmptyListsIsEqual()\r\n{\r\n    QVERIFY2(comparator_->compare(QList<QSharedPointer<Port> >(), \r\n        QList<QSharedPointer<Port> >()), \"Two empty lists should be equal.\");\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_PortComparator::testComparingWithSameListIsEqual()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_PortComparator::testComparingWithSameListIsEqual()\r\n{\r\n    QList<QSharedPointer<Port> > list;\r\n\r\n    QVERIFY2(comparator_->compare(list, list), \"Comparing with self should be equal.\");\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_PortComparator::testPortInOneComponentIsNotEqual()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_PortComparator::testPortInOneListIsNotEqual()\r\n{\r\n    QList<QSharedPointer<Port> > reference;\r\n    QList<QSharedPointer<Port> > subject;\r\n    \r\n    QSharedPointer<Port> port(new Port());\r\n    reference.append(port);\r\n\r\n    QVERIFY2(!comparator_->compare(reference, subject), \r\n        \"Lists with different ports should not be equal.\");\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_PortComparator::testSimilarPortsIsEqual()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_PortComparator::testSimilarPortsIsEqual()\r\n{\r\n    QList<QSharedPointer<Port> > reference;\r\n    addPort(reference, \"clk\");\r\n\r\n    QList<QSharedPointer<Port> > subject;\r\n    addPort(subject, \"clk\");\r\n\r\n    QVERIFY2(comparator_->compare(reference, subject), \"Lists with same port should be equal.\");\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_PortComparator::testDifferentPortsIsNotEqual()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_PortComparator::testDifferentPortsIsNotEqual()\r\n{\r\n    QList<QSharedPointer<Port> > reference;\r\n    addPort(reference, \"clk\");\r\n\r\n    QList<QSharedPointer<Port> > subject;    \r\n    addPort(subject, \"bridge count\");\r\n\r\n    QVERIFY2(!comparator_->compare(reference, subject), \"Lists with different ports should not be equal.\");\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_PortComparator::testMultiplePortsWithOneDifferenceIsNotEqual()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_PortComparator::testMultiplePortsWithOneDifferenceIsNotEqual()\r\n{\r\n    QList<QSharedPointer<Port> > reference;  \r\n    addPort(reference, \"addr\");\r\n    addPort(reference, \"data\");\r\n    addPort(reference, \"clk\");\r\n\r\n    QList<QSharedPointer<Port> > subject;  \r\n    addPort(subject, \"addr\");    \r\n    addPort(subject, \"data\");\r\n    addPort(subject, \"clk_freq\");    \r\n\r\n    QVERIFY2(!comparator_->compare(reference, subject), \r\n        \"Lists with different ports should not be equal.\");\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_PortComparator::testPortsInDifferentOrderIsEqual()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_PortComparator::testPortsInDifferentOrderIsEqual()\r\n{\r\n    QList<QSharedPointer<Port> > reference;   \r\n    addPort(reference, \"addr\");\r\n    addPort(reference, \"data\");\r\n    addPort(reference, \"clk\");\r\n\r\n    QList<QSharedPointer<Port> > subject;  \r\n    addPort(subject, \"data\");\r\n    addPort(subject, \"clk\");    \r\n    addPort(subject, \"addr\");    \r\n\r\n    QVERIFY2(comparator_->compare(reference, subject), \r\n        \"Lists with same ports in different order should be equal.\");\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_PortComparator::testDiffOfTwoEmptyListsIsNoChange()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_PortComparator::testDiffOfTwoEmptyListsIsNoChange()\r\n{\r\n    QList<QSharedPointer<IPXactDiff> > diff = comparator_->diff(QList<QSharedPointer<Port> >(),\r\n        QList<QSharedPointer<Port> >());\r\n\r\n    QCOMPARE(diff.count(), 1);\r\n    verifyDiffElementAndType(diff.first(), \"port\", \"\", IPXactDiff::NO_CHANGE);   \r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_PortComparator::testDiffToSameComponentIsNoChange()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_PortComparator::testDiffToSameComponentIsNoChange()\r\n{\r\n    QList<QSharedPointer<Port> > reference;   \r\n\r\n    QList<QSharedPointer<IPXactDiff> > diff = comparator_->diff(reference, reference);\r\n\r\n    QCOMPARE(diff.count(), 1);\r\n    verifyDiffElementAndType(diff.first(), \"port\", \"\", IPXactDiff::NO_CHANGE);   \r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_PortComparator::testDiffToSameComponentIsNoChange()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_PortComparator::testDiffElementChange()\r\n{\r\n    QStringList elements = getElements();\r\n\r\n    QFETCH(QString, referenceValue);\r\n    QFETCH(QString, subjectValue);\r\n    QFETCH(bool, expectedComparison);\r\n\r\n    foreach(QString const& element, elements)\r\n    {\r\n        QSharedPointer<Port> reference(new Port());\r\n        reference->setName(\"testPort\");\r\n        setElementInPort(element, referenceValue, reference);\r\n\r\n        QSharedPointer<Port> subject(new Port());\r\n        subject->setName(\"testPort\");\r\n        setElementInPort(element, subjectValue, subject);\r\n\r\n        QList<QSharedPointer<IPXactDiff> > diff = comparator_->diff(reference, subject);\r\n\r\n        QCOMPARE(diff.count(), 1);\r\n        if (expectedComparison)\r\n        {\r\n            verifyDiffElementAndType(diff.first(), \"port\", \"\", IPXactDiff::NO_CHANGE);   \r\n        }\r\n        else\r\n        {\r\n            verifyDiffElementAndType(diff.first(), \"port\", \"testPort\", IPXactDiff::MODIFICATION);\r\n            verifyModificationIs(diff.first()->getChangeList().first(), element, referenceValue, subjectValue);\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_PortComparator::testDiffElementChange_data()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_PortComparator::testDiffElementChange_data()\r\n{\r\n    createTestInputsForStringValues();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_PortComparator::testDiffPorts()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_PortComparator::testDiffPorts()\r\n{\r\n    QList<QSharedPointer<Port> > reference;  \r\n    QSharedPointer<Port> referencePort(new Port());\r\n    referencePort->setName(\"clk\");\r\n    referencePort->setTypeName(\"std_logic\");\r\n    referencePort->setDefaultValue(\"1\");\r\n    reference.append(referencePort);\r\n\r\n    QList<QSharedPointer<Port> > subject;  \r\n    QSharedPointer<Port> subjectPort(new Port());\r\n    subjectPort->setName(\"clk\");\r\n    subjectPort->setTypeName(\"int\");\r\n    subjectPort->setDefaultValue(\"200\");\r\n    subject.append(subjectPort);\r\n\r\n    QList<QSharedPointer<IPXactDiff> > diff = comparator_->diff(reference, subject);\r\n\r\n    QCOMPARE(diff.count(), 1);\r\n    verifyDiffElementAndType(diff.first(), \"port\", \"clk\", IPXactDiff::MODIFICATION);\r\n\r\n    QList<IPXactDiff::Modification> modifications = diff.first()->getChangeList();\r\n    QCOMPARE(modifications.count(), 2);\r\n\r\n    IPXactDiff::Modification dataTypeChange = modifications.at(0);\r\n    verifyModificationIs(dataTypeChange, \"type name\", \"std_logic\", \"int\");\r\n\r\n    IPXactDiff::Modification valueTypeChange = modifications.at(1);\r\n    verifyModificationIs(valueTypeChange, \"default value\", \"1\", \"200\");\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_PortComparator::testDiffPortsInDifferentOrderIsNoChange()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_PortComparator::testDiffPortsInDifferentOrderIsNoChange()\r\n{\r\n    QList<QSharedPointer<Port> > reference;    \r\n    addPort(reference, \"clk\");\r\n    addPort(reference, \"reset_n\");\r\n    addPort(reference, \"data\");\r\n\r\n    QList<QSharedPointer<Port> > subject;  \r\n    addPort(subject, \"reset_n\");\r\n    addPort(subject, \"data\");    \r\n    addPort(subject, \"clk\");    \r\n\r\n    QList<QSharedPointer<IPXactDiff> > diff = comparator_->diff(reference, subject);\r\n\r\n    QCOMPARE(diff.count(), 1);    \r\n    verifyDiffElementAndType(diff.first(), \"port\", \"\", IPXactDiff::NO_CHANGE);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_PortComparator::addPort()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_PortComparator::addPort(QList<QSharedPointer<Port> >& list, QString const& name) const\r\n{\r\n    QSharedPointer<Port> newPort(new Port());\r\n    newPort->setName(name);\r\n\r\n    list.append(newPort);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_PortComparator::setElementInPort()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_PortComparator::setElementInPort(QString const& element, QString const& value, QSharedPointer<Port> port)\r\n{\r\n    if (element == \"name\")\r\n    {\r\n        port->setName(value);\r\n    }    \r\n    else if (element == \"port access handle\")\r\n    {\r\n        QFAIL(QString(\"No setter for element %1\").arg(element).toLocal8Bit());\r\n    }  \r\n    else if (element == \"type name\")\r\n    {\r\n        port->setTypeName(value);\r\n    }  \r\n    else if (element == \"type definitions\")\r\n    {\r\n        port->setTypeDefinition(\"testType\", value);\r\n    }      \r\n    else if (element == \"default value\")\r\n    {\r\n        port->setDefaultValue(value);\r\n    }  \r\n    else\r\n    {\r\n        QFAIL(QString(\"Attempting to set unspecified element %1\").arg(element).toLocal8Bit());\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_PortComparator::getElements()\r\n//-----------------------------------------------------------------------------\r\nQStringList tst_PortComparator::getElements() const\r\n{\r\n    QStringList elements;\r\n    elements << \"type name\" << \"type definitions\" << \"default value\";\r\n    return elements;\r\n}\r\n\r\nQTEST_APPLESS_MAIN(tst_PortComparator)\r\n\r\n#include \"tst_PortComparator.moc\"\r\n    "
  },
  {
    "path": "tests/Core/tst_PortComparator.pri",
    "content": "# ----------------------------------------------------\r\n# This file is generated by the Qt Visual Studio Add-in.\r\n# ------------------------------------------------------\r\n\r\n\r\nHEADERS += ../../wizards/common/IPXactDiff.h \\\r\n    ../../wizards/common/IPXactElementComparator.h \\\r\n    ../../wizards/common/PortComparator/PortComparator.h \\\r\n    ./ComparatorTest.h\r\n\r\nSOURCES += ../../wizards/common/IPXactDiff.cpp \\\r\n    ../../wizards/common/PortComparator/PortComparator.cpp \\\r\n    ./tst_PortComparator.cpp \\\r\n    ./ComparatorTest.cpp\r\n"
  },
  {
    "path": "tests/Core/tst_PortComparator.pro",
    "content": "#-----------------------------------------------------------------------------\r\n# File: tst_PortComparator.pro\r\n#-----------------------------------------------------------------------------\r\n# Project: Kactus 2\r\n# Author: Esko Pekkarinen\r\n# Date: 24.10.2014\r\n#\r\n# Description:\r\n# Qt project file template for running unit tests for a ComponentComparator.\r\n#-----------------------------------------------------------------------------\r\n\r\nTEMPLATE = app\r\n\r\nTARGET = tst_PortComparator\r\n\r\nQT += core xml gui testlib\r\nCONFIG += c++11 testcase console\r\n\r\nwin32:CONFIG(release, debug|release) {\r\n    LIBS += -L$$PWD/../../executable/ -lIPXACTmodels\r\n    DESTDIR = ./release\r\n}\r\nelse:win32:CONFIG(debug, debug|release) {\r\n    LIBS += -L$$PWD/../../executable/ -lIPXACTmodelsd\r\n    DESTDIR = ./debug\r\n}\r\nelse:unix {\r\n    LIBS += -L$$PWD/../../executable/ -lIPXACTmodels\r\n    DESTDIR = ./release\r\n}\r\n\r\nINCLUDEPATH += $$PWD/../../\r\nINCLUDEPATH += $$PWD/../../executable\r\nINCLUDEPATH += $$DESTDIR\r\n\r\nDEPENDPATH += $$PWD/../../\r\nDEPENDPATH += $$PWD/../../executable\r\n\r\nOBJECTS_DIR += $$DESTDIR\r\n\r\nMOC_DIR += ./generatedFiles\r\nUI_DIR += ./generatedFiles\r\nRCC_DIR += ./generatedFiles\r\ninclude(tst_PortComparator.pri)\r\n"
  },
  {
    "path": "tests/Core/tst_RegisterGraphItem.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: tst_RegisterGraphItem.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Esko Pekkarinen\r\n// Date: 14.04.2015\r\n//\r\n// Description:\r\n// Unit test for class RegisterGraphItem.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include <QtTest>\r\n\r\n#include <editors/ComponentEditor/memoryMaps/memoryMapsVisualizer/addressblockgraphitem.h>\r\n#include <editors/ComponentEditor/memoryMaps/memoryMapsVisualizer/registergraphitem.h>\r\n#include <editors/ComponentEditor/memoryMaps/memoryMapsVisualizer/fieldgraphitem.h>\r\n#include <editors/ComponentEditor/visualization/memorygapitem.h>\r\n\r\n#include <KactusAPI/include/SystemVerilogExpressionParser.h>\r\n#include <KactusAPI/include/NullParser.h>\r\n\r\n#include <IPXACTmodels/Component/AddressBlock.h>\r\n#include <IPXACTmodels/Component/Field.h>\r\n#include <IPXACTmodels/Component/Register.h>\r\n#include <IPXACTmodels/Component/RegisterBase.h>\r\n\r\nclass tst_RegisterGraphItem : public QObject\r\n{\r\n    Q_OBJECT\r\n\r\npublic:\r\n    tst_RegisterGraphItem();\r\n    \r\nprivate slots:\r\n\r\n    void testConstructor();\r\n\r\n    void testRegisterWithField();\r\n\r\n    void testRegisterWithConsecutiveFields();\r\n\r\n    void testFieldInSecondAddress();\r\n\r\n    void testEmptyAfterLastField();\r\n  \r\n    void testFieldOutsideRegisterIsNotValid();\r\n\r\n    void testFieldEndingOutsideRegisterIsNotValid();\r\n\r\n    void testEmptyBetweenTwoFields();\r\n\r\n    void testPartiallyOverlappingFields();\r\n     \r\n    void testFullyOverlappingFields();\r\n    \r\n    void testMultipleFieldsOverlapping();\r\n     \r\n    void testTwoFieldsCompletelyOverlappingThird();\r\n     \r\n    void testZeroWidthFields();\r\n\r\n    void testTwoDimensional();\r\n\r\n    void testLastDimensionExceedsAddressBlockRange();\r\n\r\n    void testExpressions();\r\n\r\n    void testNonPresentField();\r\n\r\nprivate:\r\n    void expandItem(RegisterGraphItem* registerItem);\r\n\r\n    RegisterGraphItem* createRegisterItem();\r\n\r\n    FieldGraphItem* createFieldItem(QString name, unsigned int offset, unsigned int bitWidth, RegisterGraphItem* parentRegister);\r\n\r\n    QList<MemoryGapItem*> findMemoryGaps(RegisterGraphItem* memoryMapItem);\r\n   \r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_RegisterGraphItem::tst_RegisterGraphItem()\r\n//-----------------------------------------------------------------------------\r\ntst_RegisterGraphItem::tst_RegisterGraphItem()\r\n{\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_RegisterGraphItem::testConstructor()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_RegisterGraphItem::testConstructor()\r\n{\r\n    QSharedPointer<AddressBlock> addressBlock(new AddressBlock());\r\n    addressBlock->setName(\"testBlock\");\r\n    addressBlock->setBaseAddress(0);\r\n    addressBlock->setRange(\"1\");\r\n\r\n    QSharedPointer<ExpressionParser> noParser(new NullParser());\r\n\r\n    AddressBlockGraphItem* addressBlockItem = new AddressBlockGraphItem(addressBlock, noParser, 0);\r\n\r\n    QSharedPointer<Register> testRegister(new Register());\r\n    testRegister->setName(\"testRegister\");\r\n    testRegister->setAddressOffset(0);\r\n    testRegister->setSize(\"1\");\r\n\r\n    RegisterGraphItem* registerItem = new RegisterGraphItem(testRegister, noParser, addressBlockItem);    \r\n\r\n    QCOMPARE(registerItem->name(), QString(\"testRegister\"));\r\n    QCOMPARE(registerItem->getOffset(), quint64(0));\r\n    QCOMPARE(registerItem->getLastAddress(), quint64(0));\r\n    QCOMPARE(registerItem->getDisplayOffset(), quint64(0));\r\n    QCOMPARE(registerItem->getDisplayLastAddress(), quint64(0));\r\n\r\n    QCOMPARE(registerItem->pos().y(), qreal(0));\r\n\r\n    delete registerItem;\r\n    delete addressBlockItem;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_RegisterGraphItem::testRegisterWithField()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_RegisterGraphItem::testRegisterWithField()\r\n{    \r\n    RegisterGraphItem* registerItem = createRegisterItem();\r\n    FieldGraphItem* fieldItem = createFieldItem(\"testField\", 0, 8, registerItem);\r\n    registerItem->redoChildLayout();\r\n\r\n    QCOMPARE(registerItem->getOffset(), quint64(0));\r\n    QCOMPARE(registerItem->getLastAddress(), quint64(0));\r\n    QCOMPARE(registerItem->getDisplayOffset(), quint64(0));\r\n    QCOMPARE(registerItem->getDisplayLastAddress(), quint64(0));\r\n\r\n    QVERIFY(!fieldItem->isVisible());\r\n\r\n    expandItem(registerItem);\r\n\r\n    QVERIFY(fieldItem->isVisible());\r\n    QVERIFY(!fieldItem->isConflicted());\r\n    QCOMPARE(fieldItem->name(), QString(\"testField\"));\r\n    QCOMPARE(fieldItem->pos().x(), qreal(0));\r\n    QCOMPARE(fieldItem->pos().y(), qreal(VisualizerItem::DEFAULT_HEIGHT));\r\n    QCOMPARE(fieldItem->getOffset(), quint64(0));\r\n    QCOMPARE(fieldItem->getLastAddress(), quint64(7));\r\n    QCOMPARE(fieldItem->getDisplayOffset(), quint64(7));\r\n    QCOMPARE(fieldItem->getDisplayLastAddress(), quint64(0));\r\n\r\n    delete registerItem->parent();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_RegisterGraphItem::testRegisterWithConsecutiveField()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_RegisterGraphItem::testRegisterWithConsecutiveFields()\r\n{    \r\n    RegisterGraphItem* registerItem = createRegisterItem();\r\n\r\n    FieldGraphItem* firstField = createFieldItem(\"first\", 0, 4, registerItem);\r\n    FieldGraphItem* secondField = createFieldItem(\"second\", 4, 4, registerItem);\r\n\r\n    registerItem->redoChildLayout();\r\n\r\n    expandItem(registerItem);\r\n\r\n    QVERIFY(firstField->isVisible());\r\n    QVERIFY(!firstField->isConflicted());\r\n    QCOMPARE(firstField->pos().x(), registerItem->boundingRect().width()/2);\r\n    QCOMPARE(firstField->pos().y(), qreal(VisualizerItem::DEFAULT_HEIGHT));\r\n    QCOMPARE(firstField->getOffset(), quint64(0));\r\n    QCOMPARE(firstField->getLastAddress(), quint64(3));\r\n    QCOMPARE(firstField->getDisplayOffset(), quint64(3));\r\n    QCOMPARE(firstField->getDisplayLastAddress(), quint64(0));\r\n\r\n    QVERIFY(secondField->isVisible());\r\n    QVERIFY(!secondField->isConflicted());\r\n    QCOMPARE(secondField->pos().x(), qreal(0));\r\n    QCOMPARE(secondField->pos().y(), qreal(VisualizerItem::DEFAULT_HEIGHT));\r\n    QCOMPARE(secondField->getOffset(), quint64(4));\r\n    QCOMPARE(secondField->getLastAddress(), quint64(7));\r\n    QCOMPARE(secondField->getDisplayOffset(), quint64(7));\r\n    QCOMPARE(secondField->getDisplayLastAddress(), quint64(4));\r\n\r\n    delete registerItem->parent();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_RegisterGraphItem::testFieldInSecondAddress()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_RegisterGraphItem::testFieldInSecondAddress()\r\n{\r\n    RegisterGraphItem* registerItem = createRegisterItem();\r\n\r\n    FieldGraphItem* fieldItem = createFieldItem(\"\", 0, 7, registerItem);\r\n\r\n    registerItem->redoChildLayout();\r\n\r\n    expandItem(registerItem);\r\n\r\n    QList<MemoryGapItem*> gaps = findMemoryGaps(registerItem);\r\n    QCOMPARE(gaps.count(), 1);\r\n\r\n    MemoryGapItem* emptyMSB = gaps.first();\r\n    QVERIFY(!emptyMSB->isConflicted());\r\n    QCOMPARE(emptyMSB->name(), QString(\"Reserved\"));\r\n    QCOMPARE(emptyMSB->pos().x(), qreal(0));\r\n    QCOMPARE(emptyMSB->pos().y(), qreal(VisualizerItem::DEFAULT_HEIGHT));\r\n    QCOMPARE(emptyMSB->getDisplayOffset(), quint64(7));\r\n    QCOMPARE(emptyMSB->getDisplayLastAddress(), quint64(7));\r\n    QCOMPARE(emptyMSB->boundingRect().width(), registerItem->boundingRect().width()/8);\r\n\r\n    QVERIFY(fieldItem->isVisible());\r\n    QCOMPARE(fieldItem->pos().x(), emptyMSB->boundingRect().right());\r\n    QCOMPARE(fieldItem->pos().y(), qreal(VisualizerItem::DEFAULT_HEIGHT));\r\n    QCOMPARE(fieldItem->getOffset(), quint64(0));\r\n    QCOMPARE(fieldItem->getLastAddress(), quint64(6));\r\n    QCOMPARE(fieldItem->getDisplayOffset(), quint64(6));\r\n    QCOMPARE(fieldItem->getDisplayLastAddress(), quint64(0));\r\n    QCOMPARE(fieldItem->boundingRect().width(), 7*registerItem->boundingRect().width()/8);\r\n\r\n    delete registerItem->parent();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_RegisterGraphItem::testEmptyAfterLastField()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_RegisterGraphItem::testEmptyAfterLastField()\r\n{\r\n    RegisterGraphItem* registerItem = createRegisterItem();\r\n    FieldGraphItem* fieldItem = createFieldItem(\"\", 1, 7, registerItem);\r\n\r\n    registerItem->redoChildLayout();\r\n\r\n    expandItem(registerItem);\r\n\r\n    QList<MemoryGapItem*> gaps = findMemoryGaps(registerItem);\r\n    QCOMPARE(gaps.count(), 1);\r\n\r\n    QVERIFY(fieldItem->isVisible());\r\n    QCOMPARE(fieldItem->pos().x(), qreal(0));\r\n    QCOMPARE(fieldItem->getOffset(), quint64(1));\r\n    QCOMPARE(fieldItem->getLastAddress(), quint64(7));\r\n    QCOMPARE(fieldItem->getDisplayOffset(), quint64(7));\r\n    QCOMPARE(fieldItem->getDisplayLastAddress(), quint64(1));\r\n    QCOMPARE(fieldItem->boundingRect().width(), 7*registerItem->boundingRect().width()/8);\r\n\r\n    MemoryGapItem* emptyLSB = gaps.first();\r\n    QVERIFY(!emptyLSB->isConflicted());\r\n    QCOMPARE(emptyLSB->name(), QString(\"Reserved\"));\r\n    QCOMPARE(emptyLSB->pos().x(), fieldItem->boundingRect().right());\r\n    QCOMPARE(emptyLSB->getDisplayOffset(), quint64(0));\r\n    QCOMPARE(emptyLSB->getDisplayLastAddress(), quint64(0));\r\n    QCOMPARE(emptyLSB->boundingRect().width(), registerItem->boundingRect().width()/8);\r\n\r\n    delete registerItem->parent();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_RegisterGraphItem::testFieldOutsideRegisterIsNotValid()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_RegisterGraphItem::testFieldOutsideRegisterIsNotValid()\r\n{\r\n    RegisterGraphItem* registerItem = createRegisterItem();\r\n    FieldGraphItem* fieldItem = createFieldItem(\"\", 15, 1, registerItem);\r\n\r\n    registerItem->redoChildLayout();\r\n\r\n    expandItem(registerItem);\r\n\r\n    QList<MemoryGapItem*> gaps = findMemoryGaps(registerItem);\r\n    QCOMPARE(gaps.count(), 1);\r\n\r\n    QVERIFY(fieldItem->isConflicted());\r\n\r\n    MemoryGapItem* placeholderForFields = gaps.first();\r\n    QVERIFY(!placeholderForFields->isConflicted());\r\n    QCOMPARE(placeholderForFields->name(), QString(\"Reserved\"));\r\n    QCOMPARE(placeholderForFields->pos().x(), registerItem->boundingRect().width() / 16);\r\n    QCOMPARE(placeholderForFields->getDisplayOffset(), quint64(0));\r\n    QCOMPARE(placeholderForFields->getDisplayLastAddress(), quint64(14));\r\n    QCOMPARE(placeholderForFields->boundingRect().width(), 15*registerItem->boundingRect().width()/16);\r\n\r\n    delete registerItem->parent();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_RegisterGraphItem::testFieldEndingOutsideRegisterIsNotValid()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_RegisterGraphItem::testFieldEndingOutsideRegisterIsNotValid()\r\n{\r\n    RegisterGraphItem* registerItem = createRegisterItem();\r\n    FieldGraphItem* fieldItem = createFieldItem(\"\", 7, 8, registerItem);\r\n\r\n    registerItem->redoChildLayout();\r\n\r\n    expandItem(registerItem);\r\n\r\n    QList<MemoryGapItem*> gaps = findMemoryGaps(registerItem);\r\n    QCOMPARE(gaps.count(), 1);\r\n\r\n    QVERIFY(fieldItem->isConflicted());\r\n    QCOMPARE(fieldItem->pos().x(), qreal(0));\r\n    QCOMPARE(fieldItem->getDisplayOffset(), quint64(14));\r\n    QCOMPARE(fieldItem->getDisplayLastAddress(), quint64(7));\r\n    QCOMPARE(fieldItem->boundingRect().width(), 8*registerItem->boundingRect().width()/15);\r\n\r\n    MemoryGapItem* placeholderForFields = gaps.first();\r\n    QVERIFY(!placeholderForFields->isConflicted());\r\n    QCOMPARE(placeholderForFields->name(), QString(\"Reserved\"));\r\n    QCOMPARE(placeholderForFields->pos().x(), 8*registerItem->boundingRect().width()/15);\r\n    QCOMPARE(placeholderForFields->getDisplayOffset(), quint64(0));\r\n    QCOMPARE(placeholderForFields->getDisplayLastAddress(), quint64(6));\r\n    QCOMPARE(placeholderForFields->boundingRect().width(), 7*registerItem->boundingRect().width()/15);\r\n\r\n    delete registerItem->parent();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_RegisterGraphItem::testEmptyBetweenTwoFields()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_RegisterGraphItem::testEmptyBetweenTwoFields()\r\n{\r\n    RegisterGraphItem* registerItem = createRegisterItem();\r\n\r\n    FieldGraphItem* msbItem = createFieldItem(\"msb\", 6, 2, registerItem);\r\n    FieldGraphItem* lsbItem = createFieldItem(\"lsb\", 0, 3, registerItem);\r\n\r\n    registerItem->redoChildLayout();\r\n\r\n    expandItem(registerItem);\r\n\r\n    QList<MemoryGapItem*> gaps = findMemoryGaps(registerItem);\r\n    QCOMPARE(gaps.count(), 1);\r\n\r\n    QVERIFY(msbItem->isVisible());\r\n    QCOMPARE(msbItem->pos().x(), qreal(0));\r\n    QCOMPARE(msbItem->getOffset(), quint64(6));\r\n    QCOMPARE(msbItem->getLastAddress(), quint64(7));\r\n    QCOMPARE(msbItem->getDisplayOffset(), quint64(7));\r\n    QCOMPARE(msbItem->getDisplayLastAddress(), quint64(6));\r\n    QCOMPARE(msbItem->boundingRect().width(), 2*registerItem->boundingRect().width()/8);\r\n\r\n    MemoryGapItem* emptySpace = gaps.first();\r\n    QVERIFY(!emptySpace->isConflicted());\r\n    QCOMPARE(emptySpace->name(), QString(\"Reserved\"));\r\n    QCOMPARE(emptySpace->pos().x(), 2*registerItem->boundingRect().width()/8);\r\n    QCOMPARE(emptySpace->getDisplayOffset(), quint64(3));\r\n    QCOMPARE(emptySpace->getDisplayLastAddress(), quint64(5));\r\n    QCOMPARE(emptySpace->boundingRect().width(), 3*registerItem->boundingRect().width()/8);\r\n\r\n    QVERIFY(lsbItem->isVisible());\r\n    QCOMPARE(lsbItem->pos().x(), msbItem->boundingRect().width() + emptySpace->boundingRect().width());\r\n    QCOMPARE(lsbItem->getOffset(), quint64(0));\r\n    QCOMPARE(lsbItem->getLastAddress(), quint64(2));\r\n    QCOMPARE(lsbItem->getDisplayOffset(), quint64(2));\r\n    QCOMPARE(lsbItem->getDisplayLastAddress(), quint64(0));\r\n    QCOMPARE(lsbItem->boundingRect().width(), 3*registerItem->boundingRect().width()/8);\r\n\r\n    delete registerItem->parent();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_RegisterGraphItem::testPartiallyOverlappingFields()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_RegisterGraphItem::testPartiallyOverlappingFields()\r\n{\r\n    RegisterGraphItem* registerItem = createRegisterItem();\r\n    FieldGraphItem* msbItem = createFieldItem(\"msb\", 4, 4, registerItem);\r\n    FieldGraphItem* lsbItem = createFieldItem(\"lsb\", 0, 5, registerItem);\r\n\r\n    registerItem->redoChildLayout();\r\n\r\n    expandItem(registerItem);\r\n\r\n    QVERIFY(msbItem->isVisible());\r\n    QVERIFY(msbItem->isConflicted());\r\n    QCOMPARE(msbItem->pos().x(), qreal(0));\r\n    QCOMPARE(msbItem->getDisplayOffset(), quint64(7));\r\n    QCOMPARE(msbItem->getDisplayLastAddress(), quint64(4));\r\n    QCOMPARE(msbItem->boundingRect().width(), qreal(100));\r\n\r\n    QCOMPARE(findMemoryGaps(registerItem).count(), 0);\r\n   \r\n    QVERIFY(lsbItem->isVisible());\r\n    QVERIFY(msbItem->isConflicted());\r\n    QCOMPARE(lsbItem->pos().x(), 3*registerItem->boundingRect().width()/8);\r\n    QCOMPARE(lsbItem->getDisplayOffset(), quint64(4));\r\n    QCOMPARE(lsbItem->getDisplayLastAddress(), quint64(0));\r\n    QCOMPARE(lsbItem->boundingRect().width(), 5*registerItem->boundingRect().width()/8);\r\n\r\n    delete registerItem->parent();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_RegisterGraphItem::testFullyOverlappingFields()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_RegisterGraphItem::testFullyOverlappingFields()\r\n{\r\n    RegisterGraphItem* registerItem = createRegisterItem();\r\n    FieldGraphItem* firstItem = createFieldItem(\"first\", 0, 4, registerItem);\r\n    FieldGraphItem* secondItem = createFieldItem(\"second\", 0, 4, registerItem);\r\n\r\n    registerItem->redoChildLayout();\r\n\r\n    expandItem(registerItem);\r\n\r\n    QVERIFY(firstItem->isVisible());\r\n    QVERIFY(firstItem->isConflicted());\r\n    QCOMPARE(firstItem->pos().x(), qreal(100));\r\n    QCOMPARE(firstItem->getDisplayOffset(), quint64(3));\r\n    QCOMPARE(firstItem->getDisplayLastAddress(), quint64(0));\r\n    QCOMPARE(firstItem->boundingRect().width(), qreal(100));\r\n\r\n    QVERIFY(secondItem->isVisible());\r\n    QVERIFY(secondItem->isConflicted());\r\n    QCOMPARE(secondItem->pos().x(), qreal(100));\r\n    QCOMPARE(secondItem->getDisplayOffset(), quint64(3));\r\n    QCOMPARE(secondItem->getDisplayLastAddress(), quint64(0));\r\n    QCOMPARE(secondItem->boundingRect().width(), qreal(100));\r\n\r\n    delete registerItem->parent();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_RegisterGraphItem::testMultipleFieldsOverlapping()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_RegisterGraphItem::testMultipleFieldsOverlapping()\r\n{\r\n    RegisterGraphItem* registerItem = createRegisterItem();\r\n\r\n    FieldGraphItem* largeItem = createFieldItem(\"largeField\", 0, 8, registerItem);\r\n\r\n    FieldGraphItem* firstOverlap = createFieldItem(\"firstOverlap\", 6, 2, registerItem);\r\n    FieldGraphItem* secondOverlap = createFieldItem(\"secondOverlap\", 0, 2, registerItem);\r\n\r\n    registerItem->redoChildLayout();\r\n\r\n    expandItem(registerItem);\r\n\r\n    QList<MemoryGapItem*> conflictedAreas = findMemoryGaps(registerItem);\r\n    QCOMPARE(conflictedAreas.count(), 0);\r\n\r\n    QVERIFY(largeItem->isVisible());\r\n    QVERIFY(largeItem->isConflicted());\r\n    QCOMPARE(largeItem->pos().x(), qreal(0));\r\n    QCOMPARE(largeItem->getDisplayOffset(), quint64(7));\r\n    QCOMPARE(largeItem->getDisplayLastAddress(), quint64(0));\r\n    QCOMPARE(largeItem->boundingRect().width(), registerItem->boundingRect().width());\r\n\r\n    QVERIFY(firstOverlap->isVisible());  \r\n    QVERIFY(firstOverlap->isConflicted());    \r\n    QCOMPARE(firstOverlap->boundingRect().width(), 2*registerItem->boundingRect().width()/8);\r\n\r\n    QVERIFY(secondOverlap->isVisible());\r\n    QVERIFY(secondOverlap->isConflicted());    \r\n    QCOMPARE(secondOverlap->boundingRect().width(), 2*registerItem->boundingRect().width()/8);\r\n\r\n    delete registerItem->parent();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_MemoryMapGraphItem::testTwoFieldsCompletelyOverlappingThird()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_RegisterGraphItem::testTwoFieldsCompletelyOverlappingThird()\r\n{\r\n    RegisterGraphItem* registerItem = createRegisterItem();\r\n\r\n    FieldGraphItem* msbItem = createFieldItem(\"msb\", 4, 4, registerItem);\r\n    FieldGraphItem* overlappedItem = createFieldItem(\"overlapped\", 2, 4, registerItem);\r\n    FieldGraphItem* lsbItem = createFieldItem(\"lsb\", 0, 4, registerItem);\r\n\r\n    registerItem->redoChildLayout();\r\n\r\n    expandItem(registerItem);\r\n\r\n    QList<MemoryGapItem*> conflictedAreas = findMemoryGaps(registerItem);\r\n    QCOMPARE(conflictedAreas.count(), 0);\r\n\r\n    QVERIFY(msbItem->isConflicted());\r\n    QCOMPARE(msbItem->pos().x(), qreal(0));\r\n    QCOMPARE(msbItem->getDisplayOffset(), quint64(7));\r\n    QCOMPARE(msbItem->getDisplayLastAddress(), quint64(4));\r\n    QCOMPARE(msbItem->boundingRect().width(), registerItem->boundingRect().width()/2);\r\n\r\n    QVERIFY(overlappedItem->isConflicted());\r\n    QCOMPARE(overlappedItem->pos().x(), registerItem->boundingRect().width()/4);\r\n    QCOMPARE(overlappedItem->getDisplayOffset(), quint64(5));\r\n    QCOMPARE(overlappedItem->getDisplayLastAddress(), quint64(2));\r\n    QCOMPARE(overlappedItem->boundingRect().width(), registerItem->boundingRect().width()/2);\r\n\r\n    QVERIFY(lsbItem->isConflicted());\r\n    QCOMPARE(lsbItem->pos().x(), registerItem->boundingRect().width()/2);\r\n    QCOMPARE(lsbItem->getDisplayOffset(), quint64(3));\r\n    QCOMPARE(lsbItem->getDisplayLastAddress(), quint64(0));\r\n    QCOMPARE(lsbItem->boundingRect().width(), registerItem->boundingRect().width()/2);\r\n\r\n    delete registerItem->parent();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_MemoryMapGraphItem::testZeroWidthFields()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_RegisterGraphItem::testZeroWidthFields()\r\n{\r\n    RegisterGraphItem* registerItem = createRegisterItem();\r\n\r\n    FieldGraphItem* msbItem = createFieldItem(\"msb\", 0, 0, registerItem);\r\n    FieldGraphItem* lsbItem = createFieldItem(\"lsb\", 0, 0, registerItem);\r\n\r\n    registerItem->redoChildLayout();\r\n\r\n    expandItem(registerItem);\r\n\r\n    QList<MemoryGapItem*> emptySpaces = findMemoryGaps(registerItem);\r\n    QCOMPARE(emptySpaces.count(), 1);\r\n\r\n    QVERIFY(msbItem->isConflicted());\r\n    QCOMPARE(msbItem->boundingRect().width(), qreal(1));\r\n\r\n    MemoryGapItem* placeholder = emptySpaces.first();\r\n    QVERIFY(!placeholder->isConflicted());\r\n    QCOMPARE(placeholder->pos().x(), qreal(0));\r\n    QCOMPARE(placeholder->getDisplayOffset(), quint64(1));\r\n    QCOMPARE(placeholder->getDisplayLastAddress(), quint64(7));\r\n    QCOMPARE(placeholder->boundingRect().width(), 7*registerItem->boundingRect().width()/8);\r\n\r\n    QVERIFY(lsbItem->isConflicted());\r\n    QCOMPARE(lsbItem->boundingRect().width(), qreal(1));\r\n\r\n    delete registerItem->parent();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_RegisterGraphItem::testTwoDimensional()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_RegisterGraphItem::testTwoDimensional()\r\n{\r\n    QSharedPointer<AddressBlock> addressBlock(new AddressBlock());\r\n    addressBlock->setName(\"testBlock\");\r\n    addressBlock->setBaseAddress(0);\r\n    addressBlock->setRange(\"4\");\r\n\r\n    QSharedPointer<ExpressionParser> noParser(new NullParser());\r\n\r\n    AddressBlockGraphItem* addressBlockItem = new AddressBlockGraphItem(addressBlock, noParser, 0);\r\n    addressBlockItem->setAddressableUnitBits(8);\r\n\r\n    QSharedPointer<Register> twoDimensionalRegister(new Register());\r\n    twoDimensionalRegister->setName(\"testRegister\");\r\n    twoDimensionalRegister->setAddressOffset(\"1\");\r\n    twoDimensionalRegister->setSize(\"8\");\r\n    twoDimensionalRegister->setDimension(\"2\");\r\n\r\n\r\n    RegisterGraphItem* registerItem = new RegisterGraphItem(twoDimensionalRegister, noParser, addressBlockItem);    \r\n    registerItem->updateDisplay();\r\n    \r\n    QCOMPARE(registerItem->name(), QString(\"testRegister[1:0]\"));\r\n    QCOMPARE(registerItem->getDisplayOffset(), quint64(1));\r\n    QCOMPARE(registerItem->getDisplayLastAddress(), quint64(2));\r\n\r\n    delete addressBlockItem;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_RegisterGraphItem::testLastDimensionExceedsAddressBlockRange()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_RegisterGraphItem::testLastDimensionExceedsAddressBlockRange()\r\n{\r\n    QSharedPointer<AddressBlock> addressBlock(new AddressBlock());\r\n    addressBlock->setName(\"testBlock\");\r\n    addressBlock->setBaseAddress(0);\r\n    addressBlock->setRange(\"2\");\r\n\r\n    QSharedPointer<ExpressionParser> noParser(new NullParser());\r\n\r\n    AddressBlockGraphItem* addressBlockItem = new AddressBlockGraphItem(addressBlock, noParser, 0);\r\n    addressBlockItem->setAddressableUnitBits(8);\r\n\r\n    QSharedPointer<Register> twoDimensionalRegister(new Register());\r\n    twoDimensionalRegister->setName(\"testRegister\");\r\n    twoDimensionalRegister->setAddressOffset(0);\r\n    twoDimensionalRegister->setSize(\"16\");\r\n    twoDimensionalRegister->setDimension(\"2\");\r\n\r\n\r\n    RegisterGraphItem* registerItem = new RegisterGraphItem(twoDimensionalRegister, noParser, addressBlockItem);\r\n    \r\n\r\n    QCOMPARE(registerItem->getOffset(), quint64(0));\r\n    QCOMPARE(registerItem->getLastAddress(), quint64(3));\r\n\r\n    \r\n    delete addressBlockItem;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_RegisterGraphItem::testExpressions()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_RegisterGraphItem::testExpressions()\r\n{\r\n    QSharedPointer<AddressBlock> addressBlock(new AddressBlock());\r\n    addressBlock->setName(\"testBlock\");\r\n    addressBlock->setBaseAddress(0);\r\n    addressBlock->setRange(\"6\");\r\n\r\n    QSharedPointer<ExpressionParser> noParser(new NullParser());\r\n\r\n    AddressBlockGraphItem* addressBlockItem = new AddressBlockGraphItem(addressBlock, noParser, 0);\r\n    addressBlockItem->setAddressableUnitBits(8);\r\n\r\n    QSharedPointer<Register> testRegister(new Register());\r\n    testRegister->setName(\"testRegister\");\r\n    testRegister->setAddressOffset(\"1+1\");\r\n    testRegister->setSize(\"8*2\");\r\n    testRegister->setDimension(\"3-1\");\r\n\r\n    QSharedPointer<ExpressionParser> expressionParser(new SystemVerilogExpressionParser());\r\n\r\n    RegisterGraphItem* registerItem = new RegisterGraphItem(testRegister, expressionParser, addressBlockItem);    \r\n\r\n    QCOMPARE(registerItem->name(), QString(\"testRegister[1:0]\"));\r\n    QCOMPARE(registerItem->getDisplayOffset(), quint64(2));\r\n    QCOMPARE(registerItem->getDisplayLastAddress(), quint64(5));\r\n    QCOMPARE(registerItem->getBitWidth(), 16);\r\n\r\n    delete addressBlockItem;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_RegisterGraphItem::testNonPresentField()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_RegisterGraphItem::testNonPresentField()\r\n{\r\n    RegisterGraphItem* registerItem = createRegisterItem();\r\n\r\n    QSharedPointer<Field> nonPresentField(new Field());\r\n    nonPresentField->setName(\"invisibleField\");\r\n    nonPresentField->setBitOffset(\"2\");\r\n    nonPresentField->setBitWidth(\"2\");\r\n    nonPresentField->setIsPresent(\"0\");\r\n\r\n    QSharedPointer<ExpressionParser> expressionParser(new SystemVerilogExpressionParser());\r\n\r\n    FieldGraphItem* nonPresentItem = new FieldGraphItem(nonPresentField, expressionParser, registerItem);\r\n    registerItem->addChild(nonPresentItem);\r\n\r\n    FieldGraphItem* presentItem = createFieldItem(\"visibleField\", 1, 3, registerItem);\r\n\r\n    registerItem->redoChildLayout();\r\n    expandItem(registerItem);\r\n\r\n    QCOMPARE(nonPresentItem->isVisible(), false);\r\n\r\n    QCOMPARE(presentItem->isConflicted(), false);\r\n\r\n    QList<MemoryGapItem*> reservedSpaces = findMemoryGaps(registerItem);\r\n\r\n    QCOMPARE(reservedSpaces.size(), 2);\r\n    MemoryGapItem* reservedMSBs = reservedSpaces.last();\r\n    QCOMPARE(reservedMSBs->getDisplayOffset(), quint64(4));\r\n    QCOMPARE(reservedMSBs->getDisplayLastAddress(), quint64(7));\r\n\r\n    MemoryGapItem* reservedLSB = reservedSpaces.first();\r\n    QCOMPARE(reservedLSB->getDisplayOffset(), quint64(0));\r\n    QCOMPARE(reservedLSB->getDisplayLastAddress(), quint64(0));\r\n\r\n    delete registerItem->parentItem();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_MemoryMapGraphItem::expandItem()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_RegisterGraphItem::expandItem(RegisterGraphItem* registerItem)\r\n{\r\n    GraphicsExpandCollapseItem* expander(0);\r\n    foreach (QGraphicsItem* item, registerItem->childItems())\r\n    {\r\n        if (dynamic_cast<GraphicsExpandCollapseItem*>(item) != 0)\r\n        {\r\n            expander = dynamic_cast<GraphicsExpandCollapseItem*>(item);\r\n            expander->expand();\r\n            return;\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_RegisterGraphItem::findMemoryGaps()\r\n//-----------------------------------------------------------------------------\r\nQList<MemoryGapItem*> tst_RegisterGraphItem::findMemoryGaps(RegisterGraphItem* memoryMapItem)\r\n{\r\n    QList<MemoryGapItem*> gaps;\r\n    foreach (QGraphicsItem* child, memoryMapItem->childItems())\r\n    {\r\n        if (dynamic_cast<MemoryGapItem*>(child))\r\n        {\r\n            gaps.append(dynamic_cast<MemoryGapItem*>(child));\r\n        }\r\n    }\r\n\r\n    return gaps;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_RegisterGraphItem::createRegisterItem()\r\n//-----------------------------------------------------------------------------\r\nRegisterGraphItem* tst_RegisterGraphItem::createRegisterItem()\r\n{\r\n    QSharedPointer<AddressBlock> addressBlock(new AddressBlock());\r\n    addressBlock->setName(\"testBlock\");\r\n    addressBlock->setBaseAddress(0);\r\n    addressBlock->setRange(\"1\");\r\n\r\n    QSharedPointer<ExpressionParser> noParser(new NullParser());\r\n\r\n    AddressBlockGraphItem* addressBlockItem = new AddressBlockGraphItem(addressBlock, noParser, 0);\r\n    addressBlockItem->setAddressableUnitBits(8);\r\n\r\n    QSharedPointer<Register> testRegister(new Register());\r\n    testRegister->setName(\"testRegister\");\r\n    testRegister->setAddressOffset(\"0\");\r\n    testRegister->setSize(\"8\");\r\n\r\n    return new RegisterGraphItem(testRegister, noParser, addressBlockItem);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_RegisterGraphItem::createFieldItem()\r\n//-----------------------------------------------------------------------------\r\nFieldGraphItem* tst_RegisterGraphItem::createFieldItem(QString name, unsigned int offset, unsigned int bitWidth,\r\n    RegisterGraphItem* parentRegister)\r\n{\r\n    QSharedPointer<Field> field(new Field());\r\n    field->setName(name);\r\n    field->setBitOffset(QString::number(offset));\r\n    field->setBitWidth(QString::number(bitWidth));\r\n    \r\n    QSharedPointer<ExpressionParser> expressionParser(new SystemVerilogExpressionParser());\r\n\r\n    FieldGraphItem* fieldItem = new FieldGraphItem(field, expressionParser, parentRegister);\r\n    parentRegister->addChild(fieldItem);\r\n\r\n    return fieldItem;\r\n}\r\n\r\nQTEST_MAIN(tst_RegisterGraphItem)\r\n\r\n#include \"tst_RegisterGraphItem.moc\"\r\n"
  },
  {
    "path": "tests/Core/tst_RegisterGraphItem.pri",
    "content": "# ----------------------------------------------------\r\n# This file is generated by the Qt Visual Studio Tools.\r\n# ------------------------------------------------------\r\n\r\nHEADERS += ../../editors/ComponentEditor/memoryMaps/memoryMapsVisualizer/addressblockgraphitem.h \\\r\n    ../../common/graphicsItems/expandableitem.h \\\r\n    ../../editors/ComponentEditor/visualization/fieldgapitem.h \\\r\n    ../../editors/ComponentEditor/visualization/AddressableItem.h \\\r\n    ../../editors/ComponentEditor/memoryMaps/memoryMapsVisualizer/fieldgraphitem.h \\\r\n    ../../common/graphicsItems/graphicsexpandcollapseitem.h \\\r\n    ../../editors/ComponentEditor/visualization/memorygapitem.h \\\r\n    ../../editors/ComponentEditor/visualization/memoryvisualizationitem.h \\\r\n    ../../editors/ComponentEditor/memoryMaps/memoryMapsVisualizer/registergraphitem.h \\\r\n    ../../common/graphicsItems/visualizeritem.h \\\r\n    ../../editors/ComponentEditor/memoryMaps/memoryMapsVisualizer/MemoryBlockGraphItem.h\r\nSOURCES += ../../editors/ComponentEditor/memoryMaps/memoryMapsVisualizer/addressblockgraphitem.cpp \\\r\n    ../../common/graphicsItems/expandableitem.cpp \\\r\n    ../../editors/ComponentEditor/visualization/AddressableItem.cpp \\\r\n    ../../editors/ComponentEditor/visualization/fieldgapitem.cpp \\\r\n    ../../editors/ComponentEditor/memoryMaps/memoryMapsVisualizer/fieldgraphitem.cpp \\\r\n    ../../common/graphicsItems/graphicsexpandcollapseitem.cpp \\\r\n    ../../editors/ComponentEditor/visualization/memorygapitem.cpp \\\r\n    ../../editors/ComponentEditor/visualization/memoryvisualizationitem.cpp \\\r\n    ../../editors/ComponentEditor/memoryMaps/memoryMapsVisualizer/registergraphitem.cpp \\\r\n    ../../editors/ComponentEditor/memoryMaps/memoryMapsVisualizer/MemoryBlockGraphItem.cpp \\\r\n    ../../common/graphicsItems/visualizeritem.cpp \\\r\n    ./tst_RegisterGraphItem.cpp\r\n"
  },
  {
    "path": "tests/Core/tst_RegisterGraphItem.pro",
    "content": "#-----------------------------------------------------------------------------\r\n# File: tst_RegisterGraphItem.pro\r\n#-----------------------------------------------------------------------------\r\n# Project: Kactus 2\r\n# Author: Esko Pekkarinen\r\n# Date: 22.03.2015\r\n#\r\n# Description:\r\n# Qt project file template for running unit tests for AddressBlockGraphItem.\r\n#-----------------------------------------------------------------------------\r\n\r\nTEMPLATE = app\r\n\r\nTARGET = tst_RegisterGraphItem\r\n\r\nDEFINES+=KACTUS2_EXPORTS\r\n\r\nQT += core xml gui testlib widgets\r\nCONFIG += c++11 testcase console\r\n\r\nQMAKE_EXPORTED_VARIABLES += MAKE_TESTARGS\r\nMAKE_TESTARGS.name = TESTARGS\r\nMAKE_TESTARGS.value = \"-platform offscreen\"\r\n\r\nwin32:CONFIG(release, debug|release) {\r\n    LIBS += -L$$PWD/../../executable/ -lIPXACTmodels -lKactusAPI\r\n    DESTDIR = ./release\r\n}\r\nelse:win32:CONFIG(debug, debug|release) {\r\n    LIBS += -L$$PWD/../../executable/ -lIPXACTmodelsd -lKactusAPId\r\n    DESTDIR = ./debug\r\n}\r\nelse:unix {\r\n    LIBS += -L$$PWD/../../executable/ -lIPXACTmodels -lKactusAPI\r\n    DESTDIR = ./release\r\n}\r\n\r\nINCLUDEPATH += $$PWD/../../\r\nINCLUDEPATH += $$PWD/../../executable\r\nINCLUDEPATH += $$DESTDIR\r\n\r\nDEPENDPATH += $$PWD/../../\r\nDEPENDPATH += $$PWD/../../executable\r\nDEPENDPATH += .\r\n\r\nOBJECTS_DIR += $$DESTDIR\r\n\r\nMOC_DIR += ./generatedFiles\r\nUI_DIR += ./generatedFiles\r\nRCC_DIR += ./generatedFiles\r\ninclude(tst_RegisterGraphItem.pri)\r\n"
  },
  {
    "path": "tests/Core/tst_SystemVerilogExpressionParser.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: tst_SystemVerilogExpressionParser.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Esko Pekkarinen\r\n// Date: 25.11.2014\r\n//\r\n// Description:\r\n// Unit test for class SystemVerilogExpressionParser.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include <QTest>\r\n#include <QtMath>\r\n\r\n#include <KactusAPI/include/SystemVerilogExpressionParser.h>\r\n\r\nclass tst_SystemVerilogExpressionParser : public QObject\r\n{\r\n    Q_OBJECT\r\n\r\npublic:\r\n    tst_SystemVerilogExpressionParser();\r\n\r\n    void testInputs();\r\n\r\nprivate slots:\r\n\r\n    void testParseConstant();\r\n    void testParseConstant_data();\r\n\r\n    void testParseAddition();\r\n    void testParseAddition_data();\r\n    void testParseSubtraction();\r\n    void testParseSubtraction_data();\r\n\r\n    void testParseMultiply();\r\n    void testParseMultiply_data();\r\n    void testParseDivision();\r\n    void testParseDivision_data();\r\n\r\n    void testParsePower();\r\n    void testParsePower_data();\r\n\r\n    void testClog2Function();\r\n    void testClog2Function_data();\r\n\r\n    void testParseMultipleOperations();\r\n    void testParseMultipleOperations_data();\r\n\r\n    void testParseExpressionWithParathesis();\r\n    void testParseExpressionWithParathesis_data();\r\n\r\n    void testGetBaseForExpression();\r\n    void testGetBaseForExpression_data();\r\n\r\n    void testIsPlainValue();\r\n    void testIsPlainValue_data();\r\n\r\n    void testStringValues();\r\n    void testStringValues_data();\r\n\r\n    void testParseComparison();\r\n    void testParseComparison_data();\r\n\r\n    void testParseMathFunctions();\r\n    void testParseMathFunctions_data();\r\n\r\n    void testBitwiseOperations();\r\n    void testBitwiseOperations_data();\r\n\r\n    void testTernaryOperations();\r\n    void testTernaryOperations_data();\r\n\r\n    void testParserPerformance();\r\n    void testParserPerformance_data();\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_SystemVerilogExpressionParser::tst_SystemVerilogExpressionParser()\r\n//-----------------------------------------------------------------------------\r\ntst_SystemVerilogExpressionParser::tst_SystemVerilogExpressionParser()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_SystemVerilogExpressionParser::testInputs()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_SystemVerilogExpressionParser::testInputs()\r\n{\r\n    QFETCH(QString, expression);\r\n    QFETCH(QString, expectedResult);\r\n    QFETCH(bool, expectedValid);\r\n\r\n    SystemVerilogExpressionParser parser;\r\n\r\n    bool isValid = false;\r\n    QString parserResult = parser.parseExpression(expression, &isValid);\r\n\r\n    QCOMPARE(isValid, expectedValid);\r\n    if (expectedValid)\r\n    {\r\n        QCOMPARE(parserResult, expectedResult);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_SystemVerilogExpressionParser::testParseConstant()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_SystemVerilogExpressionParser::testParseConstant()\r\n{\r\n    testInputs();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_SystemVerilogExpressionParser::testParseConstant_data()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_SystemVerilogExpressionParser::testParseConstant_data()\r\n{\r\n    QTest::addColumn<QString>(\"expression\");\r\n    QTest::addColumn<QString>(\"expectedResult\");\r\n    QTest::addColumn<bool>(\"expectedValid\");\r\n\r\n    QTest::newRow(\"Empty value evaluates to empty\") << \"\" << \"\" << true;\r\n\r\n    QTest::newRow(\"Operator only evaluates to invalid\") << \"-\" << \"x\" << false;\r\n\r\n\t//! Booleans\r\n    QTest::newRow(\"Boolean true should evaluate to 1\") << \"true\" << \"1\" << true;\r\n    QTest::newRow(\"Boolean false should evaluate to 0\") << \"false\" << \"0\" << true;\r\n    QTest::newRow(\"Array of {true,false} should evaluate to an array of {1,0}\") << \"{true,false}\" << \"{1,0}\" << true;\r\n    QTest::newRow(\"Boolean True should evaluate to 1\") << \"True\" << \"1\" << true;\r\n    QTest::newRow(\"Boolean False should evaluate to 0\") << \"False\" << \"0\" << true;\r\n    QTest::newRow(\"Boolean True should evaluate to 1\") << \"TRUe\" << \"1\" << true;\r\n    QTest::newRow(\"Boolean False should evaluate to 0\") << \"fALSe\" << \"0\" << true;\r\n\r\n    //! Array.\r\n    QTest::newRow(\"Array of {1,1} should evaluate to an array of {1,1}\") << \"{1,1}\" << \"{1,1}\" << true;\r\n    QTest::newRow(\"Array with one value is a valid array\") << \"{2}\" << \"{2}\" << true;\r\n    QTest::newRow(\"Inadequate array of {1,1,#} should evaluate to unknown\") << \"{1,1,#}\" << \"x\" << false;\r\n    //QTest::newRow(\"Inadequate array of {1,} should evaluate to unknown\") << \"{1,}\" << \"x\" << false;\r\n    QTest::newRow(\"Inadequate array of ,1} should evaluate to unknown\") << \",1}\" << \"x\" << false;\r\n    QTest::newRow(\"Hexadecimal values in array are evaluated as decimal values\") << \"{'h10,'h14}\" << \"{16,20}\" << true;\r\n    QTest::newRow(\"Array {1,1} should evaluate to an array of {1,1}\") << \"{1,1}\" << \"{1,1}\" << true;\r\n    //QTest::newRow(\"Array consisting of multiple types of data is unknown\") << \"{1.1,1,\\\"helloWorld\\\"}\" << \"x\"  << false;\r\n    QTest::newRow(\"Array inside an array is ok\") << \"{1,{1,1}}\" << \"{1,{1,1}}\"  << true;\r\n    QTest::newRow(\"Array inside an array as first is ok\") << \"{{1,1},1}\" << \"{{1,1},1}\"  << true;\r\n\r\n    //! Decimal numbers.\r\n    QTest::newRow(\"Decimal number 0 should evaluate to 0\") << \"0\" << \"0\" << true;\r\n    QTest::newRow(\"Decimal number 1 should evaluate to 1\") << \"1\" << \"1\" << true;\r\n    QTest::newRow(\"Decimal number 7 should evaluate to 7\") << \"7\" << \"7\" << true;\r\n    QTest::newRow(\"Decimal number '4 should evaluate to 4\") << \"4\" << \"4\" << true;\r\n\r\n    QTest::newRow(\"Positive decimal number\") << \"+1\" << \"1\" << true;\r\n    QTest::newRow(\"Negative decimal number\") << \"-1\" << \"-1\" << true;\r\n\r\n    QTest::newRow(\"Decimal number 'd2 should evaluate to 2\") << \"'d2\" << \"2\" << true;\r\n    QTest::newRow(\"Decimal number 'D8 should evaluate to 8\") << \"'D8\" << \"8\" << true;\r\n\r\n    QTest::newRow(\"Decimal number 'sd2 should evaluate to 2\") << \"'sd2\" << \"2\" << true;\r\n    QTest::newRow(\"Decimal number 'sD2 should evaluate to 2\") << \"'sD2\" << \"2\" << true;\r\n\r\n    QTest::newRow(\"Decimal number 'Sd3 should evaluate to 3\") << \"'Sd3\" << \"3\" << true;\r\n    QTest::newRow(\"Decimal number 'SD3 should evaluate to 3\") << \"'SD3\" << \"3\" << true;\r\n    \r\n    QTest::newRow(\"Decimal number 1'd3 with size should evaluate to 3\") << \"1'd3\" << \"3\" << true;\r\n\r\n    QTest::newRow(\"Decimal number '2 should evaluate to 2\") << \"'2\" << \"2\" << true;\r\n\r\n    QTest::newRow(\"Decimal number with underscore should evaluate without underscore\") << \"10_000\" << \"10000\" << true;\r\n    QTest::newRow(\"Decimal number with multiple underscores should evaluate without underscores\") \r\n        << \"1_000_000\" << \"1000000\" << true;\r\n    QTest::newRow(\"Decimal number with base and underscores should evaluate\") << \"'sd10_000\" << \"10000\" << true;\r\n    QTest::newRow(\"Decimal number 1000005 evaluates to 1000005\") << \"1000005\" << \"1000005\" << true;\r\n\r\n    //! Fixed-point numbers.\r\n    QTest::newRow(\"Fixed-point number 0.0 should evaluate to 0.0\") << \"0.0\" << \"0.0\" << true;\r\n    QTest::newRow(\"Fixed-point number 0.5 should evaluate to 0.5\") << \"0.5\" << \"0.5\" << true;\r\n    QTest::newRow(\"Fixed-point number 0.25 should evaluate to 0.25\") << \"0.25\" << \"0.25\" << true;\r\n    QTest::newRow(\"Fixed-point number 1.0 should evaluate to 1.0\") << \"1.0\" << \"1.0\" << true;\r\n    QTest::newRow(\"Negative fixed-point number\") << \"-1.0\" << \"-1.0\" << true;\r\n\r\n    //! Hexadecimal numbers.\r\n    QTest::newRow(\"Hexadecimal number without base should evaluate to unknown\") << \"ff\" << \"x\" << false;\r\n    QTest::newRow(\"Hexadecimal number 'h1 should evaluate to 1\") << \"'h1\" << \"1\" << true;\r\n    QTest::newRow(\"Hexadecimal number 'hA should evaluate to 10\") << \"'hA\" << \"10\" << true;\r\n    QTest::newRow(\"Hexadecimal number 'Hf should evaluate to 15\") << \"'Hf\" << \"15\" << true;\r\n\r\n    QTest::newRow(\"Hexadecimal number 'shf should evaluate to 15\") << \"'shf\" << \"15\" << true;\r\n    QTest::newRow(\"Hexadecimal number 'sH2 should evaluate to 2\") << \"'sH2\" << \"2\" << true;\r\n    \r\n    QTest::newRow(\"Hexadecimal number 'Shb should evaluate to 11\") << \"'Shb\" << \"11\" << true;\r\n    QTest::newRow(\"Hexadecimal number 'SH5 should evaluate to 5\") << \"'SH5\" << \"5\" << true;\r\n\r\n    QTest::newRow(\"Hexadecimal number 8'h02 with size should evaluate to 2\") << \"8'd02\" << \"2\" << true;\r\n    QTest::newRow(\"Hexadecimal number 32'h00000001 with size should evaluate to 1\") << \"32'h00000001\" << \"1\" << true;\r\n\r\n    QTest::newRow(\"Hexadecimal number with underscore should evaluate to decimal without underscore\") \r\n        << \"'h1_F\" << \"31\" << true;\r\n    QTest::newRow(\"Hexadecimal number with multiple underscores should evaluate to decimal without underscores\") \r\n        << \"'h0_F_F\" << \"255\" << true;\r\n\r\n    //! Binary numbers.\r\n    QTest::newRow(\"Binary number 'b1 should evaluate to 1\") << \"'b1\" << \"1\" << true;\r\n    QTest::newRow(\"Binary number 'b10 should evaluate to 2\") << \"'b10\" << \"2\" << true;\r\n    QTest::newRow(\"Binary number 'b111 should evaluate to 7\") << \"'b111\" << \"7\" << true;\r\n\r\n    QTest::newRow(\"Binary number 'sb11 should evaluate to 3\") << \"'sb11\" << \"3\" << true;\r\n    QTest::newRow(\"Binary number 'sB10 should evaluate to 2\") << \"'sB10\" << \"2\" << true;\r\n\r\n    QTest::newRow(\"Binary number 'Sb110 should evaluate to 6\") << \"'Sb110\" << \"6\" << true;\r\n    QTest::newRow(\"Binary number 'SB100 should evaluate to 4\") << \"'sB100\" << \"4\" << true;\r\n\r\n    QTest::newRow(\"Binary number 4'b0111 with size should evaluate to 7\") << \"4'b0111\" << \"7\" << true;\r\n\r\n    QTest::newRow(\"Binary number with underscore should evaluate to decimal without underscore\") \r\n        << \"'b1_1\" << \"3\" << true;\r\n    QTest::newRow(\"Binary number with multiple underscores should evaluate to decimal without underscores\") \r\n        << \"'b1_1_1_1\" << \"15\" << true;\r\n\r\n    //! Octal numbers.\r\n    QTest::newRow(\"Octal number 'o1 should evaluate to 1\") << \"'o1\" << \"1\" << true;\r\n    QTest::newRow(\"Octal number 'o7 should evaluate to 7\") << \"'o7\" << \"7\" << true;\r\n    QTest::newRow(\"Octal number 'o10 should evaluate to 8\") << \"'o10\" << \"8\" << true;\r\n    QTest::newRow(\"Octal number 'O12 should evaluate to 10\") << \"'O12\" << \"10\" << true;\r\n\r\n    QTest::newRow(\"Octal number 'so4 should evaluate to 4\") << \"'so4\" << \"4\" << true;\r\n    QTest::newRow(\"Octal number 'sO17 should evaluate to 15\") << \"'sO17\" << \"15\" << true;\r\n\r\n    QTest::newRow(\"Octal number 'So20 should evaluate to 16\") << \"'So20\" << \"16\" << true;\r\n    QTest::newRow(\"Octal number 'SO2 should evaluate to 2\") << \"'SO2\" << \"2\" << true;\r\n\r\n    QTest::newRow(\"Octal number 3'o011 with size should evaluate to 9\") << \"3'o011\" << \"9\" << true;\r\n\r\n    QTest::newRow(\"Octal number with underscore should evaluate to decimal without underscore\") \r\n        << \"'o1_0\" << \"8\" << true;\r\n    QTest::newRow(\"Octal number with multiple underscores should evaluate to decimal without underscores\") \r\n        << \"'o1_0_0\" << \"64\" << true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_SystemVerilogExpressionParser::testParseAddition()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_SystemVerilogExpressionParser::testParseAddition()\r\n{\r\n    testInputs();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_SystemVerilogExpressionParser::testParseAddition_data()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_SystemVerilogExpressionParser::testParseAddition_data()\r\n{\r\n    QTest::addColumn<QString>(\"expression\");\r\n    QTest::addColumn<QString>(\"expectedResult\");\r\n    QTest::addColumn<bool>(\"expectedValid\");\r\n\r\n    QTest::newRow(\"No addition on constant equals constant\") << \"1\" << \"1\" << true;\r\n    QTest::newRow(\"Addition without second operand is unknown\") << \"1+\" << \"x\" << false;\r\n    QTest::newRow(\"Addition without second operand and whitespaces is unknown\") << \" 1 + \" << \"x\" << false;\r\n\r\n\t//! Booleans\r\n\tQTest::newRow(\"True + false + true equals two\") << \"True + false + true\" << \"2\" << true;\r\n\tQTest::newRow(\"true+true inside array equals 2\") << \"{false,true+true}\" << \"{0,2}\" << true;\r\n\r\n    //! Array.\r\n    QTest::newRow(\"Addition of arrays should evaluate to unknown\") << \"{1,1}+{1,1}\" << \"x\" << false;\r\n    QTest::newRow(\"1+1 inside array equals 2\") << \"{1+1,1}\" << \"{2,1}\" << true;\r\n    QTest::newRow(\"Constant added to an array is unknown\") << \"{1,1} + 1\" << \"x\" << false;\r\n\r\n    //! Decimal numbers.\r\n    QTest::newRow(\"Constant plus zero equals constant\") << \"1+0\" << \"1\" << true;\r\n    QTest::newRow(\"One plus one equals two\") << \"1+1\" << \"2\" << true;\r\n    QTest::newRow(\"One plus two equals three\") << \"1+2\" << \"3\" << true;\r\n    QTest::newRow(\"Two plus one equals three\") << \"2+1\" << \"3\" << true;\r\n    QTest::newRow(\"Two plus two with whitespaces equals four\") << \"2 + 2\" << \"4\" << true;\r\n    QTest::newRow(\"Multiple whitespaces\") << \" 1  +     1 \" << \"2\" << true;\r\n    QTest::newRow(\"Sum of decimal values with sizes and signs\") << \"8'sd8 + 8'sd9\" << \"17\" << true;\r\n    QTest::newRow(\"Large decimal sum 1000003+1\") << \"1000003+1\" << \"1000004\" << true;\r\n    QTest::newRow(\"Larger decimal sum 1000004+1\") << \"1000004+1\" << \"1000005\" << true;\r\n    QTest::newRow(\"Sum of large decimal values 1000003+1000003\") << \"1000003+1000003\" << \"2000006\" << true;\r\n\r\n    //! Fixed-point numbers.\r\n    QTest::newRow(\"One plus one equals exactly two\") << \"1.0+1.0\" << \"2.0\" << true;\r\n    QTest::newRow(\"One plus decimal two equals three\") << \"1.0+2\" << \"3.0\" << true;\r\n    QTest::newRow(\"Decimal one plus real two equals three\") << \"1+2.0\" << \"3.0\" << true;\r\n    QTest::newRow(\"Half plus one quarter equals 0.75\") << \"0.5 + 0.25\" << \"0.75\" << true;\r\n    QTest::newRow(\"Four quarters equals 1\") << \"0.25 + 0.25 + 0.25 + 0.25\" << \"1.00\" << true;\r\n    QTest::newRow(\"Real sum 1000004.012 + 1.84444444\") << \"1000004.012 + 1.84444444\" << \"1000005.85644444\" << true;\r\n\r\n    //! Hexadecimal numbers.\r\n    QTest::newRow(\"Sum of hexadecimal 'h10 + 'h0 equals 16\") << \"'h10 + 'h0\" << \"16\" << true;\r\n    QTest::newRow(\"Sum of hexadecimal 'h10 + 'h10 equals 32\") << \"'h10 + 'h10\" << \"32\" << true;\r\n    QTest::newRow(\"Sum of hexadecimal values with sizes and signs\") << \"8'sh10 + 8'sh02\" << \"18\" << true;\r\n    QTest::newRow(\"Constant hexadecimal with long size\") << \"32'h00000001\" << \"1\" << true;\r\n\r\n    //! Binary numbers.\r\n    QTest::newRow(\"Sum of binary 'b100 + 'b010 equals 6\") << \"'b100 + 'b010\" << \"6\" << true;\r\n    QTest::newRow(\"Sum of binary 'b0001 + 'b0111 equals 8\") << \"'b0001 + 'b0111\" << \"8\" << true;\r\n    QTest::newRow(\"Sum of binary values with sizes and signs\") << \"4'sb0010 + 4'sb0001\" << \"3\" << true;\r\n\r\n    //! Octal numbers.\r\n    QTest::newRow(\"Sum of octal 'o1 + 'o1 equals 2\") << \"'o1 + 'o1\" << \"2\" << true;\r\n    QTest::newRow(\"Sum of octal 'o2 + 'o7 equals 9\") << \"'o2 + 'o7\" << \"9\" << true;\r\n    QTest::newRow(\"Sum of octal values with sizes and signs\") << \"3'so3 + 3'so4\" << \"7\" << true;\r\n\r\n    QTest::newRow(\"Sum of decimal and octal 10 + 'o10 equals 18\") << \"10 + 'o10\" << \"18\" << true;\r\n    QTest::newRow(\"Sum of hexadecimal and binary 'h10 + 'b10 equals 18\") << \"'h10 + 'b10\" << \"18\" << true;\r\n\r\n    QTest::newRow(\"Sum of multiple values of same base\") << \"'h10 + 'h10 + 'h01\" << \"33\" << true;\r\n    QTest::newRow(\"Sum of multiple values of different bases\") << \"'hA + 'b1010 + 'o12 + 10\" << \"40\" << true;\r\n\r\n    QTest::newRow(\"Sum of ascii characters and a number is unknown\") << \"text + 2\" << \"x\" << false;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_SystemVerilogExpressionParser::testParseSubtraction()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_SystemVerilogExpressionParser::testParseSubtraction()\r\n{\r\n    testInputs();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_SystemVerilogExpressionParser::testParseSubtraction_data()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_SystemVerilogExpressionParser::testParseSubtraction_data()\r\n{\r\n    QTest::addColumn<QString>(\"expression\");\r\n    QTest::addColumn<QString>(\"expectedResult\");\r\n    QTest::addColumn<bool>(\"expectedValid\");\r\n\r\n    //! Arrays.\r\n    QTest::newRow(\"One minus one equals zero in array\") << \"{1,1-1}\" << \"{1,0}\" << true;\r\n    QTest::newRow(\"Subtraction of arrays evaluates to unknown\") << \"{1,1} - {1,1}\" << \"x\" << false;\r\n    QTest::newRow(\"Constant subtracted from an array is unknown\") << \"{1,1} - 1\" << \"x\" << false;\r\n\r\n    //! Decimal numbers.\r\n    QTest::newRow(\"Constant minus zero equals constant\") << \"1-0\" << \"1\" << true;\r\n    QTest::newRow(\"Constant minus constant equals zero\") << \"1-1\" << \"0\" << true;\r\n    QTest::newRow(\"Four minus two equals two\") << \"4-2\" << \"2\" << true;\r\n    QTest::newRow(\"three minus one equals two\") << \"3-1\" << \"2\" << true;\r\n    QTest::newRow(\"Negative result\") << \"1-2\" << \"-1\" << true;\r\n    QTest::newRow(\"Negative operands\") << \"-1-2\" << \"-3\" << true;\r\n    QTest::newRow(\"Two minus one with whitespaces equals one\") << \"2 - 1\" << \"1\" << true;\r\n    QTest::newRow(\"Multiple whitespaces\") << \" 2  -     1 \" << \"1\" << true;\r\n    QTest::newRow(\"Subtraction of decimal values with sizes and signs\") << \"8'sd9 - 8'sd2\" << \"7\" << true;\r\n\r\n    //! Fixed-point numbers.\r\n    QTest::newRow(\"4 - 2.25 two equals 1.75\") << \"4.0 - 2.25\" << \"1.75\" << true;\r\n    QTest::newRow(\"Negative fixed-point result\") << \"0.5 - 2.0\" << \"-1.5\" << true;\r\n\r\n    //! Hexadecimal numbers.\r\n    QTest::newRow(\"Subtraction of hexadecimal 'h10 - 'h1 equals 15\") << \"'h10 - 'h1\" << \"15\" << true;\r\n    QTest::newRow(\"Subtraction of hexadecimal 'h0E - 'h4 equals 10\") << \"'h0E - 'h4\" << \"10\" << true;\r\n    QTest::newRow(\"Subtraction of hexadecimal values with sizes and signs\") << \"8'sh0B - 8'sh04\" << \"7\" << true;\r\n\r\n    //! Binary numbers.\r\n    QTest::newRow(\"Subtraction of binary 'b100 - 'b010 equals 2\") << \"'b100 - 'b010\" << \"2\" << true;\r\n    QTest::newRow(\"Subtraction of binary 'b0111 - 'b011 equals 4\") << \"'b0111 - 'b011\" << \"4\" << true;\r\n    QTest::newRow(\"Subtraction of binary values with sizes and signs\") << \"4'sb0010 - 4'sb0001\" << \"1\" << true;\r\n\r\n    //! Octal numbers.\r\n    QTest::newRow(\"Subtraction of octal 'o3 - 'o1 equals 2\") << \"'o3 - 'o1\" << \"2\" << true;\r\n    QTest::newRow(\"Subtraction of octal 'o7 - 'o2 equals 5\") << \"'o7 - 'o2\" << \"5\" << true;\r\n    QTest::newRow(\"Subtraction of octal values with sizes and signs\") << \"3'so6 - 3'so3\" << \"3\" << true;\r\n\r\n    QTest::newRow(\"Subtraction of multiple values of same base\") << \"'h12 - 'h8 - 'h01\" << \"9\" << true;\r\n    QTest::newRow(\"Subtraction of multiple values of different bases\") << \"'h20 - 'b1010 - 'o12 - 2\" << \"10\" << true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_SystemVerilogExpressionParser::testParseMultiply()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_SystemVerilogExpressionParser::testParseMultiply()\r\n{\r\n    testInputs();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_SystemVerilogExpressionParser::testParseMultiply_data()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_SystemVerilogExpressionParser::testParseMultiply_data()\r\n{\r\n    QTest::addColumn<QString>(\"expression\");\r\n    QTest::addColumn<QString>(\"expectedResult\");\r\n    QTest::addColumn<bool>(\"expectedValid\");\r\n\r\n    QTest::newRow(\"Zero times zero equals zero\") << \"0*0\" << \"0\" << true;\r\n    QTest::newRow(\"Zero times constant equals zero\") << \"0*1\" << \"0\" << true;\r\n    QTest::newRow(\"Constant times zero equals zero\") << \"1*0\" << \"0\" << true;\r\n\r\n    //! Arrays.\r\n    QTest::newRow(\"Multiplication of arrays is unknown\") << \"{1,1}*{1,1}\" << \"x\" << false;\r\n    QTest::newRow(\"Two times two inside array is four\") << \"{2*2,2*2}\" << \"{4,4}\" << true;\r\n    QTest::newRow(\"Constant multiplied with an array is unknown\") << \"{1,1} * 1\" << \"x\" << false;\r\n\r\n    //! Decimal numbers.\r\n    QTest::newRow(\"One times constant equals constant\") << \"1*2\" << \"2\" << true;\r\n    QTest::newRow(\"Two times two equals four\") << \"2*2\" << \"4\" << true;\r\n    QTest::newRow(\"Two times three with whitespaces equals six\") << \"2 * 3\" << \"6\" << true;\r\n    QTest::newRow(\"Multiple whitespaces\") << \" 4  *     4 \" << \"16\" << true;\r\n    QTest::newRow(\"Multiply of decimal values with sizes and signs\") << \"8'sd9 * 8'sd2\" << \"18\" << true;\r\n\r\n    QTest::newRow(\"Negative constant times negative constant gives positive value\") << \"-2*-2\" << \"4\" << true;\r\n    QTest::newRow(\"Negative constant times positive constant gives negative value\") << \"-2*2\" << \"-4\" << true;\r\n    QTest::newRow(\"Positive constant times negative constant gives negative value\") << \"2*-2\" << \"-4\" << true;\r\n\r\n    //! Fixed-point numbers.\r\n    QTest::newRow(\"Two times one half equals one\") << \"2*0.5\" << \"1.0\" << true;\r\n    QTest::newRow(\"Multiple fraction digits\") << \"0.240*0.21\" << \"0.050\" << true;\r\n    QTest::newRow(\"Zero times anything is zero\") << \"0.0*42\" << \"0.0\" << true;\r\n    QTest::newRow(\"Large real multiplication 10000.1 * 20002\") << \"10000.1 * 20002\" << \"200022000.2\" << true;\r\n\r\n    //! Hexadecimal numbers.\r\n    QTest::newRow(\"Multiply of hexadecimal 'h10 * 'h2 equals 32\") << \"'h10 * 'h2\" << \"32\" << true;\r\n    QTest::newRow(\"Multiply of hexadecimal 'hA * 'h3 equals 30\") << \"'hA * 'h3\" << \"30\" << true;\r\n    QTest::newRow(\"Multiply of hexadecimal values with sizes and signs\") << \"8'sh0A * 8'sh05\" << \"50\" << true;\r\n    \r\n    //! Binary numbers.\r\n    QTest::newRow(\"Multiply of binary 'b100 * 'b010 equals 8\") << \"'b100 * 'b010\" << \"8\" << true;\r\n    QTest::newRow(\"Multiply of binary 'b0111 * 'b001 equals 7\") << \"'b0111 * 'b001\" << \"7\" << true;\r\n    QTest::newRow(\"Multiply of binary values with sizes and signs\") << \"4'sb0010 * 4'sb0011\" << \"6\" << true;\r\n    \r\n    //! Octal numbers.\r\n    QTest::newRow(\"Multiply of octal 'o3 * 'o7 equals 21\") << \"'o3 * 'o7\" << \"21\" << true;\r\n    QTest::newRow(\"Multiply of octal 'o7 * 'o10 equals 56\") << \"'o7 * 'o10\" << \"56\" << true;\r\n    QTest::newRow(\"Multiply of octal values with sizes and signs\") << \"6'so6 * 6'so3\" << \"18\" << true;\r\n\r\n    QTest::newRow(\"Multiply of multiple values of same base\") << \"'h2 * 'h8 * 'h01\" << \"16\" << true;\r\n    QTest::newRow(\"Multiply of multiple values of different bases\") << \"'h04 * 'b0100 * 'o2 * 2\" << \"64\" << true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_SystemVerilogExpressionParser::testParseDivision()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_SystemVerilogExpressionParser::testParseDivision()\r\n{\r\n    testInputs();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_SystemVerilogExpressionParser::testParseDivision_data()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_SystemVerilogExpressionParser::testParseDivision_data()\r\n{\r\n    QTest::addColumn<QString>(\"expression\");\r\n    QTest::addColumn<QString>(\"expectedResult\");\r\n    QTest::addColumn<bool>(\"expectedValid\");\r\n\r\n    QTest::newRow(\"Constant divided by same constant equals one\") << \"2/2\" << \"1\" << true;\r\n    QTest::newRow(\"Constant divided by one equals the same constant\") << \"2/1\" << \"2\" << true;\r\n    QTest::newRow(\"Constant divided by zero equals x\") << \"1/0\" << \"x\" << false;\r\n\r\n    //! Arrays.\r\n    QTest::newRow(\"Division of arrays evaluates to unknown\") << \"{1,1}/{1,1}\" << \"x\" << false;\r\n    QTest::newRow(\"Ten divided by two inside array is five\") << \"{10/2,1,1}\" << \"{5,1,1}\" << true;\r\n    QTest::newRow(\"Constant divided by an array is unknown\") << \"1 / {1,1}\" << \"x\" << false;\r\n    QTest::newRow(\"An array divided by a constant is unknown\") << \"{1,1} / 1\" << \"x\" << false;\r\n\r\n    //! Decimal numbers.\r\n    QTest::newRow(\"Division result for integer truncates towards zero\") << \"3/2\" << \"1\" << true;\r\n\r\n    QTest::newRow(\"Four divided by two equals two\") << \"4/2\" << \"2\" << true;\r\n    QTest::newRow(\"Ten divided by two equals five\") << \"10/2\" << \"5\" << true;\r\n    QTest::newRow(\"Division with whitespaces\") << \"7 / 3\" << \"2\" << true;\r\n    QTest::newRow(\"Division with multiple whitespaces\") << \" 4   /  2 \" << \"2\" << true;\r\n    QTest::newRow(\"Division of decimal values with sizes and signs\") << \"8'sd9 / 8'sd3\" << \"3\" << true;\r\n\r\n    QTest::newRow(\"Negative constant divided by negative constant gives positive value\") << \"-2/-2\" << \"1\" << true;\r\n    QTest::newRow(\"Negative constant divided by positive constant gives negative value\") << \"-2/2\" << \"-1\" << true;\r\n    QTest::newRow(\"Positive constant divided by negative constant gives negative value\") << \"2/-2\" << \"-1\" << true;\r\n\r\n    //! Fixed-point numbers.\r\n    QTest::newRow(\"Division result for integer divisor truncates towards zero\") << \"3/2.0\" << \"1\" << true;\r\n    QTest::newRow(\"Division result for real does not truncate towards zero\") << \"3.0/2\" << \"1.5\" << true;\r\n    QTest::newRow(\"Number of fractional digits is five by default\") << \"10.0/3\" << \"3.3\" << true;\r\n    QTest::newRow(\"Division by zero is unknown\") << \"3.0/0.0\" << \"x\" << false;\r\n    QTest::newRow(\"Large real division 10000.1 / 20002\") << \"10000.1 / 20002\" << \"0.5\" << true;\r\n    QTest::newRow(\"Real division 1 / 7 \") << \"1 / 7\" << \"0\" << true;\r\n    QTest::newRow(\"Real division 1.0 / 7 \") << \"1.0 / 7\" << \"0.1\" << true;\r\n    QTest::newRow(\"Real division 1.00 / 7 \") << \"1.00 / 7\" << \"0.14\" << true;\r\n    QTest::newRow(\"Real division 1.000 / 7 \") << \"1.000 / 7\" << \"0.143\" << true;\r\n    QTest::newRow(\"Real division 1.0000 / 7 \") << \"1.0000 / 7\" << \"0.1429\" << true;\r\n\r\n    //! Hexadecimal numbers.\r\n    QTest::newRow(\"Division of hexadecimal 'h10 / 'h2 equals 8\") << \"'h10 / 'h2\" << \"8\" << true;\r\n    QTest::newRow(\"Division of hexadecimal 'hA / 'h3 equals 3\") << \"'hA / 'h3\" << \"3\" << true;\r\n    QTest::newRow(\"Division of hexadecimal values with sizes and signs\") << \"8'sh0A / 8'sh05\" << \"2\" << true;\r\n\r\n    //! Binary numbers.\r\n    QTest::newRow(\"Division of binary 'b100 / 'b010 equals 2\") << \"'b100 / 'b010\" << \"2\" << true;\r\n    QTest::newRow(\"Division of binary 'b0111 / 'b010 equals 3\") << \"'b0111 / 'b010\" << \"3\" << true;\r\n    QTest::newRow(\"Division of binary values with sizes and signs\") << \"4'sb1000 / 4'sb0010\" << \"4\" << true;\r\n\r\n    //! Octal numbers.\r\n    QTest::newRow(\"Division of octal 'o10 / 'o2 equals 4\") << \"'o10 /'o2\" << \"4\" << true;\r\n    QTest::newRow(\"Division of octal 'o20 / 'o4 equals 4\") << \"'o20 / 'o4\" << \"4\" << true;\r\n    QTest::newRow(\"Division of octal values with sizes and signs\") << \"6'so6 / 6'so3\" << \"2\" << true;\r\n\r\n    QTest::newRow(\"Divide multiple values of same base\") << \"'h20 / 'h02 / 'h08\" << \"2\" << true;\r\n    QTest::newRow(\"Divide multiple values of different bases\") << \"'h40 / 'b0010 / 'o2 / 2\" << \"8\" << true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_SystemVerilogExpressionParser::testParsePower()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_SystemVerilogExpressionParser::testParsePower()\r\n{\r\n    testInputs();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_SystemVerilogExpressionParser::testParsePower_data()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_SystemVerilogExpressionParser::testParsePower_data()\r\n{\r\n    QTest::addColumn<QString>(\"expression\");\r\n    QTest::addColumn<QString>(\"expectedResult\");\r\n    QTest::addColumn<bool>(\"expectedValid\");\r\n\r\n    //! Arrays.\r\n    QTest::newRow(\"Array to the power of an array is unknown\") << \"{1,1}**{1,1}\" << \"x\" << false;\r\n    QTest::newRow(\"Two to the power of three is eight inside an array\") << \"{1,2**3,1}\" << \"{1,8,1}\" << true;\r\n    QTest::newRow(\"Constant to the power of an array is unknown\") << \"1**{1,1}\" << \"x\" << false;\r\n    QTest::newRow(\"An array to the power of a constant is unknown\") << \"{1,1} ** 1\" << \"x\" << false;\r\n\r\n    //! Decimal numbers.\r\n    QTest::newRow(\"One to the power of zero equals one\") << \"1**0\" << \"1\" << true;\r\n    QTest::newRow(\"Zero to the power of zero equals one\") << \"0**0\" << \"1\" << true;\r\n    QTest::newRow(\"Anything to the power of zero equals one\") << \"42**0\" << \"1\" << true;\r\n\r\n    QTest::newRow(\"Zero to the power of a negative value is unknown\") << \"0**-2\" << \"x\" << false;\r\n\r\n    QTest::newRow(\"One to the power of anything equals one\") << \"1**42\" << \"1\" << true;\r\n\r\n    QTest::newRow(\"Negative one to the power of an even value equals one\") << \"-1**2\" << \"1\" << true;\r\n    QTest::newRow(\"Negative one to the power of an odd value equals negative one\") << \"-1**1\" << \"-1\" << true;\r\n\r\n    QTest::newRow(\"Negative one to the power of an even negative value equals one\") << \"-1**-2\" << \"1\" << true;\r\n    QTest::newRow(\"Negative one to the power of an odd negative value equals negative one\") << \"-1**-1\" << \"-1\" << true;\r\n    \r\n    QTest::newRow(\"Integer truncates to zero\") << \"2 ** -1\" << \"0\" << true;\r\n\r\n    QTest::newRow(\"Two to the power of two equals four\") << \"2**2\" << \"4\" << true;\r\n    QTest::newRow(\"Negative Two to the power of two equals four\") << \"-2**2\" << \"4\" << true;\r\n    QTest::newRow(\"Two to the power of three equals eight\") << \"2**3\" << \"8\" << true;\r\n    QTest::newRow(\"Negative two to the power of three equals negative eight\") << \"-2**3\" << \"-8\" << true;\r\n    QTest::newRow(\"Two to the power of five equals 32\") << \"2**5\" << \"32\" << true;\r\n    QTest::newRow(\"Three to the power of three equals 27\") << \"3**3\" << \"27\" << true;\r\n    QTest::newRow(\"Power operation with whitespaces\") << \"4 ** 3\" << \"64\" << true;\r\n\r\n    QTest::newRow(\"Multiple power operations\") << \"2**2**2\" << \"16\" << true;\r\n    QTest::newRow(\"Power of multiple different bases\") << \"'h02 ** 'b0010 ** 'o2 ** 2\" << \"256\" << true;\r\n\r\n    //! Fixed-point numbers.\r\n    QTest::newRow(\"Real gives real reciprocal\") << \"2.0 ** -1\" << \"0.5\" << true;\r\n    QTest::newRow(\"2.5 to the power of two\") << \"2.50 ** 2\" << \"6.25\" << true;\r\n    QTest::newRow(\"Large real in power 10000.1 ** 2\") << \"10000.1 ** 2\" << \"100002000.0\" << true;\r\n    QTest::newRow(\"Large real in larger power 10000.1**3\") << \"10000.1**3\" << \"1000030000300.0\" << true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_SystemVerilogExpressionParser::testClog2Function()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_SystemVerilogExpressionParser::testClog2Function()\r\n{\r\n    QFETCH(QString, expression);\r\n    QFETCH(QString, expectedResult);\r\n\r\n    SystemVerilogExpressionParser parser;\r\n    QCOMPARE(parser.parseExpression(expression), expectedResult);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_SystemVerilogExpressionParser::testClog2Function_data()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_SystemVerilogExpressionParser::testClog2Function_data()\r\n{\r\n    QTest::addColumn<QString>(\"expression\");\r\n    QTest::addColumn<QString>(\"expectedResult\");\r\n\r\n    QTest::newRow(\"$clog(0) equals 0\") << \"$clog2(0)\" << \"0\";\r\n    QTest::newRow(\"$clog(1) equals 0\") << \"$clog2(1)\" << \"0\";\r\n    QTest::newRow(\"$clog(2) equals 1\") << \"$clog2(2)\" << \"1\";\r\n    QTest::newRow(\"$clog(3) equals 2\") << \"$clog2(3)\" << \"2\";\r\n    QTest::newRow(\"$clog(127) equals 7\") << \"$clog2(127)\" << \"7\";\r\n    QTest::newRow(\"$clog(128) equals 7\") << \"$clog2(128)\" << \"7\";\r\n    QTest::newRow(\"$clog(129) equals 8\") << \"$clog2(129)\" << \"8\";\r\n    QTest::newRow(\"$clog(2048) equals 11\") << \"$clog2(2048)\" << \"11\";\r\n\r\n    QTest::newRow(\"$clog() for negative value is undefined\") << \"$clog2(-1)\" << \"x\";\r\n\r\n    QTest::newRow(\"$clog('h0F) for hexadecimal value equals 4\") << \"$clog2('h0F)\" << \"4\";\r\n    QTest::newRow(\"$clog('hFF) for hexadecimal value equals 8\") << \"$clog2('hFF)\" << \"8\";\r\n\r\n    QTest::newRow(\"Multiple clog2-functions\") << \"$clog2(2) + $clog2(4) + $clog2(4)\" << \"5\";\r\n\r\n    QTest::newRow(\"Simple expression as argument\") << \"$clog2(2 + 2)\" << \"2\";\r\n    QTest::newRow(\"Expression as argument\") << \"$clog2(2**12)\" << \"12\";\r\n\r\n    QTest::newRow(\"Nested clog2s\") << \"$clog2($clog2(256))\" << \"3\";\r\n    //! Arrays.\r\n    QTest::newRow(\"$clog(3) inside an array equals 2\") << \"{$clog2(3),1,1,1}\" << \"{2,1,1,1}\";\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_SystemVerilogExpressionParser::testParseMultipleOperations()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_SystemVerilogExpressionParser::testParseMultipleOperations()\r\n{\r\n    QFETCH(QString, expression);\r\n    QFETCH(QString, expectedResult);\r\n\r\n    SystemVerilogExpressionParser parser;\r\n    QCOMPARE(parser.parseExpression(expression), expectedResult);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_SystemVerilogExpressionParser::testParseMultipleOperations_data()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_SystemVerilogExpressionParser::testParseMultipleOperations_data()\r\n{\r\n    QTest::addColumn<QString>(\"expression\");\r\n    QTest::addColumn<QString>(\"expectedResult\");\r\n\r\n    QTest::newRow(\"Additions followed by a subtraction\") << \"1 + 1 + 1 - 2\" << \"1\";\r\n    QTest::newRow(\"Addition and subtraction mixed\") << \"1 + 2 - 3 + 4 - 5\" << \"-1\";\r\n    QTest::newRow(\"Addition and subtraction for different bases\") << \"'h0F - 'b11 - 'o2 + 1\" << \"11\";\r\n\r\n    QTest::newRow(\"Multiply precedes addition\") << \"1 + 2*3\" << \"7\";\r\n    QTest::newRow(\"Multiply precedes subtraction\") << \"8 - 2*3\" << \"2\";\r\n    QTest::newRow(\"Multiply, addition and subtraction mixed\") << \"7 + 2*4*1 - 2*1 - 5*2\" << \"3\";\r\n\r\n    QTest::newRow(\"Division precedes addition\") << \"1 + 4/2\" << \"3\";\r\n    QTest::newRow(\"Division precedes subtraction\") << \"8 - 6/2\" << \"5\";\r\n    QTest::newRow(\"Division, addition and subtraction mixed\") << \"8 + 8/2 - 4/2 - 3/2\" << \"9\";\r\n\r\n    QTest::newRow(\"Division and multiplication evaluated from left to right\") << \"6/2*4*3/1\" << \"36\";\r\n    QTest::newRow(\"Division, multiplication, addition and subtraction mixed\") << \"8*2 - 4/2 + 4 - 3*2*2\" << \"6\";\r\n\r\n    QTest::newRow(\"Power precedes addition\") << \"1 + 2**3\" << \"9\";\r\n    QTest::newRow(\"Power precedes multiplication\") << \"4*2**3\" << \"32\";\r\n    QTest::newRow(\"Power precedes division\") << \"16/2**3\" << \"2\";\r\n\r\n    QTest::newRow(\"clog2() precedes power operation\") << \"2**$clog2(4) + 1\" << \"5\";\r\n\r\n    QTest::newRow(\"Value of clog2() preceds other operations\") << \"(2 + 2)*3*$clog2(4*2*2) + 2\" << \"50\";\r\n\r\n    QTest::newRow(\"Unary minus in expression\") << \"-$clog2(32)-($sqrt(25)-(-$pow(2,2)))\" << \"-14\";\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_SystemVerilogExpressionParser::testParseExpressionWithParathesis()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_SystemVerilogExpressionParser::testParseExpressionWithParathesis()\r\n{\r\n    testInputs();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_SystemVerilogExpressionParser::testParseExpressionWithParathesis_data()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_SystemVerilogExpressionParser::testParseExpressionWithParathesis_data()\r\n{\r\n    QTest::addColumn<QString>(\"expression\");\r\n    QTest::addColumn<QString>(\"expectedResult\");\r\n    QTest::addColumn<bool>(\"expectedValid\");\r\n\r\n    QTest::newRow(\"Empty parenthesis\") << \"()\" << \"\" << true;\r\n    QTest::newRow(\"Single constant in parenthesis\") << \"(1)\" << \"1\" << true;\r\n    QTest::newRow(\"Single operation in parenthesis\") << \"(1+1)\" << \"2\" << true;\r\n    QTest::newRow(\"Single operation and whitespace in parenthesis\") << \" ( 1 + 1 ) \" << \"2\" << true;\r\n\r\n    QTest::newRow(\"Addition in parenthesis precedes multiplication\") << \"(1 + 1)*4\" << \"8\" << true;\r\n    QTest::newRow(\"Subtraction in parenthesis precedes multiplication\") << \"(4 - 1)*3\" << \"9\" << true;\r\n    QTest::newRow(\"Multiplication in parenthesis precedes division\") << \"9/(3*3)\" << \"1\" << true;\r\n\r\n    QTest::newRow(\"Nested parentheses\") << \"2*(3*(1 + 1) - 5)\" << \"2\" << true;\r\n    QTest::newRow(\"Double parentheses\") << \"((1 + 3)*4)/2\" << \"8\" << true;\r\n    QTest::newRow(\"Double parentheses with whitespace\") << \"( (1 + 3)*4 ) /2\" << \"8\" << true;\r\n    QTest::newRow(\"Triple parentheses\") << \"(((1 + 3))*4)/2\" << \"8\" << true;\r\n    QTest::newRow(\"Deeply nested parentheses\") << \"((((2))))\" << \"2\" << true;\r\n    QTest::newRow(\"Deeply nested parentheses with whitespace\") << \" ( ((  (2 ) ))  ) \" << \"2\" << true;\r\n\r\n    QTest::newRow(\"Parallel parentheses\") << \"(1 + 1)*(1 + 1)\" << \"4\" << true;\r\n    QTest::newRow(\"Parallel and nested parentheses\") << \"(2 * (1 + 1))*(1 + 1)\" << \"8\" << true;\r\n    QTest::newRow(\"Multiple parallel parentheses\") << \"(1+1)*(1+1)*(1+1)*(1+1)*(1+1)\" << \"32\" << true;\r\n\r\n    QTest::newRow(\"Mismatched open parentheses\") << \"((1)\" << \"x\" << false;\r\n    QTest::newRow(\"Mismatched closed parentheses\") << \"(1))\" << \"x\" << false;\r\n    QTest::newRow(\"Parentheses wrong way\") << \")1(\" << \"x\" << false;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_SystemVerilogExpressionParser::testGetBaseForExpression()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_SystemVerilogExpressionParser::testGetBaseForExpression()\r\n{\r\n    QFETCH(QString, expression);\r\n    QFETCH(int, expectedBase);\r\n\r\n    SystemVerilogExpressionParser parser;\r\n    \r\n    QCOMPARE(parser.baseForExpression(expression), expectedBase);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_SystemVerilogExpressionParser::testGetBaseForExpression_data()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_SystemVerilogExpressionParser::testGetBaseForExpression_data()\r\n{\r\n    QTest::addColumn<QString>(\"expression\");\r\n    QTest::addColumn<int>(\"expectedBase\");\r\n\r\n    QTest::newRow(\"Decimal constant has base 10\") << \"1\" << 10;\r\n    QTest::newRow(\"Hexadecimal constant has base 16\") << \"'h1\" << 16;\r\n    QTest::newRow(\"Octal constant has base 8\") << \"'o1\" << 8;\r\n    QTest::newRow(\"Binary constant has base 2\") << \"'b1\" << 2;\r\n\r\n    QTest::newRow(\"String constant has base 0\") << \"\\\"text\\\"\" << 0;\r\n\r\n    QTest::newRow(\"Expression with binary values has base 2\") << \"'b1 + 'b1\" << 2;\r\n    QTest::newRow(\"Expression with hexadecimal values has base 2\") << \"'h0F + 'h01\" << 16;\r\n\r\n    QTest::newRow(\"Expression with binary and hexadecimal values has base 16\") << \"'b01 + 'h01\" << 16;\r\n    QTest::newRow(\"Expression with decimal and hexadecimal values has base 16\") << \"'h01 + 12\" << 16;\r\n    QTest::newRow(\"Expression with multiple bases values has the greatest base\") << \"'b01 + 'o1 + 'h01 + 'd1\" << 16;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_SystemVerilogExpressionParser::testIsPlainValue()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_SystemVerilogExpressionParser::testIsPlainValue()\r\n{\r\n    QFETCH(QString, expression);\r\n    QFETCH(bool, expectedPlain);\r\n\r\n    SystemVerilogExpressionParser parser;\r\n\r\n    QCOMPARE(parser.isPlainValue(expression), expectedPlain);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_SystemVerilogExpressionParser::testIsPlainValue_data()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_SystemVerilogExpressionParser::testIsPlainValue_data()\r\n{\r\n    QTest::addColumn<QString>(\"expression\");\r\n    QTest::addColumn<bool>(\"expectedPlain\");\r\n\r\n    QTest::newRow(\"Decimal constant is plain\") << \"1\" << true;\r\n    QTest::newRow(\"Hexadecimal constant is plain\") << \"'h1\" << true;\r\n    QTest::newRow(\"Octal constant is plain\") << \"'o1\" << true;\r\n    QTest::newRow(\"Binary constant is plain\") << \"'b1\" << true;\r\n    QTest::newRow(\"String is plain\") << \"\\\"text\\\"\" << true;\r\n    QTest::newRow(\"Empty value is plain\") << \"\" << true;\r\n    QTest::newRow(\"Decimal with preceding and trailing spaces is plain\") << \"  1  \" << true;\r\n\r\n    QTest::newRow(\"Addition is not plain\") << \"'h1 + 'h1\" << false;\r\n    QTest::newRow(\"Subtraction is not plain\") << \"'o2 - 'o1\" << false;\r\n    QTest::newRow(\"Multiply is not plain\") << \"2 * 2\" << false;\r\n    QTest::newRow(\"Division is not plain\") << \"4/2\" << false;\r\n    QTest::newRow(\"Power is not plain\") << \"2**8\" << false;\r\n    QTest::newRow(\"clog2 function is not plain\") << \"$clog2(8)\" << false;\r\n\r\n    QTest::newRow(\"Addition in parentheses is not plain\") << \"(8 + 2)\" << false;\r\n\r\n    QTest::newRow(\"Large negative number is plain\") << \"-99999\" << true;\r\n    QTest::newRow(\"Even larger negative number is plain\") << \"-99999999999999\" << true;\r\n    QTest::newRow(\"Even larger negative number is plain\") << \"-999999999999999999\" << true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_SystemVerilogExpressionParser::testStringValues()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_SystemVerilogExpressionParser::testStringValues()\r\n{\r\n    testInputs();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_SystemVerilogExpressionParser::testStringValues_data()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_SystemVerilogExpressionParser::testStringValues_data()\r\n{\r\n    QTest::addColumn<QString>(\"expression\");\r\n    QTest::addColumn<QString>(\"expectedResult\");\r\n    QTest::addColumn<bool>(\"expectedValid\");\r\n\r\n    QTest::newRow(\"Empty string literal\") << \"\\\"\\\"\" << \"\\\"\\\"\" << true;\r\n    QTest::newRow(\"Non-empty string value is parsed as is.\") << \"\\\"A string.\\\"\" << \"\\\"A string.\\\"\" << true;\r\n    QTest::newRow(\"Non-empty string literal with whitespace\") << \"\\\" text \\\"\" << \"\\\" text \\\"\" << true;;\r\n\r\n    QTest::newRow(\"String missing a double quote is unknown\") << \"\\\"text\" << \"x\" << false;\r\n\r\n    QTest::newRow(\"String comparison for equal strings\") << \"\\\"string1\\\"==\\\"string1\\\"\" << \"1\" << true;\r\n    QTest::newRow(\"String comparison for not equal strings\") << \"\\\"string1\\\"==\\\"string2\\\"\" << \"0\" << true;\r\n    QTest::newRow(\"String not equal comparison for equal strings\") << \"\\\"string1\\\"!=\\\"string1\\\"\" << \"0\" << true;\r\n    QTest::newRow(\"String not equal comparison for not equal strings\") << \"\\\"string1\\\"!=\\\"string2\\\"\" << \"1\" << true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_SystemVerilogExpressionParser::testParseComparison()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_SystemVerilogExpressionParser::testParseComparison()\r\n{\r\n    QFETCH(QString, expression);\r\n    QFETCH(int, expectedResult);\r\n\r\n    SystemVerilogExpressionParser parser;\r\n\r\n    QString parserResult = parser.parseExpression(expression);\r\n\r\n    QCOMPARE(parserResult.toInt(), expectedResult);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_SystemVerilogExpressionParser::testParseComparison_data()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_SystemVerilogExpressionParser::testParseComparison_data()\r\n{\r\n    QTest::addColumn<QString>(\"expression\");\r\n    QTest::addColumn<int>(\"expectedResult\");\r\n\r\n    QTest::newRow(\"Single value: 10 is greater than 2 returns 1\") << \"10 > 2\" << 1;\r\n    QTest::newRow(\"Single value: 2 is greater than 10 returns 0\") << \"2 > 10\" << 0;\r\n    QTest::newRow(\"Single value: 10 is lesser than 2 returns 0\") << \"10 < 2\" << 0;\r\n    QTest::newRow(\"Single value: 2 is lesser than 10 returns 1\") << \"2 < 10\" << 1;\r\n\r\n    QTest::newRow(\"5 is greater than 5 returns 0\") << \"5>5\" << 0;\r\n    QTest::newRow(\"5 is lesser than 5 returns 0\") << \"5<5\" << 0;\r\n\r\n    QTest::newRow(\"Expression: 14*2 is greater than 2-3*2+8 returns 1\") << \"14*2 > 2-3*2+8\" << 1;\r\n    QTest::newRow(\"Expression: 2-3*2+8 is greater than 14*2 returns 0\") << \"2 > 10\" << 0;\r\n    QTest::newRow(\"Expression: 14*2 is lesser than 2-3*2+8 returns 0\") << \"10 < 2\" << 0;\r\n    QTest::newRow(\"Expression: 2-3*2+8 is lesser than 14*2 returns 1\") << \"2 < 10\" << 1;\r\n\r\n    QTest::newRow(\"Single value: 10 is equal to 10 returns 1\") << \"21==21\" << 1;\r\n    QTest::newRow(\"Single value: 10 is equal to 2 returns 0\") << \"10==2\" << 0;\r\n    QTest::newRow(\"Single value: 10 is equal to 2 returns 0\") << \"1==(8==8)\" << 1;\r\n\r\n    QTest::newRow(\"Expression: 14-2*2 is equal to 2*5 returns 1\") << \"14-2*2 == 2*5\" << 1;\r\n    QTest::newRow(\"Expression: 14-2*2+1 is equal to 2*5 returns 0\") << \"14-2*2+1 == 2*5\" << 0;\r\n\r\n    QTest::newRow(\"Single value: 10 is greater or equal than 2 returns 1\") << \"10>=2\" << 1;\r\n    QTest::newRow(\"Single value: 10 is greater or equal than 10 returns 1\") << \"10>=10\" << 1;\r\n    QTest::newRow(\"Single value: 10 is greater or equal than 11 returns 0\") << \"10>=11\" << 0;\r\n\r\n    QTest::newRow(\"Expression: 10/2 is greater or equal than 2+1-2 returns 1\") << \"10/2>=2+1-2\" << 1;\r\n    QTest::newRow(\"Expression: 10/2 is greater or equal than 2*3-1 returns 1\") << \"10/2>=2*3-1\" << 1;\r\n    QTest::newRow(\"Expression: 10/2 is greater or equal than 11+1*10 returns 0\") << \"10/2>=11+1*10\" << 0;\r\n\r\n    QTest::newRow(\"Single value: 2 is lesser or equal than 10 returns 1\") << \"2<=10\" << 1;\r\n    QTest::newRow(\"Single value: 10 is lesser or equal than 10 returns 1\") << \"10<=10\" << 1;\r\n    QTest::newRow(\"Single value: 11 is lesser or equal than 10 returns 0\") << \"11<=10\" << 0;\r\n\r\n    QTest::newRow(\"Expression: 2+1-2 is lesser or equal than 10/2 returns 1\") << \"2+1-2<=10/2\" << 1;\r\n    QTest::newRow(\"Expression: 2*3-1 is lesser or equal than 10/2 returns 1\") << \"2*3-1<=10/2\" << 1;\r\n    QTest::newRow(\"Expression: 11+1*10 is lesser or equal than 10/2 returns 0\") << \"11+1*10<=10/2\" << 0;\r\n\r\n    QTest::newRow(\"Single value: 2 is not equal to 10 returns 1\") << \"2!=10\" << 1;\r\n    QTest::newRow(\"Single value: 10 is not equal to 10 returns 0\") << \"10!=10\" << 0;\r\n\r\n    QTest::newRow(\"Expression: 2+1-2 is not equal to 10/2 returns 1\") << \"2+1-2!=10/2\" << 1;\r\n    QTest::newRow(\"Expression: 2*3-1 is not equal to 10/2 returns 0\") << \"2*3-1!=10/2\" << 0;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_SystemVerilogExpressionParser::testParseMathFunctions()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_SystemVerilogExpressionParser::testParseMathFunctions()\r\n{\r\n    testInputs();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_SystemVerilogExpressionParser::testParseMathFunctions_data()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_SystemVerilogExpressionParser::testParseMathFunctions_data()\r\n{\r\n    QTest::addColumn<QString>(\"expression\");\r\n    QTest::addColumn<QString>(\"expectedResult\");\r\n    QTest::addColumn<bool>(\"expectedValid\");\r\n\r\n    QTest::newRow(\"System function $clog2(), ceil of log2\") << \"$clog2(17)\" << \"5\" << true;\r\n\r\n    QTest::newRow(\"Simple power function\") << \"$pow(2, 3)\" << \"8\" << true;\r\n\r\n    QTest::newRow(\"Square root of 0 is 0\") << \"$sqrt(0)\" << \"0\" << true;\r\n    QTest::newRow(\"Square root of 4 equals 2\") << \"$sqrt(4)\" << \"2\" << true;\r\n    QTest::newRow(\"Square root of negative value is invalid\") << \"$sqrt(-2)\" << \"x\" << false;\r\n\r\n    QTest::newRow(\"Exp() of 0 is 1\") << \"$exp(0)\" << \"1\" << true;\r\n    QTest::newRow(\"Exp() of 1\") << \"$exp(1)\" << QString::number(qExp(1)) << true;\r\n    QTest::newRow(\"Exp() of -2\") << \"$exp(-2)\" << QString::number(qExp(-2)) << true;\r\n}   \r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_SystemVerilogExpressionParser::testBitwiseOperations()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_SystemVerilogExpressionParser::testBitwiseOperations()\r\n{\r\n    testInputs();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_SystemVerilogExpressionParser::testBitwiseOperations_data()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_SystemVerilogExpressionParser::testBitwiseOperations_data()\r\n{\r\n    QTest::addColumn<QString>(\"expression\");\r\n    QTest::addColumn<QString>(\"expectedResult\");\r\n    QTest::addColumn<bool>(\"expectedValid\");\r\n\r\n\r\n    QTest::newRow(\"Negation\") << \"~4'b001\" << \"-2\" << true;\r\n    QTest::newRow(\"Shift left\") << \"4'b0010 << 2\" << \"8\" << true;\r\n    QTest::newRow(\"Shift right\") << \"4'b1000 >> 3\" << \"1\" << true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_SystemVerilogExpressionParser::testTernaryOperations()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_SystemVerilogExpressionParser::testTernaryOperations()\r\n{\r\n    testInputs();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_SystemVerilogExpressionParser::testTernaryOperations_data()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_SystemVerilogExpressionParser::testTernaryOperations_data()\r\n{\r\n    QTest::addColumn<QString>(\"expression\");\r\n    QTest::addColumn<QString>(\"expectedResult\");\r\n    QTest::addColumn<bool>(\"expectedValid\");\r\n\r\n    QTest::newRow(\"Ternary true?1:0 should be 1\") << \"true?1:0\" << \"1\" << true;\r\n    QTest::newRow(\"Ternary false?1:0 should be 0\") << \"false?1:0\" << \"0\" << true;\r\n    QTest::newRow(\"Ternary 1?2:3 should be 2\") << \"1?2:3\" << \"2\" << true;\r\n    QTest::newRow(\"Ternary 1-1?2:3+1 should be 4\") << \"1-1?2:3+1\" << \"4\" << true;\r\n    QTest::newRow(\"Ternary ? should invalid\") << \"?\" << \"0\" << false;\r\n    QTest::newRow(\"Ternary : should invalid\") << \":\" << \"0\" << false;\r\n    QTest::newRow(\"Ternary (3+2)?(4+6) should invalid\") << \"(3+2)?(4+6)\" << \"0\" << false;\r\n    QTest::newRow(\"Ternary (3+2):(4+6) should invalid\") << \"(3+2):(4+6)\" << \"0\" << false;\r\n    QTest::newRow(\"Ternary (3+2)?((3+3)?(4+7):1):0 should be 11\") << \"(3+2)?((3+3)?(4+7):1):0\" << \"11\" << true;\r\n    QTest::newRow(\"Ternary (1>2)?((3+3)?(4+7):1):0 should be 0\") << \"(1>2)?((3+3)?(4+7):1):0\" << \"0\" << true;\r\n    QTest::newRow(\"Ternary 3+2?3+3?4+7:1:0 should be 11\") << \"3+2?3+3?4+7:1:0\" << \"11\" << true;\r\n    QTest::newRow(\"Ternary 1>2?3+3?4+7:1:0 should be 0\") << \"1>2?3+3?4+7:1:0\" << \"0\" << true;\r\n    QTest::newRow(\"Ternary 1?11:2?12:0 should be 11\") << \"1?11:2?12:0\" << \"11\" << true;\r\n    QTest::newRow(\"Ternary 1?11:(2?12:0) should be 11\") << \"1?11:(2?12:0)\" << \"11\" << true;\r\n    QTest::newRow(\"Ternary 1?12?1:0:22 should be 1\") << \"1?12?1:0:22\" << \"1\" << true;\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_SystemVerilogExpressionParser::testParserPerformance()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_SystemVerilogExpressionParser::testParserPerformance()\r\n{\r\n    QFETCH(QString, expression);\r\n    QFETCH(int, expectedResult);\r\n\r\n    SystemVerilogExpressionParser parser;\r\n\r\n    QString parserResult;\r\n\r\n    QBENCHMARK\r\n    {\r\n        parserResult = parser.parseExpression(expression);\r\n    }\r\n\r\n    QCOMPARE(parserResult.toInt(), expectedResult);\r\n    \r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_SystemVerilogExpressionParser::testParserPerformance_data()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_SystemVerilogExpressionParser::testParserPerformance_data()\r\n{\r\n    QTest::addColumn<QString>(\"expression\");\r\n    QTest::addColumn<int>(\"expectedResult\");\r\n\r\n    QTest::newRow(\"Constant value\") << \"'hFF\" << 255;\r\n    QTest::newRow(\"Basic operations\") << \"12*12 + 8/2 -8\" << 140;\r\n    QTest::newRow(\"clog2 operations\") << \"$clog2(256) - $clog2(8)\" << 5;\r\n    QTest::newRow(\"Nested clog2 operations\") << \"$clog2($clog2(256))\" << 3;\r\n    QTest::newRow(\"Sum of multiple values of different bases\") << \"'hA + 'b1010 + 'o12 + 10\" << 40;\r\n\r\n}\r\n\r\nQTEST_APPLESS_MAIN(tst_SystemVerilogExpressionParser)\r\n\r\n#include \"tst_SystemVerilogExpressionParser.moc\"\r\n"
  },
  {
    "path": "tests/Core/tst_SystemVerilogExpressionParser.pri",
    "content": "# ----------------------------------------------------\r\n# This file is generated by the Qt Visual Studio Add-in.\r\n# ------------------------------------------------------\r\n\r\nSOURCES += ./tst_SystemVerilogExpressionParser.cpp\r\n"
  },
  {
    "path": "tests/Core/tst_SystemVerilogExpressionParser.pro",
    "content": "#-----------------------------------------------------------------------------\r\n# File: tst_SystemVerilogExpressionParser.pro\r\n#-----------------------------------------------------------------------------\r\n# Project: Kactus 2\r\n# Author: Esko Pekkarinen\r\n# Date: 25.11.2014\r\n#\r\n# Description:\r\n# Qt project file template for running unit tests for SystemVerilogExpressionParser.\r\n#-----------------------------------------------------------------------------\r\n\r\nTEMPLATE = app\r\n\r\nTARGET = tst_SystemVerilogExpressionParser\r\n\r\nQT += core xml gui testlib\r\nCONFIG += c++11 testcase console\r\n\r\n\t\r\nwin32:CONFIG(release, debug|release) {\r\n    LIBS += -L$$PWD/../../executable/ -lKactusAPI\r\n    DESTDIR = ./release\r\n}\r\nelse:win32:CONFIG(debug, debug|release) {\r\n    LIBS += -L$$PWD/../../executable/ -lKactusAPId\r\n    DESTDIR = ./debug\r\n}\r\nelse:unix {\r\n    LIBS += -L$$PWD/../../executable/ -lKactusAPI\r\n    DESTDIR = ./release\r\n}\r\n\r\nINCLUDEPATH += $$DESTDIR\r\nINCLUDEPATH += ../../\r\nINCLUDEPATH += ../../KactusAPI/include/\r\n\r\nDEPENDPATH += .\r\nDEPENDPATH += ../../\r\n\r\nOBJECTS_DIR += $$DESTDIR\r\n\r\nMOC_DIR += ./generatedFiles\r\nUI_DIR += ./generatedFiles\r\nRCC_DIR += ./generatedFiles\r\ninclude(tst_SystemVerilogExpressionParser.pri)\r\n"
  },
  {
    "path": "tests/Core/tst_VLNVComparator.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: tst_VLNVComparator.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Esko Pekkarinen\r\n// Date: 17.10.2014\r\n//\r\n// Description:\r\n// Unit test for class VLNVComparator.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include <QtTest>\r\n\r\n#include <IPXACTmodels/common/VLNV.h>\r\n\r\n#include <wizards/common/VLNVComparator/VLNVComparator.h>\r\n#include <wizards/common/IPXactDiff.h>\r\n\r\n#include \"ComparatorTest.h\"\r\n\r\nclass tst_VLNVComparator : public QObject, public ComparatorTest\r\n{\r\n    Q_OBJECT\r\n\r\npublic:\r\n    tst_VLNVComparator();\r\n\r\nprivate slots:\r\n    void initTestCase();\r\n    void cleanupTestCase();\r\n\r\n    void testComparingTwoNullsAreEquivalent();\r\n    void testComparingToNullIsNotEquivalent();\r\n    void testComparingWithSelfIsEquivalent();\r\n    void testComparingDifferentVLNVsIsNotEqual();\r\n\r\n    void testDiffVLNVChanges();\r\n    \r\n    void testDiffVLNVChanges_data();\r\n    void testDiffVLNVMultipleChanges();\r\n    \r\n    void testDiffForAddingVLVNisAdd();\r\n    void testDiffForRemovingVLVNisRemove();\r\n    void testDiffForSelfIsNoChange();\r\n\r\nprivate:\r\n    \r\n    VLNVComparator* makeComparator();\r\n\r\n    VLNVComparator* comparator_;\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_VLNVComparator::tst_VLNVComparator()\r\n//-----------------------------------------------------------------------------\r\ntst_VLNVComparator::tst_VLNVComparator()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_VLNVComparator::initTestCase()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_VLNVComparator::initTestCase()\r\n{\r\n    comparator_ = makeComparator();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ComponentComparator::cleanupTestCase()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_VLNVComparator::cleanupTestCase()\r\n{\r\n    delete comparator_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_VLNVComparator::makeComparator()\r\n//-----------------------------------------------------------------------------\r\nVLNVComparator* tst_VLNVComparator::makeComparator()\r\n{\r\n    return new VLNVComparator;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_VLNVComparator::testComparingTwoNullsAreEquivalent()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_VLNVComparator::testComparingTwoNullsAreEquivalent()\r\n{\r\n    QVERIFY2(comparator_->compare(QSharedPointer<VLNV>(0), QSharedPointer<VLNV>(0)), \"Two nulls should be equal.\");\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_VLNVComparator::testComparingNullToComponentIsNotEquivalent()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_VLNVComparator::testComparingToNullIsNotEquivalent()\r\n{\r\n    QSharedPointer<VLNV> vlnv(new VLNV());\r\n\r\n    QVERIFY2(!comparator_->compare(QSharedPointer<VLNV>(0), vlnv), \"Comparison to null should not be equal.\");\r\n    QVERIFY2(!comparator_->compare(vlnv, QSharedPointer<VLNV>(0)), \"Comparison to null should not be equal.\");\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_VLNVComparator::testComparingWithSelfIsEquivalent()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_VLNVComparator::testComparingWithSelfIsEquivalent()\r\n{\r\n    QSharedPointer<VLNV> vlnv(new VLNV());\r\n    QVERIFY2(comparator_->compare(vlnv, vlnv), \"Comparing with self should be equal.\");\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_VLNVComparator::testComparingWithDifferentVLNVIsNotEqual()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_VLNVComparator::testComparingDifferentVLNVsIsNotEqual()\r\n{\r\n    QSharedPointer<VLNV> reference(new VLNV(VLNV::COMPONENT, \"TUT:Tests:TestComponent:1.0\"));   \r\n    QSharedPointer<VLNV> vlnv(new VLNV(VLNV::COMPONENT, \"Vendor:Library:Name:Version\"));   \r\n\r\n    QVERIFY2(!comparator_->compare(reference, vlnv), \"Different VLVNs should not be equal.\");\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_VLNVComparator::testDiffVLNVChanges()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_VLNVComparator::testDiffVLNVChanges()\r\n{\r\n    QFETCH(QString, vlnv);\r\n    QFETCH(QString, previousValue);\r\n\r\n    QSharedPointer<VLNV> reference(new VLNV(VLNV::COMPONENT, previousValue));   \r\n    QSharedPointer<VLNV> other(new VLNV(VLNV::COMPONENT, vlnv));   \r\n\r\n    QList<QSharedPointer<IPXactDiff> > diff = comparator_->diff(reference, other);\r\n\r\n    QCOMPARE(diff.count(), 1);\r\n    verifyDiffElementAndType(diff.first(), \"vlnv\", \"\", IPXactDiff::MODIFICATION);\r\n\r\n    QList<IPXactDiff::Modification> modifications = diff.first()->getChangeList();\r\n    QCOMPARE(modifications.count(), 1);\r\n    verifyModificationIs(modifications.first(), \"vlnv\" , previousValue, vlnv);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_VLNVComparator::testComparingWithDifferentVLNVIsNotEqual_data()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_VLNVComparator::testDiffVLNVChanges_data()\r\n{\r\n    QTest::addColumn<QString>(\"vlnv\");\r\n    QTest::addColumn<QString>(\"previousValue\");   \r\n\r\n    QTest::newRow(\"Different vendor\") << \"X:Tests:TestComponent:1.0\" << \"TUT:Tests:TestComponent:1.0\";\r\n    QTest::newRow(\"Different library\") << \"TUT:X:TestComponent:1.0\" << \"TUT:Tests:TestComponent:1.0\";\r\n    QTest::newRow(\"Different name\") << \"TUT:Tests:X:1.0\" << \"TUT:Tests:TestComponent:1.0\";\r\n    QTest::newRow(\"Different version\") << \"TUT:Tests:TestComponent:X\" << \"TUT:Tests:TestComponent:1.0\";\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_VLNVComparator::testDiffVLNVMultipleChanges()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_VLNVComparator::testDiffVLNVMultipleChanges()\r\n{\r\n    QSharedPointer<VLNV> reference(new VLNV(VLNV::COMPONENT, \"TUT:Tests:TestComponent:1.0\"));   \r\n    QSharedPointer<VLNV> other(new VLNV(VLNV::COMPONENT, \"X:Y:Z:1\"));   \r\n\r\n    QList<QSharedPointer<IPXactDiff> > diff = comparator_->diff(reference, other);\r\n\r\n    QCOMPARE(diff.count(), 1);\r\n    verifyDiffElementAndType(diff.first(), \"vlnv\", \"\", IPXactDiff::MODIFICATION);\r\n\r\n    QList<IPXactDiff::Modification> modifications = diff.first()->getChangeList();\r\n    QCOMPARE(modifications.count(), 1);\r\n\r\n    IPXactDiff::Modification change = modifications.at(0);\r\n    verifyModificationIs(change, \"vlnv\", \"TUT:Tests:TestComponent:1.0\", \"X:Y:Z:1\");\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_VLNVComparator::testDiffForAddingVLVNisAdd()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_VLNVComparator::testDiffForAddingVLVNisAdd()\r\n{\r\n    QSharedPointer<VLNV> reference(new VLNV());\r\n    QSharedPointer<VLNV> component(new VLNV(VLNV::COMPONENT, \"TUT:Tests:TestComponent:1.0\"));   \r\n\r\n    QList<QSharedPointer<IPXactDiff> > diff = comparator_->diff(reference, component);\r\n\r\n    QCOMPARE(diff.count(), 1);\r\n    verifyDiffElementAndType(diff.first(), \"vlnv\", \"\", IPXactDiff::ADD);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_VLNVComparator::testDiffForRemovingVLVNisRemove()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_VLNVComparator::testDiffForRemovingVLVNisRemove()\r\n{\r\n    QSharedPointer<VLNV> reference(new VLNV(VLNV::COMPONENT, \"TUT:Tests:TestComponent:1.0\"));   \r\n    QSharedPointer<VLNV> component(new VLNV());   \r\n\r\n    QList<QSharedPointer<IPXactDiff> > diff = comparator_->diff(reference, component);\r\n\r\n    QCOMPARE(diff.count(), 1);\r\n    verifyDiffElementAndType(diff.first(), \"vlnv\", \"\", IPXactDiff::REMOVE);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_VLNVComparator::testDiffForSelfIsNoChange()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_VLNVComparator::testDiffForSelfIsNoChange()\r\n{\r\n    QSharedPointer<VLNV> reference(new VLNV(VLNV::COMPONENT, \"TUT:Tests:TestComponent:1.0\"));   \r\n\r\n    QList<QSharedPointer<IPXactDiff> > diff = comparator_->diff(reference, reference);\r\n\r\n    QCOMPARE(diff.count(), 1);\r\n    verifyDiffElementAndType(diff.first(), \"vlnv\", \"\", IPXactDiff::NO_CHANGE);\r\n}\r\n\r\nQTEST_APPLESS_MAIN(tst_VLNVComparator)\r\n\r\n#include \"tst_VLNVComparator.moc\"\r\n    "
  },
  {
    "path": "tests/Core/tst_VLNVComparator.pri",
    "content": "# ----------------------------------------------------\r\n# This file is generated by the Qt Visual Studio Add-in.\r\n# ------------------------------------------------------\r\n\r\nHEADERS += ../../wizards/common/IPXactDiff.h \\\r\n    ../../wizards/common/IPXactElementComparator.h \\\r\n    ../../wizards/common/VLNVComparator/VLNVComparator.h \\\r\n    ./ComparatorTest.h\r\n\r\nSOURCES += ../../wizards/common/IPXactDiff.cpp \\\r\n    ../../wizards/common/VLNVComparator/VLNVComparator.cpp \\\r\n    ./tst_VLNVComparator.cpp \\\r\n    ./ComparatorTest.cpp\r\n"
  },
  {
    "path": "tests/Core/tst_VLNVComparator.pro",
    "content": "#-----------------------------------------------------------------------------\r\n# File: tst_VLNVComparator.pro\r\n#-----------------------------------------------------------------------------\r\n# Project: Kactus 2\r\n# Author: Esko Pekkarinen\r\n# Date: 17.10.2014\r\n#\r\n# Description:\r\n# Qt project file template for running unit tests for a VLNVComparator.\r\n#-----------------------------------------------------------------------------\r\n\r\nTEMPLATE = app\r\n\r\nTARGET = tst_VLNVComparator\r\n\r\nQT += core xml gui testlib\r\nCONFIG += c++11 testcase console\r\n\r\nwin32:CONFIG(release, debug|release) {\r\n    LIBS += -L$$PWD/../../executable/ -lIPXACTmodels\r\n    DESTDIR = ./release\r\n}\r\nelse:win32:CONFIG(debug, debug|release) {\r\n    LIBS += -L$$PWD/../../executable/ -lIPXACTmodelsd\r\n    DESTDIR = ./debug\r\n}\r\nelse:unix {\r\n    LIBS += -L$$PWD/../../executable/ -lIPXACTmodels\r\n    DESTDIR = ./release\r\n}\r\n\r\nINCLUDEPATH += $$PWD/../../\r\nINCLUDEPATH += $$PWD/../../executable\r\nINCLUDEPATH += $$PWD/../../executable/Plugins\r\nINCLUDEPATH += $$DESTDIR\r\n\r\nDEPENDPATH += $$PWD/../../\r\nDEPENDPATH += $$PWD/../../executable\r\nDEPENDPATH += $$PWD/../../executable/Plugins\r\n\r\nOBJECTS_DIR += $$DESTDIR\r\n\r\nMOC_DIR += ./generatedFiles\r\nUI_DIR += ./generatedFiles\r\nRCC_DIR += ./generatedFiles\r\ninclude(tst_VLNVComparator.pri)\r\n"
  },
  {
    "path": "tests/Core/tst_ValueFormatter.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: tst_ValueFormatter.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 05.03.2015\r\n//\r\n// Description:\r\n// Unit test for class ValueFormatter.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include <QtTest>\r\n\r\n#include <IPXACTmodels/common/validators/ValueFormatter.h>\r\n\r\nclass tst_ValueFormatter : public QObject\r\n{\r\n    Q_OBJECT\r\n\r\npublic:\r\n    tst_ValueFormatter();\r\n\r\nprivate slots:\r\n    void testFormatValue();\r\n    void testFormatValue_data();\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ValueFormatter::tst_ValueFormatter()\r\n//-----------------------------------------------------------------------------\r\ntst_ValueFormatter::tst_ValueFormatter()\r\n{\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ValueFormatter::testFormatValue()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ValueFormatter::testFormatValue()\r\n{\r\n    QFETCH(QString, value);\r\n    QFETCH(int, formatBase);\r\n    QFETCH(QString, expectedValue);\r\n\r\n    ValueFormatter formatter;\r\n    QCOMPARE(formatter.format(value, formatBase), expectedValue);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ValueFormatter::testFormatValue_data()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ValueFormatter::testFormatValue_data()\r\n{\r\n    QTest::addColumn<QString>(\"value\");\r\n    QTest::addColumn<int>(\"formatBase\");\r\n    QTest::addColumn<QString>(\"expectedValue\");\r\n\r\n    QTest::newRow(\"Base of two in value 10 is formatted to binary value 1010\") << \"10\" << 2 << \"'b1010\";\r\n    QTest::newRow(\"Base of two in array {10,16} is formatted to binary array {1010,10000}\") << \"{10,16}\" << 2 <<\r\n        \"{'b1010,'b10000}\";\r\n\r\n    QTest::newRow(\"Base of eight in value 10 is formatted to octal value 12\") << \"10\" << 8 << \"'o12\";\r\n    QTest::newRow(\"Base of eight in array {10,16} is formatted to octal array {12,20}\") << \"{10,16}\" << 8 <<\r\n        \"{'o12,'o20}\";\r\n\r\n    QTest::newRow(\"Base of ten in value 10 is formatted to decimal value 10\") << \"10\" << 10 << \"10\";\r\n    QTest::newRow(\"Base of ten in array {10,16} is formatted to decimal array {10,16}\") << \"{10,16}\" << 10 <<\r\n        \"{10,16}\";\r\n\r\n    QTest::newRow(\"Base of 16 in value 10 is formatted to hexadecimal value a\") << \"10\" << 16 << \"'ha\";\r\n    QTest::newRow(\"Base of 16 in array {10,16} is formatted to hexadecimal array {a,10}\") << \"{10,16}\" << 16 <<\r\n        \"{'ha,'h10}\";\r\n\r\n    QTest::newRow(\"Base of ten in array '{10,16} is formatted to decimal array {10,16}\") << \"'{10,16}\" << 10 <<\r\n        \"{10,16}\";\r\n}\r\n\r\nQTEST_APPLESS_MAIN(tst_ValueFormatter)\r\n\r\n#include \"tst_ValueFormatter.moc\"\r\n"
  },
  {
    "path": "tests/Core/tst_ValueFormatter.pri",
    "content": "# ----------------------------------------------------\r\n# This file is generated by the Qt Visual Studio Add-in.\r\n# ------------------------------------------------------\r\n\r\nHEADERS += ../../IPXACTmodels/common/validators/ValueFormatter.h\r\nSOURCES += ../../IPXACTmodels/common/validators/ValueFormatter.cpp \\\r\n    ./tst_ValueFormatter.cpp\r\n"
  },
  {
    "path": "tests/Core/tst_ValueFormatter.pro",
    "content": "#-----------------------------------------------------------------------------\r\n# File: tst_ValueFormatter.pro\r\n#-----------------------------------------------------------------------------\r\n# Project: Kactus 2\r\n# Author: Mikko Teuho\r\n# Date: 05.03.2015\r\n#\r\n# Description:\r\n# Qt project file template for running unit tests for ValueFormatter.\r\n#-----------------------------------------------------------------------------\r\n\r\nTEMPLATE = app\r\n\r\nTARGET = tst_ValueFormatter\r\n\r\nQT += core xml gui testlib\r\nCONFIG += c++11 testcase console\r\nDEFINES += IPXACTMODELS_LIB\r\n\r\nwin32:CONFIG(release, debug|release) {\r\n    DESTDIR = ./release\r\n}\r\nelse:win32:CONFIG(debug, debug|release) {\r\n    DESTDIR = ./debug\r\n}\r\nelse:unix {\r\n    DESTDIR = ./release\r\n}\r\n\r\nINCLUDEPATH += $$DESTDIR\r\nINCLUDEPATH += ../../\r\n\r\nDEPENDPATH += .\r\nDEPENDPATH += ../../\r\n\r\nOBJECTS_DIR += $$DESTDIR\r\n\r\nMOC_DIR += ./generatedFiles\r\nUI_DIR += ./generatedFiles\r\nRCC_DIR += ./generatedFiles\r\ninclude(tst_ValueFormatter.pri)\r\n"
  },
  {
    "path": "tests/Core/tst_ViewComparator.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: tst_ViewComparator.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Esko Pekkarinen\r\n// Date: 24.10.2014\r\n//\r\n// Description:\r\n// Unit test for class ViewComparator.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include <QtTest>\r\n\r\n#include <QSharedPointer>\r\n\r\n#include <IPXACTmodels/Component/Component.h>\r\n#include <IPXACTmodels/Component/Model.h>\r\n#include <IPXACTmodels/common/Parameter.h>\r\n#include <IPXACTmodels/common/VLNV.h>\r\n\r\n#include <wizards/common/ViewComparator/ViewComparator.h>\r\n#include <wizards/common/IPXactDiff.h>\r\n\r\n#include \"ComparatorTest.h\"\r\n\r\n\r\nclass tst_ViewComparator : public QObject, public ComparatorTest\r\n{\r\n    Q_OBJECT\r\n\r\npublic:\r\n    tst_ViewComparator();\r\n\r\nprivate slots:\r\n    void initTestCase();\r\n    void cleanupTestCase();\r\n\r\n    void testViewsNamesComparison();\r\n    void testViewsNamesComparison_data();\r\n    void testViewsEnvIdenrtifierComparison();\r\n    void testViewsEnvIdenrtifierComparison_data();\r\n\r\n    void testDiffEnvIdentifiers();\r\n\r\nprivate:\r\n    \r\n    ViewComparator* makeComparator();\r\n\r\n   \r\n    ViewComparator* comparator_;\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ViewComparator::tst_ViewComparator()\r\n//-----------------------------------------------------------------------------\r\ntst_ViewComparator::tst_ViewComparator()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ViewComparator::initTestCase()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ViewComparator::initTestCase()\r\n{\r\n    comparator_ = makeComparator();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ViewComparator::cleanupTestCase()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ViewComparator::cleanupTestCase()\r\n{\r\n    delete comparator_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ViewComparator::makeComparator()\r\n//-----------------------------------------------------------------------------\r\nViewComparator* tst_ViewComparator::makeComparator()\r\n{\r\n    return new ViewComparator;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ViewComparator::testViewsNamesComparison()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ViewComparator::testViewsNamesComparison()\r\n{    \r\n    QFETCH(QString, referenceValue);\r\n    QFETCH(QString, subjectValue);\r\n    QFETCH(bool, expectedComparison);\r\n\r\n    QSharedPointer<View> reference(new View(referenceValue));    \r\n\r\n    QSharedPointer<View> subject(new View(subjectValue));    \r\n\r\n    QVERIFY(comparator_->compare(reference, subject) == expectedComparison);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ViewComparator::testSimilarViewsIsEqual_data()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ViewComparator::testViewsNamesComparison_data()\r\n{\r\n    createTestInputsForStringValues();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ViewComparator::testViewsEnvIdenrtifierComparison(()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ViewComparator::testViewsEnvIdenrtifierComparison()\r\n{\r\n    QFETCH(QString, referenceValue);\r\n    QFETCH(QString, subjectValue);\r\n    QFETCH(bool, expectedComparison);\r\n\r\n    QSharedPointer<View> reference(new View());    \r\n    QSharedPointer<View::EnvironmentIdentifier> referenceIdentifier(\r\n        new View::EnvironmentIdentifier(referenceValue));\r\n    reference->addEnvIdentifier(referenceIdentifier);\r\n\r\n    QSharedPointer<View> subject(new View());\r\n    QSharedPointer<View::EnvironmentIdentifier> subjectIdentifier(new View::EnvironmentIdentifier(subjectValue));\r\n    subject->addEnvIdentifier(subjectIdentifier);\r\n\r\n    QVERIFY(comparator_->compare(reference, subject) == expectedComparison);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ViewComparator::testViewsEnvIdenrtifierComparison_data()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ViewComparator::testViewsEnvIdenrtifierComparison_data()\r\n{\r\n    createTestInputsForStringValues();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ViewComparator::testDiffEnvIdentifiers()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ViewComparator::testDiffEnvIdentifiers()\r\n{\r\n    QSharedPointer<View> reference(new View(\"view1\"));    \r\n\r\n    QSharedPointer<View::EnvironmentIdentifier> firstReferenceIdentifier(new View::EnvironmentIdentifier(\r\n        QStringLiteral(\"0\"), QStringLiteral(\"0\"), QStringLiteral(\"0\")));\r\n    reference->addEnvIdentifier(firstReferenceIdentifier);\r\n\r\n    QSharedPointer<View::EnvironmentIdentifier> secondReferenceIdentifier(new View::EnvironmentIdentifier(\r\n        QStringLiteral(\"1\"), QStringLiteral(\"1\"), QStringLiteral(\"1\")));\r\n    reference->addEnvIdentifier(secondReferenceIdentifier);\r\n\r\n    QSharedPointer<View> subject(new View(\"view1\"));\r\n\r\n    QSharedPointer<View::EnvironmentIdentifier> firstSubjectIdentifier(new View::EnvironmentIdentifier(\r\n        QStringLiteral(\"2\"), QStringLiteral(\"2\"), QStringLiteral(\"2\")));\r\n    subject->addEnvIdentifier(firstSubjectIdentifier);\r\n\r\n    QSharedPointer<View::EnvironmentIdentifier> secondSubjectIdentifier(new View::EnvironmentIdentifier(\r\n        QStringLiteral(\"3\"), QStringLiteral(\"3\"), QStringLiteral(\"3\")));\r\n    subject->addEnvIdentifier(secondSubjectIdentifier);\r\n\r\n    QList<QSharedPointer<IPXactDiff> > diff = comparator_->diff(reference, subject);\r\n\r\n    QCOMPARE(diff.count(), 1);\r\n    verifyDiffElementAndType(diff.first(), \"view\", \"view1\", IPXactDiff::MODIFICATION);\r\n    verifyModificationIs(diff.first()->getChangeList().first(), \"environment identifiers\", \"0:0:0, 1:1:1\", \"2:2:2, 3:3:3\");\r\n}\r\n\r\n\r\nQTEST_APPLESS_MAIN(tst_ViewComparator)\r\n\r\n#include \"tst_ViewComparator.moc\"\r\n    "
  },
  {
    "path": "tests/Core/tst_ViewComparator.pri",
    "content": "# ----------------------------------------------------\r\n# This file is generated by the Qt Visual Studio Add-in.\r\n# ------------------------------------------------------\r\n\r\nHEADERS += ../../wizards/common/IPXactDiff.h \\\r\n    ../../wizards/common/IPXactElementComparator.h \\\r\n    ../../wizards/common/ViewComparator/ViewComparator.h \\\r\n    ./ComparatorTest.h\r\n\r\nSOURCES += ../../wizards/common/IPXactDiff.cpp \\\r\n    ../../wizards/common/ViewComparator/ViewComparator.cpp \\\r\n    ./tst_ViewComparator.cpp \\\r\n    ./ComparatorTest.cpp\r\n"
  },
  {
    "path": "tests/Core/tst_ViewComparator.pro",
    "content": "#-----------------------------------------------------------------------------\r\n# File: tst_ViewComparator.pro\r\n#-----------------------------------------------------------------------------\r\n# Project: Kactus 2\r\n# Author: Esko Pekkarinen\r\n# Date: 24.10.2014\r\n#\r\n# Description:\r\n# Qt project file template for running unit tests for a ComponentComparator.\r\n#-----------------------------------------------------------------------------\r\n\r\nTEMPLATE = app\r\n\r\nTARGET = tst_ViewComparator\r\n\r\nQT += core xml gui testlib\r\nCONFIG += c++11 testcase console\r\n\r\nwin32:CONFIG(release, debug|release) {\r\n    LIBS += -L$$PWD/../../executable/ -lIPXACTmodels\r\n    DESTDIR = ./release\r\n}\r\nelse:win32:CONFIG(debug, debug|release) {\r\n    LIBS += -L$$PWD/../../executable/ -lIPXACTmodelsd\r\n    DESTDIR = ./debug\r\n}\r\nelse:unix {\r\n    LIBS += -L$$PWD/../../executable/ -lIPXACTmodels\r\n    DESTDIR = ./release\r\n}\r\n\r\nINCLUDEPATH += $$PWD/../../\r\nINCLUDEPATH += $$PWD/../../executable\r\nINCLUDEPATH += $$DESTDIR\r\n\r\nDEPENDPATH += $$PWD/../../\r\nDEPENDPATH += $$PWD/../../executable\r\n\r\nOBJECTS_DIR += $$DESTDIR\r\n\r\nMOC_DIR += ./generatedFiles\r\nUI_DIR += ./generatedFiles\r\nRCC_DIR += ./generatedFiles\r\ninclude(tst_ViewComparator.pri)\r\n"
  },
  {
    "path": "tests/IPXACTmodels/AbstractionDefinition/AbstractionDefinition.pro",
    "content": "#-----------------------------------------------------------------------------\n# File: AbstractionDefinition.pro\n#-----------------------------------------------------------------------------\n# Project: Kactus2\n# Author: Esko Pekkarinen\n# Date: 04.05.2018\n#\n# Description:\n# Qt project file template for running unit tests for AbstractionDefinition.\n#-----------------------------------------------------------------------------\n\nTEMPLATE = subdirs\n\nCONFIG += testcase\nSUBDIRS += tst_AbstractionDefinitionReader.pro \\\n\t       tst_AbstractionDefinitionWriter.pro \\\n\t\t   tst_AbstractionDefinitionValidator.pro\n"
  },
  {
    "path": "tests/IPXACTmodels/AbstractionDefinition/tst_AbstractionDefinitionReader.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: tst_AbstractionDefinitionReader.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Esko Pekkarinen\n// Date: 10.08.2015\n//\n// Description:\n// Unit test for class AbstractionDefinition.\n//-----------------------------------------------------------------------------\n\n#include <QtTest>\n\n#include <QDomNode>\n\n#include <IPXACTmodels/common/CellSpecification.h>\n#include <IPXACTmodels/common/Parameter.h>\n#include <IPXACTmodels/common/PresenceTypes.h>\n#include <IPXACTmodels/common/Protocol.h>\n#include <IPXACTmodels/common/TimingConstraint.h>\n#include <IPXACTmodels/common/Qualifier.h>\n\n#include <IPXACTmodels/AbstractionDefinition/AbstractionDefinition.h>\n#include <IPXACTmodels/AbstractionDefinition/AbstractionDefinitionReader.h>\n#include <IPXACTmodels/AbstractionDefinition/PortAbstraction.h>\n#include <IPXACTmodels/AbstractionDefinition/TransactionalAbstraction.h>\n#include <IPXACTmodels/AbstractionDefinition/TransactionalPort.h>\n#include <IPXACTmodels/AbstractionDefinition/WireAbstraction.h>\n#include <IPXACTmodels/AbstractionDefinition/WirePort.h>\n#include <IPXACTmodels/AbstractionDefinition/Packet.h>\n\n#include <IPXACTmodels/common/GenericVendorExtension.h>\n\n//-----------------------------------------------------------------------------\n//! Unit test for class AbstractionDefinition.\n//-----------------------------------------------------------------------------\nclass tst_AbstractionDefinitionReader : public QObject\n{\n    Q_OBJECT\n\npublic:\n    tst_AbstractionDefinitionReader();\n\nprivate slots:\n    void testReadVLNVAndMandatoryFields();\n    void testReadDocumentNameGroupAndMandatoryFields();\n    void testReadTopComments();\n    void testProcessingInstructionsAreParsed();\n\n    void testReadExtends();\n    void testReadDescription();\n\n    void testReadWirePort();\n    void testReadWirePortNewStd();\n    void testReadMultipleWireSystemPorts();\n    void testReadWirePortConstraints();\n\n    void testReadTransactionalPort();\n    void testReadMultipleTransactionalSystemPorts();\n    void testReadTransactionalWithProtocol();\n    void testReadTransactionalWithCustomProtocol();\n   \n    void testReadChoices();\n\n    void testReadParameters();\n    void testReadParametersNewStd();\n    void testReadAssertions();\n    void testReadVendorExtension();\n\n};\n\n//-----------------------------------------------------------------------------\n// Function: tst_AbstractionDefinitionReader::tst_AbstractionDefinitionReader()\n//-----------------------------------------------------------------------------\ntst_AbstractionDefinitionReader::tst_AbstractionDefinitionReader()\n{\n    \n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_AbstractionDefinitionReader::testReadVLNVAndMandatoryFields()\n//-----------------------------------------------------------------------------\nvoid tst_AbstractionDefinitionReader::testReadVLNVAndMandatoryFields()\n{\n    QDomDocument document;\n    document.setContent(QString(        \n        \"<ipxact:abstractionDefinition xmlns:xsi=\\\"http://www.w3.org/2001/XMLSchema-instance\\\" \" \n        \"xmlns:ipxact=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014\\\" \"\n        \"xmlns:kactus2=\\\"http://kactus2.cs.tut.fi\\\" \"\n        \"xsi:schemaLocation=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/ \"\n        \"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/index.xsd\\\">\"\n            \"<ipxact:vendor>TUT</ipxact:vendor>\"\n            \"<ipxact:library>TestLibrary</ipxact:library>\"\n            \"<ipxact:name>MinimalDefinition</ipxact:name>\"\n            \"<ipxact:version>1.0</ipxact:version>\"\n            \"<ipxact:busType vendor=\\\"TUT\\\" library=\\\"TestLibrary\\\" name=\\\"TargetBus\\\" version=\\\"2.0\\\"/>\"\n        \"</ipxact:abstractionDefinition>\"));\n\n    QSharedPointer<AbstractionDefinition> definition = AbstractionDefinitionReader::createAbstractionDefinitionFrom(document);\n   \n    VLNV readVLNV = definition->getVlnv();\n    QCOMPARE(readVLNV.getVendor(), QString(\"TUT\"));\n    QCOMPARE(readVLNV.getLibrary(), QString(\"TestLibrary\"));\n    QCOMPARE(readVLNV.getName(), QString(\"MinimalDefinition\"));\n    QCOMPARE(readVLNV.getVersion(), QString(\"1.0\"));\n    \n    VLNV busType = definition->getBusType();\n    QCOMPARE(busType.getVendor(), QString(\"TUT\"));\n    QCOMPARE(busType.getLibrary(), QString(\"TestLibrary\"));\n    QCOMPARE(busType.getName(), QString(\"TargetBus\"));\n    QCOMPARE(busType.getVersion(), QString(\"2.0\"));\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_AbstractionDefinitionReader::testReadDocumentNameGroupAndMandatoryFields()\n//-----------------------------------------------------------------------------\nvoid tst_AbstractionDefinitionReader::testReadDocumentNameGroupAndMandatoryFields()\n{\n    QDomDocument document;\n    document.setContent(QString(\n        \"<ipxact:abstractionDefinition xmlns:xsi=\\\"http://www.w3.org/2001/XMLSchema-instance\\\" \"\n        \"xmlns:ipxact=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2022\\\" \"\n        \"xmlns:kactus2=\\\"http://kactus2.cs.tut.fi\\\" \"\n        \"xsi:schemaLocation=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2022/ \"\n        \"http://www.accellera.org/XMLSchema/IPXACT/1685-2022/index.xsd\\\">\"\n            \"<ipxact:vendor>TUT</ipxact:vendor>\"\n            \"<ipxact:library>TestLibrary</ipxact:library>\"\n            \"<ipxact:name>MinimalDefinition</ipxact:name>\"\n            \"<ipxact:version>1.0</ipxact:version>\"\n            \"<ipxact:displayName>testDisplayName</ipxact:displayName>\"\n            \"<ipxact:shortDescription>testShortDescription</ipxact:shortDescription>\"\n            \"<ipxact:description>testDescription</ipxact:description>\"\n            \"<ipxact:busType vendor=\\\"TUT\\\" library=\\\"TestLibrary\\\" name=\\\"TargetBus\\\" version=\\\"2.0\\\"/>\"\n        \"</ipxact:abstractionDefinition>\"));\n\n    QSharedPointer<AbstractionDefinition> definition = AbstractionDefinitionReader::createAbstractionDefinitionFrom(document);\n\n    VLNV readVLNV = definition->getVlnv();\n    QCOMPARE(readVLNV.getVendor(), QString(\"TUT\"));\n    QCOMPARE(readVLNV.getLibrary(), QString(\"TestLibrary\"));\n    QCOMPARE(readVLNV.getName(), QString(\"MinimalDefinition\"));\n    QCOMPARE(readVLNV.getVersion(), QString(\"1.0\"));\n    \n    QCOMPARE(definition->getDisplayName(), QString(\"testDisplayName\"));\n    QCOMPARE(definition->getShortDescription(), QString(\"testShortDescription\"));\n    QCOMPARE(definition->getDescription(), QString(\"testDescription\"));\n    QCOMPARE(definition->toString(definition->getRevision()), QString(\"1685-2022\"));\n\n    VLNV busType = definition->getBusType();\n    QCOMPARE(busType.getVendor(), QString(\"TUT\"));\n    QCOMPARE(busType.getLibrary(), QString(\"TestLibrary\"));\n    QCOMPARE(busType.getName(), QString(\"TargetBus\"));\n    QCOMPARE(busType.getVersion(), QString(\"2.0\"));\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_AbstractionDefinitionReader::testReadTopComments()\n//-----------------------------------------------------------------------------\nvoid tst_AbstractionDefinitionReader::testReadTopComments()\n{\n    QDomDocument document;\n    document.setContent(QString(        \n        \"<?xml version=\\\"1.0\\\"?>\"\n        \"<!--Commented line 1-->\"\n        \"<!--Commented line 2-->\"\n        \"<ipxact:abstractionDefinition xmlns:xsi=\\\"http://www.w3.org/2001/XMLSchema-instance\\\" \" \n        \"xmlns:ipxact=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014\\\" \"\n        \"xmlns:kactus2=\\\"http://kactus2.cs.tut.fi\\\" \"\n        \"xsi:schemaLocation=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/ \"\n        \"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/index.xsd\\\">\"\n            \"<ipxact:vendor>TUT</ipxact:vendor>\"\n            \"<ipxact:library>TestLibrary</ipxact:library>\"\n            \"<ipxact:name>MinimalDefinition</ipxact:name>\"\n            \"<ipxact:version>1.0</ipxact:version>\"\n            \"<ipxact:busType vendor=\\\"TUT\\\" library=\\\"TestLibrary\\\" name=\\\"TargetBus\\\" version=\\\"2.0\\\"/>\"\n            \"</ipxact:abstractionDefinition>\"\n        \"<!--Comment not to include-->\"));\n\n    QSharedPointer<AbstractionDefinition> definition = AbstractionDefinitionReader::createAbstractionDefinitionFrom(document);\n\n    QCOMPARE(definition->getTopComments().size(), 2);\n    QCOMPARE(definition->getTopComments().first(), QString(\"Commented line 1\"));   \n    QCOMPARE(definition->getTopComments().last(), QString(\"Commented line 2\"));   \n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_AbstractionDefinitionReader::testProcessingInstructionsAreWritten()\n//-----------------------------------------------------------------------------\nvoid tst_AbstractionDefinitionReader::testProcessingInstructionsAreParsed()\n{\n    QDomDocument document;\n    document.setContent(QString(        \n        \"<?xml version=\\\"1.0\\\"?>\"\n        \"<!--Header comment -->\"\n        \"<?xml-stylesheet href=\\\"style.css\\\"?>\"\n        \"<ipxact:abstractionDefinition xmlns:xsi=\\\"http://www.w3.org/2001/XMLSchema-instance\\\" \" \n        \"xmlns:ipxact=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014\\\" \"\n        \"xmlns:kactus2=\\\"http://kactus2.cs.tut.fi\\\" \"\n        \"xsi:schemaLocation=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/ \"\n        \"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/index.xsd\\\">\"\n            \"<ipxact:vendor>TUT</ipxact:vendor>\"\n            \"<ipxact:library>TestLibrary</ipxact:library>\"\n            \"<ipxact:name>MinimalDefinition</ipxact:name>\"\n            \"<ipxact:version>1.0</ipxact:version>\"\n            \"<ipxact:busType vendor=\\\"TUT\\\" library=\\\"TestLibrary\\\" name=\\\"TargetBus\\\" version=\\\"2.0\\\"/>\"\n        \"</ipxact:abstractionDefinition>\"\n        ));\n\n    QSharedPointer<AbstractionDefinition> definition = AbstractionDefinitionReader::createAbstractionDefinitionFrom(document);\n\n    QCOMPARE(definition->getXmlProcessingInstructions().count(), 1);\n\n    QPair<QString, QString> styleInstruction = definition->getXmlProcessingInstructions().first();\n    QCOMPARE(styleInstruction.first, QString(\"xml-stylesheet\"));\n    QCOMPARE(styleInstruction.second, QString(\"href=\\\"style.css\\\"\"));\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_AbstractionDefinitionReader::testReadExtends()\n//-----------------------------------------------------------------------------\nvoid tst_AbstractionDefinitionReader::testReadExtends()\n{\n    QDomDocument document;\n    document.setContent(QString(        \n        \"<ipxact:abstractionDefinition xmlns:xsi=\\\"http://www.w3.org/2001/XMLSchema-instance\\\" \" \n        \"xmlns:ipxact=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014\\\" \"\n        \"xmlns:kactus2=\\\"http://kactus2.cs.tut.fi\\\" \"\n        \"xsi:schemaLocation=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/ \"\n        \"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/index.xsd\\\">\"\n            \"<ipxact:vendor>TUT</ipxact:vendor>\"\n            \"<ipxact:library>TestLibrary</ipxact:library>\"\n            \"<ipxact:name>MinimalDefinition</ipxact:name>\"\n            \"<ipxact:version>1.0</ipxact:version>\"\n            \"<ipxact:busType vendor=\\\"TUT\\\" library=\\\"TestLibrary\\\" name=\\\"TargetBus\\\" version=\\\"2.0\\\"/>\"\n            \"<ipxact:extends vendor=\\\"TUT\\\" library=\\\"TestLibrary\\\" name=\\\"extended\\\" version=\\\"1.0\\\"/>\"\n        \"</ipxact:abstractionDefinition>\"));\n\n    QSharedPointer<AbstractionDefinition> testBus = AbstractionDefinitionReader::createAbstractionDefinitionFrom(document);\n\n    VLNV extendedBus = testBus->getExtends();\n    QCOMPARE(extendedBus.getVendor(), QString(\"TUT\"));\n    QCOMPARE(extendedBus.getLibrary(), QString(\"TestLibrary\"));\n    QCOMPARE(extendedBus.getName(), QString(\"extended\"));\n    QCOMPARE(extendedBus.getVersion(), QString(\"1.0\"));\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_AbstractionDefinitionReader::testReadDescription()\n//-----------------------------------------------------------------------------\nvoid tst_AbstractionDefinitionReader::testReadDescription()\n{\n    QDomDocument document;\n    document.setContent(QString(        \n        \"<?xml version=\\\"1.0\\\"?>\"\n        \"<ipxact:abstractionDefinition xmlns:xsi=\\\"http://www.w3.org/2001/XMLSchema-instance\\\" \" \n        \"xmlns:ipxact=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014\\\" \"\n        \"xmlns:kactus2=\\\"http://kactus2.cs.tut.fi\\\" \"\n        \"xsi:schemaLocation=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/ \"\n        \"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/index.xsd\\\">\"\n            \"<ipxact:vendor>TUT</ipxact:vendor>\"\n            \"<ipxact:library>TestLibrary</ipxact:library>\"\n            \"<ipxact:name>MinimalDefinition</ipxact:name>\"\n            \"<ipxact:version>1.0</ipxact:version>\"\n            \"<ipxact:busType vendor=\\\"TUT\\\" library=\\\"TestLibrary\\\" name=\\\"TargetBus\\\" version=\\\"1.0\\\"/>\"\n            \"<ipxact:description>Abstraction definition description.</ipxact:description>\"\n        \"</ipxact:abstractionDefinition>\"));\n\n    QSharedPointer<AbstractionDefinition> testBus = AbstractionDefinitionReader::createAbstractionDefinitionFrom(document);\n\n    QCOMPARE(testBus->getDescription(), QString(\"Abstraction definition description.\"));\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_AbstractionDefinitionReader::testReadWirePort()\n//-----------------------------------------------------------------------------\nvoid tst_AbstractionDefinitionReader::testReadWirePort()\n{\n    QDomDocument document;\n    document.setContent(QString(        \n        \"<?xml version=\\\"1.0\\\"?>\"\n        \"<ipxact:abstractionDefinition xmlns:xsi=\\\"http://www.w3.org/2001/XMLSchema-instance\\\" \" \n        \"xmlns:ipxact=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014\\\" \"\n        \"xmlns:kactus2=\\\"http://kactus2.cs.tut.fi\\\" \"\n        \"xsi:schemaLocation=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/ \"\n        \"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/index.xsd\\\">\"\n            \"<ipxact:vendor>TUT</ipxact:vendor>\"\n            \"<ipxact:library>TestLibrary</ipxact:library>\"\n            \"<ipxact:name>MinimalDefinition</ipxact:name>\"\n            \"<ipxact:version>1.0</ipxact:version>\"\n            \"<ipxact:busType vendor=\\\"TUT\\\" library=\\\"TestLibrary\\\" name=\\\"TargetBus\\\" version=\\\"1.0\\\"/>\"\n            \"<ipxact:ports>\"\n                \"<ipxact:port>\"\n                    \"<ipxact:isPresent>1</ipxact:isPresent>\"\n                    \"<ipxact:logicalName>wirePort</ipxact:logicalName>\"\n                    \"<ipxact:displayName>simple wire</ipxact:displayName>\"\n                    \"<ipxact:description>simple wire for testing</ipxact:description>\"\n                     \"<ipxact:wire>\"\n                        \"<ipxact:qualifier>\"\n                            \"<ipxact:isData>true</ipxact:isData>\"\n                            \"<ipxact:isAddress>true</ipxact:isAddress>\"\n                        \"</ipxact:qualifier>\"\n                        \"<ipxact:onMaster>\"\n                            \"<ipxact:presence>required</ipxact:presence>\"\n                            \"<ipxact:width>widthExpression</ipxact:width>\"\n                            \"<ipxact:direction>inout</ipxact:direction>\"\n                        \"</ipxact:onMaster>\"\n                         \"<ipxact:defaultValue>1</ipxact:defaultValue>\"\n                    \"</ipxact:wire>\"\n                    \"<ipxact:vendorExtensions>\"\n                        \"<testExtension vendorAttribute=\\\"extension\\\">testValue</testExtension>\"\n                    \"</ipxact:vendorExtensions>\"\n                \"</ipxact:port>\"\n            \"</ipxact:ports>\"\n        \"</ipxact:abstractionDefinition>\"));\n\n    QSharedPointer<AbstractionDefinition> readAbsDef = AbstractionDefinitionReader::createAbstractionDefinitionFrom(document);\n\n    QCOMPARE(readAbsDef->getLogicalPorts()->size(), 1);\n\n    QSharedPointer<PortAbstraction> port = readAbsDef->getLogicalPorts()->first();\n\n    QCOMPARE(port->isPresent(), QString(\"1\"));\n    QCOMPARE(port->getLogicalName(), QString(\"wirePort\"));\n    QCOMPARE(port->displayName(), QString(\"simple wire\"));\n    QCOMPARE(port->description(), QString(\"simple wire for testing\"));\n    QCOMPARE(port->getVendorExtensions()->size(), 1);\n\n    QCOMPARE(port->hasWire(), true);\n    QCOMPARE(port->getWire()->getDefaultValue(), QString(\"1\"));\n\n    auto wireQualifier = port->getQualifier();\n    QCOMPARE(wireQualifier->hasType(Qualifier::Type::Data), true);\n    QCOMPARE(wireQualifier->hasType(Qualifier::Type::Address), true);\n    QCOMPARE(wireQualifier->hasType(Qualifier::Type::Clock), false);\n    QCOMPARE(wireQualifier->hasType(Qualifier::Type::Reset), false);\n\n    QSharedPointer<WirePort> master = port->getWire()->getMasterPort();\n    QCOMPARE(master->getPresence(), PresenceTypes::REQUIRED);\n    QCOMPARE(master->getWidth(), QString(\"widthExpression\"));\n    QCOMPARE(master->getDirection(), DirectionTypes::INOUT);\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_AbstractionDefinitionReader::testReadWirePortNewStd()\n//-----------------------------------------------------------------------------\nvoid tst_AbstractionDefinitionReader::testReadWirePortNewStd()\n{\n    QDomDocument document;\n    document.setContent(QString(\n        \"<?xml version=\\\"1.0\\\"?>\"\n        \"<ipxact:abstractionDefinition xmlns:xsi=\\\"http://www.w3.org/2001/XMLSchema-instance\\\" \"\n        \"xmlns:ipxact=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2022\\\" \"\n        \"xmlns:kactus2=\\\"http://kactus2.cs.tut.fi\\\" \"\n        \"xsi:schemaLocation=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2022/ \"\n        \"http://www.accellera.org/XMLSchema/IPXACT/1685-2022/index.xsd\\\">\"\n        \"<ipxact:vendor>TUT</ipxact:vendor>\"\n        \"<ipxact:library>TestLibrary</ipxact:library>\"\n        \"<ipxact:name>MinimalDefinition</ipxact:name>\"\n        \"<ipxact:version>1.0</ipxact:version>\"\n        \"<ipxact:busType vendor=\\\"TUT\\\" library=\\\"TestLibrary\\\" name=\\\"TargetBus\\\" version=\\\"1.0\\\"/>\"\n            \"<ipxact:ports>\"\n                \"<ipxact:port>\"\n                    \"<ipxact:logicalName>wirePort</ipxact:logicalName>\"\n                    \"<ipxact:displayName>simple wire</ipxact:displayName>\"\n                    \"<ipxact:shortDescription>shortDesc.</ipxact:shortDescription>\"\n                    \"<ipxact:description>simple wire for testing</ipxact:description>\"\n                    \"<ipxact:match>true</ipxact:match>\"\n                    \"<ipxact:wire>\"\n                        \"<ipxact:qualifier>\"\n                            \"<ipxact:isFlowControl flowType=\\\"user\\\" user=\\\"test flow type\\\">true</ipxact:isFlowControl>\"\n                        \"</ipxact:qualifier>\"\n                        \"<ipxact:onInitiator>\"\n                            \"<ipxact:presence>required</ipxact:presence>\"\n                            \"<ipxact:width>widthExpression</ipxact:width>\"\n                            \"<ipxact:direction>inout</ipxact:direction>\"\n                        \"</ipxact:onInitiator>\"\n                        \"<ipxact:onTarget>\"\n                            \"<ipxact:presence>required</ipxact:presence>\"\n                            \"<ipxact:width>4</ipxact:width>\"\n                            \"<ipxact:direction>in</ipxact:direction>\"\n                        \"</ipxact:onTarget>\"\n                        \"<ipxact:defaultValue>1</ipxact:defaultValue>\"\n                    \"</ipxact:wire>\"\n                    \"<ipxact:vendorExtensions>\"\n                        \"<testExtension vendorAttribute=\\\"extension\\\">testValue</testExtension>\"\n                    \"</ipxact:vendorExtensions>\"\n                    \"<ipxact:packets>\"\n                        \"<ipxact:packet>\"\n                            \"<ipxact:name>testPacket</ipxact:name>\"\n                            \"<ipxact:endianness>little</ipxact:endianness>\"\n                            \"<ipxact:packetFields>\"\n                                \"<ipxact:packetField>\"\n                                    \"<ipxact:name>testField</ipxact:name>\"\n                                    \"<ipxact:description>A packet field description</ipxact:description>\"\n                                    \"<ipxact:value>4</ipxact:value>\"\n                                    \"<ipxact:width>4</ipxact:width>\"\n                                    \"<ipxact:qualifier>\"\n                                        \"<ipxact:isOpcode>true</ipxact:isOpcode>\"\n                                    \"</ipxact:qualifier>\"\n                                \"</ipxact:packetField>\"\n                            \"</ipxact:packetFields>\"\n                        \"</ipxact:packet>\"\n                    \"</ipxact:packets>\"\n                \"</ipxact:port>\"\n            \"</ipxact:ports>\"\n        \"</ipxact:abstractionDefinition>\"));\n\n    QSharedPointer<AbstractionDefinition> readAbsDef = AbstractionDefinitionReader::createAbstractionDefinitionFrom(document);\n\n    QCOMPARE(readAbsDef->getLogicalPorts()->size(), 1);\n\n    QSharedPointer<PortAbstraction> port = readAbsDef->getLogicalPorts()->first();\n\n    QCOMPARE(port->getLogicalName(), QString(\"wirePort\"));\n    QCOMPARE(port->displayName(), QString(\"simple wire\"));\n    QCOMPARE(port->description(), QString(\"simple wire for testing\"));\n    QCOMPARE(port->shortDescription(), QString(\"shortDesc.\"));\n    QCOMPARE(port->getMatch(), true);\n    QCOMPARE(port->getVendorExtensions()->size(), 1);\n\n    QCOMPARE(port->hasWire(), true);\n    QCOMPARE(port->getWire()->getDefaultValue(), QString(\"1\"));\n\n    auto wireQualifier = port->getQualifier();\n    QCOMPARE(wireQualifier->hasType(Qualifier::Type::FlowControl), true);\n    QCOMPARE(wireQualifier->getAttribute(Qualifier::Attribute::FlowType), \"user\");\n    QCOMPARE(wireQualifier->getAttribute(Qualifier::Attribute::UserFlowType), \"test flow type\");\n    QCOMPARE(wireQualifier->hasType(Qualifier::Type::Data), false);\n    QCOMPARE(wireQualifier->hasType(Qualifier::Type::Address), false);\n    QVERIFY(wireQualifier->getAttribute(Qualifier::Attribute::UserDefined).size() == 0);\n\n    auto initiator = port->getWire()->getInitiatorPort();\n    QCOMPARE(initiator->getPresence(), PresenceTypes::REQUIRED);\n    QCOMPARE(initiator->getWidth(), QString(\"widthExpression\"));\n    QCOMPARE(initiator->getDirection(), DirectionTypes::INOUT);\n\n    auto target = port->getWire()->getTargetPort();\n    QCOMPARE(target->getPresence(), PresenceTypes::REQUIRED);\n    QCOMPARE(target->getWidth(), QString(\"4\"));\n    QCOMPARE(target->getDirection(), DirectionTypes::IN);\n\n    auto packet = port->getPackets()->first();\n    QCOMPARE(packet->name(), QString(\"testPacket\"));\n    QCOMPARE(packet->getEndianness(), QString(\"little\"));\n\n    auto testPacketField = packet->getPacketFields()->first();\n    QCOMPARE(testPacketField->name(), QString(\"testField\"));\n    QCOMPARE(testPacketField->description(), QString(\"A packet field description\"));\n    QCOMPARE(testPacketField->getValue(), QString(\"4\"));\n    QCOMPARE(testPacketField->getWidth(), QString(\"4\"));\n\n    auto fieldQualifier = testPacketField->getQualifier();\n    QCOMPARE(fieldQualifier->hasType(Qualifier::Type::Opcode), true);\n    QCOMPARE(fieldQualifier->hasType(Qualifier::Type::PowerEnable), false);\n    QVERIFY(fieldQualifier->getAttribute(Qualifier::Attribute::PowerEnableLevel).size() == 0);\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_AbstractionDefinitionReader::testReadMultipleWireSystemPorts()\n//-----------------------------------------------------------------------------\nvoid tst_AbstractionDefinitionReader::testReadMultipleWireSystemPorts()\n{\n    QDomDocument document;\n    document.setContent(QString(        \n        \"<?xml version=\\\"1.0\\\"?>\"\n        \"<ipxact:abstractionDefinition xmlns:xsi=\\\"http://www.w3.org/2001/XMLSchema-instance\\\" \" \n        \"xmlns:ipxact=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014\\\" \"\n        \"xmlns:kactus2=\\\"http://kactus2.cs.tut.fi\\\" \"\n        \"xsi:schemaLocation=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/ \"\n        \"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/index.xsd\\\">\"\n            \"<ipxact:vendor>TUT</ipxact:vendor>\"\n            \"<ipxact:library>TestLibrary</ipxact:library>\"\n            \"<ipxact:name>MinimalDefinition</ipxact:name>\"\n            \"<ipxact:version>1.0</ipxact:version>\"\n            \"<ipxact:busType vendor=\\\"TUT\\\" library=\\\"TestLibrary\\\" name=\\\"TargetBus\\\" version=\\\"1.0\\\"/>\"\n            \"<ipxact:ports>\"\n                \"<ipxact:port>\"\n                    \"<ipxact:isPresent>1</ipxact:isPresent>\"\n                    \"<ipxact:logicalName>wirePort</ipxact:logicalName>\"\n                    \"<ipxact:wire>\"\n                        \"<ipxact:onSystem>\"\n                            \"<ipxact:group>testInGroup</ipxact:group>\"\n                            \"<ipxact:direction>in</ipxact:direction>\"\n                        \"</ipxact:onSystem>\"\n                        \"<ipxact:onSystem>\"   \n                            \"<ipxact:group>testOutGroup</ipxact:group>\"\n                            \"<ipxact:direction>out</ipxact:direction>\"\n                        \"</ipxact:onSystem>\"\n                        \"<ipxact:onSystem>\"       \n                            \"<ipxact:group>testInOutGroup</ipxact:group>\"\n                            \"<ipxact:direction>inout</ipxact:direction>\"\n                        \"</ipxact:onSystem>\"\n                        \"<ipxact:defaultValue>1</ipxact:defaultValue>\"\n                    \"</ipxact:wire>\"            \n                \"</ipxact:port>\"\n            \"</ipxact:ports>\"\n        \"</ipxact:abstractionDefinition>\"));\n\n    QSharedPointer<AbstractionDefinition> readAbsDef = AbstractionDefinitionReader::createAbstractionDefinitionFrom(document);\n\n    QSharedPointer<PortAbstraction> port = readAbsDef->getLogicalPorts()->first();\n\n    QSharedPointer<QList<QSharedPointer<WirePort> > > systemPorts = port->getWire()->getSystemPorts();\n    QCOMPARE(systemPorts->size(), 3);\n\n    QCOMPARE(systemPorts->at(0)->getDirection(), DirectionTypes::IN);\n    QCOMPARE(systemPorts->at(0)->getSystemGroup(), QString(\"testInGroup\"));\n\n    QCOMPARE(systemPorts->at(1)->getDirection(), DirectionTypes::OUT);\n    QCOMPARE(systemPorts->at(1)->getSystemGroup(), QString(\"testOutGroup\"));\n\n    QCOMPARE(systemPorts->at(2)->getDirection(), DirectionTypes::INOUT);\n    QCOMPARE(systemPorts->at(2)->getSystemGroup(), QString(\"testInOutGroup\"));\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_AbstractionDefinitionReader::testReadWirePortConstraints()\n//-----------------------------------------------------------------------------\nvoid tst_AbstractionDefinitionReader::testReadWirePortConstraints()\n{\n    QDomDocument document;\n    document.setContent(QString(        \n        \"<?xml version=\\\"1.0\\\"?>\"\n        \"<ipxact:abstractionDefinition xmlns:xsi=\\\"http://www.w3.org/2001/XMLSchema-instance\\\" \" \n        \"xmlns:ipxact=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014\\\" \"\n        \"xmlns:kactus2=\\\"http://kactus2.cs.tut.fi\\\" \"\n        \"xsi:schemaLocation=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/ \"\n        \"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/index.xsd\\\">\"\n            \"<ipxact:vendor>TUT</ipxact:vendor>\"\n            \"<ipxact:library>TestLibrary</ipxact:library>\"\n            \"<ipxact:name>MinimalDefinition</ipxact:name>\"\n            \"<ipxact:version>1.0</ipxact:version>\"\n            \"<ipxact:busType vendor=\\\"TUT\\\" library=\\\"TestLibrary\\\" name=\\\"TargetBus\\\" version=\\\"1.0\\\"/>\"\n                \"<ipxact:ports>\"\n                    \"<ipxact:port>\"\n                        \"<ipxact:isPresent>1</ipxact:isPresent>\"\n                        \"<ipxact:logicalName>wirePort</ipxact:logicalName>\"\n                        \"<ipxact:wire>\"        \n                            \"<ipxact:onSlave>\"\n                                \"<ipxact:modeConstraints>\"\n                                    \"<ipxact:timingConstraint clockEdge=\\\"fall\\\" delayType=\\\"min\\\" clockName=\\\"clk_in\\\">2.25</ipxact:timingConstraint>\"\n                                    \"<ipxact:loadConstraint>\"\n                                        \"<ipxact:cellSpecification cellStrength=\\\"low\\\">\"\n                                            \"<ipxact:cellFunction other=\\\"customFunction\\\">other</ipxact:cellFunction>\"\n                                        \"</ipxact:cellSpecification>\"\n                                    \"</ipxact:loadConstraint>\"\n                                    \"<ipxact:driveConstraint>\"\n                                        \"<ipxact:cellSpecification cellStrength=\\\"high\\\">\"\n                                            \"<ipxact:cellClass>sequential</ipxact:cellClass>\"\n                                        \"</ipxact:cellSpecification>\"\n                                    \"</ipxact:driveConstraint>\"\n                                \"</ipxact:modeConstraints>\"\n                            \"</ipxact:onSlave>\"\n                        \"<ipxact:requiresDriver driverType=\\\"singleShot\\\">true</ipxact:requiresDriver>\"\n                    \"</ipxact:wire>\"\n                \"</ipxact:port>\"\n            \"</ipxact:ports>\"\n        \"</ipxact:abstractionDefinition>\"));\n\n    QSharedPointer<AbstractionDefinition> readAbsDef = AbstractionDefinitionReader::createAbstractionDefinitionFrom(document);\n\n    QCOMPARE(readAbsDef->getLogicalPorts()->size(), 1);\n\n    QSharedPointer<PortAbstraction> port = readAbsDef->getLogicalPorts()->first();\n    QCOMPARE(port->getLogicalName(), QString(\"wirePort\"));\n\n    QCOMPARE(port->hasWire(), true);\n    QCOMPARE(port->getWire()->requiresDriver(), true);\n    QCOMPARE(port->getWire()->getDriverType(), General::SINGLESHOT);\n\n    QSharedPointer<WirePort> slave = port->getWire()->getSlavePort();\n    QSharedPointer<TimingConstraint> timingConstraint = slave->getTimingConstraint();\n    QCOMPARE(timingConstraint->getClockEdge(), TimingConstraint::FALL);\n    QCOMPARE(timingConstraint->getDelayType(), TimingConstraint::MINIMUM_DELAY);\n    QCOMPARE(timingConstraint->getClockName(), QString(\"clk_in\"));\n    QCOMPARE(timingConstraint->getValue(), 2.25);\n\n    QSharedPointer<CellSpecification> driveConstraint = slave->getDriveConstraint();\n    QCOMPARE(driveConstraint->getCellStrength(), CellSpecification::HIGH);\n    QCOMPARE(driveConstraint->getCellFunction(), QString(\"\"));\n    QCOMPARE(driveConstraint->getCellClass(), CellSpecification::SEQUENTIAL);\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_AbstractionDefinitionReader::testReadTransactionalPort()\n//-----------------------------------------------------------------------------\nvoid tst_AbstractionDefinitionReader::testReadTransactionalPort()\n{\n    QDomDocument document;\n    document.setContent(QString(        \n        \"<?xml version=\\\"1.0\\\"?>\"\n        \"<ipxact:abstractionDefinition xmlns:xsi=\\\"http://www.w3.org/2001/XMLSchema-instance\\\" \" \n        \"xmlns:ipxact=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2022\\\" \"\n        \"xmlns:kactus2=\\\"http://kactus2.cs.tut.fi\\\" \"\n        \"xsi:schemaLocation=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2022/ \"\n        \"http://www.accellera.org/XMLSchema/IPXACT/1685-2022/index.xsd\\\">\"\n            \"<ipxact:vendor>TUT</ipxact:vendor>\"\n            \"<ipxact:library>TestLibrary</ipxact:library>\"\n            \"<ipxact:name>TestAbsDef</ipxact:name>\"\n            \"<ipxact:version>1.0</ipxact:version>\"\n            \"<ipxact:busType vendor=\\\"TUT\\\" library=\\\"TestLibrary\\\" name=\\\"TargetBusDef\\\" version=\\\"1.0\\\"/>\"\n            \"<ipxact:ports>\"\n                \"<ipxact:port>\"\n                    \"<ipxact:logicalName>testPort</ipxact:logicalName>\"\n                    \"<ipxact:match>false</ipxact:match>\"\n                    \"<ipxact:transactional>\"\n                        \"<ipxact:qualifier>\"\n                            \"<ipxact:isClockEn level=\\\"high\\\">true</ipxact:isClockEn>\"\n                        \"</ipxact:qualifier>\"\n                        \"<ipxact:onInitiator>\"\n                            \"<ipxact:presence>optional</ipxact:presence>\"\n                            \"<ipxact:initiative>requires</ipxact:initiative>\"\n                            \"<ipxact:kind>tlm_port</ipxact:kind>\"\n                            \"<ipxact:busWidth>32</ipxact:busWidth>\"\n                        \"</ipxact:onInitiator>\" \n                    \"</ipxact:transactional>\"\n                \"</ipxact:port>\"\n            \"</ipxact:ports>\"\n        \"</ipxact:abstractionDefinition>\"));\n\n    QSharedPointer<AbstractionDefinition> testDefinition = AbstractionDefinitionReader::createAbstractionDefinitionFrom(document);\n\n    QSharedPointer<PortAbstraction> port = testDefinition->getLogicalPorts()->first();\n\n    QCOMPARE(port->hasTransactional(), true);\n\n    auto transactionalQualifier = port->getQualifier();\n    QCOMPARE(transactionalQualifier->hasType(Qualifier::Type::Data), false);\n    QCOMPARE(transactionalQualifier->hasType(Qualifier::Type::Address), false);\n    QCOMPARE(transactionalQualifier->hasType(Qualifier::Type::ClockEnable), true);\n    QCOMPARE(transactionalQualifier->hasType(Qualifier::Type::Reset), false);\n    QCOMPARE(transactionalQualifier->getAttribute(Qualifier::Attribute::ClockEnableLevel), QStringLiteral(\"high\"));\n\n    QSharedPointer<TransactionalAbstraction> transactional = port->getTransactional();\n\n    QCOMPARE(transactional->hasInitiatorPort(), true);\n\n    QSharedPointer<TransactionalPort> initiatorPort = transactional->getInitiatorPort();\n    QCOMPARE(initiatorPort->getPresence(), PresenceTypes::OPTIONAL);\n    QCOMPARE(initiatorPort->getInitiative(), QString(\"requires\"));\n    QCOMPARE(initiatorPort->getKind(), QString(\"tlm_port\"));\n    QCOMPARE(initiatorPort->getBusWidth(), QString(\"32\"));\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_AbstractionDefinitionReader::testReadMultipleTransactionalSystemPorts()\n//-----------------------------------------------------------------------------\nvoid tst_AbstractionDefinitionReader::testReadMultipleTransactionalSystemPorts()\n{\n    QDomDocument document;\n    document.setContent(QString(        \n        \"<?xml version=\\\"1.0\\\"?>\"\n        \"<ipxact:abstractionDefinition xmlns:xsi=\\\"http://www.w3.org/2001/XMLSchema-instance\\\" \" \n        \"xmlns:ipxact=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014\\\" \"\n        \"xmlns:kactus2=\\\"http://kactus2.cs.tut.fi\\\" \"\n        \"xsi:schemaLocation=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/ \"\n        \"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/index.xsd\\\">\"\n            \"<ipxact:vendor>TUT</ipxact:vendor>\"\n            \"<ipxact:library>TestLibrary</ipxact:library>\"\n            \"<ipxact:name>TestAbsDef</ipxact:name>\"\n            \"<ipxact:version>1.0</ipxact:version>\"\n            \"<ipxact:busType vendor=\\\"TUT\\\" library=\\\"TestLibrary\\\" name=\\\"TargetBusDef\\\" version=\\\"1.0\\\"/>\"\n                \"<ipxact:ports>\"\n                    \"<ipxact:port>\"                \n                        \"<ipxact:logicalName>testPort</ipxact:logicalName>\"\n                        \"<ipxact:transactional>\"    \n                        \"<ipxact:onSystem>\"\n                            \"<ipxact:group>illegalGroup</ipxact:group>\"\n                            \"<ipxact:presence>illegal</ipxact:presence>\"\n                        \"</ipxact:onSystem>\" \n                        \"<ipxact:onSystem>\"\n                            \"<ipxact:group>requiredGroup</ipxact:group>\"\n                            \"<ipxact:presence>required</ipxact:presence>\"\n                        \"</ipxact:onSystem>\" \n                    \"</ipxact:transactional>\"\n                \"</ipxact:port>\"\n            \"</ipxact:ports>\"\n        \"</ipxact:abstractionDefinition>\"));\n\n    QSharedPointer<AbstractionDefinition> testDefinition = AbstractionDefinitionReader::createAbstractionDefinitionFrom(document);\n\n    QSharedPointer<PortAbstraction> port = testDefinition->getLogicalPorts()->first();\n\n    QCOMPARE(port->hasTransactional(), true);\n\n    QSharedPointer<TransactionalAbstraction> transactional = port->getTransactional();\n\n    QCOMPARE(transactional->getSystemPorts()->count(), 2);\n    QCOMPARE(transactional->getSystemPorts()->first()->getSystemGroup(), QString(\"illegalGroup\"));\n    QCOMPARE(transactional->getSystemPorts()->last()->getPresence(), PresenceTypes::REQUIRED);\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_AbstractionDefinitionReader::testReadTransactionalWithProtocol()\n//-----------------------------------------------------------------------------\nvoid tst_AbstractionDefinitionReader::testReadTransactionalWithProtocol()\n{\n    QDomDocument document;\n    document.setContent(QString(        \n        \"<?xml version=\\\"1.0\\\"?>\"\n        \"<ipxact:abstractionDefinition xmlns:xsi=\\\"http://www.w3.org/2001/XMLSchema-instance\\\" \" \n        \"xmlns:ipxact=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014\\\" \"\n        \"xmlns:kactus2=\\\"http://kactus2.cs.tut.fi\\\" \"\n        \"xsi:schemaLocation=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/ \"\n        \"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/index.xsd\\\">\"\n            \"<ipxact:vendor>TUT</ipxact:vendor>\"\n            \"<ipxact:library>TestLibrary</ipxact:library>\"\n            \"<ipxact:name>TestAbsDef</ipxact:name>\"\n            \"<ipxact:version>1.0</ipxact:version>\"\n            \"<ipxact:busType vendor=\\\"TUT\\\" library=\\\"TestLibrary\\\" name=\\\"TargetBusDef\\\" version=\\\"1.0\\\"/>\"\n            \"<ipxact:ports>\"\n                \"<ipxact:port>\"                \n                    \"<ipxact:logicalName>testPort</ipxact:logicalName>\"\n                    \"<ipxact:transactional>\"                    \n                        \"<ipxact:onMaster>\"\n                            \"<ipxact:protocol>\"\n                                \"<ipxact:protocolType>tlm</ipxact:protocolType>\"\n                                \"<ipxact:payload>\"\n                                    \"<ipxact:name>data</ipxact:name>\"\n                                    \"<ipxact:type>generic</ipxact:type>\"\n                                    \"<ipxact:extension mandatory=\\\"true\\\">extension</ipxact:extension>\"\n                                    \"<ipxact:vendorExtensions>\"\n                                        \"<testExtension vendorAttribute=\\\"extension\\\">testValue</testExtension>\"\n                                    \"</ipxact:vendorExtensions>\"\n                                \"</ipxact:payload>\"\n                            \"</ipxact:protocol>\"\n                        \"</ipxact:onMaster>\" \n                    \"</ipxact:transactional>\"\n                \"</ipxact:port>\"\n            \"</ipxact:ports>\"\n        \"</ipxact:abstractionDefinition>\"));\n\n    QSharedPointer<AbstractionDefinition> testDefinition = AbstractionDefinitionReader::createAbstractionDefinitionFrom(document);\n\n    QSharedPointer<PortAbstraction> port = testDefinition->getLogicalPorts()->first();\n\n    QCOMPARE(port->hasTransactional(), true);\n    QSharedPointer<TransactionalAbstraction> transactional = port->getTransactional();\n\n    QCOMPARE(transactional->hasMasterPort(), true);\n    QSharedPointer<TransactionalPort> master = transactional->getMasterPort();\n\n    QCOMPARE(master->hasProtocol(), true);\n    QSharedPointer<Protocol> protocol = master->getProtocol();\n   \n    QCOMPARE(protocol->getProtocolType(), QString(\"tlm\"));\n    QCOMPARE(protocol->getPayloadName(), QString(\"data\"));\n    QCOMPARE(protocol->getPayloadType(), QString(\"generic\"));\n    QCOMPARE(protocol->getPayloadExtension(), QString(\"extension\"));\n    QCOMPARE(protocol->hasMandatoryPayloadExtension(), true);\n\n    QCOMPARE(protocol->getVendorExtensions()->count(), 1);\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_AbstractionDefinitionReader::testReadTransactionalWithCustomProtocol()\n//-----------------------------------------------------------------------------\nvoid tst_AbstractionDefinitionReader::testReadTransactionalWithCustomProtocol()\n{\n    QDomDocument document;\n    document.setContent(QString(        \n        \"<?xml version=\\\"1.0\\\"?>\"\n        \"<ipxact:abstractionDefinition xmlns:xsi=\\\"http://www.w3.org/2001/XMLSchema-instance\\\" \" \n            \"xmlns:ipxact=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014\\\" \"\n            \"xmlns:kactus2=\\\"http://kactus2.cs.tut.fi\\\" \"\n            \"xsi:schemaLocation=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/ \"\n            \"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/index.xsd\\\">\"\n            \"<ipxact:vendor>TUT</ipxact:vendor>\"\n            \"<ipxact:library>TestLibrary</ipxact:library>\"\n            \"<ipxact:name>TestAbsDef</ipxact:name>\"\n            \"<ipxact:version>1.0</ipxact:version>\"\n            \"<ipxact:busType vendor=\\\"TUT\\\" library=\\\"TestLibrary\\\" name=\\\"TargetBusDef\\\" version=\\\"1.0\\\"/>\"\n            \"<ipxact:ports>\"\n                \"<ipxact:port>\"                \n                    \"<ipxact:logicalName>testPort</ipxact:logicalName>\"\n                    \"<ipxact:transactional>\"                    \n                        \"<ipxact:onMaster>\"\n                            \"<ipxact:protocol>\"\n                                \"<ipxact:protocolType custom=\\\"customProtocol\\\">custom</ipxact:protocolType>\"                        \n                            \"</ipxact:protocol>\"\n                        \"</ipxact:onMaster>\" \n                    \"</ipxact:transactional>\"\n                \"</ipxact:port>\"\n            \"</ipxact:ports>\"\n        \"</ipxact:abstractionDefinition>\"));\n\n    QSharedPointer<AbstractionDefinition> testDefinition = AbstractionDefinitionReader::createAbstractionDefinitionFrom(document);\n\n    QSharedPointer<PortAbstraction> port = testDefinition->getLogicalPorts()->first();\n\n    QCOMPARE(port->hasTransactional(), true);\n    QSharedPointer<TransactionalAbstraction> transactional = port->getTransactional();\n\n    QCOMPARE(transactional->hasMasterPort(), true);\n    QSharedPointer<TransactionalPort> master = transactional->getMasterPort();\n\n    QCOMPARE(master->hasProtocol(), true);\n    QSharedPointer<Protocol> protocol = master->getProtocol();\n\n    QCOMPARE(protocol->getProtocolType(), QString(\"custom\"));\n    QCOMPARE(protocol->getCustomProtocolType(), QString(\"customProtocol\"));\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_AbstractionDefinitionReader::testReadChoices()\n//-----------------------------------------------------------------------------\nvoid tst_AbstractionDefinitionReader::testReadChoices()\n{\n    QDomDocument document;\n    document.setContent(QString(\n        \"<?xml version=\\\"1.0\\\"?>\"\n        \"<ipxact:abstractionDefinition xmlns:xsi=\\\"http://www.w3.org/2001/XMLSchema-instance\\\" \"\n        \"xmlns:ipxact=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2022\\\" \"\n        \"xmlns:kactus2=\\\"http://kactus2.cs.tut.fi\\\" \"\n        \"xsi:schemaLocation=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2022/ \"\n        \"http://www.accellera.org/XMLSchema/IPXACT/1685-2022/index.xsd\\\">\"\n            \"<ipxact:vendor>TUT</ipxact:vendor>\"\n            \"<ipxact:library>TestLibrary</ipxact:library>\"\n            \"<ipxact:name>TestDefinition</ipxact:name>\"\n            \"<ipxact:version>1.0</ipxact:version>\"\n            \"<ipxact:choices>\"\n                \"<ipxact:choice>\"\n                    \"<ipxact:name>bitsize</ipxact:name>\"\n                    \"<ipxact:enumeration text=\\\"32 bits\\\">32</ipxact:enumeration>\"\n                    \"<ipxact:enumeration text=\\\"64 bits\\\">64</ipxact:enumeration>\"\n                \"</ipxact:choice>\"\n                \"<ipxact:choice>\"\n                    \"<ipxact:name>testChoice</ipxact:name>\"\n                    \"<ipxact:enumeration text=\\\"some bits\\\">some</ipxact:enumeration>\"\n                    \"<ipxact:enumeration text=\\\"lots of bits\\\">lots</ipxact:enumeration>\"\n                \"</ipxact:choice>\"\n            \"</ipxact:choices>\"\n        \"</ipxact:abstractionDefinition>\"));\n\n    QSharedPointer<AbstractionDefinition> testDefinition = AbstractionDefinitionReader::createAbstractionDefinitionFrom(document);\n\n    QCOMPARE(testDefinition->getChoices()->count(), 2);\n\n    auto choice1 = testDefinition->getChoices()->at(0);\n    auto choice2 = testDefinition->getChoices()->at(1);\n\n    QCOMPARE(choice1->name(), QString(\"bitsize\"));\n    QCOMPARE(choice1->enumerations()->count(), 2);\n    QCOMPARE(choice1->enumerations()->at(0)->getValue(), QString(\"32\"));\n    QCOMPARE(choice1->enumerations()->at(1)->getValue(), QString(\"64\"));\n    QCOMPARE(choice1->enumerations()->at(1)->getText(), QString(\"64 bits\"));\n    \n    QCOMPARE(choice2->name(), QString(\"testChoice\"));\n    QCOMPARE(choice2->enumerations()->count(), 2);\n    QCOMPARE(choice2->enumerations()->at(0)->getValue(), QString(\"some\"));\n    QCOMPARE(choice2->enumerations()->at(1)->getValue(), QString(\"lots\"));\n    QCOMPARE(choice2->enumerations()->at(1)->getText(), QString(\"lots of bits\"));\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_AbstractionDefinitionReader::testReadParameters()\n//-----------------------------------------------------------------------------\nvoid tst_AbstractionDefinitionReader::testReadParameters()\n{\n    QDomDocument document;\n    document.setContent(QString(        \n        \"<?xml version=\\\"1.0\\\"?>\"\n        \"<ipxact:abstractionDefinition xmlns:xsi=\\\"http://www.w3.org/2001/XMLSchema-instance\\\" \" \n        \"xmlns:ipxact=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014\\\" \"\n        \"xmlns:kactus2=\\\"http://kactus2.cs.tut.fi\\\" \"\n        \"xsi:schemaLocation=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/ \"\n        \"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/index.xsd\\\">\"\n            \"<ipxact:vendor>TUT</ipxact:vendor>\"\n            \"<ipxact:library>TestLibrary</ipxact:library>\"\n            \"<ipxact:name>TestDefinition</ipxact:name>\"\n            \"<ipxact:version>1.0</ipxact:version>\"\n            \"<ipxact:parameters>\"\n                \"<ipxact:parameter>\"\n                    \"<ipxact:name>parameter1</ipxact:name>\"\n                    \"<ipxact:value>1</ipxact:value>\"\n                \"</ipxact:parameter>\"     \n                \"<ipxact:parameter>\"\n                    \"<ipxact:name>parameter2</ipxact:name>\"\n                    \"<ipxact:value>text</ipxact:value>\"\n                \"</ipxact:parameter>\"   \n            \"</ipxact:parameters>\"\n        \"</ipxact:abstractionDefinition>\"));\n\n    QSharedPointer<AbstractionDefinition> testDefinition = AbstractionDefinitionReader::createAbstractionDefinitionFrom(document);\n\n    QCOMPARE(testDefinition->getParameters()->count(), 2);\n    \n    QSharedPointer<Parameter> testParameter = testDefinition->getParameters()->first();\n    QCOMPARE(testParameter->name(), QString(\"parameter1\"));\n    QCOMPARE(testParameter->getValue(), QString(\"1\"));\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_AbstractionDefinitionReader::testReadParametersNewStd()\n//-----------------------------------------------------------------------------\nvoid tst_AbstractionDefinitionReader::testReadParametersNewStd()\n{\n    QDomDocument document;\n    document.setContent(QString(\n        \"<?xml version=\\\"1.0\\\"?>\"\n        \"<ipxact:abstractionDefinition xmlns:xsi=\\\"http://www.w3.org/2001/XMLSchema-instance\\\" \"\n        \"xmlns:ipxact=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2022\\\" \"\n        \"xmlns:kactus2=\\\"http://kactus2.cs.tut.fi\\\" \"\n        \"xsi:schemaLocation=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2022/ \"\n        \"http://www.accellera.org/XMLSchema/IPXACT/1685-2022/index.xsd\\\">\"\n            \"<ipxact:vendor>TUT</ipxact:vendor>\"\n            \"<ipxact:library>TestLibrary</ipxact:library>\"\n            \"<ipxact:name>TestDefinition</ipxact:name>\"\n            \"<ipxact:version>1.0</ipxact:version>\"\n            \"<ipxact:parameters>\"\n                \"<ipxact:parameter>\"\n                    \"<ipxact:name>parameter1</ipxact:name>\"\n                    \"<ipxact:value>1</ipxact:value>\"\n                    \"<ipxact:vectors>\"\n                        \"<ipxact:vector vectorId=\\\"testVector\\\">\"\n                            \"<ipxact:left>3</ipxact:left>\"\n                            \"<ipxact:right>0</ipxact:right>\"\n                        \"</ipxact:vector>\"\n                    \"</ipxact:vectors>\"\n                \"</ipxact:parameter>\"\n            \"</ipxact:parameters>\"\n        \"</ipxact:abstractionDefinition>\"));\n\n    QSharedPointer<AbstractionDefinition> testDefinition = AbstractionDefinitionReader::createAbstractionDefinitionFrom(document);\n\n    QCOMPARE(testDefinition->getParameters()->count(), 1);\n\n    QSharedPointer<Parameter> testParameter = testDefinition->getParameters()->first();\n    QCOMPARE(testParameter->name(), QString(\"parameter1\"));\n    QCOMPARE(testParameter->getValue(), QString(\"1\"));\n\n    auto testVector = testParameter->getVectors()->first();\n    QCOMPARE(testVector->getId(), QString(\"testVector\"));\n    QCOMPARE(testVector->getLeft(), QString(\"3\"));\n    QCOMPARE(testVector->getRight(), QString(\"0\"));\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_AbstractionDefinitionReader::testReadAssertions()\n//-----------------------------------------------------------------------------\nvoid tst_AbstractionDefinitionReader::testReadAssertions()\n{\n    QDomDocument document;\n    document.setContent(QString(        \n        \"<?xml version=\\\"1.0\\\"?>\"\n        \"<ipxact:abstractionDefinition xmlns:xsi=\\\"http://www.w3.org/2001/XMLSchema-instance\\\" \" \n        \"xmlns:ipxact=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014\\\" \"\n        \"xmlns:kactus2=\\\"http://kactus2.cs.tut.fi\\\" \"\n        \"xsi:schemaLocation=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/ \"\n        \"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/index.xsd\\\">\"\n            \"<ipxact:vendor>TUT</ipxact:vendor>\"\n            \"<ipxact:library>TestLibrary</ipxact:library>\"\n            \"<ipxact:name>TestDefinition</ipxact:name>\"\n            \"<ipxact:version>1.0</ipxact:version>\"\n            \"<ipxact:assertions>\"\n                \"<ipxact:assertion>\"\n                    \"<ipxact:name>testAssert</ipxact:name>\"\n                    \"<ipxact:displayName>testable assert</ipxact:displayName>\"\n                    \"<ipxact:description>description for assertion</ipxact:description>\"\n                    \"<ipxact:assert>1</ipxact:assert>\"\n                \"</ipxact:assertion>\"     \n            \"</ipxact:assertions>\"\n        \"</ipxact:abstractionDefinition>\"));\n\n    QSharedPointer<AbstractionDefinition> TestDefinition = AbstractionDefinitionReader::createAbstractionDefinitionFrom(document);\n\n    QCOMPARE(TestDefinition->getAssertions()->count(), 1);\n\n    QSharedPointer<Assertion> testAssertion = TestDefinition->getAssertions()->first();\n    QCOMPARE(testAssertion->name(), QString(\"testAssert\"));\n    QCOMPARE(testAssertion->displayName(), QString(\"testable assert\"));\n    QCOMPARE(testAssertion->description(), QString(\"description for assertion\"));\n    QCOMPARE(testAssertion->getAssert(), QString(\"1\"));\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_AbstractionDefinitionReader::testReadVendorExtension()\n//-----------------------------------------------------------------------------\nvoid tst_AbstractionDefinitionReader::testReadVendorExtension()\n{\n    QDomDocument document;\n    document.setContent(QString(\n        \"<?xml version=\\\"1.0\\\"?>\"\n        \"<ipxact:abstractionDefinition xmlns:xsi=\\\"http://www.w3.org/2001/XMLSchema-instance\\\" \" \n        \"xmlns:ipxact=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014\\\" \"\n        \"xmlns:kactus2=\\\"http://kactus2.cs.tut.fi\\\" \"\n        \"xsi:schemaLocation=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/ \"\n        \"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/index.xsd\\\">\"\n            \"<ipxact:vendor>TUT</ipxact:vendor>\"\n            \"<ipxact:library>TestLibrary</ipxact:library>\"\n            \"<ipxact:name>TestDefinition</ipxact:name>\"\n            \"<ipxact:version>1.0</ipxact:version>\"\n            \"<ipxact:vendorExtensions>\"\n                \"<kactus2:version>3.0.0</kactus2:version>\"\n                \"<testExtension vendorAttribute=\\\"extension\\\">testValue</testExtension>\"\n            \"</ipxact:vendorExtensions>\"\n        \"</ipxact:abstractionDefinition>\"));\n\n    QSharedPointer<AbstractionDefinition> TestDefinition = AbstractionDefinitionReader::createAbstractionDefinitionFrom(document);\n\n    QCOMPARE(TestDefinition->getVendorExtensions()->count(), 2);\n    QCOMPARE(TestDefinition->getVersion(), QString(\"3.0.0\"));\n}\n\n\nQTEST_APPLESS_MAIN(tst_AbstractionDefinitionReader)\n\n#include \"tst_AbstractionDefinitionReader.moc\"\n"
  },
  {
    "path": "tests/IPXACTmodels/AbstractionDefinition/tst_AbstractionDefinitionReader.pri",
    "content": "# ----------------------------------------------------\r\n# This file is generated by the Qt Visual Studio Tools.\r\n# ------------------------------------------------------\r\n\r\nSOURCES += ./tst_AbstractionDefinitionReader.cpp \r\n\t"
  },
  {
    "path": "tests/IPXACTmodels/AbstractionDefinition/tst_AbstractionDefinitionReader.pro",
    "content": "#-----------------------------------------------------------------------------\r\n# File: tst_AbstractionDefinitionReader.pro\r\n#-----------------------------------------------------------------------------\r\n# Project: Kactus 2\r\n# Author: Esko Pekkarinen\r\n# Date: 03.08.2015\r\n#\r\n# Description:\r\n# Qt project file template for running unit tests for class AbstractionDefinition.\r\n#-----------------------------------------------------------------------------\r\n\r\nTEMPLATE = app\r\n\r\nTARGET = tst_AbstractionDefinitionReader\r\n\r\nQT += core xml testlib\r\nQT -= gui\r\n\r\nCONFIG += c++11 testcase console\r\n\r\nlinux-g++ | linux-g++-64 | linux-g++-32 {\r\n LIBS += -L../../../executable \\\r\n     -lIPXACTmodels\r\n\r\n}\r\nwin64 | win32 {\r\n LIBS += -L../../../executable/ \\\r\n     -lIPXACTmodelsd\r\n}\r\n\r\nDESTDIR = ./release\r\n\r\nINCLUDEPATH += $$DESTDIR\r\nINCLUDEPATH += ../../../\r\n\r\nDEPENDPATH += .\r\n\r\nOBJECTS_DIR += $$DESTDIR\r\n\r\nMOC_DIR += ./generatedFiles\r\nUI_DIR += ./generatedFiles\r\nRCC_DIR += ./generatedFiles\r\n\r\ninclude(tst_AbstractionDefinitionReader.pri)\r\n"
  },
  {
    "path": "tests/IPXACTmodels/AbstractionDefinition/tst_AbstractionDefinitionValidator.cpp",
    "content": "//-----------------------------------------------------------------------------\n// AbstractionDefinition: tst_AbstractionDefinitionValidator.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Janne Virtanen\n// Date: 04.12.2015\n//\n// Description:\n// Unit test for class AbstractionDefinitionValidator.\n//-----------------------------------------------------------------------------\n\n#include <IPXACTmodels/AbstractionDefinition/AbstractionDefinition.h>\n#include <IPXACTmodels/AbstractionDefinition/PortAbstraction.h>\n#include <IPXACTmodels/AbstractionDefinition/WireAbstraction.h>\n#include <IPXACTmodels/AbstractionDefinition/TransactionalAbstraction.h>\n#include <IPXACTmodels/AbstractionDefinition/validators/AbstractionDefinitionValidator.h>\n#include <IPXACTmodels/AbstractionDefinition/Packet.h>\n\n#include <IPXACTmodels/BusDefinition/BusDefinition.h>\n\n#include <IPXACTmodels/common/TimingConstraint.h>\n#include <IPXACTmodels/common/CellSpecification.h>\n\n#include <KactusAPI/include/SystemVerilogExpressionParser.h>\n\n#include <tests/MockObjects/LibraryMock.h>\n\n#include <QtTest>\n\nclass tst_AbstractionDefinitionValidator : public QObject\n{\n\tQ_OBJECT\n\npublic:\n    tst_AbstractionDefinitionValidator();\n\nprivate slots:\n\tvoid baseCase();\n\tvoid vlnvFail();\n\tvoid busFail();\n\tvoid extendFail();\n    void extendedBusType();\n\n    void getPortsFromExtendAbstraction();\n    void testExtendedPortsNonEditableParameters();\n\n\tvoid paraFail();\n\tvoid paraPassStd22();\n\tvoid portFail();\n\n\tvoid portMatchOnlyInStd22();\n\n\tvoid wireFail();\n\tvoid noDublicatePorts();\n\tvoid invalidWirePort();\n\tvoid invalidTransactionalPort();\n\tvoid invalidTimingConstraint();\n\tvoid invalidCellSpec();\n\tvoid wirePortSuccessful();\n\tvoid transactionalSuccessful();\n    void systemWirePortHasGroup();\n\n\tvoid wireQualifier();\n\tvoid packetsOnlyInStd22();\n    void invalidPacketFieldWidthValue();\n    void packetFieldValueWhenOpcode();\n\tvoid choicesOnlyInStd22();\n\nprivate:\n\t//! The test mock for library interface.\n\tLibraryMock* library_;\n\n    QSharedPointer<ExpressionParser> expressionParser_;\n\n\t//! VLNV for some bus referred by the abstraction definition.\n\tVLNV testBusDefVlnv_;\n\n\t//! Some valid abstraction port within the abstraction definition.\n\tQSharedPointer<PortAbstraction> port_;\n};\n\n//-----------------------------------------------------------------------------\n// Function: tst_AbstractionDefinitionValidator::tst_AbstractionDefinitionValidator()\n//-----------------------------------------------------------------------------\ntst_AbstractionDefinitionValidator::tst_AbstractionDefinitionValidator() :\nlibrary_(new LibraryMock(this)), expressionParser_(new SystemVerilogExpressionParser())\n{\n\ttestBusDefVlnv_ = VLNV(VLNV::BUSDEFINITION,\"vendor\",\"library\",\"test_bus_def\",\"version\");\n\tQSharedPointer<BusDefinition> testBusDef(new BusDefinition(testBusDefVlnv_, Document::Revision::Std14));\n\tlibrary_->addComponent(testBusDef);\n\n\tport_ = QSharedPointer<PortAbstraction>(new PortAbstraction);\n\tport_->setLogicalName(\"trvv\");\n\n\tQSharedPointer<WireAbstraction> wire(new WireAbstraction);\n\tport_->setWire(wire);\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_AbstractionDefinitionValidator::baseCase()\n//-----------------------------------------------------------------------------\nvoid tst_AbstractionDefinitionValidator::baseCase()\n{\n\tVLNV vlnv(VLNV::ABSTRACTIONDEFINITION, \"vendor\", \"library\", \"name\", \"version\");\n\tQSharedPointer<AbstractionDefinition> abs(new AbstractionDefinition(vlnv, Document::Revision::Std14));\n\tAbstractionDefinitionValidator validator(library_, expressionParser_);\n\n\tabs->setBusType(testBusDefVlnv_);\n\tabs->getLogicalPorts()->append(port_);\n\n\tQVector<QString> errorList;\n\tvalidator.findErrorsIn(errorList, abs);\n\n\tQCOMPARE(errorList.size(), 0);\n\tQVERIFY(validator.validate(abs));\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_AbstractionDefinitionValidator::vlnvFail()\n//-----------------------------------------------------------------------------\nvoid tst_AbstractionDefinitionValidator::vlnvFail()\n{\n\tQSharedPointer<AbstractionDefinition> abs(new AbstractionDefinition(VLNV(VLNV::INVALID, \"a\", \"b\", \"c\", \"d\"), Document::Revision::Std14));\n\tAbstractionDefinitionValidator validator(library_, expressionParser_);\n\n\tabs->setBusType(testBusDefVlnv_);\n\tabs->getLogicalPorts()->append(port_);\n\n\tQVector<QString> errorList;\n\tvalidator.findErrorsIn(errorList, abs);\n\n\tQCOMPARE(errorList.size(), 1);\n\tQVERIFY(!validator.validate(abs));\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_AbstractionDefinitionValidator::busFail()\n//-----------------------------------------------------------------------------\nvoid tst_AbstractionDefinitionValidator::busFail()\n{\n    VLNV vlnv(VLNV::ABSTRACTIONDEFINITION, \"vendor\", \"library\", \"name\", \"version\");\n    QSharedPointer<AbstractionDefinition> abs(new AbstractionDefinition(vlnv, Document::Revision::Std14));\n    AbstractionDefinitionValidator validator(library_, expressionParser_);\n\n\tabs->setBusType(VLNV(VLNV::BUSDEFINITION,\"vendor\",\"library\",\"bogus\",\"version\"));\n\tabs->getLogicalPorts()->append(port_);\n\n\tQVector<QString> errorList;\n\tvalidator.findErrorsIn(errorList, abs);\n\n\tQCOMPARE(errorList.size(), 1);\n\tQVERIFY(!validator.validate(abs));\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_AbstractionDefinitionValidator::extendFail()\n//-----------------------------------------------------------------------------\nvoid tst_AbstractionDefinitionValidator::extendFail()\n{\n    VLNV vlnv(VLNV::ABSTRACTIONDEFINITION, \"vendor\", \"library\", \"name\", \"version\");\n    QSharedPointer<AbstractionDefinition> abs(new AbstractionDefinition(vlnv, Document::Revision::Std14));\n    AbstractionDefinitionValidator validator(library_, expressionParser_);\n\n\tabs->setBusType(testBusDefVlnv_);\n\tabs->getLogicalPorts()->append(port_);\n\n\tabs->setExtends(VLNV(VLNV::ABSTRACTIONDEFINITION,\"vendor\",\"library\",\"bogus\",\"version\"));\n\n\tQVector<QString> errorList;\n\tvalidator.findErrorsIn(errorList, abs);\n\n    QCOMPARE(errorList.size(), 1);\n    QCOMPARE(errorList.first(), QLatin1String(\"The bus definition vendor:library:bogus:version extended in \"\n        \"abstraction definition vendor:library:name:version is not found in the library\"));\n\tQVERIFY(!validator.validate(abs));\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_AbstractionDefinitionValidator::extendedBusType()\n//-----------------------------------------------------------------------------\nvoid tst_AbstractionDefinitionValidator::extendedBusType()\n{\n    VLNV extendBusVLNV(VLNV::BUSDEFINITION, \"vendor\", \"library\", \"extend_test_bus_def\", \"version\");\n    QSharedPointer<BusDefinition> extendBusDef(new BusDefinition(extendBusVLNV, Document::Revision::Std14));\n\n    VLNV busVLNV(VLNV::BUSDEFINITION, \"vendor\", \"library\", \"test_bus_def\", \"version\");\n    QSharedPointer<BusDefinition> busDef(new BusDefinition(busVLNV, Document::Revision::Std14));\n\n    VLNV extendAbsVLNV(VLNV::ABSTRACTIONDEFINITION, \"vendor\", \"library\", \"bogus\", \"version\");\n    QSharedPointer<AbstractionDefinition> extendAbs(new AbstractionDefinition(extendAbsVLNV, Document::Revision::Std14));\n    extendAbs->setBusType(extendBusVLNV);\n\n    VLNV absVLNV(VLNV::ABSTRACTIONDEFINITION, \"vendor\", \"library\", \"name\", \"version\");\n    QSharedPointer<AbstractionDefinition> abs(new AbstractionDefinition(absVLNV, Document::Revision::Std14));\n\n    abs->setBusType(busVLNV);\n    abs->getLogicalPorts()->append(port_);\n    abs->setExtends(extendAbsVLNV);\n\n    library_->addComponent(extendBusDef);\n    library_->addComponent(extendAbs);\n    library_->addComponent(busDef);\n    library_->addComponent(abs);\n    \n    AbstractionDefinitionValidator validator(library_, expressionParser_);\n\n    QString extendError = \"The bus definition vendor:library:test_bus_def:version extended in abstraction \"\n        \"definition vendor:library:name:version does not define extended abstraction definition bus type\";\n\n    QVector<QString> errorList;\n    validator.findErrorsIn(errorList, abs);\n    QCOMPARE(errorList.size(), 1);\n    QCOMPARE(errorList.last(), extendError);\n    QVERIFY(!validator.validate(abs));\n\n    busDef->setExtends(extendBusVLNV);\n    errorList.clear();\n    validator.findErrorsIn(errorList, abs);\n    QCOMPARE(errorList.size(), 0);\n    QVERIFY(validator.validate(abs));\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_AbstractionDefinitionValidator::getPortsFromExtendAbstraction()\n//-----------------------------------------------------------------------------\nvoid tst_AbstractionDefinitionValidator::getPortsFromExtendAbstraction()\n{\n    VLNV extendBusVLNV(VLNV::BUSDEFINITION, \"vendor\", \"library\", \"extend_test_bus_def\", \"version\");\n    QSharedPointer<BusDefinition> extendBusDef(new BusDefinition(extendBusVLNV, Document::Revision::Std14));\n\n    VLNV busVLNV(VLNV::BUSDEFINITION, \"vendor\", \"library\", \"test_bus_def\", \"version\");\n\tQSharedPointer<BusDefinition> busDef(new BusDefinition(busVLNV, Document::Revision::Std14));\n    busDef->setExtends(extendBusVLNV);\n\n    VLNV extendAbsVLNV(VLNV::ABSTRACTIONDEFINITION, \"vendor\", \"library\", \"bogus\", \"version\");\n    QSharedPointer<AbstractionDefinition> extendAbs(new AbstractionDefinition(extendAbsVLNV, Document::Revision::Std14));\n    extendAbs->setBusType(extendBusVLNV);\n    extendAbs->getLogicalPorts()->append(port_);\n\n    VLNV absVLNV(VLNV::ABSTRACTIONDEFINITION, \"vendor\", \"library\", \"name\", \"version\");\n    QSharedPointer<AbstractionDefinition> abs(new AbstractionDefinition(absVLNV, Document::Revision::Std14));\n    abs->setBusType(busVLNV);\n    abs->setExtends(extendAbsVLNV);\n\n    for (auto logicalPort : *extendAbs->getLogicalPorts())\n    {\n        abs->getLogicalPorts()->append(logicalPort);\n    }\n\n    library_->addComponent(extendBusDef);\n    library_->addComponent(extendAbs);\n    library_->addComponent(busDef);\n    library_->addComponent(abs);\n\n    AbstractionDefinitionValidator validator(library_, expressionParser_);\n\n    QVector<QString> errorList;\n    validator.findErrorsIn(errorList, abs);\n    QCOMPARE(errorList.size(), 0);\n    QVERIFY(validator.validate(abs));\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_AbstractionDefinitionValidator::testExtendedPortsNonEditableParameters()\n//-----------------------------------------------------------------------------\nvoid tst_AbstractionDefinitionValidator::testExtendedPortsNonEditableParameters()\n{\n    QStringList extendBusDefSystemGroups(\"system\");\n\n    VLNV extendBusVLNV(VLNV::BUSDEFINITION, \"vendor\", \"library\", \"extend_test_bus_def\", \"version\");\n    QSharedPointer<BusDefinition> extendBusDef(new BusDefinition(extendBusVLNV, Document::Revision::Std14));\n    extendBusDef->setSystemGroupNames(extendBusDefSystemGroups);\n\n    VLNV busVLNV(VLNV::BUSDEFINITION, \"vendor\", \"library\", \"test_bus_def\", \"version\");\n    QSharedPointer<BusDefinition> busDef(new BusDefinition(busVLNV, Document::Revision::Std14));\n    busDef->setExtends(extendBusVLNV);\n\n    QSharedPointer<WirePort> wirePort(new WirePort());\n    wirePort->setDirection(DirectionTypes::IN);\n    wirePort->setPresence(PresenceTypes::REQUIRED);\n    wirePort->setWidth(\"10\");\n    wirePort->setSystemGroup(extendBusDefSystemGroups.first());\n\n    QSharedPointer<WireAbstraction> extendWire(new WireAbstraction());\n    extendWire->getSystemPorts()->append(wirePort);\n    extendWire->setDefaultValue(\"0\");\n    extendWire->addQualifier(Qualifier::Type::Data);\n\n    QSharedPointer<PortAbstraction> extendWirePort(new PortAbstraction());\n    extendWirePort->setName(\"ExtendWire\");\n    extendWirePort->setDescription(\"wireDescription\");\n    extendWirePort->setWire(extendWire);\n\n    QSharedPointer<Protocol> transactionalProtocol(new Protocol());\n    transactionalProtocol->setProtocolType(\"protocolType\");\n    transactionalProtocol->setPayloadName(\"payDay\");\n    transactionalProtocol->setPayloadType(\"generic\");\n    transactionalProtocol->setPayloadExtension(\"extend\", false);\n\n    QSharedPointer<TransactionalPort> transactionalPort(new TransactionalPort());\n    transactionalPort->setPresence(PresenceTypes::REQUIRED);\n    transactionalPort->setInitiative(\"requires\");\n    transactionalPort->setKind(\"tlm_port\");\n    transactionalPort->setBusWidth(\"3\");\n    transactionalPort->setSystemGroup(extendBusDefSystemGroups.first());\n    transactionalPort->setProtocol(transactionalProtocol);\n\n    QSharedPointer<TransactionalAbstraction> extendTransactional(new TransactionalAbstraction());\n    extendTransactional->addQualifier(Qualifier::Type::Data);\n    extendTransactional->getSystemPorts()->append(transactionalPort);\n\n    QSharedPointer<PortAbstraction> extendTransactionalPort(new PortAbstraction());\n    extendTransactionalPort->setName(\"extendTransactional\");\n    extendTransactionalPort->setDescription(\"transactionalDescription\");\n    extendTransactionalPort->setTransactional(extendTransactional);\n\n    VLNV extendAbsVLNV(VLNV::ABSTRACTIONDEFINITION, \"vendor\", \"library\", \"bogus\", \"version\");\n    QSharedPointer<AbstractionDefinition> extendAbs(new AbstractionDefinition(extendAbsVLNV, Document::Revision::Std14));\n    extendAbs->setBusType(extendBusVLNV);\n    extendAbs->getLogicalPorts()->append(extendWirePort);\n    extendAbs->getLogicalPorts()->append(extendTransactionalPort);\n\n    VLNV absVLNV(VLNV::ABSTRACTIONDEFINITION, \"vendor\", \"library\", \"name\", \"version\");\n    QSharedPointer<AbstractionDefinition> abs(new AbstractionDefinition(absVLNV, Document::Revision::Std14));\n    abs->setBusType(busVLNV);\n    abs->setExtends(extendAbsVLNV);\n\n    QSharedPointer<PortAbstraction> absWirePort(new PortAbstraction(*extendWirePort.data()));\n    QSharedPointer<PortAbstraction> absTransactionalPort(new PortAbstraction(*extendTransactionalPort.data()));\n    abs->getLogicalPorts()->append(absWirePort);\n    abs->getLogicalPorts()->append(absTransactionalPort);\n\n    library_->addComponent(extendBusDef);\n    library_->addComponent(extendAbs);\n    library_->addComponent(busDef);\n    library_->addComponent(abs);\n\n    AbstractionDefinitionValidator validator(library_, expressionParser_);\n\n    QVector<QString> errorList;\n    validator.findErrorsIn(errorList, abs);\n\n    QCOMPARE(errorList.size(), 0);\n    QVERIFY(validator.validate(abs));\n\n    wirePort->setDirection(DirectionTypes::OUT);\n    extendWire->addQualifier(Qualifier::Type::Address);\n    extendWirePort->setDescription(\"newExtendWireDescription\");\n    transactionalPort->setInitiative(\"provides\");\n    transactionalPort->setKind(\"tlm_socket\");\n    transactionalPort->setBusWidth(\"4\");\n    transactionalProtocol->setProtocolType(\"newProtocol\");\n    transactionalProtocol->setPayloadName(\"newPayment\");\n    transactionalProtocol->setPayloadType(\"specific\");\n    transactionalProtocol->setPayloadExtension(\"extends\", false);\n\n    errorList.clear();\n    validator.findErrorsIn(errorList, abs);\n    QVERIFY(validator.validate(extendAbs));\n    QVERIFY(validator.validate(abs) == false);\n\n    QCOMPARE(errorList.size(), 9);\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_AbstractionDefinitionValidator::paraFail()\n//-----------------------------------------------------------------------------\nvoid tst_AbstractionDefinitionValidator::paraFail()\n{\n\tVLNV vlnv = VLNV(VLNV::ABSTRACTIONDEFINITION, \"vendor\", \"library\", \"name\", \"version\");\n\tQSharedPointer<AbstractionDefinition> abs(new AbstractionDefinition(vlnv, Document::Revision::Std14));\n\tAbstractionDefinitionValidator validator(library_, expressionParser_);\n\tabs->setBusType(testBusDefVlnv_);\n\tabs->getLogicalPorts()->append(port_);\n\n\tQSharedPointer<Parameter> parameter (new Parameter());\n\tparameter->setName(\"param\");\n\tparameter->setType(\"bit\");\n\tparameter->setValue(\"{'b11, 'b00}\");\n\tparameter->setValueId(\"parameterid\");\n\tparameter->setVectorLeft(\"4\");\n\tparameter->setVectorRight(\"0\");\n\tparameter->setVectorId(\"testId\"); // VectorId is Std22 only\n\n\tabs->getParameters()->append(parameter);\n\n\tQVector<QString> errorList;\n\tvalidator.findErrorsIn(errorList, abs);\n\n\tQCOMPARE(errorList.size(), 2);\n\tQVERIFY(!validator.validate(abs));\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_AbstractionDefinitionValidator::paraPassStd22()\n//-----------------------------------------------------------------------------\nvoid tst_AbstractionDefinitionValidator::paraPassStd22()\n{\n    VLNV vlnv = VLNV(VLNV::ABSTRACTIONDEFINITION, \"vendor\", \"library\", \"name\", \"version\");\n    QSharedPointer<AbstractionDefinition> abs(new AbstractionDefinition(vlnv, Document::Revision::Std22));\n    AbstractionDefinitionValidator validator(library_, expressionParser_);\n    abs->setBusType(testBusDefVlnv_);\n    abs->getLogicalPorts()->append(port_);\n\n    QSharedPointer<Parameter> parameter(new Parameter());\n    parameter->setName(\"param\");\n    parameter->setType(\"bit\");\n    parameter->setValue(\"16\");\n    parameter->setValueId(\"parameterid\");\n    parameter->setVectorLeft(\"4\");\n    parameter->setVectorRight(\"0\");\n    parameter->setVectorId(\"testId\");\n\n    abs->getParameters()->append(parameter);\n\n    QVector<QString> errorList;\n    validator.findErrorsIn(errorList, abs);\n\n    QCOMPARE(errorList.size(), 0);\n    QVERIFY(validator.validate(abs));\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_AbstractionDefinitionValidator::portFail()\n//-----------------------------------------------------------------------------\nvoid tst_AbstractionDefinitionValidator::portFail()\n{\n    VLNV absVLNV(VLNV::ABSTRACTIONDEFINITION, \"vendor\", \"library\", \"name\", \"version\");\n\tQSharedPointer<AbstractionDefinition> abs(new AbstractionDefinition(absVLNV, Document::Revision::Std14));\n\tAbstractionDefinitionValidator validator(library_, expressionParser_);\n\n\tabs->setBusType(testBusDefVlnv_);\n\tabs->getLogicalPorts()->append(port_);\n\n\tQSharedPointer<PortAbstraction> port(new PortAbstraction);\n\tport->setIsPresent(\"eiole\");\n\tabs->getLogicalPorts()->append(port);\n\n\tQVector<QString> errorList;\n\tvalidator.findErrorsIn(errorList, abs);\n\n\tQCOMPARE(errorList.size(), 3);\n\tQVERIFY(!validator.validate(abs));\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_AbstractionDefinitionValidator::portMatchOnlyInStd22()\n//-----------------------------------------------------------------------------\nvoid tst_AbstractionDefinitionValidator::portMatchOnlyInStd22()\n{\n    VLNV absVLNV14(VLNV::ABSTRACTIONDEFINITION, \"vendor\", \"library\", \"name\", \"version\");\n    QSharedPointer<AbstractionDefinition> abs14(new AbstractionDefinition(absVLNV14, Document::Revision::Std14));\n    \n    VLNV absVLNV22(VLNV::ABSTRACTIONDEFINITION, \"vendor\", \"library\", \"name\", \"version\");\n    QSharedPointer<AbstractionDefinition> abs22(new AbstractionDefinition(absVLNV22, Document::Revision::Std22));\n    \n\tVLNV busVLNV22(VLNV::BUSDEFINITION, \"vendor\", \"library\", \"extend_test_bus_def\", \"version\");\n    QSharedPointer<BusDefinition> busDef22(new BusDefinition(busVLNV22, Document::Revision::Std22));\n\tabs22->setBusType(busVLNV22);\n    abs14->setBusType(testBusDefVlnv_);\n\n\tAbstractionDefinitionValidator validator(library_, expressionParser_);\n\t\n    QSharedPointer<PortAbstraction> port14(new PortAbstraction(*port_));\n\tport14->setMatch(true);\n\n    QSharedPointer<WireAbstraction> wire14(new WireAbstraction);\n    port14->setWire(wire14);\n\t\n\tQSharedPointer<PortAbstraction> port22(new PortAbstraction(*port14));\n\tport22->setLogicalName(\"other_name\"); //name must be unique within absDef\n\n    QSharedPointer<WireAbstraction> wire22(new WireAbstraction);\n    port22->setWire(wire22);\n\n\tabs14->getLogicalPorts()->append(port14);\n\tabs22->getLogicalPorts()->append(port22);\n\n    QVector<QString> errorList;\n    validator.findErrorsIn(errorList, abs14);\n\n    QCOMPARE(errorList.size(), 1);\n    QVERIFY(!validator.validate(abs14));\n\terrorList.clear();\n\n    validator.findErrorsIn(errorList, abs22);\n\n    QCOMPARE(errorList.size(), 0);\n    QVERIFY(validator.validate(abs22));\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_AbstractionDefinitionValidator::noDublicatePorts()\n//-----------------------------------------------------------------------------\nvoid tst_AbstractionDefinitionValidator::noDublicatePorts()\n{\n    VLNV absVLNV(VLNV::ABSTRACTIONDEFINITION, \"vendor\", \"library\", \"name\", \"version\");\n    QSharedPointer<AbstractionDefinition> abs(new AbstractionDefinition(absVLNV, Document::Revision::Std14));\n\tAbstractionDefinitionValidator validator(library_, expressionParser_);\n\n\tabs->setBusType(testBusDefVlnv_);\n\tabs->getLogicalPorts()->append(port_);\n\n\tQSharedPointer<WireAbstraction> wire(new WireAbstraction);\n\tQSharedPointer<PortAbstraction> port1(new PortAbstraction);\n\tport1->setLogicalName(\"alias\");\n\tabs->getLogicalPorts()->append(port1);\n\tport1->setWire(wire);\n\n\tQSharedPointer<PortAbstraction> port2(new PortAbstraction);\n\tport2->setLogicalName(\"alias\");\n\tabs->getLogicalPorts()->append(port2);\n\tport2->setWire(wire);\n\n\tQVector<QString> errorList;\n\tvalidator.findErrorsIn(errorList, abs);\n\n\tQCOMPARE(errorList.size(), 1);\n\tQVERIFY(!validator.validate(abs));\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_AbstractionDefinitionValidator::wireFail()\n//-----------------------------------------------------------------------------\nvoid tst_AbstractionDefinitionValidator::wireFail()\n{\n    VLNV absVLNV(VLNV::ABSTRACTIONDEFINITION, \"vendor\", \"library\", \"name\", \"version\");\n    QSharedPointer<AbstractionDefinition> abs(new AbstractionDefinition(absVLNV, Document::Revision::Std14));\n\n\tAbstractionDefinitionValidator validator(library_, expressionParser_);\n\n\tabs->setBusType(testBusDefVlnv_);\n\tabs->getLogicalPorts()->append(port_);\n\n\tQSharedPointer<PortAbstraction> port(new PortAbstraction);\n\tport->setLogicalName(\"nimi\");\n\tabs->getLogicalPorts()->append(port);\n\tQSharedPointer<WireAbstraction> wire(new WireAbstraction);\n\twire->setDefaultValue(\"bogus\");\n\tport->setWire(wire);\n\n\tQVector<QString> errorList;\n\tvalidator.findErrorsIn(errorList, abs);\n\n\tQCOMPARE(errorList.size(), 1);\n\tQVERIFY(!validator.validate(abs));\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_AbstractionDefinitionValidator::invalidWirePort()\n//-----------------------------------------------------------------------------\nvoid tst_AbstractionDefinitionValidator::invalidWirePort()\n{\n    VLNV absVLNV(VLNV::ABSTRACTIONDEFINITION, \"vendor\", \"library\", \"name\", \"version\");\n    QSharedPointer<AbstractionDefinition> abs(new AbstractionDefinition(absVLNV, Document::Revision::Std14));\n\n\tAbstractionDefinitionValidator validator(library_, expressionParser_);\n\n\tabs->setBusType(testBusDefVlnv_);\n\tabs->getLogicalPorts()->append(port_);\n\n\tQSharedPointer<PortAbstraction> port(new PortAbstraction);\n\tport->setLogicalName(\"nimi\");\n\tabs->getLogicalPorts()->append(port);\n\tQSharedPointer<WireAbstraction> wire(new WireAbstraction);\n\tport->setWire(wire);\n\n\tQSharedPointer<WirePort> wirePort(new WirePort);\n\twirePort->setDirection(DirectionTypes::DIRECTION_PHANTOM);\n\twirePort->setPresence(PresenceTypes::UNKNOWN);\n\twirePort->setWidth(\"width\");\n\twire->setMasterPort(wirePort);\n\n\tQVector<QString> errorList;\n\tvalidator.findErrorsIn(errorList, abs);\n\n\tQCOMPARE(errorList.size(), 1);\n\tQVERIFY(!validator.validate(abs));\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_AbstractionDefinitionValidator::invalidTransactionalPort()\n//-----------------------------------------------------------------------------\nvoid tst_AbstractionDefinitionValidator::invalidTransactionalPort()\n{\n    VLNV absVLNV(VLNV::ABSTRACTIONDEFINITION, \"vendor\", \"library\", \"name\", \"version\");\n\tQSharedPointer<AbstractionDefinition> abs(new AbstractionDefinition(absVLNV, Document::Revision::Std14));\n\t\n\tAbstractionDefinitionValidator validator(library_, expressionParser_);\n\n\tabs->setBusType(testBusDefVlnv_);\n\tabs->getLogicalPorts()->append(port_);\n\n\tQSharedPointer<PortAbstraction> port(new PortAbstraction);\n\tport->setLogicalName(\"nimi\");\n\tabs->getLogicalPorts()->append(port);\n\tQSharedPointer<TransactionalAbstraction> transAbs(new TransactionalAbstraction);\n\tport->setTransactional(transAbs);\n\n\tQSharedPointer<TransactionalPort> transPort(new TransactionalPort);\n\ttransPort->setBusWidth(\"yks\");\n\ttransPort->setInitiative(\"init\");\n\ttransPort->setKind(\"joo\");\n\ttransPort->setPresence(PresenceTypes::UNKNOWN);\n\ttransAbs->setMasterPort(transPort);\n\n\tQVector<QString> errorList;\n\tvalidator.findErrorsIn(errorList, abs);\n\n\tQCOMPARE(errorList.size(), 3);\n\tQVERIFY(!validator.validate(abs));\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_AbstractionDefinitionValidator::invalidTimingConstraint()\n//-----------------------------------------------------------------------------\nvoid tst_AbstractionDefinitionValidator::invalidTimingConstraint()\n{\n    VLNV absVLNV(VLNV::ABSTRACTIONDEFINITION, \"vendor\", \"library\", \"name\", \"version\");\n    QSharedPointer<AbstractionDefinition> abs(new AbstractionDefinition(absVLNV, Document::Revision::Std14));\n\n\tAbstractionDefinitionValidator validator(library_, expressionParser_);\n\n\tabs->setBusType(testBusDefVlnv_);\n\tabs->getLogicalPorts()->append(port_);\n\n\tQSharedPointer<PortAbstraction> port(new PortAbstraction);\n\tport->setLogicalName(\"nimi\");\n\tabs->getLogicalPorts()->append(port);\n\tQSharedPointer<WireAbstraction> wire(new WireAbstraction);\n\tport->setWire(wire);\n\n\tQSharedPointer<WirePort> wirePort(new WirePort);\n\twirePort->setDirection(DirectionTypes::IN);\n\twirePort->setPresence(PresenceTypes::ILLEGAL);\n\twirePort->setWidth(\"47\");\n\twire->setMasterPort(wirePort);\n\n\tQSharedPointer<TimingConstraint> timing(new TimingConstraint);\n\ttiming->setClockEdge(TimingConstraint::UNKNOWN);\n\ttiming->setClockName(\"bogus\");\n\ttiming->setValue(100.01);\n\twirePort->setTimingConstraint(timing);\n\n\tQVector<QString> errorList;\n\tvalidator.findErrorsIn(errorList, abs);\n\n\tQCOMPARE(errorList.size(), 3);\n\tQVERIFY(!validator.validate(abs));\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_AbstractionDefinitionValidator::invalidCellSpec()\n//-----------------------------------------------------------------------------\nvoid tst_AbstractionDefinitionValidator::invalidCellSpec()\n{\n    VLNV absVLNV(VLNV::ABSTRACTIONDEFINITION, \"vendor\", \"library\", \"name\", \"version\");\n\tQSharedPointer<AbstractionDefinition> abs(new AbstractionDefinition(absVLNV, Document::Revision::Std14));\n\t\n\tAbstractionDefinitionValidator validator(library_, expressionParser_);\n\n\tabs->setBusType(testBusDefVlnv_);\n\tabs->getLogicalPorts()->append(port_);\n\n\tQSharedPointer<PortAbstraction> port(new PortAbstraction);\n\tport->setLogicalName(\"nimi\");\n\tabs->getLogicalPorts()->append(port);\n\tQSharedPointer<WireAbstraction> wire(new WireAbstraction);\n\tport->setWire(wire);\n\n\tQSharedPointer<WirePort> wirePort(new WirePort);\n\twirePort->setDirection(DirectionTypes::IN);\n\twirePort->setPresence(PresenceTypes::ILLEGAL);\n\twirePort->setWidth(\"47\");\n\twire->setMasterPort(wirePort);\n\n\tQSharedPointer<CellSpecification> cell(new CellSpecification);\n\tcell->setCellClass(CellSpecification::NO_CLASS);\n\tcell->setCellFunction(\"bogus\");\n\tcell->setCellStrength(CellSpecification::UNKNOWN);\n\twirePort->setLoadConstraint(cell);\n\n\tQVector<QString> errorList;\n\tvalidator.findErrorsIn(errorList, abs);\n\n\tQCOMPARE(errorList.size(), 2);\n\tQVERIFY(!validator.validate(abs));\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_AbstractionDefinitionValidator::wirePortSuccessful()\n//-----------------------------------------------------------------------------\nvoid tst_AbstractionDefinitionValidator::wirePortSuccessful()\n{\n    VLNV absVLNV(VLNV::ABSTRACTIONDEFINITION, \"vendor\", \"library\", \"name\", \"version\");\n    QSharedPointer<AbstractionDefinition> abs(new AbstractionDefinition(absVLNV, Document::Revision::Std14));\n\n\tAbstractionDefinitionValidator validator(library_, expressionParser_);\n\n\tabs->setBusType(testBusDefVlnv_);\n\tabs->getLogicalPorts()->append(port_);\n\n\tQSharedPointer<PortAbstraction> port(new PortAbstraction);\n\tport->setLogicalName(\"nimi\");\n\tabs->getLogicalPorts()->append(port);\n\tQSharedPointer<WireAbstraction> wire(new WireAbstraction);\n\tport->setWire(wire);\n\n\tQSharedPointer<WirePort> wirePort(new WirePort);\n\twirePort->setDirection(DirectionTypes::IN);\n\twirePort->setPresence(PresenceTypes::ILLEGAL);\n\twirePort->setWidth(\"47\");\n\twire->setMasterPort(wirePort);\n\n\tQSharedPointer<TimingConstraint> timing(new TimingConstraint);\n\ttiming->setClockEdge(TimingConstraint::RISE);\n\ttiming->setClockName(\"nimi\");\n\ttiming->setValue(99.99);\n\twirePort->setTimingConstraint(timing);\n\n\tQSharedPointer<CellSpecification> cell(new CellSpecification);\n\tcell->setCellFunction(\"xor2\");\n\tcell->setCellStrength(CellSpecification::LOW);\n\twirePort->setLoadConstraint(cell);\n\n\tQVector<QString> errorList;\n\tvalidator.findErrorsIn(errorList, abs);\n\n\tQCOMPARE(errorList.size(), 0);\n\tQVERIFY(validator.validate(abs));\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_AbstractionDefinitionValidator::transactionalSuccessful()\n//-----------------------------------------------------------------------------\nvoid tst_AbstractionDefinitionValidator::transactionalSuccessful()\n{\n    VLNV absVLNV(VLNV::ABSTRACTIONDEFINITION, \"vendor\", \"library\", \"name\", \"version\");\n    QSharedPointer<AbstractionDefinition> abs(new AbstractionDefinition(absVLNV, Document::Revision::Std14));\n\t\n\tAbstractionDefinitionValidator validator(library_, expressionParser_);\n\n\tabs->setBusType(testBusDefVlnv_);\n\tabs->getLogicalPorts()->append(port_);\n\n\tQSharedPointer<PortAbstraction> port(new PortAbstraction);\n\tport->setLogicalName(\"nimi\");\n\tabs->getLogicalPorts()->append(port);\n\tQSharedPointer<TransactionalAbstraction> transAbs(new TransactionalAbstraction);\n\tport->setTransactional(transAbs);\n\n\tQSharedPointer<TransactionalPort> transPort(new TransactionalPort);\n\ttransPort->setBusWidth(\"3\");\n\ttransPort->setInitiative(\"provides\");\n\ttransPort->setKind(\"tlm_socket\");\n\ttransPort->setPresence(PresenceTypes::REQUIRED);\n\ttransAbs->setMasterPort(transPort);\n\n\tQVector<QString> errorList;\n\tvalidator.findErrorsIn(errorList, abs);\n\n\tQCOMPARE(errorList.size(), 0);\n\tQVERIFY(validator.validate(abs));\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_AbstractionDefinitionValidator::transactionalSuccessful()\n//-----------------------------------------------------------------------------\nvoid tst_AbstractionDefinitionValidator::systemWirePortHasGroup()\n{\n    VLNV absVLNV(VLNV::ABSTRACTIONDEFINITION, \"vendor\", \"library\", \"name\", \"version\");\n    QSharedPointer<AbstractionDefinition> abstraction(new AbstractionDefinition(absVLNV, Document::Revision::Std14));\n\n    AbstractionDefinitionValidator validator(library_, expressionParser_);\n\n    abstraction->setBusType(testBusDefVlnv_);\n    \n    QSharedPointer<PortAbstraction>systemPort(new PortAbstraction);\n    systemPort->setLogicalName(\"system\");\n\n    QSharedPointer<WireAbstraction> wire(new WireAbstraction());\n    QSharedPointer<WirePort> systemWire(new WirePort());\n\n    wire->getSystemPorts()->append(systemWire);\n    systemPort->setWire(wire);\n\n    abstraction->getLogicalPorts()->append(systemPort);\n\n    QVector<QString> errorList;\n    validator.findErrorsIn(errorList, abstraction);\n\n    QCOMPARE(errorList.size(), 1);\n    QVERIFY(validator.validate(abstraction) == false);\n\n    QSharedPointer<BusDefinition> busDef(new BusDefinition(testBusDefVlnv_, Document::Revision::Std14));\n    QStringList systemGroupNames({ \"testSystem\" });\n    busDef->setSystemGroupNames(systemGroupNames);\n    library_->addComponent(busDef);\n\n    systemWire->setSystemGroup(\"testSystem\");\n\n    errorList.clear();\n    validator.findErrorsIn(errorList, abstraction);\n\n    QCOMPARE(errorList.size(), 0);\n    QVERIFY(validator.validate(abstraction));\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_AbstractionDefinitionValidator::wireQualifier()\n//-----------------------------------------------------------------------------\nvoid tst_AbstractionDefinitionValidator::wireQualifier()\n{\n    VLNV absVLNV(VLNV::ABSTRACTIONDEFINITION, \"vendor\", \"library\", \"name\", \"version\");\n    QSharedPointer<AbstractionDefinition> abstraction(new AbstractionDefinition(absVLNV, Document::Revision::Std14));\n\n    AbstractionDefinitionValidator validator(library_, expressionParser_);\n\n    abstraction->setBusType(testBusDefVlnv_);\n\n\tQSharedPointer<PortAbstraction> testPort(new PortAbstraction());\n\ttestPort->setLogicalName(\"testPort\");\n\tabstraction->getLogicalPorts()->append(testPort);\n\n\tQSharedPointer<WireAbstraction> wire(new WireAbstraction());\n\ttestPort->setWire(wire);\n\n\tQSharedPointer<Qualifier> wireQualifier(new Qualifier());\n\twireQualifier->setType(Qualifier::Type::Protection);\n\twireQualifier->setAttribute(Qualifier::Attribute::PowerEnableLevel, QStringLiteral(\"super high\"));\n\twire->setQualifier(wireQualifier);\n\n    VLNV absVLNV2(VLNV::ABSTRACTIONDEFINITION, \"vendor\", \"library\", \"name2\", \"version\");\n    QSharedPointer<AbstractionDefinition> abstraction2(new AbstractionDefinition(absVLNV2, Document::Revision::Std22));\n\n    abstraction2->setBusType(testBusDefVlnv_);\n\n    QSharedPointer<PortAbstraction> testPort2(new PortAbstraction());\n    testPort2->setLogicalName(\"testPort\");\n\tabstraction2->getLogicalPorts()->append(testPort2);\n\n    QSharedPointer<WireAbstraction> wire2(new WireAbstraction());\n    testPort2->setWire(wire2);\n\n    QSharedPointer<Qualifier> wireQualifier2(new Qualifier());\n    wireQualifier2->setType(Qualifier::Type::PowerEnable);\n    wireQualifier2->setAttribute(Qualifier::Attribute::PowerEnableLevel, QStringLiteral(\"high\"));\n    wireQualifier2->setAttribute(Qualifier::Attribute::PowerDomainReference, QStringLiteral(\"testPowerDomain\")); // port qualifier must not have powerDomainRef set when in an absDef\n\n\twire2->setQualifier(wireQualifier2);\n\n    QVector<QString> errorList;\n    validator.findErrorsIn(errorList, abstraction);\n\tvalidator.findErrorsIn(errorList, abstraction2);\n\n    QCOMPARE(errorList.size(), 2);\n    QVERIFY(!validator.validate(abstraction));\n    QVERIFY(!validator.validate(abstraction2));\n\n\twireQualifier->clear();\n\twireQualifier->setType(Qualifier::Type::Address);\n\twireQualifier->setType(Qualifier::Type::Data);\n\n\twireQualifier2->setAttribute(Qualifier::Attribute::PowerDomainReference, QStringLiteral(\"\"));\n\n\terrorList.clear();\n    validator.findErrorsIn(errorList, abstraction);\n    validator.findErrorsIn(errorList, abstraction2);\n\n    QCOMPARE(errorList.size(), 0);\n    QVERIFY(validator.validate(abstraction));\n    QVERIFY(validator.validate(abstraction2));\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_AbstractionDefinitionValidator::packetsOnlyInStd22()\n//-----------------------------------------------------------------------------\nvoid tst_AbstractionDefinitionValidator::packetsOnlyInStd22()\n{\n    VLNV absVLNV(VLNV::ABSTRACTIONDEFINITION, \"vendor\", \"library\", \"name\", \"version\");\n    QSharedPointer<AbstractionDefinition> abstraction(new AbstractionDefinition(absVLNV, Document::Revision::Std22));\n\t\n    AbstractionDefinitionValidator validator(library_, expressionParser_);\n\n    abstraction->setBusType(testBusDefVlnv_);\n\n    QSharedPointer<PortAbstraction> testPort(new PortAbstraction());\n    testPort->setLogicalName(\"testPort\");\n\tabstraction->getLogicalPorts()->append(testPort);\n\n\tQSharedPointer<WireAbstraction> wire(new WireAbstraction());\n\ttestPort->setWire(wire);\n\n\tQSharedPointer<Packet> testPacket(new Packet()); // no packet name\n\tQSharedPointer<PacketField> testPacketField(new PacketField(\"testPacketField\"));\n\t// no packetfield in packet\n\t// no width defined\n\n\ttestPort->getPackets()->append(testPacket);\n\n\n    VLNV absVLNV2(VLNV::ABSTRACTIONDEFINITION, \"vendor\", \"library\", \"name2\", \"version\");\n    QSharedPointer<AbstractionDefinition> abstraction2(new AbstractionDefinition(absVLNV2, Document::Revision::Std14));\n\n    abstraction2->setBusType(testBusDefVlnv_);\n\n    QSharedPointer<PortAbstraction> testPort2(new PortAbstraction());\n    testPort2->setLogicalName(\"testPort2\");\n    abstraction2->getLogicalPorts()->append(testPort2);\n\n    QSharedPointer<WireAbstraction> wire2(new WireAbstraction());\n    testPort2->setWire(wire2);\n\n    QSharedPointer<Packet> testPacket2(new Packet(\"testPacket2\"));\n    QSharedPointer<PacketField> testPacketField2(new PacketField(\"testPacketField2\"));\n\ttestPacket2->getPacketFields()->append(testPacketField2);\n\n\ttestPort2->getPackets()->append(testPacket2);\n\n    QVector<QString> errorList;\n    validator.findErrorsIn(errorList, abstraction);\n    validator.findErrorsIn(errorList, abstraction2);\n    QCOMPARE(errorList.size(), 3);\n    QVERIFY(!validator.validate(abstraction));\n    QVERIFY(!validator.validate(abstraction2));\n\n\ttestPacket->getPacketFields()->append(testPacketField);\n\ttestPacket->setName(\"testPacket\");\n\ttestPort2->getPackets()->clear();\n\n\terrorList.clear();\n    validator.findErrorsIn(errorList, abstraction);\n    validator.findErrorsIn(errorList, abstraction2);\n\n    QCOMPARE(errorList.size(), 1); // still no width defined for testPacketField\n    QVERIFY(!validator.validate(abstraction));\n    QVERIFY(validator.validate(abstraction2));\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_AbstractionDefinitionValidator::invalidPacketFieldWidthValue()\n//-----------------------------------------------------------------------------\nvoid tst_AbstractionDefinitionValidator::invalidPacketFieldWidthValue()\n{\n    VLNV absVLNV(VLNV::ABSTRACTIONDEFINITION, \"vendor\", \"library\", \"name\", \"version\");\n    QSharedPointer<AbstractionDefinition> abstraction(new AbstractionDefinition(absVLNV, Document::Revision::Std22));\n\n    AbstractionDefinitionValidator validator(library_, expressionParser_);\n\n    abstraction->setBusType(testBusDefVlnv_);\n\n    QSharedPointer<PortAbstraction> testPort(new PortAbstraction());\n    testPort->setLogicalName(\"testPort\");\n    abstraction->getLogicalPorts()->append(testPort);\n\n    QSharedPointer<WireAbstraction> wire(new WireAbstraction());\n    testPort->setWire(wire);\n\n    QSharedPointer<Packet> testPacket(new Packet(\"testPacket\"));\n    QSharedPointer<PacketField> testPacketField(new PacketField(\"testPacketField\"));\n    testPacket->getPacketFields()->append(testPacketField);\n    testPacketField->setWidth(\"2+2\");\n    testPacketField->setValue(\"'h10\"); // error\n    \n    testPort->getPackets()->append(testPacket);\n\n    QVector<QString> errorList;\n    validator.findErrorsIn(errorList, abstraction);\n    QCOMPARE(errorList.size(), 1);\n    QVERIFY(!validator.validate(abstraction));\n\n    testPacketField->setWidth(\"8\");\n\n    errorList.clear();\n    validator.findErrorsIn(errorList, abstraction);\n    QCOMPARE(errorList.size(), 0);\n    QVERIFY(validator.validate(abstraction));\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_AbstractionDefinitionValidator::packetFieldValueWhenOpcode()\n//-----------------------------------------------------------------------------\nvoid tst_AbstractionDefinitionValidator::packetFieldValueWhenOpcode()\n{\n    // Packet field value must be constant, when qualifier is opcode.\n    VLNV absVLNV(VLNV::ABSTRACTIONDEFINITION, \"vendor\", \"library\", \"name\", \"version\");\n    QSharedPointer<AbstractionDefinition> abstraction(new AbstractionDefinition(absVLNV, Document::Revision::Std22));\n\n    AbstractionDefinitionValidator validator(library_, expressionParser_);\n\n    abstraction->setBusType(testBusDefVlnv_);\n\n    QSharedPointer<PortAbstraction> testPort(new PortAbstraction());\n    testPort->setLogicalName(\"testPort\");\n    abstraction->getLogicalPorts()->append(testPort);\n\n    QSharedPointer<WireAbstraction> wire(new WireAbstraction());\n    testPort->setWire(wire);\n\n    QSharedPointer<Packet> testPacket(new Packet(\"testPacket\"));\n    QSharedPointer<PacketField> testPacketField(new PacketField(\"testPacketField\"));\n    testPacket->getPacketFields()->append(testPacketField);\n    testPacketField->setWidth(\"8\");\n    testPacketField->setValue(\"128+64\"); // error\n\n    QSharedPointer<Qualifier> testQualifier(new Qualifier());\n    testQualifier->setType(Qualifier::Type::Opcode);\n    testPacketField->setQualifier(testQualifier);\n\n    testPort->getPackets()->append(testPacket);\n\n    QVector<QString> errorList;\n    validator.findErrorsIn(errorList, abstraction);\n    QCOMPARE(errorList.size(), 2);\n    QVERIFY(errorList.contains(QStringLiteral(\"Value of packet field testPacketField in packet testPacket within port testPort must be constant when qualifier is opcode.\")));\n    QVERIFY(!validator.validate(abstraction));\n\n    testPacketField->setValue(\"128\");\n\n    errorList.clear();\n    validator.findErrorsIn(errorList, abstraction);\n    QCOMPARE(errorList.size(), 0);\n    QVERIFY(validator.validate(abstraction));\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_AbstractionDefinitionValidator::choicesOnlyInStd22()\n//-----------------------------------------------------------------------------\nvoid tst_AbstractionDefinitionValidator::choicesOnlyInStd22()\n{\n    VLNV absVLNV(VLNV::ABSTRACTIONDEFINITION, \"vendor\", \"library\", \"name\", \"version\");\n    QSharedPointer<AbstractionDefinition> abstraction(new AbstractionDefinition(absVLNV, Document::Revision::Std14));\n\n    AbstractionDefinitionValidator validator(library_, expressionParser_);\n\n    abstraction->setBusType(testBusDefVlnv_);\n\n    QSharedPointer<PortAbstraction> testPort(new PortAbstraction());\n    testPort->setLogicalName(\"testPort\");\n    abstraction->getLogicalPorts()->append(testPort);\n\n    QSharedPointer<WireAbstraction> wire(new WireAbstraction());\n    testPort->setWire(wire);\n\n    QSharedPointer<Choice> testChoice(new Choice());\n    abstraction->getChoices()->append(testChoice); // error 1\n\n    VLNV busVLNV(VLNV::BUSDEFINITION, \"vendor\", \"library\", \"testbusdef\", \"version\");\n    QSharedPointer<BusDefinition> busDef(new BusDefinition(busVLNV, Document::Revision::Std22));\n    library_->addComponent(busDef);\n\n    VLNV absVLNV2(VLNV::ABSTRACTIONDEFINITION, \"vendor\", \"library\", \"name2\", \"version\");\n    QSharedPointer<AbstractionDefinition> abstraction2(new AbstractionDefinition(absVLNV2, Document::Revision::Std22));\n\n    abstraction2->setBusType(busVLNV);\n\n    QSharedPointer<PortAbstraction> testPort2(new PortAbstraction());\n    testPort2->setLogicalName(\"testPort\");\n    abstraction2->getLogicalPorts()->append(testPort2);\n\n    abstraction2->getChoices()->append(testChoice); // error 2 & 3: no name, no enumeration(s)\n\n    QSharedPointer<WireAbstraction> wire2(new WireAbstraction());\n    testPort2->setWire(wire2);\n\n    QVector<QString> errorList;\n    validator.findErrorsIn(errorList, abstraction);\n    validator.findErrorsIn(errorList, abstraction2);\n    QCOMPARE(errorList.size(), 4);\n    QVERIFY(!validator.validate(abstraction));\n    QVERIFY(!validator.validate(abstraction2));\n\n    abstraction->getChoices()->clear();\n    testChoice->setName(\"testChoice\");\n    \n    QSharedPointer<Enumeration> testEnumeration(new Enumeration());\n    testEnumeration->setValue(\"16\");\n    testChoice->enumerations()->append(testEnumeration);\n\n    errorList.clear();\n    validator.findErrorsIn(errorList, abstraction);\n    validator.findErrorsIn(errorList, abstraction2);\n    QCOMPARE(errorList.size(), 0);\n    QVERIFY(validator.validate(abstraction));\n    QVERIFY(validator.validate(abstraction2));\n}\n\nQTEST_APPLESS_MAIN(tst_AbstractionDefinitionValidator)\n\n#include \"tst_AbstractionDefinitionValidator.moc\"\n"
  },
  {
    "path": "tests/IPXACTmodels/AbstractionDefinition/tst_AbstractionDefinitionValidator.pri",
    "content": "# ----------------------------------------------------\n# This file is generated by the Qt Visual Studio Tools.\n# ------------------------------------------------------\n\n# This is a reminder that you are using a generated .pro file.\n# Remove it when you are finished editing this file.\nmessage(\"You are running qmake on a generated .pro file. This may not work!\")\n\n\nHEADERS += ../../MockObjects/LibraryMock.h\nSOURCES += ../../MockObjects/LibraryMock.cpp \\\n    ./tst_AbstractionDefinitionValidator.cpp\n"
  },
  {
    "path": "tests/IPXACTmodels/AbstractionDefinition/tst_AbstractionDefinitionValidator.pro",
    "content": "#-----------------------------------------------------------------------------\n# File: tst_AbstractionDefinitionValidator.pro\n#-----------------------------------------------------------------------------\n# Project: Kactus 2\n# Author: Janne Virtanen\n# Date: 04.12.2015\n#\n# Description:\n# Qt project file for running unit tests for AbstractionDefinition Validator.\n#-----------------------------------------------------------------------------\n\nTEMPLATE = app\n\nTARGET = tst_AbstractionDefinitionValidator\n\nQT += core gui xml testlib\n\nCONFIG += c++11 testcase console\n\nlinux-g++ | linux-g++-64 | linux-g++-32 {\n LIBS += -L../../../executable \\\n     -lIPXACTmodels -lKactusAPI\n\n}\nwin64 | win32 {\n LIBS += -L$$PWD/../../../executable/ \\\n     -lIPXACTmodelsd -lKactusAPId\n}\n\nDESTDIR = ./release\n\nINCLUDEPATH += $$DESTDIR\nINCLUDEPATH += ../../../\n\nDEPENDPATH += .\nDEPENDPATH += ../../../\n\nOBJECTS_DIR += $$DESTDIR\n\nMOC_DIR += ./generatedFiles\nUI_DIR += ./generatedFiles\nRCC_DIR += ./generatedFiles\ninclude(tst_AbstractionDefinitionValidator.pri)\n"
  },
  {
    "path": "tests/IPXACTmodels/AbstractionDefinition/tst_AbstractionDefinitionWriter.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: tst_AbstractionDefinitionWriter.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Esko Pekkarinen\n// Date: 10.08.2015\n//\n// Description:\n// Unit test for class AbstractionDefinitionWriter.\n//-----------------------------------------------------------------------------\n\n#include <QtTest>\n\n#include <IPXACTmodels/common/GenericVendorExtension.h>\n\n#include <IPXACTmodels/common/Assertion.h>\n#include <IPXACTmodels/common/CellSpecification.h>\n#include <IPXACTmodels/common/Parameter.h>\n#include <IPXACTmodels/common/PresenceTypes.h>\n#include <IPXACTmodels/common/Protocol.h>\n#include <IPXACTmodels/common/Qualifier.h>\n#include <IPXACTmodels/common/TimingConstraint.h>\n\n#include <IPXACTmodels/AbstractionDefinition/AbstractionDefinition.h>\n#include <IPXACTmodels/AbstractionDefinition/AbstractionDefinitionWriter.h>\n#include <IPXACTmodels/AbstractionDefinition/PortAbstraction.h>\n#include <IPXACTmodels/AbstractionDefinition/TransactionalAbstraction.h>\n#include <IPXACTmodels/AbstractionDefinition/TransactionalPort.h>\n#include <IPXACTmodels/AbstractionDefinition/WirePort.h>\n#include <IPXACTmodels/AbstractionDefinition/WireAbstraction.h>\n#include <IPXACTmodels/AbstractionDefinition/Packet.h>\n\n#include <IPXACTmodels/common/Choice.h>\n\nclass tst_AbstractionDefinitionWriter : public QObject\n{\n    Q_OBJECT\n\npublic:\n    tst_AbstractionDefinitionWriter();\n\nprivate slots:\n    void testWriteAbstractionDefinitionWithoutPorts();\n    void testTopCommentsAreWritten();\n    void testProcessingInstructionsAreWritten();\n    void testWriteExtendingAbstractionDefinition();\n\n    void testWriteDocumentNameGroupNoPorts();\n\n    void testWriteSimpleWirePort();\n    void testWriteWirePortWithPackets();\n    void testWriteWirePortForAllModes();\n    void testWriteWirePortForInitiatorTarget();\n    void testWriteMultipleSystemWirePorts();\n\n    void testWireConstraints();\n    void testWireMirroredConstraints();\n\n    void testWriteSimpleTransactionalPort();\n    void testWriteTransactionalPortForAllModes();\n    void testWriteTransactionalPortWithProtocol();\n\n    void testWriteChoices();\n\n    void testWriteParameters();\n    void testWriteAssertions();\n    void testVendorExtensions();\n};\n\n//-----------------------------------------------------------------------------\n// Function: tst_AbstractionDefinitionWriter::tst_AbstractionDefinition()\n//-----------------------------------------------------------------------------\ntst_AbstractionDefinitionWriter::tst_AbstractionDefinitionWriter()\n{\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_AbstractionDefinitionWriter::testWriteAbstractionDefinitionWithoutPorts()\n//-----------------------------------------------------------------------------\nvoid tst_AbstractionDefinitionWriter::testWriteAbstractionDefinitionWithoutPorts()\n{\n    VLNV targetBus(VLNV::BUSDEFINITION, \"TUT\", \"TestLibrary\", \"TargetBusDef\", \"1.0\");\n\n    VLNV vlnv(VLNV::ABSTRACTIONDEFINITION, \"TUT\", \"TestLibrary\", \"MinimalAbsDef\", \"1.0\");\n    QSharedPointer<AbstractionDefinition> abstractionDefinition(new AbstractionDefinition(vlnv, Document::Revision::Std14));\n    abstractionDefinition->setVlnv(vlnv);\n    abstractionDefinition->setBusType(targetBus);\n    abstractionDefinition->setDescription(\"This is a description\");\n\n    QString output;\n    QXmlStreamWriter xmlStreamWriter(&output);\n    \n    AbstractionDefinitionWriter::writeAbstractionDefinition(xmlStreamWriter, abstractionDefinition);\n\n    QCOMPARE(output, QString(\n        \"<?xml version=\\\"1.0\\\"?>\"\n        \"<ipxact:abstractionDefinition xmlns:xsi=\\\"http://www.w3.org/2001/XMLSchema-instance\\\" \" \n        \"xmlns:ipxact=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014\\\" \"\n        \"xmlns:kactus2=\\\"http://kactus2.cs.tut.fi\\\" \"\n        \"xsi:schemaLocation=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014 \"\n        \"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/index.xsd\\\">\"\n            \"<ipxact:vendor>TUT</ipxact:vendor>\"\n            \"<ipxact:library>TestLibrary</ipxact:library>\"\n            \"<ipxact:name>MinimalAbsDef</ipxact:name>\"\n            \"<ipxact:version>1.0</ipxact:version>\"\n            \"<ipxact:busType vendor=\\\"TUT\\\" library=\\\"TestLibrary\\\" name=\\\"TargetBusDef\\\" version=\\\"1.0\\\"/>\"\n            \"<ipxact:description>This is a description</ipxact:description>\"\n        \"</ipxact:abstractionDefinition>\\n\"));\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_AbstractionDefinition::testTopCommentsAreWritten()\n//-----------------------------------------------------------------------------\nvoid tst_AbstractionDefinitionWriter::testTopCommentsAreWritten()\n{\n    VLNV targetBus(VLNV::BUSDEFINITION, \"TUT\", \"TestLibrary\", \"TargetBusDef\", \"1.0\");\n\n    VLNV vlnv(VLNV::ABSTRACTIONDEFINITION, \"TUT\", \"TestLibrary\", \"MinimalAbsDef\", \"1.0\");\n    QSharedPointer<AbstractionDefinition> abstractionDefinition(new AbstractionDefinition(vlnv, Document::Revision::Std14));\n    abstractionDefinition->setVlnv(vlnv);\n    abstractionDefinition->setBusType(targetBus);\n    abstractionDefinition->setTopComments(\"Commented section\");\n\n    QString output;\n    QXmlStreamWriter xmlStreamWriter(&output);\n    \n    AbstractionDefinitionWriter::writeAbstractionDefinition(xmlStreamWriter, abstractionDefinition);\n\n    QCOMPARE(output, QString(\n        \"<?xml version=\\\"1.0\\\"?>\"\n        \"<!--Commented section-->\"\n        \"<ipxact:abstractionDefinition xmlns:xsi=\\\"http://www.w3.org/2001/XMLSchema-instance\\\" \" \n        \"xmlns:ipxact=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014\\\" \"\n        \"xmlns:kactus2=\\\"http://kactus2.cs.tut.fi\\\" \"\n        \"xsi:schemaLocation=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014 \"\n        \"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/index.xsd\\\">\"\n            \"<ipxact:vendor>TUT</ipxact:vendor>\"\n            \"<ipxact:library>TestLibrary</ipxact:library>\"\n            \"<ipxact:name>MinimalAbsDef</ipxact:name>\"\n            \"<ipxact:version>1.0</ipxact:version>\"\n            \"<ipxact:busType vendor=\\\"TUT\\\" library=\\\"TestLibrary\\\" name=\\\"TargetBusDef\\\" version=\\\"1.0\\\"/>\"\n        \"</ipxact:abstractionDefinition>\\n\"));\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_AbstractionDefinition::testProcessingInstructionsAreWritten()\n//-----------------------------------------------------------------------------\nvoid tst_AbstractionDefinitionWriter::testProcessingInstructionsAreWritten()\n{\n    VLNV targetBus(VLNV::BUSDEFINITION, \"TUT\", \"TestLibrary\", \"TargetBusDef\", \"1.0\");\n\n    VLNV vlnv(VLNV::ABSTRACTIONDEFINITION, \"TUT\", \"TestLibrary\", \"MinimalAbsDef\", \"1.0\");\n    QSharedPointer<AbstractionDefinition> abstractionDefinition(new AbstractionDefinition(vlnv, Document::Revision::Std14));\n    abstractionDefinition->setVlnv(vlnv);\n    abstractionDefinition->setBusType(targetBus);\n    abstractionDefinition->addXmlProcessingInstructions(\"xml-stylesheet\", \"href=\\\"style.css\\\"\");\n\n    QString output;\n    QXmlStreamWriter xmlStreamWriter(&output);\n    \n    AbstractionDefinitionWriter::writeAbstractionDefinition(xmlStreamWriter, abstractionDefinition);\n\n    QCOMPARE(output, QString(\n        \"<?xml version=\\\"1.0\\\"?>\"\n        \"<?xml-stylesheet href=\\\"style.css\\\"?>\"\n        \"<ipxact:abstractionDefinition xmlns:xsi=\\\"http://www.w3.org/2001/XMLSchema-instance\\\" \" \n        \"xmlns:ipxact=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014\\\" \"\n        \"xmlns:kactus2=\\\"http://kactus2.cs.tut.fi\\\" \"\n        \"xsi:schemaLocation=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014 \"\n        \"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/index.xsd\\\">\"\n            \"<ipxact:vendor>TUT</ipxact:vendor>\"\n            \"<ipxact:library>TestLibrary</ipxact:library>\"\n            \"<ipxact:name>MinimalAbsDef</ipxact:name>\"\n            \"<ipxact:version>1.0</ipxact:version>\"\n            \"<ipxact:busType vendor=\\\"TUT\\\" library=\\\"TestLibrary\\\" name=\\\"TargetBusDef\\\" version=\\\"1.0\\\"/>\"\n        \"</ipxact:abstractionDefinition>\\n\"));\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_AbstractionDefinitionWriter::testWriteExtendingAbstractionDefinition()\n//-----------------------------------------------------------------------------\nvoid tst_AbstractionDefinitionWriter::testWriteExtendingAbstractionDefinition()\n{\n    VLNV targetBus(VLNV::BUSDEFINITION, \"TUT\", \"TestLibrary\", \"TargetBusDef\", \"1.0\");\n\n    VLNV extendedVlnv(VLNV::ABSTRACTIONDEFINITION, \"TUT\", \"TestLibrary\", \"extended\", \"1.0\");\n\n    VLNV extendingVlnv(VLNV::ABSTRACTIONDEFINITION, \"TUT\", \"TestLibrary\", \"extending\", \"1.0\");\n    QSharedPointer<AbstractionDefinition> abstractionDefinition(new AbstractionDefinition(extendingVlnv, Document::Revision::Std14));\n    abstractionDefinition->setVlnv(extendingVlnv);\n    abstractionDefinition->setBusType(targetBus);\n    abstractionDefinition->setExtends(extendedVlnv);\n\n    QString output;\n    QXmlStreamWriter xmlStreamWriter(&output);\n    \n    AbstractionDefinitionWriter::writeAbstractionDefinition(xmlStreamWriter, abstractionDefinition);\n\n    QCOMPARE(output, QString(\n        \"<?xml version=\\\"1.0\\\"?>\"\n        \"<ipxact:abstractionDefinition xmlns:xsi=\\\"http://www.w3.org/2001/XMLSchema-instance\\\" \" \n        \"xmlns:ipxact=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014\\\" \"\n        \"xmlns:kactus2=\\\"http://kactus2.cs.tut.fi\\\" \"\n        \"xsi:schemaLocation=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014 \"\n        \"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/index.xsd\\\">\"\n            \"<ipxact:vendor>TUT</ipxact:vendor>\"\n            \"<ipxact:library>TestLibrary</ipxact:library>\"\n            \"<ipxact:name>extending</ipxact:name>\"\n            \"<ipxact:version>1.0</ipxact:version>\"\n            \"<ipxact:busType vendor=\\\"TUT\\\" library=\\\"TestLibrary\\\" name=\\\"TargetBusDef\\\" version=\\\"1.0\\\"/>\"\n            \"<ipxact:extends vendor=\\\"TUT\\\" library=\\\"TestLibrary\\\" name=\\\"extended\\\" version=\\\"1.0\\\"/>\"\n        \"</ipxact:abstractionDefinition>\\n\"));\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_AbstractionDefinitionWriter::testWriteSimpleWirePort()\n//-----------------------------------------------------------------------------\nvoid tst_AbstractionDefinitionWriter::testWriteDocumentNameGroupNoPorts()\n{\n    VLNV targetBus(VLNV::BUSDEFINITION, \"TUT\", \"TestLibrary\", \"TargetBusDef\", \"1.0\");\n\n    VLNV vlnv(VLNV::ABSTRACTIONDEFINITION, \"TUT\", \"TestLibrary\", \"TestAbsDef\", \"1.0\");\n    QSharedPointer<AbstractionDefinition> abstractionDefinition(\n        new AbstractionDefinition(vlnv,Document::Revision::Std22));\n    abstractionDefinition->setBusType(targetBus);\n\n    abstractionDefinition->setDisplayName(\"A test absdef\");\n    abstractionDefinition->setShortDescription(\"shortDescription\");\n    abstractionDefinition->setDescription(\"A longer description of the test abs def\");\n\n    QString output;\n    QXmlStreamWriter xmlStreamWriter(&output);\n    \n    AbstractionDefinitionWriter::writeAbstractionDefinition(xmlStreamWriter, abstractionDefinition);\n\n    QCOMPARE(output, QString(\n        \"<?xml version=\\\"1.0\\\"?>\"\n        \"<ipxact:abstractionDefinition xmlns:xsi=\\\"http://www.w3.org/2001/XMLSchema-instance\\\" \"\n        \"xmlns:ipxact=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2022\\\" \"\n        \"xmlns:kactus2=\\\"http://kactus2.cs.tut.fi\\\" \"\n        \"xsi:schemaLocation=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2022 \"\n        \"http://www.accellera.org/XMLSchema/IPXACT/1685-2022/index.xsd\\\">\"\n            \"<ipxact:vendor>TUT</ipxact:vendor>\"\n            \"<ipxact:library>TestLibrary</ipxact:library>\"\n            \"<ipxact:name>TestAbsDef</ipxact:name>\"\n            \"<ipxact:version>1.0</ipxact:version>\"\n            \"<ipxact:displayName>A test absdef</ipxact:displayName>\"\n            \"<ipxact:shortDescription>shortDescription</ipxact:shortDescription>\"\n            \"<ipxact:description>A longer description of the test abs def</ipxact:description>\"\n            \"<ipxact:busType vendor=\\\"TUT\\\" library=\\\"TestLibrary\\\" name=\\\"TargetBusDef\\\" version=\\\"1.0\\\"/>\"\n        \"</ipxact:abstractionDefinition>\\n\"));\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_AbstractionDefinitionWriter::testWriteSimpleWirePort()\n//-----------------------------------------------------------------------------\nvoid tst_AbstractionDefinitionWriter::testWriteSimpleWirePort()\n{\n    VLNV targetBus(VLNV::BUSDEFINITION, \"TUT\", \"TestLibrary\", \"TargetBusDef\", \"1.0\");\n\n    VLNV extendingVlnv(VLNV::ABSTRACTIONDEFINITION, \"TUT\", \"TestLibrary\", \"TestAbsDef\", \"1.0\");\n    QSharedPointer<AbstractionDefinition> abstractionDefinition(new AbstractionDefinition(extendingVlnv, Document::Revision::Std14));\n    abstractionDefinition->setVlnv(extendingVlnv);\n    abstractionDefinition->setBusType(targetBus);\n    \n    QSharedPointer<PortAbstraction> testPort(new PortAbstraction());\n    testPort->setName(\"testPort\");\n    testPort->setDisplayName(\"test wire port\");\n    testPort->setDescription(\"This is a description for testPort\");\n    testPort->setIsPresent(\"1\");\n    \n    testPort->setDefaultValue(\"0\");\n\n    QSharedPointer<Qualifier> testQualifier(new Qualifier());\n    testQualifier->setType(Qualifier::Type::Data);\n    testPort->getWire()->setQualifier(testQualifier);\n\n    QDomDocument document;\n    QDomElement extensionNode = document.createElement(\"kactus2:testExtension\");\n    extensionNode.setAttribute(\"vendorAttribute\", \"extension\");\n    extensionNode.appendChild(document.createTextNode(\"testValue\"));\n\n    QSharedPointer<GenericVendorExtension> testExtension(new GenericVendorExtension(extensionNode));\n    QSharedPointer<QList<QSharedPointer<VendorExtension> > > portExtensions = testPort->getVendorExtensions();\n    portExtensions->append(testExtension);\n\n    QSharedPointer<QList<QSharedPointer<PortAbstraction> > > ports = abstractionDefinition->getLogicalPorts();\n    ports->append(testPort);\n\n    QString output;\n    QXmlStreamWriter xmlStreamWriter(&output);\n    \n    AbstractionDefinitionWriter::writeAbstractionDefinition(xmlStreamWriter, abstractionDefinition);\n\n    QCOMPARE(output, QString(\n        \"<?xml version=\\\"1.0\\\"?>\"\n        \"<ipxact:abstractionDefinition xmlns:xsi=\\\"http://www.w3.org/2001/XMLSchema-instance\\\" \" \n        \"xmlns:ipxact=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014\\\" \"\n        \"xmlns:kactus2=\\\"http://kactus2.cs.tut.fi\\\" \"\n        \"xsi:schemaLocation=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014 \"\n        \"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/index.xsd\\\">\"\n            \"<ipxact:vendor>TUT</ipxact:vendor>\"\n            \"<ipxact:library>TestLibrary</ipxact:library>\"\n            \"<ipxact:name>TestAbsDef</ipxact:name>\"\n            \"<ipxact:version>1.0</ipxact:version>\"\n            \"<ipxact:busType vendor=\\\"TUT\\\" library=\\\"TestLibrary\\\" name=\\\"TargetBusDef\\\" version=\\\"1.0\\\"/>\"\n            \"<ipxact:ports>\"\n                \"<ipxact:port>\"\n                    \"<ipxact:isPresent>1</ipxact:isPresent>\"\n                    \"<ipxact:logicalName>testPort</ipxact:logicalName>\"\n                    \"<ipxact:displayName>test wire port</ipxact:displayName>\"\n                    \"<ipxact:description>This is a description for testPort</ipxact:description>\"\n                    \"<ipxact:wire>\"\n                        \"<ipxact:qualifier>\"\n                            \"<ipxact:isData>true</ipxact:isData>\"\n                        \"</ipxact:qualifier>\"\n                        \"<ipxact:defaultValue>0</ipxact:defaultValue>\"\n                    \"</ipxact:wire>\"\n                    \"<ipxact:vendorExtensions>\"\n                        \"<kactus2:testExtension vendorAttribute=\\\"extension\\\">testValue</kactus2:testExtension>\"\n                    \"</ipxact:vendorExtensions>\"\n                \"</ipxact:port>\"\n            \"</ipxact:ports>\"\n        \"</ipxact:abstractionDefinition>\\n\"));\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_AbstractionDefinition::testWriteSimplePortWithPackets()\n//-----------------------------------------------------------------------------\nvoid tst_AbstractionDefinitionWriter::testWriteWirePortWithPackets()\n{\n    VLNV targetBus(VLNV::BUSDEFINITION, \"TUT\", \"TestLibrary\", \"TargetBusDef\", \"1.0\");\n\n    VLNV extendingVlnv(VLNV::ABSTRACTIONDEFINITION, \"TUT\", \"TestLibrary\", \"TestAbsDef\", \"1.0\");\n    QSharedPointer<AbstractionDefinition> abstractionDefinition(\n        new AbstractionDefinition(extendingVlnv, Document::Revision::Std22));\n    abstractionDefinition->setBusType(targetBus);\n\n    QSharedPointer<PortAbstraction> testPort(new PortAbstraction());\n    testPort->setName(\"testPort\");\n    testPort->setDisplayName(\"test wire port\");\n    testPort->setDescription(\"This is a description for testPort\");\n\n    testPort->setDefaultValue(\"0\");\n\n    QSharedPointer<Qualifier> qualifier1(new Qualifier());\n    qualifier1->setType(Qualifier::Type::Data);\n    qualifier1->setType(Qualifier::Type::Address);\n\n    testPort->getWire()->setQualifier(qualifier1);\n\n    QDomDocument document;\n    QDomElement extensionNode = document.createElement(\"kactus2:testExtension\");\n    extensionNode.setAttribute(\"vendorAttribute\", \"extension\");\n    extensionNode.appendChild(document.createTextNode(\"testValue\"));\n\n    QSharedPointer<GenericVendorExtension> testExtension(new GenericVendorExtension(extensionNode));\n    testPort->getVendorExtensions()->append(testExtension);\n\n    QSharedPointer<Packet> testPacket(new Packet());\n    testPacket->setName(\"testPacket\");\n    testPacket->setDescription(\"A test packet description\");\n\n    QSharedPointer<PacketField> testPacketField(new PacketField());\n    testPacketField->setName(\"testField\");\n    testPacketField->setDisplayName(\"A test field\");\n    testPacketField->setShortDescription(\"shortDescription\");\n    testPacketField->setDescription(\"A longer description for the test field\");\n\n    testPacketField->setEndianness(\"little\");\n    testPacketField->setWidth(\"16\");\n    testPacketField->setValue(\"8\");\n\n    QSharedPointer<Qualifier> fieldQualifier(new Qualifier());\n    fieldQualifier->setType(Qualifier::Type::FlowControl);\n    fieldQualifier->setAttribute(Qualifier::Attribute::FlowType, QStringLiteral(\"user\"));\n    fieldQualifier->setAttribute(Qualifier::Attribute::UserFlowType, QStringLiteral(\"user flow type\"));\n    testPacketField->setQualifier(fieldQualifier);\n\n    QDomDocument document2;\n    QDomElement extensionNodePacket = document2.createElement(\"kactus2:packetTestExtension\");\n    extensionNodePacket.setAttribute(\"vendorAttribute\", \"packet_extension\");\n    extensionNodePacket.appendChild(document2.createTextNode(\"testValue1\"));\n\n    QSharedPointer<GenericVendorExtension> testPacketExtension(new GenericVendorExtension(extensionNodePacket));\n    testPacket->getVendorExtensions()->append(testPacketExtension);\n    \n    testPacket->getPacketFields()->append(testPacketField);\n    testPort->getPackets()->append(testPacket);\n    abstractionDefinition->getLogicalPorts()->append(testPort);\n\n    QString output;\n    QXmlStreamWriter xmlStreamWriter(&output);\n    \n    AbstractionDefinitionWriter::writeAbstractionDefinition(xmlStreamWriter, abstractionDefinition);\n\n    QCOMPARE(output, QString(\n        \"<?xml version=\\\"1.0\\\"?>\"\n        \"<ipxact:abstractionDefinition xmlns:xsi=\\\"http://www.w3.org/2001/XMLSchema-instance\\\" \"\n        \"xmlns:ipxact=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2022\\\" \"\n        \"xmlns:kactus2=\\\"http://kactus2.cs.tut.fi\\\" \"\n        \"xsi:schemaLocation=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2022 \"\n        \"http://www.accellera.org/XMLSchema/IPXACT/1685-2022/index.xsd\\\">\"\n            \"<ipxact:vendor>TUT</ipxact:vendor>\"\n            \"<ipxact:library>TestLibrary</ipxact:library>\"\n            \"<ipxact:name>TestAbsDef</ipxact:name>\"\n            \"<ipxact:version>1.0</ipxact:version>\"\n            \"<ipxact:busType vendor=\\\"TUT\\\" library=\\\"TestLibrary\\\" name=\\\"TargetBusDef\\\" version=\\\"1.0\\\"/>\"\n            \"<ipxact:ports>\"\n                \"<ipxact:port>\"\n                    \"<ipxact:logicalName>testPort</ipxact:logicalName>\"\n                    \"<ipxact:displayName>test wire port</ipxact:displayName>\"\n                    \"<ipxact:description>This is a description for testPort</ipxact:description>\"\n                    \"<ipxact:wire>\"\n                        \"<ipxact:qualifier>\"\n                            \"<ipxact:isAddress>true</ipxact:isAddress>\"\n                            \"<ipxact:isData>true</ipxact:isData>\"\n                        \"</ipxact:qualifier>\"\n                        \"<ipxact:defaultValue>0</ipxact:defaultValue>\"\n                    \"</ipxact:wire>\"\n                    \"<ipxact:packets>\"\n                        \"<ipxact:packet>\"\n                            \"<ipxact:name>testPacket</ipxact:name>\"\n                            \"<ipxact:description>A test packet description</ipxact:description>\"\n                            \"<ipxact:packetFields>\"\n                                \"<ipxact:packetField>\"\n                                    \"<ipxact:name>testField</ipxact:name>\"\n                                    \"<ipxact:displayName>A test field</ipxact:displayName>\"\n                                    \"<ipxact:shortDescription>shortDescription</ipxact:shortDescription>\"\n                                    \"<ipxact:description>A longer description for the test field</ipxact:description>\"\n                                    \"<ipxact:width>16</ipxact:width>\"\n                                    \"<ipxact:value>8</ipxact:value>\"\n                                    \"<ipxact:endianness>little</ipxact:endianness>\"\n                                    \"<ipxact:qualifier>\"\n                                        \"<ipxact:isFlowControl flowType=\\\"user\\\" user=\\\"user flow type\\\">true</ipxact:isFlowControl>\"\n                                    \"</ipxact:qualifier>\"\n                                \"</ipxact:packetField>\"\n                            \"</ipxact:packetFields>\"\n                            \"<ipxact:vendorExtensions>\"\n                                \"<kactus2:packetTestExtension vendorAttribute=\\\"packet_extension\\\">testValue1</kactus2:packetTestExtension>\"\n                            \"</ipxact:vendorExtensions>\"\n                        \"</ipxact:packet>\"\n                    \"</ipxact:packets>\"\n                    \"<ipxact:vendorExtensions>\"\n                        \"<kactus2:testExtension vendorAttribute=\\\"extension\\\">testValue</kactus2:testExtension>\"\n                    \"</ipxact:vendorExtensions>\"\n                \"</ipxact:port>\"\n            \"</ipxact:ports>\"\n        \"</ipxact:abstractionDefinition>\\n\"));\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_AbstractionDefinition::testWriteWirePortForAllModes()\n//-----------------------------------------------------------------------------\nvoid tst_AbstractionDefinitionWriter::testWriteWirePortForAllModes()\n{\n    VLNV targetBus(VLNV::BUSDEFINITION, \"TUT\", \"TestLibrary\", \"TargetBusDef\", \"1.0\");\n\n    VLNV extendingVlnv(VLNV::ABSTRACTIONDEFINITION, \"TUT\", \"TestLibrary\", \"TestAbsDef\", \"1.0\");\n    QSharedPointer<AbstractionDefinition> abstractionDefinition(new AbstractionDefinition(extendingVlnv, Document::Revision::Std14));\n    abstractionDefinition->setVlnv(extendingVlnv);\n    abstractionDefinition->setBusType(targetBus);\n\n    QSharedPointer<PortAbstraction> testPort(new PortAbstraction());\n    testPort->setName(\"reset\");\n    \n    QSharedPointer<WireAbstraction> wire(new WireAbstraction());\n    QSharedPointer<Qualifier> qualifier(new Qualifier());\n    qualifier->setType(Qualifier::Type::Reset);\n    wire->setQualifier(qualifier);\n    wire->setRequiresDriver(true);\n    wire->setDriverType(General::SINGLESHOT);\n    testPort->setWire(wire);\n\n    QSharedPointer<WirePort> systemPort(new WirePort);\n    systemPort->setSystemGroup(\"system1\");\n    systemPort->setPresence(PresenceTypes::REQUIRED);\n    systemPort->setWidth(\"1\");\n    systemPort->setDirection(DirectionTypes::INOUT);\n\n    QSharedPointer<WirePort> masterPort(new WirePort);\n    masterPort->setPresence(PresenceTypes::OPTIONAL);\n    masterPort->setWidth(\"expression\");\n    masterPort->setDirection(DirectionTypes::IN);\n\n    QSharedPointer<WirePort> slavePort(new WirePort);\n    slavePort->setPresence(PresenceTypes::ILLEGAL);\n    slavePort->setDirection(DirectionTypes::OUT);\n\n    testPort->getWire()->addSystemPort(systemPort);\n    testPort->getWire()->setMasterPort(masterPort);\n    testPort->getWire()->setSlavePort(slavePort);\n\n    QSharedPointer<QList<QSharedPointer<PortAbstraction> > > ports = abstractionDefinition->getLogicalPorts();\n    ports->append(testPort);\n\n    QString output;\n    QXmlStreamWriter xmlStreamWriter(&output);\n    \n    AbstractionDefinitionWriter::writeAbstractionDefinition(xmlStreamWriter, abstractionDefinition);\n\n    QCOMPARE(output, QString(\n        \"<?xml version=\\\"1.0\\\"?>\"\n        \"<ipxact:abstractionDefinition xmlns:xsi=\\\"http://www.w3.org/2001/XMLSchema-instance\\\" \" \n        \"xmlns:ipxact=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014\\\" \"\n        \"xmlns:kactus2=\\\"http://kactus2.cs.tut.fi\\\" \"\n        \"xsi:schemaLocation=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014 \"\n        \"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/index.xsd\\\">\"\n            \"<ipxact:vendor>TUT</ipxact:vendor>\"\n            \"<ipxact:library>TestLibrary</ipxact:library>\"\n            \"<ipxact:name>TestAbsDef</ipxact:name>\"\n            \"<ipxact:version>1.0</ipxact:version>\"\n            \"<ipxact:busType vendor=\\\"TUT\\\" library=\\\"TestLibrary\\\" name=\\\"TargetBusDef\\\" version=\\\"1.0\\\"/>\"\n            \"<ipxact:ports>\"\n                \"<ipxact:port>\"                \n                    \"<ipxact:logicalName>reset</ipxact:logicalName>\"\n                    \"<ipxact:wire>\"\n                        \"<ipxact:qualifier>\"\n                            \"<ipxact:isReset>true</ipxact:isReset>\"\n                        \"</ipxact:qualifier>\"\n                        \"<ipxact:onSystem>\"\n                            \"<ipxact:group>system1</ipxact:group>\"\n                            \"<ipxact:presence>required</ipxact:presence>\"\n                            \"<ipxact:width>1</ipxact:width>\"\n                            \"<ipxact:direction>inout</ipxact:direction>\"\n                        \"</ipxact:onSystem>\"\n                        \"<ipxact:onMaster>\"\n                            \"<ipxact:presence>optional</ipxact:presence>\"\n                            \"<ipxact:width>expression</ipxact:width>\"\n                            \"<ipxact:direction>in</ipxact:direction>\"\n                        \"</ipxact:onMaster>\"\n                        \"<ipxact:onSlave>\"\n                            \"<ipxact:presence>illegal</ipxact:presence>\"\n                            \"<ipxact:direction>out</ipxact:direction>\"\n                        \"</ipxact:onSlave>\"\n                        \"<ipxact:requiresDriver driverType=\\\"singleShot\\\">true</ipxact:requiresDriver>\"\n                    \"</ipxact:wire>\"\n                \"</ipxact:port>\"\n            \"</ipxact:ports>\"\n        \"</ipxact:abstractionDefinition>\\n\"));\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_AbstractionDefinition::testWriteWirePortForInitiatorTarget()\n//-----------------------------------------------------------------------------\nvoid tst_AbstractionDefinitionWriter::testWriteWirePortForInitiatorTarget()\n{\n    VLNV targetBus(VLNV::BUSDEFINITION, \"TUT\", \"TestLibrary\", \"TargetBusDef\", \"1.0\");\n\n    VLNV extendingVlnv(VLNV::ABSTRACTIONDEFINITION, \"TUT\", \"TestLibrary\", \"TestAbsDef\", \"1.0\");\n    QSharedPointer<AbstractionDefinition> abstractionDefinition(\n        new AbstractionDefinition(extendingVlnv, Document::Revision::Std22));\n    abstractionDefinition->setBusType(targetBus);\n\n    QSharedPointer<PortAbstraction> testPort(new PortAbstraction());\n    testPort->setName(\"reset\");\n    \n    QSharedPointer<WireAbstraction> wire(new WireAbstraction());\n    QSharedPointer<Qualifier> qualifier(new Qualifier());\n    qualifier->setType(Qualifier::Type::Reset);\n    wire->setQualifier(qualifier);\n    wire->setRequiresDriver(true);\n    wire->setDriverType(General::SINGLESHOT);\n    testPort->setWire(wire);\n\n    QSharedPointer<WirePort> initiatorPort(new WirePort);\n    initiatorPort->setPresence(PresenceTypes::OPTIONAL);\n    initiatorPort->setWidth(\"expression\");\n    initiatorPort->setDirection(DirectionTypes::IN);\n    initiatorPort->setAllBits(true);\n\n    QSharedPointer<WirePort> targetPort(new WirePort);\n    targetPort->setPresence(PresenceTypes::ILLEGAL);\n    targetPort->setDirection(DirectionTypes::OUT);\n\n    testPort->getWire()->setInitiatorPort(initiatorPort);\n    testPort->getWire()->setTargetPort(targetPort);\n\n    QSharedPointer<QList<QSharedPointer<PortAbstraction> > > ports = abstractionDefinition->getLogicalPorts();\n    ports->append(testPort);\n\n    QString output;\n    QXmlStreamWriter xmlStreamWriter(&output);\n    \n    AbstractionDefinitionWriter::writeAbstractionDefinition(xmlStreamWriter, abstractionDefinition);\n\n    QCOMPARE(output, QString(\n        \"<?xml version=\\\"1.0\\\"?>\"\n        \"<ipxact:abstractionDefinition xmlns:xsi=\\\"http://www.w3.org/2001/XMLSchema-instance\\\" \" \n        \"xmlns:ipxact=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2022\\\" \"\n        \"xmlns:kactus2=\\\"http://kactus2.cs.tut.fi\\\" \"\n        \"xsi:schemaLocation=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2022 \"\n        \"http://www.accellera.org/XMLSchema/IPXACT/1685-2022/index.xsd\\\">\"\n            \"<ipxact:vendor>TUT</ipxact:vendor>\"\n            \"<ipxact:library>TestLibrary</ipxact:library>\"\n            \"<ipxact:name>TestAbsDef</ipxact:name>\"\n            \"<ipxact:version>1.0</ipxact:version>\"\n            \"<ipxact:busType vendor=\\\"TUT\\\" library=\\\"TestLibrary\\\" name=\\\"TargetBusDef\\\" version=\\\"1.0\\\"/>\"\n            \"<ipxact:ports>\"\n                \"<ipxact:port>\"                \n                    \"<ipxact:logicalName>reset</ipxact:logicalName>\"\n                    \"<ipxact:wire>\"\n                        \"<ipxact:qualifier>\"\n                            \"<ipxact:isReset>true</ipxact:isReset>\"\n                        \"</ipxact:qualifier>\"\n                        \"<ipxact:onInitiator>\"\n                            \"<ipxact:presence>optional</ipxact:presence>\"\n                            \"<ipxact:width allBits=\\\"true\\\">expression</ipxact:width>\"\n                            \"<ipxact:direction>in</ipxact:direction>\"\n                        \"</ipxact:onInitiator>\"\n                        \"<ipxact:onTarget>\"\n                            \"<ipxact:presence>illegal</ipxact:presence>\"\n                            \"<ipxact:direction>out</ipxact:direction>\"\n                        \"</ipxact:onTarget>\"\n                        \"<ipxact:requiresDriver driverType=\\\"singleShot\\\">true</ipxact:requiresDriver>\"\n                    \"</ipxact:wire>\"\n                \"</ipxact:port>\"\n            \"</ipxact:ports>\"\n        \"</ipxact:abstractionDefinition>\\n\"));\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_AbstractionDefinition::testWriteMultipleSystemWirePorts()\n//-----------------------------------------------------------------------------\nvoid tst_AbstractionDefinitionWriter::testWriteMultipleSystemWirePorts()\n{\n    VLNV targetBus(VLNV::BUSDEFINITION, \"TUT\", \"TestLibrary\", \"TargetBusDef\", \"1.0\");\n\n    VLNV extendingVlnv(VLNV::ABSTRACTIONDEFINITION, \"TUT\", \"TestLibrary\", \"TestAbsDef\", \"1.0\");\n    QSharedPointer<AbstractionDefinition> abstractionDefinition(new AbstractionDefinition(extendingVlnv, Document::Revision::Std14));\n    abstractionDefinition->setVlnv(extendingVlnv);\n    abstractionDefinition->setBusType(targetBus);\n\n    QSharedPointer<PortAbstraction> testPort(new PortAbstraction());\n    testPort->setName(\"systemPorts\");\n    testPort->setRequiresDriver(false);\n\n    QSharedPointer<WirePort> systemPort(new WirePort);\n    systemPort->setSystemGroup(\"system1\");\n    systemPort->setPresence(PresenceTypes::REQUIRED);\n    systemPort->setWidth(\"1\");\n    systemPort->setDirection(DirectionTypes::INOUT);\n\n    QSharedPointer<WirePort> secondSystemPort(new WirePort);\n    secondSystemPort->setSystemGroup(\"system2\");\n    secondSystemPort->setPresence(PresenceTypes::OPTIONAL);\n    secondSystemPort->setWidth(\"16\");\n    secondSystemPort->setDirection(DirectionTypes::INOUT);\n\n\n    testPort->setWire(QSharedPointer<WireAbstraction>(new WireAbstraction()));\n    testPort->getWire()->addSystemPort(systemPort);\n    testPort->getWire()->addSystemPort(secondSystemPort);\n\n    QSharedPointer<QList<QSharedPointer<PortAbstraction> > > ports = abstractionDefinition->getLogicalPorts();\n    ports->append(testPort);\n\n    QString output;\n    QXmlStreamWriter xmlStreamWriter(&output);\n    \n    AbstractionDefinitionWriter::writeAbstractionDefinition(xmlStreamWriter, abstractionDefinition);\n\n    QCOMPARE(output, QString(\n        \"<?xml version=\\\"1.0\\\"?>\"\n        \"<ipxact:abstractionDefinition xmlns:xsi=\\\"http://www.w3.org/2001/XMLSchema-instance\\\" \" \n        \"xmlns:ipxact=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014\\\" \"\n        \"xmlns:kactus2=\\\"http://kactus2.cs.tut.fi\\\" \"\n        \"xsi:schemaLocation=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014 \"\n        \"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/index.xsd\\\">\"\n            \"<ipxact:vendor>TUT</ipxact:vendor>\"\n            \"<ipxact:library>TestLibrary</ipxact:library>\"\n            \"<ipxact:name>TestAbsDef</ipxact:name>\"\n            \"<ipxact:version>1.0</ipxact:version>\"\n            \"<ipxact:busType vendor=\\\"TUT\\\" library=\\\"TestLibrary\\\" name=\\\"TargetBusDef\\\" version=\\\"1.0\\\"/>\"\n            \"<ipxact:ports>\"\n                \"<ipxact:port>\"                \n                    \"<ipxact:logicalName>systemPorts</ipxact:logicalName>\"\n                    \"<ipxact:wire>\"\n                        \"<ipxact:onSystem>\"\n                            \"<ipxact:group>system1</ipxact:group>\"\n                            \"<ipxact:presence>required</ipxact:presence>\"\n                            \"<ipxact:width>1</ipxact:width>\"\n                            \"<ipxact:direction>inout</ipxact:direction>\"\n                        \"</ipxact:onSystem>\" \n                        \"<ipxact:onSystem>\"\n                            \"<ipxact:group>system2</ipxact:group>\"\n                            \"<ipxact:presence>optional</ipxact:presence>\"\n                            \"<ipxact:width>16</ipxact:width>\"\n                            \"<ipxact:direction>inout</ipxact:direction>\"\n                        \"</ipxact:onSystem>\" \n                    \"</ipxact:wire>\"\n                \"</ipxact:port>\"\n            \"</ipxact:ports>\"\n        \"</ipxact:abstractionDefinition>\\n\"));\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_AbstractionDefinition::testWireConstraints()\n//-----------------------------------------------------------------------------\nvoid tst_AbstractionDefinitionWriter::testWireConstraints()\n{\n    VLNV targetBus(VLNV::BUSDEFINITION, \"TUT\", \"TestLibrary\", \"TargetBusDef\", \"1.0\");\n\n    VLNV extendingVlnv(VLNV::ABSTRACTIONDEFINITION, \"TUT\", \"TestLibrary\", \"TestAbsDef\", \"1.0\");\n    QSharedPointer<AbstractionDefinition> abstractionDefinition(new AbstractionDefinition(extendingVlnv, Document::Revision::Std14));\n    abstractionDefinition->setVlnv(extendingVlnv);\n    abstractionDefinition->setBusType(targetBus);\n\n    QSharedPointer<PortAbstraction> testPort(new PortAbstraction());\n    testPort->setName(\"constrainedPort\");\n\n    QSharedPointer<TimingConstraint> timeConstraint(new TimingConstraint());\n    timeConstraint->setValue(80.0);\n    timeConstraint->setClockEdge(TimingConstraint::FALL);\n    timeConstraint->setDelayType(TimingConstraint::MINIMUM_DELAY);\n    timeConstraint->setClockName(\"clk\");\n\n    QSharedPointer<CellSpecification> driveConstraint(new CellSpecification());\n    driveConstraint->setCellClass(CellSpecification::COMBINATORIAL);\n\n    QSharedPointer<CellSpecification> loadConstraint(new CellSpecification());\n    loadConstraint->setCellStrength(CellSpecification::LOW);\n    loadConstraint->setCellFunction(\"inv\");\n\n    QSharedPointer<WirePort> masterPort(new WirePort);\n    masterPort->setTimingConstraint(timeConstraint);\n    masterPort->setDriveConstraint(driveConstraint);\n    masterPort->setLoadConstraint(loadConstraint);\n\n    testPort->setWire(QSharedPointer<WireAbstraction>(new WireAbstraction()));\n    testPort->getWire()->setMasterPort(masterPort);\n\n    abstractionDefinition->getLogicalPorts()->append(testPort);\n\n    QString output;\n    QXmlStreamWriter xmlStreamWriter(&output);\n    \n    AbstractionDefinitionWriter::writeAbstractionDefinition(xmlStreamWriter, abstractionDefinition);\n\n    QCOMPARE(output, QString(\n        \"<?xml version=\\\"1.0\\\"?>\"\n        \"<ipxact:abstractionDefinition xmlns:xsi=\\\"http://www.w3.org/2001/XMLSchema-instance\\\" \" \n        \"xmlns:ipxact=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014\\\" \"\n        \"xmlns:kactus2=\\\"http://kactus2.cs.tut.fi\\\" \"\n        \"xsi:schemaLocation=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014 \"\n        \"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/index.xsd\\\">\"\n            \"<ipxact:vendor>TUT</ipxact:vendor>\"\n            \"<ipxact:library>TestLibrary</ipxact:library>\"\n            \"<ipxact:name>TestAbsDef</ipxact:name>\"\n            \"<ipxact:version>1.0</ipxact:version>\"\n            \"<ipxact:busType vendor=\\\"TUT\\\" library=\\\"TestLibrary\\\" name=\\\"TargetBusDef\\\" version=\\\"1.0\\\"/>\"\n            \"<ipxact:ports>\"\n                \"<ipxact:port>\"                \n                    \"<ipxact:logicalName>constrainedPort</ipxact:logicalName>\"\n                    \"<ipxact:wire>\"\n                        \"<ipxact:onMaster>\"\n                            \"<ipxact:modeConstraints>\"\n                                \"<ipxact:timingConstraint clockEdge=\\\"fall\\\" delayType=\\\"min\\\" clockName=\\\"clk\\\">80</ipxact:timingConstraint>\"\n                                \"<ipxact:driveConstraint>\"\n                                    \"<ipxact:cellSpecification>\"\n                                        \"<ipxact:cellClass>combinatorial</ipxact:cellClass>\"\n                                    \"</ipxact:cellSpecification>\"\n                                \"</ipxact:driveConstraint>\"\n                                \"<ipxact:loadConstraint>\"\n                                    \"<ipxact:cellSpecification cellStrength=\\\"low\\\">\"\n                                        \"<ipxact:cellFunction>inv</ipxact:cellFunction>\"\n                                    \"</ipxact:cellSpecification>\"\n                                \"</ipxact:loadConstraint>\"\n                            \"</ipxact:modeConstraints>\"\n                        \"</ipxact:onMaster>\"\n                    \"</ipxact:wire>\"\n                \"</ipxact:port>\"\n            \"</ipxact:ports>\"\n        \"</ipxact:abstractionDefinition>\\n\"));\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_AbstractionDefinition::testWireMirroredConstraints()\n//-----------------------------------------------------------------------------\nvoid tst_AbstractionDefinitionWriter::testWireMirroredConstraints()\n{\n    VLNV targetBus(VLNV::BUSDEFINITION, \"TUT\", \"TestLibrary\", \"TargetBusDef\", \"1.0\");\n\n    VLNV extendingVlnv(VLNV::ABSTRACTIONDEFINITION, \"TUT\", \"TestLibrary\", \"TestAbsDef\", \"1.0\");\n    QSharedPointer<AbstractionDefinition> abstractionDefinition(new AbstractionDefinition(extendingVlnv, Document::Revision::Std14));\n    abstractionDefinition->setVlnv(extendingVlnv);\n    abstractionDefinition->setBusType(targetBus);\n\n    QSharedPointer<PortAbstraction> testPort(new PortAbstraction());\n    testPort->setName(\"constrainedPort\");\n\n    QSharedPointer<TimingConstraint> timeConstraint(new TimingConstraint());\n    timeConstraint->setValue(45.6);\n    timeConstraint->setClockEdge(TimingConstraint::RISE);\n    timeConstraint->setDelayType(TimingConstraint::MAXIMUM_DELAY);\n    timeConstraint->setClockName(\"clk\");\n\n    QSharedPointer<CellSpecification> driveConstraint(new CellSpecification());\n    driveConstraint->setCellClass(CellSpecification::SEQUENTIAL);\n\n    QSharedPointer<CellSpecification> loadConstraint(new CellSpecification());\n    loadConstraint->setCellStrength(CellSpecification::HIGH);\n    loadConstraint->setCellFunction(\"customFunction\");\n\n    QSharedPointer<WirePort> masterPort(new WirePort);\n    masterPort->setMirroredTimingConstraint(timeConstraint);\n    masterPort->setMirroredDriveConstraint(driveConstraint);\n    masterPort->setMirroredLoadConstraint(loadConstraint);\n\n    testPort->setWire(QSharedPointer<WireAbstraction>(new WireAbstraction()));\n    testPort->getWire()->setMasterPort(masterPort);\n\n    abstractionDefinition->getLogicalPorts()->append(testPort);\n\n    QString output;\n    QXmlStreamWriter xmlStreamWriter(&output);\n    \n    AbstractionDefinitionWriter::writeAbstractionDefinition(xmlStreamWriter, abstractionDefinition);\n\n    QCOMPARE(output, QString(\n        \"<?xml version=\\\"1.0\\\"?>\"\n        \"<ipxact:abstractionDefinition xmlns:xsi=\\\"http://www.w3.org/2001/XMLSchema-instance\\\" \" \n        \"xmlns:ipxact=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014\\\" \"\n        \"xmlns:kactus2=\\\"http://kactus2.cs.tut.fi\\\" \"\n        \"xsi:schemaLocation=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014 \"\n        \"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/index.xsd\\\">\"\n            \"<ipxact:vendor>TUT</ipxact:vendor>\"\n            \"<ipxact:library>TestLibrary</ipxact:library>\"\n            \"<ipxact:name>TestAbsDef</ipxact:name>\"\n            \"<ipxact:version>1.0</ipxact:version>\"\n            \"<ipxact:busType vendor=\\\"TUT\\\" library=\\\"TestLibrary\\\" name=\\\"TargetBusDef\\\" version=\\\"1.0\\\"/>\"\n            \"<ipxact:ports>\"\n                \"<ipxact:port>\"                \n                    \"<ipxact:logicalName>constrainedPort</ipxact:logicalName>\"\n                    \"<ipxact:wire>\"\n                        \"<ipxact:onMaster>\"\n                        \"<ipxact:mirroredModeConstraints>\"\n                            \"<ipxact:timingConstraint clockEdge=\\\"rise\\\" delayType=\\\"max\\\" clockName=\\\"clk\\\">45.6</ipxact:timingConstraint>\"\n                            \"<ipxact:driveConstraint>\"\n                                \"<ipxact:cellSpecification>\"\n                                    \"<ipxact:cellClass>sequential</ipxact:cellClass>\"\n                                \"</ipxact:cellSpecification>\"\n                            \"</ipxact:driveConstraint>\"\n                            \"<ipxact:loadConstraint>\"\n                                \"<ipxact:cellSpecification cellStrength=\\\"high\\\">\"\n                                    \"<ipxact:cellFunction other=\\\"customFunction\\\">other</ipxact:cellFunction>\"\n                                \"</ipxact:cellSpecification>\"\n                            \"</ipxact:loadConstraint>\"\n                        \"</ipxact:mirroredModeConstraints>\"\n                    \"</ipxact:onMaster>\"\n                \"</ipxact:wire>\"\n                \"</ipxact:port>\"\n            \"</ipxact:ports>\"\n        \"</ipxact:abstractionDefinition>\\n\"));\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_AbstractionDefinition::testWriteSimpleTransactionalPort()\n//-----------------------------------------------------------------------------\nvoid tst_AbstractionDefinitionWriter::testWriteSimpleTransactionalPort()\n{\n    VLNV targetBus(VLNV::BUSDEFINITION, \"TUT\", \"TestLibrary\", \"TargetBusDef\", \"1.0\");\n\n    VLNV extendingVlnv(VLNV::ABSTRACTIONDEFINITION, \"TUT\", \"TestLibrary\", \"TestAbsDef\", \"1.0\");\n    QSharedPointer<AbstractionDefinition> abstractionDefinition(new AbstractionDefinition(extendingVlnv, Document::Revision::Std14));\n    abstractionDefinition->setVlnv(extendingVlnv);\n    abstractionDefinition->setBusType(targetBus);\n\n    QSharedPointer<PortAbstraction> testPort(new PortAbstraction());\n    testPort->setName(\"testPort\");\n\n    testPort->setTransactional(QSharedPointer<TransactionalAbstraction>(new TransactionalAbstraction()));\n    QSharedPointer<Qualifier> testQualifier(new Qualifier());\n    testQualifier->setType(Qualifier::Type::Data);\n    testPort->getTransactional()->setQualifier(testQualifier);\n    \n    abstractionDefinition->getLogicalPorts()->append(testPort);\n\n    QString output;\n    QXmlStreamWriter xmlStreamWriter(&output);\n    \n    AbstractionDefinitionWriter::writeAbstractionDefinition(xmlStreamWriter, abstractionDefinition);\n\n    QCOMPARE(output, QString(\n        \"<?xml version=\\\"1.0\\\"?>\"\n        \"<ipxact:abstractionDefinition xmlns:xsi=\\\"http://www.w3.org/2001/XMLSchema-instance\\\" \" \n        \"xmlns:ipxact=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014\\\" \"\n        \"xmlns:kactus2=\\\"http://kactus2.cs.tut.fi\\\" \"\n        \"xsi:schemaLocation=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014 \"\n        \"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/index.xsd\\\">\"\n            \"<ipxact:vendor>TUT</ipxact:vendor>\"\n            \"<ipxact:library>TestLibrary</ipxact:library>\"\n            \"<ipxact:name>TestAbsDef</ipxact:name>\"\n            \"<ipxact:version>1.0</ipxact:version>\"\n            \"<ipxact:busType vendor=\\\"TUT\\\" library=\\\"TestLibrary\\\" name=\\\"TargetBusDef\\\" version=\\\"1.0\\\"/>\"\n            \"<ipxact:ports>\"\n                \"<ipxact:port>\"\n                    \"<ipxact:logicalName>testPort</ipxact:logicalName>\"\n                    \"<ipxact:transactional>\"\n                        \"<ipxact:qualifier>\"\n                            \"<ipxact:isData>true</ipxact:isData>\"\n                        \"</ipxact:qualifier>\"        \n                    \"</ipxact:transactional>\"        \n                \"</ipxact:port>\"\n            \"</ipxact:ports>\"\n        \"</ipxact:abstractionDefinition>\\n\"));\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_AbstractionDefinition::testWriteTransactionalPortForAllModes()\n//-----------------------------------------------------------------------------\nvoid tst_AbstractionDefinitionWriter::testWriteTransactionalPortForAllModes()\n{\n    VLNV targetBus(VLNV::BUSDEFINITION, \"TUT\", \"TestLibrary\", \"TargetBusDef\", \"1.0\");\n\n    VLNV extendingVlnv(VLNV::ABSTRACTIONDEFINITION, \"TUT\", \"TestLibrary\", \"TestAbsDef\", \"1.0\");\n    QSharedPointer<AbstractionDefinition> abstractionDefinition(new AbstractionDefinition(extendingVlnv, Document::Revision::Std14));\n    abstractionDefinition->setVlnv(extendingVlnv);\n    abstractionDefinition->setBusType(targetBus);\n\n    QSharedPointer<PortAbstraction> testPort(new PortAbstraction());\n    testPort->setName(\"testPort\");\n\n    QSharedPointer<TransactionalAbstraction> transactional(new TransactionalAbstraction());\n    testPort->setTransactional(transactional);\n\n    QSharedPointer<TransactionalPort> systemPort(new TransactionalPort());\n    systemPort->setSystemGroup(\"illegalGroup\");\n    systemPort->setPresence(PresenceTypes::ILLEGAL);\n    transactional->addSystemPort(systemPort);\n\n    QSharedPointer<TransactionalPort> secondSystemPort(new TransactionalPort());\n    secondSystemPort->setSystemGroup(\"requiredGroup\");\n    secondSystemPort->setPresence(PresenceTypes::REQUIRED);\n    transactional->addSystemPort(secondSystemPort);\n\n    QSharedPointer<TransactionalPort> masterPort(new TransactionalPort());\n    masterPort->setPresence(PresenceTypes::OPTIONAL);\n    masterPort->setInitiative(\"requires\");\n    masterPort->setKind(\"tlm_port\");\n    masterPort->setBusWidth(\"32\");\n    transactional->setMasterPort(masterPort);\n\n    QSharedPointer<TransactionalPort> slavePort(new TransactionalPort());\n    slavePort->setPresence(PresenceTypes::OPTIONAL);\n    slavePort->setInitiative(\"provides\");\n    slavePort->setKind(\"customKind\");\n    transactional->setSlavePort(slavePort);\n\n    abstractionDefinition->getLogicalPorts()->append(testPort);\n\n    QString output;\n    QXmlStreamWriter xmlStreamWriter(&output);\n    \n    AbstractionDefinitionWriter::writeAbstractionDefinition(xmlStreamWriter, abstractionDefinition);\n\n    QCOMPARE(output, QString(\n        \"<?xml version=\\\"1.0\\\"?>\"\n        \"<ipxact:abstractionDefinition xmlns:xsi=\\\"http://www.w3.org/2001/XMLSchema-instance\\\" \" \n        \"xmlns:ipxact=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014\\\" \"\n        \"xmlns:kactus2=\\\"http://kactus2.cs.tut.fi\\\" \"\n        \"xsi:schemaLocation=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014 \"\n        \"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/index.xsd\\\">\"\n            \"<ipxact:vendor>TUT</ipxact:vendor>\"\n            \"<ipxact:library>TestLibrary</ipxact:library>\"\n            \"<ipxact:name>TestAbsDef</ipxact:name>\"\n            \"<ipxact:version>1.0</ipxact:version>\"\n            \"<ipxact:busType vendor=\\\"TUT\\\" library=\\\"TestLibrary\\\" name=\\\"TargetBusDef\\\" version=\\\"1.0\\\"/>\"\n            \"<ipxact:ports>\"\n                \"<ipxact:port>\"                \n                    \"<ipxact:logicalName>testPort</ipxact:logicalName>\"\n                    \"<ipxact:transactional>\"    \n                    \"<ipxact:onSystem>\"\n                        \"<ipxact:group>illegalGroup</ipxact:group>\"\n                        \"<ipxact:presence>illegal</ipxact:presence>\"\n                    \"</ipxact:onSystem>\" \n                        \"<ipxact:onSystem>\"\n                            \"<ipxact:group>requiredGroup</ipxact:group>\"\n                            \"<ipxact:presence>required</ipxact:presence>\"\n                        \"</ipxact:onSystem>\" \n                        \"<ipxact:onMaster>\"\n                            \"<ipxact:presence>optional</ipxact:presence>\"\n                            \"<ipxact:initiative>requires</ipxact:initiative>\"\n                            \"<ipxact:kind>tlm_port</ipxact:kind>\"\n                            \"<ipxact:busWidth>32</ipxact:busWidth>\"\n                        \"</ipxact:onMaster>\" \n                        \"<ipxact:onSlave>\"\n                            \"<ipxact:presence>optional</ipxact:presence>\"\n                            \"<ipxact:initiative>provides</ipxact:initiative>\"\n                            \"<ipxact:kind custom=\\\"customKind\\\">custom</ipxact:kind>\"\n                        \"</ipxact:onSlave>\"    \n                    \"</ipxact:transactional>\"\n                \"</ipxact:port>\"\n            \"</ipxact:ports>\"\n        \"</ipxact:abstractionDefinition>\\n\"));\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_AbstractionDefinition::testWriteTransactionalPortWithProtocol()\n//-----------------------------------------------------------------------------\nvoid tst_AbstractionDefinitionWriter::testWriteTransactionalPortWithProtocol()\n{\n    VLNV targetBus(VLNV::BUSDEFINITION, \"TUT\", \"TestLibrary\", \"TargetBusDef\", \"1.0\");\n\n    VLNV extendingVlnv(VLNV::ABSTRACTIONDEFINITION, \"TUT\", \"TestLibrary\", \"TestAbsDef\", \"1.0\");\n    QSharedPointer<AbstractionDefinition> abstractionDefinition(new AbstractionDefinition(extendingVlnv, Document::Revision::Std14));\n    abstractionDefinition->setVlnv(extendingVlnv);\n    abstractionDefinition->setBusType(targetBus);\n\n    QSharedPointer<PortAbstraction> testPort(new PortAbstraction());\n    testPort->setName(\"testPort\");\n\n    QSharedPointer<TransactionalAbstraction> transactional(new TransactionalAbstraction());\n    testPort->setTransactional(transactional);\n\n    QSharedPointer<Protocol> portProtocol(new Protocol());\n    portProtocol->setProtocolType(\"tlm\");\n    portProtocol->setPayloadName(\"data\");\n    portProtocol->setPayloadExtension(\"extension\", true);\n    portProtocol->setPayloadType(\"generic\");\n\n    QDomDocument document;\n    QDomElement extensionNode = document.createElement(\"kactus2:testExtension\");\n    extensionNode.setAttribute(\"vendorAttribute\", \"extension\");\n    extensionNode.appendChild(document.createTextNode(\"testValue\"));\n\n    QSharedPointer<GenericVendorExtension> testExtension(new GenericVendorExtension(extensionNode));\n    QSharedPointer<QList<QSharedPointer<VendorExtension> > > payloadVendorExtensions = portProtocol->getVendorExtensions();\n    payloadVendorExtensions->append(testExtension);\n\n    QSharedPointer<TransactionalPort> masterPort(new TransactionalPort());\n    masterPort->setProtocol(portProtocol);\n    transactional->setMasterPort(masterPort);\n\n    abstractionDefinition->getLogicalPorts()->append(testPort);\n\n    QString output;\n    QXmlStreamWriter xmlStreamWriter(&output);\n    \n    AbstractionDefinitionWriter::writeAbstractionDefinition(xmlStreamWriter, abstractionDefinition);\n\n    QCOMPARE(output, QString(\n        \"<?xml version=\\\"1.0\\\"?>\"\n        \"<ipxact:abstractionDefinition xmlns:xsi=\\\"http://www.w3.org/2001/XMLSchema-instance\\\" \" \n        \"xmlns:ipxact=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014\\\" \"\n        \"xmlns:kactus2=\\\"http://kactus2.cs.tut.fi\\\" \"\n        \"xsi:schemaLocation=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014 \"\n        \"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/index.xsd\\\">\"\n            \"<ipxact:vendor>TUT</ipxact:vendor>\"\n            \"<ipxact:library>TestLibrary</ipxact:library>\"\n            \"<ipxact:name>TestAbsDef</ipxact:name>\"\n            \"<ipxact:version>1.0</ipxact:version>\"\n            \"<ipxact:busType vendor=\\\"TUT\\\" library=\\\"TestLibrary\\\" name=\\\"TargetBusDef\\\" version=\\\"1.0\\\"/>\"\n             \"<ipxact:ports>\"\n                \"<ipxact:port>\"                \n                    \"<ipxact:logicalName>testPort</ipxact:logicalName>\"\n                    \"<ipxact:transactional>\"                    \n                        \"<ipxact:onMaster>\"\n                            \"<ipxact:protocol>\"\n                                \"<ipxact:protocolType>tlm</ipxact:protocolType>\"\n                                \"<ipxact:payload>\"\n                                    \"<ipxact:name>data</ipxact:name>\"\n                                    \"<ipxact:type>generic</ipxact:type>\"\n                                    \"<ipxact:extension mandatory=\\\"true\\\">extension</ipxact:extension>\"\n                                    \"<ipxact:vendorExtensions>\"\n                                        \"<kactus2:testExtension vendorAttribute=\\\"extension\\\">testValue</kactus2:testExtension>\"\n                                    \"</ipxact:vendorExtensions>\"\n                                \"</ipxact:payload>\"\n                            \"</ipxact:protocol>\"\n                        \"</ipxact:onMaster>\" \n                    \"</ipxact:transactional>\"\n                \"</ipxact:port>\"\n            \"</ipxact:ports>\"\n        \"</ipxact:abstractionDefinition>\\n\"));\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_AbstractionDefinition::testWriteChoices()\n//-----------------------------------------------------------------------------\nvoid tst_AbstractionDefinitionWriter::testWriteChoices()\n{\n    VLNV targetBus(VLNV::BUSDEFINITION, \"TUT\", \"TestLibrary\", \"TargetBusDef\", \"1.0\");\n\n    VLNV vlnv(VLNV::ABSTRACTIONDEFINITION, \"TUT\", \"TestLibrary\", \"TestBus\", \"1.0\");\n    QSharedPointer<AbstractionDefinition> abstractionDefinition(\n        new AbstractionDefinition(vlnv, Document::Revision::Std22));\n    abstractionDefinition->setBusType(targetBus);\n\n    QSharedPointer<Choice> testChoice(new Choice);\n    testChoice->setName(\"testChoice\");\n    \n    QSharedPointer<Enumeration> testEnumeration1(new Enumeration());\n    testEnumeration1->setHelp(\"test enumeration 1\");\n    testEnumeration1->setValue(\"enumeration1\");\n    \n    QSharedPointer<Enumeration> testEnumeration2(new Enumeration());\n    testEnumeration2->setText(\"enum2\");\n    testEnumeration2->setValue(\"enumeration2\");\n\n    testChoice->enumerations()->append(testEnumeration1);\n    testChoice->enumerations()->append(testEnumeration2);\n\n    abstractionDefinition->getChoices()->append(testChoice);\n\n    QString output;\n    QXmlStreamWriter xmlStreamWriter(&output);\n    \n    AbstractionDefinitionWriter::writeAbstractionDefinition(xmlStreamWriter, abstractionDefinition);\n\n    QCOMPARE(output, QString(\n        \"<?xml version=\\\"1.0\\\"?>\"\n        \"<ipxact:abstractionDefinition xmlns:xsi=\\\"http://www.w3.org/2001/XMLSchema-instance\\\" \" \n        \"xmlns:ipxact=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2022\\\" \"\n        \"xmlns:kactus2=\\\"http://kactus2.cs.tut.fi\\\" \"\n        \"xsi:schemaLocation=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2022 \"\n        \"http://www.accellera.org/XMLSchema/IPXACT/1685-2022/index.xsd\\\">\"\n            \"<ipxact:vendor>TUT</ipxact:vendor>\"\n            \"<ipxact:library>TestLibrary</ipxact:library>\"\n            \"<ipxact:name>TestBus</ipxact:name>\"\n            \"<ipxact:version>1.0</ipxact:version>\"\n            \"<ipxact:busType vendor=\\\"TUT\\\" library=\\\"TestLibrary\\\" name=\\\"TargetBusDef\\\" version=\\\"1.0\\\"/>\"\n            \"<ipxact:choices>\"\n                \"<ipxact:choice>\"\n                    \"<ipxact:name>testChoice</ipxact:name>\"\n                    \"<ipxact:enumeration help=\\\"test enumeration 1\\\">enumeration1</ipxact:enumeration>\"\n                    \"<ipxact:enumeration text=\\\"enum2\\\">enumeration2</ipxact:enumeration>\"\n                \"</ipxact:choice>\"\n            \"</ipxact:choices>\"\n        \"</ipxact:abstractionDefinition>\\n\"));\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_AbstractionDefinition::testWriteParameters()\n//-----------------------------------------------------------------------------\nvoid tst_AbstractionDefinitionWriter::testWriteParameters()\n{\n    VLNV targetBus(VLNV::BUSDEFINITION, \"TUT\", \"TestLibrary\", \"TargetBusDef\", \"1.0\");\n\n    VLNV vlnv(VLNV::ABSTRACTIONDEFINITION, \"TUT\", \"TestLibrary\", \"TestBus\", \"1.0\");\n    QSharedPointer<AbstractionDefinition> abstractionDefinition(new AbstractionDefinition(vlnv, Document::Revision::Std14));\n    abstractionDefinition->setVlnv(vlnv);\n    abstractionDefinition->setBusType(targetBus);\n\n    QSharedPointer<Parameter> firstParameter(new Parameter());\n    firstParameter->setName(\"parameter1\");\n    firstParameter->setValueId(\"\");\n    firstParameter->setValue(\"1\");\n\n    QSharedPointer<Parameter> secondParameter(new Parameter());\n    secondParameter->setName(\"parameter2\");\n    secondParameter->setValueId(\"\");\n    secondParameter->setValue(\"text\");\n\n    QSharedPointer<QList<QSharedPointer<Parameter> > > busParameters = abstractionDefinition->getParameters();\n    busParameters->append(firstParameter);\n    busParameters->append(secondParameter);\n\n    QString output;\n    QXmlStreamWriter xmlStreamWriter(&output);\n    \n    AbstractionDefinitionWriter::writeAbstractionDefinition(xmlStreamWriter, abstractionDefinition);\n\n    QCOMPARE(output, QString(\n        \"<?xml version=\\\"1.0\\\"?>\"\n        \"<ipxact:abstractionDefinition xmlns:xsi=\\\"http://www.w3.org/2001/XMLSchema-instance\\\" \" \n        \"xmlns:ipxact=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014\\\" \"\n        \"xmlns:kactus2=\\\"http://kactus2.cs.tut.fi\\\" \"\n        \"xsi:schemaLocation=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014 \"\n        \"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/index.xsd\\\">\"\n            \"<ipxact:vendor>TUT</ipxact:vendor>\"\n            \"<ipxact:library>TestLibrary</ipxact:library>\"\n            \"<ipxact:name>TestBus</ipxact:name>\"\n            \"<ipxact:version>1.0</ipxact:version>\"\n            \"<ipxact:busType vendor=\\\"TUT\\\" library=\\\"TestLibrary\\\" name=\\\"TargetBusDef\\\" version=\\\"1.0\\\"/>\"\n            \"<ipxact:parameters>\"\n                \"<ipxact:parameter>\"\n                    \"<ipxact:name>parameter1</ipxact:name>\"\n                    \"<ipxact:value>1</ipxact:value>\"\n                \"</ipxact:parameter>\"\n                \"<ipxact:parameter>\"\n                    \"<ipxact:name>parameter2</ipxact:name>\"\n                    \"<ipxact:value>text</ipxact:value>\"\n                \"</ipxact:parameter>\"\n            \"</ipxact:parameters>\"\n        \"</ipxact:abstractionDefinition>\\n\"));\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_AbstractionDefinition::testWriteAssertions()\n//-----------------------------------------------------------------------------\nvoid tst_AbstractionDefinitionWriter::testWriteAssertions()\n{\n    VLNV targetBus(VLNV::BUSDEFINITION, \"TUT\", \"TestLibrary\", \"TargetBusDef\", \"1.0\");\n\n    VLNV vlnv(VLNV::ABSTRACTIONDEFINITION, \"TUT\", \"TestLibrary\", \"TestBus\", \"1.0\");\n    QSharedPointer<AbstractionDefinition> abstractionDefinition(new AbstractionDefinition(vlnv, Document::Revision::Std14));\n    abstractionDefinition->setVlnv(vlnv);\n    abstractionDefinition->setBusType(targetBus);\n\n    QSharedPointer<Assertion> firstTestAssertion(new Assertion());\n    firstTestAssertion->setName(\"testAssertion1\");\n    firstTestAssertion->setDisplayName(\"Display name for assertion.\");\n    firstTestAssertion->setDescription(\"Description for assertion.\");\n    firstTestAssertion->setAssert(\"1\");\n\n    QSharedPointer<Assertion> secondTestAssertion(new Assertion());\n    secondTestAssertion->setName(\"testAssertion2\");\n    secondTestAssertion->setAssert(\"0\");\n\n    abstractionDefinition->getAssertions()->append(firstTestAssertion);\n    abstractionDefinition->getAssertions()->append(secondTestAssertion);\n\n    QString output;\n    QXmlStreamWriter xmlStreamWriter(&output);\n    \n    AbstractionDefinitionWriter::writeAbstractionDefinition(xmlStreamWriter, abstractionDefinition);\n\n    QCOMPARE(output, QString(\n        \"<?xml version=\\\"1.0\\\"?>\"\n        \"<ipxact:abstractionDefinition xmlns:xsi=\\\"http://www.w3.org/2001/XMLSchema-instance\\\" \" \n        \"xmlns:ipxact=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014\\\" \"\n        \"xmlns:kactus2=\\\"http://kactus2.cs.tut.fi\\\" \"\n        \"xsi:schemaLocation=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014 \"\n        \"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/index.xsd\\\">\"\n        \"<ipxact:vendor>TUT</ipxact:vendor>\"\n        \"<ipxact:library>TestLibrary</ipxact:library>\"\n        \"<ipxact:name>TestBus</ipxact:name>\"\n        \"<ipxact:version>1.0</ipxact:version>\"\n        \"<ipxact:busType vendor=\\\"TUT\\\" library=\\\"TestLibrary\\\" name=\\\"TargetBusDef\\\" version=\\\"1.0\\\"/>\"\n            \"<ipxact:assertions>\"\n                \"<ipxact:assertion>\"\n                    \"<ipxact:name>testAssertion1</ipxact:name>\"\n                    \"<ipxact:displayName>Display name for assertion.</ipxact:displayName>\"\n                    \"<ipxact:description>Description for assertion.</ipxact:description>\"\n                    \"<ipxact:assert>1</ipxact:assert>\"\n                \"</ipxact:assertion>\"\n                \"<ipxact:assertion>\"\n                    \"<ipxact:name>testAssertion2</ipxact:name>\"\n                    \"<ipxact:assert>0</ipxact:assert>\"\n                \"</ipxact:assertion>\"\n            \"</ipxact:assertions>\"\n        \"</ipxact:abstractionDefinition>\\n\"));\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_AbstractionDefinition::testVendorExtensions()\n//-----------------------------------------------------------------------------\nvoid tst_AbstractionDefinitionWriter::testVendorExtensions()\n{\n    VLNV targetBus(VLNV::BUSDEFINITION, \"TUT\", \"TestLibrary\", \"TargetBusDef\", \"1.0\");\n\n    VLNV vlnv(VLNV::ABSTRACTIONDEFINITION, \"TUT\", \"TestLibrary\", \"TestBus\", \"1.0\");\n    QSharedPointer<AbstractionDefinition> abstractionDefinition(new AbstractionDefinition(vlnv, Document::Revision::Std14));\n    abstractionDefinition->setVlnv(vlnv);\n    abstractionDefinition->setBusType(targetBus);\n    abstractionDefinition->setVersion(\"3.0.0\");\n\n    QDomDocument document;\n    QDomElement extensionNode = document.createElement(\"kactus2:testExtension\");\n    extensionNode.setAttribute(\"vendorAttribute\", \"extension\");\n    extensionNode.appendChild(document.createTextNode(\"testValue\"));\n\n    QSharedPointer<GenericVendorExtension> testExtension(new GenericVendorExtension(extensionNode));\n    QSharedPointer<QList<QSharedPointer<VendorExtension> > > vendorExtensions = abstractionDefinition->getVendorExtensions();\n    vendorExtensions->append(testExtension);\n\n    QString output;\n    QXmlStreamWriter xmlStreamWriter(&output);\n    \n    AbstractionDefinitionWriter::writeAbstractionDefinition(xmlStreamWriter, abstractionDefinition);\n\n    QCOMPARE(output, QString(\n        \"<?xml version=\\\"1.0\\\"?>\"\n        \"<ipxact:abstractionDefinition xmlns:xsi=\\\"http://www.w3.org/2001/XMLSchema-instance\\\" \" \n        \"xmlns:ipxact=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014\\\" \"\n        \"xmlns:kactus2=\\\"http://kactus2.cs.tut.fi\\\" \"\n        \"xsi:schemaLocation=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014 \"\n        \"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/index.xsd\\\">\"\n            \"<ipxact:vendor>TUT</ipxact:vendor>\"\n            \"<ipxact:library>TestLibrary</ipxact:library>\"\n            \"<ipxact:name>TestBus</ipxact:name>\"\n            \"<ipxact:version>1.0</ipxact:version>\"\n            \"<ipxact:busType vendor=\\\"TUT\\\" library=\\\"TestLibrary\\\" name=\\\"TargetBusDef\\\" version=\\\"1.0\\\"/>\"\n            \"<ipxact:vendorExtensions>\"\n                \"<kactus2:version>3.0.0</kactus2:version>\"\n                \"<kactus2:testExtension vendorAttribute=\\\"extension\\\">testValue</kactus2:testExtension>\"       \n            \"</ipxact:vendorExtensions>\"\n        \"</ipxact:abstractionDefinition>\\n\"));\n}\n\nQTEST_APPLESS_MAIN(tst_AbstractionDefinitionWriter)\n\n#include \"tst_AbstractionDefinitionWriter.moc\"\n"
  },
  {
    "path": "tests/IPXACTmodels/AbstractionDefinition/tst_AbstractionDefinitionWriter.pri",
    "content": "# ----------------------------------------------------\r\n# This file is generated by the Qt Visual Studio Add-in.\r\n# ------------------------------------------------------\r\n\t\r\nSOURCES += ./tst_AbstractionDefinitionWriter.cpp\r\n"
  },
  {
    "path": "tests/IPXACTmodels/AbstractionDefinition/tst_AbstractionDefinitionWriter.pro",
    "content": "#-----------------------------------------------------------------------------\r\n# File: tst_AbstractionDefinitionWriter.pro\r\n#-----------------------------------------------------------------------------\r\n# Project: Kactus 2\r\n# Author: Esko Pekkarinen\r\n# Date: 05.08.2015\r\n#\r\n# Description:\r\n# Qt project file for running unit tests for AbstractionDefinition Writer.\r\n#-----------------------------------------------------------------------------\r\n\r\nTEMPLATE = app\r\n\r\nTARGET = tst_AbstractionDefinitionWriter\r\n\r\nQT += core xml testlib\r\nQT -= gui\r\n\r\nCONFIG += c++11 testcase console\r\n\r\nlinux-g++ | linux-g++-64 | linux-g++-32 {\r\n LIBS += -L../../../executable \\\r\n     -lIPXACTmodels\r\n}\r\nwin64 | win32 {\r\n LIBS += -L../../../executable/ \\\r\n     -lIPXACTmodelsd\r\n}\r\n\r\nDESTDIR = ./release\r\n\r\nINCLUDEPATH += $$DESTDIR\r\nINCLUDEPATH += ../../../\r\n\r\nDEPENDPATH += .\r\n\r\nOBJECTS_DIR += $$DESTDIR\r\n\r\nMOC_DIR += ./generatedFiles\r\nUI_DIR += ./generatedFiles\r\nRCC_DIR += ./generatedFiles\r\ninclude(tst_AbstractionDefinitionWriter.pri)\r\n"
  },
  {
    "path": "tests/IPXACTmodels/BusDefinition/BusDefinition.pro",
    "content": "#-----------------------------------------------------------------------------\n# File: BusDefinition.pro\n#-----------------------------------------------------------------------------\n# Project: Kactus2\n# Author: Esko Pekkarinen\n# Date: 04.05.2018\n#\n# Description:\n# Qt project file template for running unit tests for BusDefinition.\n#-----------------------------------------------------------------------------\n\nTEMPLATE = subdirs\n\nCONFIG += testcase\nSUBDIRS += tst_BusDefinitionReader.pro \\\n\t       tst_BusDefinitionWriter.pro \\\n\t\t   tst_BusDefinitionValidator.pro\n"
  },
  {
    "path": "tests/IPXACTmodels/BusDefinition/tst_BusDefinitionReader.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: tst_BusDefinitionReader.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Esko Pekkarinen\r\n// Date: 03.08.2015\r\n//\r\n// Description:\r\n// Unit test for class BusDefinition.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include <QtTest>\r\n\r\n#include <QDomNode>\r\n\r\n#include <IPXACTmodels/common/Parameter.h>\r\n#include <IPXACTmodels/BusDefinition/BusDefinition.h>\r\n#include <IPXACTmodels/BusDefinition/BusDefinitionReader.h>\r\n#include <IPXACTmodels/common/GenericVendorExtension.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Unit test for class BusDefinition.\r\n//-----------------------------------------------------------------------------\r\nclass tst_BusDefinitionReader : public QObject\r\n{\r\n    Q_OBJECT\r\n\r\npublic:\r\n    tst_BusDefinitionReader();\r\n\r\nprivate slots:\r\n    void testReadVLNVAndMandatoryFields();\r\n    void testReadDocumentNameGroupAndMandatoryFields();\r\n\r\n    void testReadTopComments();\r\n    void testProcessingInstructionsAreParsed();\r\n\r\n    void testReadExtends();\r\n    void testReadBroadcastAndDescription();\r\n    void testReadMaximumMasterAndMaximumSlave();\r\n    void testReadMaximumInitiatorAndMaximumTarget();\r\n    void testReadSystemGroupNames();\r\n\r\n    void testReadChoices();\r\n\r\n    void testReadParameters();\r\n    void testReadAssertions();\r\n    void testReadVendorExtension();\r\n\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_BusDefinitionReader::tst_BusDefinitionReader()\r\n//-----------------------------------------------------------------------------\r\ntst_BusDefinitionReader::tst_BusDefinitionReader()\r\n{\r\n    \r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_BusDefinitionReader::testReadDocumentNameGroupAndMandatoryFields()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_BusDefinitionReader::testReadVLNVAndMandatoryFields()\r\n{\r\n    QDomDocument document;\r\n    document.setContent(QString(        \r\n        \"<ipxact:busDefinition xmlns:xsi=\\\"http://www.w3.org/2001/XMLSchema-instance\\\" \" \r\n        \"xmlns:ipxact=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014\\\" \"\r\n        \"xmlns:kactus2=\\\"http://kactus2.cs.tut.fi\\\" \"\r\n        \"xsi:schemaLocation=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/ \"\r\n        \"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/index.xsd\\\">\"\r\n            \"<ipxact:vendor>TUT</ipxact:vendor>\"\r\n            \"<ipxact:library>TestLibrary</ipxact:library>\"\r\n            \"<ipxact:name>MinimalBus</ipxact:name>\"\r\n            \"<ipxact:version>1.0</ipxact:version>\"\r\n            \"<ipxact:directConnection>false</ipxact:directConnection>\"\r\n            \"<ipxact:isAddressable>false</ipxact:isAddressable>\"\r\n        \"</ipxact:busDefinition>\"));\r\n\r\n        QSharedPointer<BusDefinition> testBus = BusDefinitionReader::createBusDefinitionFrom(document);\r\n    \r\n    VLNV busVLNV = testBus->getVlnv();\r\n    QCOMPARE(busVLNV.getVendor(), QString(\"TUT\"));\r\n    QCOMPARE(busVLNV.getLibrary(), QString(\"TestLibrary\"));\r\n    QCOMPARE(busVLNV.getName(), QString(\"MinimalBus\"));\r\n    QCOMPARE(busVLNV.getVersion(), QString(\"1.0\"));\r\n    \r\n    QCOMPARE(testBus->getDirectConnection(), false);\r\n    QCOMPARE(testBus->getIsAddressable(), false);\r\n}\r\n\r\nvoid tst_BusDefinitionReader::testReadDocumentNameGroupAndMandatoryFields()\r\n{\r\n    QDomDocument document;\r\n    document.setContent(QString(\r\n        \"<ipxact:busDefinition xmlns:xsi=\\\"http://www.w3.org/2001/XMLSchema-instance\\\" \"\r\n        \"xmlns:ipxact=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2022\\\" \"\r\n        \"xmlns:kactus2=\\\"http://kactus2.cs.tut.fi\\\" \"\r\n        \"xsi:schemaLocation=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2022/ \"\r\n        \"http://www.accellera.org/XMLSchema/IPXACT/1685-2022/index.xsd\\\">\"\r\n            \"<ipxact:vendor>TUT</ipxact:vendor>\"\r\n            \"<ipxact:library>TestLibrary</ipxact:library>\"\r\n            \"<ipxact:name>MinimalBus</ipxact:name>\"\r\n            \"<ipxact:version>1.0</ipxact:version>\"\r\n            \"<ipxact:displayName>TEST</ipxact:displayName>\"\r\n            \"<ipxact:shortDescription>testdesc</ipxact:shortDescription>\"\r\n            \"<ipxact:description>Test description</ipxact:description>\"\r\n            \"<ipxact:directConnection>false</ipxact:directConnection>\"\r\n            \"<ipxact:isAddressable>false</ipxact:isAddressable>\"\r\n        \"</ipxact:busDefinition>\"));\r\n\r\n        QSharedPointer<BusDefinition> testBus = BusDefinitionReader::createBusDefinitionFrom(document);\r\n    VLNV busVLNV = testBus->getVlnv();\r\n    QCOMPARE(busVLNV.getVendor(), QString(\"TUT\"));\r\n    QCOMPARE(busVLNV.getLibrary(), QString(\"TestLibrary\"));\r\n    QCOMPARE(busVLNV.getName(), QString(\"MinimalBus\"));\r\n    QCOMPARE(busVLNV.getVersion(), QString(\"1.0\"));\r\n    QCOMPARE(testBus->getDisplayName(), QString(\"TEST\"));\r\n    QCOMPARE(testBus->getShortDescription(), QString(\"testdesc\"));\r\n    QCOMPARE(testBus->getDescription(), QString(\"Test description\"));\r\n\r\n    QCOMPARE(testBus->getDirectConnection(), false);\r\n    QCOMPARE(testBus->getIsAddressable(), false);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_BusDefinitionReader::testReadTopComments()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_BusDefinitionReader::testReadTopComments()\r\n{\r\n    QDomDocument document;\r\n    document.setContent(QString(        \r\n        \"<?xml version=\\\"1.0\\\"?>\"\r\n        \"<!--Commented line 1-->\"\r\n        \"<!--Commented line 2-->\"\r\n        \"<ipxact:busDefinition xmlns:xsi=\\\"http://www.w3.org/2001/XMLSchema-instance\\\" \" \r\n        \"xmlns:ipxact=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014\\\" \"\r\n        \"xmlns:kactus2=\\\"http://kactus2.cs.tut.fi\\\" \"\r\n        \"xsi:schemaLocation=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/ \"\r\n        \"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/index.xsd\\\">\"\r\n            \"<ipxact:vendor>TUT</ipxact:vendor>\"\r\n            \"<ipxact:library>TestLibrary</ipxact:library>\"\r\n            \"<ipxact:name>MinimalBus</ipxact:name>\"\r\n            \"<ipxact:version>1.0</ipxact:version>\"\r\n            \"<!--Comment not to include-->\"\r\n            \"<ipxact:directConnection>true</ipxact:directConnection>\"\r\n            \"<ipxact:isAddressable>true</ipxact:isAddressable>\"\r\n        \"</ipxact:busDefinition>\"\r\n        \"<!--Comment not to include-->\"));\r\n\r\n        QSharedPointer<BusDefinition> testBus = BusDefinitionReader::createBusDefinitionFrom(document);\r\n\r\n    QCOMPARE(testBus->getTopComments().size(), 2);\r\n    QCOMPARE(testBus->getTopComments().first(), QString(\"Commented line 1\"));   \r\n    QCOMPARE(testBus->getTopComments().last(), QString(\"Commented line 2\"));   \r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_BusDefinitionReader::testProcessingInstructionsAreParsed()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_BusDefinitionReader::testProcessingInstructionsAreParsed()\r\n{\r\n    QDomDocument document;\r\n    document.setContent(QString(        \r\n        \"<?xml version=\\\"1.0\\\"?>\"\r\n        \"<!-- Header comments -->\"\n        \"<?xml-stylesheet href=\\\"style.css\\\"?>\"\r\n        \"<ipxact:busDefinition xmlns:xsi=\\\"http://www.w3.org/2001/XMLSchema-instance\\\" \" \r\n        \"xmlns:ipxact=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014\\\" \"\r\n        \"xmlns:kactus2=\\\"http://kactus2.cs.tut.fi\\\" \"\r\n        \"xsi:schemaLocation=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/ \"\r\n        \"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/index.xsd\\\">\"\r\n            \"<ipxact:vendor>TUT</ipxact:vendor>\"\r\n            \"<ipxact:library>TestLibrary</ipxact:library>\"\r\n            \"<ipxact:name>MinimalBus</ipxact:name>\"\r\n            \"<ipxact:version>1.0</ipxact:version>\"\r\n            \"<ipxact:directConnection>true</ipxact:directConnection>\"\r\n            \"<ipxact:isAddressable>true</ipxact:isAddressable>\"\r\n        \"</ipxact:busDefinition>\"\r\n        \"<!--Comment not to include-->\"));\r\n\r\n        QSharedPointer<BusDefinition> testBus = BusDefinitionReader::createBusDefinitionFrom(document);\r\n\r\n    QCOMPARE(testBus->getXmlProcessingInstructions().count(), 1);\r\n\r\n    QPair<QString, QString> styleInstruction = testBus->getXmlProcessingInstructions().first();\r\n    QCOMPARE(styleInstruction.first, QString(\"xml-stylesheet\"));\r\n    QCOMPARE(styleInstruction.second, QString(\"href=\\\"style.css\\\"\"));\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_BusDefinitionReader::testReadExtends()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_BusDefinitionReader::testReadExtends()\r\n{\r\n    QDomDocument document;\r\n    document.setContent(QString(        \r\n        \"<?xml version=\\\"1.0\\\"?>\"\r\n        \"<ipxact:busDefinition xmlns:xsi=\\\"http://www.w3.org/2001/XMLSchema-instance\\\" \" \r\n        \"xmlns:ipxact=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014\\\" \"\r\n        \"xmlns:kactus2=\\\"http://kactus2.cs.tut.fi\\\" \"\r\n        \"xsi:schemaLocation=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/ \"\r\n        \"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/index.xsd\\\">\"\r\n            \"<ipxact:vendor>TUT</ipxact:vendor>\"\r\n            \"<ipxact:library>TestLibrary</ipxact:library>\"\r\n            \"<ipxact:name>extending</ipxact:name>\"\r\n            \"<ipxact:version>1.0</ipxact:version>\"\r\n            \"<ipxact:directConnection>true</ipxact:directConnection>\"\r\n            \"<ipxact:isAddressable>true</ipxact:isAddressable>\"\r\n            \"<ipxact:extends vendor=\\\"TUT\\\" library=\\\"TestLibrary\\\" name=\\\"extended\\\" version=\\\"1.0\\\"/>\"\r\n        \"</ipxact:busDefinition>\"));\r\n\r\n        QSharedPointer<BusDefinition> testBus = BusDefinitionReader::createBusDefinitionFrom(document);\r\n\r\n    VLNV extendedBus = testBus->getExtends();\r\n    QCOMPARE(extendedBus.getVendor(), QString(\"TUT\"));\r\n    QCOMPARE(extendedBus.getLibrary(), QString(\"TestLibrary\"));\r\n    QCOMPARE(extendedBus.getName(), QString(\"extended\"));\r\n    QCOMPARE(extendedBus.getVersion(), QString(\"1.0\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_BusDefinitionReader::testReadBroadcastAndDescription()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_BusDefinitionReader::testReadBroadcastAndDescription()\r\n{\r\n    QDomDocument document;\r\n    document.setContent(QString(        \r\n        \"<?xml version=\\\"1.0\\\"?>\"\r\n        \"<ipxact:busDefinition xmlns:xsi=\\\"http://www.w3.org/2001/XMLSchema-instance\\\" \" \r\n        \"xmlns:ipxact=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014\\\" \"\r\n        \"xmlns:kactus2=\\\"http://kactus2.cs.tut.fi\\\" \"\r\n        \"xsi:schemaLocation=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/ \"\r\n        \"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/index.xsd\\\">\"\r\n            \"<ipxact:vendor>TUT</ipxact:vendor>\"\r\n            \"<ipxact:library>TestLibrary</ipxact:library>\"\r\n            \"<ipxact:name>TestBus</ipxact:name>\"\r\n            \"<ipxact:version>1.0</ipxact:version>\"\r\n            \"<ipxact:directConnection>true</ipxact:directConnection>\"\r\n            \"<ipxact:broadcast>true</ipxact:broadcast>\"\r\n            \"<ipxact:isAddressable>true</ipxact:isAddressable>\"\r\n            \"<ipxact:description>Bus description</ipxact:description>\"\r\n        \"</ipxact:busDefinition>\"));\r\n\r\n        QSharedPointer<BusDefinition> testBus = BusDefinitionReader::createBusDefinitionFrom(document);\r\n\r\n    QCOMPARE(testBus->getBroadcast().toBool(), true);\r\n    QCOMPARE(testBus->getDescription(), QString(\"Bus description\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_BusDefinitionReader::testReadMaximumMasterAndMaximumSlave()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_BusDefinitionReader::testReadMaximumMasterAndMaximumSlave()\r\n{\r\n    QDomDocument document;\r\n    document.setContent(QString(        \r\n        \"<?xml version=\\\"1.0\\\"?>\"\r\n        \"<ipxact:busDefinition xmlns:xsi=\\\"http://www.w3.org/2001/XMLSchema-instance\\\" \" \r\n        \"xmlns:ipxact=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014\\\" \"\r\n        \"xmlns:kactus2=\\\"http://kactus2.cs.tut.fi\\\" \"\r\n        \"xsi:schemaLocation=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/ \"\r\n        \"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/index.xsd\\\">\"\r\n            \"<ipxact:vendor>TUT</ipxact:vendor>\"\r\n            \"<ipxact:library>TestLibrary</ipxact:library>\"\r\n            \"<ipxact:name>TestBus</ipxact:name>\"\r\n            \"<ipxact:version>1.0</ipxact:version>\"\r\n            \"<ipxact:directConnection>true</ipxact:directConnection>\"\r\n            \"<ipxact:isAddressable>true</ipxact:isAddressable>\"\r\n            \"<ipxact:maxMasters>1</ipxact:maxMasters>\"\r\n            \"<ipxact:maxSlaves>8-1</ipxact:maxSlaves>\"\r\n        \"</ipxact:busDefinition>\"));\r\n\r\n        QSharedPointer<BusDefinition> testBus = BusDefinitionReader::createBusDefinitionFrom(document);\r\n\r\n    QCOMPARE(testBus->getMaxMasters(), std::string(\"1\"));\r\n    QCOMPARE(testBus->getMaxSlaves(), std::string(\"8-1\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_BusDefinitionReader::testReadMaximumInitiatorAndMaximumTarget()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_BusDefinitionReader::testReadMaximumInitiatorAndMaximumTarget()\r\n{\r\n    QDomDocument document;\r\n    document.setContent(QString(\r\n        \"<?xml version=\\\"1.0\\\"?>\"\r\n        \"<ipxact:busDefinition xmlns:xsi=\\\"http://www.w3.org/2001/XMLSchema-instance\\\" \"\r\n        \"xmlns:ipxact=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2022\\\" \"\r\n        \"xmlns:kactus2=\\\"http://kactus2.cs.tut.fi\\\" \"\r\n        \"xsi:schemaLocation=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2022/ \"\r\n        \"http://www.accellera.org/XMLSchema/IPXACT/1685-2022/index.xsd\\\">\"\r\n        \"<ipxact:vendor>TUT</ipxact:vendor>\"\r\n        \"<ipxact:library>TestLibrary</ipxact:library>\"\r\n        \"<ipxact:name>TestBus</ipxact:name>\"\r\n        \"<ipxact:version>1.0</ipxact:version>\"\r\n        \"<ipxact:directConnection>true</ipxact:directConnection>\"\r\n        \"<ipxact:isAddressable>true</ipxact:isAddressable>\"\r\n        \"<ipxact:maxInitiators>1</ipxact:maxInitiators>\"\r\n        \"<ipxact:maxTargets>8-1</ipxact:maxTargets>\"\r\n        \"</ipxact:busDefinition>\"));\r\n\r\n    QSharedPointer<BusDefinition> testBus = BusDefinitionReader::createBusDefinitionFrom(document);\r\n\r\n    QCOMPARE(testBus->getMaxInitiators(), std::string(\"1\"));\r\n    QCOMPARE(testBus->getMaxTargets(), std::string(\"8-1\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_BusDefinitionReader::testReadSystemGroupNames()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_BusDefinitionReader::testReadSystemGroupNames()\r\n{\r\n    QDomDocument document;\r\n    document.setContent(QString(        \r\n        \"<?xml version=\\\"1.0\\\"?>\"\r\n        \"<ipxact:busDefinition xmlns:xsi=\\\"http://www.w3.org/2001/XMLSchema-instance\\\" \" \r\n        \"xmlns:ipxact=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014\\\" \"\r\n        \"xmlns:kactus2=\\\"http://kactus2.cs.tut.fi\\\" \"\r\n        \"xsi:schemaLocation=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/ \"\r\n        \"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/index.xsd\\\">\"\r\n            \"<ipxact:vendor>TUT</ipxact:vendor>\"\r\n            \"<ipxact:library>TestLibrary</ipxact:library>\"\r\n            \"<ipxact:name>TestBus</ipxact:name>\"\r\n            \"<ipxact:version>1.0</ipxact:version>\"\r\n            \"<ipxact:directConnection>true</ipxact:directConnection>\"\r\n            \"<ipxact:isAddressable>true</ipxact:isAddressable>\"\r\n            \"<ipxact:systemGroupNames>\"\r\n                \"<ipxact:systemGroupName>system1</ipxact:systemGroupName>\"\r\n                \"<ipxact:systemGroupName>system2</ipxact:systemGroupName>\"\r\n                \"<ipxact:systemGroupName>system3</ipxact:systemGroupName>\"\r\n            \"</ipxact:systemGroupNames>\"\r\n        \"</ipxact:busDefinition>\"));\r\n\r\n        QSharedPointer<BusDefinition> testBus = BusDefinitionReader::createBusDefinitionFrom(document);\r\n\r\n    QCOMPARE(testBus->getSystemGroupNames().count(), 3);\r\n    QCOMPARE(testBus->getSystemGroupNames().join(','), QString(\"system1,system2,system3\"));\r\n}\r\n\r\nvoid tst_BusDefinitionReader::testReadChoices()\r\n{\r\n    QDomDocument document;\r\n    document.setContent(QString(\r\n        \"<?xml version=\\\"1.0\\\"?>\"\r\n        \"<ipxact:busDefinition xmlns:xsi=\\\"http://www.w3.org/2001/XMLSchema-instance\\\" \"\r\n        \"xmlns:ipxact=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2022\\\" \"\r\n        \"xmlns:kactus2=\\\"http://kactus2.cs.tut.fi\\\" \"\r\n        \"xsi:schemaLocation=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2022/ \"\r\n        \"http://www.accellera.org/XMLSchema/IPXACT/1685-2022/index.xsd\\\">\"\r\n            \"<ipxact:vendor>TUT</ipxact:vendor>\"\r\n            \"<ipxact:library>TestLibrary</ipxact:library>\"\r\n            \"<ipxact:name>TestBus</ipxact:name>\"\r\n            \"<ipxact:version>1.0</ipxact:version>\"\r\n            \"<ipxact:directConnection>true</ipxact:directConnection>\"\r\n            \"<ipxact:isAddressable>true</ipxact:isAddressable>\"\r\n            \"<ipxact:choices>\"\r\n                \"<ipxact:choice>\"\r\n                    \"<ipxact:name>bitsize</ipxact:name>\"\r\n                    \"<ipxact:enumeration text=\\\"32 bits\\\">32</ipxact:enumeration>\"\r\n                    \"<ipxact:enumeration text=\\\"64 bits\\\">64</ipxact:enumeration>\"\r\n                \"</ipxact:choice>\"\r\n                \"<ipxact:choice>\"\r\n                    \"<ipxact:name>testChoice</ipxact:name>\"\r\n                    \"<ipxact:enumeration text=\\\"some bits\\\">some</ipxact:enumeration>\"\r\n                    \"<ipxact:enumeration text=\\\"lots of bits\\\">lots</ipxact:enumeration>\"\r\n                \"</ipxact:choice>\"\r\n            \"</ipxact:choices>\"\r\n        \"</ipxact:busDefinition>\"\r\n    ));\r\n    \r\n        QSharedPointer<BusDefinition> testBus = BusDefinitionReader::createBusDefinitionFrom(document);\r\n\r\n    QCOMPARE(testBus->getChoices()->size(), 2);\r\n    QCOMPARE(testBus->getChoices()->at(0)->name(), QString(\"bitsize\"));\r\n    QCOMPARE(testBus->getChoices()->at(1)->name(), QString(\"testChoice\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_BusDefinitionReader::testReadParameters()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_BusDefinitionReader::testReadParameters()\r\n{\r\n    QDomDocument document;\r\n    document.setContent(QString(        \r\n        \"<?xml version=\\\"1.0\\\"?>\"\r\n        \"<ipxact:busDefinition xmlns:xsi=\\\"http://www.w3.org/2001/XMLSchema-instance\\\" \" \r\n        \"xmlns:ipxact=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014\\\" \"\r\n        \"xmlns:kactus2=\\\"http://kactus2.cs.tut.fi\\\" \"\r\n        \"xsi:schemaLocation=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/ \"\r\n        \"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/index.xsd\\\">\"\r\n            \"<ipxact:vendor>TUT</ipxact:vendor>\"\r\n            \"<ipxact:library>TestLibrary</ipxact:library>\"\r\n            \"<ipxact:name>TestBus</ipxact:name>\"\r\n            \"<ipxact:version>1.0</ipxact:version>\"\r\n            \"<ipxact:directConnection>true</ipxact:directConnection>\"\r\n            \"<ipxact:isAddressable>true</ipxact:isAddressable>\"\r\n            \"<ipxact:parameters>\"\r\n                \"<ipxact:parameter>\"\r\n                    \"<ipxact:name>parameter1</ipxact:name>\"\r\n                    \"<ipxact:value>1</ipxact:value>\"\r\n                \"</ipxact:parameter>\"     \r\n                \"<ipxact:parameter>\"\r\n                    \"<ipxact:name>parameter2</ipxact:name>\"\r\n                    \"<ipxact:value>text</ipxact:value>\"\r\n                \"</ipxact:parameter>\"   \r\n            \"</ipxact:parameters>\"\r\n        \"</ipxact:busDefinition>\"));\r\n\r\n        QSharedPointer<BusDefinition> testBus = BusDefinitionReader::createBusDefinitionFrom(document);\r\n\r\n    QCOMPARE(testBus->getParameters()->count(), 2);\r\n    \r\n    QSharedPointer<Parameter> testParameter = testBus->getParameters()->first();\r\n    QCOMPARE(testParameter->name(), QString(\"parameter1\"));\r\n    QCOMPARE(testParameter->getValue(), QString(\"1\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_BusDefinitionReader::testReadAssertions()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_BusDefinitionReader::testReadAssertions()\r\n{\r\n    QDomDocument document;\r\n    document.setContent(QString(        \r\n        \"<?xml version=\\\"1.0\\\"?>\"\r\n        \"<ipxact:busDefinition xmlns:xsi=\\\"http://www.w3.org/2001/XMLSchema-instance\\\" \" \r\n        \"xmlns:ipxact=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014\\\" \"\r\n        \"xmlns:kactus2=\\\"http://kactus2.cs.tut.fi\\\" \"\r\n        \"xsi:schemaLocation=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/ \"\r\n        \"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/index.xsd\\\">\"\r\n            \"<ipxact:vendor>TUT</ipxact:vendor>\"\r\n            \"<ipxact:library>TestLibrary</ipxact:library>\"\r\n            \"<ipxact:name>TestBus</ipxact:name>\"\r\n            \"<ipxact:version>1.0</ipxact:version>\"\r\n            \"<ipxact:directConnection>true</ipxact:directConnection>\"\r\n            \"<ipxact:isAddressable>true</ipxact:isAddressable>\"\r\n            \"<ipxact:assertions>\"\r\n                \"<ipxact:assertion>\"\r\n                    \"<ipxact:name>testAssert</ipxact:name>\"\r\n                    \"<ipxact:displayName>testable assert</ipxact:displayName>\"\r\n                    \"<ipxact:description>description for assertion</ipxact:description>\"\r\n                    \"<ipxact:assert>1</ipxact:assert>\"\r\n                \"</ipxact:assertion>\"     \r\n            \"</ipxact:assertions>\"\r\n        \"</ipxact:busDefinition>\"));\r\n\r\n        QSharedPointer<BusDefinition> testBus = BusDefinitionReader::createBusDefinitionFrom(document);\r\n\r\n    QCOMPARE(testBus->getAssertions()->count(), 1);\r\n\r\n    QSharedPointer<Assertion> testAssertion = testBus->getAssertions()->first();\r\n    QCOMPARE(testAssertion->name(), QString(\"testAssert\"));\r\n    QCOMPARE(testAssertion->displayName(), QString(\"testable assert\"));\r\n    QCOMPARE(testAssertion->description(), QString(\"description for assertion\"));\r\n    QCOMPARE(testAssertion->getAssert(), QString(\"1\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_BusDefinitionReader::testReadVendorExtension()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_BusDefinitionReader::testReadVendorExtension()\r\n{\r\n    QDomDocument document;\r\n    document.setContent(QString(\r\n        \"<?xml version=\\\"1.0\\\"?>\"\r\n        \"<ipxact:busDefinition xmlns:xsi=\\\"http://www.w3.org/2001/XMLSchema-instance\\\" \" \r\n        \"xmlns:ipxact=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014\\\" \"\r\n        \"xmlns:kactus2=\\\"http://kactus2.cs.tut.fi\\\" \"\r\n        \"xsi:schemaLocation=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/ \"\r\n        \"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/index.xsd\\\">\"\r\n            \"<ipxact:vendor>TUT</ipxact:vendor>\"\r\n            \"<ipxact:library>TestLibrary</ipxact:library>\"\r\n            \"<ipxact:name>TestBus</ipxact:name>\"\r\n            \"<ipxact:version>1.0</ipxact:version>\"\r\n            \"<ipxact:directConnection>true</ipxact:directConnection>\"\r\n            \"<ipxact:isAddressable>true</ipxact:isAddressable>\"\r\n            \"<ipxact:vendorExtensions>\"\r\n                \"<testExtension vendorAttribute=\\\"extension\\\">testValue</testExtension>\"\r\n                \"<kactus2:version>3.0.0<kactus2:version>\"\r\n            \"</ipxact:vendorExtensions>\"\r\n        \"</ipxact:busDefinition>\"));\r\n\r\n    QDomElement parameterElement = document.firstChildElement();\r\n\r\n        QSharedPointer<BusDefinition> testBus = BusDefinitionReader::createBusDefinitionFrom(document);\r\n\r\n    QCOMPARE(testBus->getVendorExtensions()->count(), 2);\r\n    QCOMPARE(testBus->getVersion(), QString(\"3.0.0\"));\r\n}\r\n\r\n\r\nQTEST_APPLESS_MAIN(tst_BusDefinitionReader)\r\n\r\n#include \"tst_BusDefinitionReader.moc\"\r\n"
  },
  {
    "path": "tests/IPXACTmodels/BusDefinition/tst_BusDefinitionReader.pri",
    "content": "# ----------------------------------------------------\r\n# This file is generated by the Qt Visual Studio Add-in.\r\n# ------------------------------------------------------\r\n\r\nSOURCES += ./tst_BusDefinitionReader.cpp "
  },
  {
    "path": "tests/IPXACTmodels/BusDefinition/tst_BusDefinitionReader.pro",
    "content": "#-----------------------------------------------------------------------------\r\n# File: tst_BusDefinitionReader.pro\r\n#-----------------------------------------------------------------------------\r\n# Project: Kactus 2\r\n# Author: Esko Pekkarinen\r\n# Date: 03.08.2015\r\n#\r\n# Description:\r\n# Qt project file template for running unit tests for class BusDefinition.\r\n#-----------------------------------------------------------------------------\r\n\r\nTEMPLATE = app\r\n\r\nTARGET = tst_BusDefinitionReader\r\n\r\nQT += core xml testlib\r\nQT -= gui\r\n\r\nCONFIG += c++11 testcase console\r\n\r\nlinux-g++ | linux-g++-64 | linux-g++-32 {\r\n LIBS += -L../../../executable \\\r\n     -lIPXACTmodels\r\n\r\n}\r\nwin64 | win32 {\r\n LIBS += -L../../../executable/ \\\r\n     -lIPXACTmodelsd\r\n}\r\n\r\nDESTDIR = ./release\r\n\r\nINCLUDEPATH += $$DESTDIR\r\nINCLUDEPATH += ../../../\r\n\r\nDEPENDPATH += .\r\n\r\nOBJECTS_DIR += $$DESTDIR\r\n\r\nMOC_DIR += ./generatedFiles\r\nUI_DIR += ./generatedFiles\r\nRCC_DIR += ./generatedFiles\r\ninclude(tst_BusDefinitionReader.pri)\r\n"
  },
  {
    "path": "tests/IPXACTmodels/BusDefinition/tst_BusDefinitionValidator.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: tst_BusDefinitionValidator.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Janne Virtanen\n// Date: 17.11.2015\n//\n// Description:\n// Unit test for class BusDefinitionValidator.\n//-----------------------------------------------------------------------------\n\n#include <QtTest>\n\n#include <IPXACTmodels/BusDefinition/BusDefinition.h>\n#include <IPXACTmodels/BusDefinition/validators/BusDefinitionValidator.h>\n\n#include <KactusAPI/include/SystemVerilogExpressionParser.h>\n\nclass tst_BusDefinitionValidator : public QObject\n{\n    Q_OBJECT\n\npublic:\n    tst_BusDefinitionValidator();\n\nprivate slots:\n\n    void baseCase();\n\tvoid failVLNV();\n\tvoid failParameter();\n\tvoid maxFail();\n    void maxPass();\n    void testEmptyMaximumMastersAndSlaves();\n    \n    void testFailChoices();\n    void testValidChoices();\n};\n\n//-----------------------------------------------------------------------------\n// Function: tst_BusDefinitionValidator::tst_BusDefinitionValidator()\n//-----------------------------------------------------------------------------\ntst_BusDefinitionValidator::tst_BusDefinitionValidator()\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_BusDefinitionValidator::baseCase()\n//-----------------------------------------------------------------------------\nvoid tst_BusDefinitionValidator::baseCase()\n{\n    VLNV vlnv(VLNV::BUSDEFINITION, \"vendori\", \"kurjasto\", \"jaska\", \"eka\");\n    QSharedPointer<BusDefinition> busDefinition(new BusDefinition(vlnv, Document::Revision::Std14));\n\n    QSharedPointer<Parameter> parameter(new Parameter());\n    parameter->setName(\"param\");\n    parameter->setType(\"bit\");\n    parameter->setValue(\"'b01\");\n    parameter->setValueId(\"parameterid\");\n\n    busDefinition->getParameters()->append(parameter);\n\n\tBusDefinitionValidator validator(nullptr, QSharedPointer<ExpressionParser>(new SystemVerilogExpressionParser()));\n\n\tQVector<QString> errorList;\n\tvalidator.findErrorsIn(errorList, busDefinition);\n\n\tQCOMPARE(errorList.size(), 0);\n\tQVERIFY(validator.validate(busDefinition));\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_BusDefinitionValidator::failVLNV()\n//-----------------------------------------------------------------------------\nvoid tst_BusDefinitionValidator::failVLNV()\n{\n\tQSharedPointer<BusDefinition> busDefinition(new BusDefinition(VLNV(VLNV::INVALID, \"a\", \"b\", \"c\", \"d\"), Document::Revision::Std14));\n\n\tBusDefinitionValidator validator(nullptr, QSharedPointer<ExpressionParser>(new SystemVerilogExpressionParser()));\n\n\tQVector<QString> errorList;\n\tvalidator.findErrorsIn(errorList, busDefinition);\n\n\tQVERIFY(!validator.validate(busDefinition));\n\tQVERIFY(errorList.size() > 0);\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_BusDefinitionValidator::failParameter()\n//-----------------------------------------------------------------------------\nvoid tst_BusDefinitionValidator::failParameter()\n{\n    VLNV vlnv(VLNV::BUSDEFINITION, \"vendori\", \"kurjasto\", \"jaska\", \"eka\");\n    QSharedPointer<BusDefinition> busDefinition(new BusDefinition(vlnv, Document::Revision::Std14));\n\n    QSharedPointer<Parameter> parameter (new Parameter());\n    parameter->setName(\"param\");\n    parameter->setType(\"bit\");\n    parameter->setValue(\"{'b11, 'b00}\");\n    parameter->setValueId(\"parameterid\");\n\n    busDefinition->getParameters()->append(parameter);\n\n\tBusDefinitionValidator validator(nullptr,QSharedPointer<ExpressionParser>(new SystemVerilogExpressionParser()));\n\n\tQVector<QString> errorList;\n\tvalidator.findErrorsIn(errorList, busDefinition);\n\n\tQVERIFY(!validator.validate(busDefinition));\n\tQVERIFY(errorList.size() == 1);\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_BusDefinitionValidator::maxFail()\n//-----------------------------------------------------------------------------\nvoid tst_BusDefinitionValidator::maxFail()\n{\n    VLNV vlnv(VLNV::BUSDEFINITION, \"vendori\", \"kurjasto\", \"jaska\", \"eka\");\n    QSharedPointer<BusDefinition> busDefinition(new BusDefinition(vlnv, Document::Revision::Std14));\n    busDefinition->setMaxMasters(\"ghhhk,\");\n    busDefinition->setMaxSlaves(\"jii oku\");\n\n\tBusDefinitionValidator validator(nullptr,QSharedPointer<ExpressionParser>(new SystemVerilogExpressionParser()));\n\n\tQVector<QString> errorList;\n\tvalidator.findErrorsIn(errorList, busDefinition);\n\n\tQVERIFY(!validator.validate(busDefinition));\n\tQVERIFY(errorList.size() == 2);\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_BusDefinitionValidator::maxPass()\n//-----------------------------------------------------------------------------\nvoid tst_BusDefinitionValidator::maxPass()\n{\n    VLNV vlnv(VLNV::BUSDEFINITION, \"vendori\", \"kurjasto\", \"jaska\", \"eka\");\n    QSharedPointer<BusDefinition> busDefinition(new BusDefinition(vlnv, Document::Revision::Std14));\n    busDefinition->setMaxMasters(\"1337\");\n    busDefinition->setMaxSlaves(\"5\");\n\n\tBusDefinitionValidator validator(nullptr,QSharedPointer<ExpressionParser>(new SystemVerilogExpressionParser()));\n\n\tQVector<QString> errorList;\n\tvalidator.findErrorsIn(errorList, busDefinition);\n\n\tQVERIFY(validator.validate(busDefinition));\n\tQCOMPARE(errorList.size(), 0);\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_BusDefinitionValidator::testEmptyMaximumMastersAndSlaves()\n//-----------------------------------------------------------------------------\nvoid tst_BusDefinitionValidator::testEmptyMaximumMastersAndSlaves()\n{\n    VLNV vlnv(VLNV::BUSDEFINITION, \"vendori\", \"kurjasto\", \"jaska\", \"eka\");\n    QSharedPointer<BusDefinition> busDefinition(new BusDefinition(vlnv, Document::Revision::Std14));\n    busDefinition->setMaxMasters(\"\");\n    busDefinition->setMaxSlaves(\"\");\n\n    BusDefinitionValidator validator(nullptr,QSharedPointer<ExpressionParser>(new SystemVerilogExpressionParser()));\n\n    QVector<QString> errorList;\n    validator.findErrorsIn(errorList, busDefinition);\n\n    QVERIFY(validator.validate(busDefinition));\n    QCOMPARE(errorList.size(), 0);\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_BusDefinitionValidator::testFailChoices()\n//-----------------------------------------------------------------------------\nvoid tst_BusDefinitionValidator::testFailChoices()\n{\n    VLNV vlnv(VLNV::BUSDEFINITION, \"vendor\", \"library\", \"name\", \"version\");\n    QSharedPointer<BusDefinition> busDefinition(new BusDefinition(vlnv, Document::Revision::Std22));\n\n    // Invalid enumeration.\n    QSharedPointer<Choice> testChoice(new Choice());\n    testChoice->setName(\"testChoice\");\n\n    QSharedPointer<Enumeration> testEnumeration(new Enumeration());\n    testEnumeration->setValue(\"32#|!|!||||\");\n\n    testChoice->enumerations()->append(testEnumeration);\n\n    busDefinition->getChoices()->append(testChoice);\n\n    // No enumerations, no name.\n    QSharedPointer<Choice> testChoice2(new Choice());\n\n    busDefinition->getChoices()->append(testChoice2);\n\n    BusDefinitionValidator validator(nullptr, QSharedPointer<ExpressionParser>(new SystemVerilogExpressionParser()));\n\n    QVector<QString> errorList;\n    validator.findErrorsIn(errorList, busDefinition);\n\n    QCOMPARE(errorList.size(), 3);\n    QVERIFY(!validator.validate(busDefinition));\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_BusDefinitionValidator::testValidChoices()\n//-----------------------------------------------------------------------------\nvoid tst_BusDefinitionValidator::testValidChoices()\n{\n    VLNV vlnv(VLNV::BUSDEFINITION, \"vendor\", \"library\", \"name\", \"version\");\n    QSharedPointer<BusDefinition> busDefinition(new BusDefinition(vlnv, Document::Revision::Std22));\n\n    QSharedPointer<Choice> testChoice(new Choice());\n    testChoice->setName(\"TestChoice\");\n\n    QSharedPointer<Enumeration> testEnumeration(new Enumeration());\n    testEnumeration->setValue(\"32\");\n\n    testChoice->enumerations()->append(testEnumeration);\n    \n    busDefinition->getChoices()->append(testChoice);\n\n    BusDefinitionValidator validator(nullptr, QSharedPointer<ExpressionParser>(new SystemVerilogExpressionParser()));\n\n    QVector<QString> errorList;\n    validator.findErrorsIn(errorList, busDefinition);\n\n    QCOMPARE(errorList.size(), 0);\n    QVERIFY(validator.validate(busDefinition));\n}\n\nQTEST_APPLESS_MAIN(tst_BusDefinitionValidator)\n\n#include \"tst_BusDefinitionValidator.moc\"\n"
  },
  {
    "path": "tests/IPXACTmodels/BusDefinition/tst_BusDefinitionValidator.pri",
    "content": "# ----------------------------------------------------\n# This file is generated by the Qt Visual Studio Tools.\n# ------------------------------------------------------\n\nSOURCES += ./tst_BusDefinitionValidator.cpp\n"
  },
  {
    "path": "tests/IPXACTmodels/BusDefinition/tst_BusDefinitionValidator.pro",
    "content": "#-----------------------------------------------------------------------------\n# File: tst_BusDefinitionValidator.pro\n#-----------------------------------------------------------------------------\n# Project: Kactus 2\n# Author: Janne Virtanen\n# Date: 17.11.2015\n#\n# Description:\n# Qt project file template for running unit tests for BusDefinitionValidator.\n#-----------------------------------------------------------------------------\n\nTEMPLATE = app\n\nTARGET = tst_BusDefinitionValidator\n\nQT += core gui xml testlib\n\nCONFIG += c++11 testcase console\n\nlinux-g++ | linux-g++-64 | linux-g++-32 {\n LIBS += -L../../../executable \\\n     -lIPXACTmodels \\\n     -lKactusAPI\n\n}\nwin64 | win32 {\n LIBS += -L../../../executable/ \\\n     -lIPXACTmodelsd \\\n     -lKactusAPId\n}\n\nDESTDIR = ./release\n\nINCLUDEPATH += $$DESTDIR\nINCLUDEPATH += ../../../\n\nDEPENDPATH += .\nDEPENDPATH += ../../../\n\nOBJECTS_DIR += $$DESTDIR\n\nMOC_DIR += ./generatedFiles\nUI_DIR += ./generatedFiles\nRCC_DIR += ./generatedFiles\ninclude(tst_BusDefinitionValidator.pri)\n"
  },
  {
    "path": "tests/IPXACTmodels/BusDefinition/tst_BusDefinitionWriter.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: tst_BusDefinitionWriter.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Esko Pekkarinen\r\n// Date: 05.08.2015\r\n//\r\n// Description:\r\n// Unit test for class BusDefinitionWriter.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include <QtTest>\r\n\r\n#include <IPXACTmodels/common/Assertion.h>\r\n#include <IPXACTmodels/common/Parameter.h>\r\n#include <IPXACTmodels/common/GenericVendorExtension.h>\r\n\r\n#include <IPXACTmodels/common/Choice.h>\r\n\r\n#include <IPXACTmodels/BusDefinition/BusDefinition.h>\r\n#include <IPXACTmodels/BusDefinition/BusDefinitionWriter.h>\r\n\r\nclass tst_BusDefinition : public QObject\r\n{\r\n    Q_OBJECT\r\n\r\npublic:\r\n    tst_BusDefinition();\r\n\r\nprivate slots:\r\n\r\n    void testWriteMinimalBusDefinition();\r\n\r\n    void testTopCommentsAreWritten();\r\n    void testProcessingInstructionsAreWritten();\r\n\r\n    void testWriteExtendingBusDefinition();\r\n    void testWriteBroadcastAndDescription();\r\n    void testWriteDocmentNameGroup();\r\n\r\n    void testWriteMasterAndSlaveMaximum();\r\n    void testWriteSystemGroupNames();\r\n\r\n    void testWriteChoices();\r\n\r\n    void testWriteParameters();\r\n    void testWriteAssertions();\r\n    void testVendorExtensions();\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_BusDefinitionWriter::tst_BusDefinition()\r\n//-----------------------------------------------------------------------------\r\ntst_BusDefinition::tst_BusDefinition()\r\n{\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_BusDefinitionWriter::testWriteMinimalBusDefinition()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_BusDefinition::testWriteMinimalBusDefinition()\r\n{\r\n    VLNV vlnv(VLNV::BUSDEFINITION, \"TUT\", \"TestLibrary\", \"MinimalBus\", \"1.0\");\r\n    QSharedPointer<BusDefinition> busDefinition(new BusDefinition(vlnv, Document::Revision::Std14));\r\n    busDefinition->setDirectConnection(true);\r\n    busDefinition->setIsAddressable(false);\r\n\r\n    QString output;\r\n    QXmlStreamWriter xmlStreamWriter(&output);\r\n    \r\n    BusDefinitionWriter::writeBusDefinition(xmlStreamWriter, busDefinition);\r\n\r\n    QCOMPARE(output, QString(\r\n        \"<?xml version=\\\"1.0\\\"?>\"\r\n        \"<ipxact:busDefinition xmlns:xsi=\\\"http://www.w3.org/2001/XMLSchema-instance\\\" \" \r\n        \"xmlns:ipxact=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014\\\" \"\r\n        \"xmlns:kactus2=\\\"http://kactus2.cs.tut.fi\\\" \"\r\n        \"xsi:schemaLocation=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014 \"\r\n        \"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/index.xsd\\\">\"\r\n            \"<ipxact:vendor>TUT</ipxact:vendor>\"\r\n            \"<ipxact:library>TestLibrary</ipxact:library>\"\r\n            \"<ipxact:name>MinimalBus</ipxact:name>\"\r\n            \"<ipxact:version>1.0</ipxact:version>\"\r\n            \"<ipxact:directConnection>true</ipxact:directConnection>\"\r\n            \"<ipxact:isAddressable>false</ipxact:isAddressable>\"\r\n        \"</ipxact:busDefinition>\\n\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_BusDefinition::testTopCommentsAreWritten()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_BusDefinition::testTopCommentsAreWritten()\r\n{\r\n    VLNV vlnv(VLNV::BUSDEFINITION, \"TUT\", \"TestLibrary\", \"MinimalBus\", \"1.0\");\r\n    QSharedPointer<BusDefinition> busDefinition(new BusDefinition(vlnv, Document::Revision::Std14));\r\n    busDefinition->setTopComments(\"Commented section\");\r\n\r\n    QString output;\r\n    QXmlStreamWriter xmlStreamWriter(&output);\r\n    \r\n    BusDefinitionWriter::writeBusDefinition(xmlStreamWriter, busDefinition);\r\n\r\n    QCOMPARE(output, QString(\r\n        \"<?xml version=\\\"1.0\\\"?>\"\r\n        \"<!--Commented section-->\"\r\n        \"<ipxact:busDefinition xmlns:xsi=\\\"http://www.w3.org/2001/XMLSchema-instance\\\" \" \r\n        \"xmlns:ipxact=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014\\\" \"\r\n        \"xmlns:kactus2=\\\"http://kactus2.cs.tut.fi\\\" \"\r\n        \"xsi:schemaLocation=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014 \"\r\n        \"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/index.xsd\\\">\"\r\n            \"<ipxact:vendor>TUT</ipxact:vendor>\"\r\n            \"<ipxact:library>TestLibrary</ipxact:library>\"\r\n            \"<ipxact:name>MinimalBus</ipxact:name>\"\r\n            \"<ipxact:version>1.0</ipxact:version>\"\r\n            \"<ipxact:directConnection>true</ipxact:directConnection>\"\r\n            \"<ipxact:isAddressable>true</ipxact:isAddressable>\"\r\n        \"</ipxact:busDefinition>\\n\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_BusDefinition::testProcessingInstructionsAreWritten()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_BusDefinition::testProcessingInstructionsAreWritten()\r\n{\r\n    VLNV vlnv(VLNV::BUSDEFINITION, \"TUT\", \"TestLibrary\", \"StyledBus\", \"1.0\");\r\n    QSharedPointer<BusDefinition> busDefinition(new BusDefinition(vlnv, Document::Revision::Std14));\r\n    busDefinition->addXmlProcessingInstructions(\"xml-stylesheet\", \"href=\\\"style.css\\\" attribute=\\\"value\\\"\");\r\n\r\n    QString output;\r\n    QXmlStreamWriter xmlStreamWriter(&output);\r\n    \r\n    BusDefinitionWriter::writeBusDefinition(xmlStreamWriter, busDefinition);\r\n\r\n    QCOMPARE(output, QString(\r\n        \"<?xml version=\\\"1.0\\\"?>\"\r\n        \"<?xml-stylesheet href=\\\"style.css\\\" attribute=\\\"value\\\"?>\"\r\n        \"<ipxact:busDefinition xmlns:xsi=\\\"http://www.w3.org/2001/XMLSchema-instance\\\" \" \r\n        \"xmlns:ipxact=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014\\\" \"\r\n        \"xmlns:kactus2=\\\"http://kactus2.cs.tut.fi\\\" \"\r\n        \"xsi:schemaLocation=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014 \"\r\n        \"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/index.xsd\\\">\"\r\n        \"<ipxact:vendor>TUT</ipxact:vendor>\"\r\n        \"<ipxact:library>TestLibrary</ipxact:library>\"\r\n        \"<ipxact:name>StyledBus</ipxact:name>\"\r\n        \"<ipxact:version>1.0</ipxact:version>\"\r\n        \"<ipxact:directConnection>true</ipxact:directConnection>\"\r\n        \"<ipxact:isAddressable>true</ipxact:isAddressable>\"\r\n        \"</ipxact:busDefinition>\\n\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_BusDefinitionWriter::testWriteExtendingBusDefinition()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_BusDefinition::testWriteExtendingBusDefinition()\r\n{\r\n    VLNV extendedVlnv(VLNV::BUSDEFINITION, \"TUT\", \"TestLibrary\", \"extended\", \"1.0\");\r\n\r\n    VLNV extendingVlnv(VLNV::BUSDEFINITION, \"TUT\", \"TestLibrary\", \"extending\", \"1.0\");\r\n    QSharedPointer<BusDefinition> busDefinition(new BusDefinition(extendingVlnv, Document::Revision::Std14));\r\n    busDefinition->setExtends(extendedVlnv);\r\n\r\n    QString output;\r\n    QXmlStreamWriter xmlStreamWriter(&output);\r\n    \r\n    BusDefinitionWriter::writeBusDefinition(xmlStreamWriter, busDefinition);\r\n\r\n    QCOMPARE(output, QString(\r\n        \"<?xml version=\\\"1.0\\\"?>\"\r\n        \"<ipxact:busDefinition xmlns:xsi=\\\"http://www.w3.org/2001/XMLSchema-instance\\\" \" \r\n        \"xmlns:ipxact=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014\\\" \"\r\n        \"xmlns:kactus2=\\\"http://kactus2.cs.tut.fi\\\" \"\r\n        \"xsi:schemaLocation=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014 \"\r\n        \"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/index.xsd\\\">\"\r\n            \"<ipxact:vendor>TUT</ipxact:vendor>\"\r\n            \"<ipxact:library>TestLibrary</ipxact:library>\"\r\n            \"<ipxact:name>extending</ipxact:name>\"\r\n            \"<ipxact:version>1.0</ipxact:version>\"\r\n            \"<ipxact:directConnection>true</ipxact:directConnection>\"\r\n            \"<ipxact:isAddressable>true</ipxact:isAddressable>\"\r\n            \"<ipxact:extends vendor=\\\"TUT\\\" library=\\\"TestLibrary\\\" name=\\\"extended\\\" version=\\\"1.0\\\"/>\"\r\n        \"</ipxact:busDefinition>\\n\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_BusDefinitionWriter::testWriteBroadcastAndDescription()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_BusDefinition::testWriteBroadcastAndDescription()\r\n{\r\n    VLNV vlnv(VLNV::BUSDEFINITION, \"TUT\", \"TestLibrary\", \"TestBus\", \"1.0\");\r\n    QSharedPointer<BusDefinition> busDefinition(new BusDefinition(vlnv, Document::Revision::Std14));\r\n    busDefinition->setBroadcast(true);\r\n    busDefinition->setDescription(\"Bus description\");\r\n\r\n    QString output;\r\n    QXmlStreamWriter xmlStreamWriter(&output);\r\n    \r\n    BusDefinitionWriter::writeBusDefinition(xmlStreamWriter, busDefinition);\r\n\r\n    QCOMPARE(output, QString(\r\n        \"<?xml version=\\\"1.0\\\"?>\"\r\n        \"<ipxact:busDefinition xmlns:xsi=\\\"http://www.w3.org/2001/XMLSchema-instance\\\" \" \r\n        \"xmlns:ipxact=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014\\\" \"\r\n        \"xmlns:kactus2=\\\"http://kactus2.cs.tut.fi\\\" \"\r\n        \"xsi:schemaLocation=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014 \"\r\n        \"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/index.xsd\\\">\"\r\n            \"<ipxact:vendor>TUT</ipxact:vendor>\"\r\n            \"<ipxact:library>TestLibrary</ipxact:library>\"\r\n            \"<ipxact:name>TestBus</ipxact:name>\"\r\n            \"<ipxact:version>1.0</ipxact:version>\"\r\n            \"<ipxact:directConnection>true</ipxact:directConnection>\"\r\n            \"<ipxact:broadcast>true</ipxact:broadcast>\"\r\n            \"<ipxact:isAddressable>true</ipxact:isAddressable>\"\r\n            \"<ipxact:description>Bus description</ipxact:description>\"\r\n        \"</ipxact:busDefinition>\\n\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_BusDefinitionWriter::testWriteDocmentNameGroup()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_BusDefinition::testWriteDocmentNameGroup()\r\n{\r\n    VLNV vlnv(VLNV::BUSDEFINITION, \"TUT\", \"TestLibrary\", \"TestBus\", \"1.0\");\r\n    QSharedPointer<BusDefinition> busDefinition(new BusDefinition(vlnv, Document::Revision::Std22));\r\n    busDefinition->setDescription(\"Bus description\");\r\n    busDefinition->setShortDescription(\"Shortdesc.\");\r\n    busDefinition->setDisplayName(\"BusDef\");\r\n\r\n    QString output;\r\n    QXmlStreamWriter xmlStreamWriter(&output);\r\n    \r\n    BusDefinitionWriter::writeBusDefinition(xmlStreamWriter, busDefinition);\r\n\r\n    QCOMPARE(output, QString(\r\n        \"<?xml version=\\\"1.0\\\"?>\"\r\n        \"<ipxact:busDefinition xmlns:xsi=\\\"http://www.w3.org/2001/XMLSchema-instance\\\" \"\r\n        \"xmlns:ipxact=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2022\\\" \"\r\n        \"xmlns:kactus2=\\\"http://kactus2.cs.tut.fi\\\" \"\r\n        \"xsi:schemaLocation=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2022 \"\r\n        \"http://www.accellera.org/XMLSchema/IPXACT/1685-2022/index.xsd\\\">\"\r\n        \"<ipxact:vendor>TUT</ipxact:vendor>\"\r\n        \"<ipxact:library>TestLibrary</ipxact:library>\"\r\n        \"<ipxact:name>TestBus</ipxact:name>\"\r\n        \"<ipxact:version>1.0</ipxact:version>\"\r\n        \"<ipxact:displayName>BusDef</ipxact:displayName>\"\r\n        \"<ipxact:shortDescription>Shortdesc.</ipxact:shortDescription>\"\r\n        \"<ipxact:description>Bus description</ipxact:description>\"\r\n        \"<ipxact:directConnection>true</ipxact:directConnection>\"\r\n        \"<ipxact:isAddressable>true</ipxact:isAddressable>\"\r\n        \"</ipxact:busDefinition>\\n\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_BusDefinitionWriter::testWriteMasterAndSlaveMaximum()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_BusDefinition::testWriteMasterAndSlaveMaximum()\r\n{\r\n    VLNV vlnv(VLNV::BUSDEFINITION, \"TUT\", \"TestLibrary\", \"TestBus\", \"1.0\");\r\n    QSharedPointer<BusDefinition> busDefinition(new BusDefinition(vlnv, Document::Revision::Std14));\r\n    busDefinition->setMaxMasters(\"1\");\r\n    busDefinition->setMaxSlaves(\"8-1\");\r\n\r\n    QString output;\r\n    QXmlStreamWriter xmlStreamWriter(&output);\r\n    \r\n    BusDefinitionWriter::writeBusDefinition(xmlStreamWriter, busDefinition);\r\n\r\n    QCOMPARE(output, QString(\r\n        \"<?xml version=\\\"1.0\\\"?>\"\r\n        \"<ipxact:busDefinition xmlns:xsi=\\\"http://www.w3.org/2001/XMLSchema-instance\\\" \" \r\n        \"xmlns:ipxact=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014\\\" \"\r\n        \"xmlns:kactus2=\\\"http://kactus2.cs.tut.fi\\\" \"\r\n        \"xsi:schemaLocation=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014 \"\r\n        \"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/index.xsd\\\">\"\r\n            \"<ipxact:vendor>TUT</ipxact:vendor>\"\r\n            \"<ipxact:library>TestLibrary</ipxact:library>\"\r\n            \"<ipxact:name>TestBus</ipxact:name>\"\r\n            \"<ipxact:version>1.0</ipxact:version>\"\r\n            \"<ipxact:directConnection>true</ipxact:directConnection>\"\r\n            \"<ipxact:isAddressable>true</ipxact:isAddressable>\"\r\n            \"<ipxact:maxMasters>1</ipxact:maxMasters>\"\r\n            \"<ipxact:maxSlaves>8-1</ipxact:maxSlaves>\"\r\n        \"</ipxact:busDefinition>\\n\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_BusDefinitionWriter::testWriteSystemGroupNames()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_BusDefinition::testWriteSystemGroupNames()\r\n{\r\n    VLNV vlnv(VLNV::BUSDEFINITION, \"TUT\", \"TestLibrary\", \"TestBus\", \"1.0\");\r\n    QSharedPointer<BusDefinition> busDefinition(new BusDefinition(vlnv, Document::Revision::Std14));\r\n\r\n    QStringList systemGroupNames;\r\n    systemGroupNames << \"system1\" << \"system2\" << \"system3\";\r\n\r\n    busDefinition->setSystemGroupNames(systemGroupNames);\r\n\r\n    QString output;\r\n    QXmlStreamWriter xmlStreamWriter(&output);\r\n    \r\n    BusDefinitionWriter::writeBusDefinition(xmlStreamWriter, busDefinition);\r\n\r\n    QCOMPARE(output, QString(\r\n        \"<?xml version=\\\"1.0\\\"?>\"\r\n        \"<ipxact:busDefinition xmlns:xsi=\\\"http://www.w3.org/2001/XMLSchema-instance\\\" \" \r\n        \"xmlns:ipxact=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014\\\" \"\r\n        \"xmlns:kactus2=\\\"http://kactus2.cs.tut.fi\\\" \"\r\n        \"xsi:schemaLocation=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014 \"\r\n        \"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/index.xsd\\\">\"\r\n            \"<ipxact:vendor>TUT</ipxact:vendor>\"\r\n            \"<ipxact:library>TestLibrary</ipxact:library>\"\r\n            \"<ipxact:name>TestBus</ipxact:name>\"\r\n            \"<ipxact:version>1.0</ipxact:version>\"\r\n            \"<ipxact:directConnection>true</ipxact:directConnection>\"\r\n            \"<ipxact:isAddressable>true</ipxact:isAddressable>\"\r\n            \"<ipxact:systemGroupNames>\"\r\n                \"<ipxact:systemGroupName>system1</ipxact:systemGroupName>\"\r\n                \"<ipxact:systemGroupName>system2</ipxact:systemGroupName>\"\r\n                \"<ipxact:systemGroupName>system3</ipxact:systemGroupName>\"\r\n            \"</ipxact:systemGroupNames>\"\r\n        \"</ipxact:busDefinition>\\n\"));\r\n}\r\n\r\nvoid tst_BusDefinition::testWriteChoices()\r\n{\r\n    VLNV vlnv(VLNV::BUSDEFINITION, \"TUT\", \"TestLibrary\", \"TestBus\", \"1.0\");\r\n    QSharedPointer<BusDefinition> busDefinition(new BusDefinition(vlnv, Document::Revision::Std22));\r\n    \r\n    QSharedPointer<Choice> testChoice(new Choice());\r\n    testChoice->setName(\"bitsize\");\r\n\r\n    QSharedPointer<Enumeration> testEnum1(new Enumeration());\r\n    testEnum1->setValue(\"32\");\r\n    testEnum1->setText(\"32 bits\");\r\n    \r\n    QSharedPointer<Enumeration> testEnum2(new Enumeration());\r\n    testEnum2->setValue(\"64\");\r\n    testEnum2->setText(\"64 bits\");\r\n    testEnum2->setHelp(\"this is a help text\");\r\n    \r\n    testChoice->enumerations()->append(testEnum1);\r\n    testChoice->enumerations()->append(testEnum2);\r\n\r\n    busDefinition->getChoices()->append(testChoice);\r\n\r\n    QString output;\r\n    QXmlStreamWriter xmlStreamWriter(&output);\r\n    \r\n    BusDefinitionWriter::writeBusDefinition(xmlStreamWriter, busDefinition);\r\n\r\n    QCOMPARE(output, QString(\r\n        \"<?xml version=\\\"1.0\\\"?>\"\r\n        \"<ipxact:busDefinition xmlns:xsi=\\\"http://www.w3.org/2001/XMLSchema-instance\\\" \"\r\n        \"xmlns:ipxact=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2022\\\" \"\r\n        \"xmlns:kactus2=\\\"http://kactus2.cs.tut.fi\\\" \"\r\n        \"xsi:schemaLocation=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2022 \"\r\n        \"http://www.accellera.org/XMLSchema/IPXACT/1685-2022/index.xsd\\\">\"\r\n        \"<ipxact:vendor>TUT</ipxact:vendor>\"\r\n        \"<ipxact:library>TestLibrary</ipxact:library>\"\r\n        \"<ipxact:name>TestBus</ipxact:name>\"\r\n        \"<ipxact:version>1.0</ipxact:version>\"\r\n        \"<ipxact:directConnection>true</ipxact:directConnection>\"\r\n        \"<ipxact:isAddressable>true</ipxact:isAddressable>\"\r\n        \"<ipxact:choices>\"\r\n            \"<ipxact:choice>\"\r\n                \"<ipxact:name>bitsize</ipxact:name>\"\r\n                \"<ipxact:enumeration text=\\\"32 bits\\\">32</ipxact:enumeration>\"\r\n                \"<ipxact:enumeration text=\\\"64 bits\\\" help=\\\"this is a help text\\\">64</ipxact:enumeration>\"\r\n            \"</ipxact:choice>\"\r\n        \"</ipxact:choices>\"\r\n        \"</ipxact:busDefinition>\\n\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_BusDefinition::testWriteParameters()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_BusDefinition::testWriteParameters()\r\n{\r\n    VLNV vlnv(VLNV::BUSDEFINITION, \"TUT\", \"TestLibrary\", \"TestBus\", \"1.0\");\r\n    QSharedPointer<BusDefinition> busDefinition(new BusDefinition(vlnv, Document::Revision::Std14));\r\n\r\n    QSharedPointer<Parameter> firstParameter(new Parameter());\r\n    firstParameter->setName(\"parameter1\");\r\n    firstParameter->setValueId(\"\");\r\n    firstParameter->setValue(\"1\");\r\n\r\n    QSharedPointer<Parameter> secondParameter(new Parameter());\r\n    secondParameter->setName(\"parameter2\");\r\n    secondParameter->setValueId(\"\");\r\n    secondParameter->setValue(\"text\");\r\n\r\n    QSharedPointer<QList<QSharedPointer<Parameter> > > busParameters = busDefinition->getParameters();\r\n    busParameters->append(firstParameter);\r\n    busParameters->append(secondParameter);\r\n\r\n    QString output;\r\n    QXmlStreamWriter xmlStreamWriter(&output);\r\n    \r\n    BusDefinitionWriter::writeBusDefinition(xmlStreamWriter, busDefinition);\r\n\r\n    QCOMPARE(output, QString(\r\n        \"<?xml version=\\\"1.0\\\"?>\"\r\n        \"<ipxact:busDefinition xmlns:xsi=\\\"http://www.w3.org/2001/XMLSchema-instance\\\" \" \r\n        \"xmlns:ipxact=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014\\\" \"\r\n        \"xmlns:kactus2=\\\"http://kactus2.cs.tut.fi\\\" \"\r\n        \"xsi:schemaLocation=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014 \"\r\n        \"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/index.xsd\\\">\"\r\n            \"<ipxact:vendor>TUT</ipxact:vendor>\"\r\n            \"<ipxact:library>TestLibrary</ipxact:library>\"\r\n            \"<ipxact:name>TestBus</ipxact:name>\"\r\n            \"<ipxact:version>1.0</ipxact:version>\"\r\n            \"<ipxact:directConnection>true</ipxact:directConnection>\"\r\n            \"<ipxact:isAddressable>true</ipxact:isAddressable>\"\r\n            \"<ipxact:parameters>\"\r\n                \"<ipxact:parameter>\"\r\n                    \"<ipxact:name>parameter1</ipxact:name>\"\r\n                    \"<ipxact:value>1</ipxact:value>\"\r\n                \"</ipxact:parameter>\"\r\n                \"<ipxact:parameter>\"\r\n                    \"<ipxact:name>parameter2</ipxact:name>\"\r\n                    \"<ipxact:value>text</ipxact:value>\"\r\n                \"</ipxact:parameter>\"\r\n            \"</ipxact:parameters>\"\r\n        \"</ipxact:busDefinition>\\n\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_BusDefinition::testWriteAssertions()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_BusDefinition::testWriteAssertions()\r\n{\r\n    VLNV vlnv(VLNV::BUSDEFINITION, \"TUT\", \"TestLibrary\", \"TestBus\", \"1.0\");\r\n    QSharedPointer<BusDefinition> busDefinition(new BusDefinition(vlnv, Document::Revision::Std14));\r\n\r\n    QSharedPointer<Assertion> firstTestAssertion(new Assertion());\r\n    firstTestAssertion->setName(\"testAssertion1\");\r\n    firstTestAssertion->setDisplayName(\"Display name for assertion.\");\r\n    firstTestAssertion->setDescription(\"Description for assertion.\");\r\n    firstTestAssertion->setAssert(\"1\");\r\n\r\n    QSharedPointer<Assertion> secondTestAssertion(new Assertion());\r\n    secondTestAssertion->setName(\"testAssertion2\");\r\n    secondTestAssertion->setAssert(\"0\");\r\n\r\n    busDefinition->getAssertions()->append(firstTestAssertion);\r\n    busDefinition->getAssertions()->append(secondTestAssertion);\r\n\r\n    QString output;\r\n    QXmlStreamWriter xmlStreamWriter(&output);\r\n    \r\n    BusDefinitionWriter::writeBusDefinition(xmlStreamWriter, busDefinition);\r\n\r\n    QCOMPARE(output, QString(\r\n        \"<?xml version=\\\"1.0\\\"?>\"\r\n        \"<ipxact:busDefinition xmlns:xsi=\\\"http://www.w3.org/2001/XMLSchema-instance\\\" \" \r\n        \"xmlns:ipxact=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014\\\" \"\r\n        \"xmlns:kactus2=\\\"http://kactus2.cs.tut.fi\\\" \"\r\n        \"xsi:schemaLocation=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014 \"\r\n        \"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/index.xsd\\\">\"\r\n        \"<ipxact:vendor>TUT</ipxact:vendor>\"\r\n        \"<ipxact:library>TestLibrary</ipxact:library>\"\r\n        \"<ipxact:name>TestBus</ipxact:name>\"\r\n        \"<ipxact:version>1.0</ipxact:version>\"\r\n        \"<ipxact:directConnection>true</ipxact:directConnection>\"\r\n        \"<ipxact:isAddressable>true</ipxact:isAddressable>\"\r\n            \"<ipxact:assertions>\"\r\n                \"<ipxact:assertion>\"\r\n                    \"<ipxact:name>testAssertion1</ipxact:name>\"\r\n                    \"<ipxact:displayName>Display name for assertion.</ipxact:displayName>\"\r\n                    \"<ipxact:description>Description for assertion.</ipxact:description>\"\r\n                    \"<ipxact:assert>1</ipxact:assert>\"\r\n                \"</ipxact:assertion>\"\r\n                \"<ipxact:assertion>\"\r\n                    \"<ipxact:name>testAssertion2</ipxact:name>\"\r\n                    \"<ipxact:assert>0</ipxact:assert>\"\r\n                \"</ipxact:assertion>\"\r\n            \"</ipxact:assertions>\"\r\n        \"</ipxact:busDefinition>\\n\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_BusDefinition::testVendorExtensions()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_BusDefinition::testVendorExtensions()\r\n{\r\n    VLNV vlnv(VLNV::BUSDEFINITION, \"TUT\", \"TestLibrary\", \"TestBus\", \"1.0\");\r\n    QSharedPointer<BusDefinition> busDefinition(new BusDefinition(vlnv, Document::Revision::Std14));\r\n    busDefinition->setVersion(\"3.0.0\");\r\n\r\n    QDomDocument document;\r\n    QDomElement extensionNode = document.createElement(\"kactus2:testExtension\");\r\n    extensionNode.setAttribute(\"vendorAttribute\", \"extension\");\r\n    extensionNode.appendChild(document.createTextNode(\"testValue\"));\r\n\r\n    QSharedPointer<GenericVendorExtension> testExtension(new GenericVendorExtension(extensionNode));\r\n    QSharedPointer<QList<QSharedPointer<VendorExtension> > > vendorExtensions = busDefinition->getVendorExtensions();\r\n    vendorExtensions->append(testExtension);\r\n\r\n    QString output;\r\n    QXmlStreamWriter xmlStreamWriter(&output);\r\n    \r\n    BusDefinitionWriter::writeBusDefinition(xmlStreamWriter, busDefinition);\r\n\r\n    QCOMPARE(output, QString(\r\n        \"<?xml version=\\\"1.0\\\"?>\"\r\n        \"<ipxact:busDefinition xmlns:xsi=\\\"http://www.w3.org/2001/XMLSchema-instance\\\" \" \r\n        \"xmlns:ipxact=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014\\\" \"\r\n        \"xmlns:kactus2=\\\"http://kactus2.cs.tut.fi\\\" \"\r\n        \"xsi:schemaLocation=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014 \"\r\n        \"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/index.xsd\\\">\"\r\n            \"<ipxact:vendor>TUT</ipxact:vendor>\"\r\n            \"<ipxact:library>TestLibrary</ipxact:library>\"\r\n            \"<ipxact:name>TestBus</ipxact:name>\"\r\n            \"<ipxact:version>1.0</ipxact:version>\"\r\n            \"<ipxact:directConnection>true</ipxact:directConnection>\"\r\n            \"<ipxact:isAddressable>true</ipxact:isAddressable>\"\r\n            \"<ipxact:vendorExtensions>\"\r\n                \"<kactus2:version>3.0.0</kactus2:version>\"\r\n                \"<kactus2:testExtension vendorAttribute=\\\"extension\\\">testValue</kactus2:testExtension>\"\r\n            \"</ipxact:vendorExtensions>\"\r\n        \"</ipxact:busDefinition>\\n\"));\r\n}\r\n\r\n\r\nQTEST_APPLESS_MAIN(tst_BusDefinition)\r\n\r\n#include \"tst_BusDefinitionWriter.moc\"\r\n"
  },
  {
    "path": "tests/IPXACTmodels/BusDefinition/tst_BusDefinitionWriter.pri",
    "content": "# ----------------------------------------------------\r\n# This file is generated by the Qt Visual Studio Add-in.\r\n# ------------------------------------------------------\r\n\r\nSOURCES += ./tst_BusDefinitionWriter.cpp "
  },
  {
    "path": "tests/IPXACTmodels/BusDefinition/tst_BusDefinitionWriter.pro",
    "content": "#-----------------------------------------------------------------------------\r\n# File: tst_BusDefinitionWriter.pro\r\n#-----------------------------------------------------------------------------\r\n# Project: Kactus 2\r\n# Author: Esko Pekkarinen\r\n# Date: 05.08.2015\r\n#\r\n# Description:\r\n# Qt project file for running unit tests for BusDefinition Writer.\r\n#-----------------------------------------------------------------------------\r\n\r\nTEMPLATE = app\r\n\r\nTARGET = tst_BusDefinitionWriter\r\n\r\nQT += core xml testlib\r\nQT -= gui\r\n\r\nCONFIG += c++11 testcase console\r\n\r\nlinux-g++ | linux-g++-64 | linux-g++-32 {\r\n LIBS += -L../../../executable \\\r\n     -lIPXACTmodels\r\n\r\n}\r\nwin64 | win32 {\r\n LIBS += -L../../../executable/ \\\r\n     -lIPXACTmodelsd\r\n}\r\n\r\nDESTDIR = ./release\r\n\r\nINCLUDEPATH += $$DESTDIR\r\nINCLUDEPATH += ../../../\r\n\r\nDEPENDPATH += .\r\n\r\nOBJECTS_DIR += $$DESTDIR\r\n\r\nMOC_DIR += ./generatedFiles\r\nUI_DIR += ./generatedFiles\r\nRCC_DIR += ./generatedFiles\r\ninclude(tst_BusDefinitionWriter.pri)\r\n"
  },
  {
    "path": "tests/IPXACTmodels/Catalog/Catalog.pro",
    "content": "#-----------------------------------------------------------------------------\n# File: BusDefinition.pro\n#-----------------------------------------------------------------------------\n# Project: Kactus2\n# Author: Esko Pekkarinen\n# Date: 04.05.2018\n#\n# Description:\n# Qt project file template for running unit tests for BusDefinition.\n#-----------------------------------------------------------------------------\n\nTEMPLATE = subdirs\n\nCONFIG += testcase\nSUBDIRS += tst_CatalogReader.pro \\\n\t       tst_CatalogWriter.pro \\\n\t\t   tst_CatalogValidator.pro\n"
  },
  {
    "path": "tests/IPXACTmodels/Catalog/tst_CatalogReader.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: tst_CatalogReader.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Esko Pekkarinen\n// Date: 01.02.2017\n//\n// Description:\n// Unit test for class CatalogReader.\n//-----------------------------------------------------------------------------\n\n#include <QtTest>\n\n#include <IPXACTmodels/common/Assertion.h>\n#include <IPXACTmodels/common/Parameter.h>\n#include <IPXACTmodels/common/GenericVendorExtension.h>\n\n#include <IPXACTmodels/Catalog/Catalog.h>\n#include <IPXACTmodels/Catalog/CatalogReader.h>\n#include <IPXACTmodels/Catalog/IpxactFile.h>\n\nclass tst_CatalogReader : public QObject\n{\n    Q_OBJECT\n\npublic:\n    tst_CatalogReader();\n\nprivate slots:\n\n    void testReadMinimalCatalog();\n\n    void testReadTopComments();\n    void testProcessingInstructionsAreParsed();\n\n    void testReadOtherCatalogs();\n    void testReadBusDefinitions();\n    void testReadAbstractionDefinitions();\n    void testReadComponents();\n    void testReadAbstractors();\n    void testReadDesigns();\n    void testReadDesignConfigurations();\n    void testReadGeneratorChains();\n    void testReadTypeDefinitions();\n\n    void testReadAllElements();\n    /*\n    void testOtherCatalogsAreWritten();\n    void testBusDefinitionsAreWritten();\n    void testAbstractionDefinitionsAreWritten();\n    void testComponentsAreWritten();\n    void testAbstractorsAreWritten();\n    void testDesignsAreWritten();\n    void testDesignConfigurationsAreWritten();\n    void testGeneratorChainsAreWritten();\n    \n    void testVendorExtensions();*/\n\nprivate:\n\n    //QSharedPointer<VendorExtension> createTestVendorExtension();\n\n};\n\n//-----------------------------------------------------------------------------\n// Function: tst_CatalogReader::tst_Catalog()\n//-----------------------------------------------------------------------------\ntst_CatalogReader::tst_CatalogReader()\n{\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_CatalogReader::testReadMinimalCatalog()\n//-----------------------------------------------------------------------------\nvoid tst_CatalogReader::testReadMinimalCatalog()\n{\n    QDomDocument document;\n    document.setContent(QString(        \n        \"<?xml version=\\\"1.0\\\"?>\"\n        \"<ipxact:catalog xmlns:xsi=\\\"http://www.w3.org/2001/XMLSchema-instance\\\" \" \n        \"xmlns:ipxact=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014\\\" \"\n        \"xmlns:kactus2=\\\"http://kactus2.cs.tut.fi\\\" \"\n        \"xsi:schemaLocation=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/ \"\n        \"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/index.xsd\\\">\"\n            \"<ipxact:vendor>tut.fi</ipxact:vendor>\"\n            \"<ipxact:library>TestLibrary</ipxact:library>\"\n            \"<ipxact:name>MinimalCatalog</ipxact:name>\"\n            \"<ipxact:version>1.0</ipxact:version>\"\n            \"<ipxact:description>Catalog description</ipxact:description>\"\n        \"</ipxact:catalog>\\n\"));\n\n    QSharedPointer<Catalog> testCatalog = CatalogReader::createCatalogFrom(document);\n\n    VLNV catalogVLNV = testCatalog->getVlnv();\n    QCOMPARE(catalogVLNV.getVendor(), QString(\"tut.fi\"));\n    QCOMPARE(catalogVLNV.getLibrary(), QString(\"TestLibrary\"));\n    QCOMPARE(catalogVLNV.getName(), QString(\"MinimalCatalog\"));\n    QCOMPARE(catalogVLNV.getVersion(), QString(\"1.0\"));\n\n    QCOMPARE(testCatalog->getDescription(), QString(\"Catalog description\"));\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_CatalogReader::testReadTopComments()\n//-----------------------------------------------------------------------------\nvoid tst_CatalogReader::testReadTopComments()\n{\n    QDomDocument document;\n    document.setContent(QString(        \n        \"<?xml version=\\\"1.0\\\"?>\"\n        \"<!--Commented line 1-->\"\n        \"<!--Commented line 2-->\"\n        \"<ipxact:catalog xmlns:xsi=\\\"http://www.w3.org/2001/XMLSchema-instance\\\" \" \n        \"xmlns:ipxact=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014\\\" \"\n        \"xmlns:kactus2=\\\"http://kactus2.cs.tut.fi\\\" \"\n        \"xsi:schemaLocation=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/ \"\n        \"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/index.xsd\\\">\"\n            \"<ipxact:vendor>TUT</ipxact:vendor>\"\n            \"<ipxact:library>TestLibrary</ipxact:library>\"\n            \"<ipxact:name>TestCatalog</ipxact:name>\"\n            \"<ipxact:version>1.0</ipxact:version>\"\n         \"<!--Comment not to include-->\"       \n        \"</ipxact:catalog>\"\n        \"<!--Comment not to include-->\"));\n\n    QSharedPointer<Catalog> testCatalog = CatalogReader::createCatalogFrom(document);\n\n    QCOMPARE(testCatalog->getTopComments().size(), 2);\n    QCOMPARE(testCatalog->getTopComments().first(), QString(\"Commented line 1\"));   \n    QCOMPARE(testCatalog->getTopComments().last(), QString(\"Commented line 2\"));   \n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_CatalogReader::testProcessingInstructionsAreParsed()\n//-----------------------------------------------------------------------------\nvoid tst_CatalogReader::testProcessingInstructionsAreParsed()\n{\n    QDomDocument document;\n    document.setContent(QString(        \n        \"<?xml version=\\\"1.0\\\"?>\"\n        \"<!-- Header comments -->\"\n        \"<?xml-stylesheet href=\\\"style.css\\\"?>\"\n        \"<ipxact:catalog xmlns:xsi=\\\"http://www.w3.org/2001/XMLSchema-instance\\\" \" \n        \"xmlns:ipxact=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014\\\" \"\n        \"xmlns:kactus2=\\\"http://kactus2.cs.tut.fi\\\" \"\n        \"xsi:schemaLocation=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/ \"\n        \"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/index.xsd\\\">\"\n            \"<ipxact:vendor>TUT</ipxact:vendor>\"\n            \"<ipxact:library>TestLibrary</ipxact:library>\"\n            \"<ipxact:name>TestCatalog</ipxact:name>\"\n            \"<ipxact:version>1.0</ipxact:version>\"        \n        \"</ipxact:catalog>\"\n        \"<!--Comment not to include-->\"));\n\n    QSharedPointer<Catalog> testCatalog = CatalogReader::createCatalogFrom(document);\n\n    QCOMPARE(testCatalog->getXmlProcessingInstructions().count(), 1);\n\n    QPair<QString, QString> styleInstruction = testCatalog->getXmlProcessingInstructions().first();\n    QCOMPARE(styleInstruction.first, QString(\"xml-stylesheet\"));\n    QCOMPARE(styleInstruction.second, QString(\"href=\\\"style.css\\\"\"));\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_CatalogReader::testReadOtherCatalogs()\n//-----------------------------------------------------------------------------\nvoid tst_CatalogReader::testReadOtherCatalogs()\n{ \n    QDomDocument document;\n    document.setContent(QString(    \n        \"<?xml version=\\\"1.0\\\"?>\"\n        \"<ipxact:catalog xmlns:xsi=\\\"http://www.w3.org/2001/XMLSchema-instance\\\" \" \n        \"xmlns:ipxact=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014\\\" \"\n        \"xmlns:kactus2=\\\"http://kactus2.cs.tut.fi\\\" \"\n        \"xsi:schemaLocation=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/ \"\n        \"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/index.xsd\\\">\"\n            \"<ipxact:vendor>tut.fi</ipxact:vendor>\"\n            \"<ipxact:library>TestLibrary</ipxact:library>\"\n            \"<ipxact:name>TestCatalog</ipxact:name>\"\n            \"<ipxact:version>1.0</ipxact:version>\"\n            \"<ipxact:catalogs>\"\n                \"<ipxact:ipxactFile>\"\n                    \"<ipxact:vlnv vendor=\\\"tut.fi\\\" library=\\\"TestLibrary\\\" name=\\\"SubCatalog\\\" version=\\\"1.0\\\"/>\"\n                    \"<ipxact:name>./mini.xml</ipxact:name>\"          \n                \"</ipxact:ipxactFile>\"\n                \"<ipxact:ipxactFile>\"\n                    \"<ipxact:vlnv vendor=\\\"tut.fi\\\" library=\\\"TestLibrary\\\" name=\\\"CompleteCatalog\\\" version=\\\"1.0\\\"/>\"\n                    \"<ipxact:name>./complete.xml</ipxact:name>\"\n                    \"<ipxact:description>Test file description</ipxact:description>\"\n                    \"<ipxact:vendorExtensions>\"\n                        \"<testExtension vendorAttribute=\\\"extension\\\">testValue</testExtension>\"\n                    \"</ipxact:vendorExtensions>\"\n                \"</ipxact:ipxactFile>\"\n            \"</ipxact:catalogs>\"\n        \"</ipxact:catalog>\\n\"));\n\n    QSharedPointer<Catalog> testCatalog = CatalogReader::createCatalogFrom(document);\n\n    QCOMPARE(testCatalog->getCatalogs()->size(), 2); \n\n    QSharedPointer<IpxactFile> firstCatalogFile = testCatalog->getCatalogs()->first();\n\n    QCOMPARE(firstCatalogFile->getVlnv(), VLNV(VLNV::CATALOG, \"tut.fi\", \"TestLibrary\", \"SubCatalog\", \"1.0\"));\n    QCOMPARE(firstCatalogFile->getName(), QString(\"./mini.xml\"));\n\n    QSharedPointer<IpxactFile> secondCatalogFile = testCatalog->getCatalogs()->last();\n\n    QCOMPARE(secondCatalogFile->getVlnv(), VLNV(VLNV::CATALOG, \"tut.fi\", \"TestLibrary\", \"CompleteCatalog\", \"1.0\"));\n    QCOMPARE(secondCatalogFile->getDescription(), QString(\"Test file description\"));\n    QCOMPARE(secondCatalogFile->getVendorExtensions()->size(), 1);\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_CatalogReader::testReadBusDefinitions()\n//-----------------------------------------------------------------------------\nvoid tst_CatalogReader::testReadBusDefinitions()\n{ \n    QDomDocument document;\n    document.setContent(QString(    \n        \"<?xml version=\\\"1.0\\\"?>\"\n        \"<ipxact:catalog xmlns:xsi=\\\"http://www.w3.org/2001/XMLSchema-instance\\\" \" \n        \"xmlns:ipxact=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014\\\" \"\n        \"xmlns:kactus2=\\\"http://kactus2.cs.tut.fi\\\" \"\n        \"xsi:schemaLocation=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/ \"\n        \"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/index.xsd\\\">\"\n            \"<ipxact:vendor>tut.fi</ipxact:vendor>\"\n            \"<ipxact:library>TestLibrary</ipxact:library>\"\n            \"<ipxact:name>TestCatalog</ipxact:name>\"\n            \"<ipxact:version>1.0</ipxact:version>\"\n            \"<ipxact:busDefinitions>\"\n                \"<ipxact:ipxactFile>\"\n                    \"<ipxact:vlnv vendor=\\\"tut.fi\\\" library=\\\"TestLibrary\\\" name=\\\"MiniBus\\\" version=\\\"1.0\\\"/>\"\n                    \"<ipxact:name>./mini.xml</ipxact:name>\"          \n                \"</ipxact:ipxactFile>\"\n                \"<ipxact:ipxactFile>\"\n                    \"<ipxact:vlnv vendor=\\\"tut.fi\\\" library=\\\"TestLibrary\\\" name=\\\"CompleteBus\\\" version=\\\"1.0\\\"/>\"\n                    \"<ipxact:name>./complete.xml</ipxact:name>\"\n                    \"<ipxact:description>Test file description</ipxact:description>\"\n                    \"<ipxact:vendorExtensions>\"\n                        \"<testExtension vendorAttribute=\\\"extension\\\">testValue</testExtension>\"\n                    \"</ipxact:vendorExtensions>\"\n                \"</ipxact:ipxactFile>\"\n            \"</ipxact:busDefinitions>\"\n        \"</ipxact:catalog>\\n\"));\n\n    QSharedPointer<Catalog> testCatalog = CatalogReader::createCatalogFrom(document);\n\n    QCOMPARE(testCatalog->getBusDefinitions()->size(), 2); \n\n    QSharedPointer<IpxactFile> firstBusFile = testCatalog->getBusDefinitions()->first();\n\n    QCOMPARE(firstBusFile->getVlnv(), VLNV(VLNV::BUSDEFINITION, \"tut.fi\", \"TestLibrary\", \"MiniBus\", \"1.0\"));\n    QCOMPARE(firstBusFile->getName(), QString(\"./mini.xml\"));\n\n    QSharedPointer<IpxactFile> secondBusFile = testCatalog->getBusDefinitions()->last();\n\n    QCOMPARE(secondBusFile->getVlnv(), VLNV(VLNV::BUSDEFINITION, \"tut.fi\", \"TestLibrary\", \"CompleteBus\", \"1.0\"));\n    QCOMPARE(secondBusFile->getDescription(), QString(\"Test file description\"));\n    QCOMPARE(secondBusFile->getVendorExtensions()->size(), 1);\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_CatalogReader::testReadAbstractionDefinitions()\n//-----------------------------------------------------------------------------\nvoid tst_CatalogReader::testReadAbstractionDefinitions()\n{ \n    QDomDocument document;\n    document.setContent(QString(    \n        \"<?xml version=\\\"1.0\\\"?>\"\n        \"<ipxact:catalog xmlns:xsi=\\\"http://www.w3.org/2001/XMLSchema-instance\\\" \" \n        \"xmlns:ipxact=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014\\\" \"\n        \"xmlns:kactus2=\\\"http://kactus2.cs.tut.fi\\\" \"\n        \"xsi:schemaLocation=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/ \"\n        \"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/index.xsd\\\">\"\n            \"<ipxact:vendor>tut.fi</ipxact:vendor>\"\n            \"<ipxact:library>TestLibrary</ipxact:library>\"\n            \"<ipxact:name>TestCatalog</ipxact:name>\"\n            \"<ipxact:version>1.0</ipxact:version>\"\n            \"<ipxact:abstractionDefinitions>\"\n                \"<ipxact:ipxactFile>\"\n                    \"<ipxact:vlnv vendor=\\\"tut.fi\\\" library=\\\"TestLibrary\\\" name=\\\"MiniAbstraction\\\" version=\\\"1.0\\\"/>\"\n                    \"<ipxact:name>./mini.xml</ipxact:name>\"          \n                \"</ipxact:ipxactFile>\"\n                \"<ipxact:ipxactFile>\"\n                    \"<ipxact:vlnv vendor=\\\"tut.fi\\\" library=\\\"TestLibrary\\\" name=\\\"CompleteAbstraction\\\" version=\\\"1.0\\\"/>\"\n                    \"<ipxact:name>./complete.xml</ipxact:name>\"\n                    \"<ipxact:description>Test file description</ipxact:description>\"\n                    \"<ipxact:vendorExtensions>\"\n                        \"<testExtension vendorAttribute=\\\"extension\\\">testValue</testExtension>\"\n                    \"</ipxact:vendorExtensions>\"\n                \"</ipxact:ipxactFile>\"\n            \"</ipxact:abstractionDefinitions>\"\n        \"</ipxact:catalog>\\n\"));\n\n    QSharedPointer<Catalog> testCatalog = CatalogReader::createCatalogFrom(document);\n\n    QCOMPARE(testCatalog->getAbstractionDefinitions()->size(), 2); \n\n    QSharedPointer<IpxactFile> firstAbstractionFile = testCatalog->getAbstractionDefinitions()->first();\n\n    QCOMPARE(firstAbstractionFile->getVlnv(), VLNV(VLNV::ABSTRACTIONDEFINITION, \"tut.fi\", \"TestLibrary\", \"MiniAbstraction\", \"1.0\"));\n    QCOMPARE(firstAbstractionFile->getName(), QString(\"./mini.xml\"));\n\n    QSharedPointer<IpxactFile> secondAbstractionFile = testCatalog->getAbstractionDefinitions()->last();\n\n    QCOMPARE(secondAbstractionFile->getVlnv(), VLNV(VLNV::ABSTRACTIONDEFINITION, \"tut.fi\", \"TestLibrary\", \"CompleteAbstraction\", \"1.0\"));\n    QCOMPARE(secondAbstractionFile->getDescription(), QString(\"Test file description\"));\n    QCOMPARE(secondAbstractionFile->getVendorExtensions()->size(), 1);\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_CatalogReader::testReadComponents()\n//-----------------------------------------------------------------------------\nvoid tst_CatalogReader::testReadComponents()\n{ \n    QDomDocument document;\n    document.setContent(QString(    \n        \"<?xml version=\\\"1.0\\\"?>\"\n        \"<ipxact:catalog xmlns:xsi=\\\"http://www.w3.org/2001/XMLSchema-instance\\\" \" \n        \"xmlns:ipxact=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014\\\" \"\n        \"xmlns:kactus2=\\\"http://kactus2.cs.tut.fi\\\" \"\n        \"xsi:schemaLocation=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/ \"\n        \"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/index.xsd\\\">\"\n            \"<ipxact:vendor>tut.fi</ipxact:vendor>\"\n            \"<ipxact:library>TestLibrary</ipxact:library>\"\n            \"<ipxact:name>TestCatalog</ipxact:name>\"\n            \"<ipxact:version>1.0</ipxact:version>\"\n            \"<ipxact:components>\"\n                \"<ipxact:ipxactFile>\"\n                    \"<ipxact:vlnv vendor=\\\"tut.fi\\\" library=\\\"TestLibrary\\\" name=\\\"SubComponent\\\" version=\\\"1.0\\\"/>\"\n                    \"<ipxact:name>./mini.xml</ipxact:name>\"          \n                \"</ipxact:ipxactFile>\"\n                \"<ipxact:ipxactFile>\"\n                    \"<ipxact:vlnv vendor=\\\"tut.fi\\\" library=\\\"TestLibrary\\\" name=\\\"CompleteComponent\\\" version=\\\"1.0\\\"/>\"\n                    \"<ipxact:name>./complete.xml</ipxact:name>\"\n                    \"<ipxact:description>Test file description</ipxact:description>\"\n                    \"<ipxact:vendorExtensions>\"\n                        \"<testExtension vendorAttribute=\\\"extension\\\">testValue</testExtension>\"\n                    \"</ipxact:vendorExtensions>\"\n                \"</ipxact:ipxactFile>\"\n            \"</ipxact:components>\"\n        \"</ipxact:catalog>\\n\"));\n\n    QSharedPointer<Catalog> testCatalog = CatalogReader::createCatalogFrom(document);\n\n    QCOMPARE(testCatalog->getComponents()->size(), 2); \n\n    QSharedPointer<IpxactFile> firstComponentFile = testCatalog->getComponents()->first();\n\n    QCOMPARE(firstComponentFile->getVlnv(), VLNV(VLNV::COMPONENT, \"tut.fi\", \"TestLibrary\", \"SubComponent\", \"1.0\"));\n    QCOMPARE(firstComponentFile->getName(), QString(\"./mini.xml\"));\n\n    QSharedPointer<IpxactFile> secondComponentFile = testCatalog->getComponents()->last();\n\n    QCOMPARE(secondComponentFile->getVlnv(), VLNV(VLNV::COMPONENT, \"tut.fi\", \"TestLibrary\", \"CompleteComponent\", \"1.0\"));\n    QCOMPARE(secondComponentFile->getDescription(), QString(\"Test file description\"));\n    QCOMPARE(secondComponentFile->getVendorExtensions()->size(), 1);\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_CatalogReader::testReadAbstractors()\n//-----------------------------------------------------------------------------\nvoid tst_CatalogReader::testReadAbstractors()\n{ \n    QDomDocument document;\n    document.setContent(QString(    \n        \"<?xml version=\\\"1.0\\\"?>\"\n        \"<ipxact:catalog xmlns:xsi=\\\"http://www.w3.org/2001/XMLSchema-instance\\\" \" \n        \"xmlns:ipxact=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014\\\" \"\n        \"xmlns:kactus2=\\\"http://kactus2.cs.tut.fi\\\" \"\n        \"xsi:schemaLocation=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/ \"\n        \"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/index.xsd\\\">\"\n            \"<ipxact:vendor>tut.fi</ipxact:vendor>\"\n            \"<ipxact:library>TestLibrary</ipxact:library>\"\n            \"<ipxact:name>TestCatalog</ipxact:name>\"\n            \"<ipxact:version>1.0</ipxact:version>\"\n            \"<ipxact:abstractors>\"\n                \"<ipxact:ipxactFile>\"\n                    \"<ipxact:vlnv vendor=\\\"tut.fi\\\" library=\\\"TestLibrary\\\" name=\\\"MiniAbstractor\\\" version=\\\"1.0\\\"/>\"\n                    \"<ipxact:name>./mini.xml</ipxact:name>\"          \n                \"</ipxact:ipxactFile>\"\n                \"<ipxact:ipxactFile>\"\n                    \"<ipxact:vlnv vendor=\\\"tut.fi\\\" library=\\\"TestLibrary\\\" name=\\\"CompleteAbstractor\\\" version=\\\"1.0\\\"/>\"\n                    \"<ipxact:name>./complete.xml</ipxact:name>\"\n                    \"<ipxact:description>Test file description</ipxact:description>\"\n                    \"<ipxact:vendorExtensions>\"\n                        \"<testExtension vendorAttribute=\\\"extension\\\">testValue</testExtension>\"\n                    \"</ipxact:vendorExtensions>\"\n                \"</ipxact:ipxactFile>\"\n            \"</ipxact:abstractors>\"\n        \"</ipxact:catalog>\\n\"));\n\n    QSharedPointer<Catalog> testCatalog = CatalogReader::createCatalogFrom(document);\n\n    QCOMPARE(testCatalog->getAbstractors()->size(), 2); \n\n    QSharedPointer<IpxactFile> firstAbstractorFile = testCatalog->getAbstractors()->first();\n\n    QCOMPARE(firstAbstractorFile->getVlnv(), VLNV(VLNV::ABSTRACTOR, \"tut.fi\", \"TestLibrary\", \"MiniAbstractor\", \"1.0\"));\n    QCOMPARE(firstAbstractorFile->getName(), QString(\"./mini.xml\"));\n\n    QSharedPointer<IpxactFile> secondAbstractorFile = testCatalog->getAbstractors()->last();\n\n    QCOMPARE(secondAbstractorFile->getVlnv(), VLNV(VLNV::ABSTRACTOR, \"tut.fi\", \"TestLibrary\", \"CompleteAbstractor\", \"1.0\"));\n    QCOMPARE(secondAbstractorFile->getDescription(), QString(\"Test file description\"));\n    QCOMPARE(secondAbstractorFile->getVendorExtensions()->size(), 1);\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_CatalogReader::testReadDesigns()\n//-----------------------------------------------------------------------------\nvoid tst_CatalogReader::testReadDesigns()\n{ \n    QDomDocument document;\n    document.setContent(QString(    \n        \"<?xml version=\\\"1.0\\\"?>\"\n        \"<ipxact:catalog xmlns:xsi=\\\"http://www.w3.org/2001/XMLSchema-instance\\\" \" \n        \"xmlns:ipxact=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014\\\" \"\n        \"xmlns:kactus2=\\\"http://kactus2.cs.tut.fi\\\" \"\n        \"xsi:schemaLocation=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/ \"\n        \"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/index.xsd\\\">\"\n            \"<ipxact:vendor>tut.fi</ipxact:vendor>\"\n            \"<ipxact:library>TestLibrary</ipxact:library>\"\n            \"<ipxact:name>TestCatalog</ipxact:name>\"\n            \"<ipxact:version>1.0</ipxact:version>\"\n            \"<ipxact:designs>\"\n                \"<ipxact:ipxactFile>\"\n                    \"<ipxact:vlnv vendor=\\\"tut.fi\\\" library=\\\"TestLibrary\\\" name=\\\"SubDesign\\\" version=\\\"1.0\\\"/>\"\n                    \"<ipxact:name>./mini.xml</ipxact:name>\"          \n                \"</ipxact:ipxactFile>\"\n                \"<ipxact:ipxactFile>\"\n                    \"<ipxact:vlnv vendor=\\\"tut.fi\\\" library=\\\"TestLibrary\\\" name=\\\"FullDesign\\\" version=\\\"1.0\\\"/>\"\n                    \"<ipxact:name>./complete.xml</ipxact:name>\"\n                    \"<ipxact:description>Test file description</ipxact:description>\"\n                    \"<ipxact:vendorExtensions>\"\n                        \"<testExtension vendorAttribute=\\\"extension\\\">testValue</testExtension>\"\n                    \"</ipxact:vendorExtensions>\"\n                \"</ipxact:ipxactFile>\"\n            \"</ipxact:designs>\"\n        \"</ipxact:catalog>\\n\"));\n\n    QSharedPointer<Catalog> testCatalog = CatalogReader::createCatalogFrom(document);\n\n    QCOMPARE(testCatalog->getDesigns()->size(), 2); \n\n    QSharedPointer<IpxactFile> firstDesignFile = testCatalog->getDesigns()->first();\n\n    QCOMPARE(firstDesignFile->getVlnv(), VLNV(VLNV::DESIGN, \"tut.fi\", \"TestLibrary\", \"SubDesign\", \"1.0\"));\n    QCOMPARE(firstDesignFile->getName(), QString(\"./mini.xml\"));\n\n    QSharedPointer<IpxactFile> secondDesignFile = testCatalog->getDesigns()->last();\n\n    QCOMPARE(secondDesignFile->getVlnv(), VLNV(VLNV::DESIGN, \"tut.fi\", \"TestLibrary\", \"FullDesign\", \"1.0\"));\n    QCOMPARE(secondDesignFile->getDescription(), QString(\"Test file description\"));\n    QCOMPARE(secondDesignFile->getVendorExtensions()->size(), 1);\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_CatalogReader::testReadDesignConfigurations()\n//-----------------------------------------------------------------------------\nvoid tst_CatalogReader::testReadDesignConfigurations()\n{ \n    QDomDocument document;\n    document.setContent(QString(    \n        \"<?xml version=\\\"1.0\\\"?>\"\n        \"<ipxact:catalog xmlns:xsi=\\\"http://www.w3.org/2001/XMLSchema-instance\\\" \" \n        \"xmlns:ipxact=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014\\\" \"\n        \"xmlns:kactus2=\\\"http://kactus2.cs.tut.fi\\\" \"\n        \"xsi:schemaLocation=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/ \"\n        \"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/index.xsd\\\">\"\n            \"<ipxact:vendor>tut.fi</ipxact:vendor>\"\n            \"<ipxact:library>TestLibrary</ipxact:library>\"\n            \"<ipxact:name>TestCatalog</ipxact:name>\"\n            \"<ipxact:version>1.0</ipxact:version>\"\n            \"<ipxact:designConfigurations>\"\n                \"<ipxact:ipxactFile>\"\n                    \"<ipxact:vlnv vendor=\\\"tut.fi\\\" library=\\\"TestLibrary\\\" name=\\\"SubDesign\\\" version=\\\"1.0\\\"/>\"\n                    \"<ipxact:name>./mini.xml</ipxact:name>\"          \n                \"</ipxact:ipxactFile>\"\n                \"<ipxact:ipxactFile>\"\n                    \"<ipxact:vlnv vendor=\\\"tut.fi\\\" library=\\\"TestLibrary\\\" name=\\\"FullDesign\\\" version=\\\"1.0\\\"/>\"\n                    \"<ipxact:name>./complete.xml</ipxact:name>\"\n                    \"<ipxact:description>Test file description</ipxact:description>\"\n                    \"<ipxact:vendorExtensions>\"\n                        \"<testExtension vendorAttribute=\\\"extension\\\">testValue</testExtension>\"\n                    \"</ipxact:vendorExtensions>\"\n                \"</ipxact:ipxactFile>\"\n            \"</ipxact:designConfigurations>\"\n        \"</ipxact:catalog>\\n\"));\n\n    QSharedPointer<Catalog> testCatalog = CatalogReader::createCatalogFrom(document);\n\n    QCOMPARE(testCatalog->getDesignConfigurations()->size(), 2); \n\n    QSharedPointer<IpxactFile> firstDesignFile = testCatalog->getDesignConfigurations()->first();\n\n    QCOMPARE(firstDesignFile->getVlnv(), VLNV(VLNV::DESIGNCONFIGURATION, \"tut.fi\", \"TestLibrary\", \"SubDesign\", \"1.0\"));\n    QCOMPARE(firstDesignFile->getName(), QString(\"./mini.xml\"));\n\n    QSharedPointer<IpxactFile> secondDesignFile = testCatalog->getDesignConfigurations()->last();\n\n    QCOMPARE(secondDesignFile->getVlnv(), VLNV(VLNV::DESIGNCONFIGURATION, \"tut.fi\", \"TestLibrary\", \"FullDesign\", \"1.0\"));\n    QCOMPARE(secondDesignFile->getDescription(), QString(\"Test file description\"));\n    QCOMPARE(secondDesignFile->getVendorExtensions()->size(), 1);\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_CatalogReader::testReadGeneratorChains()\n//-----------------------------------------------------------------------------\nvoid tst_CatalogReader::testReadGeneratorChains()\n{ \n    QDomDocument document;\n    document.setContent(QString(    \n        \"<?xml version=\\\"1.0\\\"?>\"\n        \"<ipxact:catalog xmlns:xsi=\\\"http://www.w3.org/2001/XMLSchema-instance\\\" \" \n        \"xmlns:ipxact=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014\\\" \"\n        \"xmlns:kactus2=\\\"http://kactus2.cs.tut.fi\\\" \"\n        \"xsi:schemaLocation=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/ \"\n        \"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/index.xsd\\\">\"\n            \"<ipxact:vendor>tut.fi</ipxact:vendor>\"\n            \"<ipxact:library>TestLibrary</ipxact:library>\"\n            \"<ipxact:name>TestCatalog</ipxact:name>\"\n            \"<ipxact:version>1.0</ipxact:version>\"\n            \"<ipxact:generatorChains>\"\n                \"<ipxact:ipxactFile>\"\n                    \"<ipxact:vlnv vendor=\\\"tut.fi\\\" library=\\\"TestLibrary\\\" name=\\\"MiniChain\\\" version=\\\"1.0\\\"/>\"\n                    \"<ipxact:name>./mini.xml</ipxact:name>\"          \n                \"</ipxact:ipxactFile>\"\n                \"<ipxact:ipxactFile>\"\n                    \"<ipxact:vlnv vendor=\\\"tut.fi\\\" library=\\\"TestLibrary\\\" name=\\\"CompleteChain\\\" version=\\\"1.0\\\"/>\"\n                    \"<ipxact:name>./complete.xml</ipxact:name>\"\n                    \"<ipxact:description>Test file description</ipxact:description>\"\n                    \"<ipxact:vendorExtensions>\"\n                        \"<testExtension vendorAttribute=\\\"extension\\\">testValue</testExtension>\"\n                    \"</ipxact:vendorExtensions>\"\n                \"</ipxact:ipxactFile>\"\n            \"</ipxact:generatorChains>\"\n        \"</ipxact:catalog>\\n\"));\n\n    QSharedPointer<Catalog> testCatalog = CatalogReader::createCatalogFrom(document);\n\n    QCOMPARE(testCatalog->getGeneratorChains()->size(), 2); \n\n    QSharedPointer<IpxactFile> firstDesignFile = testCatalog->getGeneratorChains()->first();\n\n    QCOMPARE(firstDesignFile->getVlnv(), VLNV(VLNV::GENERATORCHAIN, \"tut.fi\", \"TestLibrary\", \"MiniChain\", \"1.0\"));\n    QCOMPARE(firstDesignFile->getName(), QString(\"./mini.xml\"));\n\n    QSharedPointer<IpxactFile> secondDesignFile = testCatalog->getGeneratorChains()->last();\n\n    QCOMPARE(secondDesignFile->getVlnv(), VLNV(VLNV::GENERATORCHAIN, \"tut.fi\", \"TestLibrary\", \"CompleteChain\", \"1.0\"));\n    QCOMPARE(secondDesignFile->getDescription(), QString(\"Test file description\"));\n    QCOMPARE(secondDesignFile->getVendorExtensions()->size(), 1);\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_CatalogReader::testReadTypeDefinitions()\n//-----------------------------------------------------------------------------\nvoid tst_CatalogReader::testReadTypeDefinitions()\n{\n    QDomDocument document;\n    document.setContent(QString(    \n        \"<?xml version=\\\"1.0\\\"?>\"\n        \"<ipxact:catalog xmlns:xsi=\\\"http://www.w3.org/2001/XMLSchema-instance\\\" \" \n        \"xmlns:ipxact=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2022\\\" \"\n        \"xmlns:kactus2=\\\"http://kactus2.cs.tut.fi\\\" \"\n        \"xsi:schemaLocation=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2022/ \"\n        \"http://www.accellera.org/XMLSchema/IPXACT/1685-2022/index.xsd\\\">\"\n            \"<ipxact:vendor>tut.fi</ipxact:vendor>\"\n            \"<ipxact:library>TestLibrary</ipxact:library>\"\n            \"<ipxact:name>TestCatalog</ipxact:name>\"\n            \"<ipxact:version>1.0</ipxact:version>\"\n            \"<ipxact:displayName>testDisplayName</ipxact:displayName>\"\n            \"<ipxact:shortDescription>a short description</ipxact:shortDescription>\"\n            \"<ipxact:typeDefinitions>\"\n                \"<ipxact:ipxactFile>\"\n                    \"<ipxact:vlnv vendor=\\\"tut.fi\\\" library=\\\"TestLibrary\\\" name=\\\"CompleteTypeDefinition\\\" version=\\\"1.0\\\"/>\"\n                    \"<ipxact:name>./typedef.xml</ipxact:name>\"\n                    \"<ipxact:description>Test file description</ipxact:description>\"\n                    \"<ipxact:vendorExtensions>\"\n                        \"<testExtension vendorAttribute=\\\"extension\\\">testValue</testExtension>\"\n                    \"</ipxact:vendorExtensions>\"\n                \"</ipxact:ipxactFile>\"\n            \"</ipxact:typeDefinitions>\"\n        \"</ipxact:catalog>\\n\"));\n\n    QSharedPointer<Catalog> testCatalog = CatalogReader::createCatalogFrom(document);\n    QCOMPARE(testCatalog->getTypeDefinitions()->size(), 1);\n    QCOMPARE(testCatalog->getShortDescription(), QString(\"a short description\"));\n    QCOMPARE(testCatalog->getDisplayName(), QString(\"testDisplayName\"));\n\n    QSharedPointer<IpxactFile> typeDefFile = testCatalog->getTypeDefinitions()->first();\n    QCOMPARE(typeDefFile->getVlnv(), VLNV(VLNV::TYPEDEFINITION, \"tut.fi\", \"TestLibrary\", \"CompleteTypeDefinition\", \"1.0\"));\n    QCOMPARE(typeDefFile->getName(), QString(\"./typedef.xml\"));\n    QCOMPARE(typeDefFile->getVendorExtensions()->size(), 1);\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_CatalogReader::testReadAllElements()\n//-----------------------------------------------------------------------------\nvoid tst_CatalogReader::testReadAllElements()\n{\n    QDomDocument document;\n    document.setContent(QString(    \n        \"<?xml version=\\\"1.0\\\"?>\"\n        \"<ipxact:catalog xmlns:xsi=\\\"http://www.w3.org/2001/XMLSchema-instance\\\" \" \n        \"xmlns:ipxact=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014\\\" \"\n        \"xmlns:kactus2=\\\"http://kactus2.cs.tut.fi\\\" \"\n        \"xsi:schemaLocation=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/ \"\n        \"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/index.xsd\\\">\"\n        \"<ipxact:vendor>tut.fi</ipxact:vendor>\"\n        \"<ipxact:library>TestLibrary</ipxact:library>\"\n        \"<ipxact:name>CompleteCatalog</ipxact:name>\"\n        \"<ipxact:version>1.0</ipxact:version>\"\n        \"<ipxact:description>Catalog with all elements</ipxact:description>\"\n        \"<ipxact:catalogs>\"\n            \"<ipxact:ipxactFile>\"\n                \"<ipxact:vlnv vendor=\\\"tut.fi\\\" library=\\\"TestLibrary\\\" name=\\\"SubCatalog\\\" version=\\\"1.0\\\"/>\"\n                \"<ipxact:name>./catalog.xml</ipxact:name>\"          \n            \"</ipxact:ipxactFile>\"        \n        \"</ipxact:catalogs>\"\n        \"<ipxact:busDefinitions>\"\n            \"<ipxact:ipxactFile>\"\n                \"<ipxact:vlnv vendor=\\\"tut.fi\\\" library=\\\"TestLibrary\\\" name=\\\"Bus\\\" version=\\\"1.0\\\"/>\"\n                \"<ipxact:name>./bus.xml</ipxact:name>\"          \n            \"</ipxact:ipxactFile>\"        \n        \"</ipxact:busDefinitions>\"\n        \"<ipxact:abstractionDefinitions>\"\n            \"<ipxact:ipxactFile>\"\n                \"<ipxact:vlnv vendor=\\\"tut.fi\\\" library=\\\"TestLibrary\\\" name=\\\"Abstraction\\\" version=\\\"1.0\\\"/>\"\n                \"<ipxact:name>./abstraction.xml</ipxact:name>\"          \n            \"</ipxact:ipxactFile>\"        \n        \"</ipxact:abstractionDefinitions>\" \n        \"<ipxact:components>\"\n            \"<ipxact:ipxactFile>\"\n                \"<ipxact:vlnv vendor=\\\"tut.fi\\\" library=\\\"TestLibrary\\\" name=\\\"Component\\\" version=\\\"1.0\\\"/>\"\n                \"<ipxact:name>./component.xml</ipxact:name>\"          \n            \"</ipxact:ipxactFile>\"        \n        \"</ipxact:components>\" \n        \"<ipxact:abstractors>\"\n            \"<ipxact:ipxactFile>\"\n                \"<ipxact:vlnv vendor=\\\"tut.fi\\\" library=\\\"TestLibrary\\\" name=\\\"Abstractor\\\" version=\\\"1.0\\\"/>\"\n                \"<ipxact:name>./abstractor.xml</ipxact:name>\"          \n            \"</ipxact:ipxactFile>\"        \n        \"</ipxact:abstractors>\" \n        \"<ipxact:designs>\"\n            \"<ipxact:ipxactFile>\"\n                \"<ipxact:vlnv vendor=\\\"tut.fi\\\" library=\\\"TestLibrary\\\" name=\\\"Design\\\" version=\\\"1.0\\\"/>\"\n                \"<ipxact:name>./design.xml</ipxact:name>\"          \n            \"</ipxact:ipxactFile>\"        \n        \"</ipxact:designs>\" \n        \"<ipxact:designConfigurations>\"\n            \"<ipxact:ipxactFile>\"\n                \"<ipxact:vlnv vendor=\\\"tut.fi\\\" library=\\\"TestLibrary\\\" name=\\\"Configuration\\\" version=\\\"1.0\\\"/>\"\n                \"<ipxact:name>./configuration.xml</ipxact:name>\"          \n            \"</ipxact:ipxactFile>\"        \n        \"</ipxact:designConfigurations>\" \n        \"<ipxact:generatorChains>\"\n            \"<ipxact:ipxactFile>\"\n                \"<ipxact:vlnv vendor=\\\"tut.fi\\\" library=\\\"TestLibrary\\\" name=\\\"TestChain\\\" version=\\\"1.0\\\"/>\"\n                \"<ipxact:name>./chain.xml</ipxact:name>\"          \n            \"</ipxact:ipxactFile>\"        \n        \"</ipxact:generatorChains>\" \n        \"<ipxact:vendorExtensions>\"\n            \"<kactus2:version>3.4.0</kactus2:version>\"\n        \"</ipxact:vendorExtensions>\"\n        \"</ipxact:catalog>\\n\"));\n\n    QSharedPointer<Catalog> testCatalog = CatalogReader::createCatalogFrom(document);\n\n    QCOMPARE(testCatalog->getCatalogs()->size(), 1); \n    QCOMPARE(testCatalog->getBusDefinitions()->size(), 1); \n    QCOMPARE(testCatalog->getAbstractionDefinitions()->size(), 1); \n    QCOMPARE(testCatalog->getComponents()->size(), 1); \n    QCOMPARE(testCatalog->getAbstractors()->size(), 1); \n    QCOMPARE(testCatalog->getDesigns()->size(), 1); \n    QCOMPARE(testCatalog->getDesignConfigurations()->size(), 1); \n    QCOMPARE(testCatalog->getGeneratorChains()->size(), 1); \n\n    QCOMPARE(testCatalog->getVersion(), QString(\"3.4.0\")); \n}\n\n\nQTEST_APPLESS_MAIN(tst_CatalogReader)\n\n#include \"tst_CatalogReader.moc\"\n"
  },
  {
    "path": "tests/IPXACTmodels/Catalog/tst_CatalogReader.pri",
    "content": "# ----------------------------------------------------\n# This file is generated by the Qt Visual Studio Add-in.\n# ------------------------------------------------------\n\nSOURCES += ./tst_CatalogReader.cpp "
  },
  {
    "path": "tests/IPXACTmodels/Catalog/tst_CatalogReader.pro",
    "content": "#-----------------------------------------------------------------------------\n# File: tst_CatalogReader.pro\n#-----------------------------------------------------------------------------\n# Project: Kactus 2\n# Author: Esko Pekkarinen\n# Date: 01.02.2017\n#\n# Description:\n# Qt project file for running unit tests for Catalog Reader.\n#-----------------------------------------------------------------------------\n\nTEMPLATE = app\n\nTARGET = tst_CatalogReader\n\nQT += core xml testlib\nQT -= gui\n\nCONFIG += c++11 testcase console\n\nlinux-g++ | linux-g++-64 | linux-g++-32 {\n LIBS += -L../../../executable \\\n     -lIPXACTmodels\n\n}\nwin64 | win32 {\n LIBS += -L../../../executable \\\n     -lIPXACTmodelsd\n}\n\nDESTDIR = ./release\n\nINCLUDEPATH += $$DESTDIR\nINCLUDEPATH += ../../../\n\nDEPENDPATH += .\n\nOBJECTS_DIR += $$DESTDIR\n\nMOC_DIR += ./generatedFiles\nUI_DIR += ./generatedFiles\nRCC_DIR += ./generatedFiles\ninclude(tst_CatalogReader.pri)\n"
  },
  {
    "path": "tests/IPXACTmodels/Catalog/tst_CatalogValidator.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: tst_CatalogValidator.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Esko Pekkarinen\n// Date: 01.02.2017\n//\n// Description:\n// Unit test for class CatalogValidator\n//-----------------------------------------------------------------------------\n\n#include <IPXACTmodels/Catalog/Catalog.h>\n#include <IPXACTmodels/Catalog/IpxactFile.h>\n#include <IPXACTmodels/Catalog/validators/CatalogValidator.h>\n\n#include <QtTest>\n\nclass tst_CatalogValidator : public QObject\n{\n\tQ_OBJECT\n\npublic:\n    tst_CatalogValidator();\n\nprivate slots:\n\n\tvoid testMandatoryFields();\n\n    void testMandatoryFieldsInFile();\n\nprivate:\n\n};\n\n//-----------------------------------------------------------------------------\n// Function: tst_CatalogValidator::tst_CatalogValidator()\n//-----------------------------------------------------------------------------\ntst_CatalogValidator::tst_CatalogValidator()\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_CatalogValidator::testMandatoryFields()\n//-----------------------------------------------------------------------------\nvoid tst_CatalogValidator::testMandatoryFields()\n{\n    QSharedPointer<Catalog> testCatalog(new Catalog(VLNV(), Document::Revision::Std14));\n\n    CatalogValidator testValidator;\n    QCOMPARE(testValidator.validate(testCatalog), false);\n\n    QVector<QString> errorList;\n    testValidator.findErrorsIn(errorList, testCatalog);\n\n    QCOMPARE(errorList.size(), 1);\n    QCOMPARE(errorList.first(), QString(\"The VLNV ::: is invalid.\"));\n\n    testCatalog->setVlnv(VLNV(VLNV::CATALOG, \"tut.fi\", \"TestLibrary\", \"TestCatalog\", \"1.0\"));\n    QCOMPARE(testValidator.validate(testCatalog), true);\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_CatalogValidator::testMandatoryFieldsInFile()\n//-----------------------------------------------------------------------------\nvoid tst_CatalogValidator::testMandatoryFieldsInFile()\n{\n    QSharedPointer<Catalog> testCatalog(new Catalog(VLNV(VLNV::CATALOG, \"tut.fi\", \"TestLibrary\", \"TestCatalog\", \"1.0\"), Document::Revision::Std14));\n\n    QSharedPointer<IpxactFile> testFile(new IpxactFile());\n\n    testCatalog->getAbstractors()->append(testFile);\n\n    CatalogValidator testValidator;\n    QCOMPARE(testValidator.validate(testCatalog), false);\n\n    QVector<QString> errorList;\n    testValidator.findErrorsIn(errorList, testCatalog);\n\n    QCOMPARE(errorList.size(), 6);\n    //QCOMPARE(errorList.first(), QString(\"The VLNV ::: is invalid for a file within catalog tut.fi:TestLibrary:TestCatalog:1.0.\"));\n    QCOMPARE(errorList.last(), QString(\"File name must not be empty for abstractor within catalog tut.fi:TestLibrary:TestCatalog:1.0.\"));\n\n    testFile->setVlnv(VLNV(VLNV::ABSTRACTOR, \"tut.fi\", \"TestLibrary\", \"TestAbstractor\", \"1.0\"));\n  \n    errorList.clear();\n    testValidator.findErrorsIn(errorList, testCatalog);\n\n    QCOMPARE(testValidator.validate(testCatalog), false);\n    QCOMPARE(errorList.size(), 1);\n    QCOMPARE(errorList.first(), QString(\"File name must not be empty for abstractor within catalog tut.fi:TestLibrary:TestCatalog:1.0.\"));\n\n    testFile->setName(\"./test.xml\");\n   \n    errorList.clear();\n    testValidator.findErrorsIn(errorList, testCatalog);\n\n    QCOMPARE(testValidator.validate(testCatalog), true);\n    QCOMPARE(errorList.size(), 0);\n}\n\n\nQTEST_APPLESS_MAIN(tst_CatalogValidator)\n\n\n#include \"tst_CatalogValidator.moc\"\n"
  },
  {
    "path": "tests/IPXACTmodels/Catalog/tst_CatalogValidator.pri",
    "content": "# ----------------------------------------------------\n# This file is generated by the Qt Visual Studio Tools.\n# ------------------------------------------------------\n\nSOURCES += ./tst_CatalogValidator.cpp\n"
  },
  {
    "path": "tests/IPXACTmodels/Catalog/tst_CatalogValidator.pro",
    "content": "#-----------------------------------------------------------------------------\n# Catalog: tst_CatalogValidator.pro\n#-----------------------------------------------------------------------------\n# Project: Kactus 2\n# Author: Esko Pekkarinen\n# Date: 01.02.2017\n#\n# Description:\n# Qt project file for running unit tests for Catalog Validator.\n#-----------------------------------------------------------------------------\n\nTEMPLATE = app\n\nTARGET = tst_CatalogValidator\n\nQT += core xml testlib\nQT -= gui\n\nCONFIG += c++11 testcase console\n\nlinux-g++ | linux-g++-64 | linux-g++-32 {\n LIBS += -L../../../executable \\\n     -lIPXACTmodels\n\n}\nwin64 | win32 {\n LIBS += -L../../../executable \\\n     -lIPXACTmodelsd\n}\n\nDESTDIR = ./release\n\nINCLUDEPATH += $$DESTDIR\nINCLUDEPATH += ../../../\n\nDEPENDPATH += .\n\nOBJECTS_DIR += $$DESTDIR\n\nMOC_DIR += ./generatedFiles\nUI_DIR += ./generatedFiles\nRCC_DIR += ./generatedFiles\ninclude(tst_CatalogValidator.pri)\n"
  },
  {
    "path": "tests/IPXACTmodels/Catalog/tst_CatalogWriter.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: tst_CatalogWriter.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Esko Pekkarinen\n// Date: 30.01.2017\n//\n// Description:\n// Unit test for class CatalogWriter.\n//-----------------------------------------------------------------------------\n\n#include <QtTest>\n\n#include <IPXACTmodels/common/Assertion.h>\n#include <IPXACTmodels/common/Parameter.h>\n#include <IPXACTmodels/common/GenericVendorExtension.h>\n\n#include <IPXACTmodels/Catalog/Catalog.h>\n#include <IPXACTmodels/Catalog/CatalogWriter.h>\n#include <IPXACTmodels/Catalog/IpxactFile.h>\n\nclass tst_CatalogWriter : public QObject\n{\n    Q_OBJECT\n\npublic:\n    tst_CatalogWriter();\n\nprivate slots:\n\n    void testWriteMinimalCatalog();\n\n    void testTopCommentsAreWritten();\n    void testProcessingInstructionsAreWritten();\n\n    void testOtherCatalogsAreWritten();\n    void testBusDefinitionsAreWritten();\n    void testAbstractionDefinitionsAreWritten();\n    void testComponentsAreWritten();\n    void testAbstractorsAreWritten();\n    void testDesignsAreWritten();\n    void testDesignConfigurationsAreWritten();\n    void testGeneratorChainsAreWritten();\n    void testTypeDefinitionsAreWritten();\n    \n    void testVendorExtensions();\n\n    void testWriteAllElements();\n\nprivate:\n\n    QDomDocument document_;\n\n    QSharedPointer<VendorExtension> createTestVendorExtension();\n\n};\n\n//-----------------------------------------------------------------------------\n// Function: tst_CatalogWriter::tst_Catalog()\n//-----------------------------------------------------------------------------\ntst_CatalogWriter::tst_CatalogWriter(): document_()\n{\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_CatalogWriter::testWriteMinimalCatalog()\n//-----------------------------------------------------------------------------\nvoid tst_CatalogWriter::testWriteMinimalCatalog()\n{\n    VLNV vlnv(VLNV::CATALOG, \"tut.fi\", \"TestLibrary\", \"MinimalCatalog\", \"1.0\");\n    QSharedPointer<Catalog> catalog(new Catalog(vlnv, Document::Revision::Std14));\n    catalog->setVlnv(vlnv);\n\n    QString output;\n    QXmlStreamWriter xmlStreamWriter(&output);\n    \n    CatalogWriter::writeCatalog(xmlStreamWriter, catalog);\n\n    QCOMPARE(output, QString(\n        \"<?xml version=\\\"1.0\\\"?>\"\n        \"<ipxact:catalog xmlns:xsi=\\\"http://www.w3.org/2001/XMLSchema-instance\\\" \" \n        \"xmlns:ipxact=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014\\\" \"\n        \"xmlns:kactus2=\\\"http://kactus2.cs.tut.fi\\\" \"\n        \"xsi:schemaLocation=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014 \"\n        \"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/index.xsd\\\">\"\n            \"<ipxact:vendor>tut.fi</ipxact:vendor>\"\n            \"<ipxact:library>TestLibrary</ipxact:library>\"\n            \"<ipxact:name>MinimalCatalog</ipxact:name>\"\n            \"<ipxact:version>1.0</ipxact:version>\"\n        \"</ipxact:catalog>\\n\"));\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_CatalogWriter::testTopCommentsAreWritten()\n//-----------------------------------------------------------------------------\nvoid tst_CatalogWriter::testTopCommentsAreWritten()\n{\n    VLNV vlnv(VLNV::CATALOG, \"tut.fi\", \"TestLibrary\", \"MinimalCatalog\", \"1.0\");\n    QSharedPointer<Catalog> catalog(new Catalog(vlnv, Document::Revision::Std14));\n    catalog->setVlnv(vlnv);\n    catalog->setTopComments(\"Commented section\");\n\n    QString output;\n    QXmlStreamWriter xmlStreamWriter(&output);\n    \n    CatalogWriter::writeCatalog(xmlStreamWriter, catalog);\n\n    QCOMPARE(output, QString(\n        \"<?xml version=\\\"1.0\\\"?>\"\n        \"<!--Commented section-->\"\n        \"<ipxact:catalog xmlns:xsi=\\\"http://www.w3.org/2001/XMLSchema-instance\\\" \" \n        \"xmlns:ipxact=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014\\\" \"\n        \"xmlns:kactus2=\\\"http://kactus2.cs.tut.fi\\\" \"\n        \"xsi:schemaLocation=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014 \"\n        \"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/index.xsd\\\">\"\n            \"<ipxact:vendor>tut.fi</ipxact:vendor>\"\n            \"<ipxact:library>TestLibrary</ipxact:library>\"\n            \"<ipxact:name>MinimalCatalog</ipxact:name>\"\n            \"<ipxact:version>1.0</ipxact:version>\"\n        \"</ipxact:catalog>\\n\"));\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_CatalogWriter::testProcessingInstructionsAreWritten()\n//-----------------------------------------------------------------------------\nvoid tst_CatalogWriter::testProcessingInstructionsAreWritten()\n{\n    VLNV vlnv(VLNV::CATALOG, \"tut.fi\", \"TestLibrary\", \"StyledCatalog\", \"1.0\");\n    QSharedPointer<Catalog> catalog(new Catalog(vlnv, Document::Revision::Std14));\n    catalog->setVlnv(vlnv);\n    catalog->addXmlProcessingInstructions(\"xml-stylesheet\", \"href=\\\"style.css\\\" attribute=\\\"value\\\"\");\n\n    QString output;\n    QXmlStreamWriter xmlStreamWriter(&output);\n    \n    CatalogWriter::writeCatalog(xmlStreamWriter, catalog);\n\n    QCOMPARE(output, QString(\"<?xml version=\\\"1.0\\\"?>\"\n        \"<?xml-stylesheet href=\\\"style.css\\\" attribute=\\\"value\\\"?>\"\n        \"<ipxact:catalog xmlns:xsi=\\\"http://www.w3.org/2001/XMLSchema-instance\\\" \" \n        \"xmlns:ipxact=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014\\\" \"\n        \"xmlns:kactus2=\\\"http://kactus2.cs.tut.fi\\\" \"\n        \"xsi:schemaLocation=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014 \"\n        \"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/index.xsd\\\">\"\n            \"<ipxact:vendor>tut.fi</ipxact:vendor>\"\n            \"<ipxact:library>TestLibrary</ipxact:library>\"\n            \"<ipxact:name>StyledCatalog</ipxact:name>\"\n            \"<ipxact:version>1.0</ipxact:version>\"\n        \"</ipxact:catalog>\\n\"));\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_CatalogWriter::testOtherCatalogsAreWritten()\n//-----------------------------------------------------------------------------\nvoid tst_CatalogWriter::testOtherCatalogsAreWritten()\n{\n    VLNV vlnv(VLNV::CATALOG, \"tut.fi\", \"TestLibrary\", \"TestCatalog\", \"1.0\");\n    QSharedPointer<Catalog> catalog(new Catalog(vlnv, Document::Revision::Std14));\n    catalog->setVlnv(vlnv);\n    catalog->setDescription(QStringLiteral(\"Catalog description\"));\n\n    VLNV minimalVLNV(VLNV::CATALOG, \"tut.fi\", \"TestLibrary\", \"MiniCatalog\", \"1.0\");\n    QSharedPointer<IpxactFile> miniCatalog(new IpxactFile());\n    miniCatalog->setVlnv(minimalVLNV);\n    miniCatalog->setName(\"./mini.xml\");\n\n    VLNV completeVLNV(VLNV::CATALOG, \"tut.fi\", \"TestLibrary\", \"CompleteCatalog\", \"1.0\");\n    QSharedPointer<IpxactFile> completeCatalog(new IpxactFile());\n    completeCatalog->setVlnv(completeVLNV);\n    completeCatalog->setName(\"./complete.xml\");\n    completeCatalog->setDescription(\"Test file description\");\n    completeCatalog->getVendorExtensions()->append(createTestVendorExtension());\n\n    catalog->getCatalogs()->append(miniCatalog);\n    catalog->getCatalogs()->append(completeCatalog);\n\n    QString output;\n    QXmlStreamWriter xmlStreamWriter(&output);\n    \n    CatalogWriter::writeCatalog(xmlStreamWriter, catalog);\n\n    QCOMPARE(output, QString(\n        \"<?xml version=\\\"1.0\\\"?>\"\n        \"<ipxact:catalog xmlns:xsi=\\\"http://www.w3.org/2001/XMLSchema-instance\\\" \" \n        \"xmlns:ipxact=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014\\\" \"\n        \"xmlns:kactus2=\\\"http://kactus2.cs.tut.fi\\\" \"\n        \"xsi:schemaLocation=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014 \"\n        \"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/index.xsd\\\">\"\n            \"<ipxact:vendor>tut.fi</ipxact:vendor>\"\n            \"<ipxact:library>TestLibrary</ipxact:library>\"\n            \"<ipxact:name>TestCatalog</ipxact:name>\"\n            \"<ipxact:version>1.0</ipxact:version>\"\n            \"<ipxact:description>Catalog description</ipxact:description>\"\n            \"<ipxact:catalogs>\"\n                \"<ipxact:ipxactFile>\"\n                \"<ipxact:vlnv vendor=\\\"tut.fi\\\" library=\\\"TestLibrary\\\" name=\\\"MiniCatalog\\\" version=\\\"1.0\\\"/>\"\n                \"<ipxact:name>./mini.xml</ipxact:name>\"          \n            \"</ipxact:ipxactFile>\"\n                \"<ipxact:ipxactFile>\"\n                    \"<ipxact:vlnv vendor=\\\"tut.fi\\\" library=\\\"TestLibrary\\\" name=\\\"CompleteCatalog\\\" version=\\\"1.0\\\"/>\"\n                    \"<ipxact:name>./complete.xml</ipxact:name>\"\n                    \"<ipxact:description>Test file description</ipxact:description>\"\n                    \"<ipxact:vendorExtensions>\"\n                        \"<test:testExtension test:attribute=\\\"extension\\\">testValue</test:testExtension>\"\n                    \"</ipxact:vendorExtensions>\"\n                \"</ipxact:ipxactFile>\"\n            \"</ipxact:catalogs>\"\n        \"</ipxact:catalog>\\n\"));\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_CatalogWriter::testBusDefinitionsAreWritten()\n//-----------------------------------------------------------------------------\nvoid tst_CatalogWriter::testBusDefinitionsAreWritten()\n{\n    VLNV vlnv(VLNV::CATALOG, \"tut.fi\", \"TestLibrary\", \"TestCatalog\", \"1.0\");\n    QSharedPointer<Catalog> catalog(new Catalog(vlnv, Document::Revision::Std14));\n    catalog->setVlnv(vlnv);\n    catalog->setDescription(QStringLiteral(\"Catalog description\"));\n\n    VLNV minimalVLNV(VLNV::BUSDEFINITION, \"tut.fi\", \"TestLibrary\", \"MiniBus\", \"1.0\");\n    QSharedPointer<IpxactFile> miniBus(new IpxactFile());\n    miniBus->setVlnv(minimalVLNV);\n    miniBus->setName(\"./mini.xml\");\n\n    VLNV completeVLNV(VLNV::BUSDEFINITION, \"tut.fi\", \"TestLibrary\", \"CompleteBus\", \"1.0\");\n    QSharedPointer<IpxactFile> completeBus(new IpxactFile());\n    completeBus->setVlnv(completeVLNV);\n    completeBus->setName(\"./complete.xml\");\n    completeBus->setDescription(\"Test file description\");\n    completeBus->getVendorExtensions()->append(createTestVendorExtension());\n\n    catalog->getBusDefinitions()->append(miniBus);\n    catalog->getBusDefinitions()->append(completeBus);\n\n    QString output;\n    QXmlStreamWriter xmlStreamWriter(&output);\n    \n    CatalogWriter::writeCatalog(xmlStreamWriter, catalog);\n\n    QCOMPARE(output, QString(\n        \"<?xml version=\\\"1.0\\\"?>\"\n        \"<ipxact:catalog xmlns:xsi=\\\"http://www.w3.org/2001/XMLSchema-instance\\\" \" \n        \"xmlns:ipxact=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014\\\" \"\n        \"xmlns:kactus2=\\\"http://kactus2.cs.tut.fi\\\" \"\n        \"xsi:schemaLocation=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014 \"\n        \"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/index.xsd\\\">\"\n        \"<ipxact:vendor>tut.fi</ipxact:vendor>\"\n        \"<ipxact:library>TestLibrary</ipxact:library>\"\n        \"<ipxact:name>TestCatalog</ipxact:name>\"\n        \"<ipxact:version>1.0</ipxact:version>\"\n        \"<ipxact:description>Catalog description</ipxact:description>\"\n            \"<ipxact:busDefinitions>\"\n                \"<ipxact:ipxactFile>\"\n                    \"<ipxact:vlnv vendor=\\\"tut.fi\\\" library=\\\"TestLibrary\\\" name=\\\"MiniBus\\\" version=\\\"1.0\\\"/>\"\n                    \"<ipxact:name>./mini.xml</ipxact:name>\"          \n                \"</ipxact:ipxactFile>\"\n                \"<ipxact:ipxactFile>\"\n                    \"<ipxact:vlnv vendor=\\\"tut.fi\\\" library=\\\"TestLibrary\\\" name=\\\"CompleteBus\\\" version=\\\"1.0\\\"/>\"\n                    \"<ipxact:name>./complete.xml</ipxact:name>\"\n                    \"<ipxact:description>Test file description</ipxact:description>\"\n                    \"<ipxact:vendorExtensions>\"\n                        \"<test:testExtension test:attribute=\\\"extension\\\">testValue</test:testExtension>\"\n                    \"</ipxact:vendorExtensions>\"\n                \"</ipxact:ipxactFile>\"\n            \"</ipxact:busDefinitions>\"\n        \"</ipxact:catalog>\\n\"));\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_CatalogWriter::testAbstractionDefinitionsAreWritten()\n//-----------------------------------------------------------------------------\nvoid tst_CatalogWriter::testAbstractionDefinitionsAreWritten()\n{\n    VLNV vlnv(VLNV::CATALOG, \"tut.fi\", \"TestLibrary\", \"TestCatalog\", \"1.0\");\n    QSharedPointer<Catalog> catalog(new Catalog(vlnv, Document::Revision::Std14));\n    catalog->setVlnv(vlnv);\n    catalog->setDescription(QStringLiteral(\"Catalog description\"));\n\n    VLNV minimalVLNV(VLNV::ABSTRACTIONDEFINITION, \"tut.fi\", \"TestLibrary\", \"MiniBus\", \"1.0\");\n    QSharedPointer<IpxactFile> miniAbstraction(new IpxactFile());\n    miniAbstraction->setVlnv(minimalVLNV);\n    miniAbstraction->setName(\"./mini.xml\");\n\n    VLNV completeVLNV(VLNV::ABSTRACTIONDEFINITION, \"tut.fi\", \"TestLibrary\", \"CompleteBus\", \"1.0\");\n    QSharedPointer<IpxactFile> completeAbstraction(new IpxactFile());\n    completeAbstraction->setVlnv(completeVLNV);\n    completeAbstraction->setName(\"./complete.xml\");\n    completeAbstraction->setDescription(\"Test file description\");\n    completeAbstraction->getVendorExtensions()->append(createTestVendorExtension());\n\n    catalog->getAbstractionDefinitions()->append(miniAbstraction);\n    catalog->getAbstractionDefinitions()->append(completeAbstraction);\n\n    QString output;\n    QXmlStreamWriter xmlStreamWriter(&output);\n    \n    CatalogWriter::writeCatalog(xmlStreamWriter, catalog);\n\n    QCOMPARE(output, QString(\n        \"<?xml version=\\\"1.0\\\"?>\"\n        \"<ipxact:catalog xmlns:xsi=\\\"http://www.w3.org/2001/XMLSchema-instance\\\" \" \n        \"xmlns:ipxact=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014\\\" \"\n        \"xmlns:kactus2=\\\"http://kactus2.cs.tut.fi\\\" \"\n        \"xsi:schemaLocation=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014 \"\n        \"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/index.xsd\\\">\"\n        \"<ipxact:vendor>tut.fi</ipxact:vendor>\"\n        \"<ipxact:library>TestLibrary</ipxact:library>\"\n        \"<ipxact:name>TestCatalog</ipxact:name>\"\n        \"<ipxact:version>1.0</ipxact:version>\"\n        \"<ipxact:description>Catalog description</ipxact:description>\"\n            \"<ipxact:abstractionDefinitions>\"\n                \"<ipxact:ipxactFile>\"\n                    \"<ipxact:vlnv vendor=\\\"tut.fi\\\" library=\\\"TestLibrary\\\" name=\\\"MiniBus\\\" version=\\\"1.0\\\"/>\"\n                    \"<ipxact:name>./mini.xml</ipxact:name>\"          \n                \"</ipxact:ipxactFile>\"\n                \"<ipxact:ipxactFile>\"\n                    \"<ipxact:vlnv vendor=\\\"tut.fi\\\" library=\\\"TestLibrary\\\" name=\\\"CompleteBus\\\" version=\\\"1.0\\\"/>\"\n                    \"<ipxact:name>./complete.xml</ipxact:name>\"\n                    \"<ipxact:description>Test file description</ipxact:description>\"\n                    \"<ipxact:vendorExtensions>\"\n                        \"<test:testExtension test:attribute=\\\"extension\\\">testValue</test:testExtension>\"\n                    \"</ipxact:vendorExtensions>\"\n                \"</ipxact:ipxactFile>\"\n            \"</ipxact:abstractionDefinitions>\"\n        \"</ipxact:catalog>\\n\"));\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_CatalogWriter::testComponentsAreWritten()\n//-----------------------------------------------------------------------------\nvoid tst_CatalogWriter::testComponentsAreWritten()\n{\n    VLNV vlnv(VLNV::CATALOG, \"tut.fi\", \"TestLibrary\", \"TestCatalog\", \"1.0\");\n    QSharedPointer<Catalog> catalog(new Catalog(vlnv, Document::Revision::Std14));\n    catalog->setVlnv(vlnv);\n    catalog->setDescription(QStringLiteral(\"This catalog contains two components\"));\n\n    VLNV minimalVLNV(VLNV::COMPONENT, \"tut.fi\", \"TestLibrary\", \"SubComponent\", \"1.0\");\n    QSharedPointer<IpxactFile> subComponent(new IpxactFile());\n    subComponent->setVlnv(minimalVLNV);\n    subComponent->setName(\"./sub.xml\");\n\n    VLNV completeVLNV(VLNV::COMPONENT, \"tut.fi\", \"TestLibrary\", \"TopComponent\", \"1.0\");\n    QSharedPointer<IpxactFile> topComponent(new IpxactFile());\n    topComponent->setVlnv(completeVLNV);\n    topComponent->setName(\"./top.xml\");\n    topComponent->setDescription(\"This is the top level component\");\n    topComponent->getVendorExtensions()->append(createTestVendorExtension());\n\n    catalog->getComponents()->append(subComponent);\n    catalog->getComponents()->append(topComponent);\n\n    QString output;\n    QXmlStreamWriter xmlStreamWriter(&output);\n    \n    CatalogWriter::writeCatalog(xmlStreamWriter, catalog);\n\n    QCOMPARE(output, QString(\n        \"<?xml version=\\\"1.0\\\"?>\"\n        \"<ipxact:catalog xmlns:xsi=\\\"http://www.w3.org/2001/XMLSchema-instance\\\" \" \n        \"xmlns:ipxact=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014\\\" \"\n        \"xmlns:kactus2=\\\"http://kactus2.cs.tut.fi\\\" \"\n        \"xsi:schemaLocation=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014 \"\n        \"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/index.xsd\\\">\"\n        \"<ipxact:vendor>tut.fi</ipxact:vendor>\"\n        \"<ipxact:library>TestLibrary</ipxact:library>\"\n        \"<ipxact:name>TestCatalog</ipxact:name>\"\n        \"<ipxact:version>1.0</ipxact:version>\"\n        \"<ipxact:description>This catalog contains two components</ipxact:description>\"\n            \"<ipxact:components>\"\n                \"<ipxact:ipxactFile>\"\n                    \"<ipxact:vlnv vendor=\\\"tut.fi\\\" library=\\\"TestLibrary\\\" name=\\\"SubComponent\\\" version=\\\"1.0\\\"/>\"\n                    \"<ipxact:name>./sub.xml</ipxact:name>\"          \n                \"</ipxact:ipxactFile>\"\n                \"<ipxact:ipxactFile>\"\n                    \"<ipxact:vlnv vendor=\\\"tut.fi\\\" library=\\\"TestLibrary\\\" name=\\\"TopComponent\\\" version=\\\"1.0\\\"/>\"\n                    \"<ipxact:name>./top.xml</ipxact:name>\"\n                    \"<ipxact:description>This is the top level component</ipxact:description>\"\n                    \"<ipxact:vendorExtensions>\"\n                        \"<test:testExtension test:attribute=\\\"extension\\\">testValue</test:testExtension>\"\n                    \"</ipxact:vendorExtensions>\"\n                \"</ipxact:ipxactFile>\"\n            \"</ipxact:components>\"\n        \"</ipxact:catalog>\\n\"));\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_CatalogWriter::testAbstractorsAreWritten()\n//-----------------------------------------------------------------------------\nvoid tst_CatalogWriter::testAbstractorsAreWritten()\n{\n    VLNV vlnv(VLNV::CATALOG, \"tut.fi\", \"TestLibrary\", \"TestCatalog\", \"1.0\");\n    QSharedPointer<Catalog> catalog(new Catalog(vlnv, Document::Revision::Std14));\n    catalog->setVlnv(vlnv);\n    catalog->setDescription(QStringLiteral(\"Catalog description\"));\n\n    VLNV minimalVLNV(VLNV::ABSTRACTOR, \"tut.fi\", \"TestLibrary\", \"MiniAbstractor\", \"1.0\");\n    QSharedPointer<IpxactFile> miniAbstractor(new IpxactFile());\n    miniAbstractor->setVlnv(minimalVLNV);\n    miniAbstractor->setName(\"./mini.xml\");\n\n    VLNV completeVLNV(VLNV::ABSTRACTOR, \"tut.fi\", \"TestLibrary\", \"CompleteAbstractor\", \"1.0\");\n    QSharedPointer<IpxactFile> completeAbstactor(new IpxactFile());\n    completeAbstactor->setVlnv(completeVLNV);\n    completeAbstactor->setName(\"./complete.xml\");\n    completeAbstactor->setDescription(\"Test file description\");\n    completeAbstactor->getVendorExtensions()->append(createTestVendorExtension());\n\n    catalog->getAbstractors()->append(miniAbstractor);\n    catalog->getAbstractors()->append(completeAbstactor);\n\n    QString output;\n    QXmlStreamWriter xmlStreamWriter(&output);\n    \n    CatalogWriter::writeCatalog(xmlStreamWriter, catalog);\n\n    QCOMPARE(output, QString(\n        \"<?xml version=\\\"1.0\\\"?>\"\n        \"<ipxact:catalog xmlns:xsi=\\\"http://www.w3.org/2001/XMLSchema-instance\\\" \" \n        \"xmlns:ipxact=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014\\\" \"\n        \"xmlns:kactus2=\\\"http://kactus2.cs.tut.fi\\\" \"\n        \"xsi:schemaLocation=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014 \"\n        \"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/index.xsd\\\">\"\n        \"<ipxact:vendor>tut.fi</ipxact:vendor>\"\n        \"<ipxact:library>TestLibrary</ipxact:library>\"\n        \"<ipxact:name>TestCatalog</ipxact:name>\"\n        \"<ipxact:version>1.0</ipxact:version>\"\n        \"<ipxact:description>Catalog description</ipxact:description>\"\n            \"<ipxact:abstractors>\"\n                \"<ipxact:ipxactFile>\"\n                    \"<ipxact:vlnv vendor=\\\"tut.fi\\\" library=\\\"TestLibrary\\\" name=\\\"MiniAbstractor\\\" version=\\\"1.0\\\"/>\"\n                    \"<ipxact:name>./mini.xml</ipxact:name>\"          \n                \"</ipxact:ipxactFile>\"\n                \"<ipxact:ipxactFile>\"\n                    \"<ipxact:vlnv vendor=\\\"tut.fi\\\" library=\\\"TestLibrary\\\" name=\\\"CompleteAbstractor\\\" version=\\\"1.0\\\"/>\"\n                    \"<ipxact:name>./complete.xml</ipxact:name>\"\n                    \"<ipxact:description>Test file description</ipxact:description>\"\n                    \"<ipxact:vendorExtensions>\"\n                        \"<test:testExtension test:attribute=\\\"extension\\\">testValue</test:testExtension>\"\n                    \"</ipxact:vendorExtensions>\"\n                \"</ipxact:ipxactFile>\"\n            \"</ipxact:abstractors>\"\n        \"</ipxact:catalog>\\n\"));\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_CatalogWriter::testDesignsAreWritten()\n//-----------------------------------------------------------------------------\nvoid tst_CatalogWriter::testDesignsAreWritten()\n{\n    VLNV vlnv(VLNV::CATALOG, \"tut.fi\", \"TestLibrary\", \"TestCatalog\", \"1.0\");\n    QSharedPointer<Catalog> catalog(new Catalog(vlnv, Document::Revision::Std14));\n    catalog->setVlnv(vlnv);\n    catalog->setDescription(QStringLiteral(\"Catalog description\"));\n\n    VLNV minimalVLNV(VLNV::DESIGN, \"tut.fi\", \"TestLibrary\", \"MiniDesign\", \"1.0\");\n    QSharedPointer<IpxactFile> miniDesign(new IpxactFile());\n    miniDesign->setVlnv(minimalVLNV);\n    miniDesign->setName(\"./mini.xml\");\n\n    VLNV completeVLNV(VLNV::DESIGN, \"tut.fi\", \"TestLibrary\", \"FullDesign\", \"1.0\");\n    QSharedPointer<IpxactFile> completeDesign(new IpxactFile());\n    completeDesign->setVlnv(completeVLNV);\n    completeDesign->setName(\"./complete.xml\");\n    completeDesign->setDescription(\"Test file description\");\n    completeDesign->getVendorExtensions()->append(createTestVendorExtension());\n\n    catalog->getDesigns()->append(miniDesign);\n    catalog->getDesigns()->append(completeDesign);\n\n    QString output;\n    QXmlStreamWriter xmlStreamWriter(&output);\n    \n    CatalogWriter::writeCatalog(xmlStreamWriter, catalog);\n\n    QCOMPARE(output, QString(\n        \"<?xml version=\\\"1.0\\\"?>\"\n        \"<ipxact:catalog xmlns:xsi=\\\"http://www.w3.org/2001/XMLSchema-instance\\\" \" \n        \"xmlns:ipxact=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014\\\" \"\n        \"xmlns:kactus2=\\\"http://kactus2.cs.tut.fi\\\" \"\n        \"xsi:schemaLocation=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014 \"\n        \"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/index.xsd\\\">\"\n        \"<ipxact:vendor>tut.fi</ipxact:vendor>\"\n        \"<ipxact:library>TestLibrary</ipxact:library>\"\n        \"<ipxact:name>TestCatalog</ipxact:name>\"\n        \"<ipxact:version>1.0</ipxact:version>\"\n        \"<ipxact:description>Catalog description</ipxact:description>\"\n            \"<ipxact:designs>\"\n                \"<ipxact:ipxactFile>\"\n                    \"<ipxact:vlnv vendor=\\\"tut.fi\\\" library=\\\"TestLibrary\\\" name=\\\"MiniDesign\\\" version=\\\"1.0\\\"/>\"\n                    \"<ipxact:name>./mini.xml</ipxact:name>\"          \n                \"</ipxact:ipxactFile>\"\n                \"<ipxact:ipxactFile>\"\n                    \"<ipxact:vlnv vendor=\\\"tut.fi\\\" library=\\\"TestLibrary\\\" name=\\\"FullDesign\\\" version=\\\"1.0\\\"/>\"\n                    \"<ipxact:name>./complete.xml</ipxact:name>\"\n                    \"<ipxact:description>Test file description</ipxact:description>\"\n                    \"<ipxact:vendorExtensions>\"\n                        \"<test:testExtension test:attribute=\\\"extension\\\">testValue</test:testExtension>\"\n                    \"</ipxact:vendorExtensions>\"\n                \"</ipxact:ipxactFile>\"\n            \"</ipxact:designs>\"\n        \"</ipxact:catalog>\\n\"));\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_CatalogWriter::testDesignConfigurationsAreWritten()\n//-----------------------------------------------------------------------------\nvoid tst_CatalogWriter::testDesignConfigurationsAreWritten()\n{\n    VLNV vlnv(VLNV::CATALOG, \"tut.fi\", \"TestLibrary\", \"TestCatalog\", \"1.0\");\n    QSharedPointer<Catalog> catalog(new Catalog(vlnv, Document::Revision::Std14));\n    catalog->setVlnv(vlnv);\n    catalog->setDescription(QStringLiteral(\"Catalog description\"));\n\n    VLNV minimalVLNV(VLNV::DESIGNCONFIGURATION, \"tut.fi\", \"TestLibrary\", \"MiniDesign\", \"1.0\");\n    QSharedPointer<IpxactFile> miniConfiguration(new IpxactFile());\n    miniConfiguration->setVlnv(minimalVLNV);\n    miniConfiguration->setName(\"./mini.xml\");\n\n    VLNV completeVLNV(VLNV::DESIGNCONFIGURATION, \"tut.fi\", \"TestLibrary\", \"FullDesign\", \"1.0\");\n    QSharedPointer<IpxactFile> completeConfiguration(new IpxactFile());\n    completeConfiguration->setVlnv(completeVLNV);\n    completeConfiguration->setName(\"./complete.xml\");\n    completeConfiguration->setDescription(\"Test file description\");\n    completeConfiguration->getVendorExtensions()->append(createTestVendorExtension());\n\n    catalog->getDesignConfigurations()->append(miniConfiguration);\n    catalog->getDesignConfigurations()->append(completeConfiguration);\n\n    QString output;\n    QXmlStreamWriter xmlStreamWriter(&output);\n    \n    CatalogWriter::writeCatalog(xmlStreamWriter, catalog);\n\n    QCOMPARE(output, QString(\n        \"<?xml version=\\\"1.0\\\"?>\"\n        \"<ipxact:catalog xmlns:xsi=\\\"http://www.w3.org/2001/XMLSchema-instance\\\" \" \n        \"xmlns:ipxact=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014\\\" \"\n        \"xmlns:kactus2=\\\"http://kactus2.cs.tut.fi\\\" \"\n        \"xsi:schemaLocation=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014 \"\n        \"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/index.xsd\\\">\"\n        \"<ipxact:vendor>tut.fi</ipxact:vendor>\"\n        \"<ipxact:library>TestLibrary</ipxact:library>\"\n        \"<ipxact:name>TestCatalog</ipxact:name>\"\n        \"<ipxact:version>1.0</ipxact:version>\"\n        \"<ipxact:description>Catalog description</ipxact:description>\"\n            \"<ipxact:designConfigurations>\"\n                \"<ipxact:ipxactFile>\"\n                    \"<ipxact:vlnv vendor=\\\"tut.fi\\\" library=\\\"TestLibrary\\\" name=\\\"MiniDesign\\\" version=\\\"1.0\\\"/>\"\n                    \"<ipxact:name>./mini.xml</ipxact:name>\"          \n                \"</ipxact:ipxactFile>\"\n                \"<ipxact:ipxactFile>\"\n                    \"<ipxact:vlnv vendor=\\\"tut.fi\\\" library=\\\"TestLibrary\\\" name=\\\"FullDesign\\\" version=\\\"1.0\\\"/>\"\n                    \"<ipxact:name>./complete.xml</ipxact:name>\"\n                     \"<ipxact:description>Test file description</ipxact:description>\"\n                     \"<ipxact:vendorExtensions>\"\n                            \"<test:testExtension test:attribute=\\\"extension\\\">testValue</test:testExtension>\"\n                    \"</ipxact:vendorExtensions>\"\n                \"</ipxact:ipxactFile>\"\n            \"</ipxact:designConfigurations>\"\n        \"</ipxact:catalog>\\n\"));\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_CatalogWriter::testGeneratorChainsAreWritten()\n//-----------------------------------------------------------------------------\nvoid tst_CatalogWriter::testGeneratorChainsAreWritten()\n{\n    VLNV vlnv(VLNV::CATALOG, \"tut.fi\", \"TestLibrary\", \"TestCatalog\", \"1.0\");\n    QSharedPointer<Catalog> catalog(new Catalog(vlnv, Document::Revision::Std14));\n    catalog->setVlnv(vlnv);\n    catalog->setDescription(QStringLiteral(\"Catalog description\"));\n\n    VLNV minimalVLNV(VLNV::GENERATORCHAIN, \"tut.fi\", \"TestLibrary\", \"MiniChain\", \"1.0\");\n    QSharedPointer<IpxactFile> miniChain(new IpxactFile());\n    miniChain->setVlnv(minimalVLNV);\n    miniChain->setName(\"./mini.xml\");\n\n    VLNV completeVLNV(VLNV::GENERATORCHAIN, \"tut.fi\", \"TestLibrary\", \"CompleteChain\", \"1.0\");\n    QSharedPointer<IpxactFile> completeChain(new IpxactFile());\n    completeChain->setVlnv(completeVLNV);\n    completeChain->setName(\"./complete.xml\");\n    completeChain->setDescription(\"Test file description\");\n    completeChain->getVendorExtensions()->append(createTestVendorExtension());\n\n    catalog->getGeneratorChains()->append(miniChain);\n    catalog->getGeneratorChains()->append(completeChain);\n\n    QString output;\n    QXmlStreamWriter xmlStreamWriter(&output);\n    \n    CatalogWriter::writeCatalog(xmlStreamWriter, catalog);\n\n    QCOMPARE(output, QString(\n        \"<?xml version=\\\"1.0\\\"?>\"\n        \"<ipxact:catalog xmlns:xsi=\\\"http://www.w3.org/2001/XMLSchema-instance\\\" \" \n        \"xmlns:ipxact=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014\\\" \"\n        \"xmlns:kactus2=\\\"http://kactus2.cs.tut.fi\\\" \"\n        \"xsi:schemaLocation=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014 \"\n        \"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/index.xsd\\\">\"\n        \"<ipxact:vendor>tut.fi</ipxact:vendor>\"\n        \"<ipxact:library>TestLibrary</ipxact:library>\"\n        \"<ipxact:name>TestCatalog</ipxact:name>\"\n        \"<ipxact:version>1.0</ipxact:version>\"\n        \"<ipxact:description>Catalog description</ipxact:description>\"\n            \"<ipxact:generatorChains>\"\n                \"<ipxact:ipxactFile>\"\n                    \"<ipxact:vlnv vendor=\\\"tut.fi\\\" library=\\\"TestLibrary\\\" name=\\\"MiniChain\\\" version=\\\"1.0\\\"/>\"\n                    \"<ipxact:name>./mini.xml</ipxact:name>\"          \n                \"</ipxact:ipxactFile>\"\n                \"<ipxact:ipxactFile>\"\n                    \"<ipxact:vlnv vendor=\\\"tut.fi\\\" library=\\\"TestLibrary\\\" name=\\\"CompleteChain\\\" version=\\\"1.0\\\"/>\"\n                    \"<ipxact:name>./complete.xml</ipxact:name>\"\n                    \"<ipxact:description>Test file description</ipxact:description>\"\n                    \"<ipxact:vendorExtensions>\"\n                        \"<test:testExtension test:attribute=\\\"extension\\\">testValue</test:testExtension>\"\n                    \"</ipxact:vendorExtensions>\"\n                \"</ipxact:ipxactFile>\"\n            \"</ipxact:generatorChains>\"\n        \"</ipxact:catalog>\\n\"));\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_CatalogWriter::testTypeDefinitionsAreWritten()\n//-----------------------------------------------------------------------------\nvoid tst_CatalogWriter::testTypeDefinitionsAreWritten()\n{\n    VLNV vlnv(VLNV::CATALOG, \"tut.fi\", \"TestLibrary\", \"TestCatalog\", \"1.0\");\n    QSharedPointer<Catalog> catalog(new Catalog(vlnv, Document::Revision::Std22));\n    catalog->setDisplayName(QStringLiteral(\"DisplayName\"));\n    catalog->setShortDescription(QStringLiteral(\"ShortDescription\"));\n    catalog->setDescription(QStringLiteral(\"Catalog description\"));\n\n    VLNV completeVLNV(VLNV::TYPEDEFINITION, \"tut.fi\", \"TestLibrary\", \"typeDef\", \"1.0\");\n    QSharedPointer<IpxactFile> typeDef(new IpxactFile());\n    typeDef->setVlnv(completeVLNV);\n    typeDef->setName(\"./typeDef.xml\");\n    typeDef->setDescription(\"Test file description\");\n    typeDef->getVendorExtensions()->append(createTestVendorExtension());\n\n    catalog->getTypeDefinitions()->append(typeDef);\n\n    QString output;\n    QXmlStreamWriter xmlStreamWriter(&output);\n    \n    CatalogWriter::writeCatalog(xmlStreamWriter, catalog);\n\n    QCOMPARE(output, QString(\n        \"<?xml version=\\\"1.0\\\"?>\"\n        \"<ipxact:catalog xmlns:xsi=\\\"http://www.w3.org/2001/XMLSchema-instance\\\" \"\n        \"xmlns:ipxact=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2022\\\" \"\n        \"xmlns:kactus2=\\\"http://kactus2.cs.tut.fi\\\" \"\n        \"xsi:schemaLocation=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2022 \"\n        \"http://www.accellera.org/XMLSchema/IPXACT/1685-2022/index.xsd\\\">\"\n            \"<ipxact:vendor>tut.fi</ipxact:vendor>\"\n            \"<ipxact:library>TestLibrary</ipxact:library>\"\n            \"<ipxact:name>TestCatalog</ipxact:name>\"\n            \"<ipxact:version>1.0</ipxact:version>\"\n            \"<ipxact:displayName>DisplayName</ipxact:displayName>\"\n            \"<ipxact:shortDescription>ShortDescription</ipxact:shortDescription>\"\n            \"<ipxact:description>Catalog description</ipxact:description>\"\n            \"<ipxact:typeDefinitions>\"\n                \"<ipxact:ipxactFile>\"\n                    \"<ipxact:vlnv vendor=\\\"tut.fi\\\" library=\\\"TestLibrary\\\" name=\\\"typeDef\\\" version=\\\"1.0\\\"/>\"\n                    \"<ipxact:name>./typeDef.xml</ipxact:name>\"\n                    \"<ipxact:description>Test file description</ipxact:description>\"\n                    \"<ipxact:vendorExtensions>\"\n                        \"<test:testExtension test:attribute=\\\"extension\\\">testValue</test:testExtension>\"\n                    \"</ipxact:vendorExtensions>\"\n                \"</ipxact:ipxactFile>\"\n            \"</ipxact:typeDefinitions>\"\n        \"</ipxact:catalog>\\n\"));\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_CatalogWriter::testVendorExtensions()\n//-----------------------------------------------------------------------------\nvoid tst_CatalogWriter::testVendorExtensions()\n{\n    VLNV vlnv(VLNV::CATALOG, \"tut.fi\", \"TestLibrary\", \"TestCatalog\", \"1.0\");\n    QSharedPointer<Catalog> catalog(new Catalog(vlnv, Document::Revision::Std14));\n    catalog->setVlnv(vlnv);\n    catalog->setVersion(\"3.0.0\");\n    catalog->getVendorExtensions()->append(createTestVendorExtension());\n\n    QString output;\n    QXmlStreamWriter xmlStreamWriter(&output);\n    \n    CatalogWriter::writeCatalog(xmlStreamWriter, catalog);\n\n    QCOMPARE(output, QString(\n        \"<?xml version=\\\"1.0\\\"?>\"\n        \"<ipxact:catalog xmlns:xsi=\\\"http://www.w3.org/2001/XMLSchema-instance\\\" \" \n        \"xmlns:ipxact=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014\\\" \"\n        \"xmlns:kactus2=\\\"http://kactus2.cs.tut.fi\\\" \"\n        \"xsi:schemaLocation=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014 \"\n        \"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/index.xsd\\\">\"\n            \"<ipxact:vendor>tut.fi</ipxact:vendor>\"\n            \"<ipxact:library>TestLibrary</ipxact:library>\"\n            \"<ipxact:name>TestCatalog</ipxact:name>\"\n            \"<ipxact:version>1.0</ipxact:version>\"\n            \"<ipxact:vendorExtensions>\"\n                \"<kactus2:version>3.0.0</kactus2:version>\"\n                \"<test:testExtension test:attribute=\\\"extension\\\">testValue</test:testExtension>\"\n            \"</ipxact:vendorExtensions>\"\n        \"</ipxact:catalog>\\n\"));\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_CatalogWriter::testWriteAllElements()\n//-----------------------------------------------------------------------------\nvoid tst_CatalogWriter::testWriteAllElements()\n{\n    VLNV vlnv(VLNV::CATALOG, \"tut.fi\", \"TestLibrary\", \"CompleteCatalog\", \"1.0\");\n    QSharedPointer<Catalog> catalog(new Catalog(vlnv, Document::Revision::Std14));\n    catalog->setVlnv(vlnv);\n    catalog->setDescription(QStringLiteral(\"Catalog with all elements\"));\n    catalog->setVersion(\"3.0.0\");\n\n    VLNV catalogVLNV(VLNV::CATALOG, \"tut.fi\", \"TestLibrary\", \"SubCatalog\", \"1.0\");\n    QSharedPointer<IpxactFile> otherCatalog(new IpxactFile());\n    otherCatalog->setVlnv(catalogVLNV);\n    otherCatalog->setName(\"./catalog.xml\");\n\n    VLNV busVLNV(VLNV::BUSDEFINITION, \"tut.fi\", \"TestLibrary\", \"Bus\", \"1.0\");\n    QSharedPointer<IpxactFile> busDefinition(new IpxactFile());\n    busDefinition->setVlnv(busVLNV);\n    busDefinition->setName(\"./bus.xml\");\n\n    VLNV abstractionVLNV(VLNV::ABSTRACTIONDEFINITION, \"tut.fi\", \"TestLibrary\", \"Abstraction\", \"1.0\");\n    QSharedPointer<IpxactFile> abstraction(new IpxactFile());\n    abstraction->setVlnv(abstractionVLNV);\n    abstraction->setName(\"./abstraction.xml\");\n\n    VLNV componentVLNV(VLNV::COMPONENT, \"tut.fi\", \"TestLibrary\", \"Component\", \"1.0\");\n    QSharedPointer<IpxactFile> component(new IpxactFile());\n    component->setVlnv(componentVLNV);\n    component->setName(\"./component.xml\");\n\n    VLNV abstractorVLNV(VLNV::ABSTRACTOR, \"tut.fi\", \"TestLibrary\", \"Abstractor\", \"1.0\");\n    QSharedPointer<IpxactFile> abstractor(new IpxactFile());\n    abstractor->setVlnv(abstractorVLNV);\n    abstractor->setName(\"./abstractor.xml\");\n\n    VLNV designVLNV(VLNV::DESIGN, \"tut.fi\", \"TestLibrary\", \"Design\", \"1.0\");\n    QSharedPointer<IpxactFile> design(new IpxactFile());\n    design->setVlnv(designVLNV);\n    design->setName(\"./design.xml\");\n\n    VLNV configurationVLNV(VLNV::DESIGNCONFIGURATION, \"tut.fi\", \"TestLibrary\", \"Configuration\", \"1.0\");\n    QSharedPointer<IpxactFile> designConfiguration(new IpxactFile());\n    designConfiguration->setVlnv(configurationVLNV);\n    designConfiguration->setName(\"./configuration.xml\");\n\n    VLNV chainVLNV(VLNV::GENERATORCHAIN, \"tut.fi\", \"TestLibrary\", \"TestChain\", \"1.0\");\n    QSharedPointer<IpxactFile> generatorChain(new IpxactFile());\n    generatorChain->setVlnv(chainVLNV);\n    generatorChain->setName(\"./chain.xml\");\n\n    catalog->getCatalogs()->append(otherCatalog);\n    catalog->getBusDefinitions()->append(busDefinition);\n    catalog->getAbstractionDefinitions()->append(abstraction);\n    catalog->getComponents()->append(component);\n    catalog->getAbstractors()->append(abstractor);\n    catalog->getDesigns()->append(design);\n    catalog->getDesignConfigurations()->append(designConfiguration);\n    catalog->getGeneratorChains()->append(generatorChain);\n\n    QString output;\n    QXmlStreamWriter xmlStreamWriter(&output);\n    \n    CatalogWriter::writeCatalog(xmlStreamWriter, catalog);\n\n    QCOMPARE(output, QString(\n        \"<?xml version=\\\"1.0\\\"?>\"\n        \"<ipxact:catalog xmlns:xsi=\\\"http://www.w3.org/2001/XMLSchema-instance\\\" \" \n        \"xmlns:ipxact=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014\\\" \"\n        \"xmlns:kactus2=\\\"http://kactus2.cs.tut.fi\\\" \"\n        \"xsi:schemaLocation=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014 \"\n        \"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/index.xsd\\\">\"\n        \"<ipxact:vendor>tut.fi</ipxact:vendor>\"\n        \"<ipxact:library>TestLibrary</ipxact:library>\"\n        \"<ipxact:name>CompleteCatalog</ipxact:name>\"\n        \"<ipxact:version>1.0</ipxact:version>\"\n        \"<ipxact:description>Catalog with all elements</ipxact:description>\"\n        \"<ipxact:catalogs>\"\n            \"<ipxact:ipxactFile>\"\n                \"<ipxact:vlnv vendor=\\\"tut.fi\\\" library=\\\"TestLibrary\\\" name=\\\"SubCatalog\\\" version=\\\"1.0\\\"/>\"\n                \"<ipxact:name>./catalog.xml</ipxact:name>\"          \n            \"</ipxact:ipxactFile>\"        \n        \"</ipxact:catalogs>\"\n        \"<ipxact:busDefinitions>\"\n            \"<ipxact:ipxactFile>\"\n                \"<ipxact:vlnv vendor=\\\"tut.fi\\\" library=\\\"TestLibrary\\\" name=\\\"Bus\\\" version=\\\"1.0\\\"/>\"\n                \"<ipxact:name>./bus.xml</ipxact:name>\"          \n            \"</ipxact:ipxactFile>\"        \n        \"</ipxact:busDefinitions>\"\n        \"<ipxact:abstractionDefinitions>\"\n            \"<ipxact:ipxactFile>\"\n                \"<ipxact:vlnv vendor=\\\"tut.fi\\\" library=\\\"TestLibrary\\\" name=\\\"Abstraction\\\" version=\\\"1.0\\\"/>\"\n                \"<ipxact:name>./abstraction.xml</ipxact:name>\"          \n            \"</ipxact:ipxactFile>\"        \n        \"</ipxact:abstractionDefinitions>\" \n        \"<ipxact:components>\"\n            \"<ipxact:ipxactFile>\"\n                \"<ipxact:vlnv vendor=\\\"tut.fi\\\" library=\\\"TestLibrary\\\" name=\\\"Component\\\" version=\\\"1.0\\\"/>\"\n                \"<ipxact:name>./component.xml</ipxact:name>\"          \n            \"</ipxact:ipxactFile>\"        \n        \"</ipxact:components>\" \n        \"<ipxact:abstractors>\"\n            \"<ipxact:ipxactFile>\"\n                \"<ipxact:vlnv vendor=\\\"tut.fi\\\" library=\\\"TestLibrary\\\" name=\\\"Abstractor\\\" version=\\\"1.0\\\"/>\"\n                \"<ipxact:name>./abstractor.xml</ipxact:name>\"          \n            \"</ipxact:ipxactFile>\"        \n        \"</ipxact:abstractors>\" \n        \"<ipxact:designs>\"\n            \"<ipxact:ipxactFile>\"\n                \"<ipxact:vlnv vendor=\\\"tut.fi\\\" library=\\\"TestLibrary\\\" name=\\\"Design\\\" version=\\\"1.0\\\"/>\"\n                \"<ipxact:name>./design.xml</ipxact:name>\"          \n            \"</ipxact:ipxactFile>\"        \n        \"</ipxact:designs>\" \n        \"<ipxact:designConfigurations>\"\n            \"<ipxact:ipxactFile>\"\n                \"<ipxact:vlnv vendor=\\\"tut.fi\\\" library=\\\"TestLibrary\\\" name=\\\"Configuration\\\" version=\\\"1.0\\\"/>\"\n                \"<ipxact:name>./configuration.xml</ipxact:name>\"          \n            \"</ipxact:ipxactFile>\"        \n        \"</ipxact:designConfigurations>\" \n        \"<ipxact:generatorChains>\"\n            \"<ipxact:ipxactFile>\"\n                \"<ipxact:vlnv vendor=\\\"tut.fi\\\" library=\\\"TestLibrary\\\" name=\\\"TestChain\\\" version=\\\"1.0\\\"/>\"\n                \"<ipxact:name>./chain.xml</ipxact:name>\"          \n            \"</ipxact:ipxactFile>\"        \n        \"</ipxact:generatorChains>\" \n        \"<ipxact:vendorExtensions>\"\n            \"<kactus2:version>3.0.0</kactus2:version>\"\n        \"</ipxact:vendorExtensions>\"\n        \"</ipxact:catalog>\\n\"));\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_CatalogWriter::createTestVendorExtension()\n//-----------------------------------------------------------------------------\nQSharedPointer<VendorExtension> tst_CatalogWriter::createTestVendorExtension()\n{\n    QDomElement extensionNode = document_.createElement(\"test:testExtension\");\n   \n    extensionNode.setAttribute(\"test:attribute\", \"extension\");\n\n    QDomText valueNode = document_.createTextNode(\"testValue\");\n    extensionNode.appendChild(valueNode);\n \n    QSharedPointer<GenericVendorExtension> testExtension(new GenericVendorExtension(extensionNode));\n    return testExtension;\n}\n\n\nQTEST_APPLESS_MAIN(tst_CatalogWriter)\n\n#include \"tst_CatalogWriter.moc\"\n"
  },
  {
    "path": "tests/IPXACTmodels/Catalog/tst_CatalogWriter.pri",
    "content": "# ----------------------------------------------------\n# This file is generated by the Qt Visual Studio Add-in.\n# ------------------------------------------------------\n\nSOURCES += ./tst_CatalogWriter.cpp \n  "
  },
  {
    "path": "tests/IPXACTmodels/Catalog/tst_CatalogWriter.pro",
    "content": "#-----------------------------------------------------------------------------\n# File: tst_CatalogWriter.pro\n#-----------------------------------------------------------------------------\n# Project: Kactus 2\n# Author: Esko Pekkarinen\n# Date: 31.01.2017\n#\n# Description:\n# Qt project file for running unit tests for Catalog Writer.\n#-----------------------------------------------------------------------------\n\nTEMPLATE = app\n\nTARGET = tst_CatalogWriter\n\nQT += core xml testlib\nQT -= gui\n\nCONFIG += c++11 testcase console\n\nlinux-g++ | linux-g++-64 | linux-g++-32 {\n LIBS += -L../../../executable \\\n     -lIPXACTmodels\n\n}\nwin64 | win32 {\n LIBS += -L../../../executable \\\n     -lIPXACTmodelsd\n}\n\nDESTDIR = ./release\n\nINCLUDEPATH += $$DESTDIR\nINCLUDEPATH += ../../../\n\nDEPENDPATH += .\n\nOBJECTS_DIR += $$DESTDIR\n\nMOC_DIR += ./generatedFiles\nUI_DIR += ./generatedFiles\nRCC_DIR += ./generatedFiles\ninclude(tst_CatalogWriter.pri)\n"
  },
  {
    "path": "tests/IPXACTmodels/Component/Component.pro",
    "content": "#-----------------------------------------------------------------------------\r\n# File: ComponentModel.pro\r\n#-----------------------------------------------------------------------------\r\n# Project: Kactus 2\r\n# Author: Mikko Teuho\r\n# Date: 16.09.2015\r\n#\r\n# Description:\r\n# Qt project file template for running unit tests in Component Model.\r\n#-----------------------------------------------------------------------------\r\n\r\nTEMPLATE = subdirs\r\n\r\nCONFIG += testcase\r\nSUBDIRS += tst_AddressSpaceReader.pro \\\r\n\t\t   tst_AddressSpaceWriter.pro \\\r\n\t\t   tst_AddressSpaceValidator.pro \\\r\n\t\t   tst_BusInterfacePortMapValidator.pro \\\r\n\t\t   tst_BusInterfaceReader.pro \\\r\n\t\t   tst_BusInterfaceWriter.pro \\\r\n\t\t   tst_BusInterfaceValidator.pro \\\r\n\t\t   tst_ChannelReader.pro \\\r\n\t\t   tst_ChannelWriter.pro \\\r\n\t\t   tst_ChannelValidator.pro \\\r\n\t\t   tst_ChoiceReader.pro \\\r\n\t\t   tst_ChoiceWriter.pro \\\r\n\t\t   tst_ChoiceValidator.pro \\\r\n\t\t   tst_ComponentGeneratorReader.pro \\\r\n\t\t   tst_ComponentGeneratorWriter.pro \\\r\n\t\t   tst_ComponentGeneratorValidator.pro \\\r\n\t\t   tst_ComponentPortWriter.pro \\\r\n\t\t   tst_ComponentPortReader.pro \\\r\n\t\t   tst_ComponentPortValidator.pro \\\r\n\t\t   tst_CPUReader.pro \\\r\n\t\t   tst_CPUWriter.pro \\\r\n\t\t   tst_CPUValidator.pro \\\r\n\t\t   tst_FileWriter.pro \\\r\n\t\t   tst_FileReader.pro \\\r\n\t\t   tst_FileValidator.pro \\\r\n\t\t   tst_FileSetWriter.pro \\\r\n\t\t   tst_FileSetReader.pro \\\r\n\t\t   tst_FileSetValidator.pro \\\r\n\t\t   tst_IndirectInterfaceReader.pro \\\r\n\t\t   tst_IndirectInterfaceWriter.pro \\\r\n\t\t   tst_IndirectInterfaceValidator.pro \\\r\n\t\t   tst_InstantiationsWriter.pro \\\r\n\t\t   tst_InstantiationsReader.pro \\\r\n\t\t   tst_InstantiationsValidator.pro \\\r\n\t\t   tst_OtherClockDriverReader.pro \\\r\n\t\t   tst_OtherClockDriverWriter.pro \\\r\n\t\t   tst_OtherClockDriverValidator.pro \\\t\t   \r\n\t\t   tst_ParameterReader.pro \\\r\n\t\t   tst_ParameterWriter.pro \\\r\n\t\t   tst_ParameterValidator.pro \\\r\n\t\t   tst_RemapStateWriter.pro \\\r\n\t\t   tst_RemapStateReader.pro \\\r\n\t\t   tst_RemapStateValidator.pro \\\r\n\t\t   tst_ViewWriter.pro \\\r\n\t\t   tst_ViewReader.pro \\\r\n\t\t   tst_ViewValidator.pro \\\r\n\t\t   tst_EnumeratedValueWriter.pro \\\r\n\t\t   tst_EnumeratedValueReader.pro \\\r\n\t\t   tst_EnumeratedValueValidator.pro \\\r\n\t\t   tst_FieldWriter.pro \\\r\n\t\t   tst_FieldReader.pro \\\r\n\t\t   tst_FieldValidator.pro \\\r\n\t\t   tst_RegisterWriter.pro \\\r\n\t\t   tst_RegisterReader.pro \\\t\t\r\n\t\t   tst_RegisterValidator.pro  \\\t\t   \t\t  \r\n\t\t   tst_AddressBlockWriter.pro \\\r\n\t\t   tst_AddressBlockReader.pro \\\r\n\t\t   tst_AddressBlockValidator.pro \\\r\n\t\t   tst_MemoryArrayReader.pro \\\r\n\t\t   tst_MemoryArrayValidator.pro \\\r\n\t\t   tst_MemoryArrayWriter.pro \\\r\n\t\t   tst_MemoryMapBaseReader.pro \\\r\n\t\t   tst_MemoryMapBaseWriter.pro \\\r\n\t\t   tst_MemoryMapBaseValidator.pro \\\r\n\t\t   tst_MemoryMapWriter.pro \\\r\n\t\t   tst_MemoryMapReader.pro \\\r\n\t\t   tst_MemoryMapValidator.pro \\  \r\n\t\t   tst_ModeReader.pro \\  \r\n\t\t   tst_ModeWriter.pro \\  \r\n\t\t   tst_ModeValidator.pro \\\r\n\t\t   tst_PowerDomainWriter.pro \\\r\n\t\t   tst_PowerDomainReader.pro \\\r\n\t\t   tst_PowerDomainValidator.pro \\  \r\n\t\t   tst_ComponentWriter.pro \\\r\n\t\t   tst_ComponentReader.pro \\\r\n\t\t   tst_ComponentValidator.pro \\\r\n\t\t   tst_FieldAccessPolicyWriter.pro \\\r\n\t\t   tst_FieldAccessPolicyReader.pro \\\r\n\t\t   tst_FieldAccessPolicyValidator.pro \\\r\n\t\t   tst_FieldReferenceWriter.pro \\\r\n\t\t   tst_FieldReferenceReader.pro \\\r\n\t\t   tst_FieldReferenceValidator.pro\r\n\t\t   \r\n"
  },
  {
    "path": "tests/IPXACTmodels/Component/tst_AccessPolicyReader.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: tst_FieldReader.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Anton Hagqvist\n// Date: 8.8.2023\n//\n// Description:\n// Unit test for class AccessPolicyReader.\n//-----------------------------------------------------------------------------\n\n#include <IPXACTmodels/Component/AccessPolicyReader.h>\n\n#include <IPXACTmodels/Component/AccessPolicy.h>\n\n#include <IPXACTmodels/common/VendorExtension.h>\n\n#include <QtTest>\n\nclass tst_AccessPolicyReader : public QObject\n{\n    Q_OBJECT\n\npublic:\n    tst_AccessPolicyReader();\n\nprivate slots:\n\n    void readModeRefs();\n    void readAccess();\n    void readVendorExtensions();\n};\n\n//-----------------------------------------------------------------------------\n// Function: tst_AccessPolicyReader::tst_AccessPolicyReader()\n//-----------------------------------------------------------------------------\ntst_AccessPolicyReader::tst_AccessPolicyReader()\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_AccessPolicyReader::readModeRefs()\n//-----------------------------------------------------------------------------\nvoid tst_AccessPolicyReader::readModeRefs()\n{\n    QString doc(\n        \"<ipxact:accessPolicy>\"\n            \"<ipxact:modeRef priority=\\\"0\\\">normal</ipxact:modeRef>\"\n        \"</ipxact:accessPolicy>\"\n    );\n\n    QDomDocument document;\n    document.setContent(doc);\n\n    auto accessPolicy = AccessPolicyReader::createAccessPolicyFrom(document.firstChildElement(\"ipxact:accessPolicy\"));\n\n    QCOMPARE(accessPolicy->getModeReferences()->size(), 1);\n    QCOMPARE(accessPolicy->getModeReferences()->first()->getReference(), QString(\"normal\"));\n\n     doc =\n        \"<ipxact:accessPolicy>\"\n            \"<ipxact:modeRef priority=\\\"0\\\">normal</ipxact:modeRef>\"\n            \"<ipxact:modeRef priority=\\\"1\\\">test</ipxact:modeRef>\"\n        \"</ipxact:accessPolicy>\"\n        ;\n\n    document.setContent(doc);\n\n    accessPolicy = AccessPolicyReader::createAccessPolicyFrom(document.firstChildElement(\"ipxact:accessPolicy\"));\n\n    QCOMPARE(accessPolicy->getModeReferences()->size(), 2);\n    QCOMPARE(accessPolicy->getModeReferences()->first()->getReference(), QString(\"normal\"));\n    QCOMPARE(accessPolicy->getModeReferences()->first()->getPriority(), 0);\n    QCOMPARE(accessPolicy->getModeReferences()->at(1)->getReference(), QString(\"test\"));\n    QCOMPARE(accessPolicy->getModeReferences()->at(1)->getPriority(), 1);\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_AccessPolicyReader::readAccess()\n//-----------------------------------------------------------------------------\nvoid tst_AccessPolicyReader::readAccess()\n{\n    QString documentContent(\n        \"<ipxact:accessPolicy>\"\n            \"<ipxact:access>read-write</ipxact:access>\"\n        \"</ipxact:accessPolicy>\"\n        );\n\n    QDomDocument document;\n    document.setContent(documentContent);\n\n    auto accessPolicy = AccessPolicyReader::createAccessPolicyFrom(document.firstChildElement(\"ipxact:accessPolicy\"));\n\n    QCOMPARE(accessPolicy->getAccess(), AccessTypes::Access::READ_WRITE);\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_AccessPolicyReader::readVendorExtensions()\n//-----------------------------------------------------------------------------\nvoid tst_AccessPolicyReader::readVendorExtensions()\n{\n    QString documentContent(\n        \"<ipxact:accessPolicy>\"\n            \"<ipxact:vendorExtensions>\"\n                \"<testExtension testExtensionAttribute=\\\"extension\\\">testValue</testExtension>\"\n            \"</ipxact:vendorExtensions>\"\n        \"</ipxact:accessPolicy>\"\n        );\n\n    QDomDocument document;\n    document.setContent(documentContent);\n\n    QDomNode fieldNode = document.firstChildElement(\"ipxact:field\");\n\n    auto accessPolicy = AccessPolicyReader::createAccessPolicyFrom(document.firstChildElement(\"ipxact:accessPolicy\"));\n\n    QCOMPARE(accessPolicy->getVendorExtensions()->size(), 1);\n    QCOMPARE(accessPolicy->getVendorExtensions()->first()->type(), QString(\"testExtension\"));\n}\n\nQTEST_APPLESS_MAIN(tst_AccessPolicyReader)\n\n#include \"tst_AccessPolicyReader.moc\"\n"
  },
  {
    "path": "tests/IPXACTmodels/Component/tst_AccessPolicyReader.pri",
    "content": "# ----------------------------------------------------\n# This file is generated by the Qt Visual Studio Tools.\n# ------------------------------------------------------\n\nSOURCES += ./tst_AccessPolicyReader.cpp\n"
  },
  {
    "path": "tests/IPXACTmodels/Component/tst_AccessPolicyReader.pro",
    "content": "#-----------------------------------------------------------------------------\n# File: tst_AccessPolicyReader.pro\n#-----------------------------------------------------------------------------\n# Project: Kactus 2\n# Author: Anton Hagqvist\n# Date: 31.7.2023\n#\n# Description:\n# Qt project file template for running unit tests for FieldAccessPolicyReader.\n#-----------------------------------------------------------------------------\n\nTEMPLATE = app\n\nTARGET = tst_AccessPolicyReader\n\nQT += core xml testlib\nQT -= gui\n\nCONFIG += c++11 testcase console\n\nlinux-g++ | linux-g++-64 | linux-g++-32 {\n LIBS += -L../../../executable \\\n     -lIPXACTmodels\n\n}\nwin64 | win32 {\n LIBS += -L../../../executable \\\n     -lIPXACTmodelsd\n}\n\nINCLUDEPATH += $$DESTDIR\nINCLUDEPATH += ../../../\n\nDEPENDPATH += .\nDEPENDPATH += ../../../\n\nOBJECTS_DIR += $$DESTDIR\n\nMOC_DIR += ./generatedFiles\nUI_DIR += ./generatedFiles\nRCC_DIR += ./generatedFiles\ninclude(tst_AccessPolicyReader.pri)\n"
  },
  {
    "path": "tests/IPXACTmodels/Component/tst_AccessPolicyWriter.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: tst_AccessPolicyWriter.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Anton Hagqvist\n// Date: 8.8.2023\n//\n// Description:\n// Unit test for class AccessPolicyWriter>.    \n//-----------------------------------------------------------------------------\n\n#include <IPXACTmodels/Component/AccessPolicyWriter.h>\n#include <IPXACTmodels/Component/AccessPolicy.h>\n#include <IPXACTmodels/common/GenericVendorExtension.h>\n\n#include <QtTest>\n#include <QDomDocument>\n\nclass tst_AccessPolicyWriter : public QObject\n{\n    Q_OBJECT\n\npublic:\n    tst_AccessPolicyWriter();\n\nprivate slots:\n\n    void init();\n    void cleanup();\n\n    void writeModeRefs();\n    void writeAccess();\n    void writeVendorExtensions();\n\nprivate:\n    QSharedPointer<AccessPolicy> accessPolicy_;\n\n};\n\n//-----------------------------------------------------------------------------\n// Function: tst_AccessPolicyWriter::tst_AccessPolicyWriter()\n//-----------------------------------------------------------------------------\ntst_AccessPolicyWriter::tst_AccessPolicyWriter()\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_AccessPolicyWriter::init()\n//-----------------------------------------------------------------------------\nvoid tst_AccessPolicyWriter::init()\n{\n    accessPolicy_ = QSharedPointer<AccessPolicy>(new AccessPolicy());\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_AccessPolicyWriter::cleanup()\n//-----------------------------------------------------------------------------\nvoid tst_AccessPolicyWriter::cleanup()\n{\n    accessPolicy_.clear();\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_AccessPolicyWriter::writeModeRefs()\n//-----------------------------------------------------------------------------\nvoid tst_AccessPolicyWriter::writeModeRefs()\n{\n    QSharedPointer<ModeReference> modeRef1(new ModeReference());\n    modeRef1->setPriority(0);\n    modeRef1->setReference(\"testMode1\");\n\n    QSharedPointer<ModeReference> modeRef2(new ModeReference());\n    modeRef2->setPriority(1);\n    modeRef2->setReference(\"testMode2\");\n\n    accessPolicy_->getModeReferences()->append(modeRef1);\n    accessPolicy_->getModeReferences()->append(modeRef2);\n\n    QString expectedOutput(\n        \"<ipxact:accessPolicy>\"\n            \"<ipxact:modeRef priority=\\\"0\\\">testMode1</ipxact:modeRef>\"\n            \"<ipxact:modeRef priority=\\\"1\\\">testMode2</ipxact:modeRef>\"\n        \"</ipxact:accessPolicy>\"\n    );\n    \n    QString output;\n    QXmlStreamWriter writer(&output);\n\n    AccessPolicyWriter::writeAccessPolicy(writer, accessPolicy_);\n    QCOMPARE(output, expectedOutput);\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_AccessPolicyWriter::writeAccess()\n//-----------------------------------------------------------------------------\nvoid tst_AccessPolicyWriter::writeAccess()\n{\n    accessPolicy_->setAccess(AccessTypes::READ_WRITE);\n\n    QString expectedOutput(\n        \"<ipxact:accessPolicy>\"\n            \"<ipxact:access>read-write</ipxact:access>\"\n        \"</ipxact:accessPolicy>\"\n    );\n\n    QString output;\n    QXmlStreamWriter writer(&output);\n\n    AccessPolicyWriter::writeAccessPolicy(writer, accessPolicy_);\n    QCOMPARE(output, expectedOutput);\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_AccessPolicyWriter::writeVendorExtensions()\n//-----------------------------------------------------------------------------\nvoid tst_AccessPolicyWriter::writeVendorExtensions()\n{\n    QString output;\n    QXmlStreamWriter writer(&output);\n\n    QDomDocument document;\n    QDomElement extensionNode = document.createElement(\"testExtension\");\n    extensionNode.setAttribute(\"testExtensionAttribute\", \"extension\");\n    extensionNode.appendChild(document.createTextNode(\"testValue\"));\n\n    QSharedPointer<GenericVendorExtension> testExtension(new GenericVendorExtension(extensionNode));\n\n    accessPolicy_->getVendorExtensions()->append(testExtension);\n\n    QString expectedOutput(\n        \"<ipxact:accessPolicy>\"\n            \"<ipxact:vendorExtensions>\"\n                \"<testExtension testExtensionAttribute=\\\"extension\\\">testValue</testExtension>\"\n            \"</ipxact:vendorExtensions>\"\n        \"</ipxact:accessPolicy>\"\n        );\n\n    AccessPolicyWriter::writeAccessPolicy(writer, accessPolicy_);\n    QCOMPARE(output, expectedOutput);\n}\n\nQTEST_APPLESS_MAIN(tst_AccessPolicyWriter)\n\n#include \"tst_AccessPolicyWriter.moc\"\n"
  },
  {
    "path": "tests/IPXACTmodels/Component/tst_AccessPolicyWriter.pri",
    "content": "# ----------------------------------------------------\n# This file is generated by the Qt Visual Studio Tools.\n# ------------------------------------------------------\n\nSOURCES += ./tst_AccessPolicyWriter.cpp\n"
  },
  {
    "path": "tests/IPXACTmodels/Component/tst_AccessPolicyWriter.pro",
    "content": "#-----------------------------------------------------------------------------\n# File: tst_AccessPolicyWriter.pro\n#-----------------------------------------------------------------------------\n# Project: Kactus 2\n# Author: Anton Hagqvist\n# Date: 8.8.2023\n#\n# Description:\n# Qt project file template for running unit tests for AccessPolicyWriter.\n#-----------------------------------------------------------------------------\n\nTEMPLATE = app\n\nTARGET = tst_AccessPolicyWriter\n\nQT += core xml testlib\nQT -= gui\n\nCONFIG += c++11 testcase console\n\nlinux-g++ | linux-g++-64 | linux-g++-32 {\n LIBS += -L../../../executable \\\n     -lIPXACTmodels\n\n}\nwin64 | win32 {\n LIBS += -L../../../executable \\\n     -lIPXACTmodelsd\n}\n\nINCLUDEPATH += $$DESTDIR\nINCLUDEPATH += ../../../\n\nDEPENDPATH += .\nDEPENDPATH += ../../../\n\nOBJECTS_DIR += $$DESTDIR\n\nMOC_DIR += ./generatedFiles\nUI_DIR += ./generatedFiles\nRCC_DIR += ./generatedFiles\ninclude(tst_AccessPolicyWriter.pri)\n"
  },
  {
    "path": "tests/IPXACTmodels/Component/tst_AddressBlockReader.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: tst_AddressBlockReader.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 30.09.2015\r\n//\r\n// Description:\r\n// Unit test for class AddressBlockReader.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include <IPXACTmodels/Component/AddressBlockReader.h>\r\n#include <IPXACTmodels/Component/AddressBlock.h>\r\n#include <IPXACTmodels/Component/Register.h>\r\n#include <IPXACTmodels/Component/RegisterFile.h>\r\n#include <IPXACTmodels/Component/Field.h>\r\n#include <IPXACTmodels/Component/MemoryArray.h>\r\n\r\n#include <IPXACTmodels/common/VendorExtension.h>\r\n\r\n#include <QtTest>\r\n\r\nclass tst_AddressBlockReader : public QObject\r\n{\r\n    Q_OBJECT\r\n\r\npublic:\r\n\r\n    tst_AddressBlockReader();\r\n\r\nprivate slots:\r\n\r\n    void readSimpleAddressBlock();\r\n    void readIsPresent();\r\n    void readTypeIdentifier();\r\n\r\n    void readUsage();\r\n    void readVolatile();\r\n    void readAccess();\r\n    void readParameters();\r\n\r\n    void readRegisterData();\r\n\r\n    void readMisalignmentAllowed2022();\r\n    void readMemoryArray2022();\r\n    void readAddressBlockDefinitionRef2022();\r\n    void readAccessPolicies2022();\r\n\r\n    void readVendorExtensions();\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_AddressBlockReader::tst_AddressBlockReader()\r\n//-----------------------------------------------------------------------------\r\ntst_AddressBlockReader::tst_AddressBlockReader()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_AddressBlockReader::readSimpleAddressBlock()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_AddressBlockReader::readSimpleAddressBlock()\r\n{\r\n    QString documentContent(\r\n        \"<ipxact:addressBlock>\"\r\n            \"<ipxact:name>testBlock</ipxact:name>\"\r\n            \"<ipxact:displayName>displayed</ipxact:displayName>\"\r\n            \"<ipxact:description>described</ipxact:description>\"\r\n            \"<ipxact:baseAddress>StarControl</ipxact:baseAddress>\"\r\n            \"<ipxact:range>Kzer-Za</ipxact:range>\"\r\n            \"<ipxact:width>Kohr-Ah</ipxact:width>\"\r\n        \"</ipxact:addressBlock>\"\r\n        );\r\n\r\n    QDomDocument document;\r\n    document.setContent(documentContent);\r\n\r\n    QDomNode addressBlockNode = document.firstChildElement(\"ipxact:addressBlock\");\r\n\r\n    QSharedPointer<AddressBlock> testAddressBlock = AddressBlockReader::createAddressBlockFrom(addressBlockNode, Document::Revision::Std14);\r\n\r\n    QCOMPARE(testAddressBlock->name(), QString(\"testBlock\"));\r\n    QCOMPARE(testAddressBlock->displayName(), QString(\"displayed\"));\r\n    QCOMPARE(testAddressBlock->description(), QString(\"described\"));\r\n    QCOMPARE(testAddressBlock->getBaseAddress(), QString(\"StarControl\"));\r\n    QCOMPARE(testAddressBlock->getRange(), QString(\"Kzer-Za\"));\r\n    QCOMPARE(testAddressBlock->getWidth(), QString(\"Kohr-Ah\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_AddressBlockReader::readIsPresent()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_AddressBlockReader::readIsPresent()\r\n{\r\n    QString documentContent(\r\n        \"<ipxact:addressBlock>\"\r\n            \"<ipxact:name>testBlock</ipxact:name>\"\r\n            \"<ipxact:isPresent>presence</ipxact:isPresent>\"\r\n            \"<ipxact:baseAddress>StarControl</ipxact:baseAddress>\"\r\n            \"<ipxact:range>Kzer-Za</ipxact:range>\"\r\n            \"<ipxact:width>Kohr-Ah</ipxact:width>\"\r\n        \"</ipxact:addressBlock>\"\r\n        );\r\n\r\n    QDomDocument document;\r\n    document.setContent(documentContent);\r\n\r\n    QDomNode addressBlockNode = document.firstChildElement(\"ipxact:addressBlock\");\r\n\r\n    QSharedPointer<AddressBlock> testAddressBlock = AddressBlockReader::createAddressBlockFrom(addressBlockNode, Document::Revision::Std14);\r\n\r\n    QCOMPARE(testAddressBlock->name(), QString(\"testBlock\"));\r\n    QCOMPARE(testAddressBlock->getIsPresent(), QString(\"presence\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_AddressBlockReader::readTypeIdentifier()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_AddressBlockReader::readTypeIdentifier()\r\n{\r\n    QString documentContent(\r\n        \"<ipxact:addressBlock>\"\r\n            \"<ipxact:name>testBlock</ipxact:name>\"\r\n            \"<ipxact:baseAddress>StarControl</ipxact:baseAddress>\"\r\n            \"<ipxact:typeIdentifier>identifier</ipxact:typeIdentifier>\"\r\n            \"<ipxact:range>Kzer-Za</ipxact:range>\"\r\n            \"<ipxact:width>Kohr-Ah</ipxact:width>\"\r\n        \"</ipxact:addressBlock>\"\r\n        );\r\n\r\n    QDomDocument document;\r\n    document.setContent(documentContent);\r\n\r\n    QDomNode addressBlockNode = document.firstChildElement(\"ipxact:addressBlock\");\r\n\r\n    QSharedPointer<AddressBlock> testAddressBlock = AddressBlockReader::createAddressBlockFrom(addressBlockNode, Document::Revision::Std14);\r\n\r\n    QCOMPARE(testAddressBlock->name(), QString(\"testBlock\"));\r\n    QCOMPARE(testAddressBlock->getTypeIdentifier(), QString(\"identifier\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_AddressBlockReader::readUsage()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_AddressBlockReader::readUsage()\r\n{\r\n    QString documentContent(\r\n        \"<ipxact:addressBlock>\"\r\n            \"<ipxact:name>testBlock</ipxact:name>\"\r\n            \"<ipxact:baseAddress>StarControl</ipxact:baseAddress>\"\r\n            \"<ipxact:range>Kzer-Za</ipxact:range>\"\r\n            \"<ipxact:width>Kohr-Ah</ipxact:width>\"\r\n            \"<ipxact:usage>register</ipxact:usage>\"\r\n        \"</ipxact:addressBlock>\"\r\n        );\r\n\r\n    QDomDocument document;\r\n    document.setContent(documentContent);\r\n\r\n    QDomNode addressBlockNode = document.firstChildElement(\"ipxact:addressBlock\");\r\n\r\n    QSharedPointer<AddressBlock> testAddressBlock = AddressBlockReader::createAddressBlockFrom(addressBlockNode, Document::Revision::Std14);\r\n\r\n    QCOMPARE(testAddressBlock->name(), QString(\"testBlock\"));\r\n    QCOMPARE(testAddressBlock->getUsage(), General::REGISTER);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_AddressBlockReader::readVolatile()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_AddressBlockReader::readVolatile()\r\n{\r\n    QString documentContent(\r\n        \"<ipxact:addressBlock>\"\r\n            \"<ipxact:name>testBlock</ipxact:name>\"\r\n            \"<ipxact:baseAddress>StarControl</ipxact:baseAddress>\"\r\n            \"<ipxact:range>Kzer-Za</ipxact:range>\"\r\n            \"<ipxact:width>Kohr-Ah</ipxact:width>\"\r\n            \"<ipxact:volatile>true</ipxact:volatile>\"\r\n        \"</ipxact:addressBlock>\"\r\n        );\r\n\r\n    QDomDocument document;\r\n    document.setContent(documentContent);\r\n\r\n    QDomNode addressBlockNode = document.firstChildElement(\"ipxact:addressBlock\");\r\n\r\n    QSharedPointer<AddressBlock> testAddressBlock = AddressBlockReader::createAddressBlockFrom(addressBlockNode, Document::Revision::Std14);\r\n\r\n    QCOMPARE(testAddressBlock->name(), QString(\"testBlock\"));\r\n    QCOMPARE(testAddressBlock->getVolatile(), QString(\"true\"));\r\n\r\n    documentContent = \r\n        \"<ipxact:addressBlock>\"\r\n            \"<ipxact:name>testBlock</ipxact:name>\"\r\n            \"<ipxact:baseAddress>StarControl</ipxact:baseAddress>\"\r\n            \"<ipxact:range>Kzer-Za</ipxact:range>\"\r\n            \"<ipxact:width>Kohr-Ah</ipxact:width>\"\r\n            \"<ipxact:volatile>false</ipxact:volatile>\"\r\n        \"</ipxact:addressBlock>\"\r\n        ;\r\n\r\n    document.setContent(documentContent);\r\n    addressBlockNode = document.firstChildElement(\"ipxact:addressBlock\");\r\n    testAddressBlock = AddressBlockReader::createAddressBlockFrom(addressBlockNode, Document::Revision::Std14);\r\n\r\n    QCOMPARE(testAddressBlock->name(), QString(\"testBlock\"));\r\n    QCOMPARE(testAddressBlock->getVolatile(), QString(\"false\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_AddressBlockReader::readAccess()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_AddressBlockReader::readAccess()\r\n{\r\n    QString documentContent(\r\n        \"<ipxact:addressBlock>\"\r\n            \"<ipxact:name>testBlock</ipxact:name>\"\r\n            \"<ipxact:baseAddress>StarControl</ipxact:baseAddress>\"\r\n            \"<ipxact:range>Kzer-Za</ipxact:range>\"\r\n            \"<ipxact:width>Kohr-Ah</ipxact:width>\"\r\n            \"<ipxact:access>writeOnce</ipxact:access>\"\r\n        \"</ipxact:addressBlock>\"\r\n        );\r\n\r\n    QDomDocument document;\r\n    document.setContent(documentContent);\r\n\r\n    QDomNode addressBlockNode = document.firstChildElement(\"ipxact:addressBlock\");\r\n\r\n    QSharedPointer<AddressBlock> testAddressBlock = AddressBlockReader::createAddressBlockFrom(addressBlockNode, Document::Revision::Std14);\r\n\r\n    QCOMPARE(testAddressBlock->name(), QString(\"testBlock\"));\r\n    QCOMPARE(testAddressBlock->getAccess(), AccessTypes::WRITEONCE);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_AddressBlockReader::readParameters()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_AddressBlockReader::readParameters()\r\n{\r\n    QString documentContent(\r\n        \"<ipxact:addressBlock>\"\r\n            \"<ipxact:name>testBlock</ipxact:name>\"\r\n            \"<ipxact:baseAddress>StarControl</ipxact:baseAddress>\"\r\n            \"<ipxact:range>Kzer-Za</ipxact:range>\"\r\n            \"<ipxact:width>Kohr-Ah</ipxact:width>\"\r\n            \"<ipxact:parameters>\"\r\n                \"<ipxact:parameter parameterId=\\\"testID\\\">\"\r\n                    \"<ipxact:name>testParameter</ipxact:name>\"\r\n                    \"<ipxact:value>1</ipxact:value>\"\r\n                \"</ipxact:parameter>\"\r\n            \"</ipxact:parameters>\"\r\n        \"</ipxact:addressBlock>\"\r\n        );\r\n\r\n    QDomDocument document;\r\n    document.setContent(documentContent);\r\n\r\n    QDomNode addressBlockNode = document.firstChildElement(\"ipxact:addressBlock\");\r\n\r\n    QSharedPointer<AddressBlock> testAddressBlock = AddressBlockReader::createAddressBlockFrom(addressBlockNode, Document::Revision::Std14);\r\n\r\n    QCOMPARE(testAddressBlock->name(), QString(\"testBlock\"));\r\n\r\n    QCOMPARE(testAddressBlock->getParameters()->size(), 1);\r\n\r\n    QSharedPointer<Parameter> testParameter = testAddressBlock->getParameters()->first();\r\n    QCOMPARE(testParameter->name(), QString(\"testParameter\"));\r\n    QCOMPARE(testParameter->getValueId(), QString(\"testID\"));\r\n    QCOMPARE(testParameter->getValue(), QString(\"1\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_AddressBlockReader::readRegisterData()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_AddressBlockReader::readRegisterData()\r\n{\r\n    QString documentContent(\r\n        \"<ipxact:addressBlock>\"\r\n            \"<ipxact:name>testBlock</ipxact:name>\"\r\n            \"<ipxact:baseAddress>StarControl</ipxact:baseAddress>\"\r\n            \"<ipxact:range>Kzer-Za</ipxact:range>\"\r\n            \"<ipxact:width>Kohr-Ah</ipxact:width>\"\r\n            \"<ipxact:register>\"\r\n                \"<ipxact:name>testRegister</ipxact:name>\"\r\n                \"<ipxact:displayName>displayed</ipxact:displayName>\"\r\n                \"<ipxact:description>described</ipxact:description>\"\r\n                \"<ipxact:addressOffset>offset</ipxact:addressOffset>\"\r\n                \"<ipxact:size>10</ipxact:size>\"\r\n                \"<ipxact:field>\"\r\n                    \"<ipxact:name>simpleField</ipxact:name>\"\r\n                    \"<ipxact:bitOffset>fieldOffset</ipxact:bitOffset>\"\r\n                    \"<ipxact:bitWidth>fieldWidth</ipxact:bitWidth>\"\r\n                \"</ipxact:field>\"\r\n            \"</ipxact:register>\"\r\n            \"<ipxact:registerFile>\"\r\n                \"<ipxact:name>contained</ipxact:name>\"\r\n                \"<ipxact:addressOffset>containedOffset</ipxact:addressOffset>\"\r\n                \"<ipxact:range>containedRange</ipxact:range>\"\r\n            \"</ipxact:registerFile>\"\r\n        \"</ipxact:addressBlock>\"\r\n        );\r\n\r\n    QDomDocument document;\r\n    document.setContent(documentContent);\r\n\r\n    QDomNode addressBlockNode = document.firstChildElement(\"ipxact:addressBlock\");\r\n\r\n    QSharedPointer<AddressBlock> testAddressBlock = AddressBlockReader::createAddressBlockFrom(addressBlockNode, Document::Revision::Std14);\r\n\r\n    QCOMPARE(testAddressBlock->name(), QString(\"testBlock\"));\r\n\r\n    QCOMPARE(testAddressBlock->getRegisterData()->size(), 2);\r\n\r\n    QSharedPointer<Register> containedRegister =\r\n        testAddressBlock->getRegisterData()->first().dynamicCast<Register>();\r\n    QCOMPARE(containedRegister.isNull(), false);\r\n    QCOMPARE(containedRegister->name(), QString(\"testRegister\"));\r\n    QCOMPARE(containedRegister->displayName(), QString(\"displayed\"));\r\n    QCOMPARE(containedRegister->description(), QString(\"described\"));\r\n    QCOMPARE(containedRegister->getSize(), QString(\"10\"));\r\n\r\n    QCOMPARE(containedRegister->getFields()->size(), 1);\r\n    QCOMPARE(containedRegister->getFields()->first()->name(), QString(\"simpleField\"));\r\n    QCOMPARE(containedRegister->getFields()->first()->getBitOffset(), QString(\"fieldOffset\"));\r\n    QCOMPARE(containedRegister->getFields()->first()->getBitWidth(), QString(\"fieldWidth\"));\r\n\r\n    QSharedPointer<RegisterFile> containedFile =\r\n        testAddressBlock->getRegisterData()->last().dynamicCast<RegisterFile>();\r\n    QCOMPARE(containedFile.isNull(), false);\r\n    QCOMPARE(containedFile->name(), QString(\"contained\"));\r\n    QCOMPARE(containedFile->getAddressOffset(), QString(\"containedOffset\"));\r\n    QCOMPARE(containedFile->getRange(), QString(\"containedRange\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_AddressBlockReader::readMisallignmentAllowed2022()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_AddressBlockReader::readMisalignmentAllowed2022()\r\n{\r\n    QString documentContent(\r\n        \"<ipxact:addressBlock misalignmentAllowed=\\\"false\\\">\"\r\n            \"<ipxact:name>testBlock</ipxact:name>\"\r\n            \"<ipxact:baseAddress>StarControl</ipxact:baseAddress>\"\r\n            \"<ipxact:range>Kzer-Za</ipxact:range>\"\r\n            \"<ipxact:width>Kohr-Ah</ipxact:width>\"\r\n        \"</ipxact:addressBlock>\"\r\n        );\r\n\r\n    QDomDocument document;\r\n    document.setContent(documentContent);\r\n    QDomNode addressBlockNode = document.firstChildElement(\"ipxact:addressBlock\");\r\n\r\n    QSharedPointer<AddressBlock> testAddressBlock = AddressBlockReader::createAddressBlockFrom(addressBlockNode, Document::Revision::Std22);\r\n\r\n    QCOMPARE(testAddressBlock->name(), QString(\"testBlock\"));\r\n    QCOMPARE(testAddressBlock->getMisalignmentAllowed(), QString(\"false\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_AddressBlockReader::readMemoryArray2022()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_AddressBlockReader::readMemoryArray2022()\r\n{\r\n    QString documentContent(\r\n        \"<ipxact:addressBlock>\"\r\n            \"<ipxact:name>testBlock</ipxact:name>\"\r\n            \"<ipxact:array>\"\r\n                \"<ipxact:dim indexVar=\\\"testDim\\\">1+1</ipxact:dim>\"\r\n                \"<ipxact:dim>4</ipxact:dim>\"\r\n                \"<ipxact:stride>4</ipxact:stride>\"\r\n            \"</ipxact:array>\"\r\n            \"<ipxact:baseAddress>StarControl</ipxact:baseAddress>\"\r\n            \"<ipxact:range>Kzer-Za</ipxact:range>\"\r\n            \"<ipxact:width>Kohr-Ah</ipxact:width>\"    \r\n        \"</ipxact:addressBlock>\"\r\n        );\r\n\r\n    QDomDocument document;\r\n    document.setContent(documentContent);\r\n    QDomNode addressBlockNode = document.firstChildElement(\"ipxact:addressBlock\");\r\n\r\n    QSharedPointer<AddressBlock> testAddressBlock = AddressBlockReader::createAddressBlockFrom(addressBlockNode, Document::Revision::Std22);\r\n\r\n    QCOMPARE(testAddressBlock->getMemoryArray()->getDimensions()->size(), 2);\r\n    \r\n    QCOMPARE(testAddressBlock->getMemoryArray()->getDimensions()->first()->indexVar_, QString(\"testDim\"));\r\n    QCOMPARE(testAddressBlock->getMemoryArray()->getDimensions()->first()->value_, QString(\"1+1\"));\r\n    \r\n    QCOMPARE(testAddressBlock->getMemoryArray()->getDimensions()->last()->indexVar_, QString(\"\"));\r\n    QCOMPARE(testAddressBlock->getMemoryArray()->getDimensions()->last()->value_, QString(\"4\"));\r\n\r\n    QCOMPARE(testAddressBlock->getMemoryArray()->getStride(), QString(\"4\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_AddressBlockReader::readAddressBlockDefinitionRef2022()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_AddressBlockReader::readAddressBlockDefinitionRef2022()\r\n{\r\n    QString documentContent(\r\n        \"<ipxact:addressBlock>\"\r\n            \"<ipxact:name>testBlock</ipxact:name>\"\r\n            \"<ipxact:baseAddress>StarControl</ipxact:baseAddress>\"\r\n            \"<ipxact:addressBlockDefinitionRef typeDefinitions=\\\"testDefinitions\\\">someBlock</ipxact:addressBlockDefinitionRef>\"\r\n        \"</ipxact:addressBlock>\"\r\n        );\r\n\r\n    QDomDocument document;\r\n    document.setContent(documentContent);\r\n    QDomNode addressBlockNode = document.firstChildElement(\"ipxact:addressBlock\");\r\n\r\n    QSharedPointer<AddressBlock> testAddressBlock = AddressBlockReader::createAddressBlockFrom(addressBlockNode, Document::Revision::Std22);\r\n\r\n    QCOMPARE(testAddressBlock->getAddressBlockDefinitionRef(), QString(\"someBlock\"));\r\n    QCOMPARE(testAddressBlock->getTypeDefinitionsRef(), QString(\"testDefinitions\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_AddressBlockReader::readAccessPolicies2022()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_AddressBlockReader::readAccessPolicies2022()\r\n{\r\n    QString documentContent(\r\n        \"<ipxact:addressBlock>\"\r\n            \"<ipxact:name>testBlock</ipxact:name>\"\r\n            \"<ipxact:baseAddress>StarControl</ipxact:baseAddress>\"\r\n            \"<ipxact:range>Kzer-Za</ipxact:range>\"\r\n            \"<ipxact:width>Kohr-Ah</ipxact:width>\"\r\n            \"<ipxact:accessPolicies>\"\r\n                \"<ipxact:accessPolicy>\"\r\n                    \"<ipxact:modeRef priority=\\\"1\\\">testMode</ipxact:modeRef>\"\r\n                    \"<ipxact:access>read-only</ipxact:access>\"\r\n                \"</ipxact:accessPolicy>\"\r\n                \"<ipxact:accessPolicy>\"\r\n                    \"<ipxact:modeRef priority=\\\"2\\\">testMode2</ipxact:modeRef>\"\r\n                \"</ipxact:accessPolicy>\"\r\n            \"</ipxact:accessPolicies>\"\r\n        \"</ipxact:addressBlock>\"\r\n        );\r\n\r\n    QDomDocument document;\r\n    document.setContent(documentContent);\r\n    QDomNode addressBlockNode = document.firstChildElement(\"ipxact:addressBlock\");\r\n\r\n    QSharedPointer<AddressBlock> testAddressBlock = AddressBlockReader::createAddressBlockFrom(addressBlockNode, Document::Revision::Std22);\r\n\r\n    QCOMPARE(testAddressBlock->getAccessPolicies()->size(), 2);\r\n    QCOMPARE(testAddressBlock->getAccessPolicies()->first()->getModeReferences()->first()->getReference(), QString(\"testMode\"));\r\n    QCOMPARE(testAddressBlock->getAccessPolicies()->first()->getAccess(), AccessTypes::READ_ONLY);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_AddressBlockReader::readVendorExtensions()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_AddressBlockReader::readVendorExtensions()\r\n{\r\n    QString documentContent(\r\n        \"<ipxact:addressBlock>\"\r\n            \"<ipxact:name>testBlock</ipxact:name>\"\r\n            \"<ipxact:baseAddress>StarControl</ipxact:baseAddress>\"\r\n            \"<ipxact:range>Kzer-Za</ipxact:range>\"\r\n            \"<ipxact:width>Kohr-Ah</ipxact:width>\"\r\n            \"<ipxact:vendorExtensions>\"\r\n                \"<testExtension testExtensionAttribute=\\\"extension\\\">testValue</testExtension>\"\r\n            \"</ipxact:vendorExtensions>\"\r\n        \"</ipxact:addressBlock>\"\r\n        );\r\n\r\n    QDomDocument document;\r\n    document.setContent(documentContent);\r\n\r\n    QDomNode addressBlockNode = document.firstChildElement(\"ipxact:addressBlock\");\r\n\r\n    QSharedPointer<AddressBlock> testAddressBlock = AddressBlockReader::createAddressBlockFrom(addressBlockNode, Document::Revision::Std14);\r\n\r\n    QCOMPARE(testAddressBlock->name(), QString(\"testBlock\"));\r\n\r\n    QCOMPARE(testAddressBlock->getVendorExtensions()->size(), 1);\r\n    QCOMPARE(testAddressBlock->getVendorExtensions()->first()->type(), QString(\"testExtension\"));\r\n}\r\n\r\nQTEST_APPLESS_MAIN(tst_AddressBlockReader)\r\n\r\n#include \"tst_AddressBlockReader.moc\"\r\n"
  },
  {
    "path": "tests/IPXACTmodels/Component/tst_AddressBlockReader.pri",
    "content": "# ----------------------------------------------------\r\n# This file is generated by the Qt Visual Studio Add-in.\r\n# ------------------------------------------------------\r\n\r\nSOURCES += ./tst_AddressBlockReader.cpp \r\n"
  },
  {
    "path": "tests/IPXACTmodels/Component/tst_AddressBlockReader.pro",
    "content": "#-----------------------------------------------------------------------------\r\n# File: tst_AddressBlockReader.pro\r\n#-----------------------------------------------------------------------------\r\n# Project: Kactus 2\r\n# Author: Mikko Teuho\r\n# Date: 30.09.2015\r\n#\r\n# Description:\r\n# Qt project file template for running unit tests for AddressBlockReader.\r\n#-----------------------------------------------------------------------------\r\n\r\nTEMPLATE = app\r\n\r\nTARGET = tst_AddressBlockReader\r\n\r\nQT += core xml testlib\r\nQT -= gui\r\n\r\nCONFIG += c++11 testcase console\r\n\r\nlinux-g++ | linux-g++-64 | linux-g++-32 {\r\n LIBS += -L../../../executable \\\r\n     -lIPXACTmodels\r\n\r\n}\r\nwin64 | win32 {\r\n LIBS += -L../../../executable \\\r\n     -lIPXACTmodelsd\r\n}\r\n\r\nINCLUDEPATH += $$DESTDIR\r\nINCLUDEPATH += ../../../\r\n\r\nDEPENDPATH += .\r\nDEPENDPATH += ../../../\r\n\r\nOBJECTS_DIR += $$DESTDIR\r\n\r\nMOC_DIR += ./generatedFiles\r\nUI_DIR += ./generatedFiles\r\nRCC_DIR += ./generatedFiles\r\ninclude(tst_AddressBlockReader.pri)\r\n"
  },
  {
    "path": "tests/IPXACTmodels/Component/tst_AddressBlockValidator.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: tst_AddressBlockValidator.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: <Name>\r\n// Date: <Date in the format dd.mm.yyyy>\r\n//\r\n// Description:\r\n// Unit test for class AddressBlockValidator.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include <KactusAPI/include/SystemVerilogExpressionParser.h>\r\n\r\n#include <IPXACTmodels/Component/validators/AddressBlockValidator.h>\r\n#include <IPXACTmodels/Component/validators/RegisterValidator.h>\r\n#include <IPXACTmodels/Component/validators/RegisterFileValidator.h>\r\n#include <IPXACTmodels/Component/validators/FieldValidator.h>\r\n#include <IPXACTmodels/Component/validators/EnumeratedValueValidator.h>\r\n#include <IPXACTmodels/common/validators/ParameterValidator.h>\r\n#include <IPXACTmodels/common/Document.h>\r\n\r\n#include <IPXACTmodels/Component/AddressBlock.h>\r\n#include <IPXACTmodels/Component/Register.h>\r\n#include <IPXACTmodels/Component/RegisterFile.h>\r\n#include <IPXACTmodels/Component/Field.h>\r\n#include <IPXACTmodels/Component/MemoryArray.h>\r\n#include <IPXACTmodels/Component/Mode.h>\r\n#include <IPXACTmodels/Component/Component.h>\r\n#include <IPXACTmodels/common/Parameter.h>\r\n\r\n#include <QtTest>\r\n\r\nclass tst_AddressBlockValidator : public QObject\r\n{\r\n    Q_OBJECT\r\n\r\npublic:\r\n    tst_AddressBlockValidator();\r\n\r\nprivate slots:\r\n\r\n    void testNameIsValid();\r\n    void testNameIsValid_data();\r\n\r\n    void testIsPresentIsValid();\r\n    void testIsPresentIsValid_data();\r\n\r\n    void testBaseAddressIsValid();\r\n    void testBaseAddressIsValid_data();\r\n\r\n    void testRangeIsValid();\r\n    void testRangeIsValid_data();\r\n\r\n    void testWidthIsValid();\r\n    void testWidthIsValid_data();\r\n\r\n    void testHasValidUsage();\r\n    void testHasValidUsage_data();\r\n\r\n    void testParametersAreValid();\r\n\r\n    void testRegisterDataIsValid();\r\n    void testRegisterDataIsValid_data();\r\n    void testAccessIsValidWithRegister();\r\n    void testAccessIsValidWithRegister_data();\r\n    void testRegisterPositioning();\r\n    void testRegisterPositioning_data();\r\n    void testRegisterOverlapping();\r\n    void testRegisterOverlapping_data();\r\n    void testRegisterIsOverlappingTwoOtherRegisters();\r\n\r\n    void testHasValidMemoryarray2022();\r\n    void testHasValidMemoryarray2022_data();\r\n    void testAccessPolicies2022();\r\n    void testRegisterAlignment2022();\r\n    void testRegisterAlignment2022_data();\r\n    void testStructureIsValid2022();\r\n\r\n    void testRegisterDataHaveUniqueNames();\r\n    void testRegisterDataHaveUniqueNames_data();\r\n\r\nprivate:\r\n    \r\n    bool errorIsNotFoundInErrorList(QString const& expectedError, QVector<QString> errorList);\r\n\r\n    QSharedPointer<AddressBlockValidator> createValidator(Document::Revision revision);\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_AddressBlockValidator::tst_AddressBlockValidator()\r\n//-----------------------------------------------------------------------------\r\ntst_AddressBlockValidator::tst_AddressBlockValidator()\r\n{\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_AddressBlockValidator::testNameIsValid()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_AddressBlockValidator::testNameIsValid()\r\n{\r\n    QFETCH(QString, name);\r\n    QFETCH(bool, isValid);\r\n\r\n    QSharedPointer<AddressBlock> testBlock (new AddressBlock(name));\r\n\r\n    QSharedPointer<AddressBlockValidator> validator = createValidator(Document::Revision::Std14);\r\n\r\n//     AddressBlockValidator validator(parser, QSharedPointer<QList<QSharedPointer<Choice> > > ());\r\n    QCOMPARE(validator->hasValidName(testBlock), isValid);\r\n\r\n    if (!isValid)\r\n    {\r\n        QVector<QString> foundErrors;\r\n        validator->findErrorsIn(foundErrors, testBlock, \"\", \"test\");\r\n\r\n        QString expectedError = QObject::tr(\"Invalid name specified for address block %1 within %2\").\r\n            arg(testBlock->name(), \"test\");\r\n        if (errorIsNotFoundInErrorList(expectedError, foundErrors))\r\n        {\r\n            QFAIL(\"No error message found\");\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_AddressBlockValidator::testNameIsValid_data()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_AddressBlockValidator::testNameIsValid_data()\r\n{\r\n    QTest::addColumn<QString>(\"name\");\r\n    QTest::addColumn<bool>(\"isValid\");\r\n\r\n    QTest::newRow(\"Name test is valid\") << \"test\" << true;\r\n    QTest::newRow(\"Empty name is invalid\") << \"\" << false;\r\n    QTest::newRow(\"Name consisting of only white spaces is invalid\") << \"    \" << false;\r\n    QTest::newRow(\"Name consisting of characters and white spaces is valid\") << \"  test  \" << true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_AddressBlockValidator::testIsPresentIsValid()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_AddressBlockValidator::testIsPresentIsValid()\r\n{\r\n    QFETCH(QString, isPresent);\r\n    QFETCH(bool, isValid);\r\n\r\n    QSharedPointer<AddressBlock> testBlock (new AddressBlock(\"TestAddressBlock\"));\r\n    testBlock->setIsPresent(isPresent);\r\n\r\n    QSharedPointer<AddressBlockValidator> validator = createValidator(Document::Revision::Std14);\r\n    QCOMPARE(validator->hasValidIsPresent(testBlock), isValid);\r\n\r\n    if (!isValid)\r\n    {\r\n        QVector<QString> foundErrors;\r\n        validator->findErrorsIn(foundErrors, testBlock, \"\", \"test\");\r\n\r\n        QString expectedError = QObject::tr(\"Invalid isPresent set for address block %1 within %2\").\r\n            arg(testBlock->name(), \"test\");\r\n        if (errorIsNotFoundInErrorList(expectedError, foundErrors))\r\n        {\r\n            QFAIL(\"No error message found\");\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_AddressBlockValidator::testIsPresentIsValid_data()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_AddressBlockValidator::testIsPresentIsValid_data()\r\n{\r\n    QTest::addColumn<QString>(\"isPresent\");\r\n    QTest::addColumn<bool>(\"isValid\");\r\n\r\n    QTest::newRow(\"IsPresent 1 is valid\") << \"1\" << true;\r\n    QTest::newRow(\"IsPresent 1*3-3 is valid\") << \"1*3-3\" << true;\r\n    QTest::newRow(\"IsPresent 2*100 is invalid\") << \"2*100\" << false;\r\n    QTest::newRow(\"IsPresent -14 is invalid\") << \"-14\" << false;\r\n    QTest::newRow(\"Real number isPresent  0.12 is invalid\") << \"0.12\" << false;\r\n    QTest::newRow(\"Text as isPresent is invalid\") << \"test\" << false;\r\n    QTest::newRow(\"String as isPresent is invalid\") << \"\\\"test\\\"\" << false;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_AddressBlockValidator::testBaseAddressIsValid()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_AddressBlockValidator::testBaseAddressIsValid()\r\n{\r\n    QFETCH(QString, baseAddress);\r\n    QFETCH(bool, isValid);\r\n\r\n    QSharedPointer<AddressBlock> testBlock (new AddressBlock(\"TestAddressBlock\"));\r\n    testBlock->setBaseAddress(baseAddress);\r\n\r\n    QSharedPointer<AddressBlockValidator> validator = createValidator(Document::Revision::Std14);\r\n    QCOMPARE(validator->hasValidBaseAddress(testBlock), isValid);\r\n\r\n    if (!isValid)\r\n    {\r\n        QVector<QString> foundErrors;\r\n        validator->findErrorsIn(foundErrors, testBlock, \"\", \"test\");\r\n\r\n        QString expectedError = QObject::tr(\"Invalid baseAddress set for address block %1 within %2\").\r\n            arg(testBlock->name(), \"test\");\r\n        if (errorIsNotFoundInErrorList(expectedError, foundErrors))\r\n        {\r\n            QFAIL(\"No error message found\");\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_AddressBlockValidator::testBaseAddressIsValid_data()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_AddressBlockValidator::testBaseAddressIsValid_data()\r\n{\r\n    QTest::addColumn<QString>(\"baseAddress\");\r\n    QTest::addColumn<bool>(\"isValid\");\r\n\r\n    QTest::newRow(\"BaseAddress 1 is valid\") << \"1\" << true;\r\n    QTest::newRow(\"BaseAddress 2*100 is valid\") << \"2*100\" << true;\r\n    QTest::newRow(\"BaseAddress -14 is invalid\") << \"-14\" << false;\r\n    QTest::newRow(\"Real number baseAddress 0.12 is invalid\") << \"0.12\" << false;\r\n    QTest::newRow(\"Text as baseAddress is invalid\") << \"test\" << false;\r\n    QTest::newRow(\"String as baseAddress is invalid\") << \"\\\"test\\\"\" << false;\r\n\r\n    QTest::newRow(\"Long base address is valid\") << \"40000000000\" << true;\r\n    //QTest::newRow(\"Really long base address is invalid\") << \"40000000000000000000000000000000000000000*2\" << false;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_AddressBlockValidator::testRangeIsValid()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_AddressBlockValidator::testRangeIsValid()\r\n{\r\n    QFETCH(QString, range);\r\n    QFETCH(bool, isValid);\r\n\r\n    QSharedPointer<AddressBlock> testBlock (new AddressBlock(\"TestAddressBlock\"));\r\n    testBlock->setRange(range);\r\n\r\n    QSharedPointer<AddressBlockValidator> validator = createValidator(Document::Revision::Std14);\r\n    QCOMPARE(validator->hasValidRange(testBlock), isValid);\r\n\r\n    if (!isValid)\r\n    {\r\n        QVector<QString> foundErrors;\r\n        validator->findErrorsIn(foundErrors, testBlock, \"\", \"test\");\r\n\r\n        QString expectedError = QObject::tr(\"Invalid range set for address block %1 within %2\").\r\n            arg(testBlock->name(), \"test\");\r\n        if (errorIsNotFoundInErrorList(expectedError, foundErrors))\r\n        {\r\n            QFAIL(\"No error message found\");\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_AddressBlockValidator::testRangeIsValid_data()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_AddressBlockValidator::testRangeIsValid_data()\r\n{\r\n    QTest::addColumn<QString>(\"range\");\r\n    QTest::addColumn<bool>(\"isValid\");\r\n\r\n    QTest::newRow(\"Range 1 is valid\") << \"1\" << true;\r\n    QTest::newRow(\"Range 5*5+15 is valid\") << \"5*5+15\" << true;\r\n    QTest::newRow(\"Range 2*100-200 is invalid\") << \"2*100-200\" << false;\r\n    QTest::newRow(\"Range -14 is invalid\") << \"-14\" << false;\r\n    QTest::newRow(\"Real number as range 0.12 is invalid\") << \"0.12\" << false;\r\n    QTest::newRow(\"Text as range is invalid\") << \"test\" << false;\r\n    QTest::newRow(\"String as range is invalid\") << \"\\\"test\\\"\" << false;\r\n\r\n    QTest::newRow(\"Long range is valid\") << \"40000000000\" << true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_AddressBlockValidator::testWidthIsValid()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_AddressBlockValidator::testWidthIsValid()\r\n{\r\n    QFETCH(QString, width);\r\n    QFETCH(bool, isValid);\r\n\r\n    QSharedPointer<AddressBlock> testBlock (new AddressBlock(\"TestAddressBlock\"));\r\n    testBlock->setWidth(width);\r\n\r\n    QSharedPointer<AddressBlockValidator> validator = createValidator(Document::Revision::Std14);\r\n    QCOMPARE(validator->hasValidWidth(testBlock), isValid);\r\n\r\n    if (!isValid)\r\n    {\r\n        QVector<QString> foundErrors;\r\n        validator->findErrorsIn(foundErrors, testBlock, \"\", \"test\");\r\n\r\n        QString expectedError = QObject::tr(\"Invalid width set for address block %1 within %2\").\r\n            arg(testBlock->name()).arg(\"test\");\r\n        if (errorIsNotFoundInErrorList(expectedError, foundErrors))\r\n        {\r\n            QFAIL(\"No error message found\");\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_AddressBlockValidator::testWidthIsValid_data()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_AddressBlockValidator::testWidthIsValid_data()\r\n{\r\n    QTest::addColumn<QString>(\"width\");\r\n    QTest::addColumn<bool>(\"isValid\");\r\n\r\n    QTest::newRow(\"Width 5*5+15 is valid\") << \"5*5+15\" << true;\r\n    QTest::newRow(\"Width 2*100-200 is valid\") << \"2*100-200\" << true;\r\n    QTest::newRow(\"Width -14 is invalid\") << \"-14\" << false;\r\n    QTest::newRow(\"Real number as width 0.12 is invalid\") << \"0.12\" << false;\r\n    QTest::newRow(\"Text as width is invalid\") << \"test\" << false;\r\n    QTest::newRow(\"String as width is invalid\") << \"\\\"test\\\"\" << false;\r\n\r\n    QTest::newRow(\"Long width is valid\") << \"40000000000\" << true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_AddressBlockValidator::testHasValidUsage()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_AddressBlockValidator::testHasValidUsage()\r\n{\r\n    QFETCH(QString, usage);\r\n    QFETCH(int, registerAmount);\r\n    QFETCH(QString, registerVolatile);\r\n    QFETCH(QString, registerAccess);\r\n    QFETCH(bool, isValid);\r\n\r\n    QSharedPointer<Field> testField (new Field(\"testField\"));\r\n    testField->setBitOffset(\"0\");\r\n    testField->setBitWidth(\"4\");\r\n\r\n    QSharedPointer<AddressBlock> testBlock (new AddressBlock(\"testAddressBlock\"));\r\n    testBlock->setUsage(General::str2Usage(usage, General::USAGE_COUNT));\r\n    testBlock->setWidth(\"20\");\r\n\r\n    QSharedPointer<Register> testRegister;\r\n    for (int i = 0; i < registerAmount; ++i)\r\n    {\r\n        QSharedPointer<Register> newRegister (new Register(\"testRegister \" + i, \"0\", \"10\"));\r\n        newRegister->getFields()->append(testField);\r\n\r\n        if (usage == QLatin1String(\"memory\") && i == 0)\r\n        {\r\n            testRegister = newRegister;\r\n            if (registerVolatile == QLatin1String(\"true\"))\r\n            {\r\n                newRegister->setVolatile(true);\r\n            }\r\n            else if (registerVolatile == QLatin1String(\"false\"))\r\n            {\r\n                newRegister->setVolatile(false);\r\n            }\r\n\r\n            newRegister->setAccess(AccessTypes::str2Access(registerAccess, AccessTypes::ACCESS_COUNT));\r\n        }\r\n\r\n        testBlock->getRegisterData()->append(newRegister);\r\n    }\r\n\r\n    QSharedPointer<AddressBlockValidator> validator = createValidator(Document::Revision::Std14);\r\n    QCOMPARE(validator->hasValidUsage(testBlock), isValid);\r\n\r\n    if (!isValid)\r\n    {\r\n        QVector<QString> foundErrors;\r\n        validator->findErrorsIn(foundErrors, testBlock, \"\", \"test\");\r\n\r\n        if (General::str2Usage(usage, General::USAGE_COUNT) == General::RESERVED)\r\n        {\r\n            QString expectedError = QObject::tr(\"Registers cannot be contained in address block %1 with usage \"\r\n                \"%2 within %3\").arg(testBlock->name()).arg(usage).arg(\"test\");\r\n            if (errorIsNotFoundInErrorList(expectedError, foundErrors))\r\n            {\r\n                QFAIL(\"No error message found\");\r\n            }\r\n        }\r\n        else if (General::str2Usage(usage, General::USAGE_COUNT) == General::MEMORY)\r\n        {\r\n            QString expectedError = QObject::tr(\"Access and volatile values must be empty for register %1 in \"\r\n                \"address block %2 with usage %3 within %4\")\r\n                .arg(testRegister->name()).arg(testBlock->name()).arg(usage).arg(\"test\");\r\n            if (errorIsNotFoundInErrorList(expectedError, foundErrors))\r\n            {\r\n                QFAIL(\"No error message found\");\r\n            }\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_AddressBlockValidator::testHasValidUsage_data()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_AddressBlockValidator::testHasValidUsage_data()\r\n{\r\n    QTest::addColumn<QString>(\"usage\");\r\n    QTest::addColumn<int>(\"registerAmount\");\r\n    QTest::addColumn<QString>(\"registerVolatile\");\r\n    QTest::addColumn<QString>(\"registerAccess\");\r\n    QTest::addColumn<bool>(\"isValid\");\r\n\r\n    QTest::newRow(\"Reserved usage is valid without registers\") << \"reserved\" << 0 << \"\" << \"\" << true;\r\n    QTest::newRow(\"Reserved usage is invalid with registers\") << \"reserved\" << 3 << \"\" << \"\" << false;\r\n\r\n    QTest::newRow(\"Register usage is valid without registers\") << \"register\" << 0 << \"\" << \"\" << true;\r\n    QTest::newRow(\"Register usage is valid with registers\") << \"register\" << 3 << \"\" << \"\" << true;\r\n\r\n    QTest::newRow(\"Memory usage is valid without registers\") << \"memory\" << 0 << \"\" << \"\" << true;\r\n    QTest::newRow(\"Memory usage is valid with virtual registers\") << \"memory\" << 3 << \"\" << \"\" << true;\r\n//     QTest::newRow(\"Memory usage is invalid with registers containing volatile\") << \"memory\" << 3 << \"true\" << \"\" << false;\r\n//     QTest::newRow(\"Memory usage is invalid with registers containing access\") << \"memory\" << 3 << \"\" << \"read-write\" << false;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_AddressBlockValidator::testParametersAreValid()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_AddressBlockValidator::testParametersAreValid()\r\n{\r\n    QSharedPointer<Parameter> testParameter (new Parameter());\r\n    testParameter->setValueId(\"Sanger\");\r\n    testParameter->setName(\"Daizengar\");\r\n    testParameter->setValue(\"20\");\r\n    testParameter->setType(\"int\");\r\n\r\n    QSharedPointer<AddressBlock> testBlock (new AddressBlock(\"TestAddressBlock\"));\r\n    testBlock->getParameters()->append(testParameter);\r\n\r\n    QSharedPointer<AddressBlockValidator> validator = createValidator(Document::Revision::Std14);\r\n    QCOMPARE(validator->hasValidParameters(testBlock), true);\r\n\r\n    testParameter->setValue(\"\");\r\n    QCOMPARE(validator->hasValidParameters(testBlock), false);\r\n\r\n    QVector<QString> errorsFound;\r\n    validator->findErrorsIn(errorsFound, testBlock, \"\", \"test\");\r\n\r\n    QString expectedError = QObject::tr(\"No value specified for %1 %2 within address block %3\").\r\n        arg(testParameter->elementName()).arg(testParameter->name()).arg(testBlock->name());\r\n\r\n    if (errorIsNotFoundInErrorList(expectedError, errorsFound))\r\n    {\r\n        QFAIL(\"Error was not found\");\r\n    }\r\n\r\n    QSharedPointer<Parameter> otherParameter (new Parameter(*testParameter.data()));\r\n    testParameter->setValue(\"1\");\r\n    otherParameter->setValue(\"2\");\r\n    testBlock->getParameters()->append(otherParameter);\r\n\r\n    QCOMPARE(validator->hasValidParameters(testBlock), false);\r\n\r\n    errorsFound.clear();\r\n    validator->findErrorsIn(errorsFound, testBlock, \"\", \"test\");\r\n    expectedError = QObject::tr(\"Name %1 of parameters in address block %2 is not unique.\").arg(otherParameter->name()).\r\n        arg(testBlock->name());\r\n    if (errorIsNotFoundInErrorList(expectedError, errorsFound))\r\n    {\r\n        QFAIL(\"Error was not found\");\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_AddressBlockValidator::testRegisterDataIsValid()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_AddressBlockValidator::testRegisterDataIsValid()\r\n{\r\n    QFETCH(QString, registerName1);\r\n    QFETCH(QString, registerOffset1);\r\n    QFETCH(QString, registerSize1);\r\n    QFETCH(QString, typeIdentifier1);\r\n    QFETCH(bool, registerVolatile);\r\n\r\n    QFETCH(QString, registerName2);\r\n    QFETCH(QString, registerOffset2);\r\n    QFETCH(QString, registerSize2);\r\n    QFETCH(QString, typeIdentifier2);\r\n\r\n    QFETCH(bool, blockVolatile);\r\n    QFETCH(bool, isValid);\r\n\r\n    QSharedPointer<Field> testFieldOne (new Field(\"fieldOne\"));\r\n    testFieldOne->setBitOffset(\"0\");\r\n    testFieldOne->setBitWidth(\"2\");\r\n    testFieldOne->setVolatile(registerVolatile);\r\n\r\n    QSharedPointer<Field> testFieldTwo (new Field(\"fieldTwo\"));\r\n    testFieldTwo->setBitOffset(\"0\");\r\n    testFieldTwo->setBitWidth(\"4\");\r\n    testFieldTwo->setVolatile(registerVolatile);\r\n\r\n    QSharedPointer<Register> registerOne (new Register(registerName1, registerOffset1, registerSize1));\r\n    registerOne->setVolatile(registerVolatile);\r\n    registerOne->setTypeIdentifier(typeIdentifier1);\r\n    registerOne->getFields()->append(testFieldOne);\r\n\r\n    QSharedPointer<Register> registerTwo (new Register(registerName2, registerOffset2, registerSize2));\r\n    registerTwo->setVolatile(registerVolatile);\r\n    registerTwo->setTypeIdentifier(typeIdentifier2);\r\n    registerTwo->getFields()->append(testFieldTwo);\r\n\r\n    QSharedPointer<AddressBlock> testBlock (new AddressBlock(\"testAddressBlock\"));\r\n    testBlock->setWidth(\"20\");\r\n    testBlock->setVolatile(blockVolatile);\r\n    testBlock->getRegisterData()->append(registerOne);\r\n    testBlock->getRegisterData()->append(registerTwo);\r\n\r\n    QSharedPointer<AddressBlockValidator> validator = createValidator(Document::Revision::Std14);    QCOMPARE(validator->hasValidRegisterData(testBlock, \"\"), isValid);\r\n\r\n    if (!isValid)\r\n    {\r\n        QVector<QString> foundErrors;\r\n        validator->findErrorsIn(foundErrors, testBlock, \"\", \"test\");\r\n\r\n        if (registerOffset1.isEmpty())\r\n        {\r\n            QString expectedError = QObject::tr(\"Invalid address offset set for register '%1' within %2\").\r\n                arg(registerName1).arg(\"address block \" + testBlock->name());\r\n\r\n            if (errorIsNotFoundInErrorList(expectedError, foundErrors))\r\n            {\r\n                QFAIL(\"No error message found\");\r\n            }\r\n        }\r\n\r\n        if (registerName1 == registerName2)\r\n        {\r\n            QString expectedError = QObject::tr(\"Name %1 of registers in addressBlock %2 is not unique.\")\r\n                .arg(registerName1).arg(testBlock->name());\r\n\r\n            if (errorIsNotFoundInErrorList(expectedError, foundErrors))\r\n            {\r\n                QFAIL(\"No error message found\");\r\n            }\r\n        }\r\n\r\n        if (validator->registerSizeIsNotWithinBlockWidth(registerOne, testBlock))\r\n        {\r\n            QString expectedError = QObject::tr(\"Register %1 size must not be greater than the containing \"\r\n                \"addressBlock %2 width.\").arg(registerOne->name()).arg(testBlock->name());\r\n\r\n            if (errorIsNotFoundInErrorList(expectedError, foundErrors))\r\n            {\r\n                QFAIL(\"No error message found\");\r\n            }\r\n        }\r\n\r\n        if (!validator->hasValidVolatileForRegister(testBlock, registerOne))\r\n        {\r\n            QString expectedError = QObject::tr(\"Volatile value cannot be set to false for addressBlock %1 \"\r\n                \"containing a register or register field with volatile true\").arg(testBlock->name());\r\n\r\n            if (errorIsNotFoundInErrorList(expectedError, foundErrors))\r\n            {\r\n                QFAIL(\"No error message found\");\r\n            }\r\n        }\r\n\r\n        if (!typeIdentifier1.isEmpty() && typeIdentifier1 == typeIdentifier2)\r\n        {\r\n            QString expectedError = QObject::tr(\"Registers containing the same type identifiers must contain \"\r\n                \"similar register definitions within address block %1\").arg(testBlock->name());\r\n\r\n            if (errorIsNotFoundInErrorList(expectedError, foundErrors))\r\n            {\r\n                QFAIL(\"No error message found\");\r\n            }\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_AddressBlockValidator::testRegisterDataIsValid_data()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_AddressBlockValidator::testRegisterDataIsValid_data()\r\n{\r\n    QTest::addColumn<QString>(\"registerName1\");\r\n    QTest::addColumn<QString>(\"registerOffset1\");\r\n    QTest::addColumn<QString>(\"registerSize1\");\r\n    QTest::addColumn<QString>(\"typeIdentifier1\");\r\n    QTest::addColumn<bool>(\"registerVolatile\");\r\n\r\n    QTest::addColumn<QString>(\"registerName2\");\r\n    QTest::addColumn<QString>(\"registerOffset2\");\r\n    QTest::addColumn<QString>(\"registerSize2\");\r\n    QTest::addColumn<QString>(\"typeIdentifier2\");\r\n\r\n    QTest::addColumn<bool>(\"blockVolatile\");\r\n    QTest::addColumn<bool>(\"isValid\");\r\n\r\n    QTest::newRow(\"Registers with same type identifier must contain same definition\") << \"register1\" << \"0\" <<\r\n        \"12\" << \"identifier\" << false << \"register2\" << \"0\" << \"4\" << \"identifier\" << false << false;\r\n\r\n    QTest::newRow(\"Registers with different names are valid\") << \"register1\" << \"0\" << \"10\" << \"\" << false <<\r\n        \"register2\" << \"0\" << \"10\" << \"\" << false << true;\r\n    QTest::newRow(\"Register without address offset is invalid\") << \"register1\" << \"\" << \"10\" << \"\" << false <<\r\n        \"register2\" << \"0\" << \"10\" << \"\" << false << false;\r\n    QTest::newRow(\"Registers with same names are invalid\") << \"register\" << \"0\" << \"10\" << \"\" << false <<\r\n        \"register\" << \"10\" << \"10\" << \"\" << false << false;\r\n    QTest::newRow(\"Register with size > address block width is invalid\") << \"register\" << \"0\" << \"30\" << \"\" <<\r\n        false << \"register2\" << \"0\" << \"4\" << \"\" << false << false;\r\n\r\n    QTest::newRow(\"Register: volatile = true, address block: volatile = true is valid\")  << \"register1\" << \"0\" <<\r\n        \"10\" << \"\" << true << \"register2\" << \"0\" << \"10\" << \"\" << true << true;\r\n    QTest::newRow(\"Register: volatile = true, address block: volatile = false is invalid\")  << \"register1\" <<\r\n        \"0\" << \"10\" << \"\" << true << \"register2\" << \"0\" << \"10\" << \"\" << false << false;\r\n\r\n    QTest::newRow(\"Registers with same type identifier must contain same definition\") << \"register1\" << \"0\" <<\r\n        \"10\" << \"identifier\" << false << \"register2\" << \"0\" << \"10\" << \"identifier\" << false << true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_AddressBlockValidator::testAccessIsValidWithRegister()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_AddressBlockValidator::testAccessIsValidWithRegister()\r\n{\r\n    QFETCH(QString, blockAccess);\r\n    QFETCH(QString, registerAccess);\r\n    QFETCH(bool, isValid);\r\n\r\n    QSharedPointer<Field> testField (new Field(\"testField\"));\r\n    testField->setBitOffset(\"0\");\r\n    testField->setBitWidth(\"4\");\r\n    testField->setAccess(AccessTypes::str2Access(registerAccess, AccessTypes::ACCESS_COUNT));\r\n\r\n    QSharedPointer<Register> testRegister (new Register(\"Mugen\", \"0\", \"20\"));\r\n    testRegister->setAccess(AccessTypes::str2Access(registerAccess, AccessTypes::ACCESS_COUNT));\r\n    testRegister->getFields()->append(testField);\r\n\r\n    QSharedPointer<AddressBlock> testBlock (new AddressBlock(\"block\"));\r\n    testBlock->setWidth(\"100\");\r\n    testBlock->setAccess(AccessTypes::str2Access(blockAccess, AccessTypes::ACCESS_COUNT));\r\n    testBlock->getRegisterData()->append(testRegister);\r\n\r\n    QSharedPointer<AddressBlockValidator> validator = createValidator(Document::Revision::Std14);\r\n    QCOMPARE(validator->hasValidRegisterData(testBlock, \"\"), isValid);\r\n\r\n    if (!isValid)\r\n    {\r\n        QVector<QString> foundErrors;\r\n        validator->findErrorsIn(foundErrors, testBlock, \"\", \"test\");\r\n\r\n        QString expectedError = QObject::tr(\"Access cannot be set to %1 in register %2, where containing address \"\r\n            \"block %3 has access %4\").arg(registerAccess).arg(testRegister->name())\r\n            .arg(testBlock->name()).arg(blockAccess);\r\n\r\n        if (errorIsNotFoundInErrorList(expectedError, foundErrors))\r\n        {\r\n            QFAIL(\"No error message found\");\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_AddressBlockValidator::testAccessIsValidWithRegister_data()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_AddressBlockValidator::testAccessIsValidWithRegister_data()\r\n{\r\n    QTest::addColumn<QString>(\"blockAccess\");\r\n    QTest::addColumn<QString>(\"registerAccess\");\r\n    QTest::addColumn<bool>(\"isValid\");\r\n\r\n    QTest::newRow(\"AddressBlock: access = read-only, register: access = read-write is invalid\") <<\r\n        \"read-only\" << \"read-write\" << false;\r\n    QTest::newRow(\"AddressBlock: access = read-only, register: access = read-only is valid\") <<\r\n        \"read-only\" << \"read-only\" << true;\r\n    QTest::newRow(\"AddressBlock: access = read-only, register: access = write-only is invalid\") <<\r\n        \"read-only\" << \"write-only\" << false;\r\n    QTest::newRow(\"AddressBlock: access = read-only, register: access = read-writeOnce is invalid\") <<\r\n        \"read-only\" << \"read-writeOnce\" << false;\r\n    QTest::newRow(\"AddressBlock: access = read-only, register: access = writeOnce is invalid\") <<\r\n        \"read-only\" << \"writeOnce\" << false;\r\n\r\n    QTest::newRow(\"AddressBlock: access = write-only, register: access = read-write is invalid\") <<\r\n        \"write-only\" << \"read-write\" << false;\r\n    QTest::newRow(\"AddressBlock: access = write-only, register: access = read-only is invalid\") <<\r\n        \"write-only\" << \"read-only\" << false;\r\n    QTest::newRow(\"AddressBlock: access = write-only, register: access = write-only is valid\") <<\r\n        \"write-only\" << \"write-only\" << true;\r\n    QTest::newRow(\"AddressBlock: access = write-only, register: access = read-writeOnce is invalid\") <<\r\n        \"write-only\" << \"read-writeOnce\" << false;\r\n    QTest::newRow(\"AddressBlock: access = write-only, register: access = writeOnce is valid\") <<\r\n        \"write-only\" << \"writeOnce\" << true;\r\n\r\n    QTest::newRow(\"AddressBlock: access = read-writeOnce , register: access = read-write is invalid\") <<\r\n        \"read-writeOnce\" << \"read-write\" << false;\r\n    QTest::newRow(\"AddressBlock: access = read-writeOnce , register: access = read-only is valid\") <<\r\n        \"read-writeOnce\" << \"read-only\" << true;\r\n    QTest::newRow(\"AddressBlock: access = read-writeOnce , register: access = write-only is invalid\") <<\r\n        \"read-writeOnce\" << \"write-only\" << false;\r\n    QTest::newRow(\"AddressBlock: access = read-writeOnce , register: access = read-writeOnce is valid\") <<\r\n        \"read-writeOnce\" << \"read-writeOnce\" << true;\r\n    QTest::newRow(\"AddressBlock: access = read-writeOnce , register: access = writeOnce is valid\") <<\r\n        \"read-writeOnce\" << \"writeOnce\" << true;\r\n\r\n    QTest::newRow(\"AddressBlock: access = writeOnce , register: access = read-write is invalid\") <<\r\n        \"writeOnce\" << \"read-write\" << false;\r\n    QTest::newRow(\"AddressBlock: access = writeOnce , register: access = read-only is valid\") <<\r\n        \"writeOnce\" << \"read-only\" << false;\r\n    QTest::newRow(\"AddressBlock: access = writeOnce , register: access = write-only is invalid\") <<\r\n        \"writeOnce\" << \"write-only\" << false;\r\n    QTest::newRow(\"AddressBlock: access = writeOnce , register: access = read-writeOnce is valid\") <<\r\n        \"writeOnce\" << \"read-writeOnce\" << false;\r\n    QTest::newRow(\"AddressBlock: access = writeOnce , register: access = writeOnce is valid\") <<\r\n        \"writeOnce\" << \"writeOnce\" << true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_AddressBlockValidator::testRegistersAreWithinAddressBlock()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_AddressBlockValidator::testRegisterPositioning()\r\n{\r\n    QFETCH(QString, registerOffset1);\r\n    QFETCH(QString, registerSize1);\r\n    QFETCH(QString, registerDimension1);\r\n    QFETCH(QString, addressBlockRange);\r\n    QFETCH(QString, addressUnitBits);\r\n    QFETCH(QString, addressBlockWidth);\r\n    QFETCH(bool, isValid);\r\n\r\n    QSharedPointer<Field> testField (new Field(\"testField\"));\r\n    testField->setBitOffset(\"0\");\r\n    testField->setBitWidth(\"1\");\r\n\r\n    QSharedPointer<Register> registerOne (new Register(\"Mugen\", registerOffset1, registerSize1));\r\n    registerOne->setDimension(registerDimension1);\r\n    registerOne->getFields()->append(testField);\r\n\r\n    QSharedPointer<AddressBlock> testBlock (new AddressBlock(\"testBlock\", \"0\"));\r\n    testBlock->setWidth(addressBlockWidth);\r\n    testBlock->setRange(addressBlockRange);\r\n    testBlock->getRegisterData()->append(registerOne);\r\n\r\n    QSharedPointer<AddressBlockValidator> validator = createValidator(Document::Revision::Std14);\r\n    QCOMPARE(validator->hasValidRegisterData(testBlock, addressUnitBits), isValid);\r\n\r\n    if (!isValid)\r\n    {\r\n        QVector<QString> foundErrors;\r\n        validator->findErrorsIn(foundErrors, testBlock, addressUnitBits, \"test\");\r\n\r\n        QString expectedError = QObject::tr(\"Register %1 is not contained within address block %2\")\r\n            .arg(registerOne->name()).arg(testBlock->name());\r\n\r\n        if (registerDimension1 == \"0\")\r\n        {\r\n            expectedError = QObject::tr(\"Invalid dimensions set for register '%1' within address block %2\")\r\n                .arg(registerOne->name()).arg(testBlock->name());\r\n        }\r\n\r\n        if (errorIsNotFoundInErrorList(expectedError, foundErrors))\r\n        {\r\n            QFAIL(\"No error message found\");\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_AddressBlockValidator::testRegistersAreWithinAddressBlock_data()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_AddressBlockValidator::testRegisterPositioning_data()\r\n{\r\n    QTest::addColumn<QString>(\"registerOffset1\");\r\n    QTest::addColumn<QString>(\"registerSize1\");\r\n    QTest::addColumn<QString>(\"registerDimension1\");\r\n    QTest::addColumn<QString>(\"addressBlockRange\");\r\n    QTest::addColumn<QString>(\"addressUnitBits\");\r\n    QTest::addColumn<QString>(\"addressBlockWidth\");\r\n    QTest::addColumn<bool>(\"isValid\");\r\n\r\n    QTest::newRow(\"Register: offset='h0, size=32, dimension=0; addressBlock range=4, AUB=8, width=32 is not valid\")\r\n        << \"'h0\" << \"32\" << \"0\" << \"4\" << \"8\" << \"32\" << false;\r\n\r\n    QTest::newRow(\"Register: offset=4, size=5, dimension=1; addressBlock range = 10; addressUnitBits = 4 is valid\")\r\n        << \"4\" << \"5\" << \"1\" << \"10\" << \"4\" << \"100\" << true;\r\n    QTest::newRow(\"Register: offset=-1, size=5, dimension=1; addressBlock range = 10; addressUnitBits = 4 is not valid\")\r\n        << \"-1\" << \"5\" << \"1\" << \"10\" << \"4\" << \"100\" << false;\r\n    QTest::newRow(\"Register: offset=4, size=25, dimension=1; addressBlock range = 10; addressUnitBits = 4 is not valid\")\r\n        << \"4\" << \"25\" << \"1\" << \"10\" << \"4\" << \"100\" << false;\r\n    QTest::newRow(\"Register: offset=4, size=5, dimension=4; addressBlock range = 10; addressUnitBits = 4 is not valid\")\r\n        << \"4\" << \"5\" << \"4\" << \"10\" << \"4\" << \"100\" << false;\r\n    QTest::newRow(\"Register: offset=4, size=5, dimension=1; addressBlock range = 5; addressUnitBits = 4 is not valid\")\r\n        << \"4\" << \"5\" << \"1\" << \"5\" << \"4\" << \"100\" << false;\r\n\r\n    QTest::newRow(\"Register: offset='h10, size=32, dimension=; addressBlock range=24, AUB=8, width = 32 is valid\")\r\n        << \"'h10\" << \"32\" << \"\" << \"24\" << \"8\" << \"32\" << true;\r\n\r\n    /*QTest::newRow(\"Register with long offset is not valid within a small address block\")\r\n        << \"4000000000000000000000\" << \"32\" << \"0\" << \"4\" << \"8\" << \"32\" << false;\r\n    QTest::newRow(\"Register with long size is not valid within a small address block\")\r\n        << \"'h0\" << \"4000000000000000000000\" << \"0\" << \"4\" << \"8\" << \"32\" << false;\r\n    QTest::newRow(\"Register with long dimension is not valid within a small address block\")\r\n        << \"'h0\" << \"32\" << \"4000000000000000000000\" << \"4\" << \"8\" << \"32\" << false;*/\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_AddressBlockValidator::testRegisterOverlapping()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_AddressBlockValidator::testRegisterOverlapping()\r\n{\r\n    QFETCH(QString, registerOffset1);\r\n    QFETCH(QString, registerSize1);\r\n    QFETCH(QString, registerDimension1);\r\n    QFETCH(QString, registerOffset2);\r\n    QFETCH(QString, registerSize2);\r\n    QFETCH(QString, registerDimension2);\r\n    QFETCH(QString, addressUnitBits);\r\n    QFETCH(bool, isValid);\r\n\r\n    QSharedPointer<Field> testField (new Field(\"testField\"));\r\n    testField->setBitOffset(\"0\");\r\n    testField->setBitWidth(\"1\");\r\n\r\n    QSharedPointer<Register> registerOne (new Register(\"Mugen\", registerOffset1, registerSize1));\r\n    registerOne->setDimension(registerDimension1);\r\n    registerOne->getFields()->append(testField);\r\n\r\n    QSharedPointer<Register> registerTwo (new Register(\"Jin\", registerOffset2, registerSize2));\r\n    registerTwo->setDimension(registerDimension2);\r\n    registerTwo->getFields()->append(testField);\r\n\r\n    QSharedPointer<AddressBlock> testBlock (new AddressBlock(\"testBlock\", \"0\"));\r\n    testBlock->setWidth(\"100\");\r\n    testBlock->setRange(\"100\");\r\n    testBlock->getRegisterData()->append(registerOne);\r\n    testBlock->getRegisterData()->append(registerTwo);\r\n\r\n    QSharedPointer<AddressBlockValidator> validator = createValidator(Document::Revision::Std14);\r\n    QCOMPARE(validator->hasValidRegisterData(testBlock, addressUnitBits), isValid);\r\n\r\n    if (!isValid)\r\n    {\r\n        QVector<QString> foundErrors;\r\n        validator->findErrorsIn(foundErrors, testBlock, addressUnitBits, \"test\");\r\n\r\n        if (registerDimension1 == \"0\" || registerDimension2 == \"0\")\r\n        {\r\n            QStringList expectedErrors;\r\n\r\n            if (registerDimension1 == \"0\")\r\n            {\r\n                expectedErrors.append(QObject::tr(\"Invalid dimensions set for register '%1' within address block %2\")\r\n                    .arg(registerOne->name()).arg(testBlock->name()));\r\n            }\r\n\r\n            if (registerDimension2 == \"0\")\r\n            {\r\n                expectedErrors.append(QObject::tr(\"Invalid dimensions set for register '%1' within address block %2\")\r\n                    .arg(registerTwo->name()).arg(testBlock->name()));\r\n            }\r\n\r\n            for (auto const& error : expectedErrors)\r\n            {\r\n                if (errorIsNotFoundInErrorList(error, foundErrors))\r\n                {\r\n                    QFAIL(\"No error message found\");\r\n                }\r\n            }\r\n        }\r\n        else if (registerOffset1.toInt() < registerOffset2.toInt())\r\n        {\r\n            QString expectedError = QObject::tr(\"Register data %1 and %2 overlap within address block %3\")\r\n                .arg(registerOne->name()).arg(registerTwo->name()).arg(testBlock->name());\r\n\r\n            if (errorIsNotFoundInErrorList(expectedError, foundErrors))\r\n            {\r\n                QFAIL(\"No error message found\");\r\n            }\r\n        }\r\n        else\r\n        {\r\n            QString expectedError = QObject::tr(\"Register data %1 and %2 overlap within address block %3\")\r\n                .arg(registerTwo->name()).arg(registerOne->name()).arg(testBlock->name());\r\n\r\n            if (errorIsNotFoundInErrorList(expectedError, foundErrors))\r\n            {\r\n                QFAIL(\"No error message found\");\r\n            }\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_AddressBlockValidator::testRegisterOverlapping_data()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_AddressBlockValidator::testRegisterOverlapping_data()\r\n{\r\n    QTest::addColumn<QString>(\"registerOffset1\");\r\n    QTest::addColumn<QString>(\"registerSize1\");\r\n    QTest::addColumn<QString>(\"registerDimension1\");\r\n    QTest::addColumn<QString>(\"registerOffset2\");\r\n    QTest::addColumn<QString>(\"registerSize2\");\r\n    QTest::addColumn<QString>(\"registerDimension2\");\r\n    QTest::addColumn<QString>(\"addressUnitBits\");\r\n    QTest::addColumn<bool>(\"isValid\");\r\n\r\n    QTest::newRow(\"First: offset='h0, size=32, dimension=0; Second: offset=4, size=32, dimension=0; AUB=8 is invalid\")\r\n        << \"0\" << \"32\" << \"0\" << \"4\" << \"32\" << \"0\" << \"8\" << false;\r\n\r\n    QTest::newRow(\"Register1: offset=0, size=5, dimension=1; Register2: offset=50, size=5, dimension=2; \"\r\n        \"Address unit bits: 8 is valid\") <<\r\n        \"0\" << \"5\" << \"1\" << \"50\" << \"5\" << \"2\" << \"8\" << true;\r\n    QTest::newRow(\"Register1: offset=49, size=9, dimension=1; Register2: offset=50, size=5, dimension=2; \"\r\n        \"Address unit bits: 8 is not valid\") <<\r\n        \"49\" << \"9\" << \"1\" << \"50\" << \"5\" << \"2\" << \"8\" << false;\r\n    QTest::newRow(\"Register1: offset=50, size=5, dimension=2; Register2: offset=49, size=9, dimension=1; \"\r\n        \"Address unit bits: 8 is not valid\") <<\r\n        \"50\" << \"5\" << \"2\" << \"49\" << \"9\" << \"1\" << \"8\" << false;\r\n    QTest::newRow(\"Register1: offset=49, size=5, dimension=2; Register2: offset=50, size=5, dimension=2; \"\r\n        \"Address unit bits: 8 is not valid\") <<\r\n        \"49\" << \"5\" << \"2\" << \"50\" << \"5\" << \"2\" << \"8\" << false;\r\n    QTest::newRow(\"Register1: offset=70, size=5, dimension=1; Register2: offset=50, size=5, dimension=2; \"\r\n        \"Address unit bits: 8 is valid\") <<\r\n        \"70\" << \"5\" << \"1\" << \"50\" << \"5\" << \"2\" << \"8\" << true;\r\n    QTest::newRow(\"Register1: offset=60, size=5, dimension=1; Register2: offset=50, size=5, dimension=20; \"\r\n        \"Address unit bits: 8 is not valid\") <<\r\n        \"60\" << \"5\" << \"1\" << \"50\" << \"5\" << \"20\" << \"8\" << false;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_AddressBlockValidator::testRegisterIsOverlappingTwoOtherRegisters()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_AddressBlockValidator::testRegisterIsOverlappingTwoOtherRegisters()\r\n{\r\n    QSharedPointer<Field> testField (new Field(\"testField\"));\r\n    testField->setBitOffset(\"0\");\r\n    testField->setBitWidth(\"1\");\r\n\r\n    QSharedPointer<Register> registerOne (new Register(\"Mugen\", \"0\", \"5\"));\r\n    registerOne->setDimension(\"4\");\r\n    registerOne->getFields()->append(testField);\r\n\r\n    QSharedPointer<Register> registerTwo (new Register(\"Jin\", \"10\", \"5\"));\r\n    registerTwo->setDimension(\"4\");\r\n    registerTwo->getFields()->append(testField);\r\n\r\n    QSharedPointer<Register> registerThree (new Register(\"Fuu\", \"3\", \"1\"));\r\n    registerThree->setDimension(\"8\");\r\n    registerThree->getFields()->append(testField);\r\n\r\n    QSharedPointer<AddressBlock> testBlock (new AddressBlock(\"champloo\", \"0\"));\r\n    testBlock->setRange(\"50\");\r\n    testBlock->setWidth(\"10\");\r\n    testBlock->getRegisterData()->append(registerOne);\r\n    testBlock->getRegisterData()->append(registerTwo);\r\n    testBlock->getRegisterData()->append(registerThree);\r\n\r\n    QString addressUnitBits = QLatin1String(\"8\");\r\n\r\n    QSharedPointer<AddressBlockValidator> validator = createValidator(Document::Revision::Std14);\r\n    QCOMPARE(validator->hasValidRegisterData(testBlock, addressUnitBits), false);\r\n\r\n    QVector<QString> foundErrors;\r\n    validator->findErrorsIn(foundErrors, testBlock, addressUnitBits, \"test\");\r\n\r\n    QString expectedError = QObject::tr(\"Register data %1 and %2 overlap within address block %3\")\r\n        .arg(registerOne->name()).arg(registerThree->name()).arg(testBlock->name());\r\n\r\n    if (errorIsNotFoundInErrorList(expectedError, foundErrors))\r\n    {\r\n        QFAIL(\"No error message found\");\r\n    }\r\n\r\n    expectedError = QObject::tr(\"Register data %1 and %2 overlap within address block %3\")\r\n        .arg(registerThree->name()).arg(registerTwo->name()).arg(testBlock->name());\r\n    if (errorIsNotFoundInErrorList(expectedError, foundErrors))\r\n    {\r\n        QFAIL(\"No error message found\");\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_AddressBlockValidator::testHasValidMemoryarray2022()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_AddressBlockValidator::testHasValidMemoryarray2022()\r\n{\r\n    QFETCH(QString, dimValue);\r\n    QFETCH(QString, indexVar);\r\n    QFETCH(QString, stride);\r\n    QFETCH(bool, validDim);\r\n    QFETCH(bool, validStride);\r\n \r\n    QSharedPointer<AddressBlockValidator> validator = createValidator(Document::Revision::Std22);\r\n\r\n    QSharedPointer<AddressBlock> testBlock(new AddressBlock(\"champloo\", \"0\"));\r\n    testBlock->setRange(\"50\");\r\n    testBlock->setWidth(\"10\");\r\n\r\n    QSharedPointer<MemoryArray> memArray(new MemoryArray());\r\n    QSharedPointer<MemoryArray::Dimension> testDim(new MemoryArray::Dimension());\r\n\r\n    testDim->indexVar_ = indexVar;\r\n    testDim->value_ = dimValue;\r\n\r\n    memArray->getDimensions()->append(testDim);\r\n    memArray->setStride(stride);\r\n\r\n    testBlock->setMemoryArray(memArray);\r\n\r\n    QCOMPARE(validator->hasValidMemoryArray(testBlock), validDim && validStride);\r\n\r\n    if (!(validDim && validStride))\r\n    {\r\n        QStringList foundErrors;\r\n        validator->findErrorsIn(foundErrors, testBlock, \"8\", \"test\");\r\n\r\n        QString expectedError;\r\n\r\n        if (memArray->getDimensions()->isEmpty())\r\n        {\r\n            expectedError = \"No dimensions defined for memory array in address block champloo within test\";\r\n        }\r\n\r\n        else if (!validDim)\r\n        {\r\n            expectedError = \"One or more dimensions of the memory array in address block champloo within test have an invalid value.\";\r\n        }\r\n\r\n        else if (!validStride)\r\n        {\r\n            expectedError = \"Memory array in address block champloo within test has an invalid stride value.\";\r\n        }\r\n\r\n        if (errorIsNotFoundInErrorList(expectedError, foundErrors))\r\n        {\r\n            QFAIL(\"No error message found\");\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_AddressBlockValidator::testHasValidMemoryarray2022_data()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_AddressBlockValidator::testHasValidMemoryarray2022_data()\r\n{\r\n    QTest::addColumn<QString>(\"dimValue\");\r\n    QTest::addColumn<QString>(\"indexVar\");\r\n    QTest::addColumn<QString>(\"stride\");\r\n    QTest::addColumn<bool>(\"validDim\");\r\n    QTest::addColumn<bool>(\"validStride\");\r\n\r\n    QTest::newRow(\"Dimension with valid values is valid\") << \"8\" << \"i\" << \"8\" << true << true;\r\n    QTest::newRow(\"Dimension without stride is valid\") << \"8\" << \"i\" << \"\" << true << true;\r\n    QTest::newRow(\"Valid expression in dim is valid\") << \"1+1\" << \"index\" << \"\" << true << true;\r\n    QTest::newRow(\"Invalid expression in dim is not valid\") << \"a+a\" << \"index\" << \"\" << false << true;\r\n    QTest::newRow(\"Invalid value in dim is not valid\") << \"-1\" << \"index\" << \"\" << false << true;\r\n    QTest::newRow(\"Valid expression in stride is valid\") << \"1\" << \"index\" << \"1+1\" << true << true;\r\n    QTest::newRow(\"Invalid expression in stride is not valid\") << \"1\" << \"index\" << \"a+a\" << true << false;\r\n    QTest::newRow(\"Invalid value in stride is not valid\") << \"1\" << \"index\" << \"-1\" << true << false;\r\n    QTest::newRow(\"Dimension doesn't exist is invalid\") << \"\" << \"\" << \"\" << false << false;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_AddressBlockValidator::testAccessPolicies2022()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_AddressBlockValidator::testAccessPolicies2022()\r\n{\r\n    QSharedPointer<AddressBlockValidator> validator = createValidator(Document::Revision::Std22);\r\n\r\n    QSharedPointer<AddressBlock> testBlock(new AddressBlock(\"champloo\", \"0\"));\r\n    testBlock->setRange(\"50\");\r\n    testBlock->setWidth(\"10\");\r\n\r\n    QSharedPointer<ModeReference> modeRef1(new ModeReference());\r\n    modeRef1->setPriority(0);\r\n    modeRef1->setReference(\"ref\");\r\n\r\n    QSharedPointer<ModeReference> modeRef2(new ModeReference());\r\n    modeRef2->setPriority(0);\r\n    modeRef2->setReference(\"ref1\");\r\n\r\n    QSharedPointer<Mode> mode1(new Mode(\"ref\"));\r\n    QSharedPointer<Mode> mode2(new Mode(\"ref1\"));\r\n\r\n    QSharedPointer<Component> dummyComponent(new Component(VLNV(\"test\", \"vendor\", \"library\", \"component\", \"1.0\"), Document::Revision::Std22));\r\n    dummyComponent->getModes()->append(mode1);\r\n    dummyComponent->getModes()->append(mode2);\r\n\r\n    validator->componentChange(dummyComponent);\r\n\r\n    QSharedPointer<AccessPolicy> accessPolicy1(new AccessPolicy());\r\n    QSharedPointer<AccessPolicy> accessPolicy2(new AccessPolicy());\r\n    accessPolicy1->getModeReferences()->append(modeRef1);\r\n    accessPolicy2->getModeReferences()->append(modeRef2);\r\n\r\n    testBlock->getAccessPolicies()->append(accessPolicy1);\r\n    testBlock->getAccessPolicies()->append(accessPolicy2);\r\n\r\n    QStringList errors;\r\n\r\n    QStringList possibleErrors(QStringList()\r\n        << \"One or more mode references in access policies of address block champloo within test contain duplicate priority values.\"\r\n        << \"One or more mode references in access policies of address block champloo within test contain duplicate mode reference values.\"\r\n        << \"In address block testBlock in test, multiple access policies are not allowed if one of them lacks a mode reference.\"\r\n        << \"Mode reference in access policies of address block champloo within test has invalid or empty reference value 'ref2'.\"\r\n    );\r\n\r\n    // Test duplicate mode reference priority.\r\n    validator->findErrorsIn(errors, testBlock, \"8\", \"test\");\r\n    QVERIFY(errors.contains(possibleErrors.first()));\r\n    QVERIFY(validator->hasValidAccessPolicies(testBlock) == false);\r\n\r\n    // Test duplicate reference.\r\n    errors.clear();\r\n\r\n    modeRef2->setPriority(1);\r\n    modeRef2->setReference(\"ref\");\r\n\r\n    validator->findErrorsIn(errors, testBlock, \"8\", \"test\");\r\n    QVERIFY(errors.contains(possibleErrors.at(1)));\r\n    QVERIFY(validator->hasValidAccessPolicies(testBlock) == false);\r\n\r\n    // Test invalid (not found in component modes).\r\n    errors.clear();\r\n\r\n    modeRef2->setReference(\"ref2\");\r\n\r\n    validator->findErrorsIn(errors, testBlock, \"8\", \"test\");\r\n    QVERIFY(errors.contains(possibleErrors.back()));\r\n\r\n    QVERIFY(validator->hasValidAccessPolicies(testBlock) == false);\r\n\r\n    // Finally test valid.\r\n    errors.clear();\r\n    modeRef2->setReference(\"ref1\");\r\n    \r\n    validator->findErrorsIn(errors, testBlock, \"8\", \"test\");\r\n    QVERIFY(std::none_of(possibleErrors.cbegin(), possibleErrors.cend(), [&errors](QString const& str)\r\n        {\r\n            return errors.contains(str);\r\n        }));\r\n\r\n    QVERIFY(validator->hasValidAccessPolicies(testBlock));\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_AddressBlockValidator::testRegisterAlignment2022()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_AddressBlockValidator::testRegisterAlignment2022()\r\n{\r\n    QFETCH(QString, registerOffset1);\r\n    QFETCH(QString, registerSize1);\r\n    QFETCH(QString, registerOffset2);\r\n    QFETCH(QString, registerSize2);\r\n    QFETCH(QString, addressBlockWidth);\r\n    QFETCH(bool, misalignmentAllowed);\r\n    QFETCH(bool, isValid);\r\n\r\n    QSharedPointer<AddressBlockValidator> validator = createValidator(Document::Revision::Std22);\r\n\r\n    QSharedPointer<AddressBlock> testBlock(new AddressBlock(\"champloo\", \"0\"));\r\n    testBlock->setRange(\"50\");\r\n    testBlock->setWidth(addressBlockWidth);\r\n    testBlock->setMisalignmentAllowed(misalignmentAllowed);\r\n\r\n    QSharedPointer<Field> testfield(new Field(\"testField\"));\r\n\r\n    QSharedPointer<Register> register1(new Register(\"register1\", registerOffset1, registerSize1));\r\n    QSharedPointer<Register> register2(new Register(\"register2\", registerOffset2, registerSize2));\r\n\r\n    register1->getFields()->append(testfield);\r\n    register2->getFields()->append(testfield);\r\n\r\n    testBlock->getRegisterData()->append(register1);\r\n    testBlock->getRegisterData()->append(register2);\r\n\r\n    QCOMPARE(validator->hasValidRegisterAlignment(testBlock), isValid);\r\n\r\n    if (!isValid)\r\n    {\r\n        QStringList foundErrors;\r\n        validator->findErrorsIn(foundErrors, testBlock, \"8\", \"test\");\r\n\r\n        QString expectedError = QObject::tr(\"Register misalignment set to false for address block %1 within test, \"\r\n            \"where one or more registers are fully or partly offset outside of the address block width.\")\r\n            .arg(testBlock->name());\r\n\r\n        if (errorIsNotFoundInErrorList(expectedError, foundErrors))\r\n        {\r\n            QFAIL(\"No error message found\");\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_AddressBlockValidator::testRegisterAlignment2022_data()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_AddressBlockValidator::testRegisterAlignment2022_data()\r\n{\r\n    QTest::addColumn<QString>(\"registerOffset1\");\r\n    QTest::addColumn<QString>(\"registerSize1\");\r\n    QTest::addColumn<QString>(\"registerOffset2\");\r\n    QTest::addColumn<QString>(\"registerSize2\");\r\n    QTest::addColumn<QString>(\"addressBlockWidth\");\r\n    QTest::addColumn<bool>(\"misalignmentAllowed\");\r\n    QTest::addColumn<bool>(\"isValid\");\r\n\r\n    QTest::newRow(\"Register 1: offset = 0, size = 8; Register 2: offset = 24, size = 8; Address block width = 32, misalignment not allowed => valid\")\r\n        << \"0\" << \"8\" << \"24\" << \"8\" << \"32\" << false << true;\r\n\r\n    QTest::newRow(\"Register 1: offset = 0, size = 8; Register 2: offset = 24, size = 8; Address block width = 32, misalignment allowed => valid\")\r\n        << \"0\" << \"8\" << \"24\" << \"8\" << \"32\" << true << true;\r\n    \r\n    QTest::newRow(\"Register 1: offset = 0, size = 8; Register 2: offset = 30, size = 8; Address block width = 32, misalignment not allowed => invalid\")\r\n        << \"0\" << \"8\" << \"30\" << \"8\" << \"32\" << false << false;\r\n\r\n    QTest::newRow(\"Register 1: offset = 0, size = 8; Register 2: offset = 30, size = 8; Address block width = 32, misalignment allowed => valid\")\r\n        << \"0\" << \"8\" << \"30\" << \"8\" << \"32\" << true << true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_AddressBlockValidator::testStructureIsValid2022()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_AddressBlockValidator::testStructureIsValid2022()\r\n{\r\n    QSharedPointer<AddressBlockValidator> validator = createValidator(Document::Revision::Std22);\r\n\r\n    QSharedPointer<AddressBlock> testBlock(new AddressBlock(\"champloo\", \"0\"));\r\n    testBlock->setRange(\"50\");\r\n    testBlock->setWidth(\"10\");\r\n\r\n    // Also set definition reference.\r\n    testBlock->setAddressBlockDefinitionRef(\"testAddressBlock\");\r\n    testBlock->setTypeDefinitionsRef(\"testTypeDefinitions\");\r\n\r\n    QString expectedError = \"Address block champloo in test must not be explicitly defined while also containing\"\r\n        \" a definition reference.\";\r\n\r\n    QStringList foundErrors;\r\n    validator->findErrorsIn(foundErrors, testBlock, \"8\", \"test\");\r\n    QCOMPARE(foundErrors.size(), 1);\r\n    QVERIFY(foundErrors.contains(expectedError));\r\n    QCOMPARE(validator->hasValidStructure(testBlock), false);\r\n\r\n    foundErrors.clear();\r\n    testBlock->setRange(\"\");\r\n    testBlock->setWidth(\"\");\r\n\r\n    validator->findErrorsIn(foundErrors, testBlock, \"8\", \"test\");\r\n    QCOMPARE(foundErrors.size(), 0);\r\n    QCOMPARE(validator->hasValidStructure(testBlock), true);\r\n\r\n    // Test with usage.\r\n    testBlock->setUsage(General::RESERVED);\r\n    validator->findErrorsIn(foundErrors, testBlock, \"8\", \"test\");\r\n    QCOMPARE(foundErrors.size(), 1);\r\n    QVERIFY(foundErrors.contains(expectedError));\r\n    QCOMPARE(validator->hasValidStructure(testBlock), false);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_AddressBlockValidator::testRegisterDataHaveUniqueNames()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_AddressBlockValidator::testRegisterDataHaveUniqueNames()\r\n{\r\n    // Register and register file names must be unique in an address block or register file.\r\n    QFETCH(QString, registerOneName);\r\n    QFETCH(QString, registerTwoName);\r\n    QFETCH(QString, registerFileOneName);\r\n    QFETCH(QString, registerFileTwoName);\r\n    QFETCH(bool, isValid);\r\n    \r\n    QString addressUnitBits(\"8\");\r\n\r\n    QSharedPointer<AddressBlockValidator> validator = createValidator(Document::Revision::Std22);\r\n\r\n    QSharedPointer<AddressBlock> testBlock(new AddressBlock(\"champloo\", \"0\"));\r\n    testBlock->setRange(\"50\");\r\n    testBlock->setWidth(\"32\");\r\n\r\n    QSharedPointer<Field> testfield(new Field(\"testField\"));\r\n    testfield->setBitOffset(\"0\");\r\n    testfield->setBitWidth(\"8\");\r\n\r\n    QSharedPointer<Register> registerOne(new Register(registerOneName, \"0\", \"8\"));\r\n    QSharedPointer<Register> registerTwo(new Register(registerTwoName, \"1\", \"8\"));\r\n\r\n    registerOne->getFields()->append(testfield);\r\n    registerTwo->getFields()->append(testfield);\r\n\r\n    QSharedPointer<RegisterFile> registerFileOne(new RegisterFile(registerFileOneName, \"2\", \"1\"));\r\n    QSharedPointer<RegisterFile> registerFileTwo(new RegisterFile(registerFileTwoName, \"3\", \"1\"));\r\n    \r\n    testBlock->getRegisterData()->append(registerOne);\r\n    testBlock->getRegisterData()->append(registerTwo);\r\n    testBlock->getRegisterData()->append(registerFileOne);\r\n    testBlock->getRegisterData()->append(registerFileTwo);\r\n\r\n    QCOMPARE(validator->hasValidRegisterData(testBlock, addressUnitBits), isValid);\r\n\r\n    if (!isValid)\r\n    {\r\n        QStringList foundErrors;\r\n        validator->findErrorsIn(foundErrors, testBlock, addressUnitBits, \"test\");\r\n        QStringList expectedErrors;\r\n\r\n        if (registerOneName == registerTwoName)\r\n        {\r\n            expectedErrors.append(QObject::tr(\"Name %1 of registers in addressBlock %2 is not unique.\")\r\n                .arg(registerOneName).arg(testBlock->name()));\r\n        }\r\n        \r\n        if (registerFileOneName == registerFileTwoName)\r\n        {\r\n            expectedErrors.append(QObject::tr(\"Name %1 of register files in addressBlock %2 is not unique.\")\r\n                .arg(registerFileOneName).arg(testBlock->name()));\r\n        }\r\n\r\n        for (auto const& error : expectedErrors)\r\n        {\r\n            if (errorIsNotFoundInErrorList(error, foundErrors))\r\n            {\r\n                QFAIL(\"No error message found\");\r\n            }\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_AddressBlockValidator::testRegisterDataHaveUniqueNames_data()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_AddressBlockValidator::testRegisterDataHaveUniqueNames_data()\r\n{\r\n    QTest::addColumn<QString>(\"registerOneName\");\r\n    QTest::addColumn<QString>(\"registerTwoName\");\r\n    QTest::addColumn<QString>(\"registerFileOneName\");\r\n    QTest::addColumn<QString>(\"registerFileTwoName\");\r\n    QTest::addColumn<bool>(\"isValid\");\r\n\r\n    QTest::addRow(\"Unique register and register file names is valid\") << \"reg1\" << \"reg2\" << \"regFile1\" << \"regFile2\" << true;\r\n    QTest::addRow(\"Non-unique register and unique register file names is invalid\") << \"reg\" << \"reg\" << \"regFile1\" << \"regFile2\" << false;\r\n    QTest::addRow(\"Unique register and non-unique register file names is invalid\") << \"reg1\" << \"reg2\" << \"regFile\" << \"regFile\" << false;\r\n    QTest::addRow(\"Non-unique register and non-unique register file names is invalid\") << \"reg\" << \"reg\" << \"regFile\" << \"regFile\" << false;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_AddressBlockValidator::errorIsNotFoundInErrorList()\r\n//-----------------------------------------------------------------------------\r\nbool tst_AddressBlockValidator::errorIsNotFoundInErrorList(QString const& expectedError,\r\n    QVector<QString> errorList)\r\n{\r\n    if (!errorList.contains(expectedError))\r\n    {\r\n        qDebug() << \"The following error:\" << Qt::endl << expectedError << Qt::endl << \"was not found in error list:\";\r\n        foreach(QString error, errorList)\r\n        {\r\n            qDebug() << error;\r\n        }\r\n        return true;\r\n    }\r\n\r\n    return false;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_AddressBlockValidator::createValidator()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<AddressBlockValidator> tst_AddressBlockValidator::createValidator(Document::Revision revision)\r\n{\r\n    QSharedPointer<ExpressionParser> parser(new SystemVerilogExpressionParser());\r\n    QSharedPointer<ParameterValidator> parameterValidator (\r\n        new ParameterValidator(parser, QSharedPointer<QList<QSharedPointer<Choice> > > (), revision));\r\n    QSharedPointer<EnumeratedValueValidator> enumValidator (new EnumeratedValueValidator(parser));\r\n    QSharedPointer<FieldValidator> fieldValidator (new FieldValidator(parser, enumValidator, parameterValidator));\r\n    QSharedPointer<RegisterValidator> registerValidator (new RegisterValidator(parser, fieldValidator,\r\n        parameterValidator));\r\n    QSharedPointer<RegisterFileValidator> registerFileValidator (new RegisterFileValidator(parser, registerValidator,\r\n        parameterValidator, revision));\r\n   \r\n    QSharedPointer<AddressBlockValidator> validator(new AddressBlockValidator(parser, registerValidator, registerFileValidator, parameterValidator, revision));\r\n    return validator;\r\n}\r\n\r\nQTEST_APPLESS_MAIN(tst_AddressBlockValidator)\r\n\r\n#include \"tst_AddressBlockValidator.moc\"\r\n"
  },
  {
    "path": "tests/IPXACTmodels/Component/tst_AddressBlockValidator.pri",
    "content": "# ----------------------------------------------------\r\n# This file is generated by the Qt Visual Studio Tools.\r\n# ------------------------------------------------------\r\n\r\n# This is a reminder that you are using a generated .pro file.\r\n# Remove it when you are finished editing this file.\r\nmessage(\"You are running qmake on a generated .pro file. This may not work!\")\r\n\r\n\r\nSOURCES += ./tst_AddressBlockValidator.cpp\r\n"
  },
  {
    "path": "tests/IPXACTmodels/Component/tst_AddressBlockValidator.pro",
    "content": "#-----------------------------------------------------------------------------\r\n# File: tst_AddressBlockValidator.pro\r\n#-----------------------------------------------------------------------------\r\n# Project: Kactus 2\r\n# Author: Mikko Teuho\r\n# Date: 23.11.2015\r\n#\r\n# Description:\r\n# Qt project file template for running unit tests for AddressBlockValidator.\r\n#-----------------------------------------------------------------------------\r\n\r\nTEMPLATE = app\r\n\r\nTARGET = tst_AddressBlockValidator\r\n\r\nQT += core gui xml testlib\r\n\r\nCONFIG += c++11 testcase console\r\n\r\nlinux-g++ | linux-g++-64 | linux-g++-32 {\r\n LIBS += -L../../../executable \\\r\n     -lIPXACTmodels -lKactusAPI\r\n}\r\n\r\nwin64 | win32 {\r\n LIBS += -L../../../executable \\\r\n     -lIPXACTmodelsd -lKactusAPId\r\n}\r\n\r\nINCLUDEPATH += $$DESTDIR\r\nINCLUDEPATH += ../../../\r\nINCLUDEPATH += ../../../KactusAPI/include\r\n\r\nDEPENDPATH += .\r\nDEPENDPATH += ../../../\r\n\r\nOBJECTS_DIR += $$DESTDIR\r\n\r\nMOC_DIR += ./generatedFiles\r\nUI_DIR += ./generatedFiles\r\nRCC_DIR += ./generatedFiles\r\ninclude(tst_AddressBlockValidator.pri)\r\n"
  },
  {
    "path": "tests/IPXACTmodels/Component/tst_AddressBlockWriter.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: tst_AddressBlockWriter.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 29.09.2015\r\n//\r\n// Description:\r\n// Unit test for class AddressBlockWriter.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include <IPXACTmodels/Component/AddressBlockWriter.h>\r\n#include <IPXACTmodels/Component/AddressBlock.h>\r\n\r\n#include <IPXACTmodels/Component/Field.h>\r\n#include <IPXACTmodels/Component/Register.h>\r\n#include <IPXACTmodels/Component/RegisterFile.h>\r\n#include <IPXACTmodels/Component/MemoryArray.h>\r\n\r\n#include <IPXACTmodels/common/Parameter.h>\r\n#include <IPXACTmodels/common/GenericVendorExtension.h>\r\n\r\n#include <QtTest>\r\n\r\nclass tst_AddressBlockWriter : public QObject\r\n{\r\n    Q_OBJECT\r\n\r\npublic:\r\n    tst_AddressBlockWriter();\r\n\r\nprivate slots:\r\n\r\n    void initTestCase();\r\n    void cleanupTestCase();\r\n    void init();\r\n    void cleanup();\r\n\r\n    void writeSimpleAddressBlock();\r\n    void writeIsPresent();\r\n    void writeTypeIdentifier();\r\n    \r\n    void writeUsage();\r\n    void writeVolatile();\r\n    void writeAccess();\r\n    void writeParameters();\r\n\r\n    void writeRegisterData();\r\n\r\n    void writeMisalignmentAllowed2022();\r\n    void writeMemoryArray2022();\r\n    void writeAddressBlockDefinitionRef2022();\r\n    void writeAccessPolicies2022();\r\n\r\n    void writeVendorExtensions();\r\n\r\nprivate:\r\n\r\n    QSharedPointer<AddressBlock> testAddressBlock_;\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_AddressBlockWriter::tst_AddressBlockWriter()\r\n//-----------------------------------------------------------------------------\r\ntst_AddressBlockWriter::tst_AddressBlockWriter():\r\ntestAddressBlock_()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_AddressBlockWriter::initTestCase()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_AddressBlockWriter::initTestCase()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_AddressBlockWriter::cleanupTestCase()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_AddressBlockWriter::cleanupTestCase()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_AddressBlockWriter::init()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_AddressBlockWriter::init()\r\n{\r\n    testAddressBlock_ = QSharedPointer<AddressBlock>(new AddressBlock(\"testBlock\", \"StarControl\"));\r\n    testAddressBlock_->setRange(\"Kzer-Za\");\r\n    testAddressBlock_->setWidth(\"Kohr-Ah\");\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_AddressBlockWriter::cleanup()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_AddressBlockWriter::cleanup()\r\n{\r\n    testAddressBlock_.clear();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_AddressBlockWriter::()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_AddressBlockWriter::writeSimpleAddressBlock()\r\n{\r\n    QString output;\r\n    QXmlStreamWriter xmlStreamWriter(&output);\r\n\r\n    testAddressBlock_->setDisplayName(\"displayed\");\r\n    testAddressBlock_->setDescription(\"described\");\r\n\r\n    QString expectedOutput(\r\n        \"<ipxact:addressBlock>\"\r\n            \"<ipxact:name>testBlock</ipxact:name>\"\r\n            \"<ipxact:displayName>displayed</ipxact:displayName>\"\r\n            \"<ipxact:description>described</ipxact:description>\"\r\n            \"<ipxact:baseAddress>StarControl</ipxact:baseAddress>\"\r\n            \"<ipxact:range>Kzer-Za</ipxact:range>\"\r\n            \"<ipxact:width>Kohr-Ah</ipxact:width>\"\r\n        \"</ipxact:addressBlock>\"\r\n        );\r\n\r\n    AddressBlockWriter::writeAddressBlock(xmlStreamWriter, testAddressBlock_, Document::Revision::Std14);\r\n    QCOMPARE(output, expectedOutput);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_AddressBlockWriter::writeIsPresent()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_AddressBlockWriter::writeIsPresent()\r\n{\r\n    QString output;\r\n    QXmlStreamWriter xmlStreamWriter(&output);\r\n\r\n    testAddressBlock_->setIsPresent(\"presence\");\r\n\r\n    QString expectedOutput(\r\n        \"<ipxact:addressBlock>\"\r\n            \"<ipxact:name>testBlock</ipxact:name>\"\r\n            \"<ipxact:isPresent>presence</ipxact:isPresent>\"\r\n            \"<ipxact:baseAddress>StarControl</ipxact:baseAddress>\"\r\n            \"<ipxact:range>Kzer-Za</ipxact:range>\"\r\n            \"<ipxact:width>Kohr-Ah</ipxact:width>\"\r\n        \"</ipxact:addressBlock>\"\r\n        );\r\n\r\n    AddressBlockWriter::writeAddressBlock(xmlStreamWriter, testAddressBlock_, Document::Revision::Std14);\r\n    QCOMPARE(output, expectedOutput);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_AddressBlockWriter::writeTypeIdentifier()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_AddressBlockWriter::writeTypeIdentifier()\r\n{\r\n    QString output;\r\n    QXmlStreamWriter xmlStreamWriter(&output);\r\n\r\n    testAddressBlock_->setTypeIdentifier(\"identifier\");\r\n\r\n    QString expectedOutput(\r\n        \"<ipxact:addressBlock>\"\r\n            \"<ipxact:name>testBlock</ipxact:name>\"\r\n            \"<ipxact:baseAddress>StarControl</ipxact:baseAddress>\"\r\n            \"<ipxact:typeIdentifier>identifier</ipxact:typeIdentifier>\"\r\n            \"<ipxact:range>Kzer-Za</ipxact:range>\"\r\n            \"<ipxact:width>Kohr-Ah</ipxact:width>\"\r\n        \"</ipxact:addressBlock>\"\r\n        );\r\n\r\n    AddressBlockWriter::writeAddressBlock(xmlStreamWriter, testAddressBlock_, Document::Revision::Std14);\r\n    QCOMPARE(output, expectedOutput);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_AddressBlockWriter::writeUsage()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_AddressBlockWriter::writeUsage()\r\n{\r\n    QString output;\r\n    QXmlStreamWriter xmlStreamWriter(&output);\r\n\r\n    testAddressBlock_->setUsage(General::REGISTER);\r\n\r\n    QString expectedOutput(\r\n        \"<ipxact:addressBlock>\"\r\n            \"<ipxact:name>testBlock</ipxact:name>\"\r\n            \"<ipxact:baseAddress>StarControl</ipxact:baseAddress>\"\r\n            \"<ipxact:range>Kzer-Za</ipxact:range>\"\r\n            \"<ipxact:width>Kohr-Ah</ipxact:width>\"\r\n            \"<ipxact:usage>register</ipxact:usage>\"\r\n        \"</ipxact:addressBlock>\"\r\n        );\r\n\r\n    AddressBlockWriter::writeAddressBlock(xmlStreamWriter, testAddressBlock_, Document::Revision::Std14);\r\n    QCOMPARE(output, expectedOutput);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_AddressBlockWriter::writeVolatile()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_AddressBlockWriter::writeVolatile()\r\n{\r\n    QString output;\r\n    QXmlStreamWriter xmlStreamWriter(&output);\r\n\r\n    testAddressBlock_->setVolatile(true);\r\n\r\n    QString expectedOutput(\r\n        \"<ipxact:addressBlock>\"\r\n            \"<ipxact:name>testBlock</ipxact:name>\"\r\n            \"<ipxact:baseAddress>StarControl</ipxact:baseAddress>\"\r\n            \"<ipxact:range>Kzer-Za</ipxact:range>\"\r\n            \"<ipxact:width>Kohr-Ah</ipxact:width>\"\r\n            \"<ipxact:volatile>true</ipxact:volatile>\"\r\n        \"</ipxact:addressBlock>\"\r\n        );\r\n\r\n    AddressBlockWriter::writeAddressBlock(xmlStreamWriter, testAddressBlock_, Document::Revision::Std14);\r\n    QCOMPARE(output, expectedOutput);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_AddressBlockWriter::writeAccess()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_AddressBlockWriter::writeAccess()\r\n{\r\n    QString output;\r\n    QXmlStreamWriter xmlStreamWriter(&output);\r\n\r\n    testAddressBlock_->setAccess(AccessTypes::WRITEONCE);\r\n\r\n    QString expectedOutput(\r\n        \"<ipxact:addressBlock>\"\r\n            \"<ipxact:name>testBlock</ipxact:name>\"\r\n            \"<ipxact:baseAddress>StarControl</ipxact:baseAddress>\"\r\n            \"<ipxact:range>Kzer-Za</ipxact:range>\"\r\n            \"<ipxact:width>Kohr-Ah</ipxact:width>\"\r\n            \"<ipxact:access>writeOnce</ipxact:access>\"\r\n        \"</ipxact:addressBlock>\"\r\n        );\r\n\r\n    AddressBlockWriter::writeAddressBlock(xmlStreamWriter, testAddressBlock_, Document::Revision::Std14);\r\n    QCOMPARE(output, expectedOutput);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_AddressBlockWriter::writeParameters()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_AddressBlockWriter::writeParameters()\r\n{\r\n    QString output;\r\n    QXmlStreamWriter xmlStreamWriter(&output);\r\n\r\n    QSharedPointer<Parameter> testParameter(new Parameter());\r\n    testParameter->setValueId(\"testID\");\r\n    testParameter->setName(\"testParameter\");\r\n    testParameter->setValue(\"1\");\r\n\r\n    testAddressBlock_->getParameters()->append(testParameter);\r\n\r\n    QString expectedOutput(\r\n        \"<ipxact:addressBlock>\"\r\n            \"<ipxact:name>testBlock</ipxact:name>\"\r\n            \"<ipxact:baseAddress>StarControl</ipxact:baseAddress>\"\r\n            \"<ipxact:range>Kzer-Za</ipxact:range>\"\r\n            \"<ipxact:width>Kohr-Ah</ipxact:width>\"\r\n            \"<ipxact:parameters>\"\r\n                \"<ipxact:parameter parameterId=\\\"testID\\\">\"\r\n                    \"<ipxact:name>testParameter</ipxact:name>\"\r\n                    \"<ipxact:value>1</ipxact:value>\"\r\n                \"</ipxact:parameter>\"\r\n            \"</ipxact:parameters>\"\r\n        \"</ipxact:addressBlock>\"\r\n        );\r\n\r\n    AddressBlockWriter::writeAddressBlock(xmlStreamWriter, testAddressBlock_, Document::Revision::Std14);\r\n    QCOMPARE(output, expectedOutput);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_AddressBlockWriter::writeRegisterData()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_AddressBlockWriter::writeRegisterData()\r\n{\r\n    QString output;\r\n    QXmlStreamWriter xmlStreamWriter(&output);\r\n\r\n    QSharedPointer<Field> simpleField(new Field(\"simpleField\"));\r\n    simpleField->setBitOffset(\"fieldOffset\");\r\n    simpleField->setBitWidth(\"fieldWidth\");\r\n\r\n    QSharedPointer<Register> testRegister (new Register(\"testRegister\", \"offset\", \"10\"));\r\n    testRegister->setDisplayName(\"displayed\");\r\n    testRegister->setDescription(\"described\");\r\n    testRegister->getFields()->append(simpleField);\r\n\r\n    QSharedPointer<RegisterFile> containedRegisterFile\r\n        (new RegisterFile(\"contained\", \"containedOffset\", \"containedRange\"));\r\n\r\n    testAddressBlock_->getRegisterData()->append(testRegister);\r\n    testAddressBlock_->getRegisterData()->append(containedRegisterFile);\r\n\r\n    QString expectedOutput(\r\n        \"<ipxact:addressBlock>\"\r\n            \"<ipxact:name>testBlock</ipxact:name>\"\r\n            \"<ipxact:baseAddress>StarControl</ipxact:baseAddress>\"\r\n            \"<ipxact:range>Kzer-Za</ipxact:range>\"\r\n            \"<ipxact:width>Kohr-Ah</ipxact:width>\"\r\n            \"<ipxact:register>\"\r\n                \"<ipxact:name>testRegister</ipxact:name>\"\r\n                \"<ipxact:displayName>displayed</ipxact:displayName>\"\r\n                \"<ipxact:description>described</ipxact:description>\"\r\n                \"<ipxact:addressOffset>offset</ipxact:addressOffset>\"\r\n                \"<ipxact:size>10</ipxact:size>\"\r\n                \"<ipxact:field>\"\r\n                    \"<ipxact:name>simpleField</ipxact:name>\"\r\n                    \"<ipxact:bitOffset>fieldOffset</ipxact:bitOffset>\"\r\n                    \"<ipxact:bitWidth>fieldWidth</ipxact:bitWidth>\"\r\n                \"</ipxact:field>\"\r\n            \"</ipxact:register>\"\r\n            \"<ipxact:registerFile>\"\r\n                \"<ipxact:name>contained</ipxact:name>\"\r\n                \"<ipxact:addressOffset>containedOffset</ipxact:addressOffset>\"\r\n                \"<ipxact:range>containedRange</ipxact:range>\"\r\n            \"</ipxact:registerFile>\"\r\n        \"</ipxact:addressBlock>\"\r\n        );\r\n\r\n    AddressBlockWriter::writeAddressBlock(xmlStreamWriter, testAddressBlock_, Document::Revision::Std14);\r\n    QCOMPARE(output, expectedOutput);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_AddressBlockWriter::writeMisalignmentAllowed2022()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_AddressBlockWriter::writeMisalignmentAllowed2022()\r\n{\r\n    QString output;\r\n    QXmlStreamWriter xmlStreamWriter(&output);\r\n\r\n    testAddressBlock_->setMisalignmentAllowed(false);\r\n\r\n    QString expectedOutput(\r\n        \"<ipxact:addressBlock misalignmentAllowed=\\\"false\\\">\"\r\n            \"<ipxact:name>testBlock</ipxact:name>\"\r\n            \"<ipxact:baseAddress>StarControl</ipxact:baseAddress>\"\r\n            \"<ipxact:range>Kzer-Za</ipxact:range>\"\r\n            \"<ipxact:width>Kohr-Ah</ipxact:width>\"\r\n        \"</ipxact:addressBlock>\"\r\n        );\r\n\r\n    AddressBlockWriter::writeAddressBlock(xmlStreamWriter, testAddressBlock_, Document::Revision::Std22);\r\n    QCOMPARE(output, expectedOutput);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_AddressBlockWriter::writeMemoryArray2022()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_AddressBlockWriter::writeMemoryArray2022()\r\n{\r\n    QString output;\r\n    QXmlStreamWriter xmlStreamWriter(&output);\r\n\r\n    QSharedPointer<MemoryArray> memArray(new MemoryArray());\r\n    QSharedPointer<MemoryArray::Dimension> testDim(new MemoryArray::Dimension());\r\n    testDim->indexVar_ = \"testVar\";\r\n    testDim->value_ = \"2\";\r\n\r\n    memArray->getDimensions()->append(testDim);\r\n    memArray->setStride(\"4\");\r\n\r\n    testAddressBlock_->setMemoryArray(memArray);\r\n\r\n    QString expectedOutput(\r\n        \"<ipxact:addressBlock>\"\r\n            \"<ipxact:name>testBlock</ipxact:name>\"\r\n            \"<ipxact:array>\"\r\n                \"<ipxact:dim indexVar=\\\"testVar\\\">2</ipxact:dim>\"\r\n                \"<ipxact:stride>4</ipxact:stride>\"\r\n            \"</ipxact:array>\"\r\n            \"<ipxact:baseAddress>StarControl</ipxact:baseAddress>\"\r\n            \"<ipxact:range>Kzer-Za</ipxact:range>\"\r\n            \"<ipxact:width>Kohr-Ah</ipxact:width>\"\r\n        \"</ipxact:addressBlock>\"\r\n        );\r\n\r\n    AddressBlockWriter::writeAddressBlock(xmlStreamWriter, testAddressBlock_, Document::Revision::Std22);\r\n    QCOMPARE(output, expectedOutput);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_AddressBlockWriter::writeAddressBlockDefinitionRef2022()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_AddressBlockWriter::writeAddressBlockDefinitionRef2022()\r\n{\r\n    QString output;\r\n    QXmlStreamWriter xmlStreamWriter(&output);\r\n\r\n    testAddressBlock_->setWidth(\"\");\r\n    testAddressBlock_->setRange(\"\");\r\n\r\n    testAddressBlock_->setAddressBlockDefinitionRef(\"someOtherAddressBlock\");\r\n    testAddressBlock_->setTypeDefinitionsRef(\"someTypeDefinitions\");\r\n\r\n    QString expectedOutput(\r\n        \"<ipxact:addressBlock>\"\r\n            \"<ipxact:name>testBlock</ipxact:name>\"\r\n            \"<ipxact:baseAddress>StarControl</ipxact:baseAddress>\"\r\n            \"<ipxact:addressBlockDefinitionRef typeDefinitions=\\\"someTypeDefinitions\\\">someOtherAddressBlock</ipxact:addressBlockDefinitionRef>\"\r\n        \"</ipxact:addressBlock>\"\r\n        );\r\n\r\n    AddressBlockWriter::writeAddressBlock(xmlStreamWriter, testAddressBlock_, Document::Revision::Std22);\r\n    QCOMPARE(output, expectedOutput);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_AddressBlockWriter::writeAccessPolicies2022()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_AddressBlockWriter::writeAccessPolicies2022()\r\n{\r\n    QString output;\r\n    QXmlStreamWriter xmlStreamWriter(&output);\r\n\r\n    QSharedPointer<AccessPolicy> testAccessPolicy1(new AccessPolicy());\r\n    QSharedPointer<AccessPolicy> testAccessPolicy2(new AccessPolicy());\r\n\r\n    QSharedPointer<ModeReference> modeRef1(new ModeReference());\r\n    QSharedPointer<ModeReference> modeRef2(new ModeReference());\r\n\r\n    modeRef1->setPriority(1);\r\n    modeRef1->setReference(\"testMode\");\r\n    \r\n    modeRef2->setPriority(2);\r\n    modeRef2->setReference(\"testMode2\");\r\n\r\n    testAccessPolicy1->getModeReferences()->append(modeRef1);\r\n    testAccessPolicy1->setAccess(AccessTypes::READ_ONLY);\r\n\r\n    testAccessPolicy2->getModeReferences()->append(modeRef2);\r\n\r\n    testAddressBlock_->getAccessPolicies()->append(testAccessPolicy1);\r\n    testAddressBlock_->getAccessPolicies()->append(testAccessPolicy2);\r\n\r\n    QString expectedOutput(\r\n        \"<ipxact:addressBlock>\"\r\n            \"<ipxact:name>testBlock</ipxact:name>\"\r\n            \"<ipxact:baseAddress>StarControl</ipxact:baseAddress>\"\r\n            \"<ipxact:range>Kzer-Za</ipxact:range>\"\r\n            \"<ipxact:width>Kohr-Ah</ipxact:width>\"\r\n            \"<ipxact:accessPolicies>\"\r\n                \"<ipxact:accessPolicy>\"\r\n                    \"<ipxact:modeRef priority=\\\"1\\\">testMode</ipxact:modeRef>\"\r\n                    \"<ipxact:access>read-only</ipxact:access>\"\r\n                \"</ipxact:accessPolicy>\"\r\n                \"<ipxact:accessPolicy>\"\r\n                    \"<ipxact:modeRef priority=\\\"2\\\">testMode2</ipxact:modeRef>\"\r\n                \"</ipxact:accessPolicy>\"\r\n            \"</ipxact:accessPolicies>\"\r\n        \"</ipxact:addressBlock>\"\r\n        );\r\n\r\n    AddressBlockWriter::writeAddressBlock(xmlStreamWriter, testAddressBlock_, Document::Revision::Std22);\r\n    QCOMPARE(output, expectedOutput);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_AddressBlockWriter::writeVendorExtensions()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_AddressBlockWriter::writeVendorExtensions()\r\n{\r\n    QString output;\r\n    QXmlStreamWriter xmlStreamWriter(&output);\r\n\r\n    QDomDocument document;\r\n    QDomElement extensionNode = document.createElement(\"testExtension\");\r\n    extensionNode.setAttribute(\"testExtensionAttribute\", \"extension\");\r\n    extensionNode.appendChild(document.createTextNode(\"testValue\"));\r\n\r\n    QSharedPointer<GenericVendorExtension> testExtension(new GenericVendorExtension(extensionNode));\r\n\r\n    testAddressBlock_->getVendorExtensions()->append(testExtension);\r\n\r\n    QString expectedOutput(\r\n        \"<ipxact:addressBlock>\"\r\n            \"<ipxact:name>testBlock</ipxact:name>\"\r\n            \"<ipxact:baseAddress>StarControl</ipxact:baseAddress>\"\r\n            \"<ipxact:range>Kzer-Za</ipxact:range>\"\r\n            \"<ipxact:width>Kohr-Ah</ipxact:width>\"\r\n            \"<ipxact:vendorExtensions>\"\r\n                \"<testExtension testExtensionAttribute=\\\"extension\\\">testValue</testExtension>\"\r\n            \"</ipxact:vendorExtensions>\"\r\n        \"</ipxact:addressBlock>\"\r\n        );\r\n\r\n    AddressBlockWriter::writeAddressBlock(xmlStreamWriter, testAddressBlock_, Document::Revision::Std14);\r\n    QCOMPARE(output, expectedOutput);\r\n}\r\n\r\nQTEST_APPLESS_MAIN(tst_AddressBlockWriter)\r\n\r\n#include \"tst_AddressBlockWriter.moc\"\r\n"
  },
  {
    "path": "tests/IPXACTmodels/Component/tst_AddressBlockWriter.pri",
    "content": "# ----------------------------------------------------\r\n# This file is generated by the Qt Visual Studio Tools.\r\n# ------------------------------------------------------\r\n\r\nSOURCES += ./tst_AddressBlockWriter.cpp \r\n    "
  },
  {
    "path": "tests/IPXACTmodels/Component/tst_AddressBlockWriter.pro",
    "content": "#-----------------------------------------------------------------------------\r\n# File: tst_AddressBlockWriter.pro\r\n#-----------------------------------------------------------------------------\r\n# Project: Kactus 2\r\n# Author: Mikko Teuho\r\n# Date: 29.09.2015\r\n#\r\n# Description:\r\n# Qt project file template for running unit tests for AddressBlockWriter.\r\n#-----------------------------------------------------------------------------\r\n\r\nTEMPLATE = app\r\n\r\nTARGET = tst_AddressBlockWriter\r\n\r\nQT += core xml testlib\r\nQT -= gui\r\n\r\nCONFIG += c++11 testcase console\r\n\r\nlinux-g++ | linux-g++-64 | linux-g++-32 {\r\n LIBS += -L../../../executable \\\r\n     -lIPXACTmodels\r\n\r\n}\r\nwin64 | win32 {\r\n LIBS += -L../../../executable \\\r\n     -lIPXACTmodelsd\r\n}\r\n\r\nINCLUDEPATH += $$DESTDIR\r\nINCLUDEPATH += ../../../\r\n\r\nDEPENDPATH += .\r\nDEPENDPATH += ../../../\r\n\r\nOBJECTS_DIR += $$DESTDIR\r\n\r\nMOC_DIR += ./generatedFiles\r\nUI_DIR += ./generatedFiles\r\nRCC_DIR += ./generatedFiles\r\ninclude(tst_AddressBlockWriter.pri)\r\n"
  },
  {
    "path": "tests/IPXACTmodels/Component/tst_AddressSpaceReader.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: tst_AddressSpaceReader.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Janne Virtanen\r\n// Date: 30.09.2015\r\n//\r\n// Description:\r\n// Unit test for class AddressSpaceReader.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include <IPXACTmodels/Component/AddressSpaceReader.h>\r\n#include <IPXACTmodels/common/VendorExtension.h>\r\n\r\n#include <IPXACTmodels/Component/AddressBlock.h>\r\n#include <IPXACTmodels/Component/Register.h>\r\n#include <IPXACTmodels/Component/RegisterFile.h>\r\n#include <IPXACTmodels/Component/Field.h>\r\n\r\n#include <QtTest>\r\n\r\nclass tst_AddressSpaceReader : public QObject\r\n{\r\n    Q_OBJECT\r\n\r\npublic:\r\n    tst_AddressSpaceReader();\r\n\r\nprivate slots:\r\n\r\n    void testReadSimpleAddressSpace();\r\n\tvoid testReadIsPresent();\r\n\tvoid testReadParameters();\r\n\tvoid testReadBlockSize();\r\n\tvoid testReadAddressUnitBits();\r\n\tvoid testReadVendorExtensions();\r\n\tvoid testReadSegments();\r\n\tvoid readAddressBlocks();\r\n\tvoid testReadNewStd();\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_AddressSpaceReader::tst_AddressSpaceReader()\r\n//-----------------------------------------------------------------------------\r\ntst_AddressSpaceReader::tst_AddressSpaceReader()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_AddressSpaceReader::testReadSimpleAddressSpace()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_AddressSpaceReader::testReadSimpleAddressSpace()\r\n{\r\n    QString documentContent(\r\n        \"<ipxact:addressSpace>\"\r\n            \"<ipxact:name>AddressSpace</ipxact:name>\"\r\n            \"<ipxact:displayName>viewDisplay</ipxact:displayName>\"\r\n            \"<ipxact:description>viewDescription</ipxact:description>\"\r\n        \"</ipxact:addressSpace>\"\r\n        );\r\n\r\n\r\n    QDomDocument document;\r\n    document.setContent(documentContent);\r\n\r\n    QDomNode AddressSpaceNode = document.firstChildElement(\"ipxact:addressSpace\");\r\n\r\n    QSharedPointer<AddressSpace> testAddressSpace = AddressSpaceReader::createAddressSpaceFrom(AddressSpaceNode, Document::Revision::Std14);\r\n\r\n    QCOMPARE(testAddressSpace->name(), QString(\"AddressSpace\"));\r\n    QCOMPARE(testAddressSpace->displayName(), QString(\"viewDisplay\"));\r\n    QCOMPARE(testAddressSpace->description(), QString(\"viewDescription\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_AddressSpaceReader::testReadIsPresent()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_AddressSpaceReader::testReadIsPresent()\r\n{\r\n    QString documentContent(\r\n        \"<ipxact:addressSpace>\"\r\n            \"<ipxact:name>testAddressSpace</ipxact:name>\"\r\n            \"<ipxact:isPresent>4-3</ipxact:isPresent>\"\r\n        \"</ipxact:addressSpace>\"\r\n        );\r\n\r\n\r\n    QDomDocument document;\r\n    document.setContent(documentContent);\r\n\r\n    QDomNode AddressSpaceNode = document.firstChildElement(\"ipxact:addressSpace\");\r\n\r\n    QSharedPointer<AddressSpace> testAddressSpace = AddressSpaceReader::createAddressSpaceFrom(AddressSpaceNode, Document::Revision::Std14);\r\n\r\n    QCOMPARE(testAddressSpace->name(), QString(\"testAddressSpace\"));\r\n    QCOMPARE(testAddressSpace->getIsPresent(), QString(\"4-3\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_AddressSpaceReader::testReadParameters()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_AddressSpaceReader::testReadParameters()\r\n{\r\n\tQString documentContent(\r\n\t\t\"<ipxact:addressSpace>\"\r\n        \"<ipxact:parameters>\"\r\n        \"<ipxact:parameter parameterId=\\\"joq\\\" prompt=\\\"Parm 1\\\" type=\\\"shortint\\\" resolve=\\\"user\\\">\"\r\n        \"<ipxact:name>Esko</ipxact:name>\"\r\n        \"<ipxact:description>First generator parameter.</ipxact:description>\"\r\n        \"<ipxact:value>5</ipxact:value>\"\r\n        \"</ipxact:parameter>\"\r\n        \"<ipxact:parameter parameterId=\\\"ev0\\\" prompt=\\\"Parm 1\\\" type=\\\"shortint\\\" resolve=\\\"user\\\">\"\r\n        \"<ipxact:name>Mikko</ipxact:name>\"\r\n        \"<ipxact:description>First generator parameter.</ipxact:description>\"\r\n        \"<ipxact:value>1337</ipxact:value>\"\r\n        \"</ipxact:parameter>\"\r\n        \"</ipxact:parameters>\"\r\n\t\t\"</ipxact:addressSpace>\"\r\n\t\t);\r\n\r\n\tQDomDocument document;\r\n\tdocument.setContent(documentContent);\r\n\r\n\tQDomNode AddressSpaceNode = document.firstChildElement(\"ipxact:addressSpace\");\r\n\r\n\tQSharedPointer<AddressSpace> testAddressSpace = AddressSpaceReader::createAddressSpaceFrom(AddressSpaceNode, Document::Revision::Std14);\r\n\r\n\tQCOMPARE(testAddressSpace->getParameters()->size(), 2);\r\n\tQCOMPARE(testAddressSpace->getParameters()->first()->name(), QString(\"Esko\"));\r\n\tQCOMPARE(testAddressSpace->getParameters()->first()->getValueId(), QString(\"joq\"));\r\n\tQCOMPARE(testAddressSpace->getParameters()->first()->getValue(), QString(\"5\"));\r\n\tQCOMPARE(testAddressSpace->getParameters()->last()->name(), QString(\"Mikko\"));\r\n\tQCOMPARE(testAddressSpace->getParameters()->last()->getValueId(), QString(\"ev0\"));\r\n\tQCOMPARE(testAddressSpace->getParameters()->last()->getValue(), QString(\"1337\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_AddressSpaceReader::testReadBlockSize()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_AddressSpaceReader::testReadBlockSize()\r\n{\r\n\tQString documentContent(\r\n\t\t\"<ipxact:addressSpace>\"\r\n\t\t\"<ipxact:range>testRange</ipxact:range>\"\r\n\t\t\"<ipxact:width>123</ipxact:width>\"\r\n\t\t\"</ipxact:addressSpace>\"\r\n\t\t);\r\n\r\n\r\n\tQDomDocument document;\r\n\tdocument.setContent(documentContent);\r\n\r\n\tQDomNode AddressSpaceNode = document.firstChildElement(\"ipxact:addressSpace\");\r\n\r\n\tQSharedPointer<AddressSpace> testAddressSpace = AddressSpaceReader::createAddressSpaceFrom(AddressSpaceNode, Document::Revision::Std14);\r\n\r\n    QCOMPARE(testAddressSpace->getRange(), QString(\"testRange\"));\r\n\tQCOMPARE(testAddressSpace->getWidth(), QString(\"123\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_AddressSpaceReader::testReadAddressUnitBits()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_AddressSpaceReader::testReadAddressUnitBits()\r\n{\r\n\tQString documentContent(\r\n\t\t\"<ipxact:addressSpace>\"\r\n\t\t\"<ipxact:addressUnitBits>15</ipxact:addressUnitBits>\"\r\n\t\t\"</ipxact:addressSpace>\"\r\n\t\t);\r\n\r\n\r\n\tQDomDocument document;\r\n\tdocument.setContent(documentContent);\r\n\r\n\tQDomNode AddressSpaceNode = document.firstChildElement(\"ipxact:addressSpace\");\r\n\r\n\tQSharedPointer<AddressSpace> testAddressSpace = AddressSpaceReader::createAddressSpaceFrom(AddressSpaceNode, Document::Revision::Std14);\r\n\r\n\tQCOMPARE(testAddressSpace->getAddressUnitBits(), QString(\"15\"));\r\n\r\n\t// No AUB = default 8 bits\r\n\tQString documentContentNoAUB(\r\n        \"<ipxact:addressSpace>\"\r\n        \"</ipxact:addressSpace>\"\r\n    );\r\n\r\n    document.setContent(documentContentNoAUB);\r\n\r\n    AddressSpaceNode = document.firstChildElement(\"ipxact:addressSpace\");\r\n\r\n    QSharedPointer<AddressSpace> testAddressSpaceNoAUB = AddressSpaceReader::createAddressSpaceFrom(AddressSpaceNode, Document::Revision::Std14);\r\n\r\n    QCOMPARE(testAddressSpaceNoAUB->getAddressUnitBits(), QString(\"8\"));\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_AddressSpaceReader::testReadVendorExtensions()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_AddressSpaceReader::testReadVendorExtensions()\r\n{\r\n\tQString documentContent(\r\n\t\t\"<ipxact:addressSpace>\"\r\n\t\t\"<ipxact:vendorExtensions>\"\r\n\t\t\"<ulina kolina=\\\"eaa\\\"/>\"\r\n\t\t\"</ipxact:vendorExtensions>\"\r\n\t\t\"</ipxact:addressSpace>\"\r\n\t\t);\r\n\r\n\tQDomDocument document;\r\n\tdocument.setContent(documentContent);\r\n\r\n\tQDomNode addressSpaceNode = document.firstChildElement(\"ipxact:addressSpace\");\r\n\r\n\tQSharedPointer<AddressSpace> testAddressSpace = AddressSpaceReader::createAddressSpaceFrom(addressSpaceNode, Document::Revision::Std14);\r\n\r\n\tQCOMPARE(testAddressSpace->getVendorExtensions()->first()->type(), QString(\"ulina\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_AddressSpaceReader::testReadSegments()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_AddressSpaceReader::testReadSegments()\r\n{\r\n\tQString documentContent(\r\n\t\t\"<ipxact:addressSpace>\"\r\n\t\t\"<ipxact:segments>\"\r\n\t\t\"<ipxact:segment>\"\r\n\t\t\"<ipxact:name>segment1</ipxact:name>\"\r\n\t\t\"<ipxact:isPresent>4-3</ipxact:isPresent>\"\r\n\t\t\"<ipxact:addressOffset eka=\\\"toka\\\">0x10000000</ipxact:addressOffset>\"\r\n\t\t\"<ipxact:range joku=\\\"jotain\\\">32M</ipxact:range>\"\r\n\t\t\"</ipxact:segment>\"\r\n\t\t\"<ipxact:segment>\"\r\n\t\t\"<ipxact:name>segment2</ipxact:name>\"\r\n\t\t\"<ipxact:displayName>display</ipxact:displayName>\"\r\n\t\t\"<ipxact:description>description</ipxact:description>\"\r\n\t\t\"<ipxact:isPresent>11</ipxact:isPresent>\"\r\n\t\t\"<ipxact:addressOffset>0x00000080</ipxact:addressOffset>\"\r\n\t\t\"<ipxact:range>64</ipxact:range>\"\r\n\t\t\"</ipxact:segment>\"\r\n\t\t\"</ipxact:segments>\"\r\n\t\t\"</ipxact:addressSpace>\"\r\n\t\t);\r\n\r\n\tQDomDocument document;\r\n\tdocument.setContent(documentContent);\r\n\r\n\tQDomNode addressSpaceNode = document.firstChildElement(\"ipxact:addressSpace\");\r\n\r\n\tQSharedPointer<AddressSpace> testAddressSpace = AddressSpaceReader::createAddressSpaceFrom(addressSpaceNode, Document::Revision::Std14);\r\n\r\n\tQCOMPARE(testAddressSpace->getSegments()->size(), 2);\r\n\r\n\tQSharedPointer<Segment> segment1 = testAddressSpace->getSegments()->first();\r\n\r\n\tQCOMPARE(segment1->getIsPresent(), QString(\"4-3\"));\r\n\tQCOMPARE(segment1->getAddressOffset(), QString(\"0x10000000\"));\r\n\tQCOMPARE(segment1->getOffsetAttributes().firstKey(), QString(\"eka\"));\r\n\tQCOMPARE(segment1->getOffsetAttributes().first(), QString(\"toka\"));\r\n\tQCOMPARE(segment1->getRange(), QString(\"32M\"));\r\n\tQCOMPARE(segment1->getRangeAttributes().firstKey(), QString(\"joku\"));\r\n\tQCOMPARE(segment1->getRangeAttributes().first(), QString(\"jotain\"));\r\n\r\n\tQSharedPointer<Segment> segment2 = testAddressSpace->getSegments()->last();\r\n\r\n\tQCOMPARE(segment2->name(), QString(\"segment2\"));\r\n\tQCOMPARE(segment2->description(), QString(\"description\"));\r\n\tQCOMPARE(segment2->displayName(), QString(\"display\"));\r\n\tQCOMPARE(segment2->getIsPresent(), QString(\"11\"));\r\n\tQCOMPARE(segment2->getAddressOffset(), QString(\"0x00000080\"));\r\n\tQCOMPARE(segment2->getRange(), QString(\"64\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_AddressSpaceReader::readAddressBlocks()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_AddressSpaceReader::readAddressBlocks()\r\n{\r\n\tQString documentContent(\r\n\t\t\"<ipxact:addressSpace>\"\r\n\t\t\"<ipxact:localMemoryMap>\"\r\n\t\t\"<ipxact:name>testMemoryMapBase</ipxact:name>\"\r\n\t\t\"<ipxact:addressBlock>\"\r\n\t\t\"<ipxact:name>testBlock</ipxact:name>\"\r\n\t\t\"<ipxact:baseAddress>Tur-quan Masters</ipxact:baseAddress>\"\r\n\t\t\"<ipxact:range>Kuusistolinna</ipxact:range>\"\r\n\t\t\"<ipxact:width>Taidemuseo</ipxact:width>\"\r\n\t\t\"<ipxact:register>\"\r\n\t\t\"<ipxact:name>testRegister</ipxact:name>\"\r\n\t\t\"<ipxact:displayName>displayed</ipxact:displayName>\"\r\n\t\t\"<ipxact:description>described</ipxact:description>\"\r\n\t\t\"<ipxact:addressOffset>offset</ipxact:addressOffset>\"\r\n\t\t\"<ipxact:size>10</ipxact:size>\"\r\n\t\t\"<ipxact:field>\"\r\n\t\t\"<ipxact:name>simpleField</ipxact:name>\"\r\n\t\t\"<ipxact:bitOffset>fieldOffset</ipxact:bitOffset>\"\r\n\t\t\"<ipxact:bitWidth>fieldWidth</ipxact:bitWidth>\"\r\n\t\t\"</ipxact:field>\"\r\n\t\t\"</ipxact:register>\"\r\n\t\t\"<ipxact:registerFile>\"\r\n\t\t\"<ipxact:name>contained</ipxact:name>\"\r\n\t\t\"<ipxact:addressOffset>containedOffset</ipxact:addressOffset>\"\r\n\t\t\"<ipxact:range>containedRange</ipxact:range>\"\r\n\t\t\"</ipxact:registerFile>\"\r\n\t\t\"</ipxact:addressBlock>\"\r\n\t\t\"</ipxact:localMemoryMap>\"\r\n\t\t\"</ipxact:addressSpace>\"\r\n\t\t);\r\n\r\n\tQDomDocument document;\r\n\tdocument.setContent(documentContent);\r\n\r\n\tQDomNode addressSpaceNode = document.firstChildElement(\"ipxact:addressSpace\");\r\n\r\n\tQSharedPointer<AddressSpace> testAddressSpace = AddressSpaceReader::createAddressSpaceFrom(addressSpaceNode, Document::Revision::Std14);\r\n\r\n\tQSharedPointer<MemoryMapBase> testMemoryMapBase = testAddressSpace->getLocalMemoryMap();\r\n\r\n\tQCOMPARE(testMemoryMapBase->getMemoryBlocks()->size(), 1);\r\n\r\n\tQSharedPointer<AddressBlock> testAddressBlock =\r\n\t\ttestMemoryMapBase->getMemoryBlocks()->first().dynamicCast<AddressBlock>();\r\n\tQCOMPARE(testAddressBlock.isNull(), false);\r\n\tQCOMPARE(testAddressBlock->name(), QString(\"testBlock\"));\r\n\tQCOMPARE(testAddressBlock->getBaseAddress(), QString(\"Tur-quan Masters\"));\r\n\tQCOMPARE(testAddressBlock->getRange(), QString(\"Kuusistolinna\"));\r\n\tQCOMPARE(testAddressBlock->getWidth(), QString(\"Taidemuseo\"));\r\n\r\n\tQCOMPARE(testAddressBlock->getRegisterData()->size(), 2);\r\n\r\n\tQSharedPointer<Register> containedRegister =\r\n\t\ttestAddressBlock->getRegisterData()->first().dynamicCast<Register>();\r\n\tQCOMPARE(containedRegister.isNull(), false);\r\n\tQCOMPARE(containedRegister->name(), QString(\"testRegister\"));\r\n\tQCOMPARE(containedRegister->displayName(), QString(\"displayed\"));\r\n\tQCOMPARE(containedRegister->description(), QString(\"described\"));\r\n\tQCOMPARE(containedRegister->getSize(), QString(\"10\"));\r\n\r\n\tQCOMPARE(containedRegister->getFields()->size(), 1);\r\n\tQCOMPARE(containedRegister->getFields()->first()->name(), QString(\"simpleField\"));\r\n\tQCOMPARE(containedRegister->getFields()->first()->getBitOffset(), QString(\"fieldOffset\"));\r\n\tQCOMPARE(containedRegister->getFields()->first()->getBitWidth(), QString(\"fieldWidth\"));\r\n\r\n\tQSharedPointer<RegisterFile> containedFile =\r\n\t\ttestAddressBlock->getRegisterData()->last().dynamicCast<RegisterFile>();\r\n\tQCOMPARE(containedFile.isNull(), false);\r\n\tQCOMPARE(containedFile->name(), QString(\"contained\"));\r\n\tQCOMPARE(containedFile->getAddressOffset(), QString(\"containedOffset\"));\r\n\tQCOMPARE(containedFile->getRange(), QString(\"containedRange\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_AddressSpaceReader::testReadNewStd()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_AddressSpaceReader::testReadNewStd()\r\n{\r\n\tQString documentContent(\r\n\t\t\"<ipxact:addressSpace>\"\r\n\t\t\t\"<ipxact:name>testAddressSpace</ipxact:name>\"\r\n\t\t\t\"<ipxact:shortDescription>shortDescription</ipxact:shortDescription>\"\r\n\t\t\t\"<ipxact:isPresent>true</ipxact:isPresent>\"\r\n\t\t\"</ipxact:addressSpace>\"\r\n\t);\r\n\r\n    QDomDocument document;\r\n    document.setContent(documentContent);\r\n\r\n    QDomNode addressSpaceNode = document.firstChildElement(\"ipxact:addressSpace\");\r\n\r\n    QSharedPointer<AddressSpace> testAddressSpace = AddressSpaceReader::createAddressSpaceFrom(addressSpaceNode, Document::Revision::Std22);\r\n\r\n\tQCOMPARE(testAddressSpace->shortDescription(), QString(\"shortDescription\"));\r\n\tQCOMPARE(testAddressSpace->name(), QString(\"testAddressSpace\"));\r\n\tQCOMPARE(testAddressSpace->getIsPresent(), QString(\"\"));\r\n}\r\n\r\nQTEST_APPLESS_MAIN(tst_AddressSpaceReader)\r\n\r\n#include \"tst_AddressSpaceReader.moc\"\r\n"
  },
  {
    "path": "tests/IPXACTmodels/Component/tst_AddressSpaceReader.pri",
    "content": "# ----------------------------------------------------\r\n# This file is generated by the Qt Visual Studio Add-in.\r\n# ------------------------------------------------------\r\n\r\nSOURCES += ./tst_AddressSpaceReader.cpp\r\n"
  },
  {
    "path": "tests/IPXACTmodels/Component/tst_AddressSpaceReader.pro",
    "content": "#-----------------------------------------------------------------------------\r\n# File: tst_AddressSpaceReader.pro\r\n#-----------------------------------------------------------------------------\r\n# Project: Kactus 2\r\n# Author: Janne Virtanen\r\n# Date: 30.09.2015\r\n#\r\n# Description:\r\n# Qt project file template for running unit tests for AddressSpace reader.\r\n#-----------------------------------------------------------------------------\r\n\r\nTEMPLATE = app\r\n\r\nTARGET = tst_AddressSpaceReader\r\n\r\nQT += core xml testlib\r\nQT -= gui\r\nCONFIG += c++11 testcase console\r\n\r\nlinux-g++ | linux-g++-64 | linux-g++-32 {\r\n LIBS += -L../../../executable \\\r\n     -lIPXACTmodels\r\n\r\n}\r\nwin64 | win32 {\r\n LIBS += -L../../../executable \\\r\n     -lIPXACTmodelsd\r\n}\r\n\r\nINCLUDEPATH += $$DESTDIR\r\nINCLUDEPATH += ../../../\r\n\r\nDEPENDPATH += .\r\nDEPENDPATH += ../../../\r\n\r\nOBJECTS_DIR += $$DESTDIR\r\n\r\nMOC_DIR += ./generatedFiles\r\nUI_DIR += ./generatedFiles\r\nRCC_DIR += ./generatedFiles\r\ninclude(tst_AddressSpaceReader.pri)\r\n"
  },
  {
    "path": "tests/IPXACTmodels/Component/tst_AddressSpaceValidator.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: tst_AddressSpacevalidator->cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 30.11.2015\r\n//\r\n// Description:\r\n// Unit test for class AddressSpacevalidator->\r\n//-----------------------------------------------------------------------------\r\n\r\n#include <KactusAPI/include/SystemVerilogExpressionParser.h>\r\n\r\n#include <IPXACTmodels/Component/validators/AddressSpaceValidator.h>\r\n#include <IPXACTmodels/Component/validators/MemoryMapBaseValidator.h>\r\n#include <IPXACTmodels/Component/validators/AddressBlockValidator.h>\r\n#include <IPXACTmodels/Component/validators/RegisterValidator.h>\r\n#include <IPXACTmodels/Component/validators/RegisterFileValidator.h>\r\n#include <IPXACTmodels/Component/validators/SubspaceMapValidator.h>\r\n#include <IPXACTmodels/Component/validators/FieldValidator.h>\r\n#include <IPXACTmodels/Component/validators/EnumeratedValueValidator.h>\r\n#include <IPXACTmodels/common/validators/ParameterValidator.h>\r\n\r\n#include <IPXACTmodels/Component/AddressSpace.h>\r\n#include <IPXACTmodels/Component/Segment.h>\r\n#include <IPXACTmodels/Component/MemoryMapBase.h>\r\n#include <IPXACTmodels/common/Parameter.h>\r\n\r\n#include <QtTest>\r\n\r\nclass tst_AddressSpaceValidator : public QObject\r\n{\r\n    Q_OBJECT\r\n\r\npublic:\r\n    tst_AddressSpaceValidator();\r\n\r\nprivate slots:\r\n  \r\n    void testHasValidName();\r\n    void testHasValidName_data();\r\n\r\n    void testHasValidIsPresent();\r\n    void testHasValidIsPresent_data();\r\n\r\n    void testHasValidRange();\r\n    void testHasValidRange_data();\r\n\r\n    void testHasValidWidth();\r\n    void testHasValidWidth_data();\r\n\r\n    void testSegmentHasValidName();\r\n    void testSegmentHasValidName_data();\r\n    void testSegmentsHaveUniqueNames();\r\n    void testSegmentHasValidIsPresent();\r\n    void testSegmentHasValidIsPresent_data();\r\n    void testSegmentHasValidAddressOffset();\r\n    void testSegmentHasValidAddressOffset_data();\r\n    void testSegmentHasValidRange();\r\n    void testSegmentHasValidRange_data();\r\n\r\n    void testSegmentIsContainedWithinAddressSpace();\r\n    void testSegmentIsContainedWithinAddressSpace_data();\r\n    void testOverlappingSegments();\r\n    void testOverlappingSegments_data();\r\n\r\n    void testHasValidAddressUnitBits();\r\n    void testHasValidAddressUnitBits_data();\r\n\r\n    void testHasValidLocalMemoryMap();\r\n\r\n    void testHasValidParameters();\r\n\r\nprivate:\r\n\r\n    bool errorIsNotFoundInErrorList(QString const& expectedError, QVector<QString> errorList);\r\n\r\n    QSharedPointer<AddressSpaceValidator> createValidator(Document::Revision docRevision);\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_AddressSpaceValidator::tst_AddressSpaceValidator()\r\n//-----------------------------------------------------------------------------\r\ntst_AddressSpaceValidator::tst_AddressSpaceValidator()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_AddressSpaceValidator::testHasValidName()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_AddressSpaceValidator::testHasValidName()\r\n{\r\n    QFETCH(QString, name);\r\n    QFETCH(bool, isValid);\r\n\r\n    QSharedPointer<AddressSpace> testSpace (new AddressSpace(name));\r\n\r\n    QSharedPointer<AddressSpaceValidator> validator = createValidator(Document::Revision::Std14);\r\n\r\n    QCOMPARE(validator->hasValidName(testSpace->name()), isValid);\r\n\r\n    if (!isValid)\r\n    {\r\n        QVector<QString> foundErrors;\r\n        validator->findErrorsIn(foundErrors, testSpace, \"test\");\r\n\r\n        QString expectedError = QObject::tr(\"Invalid name specified for address space %1 within %2\")\r\n            .arg(testSpace->name()).arg(\"test\");\r\n        if (errorIsNotFoundInErrorList(expectedError, foundErrors))\r\n        {\r\n            QFAIL(\"No error message found\");\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_AddressSpaceValidator::testHasValidName_data()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_AddressSpaceValidator::testHasValidName_data()\r\n{\r\n    QTest::addColumn<QString>(\"name\");\r\n    QTest::addColumn<bool>(\"isValid\");\r\n\r\n    QTest::newRow(\"Name test is valid\") << \"test\" << true;\r\n    QTest::newRow(\"Empty name is invalid\") << \"\" << false;\r\n    QTest::newRow(\"Name consisting of only white spaces is invalid\") << \"    \" << false;\r\n    QTest::newRow(\"Name consisting of characters and white spaces is valid\") << \"  test  \" << true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_AddressSpaceValidator::testHasValidIsPresent()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_AddressSpaceValidator::testHasValidIsPresent()\r\n{\r\n    QFETCH(QString, isPresent);\r\n    QFETCH(bool, isValid);\r\n\r\n    QSharedPointer<AddressSpace> testSpace (new AddressSpace(\"TestAddressBlock\"));\r\n    testSpace->setIsPresent(isPresent);\r\n\r\n    QSharedPointer<AddressSpaceValidator> validator = createValidator(Document::Revision::Std14);\r\n\r\n    QCOMPARE(validator->hasValidIsPresent(testSpace->getIsPresent()), isValid);\r\n\r\n    if (!isValid)\r\n    {\r\n        QVector<QString> foundErrors;\r\n        validator->findErrorsIn(foundErrors, testSpace, \"test\");\r\n\r\n        QString expectedError = QObject::tr(\"Invalid isPresent set for address space %1 within %2\")\r\n            .arg(testSpace->name()).arg(\"test\");\r\n        if (errorIsNotFoundInErrorList(expectedError, foundErrors))\r\n        {\r\n            QFAIL(\"No error message found\");\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_AddressSpaceValidator::testHasValidIsPresent_data()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_AddressSpaceValidator::testHasValidIsPresent_data()\r\n{\r\n    QTest::addColumn<QString>(\"isPresent\");\r\n    QTest::addColumn<bool>(\"isValid\");\r\n\r\n    QTest::newRow(\"IsPresent 1 is valid\") << \"1\" << true;\r\n    QTest::newRow(\"IsPresent 1*3-3 is valid\") << \"1*3-3\" << true;\r\n    QTest::newRow(\"IsPresent 2*100 is invalid\") << \"2*100\" << false;\r\n    QTest::newRow(\"IsPresent -14 is invalid\") << \"-14\" << false;\r\n    QTest::newRow(\"Real number isPresent  0.12 is invalid\") << \"0.12\" << false;\r\n    QTest::newRow(\"Text as isPresent is invalid\") << \"test\" << false;\r\n    QTest::newRow(\"String as isPresent is invalid\") << \"\\\"test\\\"\" << false;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_AddressSpaceValidator::testHasValidRange()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_AddressSpaceValidator::testHasValidRange()\r\n{\r\n    QFETCH(QString, range);\r\n    QFETCH(bool, isValid);\r\n\r\n    QSharedPointer<AddressSpace> testSpace (new AddressSpace(\"testSpace\", range, \"0\"));\r\n\r\n    QSharedPointer<AddressSpaceValidator> validator = createValidator(Document::Revision::Std14);\r\n\r\n    QCOMPARE(validator->hasValidRange(testSpace), isValid);\r\n\r\n    if (!isValid)\r\n    {\r\n        QVector<QString> foundErrors;\r\n        validator->findErrorsIn(foundErrors, testSpace, \"test\");\r\n\r\n        QString expectedError = QObject::tr(\"Invalid range set for address space %1 within %2\")\r\n            .arg(testSpace->name()).arg(\"test\");\r\n        if (errorIsNotFoundInErrorList(expectedError, foundErrors))\r\n        {\r\n            QFAIL(\"No error message found\");\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_AddressSpaceValidator::testHasValidRange_data()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_AddressSpaceValidator::testHasValidRange_data()\r\n{\r\n    QTest::addColumn<QString>(\"range\");\r\n    QTest::addColumn<bool>(\"isValid\");\r\n\r\n    QTest::newRow(\"1 is valid for range\") << \"1\" << true;\r\n    QTest::newRow(\"12*2+13-5 is valid for range\") << \"12*2+13-5\" << true;\r\n    QTest::newRow(\"0 is not valid for range\") << \"0\" << false;\r\n    QTest::newRow(\"-20 is not valid for range\") << \"-20\" << false;\r\n    QTest::newRow(\"14-5*3 is not valid for range\") << \"14-5*3\" << false;\r\n    QTest::newRow(\"Text is not valid for range\") << \"text\" << false;\r\n    QTest::newRow(\"String is not valid for range\") << \"\\\"text\\\"\" << false;\r\n    QTest::newRow(\"Empty value is not valid for range\") << \"\" << false;\r\n\r\n    QTest::newRow(\"Long range is valid\") << \"40000000000\" << true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_AddressSpaceValidator::testHasValidWidth()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_AddressSpaceValidator::testHasValidWidth()\r\n{\r\n    QFETCH(QString, width);\r\n    QFETCH(bool, isValid);\r\n\r\n    QSharedPointer<AddressSpace> testSpace (new AddressSpace(\"testSpace\", \"10\", width));\r\n\r\n    QSharedPointer<AddressSpaceValidator> validator = createValidator(Document::Revision::Std14);\r\n\r\n    QCOMPARE(validator->hasValidWidth(testSpace), isValid);\r\n\r\n    if (!isValid)\r\n    {\r\n        QVector<QString> foundErrors;\r\n        validator->findErrorsIn(foundErrors, testSpace, \"test\");\r\n\r\n        QString expectedError = QObject::tr(\"Invalid width set for address space %1 within %2\")\r\n            .arg(testSpace->name()).arg(\"test\");\r\n        if (errorIsNotFoundInErrorList(expectedError, foundErrors))\r\n        {\r\n            QFAIL(\"No error message found\");\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_AddressSpaceValidator::testHasValidWidth_data()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_AddressSpaceValidator::testHasValidWidth_data()\r\n{\r\n    QTest::addColumn<QString>(\"width\");\r\n    QTest::addColumn<bool>(\"isValid\");\r\n\r\n    QTest::newRow(\"1 is valid for width\") << \"1\" << true;\r\n    QTest::newRow(\"12*2+13-5 is valid for width\") << \"12*2+13-5\" << true;\r\n    QTest::newRow(\"0 is valid for width\") << \"0\" << true;\r\n    QTest::newRow(\"-20 is not valid for width\") << \"-20\" << false;\r\n    QTest::newRow(\"14-5*3 is not valid for width\") << \"14-5*3\" << false;\r\n    QTest::newRow(\"Text is not valid for width\") << \"text\" << false;\r\n    QTest::newRow(\"String is not valid for width\") << \"\\\"text\\\"\" << false;\r\n    QTest::newRow(\"Empty value is not valid for width\") << \"\" << false;\r\n\r\n    QTest::newRow(\"Long width is valid\") << \"40000000000\" << true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_AddressSpaceValidator::testSegmentHasValidName()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_AddressSpaceValidator::testSegmentHasValidName()\r\n{\r\n    QFETCH(QString, name);\r\n    QFETCH(bool, isValid);\r\n\r\n    QSharedPointer<Segment> testSegment (new Segment(name, \"10\", \"10\"));\r\n\r\n    QSharedPointer<AddressSpace> testSpace (new AddressSpace(\"testSpace\", \"100\"));\r\n    testSpace->getSegments()->append(testSegment);\r\n\r\n    QSharedPointer<AddressSpaceValidator> validator = createValidator(Document::Revision::Std14);\r\n\r\n    QCOMPARE(validator->hasValidSegments(testSpace), isValid);\r\n\r\n    if (!isValid)\r\n    {\r\n        QVector<QString> foundErrors;\r\n        validator->findErrorsIn(foundErrors, testSpace, \"test\");\r\n\r\n        QString expectedError = QObject::tr(\"Invalid name specified for segment %1 within address space %2\")\r\n            .arg(testSegment->name()).arg(testSpace->name());\r\n        if (errorIsNotFoundInErrorList(expectedError, foundErrors))\r\n        {\r\n            QFAIL(\"No error message found\");\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_AddressSpaceValidator::testSegmentHasValidName_data()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_AddressSpaceValidator::testSegmentHasValidName_data()\r\n{\r\n    QTest::addColumn<QString>(\"name\");\r\n    QTest::addColumn<bool>(\"isValid\");\r\n\r\n    QTest::newRow(\"Name test is valid\") << \"test\" << true;\r\n    QTest::newRow(\"Empty name is invalid\") << \"\" << false;\r\n    QTest::newRow(\"Name consisting of only white spaces is invalid\") << \"    \" << false;\r\n    QTest::newRow(\"Name consisting of characters and white spaces is valid\") << \"  test  \" << true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_AddressSpaceValidator::testSegmentsHaveUniqueNames()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_AddressSpaceValidator::testSegmentsHaveUniqueNames()\r\n{\r\n    QSharedPointer<Segment> segmentOne (new Segment(\"segmentOne\", \"0\", \"2\"));\r\n    QSharedPointer<Segment> segmentTwo (new Segment(*segmentOne.data()));\r\n    segmentTwo->setOffset(\"5\");\r\n\r\n    QSharedPointer<AddressSpace> testSpace (new AddressSpace(\"SpaceDandy\", \"10\", \"10\"));\r\n    testSpace->getSegments()->append(segmentOne);\r\n    testSpace->getSegments()->append(segmentTwo);\r\n\r\n    QSharedPointer<AddressSpaceValidator> validator = createValidator(Document::Revision::Std14);\r\n\r\n    QCOMPARE(validator->hasValidSegments(testSpace), false);\r\n\r\n    QVector<QString> foundErrors;\r\n    validator->findErrorsIn(foundErrors, testSpace, \"test\");\r\n\r\n    QString expectedError = QObject::tr(\"Name %1 of segments in address space %2 is not unique\")\r\n        .arg(segmentOne->name()).arg(testSpace->name());\r\n    if (errorIsNotFoundInErrorList(expectedError, foundErrors))\r\n    {\r\n        QFAIL(\"No error message found\");\r\n    }\r\n\r\n    segmentTwo->setName(\"segmentTwo\");\r\n    QCOMPARE(validator->hasValidSegments(testSpace), true);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_AddressSpaceValidator::testSegmentHasValidIsPresent()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_AddressSpaceValidator::testSegmentHasValidIsPresent()\r\n{\r\n    QFETCH(QString, isPresent);\r\n    QFETCH(bool, isValid);\r\n\r\n    QSharedPointer<Segment> testSegment (new Segment(\"testSegment\", \"10\", \"10\"));\r\n    testSegment->setIsPresent(isPresent);\r\n\r\n    QSharedPointer<AddressSpace> testSpace (new AddressSpace(\"TestAddressBlock\", \"100\"));\r\n    testSpace->getSegments()->append(testSegment);\r\n\r\n    QSharedPointer<AddressSpaceValidator> validator = createValidator(Document::Revision::Std14);\r\n    QCOMPARE(validator->hasValidSegments(testSpace), isValid);\r\n\r\n    if (!isValid)\r\n    {\r\n        QVector<QString> foundErrors;\r\n        validator->findErrorsIn(foundErrors, testSpace, \"test\");\r\n\r\n        QString expectedError = QObject::tr(\"Invalid isPresent set for segment %1 within address space %2\")\r\n            .arg(testSegment->name()).arg(testSpace->name());\r\n        if (errorIsNotFoundInErrorList(expectedError, foundErrors))\r\n        {\r\n            QFAIL(\"No error message found\");\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_AddressSpaceValidator::testSegmentHasValidIsPresent_data()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_AddressSpaceValidator::testSegmentHasValidIsPresent_data()\r\n{\r\n    QTest::addColumn<QString>(\"isPresent\");\r\n    QTest::addColumn<bool>(\"isValid\");\r\n\r\n    QTest::newRow(\"IsPresent 1 is valid\") << \"1\" << true;\r\n    QTest::newRow(\"IsPresent 1*3-3 is valid\") << \"1*3-3\" << true;\r\n    QTest::newRow(\"IsPresent 2*100 is invalid\") << \"2*100\" << false;\r\n    QTest::newRow(\"IsPresent -14 is invalid\") << \"-14\" << false;\r\n    QTest::newRow(\"Real number isPresent  0.12 is invalid\") << \"0.12\" << false;\r\n    QTest::newRow(\"Text as isPresent is invalid\") << \"test\" << false;\r\n    QTest::newRow(\"String as isPresent is invalid\") << \"\\\"test\\\"\" << false;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_AddressSpaceValidator::testSegmentHasValidAddressOffset()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_AddressSpaceValidator::testSegmentHasValidAddressOffset()\r\n{\r\n    QFETCH(QString, addressOffset);\r\n    QFETCH(bool, isValid);\r\n\r\n    QSharedPointer<Segment> testSegment (new Segment(\"testSegment\", addressOffset, \"10\"));\r\n\r\n    QSharedPointer<AddressSpace> testSpace (new AddressSpace(\"TestAddressBlock\", \"100\"));\r\n    testSpace->getSegments()->append(testSegment);\r\n\r\n    if (addressOffset == \"40000000000\")\r\n    {\r\n        testSpace->setRange(\"50000000000\");\r\n    }\r\n\r\n    QSharedPointer<AddressSpaceValidator> validator = createValidator(Document::Revision::Std14);\r\n    QCOMPARE(validator->hasValidSegments(testSpace), isValid);\r\n\r\n    if (!isValid)\r\n    {\r\n        QVector<QString> foundErrors;\r\n        validator->findErrorsIn(foundErrors, testSpace, \"test\");\r\n\r\n        QString expectedError = QObject::tr(\"Invalid address offset set for segment %1 within address space %2\")\r\n            .arg(testSegment->name()).arg(testSpace->name());\r\n        if (errorIsNotFoundInErrorList(expectedError, foundErrors))\r\n        {\r\n            QFAIL(\"No error message found\");\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_AddressSpaceValidator::testSegmentHasValidAddressOffset_data()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_AddressSpaceValidator::testSegmentHasValidAddressOffset_data()\r\n{\r\n    QTest::addColumn<QString>(\"addressOffset\");\r\n    QTest::addColumn<bool>(\"isValid\");\r\n\r\n    QTest::newRow(\"12*2+13-5 is valid for address offset\") << \"12*2+13-5\" << true;\r\n    QTest::newRow(\"0 is valid for address offset\") << \"0\" << true;\r\n    QTest::newRow(\"14-5*3 is not valid for address offset\") << \"14-5*3\" << false;\r\n    QTest::newRow(\"Text is not valid for address offset\") << \"text\" << false;\r\n    QTest::newRow(\"String is not valid for address offset\") << \"\\\"text\\\"\" << false;\r\n    QTest::newRow(\"Empty value is not valid for address offset\") << \"\" << false;\r\n\r\n    QTest::newRow(\"Long address offset is valid for segment\") << \"40000000000\" << true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_AddressSpaceValidator::testSegmentHasValidRange()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_AddressSpaceValidator::testSegmentHasValidRange()\r\n{\r\n    QFETCH(QString, range);\r\n    QFETCH(bool, isValid);\r\n\r\n    QSharedPointer<Segment> testSegment (new Segment(\"testSegment\", \"10\", range));\r\n\r\n    QSharedPointer<AddressSpace> testSpace (new AddressSpace(\"TestAddressBlock\", \"100\"));\r\n    testSpace->getSegments()->append(testSegment);\r\n\r\n    if (range == \"40000000000\")\r\n    {\r\n        testSpace->setRange(\"50000000000\");\r\n    }\r\n\r\n    QSharedPointer<AddressSpaceValidator> validator = createValidator(Document::Revision::Std14);\r\n    QCOMPARE(validator->hasValidSegments(testSpace), isValid);\r\n\r\n    if (!isValid)\r\n    {\r\n        QVector<QString> foundErrors;\r\n        validator->findErrorsIn(foundErrors, testSpace, \"test\");\r\n\r\n        QString expectedError = QObject::tr(\"Invalid range set for segment %1 within address space %2\")\r\n            .arg(testSegment->name()).arg(testSpace->name());\r\n        if (errorIsNotFoundInErrorList(expectedError, foundErrors))\r\n        {\r\n            QFAIL(\"No error message found\");\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_AddressSpaceValidator::testSegmentHasValidRange_data()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_AddressSpaceValidator::testSegmentHasValidRange_data()\r\n{\r\n    QTest::addColumn<QString>(\"range\");\r\n    QTest::addColumn<bool>(\"isValid\");\r\n\r\n    QTest::newRow(\"12*2+13-5 is valid for range\") << \"12*2+13-5\" << true;\r\n    QTest::newRow(\"0 is not valid for range\") << \"0\" << false;\r\n    QTest::newRow(\"14-5*3 is not valid for range\") << \"14-5*3\" << false;\r\n    QTest::newRow(\"Text is not valid for range\") << \"text\" << false;\r\n    QTest::newRow(\"String is not valid for range\") << \"\\\"text\\\"\" << false;\r\n    QTest::newRow(\"Empty value is not valid for range\") << \"\" << false;\r\n\r\n    QTest::newRow(\"Long range is valid for segment\") << \"40000000000\" << true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_AddressSpaceValidator::testSegmentsAreContainedWithinAddressSpace()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_AddressSpaceValidator::testSegmentIsContainedWithinAddressSpace()\r\n{\r\n    QFETCH(QString, segmentOffset);\r\n    QFETCH(QString, segmentRange);\r\n    QFETCH(QString, spaceRange);\r\n    QFETCH(bool, isValid);\r\n\r\n    QSharedPointer<Segment> testSegment (new Segment(\"Saitama\", segmentOffset, segmentRange));\r\n\r\n    QSharedPointer<AddressSpace> testSpace (new AddressSpace(\"Wanpan\", spaceRange));\r\n    testSpace->getSegments()->append(testSegment);\r\n\r\n    QSharedPointer<AddressSpaceValidator> validator = createValidator(Document::Revision::Std14);\r\n    QCOMPARE(validator->hasValidSegments(testSpace), isValid);\r\n\r\n    if (!isValid)\r\n    {\r\n        QVector<QString> foundErrors;\r\n        validator->findErrorsIn(foundErrors, testSpace, \"test\");\r\n\r\n        QString expectedError = QObject::tr(\"Segment %1 is not contained within address space %2\")\r\n            .arg(testSegment->name()).arg(testSpace->name());\r\n\r\n\r\n        if (errorIsNotFoundInErrorList(expectedError, foundErrors))\r\n        {\r\n            QFAIL(\"No error message found\");\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_AddressSpaceValidator::testSegmentsAreContainedWithinAddressSpace_data()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_AddressSpaceValidator::testSegmentIsContainedWithinAddressSpace_data()\r\n{\r\n    QTest::addColumn<QString>(\"segmentOffset\");\r\n    QTest::addColumn<QString>(\"segmentRange\");\r\n    QTest::addColumn<QString>(\"spaceRange\");\r\n\r\n    QTest::addColumn<bool>(\"isValid\");\r\n\r\n    QTest::newRow(\"Segment: offset = 0, range = 5 is within address space with range 5\") << \"0\" << \"5\" << \"5\" <<\r\n        true;\r\n    QTest::newRow(\"Segment: offset = 0, range = 10 is not within address space with range 5\") << \"0\" << \"10\" <<\r\n        \"5\" << false;\r\n    QTest::newRow(\"Segment: offset = 20, range = 1 is not within address space with range 5\") << \"20\" << \"1\" <<\r\n        \"5\" << false;\r\n\r\n    QTest::newRow(\"Segment with a long offset is not contained within a small address space\")\r\n        << \"4000000000000000000000\" << \"5\" << \"5\"  << false;\r\n    QTest::newRow(\"Segment with a long range is not contained within a small address space\")\r\n        << \"0\" << \"4000000000000000000000\" << \"5\" << false;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_AddressSpaceValidator::testOverlappingSegments()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_AddressSpaceValidator::testOverlappingSegments()\r\n{\r\n    QFETCH(QString, segmentOffsetOne);\r\n    QFETCH(QString, segmentRangeOne);\r\n    QFETCH(QString, segmentOffsetTwo);\r\n    QFETCH(QString, segmentRangeTwo);\r\n    QFETCH(bool, isValid);\r\n\r\n    QSharedPointer<Segment> segmentOne (new Segment(\"Mugen\", segmentOffsetOne, segmentRangeOne));\r\n    QSharedPointer<Segment> segmentTwo (new Segment(\"Jin\", segmentOffsetTwo, segmentRangeTwo));\r\n\r\n    QSharedPointer<AddressSpace> testSpace (new AddressSpace(\"SamuraiChamploo\", \"100\"));\r\n    testSpace->getSegments()->append(segmentOne);\r\n    testSpace->getSegments()->append(segmentTwo);\r\n\r\n    QSharedPointer<AddressSpaceValidator> validator = createValidator(Document::Revision::Std14);\r\n    QCOMPARE(validator->hasValidSegments(testSpace), isValid);\r\n\r\n    if (!isValid)\r\n    {\r\n        QVector<QString> foundErrors;\r\n        validator->findErrorsIn(foundErrors, testSpace, \"test\");\r\n\r\n        QString firstName = segmentOne->name();\r\n        QString secondName = segmentTwo->name();\r\n\r\n        if (segmentOffsetOne.toInt() >= segmentOffsetTwo.toInt())\r\n        {\r\n            firstName = segmentTwo->name();\r\n            secondName = segmentOne->name();\r\n        }\r\n\r\n        QString expectedError = QObject::tr(\"Segments %1 and %2 overlap within address space %3\")\r\n            .arg(firstName).arg(secondName).arg(testSpace->name());\r\n        if (errorIsNotFoundInErrorList(expectedError, foundErrors))\r\n        {\r\n            QFAIL(\"No error message found\");\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_AddressSpaceValidator::testOverlappingSegments_data()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_AddressSpaceValidator::testOverlappingSegments_data()\r\n{\r\n    QTest::addColumn<QString>(\"segmentOffsetOne\");\r\n    QTest::addColumn<QString>(\"segmentRangeOne\");\r\n    QTest::addColumn<QString>(\"segmentOffsetTwo\");\r\n    QTest::addColumn<QString>(\"segmentRangeTwo\");\r\n    QTest::addColumn<bool>(\"isValid\");\r\n\r\n    QTest::newRow(\"Segment1: offset=0, range=2; Segment2: offset=5, range=2 do not overlap\") <<\r\n        \"0\" << \"2\" << \"5\" << \"2\" << true;\r\n    QTest::newRow(\"Segment1: offset=0, range=8; Segment2: offset=5, range=6 overlap\") <<\r\n        \"0\" << \"8\" << \"5\" << \"6\" << false;\r\n    QTest::newRow(\"Segment1: offset=8, range=4; Segment2: offset=5, range=6 overlap\") <<\r\n        \"8\" << \"4\" << \"5\" << \"6\" << false;\r\n    QTest::newRow(\"Segment1: offset=8, range=1; Segment2: offset=5, range=6 overlap\") <<\r\n        \"8\" << \"1\" << \"5\" << \"6\" << false;\r\n\r\n    QTest::newRow(\"Segment1: offset=5, range=6; Segment2: offset=0, range=8 overlap\") <<\r\n        \"5\" << \"6\" << \"0\" << \"8\" << false;\r\n    QTest::newRow(\"Segment1: offset=5, range=6; Segment2: offset=8, range=4 overlap\") <<\r\n        \"5\" << \"6\" << \"8\" << \"4\" << false;\r\n    QTest::newRow(\"Segment1: offset=5, range=6; Segment2: offset=8, range=1 overlap\") <<\r\n        \"5\" << \"6\" << \"8\" << \"1\" << false;\r\n    QTest::newRow(\"Segment1: offset=5, range=2; Segment2: offset=0, range=2 do not overlap\") <<\r\n        \"5\" << \"2\" << \"0\" << \"2\" << true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_AddressSpaceValidator::testHasValidAddressUnitBits()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_AddressSpaceValidator::testHasValidAddressUnitBits()\r\n{\r\n    QFETCH(QString, addressUnitBits);\r\n    QFETCH(bool, isValid);\r\n\r\n    QSharedPointer<AddressSpace> testSpace (new AddressSpace(\"TestAddressBlock\"));\r\n    testSpace->setAddressUnitBits(addressUnitBits);\r\n\r\n    QSharedPointer<AddressSpaceValidator> validator = createValidator(Document::Revision::Std14);\r\n    QCOMPARE(validator->hasValidAddressUnitBits(testSpace), isValid);\r\n\r\n    if (!isValid)\r\n    {\r\n        QVector<QString> foundErrors;\r\n        validator->findErrorsIn(foundErrors, testSpace, \"test\");\r\n\r\n        QString expectedError = QObject::tr(\"Invalid address unit bits set for address space %1 within %2\")\r\n            .arg(testSpace->name()).arg(\"test\");\r\n        if (errorIsNotFoundInErrorList(expectedError, foundErrors))\r\n        {\r\n            QFAIL(\"No error message found\");\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_AddressSpaceValidator::testHasValidAddressUnitBits_data()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_AddressSpaceValidator::testHasValidAddressUnitBits_data()\r\n{\r\n    QTest::addColumn<QString>(\"addressUnitBits\");\r\n    QTest::addColumn<bool>(\"isValid\");\r\n\r\n    QTest::newRow(\"12*2+13-5 is valid for address unit bits\") << \"12*2+13-5\" << true;\r\n    QTest::newRow(\"0 is not valid for address unit bits\") << \"0\" << false;\r\n    QTest::newRow(\"14-5*3 is not valid for address unit bits\") << \"14-5*3\" << false;\r\n    QTest::newRow(\"Text is not valid for address unit bits\") << \"text\" << false;\r\n    QTest::newRow(\"String is not valid for address unit bits\") << \"\\\"text\\\"\" << false;\r\n    QTest::newRow(\"Empty value is valid for address unit bits\") << \"\" << true;\r\n\r\n    QTest::newRow(\"Long address unit bits value is valid\") << \"40000000000\" << true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_AddressSpaceValidator::testHasValidLocalMemoryMap()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_AddressSpaceValidator::testHasValidLocalMemoryMap()\r\n{\r\n    QSharedPointer<MemoryMapBase> testLocalMap (new MemoryMapBase(\"\"));\r\n\r\n    QSharedPointer<AddressSpace> testSpace (new AddressSpace(\"testSpace\"));\r\n    testSpace->setLocalMemoryMap(testLocalMap);\r\n\r\n    QSharedPointer<AddressSpaceValidator> validator = createValidator(Document::Revision::Std14);\r\n    QCOMPARE(validator->hasValidLocalMemoryMap(testSpace), false);\r\n\r\n    QVector<QString> foundErrors;\r\n    validator->findErrorsIn(foundErrors, testSpace, \"test\");\r\n\r\n    QString expectedError = QObject::tr(\"Invalid name specified for memory map %1 within address space %2\").\r\n        arg(testLocalMap->name()).arg(testSpace->name());\r\n    if (errorIsNotFoundInErrorList(expectedError, foundErrors))\r\n    {\r\n        QFAIL(\"No error message found\");\r\n    }\r\n\r\n    testLocalMap->setName(\"testMap\");\r\n    QCOMPARE(validator->hasValidLocalMemoryMap(testSpace), true);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_AddressSpaceValidator::testHasValidParameters()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_AddressSpaceValidator::testHasValidParameters()\r\n{\r\n    QSharedPointer<Parameter> testParameter (new Parameter());\r\n    testParameter->setValueId(\"Sanger\");\r\n    testParameter->setName(\"Daizengar\");\r\n    testParameter->setValue(\"\");\r\n    testParameter->setType(\"int\");\r\n\r\n    QSharedPointer<AddressSpace> testSpace (new AddressSpace(\"testSpace\"));\r\n    testSpace->getParameters()->append(testParameter);\r\n\r\n    QSharedPointer<AddressSpaceValidator> validator = createValidator(Document::Revision::Std14);\r\n    QCOMPARE(validator->hasValidParameters(testSpace), false);\r\n\r\n    QVector<QString> errorsFound;\r\n    validator->findErrorsIn(errorsFound, testSpace, \"test\");\r\n\r\n    QString expectedError = QObject::tr(\"No value specified for %1 %2 within address space %3\").\r\n        arg(testParameter->elementName()).arg(testParameter->name()).arg(testSpace->name());\r\n\r\n    if (errorIsNotFoundInErrorList(expectedError, errorsFound))\r\n    {\r\n        QFAIL(\"Error was not found\");\r\n    }\r\n\r\n    testParameter->setValue(\"20\");\r\n    QCOMPARE(validator->hasValidParameters(testSpace), true);\r\n\r\n    QSharedPointer<Parameter> otherParameter (new Parameter(*testParameter.data()));\r\n    otherParameter->setValue(\"2\");\r\n    testSpace->getParameters()->append(otherParameter);\r\n\r\n    QCOMPARE(validator->hasValidParameters(testSpace), false);\r\n\r\n    errorsFound.clear();\r\n    validator->findErrorsIn(errorsFound, testSpace, \"test\");\r\n    expectedError = QObject::tr(\"Name %1 of parameters in address space %2 is not unique.\")\r\n        .arg(otherParameter->name()).arg(testSpace->name());\r\n    if (errorIsNotFoundInErrorList(expectedError, errorsFound))\r\n    {\r\n        QFAIL(\"Error was not found\");\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_AddressSpaceValidator::errorIsNotFoundInErrorList()\r\n//-----------------------------------------------------------------------------\r\nbool tst_AddressSpaceValidator::errorIsNotFoundInErrorList(QString const& expectedError,\r\n    QVector<QString> errorList)\r\n{\r\n    if (!errorList.contains(expectedError))\r\n    {\r\n        qDebug() << \"The following error:\" << Qt::endl << expectedError << Qt::endl << \"was not found in error list:\";\r\n        for (QString const& error : errorList)\r\n        {\r\n            qDebug() << error;\r\n        }\r\n        return true;\r\n    }\r\n\r\n    return false;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_AddressSpaceValidator::createValidator()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<AddressSpaceValidator> tst_AddressSpaceValidator::createValidator(Document::Revision docRevision)\r\n{\r\n    QSharedPointer<ExpressionParser> parser(new SystemVerilogExpressionParser());\r\n    QSharedPointer<ParameterValidator> parameterValidator(\r\n        new ParameterValidator(parser, QSharedPointer<QList<QSharedPointer<Choice> > >(), docRevision));\r\n    QSharedPointer<EnumeratedValueValidator> enumeratedValueValidator(new EnumeratedValueValidator(parser));\r\n    QSharedPointer<FieldValidator> fieldValidator(\r\n        new FieldValidator(parser, enumeratedValueValidator, parameterValidator));\r\n    QSharedPointer<RegisterValidator> registerValidator(\r\n        new RegisterValidator(parser, fieldValidator, parameterValidator));\r\n    QSharedPointer<RegisterFileValidator> registerFileValidator(new RegisterFileValidator(parser, \r\n        registerValidator, parameterValidator, docRevision));\r\n    QSharedPointer<AddressBlockValidator> addressBlockValidator(\r\n        new AddressBlockValidator(parser, registerValidator, registerFileValidator, parameterValidator, docRevision));\r\n    QSharedPointer<SubspaceMapValidator> subspaceValidator(new SubspaceMapValidator(parser, parameterValidator, docRevision));\r\n    QSharedPointer<MemoryMapBaseValidator> localMemoryMapValidator(\r\n        new MemoryMapBaseValidator(parser, addressBlockValidator, subspaceValidator));\r\n\r\n    QSharedPointer<AddressSpaceValidator> validator(\r\n        new AddressSpaceValidator(parser, localMemoryMapValidator, parameterValidator));\r\n\r\n    return validator;\r\n}\r\n\r\n\r\nQTEST_APPLESS_MAIN(tst_AddressSpaceValidator)\r\n\r\n#include \"tst_AddressSpaceValidator.moc\"\r\n"
  },
  {
    "path": "tests/IPXACTmodels/Component/tst_AddressSpaceValidator.pri",
    "content": "# ----------------------------------------------------\r\n# This file is generated by the Qt Visual Studio Tools.\r\n# ------------------------------------------------------\r\n   \r\nSOURCES += ./tst_AddressSpaceValidator.cpp \r\n   "
  },
  {
    "path": "tests/IPXACTmodels/Component/tst_AddressSpaceValidator.pro",
    "content": "#-----------------------------------------------------------------------------\r\n# File: tst_AddressSpaceValidator.pro\r\n#-----------------------------------------------------------------------------\r\n# Project: Kactus 2\r\n# Author: Mikko Teuho\r\n# Date: 30.11.2015\r\n#\r\n# Description:\r\n# Qt project file template for running unit tests for AddressSpaceValidator.\r\n#-----------------------------------------------------------------------------\r\n\r\nTEMPLATE = app\r\n\r\nTARGET = tst_AddressSpaceValidator\r\n\r\nQT += core gui xml testlib\r\n\r\nCONFIG += c++11 testcase console\r\n\r\nlinux-g++ | linux-g++-64 | linux-g++-32 {\r\n LIBS += -L../../../executable \\\r\n     -lIPXACTmodels -lKactusAPI\r\n\r\n}\r\nwin64 | win32 {\r\n LIBS += -L../../../executable \\\r\n     -lIPXACTmodelsd -lKactusAPId\r\n}\r\n\r\nINCLUDEPATH += $$DESTDIR\r\nINCLUDEPATH += ../../../\r\nINCLUDEPATH += ../../../KactusAPI/include\r\n\r\nDEPENDPATH += .\r\nDEPENDPATH += ../../../\r\n\r\nOBJECTS_DIR += $$DESTDIR\r\n\r\nMOC_DIR += ./generatedFiles\r\nUI_DIR += ./generatedFiles\r\nRCC_DIR += ./generatedFiles\r\ninclude(tst_AddressSpaceValidator.pri)\r\n"
  },
  {
    "path": "tests/IPXACTmodels/Component/tst_AddressSpaceWriter.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: tst_AddressSpaceWriter.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Janne Virtanen\r\n// Date: 01.10.2015\r\n//\r\n// Description:\r\n// Unit test for class AddressSpaceWriter.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include <IPXACTmodels/Component/AddressSpaceWriter.h>\r\n#include <IPXACTmodels/common/VendorExtension.h>\r\n#include <IPXACTmodels/common/Parameter.h>\r\n#include <IPXACTmodels/common/GenericVendorExtension.h>\r\n\r\n#include <IPXACTmodels/Component/AddressBlock.h>\r\n#include <IPXACTmodels/Component/Register.h>\r\n#include <IPXACTmodels/Component/RegisterFile.h>\r\n#include <IPXACTmodels/Component/Field.h>\r\n\r\n#include <QtTest>\r\n\r\nclass tst_AddressSpaceWriter : public QObject\r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\ttst_AddressSpaceWriter();\r\n\r\n\tprivate slots:\r\n\t\tvoid init();\r\n\t\tvoid cleanup();\r\n\r\n\t\tvoid testWriteAddressSpaceNameGroup();\r\n\t\tvoid testWriteIsPresent();\r\n\t\tvoid testWriteParameter();\r\n\t\tvoid testWriteVendorExtension();\r\n\t\tvoid testWriteBlockSize();\r\n\t\tvoid testWriteAddressUnitBits();\r\n\t\tvoid testWriteSegments();\r\n\t\tvoid writeAddressBlocks();\r\n\t\tvoid writeNewStd();\r\n\r\nprivate:\r\n\r\n\tQSharedPointer<AddressSpace> testAddressSpace_;\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_AddressSpaceWriter::tst_AddressSpaceWriter()\r\n//-----------------------------------------------------------------------------\r\ntst_AddressSpaceWriter::tst_AddressSpaceWriter()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_AddressSpaceWriter::init()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_AddressSpaceWriter::init()\r\n{\r\n\ttestAddressSpace_ = QSharedPointer<AddressSpace>(new AddressSpace());\r\n\ttestAddressSpace_->setName(\"testAddressSpace\");\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_AddressSpaceWriter::cleanup()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_AddressSpaceWriter::cleanup()\r\n{\r\n\ttestAddressSpace_.clear();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_AddressSpaceWriter::testWriteAddressSpaceNameGroup()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_AddressSpaceWriter::testWriteAddressSpaceNameGroup()\r\n{\r\n\tQString output;\r\n\tQXmlStreamWriter xmlStreamWriter(&output);\r\n\r\n\ttestAddressSpace_->setDisplayName(\"testDisplay\");\r\n\ttestAddressSpace_->setDescription(\"testDescription\");\r\n\r\n\tQString expectedOutput = \r\n\t\t\"<ipxact:addressSpace>\"\r\n\t\t\"<ipxact:name>testAddressSpace</ipxact:name>\"\r\n\t\t\"<ipxact:displayName>testDisplay</ipxact:displayName>\"\r\n\t\t\"<ipxact:description>testDescription</ipxact:description>\"\r\n        \"<ipxact:range></ipxact:range>\"\r\n\t\t\"<ipxact:width></ipxact:width>\"\r\n\t\t\"</ipxact:addressSpace>\"\r\n\t\t;\r\n\r\n    AddressSpaceWriter::writeAddressSpace(xmlStreamWriter, testAddressSpace_, Document::Revision::Std14);\r\n\tQCOMPARE(output, expectedOutput);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_AddressSpaceWriter::testWriteIsPresent()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_AddressSpaceWriter::testWriteIsPresent()\r\n{\r\n\tQString output;\r\n\tQXmlStreamWriter xmlStreamWriter(&output);\r\n\r\n\ttestAddressSpace_->setIsPresent(\"4-3\");\r\n\r\n\tQString expectedOutput(\r\n\t\t\"<ipxact:addressSpace>\"\r\n\t\t\"<ipxact:name>testAddressSpace</ipxact:name>\"\r\n\t\t\"<ipxact:isPresent>4-3</ipxact:isPresent>\"\r\n        \"<ipxact:range></ipxact:range>\"\r\n        \"<ipxact:width></ipxact:width>\"\r\n\t\t\"</ipxact:addressSpace>\"\r\n\t\t);\r\n\r\n    AddressSpaceWriter::writeAddressSpace(xmlStreamWriter, testAddressSpace_, Document::Revision::Std14);\r\n\r\n\tQCOMPARE(output, expectedOutput);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_AddressSpaceReader::testWriteParameter()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_AddressSpaceWriter::testWriteParameter()\r\n{\r\n\tQString output;\r\n\tQXmlStreamWriter xmlStreamWriter(&output);\r\n\r\n\ttestAddressSpace_->setIsPresent(\"4-3\");\r\n\r\n\tQSharedPointer<Parameter> para1(new Parameter());\r\n\tpara1->setName(\"Esko\");\r\n\tpara1->setValueId(\"joq\");\r\n\tpara1->setValue(\"5\");\r\n\tpara1->setType(\"shortint\");\r\n\tpara1->setAttribute(\"prompt\", \"Parm 1\");\r\n\tpara1->setAttribute(\"resolve\", \"user\");\r\n\tpara1->setDescription(\"First generator parameter.\");\r\n\r\n    testAddressSpace_->getParameters()->append(para1);\r\n\r\n\tQString expectedOutput(\r\n\t\t\"<ipxact:addressSpace>\"\r\n\t\t\"<ipxact:name>testAddressSpace</ipxact:name>\"\r\n\t\t\"<ipxact:isPresent>4-3</ipxact:isPresent>\"\r\n        \"<ipxact:range></ipxact:range>\"\r\n        \"<ipxact:width></ipxact:width>\"\r\n\t\t\"<ipxact:parameters>\"\r\n\t\t\"<ipxact:parameter parameterId=\\\"joq\\\" prompt=\\\"Parm 1\\\"\"\r\n\t\t\" resolve=\\\"user\\\" type=\\\"shortint\\\">\"\r\n\t\t\"<ipxact:name>Esko</ipxact:name>\"\r\n\t\t\"<ipxact:description>First generator parameter.</ipxact:description>\"\r\n\t\t\"<ipxact:value>5</ipxact:value>\"\r\n\t\t\"</ipxact:parameter>\"\r\n\t\t\"</ipxact:parameters>\"\r\n\t\t\"</ipxact:addressSpace>\"\r\n\t\t);\r\n\r\n    AddressSpaceWriter::writeAddressSpace(xmlStreamWriter, testAddressSpace_, Document::Revision::Std14);\r\n\r\n\tQCOMPARE(output, expectedOutput);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_AddressSpaceReader::testWriteVendorExtension()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_AddressSpaceWriter::testWriteVendorExtension()\r\n{\r\n\tQDomDocument document;\r\n\tQDomElement extensionNode = document.createElement(\"ulina\");\r\n\textensionNode.setAttribute(\"kolina\", \"eaa\");\r\n\textensionNode.appendChild(document.createTextNode(\"testValue\"));\r\n\r\n\tQSharedPointer<GenericVendorExtension> testExtension(new GenericVendorExtension(extensionNode));\r\n\r\n\ttestAddressSpace_->getVendorExtensions()->append(testExtension);\r\n\r\n\tQString output;\r\n\tQXmlStreamWriter xmlStreamWriter(&output);\r\n\r\n\ttestAddressSpace_->setName(\"joq\");\r\n\r\n\tQString expectedOutput(\r\n\t\t\"<ipxact:addressSpace>\"\r\n\t\t\"<ipxact:name>joq</ipxact:name>\"\r\n        \"<ipxact:range></ipxact:range>\"\r\n        \"<ipxact:width></ipxact:width>\"\r\n\t\t\"<ipxact:vendorExtensions>\"\r\n\t\t\"<ulina kolina=\\\"eaa\\\">\"\r\n\t\t\"testValue\"\r\n\t\t\"</ulina>\"\r\n\t\t\"</ipxact:vendorExtensions>\"\r\n\t\t\"</ipxact:addressSpace>\"\r\n\t\t);\r\n\r\n    AddressSpaceWriter::writeAddressSpace(xmlStreamWriter, testAddressSpace_, Document::Revision::Std14);\r\n\r\n\tQCOMPARE(output, expectedOutput);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_AddressSpaceReader::testWriteBlockSize()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_AddressSpaceWriter::testWriteBlockSize()\r\n{\r\n\tQDomDocument document;\r\n\r\n\tQString output;\r\n\tQXmlStreamWriter xmlStreamWriter(&output);\r\n\r\n    testAddressSpace_->setRange(\"testRange\");\r\n\ttestAddressSpace_->setWidth(\"123\");\r\n\r\n\tQString expectedOutput(\r\n\t\t\"<ipxact:addressSpace>\"\r\n\t\t\"<ipxact:name>testAddressSpace</ipxact:name>\"\r\n        \"<ipxact:range>testRange</ipxact:range>\"\r\n        \"<ipxact:width>123</ipxact:width>\"\r\n\t\t\"</ipxact:addressSpace>\"\r\n\t\t);\r\n\r\n    AddressSpaceWriter::writeAddressSpace(xmlStreamWriter, testAddressSpace_, Document::Revision::Std14);\r\n\r\n\tQCOMPARE(output, expectedOutput);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_AddressSpaceWriter::testWriteAddressUnitBits()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_AddressSpaceWriter::testWriteAddressUnitBits()\r\n{\r\n\tQString output;\r\n\tQXmlStreamWriter xmlStreamWriter(&output);\r\n\r\n\ttestAddressSpace_->setAddressUnitBits(\"44\");\r\n\r\n\tQString expectedOutput(\r\n\t\t\"<ipxact:addressSpace>\"\r\n\t\t\"<ipxact:name>testAddressSpace</ipxact:name>\"\r\n        \"<ipxact:range></ipxact:range>\"\r\n        \"<ipxact:width></ipxact:width>\"\r\n\t\t\"<ipxact:addressUnitBits>44</ipxact:addressUnitBits>\"\r\n\t\t\"</ipxact:addressSpace>\"\r\n\t\t);\r\n\r\n    AddressSpaceWriter::writeAddressSpace(xmlStreamWriter, testAddressSpace_, Document::Revision::Std14);\r\n\r\n\tQCOMPARE(output, expectedOutput);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_AddressSpaceWriter::testWriteSegments()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_AddressSpaceWriter::testWriteSegments()\r\n{\r\n\tQString output;\r\n\tQXmlStreamWriter xmlStreamWriter(&output);\r\n\r\n\tQSharedPointer<Segment> seg1( new Segment() );\r\n\tseg1->setName(\"segment1\");\r\n\tseg1->setIsPresent(\"4-3\");\r\n\tseg1->setOffset(\"0x10000000\");\r\n\tseg1->setRange(\"32M\");\r\n\r\n\tQSharedPointer<Segment> seg2( new Segment() );\r\n\tseg2->setName(\"segment2\");\r\n\tseg2->setDisplayName(\"display\");\r\n\tseg2->setDescription(\"description\");\r\n\tseg2->setIsPresent(\"11\");\r\n\tseg2->setOffset(\"0x00000080\");\r\n\tseg2->setRange(\"64\");\r\n\r\n    testAddressSpace_->getSegments()->append(seg1);\r\n    testAddressSpace_->getSegments()->append(seg2);\r\n\r\n\tQString expectedOutput(\r\n\t\t\"<ipxact:addressSpace>\"\r\n\t\t\"<ipxact:name>testAddressSpace</ipxact:name>\"\r\n        \"<ipxact:range></ipxact:range>\"\r\n        \"<ipxact:width></ipxact:width>\"\r\n\t\t\"<ipxact:segments>\"\r\n\t\t\"<ipxact:segment>\"\r\n\t\t\"<ipxact:name>segment1</ipxact:name>\"\r\n\t\t\"<ipxact:isPresent>4-3</ipxact:isPresent>\"\r\n\t\t\"<ipxact:addressOffset>0x10000000</ipxact:addressOffset>\"\r\n\t\t\"<ipxact:range>32M</ipxact:range>\"\r\n\t\t\"</ipxact:segment>\"\r\n\t\t\"<ipxact:segment>\"\r\n\t\t\"<ipxact:name>segment2</ipxact:name>\"\r\n\t\t\"<ipxact:displayName>display</ipxact:displayName>\"\r\n\t\t\"<ipxact:description>description</ipxact:description>\"\r\n\t\t\"<ipxact:isPresent>11</ipxact:isPresent>\"\r\n\t\t\"<ipxact:addressOffset>0x00000080</ipxact:addressOffset>\"\r\n\t\t\"<ipxact:range>64</ipxact:range>\"\r\n\t\t\"</ipxact:segment>\"\r\n\t\t\"</ipxact:segments>\"\r\n\t\t\"</ipxact:addressSpace>\"\r\n\t\t);\r\n\r\n    AddressSpaceWriter::writeAddressSpace(xmlStreamWriter, testAddressSpace_, Document::Revision::Std14);\r\n\r\n\tQCOMPARE(output, expectedOutput);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_AddressSpaceWriter::writeAddressBlocks()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_AddressSpaceWriter::writeAddressBlocks()\r\n{\r\n\tQString output;\r\n\tQXmlStreamWriter xmlStreamWriter(&output);\r\n\r\n\tQSharedPointer<Field> simpleField(new Field(\"simpleField\"));\r\n\tsimpleField->setBitOffset(\"fieldOffset\");\r\n\tsimpleField->setBitWidth(\"fieldWidth\");\r\n\r\n\tQSharedPointer<Register> testRegister (new Register(\"testRegister\", \"offset\", \"10\"));\r\n\ttestRegister->setDisplayName(\"displayed\");\r\n\ttestRegister->setDescription(\"described\");\r\n\ttestRegister->getFields()->append(simpleField);\r\n\r\n\tQSharedPointer<RegisterFile> containedRegisterFile\r\n\t\t(new RegisterFile(\"contained\", \"containedOffset\", \"containedRange\"));\r\n\r\n\tQSharedPointer<AddressBlock> testAddressBlock =\r\n\t\tQSharedPointer<AddressBlock>(new AddressBlock(\"testBlock\", \"Tur-quan Masters\"));\r\n\ttestAddressBlock->setRange(\"Kuusistolinna\");\r\n\ttestAddressBlock->setWidth(\"Taidemuseo\");\r\n\ttestAddressBlock->getRegisterData()->append(testRegister);\r\n\ttestAddressBlock->getRegisterData()->append(containedRegisterFile);\r\n\r\n\tQSharedPointer<MemoryMapBase> testMemoryMapBase( new MemoryMapBase());\r\n\ttestMemoryMapBase->getMemoryBlocks()->append(testAddressBlock);\r\n\ttestAddressSpace_->setLocalMemoryMap(testMemoryMapBase);\r\n\r\n\tQString expectedOutput(\r\n\t\t\"<ipxact:addressSpace>\"\r\n\t\t\"<ipxact:name>testAddressSpace</ipxact:name>\"\r\n        \"<ipxact:range></ipxact:range>\"\r\n        \"<ipxact:width></ipxact:width>\"\r\n\t\t\"<ipxact:localMemoryMap>\"\r\n\t\t\"<ipxact:name></ipxact:name>\"\r\n\t\t\"<ipxact:addressBlock>\"\r\n\t\t\"<ipxact:name>testBlock</ipxact:name>\"\r\n\t\t\"<ipxact:baseAddress>Tur-quan Masters</ipxact:baseAddress>\"\r\n\t\t\"<ipxact:range>Kuusistolinna</ipxact:range>\"\r\n\t\t\"<ipxact:width>Taidemuseo</ipxact:width>\"\r\n\t\t\"<ipxact:register>\"\r\n\t\t\"<ipxact:name>testRegister</ipxact:name>\"\r\n\t\t\"<ipxact:displayName>displayed</ipxact:displayName>\"\r\n\t\t\"<ipxact:description>described</ipxact:description>\"\r\n\t\t\"<ipxact:addressOffset>offset</ipxact:addressOffset>\"\r\n\t\t\"<ipxact:size>10</ipxact:size>\"\r\n\t\t\"<ipxact:field>\"\r\n\t\t\"<ipxact:name>simpleField</ipxact:name>\"\r\n\t\t\"<ipxact:bitOffset>fieldOffset</ipxact:bitOffset>\"\r\n\t\t\"<ipxact:bitWidth>fieldWidth</ipxact:bitWidth>\"\r\n\t\t\"</ipxact:field>\"\r\n\t\t\"</ipxact:register>\"\r\n\t\t\"<ipxact:registerFile>\"\r\n\t\t\"<ipxact:name>contained</ipxact:name>\"\r\n\t\t\"<ipxact:addressOffset>containedOffset</ipxact:addressOffset>\"\r\n\t\t\"<ipxact:range>containedRange</ipxact:range>\"\r\n\t\t\"</ipxact:registerFile>\"\r\n\t\t\"</ipxact:addressBlock>\"\r\n\t\t\"</ipxact:localMemoryMap>\"\r\n\t\t\"</ipxact:addressSpace>\"\r\n\t\t);\r\n\r\n    AddressSpaceWriter::writeAddressSpace(xmlStreamWriter, testAddressSpace_, Document::Revision::Std14);\r\n\tQCOMPARE(output, expectedOutput);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_AddressSpaceWriter::writeNewStd()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_AddressSpaceWriter::writeNewStd()\r\n{\r\n    QString output;\r\n    QXmlStreamWriter xmlStreamWriter(&output);\r\n\r\n\ttestAddressSpace_->setShortDescription(QString(\"shortDescription\"));\r\n\r\n\tQString expectedOutput(\r\n\t\t\"<ipxact:addressSpace>\"\r\n\t\t\t\"<ipxact:name>testAddressSpace</ipxact:name>\"\r\n\t\t\t\"<ipxact:shortDescription>shortDescription</ipxact:shortDescription>\"\r\n\t\t\t\"<ipxact:range></ipxact:range>\"\r\n\t\t\t\"<ipxact:width></ipxact:width>\"\r\n\t\t\"</ipxact:addressSpace>\"\r\n\t);\r\n\r\n\tAddressSpaceWriter::writeAddressSpace(xmlStreamWriter, testAddressSpace_, Document::Revision::Std22);\r\n\r\n\tQCOMPARE(output, expectedOutput);\r\n}\r\n\r\nQTEST_APPLESS_MAIN(tst_AddressSpaceWriter)\r\n\r\n#include \"tst_AddressSpaceWriter.moc\"\r\n"
  },
  {
    "path": "tests/IPXACTmodels/Component/tst_AddressSpaceWriter.pri",
    "content": "# ----------------------------------------------------\r\n# This file is generated by the Qt Visual Studio Add-in.\r\n# ------------------------------------------------------\r\n\r\nSOURCES += ./tst_AddressSpaceWriter.cpp \r\n"
  },
  {
    "path": "tests/IPXACTmodels/Component/tst_AddressSpaceWriter.pro",
    "content": "#-----------------------------------------------------------------------------\r\n# File: tst_AddressSpaceWriter.pro\r\n#-----------------------------------------------------------------------------\r\n# Project: Kactus 2\r\n# Author: Janne Virtanen\r\n# Date: 01.10.2015\r\n#\r\n# Description:\r\n# Qt project file template for running unit tests for AddressSpace Writer.\r\n#-----------------------------------------------------------------------------\r\n\r\nTEMPLATE = app\r\n\r\nTARGET = tst_AddressSpaceWriter\r\n\r\nQT += core xml testlib\r\nQT -= gui\r\n\r\nCONFIG += c++11 testcase console\r\n\r\nlinux-g++ | linux-g++-64 | linux-g++-32 {\r\n LIBS += -L../../../executable \\\r\n     -lIPXACTmodels\r\n\r\n}\r\nwin64 | win32 {\r\n LIBS += -L../../../executable \\\r\n     -lIPXACTmodelsd\r\n}\r\n\r\nINCLUDEPATH += $$DESTDIR\r\nINCLUDEPATH += ../../../\r\n\r\nDEPENDPATH += .\r\nDEPENDPATH += ../../../\r\n\r\nOBJECTS_DIR += $$DESTDIR\r\n\r\nMOC_DIR += ./generatedFiles\r\nUI_DIR += ./generatedFiles\r\nRCC_DIR += ./generatedFiles\r\ninclude(tst_AddressSpaceWriter.pri)\r\n"
  },
  {
    "path": "tests/IPXACTmodels/Component/tst_BusInterfacePortMapValidator.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: tst_BusInterfacePortMapValidator.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 21.05.2019\n//\n// Description:\n// Unit test for class BusInterfacePortMapValidator.\n//-----------------------------------------------------------------------------\n\n#include <IPXACTmodels/AbstractionDefinition/AbstractionDefinition.h>\n\n#include <IPXACTmodels/AbstractionDefinition/TransactionalPort.h>\n#include <IPXACTmodels/AbstractionDefinition/WirePort.h>\n#include <IPXACTmodels/AbstractionDefinition/WireAbstraction.h>\n#include <IPXACTmodels/AbstractionDefinition/TransactionalAbstraction.h>\n#include <IPXACTmodels/AbstractionDefinition/PortAbstraction.h>\n\n#include <IPXACTmodels/common/ConfigurableVLNVReference.h>\n\n#include <IPXACTmodels/Component/Port.h>\n#include <IPXACTmodels/Component/BusInterface.h>\n#include <IPXACTmodels/Component/AbstractionType.h>\n#include <IPXACTmodels/Component/PortMap.h>\n\n#include <IPXACTmodels/Component/validators/PortMapValidator.h>\n\n#include <KactusAPI/include/SystemVerilogExpressionParser.h>\n\n#include <tests/MockObjects/LibraryMock.h>\n\n#include <QtTest>\n\nclass tst_BusInterfacePortMapValidator : public QObject\n{\n    Q_OBJECT\n\npublic:\n    tst_BusInterfacePortMapValidator();\n\nprivate slots:\n\n    void testPortMapLogicalPortIsValid();\n    void testPortMapLogicalPortIsValid_data();\n\n    void testPortMapPhysicalPortIsValid();\n    void testPortMapPhysicalPortIsValid_data();\n\n    void testPortMapConnectedPortDirectionsAreValid();\n    void testPortMapConnectedPortDirectionsAreValid_data();\n    void testPortMapConnectedPortInitiativesAreValid();\n    void testPortMapConnectedPortInitiativesAreValid_data();\n\n    void testPortMapConnectedPortsHaveValidType();\n    void testPortMapConnectedPortsHaveValidType_data();\n    void testPortMapConnectedPortsHaveSameRange();\n    void testPortMapConnectedPortsHaveSameRange_data();\n\nprivate:\n\n    bool errorIsNotFoundInErrorList(QString const& expectedError, QVector<QString> errorList);\n\n    QSharedPointer<Port> createWirePort(QString const& portName);\n\n    QSharedPointer<Port> createTransactionalPort(QString const& portName);\n\n    QSharedPointer<PortMapValidator> createPortMapValidator(QSharedPointer<ExpressionParser> expressionParser,\n        QSharedPointer<QList<QSharedPointer<Port> > > ports, LibraryInterface* libraryHandler);\n};\n\ntst_BusInterfacePortMapValidator::tst_BusInterfacePortMapValidator()\n{\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_BusInterfacePortMapValidator::testPortMapLogicalPortIsValid()\n//-----------------------------------------------------------------------------\nvoid tst_BusInterfacePortMapValidator::testPortMapLogicalPortIsValid()\n{\n    QFETCH(QString, logicalPortName);\n    QFETCH(QString, rangeLeft);\n    QFETCH(QString, rangeRight);\n    QFETCH(QString, abstractionWidth);\n    QFETCH(bool, createPort);\n    QFETCH(bool, isWire);\n    QFETCH(bool, isValid);\n\n    QSharedPointer<ConfigurableVLNVReference> abstractionReference (new ConfigurableVLNVReference(\n        VLNV::ABSTRACTIONDEFINITION, \"testVendor\", \"testLibrary\", \"Everett\", \"5.1\"));\n\n    QSharedPointer<AbstractionDefinition> abstractionDefinition(new AbstractionDefinition(*abstractionReference,\n        Document::Revision::Std14));\n\n    if (createPort)\n    {\n        QSharedPointer<PortAbstraction> testLogicalAbstraction(new PortAbstraction());\n\n        if (isWire)\n        {\n            QSharedPointer<WirePort> masterWire(new WirePort());\n            masterWire->setDirection(DirectionTypes::IN);\n            masterWire->setWidth(abstractionWidth);\n\n            QSharedPointer<WireAbstraction> logicalWireAbstraction(new WireAbstraction());\n            logicalWireAbstraction->setMasterPort(masterWire);\n\n            testLogicalAbstraction->setWire(logicalWireAbstraction);\n        }\n        else\n        {\n            QSharedPointer<TransactionalPort> masterTransactional(new TransactionalPort());\n            masterTransactional->setInitiative(\"requires\");\n            masterTransactional->setBusWidth(abstractionWidth);\n\n            QSharedPointer<TransactionalAbstraction> logicalTransactionalAbstraction(\n                new TransactionalAbstraction());\n            logicalTransactionalAbstraction->setMasterPort(masterTransactional);\n\n            testLogicalAbstraction->setTransactional(logicalTransactionalAbstraction);\n        }\n\n        testLogicalAbstraction->setLogicalName(logicalPortName);\n        abstractionDefinition->getLogicalPorts()->append(testLogicalAbstraction);\n    }\n\n    LibraryMock* mockLibrary (new LibraryMock(this));\n    mockLibrary->addComponent(abstractionDefinition);\n\n    QSharedPointer<Range> logicalRange (new Range(rangeLeft, rangeRight));\n\n    QSharedPointer<PortMap::LogicalPort> testLogical (new PortMap::LogicalPort());\n    testLogical->name_ = logicalPortName;\n    testLogical->range_ = logicalRange;\n\n    QSharedPointer<PartSelect> physicalPart (new PartSelect(rangeLeft, rangeRight));\n\n    QSharedPointer<PortMap::PhysicalPort> testPhysical (new PortMap::PhysicalPort());\n    testPhysical->name_ = QLatin1String(\"Physical\");\n    testPhysical->partSelect_ = physicalPart;\n\n    QSharedPointer<PortMap> testPortMap (new PortMap());\n    testPortMap->setLogicalPort(testLogical);\n    testPortMap->setPhysicalPort(testPhysical);\n\n    QSharedPointer<ExpressionParser> parser(new SystemVerilogExpressionParser());\n\n    QSharedPointer<Port> newPort;\n    if (isWire)\n    {\n        newPort = createWirePort(testPhysical->name_);\n        newPort->setLeftBound(rangeLeft);\n        newPort->setRightBound(rangeRight);\n    }\n    else\n    {\n        newPort = createTransactionalPort(testPhysical->name_);\n        \n        // Set transactional port width to smallest needed for tests.\n        quint64 logicalWidth = qMax(parser->parseExpression(rangeLeft).toULongLong(),\n            parser->parseExpression(rangeRight).toULongLong()) + 1;\n\n        newPort->getTransactional()->setBusWidth(QString::number(logicalWidth));\n    }\n\n    QSharedPointer<QList<QSharedPointer<Port> > > componentPorts (new QList<QSharedPointer<Port> > ());\n    componentPorts->append(newPort);\n\n    QSharedPointer<PortMapValidator> validator = createPortMapValidator(parser, componentPorts, mockLibrary);\n    validator->busInterfaceChanged(abstractionReference, General::MASTER, QString(\"\"));\n\n    QCOMPARE(validator->hasValidLogicalPort(testPortMap->getLogicalPort()), isValid);\n\n    if (!isValid)\n    {\n        quint64 logicalWidth =\n            parser->parseExpression(rangeRight).toULongLong() - parser->parseExpression(rangeLeft).toULongLong();\n        quint64 abstractionWidthValue = parser->parseExpression(abstractionWidth).toULongLong();\n\n        QString context = QLatin1String(\"test\");\n\n        QVector<QString> errorsFound;\n        validator->findErrorsIn(errorsFound, testPortMap, context);\n\n        QString expectedError;\n        if (logicalPortName.isEmpty())\n        {\n            expectedError = QObject::tr(\"Port map does not contain a logical port within %1\").arg(context);\n        }\n        else if (!createPort)\n        {\n            expectedError = QObject::tr(\"Could not locate logical port %1 mapped within %2\")\n                .arg(logicalPortName).arg(context);\n        }\n        else if (parser->parseExpression(rangeLeft).toInt() < 0)\n        {\n            expectedError = QObject::tr(\"Invalid value given for logical left in logical port %1 mapped within %2\")\n                    .arg(logicalPortName).arg(context);\n        }\n        else if (parser->parseExpression(rangeRight).toInt() < 0)\n        {\n            expectedError =\n                QObject::tr(\"Invalid value given for logical right in logical port %1 mapped within %2\")\n                .arg(logicalPortName).arg(context);\n        }\n        else if (rangeLeft.isEmpty())\n        {\n            expectedError = QObject::tr(\"Empty left value in logical port %1 mapped within %2\")\n                .arg(logicalPortName).arg(context);\n        }\n        else if (rangeRight.isEmpty())\n        {\n            expectedError = QObject::tr(\"Empty right value in logical port %1 mapped within %2\")\n                .arg(logicalPortName).arg(context);\n        }\n        else if (logicalWidth > abstractionWidthValue)\n        {\n            expectedError = QObject::tr(\n                \"Range is not within the referenced port width in mapped logical port %1 in %2\")\n                .arg(logicalPortName).arg(context);\n        }\n\n        if (errorIsNotFoundInErrorList(expectedError, errorsFound))\n        {\n            QFAIL(\"Error was not found\");\n        }\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_BusInterfacePortMapValidator::testPortMapLogicalPortIsValid_data()\n//-----------------------------------------------------------------------------\nvoid tst_BusInterfacePortMapValidator::testPortMapLogicalPortIsValid_data()\n{\n    QTest::addColumn<QString>(\"logicalPortName\");\n    QTest::addColumn<QString>(\"rangeLeft\");\n    QTest::addColumn<QString>(\"rangeRight\");\n    QTest::addColumn<QString>(\"abstractionWidth\");\n    QTest::addColumn<bool>(\"createPort\");\n    QTest::addColumn<bool>(\"isWire\");\n    QTest::addColumn<bool>(\"isValid\");\n\n    QTest::newRow(\"Wire: Logical port with long range is valid\") <<\n        \"logicalPort\" << \"4000000000\" << \"4000000001\" << \"5000000000\" << true << true << true;\n\n    QTest::newRow(\"Wire: Logical port without range is valid\") <<\n        \"logicalPort\" << \"\" << \"\" << \"\" << true << true << true;\n    QTest::newRow(\"Wire: Logical port with range is valid\") <<\n        \"logicalPort\" << \"4+4\" << \"12\" << \"\" << true << true << true;\n    QTest::newRow(\"Wire: Logical port with either range as 0 is valid\") <<\n        \"logicalPort\" << \"0\" << \"0\" << \"\" << true << true << true;\n    QTest::newRow(\"Wire: Logical port with negative range left value is not valid\") <<\n        \"logicalPort\" << \"-1\" << \"1\" << \"\" << true << true << false;\n    QTest::newRow(\"Wire: Logical port with negative range right value is not valid\") <<\n        \"logicalPort\" << \"1\" << \"-1\" << \"\" << true << true << false;\n    QTest::newRow(\"Wire: Logical port without left range value is not valid\") <<\n        \"logicalPort\" << \"\" << \"12\" << \"\" << true << true << false;\n    QTest::newRow(\"Wire: Logical port without right range value is not valid\") <<\n        \"logicalPort\" << \"12\" << \"\" << \"\" << true << true << false;\n    QTest::newRow(\"Wire: Referencing non-existing logical port is not valid\") <<\n        \"logicalPort\" << \"\" << \"\" << \"\" << false << true << false;\n    QTest::newRow(\"Wire: Empty logical port reference is not valid\") << \"\" << \"\" << \"\" << \"\" << true << true << false;\n\n    QTest::newRow(\"Wire: Range within abstraction width is valid\") <<\n        \"illogical\" << \"0\" << \"5\" << \"10\" << true << true << true;\n    QTest::newRow(\"Wire: Right range not within abstraction width is not valid\") <<\n        \"illogical\" << \"0\" << \"20\" << \"10\" << true << true << false;\n    QTest::newRow(\"Wire: Left range not within abstraction width is not valid\") <<\n        \"illogical\" << \"15\" << \"8\" << \"10\" << true << true << false;\n\n    QTest::newRow(\"Transactional: Logical port with long range is valid\") <<\n        \"logicalPort\" << \"4000000000\" << \"4000000001\" << \"5000000000\" << true << false << true;\n\n    QTest::newRow(\"Transactional: Logical port without range is valid\") <<\n        \"logicalPort\" << \"\" << \"\" << \"\" << true << false << true;\n    QTest::newRow(\"Transactional: Logical port with range is valid\") <<\n        \"logicalPort\" << \"4+4\" << \"12\" << \"\" << true << false << true;\n    QTest::newRow(\"Transactional: Logical port with either range as 0 is valid\") <<\n        \"logicalPort\" << \"0\" << \"0\" << \"\" << true << false << true;\n    QTest::newRow(\"Transactional: Logical port with negative range left value is not valid\") <<\n        \"logicalPort\" << \"-1\" << \"1\" << \"\" << true << false << false;\n    QTest::newRow(\"Transactional: Logical port with negative range right value is not valid\") <<\n        \"logicalPort\" << \"1\" << \"-1\" << \"\" << true << false << false;\n    QTest::newRow(\"Transactional: Logical port without left range value is not valid\") <<\n        \"logicalPort\" << \"\" << \"12\" << \"\" << true << false << false;\n    QTest::newRow(\"Transactional: Logical port without right range value is not valid\") <<\n        \"logicalPort\" << \"12\" << \"\" << \"\" << true << false << false;\n    QTest::newRow(\"Transactional: Referencing non-existing logical port is not valid\") <<\n        \"logicalPort\" << \"\" << \"\" << \"\" << false << false << false;\n    QTest::newRow(\"Transactional: Empty logical port reference is not valid\")\n        << \"\" << \"\" << \"\" << \"\" << true << false << false;\n\n    QTest::newRow(\"Transactional: Range within abstraction width is valid\") <<\n        \"illogical\" << \"0\" << \"5\" << \"10\" << true << false << true;\n    QTest::newRow(\"Transactional: Right range not within abstraction width is not valid\") <<\n        \"illogical\" << \"0\" << \"20\" << \"10\" << true << false << false;\n    QTest::newRow(\"Transactional: Left range not within abstraction width is not valid\") <<\n        \"illogical\" << \"15\" << \"8\" << \"10\" << true << false << false;\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_BusInterfacePortMapValidator::testPortMapPhysicalPortIsValid()\n//-----------------------------------------------------------------------------\nvoid tst_BusInterfacePortMapValidator::testPortMapPhysicalPortIsValid()\n{\n    QFETCH(QString, physicalPortName);\n    QFETCH(QString, physicalRangeLeft);\n    QFETCH(QString, physicalRangeRight);\n    QFETCH(QString, portLeftBound);\n    QFETCH(QString, portRigthBound);\n    QFETCH(bool, createPort);\n    QFETCH(bool, isWire);\n    QFETCH(bool, isValid);\n\n    QSharedPointer<ConfigurableVLNVReference> abstractionReference (new ConfigurableVLNVReference(\n        VLNV::ABSTRACTIONDEFINITION, \"testVendor\", \"testLibrary\", \"Everett\", \"5.1\"));\n\n    QSharedPointer<AbstractionDefinition> abstractionDefinition(new AbstractionDefinition(*abstractionReference,\n        Document::Revision::Std14));\n\n    QSharedPointer<PortAbstraction> testLogicalAbstraction (new PortAbstraction());\n    testLogicalAbstraction->setLogicalName(\"testLogical\");\n    abstractionDefinition->getLogicalPorts()->append(testLogicalAbstraction);\n\n    if (isWire)\n    {\n        QSharedPointer<WireAbstraction> logicalWireAbstraction(new WireAbstraction());\n        testLogicalAbstraction->setWire(logicalWireAbstraction);\n    }\n    else\n    {\n        QSharedPointer<TransactionalAbstraction> logicalTransactionalAbstraction(new TransactionalAbstraction());\n        testLogicalAbstraction->setTransactional(logicalTransactionalAbstraction);\n    }\n\n    LibraryMock* mockLibrary (new LibraryMock(this));\n    mockLibrary->addComponent(abstractionDefinition);\n\n    QSharedPointer<Range> logicalRange (new Range(physicalRangeLeft, physicalRangeRight));\n\n    QSharedPointer<PortMap::LogicalPort> testLogical (new PortMap::LogicalPort());\n    testLogical->name_ = testLogicalAbstraction->name();\n    testLogical->range_ = logicalRange;\n\n    QSharedPointer<PartSelect> physicalPart (new PartSelect(physicalRangeLeft, physicalRangeRight));\n\n    QSharedPointer<PortMap::PhysicalPort> testPhysical (new PortMap::PhysicalPort());\n    testPhysical->name_ = physicalPortName;\n    testPhysical->partSelect_ = physicalPart;\n\n    QSharedPointer<PortMap> testPortMap (new PortMap());\n    testPortMap->setLogicalPort(testLogical);\n    testPortMap->setPhysicalPort(testPhysical);\n\n    QSharedPointer<ExpressionParser> parser(new SystemVerilogExpressionParser());\n\n    QSharedPointer<QList<QSharedPointer<Port> > > componentPorts (new QList<QSharedPointer<Port> > ());\n    if (createPort)\n    {\n        QSharedPointer<Port> newPort;\n        if (isWire)\n        {\n            newPort = createWirePort(physicalPortName);\n            newPort->setLeftBound(portLeftBound);\n            newPort->setRightBound(portRigthBound);\n        }\n        else\n        {\n            newPort = createTransactionalPort(physicalPortName);\n\n            // Set transactional port width to smallest needed for tests.\n            quint64 logicalWidth = qMax(parser->parseExpression(portLeftBound).toULongLong(),\n                parser->parseExpression(portRigthBound).toULongLong()) + 1;\n\n            newPort->getTransactional()->setBusWidth(QString::number(logicalWidth));\n        }\n\n        if (physicalPortName.isEmpty())\n        {\n            physicalPortName = \"Champloo\";\n            newPort->setName(physicalPortName);\n            physicalPortName.clear();\n        }\n        componentPorts->append(newPort);\n    }\n\n    QSharedPointer<PortMapValidator> validator = createPortMapValidator(parser, componentPorts, mockLibrary);\n    validator->busInterfaceChanged(abstractionReference, General::MASTER, QLatin1String(\"\"));\n\n    QCOMPARE(validator->hasValidPhysicalPort(testPhysical), isValid);\n\n    if (!isValid)\n    {\n        quint64 leftValue = parser->parseExpression(physicalRangeLeft).toULongLong();\n        quint64 rightValue = parser->parseExpression(physicalRangeRight).toULongLong();\n        quint64 portMax = qMax(parser->parseExpression(portLeftBound).toULongLong(),\n            parser->parseExpression(portRigthBound).toULongLong());\n        quint64 portMin = qMin(parser->parseExpression(portLeftBound).toULongLong(),\n            parser->parseExpression(portRigthBound).toULongLong());\n\n        QString context = QLatin1String(\"test\");\n        QVector<QString> errorsFound;\n        validator->findErrorsIn(errorsFound, testPortMap, \"test\");\n\n        QString expectedError;\n\n        if (physicalPortName.isEmpty())\n        {\n            expectedError = QObject::tr(\"Port map does not contain a physical port or a logical tie off within %1\")\n                .arg(context);\n        }\n        else if (!createPort)\n        {\n            expectedError = QObject::tr(\"Could not locate physical port %1 mapped within %2\")\n                .arg(physicalPortName).arg(context);\n        }\n        else if (parser->parseExpression(physicalRangeLeft).toInt() < 0)\n        {\n            expectedError =\n                QObject::tr(\"Invalid value given for physical left in physical port %1 mapped within %2\")\n                .arg(physicalPortName).arg(context);\n        }\n        else if (parser->parseExpression(physicalRangeRight).toInt() < 0)\n        {\n            expectedError =\n                QObject::tr(\"Invalid value given for physical right in physical port %1 mapped within %2\")\n                .arg(physicalPortName).arg(context);\n        }\n        else if (physicalRangeLeft.isEmpty())\n        {\n            expectedError = QObject::tr(\"Empty left value in physical port %1 mapped within %2\")\n                .arg(physicalPortName).arg(context);\n        }\n        else if (physicalRangeRight.isEmpty())\n        {\n            expectedError = QObject::tr(\"Empty right value in physical port %1 mapped within %2\")\n                .arg(physicalPortName).arg(context);\n        }\n        else if (leftValue > portMax || rightValue > portMax || leftValue < portMin || rightValue < portMin)\n        {\n            expectedError = QObject::tr(\n                \"Range is not within the referenced port width in mapped physical port %1 in %2\")\n                .arg(physicalPortName).arg(context);\n        }\n\n        if (errorIsNotFoundInErrorList(expectedError, errorsFound))\n        {\n            QFAIL(\"Error was not found\");\n        }\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_BusInterfacePortMapValidator::testPortMapPhysicalPortIsValid_data()\n//-----------------------------------------------------------------------------\nvoid tst_BusInterfacePortMapValidator::testPortMapPhysicalPortIsValid_data()\n{\n    QTest::addColumn<QString>(\"physicalPortName\");\n    QTest::addColumn<QString>(\"physicalRangeLeft\");\n    QTest::addColumn<QString>(\"physicalRangeRight\");\n    QTest::addColumn<QString>(\"portLeftBound\");\n    QTest::addColumn<QString>(\"portRigthBound\");\n    QTest::addColumn<bool>(\"createPort\");\n    QTest::addColumn<bool>(\"isWire\");\n    QTest::addColumn<bool>(\"isValid\");\n\n    QTest::newRow(\"Wire: Physical port without range is valid\")\n        << \"physicalPort\" << \"\" << \"\" << \"0\" << \"20\" << true << true << true;\n    QTest::newRow(\"Wire: Physical port with range is valid\")\n        << \"physicalPort\" << \"4+4\" << \"12\" << \"0\" << \"20\" <<  true << true << true;\n    QTest::newRow(\"Wire: Physical port with either range as 0 is valid\")\n        << \"physicalPort\" << \"0\" << \"0\" << \"0\" << \"20\" << true << true << true;\n    QTest::newRow(\"Wire: Physical port with negative range left value is not valid\")\n        << \"physicalPort\" << \"-1\" << \"1\" << \"0\" << \"20\" << true << true << false;\n    QTest::newRow(\"Wire: Physical port with negative range right value is not valid\")\n        << \"physicalPort\" << \"1\" << \"-1\" << \"0\" << \"20\" << true << true << false;\n    QTest::newRow(\"Wire: Physical port without left range value is not valid\")\n        << \"leftRangeIsEmpty\" << \"\" << \"12\" << \"0\" << \"20\" << true << true << false;\n    QTest::newRow(\"Wire: Physical port without right range value is not valid\")\n        << \"physicalPort\" << \"12\" << \"\" << \"0\" << \"20\" << true << true << false;\n    QTest::newRow(\"Wire: Referencing non-existing physical port is not valid\")\n        << \"physicalPort\" << \"\" << \"\" << \"0\" << \"20\" << false << true << false;\n    QTest::newRow(\"Wire: Empty physical port reference is not valid\")\n        << \"\" << \"\" << \"\" << \"0\" << \"20\" << true << true << false;\n\n    QTest::newRow(\"Wire: Physical port ranges outside referenced port range is not valid\")\n        << \"testPort\" << \"0\" << \"4\" << \"1\" << \"10\" << true << true << false;\n    QTest::newRow(\"Wire: Physical port ranges outside referenced port range is not valid\")\n        << \"testPort\" << \"12\" << \"4\" << \"1\" << \"10\" << true << true << false;\n\n    QTest::newRow(\"Wire: Physical port with long range is valid\") <<\n        \"longWire\" << \"4000000000\" << \"4000000000\" << \"5000000000\" << \"3000000000\" << true << true << true;\n\n\n    QTest::newRow(\"Transactional: Physical port without range is valid\")\n        << \"physicalPort\" << \"\" << \"\" << \"0\" << \"20\" << true << false << true;\n    QTest::newRow(\"Transactional: Physical port with range is valid\")\n        << \"physicalPort\" << \"4+4\" << \"12\" << \"0\" << \"20\" << true << false << true;\n    QTest::newRow(\"Transactional: Physical port with either range as 0 is valid\")\n        << \"physicalPort\" << \"0\" << \"0\" << \"0\" << \"20\" << true << false << true;\n    QTest::newRow(\"Transactional: Physical port with negative range left value is not valid\")\n        << \"physicalPort\" << \"-1\" << \"1\" << \"0\" << \"20\" << true << false << false;\n    QTest::newRow(\"Transactional: Physical port with negative range right value is not valid\")\n        << \"physicalPort\" << \"1\" << \"-1\" << \"0\" << \"20\" << true << false << false;\n    QTest::newRow(\"Transactional: Physical port without left range value is not valid\")\n        << \"physicalPort\" << \"\" << \"12\" << \"0\" << \"20\" << true << false << false;\n    QTest::newRow(\"Transactional: Physical port without right range value is not valid\")\n        << \"physicalPort\" << \"12\" << \"\" << \"0\" << \"20\" << true << false << false;\n    QTest::newRow(\"Transactional: Referencing non-existing physical port is not valid\")\n        << \"physicalPort\" << \"\" << \"\" << \"0\" << \"20\" << false << false << false;\n    QTest::newRow(\"Transactional: Empty physical port reference is not valid\")\n        << \"\" << \"\" << \"\" << \"0\" << \"20\" << true << false << false;\n\n    QTest::newRow(\"Transactional: Physical port ranges outside referenced port range is not valid\")\n        << \"transactionalRangeTest\" << \"0\" << \"11\" << \"0\" << \"10\" << true << false << false;\n    QTest::newRow(\"Transactional: Physical port ranges outside referenced port range is not valid\")\n        << \"testPort\" << \"12\" << \"4\" << \"1\" << \"10\" << true << false << false;\n\n    QTest::newRow(\"Transactional: Physical port with long range is valid\") <<\n        \"testPort\" << \"4000000000\" << \"4000000000\" << \"5000000000\" << \"3000000000\" << true << false << true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_BusInterfacePortMapValidator::testPortMapConnectedPortDirectionsAreValid()\n//-----------------------------------------------------------------------------\nvoid tst_BusInterfacePortMapValidator::testPortMapConnectedPortDirectionsAreValid()\n{\n    QFETCH(QString, logicalDirection);\n    QFETCH(QString, physicalDirection);\n    QFETCH(bool, physicalAllLogicalDirectionsAllowed);\n    QFETCH(bool, isMirroredInterface);\n    QFETCH(bool, isValid);\n\n    QSharedPointer<ConfigurableVLNVReference> abstractionReference (new ConfigurableVLNVReference(\n        VLNV::ABSTRACTIONDEFINITION, \"testVendor\", \"testLibrary\", \"Everett\", \"5.1\"));\n\n    QSharedPointer<AbstractionDefinition> abstractionDefinition (new AbstractionDefinition(*abstractionReference,\n        Document::Revision::Std14));\n\n    QSharedPointer<WirePort> masterWire (new WirePort());\n    masterWire->setDirection(DirectionTypes::str2Direction(logicalDirection, DirectionTypes::DIRECTION_INVALID));\n\n    QSharedPointer<WireAbstraction> logicalWireAbstraction (new WireAbstraction());\n\n    QSharedPointer<PortAbstraction> testLogicalAbstraction (new PortAbstraction());\n    testLogicalAbstraction->setLogicalName(\"testLogical\");\n    testLogicalAbstraction->setWire(logicalWireAbstraction);\n    testLogicalAbstraction->getWire()->setMasterPort(masterWire);\n\n    abstractionDefinition->getLogicalPorts()->append(testLogicalAbstraction);\n\n    LibraryMock* mockLibrary (new LibraryMock(this));\n    mockLibrary->addComponent(abstractionDefinition);\n\n    QSharedPointer<PortMap::LogicalPort> testLogical (new PortMap::LogicalPort());\n    testLogical->name_ = testLogicalAbstraction->name();\n\n    QSharedPointer<PortMap::PhysicalPort> testPhysical (new PortMap::PhysicalPort());\n    testPhysical->name_ = \"testPhysicalPort\";\n\n    QSharedPointer<Port> newPort = createWirePort(testPhysical->name_);\n    newPort->getWire()->setDirection(\n        DirectionTypes::str2Direction(physicalDirection, DirectionTypes::DIRECTION_INVALID));\n    newPort->getWire()->setAllLogicalDirectionsAllowed(physicalAllLogicalDirectionsAllowed);\n    QSharedPointer<QList<QSharedPointer<Port> > > componentPorts (new QList<QSharedPointer<Port> > ());\n    componentPorts->append(newPort);\n\n    QSharedPointer<PortMap> testPortMap (new PortMap());\n    testPortMap->setLogicalPort(testLogical);\n    testPortMap->setPhysicalPort(testPhysical);\n\n    General::InterfaceMode busMode = General::MASTER;\n\n    if (isMirroredInterface)\n    {\n        busMode = General::MIRRORED_MASTER;\n    }\n\n    QSharedPointer<ExpressionParser> parser (new SystemVerilogExpressionParser());\n\n    QSharedPointer<PortMapValidator> validator = createPortMapValidator(parser, componentPorts, mockLibrary);\n    validator->abstractionDefinitionChanged(abstractionDefinition, busMode);\n    validator->busInterfaceChanged(abstractionReference, busMode, QString(\"\"));\n\n    QCOMPARE(validator->connectedPortsHaveValidDirections(testLogicalAbstraction, newPort), isValid);\n\n    if (!isValid)\n    {\n        QString context = QLatin1String(\"test\");\n\n        QVector<QString> errorsFound;\n        validator->findErrorsIn(errorsFound, testPortMap, \"test\");\n\n        QString expectedError = QObject::tr(\"Invalid connection made between logical port '%1' with direction \"\n            \"'%2' and physical port '%3' with direction '%4' within %5\")\n            .arg(testPortMap->getLogicalPort()->name_).arg(logicalDirection)\n            .arg(testPortMap->getPhysicalPort()->name_).arg(physicalDirection)\n            .arg(context);\n\n        if (errorIsNotFoundInErrorList(expectedError, errorsFound))\n        {\n            QFAIL(\"Error was not found\");\n        }\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_BusInterfacePortMapValidator::testPortMapConnectedPortDirectionsAreValid_data()\n//-----------------------------------------------------------------------------\nvoid tst_BusInterfacePortMapValidator::testPortMapConnectedPortDirectionsAreValid_data()\n{\n    QTest::addColumn<QString>(\"logicalDirection\");\n    QTest::addColumn<QString>(\"physicalDirection\");\n    QTest::addColumn<bool>(\"physicalAllLogicalDirectionsAllowed\");\n    QTest::addColumn<bool>(\"isMirroredInterface\");\n    QTest::addColumn<bool>(\"isValid\");\n\n    QTest::newRow(\"Logical port direction=in, physical port direction=in is valid\")\n        << \"in\" << \"in\" << false << false << true;\n    QTest::newRow(\"Logical port direction=in, physical port direction=out is not valid\")\n        << \"in\" << \"out\" << false << false << false;\n    QTest::newRow(\"Logical port direction=in, physical port direction=inout is valid\")\n        << \"in\" << \"inout\" << false << false << true;\n    QTest::newRow(\"Logical port direction=in, physical port direction=phantom is valid\")\n        << \"in\" << \"phantom\" << false << false << true;\n    QTest::newRow(\"Logical port direction=in, physical port has allLogicalDirectionsAllowed is valid\")\n        << \"in\" << \"out\" << true << false << true;\n\n    QTest::newRow(\"Logical port direction=out, physical port direction=in is not valid\")\n        << \"out\" << \"in\" << false << false << false;\n    QTest::newRow(\"Logical port direction=out, physical port direction=out is valid\")\n        << \"out\" << \"out\" << false << false << true;\n    QTest::newRow(\"Logical port direction=out, physical port direction=inout is valid\")\n        << \"out\" << \"inout\" << false << false << true;\n    QTest::newRow(\"Logical port direction=out, physical port direction=phantom is valid\")\n        << \"out\" << \"phantom\" << false << false << true;\n    QTest::newRow(\"Logical port direction=out, physical port has allLogicalDirectionsAllowed is valid\")\n        << \"out\" << \"in\" << true << false << true;\n\n    QTest::newRow(\"Logical port direction=inout, physical port direction=in is not valid\")\n        << \"inout\" << \"in\" << false << false << false;\n    QTest::newRow(\"Logical port direction=out, physical port direction=out is not valid\")\n        << \"inout\" << \"out\" << false << false << false;\n    QTest::newRow(\"Logical port direction=out, physical port direction=inout is valid\")\n        << \"inout\" << \"inout\" << false << false << true;\n    QTest::newRow(\"Logical port direction=out, physical port direction=phantom is valid\")\n        << \"inout\" << \"phantom\" << false << false << true;\n    QTest::newRow(\"Logical port direction=out, physical port has allLogicalDirectionsAllowed is valid\")\n        << \"inout\" << \"in\" << true << false << true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_BusInterfacePortMapValidator::testPortMapConnectedPortDirectionsAreValid()\n//-----------------------------------------------------------------------------\nvoid tst_BusInterfacePortMapValidator::testPortMapConnectedPortInitiativesAreValid()\n{\n    QFETCH(QString, logicalInitiative);\n    QFETCH(QString, physicalInitiative);\n    QFETCH(bool, isValid);\n\n    QSharedPointer<ConfigurableVLNVReference> abstractionReference(new ConfigurableVLNVReference(\n        VLNV::ABSTRACTIONDEFINITION, \"testVendor\", \"testLibrary\", \"Everett\", \"5.1\"));\n\n    QSharedPointer<AbstractionDefinition> abstractionDefinition(new AbstractionDefinition(*abstractionReference,\n        Document::Revision::Std14));\n\n    QSharedPointer<TransactionalPort> masterTransactional(new TransactionalPort());\n    masterTransactional->setInitiative(logicalInitiative);\n\n    QSharedPointer<TransactionalAbstraction> logicalTransactionalAbstraction(new TransactionalAbstraction());\n\n    QSharedPointer<PortAbstraction> testLogicalAbstraction(new PortAbstraction());\n    testLogicalAbstraction->setLogicalName(\"testLogical\");\n    testLogicalAbstraction->setTransactional(logicalTransactionalAbstraction);\n    testLogicalAbstraction->getTransactional()->setMasterPort(masterTransactional);\n\n    abstractionDefinition->getLogicalPorts()->append(testLogicalAbstraction);\n\n    LibraryMock* mockLibrary(new LibraryMock(this));\n    mockLibrary->addComponent(abstractionDefinition);\n\n    QSharedPointer<PortMap::LogicalPort> testLogical(new PortMap::LogicalPort());\n    testLogical->name_ = testLogicalAbstraction->name();\n\n    QSharedPointer<PortMap::PhysicalPort> testPhysical(new PortMap::PhysicalPort());\n    testPhysical->name_ = \"testPhysicalPort\";\n\n    QSharedPointer<Port> newPort = createTransactionalPort(testPhysical->name_);\n    newPort->getTransactional()->setInitiative(physicalInitiative);\n    QSharedPointer<QList<QSharedPointer<Port> > > componentPorts(new QList<QSharedPointer<Port> >());\n    componentPorts->append(newPort);\n\n    QSharedPointer<PortMap> testPortMap(new PortMap());\n    testPortMap->setLogicalPort(testLogical);\n    testPortMap->setPhysicalPort(testPhysical);\n\n    General::InterfaceMode busMode = General::MASTER;\n\n    QSharedPointer<ExpressionParser> parser(new SystemVerilogExpressionParser());\n    QSharedPointer<PortMapValidator> validator = createPortMapValidator(parser, componentPorts, mockLibrary);\n    validator->abstractionDefinitionChanged(abstractionDefinition, busMode);\n    validator->busInterfaceChanged(abstractionReference, busMode, QString(\"\"));\n\n    QCOMPARE(validator->connectedPortsHaveValidInitiatives(testLogicalAbstraction, newPort), isValid);\n\n    if (!isValid)\n    {\n        QString context = QLatin1String(\"test\");\n\n        QVector<QString> errorsFound;\n        validator->findErrorsIn(errorsFound, testPortMap, \"test\");\n\n        QString expectedError = QObject::tr(\"Invalid connection made between logical port '%1' with initiative \"\n            \"'%2' and physical port '%3' with initiative '%4' within %5\")\n            .arg(testPortMap->getLogicalPort()->name_).arg(logicalInitiative)\n            .arg(testPortMap->getPhysicalPort()->name_).arg(physicalInitiative)\n            .arg(context);\n\n        if (errorIsNotFoundInErrorList(expectedError, errorsFound))\n        {\n            QFAIL(\"Error was not found\");\n        }\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_BusInterfacePortMapValidator::testPortMapConnectedPortInitiativesAreValid_data()\n//-----------------------------------------------------------------------------\nvoid tst_BusInterfacePortMapValidator::testPortMapConnectedPortInitiativesAreValid_data()\n{\n    QTest::addColumn<QString>(\"logicalInitiative\");\n    QTest::addColumn<QString>(\"physicalInitiative\");\n    QTest::addColumn<bool>(\"isValid\");\n\n    QTest::newRow(\"Logical port initiative=requires, physical port initiative=requires is valid\")\n        << \"requires\" << \"requires\" << true;\n    QTest::newRow(\"Logical port initiative=requires, physical port initiative=both is valid\")\n        << \"requires\" << \"both\" << true;\n    QTest::newRow(\"Logical port initiative=requires, physical port initiative=phantom is valid\")\n        << \"requires\" << \"phantom\" << true;\n    QTest::newRow(\"Logical port initiative=requires, physical port initiative=provides is not valid\")\n        << \"requires\" << \"provides\" << false;\n\n    QTest::newRow(\"Logical port initiative=provides, physical port initiative=requires is not valid\")\n        << \"provides\" << \"requires\" << false;\n    QTest::newRow(\"Logical port initiative=provides, physical port initiative=both is valid\")\n        << \"provides\" << \"both\" << true;\n    QTest::newRow(\"Logical port initiative=provides, physical port initiative=phantom is valid\")\n        << \"provides\" << \"phantom\" << true;\n    QTest::newRow(\"Logical port initiative=provides, physical port initiative=provides is valid\")\n        << \"provides\" << \"provides\" << true;\n\n    QTest::newRow(\"Logical port initiative=both, physical port initiative=requires is not valid\")\n        << \"both\" << \"requires\" << false;\n    QTest::newRow(\"Logical port initiative=both, physical port initiative=both is valid\")\n        << \"both\" << \"both\" << true;\n    QTest::newRow(\"Logical port initiative=both, physical port initiative=phantom is valid\")\n        << \"both\" << \"phantom\" << true;\n    QTest::newRow(\"Logical port initiative=both, physical port initiative=provides is not valid\")\n        << \"both\" << \"provides\" << false;\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_BusInterfacePortMapValidator::testPortMapConnectedPortsHaveValidType()\n//-----------------------------------------------------------------------------\nvoid tst_BusInterfacePortMapValidator::testPortMapConnectedPortsHaveValidType()\n{\n    QFETCH(bool, logicalHasWire);\n    QFETCH(bool, physicalHasWire);\n    QFETCH(bool, isValid);\n\n    QSharedPointer<ConfigurableVLNVReference> abstractionReference (new ConfigurableVLNVReference(\n        VLNV::ABSTRACTIONDEFINITION, \"testVendor\", \"testLibrary\", \"Everett\", \"5.1\"));\n\n    QSharedPointer<AbstractionDefinition> abstractionDefinition(new AbstractionDefinition(*abstractionReference,\n        Document::Revision::Std14));\n\n    QSharedPointer<PortAbstraction> testLogicalAbstraction (new PortAbstraction());\n    testLogicalAbstraction->setLogicalName(\"testLogical\");\n\n    if (logicalHasWire)\n    {\n        QSharedPointer<WireAbstraction> logicalWireAbstraction (new WireAbstraction());\n        testLogicalAbstraction->setWire(logicalWireAbstraction);\n    }\n    else\n    {\n        QSharedPointer<TransactionalAbstraction> logicalTransactional (new TransactionalAbstraction());\n        testLogicalAbstraction->setTransactional(logicalTransactional);\n    }\n\n    abstractionDefinition->getLogicalPorts()->append(testLogicalAbstraction);\n\n    LibraryMock* mockLibrary (new LibraryMock(this));\n    mockLibrary->addComponent(abstractionDefinition);\n\n    QSharedPointer<PortMap::LogicalPort> testLogical (new PortMap::LogicalPort());\n    testLogical->name_ = testLogicalAbstraction->name();\n\n    QSharedPointer<PortMap::PhysicalPort> testPhysical (new PortMap::PhysicalPort());\n    testPhysical->name_ = \"testPhysicalPort\";\n\n    QSharedPointer<Port> newPort = createWirePort(testPhysical->name_);\n    if (!physicalHasWire)\n    {\n        QSharedPointer<Transactional> physicalTransactional (new Transactional());\n        newPort->setTransactional(physicalTransactional);\n    }\n\n    QSharedPointer<QList<QSharedPointer<Port> > > componentPorts (new QList<QSharedPointer<Port> > ());\n    componentPorts->append(newPort);\n\n    QSharedPointer<PortMap> testPortMap (new PortMap());\n    testPortMap->setLogicalPort(testLogical);\n    testPortMap->setPhysicalPort(testPhysical);\n\n    QSharedPointer<ExpressionParser> parser (new SystemVerilogExpressionParser());\n\n    QSharedPointer<PortMapValidator> validator = createPortMapValidator(parser, componentPorts, mockLibrary);\n    validator->busInterfaceChanged(abstractionReference, General::MASTER, QString(\"\"));\n\n    QCOMPARE(validator->connectedPortsHaveValidPortTypes(testLogicalAbstraction, newPort), isValid);\n\n    if (!isValid)\n    {\n        QString context = QLatin1String(\"test\");\n\n        QVector<QString> errorsFound;\n        validator->findErrorsIn(errorsFound, testPortMap, context);\n\n        QString expectedError = QObject::tr(\"Connected logical port %1 and physical port %3 do not have the same \"\n            \"port type within %5\")\n            .arg(testPortMap->getLogicalPort()->name_).arg(testPortMap->getPhysicalPort()->name_).arg(context);\n\n        if (errorIsNotFoundInErrorList(expectedError, errorsFound))\n        {\n            QFAIL(\"Error was not found\");\n        }\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_BusInterfacePortMapValidator::testPortMapConnectedPortsHaveValidType_data()\n//-----------------------------------------------------------------------------\nvoid tst_BusInterfacePortMapValidator::testPortMapConnectedPortsHaveValidType_data()\n{\n    QTest::addColumn<bool>(\"logicalHasWire\");\n    QTest::addColumn<bool>(\"physicalHasWire\");\n    QTest::addColumn<bool>(\"isValid\");\n\n    QTest::newRow(\"Logical wire port connected to physical wire port is valid\") << true << true << true;\n    QTest::newRow(\"Logical wire port connected to physical transactional port is not valid\") << true << false <<\n        false;\n    QTest::newRow(\"Logical transactional port connected to physical wire port is not valid\") << false << true <<\n        false;\n    QTest::newRow(\"Logical transactional port connected to physical transactional port is valid\") << false <<\n        false << true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_BusInterfacePortMapValidator::testPortMapConnectedPortsHaveSameRange()\n//-----------------------------------------------------------------------------\nvoid tst_BusInterfacePortMapValidator::testPortMapConnectedPortsHaveSameRange()\n{\n    QFETCH(QString, logicalRangeLeft);\n    QFETCH(QString, logicalRangeRight);\n    QFETCH(QString, physicalRangeLeft);\n    QFETCH(QString, physicalRangeRight);\n    QFETCH(bool, isWire);\n    QFETCH(bool, isValid);\n\n    QSharedPointer<ConfigurableVLNVReference> abstractionReference (new ConfigurableVLNVReference(\n        VLNV::ABSTRACTIONDEFINITION, \"testVendor\", \"testLibrary\", \"Everett\", \"5.1\"));\n\n    QSharedPointer<AbstractionDefinition> abstractionDefinition(new AbstractionDefinition(*abstractionReference,\n        Document::Revision::Std14));\n\n    QSharedPointer<PortAbstraction> testLogicalAbstraction(new PortAbstraction());\n    testLogicalAbstraction->setLogicalName(\"testLogical\");\n\n    if (isWire)\n    {\n        QSharedPointer<WireAbstraction> logicalWireAbstraction(new WireAbstraction());\n        testLogicalAbstraction->setWire(logicalWireAbstraction);\n    }\n    else\n    {\n        QSharedPointer<TransactionalAbstraction> logicalTransactionalAbstraction(new TransactionalAbstraction());\n        testLogicalAbstraction->setTransactional(logicalTransactionalAbstraction);\n    }\n\n    abstractionDefinition->getLogicalPorts()->append(testLogicalAbstraction);\n\n    LibraryMock* mockLibrary (new LibraryMock(this));\n    mockLibrary->addComponent(abstractionDefinition);\n\n    QSharedPointer<Range> logicalRange (new Range(logicalRangeLeft, logicalRangeRight));\n\n    QSharedPointer<PortMap::LogicalPort> testLogical (new PortMap::LogicalPort());\n    testLogical->name_ = testLogicalAbstraction->name();\n    testLogical->range_ = logicalRange;\n\n    QSharedPointer<PartSelect> physicalPart (new PartSelect(physicalRangeLeft, physicalRangeRight));\n\n    QSharedPointer<PortMap::PhysicalPort> testPhysical (new PortMap::PhysicalPort());\n    testPhysical->name_ = \"testPhysicalPort\";\n    testPhysical->partSelect_ = physicalPart;\n\n    QSharedPointer<ExpressionParser> parser(new SystemVerilogExpressionParser());\n\n    QSharedPointer<QList<QSharedPointer<Port> > > componentPorts (new QList<QSharedPointer<Port> > ());\n    QSharedPointer<Port> newPort;\n    if (isWire)\n    {\n        newPort = createWirePort(testPhysical->name_);\n        newPort->setLeftBound(physicalRangeLeft);\n        newPort->setRightBound(physicalRangeRight);\n    }\n    else\n    {\n        newPort = createTransactionalPort(testPhysical->name_);\n        \n        // Set transactional port width to smallest needed for tests.\n        quint64 logicalWidth = qMax(parser->parseExpression(physicalRangeLeft).toULongLong(),\n            parser->parseExpression(physicalRangeRight).toULongLong()) + 1;\n        \n        newPort->getTransactional()->setBusWidth(QString::number(logicalWidth));\n    }\n\n    componentPorts->append(newPort);\n\n    QSharedPointer<PortMap> testPortMap (new PortMap());\n    testPortMap->setLogicalPort(testLogical);\n    testPortMap->setPhysicalPort(testPhysical);\n\n    QSharedPointer<PortMapValidator> validator = createPortMapValidator(parser, componentPorts, mockLibrary);\n    validator->busInterfaceChanged(abstractionReference, General::MASTER, QString(\"\"));\n\n    QCOMPARE(validator->connectedPortsHaveSameRange(logicalRange, physicalPart), isValid);\n\n    if (!isValid)\n    {\n        QString context = QLatin1String(\"test\");\n\n        QVector<QString> errorsFound;\n        validator->findErrorsIn(errorsFound, testPortMap, context);\n\n        QString expectedError = QObject::tr(\"Connected logical port %1 and physical port %2 do not have the same \"\n            \"range size within %3\")\n            .arg(testPortMap->getLogicalPort()->name_).arg(testPortMap->getPhysicalPort()->name_).arg(context);\n\n        if (errorIsNotFoundInErrorList(expectedError, errorsFound))\n        {\n            QFAIL(\"Error was not found\");\n        }\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_BusInterfacePortMapValidator::testPortMapConnectedPortsHaveSameRange()\n//-----------------------------------------------------------------------------\nvoid tst_BusInterfacePortMapValidator::testPortMapConnectedPortsHaveSameRange_data()\n{\n    QTest::addColumn<QString>(\"logicalRangeLeft\");\n    QTest::addColumn<QString>(\"logicalRangeRight\");\n    QTest::addColumn<QString>(\"physicalRangeLeft\");\n    QTest::addColumn<QString>(\"physicalRangeRight\");\n    QTest::addColumn<bool>(\"isWire\");\n    QTest::addColumn<bool>(\"isValid\");\n\n    QTest::newRow(\"Wire: Connected ports without range is valid\") <<\n        \"\" << \"\" << \"\" << \"\" << true << true;\n    QTest::newRow(\"Wire: Connected ports with the same range values is valid\") <<\n        \"0\" << \"10\" << \"0\" << \"10\" << true << true;\n    QTest::newRow(\"Wire: Connected ports with the same range size is valid\") <<\n        \"0\" << \"5+1\" << \"18-8\" << \"10+3*2\" << true << true;\n    QTest::newRow(\"Wire: Connected ports without same range size is not valid\") <<\n        \"\" << \"\" << \"4\" << \"3\" << true << false;\n\n    QTest::newRow(\"Transactional: Connected ports without range is valid\") <<\n        \"\" << \"\" << \"\" << \"\" << false << true;\n    QTest::newRow(\"Transactional: Connected ports with the same range values is valid\") <<\n        \"0\" << \"10\" << \"0\" << \"10\" << false << true;\n    QTest::newRow(\"Transactional: Connected ports with the same range size is valid\") <<\n        \"0\" << \"5+1\" << \"18-8\" << \"10+3*2\" << false << true;\n    QTest::newRow(\"Transactional: Connected ports without same range size is not valid\") <<\n        \"\" << \"\" << \"4\" << \"3\" << false << false;\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_BusInterfacePortMapValidator::createPortMapValidator()\n//-----------------------------------------------------------------------------\nQSharedPointer<PortMapValidator> tst_BusInterfacePortMapValidator::createPortMapValidator(\n    QSharedPointer<ExpressionParser> expressionParser, QSharedPointer<QList<QSharedPointer<Port> > > ports,\n    LibraryInterface* libraryHandler)\n{\n    QSharedPointer<PortMapValidator> newPortMapValidator(new PortMapValidator(\n        expressionParser, ports, libraryHandler));\n\n    return newPortMapValidator;\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_BusInterfacePortMapValidator::errorIsNotFoundInErrorList()\n//-----------------------------------------------------------------------------\nbool tst_BusInterfacePortMapValidator::errorIsNotFoundInErrorList(QString const& expectedError,\n    QVector<QString> errorList)\n{\n    if (!errorList.contains(expectedError))\n    {\n        qDebug() << \"The following error:\" << Qt::endl << expectedError << Qt::endl << \"was not found in error list:\";\n        for (QString const& error : errorList)\n        {\n            qDebug() << error;\n        }\n        return true;\n    }\n\n    return false;\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_BusInterfacePortMapValidator::createWirePort()\n//-----------------------------------------------------------------------------\nQSharedPointer<Port> tst_BusInterfacePortMapValidator::createWirePort(QString const& portName)\n{\n    QSharedPointer<Port> newPort(new Port(portName));\n\n    QSharedPointer<Wire> newWire(new Wire());\n    newPort->setWire(newWire);\n\n    return newPort;\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_BusInterfacePortMapValidator::createTransactionalPort()\n//-----------------------------------------------------------------------------\nQSharedPointer<Port> tst_BusInterfacePortMapValidator::createTransactionalPort(QString const& portName)\n{\n    QSharedPointer<Port> newPort(new Port(portName));\n\n    QSharedPointer<Transactional> newTransactional(new Transactional());\n    newPort->setTransactional(newTransactional);\n\n    return newPort;\n}\n\nQTEST_APPLESS_MAIN(tst_BusInterfacePortMapValidator)\n\n#include \"tst_BusInterfacePortMapValidator.moc\"\n"
  },
  {
    "path": "tests/IPXACTmodels/Component/tst_BusInterfacePortMapValidator.pri",
    "content": "# ----------------------------------------------------\n# This file is generated by the Qt Visual Studio Tools.\n# ------------------------------------------------------\n\n\nHEADERS += ../../MockObjects/LibraryMock.h \n   \nSOURCES += ../../MockObjects/LibraryMock.cpp \\\n    ./tst_BusInterfacePortMapValidator.cpp\n"
  },
  {
    "path": "tests/IPXACTmodels/Component/tst_BusInterfacePortMapValidator.pro",
    "content": "#-----------------------------------------------------------------------------\n# File: tst_BusInterfacePortMapValidator.pro\n#-----------------------------------------------------------------------------\n# Project: Kactus2\n# Author: Esko Pekkarinen\n# Date: 28.03.2018\n#\n# Description:\n# Qt project file template for running unit tests for a single module.\n#-----------------------------------------------------------------------------\n\nTEMPLATE = app\n\nTARGET = tst_BusInterfacePortMapValidator\n\nQT += core xml gui testlib\nCONFIG += c++11 testcase console\n\nlinux-g++ | linux-g++-64 | linux-g++-32 {\n LIBS += -L../../../executable \\\n     -lIPXACTmodels -lKactusAPI\n\n}\nwin64 | win32 {\n LIBS += -L../../../executable \\\n     -lIPXACTmodelsd -lKactusAPId\n}\n\nDESTDIR = ./release\n\nINCLUDEPATH += $$DESTDIR\nINCLUDEPATH += ../../../\n\nDEPENDPATH += .\nDEPENDPATH += ../../../\n\n\nMOC_DIR += ./generatedFiles\nUI_DIR += ./generatedFiles\nRCC_DIR += ./generatedFiles\ninclude(tst_BusInterfacePortMapValidator.pri)\n"
  },
  {
    "path": "tests/IPXACTmodels/Component/tst_BusInterfaceReader.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: tst_businterfaceReader.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Janne Virtanen\r\n// Date: 22.09.2015\r\n//\r\n// Description:\r\n// Unit test for class businterfaceReader.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include <IPXACTmodels/Component/BusInterfaceReader.h>\r\n\r\n#include <IPXACTmodels/Component/BusInterface.h>\r\n#include <IPXACTmodels/Component/InitiatorInterface.h>\r\n#include <IPXACTmodels/Component/MirroredTargetInterface.h>\r\n#include <IPXACTmodels/Component/TargetInterface.h>\r\n\r\n#include <IPXACTmodels/common/VendorExtension.h>\r\n\r\n#include <QtTest>\r\n\r\nclass tst_businterfaceReader : public QObject\r\n{\r\n    Q_OBJECT\r\n\r\npublic:\r\n    tst_businterfaceReader();\r\n\r\nprivate slots:\r\n\r\n    void testReadSimplebusinterface();\r\n\tvoid testReadIsPresent();\r\n\tvoid testReadBusType();\r\n\r\n\tvoid testReadSlave();\r\n\tvoid testReadMaster();\r\n\tvoid testReadSystem();\r\n\tvoid testReadMirroredSlave();\r\n\tvoid testReadMirroredMaster();\r\n\tvoid testReadMirroredSystem();\r\n\tvoid testReadMonitor();\r\n\r\n\tvoid testReadInitiator2022();\r\n\tvoid testReadTarget2022();\r\n\tvoid testReadMirroredTarget2022();\r\n\tvoid testReadMirroredInitiator2022();\r\n\r\n\tvoid testReadAttributes();\r\n\tvoid testReadConnectionRequired();\r\n\tvoid testReadBitsInLau();\r\n\tvoid testReadBitSteering();\r\n\tvoid testReadBitSteeringExpression2022();\r\n\r\n\tvoid testReadEndianness();\r\n\tvoid testReadParameters();\r\n\tvoid testReadVendorExtensions();\r\n\tvoid testReadAbstractionReference();\r\n    void testReadPortMaps();\r\n    void testReadPortMaps2022();\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_businterfaceReader::tst_businterfaceReader()\r\n//-----------------------------------------------------------------------------\r\ntst_businterfaceReader::tst_businterfaceReader()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_businterfaceReader::testReadSimplebusinterface()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_businterfaceReader::testReadSimplebusinterface()\r\n{\r\n    QString documentContent(\r\n        \"<ipxact:busInterface>\"\r\n            \"<ipxact:name>businterface</ipxact:name>\"\r\n            \"<ipxact:displayName>viewDisplay</ipxact:displayName>\"\r\n            \"<ipxact:description>viewDescription</ipxact:description>\"\r\n        \"</ipxact:busInterface>\"\r\n        );\r\n\r\n\r\n    QDomDocument document;\r\n    document.setContent(documentContent);\r\n\r\n    QDomNode businterfaceNode = document.firstChildElement(\"ipxact:busInterface\");\r\n\r\n    QSharedPointer<BusInterface> testbusinterface = BusinterfaceReader::createBusinterfaceFrom(businterfaceNode,\r\n        Document::Revision::Std14);\r\n\r\n    QCOMPARE(testbusinterface->name(), QString(\"businterface\"));\r\n    QCOMPARE(testbusinterface->displayName(), QString(\"viewDisplay\"));\r\n    QCOMPARE(testbusinterface->description(), QString(\"viewDescription\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_businterfaceReader::testReadIsPresent()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_businterfaceReader::testReadIsPresent()\r\n{\r\n    QString documentContent(\r\n        \"<ipxact:busInterface>\"\r\n            \"<ipxact:name>testbusinterface</ipxact:name>\"\r\n            \"<ipxact:isPresent>4-3</ipxact:isPresent>\"\r\n        \"</ipxact:busInterface>\"\r\n        );\r\n\r\n\r\n    QDomDocument document;\r\n    document.setContent(documentContent);\r\n\r\n    QDomNode businterfaceNode = document.firstChildElement(\"ipxact:busInterface\");\r\n\r\n    QSharedPointer<BusInterface> testbusinterface = BusinterfaceReader::createBusinterfaceFrom(businterfaceNode,\r\n        Document::Revision::Std14);\r\n\r\n    QCOMPARE(testbusinterface->name(), QString(\"testbusinterface\"));\r\n    QCOMPARE(testbusinterface->getIsPresent(), QString(\"4-3\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_businterfaceReader::testReadBusType()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_businterfaceReader::testReadBusType()\r\n{\r\n\tQString documentContent(\r\n\t\t\"<ipxact:busInterface>\"\r\n\t\t\"<ipxact:busType vendor=\\\"testVendor\\\" library=\\\"testLibrary\\\" name=\\\"clock\\\" version=\\\"1.0\\\"/>\"\r\n\t\t\"</ipxact:busInterface>\"\r\n\t\t);\r\n\r\n\tQDomDocument document;\r\n\tdocument.setContent(documentContent);\r\n\r\n\tQDomNode businterfaceNode = document.firstChildElement(\"ipxact:busInterface\");\r\n\r\n    QSharedPointer<BusInterface> testbusinterface = BusinterfaceReader::createBusinterfaceFrom(businterfaceNode,\r\n        Document::Revision::Std14);\r\n\tVLNV refVLNV = VLNV(VLNV::BUSDEFINITION, \"testVendor\", \"testLibrary\", \"clock\", \"1.0\");\r\n\r\n    ConfigurableVLNVReference configurableVLNV (refVLNV);\r\n\r\n\tQCOMPARE(testbusinterface->getBusType(), configurableVLNV);\r\n\tQCOMPARE(testbusinterface->getBusType().getType(), VLNV::BUSDEFINITION);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_businterfaceReader::testReadSlave()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_businterfaceReader::testReadSlave()\r\n{\r\n\tQString documentContent(\r\n\t\t\"<ipxact:busInterface>\"\r\n\t\t    \"<ipxact:slave>\"\r\n\t\t        \"<ipxact:memoryMapRef memoryMapRef=\\\"ambaAHB\\\"/>\"\r\n\t\t        \"<ipxact:transparentBridge masterRef=\\\"masterBus\\\">\"\r\n\t\t            \"<ipxact:isPresent>1</ipxact:isPresent>\"\r\n\t\t        \"</ipxact:transparentBridge>\"\r\n\t\t        \"<ipxact:fileSetRefGroup>\"\r\n\t\t            \"<ipxact:group>testGroup</ipxact:group>\"\r\n\t\t            \"<ipxact:fileSetRef>\"\r\n\t\t\t\t\t\t\"<ipxact:localName>fileset1</ipxact:localName>\"\r\n\t\t\t\t\t\"</ipxact:fileSetRef>\"\r\n\t\t            \"<ipxact:fileSetRef>\"\r\n\t\t\t\t\t\t\"<ipxact:localName>fileset2</ipxact:localName>\"\r\n\t\t\t\t\t\"</ipxact:fileSetRef>\"\r\n\t\t        \"</ipxact:fileSetRefGroup>\"\r\n\t\t    \"</ipxact:slave>\"\r\n\t\t\"</ipxact:busInterface>\"\r\n\t\t);\r\n\r\n\tQDomDocument document;\r\n\tdocument.setContent(documentContent);\r\n\r\n\tQDomNode businterfaceNode = document.firstChildElement(\"ipxact:busInterface\");\r\n\r\n    QSharedPointer<BusInterface> testbusinterface = BusinterfaceReader::createBusinterfaceFrom(businterfaceNode,\r\n        Document::Revision::Std14);\r\n\r\n\tQCOMPARE(testbusinterface->getSlave()->getMemoryMapRef(), QString(\"ambaAHB\"));\r\n\tQSharedPointer<TransparentBridge> bridge = testbusinterface->getSlave()->getBridges()->first();\r\n\tQCOMPARE(bridge->getMasterRef(), QString(\"masterBus\"));\r\n\tQCOMPARE(bridge->getIsPresent(), QString(\"1\"));\r\n\r\n\tQSharedPointer<TargetInterface::FileSetRefGroup> refg = testbusinterface->getSlave()->getFileSetRefGroup()->first();\r\n\tQCOMPARE(refg->group_, QString(\"testGroup\"));\r\n\tQCOMPARE(refg->fileSetRefs_->size(), 2);\r\n\tQCOMPARE(refg->fileSetRefs_->first()->getReference(), QString(\"fileset1\"));\r\n\tQCOMPARE(refg->fileSetRefs_->last()->getReference(), QString(\"fileset2\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_businterfaceReader::testReadMaster()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_businterfaceReader::testReadMaster()\r\n{\r\n\tQString documentContent(\r\n\t\t\"<ipxact:busInterface>\"\r\n\t\t    \"<ipxact:master>\"\r\n\t\t        \"<ipxact:addressSpaceRef addressSpaceRef=\\\"apb\\\">\"\r\n\t\t\t\t\t\"<ipxact:isPresent>1</ipxact:isPresent>\"\r\n\t\t\t\t\t\"<ipxact:baseAddress>16</ipxact:baseAddress>\" \r\n\t\t\t\t\"</ipxact:addressSpaceRef >\"\r\n\t\t    \"</ipxact:master>\"\r\n\t\t\"</ipxact:busInterface>\"\r\n\t\t);\r\n\r\n\r\n\tQDomDocument document;\r\n\tdocument.setContent(documentContent);\r\n\r\n\tQDomNode businterfaceNode = document.firstChildElement(\"ipxact:busInterface\");\r\n\r\n    QSharedPointer<BusInterface> testbusinterface = BusinterfaceReader::createBusinterfaceFrom(businterfaceNode,\r\n        Document::Revision::Std14);\r\n\r\n    QCOMPARE(testbusinterface->getMaster()->getAddressSpaceRef(), QString(\"apb\"));\r\n    QCOMPARE(testbusinterface->getMaster()->getIsPresent(), QString(\"1\"));\r\n    QCOMPARE(testbusinterface->getMaster()->getBaseAddress(), QString(\"16\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_businterfaceReader::testReadSystem()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_businterfaceReader::testReadSystem()\r\n{\r\n\tQString documentContent(\r\n\t\t\"<ipxact:busInterface>\"\r\n\t\t    \"<ipxact:system>\"\r\n\t\t    \"<ipxact:group>testSystemGroup</ipxact:group>\"\r\n\t\t    \"</ipxact:system>\"\r\n\t\t\"</ipxact:busInterface>\"\r\n\t\t);\r\n\r\n\r\n\tQDomDocument document;\r\n\tdocument.setContent(documentContent);\r\n\r\n\tQDomNode businterfaceNode = document.firstChildElement(\"ipxact:busInterface\");\r\n\r\n    QSharedPointer<BusInterface> testbusinterface = BusinterfaceReader::createBusinterfaceFrom(businterfaceNode,\r\n        Document::Revision::Std14);\r\n\r\n\tQCOMPARE(testbusinterface->getSystem(), QString(\"testSystemGroup\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_businterfaceReader::testReadMirroredSlave()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_businterfaceReader::testReadMirroredSlave()\r\n{\r\n\tQString documentContent(\r\n\t\t\"<ipxact:busInterface>\"\r\n\t\t    \"<ipxact:mirroredSlave>\"\r\n\t\t        \"<ipxact:baseAddresses>\"\r\n\t\t            \"<ipxact:remapAddress state=\\\"decayed\\\">'h0000</ipxact:remapAddress>\"\r\n\t\t            \"<ipxact:remapAddress state=\\\"uptodate\\\" testAttribute=\\\"value\\\">'hFFFF</ipxact:remapAddress>\"\r\n\t                \"<ipxact:range>'h00010000</ipxact:range>\"\r\n\t            \"</ipxact:baseAddresses>\"\r\n\t        \"</ipxact:mirroredSlave>\"\r\n\t\t\"</ipxact:busInterface>\"\r\n\t\t);\r\n\r\n\r\n\tQDomDocument document;\r\n\tdocument.setContent(documentContent);\r\n\r\n\tQDomNode businterfaceNode = document.firstChildElement(\"ipxact:busInterface\");\r\n\r\n    QSharedPointer<BusInterface> testbusinterface = BusinterfaceReader::createBusinterfaceFrom(businterfaceNode,\r\n        Document::Revision::Std14);\r\n    QSharedPointer<MirroredTargetInterface::RemapAddress> firstRemapAddress =\r\n        testbusinterface->getMirroredSlave()->getRemapAddresses()->first();\r\n\r\n\tQCOMPARE(firstRemapAddress->remapAddress_, QString(\"'h0000\"));\r\n\tQCOMPARE(firstRemapAddress->state_, QString(\"decayed\"));\r\n\r\n    QSharedPointer<MirroredTargetInterface::RemapAddress> secondRemapAddress =\r\n        testbusinterface->getMirroredSlave()->getRemapAddresses()->last();\r\n\r\n\tQCOMPARE(secondRemapAddress->remapAddress_, QString(\"'hFFFF\"));\r\n\tQCOMPARE(secondRemapAddress->state_, QString(\"uptodate\"));\r\n    QCOMPARE(secondRemapAddress->remapAttributes_.firstKey(), QString(\"testAttribute\"));\r\n    QCOMPARE(secondRemapAddress->remapAttributes_.first(), QString(\"value\"));\r\n\r\n\tQCOMPARE(testbusinterface->getMirroredSlave()->getRange(), QString(\"'h00010000\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_businterfaceReader::testReadMirroredMaster()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_businterfaceReader::testReadMirroredMaster()\r\n{\r\n    QString documentContent(\r\n        \"<ipxact:busInterface>\"\r\n            \"<ipxact:mirroredMaster/>\"\r\n        \"</ipxact:busInterface>\"\r\n        );\r\n\r\n\r\n\tQDomDocument document;\r\n\tdocument.setContent(documentContent);\r\n\r\n\tQDomNode businterfaceNode = document.firstChildElement(\"ipxact:busInterface\");\r\n\r\n    QSharedPointer<BusInterface> testbusinterface = BusinterfaceReader::createBusinterfaceFrom(businterfaceNode,\r\n        Document::Revision::Std14);\r\n\r\n    QCOMPARE(testbusinterface->getInterfaceMode(), General::MIRRORED_MASTER);\r\n    QCOMPARE(testbusinterface->getMaster(), nullptr);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_businterfaceReader::testReadMirroredSystem()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_businterfaceReader::testReadMirroredSystem()\r\n{\r\n\tQString documentContent(\r\n\t\t\"<ipxact:busInterface>\"\r\n\t\t    \"<ipxact:mirroredSystem>\"\r\n\t\t        \"<ipxact:group>testSystemGroup</ipxact:group>\"\r\n\t\t    \"</ipxact:mirroredSystem>\"\r\n\t\t\"</ipxact:busInterface>\"\r\n\t\t);\r\n\r\n\r\n\tQDomDocument document;\r\n\tdocument.setContent(documentContent);\r\n\r\n\tQDomNode businterfaceNode = document.firstChildElement(\"ipxact:busInterface\");\r\n\r\n    QSharedPointer<BusInterface> testbusinterface = BusinterfaceReader::createBusinterfaceFrom(businterfaceNode,\r\n        Document::Revision::Std14);\r\n\r\n\tQCOMPARE(testbusinterface->getSystem(), QString(\"testSystemGroup\"));\r\n    QCOMPARE(testbusinterface->getInterfaceMode(), General::MIRRORED_SYSTEM);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_businterfaceReader::testReadMonitor()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_businterfaceReader::testReadMonitor()\r\n{\r\n\tQString documentContent(\r\n\t\t\"<ipxact:busInterface>\"\r\n\t\t    \"<ipxact:monitor interfaceMode=\\\"system\\\">\"\r\n\t\t        \"<ipxact:group>testGroup</ipxact:group>\"\r\n\t\t    \"</ipxact:monitor>\"\r\n\t\t\"</ipxact:busInterface>\"\r\n\t\t);\r\n\r\n\r\n\tQDomDocument document;\r\n\tdocument.setContent(documentContent);\r\n\r\n\tQDomNode businterfaceNode = document.firstChildElement(\"ipxact:busInterface\");\r\n\r\n    QSharedPointer<BusInterface> testbusinterface = BusinterfaceReader::createBusinterfaceFrom(businterfaceNode,\r\n        Document::Revision::Std14);\r\n\r\n\tQCOMPARE(testbusinterface->getMonitor()->group_, QString(\"testGroup\"));\r\n\tQCOMPARE(testbusinterface->getMonitor()->interfaceMode_, General::SYSTEM);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_businterfaceReader::testReadInitiator2022()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_businterfaceReader::testReadInitiator2022()\r\n{\r\n\tQString documentContent(\r\n\t\t\"<ipxact:busInterface>\"\r\n\t\t    \"<ipxact:initiator>\"\r\n\t\t        \"<ipxact:addressSpaceRef addressSpaceRef=\\\"apb\\\">\"\r\n\t\t\t\t\t\"<ipxact:vendorExtensions>\"\r\n        \t\t\t\t\"<testExtension testAttribute=\\\"attributeValue\\\"/>\"\r\n\t\t\t\t\t\"</ipxact:vendorExtensions>\"\r\n\t\t\t\t\t\"<ipxact:baseAddress>8</ipxact:baseAddress>\"\r\n\t\t\t\t\t\"<ipxact:modeRef>firstMode</ipxact:modeRef>\"\r\n\t\t\t\t\t\"<ipxact:modeRef>secondMode</ipxact:modeRef>\"\r\n\t\t\t\t\"</ipxact:addressSpaceRef>\"\r\n\t\t    \"</ipxact:initiator>\"\r\n\t\t\"</ipxact:busInterface>\"\r\n\t\t);\r\n\r\n\tQDomDocument document;\r\n\tdocument.setContent(documentContent);\r\n\r\n\tQDomNode businterfaceNode = document.firstChildElement(\"ipxact:busInterface\");\r\n\r\n    QSharedPointer<BusInterface> testbusinterface = BusinterfaceReader::createBusinterfaceFrom(businterfaceNode,\r\n        Document::Revision::Std22);\r\n\r\n    QCOMPARE(testbusinterface->getInitiator()->getAddressSpaceRef(), QString(\"apb\"));\r\n    QCOMPARE(testbusinterface->getInitiator()->getVendorExtensions()->count(), 1);\r\n    QCOMPARE(testbusinterface->getInitiator()->getBaseAddress(), QString(\"8\"));\r\n    QCOMPARE(testbusinterface->getInitiator()->getModeRefs().count(), 2);\r\n    QCOMPARE(testbusinterface->getInitiator()->getModeRefs().first(), QString(\"firstMode\"));\r\n    QCOMPARE(testbusinterface->getInitiator()->getModeRefs().last(), QString(\"secondMode\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_businterfaceReader::testReadTarget2022()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_businterfaceReader::testReadTarget2022()\r\n{\r\n\tQString documentContent(\r\n\t\t\"<ipxact:busInterface>\"\r\n\t\t    \"<ipxact:target>\"\r\n\t\t        \"<ipxact:memoryMapRef memoryMapRef=\\\"ambaAHB\\\">\"\r\n\t\t\t\t\t\"<ipxact:modeRef>firstMode</ipxact:modeRef>\"\r\n\t\t\t\t\t\"<ipxact:modeRef>secondMode</ipxact:modeRef>\"\r\n\t\t\t\t\"</ipxact:memoryMapRef>\"\r\n\t\t        \"<ipxact:transparentBridge initiatorRef=\\\"initiatorBus\\\">\"\r\n\t\t\t\t\t\"<ipxact:vendorExtensions>\"\r\n        \t\t\t\t\"<testExtension testAttribute=\\\"attributeValue\\\"/>\"\r\n\t\t\t\t\t\"</ipxact:vendorExtensions>\"\r\n\t\t        \"</ipxact:transparentBridge>\"\r\n\t\t        \"<ipxact:fileSetRefGroup>\"\r\n\t\t            \"<ipxact:group>testGroup</ipxact:group>\"\r\n\t\t\t\t\t\"<ipxact:fileSetRef>\"\r\n\t\t\t\t\t\t\"<ipxact:localName>fileset1</ipxact:localName>\"\r\n\t\t\t\t\t\"</ipxact:fileSetRef>\"\r\n\t\t            \"<ipxact:fileSetRef>\"\r\n\t\t\t\t\t\t\"<ipxact:localName>fileset2</ipxact:localName>\"\r\n\t\t\t\t\t\"</ipxact:fileSetRef>\"\r\n\t\t        \"</ipxact:fileSetRefGroup>\"\r\n\t\t    \"</ipxact:target>\"\r\n\t\t\"</ipxact:busInterface>\"\r\n\t\t);\r\n\r\n\tQDomDocument document;\r\n\tdocument.setContent(documentContent);\r\n\r\n\tQDomNode businterfaceNode = document.firstChildElement(\"ipxact:busInterface\");\r\n\r\n    QSharedPointer<BusInterface> testbusinterface = BusinterfaceReader::createBusinterfaceFrom(businterfaceNode,\r\n        Document::Revision::Std22);\r\n\r\n    QCOMPARE(testbusinterface->getTarget()->getMemoryMapRef(), QString(\"ambaAHB\"));\r\n    QCOMPARE(testbusinterface->getTarget()->getModeRefs().count(), 2);\r\n    QCOMPARE(testbusinterface->getTarget()->getModeRefs().first(), QString(\"firstMode\"));\r\n    QCOMPARE(testbusinterface->getTarget()->getModeRefs().last(), QString(\"secondMode\"));\r\n\r\n    QSharedPointer<TransparentBridge> bridge = testbusinterface->getTarget()->getBridges()->first();\r\n    QCOMPARE(bridge->getInitiatorRef(), QString(\"initiatorBus\"));\r\n    QCOMPARE(bridge->getVendorExtensions()->count(), 1);\r\n\r\n    QSharedPointer<TargetInterface::FileSetRefGroup> refg = testbusinterface->getTarget()->getFileSetRefGroup()->first();\r\n    QCOMPARE(refg->group_, QString(\"testGroup\"));\r\n    QCOMPARE(refg->fileSetRefs_->size(), 2);\r\n    QCOMPARE(refg->fileSetRefs_->first()->getReference(), QString(\"fileset1\"));\r\n    QCOMPARE(refg->fileSetRefs_->last()->getReference(), QString(\"fileset2\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_businterfaceReader::testReadMirroredTarget2022()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_businterfaceReader::testReadMirroredTarget2022()\r\n{\r\n\tQString documentContent(\r\n\t\t\"<ipxact:busInterface>\"\r\n\t\t    \"<ipxact:mirroredTarget>\"\r\n\t\t        \"<ipxact:baseAddresses>\"\r\n\t\t            \"<ipxact:remapAddresses>\"\r\n\t\t\t\t\t\t\"<ipxact:remapAddress>'h0000</ipxact:remapAddress>\"\r\n\t\t\t\t\t\t\"<ipxact:modeRef>firstMode</ipxact:modeRef>\"\r\n\t\t\t\t\t\t\"<ipxact:modeRef priority=\\\"2\\\">secondMode</ipxact:modeRef>\"\r\n\t\t\t\t\t\"</ipxact:remapAddresses>\"\r\n\t\t            \"<ipxact:remapAddresses>\"\r\n\t\t\t\t\t\t\"<ipxact:remapAddress>'hFFFF</ipxact:remapAddress>\"\r\n\t\t\t\t\t\t\"<ipxact:modeRef>firstMode</ipxact:modeRef>\"\r\n\t\t\t\t\t\"</ipxact:remapAddresses>\"\r\n\t                \"<ipxact:range>'h00010000</ipxact:range>\"\r\n\t            \"</ipxact:baseAddresses>\"\r\n\t        \"</ipxact:mirroredTarget>\"\r\n\t\t\"</ipxact:busInterface>\"\r\n\t\t);\r\n\r\n\r\n\tQDomDocument document;\r\n\tdocument.setContent(documentContent);\r\n\r\n\tQDomNode businterfaceNode = document.firstChildElement(\"ipxact:busInterface\");\r\n\r\n    QSharedPointer<BusInterface> testbusinterface = BusinterfaceReader::createBusinterfaceFrom(businterfaceNode,\r\n        Document::Revision::Std22);\r\n    QSharedPointer<MirroredTargetInterface::RemapAddress> firstRemapAddress =\r\n        testbusinterface->getMirroredSlave()->getRemapAddresses()->first();\r\n\r\n    QCOMPARE(firstRemapAddress->remapAddress_, QString(\"'h0000\"));\r\n    QCOMPARE(firstRemapAddress->modeRefs_, QStringList({ \"firstMode\", \"secondMode\" }));\r\n    QCOMPARE(firstRemapAddress->priorities_.value(\"secondMode\"), 2);\r\n\r\n    QSharedPointer<MirroredTargetInterface::RemapAddress> secondRemapAddress =\r\n        testbusinterface->getMirroredSlave()->getRemapAddresses()->last();\r\n\r\n\tQCOMPARE(secondRemapAddress->remapAddress_, QString(\"'hFFFF\"));\r\n    QCOMPARE(secondRemapAddress->modeRefs_, QStringList({ \"firstMode\" }));\r\n\r\n\tQCOMPARE(testbusinterface->getMirroredSlave()->getRange(), QString(\"'h00010000\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_businterfaceReader::testReadMirroredInitiator2022()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_businterfaceReader::testReadMirroredInitiator2022()\r\n{\r\n    QString documentContent(\r\n        \"<ipxact:busInterface>\"\r\n\t\t\t\"<ipxact:mirroredInitiator/>\"\r\n        \"</ipxact:busInterface>\"\r\n    );\r\n\r\n    QDomDocument document;\r\n    document.setContent(documentContent);\r\n\r\n    QDomNode businterfaceNode = document.firstChildElement(\"ipxact:busInterface\");\r\n\r\n    QSharedPointer<BusInterface> testbusinterface = BusinterfaceReader::createBusinterfaceFrom(businterfaceNode,\r\n        Document::Revision::Std22);\r\n\r\n    QCOMPARE(testbusinterface->getInterfaceMode(), General::MIRRORED_INITIATOR);\r\n    QCOMPARE(testbusinterface->getInitiator(), nullptr);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_businterfaceReader::testReadAttributes()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_businterfaceReader::testReadAttributes()\r\n{\r\n\tQString documentContent(\r\n\t\t\"<ipxact:busInterface attribute=\\\"value\\\">\"\r\n\t\t\"</ipxact:busInterface>\"\r\n\t\t);\r\n\r\n\tQDomDocument document;\r\n\tdocument.setContent(documentContent);\r\n\r\n\tQDomNode businterfaceNode = document.firstChildElement(\"ipxact:busInterface\");\r\n\r\n    QSharedPointer<BusInterface> testbusinterface = BusinterfaceReader::createBusinterfaceFrom(businterfaceNode,\r\n        Document::Revision::Std14);\r\n\r\n\tQCOMPARE(testbusinterface->getAttributes().firstKey(), QString(\"attribute\"));\r\n\tQCOMPARE(testbusinterface->getAttributes().first(), QString(\"value\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_businterfaceReader::testReadConnectionRequired()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_businterfaceReader::testReadConnectionRequired()\r\n{\r\n\tQString documentContent(\r\n\t\t\"<ipxact:busInterface>\"\r\n\t\t    \"<ipxact:connectionRequired>true</ipxact:connectionRequired>\"\r\n\t\t\"</ipxact:busInterface>\"\r\n\t\t);\r\n\r\n\tQDomDocument document;\r\n\tdocument.setContent(documentContent);\r\n\r\n\tQDomNode businterfaceNode = document.firstChildElement(\"ipxact:busInterface\");\r\n\r\n    QSharedPointer<BusInterface> testbusinterface = BusinterfaceReader::createBusinterfaceFrom(businterfaceNode,\r\n        Document::Revision::Std14);\r\n\r\n    QCOMPARE(testbusinterface->getConnectionRequired(), QString(\"true\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_businterfaceReader::testReadBitsInLau()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_businterfaceReader::testReadBitsInLau()\r\n{\r\n\tQString documentContent(\r\n\t\t\"<ipxact:busInterface>\"\r\n\t\t    \"<ipxact:bitsInLau>1234</ipxact:bitsInLau>\"\r\n\t\t\"</ipxact:busInterface>\"\r\n\t\t);\r\n\r\n\tQDomDocument document;\r\n\tdocument.setContent(documentContent);\r\n\r\n\tQDomNode businterfaceNode = document.firstChildElement(\"ipxact:busInterface\");\r\n\r\n    QSharedPointer<BusInterface> testbusinterface = BusinterfaceReader::createBusinterfaceFrom(businterfaceNode,\r\n        Document::Revision::Std14);\r\n\r\n    QCOMPARE(testbusinterface->getBitsInLau(), QString(\"1234\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_businterfaceReader::testReadBitSteering()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_businterfaceReader::testReadBitSteering()\r\n{\r\n\tQString documentContent(\r\n\t\t\"<ipxact:busInterface>\"\r\n\t\t    \"<ipxact:bitSteering testAttribute=\\\"value\\\">on</ipxact:bitSteering>\"\r\n\t\t\"</ipxact:busInterface>\"\r\n\t\t);\r\n\r\n\tQDomDocument document;\r\n\tdocument.setContent(documentContent);\r\n\r\n\tQDomNode businterfaceNode = document.firstChildElement(\"ipxact:busInterface\");\r\n\r\n\tQSharedPointer<BusInterface> testbusinterface = BusinterfaceReader::createBusinterfaceFrom(businterfaceNode,\r\n\t\tDocument::Revision::Std14);\r\n\r\n\tQCOMPARE(testbusinterface->getBitSteering(), QString(\"on\"));\r\n\tQCOMPARE(testbusinterface->getBitSteeringAttributes().firstKey(), QString(\"testAttribute\"));\r\n\tQCOMPARE(testbusinterface->getBitSteeringAttributes().first(), QString(\"value\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_businterfaceReader::testReadBitSteeringExpression2022()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_businterfaceReader::testReadBitSteeringExpression2022()\r\n{\r\n    QString documentContent(\r\n        \"<ipxact:busInterface>\"\r\n\t\t\t\"<ipxact:bitSteering testAttribute=\\\"value\\\">1</ipxact:bitSteering>\"\r\n        \"</ipxact:busInterface>\"\r\n    );\r\n\r\n    QDomDocument document;\r\n    document.setContent(documentContent);\r\n\r\n    QDomNode businterfaceNode = document.firstChildElement(\"ipxact:busInterface\");\r\n\r\n    QSharedPointer<BusInterface> testbusinterface = BusinterfaceReader::createBusinterfaceFrom(businterfaceNode,\r\n\t\tDocument::Revision::Std22);\r\n\r\n    QCOMPARE(testbusinterface->getBitSteering(), QString(\"1\"));\r\n    QCOMPARE(testbusinterface->getBitSteeringAttributes().firstKey(), QString(\"testAttribute\"));\r\n    QCOMPARE(testbusinterface->getBitSteeringAttributes().first(), QString(\"value\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_businterfaceReader::testReadEndianness()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_businterfaceReader::testReadEndianness()\r\n{\r\n\tQString documentContent(\r\n\t\t\"<ipxact:busInterface>\"\r\n\t\t    \"<ipxact:endianness>big</ipxact:endianness>\"\r\n\t\t\"</ipxact:busInterface>\"\r\n\t\t);\r\n\r\n\tQDomDocument document;\r\n\tdocument.setContent(documentContent);\r\n\r\n\tQDomNode businterfaceNode = document.firstChildElement(\"ipxact:busInterface\");\r\n\r\n    QSharedPointer<BusInterface> testbusinterface = BusinterfaceReader::createBusinterfaceFrom(businterfaceNode,\r\n        Document::Revision::Std14);\r\n\r\n\tQCOMPARE(testbusinterface->getEndianness(), BusInterface::BIG);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_businterfaceReader::testReadParameters()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_businterfaceReader::testReadParameters()\r\n{\r\n\tQString documentContent(\r\n\t\t\"<ipxact:busInterface>\"\r\n\t\t    \"<ipxact:parameters>\"\r\n\t\t        \"<ipxact:parameter parameterId=\\\"id1\\\">\"\r\n\t\t            \"<ipxact:name>testParameter</ipxact:name>\"\r\n\t\t            \"<ipxact:description>First generator parameter.</ipxact:description>\"\r\n\t\t            \"<ipxact:value>5</ipxact:value>\"\r\n\t\t        \"</ipxact:parameter>\"\r\n\t\t        \"<ipxact:parameter parameterId=\\\"id2\\\">\"\r\n\t\t            \"<ipxact:name>secondParameter</ipxact:name>\"\r\n                    \"<ipxact:value>1</ipxact:value>\"\r\n\t\t        \"</ipxact:parameter>\"\r\n\t\t    \"</ipxact:parameters>\"\r\n\t\t\"</ipxact:busInterface>\"\r\n\t\t);\r\n\r\n\tQDomDocument document;\r\n\tdocument.setContent(documentContent);\r\n\r\n\tQDomNode businterfaceNode = document.firstChildElement(\"ipxact:busInterface\");\r\n\r\n    QSharedPointer<BusInterface> testbusinterface = BusinterfaceReader::createBusinterfaceFrom(businterfaceNode,\r\n        Document::Revision::Std14);\r\n\r\n\tQCOMPARE(testbusinterface->getParameters()->size(), 2);\r\n\tQCOMPARE(testbusinterface->getParameters()->first()->name(), QString(\"testParameter\"));\r\n\tQCOMPARE(testbusinterface->getParameters()->first()->getValueId(), QString(\"id1\"));\r\n\tQCOMPARE(testbusinterface->getParameters()->first()->getValue(), QString(\"5\"));\r\n\r\n\tQCOMPARE(testbusinterface->getParameters()->last()->name(), QString(\"secondParameter\"));\r\n\tQCOMPARE(testbusinterface->getParameters()->last()->getValueId(), QString(\"id2\"));\r\n\tQCOMPARE(testbusinterface->getParameters()->last()->getValue(), QString(\"1\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_businterfaceReader::testReadVendorExtensions()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_businterfaceReader::testReadVendorExtensions()\r\n{\r\n\tQString documentContent(\r\n\t\t\"<ipxact:busInterface>\"\r\n\t\t    \"<ipxact:vendorExtensions>\"\r\n        \t\t\"<testExtension testAttribute=\\\"attributeValue\\\"/>\"\r\n\t        \t\"<kactus2:position x=\\\"1\\\" y=\\\"5\\\" />\"\r\n\t    \t\"</ipxact:vendorExtensions>\"\r\n\t\t\"</ipxact:busInterface>\"\r\n\t\t);\r\n\r\n\tQDomDocument document;\r\n\tdocument.setContent(documentContent);\r\n\r\n\tQDomNode businterfaceNode = document.firstChildElement(\"ipxact:busInterface\");\r\n\r\n    QSharedPointer<BusInterface> testbusinterface = BusinterfaceReader::createBusinterfaceFrom(businterfaceNode,\r\n        Document::Revision::Std14);\r\n\r\n\tQCOMPARE(testbusinterface->getVendorExtensions()->last()->type(), QString(\"testExtension\"));\r\n    QCOMPARE(testbusinterface->getVendorExtensions()->first()->type(), QString(\"kactus2:position\"));\r\n\r\n\tQCOMPARE(testbusinterface->getDefaultPos().isNull(), false);\r\n    QCOMPARE(testbusinterface->getDefaultPos().x(), qreal(1));\r\n    QCOMPARE(testbusinterface->getDefaultPos().y(), qreal(5));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_businterfaceReader::testReadAbstractionReference()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_businterfaceReader::testReadAbstractionReference()\r\n{\r\n\tQString documentContent(\r\n\t\t\"<ipxact:busInterface>\"\r\n\t\t    \"<ipxact:abstractionTypes>\"\r\n\t\t        \"<ipxact:abstractionType>\"\r\n\t\t            \"<ipxact:viewRef>testView</ipxact:viewRef>\"\r\n\t\t            \"<ipxact:abstractionRef vendor=\\\"testVendor\\\" library=\\\"testLibrary\\\" name=\\\"testName\\\" version=\\\"1\\\"/>\"\r\n\t\t        \"</ipxact:abstractionType>\"\r\n\t\t    \"</ipxact:abstractionTypes>\"\r\n\t\t\"</ipxact:busInterface>\"\r\n\t\t);\r\n\r\n\tQDomDocument document;\r\n\tdocument.setContent(documentContent);\r\n\r\n\tQDomNode businterfaceNode = document.firstChildElement(\"ipxact:busInterface\");\r\n\r\n    QSharedPointer<BusInterface> testbusinterface = BusinterfaceReader::createBusinterfaceFrom(businterfaceNode,\r\n        Document::Revision::Std14);\r\n\r\n    QSharedPointer<AbstractionType> abstraction = testbusinterface->getAbstractionTypes()->first();    \r\n\tQCOMPARE(abstraction->getViewReferences()->first(), QString(\"testView\"));\r\n\tQCOMPARE(abstraction->getAbstractionRef()->getVendor(), QString(\"testVendor\"));\t\r\n\tQCOMPARE(abstraction->getAbstractionRef()->getLibrary(), QString(\"testLibrary\"));\r\n    QCOMPARE(abstraction->getAbstractionRef()->getName(), QString(\"testName\"));\r\n\tQCOMPARE(abstraction->getAbstractionRef()->getVersion(), QString(\"1\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_businterfaceReader::testReadPortMaps()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_businterfaceReader::testReadPortMaps()\r\n{\r\n\tQString documentContent(\r\n\t\t\"<ipxact:busInterface>\"\r\n\t\t    \"<ipxact:abstractionTypes>\"\r\n\t\t        \"<ipxact:abstractionType>\"\r\n\t\t            \"<ipxact:portMaps>\"\r\n\t\t                \"<ipxact:portMap>\"\r\n\t\t                    \"<ipxact:isPresent>1</ipxact:isPresent>\"\r\n\t\t                    \"<ipxact:logicalPort>\"\r\n\t\t                        \"<ipxact:name>CLK</ipxact:name>\"\r\n\t\t                        \"<ipxact:range>\"\r\n\t\t                            \"<ipxact:left>leftRangeTest</ipxact:left>\"\r\n\t\t                            \"<ipxact:right>rightRangeTest</ipxact:right>\"\r\n\t\t                        \"</ipxact:range>\"\r\n\t\t                    \"</ipxact:logicalPort>\"\r\n\t\t                    \"<ipxact:physicalPort>\"\r\n\t\t                        \"<ipxact:name>clk_physical</ipxact:name>\"\r\n\t\t                        \"<ipxact:partSelect>\"\r\n\t\t                            \"<ipxact:range>\"\r\n\t\t                                \"<ipxact:left>leftTest</ipxact:left>\"\r\n\t\t                                \"<ipxact:right>rightTest</ipxact:right>\"\r\n\t\t                            \"</ipxact:range>\"\r\n\t\t                            \"<ipxact:indices>\"\r\n\t\t                                \"<ipxact:index>index1</ipxact:index>\"\r\n\t\t                                \"<ipxact:index>0</ipxact:index>\"\r\n\t\t                            \"</ipxact:indices>\"\r\n\t\t                        \"</ipxact:partSelect>\"\r\n\t\t                    \"</ipxact:physicalPort>\"\r\n\t\t                    \"<ipxact:logicalTieOff>eoae</ipxact:logicalTieOff>\"\r\n\t\t                \"</ipxact:portMap>\"\r\n\t\t            \"</ipxact:portMaps>\"\r\n\t\t        \"</ipxact:abstractionType>\"\r\n\t\t    \"</ipxact:abstractionTypes>\"\r\n\t\t\"</ipxact:busInterface>\"\r\n\t\t);\r\n\r\n\tQDomDocument document;\r\n\tdocument.setContent(documentContent);\r\n\r\n\tQDomNode businterfaceNode = document.firstChildElement(\"ipxact:busInterface\");\r\n\r\n    QSharedPointer<BusInterface> testbusinterface = BusinterfaceReader::createBusinterfaceFrom(businterfaceNode,\r\n        Document::Revision::Std14);\r\n\r\n    QSharedPointer<PortMap> portMap = testbusinterface->getAbstractionTypes()->first()->getPortMaps()->first();\r\n    \r\n\tQCOMPARE(portMap->getIsPresent(), QString(\"1\"));\r\n\r\n\tQCOMPARE(portMap->getLogicalPort()->name_, QString(\"CLK\"));\r\n\tQCOMPARE(portMap->getLogicalPort()->range_->getLeft(), QString(\"leftRangeTest\"));\r\n\tQCOMPARE(portMap->getLogicalPort()->range_->getRight(), QString(\"rightRangeTest\"));\r\n\r\n\tQCOMPARE(portMap->getPhysicalPort()->name_, QString(\"clk_physical\"));\r\n\tQCOMPARE(portMap->getPhysicalPort()->partSelect_->getLeftRange(), QString(\"leftTest\"));\r\n\tQCOMPARE(portMap->getPhysicalPort()->partSelect_->getRightRange(), QString(\"rightTest\"));\r\n\r\n\tQSharedPointer<QStringList > indices = portMap->getPhysicalPort()->partSelect_->getIndices();\r\n\tQCOMPARE(indices->first(), QString(\"index1\"));\r\n\tQCOMPARE(indices->last(), QString(\"0\"));\r\n\r\n\tQCOMPARE(portMap->getLogicalTieOff(), QString(\"eoae\") );\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_businterfaceReader::testReadPortMaps2022()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_businterfaceReader::testReadPortMaps2022()\r\n{\r\n\tQString documentContent(\r\n\t\t\"<ipxact:busInterface>\"\r\n\t\t    \"<ipxact:abstractionTypes>\"\r\n\t\t        \"<ipxact:abstractionType>\"\r\n\t\t            \"<ipxact:portMaps>\"\r\n\t\t                \"<ipxact:portMap>\"\r\n\t\t                    \"<ipxact:logicalPort>\"\r\n\t\t                        \"<ipxact:name>CLK</ipxact:name>\"\r\n\t\t                        \"<ipxact:range>\"\r\n\t\t                            \"<ipxact:left>leftRangeTest</ipxact:left>\"\r\n\t\t                            \"<ipxact:right>rightRangeTest</ipxact:right>\"\r\n\t\t                        \"</ipxact:range>\"\r\n\t\t                    \"</ipxact:logicalPort>\"\r\n\t\t                    \"<ipxact:physicalPort>\"\r\n\t\t                        \"<ipxact:name>clk_physical</ipxact:name>\"\r\n\t\t                        \"<ipxact:partSelect>\"\r\n\t\t                            \"<ipxact:range>\"\r\n\t\t                                \"<ipxact:left>leftTest</ipxact:left>\"\r\n\t\t                                \"<ipxact:right>rightTest</ipxact:right>\"\r\n\t\t                            \"</ipxact:range>\"\r\n\t\t                            \"<ipxact:indices>\"\r\n\t\t                                \"<ipxact:index>index1</ipxact:index>\"\r\n\t\t                                \"<ipxact:index>0</ipxact:index>\"\r\n\t\t                            \"</ipxact:indices>\"\r\n\t\t                        \"</ipxact:partSelect>\"\r\n\t\t                    \"</ipxact:physicalPort>\"\r\n\t\t                    \"<ipxact:logicalTieOff>none</ipxact:logicalTieOff>\"\r\n\t\t\t\t\t\t\t\"<ipxact:vendorExtensions>\"\r\n        \t\t\t\t\t\t\"<testExtension testAttribute=\\\"attributeValue\\\"/>\"\r\n\t\t\t\t\t\t\t\"</ipxact:vendorExtensions>\"\r\n\t\t                \"</ipxact:portMap>\"\r\n\t\t            \"</ipxact:portMaps>\"\r\n\t\t        \"</ipxact:abstractionType>\"\r\n\t\t    \"</ipxact:abstractionTypes>\"\r\n\t\t\"</ipxact:busInterface>\"\r\n\t\t);\r\n\r\n\tQDomDocument document;\r\n\tdocument.setContent(documentContent);\r\n\r\n\tQDomNode businterfaceNode = document.firstChildElement(\"ipxact:busInterface\");\r\n\r\n    QSharedPointer<BusInterface> testbusinterface = BusinterfaceReader::createBusinterfaceFrom(businterfaceNode,\r\n        Document::Revision::Std22);\r\n\r\n    QSharedPointer<PortMap> portMap = testbusinterface->getAbstractionTypes()->first()->getPortMaps()->first();\r\n\r\n\tQCOMPARE(portMap->getLogicalPort()->name_, QString(\"CLK\"));\r\n\tQCOMPARE(portMap->getLogicalPort()->range_->getLeft(), QString(\"leftRangeTest\"));\r\n\tQCOMPARE(portMap->getLogicalPort()->range_->getRight(), QString(\"rightRangeTest\"));\r\n\r\n\tQCOMPARE(portMap->getPhysicalPort()->name_, QString(\"clk_physical\"));\r\n\tQCOMPARE(portMap->getPhysicalPort()->partSelect_->getLeftRange(), QString(\"leftTest\"));\r\n\tQCOMPARE(portMap->getPhysicalPort()->partSelect_->getRightRange(), QString(\"rightTest\"));\r\n\r\n\tQSharedPointer<QStringList > indices = portMap->getPhysicalPort()->partSelect_->getIndices();\r\n\tQCOMPARE(indices->first(), QString(\"index1\"));\r\n\tQCOMPARE(indices->last(), QString(\"0\"));\r\n\r\n    QCOMPARE(portMap->getLogicalTieOff(), QString(\"none\"));\r\n    QCOMPARE(portMap->getVendorExtensions()->count(), 1);\r\n}\r\n\r\nQTEST_APPLESS_MAIN(tst_businterfaceReader)\r\n\r\n#include \"tst_BusInterfaceReader.moc\"\r\n"
  },
  {
    "path": "tests/IPXACTmodels/Component/tst_BusInterfaceReader.pri",
    "content": "# ----------------------------------------------------\r\n# This file is generated by the Qt Visual Studio Add-in.\r\n# ------------------------------------------------------\r\n\r\nSOURCES += ./tst_BusInterfaceReader.cpp\r\n   "
  },
  {
    "path": "tests/IPXACTmodels/Component/tst_BusInterfaceReader.pro",
    "content": "#-----------------------------------------------------------------------------\r\n# File: tst_BusInterfaceReader.pro\r\n#-----------------------------------------------------------------------------\r\n# Project: Kactus 2\r\n# Author: Janne Virtanen\r\n# Date: 22.09.2015\r\n#\r\n# Description:\r\n# Qt project file template for running unit tests for bus interface reader.\r\n#-----------------------------------------------------------------------------\r\n\r\nTEMPLATE = app\r\n\r\nTARGET = tst_BusInterfaceReader\r\nQT += core xml testlib\r\nQT -= gui\r\n\r\nCONFIG += c++11 testcase console\r\n\r\nlinux-g++ | linux-g++-64 | linux-g++-32 {\r\n LIBS += -L../../../executable \\\r\n     -lIPXACTmodels\r\n\r\n}\r\nwin64 | win32 {\r\n LIBS += -L../../../executable \\\r\n     -lIPXACTmodelsd\r\n}\r\n\r\nINCLUDEPATH += $$DESTDIR\r\nINCLUDEPATH += ../../../\r\n\r\nDEPENDPATH += .\r\nDEPENDPATH += ../../../\r\n\r\nOBJECTS_DIR += $$DESTDIR\r\n\r\nMOC_DIR += ./generatedFiles\r\nUI_DIR += ./generatedFiles\r\nRCC_DIR += ./generatedFiles\r\ninclude(tst_BusInterfaceReader.pri)\r\n"
  },
  {
    "path": "tests/IPXACTmodels/Component/tst_BusInterfaceValidator.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: tst_BusInterfaceValidator.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 01.12.2015\r\n//\r\n// Description:\r\n// Unit test for class BusInterfaceValidator.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include <KactusAPI/include/SystemVerilogExpressionParser.h>\r\n\r\n#include <IPXACTmodels/BusDefinition/BusDefinition.h>\r\n#include <IPXACTmodels/AbstractionDefinition/AbstractionDefinition.h>\r\n#include <IPXACTmodels/AbstractionDefinition/PortAbstraction.h>\r\n#include <IPXACTmodels/AbstractionDefinition/WireAbstraction.h>\r\n#include <IPXACTmodels/AbstractionDefinition/WirePort.h>\r\n#include <IPXACTmodels/AbstractionDefinition/TransactionalAbstraction.h>\r\n\r\n#include <IPXACTmodels/Component/validators/BusInterfaceValidator.h>\r\n#include <IPXACTmodels/Component/validators/PortMapValidator.h>\r\n#include <IPXACTmodels/Component/BusInterface.h>\r\n#include <IPXACTmodels/Component/AbstractionType.h>\r\n#include <IPXACTmodels/Component/PortMap.h>\r\n#include <IPXACTmodels/Component/InitiatorInterface.h>\r\n#include <IPXACTmodels/Component/TargetInterface.h>\r\n#include <IPXACTmodels/Component/MirroredTargetInterface.h>\r\n\r\n#include <IPXACTmodels/Component/View.h>\r\n#include <IPXACTmodels/Component/Port.h>\r\n#include <IPXACTmodels/Component/AddressSpace.h>\r\n#include <IPXACTmodels/Component/MemoryMap.h>\r\n#include <IPXACTmodels/Component/FileSet.h>\r\n#include <IPXACTmodels/Component/RemapState.h>\r\n#include <IPXACTmodels/Component/Mode.h>\r\n\r\n#include <IPXACTmodels/common/Parameter.h>\r\n#include <IPXACTmodels/common/Range.h>\r\n\r\n#include <tests/MockObjects/LibraryMock.h>\r\n\r\n#include <QSharedPointer>\r\n#include <QtTest>\r\n\r\nclass tst_BusInterfaceValidator : public QObject\r\n{\r\n    Q_OBJECT\r\n\r\npublic:\r\n    tst_BusInterfaceValidator();\r\n\r\nprivate slots:\r\n\r\n    void testHasValidName();\r\n    void testHasValidName_data();\r\n\r\n    void testHasValidIsPresent();\r\n    void testHasValidIsPresent_data();\r\n\r\n    void testHasValidBusType();\r\n\r\n    void testHasValidAbstractionTypeAbstractionRef();\r\n    void testHasValidAbstractionTypeViewRef();\r\n    void testHasValidAbstractionTypeViewRef_data();\r\n\r\n    void testMultiplePortMapLogicalPortsAreValid();\r\n    void testMultiplePortMapLogicalPortsAreValid_data();\r\n\r\n    void testHasValidMasterInterface();\r\n    void testHasValidMasterInterface_data();\r\n    void testHasValidSlaveInterface();\r\n    void testHasValidSlaveInterface_data();\r\n    void testHasValidSystemInterface();\r\n    void testHasValidSystemInterface_data();\r\n    void testHasValidMirroredSlaveInterface();\r\n    void testHasValidMirroredSlaveInterface_data();\r\n    void testHasValidMonitorInterface();\r\n    void testHasValidMonitorInterface_data();\r\n\r\n    void testHasValidInitiatorInterface2022();\r\n    void testHasValidInitiatorInterface2022_data();\r\n    void testHasValidTargetInterface2022();\r\n    void testHasValidTargetInterface2022_data();\r\n\r\n    void testHasValidBitsInLau();\r\n    void testHasValidBitsInLau_data();\r\n\r\n    void testHasValidBitSteering();\r\n    void testHasValidBitSteering_data();\r\n    void testHasValidBitSteeringForInterfaceMode();\r\n    void testHasValidBitSteeringForInterfaceMode_data();\r\n\r\n    void testHasValidParameters();\r\n\r\nprivate:\r\n    \r\n    bool errorIsNotFoundInErrorList(QString const& expectedError, QVector<QString> errorList);\r\n\r\n    QSharedPointer<BusInterfaceValidator> createBusInterfaceValidator(\r\n        QSharedPointer<ExpressionParser> expressionParser,\r\n        QSharedPointer<QList<QSharedPointer<Choice> > > choices,\r\n        QSharedPointer<QList<QSharedPointer<View> > > views, QSharedPointer<QList<QSharedPointer<Port> > > ports,\r\n        QSharedPointer<QList<QSharedPointer<AddressSpace> > > addressSpaces,\r\n        QSharedPointer<QList<QSharedPointer<MemoryMap> > > memoryMaps,\r\n        QSharedPointer<QList<QSharedPointer<BusInterface> > > busInterfaces,\r\n        QSharedPointer<QList<QSharedPointer<FileSet> > > fileSets,\r\n        QSharedPointer<QList<QSharedPointer<RemapState> > > remapStates,\r\n        QSharedPointer<QList<QSharedPointer<Mode> > > modes,\r\n        LibraryInterface* libraryHandler);\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_BusInterfaceValidator::tst_BusInterfaceValidator()\r\n//-----------------------------------------------------------------------------\r\ntst_BusInterfaceValidator::tst_BusInterfaceValidator()\r\n{\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_BusInterfaceValidator::testNameIsvalid()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_BusInterfaceValidator::testHasValidName()\r\n{\r\n    QFETCH(QString, name);\r\n    QFETCH(bool, isValid);\r\n\r\n    QSharedPointer<BusInterface> testBus (new BusInterface());\r\n    testBus->setName(name);\r\n\r\n    QSharedPointer<ExpressionParser> parser(new SystemVerilogExpressionParser());\r\n    QSharedPointer<BusInterfaceValidator> validator = createBusInterfaceValidator(parser,\r\n        QSharedPointer<QList<QSharedPointer<Choice> > > (),\r\n        QSharedPointer<QList<QSharedPointer<View> > > (), QSharedPointer<QList<QSharedPointer<Port> > > (),\r\n        QSharedPointer<QList<QSharedPointer<AddressSpace> > > (),\r\n        QSharedPointer<QList<QSharedPointer<MemoryMap> > > (),\r\n        QSharedPointer<QList<QSharedPointer<BusInterface> > > (),\r\n        QSharedPointer<QList<QSharedPointer<FileSet> > > (),\r\n        QSharedPointer<QList<QSharedPointer<RemapState> > > (), \r\n        nullptr,\r\n        nullptr);\r\n\r\n    QCOMPARE(validator->hasValidName(testBus), isValid);\r\n\r\n    if (!isValid)\r\n    {\r\n        QVector<QString> foundErrors;\r\n        validator->findErrorsIn(foundErrors, testBus, \"test\", Document::Revision::Std14);\r\n\r\n        QString expectedError = QObject::tr(\"Invalid name specified for bus interface %1 within %2\")\r\n            .arg(testBus->name()).arg(\"test\");\r\n        if (errorIsNotFoundInErrorList(expectedError, foundErrors))\r\n        {\r\n            QFAIL(\"No error message found\");\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_BusInterfaceValidator::testHasValidName_data()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_BusInterfaceValidator::testHasValidName_data()\r\n{\r\n    QTest::addColumn<QString>(\"name\");\r\n    QTest::addColumn<bool>(\"isValid\");\r\n\r\n    QTest::newRow(\"Name test is valid\") << \"test\" << true;\r\n    QTest::newRow(\"Empty name is invalid\") << \"\" << false;\r\n    QTest::newRow(\"Name consisting of only white spaces is invalid\") << \"    \" << false;\r\n    QTest::newRow(\"Name consisting of characters and white spaces is valid\") << \"  test  \" << true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_BusInterfaceValidator::testHasValidIsPresent()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_BusInterfaceValidator::testHasValidIsPresent()\r\n{\r\n    QFETCH(QString, isPresent);\r\n    QFETCH(bool, isValid);\r\n\r\n    QSharedPointer<BusInterface> testBus (new BusInterface());\r\n    testBus->setName(\"testBus\");\r\n    testBus->setIsPresent(isPresent);\r\n\r\n    QSharedPointer<ExpressionParser> parser(new SystemVerilogExpressionParser());\r\n    QSharedPointer<BusInterfaceValidator> validator = createBusInterfaceValidator(parser,\r\n        QSharedPointer<QList<QSharedPointer<Choice> > > (),\r\n        QSharedPointer<QList<QSharedPointer<View> > > (), QSharedPointer<QList<QSharedPointer<Port> > > (),\r\n        QSharedPointer<QList<QSharedPointer<AddressSpace> > > (),\r\n        QSharedPointer<QList<QSharedPointer<MemoryMap> > > (),\r\n        QSharedPointer<QList<QSharedPointer<BusInterface> > > (),\r\n        QSharedPointer<QList<QSharedPointer<FileSet> > > (),\r\n        QSharedPointer<QList<QSharedPointer<RemapState> > > (), \r\n        nullptr,\r\n        nullptr);\r\n\r\n    QCOMPARE(validator->hasValidIsPresent(testBus->getIsPresent()), isValid);\r\n\r\n    if (!isValid)\r\n    {\r\n        QVector<QString> foundErrors;\r\n        validator->findErrorsIn(foundErrors, testBus, \"test\", Document::Revision::Std14);\r\n\r\n        QString expectedError = QObject::tr(\"Invalid isPresent set for bus interface %1 within %2\")\r\n            .arg(testBus->name()).arg(\"test\");\r\n        if (errorIsNotFoundInErrorList(expectedError, foundErrors))\r\n        {\r\n            QFAIL(\"No error message found\");\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_BusInterfaceValidator::testHasValidIsPresent_data()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_BusInterfaceValidator::testHasValidIsPresent_data()\r\n{\r\n    QTest::addColumn<QString>(\"isPresent\");\r\n    QTest::addColumn<bool>(\"isValid\");\r\n\r\n    QTest::newRow(\"IsPresent 1 is valid\") << \"1\" << true;\r\n    QTest::newRow(\"IsPresent 1*3-3 is valid\") << \"1*3-3\" << true;\r\n    QTest::newRow(\"IsPresent 2*100 is invalid\") << \"2*100\" << false;\r\n    QTest::newRow(\"IsPresent -14 is invalid\") << \"-14\" << false;\r\n    QTest::newRow(\"Real number isPresent  0.12 is invalid\") << \"0.12\" << false;\r\n    QTest::newRow(\"Text as isPresent is invalid\") << \"test\" << false;\r\n    QTest::newRow(\"String as isPresent is invalid\") << \"\\\"test\\\"\" << false;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_BusInterfaceValidator::testHasValidBusType()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_BusInterfaceValidator::testHasValidBusType()\r\n{\r\n    QSharedPointer<BusInterface> testBus (new BusInterface());\r\n    testBus->setName(\"testBus\");\r\n\r\n    LibraryMock* mockLibrary (new LibraryMock(this));\r\n    QSharedPointer<ExpressionParser> parser (new SystemVerilogExpressionParser());\r\n    QSharedPointer<BusInterfaceValidator> validator = createBusInterfaceValidator(parser,\r\n        QSharedPointer<QList<QSharedPointer<Choice> > > (),\r\n        QSharedPointer<QList<QSharedPointer<View> > > (), QSharedPointer<QList<QSharedPointer<Port> > > (),\r\n        QSharedPointer<QList<QSharedPointer<AddressSpace> > > (),\r\n        QSharedPointer<QList<QSharedPointer<MemoryMap> > > (),\r\n        QSharedPointer<QList<QSharedPointer<BusInterface> > > (),\r\n        QSharedPointer<QList<QSharedPointer<FileSet> > > (),\r\n        QSharedPointer<QList<QSharedPointer<RemapState> > > (),\r\n        nullptr,\r\n        mockLibrary);\r\n\r\n    QCOMPARE(validator->hasValidBusType(testBus), false);\r\n\r\n    QVector<QString> foundErrors;\r\n    validator->findErrorsIn(foundErrors, testBus, \"test\", Document::Revision::Std14);\r\n\r\n    QString expectedError = QObject::tr(\"Bus definition must be given for bus interface %1 within %2\")\r\n        .arg(testBus->name()).arg(\"test\");\r\n    if (errorIsNotFoundInErrorList(expectedError, foundErrors))\r\n    {\r\n        QFAIL(\"No error message found\");\r\n    }\r\n\r\n    ConfigurableVLNVReference testType(VLNV::BUSDEFINITION, \"testVendor\", \"testLibrary\", \"busDefinition\", \"1.1\");\r\n    testBus->setBusType(testType);\r\n\r\n    QCOMPARE(validator->hasValidBusType(testBus), false);\r\n\r\n    foundErrors.clear();\r\n    validator->findErrorsIn(foundErrors, testBus, \"test\", Document::Revision::Std14);\r\n\r\n    expectedError = QObject::tr(\"Bus definition %1 set for bus interface %2 within %3 could not be found \"\r\n        \"in the library\").arg(testType.toString()).arg(testBus->name()).arg(\"test\");\r\n    if (errorIsNotFoundInErrorList(expectedError, foundErrors))\r\n    {\r\n        QFAIL(\"No error message found\");\r\n    }\r\n\r\n    QSharedPointer<BusDefinition> testDefinition (new BusDefinition(testType, Document::Revision::Std14));\r\n\r\n\r\n    mockLibrary->addComponent(testDefinition);\r\n\r\n    QCOMPARE(validator->hasValidBusType(testBus), true);\r\n\r\n    ConfigurableVLNVReference componentType (VLNV::COMPONENT, \"testVendor\", \"testLbirary\", \"component\", \"0.8\");\r\n    testBus->setBusType(componentType);\r\n\r\n    QCOMPARE(validator->hasValidBusType(testBus), false);\r\n\r\n    foundErrors.clear();\r\n    validator->findErrorsIn(foundErrors, testBus, \"test\", Document::Revision::Std14);\r\n\r\n    expectedError = QObject::tr(\"Invalid bus definition set for %1 within %2\").arg(testBus->name()).arg(\"test\");\r\n    if (errorIsNotFoundInErrorList(expectedError, foundErrors))\r\n    {\r\n        QFAIL(\"No error message found\");\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_BusInterfaceValidator::testHasValidAbstractionTypeViewRef()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_BusInterfaceValidator::testHasValidAbstractionTypeAbstractionRef()\r\n{\r\n    QSharedPointer<AbstractionType> testAbstraction(new AbstractionType());\r\n\r\n    QSharedPointer<BusInterface> testBus (new BusInterface());\r\n    testBus->setName(\"testBus\");\r\n\r\n    LibraryMock* mockLibrary (new LibraryMock(this));\r\n    QSharedPointer<ExpressionParser> parser (new SystemVerilogExpressionParser());\r\n    QSharedPointer<BusInterfaceValidator> validator = createBusInterfaceValidator(parser,\r\n        QSharedPointer<QList<QSharedPointer<Choice> > > (),\r\n        QSharedPointer<QList<QSharedPointer<View> > > (), QSharedPointer<QList<QSharedPointer<Port> > > (),\r\n        QSharedPointer<QList<QSharedPointer<AddressSpace> > > (),\r\n        QSharedPointer<QList<QSharedPointer<MemoryMap> > > (),\r\n        QSharedPointer<QList<QSharedPointer<BusInterface> > > (),\r\n        QSharedPointer<QList<QSharedPointer<FileSet> > > (),\r\n        QSharedPointer<QList<QSharedPointer<RemapState> > > (),\r\n        nullptr,\r\n        mockLibrary);\r\n\r\n    QCOMPARE(validator->hasValidAbstractionTypes(testBus), true);\r\n\r\n    testBus->getAbstractionTypes()->append(testAbstraction);\r\n\r\n    QCOMPARE(validator->hasValidAbstractionTypes(testBus), false);\r\n\r\n    QVector<QString> errorsFound;\r\n    validator->findErrorsIn(errorsFound, testBus, \"test\", Document::Revision::Std14);\r\n    QString expectedError = QObject::tr(\"Abstraction reference must be set for each abstraction type in \"\r\n        \"bus interface %1\").arg(testBus->name());\r\n    if (errorIsNotFoundInErrorList(expectedError, errorsFound))\r\n    {\r\n        QFAIL(\"Error was not found\");\r\n    }\r\n\r\n    QSharedPointer<ConfigurableVLNVReference> abstractionReference (new ConfigurableVLNVReference(\r\n        VLNV::ABSTRACTIONDEFINITION, \"testVendor\", \"testLibrary\", \"Everett\", \"5.1\"));\r\n    testAbstraction->setAbstractionRef(abstractionReference);\r\n\r\n    QCOMPARE(validator->hasValidAbstractionTypes(testBus), false);\r\n\r\n    errorsFound.clear();\r\n    validator->findErrorsIn(errorsFound, testBus, \"test\", Document::Revision::Std14);\r\n    expectedError = QObject::tr(\"Abstraction reference %1 set for bus interface %2 could not be found \"\r\n        \"in the library\").arg(abstractionReference->toString()).arg(testBus->name());\r\n    if (errorIsNotFoundInErrorList(expectedError, errorsFound))\r\n    {\r\n        QFAIL(\"Error was not found\");\r\n    }\r\n\r\n    QSharedPointer<AbstractionDefinition> abstractionDefinition (new AbstractionDefinition(*abstractionReference,\r\n        Document::Revision::Std14));\r\n\r\n    mockLibrary->addComponent(abstractionDefinition);\r\n\r\n    QCOMPARE(validator->hasValidAbstractionTypes(testBus), true);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_BusInterfaceValidator::testHasValidAbstractionTypeViewRef()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_BusInterfaceValidator::testHasValidAbstractionTypeViewRef()\r\n{\r\n    QFETCH(QString, viewName);\r\n    QFETCH(bool, createView);\r\n    QFETCH(bool, isValid);\r\n\r\n    QSharedPointer<QList<QSharedPointer<View> > > testViews (new QList<QSharedPointer<View> > ());\r\n    if (createView)\r\n    {\r\n        if (viewName.isEmpty())\r\n        {\r\n            viewName = \"Champloo\";\r\n        }\r\n\r\n        QSharedPointer<View> newview (new View(viewName));\r\n        testViews->append(newview);\r\n    }\r\n\r\n    QSharedPointer<ConfigurableVLNVReference> abstractionReference (new ConfigurableVLNVReference(\r\n        VLNV::ABSTRACTIONDEFINITION, \"testVendor\", \"testLibrary\", \"Everett\", \"5.1\"));\r\n\r\n    QSharedPointer<AbstractionDefinition> abstractionDefinition(new AbstractionDefinition(*abstractionReference,\r\n        Document::Revision::Std14));\r\n\r\n    LibraryMock* mockLibrary (new LibraryMock(this));\r\n    mockLibrary->addComponent(abstractionDefinition);\r\n\r\n    QSharedPointer<AbstractionType> testAbstraction(new AbstractionType());\r\n    testAbstraction->setAbstractionRef(abstractionReference);\r\n    testAbstraction->getViewReferences()->append(viewName);\r\n\r\n    QSharedPointer<BusInterface> testBus (new BusInterface());\r\n    testBus->setName(\"testBus\");\r\n    testBus->getAbstractionTypes()->append(testAbstraction);\r\n\r\n    QSharedPointer<ExpressionParser> parser (new SystemVerilogExpressionParser());\r\n    QSharedPointer<BusInterfaceValidator> validator  = createBusInterfaceValidator(parser,\r\n        QSharedPointer<QList<QSharedPointer<Choice> > > (), testViews,\r\n        QSharedPointer<QList<QSharedPointer<Port> > > (), QSharedPointer<QList<QSharedPointer<AddressSpace> > > (),\r\n        QSharedPointer<QList<QSharedPointer<MemoryMap> > > (),\r\n        QSharedPointer<QList<QSharedPointer<BusInterface> > > (),\r\n        QSharedPointer<QList<QSharedPointer<FileSet> > > (),\r\n        QSharedPointer<QList<QSharedPointer<RemapState> > >(),\r\n        nullptr,\r\n        mockLibrary);\r\n\r\n    QCOMPARE (validator->hasValidAbstractionTypes(testBus), isValid);\r\n\r\n    if (!isValid)\r\n    {\r\n        QVector<QString> errorsFound;\r\n        validator->findErrorsIn(errorsFound, testBus, \"test\", Document::Revision::Std14);\r\n        QString expectedError = QObject::tr(\"Invalid view reference %1 set for abstraction type in bus interface \"\r\n            \"%2\").arg(viewName).arg(testBus->name());\r\n        if (errorIsNotFoundInErrorList(expectedError, errorsFound))\r\n        {\r\n            QFAIL(\"Error was not found\");\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_BusInterfaceValidator::testHasValidAbstractionTypeViewRef_data()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_BusInterfaceValidator::testHasValidAbstractionTypeViewRef_data()\r\n{\r\n    QTest::addColumn<QString>(\"viewName\");\r\n    QTest::addColumn<bool>(\"createView\");\r\n    QTest::addColumn<bool>(\"isValid\");\r\n\r\n    QTest::newRow(\"View reference view is valid when view exists\") << \"view\" << true << true;\r\n    QTest::newRow(\"Empty view reference is valid when views do not exist\") << \"\" << false << true;\r\n    QTest::newRow(\"Empty view reference is valid when views exist\") << \"\" << true << true;\r\n    QTest::newRow(\"View reference is not valid when view does not exist\") << \"view\" << false << false;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_BusInterfaceValidator::testMultiplePortMapLogicalPortsAreValid()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_BusInterfaceValidator::testMultiplePortMapLogicalPortsAreValid()\r\n{\r\n    QFETCH(QString, logicalNameOne);\r\n    QFETCH(QString, rangeLeftOne);\r\n    QFETCH(QString, rangeRightOne);\r\n    QFETCH(QString, logicalNameTwo);\r\n    QFETCH(QString, rangeLeftTwo);\r\n    QFETCH(QString, rangeRightTwo);\r\n    QFETCH(bool, isValid);\r\n\r\n    QSharedPointer<ConfigurableVLNVReference> abstractionReference (new ConfigurableVLNVReference(\r\n        VLNV::ABSTRACTIONDEFINITION, \"testVendor\", \"testLibrary\", \"Everett\", \"5.1\"));\r\n\r\n    QSharedPointer<AbstractionDefinition> abstractionDefinition(new AbstractionDefinition(*abstractionReference,\r\n        Document::Revision::Std14));\r\n\r\n    QSharedPointer<WirePort> masterWireOne(new WirePort());\r\n    masterWireOne->setDirection(DirectionTypes::IN);\r\n\r\n    QSharedPointer<WireAbstraction> logicalWireAbstractionOne (new WireAbstraction());\r\n    logicalWireAbstractionOne->setMasterPort(masterWireOne);\r\n\r\n    QSharedPointer<PortAbstraction> testLogicalAbstractionOne (new PortAbstraction());\r\n    testLogicalAbstractionOne->setWire(logicalWireAbstractionOne);\r\n\r\n    testLogicalAbstractionOne->setLogicalName(logicalNameOne);\r\n    abstractionDefinition->getLogicalPorts()->append(testLogicalAbstractionOne);\r\n\r\n    if (logicalNameTwo != logicalNameOne)\r\n    {\r\n        QSharedPointer<WirePort> masterWireTwo (new WirePort());\r\n        masterWireTwo->setDirection(DirectionTypes::IN);\r\n\r\n        QSharedPointer<WireAbstraction> logicalWireAbstractionTwo (new WireAbstraction());\r\n        logicalWireAbstractionTwo->setMasterPort(masterWireTwo);\r\n\r\n        QSharedPointer<PortAbstraction> testLogicalAbstractionTwo (new PortAbstraction());\r\n        testLogicalAbstractionTwo->setWire(logicalWireAbstractionTwo);\r\n        testLogicalAbstractionTwo->setLogicalName(logicalNameTwo);\r\n        \r\n        abstractionDefinition->getLogicalPorts()->append(testLogicalAbstractionTwo);\r\n    }\r\n\r\n    LibraryMock* mockLibrary (new LibraryMock(this));\r\n    mockLibrary->addComponent(abstractionDefinition);\r\n\r\n    QSharedPointer<Range> logicalRangeOne (new Range(rangeLeftOne, rangeRightOne));\r\n\r\n    QSharedPointer<PortMap::LogicalPort> testLogicalOne (new PortMap::LogicalPort());\r\n    testLogicalOne->name_ = logicalNameOne;\r\n    testLogicalOne->range_ = logicalRangeOne;\r\n\r\n    QSharedPointer<PartSelect> physicalPartOne (new PartSelect(rangeLeftOne, rangeRightOne));\r\n\r\n    QSharedPointer<PortMap::PhysicalPort> testPhysicalOne (new PortMap::PhysicalPort());\r\n    testPhysicalOne->name_ = QLatin1String(\"Physical\");\r\n    testPhysicalOne->partSelect_ = physicalPartOne;\r\n\r\n    QSharedPointer<PortMap> testPortMapOne (new PortMap());\r\n    testPortMapOne->setLogicalPort(testLogicalOne);\r\n    testPortMapOne->setPhysicalPort(testPhysicalOne);\r\n\r\n    QSharedPointer<Range> logicalRangeTwo (new Range(rangeLeftTwo, rangeRightTwo));\r\n    \r\n    QSharedPointer<PortMap::LogicalPort> testLogicalTwo (new PortMap::LogicalPort());\r\n    testLogicalTwo->name_ = logicalNameTwo;\r\n    testLogicalTwo->range_ = logicalRangeTwo;\r\n\r\n    QSharedPointer<PartSelect> physicalPartTwo (new PartSelect(rangeLeftTwo, rangeRightTwo));\r\n\r\n    QSharedPointer<PortMap::PhysicalPort> testPhysicalTwo (new PortMap::PhysicalPort());\r\n    testPhysicalTwo->name_ = QLatin1String(\"PhysicalTwo\");\r\n    testPhysicalTwo->partSelect_ = physicalPartTwo;\r\n\r\n    QSharedPointer<PortMap> testPortMapTwo (new PortMap());\r\n    testPortMapTwo->setLogicalPort(testLogicalTwo);\r\n    testPortMapTwo->setPhysicalPort(testPhysicalTwo);\r\n\r\n    QSharedPointer<AbstractionType> testAbstraction(new AbstractionType());\r\n    testAbstraction->setAbstractionRef(abstractionReference);\r\n    testAbstraction->getPortMaps()->append(testPortMapOne);\r\n    testAbstraction->getPortMaps()->append(testPortMapTwo);\r\n\r\n    QSharedPointer<BusInterface> testBus (new BusInterface());\r\n    testBus->setName(\"testBus\");\r\n    testBus->setInterfaceMode(General::MASTER);\r\n    testBus->getAbstractionTypes()->append(testAbstraction);\r\n\r\n    QSharedPointer<Port> newPortOne (new Port(testPhysicalOne->name_));\r\n    newPortOne->setLeftBound(rangeLeftOne);\r\n    newPortOne->setRightBound(rangeRightOne);\r\n\r\n    QSharedPointer<Port> newPortTwo (new Port(testPhysicalTwo->name_));\r\n    newPortTwo->setLeftBound(rangeLeftTwo);\r\n    newPortTwo->setRightBound(rangeRightTwo);\r\n\r\n    QSharedPointer<QList<QSharedPointer<Port> > > componentPorts (new QList<QSharedPointer<Port> > ());\r\n    componentPorts->append(newPortOne);\r\n    componentPorts->append(newPortTwo);\r\n\r\n    QSharedPointer<ExpressionParser> parser (new SystemVerilogExpressionParser());\r\n    QSharedPointer<BusInterfaceValidator> validator = createBusInterfaceValidator(parser,\r\n        QSharedPointer<QList<QSharedPointer<Choice> > > (),\r\n        QSharedPointer<QList<QSharedPointer<View> > > (), componentPorts,\r\n        QSharedPointer<QList<QSharedPointer<AddressSpace> > > (),\r\n        QSharedPointer<QList<QSharedPointer<MemoryMap> > > (),\r\n        QSharedPointer<QList<QSharedPointer<BusInterface> > > (),\r\n        QSharedPointer<QList<QSharedPointer<FileSet> > > (),\r\n        QSharedPointer<QList<QSharedPointer<RemapState> > >(),\r\n        nullptr,\r\n        mockLibrary);\r\n\r\n    QCOMPARE (validator->hasValidAbstractionTypes(testBus), isValid);\r\n\r\n    if (!isValid)\r\n    {\r\n        QVector<QString> errorsFound;\r\n        validator->findErrorsIn(errorsFound, testBus, \"test\", Document::Revision::Std14);\r\n\r\n        QString context = tr(\"%1 bus interface %2\").arg(General::interfaceMode2Str(testBus->getInterfaceMode()),\r\n            testBus->name());\r\n\r\n        QString expectedError = QObject::tr(\"Multiple definitions of logical port %1 overlap within %2\").arg(\r\n            logicalNameTwo, context);\r\n\r\n        if (errorIsNotFoundInErrorList(expectedError, errorsFound))\r\n        {\r\n            QFAIL(\"Error was not found\");\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_BusInterfaceValidator::testMultiplePortMapLogicalPortsAreValid_data()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_BusInterfaceValidator::testMultiplePortMapLogicalPortsAreValid_data()\r\n{\r\n    QTest::addColumn<QString>(\"logicalNameOne\");\r\n    QTest::addColumn<QString>(\"rangeLeftOne\");\r\n    QTest::addColumn<QString>(\"rangeRightOne\");\r\n    QTest::addColumn<QString>(\"logicalNameTwo\");\r\n    QTest::addColumn<QString>(\"rangeLeftTwo\");\r\n    QTest::addColumn<QString>(\"rangeRightTwo\");\r\n    QTest::addColumn<bool>(\"isValid\");\r\n\r\n    QTest::newRow(\"Ports referencing different abstraction ports is valid\") <<\r\n        \"Gurren\" << \"0\" << \"4\" << \"Lagann\" << \"0\" << \"4\" << true;\r\n    QTest::newRow(\"Ports referencing the same abstraction port with different ranges is valid\") <<\r\n        \"GurrenLagann\" << \"0\" << \"4\" << \"GurrenLagann\" << \"8\" << \"10\" << true;\r\n    QTest::newRow(\"Logical1: range = [0,10]; Logical2: range = [5,15] is not valid\") <<\r\n        \"GurrenLagann\" << \"0\" << \"10\" << \"GurrenLagann\" << \"5\" << \"15\" << false;\r\n    QTest::newRow(\"Logical1: range = [5,15]; Logical2: range = [0,10] is not valid\") <<\r\n        \"GurrenLagann\" << \"5\" << \"15\" << \"GurrenLagann\" << \"0\" << \"10\" << false;\r\n    QTest::newRow(\"Logical1: range = [5,8]; Logical2: range = [0,10] is not valid\") <<\r\n        \"GurrenLagann\" << \"5\" << \"8\" << \"GurrenLagann\" << \"0\" << \"10\" << false;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_BusInterfaceValidator::testHasValidMasterInterface()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_BusInterfaceValidator::testHasValidMasterInterface()\r\n{\r\n    QFETCH(QString, addressSpaceRef);\r\n    QFETCH(QString, baseAddress);\r\n    QFETCH(QString, masterPresence);\r\n    QFETCH(QString, spacePresence);\r\n    QFETCH(bool, createSpace);\r\n    QFETCH(bool, isValid);\r\n\r\n    QSharedPointer<InitiatorInterface> testMaster (new InitiatorInterface());\r\n    testMaster->setAddressSpaceRef(addressSpaceRef);\r\n    testMaster->setBaseAddress(baseAddress);\r\n    testMaster->setIsPresent(masterPresence);\r\n\r\n    QSharedPointer<QList<QSharedPointer<AddressSpace> > > componentSpaces\r\n        (new QList<QSharedPointer<AddressSpace> > ());\r\n    if (createSpace)\r\n    {\r\n        QSharedPointer<AddressSpace> space (new AddressSpace(addressSpaceRef));\r\n        space->setIsPresent(spacePresence);\r\n        if (addressSpaceRef.isEmpty())\r\n        {\r\n            space->setName(\"Champloo\");\r\n        }\r\n        componentSpaces->append(space);\r\n    }\r\n\r\n    QSharedPointer<BusInterface> testBus (new BusInterface());\r\n    testBus->setMaster(testMaster);\r\n    testBus->setInterfaceMode(General::MASTER);\r\n\r\n    QSharedPointer<ExpressionParser> parser (new SystemVerilogExpressionParser());\r\n    QSharedPointer<BusInterfaceValidator> validator = createBusInterfaceValidator(parser,\r\n        QSharedPointer<QList<QSharedPointer<Choice> > >(),\r\n        QSharedPointer<QList<QSharedPointer<View> > > (), QSharedPointer<QList<QSharedPointer<Port> > > (),\r\n        componentSpaces, QSharedPointer<QList<QSharedPointer<MemoryMap> > > (),\r\n        QSharedPointer<QList<QSharedPointer<BusInterface> > > (),\r\n        QSharedPointer<QList<QSharedPointer<FileSet> > > (),\r\n        QSharedPointer<QList<QSharedPointer<RemapState> > >(),\r\n        nullptr,\r\n        nullptr);\r\n\r\n    QCOMPARE(validator->hasValidInterfaceMode(testBus), isValid);\r\n\r\n    if (!isValid)\r\n    {\r\n        QVector<QString> errorsFound;\r\n        validator->findErrorsIn(errorsFound, testBus, \"test\", Document::Revision::Std14);\r\n\r\n        QString expectedError = QObject::tr(\"Invalid address space reference set for master bus interface %1\")\r\n            .arg(testBus->name());\r\n\r\n        if (addressSpaceRef.isEmpty())\r\n        {\r\n            expectedError = QObject::tr(\"Invalid address space reference set for master bus interface %1\")\r\n                .arg(testBus->name());\r\n        }\r\n        else if (parser->parseExpression(baseAddress).toInt() < 0)\r\n        {\r\n            expectedError = QObject::tr(\"Invalid base address set for master bus interface %1\")\r\n                .arg(testBus->name());\r\n        }\r\n        else if (!createSpace)\r\n        {\r\n            expectedError = QObject::tr(\"Could not find address space %1 referenced by the master bus interface %2\")\r\n                .arg(testMaster->getAddressSpaceRef()).arg(testBus->name());\r\n        }\r\n        else if (parser->parseExpression(masterPresence).toInt() == 1 &&\r\n            parser->parseExpression(spacePresence).toInt() == 0)\r\n        {\r\n            expectedError = QObject::tr(\"Cannot refer to non-present address space %1 in master bus interface %2\")\r\n                .arg(addressSpaceRef).arg(testBus->name());\r\n        }\r\n\r\n        if (errorIsNotFoundInErrorList(expectedError, errorsFound))\r\n        {\r\n            QFAIL(\"Error was not found\");\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_BusInterfaceValidator::testHasValidMasterInterface_data()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_BusInterfaceValidator::testHasValidMasterInterface_data()\r\n{\r\n    QTest::addColumn<QString>(\"addressSpaceRef\");\r\n    QTest::addColumn<QString>(\"baseAddress\");\r\n    QTest::addColumn<QString>(\"masterPresence\");\r\n    QTest::addColumn<QString>(\"spacePresence\");\r\n    QTest::addColumn<bool>(\"createSpace\");\r\n    QTest::addColumn<bool>(\"isValid\");\r\n\r\n    QTest::newRow(\"Master referencing address space is valid\") << \"space\" << \"\" << \"\" << \"\" << true << true;\r\n    QTest::newRow(\"Empty master interface is valid\") << \"\" << \"\" << \"\"  << \"\" << false << true;\r\n    QTest::newRow(\"Master referencing non-existing space is not valid\") << \"space\" << \"\" << \"\" << \"\" << false <<\r\n        false;\r\n    QTest::newRow(\"Master not containing space reference is valid\") << \"\" << \"\" << \"\" << \"\" << true << true;\r\n    QTest::newRow(\"Master containing base address is valid\") << \"space\" << \"4+4\" << \"\" << \"\" << true << true;\r\n    QTest::newRow(\"Master containing negative base address is valid\") << \"space\" << \"-2\" << \"\" << \"\" << true << true;\r\n\r\n    QTest::newRow(\"Present master referring present address space is valid\") << \"space\" << \"\" << \"1\" << \"1\" <<\r\n        true << true;\r\n    QTest::newRow(\"Non-present master referring present address space is valid\") << \"space\" << \"\" << \"0\" << \"1\" <<\r\n        true << true;\r\n    QTest::newRow(\"Non-present master referring non-present address space is valid\") << \"space\" << \"\" << \"0\" <<\r\n        \"0\" << true << true;\r\n    QTest::newRow(\"Present master referring non-present address space is not valid\") << \"space\" << \"\" << \"1\" <<\r\n        \"0\" << true << false;\r\n\r\n    QTest::newRow(\"Master containing long base address is valid\") <<\r\n        \"space\" << \"4000000000\" << \"\" << \"\" << true << true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_BusInterfaceValidator::testHasValidSlaveInterface()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_BusInterfaceValidator::testHasValidSlaveInterface()\r\n{\r\n    QFETCH(QString, memoryMapRef);\r\n    QFETCH(QString, bridgeMasterRef);\r\n    QFETCH(QString, bridgeIsPresent);\r\n    QFETCH(QString, fileSetRef);\r\n    QFETCH(QString, interfacePresence);\r\n    QFETCH(QString, memoryMapPresence);\r\n    QFETCH(bool, createMemoryMap);\r\n    QFETCH(bool, createMaster);\r\n    QFETCH(bool, createFileSet);\r\n    QFETCH(bool, isValid);\r\n\r\n    QSharedPointer<TargetInterface> testSlave (new TargetInterface());\r\n    testSlave->setMemoryMapRef(memoryMapRef);\r\n\r\n    QSharedPointer<QList<QSharedPointer<MemoryMap> > > memoryMaps (new QList<QSharedPointer<MemoryMap> > ());\r\n    if (createMemoryMap)\r\n    {\r\n        QSharedPointer<MemoryMap> testMap (new MemoryMap(memoryMapRef));\r\n        testMap->setIsPresent(memoryMapPresence);\r\n        if (memoryMapRef.isEmpty())\r\n        {\r\n            testMap->setName(QLatin1String(\"Champloo\"));\r\n        }\r\n        memoryMaps->append(testMap);\r\n    }\r\n\r\n    if (!bridgeMasterRef.isEmpty())\r\n    {\r\n        QSharedPointer<TransparentBridge> testBridge (new TransparentBridge());\r\n        testBridge->setMasterRef(bridgeMasterRef);\r\n        testBridge->setIsPresent(bridgeIsPresent);\r\n\r\n        testSlave->getBridges()->append(testBridge);\r\n    }\r\n\r\n    QSharedPointer<QList<QSharedPointer<BusInterface> > > busInterfaces(new QList<QSharedPointer<BusInterface> > ());\r\n    if (createMaster)\r\n    {\r\n        QSharedPointer<BusInterface> masterBus (new BusInterface());\r\n        masterBus->setName(bridgeMasterRef);\r\n        masterBus->setInterfaceMode(General::MASTER);\r\n        if (bridgeMasterRef.isEmpty())\r\n        {\r\n            masterBus->setName(\"Samurai\");\r\n        }\r\n        busInterfaces->append(masterBus);\r\n    }\r\n\r\n    if (!fileSetRef.isEmpty())\r\n    {\r\n        QSharedPointer<TargetInterface::FileSetRefGroup> testGroup (new TargetInterface::FileSetRefGroup());\r\n        testGroup->group_ = fileSetRef + \" group\";\r\n\r\n        QSharedPointer<FileSetRef> ref = QSharedPointer<FileSetRef>(new FileSetRef());\r\n        ref->setReference(fileSetRef);\r\n\r\n        testGroup->fileSetRefs_->append(ref);\r\n        testSlave->getFileSetRefGroup()->append(testGroup);\r\n    }\r\n\r\n    QSharedPointer<QList<QSharedPointer<FileSet> > > fileSets (new QList<QSharedPointer<FileSet> > ());\r\n    if (createFileSet)\r\n    {\r\n        QSharedPointer<FileSet> testSet (new FileSet(fileSetRef));\r\n        if (fileSetRef.isEmpty())\r\n        {\r\n            testSet->setName(\"fileSetReplacement\");\r\n        }\r\n        fileSets->append(testSet);\r\n    }\r\n\r\n    QSharedPointer<BusInterface> testBus (new BusInterface());\r\n    testBus->setName(\"testBus\");\r\n    testBus->setSlave(testSlave);\r\n    testBus->setIsPresent(interfacePresence);\r\n    busInterfaces->append(testBus);\r\n\r\n    QSharedPointer<ExpressionParser> parser (new SystemVerilogExpressionParser());\r\n    QSharedPointer<BusInterfaceValidator> validator = createBusInterfaceValidator(parser,\r\n        QSharedPointer<QList<QSharedPointer<Choice> > > (),\r\n        QSharedPointer<QList<QSharedPointer<View> > > (), QSharedPointer<QList<QSharedPointer<Port> > > (),\r\n        QSharedPointer<QList<QSharedPointer<AddressSpace> > > (), memoryMaps, busInterfaces, fileSets,\r\n        QSharedPointer<QList<QSharedPointer<RemapState> > >(),\r\n        nullptr,\r\n        nullptr);\r\n\r\n    QCOMPARE(validator->hasValidInterfaceMode(testBus), isValid);\r\n\r\n    if (!isValid)\r\n    {\r\n        QVector<QString> errorsFound;\r\n        validator->findErrorsIn(errorsFound, testBus, \"test\", Document::Revision::Std14);\r\n\r\n        QString expectedError = QObject::tr(\"Invalid slave interface set for bus interface %1\")\r\n            .arg(testBus->name());\r\n\r\n        if (!testSlave->getMemoryMapRef().isEmpty() && !testSlave->getBridges()->isEmpty())\r\n        {\r\n            expectedError = QObject::tr(\"Both a memory map reference and transparent bridges are contained \"\r\n                \"within slave bus interface %1\").arg(testBus->name());\r\n        }\r\n        else if ((!memoryMapRef.isEmpty() && !createMemoryMap) || \r\n            (parser->parseExpression(interfacePresence).toInt() == 1 &&\r\n            parser->parseExpression(memoryMapPresence).toInt() == 0))\r\n        {\r\n            expectedError = QObject::tr(\"Memory map %1 referenced by the slave bus interface %2 was not found\")\r\n                .arg(testSlave->getMemoryMapRef()).arg(testBus->name());\r\n        }\r\n        else if (!bridgeMasterRef.isEmpty() && !createMaster)\r\n        {\r\n            expectedError = QObject::tr(\"Master bus interface %1 referenced by the slave bus interface %2 was \"\r\n                \"not found\").arg(bridgeMasterRef).arg(testBus->name());\r\n        }\r\n        else if (parser->parseExpression(bridgeIsPresent).toInt() < 0 ||\r\n            parser->parseExpression(bridgeIsPresent).toInt() > 1)\r\n        {\r\n            expectedError = QObject::tr(\"Transparent bridge within the slave bus interface %1 has invalid \"\r\n                \"isPresent\").arg(testBus->name());\r\n        }\r\n        else if (!fileSetRef.isEmpty() && !createFileSet)\r\n        {\r\n            expectedError = QObject::tr(\"Invalid file set %1 referenced within group %2 of slave bus interface %3\")\r\n                .arg(fileSetRef).arg(testSlave->getFileSetRefGroup()->first()->group_).arg(testBus->name());\r\n        }\r\n\r\n        if (errorIsNotFoundInErrorList(expectedError, errorsFound))\r\n        {\r\n            QFAIL(\"Error was not found\");\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_BusInterfaceValidator::testHasValidSlaveInterface_data()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_BusInterfaceValidator::testHasValidSlaveInterface_data()\r\n{\r\n    QTest::addColumn<QString>(\"memoryMapRef\");\r\n    QTest::addColumn<QString>(\"bridgeMasterRef\");\r\n    QTest::addColumn<QString>(\"bridgeIsPresent\");\r\n    QTest::addColumn<QString>(\"fileSetRef\");\r\n    QTest::addColumn<QString>(\"interfacePresence\");\r\n    QTest::addColumn<QString>(\"memoryMapPresence\");\r\n    QTest::addColumn<bool>(\"createMemoryMap\");\r\n    QTest::addColumn<bool>(\"createMaster\");\r\n    QTest::addColumn<bool>(\"createFileSet\");\r\n    QTest::addColumn<bool>(\"isValid\");\r\n\r\n    QTest::newRow(\"Empty slave is valid\") << \"\" << \"\" << \"\" << \"\" << \"\" << \"\" << true << true << true << true;\r\n    QTest::newRow(\"Slave referencing memory map is valid\")\r\n        << \"testMap\" << \"\" << \"\" << \"\" << \"\" << \"\" << true << false << false << true;\r\n    QTest::newRow(\"Slave referencing non-existing memory map is not valid\")\r\n        << \"testMap\" << \"\" << \"\" << \"\" << \"\" << \"\" << false << false << false << false;\r\n    QTest::newRow(\"Non-present slave referencing present memory map is valid\")\r\n        << \"testMap\" << \"\" << \"\" << \"\" << \"0\" << \"1\" << true << false << false << true;\r\n    QTest::newRow(\"Non-present slave referencing non-present memory map is valid\")\r\n        << \"testMap\" << \"\" << \"\" << \"\" << \"0\" << \"0\" << true << false << false << true;\r\n    QTest::newRow(\"Present slave referencing present memory map is valid\")\r\n        << \"testMap\" << \"\" << \"\" << \"\" << \"1\" << \"1\" << true << false << false << true;\r\n    QTest::newRow(\"Present slave referencing non-present memory map is not valid\")\r\n        << \"testMap\" << \"\" << \"\" << \"\" << \"1\" << \"0\" << true << false << false << false;\r\n\r\n    QTest::newRow(\"Slave bridge referencing master is valid\")\r\n        << \"\" << \"testMaster\" << \"\" << \"\" << \"\" << \"\" << false << true << false << true;\r\n    QTest::newRow(\"Slave bridge referencing non-existing master is not valid\")\r\n        << \"\" << \"testMaster\" << \"\" << \"\" << \"\" << \"\" << false << false << false << false;\r\n    QTest::newRow(\"Slave bridge with bit isPresent is valid\")\r\n        << \"\" << \"testMaster\" << \"1\" << \"\" << \"\" << \"\" << false << true << false << true;\r\n    QTest::newRow(\"Slave bridge with non-bit isPresent is not valid\")\r\n        << \"\" << \"testMaster\" << \"18\" << \"\" << \"\" << \"\" << false << true << false << false;\r\n\r\n    QTest::newRow(\"Slave with both memory map ref and bridge is not valid\")\r\n        << \"testMap\" << \"testMaster\" << \"\" << \"\" << \"\" << \"\" << true << true << false << false;\r\n    QTest::newRow(\"Slave with file set ref group is valid\")\r\n        << \"\" << \"\" << \"\" << \"testFileGroup\" << \"\" << \"\" << false << false << true << true;\r\n    QTest::newRow(\"Slave with file set ref group referencing non-existing file set is not valid\")\r\n        << \"\" << \"\" << \"\" << \"testFileGroup\" << \"\" << \"\" << false << false << false << false;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_BusInterfaceValidator::testHasValidSystemInterface()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_BusInterfaceValidator::testHasValidSystemInterface()\r\n{\r\n    QFETCH(QString, systemGroup);\r\n    QFETCH(bool, hasGroupName);\r\n    QFETCH(bool, isValid);\r\n\r\n    ConfigurableVLNVReference testType(VLNV::BUSDEFINITION, \"testVendor\", \"testLibrary\", \"busDefinition\", \"1.1\");\r\n\r\n    QSharedPointer<BusDefinition> testDefinition (new BusDefinition(testType, Document::Revision::Std14));\r\n\r\n    if (hasGroupName)\r\n    {\r\n        QStringList systemGroupNames;\r\n        systemGroupNames.append(systemGroup);\r\n        testDefinition->setSystemGroupNames(systemGroupNames);\r\n    }\r\n\r\n    LibraryMock* mockLibrary (new LibraryMock(this));\r\n    mockLibrary->addComponent(testDefinition);\r\n\r\n    QSharedPointer<BusInterface> testBus (new BusInterface());\r\n    testBus->setName(\"testBus\");\r\n    testBus->setInterfaceMode(General::SYSTEM);\r\n    testBus->setSystem(systemGroup);\r\n    testBus->setBusType(testType);\r\n    \r\n    QSharedPointer<ExpressionParser> parser (new SystemVerilogExpressionParser());\r\n    QSharedPointer<BusInterfaceValidator> validator = createBusInterfaceValidator(parser,\r\n        QSharedPointer<QList<QSharedPointer<Choice> > > (),\r\n        QSharedPointer<QList<QSharedPointer<View> > > (),\r\n        QSharedPointer<QList<QSharedPointer<Port> > > (),\r\n        QSharedPointer<QList<QSharedPointer<AddressSpace> > > (),\r\n        QSharedPointer<QList<QSharedPointer<MemoryMap> > > (),\r\n        QSharedPointer<QList<QSharedPointer<BusInterface> > > (),\r\n        QSharedPointer<QList<QSharedPointer<FileSet> > > (),\r\n        QSharedPointer<QList<QSharedPointer<RemapState> > > (),\r\n        nullptr,\r\n        mockLibrary);\r\n\r\n    QCOMPARE(validator->hasValidInterfaceMode(testBus), isValid);\r\n\r\n    if (!isValid)\r\n    {\r\n        QVector<QString> errorsFound;\r\n        validator->findErrorsIn(errorsFound, testBus, \"test\", Document::Revision::Std14);\r\n\r\n        QString expectedError = QObject::tr(\"No system group given for system bus interface %1\")\r\n            .arg(testBus->name());\r\n\r\n        if (!hasGroupName)\r\n        {\r\n            expectedError = QObject::tr(\"Could not find system group %1 set for system bus interface %2 with bus \"\r\n                \"definition %3.\").arg(systemGroup).arg(testBus->name()).arg(testType.toString());\r\n        }\r\n\r\n        if (errorIsNotFoundInErrorList(expectedError, errorsFound))\r\n        {\r\n            QFAIL(\"Error was not found\");\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_BusInterfaceValidator::testHasValidSystemInterface_data()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_BusInterfaceValidator::testHasValidSystemInterface_data()\r\n{\r\n    QTest::addColumn<QString>(\"systemGroup\");\r\n    QTest::addColumn<bool>(\"hasGroupName\");\r\n    QTest::addColumn<bool>(\"isValid\");\r\n\r\n    QTest::newRow(\"System with group referencing existing group name is valid\") << \"systemGroup\" << true << true;\r\n    QTest::newRow(\"System without group is not valid\") << \"\" << true << false;\r\n    QTest::newRow(\"System with group referencing non-existing group is not valid\") << \"systemGroup\" << false <<\r\n        false;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_BusInterfaceValidator::testHasValidMirroredSlaveInterface()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_BusInterfaceValidator::testHasValidMirroredSlaveInterface()\r\n{\r\n    QFETCH(QString, remapAddress);\r\n    QFETCH(QString, remapStateName);\r\n    QFETCH(QString, range);\r\n    QFETCH(bool, createState);\r\n    QFETCH(bool, isValid);\r\n\r\n    QSharedPointer<MirroredTargetInterface> testMirrorSlave (new MirroredTargetInterface());\r\n    testMirrorSlave->setRange(range);\r\n\r\n    if (!remapAddress.isEmpty())\r\n    {\r\n        QSharedPointer<MirroredTargetInterface::RemapAddress> slaveRemapAddress\r\n            (new MirroredTargetInterface::RemapAddress(remapAddress));\r\n        slaveRemapAddress->state_ = remapStateName;\r\n        testMirrorSlave->getRemapAddresses()->append(slaveRemapAddress);\r\n    }\r\n\r\n    QSharedPointer<QList<QSharedPointer<RemapState> > > remapStates (new QList<QSharedPointer<RemapState> > ());\r\n    if (createState)\r\n    {\r\n        QSharedPointer<RemapState> newState (new RemapState(remapStateName));\r\n        if (remapStateName.isEmpty())\r\n        {\r\n            newState->setName(\"replacedState\");\r\n        }\r\n        remapStates->append(newState);\r\n    }\r\n\r\n    QSharedPointer<BusInterface> testBus (new BusInterface());\r\n    testBus->setName(\"testBus\");\r\n    testBus->setMirroredSlave(testMirrorSlave);\r\n\r\n    QSharedPointer<ExpressionParser> parser (new SystemVerilogExpressionParser());\r\n    QSharedPointer<BusInterfaceValidator> validator = createBusInterfaceValidator(parser,\r\n        QSharedPointer<QList<QSharedPointer<Choice> > > (),\r\n        QSharedPointer<QList<QSharedPointer<View> > > (), QSharedPointer<QList<QSharedPointer<Port> > > (),\r\n        QSharedPointer<QList<QSharedPointer<AddressSpace> > > (),\r\n        QSharedPointer<QList<QSharedPointer<MemoryMap> > > (),\r\n        QSharedPointer<QList<QSharedPointer<BusInterface> > > (),\r\n        QSharedPointer<QList<QSharedPointer<FileSet> > > (),\r\n        remapStates,\r\n        nullptr,\r\n        nullptr);\r\n\r\n    QCOMPARE(validator->hasValidInterfaceMode(testBus), isValid);\r\n\r\n    if (!isValid)\r\n    {\r\n        QVector<QString> errorsFound;\r\n        validator->findErrorsIn(errorsFound, testBus, \"test\", Document::Revision::Std14);\r\n\r\n        QString expectedError = QObject::tr(\"Invalid mirroredSlave interface set for bus interface %1\")\r\n            .arg(testBus->name());\r\n\r\n        if (parser->parseExpression(remapAddress).toInt() <= 0)\r\n        {\r\n            expectedError = QObject::tr(\"Invalid remap address set for mirroredSlave bus interface %1\")\r\n                .arg(testBus->name());\r\n        }\r\n        else if (parser->parseExpression(range).toInt() < 1)\r\n        {\r\n            expectedError = QObject::tr(\"Invalid range set for mirroredSlave bus interface %1\")\r\n                .arg(testBus->name());\r\n        }\r\n        else if (!remapStateName.isEmpty() && !createState)\r\n        {\r\n            expectedError = QObject::tr(\"Invalid remap state set for mirroredSlave bus interface %1\")\r\n                .arg(testBus->name());\r\n        }\r\n\r\n        if (errorIsNotFoundInErrorList(expectedError, errorsFound))\r\n        {\r\n            QFAIL(\"Error was not found\");\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_BusInterfaceValidator::testHasValidMirroredSlaveInterface_data()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_BusInterfaceValidator::testHasValidMirroredSlaveInterface_data()\r\n{\r\n    QTest::addColumn<QString>(\"remapAddress\");\r\n    QTest::addColumn<QString>(\"range\");\r\n    QTest::addColumn<QString>(\"remapStateName\");\r\n    QTest::addColumn<bool>(\"createState\");\r\n    QTest::addColumn<bool>(\"isValid\");\r\n\r\n    QTest::newRow(\"Mirrored slave without elements is valid\") << \"\" << \"\" << \"\" << false << true;\r\n    QTest::newRow(\"Mirrored slave with remap address and range is valid\") << \"1+2\" << \"12\" << \"\" << false << true;\r\n\r\n    QTest::newRow(\"Mirrored slave with long remap address and long range is valid\") <<\r\n        \"4000000000\" << \"4000000000\" << \"\" << false << true;\r\n\r\n    QTest::newRow(\"Mirrored slave with negative remap address is not valid\") << \"10-20\" << \"12\" << \"\" << false <<\r\n        false;\r\n    QTest::newRow(\"Mirrored slave with non-positive range is not valid\") << \"1+2\" << \"0\" << \"\" << false << false;\r\n    QTest::newRow(\"Mirrored slave without remap address is not valid\") << \"\" << \"12\" << \"\" << false << false;\r\n    QTest::newRow(\"Mirrored slave without range is not valid\") << \"1+2\" << \"\" << \"\" << false << false;\r\n\r\n    QTest::newRow(\"Remap state referencing existing state is valid\") << \"1+2\" << \"12\" << \"testState\" << true <<\r\n        true;\r\n    QTest::newRow(\"Remap state referencing non-existing state is not valid\") << \"1+2\" << \"12\" << \"testState\" <<\r\n        false << false;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_BusInterfaceValidator::testHasValidMonitorInterface()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_BusInterfaceValidator::testHasValidMonitorInterface()\r\n{\r\n    QFETCH(QString, interfaceMode);\r\n    QFETCH(QString, systemGroup);\r\n    QFETCH(bool, createGroup);\r\n    QFETCH(bool, isValid);\r\n\r\n    ConfigurableVLNVReference testType(VLNV::BUSDEFINITION, \"testVendor\", \"testLibrary\", \"busDefinition\", \"1.1\");\r\n\r\n    QSharedPointer<BusDefinition> testDefinition (new BusDefinition(testType, Document::Revision::Std14));\r\n\r\n    if (createGroup)\r\n    {\r\n        QStringList systemGroupNames;\r\n        if (systemGroup.isEmpty())\r\n        {\r\n            systemGroupNames.append(\"Champloo\");\r\n        }\r\n        else\r\n        {\r\n            systemGroupNames.append(systemGroup);\r\n        }\r\n        testDefinition->setSystemGroupNames(systemGroupNames);\r\n    }\r\n\r\n    LibraryMock* mockLibrary (new LibraryMock(this));\r\n    mockLibrary->addComponent(testDefinition);\r\n\r\n    QSharedPointer<BusInterface::MonitorInterface> testMonitor (new BusInterface::MonitorInterface());\r\n    testMonitor->interfaceMode_ = General::str2Interfacemode(interfaceMode, General::INTERFACE_MODE_COUNT);\r\n    testMonitor->group_ = systemGroup;\r\n\r\n    QSharedPointer<BusInterface> testBus (new BusInterface());\r\n    testBus->setName(\"testBus\");\r\n    testBus->setMonitor(testMonitor);\r\n    testBus->setBusType(testType);\r\n\r\n    QSharedPointer<ExpressionParser> parser (new SystemVerilogExpressionParser());\r\n    QSharedPointer<BusInterfaceValidator> validator = createBusInterfaceValidator(parser,\r\n        QSharedPointer<QList<QSharedPointer<Choice> > > (),\r\n        QSharedPointer<QList<QSharedPointer<View> > > (),\r\n        QSharedPointer<QList<QSharedPointer<Port> > > (),\r\n        QSharedPointer<QList<QSharedPointer<AddressSpace> > > (),\r\n        QSharedPointer<QList<QSharedPointer<MemoryMap> > > (),\r\n        QSharedPointer<QList<QSharedPointer<BusInterface> > > (),\r\n        QSharedPointer<QList<QSharedPointer<FileSet> > > (),\r\n        QSharedPointer<QList<QSharedPointer<RemapState> > >(),\r\n        nullptr,\r\n        mockLibrary);\r\n\r\n    QCOMPARE(validator->hasValidInterfaceMode(testBus), isValid);\r\n\r\n    if (!isValid)\r\n    {\r\n        QVector<QString> errorsFound;\r\n        validator->findErrorsIn(errorsFound, testBus, \"test\", Document::Revision::Std14);\r\n\r\n        QString expectedError = QObject::tr(\"Invalid interface mode set for monitor bus interface %1\")\r\n            .arg(testBus->name());\r\n\r\n        if (testMonitor->interfaceMode_ != General::SYSTEM &&\r\n            testMonitor->interfaceMode_ != General::MIRRORED_SYSTEM && !systemGroup.isEmpty())\r\n        {\r\n            expectedError = QObject::tr(\"Group cannot be set for monitor bus interface %1 with interface mode \"\r\n                \"master, slave, mirrored master or mirrored slave\").arg(testBus->name());\r\n        }\r\n        else if (!systemGroup.isEmpty() && !createGroup)\r\n        {\r\n            expectedError = QObject::tr(\"Could not find system group %1 set for monitor bus interface %2 with bus \"\r\n                \"definition %3.\").arg(systemGroup).arg(testBus->name()).arg(testType.toString());\r\n        }\r\n\r\n        if (errorIsNotFoundInErrorList(expectedError, errorsFound))\r\n        {\r\n            QFAIL(\"Error was not found\");\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_BusInterfaceValidator::testHasValidMonitorInterface_data()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_BusInterfaceValidator::testHasValidMonitorInterface_data()\r\n{\r\n    QTest::addColumn<QString>(\"interfaceMode\");\r\n    QTest::addColumn<QString>(\"systemGroup\");\r\n    QTest::addColumn<bool>(\"createGroup\");\r\n    QTest::addColumn<bool>(\"isValid\");\r\n\r\n    QTest::newRow(\"Monitor with interface master is valid\") << \"master\" << \"\" << false << true;\r\n    QTest::newRow(\"Monitor with interface master containing a group is not valid\") << \"master\" << \"group\" <<\r\n        false <<false;\r\n\r\n    QTest::newRow(\"Monitor with interface system containing group referencing existing group is valid\") <<\r\n        \"system\" << \"group\" << true << true;\r\n    QTest::newRow(\"Monitor with interface system containing group referencing non-existing group is not valid\") <<\r\n        \"system\" << \"group\" << false << false;\r\n    \r\n    QTest::newRow(\"Monitor with interface undefined is not valid\") << \"undefined\" << \"\" << false << false;\r\n    QTest::newRow(\"Monitor with interface monitor is not valid\") << \"monitor\" << \"\" << false << false;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_BusInterfaceValidator::testHasValidInitiatorInterface2022()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_BusInterfaceValidator::testHasValidInitiatorInterface2022()\r\n{\r\n    QFETCH(QString, addressSpaceRef);\r\n    QFETCH(QString, baseAddress);\r\n    QFETCH(QString, modeRef);\r\n    QFETCH(bool, createSpace);\r\n    QFETCH(bool, isValid);\r\n    QFETCH(QString, expectedError);\r\n\r\n    QSharedPointer<InitiatorInterface> testMaster(new InitiatorInterface());\r\n    testMaster->setAddressSpaceRef(addressSpaceRef);\r\n    testMaster->setBaseAddress(baseAddress);\r\n\r\n    QSharedPointer<QList<QSharedPointer<AddressSpace> > > componentSpaces\r\n    (new QList<QSharedPointer<AddressSpace> >());\r\n    if (createSpace)\r\n    {\r\n        QSharedPointer<AddressSpace> space(new AddressSpace(addressSpaceRef));\r\n\r\n        if (addressSpaceRef.isEmpty())\r\n        {\r\n            space->setName(\"Champloo\");\r\n        }\r\n        componentSpaces->append(space);\r\n    }\r\n\r\n    QSharedPointer<BusInterface> testBus(new BusInterface());\r\n    testBus->setName(\"testBus\");\r\n    testBus->setMaster(testMaster);\r\n    testBus->setInterfaceMode(General::INITIATOR);\r\n\r\n    QSharedPointer<QList<QSharedPointer<Mode> > > componentModes(new QList<QSharedPointer<Mode> >());\r\n    QSharedPointer<Mode> testMode(new Mode(\"mode1\"));\r\n    componentModes->append(testMode);\r\n\r\n    if (modeRef.isEmpty() == false)\r\n    {\r\n        testBus->getInitiator()->setModeRefs(QStringList({ modeRef }));\r\n    }\r\n\r\n    QSharedPointer<ExpressionParser> parser(new SystemVerilogExpressionParser());\r\n    QSharedPointer<BusInterfaceValidator> validator = createBusInterfaceValidator(parser,\r\n        QSharedPointer<QList<QSharedPointer<Choice> > >(),\r\n        QSharedPointer<QList<QSharedPointer<View> > >(), QSharedPointer<QList<QSharedPointer<Port> > >(),\r\n        componentSpaces, QSharedPointer<QList<QSharedPointer<MemoryMap> > >(),\r\n        QSharedPointer<QList<QSharedPointer<BusInterface> > >(),\r\n        QSharedPointer<QList<QSharedPointer<FileSet> > >(),\r\n        QSharedPointer<QList<QSharedPointer<RemapState> > >(),\r\n        componentModes,\r\n        nullptr);\r\n\r\n    QCOMPARE(validator->hasValidInterfaceMode(testBus), isValid);\r\n\r\n    if (!isValid)\r\n    {\r\n        QVector<QString> errorsFound;\r\n        validator->findErrorsIn(errorsFound, testBus, \"test\", Document::Revision::Std22);\r\n\r\n        if (errorIsNotFoundInErrorList(expectedError, errorsFound))\r\n        {\r\n            QFAIL(\"Error was not found\");\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_BusInterfaceValidator::testHasValidInitiatorInterface2022_data()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_BusInterfaceValidator::testHasValidInitiatorInterface2022_data()\r\n{\r\n    QTest::addColumn<QString>(\"addressSpaceRef\");\r\n    QTest::addColumn<QString>(\"baseAddress\");\r\n    QTest::addColumn<QString>(\"modeRef\");\r\n    QTest::addColumn<bool>(\"createSpace\");\r\n    QTest::addColumn<bool>(\"isValid\");\r\n    QTest::addColumn<QString>(\"expectedError\");\r\n\r\n    QTest::newRow(\"Initiator referencing address space is valid\") << \"space\" << \"\" << \"\" << true << true <<\r\n        \"\";\r\n    QTest::newRow(\"Initiator referencing non-existing space is not valid\") << \"none\" << \"\" << \"\" << false << false\r\n        << \"Could not find address space none referenced by the initiator bus interface testBus\";\r\n    QTest::newRow(\"Initiator not referencing an address space with base address is not valid\") << \"\" << \"1\" << \"\" \r\n        << false << false << \"Invalid address space reference set for initiator bus interface testBus\";\r\n\r\n    QTest::newRow(\"Initiator not containing space reference is valid\") << \"\" << \"\" << \"\" << true << true << \"\";\r\n    QTest::newRow(\"Initiator containing base address is valid\") << \"space\" << \"4+4\" << \"\" <<  true << true << \"\";\r\n    QTest::newRow(\"Initiator containing negative base address is valid\") << \"space\" << \"-2\" << \"\" << true << true  << \"\";\r\n\r\n    QTest::newRow(\"Initiator containing long base address is valid\") << \"space\" << \"4000000000\" << \"\" << true << true \r\n        << \"\";\r\n\r\n    QTest::newRow(\"Reference to non-existing mode is not valid\") << \"space\" << \"0\" << \"no-mode\" << true << false \r\n        << \"Could not find mode no-mode referenced by the initiator bus interface testBus\";\r\n    QTest::newRow(\"Reference to existing mode is valid\") << \"space\" << \"0\" << \"mode1\" << true << true\r\n        << \"\";\r\n    QTest::newRow(\"Reference to mode without address space is not valid\") << \"\" << \"\" << \"mode1\" << false << false\r\n        << \"Invalid address space reference set for initiator bus interface testBus\";\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_BusInterfaceValidator::testHasValidTargetInterface2022()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_BusInterfaceValidator::testHasValidTargetInterface2022()\r\n{\r\n    QFETCH(QString, memoryMapRef);\r\n    QFETCH(QString, bridgeMasterRef);\r\n    QFETCH(QString, fileSetRef);\r\n    QFETCH(QString, modeRef);\r\n    QFETCH(bool, createMemoryMap);\r\n    QFETCH(bool, createMaster);\r\n    QFETCH(bool, createFileSet);\r\n    QFETCH(bool, isValid);\r\n    QFETCH(QString, expectedError);\r\n\r\n    QSharedPointer<TargetInterface> testTarget(new TargetInterface());\r\n    testTarget->setMemoryMapRef(memoryMapRef);\r\n\r\n    QSharedPointer<QList<QSharedPointer<MemoryMap> > > memoryMaps(new QList<QSharedPointer<MemoryMap> >());\r\n    if (createMemoryMap)\r\n    {\r\n        QSharedPointer<MemoryMap> testMap(new MemoryMap(memoryMapRef));\r\n        if (memoryMapRef.isEmpty())\r\n        {\r\n            testMap->setName(QLatin1String(\"Champloo\"));\r\n        }\r\n        memoryMaps->append(testMap);\r\n    }\r\n\r\n    if (!bridgeMasterRef.isEmpty())\r\n    {\r\n        QSharedPointer<TransparentBridge> testBridge(new TransparentBridge());\r\n        testBridge->setMasterRef(bridgeMasterRef);\r\n\r\n        testTarget->getBridges()->append(testBridge);\r\n    }\r\n\r\n    QSharedPointer<QList<QSharedPointer<BusInterface> > > busInterfaces(new QList<QSharedPointer<BusInterface> >());\r\n    if (createMaster)\r\n    {\r\n        QSharedPointer<BusInterface> masterBus(new BusInterface());\r\n        masterBus->setName(bridgeMasterRef);\r\n        masterBus->setInterfaceMode(General::MASTER);\r\n        if (bridgeMasterRef.isEmpty())\r\n        {\r\n            masterBus->setName(\"Samurai\");\r\n        }\r\n        busInterfaces->append(masterBus);\r\n    }\r\n\r\n    if (!fileSetRef.isEmpty())\r\n    {\r\n        QSharedPointer<TargetInterface::FileSetRefGroup> testGroup(new TargetInterface::FileSetRefGroup());\r\n        testGroup->group_ = fileSetRef + \" group\";\r\n\r\n        QSharedPointer<FileSetRef> ref = QSharedPointer<FileSetRef>(new FileSetRef());\r\n        ref->setReference(fileSetRef);\r\n\r\n        testGroup->fileSetRefs_->append(ref);\r\n        testTarget->getFileSetRefGroup()->append(testGroup);\r\n    }\r\n\r\n    QSharedPointer<QList<QSharedPointer<FileSet> > > fileSets(new QList<QSharedPointer<FileSet> >());\r\n    if (createFileSet)\r\n    {\r\n        QSharedPointer<FileSet> testSet(new FileSet(fileSetRef));\r\n        if (fileSetRef.isEmpty())\r\n        {\r\n            testSet->setName(\"fileSetReplacement\");\r\n        }\r\n        fileSets->append(testSet);\r\n    }\r\n\r\n    if (modeRef.isEmpty() == false)\r\n    {\r\n        testTarget->setModeRefs(QStringList({ modeRef }));\r\n    }\r\n\r\n    QSharedPointer<BusInterface> testBus(new BusInterface());\r\n    testBus->setName(\"testBus\");\r\n    testBus->setTarget(testTarget);\r\n    busInterfaces->append(testBus);\r\n\r\n    QSharedPointer<QList<QSharedPointer<Mode> > > componentModes(new QList<QSharedPointer<Mode> >());\r\n    QSharedPointer<Mode> testMode(new Mode(\"mode1\"));\r\n    componentModes->append(testMode);\r\n\r\n    QSharedPointer<ExpressionParser> parser(new SystemVerilogExpressionParser());\r\n    QSharedPointer<BusInterfaceValidator> validator = createBusInterfaceValidator(parser,\r\n        QSharedPointer<QList<QSharedPointer<Choice> > >(),\r\n        QSharedPointer<QList<QSharedPointer<View> > >(), QSharedPointer<QList<QSharedPointer<Port> > >(),\r\n        QSharedPointer<QList<QSharedPointer<AddressSpace> > >(), memoryMaps, busInterfaces, fileSets,\r\n        QSharedPointer<QList<QSharedPointer<RemapState> > >(),\r\n        componentModes,\r\n        nullptr);\r\n\r\n    QCOMPARE(validator->hasValidInterfaceMode(testBus), isValid);\r\n\r\n    if (!isValid)\r\n    {\r\n        QVector<QString> errorsFound;\r\n        validator->findErrorsIn(errorsFound, testBus, \"test\", Document::Revision::Std22);\r\n\r\n        if (errorIsNotFoundInErrorList(expectedError, errorsFound))\r\n        {\r\n            QFAIL(\"Error was not found\");\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_BusInterfaceValidator::testHasValidTargetInterface2022_data()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_BusInterfaceValidator::testHasValidTargetInterface2022_data()\r\n{\r\n    QTest::addColumn<QString>(\"memoryMapRef\");\r\n    QTest::addColumn<QString>(\"bridgeMasterRef\");\r\n    QTest::addColumn<QString>(\"fileSetRef\");\r\n    QTest::addColumn<QString>(\"modeRef\");\r\n    QTest::addColumn<bool>(\"createMemoryMap\");\r\n    QTest::addColumn<bool>(\"createMaster\");\r\n    QTest::addColumn<bool>(\"createFileSet\");\r\n    QTest::addColumn<bool>(\"isValid\");\r\n    QTest::addColumn<QString>(\"expectedError\");\r\n\r\n    QTest::newRow(\"Empty target is valid\") << \"\" << \"\" << \"\" << \"\" << true << true << true << true << \"\";\r\n    QTest::newRow(\"Target referencing memory map is valid\")\r\n        << \"testMap\" << \"\" << \"\" << \"\" << true << false << false << true << \"\";\r\n    QTest::newRow(\"Target referencing non-existing memory map is not valid\")\r\n        << \"testMap\" << \"\" << \"\" << \"\" << false << false << false << false <<\r\n        \"Memory map testMap referenced by the target bus interface testBus was not found\";\r\n\r\n    QTest::newRow(\"Target bridge referencing master is valid\")\r\n        << \"\" << \"testInitiator\" << \"\" << \"\" << false << true << false << true << \"\";\r\n    QTest::newRow(\"Target bridge referencing non-existing master is not valid\")\r\n        << \"\" << \"testInitiator\" << \"\" << \"\" << false << false << false << false <<\r\n        \"Initiator bus interface testInitiator referenced by the target bus interface testBus was not found\";\r\n\r\n    QTest::newRow(\"Target with both memory map ref and bridge is not valid\")\r\n        << \"testMap\" << \"testMaster\" << \"\" << \"\" << true << true << false << false <<\r\n        \"Both a memory map reference and transparent bridges are contained within target bus interface testBus\";\r\n\r\n    QTest::newRow(\"Target with file set ref group is valid\")\r\n        << \"\" << \"\" <<  \"testFileGroup\" << \"\" << false << false << true << true << \"\";\r\n    QTest::newRow(\"Target with file set ref group referencing non-existing file set is not valid\")\r\n        << \"\" << \"\" << \"testFiles\" << \"\" << false << false << false << false <<\r\n        \"Invalid file set testFiles referenced within group testFiles group of target bus interface testBus\";\r\n\r\n    QTest::newRow(\"Target with non-existing mode reference is not valid\")\r\n        << \"\" << \"\" << \"\" << \"no-mode\" << false << false << false << false << \r\n        \"Could not find mode no-mode referenced by the target bus interface testBus\";\r\n    QTest::newRow(\"Target with existing mode reference is valid\")\r\n        << \"\" << \"\" << \"\" << \"mode1\" << false << false << false << true << \"\";\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_BusInterfaceValidator::testHasValidBitsInLau()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_BusInterfaceValidator::testHasValidBitsInLau()\r\n{\r\n    QFETCH(QString, bitsInLAU);\r\n    QFETCH(bool, isValid);\r\n\r\n    QSharedPointer<BusInterface> testBus (new BusInterface());\r\n    testBus->setName(\"testBus\");\r\n    testBus->setBitsInLau(bitsInLAU);\r\n\r\n    QSharedPointer<ExpressionParser> parser (new SystemVerilogExpressionParser());\r\n    QSharedPointer<BusInterfaceValidator> validator = createBusInterfaceValidator(parser,\r\n        QSharedPointer<QList<QSharedPointer<Choice> > > (),\r\n        QSharedPointer<QList<QSharedPointer<View> > > (),\r\n        QSharedPointer<QList<QSharedPointer<Port> > > (),\r\n        QSharedPointer<QList<QSharedPointer<AddressSpace> > > (),\r\n        QSharedPointer<QList<QSharedPointer<MemoryMap> > > (),\r\n        QSharedPointer<QList<QSharedPointer<BusInterface> > > (),\r\n        QSharedPointer<QList<QSharedPointer<FileSet> > > (),\r\n        QSharedPointer<QList<QSharedPointer<RemapState> > > (),\r\n        nullptr,\r\n        0);\r\n\r\n    QCOMPARE(validator->hasValidBitsInLAU(testBus), isValid);\r\n\r\n    if (!isValid)\r\n    {\r\n        QVector<QString> errorsFound;\r\n        validator->findErrorsIn(errorsFound, testBus, \"test\", Document::Revision::Std14);\r\n\r\n        QString expectedError = QObject::tr(\"Invalid bits in LAU set for bus interface %1 within %2\")\r\n            .arg(testBus->name()).arg(\"test\");\r\n\r\n        if (errorIsNotFoundInErrorList(expectedError, errorsFound))\r\n        {\r\n            QFAIL(\"Error was not found\");\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_BusInterfaceValidator::testHasValidBitsInLau_data()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_BusInterfaceValidator::testHasValidBitsInLau_data()\r\n{\r\n    QTest::addColumn<QString>(\"bitsInLAU\");\r\n    QTest::addColumn<bool>(\"isValid\");\r\n\r\n    QTest::newRow(\"Empty bits in LAU is valid\") << \"\" << true;\r\n    QTest::newRow(\"Bits in LAU 1 is valid\") << \"1\" << true;\r\n    QTest::newRow(\"Bits in LAU 14*12 is valid\") << \"14*12\" << true;\r\n    QTest::newRow(\"Bits in LAU -14 is invalid\") << \"-14\" << false;\r\n    QTest::newRow(\"Real number bits in LAU 0.12 is invalid\") << \"0.12\" << false;\r\n    QTest::newRow(\"Text as bits in LAU is invalid\") << \"test\" << false;\r\n    QTest::newRow(\"String as bits in LAU is invalid\") << \"\\\"test\\\"\" << false;\r\n\r\n    QTest::newRow(\"Long bits in LAU value is valid\") << \"40000000000\" << true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_BusInterfaceValidator::testHasValidBitSteering()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_BusInterfaceValidator::testHasValidBitSteering()\r\n{\r\n    QFETCH(General::InterfaceMode, interfaceMode);\r\n    QFETCH(QString, bitSteering);\r\n    QFETCH(Document::Revision, docRevision);\r\n    QFETCH(bool, isValid);\r\n\r\n    QSharedPointer<BusInterface> testBus(new BusInterface());\r\n    testBus->setName(\"testBus\");\r\n    testBus->setInterfaceMode(interfaceMode);\r\n    testBus->setBitSteering(bitSteering);\r\n\r\n    QSharedPointer<ExpressionParser> parser(new SystemVerilogExpressionParser());\r\n    QSharedPointer<BusInterfaceValidator> validator = createBusInterfaceValidator(parser,\r\n        QSharedPointer<QList<QSharedPointer<Choice> > >(),\r\n        QSharedPointer<QList<QSharedPointer<View> > >(),\r\n        QSharedPointer<QList<QSharedPointer<Port> > >(),\r\n        QSharedPointer<QList<QSharedPointer<AddressSpace> > >(),\r\n        QSharedPointer<QList<QSharedPointer<MemoryMap> > >(),\r\n        QSharedPointer<QList<QSharedPointer<BusInterface> > >(),\r\n        QSharedPointer<QList<QSharedPointer<FileSet> > >(),\r\n        QSharedPointer<QList<QSharedPointer<RemapState> > >(),\r\n        nullptr,\r\n        0);\r\n\r\n    QCOMPARE(validator->hasValidBitSteering(testBus, docRevision), isValid);\r\n\r\n    if (!isValid)\r\n    {\r\n        QVector<QString> errorsFound;\r\n        validator->findErrorsIn(errorsFound, testBus, \"test\", docRevision);\r\n\r\n        QString expectedError = QObject::tr(\"Bit steering value '%1' is not valid in bus interface %2 within %3\")\r\n            .arg(bitSteering, testBus->name(), \"test\");\r\n\r\n        if (errorIsNotFoundInErrorList(expectedError, errorsFound))\r\n        {\r\n            QFAIL(\"Error was not found\");\r\n        }\r\n    }\r\n}\r\n\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_BusInterfaceValidator::testHasValidBitSteering()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_BusInterfaceValidator::testHasValidBitSteering_data()\r\n{\r\n    QTest::addColumn<General::InterfaceMode>(\"interfaceMode\");\r\n    QTest::addColumn<QString>(\"bitSteering\");\r\n    QTest::addColumn<Document::Revision>(\"docRevision\");\r\n    QTest::addColumn<bool>(\"isValid\");\r\n\r\n    QTest::newRow(\"Bit steering value on is valid for master\") << General::MASTER << \"on\" << \r\n        Document::Revision::Std14 << true;\r\n    QTest::newRow(\"Bit steering value off is valid for master\") << General::MASTER << \"off\" << \r\n        Document::Revision::Std14 << true;\r\n    QTest::newRow(\"Empty bit steering value is valid for master\") << General::MASTER << \"\" << \r\n        Document::Revision::Std14 << true;\r\n    QTest::newRow(\"One in bit steering value on is not valid for master\") << General::MASTER << \"1\" << \r\n        Document::Revision::Std14 << false;\r\n    QTest::newRow(\"Zero in bit steering value on is not valid for master\") << General::MASTER << \"0\" << \r\n        Document::Revision::Std14 << false;\r\n\r\n    QTest::newRow(\"Bit steering value on is not valid for initiator\") << General::INITIATOR << \"on\" << \r\n        Document::Revision::Std22 << false;\r\n    QTest::newRow(\"Bit steering value off is not valid for initiator\") << General::INITIATOR << \"off\" <<\r\n        Document::Revision::Std22 << false;\r\n    QTest::newRow(\"Empty bit steering value is valid for initiator\") << General::INITIATOR << \"\" <<\r\n        Document::Revision::Std22 << true;\r\n    QTest::newRow(\"One in bit steering value on is valid for initiator\") << General::INITIATOR << \"1\" <<\r\n        Document::Revision::Std22 << true;\r\n    QTest::newRow(\"Zero in bit steering value on is valid for initiator\") << General::INITIATOR << \"0\" <<\r\n        Document::Revision::Std22 << true;\r\n    QTest::newRow(\"Two in bit steering value on is not valid for initiator\") << General::INITIATOR << \"2\" <<\r\n        Document::Revision::Std22 << false;\r\n    QTest::newRow(\"Expression evaluating to one in bit steering value on is valid for initiator\") << \r\n        General::INITIATOR << \"2-1\" << Document::Revision::Std22 << true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_BusInterfaceValidator::testHasValidBitSteeringForInterfaceMode()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_BusInterfaceValidator::testHasValidBitSteeringForInterfaceMode()\r\n{\r\n    QFETCH(General::InterfaceMode, interfaceMode);\r\n    QFETCH(Document::Revision, docRevision);\r\n    QFETCH(QString, bitSteering);\r\n    QFETCH(bool, isValid);\r\n\r\n    QSharedPointer<BusInterface> testBus (new BusInterface());\r\n    testBus->setName(\"testBus\");\r\n    testBus->setInterfaceMode(interfaceMode);\r\n\r\n    testBus->setBitSteering(bitSteering);\r\n    \r\n\r\n    QSharedPointer<ExpressionParser> parser (new SystemVerilogExpressionParser());\r\n    QSharedPointer<BusInterfaceValidator> validator = createBusInterfaceValidator(parser,\r\n        QSharedPointer<QList<QSharedPointer<Choice> > > (),\r\n        QSharedPointer<QList<QSharedPointer<View> > > (),\r\n        QSharedPointer<QList<QSharedPointer<Port> > > (),\r\n        QSharedPointer<QList<QSharedPointer<AddressSpace> > > (),\r\n        QSharedPointer<QList<QSharedPointer<MemoryMap> > > (),\r\n        QSharedPointer<QList<QSharedPointer<BusInterface> > > (),\r\n        QSharedPointer<QList<QSharedPointer<FileSet> > > (),\r\n        QSharedPointer<QList<QSharedPointer<RemapState> > >(),\r\n        nullptr,\r\n        nullptr);\r\n\r\n    QCOMPARE(validator->hasValidBitSteering(testBus, docRevision), isValid);\r\n\r\n    if (!isValid)\r\n    {\r\n        QVector<QString> errorsFound;\r\n        validator->findErrorsIn(errorsFound, testBus, \"test\", Document::Revision::Std14);\r\n\r\n        QString expectedError = QObject::tr(\"Bit steering value is not allowed in %1 bus interface %2 within %3\")\r\n            .arg(General::interfaceMode2Str(interfaceMode)).arg(testBus->name()).arg(\"test\");\r\n\r\n        if (errorIsNotFoundInErrorList(expectedError, errorsFound))\r\n        {\r\n            QFAIL(\"Error was not found\");\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_BusInterfaceValidator::testHasValidBitSteeringForInterfaceMode_data()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_BusInterfaceValidator::testHasValidBitSteeringForInterfaceMode_data()\r\n{\r\n    QTest::addColumn<General::InterfaceMode>(\"interfaceMode\");\r\n    QTest::addColumn<QString>(\"bitSteering\");\r\n    QTest::addColumn<Document::Revision>(\"docRevision\");\r\n    QTest::addColumn<bool>(\"isValid\");\r\n\r\n    QTest::newRow(\"Master interface allows bit steering value\") << General::MASTER << \"on\" <<\r\n        Document::Revision::Std14 << true;\r\n    QTest::newRow(\"Master interface allows unspecified bit steering value\") << General::MASTER << \"\" <<\r\n        Document::Revision::Std14 << true;\r\n    QTest::newRow(\"Slave interface allows bit steering value\") << General::SLAVE << \"on\" <<\r\n        Document::Revision::Std14 << true;\r\n    QTest::newRow(\"Slave interface allows unspecified bit steering value\") << General::SLAVE << \"\" <<\r\n        Document::Revision::Std14 << true;\r\n    QTest::newRow(\"System interface does not allow bit steering value\") << General::SYSTEM << \"on\" <<\r\n        Document::Revision::Std14 << false;\r\n    QTest::newRow(\"System interface allows unspecified bit steering value\") << General::SYSTEM << \"\" <<\r\n        Document::Revision::Std14 << true;\r\n    QTest::newRow(\"Mirrored master interface does not allow bit steering value\") << General::MIRRORED_MASTER << \"on\"\r\n        << Document::Revision::Std14 << false;\r\n    QTest::newRow(\"Mirrored master interface allows unspecified bit steering value\") << General::MIRRORED_MASTER <<\r\n        \"\" << Document::Revision::Std14 << true;\r\n    QTest::newRow(\"Mirrored slave interface allows bit steering value\") << General::MIRRORED_SLAVE << \"on\" <<\r\n        Document::Revision::Std14 << true;\r\n    QTest::newRow(\"Mirrored slave interface allows unspecified bit steering value\") << General::MIRRORED_SLAVE << \r\n        \"\" << Document::Revision::Std14 << true;\r\n    QTest::newRow(\"Mirrored system interface does not allow bit steering value\") << General::MIRRORED_SYSTEM << \r\n        \"on\" << Document::Revision::Std14 << false;\r\n    QTest::newRow(\"Mirrored system interface allows unspecified bit steering value\") << General::MIRRORED_SYSTEM <<\r\n        \"\" << Document::Revision::Std14 << true;\r\n    QTest::newRow(\"Monitor interface allows bit steering value\") << General::MONITOR << \"on\" << \r\n        Document::Revision::Std14 << true;\r\n    QTest::newRow(\"Monitor interface allows unspecified bit steering value\") << General::MONITOR << \"\" <<\r\n        Document::Revision::Std14 << true;\r\n\r\n    QTest::newRow(\"Initiator interface allows bit steering value\") << General::INITIATOR << \"1\" <<\r\n        Document::Revision::Std22 << true;\r\n    QTest::newRow(\"Initiator interface allows unspecified bit steering value\") << General::INITIATOR << \"\" <<\r\n        Document::Revision::Std22 << true;\r\n    QTest::newRow(\"Target interface allows bit steering value\") << General::TARGET << \"1\" <<\r\n        Document::Revision::Std22 << true;\r\n    QTest::newRow(\"Target interface allows unspecified bit steering value\") << General::TARGET << \"\" <<\r\n        Document::Revision::Std22 << true;\r\n    QTest::newRow(\"Mirrored initiator interface does not allow bit steering value\") << General::MIRRORED_INITIATOR \r\n        << \"1\" << Document::Revision::Std22 << false;\r\n    QTest::newRow(\"Mirrored initiator interface allows unspecified bit steering value\") << General::MIRRORED_INITIATOR\r\n         << \"\" << Document::Revision::Std22 << true;\r\n    QTest::newRow(\"Mirrored target interface allows bit steering value\") << General::MIRRORED_TARGET << \"1\" <<\r\n        Document::Revision::Std22 << true;\r\n    QTest::newRow(\"Mirrored target interface allows unspecified bit steering value\") << General::MIRRORED_TARGET\r\n        << \"\" << Document::Revision::Std22 << true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_BusInterfaceValidator::testHasValidParameters()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_BusInterfaceValidator::testHasValidParameters()\r\n{\r\n    QSharedPointer<Parameter> testParameter (new Parameter());\r\n    testParameter->setValueId(\"Sanger\");\r\n    testParameter->setName(\"Daizengar\");\r\n    testParameter->setValue(\"\");\r\n    testParameter->setType(\"int\");\r\n\r\n    QSharedPointer<BusInterface> testBus (new BusInterface());\r\n    testBus->setName(\"testBus\");\r\n    testBus->getParameters()->append(testParameter);\r\n\r\n    QSharedPointer<ExpressionParser> parser(new SystemVerilogExpressionParser());\r\n    QSharedPointer<BusInterfaceValidator> validator = createBusInterfaceValidator(parser,\r\n        QSharedPointer<QList<QSharedPointer<Choice> > > (),\r\n        QSharedPointer<QList<QSharedPointer<View> > > (), QSharedPointer<QList<QSharedPointer<Port> > > (),\r\n        QSharedPointer<QList<QSharedPointer<AddressSpace> > > (),\r\n        QSharedPointer<QList<QSharedPointer<MemoryMap> > > (),\r\n        QSharedPointer<QList<QSharedPointer<BusInterface> > > (),\r\n        QSharedPointer<QList<QSharedPointer<FileSet> > > (),\r\n        QSharedPointer<QList<QSharedPointer<RemapState> > >(),\r\n        nullptr,\r\n        0);\r\n\r\n    QCOMPARE(validator->hasValidParameters(testBus), false);\r\n\r\n    QVector<QString> errorsFound;\r\n    validator->findErrorsIn(errorsFound, testBus, \"test\", Document::Revision::Std14);\r\n\r\n    QString expectedError = QObject::tr(\"No value specified for %1 %2 within bus interface %3\").\r\n        arg(testParameter->elementName()).arg(testParameter->name()).arg(testBus->name());\r\n\r\n    if (errorIsNotFoundInErrorList(expectedError, errorsFound))\r\n    {\r\n        QFAIL(\"Error was not found\");\r\n    }\r\n\r\n    testParameter->setValue(\"20\");\r\n    QCOMPARE(validator->hasValidParameters(testBus), true);\r\n\r\n    QSharedPointer<Parameter> otherParameter (new Parameter(*testParameter.data()));\r\n    otherParameter->setValue(\"2\");\r\n    testBus->getParameters()->append(otherParameter);\r\n\r\n    QCOMPARE(validator->hasValidParameters(testBus), false);\r\n\r\n    errorsFound.clear();\r\n    validator->findErrorsIn(errorsFound, testBus, \"test\", Document::Revision::Std14);\r\n    expectedError = QObject::tr(\"Parameter name %1 is not unique within bus interface %2.\")\r\n        .arg(otherParameter->name()).arg(testBus->name());\r\n    if (errorIsNotFoundInErrorList(expectedError, errorsFound))\r\n    {\r\n        QFAIL(\"Error was not found\");\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_BusInterfaceValidator::errorIsNotFoundInErrorList()\r\n//-----------------------------------------------------------------------------\r\nbool tst_BusInterfaceValidator::errorIsNotFoundInErrorList(QString const& expectedError,\r\n    QVector<QString> errorList)\r\n{\r\n    if (!errorList.contains(expectedError))\r\n    {\r\n        qDebug() << \"The following error:\" << Qt::endl << expectedError << Qt::endl << \"was not found in error list:\";\r\n        for (QString const& error : errorList)\r\n        {\r\n            qDebug() << error;\r\n        }\r\n        return true;\r\n    }\r\n\r\n    return false;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_BusInterfaceValidator::createBusInterfaceValidator()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<BusInterfaceValidator> tst_BusInterfaceValidator::createBusInterfaceValidator(\r\n    QSharedPointer<ExpressionParser> expressionParser,\r\n    QSharedPointer<QList<QSharedPointer<Choice> > > choices,\r\n    QSharedPointer<QList<QSharedPointer<View> > > views,\r\n    QSharedPointer<QList<QSharedPointer<Port> > > ports,\r\n    QSharedPointer<QList<QSharedPointer<AddressSpace> > > addressSpaces,\r\n    QSharedPointer<QList<QSharedPointer<MemoryMap> > > memoryMaps,\r\n    QSharedPointer<QList<QSharedPointer<BusInterface> > > busInterfaces,\r\n    QSharedPointer<QList<QSharedPointer<FileSet> > > fileSets,\r\n    QSharedPointer<QList<QSharedPointer<RemapState> > > remapStates,\r\n    QSharedPointer<QList<QSharedPointer<Mode> > > modes,\r\n    LibraryInterface* libraryHandler)\r\n{\r\n    QSharedPointer<ParameterValidator> parameterValidator(\r\n        new ParameterValidator(expressionParser, choices, Document::Revision::Std14));\r\n\r\n    QSharedPointer<PortMapValidator> newPortMapValidator (new PortMapValidator(\r\n        expressionParser, ports, libraryHandler));\r\n\r\n    QSharedPointer<BusInterfaceValidator> newValidator(new BusInterfaceValidator(expressionParser, choices, views,\r\n        ports, addressSpaces, memoryMaps, busInterfaces, fileSets, remapStates, modes,\r\n        newPortMapValidator, parameterValidator, libraryHandler));\r\n\r\n    return newValidator;\r\n}\r\n\r\nQTEST_APPLESS_MAIN(tst_BusInterfaceValidator)\r\n\r\n#include \"tst_BusInterfaceValidator.moc\"\r\n"
  },
  {
    "path": "tests/IPXACTmodels/Component/tst_BusInterfaceValidator.pri",
    "content": "# ----------------------------------------------------\r\n# This file is generated by the Qt Visual Studio Tools.\r\n# ------------------------------------------------------\r\n\r\nHEADERS += ../../MockObjects/LibraryMock.h \r\n\t\r\nSOURCES += ../../MockObjects/LibraryMock.cpp \\\r\n./tst_BusInterfaceValidator.cpp\r\n"
  },
  {
    "path": "tests/IPXACTmodels/Component/tst_BusInterfaceValidator.pro",
    "content": "#-----------------------------------------------------------------------------\r\n# File: tst_BusInterfaceValidator.pro\r\n#-----------------------------------------------------------------------------\r\n# Project: Kactus 2\r\n# Author: Mikko Teuho\r\n# Date: 01.12.2015\r\n#\r\n# Description:\r\n# Qt project file template for running unit tests for BusInterfaceValidator.\r\n#-----------------------------------------------------------------------------\r\n\r\nTEMPLATE = app\r\n\r\nTARGET = tst_BusInterfaceValidator\r\n\r\nQT += core xml gui testlib\r\nCONFIG += c++11 testcase console\r\n\r\nlinux-g++ | linux-g++-64 | linux-g++-32 {\r\n LIBS += -L../../../executable \\\r\n     -lIPXACTmodels -lKactusAPI\r\n\r\n}\r\nwin64 | win32 {\r\n LIBS += -L../../../executable \\\r\n     -lIPXACTmodelsd -lKactusAPId\r\n}\r\n\r\nINCLUDEPATH += $$DESTDIR\r\nINCLUDEPATH += ../../../\r\n\r\nDEPENDPATH += .\r\nDEPENDPATH += ../../../\r\n\r\nOBJECTS_DIR += $$DESTDIR\r\n\r\nMOC_DIR += ./generatedFiles\r\nUI_DIR += ./generatedFiles\r\nRCC_DIR += ./generatedFiles\r\ninclude(tst_BusInterfaceValidator.pri)\r\n"
  },
  {
    "path": "tests/IPXACTmodels/Component/tst_BusInterfaceWriter.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: tst_businterfaceWriter.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Janne Virtanen\r\n// Date: 22.09.2015\r\n//\r\n// Description:\r\n// Unit test for class businterfaceWriter.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include <IPXACTmodels/Component/BusInterfaceWriter.h>\r\n\r\n#include <IPXACTmodels/Component/InitiatorInterface.h>\r\n#include <IPXACTmodels/Component/MirroredTargetInterface.h>\r\n#include <IPXACTmodels/Component/TargetInterface.h>\r\n#include <IPXACTmodels/common/GenericVendorExtension.h>\r\n#include <IPXACTmodels/common/VendorExtension.h>\r\n\r\n#include <QtTest>\r\n\r\nclass tst_businterfaceWriter : public QObject\r\n{\r\n\tQ_OBJECT\r\n\r\n\tpublic:\r\n\t\ttst_businterfaceWriter();\r\n\r\nprivate slots:\r\n\r\n    void init();\r\n    void cleanup();\r\n\r\n    void testwriteBusInterfaceNameGroup();\r\n    void testWriteIsPresent();\r\n    void testWriteAttributes();\r\n    void testWriteConnectionRequired();\r\n    void testWriteBusType();\r\n    void testWriteBitsInLau();\r\n    void testWriteBitSteering();\r\n\tvoid testWriteBitSteeringExpression2022();\r\n\tvoid testWriteEndianness();\r\n    void testWriteParameters();\r\n    void testWriteVendorExtensions();\r\n    void testWriteAbstractionReference();\r\n    void testWritePortMaps();\r\n    void testWritePortMaps2022();\r\n    void testWriteMaster();\r\n    void testWriteSlave();\r\n    void testWriteSystem();\r\n    void testWriteMirroredSystem();\r\n    void testWriteMonitor();\r\n    void testWriteMirroredSlave();\r\n    void testWriteMirroredMaster();\r\n\r\n    void testWriteInitiator2022();\r\n    void testWriteTarget2022();\r\n\tvoid testWriteMirroredTarget2022();\r\n\r\nprivate:\r\n    QSharedPointer<BusInterface> testbusinterface_;\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_businterfaceWriter::tst_businterfaceWriter()\r\n//-----------------------------------------------------------------------------\r\ntst_businterfaceWriter::tst_businterfaceWriter()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_businterfaceWriter::init()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_businterfaceWriter::init()\r\n{\r\n\ttestbusinterface_ = QSharedPointer<BusInterface>(new BusInterface());\r\n\ttestbusinterface_->setName(\"testbusinterface\");\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_businterfaceWriter::cleanup()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_businterfaceWriter::cleanup()\r\n{\r\n\ttestbusinterface_.clear();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_businterfaceWriter::testwriteBusInterfaceNameGroup()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_businterfaceWriter::testwriteBusInterfaceNameGroup()\r\n{\r\n\tQString output;\r\n\tQXmlStreamWriter xmlStreamWriter(&output);\r\n\ttestbusinterface_->setDisplayName(\"testDisplay\");\r\n\ttestbusinterface_->setDescription(\"testDescription\");\r\n\r\n\tQString expectedOutput( \r\n\t\t\"<ipxact:busInterface>\"\r\n\t\t    \"<ipxact:name>testbusinterface</ipxact:name>\"\r\n\t\t    \"<ipxact:displayName>testDisplay</ipxact:displayName>\"\r\n\t\t    \"<ipxact:description>testDescription</ipxact:description>\"\r\n\t\t    \"<ipxact:busType vendor=\\\"\\\" library=\\\"\\\" name=\\\"\\\" version=\\\"\\\"/>\"\r\n\t\t\"</ipxact:busInterface>\");\r\n\r\n\tBusInterfaceWriter::writeBusInterface(xmlStreamWriter, testbusinterface_, Document::Revision::Std14);\r\n\tQCOMPARE(output, expectedOutput);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_businterfaceWriter::testWriteIsPresent()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_businterfaceWriter::testWriteIsPresent()\r\n{\r\n\tQString output;\r\n\tQXmlStreamWriter xmlStreamWriter(&output);\r\n\r\n\ttestbusinterface_->setIsPresent(\"4-3\");\r\n\r\n\tQString expectedOutput(\r\n\t\t\"<ipxact:busInterface>\"\r\n\t\t    \"<ipxact:name>testbusinterface</ipxact:name>\"\r\n\t\t    \"<ipxact:isPresent>4-3</ipxact:isPresent>\"\r\n\t\t    \"<ipxact:busType vendor=\\\"\\\" library=\\\"\\\" name=\\\"\\\" version=\\\"\\\"/>\"\r\n\t\t\"</ipxact:busInterface>\");\r\n\r\n\tBusInterfaceWriter::writeBusInterface(xmlStreamWriter, testbusinterface_, Document::Revision::Std14);\r\n\r\n\tQCOMPARE(output, expectedOutput);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_businterfaceWriter::testWriteAttributes()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_businterfaceWriter::testWriteAttributes()\r\n{\r\n\tQString output;\r\n\tQXmlStreamWriter xmlStreamWriter(&output);\r\n\r\n\tQMap<QString,QString> attributes;\r\n\tattributes.insert(QString(\"firstAttribute\"), QString(\"testValue\"));\r\n\ttestbusinterface_->setAttributes(attributes);\r\n\r\n    QString expectedOutput(\r\n        \"<ipxact:busInterface firstAttribute=\\\"testValue\\\">\"\r\n        \"<ipxact:name>testbusinterface</ipxact:name>\"\r\n        \"<ipxact:busType vendor=\\\"\\\" library=\\\"\\\" name=\\\"\\\" version=\\\"\\\"/>\"\r\n        \"</ipxact:busInterface>\"\r\n        );\r\n\r\n\tBusInterfaceWriter::writeBusInterface(xmlStreamWriter, testbusinterface_, Document::Revision::Std14);\r\n\r\n\tQCOMPARE(output, expectedOutput);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_businterfaceWriter::testWriteBusType()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_businterfaceWriter::testWriteBusType()\r\n{\r\n\tQString output;\r\n\tQXmlStreamWriter xmlStreamWriter(&output);\r\n\r\n    testbusinterface_->setBusType(VLNV(VLNV::BUSDEFINITION,\"testVendor\", \"testLibrary\", \"testName\", \"testVersion\"));\r\n\r\n\tQString expectedOutput(\r\n\t\t\"<ipxact:busInterface>\"\r\n\t\t    \"<ipxact:name>testbusinterface</ipxact:name>\"\r\n\t\t    \"<ipxact:busType vendor=\\\"testVendor\\\" library=\\\"testLibrary\\\" name=\\\"testName\\\" version=\\\"testVersion\\\"/>\"\r\n\t\t\"</ipxact:busInterface>\"\r\n\t\t);\r\n\r\n\tBusInterfaceWriter::writeBusInterface(xmlStreamWriter, testbusinterface_, Document::Revision::Std14);\r\n\r\n\tQCOMPARE(output, expectedOutput);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_businterfaceWriter::testWriteConnectionRequired()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_businterfaceWriter::testWriteConnectionRequired()\r\n{\r\n\tQString output;\r\n\tQXmlStreamWriter xmlStreamWriter(&output);\r\n\r\n    testbusinterface_->setConnectionRequired(true);\r\n\r\n\tQString expectedOutput(\r\n\t\t\"<ipxact:busInterface>\"\r\n\t\t    \"<ipxact:name>testbusinterface</ipxact:name>\"\r\n\t\t    \"<ipxact:busType vendor=\\\"\\\" library=\\\"\\\" name=\\\"\\\" version=\\\"\\\"/>\"\r\n\t\t    \"<ipxact:connectionRequired>true</ipxact:connectionRequired>\"\r\n\t\t\"</ipxact:busInterface>\"\r\n\t\t);\r\n\r\n\tBusInterfaceWriter::writeBusInterface(xmlStreamWriter, testbusinterface_, Document::Revision::Std14);\r\n\r\n\tQCOMPARE(output, expectedOutput);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_businterfaceWriter::testWriteBitsInLau()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_businterfaceWriter::testWriteBitsInLau()\r\n{\r\n\tQString output;\r\n\tQXmlStreamWriter xmlStreamWriter(&output);\r\n\r\n    testbusinterface_->setBitsInLau(\"16\");\r\n\r\n\tQString expectedOutput(\r\n\t\t\"<ipxact:busInterface>\"\r\n\t\t    \"<ipxact:name>testbusinterface</ipxact:name>\"\r\n\t\t    \"<ipxact:busType vendor=\\\"\\\" library=\\\"\\\" name=\\\"\\\" version=\\\"\\\"/>\"\r\n\t\t    \"<ipxact:bitsInLau>16</ipxact:bitsInLau>\"\r\n\t\t\"</ipxact:busInterface>\"\r\n\t\t);\t\r\n\r\n\tBusInterfaceWriter::writeBusInterface(xmlStreamWriter, testbusinterface_, Document::Revision::Std14);\r\n\r\n\tQCOMPARE(output, expectedOutput);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_businterfaceWriter::testWriteBitSteering()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_businterfaceWriter::testWriteBitSteering()\r\n{\r\n\tQString output;\r\n\tQXmlStreamWriter xmlStreamWriter(&output);\r\n    \r\n    QMap<QString, QString> bitSteeringAttributes;\r\n    bitSteeringAttributes.insert(QString(\"testAttribute\"), QString(\"testValue\"));\r\n    testbusinterface_->setBitSteeringAttributes(bitSteeringAttributes);\r\n    testbusinterface_->setBitSteering(\"on\");\r\n\r\n\tQString expectedOutput(\r\n\t\t\"<ipxact:busInterface>\"\r\n\t\t    \"<ipxact:name>testbusinterface</ipxact:name>\"\r\n\t\t    \"<ipxact:busType vendor=\\\"\\\" library=\\\"\\\" name=\\\"\\\" version=\\\"\\\"/>\"\r\n\t\t    \"<ipxact:bitSteering testAttribute=\\\"testValue\\\">on</ipxact:bitSteering>\"\r\n\t\t\"</ipxact:busInterface>\"\r\n\t\t);\r\n\r\n\r\n\tBusInterfaceWriter::writeBusInterface(xmlStreamWriter, testbusinterface_, Document::Revision::Std14);\r\n\r\n\tQCOMPARE(output, expectedOutput);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_businterfaceWriter::testWriteBitSteeringExpression2022()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_businterfaceWriter::testWriteBitSteeringExpression2022()\r\n{\r\n    QString output;\r\n    QXmlStreamWriter xmlStreamWriter(&output);\r\n\r\n    QMap<QString, QString> bitSteeringAttributes;\r\n    bitSteeringAttributes.insert(QString(\"testAttribute\"), QString(\"testValue\"));\r\n    testbusinterface_->setBitSteeringAttributes(bitSteeringAttributes);\r\n    testbusinterface_->setBitSteering(\"1\");\r\n\r\n    QString expectedOutput(\r\n        \"<ipxact:busInterface>\"\r\n        \"<ipxact:name>testbusinterface</ipxact:name>\"\r\n        \"<ipxact:busType vendor=\\\"\\\" library=\\\"\\\" name=\\\"\\\" version=\\\"\\\"/>\"\r\n        \"<ipxact:bitSteering testAttribute=\\\"testValue\\\">1</ipxact:bitSteering>\"\r\n        \"</ipxact:busInterface>\"\r\n    );\r\n\r\n\r\n    BusInterfaceWriter::writeBusInterface(xmlStreamWriter, testbusinterface_, Document::Revision::Std22);\r\n\r\n    QCOMPARE(output, expectedOutput);\r\n}\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_businterfaceWriter::testWriteEndianness()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_businterfaceWriter::testWriteEndianness()\r\n{\r\n\tQString output;\r\n\tQXmlStreamWriter xmlStreamWriter(&output);\r\n\r\n    testbusinterface_->setEndianness(BusInterface::BIG);\r\n\r\n\tQString expectedOutput(\r\n\t\t\"<ipxact:busInterface>\"\r\n\t\t    \"<ipxact:name>testbusinterface</ipxact:name>\"\r\n\t\t    \"<ipxact:busType vendor=\\\"\\\" library=\\\"\\\" name=\\\"\\\" version=\\\"\\\"/>\"\r\n\t\t    \"<ipxact:endianness>big</ipxact:endianness>\"\r\n\t\t\"</ipxact:busInterface>\"\r\n\t\t);\t\r\n\r\n\tBusInterfaceWriter::writeBusInterface(xmlStreamWriter, testbusinterface_, Document::Revision::Std14);\r\n\r\n\tQCOMPARE(output, expectedOutput);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_businterfaceWriter::testWriteParameters()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_businterfaceWriter::testWriteParameters()\r\n{\r\n\tQString output;\r\n\tQXmlStreamWriter xmlStreamWriter(&output);\r\n\r\n    QSharedPointer<Parameter> firstParameter(new Parameter());\r\n    firstParameter->setName(\"firstParameter\");\r\n    firstParameter->setValueId(\"id1\");\r\n    firstParameter->setValue(\"5\");\r\n    firstParameter->setType(\"shortint\");\r\n    firstParameter->setAttribute(\"prompt\", \"Parm 1\");\r\n    firstParameter->setAttribute(\"resolve\", \"user\");\r\n    firstParameter->setDescription(\"First bus interface parameter.\");\r\n\r\n    QSharedPointer<Parameter> secondParameter(new Parameter());\r\n    secondParameter->setName(\"secondParameter\");\r\n    secondParameter->setValueId(\"id2\");\r\n    secondParameter->setValue(\"1\");\r\n    secondParameter->setDescription(\"Second bus interface parameter.\");\r\n\r\n    QSharedPointer<QList<QSharedPointer<Parameter> > > parameters = testbusinterface_->getParameters();\r\n    parameters->append(firstParameter);\r\n    parameters->append(secondParameter);\r\n\r\n\tQString expectedOutput(\r\n\t\t\"<ipxact:busInterface>\"\r\n\t\t    \"<ipxact:name>testbusinterface</ipxact:name>\"\r\n\t\t    \"<ipxact:busType vendor=\\\"\\\" library=\\\"\\\" name=\\\"\\\" version=\\\"\\\"/>\"\r\n\t\t    \"<ipxact:parameters>\"\r\n\t\t        \"<ipxact:parameter parameterId=\\\"id1\\\" prompt=\\\"Parm 1\\\" resolve=\\\"user\\\" type=\\\"shortint\\\">\"\r\n\t\t            \"<ipxact:name>firstParameter</ipxact:name>\"\r\n\t\t            \"<ipxact:description>First bus interface parameter.</ipxact:description>\"\r\n\t\t            \"<ipxact:value>5</ipxact:value>\"\r\n\t\t        \"</ipxact:parameter>\"\r\n\t\t        \"<ipxact:parameter parameterId=\\\"id2\\\">\"\r\n\t\t            \"<ipxact:name>secondParameter</ipxact:name>\"\r\n\t\t            \"<ipxact:description>Second bus interface parameter.</ipxact:description>\"\r\n\t\t            \"<ipxact:value>1</ipxact:value>\"\r\n\t\t        \"</ipxact:parameter>\"\r\n\t\t    \"</ipxact:parameters>\"\r\n\t\t\"</ipxact:busInterface>\"\r\n\t\t);\r\n\r\n\tBusInterfaceWriter::writeBusInterface(xmlStreamWriter, testbusinterface_, Document::Revision::Std14);\r\n\r\n\tQCOMPARE(output, expectedOutput);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_businterfaceWriter::testWriteVendorExtensions()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_businterfaceWriter::testWriteVendorExtensions()\r\n{\r\n\tQString output;\r\n\tQXmlStreamWriter xmlStreamWriter(&output);\r\n\r\n    QDomDocument document;\r\n    QDomElement extensionNode = document.createElement(\"testExtension\");\r\n    extensionNode.setAttribute(\"extensionValue\", \"true\");\r\n    extensionNode.appendChild(document.createTextNode(\"testValue\"));\r\n\r\n    QSharedPointer<GenericVendorExtension> testExtension(new GenericVendorExtension(extensionNode));\r\n\r\n    testbusinterface_->getVendorExtensions()->append(testExtension);\r\n    testbusinterface_->setDefaultPos(QPointF(1,5));\r\n\r\n\tQString expectedOutput(\r\n\t\t\"<ipxact:busInterface>\"\r\n\t\t    \"<ipxact:name>testbusinterface</ipxact:name>\"\r\n\t\t    \"<ipxact:busType vendor=\\\"\\\" library=\\\"\\\" name=\\\"\\\" version=\\\"\\\"/>\"\r\n\t\t    \"<ipxact:vendorExtensions>\"\r\n                \"<testExtension extensionValue=\\\"true\\\">testValue</testExtension>\"\r\n           \t    \"<kactus2:position x=\\\"1\\\" y=\\\"5\\\"/>\"\r\n\t\t    \"</ipxact:vendorExtensions>\"\r\n\t\t\"</ipxact:busInterface>\"\r\n\t\t);\r\n\r\n\tBusInterfaceWriter::writeBusInterface(xmlStreamWriter, testbusinterface_, Document::Revision::Std14);\r\n\r\n\tQCOMPARE(output, expectedOutput);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_businterfaceWriter::testWriteAbstractionReference()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_businterfaceWriter::testWriteAbstractionReference()\r\n{\r\n\tQString output;\r\n\tQXmlStreamWriter xmlStreamWriter(&output);\r\n\r\n    QSharedPointer<AbstractionType> abstractionType(new AbstractionType());\r\n    abstractionType->getViewReferences()->append(QStringLiteral(\"rtl_view\"));\r\n    abstractionType->setAbstractionRef(QSharedPointer<ConfigurableVLNVReference>(\r\n        new ConfigurableVLNVReference(VLNV::ABSTRACTIONDEFINITION, \"testVendor\", \"testLibrary\", \"testName\", \"1.0\")));\r\n\r\n    testbusinterface_->getAbstractionTypes()->append(abstractionType);\r\n\r\n\tQString expectedOutput(\r\n\t\t\"<ipxact:busInterface>\"\r\n\t\t    \"<ipxact:name>testbusinterface</ipxact:name>\"\r\n\t\t    \"<ipxact:busType vendor=\\\"\\\" library=\\\"\\\" name=\\\"\\\" version=\\\"\\\"/>\"\r\n\t\t    \"<ipxact:abstractionTypes>\"\r\n\t\t        \"<ipxact:abstractionType>\"\r\n\t\t            \"<ipxact:viewRef>rtl_view</ipxact:viewRef>\"\r\n\t\t            \"<ipxact:abstractionRef vendor=\\\"testVendor\\\" library=\\\"testLibrary\\\" name=\\\"testName\\\" \"\r\n                        \"version=\\\"1.0\\\"/>\"\r\n\t\t        \"</ipxact:abstractionType>\"\r\n\t\t    \"</ipxact:abstractionTypes>\"\r\n\t\t\"</ipxact:busInterface>\"\r\n\t\t);\r\n\r\n\r\n\tBusInterfaceWriter::writeBusInterface(xmlStreamWriter, testbusinterface_, Document::Revision::Std14);\r\n\r\n\tQCOMPARE(output, expectedOutput);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_businterfaceWriter::testWritePortMaps()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_businterfaceWriter::testWritePortMaps()\r\n{\r\n\tQString output;\r\n\tQXmlStreamWriter xmlStreamWriter(&output);\r\n\r\n\tQSharedPointer<AbstractionType> abstractionType(new AbstractionType());\r\n    abstractionType->setAbstractionRef(QSharedPointer<ConfigurableVLNVReference>(\r\n        new ConfigurableVLNVReference(VLNV::ABSTRACTIONDEFINITION, \"testVendor\", \"testLibrary\", \"testName\", \"1.0\")));\r\n\r\n\tQSharedPointer<PortMap::LogicalPort> logicalPort(new PortMap::LogicalPort());\r\n    logicalPort->name_ = \"CLK\";\r\n    logicalPort->range_ = QSharedPointer<Range>(new Range(\"testLeft\", \"testRight\"));\r\n\r\n\tQSharedPointer<PortMap::PhysicalPort> physicalPort(new PortMap::PhysicalPort() );\r\n\tphysicalPort->name_ = \"clk_physical\";\r\n\tphysicalPort->partSelect_ = QSharedPointer<PartSelect>(new PartSelect(\"testLeft\", \"testRight\"));\r\n\r\n\tQSharedPointer<QStringList> indices(new QStringList());\r\n\tindices->append(\"index1\");\r\n\tindices->append(\"index2\");\r\n\tphysicalPort->partSelect_->setIndices(indices);\r\n\r\n\tQSharedPointer<PortMap> portMap(new PortMap());\r\n\tportMap->setLogicalPort(logicalPort);\r\n\tportMap->setPhysicalPort(physicalPort);    \r\n\t//portMap->setLogicalTieOff(\"tieoffValue\");\r\n    abstractionType->getPortMaps()->append(portMap);\r\n\r\n    QSharedPointer<PortMap> tiedPortMap(new PortMap());\r\n    tiedPortMap->setLogicalPort(logicalPort);\r\n    tiedPortMap->setLogicalTieOff(\"tieoffValue\");\r\n    abstractionType->getPortMaps()->append(tiedPortMap);\r\n\r\n    testbusinterface_->getAbstractionTypes()->append(abstractionType);\r\n\r\n    QString expectedOutput(\r\n\t\t\"<ipxact:busInterface>\"\r\n    \t\t\"<ipxact:name>testbusinterface</ipxact:name>\"\r\n\t    \t\"<ipxact:busType vendor=\\\"\\\" library=\\\"\\\" name=\\\"\\\" version=\\\"\\\"/>\"\r\n    \t\t\"<ipxact:abstractionTypes>\"\r\n    \t    \t\"<ipxact:abstractionType>\"\r\n                    \"<ipxact:abstractionRef vendor=\\\"testVendor\\\" library=\\\"testLibrary\\\" name=\\\"testName\\\" \"\r\n                        \"version=\\\"1.0\\\"/>\"\r\n    \t    \t    \"<ipxact:portMaps>\"\r\n                \t\t\"<ipxact:portMap>\"\r\n                    \t\t\"<ipxact:logicalPort>\"\r\n                        \t\t\"<ipxact:name>CLK</ipxact:name>\"\r\n                        \t\t\"<ipxact:range>\"\r\n                            \t\t\"<ipxact:left>testLeft</ipxact:left>\"\r\n                            \t\t\"<ipxact:right>testRight</ipxact:right>\"\r\n                        \t\t\"</ipxact:range>\"\r\n                    \t\t\"</ipxact:logicalPort>\"\r\n                    \t\t\"<ipxact:physicalPort>\"\r\n                        \t\t\"<ipxact:name>clk_physical</ipxact:name>\"\r\n                        \t\t\"<ipxact:partSelect>\"\r\n                            \t\t\"<ipxact:range>\"\r\n                                \t\t\"<ipxact:left>testLeft</ipxact:left>\"\r\n                                \t\t\"<ipxact:right>testRight</ipxact:right>\"\r\n                            \t\t\"</ipxact:range>\"\r\n                            \t\t\"<ipxact:indices>\"\r\n                                \t\t\"<ipxact:index>index1</ipxact:index>\"\r\n                                \t\t\"<ipxact:index>index2</ipxact:index>\"\r\n                            \t\t\"</ipxact:indices>\"\r\n                        \t\t\"</ipxact:partSelect>\"\r\n                    \t\t\"</ipxact:physicalPort>\"\r\n                \t\t\"</ipxact:portMap>\"\r\n                        \"<ipxact:portMap>\"\r\n                            \"<ipxact:logicalPort>\"\r\n                                \"<ipxact:name>CLK</ipxact:name>\"\r\n                                \"<ipxact:range>\"\r\n                                    \"<ipxact:left>testLeft</ipxact:left>\"\r\n                                    \"<ipxact:right>testRight</ipxact:right>\"\r\n                                \"</ipxact:range>\"\r\n                            \"</ipxact:logicalPort>\"\r\n                            \"<ipxact:logicalTieOff>tieoffValue</ipxact:logicalTieOff>\"\r\n                        \"</ipxact:portMap>\"\r\n            \t\t\"</ipxact:portMaps>\"\r\n        \t\t\"</ipxact:abstractionType>\"\r\n    \t\t\"</ipxact:abstractionTypes>\"\r\n\t\t\"</ipxact:busInterface>\"\r\n\t\t);\r\n\tBusInterfaceWriter::writeBusInterface(xmlStreamWriter, testbusinterface_, Document::Revision::Std14);\r\n\r\n\tQCOMPARE(output, expectedOutput);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_businterfaceWriter::testWritePortMaps2022()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_businterfaceWriter::testWritePortMaps2022()\r\n{\r\n\tQString output;\r\n\tQXmlStreamWriter xmlStreamWriter(&output);\r\n\r\n\tQSharedPointer<AbstractionType> abstractionType(new AbstractionType());\r\n    abstractionType->setAbstractionRef(QSharedPointer<ConfigurableVLNVReference>(\r\n        new ConfigurableVLNVReference(VLNV::ABSTRACTIONDEFINITION, \"testVendor\", \"testLibrary\", \"testName\", \"1.0\")));\r\n\r\n\tQSharedPointer<PortMap::LogicalPort> logicalPort(new PortMap::LogicalPort());\r\n    logicalPort->name_ = \"CLK\";\r\n    logicalPort->range_ = QSharedPointer<Range>(new Range(\"testLeft\", \"testRight\"));\r\n\r\n\tQSharedPointer<PortMap::PhysicalPort> physicalPort(new PortMap::PhysicalPort() );\r\n\tphysicalPort->name_ = \"clk_physical\";\r\n\tphysicalPort->partSelect_ = QSharedPointer<PartSelect>(new PartSelect(\"testLeft\", \"testRight\"));\r\n\r\n\tQSharedPointer<QStringList> indices(new QStringList());\r\n\tindices->append(\"index1\");\r\n\tindices->append(\"index2\");\r\n\tphysicalPort->partSelect_->setIndices(indices);\r\n\r\n\tQSharedPointer<PortMap> portMap(new PortMap());\r\n\tportMap->setLogicalPort(logicalPort);\r\n\tportMap->setPhysicalPort(physicalPort);    \r\n\tportMap->getVendorExtensions()->append(QSharedPointer<VendorExtension>(new Kactus2Value(\"testExtension\", \"testValue\")));\r\n    abstractionType->getPortMaps()->append(portMap);\r\n\r\n    QSharedPointer<PortMap> tiedPortMap(new PortMap());\r\n    tiedPortMap->setLogicalPort(logicalPort);\r\n    tiedPortMap->setLogicalTieOff(\"tieoffValue\");\r\n    abstractionType->getPortMaps()->append(tiedPortMap);\r\n\r\n    testbusinterface_->getAbstractionTypes()->append(abstractionType);\r\n\r\n    QString expectedOutput(\r\n\t\t\"<ipxact:busInterface>\"\r\n    \t\t\"<ipxact:name>testbusinterface</ipxact:name>\"\r\n\t    \t\"<ipxact:busType vendor=\\\"\\\" library=\\\"\\\" name=\\\"\\\" version=\\\"\\\"/>\"\r\n    \t\t\"<ipxact:abstractionTypes>\"\r\n    \t    \t\"<ipxact:abstractionType>\"\r\n                    \"<ipxact:abstractionRef vendor=\\\"testVendor\\\" library=\\\"testLibrary\\\" name=\\\"testName\\\" \"\r\n                        \"version=\\\"1.0\\\"/>\"\r\n    \t    \t    \"<ipxact:portMaps>\"\r\n                \t\t\"<ipxact:portMap>\"\r\n                    \t\t\"<ipxact:logicalPort>\"\r\n                        \t\t\"<ipxact:name>CLK</ipxact:name>\"\r\n                        \t\t\"<ipxact:range>\"\r\n                            \t\t\"<ipxact:left>testLeft</ipxact:left>\"\r\n                            \t\t\"<ipxact:right>testRight</ipxact:right>\"\r\n                        \t\t\"</ipxact:range>\"\r\n                    \t\t\"</ipxact:logicalPort>\"\r\n                    \t\t\"<ipxact:physicalPort>\"\r\n                        \t\t\"<ipxact:name>clk_physical</ipxact:name>\"\r\n                        \t\t\"<ipxact:partSelect>\"\r\n                            \t\t\"<ipxact:range>\"\r\n                                \t\t\"<ipxact:left>testLeft</ipxact:left>\"\r\n                                \t\t\"<ipxact:right>testRight</ipxact:right>\"\r\n                            \t\t\"</ipxact:range>\"\r\n                            \t\t\"<ipxact:indices>\"\r\n                                \t\t\"<ipxact:index>index1</ipxact:index>\"\r\n                                \t\t\"<ipxact:index>index2</ipxact:index>\"\r\n                            \t\t\"</ipxact:indices>\"\r\n                        \t\t\"</ipxact:partSelect>\"\r\n                    \t\t\"</ipxact:physicalPort>\"\r\n\t\t\t\t\t\t\t\"<ipxact:vendorExtensions>\"\r\n\t\t\t\t\t\t\t\t\"<testExtension>testValue</testExtension>\"\r\n\t\t\t\t\t\t\t\"</ipxact:vendorExtensions>\"\r\n                \t\t\"</ipxact:portMap>\"\r\n                        \"<ipxact:portMap>\"\r\n                            \"<ipxact:logicalPort>\"\r\n                                \"<ipxact:name>CLK</ipxact:name>\"\r\n                                \"<ipxact:range>\"\r\n                                    \"<ipxact:left>testLeft</ipxact:left>\"\r\n                                    \"<ipxact:right>testRight</ipxact:right>\"\r\n                                \"</ipxact:range>\"\r\n                            \"</ipxact:logicalPort>\"\r\n                            \"<ipxact:logicalTieOff>tieoffValue</ipxact:logicalTieOff>\"\r\n                        \"</ipxact:portMap>\"\r\n            \t\t\"</ipxact:portMaps>\"\r\n        \t\t\"</ipxact:abstractionType>\"\r\n    \t\t\"</ipxact:abstractionTypes>\"\r\n\t\t\"</ipxact:busInterface>\"\r\n\t\t);\r\n\tBusInterfaceWriter::writeBusInterface(xmlStreamWriter, testbusinterface_, Document::Revision::Std22);\r\n\r\n\tQCOMPARE(output, expectedOutput);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_businterfaceReader::testWriteMaster()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_businterfaceWriter::testWriteMaster()\r\n{\r\n\tQString output;\r\n\tQXmlStreamWriter xmlStreamWriter(&output);\r\n\r\n    QSharedPointer<InitiatorInterface> masterInterface(new InitiatorInterface());\r\n    masterInterface->setAddressSpaceRef(\"apb\");\r\n\r\n    testbusinterface_->setInterfaceMode(General::MASTER);\r\n    testbusinterface_->setMaster(masterInterface);\r\n\r\n\tQString expectedOutput(\r\n\t\t\"<ipxact:busInterface>\"\r\n\t\t    \"<ipxact:name>testbusinterface</ipxact:name>\"\r\n\t\t    \"<ipxact:busType vendor=\\\"\\\" library=\\\"\\\" name=\\\"\\\" version=\\\"\\\"/>\"\r\n\t\t    \"<ipxact:master>\"\r\n\t\t        \"<ipxact:addressSpaceRef addressSpaceRef=\\\"apb\\\"/>\"\r\n\t\t    \"</ipxact:master>\"\r\n\t\t\"</ipxact:busInterface>\"\r\n\t);\r\n\r\n\tBusInterfaceWriter::writeBusInterface(xmlStreamWriter, testbusinterface_, Document::Revision::Std14);\r\n\r\n\tQCOMPARE(output, expectedOutput);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_businterfaceReader::testWriteSlave()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_businterfaceWriter::testWriteSlave()\r\n{\r\n\tQString output;\r\n\tQXmlStreamWriter xmlStreamWriter(&output);\r\n\r\n    QSharedPointer<TargetInterface> slaveInterface(new TargetInterface());\r\n    slaveInterface->setMemoryMapRef(\"ambaAHB\");\r\n\r\n    QSharedPointer<TransparentBridge> bridge(new TransparentBridge());\r\n    bridge->setMasterRef(\"masterBus\");\r\n    bridge->setIsPresent(\"1\");\r\n\r\n    slaveInterface->getBridges()->append(bridge);\r\n\r\n    QSharedPointer<TargetInterface::FileSetRefGroup> fileSetReference(new TargetInterface::FileSetRefGroup());\r\n    fileSetReference->group_ = \"group1\";\r\n\r\n\tQSharedPointer<FileSetRef> fileSetRef1(new FileSetRef());\r\n\tQSharedPointer<FileSetRef> fileSetRef2(new FileSetRef());\r\n\r\n    fileSetRef1->setReference(\"fileset1\");\r\n    fileSetRef2->setReference(\"fileset2\");\r\n\r\n    fileSetReference->fileSetRefs_->append(fileSetRef1);\r\n    fileSetReference->fileSetRefs_->append(fileSetRef2);\r\n\r\n    slaveInterface->getFileSetRefGroup()->append(fileSetReference);\r\n\r\n    testbusinterface_->setInterfaceMode(General::SLAVE);\r\n    testbusinterface_->setSlave(slaveInterface);\r\n\r\n\tQString expectedOutput(\r\n\t\t\"<ipxact:busInterface>\"\r\n\t\t    \"<ipxact:name>testbusinterface</ipxact:name>\"\r\n\t\t    \"<ipxact:busType vendor=\\\"\\\" library=\\\"\\\" name=\\\"\\\" version=\\\"\\\"/>\"\r\n\t\t    \"<ipxact:slave>\"\r\n\t\t        \"<ipxact:memoryMapRef memoryMapRef=\\\"ambaAHB\\\"/>\"\r\n\t\t        \"<ipxact:transparentBridge masterRef=\\\"masterBus\\\">\"\r\n\t\t            \"<ipxact:isPresent>1</ipxact:isPresent>\"\r\n\t\t        \"</ipxact:transparentBridge>\"\r\n\t\t        \"<ipxact:fileSetRefGroup>\"\r\n\t\t            \"<ipxact:group>group1</ipxact:group>\"\r\n\t\t            \"<ipxact:fileSetRef>\"\r\n\t\t\t\t\t\t\"<ipxact:localName>fileset1</ipxact:localName>\"\r\n\t\t\t\t\t\"</ipxact:fileSetRef>\"\r\n\t\t            \"<ipxact:fileSetRef>\"\r\n\t\t\t\t\t\t\"<ipxact:localName>fileset2</ipxact:localName>\"\r\n\t\t\t\t\t\"</ipxact:fileSetRef>\"\r\n\t\t        \"</ipxact:fileSetRefGroup>\"\r\n\t\t    \"</ipxact:slave>\"\r\n\t\t\"</ipxact:busInterface>\"\r\n\t\t);\r\n\r\n\tBusInterfaceWriter::writeBusInterface(xmlStreamWriter, testbusinterface_, Document::Revision::Std14);\r\n\r\n\tQCOMPARE(output, expectedOutput);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_businterfaceReader::testWriteSystem()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_businterfaceWriter::testWriteSystem()\r\n{\r\n\tQString output;\r\n\tQXmlStreamWriter xmlStreamWriter(&output);\r\n\r\n    testbusinterface_->setInterfaceMode(General::SYSTEM);\r\n    testbusinterface_->setSystem(\"systemGroupName\");\r\n\r\n\tQString expectedOutput(\r\n\t\t\"<ipxact:busInterface>\"\r\n\t\t    \"<ipxact:name>testbusinterface</ipxact:name>\"\r\n\t\t    \"<ipxact:busType vendor=\\\"\\\" library=\\\"\\\" name=\\\"\\\" version=\\\"\\\"/>\"\r\n\t\t    \"<ipxact:system>\"\r\n\t\t        \"<ipxact:group>systemGroupName</ipxact:group>\"\r\n\t\t    \"</ipxact:system>\"\r\n\t\t\"</ipxact:busInterface>\"\r\n\t\t);\r\n\r\n\tBusInterfaceWriter::writeBusInterface(xmlStreamWriter, testbusinterface_, Document::Revision::Std14);\r\n\r\n\tQCOMPARE(output, expectedOutput);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_businterfaceReader::testWriteMirroredSystem()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_businterfaceWriter::testWriteMirroredSystem()\r\n{\r\n\tQString output;\r\n\tQXmlStreamWriter xmlStreamWriter(&output);\r\n\r\n    testbusinterface_->setInterfaceMode(General::MIRRORED_SYSTEM);\r\n    testbusinterface_->setSystem(\"mirroredSystemName\");\r\n\r\n\tQString expectedOutput(\r\n\t\t\"<ipxact:busInterface>\"\r\n    \t\t\"<ipxact:name>testbusinterface</ipxact:name>\"\r\n\t    \t\"<ipxact:busType vendor=\\\"\\\" library=\\\"\\\" name=\\\"\\\" version=\\\"\\\"/>\"\r\n\t    \t\"<ipxact:mirroredSystem>\"\r\n\t    \t    \"<ipxact:group>mirroredSystemName</ipxact:group>\"\r\n    \t\t\"</ipxact:mirroredSystem>\"\r\n\t\t\"</ipxact:busInterface>\"\r\n\t\t);\r\n\r\n\tBusInterfaceWriter::writeBusInterface(xmlStreamWriter, testbusinterface_, Document::Revision::Std14);\r\n\r\n\tQCOMPARE(output, expectedOutput);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_businterfaceReader::testWriteMonitor()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_businterfaceWriter::testWriteMonitor()\r\n{\r\n\tQString output;\r\n\tQXmlStreamWriter xmlStreamWriter(&output);\r\n\r\n    QSharedPointer<BusInterface::MonitorInterface> monitorInterface(new BusInterface::MonitorInterface());\r\n    monitorInterface->group_ = \"monitorGroup\";\r\n    monitorInterface->interfaceMode_ = General::SYSTEM;\r\n\r\n    testbusinterface_->setInterfaceMode(General::MONITOR);\r\n    testbusinterface_->setMonitor(monitorInterface);\r\n\r\n\tQString expectedOutput(\r\n\t\t\"<ipxact:busInterface>\"\r\n\t\t    \"<ipxact:name>testbusinterface</ipxact:name>\"\r\n\t\t    \"<ipxact:busType vendor=\\\"\\\" library=\\\"\\\" name=\\\"\\\" version=\\\"\\\"/>\"\r\n\t\t    \"<ipxact:monitor interfaceMode=\\\"system\\\">\"\r\n\t\t        \"<ipxact:group>monitorGroup</ipxact:group>\"\r\n\t\t    \"</ipxact:monitor>\"\r\n\t\t\"</ipxact:busInterface>\"\r\n\t\t);\r\n\r\n\tBusInterfaceWriter::writeBusInterface(xmlStreamWriter, testbusinterface_, Document::Revision::Std14);\r\n\r\n\tQCOMPARE(output, expectedOutput);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_businterfaceReader::testWriteMirroredSlave()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_businterfaceWriter::testWriteMirroredSlave()\r\n{\r\n\tQString output;\r\n\tQXmlStreamWriter xmlStreamWriter(&output);\r\n\r\n    QSharedPointer<MirroredTargetInterface> mirroredSlave(new MirroredTargetInterface());\r\n    mirroredSlave->setRange(\"0x00010000\");\r\n\r\n    QSharedPointer<MirroredTargetInterface::RemapAddress> firstRemapAddress(\r\n        new MirroredTargetInterface::RemapAddress(\"'h0000\"));\r\n    firstRemapAddress->state_ = \"decayed\";\r\n    firstRemapAddress->remapAttributes_.insert(QString(\"attribute1\"), QString(\"testValue\"));\r\n\r\n    QSharedPointer<MirroredTargetInterface::RemapAddress> seconRemapAddress(\r\n        new MirroredTargetInterface::RemapAddress(\"'hFFFF\"));\r\n    seconRemapAddress->state_ = \"uptodate\";\r\n\r\n    mirroredSlave->getRemapAddresses()->append(firstRemapAddress);\r\n    mirroredSlave->getRemapAddresses()->append(seconRemapAddress);\r\n\r\n    testbusinterface_->setMirroredSlave( mirroredSlave );\r\n\r\n\tQString expectedOutput(\r\n\t\t\"<ipxact:busInterface>\"\r\n\t\t    \"<ipxact:name>testbusinterface</ipxact:name>\"\r\n\t\t    \"<ipxact:busType vendor=\\\"\\\" library=\\\"\\\" name=\\\"\\\" version=\\\"\\\"/>\"\r\n\t\t    \"<ipxact:mirroredSlave>\"\r\n\t\t        \"<ipxact:baseAddresses>\"\r\n\t\t            \"<ipxact:remapAddress state=\\\"decayed\\\" attribute1=\\\"testValue\\\">'h0000</ipxact:remapAddress>\"\r\n\t\t            \"<ipxact:remapAddress state=\\\"uptodate\\\">'hFFFF</ipxact:remapAddress>\"\r\n\t\t            \"<ipxact:range>0x00010000</ipxact:range>\"\r\n\t\t        \"</ipxact:baseAddresses>\"\r\n\t\t    \"</ipxact:mirroredSlave>\"\r\n\t\t\"</ipxact:busInterface>\"\r\n\t\t);\r\n\r\n\r\n\tBusInterfaceWriter::writeBusInterface(xmlStreamWriter, testbusinterface_, Document::Revision::Std14);\r\n\r\n\tQCOMPARE(output, expectedOutput);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_businterfaceReader::testWriteMirroredMaster()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_businterfaceWriter::testWriteMirroredMaster()\r\n{\r\n\tQString output;\r\n\tQXmlStreamWriter xmlStreamWriter(&output);\r\n\r\n    testbusinterface_->setInterfaceMode(General::MIRRORED_MASTER);\r\n\r\n    QString expectedOutput(\r\n        \"<ipxact:busInterface>\"\r\n            \"<ipxact:name>testbusinterface</ipxact:name>\"\r\n            \"<ipxact:busType vendor=\\\"\\\" library=\\\"\\\" name=\\\"\\\" version=\\\"\\\"/>\"\r\n            \"<ipxact:mirroredMaster/>\"\r\n        \"</ipxact:busInterface>\"\r\n        );\r\n\r\n\tBusInterfaceWriter::writeBusInterface(xmlStreamWriter, testbusinterface_, Document::Revision::Std14);\r\n\r\n\tQCOMPARE(output, expectedOutput);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_businterfaceWriter::testWriteInitiator2022()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_businterfaceWriter::testWriteInitiator2022()\r\n{\r\n\tQString output;\r\n\tQXmlStreamWriter xmlStreamWriter(&output);\r\n\r\n    QSharedPointer<InitiatorInterface> initiatorInterface(new InitiatorInterface());\r\n\tinitiatorInterface->setAddressSpaceRef(\"apb\");\r\n\r\n    testbusinterface_->setInitiator(initiatorInterface);\r\n\r\n\tQString expectedOutput(\r\n\t\t\"<ipxact:busInterface>\"\r\n\t\t    \"<ipxact:name>testbusinterface</ipxact:name>\"\r\n\t\t    \"<ipxact:busType vendor=\\\"\\\" library=\\\"\\\" name=\\\"\\\" version=\\\"\\\"/>\"\r\n\t\t    \"<ipxact:initiator>\"\r\n\t\t        \"<ipxact:addressSpaceRef addressSpaceRef=\\\"apb\\\"/>\"\r\n\t\t    \"</ipxact:initiator>\"\r\n\t\t\"</ipxact:busInterface>\"\r\n\t);\r\n\r\n\tBusInterfaceWriter::writeBusInterface(xmlStreamWriter, testbusinterface_, Document::Revision::Std22);\r\n\r\n\tQCOMPARE(output, expectedOutput);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_businterfaceWriter::testWriteTarget2022()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_businterfaceWriter::testWriteTarget2022()\r\n{\r\n\tQString output;\r\n\tQXmlStreamWriter xmlStreamWriter(&output);\r\n\r\n    QSharedPointer<TargetInterface> targetInterface(new TargetInterface());\r\n\ttargetInterface->setMemoryMapRef(\"ambaAHB\");\r\n\ttargetInterface->setModeRefs(QStringList({ \"mode1\", \"mode2\" }));\r\n\r\n    QSharedPointer<TransparentBridge> bridge(new TransparentBridge());\r\n    bridge->setInitiatorRef(\"initiatorBus\");\r\n\tbridge->getVendorExtensions()->append(\r\n\t\tQSharedPointer<VendorExtension>(new Kactus2Value(\"testExtension\", \"testValue\")));\r\n\ttargetInterface->getBridges()->append(bridge);\r\n\r\n    QSharedPointer<TargetInterface::FileSetRefGroup> fileSetReference(new TargetInterface::FileSetRefGroup());\r\n    fileSetReference->group_ = \"group1\";\r\n\r\n    QSharedPointer<FileSetRef> fileSetRef1(new FileSetRef());\r\n    QSharedPointer<FileSetRef> fileSetRef2(new FileSetRef());\r\n\r\n    fileSetRef1->setReference(\"fileset1\");\r\n    fileSetRef2->setReference(\"fileset2\");\r\n\r\n    fileSetReference->fileSetRefs_->append(fileSetRef1);\r\n    fileSetReference->fileSetRefs_->append(fileSetRef2);\r\n\r\n\ttargetInterface->getFileSetRefGroup()->append(fileSetReference);\r\n\r\n    testbusinterface_->setTarget(targetInterface);\r\n\r\n\tQString expectedOutput(\r\n\t\t\"<ipxact:busInterface>\"\r\n\t\t    \"<ipxact:name>testbusinterface</ipxact:name>\"\r\n\t\t    \"<ipxact:busType vendor=\\\"\\\" library=\\\"\\\" name=\\\"\\\" version=\\\"\\\"/>\"\r\n\t\t    \"<ipxact:target>\"\r\n\t\t        \"<ipxact:memoryMapRef memoryMapRef=\\\"ambaAHB\\\">\"\r\n\t\t\t\t\t\"<ipxact:modeRef>mode1</ipxact:modeRef>\"\r\n\t\t\t\t\t\"<ipxact:modeRef>mode2</ipxact:modeRef>\"\r\n\t\t\t\t\"</ipxact:memoryMapRef>\"\r\n\t\t        \"<ipxact:transparentBridge initiatorRef=\\\"initiatorBus\\\">\"\r\n\t\t\t\t\t\"<ipxact:vendorExtensions>\"\r\n\t\t\t\t\t\t\"<testExtension>testValue</testExtension>\"\r\n\t\t\t\t\t\"</ipxact:vendorExtensions>\"\r\n\t\t        \"</ipxact:transparentBridge>\"\r\n\t\t        \"<ipxact:fileSetRefGroup>\"\r\n\t\t            \"<ipxact:group>group1</ipxact:group>\"\r\n\t\t            \"<ipxact:fileSetRef>\"\r\n\t\t\t\t\t\t\"<ipxact:localName>fileset1</ipxact:localName>\"\r\n\t\t\t\t\t\"</ipxact:fileSetRef>\"\r\n\t\t            \"<ipxact:fileSetRef>\"\r\n\t\t\t\t\t\t\"<ipxact:localName>fileset2</ipxact:localName>\"\r\n\t\t\t\t\t\"</ipxact:fileSetRef>\"\r\n\t\t        \"</ipxact:fileSetRefGroup>\"\r\n\t\t    \"</ipxact:target>\"\r\n\t\t\"</ipxact:busInterface>\"\r\n\t\t);\r\n\r\n\tBusInterfaceWriter::writeBusInterface(xmlStreamWriter, testbusinterface_, Document::Revision::Std22);\r\n\r\n\tQCOMPARE(output, expectedOutput);\r\n}\r\n\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_businterfaceReader::testWriteMirroredTarget2022()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_businterfaceWriter::testWriteMirroredTarget2022()\r\n{\r\n\tQString output;\r\n\tQXmlStreamWriter xmlStreamWriter(&output);\r\n\r\n    QSharedPointer<MirroredTargetInterface> mirroredTarget(new MirroredTargetInterface());\r\n\tmirroredTarget->setRange(\"0x00010000\");\r\n\r\n    QSharedPointer<MirroredTargetInterface::RemapAddress> firstRemapAddress(\r\n        new MirroredTargetInterface::RemapAddress(\"'h0000\"));\r\n\r\n    QSharedPointer<MirroredTargetInterface::RemapAddress> seconRemapAddress(\r\n        new MirroredTargetInterface::RemapAddress(\"'hFFFF\"));\r\n\r\n\tmirroredTarget->getRemapAddresses()->append(firstRemapAddress);\r\n\tmirroredTarget->getRemapAddresses()->append(seconRemapAddress);\r\n\r\n    testbusinterface_->setMirroredTarget(mirroredTarget);\r\n\r\n\tQString expectedOutput(\r\n\t\t\"<ipxact:busInterface>\"\r\n\t\t    \"<ipxact:name>testbusinterface</ipxact:name>\"\r\n\t\t    \"<ipxact:busType vendor=\\\"\\\" library=\\\"\\\" name=\\\"\\\" version=\\\"\\\"/>\"\r\n\t\t    \"<ipxact:mirroredTarget>\"\r\n\t\t        \"<ipxact:baseAddresses>\"\r\n\t\t\t\t\t\"<ipxact:remapAddresses>\"\r\n\t\t\t\t\t\t\"<ipxact:remapAddress>'h0000</ipxact:remapAddress>\"\r\n\t\t\t\t\t\"</ipxact:remapAddresses>\"\r\n\t\t\t\t\t\"<ipxact:remapAddresses>\"\r\n\t\t\t\t\t\t\"<ipxact:remapAddress>'hFFFF</ipxact:remapAddress>\"\r\n\t\t\t\t\t\"</ipxact:remapAddresses>\"\r\n\t\t            \"<ipxact:range>0x00010000</ipxact:range>\"\r\n\t\t        \"</ipxact:baseAddresses>\"\r\n\t\t    \"</ipxact:mirroredTarget>\"\r\n\t\t\"</ipxact:busInterface>\"\r\n\t\t);\r\n\r\n\r\n\tBusInterfaceWriter::writeBusInterface(xmlStreamWriter, testbusinterface_, Document::Revision::Std22);\r\n\r\n\tQCOMPARE(output, expectedOutput);\r\n}\r\n\r\nQTEST_APPLESS_MAIN(tst_businterfaceWriter)\r\n\r\n#include \"tst_BusInterfaceWriter.moc\"\r\n"
  },
  {
    "path": "tests/IPXACTmodels/Component/tst_BusInterfaceWriter.pri",
    "content": "# ----------------------------------------------------\r\n# This file is generated by the Qt Visual Studio Add-in.\r\n# ------------------------------------------------------\r\n\r\nSOURCES += ./tst_BusInterfaceWriter.cpp \r\n"
  },
  {
    "path": "tests/IPXACTmodels/Component/tst_BusInterfaceWriter.pro",
    "content": "#-----------------------------------------------------------------------------\r\n# File: tst_BusInterfaceWriter.pro\r\n#-----------------------------------------------------------------------------\r\n# Project: Kactus 2\r\n# Author: Janne Virtanen\r\n# Date: 22.09.2015\r\n#\r\n# Description:\r\n# Qt project file template for running unit tests for bus interface writer.\r\n#-----------------------------------------------------------------------------\r\n\r\nTEMPLATE = app\r\n\r\nTARGET = tst_BusInterfaceWriter\r\n\r\nQT += core xml testlib\r\nQT -= gui\r\n\r\nCONFIG += c++11 testcase console\r\n\r\nlinux-g++ | linux-g++-64 | linux-g++-32 {\r\n LIBS += -L../../../executable \\\r\n     -lIPXACTmodels\r\n\r\n}\r\nwin64 | win32 {\r\n LIBS += -L../../../executable \\\r\n     -lIPXACTmodelsd\r\n}\r\n\r\nINCLUDEPATH += $$DESTDIR\r\nINCLUDEPATH += ../../../\r\n\r\nDEPENDPATH += .\r\nDEPENDPATH += ../../../\r\n\r\nOBJECTS_DIR += $$DESTDIR\r\n\r\nMOC_DIR += ./generatedFiles\r\nUI_DIR += ./generatedFiles\r\nRCC_DIR += ./generatedFiles\r\ninclude(tst_BusInterfaceWriter.pri)\r\n"
  },
  {
    "path": "tests/IPXACTmodels/Component/tst_CPUReader.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: tst_CPUReader.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Janne Virtanen\r\n// Date: 15.09.2015\r\n//\r\n// Description:\r\n// Unit test for class CPUReader.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include <IPXACTmodels/Component/CPUReader.h>\r\n#include <IPXACTmodels/common/VendorExtension.h>\r\n\r\n#include <QtTest>\r\n\r\nclass tst_CPUReader : public QObject\r\n{\r\n    Q_OBJECT\r\n\r\npublic:\r\n    tst_CPUReader();\r\n\r\nprivate slots:\r\n\r\n    void testReadNamedCPU();\r\n    void testReadNamedCPU2022();\r\n\r\n    void testReadIsPresent();\r\n\tvoid testReadParameters();\r\n\r\n    void testReadAddressSpaceReference();\r\n\r\n    void testReadBlockSize2022();\r\n\r\n    void testReadRegions2022();\r\n\r\n    void testReadAUB2022();\r\n\r\n    void testReadExecutableImages2022();\r\n\r\n    void testReadMemoryMapReference2022();\r\n\r\n    void testReadVendorExtension();\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_CPUReader::tst_CPUReader()\r\n//-----------------------------------------------------------------------------\r\ntst_CPUReader::tst_CPUReader()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_CPUReader::testReadNamedCPU()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_CPUReader::testReadNamedCPU()\r\n{\r\n    QString documentContent(\r\n        \"<ipxact:cpu>\"\r\n            \"<ipxact:name>testCPU</ipxact:name>\"\r\n            \"<ipxact:displayName>cpuDisplay</ipxact:displayName>\"\r\n            \"<ipxact:description>cpuDescription</ipxact:description>\"\r\n        \"</ipxact:cpu>\"\r\n        );\r\n\r\n    QDomDocument document;\r\n    document.setContent(documentContent);\r\n\r\n    QDomNode cpuNode = document.firstChildElement(\"ipxact:cpu\");\r\n\r\n    QSharedPointer<Cpu> testCPU = CPUReader::createCPUFrom(cpuNode, Document::Revision::Std14);\r\n\r\n    QCOMPARE(testCPU->name(), QString(\"testCPU\"));\r\n    QCOMPARE(testCPU->displayName(), QString(\"cpuDisplay\"));\r\n    QCOMPARE(testCPU->description(), QString(\"cpuDescription\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_CPUReader::testReadNamedCPU2022()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_CPUReader::testReadNamedCPU2022()\r\n{\r\n    QString documentContent(\r\n        \"<ipxact:cpu>\"\r\n            \"<ipxact:name>testCPU</ipxact:name>\"\r\n            \"<ipxact:displayName>cpuDisplay</ipxact:displayName>\"\r\n            \"<ipxact:shortDescription>brief description</ipxact:shortDescription>\"\r\n            \"<ipxact:description>longer description</ipxact:description>\"\r\n        \"</ipxact:cpu>\"\r\n    );\r\n\r\n    QDomDocument document;\r\n    document.setContent(documentContent);\r\n\r\n    QDomNode cpuNode = document.firstChildElement(\"ipxact:cpu\");\r\n\r\n    QSharedPointer<Cpu> testCPU = CPUReader::createCPUFrom(cpuNode, Document::Revision::Std22);\r\n\r\n    QCOMPARE(testCPU->name(), QString(\"testCPU\"));\r\n    QCOMPARE(testCPU->displayName(), QString(\"cpuDisplay\"));\r\n    QCOMPARE(testCPU->shortDescription(), QString(\"brief description\"));\r\n    QCOMPARE(testCPU->description(), QString(\"longer description\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_CPUReader::testReadIsPresent()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_CPUReader::testReadIsPresent()\r\n{\r\n    QString documentContent(\r\n        \"<ipxact:cpu>\"\r\n            \"<ipxact:name>testCPU</ipxact:name>\"\r\n            \"<ipxact:isPresent>4-3</ipxact:isPresent>\"\r\n        \"</ipxact:cpu>\"\r\n        );\r\n\r\n\r\n    QDomDocument document;\r\n    document.setContent(documentContent);\r\n\r\n    QDomNode cpuNode = document.firstChildElement(\"ipxact:cpu\");\r\n\r\n    QSharedPointer<Cpu> testCPU = CPUReader::createCPUFrom(cpuNode, Document::Revision::Std14);\r\n\r\n    QCOMPARE(testCPU->name(), QString(\"testCPU\"));\r\n    QCOMPARE(testCPU->getIsPresent(), QString(\"4-3\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_CPUReader::testReadParameters()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_CPUReader::testReadParameters()\r\n{\r\n\tQString documentContent(\r\n\t\t\"<ipxact:cpu>\"\r\n    \t\t\"<ipxact:name>testCPU</ipxact:name>\"\r\n\t    \t\"<ipxact:isPresent>1</ipxact:isPresent>\"\r\n\t\t    \"<ipxact:parameters>\"\r\n        \t\t\"<ipxact:parameter parameterId=\\\"id1\\\" prompt=\\\"Parm 1\\\" type=\\\"shortint\\\" resolve=\\\"user\\\">\"\r\n            \t\t\"<ipxact:name>param1</ipxact:name>\"\r\n            \t\t\"<ipxact:description>First generator parameter.</ipxact:description>\"\r\n            \t\t\"<ipxact:value>5</ipxact:value>\"\r\n        \t\t\"</ipxact:parameter>\"\r\n        \t\t\"<ipxact:parameter parameterId=\\\"id2\\\" prompt=\\\"Parm 1\\\" type=\\\"shortint\\\" resolve=\\\"user\\\">\"\r\n            \t\t\"<ipxact:name>param2</ipxact:name>\"\r\n            \t\t\"<ipxact:description>First generator parameter.</ipxact:description>\"\r\n            \t\t\"<ipxact:value>1337</ipxact:value>\"\r\n        \t\t\"</ipxact:parameter>\"\r\n    \t\t\"</ipxact:parameters>\"\r\n\t\t\"</ipxact:cpu>\"\r\n\t\t);\r\n\r\n\r\n\tQDomDocument document;\r\n\tdocument.setContent(documentContent);\r\n\r\n\tQDomNode cpuNode = document.firstChildElement(\"ipxact:cpu\");\r\n\r\n\tQSharedPointer<Cpu> testCPU = CPUReader::createCPUFrom(cpuNode, Document::Revision::Std14);\r\n\r\n\tQCOMPARE(testCPU->name(), QString(\"testCPU\"));\r\n\tQCOMPARE(testCPU->getIsPresent(), QString(\"1\"));\r\n\tQCOMPARE(testCPU->getParameters()->size(), 2);\r\n\tQCOMPARE(testCPU->getParameters()->first()->name(), QString(\"param1\"));\r\n\tQCOMPARE(testCPU->getParameters()->first()->getValueId(), QString(\"id1\"));\r\n\tQCOMPARE(testCPU->getParameters()->first()->getValue(), QString(\"5\"));\r\n\tQCOMPARE(testCPU->getParameters()->last()->name(), QString(\"param2\"));\r\n\tQCOMPARE(testCPU->getParameters()->last()->getValueId(), QString(\"id2\"));\r\n\tQCOMPARE(testCPU->getParameters()->last()->getValue(), QString(\"1337\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_CPUReader::testReadAddressSpaceReference()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_CPUReader::testReadAddressSpaceReference()\r\n{\r\n    QString documentContent(\r\n        \"<ipxact:cpu>\"\r\n            \"<ipxact:name>CPU</ipxact:name>\"\r\n            \"<ipxact:addressSpaceRef addressSpaceRef=\\\"default_interconnect\\\">\"\r\n                \"<ipxact:isPresent>Balduran</ipxact:isPresent>\"\r\n            \"</ipxact:addressSpaceRef>\"\r\n        \"</ipxact:cpu>\"\r\n        );\r\n\r\n    QDomDocument document;\r\n    document.setContent(documentContent);\r\n\r\n    QDomNode cpuNode = document.firstChildElement(\"ipxact:cpu\");\r\n\r\n    QSharedPointer<Cpu> testCPU = CPUReader::createCPUFrom(cpuNode, Document::Revision::Std14);\r\n\r\n    QCOMPARE(testCPU->getAddressSpaceReferences()->size(), 1);\r\n    QCOMPARE(testCPU->getAddressSpaceReferences()->first()->getAddressSpaceRef(), QString(\"default_interconnect\"));\r\n    QCOMPARE(testCPU->getAddressSpaceReferences()->first()->getIsPresent(), QString(\"Balduran\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_CPUReader::testReadBlockSize2022()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_CPUReader::testReadBlockSize2022()\r\n{\r\n    QString documentContent(\r\n        \"<ipxact:cpu>\"\r\n            \"<ipxact:name>testCPU</ipxact:name>\"\r\n            \"<ipxact:range>16</ipxact:range>\"\r\n            \"<ipxact:width>32</ipxact:width>\"\r\n        \"</ipxact:cpu>\"\r\n    );\r\n\r\n    QDomDocument document;\r\n    document.setContent(documentContent);\r\n\r\n    QDomNode cpuNode = document.firstChildElement(\"ipxact:cpu\");\r\n\r\n    QSharedPointer<Cpu> testCPU = CPUReader::createCPUFrom(cpuNode, Document::Revision::Std22);\r\n\r\n    QCOMPARE(testCPU->getRange(), QString(\"16\"));\r\n    QCOMPARE(testCPU->getWidth(), QString(\"32\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_CPUReader::testReadRegions2022()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_CPUReader::testReadRegions2022()\r\n{\r\n    QString documentContent(\r\n        \"<ipxact:cpu>\"\r\n            \"<ipxact:name>testCPU</ipxact:name>\"\r\n            \"<ipxact:regions>\"\r\n                \"<ipxact:region>\"\r\n                    \"<ipxact:name>firstRegion</ipxact:name>\"\r\n                    \"<ipxact:displayName>r1</ipxact:displayName>\"\r\n                    \"<ipxact:shortDescription>brief</ipxact:shortDescription>\"\r\n                    \"<ipxact:description>region description text</ipxact:description>\"\r\n                    \"<ipxact:addressOffset>0</ipxact:addressOffset>\"\r\n                    \"<ipxact:range>8</ipxact:range>\"\r\n                    \"<ipxact:vendorExtensions>\"\r\n                        \"<testExtension>testValue</testExtension>\"\r\n\t\t            \"</ipxact:vendorExtensions>\"\r\n                \"</ipxact:region>\"\r\n                \"<ipxact:region>\"\r\n                    \"<ipxact:name>secondRegion</ipxact:name>\"\r\n                    \"<ipxact:displayName>r2</ipxact:displayName>\"\r\n                    \"<ipxact:addressOffset>8</ipxact:addressOffset>\"\r\n                    \"<ipxact:range>16</ipxact:range>\"\r\n                \"</ipxact:region>\"\r\n            \"</ipxact:regions>\"\r\n        \"</ipxact:cpu>\"\r\n    );\r\n\r\n    QDomDocument document;\r\n    document.setContent(documentContent);\r\n\r\n    QDomNode cpuNode = document.firstChildElement(\"ipxact:cpu\");\r\n\r\n    QSharedPointer<Cpu> testCPU = CPUReader::createCPUFrom(cpuNode, Document::Revision::Std22);\r\n\r\n    QCOMPARE(testCPU->getRegions()->count(), 2);\r\n\r\n    QSharedPointer<Region> firstRegion = testCPU->getRegions()->first();\r\n    QCOMPARE(firstRegion->name(), QString(\"firstRegion\"));\r\n    QCOMPARE(firstRegion->displayName(), QString(\"r1\"));\r\n    QCOMPARE(firstRegion->shortDescription(), QString(\"brief\"));\r\n    QCOMPARE(firstRegion->description(), QString(\"region description text\"));\r\n    QCOMPARE(firstRegion->getAddressOffset(), QString(\"0\"));\r\n    QCOMPARE(firstRegion->getRange(), QString(\"8\"));\r\n    QCOMPARE(firstRegion->getVendorExtensions()->count(), 1);\r\n\r\n    QSharedPointer<Region> secondRegion = testCPU->getRegions()->last();\r\n    QCOMPARE(secondRegion->name(), QString(\"secondRegion\"));\r\n    QCOMPARE(secondRegion->displayName(), QString(\"r2\"));\r\n    QCOMPARE(secondRegion->shortDescription(), QString());\r\n    QCOMPARE(secondRegion->description(), QString());\r\n    QCOMPARE(secondRegion->getAddressOffset(), QString(\"8\"));\r\n    QCOMPARE(secondRegion->getRange(), QString(\"16\"));\r\n    QCOMPARE(secondRegion->getVendorExtensions()->count(), 0);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_CPUReader::testReadAUB2022()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_CPUReader::testReadAUB2022()\r\n{\r\n    QString documentContent(\r\n        \"<ipxact:cpu>\"\r\n            \"<ipxact:name>CPU</ipxact:name>\"\r\n            \"<ipxact:addressUnitBits>32</ipxact:addressUnitBits>\"\r\n        \"</ipxact:cpu>\"\r\n    );\r\n\r\n    QDomDocument document;\r\n    document.setContent(documentContent);\r\n\r\n    QDomNode cpuNode = document.firstChildElement(\"ipxact:cpu\");\r\n\r\n    QSharedPointer<Cpu> testCPU = CPUReader::createCPUFrom(cpuNode, Document::Revision::Std22);\r\n    QCOMPARE(testCPU->getAddressUnitBits(), QString(\"32\"));\r\n\r\n    // No AUB = default 8 bits\r\n    QString documentContentNoAUB(\r\n        \"<ipxact:cpu>\"\r\n        \"<ipxact:name>CPU</ipxact:name>\"\r\n        \"</ipxact:cpu>\"\r\n    );\r\n\r\n    document.setContent(documentContentNoAUB);\r\n    cpuNode = document.firstChildElement(\"ipxact:cpu\");\r\n\r\n    QSharedPointer<Cpu> testCPUNoAUB = CPUReader::createCPUFrom(cpuNode, Document::Revision::Std22);\r\n    QCOMPARE(testCPUNoAUB->getAddressUnitBits(), QString(\"8\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_CPUReader::testReadExecutableImages2022()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_CPUReader::testReadExecutableImages2022()\r\n{\r\n    QString documentContent(\r\n        \"<ipxact:cpu>\"\r\n            \"<ipxact:name>CPU</ipxact:name>\"\r\n            \"<ipxact:executableImage imageId=\\\"id1\\\" imageType=\\\"binary\\\" >\"\r\n                \"<ipxact:name>image1</ipxact:name>\"\r\n                \"<ipxact:displayName>d1</ipxact:displayName>\"\r\n                \"<ipxact:shortDescription>brief</ipxact:shortDescription>\"\r\n                \"<ipxact:description>description text</ipxact:description>\"\r\n                \"<ipxact:parameters>\"\r\n                    \"<ipxact:parameter parameterId=\\\"id1\\\" resolve=\\\"user\\\">\"\r\n                        \"<ipxact:name>param1</ipxact:name>\"\r\n                        \"<ipxact:value>1</ipxact:value>\"\r\n                    \"</ipxact:parameter>\"\r\n                \"</ipxact:parameters>\"\r\n                \"<ipxact:languageTools>\"\r\n                   \"<ipxact:fileBuilder>\"\r\n                        \"<ipxact:fileType>cSource</ipxact:fileType>\"\r\n                        \"<ipxact:command>gcc</ipxact:command>\"\r\n                        \"<ipxact:flags>-O2</ipxact:flags>\"\r\n                        \"<ipxact:replaceDefaultFlags>1</ipxact:replaceDefaultFlags>\"\r\n                    \"</ipxact:fileBuilder>\"\r\n                    \"<ipxact:linker>ld</ipxact:linker>\"\r\n                    \"<ipxact:linkerFlags>-flag</ipxact:linkerFlags>\"\r\n                    \"<ipxact:linkerCommandFile>\"\r\n                        \"<ipxact:name>./link.cmd</ipxact:name>\"\r\n                        \"<ipxact:commandLineSwitch>-f</ipxact:commandLineSwitch>\"\r\n                        \"<ipxact:enable>1</ipxact:enable>\"\r\n                        \"<ipxact:generatorRef>gen1</ipxact:generatorRef>\"\r\n                        \"<ipxact:generatorRef>gen2</ipxact:generatorRef>\"\r\n                        \"<ipxact:vendorExtensions>\"\r\n                            \"<testExtension>testValue</testExtension>\"\r\n                        \"</ipxact:vendorExtensions>\"\r\n                    \"</ipxact:linkerCommandFile>\"\r\n                \"</ipxact:languageTools>\"\r\n            \"</ipxact:executableImage>\"\r\n        \"</ipxact:cpu>\"\r\n    );\r\n\r\n    QDomDocument document;\r\n    document.setContent(documentContent);\r\n\r\n    QDomNode cpuNode = document.firstChildElement(\"ipxact:cpu\");\r\n\r\n    QSharedPointer<Cpu> testCPU = CPUReader::createCPUFrom(cpuNode, Document::Revision::Std22);\r\n\r\n    QCOMPARE(testCPU->getExecutableImages()->count(), 1);\r\n    QSharedPointer<ExecutableImage> firstImage = testCPU->getExecutableImages()->first();\r\n\r\n    QCOMPARE(firstImage->name(), QString(\"image1\"));\r\n    QCOMPARE(firstImage->displayName(), QString(\"d1\"));\r\n    QCOMPARE(firstImage->shortDescription(), QString(\"brief\"));\r\n    QCOMPARE(firstImage->description(), QString(\"description text\"));\r\n    QCOMPARE(firstImage->getImageId(), QString(\"id1\"));\r\n    QCOMPARE(firstImage->getImageType(), QString(\"binary\"));\r\n\r\n    QCOMPARE(firstImage->getParameters()->count(), 1);\r\n\r\n    auto languageTools = firstImage->getLanguageTools();\r\n    QCOMPARE(languageTools->getFileBuilders()->count(), 1);\r\n    auto fileBuilder = languageTools->getFileBuilders()->first();\r\n    QCOMPARE(fileBuilder->getFileType().type_, QString(\"cSource\"));\r\n    QCOMPARE(fileBuilder->getCommand(), QString(\"gcc\"));\r\n    QCOMPARE(fileBuilder->getFlags(), QString(\"-O2\"));\r\n    QCOMPARE(fileBuilder->getReplaceDefaultFlags(), QString(\"1\"));\r\n\r\n    QCOMPARE(languageTools->getLinker(), QString(\"ld\"));\r\n    QCOMPARE(languageTools->getLinkerFlags(), QString(\"-flag\"));\r\n\r\n    auto linkerCommandFile = languageTools->getLinkerCommandFile();\r\n    QCOMPARE(linkerCommandFile->name_, QString(\"./link.cmd\"));\r\n    QCOMPARE(linkerCommandFile->commandLineSwitch_, QString(\"-f\"));\r\n    QCOMPARE(linkerCommandFile->enable_, QString(\"1\"));\r\n    QCOMPARE(linkerCommandFile->generatorRefs_.count(), 2);\r\n    QCOMPARE(linkerCommandFile->generatorRefs_.first(), QString(\"gen1\"));\r\n    QCOMPARE(linkerCommandFile->generatorRefs_.last(), QString(\"gen2\"));\r\n    QCOMPARE(linkerCommandFile->getVendorExtensions()->count(), 1);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_CPUReader::testReadMemoryMapReference2022()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_CPUReader::testReadMemoryMapReference2022()\r\n{\r\n    QString documentContent(\r\n        \"<ipxact:cpu>\"\r\n            \"<ipxact:name>CPU</ipxact:name>\"\r\n            \"<ipxact:memoryMapRef>map1</ipxact:memoryMapRef>\"\r\n        \"</ipxact:cpu>\"\r\n        );\r\n\r\n    QDomDocument document;\r\n    document.setContent(documentContent);\r\n\r\n    QDomNode cpuNode = document.firstChildElement(\"ipxact:cpu\");\r\n\r\n    QSharedPointer<Cpu> testCPU = CPUReader::createCPUFrom(cpuNode, Document::Revision::Std22);\r\n\r\n    QCOMPARE(testCPU->name(), QString(\"CPU\"));\r\n    QCOMPARE(testCPU->getMemoryMapReference(), QString(\"map1\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_CPUReader::testReadVendorExtension()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_CPUReader::testReadVendorExtension()\r\n{\r\n\tQString documentContent(\r\n\t\t\"<ipxact:cpu>\"\r\n\t\t\"<ipxact:name>CPU</ipxact:name>\"\r\n\t\t\"<ipxact:vendorExtensions>\"\r\n\t\t    \"<testExtension attr=\\\"ea\\\"/>\"\r\n\t\t\"</ipxact:vendorExtensions>\"\r\n\t\t\"</ipxact:cpu>\"\r\n\t\t);\r\n\r\n\r\n\tQDomDocument document;\r\n\tdocument.setContent(documentContent);\r\n\r\n\tQDomNode cpuNode = document.firstChildElement(\"ipxact:cpu\");\r\n\r\n\tQSharedPointer<Cpu> testCPU = CPUReader::createCPUFrom(cpuNode, Document::Revision::Std14);\r\n\r\n\tQCOMPARE(testCPU->name(), QString(\"CPU\"));\r\n\tQCOMPARE(testCPU->getVendorExtensions()->first()->type(), QString(\"testExtension\"));\r\n}\r\n\r\n\r\nQTEST_APPLESS_MAIN(tst_CPUReader)\r\n\r\n#include \"tst_CPUReader.moc\"\r\n"
  },
  {
    "path": "tests/IPXACTmodels/Component/tst_CPUReader.pri",
    "content": "# ----------------------------------------------------\r\n# This file is generated by the Qt Visual Studio Add-in.\r\n# ------------------------------------------------------\r\n\r\nSOURCES += ./tst_CPUReader.cpp \r\n"
  },
  {
    "path": "tests/IPXACTmodels/Component/tst_CPUReader.pro",
    "content": "#-----------------------------------------------------------------------------\r\n# File: tst_CPUReader.pro\r\n#-----------------------------------------------------------------------------\r\n# Project: Kactus 2\r\n# Author: Janne Virtanen\r\n# Date: 15.09.2015\r\n#\r\n# Description:\r\n# Qt project file template for running unit tests for CPU reader.\r\n#-----------------------------------------------------------------------------\r\n\r\nTEMPLATE = app\r\n\r\nTARGET = tst_CPUReader\r\n\r\nQT += core xml testlib\r\nQT -= gui\r\n\r\nCONFIG += c++11 testcase console\r\n\r\nlinux-g++ | linux-g++-64 | linux-g++-32 {\r\n LIBS += -L../../../executable \\\r\n     -lIPXACTmodels\r\n\r\n}\r\nwin64 | win32 {\r\n LIBS += -L../../../executable \\\r\n     -lIPXACTmodelsd\r\n}\r\n\r\nINCLUDEPATH += $$DESTDIR\r\nINCLUDEPATH += ../../../\r\n\r\nDEPENDPATH += .\r\nDEPENDPATH += ../../../\r\n\r\nOBJECTS_DIR += $$DESTDIR\r\n\r\nMOC_DIR += ./generatedFiles\r\nUI_DIR += ./generatedFiles\r\nRCC_DIR += ./generatedFiles\r\ninclude(tst_CPUReader.pri)\r\n"
  },
  {
    "path": "tests/IPXACTmodels/Component/tst_CPUValidator.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: tst_CPUValidator.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Janne Virtanen\r\n// Date: 18.11.2015\r\n//\r\n// Description:\r\n// Unit test for class CPUValidator.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include <IPXACTmodels/Component/AddressSpace.h>\r\n#include <IPXACTmodels/Component/Cpu.h>\r\n#include <IPXACTmodels/Component/MemoryMap.h>\r\n#include <IPXACTmodels/Component/validators/CPUValidator.h>\r\n\r\n#include <IPXACTmodels/common/Parameter.h>\r\n#include <IPXACTmodels/common/validators/ParameterValidator.h>\r\n\r\n#include <KactusAPI/include/SystemVerilogExpressionParser.h>\r\n\r\n#include <QDebug>\r\n#include <QtTest>\r\n\r\nclass tst_CPUValidator : public QObject\r\n{\r\n    Q_OBJECT\r\n\r\npublic:\r\n    tst_CPUValidator();\r\n\r\nprivate slots:\r\n\tvoid baseCase();\r\n    void testNameIsNotEmpty();\r\n\tvoid noRef();\r\n    void testIllegalAddressSpaceReference();\r\n    void testMemoryMapReference2022();\r\n    void testMemoryMapReference2022_data();\r\n\r\n    void testRange2022();\r\n    void testRange2022_data();\r\n\r\n    void testWidth2022();\r\n    void testWidth2022_data();\r\n\r\n    void testAddressUnitBits2022();\r\n    void testAddressUnitBits2022_data();\r\n\r\n    void testRegionHasValidName2022();\r\n    void testRegionHasValidName2022_data();\r\n    void testRegionsHaveUniqueNames2022();\r\n    void testRegionHasValidAddressOffset2022();\r\n    void testRegionHasValidAddressOffset2022_data();\r\n    void testRegionHasValidRange2022();\r\n    void testRegionHasValidRange2022_data();\r\n    void testRegionIsContainedWithinAddressSpace2022();\r\n    void testRegionIsContainedWithinAddressSpace2022_data();\r\n    void testOverlappingRegions2022();\r\n    void testOverlappingRegions2022_data();\r\n\r\n    void failParameter();\r\n\tvoid failPresense();\r\n\tvoid failRefPresense();\r\n\r\nprivate:\r\n    bool errorIsNotFoundInErrorList(QString const& expectedError, QVector<QString> errorList);\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_CPUValidator::tst_CPUValidator()\r\n//-----------------------------------------------------------------------------\r\ntst_CPUValidator::tst_CPUValidator()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_CPUValidator::baseCase()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_CPUValidator::baseCase()\r\n{\r\n\tQSharedPointer<ExpressionParser> parser(new SystemVerilogExpressionParser());\r\n    QSharedPointer<ParameterValidator> parameterValidator(new ParameterValidator(parser,\r\n        QSharedPointer<QList<QSharedPointer<Choice> > >(), Document::Revision::Std14));\r\n\r\n    QSharedPointer<QList<QSharedPointer<AddressSpace> > > singleSpace(new QList<QSharedPointer<AddressSpace> >());\r\n    singleSpace->append(QSharedPointer<AddressSpace>(new AddressSpace(\"testSpace\")));\r\n\r\n    QSharedPointer<QList<QSharedPointer<MemoryMap> > > noMaps;\r\n\r\n    CPUValidator validator(parameterValidator, parser, singleSpace, noMaps, Document::Revision::Std14);\r\n\t\r\n    QSharedPointer<Cpu> cpu(new Cpu());\r\n    cpu->setName(\"esa\");\r\n\tcpu->setIsPresent(\"1\");\r\n\r\n\tQSharedPointer<Parameter> parameter (new Parameter());\r\n\tparameter->setName(\"param\");\r\n\tparameter->setType(\"bit\");\r\n\tparameter->setValue(\"3'b111\");\r\n\tparameter->setValueId(\"parameterid\");\r\n\r\n\tcpu->getParameters()->append(parameter);\r\n\r\n\tQSharedPointer<Cpu::AddressSpaceRef> aref(new Cpu::AddressSpaceRef(\"testSpace\"));\r\n\taref->setIsPresent(\"0\");\r\n\tcpu->getAddressSpaceReferences()->append( aref );\r\n\r\n\tQVector<QString> errorList;\r\n\tvalidator.findErrorsIn(errorList, cpu, \"test\");\r\n\r\n\tQVERIFY(validator.validate(cpu));\r\n\tQCOMPARE(errorList.size(), 0);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_CPUValidator::testNameIsNotEmpty()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_CPUValidator::testNameIsNotEmpty()\r\n{\r\n    QSharedPointer<ExpressionParser> parser(new SystemVerilogExpressionParser());\r\n    QSharedPointer<ParameterValidator> parameterValidator(new ParameterValidator(parser,\r\n        QSharedPointer<QList<QSharedPointer<Choice> > >(), Document::Revision::Std14));\r\n    QSharedPointer<QList<QSharedPointer<AddressSpace> > > noSpaces;\r\n    QSharedPointer<QList<QSharedPointer<MemoryMap> > > noMaps;\r\n\r\n    CPUValidator validator(parameterValidator, parser, noSpaces, noMaps, Document::Revision::Std14);\r\n\r\n    QSharedPointer<Cpu> cpu( new Cpu() );\r\n    cpu->setName(\"\");\r\n\r\n    QVector<QString> errorList;\r\n    validator.findErrorsIn(errorList, cpu, \"test\");\r\n\r\n    QVERIFY(!validator.validate(cpu));\r\n    QVERIFY(errorList.size() > 0);\r\n    QCOMPARE(errorList.first(), QString(\"Invalid name '' set for CPU within test.\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_CPUValidator::noRef()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_CPUValidator::noRef()\r\n{\r\n    QSharedPointer<ExpressionParser> parser(new SystemVerilogExpressionParser());\r\n    QSharedPointer<ParameterValidator> parameterValidator(new ParameterValidator(parser,\r\n        QSharedPointer<QList<QSharedPointer<Choice> > >(), Document::Revision::Std14));\r\n    QSharedPointer<QList<QSharedPointer<AddressSpace> > > noSpaces;\r\n    QSharedPointer<QList<QSharedPointer<MemoryMap> > > noMaps;\r\n\r\n    CPUValidator validator(parameterValidator, parser, noSpaces, noMaps, Document::Revision::Std14);\r\n\r\n    QSharedPointer<Cpu> cpu( new Cpu() );\r\n    cpu->setName(\"testCpu\");\r\n\r\n\tQVector<QString> errorList;\r\n\tvalidator.findErrorsIn(errorList, cpu, \"test\");\r\n\r\n\tQVERIFY(!validator.validate(cpu));\r\n\tQVERIFY(errorList.size() > 0);\r\n    QCOMPARE(errorList.first(), QString(\"No address space reference set for CPU testCpu within test.\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_CPUValidator::testIllegalAddressSpaceReference()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_CPUValidator::testIllegalAddressSpaceReference()\r\n{\r\n    QSharedPointer<ExpressionParser> parser(new SystemVerilogExpressionParser());\r\n    QSharedPointer<ParameterValidator> parameterValidator(new ParameterValidator(parser,\r\n        QSharedPointer<QList<QSharedPointer<Choice> > >(), Document::Revision::Std14));\r\n    QSharedPointer<QList<QSharedPointer<AddressSpace> > > noSpaces;\r\n    QSharedPointer<QList<QSharedPointer<MemoryMap> > > noMaps;\r\n\r\n    CPUValidator validator(parameterValidator, parser, noSpaces, noMaps, Document::Revision::Std14);\r\n\r\n    QSharedPointer<Cpu> cpu(new Cpu());\r\n    cpu->setName(\"testCpu\");\r\n\r\n    QSharedPointer<Cpu::AddressSpaceRef> aref(new Cpu::AddressSpaceRef(\"nonExistingSpace\") );\r\n    cpu->getAddressSpaceReferences()->append(aref);\r\n\r\n    QVector<QString> errorList;\r\n    validator.findErrorsIn(errorList, cpu, \"test\");\r\n\r\n    QVERIFY(!validator.validate(cpu));\r\n    QCOMPARE(errorList.size(), 1);\r\n    QCOMPARE(errorList.first(), QString(\"Address space 'nonExistingSpace' referenced within CPU testCpu is not found.\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_CPUValidator::testMemoryMapReference()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_CPUValidator::testMemoryMapReference2022()\r\n{\r\n    QFETCH(QString, memMapRef);\r\n    QFETCH(bool, isValid);\r\n    QFETCH(QString, expectedError);\r\n\r\n    QSharedPointer<ExpressionParser> parser(new SystemVerilogExpressionParser());\r\n    QSharedPointer<ParameterValidator> parameterValidator(new ParameterValidator(parser,\r\n        QSharedPointer<QList<QSharedPointer<Choice> > >(), Document::Revision::Std22));\r\n    QSharedPointer<QList<QSharedPointer<AddressSpace> > > noSpaces;\r\n\r\n    QSharedPointer<QList<QSharedPointer<MemoryMap> > > maps(new QList<QSharedPointer<MemoryMap> >());\r\n    auto testMap = QSharedPointer<MemoryMap>(new MemoryMap(\"testMap\"));\r\n    maps->append(testMap);\r\n\r\n    CPUValidator validator(parameterValidator, parser, noSpaces, maps, Document::Revision::Std22);\r\n\r\n    QSharedPointer<Cpu> cpu(new Cpu(\"testCpu\"));\r\n    cpu->setMemoryMapReference(memMapRef);\r\n\r\n    cpu->setRange(\"1\");\r\n    cpu->setWidth(\"1\");\r\n\r\n    QVector<QString> errorList;\r\n    validator.findErrorsIn(errorList, cpu, \"test\");\r\n\r\n    QCOMPARE(validator.hasValidMemoryMapReference(cpu), isValid);\r\n\r\n    if (expectedError.isEmpty() == false)\r\n    {\r\n        QCOMPARE(errorList.size(), 1);\r\n        QCOMPARE(errorList.first(), expectedError);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_CPUValidator::testMemoryMapReference2022_data()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_CPUValidator::testMemoryMapReference2022_data()\r\n{\r\n    QTest::addColumn<QString>(\"memMapRef\");\r\n    QTest::addColumn<bool>(\"isValid\");\r\n    QTest::addColumn<QString>(\"expectedError\");\r\n\r\n    QTest::newRow(\"Empty memory map reference is invalid\") << \"\" << false << \r\n        \"No memory map reference set for CPU testCpu within test.\";\r\n\r\n    QTest::newRow(\"Non-existing memory map reference is invalid\") << \"noMap\" << false <<\r\n        \"Memory map 'noMap' referenced within CPU testCpu is not found.\";\r\n\r\n    QTest::newRow(\"Existing memory map reference is valid\") << \"testMap\" << true <<  \"\";\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_CPUValidator::testRange2022()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_CPUValidator::testRange2022()\r\n{\r\n    QFETCH(QString, range);\r\n    QFETCH(bool, isValid);\r\n    QFETCH(QString, expectedError);\r\n\r\n    QSharedPointer<ExpressionParser> parser(new SystemVerilogExpressionParser());\r\n    QSharedPointer<ParameterValidator> parameterValidator(new ParameterValidator(parser,\r\n        QSharedPointer<QList<QSharedPointer<Choice> > >(), Document::Revision::Std22));\r\n    QSharedPointer<QList<QSharedPointer<AddressSpace> > > noSpaces;\r\n\r\n    QSharedPointer<QList<QSharedPointer<MemoryMap> > > maps(new QList<QSharedPointer<MemoryMap> >());\r\n    auto testMap = QSharedPointer<MemoryMap>(new MemoryMap(\"testMap\"));\r\n    maps->append(testMap);\r\n\r\n    CPUValidator validator(parameterValidator, parser, noSpaces, maps, Document::Revision::Std22);\r\n\r\n    QSharedPointer<Cpu> cpu(new Cpu(\"testCpu\"));\r\n    cpu->setMemoryMapReference(\"testMap\");\r\n    cpu->setRange(range);\r\n    \r\n    cpu->setWidth(\"1\");\r\n\r\n    QVector<QString> errorList;\r\n    validator.findErrorsIn(errorList, cpu, \"test\");\r\n\r\n    QCOMPARE(validator.hasValidRange(cpu), isValid);\r\n\r\n    if (expectedError.isEmpty() == false)\r\n    {\r\n        QCOMPARE(errorList.size(), 1);\r\n        QCOMPARE(errorList.first(), expectedError);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_CPUValidator::testRange2022_data()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_CPUValidator::testRange2022_data()\r\n{\r\n    QTest::addColumn<QString>(\"range\");\r\n    QTest::addColumn<bool>(\"isValid\");\r\n    QTest::addColumn<QString>(\"expectedError\");\r\n\r\n    QTest::newRow(\"Empty range is invalid\") << \"\" << false <<\r\n        \"Invalid range set for CPU testCpu.\";\r\n\r\n    QTest::newRow(\"Text as range is not valid\") << \"Six\" << false <<\r\n        \"Invalid range set for CPU testCpu.\";\r\n\r\n    QTest::newRow(\"Constant integer as range is valid\") << \"8\" << true << \"\";\r\n\r\n    QTest::newRow(\"Expression as range is valid\") << \"2*4\" << true << \"\";\r\n\r\n    QTest::newRow(\"Invalid expression as range is invalid\") << \"2+^^^^\" << false <<\r\n        \"Invalid range set for CPU testCpu.\";\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_CPUValidator::testWidth2022()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_CPUValidator::testWidth2022()\r\n{\r\n    QFETCH(QString, width);\r\n    QFETCH(bool, isValid);\r\n    QFETCH(QString, expectedError);\r\n\r\n    QSharedPointer<ExpressionParser> parser(new SystemVerilogExpressionParser());\r\n    QSharedPointer<ParameterValidator> parameterValidator(new ParameterValidator(parser,\r\n        QSharedPointer<QList<QSharedPointer<Choice> > >(), Document::Revision::Std22));\r\n    QSharedPointer<QList<QSharedPointer<AddressSpace> > > noSpaces;\r\n\r\n    QSharedPointer<QList<QSharedPointer<MemoryMap> > > maps(new QList<QSharedPointer<MemoryMap> >());\r\n    auto testMap = QSharedPointer<MemoryMap>(new MemoryMap(\"testMap\"));\r\n    maps->append(testMap);\r\n\r\n    CPUValidator validator(parameterValidator, parser, noSpaces, maps, Document::Revision::Std22);\r\n\r\n    QSharedPointer<Cpu> cpu(new Cpu(\"testCpu\"));\r\n    cpu->setMemoryMapReference(\"testMap\");\r\n    cpu->setWidth(width);\r\n\r\n    cpu->setRange(\"1\");\r\n\r\n    QVector<QString> errorList;\r\n    validator.findErrorsIn(errorList, cpu, \"test\");\r\n\r\n    QCOMPARE(validator.hasValidWidth(cpu), isValid);\r\n\r\n    if (expectedError.isEmpty() == false)\r\n    {\r\n        QCOMPARE(errorList.size(), 1);\r\n        QCOMPARE(errorList.first(), expectedError);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_CPUValidator::testWidth2022_data()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_CPUValidator::testWidth2022_data()\r\n{\r\n    QTest::addColumn<QString>(\"width\");\r\n    QTest::addColumn<bool>(\"isValid\");\r\n    QTest::addColumn<QString>(\"expectedError\");\r\n\r\n    QTest::newRow(\"Empty width is invalid\") << \"\" << false <<\r\n        \"Invalid width set for CPU testCpu.\";\r\n\r\n    QTest::newRow(\"Text as width is not valid\") << \"Six\" << false <<\r\n        \"Invalid width set for CPU testCpu.\";\r\n\r\n    QTest::newRow(\"Constant integer as width is valid\") << \"8\" << true << \"\";\r\n\r\n    QTest::newRow(\"Expression as width is valid\") << \"2*4\" << true << \"\";\r\n\r\n    QTest::newRow(\"Invalid expression as width is invalid\") << \"2+^^^^\" << false <<\r\n        \"Invalid width set for CPU testCpu.\";\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_CPUValidator::testAddressUnitBits2022()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_CPUValidator::testAddressUnitBits2022()\r\n{\r\n    QFETCH(QString, aub);\r\n    QFETCH(bool, isValid);\r\n    QFETCH(QString, expectedError);\r\n\r\n    QSharedPointer<ExpressionParser> parser(new SystemVerilogExpressionParser());\r\n    QSharedPointer<ParameterValidator> parameterValidator(new ParameterValidator(parser,\r\n        QSharedPointer<QList<QSharedPointer<Choice> > >(), Document::Revision::Std22));\r\n    QSharedPointer<QList<QSharedPointer<AddressSpace> > > noSpaces;\r\n\r\n    QSharedPointer<QList<QSharedPointer<MemoryMap> > > maps(new QList<QSharedPointer<MemoryMap> >());\r\n    auto testMap = QSharedPointer<MemoryMap>(new MemoryMap(\"testMap\"));\r\n    maps->append(testMap);\r\n\r\n    CPUValidator validator(parameterValidator, parser, noSpaces, maps, Document::Revision::Std22);\r\n\r\n    QSharedPointer<Cpu> cpu(new Cpu(\"testCpu\"));\r\n    cpu->setMemoryMapReference(\"testMap\");\r\n    cpu->setAddressUnitBits(aub);\r\n\r\n    cpu->setRange(\"1\");\r\n    cpu->setWidth(\"1\");\r\n\r\n    QVector<QString> errorList;\r\n    validator.findErrorsIn(errorList, cpu, \"test\");\r\n\r\n    QCOMPARE(validator.hasValidAddressUnitBits(cpu), isValid);\r\n\r\n    if (expectedError.isEmpty() == false)\r\n    {\r\n        QCOMPARE(errorList.size(), 1);\r\n        QCOMPARE(errorList.first(), expectedError);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_CPUValidator::testAddressUnitBits2022_data()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_CPUValidator::testAddressUnitBits2022_data()\r\n{\r\n    QTest::addColumn<QString>(\"aub\");\r\n    QTest::addColumn<bool>(\"isValid\");\r\n    QTest::addColumn<QString>(\"expectedError\");\r\n\r\n    QTest::newRow(\"Empty address unit bits is valid\") << \"\" << true <<\r\n        \"\";\r\n\r\n    QTest::newRow(\"Text as address unit bits is not valid\") << \"Six\" << false <<\r\n        \"Invalid address unit bits set for CPU testCpu.\";\r\n\r\n    QTest::newRow(\"Constant integer as address unit bits is valid\") << \"8\" << true << \"\";\r\n\r\n    QTest::newRow(\"Expression as address unit bits is valid\") << \"2*4\" << true << \"\";\r\n\r\n    QTest::newRow(\"Invalid expression as address unit bits is invalid\") << \"2+^^^^\" << false <<\r\n        \"Invalid address unit bits set for CPU testCpu.\";\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_CPUValidator::testRegionHasValidName2022()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_CPUValidator::testRegionHasValidName2022()\r\n{\r\n    QFETCH(QString, name);\r\n    QFETCH(bool, isValid);\r\n\r\n    QSharedPointer<ExpressionParser> parser(new SystemVerilogExpressionParser());\r\n\r\n    RegionValidator validator(parser);\r\n\r\n    QSharedPointer<Region> testRegion(new Region(name, \"10\", \"10\"));\r\n\r\n    QCOMPARE(validator.hasValidName(testRegion->name()), isValid);\r\n\r\n    if (!isValid)\r\n    {\r\n        QVector<QString> foundErrors;\r\n        validator.findErrorsIn(foundErrors, testRegion, \"CPU testCpu\");\r\n\r\n        QString expectedError = QString(\"Invalid name specified for region %1 in CPU testCpu.\")\r\n            .arg(testRegion->name());\r\n        if (errorIsNotFoundInErrorList(expectedError, foundErrors))\r\n        {\r\n            QFAIL(\"No error message found\");\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_CPUValidator::testRegionHasValidName2022_data()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_CPUValidator::testRegionHasValidName2022_data()\r\n{\r\n    QTest::addColumn<QString>(\"name\");\r\n    QTest::addColumn<bool>(\"isValid\");\r\n\r\n    QTest::newRow(\"Empty name is invalid\") << \"\" << false;\r\n    QTest::newRow(\"Name test is valid\") << \"test\" << true;\r\n    QTest::newRow(\"Name consisting of only white spaces is invalid\") << \"    \" << false;\r\n    QTest::newRow(\"Name consisting of characters and white spaces is valid\") << \"  test  \" << true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_CPUValidator::testRegionsHaveUniqueNames2022()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_CPUValidator::testRegionsHaveUniqueNames2022()\r\n{\r\n    QSharedPointer<ExpressionParser> parser(new SystemVerilogExpressionParser());\r\n    QSharedPointer<ParameterValidator> parameterValidator(new ParameterValidator(parser,\r\n        QSharedPointer<QList<QSharedPointer<Choice> > >(), Document::Revision::Std22));\r\n    QSharedPointer<QList<QSharedPointer<AddressSpace> > > noSpaces;\r\n\r\n    QSharedPointer<QList<QSharedPointer<MemoryMap> > > noMaps;\r\n\r\n    CPUValidator validator(parameterValidator, parser, noSpaces, noMaps, Document::Revision::Std22);\r\n\r\n    QSharedPointer<Region> firstRegion(new Region(\"firstRegion\", \"0\", \"2\"));\r\n    QSharedPointer<Region> secondRegion(new Region(\"firstRegion\", \"5\", \"1\"));\r\n\r\n    QSharedPointer<Cpu> testCpu(new Cpu(\"testCpu\"));\r\n    testCpu->setRange(\"100\");\r\n    testCpu->getRegions()->append(firstRegion);\r\n    testCpu->getRegions()->append(secondRegion);\r\n\r\n    QCOMPARE(validator.hasValidRegions(testCpu), false);\r\n\r\n    QVector<QString> foundErrors;\r\n    validator.findErrorsIn(foundErrors, testCpu, \"CPU testCpu\");\r\n\r\n    QString expectedError = QString(\"Name %1 of regions in CPU testCpu is not unique.\").arg(firstRegion->name());\r\n\r\n    if (errorIsNotFoundInErrorList(expectedError, foundErrors))\r\n    {\r\n        QFAIL(\"No error message found\");\r\n    }\r\n\r\n    secondRegion->setName(\"segmentTwo\");\r\n    QCOMPARE(validator.hasValidRegions(testCpu), true);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_CPUValidator::testRegionHasValidAddressOffset2022()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_CPUValidator::testRegionHasValidAddressOffset2022()\r\n{\r\n    QFETCH(QString, addressOffset);\r\n    QFETCH(bool, isValid);\r\n\r\n    QSharedPointer<ExpressionParser> parser(new SystemVerilogExpressionParser());\r\n\r\n    RegionValidator validator(parser);\r\n\r\n    QSharedPointer<Region> testRegion(new Region(\"testRegion\", addressOffset, \"10\"));\r\n\r\n    QCOMPARE(validator.hasValidAddressOffset(testRegion), isValid);\r\n\r\n    if (!isValid)\r\n    {\r\n        QVector<QString> foundErrors;\r\n        validator.findErrorsIn(foundErrors, testRegion, \"CPU testCpu\");\r\n\r\n        QString expectedError = QString(\"Invalid address offset set for region %1 in CPU testCpu.\").arg(\r\n            testRegion->name());\r\n        if (errorIsNotFoundInErrorList(expectedError, foundErrors))\r\n        {\r\n            QFAIL(\"No error message found\");\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_CPUValidator::testRegionHasValidAddressOffset2022_data()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_CPUValidator::testRegionHasValidAddressOffset2022_data()\r\n{\r\n    QTest::addColumn<QString>(\"addressOffset\");\r\n    QTest::addColumn<bool>(\"isValid\");\r\n\r\n    QTest::newRow(\"12*2+13-5 is valid for address offset\") << \"12*2+13-5\" << true;\r\n    QTest::newRow(\"0 is valid for address offset\") << \"0\" << true;\r\n    QTest::newRow(\"14-5*3 is not valid for address offset\") << \"14-5*3\" << false;\r\n    QTest::newRow(\"Text is not valid for address offset\") << \"text\" << false;\r\n    QTest::newRow(\"String is not valid for address offset\") << \"\\\"text\\\"\" << false;\r\n    QTest::newRow(\"Empty value is not valid for address offset\") << \"\" << false;\r\n\r\n    QTest::newRow(\"Long address offset is valid for segment\") << \"40000000000\" << true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_CPUValidator::testRegionHasValidRange2022()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_CPUValidator::testRegionHasValidRange2022()\r\n{\r\n    QFETCH(QString, range);\r\n    QFETCH(bool, isValid);\r\n\r\n    QSharedPointer<ExpressionParser> parser(new SystemVerilogExpressionParser());\r\n\r\n    RegionValidator validator(parser);\r\n\r\n    QSharedPointer<Region> testRegion(new Region(\"testRegion\", \"10\", range));\r\n\r\n    QCOMPARE(validator.hasValidRange(testRegion), isValid);\r\n\r\n    if (!isValid)\r\n    {\r\n        QVector<QString> foundErrors;\r\n        validator.findErrorsIn(foundErrors, testRegion, \"CPU testCpu\");\r\n\r\n        QString expectedError = QString(\"Invalid range set for region %1 in CPU testCpu.\").arg(testRegion->name());\r\n        if (errorIsNotFoundInErrorList(expectedError, foundErrors))\r\n        {\r\n            QFAIL(\"No error message found\");\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_CPUValidator::testRegionHasValidRange2022_data()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_CPUValidator::testRegionHasValidRange2022_data()\r\n{\r\n    QTest::addColumn<QString>(\"range\");\r\n    QTest::addColumn<bool>(\"isValid\");\r\n\r\n    QTest::newRow(\"12*2+13-5 is valid for range\") << \"12*2+13-5\" << true;\r\n    QTest::newRow(\"0 is not valid for range\") << \"0\" << false;\r\n    QTest::newRow(\"14-5*3 is not valid for range\") << \"14-5*3\" << false;\r\n    QTest::newRow(\"Text is not valid for range\") << \"text\" << false;\r\n    QTest::newRow(\"String is not valid for range\") << \"\\\"text\\\"\" << false;\r\n    QTest::newRow(\"Empty value is not valid for range\") << \"\" << false;\r\n\r\n    QTest::newRow(\"Long range is valid for segment\") << \"40000000000\" << true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_CPUValidator::testRegionIsContainedWithinAddressSpace2022()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_CPUValidator::testRegionIsContainedWithinAddressSpace2022()\r\n{\r\n    QFETCH(QString, segmentOffset);\r\n    QFETCH(QString, segmentRange);\r\n    QFETCH(QString, spaceRange);\r\n    QFETCH(bool, isValid);\r\n\r\n    QSharedPointer<ExpressionParser> parser(new SystemVerilogExpressionParser());\r\n    QSharedPointer<ParameterValidator> parameterValidator(new ParameterValidator(parser,\r\n        QSharedPointer<QList<QSharedPointer<Choice> > >(), Document::Revision::Std22));\r\n    QSharedPointer<QList<QSharedPointer<AddressSpace> > > noSpaces;\r\n\r\n    QSharedPointer<QList<QSharedPointer<MemoryMap> > > noMaps;\r\n\r\n    CPUValidator validator(parameterValidator, parser, noSpaces, noMaps, Document::Revision::Std22);\r\n\r\n    QSharedPointer<Region> testRegion(new Region(\"region1\", segmentOffset, segmentRange));\r\n\r\n    QSharedPointer<Cpu> testSpace(new Cpu(\"testCpu\"));\r\n    testSpace->setRange(spaceRange);\r\n    testSpace->getRegions()->append(testRegion);\r\n\r\n    QCOMPARE(validator.hasValidRegions(testSpace), isValid);\r\n\r\n    if (!isValid)\r\n    {\r\n        QVector<QString> foundErrors;\r\n        validator.findErrorsIn(foundErrors, testSpace, \"CPU testCpu\");\r\n\r\n        QString expectedError = \"Region region1 is not contained within address space of CPU testCpu.\";\r\n\r\n        if (errorIsNotFoundInErrorList(expectedError, foundErrors))\r\n        {\r\n            QFAIL(\"No error message found\");\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_CPUValidator::testRegionIsContainedWithinAddressSpace2022_data()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_CPUValidator::testRegionIsContainedWithinAddressSpace2022_data()\r\n{\r\n    QTest::addColumn<QString>(\"segmentOffset\");\r\n    QTest::addColumn<QString>(\"segmentRange\");\r\n    QTest::addColumn<QString>(\"spaceRange\");\r\n\r\n    QTest::addColumn<bool>(\"isValid\");\r\n\r\n    QTest::newRow(\"Region: offset = 0, range = 5 is within address space with range 5\") << \"0\" << \"5\" << \"5\" <<\r\n        true;\r\n    QTest::newRow(\"Region: offset = 0, range = 10 is not within address space with range 5\") << \"0\" << \"10\" <<\r\n        \"5\" << false;\r\n    QTest::newRow(\"Region: offset = 20, range = 1 is not within address space with range 5\") << \"20\" << \"1\" <<\r\n        \"5\" << false;\r\n\r\n    QTest::newRow(\"Region with a long offset is not contained within a small address space\")\r\n        << \"4000000000000000000000\" << \"5\" << \"5\" << false;\r\n    QTest::newRow(\"Region with a long range is not contained within a small address space\")\r\n        << \"0\" << \"4000000000000000000000\" << \"5\" << false;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_CPUValidator::testOverlappingRegions2022()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_CPUValidator::testOverlappingRegions2022()\r\n{\r\n    QFETCH(QString, segmentOffsetOne);\r\n    QFETCH(QString, segmentRangeOne);\r\n    QFETCH(QString, segmentOffsetTwo);\r\n    QFETCH(QString, segmentRangeTwo);\r\n    QFETCH(bool, isValid);\r\n\r\n    QSharedPointer<ExpressionParser> parser(new SystemVerilogExpressionParser());\r\n    QSharedPointer<ParameterValidator> parameterValidator(new ParameterValidator(parser,\r\n        QSharedPointer<QList<QSharedPointer<Choice> > >(), Document::Revision::Std22));\r\n    QSharedPointer<QList<QSharedPointer<AddressSpace> > > noSpaces;\r\n\r\n    QSharedPointer<QList<QSharedPointer<MemoryMap> > > noMaps;\r\n\r\n    CPUValidator validator(parameterValidator, parser, noSpaces, noMaps, Document::Revision::Std22);\r\n\r\n    QSharedPointer<Region> segmentOne(new Region(\"region1\", segmentOffsetOne, segmentRangeOne));\r\n    QSharedPointer<Region> segmentTwo(new Region(\"region2\", segmentOffsetTwo, segmentRangeTwo));\r\n\r\n    QSharedPointer<Cpu> testCpu(new Cpu(\"testCpu\"));\r\n    testCpu->setRange(\"100\");\r\n    testCpu->getRegions()->append(segmentOne);\r\n    testCpu->getRegions()->append(segmentTwo);\r\n\r\n    QCOMPARE(validator.hasValidRegions(testCpu), isValid);\r\n\r\n    if (!isValid)\r\n    {\r\n        QVector<QString> foundErrors;\r\n        validator.findErrorsIn(foundErrors, testCpu, \"CPU testCpu\");\r\n\r\n        QString firstName = segmentOne->name();\r\n        QString secondName = segmentTwo->name();\r\n\r\n        if (segmentOffsetOne.toInt() >= segmentOffsetTwo.toInt())\r\n        {\r\n            firstName = segmentTwo->name();\r\n            secondName = segmentOne->name();\r\n        }\r\n\r\n        QString expectedError = QString(\"Regions %1 and %2 overlap within address space of CPU testCpu\").arg(\r\n            firstName, secondName);\r\n        if (errorIsNotFoundInErrorList(expectedError, foundErrors))\r\n        {\r\n            QFAIL(\"No error message found\");\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_CPUValidator::testOverlappingRegions2022_data()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_CPUValidator::testOverlappingRegions2022_data()\r\n{\r\n    QTest::addColumn<QString>(\"segmentOffsetOne\");\r\n    QTest::addColumn<QString>(\"segmentRangeOne\");\r\n    QTest::addColumn<QString>(\"segmentOffsetTwo\");\r\n    QTest::addColumn<QString>(\"segmentRangeTwo\");\r\n    QTest::addColumn<bool>(\"isValid\");\r\n\r\n    QTest::newRow(\"Region1: offset=0, range=2; Region2: offset=5, range=2 do not overlap\") <<\r\n        \"0\" << \"2\" << \"5\" << \"2\" << true;\r\n    QTest::newRow(\"Region1: offset=0, range=8; Region2: offset=5, range=6 overlap\") <<\r\n        \"0\" << \"8\" << \"5\" << \"6\" << false;\r\n    QTest::newRow(\"Region1: offset=8, range=4; Region2: offset=5, range=6 overlap\") <<\r\n        \"8\" << \"4\" << \"5\" << \"6\" << false;\r\n    QTest::newRow(\"Region1: offset=8, range=1; Region2: offset=5, range=6 overlap\") <<\r\n        \"8\" << \"1\" << \"5\" << \"6\" << false;\r\n\r\n    QTest::newRow(\"Region1: offset=5, range=6; Region2: offset=0, range=8 overlap\") <<\r\n        \"5\" << \"6\" << \"0\" << \"8\" << false;\r\n    QTest::newRow(\"Region1: offset=5, range=6; Region2: offset=8, range=4 overlap\") <<\r\n        \"5\" << \"6\" << \"8\" << \"4\" << false;\r\n    QTest::newRow(\"Region1: offset=5, range=6; Region2: offset=8, range=1 overlap\") <<\r\n        \"5\" << \"6\" << \"8\" << \"1\" << false;\r\n    QTest::newRow(\"Region1: offset=5, range=2; Region2: offset=0, range=2 do not overlap\") <<\r\n        \"5\" << \"2\" << \"0\" << \"2\" << true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_CPUValidator::failParameter()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_CPUValidator::failParameter()\r\n{\r\n    QSharedPointer<ExpressionParser> parser(new SystemVerilogExpressionParser());\r\n    QSharedPointer<ParameterValidator> parameterValidator(new ParameterValidator(parser,\r\n        QSharedPointer<QList<QSharedPointer<Choice> > >(), Document::Revision::Std14));\r\n\r\n    QSharedPointer<QList<QSharedPointer<AddressSpace> > > singleSpace(new QList<QSharedPointer<AddressSpace> >());\r\n    singleSpace->append(QSharedPointer<AddressSpace>(new AddressSpace(\"testSpace\")));\r\n    QSharedPointer<QList<QSharedPointer<MemoryMap> > > noMaps;\r\n\r\n    CPUValidator validator(parameterValidator, parser, singleSpace, noMaps, Document::Revision::Std14);\r\n\r\n    QSharedPointer<Cpu> cpu( new Cpu());\r\n    cpu->setName(\"testCpu\");\r\n\r\n\tQSharedPointer<Parameter> parameter (new Parameter());\r\n\tparameter->setName(\"testParameter\");\r\n\tparameter->setValue(\"\");\r\n\r\n\tcpu->getParameters()->append(parameter);\r\n\r\n\tQSharedPointer<Cpu::AddressSpaceRef> aref(new Cpu::AddressSpaceRef(\"testSpace\") );\r\n\tcpu->getAddressSpaceReferences()->append(aref);\r\n\r\n\tQVector<QString> errorList;\r\n\tvalidator.findErrorsIn(errorList, cpu, \"test\");\r\n\r\n\tQVERIFY(!validator.validate(cpu));\r\n\tQCOMPARE(errorList.size(), 1);\r\n    QCOMPARE(errorList.first(), QString(\"No value specified for parameter testParameter within cpu testCpu\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_CPUValidator::failPresense()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_CPUValidator::failPresense()\r\n{\r\n    QSharedPointer<ExpressionParser> parser(new SystemVerilogExpressionParser());\r\n    QSharedPointer<ParameterValidator> parameterValidator(new ParameterValidator(parser,\r\n        QSharedPointer<QList<QSharedPointer<Choice> > >(), Document::Revision::Std14));\r\n\r\n    QSharedPointer<QList<QSharedPointer<AddressSpace> > > singleSpace(new QList<QSharedPointer<AddressSpace> >());\r\n    singleSpace->append(QSharedPointer<AddressSpace>(new AddressSpace(\"testSpace\")));\r\n    QSharedPointer<QList<QSharedPointer<MemoryMap> > > noMaps;\r\n\r\n    CPUValidator validator(parameterValidator, parser, singleSpace, noMaps, Document::Revision::Std14);\r\n\r\n    QSharedPointer<Cpu> cpu( new Cpu());\r\n    cpu->setName(\"testCpu\");\r\n\tcpu->setIsPresent(\"alabama-man\");\r\n\r\n\tQSharedPointer<Cpu::AddressSpaceRef> aref( new Cpu::AddressSpaceRef(\"testSpace\") );\r\n\tcpu->getAddressSpaceReferences()->append( aref );\r\n\r\n\tQVector<QString> errorList;\r\n\tvalidator.findErrorsIn(errorList, cpu, \"test\");\r\n\r\n\tQVERIFY(!validator.validate(cpu));\r\n\tQCOMPARE(errorList.size(), 1);\r\n    QCOMPARE(errorList.first(), QString(\"Is present expression 'alabama-man' in CPU testCpu is invalid.\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_CPUValidator::failRefPresense()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_CPUValidator::failRefPresense()\r\n{\r\n    QSharedPointer<ExpressionParser> parser(new SystemVerilogExpressionParser());\r\n    QSharedPointer<ParameterValidator> parameterValidator(new ParameterValidator(parser,\r\n        QSharedPointer<QList<QSharedPointer<Choice> > >(), Document::Revision::Std14));\r\n\r\n    QSharedPointer<QList<QSharedPointer<AddressSpace> > > singleSpace(new QList<QSharedPointer<AddressSpace> >());\r\n    singleSpace->append(QSharedPointer<AddressSpace>(new AddressSpace(\"testSpace\")));\r\n    QSharedPointer<QList<QSharedPointer<MemoryMap> > > noMaps;\r\n\r\n    CPUValidator validator(parameterValidator, parser, singleSpace, noMaps, Document::Revision::Std14);\r\n\r\n    QSharedPointer<Cpu> cpu( new Cpu());\r\n    cpu->setName(\"testCpu\");\r\n\r\n\tQSharedPointer<Cpu::AddressSpaceRef> aref(new Cpu::AddressSpaceRef(\"testSpace\"));\r\n\taref->setIsPresent(\"ohio\");\r\n\tcpu->getAddressSpaceReferences()->append( aref );\r\n\r\n\tQVector<QString> errorList;\r\n\tvalidator.findErrorsIn(errorList, cpu, \"test\");\r\n\r\n\tQVERIFY(!validator.validate(cpu));\r\n\tQCOMPARE(errorList.size(), 1);\r\n    QCOMPARE(errorList.first(), \r\n        QString(\"Is present expression 'ohio' for address space reference testSpace in CPU testCpu is invalid.\"));\r\n}\r\n\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_CPUValidator::errorIsNotFoundInErrorList()\r\n//-----------------------------------------------------------------------------\r\nbool tst_CPUValidator::errorIsNotFoundInErrorList(QString const& expectedError,\r\n    QVector<QString> errorList)\r\n{\r\n    if (!errorList.contains(expectedError))\r\n    {\r\n        qDebug() << \"The following error:\" << Qt::endl << expectedError << Qt::endl << \"was not found in error list:\";\r\n        for (QString const& error : errorList)\r\n        {\r\n            qDebug() << error;\r\n        }\r\n        return true;\r\n    }\r\n\r\n    return false;\r\n}\r\nQTEST_APPLESS_MAIN(tst_CPUValidator)\r\n\r\n#include \"tst_CPUValidator.moc\"\r\n"
  },
  {
    "path": "tests/IPXACTmodels/Component/tst_CPUValidator.pri",
    "content": "# ----------------------------------------------------\r\n# This file is generated by the Qt Visual Studio Tools.\r\n# ------------------------------------------------------\r\n\r\nSOURCES += ./tst_CPUValidator.cpp \r\n   "
  },
  {
    "path": "tests/IPXACTmodels/Component/tst_CPUValidator.pro",
    "content": "#-----------------------------------------------------------------------------\r\n# File: tst_CPUValidator.pro\r\n#-----------------------------------------------------------------------------\r\n# Project: Kactus 2\r\n# Author: Janne Virtanen\r\n# Date: 18.11.2015\r\n#\r\n# Description:\r\n# Qt project file template for running unit tests for Enumerated Value Validator.\r\n#-----------------------------------------------------------------------------\r\n\r\nTEMPLATE = app\r\n\r\nTARGET = tst_CPUValidator\r\n\r\nQT += core gui xml testlib\r\n\r\nCONFIG += c++11 testcase console\r\n\r\nlinux-g++ | linux-g++-64 | linux-g++-32 {\r\n LIBS += -L../../../executable \\\r\n     -lIPXACTmodels -lKactusAPI\r\n\r\n}\r\nwin64 | win32 {\r\n LIBS += -L../../../executable \\\r\n     -lIPXACTmodelsd -lKactusAPId\r\n}\r\n\r\nINCLUDEPATH += $$DESTDIR\r\nINCLUDEPATH += ../../../\r\n\r\nDEPENDPATH += .\r\nDEPENDPATH += ../../../\r\n\r\nOBJECTS_DIR += $$DESTDIR\r\n\r\nMOC_DIR += ./generatedFiles\r\nUI_DIR += ./generatedFiles\r\nRCC_DIR += ./generatedFiles\r\ninclude(tst_CPUValidator.pri)\r\n"
  },
  {
    "path": "tests/IPXACTmodels/Component/tst_CPUWriter.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: tst_CPUWriter.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Janne Virtanen\r\n// Date: 15.09.2015\r\n//\r\n// Description:\r\n// Unit test for class CPUWriter.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include <IPXACTmodels/common/Parameter.h>\r\n\r\n#include <IPXACTmodels/Component/CPUWriter.h>\r\n\r\n#include <IPXACTmodels/common/GenericVendorExtension.h>\r\n#include <IPXACTmodels/common/VendorExtension.h>\r\n\r\n#include <QtTest>\r\n\r\nclass tst_CPUWriter : public QObject\r\n{\r\n    Q_OBJECT\r\n\r\npublic:\r\n\ttst_CPUWriter();\r\n\r\nprivate slots:\r\n\tvoid init();\r\n\tvoid cleanup();\r\n\r\n    void testWriteCPUNameGroup();\r\n    void testWriteCPUNameGroup2022();\r\n\r\n\tvoid testWriteIsPresent();\r\n\tvoid testWriteParameter();\r\n\tvoid testWriteAddressSpaces();\r\n\r\n    void testWriteBlockSize2022();\r\n\r\n    void testWriteBlockRegions2022();\r\n\r\n\tvoid testWriteAUB2022();\r\n\r\n    void testWriteExecutableImages2022();\r\n\r\n\tvoid testWriteMemoryMapReference2022();\r\n\r\n\tvoid testWriteVendorExtension();\r\n\r\nprivate:\r\n\r\n\tQSharedPointer<Cpu> testCPU_;\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_CPUWriter::tst_CPUWriter()\r\n//-----------------------------------------------------------------------------\r\ntst_CPUWriter::tst_CPUWriter()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_CPUWriter::init()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_CPUWriter::init()\r\n{\r\n\ttestCPU_ = QSharedPointer<Cpu>(new Cpu());\r\n\ttestCPU_->setName(\"testCpu\");\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_CPUWriter::cleanup()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_CPUWriter::cleanup()\r\n{\r\n\ttestCPU_.clear();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_CPUWriter::testWriteCPUNameGroup()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_CPUWriter::testWriteCPUNameGroup()\r\n{\r\n\tQString output;\r\n\tQXmlStreamWriter xmlStreamWriter(&output);\r\n\r\n\ttestCPU_->setDisplayName(\"testDisplay\");\r\n\ttestCPU_->setDescription(\"testDescription\");\r\n\r\n\tQString expectedOutput = \r\n\t\t\"<ipxact:cpu>\"\r\n\t\t    \"<ipxact:name>testCpu</ipxact:name>\"\r\n\t\t    \"<ipxact:displayName>testDisplay</ipxact:displayName>\"\r\n\t\t    \"<ipxact:description>testDescription</ipxact:description>\"\r\n\t\t\"</ipxact:cpu>\";\r\n\r\n    CPUWriter::writeCPU(xmlStreamWriter, testCPU_, Document::Revision::Std14);\r\n\r\n\tQCOMPARE(output, expectedOutput);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_CPUWriter::testWriteCPUNameGroup2022()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_CPUWriter::testWriteCPUNameGroup2022()\r\n{\r\n    QString output;\r\n    QXmlStreamWriter xmlStreamWriter(&output);\r\n\r\n    testCPU_->setDisplayName(\"testDisplay\");\r\n    testCPU_->setShortDescription(\"brief\");\r\n    testCPU_->setDescription(\"testDescription\");\r\n\r\n    QString expectedOutput =\r\n        \"<ipxact:cpu>\"\r\n\t\t\t\"<ipxact:name>testCpu</ipxact:name>\"\r\n\t\t\t\"<ipxact:displayName>testDisplay</ipxact:displayName>\"\r\n\t\t\t\"<ipxact:shortDescription>brief</ipxact:shortDescription>\"\r\n\t\t\t\"<ipxact:description>testDescription</ipxact:description>\"\r\n        \"</ipxact:cpu>\";\r\n\r\n    CPUWriter::writeCPU(xmlStreamWriter, testCPU_, Document::Revision::Std22);\r\n\r\n    QCOMPARE(output, expectedOutput);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_CPUWriter::testWriteIsPresent()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_CPUWriter::testWriteIsPresent()\r\n{\r\n\tQString output;\r\n\tQXmlStreamWriter xmlStreamWriter(&output);\r\n\r\n\ttestCPU_->setIsPresent(\"4-3\");\r\n\r\n\tQString expectedOutput(\r\n\t\t\"<ipxact:cpu>\"\r\n\t\t    \"<ipxact:name>testCpu</ipxact:name>\"\r\n\t\t    \"<ipxact:isPresent>4-3</ipxact:isPresent>\"\r\n\t\t\"</ipxact:cpu>\"\r\n\t\t);\r\n\r\n\tCPUWriter::writeCPU(xmlStreamWriter, testCPU_, Document::Revision::Std14);\r\n\r\n\tQCOMPARE(output, expectedOutput);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_CPUReader::testWriteParameter()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_CPUWriter::testWriteParameter()\r\n{\r\n\tQString output;\r\n\tQXmlStreamWriter xmlStreamWriter(&output);\r\n\r\n\ttestCPU_->setIsPresent(\"4-3\");\r\n\r\n\tQSharedPointer<Parameter> para1(new Parameter());\r\n\tpara1->setName(\"testParameter\");\r\n\tpara1->setValueId(\"id1\");\r\n\tpara1->setValue(\"5\");\r\n\tpara1->setType(\"shortint\");\r\n\tpara1->setAttribute(\"prompt\", \"Parm 1\");\r\n\tpara1->setAttribute(\"resolve\", \"user\");\r\n\tpara1->setDescription(\"First generator parameter.\");\r\n\r\n    testCPU_->getParameters()->append(para1);\r\n\r\n\tQString expectedOutput(\r\n\t\t\"<ipxact:cpu>\"\r\n\t\t    \"<ipxact:name>testCpu</ipxact:name>\"\r\n\t\t    \"<ipxact:isPresent>4-3</ipxact:isPresent>\"\r\n\t\t    \"<ipxact:parameters>\"\r\n\t\t        \"<ipxact:parameter parameterId=\\\"id1\\\" prompt=\\\"Parm 1\\\" resolve=\\\"user\\\" type=\\\"shortint\\\">\"\r\n\t\t            \"<ipxact:name>testParameter</ipxact:name>\"\r\n\t\t            \"<ipxact:description>First generator parameter.</ipxact:description>\"\r\n\t\t            \"<ipxact:value>5</ipxact:value>\"\r\n\t\t        \"</ipxact:parameter>\"\r\n\t\t    \"</ipxact:parameters>\"\r\n\t\t\"</ipxact:cpu>\"\r\n\t\t);\r\n\r\n\tCPUWriter::writeCPU(xmlStreamWriter, testCPU_, Document::Revision::Std14);\r\n\r\n\tQCOMPARE(output, expectedOutput);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_CPUReader::testWriteAddressSpaces()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_CPUWriter::testWriteAddressSpaces()\r\n{\r\n\tQString output;\r\n\tQXmlStreamWriter xmlStreamWriter(&output);\r\n\r\n\ttestCPU_->setName(\"cpuWithAddressSpace\");\r\n\r\n    QSharedPointer<Cpu::AddressSpaceRef> addressReference (new Cpu::AddressSpaceRef(\"lackOfImagination\"));\r\n    addressReference->setIsPresent(\"spacePresence\");\r\n\r\n    testCPU_->getAddressSpaceReferences()->append(addressReference);\r\n\r\n\tQString expectedOutput(\r\n\t\t\"<ipxact:cpu>\"\r\n    \t\t\"<ipxact:name>cpuWithAddressSpace</ipxact:name>\"\r\n\t    \t    \"<ipxact:addressSpaceRef addressSpaceRef=\\\"lackOfImagination\\\">\"\r\n                    \"<ipxact:isPresent>spacePresence</ipxact:isPresent>\"\r\n                \"</ipxact:addressSpaceRef>\"\r\n\t\t\"</ipxact:cpu>\");\r\n\r\n\tCPUWriter::writeCPU(xmlStreamWriter, testCPU_, Document::Revision::Std14);\r\n\r\n\tQCOMPARE(output, expectedOutput);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_CPUWriter::testWriteBlockSize2022()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_CPUWriter::testWriteBlockSize2022()\r\n{\r\n\tQString output;\r\n\tQXmlStreamWriter xmlStreamWriter(&output);\r\n\r\n    testCPU_->setRange(\"16\");\r\n    testCPU_->setWidth(\"32\");\r\n\r\n\tQString expectedOutput(\r\n\t\t\"<ipxact:cpu>\"\r\n    \t\t\"<ipxact:name>testCpu</ipxact:name>\"\r\n\t    \t    \"<ipxact:range>16</ipxact:range>\"\r\n                \"<ipxact:width>32</ipxact:width>\"\r\n\t\t\"</ipxact:cpu>\");\r\n\r\n\tCPUWriter::writeCPU(xmlStreamWriter, testCPU_, Document::Revision::Std22);\r\n\r\n\tQCOMPARE(output, expectedOutput);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_CPUWriter::testWriteBlockRegions2022()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_CPUWriter::testWriteBlockRegions2022()\r\n{\r\n\tQString output;\r\n\tQXmlStreamWriter xmlStreamWriter(&output);\r\n\r\n\tQSharedPointer<Region> firstRegion(new Region(\"firstRegion\"));\r\n    firstRegion->setDisplayName(\"r1\");\r\n    firstRegion->setShortDescription(\"brief\");\r\n    firstRegion->setDescription(\"region description text\");\r\n\tfirstRegion->setOffset(\"0\");\r\n\tfirstRegion->setRange(\"8\");\r\n\tfirstRegion->getVendorExtensions()->append(\r\n\t\tQSharedPointer<VendorExtension>(new Kactus2Value(\"testExtension\", \"testValue\")));\r\n\r\n\ttestCPU_->getRegions()->append(firstRegion);\r\n\r\n    QSharedPointer<Region> secondRegion(new Region(\"secondRegion\"));\r\n    secondRegion->setDisplayName(\"r2\");\r\n\tsecondRegion->setOffset(\"8\");\r\n\tsecondRegion->setRange(\"16\");\r\n\r\n\ttestCPU_->getRegions()->append(secondRegion);\r\n\r\n\tQString expectedOutput(\r\n        \"<ipxact:cpu>\"\r\n            \"<ipxact:name>testCpu</ipxact:name>\"\r\n            \"<ipxact:regions>\"\r\n                \"<ipxact:region>\"\r\n                    \"<ipxact:name>firstRegion</ipxact:name>\"\r\n                    \"<ipxact:displayName>r1</ipxact:displayName>\"\r\n                    \"<ipxact:shortDescription>brief</ipxact:shortDescription>\"\r\n                    \"<ipxact:description>region description text</ipxact:description>\"\r\n                    \"<ipxact:addressOffset>0</ipxact:addressOffset>\"\r\n                    \"<ipxact:range>8</ipxact:range>\"\r\n                    \"<ipxact:vendorExtensions>\"\r\n                        \"<testExtension>testValue</testExtension>\"\r\n\t\t            \"</ipxact:vendorExtensions>\"\r\n                \"</ipxact:region>\"\r\n                \"<ipxact:region>\"\r\n                    \"<ipxact:name>secondRegion</ipxact:name>\"\r\n                    \"<ipxact:displayName>r2</ipxact:displayName>\"\r\n                    \"<ipxact:addressOffset>8</ipxact:addressOffset>\"\r\n                    \"<ipxact:range>16</ipxact:range>\"\r\n                \"</ipxact:region>\"\r\n            \"</ipxact:regions>\"\r\n        \"</ipxact:cpu>\");\r\n\r\n\tCPUWriter::writeCPU(xmlStreamWriter, testCPU_, Document::Revision::Std22);\r\n\r\n\tQCOMPARE(output, expectedOutput);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_CPUWriter::testWriteAUB2022()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_CPUWriter::testWriteAUB2022()\r\n{\r\n\tQString output;\r\n\tQXmlStreamWriter xmlStreamWriter(&output);\r\n\r\n    testCPU_->setAddressUnitBits(\"32\");\r\n\r\n\tQString expectedOutput(\r\n\t\t\"<ipxact:cpu>\"\r\n    \t\t\"<ipxact:name>testCpu</ipxact:name>\"\r\n\t    \t\"<ipxact:addressUnitBits>32</ipxact:addressUnitBits>\"\r\n\t\t\"</ipxact:cpu>\");\r\n\r\n\tCPUWriter::writeCPU(xmlStreamWriter, testCPU_, Document::Revision::Std22);\r\n\r\n\tQCOMPARE(output, expectedOutput);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_CPUWriter::testWriteExecutableImages2022()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_CPUWriter::testWriteExecutableImages2022()\r\n{\r\n\tQString output;\r\n\tQXmlStreamWriter xmlStreamWriter(&output);\r\n\r\n\tQSharedPointer<ExecutableImage> firstImage(new ExecutableImage);\r\n    firstImage->setName(\"image1\");\r\n    firstImage->setDisplayName(\"d1\");\r\n    firstImage->setShortDescription(\"brief\");\r\n    firstImage->setDescription(\"description text\");\r\n    firstImage->setImageId(\"id1\");\r\n    firstImage->setImageType(\"binary\");\r\n\r\n\ttestCPU_->getExecutableImages()->append(firstImage);\r\n\r\n\tQSharedPointer<Parameter> parameter(new Parameter());\r\n\tparameter->setName(\"param1\");\r\n\tparameter->setValueId(\"id1\");\r\n\tparameter->setValueResolve(\"user\");\r\n\tparameter->setValue(\"1\");\r\n\r\n    firstImage->getParameters()->append(parameter);\r\n\r\n\r\n\tQSharedPointer<FileBuilder> fileBuilder(new FileBuilder);\r\n    fileBuilder->setFileType(\"cSource\");\r\n    fileBuilder->setCommand(\"gcc\");\r\n    fileBuilder->setFlags(\"-O2\");\r\n    fileBuilder->setReplaceDefaultFlags(\"1\");\r\n\r\n    QSharedPointer<LanguageTools> languageTools(new LanguageTools);\r\n    languageTools->getFileBuilders()->append(fileBuilder);\r\n\tlanguageTools->setLinker(\"ld\");\r\n\tlanguageTools->setLinkerFlags(\"-flag\");\r\n\r\n    auto linkerCommandFile = languageTools->getLinkerCommandFile();\r\n    linkerCommandFile->name_ = \"./link.cmd\";\r\n    linkerCommandFile->commandLineSwitch_ = \"-f\";\r\n    linkerCommandFile->enable_ = \"1\";\r\n    linkerCommandFile->generatorRefs_.append(\"gen1\");\r\n    linkerCommandFile->generatorRefs_.append(\"gen2\");\r\n\tlinkerCommandFile->getVendorExtensions()->append(\r\n\t\tQSharedPointer<VendorExtension>(new Kactus2Value(\"testExtension\", \"testValue\")));\r\n\r\n    firstImage->setLanguageTools(languageTools);\r\n\r\n\tQString expectedOutput(\r\n\t\t\"<ipxact:cpu>\"\r\n            \"<ipxact:name>testCpu</ipxact:name>\"\r\n            \"<ipxact:executableImage imageId=\\\"id1\\\" imageType=\\\"binary\\\">\"\r\n                \"<ipxact:name>image1</ipxact:name>\"\r\n                \"<ipxact:displayName>d1</ipxact:displayName>\"\r\n                \"<ipxact:shortDescription>brief</ipxact:shortDescription>\"\r\n                \"<ipxact:description>description text</ipxact:description>\"\r\n                \"<ipxact:parameters>\"\r\n                    \"<ipxact:parameter parameterId=\\\"id1\\\" resolve=\\\"user\\\">\"\r\n                        \"<ipxact:name>param1</ipxact:name>\"\r\n                        \"<ipxact:value>1</ipxact:value>\"\r\n                    \"</ipxact:parameter>\"\r\n                \"</ipxact:parameters>\"\r\n                \"<ipxact:languageTools>\"\r\n                   \"<ipxact:fileBuilder>\"\r\n                        \"<ipxact:fileType>cSource</ipxact:fileType>\"\r\n                        \"<ipxact:command>gcc</ipxact:command>\"\r\n                        \"<ipxact:flags>-O2</ipxact:flags>\"\r\n                        \"<ipxact:replaceDefaultFlags>1</ipxact:replaceDefaultFlags>\"\r\n                    \"</ipxact:fileBuilder>\"\r\n                    \"<ipxact:linker>ld</ipxact:linker>\"\r\n                    \"<ipxact:linkerFlags>-flag</ipxact:linkerFlags>\"\r\n                    \"<ipxact:linkerCommandFile>\"\r\n                        \"<ipxact:name>./link.cmd</ipxact:name>\"\r\n                        \"<ipxact:commandLineSwitch>-f</ipxact:commandLineSwitch>\"\r\n                        \"<ipxact:enable>1</ipxact:enable>\"\r\n                        \"<ipxact:generatorRef>gen1</ipxact:generatorRef>\"\r\n                        \"<ipxact:generatorRef>gen2</ipxact:generatorRef>\"\r\n                        \"<ipxact:vendorExtensions>\"\r\n                            \"<testExtension>testValue</testExtension>\"\r\n                        \"</ipxact:vendorExtensions>\"\r\n                    \"</ipxact:linkerCommandFile>\"\r\n                \"</ipxact:languageTools>\"\r\n            \"</ipxact:executableImage>\"\r\n        \"</ipxact:cpu>\");\r\n\r\n\tCPUWriter::writeCPU(xmlStreamWriter, testCPU_, Document::Revision::Std22);\r\n\r\n\tQCOMPARE(output, expectedOutput);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_CPUWriter::testWriteMemoryMapReference2022()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_CPUWriter::testWriteMemoryMapReference2022()\r\n{\r\n\tQString output;\r\n\tQXmlStreamWriter xmlStreamWriter(&output);\r\n\r\n    testCPU_->setMemoryMapReference(\"map1\");\r\n\r\n\tQString expectedOutput(\r\n\t\t\"<ipxact:cpu>\"\r\n    \t\t\"<ipxact:name>testCpu</ipxact:name>\"\r\n\t    \t\"<ipxact:memoryMapRef>map1</ipxact:memoryMapRef>\"\r\n\t\t\"</ipxact:cpu>\");\r\n\r\n\tCPUWriter::writeCPU(xmlStreamWriter, testCPU_, Document::Revision::Std22);\r\n\r\n\tQCOMPARE(output, expectedOutput);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_CPUReader::testWriteVendorExtension()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_CPUWriter::testWriteVendorExtension()\r\n{\r\n\tQDomDocument document;\r\n\tQDomElement extensionNode = document.createElement(\"testExtension\");\r\n\textensionNode.setAttribute(\"testAttribute\", \"true\");\r\n\textensionNode.appendChild(document.createTextNode(\"testValue\"));\r\n\r\n\tQSharedPointer<GenericVendorExtension> testExtension(new GenericVendorExtension(extensionNode));\r\n\r\n\ttestCPU_->getVendorExtensions()->append(testExtension);\r\n\r\n\tQString output;\r\n\tQXmlStreamWriter xmlStreamWriter(&output);\r\n\r\n\tQString expectedOutput(\r\n\t\t\"<ipxact:cpu>\"\r\n\t\t    \"<ipxact:name>testCpu</ipxact:name>\"\r\n\t\t    \"<ipxact:vendorExtensions>\"\r\n\t\t        \"<testExtension testAttribute=\\\"true\\\">testValue</testExtension>\"\r\n\t\t    \"</ipxact:vendorExtensions>\"\r\n\t\t\"</ipxact:cpu>\"\r\n\t\t);\r\n\r\n\tCPUWriter::writeCPU(xmlStreamWriter, testCPU_, Document::Revision::Std14);\r\n\r\n\tQCOMPARE(output, expectedOutput);\r\n}\r\n\r\nQTEST_APPLESS_MAIN(tst_CPUWriter)\r\n\r\n#include \"tst_CPUWriter.moc\"\r\n"
  },
  {
    "path": "tests/IPXACTmodels/Component/tst_CPUWriter.pri",
    "content": "# ----------------------------------------------------\r\n# This file is generated by the Qt Visual Studio Add-in.\r\n# ------------------------------------------------------\r\n\r\nSOURCES += ./tst_CPUWriter.cpp \r\n"
  },
  {
    "path": "tests/IPXACTmodels/Component/tst_CPUWriter.pro",
    "content": "#-----------------------------------------------------------------------------\r\n# File: tst_CPUWriter.pro\r\n#-----------------------------------------------------------------------------\r\n# Project: Kactus 2\r\n# Author: Janne Virtanen\r\n# Date: 15.09.2015\r\n#\r\n# Description:\r\n# Qt project file template for running unit tests for CPU writer.\r\n#-----------------------------------------------------------------------------\r\n\r\nTEMPLATE = app\r\n\r\nTARGET = tst_CPUWriter\r\n\r\nQT += core xml testlib\r\nQT -= gui\r\n\r\nCONFIG += c++11 testcase console\r\n\r\nlinux-g++ | linux-g++-64 | linux-g++-32 {\r\n LIBS += -L../../../executable \\\r\n     -lIPXACTmodels\r\n\r\n}\r\nwin64 | win32 {\r\n LIBS += -L../../../executable \\\r\n     -lIPXACTmodelsd\r\n}\r\n\r\nINCLUDEPATH += $$DESTDIR\r\nINCLUDEPATH += ../../../\r\n\r\nDEPENDPATH += .\r\nDEPENDPATH += ../../../\r\n\r\nOBJECTS_DIR += $$DESTDIR\r\n\r\nMOC_DIR += ./generatedFiles\r\nUI_DIR += ./generatedFiles\r\nRCC_DIR += ./generatedFiles\r\ninclude(tst_CPUWriter.pri)\r\n"
  },
  {
    "path": "tests/IPXACTmodels/Component/tst_ChannelReader.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: tst_ChannelReader.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Janne Virtanen\r\n// Date: 21.09.2015\r\n//\r\n// Description:\r\n// Unit test for class ChannelReader.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include <IPXACTmodels/Component/ChannelReader.h>\r\n\r\n#include <QtTest>\r\n\r\nclass tst_ChannelReader : public QObject\r\n{\r\n    Q_OBJECT\r\n\r\npublic:\r\n    tst_ChannelReader();\r\n\r\nprivate slots:\r\n\r\n    void testReadNamedChannel();\r\n    void testReadNamedChannel2022();\r\n\r\n    void testReadIsPresent();\r\n    void testReadIsPresentNotAvailableIn2022();\r\n\r\n\tvoid testReadBusInterfaceReferences();\r\n    void testReadBusInterfaceVendorExtensions2022();\r\n\r\n    void testReadVendorExtensions2022();\r\n\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ChannelReader::tst_ChannelReader()\r\n//-----------------------------------------------------------------------------\r\ntst_ChannelReader::tst_ChannelReader()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ChannelReader::testReadNamedChannel()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ChannelReader::testReadNamedChannel()\r\n{\r\n    QString documentContent(\r\n        \"<ipxact:channel>\"\r\n            \"<ipxact:name>channel</ipxact:name>\"\r\n            \"<ipxact:displayName>viewDisplay</ipxact:displayName>\"\r\n            \"<ipxact:description>viewDescription</ipxact:description>\"\r\n        \"</ipxact:channel>\"\r\n        );\r\n\r\n    QDomDocument document;\r\n    document.setContent(documentContent);\r\n\r\n    QDomNode channelNode = document.firstChildElement(\"ipxact:channel\");\r\n\r\n    QSharedPointer<Channel> testChannel = ChannelReader::createChannelFrom(channelNode, Document::Revision::Std14);\r\n\r\n    QCOMPARE(testChannel->name(), QString(\"channel\"));\r\n    QCOMPARE(testChannel->displayName(), QString(\"viewDisplay\"));\r\n    QCOMPARE(testChannel->description(), QString(\"viewDescription\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ChannelReader::testReadNamedChannel()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ChannelReader::testReadNamedChannel2022()\r\n{\r\n    QString documentContent(\r\n        \"<ipxact:channel>\"\r\n            \"<ipxact:name>testChannel</ipxact:name>\"\r\n            \"<ipxact:displayName>viewDisplay</ipxact:displayName>\"\r\n            \"<ipxact:shortDescription>shortDisplay</ipxact:shortDescription>\"\r\n            \"<ipxact:description>viewDescription</ipxact:description>\"\r\n        \"</ipxact:channel>\"\r\n        );\r\n\r\n    QDomDocument document;\r\n    document.setContent(documentContent);\r\n\r\n    QDomNode channelNode = document.firstChildElement(\"ipxact:channel\");\r\n\r\n    QSharedPointer<Channel> testChannel = ChannelReader::createChannelFrom(channelNode, Document::Revision::Std22);\r\n\r\n    QCOMPARE(testChannel->name(), QString(\"testChannel\"));\r\n    QCOMPARE(testChannel->displayName(), QString(\"viewDisplay\"));\r\n    QCOMPARE(testChannel->shortDescription(), QString(\"shortDisplay\"));\r\n    QCOMPARE(testChannel->description(), QString(\"viewDescription\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ChannelReader::testReadIsPresent()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ChannelReader::testReadIsPresent()\r\n{\r\n    QString documentContent(\r\n        \"<ipxact:channel>\"\r\n            \"<ipxact:name>testChannel</ipxact:name>\"\r\n            \"<ipxact:isPresent>4-3</ipxact:isPresent>\"\r\n        \"</ipxact:channel>\");\r\n\r\n\r\n    QDomDocument document;\r\n    document.setContent(documentContent);\r\n\r\n    QDomNode channelNode = document.firstChildElement(\"ipxact:channel\");\r\n\r\n    QSharedPointer<Channel> testChannel = ChannelReader::createChannelFrom(channelNode, Document::Revision::Std14);\r\n\r\n    QCOMPARE(testChannel->getIsPresent(), QString(\"4-3\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ChannelReader::testReadIsPresentNotAvailableIn2022()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ChannelReader::testReadIsPresentNotAvailableIn2022()\r\n{\r\n    QString documentContent(\r\n        \"<ipxact:channel>\"\r\n            \"<ipxact:name>testChannel</ipxact:name>\"\r\n            \"<ipxact:isPresent>4-3</ipxact:isPresent>\"\r\n        \"</ipxact:channel>\");\r\n\r\n    QDomDocument document;\r\n    document.setContent(documentContent);\r\n\r\n    QDomNode channelNode = document.firstChildElement(\"ipxact:channel\");\r\n\r\n    QSharedPointer<Channel> testChannel = ChannelReader::createChannelFrom(channelNode, Document::Revision::Std22);\r\n\r\n    QCOMPARE(testChannel->getIsPresent(), QString());\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_CPUReader::testReadBusInterfaceReferences()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ChannelReader::testReadBusInterfaceReferences()\r\n{\r\n\tQString documentContent(\r\n\t\t\"<ipxact:channel>\"\r\n\t\t\"   <ipxact:name>testChannel</ipxact:name>\"\r\n\t\t    \"<ipxact:isPresent>expression</ipxact:isPresent>\"\r\n\t\t    \"<ipxact:busInterfaceRef>\"\r\n\t\t        \"<ipxact:localName>firstInterface</ipxact:localName>\"\r\n\t\t    \"</ipxact:busInterfaceRef>\"\r\n\t\t    \"<ipxact:busInterfaceRef>\"\r\n\t\t        \"<ipxact:localName>secondInterface</ipxact:localName>\"\r\n\t\t    \"</ipxact:busInterfaceRef>\"\r\n\t\t\"</ipxact:channel>\"\r\n\t\t);\r\n\r\n\tQDomDocument document;\r\n\tdocument.setContent(documentContent);\r\n\r\n\tQDomNode channelNode = document.firstChildElement(\"ipxact:channel\");\r\n\r\n\tQSharedPointer<Channel> testChannel = ChannelReader::createChannelFrom(channelNode, Document::Revision::Std14);\r\n\r\n\tQCOMPARE(testChannel->getIsPresent(), QString(\"expression\"));\r\n\tQCOMPARE(testChannel->getInterfaces()->size(), 2);\r\n\tQCOMPARE(testChannel->getInterfaces()->first()->localName_, QString(\"firstInterface\"));\r\n\tQCOMPARE(testChannel->getInterfaces()->last()->localName_, QString(\"secondInterface\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ChannelReader::testReadBusInterfaceVendorExtensions()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ChannelReader::testReadBusInterfaceVendorExtensions2022()\r\n{\r\n    QString documentContent(\r\n\t\t\"<ipxact:channel>\"\r\n\t\t\"   <ipxact:name>testChannel</ipxact:name>\"\r\n\t\t    \"<ipxact:isPresent>expression</ipxact:isPresent>\"\r\n\t\t    \"<ipxact:busInterfaceRef>\"\r\n\t\t        \"<ipxact:localName>firstInterface</ipxact:localName>\"\r\n                \"<ipxact:vendorExtensions>\"\r\n                    \"<testExtension testExtensionAttribute=\\\"extension\\\">testValue</testExtension>\"\r\n                \"</ipxact:vendorExtensions>\"\r\n\t\t    \"</ipxact:busInterfaceRef>\"\r\n\r\n\t\t\"</ipxact:channel>\"\r\n\t\t);\r\n\r\n\tQDomDocument document;\r\n\tdocument.setContent(documentContent);\r\n\r\n\tQDomNode channelNode = document.firstChildElement(\"ipxact:channel\");\r\n\r\n\tQSharedPointer<Channel> testChannel = ChannelReader::createChannelFrom(channelNode, Document::Revision::Std22);\r\n\r\n\tQCOMPARE(testChannel->getIsPresent(), QString());\r\n\tQCOMPARE(testChannel->getInterfaces()->size(), 1);\r\n    QCOMPARE(testChannel->getInterfaces()->first()->getVendorExtensions()->size(), 1);\r\n    QCOMPARE(testChannel->getInterfaces()->first()->getVendorExtensions()->first()->type(), QString(\"testExtension\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_CPUReader::testReadVendorExtensions()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ChannelReader::testReadVendorExtensions2022()\r\n{\r\n    QString documentContent(\r\n        \"<ipxact:channel>\"\r\n            \"<ipxact:name>testChannel</ipxact:name>\"\r\n            \"<ipxact:vendorExtensions>\"\r\n                \"<testExtension testExtensionAttribute=\\\"extension\\\">testValue</testExtension>\"\r\n            \"</ipxact:vendorExtensions>\"\r\n        \"</ipxact:channel>\"\r\n    );\r\n\r\n    QDomDocument document;\r\n    document.setContent(documentContent);\r\n\r\n    QDomNode channelNode = document.firstChildElement(\"ipxact:channel\");\r\n\r\n    QSharedPointer<Channel> testChannel = ChannelReader::createChannelFrom(channelNode, Document::Revision::Std22);\r\n\r\n    QCOMPARE(testChannel->getVendorExtensions()->size(), 1);\r\n    QCOMPARE(testChannel->getVendorExtensions()->first()->type(), QString(\"testExtension\"));\r\n}\r\n\r\nQTEST_APPLESS_MAIN(tst_ChannelReader)\r\n\r\n#include \"tst_ChannelReader.moc\"\r\n"
  },
  {
    "path": "tests/IPXACTmodels/Component/tst_ChannelReader.pri",
    "content": "# ----------------------------------------------------\r\n# This file is generated by the Qt Visual Studio Add-in.\r\n# ------------------------------------------------------\r\n\r\nSOURCES += ./tst_ChannelReader.cpp \r\n"
  },
  {
    "path": "tests/IPXACTmodels/Component/tst_ChannelReader.pro",
    "content": "#-----------------------------------------------------------------------------\r\n# File: tst_ChannelReader.pro\r\n#-----------------------------------------------------------------------------\r\n# Project: Kactus 2\r\n# Author: Janne Virtanen\r\n# Date: 21.09.2015\r\n#\r\n# Description:\r\n# Qt project file template for running unit tests for Channel reader.\r\n#-----------------------------------------------------------------------------\r\n\r\nTEMPLATE = app\r\n\r\nTARGET = tst_ChannelReader\r\n\r\nQT += core xml testlib\r\nQT -= gui\r\n\r\nCONFIG += c++11 testcase console\r\n\r\nlinux-g++ | linux-g++-64 | linux-g++-32 {\r\n LIBS += -L../../../executable \\\r\n     -lIPXACTmodels\r\n\r\n}\r\nwin64 | win32 {\r\n LIBS += -L../../../executable \\\r\n     -lIPXACTmodelsd\r\n}\r\n\r\nINCLUDEPATH += $$DESTDIR\r\nINCLUDEPATH += ../../../\r\n\r\nDEPENDPATH += .\r\nDEPENDPATH += ../../../\r\n\r\nOBJECTS_DIR += $$DESTDIR\r\n\r\nMOC_DIR += ./generatedFiles\r\nUI_DIR += ./generatedFiles\r\nRCC_DIR += ./generatedFiles\r\n\r\ninclude(tst_ChannelReader.pri)\r\n"
  },
  {
    "path": "tests/IPXACTmodels/Component/tst_ChannelValidator.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: tst_ChannelValidator.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Janne Virtanen\r\n// Date: 19.11.2015\r\n//\r\n// Description:\r\n// Unit test for class ChannelValidator.\r\n//-----------------------------------------------------------------------------\r\n\r\n\r\n#include <IPXACTmodels/Component/BusInterface.h>\r\n#include <IPXACTmodels/Component/Channel.h>\r\n#include <IPXACTmodels/Component/validators/ChannelValidator.h>\r\n\r\n#include <KactusAPI/include/SystemVerilogExpressionParser.h>\r\n\r\n#include <QtTest>\r\n\r\nclass tst_ChannelValidator : public QObject\r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n    tst_ChannelValidator();\r\n\r\nprivate slots:\r\n\tvoid baseCase();\r\n\tvoid testOnlyOneInterfaceReferenceIsInvalid();\r\n\tvoid testReferenceToUnknownInterfaceIsInvalid();\r\n    void testReferenceToNonMirroredInterfaceIsInvalid();\r\n\r\nprivate:\r\n\r\n    QSharedPointer<ExpressionParser> expressionParser_;\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ChannelValidator::tst_ChannelValidator()\r\n//-----------------------------------------------------------------------------\r\ntst_ChannelValidator::tst_ChannelValidator(): expressionParser_(new SystemVerilogExpressionParser())\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ChannelValidator::baseCase()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ChannelValidator::baseCase()\r\n{\r\n    QSharedPointer<QList<QSharedPointer<BusInterface> > > availableInterfaces(\r\n        new QList<QSharedPointer<BusInterface> >());\r\n\r\n    QSharedPointer<BusInterface> firstInterface(new BusInterface());\r\n    firstInterface->setName(\"first\");\r\n    firstInterface->setInterfaceMode(General::MIRRORED_MASTER);\r\n    availableInterfaces->append(firstInterface);\r\n\r\n    QSharedPointer<BusInterface> secondInterface(new BusInterface());\r\n    secondInterface->setName(\"second\");\r\n    secondInterface->setInterfaceMode(General::MIRRORED_SLAVE);\r\n    availableInterfaces->append(secondInterface);\r\n\r\n    QSharedPointer<BusInterface> systemInterface(new BusInterface());\r\n    systemInterface->setName(\"system\");\r\n    systemInterface->setInterfaceMode(General::MIRRORED_SYSTEM);\r\n    availableInterfaces->append(systemInterface);\r\n\r\n\tQSharedPointer<Channel> channel(new Channel);\r\n\tchannel->setName(\"testChannel\");\r\n\tchannel->setIsPresent(\"1\");\r\n\r\n    channel->getInterfaces()->append(QSharedPointer<Channel::BusInterfaceRef>(new Channel::BusInterfaceRef(\"first\")));\r\n    channel->getInterfaces()->append(QSharedPointer<Channel::BusInterfaceRef>(new Channel::BusInterfaceRef(\"second\")));\r\n    channel->getInterfaces()->append(QSharedPointer<Channel::BusInterfaceRef>(new Channel::BusInterfaceRef(\"system\")));\r\n\r\n\tQVector<QString> errorList;\r\n    ChannelValidator validator(expressionParser_, availableInterfaces);\r\n\tvalidator.findErrorsIn(errorList, channel, \"test\");\r\n\r\n\tQVERIFY(validator.validate(channel));\r\n    QCOMPARE(errorList.size(), 0);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ChannelValidator::testOnlyOneInterfaceReferenceIsInvalid()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ChannelValidator::testOnlyOneInterfaceReferenceIsInvalid()\r\n{\r\n    QSharedPointer<QList<QSharedPointer<BusInterface> > > noInterfaces(new QList<QSharedPointer<BusInterface> >());\r\n\r\n\tQSharedPointer<Channel> channel(new Channel);\r\n\tchannel->setName(\"testChannel\");\r\n    channel->setIsPresent(\"1\");\r\n\r\n    channel->getInterfaces()->append(QSharedPointer<Channel::BusInterfaceRef>(new Channel::BusInterfaceRef(\"nonExisting\")));\r\n\r\n\tQVector<QString> errorList;\r\n    ChannelValidator validator(expressionParser_, noInterfaces);\r\n\tvalidator.findErrorsIn(errorList, channel, \"test\");\r\n\r\n\tQVERIFY(!validator.validate(channel));\r\n    QCOMPARE(errorList.size(), 2);\r\n    QCOMPARE(errorList.first(), QStringLiteral(\"At least two interfaces must be defined for channel testChannel.\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ChannelValidator::testReferenceToUnknownInterfaceIsInvalid()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ChannelValidator::testReferenceToUnknownInterfaceIsInvalid()\r\n{\r\n    QSharedPointer<QList<QSharedPointer<BusInterface> > > availableInterfaces(\r\n        new QList<QSharedPointer<BusInterface> >());\r\n\r\n\tQSharedPointer<Channel> channel(new Channel);\r\n\tchannel->setName(\"testChannel\");\r\n\tchannel->setIsPresent(\"1\");\r\n \r\n    channel->getInterfaces()->append(QSharedPointer<Channel::BusInterfaceRef>(new Channel::BusInterfaceRef(\"nonExisting\")));\r\n    channel->getInterfaces()->append(QSharedPointer<Channel::BusInterfaceRef>(new Channel::BusInterfaceRef(\"\")));\r\n\r\n\tQVector<QString> errorList;\r\n    ChannelValidator validator(expressionParser_, availableInterfaces);\r\n\tvalidator.findErrorsIn(errorList, channel, \"test\");\r\n\r\n\tQVERIFY(!validator.validate(channel));\r\n    QCOMPARE(errorList.size(), 2);\r\n    QCOMPARE(errorList.last(), QStringLiteral(\r\n        \"Bus interface '' referenced within channel testChannel not found.\"));\r\n    QCOMPARE(errorList.first(), QStringLiteral(\r\n        \"Bus interface 'nonExisting' referenced within channel testChannel not found.\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ChannelValidator::testReferenceToNonMirroredInterfaceIsInvalid()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ChannelValidator::testReferenceToNonMirroredInterfaceIsInvalid() \r\n{\r\n    QSharedPointer<QList<QSharedPointer<BusInterface> > > availableInterfaces(\r\n        new QList<QSharedPointer<BusInterface> >());\r\n\r\n    QSharedPointer<BusInterface> slaveInterface(new BusInterface());\r\n    slaveInterface->setName(\"slaveInterface\");\r\n    slaveInterface->setInterfaceMode(General::SLAVE);\r\n    availableInterfaces->append(slaveInterface);\r\n\r\n    QSharedPointer<BusInterface> masterInterface(new BusInterface());\r\n    masterInterface->setName(\"masterInterface\");\r\n    masterInterface->setInterfaceMode(General::MASTER);\r\n    availableInterfaces->append(masterInterface);\r\n\r\n    QSharedPointer<BusInterface> systemInterface(new BusInterface());\r\n    systemInterface->setName(\"systemInterface\");\r\n    systemInterface->setInterfaceMode(General::SYSTEM);\r\n    availableInterfaces->append(systemInterface);\r\n\r\n    QSharedPointer<Channel> channel(new Channel);\r\n    channel->setName(\"testChannel\");\r\n\r\n    channel->getInterfaces()->append(QSharedPointer<Channel::BusInterfaceRef>(new Channel::BusInterfaceRef(\"slaveInterface\")));\r\n    channel->getInterfaces()->append(QSharedPointer<Channel::BusInterfaceRef>(new Channel::BusInterfaceRef(\"masterInterface\")));\r\n    channel->getInterfaces()->append(QSharedPointer<Channel::BusInterfaceRef>(new Channel::BusInterfaceRef(\"systemInterface\")));\r\n\r\n    QVector<QString> errorList;\r\n    ChannelValidator validator(expressionParser_, availableInterfaces);\r\n    validator.findErrorsIn(errorList, channel, \"test\");\r\n\r\n    QVERIFY(!validator.validate(channel));\r\n    QCOMPARE(errorList.size(), 3);\r\n    QCOMPARE(errorList.at(0), QStringLiteral(\r\n        \"Bus interface 'slaveInterface' referenced within channel testChannel is not a mirrored interface.\"));\r\n    QCOMPARE(errorList.at(1), QStringLiteral(\r\n        \"Bus interface 'masterInterface' referenced within channel testChannel is not a mirrored interface.\"));\r\n    QCOMPARE(errorList.at(2), QStringLiteral(\r\n        \"Bus interface 'systemInterface' referenced within channel testChannel is not a mirrored interface.\"));\r\n}\r\n\r\n\r\nQTEST_APPLESS_MAIN(tst_ChannelValidator)\r\n\r\n#include \"tst_ChannelValidator.moc\"\r\n"
  },
  {
    "path": "tests/IPXACTmodels/Component/tst_ChannelValidator.pri",
    "content": "# ----------------------------------------------------\r\n# This file is generated by the Qt Visual Studio Tools.\r\n# ------------------------------------------------------\r\n\r\nSOURCES += ./tst_ChannelValidator.cpp \r\n    \r\n"
  },
  {
    "path": "tests/IPXACTmodels/Component/tst_ChannelValidator.pro",
    "content": "#-----------------------------------------------------------------------------\r\n# File: tst_ChannelValidator.pro\r\n#-----------------------------------------------------------------------------\r\n# Project: Kactus 2\r\n# Author: Janne Virtanen\r\n# Date: 19.11.2015\r\n#\r\n# Description:\r\n# Qt project file template for running unit tests for Channel Validator.\r\n#-----------------------------------------------------------------------------\r\n\r\nTEMPLATE = app\r\n\r\nTARGET = tst_ChannelValidator\r\nQT += core xml testlib\r\nQT -= gui\r\n\r\nCONFIG += c++11 testcase console\r\n\r\nlinux-g++ | linux-g++-64 | linux-g++-32 {\r\n LIBS += -L../../../executable \\\r\n     -lIPXACTmodels -lKactusAPI\r\n\r\n}\r\nwin64 | win32 {\r\n LIBS += -L../../../executable \\\r\n     -lIPXACTmodelsd -lKactusAPId\r\n}\r\n\r\nINCLUDEPATH += $$DESTDIR\r\nINCLUDEPATH += ../../../\r\n\r\nDEPENDPATH += .\r\nDEPENDPATH += ../../../\r\n\r\nOBJECTS_DIR += $$DESTDIR\r\n\r\nMOC_DIR += ./generatedFiles\r\nUI_DIR += ./generatedFiles\r\nRCC_DIR += ./generatedFiles\r\ninclude(tst_ChannelValidator.pri)\r\n"
  },
  {
    "path": "tests/IPXACTmodels/Component/tst_ChannelWriter.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: tst_ChannelWriter.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Janne Virtanen\r\n// Date: 21.09.2015\r\n//\r\n// Description:\r\n// Unit test for class ChannelWriter.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include <IPXACTmodels/Component/ChannelWriter.h>\r\n\r\n#include <IPXACTmodels/common/Document.h>\r\n\r\n#include <IPXACTmodels/kactusExtensions/Kactus2Value.h>\r\n\r\n#include <QtTest>\r\n\r\nclass tst_ChannelWriter : public QObject\r\n{\r\n    Q_OBJECT\r\n\r\npublic:\r\n\ttst_ChannelWriter();\r\n\r\nprivate slots:\r\n\tvoid init();\r\n\tvoid cleanup();\r\n\r\n\tvoid testWriteChannelNameGroup();\r\n\tvoid testWriteIsPresent();\r\n\r\n\tvoid testWriteBusRef();\r\n\tvoid testBusRefWriteVendorExtensions2022();\r\n\r\n\tvoid testWriteVendorExtensions2022();\r\n\r\nprivate:\r\n\r\n\tQSharedPointer<Channel> testChannel_;\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ChannelWriter::tst_ChannelWriter()\r\n//-----------------------------------------------------------------------------\r\ntst_ChannelWriter::tst_ChannelWriter()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ChannelWriter::init()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ChannelWriter::init()\r\n{\r\n\ttestChannel_ = QSharedPointer<Channel>(new Channel());\r\n\ttestChannel_->setName(\"testChannel\");\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ChannelWriter::cleanup()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ChannelWriter::cleanup()\r\n{\r\n\ttestChannel_.clear();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ChannelWriter::testWriteChannelNameGroup()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ChannelWriter::testWriteChannelNameGroup()\r\n{\r\n\tQString output;\r\n\tQXmlStreamWriter xmlStreamWriter(&output);\r\n\r\n    testChannel_->setDisplayName(\"testDisplay\");\r\n    testChannel_->setDescription(\"testDescription\");\r\n\r\n\tQString expectedOutput = \r\n\t\t\"<ipxact:channel>\"\r\n\t\t    \"<ipxact:name>testChannel</ipxact:name>\"\r\n\t\t    \"<ipxact:displayName>testDisplay</ipxact:displayName>\"\r\n\t\t    \"<ipxact:description>testDescription</ipxact:description>\"\r\n\t\t\"</ipxact:channel>\";\r\n\r\n\tChannelWriter::writeChannel(xmlStreamWriter, testChannel_, Document::Revision::Std14);\r\n\tQCOMPARE(output, expectedOutput);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ChannelWriter::testWriteIsPresent()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ChannelWriter::testWriteIsPresent()\r\n{\r\n\tQString output;\r\n\tQXmlStreamWriter xmlStreamWriter(&output);\r\n\r\n\ttestChannel_->setIsPresent(\"4-3\");\r\n\r\n\tQString expectedOutput(\r\n\t\t\"<ipxact:channel>\"\r\n\t\t    \"<ipxact:name>testChannel</ipxact:name>\"\r\n\t\t    \"<ipxact:isPresent>4-3</ipxact:isPresent>\"\r\n\t\t\"</ipxact:channel>\"\r\n\t\t);\r\n\r\n\tChannelWriter::writeChannel(xmlStreamWriter, testChannel_, Document::Revision::Std14);\r\n\r\n\tQCOMPARE(output, expectedOutput);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ChannelReader::testWriteBusRef()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ChannelWriter::testWriteBusRef()\r\n{\r\n\tQString output;\r\n\tQXmlStreamWriter xmlStreamWriter(&output);\r\n\r\n\ttestChannel_->setIsPresent(\"expression\");\r\n\r\n    QSharedPointer<Channel::BusInterfaceRef> firstRef(new Channel::BusInterfaceRef(\"firstIf\"));\r\n\r\n    QSharedPointer<Channel::BusInterfaceRef> secondRef(new Channel::BusInterfaceRef(\"secondIf\"));\r\n\r\n    testChannel_->getInterfaces()->append(firstRef);\r\n    testChannel_->getInterfaces()->append(secondRef);\r\n\r\n\tQString expectedOutput(\r\n\t\t\"<ipxact:channel>\"\r\n\t\t    \"<ipxact:name>testChannel</ipxact:name>\"\r\n\t\t    \"<ipxact:isPresent>expression</ipxact:isPresent>\"\r\n\t\t    \"<ipxact:busInterfaceRef>\"\r\n\t\t        \"<ipxact:localName>firstIf</ipxact:localName>\"\r\n\t\t    \"</ipxact:busInterfaceRef>\"\r\n\t\t    \"<ipxact:busInterfaceRef>\"\r\n\t\t        \"<ipxact:localName>secondIf</ipxact:localName>\"\r\n\t\t    \"</ipxact:busInterfaceRef>\"\r\n\t\t\"</ipxact:channel>\"\r\n\t\t);\r\n\r\n\tChannelWriter::writeChannel(xmlStreamWriter, testChannel_, Document::Revision::Std14);\r\n\r\n\tQCOMPARE(output, expectedOutput);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ChannelWriter::testBusRefWriteVendorExtensions2022()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ChannelWriter::testBusRefWriteVendorExtensions2022()\r\n{\r\n    QString output;\r\n    QXmlStreamWriter xmlStreamWriter(&output);\r\n\r\n    QSharedPointer<Channel::BusInterfaceRef> busRef(new Channel::BusInterfaceRef(\"busIf\"));\r\n\r\n\tbusRef->getVendorExtensions()->append(QSharedPointer<VendorExtension>(\r\n        new Kactus2Value(\"testExtension\", \"testValue\")));\r\n\r\n    testChannel_->getInterfaces()->append(busRef);\r\n\r\n    QString expectedOutput =\r\n        \"<ipxact:channel>\"\r\n\t\t\t\"<ipxact:name>testChannel</ipxact:name>\"\r\n\t\t    \"<ipxact:busInterfaceRef>\"\r\n\t\t        \"<ipxact:localName>busIf</ipxact:localName>\"\r\n\t\t\t\t\"<ipxact:vendorExtensions>\"\r\n\t\t\t\t\t\"<testExtension>testValue</testExtension>\"\r\n\t\t\t\t\"</ipxact:vendorExtensions>\"\r\n\t\t    \"</ipxact:busInterfaceRef>\"\r\n        \"</ipxact:channel>\";\r\n\r\n    ChannelWriter::writeChannel(xmlStreamWriter, testChannel_, Document::Revision::Std22);\r\n    QCOMPARE(output, expectedOutput);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ChannelWriter::testWriteVendorExtensions2022()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ChannelWriter::testWriteVendorExtensions2022()\r\n{\r\n    QString output;\r\n    QXmlStreamWriter xmlStreamWriter(&output);\r\n\r\n\r\n\ttestChannel_->getVendorExtensions()->append(QSharedPointer<VendorExtension>(\r\n\t\tnew Kactus2Value(\"testExtension\", \"testValue\")));\r\n\r\n    QString expectedOutput =\r\n        \"<ipxact:channel>\"\r\n\t\t\t\"<ipxact:name>testChannel</ipxact:name>\"\r\n\t\t\t\"<ipxact:vendorExtensions>\"\r\n\t\t\t\t\"<testExtension>testValue</testExtension>\"\r\n\t\t\t\"</ipxact:vendorExtensions>\"\r\n        \"</ipxact:channel>\";\r\n\r\n\tChannelWriter::writeChannel(xmlStreamWriter, testChannel_, Document::Revision::Std22);\r\n    QCOMPARE(output, expectedOutput);\r\n}\r\n\r\n\r\nQTEST_APPLESS_MAIN(tst_ChannelWriter)\r\n\r\n#include \"tst_ChannelWriter.moc\"\r\n"
  },
  {
    "path": "tests/IPXACTmodels/Component/tst_ChannelWriter.pri",
    "content": "# ----------------------------------------------------\r\n# This file is generated by the Qt Visual Studio Add-in.\r\n# ------------------------------------------------------\r\n\r\nSOURCES += ./tst_ChannelWriter.cpp\r\n  "
  },
  {
    "path": "tests/IPXACTmodels/Component/tst_ChannelWriter.pro",
    "content": "#-----------------------------------------------------------------------------\r\n# File: tst_ChannelWriter.pro\r\n#-----------------------------------------------------------------------------\r\n# Project: Kactus 2\r\n# Author: Janne Virtanen\r\n# Date: 21.09.2015\r\n#\r\n# Description:\r\n# Qt project file template for running unit tests for Channel writer.\r\n#-----------------------------------------------------------------------------\r\n\r\nTEMPLATE = app\r\n\r\nTARGET = tst_ChannelWriter\r\n\r\nQT += core xml testlib\r\nQT -= gui\r\n\r\nCONFIG += c++11 testcase console\r\n\r\nlinux-g++ | linux-g++-64 | linux-g++-32 {\r\n LIBS += -L../../../executable \\\r\n     -lIPXACTmodels\r\n\r\n}\r\nwin64 | win32 {\r\n LIBS += -L../../../executable \\\r\n     -lIPXACTmodelsd\r\n}\r\n\r\nINCLUDEPATH += $$DESTDIR\r\nINCLUDEPATH += ../../../\r\n\r\nDEPENDPATH += .\r\nDEPENDPATH += ../../../\r\n\r\nOBJECTS_DIR += $$DESTDIR\r\n\r\nMOC_DIR += ./generatedFiles\r\nUI_DIR += ./generatedFiles\r\nRCC_DIR += ./generatedFiles\r\ninclude(tst_ChannelWriter.pri)\r\n"
  },
  {
    "path": "tests/IPXACTmodels/Component/tst_ChoiceReader.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: tst_ChoiceReader.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Janne Virtanen\r\n// Date: 21.09.2015\r\n//\r\n// Description:\r\n// Unit test for class ChoiceReader.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include <IPXACTmodels/common/ChoiceReader.h>\r\n\r\n#include <QtTest>\r\n\r\nclass tst_ChoiceReader : public QObject\r\n{\r\n    Q_OBJECT\r\n\r\npublic:\r\n    tst_ChoiceReader();\r\n\r\nprivate slots:\r\n\r\n\tvoid testReadSimpleChoice();\r\n\tvoid testReadEnumeration();\r\n\tvoid testReadEnumeration2();\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ChoiceReader::tst_ChoiceReader()\r\n//-----------------------------------------------------------------------------\r\ntst_ChoiceReader::tst_ChoiceReader()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ChoiceReader::testReadSimpleChoice()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ChoiceReader::testReadSimpleChoice()\r\n{\r\n    QString documentContent(\r\n        \"<ipxact:choice>\"\r\n            \"<ipxact:name>Choice</ipxact:name>\"\r\n        \"</ipxact:choice>\"\r\n        );\r\n\r\n\r\n    QDomDocument document;\r\n    document.setContent(documentContent);\r\n\r\n    QDomNode ChoiceNode = document.firstChildElement(\"ipxact:choice\");\r\n\r\n    ChoiceReader choiceReader;\r\n    QSharedPointer<Choice> testChoice = choiceReader.createChoiceFrom(ChoiceNode);\r\n\r\n    QCOMPARE(testChoice->name(), QString(\"Choice\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ChoiceReader::testReadEnumeration()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ChoiceReader::testReadEnumeration()\r\n{\r\n\tQString documentContent(\r\n\t\t\"<ipxact:choice>\"\r\n\t\t\"<ipxact:name>Choice</ipxact:name>\"\r\n\t\t\"<ipxact:enumeration text=\\\"64 bits\\\" help=\\\"ei auteta\\\">64</ipxact:enumeration>\"\r\n\t\t\"</ipxact:choice>\"\r\n\t\t);\r\n\r\n\r\n\tQDomDocument document;\r\n\tdocument.setContent(documentContent);\r\n\r\n\tQDomNode ChoiceNode = document.firstChildElement(\"ipxact:choice\");\r\n\r\n\tChoiceReader choiceReader;\r\n\tQSharedPointer<Choice> testChoice = choiceReader.createChoiceFrom(ChoiceNode);\r\n\r\n\tQCOMPARE(testChoice->name(), QString(\"Choice\"));\r\n\tQCOMPARE(testChoice->enumerations()->size(), 1);\r\n\tQCOMPARE(testChoice->enumerations()->first()->getValue(), QString(\"64\"));\r\n\tQCOMPARE(testChoice->enumerations()->first()->getText(), QString(\"64 bits\"));\r\n\tQCOMPARE(testChoice->enumerations()->first()->getHelp(), QString(\"ei auteta\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ChoiceReader::testReadEnumeration2()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ChoiceReader::testReadEnumeration2()\r\n{\r\n\tQString documentContent(\r\n\t\t\"<ipxact:choice>\"\r\n\t\t\"<ipxact:name>Choice</ipxact:name>\"\r\n\t\t\"<ipxact:enumeration text=\\\"64 bits\\\" help=\\\"ei auteta\\\">64</ipxact:enumeration>\"\r\n\t\t\"<ipxact:enumeration text=\\\"32 bits\\\" help=\\\"ei auteta vielkn\\\">32</ipxact:enumeration>\"\r\n\t\t\"</ipxact:choice>\"\r\n\t\t);\r\n\r\n\r\n\tQDomDocument document;\r\n\tdocument.setContent(documentContent);\r\n\r\n\tQDomNode ChoiceNode = document.firstChildElement(\"ipxact:choice\");\r\n\r\n\tChoiceReader choiceReader;\r\n\tQSharedPointer<Choice> testChoice = choiceReader.createChoiceFrom(ChoiceNode);\r\n\r\n\tQCOMPARE(testChoice->name(), QString(\"Choice\"));\r\n\tQCOMPARE(testChoice->enumerations()->size(), 2);\r\n\tQCOMPARE(testChoice->enumerations()->first()->getValue(), QString(\"64\"));\r\n\tQCOMPARE(testChoice->enumerations()->first()->getText(), QString(\"64 bits\"));\r\n\tQCOMPARE(testChoice->enumerations()->first()->getHelp(), QString(\"ei auteta\"));\r\n\tQCOMPARE(testChoice->enumerations()->last()->getValue(), QString(\"32\"));\r\n\tQCOMPARE(testChoice->enumerations()->last()->getText(), QString(\"32 bits\"));\r\n\tQCOMPARE(testChoice->enumerations()->last()->getHelp(), QString(\"ei auteta vielkn\"));\r\n}\r\n\r\nQTEST_APPLESS_MAIN(tst_ChoiceReader)\r\n\r\n#include \"tst_ChoiceReader.moc\"\r\n"
  },
  {
    "path": "tests/IPXACTmodels/Component/tst_ChoiceReader.pri",
    "content": "# ----------------------------------------------------\r\n# This file is generated by the Qt Visual Studio Add-in.\r\n# ------------------------------------------------------\r\n\r\nSOURCES += ./tst_ChoiceReader.cpp \r\n"
  },
  {
    "path": "tests/IPXACTmodels/Component/tst_ChoiceReader.pro",
    "content": "#-----------------------------------------------------------------------------\r\n# File: tst_ChoiceReader.pro\r\n#-----------------------------------------------------------------------------\r\n# Project: Kactus 2\r\n# Author: Janne Virtanen\r\n# Date: 21.09.2015\r\n#\r\n# Description:\r\n# Qt project file template for running unit tests for Choice reader.\r\n#-----------------------------------------------------------------------------\r\n\r\nTEMPLATE = app\r\n\r\nTARGET = tst_ChoiceReader\r\n\r\nQT += core xml testlib\r\nQT -= gui\r\n\r\nCONFIG += c++11 testcase console\r\n\r\nlinux-g++ | linux-g++-64 | linux-g++-32 {\r\n LIBS += -L../../../executable \\\r\n     -lIPXACTmodels\r\n\r\n}\r\nwin64 | win32 {\r\n LIBS += -L../../../executable \\\r\n     -lIPXACTmodelsd\r\n}\r\n\r\nINCLUDEPATH += $$DESTDIR\r\nINCLUDEPATH += ../../../\r\n\r\nDEPENDPATH += .\r\nDEPENDPATH += ../../../\r\n\r\nOBJECTS_DIR += $$DESTDIR\r\n\r\nMOC_DIR += ./generatedFiles\r\nUI_DIR += ./generatedFiles\r\nRCC_DIR += ./generatedFiles\r\ninclude(tst_ChoiceReader.pri)\r\n"
  },
  {
    "path": "tests/IPXACTmodels/Component/tst_ChoiceValidator.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: tst_ChoiceValidator.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 07.12.2015\r\n//\r\n// Description:\r\n// Unit test for class ChoiceValidator.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include <KactusAPI/include/SystemVerilogExpressionParser.h>\r\n\r\n#include <IPXACTmodels/common/validators/ChoiceValidator.h>\r\n\r\n#include <IPXACTmodels/common/Choice.h>\r\n#include <IPXACTmodels/common/Enumeration.h>\r\n\r\n#include <QtTest>\r\n\r\nclass tst_ChoiceValidator : public QObject\r\n{\r\n    Q_OBJECT\r\n\r\npublic:\r\n    tst_ChoiceValidator();\r\n\r\nprivate slots:\r\n\r\n    void testHasValidName();\r\n    void testHasValidName_data();\r\n\r\n    void testHasValidEnumerations();\r\n\r\nprivate:\r\n\r\n    bool errorIsNotFoundInErrorList(QString const& expectedError, QVector<QString> errorList);\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ChoiceValidator::tst_ChoiceValidator()\r\n//-----------------------------------------------------------------------------\r\ntst_ChoiceValidator::tst_ChoiceValidator()\r\n{\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ChoiceValidator::testHasValidName()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ChoiceValidator::testHasValidName()\r\n{\r\n    QFETCH(QString, name);\r\n    QFETCH(bool, isValid);\r\n\r\n    QSharedPointer<Choice> testChoice (new Choice());\r\n    testChoice->setName(name);\r\n\r\n    QSharedPointer<ExpressionParser> parser(new SystemVerilogExpressionParser());\r\n    ChoiceValidator validator(parser);\r\n    QCOMPARE(validator.hasValidName(testChoice), isValid);\r\n\r\n    if (!isValid)\r\n    {\r\n        QVector<QString> foundErrors;\r\n        validator.findErrorsIn(foundErrors, testChoice, \"test\");\r\n\r\n        QString expectedError = QObject::tr(\"Invalid name set for choice %1 within %2\")\r\n            .arg(testChoice->name()).arg(\"test\");\r\n        if (errorIsNotFoundInErrorList(expectedError, foundErrors))\r\n        {\r\n            QFAIL(\"No error message found\");\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ChoiceValidator::testHasValidName_data()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ChoiceValidator::testHasValidName_data()\r\n{\r\n    QTest::addColumn<QString>(\"name\");\r\n    QTest::addColumn<bool>(\"isValid\");\r\n\r\n    QTest::newRow(\"Name test is valid\") << \"test\" << true;\r\n    QTest::newRow(\"Empty name is invalid\") << \"\" << false;\r\n    QTest::newRow(\"Name consisting of only white spaces is invalid\") << \"    \" << false;\r\n    QTest::newRow(\"Name consisting of characters and white spaces is valid\") << \"  test  \" << true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ChoiceValidator::testHasValidEnumerations()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ChoiceValidator::testHasValidEnumerations()\r\n{\r\n    QSharedPointer<Choice> testChoice (new Choice());\r\n    testChoice->setName(\"testChoice\");\r\n\r\n    QSharedPointer<ExpressionParser> parser (new SystemVerilogExpressionParser());\r\n    ChoiceValidator validator(parser);\r\n\r\n    QCOMPARE(validator.hasValidEnumerations(testChoice), false);\r\n\r\n    QVector<QString> foundErrors;\r\n    validator.findErrorsIn(foundErrors, testChoice, \"test\");\r\n\r\n    QString expectedError = QObject::tr(\"No enumerations found in choice '%1' within %2\")\r\n        .arg(testChoice->name()).arg(\"test\");\r\n    if (errorIsNotFoundInErrorList(expectedError, foundErrors))\r\n    {\r\n        QFAIL(\"No error message found\");\r\n    }\r\n\r\n    QSharedPointer<Enumeration> testEnumeration (new Enumeration());\r\n    testChoice->enumerations()->append(testEnumeration);\r\n\r\n    QCOMPARE(validator.hasValidEnumerations(testChoice), false);\r\n\r\n    foundErrors.clear();\r\n    validator.findErrorsIn(foundErrors, testChoice, \"test\");\r\n\r\n    expectedError = QObject::tr(\"Invalid value '%1' set for enumeration in choice '%2' within %3\")\r\n        .arg(testEnumeration->getValue()).arg(testChoice->name()).arg(\"test\");\r\n    if (errorIsNotFoundInErrorList(expectedError, foundErrors))\r\n    {\r\n        QFAIL(\"No error message found\");\r\n    }\r\n\r\n    testEnumeration->setValue(\"4+4\");\r\n\r\n    QCOMPARE(validator.hasValidEnumerations(testChoice), true);\r\n\r\n    QSharedPointer<Enumeration> otherEnumeration (new Enumeration());\r\n    otherEnumeration->setValue(\"10\");\r\n    testChoice->enumerations()->append(otherEnumeration);\r\n\r\n    QCOMPARE(validator.hasValidEnumerations(testChoice), true);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ChoiceValidator::errorIsNotFoundInErrorList()\r\n//-----------------------------------------------------------------------------\r\nbool tst_ChoiceValidator::errorIsNotFoundInErrorList(QString const& expectedError, QVector<QString> errorList)\r\n{\r\n    if (!errorList.contains(expectedError))\r\n    {\r\n        qDebug() << \"The following error:\" << Qt::endl << expectedError << Qt::endl << \"was not found in error list:\";\r\n        for (QString const& error : errorList)\r\n        {\r\n            qDebug() << error;\r\n        }\r\n        return true;\r\n    }\r\n\r\n    return false;\r\n}\r\n\r\nQTEST_APPLESS_MAIN(tst_ChoiceValidator)\r\n\r\n#include \"tst_ChoiceValidator.moc\"\r\n"
  },
  {
    "path": "tests/IPXACTmodels/Component/tst_ChoiceValidator.pri",
    "content": "# ----------------------------------------------------\r\n# This file is generated by the Qt Visual Studio Tools.\r\n# ------------------------------------------------------\r\n  \r\nSOURCES += ./tst_ChoiceValidator.cpp \r\n   "
  },
  {
    "path": "tests/IPXACTmodels/Component/tst_ChoiceValidator.pro",
    "content": "#-----------------------------------------------------------------------------\r\n# File: tst_ChoiceValidator.pro\r\n#-----------------------------------------------------------------------------\r\n# Project: Kactus 2\r\n# Author: Mikko Teuho\r\n# Date: 07.12.2015\r\n#\r\n# Description:\r\n# Qt project file template for running unit tests for ChoiceValidator.\r\n#-----------------------------------------------------------------------------\r\n\r\nTEMPLATE = app\r\n\r\nTARGET = tst_ChoiceValidator\r\n\r\nQT += core xml testlib\r\nQT -= gui\r\n\r\nCONFIG += c++11 testcase console\r\n\r\nlinux-g++ | linux-g++-64 | linux-g++-32 {\r\n LIBS += -L../../../executable \\\r\n     -lIPXACTmodels -lKactusAPI\r\n\r\n}\r\nwin64 | win32 {\r\n LIBS += -L../../../executable \\\r\n     -lIPXACTmodelsd -lKactusAPId\r\n}\r\nINCLUDEPATH += $$DESTDIR\r\nINCLUDEPATH += ../../../\r\n\r\nDEPENDPATH += .\r\nDEPENDPATH += ../../../\r\n\r\nOBJECTS_DIR += $$DESTDIR\r\n\r\nMOC_DIR += ./generatedFiles\r\nUI_DIR += ./generatedFiles\r\nRCC_DIR += ./generatedFiles\r\ninclude(tst_ChoiceValidator.pri)\r\n"
  },
  {
    "path": "tests/IPXACTmodels/Component/tst_ChoiceWriter.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: tst_ChoiceWriter.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Janne Virtanen\r\n// Date: 21.09.2015\r\n//\r\n// Description:\r\n// Unit test for class ChoiceWriter.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include <IPXACTmodels/common/ChoiceWriter.h>\r\n\r\n#include <QtTest>\r\n\r\nclass tst_ChoiceWriter : public QObject\r\n{\r\n    Q_OBJECT\r\n\r\npublic:\r\n\ttst_ChoiceWriter();\r\n\r\nprivate slots:\r\n\tvoid init();\r\n\tvoid cleanup();\r\n\r\n\tvoid testWriteChoiceName();\r\n\tvoid testWriteEnum();\r\n\tvoid testWriteEnum2();\r\n\r\nprivate:\r\n\r\n\tQSharedPointer<Choice> testChoice_;\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ChoiceWriter::tst_ChoiceWriter()\r\n//-----------------------------------------------------------------------------\r\ntst_ChoiceWriter::tst_ChoiceWriter()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ChoiceWriter::init()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ChoiceWriter::init()\r\n{\r\n\ttestChoice_ = QSharedPointer<Choice>(new Choice());\r\n\ttestChoice_->setName(\"testChoice\");\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ChoiceWriter::cleanup()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ChoiceWriter::cleanup()\r\n{\r\n\ttestChoice_.clear();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ChoiceWriter::testWriteChoiceName()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ChoiceWriter::testWriteChoiceName()\r\n{\r\n\tQString output;\r\n\tQXmlStreamWriter xmlStreamWriter(&output);\r\n\r\n\ttestChoice_->setName(\"Mikko\");\r\n\r\n\tQString expectedOutput(\r\n\t\t\"<ipxact:choice>\"\r\n\t\t\"<ipxact:name>Mikko</ipxact:name>\"\r\n\t\t\"</ipxact:choice>\"\r\n\t\t);\r\n\r\n\t ChoiceWriter::writeChoice(xmlStreamWriter, testChoice_);\r\n\tQCOMPARE(output, expectedOutput);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ChoiceWriter::testWriteEnum()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ChoiceWriter::testWriteEnum()\r\n{\r\n\tQString output;\r\n\tQXmlStreamWriter xmlStreamWriter(&output);\r\n\r\n\tQSharedPointer<Enumeration> enumr(new Enumeration());\r\n\tenumr->setValue(\"64\");\r\n\tenumr->setText(\"64 bits\");\r\n\tenumr->setHelp(\"ei auteta\");\r\n\r\n\tQSharedPointer<QList<QSharedPointer<Enumeration> > > enumrs = testChoice_->enumerations();\r\n\tenumrs->append(enumr);\r\n\r\n\tQString expectedOutput(\r\n\t\t\"<ipxact:choice>\"\r\n\t\t\"<ipxact:name>testChoice</ipxact:name>\"\r\n\t\t\"<ipxact:enumeration text=\\\"64 bits\\\" help=\\\"ei auteta\\\">64</ipxact:enumeration>\"\r\n\t\t\"</ipxact:choice>\"\r\n\t\t);\r\n\r\n\tChoiceWriter::writeChoice(xmlStreamWriter, testChoice_);\r\n\tQCOMPARE(output, expectedOutput);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ChoiceWriter::testWriteEnum2()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ChoiceWriter::testWriteEnum2()\r\n{\r\n\tQString output;\r\n\tQXmlStreamWriter xmlStreamWriter(&output);\r\n\r\n\tQSharedPointer<Enumeration> enumr(new Enumeration());\r\n\tenumr->setValue(\"64\");\r\n\tenumr->setText(\"64 bits\");\r\n\tenumr->setHelp(\"ei auteta\");\r\n\r\n\tQSharedPointer<Enumeration> enumr2(new Enumeration());\r\n\tenumr2->setValue(\"32\");\r\n\tenumr2->setText(\"32 bits\");\r\n\tenumr2->setHelp(\"ei auteta vielkn\");\r\n\r\n\tQSharedPointer<QList<QSharedPointer<Enumeration> > > enumrs = testChoice_->enumerations();\r\n\tenumrs->append(enumr);\r\n\tenumrs->append(enumr2);\r\n\r\n\tQString expectedOutput(\r\n\t\t\"<ipxact:choice>\"\r\n\t\t\"<ipxact:name>testChoice</ipxact:name>\"\r\n\t\t\"<ipxact:enumeration text=\\\"64 bits\\\" help=\\\"ei auteta\\\">64</ipxact:enumeration>\"\r\n\t\t\"<ipxact:enumeration text=\\\"32 bits\\\" help=\\\"ei auteta vielkn\\\">32</ipxact:enumeration>\"\r\n\t\t\"</ipxact:choice>\"\r\n\t\t);\r\n\r\n\tChoiceWriter::writeChoice(xmlStreamWriter, testChoice_);\r\n\tQCOMPARE(output, expectedOutput);\r\n}\r\n\r\nQTEST_APPLESS_MAIN(tst_ChoiceWriter)\r\n\r\n#include \"tst_ChoiceWriter.moc\"\r\n"
  },
  {
    "path": "tests/IPXACTmodels/Component/tst_ChoiceWriter.pri",
    "content": "# ----------------------------------------------------\r\n# This file is generated by the Qt Visual Studio Add-in.\r\n# ------------------------------------------------------\r\n\r\nSOURCES += ./tst_ChoiceWriter.cpp \r\n"
  },
  {
    "path": "tests/IPXACTmodels/Component/tst_ChoiceWriter.pro",
    "content": "#-----------------------------------------------------------------------------\r\n# File: tst_ChoiceWriter.pro\r\n#-----------------------------------------------------------------------------\r\n# Project: Kactus 2\r\n# Author: Janne Virtanen\r\n# Date: 21.09.2015\r\n#\r\n# Description:\r\n# Qt project file template for running unit tests for Choice writer.\r\n#-----------------------------------------------------------------------------\r\n\r\nTEMPLATE = app\r\n\r\nTARGET = tst_ChoiceWriter\r\n\r\nQT += core xml testlib\r\nQT -= gui\r\n\r\nCONFIG += c++11 testcase console\r\n\r\nlinux-g++ | linux-g++-64 | linux-g++-32 {\r\n LIBS += -L../../../executable \\\r\n     -lIPXACTmodels\r\n\r\n}\r\nwin64 | win32 {\r\n LIBS += -L../../../executable \\\r\n     -lIPXACTmodelsd\r\n}\r\n\r\nINCLUDEPATH += $$DESTDIR\r\nINCLUDEPATH += ../../../\r\n\r\nDEPENDPATH += .\r\nDEPENDPATH += ../../../\r\n\r\nOBJECTS_DIR += $$DESTDIR\r\n\r\nMOC_DIR += ./generatedFiles\r\nUI_DIR += ./generatedFiles\r\nRCC_DIR += ./generatedFiles\r\ninclude(tst_ChoiceWriter.pri)\r\n"
  },
  {
    "path": "tests/IPXACTmodels/Component/tst_ComponentGeneratorReader.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: tst_ComponentGeneratorReader.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Janne Virtanen\r\n// Date: 05.10.2015\r\n//\r\n// Description:\r\n// Unit test for class ComponentGeneratorReader.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include <IPXACTmodels/Component/ComponentGeneratorReader.h>\r\n#include <IPXACTmodels/common/VendorExtension.h>\r\n\r\n#include <QtTest>\r\n\r\nclass tst_ComponentGeneratorReader : public QObject\r\n{\r\n    Q_OBJECT\r\n\r\npublic:\r\n    tst_ComponentGeneratorReader();\r\n\r\nprivate slots:\r\n\r\n    void testReadSimpleComponentGenerator();\r\n\tvoid testReadAttributes();\r\n\tvoid testReadGroups();\r\n\tvoid testReadParameters();\r\n\tvoid testRead2Parameters();\r\n\tvoid testReadPhase();\r\n\tvoid testReadApiType();\r\n\tvoid testReadApiService();\r\n\tvoid testReadVendorExtension();\r\n\tvoid testReadTransportMethods();\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ComponentGeneratorReader::tst_ComponentGeneratorReader()\r\n//-----------------------------------------------------------------------------\r\ntst_ComponentGeneratorReader::tst_ComponentGeneratorReader()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ComponentGeneratorReader::testReadSimpleComponentGenerator()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ComponentGeneratorReader::testReadSimpleComponentGenerator()\r\n{\r\n    QString documentContent(\r\n\t\t\"<ipxact:componentGenerator>\"\r\n\t\t    \"<ipxact:name>test</ipxact:name>\"\r\n\t\t    \"<ipxact:displayName>Display</ipxact:displayName>\"\r\n\t\t    \"<ipxact:description>Description</ipxact:description>\"\r\n            \"<ipxact:generatorExe>/bin/generator.exe</ipxact:generatorExe>\"\r\n        \"</ipxact:componentGenerator>\"\r\n    );\r\n\r\n    QDomDocument document;\r\n    document.setContent(documentContent);\r\n\r\n    QDomNode componentGeneratorNode = document.firstChildElement(\"ipxact:componentGenerator\");\r\n\r\n\tQSharedPointer<ComponentGenerator> testComponentGenerator =\r\n        ComponentGeneratorReader::createComponentGeneratorFrom(componentGeneratorNode, Document::Revision::Std14);\r\n\r\n\tQCOMPARE(testComponentGenerator->name(), QStringLiteral(\"test\"));\r\n\tQCOMPARE(testComponentGenerator->displayName(), QStringLiteral(\"Display\"));\r\n\tQCOMPARE(testComponentGenerator->description(), QStringLiteral(\"Description\"));\r\n    QCOMPARE(testComponentGenerator->getGeneratorExe(), QStringLiteral(\"/bin/generator.exe\"));\r\n    \t\r\n    QVERIFY(testComponentGenerator->getHidden().toString().isEmpty());\r\n    QVERIFY(testComponentGenerator->getScope() == ComponentGenerator::Scope::NO_SCOPE);\r\n    QVERIFY(testComponentGenerator->getPhase().isEmpty());\r\n    QVERIFY(testComponentGenerator->getApiType() == ComponentGenerator::ApiType::EMPTY_API_TYPE);    \r\n    QVERIFY(testComponentGenerator->getTransportMethods().isEmpty());\r\n    QVERIFY(testComponentGenerator->getGroups().isEmpty());\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ComponentGeneratorReader::testReadAttributes()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ComponentGeneratorReader::testReadAttributes()\r\n{\r\n\tQString documentContent(\r\n\t\t\"<ipxact:componentGenerator hidden=\\\"true\\\" scope=\\\"entity\\\">\"\r\n\t\t\"</ipxact:componentGenerator>\"\r\n\t);\r\n\r\n\tQDomDocument document;\r\n\tdocument.setContent(documentContent);\r\n\r\n\tQDomNode componentGeneratorNode = document.firstChildElement(\"ipxact:componentGenerator\");\r\n\r\n\tQSharedPointer<ComponentGenerator> testComponentGenerator = \r\n        ComponentGeneratorReader::createComponentGeneratorFrom(componentGeneratorNode, Document::Revision::Std14);\r\n\r\n\tQCOMPARE(testComponentGenerator->getScope(), ComponentGenerator::Scope::ENTITY);\r\n\tQCOMPARE(testComponentGenerator->getHidden().toBool(), true);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ComponentGeneratorReader::testReadGroups()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ComponentGeneratorReader::testReadGroups()\r\n{\r\n\tQString documentContent(\r\n        \"<ipxact:componentGenerator scope=\\\"instance\\\">\"\r\n\t\t    \"<ipxact:group>testGroup</ipxact:group>\"\r\n\t\t    \"<ipxact:group>secondTestGroup</ipxact:group>\"\r\n\t\t\"</ipxact:componentGenerator>\"\r\n\t);\r\n\r\n\r\n\tQDomDocument document;\r\n\tdocument.setContent(documentContent);\r\n\r\n\tQDomNode componentGeneratorNode = document.firstChildElement(\"ipxact:componentGenerator\");\r\n\r\n\tQSharedPointer<ComponentGenerator> testComponentGenerator = \r\n        ComponentGeneratorReader::createComponentGeneratorFrom(componentGeneratorNode, Document::Revision::Std14);\r\n\r\n\tQCOMPARE(testComponentGenerator->getGroups().size(), 2);\r\n\tQCOMPARE(testComponentGenerator->getGroups().first(), QStringLiteral(\"testGroup\"));\r\n\tQCOMPARE(testComponentGenerator->getGroups().last(), QStringLiteral(\"secondTestGroup\"));\r\n\r\n    QCOMPARE(testComponentGenerator->getScope(), ComponentGenerator::Scope::INSTANCE);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ComponentGeneratorReader::testReadParameters()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ComponentGeneratorReader::testReadParameters()\r\n{\r\n\tQString documentContent(\r\n\t\t\"<ipxact:componentGenerator>\"\r\n\t\t    \"<ipxact:parameters>\"\r\n\t\t        \"<ipxact:parameter parameterId=\\\"id\\\" prompt=\\\"Parm 1\\\" type=\\\"shortint\\\" resolve=\\\"user\\\">\"\r\n\t\t            \"<ipxact:name>testParameter</ipxact:name>\"\r\n\t\t            \"<ipxact:description>First generator parameter.</ipxact:description>\"\r\n\t\t            \"<ipxact:value>5</ipxact:value>\"\r\n\t\t        \"</ipxact:parameter>\"\r\n\t\t    \"</ipxact:parameters>\"\r\n\t\t\"</ipxact:componentGenerator>\"\r\n\t\t);\r\n\r\n\r\n\tQDomDocument document;\r\n\tdocument.setContent(documentContent);\r\n\r\n\tQDomNode componentGeneratorNode = document.firstChildElement(\"ipxact:componentGenerator\");\r\n\r\n\tQSharedPointer<ComponentGenerator> testComponentGenerator = \r\n        ComponentGeneratorReader::createComponentGeneratorFrom(componentGeneratorNode, Document::Revision::Std14);\r\n\r\n\tQCOMPARE(testComponentGenerator->getParameters()->first()->name(), QStringLiteral(\"testParameter\"));\r\n\tQCOMPARE(testComponentGenerator->getParameters()->first()->getValueId(), QStringLiteral(\"id\"));\r\n\tQCOMPARE(testComponentGenerator->getParameters()->first()->getValue(), QStringLiteral(\"5\"));\r\n\tQCOMPARE(testComponentGenerator->getParameters()->first()->getType(), QStringLiteral(\"shortint\"));\r\n\tQCOMPARE(testComponentGenerator->getParameters()->first()->getAttribute(\"prompt\"), QStringLiteral(\"Parm 1\"));\r\n\tQCOMPARE(testComponentGenerator->getParameters()->first()->getAttribute(\"resolve\"), QStringLiteral(\"user\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ComponentGeneratorReader::testRead2Parameters()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ComponentGeneratorReader::testRead2Parameters()\r\n{\r\n\tQString documentContent(\r\n\t\t\"<ipxact:componentGenerator>\"\r\n\t\t    \"<ipxact:parameters>\"\r\n\t\t        \"<ipxact:parameter parameterId=\\\"id1\\\">\"\r\n\t\t            \"<ipxact:name>testParameter</ipxact:name>\"\r\n\t\t            \"<ipxact:description>First generator parameter.</ipxact:description>\"\r\n\t\t            \"<ipxact:value>5</ipxact:value>\"\r\n\t\t        \"</ipxact:parameter>\"\r\n\t\t        \"<ipxact:parameter parameterId=\\\"id2\\\">\"\r\n\t\t            \"<ipxact:name>secondTestParameter</ipxact:name>\"\r\n\t\t            \"<ipxact:value>1337</ipxact:value>\"\r\n\t\t        \"</ipxact:parameter>\"\r\n\t\t    \"</ipxact:parameters>\"\r\n\t\t\"</ipxact:componentGenerator>\"\r\n\t\t);\r\n\r\n\r\n\tQDomDocument document;\r\n\tdocument.setContent(documentContent);\r\n\r\n\tQDomNode componentGeneratorNode = document.firstChildElement(\"ipxact:componentGenerator\");\r\n\r\n\tQSharedPointer<ComponentGenerator> testComponentGenerator = \r\n        ComponentGeneratorReader::createComponentGeneratorFrom(componentGeneratorNode, Document::Revision::Std14);\r\n\r\n\tQCOMPARE(testComponentGenerator->getParameters()->size(), 2);\r\n\tQCOMPARE(testComponentGenerator->getParameters()->first()->name(), QStringLiteral(\"testParameter\"));\r\n\tQCOMPARE(testComponentGenerator->getParameters()->first()->getValueId(), QStringLiteral(\"id1\"));\r\n\tQCOMPARE(testComponentGenerator->getParameters()->first()->getValue(), QStringLiteral(\"5\"));\r\n\r\n\tQCOMPARE(testComponentGenerator->getParameters()->last()->name(), QStringLiteral(\"secondTestParameter\"));\r\n\tQCOMPARE(testComponentGenerator->getParameters()->last()->getValueId(), QStringLiteral(\"id2\"));\r\n\tQCOMPARE(testComponentGenerator->getParameters()->last()->getValue(), QStringLiteral(\"1337\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ComponentGeneratorReader::testReadPhase()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ComponentGeneratorReader::testReadPhase()\r\n{\r\n\tQString documentContent(\r\n\t\t\"<ipxact:componentGenerator>\"\r\n\t\t    \"<ipxact:phase>13.37</ipxact:phase>\"\r\n\t\t\"</ipxact:componentGenerator>\"\r\n\t\t);\r\n\r\n\r\n\tQDomDocument document;\r\n\tdocument.setContent(documentContent);\r\n\r\n\tQDomNode componentGeneratorNode = document.firstChildElement(\"ipxact:componentGenerator\");\r\n\r\n\tQSharedPointer<ComponentGenerator> testComponentGenerator =\r\n\t\tComponentGeneratorReader::createComponentGeneratorFrom(componentGeneratorNode, Document::Revision::Std14);\r\n\r\n\tQCOMPARE(testComponentGenerator->getPhase(), QStringLiteral(\"13.37\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ComponentGeneratorReader::testReadApiType()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ComponentGeneratorReader::testReadApiType()\r\n{\r\n\tQString documentContent(\r\n\t\t\"<ipxact:componentGenerator>\"\r\n\t\t    \"<ipxact:apiType>TGI_2014_EXTENDED</ipxact:apiType>\"\r\n\t\t\"</ipxact:componentGenerator>\"\r\n\t\t);\r\n\r\n\r\n\tQDomDocument document;\r\n\tdocument.setContent(documentContent);\r\n\r\n\tQDomNode componentGeneratorNode = document.firstChildElement(\"ipxact:componentGenerator\");\r\n\r\n\tQSharedPointer<ComponentGenerator> testComponentGenerator =\r\n\t\tComponentGeneratorReader::createComponentGeneratorFrom(componentGeneratorNode, Document::Revision::Std14);\r\n\r\n\tQCOMPARE(testComponentGenerator->getApiType(), ComponentGenerator::ApiType::TGI_2014_EXTENDED);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ComponentGeneratorReader::testReadApiService()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ComponentGeneratorReader::testReadApiService()\r\n{\r\n\tQString documentContent(\r\n\t\t\"<ipxact:componentGenerator>\"\r\n\t\t    \"<ipxact:apiType>TGI_2022_BASE</ipxact:apiType>\"\r\n\t\t    \"<ipxact:apiService>REST</ipxact:apiService>\"\r\n\t\t\"</ipxact:componentGenerator>\"\r\n\t\t);\r\n\r\n\r\n\tQDomDocument document;\r\n\tdocument.setContent(documentContent);\r\n\r\n\tQDomNode componentGeneratorNode = document.firstChildElement(\"ipxact:componentGenerator\");\r\n\r\n\tQSharedPointer<ComponentGenerator> testComponentGenerator =\r\n\t\tComponentGeneratorReader::createComponentGeneratorFrom(componentGeneratorNode, Document::Revision::Std22);\r\n\r\n\tQCOMPARE(testComponentGenerator->getApiType(), ComponentGenerator::ApiType::TGI_2022_BASE);\r\n\tQCOMPARE(testComponentGenerator->getApiService(), QString(\"REST\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ComponentGeneratorReader::testReadVendorExtension()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ComponentGeneratorReader::testReadVendorExtension()\r\n{\r\n\tQString documentContent(\r\n\t\t\"<ipxact:componentGenerator>\"\r\n\t\t    \"<ipxact:vendorExtensions>\"\r\n\t\t        \"<testExtension attribute=\\\"value\\\"/>\"\r\n\t\t    \"</ipxact:vendorExtensions>\"\r\n\t\t\"</ipxact:componentGenerator>\"\r\n\t\t);\r\n\r\n\r\n\tQDomDocument document;\r\n\tdocument.setContent(documentContent);\r\n\r\n\tQDomNode componentGeneratorNode = document.firstChildElement(\"ipxact:componentGenerator\");\r\n\r\n\tQSharedPointer<ComponentGenerator> testComponentGenerator =\r\n\t\tComponentGeneratorReader::createComponentGeneratorFrom(componentGeneratorNode, Document::Revision::Std14);\r\n\r\n\tQCOMPARE(testComponentGenerator->getVendorExtensions()->first()->type(), QStringLiteral(\"testExtension\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ComponentGeneratorReader::testReadTransportMethods()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ComponentGeneratorReader::testReadTransportMethods()\r\n{\r\n\tQString documentContent(\r\n\t\t\"<ipxact:componentGenerator>\"\r\n\t\t    \"<ipxact:transportMethods>\"\r\n\t\t        \"<ipxact:transportMethod>file</ipxact:transportMethod>\"\r\n\t\t    \"</ipxact:transportMethods>\"\r\n\t\t\"</ipxact:componentGenerator>\"\r\n\t\t);\r\n\r\n\r\n\tQDomDocument document;\r\n\tdocument.setContent(documentContent);\r\n\r\n\tQDomNode componentGeneratorNode = document.firstChildElement(\"ipxact:componentGenerator\");\r\n\r\n\tQSharedPointer<ComponentGenerator> testComponentGenerator =\r\n\t\tComponentGeneratorReader::createComponentGeneratorFrom(componentGeneratorNode, Document::Revision::Std14);\r\n\r\n\tQCOMPARE(testComponentGenerator->getTransportMethods().size(), 1);\r\n\tQCOMPARE(testComponentGenerator->getTransportMethods().first(), QStringLiteral(\"file\"));\r\n}\r\n\r\nQTEST_APPLESS_MAIN(tst_ComponentGeneratorReader)\r\n\r\n#include \"tst_ComponentGeneratorReader.moc\"\r\n"
  },
  {
    "path": "tests/IPXACTmodels/Component/tst_ComponentGeneratorReader.pri",
    "content": "# ----------------------------------------------------\r\n# This file is generated by the Qt Visual Studio Add-in.\r\n# ------------------------------------------------------\r\n\r\nSOURCES += ./tst_ComponentGeneratorReader.cpp \r\n"
  },
  {
    "path": "tests/IPXACTmodels/Component/tst_ComponentGeneratorReader.pro",
    "content": "#-----------------------------------------------------------------------------\r\n# File: tst_ComponentGeneratorReader.pro\r\n#-----------------------------------------------------------------------------\r\n# Project: Kactus 2\r\n# Author: Janne Virtanen\r\n# Date: 05.10.2015\r\n#\r\n# Description:\r\n# Qt project file template for running unit tests for ComponentGenerator reader.\r\n#-----------------------------------------------------------------------------\r\n\r\nTEMPLATE = app\r\n\r\nTARGET = tst_ComponentGeneratorReader\r\n\r\nQT += core xml testlib\r\nQT -= gui\r\n\r\nCONFIG += c++11 testcase console\r\n\r\nlinux-g++ | linux-g++-64 | linux-g++-32 {\r\n LIBS += -L../../../executable \\\r\n     -lIPXACTmodels\r\n\r\n}\r\nwin64 | win32 {\r\n LIBS += -L../../../executable \\\r\n     -lIPXACTmodelsd\r\n}\r\n\r\nINCLUDEPATH += $$DESTDIR\r\nINCLUDEPATH += ../../../\r\n\r\nDEPENDPATH += .\r\nDEPENDPATH += ../../../\r\n\r\nOBJECTS_DIR += $$DESTDIR\r\n\r\nMOC_DIR += ./generatedFiles\r\nUI_DIR += ./generatedFiles\r\nRCC_DIR += ./generatedFiles\r\ninclude(tst_ComponentGeneratorReader.pri)\r\n"
  },
  {
    "path": "tests/IPXACTmodels/Component/tst_ComponentGeneratorValidator.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: tst_ComponentGeneratorValidator.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 07.01.2016\r\n//\r\n// Description:\r\n// Unit test for class ComponentGeneratorValidator.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include <KactusAPI/include/SystemVerilogExpressionParser.h>\r\n\r\n#include <IPXACTmodels/Component/ComponentGenerator.h>\r\n\r\n#include <IPXACTmodels/Component/validators/ComponentGeneratorValidator.h>\r\n#include <IPXACTmodels/common/validators/ParameterValidator.h>\r\n\r\n#include <QtTest>\r\n\r\nclass tst_ComponentGeneratorValidator : public QObject\r\n{\r\n    Q_OBJECT\r\n\r\npublic:\r\n    tst_ComponentGeneratorValidator();\r\n\r\nprivate slots:\r\n    \r\n    void testHasValidName();\r\n    void testHasValidName_data();\r\n\r\n    void testHasValidPhase();\r\n    void testHasValidPhase_data();\r\n\r\n    void testHasValidGeneratorExe();\r\n    void testHasValidGeneratorExe_data();\r\n\r\nprivate:\r\n\r\n    bool errorIsNotFoundInErrorList(QString const& expectedError, QVector<QString> errorList);\r\n\r\n    QSharedPointer<ComponentGeneratorValidator> createComponentGeneratorValidator(Document::Revision docRevision);\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ComponentGeneratorValidator::tst_ComponentGeneratorValidator()\r\n//-----------------------------------------------------------------------------\r\ntst_ComponentGeneratorValidator::tst_ComponentGeneratorValidator()\r\n{\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ComponentGeneratorValidator::testHasValidName()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ComponentGeneratorValidator::testHasValidName()\r\n{\r\n    QFETCH(QString, name);\r\n    QFETCH(bool, isValid);\r\n\r\n    QSharedPointer<ComponentGenerator> testGenerator (new ComponentGenerator());\r\n    testGenerator->setName(name);\r\n\r\n    QSharedPointer<ComponentGeneratorValidator> validator = createComponentGeneratorValidator(Document::Revision::Std14);\r\n\r\n    QCOMPARE(validator->hasValidName(testGenerator), isValid);\r\n\r\n    if (!isValid)\r\n    {\r\n        QVector<QString> foundErrors;\r\n        validator->findErrorsIn(foundErrors, testGenerator, \"test\");\r\n\r\n        QString expectedError = QObject::tr(\"Invalid name specified for component generator %1 within %2\").\r\n            arg(testGenerator->name(), \"test\");\r\n        if (errorIsNotFoundInErrorList(expectedError, foundErrors))\r\n        {\r\n            QFAIL(\"No error message found\");\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ComponentGeneratorValidator::testHasValidName_data()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ComponentGeneratorValidator::testHasValidName_data()\r\n{\r\n    QTest::addColumn<QString>(\"name\");\r\n    QTest::addColumn<bool>(\"isValid\");\r\n\r\n    QTest::newRow(\"Name test is valid\") << \"test\" << true;\r\n    QTest::newRow(\"Empty name is invalid\") << \"\" << false;\r\n    QTest::newRow(\"Name consisting of only white spaces is invalid\") << \"    \" << false;\r\n    QTest::newRow(\"Name consisting of characters and white spaces is valid\") << \"  test  \" << true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ComponentGeneratorValidator::testHasValidPhase()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ComponentGeneratorValidator::testHasValidPhase()\r\n{\r\n    QFETCH(QString, phaseValue);\r\n    QFETCH(bool, isValid);\r\n\r\n    QSharedPointer<ComponentGenerator> testGenerator (new ComponentGenerator());\r\n    testGenerator->setName(\"Phasor\");\r\n    testGenerator->setPhase(phaseValue);\r\n\r\n    QSharedPointer<ComponentGeneratorValidator> validator = createComponentGeneratorValidator(Document::Revision::Std14);\r\n\r\n    QCOMPARE(validator->hasValidPhase(testGenerator), isValid);\r\n\r\n    if (!isValid)\r\n    {\r\n        QVector<QString> foundErrors;\r\n        validator->findErrorsIn(foundErrors, testGenerator, \"test\");\r\n\r\n        QString expectedError = QObject::tr(\"Invalid phase value set for component generator '%1' within %2\")\r\n            .arg(testGenerator->name()).arg(\"test\");\r\n        if (errorIsNotFoundInErrorList(expectedError, foundErrors))\r\n        {\r\n            QFAIL(\"No error message found\");\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ComponentGeneratorValidator::testHasValidPhase_data()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ComponentGeneratorValidator::testHasValidPhase_data()\r\n{\r\n    QTest::addColumn<QString>(\"phaseValue\");\r\n    QTest::addColumn<bool>(\"isValid\");\r\n\r\n    QTest::newRow(\"Phase value 1+1.12 is valid\") << \"1+1.12\" << true;\r\n    QTest::newRow(\"Phase value 0 is valid\") << \"0\" << true;\r\n    QTest::newRow(\"Phase value -4.12 is valid\") << \"-4.12\" << true;\r\n    QTest::newRow(\"Empty phase value is valid\") << \"\" << true;\r\n    QTest::newRow(\"Text is not valid for phase value\") << \"text\" << false;\r\n    QTest::newRow(\"String is not valid for phase value\") << \"\\\"text\\\"\" << false;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ComponentGeneratorValidator::testHasValidGeneratorExe()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ComponentGeneratorValidator::testHasValidGeneratorExe()\r\n{\r\n    QFETCH(QString, generatorExe);\r\n    QFETCH(bool, isValid);\r\n\r\n    QSharedPointer<ComponentGenerator> testGenerator (new ComponentGenerator());\r\n    testGenerator->setName(\"Phazon\");\r\n    testGenerator->setGeneratorExe(generatorExe);\r\n\r\n    QSharedPointer<ComponentGeneratorValidator> validator = createComponentGeneratorValidator(Document::Revision::Std14);\r\n\r\n    QCOMPARE(validator->hasValidGeneratorExe(testGenerator), isValid);\r\n\r\n    if (!isValid)\r\n    {\r\n        QVector<QString> foundErrors;\r\n        validator->findErrorsIn(foundErrors, testGenerator, \"test\");\r\n\r\n        QString expectedError = QObject::tr(\"Invalid generator exe set for component generator '%1' within %2\")\r\n            .arg(testGenerator->name()).arg(\"test\");\r\n        if (errorIsNotFoundInErrorList(expectedError, foundErrors))\r\n        {\r\n            QFAIL(\"No error message found\");\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ComponentGeneratorValidator::testHasValidGeneratorExe_data()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ComponentGeneratorValidator::testHasValidGeneratorExe_data()\r\n{\r\n    QTest::addColumn<QString>(\"generatorExe\");\r\n    QTest::addColumn<bool>(\"isValid\");\r\n\r\n    QTest::newRow(\"Generator exe ../bin/myGenerator.pl is valid\") << \"../bin/myGenerator.pl\" << true;\r\n    QTest::newRow(\"Empty generator exe is not valid\") << \"\" << false;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ComponentGeneratorValidator::errorIsNotFoundInErrorList()\r\n//-----------------------------------------------------------------------------\r\nbool tst_ComponentGeneratorValidator::errorIsNotFoundInErrorList(QString const& expectedError,\r\n    QVector<QString> errorList)\r\n{\r\n    if (!errorList.contains(expectedError))\r\n    {\r\n        qDebug() << \"The following error:\" << Qt::endl << expectedError << Qt::endl << \"was not found in error list:\";\r\n        foreach(QString error, errorList)\r\n        {\r\n            qDebug() << error;\r\n        }\r\n        return true;\r\n    }\r\n\r\n    return false;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ComponentGeneratorValidator::createGeneratorValidator()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<ComponentGeneratorValidator> tst_ComponentGeneratorValidator::createComponentGeneratorValidator(Document::Revision docRevision)\r\n{\r\n    QSharedPointer<ExpressionParser> parser (new SystemVerilogExpressionParser());\r\n\r\n    QSharedPointer<ParameterValidator> parameterValidator(new ParameterValidator(parser,\r\n        QSharedPointer<QList<QSharedPointer<Choice> > > (), docRevision));\r\n\r\n    QSharedPointer<ComponentGeneratorValidator> generatorValidator (\r\n        new ComponentGeneratorValidator(parser, parameterValidator));\r\n\r\n    return generatorValidator;\r\n}\r\n\r\nQTEST_APPLESS_MAIN(tst_ComponentGeneratorValidator)\r\n\r\n#include \"tst_ComponentGeneratorValidator.moc\"\r\n"
  },
  {
    "path": "tests/IPXACTmodels/Component/tst_ComponentGeneratorValidator.pri",
    "content": "# ----------------------------------------------------\r\n# This file is generated by the Qt Visual Studio Tools.\r\n# ------------------------------------------------------\r\n\r\n# This is a reminder that you are using a generated .pro file.\r\n# Remove it when you are finished editing this file.\r\nmessage(\"You are running qmake on a generated .pro file. This may not work!\")\r\n\r\n\r\nSOURCES += ./tst_ComponentGeneratorValidator.cpp\r\n"
  },
  {
    "path": "tests/IPXACTmodels/Component/tst_ComponentGeneratorValidator.pro",
    "content": "#-----------------------------------------------------------------------------\r\n# File: tst_ComponentGeneratorValidator.pro\r\n#-----------------------------------------------------------------------------\r\n# Project: Kactus 2\r\n# Author: Mikko Teuho\r\n# Date: 07.01.2016\r\n#\r\n# Description:\r\n# Qt project file template for running unit tests for a single module.\r\n#-----------------------------------------------------------------------------\r\n\r\nTEMPLATE = app\r\n\r\nTARGET = tst_ComponentGeneratorValidator\r\n\r\nQT += core gui xml testlib\r\n\r\nCONFIG += c++11 testcase console\r\n\r\nlinux-g++ | linux-g++-64 | linux-g++-32 {\r\n LIBS += -L../../../executable \\\r\n     -lIPXACTmodels \\\r\n     -lKactusAPI\r\n\r\n}\r\nwin64 | win32 {\r\n LIBS += -L../../../executable \\\r\n     -lIPXACTmodelsd \\\r\n     -lKactusAPId\r\n}\r\n\r\nINCLUDEPATH += $$DESTDIR\r\nINCLUDEPATH += ../../../\r\n\r\nDEPENDPATH += .\r\nDEPENDPATH += ../../../\r\n\r\nOBJECTS_DIR += $$DESTDIR\r\n\r\nMOC_DIR += ./generatedFiles\r\nUI_DIR += ./generatedFiles\r\nRCC_DIR += ./generatedFiles\r\ninclude(tst_ComponentGeneratorValidator.pri)\r\n"
  },
  {
    "path": "tests/IPXACTmodels/Component/tst_ComponentGeneratorWriter.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: tst_ComponentGeneratorWriter.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Janne Virtanen\r\n// Date: 05.10.2015\r\n//\r\n// Description:\r\n// Unit test for class ComponentGeneratorWriter.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include <IPXACTmodels/Component/ComponentGeneratorWriter.h>\r\n\r\n#include <IPXACTmodels/common/Parameter.h>\r\n\r\n#include <IPXACTmodels/common/GenericVendorExtension.h>\r\n#include <IPXACTmodels/common/VendorExtension.h>\r\n#include <IPXACTmodels/common/Document.h>\r\n\r\n#include <IPXACTmodels/kactusExtensions/Kactus2Placeholder.h>\r\n\r\n#include <QtTest>\r\n\r\nclass tst_ComponentGeneratorWriter : public QObject\r\n{\r\n    Q_OBJECT\r\n\r\npublic:\r\n\ttst_ComponentGeneratorWriter();\r\n\r\nprivate slots:\r\n\tvoid init();\r\n\tvoid cleanup();\r\n\r\n\tvoid testWriteAttributes();\r\n\tvoid testWriteComponentGenerator();\r\n\tvoid testWritePhase();\r\n\tvoid testWriteAPI();\r\n\tvoid testWriteApiService();\r\n\tvoid testWriteGeneratorExe();\r\n\tvoid testWriteGroups();\r\n\tvoid testWriteParameter();\r\n    void testWriteCompleteGenerator();\r\n\r\nprivate:\r\n\r\n\tQSharedPointer<ComponentGenerator> testComponentGenerator_;\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ComponentGeneratorWriter::tst_ComponentGeneratorWriter()\r\n//-----------------------------------------------------------------------------\r\ntst_ComponentGeneratorWriter::tst_ComponentGeneratorWriter()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ComponentGeneratorWriter::init()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ComponentGeneratorWriter::init()\r\n{\r\n\ttestComponentGenerator_ = QSharedPointer<ComponentGenerator>(new ComponentGenerator());\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ComponentGeneratorWriter::cleanup()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ComponentGeneratorWriter::cleanup()\r\n{\r\n\ttestComponentGenerator_.clear();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ComponentGeneratorWriter::testWriteAttributes()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ComponentGeneratorWriter::testWriteAttributes()\r\n{\r\n    testComponentGenerator_->setName(\"testGenerator\");\r\n\ttestComponentGenerator_->setHidden(true);\r\n\ttestComponentGenerator_->setScope(ComponentGenerator::Scope::ENTITY);\r\n\r\n\tQString expectedOutput(\r\n\t\t\"<ipxact:componentGenerator hidden=\\\"true\\\" scope=\\\"entity\\\">\"\r\n\t\t    \"<ipxact:name>testGenerator</ipxact:name>\"\t\t\r\n\t\t\"</ipxact:componentGenerator>\"\r\n\t\t);\r\n\r\n    QString output;\r\n    QXmlStreamWriter xmlStreamWriter(&output);\r\n\r\n\tComponentGeneratorWriter::writeComponentGenerator(xmlStreamWriter, testComponentGenerator_, Document::Revision::Std14);\r\n\tQCOMPARE(output, expectedOutput);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ComponentGeneratorWriter::testWriteComponentGenerator()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ComponentGeneratorWriter::testWriteComponentGenerator()\r\n{\r\n\ttestComponentGenerator_->setName(\"test\");\r\n\ttestComponentGenerator_->setDisplayName(\"testDisplay\");\r\n\ttestComponentGenerator_->setDescription(\"testDescription\");\r\n\r\n\tQString expectedOutput(\r\n\t\t\"<ipxact:componentGenerator>\"\r\n\t\t    \"<ipxact:name>test</ipxact:name>\"\r\n\t\t    \"<ipxact:displayName>testDisplay</ipxact:displayName>\"\r\n\t\t    \"<ipxact:description>testDescription</ipxact:description>\"\r\n\t\t\"</ipxact:componentGenerator>\"\r\n\t\t);\r\n\r\n    QString output;\r\n    QXmlStreamWriter xmlStreamWriter(&output);\r\n\r\n\tComponentGeneratorWriter::writeComponentGenerator(xmlStreamWriter, testComponentGenerator_, Document::Revision::Std14);\r\n\tQCOMPARE(output, expectedOutput);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ComponentGeneratorWriter::testWritePhase()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ComponentGeneratorWriter::testWritePhase()\r\n{\r\n    testComponentGenerator_->setName(\"testGenerator\");\r\n\ttestComponentGenerator_->setPhase(\"13.37\");\r\n\r\n\tQString expectedOutput(\r\n\t\t\"<ipxact:componentGenerator>\"\r\n\t\t    \"<ipxact:name>testGenerator</ipxact:name>\"\r\n\t\t    \"<ipxact:phase>13.37</ipxact:phase>\"\r\n\t\t\"</ipxact:componentGenerator>\"\r\n\t\t);\r\n\r\n    QString output;\r\n    QXmlStreamWriter xmlStreamWriter(&output);\r\n\r\n\tComponentGeneratorWriter::writeComponentGenerator(xmlStreamWriter, testComponentGenerator_, Document::Revision::Std14);\r\n\tQCOMPARE(output, expectedOutput);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ComponentGeneratorWriter::testWriteAPI()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ComponentGeneratorWriter::testWriteAPI()\r\n{\r\n    testComponentGenerator_->setName(\"testGenerator\");\r\n\ttestComponentGenerator_->setApiType(ComponentGenerator::ApiType::TGI_2014_EXTENDED);\r\n\r\n\tQString expectedOutput(\r\n\t\t\"<ipxact:componentGenerator>\"\r\n\t\t    \"<ipxact:name>testGenerator</ipxact:name>\"\r\n\t\t    \"<ipxact:apiType>TGI_2014_EXTENDED</ipxact:apiType>\"\r\n\t\t\"</ipxact:componentGenerator>\"\r\n\t\t);\r\n\r\n    QString output;\r\n    QXmlStreamWriter xmlStreamWriter(&output);\r\n\r\n\tComponentGeneratorWriter::writeComponentGenerator(xmlStreamWriter, testComponentGenerator_, Document::Revision::Std14);\r\n\tQCOMPARE(output, expectedOutput);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ComponentGeneratorWriter::testWriteApiService()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ComponentGeneratorWriter::testWriteApiService()\r\n{\r\n\ttestComponentGenerator_->setName(\"testGenerator\");\r\n\ttestComponentGenerator_->setApiType(ComponentGenerator::ApiType::TBGI_2022_EXTENDED);\r\n\ttestComponentGenerator_->setApiService(\"REST\");\r\n\r\n\tQString expectedOutput(\r\n\t\t\"<ipxact:componentGenerator>\"\r\n\t\t    \"<ipxact:name>testGenerator</ipxact:name>\"\r\n\t\t    \"<ipxact:apiType>TBGI_2022_EXTENDED</ipxact:apiType>\"\r\n\t\t    \"<ipxact:apiService>REST</ipxact:apiService>\"\r\n\t\t\"</ipxact:componentGenerator>\"\r\n\t\t);\r\n\r\n    QString output;\r\n    QXmlStreamWriter xmlStreamWriter(&output);\r\n\r\n\tComponentGeneratorWriter::writeComponentGenerator(xmlStreamWriter, testComponentGenerator_, Document::Revision::Std22);\r\n\tQCOMPARE(output, expectedOutput);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ComponentGeneratorWriter::testWriteGeneratorExe()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ComponentGeneratorWriter::testWriteGeneratorExe()\r\n{\r\n    testComponentGenerator_->setName(\"testGenerator\");\r\n\ttestComponentGenerator_->setGeneratorExe(\"/bin/bash.exe\");\r\n\r\n\tQString expectedOutput(\r\n\t\t\"<ipxact:componentGenerator>\"\r\n\t\t    \"<ipxact:name>testGenerator</ipxact:name>\"\r\n\t\t    \"<ipxact:generatorExe>/bin/bash.exe</ipxact:generatorExe>\"\r\n\t\t\"</ipxact:componentGenerator>\"\r\n\t\t);\r\n\r\n    QString output;\r\n    QXmlStreamWriter xmlStreamWriter(&output);\r\n\r\n\tComponentGeneratorWriter::writeComponentGenerator(xmlStreamWriter, testComponentGenerator_, Document::Revision::Std14);\r\n\tQCOMPARE(output, expectedOutput);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ComponentGeneratorWriter::testWriteGroups()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ComponentGeneratorWriter::testWriteGroups()\r\n{\r\n    testComponentGenerator_->setName(\"testGenerator\");\r\n\r\n\tQStringList groups;\r\n\tgroups.append(\"makeGenerator\");\r\n\tgroups.append(\"hdlGenerator\");\r\n\ttestComponentGenerator_->setGroups(groups);\r\n\r\n\tQString expectedOutput(\r\n\t\t\"<ipxact:componentGenerator>\"\r\n\t\t    \"<ipxact:name>testGenerator</ipxact:name>\"\r\n\t\t    \"<ipxact:group>makeGenerator</ipxact:group>\"\r\n\t\t    \"<ipxact:group>hdlGenerator</ipxact:group>\"\r\n\t\t\"</ipxact:componentGenerator>\"\r\n\t\t);\r\n\r\n    QString output;\r\n    QXmlStreamWriter xmlStreamWriter(&output);\r\n\r\n\tComponentGeneratorWriter::writeComponentGenerator(xmlStreamWriter, testComponentGenerator_, Document::Revision::Std14);\r\n\tQCOMPARE(output, expectedOutput);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ComponentGeneratorWriter::testWriteParameter()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ComponentGeneratorWriter::testWriteParameter()\r\n{\r\n\tQSharedPointer<Parameter> testParameter(new Parameter());\r\n\ttestParameter->setName(\"generatorParameter\");\r\n\ttestParameter->setValueId(\"id1\");\r\n\ttestParameter->setValue(\"5\");\r\n\ttestParameter->setType(\"shortint\");\r\n\ttestParameter->setAttribute(\"prompt\", \"Parm 1\");\r\n\ttestParameter->setAttribute(\"resolve\", \"user\");\r\n\ttestParameter->setDescription(\"First generator parameter.\");\r\n\r\n\ttestComponentGenerator_->getParameters()->append(testParameter);\r\n\r\n\tQString expectedOutput(\r\n\t\t\"<ipxact:componentGenerator>\"\r\n\t\t    \"<ipxact:name></ipxact:name>\"\r\n\t\t    \"<ipxact:parameters>\"\r\n\t\t        \"<ipxact:parameter parameterId=\\\"id1\\\" prompt=\\\"Parm 1\\\" resolve=\\\"user\\\" type=\\\"shortint\\\">\"\r\n\t\t            \"<ipxact:name>generatorParameter</ipxact:name>\"\r\n\t\t            \"<ipxact:description>First generator parameter.</ipxact:description>\"\r\n\t\t            \"<ipxact:value>5</ipxact:value>\"\r\n\t\t        \"</ipxact:parameter>\"\r\n\t\t    \"</ipxact:parameters>\"\r\n\t\t\"</ipxact:componentGenerator>\"\r\n\t\t);\r\n\r\n    QString output;\r\n    QXmlStreamWriter xmlStreamWriter(&output);\r\n\r\n\tComponentGeneratorWriter::writeComponentGenerator(xmlStreamWriter, testComponentGenerator_, Document::Revision::Std14);\r\n\tQCOMPARE(output, expectedOutput);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ComponentGeneratorWriter::testWriteCompleteGenerator()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ComponentGeneratorWriter::testWriteCompleteGenerator()\r\n{\r\n    testComponentGenerator_->setHidden(false);\r\n    testComponentGenerator_->setScope(ComponentGenerator::Scope::INSTANCE);\r\n    testComponentGenerator_->setName(\"fullGenerator\");\r\n    testComponentGenerator_->setPhase(\"id1\");\r\n    \r\n    QSharedPointer<Parameter> testParameter(new Parameter());\r\n    testParameter->setName(\"phaseParameter\");\r\n    testParameter->setValueId(\"id1\");\r\n    testParameter->setValue(\"1\");\r\n \r\n    testComponentGenerator_->getParameters()->append(testParameter);\r\n\r\n    testComponentGenerator_->setApiType(ComponentGenerator::ApiType::TGI_2009);\r\n    \r\n    QStringList transportMethods;\r\n    transportMethods << \"file\";\r\n    testComponentGenerator_->setTransportMethods(transportMethods);\r\n\r\n    testComponentGenerator_->setGeneratorExe(\"/bin/tools/generators/do_all.exe\");\r\n    \r\n    QSharedPointer<VendorExtension> testExtension(new Kactus2Placeholder(\"kactus2:testExtension\"));\r\n    testComponentGenerator_->getVendorExtensions()->append(testExtension);\r\n\r\n    QStringList testGroups;\r\n    testGroups << \"globalGenerators\";\r\n    testComponentGenerator_->setGroups(testGroups);\r\n\r\n    QString expectedOutput(\r\n        \"<ipxact:componentGenerator hidden=\\\"false\\\" scope=\\\"instance\\\">\"\r\n            \"<ipxact:name>fullGenerator</ipxact:name>\"\r\n            \"<ipxact:phase>id1</ipxact:phase>\"\r\n            \"<ipxact:parameters>\"\r\n                \"<ipxact:parameter parameterId=\\\"id1\\\">\"\r\n                    \"<ipxact:name>phaseParameter</ipxact:name>\"\r\n                    \"<ipxact:value>1</ipxact:value>\"\r\n                \"</ipxact:parameter>\"\r\n            \"</ipxact:parameters>\"\r\n            \"<ipxact:apiType>TGI_2009</ipxact:apiType>\"\r\n            \"<ipxact:transportMethods>\"\r\n                \"<ipxact:transportMethod>file</ipxact:transportMethod>\"\r\n            \"</ipxact:transportMethods>\"\r\n            \"<ipxact:generatorExe>/bin/tools/generators/do_all.exe</ipxact:generatorExe>\"\r\n            \"<ipxact:vendorExtensions>\"\r\n                \"<kactus2:testExtension/>\"\r\n            \"</ipxact:vendorExtensions>\"\r\n            \"<ipxact:group>globalGenerators</ipxact:group>\"            \r\n        \"</ipxact:componentGenerator>\"\r\n        );\r\n\r\n    QString output;\r\n    QXmlStreamWriter xmlStreamWriter(&output);\r\n\r\n    ComponentGeneratorWriter::writeComponentGenerator(xmlStreamWriter, testComponentGenerator_, Document::Revision::Std14);\r\n    QCOMPARE(output, expectedOutput);\r\n}\r\n\r\nQTEST_APPLESS_MAIN(tst_ComponentGeneratorWriter)\r\n\r\n#include \"tst_ComponentGeneratorWriter.moc\"\r\n"
  },
  {
    "path": "tests/IPXACTmodels/Component/tst_ComponentGeneratorWriter.pri",
    "content": "# ----------------------------------------------------\r\n# This file is generated by the Qt Visual Studio Add-in.\r\n# ------------------------------------------------------\r\n\r\n\r\nSOURCES += ./tst_ComponentGeneratorWriter.cpp \r\n  "
  },
  {
    "path": "tests/IPXACTmodels/Component/tst_ComponentGeneratorWriter.pro",
    "content": "#-----------------------------------------------------------------------------\r\n# File: tst_ComponentGeneratorWriter.pro\r\n#-----------------------------------------------------------------------------\r\n# Project: Kactus 2\r\n# Author: Janne Virtanen\r\n# Date: 05.10.2015\r\n#\r\n# Description:\r\n# Qt project file template for running unit tests for ComponentGenerator writer.\r\n#-----------------------------------------------------------------------------\r\n\r\nTEMPLATE = app\r\n\r\nTARGET = tst_ComponentGeneratorWriter\r\n\r\nQT += core xml testlib\r\nQT -= gui\r\n\r\nCONFIG += c++11 testcase console\r\n\r\nlinux-g++ | linux-g++-64 | linux-g++-32 {\r\n LIBS += -L../../../executable \\\r\n     -lIPXACTmodels\r\n\r\n}\r\nwin64 | win32 {\r\n LIBS += -L../../../executable \\\r\n     -lIPXACTmodelsd\r\n}\r\n\r\nINCLUDEPATH += $$DESTDIR\r\nINCLUDEPATH += ../../../\r\n\r\nDEPENDPATH += .\r\nDEPENDPATH += ../../../\r\n\r\nOBJECTS_DIR += $$DESTDIR\r\n\r\nMOC_DIR += ./generatedFiles\r\nUI_DIR += ./generatedFiles\r\nRCC_DIR += ./generatedFiles\r\ninclude(tst_ComponentGeneratorWriter.pri)\r\n"
  },
  {
    "path": "tests/IPXACTmodels/Component/tst_ComponentPortReader.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: tst_ComponentPortReader::cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 14.09.2015\r\n//\r\n// Description:\r\n// Unit test for class tst_ComponentPortReader::\r\n//-----------------------------------------------------------------------------\r\n\r\n#include <IPXACTmodels/Component/PortReader.h>\r\n#include <IPXACTmodels/Component/Structured.h>\r\n\r\n#include <IPXACTmodels/common/VendorExtension.h>\r\n\r\n#include <QtTest>\r\n#include <QDomDocument>\r\n\r\nclass tst_ComponentPortReader : public QObject\r\n{\r\n    Q_OBJECT\r\n\r\n\r\nprivate slots:\r\n\r\n    void readSimplePort();\r\n    void readSimpleTransactionalPort();\r\n    void readPortPresence();\r\n    void readPortArrays();\r\n    void readPortExtensions();\r\n    void readPortAdHocVisibility();\r\n    void readPortPosition();\r\n    void readPortTags();\r\n\r\n    void readWirePortAllLogicalDirectionsAllowed();\r\n    void readWirePortVectors();\r\n    void readWirePortVectors_2022();\r\n    void readWireTypeDefinitions();\r\n    void readWireDriver();\r\n    void readWireDefaultDriver();\r\n    void readWireQualifiers_2022();\r\n\r\n    void readTransactionalAllLogicalInitiativesAllowed();\r\n    void readTransactionalKind();\r\n    void readTransactionalBusWidth();\r\n    void readTransactionalProtocol();\r\n    void readTransactionalTypeDefinitions();\r\n    void readTransactionalConnectionMinMax();\r\n\r\n    void readStrucuredType_2022();\r\n    void readStrucuredType_2022_data();\r\n    void readStructuredVectors_2022();\r\n    void readStructuredSubPortWire_2022();\r\n    void readNestedStructuredSubPort_2022();\r\n    void readSubPortArrays_2022();\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ComponentPortReader::readSimplePort()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ComponentPortReader::readSimplePort()\r\n{\r\n    QString documentContent(\r\n        \"<ipxact:port>\"\r\n            \"<ipxact:name>testPort</ipxact:name>\"\r\n            \"<ipxact:displayName>PortorDisplay</ipxact:displayName>\"\r\n            \"<ipxact:description>PortorDescription</ipxact:description>\"\r\n            \"<ipxact:wire>\"\r\n                \"<ipxact:direction>in</ipxact:direction>\"\r\n            \"</ipxact:wire>\"\r\n        \"</ipxact:port>\"\r\n        );\r\n\r\n\r\n    QDomDocument document;\r\n    document.setContent(documentContent);\r\n\r\n    QDomNode portNode = document.firstChildElement(\"ipxact:port\");\r\n\r\n    QSharedPointer<Port> testPort = PortReader::createPortFrom(portNode, Document::Revision::Std14);\r\n\r\n    QCOMPARE(testPort->name(), QString(\"testPort\"));\r\n    QCOMPARE(testPort->displayName(), QString(\"PortorDisplay\"));\r\n    QCOMPARE(testPort->description(), QString(\"PortorDescription\"));\r\n\r\n    QCOMPARE(testPort->getWire().isNull(), false);\r\n    QCOMPARE(testPort->getTransactional().isNull(), true);\r\n    QCOMPARE(testPort->getDirection(), DirectionTypes::IN);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ComponentPortReader::readSimpleTransactionalPort()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ComponentPortReader::readSimpleTransactionalPort()\r\n{\r\n    QString documentContent(\r\n        \"<ipxact:port>\"\r\n            \"<ipxact:name>testPort</ipxact:name>\"\r\n            \"<ipxact:displayName>PortorDisplay</ipxact:displayName>\"\r\n            \"<ipxact:description>PortorDescription</ipxact:description>\"\r\n            \"<ipxact:transactional>\"\r\n                \"<ipxact:initiative>provides</ipxact:initiative>\"\r\n            \"</ipxact:transactional>\"\r\n        \"</ipxact:port>\"\r\n        );\r\n\r\n\r\n    QDomDocument document;\r\n    document.setContent(documentContent);\r\n\r\n    QDomNode portNode = document.firstChildElement(\"ipxact:port\");\r\n\r\n    QSharedPointer<Port> testPort = PortReader::createPortFrom(portNode, Document::Revision::Std14);\r\n\r\n    QCOMPARE(testPort->name(), QString(\"testPort\"));\r\n    QCOMPARE(testPort->displayName(), QString(\"PortorDisplay\"));\r\n    QCOMPARE(testPort->description(), QString(\"PortorDescription\"));\r\n\r\n    QCOMPARE(testPort->getWire().isNull(), true);\r\n    QCOMPARE(testPort->getTransactional().isNull(), false);\r\n    QCOMPARE(testPort->getTransactional()->getInitiative(), QString(\"provides\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ComponentPortReader::readPortPresence()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ComponentPortReader::readPortPresence()\r\n{\r\n    QString documentContent(\r\n        \"<ipxact:port>\"\r\n            \"<ipxact:name>testPort</ipxact:name>\"\r\n            \"<ipxact:isPresent>4-2*2+1</ipxact:isPresent>\"\r\n            \"<ipxact:wire>\"\r\n                \"<ipxact:direction>out</ipxact:direction>\"\r\n            \"</ipxact:wire>\"\r\n        \"</ipxact:port>\"\r\n        );\r\n\r\n\r\n    QDomDocument document;\r\n    document.setContent(documentContent);\r\n\r\n    QDomNode portNode = document.firstChildElement(\"ipxact:port\");\r\n\r\n    QSharedPointer<Port> testPort = PortReader::createPortFrom(portNode, Document::Revision::Std14);\r\n\r\n    QCOMPARE(testPort->name(), QString(\"testPort\"));\r\n    QCOMPARE(testPort->getIsPresent(), QString(\"4-2*2+1\"));\r\n\r\n    QCOMPARE(testPort->getWire().isNull(), false);\r\n    QCOMPARE(testPort->getTransactional().isNull(), true);\r\n    QCOMPARE(testPort->getDirection(), DirectionTypes::OUT);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ComponentPortReader::readPortArrays()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ComponentPortReader::readPortArrays()\r\n{\r\n    QString documentContent(\r\n        \"<ipxact:port>\"\r\n            \"<ipxact:name>testPort</ipxact:name>\"\r\n            \"<ipxact:transactional>\"\r\n                \"<ipxact:initiative>requires</ipxact:initiative>\"\r\n            \"</ipxact:transactional>\"\r\n            \"<ipxact:arrays>\"\r\n                \"<ipxact:array>\"\r\n                    \"<ipxact:left>4+4</ipxact:left>\"\r\n                    \"<ipxact:right>18</ipxact:right>\"\r\n                \"</ipxact:array>\"\r\n            \"</ipxact:arrays>\"\r\n        \"</ipxact:port>\"\r\n        );\r\n\r\n\r\n    QDomDocument document;\r\n    document.setContent(documentContent);\r\n\r\n    QDomNode portNode = document.firstChildElement(\"ipxact:port\");\r\n\r\n    QSharedPointer<Port> testPort = PortReader::createPortFrom(portNode, Document::Revision::Std14);\r\n\r\n    QCOMPARE(testPort->name(), QString(\"testPort\"));\r\n    QCOMPARE(testPort->getArrays()->size(), 1);\r\n    QCOMPARE(testPort->getArrayLeft(), QString(\"4+4\"));\r\n    QCOMPARE(testPort->getArrayRight(), QString(\"18\"));\r\n\r\n    QCOMPARE(testPort->getWire().isNull(), true);\r\n    QCOMPARE(testPort->getTransactional().isNull(), false);\r\n    QCOMPARE(testPort->getTransactional()->getInitiative(), QString(\"requires\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ComponentPortReader::readPortExtensions()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ComponentPortReader::readPortExtensions()\r\n{\r\n    QString documentContent(\r\n        \"<ipxact:port>\"\r\n            \"<ipxact:name>testPort</ipxact:name>\"\r\n            \"<ipxact:wire>\"\r\n                \"<ipxact:direction>out</ipxact:direction>\"\r\n            \"</ipxact:wire>\"\r\n            \"<ipxact:vendorExtensions>\"\r\n                \"<testExtension testExtensionAttribute=\\\"extension\\\">testValue</testExtension>\"\r\n            \"</ipxact:vendorExtensions>\"\r\n        \"</ipxact:port>\"\r\n        );\r\n\r\n\r\n    QDomDocument document;\r\n    document.setContent(documentContent);\r\n\r\n    QDomNode portNode = document.firstChildElement(\"ipxact:port\");\r\n\r\n    QSharedPointer<Port> testPort = PortReader::createPortFrom(portNode, Document::Revision::Std14);\r\n\r\n    QCOMPARE(testPort->name(), QString(\"testPort\"));\r\n    QCOMPARE(testPort->getVendorExtensions()->size(), 1);\r\n    QCOMPARE(testPort->getVendorExtensions()->first()->type(), QString(\"testExtension\"));\r\n\r\n    QCOMPARE(testPort->getWire().isNull(), false);\r\n    QCOMPARE(testPort->getTransactional().isNull(), true);\r\n    QCOMPARE(testPort->getDirection(), DirectionTypes::OUT);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ComponentPortReader::readPortAdHocVisibility()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ComponentPortReader::readPortAdHocVisibility()\r\n{\r\n    QString documentContent(\r\n        \"<ipxact:port>\"\r\n            \"<ipxact:name>testPort</ipxact:name>\"\r\n            \"<ipxact:wire>\"\r\n                \"<ipxact:direction>in</ipxact:direction>\"\r\n            \"</ipxact:wire>\"\r\n            \"<ipxact:vendorExtensions>\"\r\n                \"<kactus2:adHocVisible/>\"\r\n            \"</ipxact:vendorExtensions>\"\r\n        \"</ipxact:port>\"\r\n        );\r\n\r\n\r\n    QDomDocument document;\r\n    document.setContent(documentContent);\r\n\r\n    QDomNode portNode = document.firstChildElement(\"ipxact:port\");\r\n\r\n    QSharedPointer<Port> testPort = PortReader::createPortFrom(portNode, Document::Revision::Std14);\r\n\r\n    QCOMPARE(testPort->name(), QString(\"testPort\"));\r\n    QCOMPARE(testPort->getVendorExtensions()->size(), 1);\r\n    QCOMPARE(testPort->isAdHocVisible(), true);\r\n\r\n    QCOMPARE(testPort->getWire().isNull(), false);\r\n    QCOMPARE(testPort->getTransactional().isNull(), true);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ComponentPortReader::readPortPosition()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ComponentPortReader::readPortPosition()\r\n{\r\n    QString documentContent(\r\n        \"<ipxact:port>\"\r\n            \"<ipxact:name>testPort</ipxact:name>\"\r\n            \"<ipxact:wire>\"\r\n                \"<ipxact:direction>in</ipxact:direction>\"\r\n            \"</ipxact:wire>\"\r\n            \"<ipxact:vendorExtensions>\"\r\n                \"<kactus2:position x=\\\"1\\\" y=\\\"1\\\"/>\"\r\n            \"</ipxact:vendorExtensions>\"\r\n        \"</ipxact:port>\"\r\n        );\r\n\r\n\r\n    QDomDocument document;\r\n    document.setContent(documentContent);\r\n\r\n    QDomNode portNode = document.firstChildElement(\"ipxact:port\");\r\n\r\n    QSharedPointer<Port> testPort = PortReader::createPortFrom(portNode, Document::Revision::Std14);\r\n\r\n    QCOMPARE(testPort->name(), QString(\"testPort\"));\r\n    QCOMPARE(testPort->getVendorExtensions()->size(), 1);\r\n    QCOMPARE(testPort->getDefaultPos().x(), qreal(1));\r\n    QCOMPARE(testPort->getDefaultPos().y(), qreal(1));\r\n\r\n    QCOMPARE(testPort->getWire().isNull(), false);\r\n    QCOMPARE(testPort->getTransactional().isNull(), true);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ComponentPortReader::readPortTags()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ComponentPortReader::readPortTags()\r\n{\r\n    QString documentContent(\r\n        \"<ipxact:port>\"\r\n            \"<ipxact:name>testPort</ipxact:name>\"\r\n            \"<ipxact:wire>\"\r\n                \"<ipxact:direction>in</ipxact:direction>\"\r\n            \"</ipxact:wire>\"\r\n            \"<ipxact:vendorExtensions>\"\r\n                \"<kactus2:portTags>oyoroi,yuJing,guilang,tags</kactus2:portTags>\"\r\n            \"</ipxact:vendorExtensions>\"\r\n        \"</ipxact:port>\"\r\n        );\r\n\r\n\r\n    QDomDocument document;\r\n    document.setContent(documentContent);\r\n\r\n    QDomNode portNode = document.firstChildElement(\"ipxact:port\");\r\n\r\n    QSharedPointer<Port> testPort = PortReader::createPortFrom(portNode, Document::Revision::Std14);\r\n\r\n    QCOMPARE(testPort->name(), QString(\"testPort\"));\r\n    QCOMPARE(testPort->getVendorExtensions()->size(), 1);\r\n    QCOMPARE(testPort->getPortTags(), QString(\"oyoroi,yuJing,guilang,tags\"));\r\n\r\n    QCOMPARE(testPort->getWire().isNull(), false);\r\n    QCOMPARE(testPort->getTransactional().isNull(), true);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ComponentPortReader::readWirePortAllLogicalDirectionsAllowed()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ComponentPortReader::readWirePortAllLogicalDirectionsAllowed()\r\n{\r\n    QString documentContent(\r\n        \"<ipxact:port>\"\r\n            \"<ipxact:name>testPort</ipxact:name>\"\r\n            \"<ipxact:wire allLogicalDirectionsAllowed=\\\"true\\\">\"\r\n                \"<ipxact:direction>in</ipxact:direction>\"\r\n            \"</ipxact:wire>\"\r\n        \"</ipxact:port>\"\r\n        );\r\n\r\n\r\n    QDomDocument document;\r\n    document.setContent(documentContent);\r\n\r\n    QDomNode portNode = document.firstChildElement(\"ipxact:port\");\r\n\r\n    QSharedPointer<Port> testPort = PortReader::createPortFrom(portNode, Document::Revision::Std14);\r\n\r\n    QCOMPARE(testPort->name(), QString(\"testPort\"));\r\n\r\n    QCOMPARE(testPort->getTransactional().isNull(), true);\r\n    QCOMPARE(testPort->getWire().isNull(), false);\r\n\r\n    QCOMPARE(testPort->allLogicalDirectionsAllowed(), true);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ComponentPortReader::readWirePortVectors()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ComponentPortReader::readWirePortVectors()\r\n{\r\n    QString documentContent(\r\n        \"<ipxact:port>\"\r\n            \"<ipxact:name>testPort</ipxact:name>\"\r\n            \"<ipxact:wire>\"\r\n                \"<ipxact:direction>out</ipxact:direction>\"\r\n                \"<ipxact:vectors>\"\r\n                    \"<ipxact:vector>\"\r\n                        \"<ipxact:left>4+18-Yaoxao</ipxact:left>\"\r\n                        \"<ipxact:right>Yaoxao</ipxact:right>\"\r\n                    \"</ipxact:vector>\"\r\n                    \"<ipxact:vector>\"\r\n                        \"<ipxact:left>1</ipxact:left>\"\r\n                        \"<ipxact:right>0</ipxact:right>\"\r\n                    \"</ipxact:vector>\"\r\n                \"</ipxact:vectors>\"\r\n            \"</ipxact:wire>\"\r\n        \"</ipxact:port>\"\r\n        );\r\n\r\n\r\n    QDomDocument document;\r\n    document.setContent(documentContent);\r\n\r\n    QDomNode portNode = document.firstChildElement(\"ipxact:port\");\r\n\r\n    QSharedPointer<Port> testPort = PortReader::createPortFrom(portNode, Document::Revision::Std14);\r\n\r\n    QCOMPARE(testPort->name(), QString(\"testPort\"));\r\n\r\n    QCOMPARE(testPort->getTransactional().isNull(), true);\r\n    QCOMPARE(testPort->getWire().isNull(), false);\r\n    QCOMPARE(testPort->getWire()->getVectors()->count(), 2);\r\n\r\n    auto const& vector = testPort->getWire()->getVectors()->first();\r\n    QCOMPARE(vector.getLeft(), QStringLiteral(\"4+18-Yaoxao\"));\r\n    QCOMPARE(vector.getRight(), QStringLiteral(\"Yaoxao\"));\r\n    QCOMPARE(vector.getId(), QString());\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ComponentPortReader::readWirePortVectors_2022()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ComponentPortReader::readWirePortVectors_2022()\r\n{\r\n    QString documentContent(\r\n        \"<ipxact:port>\"\r\n            \"<ipxact:name>testPort</ipxact:name>\"\r\n            \"<ipxact:wire>\"\r\n                \"<ipxact:direction>out</ipxact:direction>\"\r\n                \"<ipxact:vectors>\"\r\n                    \"<ipxact:vector vectorId=\\\"testVector\\\">\"\r\n                        \"<ipxact:left>1</ipxact:left>\"\r\n                        \"<ipxact:right>0</ipxact:right>\"\r\n                    \"</ipxact:vector>\"\r\n                \"</ipxact:vectors>\"\r\n            \"</ipxact:wire>\"\r\n        \"</ipxact:port>\"\r\n        );\r\n\r\n\r\n    QDomDocument document;\r\n    document.setContent(documentContent);\r\n\r\n    QDomNode portNode = document.firstChildElement(\"ipxact:port\");\r\n\r\n    QSharedPointer<Port> testPort = PortReader::createPortFrom(portNode, Document::Revision::Std22);\r\n\r\n    QCOMPARE(testPort->name(), QString(\"testPort\"));\r\n\r\n    QCOMPARE(testPort->getTransactional().isNull(), true);\r\n    QCOMPARE(testPort->getWire().isNull(), false);\r\n\r\n    auto const& vector = testPort->getWire()->getVectors()->first();\r\n    QCOMPARE(vector.getLeft(), QStringLiteral(\"1\"));\r\n    QCOMPARE(vector.getRight(), QStringLiteral(\"0\"));\r\n    QCOMPARE(vector.getId(), QStringLiteral(\"testVector\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ComponentPortReader::readWireTypeDefinitions()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ComponentPortReader::readWireTypeDefinitions()\r\n{\r\n    QString documentContent(\r\n        \"<ipxact:port>\"\r\n            \"<ipxact:name>testPort</ipxact:name>\"\r\n            \"<ipxact:wire>\"\r\n                \"<ipxact:direction>out</ipxact:direction>\"\r\n                \"<ipxact:wireTypeDefs>\"\r\n                    \"<ipxact:wireTypeDef>\"\r\n                        \"<ipxact:typeName constrained=\\\"true\\\">testType</ipxact:typeName>\"\r\n                        \"<ipxact:typeDefinition>testTypeDefinition</ipxact:typeDefinition>\"\r\n                        \"<ipxact:viewRef>testView</ipxact:viewRef>\"\r\n                    \"</ipxact:wireTypeDef>\"\r\n                \"</ipxact:wireTypeDefs>\"\r\n            \"</ipxact:wire>\"\r\n        \"</ipxact:port>\"\r\n        );\r\n\r\n\r\n    QDomDocument document;\r\n    document.setContent(documentContent);\r\n\r\n    QDomNode portNode = document.firstChildElement(\"ipxact:port\");\r\n\r\n    QSharedPointer<Port> testPort = PortReader::createPortFrom(portNode, Document::Revision::Std14);\r\n\r\n    QCOMPARE(testPort->name(), QString(\"testPort\"));\r\n\r\n    QCOMPARE(testPort->getTransactional().isNull(), true);\r\n    QCOMPARE(testPort->getWire().isNull(), false);\r\n\r\n    QCOMPARE(testPort->getWire()->getWireTypeDefs()->size(), 1);\r\n    QSharedPointer<WireTypeDef> typeDefinition = testPort->getWire()->getWireTypeDefs()->first();\r\n    QCOMPARE(typeDefinition->getTypeName(), QString(\"testType\"));\r\n    QCOMPARE(typeDefinition->getTypeDefinitions()->size(), 1);\r\n    QCOMPARE(typeDefinition->getTypeDefinitions()->first(), QString(\"testTypeDefinition\"));\r\n    QCOMPARE(typeDefinition->getViewRefs()->size(), 1);\r\n    QCOMPARE(typeDefinition->getViewRefs()->first(), QString(\"testView\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ComponentPortReader::readWireDriver()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ComponentPortReader::readWireDriver()\r\n{\r\n    QString documentContent(\r\n        \"<ipxact:port>\"\r\n            \"<ipxact:name>testPort</ipxact:name>\"\r\n            \"<ipxact:wire>\"\r\n                \"<ipxact:direction>out</ipxact:direction>\"\r\n                \"<ipxact:drivers>\"\r\n                    \"<ipxact:driver>\"\r\n                        \"<ipxact:range>\"\r\n                            \"<ipxact:left>7</ipxact:left>\"\r\n                            \"<ipxact:right>0</ipxact:right>\"\r\n                        \"</ipxact:range>\"\r\n                        \"<ipxact:defaultValue>4+4-2</ipxact:defaultValue>\"\r\n                    \"</ipxact:driver>\"\r\n                \"</ipxact:drivers>\"\r\n            \"</ipxact:wire>\"\r\n        \"</ipxact:port>\"\r\n        );\r\n\r\n\r\n    QDomDocument document;\r\n    document.setContent(documentContent);\r\n\r\n    QDomNode portNode = document.firstChildElement(\"ipxact:port\");\r\n\r\n    QSharedPointer<Port> testPort = PortReader::createPortFrom(portNode, Document::Revision::Std14);\r\n\r\n    QCOMPARE(testPort->getTransactional().isNull(), true);\r\n    QCOMPARE(testPort->getWire().isNull(), false);\r\n    QCOMPARE(testPort->getDefaultValue(), QString(\"4+4-2\"));\r\n\r\n    auto wireRange = testPort->getWire()->getDriver()->getRange();\r\n    QCOMPARE(wireRange.getLeft(), QString(\"7\"));\r\n    QCOMPARE(wireRange.getRight(), QString(\"0\"));\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ComponentPortReader::readWireDefaultDriver()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ComponentPortReader::readWireDefaultDriver()\r\n{\r\n    QString documentContent(\r\n        \"<ipxact:port>\"\r\n            \"<ipxact:name>testPort</ipxact:name>\"\r\n            \"<ipxact:wire>\"\r\n                \"<ipxact:direction>out</ipxact:direction>\"\r\n                \"<ipxact:drivers>\"\r\n                    \"<ipxact:driver>\"\r\n                        \"<ipxact:defaultValue>4+4-2</ipxact:defaultValue>\"\r\n                    \"</ipxact:driver>\"\r\n                \"</ipxact:drivers>\"\r\n            \"</ipxact:wire>\"\r\n        \"</ipxact:port>\"\r\n        );\r\n\r\n\r\n    QDomDocument document;\r\n    document.setContent(documentContent);\r\n\r\n    QDomNode portNode = document.firstChildElement(\"ipxact:port\");\r\n\r\n    QSharedPointer<Port> testPort = PortReader::createPortFrom(portNode, Document::Revision::Std14);\r\n\r\n    QCOMPARE(testPort->name(), QString(\"testPort\"));\r\n\r\n    QCOMPARE(testPort->getTransactional().isNull(), true);\r\n    QCOMPARE(testPort->getWire().isNull(), false);\r\n    QCOMPARE(testPort->getDefaultValue(), QString(\"4+4-2\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ComponentPortReader::readWireQualifiers_2022()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ComponentPortReader::readWireQualifiers_2022()\r\n{\r\n     QString documentContent(\r\n        \"<ipxact:port>\"\r\n            \"<ipxact:name>testPort</ipxact:name>\"\r\n            \"<ipxact:wire>\"\r\n                \"<ipxact:direction>out</ipxact:direction>\"\r\n                \"<ipxact:qualifier>\"\r\n                    \"<ipxact:isData>true</ipxact:isData>\"\r\n                    \"<ipxact:isValid>true</ipxact:isValid>\"\r\n                    \"<ipxact:isInterrupt>false</ipxact:isInterrupt>\"\r\n                    \"<ipxact:isClockEn level=\\\"high\\\">true</ipxact:isClockEn>\"\r\n                \"</ipxact:qualifier>\"\r\n            \"</ipxact:wire>\"\r\n        \"</ipxact:port>\"\r\n        );\r\n\r\n\r\n    QDomDocument document;\r\n    document.setContent(documentContent);\r\n\r\n    QDomNode portNode = document.firstChildElement(\"ipxact:port\");\r\n\r\n    QSharedPointer<Port> testPort = PortReader::createPortFrom(portNode, Document::Revision::Std22);\r\n\r\n    QCOMPARE(testPort->getTransactional().isNull(), true);\r\n    \r\n    auto wire = testPort->getWire();\r\n    QCOMPARE(wire.isNull(), false);\r\n    QCOMPARE(wire->getQualifier()->hasType(Qualifier::Type::Data), true);\r\n    QCOMPARE(wire->getQualifier()->hasType(Qualifier::Type::Valid), true);\r\n    QCOMPARE(wire->getQualifier()->hasType(Qualifier::Type::Interrupt), false);\r\n    QCOMPARE(wire->getQualifier()->hasType(Qualifier::Type::ClockEnable), true);\r\n    QCOMPARE(wire->getQualifier()->getAttribute(Qualifier::Attribute::ClockEnableLevel), QString(\"high\"));\r\n}\r\n\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ComponentPortReader::readTransactionalAllLogicalInitiativesAllowed()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ComponentPortReader::readTransactionalAllLogicalInitiativesAllowed()\r\n{\r\n    QString documentContent(\r\n        \"<ipxact:port>\"\r\n            \"<ipxact:name>testPort</ipxact:name>\"\r\n            \"<ipxact:transactional allLogicalInitiativesAllowed=\\\"true\\\">\"\r\n                \"<ipxact:initiative>provides</ipxact:initiative>\"\r\n            \"</ipxact:transactional>\"\r\n        \"</ipxact:port>\"\r\n        );\r\n\r\n\r\n    QDomDocument document;\r\n    document.setContent(documentContent);\r\n\r\n    QDomNode portNode = document.firstChildElement(\"ipxact:port\");\r\n\r\n    QSharedPointer<Port> testPort = PortReader::createPortFrom(portNode, Document::Revision::Std14);\r\n\r\n    QCOMPARE(testPort->name(), QString(\"testPort\"));\r\n\r\n    QCOMPARE(testPort->getWire().isNull(), true);\r\n    QCOMPARE(testPort->getTransactional().isNull(), false);\r\n    QCOMPARE(testPort->getTransactional()->getAllLogicalInitiativesAllowed(), true);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ComponentPortReader::readTransactionalKind()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ComponentPortReader::readTransactionalKind()\r\n{\r\n    QString documentContent(\r\n        \"<ipxact:port>\"\r\n            \"<ipxact:name>testPort</ipxact:name>\"\r\n            \"<ipxact:transactional>\"\r\n                \"<ipxact:initiative>provides</ipxact:initiative>\"\r\n                \"<ipxact:kind>tlm_port</ipxact:kind>\"\r\n            \"</ipxact:transactional>\"\r\n        \"</ipxact:port>\"\r\n        );\r\n\r\n\r\n    QDomDocument document;\r\n    document.setContent(documentContent);\r\n\r\n    QDomNode portNode = document.firstChildElement(\"ipxact:port\");\r\n\r\n    QSharedPointer<Port> testPort = PortReader::createPortFrom(portNode, Document::Revision::Std14);\r\n\r\n    QCOMPARE(testPort->name(), QString(\"testPort\"));\r\n\r\n    QCOMPARE(testPort->getWire().isNull(), true);\r\n    QCOMPARE(testPort->getTransactional().isNull(), false);\r\n    QCOMPARE(testPort->getTransactional()->getAllLogicalInitiativesAllowed(), false);\r\n    QCOMPARE(testPort->getTransactional()->getKind(), QString(\"tlm_port\"));\r\n\r\n    documentContent =\r\n        \"<ipxact:port>\"\r\n            \"<ipxact:name>testPort</ipxact:name>\"\r\n            \"<ipxact:transactional>\"\r\n                \"<ipxact:initiative>provides</ipxact:initiative>\"\r\n                \"<ipxact:kind custom=\\\"customKind\\\">custom</ipxact:kind>\"\r\n            \"</ipxact:transactional>\"\r\n        \"</ipxact:port>\"\r\n        ;\r\n\r\n    document.setContent(documentContent);\r\n    portNode = document.firstChildElement(\"ipxact:port\");\r\n    testPort = PortReader::createPortFrom(portNode, Document::Revision::Std14);\r\n\r\n    QCOMPARE(testPort->name(), QString(\"testPort\"));\r\n\r\n    QCOMPARE(testPort->getWire().isNull(), true);\r\n    QCOMPARE(testPort->getTransactional().isNull(), false);\r\n    QCOMPARE(testPort->getTransactional()->getKind(), QString(\"customKind\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ComponentPortReader::readTransactionalBusWidth()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ComponentPortReader::readTransactionalBusWidth()\r\n{\r\n    QString documentContent(\r\n        \"<ipxact:port>\"\r\n            \"<ipxact:name>testPort</ipxact:name>\"\r\n            \"<ipxact:transactional>\"\r\n                \"<ipxact:initiative>provides</ipxact:initiative>\"\r\n                \"<ipxact:busWidth>8</ipxact:busWidth>\"\r\n            \"</ipxact:transactional>\"\r\n        \"</ipxact:port>\"\r\n        );\r\n\r\n\r\n    QDomDocument document;\r\n    document.setContent(documentContent);\r\n\r\n    QDomNode portNode = document.firstChildElement(\"ipxact:port\");\r\n\r\n    QSharedPointer<Port> testPort = PortReader::createPortFrom(portNode, Document::Revision::Std14);\r\n\r\n    QCOMPARE(testPort->name(), QString(\"testPort\"));\r\n\r\n    QCOMPARE(testPort->getWire().isNull(), true);\r\n    QCOMPARE(testPort->getTransactional().isNull(), false);\r\n    QCOMPARE(testPort->getTransactional()->getBusWidth(), QString(\"8\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ComponentPortReader::readTransactionalProtocol()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ComponentPortReader::readTransactionalProtocol()\r\n{\r\n    QString documentContent(\r\n        \"<ipxact:port>\"\r\n            \"<ipxact:name>testPort</ipxact:name>\"\r\n            \"<ipxact:transactional>\"\r\n                \"<ipxact:initiative>provides</ipxact:initiative>\"\r\n                \"<ipxact:protocol>\"\r\n                    \"<ipxact:protocolType>tlm</ipxact:protocolType>\"\r\n                    \"<ipxact:payload>\"\r\n                        \"<ipxact:name>testPayload</ipxact:name>\"\r\n                        \"<ipxact:type>generic</ipxact:type>\"\r\n                        \"<ipxact:extension mandatory=\\\"true\\\">extended</ipxact:extension>\"\r\n                        \"<ipxact:vendorExtensions>\"\r\n                            \"<testExtension testExtensionAttribute=\\\"extension\\\">testValue</testExtension>\"\r\n                        \"</ipxact:vendorExtensions>\"\r\n                    \"</ipxact:payload>\"\r\n                \"</ipxact:protocol>\"\r\n            \"</ipxact:transactional>\"\r\n        \"</ipxact:port>\"\r\n        );\r\n\r\n\r\n    QDomDocument document;\r\n    document.setContent(documentContent);\r\n\r\n    QDomNode portNode = document.firstChildElement(\"ipxact:port\");\r\n\r\n    QSharedPointer<Port> testPort = PortReader::createPortFrom(portNode, Document::Revision::Std14);\r\n\r\n    QCOMPARE(testPort->name(), QString(\"testPort\"));\r\n\r\n    QCOMPARE(testPort->getWire().isNull(), true);\r\n    QCOMPARE(testPort->getTransactional().isNull(), false);\r\n    QCOMPARE(testPort->getTransactional()->getProtocol().isNull(), false);\r\n\r\n    QSharedPointer<Protocol> transactionalProtocol = testPort->getTransactional()->getProtocol();\r\n    QCOMPARE(transactionalProtocol->getProtocolType(), QString(\"tlm\"));\r\n    QCOMPARE(transactionalProtocol->getPayloadName(), QString(\"testPayload\"));\r\n    QCOMPARE(transactionalProtocol->getPayloadType(), QString(\"generic\"));\r\n    QCOMPARE(transactionalProtocol->hasMandatoryPayloadExtension(), true);\r\n    QCOMPARE(transactionalProtocol->getPayloadExtension(), QString(\"extended\"));\r\n    QCOMPARE(transactionalProtocol->getVendorExtensions()->size(), 1);\r\n    QCOMPARE(transactionalProtocol->getVendorExtensions()->first()->type(), QString(\"testExtension\"));\r\n\r\n    documentContent =\r\n        \"<ipxact:port>\"\r\n            \"<ipxact:name>testPort</ipxact:name>\"\r\n            \"<ipxact:transactional>\"\r\n                \"<ipxact:initiative>provides</ipxact:initiative>\"\r\n                \"<ipxact:protocol>\"\r\n                    \"<ipxact:protocolType custom=\\\"customType\\\">custom</ipxact:protocolType>\"\r\n                    \"<ipxact:payload>\"\r\n                        \"<ipxact:name>testPayload</ipxact:name>\"\r\n                        \"<ipxact:type>generic</ipxact:type>\"\r\n                        \"<ipxact:extension>extend</ipxact:extension>\"\r\n                    \"</ipxact:payload>\"\r\n                \"</ipxact:protocol>\"\r\n            \"</ipxact:transactional>\"\r\n        \"</ipxact:port>\"\r\n        ;\r\n\r\n    document.setContent(documentContent);\r\n    portNode = document.firstChildElement(\"ipxact:port\");\r\n    testPort = PortReader::createPortFrom(portNode, Document::Revision::Std14);\r\n\r\n    QCOMPARE(testPort->getTransactional()->getProtocol().isNull(), false);\r\n\r\n    transactionalProtocol = testPort->getTransactional()->getProtocol();\r\n    QCOMPARE(transactionalProtocol->getProtocolType(), QString(\"custom\"));\r\n    QCOMPARE(transactionalProtocol->getCustomProtocolType(), QString(\"customType\"));\r\n    QCOMPARE(transactionalProtocol->getPayloadName(), QString(\"testPayload\"));\r\n    QCOMPARE(transactionalProtocol->getPayloadType(), QString(\"generic\"));\r\n    QCOMPARE(transactionalProtocol->hasMandatoryPayloadExtension(), false);\r\n    QCOMPARE(transactionalProtocol->getPayloadExtension(), QString(\"extend\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ComponentPortReader::readTransactionalTypeDefinitions()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ComponentPortReader::readTransactionalTypeDefinitions()\r\n{\r\n    QString documentContent(\r\n        \"<ipxact:port>\"\r\n            \"<ipxact:name>testPort</ipxact:name>\"\r\n            \"<ipxact:transactional>\"\r\n                \"<ipxact:initiative>provides</ipxact:initiative>\"\r\n                \"<ipxact:transTypeDefs>\"\r\n                    \"<ipxact:transTypeDef>\"\r\n                        \"<ipxact:typeName exact=\\\"true\\\">testType</ipxact:typeName>\"\r\n                        \"<ipxact:typeDefinition>testTypeDefinition</ipxact:typeDefinition>\"\r\n                        \"<ipxact:viewRef>testView</ipxact:viewRef>\"\r\n                    \"</ipxact:transTypeDef>\"\r\n                \"</ipxact:transTypeDefs>\"\r\n            \"</ipxact:transactional>\"\r\n        \"</ipxact:port>\"\r\n        );\r\n\r\n\r\n    QDomDocument document;\r\n    document.setContent(documentContent);\r\n\r\n    QDomNode portNode = document.firstChildElement(\"ipxact:port\");\r\n\r\n    QSharedPointer<Port> testPort = PortReader::createPortFrom(portNode, Document::Revision::Std14);\r\n\r\n    QCOMPARE(testPort->name(), QString(\"testPort\"));\r\n    QCOMPARE(testPort->getTransactional().isNull(), false);\r\n    QCOMPARE(testPort->getTransactional()->getTransTypeDef()->size(), 1);\r\n    \r\n    QSharedPointer<WireTypeDef> transTypeDefinition = testPort->getTransactional()->getTransTypeDef()->first();\r\n    QCOMPARE(transTypeDefinition->getTypeName(), QString(\"testType\"));\r\n    QCOMPARE(transTypeDefinition->isConstrained(), true);\r\n    QCOMPARE(transTypeDefinition->getTypeDefinitions()->size(), 1);\r\n    QCOMPARE(transTypeDefinition->getTypeDefinitions()->first(), QString(\"testTypeDefinition\"));\r\n    QCOMPARE(transTypeDefinition->getViewRefs()->size(), 1);\r\n    QCOMPARE(transTypeDefinition->getViewRefs()->first(), QString(\"testView\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ComponentPortReader::readTransactionalConnectionMinMax()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ComponentPortReader::readTransactionalConnectionMinMax()\r\n{\r\n    QString documentContent(\r\n        \"<ipxact:port>\"\r\n            \"<ipxact:name>testPort</ipxact:name>\"\r\n            \"<ipxact:transactional>\"\r\n                \"<ipxact:initiative>provides</ipxact:initiative>\"\r\n                \"<ipxact:connection>\"\r\n                    \"<ipxact:maxConnections>16*2</ipxact:maxConnections>\"\r\n                    \"<ipxact:minConnections>8*2</ipxact:minConnections>\"\r\n                \"</ipxact:connection>\"\r\n            \"</ipxact:transactional>\"\r\n        \"</ipxact:port>\"\r\n        );\r\n\r\n\r\n    QDomDocument document;\r\n    document.setContent(documentContent);\r\n\r\n    QDomNode portNode = document.firstChildElement(\"ipxact:port\");\r\n\r\n    QSharedPointer<Port> testPort = PortReader::createPortFrom(portNode, Document::Revision::Std14);\r\n\r\n    QCOMPARE(testPort->name(), QString(\"testPort\"));\r\n    QCOMPARE(testPort->getTransactional().isNull(), false);\r\n\r\n    QCOMPARE(testPort->getTransactional()->getMaxConnections(), QString(\"16*2\"));\r\n    QCOMPARE(testPort->getTransactional()->getMinConnections(), QString(\"8*2\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ComponentPortReader::readStrucuredType_2022()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ComponentPortReader::readStrucuredType_2022()\r\n{\r\n    QFETCH(QString, content);\r\n    QFETCH(Structured::Type, expectedType);\r\n    QFETCH(DirectionTypes::Direction, expectedDirection);\r\n\r\n     QString documentContent(\r\n        \"<ipxact:port>\"\r\n            \"<ipxact:name>testPort</ipxact:name>\"\r\n            \"<ipxact:structured>\" +\r\n            content +\r\n            \"</ipxact:structured>\"\r\n        \"</ipxact:port>\"\r\n        );\r\n\r\n    QDomDocument document;\r\n    document.setContent(documentContent);\r\n\r\n    QDomNode portNode = document.firstChildElement(\"ipxact:port\");\r\n\r\n    QSharedPointer<Port> testPort = PortReader::createPortFrom(portNode, Document::Revision::Std22);\r\n\r\n    QCOMPARE(testPort->name(), QString(\"testPort\"));\r\n    QCOMPARE(testPort->getWire().isNull(), true);\r\n    QCOMPARE(testPort->getTransactional().isNull(), true);\r\n    QCOMPARE(testPort->getStructured().isNull(), false);\r\n\r\n    auto structured = testPort->getStructured();\r\n    QCOMPARE(structured->isPacked(), false);\r\n    QCOMPARE(structured->getType(), expectedType);\r\n    QCOMPARE(structured->getDirection(), expectedDirection);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ComponentPortReader::readStrucuredType_2022_data()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ComponentPortReader::readStrucuredType_2022_data()\r\n{\r\n    QTest::addColumn<QString>(\"content\");\r\n    QTest::addColumn<Structured::Type>(\"expectedType\");\r\n    QTest::addColumn<DirectionTypes::Direction>(\"expectedDirection\");\r\n\r\n    QTest::addRow(\"Struct without direction\") << \r\n        \"<ipxact:struct>\" << Structured::Type::Struct << DirectionTypes::DIRECTION_INVALID;\r\n    QTest::addRow(\"Struct with in direction\") << \r\n        \"<ipxact:struct direction = \\\"in\\\">\" << Structured::Type::Struct << DirectionTypes::IN;\r\n\r\n    QTest::addRow(\"Union without direction\") << \r\n        \"<ipxact:union>\" << Structured::Type::Union << DirectionTypes::DIRECTION_INVALID;\r\n    QTest::addRow(\"Union with out direction\") << \r\n        \"<ipxact:union direction = \\\"out\\\">\" << Structured::Type::Union << DirectionTypes::OUT;\r\n\r\n    QTest::addRow(\"Interface without phantom attribute\") <<\r\n        \"<ipxact:interface>\" << Structured::Type::Interface << DirectionTypes::DIRECTION_INVALID;\r\n    QTest::addRow(\"Interface with true phantom attribute\") <<\r\n        \"<ipxact:interface phantom=\\\"true\\\">\" << Structured::Type::Interface << DirectionTypes::DIRECTION_PHANTOM;\r\n    QTest::addRow(\"Interface with false phantom attribute\") <<\r\n        \"<ipxact:interface phantom=\\\"false\\\">\" << Structured::Type::Interface << DirectionTypes::DIRECTION_INVALID;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ComponentPortReader::readStructuredVectors_2022()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ComponentPortReader::readStructuredVectors_2022()\r\n{\r\n    QString documentContent(\r\n        \"<ipxact:port>\"\r\n            \"<ipxact:name>testPort</ipxact:name>\"\r\n            \"<ipxact:structured packed=\\\"true\\\">\"\r\n                \"<ipxact:vectors>\"\r\n                    \"<ipxact:vector>\"\r\n                        \"<ipxact:left>1</ipxact:left>\"\r\n                        \"<ipxact:right>0</ipxact:right>\"\r\n                    \"</ipxact:vector>\"\r\n                    \"<ipxact:vector>\"\r\n                        \"<ipxact:left>2</ipxact:left>\"\r\n                        \"<ipxact:right>0</ipxact:right>\"\r\n                    \"</ipxact:vector>\"\r\n                \"</ipxact:vectors>\"\r\n            \"</ipxact:structured>\"\r\n        \"</ipxact:port>\"\r\n        );\r\n\r\n    QDomDocument document;\r\n    document.setContent(documentContent);\r\n\r\n    QDomNode portNode = document.firstChildElement(\"ipxact:port\");\r\n\r\n    QSharedPointer<Port> testPort = PortReader::createPortFrom(portNode, Document::Revision::Std22);\r\n\r\n    QCOMPARE(testPort->getStructured().isNull(), false);\r\n\r\n    auto structured = testPort->getStructured();\r\n    QCOMPARE(structured->isPacked(), true);\r\n    QCOMPARE(structured->getVectors()->count(), 2);\r\n\r\n    auto const& lastVector = structured->getVectors()->last();\r\n    QCOMPARE(lastVector.getLeft(), \"2\");\r\n    QCOMPARE(lastVector.getRight(), \"0\");\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ComponentPortReader::readStructuredSubPortWire_2022()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ComponentPortReader::readStructuredSubPortWire_2022()\r\n{\r\n    QString documentContent(\r\n        \"<ipxact:port>\"\r\n            \"<ipxact:name>testPort</ipxact:name>\"\r\n            \"<ipxact:structured>\"\r\n                \"<ipxact:interface/>\"\r\n                \"<ipxact:subPorts>\"\r\n                    \"<ipxact:subPort isIO=\\\"true\\\">\"\r\n                        \"<ipxact:name>minimalWire</ipxact:name>\"\r\n                        \"<ipxact:wire>\"\r\n                            \"<ipxact:direction>in</ipxact:direction>\"\r\n                        \"</ipxact:wire>\"\r\n                    \"</ipxact:subPort>\"\r\n                \"</ipxact:subPorts>\"\r\n            \"</ipxact:structured>\"\r\n        \"</ipxact:port>\"\r\n        );\r\n\r\n    QDomDocument document;\r\n    document.setContent(documentContent);\r\n\r\n    QDomNode portNode = document.firstChildElement(\"ipxact:port\");\r\n\r\n    QSharedPointer<Port> testPort = PortReader::createPortFrom(portNode, Document::Revision::Std22);\r\n\r\n    QCOMPARE(testPort->getStructured().isNull(), false);\r\n\r\n    auto structured = testPort->getStructured();\r\n    QCOMPARE(structured->isPacked(), false);\r\n    QCOMPARE(structured->getSubPorts()->count(), 1);\r\n\r\n    auto subPort = structured->getSubPorts()->first();\r\n    QCOMPARE(subPort->isIO(), true);\r\n    QCOMPARE(subPort->name(), QString(\"minimalWire\"));\r\n\r\n    QCOMPARE(subPort->getWire().isNull(), false);\r\n    QCOMPARE(subPort->getWire()->getDirection(), DirectionTypes::IN);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ComponentPortReader::readNestedStructuredSubPort_2022()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ComponentPortReader::readNestedStructuredSubPort_2022()\r\n{\r\n    QString documentContent(\r\n        \"<ipxact:port>\"\r\n            \"<ipxact:name>testPort</ipxact:name>\"\r\n            \"<ipxact:structured>\"\r\n                \"<ipxact:interface/>\"\r\n                \"<ipxact:subPorts>\"\r\n                    \"<ipxact:subPort>\"\r\n                    \"<ipxact:name>firstLayer</ipxact:name>\"\r\n                        \"<ipxact:structured>\"\r\n                        \"<ipxact:interface/>\"\r\n                            \"<ipxact:subPorts>\"\r\n                                \"<ipxact:subPort>\"\r\n                                \"<ipxact:name>middleLayer</ipxact:name>\"\r\n                                    \"<ipxact:structured>\"\r\n                                        \"<ipxact:interface/>\"\r\n                                        \"<ipxact:subPorts>\"\r\n                                            \"<ipxact:subPort>\"\r\n                                                \"<ipxact:name>wireLayer</ipxact:name>\"\r\n                                                \"<ipxact:wire>\"\r\n                                                    \"<ipxact:direction>in</ipxact:direction>\"\r\n                                                \"</ipxact:wire>\"\r\n                                            \"</ipxact:subPort>\"\r\n                                        \"</ipxact:subPorts>\"\r\n                                    \"</ipxact:structured>\"\r\n                                \"</ipxact:subPort>\"\r\n                            \"</ipxact:subPorts>\"\r\n                        \"</ipxact:structured>\"\r\n                    \"</ipxact:subPort>\"\r\n                \"</ipxact:subPorts>\"\r\n            \"</ipxact:structured>\"\r\n        \"</ipxact:port>\"\r\n    );\r\n\r\n    QDomDocument document;\r\n    document.setContent(documentContent);\r\n\r\n    QDomNode portNode = document.firstChildElement(\"ipxact:port\");\r\n\r\n    QSharedPointer<Port> testPort = PortReader::createPortFrom(portNode, Document::Revision::Std22);\r\n\r\n    QCOMPARE(testPort->getStructured().isNull(), false);\r\n\r\n    auto structured = testPort->getStructured();\r\n    QCOMPARE(structured->getSubPorts()->count(), 1);\r\n\r\n    auto const& firstSubPort = structured->getSubPorts()->first();\r\n    QCOMPARE(firstSubPort->name(), \"firstLayer\");\r\n    QCOMPARE(firstSubPort->getWire().isNull(), true);\r\n    QCOMPARE(firstSubPort->getStructured().isNull(), false);\r\n    QCOMPARE(firstSubPort->getStructured()->getSubPorts()->count(), 1);\r\n\r\n    auto const& middleSubPort = firstSubPort->getStructured()->getSubPorts()->first();\r\n    QCOMPARE(middleSubPort->name(), \"middleLayer\");\r\n    QCOMPARE(middleSubPort->getWire().isNull(), true);\r\n    QCOMPARE(middleSubPort->getStructured().isNull(), false);\r\n    QCOMPARE(middleSubPort->getStructured()->getSubPorts()->count(), 1);\r\n\r\n    auto const& finalSubPort = middleSubPort->getStructured()->getSubPorts()->first();\r\n    QCOMPARE(finalSubPort->name(), QString(\"wireLayer\"));\r\n    QCOMPARE(finalSubPort->getStructured().isNull(), true);\r\n    QCOMPARE(finalSubPort->getWire().isNull(), false);\r\n\r\n    auto const& wire = finalSubPort->getWire();\r\n    QCOMPARE(wire->getDirection(), DirectionTypes::IN);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ComponentPortReader::readSubPortArrays_2022()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ComponentPortReader::readSubPortArrays_2022()\r\n{\r\n    \r\n    QString documentContent(\r\n        \"<ipxact:port>\"\r\n            \"<ipxact:name>testPort</ipxact:name>\"\r\n            \"<ipxact:structured>\"\r\n                \"<ipxact:interface/>\"\r\n                \"<ipxact:subPorts>\"\r\n                    \"<ipxact:subPort>\"\r\n                        \"<ipxact:name>arrays</ipxact:name>\"\r\n                        \"<ipxact:wire>\"\r\n                            \"<ipxact:direction>in</ipxact:direction>\"\r\n                        \"</ipxact:wire>\"\r\n                        \"<ipxact:arrays>\"\r\n                            \"<ipxact:array>\"\r\n                            \"<ipxact:left>0</ipxact:left>\"\r\n                            \"<ipxact:right>0</ipxact:right>\"\r\n                            \"</ipxact:array>\"\r\n                            \"<ipxact:array>\"\r\n                                \"<ipxact:left>1</ipxact:left>\"\r\n                                \"<ipxact:right>0</ipxact:right>\"\r\n                            \"</ipxact:array>\"\r\n                        \"</ipxact:arrays>\"\r\n                    \"</ipxact:subPort>\"\r\n                \"</ipxact:subPorts>\"\r\n            \"</ipxact:structured>\"\r\n        \"</ipxact:port>\"\r\n        );\r\n\r\n    QDomDocument document;\r\n    document.setContent(documentContent);\r\n\r\n    QDomNode portNode = document.firstChildElement(\"ipxact:port\");\r\n\r\n    QSharedPointer<Port> testPort = PortReader::createPortFrom(portNode, Document::Revision::Std22);\r\n\r\n    QCOMPARE(testPort->getStructured().isNull(), false);\r\n\r\n    auto structured = testPort->getStructured();\r\n    QCOMPARE(structured->isPacked(), false);\r\n    QCOMPARE(structured->getSubPorts()->count(), 1);\r\n\r\n    auto subPort = structured->getSubPorts()->first();\r\n    QCOMPARE(subPort->getArrays()->count(), 2);\r\n\r\n    auto firstArray = subPort->getArrays()->first();\r\n    QCOMPARE(firstArray.getLeft(), \"0\");\r\n    QCOMPARE(firstArray.getRight(), \"0\");\r\n\r\n    auto lastArray = subPort->getArrays()->last();\r\n    QCOMPARE(lastArray.getLeft(), \"1\");\r\n    QCOMPARE(lastArray.getRight(), \"0\");\r\n\r\n}\r\n\r\nQTEST_APPLESS_MAIN(tst_ComponentPortReader)\r\n\r\n#include \"tst_ComponentPortReader.moc\"\r\n"
  },
  {
    "path": "tests/IPXACTmodels/Component/tst_ComponentPortReader.pri",
    "content": "# ----------------------------------------------------\r\n# This file is generated by the Qt Visual Studio Tools.\r\n# ------------------------------------------------------\r\n\r\nSOURCES += ./tst_ComponentPortReader.cpp "
  },
  {
    "path": "tests/IPXACTmodels/Component/tst_ComponentPortReader.pro",
    "content": "#-----------------------------------------------------------------------------\r\n# File: tst_ComponentPortReader.pro\r\n#-----------------------------------------------------------------------------\r\n# Project: Kactus 2\r\n# Author: Mikko Teuho\r\n# Date: 14.09.2015\r\n#\r\n# Description:\r\n# Qt project file template for running unit tests for component port reader.\r\n#-----------------------------------------------------------------------------\r\n\r\nTEMPLATE = app\r\n\r\nTARGET = tst_ComponentPortReader\r\n\r\nQT += core xml testlib\r\nQT -= gui\r\n\r\nCONFIG += c++17 testcase console\r\n\r\nlinux-g++ | linux-g++-64 | linux-g++-32 {\r\n LIBS += -L../../../executable \\\r\n     -lIPXACTmodels\r\n\r\n}\r\nwin64 | win32 {\r\n LIBS += -L../../../executable \\\r\n     -lIPXACTmodelsd\r\n}\r\n\r\nINCLUDEPATH += $$DESTDIR\r\nINCLUDEPATH += ../../../\r\n\r\nDEPENDPATH += .\r\nDEPENDPATH += ../../../\r\n\r\nOBJECTS_DIR += $$DESTDIR\r\n\r\nMOC_DIR += ./generatedFiles\r\nUI_DIR += ./generatedFiles\r\nRCC_DIR += ./generatedFiles\r\ninclude(tst_ComponentPortReader.pri)\r\n"
  },
  {
    "path": "tests/IPXACTmodels/Component/tst_ComponentPortValidator.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// ComponentPort: tst_ComponentPortValidator.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Janne Virtanen\r\n// Date: 25.11.2015\r\n//\r\n// Description:\r\n// Unit test for class ComponentPortValidator.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include <KactusAPI/include/SystemVerilogExpressionParser.h>\r\n\r\n#include <IPXACTmodels/Component/validators/PortValidator.h>\r\n\r\n#include <IPXACTmodels/Component/View.h>\r\n#include <IPXACTmodels/Component/Port.h>\r\n\r\n#include <QtTest>\r\n\r\nclass tst_ComponentPortValidator : public QObject\r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n    tst_ComponentPortValidator();\r\n\r\nprivate slots:\r\n\tvoid baseCase();\r\n\tvoid presenceFail();\r\n\tvoid arrayFail();\r\n\tvoid wireFail();\r\n\tvoid wireSuccess();\r\n\tvoid initiativeKindFail();\r\n\tvoid initiativeKindSuccess();\r\n\tvoid transactionalFail();\r\n\tvoid transactionalSuccess();\r\n\tvoid protocolFail();\r\n\tvoid protocolSuccess();\r\n\r\nprivate:\r\n\r\n\tQSharedPointer<QList<QSharedPointer<View> > > views_;\r\n\r\n    QSharedPointer<ExpressionParser> parser_;\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ComponentPortValidator::tst_ComponentPortValidator()\r\n//-----------------------------------------------------------------------------\r\ntst_ComponentPortValidator::tst_ComponentPortValidator()\r\n{\r\n\tviews_ = QSharedPointer<QList<QSharedPointer<View> > >( new QList<QSharedPointer<View> > );\r\n\tQSharedPointer<View> testView( new View(\"test_view\") );\r\n\tviews_->append(testView);\r\n\r\n    parser_ = QSharedPointer<SystemVerilogExpressionParser> (new SystemVerilogExpressionParser());\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ComponentPortValidator::baseCase()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ComponentPortValidator::baseCase()\r\n{\r\n    QSharedPointer<Port> port( new Port );\r\n    port->setDirection(DirectionTypes::IN);\r\n    port->setLeftBound(\"4\");\r\n    port->setRightBound(\"4\");\r\n\tPortValidator validator(parser_, views_);\r\n\r\n\tport->setName(\"joq\");\r\n\r\n\tQVector<QString> errorList;\r\n    validator.findErrorsIn(errorList, port, \"test\");\r\n\r\n\tQCOMPARE( errorList.size(), 0 );\r\n    QVERIFY( validator.validate(port) );\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ComponentPortValidator::presenceFail()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ComponentPortValidator::presenceFail()\r\n{\r\n\tQSharedPointer<Port> port( new Port );\r\n\tPortValidator validator(parser_, views_);\r\n\r\n\tport->setName(\"joq\");\r\n\tport->setIsPresent(\"evoo\");\r\n\r\n\tQVector<QString> errorList;\r\n    validator.findErrorsIn(errorList, port, \"test\");\r\n\r\n\tQCOMPARE( errorList.size(), 1 );\r\n    QVERIFY( !validator.validate(port) );\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ComponentPortValidator::arrayFail()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ComponentPortValidator::arrayFail()\r\n{\r\n\tQSharedPointer<Port> port( new Port );\r\n\tPortValidator validator(parser_, views_);\r\n\r\n\tport->setName(\"joq\");\r\n\r\n\tArray arr{ \"eka\", \"toka\" };\r\n\tport->getArrays()->append(arr);\r\n\r\n\tQVector<QString> errorList;\r\n    validator.findErrorsIn(errorList, port, \"test\");\r\n\r\n\tQCOMPARE( errorList.size(), 2 );\r\n    QVERIFY( !validator.validate(port) );\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ComponentPortValidator::wireFail()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ComponentPortValidator::wireFail()\r\n{\r\n\tQSharedPointer<Port> port( new Port );\r\n\tPortValidator validator(parser_, views_);\r\n\r\n\tport->setName(\"joq\");\r\n\r\n\tQSharedPointer<Wire> wire( new Wire );\r\n\twire->setVectorLeftBound(\"bogus\");\r\n\twire->setVectorRightBound(\"myriad\");\r\n\tport->setWire(wire);\r\n\r\n\tQSharedPointer<WireTypeDef> wiredef( new WireTypeDef );\r\n\tQStringList refs;\r\n\trefs.append(\"bogus view\");\r\n\twiredef->getViewRefs()->append(refs);\r\n\twire->getWireTypeDefs()->append(wiredef);\r\n\r\n\tQVector<QString> errorList;\r\n    validator.findErrorsIn(errorList, port, \"test\");\r\n\r\n\tQCOMPARE( errorList.size(), 4 );\r\n    QVERIFY( !validator.validate(port) );\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ComponentPortValidator::wireSuccess()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ComponentPortValidator::wireSuccess()\r\n{\r\n\tQSharedPointer<Port> port( new Port );\r\n\tPortValidator validator(parser_, views_);\r\n\r\n\tport->setName(\"joq\");\r\n\r\n\tQSharedPointer<Wire> wire( new Wire );\r\n\twire->setVectorLeftBound(\"1\");\r\n\twire->setVectorRightBound(\"2\");\r\n    wire->setDirection(DirectionTypes::IN);\r\n\tport->setWire(wire);\r\n\r\n\tQSharedPointer<WireTypeDef> wiredef( new WireTypeDef );\r\n    wiredef->setTypeName(\"wire\");\r\n\tQStringList refs;\r\n\trefs.append(\"test_view\");\r\n\twiredef->getViewRefs()->append(refs);\r\n\twire->getWireTypeDefs()->append(wiredef);\r\n\r\n\tQVector<QString> errorList;\r\n    validator.findErrorsIn(errorList, port, \"test\");\r\n\r\n\tQCOMPARE( errorList.size(), 0 );\r\n    QVERIFY( validator.validate(port) );\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ComponentPortValidator::initiativeKindFail()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ComponentPortValidator::initiativeKindFail()\r\n{\r\n\tQSharedPointer<Port> port( new Port );\r\n\tPortValidator validator(parser_, views_);\r\n\r\n\tport->setName(\"joq\");\r\n\r\n\tQSharedPointer<Transactional> trans( new Transactional );\r\n\ttrans->setInitiative(\"joq\");\r\n\ttrans->setKind(\"on\");\r\n\tport->setTransactional(trans);\r\n\r\n\tQVector<QString> errorList;\r\n    validator.findErrorsIn(errorList, port, \"test\");\r\n\r\n\tQCOMPARE( errorList.size(), 1 );\r\n    QVERIFY( !validator.validate(port) );\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ComponentPortValidator::initiativeKindSuccess()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ComponentPortValidator::initiativeKindSuccess()\r\n{\r\n\tQSharedPointer<Port> port( new Port );\r\n\tPortValidator validator(parser_, views_);\r\n\r\n\tport->setName(\"joq\");\r\n\r\n\tQSharedPointer<Transactional> trans( new Transactional );\r\n\ttrans->setInitiative(\"provides\");\r\n\ttrans->setKind(\"simple_socket\");\r\n\tport->setTransactional(trans);\r\n\r\n\tQVector<QString> errorList;\r\n    validator.findErrorsIn(errorList, port, \"test\");\r\n\r\n\tQCOMPARE( errorList.size(), 0 );\r\n    QVERIFY( validator.validate(port) );\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ComponentPortValidator::transactionalFail()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ComponentPortValidator::transactionalFail()\r\n{\r\n\tQSharedPointer<Port> port( new Port );\r\n\tPortValidator validator(parser_, views_);\r\n\r\n\tport->setName(\"joq\");\r\n\r\n\tQSharedPointer<Transactional> trans( new Transactional );\r\n\ttrans->setInitiative(\"requires\");\r\n\ttrans->setMinConnections(\"esa\");\r\n\ttrans->setMaxConnections(\"masa\");\r\n\ttrans->setBusWidth(\"eioo\");\r\n\tport->setTransactional(trans);\r\n\r\n\tQSharedPointer<WireTypeDef> wiredef( new WireTypeDef );\r\n\tQStringList refs;\r\n\trefs.append(\"bogus view\");\r\n\twiredef->getViewRefs()->append(refs);\r\n\ttrans->getTransTypeDef()->append(wiredef);\r\n\r\n\tQVector<QString> errorList;\r\n    validator.findErrorsIn(errorList, port, \"test\");\r\n\r\n\tQCOMPARE( errorList.size(), 4 );\r\n    QVERIFY( !validator.validate(port) );\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ComponentPortValidator::transactionalSuccess()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ComponentPortValidator::transactionalSuccess()\r\n{\r\n\tQSharedPointer<Port> port( new Port );\r\n\tPortValidator validator(parser_, views_);\r\n\r\n\tport->setName(\"joq\");\r\n\r\n\tQSharedPointer<Transactional> trans( new Transactional );\r\n\ttrans->setInitiative(\"requires\");\r\n\ttrans->setMinConnections(\"1\");\r\n\ttrans->setMaxConnections(\"10\");\r\n\ttrans->setBusWidth(\"16\");\r\n\tport->setTransactional(trans);\r\n\r\n\tQSharedPointer<WireTypeDef> wiredef( new WireTypeDef );\r\n\tQStringList refs;\r\n\trefs.append(\"test_view\");\r\n\twiredef->getViewRefs()->append(refs);\r\n\ttrans->getTransTypeDef()->append(wiredef);\r\n\r\n\tQVector<QString> errorList;\r\n    validator.findErrorsIn(errorList, port, \"test\");\r\n\r\n\tQCOMPARE( errorList.size(), 0 );\r\n    QVERIFY( validator.validate(port) );\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ComponentPortValidator::protocolFail()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ComponentPortValidator::protocolFail()\r\n{\r\n\tQSharedPointer<Port> port( new Port );\r\n\tPortValidator validator(parser_, views_);\r\n\r\n\tport->setName(\"joq\");\r\n\r\n\tQSharedPointer<Transactional> trans( new Transactional );\r\n\ttrans->setInitiative(\"requires\");\r\n\tport->setTransactional(trans);\r\n\r\n\tQSharedPointer<Protocol> prot( new Protocol );\r\n\tprot->setPayloadExtension(\"eioota\",true);\r\n\tprot->setPayloadName(\" \\t\");\r\n\tprot->setProtocolType(\"type\");\r\n\ttrans->setProtocol(prot);\r\n\r\n\tQVector<QString> errorList;\r\n    validator.findErrorsIn(errorList, port, \"test\");\r\n\r\n\tQCOMPARE( errorList.size(), 2 );\r\n    QVERIFY( !validator.validate(port) );\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ComponentPortValidator::protocolSuccess()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ComponentPortValidator::protocolSuccess()\r\n{\r\n\tQSharedPointer<Port> port( new Port );\r\n\tPortValidator validator(parser_, views_);\r\n\r\n\tport->setName(\"joq\");\r\n\r\n\tQSharedPointer<Transactional> trans( new Transactional );\r\n\ttrans->setInitiative(\"requires\");\r\n\tport->setTransactional(trans);\r\n\r\n\tQSharedPointer<Protocol> prot( new Protocol );\r\n\tprot->setPayloadExtension(\"mandatory\",true);\r\n\tprot->setPayloadName(\"esa\");\r\n\tprot->setProtocolType(\"tlm\");\r\n\tprot->setPayloadType(\"generic\");\r\n\ttrans->setProtocol(prot);\r\n\r\n\tQVector<QString> errorList;\r\n    validator.findErrorsIn(errorList, port, \"test\");\r\n\r\n\tQCOMPARE( errorList.size(), 0 );\r\n    QVERIFY( validator.validate(port) );\r\n}\r\n\r\nQTEST_APPLESS_MAIN(tst_ComponentPortValidator)\r\n\r\n#include \"tst_ComponentPortValidator.moc\"\r\n"
  },
  {
    "path": "tests/IPXACTmodels/Component/tst_ComponentPortValidator.pri",
    "content": "# ----------------------------------------------------\r\n# This file is generated by the Qt Visual Studio Tools.\r\n# ------------------------------------------------------\r\n\r\nSOURCES += ./tst_ComponentPortValidator.cpp "
  },
  {
    "path": "tests/IPXACTmodels/Component/tst_ComponentPortValidator.pro",
    "content": "#-----------------------------------------------------------------------------\r\n# ComponentPort: tst_ComponentPortValidator.pro\r\n#-----------------------------------------------------------------------------\r\n# Project: Kactus 2\r\n# Author: Janne Virtanen\r\n# Date: 25.11.2015\r\n#\r\n# Description:\r\n# Qt project ComponentPort template for running unit tests for Enumerated Value Validator.\r\n#-----------------------------------------------------------------------------\r\n\r\nTEMPLATE = app\r\n\r\nTARGET = tst_ComponentPortValidator\r\n\r\nQT += core gui xml testlib\r\n\r\nCONFIG += c++17 testcase console\r\n\r\nlinux-g++ | linux-g++-64 | linux-g++-32 {\r\n LIBS += -L../../../executable \\\r\n     -lIPXACTmodels -lKactusAPI\r\n\r\n}\r\nwin64 | win32 {\r\n LIBS += -L../../../executable \\\r\n     -lIPXACTmodelsd -lKactusAPId\r\n}\r\n\r\nINCLUDEPATH += $$DESTDIR\r\nINCLUDEPATH += ../../../\r\n\r\nDEPENDPATH += .\r\nDEPENDPATH += ../../../\r\n\r\nOBJECTS_DIR += $$DESTDIR\r\n\r\nMOC_DIR += ./generatedFiles\r\nUI_DIR += ./generatedFiles\r\nRCC_DIR += ./generatedFiles\r\ninclude(tst_ComponentPortValidator.pri)\r\n"
  },
  {
    "path": "tests/IPXACTmodels/Component/tst_ComponentPortWriter.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: tst_tst_ComponentPortWriter.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 09.09.2015\r\n//\r\n// Description:\r\n// Unit test for class tst_ComponentPortWriter.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include <IPXACTmodels/Component/PortWriter.h>\r\n\r\n#include <IPXACTmodels/common/GenericVendorExtension.h>\r\n#include <IPXACTmodels/common/Qualifier.h>\r\n\r\n#include <QtTest>\r\n#include <QDomDocument>\r\n\r\nclass tst_ComponentPortWriter : public QObject\r\n{\r\n    Q_OBJECT\r\n\r\npublic:\r\n    tst_ComponentPortWriter();\r\n\r\nprivate slots:\r\n    void writeSimplePort();\r\n    void writeSimpleTransactionalPort();\r\n    void writePortPresence();\r\n    void writePortArrays();\r\n    void writePortExtensions();\r\n    void writePortAdHocVisible();\r\n    void writePortDefaultPosition();\r\n    void writePortTags();\r\n\r\n    void writeWirePortAllLogicalDirectionsAllowed();\r\n    void writeWirePortVectors();\r\n    void writeWirePortVectors_2022();\r\n    void writeWireTypeDefinitions();\r\n    void emptyWireTypeDefinitionIsNotWritten();\r\n    void writeWireDefaultDriver();\r\n    void writeWireQualifiers_2022();\r\n\r\n    void writeTransactionalAllLogicalInitiativesAllowed();\r\n    void writeTransactionalKind();\r\n    void writeTransactionalBusWidth();\r\n    void writeTransactionalQualifier_2022();\r\n    void writeTransactionalProtocol();\r\n    void writeTransactionalTypeDefinitions();\r\n    void writeTransactionalConnectionMinMax();\r\n\r\n    void writeStructuredType_2022();\r\n    void writeStructuredType_2022_data();\r\n    void writeStructuredVectors_2022();\r\n    void writeStructuredWirePort_2022();\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ComponentPortWriter::tst_ComponentPortWriter()\r\n//-----------------------------------------------------------------------------\r\ntst_ComponentPortWriter::tst_ComponentPortWriter()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ComponentPortWriter::writeSimplePort()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ComponentPortWriter::writeSimplePort()\r\n{\r\n    QString output;\r\n    QXmlStreamWriter xmlStreamWriter(&output);\r\n\r\n    QSharedPointer<Port> testPort(new Port(\"testPort\"));\r\n    testPort->setDirection(DirectionTypes::IN);\r\n    testPort->setDisplayName(\"PortorDisplay\");\r\n    testPort->setDescription(\"PortorDescription\");\r\n\r\n    QString expectedOutput(\r\n        \"<ipxact:port>\"\r\n            \"<ipxact:name>testPort</ipxact:name>\"\r\n            \"<ipxact:displayName>PortorDisplay</ipxact:displayName>\"\r\n            \"<ipxact:description>PortorDescription</ipxact:description>\"\r\n            \"<ipxact:wire>\"\r\n                \"<ipxact:direction>in</ipxact:direction>\"\r\n            \"</ipxact:wire>\"\r\n        \"</ipxact:port>\"\r\n        );\r\n\r\n    PortWriter portWriter;\r\n    portWriter.writePort(xmlStreamWriter, testPort, Document::Revision::Std14);\r\n    QCOMPARE(output, expectedOutput);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ComponentPortWriter::writeSimpleTransactionalPort()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ComponentPortWriter::writeSimpleTransactionalPort()\r\n{\r\n    QString output;\r\n    QXmlStreamWriter xmlStreamWriter(&output);\r\n\r\n    QSharedPointer<Port> testPort(new Port(\"testPort\"));\r\n    testPort->setDisplayName(\"PortorDisplay\");\r\n    testPort->setDescription(\"PortorDescription\");\r\n\r\n    QSharedPointer<Transactional> testTransactional(new Transactional());\r\n    testTransactional->setInitiative(\"provides\");\r\n\r\n    testPort->setTransactional(testTransactional);\r\n\r\n    QString expectedOutput(\r\n        \"<ipxact:port>\"\r\n            \"<ipxact:name>testPort</ipxact:name>\"\r\n            \"<ipxact:displayName>PortorDisplay</ipxact:displayName>\"\r\n            \"<ipxact:description>PortorDescription</ipxact:description>\"\r\n            \"<ipxact:transactional>\"\r\n                \"<ipxact:initiative>provides</ipxact:initiative>\"\r\n            \"</ipxact:transactional>\"\r\n        \"</ipxact:port>\"\r\n        );\r\n\r\n    PortWriter portWriter;\r\n    portWriter.writePort(xmlStreamWriter, testPort, Document::Revision::Std14);\r\n    QCOMPARE(output, expectedOutput);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ComponentPortWriter::writePortPresence()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ComponentPortWriter::writePortPresence()\r\n{\r\n    QString output;\r\n    QXmlStreamWriter xmlStreamWriter(&output);\r\n\r\n    QSharedPointer<Port> testPort (new Port(\"testPort\"));\r\n    testPort->setDirection(DirectionTypes::IN);\r\n    testPort->setIsPresent(\"4-2*2+1\");\r\n\r\n    QString expectedOutput(\r\n        \"<ipxact:port>\"\r\n            \"<ipxact:name>testPort</ipxact:name>\"\r\n            \"<ipxact:isPresent>4-2*2+1</ipxact:isPresent>\"\r\n            \"<ipxact:wire>\"\r\n                \"<ipxact:direction>in</ipxact:direction>\"\r\n            \"</ipxact:wire>\"\r\n        \"</ipxact:port>\"\r\n        );\r\n\r\n    PortWriter portWriter;\r\n    portWriter.writePort(xmlStreamWriter, testPort, Document::Revision::Std14);\r\n    QCOMPARE(output, expectedOutput);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ComponentPortWriter::writePortArrays()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ComponentPortWriter::writePortArrays()\r\n{\r\n    QString output;\r\n    QXmlStreamWriter xmlStreamWriter(&output);\r\n\r\n    QSharedPointer<Transactional> testTransactional(new Transactional());\r\n    testTransactional->setInitiative(\"provides\");\r\n\r\n    QSharedPointer<Port> testPort(new Port(\"testPort\"));\r\n    testPort->setArrayLeft(\"4+4\");\r\n    testPort->setArrayRight(\"18\");\r\n    testPort->setTransactional(testTransactional);\r\n\r\n    QString expectedOutput(\r\n        \"<ipxact:port>\"\r\n            \"<ipxact:name>testPort</ipxact:name>\"\r\n            \"<ipxact:transactional>\"\r\n                \"<ipxact:initiative>provides</ipxact:initiative>\"\r\n            \"</ipxact:transactional>\"\r\n            \"<ipxact:arrays>\"\r\n                \"<ipxact:array>\"\r\n                    \"<ipxact:left>4+4</ipxact:left>\"\r\n                    \"<ipxact:right>18</ipxact:right>\"\r\n                \"</ipxact:array>\"\r\n            \"</ipxact:arrays>\"\r\n        \"</ipxact:port>\"\r\n        );\r\n\r\n    PortWriter portWriter;\r\n    portWriter.writePort(xmlStreamWriter, testPort, Document::Revision::Std14);\r\n    QCOMPARE(output, expectedOutput);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ComponentPortWriter::writePortExtensions()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ComponentPortWriter::writePortExtensions()\r\n{\r\n    QString output;\r\n    QXmlStreamWriter xmlStreamWriter(&output);\r\n\r\n    QDomDocument document;\r\n    QDomElement extensionNode = document.createElement(\"testExtension\");\r\n    extensionNode.setAttribute(\"testExtensionAttribute\", \"extension\");\r\n    extensionNode.appendChild(document.createTextNode(\"testValue\"));\r\n\r\n    QSharedPointer<GenericVendorExtension> testExtension(new GenericVendorExtension(extensionNode));\r\n\r\n    QSharedPointer<Port> testPort (new Port(\"testPort\"));\r\n    testPort->setDirection(DirectionTypes::IN);\r\n    testPort->getVendorExtensions()->append(testExtension);\r\n\r\n    QString expectedOutput(\r\n        \"<ipxact:port>\"\r\n            \"<ipxact:name>testPort</ipxact:name>\"\r\n            \"<ipxact:wire>\"\r\n                \"<ipxact:direction>in</ipxact:direction>\"\r\n            \"</ipxact:wire>\"\r\n            \"<ipxact:vendorExtensions>\"\r\n                \"<testExtension testExtensionAttribute=\\\"extension\\\">testValue</testExtension>\"\r\n            \"</ipxact:vendorExtensions>\"\r\n        \"</ipxact:port>\"\r\n        );\r\n\r\n    PortWriter portWriter;\r\n    portWriter.writePort(xmlStreamWriter, testPort, Document::Revision::Std14);\r\n    QCOMPARE(output, expectedOutput);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ComponentPortWriter::writePortAdHocVisible()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ComponentPortWriter::writePortAdHocVisible()\r\n{\r\n    QString output;\r\n    QXmlStreamWriter xmlStreamWriter(&output);\r\n\r\n    QSharedPointer<Port> testPort(new Port(\"testPort\"));  \r\n    testPort->setDirection(DirectionTypes::IN);\r\n    testPort->setAdHocVisible(true);\r\n\r\n    QString expectedOutput(\r\n        \"<ipxact:port>\"\r\n            \"<ipxact:name>testPort</ipxact:name>\"\r\n            \"<ipxact:wire>\"\r\n                \"<ipxact:direction>in</ipxact:direction>\"\r\n            \"</ipxact:wire>\"\r\n            \"<ipxact:vendorExtensions>\"\r\n                \"<kactus2:adHocVisible/>\"\r\n            \"</ipxact:vendorExtensions>\"\r\n        \"</ipxact:port>\"\r\n        );\r\n\r\n    PortWriter portWriter;\r\n    portWriter.writePort(xmlStreamWriter, testPort, Document::Revision::Std14);\r\n    QCOMPARE(output, expectedOutput);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ComponentPortWriter::writePortDefaultPosition()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ComponentPortWriter::writePortDefaultPosition()\r\n{\r\n    QString output;\r\n    QXmlStreamWriter xmlStreamWriter(&output);\r\n\r\n\r\n    QSharedPointer<Port> testPort(new Port(\"testPort\"));\r\n    testPort->setDirection(DirectionTypes::IN);\r\n    testPort->setDefaultPos(QPointF(1, 1));\r\n\r\n    QString expectedOutput(\r\n        \"<ipxact:port>\"\r\n            \"<ipxact:name>testPort</ipxact:name>\"\r\n            \"<ipxact:wire>\"\r\n                \"<ipxact:direction>in</ipxact:direction>\"\r\n            \"</ipxact:wire>\"\r\n            \"<ipxact:vendorExtensions>\"\r\n                \"<kactus2:position x=\\\"1\\\" y=\\\"1\\\"/>\"\r\n            \"</ipxact:vendorExtensions>\"\r\n        \"</ipxact:port>\"\r\n        );\r\n\r\n    PortWriter portWriter;\r\n    portWriter.writePort(xmlStreamWriter, testPort, Document::Revision::Std14);\r\n    QCOMPARE(output, expectedOutput);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ComponentPortWriter::writePortTags()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ComponentPortWriter::writePortTags()\r\n{\r\n    QString output;\r\n    QXmlStreamWriter xmlStreamWriter(&output);\r\n\r\n    QSharedPointer<Port> testPort(new Port(\"testPort\"));\r\n    testPort->setDirection(DirectionTypes::IN);\r\n    testPort->setPortTags(\"oyoroi,yuJing,guilang,tags\");\r\n\r\n    QString expectedOutput(\r\n        \"<ipxact:port>\"\r\n            \"<ipxact:name>testPort</ipxact:name>\"\r\n            \"<ipxact:wire>\"\r\n                \"<ipxact:direction>in</ipxact:direction>\"\r\n            \"</ipxact:wire>\"\r\n            \"<ipxact:vendorExtensions>\"\r\n                \"<kactus2:portTags>oyoroi,yuJing,guilang,tags</kactus2:portTags>\"\r\n            \"</ipxact:vendorExtensions>\"\r\n        \"</ipxact:port>\"\r\n        );\r\n\r\n    PortWriter portWriter;\r\n    portWriter.writePort(xmlStreamWriter, testPort, Document::Revision::Std14);\r\n    QCOMPARE(output, expectedOutput);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ComponentPortWriter::writeWirePortAllLogicalDirectionsAllowed()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ComponentPortWriter::writeWirePortAllLogicalDirectionsAllowed()\r\n{\r\n    QString output;\r\n    QXmlStreamWriter xmlStreamWriter(&output);\r\n\r\n    QSharedPointer<Port> testPort(new Port(\"testPort\"));\r\n    testPort->setDirection(DirectionTypes::IN);\r\n    testPort->setAllLogicalDirectionsAllowed(true);\r\n\r\n    QString expectedOutput(\r\n        \"<ipxact:port>\"\r\n            \"<ipxact:name>testPort</ipxact:name>\"\r\n            \"<ipxact:wire allLogicalDirectionsAllowed=\\\"true\\\">\"\r\n                \"<ipxact:direction>in</ipxact:direction>\"\r\n            \"</ipxact:wire>\"\r\n        \"</ipxact:port>\"\r\n        );\r\n\r\n    PortWriter portWriter;\r\n    portWriter.writePort(xmlStreamWriter, testPort, Document::Revision::Std14);\r\n    QCOMPARE(output, expectedOutput);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ComponentPortWriter::writeWirePortVectors()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ComponentPortWriter::writeWirePortVectors()\r\n{\r\n    QString output;\r\n    QXmlStreamWriter xmlStreamWriter(&output);\r\n\r\n    QSharedPointer<Port> testPort(new Port(\"testPort\"));\r\n    testPort->setDirection(DirectionTypes::OUT);\r\n    testPort->getWire()->setVectorLeftBound(\"4+18-Yaoxao\");\r\n    testPort->getWire()->setVectorRightBound(\"Yaoxao\");\r\n\r\n    QString expectedOutput(\r\n        \"<ipxact:port>\"\r\n            \"<ipxact:name>testPort</ipxact:name>\"\r\n            \"<ipxact:wire>\"\r\n                \"<ipxact:direction>out</ipxact:direction>\"\r\n                \"<ipxact:vectors>\"\r\n                    \"<ipxact:vector>\"\r\n                        \"<ipxact:left>4+18-Yaoxao</ipxact:left>\"\r\n                        \"<ipxact:right>Yaoxao</ipxact:right>\"\r\n                    \"</ipxact:vector>\"\r\n                \"</ipxact:vectors>\"\r\n            \"</ipxact:wire>\"\r\n        \"</ipxact:port>\"\r\n        );\r\n\r\n    PortWriter portWriter;\r\n    portWriter.writePort(xmlStreamWriter, testPort, Document::Revision::Std14);\r\n    QCOMPARE(output, expectedOutput);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ComponentPortWriter::writeWirePortVectors_2022()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ComponentPortWriter::writeWirePortVectors_2022()\r\n{\r\n    QString output;\r\n    QXmlStreamWriter xmlStreamWriter(&output);\r\n\r\n    QSharedPointer<Port> testPort(new Port(\"testPort\"));\r\n    testPort->setDirection(DirectionTypes::OUT);\r\n    testPort->getWire()->setVectorLeftBound(\"4+18-Yaoxao\");\r\n    testPort->getWire()->setVectorRightBound(\"Yaoxao\");\r\n    testPort->getWire()->getVectors()->first().setId(\"testID\");\r\n\r\n    QString expectedOutput(\r\n        \"<ipxact:port>\"\r\n            \"<ipxact:name>testPort</ipxact:name>\"\r\n            \"<ipxact:wire>\"\r\n                \"<ipxact:direction>out</ipxact:direction>\"\r\n                \"<ipxact:vectors>\"\r\n                    \"<ipxact:vector vectorId=\\\"testID\\\">\"\r\n                        \"<ipxact:left>4+18-Yaoxao</ipxact:left>\"\r\n                        \"<ipxact:right>Yaoxao</ipxact:right>\"\r\n                    \"</ipxact:vector>\"\r\n                \"</ipxact:vectors>\"\r\n            \"</ipxact:wire>\"\r\n        \"</ipxact:port>\"\r\n    );\r\n\r\n    PortWriter portWriter;\r\n    portWriter.writePort(xmlStreamWriter, testPort, Document::Revision::Std22);\r\n    QCOMPARE(output, expectedOutput);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ComponentPortWriter::writeWireTypeDefinitions()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ComponentPortWriter::writeWireTypeDefinitions()\r\n{\r\n    QString output;\r\n    QXmlStreamWriter xmlStreamWriter(&output);\r\n\r\n    QSharedPointer<Port> testPort(new Port(\"testPort\"));\r\n    testPort->setDirection(DirectionTypes::OUT);\r\n\r\n    QSharedPointer<WireTypeDef> testTypeDefinition (new WireTypeDef(\"testType\"));\r\n    testTypeDefinition->getViewRefs()->append(QStringList{ \"testView\" });\r\n    testTypeDefinition->setConstrained(true);\r\n    QStringList typeDefinitions;\r\n    typeDefinitions.append(\"testTypeDefinition\");\r\n    testTypeDefinition->getTypeDefinitions()->append(typeDefinitions);\r\n\r\n    testPort->getWire()->getWireTypeDefs()->append(testTypeDefinition);\r\n\r\n    QString expectedOutput(\r\n        \"<ipxact:port>\"\r\n            \"<ipxact:name>testPort</ipxact:name>\"\r\n            \"<ipxact:wire>\"\r\n                \"<ipxact:direction>out</ipxact:direction>\"\r\n                \"<ipxact:wireTypeDefs>\"\r\n                    \"<ipxact:wireTypeDef>\"\r\n                        \"<ipxact:typeName constrained=\\\"true\\\">testType</ipxact:typeName>\"\r\n                        \"<ipxact:typeDefinition>testTypeDefinition</ipxact:typeDefinition>\"\r\n                        \"<ipxact:viewRef>testView</ipxact:viewRef>\"\r\n                    \"</ipxact:wireTypeDef>\"\r\n                \"</ipxact:wireTypeDefs>\"\r\n            \"</ipxact:wire>\"\r\n        \"</ipxact:port>\"\r\n        );\r\n\r\n    PortWriter portWriter;\r\n    portWriter.writePort(xmlStreamWriter, testPort, Document::Revision::Std14);\r\n    QCOMPARE(output, expectedOutput);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ComponentPortWriter::emptyWireTypeDefinitionIsNotWritten()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ComponentPortWriter::emptyWireTypeDefinitionIsNotWritten()\r\n{\r\n    QString output;\r\n    QXmlStreamWriter xmlStreamWriter(&output);\r\n\r\n    QSharedPointer<Port> testPort(new Port(\"testPort\"));\r\n    testPort->setDirection(DirectionTypes::OUT);\r\n\r\n    QSharedPointer<WireTypeDef> testTypeDefinition(new WireTypeDef(\"testType\"));\r\n    testTypeDefinition->getViewRefs()->append(QStringList{ \"testView\" });\r\n    testTypeDefinition->setConstrained(true);\r\n    QStringList typeDefinitions;\r\n    typeDefinitions.append(\"testTypeDefinition\");\r\n    testTypeDefinition->getTypeDefinitions()->append(typeDefinitions);\r\n\r\n    testPort->getWire()->getWireTypeDefs()->append(testTypeDefinition);\r\n\r\n    QString expectedOutput(\r\n        \"<ipxact:port>\"\r\n            \"<ipxact:name>testPort</ipxact:name>\"\r\n            \"<ipxact:wire>\"\r\n                \"<ipxact:direction>out</ipxact:direction>\"\r\n                \"<ipxact:wireTypeDefs>\"\r\n                    \"<ipxact:wireTypeDef>\"\r\n                        \"<ipxact:typeName constrained=\\\"true\\\">testType</ipxact:typeName>\"\r\n                        \"<ipxact:typeDefinition>testTypeDefinition</ipxact:typeDefinition>\"\r\n                        \"<ipxact:viewRef>testView</ipxact:viewRef>\"\r\n                    \"</ipxact:wireTypeDef>\"\r\n                \"</ipxact:wireTypeDefs>\"\r\n            \"</ipxact:wire>\"\r\n        \"</ipxact:port>\"\r\n        );\r\n\r\n    PortWriter portWriter;\r\n    portWriter.writePort(xmlStreamWriter, testPort, Document::Revision::Std14);\r\n    QCOMPARE(output, expectedOutput);\r\n\r\n    output.clear();\r\n    QSharedPointer<WireTypeDef> testWireDefinition = testPort->getWire()->getWireTypeDefs()->first();\r\n    testWireDefinition->setTypeName(QStringLiteral(\"\"));\r\n\r\n    expectedOutput =\r\n        \"<ipxact:port>\"\r\n            \"<ipxact:name>testPort</ipxact:name>\"\r\n            \"<ipxact:wire>\"\r\n                \"<ipxact:direction>out</ipxact:direction>\"\r\n                \"<ipxact:wireTypeDefs>\"\r\n                    \"<ipxact:wireTypeDef>\"\r\n                        \"<ipxact:typeDefinition>testTypeDefinition</ipxact:typeDefinition>\"\r\n                        \"<ipxact:viewRef>testView</ipxact:viewRef>\"\r\n                    \"</ipxact:wireTypeDef>\"\r\n                \"</ipxact:wireTypeDefs>\"\r\n            \"</ipxact:wire>\"\r\n        \"</ipxact:port>\";\r\n\r\n    portWriter.writePort(xmlStreamWriter, testPort, Document::Revision::Std14);\r\n    QCOMPARE(output, expectedOutput);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ComponentPortWriter::writeWireDefaultDriver()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ComponentPortWriter::writeWireDefaultDriver()\r\n{\r\n    QString output;\r\n    QXmlStreamWriter xmlStreamWriter(&output);\r\n\r\n    QSharedPointer<Port> testPort(new Port(\"testPort\"));\r\n    testPort->setDirection(DirectionTypes::OUT);\r\n    testPort->setDefaultValue(\"4+4-2\");\r\n    auto driver = testPort->getWire()->getDriver();\r\n    driver->setRange(Range(\"1\", \"0\"));\r\n\r\n    QString expectedOutput(\r\n        \"<ipxact:port>\"\r\n            \"<ipxact:name>testPort</ipxact:name>\"\r\n            \"<ipxact:wire>\"\r\n                \"<ipxact:direction>out</ipxact:direction>\"\r\n                \"<ipxact:drivers>\"\r\n                    \"<ipxact:driver>\"\r\n                        \"<ipxact:range>\"\r\n                            \"<ipxact:left>1</ipxact:left>\"\r\n                            \"<ipxact:right>0</ipxact:right>\"\r\n                        \"</ipxact:range>\"\r\n                        \"<ipxact:defaultValue>4+4-2</ipxact:defaultValue>\"\r\n                    \"</ipxact:driver>\"\r\n                \"</ipxact:drivers>\"\r\n            \"</ipxact:wire>\"\r\n        \"</ipxact:port>\"\r\n        );\r\n\r\n    PortWriter portWriter;\r\n    portWriter.writePort(xmlStreamWriter, testPort, Document::Revision::Std14);\r\n    QCOMPARE(output, expectedOutput);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ComponentPortWriter::writeWireQualifiers_2022()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ComponentPortWriter::writeWireQualifiers_2022()\r\n{\r\n    QString output;\r\n    QXmlStreamWriter xmlStreamWriter(&output);\r\n\r\n    QSharedPointer<Port> testPort(new Port(\"testPort\"));\r\n    testPort->setWire(QSharedPointer<Wire>(new Wire()));\r\n    testPort->setDirection(DirectionTypes::OUT);\r\n    \r\n    auto wire = testPort->getWire(); \r\n    auto qualifier = wire->getQualifier();\r\n    qualifier->setType(Qualifier::Type::Reset);\r\n    qualifier->setAttribute(Qualifier::Attribute::ResetLevel, \"low\");\r\n    qualifier->setType(Qualifier::Type::FlowControl);\r\n\r\n    QString expectedOutput(\r\n        \"<ipxact:port>\"\r\n            \"<ipxact:name>testPort</ipxact:name>\"\r\n            \"<ipxact:wire>\"\r\n                \"<ipxact:direction>out</ipxact:direction>\"\r\n                \"<ipxact:qualifier>\"\r\n                    \"<ipxact:isReset level=\\\"low\\\">true</ipxact:isReset>\"\r\n                    \"<ipxact:isFlowControl>true</ipxact:isFlowControl>\"\r\n                \"</ipxact:qualifier>\"\r\n            \"</ipxact:wire>\"\r\n        \"</ipxact:port>\"\r\n        );\r\n\r\n    PortWriter portWriter;\r\n    portWriter.writePort(xmlStreamWriter, testPort, Document::Revision::Std22);\r\n    QCOMPARE(output, expectedOutput);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ComponentPortWriter::writeTransactionalAllLogicalInitiativesAllowed()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ComponentPortWriter::writeTransactionalAllLogicalInitiativesAllowed()\r\n{\r\n    QString output;\r\n    QXmlStreamWriter xmlStreamWriter(&output);\r\n\r\n    QSharedPointer<Transactional> testTransactional(new Transactional());\r\n    testTransactional->setInitiative(\"provides\");\r\n    testTransactional->setAllLogicalInitiativesAllowed(true);\r\n\r\n    QSharedPointer<Port> testPort(new Port(\"testPort\"));   \r\n    testPort->setTransactional(testTransactional);\r\n\r\n    QString expectedOutput(\r\n        \"<ipxact:port>\"\r\n            \"<ipxact:name>testPort</ipxact:name>\"\r\n            \"<ipxact:transactional allLogicalInitiativesAllowed=\\\"true\\\">\"\r\n                \"<ipxact:initiative>provides</ipxact:initiative>\"\r\n            \"</ipxact:transactional>\"\r\n        \"</ipxact:port>\"\r\n        );\r\n\r\n    PortWriter portWriter;\r\n    portWriter.writePort(xmlStreamWriter, testPort, Document::Revision::Std14);\r\n    QCOMPARE(output, expectedOutput);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ComponentPortWriter::writeTransactionalKind()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ComponentPortWriter::writeTransactionalKind()\r\n{\r\n    QString output;\r\n    QXmlStreamWriter xmlStreamWriter(&output);\r\n\r\n    QSharedPointer<Transactional> testTransactional(new Transactional());\r\n    testTransactional->setInitiative(\"provides\");\r\n    testTransactional->setKind(\"tlm_port\");\r\n    \r\n    QSharedPointer<Port> testPort(new Port(\"testPort\"));    \r\n    testPort->setTransactional(testTransactional);\r\n\r\n    QString expectedOutput(\r\n        \"<ipxact:port>\"\r\n            \"<ipxact:name>testPort</ipxact:name>\"\r\n            \"<ipxact:transactional>\"\r\n                \"<ipxact:initiative>provides</ipxact:initiative>\"\r\n                \"<ipxact:kind>tlm_port</ipxact:kind>\"\r\n            \"</ipxact:transactional>\"\r\n        \"</ipxact:port>\"\r\n        );\r\n\r\n    PortWriter portWriter;\r\n    portWriter.writePort(xmlStreamWriter, testPort, Document::Revision::Std14);\r\n    QCOMPARE(output, expectedOutput);\r\n\r\n    output.clear();\r\n    expectedOutput.clear();\r\n\r\n    testTransactional->setKind(\"customKind\");\r\n    \r\n    expectedOutput =\r\n        \"<ipxact:port>\"\r\n            \"<ipxact:name>testPort</ipxact:name>\"\r\n            \"<ipxact:transactional>\"\r\n                \"<ipxact:initiative>provides</ipxact:initiative>\"\r\n                \"<ipxact:kind custom=\\\"customKind\\\">custom</ipxact:kind>\"\r\n            \"</ipxact:transactional>\"\r\n        \"</ipxact:port>\"\r\n        ;\r\n\r\n    portWriter.writePort(xmlStreamWriter, testPort, Document::Revision::Std14);\r\n    QCOMPARE(output, expectedOutput);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ComponentPortWriter::writeTransactionalBusWidth()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ComponentPortWriter::writeTransactionalBusWidth()\r\n{\r\n    QString output;\r\n    QXmlStreamWriter xmlStreamWriter(&output);\r\n\r\n    QSharedPointer<Transactional> testTransactional(new Transactional());\r\n    testTransactional->setInitiative(\"provides\");\r\n    testTransactional->setBusWidth(\"8\");\r\n\r\n\r\n    QSharedPointer<Port> testPort(new Port(\"testPort\"));    \r\n    testPort->setTransactional(testTransactional);\r\n\r\n    QString expectedOutput(\r\n        \"<ipxact:port>\"\r\n            \"<ipxact:name>testPort</ipxact:name>\"\r\n            \"<ipxact:transactional>\"\r\n                \"<ipxact:initiative>provides</ipxact:initiative>\"\r\n                \"<ipxact:busWidth>8</ipxact:busWidth>\"\r\n            \"</ipxact:transactional>\"\r\n        \"</ipxact:port>\"\r\n        );\r\n\r\n    PortWriter portWriter;\r\n    portWriter.writePort(xmlStreamWriter, testPort, Document::Revision::Std14);\r\n    QCOMPARE(output, expectedOutput);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ComponentPortWriter::writeTransactionalQualifier_2022()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ComponentPortWriter::writeTransactionalQualifier_2022()\r\n{\r\n    QString output;\r\n    QXmlStreamWriter xmlStreamWriter(&output);\r\n\r\n    QSharedPointer<Transactional> testTransactional(new Transactional());\r\n    auto qualifier = testTransactional->getQualifier();\r\n    qualifier->setType(Qualifier::Type::Data);\r\n    qualifier->setType(Qualifier::Type::User);\r\n    qualifier->setAttribute(Qualifier::Attribute::UserDefined, \"test\");\r\n\r\n    QSharedPointer<Port> testPort(new Port(\"testPort\"));    \r\n    testPort->setTransactional(testTransactional);\r\n\r\n    QString expectedOutput(\r\n        \"<ipxact:port>\"\r\n            \"<ipxact:name>testPort</ipxact:name>\"\r\n            \"<ipxact:transactional>\"\r\n                \"<ipxact:initiative></ipxact:initiative>\"\r\n                \"<ipxact:qualifier>\"\r\n                    \"<ipxact:isData>true</ipxact:isData>\"\r\n                    \"<ipxact:isUser user=\\\"test\\\">true</ipxact:isUser>\"\r\n                \"</ipxact:qualifier>\"\r\n            \"</ipxact:transactional>\"\r\n        \"</ipxact:port>\"\r\n        );\r\n\r\n    PortWriter portWriter;\r\n    portWriter.writePort(xmlStreamWriter, testPort, Document::Revision::Std22);\r\n    QCOMPARE(output, expectedOutput);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ComponentPortWriter::writeTransactionalProtocol()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ComponentPortWriter::writeTransactionalProtocol()\r\n{\r\n    QString output;\r\n    QXmlStreamWriter xmlStreamWriter(&output);\r\n\r\n    QDomDocument document;\r\n    QDomElement extensionNode = document.createElement(\"testExtension\");\r\n    extensionNode.setAttribute(\"testExtensionAttribute\", \"extension\");\r\n    extensionNode.appendChild(document.createTextNode(\"testValue\"));\r\n    QSharedPointer<GenericVendorExtension> testExtension(new GenericVendorExtension(extensionNode));\r\n\r\n    QSharedPointer<Protocol> testProtocol (new Protocol());\r\n    testProtocol->setProtocolType(\"tlm\");\r\n    testProtocol->setPayloadName(\"testPayload\");\r\n    testProtocol->setPayloadType(\"generic\");\r\n    testProtocol->setPayloadExtension(\"extended\", true);\r\n    testProtocol->getVendorExtensions()->append(testExtension);\r\n\r\n    QSharedPointer<Transactional> testTransactional(new Transactional());\r\n    testTransactional->setInitiative(\"provides\");\r\n    testTransactional->setProtocol(testProtocol);\r\n\r\n    QSharedPointer<Port> testPort(new Port(\"testPort\"));    \r\n    testPort->setTransactional(testTransactional);\r\n\r\n    QString expectedOutput(\r\n        \"<ipxact:port>\"\r\n            \"<ipxact:name>testPort</ipxact:name>\"\r\n            \"<ipxact:transactional>\"\r\n                \"<ipxact:initiative>provides</ipxact:initiative>\"\r\n                \"<ipxact:protocol>\"\r\n                    \"<ipxact:protocolType>tlm</ipxact:protocolType>\"\r\n                    \"<ipxact:payload>\"\r\n                        \"<ipxact:name>testPayload</ipxact:name>\"\r\n                        \"<ipxact:type>generic</ipxact:type>\"\r\n                        \"<ipxact:extension mandatory=\\\"true\\\">extended</ipxact:extension>\"\r\n                        \"<ipxact:vendorExtensions>\"\r\n                            \"<testExtension testExtensionAttribute=\\\"extension\\\">testValue</testExtension>\"\r\n                        \"</ipxact:vendorExtensions>\"\r\n                    \"</ipxact:payload>\"\r\n                \"</ipxact:protocol>\"\r\n            \"</ipxact:transactional>\"\r\n        \"</ipxact:port>\"\r\n        );\r\n\r\n    PortWriter portWriter;\r\n    portWriter.writePort(xmlStreamWriter, testPort, Document::Revision::Std14);\r\n    QCOMPARE(output, expectedOutput);\r\n\r\n    output.clear();\r\n    expectedOutput.clear();\r\n\r\n    testProtocol->setProtocolType(\"customType\");\r\n    testProtocol->setPayloadExtension(\"extend\", false);\r\n    testProtocol->getVendorExtensions()->removeAll(testExtension);\r\n\r\n    expectedOutput =\r\n        \"<ipxact:port>\"\r\n            \"<ipxact:name>testPort</ipxact:name>\"\r\n            \"<ipxact:transactional>\"\r\n                \"<ipxact:initiative>provides</ipxact:initiative>\"\r\n                \"<ipxact:protocol>\"\r\n                    \"<ipxact:protocolType custom=\\\"customType\\\">custom</ipxact:protocolType>\"\r\n                    \"<ipxact:payload>\"\r\n                        \"<ipxact:name>testPayload</ipxact:name>\"\r\n                        \"<ipxact:type>generic</ipxact:type>\"\r\n                        \"<ipxact:extension>extend</ipxact:extension>\"\r\n                    \"</ipxact:payload>\"\r\n                \"</ipxact:protocol>\"\r\n            \"</ipxact:transactional>\"\r\n        \"</ipxact:port>\"\r\n        ;\r\n\r\n    portWriter.writePort(xmlStreamWriter, testPort, Document::Revision::Std14);\r\n    QCOMPARE(output, expectedOutput);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ComponentPortWriter::writeTransactionalTypeDefinitions()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ComponentPortWriter::writeTransactionalTypeDefinitions()\r\n{\r\n    QString output;\r\n    QXmlStreamWriter xmlStreamWriter(&output);\r\n\r\n    QSharedPointer<WireTypeDef> testTypeDefinition(new WireTypeDef(\"testType\"));\r\n    testTypeDefinition->getViewRefs()->append(QStringList{ \"testView\" });\r\n    testTypeDefinition->setConstrained(true);\r\n    QStringList typeDefinitions;\r\n    typeDefinitions.append(\"testTypeDefinition\");\r\n    testTypeDefinition->getTypeDefinitions()->append(typeDefinitions);\r\n\r\n    QSharedPointer<Transactional> testTransactional(new Transactional());\r\n    testTransactional->setInitiative(\"provides\");\r\n    testTransactional->getTransTypeDef()->append(testTypeDefinition);\r\n\r\n    QSharedPointer<Port> testPort(new Port(\"testPort\"));    \r\n    testPort->setTransactional(testTransactional);\r\n\r\n    QString expectedOutput(\r\n        \"<ipxact:port>\"\r\n            \"<ipxact:name>testPort</ipxact:name>\"\r\n            \"<ipxact:transactional>\"\r\n                \"<ipxact:initiative>provides</ipxact:initiative>\"\r\n                \"<ipxact:transTypeDefs>\"\r\n                    \"<ipxact:transTypeDef>\"\r\n                        \"<ipxact:typeName exact=\\\"true\\\">testType</ipxact:typeName>\"\r\n                        \"<ipxact:typeDefinition>testTypeDefinition</ipxact:typeDefinition>\"\r\n                        \"<ipxact:viewRef>testView</ipxact:viewRef>\"\r\n                    \"</ipxact:transTypeDef>\"\r\n                \"</ipxact:transTypeDefs>\"\r\n            \"</ipxact:transactional>\"\r\n        \"</ipxact:port>\"\r\n        );\r\n\r\n    PortWriter portWriter;\r\n    portWriter.writePort(xmlStreamWriter, testPort, Document::Revision::Std14);\r\n    QCOMPARE(output, expectedOutput);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ComponentPortWriter::writeTransactionalConnectionMinMax()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ComponentPortWriter::writeTransactionalConnectionMinMax()\r\n{\r\n    QString output;\r\n    QXmlStreamWriter xmlStreamWriter(&output);\r\n\r\n    QSharedPointer<Transactional> testTransactional(new Transactional());\r\n    testTransactional->setInitiative(\"provides\");\r\n    testTransactional->setMinConnections(\"8*2\");\r\n    testTransactional->setMaxConnections(\"16*2\");\r\n\r\n    QSharedPointer<Port> testPort(new Port(\"testPort\"));    \r\n    testPort->setTransactional(testTransactional);\r\n\r\n    QString expectedOutput(\r\n        \"<ipxact:port>\"\r\n            \"<ipxact:name>testPort</ipxact:name>\"\r\n            \"<ipxact:transactional>\"\r\n                \"<ipxact:initiative>provides</ipxact:initiative>\"\r\n                \"<ipxact:connection>\"\r\n                    \"<ipxact:maxConnections>16*2</ipxact:maxConnections>\"\r\n                    \"<ipxact:minConnections>8*2</ipxact:minConnections>\"\r\n                \"</ipxact:connection>\"\r\n            \"</ipxact:transactional>\"\r\n        \"</ipxact:port>\"\r\n        );\r\n\r\n    PortWriter portWriter;\r\n    portWriter.writePort(xmlStreamWriter, testPort, Document::Revision::Std14);\r\n    QCOMPARE(output, expectedOutput);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ComponentPortWriter::writeStructuredType_2022()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ComponentPortWriter::writeStructuredType_2022()\r\n{\r\n    QFETCH(Structured::Type, type);\r\n    QFETCH(DirectionTypes::Direction, direction);\r\n    QFETCH(QString, expectedType);\r\n\r\n    QString output;\r\n    QXmlStreamWriter xmlStreamWriter(&output);\r\n\r\n    QSharedPointer<Structured> testStructured(new Structured());\r\n    testStructured->setPacked(true);\r\n    testStructured->setType(type);\r\n    testStructured->setDirection(direction);\r\n\r\n    QSharedPointer<Port> testPort(new Port(\"testPort\"));    \r\n    testPort->setStructured(testStructured);\r\n\r\n    QString expectedOutput(\r\n        \"<ipxact:port>\"\r\n            \"<ipxact:name>testPort</ipxact:name>\"\r\n            \"<ipxact:structured packed=\\\"true\\\">\"\r\n               + expectedType +\r\n            \"</ipxact:structured>\"\r\n        \"</ipxact:port>\"\r\n        );\r\n\r\n    PortWriter portWriter;\r\n    portWriter.writePort(xmlStreamWriter, testPort, Document::Revision::Std22);\r\n    QCOMPARE(output, expectedOutput);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ComponentPortWriter::writeStructuredType_2022_data()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ComponentPortWriter::writeStructuredType_2022_data()\r\n{\r\n    QTest::addColumn<Structured::Type>(\"type\");\r\n    QTest::addColumn<DirectionTypes::Direction>(\"direction\");\r\n    QTest::addColumn<QString>(\"expectedType\");\r\n\r\n    QTest::addRow(\"Struct with out direction\") << Structured::Type::Struct << DirectionTypes::OUT <<\r\n        \"<ipxact:struct direction=\\\"out\\\"/>\";\r\n    QTest::addRow(\"Struct with inout direction\") << Structured::Type::Struct << DirectionTypes::INOUT <<\r\n        \"<ipxact:struct direction=\\\"inout\\\"/>\";\r\n    QTest::addRow(\"Struct with in direction\") << Structured::Type::Struct << DirectionTypes::IN <<\r\n        \"<ipxact:struct direction=\\\"in\\\"/>\";\r\n    QTest::addRow(\"Struct with phantom direction\") << Structured::Type::Struct << \r\n        DirectionTypes::DIRECTION_PHANTOM << \r\n        \"<ipxact:struct direction=\\\"phantom\\\"/>\";\r\n    QTest::addRow(\"Struct with invalid direction\") << Structured::Type::Struct <<\r\n        DirectionTypes::DIRECTION_INVALID <<\r\n        \"<ipxact:struct direction=\\\"\\\"/>\";\r\n\r\n    QTest::addRow(\"Union with in direction\") << Structured::Type::Union << DirectionTypes::IN <<\r\n        \"<ipxact:union direction=\\\"in\\\"/>\";\r\n\r\n    QTest::addRow(\"Interface with phantom direction\") << \r\n        Structured::Type::Interface << DirectionTypes::DIRECTION_PHANTOM <<\r\n        \"<ipxact:interface phantom=\\\"true\\\"/>\";\r\n\r\n    QTest::addRow(\"Interface with invalid direction\") << Structured::Type::Interface << DirectionTypes::IN <<\r\n        \"<ipxact:interface/>\";\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ComponentPortWriter::writeStructuredVectors_2022()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ComponentPortWriter::writeStructuredVectors_2022()\r\n{\r\n    QString output;\r\n    QXmlStreamWriter xmlStreamWriter(&output);\r\n\r\n    QSharedPointer<Structured> testStructured(new Structured());\r\n    testStructured->setPacked(true);\r\n    testStructured->setType(Structured::Type::Union);\r\n    testStructured->setDirection(DirectionTypes::OUT);\r\n\r\n    testStructured->getVectors()->append(Vector(\"1\", \"0\"));\r\n    testStructured->getVectors()->append(Vector(\"2\", \"0\"));\r\n\r\n    QSharedPointer<Port> testPort(new Port(\"testPort\"));    \r\n    testPort->setStructured(testStructured);\r\n\r\n    QString expectedOutput(\r\n        \"<ipxact:port>\"\r\n            \"<ipxact:name>testPort</ipxact:name>\"\r\n            \"<ipxact:structured packed=\\\"true\\\">\"\r\n            \"<ipxact:union direction=\\\"out\\\"/>\"\r\n                \"<ipxact:vectors>\"\r\n                    \"<ipxact:vector>\"\r\n                        \"<ipxact:left>1</ipxact:left>\"\r\n                        \"<ipxact:right>0</ipxact:right>\"\r\n                    \"</ipxact:vector>\"\r\n                    \"<ipxact:vector>\"\r\n                        \"<ipxact:left>2</ipxact:left>\"\r\n                        \"<ipxact:right>0</ipxact:right>\"\r\n                    \"</ipxact:vector>\"\r\n                \"</ipxact:vectors>\"\r\n            \"</ipxact:structured>\"\r\n        \"</ipxact:port>\"\r\n        );\r\n\r\n    PortWriter portWriter;\r\n    portWriter.writePort(xmlStreamWriter, testPort, Document::Revision::Std22);\r\n    QCOMPARE(output, expectedOutput);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ComponentPortWriter::writeStructuredWirePort_2022()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ComponentPortWriter::writeStructuredWirePort_2022()\r\n{\r\n    QString output;\r\n    QXmlStreamWriter xmlStreamWriter(&output);\r\n\r\n    QSharedPointer<Structured> testStructured(new Structured());\r\n    testStructured->setType(Structured::Type::Interface);\r\n    testStructured->setPacked(false);\r\n\r\n    QSharedPointer<Port> testPort(new Port(\"testPort\"));    \r\n    testPort->setStructured(testStructured);\r\n\r\n    QSharedPointer<SubPort> wireSubPort(new SubPort());\r\n    wireSubPort->setName(\"simpleWire\");\r\n\r\n    QSharedPointer<Wire> testWire(new Wire);\r\n    testWire->setDirection(DirectionTypes::IN);\r\n    wireSubPort->setWire(testWire);\r\n    testStructured->getSubPorts()->append(wireSubPort);\r\n\r\n    QString expectedOutput(\r\n        \"<ipxact:port>\"\r\n            \"<ipxact:name>testPort</ipxact:name>\"\r\n            \"<ipxact:structured>\"\r\n                \"<ipxact:interface/>\"\r\n                \"<ipxact:subPorts>\"\r\n                    \"<ipxact:subPort>\"\r\n                        \"<ipxact:name>simpleWire</ipxact:name>\"\r\n                        \"<ipxact:wire>\"\r\n                            \"<ipxact:direction>in</ipxact:direction>\"\r\n                        \"</ipxact:wire>\"\r\n                    \"</ipxact:subPort>\"\r\n                \"</ipxact:subPorts>\"\r\n            \"</ipxact:structured>\"\r\n        \"</ipxact:port>\"\r\n        );\r\n\r\n    PortWriter portWriter;\r\n    portWriter.writePort(xmlStreamWriter, testPort, Document::Revision::Std22);\r\n    QCOMPARE(output, expectedOutput);\r\n}\r\n\r\nQTEST_APPLESS_MAIN(tst_ComponentPortWriter)\r\n\r\n#include \"tst_ComponentPortWriter.moc\"\r\n"
  },
  {
    "path": "tests/IPXACTmodels/Component/tst_ComponentPortWriter.pri",
    "content": "# ----------------------------------------------------\r\n# This file is generated by the Qt Visual Studio Tools.\r\n# ------------------------------------------------------\r\n\r\nSOURCES += ./tst_ComponentPortWriter.cpp \r\n"
  },
  {
    "path": "tests/IPXACTmodels/Component/tst_ComponentPortWriter.pro",
    "content": "#-----------------------------------------------------------------------------\r\n# File: tst_ComponenPortWriter.pro\r\n#-----------------------------------------------------------------------------\r\n# Project: Kactus 2\r\n# Author: Mikko Teuho\r\n# Date: 09.09.2015\r\n#\r\n# Description:\r\n# Qt project file template for running unit tests for ComponentPortWriter.\r\n#-----------------------------------------------------------------------------\r\n\r\nTEMPLATE = app\r\n\r\nTARGET = tst_ComponentPortWriter\r\n\r\nQT += core xml testlib\r\nQT -= gui\r\n\r\nCONFIG += c++17 testcase console\r\n\r\nlinux-g++ | linux-g++-64 | linux-g++-32 {\r\n LIBS += -L../../../executable \\\r\n     -lIPXACTmodels\r\n\r\n}\r\nwin64 | win32 {\r\n LIBS += -L../../../executable \\\r\n     -lIPXACTmodelsd\r\n}\r\n\r\nINCLUDEPATH += $$DESTDIR\r\nINCLUDEPATH += ../../../\r\n\r\nDEPENDPATH += .\r\nDEPENDPATH += ../../../\r\n\r\nOBJECTS_DIR += $$DESTDIR\r\n\r\nMOC_DIR += ./generatedFiles\r\nUI_DIR += ./generatedFiles\r\nRCC_DIR += ./generatedFiles\r\ninclude(tst_ComponentPortWriter.pri)\r\n"
  },
  {
    "path": "tests/IPXACTmodels/Component/tst_ComponentReader.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: tst_ComponentReader.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Mikko Teuho\n// Date: 14.10.2015\n//\n// Description:\n// Unit test for class ComponentReader.\n//-----------------------------------------------------------------------------\n\n#include <IPXACTmodels/common/TagData.h>\n\n#include <IPXACTmodels/Component/ComponentReader.h>\n\n#include <IPXACTmodels/Component/AddressSpace.h>\n#include <IPXACTmodels/Component/BusInterface.h>\n#include <IPXACTmodels/Component/Channel.h>\n#include <IPXACTmodels/Component/Component.h>\n#include <IPXACTmodels/Component/ComponentGenerator.h>\n#include <IPXACTmodels/Component/ComponentInstantiation.h>\n#include <IPXACTmodels/Component/DesignInstantiation.h>\n#include <IPXACTmodels/Component/DesignConfigurationInstantiation.h>\n#include <IPXACTmodels/Component/RemapState.h>\n#include <IPXACTmodels/Component/MemoryMap.h>\n#include <IPXACTmodels/Component/Mode.h>\n#include <IPXACTmodels/Component/View.h>\n#include <IPXACTmodels/Component/Port.h>\n#include <IPXACTmodels/Component/PowerDomain.h>\n#include <IPXACTmodels/Component/FileSet.h>\n#include <IPXACTmodels/Component/Cpu.h>\n#include <IPXACTmodels/Component/OtherClockDriver.h>\n#include <IPXACTmodels/Component/IndirectInterface.h>\n#include <IPXACTmodels/Component/ResetType.h>\n#include <IPXACTmodels/common/Choice.h>\n\n#include <IPXACTmodels/kactusExtensions/ComProperty.h>\n#include <IPXACTmodels/kactusExtensions/SystemView.h>\n#include <IPXACTmodels/kactusExtensions/ComInterface.h>\n#include <IPXACTmodels/kactusExtensions/ApiInterface.h>\n#include <IPXACTmodels/kactusExtensions/FileDependency.h>\n\n#include <QtTest>\n#include <QDomNode>\n\nclass tst_ComponentReader : public QObject\n{\n    Q_OBJECT\n\npublic:\n    tst_ComponentReader();\n\nprivate slots:\n\n    void readSimpleComponent();\n    \n    void readXMLProcessingInstructions();\n    void readXMLNameSpaces();\n\n    void readPowerDomains2022();\n\n    void readBusInterfaces();\n    void readIndirectInterfaces();\n\n    void readChannels();\n    void readRemapStates();\n    void readModes2022();\n    void readAddressSpaces();\n    void readMemoryMaps();\n\n    void readViews();\n    void readInstantiations();\n    void readPorts();\n\n    void readComponentGenerators();\n    void readChoices();\n    void readFileSets();\n    void readCPUs();\n    void readOtherClockDrivers();\n    void readResetTypes();\n    void readResetTypes2022();\n\n    void readParameters();\n    void readAssertions();\n    void readVendorExtensions();\n\n    void readKactusAttributes();\n    void readSwComProperties();\n    void readSystemViews();\n    void readComInterfaces();\n    void readApiInterfaces();\n    void readFileDependencies();\n    void readAuthorAndLicense();\n\n    void readTags();\n};\n\n//-----------------------------------------------------------------------------\n// Function: tst_ComponentReader::tst_ComponentReader()\n//-----------------------------------------------------------------------------\ntst_ComponentReader::tst_ComponentReader()\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_ComponentReader::readSimpleComponent()\n//-----------------------------------------------------------------------------\nvoid tst_ComponentReader::readSimpleComponent()\n{\n    QString documentContent(\n        \"<?xml version=\\\"1.0\\\"?>\"\n        \"<ipxact:component \"\n        \"xmlns:xsi=\\\"http://www.w3.org/2001/XMLSchema-instance\\\" \" \n        \"xmlns:ipxact=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014\\\" \"\n        \"xmlns:kactus2=\\\"http://kactus2.cs.tut.fi\\\" \"\n        \"xsi:schemaLocation=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/ \"\n        \"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/index.xsd\\\">\"\n            \"<ipxact:vendor>tuni.fi</ipxact:vendor>\"\n            \"<ipxact:library>TestLibrary</ipxact:library>\"\n            \"<ipxact:name>TestComponent</ipxact:name>\"\n            \"<ipxact:version>8.14</ipxact:version>\"\n            \"<ipxact:description>coreDrill</ipxact:description>\"\n        \"</ipxact:component>\\n\"\n        );\n\n    QDomDocument document;\n    document.setContent(documentContent);\n\n    ComponentReader componentReader;\n\n    QSharedPointer<Component> testComponent = componentReader.createComponentFrom(document);\n\n    QCOMPARE(testComponent->getVlnv().getVendor(), QString(\"tuni.fi\"));\n    QCOMPARE(testComponent->getVlnv().getLibrary(), QString(\"TestLibrary\"));\n    QCOMPARE(testComponent->getVlnv().getName(), QString(\"TestComponent\"));\n    QCOMPARE(testComponent->getVlnv().getVersion(), QString(\"8.14\"));\n    QCOMPARE(testComponent->getVlnv().getType(), VLNV::COMPONENT);\n    QCOMPARE(testComponent->getDescription(), QString(\"coreDrill\"));\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_ComponentReader::readXMLProcessingInstructions()\n//-----------------------------------------------------------------------------\nvoid tst_ComponentReader::readXMLProcessingInstructions()\n{\n    QString documentContent(\n        \"<?xml version=\\\"1.0\\\"?>\"\n        \"<!-- Header comments -->\"\n        \"<?xml-stylesheet href=\\\"style.css\\\"?>\"\n        \"<?xml-stylesheet href=\\\"other.css\\\" attribute=\\\"value\\\" title=\\\"Other\\\"?>\"\n        \"<ipxact:component \"\n        \"xmlns:xsi=\\\"http://www.w3.org/2001/XMLSchema-instance\\\" \" \n        \"xmlns:ipxact=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014\\\" \"\n        \"xmlns:kactus2=\\\"http://kactus2.cs.tut.fi\\\" \"\n        \"xsi:schemaLocation=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/ \"\n        \"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/index.xsd\\\">\"\n            \"<ipxact:vendor>tuni.fi</ipxact:vendor>\"\n            \"<ipxact:library>TestLibrary</ipxact:library>\"\n            \"<ipxact:name>TestComponent</ipxact:name>\"\n            \"<ipxact:version>1.0</ipxact:version>\"\n        \"</ipxact:component>\\n\"\n        );\n\n    QDomDocument document;\n    document.setContent(documentContent);\n\n    ComponentReader componentReader;\n\n    QSharedPointer<Component> testComponent = componentReader.createComponentFrom(document);\n\n    QCOMPARE(testComponent->getXmlProcessingInstructions().size(), 2);\n\n    QPair<QString, QString> firstInstructions = testComponent->getXmlProcessingInstructions().first();\n    QCOMPARE(firstInstructions.first, QString(\"xml-stylesheet\"));\n    QCOMPARE(firstInstructions.second, QString(\"href=\\\"style.css\\\"\"));\n\n    QPair<QString, QString> secondInstructions = testComponent->getXmlProcessingInstructions().last();\n    QCOMPARE(secondInstructions.first, QString(\"xml-stylesheet\"));\n    QCOMPARE(secondInstructions.second, QString(\"href=\\\"other.css\\\" attribute=\\\"value\\\" title=\\\"Other\\\"\"));\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_ComponentReader::readXMLNameSpaces()\n//-----------------------------------------------------------------------------\nvoid tst_ComponentReader::readXMLNameSpaces()\n{\n    QString documentContent(\n        \"<?xml version=\\\"1.0\\\"?>\"\n        \"<ipxact:component \"\n        \"xmlns:xsi=\\\"http://www.w3.org/2001/XMLSchema-instance\\\" \" \n        \"xmlns:ipxact=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014\\\" \"\n        \"xmlns:kactus2=\\\"http://kactus2.cs.tut.fi\\\" \"\n        \"xsi:schemaLocation=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/ \"\n        \"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/index.xsd\\\" \"\n        \"xmlns:bogusvendor=\\\"http://bogus.tld/info.txt\\\">\"\n        \"<ipxact:vendor>tuni.fi</ipxact:vendor>\"\n        \"<ipxact:library>TestLibrary</ipxact:library>\"\n        \"<ipxact:name>TestComponent</ipxact:name>\"\n        \"<ipxact:version>1.0</ipxact:version>\"\n        \"</ipxact:component>\\n\"\n        );\n\n    QDomDocument document;\n    document.setContent(documentContent);\n\n    ComponentReader componentReader;\n\n    QSharedPointer<Component> testComponent = componentReader.createComponentFrom(document);\n\n    QCOMPARE(testComponent->getXmlNameSpaces().size(), 4);\n\n    QPair<QString, QString> xsiNs = testComponent->getXmlNameSpaces().at(0);\n    QCOMPARE(xsiNs.first, QStringLiteral(\"xsi\"));\n    QCOMPARE(xsiNs.second, QStringLiteral(\"http://www.w3.org/2001/XMLSchema-instance\"));\n\n    QPair<QString, QString> ipxactNs = testComponent->getXmlNameSpaces().at(1);\n    QCOMPARE(ipxactNs.first, QStringLiteral(\"ipxact\"));\n    QCOMPARE(ipxactNs.second, QStringLiteral(\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014\"));\n\n    QPair<QString, QString> kactus2Ns = testComponent->getXmlNameSpaces().at(2);\n    QCOMPARE(kactus2Ns.first, QStringLiteral(\"kactus2\"));\n    QCOMPARE(kactus2Ns.second, QStringLiteral(\"http://kactus2.cs.tut.fi\"));\n\n    QPair<QString, QString> bogusNs = testComponent->getXmlNameSpaces().at(3);\n    QCOMPARE(bogusNs.first, QStringLiteral(\"bogusvendor\"));\n    QCOMPARE(bogusNs.second, QStringLiteral(\"http://bogus.tld/info.txt\"));\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_ComponentReader::readPowerDomains2022()\n//-----------------------------------------------------------------------------\nvoid tst_ComponentReader::readPowerDomains2022()\n{\n     QString documentContent(\n        \"<?xml version=\\\"1.0\\\"?>\"\n        \"<ipxact:component \"\n        \"xmlns:xsi=\\\"http://www.w3.org/2001/XMLSchema-instance\\\" \" \n        \"xmlns:ipxact=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2022\\\" \"\n        \"xmlns:kactus2=\\\"http://kactus2.cs.tut.fi\\\" \"\n        \"xsi:schemaLocation=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2022/ \"\n        \"http://www.accellera.org/XMLSchema/IPXACT/1685-2022/index.xsd\\\">\\n\"\n            \"<ipxact:vendor>tuni.fi</ipxact:vendor>\"\n            \"<ipxact:library>TestLibrary</ipxact:library>\"\n            \"<ipxact:name>TestComponent</ipxact:name>\"\n            \"<ipxact:version>0.11</ipxact:version>\"\n            \"<ipxact:powerDomains>\"\n                \"<ipxact:powerDomain>\"\n                    \"<ipxact:name>testDomain</ipxact:name>\"\n                    \"<ipxact:alwaysOn>1</ipxact:alwaysOn>\"\n                \"</ipxact:powerDomain>\"\n            \"</ipxact:powerDomains>\"\n        \"</ipxact:component>\"\n        );\n\n    QDomDocument document;\n    document.setContent(documentContent);\n\n    ComponentReader componentReader;\n\n    QSharedPointer<Component> testComponent = componentReader.createComponentFrom(document);\n\n    QCOMPARE(testComponent->getVlnv().getName(), QString(\"TestComponent\"));\n    QCOMPARE(testComponent->getPowerDomains()->size(), 1);\n\n    QSharedPointer<PowerDomain> domain = testComponent->getPowerDomains()->first();\n    QCOMPARE(domain->name(), QString(\"testDomain\"));\n    QCOMPARE(domain->getAlwaysOn(), QString(\"1\"));\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_ComponentReader::readBusInterfaces()\n//-----------------------------------------------------------------------------\nvoid tst_ComponentReader::readBusInterfaces()\n{\n    QString documentContent(\n        \"<?xml version=\\\"1.0\\\"?>\"\n        \"<ipxact:component \"\n        \"xmlns:xsi=\\\"http://www.w3.org/2001/XMLSchema-instance\\\" \" \n        \"xmlns:ipxact=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014\\\" \"\n        \"xmlns:kactus2=\\\"http://kactus2.cs.tut.fi\\\" \"\n        \"xsi:schemaLocation=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/ \"\n        \"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/index.xsd\\\">\\n\"\n            \"<ipxact:vendor>tuni.fi</ipxact:vendor>\"\n            \"<ipxact:library>TestLibrary</ipxact:library>\"\n            \"<ipxact:name>TestComponent</ipxact:name>\"\n            \"<ipxact:version>0.11</ipxact:version>\"\n            \"<ipxact:busInterfaces>\"\n                \"<ipxact:busInterface>\"\n                    \"<ipxact:name>testInterface</ipxact:name>\"\n                    \"<ipxact:busType vendor=\\\"tuni.fi\\\" library=\\\"TestLibrary\\\" name=\\\"busDefinition\\\"\"\n                        \" version=\\\"0.2\\\"/>\"\n                    \"<ipxact:master/>\"\n                \"</ipxact:busInterface>\"\n            \"</ipxact:busInterfaces>\"\n        \"</ipxact:component>\"\n        );\n\n    QDomDocument document;\n    document.setContent(documentContent);\n\n    ComponentReader componentReader;\n\n    QSharedPointer<Component> testComponent = componentReader.createComponentFrom(document);\n\n    QCOMPARE(testComponent->getVlnv().getName(), QString(\"TestComponent\"));\n    QCOMPARE(testComponent->getBusInterfaces()->size(), 1);\n\n    QSharedPointer<BusInterface> busInterface = testComponent->getBusInterfaces()->first();\n    QCOMPARE(busInterface->name(), QString(\"testInterface\"));\n    QCOMPARE(busInterface->getBusType().getVendor(), QString(\"tuni.fi\"));\n    QCOMPARE(busInterface->getBusType().getLibrary(), QString(\"TestLibrary\"));\n    QCOMPARE(busInterface->getBusType().getName(), QString(\"busDefinition\"));\n    QCOMPARE(busInterface->getBusType().getVersion(), QString(\"0.2\"));\n    QCOMPARE(busInterface->getInterfaceMode(), General::MASTER);\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_ComponentReader::readIndirectInterfaces()\n//-----------------------------------------------------------------------------\nvoid tst_ComponentReader::readIndirectInterfaces()\n{\n    QString documentContent(\n        \"<?xml version=\\\"1.0\\\"?>\"\n        \"<ipxact:component xmlns:xsi=\\\"http://www.w3.org/2001/XMLSchema-instance\\\" \" \n        \"xmlns:ipxact=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014\\\" \"\n        \"xmlns:kactus2=\\\"http://kactus2.cs.tut.fi\\\" \"\n        \"xsi:schemaLocation=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/ \"\n        \"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/index.xsd\\\">\\n\"\n            \"<ipxact:vendor>tuni.fi</ipxact:vendor>\"\n            \"<ipxact:library>TestLibrary</ipxact:library>\"\n            \"<ipxact:name>TestComponent</ipxact:name>\"\n            \"<ipxact:version>1.0</ipxact:version>\"\n            \"<ipxact:indirectInterfaces>\"\n                \"<ipxact:indirectInterface>\"\n                    \"<ipxact:name>testInterface</ipxact:name>\"\n                    \"<ipxact:indirectAddressRef>addressRef</ipxact:indirectAddressRef>\"\n                    \"<ipxact:indirectDataRef>dataRef</ipxact:indirectDataRef>\"        \n                    \"<ipxact:memoryMapRef>map1</ipxact:memoryMapRef>\"\n                \"</ipxact:indirectInterface>\"\n            \"</ipxact:indirectInterfaces>\"\n        \"</ipxact:component>\"\n        );\n\n    QDomDocument document;\n    document.setContent(documentContent);\n\n    ComponentReader componentReader;\n\n    QSharedPointer<Component> testComponent = componentReader.createComponentFrom(document);\n\n    QCOMPARE(testComponent->getVlnv().getName(), QString(\"TestComponent\"));\n    QCOMPARE(testComponent->getIndirectInterfaces()->size(), 1);\n\n    QSharedPointer<IndirectInterface> indirectInterface = testComponent->getIndirectInterfaces()->first();\n    QCOMPARE(indirectInterface->name(), QString(\"testInterface\"));\n    QCOMPARE(indirectInterface->getIndirectAddressRef(), QString(\"addressRef\"));\n    QCOMPARE(indirectInterface->getIndirectDataRef(), QString(\"dataRef\"));\n    QCOMPARE(indirectInterface->getMemoryMapRef(), QString(\"map1\"));\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_ComponentReader::readChannels()\n//-----------------------------------------------------------------------------\nvoid tst_ComponentReader::readChannels()\n{\n    QString documentContent(\n        \"<?xml version=\\\"1.0\\\"?>\"\n        \"<ipxact:component \"\n        \"xmlns:xsi=\\\"http://www.w3.org/2001/XMLSchema-instance\\\" \" \n        \"xmlns:ipxact=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014\\\" \"\n        \"xmlns:kactus2=\\\"http://kactus2.cs.tut.fi\\\" \"\n        \"xsi:schemaLocation=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/ \"\n        \"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/index.xsd\\\">\"\n            \"<ipxact:vendor>tuni.fi</ipxact:vendor>\"\n            \"<ipxact:library>TestLibrary</ipxact:library>\"\n            \"<ipxact:name>TestComponent</ipxact:name>\"\n            \"<ipxact:version>0.11</ipxact:version>\"\n            \"<ipxact:channels>\"\n                \"<ipxact:channel>\"\n                    \"<ipxact:name>testChannel</ipxact:name>\"\n                    \"<ipxact:busInterfaceRef>\"\n                        \"<ipxact:localName>interfaceOne</ipxact:localName>\"\n                    \"</ipxact:busInterfaceRef>\"\n                    \"<ipxact:busInterfaceRef>\"\n                        \"<ipxact:localName>interfaceTwo</ipxact:localName>\"\n                    \"</ipxact:busInterfaceRef>\"\n                \"</ipxact:channel>\"\n            \"</ipxact:channels>\"\n        \"</ipxact:component>\"\n        );\n\n    QDomDocument document;\n    document.setContent(documentContent);\n\n    ComponentReader componentReader;\n\n    QSharedPointer<Component> testComponent = componentReader.createComponentFrom(document);\n\n    QCOMPARE(testComponent->getVlnv().getName(), QString(\"TestComponent\"));\n    QCOMPARE(testComponent->getBusInterfaces()->size(), 0);\n    QCOMPARE(testComponent->getChannels()->size(), 1);\n\n    QSharedPointer<Channel> channel = testComponent->getChannels()->first();\n    QCOMPARE(channel->name(), QString(\"testChannel\"));\n    QCOMPARE(channel->getInterfaces()->size(), 2);\n    QCOMPARE(channel->getInterfaces()->first()->localName_, QString(\"interfaceOne\"));\n    QCOMPARE(channel->getInterfaces()->last()->localName_, QString(\"interfaceTwo\"));\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_ComponentReader::readRemapStates()\n//-----------------------------------------------------------------------------\nvoid tst_ComponentReader::readRemapStates()\n{\n    QString documentContent(\n        \"<?xml version=\\\"1.0\\\"?>\"\n        \"<ipxact:component \"\n        \"xmlns:xsi=\\\"http://www.w3.org/2001/XMLSchema-instance\\\" \" \n        \"xmlns:ipxact=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014\\\" \"\n        \"xmlns:kactus2=\\\"http://kactus2.cs.tut.fi\\\" \"\n        \"xsi:schemaLocation=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/ \"\n        \"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/index.xsd\\\">\"\n            \"<ipxact:vendor>tuni.fi</ipxact:vendor>\"\n            \"<ipxact:library>TestLibrary</ipxact:library>\"\n            \"<ipxact:name>TestComponent</ipxact:name>\"\n            \"<ipxact:version>0.11</ipxact:version>\"\n            \"<ipxact:remapStates>\"\n                \"<ipxact:remapState>\"\n                    \"<ipxact:name>remap</ipxact:name>\"\n                \"</ipxact:remapState>\"\n            \"</ipxact:remapStates>\"\n        \"</ipxact:component>\"\n        );\n\n    QDomDocument document;\n    document.setContent(documentContent);\n\n    ComponentReader componentReader;\n\n    QSharedPointer<Component> testComponent = componentReader.createComponentFrom(document);\n\n    QCOMPARE(testComponent->getVlnv().getName(), QString(\"TestComponent\"));\n    QCOMPARE(testComponent->getChannels()->size(), 0);\n    QCOMPARE(testComponent->getRemapStates()->size(), 1);\n\n    QSharedPointer<RemapState> remapState = testComponent->getRemapStates()->first();\n    QCOMPARE(remapState->name(), QString(\"remap\"));\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_ComponentReader::readModes2022()\n//-----------------------------------------------------------------------------\nvoid tst_ComponentReader::readModes2022()\n{\n    QString documentContent(\n        \"<?xml version=\\\"1.0\\\"?>\"\n        \"<ipxact:component \"\n        \"xmlns:xsi=\\\"http://www.w3.org/2001/XMLSchema-instance\\\" \" \n        \"xmlns:ipxact=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2022\\\" \"\n        \"xmlns:kactus2=\\\"http://kactus2.cs.tut.fi\\\" \"\n        \"xsi:schemaLocation=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2022/ \"\n        \"http://www.accellera.org/XMLSchema/IPXACT/1685-2022/index.xsd\\\">\"\n            \"<ipxact:vendor>tuni.fi</ipxact:vendor>\"\n            \"<ipxact:library>TestLibrary</ipxact:library>\"\n            \"<ipxact:name>TestComponent</ipxact:name>\"\n            \"<ipxact:version>0.11</ipxact:version>\"\n            \"<ipxact:modes>\"\n                \"<ipxact:mode>\"\n                    \"<ipxact:name>idle</ipxact:name>\"\n                    \"<ipxact:description>Default test state</ipxact:description>\"\n                \"</ipxact:mode>\"\n            \"</ipxact:modes>\"\n        \"</ipxact:component>\"\n        );\n\n    QDomDocument document;\n    document.setContent(documentContent);\n\n    ComponentReader componentReader;\n\n    QSharedPointer<Component> testComponent = componentReader.createComponentFrom(document);\n\n    QCOMPARE(testComponent->getModes()->size(), 1);\n\n    QSharedPointer<Mode> idleMode = testComponent->getModes()->first();\n    QCOMPARE(idleMode->name(), QString(\"idle\"));\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_ComponentReader::readAddressSpaces()\n//-----------------------------------------------------------------------------\nvoid tst_ComponentReader::readAddressSpaces()\n{\n    QString documentContent(\n        \"<?xml version=\\\"1.0\\\"?>\"\n        \"<ipxact:component \"\n        \"xmlns:xsi=\\\"http://www.w3.org/2001/XMLSchema-instance\\\" \" \n        \"xmlns:ipxact=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014\\\" \"\n        \"xmlns:kactus2=\\\"http://kactus2.cs.tut.fi\\\" \"\n        \"xsi:schemaLocation=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/ \"\n        \"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/index.xsd\\\">\"\n            \"<ipxact:vendor>tuni.fi</ipxact:vendor>\"\n            \"<ipxact:library>TestLibrary</ipxact:library>\"\n            \"<ipxact:name>TestComponent</ipxact:name>\"\n            \"<ipxact:version>0.11</ipxact:version>\"\n            \"<ipxact:addressSpaces>\"\n                \"<ipxact:addressSpace>\"\n                    \"<ipxact:name>StarControl</ipxact:name>\"\n                    \"<ipxact:range>coreward</ipxact:range>\"\n                    \"<ipxact:width>front</ipxact:width>\"\n                \"</ipxact:addressSpace>\"\n            \"</ipxact:addressSpaces>\"\n        \"</ipxact:component>\"\n        );\n\n    QDomDocument document;\n    document.setContent(documentContent);\n\n    ComponentReader componentReader;\n\n    QSharedPointer<Component> testComponent = componentReader.createComponentFrom(document);\n\n    QCOMPARE(testComponent->getVlnv().getName(), QString(\"TestComponent\"));\n    QCOMPARE(testComponent->getRemapStates()->size(), 0);\n    QCOMPARE(testComponent->getAddressSpaces()->size(), 1);\n\n    QSharedPointer<AddressSpace> addressSpace = testComponent->getAddressSpaces()->first();\n    QCOMPARE(addressSpace->name(), QString(\"StarControl\"));\n    QCOMPARE(addressSpace->getRange(), QString(\"coreward\"));\n    QCOMPARE(addressSpace->getWidth(), QString(\"front\"));\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_ComponentReader::readMemoryMaps()\n//-----------------------------------------------------------------------------\nvoid tst_ComponentReader::readMemoryMaps()\n{\n    QString documentContent(\n        \"<?xml version=\\\"1.0\\\"?>\"\n        \"<ipxact:component \"\n        \"xmlns:xsi=\\\"http://www.w3.org/2001/XMLSchema-instance\\\" \" \n        \"xmlns:ipxact=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014\\\" \"\n        \"xmlns:kactus2=\\\"http://kactus2.cs.tut.fi\\\" \"\n        \"xsi:schemaLocation=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/ \"\n        \"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/index.xsd\\\">\"\n            \"<ipxact:vendor>tuni.fi</ipxact:vendor>\"\n            \"<ipxact:library>TestLibrary</ipxact:library>\"\n            \"<ipxact:name>TestComponent</ipxact:name>\"\n            \"<ipxact:version>0.11</ipxact:version>\"\n            \"<ipxact:memoryMaps>\"\n                \"<ipxact:memoryMap>\"\n                    \"<ipxact:name>memoryMap</ipxact:name>\"\n                \"</ipxact:memoryMap>\"\n            \"</ipxact:memoryMaps>\"\n        \"</ipxact:component>\"\n        );\n\n    QDomDocument document;\n    document.setContent(documentContent);\n\n    ComponentReader componentReader;\n\n    QSharedPointer<Component> testComponent = componentReader.createComponentFrom(document);\n\n    QCOMPARE(testComponent->getVlnv().getName(), QString(\"TestComponent\"));\n    QCOMPARE(testComponent->getAddressSpaces()->size(), 0);\n    QCOMPARE(testComponent->getMemoryMaps()->size(), 1);\n\n    QSharedPointer<MemoryMap> memoryMap = testComponent->getMemoryMaps()->first();\n    QCOMPARE(memoryMap->name(), QString(\"memoryMap\"));\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_ComponentReader::readViews()\n//-----------------------------------------------------------------------------\nvoid tst_ComponentReader::readViews()\n{\n    QString documentContent(\n        \"<?xml version=\\\"1.0\\\"?>\"\n        \"<ipxact:component \"\n        \"xmlns:xsi=\\\"http://www.w3.org/2001/XMLSchema-instance\\\" \" \n        \"xmlns:ipxact=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014\\\" \"\n        \"xmlns:kactus2=\\\"http://kactus2.cs.tut.fi\\\" \"\n        \"xsi:schemaLocation=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/ \"\n        \"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/index.xsd\\\">\"\n            \"<ipxact:vendor>tuni.fi</ipxact:vendor>\"\n            \"<ipxact:library>TestLibrary</ipxact:library>\"\n            \"<ipxact:name>TestComponent</ipxact:name>\"\n            \"<ipxact:version>0.11</ipxact:version>\"\n            \"<ipxact:model>\"\n                \"<ipxact:views>\"\n                    \"<ipxact:view>\"\n                        \"<ipxact:name>testView</ipxact:name>\"\n                    \"</ipxact:view>\"\n                \"</ipxact:views>\"\n            \"</ipxact:model>\"\n        \"</ipxact:component>\"\n        );\n\n    QDomDocument document;\n    document.setContent(documentContent);\n\n    ComponentReader componentReader;\n\n    QSharedPointer<Component> testComponent = componentReader.createComponentFrom(document);\n\n    QCOMPARE(testComponent->getVlnv().getName(), QString(\"TestComponent\"));\n    QCOMPARE(testComponent->getMemoryMaps()->size(), 0);\n    QCOMPARE(testComponent->getViews()->size(), 1);\n\n    QSharedPointer<View> view = testComponent->getViews()->first();\n    QCOMPARE(view->name(), QString(\"testView\"));\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_ComponentReader::readInstantiations()\n//-----------------------------------------------------------------------------\nvoid tst_ComponentReader::readInstantiations()\n{\n    QString documentContent(\n        \"<?xml version=\\\"1.0\\\"?>\"\n        \"<ipxact:component \"\n        \"xmlns:xsi=\\\"http://www.w3.org/2001/XMLSchema-instance\\\" \" \n        \"xmlns:ipxact=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014\\\" \"\n        \"xmlns:kactus2=\\\"http://kactus2.cs.tut.fi\\\" \"\n        \"xsi:schemaLocation=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/ \"\n        \"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/index.xsd\\\">\"\n            \"<ipxact:vendor>tuni.fi</ipxact:vendor>\"\n            \"<ipxact:library>TestLibrary</ipxact:library>\"\n            \"<ipxact:name>TestComponent</ipxact:name>\"\n            \"<ipxact:version>0.11</ipxact:version>\"\n            \"<ipxact:model>\"\n                \"<ipxact:instantiations>\"\n                    \"<ipxact:componentInstantiation>\"\n                        \"<ipxact:name>component</ipxact:name>\"\n                    \"</ipxact:componentInstantiation>\"\n                    \"<ipxact:designInstantiation>\"\n                        \"<ipxact:name>design</ipxact:name>\"\n                        \"<ipxact:designRef vendor=\\\"tuni.fi\\\" library=\\\"TestLibrary\\\" name=\\\"designReference\\\" \"\n                            \"version=\\\"1.0\\\"/>\"\n                    \"</ipxact:designInstantiation>\"\n                    \"<ipxact:designConfigurationInstantiation>\"\n                        \"<ipxact:name>designConfiguration</ipxact:name>\"\n                        \"<ipxact:designConfigurationRef vendor=\\\"tuni.fi\\\" library=\\\"TestLibrary\\\"\"\n                            \" name=\\\"configuration\\\" version=\\\"8.1\\\"/>\"\n                    \"</ipxact:designConfigurationInstantiation>\"\n                \"</ipxact:instantiations>\"\n            \"</ipxact:model>\"\n        \"</ipxact:component>\"\n        );\n\n    QDomDocument document;\n    document.setContent(documentContent);\n\n    ComponentReader componentReader;\n\n    QSharedPointer<Component> testComponent = componentReader.createComponentFrom(document);\n\n    QCOMPARE(testComponent->getVlnv().getName(), QString(\"TestComponent\"));\n    QCOMPARE(testComponent->getViews()->size(), 0);\n    QCOMPARE(testComponent->getComponentInstantiations()->size(), 1);\n    QCOMPARE(testComponent->getDesignInstantiations()->size(), 1);\n    QCOMPARE(testComponent->getDesignConfigurationInstantiations()->size(), 1);\n\n    QSharedPointer<ComponentInstantiation> componentInstantiation =\n        testComponent->getComponentInstantiations()->first();\n    QCOMPARE(componentInstantiation->name(), QString(\"component\"));\n\n    QSharedPointer<DesignInstantiation> designInstantiation = testComponent->getDesignInstantiations()->first();\n    QCOMPARE(designInstantiation->name(), QString(\"design\"));\n    QCOMPARE(designInstantiation->getDesignReference()->getVendor(), QString(\"tuni.fi\"));\n    QCOMPARE(designInstantiation->getDesignReference()->getLibrary(), QString(\"TestLibrary\"));\n    QCOMPARE(designInstantiation->getDesignReference()->getName(), QString(\"designReference\"));\n    QCOMPARE(designInstantiation->getDesignReference()->getVersion(), QString(\"1.0\"));\n\n    QSharedPointer<DesignConfigurationInstantiation> configurationInstantiation =\n        testComponent->getDesignConfigurationInstantiations()->first();\n    QCOMPARE(configurationInstantiation->name(), QString(\"designConfiguration\"));\n    QCOMPARE(configurationInstantiation->getDesignConfigurationReference()->getVendor(), QString(\"tuni.fi\"));\n    QCOMPARE(configurationInstantiation->getDesignConfigurationReference()->getLibrary(), QString(\"TestLibrary\"));\n    QCOMPARE(configurationInstantiation->getDesignConfigurationReference()->getName(), QString(\"configuration\"));\n    QCOMPARE(configurationInstantiation->getDesignConfigurationReference()->getVersion(), QString(\"8.1\"));\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_ComponentReader::readPorts()\n//-----------------------------------------------------------------------------\nvoid tst_ComponentReader::readPorts()\n{\n    QString documentContent(\n        \"<?xml version=\\\"1.0\\\"?>\"\n        \"<ipxact:component \"\n        \"xmlns:xsi=\\\"http://www.w3.org/2001/XMLSchema-instance\\\" \" \n        \"xmlns:ipxact=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014\\\" \"\n        \"xmlns:kactus2=\\\"http://kactus2.cs.tut.fi\\\" \"\n        \"xsi:schemaLocation=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/ \"\n        \"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/index.xsd\\\">\"\n            \"<ipxact:vendor>tuni.fi</ipxact:vendor>\"\n            \"<ipxact:library>TestLibrary</ipxact:library>\"\n            \"<ipxact:name>TestComponent</ipxact:name>\"\n            \"<ipxact:version>0.11</ipxact:version>\"\n            \"<ipxact:model>\"\n                \"<ipxact:ports>\"\n                    \"<ipxact:port>\"\n                        \"<ipxact:name>testPort</ipxact:name>\"\n                        \"<ipxact:wire>\"\n                            \"<ipxact:direction>in</ipxact:direction>\"\n                        \"</ipxact:wire>\"\n                    \"</ipxact:port>\"\n                \"</ipxact:ports>\"\n            \"</ipxact:model>\"\n        \"</ipxact:component>\"\n        );\n\n    QDomDocument document;\n    document.setContent(documentContent);\n\n    ComponentReader componentReader;\n\n    QSharedPointer<Component> testComponent = componentReader.createComponentFrom(document);\n\n    QCOMPARE(testComponent->getVlnv().getName(), QString(\"TestComponent\"));\n    QCOMPARE(testComponent->getComponentInstantiations()->size(), 0);\n    QCOMPARE(testComponent->getDesignInstantiations()->size(), 0);\n    QCOMPARE(testComponent->getDesignConfigurationInstantiations()->size(), 0);\n    QCOMPARE(testComponent->getPorts()->size(), 1);\n\n    QSharedPointer<Port> port = testComponent->getPorts()->first();\n    QCOMPARE(port->name(), QString(\"testPort\"));\n    QCOMPARE(port->getWire().isNull(), false);\n    QCOMPARE(port->getWire()->getDirection(), DirectionTypes::IN);\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_ComponentReader::readComponentGenerators()\n//-----------------------------------------------------------------------------\nvoid tst_ComponentReader::readComponentGenerators()\n{\n    QString documentContent(\n        \"<?xml version=\\\"1.0\\\"?>\"\n        \"<ipxact:component \"\n        \"xmlns:xsi=\\\"http://www.w3.org/2001/XMLSchema-instance\\\" \" \n        \"xmlns:ipxact=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014\\\" \"\n        \"xmlns:kactus2=\\\"http://kactus2.cs.tut.fi\\\" \"\n        \"xsi:schemaLocation=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/ \"\n        \"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/index.xsd\\\">\"\n            \"<ipxact:vendor>tuni.fi</ipxact:vendor>\"\n            \"<ipxact:library>TestLibrary</ipxact:library>\"\n            \"<ipxact:name>TestComponent</ipxact:name>\"\n            \"<ipxact:version>0.11</ipxact:version>\"\n            \"<ipxact:componentGenerators>\"\n                \"<ipxact:componentGenerator>\"\n                    \"<ipxact:name>generator</ipxact:name>\"\n                    \"<ipxact:generatorExe>saMatra</ipxact:generatorExe>\"\n                \"</ipxact:componentGenerator>\"\n            \"</ipxact:componentGenerators>\"\n        \"</ipxact:component>\\n\"\n        );\n\n    QDomDocument document;\n    document.setContent(documentContent);\n\n    ComponentReader componentReader;\n\n    QSharedPointer<Component> testComponent = componentReader.createComponentFrom(document);\n\n    QCOMPARE(testComponent->getVlnv().getName(), QString(\"TestComponent\"));\n    QCOMPARE(testComponent->getPorts()->size(), 0);\n    QCOMPARE(testComponent->getComponentGenerators()->size(), 1);\n\n    QSharedPointer<ComponentGenerator> generator = testComponent->getComponentGenerators()->first();\n    QCOMPARE(generator->name(), QString(\"generator\"));\n    QCOMPARE(generator->getGeneratorExe(), QString(\"saMatra\"));\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_ComponentReader::readChoices()\n//-----------------------------------------------------------------------------\nvoid tst_ComponentReader::readChoices()\n{\n    QString documentContent(\n        \"<?xml version=\\\"1.0\\\"?>\"\n        \"<ipxact:component \"\n        \"xmlns:xsi=\\\"http://www.w3.org/2001/XMLSchema-instance\\\" \" \n        \"xmlns:ipxact=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014\\\" \"\n        \"xmlns:kactus2=\\\"http://kactus2.cs.tut.fi\\\" \"\n        \"xsi:schemaLocation=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/ \"\n        \"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/index.xsd\\\">\"\n            \"<ipxact:vendor>tuni.fi</ipxact:vendor>\"\n            \"<ipxact:library>TestLibrary</ipxact:library>\"\n            \"<ipxact:name>TestComponent</ipxact:name>\"\n            \"<ipxact:version>0.11</ipxact:version>\"\n            \"<ipxact:choices>\"\n                \"<ipxact:choice>\"\n                    \"<ipxact:name>chosenOne</ipxact:name>\"\n                    \"<ipxact:enumeration>14</ipxact:enumeration>\"\n                \"</ipxact:choice>\"\n            \"</ipxact:choices>\"\n        \"</ipxact:component>\"\n        );\n\n    QDomDocument document;\n    document.setContent(documentContent);\n\n    ComponentReader componentReader;\n\n    QSharedPointer<Component> testComponent = componentReader.createComponentFrom(document);\n\n    QCOMPARE(testComponent->getVlnv().getName(), QString(\"TestComponent\"));\n    QCOMPARE(testComponent->getComponentGenerators()->size(), 0);\n    QCOMPARE(testComponent->getChoices()->size(), 1);\n\n    QSharedPointer<Choice> testChoice = testComponent->getChoices()->first();\n    QCOMPARE(testChoice->name(), QString(\"chosenOne\"));\n    QCOMPARE(testChoice->getEnumerationValues().size(), 1);\n    QCOMPARE(testChoice->getEnumerationValues().first(), QString(\"14\"));\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_ComponentReader::readFileSets()\n//-----------------------------------------------------------------------------\nvoid tst_ComponentReader::readFileSets()\n{\n    QString documentContent(\n        \"<?xml version=\\\"1.0\\\"?>\"\n        \"<ipxact:component \"\n        \"xmlns:xsi=\\\"http://www.w3.org/2001/XMLSchema-instance\\\" \" \n        \"xmlns:ipxact=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014\\\" \"\n        \"xmlns:kactus2=\\\"http://kactus2.cs.tut.fi\\\" \"\n        \"xsi:schemaLocation=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/ \"\n        \"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/index.xsd\\\">\"\n            \"<ipxact:vendor>tuni.fi</ipxact:vendor>\"\n            \"<ipxact:library>TestLibrary</ipxact:library>\"\n            \"<ipxact:name>TestComponent</ipxact:name>\"\n            \"<ipxact:version>0.11</ipxact:version>\"\n            \"<ipxact:fileSets>\"\n                \"<ipxact:fileSet>\"\n                    \"<ipxact:name>urquanMasters</ipxact:name>\"\n                \"</ipxact:fileSet>\"\n            \"</ipxact:fileSets>\"\n        \"</ipxact:component>\"\n        );\n\n    QDomDocument document;\n    document.setContent(documentContent);\n\n    ComponentReader componentReader;\n\n    QSharedPointer<Component> testComponent = componentReader.createComponentFrom(document);\n\n    QCOMPARE(testComponent->getVlnv().getName(), QString(\"TestComponent\"));\n    QCOMPARE(testComponent->getChoices()->size(), 0);\n    QCOMPARE(testComponent->getFileSets()->size(), 1);\n\n    QSharedPointer<FileSet> fileSet = testComponent->getFileSets()->first();\n    QCOMPARE(fileSet->name(), QString(\"urquanMasters\"));\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_ComponentReader::readCPUs()\n//-----------------------------------------------------------------------------\nvoid tst_ComponentReader::readCPUs()\n{\n    QString documentContent(\n        \"<?xml version=\\\"1.0\\\"?>\"\n        \"<ipxact:component \"\n        \"xmlns:xsi=\\\"http://www.w3.org/2001/XMLSchema-instance\\\" \" \n        \"xmlns:ipxact=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014\\\" \"\n        \"xmlns:kactus2=\\\"http://kactus2.cs.tut.fi\\\" \"\n        \"xsi:schemaLocation=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/ \"\n        \"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/index.xsd\\\">\"\n            \"<ipxact:vendor>tuni.fi</ipxact:vendor>\"\n            \"<ipxact:library>TestLibrary</ipxact:library>\"\n            \"<ipxact:name>TestComponent</ipxact:name>\"\n            \"<ipxact:version>0.11</ipxact:version>\"\n            \"<ipxact:cpus>\"\n                \"<ipxact:cpu>\"\n                    \"<ipxact:name>Chmmr</ipxact:name>\"\n                    \"<ipxact:addressSpaceRef addressSpaceRef=\\\"Avatar\\\"/>\"\n                \"</ipxact:cpu>\"\n            \"</ipxact:cpus>\"\n        \"</ipxact:component>\"\n        );\n\n    QDomDocument document;\n    document.setContent(documentContent);\n\n    ComponentReader componentReader;\n\n    QSharedPointer<Component> testComponent = componentReader.createComponentFrom(document);\n\n    QCOMPARE(testComponent->getVlnv().getName(), QString(\"TestComponent\"));\n    QCOMPARE(testComponent->getFileSets()->size(), 0);\n    QCOMPARE(testComponent->getCpus()->size(), 1);\n\n    QSharedPointer<Cpu> testCPU = testComponent->getCpus()->first();\n    QCOMPARE(testCPU->name(), QString(\"Chmmr\"));\n    QCOMPARE(testCPU->getAddressSpaceReferences()->size(), 1);\n    QCOMPARE(testCPU->getAddressSpaceReferences()->first()->addressSpaceRef_, QString(\"Avatar\"));\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_ComponentReader::readOtherClockDrivers()\n//-----------------------------------------------------------------------------\nvoid tst_ComponentReader::readOtherClockDrivers()\n{\n    QString documentContent(\n        \"<?xml version=\\\"1.0\\\"?>\"\n        \"<ipxact:component \"\n        \"xmlns:xsi=\\\"http://www.w3.org/2001/XMLSchema-instance\\\" \" \n        \"xmlns:ipxact=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014\\\" \"\n        \"xmlns:kactus2=\\\"http://kactus2.cs.tut.fi\\\" \"\n        \"xsi:schemaLocation=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/ \"\n        \"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/index.xsd\\\">\"\n            \"<ipxact:vendor>tuni.fi</ipxact:vendor>\"\n            \"<ipxact:library>TestLibrary</ipxact:library>\"\n            \"<ipxact:name>TestComponent</ipxact:name>\"\n            \"<ipxact:version>0.11</ipxact:version>\"\n            \"<ipxact:otherClockDrivers>\"\n                \"<ipxact:otherClockDriver clockName=\\\"clockName\\\">\"\n                    \"<ipxact:clockPeriod>watch</ipxact:clockPeriod>\"\n                    \"<ipxact:clockPulseOffset>Laser</ipxact:clockPulseOffset>\"\n                    \"<ipxact:clockPulseValue>KingOsrik</ipxact:clockPulseValue>\"\n                    \"<ipxact:clockPulseDuration>eternity</ipxact:clockPulseDuration>\"\n                \"</ipxact:otherClockDriver>\"\n            \"</ipxact:otherClockDrivers>\"\n        \"</ipxact:component>\"\n        );\n\n    QDomDocument document;\n    document.setContent(documentContent);\n\n    ComponentReader componentReader;\n\n    QSharedPointer<Component> testComponent = componentReader.createComponentFrom(document);\n\n    QCOMPARE(testComponent->getVlnv().getName(), QString(\"TestComponent\"));\n    QCOMPARE(testComponent->getCpus()->size(), 0);\n    QCOMPARE(testComponent->getOtherClockDrivers()->size(), 1);\n\n    QSharedPointer<OtherClockDriver> clockDriver = testComponent->getOtherClockDrivers()->first();\n    QCOMPARE(clockDriver->getClockName(), QString(\"clockName\"));\n    QCOMPARE(clockDriver->getClockPeriod()->getValue(), QString(\"watch\"));\n    QCOMPARE(clockDriver->getClockPulseOffset()->getValue(), QString(\"Laser\"));\n    QCOMPARE(clockDriver->getClockPulseValue(), QString(\"KingOsrik\"));\n    QCOMPARE(clockDriver->getClockPulseDuration()->getValue(), QString(\"eternity\"));\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_ComponentReader::readResetTypes()\n//-----------------------------------------------------------------------------\nvoid tst_ComponentReader::readResetTypes()\n{\n    ComponentReader componentReader;\n\n    QString documentContent(\n        \"<?xml version=\\\"1.0\\\"?>\"\n        \"<ipxact:component \"\n        \"xmlns:xsi=\\\"http://www.w3.org/2001/XMLSchema-instance\\\" \"\n        \"xmlns:ipxact=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014\\\" \"\n        \"xmlns:kactus2=\\\"http://kactus2.cs.tut.fi\\\" \"\n        \"xsi:schemaLocation=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/ \"\n        \"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/index.xsd\\\">\"\n            \"<ipxact:vendor>tuni.fi</ipxact:vendor>\"\n            \"<ipxact:library>TestLibrary</ipxact:library>\"\n            \"<ipxact:name>TestComponent</ipxact:name>\"\n            \"<ipxact:version>0.11</ipxact:version>\"\n        \"</ipxact:component>\"\n    );\n\n    QDomDocument document;\n    document.setContent(documentContent);\n\n    QSharedPointer<Component> testComponent = componentReader.createComponentFrom(document);\n    QCOMPARE(testComponent->getResetTypes()->size(), 0);\n\n    documentContent = \n        \"<?xml version=\\\"1.0\\\"?>\"\n        \"<ipxact:component \"\n        \"xmlns:xsi=\\\"http://www.w3.org/2001/XMLSchema-instance\\\" \"\n        \"xmlns:ipxact=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014\\\" \"\n        \"xmlns:kactus2=\\\"http://kactus2.cs.tut.fi\\\" \"\n        \"xsi:schemaLocation=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/ \"\n        \"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/index.xsd\\\">\"\n            \"<ipxact:vendor>tuni.fi</ipxact:vendor>\"\n            \"<ipxact:library>TestLibrary</ipxact:library>\"\n            \"<ipxact:name>TestComponent</ipxact:name>\"\n            \"<ipxact:version>0.11</ipxact:version>\"\n            \"<ipxact:resetTypes>\"\n                \"<ipxact:resetType>\"\n                    \"<ipxact:name>SOFT</ipxact:name>\"\n                    \"<ipxact:displayName>Soft Reset</ipxact:displayName>\"\n                \"</ipxact:resetType>\"\n            \"</ipxact:resetTypes>\"\n        \"</ipxact:component>\"\n    ;\n\n    document.setContent(documentContent);\n\n    testComponent = componentReader.createComponentFrom(document);\n    QCOMPARE(testComponent->getResetTypes()->size(), 1);\n\n    QSharedPointer<ResetType> testReset = testComponent->getResetTypes()->first();\n    QCOMPARE(testReset->name(), QString(\"SOFT\"));\n    QCOMPARE(testReset->displayName(), QString(\"Soft Reset\"));\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_ComponentReader::readResetTypes2022()\n//-----------------------------------------------------------------------------\nvoid tst_ComponentReader::readResetTypes2022()\n{\n    ComponentReader componentReader;\n\n    QString documentContent = \n        \"<?xml version=\\\"1.0\\\"?>\"\n        \"<ipxact:component \"\n        \"xmlns:xsi=\\\"http://www.w3.org/2001/XMLSchema-instance\\\" \"\n        \"xmlns:ipxact=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2022\\\" \"\n        \"xmlns:kactus2=\\\"http://kactus2.cs.tut.fi\\\" \"\n        \"xsi:schemaLocation=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2022/ \"\n        \"http://www.accellera.org/XMLSchema/IPXACT/1685-2022/index.xsd\\\">\"\n            \"<ipxact:vendor>tuni.fi</ipxact:vendor>\"\n            \"<ipxact:library>TestLibrary</ipxact:library>\"\n            \"<ipxact:name>TestComponent</ipxact:name>\"\n            \"<ipxact:version>0.11</ipxact:version>\"\n            \"<ipxact:resetTypes>\"\n                \"<ipxact:resetType>\"\n                    \"<ipxact:name>SOFT</ipxact:name>\"\n                    \"<ipxact:displayName>Soft Reset</ipxact:displayName>\"\n                    \"<ipxact:shortDescription>brief</ipxact:shortDescription>\"\n                    \"<ipxact:description>Not hard reset</ipxact:description>\"\n                \"</ipxact:resetType>\"\n            \"</ipxact:resetTypes>\"\n        \"</ipxact:component>\";\n\n    QDomDocument document;\n    document.setContent(documentContent);\n\n    QSharedPointer<Component> testComponent = componentReader.createComponentFrom(document);\n    QCOMPARE(testComponent->getResetTypes()->size(), 1);\n\n    QSharedPointer<ResetType> testReset = testComponent->getResetTypes()->first();\n    QCOMPARE(testReset->name(), QString(\"SOFT\"));\n    QCOMPARE(testReset->displayName(), QString(\"Soft Reset\"));\n    QCOMPARE(testReset->shortDescription(), QString(\"brief\"));\n    QCOMPARE(testReset->description(), QString(\"Not hard reset\"));\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_ComponentReader::readParameters()\n//-----------------------------------------------------------------------------\nvoid tst_ComponentReader::readParameters()\n{\n    QString documentContent(\n        \"<?xml version=\\\"1.0\\\"?>\"\n        \"<ipxact:component \"\n        \"xmlns:xsi=\\\"http://www.w3.org/2001/XMLSchema-instance\\\" \" \n        \"xmlns:ipxact=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014\\\" \"\n        \"xmlns:kactus2=\\\"http://kactus2.cs.tut.fi\\\" \"\n        \"xsi:schemaLocation=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/ \"\n        \"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/index.xsd\\\">\"\n            \"<ipxact:vendor>tuni.fi</ipxact:vendor>\"\n            \"<ipxact:library>TestLibrary</ipxact:library>\"\n            \"<ipxact:name>TestComponent</ipxact:name>\"\n            \"<ipxact:version>0.11</ipxact:version>\"\n            \"<ipxact:parameters>\"\n                \"<ipxact:parameter parameterId=\\\"testID\\\">\"\n                    \"<ipxact:name>testParameter</ipxact:name>\"\n                    \"<ipxact:value>1</ipxact:value>\"\n                \"</ipxact:parameter>\"\n            \"</ipxact:parameters>\"\n        \"</ipxact:component>\"\n        );\n\n    QDomDocument document;\n    document.setContent(documentContent);\n\n    ComponentReader componentReader;\n\n    QSharedPointer<Component> testComponent = componentReader.createComponentFrom(document);\n\n    QCOMPARE(testComponent->getVlnv().getName(), QString(\"TestComponent\"));\n    QCOMPARE(testComponent->getOtherClockDrivers()->size(), 0);\n    QCOMPARE(testComponent->getParameters()->size(), 1);\n\n    QSharedPointer<Parameter> testParameter = testComponent->getParameters()->first();\n    QCOMPARE(testParameter->getValueId(), QString(\"testID\"));\n    QCOMPARE(testParameter->name(), QString(\"testParameter\"));\n    QCOMPARE(testParameter->getValue(), QString(\"1\"));\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_ComponentReader::readAssertions()\n//-----------------------------------------------------------------------------\nvoid tst_ComponentReader::readAssertions()\n{\n    QString documentContent(\n        \"<?xml version=\\\"1.0\\\"?>\"\n        \"<ipxact:component \"\n        \"xmlns:xsi=\\\"http://www.w3.org/2001/XMLSchema-instance\\\" \" \n        \"xmlns:ipxact=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014\\\" \"\n        \"xmlns:kactus2=\\\"http://kactus2.cs.tut.fi\\\" \"\n        \"xsi:schemaLocation=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/ \"\n        \"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/index.xsd\\\">\"\n            \"<ipxact:vendor>tuni.fi</ipxact:vendor>\"\n            \"<ipxact:library>TestLibrary</ipxact:library>\"\n            \"<ipxact:name>TestComponent</ipxact:name>\"\n            \"<ipxact:version>0.11</ipxact:version>\"\n            \"<ipxact:assertions>\"\n                \"<ipxact:assertion>\"\n                    \"<ipxact:name>testAssertion</ipxact:name>\"\n                    \"<ipxact:displayName>assertionDisplay</ipxact:displayName>\"\n                    \"<ipxact:description>assertionDescription</ipxact:description>\"\n                    \"<ipxact:assert>13</ipxact:assert>\"\n                \"</ipxact:assertion>\"\n            \"</ipxact:assertions>\"\n        \"</ipxact:component>\"\n        );\n\n    QDomDocument document;\n    document.setContent(documentContent);\n\n    ComponentReader componentReader;\n\n    QSharedPointer<Component> testComponent = componentReader.createComponentFrom(document);\n\n    QCOMPARE(testComponent->getVlnv().getName(), QString(\"TestComponent\"));\n    QCOMPARE(testComponent->getParameters()->size(), 0);\n    QCOMPARE(testComponent->getAssertions()->size(), 1);\n\n    QSharedPointer<Assertion> testAssertion = testComponent->getAssertions()->first();\n    QCOMPARE(testAssertion->name(), QString(\"testAssertion\"));\n    QCOMPARE(testAssertion->displayName(), QString(\"assertionDisplay\"));\n    QCOMPARE(testAssertion->description(), QString(\"assertionDescription\"));\n    QCOMPARE(testAssertion->getAssert(), QString(\"13\"));\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_ComponentReader::readVendorExtensions()\n//-----------------------------------------------------------------------------\nvoid tst_ComponentReader::readVendorExtensions()\n{\n    QString documentContent(\n        \"<?xml version=\\\"1.0\\\"?>\"\n        \"<ipxact:component \"\n        \"xmlns:xsi=\\\"http://www.w3.org/2001/XMLSchema-instance\\\" \" \n        \"xmlns:ipxact=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014\\\" \"\n        \"xmlns:kactus2=\\\"http://kactus2.cs.tut.fi\\\" \"\n        \"xsi:schemaLocation=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/ \"\n        \"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/index.xsd\\\">\"\n            \"<ipxact:vendor>tuni.fi</ipxact:vendor>\"\n            \"<ipxact:library>TestLibrary</ipxact:library>\"\n            \"<ipxact:name>TestComponent</ipxact:name>\"\n            \"<ipxact:version>0.11</ipxact:version>\"\n            \"<ipxact:vendorExtensions>\"\n                \"<testExtension testExtensionAttribute=\\\"extension\\\">testValue</testExtension>\"\n                \"<kactus2:version>3.0.0</kactus2:version>\"\n            \"</ipxact:vendorExtensions>\"\n        \"</ipxact:component>\"\n        );\n\n    QDomDocument document;\n    document.setContent(documentContent);\n\n    ComponentReader componentReader;\n\n    QSharedPointer<Component> testComponent = componentReader.createComponentFrom(document);\n\n    QCOMPARE(testComponent->getVlnv().getName(), QString(\"TestComponent\"));\n    QCOMPARE(testComponent->getAssertions()->size(), 0);\n    QCOMPARE(testComponent->getVendorExtensions()->size(), 2);\n    QCOMPARE(testComponent->getVendorExtensions()->first()->type(), QString(\"kactus2:version\"));\n    QCOMPARE(testComponent->getVendorExtensions()->last()->type(), QString(\"testExtension\"));\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_ComponentReader::readKactusAttributes()\n//-----------------------------------------------------------------------------\nvoid tst_ComponentReader::readKactusAttributes()\n{\n    QString documentContent(\n        \"<?xml version=\\\"1.0\\\"?>\"\n            \"<ipxact:component \"\n            \"xmlns:xsi=\\\"http://www.w3.org/2001/XMLSchema-instance\\\" \" \n            \"xmlns:ipxact=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014\\\" \"\n            \"xmlns:kactus2=\\\"http://kactus2.cs.tut.fi\\\" \"\n            \"xsi:schemaLocation=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/ \"\n            \"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/index.xsd\\\">\"\n                \"<ipxact:vendor>tuni.fi</ipxact:vendor>\"\n                \"<ipxact:library>TestLibrary</ipxact:library>\"\n                \"<ipxact:name>TestComponent</ipxact:name>\"\n                \"<ipxact:version>0.11</ipxact:version>\"\n                \"<ipxact:vendorExtensions>\"\n                    \"<kactus2:kts_attributes>\"\n                        \"<kactus2:kts_productHier>IP</kactus2:kts_productHier>\"\n                        \"<kactus2:kts_implementation>SW</kactus2:kts_implementation>\"\n                        \"<kactus2:kts_firmness>Fixed</kactus2:kts_firmness>\"\n                    \"</kactus2:kts_attributes>\"\n                \"</ipxact:vendorExtensions>\"\n            \"</ipxact:component>\"\n        );\n\n    QDomDocument document;\n    document.setContent(documentContent);\n\n    ComponentReader componentReader;\n\n    QSharedPointer<Component> testComponent = componentReader.createComponentFrom(document);\n\n    QCOMPARE(testComponent->getHierarchy(), KactusAttribute::IP);\n    QCOMPARE(testComponent->getImplementation(), KactusAttribute::SW);\n    QCOMPARE(testComponent->getFirmness(), KactusAttribute::FIXED);    \n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_ComponentReader::readSwComProperties()\n//-----------------------------------------------------------------------------\nvoid tst_ComponentReader::readSwComProperties()\n{\n    QString documentContent(\n        \"<?xml version=\\\"1.0\\\"?>\"\n        \"<ipxact:component \"\n        \"xmlns:xsi=\\\"http://www.w3.org/2001/XMLSchema-instance\\\" \" \n        \"xmlns:ipxact=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014\\\" \"\n        \"xmlns:kactus2=\\\"http://kactus2.cs.tut.fi\\\" \"\n        \"xsi:schemaLocation=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/ \"\n        \"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/index.xsd\\\">\"\n            \"<ipxact:vendor>tuni.fi</ipxact:vendor>\"\n            \"<ipxact:library>TestLibrary</ipxact:library>\"\n            \"<ipxact:name>TestComponent</ipxact:name>\"\n            \"<ipxact:version>0.11</ipxact:version>\"\n            \"<ipxact:vendorExtensions>\"\n                \"<kactus2:version>3.0.0</kactus2:version>\"\n                \"<kactus2:properties>\"\n                    \"<kactus2:property name=\\\"Priority\\\" required=\\\"true\\\" propertyType=\\\"override.\\\"\"\n                        \" defaultValue=\\\"New behaviour\\\" description=\\\"dictated\\\"/>\"\n                \"</kactus2:properties>\"\n            \"</ipxact:vendorExtensions>\"\n        \"</ipxact:component>\\n\"\n        );\n\n    QDomDocument document;\n    document.setContent(documentContent);\n\n    ComponentReader componentReader;\n\n    QSharedPointer<Component> testComponent = componentReader.createComponentFrom(document);\n\n    QCOMPARE(testComponent->getVlnv().getName(), QString(\"TestComponent\"));\n    QCOMPARE(testComponent->getSWProperties().size(), 1);\n\n    QSharedPointer<ComProperty> swProperty = testComponent->getSWProperties().first();\n    QCOMPARE(swProperty->name(), QString(\"Priority\"));\n    QCOMPARE(swProperty->isRequired(), true);\n    QCOMPARE(swProperty->getType(), QString(\"override.\"));\n    QCOMPARE(swProperty->getDefaultValue(), QString(\"New behaviour\"));\n    QCOMPARE(swProperty->getDescription(), QString(\"dictated\"));\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_ComponentReader::readSystemViews()\n//-----------------------------------------------------------------------------\nvoid tst_ComponentReader::readSystemViews()\n{\n    QString documentContent(\n        \"<?xml version=\\\"1.0\\\"?>\"\n        \"<ipxact:component \"\n        \"xmlns:xsi=\\\"http://www.w3.org/2001/XMLSchema-instance\\\" \" \n        \"xmlns:ipxact=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014\\\" \"\n        \"xmlns:kactus2=\\\"http://kactus2.cs.tut.fi\\\" \"\n        \"xsi:schemaLocation=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/ \"\n        \"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/index.xsd\\\">\"\n            \"<ipxact:vendor>tuni.fi</ipxact:vendor>\"\n            \"<ipxact:library>TestLibrary</ipxact:library>\"\n            \"<ipxact:name>TestComponent</ipxact:name>\"\n            \"<ipxact:version>0.11</ipxact:version>\"\n            \"<ipxact:vendorExtensions>\"\n                \"<kactus2:version>3.0.0</kactus2:version>\"\n                \"<kactus2:systemViews>\"\n                    \"<kactus2:systemView>\"\n                        \"<ipxact:name>system</ipxact:name>\"\n                        \"<ipxact:displayName>crash</ipxact:displayName>\"\n                        \"<ipxact:description>BSOD</ipxact:description>\"\n                        \"<kactus2:hierarchyRef vendor=\\\"tuni.fi\\\" library=\\\"TestLibrary\\\" name=\\\"hierarchy\\\" \"\n                            \"version=\\\"0.3\\\"/>\"\n                        \"<kactus2:hwViewRef>malfunction</kactus2:hwViewRef>\"\n                        \"<kactus2:fileSetRef>burn</kactus2:fileSetRef>\"\n                    \"</kactus2:systemView>\"\n                \"</kactus2:systemViews>\"\n            \"</ipxact:vendorExtensions>\"\n        \"</ipxact:component>\"\n        );\n\n    QDomDocument document;\n    document.setContent(documentContent);\n\n    ComponentReader componentReader;\n\n    QSharedPointer<Component> testComponent = componentReader.createComponentFrom(document);\n\n    QCOMPARE(testComponent->getVlnv().getName(), QString(\"TestComponent\"));\n    QCOMPARE(testComponent->getSWProperties().size(), 0);\n    QCOMPARE(testComponent->getSystemViews().size(), 1);\n\n    QSharedPointer<SystemView> systemView = testComponent->getSystemViews().first();\n    QCOMPARE(systemView->name(), QString(\"system\"));\n    QCOMPARE(systemView->displayName(), QString(\"crash\"));\n    QCOMPARE(systemView->description(), QString(\"BSOD\"));\n    QCOMPARE(systemView->getHierarchyRef().getVendor(), QString(\"tuni.fi\"));\n    QCOMPARE(systemView->getHierarchyRef().getLibrary(), QString(\"TestLibrary\"));\n    QCOMPARE(systemView->getHierarchyRef().getName(), QString(\"hierarchy\"));\n    QCOMPARE(systemView->getHierarchyRef().getVersion(), QString(\"0.3\"));\n    QCOMPARE(systemView->getHWViewRef(), QString(\"malfunction\"));\n    QCOMPARE(systemView->getFileSetRefs().size(), 1);\n    QCOMPARE(systemView->getFileSetRefs().first(), QString(\"burn\"));\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_ComponentReader::readComInterfaces()\n//-----------------------------------------------------------------------------\nvoid tst_ComponentReader::readComInterfaces()\n{\n    QString documentContent(\n        \"<?xml version=\\\"1.0\\\"?>\"\n        \"<ipxact:component \"\n        \"xmlns:xsi=\\\"http://www.w3.org/2001/XMLSchema-instance\\\" \" \n        \"xmlns:ipxact=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014\\\" \"\n        \"xmlns:kactus2=\\\"http://kactus2.cs.tut.fi\\\" \"\n        \"xsi:schemaLocation=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/ \"\n        \"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/index.xsd\\\">\"\n            \"<ipxact:vendor>tuni.fi</ipxact:vendor>\"\n            \"<ipxact:library>TestLibrary</ipxact:library>\"\n            \"<ipxact:name>TestComponent</ipxact:name>\"\n            \"<ipxact:version>0.11</ipxact:version>\"\n            \"<ipxact:vendorExtensions>\"\n                \"<kactus2:version>3.0.0</kactus2:version>\"\n                \"<kactus2:comInterfaces>\"\n                    \"<kactus2:comInterface>\"\n                        \"<ipxact:name>coms</ipxact:name>\"\n                        \"<ipxact:displayName>spec</ipxact:displayName>\"\n                        \"<ipxact:description>ops</ipxact:description>\"\n                        \"<kactus2:comType vendor=\\\"tuni.fi\\\" library=\\\"TestLibrary\\\" name=\\\"hierarchy\\\" \"\n                            \"version=\\\"0.3\\\"/>\"\n                        \"<kactus2:transferType>Transfer</kactus2:transferType>\"\n                        \"<kactus2:comDirection>in</kactus2:comDirection>\"\n                        \"<kactus2:propertyValues>\"\n                            \"<kactus2:propertyValue name=\\\"spathi\\\" value=\\\"eluder\\\"/>\"\n                        \"</kactus2:propertyValues>\"\n                        \"<kactus2:comImplementationRef vendor=\\\"tuni.fi\\\" library=\\\"TestLibrary\\\" name=\\\"hierarchy\\\" \"\n                            \"version=\\\"0.3\\\"/>\"\n                    \"</kactus2:comInterface>\"\n                \"</kactus2:comInterfaces>\"\n            \"</ipxact:vendorExtensions>\"\n        \"</ipxact:component>\\n\"\n        );\n\n    QDomDocument document;\n    document.setContent(documentContent);\n\n    ComponentReader componentReader;\n\n    QSharedPointer<Component> testComponent = componentReader.createComponentFrom(document);\n\n    QCOMPARE(testComponent->getVlnv().getName(), QString(\"TestComponent\"));\n    QCOMPARE(testComponent->getSystemViews().size(), 0);\n    QCOMPARE(testComponent->getComInterfaces().size(), 1);\n\n    QSharedPointer<ComInterface> comInterface = testComponent->getComInterfaces().first();\n    QCOMPARE(comInterface->name(), QString(\"coms\"));\n    QCOMPARE(comInterface->displayName(), QString(\"spec\"));\n    QCOMPARE(comInterface->description(), QString(\"ops\"));\n    QCOMPARE(comInterface->getComType().getVendor(), QString(\"tuni.fi\"));\n    QCOMPARE(comInterface->getComType().getLibrary(), QString(\"TestLibrary\"));\n    QCOMPARE(comInterface->getComType().getName(), QString(\"hierarchy\"));\n    QCOMPARE(comInterface->getComType().getVersion(), QString(\"0.3\"));\n    QCOMPARE(comInterface->getTransferType(), QString(\"Transfer\"));\n    QCOMPARE(comInterface->getDirection(), DirectionTypes::IN);\n    QCOMPARE(comInterface->getPropertyValues().size(), 1);\n    QCOMPARE(comInterface->getPropertyValues().firstKey(), QString(\"spathi\"));\n    QCOMPARE(comInterface->getPropertyValues().first(), QString(\"eluder\"));\n    QCOMPARE(comInterface->getComImplementation().getVendor(), QString(\"tuni.fi\"));\n    QCOMPARE(comInterface->getComImplementation().getLibrary(), QString(\"TestLibrary\"));\n    QCOMPARE(comInterface->getComImplementation().getName(), QString(\"hierarchy\"));\n    QCOMPARE(comInterface->getComImplementation().getVersion(), QString(\"0.3\"));\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_ComponentReader::readApiInterfaces()\n//-----------------------------------------------------------------------------\nvoid tst_ComponentReader::readApiInterfaces()\n{\n    QString documentContent(\n        \"<?xml version=\\\"1.0\\\"?>\"\n        \"<ipxact:component \"\n        \"xmlns:xsi=\\\"http://www.w3.org/2001/XMLSchema-instance\\\" \" \n        \"xmlns:ipxact=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014\\\" \"\n        \"xmlns:kactus2=\\\"http://kactus2.cs.tut.fi\\\" \"\n        \"xsi:schemaLocation=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/ \"\n        \"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/index.xsd\\\">\"\n            \"<ipxact:vendor>tuni.fi</ipxact:vendor>\"\n            \"<ipxact:library>TestLibrary</ipxact:library>\"\n            \"<ipxact:name>TestComponent</ipxact:name>\"\n            \"<ipxact:version>0.11</ipxact:version>\"\n            \"<ipxact:vendorExtensions>\"\n                \"<kactus2:version>3.0.0</kactus2:version>\"\n                \"<kactus2:apiInterfaces>\"\n                    \"<kactus2:apiInterface>\"\n                        \"<ipxact:name>api</ipxact:name>\"\n                        \"<kactus2:apiType vendor=\\\"tuni.fi\\\" library=\\\"TestLibrary\\\" name=\\\"hierarchy\\\" \"\n                            \"version=\\\"0.3\\\"/>\"\n                        \"<kactus2:dependencyDirection>provider</kactus2:dependencyDirection>\"\n                    \"</kactus2:apiInterface>\"\n                \"</kactus2:apiInterfaces>\"\n            \"</ipxact:vendorExtensions>\"\n        \"</ipxact:component>\"\n        );\n\n    QDomDocument document;\n    document.setContent(documentContent);\n\n    ComponentReader componentReader;\n\n    QSharedPointer<Component> testComponent = componentReader.createComponentFrom(document);\n\n    QCOMPARE(testComponent->getVlnv().getName(), QString(\"TestComponent\"));\n    QCOMPARE(testComponent->getComInterfaces().size(), 0);\n    QCOMPARE(testComponent->getApiInterfaces().size(), 1);\n\n    QSharedPointer<ApiInterface> apiInterface = testComponent->getApiInterfaces().first();\n    QCOMPARE(apiInterface->name(), QString(\"api\"));\n    QCOMPARE(apiInterface->getApiType().getVendor(), QString(\"tuni.fi\"));\n    QCOMPARE(apiInterface->getApiType().getLibrary(), QString(\"TestLibrary\"));\n    QCOMPARE(apiInterface->getApiType().getName(), QString(\"hierarchy\"));\n    QCOMPARE(apiInterface->getApiType().getVersion(), QString(\"0.3\"));\n    QCOMPARE(apiInterface->getDependencyDirection(), DEPENDENCY_PROVIDER);\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_ComponentReader::readFileDependencies()\n//-----------------------------------------------------------------------------\nvoid tst_ComponentReader::readFileDependencies()\n{\n    QString documentContent(\n        \"<?xml version=\\\"1.0\\\"?>\"\n        \"<ipxact:component \"\n        \"xmlns:xsi=\\\"http://www.w3.org/2001/XMLSchema-instance\\\" \" \n        \"xmlns:ipxact=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014\\\" \"\n        \"xmlns:kactus2=\\\"http://kactus2.cs.tut.fi\\\" \"\n        \"xsi:schemaLocation=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/ \"\n        \"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/index.xsd\\\">\"\n            \"<ipxact:vendor>tuni.fi</ipxact:vendor>\"\n            \"<ipxact:library>TestLibrary</ipxact:library>\"\n            \"<ipxact:name>TestComponent</ipxact:name>\"\n            \"<ipxact:version>0.11</ipxact:version>\"\n            \"<ipxact:vendorExtensions>\"\n                \"<kactus2:version>3.0.0</kactus2:version>\"\n                \"<kactus2:fileDependencies>\"\n                    \"<kactus2:fileDependency manual=\\\"true\\\" bidirectional=\\\"true\\\" locked=\\\"false\\\">\"\n                        \"<kactus2:fileRef1>super</kactus2:fileRef1>\"\n                        \"<kactus2:fileRef2>melee</kactus2:fileRef2>\"\n                        \"<ipxact:description>Immediately obvious to the most casual observer</ipxact:description>\"\n                    \"</kactus2:fileDependency>\"\n                \"</kactus2:fileDependencies>\"\n            \"</ipxact:vendorExtensions>\"\n        \"</ipxact:component>\"\n        );\n\n    QDomDocument document;\n    document.setContent(documentContent);\n\n    ComponentReader componentReader;\n\n    QSharedPointer<Component> testComponent = componentReader.createComponentFrom(document);\n\n    QCOMPARE(testComponent->getVlnv().getName(), QString(\"TestComponent\"));\n    QCOMPARE(testComponent->getApiInterfaces().size(), 0);\n    QCOMPARE(testComponent->getFileDependencies().size(), 1);\n\n    QSharedPointer<FileDependency> dependency = testComponent->getFileDependencies().first();\n    QCOMPARE(dependency->isManual(), true);\n    QCOMPARE(dependency->isBidirectional(), true);\n    QCOMPARE(dependency->isLocked(), false);\n    QCOMPARE(dependency->getFile1(), QString(\"super\"));\n    QCOMPARE(dependency->getFile2(), QString(\"melee\"));\n    QCOMPARE(dependency->getDescription(), QString(\"Immediately obvious to the most casual observer\"));\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_ComponentReader::readAuthorAndLicense()\n//-----------------------------------------------------------------------------\nvoid tst_ComponentReader::readAuthorAndLicense()\n{\n    QString documentContent(\n        \"<?xml version=\\\"1.0\\\"?>\"\n        \"<ipxact:component \"\n        \"xmlns:xsi=\\\"http://www.w3.org/2001/XMLSchema-instance\\\" \" \n        \"xmlns:ipxact=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014\\\" \"\n        \"xmlns:kactus2=\\\"http://kactus2.cs.tut.fi\\\" \"\n        \"xsi:schemaLocation=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/ \"\n        \"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/index.xsd\\\">\"\n            \"<ipxact:vendor>tuni.fi</ipxact:vendor>\"\n            \"<ipxact:library>TestLibrary</ipxact:library>\"\n            \"<ipxact:name>TestComponent</ipxact:name>\"\n            \"<ipxact:version>0.11</ipxact:version>\"\n            \"<ipxact:vendorExtensions>\"\n                \"<kactus2:author>tester</kactus2:author>\"\n                \"<kactus2:license>testLicense</kactus2:license>\"    \n            \"</ipxact:vendorExtensions>\"\n        \"</ipxact:component>\"\n        );\n\n    QDomDocument document;\n    document.setContent(documentContent);\n\n    ComponentReader componentReader;\n\n    QSharedPointer<Component> testComponent = componentReader.createComponentFrom(document);\n\n    QCOMPARE(testComponent->getAuthor(), QString(\"tester\"));\n    QCOMPARE(testComponent->getLicense(), QString(\"testLicense\"));\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_ComponentReader::readTags()\n//-----------------------------------------------------------------------------\nvoid tst_ComponentReader::readTags()\n{\n    QString documentContent(\n        \"<?xml version=\\\"1.0\\\"?>\"\n        \"<ipxact:component \"\n        \"xmlns:xsi=\\\"http://www.w3.org/2001/XMLSchema-instance\\\" \"\n        \"xmlns:ipxact=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014\\\" \"\n        \"xmlns:kactus2=\\\"http://kactus2.cs.tut.fi\\\" \"\n        \"xsi:schemaLocation=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/ \"\n        \"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/index.xsd\\\">\"\n            \"<ipxact:vendor>tuni.fi</ipxact:vendor>\"\n            \"<ipxact:library>TestLibrary</ipxact:library>\"\n            \"<ipxact:name>TestComponent</ipxact:name>\"\n            \"<ipxact:version>0.11</ipxact:version>\"\n            \"<ipxact:vendorExtensions>\"\n                \"<kactus2:tags>\"\n                    \"<kactus2:tag>\"\n                        \"<kactus2:name>TAG</kactus2:name>\"\n                        \"<kactus2:color>#79D173</kactus2:color>\"\n                    \"</kactus2:tag>\"\n                \"</kactus2:tags>\"\n        \"</ipxact:vendorExtensions>\"\n        \"</ipxact:component>\"\n    );\n\n    QDomDocument document;\n    document.setContent(documentContent);\n\n    ComponentReader componentReader;\n\n    QSharedPointer<Component> testComponent = componentReader.createComponentFrom(document);\n\n    QCOMPARE(testComponent->getTags().size(), 1);\n    QCOMPARE(testComponent->getTags().first().name_, QLatin1String(\"TAG\"));\n    QCOMPARE(testComponent->getTags().first().color_, QLatin1String(\"#79D173\"));\n}\n\n\nQTEST_APPLESS_MAIN(tst_ComponentReader)\n\n#include \"tst_ComponentReader.moc\"\n"
  },
  {
    "path": "tests/IPXACTmodels/Component/tst_ComponentReader.pri",
    "content": "# ----------------------------------------------------\r\n# This file is generated by the Qt Visual Studio Tools.\r\n# ------------------------------------------------------\r\n\r\n\r\nSOURCES += ./tst_ComponentReader.cpp \r\n"
  },
  {
    "path": "tests/IPXACTmodels/Component/tst_ComponentReader.pro",
    "content": "#-----------------------------------------------------------------------------\r\n# File: tst_ComponentReader.pro\r\n#-----------------------------------------------------------------------------\r\n# Project: Kactus 2\r\n# Author: Mikko Teuho\r\n# Date: 14.10.2015\r\n#\r\n# Description:\r\n# Qt project file template for running unit tests for a ComponentReader.\r\n#-----------------------------------------------------------------------------\r\n\r\nTEMPLATE = app\r\n\r\nTARGET = tst_ComponentReader\r\n\r\nQT += core xml testlib\r\nQT -= gui\r\n\r\nCONFIG += c++17 testcase console\r\n\r\nlinux-g++ | linux-g++-64 | linux-g++-32 {\r\n    LIBS += -L../../../executable -lIPXACTmodels\r\n}\r\n\r\nwin64 | win32 {\r\n    LIBS += -L../../../executable -lIPXACTmodelsd\r\n}\r\n\r\nINCLUDEPATH += $$DESTDIR\r\nINCLUDEPATH += ../../../\r\n\r\nDEPENDPATH += .\r\nDEPENDPATH += ../../../\r\n\r\nOBJECTS_DIR += $$DESTDIR\r\n\r\nMOC_DIR += ./generatedFiles\r\nUI_DIR += ./generatedFiles\r\nRCC_DIR += ./generatedFiles\r\ninclude(tst_ComponentReader.pri)\r\n"
  },
  {
    "path": "tests/IPXACTmodels/Component/tst_ComponentValidator.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: tst_ComponentValidator.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 14.12.2015\r\n//\r\n// Description:\r\n// Unit test for class ComponentValidator.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include <KactusAPI/include/SystemVerilogExpressionParser.h>\r\n#include <KactusAPI/include/ModeConditionParserInterface.h>\r\n#include <KactusAPI/include/ComponentParameterFinder.h>\r\n\r\n#include <IPXACTmodels/Component/validators/ComponentValidator.h>\r\n#include <IPXACTmodels/Component/validators/BusInterfaceValidator.h>\r\n#include <IPXACTmodels/Component/validators/ChannelValidator.h>\r\n#include <IPXACTmodels/Component/validators/RemapStateValidator.h>\r\n#include <IPXACTmodels/Component/validators/ModeValidator.h>\r\n#include <IPXACTmodels/Component/validators/AddressSpaceValidator.h>\r\n#include <IPXACTmodels/Component/validators/MemoryMapBaseValidator.h>\r\n#include <IPXACTmodels/Component/validators/MemoryMapValidator.h>\r\n#include <IPXACTmodels/Component/validators/AddressBlockValidator.h>\r\n#include <IPXACTmodels/Component/validators/RegisterValidator.h>\r\n#include <IPXACTmodels/Component/validators/FieldValidator.h>\r\n#include <IPXACTmodels/Component/validators/EnumeratedValueValidator.h>\r\n#include <IPXACTmodels/Component/validators/ViewValidator.h>\r\n#include <IPXACTmodels/Component/validators/InstantiationsValidator.h>\r\n#include <IPXACTmodels/Component/validators/PortValidator.h>\r\n#include <IPXACTmodels/Component/validators/PowerDomainValidator.h>\r\n#include <IPXACTmodels/Component/validators/ComponentGeneratorValidator.h>\r\n#include <IPXACTmodels/Component/validators/FileSetValidator.h>\r\n#include <IPXACTmodels/Component/validators/FileValidator.h>\r\n#include <IPXACTmodels/Component/validators/CPUValidator.h>\r\n#include <IPXACTmodels/Component/validators/OtherClockDriverValidator.h>\r\n#include <IPXACTmodels/common/validators/AssertionValidator.h>\r\n#include <IPXACTmodels/common/validators/ChoiceValidator.h>\r\n#include <IPXACTmodels/common/validators/ParameterValidator.h>\r\n\r\n#include <IPXACTmodels/common/VLNV.h>\r\n#include <IPXACTmodels/common/Enumeration.h>\r\n#include <IPXACTmodels/common/Choice.h>\r\n#include <IPXACTmodels/common/ClockUnit.h>\r\n#include <IPXACTmodels/common/Parameter.h>\r\n#include <IPXACTmodels/common/Assertion.h>\r\n\r\n#include <IPXACTmodels/Component/Component.h>\r\n#include <IPXACTmodels/Component/BusInterface.h>\r\n#include <IPXACTmodels/Component/IndirectInterface.h>\r\n#include <IPXACTmodels/Component/InitiatorInterface.h>\r\n#include <IPXACTmodels/Component/Channel.h>\r\n#include <IPXACTmodels/Component/RemapState.h>\r\n#include <IPXACTmodels/Component/AddressSpace.h>\r\n#include <IPXACTmodels/Component/MemoryMap.h>\r\n#include <IPXACTmodels/Component/View.h>\r\n#include <IPXACTmodels/Component/ComponentInstantiation.h>\r\n#include <IPXACTmodels/Component/DesignInstantiation.h>\r\n#include <IPXACTmodels/Component/DesignConfigurationInstantiation.h>\r\n#include <IPXACTmodels/Component/Port.h>\r\n#include <IPXACTmodels/Component/PowerDomain.h>\r\n#include <IPXACTmodels/Component/ComponentGenerator.h>\r\n#include <IPXACTmodels/Component/FileSet.h>\r\n#include <IPXACTmodels/Component/Cpu.h>\r\n#include <IPXACTmodels/Component/OtherClockDriver.h>\r\n#include <IPXACTmodels/Component/ResetType.h>\r\n#include <IPXACTmodels/Component/AddressBlock.h>\r\n#include <IPXACTmodels/Component/Register.h>\r\n#include <IPXACTmodels/Component/Field.h>\r\n\r\n#include <IPXACTmodels/BusDefinition/BusDefinition.h>\r\n#include <IPXACTmodels/Design/Design.h>\r\n#include <IPXACTmodels/DesignConfiguration/DesignConfiguration.h>\r\n\r\n#include <tests/MockObjects/LibraryMock.h>\r\n\r\n#include <QtTest>\r\n\r\nclass tst_ComponentValidator : public QObject\r\n{\r\n    Q_OBJECT\r\n\r\npublic:\r\n    tst_ComponentValidator();\r\n\r\nprivate slots:\r\n\r\n    void testHasValidVLNV();\r\n    void testHasValidVLNV_data();\r\n\r\n    void testHasValidBusInterfaces();\r\n    void testHasValidBusInterfaces_data();\r\n\r\n    void testHasValidIndirectInterfaces();\r\n    void testHasValidIndirectInterfaces_data();\r\n\r\n    void testHasValidChannels();\r\n    void testHasValidChannels_data();\r\n\r\n    void testHasValidRemapStates();\r\n    void testHasValidRemapStates_data();\r\n\r\n    void testHasValidAddressSpaces();\r\n    void testHasValidAddressSpaces_data();\r\n\r\n    void testHasValidMemoryMaps();\r\n    void testHasValidMemoryMaps_data();\r\n\r\n    void testHasValidViews();\r\n    void testHasValidViews_data();\r\n\r\n    void testHasValidInstantiations();\r\n    void testHasValidInstantiations_data();\r\n\r\n    void testHasValidPorts();\r\n    void testHasValidPorts_data();\r\n\r\n    void testHasValidComponentGenerators();\r\n    void testHasValidComponentGenerators_data();\r\n\r\n    void testHasValidChoices();\r\n    void testHasValidChoices_data();\r\n\r\n    void testHasValidFileSets();\r\n    void testHasValidFileSets_data();\r\n\r\n    void testHasValidCPUs();\r\n    void testHasValidCPUs_data();\r\n\r\n    void testHasValidOtherClockDrivers();\r\n    void testHasValidOtherClockDrivers_data();\r\n\r\n    void testHasValidPowerDomains();\r\n    void testHasValidPowerDomains_data();\r\n\r\n    void testHasValidResetTypes();\r\n    void testHasValidResetTypes_data();\r\n\r\n    void testHasValidParameters();\r\n    void testHasValidParameters_data();\r\n\r\n    void testHasValidAssertions();\r\n    void testHasValidAssertions_data();\r\n\r\nprivate:\r\n\r\n    enum InstantiationType\r\n    {\r\n        COMPONENT,\r\n        DESIGN,\r\n        DESIGNCFG\r\n    };\r\n\r\n    bool errorIsNotFoundInErrorList(QString const& expectedError, QVector<QString> errorList);\r\n\r\n    QSharedPointer<ComponentValidator> createComponentValidator(LibraryMock* mockLibrary);\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ComponentValidator::tst_ComponentValidator()\r\n//-----------------------------------------------------------------------------\r\ntst_ComponentValidator::tst_ComponentValidator()\r\n{\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ComponentValidator::testHasValidName()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ComponentValidator::testHasValidVLNV()\r\n{\r\n    QFETCH(QString, vendor);\r\n    QFETCH(QString, library);\r\n    QFETCH(QString, name);\r\n    QFETCH(QString, version);\r\n    QFETCH(bool, isValid);\r\n\r\n    VLNV componentVLNV(VLNV::COMPONENT, vendor, library, name, version);\r\n    QSharedPointer<Component> testComponent (new Component(componentVLNV, Document::Revision::Std14));\r\n\r\n    QSharedPointer<ComponentValidator> validator = createComponentValidator(0);\r\n    QCOMPARE(validator->hasValidVLNV(testComponent), isValid);\r\n\r\n    if (!isValid)\r\n    {\r\n        QVector<QString> foundErrors;\r\n        validator->findErrorsIn(foundErrors, testComponent);\r\n\r\n        QString expectedError = QObject::tr(\"The type of the vlnv is invalid within component\");\r\n\r\n        if (vendor.isEmpty())\r\n        {\r\n            expectedError = QObject::tr(\"No vendor specified for vlnv within component\");\r\n        }\r\n        else if (library.isEmpty())\r\n        {\r\n            expectedError = QObject::tr(\"No library specified for vlnv within component\");\r\n        }\r\n        else if (name.isEmpty())\r\n        {\r\n            expectedError = QObject::tr(\"No name specified for vlnv within component\");\r\n        }\r\n        else if (version.isEmpty())\r\n        {\r\n            expectedError = QObject::tr(\"No version specified for vlnv within component\");\r\n        }\r\n\r\n        if (errorIsNotFoundInErrorList(expectedError, foundErrors))\r\n        {\r\n            QFAIL(\"No error message found\");\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ComponentValidator::testHasValidName_data()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ComponentValidator::testHasValidVLNV_data()\r\n{\r\n    QTest::addColumn<QString>(\"vendor\");\r\n    QTest::addColumn<QString>(\"library\");\r\n    QTest::addColumn<QString>(\"name\");\r\n    QTest::addColumn<QString>(\"version\");\r\n    QTest::addColumn<bool>(\"isValid\");\r\n\r\n    QTest::newRow(\"Component with all VLNVs is valid\") << \"Tengen\" << \"Toppa\" << \"Gurren\" << \"Lagann\" << true;\r\n    QTest::newRow(\"Component without vendor is not valid\") << \"\" << \"Toppa\" << \"Gurren\" << \"Lagann\" << false;\r\n    QTest::newRow(\"Component without library is not valid\") << \"Tengen\" << \"\" << \"Gurren\" << \"Lagann\" << false;\r\n    QTest::newRow(\"Component without name is not valid\") << \"Tengen\" << \"Toppa\" << \"\" << \"Lagann\" << false;\r\n    QTest::newRow(\"Component without version is not valid\") << \"Tengen\" << \"Toppa\" << \"Gurren\" << \"\" << false;\r\n    QTest::newRow(\"Empty VLNV is not valid\") << \"\" << \"\" << \"\" << \"\" << false;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ComponentValidator::testHasValidBusInterfaces()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ComponentValidator::testHasValidBusInterfaces()\r\n{\r\n    QFETCH(QString, busName);\r\n    QFETCH(bool, hasBusType);\r\n    QFETCH(bool, hasInterfaceMode);\r\n    QFETCH(bool, copyInterface);\r\n    QFETCH(bool, isValid);\r\n\r\n    QSharedPointer<BusInterface> testBus (new BusInterface());\r\n    testBus->setName(busName);\r\n\r\n    LibraryMock* mockLibrary (new LibraryMock(this));\r\n\r\n    if (hasBusType)\r\n    {\r\n        ConfigurableVLNVReference testType(VLNV::BUSDEFINITION, \"testVendor\", \"testLibrary\", \"busDefinition\", \"1.1\");\r\n        testBus->setBusType(testType);\r\n\r\n        QSharedPointer<BusDefinition> testDefinition (new BusDefinition(testType, Document::Revision::Std14));\r\n\r\n        mockLibrary->addComponent(testDefinition);\r\n    }\r\n\r\n    if (hasInterfaceMode)\r\n    {\r\n        QSharedPointer<InitiatorInterface> testMaster (new InitiatorInterface());\r\n        testBus->setMaster(testMaster);\r\n        testBus->setInterfaceMode(General::MASTER);\r\n    }\r\n\r\n    QSharedPointer<Component> testComponent (new Component(\r\n        VLNV(VLNV::COMPONENT, \"Samurai\", \"Champloo\", \"MugenJinFuu\", \"3.0\"), Document::Revision::Std14));\r\n    testComponent->getBusInterfaces()->append(testBus);\r\n\r\n    if (copyInterface)\r\n    {\r\n        QSharedPointer<BusInterface> otherBus (new BusInterface(*testBus.data()));\r\n        testComponent->getBusInterfaces()->append(otherBus);\r\n    }\r\n\r\n    QSharedPointer<ComponentValidator> validator = createComponentValidator(mockLibrary);\r\n    QCOMPARE(validator->hasValidBusInterfaces(testComponent), isValid);\r\n\r\n    if (!isValid)\r\n    {\r\n        QVector<QString> foundErrors;\r\n        validator->findErrorsIn(foundErrors, testComponent);\r\n\r\n        QString expectedError = QObject::tr(\"Invalid name specified for bus interface %1 within component %2\")\r\n            .arg(testBus->name()).arg(testComponent->getVlnv().toString());\r\n\r\n        if (!hasBusType)\r\n        {\r\n            expectedError = QObject::tr(\"Bus definition must be given for bus interface %1 within component %2\")\r\n                .arg(testBus->name()).arg(testComponent->getVlnv().toString());\r\n        }\r\n        else if (!hasInterfaceMode)\r\n        {\r\n            expectedError = QObject::tr(\"Unknown interface mode set for bus interface %1 within component %2\")\r\n                .arg(testBus->name()).arg(testComponent->getVlnv().toString()); \r\n        }\r\n        else if (copyInterface)\r\n        {\r\n            expectedError = QObject::tr(\"Bus interface name %1 within component %2 is not unique.\")\r\n                .arg(testBus->name()).arg(testComponent->getVlnv().toString());\r\n        }\r\n\r\n        if (errorIsNotFoundInErrorList(expectedError, foundErrors))\r\n        {\r\n            QFAIL(\"No error message found\");\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ComponentValidator::testHasValidBusInterfaces_data()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ComponentValidator::testHasValidBusInterfaces_data()\r\n{\r\n    QTest::addColumn<QString>(\"busName\");\r\n    QTest::addColumn<bool>(\"hasBusType\");\r\n    QTest::addColumn<bool>(\"hasInterfaceMode\");\r\n    QTest::addColumn<bool>(\"copyInterface\");\r\n    QTest::addColumn<bool>(\"isValid\");\r\n\r\n    QTest::newRow(\"Bus interface with name, bus type and interface mode is valid\") <<\r\n        \"Wanpan\" << true << true << false << true;\r\n    QTest::newRow(\"Bus interface without name is not valid\")\r\n        << \"\" << true << true << false << false;\r\n    QTest::newRow(\"Bus interface without bus type is not valid\") <<\r\n        \"Wanpan\" << false << true <<  false << false;\r\n    QTest::newRow(\"Bus interface without interface mode is not valid\") <<\r\n        \"Wanpan\" << true << false <<  false << false;\r\n    QTest::newRow(\"Empty bus interface is not valid\") << \"\" << false << false << false << false;\r\n    QTest::newRow(\"Bus interfaces with same name is not valid\") << \"Wanpan\" << true << true << true << false;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ComponentValidator::testHasValidIndirectInterfaces()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ComponentValidator::testHasValidIndirectInterfaces()\r\n{\r\n    QFETCH(QStringList, interfaceNames);\r\n    QFETCH(bool, isValid);\r\n\r\n    QSharedPointer<Component> testComponent(new Component(VLNV(), Document::Revision::Std14));\r\n\r\n    QSharedPointer<MemoryMap> targetMap(new MemoryMap(\"targetMap\"));\r\n    testComponent->getMemoryMaps()->append(targetMap);\r\n\r\n    QSharedPointer<MemoryMap> accessMap(new MemoryMap(\"accessMap\"));\r\n    \r\n    QSharedPointer<AddressBlock> accessBlock(new AddressBlock(\"accessBlock\"));\r\n    accessMap->getMemoryBlocks()->append(accessBlock);\r\n\r\n    QSharedPointer<Register> accessRegister(new Register(\"accessRegister\"));\r\n    accessBlock->getRegisterData()->append(accessRegister);\r\n\r\n    QSharedPointer<Field> addressField(new Field(\"addr\"));\r\n    addressField->setId(\"address\");\r\n    accessRegister->getFields()->append(addressField);\r\n    \r\n    QSharedPointer<Field> dataField(new Field(\"dat\"));\r\n    dataField->setId(\"data\");\r\n    accessRegister->getFields()->append(dataField);        \r\n\r\n    testComponent->getMemoryMaps()->append(accessMap);\r\n\r\n    LibraryMock* mockLibrary (new LibraryMock(this));\r\n\r\n    foreach (QString name, interfaceNames)\r\n    {\r\n        QSharedPointer<IndirectInterface> testInterface(new IndirectInterface(name));\r\n        testInterface->setIndirectAddressRef(\"address\");\r\n        testInterface->setIndirectDataRef(\"data\");\r\n        testInterface->setMemoryMapRef(\"targetMap\");\r\n        \r\n        testComponent->getIndirectInterfaces()->append(testInterface);\r\n    }\r\n\r\n    QSharedPointer<ComponentValidator> validator = createComponentValidator(mockLibrary);\r\n    QCOMPARE(validator->hasValidIndirectInterfaces(testComponent), isValid);\r\n\r\n    delete mockLibrary;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ComponentValidator::testHasValidIndirectInterfaces()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ComponentValidator::testHasValidIndirectInterfaces_data()\r\n{\r\n    QTest::addColumn<QStringList>(\"interfaceNames\");\r\n    QTest::addColumn<bool>(\"isValid\");\r\n\r\n    QTest::newRow(\"Empty indirect interface is not valid\") << QStringList(\"\") << false;\r\n    QTest::newRow(\"Named indirect interface is valid\") << QStringList(\"testInterface\") << true;\r\n\r\n    QStringList duplicates;\r\n    duplicates << \"duplicate\" << \"duplicate\";\r\n\r\n    QTest::newRow(\"Duplicate names in indirect interfaces is invalid\") << duplicates << false;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ComponentValidator::testHasValidChannels()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ComponentValidator::testHasValidChannels()\r\n{\r\n    QFETCH(QString, channelName);\r\n    QFETCH(QString, firstBus);\r\n    QFETCH(QString, secondBus);\r\n    QFETCH(bool, copyChannel);\r\n    QFETCH(bool, isValid);\r\n\r\n    QStringList busReferences;\r\n    busReferences.append(firstBus);\r\n    busReferences.append(secondBus);\r\n\r\n    QSharedPointer<Channel> testChannel (new Channel());\r\n    testChannel->setName(channelName);\r\n    testChannel->setInterfaces(busReferences);\r\n\r\n    QSharedPointer<Component> testComponent (new Component(\r\n        VLNV(VLNV::COMPONENT, \"Samurai\", \"Champloo\", \"MugenJinFuu\", \"3.0\"), Document::Revision::Std14));\r\n    testComponent->getChannels()->append(testChannel);\r\n\r\n    if (copyChannel)\r\n    {\r\n        QSharedPointer<Channel> otherChannel (new Channel(*testChannel.data()));\r\n        testComponent->getChannels()->append(otherChannel);\r\n    }\r\n\r\n    if (!firstBus.isEmpty())\r\n    {\r\n        QSharedPointer<BusInterface> testBus (new BusInterface());\r\n        testBus->setName(firstBus);\r\n        testBus->setInterfaceMode(General::MIRRORED_MASTER);\r\n        testComponent->getBusInterfaces()->append(testBus);\r\n    }\r\n    if (!secondBus.isEmpty())\r\n    {\r\n        QSharedPointer<BusInterface> testBus (new BusInterface());\r\n        testBus->setName(secondBus);\r\n        testBus->setInterfaceMode(General::MIRRORED_SLAVE);\r\n        testComponent->getBusInterfaces()->append(testBus);\r\n    }\r\n\r\n    QSharedPointer<ComponentValidator> validator = createComponentValidator(0);\r\n    QCOMPARE(validator->hasValidChannels(testComponent), isValid);\r\n\r\n    if (!isValid)\r\n    {\r\n        QVector<QString> foundErrors;\r\n        validator->findErrorsIn(foundErrors, testComponent);\r\n\r\n        QString expectedError = QObject::tr(\"Invalid name %1 specified for channel within component %2.\")\r\n            .arg(testChannel->name()).arg(testComponent->getVlnv().toString());\r\n\r\n        if (firstBus.isEmpty())\r\n        {\r\n            expectedError = QObject::tr(\"Bus interface \\'%1\\' referenced within channel %2 not found.\")\r\n                .arg(firstBus).arg(channelName);\r\n        }\r\n        else if (copyChannel)\r\n        {\r\n            expectedError = QObject::tr(\"Channel name '%1' within component %2 is not unique.\")\r\n                .arg(testChannel->name()).arg(testComponent->getVlnv().toString());\r\n        }\r\n\r\n        if (errorIsNotFoundInErrorList(expectedError, foundErrors))\r\n        {\r\n            QFAIL(\"No error message found\");\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ComponentValidator::testHasValidChannels_data()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ComponentValidator::testHasValidChannels_data()\r\n{\r\n    QTest::addColumn<QString>(\"channelName\");\r\n    QTest::addColumn<QString>(\"firstBus\");\r\n    QTest::addColumn<QString>(\"secondBus\");\r\n    QTest::addColumn<bool>(\"copyChannel\");\r\n    QTest::addColumn<bool>(\"isValid\");\r\n\r\n    QTest::newRow(\"Channel with name and two bus interface references is valid\") <<\r\n        \"Gurren\" << \"Kamina\" << \"Yoko\" << false << true;\r\n    QTest::newRow(\"Channel without name is not valid\") <<\r\n        \"\" << \"Kamina\" << \"Yoko\" << false << false;\r\n    QTest::newRow(\"Channel without at least two bus references is not valid\") <<\r\n        \"Gurren\" << \"\" << \"Yoko\" << false << false;\r\n    QTest::newRow(\"Channels with same name is not valid\") << \"Gurren\" << \"Kamina\" << \"Yoko\" << true << false;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ComponentValidator::testHasValidRemapStates()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ComponentValidator::testHasValidRemapStates()\r\n{\r\n    QFETCH(QString, stateName);\r\n    QFETCH(bool, copyState);\r\n    QFETCH(bool, isValid);\r\n\r\n    QSharedPointer<RemapState> testState (new RemapState(stateName));\r\n\r\n    QSharedPointer<Component> testComponent (new Component(\r\n        VLNV(VLNV::COMPONENT, \"Samurai\", \"Champloo\", \"MugenJinFuu\", \"3.0\"), Document::Revision::Std14));\r\n    testComponent->getRemapStates()->append(testState);\r\n\r\n    if (copyState)\r\n    {\r\n        QSharedPointer<RemapState> otherState (new RemapState(*testState.data()));\r\n        testComponent->getRemapStates()->append(otherState);\r\n    }\r\n\r\n    QSharedPointer<ComponentValidator> validator = createComponentValidator(0);\r\n    QCOMPARE(validator->hasValidRemapStates(testComponent), isValid);\r\n\r\n\r\n    if (!isValid)\r\n    {\r\n        QVector<QString> foundErrors;\r\n        validator->findErrorsIn(foundErrors, testComponent);\r\n\r\n        QString expectedError = QObject::tr(\"Invalid name specified for remap state %1 within component %2\")\r\n            .arg(stateName).arg(testComponent->getVlnv().toString());\r\n\r\n        if (copyState)\r\n        {\r\n            expectedError = QObject::tr(\"Remap state name %1 within component %2 is not unique.\")\r\n                .arg(stateName).arg(testComponent->getVlnv().toString());\r\n        }\r\n\r\n        if (errorIsNotFoundInErrorList(expectedError, foundErrors))\r\n        {\r\n            QFAIL(\"No error message found\");\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ComponentValidator::testHasValidRemapStates_data()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ComponentValidator::testHasValidRemapStates_data()\r\n{\r\n    QTest::addColumn<QString>(\"stateName\");\r\n    QTest::addColumn<bool>(\"copyState\");\r\n    QTest::addColumn<bool>(\"isValid\");\r\n\r\n    QTest::newRow(\"Remap state with name is valid\") << \"gear\" << false << true;\r\n    QTest::newRow(\"Remap state without name is not valid\") << \"\" << false << false;\r\n    QTest::newRow(\"Remap states with same name is not valid\") << \"gear\" << true << false;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ComponentValidator::testHasValidAddressSpaces()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ComponentValidator::testHasValidAddressSpaces()\r\n{\r\n    QFETCH(QString, spaceName);\r\n    QFETCH(QString, range);\r\n    QFETCH(QString, width);\r\n    QFETCH(bool, copySpace);\r\n    QFETCH(bool, isValid);\r\n\r\n    QSharedPointer<AddressSpace> testSpace (new AddressSpace(spaceName, range, width));\r\n\r\n    QSharedPointer<Component> testComponent (new Component(\r\n        VLNV(VLNV::COMPONENT, \"Samurai\", \"Champloo\", \"MugenJinFuu\", \"3.0\"), Document::Revision::Std14));\r\n    testComponent->getAddressSpaces()->append(testSpace);\r\n\r\n    if (copySpace)\r\n    {\r\n        QSharedPointer<AddressSpace> otherSpace (new AddressSpace(*testSpace.data()));\r\n        testComponent->getAddressSpaces()->append(otherSpace);\r\n    }\r\n\r\n    QSharedPointer<ComponentValidator> validator = createComponentValidator(0);\r\n    QCOMPARE(validator->hasValidAddressSpaces(testComponent), isValid);\r\n\r\n    if (!isValid)\r\n    {\r\n        QVector<QString> foundErrors;\r\n        validator->findErrorsIn(foundErrors, testComponent);\r\n\r\n        QString expectedError = QObject::tr(\"Invalid name specified for address space %1 within component %2\")\r\n            .arg(spaceName).arg(testComponent->getVlnv().toString());\r\n\r\n        if (range.isEmpty())\r\n        {\r\n            expectedError = QObject::tr(\"Invalid range set for address space %1 within component %2\")\r\n                .arg(spaceName).arg(testComponent->getVlnv().toString());\r\n        }\r\n        else if (width.isEmpty())\r\n        {\r\n            expectedError = QObject::tr(\"Invalid width set for address space %1 within component %2\")\r\n                .arg(spaceName).arg(testComponent->getVlnv().toString());\r\n        }\r\n        else if (copySpace)\r\n        {\r\n            expectedError = QObject::tr(\"Address space name %1 within component %2 is not unique.\")\r\n                .arg(spaceName).arg(testComponent->getVlnv().toString());\r\n        }\r\n\r\n        if (errorIsNotFoundInErrorList(expectedError, foundErrors))\r\n        {\r\n            QFAIL(\"No error message found\");\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ComponentValidator::testHasValidAddressSpaces_data()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ComponentValidator::testHasValidAddressSpaces_data()\r\n{\r\n    QTest::addColumn<QString>(\"spaceName\");\r\n    QTest::addColumn<QString>(\"range\");\r\n    QTest::addColumn<QString>(\"width\");\r\n    QTest::addColumn<bool>(\"copySpace\");\r\n    QTest::addColumn<bool>(\"isValid\");\r\n\r\n    QTest::newRow(\"Address space with name, range and width is valid\") << \"Dandy\" << \"10\" << \"27\" << false << true;\r\n    QTest::newRow(\"Address space without name is not valid\") << \"\" << \"10\" << \"27\" << false << false;\r\n    QTest::newRow(\"Address space without range is not valid\") << \"Dandy\" << \"\" << \"27\" << false << false;\r\n    QTest::newRow(\"Address space without width is not valid\") << \"Dandy\" << \"10\" << \"\" << false << false;\r\n    QTest::newRow(\"Address spaces with the same name is not valid\") << \"Dandy\" << \"10\" << \"27\" << true << false;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ComponentValidator::testHasValidMemoryMaps()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ComponentValidator::testHasValidMemoryMaps()\r\n{\r\n    QFETCH(QString, mapName);\r\n    QFETCH(bool, copyMap);\r\n    QFETCH(bool, isValid);\r\n\r\n    QSharedPointer<MemoryMap> testMap (new MemoryMap(mapName));\r\n\r\n    QSharedPointer<Component> testComponent (new Component(\r\n        VLNV(VLNV::COMPONENT, \"Samurai\", \"Champloo\", \"MugenJinFuu\", \"3.0\"), Document::Revision::Std14));\r\n    testComponent->getMemoryMaps()->append(testMap);\r\n\r\n    if (copyMap)\r\n    {\r\n        QSharedPointer<MemoryMap> otherMap (new MemoryMap(*testMap.data()));\r\n        testComponent->getMemoryMaps()->append(otherMap);\r\n    }\r\n\r\n    QSharedPointer<ComponentValidator> validator = createComponentValidator(0);\r\n    QCOMPARE(validator->hasValidMemoryMaps(testComponent), isValid);\r\n\r\n    if (!isValid)\r\n    {\r\n        QVector<QString> foundErrors;\r\n        validator->findErrorsIn(foundErrors, testComponent);\r\n\r\n        QString expectedError = QObject::tr(\"Invalid name specified for memory map %1 within component %2\")\r\n            .arg(mapName).arg(testComponent->getVlnv().toString());\r\n        \r\n        if (copyMap)\r\n        {\r\n            expectedError = QObject::tr(\"Memory map name %1 within component %2 is not unique.\")\r\n                .arg(mapName).arg(testComponent->getVlnv().toString());\r\n        }\r\n\r\n        if (errorIsNotFoundInErrorList(expectedError, foundErrors))\r\n        {\r\n            QFAIL(\"No error message found\");\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ComponentValidator::testHasValidMemoryMap_data()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ComponentValidator::testHasValidMemoryMaps_data()\r\n{\r\n    QTest::addColumn<QString>(\"mapName\");\r\n    QTest::addColumn<bool>(\"copyMap\");\r\n    QTest::addColumn<bool>(\"isValid\");\r\n\r\n    QTest::newRow(\"Memory map with name is valid\") << \"Soulafein\" << false << true;\r\n    QTest::newRow(\"Memory map without name is not valid\") << \"\" << false << false;\r\n    QTest::newRow(\"Memory maps with the same name is not valid\") << \"Soulafein\" << true << false;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ComponentValidator::testHasValidViews()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ComponentValidator::testHasValidViews()\r\n{\r\n    QFETCH(QString, viewName);\r\n    QFETCH(bool, copyView);\r\n    QFETCH(bool, isValid);\r\n\r\n    QSharedPointer<View> testView (new View(viewName));\r\n\r\n    QSharedPointer<Component> testComponent (new Component(\r\n        VLNV(VLNV::COMPONENT, \"Samurai\", \"Champloo\", \"MugenJinFuu\", \"3.0\"), Document::Revision::Std14));\r\n    testComponent->getViews()->append(testView);\r\n\r\n    if (copyView)\r\n    {\r\n        QSharedPointer<View> otherView (new View(*testView.data()));\r\n        testComponent->getViews()->append(otherView);\r\n    }\r\n\r\n    QSharedPointer<ComponentValidator> validator = createComponentValidator(0);\r\n    QCOMPARE(validator->hasValidViews(testComponent), isValid);\r\n\r\n    if (!isValid)\r\n    {\r\n        QVector<QString> foundErrors;\r\n        validator->findErrorsIn(foundErrors, testComponent);\r\n\r\n        QString expectedError = QObject::tr(\"Invalid name specified for view %1 within component %2\")\r\n            .arg(viewName).arg(testComponent->getVlnv().toString());\r\n\r\n        if (copyView)\r\n        {\r\n            expectedError = QObject::tr(\"View name %1 within component %2 is not unique.\")\r\n                .arg(viewName).arg(testComponent->getVlnv().toString());\r\n        }\r\n\r\n        if (errorIsNotFoundInErrorList(expectedError, foundErrors))\r\n        {\r\n            QFAIL(\"No error message found\");\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ComponentValidator::testHasValidViews_data()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ComponentValidator::testHasValidViews_data()\r\n{\r\n    QTest::addColumn<QString>(\"viewName\");\r\n    QTest::addColumn<bool>(\"copyView\");\r\n    QTest::addColumn<bool>(\"isValid\");\r\n\r\n    QTest::newRow(\"View with name is valid\") << \"Soulafein\" << false << true;\r\n    QTest::newRow(\"View without name is not valid\") << \"\" << false << false;\r\n    QTest::newRow(\"Views with the same name is not valid\") << \"Soulafein\" << true << false;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ComponentValidator::testHasValidInstantiations()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ComponentValidator::testHasValidInstantiations()\r\n{\r\n    QFETCH(QString, instantiationName);\r\n    QFETCH(InstantiationType, instantiationType);\r\n    QFETCH(bool, hasReference);\r\n    QFETCH(bool, copyInstantiation);\r\n    QFETCH(bool, isValid);\r\n\r\n    QSharedPointer<Component> testComponent(new Component(\r\n        VLNV(VLNV::COMPONENT, \"Samurai\", \"Champloo\", \"MugenJinFuu\", \"3.0\"), Document::Revision::Std14));\r\n\r\n    QSharedPointer<ComponentValidator> validator;\r\n    QVector<QString> foundErrors;\r\n    QString expectedError;\r\n\r\n    switch (instantiationType)\r\n    {\r\n    case InstantiationType::COMPONENT:\r\n    {\r\n        QSharedPointer<ComponentInstantiation> testInstantiation(new ComponentInstantiation(instantiationName));\r\n        testComponent->getComponentInstantiations()->append(testInstantiation);\r\n\r\n        if (copyInstantiation)\r\n        {\r\n            QSharedPointer<ComponentInstantiation> otherInstantiation(new ComponentInstantiation(*testInstantiation.data()));\r\n            testComponent->getComponentInstantiations()->append(otherInstantiation);\r\n        }\r\n\r\n        validator = createComponentValidator(0);\r\n        QCOMPARE(validator->hasValidInstantiations(testComponent), isValid);\r\n\r\n        if (!isValid)\r\n        {\r\n            validator->findErrorsIn(foundErrors, testComponent);\r\n            expectedError = QObject::tr(\"Invalid name set for component instantiation %1 within component %2\")\r\n                .arg(instantiationName).arg(testComponent->getVlnv().toString());\r\n\r\n            if (copyInstantiation)\r\n            {\r\n                expectedError = QObject::tr(\"Component instantiation name %1 within component %2 is not unique.\")\r\n                    .arg(instantiationName).arg(testComponent->getVlnv().toString());\r\n            }\r\n        }\r\n        break;\r\n    }\r\n    case InstantiationType::DESIGN:\r\n    {\r\n        LibraryMock* mockLibrary = new LibraryMock(this);\r\n        QSharedPointer<DesignInstantiation> testInstantiation(new DesignInstantiation(instantiationName));\r\n\r\n        if (hasReference)\r\n        {\r\n            QSharedPointer<ConfigurableVLNVReference> designReference(new ConfigurableVLNVReference(VLNV::DESIGN, \"Shiki\", \"No\", \"Uta\", \"0.3\"));\r\n            QSharedPointer<Design> testDesign(new Design(*designReference.data(), Document::Revision::Std14));\r\n            mockLibrary->addComponent(testDesign);\r\n            testInstantiation->setDesignReference(designReference);\r\n        }\r\n\r\n        testComponent->getDesignInstantiations()->append(testInstantiation);\r\n\r\n        if (copyInstantiation)\r\n        {\r\n            QSharedPointer<DesignInstantiation> otherInstantiation(new DesignInstantiation(*testInstantiation.data()));\r\n            testComponent->getDesignInstantiations()->append(otherInstantiation);\r\n        }\r\n\r\n        validator = createComponentValidator(mockLibrary);\r\n        QCOMPARE(validator->hasValidInstantiations(testComponent), isValid);\r\n\r\n        if (!isValid)\r\n        {\r\n            validator->findErrorsIn(foundErrors, testComponent);\r\n            expectedError = QObject::tr(\"Invalid name set for design instantiation %1 within component %2\")\r\n                .arg(instantiationName).arg(testComponent->getVlnv().toString());\r\n\r\n            if (copyInstantiation)\r\n            {\r\n                expectedError = QObject::tr(\"Design instantiation name %1 within component %2 is not unique.\")\r\n                    .arg(instantiationName).arg(testComponent->getVlnv().toString());\r\n            }\r\n            else if (!hasReference)\r\n            {\r\n                expectedError = QObject::tr(\"Invalid design reference %1 set for design instantiation %2\")\r\n                    .arg(testInstantiation->getDesignReference()->toString()).arg(testInstantiation->name());\r\n            }\r\n        }\r\n        break;\r\n    }\r\n    case InstantiationType::DESIGNCFG:\r\n    {\r\n        LibraryMock* mockLibrary = new LibraryMock(this);\r\n        QSharedPointer<DesignConfigurationInstantiation> testInstantiation(new DesignConfigurationInstantiation(instantiationName));\r\n\r\n        if (hasReference)\r\n        {\r\n            QSharedPointer<ConfigurableVLNVReference> designConfigurationReference(new ConfigurableVLNVReference(VLNV::DESIGNCONFIGURATION, \"Shiki\", \"No\", \"Uta\", \"0.3\"));\r\n            QSharedPointer<DesignConfiguration> testDesignConfiguration(new DesignConfiguration(*designConfigurationReference.data(), Document::Revision::Std14));\r\n            mockLibrary->addComponent(testDesignConfiguration);\r\n            testInstantiation->setDesignConfigurationReference(designConfigurationReference);\r\n        }\r\n\r\n        testComponent->getDesignConfigurationInstantiations()->append(testInstantiation);\r\n\r\n        if (copyInstantiation)\r\n        {\r\n            QSharedPointer<DesignConfigurationInstantiation> otherInstantiation(new DesignConfigurationInstantiation(*testInstantiation.data()));\r\n            testComponent->getDesignConfigurationInstantiations()->append(otherInstantiation);\r\n        }\r\n\r\n        validator = createComponentValidator(mockLibrary);\r\n        QCOMPARE(validator->hasValidInstantiations(testComponent), isValid);\r\n\r\n        if (!isValid)\r\n        {\r\n            validator->findErrorsIn(foundErrors, testComponent);\r\n            expectedError = QObject::tr(\"Invalid name set for design configuration instantiation %1 within component %2\")\r\n                .arg(instantiationName).arg(testComponent->getVlnv().toString());\r\n\r\n            if (copyInstantiation)\r\n            {\r\n                expectedError = QObject::tr(\"Design configuration instantiation name %1 within component %2 is not unique.\")\r\n                    .arg(instantiationName).arg(testComponent->getVlnv().toString());\r\n            }\r\n            else if (!hasReference)\r\n            {\r\n                expectedError = QObject::tr(\"Invalid design configuration reference %1 set for design configuration instantiation %2\")\r\n                    .arg(testInstantiation->getDesignConfigurationReference()->toString()).arg(testInstantiation->name());\r\n            }\r\n        }\r\n        break;\r\n    }\r\n    }\r\n\r\n    if (!isValid && errorIsNotFoundInErrorList(expectedError, foundErrors))\r\n    {\r\n        QFAIL(\"No error message found\");\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ComponentValidator::testHasValidInstantiations_data()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ComponentValidator::testHasValidInstantiations_data()\r\n{\r\n    QTest::addColumn<QString>(\"instantiationName\");\r\n    QTest::addColumn<InstantiationType>(\"instantiationType\");\r\n    QTest::addColumn<bool>(\"hasReference\");\r\n    QTest::addColumn<bool>(\"copyInstantiation\");\r\n    QTest::addColumn<bool>(\"isValid\");\r\n\r\n    // Component instantiations, no refrence for them\r\n    QTest::newRow(\"Component instantiation with name is valid\") << \"Soulafein\" << InstantiationType::COMPONENT << false << false << true;\r\n    QTest::newRow(\"Component instantiation without name is not valid\") << \"\" << InstantiationType::COMPONENT << false << false << false;\r\n    QTest::newRow(\"Component instantiations with the same name is not valid\") << \"Soulafein\" << InstantiationType::COMPONENT << false << true << false;\r\n\r\n    // Design instantiations\r\n    QTest::newRow(\"Design instantiation with name and design reference is valid\") << \"Balduran\" << InstantiationType::DESIGN << true << false << true;\r\n    QTest::newRow(\"Design instantiation without name is not valid\") << \"\" << InstantiationType::DESIGN <<true << false << false;\r\n    QTest::newRow(\"Design instantiation without design reference is not valid\") << \"Balduran\" << InstantiationType::DESIGN << false << false << false;\r\n    QTest::newRow(\"Design instantiations with the same name is not valid\") << \"Balduran\" << InstantiationType::DESIGN << true << true << false;\r\n\r\n    // Design config instantiations\r\n    QTest::newRow(\"Design configuration instantiation with name and design configuration reference is valid\") << \"Balduran\" << InstantiationType::DESIGNCFG << true << false << true;\r\n    QTest::newRow(\"Design configuration instantiation without name is not valid\") << \"\" << InstantiationType::DESIGNCFG << true << false << false;\r\n    QTest::newRow(\"Design configuration instantiation without design configuration reference is not valid\") << \"Balduran\" << InstantiationType::DESIGNCFG << false << false << false;\r\n    QTest::newRow(\"Design configuration instantiations with the same name is not valid\") << \"Balduran\" << InstantiationType::DESIGNCFG << true << true << false;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ComponentValidator::testHasValidPorts()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ComponentValidator::testHasValidPorts()\r\n{\r\n    QFETCH(QString, portName);\r\n    QFETCH(QString, wireDirection);\r\n    QFETCH(bool, copyPort);\r\n    QFETCH(bool, isValid);\r\n\r\n    QSharedPointer<Port> testPort (new Port(portName));\r\n    testPort->setDirection(DirectionTypes::str2Direction(wireDirection, DirectionTypes::DIRECTION_INVALID));\r\n    QSharedPointer<Component> testComponent (new Component(\r\n        VLNV(VLNV::COMPONENT, \"Samurai\", \"Champloo\", \"MugenJinFuu\", \"3.0\"), Document::Revision::Std14));\r\n    testComponent->getPorts()->append(testPort);\r\n\r\n    if (copyPort)\r\n    {\r\n        QSharedPointer<Port> otherPort (new Port(*testPort.data()));\r\n        testComponent->getPorts()->append(otherPort);\r\n    }\r\n\r\n    QSharedPointer<ComponentValidator> validator = createComponentValidator(0);\r\n    QCOMPARE(validator->hasValidPorts(testComponent), isValid);\r\n\r\n    if (!isValid)\r\n    {\r\n        QVector<QString> foundErrors;\r\n        validator->findErrorsIn(foundErrors, testComponent);\r\n\r\n        QString expectedError = QObject::tr(\"Invalid name set for port %1 within component %2\")\r\n            .arg(portName).arg(testComponent->getVlnv().toString());\r\n\r\n        if (wireDirection.isEmpty())\r\n        {\r\n            expectedError = QObject::tr(\"Invalid direction set for port %1 within component %2\")\r\n                .arg(portName).arg(testComponent->getVlnv().toString());\r\n        }\r\n        else if (copyPort)\r\n        {\r\n            expectedError = QObject::tr(\"Port name %1 within component %2 is not unique.\")\r\n                .arg(portName).arg(testComponent->getVlnv().toString());\r\n        }\r\n\r\n        if (errorIsNotFoundInErrorList(expectedError, foundErrors))\r\n        {\r\n            QFAIL(\"No error message found\");\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ComponentValidator::testHasValidPorts_data()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ComponentValidator::testHasValidPorts_data()\r\n{\r\n    QTest::addColumn<QString>(\"portName\");\r\n    QTest::addColumn<QString>(\"wireDirection\");\r\n    QTest::addColumn<bool>(\"copyPort\");\r\n    QTest::addColumn<bool>(\"isValid\");\r\n\r\n    QTest::newRow(\"Port with name and direction is valid\") << \"Screed\" << \"in\" << false << true;\r\n    QTest::newRow(\"Port without name is not valid\") << \"\" << \"in\" << false << false;\r\n    QTest::newRow(\"Port without direction is not valid\") << \"Screed\" << \"\" << false << false;\r\n    QTest::newRow(\"Ports with the same name is not valid\") << \"Screed\" << \"in\" << true << false;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ComponentValidator::testHasValidComponentGenerators()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ComponentValidator::testHasValidComponentGenerators()\r\n{\r\n    QFETCH(QString, generatorName);\r\n    QFETCH(QString, generatorExe);\r\n    QFETCH(bool, copyGenerator);\r\n    QFETCH(bool, isValid);\r\n\r\n    QSharedPointer<ComponentGenerator> testGenerator (new ComponentGenerator());\r\n    testGenerator->setName(generatorName);\r\n    testGenerator->setGeneratorExe(generatorExe);\r\n\r\n    QSharedPointer<Component> testComponent (new Component(\r\n        VLNV(VLNV::COMPONENT, \"Samurai\", \"Champloo\", \"MugenJinFuu\", \"3.0\"), Document::Revision::Std14));\r\n    testComponent->getComponentGenerators()->append(testGenerator);\r\n\r\n    if (copyGenerator)\r\n    {\r\n        QSharedPointer<ComponentGenerator> otherGenerator (new ComponentGenerator(*testGenerator.data()));\r\n        testComponent->getComponentGenerators()->append(otherGenerator);\r\n    }\r\n\r\n    QSharedPointer<ComponentValidator> validator = createComponentValidator(0);\r\n    QCOMPARE(validator->hasValidComponentGenerators(testComponent), isValid);\r\n\r\n    if (!isValid)\r\n    {\r\n        QVector<QString> foundErrors;\r\n        validator->findErrorsIn(foundErrors, testComponent);\r\n\r\n        QString expectedError = QObject::tr(\"Invalid name specified for component generator %1 within component %2\").\r\n            arg(generatorName).arg(testComponent->getVlnv().toString());\r\n\r\n        if (generatorExe.isEmpty())\r\n        {\r\n            expectedError = QObject::tr(\"Invalid generator exe set for component generator '%1' within component %2\")\r\n                .arg(generatorName).arg(testComponent->getVlnv().toString());\r\n        }\r\n        else if (copyGenerator)\r\n        {\r\n            expectedError = QObject::tr(\"Component generator name '%1' within component %2 is not unique.\")\r\n                .arg(generatorName).arg(testComponent->getVlnv().toString());\r\n        }\r\n\r\n        if (errorIsNotFoundInErrorList(expectedError, foundErrors))\r\n        {\r\n            QFAIL(\"No error message found\");\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ComponentValidator::testHasValidComponentGenerators_data()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ComponentValidator::testHasValidComponentGenerators_data()\r\n{\r\n    QTest::addColumn<QString>(\"generatorName\");\r\n    QTest::addColumn<QString>(\"generatorExe\");\r\n    QTest::addColumn<bool>(\"copyGenerator\");\r\n    QTest::addColumn<bool>(\"isValid\");\r\n\r\n    QTest::newRow(\"Generator with name and generator exe is valid\")\r\n        << \"Nuclear\" << \"../bin/run.sh\" << false << true;\r\n    QTest::newRow(\"Generator without a name is not valid\") << \"\" << \"../bin/run.sh\" << false << false;\r\n    QTest::newRow(\"Generator without generator exe is not valid\") << \"Nuclear\" << \"\" << false << false;\r\n    QTest::newRow(\"Generators with the same name is not valid\") << \"Nuclear\" << \"../bin/run.sh\" << true << false;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ComponentValidator::testHasValidChoices()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ComponentValidator::testHasValidChoices()\r\n{\r\n    QFETCH(QString, choiceName);\r\n    QFETCH(QString, enumeration);\r\n    QFETCH(bool, copyChoice);\r\n    QFETCH(bool, createEnumeration);\r\n    QFETCH(bool, isValid);\r\n\r\n    QSharedPointer<Choice> testChoice (new Choice());\r\n    testChoice->setName(choiceName);\r\n    \r\n    if (createEnumeration)\r\n    {\r\n        QSharedPointer<Enumeration> testEnumeration (new Enumeration());\r\n        testEnumeration->setValue(enumeration);\r\n        testChoice->enumerations()->append(testEnumeration);\r\n    }\r\n\r\n    QSharedPointer<Component> testComponent (new Component(\r\n        VLNV(VLNV::COMPONENT, \"Samurai\", \"Champloo\", \"MugenJinFuu\", \"3.0\"), Document::Revision::Std14));\r\n    testComponent->getChoices()->append(testChoice);\r\n\r\n    if (copyChoice)\r\n    {\r\n        QSharedPointer<Choice> otherChoice (new Choice(*testChoice.data()));\r\n        testComponent->getChoices()->append(otherChoice);\r\n    }\r\n\r\n    QSharedPointer<ComponentValidator> validator = createComponentValidator(0);\r\n    QCOMPARE(validator->hasValidChoices(testComponent), isValid);\r\n\r\n    if (!isValid)\r\n    {\r\n        QVector<QString> foundErrors;\r\n        validator->findErrorsIn(foundErrors, testComponent);\r\n\r\n        QString expectedError = QObject::tr(\"Invalid name set for choice %1 within component %2\")\r\n            .arg(choiceName).arg(testComponent->getVlnv().toString());\r\n\r\n        if (!createEnumeration)\r\n        {\r\n            expectedError = QObject::tr(\"No enumerations found in choice '%1' within component %2\")\r\n                .arg(choiceName).arg(testComponent->getVlnv().toString());\r\n        }\r\n\r\n        else if (enumeration.isEmpty())\r\n        {\r\n            expectedError = QObject::tr(\"Invalid value '%1' set for enumeration in choice '%2' within component %3\")\r\n                .arg(enumeration).arg(choiceName).arg(testComponent->getVlnv().toString());\r\n        }\r\n\r\n        else if (copyChoice)\r\n        {\r\n            expectedError = QObject::tr(\"Choice name %1 within component %2 is not unique.\")\r\n                .arg(choiceName).arg(testComponent->getVlnv().toString());\r\n        }\r\n\r\n        if (errorIsNotFoundInErrorList(expectedError, foundErrors))\r\n        {\r\n            QFAIL(\"No error message found\");\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ComponentValidator::testHasValidChoices_data()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ComponentValidator::testHasValidChoices_data()\r\n{\r\n    QTest::addColumn<QString>(\"choiceName\");\r\n    QTest::addColumn<QString>(\"enumeration\");\r\n    QTest::addColumn<bool>(\"createEnumeration\");\r\n    QTest::addColumn<bool>(\"copyChoice\");\r\n    QTest::addColumn<bool>(\"isValid\");\r\n\r\n    QTest::newRow(\"Choice with name and enumeration is valid\") << \"Ackbar\" << \"10\" << true << false << true;\r\n    QTest::newRow(\"Choice without name is not valid\") << \"\" << \"10\" << true << false << false;\r\n    QTest::newRow(\"Choice without enumeration is not valid\") << \"Ackbar\" << \"\" << false << false << false;\r\n    QTest::newRow(\"Choice with empty enumeration value is not valid\") << \"Ackbar\" << \"\" << true << false << false;\r\n    QTest::newRow(\"Choices with the same name is not valid\") << \"Ackbar\" << \"10\" << true << true << false;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ComponentValidator::testHasValidFileSets()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ComponentValidator::testHasValidFileSets()\r\n{\r\n    QFETCH(QString, fileSetName);\r\n    QFETCH(bool, copyFileSet);\r\n    QFETCH(bool, isValid);\r\n\r\n    QSharedPointer<FileSet> testFileSet (new FileSet(fileSetName));\r\n\r\n    QSharedPointer<Component> testComponent (new Component(\r\n        VLNV(VLNV::COMPONENT, \"Samurai\", \"Champloo\", \"MugenJinFuu\", \"3.0\"), Document::Revision::Std14));\r\n    testComponent->getFileSets()->append(testFileSet);\r\n\r\n    if (copyFileSet)\r\n    {\r\n        QSharedPointer<FileSet> otherFileSet (new FileSet(*testFileSet.data()));\r\n        testComponent->getFileSets()->append(otherFileSet);\r\n    }\r\n\r\n    QSharedPointer<ComponentValidator> validator = createComponentValidator(0);\r\n    QCOMPARE(validator->hasValidFileSets(testComponent), isValid);\r\n\r\n    if (!isValid)\r\n    {\r\n        QVector<QString> foundErrors;\r\n        validator->findErrorsIn(foundErrors, testComponent);\r\n\r\n        QString expectedError = QObject::tr(\"Invalid name '%1' set for file set within component %2\")\r\n            .arg(fileSetName).arg(testComponent->getVlnv().toString());\r\n\r\n        if (copyFileSet)\r\n        {\r\n            expectedError = QObject::tr(\"File set name %1 within component %2 is not unique.\")\r\n                .arg(fileSetName).arg(testComponent->getVlnv().toString());\r\n        }\r\n\r\n        if (errorIsNotFoundInErrorList(expectedError, foundErrors))\r\n        {\r\n            QFAIL(\"No error message found\");\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ComponentValidator::testHasValidFileSets_data()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ComponentValidator::testHasValidFileSets_data()\r\n{\r\n    QTest::addColumn<QString>(\"fileSetName\");\r\n    QTest::addColumn<bool>(\"copyFileSet\");\r\n    QTest::addColumn<bool>(\"isValid\");\r\n\r\n    QTest::newRow(\"File set with name is valid\") << \"Soulafein\" << false << true;\r\n    QTest::newRow(\"File set without name is not valid\") << \"\" << false << false;\r\n    QTest::newRow(\"File sets with the same name is not valid\") << \"Soulafein\" << true << false;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ComponentValidator::testHasValidCPUs()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ComponentValidator::testHasValidCPUs()\r\n{\r\n    QFETCH(QString, name);\r\n    QFETCH(QString, referencedAddressSpace);\r\n    QFETCH(bool, copyCPU);\r\n    QFETCH(bool, isValid);\r\n\r\n    QSharedPointer<Cpu> testCPU (new Cpu(name));\r\n\r\n    QSharedPointer<Component> testComponent (new Component(\r\n        VLNV(VLNV::COMPONENT, \"Samurai\", \"Champloo\", \"MugenJinFuu\", \"3.0\"), Document::Revision::Std14));\r\n    testComponent->getCpus()->append(testCPU);\r\n\r\n    if (!referencedAddressSpace.isEmpty())\r\n    {\r\n        QSharedPointer<AddressSpace> testSpace (new AddressSpace(referencedAddressSpace, \"0\", \"8\"));\r\n        testComponent->getAddressSpaces()->append(testSpace);\r\n\r\n        QStringList addressSpaceReferences;\r\n        addressSpaceReferences.append(referencedAddressSpace);\r\n        testCPU->setAddressSpaceRefs(addressSpaceReferences);\r\n    }\r\n\r\n    if (copyCPU)\r\n    {\r\n        QSharedPointer<Cpu> otherCPU (new Cpu(*testCPU.data()));\r\n        testComponent->getCpus()->append(otherCPU);\r\n    }\r\n\r\n    QSharedPointer<ComponentValidator> validator = createComponentValidator(0);\r\n    QCOMPARE(validator->hasValidCPUs(testComponent), isValid);\r\n\r\n    if (!isValid)\r\n    {\r\n        QVector<QString> foundErrors;\r\n        validator->findErrorsIn(foundErrors, testComponent);\r\n\r\n        QString expectedError = QObject::tr(\"Invalid name '%1' set for CPU within component %2.\")\r\n            .arg(name).arg(testComponent->getVlnv().toString());\r\n\r\n        if (referencedAddressSpace.isEmpty())\r\n        {\r\n            expectedError = QObject::tr(\"No address space reference set for CPU %1 within component %2.\")\r\n                .arg(name).arg(testComponent->getVlnv().toString());\r\n        }\r\n        else if (copyCPU)\r\n        {\r\n            expectedError = QObject::tr(\"CPU name %1 within component %2 is not unique.\")\r\n                .arg(name).arg(testComponent->getVlnv().toString());\r\n        }\r\n\r\n        if (errorIsNotFoundInErrorList(expectedError, foundErrors))\r\n        {\r\n            QFAIL(\"No error message found\");\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ComponentValidator::testHasValidCPUs_data()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ComponentValidator::testHasValidCPUs_data()\r\n{\r\n    QTest::addColumn<QString>(\"name\");\r\n    QTest::addColumn<QString>(\"referencedAddressSpace\");\r\n    QTest::addColumn<bool>(\"copyCPU\");\r\n    QTest::addColumn<bool>(\"isValid\");\r\n\r\n    QTest::newRow(\"CPU with name and address space reference is valid\") << \"QT\" << \"Dandy\" << false << true;\r\n    QTest::newRow(\"CPU without name is not valid\") << \"\" << \"Dandy\" << false << false;\r\n    QTest::newRow(\"CPU without address space reference is not valid\") << \"QT\" << \"\" << false << false;\r\n    QTest::newRow(\"CPUs with the same name is not valid\") << \"QT\" << \"Dandy\" << true << false;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ComponentValidator::testHasValidOtherClockDrivers()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ComponentValidator::testHasValidOtherClockDrivers()\r\n{\r\n    QFETCH(QString, clockName);\r\n    QFETCH(bool, createTimeUnits);\r\n    QFETCH(bool, copyClock);\r\n    QFETCH(bool, isValid);\r\n\r\n    QSharedPointer<OtherClockDriver> testDriver (new OtherClockDriver(clockName));\r\n\r\n    if (createTimeUnits)\r\n    {\r\n        QSharedPointer<ClockUnit> clockPeriod (new ClockUnit(\"0.2\"));\r\n        testDriver->setClockPeriod(clockPeriod);\r\n        QSharedPointer<ClockUnit> clockPulseOffset (new ClockUnit(\"0.02\"));\r\n        testDriver->setClockPulseOffset(clockPulseOffset);\r\n        QSharedPointer<ClockUnit> clockPulseDuration (new ClockUnit(\"0.002\"));\r\n        testDriver->setClockPulseDuration(clockPulseDuration);\r\n        testDriver->setClockPulseValue(\"1\");\r\n    }\r\n\r\n    QSharedPointer<Component> testComponent (new Component(\r\n        VLNV(VLNV::COMPONENT, \"Samurai\", \"Champloo\", \"MugenJinFuu\", \"3.0\"), Document::Revision::Std14));\r\n    testComponent->getOtherClockDrivers()->append(testDriver);\r\n\r\n    if (copyClock)\r\n    {\r\n        QSharedPointer<OtherClockDriver> otherDriver (new OtherClockDriver(*testDriver.data()));\r\n        testComponent->getOtherClockDrivers()->append(otherDriver);\r\n    }\r\n\r\n    QSharedPointer<ComponentValidator> validator = createComponentValidator(0);\r\n    QCOMPARE(validator->hasValidOtherClockDrivers(testComponent), isValid);\r\n\r\n    if (!isValid)\r\n    {\r\n        QVector<QString> foundErrors;\r\n        validator->findErrorsIn(foundErrors, testComponent);\r\n\r\n        QString expectedError = QObject::tr(\"Invalid name '%1' set for other clock driver within component %2\")\r\n            .arg(clockName).arg(testComponent->getVlnv().toString());\r\n\r\n        if (copyClock)\r\n        {\r\n            expectedError = QObject::tr(\"Other clock driver name %1 within component %2 is not unique.\")\r\n                .arg(clockName).arg(testComponent->getVlnv().toString());\r\n        }\r\n\r\n        else if (!createTimeUnits)\r\n        {\r\n            expectedError = QObject::tr(\"Invalid clock period %1 set for other clock driver %2 within component %3\")\r\n                .arg(testDriver->getClockPeriod()->getValue()).arg(testDriver->getClockName())\r\n                .arg(testComponent->getVlnv().toString());\r\n        }\r\n\r\n        if (errorIsNotFoundInErrorList(expectedError, foundErrors))\r\n        {\r\n            QFAIL(\"No error message found\");\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ComponentValidator::testHasValidOtherClockDrivers_data()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ComponentValidator::testHasValidOtherClockDrivers_data()\r\n{\r\n    QTest::addColumn<QString>(\"clockName\");\r\n    QTest::addColumn<bool>(\"createTimeUnits\");\r\n    QTest::addColumn<bool>(\"copyClock\");\r\n    QTest::addColumn<bool>(\"isValid\");\r\n\r\n    QTest::newRow(\"Other clock driver with name and clock units is valid\") << \"Time\" << true << false << true;\r\n    QTest::newRow(\"Other clock driver without name is not valid\") << \"\" << true << false << false;\r\n    QTest::newRow(\"Other clock driver without clock units is not valid\") << \"Time\" << false << false << false;\r\n    QTest::newRow(\"Other clock drivers with the same name is not valid\") << \"Time\" << true << true << false;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ComponentValidator::testHasValidPowerDomains()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ComponentValidator::testHasValidPowerDomains()\r\n{\r\n    QFETCH(QString, domainName);\r\n    QFETCH(bool, isValid);\r\n\r\n    QSharedPointer<PowerDomain> testDomain(new PowerDomain());\r\n    testDomain->setName(domainName);\r\n\r\n    QSharedPointer<PowerDomain> duplicateDomain(new PowerDomain());\r\n    duplicateDomain->setName(\"reservedName\");\r\n\r\n    QSharedPointer<Component> testComponent(new Component(\r\n        VLNV(VLNV::COMPONENT, \"Samurai\", \"Champloo\", \"MugenJinFuu\", \"3.0\"), Document::Revision::Std22));\r\n    testComponent->getPowerDomains()->append(testDomain);\r\n    testComponent->getPowerDomains()->append(duplicateDomain);\r\n\r\n    QSharedPointer<ComponentValidator> validator = createComponentValidator(nullptr);\r\n    QCOMPARE(validator->hasValidPowerDomains(testComponent), isValid);\r\n\r\n    if (!isValid)\r\n    {\r\n        QVector<QString> foundErrors;\r\n        validator->findErrorsIn(foundErrors, testComponent);\r\n\r\n        QString expectedError = QObject::tr(\r\n            \"Power domain name %1 within component Samurai:Champloo:MugenJinFuu:3.0 is not unique.\")\r\n            .arg(domainName);\r\n\r\n        if (errorIsNotFoundInErrorList(expectedError, foundErrors))\r\n        {\r\n            QFAIL(\"No error message found\");\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ComponentValidator::testHasValidPowerDomains_data()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ComponentValidator::testHasValidPowerDomains_data()\r\n{\r\n    QTest::addColumn<QString>(\"domainName\");\r\n    QTest::addColumn<bool>(\"isValid\");\r\n\r\n    QTest::newRow(\"Named domain is valid\") << \"testDomain\" << true;\r\n    QTest::newRow(\"Domain with duplicate name is not valid\") << \"reservedName\" << false;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ComponentValidator::testHasValidResetTypes()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ComponentValidator::testHasValidResetTypes()\r\n{\r\n    QFETCH(QString, name);\r\n    QFETCH(QString, name2);\r\n    QFETCH(bool, isValid);\r\n\r\n    QSharedPointer<ResetType> testReset(new ResetType());\r\n    testReset->setName(name);\r\n\r\n    QSharedPointer<Component> testComponent(new Component(\r\n        VLNV(VLNV::COMPONENT, \"Samurai\", \"Champloo\", \"MugenJinFuu\", \"3.0\"), Document::Revision::Std14));\r\n    testComponent->getResetTypes()->append(testReset);\r\n\r\n    if (!name2.isEmpty())\r\n    {\r\n        QSharedPointer<ResetType> testReset2(new ResetType());\r\n        testReset2->setName(name2);\r\n        testComponent->getResetTypes()->append(testReset2);\r\n    }\r\n\r\n    QSharedPointer<ComponentValidator> validator = createComponentValidator(0);\r\n    QCOMPARE(validator->hasValidResetTypes(testComponent), isValid);\r\n\r\n    if (!isValid)\r\n    {\r\n        QVector<QString> foundErrors;\r\n        validator->findErrorsIn(foundErrors, testComponent);\r\n\r\n        QString expectedError = QObject::tr(\"Invalid name '%1' set for reset type within component %2\")\r\n            .arg(name).arg(testComponent->getVlnv().toString());\r\n\r\n        if (name.toUpper() == QLatin1String(\"HARD\"))\r\n        {\r\n            expectedError.append(\", HARD is reserved for the default reset type.\");\r\n        }\r\n\r\n        if (!name2.isEmpty())\r\n        {\r\n            expectedError = QObject::tr(\"Reset type name '%1' within component %2 is not unique.\")\r\n                .arg(name).arg(testComponent->getVlnv().toString());\r\n        }\r\n\r\n        if (errorIsNotFoundInErrorList(expectedError, foundErrors))\r\n        {\r\n            QFAIL(\"No error message found.\");\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ComponentValidator::testHasValidResetTypes_data()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ComponentValidator::testHasValidResetTypes_data()\r\n{\r\n    QTest::addColumn<QString>(\"name\");\r\n    QTest::addColumn<QString>(\"name2\");\r\n    QTest::addColumn<bool>(\"isValid\");\r\n\r\n    QTest::newRow(\"Reset type with name is valid\") << \"SOFT\" << \"\" << true;\r\n    QTest::newRow(\"Reset type without name is not valid\") << \"\" << \"\" << false;\r\n    QTest::newRow(\"Reset type with name HARD is not valid\") << \"HARD\" << \"\" << false;\r\n    QTest::newRow(\"Unique names is valid\") << \"SOFT\" << \"TEST\" << true;\r\n    QTest::newRow(\"Non-unique names is not valid\") << \"SOFT\" << \"SOFT\" << false;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ComponentValidator::testHasValidParameter()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ComponentValidator::testHasValidParameters()\r\n{\r\n    QFETCH(QString, name);\r\n    QFETCH(QString, value);\r\n    QFETCH(bool, copyParameter);\r\n    QFETCH(bool, isValid);\r\n\r\n    QSharedPointer<Parameter> testParameter (new Parameter());\r\n    testParameter->setName(name);\r\n    testParameter->setValue(value);\r\n\r\n    QSharedPointer<Component> testComponent (new Component(\r\n        VLNV(VLNV::COMPONENT, \"Samurai\", \"Champloo\", \"MugenJinFuu\", \"3.0\"), Document::Revision::Std14));\r\n    testComponent->getParameters()->append(testParameter);\r\n\r\n    if (copyParameter)\r\n    {\r\n        QSharedPointer<Parameter> otherParameter (new Parameter(*testParameter.data()));\r\n        testComponent->getParameters()->append(otherParameter);\r\n    }\r\n\r\n    QSharedPointer<ComponentValidator> validator = createComponentValidator(0);\r\n    QCOMPARE(validator->hasValidParameters(testComponent), isValid);\r\n\r\n    if (!isValid)\r\n    {\r\n        QVector<QString> foundErrors;\r\n        validator->findErrorsIn(foundErrors, testComponent);\r\n\r\n        QString expectedError = QObject::tr(\"No valid name specified for parameter %1 within component %2\")\r\n            .arg(name).arg(testComponent->getVlnv().toString());\r\n\r\n        if (value.isEmpty())\r\n        {\r\n            expectedError = QObject::tr(\"No value specified for parameter %1 within component %2\")\r\n                .arg(name).arg(testComponent->getVlnv().toString());\r\n        }\r\n        else if (copyParameter)\r\n        {\r\n            expectedError = QObject::tr(\"Parameter name %1 within component %2 is not unique.\")\r\n                .arg(name).arg(testComponent->getVlnv().toString());\r\n        }\r\n\r\n        if (errorIsNotFoundInErrorList(expectedError, foundErrors))\r\n        {\r\n            QFAIL(\"No error message found\");\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ComponentValidator::testHasValidParameters_data()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ComponentValidator::testHasValidParameters_data()\r\n{\r\n    QTest::addColumn<QString>(\"name\");\r\n    QTest::addColumn<QString>(\"value\");\r\n    QTest::addColumn<bool>(\"copyParameter\");\r\n    QTest::addColumn<bool>(\"isValid\");\r\n\r\n    QTest::newRow(\"Parameter with name and value is valid\") << \"Gunmen\" << \"8\" << false << true;\r\n    QTest::newRow(\"Parameter without name is not valid\") << \"\" << \"8\" << false << false;\r\n    QTest::newRow(\"Parameter without value is not valid\") << \"Gunmen\" << \"\" << false << false;\r\n    QTest::newRow(\"Parameters with the same name is not valid\") << \"Gunmen\" << \"8\" << true << false;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ComponentValidator::testHasValidAssertions()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ComponentValidator::testHasValidAssertions()\r\n{\r\n    QFETCH(QString, name);\r\n    QFETCH(QString, assertValue);\r\n    QFETCH(bool, copyAssertion);\r\n    QFETCH(bool, isValid);\r\n\r\n    QSharedPointer<Assertion> testAssertion (new Assertion());\r\n    testAssertion->setName(name);\r\n    testAssertion->setAssert(assertValue);\r\n\r\n    QSharedPointer<Component> testComponent (new Component(\r\n        VLNV(VLNV::COMPONENT, \"Samurai\", \"Champloo\", \"MugenJinFuu\", \"3.0\"), Document::Revision::Std14));\r\n    testComponent->getAssertions()->append(testAssertion);\r\n\r\n    if (copyAssertion)\r\n    {\r\n        QSharedPointer<Assertion> otherAssertion (new Assertion(*testAssertion.data()));\r\n        testComponent->getAssertions()->append(otherAssertion);\r\n    }\r\n\r\n    QSharedPointer<ComponentValidator> validator = createComponentValidator(0);\r\n    QCOMPARE(validator->hasValidAssertions(testComponent), isValid);\r\n\r\n    if (!isValid)\r\n    {\r\n        QVector<QString> foundErrors;\r\n        validator->findErrorsIn(foundErrors, testComponent);\r\n\r\n        QString expectedError = QObject::tr(\"Invalid name set for assertion %1 within component %2\")\r\n            .arg(name).arg(testComponent->getVlnv().toString());\r\n\r\n        QSharedPointer<ExpressionParser> parser (new SystemVerilogExpressionParser());\r\n        bool assertOk = true;\r\n        int parsedAssert = parser->parseExpression(assertValue).toInt(&assertOk);\r\n\r\n        if (!assertOk || parsedAssert != 1)\r\n        {\r\n            expectedError = QObject::tr(\"Invalid assert set for assertion %1 within component %2\")\r\n                .arg(name).arg(testComponent->getVlnv().toString());\r\n        }\r\n        else if (copyAssertion)\r\n        {\r\n            expectedError = QObject::tr(\"Assertion name %1 within component %2 is not unique.\")\r\n                .arg(name).arg(testComponent->getVlnv().toString());\r\n        }\r\n\r\n        if (errorIsNotFoundInErrorList(expectedError, foundErrors))\r\n        {\r\n            QFAIL(\"No error message found\");\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ComponentValidator::testHasValidAssertions_data()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ComponentValidator::testHasValidAssertions_data()\r\n{\r\n    QTest::addColumn<QString>(\"name\");\r\n    QTest::addColumn<QString>(\"assertValue\");\r\n    QTest::addColumn<bool>(\"copyAssertion\");\r\n    QTest::addColumn<bool>(\"isValid\");\r\n\r\n    QTest::newRow(\"Assertion with name and assert value of 1 is valid\") << \"Onibocho\" << \"1\" << false << true;\r\n    QTest::newRow(\"Assertion without name is not valid\") << \"\" << \"4-3\" << false << false;\r\n    QTest::newRow(\"Assertion with incorrect assert value is not valid\") << \"Onibocho\" << \"4*2\" << false << false;\r\n    QTest::newRow(\"Assertion with assert value 0 is not valid\") << \"Onibocho\" << \"1*2-2\" << false << false;\r\n    QTest::newRow(\"Assertion without assert value is not valid\") << \"Onibocho\" << \"\" << false << false;\r\n    QTest::newRow(\"Assertions with the same name is not valid\") << \"Onibocho\" << \"1\" << true << false;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ComponentValidator::errorIsNotFoundInErrorList()\r\n//-----------------------------------------------------------------------------\r\nbool tst_ComponentValidator::errorIsNotFoundInErrorList(QString const& expectedError,\r\n    QVector<QString> errorList)\r\n{\r\n    if (!errorList.contains(expectedError))\r\n    {\r\n        qDebug() << \"The following error:\" << Qt::endl << expectedError << Qt::endl << \"was not found in error list:\";\r\n        for (auto const& error : errorList)\r\n        {\r\n            qDebug() << error;\r\n        }\r\n        return true;\r\n    }\r\n\r\n    return false;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ComponentValidator::createComponentValidator()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<ComponentValidator> tst_ComponentValidator::createComponentValidator(LibraryMock* mockLibrary)\r\n{\r\n    QSharedPointer<ExpressionParser> parser (new SystemVerilogExpressionParser());\r\n\r\n    QSharedPointer<ComponentParameterFinder> componentParameterFinder(new ComponentParameterFinder(nullptr));\r\n\r\n    QSharedPointer<ModeConditionParserInterface> modeConditionParserIf(new ModeConditionParserInterface(componentParameterFinder));\r\n\r\n    QSharedPointer<ComponentValidator> componentValidator (new ComponentValidator(parser, modeConditionParserIf, mockLibrary, Document::Revision::Std14));\r\n\r\n    return componentValidator;\r\n}\r\n\r\nQTEST_APPLESS_MAIN(tst_ComponentValidator)\r\n\r\n#include \"tst_ComponentValidator.moc\"\r\n"
  },
  {
    "path": "tests/IPXACTmodels/Component/tst_ComponentValidator.pri",
    "content": "# ----------------------------------------------------\r\n# This file is generated by the Qt Visual Studio Tools.\r\n# ------------------------------------------------------\r\n\r\nHEADERS += ../../MockObjects/LibraryMock.h \r\n   \r\nSOURCES += ../../MockObjects/LibraryMock.cpp \\\r\n    ./tst_ComponentValidator.cpp\r\n   "
  },
  {
    "path": "tests/IPXACTmodels/Component/tst_ComponentValidator.pro",
    "content": "#-----------------------------------------------------------------------------\r\n# File: tst_ComponentValidator.pro\r\n#-----------------------------------------------------------------------------\r\n# Project: Kactus 2\r\n# Author: Mikko Teuho\r\n# Date: 14.12.2015\r\n#\r\n# Description:\r\n# Qt project file template for running unit tests for ComponentValidator.\r\n#-----------------------------------------------------------------------------\r\n\r\nTEMPLATE = app\r\n\r\nTARGET = tst_ComponentValidator\r\n\r\nQT += core gui xml testlib\r\n\r\nCONFIG += c++11 testcase console\r\n\r\nlinux-g++ | linux-g++-64 | linux-g++-32 {\r\n LIBS += -L../../../executable \\\r\n     -lIPXACTmodels -lKactusAPI\r\n\r\n}\r\nwin64 | win32 {\r\n LIBS += -L../../../executable \\\r\n     -lIPXACTmodelsd -lKactusAPId\r\n}\r\n\r\nINCLUDEPATH += $$DESTDIR\r\nINCLUDEPATH += ../../../\r\n\r\nDEPENDPATH += .\r\nDEPENDPATH += ../../../\r\n\r\nOBJECTS_DIR += $$DESTDIR\r\n\r\nMOC_DIR += ./generatedFiles\r\nUI_DIR += ./generatedFiles\r\nRCC_DIR += ./generatedFiles\r\ninclude(tst_ComponentValidator.pri)\r\n"
  },
  {
    "path": "tests/IPXACTmodels/Component/tst_ComponentWriter.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: tst_ComponentWriter.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Mikko Teuho\n// Date: 12.10.2015\n//\n// Description:\n// Unit test for class ComponentWriter.\n//-----------------------------------------------------------------------------\n\n#include <IPXACTmodels/common/TagData.h>\n\n#include <IPXACTmodels/Component/ComponentWriter.h>\n#include <IPXACTmodels/Component/Component.h>\n\n#include <IPXACTmodels/Component/BusInterface.h>\n#include <IPXACTmodels/Component/IndirectInterface.h>\n#include <IPXACTmodels/Component/Channel.h>\n#include <IPXACTmodels/Component/RemapState.h>\n#include <IPXACTmodels/Component/Mode.h>\n#include <IPXACTmodels/Component/AddressSpace.h>\n#include <IPXACTmodels/Component/MemoryMap.h>\n#include <IPXACTmodels/Component/View.h>\n#include <IPXACTmodels/Component/ComponentInstantiation.h>\n#include <IPXACTmodels/Component/DesignInstantiation.h>\n#include <IPXACTmodels/Component/DesignConfigurationInstantiation.h>\n#include <IPXACTmodels/Component/Port.h>\n#include <IPXACTmodels/Component/PowerDomain.h>\n#include <IPXACTmodels/Component/ComponentGenerator.h>\n#include <IPXACTmodels/Component/FileSet.h>\n#include <IPXACTmodels/Component/Cpu.h>\n#include <IPXACTmodels/Component/OtherClockDriver.h>\n#include <IPXACTmodels/Component/ResetType.h>\n#include <IPXACTmodels/common/Assertion.h>\n#include <IPXACTmodels/common/Choice.h>\n#include <IPXACTmodels/common/Enumeration.h>\n#include <IPXACTmodels/common/Parameter.h>\n\n#include <IPXACTmodels/kactusExtensions/ComProperty.h>\n#include <IPXACTmodels/kactusExtensions/SystemView.h>\n#include <IPXACTmodels/kactusExtensions/ComInterface.h>\n#include <IPXACTmodels/kactusExtensions/ApiInterface.h>\n#include <IPXACTmodels/kactusExtensions/FileDependency.h>\n\n#include <IPXACTmodels/common/GenericVendorExtension.h>\n\n#include <QtTest>\n\nclass tst_ComponentWriter : public QObject\n{\n    Q_OBJECT\n\npublic:\n    tst_ComponentWriter();\n\nprivate slots:\n\n    void initTestCase();\n    void cleanupTestCase();\n    void init();\n    void cleanup();\n\n    void writeSimpleComponent();\n\n    void writeXMLProcessingInstructions();\n    void writeXMLNameSpaces();\n\n    void writePowerDomains2022();\n\n    void writeBusInterfaces();\n\n    void writeIndirectInterfaces();\n\n    void writeChannels();\n    void writeRemapStates();\n    void writeModes2022();\n    void writeAddressSpace();\n    void writeMemoryMap();\n\n    void writeView();\n    void writeInstantiations();\n    void writePorts();\n\n    void writeComponentGenerators();\n    void writeChoices();\n    void writeFileSets();\n    void writeCPUs();\n    void writeOtherClockDrivers();\n    void writeResetTypes();\n    void writeResetTypes2022();\n\n    void writeParameters();\n    void writeAssertions();\n    void writeVendorExtensions();\n\n    void writeKactusAttributes();\n    void writeSwProperties();\n    void writeSystemViews();\n    void writeComInterfaces();\n    void writeApiInterfaces();\n    void writeFileDependencies();\n\n    void writeTags();\n    void writeErasedTags();\n\nprivate:\n\n    QSharedPointer<Component> testComponent_;\n};\n\n//-----------------------------------------------------------------------------\n// Function: tst_ComponentWriter::tst_ComponentWriter()\n//-----------------------------------------------------------------------------\ntst_ComponentWriter::tst_ComponentWriter() :\ntestComponent_()\n{\n\n}\n\n\n//-----------------------------------------------------------------------------\n// Function: tst_ComponentWriter::initTestCase()\n//-----------------------------------------------------------------------------\nvoid tst_ComponentWriter::initTestCase()\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_ComponentWriter::cleanupTestCase()\n//-----------------------------------------------------------------------------\nvoid tst_ComponentWriter::cleanupTestCase()\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_ComponentWriter::init()\n//-----------------------------------------------------------------------------\nvoid tst_ComponentWriter::init()\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_ComponentWriter::cleanup()\n//-----------------------------------------------------------------------------\nvoid tst_ComponentWriter::cleanup()\n{\n    testComponent_.clear();\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_ComponentWriter::writeSimpleComponent()\n//-----------------------------------------------------------------------------\nvoid tst_ComponentWriter::writeSimpleComponent()\n{\n    VLNV componentVLNV(VLNV::COMPONENT, \"tuni.fi\", \"TestLibrary\", \"TestComponent\", \"0.11\");\n    testComponent_ = QSharedPointer<Component>(new Component(componentVLNV, Document::Revision::Std14));\n\n    QString output;\n    QXmlStreamWriter xmlStreamWriter(&output);\n\n    xmlStreamWriter.setAutoFormatting(true);\n    xmlStreamWriter.setAutoFormattingIndent(-1);\n\n    testComponent_->setDescription(\"coreDrill\");\n\n    QString expectedOutput(\n        \"<?xml version=\\\"1.0\\\"?>\\n\"\n        \"<ipxact:component \"\n        \"xmlns:xsi=\\\"http://www.w3.org/2001/XMLSchema-instance\\\" \" \n        \"xmlns:ipxact=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014\\\" \"\n        \"xmlns:kactus2=\\\"http://kactus2.cs.tut.fi\\\" \"\n        \"xsi:schemaLocation=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014 \"\n        \"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/index.xsd\\\">\\n\"\n            \"\\t<ipxact:vendor>tuni.fi</ipxact:vendor>\\n\"\n            \"\\t<ipxact:library>TestLibrary</ipxact:library>\\n\"\n            \"\\t<ipxact:name>TestComponent</ipxact:name>\\n\"\n            \"\\t<ipxact:version>0.11</ipxact:version>\\n\"\n            \"\\t<ipxact:description>coreDrill</ipxact:description>\\n\"\n        \"</ipxact:component>\\n\"\n        );\n\n    ComponentWriter componentWriter;\n    componentWriter.writeComponent(xmlStreamWriter, testComponent_);\n\n    QCOMPARE(output, expectedOutput);\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_ComponentWriter::writeXMLProcessingInstructions()\n//-----------------------------------------------------------------------------\nvoid tst_ComponentWriter::writeXMLProcessingInstructions()\n{\n    VLNV componentVLNV(VLNV::COMPONENT, \"tuni.fi\", \"TestLibrary\", \"TestComponent\", \"0.11\");\n    testComponent_ = QSharedPointer<Component>(new Component(componentVLNV, Document::Revision::Std14));\n\n    QString output;\n    QXmlStreamWriter xmlStreamWriter(&output);\n\n    xmlStreamWriter.setAutoFormatting(true);\n    xmlStreamWriter.setAutoFormattingIndent(-1);\n\n    testComponent_->addXmlProcessingInstructions(\"xml-stylesheet\", \"href=\\\"style.css\\\"\");\n\n    QString expectedOutput(\n        \"<?xml version=\\\"1.0\\\"?>\\n\"\n        \"<?xml-stylesheet href=\\\"style.css\\\"?>\\n\"\n        \"<ipxact:component \"\n        \"xmlns:xsi=\\\"http://www.w3.org/2001/XMLSchema-instance\\\" \" \n        \"xmlns:ipxact=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014\\\" \"\n        \"xmlns:kactus2=\\\"http://kactus2.cs.tut.fi\\\" \"\n        \"xsi:schemaLocation=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014 \"\n        \"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/index.xsd\\\">\\n\"\n            \"\\t<ipxact:vendor>tuni.fi</ipxact:vendor>\\n\"\n            \"\\t<ipxact:library>TestLibrary</ipxact:library>\\n\"\n            \"\\t<ipxact:name>TestComponent</ipxact:name>\\n\"\n            \"\\t<ipxact:version>0.11</ipxact:version>\\n\"\n        \"</ipxact:component>\\n\"\n        );\n\n    ComponentWriter componentWriter;\n    componentWriter.writeComponent(xmlStreamWriter, testComponent_);\n\n    QCOMPARE(output, expectedOutput);\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_ComponentWriter:::writeXMLNameSpaces()\n//-----------------------------------------------------------------------------\nvoid tst_ComponentWriter::writeXMLNameSpaces()\n{\n    VLNV componentVLNV(VLNV::COMPONENT, \"tuni.fi\", \"TestLibrary\", \"TestComponent\", \"0.11\");\n    testComponent_ = QSharedPointer<Component>(new Component(componentVLNV, Document::Revision::Std14));\n    \n    QString output;\n    QXmlStreamWriter xmlStreamWriter(&output);\n\n    xmlStreamWriter.setAutoFormatting(true);\n    xmlStreamWriter.setAutoFormattingIndent(-1);\n\n    testComponent_->addXmlNameSpace(\"bogusvendor\", \"http://bogus.tld/info.txt\");\n\n    QString expectedOutput(\n        \"<?xml version=\\\"1.0\\\"?>\\n\"\n        \"<ipxact:component \"\n        \"xmlns:xsi=\\\"http://www.w3.org/2001/XMLSchema-instance\\\" \" \n        \"xmlns:ipxact=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014\\\" \"\n        \"xmlns:kactus2=\\\"http://kactus2.cs.tut.fi\\\" \"\n        \"xmlns:bogusvendor=\\\"http://bogus.tld/info.txt\\\" \"\n        \"xsi:schemaLocation=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014 \"\n        \"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/index.xsd\\\">\\n\"\n        \"\\t<ipxact:vendor>tuni.fi</ipxact:vendor>\\n\"\n        \"\\t<ipxact:library>TestLibrary</ipxact:library>\\n\"\n        \"\\t<ipxact:name>TestComponent</ipxact:name>\\n\"\n        \"\\t<ipxact:version>0.11</ipxact:version>\\n\"\n        \"</ipxact:component>\\n\"\n        );\n\n    ComponentWriter componentWriter;\n    componentWriter.writeComponent(xmlStreamWriter, testComponent_);\n\n    QCOMPARE(output, expectedOutput);\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_ComponentWriter::writePowerDomains2022()\n//-----------------------------------------------------------------------------\nvoid tst_ComponentWriter::writePowerDomains2022()\n{\n    VLNV componentVLNV(VLNV::COMPONENT, \"tuni.fi\", \"TestLibrary\", \"TestComponent\", \"0.11\");\n    testComponent_ = QSharedPointer<Component>(new Component(componentVLNV, Document::Revision::Std22));\n\n    QString output;\n    QXmlStreamWriter xmlStreamWriter(&output);\n\n    xmlStreamWriter.setAutoFormatting(true);\n    xmlStreamWriter.setAutoFormattingIndent(-1);\n\n    auto testDomain = QSharedPointer<PowerDomain>(new PowerDomain());\n    testDomain->setName(\"testDomain\");\n    testDomain->setAlwaysOn(\"1\");\n\n    testComponent_->getPowerDomains()->append(testDomain);\n\n    QString expectedOutput(\n        \"<?xml version=\\\"1.0\\\"?>\\n\"\n        \"<ipxact:component \"\n        \"xmlns:xsi=\\\"http://www.w3.org/2001/XMLSchema-instance\\\" \" \n        \"xmlns:ipxact=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2022\\\" \"\n        \"xmlns:kactus2=\\\"http://kactus2.cs.tut.fi\\\" \"\n        \"xsi:schemaLocation=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2022 \"\n        \"http://www.accellera.org/XMLSchema/IPXACT/1685-2022/index.xsd\\\">\\n\"\n            \"\\t<ipxact:vendor>tuni.fi</ipxact:vendor>\\n\"\n            \"\\t<ipxact:library>TestLibrary</ipxact:library>\\n\"\n            \"\\t<ipxact:name>TestComponent</ipxact:name>\\n\"\n            \"\\t<ipxact:version>0.11</ipxact:version>\\n\"\n            \"\\t<ipxact:powerDomains>\\n\"\n                \"\\t\\t<ipxact:powerDomain>\\n\"\n                    \"\\t\\t\\t<ipxact:name>testDomain</ipxact:name>\\n\"\n                    \"\\t\\t\\t<ipxact:alwaysOn>1</ipxact:alwaysOn>\\n\"                     \n                \"\\t\\t</ipxact:powerDomain>\\n\"\n            \"\\t</ipxact:powerDomains>\\n\"\n        \"</ipxact:component>\\n\"\n        );\n\n    ComponentWriter componentWriter;\n    componentWriter.writeComponent(xmlStreamWriter, testComponent_);\n\n    QCOMPARE(output, expectedOutput);\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_ComponentWriter::writeBusInterfaces()\n//-----------------------------------------------------------------------------\nvoid tst_ComponentWriter::writeBusInterfaces()\n{\n    VLNV componentVLNV(VLNV::COMPONENT, \"tuni.fi\", \"TestLibrary\", \"TestComponent\", \"0.11\");\n    testComponent_ = QSharedPointer<Component>(new Component(componentVLNV, Document::Revision::Std14));\n\n    QString output;\n    QXmlStreamWriter xmlStreamWriter(&output);\n\n    xmlStreamWriter.setAutoFormatting(true);\n    xmlStreamWriter.setAutoFormattingIndent(-1);\n\n    QSharedPointer<BusInterface> busInterface (new BusInterface());\n    busInterface->setName(\"testInterface\");\n    busInterface->setInterfaceMode(General::MASTER);\n    busInterface->setBusType(VLNV(VLNV::BUSDEFINITION,\"tuni.fi\",\"TestLibrary\",\"busDefinition\",\"0.2\"));\n\n    testComponent_->getBusInterfaces()->append(busInterface);\n\n    QString expectedOutput(\n        \"<?xml version=\\\"1.0\\\"?>\\n\"\n        \"<ipxact:component \"\n        \"xmlns:xsi=\\\"http://www.w3.org/2001/XMLSchema-instance\\\" \" \n        \"xmlns:ipxact=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014\\\" \"\n        \"xmlns:kactus2=\\\"http://kactus2.cs.tut.fi\\\" \"\n        \"xsi:schemaLocation=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014 \"\n        \"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/index.xsd\\\">\\n\"\n            \"\\t<ipxact:vendor>tuni.fi</ipxact:vendor>\\n\"\n            \"\\t<ipxact:library>TestLibrary</ipxact:library>\\n\"\n            \"\\t<ipxact:name>TestComponent</ipxact:name>\\n\"\n            \"\\t<ipxact:version>0.11</ipxact:version>\\n\"\n            \"\\t<ipxact:busInterfaces>\\n\"\n                \"\\t\\t<ipxact:busInterface>\\n\"\n                    \"\\t\\t\\t<ipxact:name>testInterface</ipxact:name>\\n\"\n                    \"\\t\\t\\t<ipxact:busType vendor=\\\"tuni.fi\\\" library=\\\"TestLibrary\\\" name=\\\"busDefinition\\\"\"\n                        \" version=\\\"0.2\\\"/>\\n\"\n                    \"\\t\\t\\t<ipxact:master/>\\n\"\n                \"\\t\\t</ipxact:busInterface>\\n\"\n            \"\\t</ipxact:busInterfaces>\\n\"\n        \"</ipxact:component>\\n\"\n        );\n\n    ComponentWriter componentWriter;\n    componentWriter.writeComponent(xmlStreamWriter, testComponent_);\n\n    QCOMPARE(output, expectedOutput);\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_ComponentWriter::writeIndirectInterfaces()\n//-----------------------------------------------------------------------------\nvoid tst_ComponentWriter::writeIndirectInterfaces()\n{\n    VLNV componentVLNV(VLNV::COMPONENT, \"tuni.fi\", \"TestLibrary\", \"TestComponent\", \"0.11\");\n    testComponent_ = QSharedPointer<Component>(new Component(componentVLNV, Document::Revision::Std14));\n\n    QString output;\n    QXmlStreamWriter xmlStreamWriter(&output);\n\n    xmlStreamWriter.setAutoFormatting(true);\n    xmlStreamWriter.setAutoFormattingIndent(-1);\n\n    QSharedPointer<IndirectInterface> testInterface (new IndirectInterface());\n    testInterface->setName(\"testInterface\");\n    testInterface->setIndirectAddressRef(\"addr_r0\");\n    testInterface->setIndirectDataRef(\"data_r1\");\n\n    testComponent_->getIndirectInterfaces()->append(testInterface);\n\n    QString expectedOutput(\n        \"<?xml version=\\\"1.0\\\"?>\\n\"\n        \"<ipxact:component \"\n        \"xmlns:xsi=\\\"http://www.w3.org/2001/XMLSchema-instance\\\" \" \n        \"xmlns:ipxact=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014\\\" \"\n        \"xmlns:kactus2=\\\"http://kactus2.cs.tut.fi\\\" \"\n        \"xsi:schemaLocation=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014 \"\n        \"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/index.xsd\\\">\\n\"\n        \"\\t<ipxact:vendor>tuni.fi</ipxact:vendor>\\n\"\n        \"\\t<ipxact:library>TestLibrary</ipxact:library>\\n\"\n        \"\\t<ipxact:name>TestComponent</ipxact:name>\\n\"\n        \"\\t<ipxact:version>0.11</ipxact:version>\\n\"\n        \"\\t<ipxact:indirectInterfaces>\\n\"\n        \"\\t\\t<ipxact:indirectInterface>\\n\"\n        \"\\t\\t\\t<ipxact:name>testInterface</ipxact:name>\\n\"\n        \"\\t\\t\\t<ipxact:indirectAddressRef>addr_r0</ipxact:indirectAddressRef>\\n\"\n        \"\\t\\t\\t<ipxact:indirectDataRef>data_r1</ipxact:indirectDataRef>\\n\"\n        \"\\t\\t</ipxact:indirectInterface>\\n\"\n        \"\\t</ipxact:indirectInterfaces>\\n\"\n        \"</ipxact:component>\\n\"\n        );\n\n    ComponentWriter componentWriter;\n    componentWriter.writeComponent(xmlStreamWriter, testComponent_);\n\n    QCOMPARE(output, expectedOutput);\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_ComponentWriter::writeChannels()\n//-----------------------------------------------------------------------------\nvoid tst_ComponentWriter::writeChannels()\n{\n    VLNV componentVLNV(VLNV::COMPONENT, \"tuni.fi\", \"TestLibrary\", \"TestComponent\", \"0.11\");\n    testComponent_ = QSharedPointer<Component>(new Component(componentVLNV, Document::Revision::Std14));\n\n    QString output;\n    QXmlStreamWriter xmlStreamWriter(&output);\n\n    xmlStreamWriter.setAutoFormatting(true);\n    xmlStreamWriter.setAutoFormattingIndent(-1);\n\n    QStringList busInterfaceRefs;\n    busInterfaceRefs.append(\"interfaceOne\");\n    busInterfaceRefs.append(\"interfaceTwo\");\n\n    QSharedPointer<Channel> testChannel(new Channel());\n    testChannel->setName(\"testChannel\");\n    testChannel->setInterfaces(busInterfaceRefs);\n\n    testComponent_->getChannels()->append(testChannel);\n\n    QString expectedOutput(\n        \"<?xml version=\\\"1.0\\\"?>\\n\"\n        \"<ipxact:component \"\n        \"xmlns:xsi=\\\"http://www.w3.org/2001/XMLSchema-instance\\\" \" \n        \"xmlns:ipxact=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014\\\" \"\n        \"xmlns:kactus2=\\\"http://kactus2.cs.tut.fi\\\" \"\n        \"xsi:schemaLocation=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014 \"\n        \"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/index.xsd\\\">\\n\"\n        \"\\t<ipxact:vendor>tuni.fi</ipxact:vendor>\\n\"\n        \"\\t<ipxact:library>TestLibrary</ipxact:library>\\n\"\n        \"\\t<ipxact:name>TestComponent</ipxact:name>\\n\"\n        \"\\t<ipxact:version>0.11</ipxact:version>\\n\"\n        \"\\t<ipxact:channels>\\n\"\n            \"\\t\\t<ipxact:channel>\\n\"\n                \"\\t\\t\\t<ipxact:name>testChannel</ipxact:name>\\n\"\n                \"\\t\\t\\t<ipxact:busInterfaceRef>\\n\"\n                    \"\\t\\t\\t\\t<ipxact:localName>interfaceOne</ipxact:localName>\\n\"\n                \"\\t\\t\\t</ipxact:busInterfaceRef>\\n\"\n                \"\\t\\t\\t<ipxact:busInterfaceRef>\\n\"\n                    \"\\t\\t\\t\\t<ipxact:localName>interfaceTwo</ipxact:localName>\\n\"\n                \"\\t\\t\\t</ipxact:busInterfaceRef>\\n\"\n            \"\\t\\t</ipxact:channel>\\n\"\n        \"\\t</ipxact:channels>\\n\"\n        \"</ipxact:component>\\n\"\n        );\n\n    ComponentWriter componentWriter;\n    componentWriter.writeComponent(xmlStreamWriter, testComponent_);\n\n    QCOMPARE(output, expectedOutput);\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_ComponentWriter::writeRemapStates()\n//-----------------------------------------------------------------------------\nvoid tst_ComponentWriter::writeRemapStates()\n{\n    VLNV componentVLNV(VLNV::COMPONENT, \"tuni.fi\", \"TestLibrary\", \"TestComponent\", \"0.11\");\n    testComponent_ = QSharedPointer<Component>(new Component(componentVLNV, Document::Revision::Std14));\n\n    QString output;\n    QXmlStreamWriter xmlStreamWriter(&output);\n\n    xmlStreamWriter.setAutoFormatting(true);\n    xmlStreamWriter.setAutoFormattingIndent(-1);\n\n    QSharedPointer<RemapState> remapState (new RemapState(\"remap\"));\n\n    testComponent_->getRemapStates()->append(remapState);\n\n    QString expectedOutput(\n        \"<?xml version=\\\"1.0\\\"?>\\n\"\n        \"<ipxact:component \"\n        \"xmlns:xsi=\\\"http://www.w3.org/2001/XMLSchema-instance\\\" \" \n        \"xmlns:ipxact=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014\\\" \"\n        \"xmlns:kactus2=\\\"http://kactus2.cs.tut.fi\\\" \"\n        \"xsi:schemaLocation=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014 \"\n        \"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/index.xsd\\\">\\n\"\n        \"\\t<ipxact:vendor>tuni.fi</ipxact:vendor>\\n\"\n        \"\\t<ipxact:library>TestLibrary</ipxact:library>\\n\"\n        \"\\t<ipxact:name>TestComponent</ipxact:name>\\n\"\n        \"\\t<ipxact:version>0.11</ipxact:version>\\n\"\n        \"\\t<ipxact:remapStates>\\n\"\n            \"\\t\\t<ipxact:remapState>\\n\"\n                \"\\t\\t\\t<ipxact:name>remap</ipxact:name>\\n\"\n            \"\\t\\t</ipxact:remapState>\\n\"\n        \"\\t</ipxact:remapStates>\\n\"\n        \"</ipxact:component>\\n\"\n        );\n\n    ComponentWriter componentWriter;\n    componentWriter.writeComponent(xmlStreamWriter, testComponent_);\n\n    QCOMPARE(output, expectedOutput);\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_ComponentWriter::writeModes2022()\n//-----------------------------------------------------------------------------\nvoid tst_ComponentWriter::writeModes2022()\n{\n    VLNV componentVLNV(VLNV::COMPONENT, \"tuni.fi\", \"TestLibrary\", \"TestComponent\", \"0.1\");\n    testComponent_ = QSharedPointer<Component>(new Component(componentVLNV, Document::Revision::Std22));\n\n    QString output;\n    QXmlStreamWriter xmlStreamWriter(&output);\n\n    xmlStreamWriter.setAutoFormatting(true);\n    xmlStreamWriter.setAutoFormattingIndent(-1);\n\n    QSharedPointer<Mode> mode(new Mode(\"idle\"));\n\n    testComponent_->getModes()->append(mode);\n\n    QString expectedOutput(\n        \"<?xml version=\\\"1.0\\\"?>\\n\"\n        \"<ipxact:component \"\n        \"xmlns:xsi=\\\"http://www.w3.org/2001/XMLSchema-instance\\\" \" \n        \"xmlns:ipxact=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2022\\\" \"\n        \"xmlns:kactus2=\\\"http://kactus2.cs.tut.fi\\\" \"\n        \"xsi:schemaLocation=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2022 \"\n        \"http://www.accellera.org/XMLSchema/IPXACT/1685-2022/index.xsd\\\">\\n\"\n        \"\\t<ipxact:vendor>tuni.fi</ipxact:vendor>\\n\"\n        \"\\t<ipxact:library>TestLibrary</ipxact:library>\\n\"\n        \"\\t<ipxact:name>TestComponent</ipxact:name>\\n\"\n        \"\\t<ipxact:version>0.1</ipxact:version>\\n\"\n        \"\\t<ipxact:modes>\\n\"\n            \"\\t\\t<ipxact:mode>\\n\"\n                \"\\t\\t\\t<ipxact:name>idle</ipxact:name>\\n\"\n            \"\\t\\t</ipxact:mode>\\n\"\n        \"\\t</ipxact:modes>\\n\"\n        \"</ipxact:component>\\n\"\n        );\n\n    ComponentWriter componentWriter;\n    componentWriter.writeComponent(xmlStreamWriter, testComponent_);\n\n    QCOMPARE(output, expectedOutput);\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_ComponentWriter::writeAddressSpace()\n//-----------------------------------------------------------------------------\nvoid tst_ComponentWriter::writeAddressSpace()\n{\n    VLNV componentVLNV(VLNV::COMPONENT, \"tuni.fi\", \"TestLibrary\", \"TestComponent\", \"0.11\");\n    testComponent_ = QSharedPointer<Component>(new Component(componentVLNV, Document::Revision::Std14));\n\n    QString output;\n    QXmlStreamWriter xmlStreamWriter(&output);\n\n    xmlStreamWriter.setAutoFormatting(true);\n    xmlStreamWriter.setAutoFormattingIndent(-1);\n\n    QSharedPointer<AddressSpace> testAddressSpace (new AddressSpace());\n    testAddressSpace->setName(\"StarControl\");\n    testAddressSpace->setRange(\"coreward\");\n    testAddressSpace->setWidth(\"front\");\n\n    testComponent_->getAddressSpaces()->append(testAddressSpace);\n\n    QString expectedOutput(\n        \"<?xml version=\\\"1.0\\\"?>\\n\"\n        \"<ipxact:component \"\n        \"xmlns:xsi=\\\"http://www.w3.org/2001/XMLSchema-instance\\\" \" \n        \"xmlns:ipxact=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014\\\" \"\n        \"xmlns:kactus2=\\\"http://kactus2.cs.tut.fi\\\" \"\n        \"xsi:schemaLocation=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014 \"\n        \"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/index.xsd\\\">\\n\"\n            \"\\t<ipxact:vendor>tuni.fi</ipxact:vendor>\\n\"\n            \"\\t<ipxact:library>TestLibrary</ipxact:library>\\n\"\n            \"\\t<ipxact:name>TestComponent</ipxact:name>\\n\"\n            \"\\t<ipxact:version>0.11</ipxact:version>\\n\"\n            \"\\t<ipxact:addressSpaces>\\n\"\n                \"\\t\\t<ipxact:addressSpace>\\n\"\n                    \"\\t\\t\\t<ipxact:name>StarControl</ipxact:name>\\n\"\n                    \"\\t\\t\\t<ipxact:range>coreward</ipxact:range>\\n\"\n                    \"\\t\\t\\t<ipxact:width>front</ipxact:width>\\n\"\n                \"\\t\\t</ipxact:addressSpace>\\n\"\n            \"\\t</ipxact:addressSpaces>\\n\"\n        \"</ipxact:component>\\n\"\n        );\n\n    ComponentWriter componentWriter;\n    componentWriter.writeComponent(xmlStreamWriter, testComponent_);\n\n    QCOMPARE(output, expectedOutput);\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_ComponentWriter::writeMemoryMap()\n//-----------------------------------------------------------------------------\nvoid tst_ComponentWriter::writeMemoryMap()\n{\n    VLNV componentVLNV(VLNV::COMPONENT, \"tuni.fi\", \"TestLibrary\", \"TestComponent\", \"0.11\");\n    testComponent_ = QSharedPointer<Component>(new Component(componentVLNV, Document::Revision::Std14));\n\n    QString output;\n    QXmlStreamWriter xmlStreamWriter(&output);\n\n    xmlStreamWriter.setAutoFormatting(true);\n    xmlStreamWriter.setAutoFormattingIndent(-1);\n\n    QSharedPointer<MemoryMap> testMemoryMap (new MemoryMap(\"memoryMap\"));\n\n    testComponent_->getMemoryMaps()->append(testMemoryMap);\n\n    QString expectedOutput(\n        \"<?xml version=\\\"1.0\\\"?>\\n\"\n        \"<ipxact:component \"\n        \"xmlns:xsi=\\\"http://www.w3.org/2001/XMLSchema-instance\\\" \" \n        \"xmlns:ipxact=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014\\\" \"\n        \"xmlns:kactus2=\\\"http://kactus2.cs.tut.fi\\\" \"\n        \"xsi:schemaLocation=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014 \"\n        \"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/index.xsd\\\">\\n\"\n            \"\\t<ipxact:vendor>tuni.fi</ipxact:vendor>\\n\"\n            \"\\t<ipxact:library>TestLibrary</ipxact:library>\\n\"\n            \"\\t<ipxact:name>TestComponent</ipxact:name>\\n\"\n            \"\\t<ipxact:version>0.11</ipxact:version>\\n\"\n            \"\\t<ipxact:memoryMaps>\\n\"\n                \"\\t\\t<ipxact:memoryMap>\\n\"\n                    \"\\t\\t\\t<ipxact:name>memoryMap</ipxact:name>\\n\"\n                \"\\t\\t</ipxact:memoryMap>\\n\"\n            \"\\t</ipxact:memoryMaps>\\n\"\n        \"</ipxact:component>\\n\"\n        );\n\n    ComponentWriter componentWriter;\n    componentWriter.writeComponent(xmlStreamWriter, testComponent_);\n\n    QCOMPARE(output, expectedOutput);\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_ComponentWriter::writeView()\n//-----------------------------------------------------------------------------\nvoid tst_ComponentWriter::writeView()\n{\n    VLNV componentVLNV(VLNV::COMPONENT, \"tuni.fi\", \"TestLibrary\", \"TestComponent\", \"0.11\");\n    testComponent_ = QSharedPointer<Component>(new Component(componentVLNV, Document::Revision::Std14));\n\n    QString output;\n    QXmlStreamWriter xmlStreamWriter(&output);\n\n    xmlStreamWriter.setAutoFormatting(true);\n    xmlStreamWriter.setAutoFormattingIndent(-1);\n\n    QSharedPointer<View> testView (new View(\"testView\"));\n\n    testComponent_->getViews()->append(testView);\n\n    QString expectedOutput(\n        \"<?xml version=\\\"1.0\\\"?>\\n\"\n        \"<ipxact:component \"\n        \"xmlns:xsi=\\\"http://www.w3.org/2001/XMLSchema-instance\\\" \" \n        \"xmlns:ipxact=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014\\\" \"\n        \"xmlns:kactus2=\\\"http://kactus2.cs.tut.fi\\\" \"\n        \"xsi:schemaLocation=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014 \"\n        \"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/index.xsd\\\">\\n\"\n            \"\\t<ipxact:vendor>tuni.fi</ipxact:vendor>\\n\"\n            \"\\t<ipxact:library>TestLibrary</ipxact:library>\\n\"\n            \"\\t<ipxact:name>TestComponent</ipxact:name>\\n\"\n            \"\\t<ipxact:version>0.11</ipxact:version>\\n\"\n            \"\\t<ipxact:model>\\n\"\n                \"\\t\\t<ipxact:views>\\n\"\n                    \"\\t\\t\\t<ipxact:view>\\n\"\n                        \"\\t\\t\\t\\t<ipxact:name>testView</ipxact:name>\\n\"\n                    \"\\t\\t\\t</ipxact:view>\\n\"\n                \"\\t\\t</ipxact:views>\\n\"\n            \"\\t</ipxact:model>\\n\"\n        \"</ipxact:component>\\n\"\n        );\n\n    ComponentWriter componentWriter;\n    componentWriter.writeComponent(xmlStreamWriter, testComponent_);\n\n    QCOMPARE(output, expectedOutput);\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_ComponentWriter::writeComponentInstantiations()\n//-----------------------------------------------------------------------------\nvoid tst_ComponentWriter::writeInstantiations()\n{\n    VLNV componentVLNV(VLNV::COMPONENT, \"tuni.fi\", \"TestLibrary\", \"TestComponent\", \"0.11\");\n    testComponent_ = QSharedPointer<Component>(new Component(componentVLNV, Document::Revision::Std14));\n\n    QString output;\n    QXmlStreamWriter xmlStreamWriter(&output);\n\n    xmlStreamWriter.setAutoFormatting(true);\n    xmlStreamWriter.setAutoFormattingIndent(-1);\n\n    QSharedPointer<ComponentInstantiation> componentInstantiation (new ComponentInstantiation(\"component\"));\n\n    QSharedPointer<ConfigurableVLNVReference> designReference (\n        new ConfigurableVLNVReference(VLNV::DESIGN, \"tuni.fi\", \"TestLibrary\", \"designReference\", \"1.0\"));\n\n    QSharedPointer<DesignInstantiation> designInstantiation (new DesignInstantiation(\"design\"));\n    designInstantiation->setDesignReference(designReference);\n\n    QSharedPointer<ConfigurableVLNVReference> configurationReference\n        (new ConfigurableVLNVReference(VLNV::DESIGNCONFIGURATION, \"tuni.fi\", \"TestLibrary\", \"configuration\", \"8.1\"));\n\n    QSharedPointer<DesignConfigurationInstantiation> testDesignConfigurationInstantiation\n        (new DesignConfigurationInstantiation(\"designConfiguration\"));\n    testDesignConfigurationInstantiation->setDesignConfigurationReference(configurationReference);\n\n    testComponent_->getComponentInstantiations()->append(componentInstantiation);\n    testComponent_->getDesignInstantiations()->append(designInstantiation);\n    testComponent_->getDesignConfigurationInstantiations()->append(testDesignConfigurationInstantiation);\n\n    QString expectedOutput(\n        \"<?xml version=\\\"1.0\\\"?>\\n\"\n        \"<ipxact:component \"\n        \"xmlns:xsi=\\\"http://www.w3.org/2001/XMLSchema-instance\\\" \" \n        \"xmlns:ipxact=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014\\\" \"\n        \"xmlns:kactus2=\\\"http://kactus2.cs.tut.fi\\\" \"\n        \"xsi:schemaLocation=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014 \"\n        \"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/index.xsd\\\">\\n\"\n            \"\\t<ipxact:vendor>tuni.fi</ipxact:vendor>\\n\"\n            \"\\t<ipxact:library>TestLibrary</ipxact:library>\\n\"\n            \"\\t<ipxact:name>TestComponent</ipxact:name>\\n\"\n            \"\\t<ipxact:version>0.11</ipxact:version>\\n\"\n            \"\\t<ipxact:model>\\n\"\n                \"\\t\\t<ipxact:instantiations>\\n\"\n                    \"\\t\\t\\t<ipxact:componentInstantiation>\\n\"\n                        \"\\t\\t\\t\\t<ipxact:name>component</ipxact:name>\\n\"\n                    \"\\t\\t\\t</ipxact:componentInstantiation>\\n\"\n                    \"\\t\\t\\t<ipxact:designInstantiation>\\n\"\n                        \"\\t\\t\\t\\t<ipxact:name>design</ipxact:name>\\n\"\n                        \"\\t\\t\\t\\t<ipxact:designRef vendor=\\\"tuni.fi\\\" library=\\\"TestLibrary\\\"\"\n                        \" name=\\\"designReference\\\" version=\\\"1.0\\\"/>\\n\"\n                    \"\\t\\t\\t</ipxact:designInstantiation>\\n\"\n                    \"\\t\\t\\t<ipxact:designConfigurationInstantiation>\\n\"\n                        \"\\t\\t\\t\\t<ipxact:name>designConfiguration</ipxact:name>\\n\"\n                        \"\\t\\t\\t\\t<ipxact:designConfigurationRef vendor=\\\"tuni.fi\\\" library=\\\"TestLibrary\\\"\"\n                        \" name=\\\"configuration\\\" version=\\\"8.1\\\"/>\\n\"\n                    \"\\t\\t\\t</ipxact:designConfigurationInstantiation>\\n\"\n                \"\\t\\t</ipxact:instantiations>\\n\"\n            \"\\t</ipxact:model>\\n\"\n        \"</ipxact:component>\\n\"\n        );\n\n    ComponentWriter componentWriter;\n    componentWriter.writeComponent(xmlStreamWriter, testComponent_);\n\n    QCOMPARE(output, expectedOutput);\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_ComponentWriter::writePorts()\n//-----------------------------------------------------------------------------\nvoid tst_ComponentWriter::writePorts()\n{\n    VLNV componentVLNV(VLNV::COMPONENT, \"tuni.fi\", \"TestLibrary\", \"TestComponent\", \"0.11\");\n    testComponent_ = QSharedPointer<Component>(new Component(componentVLNV, Document::Revision::Std14));\n\n    QString output;\n    QXmlStreamWriter xmlStreamWriter(&output);\n\n    xmlStreamWriter.setAutoFormatting(true);\n    xmlStreamWriter.setAutoFormattingIndent(-1);\n\n    QSharedPointer<Port> testPort (new Port(\"testPort\"));\n\n    QSharedPointer<Wire> testWire(new Wire());\n    testWire->setDirection(DirectionTypes::IN);\n\n    testPort->setWire(testWire);\n\n    testComponent_->getPorts()->append(testPort);\n\n    QString expectedOutput(\n        \"<?xml version=\\\"1.0\\\"?>\\n\"\n        \"<ipxact:component \"\n        \"xmlns:xsi=\\\"http://www.w3.org/2001/XMLSchema-instance\\\" \" \n        \"xmlns:ipxact=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014\\\" \"\n        \"xmlns:kactus2=\\\"http://kactus2.cs.tut.fi\\\" \"\n        \"xsi:schemaLocation=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014 \"\n        \"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/index.xsd\\\">\\n\"\n            \"\\t<ipxact:vendor>tuni.fi</ipxact:vendor>\\n\"\n            \"\\t<ipxact:library>TestLibrary</ipxact:library>\\n\"\n            \"\\t<ipxact:name>TestComponent</ipxact:name>\\n\"\n            \"\\t<ipxact:version>0.11</ipxact:version>\\n\"\n            \"\\t<ipxact:model>\\n\"\n                \"\\t\\t<ipxact:ports>\\n\"\n                    \"\\t\\t\\t<ipxact:port>\\n\"\n                        \"\\t\\t\\t\\t<ipxact:name>testPort</ipxact:name>\\n\"\n                        \"\\t\\t\\t\\t<ipxact:wire>\\n\"\n                            \"\\t\\t\\t\\t\\t<ipxact:direction>in</ipxact:direction>\\n\"\n                        \"\\t\\t\\t\\t</ipxact:wire>\\n\"\n                    \"\\t\\t\\t</ipxact:port>\\n\"\n                \"\\t\\t</ipxact:ports>\\n\"\n            \"\\t</ipxact:model>\\n\"\n        \"</ipxact:component>\\n\"\n        );\n\n    ComponentWriter componentWriter;\n    componentWriter.writeComponent(xmlStreamWriter, testComponent_);\n\n    QCOMPARE(output, expectedOutput);\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_ComponentWriter::writeComponentGenerators()\n//-----------------------------------------------------------------------------\nvoid tst_ComponentWriter::writeComponentGenerators()\n{\n    VLNV componentVLNV(VLNV::COMPONENT, \"tuni.fi\", \"TestLibrary\", \"TestComponent\", \"0.11\");\n    testComponent_ = QSharedPointer<Component>(new Component(componentVLNV, Document::Revision::Std14));\n\n    QString output;\n    QXmlStreamWriter xmlStreamWriter(&output);\n\n    xmlStreamWriter.setAutoFormatting(true);\n    xmlStreamWriter.setAutoFormattingIndent(-1);\n\n    QSharedPointer<ComponentGenerator> testGenerator(new ComponentGenerator());\n    testGenerator->setName(\"generator\");\n    testGenerator->setGeneratorExe(\"saMatra\");\n\n    testComponent_->getComponentGenerators()->append(testGenerator);\n\n    QString expectedOutput(\n        \"<?xml version=\\\"1.0\\\"?>\\n\"\n        \"<ipxact:component \"\n        \"xmlns:xsi=\\\"http://www.w3.org/2001/XMLSchema-instance\\\" \" \n        \"xmlns:ipxact=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014\\\" \"\n        \"xmlns:kactus2=\\\"http://kactus2.cs.tut.fi\\\" \"\n        \"xsi:schemaLocation=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014 \"\n        \"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/index.xsd\\\">\\n\"\n            \"\\t<ipxact:vendor>tuni.fi</ipxact:vendor>\\n\"\n            \"\\t<ipxact:library>TestLibrary</ipxact:library>\\n\"\n            \"\\t<ipxact:name>TestComponent</ipxact:name>\\n\"\n            \"\\t<ipxact:version>0.11</ipxact:version>\\n\"\n            \"\\t<ipxact:componentGenerators>\\n\"\n                \"\\t\\t<ipxact:componentGenerator>\\n\"\n                    \"\\t\\t\\t<ipxact:name>generator</ipxact:name>\\n\"\n                    \"\\t\\t\\t<ipxact:generatorExe>saMatra</ipxact:generatorExe>\\n\"\n                \"\\t\\t</ipxact:componentGenerator>\\n\"\n            \"\\t</ipxact:componentGenerators>\\n\"\n        \"</ipxact:component>\\n\"\n        );\n\n    ComponentWriter componentWriter;\n    componentWriter.writeComponent(xmlStreamWriter, testComponent_);\n\n    QCOMPARE(output, expectedOutput);\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_ComponentWriter::writeChoices()\n//-----------------------------------------------------------------------------\nvoid tst_ComponentWriter::writeChoices()\n{\n    VLNV componentVLNV(VLNV::COMPONENT, \"tuni.fi\", \"TestLibrary\", \"TestComponent\", \"0.11\");\n    testComponent_ = QSharedPointer<Component>(new Component(componentVLNV, Document::Revision::Std14));\n\n    QString output;\n    QXmlStreamWriter xmlStreamWriter(&output);\n\n    xmlStreamWriter.setAutoFormatting(true);\n    xmlStreamWriter.setAutoFormattingIndent(-1);\n\n    QSharedPointer<Enumeration> choiceEnumeration(new Enumeration());\n    choiceEnumeration->setValue(\"14\");\n\n    QSharedPointer<Choice> testChoice (new Choice());\n    testChoice->setName(\"chosenOne\");\n    testChoice->enumerations()->append(choiceEnumeration);\n\n    testComponent_->getChoices()->append(testChoice);\n\n    QString expectedOutput(\n        \"<?xml version=\\\"1.0\\\"?>\\n\"\n        \"<ipxact:component \"\n        \"xmlns:xsi=\\\"http://www.w3.org/2001/XMLSchema-instance\\\" \" \n        \"xmlns:ipxact=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014\\\" \"\n        \"xmlns:kactus2=\\\"http://kactus2.cs.tut.fi\\\" \"\n        \"xsi:schemaLocation=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014 \"\n        \"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/index.xsd\\\">\\n\"\n            \"\\t<ipxact:vendor>tuni.fi</ipxact:vendor>\\n\"\n            \"\\t<ipxact:library>TestLibrary</ipxact:library>\\n\"\n            \"\\t<ipxact:name>TestComponent</ipxact:name>\\n\"\n            \"\\t<ipxact:version>0.11</ipxact:version>\\n\"\n            \"\\t<ipxact:choices>\\n\"\n                \"\\t\\t<ipxact:choice>\\n\"\n                    \"\\t\\t\\t<ipxact:name>chosenOne</ipxact:name>\\n\"\n                    \"\\t\\t\\t<ipxact:enumeration>14</ipxact:enumeration>\\n\"\n                \"\\t\\t</ipxact:choice>\\n\"\n            \"\\t</ipxact:choices>\\n\"\n        \"</ipxact:component>\\n\"\n        );\n\n    ComponentWriter componentWriter;\n    componentWriter.writeComponent(xmlStreamWriter, testComponent_);\n\n    QCOMPARE(output, expectedOutput);\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_ComponentWriter::writeFileSets()\n//-----------------------------------------------------------------------------\nvoid tst_ComponentWriter::writeFileSets()\n{\n    VLNV componentVLNV(VLNV::COMPONENT, \"tuni.fi\", \"TestLibrary\", \"TestComponent\", \"0.11\");\n    testComponent_ = QSharedPointer<Component>(new Component(componentVLNV, Document::Revision::Std14));\n\n    QString output;\n    QXmlStreamWriter xmlStreamWriter(&output);\n\n    xmlStreamWriter.setAutoFormatting(true);\n    xmlStreamWriter.setAutoFormattingIndent(-1);\n\n    QSharedPointer<FileSet> fileSet (new FileSet(\"urquanMasters\"));\n\n    testComponent_->getFileSets()->append(fileSet);\n\n    QString expectedOutput(\n        \"<?xml version=\\\"1.0\\\"?>\\n\"\n        \"<ipxact:component \"\n        \"xmlns:xsi=\\\"http://www.w3.org/2001/XMLSchema-instance\\\" \" \n        \"xmlns:ipxact=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014\\\" \"\n        \"xmlns:kactus2=\\\"http://kactus2.cs.tut.fi\\\" \"\n        \"xsi:schemaLocation=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014 \"\n        \"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/index.xsd\\\">\\n\"\n            \"\\t<ipxact:vendor>tuni.fi</ipxact:vendor>\\n\"\n            \"\\t<ipxact:library>TestLibrary</ipxact:library>\\n\"\n            \"\\t<ipxact:name>TestComponent</ipxact:name>\\n\"\n            \"\\t<ipxact:version>0.11</ipxact:version>\\n\"\n            \"\\t<ipxact:fileSets>\\n\"\n                \"\\t\\t<ipxact:fileSet>\\n\"\n                    \"\\t\\t\\t<ipxact:name>urquanMasters</ipxact:name>\\n\"\n                \"\\t\\t</ipxact:fileSet>\\n\"\n            \"\\t</ipxact:fileSets>\\n\"\n        \"</ipxact:component>\\n\"\n        );\n\n    ComponentWriter componentWriter;\n    componentWriter.writeComponent(xmlStreamWriter, testComponent_);\n\n    QCOMPARE(output, expectedOutput);\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_ComponentWriter::writeCPUs()\n//-----------------------------------------------------------------------------\nvoid tst_ComponentWriter::writeCPUs()\n{\n    VLNV componentVLNV(VLNV::COMPONENT, \"tuni.fi\", \"TestLibrary\", \"TestComponent\", \"0.11\");\n    testComponent_ = QSharedPointer<Component>(new Component(componentVLNV, Document::Revision::Std14));\n\n    QString output;\n    QXmlStreamWriter xmlStreamWriter(&output);\n\n    xmlStreamWriter.setAutoFormatting(true);\n    xmlStreamWriter.setAutoFormattingIndent(-1);\n\n    QSharedPointer<Cpu::AddressSpaceRef> reference (new Cpu::AddressSpaceRef(\"Avatar\"));\n\n    QSharedPointer<Cpu> testCPU (new Cpu());\n    testCPU->setName(\"Chmmr\");\n    testCPU->getAddressSpaceReferences()->append(reference);\n\n    testComponent_->getCpus()->append(testCPU);\n\n    QString expectedOutput(\n        \"<?xml version=\\\"1.0\\\"?>\\n\"\n        \"<ipxact:component \"\n        \"xmlns:xsi=\\\"http://www.w3.org/2001/XMLSchema-instance\\\" \" \n        \"xmlns:ipxact=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014\\\" \"\n        \"xmlns:kactus2=\\\"http://kactus2.cs.tut.fi\\\" \"\n        \"xsi:schemaLocation=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014 \"\n        \"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/index.xsd\\\">\\n\"\n            \"\\t<ipxact:vendor>tuni.fi</ipxact:vendor>\\n\"\n            \"\\t<ipxact:library>TestLibrary</ipxact:library>\\n\"\n            \"\\t<ipxact:name>TestComponent</ipxact:name>\\n\"\n            \"\\t<ipxact:version>0.11</ipxact:version>\\n\"\n            \"\\t<ipxact:cpus>\\n\"\n                \"\\t\\t<ipxact:cpu>\\n\"\n                    \"\\t\\t\\t<ipxact:name>Chmmr</ipxact:name>\\n\"\n                    \"\\t\\t\\t<ipxact:addressSpaceRef addressSpaceRef=\\\"Avatar\\\"/>\\n\"\n                \"\\t\\t</ipxact:cpu>\\n\"\n            \"\\t</ipxact:cpus>\\n\"\n        \"</ipxact:component>\\n\"\n        );\n\n    ComponentWriter componentWriter;\n    componentWriter.writeComponent(xmlStreamWriter, testComponent_);\n\n    QCOMPARE(output, expectedOutput);\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_ComponentWriter::writeOtherClockDrivers()\n//-----------------------------------------------------------------------------\nvoid tst_ComponentWriter::writeOtherClockDrivers()\n{\n    VLNV componentVLNV(VLNV::COMPONENT, \"tuni.fi\", \"TestLibrary\", \"TestComponent\", \"0.11\");\n    testComponent_ = QSharedPointer<Component>(new Component(componentVLNV, Document::Revision::Std14));\n\n    QString output;\n    QXmlStreamWriter xmlStreamWriter(&output);\n\n    xmlStreamWriter.setAutoFormatting(true);\n    xmlStreamWriter.setAutoFormattingIndent(-1);\n\n    QSharedPointer<ClockUnit> clockPeriod(new ClockUnit(\"watch\"));\n    QSharedPointer<ClockUnit> clockPulseOffset(new ClockUnit(\"Laser\"));\n    QSharedPointer<ClockUnit> clockPulseDuration(new ClockUnit(\"eternity\"));\n\n    QSharedPointer<OtherClockDriver> clockDriver (new OtherClockDriver());\n    clockDriver->setClockName(\"clockName\");\n    clockDriver->setClockPeriod(clockPeriod);\n    clockDriver->setClockPulseOffset(clockPulseOffset);\n    clockDriver->setClockPulseValue(\"KingOsrik\");\n    clockDriver->setClockPulseDuration(clockPulseDuration);\n\n    testComponent_->getOtherClockDrivers()->append(clockDriver);\n\n    QString expectedOutput(\n        \"<?xml version=\\\"1.0\\\"?>\\n\"\n        \"<ipxact:component \"\n        \"xmlns:xsi=\\\"http://www.w3.org/2001/XMLSchema-instance\\\" \" \n        \"xmlns:ipxact=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014\\\" \"\n        \"xmlns:kactus2=\\\"http://kactus2.cs.tut.fi\\\" \"\n        \"xsi:schemaLocation=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014 \"\n        \"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/index.xsd\\\">\\n\"\n            \"\\t<ipxact:vendor>tuni.fi</ipxact:vendor>\\n\"\n            \"\\t<ipxact:library>TestLibrary</ipxact:library>\\n\"\n            \"\\t<ipxact:name>TestComponent</ipxact:name>\\n\"\n            \"\\t<ipxact:version>0.11</ipxact:version>\\n\"\n            \"\\t<ipxact:otherClockDrivers>\\n\"\n                \"\\t\\t<ipxact:otherClockDriver clockName=\\\"clockName\\\">\\n\"\n                    \"\\t\\t\\t<ipxact:clockPeriod>watch</ipxact:clockPeriod>\\n\"\n                    \"\\t\\t\\t<ipxact:clockPulseOffset>Laser</ipxact:clockPulseOffset>\\n\"\n                    \"\\t\\t\\t<ipxact:clockPulseValue>KingOsrik</ipxact:clockPulseValue>\\n\"\n                    \"\\t\\t\\t<ipxact:clockPulseDuration>eternity</ipxact:clockPulseDuration>\\n\"\n                \"\\t\\t</ipxact:otherClockDriver>\\n\"\n            \"\\t</ipxact:otherClockDrivers>\\n\"\n        \"</ipxact:component>\\n\"\n        );\n\n    ComponentWriter componentWriter;\n    componentWriter.writeComponent(xmlStreamWriter, testComponent_);\n\n    QCOMPARE(output, expectedOutput);\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_ComponentWriter::writeResetTypes()\n//-----------------------------------------------------------------------------\nvoid tst_ComponentWriter::writeResetTypes()\n{\n    VLNV componentVLNV(VLNV::COMPONENT, \"tuni.fi\", \"TestLibrary\", \"TestComponent\", \"0.11\");\n    testComponent_ = QSharedPointer<Component>(new Component(componentVLNV, Document::Revision::Std14));\n\n    QString output;\n    QXmlStreamWriter xmlStreamWriter(&output);\n\n    xmlStreamWriter.setAutoFormatting(true);\n    xmlStreamWriter.setAutoFormattingIndent(-1);\n\n    QSharedPointer<ResetType> testResetType(new ResetType());\n    testResetType->setName(QLatin1String(\"SOFT\"));\n    testResetType->setDisplayName(QLatin1String(\"Soft Reset\"));\n    testResetType->setShortDescription(QLatin1String(\"brief\")); //!< Should not be written in XML.\n    testResetType->setDescription(QLatin1String(\"Reset the software\"));\n\n    testComponent_->getResetTypes()->append(testResetType);\n\n    QString expectedOutput(\n        \"<?xml version=\\\"1.0\\\"?>\\n\"\n        \"<ipxact:component \"\n        \"xmlns:xsi=\\\"http://www.w3.org/2001/XMLSchema-instance\\\" \"\n        \"xmlns:ipxact=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014\\\" \"\n        \"xmlns:kactus2=\\\"http://kactus2.cs.tut.fi\\\" \"\n        \"xsi:schemaLocation=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014 \"\n        \"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/index.xsd\\\">\\n\"\n            \"\\t<ipxact:vendor>tuni.fi</ipxact:vendor>\\n\"\n            \"\\t<ipxact:library>TestLibrary</ipxact:library>\\n\"\n            \"\\t<ipxact:name>TestComponent</ipxact:name>\\n\"\n            \"\\t<ipxact:version>0.11</ipxact:version>\\n\"\n            \"\\t<ipxact:resetTypes>\\n\"\n                \"\\t\\t<ipxact:resetType>\\n\"\n                    \"\\t\\t\\t<ipxact:name>SOFT</ipxact:name>\\n\"\n                    \"\\t\\t\\t<ipxact:displayName>Soft Reset</ipxact:displayName>\\n\"\n                    \"\\t\\t\\t<ipxact:description>Reset the software</ipxact:description>\\n\"\n                \"\\t\\t</ipxact:resetType>\\n\"\n            \"\\t</ipxact:resetTypes>\\n\"\n        \"</ipxact:component>\\n\"\n    );\n\n    ComponentWriter componentWriter;\n    componentWriter.writeComponent(xmlStreamWriter, testComponent_);\n\n    QCOMPARE(output, expectedOutput);\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_ComponentWriter::writeResetTypes2022()\n//-----------------------------------------------------------------------------\nvoid tst_ComponentWriter::writeResetTypes2022()\n{\n    VLNV componentVLNV(VLNV::COMPONENT, \"tuni.fi\", \"TestLibrary\", \"TestComponent\", \"0.11\");\n    testComponent_ = QSharedPointer<Component>(new Component(componentVLNV, Document::Revision::Std22));\n\n    QString output;\n    QXmlStreamWriter xmlStreamWriter(&output);\n\n    xmlStreamWriter.setAutoFormatting(true);\n    xmlStreamWriter.setAutoFormattingIndent(-1);\n\n    QSharedPointer<ResetType> testResetType(new ResetType());\n    testResetType->setName(QLatin1String(\"SOFT\"));\n    testResetType->setDisplayName(QLatin1String(\"Soft Reset\"));\n    testResetType->setShortDescription(QLatin1String(\"brief\"));\n    testResetType->setDescription(QLatin1String(\"Reset the software\"));\n\n    testComponent_->getResetTypes()->append(testResetType);\n\n    QString expectedOutput(\n        \"<?xml version=\\\"1.0\\\"?>\\n\"\n        \"<ipxact:component \"\n        \"xmlns:xsi=\\\"http://www.w3.org/2001/XMLSchema-instance\\\" \"\n        \"xmlns:ipxact=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2022\\\" \"\n        \"xmlns:kactus2=\\\"http://kactus2.cs.tut.fi\\\" \"\n        \"xsi:schemaLocation=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2022 \"\n        \"http://www.accellera.org/XMLSchema/IPXACT/1685-2022/index.xsd\\\">\\n\"\n            \"\\t<ipxact:vendor>tuni.fi</ipxact:vendor>\\n\"\n            \"\\t<ipxact:library>TestLibrary</ipxact:library>\\n\"\n            \"\\t<ipxact:name>TestComponent</ipxact:name>\\n\"\n            \"\\t<ipxact:version>0.11</ipxact:version>\\n\"\n            \"\\t<ipxact:resetTypes>\\n\"\n                \"\\t\\t<ipxact:resetType>\\n\"\n                    \"\\t\\t\\t<ipxact:name>SOFT</ipxact:name>\\n\"\n                    \"\\t\\t\\t<ipxact:displayName>Soft Reset</ipxact:displayName>\\n\"\n                    \"\\t\\t\\t<ipxact:shortDescription>brief</ipxact:shortDescription>\\n\"\n                    \"\\t\\t\\t<ipxact:description>Reset the software</ipxact:description>\\n\"\n                \"\\t\\t</ipxact:resetType>\\n\"\n            \"\\t</ipxact:resetTypes>\\n\"\n        \"</ipxact:component>\\n\"\n    );\n\n    ComponentWriter componentWriter;\n    componentWriter.writeComponent(xmlStreamWriter, testComponent_);\n\n    QCOMPARE(output, expectedOutput);\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_ComponentWriter::writeParameters()\n//-----------------------------------------------------------------------------\nvoid tst_ComponentWriter::writeParameters()\n{\n    VLNV componentVLNV(VLNV::COMPONENT, \"tuni.fi\", \"TestLibrary\", \"TestComponent\", \"0.11\");\n    testComponent_ = QSharedPointer<Component>(new Component(componentVLNV, Document::Revision::Std14));\n\n    QString output;\n    QXmlStreamWriter xmlStreamWriter(&output);\n\n    xmlStreamWriter.setAutoFormatting(true);\n    xmlStreamWriter.setAutoFormattingIndent(-1);\n\n    QSharedPointer<Parameter> testParameter(new Parameter());\n    testParameter->setValueId(\"testID\");\n    testParameter->setName(\"testParameter\");\n    testParameter->setValue(\"1\");\n\n    testComponent_->getParameters()->append(testParameter);\n\n    QString expectedOutput(\n        \"<?xml version=\\\"1.0\\\"?>\\n\"\n        \"<ipxact:component \"\n        \"xmlns:xsi=\\\"http://www.w3.org/2001/XMLSchema-instance\\\" \" \n        \"xmlns:ipxact=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014\\\" \"\n        \"xmlns:kactus2=\\\"http://kactus2.cs.tut.fi\\\" \"\n        \"xsi:schemaLocation=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014 \"\n        \"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/index.xsd\\\">\\n\"\n            \"\\t<ipxact:vendor>tuni.fi</ipxact:vendor>\\n\"\n            \"\\t<ipxact:library>TestLibrary</ipxact:library>\\n\"\n            \"\\t<ipxact:name>TestComponent</ipxact:name>\\n\"\n            \"\\t<ipxact:version>0.11</ipxact:version>\\n\"\n            \"\\t<ipxact:parameters>\\n\"\n                \"\\t\\t<ipxact:parameter parameterId=\\\"testID\\\">\\n\"\n                    \"\\t\\t\\t<ipxact:name>testParameter</ipxact:name>\\n\"\n                    \"\\t\\t\\t<ipxact:value>1</ipxact:value>\\n\"\n                \"\\t\\t</ipxact:parameter>\\n\"\n            \"\\t</ipxact:parameters>\\n\"\n        \"</ipxact:component>\\n\"\n        );\n\n    ComponentWriter componentWriter;\n    componentWriter.writeComponent(xmlStreamWriter, testComponent_);\n\n    QCOMPARE(output, expectedOutput);\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_ComponentWriter::writeAssertions()\n//-----------------------------------------------------------------------------\nvoid tst_ComponentWriter::writeAssertions()\n{\n    VLNV componentVLNV(VLNV::COMPONENT, \"tuni.fi\", \"TestLibrary\", \"TestComponent\", \"0.11\");\n    testComponent_ = QSharedPointer<Component>(new Component(componentVLNV, Document::Revision::Std14));\n\n    QString output;\n    QXmlStreamWriter xmlStreamWriter(&output);\n\n    xmlStreamWriter.setAutoFormatting(true);\n    xmlStreamWriter.setAutoFormattingIndent(-1);\n\n    QSharedPointer<Assertion> testAssertion(new Assertion());\n    testAssertion->setName(\"testAssertion\");\n    testAssertion->setDisplayName(\"assertionDisplay\");\n    testAssertion->setDescription(\"assertionDescription\");\n    testAssertion->setAssert(\"13\");\n\n    testComponent_->getAssertions()->append(testAssertion);\n\n    QString expectedOutput(\n        \"<?xml version=\\\"1.0\\\"?>\\n\"\n        \"<ipxact:component \"\n        \"xmlns:xsi=\\\"http://www.w3.org/2001/XMLSchema-instance\\\" \" \n        \"xmlns:ipxact=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014\\\" \"\n        \"xmlns:kactus2=\\\"http://kactus2.cs.tut.fi\\\" \"\n        \"xsi:schemaLocation=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014 \"\n        \"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/index.xsd\\\">\\n\"\n            \"\\t<ipxact:vendor>tuni.fi</ipxact:vendor>\\n\"\n            \"\\t<ipxact:library>TestLibrary</ipxact:library>\\n\"\n            \"\\t<ipxact:name>TestComponent</ipxact:name>\\n\"\n            \"\\t<ipxact:version>0.11</ipxact:version>\\n\"\n            \"\\t<ipxact:assertions>\\n\"\n                \"\\t\\t<ipxact:assertion>\\n\"\n                    \"\\t\\t\\t<ipxact:name>testAssertion</ipxact:name>\\n\"\n                    \"\\t\\t\\t<ipxact:displayName>assertionDisplay</ipxact:displayName>\\n\"\n                    \"\\t\\t\\t<ipxact:description>assertionDescription</ipxact:description>\\n\"\n                    \"\\t\\t\\t<ipxact:assert>13</ipxact:assert>\\n\"\n                \"\\t\\t</ipxact:assertion>\\n\"\n            \"\\t</ipxact:assertions>\\n\"\n        \"</ipxact:component>\\n\"\n        );\n\n    ComponentWriter componentWriter;\n    componentWriter.writeComponent(xmlStreamWriter, testComponent_);\n\n    QCOMPARE(output, expectedOutput);\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_ComponentWriter::writeVendorExtensions()\n//-----------------------------------------------------------------------------\nvoid tst_ComponentWriter::writeVendorExtensions()\n{\n    VLNV componentVLNV(VLNV::COMPONENT, \"tuni.fi\", \"TestLibrary\", \"TestComponent\", \"0.11\");\n    testComponent_ = QSharedPointer<Component>(new Component(componentVLNV, Document::Revision::Std14));\n\n    QString output;\n    QXmlStreamWriter xmlStreamWriter(&output);\n\n    xmlStreamWriter.setAutoFormatting(true);\n    xmlStreamWriter.setAutoFormattingIndent(-1);\n\n    QDomDocument document;\n    QDomElement extensionNode = document.createElement(\"testExtension\");\n    extensionNode.setAttribute(\"testExtensionAttribute\", \"extension\");\n    extensionNode.appendChild(document.createTextNode(\"testValue\"));\n\n    QSharedPointer<GenericVendorExtension> testExtension(new GenericVendorExtension(extensionNode));\n    testExtension->setNameSpace(QStringLiteral(\"testSpace\"));\n\n    testComponent_->getVendorExtensions()->append(testExtension);\n    testComponent_->setVersion(\"3.0.0\");\n    testComponent_->setLicense(\"testLicense\");\n\n    QString expectedOutput(\n        \"<?xml version=\\\"1.0\\\"?>\\n\"\n        \"<ipxact:component \"\n        \"xmlns:xsi=\\\"http://www.w3.org/2001/XMLSchema-instance\\\" \" \n        \"xmlns:ipxact=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014\\\" \"\n        \"xmlns:kactus2=\\\"http://kactus2.cs.tut.fi\\\" \"\n        \"xsi:schemaLocation=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014 \"\n        \"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/index.xsd\\\">\\n\"\n            \"\\t<ipxact:vendor>tuni.fi</ipxact:vendor>\\n\"\n            \"\\t<ipxact:library>TestLibrary</ipxact:library>\\n\"\n            \"\\t<ipxact:name>TestComponent</ipxact:name>\\n\"\n            \"\\t<ipxact:version>0.11</ipxact:version>\\n\"\n            \"\\t<ipxact:vendorExtensions>\\n\"\n                \"\\t\\t<testSpace:testExtension testExtensionAttribute=\\\"extension\\\">testValue</testSpace:testExtension>\\n\"\n                \"\\t\\t<kactus2:version>3.0.0</kactus2:version>\\n\"\n                \"\\t\\t<kactus2:license>testLicense</kactus2:license>\\n\"\n            \"\\t</ipxact:vendorExtensions>\\n\"\n        \"</ipxact:component>\\n\"\n        );\n\n    ComponentWriter componentWriter;\n    componentWriter.writeComponent(xmlStreamWriter, testComponent_);\n\n    QCOMPARE(output, expectedOutput);\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_ComponentWriter::writeKactusAttributes()\n//-----------------------------------------------------------------------------\nvoid tst_ComponentWriter::writeKactusAttributes()\n{\n    VLNV componentVLNV(VLNV::COMPONENT, \"tuni.fi\", \"TestLibrary\", \"TestComponent\", \"0.11\");\n    testComponent_ = QSharedPointer<Component>(new Component(componentVLNV, Document::Revision::Std14));\n\n    QString output;\n    QXmlStreamWriter xmlStreamWriter(&output);\n\n    testComponent_->setHierarchy(KactusAttribute::IP);\n    testComponent_->setImplementation(KactusAttribute::SYSTEM);\n    testComponent_->setFirmness(KactusAttribute::FIXED);\n\n    QString expectedOutput(\n        \"<?xml version=\\\"1.0\\\"?>\"\n            \"<ipxact:component \"\n            \"xmlns:xsi=\\\"http://www.w3.org/2001/XMLSchema-instance\\\" \" \n            \"xmlns:ipxact=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014\\\" \"\n            \"xmlns:kactus2=\\\"http://kactus2.cs.tut.fi\\\" \"\n            \"xsi:schemaLocation=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014 \"\n            \"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/index.xsd\\\">\"\n                \"<ipxact:vendor>tuni.fi</ipxact:vendor>\"\n                \"<ipxact:library>TestLibrary</ipxact:library>\"\n                \"<ipxact:name>TestComponent</ipxact:name>\"\n                \"<ipxact:version>0.11</ipxact:version>\"\n                \"<ipxact:vendorExtensions>\"   \n                    \"<kactus2:kts_attributes>\"\n                        \"<kactus2:kts_productHier>IP</kactus2:kts_productHier>\"\n                        \"<kactus2:kts_implementation>SYS</kactus2:kts_implementation>\"\n                        \"<kactus2:kts_firmness>Fixed</kactus2:kts_firmness>\"\n                    \"</kactus2:kts_attributes>\"\n                \"</ipxact:vendorExtensions>\"\n        \"</ipxact:component>\\n\"\n        );\n\n    ComponentWriter componentWriter;\n    componentWriter.writeComponent(xmlStreamWriter, testComponent_);\n\n    QCOMPARE(output, expectedOutput);\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_ComponentWriter::writeSwProperties()\n//-----------------------------------------------------------------------------\nvoid tst_ComponentWriter::writeSwProperties()\n{\n    VLNV componentVLNV(VLNV::COMPONENT, \"tuni.fi\", \"TestLibrary\", \"TestComponent\", \"0.11\");\n    testComponent_ = QSharedPointer<Component>(new Component(componentVLNV, Document::Revision::Std14));\n\n    QString output;\n    QXmlStreamWriter xmlStreamWriter(&output);\n\n    xmlStreamWriter.setAutoFormatting(true);\n    xmlStreamWriter.setAutoFormattingIndent(-1);\n\n    QSharedPointer<ComProperty> swProperty (new ComProperty());\n    swProperty->setName(\"Priority\");\n    swProperty->setRequired(true);\n    swProperty->setType(\"override.\");\n    swProperty->setDefaultValue(\"New behaviour\");\n    swProperty->setDescription(\"dictated\");\n\n    QList<QSharedPointer<ComProperty> > properties;\n    properties.append(swProperty);\n\n    testComponent_->setVersion(\"3.0.0\");\n    testComponent_->setSWProperties(properties);\n\n    QString expectedOutput(\n        \"<?xml version=\\\"1.0\\\"?>\\n\"\n        \"<ipxact:component \"\n        \"xmlns:xsi=\\\"http://www.w3.org/2001/XMLSchema-instance\\\" \" \n        \"xmlns:ipxact=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014\\\" \"\n        \"xmlns:kactus2=\\\"http://kactus2.cs.tut.fi\\\" \"\n        \"xsi:schemaLocation=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014 \"\n        \"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/index.xsd\\\">\\n\"\n            \"\\t<ipxact:vendor>tuni.fi</ipxact:vendor>\\n\"\n            \"\\t<ipxact:library>TestLibrary</ipxact:library>\\n\"\n            \"\\t<ipxact:name>TestComponent</ipxact:name>\\n\"\n            \"\\t<ipxact:version>0.11</ipxact:version>\\n\"\n            \"\\t<ipxact:vendorExtensions>\\n\"\n                \"\\t\\t<kactus2:version>3.0.0</kactus2:version>\\n\"\n                \"\\t\\t<kactus2:properties>\\n\"\n                    \"\\t\\t\\t<kactus2:property name=\\\"Priority\\\" required=\\\"true\\\" propertyType=\\\"override.\\\"\"\n                        \" defaultValue=\\\"New behaviour\\\" description=\\\"dictated\\\"/>\\n\"\n                \"\\t\\t</kactus2:properties>\\n\"\n            \"\\t</ipxact:vendorExtensions>\\n\"\n        \"</ipxact:component>\\n\"\n        );\n\n    ComponentWriter componentWriter;\n    componentWriter.writeComponent(xmlStreamWriter, testComponent_);\n\n    QCOMPARE(output, expectedOutput);\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_ComponentWriter::writeSystemViews()\n//-----------------------------------------------------------------------------\nvoid tst_ComponentWriter::writeSystemViews()\n{\n    VLNV componentVLNV(VLNV::COMPONENT, \"tuni.fi\", \"TestLibrary\", \"TestComponent\", \"0.11\");\n    testComponent_ = QSharedPointer<Component>(new Component(componentVLNV, Document::Revision::Std14));\n\n    QString output;\n    QXmlStreamWriter xmlStreamWriter(&output);\n\n    xmlStreamWriter.setAutoFormatting(true);\n    xmlStreamWriter.setAutoFormattingIndent(-1);\n\n    VLNV hierarchyVLNV(VLNV::COMPONENT, \"tuni.fi\", \"TestLibrary\", \"hierarchy\", \"0.3\");\n\n    QStringList fileSetReferences;\n    fileSetReferences.append(\"burn\");\n\n    QSharedPointer<SystemView> testSystem (new SystemView(\"system\"));\n    testSystem->setDisplayName(\"crash\");\n    testSystem->setDescription(\"BSOD\");\n    testSystem->setHierarchyRef(hierarchyVLNV);\n    testSystem->setHWViewRef(\"malfunction\");\n    testSystem->setFileSetRefs(fileSetReferences);\n\n    QList<QSharedPointer<SystemView> > systemViews;\n    systemViews.append(testSystem);\n\n    testComponent_->setVersion(\"3.0.0\");\n    testComponent_->setSystemViews(systemViews);\n\n    QString expectedOutput(\n        \"<?xml version=\\\"1.0\\\"?>\\n\"\n        \"<ipxact:component \"\n        \"xmlns:xsi=\\\"http://www.w3.org/2001/XMLSchema-instance\\\" \" \n        \"xmlns:ipxact=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014\\\" \"\n        \"xmlns:kactus2=\\\"http://kactus2.cs.tut.fi\\\" \"\n        \"xsi:schemaLocation=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014 \"\n        \"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/index.xsd\\\">\\n\"\n            \"\\t<ipxact:vendor>tuni.fi</ipxact:vendor>\\n\"\n            \"\\t<ipxact:library>TestLibrary</ipxact:library>\\n\"\n            \"\\t<ipxact:name>TestComponent</ipxact:name>\\n\"\n            \"\\t<ipxact:version>0.11</ipxact:version>\\n\"\n            \"\\t<ipxact:vendorExtensions>\\n\"\n                \"\\t\\t<kactus2:version>3.0.0</kactus2:version>\\n\"\n                \"\\t\\t<kactus2:systemViews>\\n\"\n                    \"\\t\\t\\t<kactus2:systemView>\\n\"\n                        \"\\t\\t\\t\\t<ipxact:name>system</ipxact:name>\\n\"\n                        \"\\t\\t\\t\\t<ipxact:displayName>crash</ipxact:displayName>\\n\"\n                        \"\\t\\t\\t\\t<ipxact:description>BSOD</ipxact:description>\\n\"\n                        \"\\t\\t\\t\\t<kactus2:hierarchyRef vendor=\\\"tuni.fi\\\" library=\\\"TestLibrary\\\" name=\\\"hierarchy\\\" \"\n                            \"version=\\\"0.3\\\"/>\\n\"\n                        \"\\t\\t\\t\\t<kactus2:hwViewRef>malfunction</kactus2:hwViewRef>\\n\"\n                        \"\\t\\t\\t\\t<kactus2:fileSetRef>burn</kactus2:fileSetRef>\\n\"\n                    \"\\t\\t\\t</kactus2:systemView>\\n\"\n                \"\\t\\t</kactus2:systemViews>\\n\"\n            \"\\t</ipxact:vendorExtensions>\\n\"\n        \"</ipxact:component>\\n\"\n        );\n\n    ComponentWriter componentWriter;\n    componentWriter.writeComponent(xmlStreamWriter, testComponent_);\n\n    QCOMPARE(output, expectedOutput);\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_ComponentWriter::writeComInterfaces()\n//-----------------------------------------------------------------------------\nvoid tst_ComponentWriter::writeComInterfaces()\n{\n    VLNV componentVLNV(VLNV::COMPONENT, \"tuni.fi\", \"TestLibrary\", \"TestComponent\", \"0.11\");\n    testComponent_ = QSharedPointer<Component>(new Component(componentVLNV, Document::Revision::Std14));\n\n    QString output;\n    QXmlStreamWriter xmlStreamWriter(&output);\n\n    xmlStreamWriter.setAutoFormatting(true);\n    xmlStreamWriter.setAutoFormattingIndent(-1);\n\n    VLNV hierarchyVLNV(VLNV::COMPONENT, \"tuni.fi\", \"TestLibrary\", \"hierarchy\", \"0.3\");\n\n    QMap<QString, QString> propertyValues;\n    propertyValues.insert(\"spathi\", \"eluder\");\n\n    QSharedPointer<ComInterface> testComInterface (new ComInterface());\n    testComInterface->setName(\"coms\");\n    testComInterface->setDisplayName(\"spec\");\n    testComInterface->setDescription(\"ops\");\n    testComInterface->setComType(hierarchyVLNV);\n    testComInterface->setTransferType(\"Transfer\");\n    testComInterface->setDirection(DirectionTypes::IN);\n    testComInterface->setPropertyValues(propertyValues);\n    testComInterface->setComImplementation(hierarchyVLNV);\n\n    QList<QSharedPointer<ComInterface> > comInterfaces;\n    comInterfaces.append(testComInterface);\n\n    testComponent_->setVersion(\"3.0.0\");\n    testComponent_->setComInterfaces(comInterfaces);\n\n    QString expectedOutput(\n        \"<?xml version=\\\"1.0\\\"?>\\n\"\n        \"<ipxact:component \"\n        \"xmlns:xsi=\\\"http://www.w3.org/2001/XMLSchema-instance\\\" \" \n        \"xmlns:ipxact=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014\\\" \"\n        \"xmlns:kactus2=\\\"http://kactus2.cs.tut.fi\\\" \"\n        \"xsi:schemaLocation=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014 \"\n        \"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/index.xsd\\\">\\n\"\n            \"\\t<ipxact:vendor>tuni.fi</ipxact:vendor>\\n\"\n            \"\\t<ipxact:library>TestLibrary</ipxact:library>\\n\"\n            \"\\t<ipxact:name>TestComponent</ipxact:name>\\n\"\n            \"\\t<ipxact:version>0.11</ipxact:version>\\n\"\n            \"\\t<ipxact:vendorExtensions>\\n\"\n                \"\\t\\t<kactus2:version>3.0.0</kactus2:version>\\n\"\n                \"\\t\\t<kactus2:comInterfaces>\\n\"\n                    \"\\t\\t\\t<kactus2:comInterface>\\n\"\n                        \"\\t\\t\\t\\t<ipxact:name>coms</ipxact:name>\\n\"\n                        \"\\t\\t\\t\\t<ipxact:displayName>spec</ipxact:displayName>\\n\"\n                        \"\\t\\t\\t\\t<ipxact:description>ops</ipxact:description>\\n\"\n                        \"\\t\\t\\t\\t<kactus2:comType vendor=\\\"tuni.fi\\\" library=\\\"TestLibrary\\\" name=\\\"hierarchy\\\" \"\n                            \"version=\\\"0.3\\\"/>\\n\"\n                        \"\\t\\t\\t\\t<kactus2:transferType>Transfer</kactus2:transferType>\\n\"\n                        \"\\t\\t\\t\\t<kactus2:comDirection>in</kactus2:comDirection>\\n\"\n                        \"\\t\\t\\t\\t<kactus2:propertyValues>\\n\"\n                            \"\\t\\t\\t\\t\\t<kactus2:propertyValue name=\\\"spathi\\\" value=\\\"eluder\\\"/>\\n\"\n                        \"\\t\\t\\t\\t</kactus2:propertyValues>\\n\"\n                        \"\\t\\t\\t\\t<kactus2:comImplementationRef vendor=\\\"tuni.fi\\\" library=\\\"TestLibrary\\\" \"\n                            \"name=\\\"hierarchy\\\" version=\\\"0.3\\\"/>\\n\"\n                    \"\\t\\t\\t</kactus2:comInterface>\\n\"\n                \"\\t\\t</kactus2:comInterfaces>\\n\"\n            \"\\t</ipxact:vendorExtensions>\\n\"\n        \"</ipxact:component>\\n\"\n        );\n\n    ComponentWriter componentWriter;\n    componentWriter.writeComponent(xmlStreamWriter, testComponent_);\n\n    QCOMPARE(output, expectedOutput);\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_ComponentWriter::writeApiInterfaces()\n//-----------------------------------------------------------------------------\nvoid tst_ComponentWriter::writeApiInterfaces()\n{\n    VLNV componentVLNV(VLNV::COMPONENT, \"tuni.fi\", \"TestLibrary\", \"TestComponent\", \"0.11\");\n    testComponent_ = QSharedPointer<Component>(new Component(componentVLNV, Document::Revision::Std14));\n\n    QString output;\n    QXmlStreamWriter xmlStreamWriter(&output);\n\n    xmlStreamWriter.setAutoFormatting(true);\n    xmlStreamWriter.setAutoFormattingIndent(-1);\n\n    VLNV hierarchyVLNV(VLNV::COMPONENT, \"tuni.fi\", \"TestLibrary\", \"hierarchy\", \"0.3\");\n\n    QSharedPointer<ApiInterface> testApiInterface (new ApiInterface());\n    testApiInterface->setName(\"api\");\n    testApiInterface->setApiType(hierarchyVLNV);\n\n\n    QList<QSharedPointer<ApiInterface> > apiInterfaces;\n    apiInterfaces.append(testApiInterface);\n\n    testComponent_->setVersion(\"3.0.0\");\n    testComponent_->setApiInterfaces(apiInterfaces);\n\n    QString expectedOutput(\n        \"<?xml version=\\\"1.0\\\"?>\\n\"\n        \"<ipxact:component \"\n        \"xmlns:xsi=\\\"http://www.w3.org/2001/XMLSchema-instance\\\" \" \n        \"xmlns:ipxact=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014\\\" \"\n        \"xmlns:kactus2=\\\"http://kactus2.cs.tut.fi\\\" \"\n        \"xsi:schemaLocation=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014 \"\n        \"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/index.xsd\\\">\\n\"\n            \"\\t<ipxact:vendor>tuni.fi</ipxact:vendor>\\n\"\n            \"\\t<ipxact:library>TestLibrary</ipxact:library>\\n\"\n            \"\\t<ipxact:name>TestComponent</ipxact:name>\\n\"\n            \"\\t<ipxact:version>0.11</ipxact:version>\\n\"\n            \"\\t<ipxact:vendorExtensions>\\n\"\n                \"\\t\\t<kactus2:version>3.0.0</kactus2:version>\\n\"\n                \"\\t\\t<kactus2:apiInterfaces>\\n\"\n                    \"\\t\\t\\t<kactus2:apiInterface>\\n\"\n                        \"\\t\\t\\t\\t<ipxact:name>api</ipxact:name>\\n\"\n                        \"\\t\\t\\t\\t<kactus2:apiType vendor=\\\"tuni.fi\\\" library=\\\"TestLibrary\\\" name=\\\"hierarchy\\\" \"\n                            \"version=\\\"0.3\\\"/>\\n\"\n                        \"\\t\\t\\t\\t<kactus2:dependencyDirection>provider</kactus2:dependencyDirection>\\n\"\n                    \"\\t\\t\\t</kactus2:apiInterface>\\n\"\n               \"\\t\\t</kactus2:apiInterfaces>\\n\"\n            \"\\t</ipxact:vendorExtensions>\\n\"\n        \"</ipxact:component>\\n\"\n        );\n\n    ComponentWriter componentWriter;\n    componentWriter.writeComponent(xmlStreamWriter, testComponent_);\n\n    QCOMPARE(output, expectedOutput);\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_ComponentWriter::writeFileDependencies()\n//-----------------------------------------------------------------------------\nvoid tst_ComponentWriter::writeFileDependencies()\n{\n    VLNV componentVLNV(VLNV::COMPONENT, \"tuni.fi\", \"TestLibrary\", \"TestComponent\", \"0.11\");\n    testComponent_ = QSharedPointer<Component>(new Component(componentVLNV, Document::Revision::Std14));\n\n    QString output;\n    QXmlStreamWriter xmlStreamWriter(&output);\n\n    xmlStreamWriter.setAutoFormatting(true);\n    xmlStreamWriter.setAutoFormattingIndent(-1);\n\n    QSharedPointer<FileDependency> pendingDependency (new FileDependency());\n    pendingDependency->setManual(true);\n    pendingDependency->setBidirectional(true);\n    pendingDependency->setLocked(false);\n    pendingDependency->setFile1(\"super\");\n    pendingDependency->setFile2(\"melee\");\n    pendingDependency->setDescription(\"Immediately obvious to the most casual observer\");\n\n    QList<QSharedPointer<FileDependency> > fileDependencies;\n    fileDependencies.append(pendingDependency);\n\n    testComponent_->setVersion(\"3.0.0\");\n    testComponent_->setPendingFileDependencies(fileDependencies);\n\n    QString expectedOutput(\n        \"<?xml version=\\\"1.0\\\"?>\\n\"\n        \"<ipxact:component \"\n        \"xmlns:xsi=\\\"http://www.w3.org/2001/XMLSchema-instance\\\" \" \n        \"xmlns:ipxact=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014\\\" \"\n        \"xmlns:kactus2=\\\"http://kactus2.cs.tut.fi\\\" \"\n        \"xsi:schemaLocation=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014 \"\n        \"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/index.xsd\\\">\\n\"\n            \"\\t<ipxact:vendor>tuni.fi</ipxact:vendor>\\n\"\n            \"\\t<ipxact:library>TestLibrary</ipxact:library>\\n\"\n            \"\\t<ipxact:name>TestComponent</ipxact:name>\\n\"\n            \"\\t<ipxact:version>0.11</ipxact:version>\\n\"\n            \"\\t<ipxact:vendorExtensions>\\n\"\n                \"\\t\\t<kactus2:version>3.0.0</kactus2:version>\\n\"\n                \"\\t\\t<kactus2:fileDependencies>\\n\"\n                    \"\\t\\t\\t<kactus2:fileDependency manual=\\\"true\\\" bidirectional=\\\"true\\\" locked=\\\"false\\\">\\n\"\n                        \"\\t\\t\\t\\t<kactus2:fileRef1>super</kactus2:fileRef1>\\n\"\n                        \"\\t\\t\\t\\t<kactus2:fileRef2>melee</kactus2:fileRef2>\\n\"\n                        \"\\t\\t\\t\\t<ipxact:description>Immediately obvious to the most casual observer\"\n                            \"</ipxact:description>\\n\"\n                    \"\\t\\t\\t</kactus2:fileDependency>\\n\"\n                \"\\t\\t</kactus2:fileDependencies>\\n\"\n            \"\\t</ipxact:vendorExtensions>\\n\"\n        \"</ipxact:component>\\n\"\n        );\n\n    ComponentWriter componentWriter;\n    componentWriter.writeComponent(xmlStreamWriter, testComponent_);\n\n    QCOMPARE(output, expectedOutput);\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_ComponentWriter::writeTags()\n//-----------------------------------------------------------------------------\nvoid tst_ComponentWriter::writeTags()\n{\n    VLNV componentVLNV(VLNV::COMPONENT, \"tuni.fi\", \"TestLibrary\", \"TestComponent\", \"0.11\");\n    testComponent_ = QSharedPointer<Component>(new Component(componentVLNV, Document::Revision::Std14));\n\n    QString output;\n    QXmlStreamWriter xmlStreamWriter(&output);\n\n    xmlStreamWriter.setAutoFormatting(true);\n    xmlStreamWriter.setAutoFormattingIndent(-1);\n\n    TagData newTag1({ QStringLiteral(\"Kohr-ah\"), QStringLiteral(\"#FFFFFF\") });\n    TagData newTag2({ QStringLiteral(\"Kzer-za\"), QStringLiteral(\"#54D66F\") });\n    QVector<TagData> componentTags({ newTag1, newTag2 });\n\n    testComponent_->setVersion(\"3.0.0\");\n    testComponent_->setTags(componentTags);\n\n    QString expectedOutput(\n        \"<?xml version=\\\"1.0\\\"?>\\n\"\n        \"<ipxact:component \"\n        \"xmlns:xsi=\\\"http://www.w3.org/2001/XMLSchema-instance\\\" \"\n        \"xmlns:ipxact=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014\\\" \"\n        \"xmlns:kactus2=\\\"http://kactus2.cs.tut.fi\\\" \"\n        \"xsi:schemaLocation=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014 \"\n        \"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/index.xsd\\\">\\n\"\n            \"\\t<ipxact:vendor>tuni.fi</ipxact:vendor>\\n\"\n            \"\\t<ipxact:library>TestLibrary</ipxact:library>\\n\"\n            \"\\t<ipxact:name>TestComponent</ipxact:name>\\n\"\n            \"\\t<ipxact:version>0.11</ipxact:version>\\n\"\n            \"\\t<ipxact:vendorExtensions>\\n\"\n                \"\\t\\t<kactus2:version>3.0.0</kactus2:version>\\n\"\n                \"\\t\\t<kactus2:tags>\\n\"\n                    \"\\t\\t\\t<kactus2:tag>\\n\"\n                        \"\\t\\t\\t\\t<kactus2:name>Kohr-ah</kactus2:name>\\n\"\n                        \"\\t\\t\\t\\t<kactus2:color>#FFFFFF</kactus2:color>\\n\"\n                    \"\\t\\t\\t</kactus2:tag>\\n\"\n                    \"\\t\\t\\t<kactus2:tag>\\n\"\n                        \"\\t\\t\\t\\t<kactus2:name>Kzer-za</kactus2:name>\\n\"\n                        \"\\t\\t\\t\\t<kactus2:color>#54D66F</kactus2:color>\\n\"\n                    \"\\t\\t\\t</kactus2:tag>\\n\"\n                \"\\t\\t</kactus2:tags>\\n\"\n            \"\\t</ipxact:vendorExtensions>\\n\"\n        \"</ipxact:component>\\n\"\n    );\n\n    ComponentWriter componentWriter;\n    componentWriter.writeComponent(xmlStreamWriter, testComponent_);\n\n    QCOMPARE(output, expectedOutput);\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_ComponentWriter::writeErasedTags()\n//-----------------------------------------------------------------------------\nvoid tst_ComponentWriter::writeErasedTags()\n{\n    VLNV componentVLNV(VLNV::COMPONENT, \"tuni.fi\", \"TestLibrary\", \"TestComponent\", \"0.11\");\n    testComponent_ = QSharedPointer<Component>(new Component(componentVLNV, Document::Revision::Std14));\n\n    QString output;\n    QXmlStreamWriter xmlStreamWriter(&output);\n\n    xmlStreamWriter.setAutoFormatting(true);\n    xmlStreamWriter.setAutoFormattingIndent(-1);\n\n    TagData newTag1({ QStringLiteral(\"Kohr-ah\") , QStringLiteral(\"#FFFFFF\") });\n    TagData newTag2({ QStringLiteral(\"Kzer-za\") , QStringLiteral(\"#54D66F\") });\n    QVector<TagData> componentTags({ newTag1, newTag2 });\n\n    testComponent_->setVersion(\"3.0.0\");\n    testComponent_->setTags(componentTags);\n\n    componentTags.removeLast();\n    testComponent_->setTags(componentTags);\n\n    QString expectedOutput(\n        \"<?xml version=\\\"1.0\\\"?>\\n\"\n        \"<ipxact:component \"\n        \"xmlns:xsi=\\\"http://www.w3.org/2001/XMLSchema-instance\\\" \"\n        \"xmlns:ipxact=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014\\\" \"\n        \"xmlns:kactus2=\\\"http://kactus2.cs.tut.fi\\\" \"\n        \"xsi:schemaLocation=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014 \"\n        \"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/index.xsd\\\">\\n\"\n            \"\\t<ipxact:vendor>tuni.fi</ipxact:vendor>\\n\"\n            \"\\t<ipxact:library>TestLibrary</ipxact:library>\\n\"\n            \"\\t<ipxact:name>TestComponent</ipxact:name>\\n\"\n            \"\\t<ipxact:version>0.11</ipxact:version>\\n\"\n            \"\\t<ipxact:vendorExtensions>\\n\"\n                \"\\t\\t<kactus2:version>3.0.0</kactus2:version>\\n\"\n                \"\\t\\t<kactus2:tags>\\n\"\n                    \"\\t\\t\\t<kactus2:tag>\\n\"\n                        \"\\t\\t\\t\\t<kactus2:name>Kohr-ah</kactus2:name>\\n\"\n                        \"\\t\\t\\t\\t<kactus2:color>#FFFFFF</kactus2:color>\\n\"\n                    \"\\t\\t\\t</kactus2:tag>\\n\"\n                \"\\t\\t</kactus2:tags>\\n\"\n            \"\\t</ipxact:vendorExtensions>\\n\"\n        \"</ipxact:component>\\n\"\n    );\n\n    ComponentWriter componentWriter;\n    componentWriter.writeComponent(xmlStreamWriter, testComponent_);\n\n    QCOMPARE(output, expectedOutput);\n}\n\nQTEST_APPLESS_MAIN(tst_ComponentWriter)\n\n#include \"tst_ComponentWriter.moc\"\n"
  },
  {
    "path": "tests/IPXACTmodels/Component/tst_ComponentWriter.pri",
    "content": "# ----------------------------------------------------\r\n# This file is generated by the Qt Visual Studio Tools.\r\n# ------------------------------------------------------\r\n\r\nSOURCES += ./tst_ComponentWriter.cpp\r\n"
  },
  {
    "path": "tests/IPXACTmodels/Component/tst_ComponentWriter.pro",
    "content": "#-----------------------------------------------------------------------------\r\n# File: tst_ComponentWriter.pro\r\n#-----------------------------------------------------------------------------\r\n# Project: Kactus 2\r\n# Author: Mikko Teuho\r\n# Date: 06.10.2015\r\n#\r\n# Description:\r\n# Qt project file template for running unit tests for ComponentWriter.\r\n#-----------------------------------------------------------------------------\r\n\r\nTEMPLATE = app\r\n\r\nTARGET = tst_ComponentWriter\r\n\r\nQT += core xml testlib\r\nQT -= gui\r\n\r\nCONFIG += c++11 testcase console\r\n\r\nlinux-g++ | linux-g++-64 | linux-g++-32 {\r\n LIBS += -L../../../executable \\\r\n     -lIPXACTmodels\r\n\r\n}\r\nwin64 | win32 {\r\n LIBS += -L../../../executable \\\r\n     -lIPXACTmodelsd\r\n}\r\n\r\nINCLUDEPATH += $$DESTDIR\r\nINCLUDEPATH += ../../../\r\n\r\nDEPENDPATH += .\r\nDEPENDPATH += ../../../\r\n\r\nOBJECTS_DIR += $$DESTDIR\r\n\r\nMOC_DIR += ./generatedFiles\r\nUI_DIR += ./generatedFiles\r\nRCC_DIR += ./generatedFiles\r\ninclude(tst_ComponentWriter.pri)\r\n"
  },
  {
    "path": "tests/IPXACTmodels/Component/tst_EnumeratedValueReader.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: tst_EnumeratedValueReader.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 23.09.2015\r\n//\r\n// Description:\r\n// Unit test for class EnumeratedValueReader.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include <IPXACTmodels/Component/EnumeratedValueReader.h>\r\n#include <IPXACTmodels/Component/EnumeratedValue.h>\r\n\r\n#include <IPXACTmodels/common/GenericVendorExtension.h>\r\n\r\n#include <QtTest>\r\n\r\nclass tst_EnumeratedValueReader : public QObject\r\n{\r\n    Q_OBJECT\r\n\r\npublic:\r\n    tst_EnumeratedValueReader();\r\n\r\nprivate slots:\r\n\r\n    void readSimpleEnumeratedValue();\r\n    void readUsage();\r\n    void readVendorExtensions();\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_EnumeratedValueReader::tst_EnumeratedValueReader()\r\n//-----------------------------------------------------------------------------\r\ntst_EnumeratedValueReader::tst_EnumeratedValueReader()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_EnumeratedValueReader::readSimpleEnumeratedValue()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_EnumeratedValueReader::readSimpleEnumeratedValue()\r\n{\r\n    QString documentContent(\r\n        \"<ipxact:enumeratedValue>\"\r\n            \"<ipxact:name>testEnumeration</ipxact:name>\"\r\n            \"<ipxact:displayName>enumDisplay</ipxact:displayName>\"\r\n            \"<ipxact:description>enumDescription</ipxact:description>\"\r\n            \"<ipxact:value>testValue</ipxact:value>\"\r\n        \"</ipxact:enumeratedValue>\"\r\n        );\r\n\r\n    QDomDocument document;\r\n    document.setContent(documentContent);\r\n\r\n    QDomNode enumeratedValueNode = document.firstChildElement(\"ipxact:enumeratedValue\");\r\n\r\n    EnumeratedValueReader enumeratedValueReader;\r\n    QSharedPointer<EnumeratedValue> enumeratedValue =\r\n        enumeratedValueReader.createEnumeratedValueFrom(enumeratedValueNode);\r\n\r\n    QCOMPARE(enumeratedValue->name(), QString(\"testEnumeration\"));\r\n    QCOMPARE(enumeratedValue->displayName(), QString(\"enumDisplay\"));\r\n    QCOMPARE(enumeratedValue->description(), QString(\"enumDescription\"));\r\n    QCOMPARE(enumeratedValue->getValue(), QString(\"testValue\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_EnumeratedValueReader::readUsage()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_EnumeratedValueReader::readUsage()\r\n{\r\n    QString documentContent(\r\n        \"<ipxact:enumeratedValue usage=\\\"write\\\">\"\r\n            \"<ipxact:name>testEnumeration</ipxact:name>\"\r\n            \"<ipxact:value>testValue</ipxact:value>\"\r\n        \"</ipxact:enumeratedValue>\"\r\n        );\r\n\r\n    QDomDocument document;\r\n    document.setContent(documentContent);\r\n\r\n    QDomNode enumeratedValueNode = document.firstChildElement(\"ipxact:enumeratedValue\");\r\n\r\n    EnumeratedValueReader enumeratedValueReader;\r\n    QSharedPointer<EnumeratedValue> enumeratedValue =\r\n        enumeratedValueReader.createEnumeratedValueFrom(enumeratedValueNode);\r\n\r\n    QCOMPARE(enumeratedValue->name(), QString(\"testEnumeration\"));\r\n    QCOMPARE(enumeratedValue->getValue(), QString(\"testValue\"));\r\n    QCOMPARE(enumeratedValue->getUsage(), EnumeratedValue::WRITE);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_EnumeratedValueReader::readVendorExtensions()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_EnumeratedValueReader::readVendorExtensions()\r\n{\r\n    QString documentContent(\r\n        \"<ipxact:enumeratedValue>\"\r\n            \"<ipxact:name>testEnumeration</ipxact:name>\"\r\n            \"<ipxact:value>testValue</ipxact:value>\"\r\n            \"<ipxact:vendorExtensions>\"\r\n                \"<testExtension testExtensionAttribute=\\\"extension\\\">testValue</testExtension>\"\r\n            \"</ipxact:vendorExtensions>\"\r\n        \"</ipxact:enumeratedValue>\"\r\n        );\r\n\r\n    QDomDocument document;\r\n    document.setContent(documentContent);\r\n\r\n    QDomNode enumeratedValueNode = document.firstChildElement(\"ipxact:enumeratedValue\");\r\n\r\n    EnumeratedValueReader enumeratedValueReader;\r\n    QSharedPointer<EnumeratedValue> enumeratedValue =\r\n        enumeratedValueReader.createEnumeratedValueFrom(enumeratedValueNode);\r\n\r\n    QCOMPARE(enumeratedValue->name(), QString(\"testEnumeration\"));\r\n    QCOMPARE(enumeratedValue->getValue(), QString(\"testValue\"));\r\n    QCOMPARE(enumeratedValue->getVendorExtensions()->size(), 1);\r\n    QCOMPARE(enumeratedValue->getVendorExtensions()->first()->type(), QString(\"testExtension\"));\r\n}\r\n\r\nQTEST_APPLESS_MAIN(tst_EnumeratedValueReader)\r\n\r\n#include \"tst_EnumeratedValueReader.moc\"\r\n"
  },
  {
    "path": "tests/IPXACTmodels/Component/tst_EnumeratedValueReader.pri",
    "content": "# ----------------------------------------------------\r\n# This file is generated by the Qt Visual Studio Tools.\r\n# ------------------------------------------------------\r\n\r\nSOURCES += ./tst_EnumeratedValueReader.cpp "
  },
  {
    "path": "tests/IPXACTmodels/Component/tst_EnumeratedValueReader.pro",
    "content": "#-----------------------------------------------------------------------------\r\n# File: tst_EnumeratedValueReader.pro\r\n#-----------------------------------------------------------------------------\r\n# Project: Kactus 2\r\n# Author: Mikko Teuho\r\n# Date: 23.09.2015\r\n#\r\n# Description:\r\n# Qt project file template for running unit tests for EnumeratedValueReader.\r\n#-----------------------------------------------------------------------------\r\n\r\nTEMPLATE = app\r\n\r\nTARGET = tst_EnumeratedValueReader\r\n\r\nQT += core xml testlib\r\nQT -= gui\r\n\r\nCONFIG += c++11 testcase console\r\n\r\nlinux-g++ | linux-g++-64 | linux-g++-32 {\r\n LIBS += -L../../../executable \\\r\n     -lIPXACTmodels\r\n\r\n}\r\nwin64 | win32 {\r\n LIBS += -L../../../x64/executable \\\r\n     -lIPXACTmodelsd\r\n}\r\n\r\nINCLUDEPATH += $$DESTDIR\r\nINCLUDEPATH += ../../../\r\n\r\nDEPENDPATH += .\r\nDEPENDPATH += ../../../\r\n\r\nOBJECTS_DIR += $$DESTDIR\r\n\r\nMOC_DIR += ./generatedFiles\r\nUI_DIR += ./generatedFiles\r\nRCC_DIR += ./generatedFiles\r\ninclude(tst_EnumeratedValueReader.pri)\r\n"
  },
  {
    "path": "tests/IPXACTmodels/Component/tst_EnumeratedValueValidator.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: tst_EnumeratedValueValidator.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 17.11.2015\r\n//\r\n// Description:\r\n// Unit test for class EnumeratedValueValidator.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include <IPXACTmodels/Component/validators/EnumeratedValueValidator.h>\r\n#include <IPXACTmodels/Component/EnumeratedValue.h>\r\n\r\n#include <KactusAPI/include/SystemVerilogExpressionParser.h>\r\n\r\n#include <QtTest>\r\n\r\nclass tst_EnumeratedValueValidator : public QObject\r\n{\r\n    Q_OBJECT\r\n\r\npublic:\r\n    tst_EnumeratedValueValidator();\r\n\r\nprivate slots:\r\n\r\n    void testNameIsValid();\r\n    void testNameIsValid_data();\r\n\r\n    void testValueIsValid();\r\n    void testValueIsValid_data();\r\n\r\nprivate:\r\n\r\n    bool errorIsNotFoundInErrorList(QString const& expectedError, QVector<QString> errorList);\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_EnumeratedValueValidator::tst_EnumeratedValueValidator()\r\n//-----------------------------------------------------------------------------\r\ntst_EnumeratedValueValidator::tst_EnumeratedValueValidator()\r\n{\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_EnumeratedValueValidator::()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_EnumeratedValueValidator::testNameIsValid()\r\n{\r\n    QFETCH(QString, name);\r\n    QFETCH(QString, value);\r\n    QFETCH(bool, isValid);\r\n\r\n    QSharedPointer<EnumeratedValue> enumeratedValue (new EnumeratedValue(name, value));\r\n\r\n    QSharedPointer<ExpressionParser> parser(new SystemVerilogExpressionParser());\r\n\r\n    EnumeratedValueValidator validator(parser);\r\n    QCOMPARE(validator.validate(enumeratedValue), isValid);\r\n\r\n    if (!isValid)\r\n    {\r\n        QVector<QString> foundErrors;\r\n        validator.findErrorsIn(foundErrors, enumeratedValue, \"test\");\r\n\r\n        QString expectedError =\r\n            QObject::tr(\"Invalid name specified for %1 within %2\").arg(enumeratedValue->name(), \"test\");\r\n        if (errorIsNotFoundInErrorList(expectedError, foundErrors))\r\n        {\r\n            QFAIL(\"No error message found\");\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_EnumeratedValueValidator::testUsageIsValid_data()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_EnumeratedValueValidator::testNameIsValid_data()\r\n{\r\n    QTest::addColumn<QString>(\"name\");\r\n    QTest::addColumn<QString>(\"value\");\r\n    QTest::addColumn<bool>(\"isValid\");\r\n\r\n    QTest::newRow(\"Name test is valid for enumerated value\") << \"test\" << \"1\" << true;\r\n    QTest::newRow(\"Empty name is invalid for enumerated value\") << \"\" << \"1\" << false;\r\n    QTest::newRow(\"Name consisting of only white spaces is invalid for enumerated value\") << \"    \" << \"1\" << false;\r\n    QTest::newRow(\"Name consisting of characters and white spaces is valid.\") << \"  test  \" << \"1\" << true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_EnumeratedValueValidator::testValueIsValid()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_EnumeratedValueValidator::testValueIsValid()\r\n{\r\n    QFETCH(QString, value);\r\n    QFETCH(bool, isValid);\r\n\r\n    QSharedPointer<EnumeratedValue> enumeratedValue (new EnumeratedValue(\"test\", value));\r\n\r\n    QSharedPointer<ExpressionParser> parser(new SystemVerilogExpressionParser());\r\n\r\n    EnumeratedValueValidator validator(parser);\r\n    QCOMPARE(validator.hasValidValue(enumeratedValue), isValid);\r\n\r\n    if (!isValid)\r\n    {\r\n        QVector<QString> foundErrors;\r\n        validator.findErrorsIn(foundErrors, enumeratedValue, \"test\");\r\n\r\n        QString expectedError = QObject::tr(\"Invalid value %1 set for enumerated value %2 within test\").\r\n            arg(enumeratedValue->getValue()).arg(enumeratedValue->name());\r\n\r\n        if (errorIsNotFoundInErrorList(expectedError, foundErrors))\r\n        {\r\n            QFAIL(\"No error message found\");\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_EnumeratedValueValidator::testValueIsValid_data()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_EnumeratedValueValidator::testValueIsValid_data()\r\n{\r\n    QTest::addColumn<QString>(\"value\");\r\n    QTest::addColumn<bool>(\"isValid\");\r\n\r\n    QTest::newRow(\"Empty value is invalid.\") << \"\" << false;\r\n    QTest::newRow(\"Value 1 is valid.\") << \"1\" << true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_EnumeratedValueValidator::errorIsNotFoundInErrorList()\r\n//-----------------------------------------------------------------------------\r\nbool tst_EnumeratedValueValidator::errorIsNotFoundInErrorList(QString const& expectedError,\r\n    QVector<QString> errorList)\r\n{\r\n    if (!errorList.contains(expectedError))\r\n    {\r\n        qDebug() << \"The following error:\" << Qt::endl << expectedError << Qt::endl << \"was not found in errorlist:\";\r\n        for (QString const& error : errorList)\r\n        {\r\n            qDebug() << error; \r\n        }\r\n        return true;\r\n    }\r\n\r\n    return false;\r\n}\r\n\r\nQTEST_APPLESS_MAIN(tst_EnumeratedValueValidator)\r\n\r\n#include \"tst_EnumeratedValueValidator.moc\"\r\n"
  },
  {
    "path": "tests/IPXACTmodels/Component/tst_EnumeratedValueValidator.pri",
    "content": "# ----------------------------------------------------\r\n# This file is generated by the Qt Visual Studio Tools.\r\n# ------------------------------------------------------\r\n\r\nSOURCES += ./tst_EnumeratedValueValidator.cpp "
  },
  {
    "path": "tests/IPXACTmodels/Component/tst_EnumeratedValueValidator.pro",
    "content": "#-----------------------------------------------------------------------------\r\n# File: tst_EnumeratedValueValidator.pro\r\n#-----------------------------------------------------------------------------\r\n# Project: Kactus 2\r\n# Author: Mikko Teuho\r\n# Date: 17.11.2015\r\n#\r\n# Description:\r\n# Qt project file template for running unit tests for Enumerated Value Validator.\r\n#-----------------------------------------------------------------------------\r\n\r\nTEMPLATE = app\r\n\r\nTARGET = tst_EnumeratedValueValidator\r\n\r\nQT += core gui xml testlib\r\n\r\nCONFIG += c++11 testcase console\r\n\r\nlinux-g++ | linux-g++-64 | linux-g++-32 {\r\n LIBS += -L../../../executable \\\r\n     -lIPXACTmodels -lKactusAPI\r\n\r\n}\r\nwin64 | win32 {\r\n LIBS += -L../../../executable \\\r\n     -lIPXACTmodelsd -lKactusAPId\r\n}\r\n\r\nINCLUDEPATH += $$DESTDIR\r\nINCLUDEPATH += ../../../\r\n\r\nDEPENDPATH += .\r\nDEPENDPATH += ../../../\r\n\r\nOBJECTS_DIR += $$DESTDIR\r\n\r\nMOC_DIR += ./generatedFiles\r\nUI_DIR += ./generatedFiles\r\nRCC_DIR += ./generatedFiles\r\ninclude(tst_EnumeratedValueValidator.pri)\r\n"
  },
  {
    "path": "tests/IPXACTmodels/Component/tst_EnumeratedValueWriter.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: tst_EnumeratedValueWriter.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 23.09.2015\r\n//\r\n// Description:\r\n// Unit test for class EnumeratedValueWriter.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include <IPXACTmodels/Component/EnumeratedValueWriter.h>\r\n#include <IPXACTmodels/Component/EnumeratedValue.h>\r\n\r\n#include <IPXACTmodels/common/GenericVendorExtension.h>\r\n\r\n#include <QtTest>\r\n#include <QSharedPointer>\r\n#include <QDomDocument>\r\n\r\nclass tst_EnumeratedValueWriter : public QObject\r\n{\r\n    Q_OBJECT\r\n\r\npublic:\r\n    tst_EnumeratedValueWriter();\r\n\r\nprivate slots:\r\n\r\n    void initTestCase();\r\n    void cleanupTestCase();\r\n    void init();\r\n    void cleanup();\r\n\r\n    void writeSimpleEnumeration();\r\n    void writeUsage();\r\n    void writeVendorExtensions();\r\n\r\nprivate:\r\n\r\n    QSharedPointer<EnumeratedValue> testEnumeration_;\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_EnumeratedValueWriter::tst_EnumeratedValueWriter()\r\n//-----------------------------------------------------------------------------\r\ntst_EnumeratedValueWriter::tst_EnumeratedValueWriter()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_EnumeratedValueWriter::initTestCase()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_EnumeratedValueWriter::initTestCase()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_EnumeratedValueWriter::cleanupTestCase()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_EnumeratedValueWriter::cleanupTestCase()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_EnumeratedValueWriter::init()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_EnumeratedValueWriter::init()\r\n{\r\n    testEnumeration_ = QSharedPointer<EnumeratedValue> (new EnumeratedValue(\"testEnumeration\", \"testValue\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_EnumeratedValueWriter::cleanup()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_EnumeratedValueWriter::cleanup()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_EnumeratedValueWriter::writeSimpleEnumeration()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_EnumeratedValueWriter::writeSimpleEnumeration()\r\n{\r\n    QString output;\r\n    QXmlStreamWriter xmlStreamWriter(&output);\r\n\r\n    QString expectedOutput(\r\n        \"<ipxact:enumeratedValue>\"\r\n            \"<ipxact:name>testEnumeration</ipxact:name>\"\r\n            \"<ipxact:value>testValue</ipxact:value>\"\r\n        \"</ipxact:enumeratedValue>\"\r\n        );\r\n\r\n    EnumeratedValueWriter enumerationWriter;\r\n    enumerationWriter.writeEnumeratedValue(xmlStreamWriter, testEnumeration_);\r\n    QCOMPARE(output, expectedOutput);\r\n\r\n    output.clear();\r\n\r\n    testEnumeration_->setDisplayName(\"enumDisplay\");\r\n    testEnumeration_->setDescription(\"enumDescription\");\r\n\r\n    expectedOutput =\r\n        \"<ipxact:enumeratedValue>\"\r\n            \"<ipxact:name>testEnumeration</ipxact:name>\"\r\n            \"<ipxact:displayName>enumDisplay</ipxact:displayName>\"\r\n            \"<ipxact:description>enumDescription</ipxact:description>\"\r\n            \"<ipxact:value>testValue</ipxact:value>\"\r\n        \"</ipxact:enumeratedValue>\"\r\n        ;\r\n\r\n    enumerationWriter.writeEnumeratedValue(xmlStreamWriter, testEnumeration_);\r\n    QCOMPARE(output, expectedOutput);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_EnumeratedValueWriter::writeUsage()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_EnumeratedValueWriter::writeUsage()\r\n{\r\n    QString output;\r\n    QXmlStreamWriter xmlStreamWriter(&output);\r\n\r\n    testEnumeration_->setUsage(EnumeratedValue::WRITE);\r\n\r\n    QString expectedOutput(\r\n        \"<ipxact:enumeratedValue usage=\\\"write\\\">\"\r\n            \"<ipxact:name>testEnumeration</ipxact:name>\"\r\n            \"<ipxact:value>testValue</ipxact:value>\"\r\n        \"</ipxact:enumeratedValue>\"\r\n        );\r\n\r\n    EnumeratedValueWriter enumerationWriter;\r\n    enumerationWriter.writeEnumeratedValue(xmlStreamWriter, testEnumeration_);\r\n    QCOMPARE(output, expectedOutput);\r\n\r\n    output.clear();\r\n\r\n    testEnumeration_->setUsage(EnumeratedValue::READWRITE);\r\n\r\n    expectedOutput =\r\n        \"<ipxact:enumeratedValue usage=\\\"read-write\\\">\"\r\n            \"<ipxact:name>testEnumeration</ipxact:name>\"\r\n            \"<ipxact:value>testValue</ipxact:value>\"\r\n         \"</ipxact:enumeratedValue>\"\r\n        ;\r\n\r\n    enumerationWriter.writeEnumeratedValue(xmlStreamWriter, testEnumeration_);\r\n    QCOMPARE(output, expectedOutput);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_EnumeratedValueWriter::writeVendorExtensions()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_EnumeratedValueWriter::writeVendorExtensions()\r\n{\r\n    QString output;\r\n    QXmlStreamWriter xmlStreamWriter(&output);\r\n\r\n    QDomDocument document;\r\n    QDomElement extensionNode = document.createElement(\"testExtension\");\r\n    extensionNode.setAttribute(\"testExtensionAttribute\", \"extension\");\r\n    extensionNode.appendChild(document.createTextNode(\"testValue\"));\r\n\r\n    QSharedPointer<GenericVendorExtension> testExtension(new GenericVendorExtension(extensionNode));\r\n\r\n    testEnumeration_->getVendorExtensions()->append(testExtension);\r\n\r\n    QString expectedOutput(\r\n        \"<ipxact:enumeratedValue>\"\r\n            \"<ipxact:name>testEnumeration</ipxact:name>\"\r\n            \"<ipxact:value>testValue</ipxact:value>\"\r\n            \"<ipxact:vendorExtensions>\"\r\n                \"<testExtension testExtensionAttribute=\\\"extension\\\">testValue</testExtension>\"\r\n            \"</ipxact:vendorExtensions>\"\r\n        \"</ipxact:enumeratedValue>\"\r\n        );\r\n\r\n    EnumeratedValueWriter enumerationWriter;\r\n    enumerationWriter.writeEnumeratedValue(xmlStreamWriter, testEnumeration_);\r\n    QCOMPARE(output, expectedOutput);\r\n}\r\n\r\nQTEST_APPLESS_MAIN(tst_EnumeratedValueWriter)\r\n\r\n#include \"tst_EnumeratedValueWriter.moc\"\r\n"
  },
  {
    "path": "tests/IPXACTmodels/Component/tst_EnumeratedValueWriter.pri",
    "content": "# ----------------------------------------------------\r\n# This file is generated by the Qt Visual Studio Tools.\r\n# ------------------------------------------------------\r\n\r\nSOURCES += ./tst_EnumeratedValueWriter.cpp "
  },
  {
    "path": "tests/IPXACTmodels/Component/tst_EnumeratedValueWriter.pro",
    "content": "#-----------------------------------------------------------------------------\r\n# File: tst_EnumeratedValueWriter.pro\r\n#-----------------------------------------------------------------------------\r\n# Project: Kactus 2\r\n# Author: Mikko Teuho\r\n# Date: 23.09.2015\r\n#\r\n# Description:\r\n# Qt project file template for running unit tests for EnumeratedValueWriter.\r\n#-----------------------------------------------------------------------------\r\n\r\nTEMPLATE = app\r\n\r\nTARGET = tst_EnumeratedValueWriter\r\n\r\nQT += core xml testlib\r\nQT -= gui\r\n\r\nCONFIG += c++11 testcase console\r\n\r\nlinux-g++ | linux-g++-64 | linux-g++-32 {\r\n LIBS += -L../../../executable \\\r\n     -lIPXACTmodels\r\n\r\n}\r\nwin64 | win32 {\r\n LIBS += -L../../../x64/executable \\\r\n     -lIPXACTmodelsd\r\n}\r\n\r\nINCLUDEPATH += $$DESTDIR\r\nINCLUDEPATH += ../../../\r\n\r\nDEPENDPATH += .\r\nDEPENDPATH += ../../../\r\n\r\nOBJECTS_DIR += $$DESTDIR\r\n\r\nMOC_DIR += ./generatedFiles\r\nUI_DIR += ./generatedFiles\r\nRCC_DIR += ./generatedFiles\r\ninclude(tst_EnumeratedValueWriter.pri)\r\n"
  },
  {
    "path": "tests/IPXACTmodels/Component/tst_FieldAccessPolicyReader.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: tst_FieldReader.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Anton Hagqvist\n// Date: 31.7.2023\n//\n// Description:\n// Unit test for class FieldAccessPolicyReader.\n//-----------------------------------------------------------------------------\n\n#include <IPXACTmodels/Component/FieldAccessPolicyReader.h>\n\n#include <IPXACTmodels/Component/FieldAccessPolicy.h>\n\n#include <IPXACTmodels/common/VendorExtension.h>\n\n#include <QtTest>\n\nclass tst_FieldAccessPolicyReader : public QObject\n{\n    Q_OBJECT\n\npublic:\n    tst_FieldAccessPolicyReader();\n\nprivate slots:\n\n    void readModeRefs();\n    void readDefinitionRef();\n    void readAccess();\n    void readModifiedWrite();\n    void readWriteConstraint();\n    void readReadAction();\n    void readResponse();\n    void readBroadcasts();\n    void readAccessRestrictions();\n    void readTestable();\n    void readReserved();\n    void readVendorExtensions();\n};\n\n//-----------------------------------------------------------------------------\n// Function: tst_FieldAccessPolicyReader::tst_FieldAccessPolicyReader()\n//-----------------------------------------------------------------------------\ntst_FieldAccessPolicyReader::tst_FieldAccessPolicyReader()\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_FieldAccessPolicyReader::readModeRefs()\n//-----------------------------------------------------------------------------\nvoid tst_FieldAccessPolicyReader::readModeRefs()\n{\n    QString doc(\n        \"<ipxact:fieldAccessPolicy>\"\n            \"<ipxact:modeRef priority=\\\"0\\\">normal</ipxact:modeRef>\"\n        \"</ipxact:fieldAccessPolicy>\"\n    );\n\n    QDomDocument document;\n    document.setContent(doc);\n\n    auto fieldAccessPolicy = FieldAccessPolicyReader::createFieldAccessPolicyFrom(document.firstChildElement(\"ipxact:fieldAccessPolicy\"));\n\n    QCOMPARE(fieldAccessPolicy->getModeReferences()->size(), 1);\n    QCOMPARE(fieldAccessPolicy->getModeReferences()->first()->getReference(), QString(\"normal\"));\n\n     doc =\n        \"<ipxact:fieldAccessPolicy>\"\n            \"<ipxact:modeRef priority=\\\"0\\\">normal</ipxact:modeRef>\"\n            \"<ipxact:modeRef priority=\\\"1\\\">test</ipxact:modeRef>\"\n        \"</ipxact:fieldAccessPolicy>\"\n        ;\n\n    document.setContent(doc);\n\n    fieldAccessPolicy = FieldAccessPolicyReader::createFieldAccessPolicyFrom(document.firstChildElement(\"ipxact:fieldAccessPolicy\"));\n\n    QCOMPARE(fieldAccessPolicy->getModeReferences()->size(), 2);\n    QCOMPARE(fieldAccessPolicy->getModeReferences()->first()->getReference(), QString(\"normal\"));\n    QCOMPARE(fieldAccessPolicy->getModeReferences()->first()->getPriority(), 0);\n    QCOMPARE(fieldAccessPolicy->getModeReferences()->at(1)->getReference(), QString(\"test\"));\n    QCOMPARE(fieldAccessPolicy->getModeReferences()->at(1)->getPriority(), 1);\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_FieldAccessPolicyReader::readDefinitionRef()\n//-----------------------------------------------------------------------------\nvoid tst_FieldAccessPolicyReader::readDefinitionRef()\n{\n    QString doc(\n        \"<ipxact:fieldAccessPolicy>\"\n            \"<ipxact:fieldAccessPolicyDefinitionRef typeDefinitions=\\\"testTypeDefinitions\\\">testDefinition</ipxact:fieldAccessPolicyDefinitionRef>\"\n        \"</ipxact:fieldAccessPolicy>\"\n    );\n\n    QDomDocument document;\n    document.setContent(doc);\n\n    auto fieldAccessPolicy = FieldAccessPolicyReader::createFieldAccessPolicyFrom(document.firstChildElement(\"ipxact:fieldAccessPolicy\"));\n\n    QCOMPARE(fieldAccessPolicy->getFieldAccessPolicyDefinitionRef(), QString(\"testDefinition\"));\n    QCOMPARE(fieldAccessPolicy->getFieldAccessPolicyTypeDefinitionRef(), QString(\"testTypeDefinitions\"));\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_FieldAccessPolicyReader::readAccess()\n//-----------------------------------------------------------------------------\nvoid tst_FieldAccessPolicyReader::readAccess()\n{\n    QString documentContent(\n        \"<ipxact:fieldAccessPolicy>\"\n            \"<ipxact:access>read-write</ipxact:access>\"\n        \"</ipxact:fieldAccessPolicy>\"\n        );\n\n    QDomDocument document;\n    document.setContent(documentContent);\n\n    auto fieldAccessPolicy = FieldAccessPolicyReader::createFieldAccessPolicyFrom(document.firstChildElement(\"ipxact:fieldAccessPolicy\"));\n\n    QCOMPARE(fieldAccessPolicy->getAccess(), AccessTypes::Access::READ_WRITE);\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_FieldAccessPolicyReader::readModifiedWrite()\n//-----------------------------------------------------------------------------\nvoid tst_FieldAccessPolicyReader::readModifiedWrite()\n{\n     QString documentContent(\n        \"<ipxact:fieldAccessPolicy>\"\n            \"<ipxact:modifiedWriteValue>zeroToClear</ipxact:modifiedWriteValue>\"\n        \"</ipxact:fieldAccessPolicy>\"\n        );\n\n    QDomDocument document;\n    document.setContent(documentContent);\n\n    auto fieldAccessPolicy = FieldAccessPolicyReader::createFieldAccessPolicyFrom(document.firstChildElement(\"ipxact:fieldAccessPolicy\"));\n\n    QCOMPARE(fieldAccessPolicy->getModifiedWrite(), General::ZERO_TO_CLEAR);\n\n    documentContent =\n        \"<ipxact:fieldAccessPolicy>\"\n            \"<ipxact:modifiedWriteValue modify=\\\"modifier\\\">oneToToggle</ipxact:modifiedWriteValue>\"\n        \"</ipxact:fieldAccessPolicy>\"\n        ;\n\n    document.setContent(documentContent);\n    fieldAccessPolicy = FieldAccessPolicyReader::createFieldAccessPolicyFrom(document.firstChildElement(\"ipxact:fieldAccessPolicy\"));\n\n    QCOMPARE(fieldAccessPolicy->getModifiedWrite(), General::ONE_TO_TOGGLE);\n    QCOMPARE(fieldAccessPolicy->getModifiedWriteModify(), QString(\"modifier\"));\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_FieldAccessPolicyReader::readWriteConstraint()\n//-----------------------------------------------------------------------------\nvoid tst_FieldAccessPolicyReader::readWriteConstraint()\n{\n    QString documentContent(\n        \"<ipxact:fieldAccessPolicy>\"\n            \"<ipxact:writeValueConstraint>\"\n                \"<ipxact:writeAsRead>true</ipxact:writeAsRead>\"\n            \"</ipxact:writeValueConstraint>\"\n        \"</ipxact:fieldAccessPolicy>\"\n        );\n\n    QDomDocument document;\n    document.setContent(documentContent);\n\n    auto fieldAccessPolicy = FieldAccessPolicyReader::createFieldAccessPolicyFrom(document.firstChildElement(\"ipxact:fieldAccessPolicy\"));\n\n    QCOMPARE(fieldAccessPolicy->getWriteValueConstraint().isNull(), false);\n    QCOMPARE(fieldAccessPolicy->getWriteValueConstraint()->getType(), WriteValueConstraint::WRITE_AS_READ);\n\n    documentContent =\n        \"<ipxact:fieldAccessPolicy>\"\n            \"<ipxact:writeValueConstraint>\"\n                \"<ipxact:useEnumeratedValues>true</ipxact:useEnumeratedValues>\"\n            \"</ipxact:writeValueConstraint>\"\n        \"</ipxact:fieldAccessPolicy>\"\n        ;\n\n    document.setContent(documentContent);\n    \n    fieldAccessPolicy = FieldAccessPolicyReader::createFieldAccessPolicyFrom(document.firstChildElement(\"ipxact:fieldAccessPolicy\"));\n\n    QCOMPARE(fieldAccessPolicy->getWriteValueConstraint().isNull(), false);\n    QCOMPARE(fieldAccessPolicy->getWriteValueConstraint()->getType(), WriteValueConstraint::USE_ENUM);\n\n    documentContent =\n        \"<ipxact:fieldAccessPolicy>\"\n            \"<ipxact:writeValueConstraint>\"\n                \"<ipxact:minimum>0</ipxact:minimum>\"\n                \"<ipxact:maximum>10</ipxact:maximum>\"\n            \"</ipxact:writeValueConstraint>\"\n        \"</ipxact:fieldAccessPolicy>\"\n        ;\n\n    document.setContent(documentContent);\n    \n    fieldAccessPolicy = FieldAccessPolicyReader::createFieldAccessPolicyFrom(document.firstChildElement(\"ipxact:fieldAccessPolicy\"));\n\n    QCOMPARE(fieldAccessPolicy->getWriteValueConstraint().isNull(), false);\n    QCOMPARE(fieldAccessPolicy->getWriteValueConstraint()->getType(), WriteValueConstraint::MIN_MAX);\n    QCOMPARE(fieldAccessPolicy->getWriteValueConstraint()->getMinimum(), QString(\"0\"));\n    QCOMPARE(fieldAccessPolicy->getWriteValueConstraint()->getMaximum(), QString(\"10\"));\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_FieldAccessPolicyReader::readReadAction()\n//-----------------------------------------------------------------------------\nvoid tst_FieldAccessPolicyReader::readReadAction()\n{\n    QString documentContent(\n        \"<ipxact:fieldAccessPolicy>\"\n            \"<ipxact:readAction>set</ipxact:readAction>\"\n        \"</ipxact:fieldAccessPolicy>\"\n        );\n\n    QDomDocument document;\n    document.setContent(documentContent);\n\n    auto fieldAccessPolicy = FieldAccessPolicyReader::createFieldAccessPolicyFrom(document.firstChildElement(\"ipxact:fieldAccessPolicy\"));\n\n    QCOMPARE(fieldAccessPolicy->getReadAction(), General::READ_SET);\n\n    documentContent =\n        \"<ipxact:fieldAccessPolicy>\"\n            \"<ipxact:readAction modify=\\\"modifier\\\">clear</ipxact:readAction>\"\n        \"</ipxact:fieldAccessPolicy>\"\n        ;\n\n    document.setContent(documentContent);\n\n    fieldAccessPolicy = FieldAccessPolicyReader::createFieldAccessPolicyFrom(document.firstChildElement(\"ipxact:fieldAccessPolicy\"));\n\n    QCOMPARE(fieldAccessPolicy->getReadAction(), General::READ_CLEAR);\n    QCOMPARE(fieldAccessPolicy->getReadActionModify(), QString(\"modifier\"));\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_FieldAccessPolicyReader::readResponse()\n//-----------------------------------------------------------------------------\nvoid tst_FieldAccessPolicyReader::readResponse()\n{\n    QString documentContent(\n        \"<ipxact:fieldAccessPolicy>\"\n            \"<ipxact:readResponse>8+8</ipxact:readResponse>\"\n        \"</ipxact:fieldAccessPolicy>\"\n        );\n\n    QDomDocument document;\n    document.setContent(documentContent);\n\n    auto fieldAccessPolicy = FieldAccessPolicyReader::createFieldAccessPolicyFrom(document.firstChildElement(\"ipxact:fieldAccessPolicy\"));\n\n    QCOMPARE(fieldAccessPolicy->getReadResponse(), QString(\"8+8\"));\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_FieldAccessPolicyReader::readBroadcasts()\n//-----------------------------------------------------------------------------\nvoid tst_FieldAccessPolicyReader::readBroadcasts()\n{\n    QString documentContent(\n        \"<ipxact:fieldAccessPolicy>\"\n            \"<ipxact:broadcasts>\"\n                \"<ipxact:broadcastTo>\"\n                    \"<ipxact:fieldRef fieldRef=\\\"testField\\\">\"\n                        \"<ipxact:indices>\"\n                            \"<ipxact:index>0</ipxact:index>\"\n                        \"</ipxact:indices>\"\n                    \"</ipxact:fieldRef>\"\n                \"</ipxact:broadcastTo>\"\n                \"<ipxact:broadcastTo>\"\n                    \"<ipxact:memoryMapRef memoryMapRef=\\\"testMemoryMap\\\"/>\"\n                    \"<ipxact:addressBlockRef addressBlockRef=\\\"testAddressBlock\\\"/>\"\n                    \"<ipxact:registerRef registerRef=\\\"testRegister\\\"/>\"\n                    \"<ipxact:fieldRef fieldRef=\\\"testField\\\"/>\"\n                \"</ipxact:broadcastTo>\"\n            \"</ipxact:broadcasts>\"\n        \"</ipxact:fieldAccessPolicy>\"\n        );\n\n    QDomDocument document;\n    document.setContent(documentContent);\n\n    auto fieldAccessPolicy = FieldAccessPolicyReader::createFieldAccessPolicyFrom(document.firstChildElement(\"ipxact:fieldAccessPolicy\"));\n\n    QCOMPARE(fieldAccessPolicy->getBroadcasts()->size(), 2);\n    QCOMPARE(fieldAccessPolicy->getBroadcasts()->first()->getReference(FieldReference::FIELD)->reference_, QString(\"testField\"));\n    QCOMPARE(fieldAccessPolicy->getBroadcasts()->first()->getReference(FieldReference::FIELD)->indices_.size(), 1);\n    QCOMPARE(fieldAccessPolicy->getBroadcasts()->first()->getReference(FieldReference::FIELD)->indices_.first(), QString(\"0\"));\n\n    QCOMPARE(fieldAccessPolicy->getBroadcasts()->at(1)->getReference(FieldReference::MEMORY_MAP)->reference_, QString(\"testMemoryMap\"));\n    QCOMPARE(fieldAccessPolicy->getBroadcasts()->at(1)->getReference(FieldReference::ADDRESS_BLOCK)->reference_, QString(\"testAddressBlock\"));\n    QCOMPARE(fieldAccessPolicy->getBroadcasts()->at(1)->getReference(FieldReference::REGISTER)->reference_, QString(\"testRegister\"));\n    QCOMPARE(fieldAccessPolicy->getBroadcasts()->at(1)->getReference(FieldReference::FIELD)->reference_, QString(\"testField\"));\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_FieldAccessPolicyReader::readAccessRestrictions()\n//-----------------------------------------------------------------------------\nvoid tst_FieldAccessPolicyReader::readAccessRestrictions()\n{\n    QString documentContent(\n        \"<ipxact:fieldAccessPolicy>\"\n            \"<ipxact:accessRestrictions>\"\n                \"<ipxact:accessRestriction>\"\n                    \"<ipxact:modeRef priority=\\\"0\\\">testMode</ipxact:modeRef>\"\n                    \"<ipxact:modeRef priority=\\\"1\\\">testMode2</ipxact:modeRef>\"\n                    \"<ipxact:readAccessMask>'b00</ipxact:readAccessMask>\"\n                    \"<ipxact:writeAccessMask>'b11</ipxact:writeAccessMask>\"\n                \"</ipxact:accessRestriction>\"\n                \"<ipxact:accessRestriction>\"\n                    \"<ipxact:readAccessMask>'b1000</ipxact:readAccessMask>\"\n                    \"<ipxact:writeAccessMask>'b1111</ipxact:writeAccessMask>\"\n                \"</ipxact:accessRestriction>\"\n            \"</ipxact:accessRestrictions>\"\n        \"</ipxact:fieldAccessPolicy>\"\n        );\n\n    QDomDocument document;\n    document.setContent(documentContent);\n\n    auto fieldAccessPolicy = FieldAccessPolicyReader::createFieldAccessPolicyFrom(document.firstChildElement(\"ipxact:fieldAccessPolicy\"));\n\n    auto accessRestrictions = fieldAccessPolicy->getAccessRestrictions();\n\n    QCOMPARE(accessRestrictions->size(), 2);\n    QCOMPARE(accessRestrictions->first()->modeRefs_->size(), 2);\n    QCOMPARE(accessRestrictions->first()->readAccessMask_, QString(\"'b00\"));\n    QCOMPARE(accessRestrictions->first()->writeAccessMask_, QString(\"'b11\"));\n\n    QCOMPARE(accessRestrictions->at(1)->modeRefs_->size(), 0);\n    QCOMPARE(accessRestrictions->at(1)->readAccessMask_, QString(\"'b1000\"));\n    QCOMPARE(accessRestrictions->at(1)->writeAccessMask_, QString(\"'b1111\"));\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_FieldAccessPolicyReader::readTestable()\n//-----------------------------------------------------------------------------\nvoid tst_FieldAccessPolicyReader::readTestable()\n{\n    QString documentContent(\n        \"<ipxact:fieldAccessPolicy>\"\n            \"<ipxact:testable>false</ipxact:testable>\"\n        \"</ipxact:fieldAccessPolicy>\"\n    );\n\n    QDomDocument document;\n    document.setContent(documentContent);\n    \n    auto fieldAccessPolicy = FieldAccessPolicyReader::createFieldAccessPolicyFrom(document.firstChildElement(\"ipxact:fieldAccessPolicy\"));\n\n    QCOMPARE(fieldAccessPolicy->getTestable().toString(), QString(\"false\"));\n\n    documentContent =\n        \"<ipxact:fieldAccessPolicy>\"\n            \"<ipxact:testable testConstraint=\\\"restore\\\">true</ipxact:testable>\"\n        \"</ipxact:fieldAccessPolicy>\"\n        ;\n\n    document.setContent(documentContent);\n    fieldAccessPolicy = FieldAccessPolicyReader::createFieldAccessPolicyFrom(document.firstChildElement(\"ipxact:fieldAccessPolicy\"));\n\n    QCOMPARE(fieldAccessPolicy->getTestable().toString(), QString(\"true\"));\n    QCOMPARE(fieldAccessPolicy->getTestConstraint(), General::TEST_RESTORE);\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_FieldAccessPolicyReader::readReserved()\n//-----------------------------------------------------------------------------\nvoid tst_FieldAccessPolicyReader::readReserved()\n{\n    QString documentContent(\n        \"<ipxact:fieldAccessPolicy>\"\n            \"<ipxact:reserved>reserveWarning</ipxact:reserved>\"\n        \"</ipxact:fieldAccessPolicy>\"\n        );\n\n    QDomDocument document;\n    document.setContent(documentContent);\n\n    auto fieldAccessPolicy = FieldAccessPolicyReader::createFieldAccessPolicyFrom(document.firstChildElement(\"ipxact:fieldAccessPolicy\"));\n\n    QCOMPARE(fieldAccessPolicy->getReserved(), QString(\"reserveWarning\"));\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_FieldAccessPolicyReader::readVendorExtensions()\n//-----------------------------------------------------------------------------\nvoid tst_FieldAccessPolicyReader::readVendorExtensions()\n{\n    QString documentContent(\n        \"<ipxact:fieldAccessPolicy>\"\n            \"<ipxact:vendorExtensions>\"\n                \"<testExtension testExtensionAttribute=\\\"extension\\\">testValue</testExtension>\"\n            \"</ipxact:vendorExtensions>\"\n        \"</ipxact:fieldAccessPolicy>\"\n        );\n\n    QDomDocument document;\n    document.setContent(documentContent);\n\n    QDomNode fieldNode = document.firstChildElement(\"ipxact:field\");\n\n    auto fieldAccessPolicy = FieldAccessPolicyReader::createFieldAccessPolicyFrom(document.firstChildElement(\"ipxact:fieldAccessPolicy\"));\n\n    QCOMPARE(fieldAccessPolicy->getVendorExtensions()->size(), 1);\n    QCOMPARE(fieldAccessPolicy->getVendorExtensions()->first()->type(), QString(\"testExtension\"));\n}\n\nQTEST_APPLESS_MAIN(tst_FieldAccessPolicyReader)\n\n#include \"tst_FieldAccessPolicyReader.moc\"\n"
  },
  {
    "path": "tests/IPXACTmodels/Component/tst_FieldAccessPolicyReader.pri",
    "content": "# ----------------------------------------------------\n# This file is generated by the Qt Visual Studio Tools.\n# ------------------------------------------------------\n\nSOURCES += ./tst_FieldAccessPolicyReader.cpp\n"
  },
  {
    "path": "tests/IPXACTmodels/Component/tst_FieldAccessPolicyReader.pro",
    "content": "#-----------------------------------------------------------------------------\n# File: tst_FieldAccessPolicyReader.pro\n#-----------------------------------------------------------------------------\n# Project: Kactus 2\n# Author: Anton Hagqvist\n# Date: 31.7.2023\n#\n# Description:\n# Qt project file template for running unit tests for FieldAccessPolicyReader.\n#-----------------------------------------------------------------------------\n\nTEMPLATE = app\n\nTARGET = tst_FieldAccessPolicyReader\n\nQT += core xml testlib\nQT -= gui\n\nCONFIG += c++11 testcase console\n\nlinux-g++ | linux-g++-64 | linux-g++-32 {\n LIBS += -L../../../executable \\\n     -lIPXACTmodels\n\n}\nwin64 | win32 {\n LIBS += -L../../../executable \\\n     -lIPXACTmodelsd\n}\n\nINCLUDEPATH += $$DESTDIR\nINCLUDEPATH += ../../../\n\nDEPENDPATH += .\nDEPENDPATH += ../../../\n\nOBJECTS_DIR += $$DESTDIR\n\nMOC_DIR += ./generatedFiles\nUI_DIR += ./generatedFiles\nRCC_DIR += ./generatedFiles\ninclude(tst_FieldAccessPolicyReader.pri)\n"
  },
  {
    "path": "tests/IPXACTmodels/Component/tst_FieldAccessPolicyValidator.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: tst_FieldAccessPolicyvalidator_.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Anton Hagqvist\n// Date: 2.8.2023\n//\n// Description:\n// Unit test for class FieldAccessPolicyValidator>.\n//-----------------------------------------------------------------------------\n\n#include <IPXACTmodels/Component/validators/FieldAccessPolicyValidator.h>\n#include <IPXACTmodels/Component/FieldAccessPolicy.h>\n#include <IPXACTmodels/Component/Mode.h>\n\n#include <KactusAPI/include/SystemVerilogExpressionParser.h>\n\n#include <QtTest>\n#include <QDomDocument>\n\nclass tst_FieldAccessPolicyValidator : public QObject\n{\n    Q_OBJECT\n\npublic:\n    tst_FieldAccessPolicyValidator();\n\nprivate slots:\n    \n    void init();\n    void cleanup();\n    void testDefinitionRefIsValid();\n\n    void testAccessIsValid();\n    void testAccessIsValid_data();\n\n    void testWriteValueConstraintIsValid();\n    void testWriteValueConstraintIsValid_data();\n\n    void testReadResponseIsValid();\n    void testReadResponseIsValid_data();\n    \n    void testBroadcastsAreValid();\n    void testAccessRestrictionsAreValid();\n\n    void testReserved();\n    void testReserved_data();\n\n\nprivate:\n    QSharedPointer<FieldAccessPolicy> fieldAccessPolicy_;\n\n    QSharedPointer<ExpressionParser> expressionParser_ = QSharedPointer<ExpressionParser>(new SystemVerilogExpressionParser());\n    \n    FieldAccessPolicyValidator validator_;\n\n    bool errorIsNotFoundInErrorList(QString const& expectedError, QStringList errorList);\n};\n\n//-----------------------------------------------------------------------------\n// Function: tst_FieldAccessPolicyValidator::tst_FieldAccessPolicyValidator()\n//-----------------------------------------------------------------------------\ntst_FieldAccessPolicyValidator::tst_FieldAccessPolicyValidator() :\n    validator_(expressionParser_)\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_FieldAccessPolicyValidator::init()\n//-----------------------------------------------------------------------------\nvoid tst_FieldAccessPolicyValidator::init()\n{\n    fieldAccessPolicy_ = QSharedPointer<FieldAccessPolicy>(new FieldAccessPolicy());\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_FieldAccessPolicyValidator::cleanup()\n//-----------------------------------------------------------------------------\nvoid tst_FieldAccessPolicyValidator::cleanup()\n{\n    fieldAccessPolicy_.clear();\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_FieldAccessPolicyValidator::testDefinitionRefIsValid()\n//-----------------------------------------------------------------------------\nvoid tst_FieldAccessPolicyValidator::testDefinitionRefIsValid()\n{\n    fieldAccessPolicy_->setFieldAccessPolicyDefinitionRef(\"fieldAccessPolicy_AccessPolicyDefinition\");\n\n    QStringList errorList;\n\n    validator_.findErrorsIn(errorList, fieldAccessPolicy_, \"test\", QSharedPointer<QList<QSharedPointer<Mode> > >());\n\n    QCOMPARE(errorList.size(), 1); // No typedefinitions.\n    QVERIFY(validator_.validate(fieldAccessPolicy_, QSharedPointer<QList<QSharedPointer<Mode> > >()) == false);\n\n    errorList.clear();\n    fieldAccessPolicy_->setFieldAccessPolicyTypeDefinitionRef(\"testTypeDefinitions\");\n\n    validator_.findErrorsIn(errorList, fieldAccessPolicy_, \"test\", QSharedPointer<QList<QSharedPointer<Mode> > >());\n    QCOMPARE(errorList.size(), 0);\n    QVERIFY(validator_.validate(fieldAccessPolicy_, QSharedPointer<QList<QSharedPointer<Mode> > >()));\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_FieldAccessPolicyValidator::testAccessIsValid()\n//-----------------------------------------------------------------------------\nvoid tst_FieldAccessPolicyValidator::testAccessIsValid()\n{\n    QFETCH(QString, accessValue);\n    QFETCH(QString, modifiedWriteValue);\n    QFETCH(QString, readAction);\n    QFETCH(bool, isValid);\n\n    fieldAccessPolicy_->setAccess(AccessTypes::str2Access(accessValue, AccessTypes::ACCESS_COUNT));\n    fieldAccessPolicy_->setModifiedWrite(General::str2ModifiedWrite(modifiedWriteValue));\n    fieldAccessPolicy_->setReadAction(General::str2ReadAction(readAction));\n\n    QStringList errorList;\n\n    QCOMPARE(validator_.hasValidAccess(fieldAccessPolicy_), isValid);\n\n    if (!isValid)\n    {\n        QVector<QString> errorList;\n        validator_.findErrorsIn(errorList, fieldAccessPolicy_, \"test\", QSharedPointer<QList<QSharedPointer<Mode> > >());\n\n        if (fieldAccessPolicy_->getAccess() == AccessTypes::READ_ONLY &&\n            fieldAccessPolicy_->getModifiedWrite() != General::MODIFIED_WRITE_COUNT)\n        {\n            QString expectedError = QObject::tr(\"In field access policy within %1, access type readOnly does not \"\n                \"allow the field access policy to include a modified write value.\").arg(\"test\");\n            if (errorIsNotFoundInErrorList(expectedError, errorList))\n            {\n                QFAIL(\"No error message found\");\n            }\n        }\n        else if ((fieldAccessPolicy_->getAccess() == AccessTypes::WRITE_ONLY ||\n            fieldAccessPolicy_->getAccess() == AccessTypes::WRITEONCE) &&\n            fieldAccessPolicy_->getReadAction() != General::READ_ACTION_COUNT)\n        {\n            QString expectedError = QObject::tr(\"In field access policy within %1, access type write only and write once \"\n                \"do not allow the field access policy to include a read action value.\").arg(\"test\");\n            if (errorIsNotFoundInErrorList(expectedError, errorList))\n            {\n                QFAIL(\"No error message found\");\n            }\n        }\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_FieldAccessPolicyValidator::testAccessIsValid_data()\n//-----------------------------------------------------------------------------\nvoid tst_FieldAccessPolicyValidator::testAccessIsValid_data()\n{\n    QTest::addColumn<QString>(\"accessValue\");\n    QTest::addColumn<QString>(\"modifiedWriteValue\");\n    QTest::addColumn<QString>(\"readAction\");\n    QTest::addColumn<bool>(\"isValid\");\n\n    QTest::newRow(\"Empty access, modified write value and read action are valid\") << \"\" << \"\" << \"\" << true;\n    QTest::newRow(\"Access read-write with a modified write value is valid\") << \"read-write\" << \"oneToClear\" <<\n        \"set\" << true;\n    QTest::newRow(\"Access read-only with a modified write value is invalid\") << \"read-only\" << \"oneToClear\" <<\n        \"set\" << false;\n    QTest::newRow(\"Access read-only without modified write value is valid\") << \"read-only\" << \"\" << \"set\" << true;\n    QTest::newRow(\"Access write-only with a read action is invalid\") << \"write-only\" << \"\" << \"set\" << false;\n    QTest::newRow(\"Access writeOnce with a read action is invalid\") << \"writeOnce\" << \"\" << \"clear\" << false;\n    QTest::newRow(\"Access write-only without a read action is valid\") << \"write-only\" << \"oneToClear\" << \"\" << true;\n    QTest::newRow(\"Access writeOnce without a read action is valid\") << \"writeOnce\" << \"oneToClear\" << \"\" << true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_FieldAccessPolicyValidator::testWriteValueConstraintIsValid()\n//-----------------------------------------------------------------------------\nvoid tst_FieldAccessPolicyValidator::testWriteValueConstraintIsValid()\n{\n    QFETCH(QString, minimum);\n    QFETCH(QString, maximum);\n    QFETCH(QString, constraintType);\n    QFETCH(bool, isValid);\n\n    QSharedPointer<WriteValueConstraint> testConstraint(new WriteValueConstraint());\n    if (constraintType == QLatin1String(\"writeAsRead\"))\n    {\n        testConstraint->setType(WriteValueConstraint::WRITE_AS_READ);\n    }\n    else if (constraintType == QLatin1String(\"useEnumeratedValues\"))\n    {\n        testConstraint->setType(WriteValueConstraint::USE_ENUM);\n    }\n    else if (constraintType == QLatin1String(\"minMax\"))\n    {\n        testConstraint->setMinimum(minimum);\n        testConstraint->setMaximum(maximum);\n    }\n\n    fieldAccessPolicy_->setWriteValueConstraint(testConstraint);\n\n    QSharedPointer<ExpressionParser> parser(new SystemVerilogExpressionParser());\n    FieldAccessPolicyValidator validator(parser);\n    QCOMPARE(validator_.hasValidWriteValueConstraint(fieldAccessPolicy_), isValid);\n\n    if (!isValid)\n    {\n        QVector<QString> foundErrors;\n        validator_.findErrorsIn(foundErrors, fieldAccessPolicy_, \"test\", QSharedPointer<QList<QSharedPointer<Mode> > >());\n\n        if (testConstraint->getType() == WriteValueConstraint::TYPE_COUNT)\n        {\n            QString expectedError = QObject::tr(\"Invalid write value constraint set for field access policy within %1\")\n                .arg(\"test\");\n            if (errorIsNotFoundInErrorList(expectedError, foundErrors))\n            {\n                QFAIL(\"No error message found\");\n            }\n        }\n        else if (testConstraint->getType() == WriteValueConstraint::MIN_MAX)\n        {\n            int minimumValue = parser->parseExpression(testConstraint->getMinimum()).toInt();\n            int maximumValue = parser->parseExpression(testConstraint->getMaximum()).toInt();\n\n            QString expectedError;\n            if (minimumValue > maximumValue)\n            {\n                expectedError = (QObject::tr(\"Maximum value must be greater than or equal to the minimum value in \"\n                    \"write value constraint set for field access policy within %1\").arg(\"test\"));\n                if (errorIsNotFoundInErrorList(expectedError, foundErrors))\n                {\n                    QFAIL(\"No error message found\");\n                }\n            }\n\n            QRegularExpression bitExpression(\"^([0-9]+|[1-9]+[0-9]*'([bB][01_]+|[hH][0-9a-fA-F_]+))$\");\n            if (!bitExpression.match(testConstraint->getMinimum()).hasMatch() ||\n                !bitExpression.match(parser->parseExpression(testConstraint->getMinimum())).hasMatch())\n            {\n                expectedError = QObject::tr(\n                    \"Invalid minimum value set for write value constraint in field access policy within %1\")\n                    .arg(\"test\");\n                if (errorIsNotFoundInErrorList(expectedError, foundErrors))\n                {\n                    QFAIL(\"No error message found\");\n                }\n            }\n\n            if (!bitExpression.match(testConstraint->getMaximum()).hasMatch() ||\n                !bitExpression.match(parser->parseExpression(testConstraint->getMaximum())).hasMatch())\n            {\n                expectedError = QObject::tr(\n                    \"Invalid maximum value set for write value constraint in field access policy within %1\")\n                    .arg(\"test\");\n                if (errorIsNotFoundInErrorList(expectedError, foundErrors))\n                {\n                    QFAIL(\"No error message found\");\n                }\n            }\n        }\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_FieldAccessPolicyValidator::testWriteValueConstraintIsValid_data()\n//-----------------------------------------------------------------------------\nvoid tst_FieldAccessPolicyValidator::testWriteValueConstraintIsValid_data()\n{\n    QTest::addColumn<QString>(\"minimum\");\n    QTest::addColumn<QString>(\"maximum\");\n    QTest::addColumn<QString>(\"constraintType\");\n    QTest::addColumn<bool>(\"isValid\");\n\n    QTest::newRow(\"No type for write value constraint is invalid\") << \"\" << \"\" << \"\" << false;\n    QTest::newRow(\"Write value constraint writeAsRead is valid\") << \"\" << \"\" << \"writeAsRead\" << true;\n    QTest::newRow(\"Write value constraint useEnumerated values is valid\") << \"\" << \"\" << \"useEnumeratedValues\" << true;\n    QTest::newRow(\"Write value constraint minMax is invalid for empty min and max\") << \"\" << \"\" << \"minMax\" << false;\n    QTest::newRow(\"8'b1001_0110 is valid for min and max\") << \"8'b1001_0110\" << \"8'b1001_0110\" << \"minMax\" << true;\n    QTest::newRow(\"Text is invalid for min and max\") << \"text\" << \"text\" << \"minMax\" << false;\n    QTest::newRow(\"String is invalid for min and max\") << \"\\\"test\\\"\" << \"\\\"test\\\"\" << \"minMax\" << false;\n    QTest::newRow(\"Values 14 and 2'h2 are invalid for min and max\") << \"14\" << \"2'h2\" << \"minMax\" << false;\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_FieldAccessPolicyValidator::testReadResponseIsValid()\n//-----------------------------------------------------------------------------\nvoid tst_FieldAccessPolicyValidator::testReadResponseIsValid()\n{\n    QFETCH(QString, readResponse);\n    QFETCH(bool, isValid);\n\n    fieldAccessPolicy_->setReadResponse(readResponse);\n\n    QCOMPARE(validator_.hasValidReadResponse(fieldAccessPolicy_), isValid);\n    \n    if (!isValid)\n    {\n        QStringList errors;\n\n        validator_.findErrorsIn(errors, fieldAccessPolicy_, \"test\", QSharedPointer<QList<QSharedPointer<Mode> > >());\n\n        QString expectedError = QObject::tr(\"Invalid read response value for field access policy within test\");\n\n        if (errorIsNotFoundInErrorList(expectedError, errors))\n        {\n            QFAIL(\"No error message found\");\n        }\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_FieldAccessPolicyValidator::testReadResponseIsValid_data()\n//-----------------------------------------------------------------------------\nvoid tst_FieldAccessPolicyValidator::testReadResponseIsValid_data()\n{\n    QTest::addColumn<QString>(\"readResponse\");\n    QTest::addColumn<bool>(\"isValid\");\n\n    QTest::newRow(\"8'b1001_0110 is valid\") << \"8'b1001_0110\" << true;\n    QTest::newRow(\"2'b10 is valid\") << \"2'b10\" << true;\n    QTest::newRow(\"2'h2 is valid\") << \"2'h2\" << true;\n    QTest::newRow(\"text is invalid\") << \"text\" << false;\n    QTest::newRow(\"string is invalid\") << \"\\\"text\\\"\" << false;\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_FieldAccessPolicyValidator::testBroadcastsAreValid()\n//-----------------------------------------------------------------------------\nvoid tst_FieldAccessPolicyValidator::testBroadcastsAreValid()\n{\n    QStringList errors;\n    QSharedPointer<FieldReference> fieldReference(new FieldReference());\n    QSharedPointer<FieldReference::IndexedReference> addressSpaceRef(new FieldReference::IndexedReference(\"testAddressSpace\", QStringList()));\n    QSharedPointer<FieldReference::IndexedReference> memoryMapRef(new FieldReference::IndexedReference(\"testMemoryMap\", QStringList()));\n    QSharedPointer<FieldReference::IndexedReference> fieldRef(new FieldReference::IndexedReference(\"testFieldRef\", QStringList()));\n\n    fieldReference->setReference(addressSpaceRef, FieldReference::ADDRESS_SPACE);\n    fieldReference->setReference(memoryMapRef, FieldReference::MEMORY_MAP);\n\n    fieldAccessPolicy_->getBroadcasts()->append(fieldReference);\n\n    QString expectedErrorChoice(\"Field reference in test cannot contain both an address space reference\"\n        \" and a memory map or memory remap reference.\"\n    );\n\n    QString expectedErrorField(\"Field reference in test must contain a reference to a field.\");\n\n    validator_.findErrorsIn(errors, fieldAccessPolicy_, \"test\", QSharedPointer<QList<QSharedPointer<Mode> > >());\n    QCOMPARE(errors.size(), 2);\n    QVERIFY(errorIsNotFoundInErrorList(expectedErrorChoice, errors) == false);\n    QVERIFY(errorIsNotFoundInErrorList(expectedErrorField, errors) == false);\n    QVERIFY(validator_.hasValidBroadcasts(fieldAccessPolicy_) == false);\n    \n    errors.clear();\n    fieldReference->setReference(fieldRef, FieldReference::FIELD);\n    fieldReference->clearReference(FieldReference::ADDRESS_SPACE);\n\n    validator_.findErrorsIn(errors, fieldAccessPolicy_, \"test\", QSharedPointer<QList<QSharedPointer<Mode> > >());\n    QCOMPARE(errors.size(), 0);\n    QVERIFY(validator_.hasValidBroadcasts(fieldAccessPolicy_));\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_FieldAccessPolicyValidator::testAccessRestrictionsAreValid()\n//-----------------------------------------------------------------------------\nvoid tst_FieldAccessPolicyValidator::testAccessRestrictionsAreValid()\n{\n    QSharedPointer<FieldAccessPolicy::AccessRestriction> accessRestriction(new FieldAccessPolicy::AccessRestriction());\n    QSharedPointer<FieldAccessPolicy::AccessRestriction> accessRestriction2(new FieldAccessPolicy::AccessRestriction());\n    \n    QSharedPointer<ModeReference> modeRef(new ModeReference());\n    QSharedPointer<ModeReference> modeRef2(new ModeReference());\n    \n    accessRestriction->modeRefs_->append(modeRef);\n    accessRestriction2->modeRefs_->append(modeRef2);\n\n    fieldAccessPolicy_->getAccessRestrictions()->append(accessRestriction);\n    fieldAccessPolicy_->getAccessRestrictions()->append(accessRestriction2);\n\n    QSharedPointer<QList<QSharedPointer<Mode> > > availableModes(new QList<QSharedPointer<Mode> >());\n    availableModes->append(QSharedPointer<Mode>(new Mode(\"testMode\")));\n    availableModes->append(QSharedPointer<Mode>(new Mode(\"testMode2\")));\n\n    // No mode references set -> error\n    QStringList errors;\n    validator_.findErrorsIn(errors, fieldAccessPolicy_, \"test\", availableModes);\n    QCOMPARE(errors.size(), 1);\n    \n    errors.clear();\n\n    // Duplicate modes in any of the access restrictions -> error\n    modeRef->setReference(\"testMode\");\n    modeRef->setPriority(0);\n    \n    modeRef2->setReference(\"testMode\");\n    modeRef2->setPriority(1);\n\n    validator_.findErrorsIn(errors, fieldAccessPolicy_, \"test\", availableModes);\n    QCOMPARE(errors.size(), 1);\n    \n    errors.clear();\n    modeRef2->setReference(\"testMode2\");\n\n    // Invalid bit expressions in read/write access masks -> error\n    accessRestriction->readAccessMask_ = QString(\"'b1100\");\n    accessRestriction2->readAccessMask_ = QString(\"etsdfasd\"); // Not valid\n    \n    accessRestriction->writeAccessMask_ = QString(\"asdasd\"); // Not valid\n    accessRestriction2->writeAccessMask_ = QString(\"2'b11\");\n\n    validator_.findErrorsIn(errors, fieldAccessPolicy_, \"test\", availableModes);\n    QCOMPARE(errors.size(), 2);\n\n    errors.clear();\n    accessRestriction2->readAccessMask_ = QString(\"'h2\");\n    accessRestriction->writeAccessMask_ = QString(\"'b1111\");\n\n    validator_.findErrorsIn(errors, fieldAccessPolicy_, \"test\", availableModes);\n    QCOMPARE(errors.size(), 0);\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_FieldAccessPolicyValidator::testReserved()\n//-----------------------------------------------------------------------------\nvoid tst_FieldAccessPolicyValidator::testReserved()\n{\n    QFETCH(QString, reserved);\n    QFETCH(bool, isValid);\n\n    fieldAccessPolicy_->setReserved(reserved);\n\n    QCOMPARE(validator_.hasValidReserved(fieldAccessPolicy_), isValid);\n\n    if (!isValid)\n    {\n        QStringList foundErrors;\n        validator_.findErrorsIn(foundErrors, fieldAccessPolicy_, \"test\", QSharedPointer<QList<QSharedPointer<Mode> > >());\n\n        QString expectedError = QObject::tr(\"Invalid reserved set for field access policy within %1\").arg(\"test\");\n        if (errorIsNotFoundInErrorList(expectedError, foundErrors))\n        {\n            QFAIL(\"No error message found\");\n        }\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_FieldAccessPolicyValidator::testReserved_data()\n//-----------------------------------------------------------------------------\nvoid tst_FieldAccessPolicyValidator::testReserved_data()\n{\n    QTest::addColumn<QString>(\"reserved\");\n    QTest::addColumn<bool>(\"isValid\");\n\n    QTest::newRow(\"Empty reserved value is valid\") << \"\" << true;\n    QTest::newRow(\"White space is invalid reserved value\") << \"   \" << false;\n    QTest::newRow(\"10 is invalid reserved value\") << \"10\" << false;\n    QTest::newRow(\"4+5*3-20/2-8 is valid reserved value\") << \"4+5*3-20/2-8\" << true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_FieldAccessPolicyValidator::errorIsNotFoundInErrorList()\n//-----------------------------------------------------------------------------\nbool tst_FieldAccessPolicyValidator::errorIsNotFoundInErrorList(QString const& expectedError, QStringList errorList)\n{\n    if (!errorList.contains(expectedError))\n    {\n        qDebug() << \"The following error:\" << Qt::endl << expectedError << Qt::endl << \"was not found in errorlist:\";\n        for (QString const& error : errorList)\n        {\n            qDebug() << error;\n        }\n        return true;\n    }\n\n    return false;\n}\n\n\nQTEST_APPLESS_MAIN(tst_FieldAccessPolicyValidator)\n\n#include \"tst_FieldAccessPolicyValidator.moc\"\n"
  },
  {
    "path": "tests/IPXACTmodels/Component/tst_FieldAccessPolicyValidator.pri",
    "content": "# ----------------------------------------------------\n# This file is generated by the Qt Visual Studio Tools.\n# ------------------------------------------------------\n\nSOURCES += ./tst_FieldAccessPolicyValidator.cpp\n"
  },
  {
    "path": "tests/IPXACTmodels/Component/tst_FieldAccessPolicyValidator.pro",
    "content": "#-----------------------------------------------------------------------------\n# File: tst_FieldAccessPolicyValidator.pro\n#-----------------------------------------------------------------------------\n# Project: Kactus 2\n# Author: Anton Hagqvist\n# Date: 2.8s.2023\n#\n# Description:\n# Qt project file template for running unit tests for FieldAccessPolicyValidator.\n#-----------------------------------------------------------------------------\n\nTEMPLATE = app\n\nTARGET = tst_FieldAccessPolicyValidator\n\nQT += core xml testlib\nQT -= gui\n\nCONFIG += c++11 testcase console\n\nlinux-g++ | linux-g++-64 | linux-g++-32 {\n LIBS += -L../../../executable \\\n     -lIPXACTmodels \\\n     -lKactusAPI\n\n}\nwin64 | win32 {\n LIBS += -L../../../executable \\\n     -lIPXACTmodelsd \\\n     -lKactusAPId\n}\n\nINCLUDEPATH += $$DESTDIR\nINCLUDEPATH += ../../../\n\nDEPENDPATH += .\nDEPENDPATH += ../../../\n\nOBJECTS_DIR += $$DESTDIR\n\nMOC_DIR += ./generatedFiles\nUI_DIR += ./generatedFiles\nRCC_DIR += ./generatedFiles\ninclude(tst_FieldAccessPolicyValidator.pri)\n"
  },
  {
    "path": "tests/IPXACTmodels/Component/tst_FieldAccessPolicyWriter.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: tst_FieldAccessPolicyWriter.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Anton Hagqvist\n// Date: 2.8.2023\n//\n// Description:\n// Unit test for class FieldAccessPolicyWriter>.\n//-----------------------------------------------------------------------------\n\n#include <IPXACTmodels/Component/FieldAccessPolicyWriter.h>\n#include <IPXACTmodels/Component/FieldAccessPolicy.h>\n#include <IPXACTmodels/common/GenericVendorExtension.h>\n\n#include <QtTest>\n#include <QDomDocument>\n\nclass tst_FieldAccessPolicyWriter : public QObject\n{\n    Q_OBJECT\n\npublic:\n    tst_FieldAccessPolicyWriter();\n\nprivate slots:\n\n    void init();\n    void cleanup();\n\n    void writeModeRefs();\n    void writeDefinitionRef();\n    void writeAccess();\n    void writeModifiedWriteValue();\n    void writeValueConstraint();\n    void writeReadAction();\n    void writeReadResponse();\n    void writeBroadcasts();\n    void writeAccessRestrictions();\n    void writeTestable();\n    void writeReserved();\n    void writeVendorExtensions();\n\nprivate:\n    QSharedPointer<FieldAccessPolicy> fieldAccessPolicy_;\n\n};\n\n//-----------------------------------------------------------------------------\n// Function: tst_FieldAccessPolicyWriter::tst_FieldAccessPolicyWriter()\n//-----------------------------------------------------------------------------\ntst_FieldAccessPolicyWriter::tst_FieldAccessPolicyWriter()\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_FieldAccessPolicyWriter::init()\n//-----------------------------------------------------------------------------\nvoid tst_FieldAccessPolicyWriter::init()\n{\n    fieldAccessPolicy_ = QSharedPointer<FieldAccessPolicy>(new FieldAccessPolicy());\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_FieldAccessPolicyWriter::cleanup()\n//-----------------------------------------------------------------------------\nvoid tst_FieldAccessPolicyWriter::cleanup()\n{\n    fieldAccessPolicy_.clear();\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_FieldAccessPolicyWriter::writeModeRefs()\n//-----------------------------------------------------------------------------\nvoid tst_FieldAccessPolicyWriter::writeModeRefs()\n{\n    QSharedPointer<ModeReference> modeRef1(new ModeReference());\n    modeRef1->setPriority(0);\n    modeRef1->setReference(\"testMode1\");\n\n    QSharedPointer<ModeReference> modeRef2(new ModeReference());\n    modeRef2->setPriority(1);\n    modeRef2->setReference(\"testMode2\");\n\n    fieldAccessPolicy_->getModeReferences()->append(modeRef1);\n    fieldAccessPolicy_->getModeReferences()->append(modeRef2);\n\n    QString expectedOutput(\n        \"<ipxact:fieldAccessPolicy>\"\n            \"<ipxact:modeRef priority=\\\"0\\\">testMode1</ipxact:modeRef>\"\n            \"<ipxact:modeRef priority=\\\"1\\\">testMode2</ipxact:modeRef>\"\n        \"</ipxact:fieldAccessPolicy>\"\n    );\n    \n    QString output;\n    QXmlStreamWriter writer(&output);\n\n    FieldAccessPolicyWriter::writeFieldAccessPolicy(writer, fieldAccessPolicy_);\n    QCOMPARE(output, expectedOutput);\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_FieldAccessPolicyWriter::writeDefinitionRef()\n//-----------------------------------------------------------------------------\nvoid tst_FieldAccessPolicyWriter::writeDefinitionRef()\n{\n    fieldAccessPolicy_->setFieldAccessPolicyTypeDefinitionRef(\"testTypeDef\");\n    fieldAccessPolicy_->setFieldAccessPolicyDefinitionRef(\"testFieldAccessPolicy\");\n\n    QString expectedOutput(\n        \"<ipxact:fieldAccessPolicy>\"\n            \"<ipxact:fieldAccessPolicyDefinitionRef typeDefinitions=\\\"testTypeDef\\\">testFieldAccessPolicy\"\n            \"</ipxact:fieldAccessPolicyDefinitionRef>\"\n        \"</ipxact:fieldAccessPolicy>\"\n    );\n    \n    QString output;\n    QXmlStreamWriter writer(&output);\n\n    FieldAccessPolicyWriter::writeFieldAccessPolicy(writer, fieldAccessPolicy_);\n    QCOMPARE(output, expectedOutput);\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_FieldAccessPolicyWriter::writeAccess()\n//-----------------------------------------------------------------------------\nvoid tst_FieldAccessPolicyWriter::writeAccess()\n{\n    fieldAccessPolicy_->setAccess(AccessTypes::READ_WRITE);\n\n    QString expectedOutput(\n        \"<ipxact:fieldAccessPolicy>\"\n            \"<ipxact:access>read-write</ipxact:access>\"\n        \"</ipxact:fieldAccessPolicy>\"\n    );\n\n    QString output;\n    QXmlStreamWriter writer(&output);\n\n    FieldAccessPolicyWriter::writeFieldAccessPolicy(writer, fieldAccessPolicy_);\n    QCOMPARE(output, expectedOutput);\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_FieldAccessPolicyWriter::writeModifiedWriteValue()\n//-----------------------------------------------------------------------------\nvoid tst_FieldAccessPolicyWriter::writeModifiedWriteValue()\n{\n    fieldAccessPolicy_->setModifiedWrite(General::ZERO_TO_CLEAR);\n\n    QString expectedOutput(\n        \"<ipxact:fieldAccessPolicy>\"\n            \"<ipxact:modifiedWriteValue>zeroToClear</ipxact:modifiedWriteValue>\"\n        \"</ipxact:fieldAccessPolicy>\"\n    );\n\n    QString output;\n    QXmlStreamWriter writer(&output);\n\n    FieldAccessPolicyWriter::writeFieldAccessPolicy(writer, fieldAccessPolicy_);\n    QCOMPARE(output, expectedOutput);\n\n    fieldAccessPolicy_->setModifiedWriteModify(\"modifier\");\n    output.clear();\n\n    expectedOutput = \n        \"<ipxact:fieldAccessPolicy>\"\n            \"<ipxact:modifiedWriteValue modify=\\\"modifier\\\">zeroToClear</ipxact:modifiedWriteValue>\"\n        \"</ipxact:fieldAccessPolicy>\"\n        ;\n\n\n    FieldAccessPolicyWriter::writeFieldAccessPolicy(writer, fieldAccessPolicy_);\n    QCOMPARE(output, expectedOutput);\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_FieldAccessPolicyWriter::writeValueConstraint()\n//-----------------------------------------------------------------------------\nvoid tst_FieldAccessPolicyWriter::writeValueConstraint()\n{\n    QSharedPointer<WriteValueConstraint> writeConstraint (new WriteValueConstraint());\n    writeConstraint->setType(WriteValueConstraint::WRITE_AS_READ);\n\n    fieldAccessPolicy_->setWriteValueConstraint(writeConstraint);\n\n    QString expectedOutput(\n        \"<ipxact:fieldAccessPolicy>\"\n            \"<ipxact:writeValueConstraint>\"\n                \"<ipxact:writeAsRead>true</ipxact:writeAsRead>\"\n            \"</ipxact:writeValueConstraint>\"\n        \"</ipxact:fieldAccessPolicy>\"\n        );\n\n    QString output;\n    QXmlStreamWriter writer(&output);\n\n    FieldAccessPolicyWriter::writeFieldAccessPolicy(writer, fieldAccessPolicy_);\n    QCOMPARE(output, expectedOutput);\n\n    output.clear();\n    writeConstraint->setType(WriteValueConstraint::USE_ENUM);\n\n    expectedOutput =\n        \"<ipxact:fieldAccessPolicy>\"\n            \"<ipxact:writeValueConstraint>\"\n                \"<ipxact:useEnumeratedValues>true</ipxact:useEnumeratedValues>\"\n            \"</ipxact:writeValueConstraint>\"\n        \"</ipxact:fieldAccessPolicy>\"\n        ;\n\n    FieldAccessPolicyWriter::writeFieldAccessPolicy(writer, fieldAccessPolicy_);\n    QCOMPARE(output, expectedOutput);\n\n    output.clear();\n    writeConstraint->setMinimum(\"0\");\n    writeConstraint->setMaximum(\"10\");\n\n    expectedOutput =\n        \"<ipxact:fieldAccessPolicy>\"\n            \"<ipxact:writeValueConstraint>\"\n                \"<ipxact:minimum>0</ipxact:minimum>\"\n                \"<ipxact:maximum>10</ipxact:maximum>\"\n            \"</ipxact:writeValueConstraint>\"\n        \"</ipxact:fieldAccessPolicy>\"\n        ;\n\n    FieldAccessPolicyWriter::writeFieldAccessPolicy(writer, fieldAccessPolicy_);\n    QCOMPARE(output, expectedOutput);\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_FieldAccessPolicyWriter::writeReadAction()\n//-----------------------------------------------------------------------------\nvoid tst_FieldAccessPolicyWriter::writeReadAction()\n{\n    fieldAccessPolicy_->setReadAction(General::READ_SET);\n\n    QString expectedOutput(\n        \"<ipxact:fieldAccessPolicy>\"\n            \"<ipxact:readAction>set</ipxact:readAction>\"\n        \"</ipxact:fieldAccessPolicy>\"\n        );\n\n    QString output;\n    QXmlStreamWriter writer(&output);\n\n    FieldAccessPolicyWriter::writeFieldAccessPolicy(writer, fieldAccessPolicy_);\n    QCOMPARE(output, expectedOutput);\n\n    output.clear();\n\n    fieldAccessPolicy_->setReadAction(General::READ_CLEAR);\n    fieldAccessPolicy_->setReadActionModify(\"modifier\");\n\n    expectedOutput =\n        \"<ipxact:fieldAccessPolicy>\"\n            \"<ipxact:readAction modify=\\\"modifier\\\">clear</ipxact:readAction>\"\n        \"</ipxact:fieldAccessPolicy>\"\n        ;\n\n    FieldAccessPolicyWriter::writeFieldAccessPolicy(writer, fieldAccessPolicy_);\n    QCOMPARE(output, expectedOutput);\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_FieldAccessPolicyWriter::writeReadResponse()\n//-----------------------------------------------------------------------------\nvoid tst_FieldAccessPolicyWriter::writeReadResponse()\n{\n    fieldAccessPolicy_->setReadResponse(\"'b10\");\n\n    QString expectedOutput(\n        \"<ipxact:fieldAccessPolicy>\"\n        \"<ipxact:readResponse>'b10</ipxact:readResponse>\"\n        \"</ipxact:fieldAccessPolicy>\"\n    );\n\n    QString output;\n    QXmlStreamWriter writer(&output);\n\n    FieldAccessPolicyWriter::writeFieldAccessPolicy(writer, fieldAccessPolicy_);\n    QCOMPARE(output, expectedOutput);\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_FieldAccessPolicyWriter::writeBroadcasts()\n//-----------------------------------------------------------------------------\nvoid tst_FieldAccessPolicyWriter::writeBroadcasts()\n{\n    QSharedPointer<FieldReference> fieldRef(new FieldReference());\n    QSharedPointer<FieldReference::IndexedReference> testFieldRefElement(new FieldReference::IndexedReference);\n    testFieldRefElement->reference_ = \"testField\";\n    testFieldRefElement->indices_.append(\"1\");\n    \n    fieldRef->setReference(testFieldRefElement, FieldReference::FIELD);\n\n    fieldAccessPolicy_->getBroadcasts()->append(fieldRef);\n\n    QString expectedOutput(\n        \"<ipxact:fieldAccessPolicy>\"\n            \"<ipxact:broadcasts>\"\n                \"<ipxact:broadcastTo>\"\n                    \"<ipxact:fieldRef fieldRef=\\\"testField\\\">\"\n                        \"<ipxact:indices>\"\n                            \"<ipxact:index>1</ipxact:index>\"\n                        \"</ipxact:indices>\"\n                    \"</ipxact:fieldRef>\"\n                \"</ipxact:broadcastTo>\"\n            \"</ipxact:broadcasts>\"\n        \"</ipxact:fieldAccessPolicy>\"\n    );\n\n    QString output;\n    QXmlStreamWriter writer(&output);\n\n    FieldAccessPolicyWriter::writeFieldAccessPolicy(writer, fieldAccessPolicy_);\n    QCOMPARE(output, expectedOutput);\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_FieldAccessPolicyWriter::writeAccessRestrictions()\n//-----------------------------------------------------------------------------\nvoid tst_FieldAccessPolicyWriter::writeAccessRestrictions()\n{\n    QSharedPointer<FieldAccessPolicy::AccessRestriction> accessRestriction(\n        new FieldAccessPolicy::AccessRestriction());\n\n    QSharedPointer<ModeReference> testModeRef(new ModeReference());\n    testModeRef->setPriority(0);\n    testModeRef->setReference(\"modereference\");\n\n    accessRestriction->modeRefs_->append(testModeRef);\n\n    fieldAccessPolicy_->getAccessRestrictions()->append(accessRestriction);\n\n    QString expectedOutput(\n        \"<ipxact:fieldAccessPolicy>\"\n            \"<ipxact:accessRestrictions>\"\n                \"<ipxact:accessRestriction>\"\n                    \"<ipxact:modeRef priority=\\\"0\\\">modereference</ipxact:modeRef>\"\n                \"</ipxact:accessRestriction>\"\n            \"</ipxact:accessRestrictions>\"\n        \"</ipxact:fieldAccessPolicy>\"\n    );\n\n    QString output;\n    QXmlStreamWriter writer(&output);\n\n    FieldAccessPolicyWriter::writeFieldAccessPolicy(writer, fieldAccessPolicy_);\n    QCOMPARE(output, expectedOutput);\n\n    output.clear();\n    accessRestriction->readAccessMask_ = \"'b11\";\n    expectedOutput =\n        \"<ipxact:fieldAccessPolicy>\"\n            \"<ipxact:accessRestrictions>\"\n                \"<ipxact:accessRestriction>\"\n                    \"<ipxact:modeRef priority=\\\"0\\\">modereference</ipxact:modeRef>\"\n                    \"<ipxact:readAccessMask>'b11</ipxact:readAccessMask>\"\n                \"</ipxact:accessRestriction>\"\n            \"</ipxact:accessRestrictions>\"\n        \"</ipxact:fieldAccessPolicy>\"\n        ;\n\n    FieldAccessPolicyWriter::writeFieldAccessPolicy(writer, fieldAccessPolicy_);\n    QCOMPARE(output, expectedOutput);\n\n    output.clear();\n    accessRestriction->writeAccessMask_ = \"'b00\";\n    expectedOutput =\n        \"<ipxact:fieldAccessPolicy>\"\n            \"<ipxact:accessRestrictions>\"\n                \"<ipxact:accessRestriction>\"\n                    \"<ipxact:modeRef priority=\\\"0\\\">modereference</ipxact:modeRef>\"\n                    \"<ipxact:readAccessMask>'b11</ipxact:readAccessMask>\"\n                    \"<ipxact:writeAccessMask>'b00</ipxact:writeAccessMask>\"\n                \"</ipxact:accessRestriction>\"\n            \"</ipxact:accessRestrictions>\"\n        \"</ipxact:fieldAccessPolicy>\"\n        ;\n\n    FieldAccessPolicyWriter::writeFieldAccessPolicy(writer, fieldAccessPolicy_);\n    QCOMPARE(output, expectedOutput);\n\n    output.clear();\n    QSharedPointer<FieldAccessPolicy::AccessRestriction> otherAccessRestriction(\n        new FieldAccessPolicy::AccessRestriction(*accessRestriction));\n\n    otherAccessRestriction->modeRefs_->clear();\n    otherAccessRestriction->readAccessMask_.clear();\n    otherAccessRestriction->writeAccessMask_ = \"'b11\";\n\n    fieldAccessPolicy_->getAccessRestrictions()->append(otherAccessRestriction);\n\n    expectedOutput =\n        \"<ipxact:fieldAccessPolicy>\"\n            \"<ipxact:accessRestrictions>\"\n                \"<ipxact:accessRestriction>\"\n                    \"<ipxact:modeRef priority=\\\"0\\\">modereference</ipxact:modeRef>\"\n                    \"<ipxact:readAccessMask>'b11</ipxact:readAccessMask>\"\n                    \"<ipxact:writeAccessMask>'b00</ipxact:writeAccessMask>\"\n                \"</ipxact:accessRestriction>\"\n                \"<ipxact:accessRestriction>\"\n                    \"<ipxact:writeAccessMask>'b11</ipxact:writeAccessMask>\"\n                \"</ipxact:accessRestriction>\"\n            \"</ipxact:accessRestrictions>\"\n        \"</ipxact:fieldAccessPolicy>\"\n        ;\n\n    FieldAccessPolicyWriter::writeFieldAccessPolicy(writer, fieldAccessPolicy_);\n    QCOMPARE(output, expectedOutput);\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_FieldAccessPolicyWriter::writeTestable()\n//-----------------------------------------------------------------------------\nvoid tst_FieldAccessPolicyWriter::writeTestable()\n{\n    QString output;\n    QXmlStreamWriter writer(&output);\n\n    fieldAccessPolicy_->setTestable(false);\n\n    QString expectedOutput(\n        \"<ipxact:fieldAccessPolicy>\"\n            \"<ipxact:testable>false</ipxact:testable>\"\n        \"</ipxact:fieldAccessPolicy>\"\n        );\n\n    FieldAccessPolicyWriter::writeFieldAccessPolicy(writer, fieldAccessPolicy_);\n    QCOMPARE(output, expectedOutput);\n\n    output.clear();\n\n    fieldAccessPolicy_->setTestable(true);\n    fieldAccessPolicy_->setTestConstraint(General::TEST_RESTORE);\n\n    expectedOutput =\n        \"<ipxact:fieldAccessPolicy>\"\n            \"<ipxact:testable testConstraint=\\\"restore\\\">true</ipxact:testable>\"\n        \"</ipxact:fieldAccessPolicy>\"\n        ;\n\n    FieldAccessPolicyWriter::writeFieldAccessPolicy(writer, fieldAccessPolicy_);\n    QCOMPARE(output, expectedOutput);\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_FieldAccessPolicyWriter::writeReserved()\n//-----------------------------------------------------------------------------\nvoid tst_FieldAccessPolicyWriter::writeReserved()\n{\n    QString output;\n    QXmlStreamWriter writer(&output);\n\n    fieldAccessPolicy_->setReserved(\"reserveWarning\");\n\n    QString expectedOutput(\n        \"<ipxact:fieldAccessPolicy>\"\n            \"<ipxact:reserved>reserveWarning</ipxact:reserved>\"\n        \"</ipxact:fieldAccessPolicy>\"\n        );\n\n    FieldAccessPolicyWriter::writeFieldAccessPolicy(writer, fieldAccessPolicy_);\n    QCOMPARE(output, expectedOutput);\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_FieldAccessPolicyWriter::writeVendorExtensions()\n//-----------------------------------------------------------------------------\nvoid tst_FieldAccessPolicyWriter::writeVendorExtensions()\n{\n    QString output;\n    QXmlStreamWriter writer(&output);\n\n    QDomDocument document;\n    QDomElement extensionNode = document.createElement(\"testExtension\");\n    extensionNode.setAttribute(\"testExtensionAttribute\", \"extension\");\n    extensionNode.appendChild(document.createTextNode(\"testValue\"));\n\n    QSharedPointer<GenericVendorExtension> testExtension(new GenericVendorExtension(extensionNode));\n\n    fieldAccessPolicy_->getVendorExtensions()->append(testExtension);\n\n    QString expectedOutput(\n        \"<ipxact:fieldAccessPolicy>\"\n            \"<ipxact:vendorExtensions>\"\n                \"<testExtension testExtensionAttribute=\\\"extension\\\">testValue</testExtension>\"\n            \"</ipxact:vendorExtensions>\"\n        \"</ipxact:fieldAccessPolicy>\"\n        );\n\n    FieldAccessPolicyWriter::writeFieldAccessPolicy(writer, fieldAccessPolicy_);\n    QCOMPARE(output, expectedOutput);\n}\n\nQTEST_APPLESS_MAIN(tst_FieldAccessPolicyWriter)\n\n#include \"tst_FieldAccessPolicyWriter.moc\"\n"
  },
  {
    "path": "tests/IPXACTmodels/Component/tst_FieldAccessPolicyWriter.pri",
    "content": "# ----------------------------------------------------\n# This file is generated by the Qt Visual Studio Tools.\n# ------------------------------------------------------\n\nSOURCES += ./tst_FieldAccessPolicyWriter.cpp\n"
  },
  {
    "path": "tests/IPXACTmodels/Component/tst_FieldAccessPolicyWriter.pro",
    "content": "#-----------------------------------------------------------------------------\n# File: tst_FieldAccessPolicyWriter.pro\n#-----------------------------------------------------------------------------\n# Project: Kactus 2\n# Author: Anton Hagqvist\n# Date: 2.8s.2023\n#\n# Description:\n# Qt project file template for running unit tests for FieldAccessPolicyWriter.\n#-----------------------------------------------------------------------------\n\nTEMPLATE = app\n\nTARGET = tst_FieldAccessPolicyWriter\n\nQT += core xml testlib\nQT -= gui\n\nCONFIG += c++11 testcase console\n\nlinux-g++ | linux-g++-64 | linux-g++-32 {\n LIBS += -L../../../executable \\\n     -lIPXACTmodels\n\n}\nwin64 | win32 {\n LIBS += -L../../../executable \\\n     -lIPXACTmodelsd\n}\n\nINCLUDEPATH += $$DESTDIR\nINCLUDEPATH += ../../../\n\nDEPENDPATH += .\nDEPENDPATH += ../../../\n\nOBJECTS_DIR += $$DESTDIR\n\nMOC_DIR += ./generatedFiles\nUI_DIR += ./generatedFiles\nRCC_DIR += ./generatedFiles\ninclude(tst_FieldAccessPolicyWriter.pri)\n"
  },
  {
    "path": "tests/IPXACTmodels/Component/tst_FieldReader.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: tst_FieldReader.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: <Name>\r\n// Date: <Date in the format dd.mm.yyyy>\r\n//\r\n// Description:\r\n// Unit test for class FieldReader.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include <IPXACTmodels/common/VendorExtension.h>\r\n#include <IPXACTmodels/common/Document.h>\r\n\r\n#include <IPXACTmodels/Component/FieldReader.h>\r\n#include <IPXACTmodels/Component/Field.h>\r\n#include <IPXACTmodels/Component/MemoryArray.h>\r\n#include <IPXACTmodels/Component/EnumeratedValue.h>\r\n#include <IPXACTmodels/Component/WriteValueConstraint.h>\r\n#include <IPXACTmodels/Component/FieldReset.h>\r\n#include <IPXACTmodels/Component/FieldReference.h>\r\n\r\n#include <QtTest>\r\n\r\nclass tst_FieldReader : public QObject\r\n{\r\n    Q_OBJECT\r\n\r\npublic:\r\n    tst_FieldReader();\r\n\r\nprivate slots:\r\n\r\n    void readSimpleField();\r\n    void readFieldID();\r\n    void readIsPresent();\r\n    void readMemoryArray2022();\r\n    void readFieldDefinitionRef();\r\n    void readResets();\r\n\r\n    void readTypeIdentifier();\r\n    void readVolatile();\r\n    void readFieldReference();\r\n    void readFieldAccessPolicies();\r\n    void readAccess();\r\n    void readEnumeratedValues();\r\n    void readModifiedWritevalue();\r\n    void readWriteValueConstraint();\r\n    void readReadAction();\r\n    void readTestable();\r\n    void readReserved();\r\n\r\n    void readParameters();\r\n\r\n    void readVendorExtensions();\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_FieldReader::tst_FieldReader()\r\n//-----------------------------------------------------------------------------\r\ntst_FieldReader::tst_FieldReader()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_FieldReader::readSimpleField()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_FieldReader::readSimpleField()\r\n{\r\n    QString documentContent(\r\n        \"<ipxact:field>\"\r\n            \"<ipxact:name>testField</ipxact:name>\"\r\n            \"<ipxact:displayName>testDisplay</ipxact:displayName>\"\r\n            \"<ipxact:description>testDescription</ipxact:description>\"\r\n            \"<ipxact:bitOffset>Baldur's</ipxact:bitOffset>\"\r\n            \"<ipxact:bitWidth>Gate</ipxact:bitWidth>\"\r\n        \"</ipxact:field>\"\r\n        );\r\n\r\n    QDomDocument document;\r\n    document.setContent(documentContent);\r\n\r\n    QDomNode fieldNode = document.firstChildElement(\"ipxact:field\");\r\n\r\n    QSharedPointer<Field> testField = FieldReader::createFieldFrom(fieldNode, Document::Revision::Std14);\r\n\r\n    QCOMPARE(testField->name(), QString(\"testField\"));\r\n    QCOMPARE(testField->displayName(), QString(\"testDisplay\"));\r\n    QCOMPARE(testField->description(), QString(\"testDescription\"));\r\n    QCOMPARE(testField->getBitOffset(), QString(\"Baldur's\"));\r\n    QCOMPARE(testField->getBitWidth(), QString(\"Gate\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_FieldReader::readFieldID()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_FieldReader::readFieldID()\r\n{\r\n    QString documentContent(\r\n        \"<ipxact:field fieldID=\\\"AM\\\">\"\r\n            \"<ipxact:name>testField</ipxact:name>\"\r\n            \"<ipxact:bitOffset>Baldur's</ipxact:bitOffset>\"\r\n            \"<ipxact:bitWidth>Gate</ipxact:bitWidth>\"\r\n        \"</ipxact:field>\"\r\n        );\r\n\r\n    QDomDocument document;\r\n    document.setContent(documentContent);\r\n\r\n    QDomNode fieldNode = document.firstChildElement(\"ipxact:field\");\r\n\r\n    QSharedPointer<Field> testField = FieldReader::createFieldFrom(fieldNode, Document::Revision::Std14);\r\n\r\n    QCOMPARE(testField->name(), QString(\"testField\"));\r\n    QCOMPARE(testField->getBitOffset(), QString(\"Baldur's\"));\r\n    QCOMPARE(testField->getBitWidth(), QString(\"Gate\"));\r\n    QCOMPARE(testField->getId(), QString(\"AM\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_FieldReader::readIsPresent()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_FieldReader::readIsPresent()\r\n{\r\n    QString documentContent(\r\n        \"<ipxact:field>\"\r\n            \"<ipxact:name>testField</ipxact:name>\"\r\n            \"<ipxact:isPresent>presence*2</ipxact:isPresent>\"\r\n            \"<ipxact:bitOffset>Baldur's</ipxact:bitOffset>\"\r\n            \"<ipxact:bitWidth>Gate</ipxact:bitWidth>\"\r\n        \"</ipxact:field>\"\r\n        );\r\n\r\n    QDomDocument document;\r\n    document.setContent(documentContent);\r\n\r\n    QDomNode fieldNode = document.firstChildElement(\"ipxact:field\");\r\n\r\n    QSharedPointer<Field> testField = FieldReader::createFieldFrom(fieldNode, Document::Revision::Std14);\r\n\r\n    QCOMPARE(testField->getIsPresent(), QString(\"presence*2\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_FieldReader::readMemoryArray2022()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_FieldReader::readMemoryArray2022()\r\n{\r\n    QString documentContent(\r\n        \"<ipxact:field>\"\r\n            \"<ipxact:name>testField</ipxact:name>\"\r\n            \"<ipxact:bitOffset>Baldur's</ipxact:bitOffset>\"\r\n            \"<ipxact:array>\"\r\n                \"<ipxact:dim indexVar=\\\"i\\\">8</ipxact:dim>\"\r\n                \"<ipxact:bitStride>8</ipxact:bitStride>\"\r\n            \"</ipxact:array>\"\r\n            \"<ipxact:bitWidth>Gate</ipxact:bitWidth>\"\r\n        \"</ipxact:field>\"\r\n        );\r\n\r\n    QDomDocument document;\r\n    document.setContent(documentContent);\r\n\r\n    QDomNode fieldNode = document.firstChildElement(\"ipxact:field\");\r\n\r\n    QSharedPointer<Field> testField = FieldReader::createFieldFrom(fieldNode, Document::Revision::Std22);\r\n\r\n    auto memArray = testField->getMemoryArray();\r\n    auto dimension = memArray->getDimensions()->first();\r\n    auto bitStride = memArray->getStride();\r\n\r\n    QCOMPARE(dimension->value_, QString(\"8\"));\r\n    QCOMPARE(dimension->indexVar_, QString(\"i\"));\r\n    QCOMPARE(bitStride, QString(\"8\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_FieldReader::readFieldDefinitionRef()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_FieldReader::readFieldDefinitionRef()\r\n{\r\n    QString documentContent(\r\n        \"<ipxact:field>\"\r\n            \"<ipxact:name>testField</ipxact:name>\"\r\n            \"<ipxact:isPresent>presence*2</ipxact:isPresent>\"\r\n            \"<ipxact:bitOffset>Baldur's</ipxact:bitOffset>\"\r\n            \"<ipxact:fieldDefinitionRef typeDefinitions=\\\"testTypeDefinition\\\">TESTDEF</ipxact:fieldDefinitionRef>\"\r\n        \"</ipxact:field>\"\r\n        );\r\n\r\n    QDomDocument document;\r\n    document.setContent(documentContent);\r\n\r\n    QDomNode fieldNode = document.firstChildElement(\"ipxact:field\");\r\n\r\n    QSharedPointer<Field> testField = FieldReader::createFieldFrom(fieldNode, Document::Revision::Std22);\r\n\r\n    QCOMPARE(testField->getFieldDefinitionRef(), QString(\"TESTDEF\"));\r\n    QCOMPARE(testField->getTypeDefinitionsRef(), QString(\"testTypeDefinition\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_FieldReader::readResets()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_FieldReader::readResets()\r\n{\r\n    QString documentContent(\r\n        \"<ipxact:field>\"\r\n            \"<ipxact:name>testField</ipxact:name>\"\r\n            \"<ipxact:bitOffset>Baldur's</ipxact:bitOffset>\"\r\n            \"<ipxact:resets>\"\r\n                \"<ipxact:reset resetTypeRef=\\\"referencedReset\\\">\"\r\n                    \"<ipxact:value>8'b0110_1101</ipxact:value>\"\r\n                    \"<ipxact:mask>8'b1100_0011</ipxact:mask>\"\r\n                \"</ipxact:reset>\"\r\n            \"</ipxact:resets>\"\r\n            \"<ipxact:bitWidth>Gate</ipxact:bitWidth>\"\r\n        \"</ipxact:field>\"\r\n        );\r\n\r\n    QDomDocument document;\r\n    document.setContent(documentContent);\r\n\r\n    QDomNode fieldNode = document.firstChildElement(\"ipxact:field\");\r\n\r\n    QSharedPointer<Field> testField = FieldReader::createFieldFrom(fieldNode, Document::Revision::Std14);\r\n\r\n    QCOMPARE(testField->getResets()->count(), 1);\r\n\r\n    QSharedPointer<FieldReset> testReset = testField->getResets()->first();\r\n    QCOMPARE(testReset->getResetTypeReference(), QString(\"referencedReset\"));\r\n    QCOMPARE(testReset->getResetValue(), QString(\"8'b0110_1101\"));\r\n    QCOMPARE(testReset->getResetMask(), QString(\"8'b1100_0011\"));\r\n\r\n    documentContent =\r\n        \"<ipxact:field>\"\r\n            \"<ipxact:name>testField</ipxact:name>\"\r\n            \"<ipxact:bitOffset>Baldur's</ipxact:bitOffset>\"\r\n            \"<ipxact:resets>\"\r\n                \"<ipxact:reset resetTypeRef=\\\"referencedReset\\\">\"\r\n                    \"<ipxact:value>8'b0110_1101</ipxact:value>\"\r\n                    \"<ipxact:mask>8'b1100_0011</ipxact:mask>\"\r\n                \"</ipxact:reset>\"\r\n                \"<ipxact:reset>\"\r\n                    \"<ipxact:value>8'b0110_0000</ipxact:value>\"\r\n                \"</ipxact:reset>\"\r\n            \"</ipxact:resets>\"\r\n            \"<ipxact:bitWidth>Gate</ipxact:bitWidth>\"\r\n        \"</ipxact:field>\"\r\n        ;\r\n\r\n    document.setContent(documentContent);\r\n    fieldNode = document.firstChildElement(\"ipxact:field\");\r\n    testField = FieldReader::createFieldFrom(fieldNode, Document::Revision::Std14);\r\n\r\n    QCOMPARE(testField->getResets()->count(), 2);\r\n\r\n    QSharedPointer<FieldReset> firstReset = testField->getResets()->first();\r\n    QSharedPointer<FieldReset> lastReset = testField->getResets()->last();\r\n\r\n    QCOMPARE(firstReset->getResetTypeReference(), QString(\"referencedReset\"));\r\n    QCOMPARE(firstReset->getResetValue(), QString(\"8'b0110_1101\"));\r\n    QCOMPARE(firstReset->getResetMask(), QString(\"8'b1100_0011\"));\r\n\r\n    QCOMPARE(lastReset->getResetTypeReference(), QString(\"\"));\r\n    QCOMPARE(lastReset->getResetValue(), QString(\"8'b0110_0000\"));\r\n    QCOMPARE(lastReset->getResetMask(), QString(\"\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_FieldReader::readTypeIdentifier()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_FieldReader::readTypeIdentifier()\r\n{\r\n    QString documentContent(\r\n        \"<ipxact:field>\"\r\n            \"<ipxact:name>testField</ipxact:name>\"\r\n            \"<ipxact:bitOffset>Baldur's</ipxact:bitOffset>\"\r\n            \"<ipxact:typeIdentifier>testTypeIdentifier</ipxact:typeIdentifier>\"\r\n            \"<ipxact:bitWidth>Gate</ipxact:bitWidth>\"\r\n        \"</ipxact:field>\"\r\n        );\r\n\r\n    QDomDocument document;\r\n    document.setContent(documentContent);\r\n\r\n    QDomNode fieldNode = document.firstChildElement(\"ipxact:field\");\r\n\r\n    QSharedPointer<Field> testField = FieldReader::createFieldFrom(fieldNode, Document::Revision::Std14);\r\n\r\n    QCOMPARE(testField->getTypeIdentifier(), QString(\"testTypeIdentifier\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_FieldReader::readVolatile()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_FieldReader::readVolatile()\r\n{\r\n    QString documentContent(\r\n        \"<ipxact:field>\"\r\n            \"<ipxact:name>testField</ipxact:name>\"\r\n            \"<ipxact:bitOffset>Baldur's</ipxact:bitOffset>\"\r\n            \"<ipxact:bitWidth>Gate</ipxact:bitWidth>\"\r\n            \"<ipxact:volatile>true</ipxact:volatile>\"\r\n        \"</ipxact:field>\"\r\n        );\r\n\r\n    QDomDocument document;\r\n    document.setContent(documentContent);\r\n\r\n    QDomNode fieldNode = document.firstChildElement(\"ipxact:field\");\r\n\r\n    QSharedPointer<Field> testField = FieldReader::createFieldFrom(fieldNode, Document::Revision::Std14);\r\n\r\n    QCOMPARE(testField->getVolatile().toString(), QString(\"true\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_FieldReader::readFieldReference()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_FieldReader::readFieldReference()\r\n{\r\n    // Test reading ipxact:aliasOf.\r\n    QString documentContent(\r\n        \"<ipxact:field>\"\r\n            \"<ipxact:name>testField</ipxact:name>\"\r\n            \"<ipxact:bitOffset>Baldur's</ipxact:bitOffset>\"\r\n            \"<ipxact:bitWidth>Gate</ipxact:bitWidth>\"\r\n            \"<ipxact:aliasOf>\"\r\n                \"<ipxact:addressSpaceRef addressSpaceRef=\\\"testAddressSpace\\\"/>\"\r\n                \"<ipxact:memoryMapRef memoryMapRef=\\\"testMemoryMap\\\"/>\"\r\n                \"<ipxact:memoryRemapRef memoryRemapRef=\\\"testMemoryRemap\\\"/>\"\r\n                \"<ipxact:bankRef bankRef=\\\"testBankRef\\\"/>\"\r\n                \"<ipxact:bankRef bankRef=\\\"testBankRef2\\\"/>\"\r\n                \"<ipxact:addressBlockRef addressBlockRef=\\\"testAddressBlock\\\">\"\r\n                    \"<ipxact:indices>\"\r\n                        \"<ipxact:index>1</ipxact:index>\"\r\n                        \"<ipxact:index>2</ipxact:index>\"\r\n                    \"</ipxact:indices>\"\r\n                \"</ipxact:addressBlockRef>\"\r\n                \"<ipxact:registerFileRef registerFileRef=\\\"testRegisterFile\\\">\"\r\n                    \"<ipxact:indices>\"\r\n                        \"<ipxact:index>0</ipxact:index>\"\r\n                        \"<ipxact:index>1</ipxact:index>\"\r\n                    \"</ipxact:indices>\"\r\n                \"</ipxact:registerFileRef>\"\r\n                \"<ipxact:registerFileRef registerFileRef=\\\"testRegisterFile2\\\">\"\r\n                    \"<ipxact:indices>\"\r\n                        \"<ipxact:index>3</ipxact:index>\"\r\n                    \"</ipxact:indices>\"\r\n                \"</ipxact:registerFileRef>\"\r\n                \"<ipxact:registerRef registerRef=\\\"testRegister\\\">\"\r\n                    \"<ipxact:indices>\"\r\n                        \"<ipxact:index>0</ipxact:index>\"\r\n                    \"</ipxact:indices>\"\r\n                \"</ipxact:registerRef>\"\r\n                \"<ipxact:alternateRegisterRef alternateRegisterRef=\\\"testAlternateRegister\\\"/>\"\r\n                \"<ipxact:fieldRef fieldRef=\\\"testField\\\">\"\r\n                    \"<ipxact:indices>\"\r\n                        \"<ipxact:index>6</ipxact:index>\"\r\n                    \"</ipxact:indices>\"\r\n                \"</ipxact:fieldRef>\"\r\n            \"</ipxact:aliasOf>\"\r\n        \"</ipxact:field>\"\r\n        );\r\n\r\n    QDomDocument document;\r\n    document.setContent(documentContent);\r\n\r\n    QDomNode fieldNode = document.firstChildElement(\"ipxact:field\");\r\n\r\n    QSharedPointer<Field> testField = FieldReader::createFieldFrom(fieldNode, Document::Revision::Std22);\r\n\r\n    auto fieldReference = testField->getFieldReference();\r\n\r\n    QCOMPARE(fieldReference->getReference(FieldReference::Type::ADDRESS_SPACE)->reference_, QString(\"testAddressSpace\"));\r\n    QCOMPARE(fieldReference->getReference(FieldReference::Type::MEMORY_MAP)->reference_, QString(\"testMemoryMap\"));\r\n    QCOMPARE(fieldReference->getReference(FieldReference::Type::MEMORY_REMAP)->reference_, QString(\"testMemoryRemap\"));\r\n    \r\n    QCOMPARE(fieldReference->getMultipleReference(FieldReference::Type::BANK)->at(0)->reference_, QString(\"testBankRef\"));\r\n    QCOMPARE(fieldReference->getMultipleReference(FieldReference::Type::BANK)->at(1)->reference_, QString(\"testBankRef2\"));\r\n\r\n    QCOMPARE(fieldReference->getReference(FieldReference::Type::ADDRESS_BLOCK)->reference_, QString(\"testAddressBlock\"));\r\n    QCOMPARE(fieldReference->getReference(FieldReference::Type::ADDRESS_BLOCK)->indices_.first(), QString(\"1\"));\r\n    QCOMPARE(fieldReference->getReference(FieldReference::Type::ADDRESS_BLOCK)->indices_.at(1), QString(\"2\"));\r\n\r\n    QCOMPARE(fieldReference->getMultipleReference(FieldReference::Type::REGISTER_FILE)->first()->reference_, QString(\"testRegisterFile\"));\r\n    QCOMPARE(fieldReference->getMultipleReference(FieldReference::Type::REGISTER_FILE)->first()->indices_.first(), QString(\"0\"));\r\n    QCOMPARE(fieldReference->getMultipleReference(FieldReference::Type::REGISTER_FILE)->first()->indices_.at(1), QString(\"1\"));\r\n\r\n    QCOMPARE(fieldReference->getMultipleReference(FieldReference::Type::REGISTER_FILE)->at(1)->reference_, QString(\"testRegisterFile2\"));\r\n    QCOMPARE(fieldReference->getMultipleReference(FieldReference::Type::REGISTER_FILE)->at(1)->indices_.first(), QString(\"3\"));\r\n\r\n    QCOMPARE(fieldReference->getReference(FieldReference::Type::REGISTER)->reference_, QString(\"testRegister\"));\r\n    QCOMPARE(fieldReference->getReference(FieldReference::Type::REGISTER)->indices_.first(), QString(\"0\"));\r\n\r\n    QCOMPARE(fieldReference->getReference(FieldReference::Type::ALTERNATE_REGISTER)->reference_, QString(\"testAlternateRegister\"));\r\n\r\n    QCOMPARE(fieldReference->getReference(FieldReference::Type::FIELD)->reference_, QString(\"testField\"));\r\n    QCOMPARE(fieldReference->getReference(FieldReference::Type::FIELD)->indices_.first(), QString(\"6\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_FieldReader::readFieldAccessPolicies()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_FieldReader::readFieldAccessPolicies()\r\n{\r\n    QString documentContent(\r\n        \"<ipxact:field>\"\r\n            \"<ipxact:name>testField</ipxact:name>\"\r\n            \"<ipxact:bitOffset>8</ipxact:bitOffset>\"\r\n            \"<ipxact:bitWidth>16</ipxact:bitWidth>\"\r\n            \"<ipxact:fieldAccessPolicies>\"\r\n                \"<ipxact:fieldAccessPolicy>\"\r\n                    \"<ipxact:modeRef priority=\\\"0\\\">testMode</ipxact:modeRef>\"\r\n                    \"<ipxact:fieldAccessPolicyDefinitionRef typeDefinitions=\\\"testDefinition\\\"/>\"\r\n                \"</ipxact:fieldAccessPolicy>\"\r\n            \"</ipxact:fieldAccessPolicies>\"\r\n        \"</ipxact:field>\"\r\n    );\r\n\r\n    QDomDocument document;\r\n    document.setContent(documentContent);\r\n\r\n    QDomNode fieldNode = document.firstChildElement(\"ipxact:field\");\r\n    QSharedPointer<Field> testField = FieldReader::createFieldFrom(fieldNode, Document::Revision::Std22);\r\n\r\n    QCOMPARE(testField->getFieldAccessPolicies()->size(), 1);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_FieldReader::readAccess()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_FieldReader::readAccess()\r\n{\r\n    QString documentContent(\r\n        \"<ipxact:field>\"\r\n            \"<ipxact:name>testField</ipxact:name>\"\r\n            \"<ipxact:bitOffset>Baldur's</ipxact:bitOffset>\"\r\n            \"<ipxact:bitWidth>Gate</ipxact:bitWidth>\"\r\n            \"<ipxact:access>read-write</ipxact:access>\"\r\n        \"</ipxact:field>\"\r\n        );\r\n\r\n    QDomDocument document;\r\n    document.setContent(documentContent);\r\n\r\n    QDomNode fieldNode = document.firstChildElement(\"ipxact:field\");\r\n\r\n    QSharedPointer<Field> testField = FieldReader::createFieldFrom(fieldNode, Document::Revision::Std14);\r\n\r\n    QCOMPARE(testField->getAccess(), AccessTypes::READ_WRITE);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_FieldReader::readEnumeratedValues()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_FieldReader::readEnumeratedValues()\r\n{\r\n    QString documentContent(\r\n        \"<ipxact:field>\"\r\n            \"<ipxact:name>testField</ipxact:name>\"\r\n            \"<ipxact:bitOffset>Baldur's</ipxact:bitOffset>\"\r\n            \"<ipxact:bitWidth>Gate</ipxact:bitWidth>\"\r\n            \"<ipxact:enumeratedValues>\"\r\n                \"<ipxact:enumeratedValue>\"\r\n                    \"<ipxact:name>testEnumeration</ipxact:name>\"\r\n                    \"<ipxact:value>DaiGurren</ipxact:value>\"\r\n                \"</ipxact:enumeratedValue>\"\r\n            \"</ipxact:enumeratedValues>\"\r\n        \"</ipxact:field>\"\r\n        );\r\n\r\n    QDomDocument document;\r\n    document.setContent(documentContent);\r\n\r\n    QDomNode fieldNode = document.firstChildElement(\"ipxact:field\");\r\n\r\n    QSharedPointer<Field> testField = FieldReader::createFieldFrom(fieldNode, Document::Revision::Std14);\r\n\r\n    QCOMPARE(testField->getEnumeratedValues()->size(), 1);\r\n\r\n    QSharedPointer<EnumeratedValue> enumeratedValue = testField->getEnumeratedValues()->first();\r\n    QCOMPARE(enumeratedValue->name(), QString(\"testEnumeration\"));\r\n    QCOMPARE(enumeratedValue->getValue(), QString(\"DaiGurren\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_FieldReader::readModifiedWritevalue()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_FieldReader::readModifiedWritevalue()\r\n{\r\n    QString documentContent(\r\n        \"<ipxact:field>\"\r\n            \"<ipxact:name>testField</ipxact:name>\"\r\n            \"<ipxact:bitOffset>Baldur's</ipxact:bitOffset>\"\r\n            \"<ipxact:bitWidth>Gate</ipxact:bitWidth>\"\r\n            \"<ipxact:modifiedWriteValue>zeroToClear</ipxact:modifiedWriteValue>\"\r\n        \"</ipxact:field>\"\r\n        );\r\n\r\n    QDomDocument document;\r\n    document.setContent(documentContent);\r\n\r\n    QDomNode fieldNode = document.firstChildElement(\"ipxact:field\");\r\n\r\n    QSharedPointer<Field> testField = FieldReader::createFieldFrom(fieldNode, Document::Revision::Std14);\r\n\r\n    QCOMPARE(testField->getModifiedWrite(), General::ZERO_TO_CLEAR);\r\n\r\n    documentContent =\r\n        \"<ipxact:field>\"\r\n            \"<ipxact:name>testField</ipxact:name>\"\r\n            \"<ipxact:bitOffset>Baldur's</ipxact:bitOffset>\"\r\n            \"<ipxact:bitWidth>Gate</ipxact:bitWidth>\"\r\n            \"<ipxact:modifiedWriteValue modify=\\\"modifier\\\">oneToToggle</ipxact:modifiedWriteValue>\"\r\n        \"</ipxact:field>\"\r\n        ;\r\n\r\n    document.setContent(documentContent);\r\n    fieldNode = document.firstChildElement(\"ipxact:field\");\r\n    testField = FieldReader::createFieldFrom(fieldNode, Document::Revision::Std14);\r\n\r\n    QCOMPARE(testField->getModifiedWrite(), General::ONE_TO_TOGGLE);\r\n    QCOMPARE(testField->getModifiedWriteModify(), QString(\"modifier\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_FieldReader::readWriteValueConstraint()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_FieldReader::readWriteValueConstraint()\r\n{\r\n    QString documentContent(\r\n        \"<ipxact:field>\"\r\n            \"<ipxact:name>testField</ipxact:name>\"\r\n            \"<ipxact:bitOffset>Baldur's</ipxact:bitOffset>\"\r\n            \"<ipxact:bitWidth>Gate</ipxact:bitWidth>\"\r\n            \"<ipxact:writeValueConstraint>\"\r\n                \"<ipxact:writeAsRead>true</ipxact:writeAsRead>\"\r\n            \"</ipxact:writeValueConstraint>\"\r\n        \"</ipxact:field>\"\r\n        );\r\n\r\n    QDomDocument document;\r\n    document.setContent(documentContent);\r\n\r\n    QDomNode fieldNode = document.firstChildElement(\"ipxact:field\");\r\n\r\n    QSharedPointer<Field> testField = FieldReader::createFieldFrom(fieldNode, Document::Revision::Std14);\r\n\r\n    QCOMPARE(testField->getWriteConstraint().isNull(), false);\r\n    QCOMPARE(testField->getWriteConstraint()->getType(), WriteValueConstraint::WRITE_AS_READ);\r\n\r\n    documentContent =\r\n        \"<ipxact:field>\"\r\n            \"<ipxact:name>testField</ipxact:name>\"\r\n            \"<ipxact:bitOffset>Baldur's</ipxact:bitOffset>\"\r\n            \"<ipxact:bitWidth>Gate</ipxact:bitWidth>\"\r\n            \"<ipxact:writeValueConstraint>\"\r\n                \"<ipxact:useEnumeratedValues>true</ipxact:useEnumeratedValues>\"\r\n            \"</ipxact:writeValueConstraint>\"\r\n        \"</ipxact:field>\"\r\n        ;\r\n\r\n    document.setContent(documentContent);\r\n    fieldNode = document.firstChildElement(\"ipxact:field\");\r\n    testField = FieldReader::createFieldFrom(fieldNode, Document::Revision::Std14);\r\n\r\n    QCOMPARE(testField->getWriteConstraint().isNull(), false);\r\n    QCOMPARE(testField->getWriteConstraint()->getType(), WriteValueConstraint::USE_ENUM);\r\n\r\n    documentContent =\r\n        \"<ipxact:field>\"\r\n            \"<ipxact:name>testField</ipxact:name>\"\r\n            \"<ipxact:bitOffset>Baldur's</ipxact:bitOffset>\"\r\n            \"<ipxact:bitWidth>Gate</ipxact:bitWidth>\"\r\n            \"<ipxact:writeValueConstraint>\"\r\n                \"<ipxact:minimum>0</ipxact:minimum>\"\r\n                \"<ipxact:maximum>10</ipxact:maximum>\"\r\n            \"</ipxact:writeValueConstraint>\"\r\n        \"</ipxact:field>\"\r\n        ;\r\n\r\n    document.setContent(documentContent);\r\n    fieldNode = document.firstChildElement(\"ipxact:field\");\r\n    testField = FieldReader::createFieldFrom(fieldNode, Document::Revision::Std14);\r\n\r\n    QCOMPARE(testField->getWriteConstraint().isNull(), false);\r\n    QCOMPARE(testField->getWriteConstraint()->getType(), WriteValueConstraint::MIN_MAX);\r\n    QCOMPARE(testField->getWriteConstraint()->getMinimum(), QString(\"0\"));\r\n    QCOMPARE(testField->getWriteConstraint()->getMaximum(), QString(\"10\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_FieldReader::readReadAction()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_FieldReader::readReadAction()\r\n{\r\n    QString documentContent(\r\n        \"<ipxact:field>\"\r\n            \"<ipxact:name>testField</ipxact:name>\"\r\n            \"<ipxact:bitOffset>Baldur's</ipxact:bitOffset>\"\r\n            \"<ipxact:bitWidth>Gate</ipxact:bitWidth>\"\r\n            \"<ipxact:readAction>set</ipxact:readAction>\"\r\n        \"</ipxact:field>\"\r\n        );\r\n\r\n    QDomDocument document;\r\n    document.setContent(documentContent);\r\n\r\n    QDomNode fieldNode = document.firstChildElement(\"ipxact:field\");\r\n\r\n    QSharedPointer<Field> testField = FieldReader::createFieldFrom(fieldNode, Document::Revision::Std14);\r\n\r\n    QCOMPARE(testField->getReadAction(), General::READ_SET);\r\n\r\n    documentContent =\r\n        \"<ipxact:field>\"\r\n            \"<ipxact:name>testField</ipxact:name>\"\r\n            \"<ipxact:bitOffset>Baldur's</ipxact:bitOffset>\"\r\n            \"<ipxact:bitWidth>Gate</ipxact:bitWidth>\"\r\n            \"<ipxact:readAction modify=\\\"modifier\\\">clear</ipxact:readAction>\"\r\n        \"</ipxact:field>\"\r\n        ;\r\n\r\n    document.setContent(documentContent);\r\n    fieldNode = document.firstChildElement(\"ipxact:field\");\r\n    testField = FieldReader::createFieldFrom(fieldNode, Document::Revision::Std14);\r\n\r\n    QCOMPARE(testField->getReadAction(), General::READ_CLEAR);\r\n    QCOMPARE(testField->getReadActionModify(), QString(\"modifier\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_FieldReader::readTestable()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_FieldReader::readTestable()\r\n{\r\n    QString documentContent(\r\n        \"<ipxact:field>\"\r\n            \"<ipxact:name>testField</ipxact:name>\"\r\n            \"<ipxact:bitOffset>Baldur's</ipxact:bitOffset>\"\r\n            \"<ipxact:bitWidth>Gate</ipxact:bitWidth>\"\r\n            \"<ipxact:testable>false</ipxact:testable>\"\r\n        \"</ipxact:field>\"\r\n        );\r\n\r\n    QDomDocument document;\r\n    document.setContent(documentContent);\r\n\r\n    QDomNode fieldNode = document.firstChildElement(\"ipxact:field\");\r\n\r\n    QSharedPointer<Field> testField = FieldReader::createFieldFrom(fieldNode, Document::Revision::Std14);\r\n\r\n    QCOMPARE(testField->getTestable().toString(), QString(\"false\"));\r\n\r\n    documentContent =\r\n        \"<ipxact:field>\"\r\n            \"<ipxact:name>testField</ipxact:name>\"\r\n            \"<ipxact:bitOffset>Baldur's</ipxact:bitOffset>\"\r\n            \"<ipxact:bitWidth>Gate</ipxact:bitWidth>\"\r\n            \"<ipxact:testable testConstraint=\\\"restore\\\">true</ipxact:testable>\"\r\n        \"</ipxact:field>\"\r\n        ;\r\n\r\n    document.setContent(documentContent);\r\n    fieldNode = document.firstChildElement(\"ipxact:field\");\r\n    testField = FieldReader::createFieldFrom(fieldNode, Document::Revision::Std14);\r\n\r\n    QCOMPARE(testField->getTestable().toString(), QString(\"true\"));\r\n    QCOMPARE(testField->getTestConstraint(), General::TEST_RESTORE);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_FieldReader::readReserved()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_FieldReader::readReserved()\r\n{\r\n    QString documentContent(\r\n        \"<ipxact:field>\"\r\n            \"<ipxact:name>testField</ipxact:name>\"\r\n            \"<ipxact:bitOffset>Baldur's</ipxact:bitOffset>\"\r\n            \"<ipxact:bitWidth>Gate</ipxact:bitWidth>\"\r\n            \"<ipxact:reserved>reserveWarning</ipxact:reserved>\"\r\n        \"</ipxact:field>\"\r\n        );\r\n\r\n    QDomDocument document;\r\n    document.setContent(documentContent);\r\n\r\n    QDomNode fieldNode = document.firstChildElement(\"ipxact:field\");\r\n\r\n    QSharedPointer<Field> testField = FieldReader::createFieldFrom(fieldNode, Document::Revision::Std14);\r\n\r\n    QCOMPARE(testField->getReserved(), QString(\"reserveWarning\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_FieldReader::readParameters()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_FieldReader::readParameters()\r\n{\r\n    QString documentContent(\r\n        \"<ipxact:field>\"\r\n            \"<ipxact:name>testField</ipxact:name>\"\r\n            \"<ipxact:bitOffset>Baldur's</ipxact:bitOffset>\"\r\n            \"<ipxact:bitWidth>Gate</ipxact:bitWidth>\"\r\n            \"<ipxact:parameters>\"\r\n                \"<ipxact:parameter parameterId=\\\"testID\\\">\"\r\n                    \"<ipxact:name>testParameter</ipxact:name>\"\r\n                    \"<ipxact:value>1</ipxact:value>\"\r\n                \"</ipxact:parameter>\"\r\n            \"</ipxact:parameters>\"\r\n        \"</ipxact:field>\"\r\n        );\r\n\r\n    QDomDocument document;\r\n    document.setContent(documentContent);\r\n\r\n    QDomNode fieldNode = document.firstChildElement(\"ipxact:field\");\r\n\r\n    QSharedPointer<Field> testField = FieldReader::createFieldFrom(fieldNode, Document::Revision::Std14);\r\n\r\n    QCOMPARE(testField->getParameters()->size(), 1);\r\n    QCOMPARE(testField->getParameters()->first()->name(), QString(\"testParameter\"));\r\n    QCOMPARE(testField->getParameters()->first()->getValue(), QString(\"1\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_FieldReader::readVendorExtensions()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_FieldReader::readVendorExtensions()\r\n{\r\n    QString documentContent(\r\n        \"<ipxact:field>\"\r\n            \"<ipxact:name>testField</ipxact:name>\"\r\n            \"<ipxact:bitOffset>Baldur's</ipxact:bitOffset>\"\r\n            \"<ipxact:bitWidth>Gate</ipxact:bitWidth>\"\r\n            \"<ipxact:vendorExtensions>\"\r\n                \"<testExtension testExtensionAttribute=\\\"extension\\\">testValue</testExtension>\"\r\n            \"</ipxact:vendorExtensions>\"\r\n        \"</ipxact:field>\"\r\n        );\r\n\r\n    QDomDocument document;\r\n    document.setContent(documentContent);\r\n\r\n    QDomNode fieldNode = document.firstChildElement(\"ipxact:field\");\r\n\r\n    QSharedPointer<Field> testField = FieldReader::createFieldFrom(fieldNode, Document::Revision::Std14);\r\n\r\n    QCOMPARE(testField->getVendorExtensions()->size(), 1);\r\n    QCOMPARE(testField->getVendorExtensions()->first()->type(), QString(\"testExtension\"));\r\n}\r\n\r\nQTEST_APPLESS_MAIN(tst_FieldReader)\r\n\r\n#include \"tst_FieldReader.moc\"\r\n"
  },
  {
    "path": "tests/IPXACTmodels/Component/tst_FieldReader.pri",
    "content": "# ----------------------------------------------------\r\n# This file is generated by the Qt Visual Studio Tools.\r\n# ------------------------------------------------------\r\n\r\nSOURCES += ./tst_FieldReader.cpp\r\n"
  },
  {
    "path": "tests/IPXACTmodels/Component/tst_FieldReader.pro",
    "content": "#-----------------------------------------------------------------------------\r\n# File: tst_FieldReader.pro\r\n#-----------------------------------------------------------------------------\r\n# Project: Kactus 2\r\n# Author: Mikko Teuho\r\n# Date: 25.09.2015\r\n#\r\n# Description:\r\n# Qt project file template for running unit tests for FieldReader.\r\n#-----------------------------------------------------------------------------\r\n\r\nTEMPLATE = app\r\n\r\nTARGET = tst_FieldReader\r\n\r\nQT += core xml testlib\r\nQT -= gui\r\n\r\nCONFIG += c++11 testcase console\r\n\r\nlinux-g++ | linux-g++-64 | linux-g++-32 {\r\n LIBS += -L../../../executable \\\r\n     -lIPXACTmodels\r\n\r\n}\r\nwin64 | win32 {\r\n LIBS += -L../../../executable \\\r\n     -lIPXACTmodelsd\r\n}\r\n\r\nINCLUDEPATH += $$DESTDIR\r\nINCLUDEPATH += ../../../\r\n\r\nDEPENDPATH += .\r\nDEPENDPATH += ../../../\r\n\r\nOBJECTS_DIR += $$DESTDIR\r\n\r\nMOC_DIR += ./generatedFiles\r\nUI_DIR += ./generatedFiles\r\nRCC_DIR += ./generatedFiles\r\ninclude(tst_FieldReader.pri)\r\n"
  },
  {
    "path": "tests/IPXACTmodels/Component/tst_FieldReferenceReader.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: tst_FieldReferenceReader.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Anton Hagqvist\n// Date: 1.8.2023\n//\n// Description:\n// Unit test for FieldReferenceReader.\n//-----------------------------------------------------------------------------\n\n#include <IPXACTmodels/Component/FieldReference.h>\n#include <IPXACTmodels/Component/FieldReferenceReader.h>\n\n#include <QtTest>\n#include <QDomDocument>\n\nclass tst_FieldReferenceReader : public QObject\n{\n    Q_OBJECT\n\npublic:\n    tst_FieldReferenceReader();\n\nprivate slots:\n\n    void readFieldReference();\n};\n\n//-----------------------------------------------------------------------------\n// Function: tst_FieldReferenceReader::tst_FieldReferenceReader()\n//-----------------------------------------------------------------------------\ntst_FieldReferenceReader::tst_FieldReferenceReader()\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_FieldReferenceReader::readFieldReference()\n//-----------------------------------------------------------------------------\nvoid tst_FieldReferenceReader::readFieldReference()\n{\n    QString documentContent(\n        \"<ipxact:aliasOf>\"\n            \"<ipxact:addressSpaceRef addressSpaceRef=\\\"testAddressSpace\\\"/>\"\n            \"<ipxact:memoryMapRef memoryMapRef=\\\"testMemoryMap\\\"/>\"\n            \"<ipxact:memoryRemapRef memoryRemapRef=\\\"testMemoryRemap\\\"/>\"\n            \"<ipxact:bankRef bankRef=\\\"testBankRef\\\"/>\"\n            \"<ipxact:bankRef bankRef=\\\"testBankRef2\\\"/>\"\n            \"<ipxact:addressBlockRef addressBlockRef=\\\"testAddressBlock\\\">\"\n                \"<ipxact:indices>\"\n                    \"<ipxact:index>1</ipxact:index>\"\n                    \"<ipxact:index>2</ipxact:index>\"\n                \"</ipxact:indices>\"\n            \"</ipxact:addressBlockRef>\"\n            \"<ipxact:registerFileRef registerFileRef=\\\"testRegisterFile\\\">\"\n                \"<ipxact:indices>\"\n                    \"<ipxact:index>0</ipxact:index>\"\n                    \"<ipxact:index>1</ipxact:index>\"\n                \"</ipxact:indices>\"\n            \"</ipxact:registerFileRef>\"\n            \"<ipxact:registerFileRef registerFileRef=\\\"testRegisterFile2\\\">\"\n                \"<ipxact:indices>\"\n                    \"<ipxact:index>3</ipxact:index>\"\n                \"</ipxact:indices>\"\n            \"</ipxact:registerFileRef>\"\n            \"<ipxact:registerRef registerRef=\\\"testRegister\\\">\"\n                \"<ipxact:indices>\"\n                    \"<ipxact:index>0</ipxact:index>\"\n                \"</ipxact:indices>\"\n            \"</ipxact:registerRef>\"\n            \"<ipxact:alternateRegisterRef alternateRegisterRef=\\\"testAlternateRegister\\\"/>\"\n            \"<ipxact:fieldRef fieldRef=\\\"testField\\\">\"\n                \"<ipxact:indices>\"\n                    \"<ipxact:index>6</ipxact:index>\"\n                \"</ipxact:indices>\"\n            \"</ipxact:fieldRef>\"\n        \"</ipxact:aliasOf>\"\n    );\n\n    QDomDocument document;\n    document.setContent(documentContent);\n\n    QDomNode startNode = document.firstChildElement(\"ipxact:aliasOf\");\n\n    auto fieldReference = FieldReferenceReader::createFieldReferenceFrom(startNode);\n\n    QCOMPARE(fieldReference->getReference(FieldReference::Type::ADDRESS_SPACE)->reference_, QString(\"testAddressSpace\"));\n    QCOMPARE(fieldReference->getReference(FieldReference::Type::MEMORY_MAP)->reference_, QString(\"testMemoryMap\"));\n    QCOMPARE(fieldReference->getReference(FieldReference::Type::MEMORY_REMAP)->reference_, QString(\"testMemoryRemap\"));\n\n    QCOMPARE(fieldReference->getMultipleReference(FieldReference::Type::BANK)->at(0)->reference_, QString(\"testBankRef\"));\n    QCOMPARE(fieldReference->getMultipleReference(FieldReference::Type::BANK)->at(1)->reference_, QString(\"testBankRef2\"));\n\n    QCOMPARE(fieldReference->getReference(FieldReference::Type::ADDRESS_BLOCK)->reference_, QString(\"testAddressBlock\"));\n    QCOMPARE(fieldReference->getReference(FieldReference::Type::ADDRESS_BLOCK)->indices_.first(), QString(\"1\"));\n    QCOMPARE(fieldReference->getReference(FieldReference::Type::ADDRESS_BLOCK)->indices_.at(1), QString(\"2\"));\n\n    QCOMPARE(fieldReference->getMultipleReference(FieldReference::Type::REGISTER_FILE)->first()->reference_, QString(\"testRegisterFile\"));\n    QCOMPARE(fieldReference->getMultipleReference(FieldReference::Type::REGISTER_FILE)->first()->indices_.first(), QString(\"0\"));\n    QCOMPARE(fieldReference->getMultipleReference(FieldReference::Type::REGISTER_FILE)->first()->indices_.at(1), QString(\"1\"));\n\n    QCOMPARE(fieldReference->getMultipleReference(FieldReference::Type::REGISTER_FILE)->at(1)->reference_, QString(\"testRegisterFile2\"));\n    QCOMPARE(fieldReference->getMultipleReference(FieldReference::Type::REGISTER_FILE)->at(1)->indices_.first(), QString(\"3\"));\n\n    QCOMPARE(fieldReference->getReference(FieldReference::Type::REGISTER)->reference_, QString(\"testRegister\"));\n    QCOMPARE(fieldReference->getReference(FieldReference::Type::REGISTER)->indices_.first(), QString(\"0\"));\n\n    QCOMPARE(fieldReference->getReference(FieldReference::Type::ALTERNATE_REGISTER)->reference_, QString(\"testAlternateRegister\"));\n\n    QCOMPARE(fieldReference->getReference(FieldReference::Type::FIELD)->reference_, QString(\"testField\"));\n    QCOMPARE(fieldReference->getReference(FieldReference::Type::FIELD)->indices_.first(), QString(\"6\"));\n}\n\nQTEST_APPLESS_MAIN(tst_FieldReferenceReader)\n\n#include \"tst_FieldReferenceReader.moc\"\n"
  },
  {
    "path": "tests/IPXACTmodels/Component/tst_FieldReferenceReader.pri",
    "content": "# ----------------------------------------------------\n# This file is generated by the Qt Visual Studio Tools.\n# ------------------------------------------------------\n\nSOURCES += ./tst_FieldReferenceReader.cpp\n"
  },
  {
    "path": "tests/IPXACTmodels/Component/tst_FieldReferenceReader.pro",
    "content": "#-----------------------------------------------------------------------------\n# File: tst_FieldReferenceReader.pro\n#-----------------------------------------------------------------------------\n# Project: Kactus 2\n# Author: Anton Hagqvist\n# Date: 1.8.2023\n#\n# Description:\n# Qt project file template for running unit tests for FieldReferenceReader.\n#-----------------------------------------------------------------------------\n\nTEMPLATE = app\n\nTARGET = tst_FieldReferenceReader\n\nQT += core xml testlib\nQT -= gui\n\nCONFIG += c++11 testcase console\n\nlinux-g++ | linux-g++-64 | linux-g++-32 {\n LIBS += -L../../../executable \\\n     -lIPXACTmodels\n\n}\nwin64 | win32 {\n LIBS += -L../../../executable \\\n     -lIPXACTmodelsd\n}\n\nINCLUDEPATH += $$DESTDIR\nINCLUDEPATH += ../../../\n\nDEPENDPATH += .\nDEPENDPATH += ../../../\n\nOBJECTS_DIR += $$DESTDIR\n\nMOC_DIR += ./generatedFiles\nUI_DIR += ./generatedFiles\nRCC_DIR += ./generatedFiles\ninclude(tst_FieldReferenceReader.pri)\n"
  },
  {
    "path": "tests/IPXACTmodels/Component/tst_FieldReferenceValidator.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: tst_FieldReferenceValidator.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Anton Hagqvist\n// Date: 3.8.2023\n//\n// Description:\n// Unit test for FieldReferenceValidator.\n//-----------------------------------------------------------------------------\n\n#include <IPXACTmodels/Component/FieldReference.h>\n#include <IPXACTmodels/Component/validators/FieldReferenceValidator.h>\n\n#include <QtTest>\n\nclass tst_FieldReferenceValidator : public QObject\n{\n    Q_OBJECT\n\npublic:\n    tst_FieldReferenceValidator();\n\nprivate slots:\n\n    void testValidateFieldReference();\n};\n\n//-----------------------------------------------------------------------------\n// Function: tst_FieldReferenceValidator::tst_FieldReferenceValidator()\n//-----------------------------------------------------------------------------\ntst_FieldReferenceValidator::tst_FieldReferenceValidator()\n{\n    \n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_FieldReferenceValidator::testValidateFieldReference()\n//-----------------------------------------------------------------------------\nvoid tst_FieldReferenceValidator::testValidateFieldReference()\n{\n    QSharedPointer<FieldReference> testReference(new FieldReference());\n\n    QSharedPointer<FieldReference::IndexedReference> addressSpaceRef(\n        new FieldReference::IndexedReference(QString(\"testAddressSpace\"), QList<QString>()));\n\n    QSharedPointer<FieldReference::IndexedReference> memoryMapRef(\n        new FieldReference::IndexedReference(QString(\"testMemoryMap\"), QList<QString>()));\n\n    testReference->setReference(addressSpaceRef, FieldReference::ADDRESS_SPACE);\n    testReference->setReference(memoryMapRef, FieldReference::MEMORY_MAP);\n    \n    QStringList errors;\n    FieldReferenceValidator::findErrorsIn(errors, testReference, \"\");\n    \n    QCOMPARE(errors.size(), 2); // address space and memory map, no field ref\n    QVERIFY(FieldReferenceValidator::validate(testReference) == false);\n\n    // Remove memory map ref.\n    testReference->clearReference(FieldReference::MEMORY_MAP);\n    \n    QSharedPointer<FieldReference::IndexedReference> memoryRemapRef(\n        new FieldReference::IndexedReference(QString(\"testMemoryRemap\"), QList<QString>()));\n    testReference->setReference(memoryRemapRef, FieldReference::MEMORY_REMAP);\n\n    errors.clear();\n    FieldReferenceValidator::findErrorsIn(errors, testReference, \"\");\n    QCOMPARE(errors.size(), 2); // address space and memory remap, no field ref\n    QVERIFY(FieldReferenceValidator::validate(testReference) == false);\n\n    // Remove memory remap ref.\n    testReference->clearReference(FieldReference::MEMORY_REMAP);\n    \n    errors.clear();\n    FieldReferenceValidator::findErrorsIn(errors, testReference, \"\");\n    QCOMPARE(errors.size(), 1); //  no field ref\n    QVERIFY(FieldReferenceValidator::validate(testReference) == false);\n\n\n    QSharedPointer<FieldReference::IndexedReference> fieldRef(\n        new FieldReference::IndexedReference(QString(\"testField\"), QList<QString>()));\n    testReference->setReference(fieldRef, FieldReference::FIELD);\n\n    errors.clear();\n    FieldReferenceValidator::findErrorsIn(errors, testReference, \"\");\n    QCOMPARE(errors.size(), 0);\n    QVERIFY(FieldReferenceValidator::validate(testReference));\n}\n\nQTEST_APPLESS_MAIN(tst_FieldReferenceValidator)\n\n#include \"tst_FieldReferenceValidator.moc\"\n"
  },
  {
    "path": "tests/IPXACTmodels/Component/tst_FieldReferenceValidator.pri",
    "content": "# ----------------------------------------------------\n# This file is generated by the Qt Visual Studio Tools.\n# ------------------------------------------------------\n\nSOURCES += ./tst_FieldReferenceValidator.cpp\n"
  },
  {
    "path": "tests/IPXACTmodels/Component/tst_FieldReferenceValidator.pro",
    "content": "#-----------------------------------------------------------------------------\n# File: tst_FieldReferenceValidator.pro\n#-----------------------------------------------------------------------------\n# Project: Kactus 2\n# Author: Anton Hagqvist\n# Date: 1.8.2023\n#\n# Description:\n# Qt project file template for running unit tests for FieldReferenceValidator.\n#-----------------------------------------------------------------------------\n\nTEMPLATE = app\n\nTARGET = tst_FieldReferenceValidator\n\nQT += core xml testlib\nQT -= gui\n\nCONFIG += c++11 testcase console\n\nlinux-g++ | linux-g++-64 | linux-g++-32 {\n LIBS += -L../../../executable \\\n     -lIPXACTmodels\n\n}\nwin64 | win32 {\n LIBS += -L../../../executable \\\n     -lIPXACTmodelsd\n}\n\nINCLUDEPATH += $$DESTDIR\nINCLUDEPATH += ../../../\n\nDEPENDPATH += .\nDEPENDPATH += ../../../\n\nOBJECTS_DIR += $$DESTDIR\n\nMOC_DIR += ./generatedFiles\nUI_DIR += ./generatedFiles\nRCC_DIR += ./generatedFiles\ninclude(tst_FieldReferenceValidator.pri)\n"
  },
  {
    "path": "tests/IPXACTmodels/Component/tst_FieldReferenceWriter.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: tst_FieldReferenceWriter.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Anton Hagqvist\n// Date: 1.8.2023\n//\n// Description:\n// Unit test for FieldReferenceWriter.\n//-----------------------------------------------------------------------------\n\n#include <IPXACTmodels/Component/FieldReference.h>\n#include <IPXACTmodels/Component/FieldReferenceWriter.h>\n\n#include <QtTest>\n#include <QXmlStreamWriter>\n\nclass tst_FieldReferenceWriter : public QObject\n{\n    Q_OBJECT\n\npublic:\n    tst_FieldReferenceWriter();\n\nprivate slots:\n\n    void writeFieldReference();\n};\n\n//-----------------------------------------------------------------------------\n// Function: tst_FieldReferenceWriter::tst_FieldReferenceWriter()\n//-----------------------------------------------------------------------------\ntst_FieldReferenceWriter::tst_FieldReferenceWriter()\n{\n    \n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_FieldReferenceWriter::writeFieldReference()\n//-----------------------------------------------------------------------------\nvoid tst_FieldReferenceWriter::writeFieldReference()\n{\n    QString output;\n    QXmlStreamWriter xmlStreamWriter(&output);\n\n    QSharedPointer<FieldReference> fieldReference(new FieldReference());\n    \n    QSharedPointer<FieldReference::IndexedReference> addressSpace(new FieldReference::IndexedReference(QString(\"testAddressSpace\"), QList<QString>()));\n    fieldReference->setReference(addressSpace, FieldReference::Type::ADDRESS_SPACE);\n\n    QSharedPointer<FieldReference::IndexedReference> memoryMap(new FieldReference::IndexedReference(QString(\"testMemoryMap\"), QList<QString>()));\n    fieldReference->setReference(memoryMap, FieldReference::Type::MEMORY_MAP);\n\n    QSharedPointer<FieldReference::IndexedReference> memoryRemap(new FieldReference::IndexedReference(QString(\"testMemoryRemap\"), QList<QString>()));\n    fieldReference->setReference(memoryRemap, FieldReference::Type::MEMORY_REMAP);\n\n    QSharedPointer<FieldReference::IndexedReference> bank1(new FieldReference::IndexedReference(QString(\"testBank\"), QList<QString>()));\n    fieldReference->setReference(bank1, FieldReference::Type::BANK);\n\n    QSharedPointer<FieldReference::IndexedReference> bank2(new FieldReference::IndexedReference(QString(\"testBank2\"), QList<QString>()));\n    fieldReference->setReference(bank2, FieldReference::Type::BANK);\n\n    QSharedPointer<FieldReference::IndexedReference> addressBlock(new FieldReference::IndexedReference(QString(\"testAddressBlock\"), QList<QString>({ \"0\", \"1\" })));\n    fieldReference->setReference(addressBlock, FieldReference::Type::ADDRESS_BLOCK);\n\n    QSharedPointer<FieldReference::IndexedReference> regFile1(new FieldReference::IndexedReference(QString(\"testRegisterFile1\"), QList<QString>({ \"2\", \"3\" })));\n    fieldReference->setReference(regFile1, FieldReference::Type::REGISTER_FILE);\n\n    QSharedPointer<FieldReference::IndexedReference> regFile2(new FieldReference::IndexedReference(QString(\"testRegisterFile2\"), QList<QString>()));\n    fieldReference->setReference(regFile2, FieldReference::Type::REGISTER_FILE);\n\n    QSharedPointer<FieldReference::IndexedReference> testRegister(new FieldReference::IndexedReference(QString(\"testRegister\"), QList<QString>()));\n    fieldReference->setReference(testRegister, FieldReference::Type::REGISTER);\n\n    QSharedPointer<FieldReference::IndexedReference> alternateRegister(new FieldReference::IndexedReference(QString(\"testAlternateRegister\"), QList<QString>()));\n    fieldReference->setReference(alternateRegister, FieldReference::Type::ALTERNATE_REGISTER);\n\n    QSharedPointer<FieldReference::IndexedReference> field(new FieldReference::IndexedReference(QString(\"testField\"), QList<QString>({ \"8\" })));\n    fieldReference->setReference(field, FieldReference::Type::FIELD);\n\n    QString expectedOutput(\n        \"<ipxact:addressSpaceRef addressSpaceRef=\\\"testAddressSpace\\\"/>\"\n        \"<ipxact:memoryMapRef memoryMapRef=\\\"testMemoryMap\\\"/>\"\n        \"<ipxact:memoryRemapRef memoryRemapRef=\\\"testMemoryRemap\\\"/>\"\n        \"<ipxact:bankRef bankRef=\\\"testBank\\\"/>\"\n        \"<ipxact:bankRef bankRef=\\\"testBank2\\\"/>\"\n        \"<ipxact:addressBlockRef addressBlockRef=\\\"testAddressBlock\\\">\"\n            \"<ipxact:indices>\"\n                \"<ipxact:index>0</ipxact:index>\"\n                \"<ipxact:index>1</ipxact:index>\"\n            \"</ipxact:indices>\"\n        \"</ipxact:addressBlockRef>\"\n        \"<ipxact:registerFileRef registerFileRef=\\\"testRegisterFile1\\\">\"\n            \"<ipxact:indices>\"\n                \"<ipxact:index>2</ipxact:index>\"\n                \"<ipxact:index>3</ipxact:index>\"\n            \"</ipxact:indices>\"\n        \"</ipxact:registerFileRef>\"\n        \"<ipxact:registerFileRef registerFileRef=\\\"testRegisterFile2\\\"/>\"\n        \"<ipxact:registerRef registerRef=\\\"testRegister\\\"/>\"\n        \"<ipxact:alternateRegisterRef alternateRegisterRef=\\\"testAlternateRegister\\\"/>\"\n        \"<ipxact:fieldRef fieldRef=\\\"testField\\\">\"\n            \"<ipxact:indices>\"\n                \"<ipxact:index>8</ipxact:index>\"\n            \"</ipxact:indices>\"\n        \"</ipxact:fieldRef>\"\n    );\n\n    FieldReferenceWriter::writeFieldReference(xmlStreamWriter, fieldReference);\n    QCOMPARE(output, expectedOutput);\n}\n\nQTEST_APPLESS_MAIN(tst_FieldReferenceWriter)\n\n#include \"tst_FieldReferenceWriter.moc\"\n"
  },
  {
    "path": "tests/IPXACTmodels/Component/tst_FieldReferenceWriter.pri",
    "content": "# ----------------------------------------------------\n# This file is generated by the Qt Visual Studio Tools.\n# ------------------------------------------------------\n\nSOURCES += ./tst_FieldReferenceWriter.cpp\n"
  },
  {
    "path": "tests/IPXACTmodels/Component/tst_FieldReferenceWriter.pro",
    "content": "#-----------------------------------------------------------------------------\n# File: tst_FieldReferenceWriter.pro\n#-----------------------------------------------------------------------------\n# Project: Kactus 2\n# Author: Anton Hagqvist\n# Date: 1.8.2023\n#\n# Description:\n# Qt project file template for running unit tests for FieldReferenceReader.\n#-----------------------------------------------------------------------------\n\nTEMPLATE = app\n\nTARGET = tst_FieldReferenceWriter\n\nQT += core xml testlib\nQT -= gui\n\nCONFIG += c++11 testcase console\n\nlinux-g++ | linux-g++-64 | linux-g++-32 {\n LIBS += -L../../../executable \\\n     -lIPXACTmodels\n\n}\nwin64 | win32 {\n LIBS += -L../../../executable \\\n     -lIPXACTmodelsd\n}\n\nINCLUDEPATH += $$DESTDIR\nINCLUDEPATH += ../../../\n\nDEPENDPATH += .\nDEPENDPATH += ../../../\n\nOBJECTS_DIR += $$DESTDIR\n\nMOC_DIR += ./generatedFiles\nUI_DIR += ./generatedFiles\nRCC_DIR += ./generatedFiles\ninclude(tst_FieldReferenceWriter.pri)\n"
  },
  {
    "path": "tests/IPXACTmodels/Component/tst_FieldValidator.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: tst_FieldValidator.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 17.11.2015\r\n//\r\n// Description:\r\n// Unit test for class FieldValidator.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include <IPXACTmodels/common/Parameter.h>\r\n#include <IPXACTmodels/Component/Component.h>\r\n#include <IPXACTmodels/Component/MemoryArray.h>\r\n#include <IPXACTmodels/common/Choice.h>\r\n#include <IPXACTmodels/Component/Field.h>\r\n#include <IPXACTmodels/Component/EnumeratedValue.h>\r\n#include <IPXACTmodels/Component/WriteValueConstraint.h>\r\n#include <IPXACTmodels/Component/ResetType.h>\r\n#include <IPXACTmodels/Component/FieldReset.h>\r\n#include <IPXACTmodels/Component/Mode.h>\r\n\r\n#include <IPXACTmodels/common/validators/ParameterValidator.h>\r\n#include <IPXACTmodels/Component/validators/FieldValidator.h>\r\n#include <IPXACTmodels/Component/validators/EnumeratedValueValidator.h>\r\n\r\n#include <KactusAPI/include/SystemVerilogExpressionParser.h>\r\n\r\n#include <QtTest>\r\n\r\nclass tst_FieldValidator : public QObject\r\n{\r\n    Q_OBJECT\r\n\r\npublic:\r\n    tst_FieldValidator();\r\n\r\nprivate slots:\r\n\r\n    void testNameIsValid();\r\n    void testNameIsValid_data();\r\n\r\n    void testIsPresentIsValid();\r\n    void testIsPresentIsValid_data();\r\n\r\n    void testMemoryArrayIsValid();\r\n    void testMemoryArrayIsValid_data();\r\n\r\n    void testBitOffsetIsValid();\r\n    void testBitOffsetIsValid_data();\r\n\r\n    void testfieldDefinitionRefIsValid();\r\n    void testfieldDefinitionRefIsValid_data();\r\n\r\n    void testResetsAreValid();\r\n    void testResetsAreValid_data();\r\n\r\n    void testResetTypeRefIsValid();\r\n    void testResetTypeRefIsValid_data();\r\n\r\n    void testMultipleResetTypeRefIsValid();\r\n    void testMultipleResetTypeRefIsValid_data();\r\n\r\n    void testWriteValueConstraintIsValid();\r\n    void testWriteValueConstraintIsValid_data();\r\n\r\n    void testReservedIsValid();\r\n    void testReservedIsValid_data();\r\n\r\n    void testBitWidthIsValid();\r\n    void testBitWidthIsValid_data();\r\n\r\n    void testEnumeratedValuesAreValid();\r\n    void testParametersAreValid();\r\n\r\n    void testAccessIsValid();\r\n    void testAccessIsValid_data();\r\n\r\n    void testAccessPolicyModeRefs();\r\n\r\n    // Test field structure validity for new std.\r\n    void testStructureValidity();\r\n\r\nprivate:\r\n\r\n    bool errorIsNotFoundInErrorList(QString const& expectedError, QVector<QString> errorList);\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_FieldValidator::tst_FieldValidator()\r\n//-----------------------------------------------------------------------------\r\ntst_FieldValidator::tst_FieldValidator()\r\n{\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_FieldValidator::testNameIsValid()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_FieldValidator::testNameIsValid()\r\n{\r\n    QFETCH(QString, name);\r\n    QFETCH(bool, isValid);\r\n\r\n    QSharedPointer<Field> testField (new Field(name));\r\n\r\n    QSharedPointer<ExpressionParser> parser(new SystemVerilogExpressionParser());\r\n    QSharedPointer<EnumeratedValueValidator> enumeratedValueValidator (new EnumeratedValueValidator(parser));\r\n    QSharedPointer<ParameterValidator> parameterValidator (\r\n        new ParameterValidator(parser, QSharedPointer<QList<QSharedPointer<Choice> > > (), Document::Revision::Std14));\r\n    FieldValidator validator(parser, enumeratedValueValidator, parameterValidator);\r\n    QCOMPARE(validator.hasValidName(testField), isValid);\r\n\r\n    if (!isValid)\r\n    {\r\n        QVector<QString> foundErrors;\r\n        validator.findErrorsIn(foundErrors, testField, \"test\");\r\n\r\n        QString expectedError = QObject::tr(\"Invalid name specified for %1 within %2\").\r\n            arg(testField->name(), \"test\");\r\n        if (errorIsNotFoundInErrorList(expectedError, foundErrors))\r\n        {\r\n            QFAIL(\"No error message found\");\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_FieldValidator::testNameIsValid_data()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_FieldValidator::testNameIsValid_data()\r\n{\r\n    QTest::addColumn<QString>(\"name\");\r\n    QTest::addColumn<bool>(\"isValid\");\r\n\r\n    QTest::newRow(\"Name test is valid\") << \"test\" << true;\r\n    QTest::newRow(\"Empty name is invalid\") << \"\" << false;\r\n    QTest::newRow(\"Name consisting of only white spaces is invalid\") << \"    \" << false;\r\n    QTest::newRow(\"Name consisting of characters and white spaces is valid\") << \"  test  \" << true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_FieldValidator::testIsPresentIsValid()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_FieldValidator::testIsPresentIsValid()\r\n{\r\n    QFETCH(QString, isPresent);\r\n    QFETCH(bool, isValid);\r\n\r\n    QSharedPointer<Field> testField (new Field());\r\n    testField->setName(\"testField\");\r\n    testField->setIsPresent(isPresent);\r\n\r\n    QSharedPointer<ExpressionParser> parser(new SystemVerilogExpressionParser());\r\n    QSharedPointer<EnumeratedValueValidator> enumeratedValueValidator (new EnumeratedValueValidator(parser));\r\n    QSharedPointer<ParameterValidator> parameterValidator (\r\n        new ParameterValidator(parser, QSharedPointer<QList<QSharedPointer<Choice> > > (), Document::Revision::Std14));\r\n    FieldValidator validator(parser, enumeratedValueValidator, parameterValidator);\r\n    QCOMPARE(validator.hasValidIsPresent(testField), isValid);\r\n\r\n    if (!isValid)\r\n    {\r\n        QVector<QString> foundErrors;\r\n        validator.findErrorsIn(foundErrors, testField, \"test\");\r\n\r\n        QString expectedError = QObject::tr(\"Invalid isPresent value specified for testField within test. \"\r\n            \"Value should evaluate to 0 or 1.\");\r\n        if (errorIsNotFoundInErrorList(expectedError, foundErrors))\r\n        {\r\n            QFAIL(\"No error message found\");\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_FieldValidator::testIsPresentIsValid_data()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_FieldValidator::testIsPresentIsValid_data()\r\n{\r\n    QTest::addColumn<QString>(\"isPresent\");\r\n    QTest::addColumn<bool>(\"isValid\");\r\n\r\n    QTest::newRow(\"IsPresent 1 is valid\") << \"1\" << true;\r\n    QTest::newRow(\"IsPresent 1*3-3 is valid\") << \"1*3-3\" << true;\r\n    QTest::newRow(\"IsPresent 2*100 is invalid\") << \"2*100\" << false;\r\n    QTest::newRow(\"IsPresent -14 is invalid\") << \"-14\" << false;\r\n    QTest::newRow(\"Real number isPresent  0.12 is invalid\") << \"0.12\" << false;\r\n    QTest::newRow(\"Text as isPresent is invalid\") << \"test\" << false;\r\n    QTest::newRow(\"String as isPresent is invalid\") << \"\\\"test\\\"\" << false;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_FieldValidator::testMemoryArrayIsValid()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_FieldValidator::testMemoryArrayIsValid()\r\n{\r\n    QFETCH(QString, dimValue);\r\n    QFETCH(QString, indexVar);\r\n    QFETCH(QString, bitStride);\r\n    QFETCH(bool, isValid);\r\n\r\n    QSharedPointer<Field> testField(new Field());\r\n    testField->setName(\"testField\");\r\n    \r\n    QSharedPointer<MemoryArray> memArray(new MemoryArray());\r\n    QSharedPointer<MemoryArray::Dimension> dim(new MemoryArray::Dimension({ dimValue, indexVar }));\r\n    if (dimValue.isEmpty() == false)\r\n    {\r\n        memArray->getDimensions()->append(dim);\r\n    }\r\n    memArray->setStride(bitStride);\r\n\r\n    testField->setMemoryArray(memArray);\r\n\r\n    QSharedPointer<ExpressionParser> parser(new SystemVerilogExpressionParser());\r\n    QSharedPointer<EnumeratedValueValidator> enumeratedValueValidator(new EnumeratedValueValidator(parser));\r\n    QSharedPointer<ParameterValidator> parameterValidator(\r\n        new ParameterValidator(parser, QSharedPointer<QList<QSharedPointer<Choice> > >(), Document::Revision::Std22));\r\n    FieldValidator validator(parser, enumeratedValueValidator, parameterValidator, Document::Revision::Std22);\r\n\r\n    QCOMPARE(validator.hasValidMemoryArray(testField), isValid);\r\n\r\n    if (!isValid)\r\n    {\r\n        QList<QString> foundErrors;\r\n        validator.findErrorsIn(foundErrors, testField, \"test\");\r\n\r\n        QString expectedError = QObject::tr(\"No dimensions defined for memory array in field testField within test\");\r\n        if (errorIsNotFoundInErrorList(expectedError, foundErrors))\r\n        {\r\n            QFAIL(\"No error message found\");\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_FieldValidator::testMemoryArrayIsValid_data()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_FieldValidator::testMemoryArrayIsValid_data()\r\n{\r\n    QTest::addColumn<QString>(\"dimValue\");\r\n    QTest::addColumn<QString>(\"indexVar\");\r\n    QTest::addColumn<QString>(\"bitStride\");\r\n    QTest::addColumn<bool>(\"isValid\");\r\n\r\n    QTest::newRow(\"Dimension exists is valid\") << \"8\" << \"i\" << \"8\" << true;\r\n    QTest::newRow(\"Dimension doesn't exist is invalid\") << \"\" << \"\" << \"\" << false;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_FieldValidator::testBitOffsetIsValid()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_FieldValidator::testBitOffsetIsValid()\r\n{\r\n    QFETCH(QString, bitOffset);\r\n    QFETCH(bool, isValid);\r\n\r\n    QSharedPointer<Field> testField (new Field());\r\n    testField->setBitOffset(bitOffset);\r\n\r\n    QSharedPointer<ExpressionParser> parser(new SystemVerilogExpressionParser());\r\n    QSharedPointer<EnumeratedValueValidator> enumeratedValueValidator (new EnumeratedValueValidator(parser));\r\n    QSharedPointer<ParameterValidator> parameterValidator (\r\n        new ParameterValidator(parser, QSharedPointer<QList<QSharedPointer<Choice> > > (), Document::Revision::Std14));\r\n    FieldValidator validator(parser, enumeratedValueValidator, parameterValidator);\r\n    QCOMPARE(validator.hasValidBitOffset(testField), isValid);\r\n\r\n    if (!isValid)\r\n    {\r\n        QVector<QString> foundErrors;\r\n        validator.findErrorsIn(foundErrors, testField, \"test\");\r\n\r\n        QString expectedError = QObject::tr(\"Invalid bit offset set for field %1 within %2\").\r\n            arg(testField->name()).arg(\"test\");\r\n        if (errorIsNotFoundInErrorList(expectedError, foundErrors))\r\n        {\r\n            QFAIL(\"No error message found\");\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_FieldValidator::testBitOffsetIsValid_data()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_FieldValidator::testBitOffsetIsValid_data()\r\n{\r\n    QTest::addColumn<QString>(\"bitOffset\");\r\n    QTest::addColumn<bool>(\"isValid\");\r\n\r\n    QTest::newRow(\"Value 1 is valid for bit offset\") << \"1\" << true;\r\n    QTest::newRow(\"Value 0 is valid for bit offset\") << \"0\" << true;\r\n    QTest::newRow(\"Expression 1+1 is valid for bit offset\") << \"1+1\" << true;\r\n    QTest::newRow(\"Negative offset is invalid\") << \"-1\" << false;\r\n    QTest::newRow(\"Negative expression is invalid for bit offset\") << \"2-4\" << false;\r\n    QTest::newRow(\"Empty bit offset is invalid\") << \"\" << false;\r\n    QTest::newRow(\"Text is invalid for bit offset\") << \"test\" << false;\r\n    QTest::newRow(\"String is invalid for bit offset\") << \"\\\"test\\\"\" << false;\r\n\r\n    QTest::newRow(\"Long bit offset is valid\") << \"40000000000\" << true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_FieldValidator::testfieldDefinitionRefIsValid()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_FieldValidator::testfieldDefinitionRefIsValid()\r\n{\r\n    QFETCH(QString, defRef);\r\n    QFETCH(QString, typeDefRef);\r\n    QFETCH(bool, isValid);\r\n\r\n    QSharedPointer<Field> testField(new Field());\r\n    testField->setName(\"testField\");\r\n    testField->setTypeDefinitionsRef(typeDefRef);\r\n    testField->setFieldDefinitionRef(defRef);\r\n\r\n    QSharedPointer<ExpressionParser> parser(new SystemVerilogExpressionParser());\r\n    QSharedPointer<EnumeratedValueValidator> enumeratedValueValidator(new EnumeratedValueValidator(parser));\r\n    QSharedPointer<ParameterValidator> parameterValidator(\r\n        new ParameterValidator(parser, QSharedPointer<QList<QSharedPointer<Choice> > >(), Document::Revision::Std22));\r\n    FieldValidator validator(parser, enumeratedValueValidator, parameterValidator, Document::Revision::Std22);\r\n    QCOMPARE(validator.hasValidFieldDefinitionRef(testField), isValid);\r\n\r\n    if (!isValid)\r\n    {\r\n        QStringList errors;\r\n        validator.findErrorsIn(errors, testField, \"test\");\r\n\r\n        QString expectedError(\"Field testField within test has no typeDefinitions reference \"\r\n            \"defined for field definition reference.\");\r\n\r\n        if (errorIsNotFoundInErrorList(expectedError, errors))\r\n        {\r\n            QFAIL(\"No error message found\");\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_FieldValidator::testfieldDefinitionRefIsValid_data()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_FieldValidator::testfieldDefinitionRefIsValid_data()\r\n{\r\n    QTest::addColumn<QString>(\"defRef\");\r\n    QTest::addColumn<QString>(\"typeDefRef\");\r\n    QTest::addColumn<bool>(\"isValid\");\r\n\r\n    QTest::newRow(\"Missing type definitions ref\") << \"testFieldDef\" << \"\" << false;\r\n    QTest::newRow(\"Both present\") << \"testFieldDef\" << \"testTypeDefinitions\" << true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_FieldValidator::testResetValueIsValid()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_FieldValidator::testResetsAreValid()\r\n{\r\n    QFETCH(QString, resetValue);\r\n    QFETCH(QString, resetMask);\r\n    QFETCH(bool, resetValueIsValid);\r\n    QFETCH(bool, resetMaskIsValid);\r\n\r\n    QSharedPointer<Field> testField (new Field());\r\n    \r\n    QSharedPointer<FieldReset> testReset(new FieldReset());\r\n    testReset->setResetValue(resetValue);\r\n    testReset->setResetMask(resetMask);\r\n    testField->getResets()->append(testReset);\r\n\r\n    QSharedPointer<ExpressionParser> parser(new SystemVerilogExpressionParser());\r\n    QSharedPointer<EnumeratedValueValidator> enumeratedValueValidator (new EnumeratedValueValidator(parser));\r\n    QSharedPointer<ParameterValidator> parameterValidator (\r\n        new ParameterValidator(parser, QSharedPointer<QList<QSharedPointer<Choice> > > (), Document::Revision::Std14));\r\n    FieldValidator validator(parser, enumeratedValueValidator, parameterValidator);\r\n    QCOMPARE(validator.hasValidResetValue(testField->getResets()->first()), resetValueIsValid);\r\n\r\n    if (!resetValueIsValid)\r\n    {\r\n        QVector<QString> foundErrors;\r\n        validator.findErrorsIn(foundErrors, testField, \"test\");\r\n\r\n        QString expectedError = QObject::tr(\"Invalid reset value set within field %1 in %2\").\r\n            arg(testField->name()).arg(\"test\");\r\n        if (errorIsNotFoundInErrorList(expectedError, foundErrors))\r\n        {\r\n            QFAIL(\"No error message found\");\r\n        }\r\n    }\r\n\r\n    QCOMPARE(validator.hasValidResetMask(testField->getResets()->first()), resetMaskIsValid);\r\n    if (!resetMaskIsValid)\r\n    {\r\n        QVector<QString> foundErrors;\r\n        validator.findErrorsIn(foundErrors, testField, \"test\");\r\n\r\n        QString expectedError = QObject::tr(\"Invalid reset mask set within field %1 in %2\").\r\n            arg(testField->name()).arg(\"test\");\r\n        if (errorIsNotFoundInErrorList(expectedError, foundErrors))\r\n        {\r\n            QFAIL(\"No error message found\");\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_FieldValidator::testResetValueIsValid_data()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_FieldValidator::testResetsAreValid_data()\r\n{\r\n    QTest::addColumn<QString>(\"resetValue\");\r\n    QTest::addColumn<QString>(\"resetMask\");\r\n    QTest::addColumn<bool>(\"resetValueIsValid\");\r\n    QTest::addColumn<bool>(\"resetMaskIsValid\");\r\n\r\n    QTest::newRow(\"Bit vector 1 is valid for reset value\") << \"1\" << \"\" << true << true;\r\n    QTest::newRow(\"Empty reset value is valid\") << \"\" << \"\" << true << true;\r\n    QTest::newRow(\"8'b1001_0110 is valid for value and mask\") << \"8'b1001_0110\" << \"8'b1001_0110\" << true << true;\r\n    QTest::newRow(\"Text is invalid\") << \"test\" << \"test\" << false << false;\r\n    QTest::newRow(\"String is invalid\") << \"\\\"test\\\"\" << \"\\\"test\\\"\" << false << false;\r\n    QTest::newRow(\"Reset mask without a reset value is invalid\") << \"\" << \"2'b10\" << false << true;\r\n    QTest::newRow(\"Reset value 14 and mask 2'h2 is valid\") << \"14\" << \"2'h2\" << true << true;\r\n    QTest::newRow(\"White space is invalid for reset value and mask\") << \"  \" << \"   \" << false << false;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_FieldValidator::testResetTypeRefIsValid()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_FieldValidator::testResetTypeRefIsValid()\r\n{\r\n    QFETCH(QString, resetTypeReference);\r\n    QFETCH(bool, buildResetType);\r\n    QFETCH(bool, createResetValue);\r\n    QFETCH(bool, isValid);\r\n\r\n    QSharedPointer<Field> testField(new Field());\r\n    testField->setName(\"TestField\");\r\n\r\n    QSharedPointer<FieldReset> testReset(new FieldReset());\r\n    testReset->setResetTypeReference(resetTypeReference);\r\n\r\n    if (createResetValue)\r\n    {\r\n        testReset->setResetValue(\"1\");\r\n    }\r\n\r\n    testField->getResets()->append(testReset);\r\n\r\n    QSharedPointer<ExpressionParser> parser(new SystemVerilogExpressionParser());\r\n    QSharedPointer<EnumeratedValueValidator> enumeratedValueValidator(new EnumeratedValueValidator(parser));\r\n    QSharedPointer<ParameterValidator> parameterValidator(\r\n        new ParameterValidator(parser, QSharedPointer<QList<QSharedPointer<Choice> > >(), Document::Revision::Std14));\r\n    FieldValidator validator(parser, enumeratedValueValidator, parameterValidator);\r\n\r\n    if (buildResetType)\r\n    {\r\n        QSharedPointer<ResetType> testReset(new ResetType());\r\n        testReset->setName(resetTypeReference);\r\n\r\n        QSharedPointer<QList<QSharedPointer<ResetType> > > componentResets(new QList<QSharedPointer<ResetType> >());\r\n        componentResets->append(testReset);\r\n\r\n        QSharedPointer<Component> newComponent(new Component(VLNV(), Document::Revision::Std14));\r\n        newComponent->setResetTypes(componentResets);\r\n\r\n        validator.componentChange(newComponent);\r\n    }\r\n\r\n    bool resetValueIsValid = validator.hasValidResetValue(testField->getResets()->first());\r\n    bool resetTypeReferenceIsValid = validator.hasValidResetTypeReference(testField->getResets()->first());\r\n    QCOMPARE(resetValueIsValid && resetTypeReferenceIsValid, isValid);\r\n\r\n    if (!isValid)\r\n    {\r\n        QVector<QString> foundErrors;\r\n        validator.findErrorsIn(foundErrors, testField, \"test\");\r\n\r\n        QString expectedError = QObject::tr(\"Invalid reset value set within field %1 in %2\").\r\n            arg(testField->name()).arg(\"test\");\r\n\r\n        if (!buildResetType)\r\n        {\r\n            expectedError = QObject::tr(\"Reset type '%1' referenced in field %2 in test does not exist.\")\r\n                .arg(resetTypeReference).arg(testField->name());\r\n        }\r\n\r\n        if (errorIsNotFoundInErrorList(expectedError, foundErrors))\r\n        {\r\n            QFAIL(\"No error message found\");\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_FieldValidator::testResetTypeRefIsValid_data()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_FieldValidator::testResetTypeRefIsValid_data()\r\n{\r\n    QTest::addColumn<QString>(\"resetTypeReference\");\r\n    QTest::addColumn<bool>(\"buildResetType\");\r\n    QTest::addColumn<bool>(\"createResetValue\");\r\n    QTest::addColumn<bool>(\"isValid\");\r\n\r\n    QTest::newRow(\"Empty reset type reference is valid\") << \"\" << false << true << true;\r\n    QTest::newRow(\"Referencing an existing reset type is valid\") << \"SOFT\" << true << true << true;\r\n    QTest::newRow(\"Referencing a non-existing reset type is not valid\") << \"WRONG\" << false << true << false;\r\n    QTest::newRow(\"Reset type without reset value is not valid\") << \"SOFT\" << true << false << false;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_FieldValidator::testMultipleResetTypeRefIsValid()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_FieldValidator::testMultipleResetTypeRefIsValid()\r\n{\r\n    QFETCH(QString, firstResetReference);\r\n    QFETCH(QString, secondResetReference);\r\n    QFETCH(bool, isValid);\r\n\r\n    QSharedPointer<Field> testField(new Field());\r\n    testField->setName(\"field\");\r\n\r\n    QSharedPointer<FieldReset> firstReset(new FieldReset());\r\n    firstReset->setResetTypeReference(firstResetReference);\r\n    firstReset->setResetValue(\"1\");\r\n\r\n    QSharedPointer<FieldReset> secondReset(new FieldReset());\r\n    secondReset->setResetTypeReference(secondResetReference);\r\n    secondReset->setResetValue(\"0\");\r\n\r\n    testField->getResets()->append(firstReset);\r\n    testField->getResets()->append(secondReset);\r\n\r\n    QSharedPointer<QList<QSharedPointer<ResetType> > > availableResetTypes(\r\n        new QList<QSharedPointer<ResetType> >());\r\n    if (!firstResetReference.isEmpty())\r\n    {\r\n        QSharedPointer<ResetType> firstResetType(new ResetType());\r\n        firstResetType->setName(firstResetReference);\r\n        availableResetTypes->append(firstResetType);\r\n    }\r\n    if (!secondResetReference.isEmpty() && firstResetReference != secondResetReference)\r\n    {\r\n        QSharedPointer<ResetType> secondResetType(new ResetType());\r\n        secondResetType->setName(secondResetReference);\r\n        availableResetTypes->append(secondResetType);\r\n    }\r\n\r\n    QSharedPointer<ExpressionParser> parser(new SystemVerilogExpressionParser());\r\n    QSharedPointer<EnumeratedValueValidator> enumeratedValueValidator(new EnumeratedValueValidator(parser));\r\n    QSharedPointer<ParameterValidator> parameterValidator(\r\n        new ParameterValidator(parser, QSharedPointer<QList<QSharedPointer<Choice> > >(), Document::Revision::Std14));\r\n    FieldValidator validator(parser, enumeratedValueValidator, parameterValidator);\r\n    \r\n    QSharedPointer<Component> dummyComponent(new Component(VLNV(), Document::Revision::Std14));\r\n    dummyComponent->setResetTypes(availableResetTypes);\r\n\r\n    validator.componentChange(dummyComponent);\r\n\r\n    QCOMPARE(validator.hasValidResets(testField), isValid);\r\n    if (!isValid)\r\n    {\r\n        QString context = \"test\";\r\n\r\n        QVector<QString> foundErrors;\r\n        validator.findErrorsIn(foundErrors, testField, context);\r\n\r\n        QString expectedError = QObject::tr(\"Multiple references to default reset type in field %1 in %2.\")\r\n            .arg(testField->name()).arg(context);\r\n\r\n        if (errorIsNotFoundInErrorList(expectedError, foundErrors))\r\n        {\r\n            QFAIL(\"No error message found\");\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_FieldValidator::()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_FieldValidator::testMultipleResetTypeRefIsValid_data()\r\n{\r\n    QTest::addColumn<QString>(\"firstResetReference\");\r\n    QTest::addColumn<QString>(\"secondResetReference\");\r\n    QTest::addColumn<bool>(\"isValid\");\r\n\r\n    QTest::newRow(\"Separate reset type references are valid\") << \"SOFT_1\" << \"SOFT_2\" << true;\r\n    QTest::newRow(\"Same reset type references are valid\") << \"SOFT\" << \"SOFT\" << true;\r\n    QTest::newRow(\"Single empty reset type reference is valid\") << \"\" << \"SOFT\" << true;\r\n    QTest::newRow(\"Multiple empty reset type references is not valid\") << \"\" << \"\" << false;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_FieldValidator::testWriteValueConstraintIsValid()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_FieldValidator::testWriteValueConstraintIsValid()\r\n{\r\n    QFETCH(QString, minimum);\r\n    QFETCH(QString, maximum);\r\n    QFETCH(QString, constraintType);\r\n    QFETCH(bool, isValid);\r\n\r\n    QSharedPointer<WriteValueConstraint> testConstraint(new WriteValueConstraint());\r\n    if (constraintType == QLatin1String(\"writeAsRead\"))\r\n    {\r\n        testConstraint->setType(WriteValueConstraint::WRITE_AS_READ);\r\n    }\r\n    else if (constraintType == QLatin1String(\"useEnumeratedValues\"))\r\n    {\r\n        testConstraint->setType(WriteValueConstraint::USE_ENUM);\r\n    }\r\n    else if (constraintType == QLatin1String(\"minMax\"))\r\n    {\r\n        testConstraint->setMinimum(minimum);\r\n        testConstraint->setMaximum(maximum);\r\n    }\r\n\r\n    QSharedPointer<Field> testField (new Field());\r\n    testField->setWriteConstraint(testConstraint);\r\n\r\n    QSharedPointer<ExpressionParser> parser(new SystemVerilogExpressionParser());\r\n    QSharedPointer<EnumeratedValueValidator> enumeratedValueValidator (new EnumeratedValueValidator(parser));\r\n    QSharedPointer<ParameterValidator> parameterValidator (\r\n        new ParameterValidator(parser, QSharedPointer<QList<QSharedPointer<Choice> > > (), Document::Revision::Std14));\r\n    FieldValidator validator(parser, enumeratedValueValidator, parameterValidator);\r\n    QCOMPARE(validator.hasValidWriteValueConstraint(testField), isValid);\r\n\r\n    if (!isValid)\r\n    {\r\n        QVector<QString> foundErrors;\r\n        validator.findErrorsIn(foundErrors, testField, \"test\");\r\n\r\n        if (testConstraint->getType() == WriteValueConstraint::TYPE_COUNT)\r\n        {\r\n            QString expectedError = QObject::tr(\"Invalid write value constraint set for field %1 within %2\").\r\n                arg(testField->name()).arg(\"test\");\r\n            if (errorIsNotFoundInErrorList(expectedError, foundErrors))\r\n            {\r\n                QFAIL(\"No error message found\");\r\n            }\r\n        }\r\n        else if (testConstraint->getType() == WriteValueConstraint::MIN_MAX)\r\n        {\r\n            int minimumValue = parser->parseExpression(testConstraint->getMinimum()).toInt();\r\n            int maximumValue = parser->parseExpression(testConstraint->getMaximum()).toInt();\r\n\r\n            QString expectedError;\r\n            if (minimumValue > maximumValue)\r\n            {\r\n                expectedError = (QObject::tr(\"Maximum value must be greater than or equal to the minimum value in \"\r\n                    \"write value constraint set for field %1 within %2\").arg(testField->name()).arg(\"test\"));\r\n                if (errorIsNotFoundInErrorList(expectedError, foundErrors))\r\n                {\r\n                    QFAIL(\"No error message found\");\r\n                }\r\n            }\r\n\r\n            QRegularExpression bitExpression(\"^([0-9]+|[1-9]+[0-9]*'([bB][01_]+|[hH][0-9a-fA-F_]+))$\");\r\n            if (!bitExpression.match(testConstraint->getMinimum()).hasMatch() ||\r\n                !bitExpression.match(parser->parseExpression(testConstraint->getMinimum())).hasMatch())\r\n            {\r\n                expectedError = QObject::tr(\r\n                    \"Invalid minimum value set for write value constraint in field %1 within %2\").\r\n                    arg(testField->name()).arg(\"test\");\r\n                if (errorIsNotFoundInErrorList(expectedError, foundErrors))\r\n                {\r\n                    QFAIL(\"No error message found\");\r\n                }\r\n            }\r\n\r\n            if (!bitExpression.match(testConstraint->getMaximum()).hasMatch() ||\r\n                !bitExpression.match(parser->parseExpression(testConstraint->getMaximum())).hasMatch())\r\n            {\r\n                expectedError = QObject::tr(\r\n                    \"Invalid maximum value set for write value constraint in field %1 within %2\").\r\n                    arg(testField->name()).arg(\"test\");\r\n                if (errorIsNotFoundInErrorList(expectedError, foundErrors))\r\n                {\r\n                    QFAIL(\"No error message found\");\r\n                }\r\n            }\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_FieldValidator::testWriteValueConstraintIsValid_data()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_FieldValidator::testWriteValueConstraintIsValid_data()\r\n{\r\n    QTest::addColumn<QString>(\"minimum\");\r\n    QTest::addColumn<QString>(\"maximum\");\r\n    QTest::addColumn<QString>(\"constraintType\");\r\n    QTest::addColumn<bool>(\"isValid\");\r\n\r\n    QTest::newRow(\"No type for write value constraint is invalid\") << \"\" << \"\" << \"\" << false;\r\n    QTest::newRow(\"Write value constraint writeAsRead is valid\") << \"\" << \"\" << \"writeAsRead\" << true;\r\n    QTest::newRow(\"Write value constraint useEnumerated values is valid\") << \"\" << \"\" << \"useEnumeratedValues\" << true;\r\n    QTest::newRow(\"Write value constraint minMax is invalid for empty min and max\") << \"\" << \"\" << \"minMax\" << false;\r\n    QTest::newRow(\"8'b1001_0110 is valid for min and max\") << \"8'b1001_0110\" << \"8'b1001_0110\" << \"minMax\" << true;\r\n    QTest::newRow(\"Text is invalid for min and max\") << \"text\" << \"text\" << \"minMax\" << false;\r\n    QTest::newRow(\"String is invalid for min and max\") << \"\\\"test\\\"\" << \"\\\"test\\\"\" << \"minMax\" << false;\r\n    QTest::newRow(\"Values 14 and 2'h2 are invalid for min and max\") << \"14\" << \"2'h2\" << \"minMax\" << false;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_FieldValidator::testReservedIsValid()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_FieldValidator::testReservedIsValid()\r\n{\r\n    QFETCH(QString, reserved);\r\n    QFETCH(bool, isValid);\r\n\r\n    QSharedPointer<Field> testField (new Field());\r\n    testField->setReserved(reserved);\r\n\r\n    QSharedPointer<ExpressionParser> parser(new SystemVerilogExpressionParser());\r\n    QSharedPointer<EnumeratedValueValidator> enumeratedValueValidator (new EnumeratedValueValidator(parser));\r\n    QSharedPointer<ParameterValidator> parameterValidator (\r\n        new ParameterValidator(parser, QSharedPointer<QList<QSharedPointer<Choice> > > (), Document::Revision::Std14));\r\n    FieldValidator validator(parser, enumeratedValueValidator, parameterValidator);\r\n    QCOMPARE(validator.hasValidReserved(testField), isValid);\r\n\r\n    if (!isValid)\r\n    {\r\n        QVector<QString> foundErrors;\r\n        validator.findErrorsIn(foundErrors, testField, \"test\");\r\n\r\n        QString expectedError = QObject::tr(\"Invalid reserved set for field %1 within %2\").arg(testField->name()).\r\n            arg(\"test\");\r\n        if (errorIsNotFoundInErrorList(expectedError, foundErrors))\r\n        {\r\n            QFAIL(\"No error message found\");\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_FieldValidator::testReservedIsValid_data()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_FieldValidator::testReservedIsValid_data()\r\n{\r\n    QTest::addColumn<QString>(\"reserved\");\r\n    QTest::addColumn<bool>(\"isValid\");\r\n\r\n    QTest::newRow(\"Empty reserved value is valid\") << \"\" << true;\r\n    QTest::newRow(\"White space is invalid reserved value\") << \"   \" << false;\r\n    QTest::newRow(\"10 is invalid reserved value\") << \"10\" << false;\r\n    QTest::newRow(\"4+5*3-20/2-8 is valid reserved value\") << \"4+5*3-20/2-8\" << true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_FieldValidator::testBitWidthIsValid()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_FieldValidator::testBitWidthIsValid()\r\n{\r\n    QFETCH(QString, bitWidth);\r\n    QFETCH(bool, isValid);\r\n\r\n    QSharedPointer<Field> testField (new Field());\r\n    testField->setBitWidth(bitWidth);\r\n\r\n    QSharedPointer<ExpressionParser> parser(new SystemVerilogExpressionParser());\r\n    QSharedPointer<EnumeratedValueValidator> enumeratedValueValidator (new EnumeratedValueValidator(parser));\r\n    QSharedPointer<ParameterValidator> parameterValidator (\r\n        new ParameterValidator(parser, QSharedPointer<QList<QSharedPointer<Choice> > > (), Document::Revision::Std14));\r\n    FieldValidator validator(parser, enumeratedValueValidator, parameterValidator);\r\n    QCOMPARE(validator.hasValidBitWidth(testField), isValid);\r\n\r\n    if (!isValid)\r\n    {\r\n        QVector<QString> foundErrors;\r\n        validator.findErrorsIn(foundErrors, testField, \"test\");\r\n\r\n        QString expectedError = QObject::tr(\"Invalid bit width set for field %1 within %2\").\r\n            arg(testField->name()).arg(\"test\");\r\n        if (errorIsNotFoundInErrorList(expectedError, foundErrors))\r\n        {\r\n            QFAIL(\"No error message found\");\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_FieldValidator::testBitWidthIsValid_data()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_FieldValidator::testBitWidthIsValid_data()\r\n{\r\n    QTest::addColumn<QString>(\"bitWidth\");\r\n    QTest::addColumn<bool>(\"isValid\");\r\n\r\n    QTest::newRow(\"Value 1 is valid for bit width\") << \"1\" << true;\r\n    QTest::newRow(\"Value 0 is invalid for bit width\") << \"0\" << false;\r\n    QTest::newRow(\"Expression 1+1-1 is valid for bit width\") << \"1+1-1\" << true;\r\n    QTest::newRow(\"Negative width is invalid for bit width\") << \"-1\" << false;\r\n    QTest::newRow(\"Negative expression is invalid for bit width\") << \"2-3\" << false;\r\n    QTest::newRow(\"Empty bit width is invalid for bit width\") << \"\" << false;\r\n    QTest::newRow(\"Text is invalid for bit width\") << \"test\" << false;\r\n    QTest::newRow(\"String is invalid for bit width\") << \"\\\"test\\\"\" << false;\r\n\r\n    QTest::newRow(\"Long bit width is valid\") << \"40000000000\" << true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_FieldValidator::testEnumeratedValuesAreValid()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_FieldValidator::testEnumeratedValuesAreValid()\r\n{\r\n    QSharedPointer<ExpressionParser> parser(new SystemVerilogExpressionParser());\r\n    QSharedPointer<EnumeratedValueValidator> enumeratedValueValidator (new EnumeratedValueValidator(parser));\r\n    QSharedPointer<ParameterValidator> parameterValidator (\r\n        new ParameterValidator(parser, QSharedPointer<QList<QSharedPointer<Choice> > > (), Document::Revision::Std14));\r\n    FieldValidator validator(parser, enumeratedValueValidator, parameterValidator);\r\n\r\n    QSharedPointer<EnumeratedValue> enumeratedValue(new EnumeratedValue(\"test\", \"4\"));\r\n\r\n    QSharedPointer<Field> testField (new Field());\r\n    testField->getEnumeratedValues()->append(enumeratedValue);\r\n\r\n    QCOMPARE(validator.hasValidEnumeratedValues(testField), true);\r\n\r\n    QSharedPointer<EnumeratedValue> enumeratedValue2 (new EnumeratedValue(\"\", \"2\"));\r\n    testField->getEnumeratedValues()->append(enumeratedValue2);\r\n\r\n    QCOMPARE(validator.hasValidEnumeratedValues(testField), false);\r\n    \r\n    QVector<QString> errorsFound;\r\n    validator.findErrorsIn(errorsFound, testField, \"test\");\r\n\r\n    QString expectedError = QObject::tr(\"Invalid name specified for %1 within field %2\").\r\n        arg(enumeratedValue2->name()).arg(testField->name());\r\n\r\n    if (errorIsNotFoundInErrorList(expectedError, errorsFound))\r\n    {\r\n        QFAIL(\"Error was not found\");\r\n    }\r\n\r\n    enumeratedValue2->setName(\"other\");\r\n\r\n    QCOMPARE(validator.hasValidEnumeratedValues(testField), true);\r\n\r\n    QSharedPointer<EnumeratedValue> enumeratedValue3(new EnumeratedValue(\"test\", \"1+1\"));\r\n    testField->getEnumeratedValues()->append(enumeratedValue3);\r\n\r\n    QCOMPARE(validator.hasValidEnumeratedValues(testField), false);\r\n\r\n    errorsFound.clear();\r\n    validator.findErrorsIn(errorsFound, testField, \"test\");\r\n    expectedError = QObject::tr(\"Name %1 of enumerated values in field %2 is not unique.\").\r\n        arg(enumeratedValue->name()).arg(testField->name());\r\n\r\n    if (errorIsNotFoundInErrorList(expectedError, errorsFound))\r\n    {\r\n        QFAIL(\"Error was not found\");\r\n    }\r\n\r\n    QSharedPointer<WriteValueConstraint> writeConstaint (new WriteValueConstraint());\r\n    writeConstaint->setType(WriteValueConstraint::USE_ENUM);\r\n    testField->setWriteConstraint(writeConstaint);\r\n\r\n    QCOMPARE(validator.hasValidEnumeratedValues(testField), false);\r\n    errorsFound.clear();\r\n    validator.findErrorsIn(errorsFound, testField, \"test\");\r\n    expectedError = QObject::tr(\"Write value constraint of Use enumerated values needs an enumerated value with \"\r\n        \"usage of write or read-write. Such an enumerated value was not found in field %1\")\r\n        .arg(testField->name());\r\n    if (errorIsNotFoundInErrorList(expectedError, errorsFound))\r\n    {\r\n        QFAIL(\"Error was not found\");\r\n    }\r\n\r\n    enumeratedValue3->setUsage(EnumeratedValue::WRITE);\r\n    enumeratedValue3->setName(\"writeEnumeratedValue\");\r\n    QCOMPARE(validator.hasValidEnumeratedValues(testField), true);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_FieldValidator::testParametersAreValid()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_FieldValidator::testParametersAreValid()\r\n{\r\n    QSharedPointer<Parameter> testParameter (new Parameter());\r\n    testParameter->setValueId(\"Sanger\");\r\n    testParameter->setName(\"Daizengar\");\r\n    testParameter->setValue(\"20\");\r\n    testParameter->setType(\"int\");\r\n\r\n    QSharedPointer<Field> testField (new Field());\r\n    testField->getParameters()->append(testParameter);\r\n\r\n    QSharedPointer<ExpressionParser> parser(new SystemVerilogExpressionParser());\r\n    QSharedPointer<EnumeratedValueValidator> enumeratedValueValidator (new EnumeratedValueValidator(parser));\r\n    QSharedPointer<ParameterValidator> parameterValidator (\r\n        new ParameterValidator(parser, QSharedPointer<QList<QSharedPointer<Choice> > > (), Document::Revision::Std14));\r\n    FieldValidator validator(parser, enumeratedValueValidator, parameterValidator);\r\n    \r\n    QCOMPARE(validator.hasValidParameters(testField), true);\r\n\r\n    testParameter->setValue(\"\");\r\n    QCOMPARE(validator.hasValidParameters(testField), false);\r\n\r\n    QVector<QString> errorsFound;\r\n    validator.findErrorsIn(errorsFound, testField, \"test\");\r\n\r\n    QString expectedError = QObject::tr(\"No value specified for %1 %2 within field %3\").\r\n        arg(testParameter->elementName()).arg(testParameter->name()).arg(testField->name());\r\n\r\n    if (errorIsNotFoundInErrorList(expectedError, errorsFound))\r\n    {\r\n        QFAIL(\"Error was not found\");\r\n    }\r\n\r\n    QSharedPointer<Parameter> otherParameter (new Parameter(*testParameter.data()));\r\n    testParameter->setValue(\"1\");\r\n    otherParameter->setValue(\"2\");\r\n    testField->getParameters()->append(otherParameter);\r\n\r\n    QCOMPARE(validator.hasValidParameters(testField), false);\r\n\r\n    errorsFound.clear();\r\n    validator.findErrorsIn(errorsFound, testField, \"test\");\r\n    expectedError = QObject::tr(\"Name %1 of parameters in field %2 is not unique.\").arg(otherParameter->name()).\r\n        arg(testField->name());\r\n    if (errorIsNotFoundInErrorList(expectedError, errorsFound))\r\n    {\r\n        QFAIL(\"Error was not found\");\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_FieldValidator::testModifiedWriteValue()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_FieldValidator::testAccessIsValid()\r\n{\r\n    QFETCH(QString, accessValue);\r\n    QFETCH(QString, modifiedWriteValue);\r\n    QFETCH(QString, readAction);\r\n    QFETCH(bool, isValid);\r\n\r\n    QSharedPointer<Field> testField (new Field());\r\n    testField->setAccess(AccessTypes::str2Access(accessValue, AccessTypes::ACCESS_COUNT));\r\n    testField->setModifiedWrite(General::str2ModifiedWrite(modifiedWriteValue));\r\n    testField->setReadAction(General::str2ReadAction(readAction));\r\n\r\n    QSharedPointer<ExpressionParser> parser(new SystemVerilogExpressionParser());\r\n    QSharedPointer<EnumeratedValueValidator> enumeratedValueValidator (new EnumeratedValueValidator(parser));\r\n    QSharedPointer<ParameterValidator> parameterValidator (\r\n        new ParameterValidator(parser, QSharedPointer<QList<QSharedPointer<Choice> > > (), Document::Revision::Std14));\r\n    FieldValidator validator(parser, enumeratedValueValidator, parameterValidator);\r\n    QCOMPARE(validator.hasValidAccess(testField), isValid);\r\n\r\n    if (!isValid)\r\n    {\r\n        QVector<QString> foundErrors;\r\n        validator.findErrorsIn(foundErrors, testField, \"test\");\r\n\r\n        if (testField->getAccess() == AccessTypes::READ_ONLY &&\r\n            testField->getModifiedWrite() != General::MODIFIED_WRITE_COUNT)\r\n        {\r\n            QString expectedError = QObject::tr(\"In field %1 within %2, access type readOnly does not allow a field \"\r\n                \"to include a modified write value.\").arg(testField->name()).arg(\"test\");\r\n            if (errorIsNotFoundInErrorList(expectedError, foundErrors))\r\n            {\r\n                QFAIL(\"No error message found\");\r\n            }\r\n        }\r\n        else if ((testField->getAccess() == AccessTypes::WRITE_ONLY ||\r\n            testField->getAccess() == AccessTypes::WRITEONCE) &&\r\n            testField->getReadAction() != General::READ_ACTION_COUNT)\r\n        {\r\n            QString expectedError = QObject::tr(\"In field %1 within %2, access type write only and write once \"\r\n                \"do not allow a field to include a read action value.\").arg(testField->name()).arg(\"test\");\r\n            if (errorIsNotFoundInErrorList(expectedError, foundErrors))\r\n            {\r\n                QFAIL(\"No error message found\");\r\n            }\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_FieldValidator::testModifiedWriteValue_data()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_FieldValidator::testAccessIsValid_data()\r\n{\r\n    QTest::addColumn<QString>(\"accessValue\");\r\n    QTest::addColumn<QString>(\"modifiedWriteValue\");\r\n    QTest::addColumn<QString>(\"readAction\");\r\n    QTest::addColumn<bool>(\"isValid\");\r\n\r\n    QTest::newRow(\"Empty access, modified write value and read action are valid\") << \"\" << \"\" << \"\" << true;\r\n    QTest::newRow(\"Access read-write with a modified write value is valid\") << \"read-write\" << \"oneToClear\" <<\r\n        \"set\" << true;\r\n    QTest::newRow(\"Access read-only with a modified write value is invalid\") << \"read-only\" << \"oneToClear\" <<\r\n        \"set\" << false;\r\n    QTest::newRow(\"Access read-only without modified write value is valid\") << \"read-only\" << \"\" << \"set\" << true;\r\n    QTest::newRow(\"Access write-only with a read action is invalid\") << \"write-only\" << \"\" << \"set\" << false;\r\n    QTest::newRow(\"Access writeOnce with a read action is invalid\") << \"writeOnce\" << \"\" << \"clear\" << false;\r\n    QTest::newRow(\"Access write-only without a read action is valid\") << \"write-only\" << \"oneToClear\" << \"\" << true;\r\n    QTest::newRow(\"Access writeOnce without a read action is valid\") << \"writeOnce\" << \"oneToClear\" << \"\" << true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_FieldValidator::testAccessPolicyModeRefs()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_FieldValidator::testAccessPolicyModeRefs()\r\n{\r\n    QSharedPointer<Field> testField(new Field());\r\n    testField->setName(\"testField\");\r\n    testField->setBitOffset(\"8\");\r\n    testField->setBitWidth(\"8\");\r\n\r\n    QSharedPointer<ModeReference> modeRef1(new ModeReference());\r\n    modeRef1->setPriority(0);\r\n    modeRef1->setReference(\"ref\");\r\n    QSharedPointer<ModeReference> modeRef2(new ModeReference());\r\n    modeRef2->setPriority(0);\r\n    modeRef2->setReference(\"ref1\");\r\n\r\n    QSharedPointer<FieldAccessPolicy> testFieldAccessPolicy(new FieldAccessPolicy());\r\n    QSharedPointer<FieldAccessPolicy> testFieldAccessPolicy2(new FieldAccessPolicy());\r\n    testFieldAccessPolicy->getModeReferences()->append(modeRef1);\r\n    testFieldAccessPolicy2->getModeReferences()->append(modeRef2);\r\n\r\n    testField->getFieldAccessPolicies()->append(testFieldAccessPolicy);\r\n    testField->getFieldAccessPolicies()->append(testFieldAccessPolicy2);\r\n\r\n    QSharedPointer<ExpressionParser> parser(new SystemVerilogExpressionParser());\r\n    QSharedPointer<EnumeratedValueValidator> enumeratedValueValidator(new EnumeratedValueValidator(parser));\r\n    QSharedPointer<ParameterValidator> parameterValidator(\r\n        new ParameterValidator(parser, QSharedPointer<QList<QSharedPointer<Choice> > >(), Document::Revision::Std22));\r\n    FieldValidator validator(parser, enumeratedValueValidator, parameterValidator, Document::Revision::Std22);\r\n\r\n    QSharedPointer<Component> dummyComponent(new Component(VLNV(VLNV::COMPONENT, \"vendor\", \"library\", \"name\", \"1.0\"), Document::Revision::Std22));\r\n    QSharedPointer<Mode> mode1(new Mode(\"ref\"));\r\n    QSharedPointer<Mode> mode2(new Mode(\"ref1\"));\r\n    dummyComponent->getModes()->append(mode1);\r\n    dummyComponent->getModes()->append(mode2);\r\n\r\n    validator.componentChange(dummyComponent);\r\n\r\n    QStringList errors;\r\n    \r\n    // Test duplicate priority.\r\n    validator.findErrorsIn(errors, testField, \"test\");\r\n    QCOMPARE(errors.size(), 1);\r\n    QVERIFY(errors.first().contains(\"duplicate priority\"));\r\n    QVERIFY(validator.hasValidFieldAccessPolicyModeRefs(testField) == false);\r\n\r\n    // Test duplicate reference.\r\n    errors.clear();\r\n\r\n    modeRef2->setPriority(1);\r\n    modeRef2->setReference(\"ref\");\r\n\r\n    validator.findErrorsIn(errors, testField, \"test\");\r\n    QCOMPARE(errors.size(), 1);\r\n    QVERIFY(errors.first().contains(\"duplicate mode reference\"));\r\n    QVERIFY(validator.hasValidFieldAccessPolicyModeRefs(testField) == false);\r\n\r\n    // Test valid.\r\n    errors.clear();\r\n\r\n    modeRef2->setReference(\"ref1\");\r\n\r\n    validator.findErrorsIn(errors, testField, \"test\");\r\n    QCOMPARE(errors.size(), 0);\r\n    QVERIFY(validator.hasValidFieldAccessPolicyModeRefs(testField));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_FieldValidator::testStructureValidity()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_FieldValidator::testStructureValidity()\r\n{\r\n    QSharedPointer<Field> testField(new Field());\r\n    testField->setName(\"testField\");\r\n    testField->setBitOffset(\"8\");\r\n\r\n    QSharedPointer<FieldAccessPolicy> testFieldAccessPolicy(new FieldAccessPolicy());\r\n    testFieldAccessPolicy->setAccess(AccessTypes::READ_ONLY);\r\n\r\n    QSharedPointer<FieldReference> testFieldReference(new FieldReference());\r\n    QSharedPointer<FieldReference::IndexedReference> fieldRef(new FieldReference::IndexedReference(QString(\"fieldref\"), QStringList()));\r\n    testFieldReference->setReference(fieldRef, FieldReference::FIELD);\r\n\r\n    QSharedPointer<FieldReset> testReset(new FieldReset());\r\n    testReset->setResetValue(\"'b11\");\r\n\r\n    QSharedPointer<EnumeratedValue> testEnumeratedValue(new EnumeratedValue(\"testEnumeratedValue\", \"1\"));\r\n\r\n    // Test with no field definition reference, no bit width or field reference.\r\n    QSharedPointer<ExpressionParser> parser(new SystemVerilogExpressionParser());\r\n    QSharedPointer<EnumeratedValueValidator> enumeratedValueValidator(new EnumeratedValueValidator(parser));\r\n    QSharedPointer<ParameterValidator> parameterValidator(\r\n        new ParameterValidator(parser, QSharedPointer<QList<QSharedPointer<Choice> > >(), Document::Revision::Std22));\r\n    FieldValidator validator(parser, enumeratedValueValidator, parameterValidator, Document::Revision::Std22);\r\n\r\n    QStringList errors;\r\n\r\n    validator.findErrorsIn(errors, testField, \"test\");\r\n    QVERIFY(validator.hasValidStructure(testField) == false);\r\n\r\n    errors.clear();\r\n\r\n    // Should be valid with bit width defined\r\n    testField->setBitWidth(\"8\");\r\n\r\n    validator.findErrorsIn(errors, testField, \"test\");\r\n    QCOMPARE(errors.size(), 0);\r\n    QVERIFY(validator.hasValidStructure(testField));\r\n    errors.clear();\r\n\r\n    // Invalid, when both field reference and bit width is defined\r\n    testField->setFieldReference(testFieldReference);\r\n\r\n    validator.findErrorsIn(errors, testField, \"test\");\r\n    QCOMPARE(errors.size(), 1);\r\n    QVERIFY(validator.hasValidStructure(testField) == false);\r\n    errors.clear();\r\n    testField->setBitWidth(\"\");\r\n\r\n    // Invalid, when reference and volatile is defined.\r\n    testField->setVolatile(true);\r\n\r\n    validator.findErrorsIn(errors, testField, \"test\");\r\n    QCOMPARE(errors.size(), 1);\r\n    QVERIFY(validator.hasValidStructure(testField) == false);\r\n    errors.clear();\r\n    testField->clearVolatile();\r\n\r\n    // Invalid, when reference and resets are defined.\r\n    testField->getResets()->append(testReset);\r\n\r\n    validator.findErrorsIn(errors, testField, \"test\");\r\n    QCOMPARE(errors.size(), 1);\r\n    QVERIFY(validator.hasValidStructure(testField) == false);\r\n    errors.clear();\r\n    testField->getResets()->clear();\r\n\r\n    // Valid, when just field reference is defined.\r\n    validator.findErrorsIn(errors, testField, \"test\");\r\n    QCOMPARE(errors.size(), 0);\r\n    QVERIFY(validator.hasValidStructure(testField));\r\n    errors.clear();\r\n    testField->setFieldReference(nullptr);\r\n\r\n    // Valid, when just definition ref is defined.\r\n    testField->setFieldDefinitionRef(\"fieldDefinition\");\r\n    testField->setTypeDefinitionsRef(\"testTypeDefinitions\");\r\n    validator.findErrorsIn(errors, testField, \"test\");\r\n    QCOMPARE(errors.size(), 0);\r\n    QVERIFY(validator.hasValidStructure(testField));\r\n    errors.clear();\r\n\r\n    // Invalid, when both definition reference and type identifier are defined\r\n    testField->setTypeIdentifier(\"testIdentifier\");\r\n\r\n    validator.findErrorsIn(errors, testField, \"test\");\r\n    QCOMPARE(errors.size(), 1);\r\n    QVERIFY(validator.hasValidStructure(testField) == false);\r\n    errors.clear();\r\n    testField->setTypeIdentifier(\"\");\r\n\r\n    // Invalid, when the field has a definition reference and field access policies defined.\r\n    testField->getFieldAccessPolicies()->append(testFieldAccessPolicy);\r\n\r\n    validator.findErrorsIn(errors, testField, \"test\");\r\n    QCOMPARE(errors.size(), 1);\r\n    QVERIFY(validator.hasValidStructure(testField) == false);\r\n    errors.clear();\r\n    testField->getFieldAccessPolicies()->clear();\r\n\r\n    // Invalid, when the field has a definition reference and enumerated values defined.\r\n    testField->getEnumeratedValues()->append(testEnumeratedValue);\r\n\r\n    validator.findErrorsIn(errors, testField, \"test\");\r\n    QCOMPARE(errors.size(), 1);\r\n    QVERIFY(validator.hasValidStructure(testField) == false);\r\n    errors.clear();\r\n    testField->getEnumeratedValues()->clear();\r\n\r\n    // Invalid, when the field has a definition reference and bit width.\r\n    testField->setBitWidth(\"8\");\r\n\r\n    validator.findErrorsIn(errors, testField, \"test\");\r\n    QCOMPARE(errors.size(), 1);\r\n    QVERIFY(validator.hasValidStructure(testField) == false);\r\n    errors.clear();\r\n    testField->setBitWidth(\"\");\r\n\r\n    // Invalid, when the field has a definition reference and field reference.\r\n    testField->setFieldReference(testFieldReference);\r\n\r\n    validator.findErrorsIn(errors, testField, \"test\");\r\n    QCOMPARE(errors.size(), 1);\r\n    QVERIFY(validator.hasValidStructure(testField) == false);\r\n    errors.clear();\r\n    testField->setFieldDefinitionRef(\"\");\r\n    testField->setTypeDefinitionsRef(\"\");\r\n\r\n    // Valid configuration.\r\n    testField->getEnumeratedValues()->append(testEnumeratedValue);\r\n    testField->getFieldAccessPolicies()->append(testFieldAccessPolicy);\r\n\r\n    validator.findErrorsIn(errors, testField, \"test\");\r\n    QCOMPARE(errors.size(), 0);\r\n    QVERIFY(validator.hasValidStructure(testField));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_FieldValidator::errorIsNotFoundInErrorList()\r\n//-----------------------------------------------------------------------------\r\nbool tst_FieldValidator::errorIsNotFoundInErrorList(QString const& expectedError, QVector<QString> errorList)\r\n{\r\n    if (!errorList.contains(expectedError))\r\n    {\r\n        qDebug() << \"The following error:\" << Qt::endl << expectedError << Qt::endl << \"was not found in errorlist:\";\r\n        foreach(QString error, errorList)\r\n        {\r\n            qDebug() << error;\r\n        }\r\n        return true;\r\n    }\r\n\r\n    return false;\r\n}\r\n\r\nQTEST_APPLESS_MAIN(tst_FieldValidator)\r\n\r\n#include \"tst_FieldValidator.moc\"\r\n"
  },
  {
    "path": "tests/IPXACTmodels/Component/tst_FieldValidator.pri",
    "content": "# ----------------------------------------------------\r\n# This file is generated by the Qt Visual Studio Tools.\r\n# ------------------------------------------------------\r\n\t\r\nSOURCES += ./tst_FieldValidator.cpp"
  },
  {
    "path": "tests/IPXACTmodels/Component/tst_FieldValidator.pro",
    "content": "#-----------------------------------------------------------------------------\r\n# File: tst_FieldValidator.pro\r\n#-----------------------------------------------------------------------------\r\n# Project: Kactus 2\r\n# Author: Mikko Teuho\r\n# Date: 17.11.2015\r\n#\r\n# Description:\r\n# Qt project file template for running unit tests for FieldValidator.\r\n#-----------------------------------------------------------------------------\r\n\r\nTEMPLATE = app\r\n\r\nTARGET = tst_FieldValidator\r\n\r\nQT += core gui xml testlib\r\n\r\nCONFIG += c++11 testcase console\r\n\r\nlinux-g++ | linux-g++-64 | linux-g++-32 {\r\n LIBS += -L../../../executable \\\r\n     -lIPXACTmodels \\\r\n     -lKactusAPI\r\n\r\n}\r\nwin64 | win32 {\r\n LIBS += -L../../../executable \\\r\n     -lIPXACTmodelsd \\\r\n     -lKactusAPId\r\n}\r\n\r\nINCLUDEPATH += $$DESTDIR\r\nINCLUDEPATH += ../../../\r\n\r\nDEPENDPATH += .\r\nDEPENDPATH += ../../../\r\n\r\nOBJECTS_DIR += $$DESTDIR\r\n\r\nMOC_DIR += ./generatedFiles\r\nUI_DIR += ./generatedFiles\r\nRCC_DIR += ./generatedFiles\r\ninclude(tst_FieldValidator.pri)\r\n"
  },
  {
    "path": "tests/IPXACTmodels/Component/tst_FieldWriter.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: tst_FieldWriter.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 24.09.2015\r\n//\r\n// Description:\r\n// Unit test for class FieldWriter.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include <IPXACTmodels/common/GenericVendorExtension.h>\r\n#include <IPXACTmodels/common/Parameter.h>\r\n\r\n#include <IPXACTmodels/Component/FieldWriter.h>\r\n#include <IPXACTmodels/Component/Field.h>\r\n#include <IPXACTmodels/Component/EnumeratedValue.h>\r\n#include <IPXACTmodels/Component/WriteValueConstraint.h>\r\n#include <IPXACTmodels/Component/FieldReset.h>\r\n#include <IPXACTmodels/Component/MemoryArray.h>\r\n#include <IPXACTmodels/Component/FieldReference.h>\r\n\r\n#include <QtTest>\r\n\r\nclass tst_FieldWriter : public QObject\r\n{\r\n    Q_OBJECT\r\n\r\npublic:\r\n    tst_FieldWriter();\r\n\r\nprivate slots:\r\n    \r\n    void initTestCase();\r\n    void cleanupTestCase();\r\n    void init();\r\n    void cleanup();\r\n\r\n    void writeSimpleField();\r\n    void writeFieldID();\r\n    void writeIsPresent();\r\n    void writeMemoryArray2022();\r\n    void writeFieldDefinitionRef();\r\n    void writeResets();\r\n\r\n    void writeTypeIdentifier();\r\n    void writeVolatile();\r\n    void writeFieldReference2022();\r\n    void writeAccess();\r\n    void writeEnumeratedValues();\r\n    void writeModifiedWriteValue();\r\n    void writeWriteValueConstraint();\r\n    void writeReadAction();\r\n    void writeTestable();\r\n    void writeReserved();\r\n\r\n    void writeFieldAccessPolicies();\r\n\r\n    void writeParameters();\r\n\r\n    void writeVendorExtensions();\r\n\r\nprivate:\r\n\r\n    QSharedPointer<Field> testField_;\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_FieldWriter::tst_FieldWriter()\r\n//-----------------------------------------------------------------------------\r\ntst_FieldWriter::tst_FieldWriter() :\r\ntestField_()\r\n{\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_FieldWriter::initTestCase()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_FieldWriter::initTestCase()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_FieldWriter::cleanupTestCase()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_FieldWriter::cleanupTestCase()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_FieldWriter::init()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_FieldWriter::init()\r\n{\r\n    testField_ = QSharedPointer<Field>(new Field(\"testField\"));\r\n    testField_->setBitOffset(\"Baldur's\");\r\n    testField_->setBitWidth(\"Gate\");\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_FieldWriter::cleanup()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_FieldWriter::cleanup()\r\n{\r\n    testField_.clear();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_FieldWriter::writeSimpleField()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_FieldWriter::writeSimpleField()\r\n{\r\n    QString output;\r\n    QXmlStreamWriter xmlStreamWriter(&output);\r\n\r\n    QString expectedOutput(\r\n        \"<ipxact:field>\"\r\n            \"<ipxact:name>testField</ipxact:name>\"\r\n            \"<ipxact:bitOffset>Baldur's</ipxact:bitOffset>\"\r\n            \"<ipxact:bitWidth>Gate</ipxact:bitWidth>\"\r\n        \"</ipxact:field>\"\r\n        );\r\n\r\n    FieldWriter::writeField(xmlStreamWriter, testField_, Document::Revision::Std14);\r\n    QCOMPARE(output, expectedOutput);\r\n\r\n    output.clear();\r\n\r\n    testField_->setDisplayName(\"testDisplay\");\r\n    testField_->setDescription(\"testDescription\");\r\n\r\n    expectedOutput =\r\n        \"<ipxact:field>\"\r\n            \"<ipxact:name>testField</ipxact:name>\"\r\n            \"<ipxact:displayName>testDisplay</ipxact:displayName>\"\r\n            \"<ipxact:description>testDescription</ipxact:description>\"\r\n            \"<ipxact:bitOffset>Baldur's</ipxact:bitOffset>\"\r\n            \"<ipxact:bitWidth>Gate</ipxact:bitWidth>\"\r\n        \"</ipxact:field>\"\r\n        ;\r\n\r\n    FieldWriter::writeField(xmlStreamWriter, testField_, Document::Revision::Std14);\r\n    QCOMPARE(output, expectedOutput);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_FieldWriter::writeFieldID()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_FieldWriter::writeFieldID()\r\n{\r\n    QString output;\r\n    QXmlStreamWriter xmlStreamWriter(&output);\r\n\r\n    testField_->setId(\"AM\");\r\n\r\n    QString expectedOutput(\r\n        \"<ipxact:field fieldID=\\\"AM\\\">\"\r\n            \"<ipxact:name>testField</ipxact:name>\"\r\n            \"<ipxact:bitOffset>Baldur's</ipxact:bitOffset>\"\r\n            \"<ipxact:bitWidth>Gate</ipxact:bitWidth>\"\r\n        \"</ipxact:field>\"\r\n        );\r\n\r\n    FieldWriter::writeField(xmlStreamWriter, testField_, Document::Revision::Std14);\r\n    QCOMPARE(output, expectedOutput);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_FieldWriter::writeIsPresent()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_FieldWriter::writeIsPresent()\r\n{\r\n    QString output;\r\n    QXmlStreamWriter xmlStreamWriter(&output);\r\n\r\n    testField_->setIsPresent(\"presence*2\");\r\n\r\n    QString expectedOutput(\r\n        \"<ipxact:field>\"\r\n            \"<ipxact:name>testField</ipxact:name>\"\r\n            \"<ipxact:isPresent>presence*2</ipxact:isPresent>\"\r\n            \"<ipxact:bitOffset>Baldur's</ipxact:bitOffset>\"\r\n            \"<ipxact:bitWidth>Gate</ipxact:bitWidth>\"\r\n        \"</ipxact:field>\"\r\n        );\r\n\r\n    FieldWriter::writeField(xmlStreamWriter, testField_, Document::Revision::Std14);\r\n    QCOMPARE(output, expectedOutput);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_FieldWriter::writeMemoryArray2022()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_FieldWriter::writeMemoryArray2022()\r\n{\r\n    QString output;\r\n    QXmlStreamWriter xmlStreamWriter(&output);\r\n\r\n    QSharedPointer<MemoryArray> memArray(new MemoryArray());\r\n    QSharedPointer<MemoryArray::Dimension> dim(new MemoryArray::Dimension({ QString(\"8\"), QString(\"i\") }));\r\n    memArray->getDimensions()->append(dim);\r\n    memArray->setStride(\"16\");\r\n    testField_->setMemoryArray(memArray);\r\n\r\n    QString expectedOutput(\r\n        \"<ipxact:field>\"\r\n            \"<ipxact:name>testField</ipxact:name>\"\r\n            \"<ipxact:array>\"\r\n                \"<ipxact:dim indexVar=\\\"i\\\">8</ipxact:dim>\"\r\n                \"<ipxact:bitStride>16</ipxact:bitStride>\"\r\n            \"</ipxact:array>\"\r\n            \"<ipxact:bitOffset>Baldur's</ipxact:bitOffset>\"\r\n            \"<ipxact:bitWidth>Gate</ipxact:bitWidth>\"\r\n        \"</ipxact:field>\"\r\n        );\r\n\r\n    FieldWriter::writeField(xmlStreamWriter, testField_, Document::Revision::Std22);\r\n    QCOMPARE(output, expectedOutput);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_FieldWriter::writeFieldDefinitionRef()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_FieldWriter::writeFieldDefinitionRef()\r\n{\r\n    QString output;\r\n    QXmlStreamWriter xmlStreamWriter(&output);\r\n\r\n    testField_->setFieldDefinitionRef(\"TESTDEF\");\r\n    testField_->setTypeDefinitionsRef(\"testTypeDefinitionsRef\");\r\n    testField_->setBitWidth(\"\");\r\n\r\n    QString expectedOutput(\r\n        \"<ipxact:field>\"\r\n            \"<ipxact:name>testField</ipxact:name>\"\r\n            \"<ipxact:bitOffset>Baldur's</ipxact:bitOffset>\"\r\n            \"<ipxact:fieldDefinitionRef typeDefinitions=\\\"testTypeDefinitionsRef\\\">TESTDEF</ipxact:fieldDefinitionRef>\"\r\n        \"</ipxact:field>\"\r\n    );\r\n\r\n    FieldWriter::writeField(xmlStreamWriter, testField_, Document::Revision::Std22);\r\n    QCOMPARE(output, expectedOutput);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_FieldWriter::writeResets()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_FieldWriter::writeResets()\r\n{\r\n    QString output;\r\n    QXmlStreamWriter xmlStreamWriter(&output);\r\n\r\n    QSharedPointer<FieldReset> firstReset(new FieldReset());\r\n    firstReset->setResetTypeReference(\"HARD\");\r\n    firstReset->setResetValue(\"8'b0000_0000\");\r\n    firstReset->setResetMask(\"8'b1111_1111\");\r\n    QSharedPointer<FieldReset> lastReset(new FieldReset());\r\n    lastReset->setResetTypeReference(\"referencedReset\");\r\n    lastReset->setResetValue(\"8'b0110_1101\");\r\n    lastReset->setResetMask(\"8'b1100_0011\");\r\n\r\n    testField_->getResets()->append(firstReset);\r\n    testField_->getResets()->append(lastReset);\r\n\r\n    QString expectedOutput(\r\n        \"<ipxact:field>\"\r\n            \"<ipxact:name>testField</ipxact:name>\"\r\n            \"<ipxact:bitOffset>Baldur's</ipxact:bitOffset>\"\r\n            \"<ipxact:resets>\"\r\n                \"<ipxact:reset resetTypeRef=\\\"HARD\\\">\"\r\n                    \"<ipxact:value>8'b0000_0000</ipxact:value>\"\r\n                    \"<ipxact:mask>8'b1111_1111</ipxact:mask>\"\r\n                \"</ipxact:reset>\"\r\n                \"<ipxact:reset resetTypeRef=\\\"referencedReset\\\">\"\r\n                    \"<ipxact:value>8'b0110_1101</ipxact:value>\"\r\n                    \"<ipxact:mask>8'b1100_0011</ipxact:mask>\"\r\n                \"</ipxact:reset>\"\r\n            \"</ipxact:resets>\"\r\n            \"<ipxact:bitWidth>Gate</ipxact:bitWidth>\"\r\n        \"</ipxact:field>\"\r\n        );\r\n\r\n    FieldWriter::writeField(xmlStreamWriter, testField_, Document::Revision::Std14);\r\n    QCOMPARE(output, expectedOutput);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_FieldWriter::writeTypeIdentifier()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_FieldWriter::writeTypeIdentifier()\r\n{\r\n    QString output;\r\n    QXmlStreamWriter xmlStreamWriter(&output);\r\n\r\n    testField_->setTypeIdentifier(\"testTypeIdentifier\");\r\n\r\n    QString expectedOutput(\r\n        \"<ipxact:field>\"\r\n            \"<ipxact:name>testField</ipxact:name>\"\r\n            \"<ipxact:bitOffset>Baldur's</ipxact:bitOffset>\"\r\n            \"<ipxact:typeIdentifier>testTypeIdentifier</ipxact:typeIdentifier>\"\r\n            \"<ipxact:bitWidth>Gate</ipxact:bitWidth>\"\r\n        \"</ipxact:field>\"\r\n        );\r\n\r\n    FieldWriter::writeField(xmlStreamWriter, testField_, Document::Revision::Std14);\r\n    QCOMPARE(output, expectedOutput);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_FieldWriter::writeVolatile()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_FieldWriter::writeVolatile()\r\n{\r\n    QString output;\r\n    QXmlStreamWriter xmlStreamWriter(&output);\r\n\r\n    testField_->setVolatile(true);\r\n\r\n    QString expectedOutput(\r\n        \"<ipxact:field>\"\r\n            \"<ipxact:name>testField</ipxact:name>\"\r\n            \"<ipxact:bitOffset>Baldur's</ipxact:bitOffset>\"\r\n            \"<ipxact:bitWidth>Gate</ipxact:bitWidth>\"\r\n            \"<ipxact:volatile>true</ipxact:volatile>\"\r\n        \"</ipxact:field>\"\r\n        );\r\n\r\n    FieldWriter::writeField(xmlStreamWriter, testField_, Document::Revision::Std14);\r\n    QCOMPARE(output, expectedOutput);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_FieldWriter::writeFieldReference2022()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_FieldWriter::writeFieldReference2022()\r\n{\r\n    QString output;\r\n    QXmlStreamWriter xmlStreamWriter(&output);\r\n\r\n    QSharedPointer<FieldReference> fieldReference(new FieldReference());\r\n\r\n    testField_->setBitWidth(\"\");\r\n\r\n    QSharedPointer<FieldReference::IndexedReference> addressSpace(new FieldReference::IndexedReference(QString(\"testAddressSpace\"), QList<QString>()));\r\n    fieldReference->setReference(addressSpace, FieldReference::Type::ADDRESS_SPACE);\r\n\r\n    QSharedPointer<FieldReference::IndexedReference> memoryMap(new FieldReference::IndexedReference(QString(\"testMemoryMap\"), QList<QString>()));\r\n    fieldReference->setReference(memoryMap, FieldReference::Type::MEMORY_MAP);\r\n\r\n    QSharedPointer<FieldReference::IndexedReference> memoryRemap(new FieldReference::IndexedReference(QString(\"testMemoryRemap\"), QList<QString>()));\r\n    fieldReference->setReference(memoryRemap, FieldReference::Type::MEMORY_REMAP);\r\n\r\n    QSharedPointer<FieldReference::IndexedReference> bank1(new FieldReference::IndexedReference(QString(\"testBank\"), QList<QString>()));\r\n    fieldReference->setReference(bank1, FieldReference::Type::BANK);\r\n\r\n    QSharedPointer<FieldReference::IndexedReference> bank2(new FieldReference::IndexedReference(QString(\"testBank2\"), QList<QString>()));\r\n    fieldReference->setReference(bank2, FieldReference::Type::BANK);\r\n    \r\n    QSharedPointer<FieldReference::IndexedReference> addressBlock(new FieldReference::IndexedReference(QString(\"testAddressBlock\"), QList<QString>({ \"0\", \"1\" })));\r\n    fieldReference->setReference(addressBlock, FieldReference::Type::ADDRESS_BLOCK);\r\n\r\n    QSharedPointer<FieldReference::IndexedReference> regFile1(new FieldReference::IndexedReference(QString(\"testRegisterFile1\"), QList<QString>({ \"2\", \"3\" })));\r\n    fieldReference->setReference(regFile1, FieldReference::Type::REGISTER_FILE);\r\n\r\n    QSharedPointer<FieldReference::IndexedReference> regFile2(new FieldReference::IndexedReference(QString(\"testRegisterFile2\"), QList<QString>()));\r\n    fieldReference->setReference(regFile2, FieldReference::Type::REGISTER_FILE);\r\n\r\n    QSharedPointer<FieldReference::IndexedReference> testRegister(new FieldReference::IndexedReference(QString(\"testRegister\"), QList<QString>()));\r\n    fieldReference->setReference(testRegister, FieldReference::Type::REGISTER);\r\n\r\n    QSharedPointer<FieldReference::IndexedReference> alternateRegister(new FieldReference::IndexedReference(QString(\"testAlternateRegister\"), QList<QString>()));\r\n    fieldReference->setReference(alternateRegister, FieldReference::Type::ALTERNATE_REGISTER);\r\n\r\n    QSharedPointer<FieldReference::IndexedReference> field(new FieldReference::IndexedReference(QString(\"testField\"), QList<QString>({ \"8\" })));\r\n    fieldReference->setReference(field, FieldReference::Type::FIELD);\r\n\r\n    testField_->setFieldReference(fieldReference);\r\n\r\n    QString expectedOutput(\r\n        \"<ipxact:field>\"\r\n            \"<ipxact:name>testField</ipxact:name>\"\r\n            \"<ipxact:bitOffset>Baldur's</ipxact:bitOffset>\"\r\n            \"<ipxact:aliasOf>\"\r\n                \"<ipxact:addressSpaceRef addressSpaceRef=\\\"testAddressSpace\\\"/>\"\r\n                \"<ipxact:memoryMapRef memoryMapRef=\\\"testMemoryMap\\\"/>\"\r\n                \"<ipxact:memoryRemapRef memoryRemapRef=\\\"testMemoryRemap\\\"/>\"\r\n                \"<ipxact:bankRef bankRef=\\\"testBank\\\"/>\"\r\n                \"<ipxact:bankRef bankRef=\\\"testBank2\\\"/>\"\r\n                \"<ipxact:addressBlockRef addressBlockRef=\\\"testAddressBlock\\\">\"\r\n                    \"<ipxact:indices>\"\r\n                        \"<ipxact:index>0</ipxact:index>\"\r\n                        \"<ipxact:index>1</ipxact:index>\"\r\n                    \"</ipxact:indices>\"\r\n                \"</ipxact:addressBlockRef>\"\r\n                \"<ipxact:registerFileRef registerFileRef=\\\"testRegisterFile1\\\">\"\r\n                    \"<ipxact:indices>\"\r\n                        \"<ipxact:index>2</ipxact:index>\"\r\n                        \"<ipxact:index>3</ipxact:index>\"\r\n                    \"</ipxact:indices>\"\r\n                \"</ipxact:registerFileRef>\"\r\n                \"<ipxact:registerFileRef registerFileRef=\\\"testRegisterFile2\\\"/>\"\r\n                \"<ipxact:registerRef registerRef=\\\"testRegister\\\"/>\"\r\n                \"<ipxact:alternateRegisterRef alternateRegisterRef=\\\"testAlternateRegister\\\"/>\"\r\n                \"<ipxact:fieldRef fieldRef=\\\"testField\\\">\"\r\n                    \"<ipxact:indices>\"\r\n                        \"<ipxact:index>8</ipxact:index>\"\r\n                    \"</ipxact:indices>\"\r\n                \"</ipxact:fieldRef>\"\r\n            \"</ipxact:aliasOf>\"\r\n        \"</ipxact:field>\"\r\n    );\r\n\r\n    FieldWriter::writeField(xmlStreamWriter, testField_, Document::Revision::Std22);\r\n    QCOMPARE(output, expectedOutput);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_FieldWriter::writeAccess()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_FieldWriter::writeAccess()\r\n{\r\n    QString output;\r\n    QXmlStreamWriter xmlStreamWriter(&output);\r\n\r\n    testField_->setAccess(AccessTypes::READ_WRITE);\r\n\r\n    QString expectedOutput(\r\n        \"<ipxact:field>\"\r\n            \"<ipxact:name>testField</ipxact:name>\"\r\n            \"<ipxact:bitOffset>Baldur's</ipxact:bitOffset>\"\r\n            \"<ipxact:bitWidth>Gate</ipxact:bitWidth>\"\r\n            \"<ipxact:access>read-write</ipxact:access>\"\r\n        \"</ipxact:field>\"\r\n        );\r\n\r\n    FieldWriter::writeField(xmlStreamWriter, testField_, Document::Revision::Std14);\r\n    QCOMPARE(output, expectedOutput);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_FieldWriter::writeEnumeratedValues()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_FieldWriter::writeEnumeratedValues()\r\n{\r\n    QString output;\r\n    QXmlStreamWriter xmlStreamWriter(&output);\r\n\r\n    QSharedPointer<EnumeratedValue> enumeration (new EnumeratedValue(\"testEnumeration\", \"DaiGurren\"));\r\n    testField_->getEnumeratedValues()->append(enumeration);\r\n\r\n    QString expectedOutput(\r\n        \"<ipxact:field>\"\r\n            \"<ipxact:name>testField</ipxact:name>\"\r\n            \"<ipxact:bitOffset>Baldur's</ipxact:bitOffset>\"\r\n            \"<ipxact:bitWidth>Gate</ipxact:bitWidth>\"\r\n            \"<ipxact:enumeratedValues>\"\r\n                \"<ipxact:enumeratedValue>\"\r\n                    \"<ipxact:name>testEnumeration</ipxact:name>\"\r\n                    \"<ipxact:value>DaiGurren</ipxact:value>\"\r\n                \"</ipxact:enumeratedValue>\"\r\n            \"</ipxact:enumeratedValues>\"\r\n        \"</ipxact:field>\"\r\n        );\r\n\r\n    FieldWriter::writeField(xmlStreamWriter, testField_, Document::Revision::Std14);\r\n    QCOMPARE(output, expectedOutput);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_FieldWriter::writeModifiedWriteValue()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_FieldWriter::writeModifiedWriteValue()\r\n{\r\n    QString output;\r\n    QXmlStreamWriter xmlStreamWriter(&output);\r\n\r\n    testField_->setModifiedWrite(General::ZERO_TO_CLEAR);\r\n\r\n    QString expectedOutput(\r\n        \"<ipxact:field>\"\r\n            \"<ipxact:name>testField</ipxact:name>\"\r\n            \"<ipxact:bitOffset>Baldur's</ipxact:bitOffset>\"\r\n            \"<ipxact:bitWidth>Gate</ipxact:bitWidth>\"\r\n            \"<ipxact:modifiedWriteValue>zeroToClear</ipxact:modifiedWriteValue>\"\r\n        \"</ipxact:field>\"\r\n        );\r\n\r\n    FieldWriter::writeField(xmlStreamWriter, testField_, Document::Revision::Std14);\r\n    QCOMPARE(output, expectedOutput);\r\n\r\n    output.clear();\r\n    testField_->setModifiedWriteModify(\"modifier\");\r\n\r\n    expectedOutput =\r\n        \"<ipxact:field>\"\r\n            \"<ipxact:name>testField</ipxact:name>\"\r\n            \"<ipxact:bitOffset>Baldur's</ipxact:bitOffset>\"\r\n            \"<ipxact:bitWidth>Gate</ipxact:bitWidth>\"\r\n            \"<ipxact:modifiedWriteValue modify=\\\"modifier\\\">zeroToClear</ipxact:modifiedWriteValue>\"\r\n        \"</ipxact:field>\"\r\n        ;\r\n\r\n    FieldWriter::writeField(xmlStreamWriter, testField_, Document::Revision::Std14);\r\n    QCOMPARE(output, expectedOutput);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_FieldWriter::writeWriteValueConstraint()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_FieldWriter::writeWriteValueConstraint()\r\n{\r\n    QString output;\r\n    QXmlStreamWriter xmlStreamWriter(&output);\r\n\r\n    QSharedPointer<WriteValueConstraint> writeConstraint (new WriteValueConstraint());\r\n    writeConstraint->setType(WriteValueConstraint::WRITE_AS_READ);\r\n\r\n    testField_->setWriteConstraint(writeConstraint);\r\n\r\n    QString expectedOutput(\r\n        \"<ipxact:field>\"\r\n            \"<ipxact:name>testField</ipxact:name>\"\r\n            \"<ipxact:bitOffset>Baldur's</ipxact:bitOffset>\"\r\n            \"<ipxact:bitWidth>Gate</ipxact:bitWidth>\"\r\n            \"<ipxact:writeValueConstraint>\"\r\n                \"<ipxact:writeAsRead>true</ipxact:writeAsRead>\"\r\n            \"</ipxact:writeValueConstraint>\"\r\n        \"</ipxact:field>\"\r\n        );\r\n\r\n    FieldWriter::writeField(xmlStreamWriter, testField_, Document::Revision::Std14);\r\n    QCOMPARE(output, expectedOutput);\r\n\r\n    output.clear();\r\n    writeConstraint->setType(WriteValueConstraint::USE_ENUM);\r\n\r\n    expectedOutput =\r\n        \"<ipxact:field>\"\r\n            \"<ipxact:name>testField</ipxact:name>\"\r\n            \"<ipxact:bitOffset>Baldur's</ipxact:bitOffset>\"\r\n            \"<ipxact:bitWidth>Gate</ipxact:bitWidth>\"\r\n            \"<ipxact:writeValueConstraint>\"\r\n                \"<ipxact:useEnumeratedValues>true</ipxact:useEnumeratedValues>\"\r\n            \"</ipxact:writeValueConstraint>\"\r\n        \"</ipxact:field>\"\r\n        ;\r\n\r\n    FieldWriter::writeField(xmlStreamWriter, testField_, Document::Revision::Std14);\r\n    QCOMPARE(output, expectedOutput);\r\n\r\n    output.clear();\r\n    writeConstraint->setMinimum(\"0\");\r\n    writeConstraint->setMaximum(\"10\");\r\n\r\n    expectedOutput =\r\n        \"<ipxact:field>\"\r\n            \"<ipxact:name>testField</ipxact:name>\"\r\n            \"<ipxact:bitOffset>Baldur's</ipxact:bitOffset>\"\r\n            \"<ipxact:bitWidth>Gate</ipxact:bitWidth>\"\r\n            \"<ipxact:writeValueConstraint>\"\r\n                \"<ipxact:minimum>0</ipxact:minimum>\"\r\n                \"<ipxact:maximum>10</ipxact:maximum>\"\r\n            \"</ipxact:writeValueConstraint>\"\r\n        \"</ipxact:field>\"\r\n        ;\r\n\r\n    FieldWriter::writeField(xmlStreamWriter, testField_, Document::Revision::Std14);\r\n    QCOMPARE(output, expectedOutput);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_FieldWriter::writeReadAction()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_FieldWriter::writeReadAction()\r\n{\r\n    QString output;\r\n    QXmlStreamWriter xmlStreamWriter(&output);\r\n\r\n    testField_->setReadAction(General::READ_SET);\r\n\r\n    QString expectedOutput(\r\n        \"<ipxact:field>\"\r\n            \"<ipxact:name>testField</ipxact:name>\"\r\n            \"<ipxact:bitOffset>Baldur's</ipxact:bitOffset>\"\r\n            \"<ipxact:bitWidth>Gate</ipxact:bitWidth>\"\r\n            \"<ipxact:readAction>set</ipxact:readAction>\"\r\n        \"</ipxact:field>\"\r\n        );\r\n\r\n    FieldWriter::writeField(xmlStreamWriter, testField_, Document::Revision::Std14);\r\n    QCOMPARE(output, expectedOutput);\r\n\r\n    output.clear();\r\n\r\n    testField_->setReadAction(General::READ_CLEAR);\r\n    testField_->setReadActionModify(\"modifier\");\r\n\r\n    expectedOutput =\r\n        \"<ipxact:field>\"\r\n            \"<ipxact:name>testField</ipxact:name>\"\r\n            \"<ipxact:bitOffset>Baldur's</ipxact:bitOffset>\"\r\n            \"<ipxact:bitWidth>Gate</ipxact:bitWidth>\"\r\n            \"<ipxact:readAction modify=\\\"modifier\\\">clear</ipxact:readAction>\"\r\n        \"</ipxact:field>\"\r\n        ;\r\n\r\n    FieldWriter::writeField(xmlStreamWriter, testField_, Document::Revision::Std14);\r\n    QCOMPARE(output, expectedOutput);\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_FieldWriter::writeTestable()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_FieldWriter::writeTestable()\r\n{\r\n    QString output;\r\n    QXmlStreamWriter xmlStreamWriter(&output);\r\n\r\n    testField_->setTestable(false);\r\n\r\n    QString expectedOutput(\r\n        \"<ipxact:field>\"\r\n            \"<ipxact:name>testField</ipxact:name>\"\r\n            \"<ipxact:bitOffset>Baldur's</ipxact:bitOffset>\"\r\n            \"<ipxact:bitWidth>Gate</ipxact:bitWidth>\"\r\n            \"<ipxact:testable>false</ipxact:testable>\"\r\n        \"</ipxact:field>\"\r\n        );\r\n\r\n    FieldWriter::writeField(xmlStreamWriter, testField_, Document::Revision::Std14);\r\n    QCOMPARE(output, expectedOutput);\r\n\r\n    output.clear();\r\n\r\n    testField_->setTestable(true);\r\n    testField_->setTestConstraint(General::TEST_RESTORE);\r\n\r\n    expectedOutput =\r\n        \"<ipxact:field>\"\r\n            \"<ipxact:name>testField</ipxact:name>\"\r\n            \"<ipxact:bitOffset>Baldur's</ipxact:bitOffset>\"\r\n            \"<ipxact:bitWidth>Gate</ipxact:bitWidth>\"\r\n            \"<ipxact:testable testConstraint=\\\"restore\\\">true</ipxact:testable>\"\r\n        \"</ipxact:field>\"\r\n        ;\r\n\r\n    FieldWriter::writeField(xmlStreamWriter, testField_, Document::Revision::Std14);\r\n    QCOMPARE(output, expectedOutput);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_FieldWriter::writeReserved()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_FieldWriter::writeReserved()\r\n{\r\n    QString output;\r\n    QXmlStreamWriter xmlStreamWriter(&output);\r\n\r\n    testField_->setReserved(\"reserveWarning\");\r\n\r\n    QString expectedOutput(\r\n        \"<ipxact:field>\"\r\n            \"<ipxact:name>testField</ipxact:name>\"\r\n            \"<ipxact:bitOffset>Baldur's</ipxact:bitOffset>\"\r\n            \"<ipxact:bitWidth>Gate</ipxact:bitWidth>\"\r\n            \"<ipxact:reserved>reserveWarning</ipxact:reserved>\"\r\n        \"</ipxact:field>\"\r\n        );\r\n\r\n    FieldWriter::writeField(xmlStreamWriter, testField_, Document::Revision::Std14);\r\n    QCOMPARE(output, expectedOutput);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_FieldWriter::writeFieldAccessPolicies()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_FieldWriter::writeFieldAccessPolicies()\r\n{\r\n    QString output;\r\n    QXmlStreamWriter xmlStreamWriter(&output);\r\n\r\n    QSharedPointer<FieldAccessPolicy> testFieldAccessPolicy(new FieldAccessPolicy());\r\n    testFieldAccessPolicy->setTestable(true);\r\n    testFieldAccessPolicy->setTestConstraint(General::TEST_RESTORE);\r\n    testFieldAccessPolicy->setAccess(AccessTypes::READ_ONLY);\r\n    testFieldAccessPolicy->setReadAction(General::READ_CLEAR);\r\n\r\n    testField_->getFieldAccessPolicies()->append(testFieldAccessPolicy);\r\n\r\n    QString expectedOutput(\r\n        \"<ipxact:field>\"\r\n            \"<ipxact:name>testField</ipxact:name>\"\r\n            \"<ipxact:bitOffset>Baldur's</ipxact:bitOffset>\"\r\n            \"<ipxact:bitWidth>Gate</ipxact:bitWidth>\"\r\n            \"<ipxact:fieldAccessPolicies>\"\r\n                \"<ipxact:fieldAccessPolicy>\"\r\n                    \"<ipxact:access>read-only</ipxact:access>\"\r\n                    \"<ipxact:readAction>clear</ipxact:readAction>\"\r\n                    \"<ipxact:testable testConstraint=\\\"restore\\\">true</ipxact:testable>\"\r\n                \"</ipxact:fieldAccessPolicy>\"\r\n            \"</ipxact:fieldAccessPolicies>\"\r\n        \"</ipxact:field>\"\r\n    );\r\n\r\n    FieldWriter::writeField(xmlStreamWriter, testField_, Document::Revision::Std22);\r\n    QCOMPARE(output, expectedOutput);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_FieldWriter::writeParameters()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_FieldWriter::writeParameters()\r\n{\r\n    QString output;\r\n    QXmlStreamWriter xmlStreamWriter(&output);\r\n\r\n    QSharedPointer<Parameter> testParameter(new Parameter());\r\n    testParameter->setValueId(\"testID\");\r\n    testParameter->setName(\"testParameter\");\r\n    testParameter->setValue(\"1\");\r\n\r\n    testField_->getParameters()->append(testParameter);\r\n\r\n    QString expectedOutput(\r\n        \"<ipxact:field>\"\r\n            \"<ipxact:name>testField</ipxact:name>\"\r\n            \"<ipxact:bitOffset>Baldur's</ipxact:bitOffset>\"\r\n            \"<ipxact:bitWidth>Gate</ipxact:bitWidth>\"\r\n            \"<ipxact:parameters>\"\r\n                \"<ipxact:parameter parameterId=\\\"testID\\\">\"\r\n                    \"<ipxact:name>testParameter</ipxact:name>\"\r\n                    \"<ipxact:value>1</ipxact:value>\"\r\n                \"</ipxact:parameter>\"\r\n            \"</ipxact:parameters>\"\r\n        \"</ipxact:field>\"\r\n        );\r\n\r\n    FieldWriter::writeField(xmlStreamWriter, testField_, Document::Revision::Std14);\r\n    QCOMPARE(output, expectedOutput);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_FieldWriter::writeVendorExtensions()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_FieldWriter::writeVendorExtensions()\r\n{\r\n    QString output;\r\n    QXmlStreamWriter xmlStreamWriter(&output);\r\n\r\n    QDomDocument document;\r\n    QDomElement extensionNode = document.createElement(\"testExtension\");\r\n    extensionNode.setAttribute(\"testExtensionAttribute\", \"extension\");\r\n    extensionNode.appendChild(document.createTextNode(\"testValue\"));\r\n\r\n    QSharedPointer<GenericVendorExtension> testExtension(new GenericVendorExtension(extensionNode));\r\n\r\n    testField_->getVendorExtensions()->append(testExtension);\r\n\r\n    QString expectedOutput(\r\n        \"<ipxact:field>\"\r\n            \"<ipxact:name>testField</ipxact:name>\"\r\n            \"<ipxact:bitOffset>Baldur's</ipxact:bitOffset>\"\r\n            \"<ipxact:bitWidth>Gate</ipxact:bitWidth>\"\r\n            \"<ipxact:vendorExtensions>\"\r\n                \"<testExtension testExtensionAttribute=\\\"extension\\\">testValue</testExtension>\"\r\n            \"</ipxact:vendorExtensions>\"\r\n        \"</ipxact:field>\"\r\n        );\r\n\r\n    FieldWriter::writeField(xmlStreamWriter, testField_, Document::Revision::Std14);\r\n    QCOMPARE(output, expectedOutput);\r\n}\r\n\r\nQTEST_APPLESS_MAIN(tst_FieldWriter)\r\n\r\n#include \"tst_FieldWriter.moc\"\r\n"
  },
  {
    "path": "tests/IPXACTmodels/Component/tst_FieldWriter.pri",
    "content": "# ----------------------------------------------------\r\n# This file is generated by the Qt Visual Studio Tools.\r\n# ------------------------------------------------------\r\n\r\nSOURCES += ./tst_FieldWriter.cpp \r\n"
  },
  {
    "path": "tests/IPXACTmodels/Component/tst_FieldWriter.pro",
    "content": "#-----------------------------------------------------------------------------\r\n# File: tst_FieldWriter.pro\r\n#-----------------------------------------------------------------------------\r\n# Project: Kactus 2\r\n# Author: Mikko Teuho\r\n# Date: 24.09.2015\r\n#\r\n# Description:\r\n# Qt project file template for running unit tests for FieldWriter.\r\n#-----------------------------------------------------------------------------\r\n\r\nTEMPLATE = app\r\n\r\nTARGET = tst_FieldWriter\r\n\r\nQT += core xml testlib\r\nQT -= gui\r\n\r\nCONFIG += c++11 testcase console\r\n\r\nlinux-g++ | linux-g++-64 | linux-g++-32 {\r\n LIBS += -L../../../executable \\\r\n     -lIPXACTmodels\r\n\r\n}\r\nwin64 | win32 {\r\n LIBS += -L../../../executable \\\r\n     -lIPXACTmodelsd\r\n}\r\n\r\nINCLUDEPATH += $$DESTDIR\r\nINCLUDEPATH += ../../../\r\n\r\nDEPENDPATH += .\r\nDEPENDPATH += ../../../\r\n\r\nOBJECTS_DIR += $$DESTDIR\r\n\r\nMOC_DIR += ./generatedFiles\r\nUI_DIR += ./generatedFiles\r\nRCC_DIR += ./generatedFiles\r\ninclude(tst_FieldWriter.pri)\r\n"
  },
  {
    "path": "tests/IPXACTmodels/Component/tst_FileReader.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: tst_FileReader.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 18.09.2015\r\n//\r\n// Description:\r\n// Unit test for class FileReader.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include <IPXACTmodels/common/VendorExtension.h>\r\n\r\n#include <IPXACTmodels/Component/FileReader.h>\r\n\r\n#include <QtTest>\r\n\r\nclass tst_FileReader : public QObject\r\n{\r\n    Q_OBJECT\r\n\r\npublic:\r\n    tst_FileReader();\r\n\r\nprivate slots:\r\n\r\n    void readSimpleFile();\r\n    void readFileAttributes();\r\n\r\n    void readFileIsPresent();\r\n    void read2022File();\r\n\r\n    void readFileTypes();\r\n    void readIsStructural();\r\n    void readIsIncludeFile();\r\n    void readLogicalName();\r\n    void readExportedNames();\r\n    void readBuildCommand();\r\n    void readDependencies();\r\n    void readDefines();\r\n    void readImageTypes();\r\n\r\n\r\n    //void readHashExtension();\r\n    void readVendorExtensions();\r\n    void readDescription();\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_FileReader::tst_FileReader()\r\n//-----------------------------------------------------------------------------\r\ntst_FileReader::tst_FileReader()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_FileReader::readSimpleFile()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_FileReader::readSimpleFile()\r\n{\r\n    QString documentContent(\r\n        \"<ipxact:file>\"\r\n            \"<ipxact:name>./testFile</ipxact:name>\"\r\n            \"<ipxact:fileType>vhdlSource</ipxact:fileType>\"\r\n        \"</ipxact:file>\"\r\n        );\r\n\r\n\r\n    QDomDocument document;\r\n    document.setContent(documentContent);\r\n\r\n    QDomNode fileNode = document.firstChildElement(\"ipxact:file\");\r\n\r\n    QSharedPointer<File> testFile = FileReader::createFileFrom(fileNode, Document::Revision::Std14);\r\n\r\n    QCOMPARE(testFile->name(), QString(\"./testFile\"));\r\n    QCOMPARE(testFile->getFileTypes()->size(), 1);\r\n    QCOMPARE(testFile->getFileTypes()->first().type_, QString(\"vhdlSource\"));\r\n\r\n    documentContent =\r\n        \"<ipxact:file>\"\r\n            \"<ipxact:name>./testFile</ipxact:name>\"\r\n            \"<ipxact:fileType>vhdlSource</ipxact:fileType>\"\r\n            \"<ipxact:fileType user=\\\"testUserFileType\\\">user</ipxact:fileType>\"\r\n        \"</ipxact:file>\"\r\n        ;\r\n\r\n    document.setContent(documentContent);\r\n    fileNode = document.firstChildElement(\"ipxact:file\");\r\n    testFile = FileReader::createFileFrom(fileNode, Document::Revision::Std14);\r\n\r\n    QCOMPARE(testFile->name(), QString(\"./testFile\"));\r\n    QCOMPARE(testFile->getFileTypes()->size(), 2);\r\n    QCOMPARE(testFile->getFileTypes()->first().type_, QString(\"vhdlSource\"));\r\n    QCOMPARE(testFile->getFileTypes()->last().type_, QString(\"testUserFileType\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_FileReader::readFileAttributes()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_FileReader::readFileAttributes()\r\n{\r\n    QString documentContent(\r\n        \"<ipxact:file fileId=\\\"raiden\\\" otherAttribute=\\\"lightning\\\">\"\r\n            \"<ipxact:name>./testFile</ipxact:name>\"\r\n            \"<ipxact:fileType>vhdlSource</ipxact:fileType>\"\r\n        \"</ipxact:file>\"\r\n        );\r\n\r\n\r\n    QDomDocument document;\r\n    document.setContent(documentContent);\r\n\r\n    QDomNode fileNode = document.firstChildElement(\"ipxact:file\");\r\n\r\n    QSharedPointer<File> testFile = FileReader::createFileFrom(fileNode, Document::Revision::Std14);\r\n\r\n    QCOMPARE(testFile->getFileId(), QString(\"raiden\"));\r\n    QCOMPARE(testFile->getAttributes().count(), 1);\r\n    QCOMPARE(testFile->getAttributes().firstKey(), QString(\"otherAttribute\"));\r\n    QCOMPARE(testFile->getAttributes().first(), QString(\"lightning\"));\r\n\r\n    QCOMPARE(testFile->name(), QString(\"./testFile\"));\r\n    QCOMPARE(testFile->getFileTypes()->size(), 1);\r\n    QCOMPARE(testFile->getFileTypes()->first().type_, QString(\"vhdlSource\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_FileReader::readFileIsPresent()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_FileReader::readFileIsPresent()\r\n{\r\n    QString documentContent(\r\n        \"<ipxact:file>\"\r\n            \"<ipxact:name>./testFile</ipxact:name>\"\r\n            \"<ipxact:isPresent>4*4/4-3</ipxact:isPresent>\"\r\n            \"<ipxact:fileType>vhdlSource</ipxact:fileType>\"\r\n        \"</ipxact:file>\"\r\n        );\r\n\r\n\r\n    QDomDocument document;\r\n    document.setContent(documentContent);\r\n\r\n    QDomNode fileNode = document.firstChildElement(\"ipxact:file\");\r\n\r\n    QSharedPointer<File> testFile = FileReader::createFileFrom(fileNode, Document::Revision::Std14);\r\n\r\n    QCOMPARE(testFile->name(), QString(\"./testFile\"));\r\n    QCOMPARE(testFile->getIsPresent(), QString(\"4*4/4-3\"));\r\n    QCOMPARE(testFile->getFileTypes()->size(), 1);\r\n    QCOMPARE(testFile->getFileTypes()->first().type_, QString(\"vhdlSource\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_FileReader::read2022File()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_FileReader::read2022File()\r\n{\r\n    QString documentContent(\r\n        \"<ipxact:file>\"\r\n        \"<ipxact:name>./testFile</ipxact:name>\"\r\n        \"<ipxact:isPresent>1</ipxact:isPresent>\"\r\n        \"<ipxact:fileType user=\\\"test\\\" libext=\\\"ext\\\">user</ipxact:fileType>\"\r\n        \"</ipxact:file>\"\r\n    );\r\n\r\n    QDomDocument document;\r\n    document.setContent(documentContent);\r\n\r\n    QDomNode fileNode = document.firstChildElement(\"ipxact:file\");\r\n\r\n    QSharedPointer<File> testFile = FileReader::createFileFrom(fileNode, Document::Revision::Std22);\r\n\r\n    QCOMPARE(testFile->getIsPresent(), QString()); //!< No isPresent should be available.\r\n    QCOMPARE(testFile->getFileTypes()->first().type_, QString(\"test\"));\r\n    QCOMPARE(testFile->getFileTypes()->first().libext_, QString(\"ext\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_FileReader::readFileTypes()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_FileReader::readFileTypes()\r\n{\r\n    QString documentContent(\r\n        \"<ipxact:file>\"\r\n        \"<ipxact:name>./testFile</ipxact:name>\"\r\n        \"<ipxact:fileType>vhdlSource</ipxact:fileType>\"\r\n        \"<ipxact:fileType libext=\\\"ext\\\">vhdlSource-93</ipxact:fileType>\"\r\n        \"<ipxact:fileType user=\\\"test\\\">user</ipxact:fileType>\"\r\n        \"</ipxact:file>\"\r\n    );\r\n\r\n    QDomDocument document;\r\n    document.setContent(documentContent);\r\n\r\n    QDomNode fileNode = document.firstChildElement(\"ipxact:file\");\r\n\r\n    QSharedPointer<File> testFile = FileReader::createFileFrom(fileNode, Document::Revision::Std14);\r\n\r\n    QCOMPARE(testFile->getFileTypes()->count(), 3);\r\n    QCOMPARE(testFile->getFileTypes()->at(0).type_, QString(\"vhdlSource\"));\r\n    QCOMPARE(testFile->getFileTypes()->at(0).libext_, QString());\r\n    QCOMPARE(testFile->getFileTypes()->at(1).type_, QString(\"vhdlSource-93\"));\r\n    QCOMPARE(testFile->getFileTypes()->at(1).libext_, QString());\r\n    QCOMPARE(testFile->getFileTypes()->at(2).type_, QString(\"test\"));\r\n    QCOMPARE(testFile->getFileTypes()->at(2).libext_, QString());\r\n\r\n    testFile = FileReader::createFileFrom(fileNode, Document::Revision::Std22);\r\n\r\n    QCOMPARE(testFile->getFileTypes()->count(), 3);\r\n    QCOMPARE(testFile->getFileTypes()->at(0).type_, QString(\"vhdlSource\"));\r\n    QCOMPARE(testFile->getFileTypes()->at(0).libext_, QString());\r\n    QCOMPARE(testFile->getFileTypes()->at(1).type_, QString(\"vhdlSource-93\"));\r\n    QCOMPARE(testFile->getFileTypes()->at(1).libext_, QString(\"ext\"));\r\n    QCOMPARE(testFile->getFileTypes()->at(2).type_, QString(\"test\"));\r\n    QCOMPARE(testFile->getFileTypes()->at(2).libext_, QString());\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_FileReader::readIsStructural()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_FileReader::readIsStructural()\r\n{\r\n    QString documentContent(\r\n        \"<ipxact:file>\"\r\n            \"<ipxact:name>./testFile</ipxact:name>\"\r\n            \"<ipxact:fileType>vhdlSource</ipxact:fileType>\"\r\n            \"<ipxact:isStructural>true</ipxact:isStructural>\"\r\n        \"</ipxact:file>\"\r\n        );\r\n\r\n\r\n    QDomDocument document;\r\n    document.setContent(documentContent);\r\n\r\n    QDomNode fileNode = document.firstChildElement(\"ipxact:file\");\r\n\r\n    QSharedPointer<File> testFile = FileReader::createFileFrom(fileNode, Document::Revision::Std14);\r\n\r\n    QCOMPARE(testFile->isStructural(), true);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_FileReader::readIsIncludeFile()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_FileReader::readIsIncludeFile()\r\n{\r\n    QString documentContent(\r\n        \"<ipxact:file>\"\r\n            \"<ipxact:name>./testFile</ipxact:name>\"\r\n            \"<ipxact:fileType>vhdlSource</ipxact:fileType>\"\r\n            \"<ipxact:isIncludeFile>true</ipxact:isIncludeFile>\"\r\n        \"</ipxact:file>\"\r\n        );\r\n\r\n    QDomDocument document;\r\n    document.setContent(documentContent);\r\n\r\n    QDomNode fileNode = document.firstChildElement(\"ipxact:file\");\r\n\r\n    QSharedPointer<File> testFile = FileReader::createFileFrom(fileNode, Document::Revision::Std14);\r\n\r\n    QCOMPARE(testFile->isIncludeFile(), true);\r\n    QCOMPARE(testFile->hasExternalDeclarations(), false);\r\n\r\n    documentContent =\r\n        \"<ipxact:file>\"\r\n            \"<ipxact:name>./testFile</ipxact:name>\"\r\n            \"<ipxact:fileType>vhdlSource</ipxact:fileType>\"\r\n            \"<ipxact:isIncludeFile externalDeclarations=\\\"true\\\">true</ipxact:isIncludeFile>\"\r\n        \"</ipxact:file>\"\r\n        ;\r\n\r\n    document.setContent(documentContent);\r\n    fileNode = document.firstChildElement(\"ipxact:file\");\r\n    testFile = FileReader::createFileFrom(fileNode, Document::Revision::Std14);\r\n\r\n    QCOMPARE(testFile->isIncludeFile(), true);\r\n    QCOMPARE(testFile->hasExternalDeclarations(), true);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_FileReader::readLogicalName()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_FileReader::readLogicalName()\r\n{\r\n    QString documentContent(\r\n        \"<ipxact:file>\"\r\n            \"<ipxact:name>./testFile</ipxact:name>\"\r\n            \"<ipxact:fileType>vhdlSource</ipxact:fileType>\"\r\n            \"<ipxact:logicalName>Spock</ipxact:logicalName>\"\r\n        \"</ipxact:file>\"\r\n        );\r\n\r\n    QDomDocument document;\r\n    document.setContent(documentContent);\r\n\r\n    QDomNode fileNode = document.firstChildElement(\"ipxact:file\");\r\n\r\n    QSharedPointer<File> testFile = FileReader::createFileFrom(fileNode, Document::Revision::Std14);\r\n\r\n    QCOMPARE(testFile->getLogicalName(), QString(\"Spock\"));\r\n    QCOMPARE(testFile->isLogicalNameDefault(), false);\r\n\r\n    documentContent =\r\n        \"<ipxact:file>\"\r\n            \"<ipxact:name>./testFile</ipxact:name>\"\r\n            \"<ipxact:fileType>vhdlSource</ipxact:fileType>\"\r\n            \"<ipxact:logicalName default=\\\"true\\\">Spock</ipxact:logicalName>\"\r\n        \"</ipxact:file>\"\r\n        ;\r\n\r\n    document.setContent(documentContent);\r\n    fileNode = document.firstChildElement(\"ipxact:file\");\r\n    testFile = FileReader::createFileFrom(fileNode, Document::Revision::Std14);\r\n\r\n    QCOMPARE(testFile->getLogicalName(), QString(\"Spock\"));\r\n    QCOMPARE(testFile->isLogicalNameDefault(), true);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_FileReader::readExportedNames()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_FileReader::readExportedNames()\r\n{\r\n    QString documentContent(\r\n        \"<ipxact:file>\"\r\n            \"<ipxact:name>./testFile</ipxact:name>\"\r\n            \"<ipxact:fileType>vhdlSource</ipxact:fileType>\"\r\n            \"<ipxact:exportedName>Enterprise</ipxact:exportedName>\"\r\n        \"</ipxact:file>\"\r\n        );\r\n\r\n    QDomDocument document;\r\n    document.setContent(documentContent);\r\n\r\n    QDomNode fileNode = document.firstChildElement(\"ipxact:file\");\r\n\r\n    QSharedPointer<File> testFile = FileReader::createFileFrom(fileNode, Document::Revision::Std14);\r\n\r\n    QCOMPARE(testFile->getExportedNames()->size(), 1);\r\n    QCOMPARE(testFile->getExportedNames()->first(), QString(\"Enterprise\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_FileReader::readBuildCommand()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_FileReader::readBuildCommand()\r\n{\r\n    QString documentContent(\r\n        \"<ipxact:file>\"\r\n            \"<ipxact:name>./testFile</ipxact:name>\"\r\n            \"<ipxact:fileType>vhdlSource</ipxact:fileType>\"\r\n            \"<ipxact:buildCommand>\"\r\n                \"<ipxact:command>engage</ipxact:command>\"\r\n                \"<ipxact:flags append=\\\"false\\\">testFlags</ipxact:flags>\"\r\n                \"<ipxact:replaceDefaultFlags>4+3-6</ipxact:replaceDefaultFlags>\"\r\n                \"<ipxact:targetName>target</ipxact:targetName>\"\r\n            \"</ipxact:buildCommand>\"\r\n        \"</ipxact:file>\"\r\n        );\r\n\r\n    QDomDocument document;\r\n    document.setContent(documentContent);\r\n\r\n    QDomNode fileNode = document.firstChildElement(\"ipxact:file\");\r\n\r\n    QSharedPointer<File> testFile = FileReader::createFileFrom(fileNode, Document::Revision::Std14);\r\n\r\n    QCOMPARE(testFile->getBuildCommand().isNull(), false);\r\n\r\n    QSharedPointer<BuildCommand> buildCommand = testFile->getBuildCommand();\r\n    QCOMPARE(buildCommand->getCommand(), QString(\"engage\"));\r\n    QCOMPARE(buildCommand->getFlags(), QString(\"testFlags\"));\r\n    QCOMPARE(buildCommand->getFlagsAppend(), QString(\"false\"));\r\n    QCOMPARE(buildCommand->getReplaceDefaultFlags(), QString(\"4+3-6\"));\r\n    QCOMPARE(buildCommand->getTargetName(), QString(\"target\"));\r\n\r\n    documentContent =\r\n        \"<ipxact:file>\"\r\n            \"<ipxact:name>./testFile</ipxact:name>\"\r\n            \"<ipxact:fileType>vhdlSource</ipxact:fileType>\"\r\n            \"<ipxact:buildCommand>\"\r\n                \"<ipxact:flags>testFlags</ipxact:flags>\"\r\n            \"</ipxact:buildCommand>\"\r\n        \"</ipxact:file>\"\r\n        ;\r\n    document.setContent(documentContent);\r\n    fileNode = document.firstChildElement(\"ipxact:file\");\r\n    testFile = FileReader::createFileFrom(fileNode, Document::Revision::Std14);\r\n\r\n    QCOMPARE(testFile->getBuildCommand().isNull(), false);\r\n\r\n    buildCommand = testFile->getBuildCommand();\r\n    QCOMPARE(buildCommand->getFlags(), QString(\"testFlags\"));\r\n    QCOMPARE(buildCommand->getFlagsAppend(), QString(\"\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_FileReader::readDependencies()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_FileReader::readDependencies()\r\n{\r\n    QString documentContent(\r\n        \"<ipxact:file>\"\r\n            \"<ipxact:name>./testFile</ipxact:name>\"\r\n            \"<ipxact:fileType>vhdlSource</ipxact:fileType>\"\r\n            \"<ipxact:dependency>/path/to/include</ipxact:dependency>\"\r\n        \"</ipxact:file>\"\r\n        );\r\n\r\n    QDomDocument document;\r\n    document.setContent(documentContent);\r\n\r\n    QDomNode fileNode = document.firstChildElement(\"ipxact:file\");\r\n\r\n    QSharedPointer<File> testFile = FileReader::createFileFrom(fileNode, Document::Revision::Std14);\r\n\r\n    QCOMPARE(testFile->getDependencies()->size(), 1);\r\n    QCOMPARE(testFile->getDependencies()->first(), QString(\"/path/to/include\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_FileReader::readDefines()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_FileReader::readDefines()\r\n{\r\n    QString documentContent(\r\n        \"<ipxact:file>\"\r\n            \"<ipxact:name>./testFile</ipxact:name>\"\r\n            \"<ipxact:fileType>vhdlSource</ipxact:fileType>\"\r\n            \"<ipxact:define>\"\r\n                \"<ipxact:name>defined</ipxact:name>\"\r\n                \"<ipxact:displayName>defineDisplay</ipxact:displayName>\"\r\n                \"<ipxact:description>defineDescription</ipxact:description>\"\r\n                \"<ipxact:value>value</ipxact:value>\"\r\n                \"<ipxact:vendorExtensions>\"\r\n                    \"<testExtension testExtensionAttribute=\\\"extension\\\">testValue</testExtension>\"\r\n                \"</ipxact:vendorExtensions>\"\r\n            \"</ipxact:define>\"\r\n        \"</ipxact:file>\"\r\n        );\r\n\r\n    QDomDocument document;\r\n    document.setContent(documentContent);\r\n\r\n    QDomNode fileNode = document.firstChildElement(\"ipxact:file\");\r\n\r\n    QSharedPointer<File> testFile = FileReader::createFileFrom(fileNode, Document::Revision::Std14);\r\n\r\n    QCOMPARE(testFile->getDefines()->size(), 1);\r\n    QSharedPointer<NameValuePair> define = testFile->getDefines()->first();\r\n    QCOMPARE(define->name(), QString(\"defined\"));\r\n    QCOMPARE(define->displayName(), QString(\"defineDisplay\"));\r\n    QCOMPARE(define->description(), QString(\"defineDescription\"));\r\n    QCOMPARE(define->getValue(), QString(\"value\"));\r\n\r\n    QCOMPARE(define->getVendorExtensions()->size(), 1);\r\n    QCOMPARE(define->getVendorExtensions()->first()->type(), QString(\"testExtension\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_FileReader::readImageTypes()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_FileReader::readImageTypes()\r\n{\r\n    QString documentContent(\r\n        \"<ipxact:file>\"\r\n            \"<ipxact:name>./testFile</ipxact:name>\"\r\n            \"<ipxact:fileType>vhdlSource</ipxact:fileType>\"\r\n            \"<ipxact:imageType>jpg</ipxact:imageType>\"\r\n        \"</ipxact:file>\"\r\n        );\r\n\r\n    QDomDocument document;\r\n    document.setContent(documentContent);\r\n\r\n    QDomNode fileNode = document.firstChildElement(\"ipxact:file\");\r\n\r\n    QSharedPointer<File> testFile = FileReader::createFileFrom(fileNode, Document::Revision::Std14);\r\n\r\n    QCOMPARE(testFile->getImageTypes()->size(), 1);\r\n    QCOMPARE(testFile->getImageTypes()->first(), QString(\"jpg\"));\r\n}\r\n\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_FileReader::readHashExtension()\r\n//-----------------------------------------------------------------------------\r\n//void tst_FileReader::readHashExtension()\r\n//{\r\n//    QString documentContent(\r\n//        \"<ipxact:file>\"\r\n//            \"<ipxact:name>./testFile</ipxact:name>\"\r\n//            \"<ipxact:fileType>vhdlSource</ipxact:fileType>\"\r\n//            \"<ipxact:vendorExtensions>\"\r\n//                \"<kactus2:hash>hash</kactus2:hash>\"\r\n//            \"</ipxact:vendorExtensions>\"\r\n//        \"</ipxact:file>\"\r\n//        );\r\n//\r\n//    QDomDocument document;\r\n//    document.setContent(documentContent);\r\n//\r\n//    QDomNode fileNode = document.firstChildElement(\"ipxact:file\");\r\n//\r\n//    QSharedPointer<File> testFile = FileReader::createFileFrom(fileNode, Document::Revision::Std14);\r\n//\r\n//    QCOMPARE(testFile->getVendorExtensions()->size(), 1);\r\n//    QCOMPARE(testFile->getLastHash(), QString(\"hash\"));\r\n//}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_FileReader::readDescription()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_FileReader::readDescription()\r\n{\r\n    QString documentContent(\r\n        \"<ipxact:file>\"\r\n        \"<ipxact:name>./testFile</ipxact:name>\"\r\n        \"<ipxact:fileType>cppSource</ipxact:fileType>\"\r\n        \"<ipxact:description>This is an important file.</ipxact:description>\"\r\n        \"</ipxact:file>\"\r\n        );\r\n\r\n    QDomDocument document;\r\n    document.setContent(documentContent);\r\n\r\n    QDomNode fileNode = document.firstChildElement(\"ipxact:file\");\r\n\r\n    QSharedPointer<File> testFile = FileReader::createFileFrom(fileNode, Document::Revision::Std14);\r\n\r\n    QCOMPARE(testFile->getDescription(), QString(\"This is an important file.\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_FileReader::readVendorExtensions()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_FileReader::readVendorExtensions()\r\n{\r\n    QString documentContent(\r\n        \"<ipxact:file>\"\r\n            \"<ipxact:name>./testFile</ipxact:name>\"\r\n            \"<ipxact:fileType>vhdlSource</ipxact:fileType>\"\r\n            \"<ipxact:vendorExtensions>\"\r\n                \"<testExtension testExtensionAttribute=\\\"extension\\\">testValue</testExtension>\"\r\n            \"</ipxact:vendorExtensions>\"\r\n        \"</ipxact:file>\"\r\n        );\r\n\r\n    QDomDocument document;\r\n    document.setContent(documentContent);\r\n\r\n    QDomNode fileNode = document.firstChildElement(\"ipxact:file\");\r\n\r\n    QSharedPointer<File> testFile = FileReader::createFileFrom(fileNode, Document::Revision::Std14);\r\n\r\n    QCOMPARE(testFile->getVendorExtensions()->size(), 1);\r\n    QCOMPARE(testFile->getVendorExtensions()->first()->type(), QString(\"testExtension\"));\r\n}\r\n\r\nQTEST_APPLESS_MAIN(tst_FileReader)\r\n\r\n#include \"tst_FileReader.moc\"\r\n"
  },
  {
    "path": "tests/IPXACTmodels/Component/tst_FileReader.pri",
    "content": "# ----------------------------------------------------\r\n# This file is generated by the Qt Visual Studio Add-in.\r\n# ------------------------------------------------------\r\n\r\nSOURCES += ./tst_FileReader.cpp \r\n"
  },
  {
    "path": "tests/IPXACTmodels/Component/tst_FileReader.pro",
    "content": "#-----------------------------------------------------------------------------\r\n# File: tst_FileReader.pro\r\n#-----------------------------------------------------------------------------\r\n# Project: Kactus 2\r\n# Author: Mikko Teuho\r\n# Date: 18.09.2015\r\n#\r\n# Description:\r\n# Qt project file template for running unit tests for a single module.\r\n#-----------------------------------------------------------------------------\r\n\r\nTEMPLATE = app\r\n\r\nTARGET = tst_FileReader\r\n\r\nQT += core xml testlib\r\nQT -= gui\r\n\r\nCONFIG += c++11 testcase console\r\n\r\nlinux-g++ | linux-g++-64 | linux-g++-32 {\r\n LIBS += -L../../../executable \\\r\n     -lIPXACTmodels\r\n}\r\n\r\nwin64 | win32 {\r\n LIBS += -L../../../executable \\\r\n     -lIPXACTmodelsd\r\n}\r\n\r\nINCLUDEPATH += $$DESTDIR\r\nINCLUDEPATH += ../../../\r\n\r\nDEPENDPATH += .\r\nDEPENDPATH += ../../../\r\n\r\nOBJECTS_DIR += $$DESTDIR\r\n\r\nMOC_DIR += ./generatedFiles\r\nUI_DIR += ./generatedFiles\r\nRCC_DIR += ./generatedFiles\r\ninclude(tst_FileReader.pri)\r\n"
  },
  {
    "path": "tests/IPXACTmodels/Component/tst_FileSetReader.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: tst_FileSetReader.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 22.09.2015\r\n//\r\n// Description:\r\n// Unit test for class FileSetReader.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include <IPXACTmodels/Component/FileSetReader.h>\r\n\r\n#include <IPXACTmodels/common/VendorExtension.h>\r\n\r\n#include <QtTest>\r\n\r\nclass tst_FileSetReader : public QObject\r\n{\r\n    Q_OBJECT\r\n\r\npublic:\r\n    tst_FileSetReader();\r\n\r\nprivate slots:\r\n    \r\n    void readSimpleFileSet();\r\n    void readGroups();\r\n    void readFiles();\r\n    void readDefaultFileBuilders();\r\n    void read2022DefaultFileBuilders();\r\n    void readDependencies();\r\n    void readFunctions();\r\n\r\n    void readID();\r\n    void readVendorExtensions();\r\n};\r\n \r\n//-----------------------------------------------------------------------------\r\n// Function: tst_FileSetReader::tst_FileSetReader()\r\n//-----------------------------------------------------------------------------\r\ntst_FileSetReader::tst_FileSetReader()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_FileSetReader::readSimpleFileSet()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_FileSetReader::readSimpleFileSet()\r\n{\r\n    QString documentContent(\r\n        \"<ipxact:fileSet>\"\r\n            \"<ipxact:name>testFileSet</ipxact:name>\"\r\n        \"</ipxact:fileSet>\"\r\n        );\r\n\r\n\r\n    QDomDocument document;\r\n    document.setContent(documentContent);\r\n\r\n    QDomNode fileSetNode = document.firstChildElement(\"ipxact:fileSet\");\r\n\r\n    QSharedPointer<FileSet> testFileSet = FileSetReader::createFileSetFrom(fileSetNode, Document::Revision::Std14);\r\n\r\n    QCOMPARE(testFileSet->name(), QString(\"testFileSet\"));\r\n\r\n    documentContent =\r\n        \"<ipxact:fileSet>\"\r\n            \"<ipxact:name>otherFileSet</ipxact:name>\"\r\n            \"<ipxact:displayName>fileSetDisplay</ipxact:displayName>\"\r\n            \"<ipxact:description>fileSetDescription</ipxact:description>\"\r\n        \"</ipxact:fileSet>\"\r\n        ;\r\n\r\n    document.setContent(documentContent);\r\n    fileSetNode = document.firstChildElement(\"ipxact:fileSet\");\r\n    testFileSet = FileSetReader::createFileSetFrom(fileSetNode, Document::Revision::Std14);\r\n\r\n    QCOMPARE(testFileSet->name(), QString(\"otherFileSet\"));\r\n    QCOMPARE(testFileSet->displayName(), QString(\"fileSetDisplay\"));\r\n    QCOMPARE(testFileSet->description(), QString(\"fileSetDescription\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_FileSetReader::readGroups()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_FileSetReader::readGroups()\r\n{\r\n    QString documentContent(\r\n        \"<ipxact:fileSet>\"\r\n            \"<ipxact:name>testFileSet</ipxact:name>\"\r\n            \"<ipxact:group>firstGroup</ipxact:group>\"\r\n        \"</ipxact:fileSet>\"\r\n        );\r\n\r\n\r\n    QDomDocument document;\r\n    document.setContent(documentContent);\r\n\r\n    QDomNode fileSetNode = document.firstChildElement(\"ipxact:fileSet\");\r\n\r\n    QSharedPointer<FileSet> testFileSet = FileSetReader::createFileSetFrom(fileSetNode, Document::Revision::Std14);\r\n\r\n    QCOMPARE(testFileSet->name(), QString(\"testFileSet\"));\r\n    QCOMPARE(testFileSet->getGroups()->size(), 1);\r\n    QCOMPARE(testFileSet->getGroups()->first(), QString(\"firstGroup\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_FileSetReader::readFiles()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_FileSetReader::readFiles()\r\n{\r\n    QString documentContent(\r\n        \"<ipxact:fileSet>\"\r\n            \"<ipxact:name>testFileSet</ipxact:name>\"\r\n            \"<ipxact:file>\"\r\n                \"<ipxact:name>./test/file</ipxact:name>\"\r\n                \"<ipxact:fileType user=\\\"userFile\\\">user</ipxact:fileType>\"\r\n                \"<ipxact:fileType>executableHdl</ipxact:fileType>\"\r\n            \"</ipxact:file>\"\r\n        \"</ipxact:fileSet>\"\r\n        );\r\n\r\n\r\n    QDomDocument document;\r\n    document.setContent(documentContent);\r\n\r\n    QDomNode fileSetNode = document.firstChildElement(\"ipxact:fileSet\");\r\n\r\n    QSharedPointer<FileSet> testFileSet = FileSetReader::createFileSetFrom(fileSetNode, Document::Revision::Std14);\r\n\r\n    QCOMPARE(testFileSet->name(), QString(\"testFileSet\"));\r\n    QCOMPARE(testFileSet->getFiles()->size(), 1);\r\n\r\n    QSharedPointer<File> testFile = testFileSet->getFiles()->first();\r\n    QCOMPARE(testFile->name(), QString(\"./test/file\"));\r\n    QCOMPARE(testFile->getFileTypes()->size(), 2);\r\n    QCOMPARE(testFile->getFileTypes()->first().type_, QString(\"userFile\"));\r\n    QCOMPARE(testFile->getFileTypes()->last().type_, QString(\"executableHdl\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_FileSetReader::readDefaultFileBuilders()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_FileSetReader::readDefaultFileBuilders()\r\n{\r\n    QString documentContent(\r\n        \"<ipxact:fileSet>\"\r\n            \"<ipxact:name>testFileSet</ipxact:name>\"\r\n            \"<ipxact:defaultFileBuilder>\"\r\n                \"<ipxact:fileType user=\\\"userFile\\\">user</ipxact:fileType>\"\r\n                \"<ipxact:command>4+5+6-14</ipxact:command>\"\r\n                \"<ipxact:flags>2-1</ipxact:flags>\"\r\n                \"<ipxact:replaceDefaultFlags>0</ipxact:replaceDefaultFlags>\"\r\n                \"<ipxact:vendorExtensions>\"\r\n                    \"<testExtension testExtensionAttribute=\\\"extension\\\">testValue</testExtension>\"\r\n                \"</ipxact:vendorExtensions>\"\r\n            \"</ipxact:defaultFileBuilder>\"\r\n        \"</ipxact:fileSet>\"\r\n        );\r\n\r\n\r\n    QDomDocument document;\r\n    document.setContent(documentContent);\r\n\r\n    QDomNode fileSetNode = document.firstChildElement(\"ipxact:fileSet\");\r\n\r\n    QSharedPointer<FileSet> testFileSet = FileSetReader::createFileSetFrom(fileSetNode, Document::Revision::Std14);\r\n\r\n    QCOMPARE(testFileSet->name(), QString(\"testFileSet\"));\r\n\r\n    QCOMPARE(testFileSet->getDefaultFileBuilders()->size(), 1);\r\n\r\n    QSharedPointer<FileBuilder> testFileBuilder = testFileSet->getDefaultFileBuilders()->first();\r\n    QCOMPARE(testFileBuilder->getFileType().type_, QString(\"userFile\"));\r\n    QCOMPARE(testFileBuilder->getCommand(), QString(\"4+5+6-14\"));\r\n    QCOMPARE(testFileBuilder->getFlags(), QString(\"2-1\"));\r\n    QCOMPARE(testFileBuilder->getReplaceDefaultFlags(), QString(\"0\"));\r\n\r\n    QCOMPARE(testFileBuilder->getVendorExtensions()->size(), 1);\r\n    QCOMPARE(testFileBuilder->getVendorExtensions()->first()->type(), QString(\"testExtension\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_FileSetReader::read2022DefaultFileBuilders()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_FileSetReader::read2022DefaultFileBuilders()\r\n{\r\n    QString documentContent(\r\n        \"<ipxact:fileSet>\"\r\n            \"<ipxact:name>testFileSet</ipxact:name>\"\r\n            \"<ipxact:shortDescription>brief test</ipxact:shortDescription>\"\r\n            \"<ipxact:defaultFileBuilder>\"\r\n                \"<ipxact:fileType user=\\\"userFile\\\" libext=\\\"ext\\\">user</ipxact:fileType>\"\r\n                \"<ipxact:command>4+5+6-14</ipxact:command>\"\r\n                \"<ipxact:flags>2-1</ipxact:flags>\"\r\n                \"<ipxact:replaceDefaultFlags>0</ipxact:replaceDefaultFlags>\"\r\n                \"<ipxact:vendorExtensions>\"\r\n                    \"<testExtension testExtensionAttribute=\\\"extension\\\">testValue</testExtension>\"\r\n                \"</ipxact:vendorExtensions>\"\r\n            \"</ipxact:defaultFileBuilder>\"\r\n        \"</ipxact:fileSet>\"\r\n        );\r\n\r\n\r\n    QDomDocument document;\r\n    document.setContent(documentContent);\r\n\r\n    QDomNode fileSetNode = document.firstChildElement(\"ipxact:fileSet\");\r\n\r\n    QSharedPointer<FileSet> testFileSet = FileSetReader::createFileSetFrom(fileSetNode, Document::Revision::Std22);\r\n\r\n    QCOMPARE(testFileSet->shortDescription(), QString(\"brief test\"));\r\n\r\n    QCOMPARE(testFileSet->getDefaultFileBuilders()->size(), 1);\r\n\r\n    QSharedPointer<FileBuilder> testFileBuilder = testFileSet->getDefaultFileBuilders()->first();\r\n    QCOMPARE(testFileBuilder->getFileType().type_, QString(\"userFile\"));\r\n    QCOMPARE(testFileBuilder->getFileType().libext_, QString(\"ext\"));\r\n    QCOMPARE(testFileBuilder->getCommand(), QString(\"4+5+6-14\"));\r\n    QCOMPARE(testFileBuilder->getFlags(), QString(\"2-1\"));\r\n    QCOMPARE(testFileBuilder->getReplaceDefaultFlags(), QString(\"0\"));\r\n\r\n    QCOMPARE(testFileBuilder->getVendorExtensions()->size(), 0); //!< No vendor extensions allowed.\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_FileSetReader::readDependencies()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_FileSetReader::readDependencies()\r\n{\r\n    QString documentContent(\r\n        \"<ipxact:fileSet>\"\r\n            \"<ipxact:name>testFileSet</ipxact:name>\"\r\n            \"<ipxact:dependency>Stan</ipxact:dependency>\"\r\n            \"<ipxact:dependency>Ollie</ipxact:dependency>\"\r\n        \"</ipxact:fileSet>\"\r\n        );\r\n\r\n\r\n    QDomDocument document;\r\n    document.setContent(documentContent);\r\n\r\n    QDomNode fileSetNode = document.firstChildElement(\"ipxact:fileSet\");\r\n\r\n    QSharedPointer<FileSet> testFileSet = FileSetReader::createFileSetFrom(fileSetNode, Document::Revision::Std14);\r\n\r\n    QCOMPARE(testFileSet->name(), QString(\"testFileSet\"));\r\n    QCOMPARE(testFileSet->getDependencies()->size(), 2);\r\n    QCOMPARE(testFileSet->getDependencies()->first(), QString(\"Stan\"));\r\n    QCOMPARE(testFileSet->getDependencies()->last(), QString(\"Ollie\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_FileSetReader::readFunctions()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_FileSetReader::readFunctions()\r\n{\r\n    QString documentContent(\r\n        \"<ipxact:fileSet>\"\r\n            \"<ipxact:name>testFileSet</ipxact:name>\"\r\n            \"<ipxact:function replicate=\\\"true\\\">\"\r\n                \"<ipxact:entryPoint>uguisubari</ipxact:entryPoint>\"\r\n                \"<ipxact:fileRef>nineCuts</ipxact:fileRef>\"\r\n                \"<ipxact:returnType>void</ipxact:returnType>\"\r\n                \"<ipxact:argument>\"\r\n                    \"<ipxact:name>ninja</ipxact:name>\"\r\n                    \"<ipxact:displayName>shinobi</ipxact:displayName>\"\r\n                    \"<ipxact:description>oniwaban</ipxact:description>\"\r\n                    \"<ipxact:value>ninjutsu</ipxact:value>\"\r\n                    \"<ipxact:vendorExtensions>\"\r\n                        \"<testExtension testExtensionAttribute=\\\"extension\\\">testValue</testExtension>\"\r\n                    \"</ipxact:vendorExtensions>\"\r\n                \"</ipxact:argument>\"\r\n                \"<ipxact:disabled>4-2*2+1</ipxact:disabled>\"\r\n                \"<ipxact:sourceFile>\"\r\n                    \"<ipxact:sourceName>sourcery</ipxact:sourceName>\"\r\n                    \"<ipxact:fileType>swObject</ipxact:fileType>\"\r\n                \"</ipxact:sourceFile>\"\r\n            \"</ipxact:function>\"\r\n        \"</ipxact:fileSet>\"\r\n        );\r\n\r\n\r\n    QDomDocument document;\r\n    document.setContent(documentContent);\r\n\r\n    QDomNode fileSetNode = document.firstChildElement(\"ipxact:fileSet\");\r\n\r\n    QSharedPointer<FileSet> testFileSet = FileSetReader::createFileSetFrom(fileSetNode, Document::Revision::Std14);\r\n\r\n    QCOMPARE(testFileSet->name(), QString(\"testFileSet\"));\r\n    QCOMPARE(testFileSet->getFunctions()->size(), 1);\r\n\r\n    QSharedPointer<Function> testFunction = testFileSet->getFunctions()->first();\r\n    QCOMPARE(testFunction->getReplicate(), true);\r\n    QCOMPARE(testFunction->getEntryPoint(), QString(\"uguisubari\"));\r\n    QCOMPARE(testFunction->getFileRef(), QString(\"nineCuts\"));\r\n    QCOMPARE(testFunction->getReturnType(), QString(\"void\"));\r\n    QCOMPARE(testFunction->getDisabled(), QString(\"4-2*2+1\"));\r\n\r\n    QCOMPARE(testFunction->getArguments()->size(), 1);\r\n    QSharedPointer<NameValuePair> testArgument = testFunction->getArguments()->first();\r\n    QCOMPARE(testArgument->name(), QString(\"ninja\"));\r\n    QCOMPARE(testArgument->displayName(), QString(\"shinobi\"));\r\n    QCOMPARE(testArgument->description(), QString(\"oniwaban\"));\r\n    QCOMPARE(testArgument->getValue(), QString(\"ninjutsu\"));\r\n    QCOMPARE(testArgument->getVendorExtensions()->size(), 1);\r\n    QCOMPARE(testArgument->getVendorExtensions()->first()->type(), QString(\"testExtension\"));\r\n\r\n    QCOMPARE(testFunction->getSourceFiles()->size(), 1);\r\n    QSharedPointer<Function::SourceFile> testSource = testFunction->getSourceFiles()->first();\r\n    QCOMPARE(testSource->getSourceName(), QString(\"sourcery\"));\r\n    QCOMPARE(testSource->getFileType().type_, QString(\"swObject\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_FileSetReader::readID()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_FileSetReader::readID()\r\n{\r\n    QString documentContent(\r\n        \"<ipxact:fileSet>\"\r\n            \"<ipxact:name>testFileSet</ipxact:name>\"\r\n            \"<ipxact:vendorExtensions>\"\r\n                \"<kactus2:fileSetId>testID</kactus2:fileSetId>\"\r\n            \"</ipxact:vendorExtensions>\"\r\n        \"</ipxact:fileSet>\"\r\n        );\r\n\r\n\r\n    QDomDocument document;\r\n    document.setContent(documentContent);\r\n\r\n    QDomNode fileSetNode = document.firstChildElement(\"ipxact:fileSet\");\r\n\r\n    QSharedPointer<FileSet> testFileSet = FileSetReader::createFileSetFrom(fileSetNode, Document::Revision::Std14);\r\n\r\n    QCOMPARE(testFileSet->name(), QString(\"testFileSet\"));\r\n\r\n    QCOMPARE(testFileSet->getVendorExtensions()->size(), 1);\r\n    QCOMPARE(testFileSet->getVendorExtensions()->first()->type(), QString(\"kactus2:fileSetId\"));\r\n    QCOMPARE(testFileSet->getFileSetId(), QString(\"testID\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_FileSetReader::readVendorExtensions()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_FileSetReader::readVendorExtensions()\r\n{\r\n    QString documentContent(\r\n        \"<ipxact:fileSet>\"\r\n            \"<ipxact:name>testFileSet</ipxact:name>\"\r\n            \"<ipxact:vendorExtensions>\"\r\n                \"<testExtension testExtensionAttribute=\\\"extension\\\">testValue</testExtension>\"\r\n            \"</ipxact:vendorExtensions>\"\r\n        \"</ipxact:fileSet>\"\r\n        );\r\n\r\n\r\n    QDomDocument document;\r\n    document.setContent(documentContent);\r\n\r\n    QDomNode fileSetNode = document.firstChildElement(\"ipxact:fileSet\");\r\n\r\n    QSharedPointer<FileSet> testFileSet = FileSetReader::createFileSetFrom(fileSetNode, Document::Revision::Std14);\r\n\r\n    QCOMPARE(testFileSet->name(), QString(\"testFileSet\"));\r\n\r\n    QCOMPARE(testFileSet->getVendorExtensions()->size(), 1);\r\n    QCOMPARE(testFileSet->getVendorExtensions()->first()->type(), QString(\"testExtension\"));\r\n}\r\n\r\nQTEST_APPLESS_MAIN(tst_FileSetReader)\r\n\r\n#include \"tst_FileSetReader.moc\"\r\n"
  },
  {
    "path": "tests/IPXACTmodels/Component/tst_FileSetReader.pri",
    "content": "# ----------------------------------------------------\r\n# This file is generated by the Qt Visual Studio Add-in.\r\n# ------------------------------------------------------\r\n\r\nSOURCES += ./tst_FileSetReader.cpp \r\n"
  },
  {
    "path": "tests/IPXACTmodels/Component/tst_FileSetReader.pro",
    "content": "#-----------------------------------------------------------------------------\r\n# File: FileSetReader.pro\r\n#-----------------------------------------------------------------------------\r\n# Project: Kactus 2\r\n# Author: Mikko Teuho\r\n# Date: 22.09.2015\r\n#\r\n# Description:\r\n# Qt project file template for running unit tests for file set reader.\r\n#-----------------------------------------------------------------------------\r\n\r\nTEMPLATE = app\r\n\r\nTARGET = tst_FileSetReader\r\n\r\nQT += core xml testlib\r\nQT -= gui\r\n\r\nCONFIG += c++11 testcase console\r\n\r\nlinux-g++ | linux-g++-64 | linux-g++-32 {\r\n LIBS += -L../../../executable \\\r\n     -lIPXACTmodels\r\n\r\n}\r\n\r\nwin64 | win32 {\r\n LIBS += -L../../../executable \\\r\n     -lIPXACTmodelsd\r\n}\r\n\r\nINCLUDEPATH += $$DESTDIR\r\nINCLUDEPATH += ../../../\r\n\r\nDEPENDPATH += .\r\nDEPENDPATH += ../../../\r\n\r\nOBJECTS_DIR += $$DESTDIR\r\n\r\nMOC_DIR += ./generatedFiles\r\nUI_DIR += ./generatedFiles\r\nRCC_DIR += ./generatedFiles\r\ninclude(tst_FileSetReader.pri)\r\n"
  },
  {
    "path": "tests/IPXACTmodels/Component/tst_FileSetValidator.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// FileSet: tst_FileSetValidator.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Janne Virtanen\r\n// Date: 20.11.2015\r\n//\r\n// Description:\r\n// Unit test for class FileSetValidator.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include <IPXACTmodels/Component/validators/FileValidator.h>\r\n#include <IPXACTmodels/Component/validators/FileSetValidator.h>\r\n#include <IPXACTmodels/Component/FileSet.h>\r\n\r\n#include <KactusAPI/include/SystemVerilogExpressionParser.h>\r\n\r\n#include <QtTest>\r\n\r\nclass tst_FileSetValidator : public QObject\r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n    tst_FileSetValidator();\r\n\r\nprivate slots:\r\n\tvoid baseCase();\r\n\tvoid nameFail();\r\n\tvoid fileSetNoType();\r\n\tvoid fileSetBogusReplace();\r\n\tvoid hasValidFile();\r\n\tvoid hasInValidFile();\r\n\r\nprivate:\r\n    QSharedPointer<ExpressionParser> expressionParser_;\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_FileSetValidator::tst_FileSetValidator()\r\n//-----------------------------------------------------------------------------\r\ntst_FileSetValidator::tst_FileSetValidator(): expressionParser_(new SystemVerilogExpressionParser())\r\n{\r\n    \r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_FileSetValidator::baseCase()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_FileSetValidator::baseCase()\r\n{\r\n\tQSharedPointer<FileSet> fileSet( new FileSet );\r\n\tFileSetValidator validator(QSharedPointer<FileValidator>(new FileValidator(expressionParser_)),\r\n        expressionParser_);\r\n\tfileSet->setName(\"tekstit\");\r\n\t\r\n\tQSharedPointer<FileBuilder> builder( new FileBuilder );\r\n\tbuilder->setFileType(\"txt\");\r\n\tbuilder->setReplaceDefaultFlags(\"1\");\r\n\tfileSet->getDefaultFileBuilders()->append( builder );\r\n\r\n\tQVector<QString> errorList;\r\n\tvalidator.findErrorsIn(errorList, fileSet, \"test\");\r\n\r\n\tQCOMPARE( errorList.size(), 0 );\r\n\tQVERIFY( validator.validate(fileSet) );\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_FileSetValidator::nameFail()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_FileSetValidator::nameFail()\r\n{\r\n\tQSharedPointer<FileSet> fileSet( new FileSet );\r\n    FileSetValidator validator(QSharedPointer<FileValidator>(new FileValidator(expressionParser_)),\r\n        expressionParser_);\r\n\tfileSet->setName(\" \\t \\r \\n\");\r\n\r\n\tQSharedPointer<FileBuilder> builder( new FileBuilder );\r\n\tbuilder->setFileType(\"txt\");\r\n\tbuilder->setReplaceDefaultFlags(\"1\");\r\n\tfileSet->getDefaultFileBuilders()->append( builder );\r\n\r\n\tQVector<QString> errorList;\r\n\tvalidator.findErrorsIn(errorList, fileSet, \"test\");\r\n\r\n\tQCOMPARE( errorList.size(), 1 );\r\n\tQVERIFY( !validator.validate(fileSet) );\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_FileSetValidator::fileSetNoType()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_FileSetValidator::fileSetNoType()\r\n{\r\n\tQSharedPointer<FileSet> fileSet( new FileSet );\r\n    FileSetValidator validator(QSharedPointer<FileValidator>(new FileValidator(expressionParser_)),\r\n        expressionParser_);\r\n\tfileSet->setName(\"tekstit\");\r\n\r\n\tQSharedPointer<FileBuilder> builder( new FileBuilder );\r\n\tbuilder->setFileType(\"txt\");\r\n\tbuilder->setReplaceDefaultFlags(\"1\");\r\n\tfileSet->getDefaultFileBuilders()->append( builder );\r\n\tQSharedPointer<FileBuilder> builder2( new FileBuilder );\r\n\tbuilder2->setFileType(\"\");\r\n\tbuilder2->setReplaceDefaultFlags(\"1\");\r\n\tfileSet->getDefaultFileBuilders()->append( builder2 );\r\n\r\n\tQVector<QString> errorList;\r\n\tvalidator.findErrorsIn(errorList, fileSet, \"test\");\r\n\r\n\tQCOMPARE( errorList.size(), 1 );\r\n\tQVERIFY( !validator.validate(fileSet) );\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_FileSetValidator::fileSetBogusReplace()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_FileSetValidator::fileSetBogusReplace()\r\n{\r\n\tQSharedPointer<FileSet> fileSet( new FileSet );\r\n    FileSetValidator validator(QSharedPointer<FileValidator>(new FileValidator(expressionParser_)),\r\n        expressionParser_);\r\n\tfileSet->setName(\"tekstit\");\r\n\r\n\tQSharedPointer<FileBuilder> builder( new FileBuilder );\r\n\tbuilder->setFileType(\"txt\");\r\n\tbuilder->setReplaceDefaultFlags(\"joq\");\r\n\tfileSet->getDefaultFileBuilders()->append( builder );\r\n\r\n\tQVector<QString> errorList;\r\n\tvalidator.findErrorsIn(errorList, fileSet, \"test\");\r\n\r\n\tQCOMPARE( errorList.size(), 1 );\r\n\tQVERIFY( !validator.validate(fileSet) );\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_FileSetValidator::hasValidFile()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_FileSetValidator::hasValidFile()\r\n{\r\n\tQSharedPointer<FileSet> fileSet( new FileSet );\r\n    FileSetValidator validator(QSharedPointer<FileValidator>(new FileValidator(expressionParser_)),\r\n        expressionParser_);\r\n\tfileSet->setName(\"jutskat\");\r\n\r\n\tQSharedPointer<File> file( new File );\r\n\tfile->setName(\"osat.txt\");\r\n\r\n\tfile->setIsPresent(\"1\");\r\n\tfile->addFileType(\"part\");\r\n\tfile->getDefines()->append(QSharedPointer<NameValuePair>(new NameValuePair(\"halkasija\",\"kolme\") ));\r\n\r\n\tQSharedPointer<BuildCommand> bc( new BuildCommand );\r\n\tbc->setReplaceDefaultFlags(\"1\");\r\n\tfile->setBuildcommand( bc );\r\n\r\n\tfileSet->getFiles()->append(file);\r\n\r\n\tQVector<QString> errorList;\r\n\tvalidator.findErrorsIn(errorList, fileSet, \"test\");\r\n\r\n\tQCOMPARE( errorList.size(), 0 );\r\n\tQVERIFY( validator.validate(fileSet) );\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_FileSetValidator::hasInValidFile()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_FileSetValidator::hasInValidFile()\r\n{\r\n\tQSharedPointer<FileSet> fileSet( new FileSet );\r\n    FileSetValidator validator(QSharedPointer<FileValidator>(new FileValidator(expressionParser_)),\r\n        expressionParser_);\r\n\tfileSet->setName(\"jutskat\");\r\n\r\n\tQSharedPointer<File> file( new File );\r\n\tfile->setName(\"osat.txt\");\r\n\r\n\tfileSet->getFiles()->append(file);\r\n\r\n\tQVector<QString> errorList;\r\n\tvalidator.findErrorsIn(errorList, fileSet, \"test\");\r\n\r\n\tQCOMPARE( errorList.size(), 1 );\r\n\tQVERIFY( !validator.validate(fileSet) );\r\n}\r\n\r\nQTEST_APPLESS_MAIN(tst_FileSetValidator)\r\n\r\n#include \"tst_FileSetValidator.moc\"\r\n"
  },
  {
    "path": "tests/IPXACTmodels/Component/tst_FileSetValidator.pri",
    "content": "# ----------------------------------------------------\r\n# This file is generated by the Qt Visual Studio Tools.\r\n# ------------------------------------------------------\r\n\r\nHEADERS += ../../../editors/ComponentEditor/common/SystemVerilogExpressionParser.h \r\n\t\r\nSOURCES += ./tst_FileSetValidator.cpp \r\n\t"
  },
  {
    "path": "tests/IPXACTmodels/Component/tst_FileSetValidator.pro",
    "content": "#-----------------------------------------------------------------------------\r\n# FileSet: tst_FileSetValidator.pro\r\n#-----------------------------------------------------------------------------\r\n# Project: Kactus 2\r\n# Author: Janne Virtanen\r\n# Date: 20.11.2015\r\n#\r\n# Description:\r\n# Qt project FileSet template for running unit tests for File Set Validator.\r\n#-----------------------------------------------------------------------------\r\n\r\nTEMPLATE = app\r\n\r\nTARGET = tst_FileSetValidator\r\nQT += core xml testlib\r\nQT -= gui\r\n\r\nCONFIG += c++11 testcase console\r\n\r\nlinux-g++ | linux-g++-64 | linux-g++-32 {\r\n LIBS += -L../../../executable \\\r\n     -lIPXACTmodels -lKactusAPI\r\n\r\n}\r\nwin64 | win32 {\r\n LIBS += -L../../../executable \\\r\n     -lIPXACTmodelsd -lKactusAPId\r\n}\r\n\r\nINCLUDEPATH += $$DESTDIR\r\nINCLUDEPATH += ../../../\r\n\r\nDEPENDPATH += .\r\nDEPENDPATH += ../../../\r\n\r\nOBJECTS_DIR += $$DESTDIR\r\n\r\nMOC_DIR += ./generatedFiles\r\nUI_DIR += ./generatedFiles\r\nRCC_DIR += ./generatedFiles\r\ninclude(tst_FileSetValidator.pri)\r\n"
  },
  {
    "path": "tests/IPXACTmodels/Component/tst_FileSetWriter.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: tst_FileSetWriter.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 18.09.2015\r\n//\r\n// Description:\r\n// Unit test for class FileSetWriter.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include <IPXACTmodels/Component/FileSetWriter.h>\r\n\r\n#include <IPXACTmodels/common/GenericVendorExtension.h>\r\n\r\n#include <QtTest>\r\n\r\nclass tst_FileSetWriter : public QObject\r\n{\r\n    Q_OBJECT\r\n\r\npublic:\r\n    tst_FileSetWriter();\r\n\r\nprivate slots:\r\n\r\n    void init();\r\n\r\n    void writeSimpleFileSet();\r\n    void writeSimple2022FileSet();\r\n\r\n    void writeGroups();\r\n    void writeFiles();\r\n    void writeDefaultFileBuilders();\r\n    void writeDependencies();\r\n    void writeFunctions();\r\n\r\n    void writeID();\r\n    void writeVendorExtensions();\r\n\r\nprivate:\r\n\r\n    QSharedPointer<FileSet> testFileSet_;\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_FileSetWriter::tst_FileSetWriter()\r\n//-----------------------------------------------------------------------------\r\ntst_FileSetWriter::tst_FileSetWriter()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_FileSetWriter::init()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_FileSetWriter::init()\r\n{\r\n    testFileSet_ = QSharedPointer<FileSet> (new FileSet(\"testFileSet\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_FileSetWriter::writeSimpleFileSet()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_FileSetWriter::writeSimpleFileSet()\r\n{\r\n    QString output;\r\n    QXmlStreamWriter xmlStreamWriter(&output);\r\n\r\n    testFileSet_->setDisplayName(\"fileSetDisplay\");\r\n    testFileSet_->setDescription(\"fileSetDescription\");\r\n\r\n    QString expectedOutput(\r\n        \"<ipxact:fileSet>\"\r\n            \"<ipxact:name>testFileSet</ipxact:name>\"\r\n        \"</ipxact:fileSet>\"\r\n        );\r\n\r\n    expectedOutput = \r\n        \"<ipxact:fileSet>\"\r\n            \"<ipxact:name>testFileSet</ipxact:name>\"\r\n            \"<ipxact:displayName>fileSetDisplay</ipxact:displayName>\"\r\n            \"<ipxact:description>fileSetDescription</ipxact:description>\"\r\n        \"</ipxact:fileSet>\"\r\n        ;\r\n\r\n    FileSetWriter::writeFileSet(xmlStreamWriter, testFileSet_, Document::Revision::Std14);\r\n    QCOMPARE(output, expectedOutput);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_FileSetWriter::writeSimple2022FileSet()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_FileSetWriter::writeSimple2022FileSet()\r\n{\r\n    QString output;\r\n    QXmlStreamWriter xmlStreamWriter(&output);\r\n\r\n    testFileSet_->setDisplayName(\"fileSetDisplay\");\r\n    testFileSet_->setShortDescription(\"brief\");\r\n    testFileSet_->setDescription(\"fileSetDescription\");\r\n\r\n    QString  expectedOutput =\r\n        \"<ipxact:fileSet>\"\r\n        \"<ipxact:name>testFileSet</ipxact:name>\"\r\n        \"<ipxact:displayName>fileSetDisplay</ipxact:displayName>\"\r\n        \"<ipxact:shortDescription>brief</ipxact:shortDescription>\"\r\n        \"<ipxact:description>fileSetDescription</ipxact:description>\"\r\n        \"</ipxact:fileSet>\";\r\n\r\n    FileSetWriter::writeFileSet(xmlStreamWriter, testFileSet_, Document::Revision::Std22);\r\n    QCOMPARE(output, expectedOutput);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_FileSetWriter::writeGroups()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_FileSetWriter::writeGroups()\r\n{\r\n    QString output;\r\n    QXmlStreamWriter xmlStreamWriter(&output);\r\n\r\n    testFileSet_->getGroups()->append(\"firstGroup\");\r\n\r\n    QString expectedOutput(\r\n        \"<ipxact:fileSet>\"\r\n            \"<ipxact:name>testFileSet</ipxact:name>\"\r\n            \"<ipxact:group>firstGroup</ipxact:group>\"\r\n        \"</ipxact:fileSet>\"\r\n        );\r\n\r\n    FileSetWriter::writeFileSet(xmlStreamWriter, testFileSet_, Document::Revision::Std14);\r\n    QCOMPARE(output, expectedOutput);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_FileSetWriter::writeFiles()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_FileSetWriter::writeFiles()\r\n{\r\n    QString output;\r\n    QXmlStreamWriter xmlStreamWriter(&output);\r\n\r\n    QSharedPointer<File> testFile (new File(\"./test/file\", \"userFile\"));\r\n    testFileSet_->getFiles()->append(testFile);\r\n\r\n    QString expectedOutput(\r\n        \"<ipxact:fileSet>\"\r\n            \"<ipxact:name>testFileSet</ipxact:name>\"\r\n            \"<ipxact:file>\"\r\n                \"<ipxact:name>./test/file</ipxact:name>\"\r\n                \"<ipxact:fileType user=\\\"userFile\\\">user</ipxact:fileType>\"\r\n            \"</ipxact:file>\"\r\n        \"</ipxact:fileSet>\"\r\n        );\r\n\r\n    FileSetWriter::writeFileSet(xmlStreamWriter, testFileSet_, Document::Revision::Std14);\r\n    QCOMPARE(output, expectedOutput);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_FileSetWriter::writeDefaultFileBuilders()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_FileSetWriter::writeDefaultFileBuilders()\r\n{\r\n    QString output;\r\n    QXmlStreamWriter xmlStreamWriter(&output);\r\n\r\n    QSharedPointer<FileBuilder> defaultFileBuilder (new FileBuilder(\"asmSource\"));\r\n    defaultFileBuilder->setCommand(\"4+5+6-14\");\r\n\r\n    testFileSet_->getDefaultFileBuilders()->append(defaultFileBuilder);\r\n    defaultFileBuilder->setFileType(\"userFile\", \"ext\");\r\n    defaultFileBuilder->setFlags(\"2-1\");\r\n    defaultFileBuilder->setReplaceDefaultFlags(\"0\");\r\n    defaultFileBuilder->getVendorExtensions()->append(\r\n        QSharedPointer<VendorExtension>(new Kactus2Value(\"test\", \"extension\")));\r\n\r\n    FileSetWriter::writeFileSet(xmlStreamWriter, testFileSet_, Document::Revision::Std14);\r\n\r\n    QString expected2014Output =\r\n        \"<ipxact:fileSet>\"\r\n            \"<ipxact:name>testFileSet</ipxact:name>\"\r\n            \"<ipxact:defaultFileBuilder>\"\r\n                \"<ipxact:fileType user=\\\"userFile\\\">user</ipxact:fileType>\"\r\n                \"<ipxact:command>4+5+6-14</ipxact:command>\"\r\n                \"<ipxact:flags>2-1</ipxact:flags>\"\r\n                \"<ipxact:replaceDefaultFlags>0</ipxact:replaceDefaultFlags>\"\r\n                \"<ipxact:vendorExtensions>\"\r\n                    \"<test>extension</test>\"\r\n                \"</ipxact:vendorExtensions>\"\r\n            \"</ipxact:defaultFileBuilder>\"\r\n        \"</ipxact:fileSet>\";\r\n\r\n    QCOMPARE(output, expected2014Output);\r\n\r\n    output.clear();\r\n    FileSetWriter::writeFileSet(xmlStreamWriter, testFileSet_, Document::Revision::Std22);\r\n\r\n    QString expected2022Output =\r\n        \"<ipxact:fileSet>\"\r\n            \"<ipxact:name>testFileSet</ipxact:name>\"\r\n            \"<ipxact:defaultFileBuilder>\"\r\n                \"<ipxact:fileType user=\\\"userFile\\\" libext=\\\"ext\\\">user</ipxact:fileType>\"\r\n                \"<ipxact:command>4+5+6-14</ipxact:command>\"\r\n                \"<ipxact:flags>2-1</ipxact:flags>\"\r\n                \"<ipxact:replaceDefaultFlags>0</ipxact:replaceDefaultFlags>\"\r\n            \"</ipxact:defaultFileBuilder>\"\r\n        \"</ipxact:fileSet>\";\r\n\r\n    QCOMPARE(output, expected2022Output);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_FileSetWriter::writeDependencies()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_FileSetWriter::writeDependencies()\r\n{\r\n    QString output;\r\n    QXmlStreamWriter xmlStreamWriter(&output);\r\n\r\n    testFileSet_->addDependency(\"Stan\");\r\n    testFileSet_->addDependency(\"Ollie\");\r\n\r\n    QString expectedOutput(\r\n        \"<ipxact:fileSet>\"\r\n            \"<ipxact:name>testFileSet</ipxact:name>\"\r\n            \"<ipxact:dependency>Stan</ipxact:dependency>\"\r\n            \"<ipxact:dependency>Ollie</ipxact:dependency>\"\r\n        \"</ipxact:fileSet>\"\r\n        );\r\n\r\n    FileSetWriter::writeFileSet(xmlStreamWriter, testFileSet_, Document::Revision::Std14);\r\n    QCOMPARE(output, expectedOutput);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_FileSetWriter::writeFunctions()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_FileSetWriter::writeFunctions()\r\n{\r\n    QString output;\r\n    QXmlStreamWriter xmlStreamWriter(&output);\r\n\r\n    QDomDocument document;\r\n    QDomElement extensionNode = document.createElement(\"testExtension\");\r\n    extensionNode.setAttribute(\"testExtensionAttribute\", \"extension\");\r\n    extensionNode.appendChild(document.createTextNode(\"testValue\"));\r\n\r\n    QSharedPointer<GenericVendorExtension> testExtension(new GenericVendorExtension(extensionNode));\r\n\r\n    QSharedPointer<NameValuePair> argument (new NameValuePair(\"ninja\", \"ninjutsu\"));\r\n    argument->setDisplayName(\"shinobi\");\r\n    argument->setDescription(\"oniwaban\");\r\n    argument->getVendorExtensions()->append(testExtension);\r\n\r\n    QSharedPointer<Function::SourceFile> sourceFile (new Function::SourceFile(\"sourcery\", \"swObject\"));\r\n\r\n    QSharedPointer<Function> testFunction (new Function(\"nineCuts\"));\r\n    testFunction->setReplicate(true);\r\n    testFunction->setEntryPoint(\"uguisubari\");\r\n    testFunction->setReturnType(\"void\");\r\n    testFunction->getArguments()->append(argument);\r\n    testFunction->setDisabled(\"4-2*2+1\");\r\n    testFunction->getSourceFiles()->append(sourceFile);\r\n\r\n    testFileSet_->getFunctions()->append(testFunction);\r\n\r\n    QString expectedOutput(\r\n        \"<ipxact:fileSet>\"\r\n            \"<ipxact:name>testFileSet</ipxact:name>\"\r\n            \"<ipxact:function replicate=\\\"true\\\">\"\r\n                \"<ipxact:entryPoint>uguisubari</ipxact:entryPoint>\"\r\n                \"<ipxact:fileRef>nineCuts</ipxact:fileRef>\"\r\n                \"<ipxact:returnType>void</ipxact:returnType>\"\r\n                \"<ipxact:argument>\"\r\n                    \"<ipxact:name>ninja</ipxact:name>\"\r\n                    \"<ipxact:displayName>shinobi</ipxact:displayName>\"\r\n                    \"<ipxact:description>oniwaban</ipxact:description>\"\r\n                    \"<ipxact:value>ninjutsu</ipxact:value>\"\r\n                    \"<ipxact:vendorExtensions>\"\r\n                        \"<testExtension testExtensionAttribute=\\\"extension\\\">testValue</testExtension>\"\r\n                    \"</ipxact:vendorExtensions>\"\r\n                \"</ipxact:argument>\"\r\n                \"<ipxact:disabled>4-2*2+1</ipxact:disabled>\"\r\n                \"<ipxact:sourceFile>\"\r\n                    \"<ipxact:sourceName>sourcery</ipxact:sourceName>\"\r\n                    \"<ipxact:fileType>swObject</ipxact:fileType>\"\r\n                \"</ipxact:sourceFile>\"\r\n            \"</ipxact:function>\"\r\n        \"</ipxact:fileSet>\"\r\n        );\r\n\r\n    FileSetWriter::writeFileSet(xmlStreamWriter, testFileSet_, Document::Revision::Std14);\r\n    QCOMPARE(output, expectedOutput);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_FileSetWriter::writeID()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_FileSetWriter::writeID()\r\n{\r\n    QString output;\r\n    QXmlStreamWriter xmlStreamWriter(&output);\r\n\r\n    testFileSet_->setFileSetId(\"GurrenLagann\");\r\n\r\n    QString expectedOutput(\r\n        \"<ipxact:fileSet>\"\r\n            \"<ipxact:name>testFileSet</ipxact:name>\"\r\n            \"<ipxact:vendorExtensions>\"\r\n                \"<kactus2:fileSetId>GurrenLagann</kactus2:fileSetId>\"\r\n            \"</ipxact:vendorExtensions>\"\r\n        \"</ipxact:fileSet>\"\r\n        );\r\n\r\n    FileSetWriter::writeFileSet(xmlStreamWriter, testFileSet_, Document::Revision::Std14);\r\n    QCOMPARE(output, expectedOutput);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_FileSetWriter::writeVendorExtensions()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_FileSetWriter::writeVendorExtensions()\r\n{\r\n    QString output;\r\n    QXmlStreamWriter xmlStreamWriter(&output);\r\n\r\n    QDomDocument document;\r\n    QDomElement extensionNode = document.createElement(\"testExtension\");\r\n    extensionNode.setAttribute(\"testExtensionAttribute\", \"extension\");\r\n    extensionNode.appendChild(document.createTextNode(\"testValue\"));\r\n\r\n    QSharedPointer<GenericVendorExtension> testExtension(new GenericVendorExtension(extensionNode));\r\n\r\n    testFileSet_->getVendorExtensions()->append(testExtension);\r\n\r\n    QString expectedOutput(\r\n        \"<ipxact:fileSet>\"\r\n            \"<ipxact:name>testFileSet</ipxact:name>\"\r\n            \"<ipxact:vendorExtensions>\"\r\n                \"<testExtension testExtensionAttribute=\\\"extension\\\">testValue</testExtension>\"\r\n            \"</ipxact:vendorExtensions>\"\r\n        \"</ipxact:fileSet>\"\r\n        );\r\n\r\n    FileSetWriter::writeFileSet(xmlStreamWriter, testFileSet_, Document::Revision::Std14);\r\n    QCOMPARE(output, expectedOutput);\r\n}\r\n\r\nQTEST_APPLESS_MAIN(tst_FileSetWriter)\r\n\r\n#include \"tst_FileSetWriter.moc\"\r\n"
  },
  {
    "path": "tests/IPXACTmodels/Component/tst_FileSetWriter.pri",
    "content": "# ----------------------------------------------------\r\n# This file is generated by the Qt Visual Studio Add-in.\r\n# ------------------------------------------------------\r\n\r\nSOURCES += ./tst_FileSetWriter.cpp \r\n"
  },
  {
    "path": "tests/IPXACTmodels/Component/tst_FileSetWriter.pro",
    "content": "#-----------------------------------------------------------------------------\r\n# File: tst_FileSetWriter.pro\r\n#-----------------------------------------------------------------------------\r\n# Project: Kactus 2\r\n# Author: Mikko Teuho\r\n# Date: 18.09.2015\r\n#\r\n# Description:\r\n# Qt project file template for running unit tests for file set writer.\r\n#-----------------------------------------------------------------------------\r\n\r\nTEMPLATE = app\r\n\r\nTARGET = tst_FileSetWriter\r\n\r\nQT += core xml testlib\r\nQT -= gui\r\n\r\nCONFIG += c++11 testcase console\r\n\r\nlinux-g++ | linux-g++-64 | linux-g++-32 {\r\n LIBS += -L../../../executable \\\r\n     -lIPXACTmodels\r\n\r\n}\r\nwin64 | win32 {\r\n LIBS += -L../../../executable \\\r\n     -lIPXACTmodelsd\r\n}\r\n\r\nINCLUDEPATH += $$DESTDIR\r\nINCLUDEPATH += ../../../\r\n\r\nDEPENDPATH += .\r\nDEPENDPATH += ../../../\r\n\r\nOBJECTS_DIR += $$DESTDIR\r\n\r\nMOC_DIR += ./generatedFiles\r\nUI_DIR += ./generatedFiles\r\nRCC_DIR += ./generatedFiles\r\ninclude(tst_FileSetWriter.pri)\r\n"
  },
  {
    "path": "tests/IPXACTmodels/Component/tst_FileValidator.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: tst_FileValidator.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Janne Virtanen\r\n// Date: 20.11.2015\r\n//\r\n// Description:\r\n// Unit test for class FileValidator.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include <IPXACTmodels/Component/validators/FileValidator.h>\r\n#include <IPXACTmodels/Component/File.h>\r\n\r\n#include <KactusAPI/include/SystemVerilogExpressionParser.h>\r\n\r\n#include <QtTest>\r\n#include <QSharedPointer>\r\n\r\nclass tst_FileValidator : public QObject\r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n    tst_FileValidator();\r\n\r\nprivate slots:\r\n\tvoid baseCase();\r\n\tvoid failFileTypes();\r\n\tvoid failName();\r\n\tvoid testIpxactURIinName();\r\n\tvoid failDefine();\r\n\tvoid failReplaceDefaultFlags();\r\n\r\nprivate:\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_FileValidator::tst_FileValidator()\r\n//-----------------------------------------------------------------------------\r\ntst_FileValidator::tst_FileValidator()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_FileValidator::baseCase()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_FileValidator::baseCase()\r\n{\r\n\tQSharedPointer<File> file(new File());\r\n\tFileValidator validator(QSharedPointer<ExpressionParser>(new SystemVerilogExpressionParser()));\r\n\tfile->setName(\"ruokalista.txt\");\r\n\r\n\tfile->setIsPresent(\"1\");\r\n\tfile->getFileTypes()->append(FileType(\"text\"));\r\n\tfile->getDefines()->append(QSharedPointer<NameValuePair>(new NameValuePair(\"Lihapullia\",\"viis\") ));\r\n\t\r\n\tQSharedPointer<BuildCommand> bc( new BuildCommand );\r\n\tbc->setReplaceDefaultFlags(\"1\");\r\n\tfile->setBuildcommand( bc );\r\n\r\n\tQVector<QString> errorList;\r\n\tvalidator.findErrorsIn(errorList, file, \"test\");\r\n\r\n\tQCOMPARE( errorList.size(), 0 );\r\n\tQVERIFY( validator.validate(file) );\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_FileValidator::failFileTypes()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_FileValidator::failFileTypes()\r\n{\r\n\tQSharedPointer<File> file( new File );\r\n\tFileValidator validator(QSharedPointer<ExpressionParser>(new SystemVerilogExpressionParser()));\r\n\tfile->setName(\"ruokalista.txt\");\r\n\r\n\tQVector<QString> errorList;\r\n\tvalidator.findErrorsIn(errorList, file, \"test\");\r\n\r\n\tQCOMPARE( errorList.size(), 1 );\r\n\tQCOMPARE( errorList.first(), QString(\"File ruokalista.txt must have at least one file type defined.\"));\r\n\tQVERIFY( !validator.validate(file) );\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_FileValidator::failName()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_FileValidator::failName()\r\n{\r\n\tQSharedPointer<File> file( new File );\r\n    FileValidator validator(QSharedPointer<ExpressionParser>(new SystemVerilogExpressionParser()));\r\n\tfile->setName(\" \\t\\n\\r\");\r\n\r\n\tfile->getFileTypes()->append(FileType(\"text\"));\r\n\r\n\tQVector<QString> errorList;\r\n\tvalidator.findErrorsIn(errorList, file, \"test\");\r\n\r\n\tQCOMPARE( errorList.size(), 1 );\r\n\tQCOMPARE(errorList.first(), QString(\"The file name ' \\t\\n\\r' is invalid within test.\"));\r\n\tQVERIFY( !validator.validate(file) );\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_FileValidator::testIpxactURIinName()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_FileValidator::testIpxactURIinName()\r\n{\r\n    QSharedPointer<File> file(new File);\r\n    FileValidator validator(QSharedPointer<ExpressionParser>(new SystemVerilogExpressionParser()));\r\n    file->setName(\"${SRC_PATH}test.sv\");\r\n\r\n    file->getFileTypes()->append(FileType(\"SystemVerilogSource\"));\r\n\r\n    QVector<QString> errorList;\r\n    validator.findErrorsIn(errorList, file, \"test\");\r\n\r\n    QVERIFY(validator.hasValidName(file->name()));\r\n    QCOMPARE(errorList.size(), 0);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_FileValidator::failDefine()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_FileValidator::failDefine()\r\n{\r\n\tQSharedPointer<File> file( new File );\r\n\tFileValidator validator(QSharedPointer<ExpressionParser>(new SystemVerilogExpressionParser()));\r\n\tfile->setName(\"joku.txt\");\r\n\r\n\tfile->getFileTypes()->append(FileType(\"text\"));\r\n\tfile->getDefines()->append(QSharedPointer<NameValuePair>(new NameValuePair(\" \\t\\r\\n\", \"viis\") ));\r\n\r\n\tQVector<QString> errorList;\r\n\tvalidator.findErrorsIn(errorList, file, \"test\");\r\n\r\n\tQCOMPARE( errorList.size(), 1 );\r\n\tQCOMPARE( errorList.first(), QString(\"The name '' of a define is invalid within file joku.txt.\"));\r\n\tQVERIFY( !validator.validate(file) );\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_FileValidator::failReplaceDefaultFlags()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_FileValidator::failReplaceDefaultFlags()\r\n{\r\n\tQSharedPointer<File> file( new File );\r\n    FileValidator validator(QSharedPointer<ExpressionParser>(new SystemVerilogExpressionParser()));\r\n\tfile->setName(\"joku.txt\");\r\n\r\n\tfile->getFileTypes()->append(FileType(\"text\"));\r\n\tQSharedPointer<BuildCommand> bc( new BuildCommand );\r\n\tbc->setReplaceDefaultFlags(\"rertthyju\");\r\n\tfile->setBuildcommand( bc );\r\n\r\n\tQVector<QString> errorList;\r\n\tvalidator.findErrorsIn(errorList, file, \"test\");\r\n\r\n\tQCOMPARE( errorList.size(), 1 );\r\n\tQCOMPARE( errorList.first(), \r\n\t\tQString(\"Invalid \\\"replace default flags\\\" value set for build command in file joku.txt. Value must evaluate to 0 or 1.\"));\r\n\tQVERIFY( !validator.validate(file) );\r\n}\r\n\r\nQTEST_APPLESS_MAIN(tst_FileValidator)\r\n\r\n#include \"tst_FileValidator.moc\"\r\n"
  },
  {
    "path": "tests/IPXACTmodels/Component/tst_FileValidator.pri",
    "content": "# ----------------------------------------------------\r\n# This file is generated by the Qt Visual Studio Tools.\r\n# ------------------------------------------------------\r\n\r\nHEADERS += ../../../editors/ComponentEditor/common/SystemVerilogExpressionParser.h \r\n\t\r\nSOURCES += ./tst_FileValidator.cpp \r\n\t"
  },
  {
    "path": "tests/IPXACTmodels/Component/tst_FileValidator.pro",
    "content": "#-----------------------------------------------------------------------------\r\n# File: tst_FileValidator.pro\r\n#-----------------------------------------------------------------------------\r\n# Project: Kactus 2\r\n# Author: Janne Virtanen\r\n# Date: 20.11.2015\r\n#\r\n# Description:\r\n# Qt project file template for running unit tests for File Validator.\r\n#-----------------------------------------------------------------------------\r\n\r\nTEMPLATE = app\r\n\r\nTARGET = tst_FileValidator\r\n\r\nQT += core xml testlib\r\nQT -= gui\r\n\r\nCONFIG += c++11 testcase console\r\n\r\nlinux-g++ | linux-g++-64 | linux-g++-32 {\r\n LIBS += -L../../../executable \\\r\n     -lIPXACTmodels -lKactusAPI\r\n\r\n}\r\nwin64 | win32 {\r\n LIBS += -L../../../executable \\\r\n     -lIPXACTmodelsd -lKactusAPId\r\n}\r\n\r\nINCLUDEPATH += $$DESTDIR\r\nINCLUDEPATH += ../../../\r\n\r\nDEPENDPATH += .\r\nDEPENDPATH += ../../../\r\n\r\nOBJECTS_DIR += $$DESTDIR\r\n\r\nMOC_DIR += ./generatedFiles\r\nUI_DIR += ./generatedFiles\r\nRCC_DIR += ./generatedFiles\r\ninclude(tst_FileValidator.pri)\r\n"
  },
  {
    "path": "tests/IPXACTmodels/Component/tst_FileWriter.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: tst_FileWriter.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 16.09.2015\r\n//\r\n// Description:\r\n// Unit test for class FileWriter.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include <IPXACTmodels/Component/File.h>\r\n#include <IPXACTmodels/Component/FileWriter.h>\r\n\r\n#include <IPXACTmodels/common/GenericVendorExtension.h>\r\n\r\n#include <QDomDocument>\r\n#include <QtTest>\r\n\r\nclass tst_FileWriter : public QObject\r\n{\r\n    Q_OBJECT\r\n\r\npublic:\r\n    tst_FileWriter();\r\n\r\nprivate slots:\r\n\r\n    void init();\r\n    void cleanup();\r\n\r\n    void writeSimpleFile();\r\n    void writeFileAttributes();\r\n    \r\n    void writeFileTypes();\r\n\r\n    void writeIsPresent();\r\n    void isPresentIsNotWrittenFor2022File();\r\n\r\n    void writeLibextFor2022File();\r\n\r\n    void writeIsStructural();\r\n    void writeIsIncluded();\r\n    void writeLogicalName();\r\n    void writeExportedName();\r\n    void writeBuildCommand();\r\n    void writeDependencies();\r\n    void writeDefines();\r\n    void writeImageTypes();\r\n    void writeDescription();\r\n\r\n    //void writeHashExtensions();\r\n    void writeVendorExtensions();\r\n\r\nprivate:\r\n\r\n    QSharedPointer<File> testFile_;\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_FileWriter::tst_FileWriter()\r\n//-----------------------------------------------------------------------------\r\ntst_FileWriter::tst_FileWriter()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_FileWriter::init()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_FileWriter::init()\r\n{\r\n    testFile_ = QSharedPointer<File> (new File(\"./testFile\", \"vhdlSource\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_FileWriter::cleanup()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_FileWriter::cleanup()\r\n{\r\n    testFile_.clear();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_FileWriter::writeSimpleFile()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_FileWriter::writeSimpleFile()\r\n{\r\n    QString output;\r\n    QXmlStreamWriter xmlStreamWriter(&output);\r\n\r\n    QString expectedOutput(\r\n        \"<ipxact:file>\"\r\n            \"<ipxact:name>./testFile</ipxact:name>\"\r\n            \"<ipxact:fileType>vhdlSource</ipxact:fileType>\"\r\n        \"</ipxact:file>\"\r\n        );\r\n\r\n    FileWriter::writeFile(xmlStreamWriter, testFile_, Document::Revision::Std14);\r\n    QCOMPARE(output, expectedOutput);\r\n\r\n    output.clear();\r\n    expectedOutput.clear();\r\n\r\n    testFile_->getFileTypes()->append(FileType(\"testUserFileType\"));\r\n    expectedOutput =\r\n        \"<ipxact:file>\"\r\n            \"<ipxact:name>./testFile</ipxact:name>\"\r\n            \"<ipxact:fileType>vhdlSource</ipxact:fileType>\"\r\n            \"<ipxact:fileType user=\\\"testUserFileType\\\">user</ipxact:fileType>\"\r\n        \"</ipxact:file>\"\r\n        ;\r\n\r\n    FileWriter::writeFile(xmlStreamWriter, testFile_, Document::Revision::Std14);\r\n    QCOMPARE(output, expectedOutput);\r\n\r\n    output.clear();\r\n\r\n    testFile_->getFileTypes()->removeLast();\r\n    testFile_->setDescription(\"describedFile\");\r\n    expectedOutput =\r\n        \"<ipxact:file>\"\r\n            \"<ipxact:name>./testFile</ipxact:name>\"\r\n            \"<ipxact:fileType>vhdlSource</ipxact:fileType>\"\r\n            \"<ipxact:description>describedFile</ipxact:description>\"\r\n        \"</ipxact:file>\"\r\n        ;\r\n\r\n    FileWriter::writeFile(xmlStreamWriter, testFile_, Document::Revision::Std14);\r\n    QCOMPARE(output, expectedOutput);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_FileWriter::writeFileAttributes()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_FileWriter::writeFileAttributes()\r\n{\r\n    QString output;\r\n    QXmlStreamWriter xmlStreamWriter(&output);\r\n\r\n    testFile_->setFileId(\"testID\");\r\n\r\n    QString expectedOutput(\r\n        \"<ipxact:file fileId=\\\"testID\\\">\"\r\n            \"<ipxact:name>./testFile</ipxact:name>\"\r\n            \"<ipxact:fileType>vhdlSource</ipxact:fileType>\"\r\n        \"</ipxact:file>\"\r\n        );\r\n\r\n    FileWriter::writeFile(xmlStreamWriter, testFile_, Document::Revision::Std14);\r\n    QCOMPARE(output, expectedOutput);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_FileWriter::writeFileTypes()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_FileWriter::writeFileTypes()\r\n{\r\n    QString output;\r\n    QXmlStreamWriter xmlStreamWriter(&output);\r\n\r\n    testFile_->addFileType(\"vhdlSource2002\");\r\n    testFile_->addFileType(\"vhdlSource2008\", \"ext\");\r\n    testFile_->addFileType(\"custom\", \"lib\");\r\n\r\n    FileWriter::writeFile(xmlStreamWriter, testFile_, Document::Revision::Std14);\r\n\r\n    QString expectedOutputFor2014(\r\n        \"<ipxact:file>\"\r\n        \"<ipxact:name>./testFile</ipxact:name>\"\r\n        \"<ipxact:fileType>vhdlSource</ipxact:fileType>\"\r\n        \"<ipxact:fileType user=\\\"vhdlSource2002\\\">user</ipxact:fileType>\"\r\n        \"<ipxact:fileType user=\\\"vhdlSource2008\\\">user</ipxact:fileType>\"\r\n        \"<ipxact:fileType user=\\\"custom\\\">user</ipxact:fileType>\"\r\n        \"</ipxact:file>\"\r\n    );\r\n    QCOMPARE(output, expectedOutputFor2014);\r\n\r\n\r\n    output.clear();\r\n    FileWriter::writeFile(xmlStreamWriter, testFile_, Document::Revision::Std22);\r\n\r\n    QString expectedOutputFor2022(\r\n        \"<ipxact:file>\"\r\n        \"<ipxact:name>./testFile</ipxact:name>\"\r\n        \"<ipxact:fileType>vhdlSource</ipxact:fileType>\"\r\n        \"<ipxact:fileType>vhdlSource2002</ipxact:fileType>\"\r\n        \"<ipxact:fileType libext=\\\"ext\\\">vhdlSource2008</ipxact:fileType>\"\r\n        \"<ipxact:fileType user=\\\"custom\\\" libext=\\\"lib\\\">user</ipxact:fileType>\"\r\n        \"</ipxact:file>\"\r\n    );\r\n    QCOMPARE(output, expectedOutputFor2022);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_FileWriter::writeIsPresent()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_FileWriter::writeIsPresent()\r\n{\r\n    QString output;\r\n    QXmlStreamWriter xmlStreamWriter(&output);\r\n\r\n    testFile_->setIsPresent(\"4*4/4-3\");\r\n\r\n    QString expectedOutput(\r\n        \"<ipxact:file>\"\r\n            \"<ipxact:name>./testFile</ipxact:name>\"\r\n            \"<ipxact:isPresent>4*4/4-3</ipxact:isPresent>\"\r\n            \"<ipxact:fileType>vhdlSource</ipxact:fileType>\"\r\n        \"</ipxact:file>\"\r\n        );\r\n\r\n    FileWriter::writeFile(xmlStreamWriter, testFile_, Document::Revision::Std14);\r\n    QCOMPARE(output, expectedOutput);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_FileWriter::isPresentIsNotWrittenFor2022File()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_FileWriter::isPresentIsNotWrittenFor2022File()\r\n{\r\n    QString output;\r\n    QXmlStreamWriter xmlStreamWriter(&output);\r\n\r\n    testFile_->setIsPresent(\"1\");\r\n\r\n    QString expectedOutput(\r\n        \"<ipxact:file>\"\r\n        \"<ipxact:name>./testFile</ipxact:name>\"\r\n        \"<ipxact:fileType>vhdlSource</ipxact:fileType>\"\r\n        \"</ipxact:file>\"\r\n    );\r\n\r\n    FileWriter::writeFile(xmlStreamWriter, testFile_, Document::Revision::Std22);\r\n    QCOMPARE(output, expectedOutput);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_FileWriter::writeLibextFor2022File()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_FileWriter::writeLibextFor2022File()\r\n{\r\n    QString output;\r\n    QXmlStreamWriter xmlStreamWriter(&output);\r\n\r\n    testFile_->addFileType(\"vhdlSource2008\", \"lib\");\r\n\r\n    QString expectedOutput(\r\n        \"<ipxact:file>\"\r\n        \"<ipxact:name>./testFile</ipxact:name>\"\r\n        \"<ipxact:fileType>vhdlSource</ipxact:fileType>\"\r\n        \"<ipxact:fileType libext=\\\"lib\\\">vhdlSource2008</ipxact:fileType>\"\r\n        \"</ipxact:file>\"\r\n    );\r\n\r\n    FileWriter::writeFile(xmlStreamWriter, testFile_, Document::Revision::Std22);\r\n    QCOMPARE(output, expectedOutput);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_FileWriter::writeIsStructural()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_FileWriter::writeIsStructural()\r\n{\r\n    QString output;\r\n    QXmlStreamWriter xmlStreamWriter(&output);\r\n\r\n    testFile_->setStructural(true);\r\n\r\n    QString expectedOutput(\r\n        \"<ipxact:file>\"\r\n            \"<ipxact:name>./testFile</ipxact:name>\"\r\n            \"<ipxact:fileType>vhdlSource</ipxact:fileType>\"\r\n            \"<ipxact:isStructural>true</ipxact:isStructural>\"\r\n        \"</ipxact:file>\"\r\n        );\r\n\r\n    FileWriter::writeFile(xmlStreamWriter, testFile_, Document::Revision::Std14);\r\n    QCOMPARE(output, expectedOutput);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_FileWriter::writeIsIncluded()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_FileWriter::writeIsIncluded()\r\n{\r\n    QString output;\r\n    QXmlStreamWriter xmlStreamWriter(&output);\r\n\r\n    testFile_->setIncludeFile(true);\r\n\r\n    QString expectedOutput(\r\n        \"<ipxact:file>\"\r\n            \"<ipxact:name>./testFile</ipxact:name>\"\r\n            \"<ipxact:fileType>vhdlSource</ipxact:fileType>\"\r\n            \"<ipxact:isIncludeFile>true</ipxact:isIncludeFile>\"\r\n        \"</ipxact:file>\"\r\n        );\r\n\r\n    FileWriter::writeFile(xmlStreamWriter, testFile_, Document::Revision::Std14);\r\n    QCOMPARE(output, expectedOutput);\r\n\r\n    output.clear();\r\n    expectedOutput.clear();\r\n\r\n    testFile_->setExternalDeclarations(true);\r\n    expectedOutput = \r\n        \"<ipxact:file>\"\r\n            \"<ipxact:name>./testFile</ipxact:name>\"\r\n            \"<ipxact:fileType>vhdlSource</ipxact:fileType>\"\r\n            \"<ipxact:isIncludeFile externalDeclarations=\\\"true\\\">true</ipxact:isIncludeFile>\"\r\n        \"</ipxact:file>\"\r\n        ;\r\n\r\n    FileWriter::writeFile(xmlStreamWriter, testFile_, Document::Revision::Std14);\r\n    QCOMPARE(output, expectedOutput);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_FileWriter::writeLogicalName()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_FileWriter::writeLogicalName()\r\n{\r\n    QString output;\r\n    QXmlStreamWriter xmlStreamWriter(&output);\r\n\r\n    testFile_->setLogicalName(\"logicalTest\");\r\n\r\n    QString expectedOutput(\r\n        \"<ipxact:file>\"\r\n            \"<ipxact:name>./testFile</ipxact:name>\"\r\n            \"<ipxact:fileType>vhdlSource</ipxact:fileType>\"\r\n            \"<ipxact:logicalName>logicalTest</ipxact:logicalName>\"\r\n        \"</ipxact:file>\"\r\n        );\r\n\r\n    FileWriter::writeFile(xmlStreamWriter, testFile_, Document::Revision::Std14);\r\n    QCOMPARE(output, expectedOutput);\r\n\r\n    output.clear();\r\n    expectedOutput.clear();\r\n\r\n    testFile_->setLogicalNameDefault(true);\r\n\r\n    testFile_->setExternalDeclarations(true);\r\n    expectedOutput = \r\n        \"<ipxact:file>\"\r\n            \"<ipxact:name>./testFile</ipxact:name>\"\r\n            \"<ipxact:fileType>vhdlSource</ipxact:fileType>\"\r\n            \"<ipxact:logicalName default=\\\"true\\\">logicalTest</ipxact:logicalName>\"\r\n        \"</ipxact:file>\"\r\n        ;\r\n\r\n    FileWriter::writeFile(xmlStreamWriter, testFile_, Document::Revision::Std14);\r\n    QCOMPARE(output, expectedOutput);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_FileWriter::writeExportedName()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_FileWriter::writeExportedName()\r\n{\r\n    QString output;\r\n    QXmlStreamWriter xmlStreamWriter(&output);\r\n\r\n    testFile_->getExportedNames()->append(\"externalExport\");\r\n\r\n    QString expectedOutput(\r\n        \"<ipxact:file>\"\r\n            \"<ipxact:name>./testFile</ipxact:name>\"\r\n            \"<ipxact:fileType>vhdlSource</ipxact:fileType>\"\r\n            \"<ipxact:exportedName>externalExport</ipxact:exportedName>\"\r\n        \"</ipxact:file>\"\r\n        );\r\n\r\n    FileWriter::writeFile(xmlStreamWriter, testFile_, Document::Revision::Std14);\r\n    QCOMPARE(output, expectedOutput);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_FileWriter::writeBuildCommand()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_FileWriter::writeBuildCommand()\r\n{\r\n    QString output;\r\n    QXmlStreamWriter xmlStreamWriter(&output);\r\n\r\n    QSharedPointer<BuildCommand> testBuildCommand(new BuildCommand());\r\n    testBuildCommand->setCommand(\"testCommand\");\r\n    testBuildCommand->setFlags(\"testFlags\");\r\n    testBuildCommand->setFlagsAppend(true);\r\n    testBuildCommand->setReplaceDefaultFlags(\"4+3-6\");\r\n    testBuildCommand->setTargetName(\"target\");\r\n\r\n    testFile_->setBuildcommand(testBuildCommand);\r\n\r\n    QString expectedOutput(\r\n        \"<ipxact:file>\"\r\n            \"<ipxact:name>./testFile</ipxact:name>\"\r\n            \"<ipxact:fileType>vhdlSource</ipxact:fileType>\"\r\n            \"<ipxact:buildCommand>\"\r\n                \"<ipxact:command>testCommand</ipxact:command>\"\r\n                \"<ipxact:flags append=\\\"true\\\">testFlags</ipxact:flags>\"\r\n                \"<ipxact:replaceDefaultFlags>4+3-6</ipxact:replaceDefaultFlags>\"\r\n                \"<ipxact:targetName>target</ipxact:targetName>\"\r\n            \"</ipxact:buildCommand>\"\r\n        \"</ipxact:file>\"\r\n        );\r\n\r\n    FileWriter::writeFile(xmlStreamWriter, testFile_, Document::Revision::Std14);\r\n    QCOMPARE(output, expectedOutput);\r\n\r\n    output.clear();\r\n\r\n    testBuildCommand->setCommand(\"\");\r\n    testBuildCommand->setReplaceDefaultFlags(\"\");\r\n    testBuildCommand->setTargetName(\"\");\r\n    testBuildCommand->clearFlagsAppend();\r\n\r\n    expectedOutput =\r\n        \"<ipxact:file>\"\r\n            \"<ipxact:name>./testFile</ipxact:name>\"\r\n            \"<ipxact:fileType>vhdlSource</ipxact:fileType>\"\r\n            \"<ipxact:buildCommand>\"\r\n                \"<ipxact:flags>testFlags</ipxact:flags>\"\r\n            \"</ipxact:buildCommand>\"\r\n        \"</ipxact:file>\"\r\n        ;\r\n\r\n    FileWriter::writeFile(xmlStreamWriter, testFile_, Document::Revision::Std14);\r\n    QCOMPARE(output, expectedOutput);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_FileWriter::writeDependencies()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_FileWriter::writeDependencies()\r\n{\r\n    QString output;\r\n    QXmlStreamWriter xmlStreamWriter(&output);\r\n\r\n    testFile_->getDependencies()->append(\"/path/to/include\");\r\n    testFile_->getDependencies()->append(\"/path/to/other/include\");\r\n\r\n    QString expectedOutput(\r\n        \"<ipxact:file>\"\r\n            \"<ipxact:name>./testFile</ipxact:name>\"\r\n            \"<ipxact:fileType>vhdlSource</ipxact:fileType>\"\r\n            \"<ipxact:dependency>/path/to/include</ipxact:dependency>\"\r\n            \"<ipxact:dependency>/path/to/other/include</ipxact:dependency>\"\r\n        \"</ipxact:file>\"\r\n        );\r\n\r\n    FileWriter::writeFile(xmlStreamWriter, testFile_, Document::Revision::Std14);\r\n    QCOMPARE(output, expectedOutput);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_FileWriter::writeDefines()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_FileWriter::writeDefines()\r\n{\r\n    QString output;\r\n    QXmlStreamWriter xmlStreamWriter(&output);\r\n\r\n    QDomDocument document;\r\n    QDomElement extensionNode = document.createElement(\"testExtension\");\r\n    extensionNode.setAttribute(\"testExtensionAttribute\", \"extension\");\r\n    extensionNode.appendChild(document.createTextNode(\"testValue\"));\r\n\r\n    QSharedPointer<GenericVendorExtension> testExtension(new GenericVendorExtension(extensionNode));\r\n\r\n    QSharedPointer<NameValuePair> testDefine (new NameValuePair(\"defined\", \"value\"));\r\n    testDefine->setDisplayName(\"defineDisplay\");\r\n    testDefine->setDescription(\"defineDescription\");\r\n    testDefine->getVendorExtensions()->append(testExtension);\r\n\r\n    QSharedPointer<NameValuePair> otherDefine (new NameValuePair(\"defineNi\", \"kachiNi\"));\r\n\r\n    testFile_->getDefines()->append(testDefine);\r\n    testFile_->getDefines()->append(otherDefine);\r\n\r\n    QString expectedOutput(\r\n        \"<ipxact:file>\"\r\n            \"<ipxact:name>./testFile</ipxact:name>\"\r\n            \"<ipxact:fileType>vhdlSource</ipxact:fileType>\"\r\n            \"<ipxact:define>\"\r\n                \"<ipxact:name>defined</ipxact:name>\"\r\n                \"<ipxact:displayName>defineDisplay</ipxact:displayName>\"\r\n                \"<ipxact:description>defineDescription</ipxact:description>\"\r\n                \"<ipxact:value>value</ipxact:value>\"\r\n                \"<ipxact:vendorExtensions>\"\r\n                    \"<testExtension testExtensionAttribute=\\\"extension\\\">testValue</testExtension>\"\r\n                \"</ipxact:vendorExtensions>\"\r\n            \"</ipxact:define>\"\r\n            \"<ipxact:define>\"\r\n                \"<ipxact:name>defineNi</ipxact:name>\"\r\n                \"<ipxact:value>kachiNi</ipxact:value>\"\r\n            \"</ipxact:define>\"\r\n        \"</ipxact:file>\"\r\n        );\r\n\r\n    FileWriter::writeFile(xmlStreamWriter, testFile_, Document::Revision::Std14);\r\n    QCOMPARE(output, expectedOutput);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_FileWriter::writeImageTypes()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_FileWriter::writeImageTypes()\r\n{\r\n    QString output;\r\n    QXmlStreamWriter xmlStreamWriter(&output);\r\n\r\n    testFile_->getImageTypes()->append(\"jpg\");\r\n    testFile_->getImageTypes()->append(\"png\");\r\n\r\n    QString expectedOutput(\r\n        \"<ipxact:file>\"\r\n            \"<ipxact:name>./testFile</ipxact:name>\"\r\n            \"<ipxact:fileType>vhdlSource</ipxact:fileType>\"\r\n            \"<ipxact:imageType>jpg</ipxact:imageType>\"\r\n            \"<ipxact:imageType>png</ipxact:imageType>\"\r\n        \"</ipxact:file>\"\r\n        );\r\n\r\n    FileWriter::writeFile(xmlStreamWriter, testFile_, Document::Revision::Std14);\r\n    QCOMPARE(output, expectedOutput);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_FileWriter::writeDescription()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_FileWriter::writeDescription()\r\n{\r\n    QString output;\r\n    QXmlStreamWriter xmlStreamWriter(&output);\r\n\r\n    testFile_->setDescription(\"This is an important file.\");\r\n\r\n    QString expectedOutput(\r\n        \"<ipxact:file>\"\r\n        \"<ipxact:name>./testFile</ipxact:name>\"\r\n        \"<ipxact:fileType>vhdlSource</ipxact:fileType>\"\r\n        \"<ipxact:description>This is an important file.</ipxact:description>\"\r\n        \"</ipxact:file>\"\r\n        );\r\n\r\n    FileWriter::writeFile(xmlStreamWriter, testFile_, Document::Revision::Std14);\r\n    QCOMPARE(output, expectedOutput);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_FileWriter::writeHashExtensions()\r\n//-----------------------------------------------------------------------------\r\n//void tst_FileWriter::writeHashExtensions()\r\n//{\r\n//    QString output;\r\n//    QXmlStreamWriter xmlStreamWriter(&output);\r\n//\r\n//    testFile_->setPendingHash(\"hash\");\r\n//\r\n//    QString expectedOutput(\r\n//        \"<ipxact:file>\"\r\n//            \"<ipxact:name>./testFile</ipxact:name>\"\r\n//            \"<ipxact:fileType>vhdlSource</ipxact:fileType>\"\r\n//            \"<ipxact:vendorExtensions>\"\r\n//                \"<kactus2:hash>hash</kactus2:hash>\"\r\n//            \"</ipxact:vendorExtensions>\"\r\n//        \"</ipxact:file>\"\r\n//        );\r\n//\r\n//    FileWriter::writeFile(xmlStreamWriter, testFile_, Document::Revision::Std14);\r\n//    QCOMPARE(output, expectedOutput);\r\n//}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_FileWriter::writeVendorExtensions()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_FileWriter::writeVendorExtensions()\r\n{\r\n    QString output;\r\n    QXmlStreamWriter xmlStreamWriter(&output);\r\n\r\n    QDomDocument document;\r\n    QDomElement extensionNode = document.createElement(\"testExtension\");\r\n    extensionNode.setAttribute(\"testExtensionAttribute\", \"extension\");\r\n    extensionNode.appendChild(document.createTextNode(\"testValue\"));\r\n\r\n    QSharedPointer<GenericVendorExtension> testExtension(new GenericVendorExtension(extensionNode));\r\n\r\n    testFile_->getVendorExtensions()->append(testExtension);\r\n\r\n    QString expectedOutput(\r\n        \"<ipxact:file>\"\r\n            \"<ipxact:name>./testFile</ipxact:name>\"\r\n            \"<ipxact:fileType>vhdlSource</ipxact:fileType>\"\r\n            \"<ipxact:vendorExtensions>\"\r\n                \"<testExtension testExtensionAttribute=\\\"extension\\\">testValue</testExtension>\"\r\n            \"</ipxact:vendorExtensions>\"\r\n        \"</ipxact:file>\"\r\n        );\r\n\r\n    FileWriter::writeFile(xmlStreamWriter, testFile_, Document::Revision::Std14);\r\n    QCOMPARE(output, expectedOutput);\r\n}\r\n\r\nQTEST_APPLESS_MAIN(tst_FileWriter)\r\n\r\n#include \"tst_FileWriter.moc\"\r\n"
  },
  {
    "path": "tests/IPXACTmodels/Component/tst_FileWriter.pri",
    "content": "# ----------------------------------------------------\r\n# This file is generated by the Qt Visual Studio Add-in.\r\n# ------------------------------------------------------\r\n\r\nSOURCES += ./tst_FileWriter.cpp \r\n"
  },
  {
    "path": "tests/IPXACTmodels/Component/tst_FileWriter.pro",
    "content": "#-----------------------------------------------------------------------------\r\n# File: tst_FileWriter.pro\r\n#-----------------------------------------------------------------------------\r\n# Project: Kactus 2\r\n# Author: Mikko Teuho\r\n# Date: 16.09.2015\r\n#\r\n# Description:\r\n# Qt project file template for running unit tests for file writer.\r\n#-----------------------------------------------------------------------------\r\n\r\nTEMPLATE = app\r\n\r\nTARGET = tst_FileWriter\r\n\r\nQT += core xml testlib\r\nQT -= gui\r\n\r\nCONFIG += c++11 testcase console\r\n\r\nlinux-g++ | linux-g++-64 | linux-g++-32 {\r\n LIBS += -L../../../executable \\\r\n     -lIPXACTmodels\r\n\r\n}\r\nwin64 | win32 {\r\n LIBS += -L../../../executable \\\r\n     -lIPXACTmodelsd\r\n}\r\n\r\nINCLUDEPATH += $$DESTDIR\r\nINCLUDEPATH += ../../../\r\n\r\nDEPENDPATH += .\r\nDEPENDPATH += ../../../\r\n\r\nOBJECTS_DIR += $$DESTDIR\r\n\r\nMOC_DIR += ./generatedFiles\r\nUI_DIR += ./generatedFiles\r\nRCC_DIR += ./generatedFiles\r\ninclude(tst_FileWriter.pri)\r\n"
  },
  {
    "path": "tests/IPXACTmodels/Component/tst_IndirectInterfaceReader.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: tst_IndirectInterfaceReader.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Esko Pekkarinen\n// Date: 02.08.2017\n//\n// Description:\n// Unit test for class IndirectInterfaceReader.\n//-----------------------------------------------------------------------------\n\n#include <QtTest>\n\n#include <IPXACTmodels/Component/IndirectInterface.h>\n#include <IPXACTmodels/Component/IndirectInterfaceReader.h>\n#include <IPXACTmodels/Component/TransparentBridge.h>\n#include <IPXACTmodels/common/Document.h>\n\n#include <QDomDocument>\n#include <QDomNode>\n\nclass tst_IndirectInterfaceReader : public QObject\n{\n    Q_OBJECT\n\npublic:\n    tst_IndirectInterfaceReader();\n\nprivate slots:\n    void simpleIndirectInterface();\n    void fullIndirectInterface();\n    void indirectInterfaceWithTransparentBridges();\n    void indirectInterfaceWithTransparentBridges2022();\n};\n\n//-----------------------------------------------------------------------------\n// Function: tst_IndirectInterfaceReader::tst_IndirectInterfaceReader()\n//-----------------------------------------------------------------------------\ntst_IndirectInterfaceReader::tst_IndirectInterfaceReader()\n{\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_IndirectInterfaceReader::simpleIndirectInterface()\n//-----------------------------------------------------------------------------\nvoid tst_IndirectInterfaceReader::simpleIndirectInterface()\n{\n    QString documentContent(\n        \"<ipxact:indirectInterface>\"\n            \"<ipxact:name>interface1</ipxact:name>\"\n            \"<ipxact:displayName>interfaceDisplay</ipxact:displayName>\"\n            \"<ipxact:description>interfaceDescription</ipxact:description>\"\n            \"<ipxact:indirectAddressRef>addressId</ipxact:indirectAddressRef>\"\n            \"<ipxact:indirectDataRef>dataId</ipxact:indirectDataRef>\"\n            \"<ipxact:memoryMapRef>targetMap</ipxact:memoryMapRef>\"\n        \"</ipxact:indirectInterface>\"\n        );\n\n    QDomDocument document;\n    document.setContent(documentContent);\n\n    QDomNode interfaceNode = document.firstChildElement(\"ipxact:indirectInterface\");\n\n    QSharedPointer<IndirectInterface> testInterface = IndirectInterfaceReader::createIndirectInterfaceFrom(interfaceNode, Document::Revision::Std14);\n\n    QCOMPARE(testInterface->name(), QString(\"interface1\"));\n    QCOMPARE(testInterface->displayName(), QString(\"interfaceDisplay\"));\n    QCOMPARE(testInterface->description(), QString(\"interfaceDescription\"));\n\n    QCOMPARE(testInterface->getIndirectAddressRef(), QString(\"addressId\"));\n    QCOMPARE(testInterface->getIndirectDataRef(), QString(\"dataId\"));\n    QCOMPARE(testInterface->getMemoryMapRef(), QString(\"targetMap\"));\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_IndirectInterfaceReader::fullIndirectInterface()\n//-----------------------------------------------------------------------------\nvoid tst_IndirectInterfaceReader::fullIndirectInterface()\n{\n    QString documentContent(\n        \"<ipxact:indirectInterface testAttribute=\\\"testValue\\\">\"\n            \"<ipxact:name>interface1</ipxact:name>\"\n            \"<ipxact:displayName>interfaceDisplay</ipxact:displayName>\"\n            \"<ipxact:description>interfaceDescription</ipxact:description>\"\n            \"<ipxact:indirectAddressRef>addressId</ipxact:indirectAddressRef>\"\n            \"<ipxact:indirectDataRef>dataId</ipxact:indirectDataRef>\"\n            \"<ipxact:memoryMapRef>targetMap</ipxact:memoryMapRef>\"\n            \"<ipxact:bitsInLau>16</ipxact:bitsInLau>\"\n            \"<ipxact:endianness>big</ipxact:endianness>\"\n            \"<ipxact:parameters>\"\n                \"<ipxact:parameter parameterId=\\\"id1\\\">\"\n                    \"<ipxact:name>testParameter</ipxact:name>\"\n                    \"<ipxact:description>First generator parameter.</ipxact:description>\"\n                    \"<ipxact:value>5</ipxact:value>\"\n                \"</ipxact:parameter>\"\n                \"<ipxact:parameter parameterId=\\\"id2\\\">\"\n                    \"<ipxact:name>secondParameter</ipxact:name>\"\n                    \"<ipxact:value>1</ipxact:value>\"\n                \"</ipxact:parameter>\"\n            \"</ipxact:parameters>\"\n            \"<ipxact:vendorExtensions>\"\n                \"<testExtension testAttribute=\\\"attributeValue\\\"/>\"\n            \"</ipxact:vendorExtensions>\"\n        \"</ipxact:indirectInterface>\"\n        );\n\n    QDomDocument document;\n    document.setContent(documentContent);\n\n    QDomNode interfaceNode = document.firstChildElement(\"ipxact:indirectInterface\");\n\n    QSharedPointer<IndirectInterface> testInterface = IndirectInterfaceReader::createIndirectInterfaceFrom(interfaceNode, Document::Revision::Std14);\n\n    QCOMPARE(testInterface->getAttributes().count(), 1);\n    QCOMPARE(testInterface->getAttributes().value(\"testAttribute\"), QString(\"testValue\"));\n\n    QCOMPARE(testInterface->name(), QString(\"interface1\"));\n    QCOMPARE(testInterface->displayName(), QString(\"interfaceDisplay\"));\n    QCOMPARE(testInterface->description(), QString(\"interfaceDescription\"));\n\n    QCOMPARE(testInterface->getIndirectAddressRef(), QString(\"addressId\"));\n    QCOMPARE(testInterface->getIndirectDataRef(), QString(\"dataId\"));\n    QCOMPARE(testInterface->getMemoryMapRef(), QString(\"targetMap\"));\n\n    QCOMPARE(testInterface->getBitsInLau(), QString(\"16\"));\n    QCOMPARE(testInterface->getEndianness(), QString(\"big\"));\n\n    QCOMPARE(testInterface->getParameters()->count(), 2);\n    QCOMPARE(testInterface->getVendorExtensions()->count(), 1);\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_IndirectInterfaceReader::indirectInterfaceWithTransparentBridges()\n//-----------------------------------------------------------------------------\nvoid tst_IndirectInterfaceReader::indirectInterfaceWithTransparentBridges()\n{\n    QString documentContent(\n        \"<ipxact:indirectInterface>\"\n            \"<ipxact:name>interface2</ipxact:name>\"\n            \"<ipxact:indirectAddressRef>addressId</ipxact:indirectAddressRef>\"\n            \"<ipxact:indirectDataRef>dataId</ipxact:indirectDataRef>\"\n            \"<ipxact:transparentBridge masterRef=\\\"firstInterface\\\">\"                         \n                \"<ipxact:isPresent>true</ipxact:isPresent>\"\n            \"</ipxact:transparentBridge>\"\n            \"<ipxact:transparentBridge masterRef=\\\"secondInterface\\\">\"                         \n                \"<ipxact:isPresent>1</ipxact:isPresent>\"\n            \"</ipxact:transparentBridge>\"\n        \"</ipxact:indirectInterface>\"\n        );\n\n    QDomDocument document;\n    document.setContent(documentContent);\n\n    QDomNode interfaceNode = document.firstChildElement(\"ipxact:indirectInterface\");\n\n    QSharedPointer<IndirectInterface> testInterface = IndirectInterfaceReader::createIndirectInterfaceFrom(interfaceNode, Document::Revision::Std14);\n\n    QCOMPARE(testInterface->getTransparentBridges()->count(), 2);\n\n    QCOMPARE(testInterface->getTransparentBridges()->first()->getMasterRef(), QString(\"firstInterface\"));\n    QCOMPARE(testInterface->getTransparentBridges()->first()->getIsPresent(), QString(\"true\"));\n\n    QCOMPARE(testInterface->getTransparentBridges()->last()->getMasterRef(), QString(\"secondInterface\"));\n    QCOMPARE(testInterface->getTransparentBridges()->last()->getIsPresent(), QString(\"1\"));\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_IndirectInterfaceReader::indirectInterfaceWithTransparentBridges2022()\n//-----------------------------------------------------------------------------\nvoid tst_IndirectInterfaceReader::indirectInterfaceWithTransparentBridges2022()\n{\n    QString documentContent(\n        \"<ipxact:indirectInterface>\"\n            \"<ipxact:name>interface2</ipxact:name>\"\n            \"<ipxact:indirectAddressRef>addressId</ipxact:indirectAddressRef>\"\n            \"<ipxact:indirectDataRef>dataId</ipxact:indirectDataRef>\"\n            \"<ipxact:transparentBridge initiatorRef=\\\"firstInterface\\\">\"                         \n                \"<ipxact:isPresent>true</ipxact:isPresent>\"\n            \"</ipxact:transparentBridge>\"\n            \"<ipxact:transparentBridge initiatorRef=\\\"secondInterface\\\">\"                         \n                \"<ipxact:isPresent>1</ipxact:isPresent>\"\n                \"<ipxact:vendorExtensions>\"\n                    \"<testExtension testExtensionAttribute=\\\"extension\\\">testValue</testExtension>\"\n                \"</ipxact:vendorExtensions>\"\n            \"</ipxact:transparentBridge>\"\n        \"</ipxact:indirectInterface>\"\n        );\n\n    QDomDocument document;\n    document.setContent(documentContent);\n\n    QDomNode interfaceNode = document.firstChildElement(\"ipxact:indirectInterface\");\n\n    QSharedPointer<IndirectInterface> testInterface = IndirectInterfaceReader::createIndirectInterfaceFrom(interfaceNode, Document::Revision::Std22);\n\n    QCOMPARE(testInterface->getTransparentBridges()->count(), 2);\n\n    QCOMPARE(testInterface->getTransparentBridges()->first()->getInitiatorRef(), QString(\"firstInterface\"));\n    QCOMPARE(testInterface->getTransparentBridges()->first()->getIsPresent(), QString(\"\")); //!< No isPresent should be available.\n\n    QCOMPARE(testInterface->getTransparentBridges()->last()->getInitiatorRef(), QString(\"secondInterface\"));\n    QCOMPARE(testInterface->getTransparentBridges()->last()->getIsPresent(), QString(\"\")); //!< No isPresent should be available.\n    QCOMPARE(testInterface->getTransparentBridges()->last()->getVendorExtensions()->count(), 1);\n    QCOMPARE(testInterface->getTransparentBridges()->last()->getVendorExtensions()->first()->type(), QString(\"testExtension\"));\n}\n\nQTEST_APPLESS_MAIN(tst_IndirectInterfaceReader)\n\n#include \"tst_IndirectInterfaceReader.moc\"\n"
  },
  {
    "path": "tests/IPXACTmodels/Component/tst_IndirectInterfaceReader.pri",
    "content": "# ----------------------------------------------------\n# This file is generated by the Qt Visual Studio Add-in.\n# ------------------------------------------------------\n\nSOURCES += ./tst_IndirectInterfaceReader.cpp \n"
  },
  {
    "path": "tests/IPXACTmodels/Component/tst_IndirectInterfaceReader.pro",
    "content": "#-----------------------------------------------------------------------------\n# File: unittest.pro\n#-----------------------------------------------------------------------------\n# Project: Kactus 2\n# Author: Esko Pekkarinen\n# Date: 24.7.2014\n#\n# Description:\n# Qt project file template for running unit tests for a single module.\n#-----------------------------------------------------------------------------\n\nTEMPLATE = app\n\nTARGET = tst_IndirectInterfaceReader\n\nQT += core xml testlib\nQT -= gui\n\nCONFIG += c++11 testcase console\n\nlinux-g++ | linux-g++-64 | linux-g++-32 {\n LIBS += -L../../../executable \\\n     -lIPXACTmodels\n\n}\nwin64 | win32 {\n LIBS += -L../../../executable \\\n     -lIPXACTmodelsd\n}\n\nINCLUDEPATH += $$DESTDIR\nINCLUDEPATH += ../../../\n\nDEPENDPATH += .\nDEPENDPATH += ../../../\n\nOBJECTS_DIR += $$DESTDIR\n\nMOC_DIR += ./generatedFiles\nUI_DIR += ./generatedFiles\nRCC_DIR += ./generatedFiles\ninclude(tst_IndirectInterfaceReader.pri)\n"
  },
  {
    "path": "tests/IPXACTmodels/Component/tst_IndirectInterfaceValidator.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: tst_IndirectInterfaceValidator.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Esko Pekkarinen\n// Date: 09.08.2017\n//\n// Description:\n// Unit test for class IndirectInterfaceValidator.\n//-----------------------------------------------------------------------------\n\n#include <QtTest>\n\n#include <IPXACTmodels/Component/AddressBlock.h>\n#include <IPXACTmodels/Component/BusInterface.h>\n#include <IPXACTmodels/Component/Component.h>\n#include <IPXACTmodels/Component/IndirectInterface.h>\n#include <IPXACTmodels/Component/TransparentBridge.h>\n#include <IPXACTmodels/Component/MemoryMap.h>\n#include <IPXACTmodels/Component/Register.h>\n#include <IPXACTmodels/Component/Field.h>\n\n#include <IPXACTmodels/Component/validators/IndirectInterfaceValidator.h>\n#include <IPXACTmodels/common/validators/ParameterValidator.h>\n\n#include <IPXACTmodels/kactusExtensions/Kactus2Value.h>\n\n#include <KactusAPI/include/ExpressionParser.h>\n#include <KactusAPI/include/SystemVerilogExpressionParser.h>\n\n#include <QDomDocument>\n#include <QDomNode>\n\nclass tst_IndirectInterfaceValidator : public QObject\n{\n    Q_OBJECT\n\npublic:\n    tst_IndirectInterfaceValidator();\n\n\nprivate slots:\n  \n    void testValidateName();\n    void testValidateName_data();\n\n    void testValidateIndirectFieldReferences();\n    void testValidateIndirectFieldReferences_data();\n\n    void testValidateMemoryMapReference();\n    void testValidateMemoryMapReference_data();\n\n    void testValidateTransparentBridges();\n    void testValidateTransparentBridges_data();\n\n    void testValidateOnlyMemoryMapOrTransparentBridgePresent();\n    void testValidateOnlyMemoryMapOrTransparentBridgePresent_data();\n\n    void testValidateBitsInLau();\n    void testValidateBitsInLau_data();\n\n    void testValidateEndianness();\n    void testValidateEndianness_data();\n\nprivate:\n    QSharedPointer<Component> containingComponent_;\n\n    QSharedPointer<ExpressionParser> expressionParser_;\n\n    QSharedPointer<ParameterValidator> parameterValidator_;\n};\n\n//-----------------------------------------------------------------------------\n// Function: tst_IndirectInterfaceValidator::tst_IndirectInterfaceValidator()\n//-----------------------------------------------------------------------------\ntst_IndirectInterfaceValidator::tst_IndirectInterfaceValidator():\ncontainingComponent_ (new Component(VLNV(), Document::Revision::Std14)),\n    expressionParser_(new SystemVerilogExpressionParser()),\n    parameterValidator_(new ParameterValidator(expressionParser_, \n    QSharedPointer<QList<QSharedPointer<Choice> > >(), Document::Revision::Std14))\n{    \n    QSharedPointer<Field> accessField(new Field(\"access\"));\n    accessField->setId(\"accessField\");\n\n    QSharedPointer<Field> readOnlyField(new Field(\"readOnly\"));\n    readOnlyField->setAccess(AccessTypes::READ_ONLY);\n    readOnlyField->setId(\"readOnlyField\");\n\n    QSharedPointer<Field> readWriteOnceField(new Field(\"readWriteOnce\"));\n    readWriteOnceField->setAccess(AccessTypes::READ_WRITEONCE);\n    readWriteOnceField->setId(\"readWriteOnceField\");\n   \n    QSharedPointer<Field> writeOnceField(new Field(\"writeOnce\"));\n    writeOnceField->setAccess(AccessTypes::WRITEONCE);\n    writeOnceField->setId(\"writeOnceField\");\n\n    QSharedPointer<Register> accessRegister(new Register());\n    accessRegister->getFields()->append(accessField);\n    accessRegister->getFields()->append(readOnlyField);\n    accessRegister->getFields()->append(readWriteOnceField);\n    accessRegister->getFields()->append(writeOnceField);\n\n    QSharedPointer<AddressBlock> accessBlock(new AddressBlock());\n    accessBlock->getRegisterData()->append(accessRegister);\n\n    QSharedPointer<MemoryMap> accessMemoryMap(new MemoryMap(\"accessMemoryMap\"));\n    accessMemoryMap->getMemoryBlocks()->append(accessBlock);\n\n    QSharedPointer<Field> targetField(new Field(\"target\"));\n    targetField->setId(\"targetMapField\");\n\n    QSharedPointer<Register> targetReg(new Register());\n    targetReg->getFields()->append(targetField);\n\n    QSharedPointer<AddressBlock> targetBlock(new AddressBlock());\n    targetBlock->getRegisterData()->append(targetReg);\n\n    QSharedPointer<MemoryMap> targetMap(new MemoryMap(\"targetMemoryMap\"));\n    targetMap->getMemoryBlocks()->append(targetBlock);\n\n    QSharedPointer<BusInterface> testMasterInterface(new BusInterface());\n    testMasterInterface->setName(\"master1\");\n    testMasterInterface->setInterfaceMode(General::MASTER);\n\n    QSharedPointer<BusInterface> testSlaveInterface(new BusInterface());\n    testSlaveInterface->setName(\"slave1\");\n    testSlaveInterface->setInterfaceMode(General::SLAVE);\n\n    containingComponent_->getBusInterfaces()->append(testMasterInterface);\n    containingComponent_->getBusInterfaces()->append(testSlaveInterface);\n\n    containingComponent_->getMemoryMaps()->append(accessMemoryMap);\n    containingComponent_->getMemoryMaps()->append(targetMap);    \n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_IndirectInterfaceValidator::testValidateName()\n//-----------------------------------------------------------------------------\nvoid tst_IndirectInterfaceValidator::testValidateName()\n{\n    QFETCH(QString, name);\n    QFETCH(bool, isValid);\n\n    QSharedPointer<IndirectInterface> testInterface (new IndirectInterface());\n    testInterface->setName(name);\n    \n    //QSharedPointer<ExpressionParser> parser(new SystemVerilogExpressionParser());\n    IndirectInterfaceValidator validator(containingComponent_, expressionParser_, parameterValidator_);\n\n    QCOMPARE(validator.hasValidName(testInterface), isValid);\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_IndirectInterfaceValidator::testValidateName_data()\n//-----------------------------------------------------------------------------\nvoid tst_IndirectInterfaceValidator::testValidateName_data()\n{\n    QTest::addColumn<QString>(\"name\");\n    QTest::addColumn<bool>(\"isValid\");\n\n    QTest::newRow(\"Name test is valid\") << \"test\" << true;\n    QTest::newRow(\"Empty name is invalid\") << \"\" << false;\n    QTest::newRow(\"Name consisting of only white spaces is invalid\") << \"    \" << false;\n    QTest::newRow(\"Name consisting of characters and white spaces is valid\") << \"  test  \" << true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_IndirectInterfaceValidator::testValidateIndirectFieldReferences()\n//-----------------------------------------------------------------------------\nvoid tst_IndirectInterfaceValidator::testValidateIndirectFieldReferences()\n{\n    QFETCH(QString, reference);\n    QFETCH(bool, dataValid);\n    QFETCH(bool, addressValid);\n\n    QSharedPointer<IndirectInterface> testInterface (new IndirectInterface());\n    testInterface->setIndirectAddressRef(reference);\n    testInterface->setIndirectDataRef(reference);\n    testInterface->setMemoryMapRef(\"targetMemoryMap\");\n\n    IndirectInterfaceValidator validator(containingComponent_, expressionParser_, parameterValidator_);\n\n    QCOMPARE(validator.hasValidDataReference(testInterface), dataValid);\n    QCOMPARE(validator.hasValidAddressReference(testInterface), addressValid);    \n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_IndirectInterfaceValidator::testValidateIndirectFieldReferences_data()\n//-----------------------------------------------------------------------------\nvoid tst_IndirectInterfaceValidator::testValidateIndirectFieldReferences_data()\n{\n    QTest::addColumn<QString>(\"reference\");\n    QTest::addColumn<bool>(\"dataValid\");\n    QTest::addColumn<bool>(\"addressValid\");\n\n    QTest::newRow(\"Empty reference is invalid\") << \"\" << false << false;\n    QTest::newRow(\"Nonexisting reference is invalid\") << \"none\" << false << false;\n    QTest::newRow(\"Existing field is valid\") << \"accessField\" << true << true;\n    QTest::newRow(\"Field in referenced memory map is invalid\") << \"targetMapField\" << false << false;\n    QTest::newRow(\"Field address of access read-only is invalid\") << \"readOnlyField\" << true << false;\n    QTest::newRow(\"Field address of access read-writeOnce is invalid\") << \"readWriteOnceField\" << true << false;\n    QTest::newRow(\"Field address of access writeOnce is invalid\") << \"writeOnceField\" << true << false;\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_IndirectInterfaceValidator::testValidateMemoryMapReference()\n//-----------------------------------------------------------------------------\nvoid tst_IndirectInterfaceValidator::testValidateMemoryMapReference()\n{\n    QFETCH(QString, memoryMap);\n    QFETCH(bool, isValid);\n\n    QSharedPointer<IndirectInterface> testInterface (new IndirectInterface());\n    testInterface->setMemoryMapRef(memoryMap);\n    \n    IndirectInterfaceValidator validator(containingComponent_, expressionParser_, parameterValidator_);\n\n    QCOMPARE(validator.hasValidMemoryMapReference(testInterface), isValid);\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_IndirectInterfaceValidator::testValidateMemoryMapReference_data()\n//-----------------------------------------------------------------------------\nvoid tst_IndirectInterfaceValidator::testValidateMemoryMapReference_data()\n{\n    QTest::addColumn<QString>(\"memoryMap\");\n    QTest::addColumn<bool>(\"isValid\");\n\n    QTest::newRow(\"Nonexisting reference is invalid\") << \"none\" << false;\n    QTest::newRow(\"Existing memory map is valid\") << \"targetMemoryMap\" << true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_IndirectInterfaceValidator::testValidateTransparentBridges()\n//-----------------------------------------------------------------------------\nvoid tst_IndirectInterfaceValidator::testValidateTransparentBridges()\n{\n    QFETCH(QString, masterRef);\n    QFETCH(bool, isValid);\n\n    QSharedPointer<IndirectInterface> testInterface (new IndirectInterface());\n    \n    QSharedPointer<TransparentBridge> testBridge(new TransparentBridge(masterRef));\n    testInterface->getTransparentBridges()->append(testBridge);\n\n    IndirectInterfaceValidator validator(containingComponent_, expressionParser_, parameterValidator_);\n\n    QCOMPARE(validator.hasValidTransparentBridges(testInterface->getTransparentBridges()), isValid);\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_IndirectInterfaceValidator::testValidateTransparentBridges_data()\n//-----------------------------------------------------------------------------\nvoid tst_IndirectInterfaceValidator::testValidateTransparentBridges_data()\n{\n    QTest::addColumn<QString>(\"masterRef\");\n    QTest::addColumn<bool>(\"isValid\");\n\n    QTest::newRow(\"Nonexisting reference is invalid\") << \"none\" << false;\n    QTest::newRow(\"Existing master interface is valid\") << \"master1\" << true;\n    QTest::newRow(\"Existing slave interface is invalid\") << \"slave1\" << false;\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_IndirectInterfaceValidator::testValidateOnlyMemoryMapOrTransparentBridgePresent()\n//-----------------------------------------------------------------------------\nvoid tst_IndirectInterfaceValidator::testValidateOnlyMemoryMapOrTransparentBridgePresent()\n{\n    QFETCH(QString, memoryMapRef);\n    QFETCH(bool, hasBridge);\n    QFETCH(bool, isValid);\n    \n    QSharedPointer<IndirectInterface> testInterface (new IndirectInterface());\n    testInterface->setName(\"testInterface\");\n    testInterface->setIndirectAddressRef(\"accessField\");\n    testInterface->setIndirectDataRef(\"accessField\");\n    \n    testInterface->setMemoryMapRef(memoryMapRef);\n\n    if (hasBridge)\n    {\n        QSharedPointer<TransparentBridge> testBridge(new TransparentBridge(\"master1\"));\n        testInterface->getTransparentBridges()->append(testBridge);\n    }\n\n    IndirectInterfaceValidator validator(containingComponent_, expressionParser_, parameterValidator_);\n\n    QCOMPARE(validator.validate(testInterface), isValid);\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_IndirectInterfaceValidator::testValidateOnlyMemoryMapOrTransparentBridgePresent_data()\n//-----------------------------------------------------------------------------\nvoid tst_IndirectInterfaceValidator::testValidateOnlyMemoryMapOrTransparentBridgePresent_data()\n{\n    QTest::addColumn<QString>(\"memoryMapRef\");\n    QTest::addColumn<bool>(\"hasBridge\");\n    QTest::addColumn<bool>(\"isValid\");\n\n    QTest::newRow(\"Memory map only is valid\") << \"targetMemoryMap\" << false << true;\n    QTest::newRow(\"Transparent bridge only is valid\") << \"\" << true << true;\n    QTest::newRow(\"No transparent bridge or memory map is invalid\") << \"\" << false << false;\n    QTest::newRow(\"Both transparent bridge and memory map is invalid\") << \"targetMemoryMap\" << true << false;\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_IndirectInterfaceValidator::testValidateBitsInLau()\n//-----------------------------------------------------------------------------\nvoid tst_IndirectInterfaceValidator::testValidateBitsInLau()\n{\n    QFETCH(QString, bitsInLau);\n    QFETCH(bool, isValid);\n\n    QSharedPointer<IndirectInterface> testInterface (new IndirectInterface());\n    testInterface->setName(\"testInterface\");\n    testInterface->setIndirectAddressRef(\"accessField\");\n    testInterface->setIndirectDataRef(\"accessField\");\n\n    testInterface->setBitsInLau(bitsInLau);\n\n    IndirectInterfaceValidator validator(containingComponent_, expressionParser_, parameterValidator_);\n\n    QCOMPARE(validator.hasValidBitsInLau(testInterface), isValid);\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_IndirectInterfaceValidator::testValidateBitsInLau_data()\n//-----------------------------------------------------------------------------\nvoid tst_IndirectInterfaceValidator::testValidateBitsInLau_data()\n{\n    QTest::addColumn<QString>(\"bitsInLau\");\n    QTest::addColumn<bool>(\"isValid\");\n\n    QTest::newRow(\"Lau of 10 is valid\") << \"10\" << true;\n    QTest::newRow(\"Empty Lau is valid\") << \"\" << true;\n    QTest::newRow(\"Lau of -2 is invalid\") << \"-2\" << false;\n    QTest::newRow(\"Lau of 20*80 is valid\") << \"20*80\" << true;\n    QTest::newRow(\"Text is invalid for Lau\") << \"text\" << false;\n    QTest::newRow(\"String is invalid for Lau\") << \"\\\"text\\\"\" << false;\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_IndirectInterfaceValidator::testValidateEndianness()\n//-----------------------------------------------------------------------------\nvoid tst_IndirectInterfaceValidator::testValidateEndianness()\n{\n    QFETCH(QString, endianness);\n    QFETCH(bool, isValid);\n\n    QSharedPointer<IndirectInterface> testInterface (new IndirectInterface());\n    testInterface->setName(\"testInterface\");\n    testInterface->setEndianness(endianness);\n   \n    IndirectInterfaceValidator validator(containingComponent_, expressionParser_, parameterValidator_);\n\n    QCOMPARE(validator.hasValidEndianness(testInterface), isValid);\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_IndirectInterfaceValidator::testValidateEndianness_data()\n//-----------------------------------------------------------------------------\nvoid tst_IndirectInterfaceValidator::testValidateEndianness_data()\n{\n    QTest::addColumn<QString>(\"endianness\");\n    QTest::addColumn<bool>(\"isValid\");\n\n    QTest::newRow(\"big is valid endianness\") << \"big\" << true;\n    QTest::newRow(\"little is valid endianness\") << \"little\" << true;\n    QTest::newRow(\"unset endianness is valid\") << \"\" << true;\n    QTest::newRow(\"other words are invalid\") << \"other\" << false;\n    QTest::newRow(\"numbers are invalid\") << \"128\" << false;\n}\n\nQTEST_APPLESS_MAIN(tst_IndirectInterfaceValidator)\n\n#include \"tst_IndirectInterfaceValidator.moc\"\n"
  },
  {
    "path": "tests/IPXACTmodels/Component/tst_IndirectInterfaceValidator.pri",
    "content": "# ----------------------------------------------------\n# This file is generated by the Qt Visual Studio Tools.\n# ------------------------------------------------------\n\t\nSOURCES += ./tst_IndirectInterfaceValidator.cpp \n\t"
  },
  {
    "path": "tests/IPXACTmodels/Component/tst_IndirectInterfaceValidator.pro",
    "content": "#-----------------------------------------------------------------------------\n# File: tst_IndirectInterfaceValidator.pro\n#-----------------------------------------------------------------------------\n# Project: Kactus 2\n# Author: Esko Pekkarinen\n# Date: 09.08.2017\n#\n# Description:\n# Qt project file template for running unit tests for a single module.\n#-----------------------------------------------------------------------------\n\nTEMPLATE = app\n\nTARGET = tst_IndirectInterfaceValidator\n\nQT += core gui xml testlib\n\nCONFIG += c++11 testcase console\n\nlinux-g++ | linux-g++-64 | linux-g++-32 {\n LIBS += -L../../../executable \\\n     -lIPXACTmodels -lKactusAPI\n\n}\nwin64 | win32 {\n LIBS += -L../../../executable \\\n     -lIPXACTmodelsd -lKactusAPId\n}\n\nINCLUDEPATH += $$DESTDIR\nINCLUDEPATH += ../../../\n\nDEPENDPATH += .\nDEPENDPATH += ../../../\n\nOBJECTS_DIR += $$DESTDIR\n\nMOC_DIR += ./generatedFiles\nUI_DIR += ./generatedFiles\nRCC_DIR += ./generatedFiles\ninclude(tst_IndirectInterfaceValidator.pri)\n"
  },
  {
    "path": "tests/IPXACTmodels/Component/tst_IndirectInterfaceWriter.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: tst_IndirectInterfaceWriter.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Esko Pekkarinen\n// Date: 07.08.2017\n//\n// Description:\n// Unit test for class IndirectInterfaceWriter.\n//-----------------------------------------------------------------------------\n\n#include <QtTest>\n\n#include <IPXACTmodels/Component/IndirectInterface.h>\n#include <IPXACTmodels/Component/IndirectInterfaceWriter.h>\n#include <IPXACTmodels/Component/TransparentBridge.h>\n\n#include <IPXACTmodels/kactusExtensions/Kactus2Value.h>\n\n#include <QDomDocument>\n#include <QDomNode>\n\nclass tst_IndirectInterfaceWriter : public QObject\n{\n    Q_OBJECT\n\npublic:\n    tst_IndirectInterfaceWriter();\n\nprivate slots:\n    void writeSimpleIndirectInterface();\n\n    void writeEndiannessAndLauInInterface();\n\n    void writeIndirectInterfaceWithBridges();\n\n    void writeIndirectInterfaceWith2022Bridges();\n\n    void writeIndirectInterfaceWithParameters();\n\n    void writeIndirectInterfaceWithVendorExtensions();\n};\n\n//-----------------------------------------------------------------------------\n// Function: tst_IndirectInterfaceWriter::tst_IndirectInterfaceWriter()\n//-----------------------------------------------------------------------------\ntst_IndirectInterfaceWriter::tst_IndirectInterfaceWriter()\n{\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_IndirectInterfaceWriter::writeSimpleIndirectInterface()\n//-----------------------------------------------------------------------------\nvoid tst_IndirectInterfaceWriter::writeSimpleIndirectInterface()\n{\n    QString output;\n    QXmlStreamWriter xmlStreamWriter(&output);\n\n    QSharedPointer<IndirectInterface> testInterface(new IndirectInterface(\"interface1\"));\n    testInterface->setDisplayName(\"testDisplay\");\n    testInterface->setDescription(\"testDescription\");\n    \n    testInterface->setIndirectAddressRef(\"addressId\");\n    testInterface->setIndirectDataRef(\"dataId\");\n\n    testInterface->setMemoryMapRef(\"targetMap\");\n\n    QString expectedOutput( \n        \"<ipxact:indirectInterface>\"\n            \"<ipxact:name>interface1</ipxact:name>\"\n            \"<ipxact:displayName>testDisplay</ipxact:displayName>\"\n            \"<ipxact:description>testDescription</ipxact:description>\"\n            \"<ipxact:indirectAddressRef>addressId</ipxact:indirectAddressRef>\"\n            \"<ipxact:indirectDataRef>dataId</ipxact:indirectDataRef>\"\n            \"<ipxact:memoryMapRef>targetMap</ipxact:memoryMapRef>\"\n        \"</ipxact:indirectInterface>\");\n\n    IndirectInterfaceWriter::writeIndirectInterface(xmlStreamWriter, testInterface, Document::Revision::Std14);\n    QCOMPARE(output, expectedOutput);\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_IndirectInterfaceWriter::writeEndiannessAndLauInInterface()\n//-----------------------------------------------------------------------------\nvoid tst_IndirectInterfaceWriter::writeEndiannessAndLauInInterface()\n{\n    QString output;\n    QXmlStreamWriter xmlStreamWriter(&output);\n\n    QSharedPointer<IndirectInterface> testInterface(new IndirectInterface(\"interface1\"));\n    testInterface->setIndirectAddressRef(\"addressId\");\n    testInterface->setIndirectDataRef(\"dataId\");\n    testInterface->setMemoryMapRef(\"targetMap\");\n    testInterface->setBitsInLau(\"16\");\n    testInterface->setEndianness(\"big\");\n\n    QString expectedOutput( \n        \"<ipxact:indirectInterface>\"\n            \"<ipxact:name>interface1</ipxact:name>\"\n            \"<ipxact:indirectAddressRef>addressId</ipxact:indirectAddressRef>\"\n            \"<ipxact:indirectDataRef>dataId</ipxact:indirectDataRef>\"\n            \"<ipxact:memoryMapRef>targetMap</ipxact:memoryMapRef>\"\n            \"<ipxact:bitsInLau>16</ipxact:bitsInLau>\"\n            \"<ipxact:endianness>big</ipxact:endianness>\"\n        \"</ipxact:indirectInterface>\");\n\n    IndirectInterfaceWriter::writeIndirectInterface(xmlStreamWriter, testInterface, Document::Revision::Std14);\n    QCOMPARE(output, expectedOutput);\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_IndirectInterfaceWriter::writeIndirectInterfaceWithBridges()\n//-----------------------------------------------------------------------------\nvoid tst_IndirectInterfaceWriter::writeIndirectInterfaceWithBridges()\n{\n    QString output;\n    QXmlStreamWriter xmlStreamWriter(&output);\n\n    QSharedPointer<IndirectInterface> testInterface(new IndirectInterface(\"interface\"));\n    testInterface->setIndirectAddressRef(\"addr\");\n    testInterface->setIndirectDataRef(\"data\");\n\n    QSharedPointer<TransparentBridge> firstBridge(new TransparentBridge(\"master1\"));\n    testInterface->getTransparentBridges()->append(firstBridge);\n\n    QSharedPointer<TransparentBridge> conditionalBridge(new TransparentBridge(\"master2\"));\n    conditionalBridge->setIsPresent(\"true\");\n    testInterface->getTransparentBridges()->append(conditionalBridge);\n\n    QString expectedOutput( \n        \"<ipxact:indirectInterface>\"\n            \"<ipxact:name>interface</ipxact:name>\"\n            \"<ipxact:indirectAddressRef>addr</ipxact:indirectAddressRef>\"\n            \"<ipxact:indirectDataRef>data</ipxact:indirectDataRef>\"\n            \"<ipxact:transparentBridge masterRef=\\\"master1\\\"/>\"\n            \"<ipxact:transparentBridge masterRef=\\\"master2\\\">\"\n                \"<ipxact:isPresent>true</ipxact:isPresent>\"\n            \"</ipxact:transparentBridge>\"\n        \"</ipxact:indirectInterface>\");\n\n    IndirectInterfaceWriter::writeIndirectInterface(xmlStreamWriter, testInterface, Document::Revision::Std14);\n    QCOMPARE(output, expectedOutput);\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_IndirectInterfaceWriter::writeIndirectInterfaceWith2022Bridges()\n//-----------------------------------------------------------------------------\nvoid tst_IndirectInterfaceWriter::writeIndirectInterfaceWith2022Bridges()\n{\n    QString output;\n    QXmlStreamWriter xmlStreamWriter(&output);\n\n    QSharedPointer<IndirectInterface> testInterface(new IndirectInterface(\"interface\"));\n    testInterface->setIndirectAddressRef(\"addr\");\n    testInterface->setIndirectDataRef(\"data\");\n\n    QSharedPointer<TransparentBridge> firstBridge(new TransparentBridge(\"initiator1\"));\n    testInterface->getTransparentBridges()->append(firstBridge);\n\n    QSharedPointer<TransparentBridge> extendedBridge(new TransparentBridge(\"initiator2\"));\n    extendedBridge->setIsPresent(\"true\");\n    extendedBridge->getVendorExtensions()->append(\n        QSharedPointer<VendorExtension>(new Kactus2Value(\"testExtension\", \"testValue\")));\n\n    testInterface->getTransparentBridges()->append(extendedBridge);\n\n    QString expectedOutput( \n        \"<ipxact:indirectInterface>\"\n            \"<ipxact:name>interface</ipxact:name>\"\n            \"<ipxact:indirectAddressRef>addr</ipxact:indirectAddressRef>\"\n            \"<ipxact:indirectDataRef>data</ipxact:indirectDataRef>\"\n            \"<ipxact:transparentBridge initiatorRef=\\\"initiator1\\\"/>\"\n            \"<ipxact:transparentBridge initiatorRef=\\\"initiator2\\\">\"\n                \"<ipxact:vendorExtensions>\"\n                    \"<testExtension>testValue</testExtension>\"\n                \"</ipxact:vendorExtensions>\"\n            \"</ipxact:transparentBridge>\"\n        \"</ipxact:indirectInterface>\");\n\n    IndirectInterfaceWriter::writeIndirectInterface(xmlStreamWriter, testInterface, Document::Revision::Std22);\n    QCOMPARE(output, expectedOutput);\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_IndirectInterfaceWriter::writeIndirectInterfaceWithParameters()\n//-----------------------------------------------------------------------------\nvoid tst_IndirectInterfaceWriter::writeIndirectInterfaceWithParameters()\n{\n    QString output;\n    QXmlStreamWriter xmlStreamWriter(&output);\n\n    QSharedPointer<IndirectInterface> testInterface(new IndirectInterface(\"interface1\"));\n    testInterface->setIndirectAddressRef(\"addressId\");\n    testInterface->setIndirectDataRef(\"dataId\");\n\n    QSharedPointer<Parameter> testParameter(new Parameter());\n    testParameter->setValueId(\"\");\n    testParameter->setName(\"testParameter\");\n    testParameter->setValue(\"testValue\");\n\n    testInterface->getParameters()->append(testParameter);\n\n    QString expectedOutput( \n        \"<ipxact:indirectInterface>\"\n            \"<ipxact:name>interface1</ipxact:name>\"\n            \"<ipxact:indirectAddressRef>addressId</ipxact:indirectAddressRef>\"\n            \"<ipxact:indirectDataRef>dataId</ipxact:indirectDataRef>\"\n            \"<ipxact:parameters>\"\n                \"<ipxact:parameter>\"\n                    \"<ipxact:name>testParameter</ipxact:name>\"\n                    \"<ipxact:value>testValue</ipxact:value>\"\n                \"</ipxact:parameter>\"\n            \"</ipxact:parameters>\"\n        \"</ipxact:indirectInterface>\");\n\n    IndirectInterfaceWriter::writeIndirectInterface(xmlStreamWriter, testInterface, Document::Revision::Std14);\n    QCOMPARE(output, expectedOutput);\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_IndirectInterfaceWriter::writeIndirectInterfaceWithVendorExtensions()\n//-----------------------------------------------------------------------------\nvoid tst_IndirectInterfaceWriter::writeIndirectInterfaceWithVendorExtensions()\n{\n    QString output;\n    QXmlStreamWriter xmlStreamWriter(&output);\n\n    QSharedPointer<IndirectInterface> testInterface(new IndirectInterface(\"interface1\"));\n    testInterface->setIndirectAddressRef(\"addressId\");\n    testInterface->setIndirectDataRef(\"dataId\");\n\n    QSharedPointer<Kactus2Value> testExtension(new Kactus2Value(\"testExtension\", \"testValue\"));\n    testInterface->getVendorExtensions()->append(testExtension);\n\n    QString expectedOutput( \n        \"<ipxact:indirectInterface>\"\n            \"<ipxact:name>interface1</ipxact:name>\"\n            \"<ipxact:indirectAddressRef>addressId</ipxact:indirectAddressRef>\"\n            \"<ipxact:indirectDataRef>dataId</ipxact:indirectDataRef>\"\n            \"<ipxact:vendorExtensions>\"\n                \"<testExtension>testValue</testExtension>\"\n            \"</ipxact:vendorExtensions>\"\n        \"</ipxact:indirectInterface>\");\n\n    IndirectInterfaceWriter::writeIndirectInterface(xmlStreamWriter, testInterface, Document::Revision::Std14);\n    QCOMPARE(output, expectedOutput);\n}\n\nQTEST_APPLESS_MAIN(tst_IndirectInterfaceWriter)\n\n#include \"tst_IndirectInterfaceWriter.moc\"\n"
  },
  {
    "path": "tests/IPXACTmodels/Component/tst_IndirectInterfaceWriter.pri",
    "content": "# ----------------------------------------------------\n# This file is generated by the Qt Visual Studio Add-in.\n# ------------------------------------------------------\n\nSOURCES += ./tst_IndirectInterfaceWriter.cpp \n"
  },
  {
    "path": "tests/IPXACTmodels/Component/tst_IndirectInterfaceWriter.pro",
    "content": "#-----------------------------------------------------------------------------\n# File: tst_IndirectInterfaceWriter.pro\n#-----------------------------------------------------------------------------\n# Project: Kactus 2\n# Author: Esko Pekkarinen\n# Date: 07.08.2017\n#\n# Description:\n# Qt project file template for running unit tests for a single module.\n#-----------------------------------------------------------------------------\n\nTEMPLATE = app\n\nTARGET = tst_IndirectInterfaceWriter\n\nQT += core xml testlib\nQT -= gui\n\nCONFIG += c++11 testcase console\n\nlinux-g++ | linux-g++-64 | linux-g++-32 {\n LIBS += -L../../../executable \\\n     -lIPXACTmodels\n}\n\nwin64 | win32 {\n LIBS += -L../../../executable \\\n     -lIPXACTmodelsd\n}\n\nINCLUDEPATH += $$DESTDIR\nINCLUDEPATH += ../../../\n\nDEPENDPATH += .\nDEPENDPATH += ../../../\n\nOBJECTS_DIR += $$DESTDIR\n\nMOC_DIR += ./generatedFiles\nUI_DIR += ./generatedFiles\nRCC_DIR += ./generatedFiles\ninclude(tst_IndirectInterfaceWriter.pri)\n"
  },
  {
    "path": "tests/IPXACTmodels/Component/tst_InstantiationsReader.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: tst_InstantiationsReader.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 07.09.2015\r\n//\r\n// Description:\r\n// Unit test for class InstantiationsReader.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include <IPXACTmodels/common/VendorExtension.h>\r\n#include <IPXACTmodels/Component/InstantiationsReader.h>\r\n\r\n#include <QtTest>\r\n\r\nclass tst_InstantiationsReader : public QObject\r\n{\r\n    Q_OBJECT\r\n\r\npublic:\r\n    tst_InstantiationsReader();\r\n\r\nprivate slots:\r\n    \r\n    void readDesignInstantiation();\r\n    void readDesignInstantiationExtensions();\r\n\r\n    void readDesignConfigurationInstantiation();\r\n    void readDesignConfigurationInstantiationLanguage();\r\n    void readDesignConfigurationInstantiationParameters();\r\n    void readDesignConfigurationInstantiationExtensions();\r\n\r\n    void readComponentInstantiation();\r\n    void readVirtualComponentInstantiation();\r\n    void readComponentInstantiationLanguage();\r\n    void readComponentInstantiationNameReferences();\r\n    void readComponentInstantiationModuleParameters();\r\n    void readComponentInstantiationModuleParameters2022();\r\n    void readComponentInstantiationDefaultFileBuilders();\r\n    void readComponentInstantiationFileSetReferences();\r\n    void readComponentInstantiationParameters();\r\n    void readComponentInstantiationExtensions();\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_InstantiationsReader::tst_InstantiationsReader()\r\n//-----------------------------------------------------------------------------\r\ntst_InstantiationsReader::tst_InstantiationsReader()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_InstantiationsReader::readDesignInstantiation()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_InstantiationsReader::readDesignInstantiation()\r\n{\r\n    QString documentContent(\r\n        \"<ipxact:designInstantiation>\"\r\n            \"<ipxact:name>testDesignInstantiation</ipxact:name>\"\r\n            \"<ipxact:displayName>display</ipxact:displayName>\"\r\n            \"<ipxact:description>described</ipxact:description>\"\r\n            \"<ipxact:designRef vendor=\\\"TUT\\\" library=\\\"TestLibrary\\\" name=\\\"designReference\\\" version=\\\"1.0\\\">\"\r\n                \"<ipxact:configurableElementValues>\"\r\n                    \"<ipxact:configurableElementValue referenceId=\\\"refID\\\">20</ipxact:configurableElementValue>\"\r\n                \"</ipxact:configurableElementValues>\"\r\n            \"</ipxact:designRef>\"\r\n        \"</ipxact:designInstantiation>\"\r\n        );\r\n\r\n\r\n    QDomDocument document;\r\n    document.setContent(documentContent);\r\n\r\n    QDomNode instantiationNode = document.firstChildElement(\"ipxact:designInstantiation\");\r\n\r\n    QSharedPointer<DesignInstantiation> testDesignInstantiation =\r\n        InstantiationsReader::createDesignInstantiationFrom(instantiationNode);\r\n    \r\n    QCOMPARE(testDesignInstantiation->name(), QString(\"testDesignInstantiation\"));\r\n    QCOMPARE(testDesignInstantiation->displayName(), QString(\"display\"));\r\n    QCOMPARE(testDesignInstantiation->description(), QString(\"described\"));\r\n\r\n    QSharedPointer<ConfigurableVLNVReference> designReference = testDesignInstantiation->getDesignReference();\r\n    QCOMPARE(designReference->getVendor(), QString(\"TUT\"));\r\n    QCOMPARE(designReference->getLibrary(), QString(\"TestLibrary\"));\r\n    QCOMPARE(designReference->getName(), QString(\"designReference\"));\r\n    QCOMPARE(designReference->getVersion(), QString(\"1.0\"));\r\n\r\n    QCOMPARE(designReference->getConfigurableElementValues()->size(), 1);\r\n    QCOMPARE(designReference->getConfigurableElementValues()->first()->getReferenceId(), QString(\"refID\"));\r\n    QCOMPARE(designReference->getConfigurableElementValues()->first()->getConfigurableValue(), QString(\"20\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_InstantiationsReader::readDesignInstantiationExtensions()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_InstantiationsReader::readDesignInstantiationExtensions()\r\n{\r\n    QString documentContent(\r\n        \"<ipxact:designInstantiation>\"\r\n            \"<ipxact:name>testDesignInstantiation</ipxact:name>\"\r\n            \"<ipxact:designRef vendor=\\\"TUT\\\" library=\\\"TestLibrary\\\" name=\\\"designReference\\\" version=\\\"1.0\\\">\"\r\n                \"<ipxact:configurableElementValues>\"\r\n                    \"<ipxact:configurableElementValue referenceId=\\\"refID\\\">20</ipxact:configurableElementValue>\"\r\n                \"</ipxact:configurableElementValues>\"\r\n            \"</ipxact:designRef>\"\r\n            \"<ipxact:vendorExtensions>\"\r\n                \"<testExtension testExtensionAttribute=\\\"extension\\\">testValue</testExtension>\"\r\n            \"</ipxact:vendorExtensions>\"\r\n        \"</ipxact:designInstantiation>\"\r\n        );\r\n\r\n\r\n    QDomDocument document;\r\n    document.setContent(documentContent);\r\n\r\n    QDomNode instantiationNode = document.firstChildElement(\"ipxact:designInstantiation\");\r\n\r\n    QSharedPointer<DesignInstantiation> testDesignInstantiation =\r\n        InstantiationsReader::createDesignInstantiationFrom(instantiationNode);\r\n\r\n    QCOMPARE(testDesignInstantiation->name(), QString(\"testDesignInstantiation\"));\r\n\r\n    QCOMPARE(testDesignInstantiation->getVendorExtensions()->size(), 1);\r\n    QCOMPARE(testDesignInstantiation->getVendorExtensions()->first()->type(), QString(\"testExtension\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_InstantiationsReader::readDesignConfigurationInstantiation()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_InstantiationsReader::readDesignConfigurationInstantiation()\r\n{\r\n    QString documentContent(\r\n        \"<ipxact:designConfigurationInstantiation>\"\r\n            \"<ipxact:name>testInstantiation</ipxact:name>\"\r\n            \"<ipxact:displayName>display</ipxact:displayName>\"\r\n            \"<ipxact:description>described</ipxact:description>\"\r\n            \"<ipxact:designConfigurationRef vendor=\\\"TUT\\\" library=\\\"TestLibrary\\\"\"\r\n                    \" name=\\\"designConfiguration\\\" version=\\\"1.1\\\">\"\r\n                \"<ipxact:configurableElementValues>\"\r\n                    \"<ipxact:configurableElementValue referenceId=\\\"reference\\\">4+4</ipxact:configurableElementValue>\"\r\n                \"</ipxact:configurableElementValues>\"\r\n            \"</ipxact:designConfigurationRef>\"\r\n        \"</ipxact:designConfigurationInstantiation>\"\r\n        );\r\n\r\n\r\n    QDomDocument document;\r\n    document.setContent(documentContent);\r\n\r\n    QDomNode instantiationNode = document.firstChildElement(\"ipxact:designConfigurationInstantiation\");\r\n\r\n    QSharedPointer<DesignConfigurationInstantiation> testInstantiation =\r\n        InstantiationsReader::createDesignConfigurationInstantiationFrom(instantiationNode, Document::Revision::Std14);\r\n\r\n    QCOMPARE(testInstantiation->name(), QString(\"testInstantiation\"));\r\n    QCOMPARE(testInstantiation->displayName(), QString(\"display\"));\r\n    QCOMPARE(testInstantiation->description(), QString(\"described\"));\r\n\r\n    QSharedPointer<ConfigurableVLNVReference> configurationReference =\r\n        testInstantiation->getDesignConfigurationReference();\r\n    QCOMPARE(configurationReference->getVendor(), QString(\"TUT\"));\r\n    QCOMPARE(configurationReference->getLibrary(), QString(\"TestLibrary\"));\r\n    QCOMPARE(configurationReference->getName(), QString(\"designConfiguration\"));\r\n    QCOMPARE(configurationReference->getVersion(), QString(\"1.1\"));\r\n\r\n    QCOMPARE(configurationReference->getConfigurableElementValues()->size(), 1);\r\n    QSharedPointer<ConfigurableElementValue> element =\r\n        configurationReference->getConfigurableElementValues()->first();\r\n    QCOMPARE(element->getReferenceId(), QString(\"reference\"));\r\n    QCOMPARE(element->getConfigurableValue(), QString(\"4+4\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_InstantiationsReader::readDesignConfigurationLanguage()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_InstantiationsReader::readDesignConfigurationInstantiationLanguage()\r\n{\r\n    QString documentContent(\r\n        \"<ipxact:designConfigurationInstantiation>\"\r\n            \"<ipxact:name>testInstantiation</ipxact:name>\"\r\n            \"<ipxact:language>vhdl</ipxact:language>\"\r\n            \"<ipxact:designConfigurationRef vendor=\\\"TUT\\\" library=\\\"TestLibrary\\\"\"\r\n                    \" name=\\\"designConfiguration\\\" version=\\\"1.1\\\">\"\r\n                \"<ipxact:configurableElementValues>\"\r\n                    \"<ipxact:configurableElementValue referenceId=\\\"reference\\\">4+4</ipxact:configurableElementValue>\"\r\n                \"</ipxact:configurableElementValues>\"\r\n            \"</ipxact:designConfigurationRef>\"\r\n        \"</ipxact:designConfigurationInstantiation>\"\r\n        );\r\n\r\n    QDomDocument document;\r\n    document.setContent(documentContent);\r\n\r\n    QDomNode instantiationNode = document.firstChildElement(\"ipxact:designConfigurationInstantiation\");\r\n\r\n    QSharedPointer<DesignConfigurationInstantiation> testInstantiation =\r\n        InstantiationsReader::createDesignConfigurationInstantiationFrom(instantiationNode, Document::Revision::Std14);\r\n\r\n    QCOMPARE(testInstantiation->name(), QString(\"testInstantiation\"));\r\n    QCOMPARE(testInstantiation->getLanguage(), QString(\"vhdl\"));\r\n    QCOMPARE(testInstantiation->isLangugageStrict(), false);\r\n\r\n    documentContent =\r\n        \"<ipxact:designConfigurationInstantiation>\"\r\n            \"<ipxact:name>designConfigurationInstantiation</ipxact:name>\"\r\n            \"<ipxact:language strict=\\\"true\\\">verilog</ipxact:language>\"\r\n            \"<ipxact:designConfigurationRef vendor=\\\"TUT\\\" library=\\\"TestLibrary\\\"\"\r\n                    \" name=\\\"designConfiguration\\\" version=\\\"1.1\\\">\"\r\n                \"<ipxact:configurableElementValues>\"\r\n                    \"<ipxact:configurableElementValue referenceId=\\\"reference\\\">4+4</ipxact:configurableElementValue>\"\r\n                \"</ipxact:configurableElementValues>\"\r\n            \"</ipxact:designConfigurationRef>\"\r\n        \"</ipxact:designConfigurationInstantiation>\"\r\n        ;\r\n    document.setContent(documentContent);\r\n    instantiationNode = document.firstChildElement(\"ipxact:designConfigurationInstantiation\");\r\n\r\n    testInstantiation = InstantiationsReader::createDesignConfigurationInstantiationFrom(instantiationNode, Document::Revision::Std14);\r\n\r\n    QCOMPARE(testInstantiation->name(), QString(\"designConfigurationInstantiation\"));\r\n    QCOMPARE(testInstantiation->getLanguage(), QString(\"verilog\"));\r\n    QCOMPARE(testInstantiation->isLangugageStrict(), true);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_InstantiationsReader::readDesignConfigurationParameters()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_InstantiationsReader::readDesignConfigurationInstantiationParameters()\r\n{\r\n    QString documentContent(\r\n        \"<ipxact:designConfigurationInstantiation>\"\r\n            \"<ipxact:name>testInstantiation</ipxact:name>\"\r\n            \"<ipxact:designConfigurationRef vendor=\\\"TUT\\\" library=\\\"TestLibrary\\\"\"\r\n                    \" name=\\\"designConfiguration\\\" version=\\\"1.1\\\">\"\r\n                \"<ipxact:configurableElementValues>\"\r\n                    \"<ipxact:configurableElementValue referenceId=\\\"reference\\\">4+4</ipxact:configurableElementValue>\"\r\n                \"</ipxact:configurableElementValues>\"\r\n            \"</ipxact:designConfigurationRef>\"\r\n            \"<ipxact:parameters>\"\r\n                \"<ipxact:parameter parameterId=\\\"testID\\\">\"\r\n                    \"<ipxact:name>testParameter</ipxact:name>\"\r\n                    \"<ipxact:value>1</ipxact:value>\"\r\n                \"</ipxact:parameter>\"\r\n                \"<ipxact:parameter parameterId=\\\"otherID\\\">\"\r\n                    \"<ipxact:name>otherParameter</ipxact:name>\"\r\n                    \"<ipxact:value>testID+1</ipxact:value>\"\r\n                \"</ipxact:parameter>\"\r\n            \"</ipxact:parameters>\"\r\n        \"</ipxact:designConfigurationInstantiation>\"\r\n        );\r\n\r\n    QDomDocument document;\r\n    document.setContent(documentContent);\r\n\r\n    QDomNode instantiationNode = document.firstChildElement(\"ipxact:designConfigurationInstantiation\");\r\n\r\n    QSharedPointer<DesignConfigurationInstantiation> testInstantiation =\r\n        InstantiationsReader::createDesignConfigurationInstantiationFrom(instantiationNode, Document::Revision::Std14);\r\n\r\n    QCOMPARE(testInstantiation->name(), QString(\"testInstantiation\"));\r\n    \r\n    QCOMPARE(testInstantiation->getParameters()->size(), 2);\r\n    QCOMPARE(testInstantiation->getParameters()->first()->name(), QString(\"testParameter\"));\r\n    QCOMPARE(testInstantiation->getParameters()->first()->getValueId(), QString(\"testID\"));\r\n    QCOMPARE(testInstantiation->getParameters()->first()->getValue(), QString(\"1\"));\r\n    QCOMPARE(testInstantiation->getParameters()->last()->name(), QString(\"otherParameter\"));\r\n    QCOMPARE(testInstantiation->getParameters()->last()->getValueId(), QString(\"otherID\"));\r\n    QCOMPARE(testInstantiation->getParameters()->last()->getValue(), QString(\"testID+1\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_InstantiationsReader::readDesignConfigurationInstantiationExtensions()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_InstantiationsReader::readDesignConfigurationInstantiationExtensions()\r\n{\r\n    QString documentContent(\r\n        \"<ipxact:designConfigurationInstantiation>\"\r\n            \"<ipxact:name>testInstantiation</ipxact:name>\"\r\n            \"<ipxact:designConfigurationRef vendor=\\\"TUT\\\" library=\\\"TestLibrary\\\"\"\r\n                    \" name=\\\"designConfiguration\\\" version=\\\"1.1\\\">\"\r\n                \"<ipxact:configurableElementValues>\"\r\n                    \"<ipxact:configurableElementValue referenceId=\\\"reference\\\">4+4</ipxact:configurableElementValue>\"\r\n                \"</ipxact:configurableElementValues>\"\r\n            \"</ipxact:designConfigurationRef>\"\r\n            \"<ipxact:vendorExtensions>\"\r\n                \"<testExtension testExtensionAttribute=\\\"extension\\\">testValue</testExtension>\"\r\n            \"</ipxact:vendorExtensions>\"\r\n        \"</ipxact:designConfigurationInstantiation>\"\r\n        );\r\n\r\n    QDomDocument document;\r\n    document.setContent(documentContent);\r\n\r\n    QDomNode instantiationNode = document.firstChildElement(\"ipxact:designConfigurationInstantiation\");\r\n\r\n    QSharedPointer<DesignConfigurationInstantiation> testInstantiation =\r\n        InstantiationsReader::createDesignConfigurationInstantiationFrom(instantiationNode, Document::Revision::Std14);\r\n\r\n    QCOMPARE(testInstantiation->name(), QString(\"testInstantiation\"));\r\n\r\n    QCOMPARE(testInstantiation->getVendorExtensions()->size(), 1);\r\n    QCOMPARE(testInstantiation->getVendorExtensions()->first()->type(), QString(\"testExtension\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_InstantiationsReader::readComponentInstantiation()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_InstantiationsReader::readComponentInstantiation()\r\n{\r\n    QString documentContent(\r\n        \"<ipxact:componentInstantiation>\"\r\n            \"<ipxact:name>testInstantiation</ipxact:name>\"\r\n            \"<ipxact:displayName>displayed</ipxact:displayName>\"\r\n            \"<ipxact:description>described</ipxact:description>\"\r\n        \"</ipxact:designConfigurationInstantiation>\"\r\n        );\r\n\r\n    QDomDocument document;\r\n    document.setContent(documentContent);\r\n\r\n    QDomNode instantiationNode = document.firstChildElement(\"ipxact:componentInstantiation\");\r\n\r\n    QSharedPointer<ComponentInstantiation> testInstantiation =\r\n        InstantiationsReader::createComponentInstantiationFrom(instantiationNode, Document::Revision::Std14);\r\n\r\n    QCOMPARE(testInstantiation->name(), QString(\"testInstantiation\"));\r\n    QCOMPARE(testInstantiation->displayName(), QString(\"displayed\"));\r\n    QCOMPARE(testInstantiation->description(), QString(\"described\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_InstantiationsReader::readVirtualComponentInstantiation()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_InstantiationsReader::readVirtualComponentInstantiation()\r\n{\r\n    QString documentContent(\r\n        \"<ipxact:componentInstantiation>\"\r\n            \"<ipxact:name>testInstantiation</ipxact:name>\"\r\n            \"<ipxact:isVirtual>true</ipxact:isVirtual>\"\r\n        \"</ipxact:designConfigurationInstantiation>\"\r\n        );\r\n\r\n    QDomDocument document;\r\n    document.setContent(documentContent);\r\n\r\n    QDomNode instantiationNode = document.firstChildElement(\"ipxact:componentInstantiation\");\r\n\r\n    QSharedPointer<ComponentInstantiation> testInstantiation =\r\n        InstantiationsReader::createComponentInstantiationFrom(instantiationNode, Document::Revision::Std14);\r\n\r\n    QCOMPARE(testInstantiation->name(), QString(\"testInstantiation\"));\r\n    QCOMPARE(testInstantiation->isVirtual(), true);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_InstantiationsReader::readComponentInstantiationLanguage()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_InstantiationsReader::readComponentInstantiationLanguage()\r\n{\r\n    QString documentContent(\r\n        \"<ipxact:componentInstantiation>\"\r\n            \"<ipxact:name>testInstantiation</ipxact:name>\"\r\n            \"<ipxact:language>verilog</ipxact:language>\"\r\n        \"</ipxact:designConfigurationInstantiation>\"\r\n        );\r\n\r\n    QDomDocument document;\r\n    document.setContent(documentContent);\r\n\r\n    QDomNode instantiationNode = document.firstChildElement(\"ipxact:componentInstantiation\");\r\n\r\n    QSharedPointer<ComponentInstantiation> testInstantiation =\r\n        InstantiationsReader::createComponentInstantiationFrom(instantiationNode, Document::Revision::Std14);\r\n\r\n    QCOMPARE(testInstantiation->name(), QString(\"testInstantiation\"));\r\n    QCOMPARE(testInstantiation->getLanguage(), QString(\"verilog\"));\r\n    QCOMPARE(testInstantiation->isLanguageStrict(), false);\r\n\r\n    documentContent = \r\n        \"<ipxact:componentInstantiation>\"\r\n            \"<ipxact:name>testInstantiation</ipxact:name>\"\r\n            \"<ipxact:language strict=\\\"true\\\">vhdl</ipxact:language>\"\r\n        \"</ipxact:componentInstantiation>\"\r\n        ;\r\n\r\n    document.setContent(documentContent);\r\n    instantiationNode = document.firstChildElement(\"ipxact:componentInstantiation\");\r\n\r\n    testInstantiation = InstantiationsReader::createComponentInstantiationFrom(instantiationNode, Document::Revision::Std14);\r\n\r\n    QCOMPARE(testInstantiation->name(), QString(\"testInstantiation\"));\r\n    QCOMPARE(testInstantiation->getLanguage(), QString(\"vhdl\"));\r\n    QCOMPARE(testInstantiation->isLanguageStrict(), true);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_InstantiationsReader::readComponentInstantiationNameReferences()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_InstantiationsReader::readComponentInstantiationNameReferences()\r\n{\r\n    QString documentContent(\r\n        \"<ipxact:componentInstantiation>\"\r\n            \"<ipxact:name>testInstantiation</ipxact:name>\"\r\n            \"<ipxact:libraryName>work</ipxact:libraryName>\"\r\n            \"<ipxact:packageName>componentVLNV_cmp_pkg</ipxact:packageName>\"\r\n            \"<ipxact:moduleName>componentVLNV</ipxact:moduleName>\"\r\n            \"<ipxact:architectureName>rtl</ipxact:architectureName>\"\r\n            \"<ipxact:configurationName>componentVLNV_rtl_cfg</ipxact:configurationName>\"\r\n        \"</ipxact:designConfigurationInstantiation>\"\r\n        );\r\n\r\n    QDomDocument document;\r\n    document.setContent(documentContent);\r\n\r\n    QDomNode instantiationNode = document.firstChildElement(\"ipxact:componentInstantiation\");\r\n\r\n    QSharedPointer<ComponentInstantiation> testInstantiation =\r\n        InstantiationsReader::createComponentInstantiationFrom(instantiationNode, Document::Revision::Std14);\r\n\r\n    QCOMPARE(testInstantiation->name(), QString(\"testInstantiation\"));\r\n\r\n    QCOMPARE(testInstantiation->getLibraryName(), QString(\"work\"));\r\n    QCOMPARE(testInstantiation->getPackageName(), QString(\"componentVLNV_cmp_pkg\"));\r\n    QCOMPARE(testInstantiation->getModuleName(), QString(\"componentVLNV\"));\r\n    QCOMPARE(testInstantiation->getArchitectureName(), QString(\"rtl\"));\r\n    QCOMPARE(testInstantiation->getConfigurationName(), QString(\"componentVLNV_rtl_cfg\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_InstantiationsReader::readComponentInstantiationModuleParameters()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_InstantiationsReader::readComponentInstantiationModuleParameters()\r\n{\r\n    QString documentContent(\r\n        \"<ipxact:componentInstantiation>\"\r\n            \"<ipxact:name>testInstantiation</ipxact:name>\"\r\n            \"<ipxact:moduleName>componentVLNV</ipxact:moduleName>\"\r\n            \"<ipxact:moduleParameters>\"\r\n                \"<ipxact:moduleParameter choiceRef=\\\"testingChoice\\\" dataType=\\\"longInt\\\" maximum=\\\"403\\\"\"\r\n                        \" minimum=\\\"3\\\" parameterId=\\\"testID\\\" usageType=\\\"int\\\">\"\r\n                    \"<ipxact:name>nameTest</ipxact:name>\"\r\n                    \"<ipxact:value>400</ipxact:value>\"\r\n                    \"<ipxact:isPresent>4-3</ipxact:isPresent>\"\r\n                \"</ipxact:moduleParameter>\"\r\n            \"</ipxact:moduleParameters>\"\r\n        \"</ipxact:designConfigurationInstantiation>\"\r\n        );\r\n\r\n    QDomDocument document;\r\n    document.setContent(documentContent);\r\n\r\n    QDomNode instantiationNode = document.firstChildElement(\"ipxact:componentInstantiation\");\r\n\r\n    QSharedPointer<ComponentInstantiation> testInstantiation =\r\n        InstantiationsReader::createComponentInstantiationFrom(instantiationNode, Document::Revision::Std14);\r\n\r\n    QCOMPARE(testInstantiation->name(), QString(\"testInstantiation\"));\r\n    QCOMPARE(testInstantiation->getModuleName(), QString(\"componentVLNV\"));\r\n\r\n    QCOMPARE(testInstantiation->getModuleParameters()->size(), 1);\r\n    QSharedPointer<ModuleParameter> moduleParameter = testInstantiation->getModuleParameters()->first();\r\n    QCOMPARE(moduleParameter->name(), QString(\"nameTest\"));\r\n    QCOMPARE(moduleParameter->getValue(), QString(\"400\"));\r\n    QCOMPARE(moduleParameter->getIsPresent(), QString(\"4-3\"));\r\n\r\n    QCOMPARE(moduleParameter->getChoiceRef(), QString(\"testingChoice\"));\r\n    QCOMPARE(moduleParameter->getDataType(), QString(\"longInt\"));\r\n    QCOMPARE(moduleParameter->getMaximumValue(), QString(\"403\"));\r\n    QCOMPARE(moduleParameter->getMinimumValue(), QString(\"3\"));\r\n    QCOMPARE(moduleParameter->getValueId(), QString(\"testID\"));\r\n    QCOMPARE(moduleParameter->getUsageType(), QString(\"int\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_InstantiationsReader::readComponentInstantiationModuleParameters2022()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_InstantiationsReader::readComponentInstantiationModuleParameters2022()\r\n{\r\n    QString documentContent(\r\n        \"<ipxact:componentInstantiation>\"\r\n            \"<ipxact:name>testInstantiation</ipxact:name>\"\r\n            \"<ipxact:moduleName>componentVLNV</ipxact:moduleName>\"\r\n            \"<ipxact:moduleParameters>\"\r\n                \"<ipxact:moduleParameter dataType=\\\"int\\\" usageType=\\\"runtime\\\">\"\r\n                    \"<ipxact:name>nameTest</ipxact:name>\"\r\n                    \"<ipxact:shortDescription>short desc</ipxact:shortDescription>\"\r\n                    \"<ipxact:vectors>\"\r\n                        \"<ipxact:vector vectorId=\\\"testVector\\\">\"\r\n                            \"<ipxact:left>0</ipxact:left>\"\r\n                            \"<ipxact:right>4</ipxact:right>\"\r\n                        \"</ipxact:vector>\"\r\n                    \"</ipxact:vectors>\"\r\n                    \"<ipxact:arrays>\"\r\n                        \"<ipxact:array arrayId=\\\"testArray\\\">\"\r\n                            \"<ipxact:left>0</ipxact:left>\"\r\n                            \"<ipxact:right>4</ipxact:right>\"\r\n                        \"</ipxact:array>\"\r\n                    \"</ipxact:arrays>\"\r\n                    \"<ipxact:value>400</ipxact:value>\"\r\n                    \"<ipxact:isPresent>4-3</ipxact:isPresent>\"\r\n                \"</ipxact:moduleParameter>\"\r\n            \"</ipxact:moduleParameters>\"\r\n        \"</ipxact:designConfigurationInstantiation>\"\r\n        );\r\n\r\n    QDomDocument document;\r\n    document.setContent(documentContent);\r\n\r\n    QDomNode instantiationNode = document.firstChildElement(\"ipxact:componentInstantiation\");\r\n\r\n    QSharedPointer<ComponentInstantiation> testInstantiation =\r\n        InstantiationsReader::createComponentInstantiationFrom(instantiationNode, Document::Revision::Std22);\r\n\r\n    QCOMPARE(testInstantiation->name(), QString(\"testInstantiation\"));\r\n    QCOMPARE(testInstantiation->getModuleName(), QString(\"componentVLNV\"));\r\n\r\n    QCOMPARE(testInstantiation->getModuleParameters()->size(), 1);\r\n    QSharedPointer<ModuleParameter> moduleParameter = testInstantiation->getModuleParameters()->first();\r\n    QCOMPARE(moduleParameter->name(), QString(\"nameTest\"));\r\n    QCOMPARE(moduleParameter->getValue(), QString(\"400\"));\r\n    QCOMPARE(moduleParameter->getIsPresent(), QString(\"\")); // no is present in std22\r\n\r\n    QCOMPARE(moduleParameter->getDataType(), QString(\"int\"));\r\n    QCOMPARE(moduleParameter->getUsageType(), QString(\"runtime\"));\r\n\r\n    auto testVector = moduleParameter->getVectors()->first();\r\n    auto testArray = moduleParameter->getArrays()->first();\r\n\r\n    QCOMPARE(testVector->getId(), QString(\"testVector\"));\r\n    QCOMPARE(testArray->getId(), QString(\"testArray\"));\r\n    QCOMPARE(testVector->getLeft(), QString(\"0\"));\r\n    QCOMPARE(testVector->getRight(), QString(\"4\"));\r\n    QCOMPARE(testArray->getLeft(), QString(\"0\"));\r\n    QCOMPARE(testArray->getRight(), QString(\"4\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_InstantiationsReader::readComponentInstantiationDefaultFileBuilders()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_InstantiationsReader::readComponentInstantiationDefaultFileBuilders()\r\n{\r\n    QString documentContent(\r\n        \"<ipxact:componentInstantiation>\"\r\n            \"<ipxact:name>testInstantiation</ipxact:name>\"\r\n            \"<ipxact:defaultFileBuilder>\"\r\n                \"<ipxact:fileType>asmSource</ipxact:fileType>\"\r\n                \"<ipxact:command>riseFromYourGrave</ipxact:command>\"\r\n                \"<ipxact:flags>passedFlags</ipxact:flags>\"\r\n                \"<ipxact:replaceDefaultFlags>1-1+0</ipxact:replaceDefaultFlags>\"\r\n            \"</ipxact:defaultFileBuilder>\"\r\n        \"</ipxact:designConfigurationInstantiation>\"\r\n        );\r\n\r\n    QDomDocument document;\r\n    document.setContent(documentContent);\r\n\r\n    QDomNode instantiationNode = document.firstChildElement(\"ipxact:componentInstantiation\");\r\n\r\n    QSharedPointer<ComponentInstantiation> testInstantiation =\r\n        InstantiationsReader::createComponentInstantiationFrom(instantiationNode, Document::Revision::Std14);\r\n\r\n    QCOMPARE(testInstantiation->name(), QString(\"testInstantiation\"));\r\n\r\n    QCOMPARE(testInstantiation->getDefaultFileBuilders()->size(), 1);\r\n\r\n    QSharedPointer<FileBuilder> defaultFileBuilder = testInstantiation->getDefaultFileBuilders()->first();\r\n    QCOMPARE(defaultFileBuilder->getFileType().type_, QString(\"asmSource\"));\r\n    QCOMPARE(defaultFileBuilder->getCommand(), QString(\"riseFromYourGrave\"));\r\n    QCOMPARE(defaultFileBuilder->getFlags(), QString(\"passedFlags\"));\r\n    QCOMPARE(defaultFileBuilder->getReplaceDefaultFlags(), QString(\"1-1+0\"));\r\n\r\n    documentContent =\r\n        \"<ipxact:componentInstantiation>\"\r\n            \"<ipxact:name>testInstantiation</ipxact:name>\"\r\n            \"<ipxact:defaultFileBuilder>\"\r\n                \"<ipxact:fileType user=\\\"userFile\\\">user</ipxact:fileType>\"\r\n                \"<ipxact:command>riseFromYourGrave</ipxact:command>\"\r\n                \"<ipxact:flags>passedFlags</ipxact:flags>\"\r\n                \"<ipxact:replaceDefaultFlags>1-1+0</ipxact:replaceDefaultFlags>\"\r\n            \"</ipxact:defaultFileBuilder>\"\r\n        \"</ipxact:designConfigurationInstantiation>\"\r\n        ;\r\n\r\n    document.setContent(documentContent);\r\n\r\n    instantiationNode = document.firstChildElement(\"ipxact:componentInstantiation\");\r\n    testInstantiation = InstantiationsReader::createComponentInstantiationFrom(instantiationNode, Document::Revision::Std14);\r\n\r\n    QCOMPARE(testInstantiation->getDefaultFileBuilders()->size(), 1);\r\n\r\n    defaultFileBuilder = testInstantiation->getDefaultFileBuilders()->first();\r\n    QCOMPARE(defaultFileBuilder->getFileType().type_, QString(\"userFile\"));\r\n    QCOMPARE(defaultFileBuilder->getCommand(), QString(\"riseFromYourGrave\"));\r\n    QCOMPARE(defaultFileBuilder->getFlags(), QString(\"passedFlags\"));\r\n    QCOMPARE(defaultFileBuilder->getReplaceDefaultFlags(), QString(\"1-1+0\"));\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_InstantiationsReader::readComponentInstantiationFileSetReferences()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_InstantiationsReader::readComponentInstantiationFileSetReferences()\r\n{\r\n    QString documentContent(\r\n        \"<ipxact:componentInstantiation>\"\r\n            \"<ipxact:name>testInstantiation</ipxact:name>\"\r\n            \"<ipxact:fileSetRef>\"\r\n                \"<ipxact:localName>otherFile</ipxact:localName>\"\r\n                \"<ipxact:isPresent>1</ipxact:isPresent>\"\r\n            \"</ipxact:fileSetRef>\"\r\n            \"<ipxact:fileSetRef>\"\r\n                \"<ipxact:localName>referencedFile</ipxact:localName>\"\r\n            \"</ipxact:fileSetRef>\"\r\n        \"</ipxact:designConfigurationInstantiation>\"\r\n        );\r\n\r\n    QDomDocument document;\r\n    document.setContent(documentContent);\r\n\r\n    QDomNode instantiationNode = document.firstChildElement(\"ipxact:componentInstantiation\");\r\n\r\n    QSharedPointer<ComponentInstantiation> testInstantiation =\r\n        InstantiationsReader::createComponentInstantiationFrom(instantiationNode, Document::Revision::Std14);\r\n\r\n    QCOMPARE(testInstantiation->name(), QString(\"testInstantiation\"));\r\n\r\n    QCOMPARE(testInstantiation->getFileSetReferences()->count(), 2);\r\n    QCOMPARE(testInstantiation->getFileSetReferences()->first()->getReference(), QString(\"otherFile\"));\r\n    QCOMPARE(testInstantiation->getFileSetReferences()->first()->getIsPresent(), QString(\"1\"));\r\n    QCOMPARE(testInstantiation->getFileSetReferences()->last()->getReference(), QString(\"referencedFile\"));\r\n\r\n    documentContent =\r\n        \"<ipxact:componentInstantiation>\"\r\n            \"<ipxact:name>testInstantiation</ipxact:name>\"\r\n            \"<ipxact:fileSetRef>\"\r\n                \"<ipxact:localName>otherFile</ipxact:localName>\"\r\n                \"<ipxact:vendorExtensions>\"\r\n                    \"<testExtension testExtensionAttribute=\\\"extension\\\">testValue</testExtension>\"\r\n                \"</ipxact:vendorExtensions>\"\r\n            \"</ipxact:fileSetRef>\"\r\n            \"<ipxact:fileSetRef>\"\r\n                \"<ipxact:localName>referencedFile</ipxact:localName>\"\r\n            \"</ipxact:fileSetRef>\"\r\n        \"</ipxact:designConfigurationInstantiation>\"\r\n        ;\r\n\r\n    document.setContent(documentContent);\r\n    instantiationNode = document.firstChildElement(\"ipxact:componentInstantiation\");\r\n\r\n    testInstantiation = InstantiationsReader::createComponentInstantiationFrom(\r\n        instantiationNode, Document::Revision::Std22);\r\n\r\n    QCOMPARE(testInstantiation->name(), QString(\"testInstantiation\"));\r\n\r\n    QCOMPARE(testInstantiation->getFileSetReferences()->count(), 2);\r\n    QCOMPARE(testInstantiation->getFileSetReferences()->first()->getReference(), QString(\"otherFile\"));\r\n    QCOMPARE(testInstantiation->getFileSetReferences()->first()->getVendorExtensions()->size(), 1);\r\n    QCOMPARE(testInstantiation->getFileSetReferences()->last()->getReference(), QString(\"referencedFile\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_InstantiationsReader::readComponentInstantiationParameters()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_InstantiationsReader::readComponentInstantiationParameters()\r\n{\r\n    QString documentContent(\r\n        \"<ipxact:componentInstantiation>\"\r\n            \"<ipxact:name>testInstantiation</ipxact:name>\"\r\n            \"<ipxact:parameters>\"\r\n                \"<ipxact:parameter parameterId=\\\"testID\\\">\"\r\n                    \"<ipxact:name>nameTest</ipxact:name>\"\r\n                    \"<ipxact:value>400</ipxact:value>\"\r\n                \"</ipxact:parameter>\"\r\n                \"<ipxact:parameter parameterId=\\\"otherID\\\">\"\r\n                    \"<ipxact:name>otherTest</ipxact:name>\"\r\n                    \"<ipxact:value>200</ipxact:value>\"\r\n                \"</ipxact:parameter>\"\r\n            \"</ipxact:parameters>\"\r\n        \"</ipxact:designConfigurationInstantiation>\"\r\n        );\r\n\r\n    QDomDocument document;\r\n    document.setContent(documentContent);\r\n\r\n    QDomNode instantiationNode = document.firstChildElement(\"ipxact:componentInstantiation\");\r\n\r\n    QSharedPointer<ComponentInstantiation> testInstantiation =\r\n        InstantiationsReader::createComponentInstantiationFrom(instantiationNode, Document::Revision::Std14);\r\n\r\n    QCOMPARE(testInstantiation->name(), QString(\"testInstantiation\"));\r\n\r\n    QCOMPARE(testInstantiation->getParameters()->size(), 2);\r\n    QCOMPARE(testInstantiation->getParameters()->first()->getValueId(), QString(\"testID\"));\r\n    QCOMPARE(testInstantiation->getParameters()->first()->name(), QString(\"nameTest\"));\r\n    QCOMPARE(testInstantiation->getParameters()->first()->getValue(), QString(\"400\"));\r\n    QCOMPARE(testInstantiation->getParameters()->last()->getValueId(), QString(\"otherID\"));\r\n    QCOMPARE(testInstantiation->getParameters()->last()->name(), QString(\"otherTest\"));\r\n    QCOMPARE(testInstantiation->getParameters()->last()->getValue(), QString(\"200\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_InstantiationsReader::readComponentInstantiationExtensions()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_InstantiationsReader::readComponentInstantiationExtensions()\r\n{\r\n    QString documentContent(\r\n        \"<ipxact:componentInstantiation>\"\r\n            \"<ipxact:name>testInstantiation</ipxact:name>\"\r\n            \"<ipxact:vendorExtensions>\"\r\n                \"<testExtension testExtensionAttribute=\\\"extension\\\">testValue</testExtension>\"\r\n            \"</ipxact:vendorExtensions>\"\r\n        \"</ipxact:designConfigurationInstantiation>\"\r\n        );\r\n\r\n    QDomDocument document;\r\n    document.setContent(documentContent);\r\n\r\n    QDomNode instantiationNode = document.firstChildElement(\"ipxact:componentInstantiation\");\r\n\r\n    QSharedPointer<ComponentInstantiation> testInstantiation =\r\n        InstantiationsReader::createComponentInstantiationFrom(instantiationNode, Document::Revision::Std14);\r\n\r\n    QCOMPARE(testInstantiation->name(), QString(\"testInstantiation\"));\r\n\r\n    QCOMPARE(testInstantiation->getVendorExtensions()->size(), 1);\r\n    QCOMPARE(testInstantiation->getVendorExtensions()->first()->type(), QString(\"testExtension\"));\r\n}\r\n\r\nQTEST_APPLESS_MAIN(tst_InstantiationsReader)\r\n\r\n#include \"tst_InstantiationsReader.moc\"\r\n"
  },
  {
    "path": "tests/IPXACTmodels/Component/tst_InstantiationsReader.pri",
    "content": "# ----------------------------------------------------\r\n# This file is generated by the Qt Visual Studio Tools.\r\n# ------------------------------------------------------\r\n\r\nSOURCES += ./tst_InstantiationsReader.cpp\r\n"
  },
  {
    "path": "tests/IPXACTmodels/Component/tst_InstantiationsReader.pro",
    "content": "#-----------------------------------------------------------------------------\r\n# File: tst_InstantiationsReader.pro\r\n#-----------------------------------------------------------------------------\r\n# Project: Kactus 2\r\n# Author: Mikko Teuho\r\n# Date: 07.09.2015\r\n#\r\n# Description:\r\n# Qt project file template for running unit tests for InstantiationReader.\r\n#-----------------------------------------------------------------------------\r\n\r\nTEMPLATE = app\r\n\r\nTARGET = tst_InstantiationsReader\r\n\r\nQT += core xml testlib\r\nQT -= gui\r\n\r\nCONFIG += c++11 testcase console\r\n\r\nlinux-g++ | linux-g++-64 | linux-g++-32 {\r\n LIBS += -L../../../executable \\\r\n     -lIPXACTmodels\r\n}\r\nwin64 | win32 {\r\n LIBS += -L../../../executable \\\r\n     -lIPXACTmodelsd\r\n}\r\n\r\nINCLUDEPATH += $$DESTDIR\r\nINCLUDEPATH += ../../../\r\n\r\nDEPENDPATH += .\r\nDEPENDPATH += ../../../\r\n\r\nOBJECTS_DIR += $$DESTDIR\r\n\r\nMOC_DIR += ./generatedFiles\r\nUI_DIR += ./generatedFiles\r\nRCC_DIR += ./generatedFiles\r\ninclude(tst_InstantiationsReader.pri)\r\n"
  },
  {
    "path": "tests/IPXACTmodels/Component/tst_InstantiationsValidator.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// Instantiations: tst_InstantiationsValidator.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Janne Virtanen\r\n// Date: 23.11.2015\r\n//\r\n// Description:\r\n// Unit test for class InstantiationsValidator.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include <IPXACTmodels/Component/validators/InstantiationsValidator.h>\r\n#include <IPXACTmodels/common/validators/ParameterValidator.h>\r\n\r\n#include <IPXACTmodels/Design/Design.h>\r\n#include <IPXACTmodels/DesignConfiguration/DesignConfiguration.h>\r\n\r\n#include <IPXACTmodels/Component/ComponentInstantiation.h>\r\n#include <IPXACTmodels/Component/DesignInstantiation.h>\r\n#include <IPXACTmodels/Component/DesignConfigurationInstantiation.h>\r\n#include <IPXACTmodels/Component/FileSet.h>\r\n\r\n#include <KactusAPI/include/SystemVerilogExpressionParser.h>\r\n\r\n#include <tests/MockObjects/LibraryMock.h>\r\n\r\n#include <QtTest>\r\n\r\nclass tst_InstantiationsValidator : public QObject\r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n    tst_InstantiationsValidator();\r\n\r\nprivate slots:\r\n\tvoid designInstantiationFail();\r\n\tvoid designInstantiationSuccess();\r\n\tvoid designConfigurationInstantiationFail();\r\n\tvoid designConfigurationInstantiationSuccess();\r\n\tvoid baseCase();\r\n\tvoid inexistingFileSet();\r\n\tvoid failFileBuilder();\r\n\tvoid failParameter();\r\n\tvoid failModuleParameter();\r\n\tvoid succeedEveryting();\r\n\r\nprivate:\r\n\r\n\tQSharedPointer<QList<QSharedPointer<FileSet > > > fileSets_;\r\n\r\n    QSharedPointer<ExpressionParser> expressionParser_;\r\n\r\n    QSharedPointer<ParameterValidator> parameterValidator_;\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_InstantiationsValidator::tst_InstantiationsValidator()\r\n//-----------------------------------------------------------------------------\r\ntst_InstantiationsValidator::tst_InstantiationsValidator()\r\n{\r\n\tfileSets_ = QSharedPointer<QList<QSharedPointer<FileSet> > >( new QList<QSharedPointer<FileSet> > );\r\n\r\n    expressionParser_ = QSharedPointer<ExpressionParser> (new SystemVerilogExpressionParser());\r\n\r\n    parameterValidator_ = QSharedPointer<ParameterValidator>\r\n        (new ParameterValidator(expressionParser_, QSharedPointer<QList<QSharedPointer<Choice> > > (),\r\n\t\t\tDocument::Revision::Std14));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_InstantiationsValidator::designInstantiationFail()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_InstantiationsValidator::designInstantiationFail()\r\n{\r\n\tQSharedPointer<DesignInstantiation> instantiation( new DesignInstantiation );\r\n\tInstantiationsValidator validator(expressionParser_, fileSets_, parameterValidator_, 0);\r\n\r\n\tinstantiation->setName(\" \\t \\n\");\r\n\tQSharedPointer<ConfigurableVLNVReference> vref( new ConfigurableVLNVReference );\r\n\tinstantiation->setDesignReference(vref);\r\n\r\n\tQVector<QString> errorList;\r\n\tvalidator.findErrorsInDesignInstantiation(errorList, instantiation, \"test\");\r\n\r\n\tQCOMPARE( errorList.size(), 2 );\r\n\tQVERIFY( !validator.validateDesignInstantiation(instantiation) );\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_InstantiationsValidator::designInstantiationSuccess()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_InstantiationsValidator::designInstantiationSuccess()\r\n{\r\n    LibraryMock* mockLibrary(new LibraryMock(this));\r\n\t\r\n    QSharedPointer<ConfigurableVLNVReference> vref(new\r\n        ConfigurableVLNVReference(VLNV::DESIGN, \"vendori\", \"kurjasto\", \"nimi\", \"versio\"));\r\n\t\r\n\tQSharedPointer<Design> testDesign(new Design(*vref, Document::Revision::Std14));\r\n    mockLibrary->addComponent(testDesign);\r\n\r\n\tInstantiationsValidator validator(expressionParser_, fileSets_, parameterValidator_, mockLibrary);\r\n\r\n    QSharedPointer<DesignInstantiation> instantiation( new DesignInstantiation );\r\n\tinstantiation->setName(\"esa\");\r\n\tinstantiation->setDesignReference(vref);\r\n\r\n\tQVector<QString> errorList;\r\n\tvalidator.findErrorsInDesignInstantiation(errorList, instantiation, \"test\");\r\n\r\n\tQCOMPARE( errorList.size(), 0 );\r\n\tQVERIFY( validator.validateDesignInstantiation(instantiation) );\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_InstantiationsValidator::designConfigurationInstantiationFail()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_InstantiationsValidator::designConfigurationInstantiationFail()\r\n{\r\n\tQSharedPointer<DesignConfigurationInstantiation> instantiation( new DesignConfigurationInstantiation );\r\n\tInstantiationsValidator validator(expressionParser_, fileSets_, parameterValidator_, 0);\r\n\r\n\tinstantiation->setName(\" \\t \\n\");\r\n\tQSharedPointer<ConfigurableVLNVReference> vref( new ConfigurableVLNVReference );\r\n\tinstantiation->setDesignConfigurationReference(vref);\r\n\r\n\tQSharedPointer<Parameter> parameter (new Parameter());\r\n\tparameter->setName(\"param\");\r\n\tparameter->setType(\"bit\");\r\n\tparameter->setValue(\"{'b11, 'b00}\");\r\n\tparameter->setValueId(\"parameterid\");\r\n\r\n\tinstantiation->getParameters()->append(parameter);\r\n\r\n\tQVector<QString> errorList;\r\n\tvalidator.findErrorsInDesignConfigurationInstantiation(errorList, instantiation, \"test\");\r\n\r\n\tQCOMPARE( errorList.size(), 3 );\r\n\tQVERIFY( !validator.validateDesignConfigurationInstantiation(instantiation) );\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_InstantiationsValidator::designConfigurationInstantiationSuccess()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_InstantiationsValidator::designConfigurationInstantiationSuccess()\r\n{\r\n    LibraryMock* mockLibrary(new LibraryMock(this));\r\n\r\n    QSharedPointer<ConfigurableVLNVReference> vref(new\r\n        ConfigurableVLNVReference(VLNV::DESIGNCONFIGURATION, \"vendori\", \"kurjasto\", \"nimi\", \"versio\"));\r\n\r\n    QSharedPointer<Design> testDesign(new Design(*vref, Document::Revision::Std14));\r\n    mockLibrary->addComponent(testDesign);\r\n\r\n\tInstantiationsValidator validator(expressionParser_, fileSets_, parameterValidator_, mockLibrary);\r\n\r\n    QSharedPointer<DesignConfigurationInstantiation> instantiation( new DesignConfigurationInstantiation );\r\n\tinstantiation->setName(\"esa\");\r\n\tinstantiation->setDesignConfigurationReference(vref);\r\n\r\n\tQSharedPointer<Parameter> parameter (new Parameter());\r\n\tparameter->setName(\"param\");\r\n\tparameter->setType(\"bit\");\r\n\tparameter->setValue(\"{3'b101,3'b111}\");\r\n\tparameter->setValueId(\"parameterid\");\r\n\r\n\tinstantiation->getParameters()->append(parameter);\r\n\r\n\tQVector<QString> errorList;\r\n\tvalidator.findErrorsInDesignConfigurationInstantiation(errorList, instantiation, \"test\");\r\n\r\n\tQCOMPARE( errorList.size(), 0 );\r\n\tQVERIFY( validator.validateDesignConfigurationInstantiation(instantiation) );\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_InstantiationsValidator::baseCase()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_InstantiationsValidator::baseCase()\r\n{\r\n\tInstantiationsValidator validator(expressionParser_, fileSets_, parameterValidator_, 0);\r\n\r\n    QSharedPointer<ComponentInstantiation> instantiation( new ComponentInstantiation (\"testInstantiation\"));\r\n\r\n    QVector<QString> errorList;\r\n\tvalidator.findErrorsInComponentInstantiation(errorList, instantiation, \"test\", Document::Revision::Std14);\r\n\r\n\tQCOMPARE( errorList.size(), 0 );\r\n\tQVERIFY( validator.validateComponentInstantiation(instantiation) );\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_InstantiationsValidator::inexistingFileSet()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_InstantiationsValidator::inexistingFileSet()\r\n{\r\n\tQSharedPointer<ComponentInstantiation> instantiation( new ComponentInstantiation (\"testInstantiation\"));\r\n\tInstantiationsValidator validator(expressionParser_, fileSets_, parameterValidator_, 0);\r\n\r\n\tinstantiation->getFileSetReferences()->append(QSharedPointer<FileSetRef>(new FileSetRef(\"joq\")));\r\n\r\n\tQVector<QString> errorList;\r\n\tvalidator.findErrorsInComponentInstantiation(errorList, instantiation, \"test\", Document::Revision::Std14);\r\n\r\n\tQCOMPARE( errorList.size(), 1 );\r\n\tQVERIFY( !validator.validateComponentInstantiation(instantiation) );\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_InstantiationsValidator::failFileBuilder()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_InstantiationsValidator::failFileBuilder()\r\n{\r\n\tQSharedPointer<ComponentInstantiation> instantiation( new ComponentInstantiation (\"testInstantiation\"));\r\n\tInstantiationsValidator validator(expressionParser_, fileSets_, parameterValidator_, 0);\r\n\r\n\tQSharedPointer<FileBuilder> fbuilder( new FileBuilder );\r\n\tfbuilder->setReplaceDefaultFlags(\"joq\");\r\n\tinstantiation->getDefaultFileBuilders()->append(fbuilder);\r\n\r\n\tQVector<QString> errorList;\r\n\tvalidator.findErrorsInComponentInstantiation(errorList, instantiation, \"test\", Document::Revision::Std14);\r\n\r\n\tQCOMPARE( errorList.size(), 2 );\r\n\tQVERIFY( !validator.validateComponentInstantiation(instantiation) );\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_InstantiationsValidator::failParameter()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_InstantiationsValidator::failParameter()\r\n{\r\n\tQSharedPointer<ComponentInstantiation> instantiation( new ComponentInstantiation(\"testInstantiation\") );\r\n\tInstantiationsValidator validator(expressionParser_, fileSets_, parameterValidator_, 0);\r\n\r\n\tQSharedPointer<Parameter> parameter (new Parameter());\r\n\tparameter->setName(\"param\");\r\n\tparameter->setType(\"bit\");\r\n\tparameter->setValue(\"{'b11, 'b00}\");\r\n\tparameter->setValueId(\"parameterid\");\r\n\r\n\tinstantiation->getParameters()->append(parameter);\r\n\r\n\tQVector<QString> errorList;\r\n\tvalidator.findErrorsInComponentInstantiation(errorList, instantiation, \"test\", Document::Revision::Std14);\r\n\r\n\tQCOMPARE( errorList.size(), 1 );\r\n\tQVERIFY( !validator.validateComponentInstantiation(instantiation) );\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_InstantiationsValidator::failModuleParameter()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_InstantiationsValidator::failModuleParameter()\r\n{\r\n\tQSharedPointer<ComponentInstantiation> instantiation( new ComponentInstantiation(\"testInstantiation\") );\r\n\tInstantiationsValidator validator(expressionParser_, fileSets_, parameterValidator_, 0);\r\n\r\n\tQSharedPointer<ModuleParameter> parameter (new ModuleParameter());\r\n\tparameter->setName(\"param\");\r\n\tparameter->setType(\"bit\");\r\n\tparameter->setValue(\"{'b11, 'b00}\");\r\n\tparameter->setValueId(\"parameterid\");\r\n\tparameter->setIsPresent(\"eeaaaa\");\r\n\tparameter->setUsageType(\"anti-usage\");\r\n\r\n\tinstantiation->getModuleParameters()->append(parameter);\r\n\r\n\tQVector<QString> errorList;\r\n\tvalidator.findErrorsInComponentInstantiation(errorList, instantiation, \"test\", Document::Revision::Std14);\r\n\r\n\tQCOMPARE( errorList.size(), 3 );\r\n\tQVERIFY( !validator.validateComponentInstantiation(instantiation) );\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_InstantiationsValidator::succeedEveryting()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_InstantiationsValidator::succeedEveryting()\r\n{\r\n\tInstantiationsValidator validator(expressionParser_, fileSets_, parameterValidator_, 0);\r\n\r\n    QSharedPointer<ComponentInstantiation> instantiation( new ComponentInstantiation (\"testInstantiation\"));\r\n\tinstantiation->getFileSetReferences()->append(QSharedPointer<FileSetRef>(new FileSetRef(\"salaiset ansiot\")));\r\n\tQSharedPointer<FileSet> fileSet( new FileSet );\r\n\tfileSet->setName(\"salaiset ansiot\");\r\n\tfileSets_->append(fileSet);\r\n\r\n\tQSharedPointer<FileBuilder> fbuilder( new FileBuilder );\r\n\tfbuilder->setReplaceDefaultFlags(\"0\");\r\n\tfbuilder->setFileType(\"txt\");\r\n\tinstantiation->getDefaultFileBuilders()->append(fbuilder);\r\n\r\n\tQSharedPointer<Parameter> parameter (new Parameter());\r\n\tparameter->setName(\"param\");\r\n\tparameter->setType(\"bit\");\r\n\tparameter->setValue(\"{3'b101,3'b111}\");\r\n\tparameter->setValueId(\"parameterid\");\r\n\r\n\tinstantiation->getParameters()->append(parameter);\r\n\r\n\tQSharedPointer<ModuleParameter> parameter2 (new ModuleParameter());\r\n\tparameter2->setName(\"param\");\r\n\tparameter2->setType(\"bit\");\r\n\tparameter2->setValue(\"{3'b101,3'b111}\");\r\n\tparameter2->setValueId(\"parameterid\");\r\n\tparameter2->setIsPresent(\"1\");\r\n\tparameter2->setUsageType(\"typed\");\r\n\r\n\tinstantiation->getModuleParameters()->append(parameter2);\r\n\r\n\tQVector<QString> errorList;\r\n\tvalidator.findErrorsInComponentInstantiation(errorList, instantiation, \"test\", Document::Revision::Std14);\r\n\r\n\tQCOMPARE( errorList.size(), 0 );\r\n\tQVERIFY( validator.validateComponentInstantiation(instantiation) );\r\n\r\n\t// Test runtime usage type only in std22.\r\n\tparameter2->setUsageType(\"runtime\");\r\n\r\n\tvalidator.findErrorsInComponentInstantiation(errorList, instantiation, \"test\", Document::Revision::Std14);\r\n    QCOMPARE(errorList.size(), 1);\r\n    QVERIFY(!validator.validateComponentInstantiation(instantiation));\r\n\r\n\terrorList.clear();\r\n\tparameter2->setIsPresent(\"\");\r\n\r\n    validator.findErrorsInComponentInstantiation(errorList, instantiation, \"test\", Document::Revision::Std22);\r\n    QCOMPARE(errorList.size(), 0);\r\n    QVERIFY(validator.validateComponentInstantiation(instantiation, Document::Revision::Std22));\r\n\r\n}\r\n\r\nQTEST_APPLESS_MAIN(tst_InstantiationsValidator)\r\n\r\n#include \"tst_InstantiationsValidator.moc\"\r\n"
  },
  {
    "path": "tests/IPXACTmodels/Component/tst_InstantiationsValidator.pri",
    "content": "# ----------------------------------------------------\r\n# This file is generated by the Qt Visual Studio Tools.\r\n# ------------------------------------------------------\r\n\r\nHEADERS += ../../MockObjects/LibraryMock.h \r\n\t\r\nSOURCES += ../../MockObjects/LibraryMock.cpp \\\r\n    ./tst_InstantiationsValidator.cpp \r\n\t"
  },
  {
    "path": "tests/IPXACTmodels/Component/tst_InstantiationsValidator.pro",
    "content": "#-----------------------------------------------------------------------------\r\n# Instantiations: tst_InstantiationsValidator.pro\r\n#-----------------------------------------------------------------------------\r\n# Project: Kactus 2\r\n# Author: Janne Virtanen\r\n# Date: 23.11.2015\r\n#\r\n# Description:\r\n# Qt project Instantiations template for running unit tests for Enumerated Value Validator.\r\n#-----------------------------------------------------------------------------\r\n\r\nTEMPLATE = app\r\n\r\nTARGET = tst_InstantiationsValidator\r\n\r\nQT += core gui xml testlib\r\n\r\nCONFIG += c++11 testcase console\r\n\r\nlinux-g++ | linux-g++-64 | linux-g++-32 {\r\n LIBS += -L../../../executable \\\r\n     -lIPXACTmodels -lKactusAPI\r\n}\r\nwin64 | win32 {\r\n LIBS += -L../../../executable \\\r\n     -lIPXACTmodelsd -lKactusAPId\r\n}\r\n\r\nINCLUDEPATH += $$DESTDIR\r\nINCLUDEPATH += ../../../\r\nINCLUDEPATH += ../../../KactusAPI/include\r\n\r\nDEPENDPATH += .\r\nDEPENDPATH += ../../../\r\n\r\nOBJECTS_DIR += $$DESTDIR\r\n\r\nMOC_DIR += ./generatedFiles\r\nUI_DIR += ./generatedFiles\r\nRCC_DIR += ./generatedFiles\r\ninclude(tst_InstantiationsValidator.pri)\r\n"
  },
  {
    "path": "tests/IPXACTmodels/Component/tst_InstantiationsWriter.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: tst_InstantiationsWriter.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: <Name>\r\n// Date: <Date in the format dd.mm.yyyy>\r\n//\r\n// Description:\r\n// Unit test for class InstantiationsWriter.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include <IPXACTmodels/common/GenericVendorExtension.h>\r\n\r\n#include <IPXACTmodels/Component/ComponentInstantiation.h>\r\n#include <IPXACTmodels/Component/DesignInstantiation.h>\r\n#include <IPXACTmodels/Component/DesignConfigurationInstantiation.h>\r\n#include <IPXACTmodels/Component/InstantiationsWriter.h>\r\n\r\n#include <QtTest>\r\n\r\nclass tst_InstantiationsWriter : public QObject\r\n{\r\n    Q_OBJECT\r\n\r\npublic:\r\n    tst_InstantiationsWriter();\r\n\r\nprivate slots:\r\n\r\n    void writeDesignInstatiation();\r\n    void writeDesignInstantiationExtensions();\r\n\r\n    void writeDesignConfigurationInstantiation();\r\n    void writeDesignConfigurationInstantiationLanguage();\r\n    void writeDesignConfigurationInstantiationParameters();\r\n    void writeDesignConfigurationInstantiationExtensions();\r\n\r\n    void writeComponentInstantiation();\r\n    void writeVirtualComponentInstantiation();\r\n    void writeComponentInstantiationLanguage();\r\n    void writeComponentInstantiationNameReferences();\r\n    void writeComponentInstantiationModuleParameters();\r\n    void writeComponentInstantiationModuleParameters2022();\r\n    void writeComponentInstantiationDefaultFileBuilders();\r\n    void writeComponentInstantiationFileSetReferences();\r\n    void writeComponentInstantiationParameters();\r\n    void writeComponentInstantiationExtensions();\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_InstantiationsWriter::tst_InstantiationsWriter()\r\n//-----------------------------------------------------------------------------\r\ntst_InstantiationsWriter::tst_InstantiationsWriter()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_InstantiationsWriter::writeDesignInstatiations()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_InstantiationsWriter::writeDesignInstatiation()\r\n{\r\n    QString output;\r\n    QXmlStreamWriter xmlStreamWriter(&output);\r\n\r\n     QSharedPointer<ConfigurableVLNVReference> testDesignReference (\r\n         new ConfigurableVLNVReference(VLNV::DESIGN, \"TUT\", \"TestLibrary\", \"designReference\", \"1.0\"));\r\n \r\n     QSharedPointer<ConfigurableElementValue> designReferenceConfig (new ConfigurableElementValue(\"20\", \"refID\"));\r\n     testDesignReference->getConfigurableElementValues()->append(designReferenceConfig);\r\n\r\n    QSharedPointer<DesignInstantiation> testDesignInstantiation (\r\n        new DesignInstantiation(\"testDesignInstantiation\"));\r\n    testDesignInstantiation->setDesignReference(testDesignReference);\r\n\r\n    QString expectedOutput(\r\n        \"<ipxact:designInstantiation>\"\r\n            \"<ipxact:name>testDesignInstantiation</ipxact:name>\"\r\n            \"<ipxact:designRef vendor=\\\"TUT\\\" library=\\\"TestLibrary\\\" name=\\\"designReference\\\" version=\\\"1.0\\\">\"\r\n                \"<ipxact:configurableElementValues>\"\r\n                    \"<ipxact:configurableElementValue referenceId=\\\"refID\\\">20</ipxact:configurableElementValue>\"\r\n                \"</ipxact:configurableElementValues>\"\r\n            \"</ipxact:designRef>\"\r\n        \"</ipxact:designInstantiation>\"\r\n        );\r\n\r\n    InstantiationsWriter::writeDesignInstantiation(xmlStreamWriter, testDesignInstantiation, Document::Revision::Std14);\r\n    QCOMPARE(output, expectedOutput);\r\n\r\n    output.clear();\r\n    expectedOutput.clear();\r\n\r\n    testDesignInstantiation->setDisplayName(\"display\");\r\n    expectedOutput = \r\n        \"<ipxact:designInstantiation>\"\r\n            \"<ipxact:name>testDesignInstantiation</ipxact:name>\"\r\n            \"<ipxact:displayName>display</ipxact:displayName>\"\r\n            \"<ipxact:designRef vendor=\\\"TUT\\\" library=\\\"TestLibrary\\\" name=\\\"designReference\\\" version=\\\"1.0\\\">\"\r\n                \"<ipxact:configurableElementValues>\"\r\n                    \"<ipxact:configurableElementValue referenceId=\\\"refID\\\">20</ipxact:configurableElementValue>\"\r\n                \"</ipxact:configurableElementValues>\"\r\n            \"</ipxact:designRef>\"\r\n        \"</ipxact:designInstantiation>\"\r\n        ;\r\n\r\n    InstantiationsWriter::writeDesignInstantiation(xmlStreamWriter, testDesignInstantiation, Document::Revision::Std14);\r\n    QCOMPARE(output, expectedOutput);\r\n\r\n    output.clear();\r\n    expectedOutput.clear();\r\n\r\n    testDesignInstantiation->setDescription(\"described\");\r\n    expectedOutput =\r\n        \"<ipxact:designInstantiation>\"\r\n            \"<ipxact:name>testDesignInstantiation</ipxact:name>\"\r\n            \"<ipxact:displayName>display</ipxact:displayName>\"\r\n            \"<ipxact:description>described</ipxact:description>\"\r\n            \"<ipxact:designRef vendor=\\\"TUT\\\" library=\\\"TestLibrary\\\" name=\\\"designReference\\\" version=\\\"1.0\\\">\"\r\n                \"<ipxact:configurableElementValues>\"\r\n                    \"<ipxact:configurableElementValue referenceId=\\\"refID\\\">20</ipxact:configurableElementValue>\"\r\n                \"</ipxact:configurableElementValues>\"\r\n            \"</ipxact:designRef>\"\r\n        \"</ipxact:designInstantiation>\"\r\n        ;\r\n\r\n    InstantiationsWriter::writeDesignInstantiation(xmlStreamWriter, testDesignInstantiation, Document::Revision::Std14);\r\n    QCOMPARE(output, expectedOutput);\r\n\r\n    output.clear();\r\n    expectedOutput.clear();\r\n\r\n    testDesignInstantiation->setShortDescription(\"short desc\");\r\n    expectedOutput =\r\n        \"<ipxact:designInstantiation>\"\r\n            \"<ipxact:name>testDesignInstantiation</ipxact:name>\"\r\n            \"<ipxact:displayName>display</ipxact:displayName>\"\r\n            \"<ipxact:shortDescription>short desc</ipxact:shortDescription>\"\r\n            \"<ipxact:description>described</ipxact:description>\"\r\n            \"<ipxact:designRef vendor=\\\"TUT\\\" library=\\\"TestLibrary\\\" name=\\\"designReference\\\" version=\\\"1.0\\\">\"\r\n                \"<ipxact:configurableElementValues>\"\r\n                    \"<ipxact:configurableElementValue referenceId=\\\"refID\\\">20</ipxact:configurableElementValue>\"\r\n                \"</ipxact:configurableElementValues>\"\r\n            \"</ipxact:designRef>\"\r\n        \"</ipxact:designInstantiation>\"\r\n        ;\r\n\r\n    InstantiationsWriter::writeDesignInstantiation(xmlStreamWriter, testDesignInstantiation, Document::Revision::Std22);\r\n    QCOMPARE(output, expectedOutput);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_InstantiationsWriter::writeDesignInstantiationExtensions()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_InstantiationsWriter::writeDesignInstantiationExtensions()\r\n{\r\n    QString output;\r\n    QXmlStreamWriter xmlStreamWriter(&output);\r\n\r\n    QDomDocument document;\r\n    QDomElement extensionNode = document.createElement(\"testExtension\");\r\n    extensionNode.setAttribute(\"testExtensionAttribute\", \"extension\");\r\n    extensionNode.appendChild(document.createTextNode(\"testValue\"));\r\n\r\n    QSharedPointer<GenericVendorExtension> testExtensions(new GenericVendorExtension(extensionNode));\r\n\r\n    QSharedPointer<ConfigurableVLNVReference> testDesignReference (\r\n        new ConfigurableVLNVReference(VLNV::DESIGN, \"TUT\", \"TestLibrary\", \"designReference\", \"1.0\"));\r\n\r\n    QSharedPointer<ConfigurableElementValue> designReferenceConfig (new ConfigurableElementValue(\"20\", \"refID\"));\r\n    testDesignReference->getConfigurableElementValues()->append(designReferenceConfig);\r\n\r\n    QSharedPointer<DesignInstantiation> testDesignInstantiation (\r\n        new DesignInstantiation(\"testDesignInstantiation\"));\r\n    testDesignInstantiation->setDesignReference(testDesignReference);\r\n    testDesignInstantiation->getVendorExtensions()->append(testExtensions);\r\n\r\n    QString expectedOutput(\r\n        \"<ipxact:designInstantiation>\"\r\n            \"<ipxact:name>testDesignInstantiation</ipxact:name>\"\r\n            \"<ipxact:designRef vendor=\\\"TUT\\\" library=\\\"TestLibrary\\\" name=\\\"designReference\\\" version=\\\"1.0\\\">\"\r\n                \"<ipxact:configurableElementValues>\"\r\n                    \"<ipxact:configurableElementValue referenceId=\\\"refID\\\">20</ipxact:configurableElementValue>\"\r\n                \"</ipxact:configurableElementValues>\"\r\n            \"</ipxact:designRef>\"\r\n            \"<ipxact:vendorExtensions>\"\r\n                \"<testExtension testExtensionAttribute=\\\"extension\\\">testValue</testExtension>\"\r\n            \"</ipxact:vendorExtensions>\"\r\n        \"</ipxact:designInstantiation>\"\r\n        );\r\n\r\n    InstantiationsWriter::writeDesignInstantiation(xmlStreamWriter, testDesignInstantiation, Document::Revision::Std14);\r\n    QCOMPARE(output, expectedOutput);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_InstantiationsWriter::writeDesignConfigurationInstantiation()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_InstantiationsWriter::writeDesignConfigurationInstantiation()\r\n{\r\n    QString output;\r\n    QXmlStreamWriter xmlStreamWriter(&output);\r\n\r\n    QSharedPointer<ConfigurableVLNVReference> testDesignConfiguration (\r\n        new ConfigurableVLNVReference(VLNV::DESIGN, \"TUT\", \"TestLibrary\", \"designConfiguration\", \"1.1\"));\r\n\r\n    QSharedPointer<ConfigurableElementValue> configurableElement (new ConfigurableElementValue(\"4+4\", \"reference\"));\r\n    testDesignConfiguration->getConfigurableElementValues()->append(configurableElement);\r\n\r\n    QSharedPointer<DesignConfigurationInstantiation> testDesignConfigurationInstantiation\r\n        (new DesignConfigurationInstantiation(\"testInstantiation\"));\r\n    testDesignConfigurationInstantiation->setDesignConfigurationReference(testDesignConfiguration);\r\n\r\n    QString expectedOutput(\r\n        \"<ipxact:designConfigurationInstantiation>\"\r\n            \"<ipxact:name>testInstantiation</ipxact:name>\"\r\n            \"<ipxact:designConfigurationRef vendor=\\\"TUT\\\" library=\\\"TestLibrary\\\"\"\r\n                    \" name=\\\"designConfiguration\\\" version=\\\"1.1\\\">\"\r\n                \"<ipxact:configurableElementValues>\"\r\n                    \"<ipxact:configurableElementValue referenceId=\\\"reference\\\">4+4</ipxact:configurableElementValue>\"\r\n                \"</ipxact:configurableElementValues>\"\r\n            \"</ipxact:designConfigurationRef>\"\r\n        \"</ipxact:designConfigurationInstantiation>\"\r\n        );\r\n\r\n    InstantiationsWriter::writeDesignConfigurationInstantiation(xmlStreamWriter,\r\n        testDesignConfigurationInstantiation, Document::Revision::Std14);\r\n    QCOMPARE(output, expectedOutput);\r\n\r\n    output.clear();\r\n    expectedOutput.clear();\r\n\r\n    testDesignConfigurationInstantiation->setDisplayName(\"display\");\r\n    expectedOutput = \r\n        \"<ipxact:designConfigurationInstantiation>\"\r\n            \"<ipxact:name>testInstantiation</ipxact:name>\"\r\n            \"<ipxact:displayName>display</ipxact:displayName>\"\r\n            \"<ipxact:designConfigurationRef vendor=\\\"TUT\\\" library=\\\"TestLibrary\\\"\"\r\n                    \" name=\\\"designConfiguration\\\" version=\\\"1.1\\\">\"\r\n                \"<ipxact:configurableElementValues>\"\r\n                    \"<ipxact:configurableElementValue referenceId=\\\"reference\\\">4+4</ipxact:configurableElementValue>\"\r\n                \"</ipxact:configurableElementValues>\"\r\n            \"</ipxact:designConfigurationRef>\"\r\n        \"</ipxact:designConfigurationInstantiation>\"\r\n        ;\r\n\r\n    InstantiationsWriter::writeDesignConfigurationInstantiation(xmlStreamWriter,\r\n        testDesignConfigurationInstantiation, Document::Revision::Std14);\r\n    QCOMPARE(output, expectedOutput);\r\n\r\n    output.clear();\r\n    expectedOutput.clear();\r\n\r\n    testDesignConfigurationInstantiation->setDescription(\"described\");\r\n    expectedOutput =\r\n        \"<ipxact:designConfigurationInstantiation>\"\r\n            \"<ipxact:name>testInstantiation</ipxact:name>\"\r\n            \"<ipxact:displayName>display</ipxact:displayName>\"\r\n            \"<ipxact:description>described</ipxact:description>\"\r\n            \"<ipxact:designConfigurationRef vendor=\\\"TUT\\\" library=\\\"TestLibrary\\\"\"\r\n                    \" name=\\\"designConfiguration\\\" version=\\\"1.1\\\">\"\r\n                \"<ipxact:configurableElementValues>\"\r\n                    \"<ipxact:configurableElementValue referenceId=\\\"reference\\\">4+4</ipxact:configurableElementValue>\"\r\n                \"</ipxact:configurableElementValues>\"\r\n            \"</ipxact:designConfigurationRef>\"\r\n        \"</ipxact:designConfigurationInstantiation>\"\r\n        ;\r\n\r\n    InstantiationsWriter::writeDesignConfigurationInstantiation(xmlStreamWriter,\r\n        testDesignConfigurationInstantiation, Document::Revision::Std14);\r\n    QCOMPARE(output, expectedOutput);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_InstantiationsWriter::writeDesignConfigurationInstantiationLanguage()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_InstantiationsWriter::writeDesignConfigurationInstantiationLanguage()\r\n{\r\n    QString output;\r\n    QXmlStreamWriter xmlStreamWriter(&output);\r\n\r\n    QSharedPointer<ConfigurableVLNVReference> testDesignConfiguration (\r\n        new ConfigurableVLNVReference(VLNV::DESIGN, \"TUT\", \"TestLibrary\", \"designConfiguration\", \"1.1\"));\r\n\r\n    QSharedPointer<ConfigurableElementValue> configurableElement (new ConfigurableElementValue(\"4+4\", \"reference\"));\r\n    testDesignConfiguration->getConfigurableElementValues()->append(configurableElement);\r\n\r\n    QSharedPointer<DesignConfigurationInstantiation> testDesignConfigurationInstantiation\r\n        (new DesignConfigurationInstantiation(\"testInstantiation\"));\r\n    testDesignConfigurationInstantiation->setDesignConfigurationReference(testDesignConfiguration);\r\n    testDesignConfigurationInstantiation->setLanguage(\"vhdl\");\r\n\r\n    QString expectedOutput(\r\n        \"<ipxact:designConfigurationInstantiation>\"\r\n            \"<ipxact:name>testInstantiation</ipxact:name>\"\r\n            \"<ipxact:language>vhdl</ipxact:language>\"\r\n            \"<ipxact:designConfigurationRef vendor=\\\"TUT\\\" library=\\\"TestLibrary\\\"\"\r\n                    \" name=\\\"designConfiguration\\\" version=\\\"1.1\\\">\"\r\n                \"<ipxact:configurableElementValues>\"\r\n                    \"<ipxact:configurableElementValue referenceId=\\\"reference\\\">4+4</ipxact:configurableElementValue>\"\r\n                \"</ipxact:configurableElementValues>\"\r\n            \"</ipxact:designConfigurationRef>\"\r\n        \"</ipxact:designConfigurationInstantiation>\"\r\n        );\r\n\r\n    InstantiationsWriter::writeDesignConfigurationInstantiation(xmlStreamWriter,\r\n        testDesignConfigurationInstantiation, Document::Revision::Std14);\r\n    QCOMPARE(output, expectedOutput);\r\n\r\n    output.clear();\r\n    expectedOutput.clear();\r\n\r\n    testDesignConfigurationInstantiation->setLanguageStrict(true);\r\n    expectedOutput =\r\n        \"<ipxact:designConfigurationInstantiation>\"\r\n            \"<ipxact:name>testInstantiation</ipxact:name>\"\r\n            \"<ipxact:language strict=\\\"true\\\">vhdl</ipxact:language>\"\r\n            \"<ipxact:designConfigurationRef vendor=\\\"TUT\\\" library=\\\"TestLibrary\\\"\"\r\n                    \" name=\\\"designConfiguration\\\" version=\\\"1.1\\\">\"\r\n                \"<ipxact:configurableElementValues>\"\r\n                    \"<ipxact:configurableElementValue referenceId=\\\"reference\\\">4+4</ipxact:configurableElementValue>\"\r\n                \"</ipxact:configurableElementValues>\"\r\n            \"</ipxact:designConfigurationRef>\"\r\n        \"</ipxact:designConfigurationInstantiation>\"\r\n        ;\r\n\r\n    InstantiationsWriter::writeDesignConfigurationInstantiation(xmlStreamWriter,\r\n        testDesignConfigurationInstantiation, Document::Revision::Std14);\r\n    QCOMPARE(output, expectedOutput);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_InstantiationsWriter::writeDesignConfigurationInstantiationParameters()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_InstantiationsWriter::writeDesignConfigurationInstantiationParameters()\r\n{\r\n    QString output;\r\n    QXmlStreamWriter xmlStreamWriter(&output);\r\n\r\n    QSharedPointer<ConfigurableVLNVReference> testDesignConfiguration (\r\n        new ConfigurableVLNVReference(VLNV::DESIGN, \"TUT\", \"TestLibrary\", \"designConfiguration\", \"1.1\"));\r\n\r\n    QSharedPointer<ConfigurableElementValue> configurableElement (new ConfigurableElementValue(\"4+4\", \"reference\"));\r\n    testDesignConfiguration->getConfigurableElementValues()->append(configurableElement);\r\n\r\n    QSharedPointer<DesignConfigurationInstantiation> testDesignConfigurationInstantiation\r\n        (new DesignConfigurationInstantiation(\"testInstantiation\"));\r\n    testDesignConfigurationInstantiation->setDesignConfigurationReference(testDesignConfiguration);\r\n\r\n    QSharedPointer<Parameter> testParameter(new Parameter());\r\n    testParameter->setValueId(\"testID\");\r\n    testParameter->setName(\"nameTest\");\r\n    testParameter->setValue(\"400\");\r\n\r\n    QSharedPointer<Parameter> otherParameter(new Parameter());\r\n    otherParameter->setValueId(\"otherID\");\r\n    otherParameter->setName(\"otherTest\");\r\n    otherParameter->setValue(\"200\");\r\n\r\n    testDesignConfigurationInstantiation->getParameters()->append(testParameter);\r\n    testDesignConfigurationInstantiation->getParameters()->append(otherParameter);\r\n\r\n    QString expectedOutput(\r\n        \"<ipxact:designConfigurationInstantiation>\"\r\n            \"<ipxact:name>testInstantiation</ipxact:name>\"\r\n            \"<ipxact:designConfigurationRef vendor=\\\"TUT\\\" library=\\\"TestLibrary\\\"\"\r\n                    \" name=\\\"designConfiguration\\\" version=\\\"1.1\\\">\"\r\n                \"<ipxact:configurableElementValues>\"\r\n                    \"<ipxact:configurableElementValue referenceId=\\\"reference\\\">4+4</ipxact:configurableElementValue>\"\r\n                \"</ipxact:configurableElementValues>\"\r\n            \"</ipxact:designConfigurationRef>\"\r\n            \"<ipxact:parameters>\"\r\n                \"<ipxact:parameter parameterId=\\\"testID\\\">\"\r\n                    \"<ipxact:name>nameTest</ipxact:name>\"\r\n                    \"<ipxact:value>400</ipxact:value>\"\r\n                \"</ipxact:parameter>\"\r\n                \"<ipxact:parameter parameterId=\\\"otherID\\\">\"\r\n                    \"<ipxact:name>otherTest</ipxact:name>\"\r\n                    \"<ipxact:value>200</ipxact:value>\"\r\n                \"</ipxact:parameter>\"\r\n            \"</ipxact:parameters>\"\r\n        \"</ipxact:designConfigurationInstantiation>\"\r\n        );\r\n\r\n    InstantiationsWriter::writeDesignConfigurationInstantiation(xmlStreamWriter,\r\n        testDesignConfigurationInstantiation, Document::Revision::Std14);\r\n    QCOMPARE(output, expectedOutput);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_InstantiationsWriter::writeDesignConfigurationInstantiationExtensions()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_InstantiationsWriter::writeDesignConfigurationInstantiationExtensions()\r\n{\r\n    QString output;\r\n    QXmlStreamWriter xmlStreamWriter(&output);\r\n\r\n    QSharedPointer<ConfigurableVLNVReference> testDesignConfiguration (\r\n        new ConfigurableVLNVReference(VLNV::DESIGN, \"TUT\", \"TestLibrary\", \"designConfiguration\", \"1.1\"));\r\n\r\n    QSharedPointer<ConfigurableElementValue> configurableElement (new ConfigurableElementValue(\"4+4\", \"reference\"));\r\n    testDesignConfiguration->getConfigurableElementValues()->append(configurableElement);\r\n\r\n    QSharedPointer<DesignConfigurationInstantiation> testDesignConfigurationInstantiation\r\n        (new DesignConfigurationInstantiation(\"testInstantiation\"));\r\n    testDesignConfigurationInstantiation->setDesignConfigurationReference(testDesignConfiguration);\r\n\r\n    QDomDocument document;\r\n    QDomElement extensionNode = document.createElement(\"testExtension\");\r\n    extensionNode.setAttribute(\"testExtensionAttribute\", \"extension\");\r\n    extensionNode.appendChild(document.createTextNode(\"testValue\"));\r\n\r\n    QSharedPointer<GenericVendorExtension> testExtensions(new GenericVendorExtension(extensionNode));\r\n    testDesignConfigurationInstantiation->getVendorExtensions()->append(testExtensions);\r\n\r\n    QString expectedOutput(\r\n        \"<ipxact:designConfigurationInstantiation>\"\r\n            \"<ipxact:name>testInstantiation</ipxact:name>\"\r\n            \"<ipxact:designConfigurationRef vendor=\\\"TUT\\\" library=\\\"TestLibrary\\\"\"\r\n                    \" name=\\\"designConfiguration\\\" version=\\\"1.1\\\">\"\r\n                \"<ipxact:configurableElementValues>\"\r\n                    \"<ipxact:configurableElementValue referenceId=\\\"reference\\\">4+4</ipxact:configurableElementValue>\"\r\n                \"</ipxact:configurableElementValues>\"\r\n            \"</ipxact:designConfigurationRef>\"\r\n            \"<ipxact:vendorExtensions>\"\r\n                \"<testExtension testExtensionAttribute=\\\"extension\\\">testValue</testExtension>\"\r\n            \"</ipxact:vendorExtensions>\"\r\n        \"</ipxact:designConfigurationInstantiation>\"\r\n        );\r\n\r\n    InstantiationsWriter::writeDesignConfigurationInstantiation(xmlStreamWriter,\r\n        testDesignConfigurationInstantiation, Document::Revision::Std14);\r\n    QCOMPARE(output, expectedOutput);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_InstantiationsWriter::writeComponentInstantiation()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_InstantiationsWriter::writeComponentInstantiation()\r\n{\r\n    QString output;\r\n    QXmlStreamWriter xmlStreamWriter(&output);\r\n\r\n    QSharedPointer<ComponentInstantiation> testComponentInstantiation (\r\n        new ComponentInstantiation(\"testComponentInstantiation\"));\r\n\r\n    QString expectedOutput(\r\n        \"<ipxact:componentInstantiation>\"\r\n            \"<ipxact:name>testComponentInstantiation</ipxact:name>\"\r\n        \"</ipxact:componentInstantiation>\"\r\n        );\r\n\r\n    InstantiationsWriter::writeComponentInstantiation(xmlStreamWriter, testComponentInstantiation, Document::Revision::Std14);\r\n    QCOMPARE(output, expectedOutput);\r\n\r\n    output.clear();\r\n    expectedOutput.clear();\r\n\r\n    testComponentInstantiation->setDisplayName(\"display\");\r\n    expectedOutput = \r\n        \"<ipxact:componentInstantiation>\"\r\n            \"<ipxact:name>testComponentInstantiation</ipxact:name>\"\r\n            \"<ipxact:displayName>display</ipxact:displayName>\"\r\n        \"</ipxact:componentInstantiation>\"\r\n        ;\r\n\r\n    InstantiationsWriter::writeComponentInstantiation(xmlStreamWriter, testComponentInstantiation, Document::Revision::Std14);\r\n    QCOMPARE(output, expectedOutput);\r\n\r\n    output.clear();\r\n    expectedOutput.clear();\r\n\r\n    testComponentInstantiation->setDescription(\"described\");\r\n    expectedOutput =\r\n        \"<ipxact:componentInstantiation>\"\r\n            \"<ipxact:name>testComponentInstantiation</ipxact:name>\"\r\n            \"<ipxact:displayName>display</ipxact:displayName>\"\r\n            \"<ipxact:description>described</ipxact:description>\"\r\n        \"</ipxact:componentInstantiation>\"\r\n        ;\r\n\r\n    InstantiationsWriter::writeComponentInstantiation(xmlStreamWriter, testComponentInstantiation, Document::Revision::Std14);\r\n    QCOMPARE(output, expectedOutput);\r\n\r\n    output.clear();\r\n    expectedOutput.clear();\r\n\r\n    testComponentInstantiation->setShortDescription(\"short desc\");\r\n    expectedOutput =\r\n        \"<ipxact:componentInstantiation>\"\r\n        \"<ipxact:name>testComponentInstantiation</ipxact:name>\"\r\n        \"<ipxact:displayName>display</ipxact:displayName>\"\r\n        \"<ipxact:shortDescription>short desc</ipxact:shortDescription>\"\r\n        \"<ipxact:description>described</ipxact:description>\"\r\n        \"</ipxact:componentInstantiation>\"\r\n        ;\r\n\r\n    InstantiationsWriter::writeComponentInstantiation(xmlStreamWriter, testComponentInstantiation, Document::Revision::Std22);\r\n    QCOMPARE(output, expectedOutput);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_InstantiationsWriter::writeVirtualComponentInstantiation()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_InstantiationsWriter::writeVirtualComponentInstantiation()\r\n{\r\n    QString output;\r\n    QXmlStreamWriter xmlStreamWriter(&output);\r\n\r\n    QSharedPointer<ComponentInstantiation> testComponentInstantiation (\r\n        new ComponentInstantiation(\"testComponentInstantiation\"));\r\n    testComponentInstantiation->setVirtual(true);\r\n\r\n    QString expectedOutput(\r\n        \"<ipxact:componentInstantiation>\"\r\n            \"<ipxact:name>testComponentInstantiation</ipxact:name>\"\r\n            \"<ipxact:isVirtual>true</ipxact:isVirtual>\"\r\n        \"</ipxact:componentInstantiation>\"\r\n        );\r\n\r\n    InstantiationsWriter::writeComponentInstantiation(xmlStreamWriter, testComponentInstantiation, Document::Revision::Std14);\r\n    QCOMPARE(output, expectedOutput);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_InstantiationsWriter::writeComponentInstantiationLanguage()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_InstantiationsWriter::writeComponentInstantiationLanguage()\r\n{\r\n    QString output;\r\n    QXmlStreamWriter xmlStreamWriter(&output);\r\n\r\n    QSharedPointer<ComponentInstantiation> testComponentInstantiation (\r\n        new ComponentInstantiation(\"testComponentInstantiation\"));\r\n    testComponentInstantiation->setLanguage(\"verilog\");\r\n\r\n    QString expectedOutput(\r\n        \"<ipxact:componentInstantiation>\"\r\n            \"<ipxact:name>testComponentInstantiation</ipxact:name>\"\r\n            \"<ipxact:language>verilog</ipxact:language>\"\r\n        \"</ipxact:componentInstantiation>\"\r\n        );\r\n\r\n    InstantiationsWriter::writeComponentInstantiation(xmlStreamWriter, testComponentInstantiation, Document::Revision::Std14);\r\n    QCOMPARE(output, expectedOutput);\r\n\r\n    output.clear();\r\n    expectedOutput.clear();\r\n\r\n    testComponentInstantiation->setLanguage(\"vhdl\");\r\n    testComponentInstantiation->setLanguageStrictness(true);\r\n    expectedOutput = \r\n        \"<ipxact:componentInstantiation>\"\r\n            \"<ipxact:name>testComponentInstantiation</ipxact:name>\"\r\n            \"<ipxact:language strict=\\\"true\\\">vhdl</ipxact:language>\"\r\n        \"</ipxact:componentInstantiation>\"\r\n        ;\r\n\r\n    InstantiationsWriter::writeComponentInstantiation(xmlStreamWriter, testComponentInstantiation, Document::Revision::Std14);\r\n    QCOMPARE(output, expectedOutput);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_InstantiationsWriter::writeComponentInstantiationNameReferences()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_InstantiationsWriter::writeComponentInstantiationNameReferences()\r\n{\r\n    QString output;\r\n    QXmlStreamWriter xmlStreamWriter(&output);\r\n\r\n    QSharedPointer<ComponentInstantiation> testComponentInstantiation (\r\n        new ComponentInstantiation(\"testComponentInstantiation\"));\r\n    testComponentInstantiation->setLibraryName(\"work\");\r\n    testComponentInstantiation->setPackageName(\"componentVLNV_cmp_pkg\");\r\n    testComponentInstantiation->setModuleName(\"componentVLNV\");\r\n    testComponentInstantiation->setArchitectureName(\"rtl\");\r\n    testComponentInstantiation->setConfigurationName(\"componentVLNV_rtl_cfg\");\r\n\r\n    QString expectedOutput(\r\n        \"<ipxact:componentInstantiation>\"\r\n            \"<ipxact:name>testComponentInstantiation</ipxact:name>\"\r\n            \"<ipxact:libraryName>work</ipxact:libraryName>\"\r\n            \"<ipxact:packageName>componentVLNV_cmp_pkg</ipxact:packageName>\"\r\n            \"<ipxact:moduleName>componentVLNV</ipxact:moduleName>\"\r\n            \"<ipxact:architectureName>rtl</ipxact:architectureName>\"\r\n            \"<ipxact:configurationName>componentVLNV_rtl_cfg</ipxact:configurationName>\"\r\n        \"</ipxact:componentInstantiation>\"\r\n        );\r\n\r\n    InstantiationsWriter::writeComponentInstantiation(xmlStreamWriter, testComponentInstantiation, Document::Revision::Std14);\r\n    QCOMPARE(output, expectedOutput);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_InstantiationsWriter::writeComponentInstantiationModuleParameters()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_InstantiationsWriter::writeComponentInstantiationModuleParameters()\r\n{\r\n    QString output;\r\n    QXmlStreamWriter xmlStreamWriter(&output);\r\n\r\n    QSharedPointer<ComponentInstantiation> testComponentInstantiation\r\n        (new ComponentInstantiation(\"testInstantiation\"));\r\n\r\n    QSharedPointer<ModuleParameter> testModuleParameter(new ModuleParameter());\r\n    testModuleParameter->setValueId(\"testID\");\r\n    testModuleParameter->setChoiceRef(\"testingChoice\");\r\n    testModuleParameter->setMinimumValue(\"3\");\r\n    testModuleParameter->setMaximumValue(\"403\");\r\n    testModuleParameter->setName(\"nameTest\");\r\n    testModuleParameter->setValue(\"400\");\r\n    testModuleParameter->setIsPresent(\"4-3\");\r\n    testModuleParameter->setUsageType(\"int\");\r\n    testModuleParameter->setDataType(\"longInt\");\r\n\r\n    testComponentInstantiation->getModuleParameters()->append(testModuleParameter);\r\n\r\n    QString expectedOutput(\r\n        \"<ipxact:componentInstantiation>\"\r\n            \"<ipxact:name>testInstantiation</ipxact:name>\"\r\n            \"<ipxact:moduleParameters>\"\r\n                \"<ipxact:moduleParameter choiceRef=\\\"testingChoice\\\" dataType=\\\"longInt\\\" maximum=\\\"403\\\"\"\r\n                        \" minimum=\\\"3\\\" parameterId=\\\"testID\\\" usageType=\\\"int\\\">\"\r\n                    \"<ipxact:name>nameTest</ipxact:name>\"\r\n                    \"<ipxact:value>400</ipxact:value>\"\r\n                    \"<ipxact:isPresent>4-3</ipxact:isPresent>\"\r\n                \"</ipxact:moduleParameter>\"\r\n            \"</ipxact:moduleParameters>\"\r\n        \"</ipxact:componentInstantiation>\"\r\n        );\r\n\r\n    InstantiationsWriter::writeComponentInstantiation(xmlStreamWriter, testComponentInstantiation, Document::Revision::Std14);\r\n    QCOMPARE(output, expectedOutput);\r\n}\r\n\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_InstantiationsWriter::writeComponentInstantiationModuleParameters2022()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_InstantiationsWriter::writeComponentInstantiationModuleParameters2022()\r\n{\r\n    QString output;\r\n    QXmlStreamWriter xmlStreamWriter(&output);\r\n\r\n    QSharedPointer<ComponentInstantiation> testComponentInstantiation\r\n        (new ComponentInstantiation(\"testInstantiation\"));\r\n\r\n    QSharedPointer<ModuleParameter> testModuleParameter(new ModuleParameter());\r\n    testModuleParameter->setValueId(\"testID\");\r\n    testModuleParameter->setChoiceRef(\"testingChoice\");\r\n    testModuleParameter->setMinimumValue(\"3\");\r\n    testModuleParameter->setMaximumValue(\"403\");\r\n    testModuleParameter->setName(\"nameTest\");\r\n    testModuleParameter->setValue(\"400\");\r\n    testModuleParameter->setUsageType(\"int\");\r\n    testModuleParameter->setDataType(\"longInt\");\r\n\r\n    QSharedPointer<Vector> testVector(new Vector(\"0\", \"4\"));\r\n    testVector->setId(\"testVector\");\r\n\r\n    QSharedPointer<Array> testArray(new Array(\"0\", \"4\"));\r\n    testArray->setId(\"testArray\");\r\n\r\n    testModuleParameter->getArrays()->append(testArray);\r\n    testModuleParameter->getVectors()->append(testVector);\r\n\r\n    testComponentInstantiation->getModuleParameters()->append(testModuleParameter);\r\n\r\n    QString expectedOutput(\r\n        \"<ipxact:componentInstantiation>\"\r\n            \"<ipxact:name>testInstantiation</ipxact:name>\"\r\n            \"<ipxact:moduleParameters>\"\r\n                \"<ipxact:moduleParameter choiceRef=\\\"testingChoice\\\" dataType=\\\"longInt\\\" maximum=\\\"403\\\"\"\r\n                        \" minimum=\\\"3\\\" parameterId=\\\"testID\\\" usageType=\\\"int\\\">\"\r\n                    \"<ipxact:name>nameTest</ipxact:name>\"\r\n                    \"<ipxact:vectors>\"\r\n                        \"<ipxact:vector vectorId=\\\"testVector\\\">\"\r\n                            \"<ipxact:left>0</ipxact:left>\"\r\n                            \"<ipxact:right>4</ipxact:right>\"\r\n                        \"</ipxact:vector>\"\r\n                    \"</ipxact:vectors>\"\r\n                    \"<ipxact:arrays>\"\r\n                        \"<ipxact:array arrayId=\\\"testArray\\\">\"\r\n                            \"<ipxact:left>0</ipxact:left>\"\r\n                            \"<ipxact:right>4</ipxact:right>\"\r\n                        \"</ipxact:array>\"\r\n                    \"</ipxact:arrays>\"\r\n                    \"<ipxact:value>400</ipxact:value>\"\r\n                \"</ipxact:moduleParameter>\"\r\n            \"</ipxact:moduleParameters>\"\r\n        \"</ipxact:componentInstantiation>\"\r\n        );\r\n\r\n    InstantiationsWriter::writeComponentInstantiation(xmlStreamWriter, testComponentInstantiation, Document::Revision::Std22);\r\n    QCOMPARE(output, expectedOutput);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_InstantiationsWriter::writeComponentInstantiationDefaultFileBuilders()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_InstantiationsWriter::writeComponentInstantiationDefaultFileBuilders()\r\n{\r\n    QString output;\r\n    QXmlStreamWriter xmlStreamWriter(&output);\r\n\r\n    QSharedPointer<ComponentInstantiation> testComponentInstantiation\r\n        (new ComponentInstantiation(\"testInstantiation\"));\r\n\r\n    QSharedPointer<FileBuilder> defaultFileBuilder (new FileBuilder);\r\n    defaultFileBuilder->setCommand(\"riseFromYourGrave\");\r\n    defaultFileBuilder->setFlags(\"passedFlags\");\r\n    defaultFileBuilder->setReplaceDefaultFlags(\"1-1+0\");\r\n    defaultFileBuilder->setFileType(\"asmSource\");\r\n\r\n    testComponentInstantiation->getDefaultFileBuilders()->append(defaultFileBuilder);\r\n\r\n    QString expectedOutput(\r\n        \"<ipxact:componentInstantiation>\"\r\n            \"<ipxact:name>testInstantiation</ipxact:name>\"\r\n            \"<ipxact:defaultFileBuilder>\"\r\n                \"<ipxact:fileType>asmSource</ipxact:fileType>\"\r\n                \"<ipxact:command>riseFromYourGrave</ipxact:command>\"\r\n                \"<ipxact:flags>passedFlags</ipxact:flags>\"\r\n                \"<ipxact:replaceDefaultFlags>1-1+0</ipxact:replaceDefaultFlags>\"\r\n            \"</ipxact:defaultFileBuilder>\"\r\n        \"</ipxact:componentInstantiation>\"\r\n        );\r\n\r\n    InstantiationsWriter::writeComponentInstantiation(xmlStreamWriter, testComponentInstantiation, Document::Revision::Std14);\r\n    QCOMPARE(output, expectedOutput);\r\n\r\n    output.clear();\r\n    expectedOutput.clear();\r\n\r\n    defaultFileBuilder->setFileType(\"userFile\");\r\n    expectedOutput =\r\n        \"<ipxact:componentInstantiation>\"\r\n            \"<ipxact:name>testInstantiation</ipxact:name>\"\r\n            \"<ipxact:defaultFileBuilder>\"\r\n                \"<ipxact:fileType user=\\\"userFile\\\">user</ipxact:fileType>\"\r\n                \"<ipxact:command>riseFromYourGrave</ipxact:command>\"\r\n                \"<ipxact:flags>passedFlags</ipxact:flags>\"\r\n                \"<ipxact:replaceDefaultFlags>1-1+0</ipxact:replaceDefaultFlags>\"\r\n            \"</ipxact:defaultFileBuilder>\"\r\n        \"</ipxact:componentInstantiation>\"\r\n        ;\r\n\r\n    InstantiationsWriter::writeComponentInstantiation(xmlStreamWriter, testComponentInstantiation, Document::Revision::Std14);\r\n    QCOMPARE(output, expectedOutput);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_InstantiationsWriter::writeComponentInstantiationFileSetReferences()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_InstantiationsWriter::writeComponentInstantiationFileSetReferences()\r\n{\r\n    QString output;\r\n    QXmlStreamWriter xmlStreamWriter(&output);\r\n\r\n    QSharedPointer<ComponentInstantiation> testComponentInstantiation\r\n        (new ComponentInstantiation(\"testInstantiation\"));\r\n\r\n    QSharedPointer<FileSetRef> fileSetRef1(new FileSetRef());\r\n    QSharedPointer<FileSetRef> fileSetRef2(new FileSetRef());\r\n\r\n    fileSetRef1->setReference(\"referencedFile\");\r\n    fileSetRef2->setReference(\"otherFile\");\r\n\r\n    testComponentInstantiation->getFileSetReferences()->append(fileSetRef1);\r\n    testComponentInstantiation->getFileSetReferences()->append(fileSetRef2);\r\n\r\n    QString expectedOutput(\r\n        \"<ipxact:componentInstantiation>\"\r\n            \"<ipxact:name>testInstantiation</ipxact:name>\"\r\n            \"<ipxact:fileSetRef>\"\r\n                \"<ipxact:localName>referencedFile</ipxact:localName>\"\r\n            \"</ipxact:fileSetRef>\"\r\n            \"<ipxact:fileSetRef>\"\r\n                \"<ipxact:localName>otherFile</ipxact:localName>\"\r\n            \"</ipxact:fileSetRef>\"\r\n        \"</ipxact:componentInstantiation>\"\r\n        );\r\n\r\n    InstantiationsWriter::writeComponentInstantiation(xmlStreamWriter, testComponentInstantiation, Document::Revision::Std14);\r\n    QCOMPARE(output, expectedOutput);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_InstantiationsWriter::writeComponentInstantiationParameters()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_InstantiationsWriter::writeComponentInstantiationParameters()\r\n{\r\n    QString output;\r\n    QXmlStreamWriter xmlStreamWriter(&output);\r\n\r\n    QSharedPointer<ComponentInstantiation> testComponentInstantiation\r\n        (new ComponentInstantiation(\"testInstantiation\"));\r\n\r\n    QSharedPointer<Parameter> testParameter(new Parameter());\r\n    testParameter->setValueId(\"testID\");\r\n    testParameter->setName(\"nameTest\");\r\n    testParameter->setValue(\"400\");\r\n\r\n    QSharedPointer<Parameter> otherParameter(new Parameter());\r\n    otherParameter->setValueId(\"otherID\");\r\n    otherParameter->setName(\"otherTest\");\r\n    otherParameter->setValue(\"200\");\r\n\r\n    testComponentInstantiation->getParameters()->append(testParameter);\r\n    testComponentInstantiation->getParameters()->append(otherParameter);\r\n\r\n    QString expectedOutput(\r\n        \"<ipxact:componentInstantiation>\"\r\n            \"<ipxact:name>testInstantiation</ipxact:name>\"\r\n            \"<ipxact:parameters>\"\r\n                \"<ipxact:parameter parameterId=\\\"testID\\\">\"\r\n                    \"<ipxact:name>nameTest</ipxact:name>\"\r\n                    \"<ipxact:value>400</ipxact:value>\"\r\n                \"</ipxact:parameter>\"\r\n                \"<ipxact:parameter parameterId=\\\"otherID\\\">\"\r\n                    \"<ipxact:name>otherTest</ipxact:name>\"\r\n                    \"<ipxact:value>200</ipxact:value>\"\r\n                \"</ipxact:parameter>\"\r\n            \"</ipxact:parameters>\"\r\n        \"</ipxact:componentInstantiation>\"\r\n        );\r\n\r\n    InstantiationsWriter::writeComponentInstantiation(xmlStreamWriter, testComponentInstantiation, Document::Revision::Std14);\r\n    QCOMPARE(output, expectedOutput);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_InstantiationsWriter::writeComponentInstantiationExtensions()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_InstantiationsWriter::writeComponentInstantiationExtensions()\r\n{\r\n    QString output;\r\n    QXmlStreamWriter xmlStreamWriter(&output);\r\n\r\n    QSharedPointer<ComponentInstantiation> testComponentInstantiation\r\n        (new ComponentInstantiation(\"testInstantiation\"));\r\n\r\n    QDomDocument document;\r\n    QDomElement extensionNode = document.createElement(\"testExtension\");\r\n    extensionNode.setAttribute(\"testExtensionAttribute\", \"extension\");\r\n    extensionNode.appendChild(document.createTextNode(\"testValue\"));\r\n\r\n    QSharedPointer<GenericVendorExtension> testExtensions(new GenericVendorExtension(extensionNode));\r\n    testComponentInstantiation->getVendorExtensions()->append(testExtensions);\r\n\r\n    QString expectedOutput(\r\n        \"<ipxact:componentInstantiation>\"\r\n            \"<ipxact:name>testInstantiation</ipxact:name>\"\r\n            \"<ipxact:vendorExtensions>\"\r\n                \"<testExtension testExtensionAttribute=\\\"extension\\\">testValue</testExtension>\"\r\n            \"</ipxact:vendorExtensions>\"\r\n        \"</ipxact:componentInstantiation>\"\r\n        );\r\n\r\n    InstantiationsWriter::writeComponentInstantiation(xmlStreamWriter, testComponentInstantiation, Document::Revision::Std14);\r\n    QCOMPARE(output, expectedOutput);\r\n}\r\n\r\nQTEST_APPLESS_MAIN(tst_InstantiationsWriter)\r\n\r\n#include \"tst_InstantiationsWriter.moc\"\r\n"
  },
  {
    "path": "tests/IPXACTmodels/Component/tst_InstantiationsWriter.pri",
    "content": "# ----------------------------------------------------\r\n# This file is generated by the Qt Visual Studio Tools.\r\n# ------------------------------------------------------\r\n\r\nSOURCES += ./tst_InstantiationsWriter.cpp \r\n"
  },
  {
    "path": "tests/IPXACTmodels/Component/tst_InstantiationsWriter.pro",
    "content": "#-----------------------------------------------------------------------------\r\n# File: tst_InstantiationsWriter.pro\r\n#-----------------------------------------------------------------------------\r\n# Project: Kactus 2\r\n# Author: Mikko Teuho\r\n# Date: 04.09.2015\r\n#\r\n# Description:\r\n# Qt project file template for running unit tests for InstantiationsWriter.\r\n#-----------------------------------------------------------------------------\r\n\r\nTEMPLATE = app\r\n\r\nTARGET = tst_InstantiationsWriter\r\n\r\nQT += core xml testlib\r\nQT -= gui\r\n\r\nCONFIG += c++11 testcase console\r\n\r\nlinux-g++ | linux-g++-64 | linux-g++-32 {\r\n LIBS += -L../../../executable \\\r\n     -lIPXACTmodels\r\n}\r\nwin64 | win32 {\r\n LIBS += -L../../../executable \\\r\n     -lIPXACTmodelsd\r\n}\r\n\r\nINCLUDEPATH += $$DESTDIR\r\nINCLUDEPATH += ../../../\r\n\r\nDEPENDPATH += .\r\nDEPENDPATH += ../../../\r\n\r\nOBJECTS_DIR += $$DESTDIR\r\n\r\nMOC_DIR += ./generatedFiles\r\nUI_DIR += ./generatedFiles\r\nRCC_DIR += ./generatedFiles\r\ninclude(tst_InstantiationsWriter.pri)\r\n"
  },
  {
    "path": "tests/IPXACTmodels/Component/tst_MemoryArrayReader.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: tst_MemoryArrayReader.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Anton Hagqvist\n// Date: 21.07.2023\n//\n// Description:\n// Unit test for class MemoryArrayReader.\n//-----------------------------------------------------------------------------\n\n#include <IPXACTmodels/Component/MemoryArrayReader.h>\n#include <IPXACTmodels/Component/MemoryArray.h>\n\n#include <QDomDocument>\n\n#include <QtTest>\n\nclass tst_MemoryArrayReader : public QObject\n{\n    Q_OBJECT\n\npublic:\n    tst_MemoryArrayReader();\n\nprivate slots:\n\n    void readSingleDimension();\n    void readMultipleDimension();\n    void readStride();\n    void readBitStride();\n};\n\n//-----------------------------------------------------------------------------\n// Function: tst_MemoryArrayReader::tst_MemoryArrayReader()\n//-----------------------------------------------------------------------------\ntst_MemoryArrayReader::tst_MemoryArrayReader()\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_MemoryArrayReader::readSingleDimension()\n//-----------------------------------------------------------------------------\nvoid tst_MemoryArrayReader::readSingleDimension()\n{\n    QString documentContent(\n        \"<ipxact:array>\"\n            \"<ipxact:dim>8</ipxact:dim>\"\n        \"</ipxact:array>\"\n    );\n\n    QDomDocument document;\n    document.setContent(documentContent);\n\n    auto array = MemoryArrayReader::createMemoryArrayFrom(document.firstChildElement(\"ipxact:array\"), Document::Revision::Std22, false);\n\n    QCOMPARE(array->getDimensions()->size(), 1);\n    QCOMPARE(array->getDimensions()->first()->value_, \"8\");\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_MemoryArrayReader::readMultipleDimension()\n//-----------------------------------------------------------------------------\nvoid tst_MemoryArrayReader::readMultipleDimension()\n{\n    QString documentContent(\n        \"<ipxact:array>\"\n            \"<ipxact:dim indexVar=\\\"first\\\">8</ipxact:dim>\"\n            \"<ipxact:dim indexVar=\\\"second\\\">16</ipxact:dim>\"\n        \"</ipxact:array>\"\n    );\n\n    QDomDocument document;\n    document.setContent(documentContent);\n\n    auto array = MemoryArrayReader::createMemoryArrayFrom(document.firstChildElement(\"ipxact:array\"), Document::Revision::Std22, false);\n\n    auto dimensions = array->getDimensions();\n\n    QCOMPARE(dimensions->size(), 2);\n    QCOMPARE(dimensions->first()->value_, \"8\");\n    QCOMPARE(dimensions->first()->indexVar_, \"first\");\n    QCOMPARE(dimensions->last()->value_, \"16\");\n    QCOMPARE(dimensions->last()->indexVar_, \"second\");\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_MemoryArrayReader::readStride()\n//-----------------------------------------------------------------------------\nvoid tst_MemoryArrayReader::readStride()\n{\n    QString documentContent(\n        \"<ipxact:array>\"\n            \"<ipxact:dim>8</ipxact:dim>\"\n            \"<ipxact:stride>16</ipxact:stride>\"\n        \"</ipxact:array>\"\n    );\n\n    QDomDocument document;\n    document.setContent(documentContent);\n\n    auto array = MemoryArrayReader::createMemoryArrayFrom(document.firstChildElement(\"ipxact:array\"), Document::Revision::Std22, false);\n\n    QCOMPARE(array->getDimensions()->size(), 1);\n    QCOMPARE(array->getDimensions()->first()->value_, \"8\");\n    QCOMPARE(array->getStride(), \"16\");\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_MemoryArrayReader::readBitStride()\n//-----------------------------------------------------------------------------\nvoid tst_MemoryArrayReader::readBitStride()\n{\n    QString documentContent(\n        \"<ipxact:array>\"\n            \"<ipxact:dim>8</ipxact:dim>\"\n            \"<ipxact:bitStride>16</ipxact:bitStride>\"\n        \"</ipxact:array>\"\n    );\n\n    QDomDocument document;\n    document.setContent(documentContent);\n\n    auto array = MemoryArrayReader::createMemoryArrayFrom(document.firstChildElement(\"ipxact:array\"), Document::Revision::Std22, true);\n\n    QCOMPARE(array->getDimensions()->size(), 1);\n    QCOMPARE(array->getDimensions()->first()->value_, \"8\");\n    QCOMPARE(array->getStride(), \"16\");\n}\n\n\nQTEST_APPLESS_MAIN(tst_MemoryArrayReader)\n\n#include \"tst_MemoryArrayReader.moc\"\n"
  },
  {
    "path": "tests/IPXACTmodels/Component/tst_MemoryArrayReader.pri",
    "content": "# ----------------------------------------------------\n# This file is generated by the Qt Visual Studio Tools.\n# ------------------------------------------------------\n\nSOURCES += ./tst_MemoryArrayReader.cpp "
  },
  {
    "path": "tests/IPXACTmodels/Component/tst_MemoryArrayReader.pro",
    "content": "#-----------------------------------------------------------------------------\n# File: tst_MemoryArrayReader.pro\n#-----------------------------------------------------------------------------\n# Project: Kactus 2\n# Author: Anton Hagqvist\n# Date: 21.07.2023\n#\n# Description:\n# Qt project file template for running unit tests for MemoryArrayReader.\n#-----------------------------------------------------------------------------\n\nTEMPLATE = app\n\nTARGET = tst_MemoryArrayReader\n\nQT += core xml testlib\nQT -= gui\n\nCONFIG += c++11 testcase console\n\nlinux-g++ | linux-g++-64 | linux-g++-32 {\n LIBS += -L../../../executable \\\n     -lIPXACTmodels\n\n}\nwin64 | win32 {\n LIBS += -L../../../executable \\\n     -lIPXACTmodelsd\n}\n\nINCLUDEPATH += $$DESTDIR\nINCLUDEPATH += ../../../\n\nDEPENDPATH += .\nDEPENDPATH += ../../../\n\nOBJECTS_DIR += $$DESTDIR\n\nMOC_DIR += ./generatedFiles\nUI_DIR += ./generatedFiles\nRCC_DIR += ./generatedFiles\ninclude(tst_MemoryArrayReader.pri)\n"
  },
  {
    "path": "tests/IPXACTmodels/Component/tst_MemoryArrayValidator.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: tst_MemoryArrayValidator.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Anton Hagqvist\n// Date: 21.07.2023\n//\n// Description:\n// Unit test for class MemoryArrayValidator.\n//-----------------------------------------------------------------------------\n\n#include <IPXACTmodels/Component/validators/MemoryArrayValidator.h>\n#include <IPXACTmodels/Component/MemoryArray.h>\n\n#include <QXmlStreamWriter>\n\n#include <QtTest>\n\nclass tst_MemoryArrayValidator : public QObject\n{\n    Q_OBJECT\n\npublic:\n    tst_MemoryArrayValidator();\n\nprivate slots:\n\n    void init();\n    void cleanup();\n\n    void testArrayHasDimension();\n    void testDimensionAndStrideValue();\n\nprivate:\n    QSharedPointer<MemoryArray> memArray_;\n    QList<QString> errorList_;\n\n    QSharedPointer<SystemVerilogExpressionParser> expressionParser_;\n    QSharedPointer<MemoryArrayValidator> validator_;\n};\n\n//-----------------------------------------------------------------------------\n// Function: tst_MemoryArrayValidator::tst_MemoryArrayValidator()\n//-----------------------------------------------------------------------------\ntst_MemoryArrayValidator::tst_MemoryArrayValidator()\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_MemoryArrayValidator::init()\n//-----------------------------------------------------------------------------\nvoid tst_MemoryArrayValidator::init()\n{\n    memArray_ = QSharedPointer<MemoryArray>(new MemoryArray());\n    expressionParser_ = QSharedPointer<SystemVerilogExpressionParser>(new SystemVerilogExpressionParser());\n    validator_ = QSharedPointer<MemoryArrayValidator>(new MemoryArrayValidator(expressionParser_));\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_MemoryArrayValidator::cleanup()\n//-----------------------------------------------------------------------------\nvoid tst_MemoryArrayValidator::cleanup()\n{\n    memArray_.clear();\n    errorList_.clear();\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_MemoryArrayValidator::testArrayHasDimension()\n//-----------------------------------------------------------------------------\nvoid tst_MemoryArrayValidator::testArrayHasDimension()\n{\n    validator_->findErrorsIn(errorList_, memArray_, \"test\");\n\n    QCOMPARE(errorList_.size(), 1);\n    QVERIFY(!validator_->validate(memArray_));\n\n    errorList_.clear();\n\n    QSharedPointer<MemoryArray::Dimension> dim(new MemoryArray::Dimension);\n    dim->value_ = QString(\"8\");\n\n    memArray_->getDimensions()->append(dim);\n\n    validator_->findErrorsIn(errorList_, memArray_, \"test\");\n\n    QCOMPARE(errorList_.size(), 0);\n    QVERIFY(validator_->validate(memArray_));\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_MemoryArrayValidator::testDimensionAndStrideValue()\n//-----------------------------------------------------------------------------\nvoid tst_MemoryArrayValidator::testDimensionAndStrideValue()\n{\n    QSharedPointer<MemoryArray::Dimension> dim(new MemoryArray::Dimension);\n    dim->value_ = QString(\"invalidValue\");\n\n    memArray_->getDimensions()->append(dim);\n    memArray_->setStride(\"invalid\");\n\n    validator_->findErrorsIn(errorList_, memArray_, \"test\");\n\n    QCOMPARE(errorList_.size(), 2);\n    QVERIFY(!validator_->validate(memArray_));\n\n    errorList_.clear();\n    dim->value_ = QString(\"16\");\n    memArray_->setStride(\"8\");\n\n    QCOMPARE(errorList_.size(), 0);\n    QVERIFY(validator_->validate(memArray_));\n}\n\nQTEST_APPLESS_MAIN(tst_MemoryArrayValidator)\n\n#include \"tst_MemoryArrayValidator.moc\"\n"
  },
  {
    "path": "tests/IPXACTmodels/Component/tst_MemoryArrayValidator.pri",
    "content": "# ----------------------------------------------------\n# This file is generated by the Qt Visual Studio Tools.\n# ------------------------------------------------------\n\nSOURCES += ./tst_MemoryArrayValidator.cpp "
  },
  {
    "path": "tests/IPXACTmodels/Component/tst_MemoryArrayValidator.pro",
    "content": "#-----------------------------------------------------------------------------\n# File: tst_MemoryArrayValidator.pro\n#-----------------------------------------------------------------------------\n# Project: Kactus 2\n# Author: Anton Hagqvist\n# Date: 21.07.2023\n#\n# Description:\n# Qt project file template for running unit tests for MemoryArrayValidator.\n#-----------------------------------------------------------------------------\n\nTEMPLATE = app\n\nTARGET = tst_MemoryArrayValidator\n\nQT += core xml testlib\nQT -= gui\n\nCONFIG += c++11 testcase console\n\nlinux-g++ | linux-g++-64 | linux-g++-32 {\n LIBS += -L../../../executable \\\n     -lIPXACTmodels -lKactusAPI\n}\n\nwin64 | win32 {\n LIBS += -L../../../executable \\\n     -lIPXACTmodelsd -lKactusAPId\n}\n\nINCLUDEPATH += $$DESTDIR\nINCLUDEPATH += ../../../\n\nDEPENDPATH += .\nDEPENDPATH += ../../../\n\nOBJECTS_DIR += $$DESTDIR\n\nMOC_DIR += ./generatedFiles\nUI_DIR += ./generatedFiles\nRCC_DIR += ./generatedFiles\ninclude(tst_MemoryArrayValidator.pri)\n"
  },
  {
    "path": "tests/IPXACTmodels/Component/tst_MemoryArrayWriter.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: tst_MemoryArrayWriter.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Anton Hagqvist\n// Date: 21.07.2023\n//\n// Description:\n// Unit test for class MemoryArrayWriter.\n//-----------------------------------------------------------------------------\n\n#include <IPXACTmodels/Component/MemoryArrayWriter.h>\n#include <IPXACTmodels/Component/MemoryArray.h>\n\n#include <QXmlStreamWriter>\n\n#include <QtTest>\n\nclass tst_MemoryArrayWriter : public QObject\n{\n    Q_OBJECT\n\npublic:\n    tst_MemoryArrayWriter();\n\nprivate slots:\n\n    void init();\n    void cleanup();\n\n    void writeSingleDimension();\n    void writeMultipleDimensions();\n    void writeStride();\n    void writeBitStride();\n\nprivate:\n    QSharedPointer<MemoryArray> memoryArray_;\n};\n\n//-----------------------------------------------------------------------------\n// Function: tst_MemoryArrayWriter::tst_MemoryArrayWriter()\n//-----------------------------------------------------------------------------\ntst_MemoryArrayWriter::tst_MemoryArrayWriter()\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_MemoryArrayWriter::init()\n//-----------------------------------------------------------------------------\nvoid tst_MemoryArrayWriter::init()\n{\n    memoryArray_ = QSharedPointer<MemoryArray>(new MemoryArray());\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_MemoryArrayWriter::cleanup()\n//-----------------------------------------------------------------------------\nvoid tst_MemoryArrayWriter::cleanup()\n{\n    memoryArray_.clear();\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_MemoryArrayWriter::writeSingleDimension()\n//-----------------------------------------------------------------------------\nvoid tst_MemoryArrayWriter::writeSingleDimension()\n{\n    QSharedPointer<MemoryArray::Dimension> dim(new MemoryArray::Dimension);\n    dim->value_ = QString(\"8\");\n    \n    memoryArray_->getDimensions()->append(dim);\n\n    QString expectedOutput(\n        \"<ipxact:array>\"\n            \"<ipxact:dim>8</ipxact:dim>\"\n        \"</ipxact:array>\"\n    );\n\n    QString output;\n    QXmlStreamWriter writer(&output);\n\n    MemoryArrayWriter::writeMemoryArray(writer, memoryArray_, Document::Revision::Std22, false);\n    QCOMPARE(output, expectedOutput);\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_MemoryArrayWriter::writeMultipleDimensions()\n//-----------------------------------------------------------------------------\nvoid tst_MemoryArrayWriter::writeMultipleDimensions()\n{\n    QSharedPointer<MemoryArray::Dimension> dim(new MemoryArray::Dimension);\n    dim->value_ = QString(\"8\");\n    dim->indexVar_ = QString(\"first\");\n\n    QSharedPointer<MemoryArray::Dimension> dim2(new MemoryArray::Dimension);\n    dim2->value_ = QString(\"16\");\n    dim2->indexVar_ = QString(\"second\");\n\n    memoryArray_->getDimensions()->append(dim);\n    memoryArray_->getDimensions()->append(dim2);\n\n    QString expectedOutput(\n        \"<ipxact:array>\"\n            \"<ipxact:dim indexVar=\\\"first\\\">8</ipxact:dim>\"\n            \"<ipxact:dim indexVar=\\\"second\\\">16</ipxact:dim>\"\n        \"</ipxact:array>\"\n    );\n\n    QString output;\n    QXmlStreamWriter writer(&output);\n\n    MemoryArrayWriter::writeMemoryArray(writer, memoryArray_, Document::Revision::Std22, false);\n    QCOMPARE(output, expectedOutput);\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_MemoryArrayWriter::writeStride()\n//-----------------------------------------------------------------------------\nvoid tst_MemoryArrayWriter::writeStride()\n{\n    QSharedPointer<MemoryArray::Dimension> dim(new MemoryArray::Dimension);\n    dim->value_ = QString(\"8\");\n\n    memoryArray_->getDimensions()->append(dim);\n    memoryArray_->setStride(\"16\");\n\n    QString expectedOutput(\n        \"<ipxact:array>\"\n            \"<ipxact:dim>8</ipxact:dim>\"\n            \"<ipxact:stride>16</ipxact:stride>\"\n        \"</ipxact:array>\"\n    );\n\n    QString output;\n    QXmlStreamWriter writer(&output);\n\n    MemoryArrayWriter::writeMemoryArray(writer, memoryArray_, Document::Revision::Std22, false);\n    QCOMPARE(output, expectedOutput);\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_MemoryArrayWriter::writeBitStride()\n//-----------------------------------------------------------------------------\nvoid tst_MemoryArrayWriter::writeBitStride()\n{\n    QSharedPointer<MemoryArray::Dimension> dim(new MemoryArray::Dimension);\n    dim->value_ = QString(\"8\");\n\n    memoryArray_->getDimensions()->append(dim);\n    memoryArray_->setStride(\"16\");\n\n    QString expectedOutput(\n        \"<ipxact:array>\"\n            \"<ipxact:dim>8</ipxact:dim>\"\n            \"<ipxact:bitStride>16</ipxact:bitStride>\"\n        \"</ipxact:array>\"\n    );\n\n    QString output;\n    QXmlStreamWriter writer(&output);\n\n    MemoryArrayWriter::writeMemoryArray(writer, memoryArray_, Document::Revision::Std22, true);\n    QCOMPARE(output, expectedOutput);\n}\n\nQTEST_APPLESS_MAIN(tst_MemoryArrayWriter)\n\n#include \"tst_MemoryArrayWriter.moc\"\n"
  },
  {
    "path": "tests/IPXACTmodels/Component/tst_MemoryArrayWriter.pri",
    "content": "# ----------------------------------------------------\n# This file is generated by the Qt Visual Studio Tools.\n# ------------------------------------------------------\n\nSOURCES += ./tst_MemoryArrayWriter.cpp "
  },
  {
    "path": "tests/IPXACTmodels/Component/tst_MemoryArrayWriter.pro",
    "content": "#-----------------------------------------------------------------------------\n# File: tst_MemoryArrayWriter.pro\n#-----------------------------------------------------------------------------\n# Project: Kactus 2\n# Author: Anton Hagqvist\n# Date: 21.07.2023\n#\n# Description:\n# Qt project file template for running unit tests for MemoryArrayWriter.\n#-----------------------------------------------------------------------------\n\nTEMPLATE = app\n\nTARGET = tst_MemoryArrayWriter\n\nQT += core xml testlib\nQT -= gui\n\nCONFIG += c++11 testcase console\n\nlinux-g++ | linux-g++-64 | linux-g++-32 {\n LIBS += -L../../../executable \\\n     -lIPXACTmodels\n\n}\nwin64 | win32 {\n LIBS += -L../../../executable \\\n     -lIPXACTmodelsd\n}\n\nINCLUDEPATH += $$DESTDIR\nINCLUDEPATH += ../../../\n\nDEPENDPATH += .\nDEPENDPATH += ../../../\n\nOBJECTS_DIR += $$DESTDIR\n\nMOC_DIR += ./generatedFiles\nUI_DIR += ./generatedFiles\nRCC_DIR += ./generatedFiles\ninclude(tst_MemoryArrayWriter.pri)\n"
  },
  {
    "path": "tests/IPXACTmodels/Component/tst_MemoryMapBaseReader.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: tst_MemoryMapBaseReader.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Janne Virtanen\r\n// Date: 01.10.2015\r\n//\r\n// Description:\r\n// Unit test for class MemoryMapBaseReader.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include <IPXACTmodels/Component/MemoryMapBaseReader.h>\r\n#include <IPXACTmodels/Component/MemoryMapBase.h>\r\n#include <IPXACTmodels/Component/MemoryRemap.h>\r\n\r\n#include <IPXACTmodels/Component/AddressBlock.h>\r\n#include <IPXACTmodels/Component/Register.h>\r\n#include <IPXACTmodels/Component/RegisterFile.h>\r\n#include <IPXACTmodels/Component/Field.h>\r\n\r\n#include <IPXACTmodels/common/VendorExtension.h>\r\n\r\n#include <QtTest>\r\n\r\nclass tst_MemoryMapBaseReader : public QObject\r\n{\r\n    Q_OBJECT\r\n\r\npublic:\r\n    tst_MemoryMapBaseReader();\r\n\r\nprivate slots:\r\n\r\n    void readSimpleMemoryMapBase();\r\n    void readIsPresent();\r\n    void readAddressBlocks();\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_MemoryMapBaseReader::tst_MemoryMapBaseReader()\r\n//-----------------------------------------------------------------------------\r\ntst_MemoryMapBaseReader::tst_MemoryMapBaseReader()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_MemoryMapBaseReader::readSimpleMemoryMapBase()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_MemoryMapBaseReader::readSimpleMemoryMapBase()\r\n{\r\n    QString documentContent(\r\n        \"<ipxact:MemoryMapBase>\"\r\n            \"<ipxact:name>testMemoryMapBase</ipxact:name>\"\r\n            \"<ipxact:displayName>displayed</ipxact:displayName>\"\r\n            \"<ipxact:description>described</ipxact:description>\"\r\n        \"</ipxact:MemoryMapBase>\"\r\n        );\r\n\r\n    QDomDocument document;\r\n    document.setContent(documentContent);\r\n\r\n    QDomNode MemoryMapBaseNode = document.firstChildElement(\"ipxact:MemoryMapBase\");\r\n\r\n    QSharedPointer<MemoryMapBase> testMemoryMapBase( new MemoryMapBase );\r\n    MemoryMapBaseReader::readMemoryMapBase(MemoryMapBaseNode, testMemoryMapBase, Document::Revision::Std14);\r\n\r\n    QCOMPARE(testMemoryMapBase->name(), QString(\"testMemoryMapBase\"));\r\n    QCOMPARE(testMemoryMapBase->displayName(), QString(\"displayed\"));\r\n    QCOMPARE(testMemoryMapBase->description(), QString(\"described\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_MemoryMapBaseReader::readIsPresent()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_MemoryMapBaseReader::readIsPresent()\r\n{\r\n    QString documentContent(\r\n        \"<ipxact:MemoryMapBase>\"\r\n            \"<ipxact:name>testMemoryMapBase</ipxact:name>\"\r\n            \"<ipxact:isPresent>8/8-1</ipxact:isPresent>\"\r\n        \"</ipxact:MemoryMapBase>\"\r\n        );\r\n\r\n    QDomDocument document;\r\n    document.setContent(documentContent);\r\n\r\n    QDomNode MemoryMapBaseNode = document.firstChildElement(\"ipxact:MemoryMapBase\");\r\n\r\n\tQSharedPointer<MemoryMapBase> testMemoryMapBase( new MemoryMapBase );\r\n    MemoryMapBaseReader::readMemoryMapBase(MemoryMapBaseNode, testMemoryMapBase, Document::Revision::Std14);\r\n\r\n    QCOMPARE(testMemoryMapBase->name(), QString(\"testMemoryMapBase\"));\r\n    QCOMPARE(testMemoryMapBase->getIsPresent(), QString(\"8/8-1\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_MemoryMapBaseReader::readAddressBlocks()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_MemoryMapBaseReader::readAddressBlocks()\r\n{\r\n    QString documentContent(\r\n        \"<ipxact:MemoryMapBase>\"\r\n            \"<ipxact:name>testMemoryMapBase</ipxact:name>\"\r\n            \"<ipxact:addressBlock>\"\r\n                \"<ipxact:name>testBlock</ipxact:name>\"\r\n                \"<ipxact:baseAddress>StarControl</ipxact:baseAddress>\"\r\n                \"<ipxact:range>Kzer-Za</ipxact:range>\"\r\n                \"<ipxact:width>Kohr-Ah</ipxact:width>\"\r\n                \"<ipxact:register>\"\r\n                    \"<ipxact:name>testRegister</ipxact:name>\"\r\n                    \"<ipxact:displayName>displayed</ipxact:displayName>\"\r\n                    \"<ipxact:description>described</ipxact:description>\"\r\n                    \"<ipxact:addressOffset>offset</ipxact:addressOffset>\"\r\n                    \"<ipxact:size>10</ipxact:size>\"\r\n                    \"<ipxact:field>\"\r\n                        \"<ipxact:name>simpleField</ipxact:name>\"\r\n                        \"<ipxact:bitOffset>fieldOffset</ipxact:bitOffset>\"\r\n                        \"<ipxact:bitWidth>fieldWidth</ipxact:bitWidth>\"\r\n                    \"</ipxact:field>\"\r\n                \"</ipxact:register>\"\r\n                \"<ipxact:registerFile>\"\r\n                    \"<ipxact:name>contained</ipxact:name>\"\r\n                    \"<ipxact:addressOffset>containedOffset</ipxact:addressOffset>\"\r\n                    \"<ipxact:range>containedRange</ipxact:range>\"\r\n                \"</ipxact:registerFile>\"\r\n            \"</ipxact:addressBlock>\"\r\n        \"</ipxact:MemoryMapBase>\"\r\n        );\r\n\r\n    QDomDocument document;\r\n    document.setContent(documentContent);\r\n\r\n    QDomNode MemoryMapBaseNode = document.firstChildElement(\"ipxact:MemoryMapBase\");\r\n\r\n\tQSharedPointer<MemoryMapBase> testMemoryMapBase( new MemoryMapBase );\r\n    MemoryMapBaseReader::readMemoryMapBase(MemoryMapBaseNode, testMemoryMapBase, Document::Revision::Std14);\r\n\r\n    QCOMPARE(testMemoryMapBase->name(), QString(\"testMemoryMapBase\"));\r\n\r\n    QCOMPARE(testMemoryMapBase->getMemoryBlocks()->size(), 1);\r\n\r\n    QSharedPointer<AddressBlock> testAddressBlock =\r\n        testMemoryMapBase->getMemoryBlocks()->first().dynamicCast<AddressBlock>();\r\n    QCOMPARE(testAddressBlock.isNull(), false);\r\n    QCOMPARE(testAddressBlock->name(), QString(\"testBlock\"));\r\n    QCOMPARE(testAddressBlock->getBaseAddress(), QString(\"StarControl\"));\r\n    QCOMPARE(testAddressBlock->getRange(), QString(\"Kzer-Za\"));\r\n    QCOMPARE(testAddressBlock->getWidth(), QString(\"Kohr-Ah\"));\r\n\r\n    QCOMPARE(testAddressBlock->getRegisterData()->size(), 2);\r\n\r\n    QSharedPointer<Register> containedRegister =\r\n        testAddressBlock->getRegisterData()->first().dynamicCast<Register>();\r\n    QCOMPARE(containedRegister.isNull(), false);\r\n    QCOMPARE(containedRegister->name(), QString(\"testRegister\"));\r\n    QCOMPARE(containedRegister->displayName(), QString(\"displayed\"));\r\n    QCOMPARE(containedRegister->description(), QString(\"described\"));\r\n    QCOMPARE(containedRegister->getSize(), QString(\"10\"));\r\n\r\n    QCOMPARE(containedRegister->getFields()->size(), 1);\r\n    QCOMPARE(containedRegister->getFields()->first()->name(), QString(\"simpleField\"));\r\n    QCOMPARE(containedRegister->getFields()->first()->getBitOffset(), QString(\"fieldOffset\"));\r\n    QCOMPARE(containedRegister->getFields()->first()->getBitWidth(), QString(\"fieldWidth\"));\r\n\r\n    QSharedPointer<RegisterFile> containedFile =\r\n        testAddressBlock->getRegisterData()->last().dynamicCast<RegisterFile>();\r\n    QCOMPARE(containedFile.isNull(), false);\r\n    QCOMPARE(containedFile->name(), QString(\"contained\"));\r\n    QCOMPARE(containedFile->getAddressOffset(), QString(\"containedOffset\"));\r\n    QCOMPARE(containedFile->getRange(), QString(\"containedRange\"));\r\n}\r\n\r\nQTEST_APPLESS_MAIN(tst_MemoryMapBaseReader)\r\n\r\n#include \"tst_MemoryMapBaseReader.moc\"\r\n"
  },
  {
    "path": "tests/IPXACTmodels/Component/tst_MemoryMapBaseReader.pri",
    "content": "# ----------------------------------------------------\r\n# This file is generated by the Qt Visual Studio Tools.\r\n# ------------------------------------------------------\r\n\r\nSOURCES += ./tst_MemoryMapBaseReader.cpp \r\n"
  },
  {
    "path": "tests/IPXACTmodels/Component/tst_MemoryMapBaseReader.pro",
    "content": "#-----------------------------------------------------------------------------\r\n# File: tst_MemoryMapBaseReader.pro\r\n#-----------------------------------------------------------------------------\r\n# Project: Kactus 2\r\n# Author: Janne Virtanen\r\n# Date: 01.10.2015\r\n#\r\n# Description:\r\n# Qt project file template for running unit tests for MemoryMapBaseReader.\r\n#-----------------------------------------------------------------------------\r\n\r\nTEMPLATE = app\r\n\r\nTARGET = tst_MemoryMapBaseReader\r\n\r\nQT += core xml testlib\r\nQT -= gui\r\n\r\nCONFIG += c++11 testcase console\r\n\r\nlinux-g++ | linux-g++-64 | linux-g++-32 {\r\n LIBS += -L../../../executable \\\r\n     -lIPXACTmodels\r\n}\r\nwin64 | win32 {\r\n LIBS += -L../../../executable \\\r\n     -lIPXACTmodelsd\r\n}\r\n\r\nINCLUDEPATH += $$DESTDIR\r\nINCLUDEPATH += ../../../\r\n\r\nDEPENDPATH += .\r\nDEPENDPATH += ../../../\r\n\r\nOBJECTS_DIR += $$DESTDIR\r\n\r\nMOC_DIR += ./generatedFiles\r\nUI_DIR += ./generatedFiles\r\nRCC_DIR += ./generatedFiles\r\ninclude(tst_MemoryMapBaseReader.pri)\r\n"
  },
  {
    "path": "tests/IPXACTmodels/Component/tst_MemoryMapBaseValidator.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: tst_MemoryMapBaseValidator.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 25.11.2015\r\n//\r\n// Description:\r\n// Unit test for class MemoryMapBaseValidator.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include <KactusAPI/include/SystemVerilogExpressionParser.h>\r\n\r\n#include <IPXACTmodels/Component/validators/MemoryMapBaseValidator.h>\r\n#include <IPXACTmodels/Component/validators/AddressBlockValidator.h>\r\n#include <IPXACTmodels/Component/validators/RegisterValidator.h>\r\n#include <IPXACTmodels/Component/validators/RegisterFileValidator.h>\r\n#include <IPXACTmodels/Component/validators/FieldValidator.h>\r\n#include <IPXACTmodels/Component/validators/SubspaceMapValidator.h>\r\n#include <IPXACTmodels/Component/validators/EnumeratedValueValidator.h>\r\n#include <IPXACTmodels/common/validators/ParameterValidator.h>\r\n\r\n#include <IPXACTmodels/Component/MemoryMapBase.h>\r\n#include <IPXACTmodels/Component/AddressBlock.h>\r\n\r\n#include <QtTest>\r\n\r\nclass tst_MemoryMapBaseValidator : public QObject\r\n{\r\n    Q_OBJECT\r\n\r\npublic:\r\n    tst_MemoryMapBaseValidator();\r\n\r\nprivate slots:\r\n\r\n    void testNameIsValid();\r\n    void testNameIsValid_data();\r\n\r\n    void testIsPresentIsValid();\r\n    void testIsPresentIsValid_data();\r\n\r\n    void testAddressBlocksAreValid();\r\n    void testAddressBlocksOverlap();\r\n    void testAddressBlocksOverlap_data();\r\n\r\nprivate:\r\n\r\n    bool errorIsNotFoundInErrorList(QString const& expectedError, QVector<QString> errorList);\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_MemoryMapBaseValidator::tst_MemoryMapBaseValidator()\r\n//-----------------------------------------------------------------------------\r\ntst_MemoryMapBaseValidator::tst_MemoryMapBaseValidator()\r\n{\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_MemoryMapBaseValidator::testNameIsValid()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_MemoryMapBaseValidator::testNameIsValid()\r\n{\r\n    QFETCH(QString, name);\r\n    QFETCH(bool, isValid);\r\n\r\n    QSharedPointer<MemoryMapBase> testMap (new MemoryMapBase(name));\r\n\r\n    QSharedPointer<ExpressionParser> parser(new SystemVerilogExpressionParser());\r\n    QSharedPointer<ParameterValidator> parameterValidator (new ParameterValidator(parser,\r\n        QSharedPointer<QList<QSharedPointer<Choice> > > (), Document::Revision::Std14));\r\n    QSharedPointer<EnumeratedValueValidator> enumValidator (new EnumeratedValueValidator(parser));\r\n    QSharedPointer<FieldValidator> fieldValidator (new FieldValidator(parser, enumValidator, parameterValidator));\r\n    QSharedPointer<RegisterValidator> registerValidator (\r\n        new RegisterValidator(parser, fieldValidator, parameterValidator));\r\n    QSharedPointer<RegisterFileValidator> registerFileValidator (\r\n        new RegisterFileValidator(parser, registerValidator, parameterValidator, Document::Revision::Std14));\r\n    QSharedPointer<AddressBlockValidator> addressBlockValidator (\r\n        new AddressBlockValidator(parser, registerValidator, registerFileValidator, parameterValidator, Document::Revision::Std14));\r\n    QSharedPointer<SubspaceMapValidator> subspaceMapValidator(new SubspaceMapValidator(parser, parameterValidator, Document::Revision::Std14));\r\n    MemoryMapBaseValidator validator(parser, addressBlockValidator, subspaceMapValidator, Document::Revision::Std14);\r\n\r\n    QCOMPARE(validator.hasValidName(testMap), isValid);\r\n\r\n    if (!isValid)\r\n    {\r\n        QVector<QString> foundErrors;\r\n        validator.findErrorsIn(foundErrors, testMap, \"\", \"test\");\r\n\r\n        QString expectedError = QObject::tr(\"Invalid name specified for memory map %1 within %2\").\r\n            arg(testMap->name(), \"test\");\r\n        if (errorIsNotFoundInErrorList(expectedError, foundErrors))\r\n        {\r\n            QFAIL(\"No error message found\");\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_MemoryMapBaseValidator::testNameIsValid_data()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_MemoryMapBaseValidator::testNameIsValid_data()\r\n{\r\n    QTest::addColumn<QString>(\"name\");\r\n    QTest::addColumn<bool>(\"isValid\");\r\n\r\n    QTest::newRow(\"Name test is valid\") << \"test\" << true;\r\n    QTest::newRow(\"Empty name is invalid\") << \"\" << false;\r\n    QTest::newRow(\"Name consisting of only white spaces is invalid\") << \"    \" << false;\r\n    QTest::newRow(\"Name consisting of characters and white spaces is valid\") << \"  test  \" << true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_MemoryMapBaseValidator::testIsPresentIsValid()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_MemoryMapBaseValidator::testIsPresentIsValid()\r\n{\r\n    QFETCH(QString, isPresent);\r\n    QFETCH(bool, isValid);\r\n\r\n    QSharedPointer<MemoryMapBase> testMap (new MemoryMapBase(\"TestAddressBlock\"));\r\n    testMap->setIsPresent(isPresent);\r\n\r\n    QSharedPointer<ExpressionParser> parser(new SystemVerilogExpressionParser());\r\n    QSharedPointer<ParameterValidator> parameterValidator (new ParameterValidator(parser,\r\n        QSharedPointer<QList<QSharedPointer<Choice> > > (), Document::Revision::Std14));\r\n    QSharedPointer<EnumeratedValueValidator> enumValidator (new EnumeratedValueValidator(parser));\r\n    QSharedPointer<FieldValidator> fieldValidator (new FieldValidator(parser, enumValidator, parameterValidator));\r\n    QSharedPointer<RegisterValidator> registerValidator (\r\n        new RegisterValidator(parser, fieldValidator, parameterValidator));\r\n    QSharedPointer<RegisterFileValidator> registerFileValidator (\r\n        new RegisterFileValidator(parser, registerValidator, parameterValidator, Document::Revision::Std14));\r\n    QSharedPointer<AddressBlockValidator> addressBlockValidator (\r\n        new AddressBlockValidator(parser, registerValidator, registerFileValidator, parameterValidator, Document::Revision::Std14));\r\n    QSharedPointer<SubspaceMapValidator> subspaceMapValidator(new SubspaceMapValidator(parser, parameterValidator, Document::Revision::Std14));\r\n    MemoryMapBaseValidator validator(parser, addressBlockValidator, subspaceMapValidator, Document::Revision::Std14);\r\n    QCOMPARE(validator.hasValidIsPresent(testMap), isValid);\r\n\r\n    if (!isValid)\r\n    {\r\n        QVector<QString> foundErrors;\r\n        validator.findErrorsIn(foundErrors, testMap, \"\", \"test\");\r\n\r\n        QString expectedError = QObject::tr(\"Invalid isPresent set for memory map %1 within %2\").\r\n            arg(testMap->name(), \"test\");\r\n        if (errorIsNotFoundInErrorList(expectedError, foundErrors))\r\n        {\r\n            QFAIL(\"No error message found\");\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_MemoryMapBaseValidator::testIsPresentIsValid_data()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_MemoryMapBaseValidator::testIsPresentIsValid_data()\r\n{\r\n    QTest::addColumn<QString>(\"isPresent\");\r\n    QTest::addColumn<bool>(\"isValid\");\r\n\r\n    QTest::newRow(\"IsPresent 1 is valid\") << \"1\" << true;\r\n    QTest::newRow(\"IsPresent 1*3-3 is valid\") << \"1*3-3\" << true;\r\n    QTest::newRow(\"IsPresent 2*100 is invalid\") << \"2*100\" << false;\r\n    QTest::newRow(\"IsPresent -14 is invalid\") << \"-14\" << false;\r\n    QTest::newRow(\"Real number isPresent  0.12 is invalid\") << \"0.12\" << false;\r\n    QTest::newRow(\"Text as isPresent is invalid\") << \"test\" << false;\r\n    QTest::newRow(\"String as isPresent is invalid\") << \"\\\"test\\\"\" << false;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_MemoryMapBaseValidator::testAddressSpacesAreValid()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_MemoryMapBaseValidator::testAddressBlocksAreValid()\r\n{\r\n    QSharedPointer<AddressBlock> testBlock (new AddressBlock(\"testBlock\"));\r\n\r\n    QSharedPointer<MemoryMapBase> testMap (new MemoryMapBase(\"testMap\"));\r\n    testMap->getMemoryBlocks()->append(testBlock);\r\n\r\n    QSharedPointer<ExpressionParser> parser(new SystemVerilogExpressionParser());\r\n    QSharedPointer<ParameterValidator> parameterValidator (new ParameterValidator(parser,\r\n        QSharedPointer<QList<QSharedPointer<Choice> > > (), Document::Revision::Std14));\r\n    QSharedPointer<EnumeratedValueValidator> enumValidator (new EnumeratedValueValidator(parser));\r\n    QSharedPointer<FieldValidator> fieldValidator (new FieldValidator(parser, enumValidator, parameterValidator));\r\n    QSharedPointer<RegisterValidator> registerValidator (\r\n        new RegisterValidator(parser, fieldValidator, parameterValidator));\r\n    QSharedPointer<RegisterFileValidator> registerFileValidator (\r\n        new RegisterFileValidator(parser, registerValidator, parameterValidator, Document::Revision::Std14));\r\n    QSharedPointer<AddressBlockValidator> addressBlockValidator (\r\n        new AddressBlockValidator(parser, registerValidator, registerFileValidator, parameterValidator, Document::Revision::Std14));\r\n    QSharedPointer<SubspaceMapValidator> subspaceMapValidator(new SubspaceMapValidator(parser, parameterValidator, Document::Revision::Std14));\r\n    MemoryMapBaseValidator validator(parser, addressBlockValidator, subspaceMapValidator, Document::Revision::Std14);\r\n    QCOMPARE(validator.hasValidMemoryBlocks(testMap, \"\"), false);\r\n\r\n    QVector<QString> foundErrors;\r\n    validator.findErrorsIn(foundErrors, testMap, \"8\", \"test\");\r\n\r\n    QString expectedError = QObject::tr(\"Invalid baseAddress set for address block %1 within memory map %2\").\r\n        arg(testBlock->name()).arg(testMap->name());\r\n    if (errorIsNotFoundInErrorList(expectedError, foundErrors))\r\n    {\r\n        QFAIL(\"No error message found\");\r\n    }\r\n\r\n    testBlock->setBaseAddress(\"0\");\r\n    testBlock->setRange(\"2\");\r\n    testBlock->setWidth(\"16\");\r\n    QCOMPARE(validator.hasValidMemoryBlocks(testMap, \"8\"), true);\r\n\r\n    QSharedPointer<AddressBlock> otherBlock (new AddressBlock(*testBlock.data()));\r\n    otherBlock->setBaseAddress(\"3\");\r\n    testMap->getMemoryBlocks()->append(otherBlock);\r\n    QCOMPARE(validator.hasValidMemoryBlocks(testMap, \"8\"), false);\r\n\r\n    foundErrors.clear();\r\n    validator.findErrorsIn(foundErrors, testMap, \"8\", \"test\");\r\n    expectedError = QObject::tr(\"Name %1 of memory blocks in memory map %2 is not unique\")\r\n        .arg(testBlock->name()).arg(testMap->name());\r\n\r\n    if (errorIsNotFoundInErrorList(expectedError, foundErrors))\r\n    {\r\n        QFAIL(\"No error message found\");\r\n    }\r\n\r\n    otherBlock->setName(\"otherBlock\");\r\n    QCOMPARE(validator.hasValidMemoryBlocks(testMap, \"8\"), true);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_MemoryMapBaseValidator::testAddressBlocksOverlap()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_MemoryMapBaseValidator::testAddressBlocksOverlap()\r\n{\r\n    QFETCH(QString, baseAddressOne);\r\n    QFETCH(QString, rangeOne);\r\n    QFETCH(QString, baseAddressTwo);\r\n    QFETCH(QString, rangeTwo);\r\n    QFETCH(bool, isValid);\r\n\r\n    QSharedPointer<AddressBlock> blockOne (new AddressBlock(\"One\", baseAddressOne));\r\n    blockOne->setRange(rangeOne);\r\n    blockOne->setWidth(\"8\");\r\n\r\n    QSharedPointer<AddressBlock> blockTwo (new AddressBlock(\"Two\", baseAddressTwo));\r\n    blockTwo->setRange(rangeTwo);\r\n    blockTwo->setWidth(\"8\");\r\n\r\n    QSharedPointer<MemoryMapBase> testMap (new MemoryMapBase(\"testMap\"));\r\n    testMap->getMemoryBlocks()->append(blockOne);\r\n    testMap->getMemoryBlocks()->append(blockTwo);\r\n\r\n    QSharedPointer<ExpressionParser> parser(new SystemVerilogExpressionParser());\r\n    QSharedPointer<ParameterValidator> parameterValidator (new ParameterValidator(parser,\r\n        QSharedPointer<QList<QSharedPointer<Choice> > > (), Document::Revision::Std14));\r\n    QSharedPointer<EnumeratedValueValidator> enumValidator (new EnumeratedValueValidator(parser));\r\n    QSharedPointer<FieldValidator> fieldValidator (new FieldValidator(parser, enumValidator, parameterValidator));\r\n    QSharedPointer<RegisterValidator> registerValidator (\r\n        new RegisterValidator(parser, fieldValidator, parameterValidator));\r\n    QSharedPointer<RegisterFileValidator> registerFileValidator (\r\n        new RegisterFileValidator(parser, registerValidator, parameterValidator, Document::Revision::Std14));\r\n    QSharedPointer<AddressBlockValidator> addressBlockValidator (\r\n        new AddressBlockValidator(parser, registerValidator, registerFileValidator, parameterValidator, Document::Revision::Std14));\r\n    MemoryMapBaseValidator validator(parser, addressBlockValidator, nullptr);\r\n    QCOMPARE(validator.hasValidMemoryBlocks(testMap, \"8\"), isValid);\r\n\r\n    if (!isValid)\r\n    {\r\n        QVector<QString> foundErrors;\r\n        validator.findErrorsIn(foundErrors, testMap, \"8\", \"test\");\r\n        QString expectedError = QObject::tr(\"Memory blocks %1 and %2 overlap in memory map %3\")\r\n            .arg(blockOne->name()).arg(blockTwo->name()).arg(testMap->name());\r\n\r\n        if (errorIsNotFoundInErrorList(expectedError, foundErrors))\r\n        {\r\n            QFAIL(\"No error message found\");\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_MemoryMapBaseValidator::testAddressBlocksOverlap_data()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_MemoryMapBaseValidator::testAddressBlocksOverlap_data()\r\n{\r\n    QTest::addColumn<QString>(\"baseAddressOne\");\r\n    QTest::addColumn<QString>(\"rangeOne\");\r\n    QTest::addColumn<QString>(\"baseAddressTwo\");\r\n    QTest::addColumn<QString>(\"rangeTwo\");\r\n    QTest::addColumn<bool>(\"isValid\");\r\n\r\n    QTest::newRow(\"Block1: baseAddress = 0, range = 2, Block2: baseAddress = 2, range = 2 is valid\") << \"0\" <<\r\n        \"2\" << \"2\" << \"2\" << true;\r\n    QTest::newRow(\"Block1: baseAddress = 5, range = 10, Block2: baseAddress = 2, range = 4 is invalid\") << \"5\" <<\r\n        \"10\" << \"2\" << \"4\" << false;\r\n    QTest::newRow(\"Block1: baseAddress = 5, range = 10, Block2: baseAddress = 6, range = 2 is invalid\") << \"5\" <<\r\n        \"10\" << \"6\" << \"2\" << false;\r\n    QTest::newRow(\"Block1: baseAddress = 5, range = 10, Block2: baseAddress = 8, range = 10 is invalid\") << \"5\" <<\r\n        \"10\" << \"8\" << \"10\" << false;\r\n    QTest::newRow(\"Block1: baseAddress = 5, range = 10, Block2: baseAddress = 15, range = 10 is valid\") << \"5\" <<\r\n        \"10\" << \"15\" << \"10\" << true;\r\n    QTest::newRow(\"Block1: baseAddress = 8, range = 10, Block2: baseAddress = 5, range = 10 is invalid\") << \"8\" <<\r\n        \"10\" << \"5\" << \"10\" << false;\r\n    QTest::newRow(\"Block1: baseAddress = 15, range = 10, Block2: baseAddress = 5, range = 10 is valid\") << \"15\" <<\r\n        \"10\" << \"5\" << \"10\" << true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_MemoryMapBaseValidator::errorIsNotFoundInErrorList()\r\n//-----------------------------------------------------------------------------\r\nbool tst_MemoryMapBaseValidator::errorIsNotFoundInErrorList(QString const& expectedError,\r\n    QVector<QString> errorList)\r\n{\r\n    if (!errorList.contains(expectedError))\r\n    {\r\n        qDebug() << \"The following error:\" << Qt::endl << expectedError << Qt::endl << \"was not found in error list:\";\r\n        for (QString const& error : errorList)\r\n        {\r\n            qDebug() << error;\r\n        }\r\n        return true;\r\n    }\r\n\r\n    return false;\r\n}\r\n\r\nQTEST_APPLESS_MAIN(tst_MemoryMapBaseValidator)\r\n\r\n#include \"tst_MemoryMapBaseValidator.moc\"\r\n"
  },
  {
    "path": "tests/IPXACTmodels/Component/tst_MemoryMapBaseValidator.pri",
    "content": "# ----------------------------------------------------\r\n# This file is generated by the Qt Visual Studio Tools.\r\n# ------------------------------------------------------\r\n\r\nSOURCES += ./tst_MemoryMapBaseValidator.cpp \r\n\t"
  },
  {
    "path": "tests/IPXACTmodels/Component/tst_MemoryMapBaseValidator.pro",
    "content": "#-----------------------------------------------------------------------------\r\n# File: tst_MemoryMapBaseValidator.pro\r\n#-----------------------------------------------------------------------------\r\n# Project: Kactus 2\r\n# Author: Mikko Teuho\r\n# Date: 25.11.2015\r\n#\r\n# Description:\r\n# Qt project file template for running unit tests for MemoryMapBaseValidator.\r\n#-----------------------------------------------------------------------------\r\n\r\nTEMPLATE = app\r\n\r\nTARGET = tst_MemoryMapBaseValidator\r\n\r\nQT += core gui xml testlib\r\n\r\nCONFIG += c++11 testcase console\r\n\r\nlinux-g++ | linux-g++-64 | linux-g++-32 {\r\n LIBS += -L../../../executable \\\r\n     -lIPXACTmodels -lKactusAPI\r\n}\r\nwin64 | win32 {\r\n LIBS += -L../../../executable \\\r\n     -lIPXACTmodelsd -lKactusAPId\r\n}\r\n\r\nINCLUDEPATH += $$DESTDIR\r\nINCLUDEPATH += ../../../\r\n\r\nDEPENDPATH += .\r\nDEPENDPATH += ../../../\r\n\r\nOBJECTS_DIR += $$DESTDIR\r\n\r\nMOC_DIR += ./generatedFiles\r\nUI_DIR += ./generatedFiles\r\nRCC_DIR += ./generatedFiles\r\ninclude(tst_MemoryMapBaseValidator.pri)\r\n"
  },
  {
    "path": "tests/IPXACTmodels/Component/tst_MemoryMapBaseWriter.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: tst_MemoryMapBaseWriter.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Janne Virtanen\r\n// Date: 01.10.2015\r\n//\r\n// Description:\r\n// Unit test for class MemoryMapBaseWriter.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include <IPXACTmodels/Component/MemoryMapBaseWriter.h>\r\n#include <IPXACTmodels/Component/MemoryMapBase.h>\r\n#include <IPXACTmodels/Component/MemoryRemap.h>\r\n\r\n#include <IPXACTmodels/Component/AddressBlock.h>\r\n#include <IPXACTmodels/Component/Register.h>\r\n#include <IPXACTmodels/Component/RegisterFile.h>\r\n#include <IPXACTmodels/Component/Field.h>\r\n\r\n#include <IPXACTmodels/common/GenericVendorExtension.h>\r\n\r\n#include <QtTest>\r\n\r\nclass tst_MemoryMapBaseWriter : public QObject\r\n{\r\n    Q_OBJECT\r\n\r\npublic:\r\n    tst_MemoryMapBaseWriter();\r\n\r\nprivate slots:\r\n\r\n    void initTestCase();\r\n    void cleanupTestCase();\r\n    void init();\r\n    void cleanup();\r\n\r\n    void writeSimpleMemoryMapBase();\r\n    void writeIsPresent();\r\n    void writeAddressBlocks();\r\n\r\nprivate:\r\n\r\n    QSharedPointer<MemoryMapBase> testMemoryMapBase_;\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_MemoryMapBaseWriter::tst_MemoryMapBaseWriter()\r\n//-----------------------------------------------------------------------------\r\ntst_MemoryMapBaseWriter::tst_MemoryMapBaseWriter():\r\ntestMemoryMapBase_()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_MemoryMapBaseWriter::initTestCase()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_MemoryMapBaseWriter::initTestCase()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_MemoryMapBaseWriter::cleanupTestCase()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_MemoryMapBaseWriter::cleanupTestCase()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_MemoryMapBaseWriter::init()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_MemoryMapBaseWriter::init()\r\n{\r\n    testMemoryMapBase_ = QSharedPointer<MemoryMapBase>(new MemoryMapBase(\"testMemoryMapBase\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_MemoryMapBaseWriter::cleanup()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_MemoryMapBaseWriter::cleanup()\r\n{\r\n    testMemoryMapBase_.clear();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_MemoryMapBaseWriter::writeSimpleMemoryMapBase()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_MemoryMapBaseWriter::writeSimpleMemoryMapBase()\r\n{\r\n    QString output;\r\n    QXmlStreamWriter xmlStreamWriter(&output);\r\n\r\n    testMemoryMapBase_->setDisplayName(\"displayed\");\r\n    testMemoryMapBase_->setDescription(\"described\");\r\n\r\n    QString expectedOutput(\r\n            \"<ipxact:name>testMemoryMapBase</ipxact:name>\"\r\n            \"<ipxact:displayName>displayed</ipxact:displayName>\"\r\n            \"<ipxact:description>described</ipxact:description>\"\r\n        );\r\n\r\n    MemoryMapBaseWriter::writeMemoryMapBase(xmlStreamWriter, testMemoryMapBase_, Document::Revision::Std14);\r\n    QCOMPARE(output, expectedOutput);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_MemoryMapBaseWriter::writeIsPresent()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_MemoryMapBaseWriter::writeIsPresent()\r\n{\r\n    QString output;\r\n    QXmlStreamWriter xmlStreamWriter(&output);\r\n\r\n    testMemoryMapBase_->setIsPresent(\"8/8-1\");\r\n\r\n    QString expectedOutput(\r\n            \"<ipxact:name>testMemoryMapBase</ipxact:name>\"\r\n            \"<ipxact:isPresent>8/8-1</ipxact:isPresent>\"\r\n        );\r\n\r\n    MemoryMapBaseWriter::writeMemoryMapBase(xmlStreamWriter, testMemoryMapBase_, Document::Revision::Std14);\r\n    QCOMPARE(output, expectedOutput);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_MemoryMapBaseWriter::writeAddressBlocks()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_MemoryMapBaseWriter::writeAddressBlocks()\r\n{\r\n    QString output;\r\n    QXmlStreamWriter xmlStreamWriter(&output);\r\n\r\n    QSharedPointer<Field> simpleField(new Field(\"simpleField\"));\r\n    simpleField->setBitOffset(\"fieldOffset\");\r\n    simpleField->setBitWidth(\"fieldWidth\");\r\n\r\n    QSharedPointer<Register> testRegister (new Register(\"testRegister\", \"offset\", \"10\"));\r\n    testRegister->setDisplayName(\"displayed\");\r\n    testRegister->setDescription(\"described\");\r\n    testRegister->getFields()->append(simpleField);\r\n\r\n    QSharedPointer<RegisterFile> containedRegisterFile\r\n        (new RegisterFile(\"contained\", \"containedOffset\", \"containedRange\"));\r\n\r\n    QSharedPointer<AddressBlock> testAddressBlock =\r\n        QSharedPointer<AddressBlock>(new AddressBlock(\"testBlock\", \"StarControl\"));\r\n    testAddressBlock->setRange(\"Kzer-Za\");\r\n    testAddressBlock->setWidth(\"Kohr-Ah\");\r\n    testAddressBlock->getRegisterData()->append(testRegister);\r\n    testAddressBlock->getRegisterData()->append(containedRegisterFile);\r\n\r\n\ttestMemoryMapBase_->getMemoryBlocks()->append(testAddressBlock);\r\n\r\n    QString expectedOutput(\r\n            \"<ipxact:name>testMemoryMapBase</ipxact:name>\"\r\n            \"<ipxact:addressBlock>\"\r\n                \"<ipxact:name>testBlock</ipxact:name>\"\r\n                \"<ipxact:baseAddress>StarControl</ipxact:baseAddress>\"\r\n                \"<ipxact:range>Kzer-Za</ipxact:range>\"\r\n                \"<ipxact:width>Kohr-Ah</ipxact:width>\"\r\n                \"<ipxact:register>\"\r\n                    \"<ipxact:name>testRegister</ipxact:name>\"\r\n                    \"<ipxact:displayName>displayed</ipxact:displayName>\"\r\n                    \"<ipxact:description>described</ipxact:description>\"\r\n                    \"<ipxact:addressOffset>offset</ipxact:addressOffset>\"\r\n                    \"<ipxact:size>10</ipxact:size>\"\r\n                    \"<ipxact:field>\"\r\n                        \"<ipxact:name>simpleField</ipxact:name>\"\r\n                        \"<ipxact:bitOffset>fieldOffset</ipxact:bitOffset>\"\r\n                        \"<ipxact:bitWidth>fieldWidth</ipxact:bitWidth>\"\r\n                    \"</ipxact:field>\"\r\n                \"</ipxact:register>\"\r\n                \"<ipxact:registerFile>\"\r\n                    \"<ipxact:name>contained</ipxact:name>\"\r\n                    \"<ipxact:addressOffset>containedOffset</ipxact:addressOffset>\"\r\n                    \"<ipxact:range>containedRange</ipxact:range>\"\r\n                \"</ipxact:registerFile>\"\r\n            \"</ipxact:addressBlock>\"\r\n\t\t);\r\n\r\n    MemoryMapBaseWriter::writeMemoryMapBase(xmlStreamWriter, testMemoryMapBase_, Document::Revision::Std14);\r\n    QCOMPARE(output, expectedOutput);\r\n}\r\n\r\nQTEST_APPLESS_MAIN(tst_MemoryMapBaseWriter)\r\n\r\n#include \"tst_MemoryMapBaseWriter.moc\"\r\n"
  },
  {
    "path": "tests/IPXACTmodels/Component/tst_MemoryMapBaseWriter.pri",
    "content": "# ----------------------------------------------------\r\n# This file is generated by the Qt Visual Studio Tools.\r\n# ------------------------------------------------------\r\n\r\nSOURCES += ./tst_MemoryMapBaseWriter.cpp \r\n"
  },
  {
    "path": "tests/IPXACTmodels/Component/tst_MemoryMapBaseWriter.pro",
    "content": "#-----------------------------------------------------------------------------\r\n# File: tst_MemoryMapBaseWriter.pro\r\n#-----------------------------------------------------------------------------\r\n# Project: Kactus 2\r\n# Author: Janne Virtanen\r\n# Date: 01.10.2015\r\n#\r\n# Description:\r\n# Qt project file template for running unit tests for MemoryMapBaseWriter.\r\n#-----------------------------------------------------------------------------\r\n\r\nTEMPLATE = app\r\n\r\nTARGET = tst_MemoryMapBaseWriter\r\n\r\nQT += core xml testlib\r\nQT -= gui\r\n\r\nCONFIG += c++11 testcase console\r\n\r\nlinux-g++ | linux-g++-64 | linux-g++-32 {\r\n LIBS += -L../../../executable \\\r\n     -lIPXACTmodels\r\n}\r\nwin64 | win32 {\r\n LIBS += -L../../../executable \\\r\n     -lIPXACTmodelsd\r\n}\r\n\r\nINCLUDEPATH += $$DESTDIR\r\nINCLUDEPATH += ../../../\r\n\r\nDEPENDPATH += .\r\nDEPENDPATH += ../../../\r\n\r\nOBJECTS_DIR += $$DESTDIR\r\n\r\nMOC_DIR += ./generatedFiles\r\nUI_DIR += ./generatedFiles\r\nRCC_DIR += ./generatedFiles\r\ninclude(tst_MemoryMapBaseWriter.pri)\r\n"
  },
  {
    "path": "tests/IPXACTmodels/Component/tst_MemoryMapReader.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: tst_MemoryMapReader.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 01.10.2015\r\n//\r\n// Description:\r\n// Unit test for class MemoryMapReader.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include <IPXACTmodels/Component/MemoryMapReader.h>\r\n#include <IPXACTmodels/Component/MemoryMap.h>\r\n#include <IPXACTmodels/Component/MemoryRemap.h>\r\n\r\n#include <IPXACTmodels/Component/AddressBlock.h>\r\n#include <IPXACTmodels/Component/Register.h>\r\n#include <IPXACTmodels/Component/RegisterFile.h>\r\n#include <IPXACTmodels/Component/Field.h>\r\n\r\n#include <IPXACTmodels/common/VendorExtension.h>\r\n\r\n#include <QtTest>\r\n\r\nclass tst_MemoryMapReader : public QObject\r\n{\r\n    Q_OBJECT\r\n\r\npublic:\r\n    tst_MemoryMapReader();\r\n\r\nprivate slots:\r\n\r\n    void readSimpleMemoryMap();\r\n    void readSimpleMemoryMap2022();\r\n\r\n    void readIsPresent();\r\n    void readAddressBlocks();\r\n    void readSubspaceMap();\r\n\r\n    void readSimpleMemoryRemap();\r\n    void readMemoryRemapAddressBlocks();\r\n\r\n    void readMemoryRemap2022();\r\n    void readMemoryRemapWithSubspaceMap();\r\n\r\n    void readAddressUnitBits();\r\n    void readSharedValue();\r\n\r\n    void readVendorExtensions();\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_MemoryMapReader::tst_MemoryMapReader()\r\n//-----------------------------------------------------------------------------\r\ntst_MemoryMapReader::tst_MemoryMapReader()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_MemoryMapReader::readSimpleMemoryMap()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_MemoryMapReader::readSimpleMemoryMap()\r\n{\r\n    QString documentContent(\r\n        \"<ipxact:memoryMap>\"\r\n            \"<ipxact:name>testMemoryMap</ipxact:name>\"\r\n            \"<ipxact:displayName>displayed</ipxact:displayName>\"\r\n            \"<ipxact:description>described</ipxact:description>\"\r\n        \"</ipxact:memoryMap>\"\r\n        );\r\n\r\n    QDomDocument document;\r\n    document.setContent(documentContent);\r\n\r\n    QDomNode memoryMapNode = document.firstChildElement(\"ipxact:memoryMap\");\r\n\r\n    QSharedPointer<MemoryMap> testMemoryMap = MemoryMapReader::createMemoryMapFrom(memoryMapNode, Document::Revision::Std14);\r\n\r\n    QCOMPARE(testMemoryMap->name(), QString(\"testMemoryMap\"));\r\n    QCOMPARE(testMemoryMap->displayName(), QString(\"displayed\"));\r\n    QCOMPARE(testMemoryMap->description(), QString(\"described\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_MemoryMapReader::readSimpleMemoryMap2022()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_MemoryMapReader::readSimpleMemoryMap2022()\r\n{\r\n    QString documentContent(\r\n        \"<ipxact:memoryMap>\"\r\n            \"<ipxact:name>testMemoryMap</ipxact:name>\"\r\n            \"<ipxact:displayName>displayed</ipxact:displayName>\"\r\n            \"<ipxact:description>described</ipxact:description>\"\r\n            \"<ipxact:memoryMapDefinitionRef typeDefinitions=\\\"testDefinitions\\\">testMemMapDef</ipxact:memoryMapDefinitionRef>\"\r\n        \"</ipxact:memoryMap>\"\r\n        );\r\n\r\n    QDomDocument document;\r\n    document.setContent(documentContent);\r\n\r\n    QDomNode memoryMapNode = document.firstChildElement(\"ipxact:memoryMap\");\r\n\r\n    QSharedPointer<MemoryMap> testMemoryMap = MemoryMapReader::createMemoryMapFrom(memoryMapNode, Document::Revision::Std22);\r\n\r\n    QCOMPARE(testMemoryMap->name(), QString(\"testMemoryMap\"));\r\n    QCOMPARE(testMemoryMap->displayName(), QString(\"displayed\"));\r\n    QCOMPARE(testMemoryMap->description(), QString(\"described\"));\r\n\r\n    QCOMPARE(testMemoryMap->getMemoryMapDefinitionReference(), QString(\"testMemMapDef\"));\r\n    QCOMPARE(testMemoryMap->getTypeDefinitionsReference(), QString(\"testDefinitions\"));\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_MemoryMapReader::readIsPresent()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_MemoryMapReader::readIsPresent()\r\n{\r\n    QString documentContent(\r\n        \"<ipxact:memoryMap>\"\r\n            \"<ipxact:name>testMemoryMap</ipxact:name>\"\r\n            \"<ipxact:isPresent>8/8-1</ipxact:isPresent>\"\r\n        \"</ipxact:memoryMap>\"\r\n        );\r\n\r\n    QDomDocument document;\r\n    document.setContent(documentContent);\r\n\r\n    QDomNode memoryMapNode = document.firstChildElement(\"ipxact:memoryMap\");\r\n\r\n    QSharedPointer<MemoryMap> testMemoryMap = MemoryMapReader::createMemoryMapFrom(memoryMapNode, Document::Revision::Std14);\r\n\r\n    QCOMPARE(testMemoryMap->name(), QString(\"testMemoryMap\"));\r\n    QCOMPARE(testMemoryMap->getIsPresent(), QString(\"8/8-1\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_MemoryMapReader::readAddressBlocks()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_MemoryMapReader::readAddressBlocks()\r\n{\r\n    QString documentContent(\r\n        \"<ipxact:memoryMap>\"\r\n            \"<ipxact:name>testMemoryMap</ipxact:name>\"\r\n            \"<ipxact:addressBlock>\"\r\n                \"<ipxact:name>testBlock</ipxact:name>\"\r\n                \"<ipxact:baseAddress>StarControl</ipxact:baseAddress>\"\r\n                \"<ipxact:range>Kzer-Za</ipxact:range>\"\r\n                \"<ipxact:width>Kohr-Ah</ipxact:width>\"\r\n                \"<ipxact:register>\"\r\n                    \"<ipxact:name>testRegister</ipxact:name>\"\r\n                    \"<ipxact:displayName>displayed</ipxact:displayName>\"\r\n                    \"<ipxact:description>described</ipxact:description>\"\r\n                    \"<ipxact:addressOffset>offset</ipxact:addressOffset>\"\r\n                    \"<ipxact:size>10</ipxact:size>\"\r\n                    \"<ipxact:field>\"\r\n                        \"<ipxact:name>simpleField</ipxact:name>\"\r\n                        \"<ipxact:bitOffset>fieldOffset</ipxact:bitOffset>\"\r\n                        \"<ipxact:bitWidth>fieldWidth</ipxact:bitWidth>\"\r\n                    \"</ipxact:field>\"\r\n                \"</ipxact:register>\"\r\n                \"<ipxact:registerFile>\"\r\n                    \"<ipxact:name>contained</ipxact:name>\"\r\n                    \"<ipxact:addressOffset>containedOffset</ipxact:addressOffset>\"\r\n                    \"<ipxact:range>containedRange</ipxact:range>\"\r\n                \"</ipxact:registerFile>\"\r\n            \"</ipxact:addressBlock>\"\r\n        \"</ipxact:memoryMap>\"\r\n        );\r\n\r\n    QDomDocument document;\r\n    document.setContent(documentContent);\r\n\r\n    QDomNode memoryMapNode = document.firstChildElement(\"ipxact:memoryMap\");\r\n\r\n    QSharedPointer<MemoryMap> testMemoryMap = MemoryMapReader::createMemoryMapFrom(memoryMapNode, Document::Revision::Std14);\r\n\r\n    QCOMPARE(testMemoryMap->name(), QString(\"testMemoryMap\"));\r\n\r\n    QCOMPARE(testMemoryMap->getMemoryBlocks()->size(), 1);\r\n\r\n    QSharedPointer<AddressBlock> testAddressBlock =\r\n        testMemoryMap->getMemoryBlocks()->first().dynamicCast<AddressBlock>();\r\n    QCOMPARE(testAddressBlock.isNull(), false);\r\n    QCOMPARE(testAddressBlock->name(), QString(\"testBlock\"));\r\n    QCOMPARE(testAddressBlock->getBaseAddress(), QString(\"StarControl\"));\r\n    QCOMPARE(testAddressBlock->getRange(), QString(\"Kzer-Za\"));\r\n    QCOMPARE(testAddressBlock->getWidth(), QString(\"Kohr-Ah\"));\r\n\r\n    QCOMPARE(testAddressBlock->getRegisterData()->size(), 2);\r\n\r\n    QSharedPointer<Register> containedRegister =\r\n        testAddressBlock->getRegisterData()->first().dynamicCast<Register>();\r\n    QCOMPARE(containedRegister.isNull(), false);\r\n    QCOMPARE(containedRegister->name(), QString(\"testRegister\"));\r\n    QCOMPARE(containedRegister->displayName(), QString(\"displayed\"));\r\n    QCOMPARE(containedRegister->description(), QString(\"described\"));\r\n    QCOMPARE(containedRegister->getSize(), QString(\"10\"));\r\n\r\n    QCOMPARE(containedRegister->getFields()->size(), 1);\r\n    QCOMPARE(containedRegister->getFields()->first()->name(), QString(\"simpleField\"));\r\n    QCOMPARE(containedRegister->getFields()->first()->getBitOffset(), QString(\"fieldOffset\"));\r\n    QCOMPARE(containedRegister->getFields()->first()->getBitWidth(), QString(\"fieldWidth\"));\r\n\r\n    QSharedPointer<RegisterFile> containedFile =\r\n        testAddressBlock->getRegisterData()->last().dynamicCast<RegisterFile>();\r\n    QCOMPARE(containedFile.isNull(), false);\r\n    QCOMPARE(containedFile->name(), QString(\"contained\"));\r\n    QCOMPARE(containedFile->getAddressOffset(), QString(\"containedOffset\"));\r\n    QCOMPARE(containedFile->getRange(), QString(\"containedRange\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_MemoryMapReader::readSubspaceMap()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_MemoryMapReader::readSubspaceMap()\r\n{\r\n    QString documentContent(\r\n        \"<ipxact:memoryMap>\"\r\n            \"<ipxact:name>testMemoryMap</ipxact:name>\"\r\n            \"<ipxact:subspaceMap initiatorRef=\\\"testInitiator\\\">\"\r\n                \"<ipxact:name>testSubspaceMap</ipxact:name>\"\r\n                \"<ipxact:baseAddress>'h01</ipxact:baseAddress>\"\r\n            \"</ipxact:subspaceMap>\"\r\n        \"</ipxact:memoryMap>\"\r\n    );\r\n\r\n    QDomDocument document;\r\n    document.setContent(documentContent);\r\n\r\n    QDomNode memoryMapNode = document.firstChildElement(\"ipxact:memoryMap\");\r\n\r\n    QSharedPointer<MemoryMap> testMemoryMap = MemoryMapReader::createMemoryMapFrom(memoryMapNode, \r\n        Document::Revision::Std22);\r\n\r\n    QSharedPointer<SubSpaceMap> parsedSubSpace;\r\n\r\n    QCOMPARE(testMemoryMap->getMemoryBlocks()->size(), 1);\r\n    QVERIFY(parsedSubSpace = testMemoryMap->getMemoryBlocks()->first().dynamicCast<SubSpaceMap>());\r\n\r\n    QCOMPARE(parsedSubSpace->getInitiatorReference(), QString(\"testInitiator\"));\r\n    QCOMPARE(parsedSubSpace->getBaseAddress(), QString(\"'h01\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_MemoryMapReader::readSimpleMemoryMap()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_MemoryMapReader::readSimpleMemoryRemap()\r\n{\r\n    QString documentContent(\r\n        \"<ipxact:memoryMap>\"\r\n            \"<ipxact:name>testMemoryMap</ipxact:name>\"\r\n            \"<ipxact:memoryRemap state=\\\"remappedState\\\">\"\r\n                \"<ipxact:name>memoryRemap</ipxact:name>\"\r\n                \"<ipxact:displayName>displayedRemap</ipxact:displayName>\"\r\n                \"<ipxact:description>describedRemap</ipxact:description>\"\r\n                \"<ipxact:isPresent>1</ipxact:isPresent>\"\r\n            \"</ipxact:memoryRemap>\"\r\n        \"</ipxact:memoryMap>\"\r\n        );\r\n\r\n    QDomDocument document;\r\n    document.setContent(documentContent);\r\n\r\n    QDomNode memoryMapNode = document.firstChildElement(\"ipxact:memoryMap\");\r\n\r\n    QSharedPointer<MemoryMap> testMemoryMap = MemoryMapReader::createMemoryMapFrom(memoryMapNode, Document::Revision::Std14);\r\n\r\n    QCOMPARE(testMemoryMap->name(), QString(\"testMemoryMap\"));\r\n\r\n    QCOMPARE(testMemoryMap->getMemoryRemaps()->size(), 1);\r\n    QCOMPARE(testMemoryMap->getMemoryBlocks()->size(), 0);\r\n\r\n    QSharedPointer<MemoryRemap> testMemoryRemap = testMemoryMap->getMemoryRemaps()->first();\r\n    QCOMPARE(testMemoryRemap->name(), QString(\"memoryRemap\"));\r\n    QCOMPARE(testMemoryRemap->displayName(), QString(\"displayedRemap\"));\r\n    QCOMPARE(testMemoryRemap->description(), QString(\"describedRemap\"));\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_MemoryMapReader::readMemoryRemapAddressBlocks()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_MemoryMapReader::readMemoryRemapAddressBlocks()\r\n{\r\n    QString documentContent(\r\n        \"<ipxact:memoryMap>\"\r\n            \"<ipxact:name>testMemoryMap</ipxact:name>\"\r\n            \"<ipxact:memoryRemap state=\\\"remappedState\\\">\"\r\n                \"<ipxact:name>memoryRemap</ipxact:name>\"\r\n                \"<ipxact:addressBlock>\"\r\n                    \"<ipxact:name>testBlock</ipxact:name>\"\r\n                    \"<ipxact:baseAddress>StarControl</ipxact:baseAddress>\"\r\n                    \"<ipxact:range>Kzer-Za</ipxact:range>\"\r\n                    \"<ipxact:width>Kohr-Ah</ipxact:width>\"\r\n                    \"<ipxact:register>\"\r\n                        \"<ipxact:name>testRegister</ipxact:name>\"\r\n                        \"<ipxact:displayName>displayed</ipxact:displayName>\"\r\n                        \"<ipxact:description>described</ipxact:description>\"\r\n                        \"<ipxact:addressOffset>offset</ipxact:addressOffset>\"\r\n                        \"<ipxact:size>10</ipxact:size>\"\r\n                        \"<ipxact:field>\"\r\n                            \"<ipxact:name>simpleField</ipxact:name>\"\r\n                            \"<ipxact:bitOffset>fieldOffset</ipxact:bitOffset>\"\r\n                            \"<ipxact:bitWidth>fieldWidth</ipxact:bitWidth>\"\r\n                        \"</ipxact:field>\"\r\n                    \"</ipxact:register>\"\r\n                    \"<ipxact:registerFile>\"\r\n                        \"<ipxact:name>contained</ipxact:name>\"\r\n                        \"<ipxact:addressOffset>containedOffset</ipxact:addressOffset>\"\r\n                        \"<ipxact:range>containedRange</ipxact:range>\"\r\n                    \"</ipxact:registerFile>\"\r\n                \"</ipxact:addressBlock>\"\r\n            \"</ipxact:memoryRemap>\"\r\n        \"</ipxact:memoryMap>\"\r\n        );\r\n\r\n    QDomDocument document;\r\n    document.setContent(documentContent);\r\n\r\n    QDomNode memoryMapNode = document.firstChildElement(\"ipxact:memoryMap\");\r\n\r\n    QSharedPointer<MemoryMap> testMemoryMap = MemoryMapReader::createMemoryMapFrom(memoryMapNode, Document::Revision::Std14);\r\n\r\n    QCOMPARE(testMemoryMap->name(), QString(\"testMemoryMap\"));\r\n\r\n    QCOMPARE(testMemoryMap->getMemoryRemaps()->size(), 1);\r\n    QCOMPARE(testMemoryMap->getMemoryBlocks()->size(), 0);\r\n\r\n    QSharedPointer<MemoryRemap> testMemoryRemap = testMemoryMap->getMemoryRemaps()->first();\r\n    QCOMPARE(testMemoryRemap->name(), QString(\"memoryRemap\"));\r\n\r\n    QCOMPARE(testMemoryRemap->getMemoryBlocks()->size(), 1);\r\n\r\n    QSharedPointer<AddressBlock> testAddressBlock =\r\n        testMemoryRemap->getMemoryBlocks()->first().dynamicCast<AddressBlock>();\r\n    QCOMPARE(testAddressBlock.isNull(), false);\r\n    QCOMPARE(testAddressBlock->name(), QString(\"testBlock\"));\r\n    QCOMPARE(testAddressBlock->getBaseAddress(), QString(\"StarControl\"));\r\n    QCOMPARE(testAddressBlock->getRange(), QString(\"Kzer-Za\"));\r\n    QCOMPARE(testAddressBlock->getWidth(), QString(\"Kohr-Ah\"));\r\n\r\n    QCOMPARE(testAddressBlock->getRegisterData()->size(), 2);\r\n\r\n    QSharedPointer<Register> containedRegister =\r\n        testAddressBlock->getRegisterData()->first().dynamicCast<Register>();\r\n    QCOMPARE(containedRegister.isNull(), false);\r\n    QCOMPARE(containedRegister->name(), QString(\"testRegister\"));\r\n    QCOMPARE(containedRegister->displayName(), QString(\"displayed\"));\r\n    QCOMPARE(containedRegister->description(), QString(\"described\"));\r\n    QCOMPARE(containedRegister->getSize(), QString(\"10\"));\r\n\r\n    QCOMPARE(containedRegister->getFields()->size(), 1);\r\n    QCOMPARE(containedRegister->getFields()->first()->name(), QString(\"simpleField\"));\r\n    QCOMPARE(containedRegister->getFields()->first()->getBitOffset(), QString(\"fieldOffset\"));\r\n    QCOMPARE(containedRegister->getFields()->first()->getBitWidth(), QString(\"fieldWidth\"));\r\n\r\n    QSharedPointer<RegisterFile> containedFile =\r\n        testAddressBlock->getRegisterData()->last().dynamicCast<RegisterFile>();\r\n    QCOMPARE(containedFile.isNull(), false);\r\n    QCOMPARE(containedFile->name(), QString(\"contained\"));\r\n    QCOMPARE(containedFile->getAddressOffset(), QString(\"containedOffset\"));\r\n    QCOMPARE(containedFile->getRange(), QString(\"containedRange\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_MemoryMapReader::readMemoryRemap2022()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_MemoryMapReader::readMemoryRemap2022()\r\n{\r\n    // Test with definition std22 reference.\r\n    QString documentContent(\r\n        \"<ipxact:memoryMap>\"\r\n            \"<ipxact:name>testMemoryMap</ipxact:name>\"\r\n            \"<ipxact:memoryRemap>\"\r\n                \"<ipxact:name>memoryRemap</ipxact:name>\"\r\n                \"<ipxact:displayName>displayedRemap</ipxact:displayName>\"\r\n                \"<ipxact:description>describedRemap</ipxact:description>\"\r\n                \"<ipxact:modeRef priority=\\\"0\\\">testMode</ipxact:modeRef>\"\r\n                \"<ipxact:modeRef priority=\\\"1\\\">mode2</ipxact:modeRef>\"\r\n                \"<ipxact:remapDefinitionRef typeDefinitions=\\\"testDefinitions\\\">testRemapDef</ipxact:remapDefinitionRef>\"\r\n                \"<ipxact:vendorExtensions>\"\r\n                    \"<testExtension testExtensionAttribute=\\\"extension\\\">testValue</testExtension>\"\r\n                \"</ipxact:vendorExtensions>\"\r\n            \"</ipxact:memoryRemap>\"\r\n        \"</ipxact:memoryMap>\"\r\n    );\r\n\r\n    QDomDocument document;\r\n    document.setContent(documentContent);\r\n\r\n    QDomNode memoryMapNode = document.firstChildElement(\"ipxact:memoryMap\");\r\n\r\n    QSharedPointer<MemoryMap> testMemoryMap = MemoryMapReader::createMemoryMapFrom(memoryMapNode, Document::Revision::Std22);\r\n\r\n    QCOMPARE(testMemoryMap->name(), QString(\"testMemoryMap\"));\r\n\r\n    QCOMPARE(testMemoryMap->getMemoryRemaps()->size(), 1);\r\n    QCOMPARE(testMemoryMap->getMemoryBlocks()->size(), 0);\r\n\r\n    QSharedPointer<MemoryRemap> testMemoryRemap = testMemoryMap->getMemoryRemaps()->first();\r\n    QCOMPARE(testMemoryRemap->name(), QString(\"memoryRemap\"));\r\n    QCOMPARE(testMemoryRemap->displayName(), QString(\"displayedRemap\"));\r\n    QCOMPARE(testMemoryRemap->description(), QString(\"describedRemap\"));\r\n    QCOMPARE(testMemoryRemap->getModeReferences()->size(), 2);\r\n    QCOMPARE(testMemoryRemap->getModeReferences()->first()->getReference(), QString(\"testMode\"));\r\n    QCOMPARE(testMemoryRemap->getModeReferences()->back()->getPriority(), 1);\r\n\r\n    QCOMPARE(testMemoryRemap->getMemoryRemapDefinitionReference(), QString(\"testRemapDef\"));\r\n    QCOMPARE(testMemoryRemap->getTypeDefinitionsReference(), QString(\"testDefinitions\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_MemoryMapReader::readMemoryRemapWithSubspaceMap()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_MemoryMapReader::readMemoryRemapWithSubspaceMap()\r\n{\r\n    QString documentContent(\r\n        \"<ipxact:memoryMap>\"\r\n            \"<ipxact:name>testMemoryMap</ipxact:name>\"\r\n            \"<ipxact:memoryRemap>\"\r\n                \"<ipxact:name>memoryRemap</ipxact:name>\"\r\n                \"<ipxact:displayName>displayedRemap</ipxact:displayName>\"\r\n                \"<ipxact:description>describedRemap</ipxact:description>\"\r\n                \"<ipxact:subspaceMap initiatorRef=\\\"testInitiator\\\">\"\r\n                    \"<ipxact:name>testSubspaceMap</ipxact:name>\"\r\n                    \"<ipxact:baseAddress>'h01</ipxact:baseAddress>\"\r\n                \"</ipxact:subspaceMap>\"\r\n                \"<ipxact:vendorExtensions>\"\r\n                    \"<testExtension testExtensionAttribute=\\\"extension\\\">testValue</testExtension>\"\r\n                \"</ipxact:vendorExtensions>\"\r\n            \"</ipxact:memoryRemap>\"\r\n        \"</ipxact:memoryMap>\"\r\n    );\r\n\r\n    QDomDocument document;\r\n    document.setContent(documentContent);\r\n\r\n    QDomNode memoryMapNode = document.firstChildElement(\"ipxact:memoryMap\");\r\n\r\n    QSharedPointer<MemoryMap> testMemoryMap = MemoryMapReader::createMemoryMapFrom(memoryMapNode, \r\n        Document::Revision::Std22);\r\n\r\n    QSharedPointer<MemoryRemap> parsedRemap;\r\n    QSharedPointer<SubSpaceMap> parsedSubSpace;\r\n\r\n    QCOMPARE(testMemoryMap->getMemoryBlocks()->size(), 0);\r\n    QCOMPARE(testMemoryMap->getMemoryRemaps()->size(), 1);\r\n\r\n    parsedRemap = testMemoryMap->getMemoryRemaps()->first();\r\n    \r\n    QVERIFY(parsedSubSpace = parsedRemap->getMemoryBlocks()->first().dynamicCast<SubSpaceMap>());\r\n\r\n    QCOMPARE(parsedSubSpace->getInitiatorReference(), QString(\"testInitiator\"));\r\n    QCOMPARE(parsedSubSpace->getBaseAddress(), QString(\"'h01\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_MemoryMapReader::readAddressUnitBits()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_MemoryMapReader::readAddressUnitBits()\r\n{\r\n    QString documentContent(\r\n        \"<ipxact:memoryMap>\"\r\n            \"<ipxact:name>testMemoryMap</ipxact:name>\"\r\n            \"<ipxact:addressUnitBits>8</ipxact:addressUnitBits>\"\r\n        \"</ipxact:memoryMap>\"\r\n        );\r\n\r\n    QDomDocument document;\r\n    document.setContent(documentContent);\r\n\r\n    QDomNode memoryMapNode = document.firstChildElement(\"ipxact:memoryMap\");\r\n\r\n    QSharedPointer<MemoryMap> testMemoryMap = MemoryMapReader::createMemoryMapFrom(memoryMapNode, Document::Revision::Std14);\r\n\r\n    QCOMPARE(testMemoryMap->name(), QString(\"testMemoryMap\"));\r\n    QCOMPARE(testMemoryMap->getAddressUnitBits(), QString(\"8\"));\r\n\r\n    // No AUB = default 8 bits\r\n    QString documentContentNoAUB(\r\n        \"<ipxact:memoryMap>\"\r\n            \"<ipxact:name>testMemoryMapNoAub</ipxact:name>\"\r\n        \"</ipxact:memoryMap>\"\r\n        );\r\n\r\n    document.setContent(documentContentNoAUB);\r\n\r\n    memoryMapNode = document.firstChildElement(\"ipxact:memoryMap\");\r\n\r\n    QSharedPointer<MemoryMap> testMemoryMapNoAUB = MemoryMapReader::createMemoryMapFrom(memoryMapNode, Document::Revision::Std14);\r\n\r\n    QCOMPARE(testMemoryMapNoAUB->name(), QString(\"testMemoryMapNoAub\"));\r\n    QCOMPARE(testMemoryMapNoAUB->getAddressUnitBits(), QString(\"8\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_MemoryMapReader::readSharedValue()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_MemoryMapReader::readSharedValue()\r\n{\r\n    QString documentContent(\r\n        \"<ipxact:memoryMap>\"\r\n            \"<ipxact:name>testMemoryMap</ipxact:name>\"\r\n            \"<ipxact:shared>yes</ipxact:shared>\"\r\n        \"</ipxact:memoryMap>\"\r\n        );\r\n\r\n    QDomDocument document;\r\n    document.setContent(documentContent);\r\n\r\n    QDomNode memoryMapNode = document.firstChildElement(\"ipxact:memoryMap\");\r\n\r\n    QSharedPointer<MemoryMap> testMemoryMap = MemoryMapReader::createMemoryMapFrom(memoryMapNode, Document::Revision::Std14);\r\n\r\n    QCOMPARE(testMemoryMap->name(), QString(\"testMemoryMap\"));\r\n    QCOMPARE(testMemoryMap->getShared(), QString(\"true\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_MemoryMapReader::readVendorExtensions()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_MemoryMapReader::readVendorExtensions()\r\n{\r\n    QString documentContent(\r\n        \"<ipxact:memoryMap>\"\r\n            \"<ipxact:name>testMemoryMap</ipxact:name>\"\r\n            \"<ipxact:vendorExtensions>\"\r\n                \"<testExtension testExtensionAttribute=\\\"extension\\\">testValue</testExtension>\"\r\n            \"</ipxact:vendorExtensions>\"\r\n        \"</ipxact:memoryMap>\"\r\n        );\r\n\r\n    QDomDocument document;\r\n    document.setContent(documentContent);\r\n\r\n    QDomNode memoryMapNode = document.firstChildElement(\"ipxact:memoryMap\");\r\n\r\n    QSharedPointer<MemoryMap> testMemoryMap = MemoryMapReader::createMemoryMapFrom(memoryMapNode, Document::Revision::Std14);\r\n\r\n    QCOMPARE(testMemoryMap->name(), QString(\"testMemoryMap\"));\r\n    QCOMPARE(testMemoryMap->getVendorExtensions()->size(), 1);\r\n    QCOMPARE(testMemoryMap->getVendorExtensions()->first()->type(), QString(\"testExtension\"));\r\n}\r\n\r\nQTEST_APPLESS_MAIN(tst_MemoryMapReader)\r\n\r\n#include \"tst_MemoryMapReader.moc\"\r\n"
  },
  {
    "path": "tests/IPXACTmodels/Component/tst_MemoryMapReader.pri",
    "content": "# ----------------------------------------------------\r\n# This file is generated by the Qt Visual Studio Tools.\r\n# ------------------------------------------------------\r\n\r\nSOURCES += ./tst_MemoryMapReader.cpp \r\n"
  },
  {
    "path": "tests/IPXACTmodels/Component/tst_MemoryMapReader.pro",
    "content": "#-----------------------------------------------------------------------------\r\n# File: tst_MemoryMapReader.pro\r\n#-----------------------------------------------------------------------------\r\n# Project: Kactus 2\r\n# Author: Mikko Teuho\r\n# Date: 01.10.2015\r\n#\r\n# Description:\r\n# Qt project file template for running unit tests for MemoryMapReader.\r\n#-----------------------------------------------------------------------------\r\n\r\nTEMPLATE = app\r\n\r\nTARGET = tst_MemoryMapReader\r\n\r\nQT += core xml testlib\r\nQT -= gui\r\n\r\nCONFIG += c++11 testcase console\r\n\r\nlinux-g++ | linux-g++-64 | linux-g++-32 {\r\n LIBS += -L../../../executable \\\r\n     -lIPXACTmodels\r\n}\r\nwin64 | win32 {\r\n LIBS += -L../../../executable \\\r\n     -lIPXACTmodelsd\r\n}\r\n\r\nINCLUDEPATH += $$DESTDIR\r\nINCLUDEPATH += ../../../\r\n\r\nDEPENDPATH += .\r\nDEPENDPATH += ../../../\r\n\r\nOBJECTS_DIR += $$DESTDIR\r\n\r\nMOC_DIR += ./generatedFiles\r\nUI_DIR += ./generatedFiles\r\nRCC_DIR += ./generatedFiles\r\ninclude(tst_MemoryMapReader.pri)\r\n"
  },
  {
    "path": "tests/IPXACTmodels/Component/tst_MemoryMapValidator.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: tst_MemoryMapValidator.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 25.11.2015\r\n//\r\n// Description:\r\n// Unit test for class MemoryMapValidator.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include <KactusAPI/include/SystemVerilogExpressionParser.h>\r\n\r\n#include <IPXACTmodels/Component/validators/MemoryMapValidator.h>\r\n#include <IPXACTmodels/Component/validators/AddressBlockValidator.h>\r\n#include <IPXACTmodels/Component/validators/RegisterValidator.h>\r\n#include <IPXACTmodels/Component/validators/RegisterFileValidator.h>\r\n#include <IPXACTmodels/Component/validators/FieldValidator.h>\r\n#include <IPXACTmodels/Component/validators/EnumeratedValueValidator.h>\r\n#include <IPXACTmodels/Component/validators/SubspaceMapValidator.h>\r\n#include <IPXACTmodels/common/validators/ParameterValidator.h>\r\n\r\n#include <IPXACTmodels/Component/MemoryMap.h>\r\n#include <IPXACTmodels/Component/Component.h>\r\n#include <IPXACTmodels/common/VLNV.h>\r\n#include <IPXACTmodels/Component/MemoryRemap.h>\r\n#include <IPXACTmodels/Component/RemapState.h>\r\n#include <IPXACTmodels/Component/AddressBlock.h>\r\n\r\n#include <QtTest>\r\n\r\nclass tst_MemoryMapValidator : public QObject\r\n{\r\n    Q_OBJECT\r\n\r\npublic:\r\n    tst_MemoryMapValidator();\r\n\r\nprivate slots:\r\n\r\n    void testNameIsValid();\r\n    void testNameIsValid_data();\r\n\r\n    void testAddressUnitBitsIsValid();\r\n    void testAddressUnitBitsIsValid_data();\r\n\r\n    void testAddressBlockWidthIsMultipleOfAddressUnitBits();\r\n    void testAddressBlockWidthIsMultipleOfAddressUnitBits_data();\r\n\r\n    void testHasValidMemoryRemaps();\r\n    void testHasValidMemoryRemaps_data();\r\n    void testMemoryRemapHasValidName();\r\n    void testMemoryRemapHasValidName_data();\r\n    void testMemoryRemapHasValidIsPresent();\r\n    void testMemoryRemapHasValidIsPresent_data();\r\n    void testMemoryRemapsHaveUniqueRemapStates();\r\n    void testMemoryRemapsHaveUniqueRemapStates_data();\r\n\r\n    void testHasValidMemoryRemapModeRefs2022();\r\n    void testHasValidMemoryRemapModeRefs2022_data();\r\n\r\n    void testMemoryMapStructureIsValid2022();\r\n    void testRemapStructureIsValid2022();\r\n\r\nprivate:\r\n\r\n    bool errorIsNotFoundInErrorList(QString const& expectedError, QVector<QString> errorList);\r\n\r\n    QSharedPointer<MemoryMapValidator> createValidator(\r\n        Document::Revision docRevision, QSharedPointer<QList<QSharedPointer<RemapState> > > remapStates = QSharedPointer<QList<QSharedPointer<RemapState> > >());\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_MemoryMapValidator::tst_MemoryMapValidator()\r\n//-----------------------------------------------------------------------------\r\ntst_MemoryMapValidator::tst_MemoryMapValidator()\r\n{\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_MemoryMapValidator::testNameIsValid()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_MemoryMapValidator::testNameIsValid()\r\n{\r\n    QFETCH(QString, name);\r\n    QFETCH(bool, isValid);\r\n\r\n    QSharedPointer<MemoryMap> testMap (new MemoryMap(name));\r\n\r\n    QSharedPointer<MemoryMapValidator> validator = createValidator(Document::Revision::Std14);\r\n\r\n    QCOMPARE(validator->hasValidName(testMap), isValid);\r\n\r\n    if (!isValid)\r\n    {\r\n        QVector<QString> foundErrors;\r\n        validator->findErrorsIn(foundErrors, testMap, \"test\");\r\n\r\n        QString expectedError = QObject::tr(\"Invalid name specified for memory map %1 within %2\").\r\n            arg(testMap->name(), \"test\");\r\n        if (errorIsNotFoundInErrorList(expectedError, foundErrors))\r\n        {\r\n            QFAIL(\"No error message found\");\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_MemoryMapValidator::testNameIsValid_data()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_MemoryMapValidator::testNameIsValid_data()\r\n{\r\n    QTest::addColumn<QString>(\"name\");\r\n    QTest::addColumn<bool>(\"isValid\");\r\n\r\n    QTest::newRow(\"Name test is valid\") << \"test\" << true;\r\n    QTest::newRow(\"Empty name is invalid\") << \"\" << false;\r\n    QTest::newRow(\"Name consisting of only white spaces is invalid\") << \"    \" << false;\r\n    QTest::newRow(\"Name consisting of characters and white spaces is valid\") << \"  test  \" << true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_MemoryMapValidator::testAddressUnitBitsIsValid()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_MemoryMapValidator::testAddressUnitBitsIsValid()\r\n{\r\n    QFETCH(QString, aub);\r\n    QFETCH(bool, createBlock);\r\n    QFETCH(bool, isValid);\r\n\r\n    QSharedPointer<MemoryMap> testMap (new MemoryMap(\"testMap\"));\r\n    testMap->setAddressUnitBits(aub);\r\n\r\n    if (createBlock)\r\n    {\r\n        QSharedPointer<AddressBlock> testBlock (new AddressBlock(\"testBlock\"));\r\n        testMap->getMemoryBlocks()->append(testBlock);\r\n    }\r\n\r\n    QSharedPointer<MemoryMapValidator> validator = createValidator(Document::Revision::Std14);\r\n    QCOMPARE(validator->hasValidAddressUnitBits(testMap), isValid);\r\n\r\n    if (!isValid)\r\n    {\r\n        QVector<QString> foundErrors;\r\n        validator->findErrorsIn(foundErrors, testMap, \"test\");\r\n\r\n        QString expectedError = QObject::tr(\"Invalid address unit bits specified for memory map %1 within %2\").\r\n            arg(testMap->name(), \"test\");\r\n        if (errorIsNotFoundInErrorList(expectedError, foundErrors))\r\n        {\r\n            QFAIL(\"No error message found\");\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_MemoryMapValidator::testAddressUnitBitsIsValid_data()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_MemoryMapValidator::testAddressUnitBitsIsValid_data()\r\n{\r\n    QTest::addColumn<QString>(\"aub\");\r\n    QTest::addColumn<bool>(\"createBlock\");\r\n    QTest::addColumn<bool>(\"isValid\");\r\n\r\n    QTest::newRow(\"Address unit bits of 8 is valid\") << \"8\" << false << true;\r\n    QTest::newRow(\"Address unit bits of 0 is invalid\") << \"0\" << false << false;\r\n    QTest::newRow(\"Address unit bits of 32/2 is valid\") << \"32/2\" << false << true;\r\n    QTest::newRow(\"Address unit bits of -2*2 is invalid\") << \"-2*2\" << false << false;\r\n    QTest::newRow(\"Address unit bits of text is invalid\") << \"text\" << false << false;\r\n    QTest::newRow(\"Address unit bits of string is invalid\") << \"\\\"text\\\"\" << false << false;\r\n    QTest::newRow(\"Empty address unit bits is valid if there exists no address blocks\") << \"\" << false << true;\r\n    QTest::newRow(\"Empty address unit bits is valid if there exists address blocks\") << \"\" << true << true;\r\n    QTest::newRow(\"Long address unit bit value is valid\") << \"40000000000\" << false << true;\r\n}\r\n\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_MemoryMapValidator::testAddressUnitBitsIsValidForAddressBlocks()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_MemoryMapValidator::testAddressBlockWidthIsMultipleOfAddressUnitBits()\r\n{\r\n    QFETCH(QString, addressUnitBits);\r\n    QFETCH(QString, addressBlockWidth);\r\n    QFETCH(bool, isValid);\r\n\r\n    QSharedPointer<AddressBlock> testBlock (new AddressBlock(\"testBlock\", \"0\"));\r\n    testBlock->setRange(\"5\");\r\n    testBlock->setWidth(addressBlockWidth);\r\n\r\n    QSharedPointer<MemoryMap> testMap (new MemoryMap(\"TestAddressBlock\"));\r\n    testMap->setAddressUnitBits(addressUnitBits);\r\n    testMap->getMemoryBlocks()->append(testBlock);\r\n\r\n    QSharedPointer<MemoryMapValidator> validator = createValidator(Document::Revision::Std14);\r\n\r\n    QCOMPARE(validator->hasValidMemoryBlocks(testMap, testMap->getAddressUnitBits()), isValid);\r\n\r\n    if (!isValid)\r\n    {\r\n        QVector<QString> foundErrors;\r\n        validator->findErrorsIn(foundErrors, testMap, \"test\");\r\n\r\n        QString expectedError = QObject::tr(\"Width of address block %1 is not a multiple of the address unit \"\r\n            \"bits of %2 %3\").arg(testBlock->name()).arg(testMap->elementName()).arg(testMap->name());\r\n        if (errorIsNotFoundInErrorList(expectedError, foundErrors))\r\n        {\r\n            QFAIL(\"No error message found\");\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_MemoryMapValidator::testAddressUnitBitsIsValidForAddressBlocks_data()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_MemoryMapValidator::testAddressBlockWidthIsMultipleOfAddressUnitBits_data()\r\n{\r\n    QTest::addColumn<QString>(\"addressUnitBits\");\r\n    QTest::addColumn<QString>(\"addressBlockWidth\");\r\n    QTest::addColumn<bool>(\"isValid\");\r\n\r\n    QTest::newRow(\"AddressUnitBits: 4, addressBlock width: 8 is valid\") << \"4\" << \"8\" << true;\r\n    QTest::newRow(\"AddressUnitBits: 14-6, addressBlock width: 8*2 is valid\") << \"14-6\" << \"8*2\" << true;\r\n    QTest::newRow(\"AddressUnitBits: 16, addressBlock width: 16 is valid\") << \"16\" << \"16\" << true;\r\n    QTest::newRow(\"AddressUnitBits: 16, addressBlock width: 21 is invalid\") << \"16\" << \"21\" << false;\r\n    QTest::newRow(\"AddressUnitBits: 16, addressBlock width: 8 is invalid\") << \"16\" << \"8\" << false;\r\n    QTest::newRow(\"AddressUnitBits not defined, addressBlock width: 8 is valid\") << \"\" << \"8\" << true;\r\n    QTest::newRow(\"AddressUnitBits not defined, addressBlock width: 2 is invalid\") << \"\" << \"2\" << false;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_MemoryMapValidator::testHasValidMemoryRemaps()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_MemoryMapValidator::testHasValidMemoryRemaps()\r\n{\r\n    QFETCH(QString, remapState);\r\n    QFETCH(bool, createRemapState);\r\n    QFETCH(bool, isValid);\r\n\r\n    QSharedPointer<MemoryRemap> testRemap (new MemoryRemap(\"testRemap\", remapState));\r\n\r\n    QSharedPointer<QList<QSharedPointer<RemapState> > > remapStates (new QList<QSharedPointer<RemapState> > ());\r\n    if (createRemapState)\r\n    {\r\n        if (remapState.isEmpty())\r\n        {\r\n            remapState = \"champloo\";\r\n        }\r\n        QSharedPointer<RemapState> newState (new RemapState(remapState));\r\n        remapStates->append(newState);\r\n    }\r\n\r\n    QSharedPointer<MemoryMap> testMap (new MemoryMap(\"testMap\"));\r\n    testMap->getMemoryRemaps()->append(testRemap);\r\n\r\n    QSharedPointer<MemoryMapValidator> validator = createValidator(Document::Revision::Std14,remapStates);\r\n\r\n    QCOMPARE(validator->hasValidMemoryRemaps(testMap), isValid);\r\n\r\n    if (!isValid)\r\n    {\r\n        QVector<QString> foundErrors;\r\n        validator->findErrorsIn(foundErrors, testMap, \"test\");\r\n\r\n        QString expectedError = QObject::tr(\"Invalid remap state %1 set for memory remap %2 within memory map %3\")\r\n            .arg(testRemap->getRemapState()).arg(testRemap->name()).arg(testMap->name());\r\n        if (errorIsNotFoundInErrorList(expectedError, foundErrors))\r\n        {\r\n            QFAIL(\"No error message found\");\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_MemoryMapValidator::testHasValidMemoryRemaps_data()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_MemoryMapValidator::testHasValidMemoryRemaps_data()\r\n{\r\n    QTest::addColumn<QString>(\"remapState\");\r\n    QTest::addColumn<bool>(\"createRemapState\");\r\n    QTest::addColumn<bool>(\"isValid\");\r\n\r\n    QTest::newRow(\"Memory remap referencing non-existing remap state is invalid\") << \"remapState\" << false << false;\r\n    QTest::newRow(\"Memory remap referencing existing remap state is valid\") << \"remapState\" << true << true;\r\n    QTest::newRow(\"Empty remap state reference is invalid\") << \"\" << true << false;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_MemoryMapValidator::testHasValidMemoryRemapName()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_MemoryMapValidator::testMemoryRemapHasValidName()\r\n{\r\n    QFETCH(QString, nameOne);\r\n    QFETCH(QString, nameTwo);\r\n    QFETCH(bool, isValid);\r\n\r\n    QSharedPointer<QList<QSharedPointer<RemapState> > > remapStates (new QList<QSharedPointer<RemapState> > ());\r\n    QSharedPointer<RemapState> newState (new RemapState(\"remapState\"));\r\n    QSharedPointer<RemapState> otherState (new RemapState(\"otherState\"));\r\n    remapStates->append(newState);\r\n    remapStates->append(otherState);\r\n\r\n    QSharedPointer<MemoryRemap> testRemap (new MemoryRemap(nameOne, newState->name()));\r\n    QSharedPointer<MemoryRemap> otherRemap (new MemoryRemap(nameTwo, otherState->name()));\r\n\r\n    QSharedPointer<MemoryMap> testMap (new MemoryMap(\"testMap\"));\r\n    testMap->getMemoryRemaps()->append(testRemap);\r\n    testMap->getMemoryRemaps()->append(otherRemap);\r\n\r\n    QSharedPointer<MemoryMapValidator> validator = createValidator(Document::Revision::Std14, remapStates);\r\n\r\n    QCOMPARE(validator->hasValidMemoryRemaps(testMap), isValid);\r\n\r\n    if (!isValid)\r\n    {\r\n        QVector<QString> foundErrors;\r\n        validator->findErrorsIn(foundErrors, testMap, \"test\");\r\n\r\n        if (nameOne == nameTwo)\r\n        {\r\n            QString expectedError = QObject::tr(\"Name %1 of memory remaps in memory map %2 is not unique.\")\r\n                .arg(testRemap->name()).arg(testMap->name());\r\n            if (errorIsNotFoundInErrorList(expectedError, foundErrors))\r\n            {\r\n                QFAIL(\"No error message found\");\r\n            }\r\n        }\r\n        else\r\n        {\r\n            QString expectedError = QObject::tr(\"Invalid name specified for memory remap %1 within memory map %2\")\r\n                .arg(testRemap->name()).arg(testMap->name());\r\n            if (errorIsNotFoundInErrorList(expectedError, foundErrors))\r\n            {\r\n                QFAIL(\"No error message found\");\r\n            }\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_MemoryMapValidator::testHasValidMemoryRemapName_data()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_MemoryMapValidator::testMemoryRemapHasValidName_data()\r\n{\r\n    QTest::addColumn<QString>(\"nameOne\");\r\n    QTest::addColumn<QString>(\"nameTwo\");\r\n    QTest::addColumn<bool>(\"isValid\");\r\n\r\n\r\n    QTest::newRow(\"Name test is valid\") << \"test\" << \"test2\" << true;\r\n    QTest::newRow(\"Empty name is invalid\") << \"\" << \"test2\" << false;\r\n    QTest::newRow(\"Name consisting of only white spaces is invalid\") << \"    \" << \"test2\" << false;\r\n    QTest::newRow(\"Name consisting of characters and spaces is valid\") << \"test \" << \"test2\" << true;\r\n    QTest::newRow(\"Non-unique names are not valid\") << \"test\" << \"test\" << false;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_MemoryMapValidator::testMemoryRemapHasValidIsPresent()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_MemoryMapValidator::testMemoryRemapHasValidIsPresent()\r\n{\r\n    QFETCH(QString, isPresent);\r\n    QFETCH(bool, isValid);\r\n\r\n    QSharedPointer<RemapState> testState(new RemapState(\"testState\"));\r\n    QSharedPointer<QList<QSharedPointer<RemapState> > > remapStates (new QList<QSharedPointer<RemapState> > ());\r\n    remapStates->append(testState);\r\n\r\n    QSharedPointer<MemoryRemap> testRemap (new MemoryRemap(\"testRemap\", testState->name()));\r\n    testRemap->setIsPresent(isPresent);\r\n\r\n    QSharedPointer<MemoryMap> testMap (new MemoryMap(\"TestAddressBlock\"));\r\n    testMap->getMemoryRemaps()->append(testRemap);\r\n\r\n    QSharedPointer<MemoryMapValidator> validator = createValidator(Document::Revision::Std14,remapStates);\r\n\r\n    QCOMPARE(validator->hasValidMemoryRemaps(testMap), isValid);\r\n\r\n    if (!isValid)\r\n    {\r\n        QVector<QString> foundErrors;\r\n        validator->findErrorsIn(foundErrors, testMap, \"test\");\r\n\r\n        QString expectedError = QObject::tr(\"Invalid isPresent set for memory remap %1 within memory map %2\").\r\n            arg(testRemap->name(), testMap->name());\r\n        if (errorIsNotFoundInErrorList(expectedError, foundErrors))\r\n        {\r\n            QFAIL(\"No error message found\");\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_MemoryMapValidator::testMemoryRemapHasValidIsPresent_data()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_MemoryMapValidator::testMemoryRemapHasValidIsPresent_data()\r\n{\r\n    QTest::addColumn<QString>(\"isPresent\");\r\n    QTest::addColumn<bool>(\"isValid\");\r\n\r\n    QTest::newRow(\"IsPresent 1 is valid\") << \"1\" << true;\r\n    QTest::newRow(\"IsPresent 1*3-3 is valid\") << \"1*3-3\" << true;\r\n    QTest::newRow(\"IsPresent 2*100 is invalid\") << \"2*100\" << false;\r\n    QTest::newRow(\"IsPresent -14 is invalid\") << \"-14\" << false;\r\n    QTest::newRow(\"Real number isPresent  0.12 is invalid\") << \"0.12\" << false;\r\n    QTest::newRow(\"Text as isPresent is invalid\") << \"test\" << false;\r\n    QTest::newRow(\"String as isPresent is invalid\") << \"\\\"test\\\"\" << false;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_MemoryMapValidator::testMemoryRemapsHaveUniqueRemapStates()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_MemoryMapValidator::testMemoryRemapsHaveUniqueRemapStates()\r\n{\r\n    QFETCH(QString, remapStateOne);\r\n    QFETCH(QString, remapStateTwo);\r\n    QFETCH(QString, remapStateThree);\r\n    QFETCH(bool, isValid);\r\n\r\n    QSharedPointer<RemapState> stateOne (new RemapState(remapStateOne));\r\n    QSharedPointer<RemapState> stateTwo (new RemapState(remapStateTwo));\r\n    QSharedPointer<RemapState> stateThree (new RemapState(remapStateThree));\r\n\r\n    QSharedPointer<QList<QSharedPointer<RemapState> > > remapStates (new QList<QSharedPointer<RemapState> > ());\r\n    remapStates->append(stateOne);\r\n    remapStates->append(stateTwo);\r\n    remapStates->append(stateThree);\r\n\r\n    QSharedPointer<MemoryRemap> remapOne (new MemoryRemap(\"remapOne\", stateOne->name()));\r\n    QSharedPointer<MemoryRemap> remapTwo (new MemoryRemap(\"remapTwo\", stateTwo->name()));\r\n    QSharedPointer<MemoryRemap> remapThree (new MemoryRemap(\"remapThree\", stateThree->name()));\r\n\r\n    QSharedPointer<MemoryMap> testMap (new MemoryMap(\"testMap\"));\r\n    testMap->getMemoryRemaps()->append(remapOne);\r\n    testMap->getMemoryRemaps()->append(remapTwo);\r\n    testMap->getMemoryRemaps()->append(remapThree);\r\n\r\n    QSharedPointer<MemoryMapValidator> validator = createValidator(Document::Revision::Std14,remapStates);\r\n    QCOMPARE(validator->hasValidMemoryRemaps(testMap), isValid);\r\n\r\n    if (!isValid)\r\n    {\r\n        QVector<QString> foundErrors;\r\n        validator->findErrorsIn(foundErrors, testMap, \"test\");\r\n\r\n        QString expectedError = QObject::tr(\"Remap states are not unique for each memory remap within memory map \"\r\n            \"%1\").arg(testMap->name());\r\n        if (errorIsNotFoundInErrorList(expectedError, foundErrors))\r\n        {\r\n            QFAIL(\"No error message found\");\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_MemoryMapValidator::testMemoryRemapsHaveUniqueRemapStates_data()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_MemoryMapValidator::testMemoryRemapsHaveUniqueRemapStates_data()\r\n{\r\n    QTest::addColumn<QString>(\"remapStateOne\");\r\n    QTest::addColumn<QString>(\"remapStateTwo\");\r\n    QTest::addColumn<QString>(\"remapStateThree\");\r\n    QTest::addColumn<bool>(\"isValid\");\r\n\r\n    QTest::newRow(\"Different remapStates are valid\") << \"remap1\" << \"remap2\" << \"remap3\" << true;\r\n    QTest::newRow(\"Similar remapStates are not valid\") << \"remap\" << \"remap\" << \"remap\" << false;\r\n    QTest::newRow(\"Similar remapStates are not valid\") << \"remap1\" << \"remap\" << \"remap\" << false;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_MemoryMapValidator::testHasValidMemoryRemapModeRefs2022()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_MemoryMapValidator::testHasValidMemoryRemapModeRefs2022()\r\n{\r\n    QFETCH(QString, modeRef1);\r\n    QFETCH(int, priority1);\r\n    QFETCH(QString, modeRef2);\r\n    QFETCH(int, priority2);\r\n    QFETCH(QString, modeRef3);\r\n    QFETCH(int, priority3);\r\n    QFETCH(QString, invalidRemapName);\r\n    QFETCH(bool, refsAreValid);\r\n    QFETCH(bool, prioritiesAreValid);\r\n\r\n\r\n    QSharedPointer<ModeReference> testModeRef1(new ModeReference());\r\n    QSharedPointer<ModeReference> testModeRef2(new ModeReference());\r\n    QSharedPointer<ModeReference> testModeRef3(new ModeReference());\r\n    \r\n    testModeRef1->setReference(modeRef1);\r\n    testModeRef2->setReference(modeRef2);\r\n    testModeRef3->setReference(modeRef3);\r\n    \r\n    testModeRef1->setPriority(priority1);\r\n    testModeRef2->setPriority(priority2);\r\n    testModeRef3->setPriority(priority3);\r\n\r\n    QSharedPointer<MemoryRemap> remap1(new MemoryRemap(\"testRemap1\"));\r\n    QSharedPointer<MemoryRemap> remap2(new MemoryRemap(\"testRemap2\"));\r\n\r\n    remap1->getModeReferences()->append(testModeRef1);\r\n\r\n    remap2->getModeReferences()->append(testModeRef2);\r\n    remap2->getModeReferences()->append(testModeRef3);\r\n\r\n    QSharedPointer<MemoryMap> testMap(new MemoryMap(\"testMap\"));\r\n    testMap->getMemoryRemaps()->append(remap1);\r\n    testMap->getMemoryRemaps()->append(remap2);\r\n\r\n    QSharedPointer<MemoryMapValidator> validator = createValidator(Document::Revision::Std22);\r\n\r\n    QCOMPARE(validator->hasValidMemoryRemaps(testMap), refsAreValid && prioritiesAreValid);\r\n\r\n    if (!(refsAreValid && prioritiesAreValid))\r\n    {\r\n        auto invalidRemapIt = std::find_if(testMap->getMemoryRemaps()->begin(), testMap->getMemoryRemaps()->end(),\r\n            [&invalidRemapName](QSharedPointer<MemoryRemap> remap)\r\n            {\r\n                return remap->name() == invalidRemapName;\r\n            });\r\n\r\n        if (invalidRemapIt == testMap->getMemoryRemaps()->end())\r\n        {\r\n            QFAIL(\"Unknown remap name.\");\r\n        }\r\n\r\n        QStringList foundErrors;\r\n        validator->findErrorsIn(foundErrors, testMap, \"memory map testMap\");\r\n\r\n        QString expectedError;\r\n        \r\n        if (!refsAreValid)\r\n        {\r\n            if (auto ref = (*invalidRemapIt)->getModeReferences()->first()->getReference(); ref.isEmpty())\r\n            {\r\n                expectedError = QObject::tr(\"Empty mode reference value set for memory remap %1 in memory map testMap\").arg(invalidRemapName);\r\n            }\r\n            else\r\n            {\r\n                expectedError = QObject::tr(\"Duplicate mode reference value %1 set for memory remap %2 in memory map testMap\").arg(ref).arg(invalidRemapName);\r\n            }\r\n        }\r\n        else if (!prioritiesAreValid)\r\n        {\r\n            expectedError = QObject::tr(\"Duplicate mode reference priority set for memory remap %1 in memory map testMap\").arg(invalidRemapName);\r\n        }\r\n\r\n        if (errorIsNotFoundInErrorList(expectedError, foundErrors))\r\n        {\r\n            QFAIL(\"No error message found\");\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_MemoryMapValidator::testHasValidMemoryRemapModeRefs2022_data()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_MemoryMapValidator::testHasValidMemoryRemapModeRefs2022_data()\r\n{\r\n    QTest::addColumn<QString>(\"modeRef1\");\r\n    QTest::addColumn<int>(\"priority1\");\r\n    QTest::addColumn<QString>(\"modeRef2\");\r\n    QTest::addColumn<int>(\"priority2\");\r\n    QTest::addColumn<QString>(\"modeRef3\");\r\n    QTest::addColumn<int>(\"priority3\");\r\n    QTest::addColumn<QString>(\"invalidRemapName\");\r\n    QTest::addColumn<bool>(\"refsAreValid\");\r\n    QTest::addColumn<bool>(\"prioritiesAreValid\");\r\n\r\n    QTest::addRow(\"Missing mode ref is invalid\") << \"\" << 0 << \"testmode2\" << 2 << \"testmode3\" << 3 << \"testRemap1\" << false << true;\r\n    QTest::addRow(\"Duplicate mode ref is invalid\") << \"testmode\" << 0 << \"testmode\" << 1 << \"testmode3\" << 3 << \"testRemap2\" << false << true;\r\n    QTest::addRow(\"Duplicate mode ref priority in same remap is valid\") << \"testmode1\" << 0 << \"testmode2\" << 1 << \"testmode3\" << 1 << \"testRemap2\" << true << true;\r\n    QTest::addRow(\"Duplicate mode ref priority in different remaps is valid\") << \"testmode1\" << 1 << \"testmode2\" << 1 << \"testmode3\" << 3 << \"\" << true << true;\r\n    QTest::addRow(\"Unique mode refs is valid\") << \"testmode1\" << 0 << \"testmode2\" << 1 << \"testmode3\" << 2 << \"\" << true << true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_MemoryMapValidator::testMemoryMapStructureIsValid2022()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_MemoryMapValidator::testMemoryMapStructureIsValid2022()\r\n{\r\n    QSharedPointer<MemoryMap> testMap(new MemoryMap(\"testMap\"));\r\n    testMap->setMemoryMapDefinitionReference(\"memMapDef\");\r\n    testMap->setTypeDefinitionsReference(\"testTypeDefinitions\");\r\n\r\n    QSharedPointer<AddressBlock> testBlock(new AddressBlock(\"testblock\", \"0\"));\r\n    testMap->getMemoryBlocks()->append(testBlock);\r\n\r\n    QSharedPointer<MemoryMapValidator> validator = createValidator(Document::Revision::Std22);\r\n\r\n    QStringList errors;\r\n\r\n    QString expectedError = QObject::tr(\"Memory map %1 in %2 cannot contain both a definition reference\"\r\n        \" and memory blocks, remaps or definitions for address unit bits or shared values.\").arg(testMap->name())\r\n        .arg(\"memory map testMap\");\r\n\r\n    validator->findErrorsIn(errors, testMap, \"test\");\r\n    QCOMPARE(validator->hasValidStructure(testMap), false); // definition ref and address block\r\n    QVERIFY(errors.contains(expectedError));\r\n\r\n    errors.clear();\r\n    testMap->getMemoryBlocks()->clear();\r\n\r\n    validator->findErrorsIn(errors, testMap, \"test\");\r\n    QCOMPARE(validator->hasValidStructure(testMap), true);\r\n    QVERIFY(errors.contains(expectedError) == false);\r\n\r\n    errors.clear();\r\n    testMap->setAddressUnitBits(\"8\");\r\n\r\n    validator->findErrorsIn(errors, testMap, \"test\"); // definition ref and address unit bits\r\n    QCOMPARE(validator->hasValidStructure(testMap), false);\r\n    QVERIFY(errors.contains(expectedError));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_MemoryMapValidator::testRemapStructureIsValid2022()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_MemoryMapValidator::testRemapStructureIsValid2022()\r\n{\r\n    QSharedPointer<MemoryMap> testMap(new MemoryMap(\"testMap\"));\r\n\r\n    QSharedPointer<MemoryRemap> testRemap(new MemoryRemap(\"remap\"));\r\n    testRemap->setMemoryRemapDefinitionReference(\"remapDef\");\r\n    testRemap->setTypeDefinitionsReference(\"testTypeDefinitions\");\r\n\r\n    QSharedPointer<AddressBlock> testBlock(new AddressBlock(\"testblock\", \"0\"));\r\n    testRemap->getMemoryBlocks()->append(testBlock);\r\n\r\n    testMap->getMemoryRemaps()->append(testRemap);\r\n\r\n    QSharedPointer<MemoryMapValidator> validator = createValidator(Document::Revision::Std22);\r\n\r\n    QStringList errors;\r\n\r\n    QString expectedError = QObject::tr(\"Memory remap %1 in %2 cannot contain both a definition reference\"\r\n        \" and address blocks / subspace maps.\").arg(testRemap->name()).arg(\"memory map testMap\");\r\n\r\n    validator->findErrorsIn(errors, testMap, \"test\");\r\n    QCOMPARE(validator->remapHasValidStructure(testRemap), false); // definition ref and address block\r\n    QVERIFY(errors.contains(expectedError));\r\n\r\n    errors.clear();\r\n    testRemap->getMemoryBlocks()->clear();\r\n\r\n    validator->findErrorsIn(errors, testMap, \"test\");\r\n    QCOMPARE(validator->remapHasValidStructure(testRemap), true);\r\n    QVERIFY(!errors.contains(expectedError));\r\n\r\n    errors.clear();\r\n    testRemap->setMemoryRemapDefinitionReference(\"\");\r\n    testRemap->setTypeDefinitionsReference(\"\");\r\n\r\n    testRemap->getMemoryBlocks()->append(testBlock);\r\n\r\n    validator->findErrorsIn(errors, testMap, \"test\");\r\n    QCOMPARE(validator->remapHasValidStructure(testRemap), true);\r\n    QVERIFY(!errors.contains(expectedError));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_MemoryMapValidator::errorIsNotFoundInErrorList()\r\n//-----------------------------------------------------------------------------\r\nbool tst_MemoryMapValidator::errorIsNotFoundInErrorList(QString const& expectedError, QVector<QString> errorList)\r\n{\r\n    if (!errorList.contains(expectedError))\r\n    {\r\n        qDebug() << \"The following error:\" << Qt::endl << expectedError << Qt::endl << \"was not found in error list:\";\r\n        foreach(QString error, errorList)\r\n        {\r\n            qDebug() << error;\r\n        }\r\n        return true;\r\n    }\r\n\r\n    return false;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_MemoryMapValidator::errorIsNotFoundInErrorList()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<MemoryMapValidator> tst_MemoryMapValidator::createValidator(\r\n    Document::Revision docRevision, QSharedPointer<QList<QSharedPointer<RemapState> > > remapStates /*= QSharedPointer<QList<QSharedPointer<RemapState> > >()*/)\r\n{\r\n    QSharedPointer<ExpressionParser> parser(new SystemVerilogExpressionParser());\r\n    QSharedPointer<ParameterValidator> parameterValidator (new ParameterValidator(parser,\r\n        QSharedPointer<QList<QSharedPointer<Choice> > > (), docRevision));\r\n    QSharedPointer<EnumeratedValueValidator> enumValidator (new EnumeratedValueValidator(parser));\r\n    QSharedPointer<FieldValidator> fieldValidator (new FieldValidator(parser, enumValidator, parameterValidator));\r\n    QSharedPointer<RegisterValidator> registerValidator (\r\n        new RegisterValidator(parser, fieldValidator, parameterValidator));\r\n    QSharedPointer<RegisterFileValidator> registerFileValidator (\r\n        new RegisterFileValidator(parser, registerValidator, parameterValidator, docRevision));\r\n    QSharedPointer<AddressBlockValidator> addressBlockValidator (\r\n        new AddressBlockValidator(parser, registerValidator, registerFileValidator, parameterValidator, docRevision));\r\n\r\n    QSharedPointer<SubspaceMapValidator> subSpaceValidator(new SubspaceMapValidator(parser, parameterValidator, docRevision));\r\n\r\n    VLNV componentVlnv(QString(\"ipxact:component\"), QString(\"testvendor\"), QString(\"testlib\"), QString(\"testname\"), QString(\"v1\"));\r\n\r\n    QSharedPointer<Component> testComponent(new Component(componentVlnv, docRevision));\r\n    testComponent->setRemapStates(remapStates);\r\n\r\n    QSharedPointer<MemoryMapValidator> validator(new MemoryMapValidator(parser, addressBlockValidator, subSpaceValidator, testComponent));\r\n\r\n    return validator;\r\n}\r\nQTEST_APPLESS_MAIN(tst_MemoryMapValidator)\r\n\r\n#include \"tst_MemoryMapValidator.moc\"\r\n"
  },
  {
    "path": "tests/IPXACTmodels/Component/tst_MemoryMapValidator.pri",
    "content": "# ----------------------------------------------------\r\n# This file is generated by the Qt Visual Studio Tools.\r\n# ------------------------------------------------------\r\n\r\nSOURCES += ./tst_MemoryMapValidator.cpp \r\n\t"
  },
  {
    "path": "tests/IPXACTmodels/Component/tst_MemoryMapValidator.pro",
    "content": "#-----------------------------------------------------------------------------\r\n# File: tst_MemoryMapValidator.pro\r\n#-----------------------------------------------------------------------------\r\n# Project: Kactus 2\r\n# Author: Mikko Teuho\r\n# Date: 25.11.2015\r\n#\r\n# Description:\r\n# Qt project file template for running unit tests for MemoryMapValidator.\r\n#-----------------------------------------------------------------------------\r\n\r\nTEMPLATE = app\r\n\r\nTARGET = tst_MemoryMapValidator\r\n\r\nQT += core gui xml testlib\r\n\r\nCONFIG += c++11 testcase console\r\n\r\nlinux-g++ | linux-g++-64 | linux-g++-32 {\r\n LIBS += -L../../../executable \\\r\n     -lIPXACTmodels -lKactusAPI\r\n}\r\nwin64 | win32 {\r\n LIBS += -L../../../executable \\\r\n     -lIPXACTmodelsd -lKactusAPId\r\n}\r\n\r\nINCLUDEPATH += $$DESTDIR\r\nINCLUDEPATH += ../../../\r\n\r\nDEPENDPATH += .\r\nDEPENDPATH += ../../../\r\n\r\nOBJECTS_DIR += $$DESTDIR\r\n\r\nMOC_DIR += ./generatedFiles\r\nUI_DIR += ./generatedFiles\r\nRCC_DIR += ./generatedFiles\r\ninclude(tst_MemoryMapValidator.pri)\r\n"
  },
  {
    "path": "tests/IPXACTmodels/Component/tst_MemoryMapWriter.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: tst_MemoryMapWriter.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: <Name>\r\n// Date: <Date in the format dd.mm.yyyy>\r\n//\r\n// Description:\r\n// Unit test for class MemoryMapWriter.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include <IPXACTmodels/Component/MemoryMapWriter.h>\r\n#include <IPXACTmodels/Component/MemoryMap.h>\r\n#include <IPXACTmodels/Component/MemoryRemap.h>\r\n\r\n#include <IPXACTmodels/Component/AddressBlock.h>\r\n#include <IPXACTmodels/Component/Register.h>\r\n#include <IPXACTmodels/Component/RegisterFile.h>\r\n#include <IPXACTmodels/Component/Field.h>\r\n#include <IPXACTmodels/Component/ModeReference.h>\r\n\r\n#include <IPXACTmodels/common/GenericVendorExtension.h>\r\n#include <IPXACTmodels/common/Document.h>\r\n\r\n#include <QtTest>\r\n\r\nclass tst_MemoryMapWriter : public QObject\r\n{\r\n    Q_OBJECT\r\n\r\npublic:\r\n    tst_MemoryMapWriter();\r\n\r\nprivate slots:\r\n\r\n    void initTestCase();\r\n    void cleanupTestCase();\r\n    void init();\r\n    void cleanup();\r\n\r\n    void writeSimpleMemoryMap();\r\n    void writeIsPresent();\r\n    void writeAddressBlocks();\r\n\r\n    void write2022MemoryMap();\r\n\r\n    void writeSimpleMemoryRemap();\r\n    void writeMemoryRemapAddressBlocks();\r\n\r\n    void writeMemoryRemap2022();\r\n\r\n    void writeAddressUnitBits();\r\n    void writeShared();\r\n\r\n    void writeVendorExtensions();\r\n\r\nprivate:\r\n\r\n    QSharedPointer<MemoryMap> testMemoryMap_;\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_MemoryMapWriter::tst_MemoryMapWriter()\r\n//-----------------------------------------------------------------------------\r\ntst_MemoryMapWriter::tst_MemoryMapWriter():\r\ntestMemoryMap_()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_MemoryMapWriter::initTestCase()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_MemoryMapWriter::initTestCase()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_MemoryMapWriter::cleanupTestCase()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_MemoryMapWriter::cleanupTestCase()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_MemoryMapWriter::init()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_MemoryMapWriter::init()\r\n{\r\n    testMemoryMap_ = QSharedPointer<MemoryMap>(new MemoryMap(\"testMemoryMap\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_MemoryMapWriter::cleanup()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_MemoryMapWriter::cleanup()\r\n{\r\n    testMemoryMap_.clear();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_MemoryMapWriter::writeSimpleMemoryMap()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_MemoryMapWriter::writeSimpleMemoryMap()\r\n{\r\n    QString output;\r\n    QXmlStreamWriter xmlStreamWriter(&output);\r\n\r\n    testMemoryMap_->setDisplayName(\"displayed\");\r\n    testMemoryMap_->setDescription(\"described\");\r\n\r\n    QString expectedOutput(\r\n        \"<ipxact:memoryMap>\"\r\n            \"<ipxact:name>testMemoryMap</ipxact:name>\"\r\n            \"<ipxact:displayName>displayed</ipxact:displayName>\"\r\n            \"<ipxact:description>described</ipxact:description>\"\r\n        \"</ipxact:memoryMap>\"\r\n        );\r\n\r\n    MemoryMapWriter::writeMemoryMap(xmlStreamWriter, testMemoryMap_, Document::Revision::Std14);\r\n    QCOMPARE(output, expectedOutput);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_MemoryMapWriter::writeIsPresent()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_MemoryMapWriter::writeIsPresent()\r\n{\r\n    QString output;\r\n    QXmlStreamWriter xmlStreamWriter(&output);\r\n\r\n    testMemoryMap_->setIsPresent(\"8/8-1\");\r\n\r\n    QString expectedOutput(\r\n        \"<ipxact:memoryMap>\"\r\n            \"<ipxact:name>testMemoryMap</ipxact:name>\"\r\n            \"<ipxact:isPresent>8/8-1</ipxact:isPresent>\"\r\n        \"</ipxact:memoryMap>\"\r\n        );\r\n\r\n    MemoryMapWriter::writeMemoryMap(xmlStreamWriter, testMemoryMap_, Document::Revision::Std14);\r\n    QCOMPARE(output, expectedOutput);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_MemoryMapWriter::writeAddressBlocks()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_MemoryMapWriter::writeAddressBlocks()\r\n{\r\n    QString output;\r\n    QXmlStreamWriter xmlStreamWriter(&output);\r\n\r\n    QSharedPointer<Field> simpleField(new Field(\"simpleField\"));\r\n    simpleField->setBitOffset(\"fieldOffset\");\r\n    simpleField->setBitWidth(\"fieldWidth\");\r\n\r\n    QSharedPointer<Register> testRegister (new Register(\"testRegister\", \"offset\", \"10\"));\r\n    testRegister->setDisplayName(\"displayed\");\r\n    testRegister->setDescription(\"described\");\r\n    testRegister->getFields()->append(simpleField);\r\n\r\n    QSharedPointer<RegisterFile> containedRegisterFile\r\n        (new RegisterFile(\"contained\", \"containedOffset\", \"containedRange\"));\r\n\r\n    QSharedPointer<AddressBlock> testAddressBlock =\r\n        QSharedPointer<AddressBlock>(new AddressBlock(\"testBlock\", \"StarControl\"));\r\n    testAddressBlock->setRange(\"Kzer-Za\");\r\n    testAddressBlock->setWidth(\"Kohr-Ah\");\r\n    testAddressBlock->getRegisterData()->append(testRegister);\r\n    testAddressBlock->getRegisterData()->append(containedRegisterFile);\r\n\r\n    testMemoryMap_->getMemoryBlocks()->append(testAddressBlock);\r\n\r\n    QString expectedOutput(\r\n        \"<ipxact:memoryMap>\"\r\n            \"<ipxact:name>testMemoryMap</ipxact:name>\"\r\n            \"<ipxact:addressBlock>\"\r\n                \"<ipxact:name>testBlock</ipxact:name>\"\r\n                \"<ipxact:baseAddress>StarControl</ipxact:baseAddress>\"\r\n                \"<ipxact:range>Kzer-Za</ipxact:range>\"\r\n                \"<ipxact:width>Kohr-Ah</ipxact:width>\"\r\n                \"<ipxact:register>\"\r\n                    \"<ipxact:name>testRegister</ipxact:name>\"\r\n                    \"<ipxact:displayName>displayed</ipxact:displayName>\"\r\n                    \"<ipxact:description>described</ipxact:description>\"\r\n                    \"<ipxact:addressOffset>offset</ipxact:addressOffset>\"\r\n                    \"<ipxact:size>10</ipxact:size>\"\r\n                    \"<ipxact:field>\"\r\n                        \"<ipxact:name>simpleField</ipxact:name>\"\r\n                        \"<ipxact:bitOffset>fieldOffset</ipxact:bitOffset>\"\r\n                        \"<ipxact:bitWidth>fieldWidth</ipxact:bitWidth>\"\r\n                    \"</ipxact:field>\"\r\n                \"</ipxact:register>\"\r\n                \"<ipxact:registerFile>\"\r\n                    \"<ipxact:name>contained</ipxact:name>\"\r\n                    \"<ipxact:addressOffset>containedOffset</ipxact:addressOffset>\"\r\n                    \"<ipxact:range>containedRange</ipxact:range>\"\r\n                \"</ipxact:registerFile>\"\r\n            \"</ipxact:addressBlock>\"\r\n        \"</ipxact:memoryMap>\"\r\n        );\r\n\r\n    MemoryMapWriter::writeMemoryMap(xmlStreamWriter, testMemoryMap_, Document::Revision::Std14);\r\n    QCOMPARE(output, expectedOutput);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_MemoryMapWriter::write2022MemoryMap()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_MemoryMapWriter::write2022MemoryMap()\r\n{\r\n    QString output;\r\n    QXmlStreamWriter xmlStreamWriter(&output);\r\n\r\n    testMemoryMap_->setDisplayName(\"displayed\");\r\n    testMemoryMap_->setDescription(\"described\");\r\n    testMemoryMap_->setIsPresent(\"false\"); // don't write presence\r\n    testMemoryMap_->setMemoryMapDefinitionReference(\"memMapDefinition\");\r\n    testMemoryMap_->setTypeDefinitionsReference(\"testTypeDefs\");\r\n\r\n    QString expectedOutput(\r\n        \"<ipxact:memoryMap>\"\r\n            \"<ipxact:name>testMemoryMap</ipxact:name>\"\r\n            \"<ipxact:displayName>displayed</ipxact:displayName>\"\r\n            \"<ipxact:description>described</ipxact:description>\"\r\n            \"<ipxact:memoryMapDefinitionRef typeDefinitions=\\\"testTypeDefs\\\">memMapDefinition</ipxact:memoryMapDefinitionRef>\"\r\n        \"</ipxact:memoryMap>\"\r\n        );\r\n\r\n    MemoryMapWriter::writeMemoryMap(xmlStreamWriter, testMemoryMap_, Document::Revision::Std22);\r\n    QCOMPARE(output, expectedOutput);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_MemoryMapWriter::writeMemoryRemaps()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_MemoryMapWriter::writeSimpleMemoryRemap()\r\n{\r\n    QString output;\r\n    QXmlStreamWriter xmlStreamWriter(&output);\r\n\r\n    QSharedPointer<MemoryRemap> testMemoryRemap (new MemoryRemap(\"memoryRemap\", QString(\"remappedState\")));\r\n    testMemoryRemap->setDisplayName(\"displayedRemap\");\r\n    testMemoryRemap->setDescription(\"describedRemap\");\r\n    testMemoryRemap->setIsPresent(\"1\");\r\n\r\n    testMemoryMap_->getMemoryRemaps()->append(testMemoryRemap);\r\n\r\n    QString expectedOutput(\r\n        \"<ipxact:memoryMap>\"\r\n            \"<ipxact:name>testMemoryMap</ipxact:name>\"\r\n            \"<ipxact:memoryRemap state=\\\"remappedState\\\">\"\r\n                \"<ipxact:name>memoryRemap</ipxact:name>\"\r\n                \"<ipxact:displayName>displayedRemap</ipxact:displayName>\"\r\n                \"<ipxact:description>describedRemap</ipxact:description>\"\r\n                \"<ipxact:isPresent>1</ipxact:isPresent>\"\r\n            \"</ipxact:memoryRemap>\"\r\n        \"</ipxact:memoryMap>\"\r\n        );\r\n\r\n    MemoryMapWriter::writeMemoryMap(xmlStreamWriter, testMemoryMap_, Document::Revision::Std14);\r\n    QCOMPARE(output, expectedOutput);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_MemoryMapWriter::writeMemoryRemapAddressBlocks()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_MemoryMapWriter::writeMemoryRemapAddressBlocks()\r\n{\r\n    QString output;\r\n    QXmlStreamWriter xmlStreamWriter(&output);\r\n\r\n    QSharedPointer<Field> simpleField(new Field(\"simpleField\"));\r\n    simpleField->setBitOffset(\"fieldOffset\");\r\n    simpleField->setBitWidth(\"fieldWidth\");\r\n\r\n    QSharedPointer<Register> testRegister (new Register(\"testRegister\", \"offset\", \"10\"));\r\n    testRegister->setDisplayName(\"displayed\");\r\n    testRegister->setDescription(\"described\");\r\n    testRegister->getFields()->append(simpleField);\r\n\r\n    QSharedPointer<RegisterFile> containedRegisterFile\r\n        (new RegisterFile(\"contained\", \"containedOffset\", \"containedRange\"));\r\n\r\n    QSharedPointer<AddressBlock> testAddressBlock =\r\n        QSharedPointer<AddressBlock>(new AddressBlock(\"testBlock\", \"StarControl\"));\r\n    testAddressBlock->setRange(\"Kzer-Za\");\r\n    testAddressBlock->setWidth(\"Kohr-Ah\");\r\n    testAddressBlock->getRegisterData()->append(testRegister);\r\n    testAddressBlock->getRegisterData()->append(containedRegisterFile);\r\n\r\n    QSharedPointer<MemoryRemap> testMemoryRemap (new MemoryRemap(\"memoryRemap\", QString(\"remappedState\")));\r\n    testMemoryRemap->getMemoryBlocks()->append(testAddressBlock);\r\n\r\n    testMemoryMap_->getMemoryRemaps()->append(testMemoryRemap);\r\n\r\n    QString expectedOutput(\r\n        \"<ipxact:memoryMap>\"\r\n            \"<ipxact:name>testMemoryMap</ipxact:name>\"\r\n            \"<ipxact:memoryRemap state=\\\"remappedState\\\">\"\r\n                \"<ipxact:name>memoryRemap</ipxact:name>\"\r\n                \"<ipxact:addressBlock>\"\r\n                    \"<ipxact:name>testBlock</ipxact:name>\"\r\n                    \"<ipxact:baseAddress>StarControl</ipxact:baseAddress>\"\r\n                    \"<ipxact:range>Kzer-Za</ipxact:range>\"\r\n                    \"<ipxact:width>Kohr-Ah</ipxact:width>\"\r\n                    \"<ipxact:register>\"\r\n                        \"<ipxact:name>testRegister</ipxact:name>\"\r\n                        \"<ipxact:displayName>displayed</ipxact:displayName>\"\r\n                        \"<ipxact:description>described</ipxact:description>\"\r\n                        \"<ipxact:addressOffset>offset</ipxact:addressOffset>\"\r\n                        \"<ipxact:size>10</ipxact:size>\"\r\n                        \"<ipxact:field>\"\r\n                            \"<ipxact:name>simpleField</ipxact:name>\"\r\n                            \"<ipxact:bitOffset>fieldOffset</ipxact:bitOffset>\"\r\n                            \"<ipxact:bitWidth>fieldWidth</ipxact:bitWidth>\"\r\n                        \"</ipxact:field>\"\r\n                    \"</ipxact:register>\"\r\n                    \"<ipxact:registerFile>\"\r\n                        \"<ipxact:name>contained</ipxact:name>\"\r\n                        \"<ipxact:addressOffset>containedOffset</ipxact:addressOffset>\"\r\n                        \"<ipxact:range>containedRange</ipxact:range>\"\r\n                    \"</ipxact:registerFile>\"\r\n                \"</ipxact:addressBlock>\"\r\n            \"</ipxact:memoryRemap>\"\r\n        \"</ipxact:memoryMap>\"\r\n        );\r\n\r\n    MemoryMapWriter::writeMemoryMap(xmlStreamWriter, testMemoryMap_, Document::Revision::Std14);\r\n    QCOMPARE(output, expectedOutput);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_MemoryMapWriter::writeMemoryRemap2022()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_MemoryMapWriter::writeMemoryRemap2022()\r\n{\r\n    QString output;\r\n    QXmlStreamWriter xmlStreamWriter(&output);\r\n\r\n    QSharedPointer<MemoryRemap> testMemoryRemap (new MemoryRemap(\"memoryRemap\", QString(\"remappedState\"))); // don't write state\r\n    testMemoryRemap->setDisplayName(\"displayedRemap\");\r\n    testMemoryRemap->setDescription(\"describedRemap\");\r\n    testMemoryRemap->setIsPresent(\"1\"); // don't write presence\r\n\r\n    testMemoryRemap->setMemoryRemapDefinitionReference(\"remapDef\");\r\n    testMemoryRemap->setTypeDefinitionsReference(\"testTypeDefs\");\r\n\r\n    QSharedPointer<ModeReference> modeRef1(new ModeReference());\r\n    modeRef1->setPriority(0);\r\n    modeRef1->setReference(\"testMode\");\r\n\r\n    QSharedPointer<ModeReference> modeRef2(new ModeReference());\r\n    modeRef2->setPriority(1);\r\n    modeRef2->setReference(\"testMode2\");\r\n\r\n    testMemoryRemap->getModeReferences()->append(modeRef1);\r\n    testMemoryRemap->getModeReferences()->append(modeRef2);\r\n\r\n    testMemoryMap_->getMemoryRemaps()->append(testMemoryRemap);\r\n\r\n    QString expectedOutput(\r\n        \"<ipxact:memoryMap>\"\r\n            \"<ipxact:name>testMemoryMap</ipxact:name>\"\r\n            \"<ipxact:memoryRemap>\"\r\n                \"<ipxact:name>memoryRemap</ipxact:name>\"\r\n                \"<ipxact:displayName>displayedRemap</ipxact:displayName>\"\r\n                \"<ipxact:description>describedRemap</ipxact:description>\"\r\n                \"<ipxact:modeRef priority=\\\"0\\\">testMode</ipxact:modeRef>\"\r\n                \"<ipxact:modeRef priority=\\\"1\\\">testMode2</ipxact:modeRef>\"\r\n                \"<ipxact:remapDefinitionRef typeDefinitions=\\\"testTypeDefs\\\">remapDef</ipxact:remapDefinitionRef>\"\r\n            \"</ipxact:memoryRemap>\"\r\n        \"</ipxact:memoryMap>\"\r\n        );\r\n\r\n    MemoryMapWriter::writeMemoryMap(xmlStreamWriter, testMemoryMap_, Document::Revision::Std22);\r\n    QCOMPARE(output, expectedOutput);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_MemoryMapWriter::writeAddressUnitBits()\r\n//-----------------------------------------------------------------------------\r\n void tst_MemoryMapWriter::writeAddressUnitBits()\r\n {\r\n     QString output;\r\n     QXmlStreamWriter xmlStreamWriter(&output);\r\n\r\n     testMemoryMap_->setAddressUnitBits(\"8\");\r\n\r\n     QString expectedOutput(\r\n         \"<ipxact:memoryMap>\"\r\n             \"<ipxact:name>testMemoryMap</ipxact:name>\"\r\n             \"<ipxact:addressUnitBits>8</ipxact:addressUnitBits>\"\r\n         \"</ipxact:memoryMap>\"\r\n         );\r\n\r\n      MemoryMapWriter::writeMemoryMap(xmlStreamWriter, testMemoryMap_, Document::Revision::Std14);\r\n     QCOMPARE(output, expectedOutput);\r\n }\r\n\r\n //-----------------------------------------------------------------------------\r\n // Function: tst_MemoryMapWriter::writeShared()\r\n //-----------------------------------------------------------------------------\r\n void tst_MemoryMapWriter::writeShared()\r\n {\r\n     QString output;\r\n     QXmlStreamWriter xmlStreamWriter(&output);\r\n\r\n     testMemoryMap_->setShared(true);\r\n\r\n     QString expectedOutput(\r\n         \"<ipxact:memoryMap>\"\r\n             \"<ipxact:name>testMemoryMap</ipxact:name>\"\r\n             \"<ipxact:shared>yes</ipxact:shared>\"\r\n         \"</ipxact:memoryMap>\"\r\n         );\r\n\r\n      MemoryMapWriter::writeMemoryMap(xmlStreamWriter, testMemoryMap_, Document::Revision::Std14);\r\n     QCOMPARE(output, expectedOutput);\r\n }\r\n\r\n //-----------------------------------------------------------------------------\r\n // Function: tst_MemoryMapWriter::writeVendorExtensions()\r\n //-----------------------------------------------------------------------------\r\n void tst_MemoryMapWriter::writeVendorExtensions()\r\n {\r\n     QString output;\r\n     QXmlStreamWriter xmlStreamWriter(&output);\r\n\r\n     QDomDocument document;\r\n     QDomElement extensionNode = document.createElement(\"testExtension\");\r\n     extensionNode.setAttribute(\"testExtensionAttribute\", \"extension\");\r\n     extensionNode.appendChild(document.createTextNode(\"testValue\"));\r\n\r\n     QSharedPointer<GenericVendorExtension> testExtension(new GenericVendorExtension(extensionNode));\r\n\r\n     testMemoryMap_->getVendorExtensions()->append(testExtension);\r\n\r\n     QString expectedOutput(\r\n         \"<ipxact:memoryMap>\"\r\n             \"<ipxact:name>testMemoryMap</ipxact:name>\"\r\n             \"<ipxact:vendorExtensions>\"\r\n                \"<testExtension testExtensionAttribute=\\\"extension\\\">testValue</testExtension>\"\r\n             \"</ipxact:vendorExtensions>\"\r\n         \"</ipxact:memoryMap>\"\r\n         );\r\n\r\n      MemoryMapWriter::writeMemoryMap(xmlStreamWriter, testMemoryMap_, Document::Revision::Std14);\r\n     QCOMPARE(output, expectedOutput);\r\n }\r\n\r\nQTEST_APPLESS_MAIN(tst_MemoryMapWriter)\r\n\r\n#include \"tst_MemoryMapWriter.moc\"\r\n"
  },
  {
    "path": "tests/IPXACTmodels/Component/tst_MemoryMapWriter.pri",
    "content": "# ----------------------------------------------------\r\n# This file is generated by the Qt Visual Studio Tools.\r\n# ------------------------------------------------------\r\n\r\nSOURCES += ./tst_MemoryMapWriter.cpp \r\n"
  },
  {
    "path": "tests/IPXACTmodels/Component/tst_MemoryMapWriter.pro",
    "content": "#-----------------------------------------------------------------------------\r\n# File: tst_MemoryMapWriter.pro\r\n#-----------------------------------------------------------------------------\r\n# Project: Kactus 2\r\n# Author: Mikko Teuho\r\n# Date: 30.09.2015\r\n#\r\n# Description:\r\n# Qt project file template for running unit tests for MemoryMapWriter.\r\n#-----------------------------------------------------------------------------\r\n\r\nTEMPLATE = app\r\n\r\nTARGET = tst_MemoryMapWriter\r\n\r\nQT += core xml testlib\r\nQT -= gui\r\n\r\nCONFIG += c++11 testcase console\r\n\r\nlinux-g++ | linux-g++-64 | linux-g++-32 {\r\n LIBS += -L../../../executable \\\r\n     -lIPXACTmodels\r\n}\r\nwin64 | win32 {\r\n LIBS += -L../../../executable \\\r\n     -lIPXACTmodelsd\r\n}\r\n\r\nINCLUDEPATH += $$DESTDIR\r\nINCLUDEPATH += ../../../\r\n\r\nDEPENDPATH += .\r\nDEPENDPATH += ../../../\r\n\r\nOBJECTS_DIR += $$DESTDIR\r\n\r\nMOC_DIR += ./generatedFiles\r\nUI_DIR += ./generatedFiles\r\nRCC_DIR += ./generatedFiles\r\ninclude(tst_MemoryMapWriter.pri)\r\n"
  },
  {
    "path": "tests/IPXACTmodels/Component/tst_ModeReader.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: tst_ModeReader.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Esko Pekkarinen\n// Date: 03.08.2023\n//\n// Description:\n// Unit test for class ModeReader.\n//-----------------------------------------------------------------------------\n\n#include <IPXACTmodels/Component/Mode.h>\n#include <IPXACTmodels/Component/ModeReader.h>\n#include <IPXACTmodels/common/VendorExtension.h>\n\n#include <QtTest>\n\nclass tst_ModeReader : public QObject\n{\n    Q_OBJECT\n\npublic:\n    tst_ModeReader();\n\nprivate slots:\n\n    void testReadNameGroup();\n    \n    void testReadCondition();\n\n    void testReadPortSlices();\n\n    void testReadFieldSlices();\n\n};\n\n//-----------------------------------------------------------------------------\n// Function: tst_ModeReader::tst_ModeReader()\n//-----------------------------------------------------------------------------\ntst_ModeReader::tst_ModeReader()\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_ModeReader::testReadNameGroup()\n//-----------------------------------------------------------------------------\nvoid tst_ModeReader::testReadNameGroup()\n{\n    QString documentContent(\n        \"<ipxact:mode>\"\n            \"<ipxact:name>testMode</ipxact:name>\"\n            \"<ipxact:displayName>testDisplay</ipxact:displayName>\"\n            \"<ipxact:shortDescription>testShortDescription</ipxact:shortDescription>\"\n            \"<ipxact:description>testDescription</ipxact:description>\"\n        \"</ipxact:mode>\"\n        );\n\n    QDomDocument document;\n    document.setContent(documentContent);\n\n    QDomNode modeNode = document.firstChildElement(\"ipxact:mode\");\n\n    QSharedPointer<Mode> testMode = ModeReader::createModeFrom(modeNode);\n\n    QCOMPARE(testMode->name(), QString(\"testMode\"));\n    QCOMPARE(testMode->displayName(), QString(\"testDisplay\"));\n    QCOMPARE(testMode->shortDescription(), QString(\"testShortDescription\"));\n    QCOMPARE(testMode->description(), QString(\"testDescription\"));\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_ModeReader::testReadCondition()\n//-----------------------------------------------------------------------------\nvoid tst_ModeReader::testReadCondition()\n{\n    QString documentContent(\n        \"<ipxact:mode>\"\n            \"<ipxact:name>testMode</ipxact:name>\"\n            \"<ipxact:condition>1</ipxact:condition>\"\n        \"</ipxact:mode>\"\n    );\n\n    QDomDocument document;\n    document.setContent(documentContent);\n\n    QDomNode modeNode = document.firstChildElement(\"ipxact:mode\");\n\n    QSharedPointer<Mode> testMode = ModeReader::createModeFrom(modeNode);\n\n    QCOMPARE(testMode->getCondition(), QStringLiteral(\"1\"));\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_ModeReader::testReadPortSlices()\n//-----------------------------------------------------------------------------\nvoid tst_ModeReader::testReadPortSlices()\n{\n    QString documentContent(\n        \"<ipxact:mode>\"\n            \"<ipxact:name>testMode</ipxact:name>\"\n            \"<ipxact:portSlice>\"\n                \"<ipxact:name>testSlice</ipxact:name>\"\n                \"<ipxact:displayName>sliceDisplay</ipxact:displayName>\"\n                \"<ipxact:shortDescription>sliceShortDescription</ipxact:shortDescription>\"\n                \"<ipxact:description>sliceDescription</ipxact:description>\"\n                \"<ipxact:portRef portRef=\\\"testRef\\\"/>\"\n                \"<ipxact:partSelect>\"\n                    \"<ipxact:range>\"\n                        \"<ipxact:left>7</ipxact:left>\"\n                        \"<ipxact:right>0</ipxact:right>\"\n                    \"</ipxact:range>\"\n                \"</ipxact:partSelect>\"\n            \"</ipxact:portSlice>\"\n            \"<ipxact:portSlice>\"\n                \"<ipxact:name>lastSlice</ipxact:name>\"\n            \"</ipxact:portSlice>\"\n        \"</ipxact:mode>\"\n    );\n\n    QDomDocument document;\n    document.setContent(documentContent);\n\n    QDomNode modeNode = document.firstChildElement(\"ipxact:mode\");\n\n    QSharedPointer<Mode> testMode = ModeReader::createModeFrom(modeNode);\n\n    QCOMPARE(testMode->getPortSlices()->count(), 2);\n    auto portSlice = testMode->getPortSlices()->first();\n\n    QCOMPARE(portSlice->name(), QString(\"testSlice\"));\n    QCOMPARE(portSlice->displayName(), QString(\"sliceDisplay\"));\n    QCOMPARE(portSlice->shortDescription(), QString(\"sliceShortDescription\"));\n    QCOMPARE(portSlice->description(), QString(\"sliceDescription\"));\n    QCOMPARE(portSlice->getPortRef(), QString(\"testRef\"));\n\n    auto partSelect = portSlice->getPartSelect();\n    QVERIFY(partSelect != nullptr);\n\n    QCOMPARE(partSelect->getLeftRange(), QString(\"7\"));\n    QCOMPARE(partSelect->getRightRange(), QString(\"0\"));\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_ModeReader::testReadFieldSlices()\n//-----------------------------------------------------------------------------\nvoid tst_ModeReader::testReadFieldSlices()\n{\n        QString documentContent(\n        \"<ipxact:mode>\"\n            \"<ipxact:name>testMode</ipxact:name>\"\n            \"<ipxact:fieldSlice>\"\n                \"<ipxact:name>testSlice</ipxact:name>\"\n                \"<ipxact:displayName>sliceDisplay</ipxact:displayName>\"\n                \"<ipxact:shortDescription>sliceShortDescription</ipxact:shortDescription>\"\n                \"<ipxact:description>sliceDescription</ipxact:description>\"\n                \"<ipxact:memoryMapRef memoryMapRef=\\\"testMMRef\\\"/>\"\n                \"<ipxact:addressBlockRef addressBlockRef=\\\"testABRef\\\"/>\"\n                \"<ipxact:registerRef registerRef=\\\"testRegisterRef\\\"/>\"\n                \"<ipxact:fieldRef fieldRef=\\\"testFieldRef\\\"/>\"\n                \"<ipxact:range>\"\n                    \"<ipxact:left>7</ipxact:left>\"\n                    \"<ipxact:right>0</ipxact:right>\"\n                \"</ipxact:range>\"\n            \"</ipxact:fieldSlice>\"\n             \"<ipxact:fieldSlice>\"\n                 \"<ipxact:name>lastSlice</ipxact:name>\"\n             \"</ipxact:fieldSlice>\"\n        \"</ipxact:mode>\"\n    );\n\n    QDomDocument document;\n    document.setContent(documentContent);\n\n    QDomNode modeNode = document.firstChildElement(\"ipxact:mode\");\n\n    QSharedPointer<Mode> testMode = ModeReader::createModeFrom(modeNode);\n\n    QCOMPARE(testMode->getFieldSlices()->count(), 2);\n    auto fieldSlice = testMode->getFieldSlices()->first();\n\n    QCOMPARE(fieldSlice->name(), QString(\"testSlice\"));\n    QCOMPARE(fieldSlice->displayName(), QString(\"sliceDisplay\"));\n    QCOMPARE(fieldSlice->shortDescription(), QString(\"sliceShortDescription\"));\n    QCOMPARE(fieldSlice->description(), QString(\"sliceDescription\"));\n    QCOMPARE(fieldSlice->getReference(FieldReference::MEMORY_MAP)->reference_, QString(\"testMMRef\"));\n    QCOMPARE(fieldSlice->getReference(FieldReference::ADDRESS_BLOCK)->reference_, QString(\"testABRef\"));\n    QCOMPARE(fieldSlice->getReference(FieldReference::REGISTER)->reference_, QString(\"testRegisterRef\"));\n    QCOMPARE(fieldSlice->getReference(FieldReference::FIELD)->reference_, QString(\"testFieldRef\"));\n    QCOMPARE(fieldSlice->getLeft(), QString(\"7\"));\n    QCOMPARE(fieldSlice->getRight(), QString(\"0\"));\n}\n\n\nQTEST_APPLESS_MAIN(tst_ModeReader)\n\n#include \"tst_ModeReader.moc\"\n"
  },
  {
    "path": "tests/IPXACTmodels/Component/tst_ModeReader.pri",
    "content": "# ----------------------------------------------------\n# This file is generated by the Qt Visual Studio Add-in.\n# ------------------------------------------------------\n\nSOURCES += ./tst_ModeReader.cpp \n"
  },
  {
    "path": "tests/IPXACTmodels/Component/tst_ModeReader.pro",
    "content": "#-----------------------------------------------------------------------------\n# File: tst_ModeReader.pro\n#-----------------------------------------------------------------------------\n# Project: Kactus 2\n# Author: Esko Pekkarinen\n# Date: 03.08.2023\n#\n# Description:\n# Qt project file for running unit tests for Mode reader.\n#-----------------------------------------------------------------------------\n\nTEMPLATE = app\n\nTARGET = tst_ModeReader\n\nQT += core xml testlib\nQT -= gui\n\nCONFIG += c++11 testcase console\n\nlinux-g++ | linux-g++-64 | linux-g++-32 {\n LIBS += -L../../../executable \\\n     -lIPXACTmodels\n}\n\nwin64 | win32 {\n LIBS += -L../../../executable \\\n     -lIPXACTmodelsd\n}\n\nINCLUDEPATH += $$DESTDIR\nINCLUDEPATH += ../../../\n\nDEPENDPATH += .\nDEPENDPATH += ../../../\n\nOBJECTS_DIR += $$DESTDIR\n\nMOC_DIR += ./generatedFiles\nUI_DIR += ./generatedFiles\nRCC_DIR += ./generatedFiles\ninclude(tst_ModeReader.pri)\n"
  },
  {
    "path": "tests/IPXACTmodels/Component/tst_ModeValidator.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: tst_ModeValidator.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Esko Pekkarinen\n// Date: 14.08.2023\n//\n// Description:\n// Unit test for class ModeValidator.\n//-----------------------------------------------------------------------------\n\n#include <IPXACTmodels/Component/Component.h>\n#include <IPXACTmodels/Component/Mode.h>\n#include <IPXACTmodels/Component/MemoryMap.h>\n#include <IPXACTmodels/Component/AddressBlock.h>\n#include <IPXACTmodels/Component/AddressSpace.h>\n#include <IPXACTmodels/Component/Register.h>\n#include <IPXACTmodels/Component/Field.h>\n#include <IPXACTmodels/Component/validators/ModeValidator.h>\n#include <IPXACTmodels/Component/validators/PortSliceValidator.h>\n#include <IPXACTmodels/Component/validators/FieldSliceValidator.h>\n\n#include <IPXACTmodels/common/Parameter.h>\n#include <IPXACTmodels/common/validators/ParameterValidator.h>\n\n#include <KactusAPI/include/SystemVerilogExpressionParser.h>\n#include <KactusAPI/include/ModeConditionParser.h>\n\n#include <QDebug>\n#include <QtTest>\n\nclass tst_ModeValidator : public QObject\n{\n    Q_OBJECT\n\npublic:\n    tst_ModeValidator();\n\nprivate slots:\n\n    void testNameIsNotEmpty();\n\t\n    void testPortSliceName();\n    void testPortSliceName_data();\n\n    void testPortSliceNameIsUnique();\n\n    void testPortRefs();\n    void testPortRefs_data();\n\n    void testFieldSliceName();\n    void testFieldSliceName_data();\n\n    void testFieldSliceNameIsUnique();\n\n    void testFieldRefs();\n    void testFieldRefs_data();\n\n    void testFieldRefRange();\n    void testFieldRefRange_data();\n\n    void testCondition();\n    void testCondition_data();\n};\n\n//-----------------------------------------------------------------------------\n// Function: tst_ModeValidator::tst_ModeValidator()\n//-----------------------------------------------------------------------------\ntst_ModeValidator::tst_ModeValidator()\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_ModeValidator::testNameIsNotEmpty()\n//-----------------------------------------------------------------------------\nvoid tst_ModeValidator::testNameIsNotEmpty()\n{\n    QSharedPointer<ExpressionParser> parser(new SystemVerilogExpressionParser());\n    QSharedPointer<Component> testComponent(new Component(VLNV(), Document::Revision::Std22));\n\n    ModeValidator validator(testComponent, parser);\n\n    QSharedPointer<Mode> mode( new Mode() );\n    mode->setName(QString());\n\n    QVector<QString> errorList;\n    validator.findErrorsIn(errorList, mode, \"test\");\n\n    QVERIFY(!validator.validate(mode));\n    QVERIFY(errorList.size() > 0);\n    QCOMPARE(errorList.first(), QString(\"Invalid name '' set for mode within test.\"));\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_ModeValidator::testPortSliceName()\n//-----------------------------------------------------------------------------\nvoid tst_ModeValidator::testPortSliceName()\n{\n    QFETCH(QString, name);\n    QFETCH(bool, isValid);\n    QFETCH(QString, expectedError);\n\n    QSharedPointer<ExpressionParser> parser(new SystemVerilogExpressionParser());\n    QSharedPointer<Component> testComponent(new Component(VLNV(), Document::Revision::Std22));\n\n    PortSliceValidator sliceValidator(testComponent, parser);\n\n    QSharedPointer<PortSlice> portSlice(new PortSlice(name));\n\n    QVERIFY(sliceValidator.hasValidName(portSlice->name()) == isValid);\n\n    if (isValid == false)\n    {\n        QVector<QString> errorList;\n        sliceValidator.findErrorsIn(errorList, portSlice, \"mode 'testMode'\");\n        QVERIFY(errorList.size() > 0);\n        QCOMPARE(errorList.first(), expectedError);\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_ModeValidator::testPortSliceName_data()\n//-----------------------------------------------------------------------------\nvoid tst_ModeValidator::testPortSliceName_data()\n{\n    QTest::addColumn<QString>(\"name\");\n    QTest::addColumn<bool>(\"isValid\");\n    QTest::addColumn<QString>(\"expectedError\");\n\n    QTest::newRow(\"Name test is valid\") << \"test\" << true << \"\";\n    QTest::newRow(\"Empty name is not valid\") << \"\" << false << \"Invalid name '' set for port condition within mode 'testMode'.\";\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_ModeValidator::testPortSliceNameIsUnique()\n//-----------------------------------------------------------------------------\nvoid tst_ModeValidator::testPortSliceNameIsUnique()\n{\n    QSharedPointer<ExpressionParser> parser(new SystemVerilogExpressionParser());\n    QSharedPointer<Component> testComponent(new Component(VLNV(), Document::Revision::Std22));\n\n    ModeValidator validator(testComponent, parser);\n\n    QSharedPointer<Mode> mode(new Mode());\n    mode->setName(\"testMode\");\n\n    QSharedPointer<PortSlice> portSlice(new PortSlice(\"slice\"));\n    mode->getPortSlices()->append(portSlice);\n\n    QSharedPointer<PortSlice> duplicateSlice(new PortSlice(\"slice\"));\n    mode->getPortSlices()->append(duplicateSlice);\n\n    QVERIFY(validator.validate(mode) == false);\n\n    QString expectedError(\"Port condition name 'slice' is not unique within mode 'testMode'.\");\n\n    QVector<QString> errorList;\n    validator.findErrorsIn(errorList, mode, \"test\");\n    QVERIFY(errorList.size() > 0);\n    QVERIFY(errorList.contains(expectedError));\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_ModeValidator::testPortRefs()\n//-----------------------------------------------------------------------------\nvoid tst_ModeValidator::testPortRefs()\n{\n    QFETCH(QString, portRef);\n    QFETCH(QString, leftBound);\n    QFETCH(QString, rightBound);\n    QFETCH(bool, isValid);\n    QFETCH(QString, expectedError);\n\n    QSharedPointer<ExpressionParser> parser(new SystemVerilogExpressionParser());\n    QSharedPointer<Component> testComponent(new Component(VLNV(), Document::Revision::Std22));\n\n    QSharedPointer<Port> targetPort(new Port(\"rst_n\"));\n    targetPort->setLeftBound(\"0\");\n    targetPort->setRightBound(\"0\");\n    testComponent->getPorts()->append(targetPort);\n\n\n    ModeValidator validator(testComponent, parser);\n\n    QSharedPointer<Mode> mode(new Mode());\n    mode->setName(\"testMode\");\n\n    QSharedPointer<PortSlice> portSlice(new PortSlice(\"slice\"));\n    portSlice->setPortRef(portRef);\n    portSlice->setLeftRange(leftBound);\n    portSlice->setRightRange(rightBound);\n    mode->getPortSlices()->append(portSlice);\n\n    QVERIFY(validator.validate(mode) == isValid);\n\n    if (isValid == false)\n    {\n        QVector<QString> errorList;\n        validator.findErrorsIn(errorList, mode, \"test\");\n        QVERIFY(errorList.size() > 0);\n        QCOMPARE(errorList.first(), expectedError);\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_ModeValidator::testPortRefs_data()\n//-----------------------------------------------------------------------------\nvoid tst_ModeValidator::testPortRefs_data()\n{\n    QTest::addColumn<QString>(\"portRef\");\n    QTest::addColumn<QString>(\"leftBound\");\n    QTest::addColumn<QString>(\"rightBound\");\n    QTest::addColumn<bool>(\"isValid\");\n    QTest::addColumn<QString>(\"expectedError\");\n\n    QTest::newRow(\"Empty port reference is not valid\") << \"\" << \"\" << \"\" << false <<\n        \"No port reference set for 'slice' within mode 'testMode'.\";\n    QTest::newRow(\"Reference to existing port is valid\") << \"rst_n\" << \"\" << \"\" << true <<\n        \"\";\n    QTest::newRow(\"Reference to unknown port is not valid\") << \"void\" << \"\" << \"\" << false <<\n        \"Port 'void' in port condition 'slice' in mode 'testMode' could not be found in the component.\";\n    QTest::newRow(\"Reference within port bounds is valid\") << \"rst_n\" << \"0\" << \"0\" << true <<\n        \"\";\n    QTest::newRow(\"Reference left range outside port bounds is not valid\") << \"rst_n\" << \"99\" << \"0\" << false <<\n        \"Range in port condition 'slice' is outside the bounds of port 'rst_n' in mode 'testMode'.\";\n    QTest::newRow(\"Reference right range outside port bounds is not valid\") << \"rst_n\" << \"0\" << \"99\" << false <<\n        \"Range in port condition 'slice' is outside the bounds of port 'rst_n' in mode 'testMode'.\";\n    QTest::newRow(\"Reference left and right range outside port bounds is not valid\") << \"rst_n\" << \"99\" << \"99\" << false <<\n        \"Range in port condition 'slice' is outside the bounds of port 'rst_n' in mode 'testMode'.\";\n    QTest::newRow(\"Reference left range incorrect expression is not valid\") << \"rst_n\" << \"abc\" << \"0\" << false <<\n        \"Left range in port condition 'slice' is not a valid expression in mode 'testMode'.\";\n    QTest::newRow(\"Reference right range incorrect expression is not valid\") << \"rst_n\" << \"0\" << \"x\" << false <<\n        \"Right range in port condition 'slice' is not a valid expression in mode 'testMode'.\";\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_ModeValidator::testFieldSliceName()\n//-----------------------------------------------------------------------------\nvoid tst_ModeValidator::testFieldSliceName()\n{\n    QFETCH(QString, name);\n    QFETCH(bool, isValid);\n    QFETCH(QString, expectedError);\n\n    QSharedPointer<ExpressionParser> parser(new SystemVerilogExpressionParser());\n    QSharedPointer<Component> testComponent(new Component(VLNV(), Document::Revision::Std22));\n\n    QSharedPointer<FieldSliceValidator> sliceValidator(new FieldSliceValidator(testComponent, parser));\n\n\n    QSharedPointer<FieldSlice> fieldSlice(new FieldSlice(\"slice\"));\n    fieldSlice->setName(name);\n\n    QVERIFY(sliceValidator->hasValidName(fieldSlice->name()) == isValid);\n\n    if (isValid == false)\n    {\n        QVector<QString> errorList;\n        sliceValidator->findErrorsIn(errorList, fieldSlice, \"mode 'testMode'\");\n        QVERIFY(errorList.size() > 0);\n        QCOMPARE(errorList.first(), expectedError);\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_ModeValidator::testFieldSliceName_data()\n//-----------------------------------------------------------------------------\nvoid tst_ModeValidator::testFieldSliceName_data()\n{\n    QTest::addColumn<QString>(\"name\");\n    QTest::addColumn<bool>(\"isValid\");\n    QTest::addColumn<QString>(\"expectedError\");\n\n    QTest::newRow(\"Empty field slice name is not valid\") << \"\" << false <<\n        \"Invalid name '' set for field condition within mode 'testMode'.\";\n    QTest::newRow(\"Field slice name is valid\") << \"slice\" << true <<\n        \"\";\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_ModeValidator::testFieldSliceNameIsUnique()\n//-----------------------------------------------------------------------------\nvoid tst_ModeValidator::testFieldSliceNameIsUnique()\n{\n    QSharedPointer<ExpressionParser> parser(new SystemVerilogExpressionParser());\n    QSharedPointer<Component> testComponent(new Component(VLNV(), Document::Revision::Std22));\n\n    ModeValidator validator(testComponent, parser);\n\n    QSharedPointer<Mode> mode(new Mode());\n    mode->setName(\"testMode\");\n\n    QSharedPointer<FieldSlice> fieldSlice(new FieldSlice(\"slice\"));\n    mode->getFieldSlices()->append(fieldSlice);\n\n    QSharedPointer<FieldSlice> duplicateSlice(new FieldSlice(\"slice\"));\n    mode->getFieldSlices()->append(duplicateSlice);\n\n    QVERIFY(validator.validate(mode) == false);\n\n    QString expectedError(\"Field condition name 'slice' is not unique within mode 'testMode'.\");\n\n    QVector<QString> errorList;\n    validator.findErrorsIn(errorList, mode, \"test\");\n    QVERIFY(errorList.size() > 0);\n    QVERIFY(errorList.contains(expectedError));\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_ModeValidator::testFieldRefs()\n//-----------------------------------------------------------------------------\nvoid tst_ModeValidator::testFieldRefs()\n{\n    QFETCH(QString, spaceRef);\n    QFETCH(QString, memoryRef);\n    QFETCH(QString, blockRef);\n    QFETCH(QString, registerRef);\n    QFETCH(QString, fieldRef);\n    QFETCH(bool, isValid);\n    QFETCH(QString, expectedError);\n\n    QSharedPointer<ExpressionParser> parser(new SystemVerilogExpressionParser());\n    QSharedPointer<Component> testComponent(new Component(VLNV(), Document::Revision::Std22));\n\n    QSharedPointer<AddressSpace> addressSpace(new AddressSpace(\"space\"));\n    QSharedPointer<MemoryMap> localMemoryMap(new MemoryMap(\"local\"));\n    addressSpace->setLocalMemoryMap(localMemoryMap);\n    testComponent->getAddressSpaces()->append(addressSpace);\n\n\n    QSharedPointer<MemoryMap> memoryMap(new MemoryMap(\"memory\"));\n    testComponent->getMemoryMaps()->append(memoryMap);\n\n    QSharedPointer<AddressBlock> addressBlock(new AddressBlock(\"block\"));\n    memoryMap->getMemoryBlocks()->append(addressBlock);\n    addressSpace->getLocalMemoryMap()->getMemoryBlocks()->append(addressBlock);\n\n    QSharedPointer<Register> register_(new Register(\"register\"));\n    addressBlock->getRegisterData()->append(register_);\n\n    QSharedPointer<Field> field(new Field(\"field\"));\n    register_->getFields()->append(field);\n\n    ModeValidator validator(testComponent, parser);\n\n    QSharedPointer<Mode> mode(new Mode());\n    mode->setName(\"testMode\");\n\n    QSharedPointer<FieldSlice> fieldSlice(new FieldSlice(\"slice\"));\n\n    auto asRef = QSharedPointer<FieldReference::IndexedReference>(new FieldReference::IndexedReference(spaceRef));\n    fieldSlice->setReference(asRef, FieldReference::ADDRESS_SPACE);\n\n    auto mmRef = QSharedPointer<FieldReference::IndexedReference>(new FieldReference::IndexedReference(memoryRef));\n    fieldSlice->setReference(mmRef, FieldReference::MEMORY_MAP);\n\n    auto addressRef = QSharedPointer<FieldReference::IndexedReference>(new FieldReference::IndexedReference(blockRef));\n    fieldSlice->setReference(addressRef, FieldReference::ADDRESS_BLOCK);\n\n    auto regRef = QSharedPointer<FieldReference::IndexedReference>(new FieldReference::IndexedReference(registerRef));\n    fieldSlice->setReference(regRef, FieldReference::REGISTER);\n\n    auto bitRef = QSharedPointer<FieldReference::IndexedReference>(new FieldReference::IndexedReference(fieldRef));\n    fieldSlice->setReference(bitRef, FieldReference::FIELD);\n\n    mode->getFieldSlices()->append(fieldSlice);\n\n    QVERIFY(validator.validate(mode) == isValid);\n\n    if (isValid == false)\n    {\n        QVector<QString> errorList;\n        validator.findErrorsIn(errorList, mode, \"test\");\n        QVERIFY(errorList.size() > 0);\n        QCOMPARE(errorList.first(), expectedError);\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_ModeValidator::testFieldRefs_data()\n//-----------------------------------------------------------------------------\nvoid tst_ModeValidator::testFieldRefs_data()\n{\n    QTest::addColumn<QString>(\"spaceRef\");\n    QTest::addColumn<QString>(\"memoryRef\");\n    QTest::addColumn<QString>(\"blockRef\");\n    QTest::addColumn<QString>(\"registerRef\");\n    QTest::addColumn<QString>(\"fieldRef\");\n    QTest::addColumn<bool>(\"isValid\");\n    QTest::addColumn<QString>(\"expectedError\");\n\n    QTest::newRow(\"Empty memory map reference is not valid\") << \"\" << \"\" << \"block\" << \"register\" << \"field\" << false <<\n        \"Field reference in condition 'slice' is not valid in mode 'testMode'.\";\n    QTest::newRow(\"Empty address block reference is not valid\") << \"\" << \"memory\" << \"\" << \"register\" << \"field\" << false <<\n        \"Field reference in condition 'slice' is not valid in mode 'testMode'.\";\n    QTest::newRow(\"Empty register reference is not valid\") << \"\" << \"memory\" << \"block\" << \"\" << \"field\" << false <<\n        \"Field reference in condition 'slice' is not valid in mode 'testMode'.\";\n    QTest::newRow(\"Empty field reference is not valid\") << \"\" << \"memory\" << \"block\" << \"register\" << \"\" << false <<\n        \"Field reference in condition 'slice' is not valid in mode 'testMode'.\";\n\n    QTest::newRow(\"Non-existent memory map reference is not valid\") << \"\" << \"none\" << \"block\" << \"register\" << \"field\" << false <<\n        \"Field reference in condition 'slice' is not valid in mode 'testMode'.\";\n    QTest::newRow(\"Non-existent address space reference is not valid\") << \"none\" << \"\" << \"block\" << \"register\" << \"field\" << false <<\n        \"Field reference in condition 'slice' is not valid in mode 'testMode'.\";\n    QTest::newRow(\"Non-existent address block reference is not valid\") << \"\" << \"memory\" << \"none\" << \"register\" << \"field\" << false <<\n        \"Field reference in condition 'slice' is not valid in mode 'testMode'.\";\n    QTest::newRow(\"Non-existent register reference is not valid\") << \"\" << \"memory\" << \"block\" << \"none\" << \"field\" << false <<\n        \"Field reference in condition 'slice' is not valid in mode 'testMode'.\";\n    QTest::newRow(\"Non-existent field reference is not valid\") << \"\" << \"memory\" << \"block\" << \"register\" << \"none\" << false <<\n        \"Field reference in condition 'slice' is not valid in mode 'testMode'.\";\n\n    QTest::newRow(\"Reference to address space is valid\") << \"space\" << \"\" << \"block\" << \"register\" << \"field\" << true <<\n        \"\";\n\n    QTest::newRow(\"All references are valid\") << \"\" << \"memory\" << \"block\" << \"register\" << \"field\" << true <<\n        \"\";\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_ModeValidator::testFieldRefRange()\n//-----------------------------------------------------------------------------\nvoid tst_ModeValidator::testFieldRefRange()\n{\n    QFETCH(QString, left);\n    QFETCH(QString, right);\n    QFETCH(bool, isValid);\n    QFETCH(QString, expectedError);\n\n    QSharedPointer<ExpressionParser> parser(new SystemVerilogExpressionParser());\n    QSharedPointer<Component> testComponent(new Component(VLNV(), Document::Revision::Std22));\n\n\n    QSharedPointer<MemoryMap> memoryMap(new MemoryMap(\"memory\"));\n    testComponent->getMemoryMaps()->append(memoryMap);\n\n    QSharedPointer<AddressBlock> addressBlock(new AddressBlock(\"block\"));\n    memoryMap->getMemoryBlocks()->append(addressBlock);\n\n    QSharedPointer<Register> register_(new Register(\"register\"));\n    addressBlock->getRegisterData()->append(register_);\n\n    QSharedPointer<Field> field(new Field(\"field\"));\n    field->setBitOffset(\"0\");\n    field->setBitWidth(\"8\");\n\n    register_->getFields()->append(field);\n\n    ModeValidator validator(testComponent, parser);\n\n    QSharedPointer<Mode> mode(new Mode());\n    mode->setName(\"testMode\");\n\n    QSharedPointer<FieldSlice> fieldSlice(new FieldSlice(\"slice\"));\n\n    auto mmRef = QSharedPointer<FieldReference::IndexedReference>(new FieldReference::IndexedReference(\"memory\"));\n    fieldSlice->setReference(mmRef, FieldReference::MEMORY_MAP);\n\n    auto addressRef = QSharedPointer<FieldReference::IndexedReference>(new FieldReference::IndexedReference(\"block\"));\n    fieldSlice->setReference(addressRef, FieldReference::ADDRESS_BLOCK);\n\n    auto regRef = QSharedPointer<FieldReference::IndexedReference>(new FieldReference::IndexedReference(\"register\"));\n    fieldSlice->setReference(regRef, FieldReference::REGISTER);\n\n    auto bitRef = QSharedPointer<FieldReference::IndexedReference>(new FieldReference::IndexedReference(\"field\"));\n    fieldSlice->setReference(bitRef, FieldReference::FIELD);\n\n    mode->getFieldSlices()->append(fieldSlice);\n\n    fieldSlice->setLeft(left);\n    fieldSlice->setRight(right);\n\n    QVERIFY(validator.validate(mode) == isValid);\n\n    if (isValid == false)\n    {\n        QVector<QString> errorList;\n        validator.findErrorsIn(errorList, mode, \"test\");\n        QVERIFY(errorList.size() > 0);\n        QCOMPARE(errorList.first(), expectedError);\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_ModeValidator::testFieldRefRange_data()\n//-----------------------------------------------------------------------------\nvoid tst_ModeValidator::testFieldRefRange_data()\n{\n    QTest::addColumn<QString>(\"left\");\n    QTest::addColumn<QString>(\"right\");\n    QTest::addColumn<bool>(\"isValid\");\n    QTest::addColumn<QString>(\"expectedError\");\n\n    QTest::newRow(\"Empty ranges is valid\") << \"\" << \"\" << true << \"\";\n    QTest::newRow(\"Both ranges are valid\") << \"0\" << \"0\" << true << \"\";\n\n    QTest::newRow(\"Left range without right is not valid\") << \"0\" << \"\" << false <<\n        \"Left range in field condition 'slice' is not valid in mode 'testMode'.\";\n    QTest::newRow(\"Right range without left is not valid\") << \"\" << \"0\" << false <<\n        \"Right range in field condition 'slice' is not valid in mode 'testMode'.\";\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_ModeValidator::testCondition()\n//-----------------------------------------------------------------------------\nvoid tst_ModeValidator::testCondition()\n{\n    QFETCH(QString, condition);\n    QFETCH(bool, isValid);\n    QFETCH(QString, expectedError);\n\n    QSharedPointer<Component> testComponent(new Component(VLNV(), Document::Revision::Std22));\n\n    QSharedPointer<Mode> mode(new Mode());\n    mode->setName(\"testMode\");\n    mode->setCondition(condition);\n    QSharedPointer<ExpressionParser> parser(new ModeConditionParser(nullptr, mode->getPortSlices(),\n        mode->getFieldSlices(), testComponent->getModes()));\n\n    ModeValidator validator(testComponent, parser);\n    \n    QVERIFY(validator.hasValidCondition(mode) == isValid);\n    if (isValid == false)\n    {\n        QVector<QString> errorList;\n        validator.findErrorsIn(errorList, mode, \"test\");\n        QVERIFY(errorList.size() > 0);\n        QCOMPARE(errorList.first(), expectedError);\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_ModeValidator::testCondition_data()\n//-----------------------------------------------------------------------------\nvoid tst_ModeValidator::testCondition_data()\n{\n    QTest::addColumn<QString>(\"condition\");\n    QTest::addColumn<bool>(\"isValid\");\n    QTest::addColumn<QString>(\"expectedError\");\n\n    QTest::newRow(\"Empty condition is valid\") << \"\" << true << \"\";\n\n    QTest::newRow(\"Empty reference is invalid\") << \"$ipxact_mode_condition()\" << false <<\n        \"Condition is not a valid expression within mode 'testMode'.\";\n\n    //! Reference validation is checked in tst_ModeConditionParser.\n}\n\n\nQTEST_APPLESS_MAIN(tst_ModeValidator)\n\n#include \"tst_ModeValidator.moc\"\n"
  },
  {
    "path": "tests/IPXACTmodels/Component/tst_ModeValidator.pri",
    "content": "# ----------------------------------------------------\n# This file is generated by the Qt Visual Studio Tools.\n# ------------------------------------------------------\n\nSOURCES += ./tst_ModeValidator.cpp \n   "
  },
  {
    "path": "tests/IPXACTmodels/Component/tst_ModeValidator.pro",
    "content": "#-----------------------------------------------------------------------------\n# File: tst_ModeValidator.pro\n#-----------------------------------------------------------------------------\n# Project: Kactus2\n# Author: Esko Pekkarinen\n# Date: 14.08.2023\n#\n# Description:\n# Qt project file template for running unit tests for Mode Validator.\n#-----------------------------------------------------------------------------\n\nTEMPLATE = app\n\nTARGET = tst_ModeValidator\n\nQT += core gui xml testlib\n\nCONFIG += c++11 testcase console\n\nlinux-g++ | linux-g++-64 | linux-g++-32 {\n LIBS += -L../../../executable \\\n     -lIPXACTmodels -lKactusAPI\n\n}\nwin64 | win32 {\n LIBS += -L../../../executable \\\n     -lIPXACTmodelsd -lKactusAPId\n}\n\nINCLUDEPATH += $$DESTDIR\nINCLUDEPATH += ../../../\n\nDEPENDPATH += .\nDEPENDPATH += ../../../\n\nOBJECTS_DIR += $$DESTDIR\n\nMOC_DIR += ./generatedFiles\nUI_DIR += ./generatedFiles\nRCC_DIR += ./generatedFiles\ninclude(tst_ModeValidator.pri)\n"
  },
  {
    "path": "tests/IPXACTmodels/Component/tst_ModeWriter.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: tst_ModeWriter.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Esko Pekkarinen\n// Date: 07.08.2023\n//\n// Description:\n// Unit test for class ModeWriter.\n//-----------------------------------------------------------------------------\n\n#include <IPXACTmodels/Component/Mode.h>\n#include <IPXACTmodels/Component/ModeWriter.h>\n#include <IPXACTmodels/common/VendorExtension.h>\n\n#include <QtTest>\n\nclass tst_ModeWriter : public QObject\n{\n    Q_OBJECT\n\npublic:\n    tst_ModeWriter();\n\nprivate slots:\n\n    void testWriteNameGroup();\n    void testWriteCondition();\n    void testWritePortSlices();\n    void testWriteFieldSlices();\n};\n\n//-----------------------------------------------------------------------------\n// Function: tst_ModeWriter::tst_ModeWriter()\n//-----------------------------------------------------------------------------\ntst_ModeWriter::tst_ModeWriter()\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_ModeWriter::testWriteNameGroup()\n//-----------------------------------------------------------------------------\nvoid tst_ModeWriter::testWriteNameGroup()\n{\n    QString output;\n    QXmlStreamWriter xmlStreamWriter(&output);\n\n\n    QSharedPointer<Mode> testMode(new Mode(\"testMode\"));\n    testMode->setDisplayName(\"testDisplay\");\n    testMode->setShortDescription(\"testShortDescription\");\n    testMode->setDescription(\"testDescription\");\n    \n    ModeWriter::writeMode(xmlStreamWriter, testMode);\n\n    QString expectedOutput(\n        \"<ipxact:mode>\"\n            \"<ipxact:name>testMode</ipxact:name>\"\n            \"<ipxact:displayName>testDisplay</ipxact:displayName>\"\n            \"<ipxact:shortDescription>testShortDescription</ipxact:shortDescription>\"\n            \"<ipxact:description>testDescription</ipxact:description>\"\n        \"</ipxact:mode>\"\n    );\n\n    QCOMPARE(output, expectedOutput);\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_ModeWriter::testWriteCondition()\n//-----------------------------------------------------------------------------\nvoid tst_ModeWriter::testWriteCondition()\n{\n     QString output;\n    QXmlStreamWriter xmlStreamWriter(&output);\n\n    QSharedPointer<Mode> testMode(new Mode(\"testMode\"));\n    testMode->setCondition(QStringLiteral(\"1\"));\n\n    ModeWriter::writeMode(xmlStreamWriter, testMode);\n\n    QString expectedOutput(\n        \"<ipxact:mode>\"\n            \"<ipxact:name>testMode</ipxact:name>\"\n            \"<ipxact:condition>1</ipxact:condition>\"\n        \"</ipxact:mode>\"\n    );\n\n    QCOMPARE(output, expectedOutput);\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_ModeWriter::testWritePortSlices()\n//-----------------------------------------------------------------------------\nvoid tst_ModeWriter::testWritePortSlices()\n{\n    QString output;\n    QXmlStreamWriter xmlStreamWriter(&output);\n\n    QSharedPointer<Mode> testMode(new Mode(\"testMode\"));\n\n    QSharedPointer<PortSlice> portSlice(new PortSlice(\"testSlice\"));\n    portSlice->setDisplayName(\"sliceDisplay\");\n    portSlice->setShortDescription(\"sliceShort\");\n    portSlice->setDescription(\"sliceDescription\");\n    portSlice->setPortRef(\"testPortRef\");\n    testMode->getPortSlices()->append(portSlice);\n\n    QSharedPointer<PartSelect> partSelect(new PartSelect);\n    partSelect->setLeftRange(\"1\");\n    partSelect->setRightRange(\"0\");\n    portSlice->setPartSelect(partSelect);\n\n    ModeWriter::writeMode(xmlStreamWriter, testMode);\n\n    QString expectedOutput(\n        \"<ipxact:mode>\"\n            \"<ipxact:name>testMode</ipxact:name>\"\n            \"<ipxact:portSlice>\"\n                \"<ipxact:name>testSlice</ipxact:name>\"\n                \"<ipxact:displayName>sliceDisplay</ipxact:displayName>\"\n                \"<ipxact:shortDescription>sliceShort</ipxact:shortDescription>\"\n                \"<ipxact:description>sliceDescription</ipxact:description>\"\n                \"<ipxact:portRef portRef=\\\"testPortRef\\\"/>\"\n                \"<ipxact:partSelect>\"\n                    \"<ipxact:range>\"\n                        \"<ipxact:left>1</ipxact:left>\"\n                        \"<ipxact:right>0</ipxact:right>\"\n                    \"</ipxact:range>\"\n                \"</ipxact:partSelect>\"\n            \"</ipxact:portSlice>\"\n        \"</ipxact:mode>\"\n    );\n\n    QCOMPARE(output, expectedOutput);\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_ModeWriter::testWriteFieldSlices()\n//-----------------------------------------------------------------------------\nvoid tst_ModeWriter::testWriteFieldSlices()\n{\n    QString output;\n    QXmlStreamWriter xmlStreamWriter(&output);\n\n    QSharedPointer<Mode> testMode(new Mode(\"testMode\"));\n\n    QSharedPointer<FieldSlice> fieldSlice(new FieldSlice(\"testSlice\"));\n    fieldSlice->setDisplayName(\"sliceDisplay\");\n    fieldSlice->setShortDescription(\"sliceShort\");\n    fieldSlice->setDescription(\"sliceDescription\");\n\n\n    QSharedPointer<FieldReference::IndexedReference> memoryMap(new FieldReference::IndexedReference(QString(\"testMMRef\")));\n    fieldSlice->setReference(memoryMap, FieldReference::Type::MEMORY_MAP);\n\n    QSharedPointer<FieldReference::IndexedReference> addressBlock(new FieldReference::IndexedReference(QString(\"testABRef\")));\n    fieldSlice->setReference(addressBlock, FieldReference::Type::ADDRESS_BLOCK);\n\n    QSharedPointer<FieldReference::IndexedReference> registerRef(new FieldReference::IndexedReference(QString(\"testRegisterRef\")));\n    fieldSlice->setReference(registerRef, FieldReference::Type::REGISTER);\n\n    QSharedPointer<FieldReference::IndexedReference> fieldRef(new FieldReference::IndexedReference(QString(\"testFieldRef\")));\n    fieldSlice->setReference(fieldRef, FieldReference::Type::FIELD);\n\n    fieldSlice->setLeft(\"7\");\n    fieldSlice->setRight(\"0\");\n\n    testMode->getFieldSlices()->append(fieldSlice);\n\n    ModeWriter::writeMode(xmlStreamWriter, testMode);\n\n    QString expectedOutput(\n        \"<ipxact:mode>\"\n            \"<ipxact:name>testMode</ipxact:name>\"\n            \"<ipxact:fieldSlice>\"\n                \"<ipxact:name>testSlice</ipxact:name>\"\n                \"<ipxact:displayName>sliceDisplay</ipxact:displayName>\"\n                \"<ipxact:shortDescription>sliceShort</ipxact:shortDescription>\"\n                \"<ipxact:description>sliceDescription</ipxact:description>\"\n                \"<ipxact:memoryMapRef memoryMapRef=\\\"testMMRef\\\"/>\"\n                \"<ipxact:addressBlockRef addressBlockRef=\\\"testABRef\\\"/>\"\n                \"<ipxact:registerRef registerRef=\\\"testRegisterRef\\\"/>\"\n                \"<ipxact:fieldRef fieldRef=\\\"testFieldRef\\\"/>\"\n                \"<ipxact:range>\"\n                    \"<ipxact:left>7</ipxact:left>\"\n                    \"<ipxact:right>0</ipxact:right>\"\n                \"</ipxact:range>\"\n            \"</ipxact:fieldSlice>\"\n        \"</ipxact:mode>\"\n    );\n\n    QCOMPARE(output, expectedOutput);\n}\n\nQTEST_APPLESS_MAIN(tst_ModeWriter)\n\n\n#include \"tst_ModeWriter.moc\"\n"
  },
  {
    "path": "tests/IPXACTmodels/Component/tst_ModeWriter.pri",
    "content": "# ----------------------------------------------------\n# This file is generated by the Qt Visual Studio Add-in.\n# ------------------------------------------------------\n\nSOURCES += ./tst_ModeWriter.cpp \n"
  },
  {
    "path": "tests/IPXACTmodels/Component/tst_ModeWriter.pro",
    "content": "#-----------------------------------------------------------------------------\n# File: tst_ModeWriter.pro\n#-----------------------------------------------------------------------------\n# Project: Kactus 2\n# Author: Esko Pekkarinen\n# Date: 07.08.2023\n#\n# Description:\n# Qt project file for running unit tests for Mode Writer.\n#-----------------------------------------------------------------------------\n\nTEMPLATE = app\n\nTARGET = tst_ModeWriter\n\nQT += core xml testlib\nQT -= gui\n\nCONFIG += c++11 testcase console\n\nlinux-g++ | linux-g++-64 | linux-g++-32 {\n LIBS += -L../../../executable \\\n     -lIPXACTmodels\n\n}\nwin64 | win32 {\n LIBS += -L../../../executable \\\n     -lIPXACTmodelsd\n}\n\nINCLUDEPATH += $$DESTDIR\nINCLUDEPATH += ../../../\n\nDEPENDPATH += .\nDEPENDPATH += ../../../\n\nOBJECTS_DIR += $$DESTDIR\n\nMOC_DIR += ./generatedFiles\nUI_DIR += ./generatedFiles\nRCC_DIR += ./generatedFiles\ninclude(tst_ModeWriter.pri)\n"
  },
  {
    "path": "tests/IPXACTmodels/Component/tst_OtherClockDriverReader.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: tst_OtherClockDriverReader.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Janne Virtanen\r\n// Date: 02.10.2015\r\n//\r\n// Description:\r\n// Unit test for class OtherClockDriverReader.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include <IPXACTmodels/Component/OtherClockDriverReader.h>\r\n\r\n#include <IPXACTmodels/common/ClockUnit.h>\r\n\r\n#include <QtTest>\r\n\r\nclass tst_OtherClockDriverReader : public QObject\r\n{\r\n    Q_OBJECT\r\n\r\npublic:\r\n    tst_OtherClockDriverReader();\r\n\r\nprivate slots:\r\n\r\n    void testReadSimpleOtherClockDriver();\r\n\tvoid testReadClockPeriod();\r\n\tvoid testReadClockPulses();\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_OtherClockDriverReader::tst_OtherClockDriverReader()\r\n//-----------------------------------------------------------------------------\r\ntst_OtherClockDriverReader::tst_OtherClockDriverReader()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_OtherClockDriverReader::testReadSimpleOtherClockDriver()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_OtherClockDriverReader::testReadSimpleOtherClockDriver()\r\n{\r\n    QString documentContent(\r\n        \"<ipxact:otherClockDriver clockName=\\\"Marko\\\" clockSource=\\\"Ari\\\">\"\r\n        \"</ipxact:otherClockDriver>\"\r\n        );\r\n\r\n\r\n    QDomDocument document;\r\n    document.setContent(documentContent);\r\n\r\n    QDomNode OtherClockDriverNode = document.firstChildElement(\"ipxact:otherClockDriver\");\r\n\r\n    OtherClockDriverReader OtherClockDriverReader;\r\n\tQSharedPointer<OtherClockDriver> testOtherClockDriver = OtherClockDriverReader.createOtherClockDriverFrom(OtherClockDriverNode);\r\n\r\n\tQCOMPARE(testOtherClockDriver->getClockName(), QString(\"Marko\"));\r\n\tQCOMPARE(testOtherClockDriver->getClockSource(), QString(\"Ari\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_OtherClockDriverReader::testReadClockPeriod()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_OtherClockDriverReader::testReadClockPeriod()\r\n{\r\n\tQString documentContent(\r\n\t\t\"<ipxact:otherClockDriver clockName=\\\"Marko\\\" clockSource=\\\"Ari\\\">\"\r\n\t\t    \"<ipxact:clockPeriod units=\\\"ps\\\">6</ipxact:clockPeriod>\"\r\n\t\t\"</ipxact:otherClockDriver>\"\r\n\t\t);\r\n\r\n\r\n\tQDomDocument document;\r\n\tdocument.setContent(documentContent);\r\n\r\n\tQDomNode OtherClockDriverNode = document.firstChildElement(\"ipxact:otherClockDriver\");\r\n\r\n\tOtherClockDriverReader OtherClockDriverReader;\r\n\tQSharedPointer<OtherClockDriver> testOtherClockDriver = OtherClockDriverReader.createOtherClockDriverFrom(OtherClockDriverNode);\r\n\r\n\tQCOMPARE(testOtherClockDriver->getClockPeriod()->getValue(), QString(\"6\"));\r\n\tQCOMPARE(testOtherClockDriver->getClockPeriod()->getTimeUnit(), ClockUnit::PS);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_OtherClockDriverReader::testReadClockPulses()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_OtherClockDriverReader::testReadClockPulses()\r\n{\r\n\tQString documentContent(\r\n\t\t\"<ipxact:otherClockDriver>\"\r\n    \t\t\"<ipxact:clockPulseOffset units=\\\"ns\\\">1</ipxact:clockPulseOffset>\"\r\n\t    \t\"<ipxact:clockPulseValue>2</ipxact:clockPulseValue>\"\r\n\t\t    \"<ipxact:clockPulseDuration units=\\\"ps\\\">3</ipxact:clockPulseDuration>\"\r\n\t\t\"</ipxact:otherClockDriver>\"\r\n\t\t);\r\n\r\n\tQDomDocument document;\r\n\tdocument.setContent(documentContent);\r\n\r\n\tQDomNode OtherClockDriverNode = document.firstChildElement(\"ipxact:otherClockDriver\");\r\n\r\n\tOtherClockDriverReader OtherClockDriverReader;\r\n\tQSharedPointer<OtherClockDriver> testOtherClockDriver = OtherClockDriverReader.createOtherClockDriverFrom(OtherClockDriverNode);\r\n\r\n\tQCOMPARE(testOtherClockDriver->getClockPulseOffset()->getValue(), QString(\"1\"));\r\n\tQCOMPARE(testOtherClockDriver->getClockPulseOffset()->getTimeUnit(), ClockUnit::NS);\r\n\tQCOMPARE(testOtherClockDriver->getClockPulseValue(), QString(\"2\"));\r\n    QCOMPARE(testOtherClockDriver->getClockPulseDuration()->getValue(), QString(\"3\"));\r\n\tQCOMPARE(testOtherClockDriver->getClockPulseDuration()->getTimeUnit(), ClockUnit::PS);\r\n}\r\n\r\nQTEST_APPLESS_MAIN(tst_OtherClockDriverReader)\r\n\r\n#include \"tst_OtherClockDriverReader.moc\"\r\n"
  },
  {
    "path": "tests/IPXACTmodels/Component/tst_OtherClockDriverReader.pri",
    "content": "# ----------------------------------------------------\r\n# This file is generated by the Qt Visual Studio Add-in.\r\n# ------------------------------------------------------\r\n\r\nSOURCES += ./tst_OtherClockDriverReader.cpp \r\n"
  },
  {
    "path": "tests/IPXACTmodels/Component/tst_OtherClockDriverReader.pro",
    "content": "#-----------------------------------------------------------------------------\r\n# File: tst_OtherClockDriverReader.pro\r\n#-----------------------------------------------------------------------------\r\n# Project: Kactus 2\r\n# Author: Janne Virtanen\r\n# Date: 02.10.2015\r\n#\r\n# Description:\r\n# Qt project file template for running unit tests for OtherClockDriver reader.\r\n#-----------------------------------------------------------------------------\r\n\r\nTEMPLATE = app\r\n\r\nTARGET = tst_OtherClockDriverReader\r\n\r\nQT += core xml testlib\r\nQT -= gui\r\n\r\nCONFIG += c++11 testcase console\r\n\r\nlinux-g++ | linux-g++-64 | linux-g++-32 {\r\n LIBS += -L../../../executable \\\r\n     -lIPXACTmodels\r\n}\r\nwin64 | win32 {\r\n LIBS += -L../../../x64/executable \\\r\n     -lIPXACTmodelsd\r\n}\r\n\r\nINCLUDEPATH += $$DESTDIR\r\nINCLUDEPATH += ../../../\r\n\r\nDEPENDPATH += .\r\nDEPENDPATH += ../../../\r\n\r\nOBJECTS_DIR += $$DESTDIR\r\n\r\nMOC_DIR += ./generatedFiles\r\nUI_DIR += ./generatedFiles\r\nRCC_DIR += ./generatedFiles\r\ninclude(tst_OtherClockDriverReader.pri)\r\n"
  },
  {
    "path": "tests/IPXACTmodels/Component/tst_OtherClockDriverValidator.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: tst_OtherClockDriverValidator.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 14.12.2015\r\n//\r\n// Description:\r\n// Unit test for class OtherClockDriverValidator.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include <KactusAPI/include/SystemVerilogExpressionParser.h>\r\n\r\n#include <IPXACTmodels/Component/validators/OtherClockDriverValidator.h>\r\n\r\n#include <IPXACTmodels/Component/OtherClockDriver.h>\r\n#include <IPXACTmodels/common/ClockUnit.h>\r\n\r\n#include <QtTest>\r\n\r\nclass tst_OtherClockDriverValidator : public QObject\r\n{\r\n    Q_OBJECT\r\n\r\npublic:\r\n    tst_OtherClockDriverValidator();\r\n\r\nprivate slots:\r\n\r\n    void testHasValidName();\r\n    void testHasValidName_data();\r\n\r\n    void testHasValidClockPeriod();\r\n    void testHasValidClockPeriod_data();\r\n\r\n    void testHasValidClockPulseOffset();\r\n    void testHasValidClockPulseOffset_data();\r\n\r\n    void testHasValidClockPulseValue();\r\n    void testHasValidClockPulseValue_data();\r\n\r\n    void testHasValidClockPulseDuration();\r\n    void testHasValidClockPulseDuration_data();\r\n\r\nprivate:\r\n    \r\n    bool errorIsNotFoundInErrorList(QString const& expectedError, QVector<QString> errorList);\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_OtherClockDriverValidator::tst_OtherClockDriverValidator()\r\n//-----------------------------------------------------------------------------\r\ntst_OtherClockDriverValidator::tst_OtherClockDriverValidator()\r\n{\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_OtherClockDriverValidator::testHasValidName()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_OtherClockDriverValidator::testHasValidName()\r\n{\r\n    QFETCH(QString, name);\r\n    QFETCH(bool, isValid);\r\n\r\n    QSharedPointer<OtherClockDriver> testDriver (new OtherClockDriver(name));\r\n\r\n    QSharedPointer<ExpressionParser> parser(new SystemVerilogExpressionParser());\r\n    OtherClockDriverValidator validator(parser);\r\n\r\n    QCOMPARE(validator.hasValidName(testDriver->getClockName()), isValid);\r\n\r\n    if (!isValid)\r\n    {\r\n        QVector<QString> foundErrors;\r\n        validator.findErrorsIn(foundErrors, testDriver, \"test\");\r\n\r\n        QString expectedError = QObject::tr(\"Invalid name '%1' set for other clock driver within %2\")\r\n            .arg(testDriver->getClockName()).arg(\"test\");\r\n        if (errorIsNotFoundInErrorList(expectedError, foundErrors))\r\n        {\r\n            QFAIL(\"No error message found\");\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_OtherClockDriverValidator::testHasValidName_data()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_OtherClockDriverValidator::testHasValidName_data()\r\n{\r\n    QTest::addColumn<QString>(\"name\");\r\n    QTest::addColumn<bool>(\"isValid\");\r\n\r\n    QTest::newRow(\"Name test is valid\") << \"test\" << true;\r\n    QTest::newRow(\"Empty name is invalid\") << \"\" << false;\r\n    QTest::newRow(\"Name consisting of only white spaces is invalid\") << \"    \" << false;\r\n    QTest::newRow(\"Name consisting of characters and white spaces is valid\") << \"  test  \" << true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_OtherClockDriverValidator::testHasValidClockPeriod()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_OtherClockDriverValidator::testHasValidClockPeriod()\r\n{\r\n    QFETCH(QString, clockValue);\r\n    QFETCH(bool, isValid);\r\n\r\n    QSharedPointer<ClockUnit> testUnit (new ClockUnit(clockValue));\r\n    \r\n    QSharedPointer<OtherClockDriver> testDriver (new OtherClockDriver(\"MassDriver\"));\r\n    testDriver->setClockPeriod(testUnit);\r\n\r\n    QSharedPointer<ExpressionParser> parser(new SystemVerilogExpressionParser());\r\n    OtherClockDriverValidator validator(parser);\r\n\r\n    QCOMPARE(validator.hasValidClockValue(testDriver->getClockPeriod()), isValid);\r\n\r\n    if (!isValid)\r\n    {\r\n        QVector<QString> foundErrors;\r\n        validator.findErrorsIn(foundErrors, testDriver, \"test\");\r\n\r\n        QString expectedError = QObject::tr(\"Invalid clock period %1 set for other clock driver %2 within %3\")\r\n            .arg(testUnit->getValue()).arg(testDriver->getClockName()).arg(\"test\");\r\n        if (errorIsNotFoundInErrorList(expectedError, foundErrors))\r\n        {\r\n            QFAIL(\"No error message found\");\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_OtherClockDriverValidator::testHasValidClockPeriod_data()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_OtherClockDriverValidator::testHasValidClockPeriod_data()\r\n{\r\n    QTest::addColumn<QString>(\"clockValue\");\r\n    QTest::addColumn<bool>(\"isValid\");\r\n\r\n    QTest::newRow(\"Clock value 1+1.12 is valid\") << \"1+1.12\" << true;\r\n    QTest::newRow(\"Clock value 0 is valid\") << \"0\" << true;\r\n    QTest::newRow(\"Clock value -4.12 is valid\") << \"-4.12\" << true;\r\n    QTest::newRow(\"Empty clock value is not valid\") << \"\" << false;\r\n    QTest::newRow(\"Text is not valid for clock value\") << \"text\" << false;\r\n    QTest::newRow(\"String is not valid for clock value\") << \"\\\"text\\\"\" << false;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_OtherClockDriverValidator::testHasValidClockPulseOffset()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_OtherClockDriverValidator::testHasValidClockPulseOffset()\r\n{\r\n    QFETCH(QString, clockValue);\r\n    QFETCH(bool, isValid);\r\n\r\n    QSharedPointer<ClockUnit> testUnit (new ClockUnit(clockValue));\r\n\r\n    QSharedPointer<OtherClockDriver> testDriver (new OtherClockDriver(\"MassDriver\"));\r\n    testDriver->setClockPulseOffset(testUnit);\r\n\r\n    QSharedPointer<ExpressionParser> parser(new SystemVerilogExpressionParser());\r\n    OtherClockDriverValidator validator(parser);\r\n\r\n    QCOMPARE(validator.hasValidClockValue(testDriver->getClockPulseOffset()), isValid);\r\n\r\n    if (!isValid)\r\n    {\r\n        QVector<QString> foundErrors;\r\n        validator.findErrorsIn(foundErrors, testDriver, \"test\");\r\n\r\n        QString expectedError = QObject::tr(\"Invalid clock pulse offset %1 set for other clock driver %2 within %3\")\r\n            .arg(clockValue).arg(testDriver->getClockName()).arg(\"test\");\r\n        if (errorIsNotFoundInErrorList(expectedError, foundErrors))\r\n        {\r\n            QFAIL(\"No error message found\");\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_OtherClockDriverValidator::testHasValidClockPulseOffset_data()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_OtherClockDriverValidator::testHasValidClockPulseOffset_data()\r\n{\r\n    QTest::addColumn<QString>(\"clockValue\");\r\n    QTest::addColumn<bool>(\"isValid\");\r\n\r\n    QTest::newRow(\"Clock value 1+1.12 is valid\") << \"1+1.12\" << true;\r\n    QTest::newRow(\"Clock value 0 is valid\") << \"0\" << true;\r\n    QTest::newRow(\"Clock value -4.12 is valid\") << \"-4.12\" << true;\r\n    QTest::newRow(\"Empty clock value is not valid\") << \"\" << false;\r\n    QTest::newRow(\"Text is not valid for clock value\") << \"text\" << false;\r\n    QTest::newRow(\"String is not valid for clock value\") << \"\\\"text\\\"\" << false;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_OtherClockDriverValidator::testHasValidClockPulseValue()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_OtherClockDriverValidator::testHasValidClockPulseValue()\r\n{\r\n    QFETCH(QString, pulseValue);\r\n    QFETCH(bool, isValid);\r\n\r\n    QSharedPointer<OtherClockDriver> testDriver (new OtherClockDriver(\"MassDriver\"));\r\n    testDriver->setClockPulseValue(pulseValue);\r\n\r\n    QSharedPointer<ExpressionParser> parser(new SystemVerilogExpressionParser());\r\n    OtherClockDriverValidator validator(parser);\r\n\r\n    QCOMPARE(validator.hasValidClockPulseValue(testDriver), isValid);\r\n\r\n    if (!isValid)\r\n    {\r\n        QVector<QString> foundErrors;\r\n        validator.findErrorsIn(foundErrors, testDriver, \"test\");\r\n\r\n        QString expectedError = QObject::tr(\"Invalid clock pulse value %1 set for other clock driver %2 within %3\")\r\n            .arg(pulseValue).arg(testDriver->getClockName()).arg(\"test\");\r\n        if (errorIsNotFoundInErrorList(expectedError, foundErrors))\r\n        {\r\n            QFAIL(\"No error message found\");\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_OtherClockDriverValidator::testHasValidClockPulseValue_data()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_OtherClockDriverValidator::testHasValidClockPulseValue_data()\r\n{\r\n    QTest::addColumn<QString>(\"pulseValue\");\r\n    QTest::addColumn<bool>(\"isValid\");\r\n\r\n    QTest::newRow(\"Clock pulse of 1 is valid\") << \"1\" << true;\r\n    QTest::newRow(\"Clock pulse of 0 is valid\") << \"0\" << true;\r\n    QTest::newRow(\"Clock pulse value that can be converted to bit vector is valid\") << \"24\" << true;\r\n    QTest::newRow(\"Clock pulse of 'b1001 is valid\") << \"'b1001\" << true;\r\n    QTest::newRow(\"Clock pulse of 0.24 is not valid\") << \"0.24\" << false;\r\n    QTest::newRow(\"Empty clock pulse is not valid\") << \"\" << false;\r\n    QTest::newRow(\"Text is not valid for clock pulse\") << \"text\" << false;\r\n    QTest::newRow(\"String is not valid for clock pulse\") << \"\\\"text\\\"\" << false;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_OtherClockDriverValidator::testHasValidClockPulseDuration()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_OtherClockDriverValidator::testHasValidClockPulseDuration()\r\n{\r\n    QFETCH(QString, clockValue);\r\n    QFETCH(bool, isValid);\r\n\r\n    QSharedPointer<ClockUnit> testUnit (new ClockUnit(clockValue));\r\n\r\n    QSharedPointer<OtherClockDriver> testDriver (new OtherClockDriver(\"MassDriver\"));\r\n    testDriver->setClockPulseDuration(testUnit);\r\n\r\n    QSharedPointer<ExpressionParser> parser(new SystemVerilogExpressionParser());\r\n    OtherClockDriverValidator validator(parser);\r\n\r\n    QCOMPARE(validator.hasValidClockValue(testDriver->getClockPulseDuration()), isValid);\r\n\r\n    if (!isValid)\r\n    {\r\n        QVector<QString> foundErrors;\r\n        validator.findErrorsIn(foundErrors, testDriver, \"test\");\r\n\r\n        QString expectedError = QObject::tr(\"Invalid clock pulse duration %1 set for other clock driver %2 within %3\")\r\n            .arg(clockValue).arg(testDriver->getClockName()).arg(\"test\");\r\n        if (errorIsNotFoundInErrorList(expectedError, foundErrors))\r\n        {\r\n            QFAIL(\"No error message found\");\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_OtherClockDriverValidator::testHasValidClockPulseDuration_data()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_OtherClockDriverValidator::testHasValidClockPulseDuration_data()\r\n{\r\n    QTest::addColumn<QString>(\"clockValue\");\r\n    QTest::addColumn<bool>(\"isValid\");\r\n\r\n    QTest::newRow(\"Clock value 1+1.12 is valid\") << \"1+1.12\" << true;\r\n    QTest::newRow(\"Clock value 0 is valid\") << \"0\" << true;\r\n    QTest::newRow(\"Clock value -4.12 is valid\") << \"-4.12\" << true;\r\n    QTest::newRow(\"Empty clock value is not valid\") << \"\" << false;\r\n    QTest::newRow(\"Text is not valid for clock value\") << \"text\" << false;\r\n    QTest::newRow(\"String is not valid for clock value\") << \"\\\"text\\\"\" << false;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_OtherClockDriverValidator::errorIsNotFoundInErrorList()\r\n//-----------------------------------------------------------------------------\r\nbool tst_OtherClockDriverValidator::errorIsNotFoundInErrorList(QString const& expectedError,\r\n    QVector<QString> errorList)\r\n{\r\n    if (!errorList.contains(expectedError))\r\n    {\r\n        qDebug() << \"The following error:\" << Qt::endl << expectedError << Qt::endl << \"was not found in error list:\";\r\n        for (QString const& error : errorList)\r\n        {\r\n            qDebug() << error;\r\n        }\r\n        return true;\r\n    }\r\n\r\n    return false;\r\n}\r\n\r\nQTEST_APPLESS_MAIN(tst_OtherClockDriverValidator)\r\n\r\n#include \"tst_OtherClockDriverValidator.moc\"\r\n"
  },
  {
    "path": "tests/IPXACTmodels/Component/tst_OtherClockDriverValidator.pri",
    "content": "# ----------------------------------------------------\r\n# This file is generated by the Qt Visual Studio Tools.\r\n# ------------------------------------------------------\r\n\r\nSOURCES += ./tst_OtherClockDriverValidator.cpp\r\n"
  },
  {
    "path": "tests/IPXACTmodels/Component/tst_OtherClockDriverValidator.pro",
    "content": "#-----------------------------------------------------------------------------\r\n# File: tst_OtherClockDriverValidator.pro\r\n#-----------------------------------------------------------------------------\r\n# Project: Kactus 2\r\n# Author: Mikko Teuho\r\n# Date: 14.12.2015\r\n#\r\n# Description:\r\n# Qt project file template for running unit tests for OtherClockDriverValidator.\r\n#-----------------------------------------------------------------------------\r\n\r\nTEMPLATE = app\r\n\r\nTARGET = tst_OtherClockDriverValidator\r\n\r\nQT += core xml testlib\r\nQT -= gui\r\n\r\nCONFIG += c++11 testcase console\r\n\r\nlinux-g++ | linux-g++-64 | linux-g++-32 {\r\n LIBS += -L../../../executable \\\r\n     -lIPXACTmodels -lKactusAPI\r\n}\r\nwin64 | win32 {\r\n LIBS += -L../../../executable \\\r\n     -lIPXACTmodelsd -lKactusAPId\r\n}\r\n\r\nINCLUDEPATH += $$DESTDIR\r\nINCLUDEPATH += ../../../\r\n\r\nDEPENDPATH += .\r\nDEPENDPATH += ../../../\r\n\r\nOBJECTS_DIR += $$DESTDIR\r\n\r\nMOC_DIR += ./generatedFiles\r\nUI_DIR += ./generatedFiles\r\nRCC_DIR += ./generatedFiles\r\ninclude(tst_OtherClockDriverValidator.pri)\r\n"
  },
  {
    "path": "tests/IPXACTmodels/Component/tst_OtherClockDriverWriter.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: tst_OtherClockDriverWriter.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Janne Virtanen\r\n// Date: 02.10.2015\r\n//\r\n// Description:\r\n// Unit test for class OtherClockDriverWriter.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include <IPXACTmodels/common/Parameter.h>\r\n#include <IPXACTmodels/common/ClockUnit.h>\r\n\r\n#include <IPXACTmodels/Component/OtherClockDriverWriter.h>\r\n\r\n#include <IPXACTmodels/common/VendorExtension.h>\r\n#include <IPXACTmodels/common/GenericVendorExtension.h>\r\n\r\n#include <QtTest>\r\n\r\nclass tst_OtherClockDriverWriter : public QObject\r\n{\r\n    Q_OBJECT\r\n\r\npublic:\r\n\ttst_OtherClockDriverWriter();\r\n\r\nprivate slots:\r\n\tvoid init();\r\n\tvoid cleanup();\r\n\r\n\tvoid testWriteOtherClockDriver();\r\n\tvoid testWriteClockPeriod();\r\n\tvoid testWriteClockPulses();\r\n\r\nprivate:\r\n\r\n\tQSharedPointer<OtherClockDriver> testOtherClockDriver_;\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_OtherClockDriverWriter::tst_OtherClockDriverWriter()\r\n//-----------------------------------------------------------------------------\r\ntst_OtherClockDriverWriter::tst_OtherClockDriverWriter()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_OtherClockDriverWriter::init()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_OtherClockDriverWriter::init()\r\n{\r\n\ttestOtherClockDriver_ = QSharedPointer<OtherClockDriver>(new OtherClockDriver());\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_OtherClockDriverWriter::cleanup()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_OtherClockDriverWriter::cleanup()\r\n{\r\n\ttestOtherClockDriver_.clear();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_OtherClockDriverWriter::testWriteOtherClockDriver()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_OtherClockDriverWriter::testWriteOtherClockDriver()\r\n{\r\n\tQString output;\r\n\tQXmlStreamWriter xmlStreamWriter(&output);\r\n\r\n\ttestOtherClockDriver_->setClockName(\"Marko\");\r\n\ttestOtherClockDriver_->setClockSource(\"Ari\");\r\n\r\n\tQString expectedOutput(\r\n\t\t\"<ipxact:otherClockDriver clockName=\\\"Marko\\\" clockSource=\\\"Ari\\\">\"\r\n        \"<ipxact:clockPeriod></ipxact:clockPeriod>\"\r\n        \"<ipxact:clockPulseOffset></ipxact:clockPulseOffset>\"\r\n        \"<ipxact:clockPulseValue></ipxact:clockPulseValue>\"\r\n        \"<ipxact:clockPulseDuration></ipxact:clockPulseDuration>\"\r\n\t\t\"</ipxact:otherClockDriver>\"\r\n\t\t);\r\n\r\n\tOtherClockDriverWriter otherClockDriverWriter;\r\n\totherClockDriverWriter.writeOtherClockDriver(xmlStreamWriter, testOtherClockDriver_);\r\n\tQCOMPARE(output, expectedOutput);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_OtherClockDriverWriter::testWriteClockPeriod()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_OtherClockDriverWriter::testWriteClockPeriod()\r\n{\r\n\tQString output;\r\n\tQXmlStreamWriter xmlStreamWriter(&output);\r\n\r\n    QSharedPointer<ClockUnit> clockPeriod (new ClockUnit(\"6\"));\r\n    clockPeriod->setTimeUnit(ClockUnit::PS);\r\n\r\n    testOtherClockDriver_->setClockPeriod(clockPeriod);\r\n\r\n\tQString expectedOutput(\r\n\t\t\"<ipxact:otherClockDriver clockName=\\\"\\\">\"\r\n    \t\t\"<ipxact:clockPeriod units=\\\"ps\\\">6</ipxact:clockPeriod>\"\r\n\t    \t\"<ipxact:clockPulseOffset></ipxact:clockPulseOffset>\"\r\n\t\t    \"<ipxact:clockPulseValue></ipxact:clockPulseValue>\"\r\n    \t\t\"<ipxact:clockPulseDuration></ipxact:clockPulseDuration>\"\r\n\t\t\"</ipxact:otherClockDriver>\"\r\n\t\t);\r\n\r\n\tOtherClockDriverWriter otherClockDriverWriter;\r\n\totherClockDriverWriter.writeOtherClockDriver(xmlStreamWriter, testOtherClockDriver_);\r\n\tQCOMPARE(output, expectedOutput);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_OtherClockDriverWriter::testWriteClockPulses()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_OtherClockDriverWriter::testWriteClockPulses()\r\n{\r\n\tQString output;\r\n\tQXmlStreamWriter xmlStreamWriter(&output);\r\n\r\n    QSharedPointer<ClockUnit> pulseOffset (new ClockUnit(\"1\"));\r\n    pulseOffset->setTimeUnit(ClockUnit::NS);\r\n\r\n    QSharedPointer<ClockUnit> pulseDuration (new ClockUnit(\"3\"));\r\n    pulseDuration->setTimeUnit(ClockUnit::PS);\r\n\r\n    testOtherClockDriver_->setClockPulseOffset(pulseOffset);\r\n    testOtherClockDriver_->setClockPulseDuration(pulseDuration);\r\n    testOtherClockDriver_->setClockPulseValue(\"2\");\r\n\r\n\tQString expectedOutput(\r\n\t\t\"<ipxact:otherClockDriver clockName=\\\"\\\">\"\r\n    \t\t\"<ipxact:clockPeriod></ipxact:clockPeriod>\"\r\n\t    \t\"<ipxact:clockPulseOffset units=\\\"ns\\\">1</ipxact:clockPulseOffset>\"\r\n\t\t    \"<ipxact:clockPulseValue>2</ipxact:clockPulseValue>\"\r\n    \t\t\"<ipxact:clockPulseDuration units=\\\"ps\\\">3</ipxact:clockPulseDuration>\"\r\n\t\t\"</ipxact:otherClockDriver>\"\r\n\t\t);\r\n\r\n\tOtherClockDriverWriter otherClockDriverWriter;\r\n\totherClockDriverWriter.writeOtherClockDriver(xmlStreamWriter, testOtherClockDriver_);\r\n\tQCOMPARE(output, expectedOutput);\r\n}\r\n\r\nQTEST_APPLESS_MAIN(tst_OtherClockDriverWriter)\r\n\r\n#include \"tst_OtherClockDriverWriter.moc\"\r\n"
  },
  {
    "path": "tests/IPXACTmodels/Component/tst_OtherClockDriverWriter.pri",
    "content": "# ----------------------------------------------------\r\n# This file is generated by the Qt Visual Studio Add-in.\r\n# ------------------------------------------------------\r\n\r\nSOURCES += ./tst_OtherClockDriverWriter.cpp \r\n"
  },
  {
    "path": "tests/IPXACTmodels/Component/tst_OtherClockDriverWriter.pro",
    "content": "#-----------------------------------------------------------------------------\r\n# File: tst_OtherClockDriverWriter.pro\r\n#-----------------------------------------------------------------------------\r\n# Project: Kactus 2\r\n# Author: Janne Virtanen\r\n# Date: 02.10.2015\r\n#\r\n# Description:\r\n# Qt project file template for running unit tests for OtherClockDriver writer.\r\n#-----------------------------------------------------------------------------\r\n\r\nTEMPLATE = app\r\n\r\nTARGET = tst_OtherClockDriverWriter\r\n\r\nQT += core xml testlib\r\nQT -= gui\r\n\r\nCONFIG += c++11 testcase console\r\n\r\nlinux-g++ | linux-g++-64 | linux-g++-32 {\r\n LIBS += -L../../../executable \\\r\n     -lIPXACTmodels\r\n}\r\nwin64 | win32 {\r\n LIBS += -L../../../executable \\\r\n     -lIPXACTmodelsd\r\n}\r\n\r\nINCLUDEPATH += $$DESTDIR\r\nINCLUDEPATH += ../../../\r\n\r\nDEPENDPATH += .\r\nDEPENDPATH += ../../../\r\n\r\nOBJECTS_DIR += $$DESTDIR\r\n\r\nMOC_DIR += ./generatedFiles\r\nUI_DIR += ./generatedFiles\r\nRCC_DIR += ./generatedFiles\r\ninclude(tst_OtherClockDriverWriter.pri)\r\n"
  },
  {
    "path": "tests/IPXACTmodels/Component/tst_ParameterReader.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: tst_ParameterReader.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Esko Pekkarinen\r\n// Date: 03.08.2015\r\n//\r\n// Description:\r\n// Unit test for class ParameterReader.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include <QtTest>\r\n\r\n#include <QDomNode>\r\n\r\n#include <IPXACTmodels/common/Parameter.h>\r\n#include <IPXACTmodels/common/ParameterReader.h>\r\n#include <IPXACTmodels/common/GenericVendorExtension.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Unit test for class ParameterReader.\r\n//-----------------------------------------------------------------------------\r\nclass tst_ParameterReader : public QObject\r\n{\r\n    Q_OBJECT\r\n\r\npublic:\r\n    tst_ParameterReader();\r\n\r\nprivate slots:\r\n    void testReadNameGroup();\r\n    void testReadAttributes();\r\n    void testReadValue();    \r\n    void testReadVector();\r\n    void testReadArray();\r\n    void testVendorExtensions();\r\n    void testReadAttributesAndValue();\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ParameterReader::tst_ParameterReader()\r\n//-----------------------------------------------------------------------------\r\ntst_ParameterReader::tst_ParameterReader()\r\n{\r\n    \r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ParameterReader::testReadNameGroup()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ParameterReader::testReadNameGroup()\r\n{\r\n    QDomDocument document;\r\n    document.setContent(QString(\r\n        \"<ipxact:parameter>\"\r\n            \"<ipxact:name>testParameter</ipxact:name>\"\r\n            \"<ipxact:displayName>firstParameter</ipxact:displayName>\"\r\n            \"<ipxact:description>This is parameter description.</ipxact:description>\"\r\n        \"</ipxact:parameter>\"));\r\n\r\n    QDomElement parameterElement = document.firstChildElement();\r\n\r\n    QSharedPointer<Parameter> testParameter = ParameterReader::createParameterFrom(parameterElement);\r\n   \r\n    QCOMPARE(testParameter->name(), QString(\"testParameter\"));\r\n    QCOMPARE(testParameter->displayName(), QString(\"firstParameter\"));\r\n    QCOMPARE(testParameter->description(), QString(\"This is parameter description.\"));\r\n}\r\n\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ParameterReader::testReadAttributes()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ParameterReader::testReadAttributes()\r\n{\r\n    QDomDocument document;\r\n    document.setContent(QString(\r\n        \"<ipxact:parameter parameterId=\\\"id\\\" prompt=\\\"please define a value\\\" choiceRef=\\\"choice1\\\" \"\r\n            \"order=\\\"1.0\\\" minimum=\\\"0\\\" maximum=\\\"1\\\" type=\\\"int\\\" sign=\\\"signed\\\" prefix=\\\"kilo\\\" \"\r\n            \"unit=\\\"hertz\\\" vendorAttribute=\\\"custom\\\">\"\r\n        \"</ipxact:parameter>\"));\r\n\r\n    QDomElement parameterElement = document.firstChildElement();\r\n\r\n    QSharedPointer<Parameter> testParameter = ParameterReader::createParameterFrom(parameterElement);\r\n\r\n    QCOMPARE(testParameter->getAttributeNames().size(), 11);\r\n\r\n    QCOMPARE(testParameter->getValueId(), QString(\"id\"));\r\n    QCOMPARE(testParameter->getType(), QString(\"int\"));\r\n    QCOMPARE(testParameter->getChoiceRef(), QString(\"choice1\"));\r\n    QCOMPARE(testParameter->getMinimumValue(), QString(\"0\"));\r\n    QCOMPARE(testParameter->getMaximumValue(), QString(\"1\"));\r\n\r\n    QCOMPARE(testParameter->getAttribute(\"prompt\"), QString(\"please define a value\"));    \r\n    QCOMPARE(testParameter->getAttribute(\"order\"), QString(\"1.0\"));\r\n    QCOMPARE(testParameter->getAttribute(\"sign\"), QString(\"signed\"));\r\n    QCOMPARE(testParameter->getAttribute(\"prefix\"), QString(\"kilo\"));\r\n    QCOMPARE(testParameter->getAttribute(\"unit\"), QString(\"hertz\"));\r\n    QCOMPARE(testParameter->getAttribute(\"vendorAttribute\"), QString(\"custom\"));\r\n}\r\n\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ParameterReader::testReadValue()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ParameterReader::testReadValue()\r\n{\r\n    QDomDocument document;\r\n    document.setContent(QString(\r\n        \"<ipxact:parameter>\"\r\n        \"<ipxact:value vendorAttribute=\\\"attributeValue\\\">parameterValue</ipxact:value>\"\r\n        \"</ipxact:parameter>\"));\r\n\r\n    QDomElement parameterElement = document.firstChildElement();\r\n\r\n    QSharedPointer<Parameter> testParameter = ParameterReader::createParameterFrom(parameterElement);\r\n\r\n    QCOMPARE(testParameter->getValue(), QString(\"parameterValue\"));\r\n    \r\n    QCOMPARE(testParameter->getValueAttributeNames().size(), 1);\r\n    QCOMPARE(testParameter->getValueAttribute(\"vendorAttribute\"), QString(\"attributeValue\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ParameterReader::testReadVector()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ParameterReader::testReadVector()\r\n{\r\n    QDomDocument document;\r\n    document.setContent(QString(\r\n        \"<ipxact:parameter>\"\r\n            \"<ipxact:vectors>\"\r\n                \"<ipxact:vector>\"\r\n                    \"<ipxact:left>leftExpression</ipxact:left>\"\r\n                    \"<ipxact:right>rightExpression</ipxact:right>\"\r\n                \"</ipxact:vector>\"\r\n            \"</ipxact:vectors>\"\r\n        \"</ipxact:parameter>\"));\r\n\r\n    QDomElement parameterElement = document.firstChildElement();\r\n\r\n    QSharedPointer<Parameter> testParameter = ParameterReader::createParameterFrom(parameterElement);\r\n\r\n    QCOMPARE(testParameter->getVectors()->size(), 1);\r\n    QCOMPARE(testParameter->getVectors()->first()->getLeft(), QString(\"leftExpression\"));\r\n    QCOMPARE(testParameter->getVectors()->first()->getRight(), QString(\"rightExpression\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ParameterReader::testReadVector()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ParameterReader::testReadArray()\r\n{\r\n    QDomDocument document;\r\n    document.setContent(QString(\r\n        \"<ipxact:parameter>\"\r\n            \"<ipxact:arrays>\"\r\n                \"<ipxact:array>\"\r\n                    \"<ipxact:left>leftExpression</ipxact:left>\"\r\n                    \"<ipxact:right>rightExpression</ipxact:right>\"\r\n                \"</ipxact:array>\"\r\n            \"</ipxact:arrays>\"\r\n        \"</ipxact:parameter>\"));\r\n\r\n    QDomElement parameterElement = document.firstChildElement();\r\n\r\n    QSharedPointer<Parameter> testParameter = ParameterReader::createParameterFrom(parameterElement);\r\n\r\n    QCOMPARE(testParameter->getArrays()->size(), 1);\r\n    QCOMPARE(testParameter->getArrayLeft(), QString(\"leftExpression\"));\r\n    QCOMPARE(testParameter->getArrayRight(), QString(\"rightExpression\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ParameterReader::testVendorExtensions()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ParameterReader::testVendorExtensions()\r\n{\r\n    QDomDocument document;\r\n    document.setContent(QString(\r\n        \"<ipxact:parameter>\"\r\n            \"<ipxact:name>testParameter</ipxact:name>\"\r\n            \"<ipxact:vendorExtensions>\"\r\n                \"<testExtension vendorAttribute=\\\"extension\\\">testValue</testExtension>\"\r\n            \"</ipxact:vendorExtensions>\"\r\n        \"</ipxact:parameter>\"));\r\n\r\n    QDomElement parameterElement = document.firstChildElement();\r\n\r\n    QSharedPointer<Parameter> testParameter = ParameterReader::createParameterFrom(parameterElement);\r\n\r\n    QCOMPARE(testParameter->getVendorExtensions()->size(), 1);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ParameterReader::testReadAttributesAndValue()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ParameterReader::testReadAttributesAndValue()\r\n{\r\n    QDomDocument document;\r\n    document.setContent(QString(\r\n        \"<ipxact:parameter parameterId=\\\"id\\\" prompt=\\\"please define a value:\\\">\"\r\n            \"<ipxact:name>parameter1</ipxact:name>\"\r\n            \"<ipxact:value vendorAttribute=\\\"attributeValue\\\">parameterValue</ipxact:value>\"\r\n        \"</ipxact:parameter>\"));\r\n\r\n    QDomElement parameterElement = document.firstChildElement();\r\n\r\n    QSharedPointer<Parameter> testParameter = ParameterReader::createParameterFrom(parameterElement);\r\n\r\n    QCOMPARE(testParameter->name(), QString(\"parameter1\"));\r\n\r\n    QCOMPARE(testParameter->getAttributeNames().size(), 2);\r\n\r\n    QCOMPARE(testParameter->getValueId(), QString(\"id\"));\r\n    QCOMPARE(testParameter->getAttribute(\"prompt\"), QString(\"please define a value:\"));    \r\n    \r\n    QCOMPARE(testParameter->getValue(), QString(\"parameterValue\"));\r\n    QCOMPARE(testParameter->getValueAttribute(\"vendorAttribute\"), QString(\"attributeValue\"));\r\n}\r\n\r\nQTEST_APPLESS_MAIN(tst_ParameterReader)\r\n\r\n#include \"tst_ParameterReader.moc\"\r\n"
  },
  {
    "path": "tests/IPXACTmodels/Component/tst_ParameterReader.pri",
    "content": "# ----------------------------------------------------\r\n# This file is generated by the Qt Visual Studio Tools.\r\n# ------------------------------------------------------\r\n\r\nSOURCES += ./tst_ParameterReader.cpp\r\n"
  },
  {
    "path": "tests/IPXACTmodels/Component/tst_ParameterReader.pro",
    "content": "#-----------------------------------------------------------------------------\r\n# File: tst_ParameterReader.pro\r\n#-----------------------------------------------------------------------------\r\n# Project: Kactus 2\r\n# Author: Esko Pekkarinen\r\n# Date: 03.08.2015\r\n#\r\n# Description:\r\n# Qt project file template for running unit tests for class ParameterReader.\r\n#-----------------------------------------------------------------------------\r\n\r\nTEMPLATE = app\r\n\r\nTARGET = tst_ParameterReader\r\n\r\nQT += core xml testlib\r\nQT -= gui\r\n\r\nCONFIG += c++11 testcase console\r\n\r\nlinux-g++ | linux-g++-64 | linux-g++-32 {\r\n LIBS += -L../../../executable \\\r\n     -lIPXACTmodels\r\n}\r\nwin64 | win32 {\r\n LIBS += -L../../../executable \\\r\n     -lIPXACTmodelsd\r\n}\r\n\r\nINCLUDEPATH += $$DESTDIR\r\nINCLUDEPATH += ../../../\r\n\r\nDEPENDPATH += .\r\nDEPENDPATH += ../../../\r\n\r\nOBJECTS_DIR += $$DESTDIR\r\n\r\nMOC_DIR += ./generatedFiles\r\nUI_DIR += ./generatedFiles\r\nRCC_DIR += ./generatedFiles\r\ninclude(tst_ParameterReader.pri)\r\n"
  },
  {
    "path": "tests/IPXACTmodels/Component/tst_ParameterValidator.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: tst_ParameterValidator.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Esko Pekkarinen\r\n// Date: 13.11.2014\r\n//\r\n// Description:\r\n// Unit test for class ParameterValidator.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include <QtTest>\r\n#include <QSharedPointer>\r\n\r\n#include <KactusAPI/include/SystemVerilogExpressionParser.h>\r\n\r\n#include <IPXACTmodels/common/Choice.h>\r\n#include <IPXACTmodels/common/Enumeration.h>\r\n#include <IPXACTmodels/common/Parameter.h>\r\n#include <IPXACTmodels/common/validators/ParameterValidator.h>\r\n\r\nclass tst_ParameterValidator : public QObject\r\n{\r\n    Q_OBJECT\r\n\r\npublic:\r\n    tst_ParameterValidator();\r\n\r\nprivate slots:\r\n\r\n    void testResolve();\r\n    void testResolve_data();\r\n\r\n    void testIdIsSpecifiedForResolveUserAndGenerated();\r\n    void testIdIsSpecifiedForResolveUserAndGenerated_data();\r\n\r\n    void testValue();\r\n    void testValue_data();\r\n\r\n    void testChoiceReference();\r\n    void testChoiceReference_data();\r\n\r\n    void testValueUsingChoice();\r\n    void testValueUsingChoice_data();\r\n\r\n    void testValidityWithMinimumValue();\r\n    void testValidityWithMinimumValue_data();\r\n\r\n    void testValidityWithMaximumValue();\r\n    void testValidityWithMaximumValue_data();\r\n\r\nprivate:\r\n        \r\n    QSharedPointer<Parameter> createParameterWithName();\r\n    ParameterValidator* createValidator(QSharedPointer<QList<QSharedPointer<Choice> > > choices =\r\n        QSharedPointer<QList<QSharedPointer<Choice> > >(new QList<QSharedPointer<Choice> >()));\r\n\r\n    QStringList findErrors(ParameterValidator* validator, QSharedPointer<Parameter> parameter);\r\n\r\n    bool errorIsNotFoundInErrorlist(QString const& expectedError, QStringList const& errorlist) const;\r\n\r\n\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_Parameter::tst_Parameter()\r\n//-----------------------------------------------------------------------------\r\ntst_ParameterValidator::tst_ParameterValidator()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ParameterValidator::testResolve()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ParameterValidator::testResolve()\r\n{\r\n    QFETCH(QString, resolve);\r\n    QFETCH(bool, expectedValid);\r\n\r\n    QSharedPointer<Parameter> parameter = createParameterWithName();\r\n    parameter->setValueResolve(resolve);\r\n\r\n    QScopedPointer<ParameterValidator> validator(createValidator());\r\n    QVERIFY(validator->hasValidResolve(parameter) == expectedValid);\r\n\r\n    if (!expectedValid)\r\n    {\r\n        QStringList errorlist =  findErrors(validator.data(), parameter);\r\n\r\n        QString expectedError = \"Invalid resolve \" + resolve + \" specified for parameter param within test\";\r\n        if (errorIsNotFoundInErrorlist(expectedError, errorlist))\r\n        {\r\n            QFAIL(\"No error message found.\");\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ParameterValidator::testResolve_data()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ParameterValidator::testResolve_data()\r\n{\r\n    QTest::addColumn<QString>(\"resolve\");\r\n    QTest::addColumn<bool>(\"expectedValid\");\r\n\r\n    QTest::newRow(\"empty resolve is valid\") << \"\" << true;\r\n    QTest::newRow(\"immediate resolve is valid\") << \"immediate\" << true;\r\n    QTest::newRow(\"user resolve is valid\") << \"user\" << true;\r\n    QTest::newRow(\"generated resolve is valid\") << \"generated\" << true;\r\n\r\n    QTest::newRow(\"other resolve is invalid\") << \"other\" << false;\r\n    QTest::newRow(\"number resolve is invalid\") << \"1\" << false;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ParameterValidator::testIdIsSpecifiedForResolveUserAndGenerated()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ParameterValidator::testIdIsSpecifiedForResolveUserAndGenerated()\r\n{\r\n    QFETCH(QString, id);\r\n    QFETCH(QString, resolve);\r\n    QFETCH(bool, expectedValid);\r\n\r\n    QSharedPointer<Parameter> parameter = createParameterWithName();\r\n    parameter->setValueId(id);\r\n    parameter->setValueResolve(resolve);\r\n\r\n    QScopedPointer<ParameterValidator> validator(createValidator());\r\n    QVERIFY(validator->hasValidValueId(parameter) == expectedValid);\r\n\r\n   if (!expectedValid)\r\n    {\r\n        QStringList errorlist =  findErrors(validator.data(), parameter);\r\n\r\n        QString expectedError = \"No identifier specified for parameter param with resolve \" + resolve + \" within test\";\r\n        if (errorIsNotFoundInErrorlist(expectedError, errorlist))\r\n        {\r\n            QFAIL(\"No error message found.\");\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ParameterValidator::testIdIsSpecifiedForResolveUserAndGenerated()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ParameterValidator::testIdIsSpecifiedForResolveUserAndGenerated_data()\r\n{\r\n    QTest::addColumn<QString>(\"id\");\r\n    QTest::addColumn<QString>(\"resolve\");\r\n    QTest::addColumn<bool>(\"expectedValid\");\r\n\r\n    QTest::newRow(\"No id for unspecified resolve is valid\") << \"\" << \"\" << true;\r\n    QTest::newRow(\"Id for unspecified resolve is valid\") << \"1\" << \"\" << true;\r\n\r\n    QTest::newRow(\"No id for resolve user is invalid\") << \"\" << \"user\" << false;\r\n    QTest::newRow(\"Id for resolve user is valid\") << \"1\" << \"user\" << true;\r\n\r\n    QTest::newRow(\"No id for resolve generated is invalid\") << \"\" << \"generated\" << false;\r\n    QTest::newRow(\"Id for resolve generated is valid\") << \"1\" << \"generated\" << true;\r\n\r\n    QTest::newRow(\"No id for resolve immediate is valid\") << \"\" << \"immediate\" << true;\r\n    QTest::newRow(\"Id for resolve immediate is valid\") << \"1\" << \"immediate\" << true;\r\n\r\n    QTest::newRow(\"No id for resolve dependent is valid\") << \"\" << \"dependent\" << true;\r\n    QTest::newRow(\"Id for resolve dependent is valid\") << \"1\" << \"dependent\" << true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ParameterValidator::testValue()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ParameterValidator::testValue()\r\n{\r\n    QFETCH(QString, value);\r\n    QFETCH(bool, expectedValid);\r\n\r\n    QSharedPointer<Parameter> parameter = createParameterWithName();\r\n    parameter->setValue(value);\r\n    parameter->setType(\"bit\");\r\n\r\n    QScopedPointer<ParameterValidator> validator(createValidator());\r\n    QVERIFY(validator->hasValidValue(parameter) == expectedValid);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ParameterValidator::testValue_data()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ParameterValidator::testValue_data()\r\n{\r\n    QTest::addColumn<QString>(\"value\");\r\n    QTest::addColumn<bool>(\"expectedValid\");\r\n\r\n    QTest::newRow(\"Empty value is invalid\") << \"\" << false;\r\n    QTest::newRow(\"Integer is valid\") << \"1\" << true;\r\n    QTest::newRow(\"Array is valid\") << \"{1,1}\" << true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ParameterValidator::testChoiceReference()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ParameterValidator::testChoiceReference()\r\n{\r\n    QFETCH(QStringList, choiceNames);\r\n    QFETCH(QString, choiceRef);\r\n    QFETCH(bool, expectedValid);\r\n\r\n    QSharedPointer<Parameter> parameter = createParameterWithName();\r\n    parameter->setChoiceRef(choiceRef);\r\n\r\n    QSharedPointer<QList<QSharedPointer<Choice> > > choices(new QList<QSharedPointer<Choice> >());\r\n\r\n    foreach(QString choiceName, choiceNames)\r\n    {\r\n        QSharedPointer<Choice> choice(new Choice());\r\n        choice->setName(choiceName);\r\n        choices->append(choice);\r\n    }\r\n\r\n    QScopedPointer<ParameterValidator> validator(createValidator(choices));\r\n    QVERIFY(validator->hasValidChoice(parameter) == expectedValid);\r\n\r\n    if (!expectedValid)\r\n    {\r\n        QStringList errorlist =  findErrors(validator.data(), parameter);\r\n\r\n        QString expectedError = \"Choice choice1 referenced in parameter param is not specified within test\";\r\n\r\n        if (errorIsNotFoundInErrorlist(expectedError, errorlist))\r\n        {\r\n            QFAIL(\"No error message found.\");\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_Parameter::testChoiceReference_data()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ParameterValidator::testChoiceReference_data()\r\n{\r\n    QTest::addColumn<QStringList>(\"choiceNames\");\r\n    QTest::addColumn<QString>(\"choiceRef\");\r\n    QTest::addColumn<bool>(\"expectedValid\");\r\n\r\n    QTest::newRow(\"Empty choice is valid\") << QStringList() << \"\" << true;\r\n    QTest::newRow(\"Empty choice is valid if choices available\") << QStringList(\"choice1\") << \"\" << true;\r\n\r\n    QTest::newRow(\"No choices available but reference set is not valid\") << QStringList() << \"choice1\" << false;\r\n    QTest::newRow(\"Reference to unavailable choice is not valid\") << QStringList(\"choice0\") << \"choice1\" << false;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ParameterValidator::testValueUsingChoice()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ParameterValidator::testValueUsingChoice()\r\n{\r\n    QFETCH(QString, choiceRef);\r\n    QFETCH(QStringList, enumerations);\r\n    QFETCH(QString, value);\r\n    QFETCH(bool, expectedValid);\r\n\r\n    QSharedPointer<Parameter> parameter = createParameterWithName();\r\n    parameter->setChoiceRef(choiceRef);\r\n    parameter->setValue(value);\r\n\r\n    QSharedPointer<QList<QSharedPointer<Choice> > > choices(new QList<QSharedPointer<Choice> > ());\r\n\r\n    QSharedPointer<Choice> referencedChoice(new Choice());\r\n    referencedChoice->setName(choiceRef);\r\n    foreach(QString enumerationValue, enumerations)\r\n    {\r\n        QSharedPointer<Enumeration> enumeration(new Enumeration());\r\n        enumeration->setValue(enumerationValue);\r\n        referencedChoice->enumerations()->append(enumeration);\r\n    }\r\n    choices->append(referencedChoice);\r\n\r\n    QScopedPointer<ParameterValidator> validator(createValidator(choices));\r\n    QVERIFY(validator->hasValidValue(parameter) == expectedValid);\r\n\r\n    if (!expectedValid && !value.isEmpty())\r\n    {\r\n        QStringList errorlist =  findErrors(validator.data(), parameter);\r\n\r\n        QString expectedError = \"Value '\" + value + \"' references unknown enumeration \"\r\n            \"for choice \" + choiceRef + \" in parameter param within test\";\r\n\r\n        if (errorIsNotFoundInErrorlist(expectedError, errorlist))\r\n        {\r\n            QFAIL(\"No error message found.\");\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_Parameter::testValueUsingChoice_data()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ParameterValidator::testValueUsingChoice_data()\r\n{\r\n    QTest::addColumn<QString>(\"choiceRef\");\r\n    QTest::addColumn<QStringList>(\"enumerations\");\r\n    QTest::addColumn<QString>(\"value\");\r\n    QTest::addColumn<bool>(\"expectedValid\");\r\n\r\n    QTest::newRow(\"Empty choice and numeric value is valid\") << \"\" << QStringList() << \"1\" << true;\r\n    QTest::newRow(\"Choice and empty value is not valid\") << \"choice1\" << QStringList() << \"\" << false;\r\n\r\n    QTest::newRow(\"Choice with no enumerations is not valid\") << \"choice1\" << QStringList() << \"1\" << false;\r\n    QTest::newRow(\"Choice and value not in enumerations is not valid\") \r\n        << \"choice1\" << QStringList(\"0\") << \"1\" << false;\r\n\r\n    QTest::newRow(\"Choice and value in enumeration is valid\") << \"choice1\" << QStringList(\"1\") << \"1\" << true;\r\n    QTest::newRow(\"Choice and value in enumerations is valid\") \r\n        << \"choice1\" << QString(\"0,1,2\").split(',') << \"1\" << true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ParameterValidator::testValidityWithMinimumValue()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ParameterValidator::testValidityWithMinimumValue()\r\n{\r\n    QFETCH(QString, value);\r\n    QFETCH(QString, minimum);\r\n    QFETCH(bool, expectedValid);\r\n\r\n    QSharedPointer<Parameter> parameter = createParameterWithName();    \r\n    parameter->setValue(value);\r\n    parameter->setType(QStringLiteral(\"int\"));\r\n    parameter->setMinimumValue(minimum);\r\n\r\n    QScopedPointer<ParameterValidator> validator(createValidator());\r\n    QVERIFY(validator->hasValidValue(parameter) == expectedValid);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ParameterValidator::testValidityWithMinimumValue_data()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ParameterValidator::testValidityWithMinimumValue_data()\r\n{\r\n    QTest::addColumn<QString>(\"value\");\r\n    QTest::addColumn<QString>(\"minimum\");\r\n    QTest::addColumn<bool>(\"expectedValid\");\r\n\r\n    QTest::newRow(\"Empty minimum is valid\") << \"1\" << \"\" << true;\r\n    QTest::newRow(\"Value equal to minimum is valid\") << \"1\" << \"1\" << true; \r\n    QTest::newRow(\"Value greater than minimum is valid\") << \"2\" << \"1\" << true;\r\n    \r\n    QTest::newRow(\"Value less than minimum is not valid\") << \"1\" << \"2\" << false;\r\n    QTest::newRow(\"Value less than negative minimum is not valid\") << \"-2\" << \"-1\" << false;\r\n\r\n    QTest::newRow(\"Empty minimum is valid for array\") << \"{1,1}\" << \"\" << true;\r\n    QTest::newRow(\"Value greater than minimum is valid for array\") << \"{2,3}\" << \"1\" << true;\r\n\r\n    QTest::newRow(\"Every value in array must be greater than minimum\") << \"{0,1,2}\" << \"1\" << false;\r\n    QTest::newRow(\"Empty array is not valid\") << \"{}\" << \"1\" << false;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ParameterValidator::testValidityWithMaximumValue()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ParameterValidator::testValidityWithMaximumValue()\r\n{\r\n    QFETCH(QString, value);\r\n    QFETCH(QString, maximum);\r\n    QFETCH(bool, expectedValid);\r\n\r\n    QSharedPointer<Parameter> parameter = createParameterWithName();\r\n    parameter->setValue(value);\r\n    parameter->setType(QStringLiteral(\"int\"));\r\n    parameter->setMaximumValue(maximum);\r\n\r\n    QScopedPointer<ParameterValidator> validator(createValidator());\r\n    QVERIFY(validator->hasValidValue(parameter) == expectedValid);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ParameterValidator::testValidityWithMaximumValue_data()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ParameterValidator::testValidityWithMaximumValue_data()\r\n{\r\n    QTest::addColumn<QString>(\"value\");\r\n    QTest::addColumn<QString>(\"maximum\");\r\n    QTest::addColumn<bool>(\"expectedValid\");\r\n\r\n    QTest::newRow(\"Empty maximum is valid\") << \"1\" << \"\" << true;\r\n    QTest::newRow(\"Value equal to maximum is valid\") << \"1\" << \"1\" << true;\r\n    QTest::newRow(\"Value less than maximum is valid\") << \"1\" << \"2\" << true;\r\n\r\n    QTest::newRow(\"Value greater than maximum is not valid\") << \"2\" << \"1\" << false;\r\n\r\n    QTest::newRow(\"Empty maximum is valid for array\") << \"{1,1}\" << \"\" << true;\r\n    QTest::newRow(\"Value less than maximum is valid for array\") << \"{1,2}\" << \"3\" << true;\r\n\r\n    QTest::newRow(\"Every value in array must be less than maximum\") << \"{0,1,2}\" << \"1\" << false;\r\n    QTest::newRow(\"Empty array is not valid\") << \"{}\" << \"1\" << false;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ParameterValidator::createParameterWithName()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<Parameter> tst_ParameterValidator::createParameterWithName()\r\n{\r\n    QSharedPointer<Parameter> parameter(new Parameter());\r\n    parameter->setName(\"param\");\r\n\r\n    return parameter;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ParameterValidator::createValidator()\r\n//-----------------------------------------------------------------------------\r\nParameterValidator* tst_ParameterValidator::createValidator(QSharedPointer<QList<QSharedPointer<Choice> > > choices)\r\n{\r\n    QSharedPointer<SystemVerilogExpressionParser> basicParser(new SystemVerilogExpressionParser());\r\n   \r\n    return new ParameterValidator(basicParser, choices, Document::Revision::Std14);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ParameterValidator::verifyErrorIsFoundInErrorlist()\r\n//-----------------------------------------------------------------------------\r\nbool tst_ParameterValidator::errorIsNotFoundInErrorlist(QString const& expectedError, QStringList const& errorlist) const\r\n{\r\n    if (!errorlist.contains(expectedError))\r\n    {\r\n        qDebug() << \"The following error:\" << Qt::endl << expectedError << Qt::endl << \"was not found in errorlist:\";\r\n        for (QString const& error : errorlist)\r\n        {\r\n            qDebug() << error; \r\n        }\r\n        return true;\r\n    }\r\n\r\n    return false;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ParameterValidator::findErrors()\r\n//-----------------------------------------------------------------------------\r\nQStringList tst_ParameterValidator::findErrors(ParameterValidator* validator, QSharedPointer<Parameter> parameter)\r\n{\r\n    QVector<QString> errors; \r\n    validator->findErrorsIn(errors, parameter, \"test\");\r\n    return errors.toList();\r\n}\r\n\r\nQTEST_APPLESS_MAIN(tst_ParameterValidator)\r\n\r\n#include \"tst_ParameterValidator.moc\"\r\n"
  },
  {
    "path": "tests/IPXACTmodels/Component/tst_ParameterValidator.pri",
    "content": "# ----------------------------------------------------\r\n# This file is generated by the Qt Visual Studio Tools.\r\n# ------------------------------------------------------\r\n\r\nSOURCES += ./tst_ParameterValidator.cpp\r\n\t"
  },
  {
    "path": "tests/IPXACTmodels/Component/tst_ParameterValidator.pro",
    "content": "#-----------------------------------------------------------------------------\r\n# File: tst_ParameterValidator.pro\r\n#-----------------------------------------------------------------------------\r\n# Project: Kactus 2\r\n# Author: Esko Pekkarinen\r\n# Date: 13.11.2014\r\n#\r\n# Description:\r\n# Qt project file template for running unit tests for ParameterValidator.\r\n#-----------------------------------------------------------------------------\r\n\r\nTEMPLATE = app\r\n\r\nTARGET = tst_ParameterValidator\r\n\r\nQT += core gui xml testlib\r\n\r\nCONFIG += c++11 testcase console\r\n\r\nlinux-g++ | linux-g++-64 | linux-g++-32 {\r\n LIBS += -L../../../executable \\\r\n     -lIPXACTmodels -lKactusAPI\r\n}\r\nwin64 | win32 {\r\n LIBS += -L../../../executable \\\r\n     -lIPXACTmodelsd -lKactusAPId\r\n}\r\n\r\nINCLUDEPATH += $$DESTDIR\r\nINCLUDEPATH += ../../../\r\n\r\nDEPENDPATH += .\r\nDEPENDPATH += ../../../\r\n\r\nOBJECTS_DIR += $$DESTDIR\r\n\r\nMOC_DIR += ./generatedFiles\r\nUI_DIR += ./generatedFiles\r\nRCC_DIR += ./generatedFiles\r\ninclude(tst_ParameterValidator.pri)\r\n"
  },
  {
    "path": "tests/IPXACTmodels/Component/tst_ParameterWriter.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: tst_ParameterWriter.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Esko Pekkarinen\r\n// Date: 31.07.2015\r\n//\r\n// Description:\r\n// Unit test for class ParameterWriter.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include <QtTest>\r\n#include <QXmlStreamWriter>\r\n\r\n#include <IPXACTmodels/common/Parameter.h>\r\n#include <IPXACTmodels/common/ParameterWriter.h>\r\n#include <IPXACTmodels/common/GenericVendorExtension.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Unit test for class ParameterWriter.\r\n//-----------------------------------------------------------------------------\r\nclass tst_ParameterWriter : public QObject\r\n{\r\n    Q_OBJECT\r\n\r\npublic:\r\n    tst_ParameterWriter();\r\n\r\nprivate slots:\r\n    void testWriteNameGroup();\r\n    void testWriteAttributes();\r\n    void testWriteValue();    \r\n    void testWriteVector();\r\n    void testWriteArray();\r\n    void testVendorExtensions();\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ParameterWriter::tst_ParameterWriter()\r\n//-----------------------------------------------------------------------------\r\ntst_ParameterWriter::tst_ParameterWriter()\r\n{\r\n    \r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ParameterWriter::testWriteNameGroup()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ParameterWriter::testWriteNameGroup()\r\n{\r\n    QSharedPointer<Parameter> testParameter(new Parameter());\r\n    testParameter->setValueId(\"\");\r\n    testParameter->setName(\"testParameter\");\r\n    testParameter->setValue(\"1\");\r\n\r\n    QString output;\r\n    QXmlStreamWriter xmlStreamWriter(&output);\r\n    \r\n    ParameterWriter::writeParameter(xmlStreamWriter, testParameter, Document::Revision::Std14);\r\n    QCOMPARE(output, QString(\r\n        \"<ipxact:parameter>\"\r\n            \"<ipxact:name>testParameter</ipxact:name>\"\r\n            \"<ipxact:value>1</ipxact:value>\"\r\n        \"</ipxact:parameter>\"));\r\n    \r\n    testParameter->setDisplayName(\"firstParameter\");\r\n\r\n    output.clear();\r\n    ParameterWriter::writeParameter(xmlStreamWriter, testParameter, Document::Revision::Std14);\r\n    QCOMPARE(output, QString(\r\n        \"<ipxact:parameter>\"\r\n            \"<ipxact:name>testParameter</ipxact:name>\"\r\n            \"<ipxact:displayName>firstParameter</ipxact:displayName>\"\r\n            \"<ipxact:value>1</ipxact:value>\"\r\n        \"</ipxact:parameter>\"));\r\n\r\n    testParameter->setDescription(\"This is parameter description.\");\r\n\r\n    output.clear();\r\n    ParameterWriter::writeParameter(xmlStreamWriter, testParameter, Document::Revision::Std14);\r\n    QCOMPARE(output, QString(\r\n        \"<ipxact:parameter>\"\r\n            \"<ipxact:name>testParameter</ipxact:name>\"\r\n            \"<ipxact:displayName>firstParameter</ipxact:displayName>\"\r\n            \"<ipxact:description>This is parameter description.</ipxact:description>\"\r\n            \"<ipxact:value>1</ipxact:value>\"\r\n        \"</ipxact:parameter>\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ParameterWriter::testWriteAttributes()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ParameterWriter::testWriteAttributes()\r\n{\r\n    QSharedPointer<Parameter> testParameter(new Parameter());\r\n    testParameter->setName(\"testParameter\");\r\n    testParameter->setChoiceRef(\"choice1\");\r\n    testParameter->setMaximumValue(\"1\");\r\n    testParameter->setMinimumValue(\"0\");\r\n    testParameter->setValueId(\"id\");\r\n    testParameter->setType(\"int\");\r\n    testParameter->setValueResolve(\"user\");\r\n    testParameter->setValue(\"1\");\r\n\r\n    QString output;\r\n    QXmlStreamWriter xmlStreamWriter(&output);\r\n\r\n    ParameterWriter::writeParameter(xmlStreamWriter, testParameter, Document::Revision::Std14);\r\n    QCOMPARE(output, QString(\r\n        \"<ipxact:parameter choiceRef=\\\"choice1\\\" maximum=\\\"1\\\" minimum=\\\"0\\\" parameterId=\\\"id\\\" resolve=\\\"user\\\" type=\\\"int\\\">\"\r\n            \"<ipxact:name>testParameter</ipxact:name>\"\r\n            \"<ipxact:value>1</ipxact:value>\"\r\n        \"</ipxact:parameter>\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ParameterWriter::testWriteValue()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ParameterWriter::testWriteValue()\r\n{\r\n    QSharedPointer<Parameter> testParameter(new Parameter());\r\n    testParameter->setValueId(\"\");\r\n    testParameter->setName(\"testParameter\");\r\n    testParameter->setValue(\"parameterValue\");\r\n    testParameter->setValueAttribute(\"vendorAttribute\", \"attributeValue\");\r\n\r\n    QString output;\r\n    QXmlStreamWriter xmlStreamWriter(&output);\r\n\r\n    ParameterWriter::writeParameter(xmlStreamWriter, testParameter, Document::Revision::Std14);\r\n    QCOMPARE(output, QString(\r\n        \"<ipxact:parameter>\"\r\n            \"<ipxact:name>testParameter</ipxact:name>\"\r\n            \"<ipxact:value vendorAttribute=\\\"attributeValue\\\">parameterValue</ipxact:value>\"\r\n        \"</ipxact:parameter>\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ParameterWriter::testWriteVector()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ParameterWriter::testWriteVector()\r\n{\r\n    QSharedPointer<Parameter> testParameter(new Parameter());\r\n    testParameter->setValueId(\"\");\r\n    testParameter->setName(\"testParameter\");\r\n    testParameter->setValue(\"1\");\r\n\r\n    QString output;\r\n    QXmlStreamWriter xmlStreamWriter(&output);\r\n\r\n    ParameterWriter::writeParameter(xmlStreamWriter, testParameter, Document::Revision::Std14);\r\n    QCOMPARE(output, QString(\r\n        \"<ipxact:parameter>\"\r\n            \"<ipxact:name>testParameter</ipxact:name>\"\r\n            \"<ipxact:value>1</ipxact:value>\"\r\n        \"</ipxact:parameter>\"));\r\n\r\n    testParameter->setVectorLeft(\"leftExpression\");\r\n    testParameter->setVectorRight(\"rightExpression\");\r\n\r\n    output.clear();\r\n    ParameterWriter::writeParameter(xmlStreamWriter, testParameter, Document::Revision::Std14);\r\n    QCOMPARE(output, QString(\r\n        \"<ipxact:parameter>\"\r\n            \"<ipxact:name>testParameter</ipxact:name>\"\r\n            \"<ipxact:vectors>\"\r\n                \"<ipxact:vector>\"\r\n                    \"<ipxact:left>leftExpression</ipxact:left>\"\r\n                    \"<ipxact:right>rightExpression</ipxact:right>\"\r\n                \"</ipxact:vector>\"\r\n            \"</ipxact:vectors>\"\r\n            \"<ipxact:value>1</ipxact:value>\"\r\n        \"</ipxact:parameter>\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ParameterWriter::testWriteArray()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ParameterWriter::testWriteArray()\r\n{\r\n    QSharedPointer<Parameter> testParameter(new Parameter());\r\n    testParameter->setValueId(\"\");\r\n    testParameter->setName(\"testParameter\");\r\n    testParameter->setValue(\"1\");\r\n\r\n    QString output;\r\n    QXmlStreamWriter xmlStreamWriter(&output);\r\n\r\n    ParameterWriter::writeParameter(xmlStreamWriter, testParameter, Document::Revision::Std14);\r\n    QCOMPARE(output, QString(\r\n        \"<ipxact:parameter>\"\r\n            \"<ipxact:name>testParameter</ipxact:name>\"\r\n            \"<ipxact:value>1</ipxact:value>\"\r\n        \"</ipxact:parameter>\"));\r\n\r\n    testParameter->setArrayLeft(\"leftExpression\");\r\n    testParameter->setArrayRight(\"rightExpression\");\r\n\r\n    output.clear();\r\n    ParameterWriter::writeParameter(xmlStreamWriter, testParameter, Document::Revision::Std14);\r\n    QCOMPARE(output, QString(\r\n        \"<ipxact:parameter>\"\r\n            \"<ipxact:name>testParameter</ipxact:name>\"\r\n            \"<ipxact:arrays>\"\r\n                \"<ipxact:array>\"\r\n                    \"<ipxact:left>leftExpression</ipxact:left>\"\r\n                    \"<ipxact:right>rightExpression</ipxact:right>\"\r\n                \"</ipxact:array>\"\r\n            \"</ipxact:arrays>\"\r\n            \"<ipxact:value>1</ipxact:value>\"\r\n        \"</ipxact:parameter>\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ParameterWriter::testVendorExtensions()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ParameterWriter::testVendorExtensions()\r\n{\r\n    QSharedPointer<Parameter> testParameter(new Parameter());\r\n    testParameter->setValueId(\"\");\r\n    testParameter->setName(\"testParameter\");\r\n    testParameter->setValue(\"1\");\r\n    \r\n    QDomDocument document;\r\n    QDomElement extensionNode = document.createElement(\"testExtension\");\r\n    extensionNode.setAttribute(\"vendorAttribute\", \"extension\");\r\n    extensionNode.appendChild(document.createTextNode(\"testValue\"));\r\n\r\n    QSharedPointer<GenericVendorExtension> testExtension(new GenericVendorExtension(extensionNode));\r\n    QSharedPointer<QList<QSharedPointer<VendorExtension> > > vendorExtensions = testParameter->getVendorExtensions();\r\n    vendorExtensions->append(testExtension);\r\n\r\n    QString output;\r\n    QXmlStreamWriter xmlStreamWriter(&output);\r\n\r\n    ParameterWriter::writeParameter(xmlStreamWriter, testParameter, Document::Revision::Std14);\r\n    QCOMPARE(output, QString(\r\n        \"<ipxact:parameter>\"\r\n            \"<ipxact:name>testParameter</ipxact:name>\"\r\n            \"<ipxact:value>1</ipxact:value>\"\r\n            \"<ipxact:vendorExtensions>\"\r\n                \"<testExtension vendorAttribute=\\\"extension\\\">testValue</testExtension>\"\r\n            \"</ipxact:vendorExtensions>\"\r\n        \"</ipxact:parameter>\"));\r\n}\r\n\r\nQTEST_APPLESS_MAIN(tst_ParameterWriter)\r\n\r\n#include \"tst_ParameterWriter.moc\"\r\n"
  },
  {
    "path": "tests/IPXACTmodels/Component/tst_ParameterWriter.pri",
    "content": "# ----------------------------------------------------\r\n# This file is generated by the Qt Visual Studio Tools.\r\n# ------------------------------------------------------\r\n\r\nSOURCES += ./tst_ParameterWriter.cpp \r\n"
  },
  {
    "path": "tests/IPXACTmodels/Component/tst_ParameterWriter.pro",
    "content": "#-----------------------------------------------------------------------------\r\n# File: tst_ParameterWriter.pro\r\n#-----------------------------------------------------------------------------\r\n# Project: Kactus 2\r\n# Author: Esko Pekkarinen\r\n# Date: 31.07.2015\r\n#\r\n# Description:\r\n# Qt project file template for running unit tests for class ParameterWriter.\r\n#-----------------------------------------------------------------------------\r\n\r\nTEMPLATE = app\r\n\r\nTARGET = tst_ParameterWriter\r\n\r\nQT += core xml testlib\r\nQT -= gui\r\n\r\nCONFIG += c++11 testcase console\r\n\r\nlinux-g++ | linux-g++-64 | linux-g++-32 {\r\n LIBS += -L../../../executable \\\r\n     -lIPXACTmodels\r\n}\r\nwin64 | win32 {\r\n LIBS += -L../../../executable \\\r\n     -lIPXACTmodelsd\r\n}\r\n\r\nINCLUDEPATH += $$DESTDIR\r\nINCLUDEPATH += ../../../\r\n\r\nDEPENDPATH += .\r\nDEPENDPATH += ../../../\r\n\r\nOBJECTS_DIR += $$DESTDIR\r\n\r\nMOC_DIR += ./generatedFiles\r\nUI_DIR += ./generatedFiles\r\nRCC_DIR += ./generatedFiles\r\ninclude(tst_ParameterWriter.pri)\r\n"
  },
  {
    "path": "tests/IPXACTmodels/Component/tst_PowerDomainReader.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: tst_PowerDomainReader.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Esko Pekkarinen\n// Date: 04.10.2023\n//\n// Description:\n// Unit test for class PowerDomainReader.\n//-----------------------------------------------------------------------------\n\n#include <IPXACTmodels/Component/PowerDomainReader.h>\n\n#include <QtTest>\n\nclass tst_PowerDomainReader : public QObject\n{\n    Q_OBJECT\n\npublic:\n    tst_PowerDomainReader();\n\nprivate slots:\n\n    void testReadNamedPowerDomain();\n    void testReadProperties();\n    void testReadParameters();\n    void testReadVendorExtensions();\n\n};\n\n//-----------------------------------------------------------------------------\n// Function: tst_PowerDomainReader::tst_PowerDomainReader()\n//-----------------------------------------------------------------------------\ntst_PowerDomainReader::tst_PowerDomainReader()\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_PowerDomainReader::testReadNamedPowerDomain()\n//-----------------------------------------------------------------------------\nvoid tst_PowerDomainReader::testReadNamedPowerDomain()\n{\n    QString documentContent(\n        \"<ipxact:powerDomain>\"\n            \"<ipxact:name>testPowerDomain</ipxact:name>\"\n            \"<ipxact:displayName>testDisplay</ipxact:displayName>\"\n            \"<ipxact:shortDescription>testBrief</ipxact:shortDescription>\"\n            \"<ipxact:description>testDescription</ipxact:description>\"\n        \"</ipxact:powerDomain>\"\n        );\n\n    QDomDocument document;\n    document.setContent(documentContent);\n\n    QDomNode PowerDomainNode = document.firstChildElement(\"ipxact:powerDomain\");\n\n    QSharedPointer<PowerDomain> testPowerDomain = PowerDomainReader::createFrom(PowerDomainNode);\n\n    QCOMPARE(testPowerDomain->name(), QString(\"testPowerDomain\"));\n    QCOMPARE(testPowerDomain->displayName(), QString(\"testDisplay\"));\n    QCOMPARE(testPowerDomain->shortDescription(), QString(\"testBrief\"));\n    QCOMPARE(testPowerDomain->description(), QString(\"testDescription\"));\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_PowerDomainReader::testReadProperties()\n//-----------------------------------------------------------------------------\nvoid tst_PowerDomainReader::testReadProperties()\n{\n    QString documentContent(\n        \"<ipxact:powerDomain>\"\n            \"<ipxact:name>testPowerDomain</ipxact:name>\"\n            \"<ipxact:alwaysOn>onExpression</ipxact:alwaysOn>\"\n            \"<ipxact:subDomainOf>mainDomain</ipxact:subDomainOf>\"\n        \"</ipxact:powerDomain>\"\n    );\n\n    QDomDocument document;\n    document.setContent(documentContent);\n\n    QDomNode PowerDomainNode = document.firstChildElement(\"ipxact:powerDomain\");\n\n    QSharedPointer<PowerDomain> testPowerDomain = PowerDomainReader::createFrom(PowerDomainNode);\n\n    QCOMPARE(testPowerDomain->name(), QString(\"testPowerDomain\"));\n    QCOMPARE(testPowerDomain->getAlwaysOn(), QString(\"onExpression\"));\n    QCOMPARE(testPowerDomain->getSubDomainOf(), QString(\"mainDomain\"));\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_PowerDomainReader::testReadParameters()\n//-----------------------------------------------------------------------------\nvoid tst_PowerDomainReader::testReadParameters()\n{\n    QString documentContent(\n        \"<ipxact:powerDomain>\"\n            \"<ipxact:name>testPowerDomain</ipxact:name>\"\n\t\t    \"<ipxact:parameters>\"\n        \t\t\"<ipxact:parameter parameterId=\\\"id1\\\" prompt=\\\"Parm 1\\\" type=\\\"shortint\\\" resolve=\\\"user\\\">\"\n            \t\t\"<ipxact:name>param1</ipxact:name>\"\n            \t\t\"<ipxact:description>First generator parameter.</ipxact:description>\"\n            \t\t\"<ipxact:value>5</ipxact:value>\"\n        \t\t\"</ipxact:parameter>\"\n        \t\t\"<ipxact:parameter parameterId=\\\"id2\\\" prompt=\\\"Parm 1\\\" type=\\\"shortint\\\" resolve=\\\"user\\\">\"\n            \t\t\"<ipxact:name>param2</ipxact:name>\"\n            \t\t\"<ipxact:description>First generator parameter.</ipxact:description>\"\n            \t\t\"<ipxact:value>13</ipxact:value>\"\n        \t\t\"</ipxact:parameter>\"\n    \t\t\"</ipxact:parameters>\"\n        \"</ipxact:powerDomain>\"\n    );\n\n    QDomDocument document;\n    document.setContent(documentContent);\n\n    QDomNode PowerDomainNode = document.firstChildElement(\"ipxact:powerDomain\");\n\n    QSharedPointer<PowerDomain> testPowerDomain = PowerDomainReader::createFrom(PowerDomainNode);\n\n    QCOMPARE(testPowerDomain->getParameters()->size(), 2);\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_CPUReader::testReadVendorExtensions()\n//-----------------------------------------------------------------------------\nvoid tst_PowerDomainReader::testReadVendorExtensions()\n{\n    QString documentContent(\n        \"<ipxact:powerDomain>\"\n            \"<ipxact:name>testPowerDomain</ipxact:name>\"\n            \"<ipxact:vendorExtensions>\"\n                \"<testExtension testExtensionAttribute=\\\"extension\\\">testValue</testExtension>\"\n            \"</ipxact:vendorExtensions>\"\n        \"</ipxact:powerDomain>\"\n    );\n\n    QDomDocument document;\n    document.setContent(documentContent);\n\n    QDomNode PowerDomainNode = document.firstChildElement(\"ipxact:powerDomain\");\n\n    QSharedPointer<PowerDomain> testPowerDomain = PowerDomainReader::createFrom(PowerDomainNode);\n\n    QCOMPARE(testPowerDomain->getVendorExtensions()->size(), 1);\n    QCOMPARE(testPowerDomain->getVendorExtensions()->first()->type(), QString(\"testExtension\"));\n}\n\nQTEST_APPLESS_MAIN(tst_PowerDomainReader)\n\n#include \"tst_PowerDomainReader.moc\"\n"
  },
  {
    "path": "tests/IPXACTmodels/Component/tst_PowerDomainReader.pri",
    "content": "# ----------------------------------------------------\n# This file is generated by the Qt Visual Studio Add-in.\n# ------------------------------------------------------\n\nSOURCES += ./tst_PowerDomainReader.cpp \n"
  },
  {
    "path": "tests/IPXACTmodels/Component/tst_PowerDomainReader.pro",
    "content": "#-----------------------------------------------------------------------------\n# File: tst_PowerDomainReader.pro\n#-----------------------------------------------------------------------------\n# Project: Kactus2\n# Author: Esko Pekkarinen\n# Date: 04.10.2023\n#\n# Description:\n# Qt project file for running unit tests for PowerDomain reader.\n#-----------------------------------------------------------------------------\n\nTEMPLATE = app\n\nTARGET = tst_PowerDomainReader\n\nQT += core xml testlib\nQT -= gui\n\nCONFIG += c++11 testcase console\n\nlinux-g++ | linux-g++-64 | linux-g++-32 {\n LIBS += -L../../../executable \\\n     -lIPXACTmodels\n\n}\nwin64 | win32 {\n LIBS += -L../../../executable \\\n     -lIPXACTmodelsd\n}\n\nINCLUDEPATH += $$DESTDIR\nINCLUDEPATH += ../../../\n\nDEPENDPATH += .\nDEPENDPATH += ../../../\n\nOBJECTS_DIR += $$DESTDIR\n\nMOC_DIR += ./generatedFiles\nUI_DIR += ./generatedFiles\nRCC_DIR += ./generatedFiles\n\ninclude(tst_PowerDomainReader.pri)\n"
  },
  {
    "path": "tests/IPXACTmodels/Component/tst_PowerDomainValidator.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: tst_PowerDomainvalidator.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Esko Pekkarinen\n// Date: 6.10.2023\n//\n// Description:\n// Unit test for class PowerDomainValidator\n//-----------------------------------------------------------------------------\n\n#include <KactusAPI/include/SystemVerilogExpressionParser.h>\n\n#include <IPXACTmodels/Component/validators/PowerDomainValidator.h>\n#include <IPXACTmodels/common/validators/ParameterValidator.h>\n\n#include <IPXACTmodels/Component/PowerDomain.h>\n#include <IPXACTmodels/common/Parameter.h>\n\n#include <QtTest>\n\nclass tst_PowerDomainValidator : public QObject\n{\n    Q_OBJECT\n\npublic:\n    tst_PowerDomainValidator();\n\nprivate slots:\n  \n    void testHasValidName();\n    void testHasValidName_data();\n\n    void testHasValidAlwaysOn();\n    void testHasValidAlwaysOn_data();\n\n    void testHasValidSubDomain();\n    void testHasValidSubDomain_data();\n\n    void testHasValidParameters();\n\nprivate:\n\n    bool errorIsNotFoundInErrorList(QString const& expectedError, QVector<QString> errorList);\n\n    QSharedPointer<PowerDomainValidator> createValidator();\n};\n\n//-----------------------------------------------------------------------------\n// Function: tst_PowerDomainValidator::tst_PowerDomainValidator()\n//-----------------------------------------------------------------------------\ntst_PowerDomainValidator::tst_PowerDomainValidator()\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_PowerDomainValidator::testHasValidName()\n//-----------------------------------------------------------------------------\nvoid tst_PowerDomainValidator::testHasValidName()\n{\n    QFETCH(QString, name);\n    QFETCH(bool, isValid);\n\n    QSharedPointer<PowerDomain> testDomain(new PowerDomain());\n    testDomain->setName(name);\n\n    QSharedPointer<PowerDomainValidator> validator = createValidator();\n\n    QCOMPARE(validator->hasValidName(testDomain->name()), isValid);\n\n    if (!isValid)\n    {\n        QVector<QString> foundErrors;\n        validator->findErrorsIn(foundErrors, testDomain, \"test\");\n\n        QString expectedError = QObject::tr(\"Invalid name specified for power domain %1 within %2\")\n            .arg(testDomain->name(), \"test\");\n        if (errorIsNotFoundInErrorList(expectedError, foundErrors))\n        {\n            QFAIL(\"No error message found\");\n        }\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_PowerDomainValidator::testHasValidName_data()\n//-----------------------------------------------------------------------------\nvoid tst_PowerDomainValidator::testHasValidName_data()\n{\n    QTest::addColumn<QString>(\"name\");\n    QTest::addColumn<bool>(\"isValid\");\n\n    QTest::newRow(\"Name test is valid\") << \"test\" << true;\n    QTest::newRow(\"Empty name is invalid\") << \"\" << false;\n    QTest::newRow(\"Name consisting of only white spaces is invalid\") << \"    \" << false;\n    QTest::newRow(\"Name consisting of characters and white spaces is valid\") << \"  test  \" << true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_PowerDomainValidator::testHasValidAlwaysOn()\n//-----------------------------------------------------------------------------\nvoid tst_PowerDomainValidator::testHasValidAlwaysOn()\n{\n    QFETCH(QString, alwaysOn);\n    QFETCH(bool, isValid);\n\n    QSharedPointer<PowerDomain> testDomain (new PowerDomain());\n    testDomain->setName(\"testDomain\");\n    testDomain->setAlwaysOn(alwaysOn);\n\n    QSharedPointer<PowerDomainValidator> validator = createValidator();\n\n    QCOMPARE(validator->hasValidAlwaysOn(testDomain), isValid);\n\n    if (!isValid)\n    {\n        QVector<QString> foundErrors;\n        validator->findErrorsIn(foundErrors, testDomain, \"test\");\n\n        QString expectedError = \n            QObject::tr(\"Invalid expression set for always on in power domain testDomain within test\");\n        if (errorIsNotFoundInErrorList(expectedError, foundErrors))\n        {\n            QFAIL(\"No error message found\");\n        }\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_PowerDomainValidator::testHasValidAlwaysOn_data()\n//-----------------------------------------------------------------------------\nvoid tst_PowerDomainValidator::testHasValidAlwaysOn_data()\n{\n    QTest::addColumn<QString>(\"alwaysOn\");\n    QTest::addColumn<bool>(\"isValid\");\n\n    QTest::newRow(\"1 is valid for always on\") << \"1\" << true;\n    QTest::newRow(\"0 is valid for always on\") << \"0\" << true;\n    QTest::newRow(\"Empty value is valid for always on\") << \"\" << true;\n    QTest::newRow(\"12*2+13-5 is not valid for always on\") << \"12*2+13-5\" << false;\n    QTest::newRow(\"-20 is not valid for always on\") << \"-20\" << false;\n    QTest::newRow(\"Text is not valid for always on\") << \"text\" << false;\n    QTest::newRow(\"String is not valid for always on\") << \"\\\"text\\\"\" << false;\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_PowerDomainValidator::testHasValidSubDomain()\n//-----------------------------------------------------------------------------\nvoid tst_PowerDomainValidator::testHasValidSubDomain()\n{\n    QFETCH(QString, subDomain);\n    QFETCH(bool, isValid);\n\n    QSharedPointer<PowerDomain> testDomain(new PowerDomain());\n    testDomain->setName(\"testDomain\");\n    testDomain->setSubDomainOf(subDomain);\n\n    QSharedPointer<PowerDomainValidator> validator = createValidator();\n\n    QCOMPARE(validator->hasValidSubDomainOf(testDomain), isValid);\n\n    if (!isValid)\n    {\n        QVector<QString> foundErrors;\n        validator->findErrorsIn(foundErrors, testDomain, \"test\");\n\n        QString expectedError =\n            QObject::tr(\"Invalid power domain '%1' referenced in power domain testDomain within test\").arg(\n                subDomain);\n        if (errorIsNotFoundInErrorList(expectedError, foundErrors))\n        {\n            QFAIL(\"No error message found\");\n        }\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_PowerDomainValidator::testHasValidSubDomain_data()\n//-----------------------------------------------------------------------------\nvoid tst_PowerDomainValidator::testHasValidSubDomain_data()\n{\n    QTest::addColumn<QString>(\"subDomain\");\n    QTest::addColumn<bool>(\"isValid\");\n\n    QTest::newRow(\"Empty domain is valid\") << \"\" << true;\n    QTest::newRow(\"Non-existent domain is not valid\") << \"None\" << false;\n    QTest::newRow(\"Existing domain is valid\") << \"main\" << true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_PowerDomainValidator::testHasValidParameters()\n//-----------------------------------------------------------------------------\nvoid tst_PowerDomainValidator::testHasValidParameters()\n{\n    QSharedPointer<Parameter> testParameter (new Parameter());\n    testParameter->setValueId(\"Sanger\");\n    testParameter->setName(\"Daizengar\");\n    testParameter->setValue(\"\");\n    testParameter->setType(\"int\");\n\n    QSharedPointer<PowerDomain> testDomain (new PowerDomain());\n    testDomain->setName(\"testDomain\");\n    testDomain->getParameters()->append(testParameter);\n\n    QSharedPointer<PowerDomainValidator> validator = createValidator();\n    QCOMPARE(validator->hasValidParameters(testDomain), false);\n\n    QVector<QString> errorsFound;\n    validator->findErrorsIn(errorsFound, testDomain, \"test\");\n\n    QString expectedError = QObject::tr(\"No value specified for %1 %2 within power domain %3\").\n        arg(testParameter->elementName()).arg(testParameter->name(), testDomain->name());\n\n    if (errorIsNotFoundInErrorList(expectedError, errorsFound))\n    {\n        QFAIL(\"Error was not found\");\n    }\n\n    testParameter->setValue(\"20\");\n    QCOMPARE(validator->hasValidParameters(testDomain), true);\n\n    QSharedPointer<Parameter> otherParameter (new Parameter(*testParameter));\n    otherParameter->setValue(\"2\");\n    testDomain->getParameters()->append(otherParameter);\n\n    QCOMPARE(validator->hasValidParameters(testDomain), false);\n\n    errorsFound.clear();\n    validator->findErrorsIn(errorsFound, testDomain, \"test\");\n    expectedError = QObject::tr(\"Name %1 of parameters in power domain %2 is not unique.\")\n        .arg(otherParameter->name(), testDomain->name());\n    if (errorIsNotFoundInErrorList(expectedError, errorsFound))\n    {\n        QFAIL(\"Error was not found\");\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_PowerDomainValidator::errorIsNotFoundInErrorList()\n//-----------------------------------------------------------------------------\nbool tst_PowerDomainValidator::errorIsNotFoundInErrorList(QString const& expectedError,\n    QVector<QString> errorList)\n{\n    if (!errorList.contains(expectedError))\n    {\n        qDebug() << \"The following error:\" << Qt::endl << expectedError << Qt::endl << \"was not found in error list:\";\n        for (QString const& error : errorList)\n        {\n            qDebug() << error;\n        }\n        return true;\n    }\n\n    return false;\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_PowerDomainValidator::createValidator()\n//-----------------------------------------------------------------------------\nQSharedPointer<PowerDomainValidator> tst_PowerDomainValidator::createValidator()\n{\n    QSharedPointer<ExpressionParser> parser(new SystemVerilogExpressionParser());\n    QSharedPointer<ParameterValidator> parameterValidator(\n        new ParameterValidator(parser, QSharedPointer<QList<QSharedPointer<Choice> > >(), Document::Revision::Std22));\n\n    QSharedPointer<QList<QSharedPointer<PowerDomain> > > componentDomains(new QList<QSharedPointer<PowerDomain> >());\n    QSharedPointer<PowerDomain> referenceDomain(new PowerDomain());\n    referenceDomain->setName(\"main\");\n    componentDomains->append(referenceDomain);\n\n    QSharedPointer<PowerDomainValidator> validator(\n        new PowerDomainValidator(componentDomains, parser, parameterValidator));\n\n    return validator;\n}\n\n\nQTEST_APPLESS_MAIN(tst_PowerDomainValidator)\n\n#include \"tst_PowerDomainValidator.moc\"\n"
  },
  {
    "path": "tests/IPXACTmodels/Component/tst_PowerDomainValidator.pri",
    "content": "# ----------------------------------------------------\n# This file is generated by the Qt Visual Studio Tools.\n# ------------------------------------------------------\n   \nSOURCES += ./tst_PowerDomainValidator.cpp \n   "
  },
  {
    "path": "tests/IPXACTmodels/Component/tst_PowerDomainValidator.pro",
    "content": "#-----------------------------------------------------------------------------\n# File: tst_PowerDomainValidator.pro\n#-----------------------------------------------------------------------------\n# Project: Kactus 2\n# Author: Mikko Teuho\n# Date: 30.11.2015\n#\n# Description:\n# Qt project file template for running unit tests for PowerDomainValidator.\n#-----------------------------------------------------------------------------\n\nTEMPLATE = app\n\nTARGET = tst_PowerDomainValidator\n\nQT += core gui xml testlib\n\nCONFIG += c++11 testcase console\n\nlinux-g++ | linux-g++-64 | linux-g++-32 {\n LIBS += -L../../../executable \\\n     -lIPXACTmodels -lKactusAPI\n}\n\nwin64 | win32 {\n LIBS += -L../../../executable \\\n     -lIPXACTmodelsd -lKactusAPId\n}\n\nINCLUDEPATH += $$DESTDIR\nINCLUDEPATH += ../../../\nINCLUDEPATH += ../../../KactusAPI/include\n\nDEPENDPATH += .\nDEPENDPATH += ../../../\n\nOBJECTS_DIR += $$DESTDIR\n\nMOC_DIR += ./generatedFiles\nUI_DIR += ./generatedFiles\nRCC_DIR += ./generatedFiles\ninclude(tst_PowerDomainValidator.pri)\n"
  },
  {
    "path": "tests/IPXACTmodels/Component/tst_PowerDomainWriter.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: tst_PowerDomainWriter.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Esko Pekkarinen\n// Date: 05.10.2023\n//\n// Description:\n// Unit test for class PowerDomainWriter.\n//-----------------------------------------------------------------------------\n\n#include <IPXACTmodels/Component/PowerDomainWriter.h>\n\n#include <IPXACTmodels/common/Document.h>\n\n#include <IPXACTmodels/kactusExtensions/Kactus2Value.h>\n\n#include <QtTest>\n\nclass tst_PowerDomainWriter : public QObject\n{\n    Q_OBJECT\n\npublic:\n\ttst_PowerDomainWriter();\n\nprivate slots:\n\n\tvoid testWritePowerDomainNameGroup();\n\n\tvoid testWriteProperties();\n\n    void testWriteParameters();\n\n\tvoid testWriteVendorExtensions();\n\n};\n\n//-----------------------------------------------------------------------------\n// Function: tst_PowerDomainWriter::tst_PowerDomainWriter()\n//-----------------------------------------------------------------------------\ntst_PowerDomainWriter::tst_PowerDomainWriter()\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_PowerDomainWriter::testWritePowerDomainNameGroup()\n//-----------------------------------------------------------------------------\nvoid tst_PowerDomainWriter::testWritePowerDomainNameGroup()\n{\n\tQString output;\n\tQXmlStreamWriter xmlStreamWriter(&output);\n\n    auto testPowerDomain = QSharedPointer<PowerDomain>(new PowerDomain());\n    testPowerDomain->setName(\"testPowerDomain\");\n    testPowerDomain->setDisplayName(\"testDisplay\");\n    testPowerDomain->setShortDescription(\"testBrief\");\n    testPowerDomain->setDescription(\"testDescription\");\n\n\tQString expectedOutput = \n\t\t\"<ipxact:powerDomain>\"\n\t\t    \"<ipxact:name>testPowerDomain</ipxact:name>\"\n\t\t    \"<ipxact:displayName>testDisplay</ipxact:displayName>\"\n\t\t    \"<ipxact:shortDescription>testBrief</ipxact:shortDescription>\"\n\t\t    \"<ipxact:description>testDescription</ipxact:description>\"\n\t\t\"</ipxact:powerDomain>\";\n\n\tPowerDomainWriter::write(xmlStreamWriter, testPowerDomain);\n\tQCOMPARE(output, expectedOutput);\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_PowerDomainWriter::testWriteProperties()\n//-----------------------------------------------------------------------------\nvoid tst_PowerDomainWriter::testWriteProperties()\n{\n    QString output;\n    QXmlStreamWriter xmlStreamWriter(&output);\n\n    auto testPowerDomain = QSharedPointer<PowerDomain>(new PowerDomain());\n    testPowerDomain->setName(\"testPowerDomain\");\n    testPowerDomain->setAlwaysOn(\"1\");\n    testPowerDomain->setSubDomainOf(\"mainDomain\");\n\n    QString expectedOutput =\n        \"<ipxact:powerDomain>\"\n            \"<ipxact:name>testPowerDomain</ipxact:name>\"\n            \"<ipxact:alwaysOn>1</ipxact:alwaysOn>\"\n            \"<ipxact:subDomainOf>mainDomain</ipxact:subDomainOf>\"\n        \"</ipxact:powerDomain>\";\n\n    PowerDomainWriter::write(xmlStreamWriter, testPowerDomain);\n    QCOMPARE(output, expectedOutput);\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_PowerDomainWriter::testWriteParameters()\n//-----------------------------------------------------------------------------\nvoid tst_PowerDomainWriter::testWriteParameters()\n{\n    QString output;\n    QXmlStreamWriter xmlStreamWriter(&output);\n\n    auto testPowerDomain = QSharedPointer<PowerDomain>(new PowerDomain());\n    testPowerDomain->setName(\"testPowerDomain\");\n\n    auto testParameter = QSharedPointer<Parameter>(new Parameter());\n    testParameter->setName(\"voltage\");\n    testParameter->setValueId(\"id\");\n    testParameter->setValue(\"0.9\");\n\n    testPowerDomain->getParameters()->append(testParameter);\n\n    QString expectedOutput =\n        \"<ipxact:powerDomain>\"\n            \"<ipxact:name>testPowerDomain</ipxact:name>\"\n            \"<ipxact:parameters>\"\n                \"<ipxact:parameter parameterId=\\\"id\\\">\"\n                    \"<ipxact:name>voltage</ipxact:name>\"\n                    \"<ipxact:value>0.9</ipxact:value>\"\n                \"</ipxact:parameter>\"\n            \"</ipxact:parameters>\"\n        \"</ipxact:powerDomain>\";\n\n    PowerDomainWriter::write(xmlStreamWriter, testPowerDomain);\n    QCOMPARE(output, expectedOutput);\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_PowerDomainWriter::testWriteVendorExtensions()\n//-----------------------------------------------------------------------------\nvoid tst_PowerDomainWriter::testWriteVendorExtensions()\n{\n    QString output;\n    QXmlStreamWriter xmlStreamWriter(&output);\n\n\n    auto testPowerDomain = QSharedPointer<PowerDomain>(new PowerDomain());\n    testPowerDomain->setName(\"testPowerDomain\");\n\ttestPowerDomain->getVendorExtensions()->append(QSharedPointer<VendorExtension>(\n\t\tnew Kactus2Value(\"testExtension\", \"testValue\")));\n\n    QString expectedOutput =\n        \"<ipxact:powerDomain>\"\n\t\t\t\"<ipxact:name>testPowerDomain</ipxact:name>\"\n\t\t\t\"<ipxact:vendorExtensions>\"\n\t\t\t\t\"<testExtension>testValue</testExtension>\"\n\t\t\t\"</ipxact:vendorExtensions>\"\n        \"</ipxact:powerDomain>\";\n\n\tPowerDomainWriter::write(xmlStreamWriter, testPowerDomain);\n    QCOMPARE(output, expectedOutput);\n}\n\n\nQTEST_APPLESS_MAIN(tst_PowerDomainWriter)\n\n#include \"tst_PowerDomainWriter.moc\"\n"
  },
  {
    "path": "tests/IPXACTmodels/Component/tst_PowerDomainWriter.pri",
    "content": "# ----------------------------------------------------\n# This file is generated by the Qt Visual Studio Add-in.\n# ------------------------------------------------------\n\nSOURCES += ./tst_PowerDomainWriter.cpp\n  "
  },
  {
    "path": "tests/IPXACTmodels/Component/tst_PowerDomainWriter.pro",
    "content": "#-----------------------------------------------------------------------------\n# File: tst_PowerDomainWriter.pro\n#-----------------------------------------------------------------------------\n# Project: Kactus2\n# Author: Esko Pekkarinen\n# Date: 05.10.2023\n#\n# Description:\n# Qt project file for running unit tests for PowerDomain writer.\n#-----------------------------------------------------------------------------\n\nTEMPLATE = app\n\nTARGET = tst_PowerDomainWriter\n\nQT += core xml testlib\nQT -= gui\n\nCONFIG += c++11 testcase console\n\nlinux-g++ | linux-g++-64 | linux-g++-32 {\n LIBS += -L../../../executable \\\n     -lIPXACTmodels\n}\n\nwin64 | win32 {\n LIBS += -L../../../executable \\\n     -lIPXACTmodelsd\n}\n\nINCLUDEPATH += $$DESTDIR\nINCLUDEPATH += ../../../\n\nDEPENDPATH += .\nDEPENDPATH += ../../../\n\nOBJECTS_DIR += $$DESTDIR\n\nMOC_DIR += ./generatedFiles\nUI_DIR += ./generatedFiles\nRCC_DIR += ./generatedFiles\ninclude(tst_PowerDomainWriter.pri)\n"
  },
  {
    "path": "tests/IPXACTmodels/Component/tst_RegisterFileValidator.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: tst_RegisterFileValidator.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Mikko Teuho\n// Date: 19.11.2015\n//\n// Description:\n// Unit test for class RegisterValidator.\n//-----------------------------------------------------------------------------\n\n#include <IPXACTmodels/Component/validators/RegisterFileValidator.h>\n\n#include <IPXACTmodels/Component/validators/EnumeratedValueValidator.h>\n#include <IPXACTmodels/common/validators/ParameterValidator.h>\n#include <IPXACTmodels/Component/validators/FieldValidator.h>\n#include <IPXACTmodels/Component/validators/RegisterValidator.h>\n\n#include <IPXACTmodels/Component/RegisterFile.h>\n#include <IPXACTmodels/Component/Register.h>\n#include <IPXACTmodels/Component/EnumeratedValue.h>\n#include <IPXACTmodels/Component/WriteValueConstraint.h>\n#include <IPXACTmodels/Component/MemoryArray.h>\n#include <IPXACTmodels/Component/Component.h>\n#include <IPXACTmodels/Component/Mode.h>\n#include <IPXACTmodels/common/Parameter.h>\n\n#include <IPXACTmodels/generaldeclarations.h>\n\n#include <KactusAPI/include/SystemVerilogExpressionParser.h>\n#include <KactusAPI/include/ComponentParameterFinder.h>\n\n\n#include <QtTest>\n\nclass tst_RegisterFileValidator : public QObject\n{\n    Q_OBJECT\n\npublic:\n    tst_RegisterFileValidator();\n\nprivate slots:\n    \n    void testNameIsValid();\n    void testNameIsValid_data();\n\n    void testIsPresentIsValid();\n    void testIsPresentIsValid_data();\n\n    void testDimensionIsValid();\n    void testDimensionIsValid_data();\n\n    void testAddressOffsetIsValid();\n    void testAddressOffsetIsValid_data();\n\n    void testRangeIsValid();\n    void testRangeIsValid_data();\n\n    void testMemoryArrayIsValid();\n    void testMemoryArrayIsValid_data();\n\n    void testAccessPoliciesAreValid();\n\n    void testRegisterDataIsValid();\n\n    void testRegisterDataUniqueNames();\n    void testRegisterDataUniqueNames_data();\n\nprivate:\n\n    bool errorIsNotFoundInErrorList(QString const& expectedError, QStringList const& errorList);\n};\n\n//-----------------------------------------------------------------------------\n// Function: tst_RegisterFileValidator::tst_RegisterFileValidator()\n//-----------------------------------------------------------------------------\ntst_RegisterFileValidator::tst_RegisterFileValidator()\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_RegisterFileValidator::testNameIsValid()\n//-----------------------------------------------------------------------------\nvoid tst_RegisterFileValidator::testNameIsValid()\n{\n    QFETCH(QString, name);\n    QFETCH(bool, isValid);\n\n    QSharedPointer<RegisterFile> testRegisterFile(new RegisterFile(name));\n\n    QSharedPointer<ExpressionParser> parser(new SystemVerilogExpressionParser());\n    QSharedPointer<ParameterValidator> parameterValidator(new ParameterValidator(parser,\n        QSharedPointer<QList<QSharedPointer<Choice> > >(), Document::Revision::Std14));\n    QSharedPointer<EnumeratedValueValidator> enumValidator(new EnumeratedValueValidator(parser));\n    QSharedPointer<FieldValidator> fieldValidator(new FieldValidator(parser, enumValidator, parameterValidator));\n    QSharedPointer<RegisterValidator> registerValidator(new RegisterValidator(parser, fieldValidator, parameterValidator));\n\n    RegisterFileValidator validator(parser, registerValidator, parameterValidator, Document::Revision::Std14);\n\n    QCOMPARE(validator.hasValidName(testRegisterFile), isValid);\n\n    if (!isValid)\n    {\n        QVector<QString> foundErrors;\n        validator.findErrorsIn(foundErrors, testRegisterFile, \"test\", \"8\", \"32\");\n\n        QString expectedError = QObject::tr(\"Invalid name specified for register file '%1' within %2\").\n            arg(testRegisterFile->name(), \"test\");\n        if (errorIsNotFoundInErrorList(expectedError, foundErrors))\n        {\n            QFAIL(\"No error message found\");\n        }\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_RegisterFileValidator::testNameIsValid_data()\n//-----------------------------------------------------------------------------\nvoid tst_RegisterFileValidator::testNameIsValid_data()\n{\n    QTest::addColumn<QString>(\"name\");\n    QTest::addColumn<bool>(\"isValid\");\n\n    QTest::newRow(\"Name test is valid\") << \"test\" << true;\n    QTest::newRow(\"Empty name is invalid\") << \"\" << false;\n    QTest::newRow(\"Name consisting of only white spaces is invalid\") << \"    \" << false;\n    QTest::newRow(\"Name consisting of characters and white spaces is valid\") << \"  test  \" << true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_RegisterFileValidator::testIsPresentIsValid()\n//-----------------------------------------------------------------------------\nvoid tst_RegisterFileValidator::testIsPresentIsValid()\n{\n    QFETCH(QString, isPresent);\n    QFETCH(bool, isValid);\n\n    QSharedPointer<RegisterFile> testRegisterFile(new RegisterFile(\"name\"));\n    testRegisterFile->setIsPresent(isPresent);\n\n    QSharedPointer<ExpressionParser> parser(new SystemVerilogExpressionParser());\n    QSharedPointer<ParameterValidator> parameterValidator(new ParameterValidator(parser,\n        QSharedPointer<QList<QSharedPointer<Choice> > >(), Document::Revision::Std14));\n    QSharedPointer<EnumeratedValueValidator> enumValidator(new EnumeratedValueValidator(parser));\n    QSharedPointer<FieldValidator> fieldValidator(new FieldValidator(parser, enumValidator, parameterValidator));\n    QSharedPointer<RegisterValidator> registerValidator(new RegisterValidator(parser, fieldValidator, parameterValidator));\n\n    RegisterFileValidator validator(parser, registerValidator, parameterValidator, Document::Revision::Std14);\n\n    if (!isValid)\n    {\n        QVector<QString> foundErrors;\n        validator.findErrorsIn(foundErrors, testRegisterFile, \"test\", \"8\", \"32\");\n\n        QString expectedError = QObject::tr(\"Invalid isPresent set for register file '%1' within %2\").\n            arg(testRegisterFile->name(), \"test\");\n        if (errorIsNotFoundInErrorList(expectedError, foundErrors))\n        {\n            QFAIL(\"No error message found\");\n        }\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_RegisterFileValidator::testIsPresentIsValid_data()\n//-----------------------------------------------------------------------------\nvoid tst_RegisterFileValidator::testIsPresentIsValid_data()\n{\n    QTest::addColumn<QString>(\"isPresent\");\n    QTest::addColumn<bool>(\"isValid\");\n\n    QTest::newRow(\"IsPresent 1 is valid\") << \"1\" << true;\n    QTest::newRow(\"IsPresent 1*3-3 is valid\") << \"1*3-3\" << true;\n    QTest::newRow(\"IsPresent 2*100 is invalid\") << \"2*100\" << false;\n    QTest::newRow(\"IsPresent -14 is invalid\") << \"-14\" << false;\n    QTest::newRow(\"Real number isPresent  0.12 is invalid\") << \"0.12\" << false;\n    QTest::newRow(\"Text as isPresent is invalid\") << \"test\" << false;\n    QTest::newRow(\"String as isPresent is invalid\") << \"\\\"test\\\"\" << false;\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_RegisterFileValidator::testDimensionIsValid()\n//-----------------------------------------------------------------------------\nvoid tst_RegisterFileValidator::testDimensionIsValid()\n{\n    QFETCH(QString, dimension);\n    QFETCH(bool, isValid);\n\n    QSharedPointer<RegisterFile> testRegisterFile(new RegisterFile(\"name\"));\n    testRegisterFile->setDimension(dimension);\n\n    QSharedPointer<ExpressionParser> parser(new SystemVerilogExpressionParser());\n    QSharedPointer<ParameterValidator> parameterValidator(new ParameterValidator(parser,\n        QSharedPointer<QList<QSharedPointer<Choice> > >(), Document::Revision::Std14));\n    QSharedPointer<EnumeratedValueValidator> enumValidator(new EnumeratedValueValidator(parser));\n    QSharedPointer<FieldValidator> fieldValidator(new FieldValidator(parser, enumValidator, parameterValidator));\n    QSharedPointer<RegisterValidator> registerValidator(new RegisterValidator(parser, fieldValidator, parameterValidator));\n\n    RegisterFileValidator validator(parser, registerValidator, parameterValidator, Document::Revision::Std14);\n\n    QCOMPARE(validator.hasValidDimensions(testRegisterFile), isValid);\n\n    if (!isValid)\n    {\n        QVector<QString> foundErrors;\n        validator.findErrorsIn(foundErrors, testRegisterFile, \"test\", \"8\", \"32\");\n\n        QString expectedError = QObject::tr(\"Invalid dimensions set for register file '%1' within %2\").\n            arg(testRegisterFile->name(), \"test\");\n\n        if (errorIsNotFoundInErrorList(expectedError, foundErrors))\n        {\n            QFAIL(\"No error message found\");\n        }\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_RegisterFileValidator::testDimensionIsValid_data()\n//-----------------------------------------------------------------------------\nvoid tst_RegisterFileValidator::testDimensionIsValid_data()\n{\n    QTest::addColumn<QString>(\"dimension\");\n    QTest::addColumn<bool>(\"isValid\");\n\n    QTest::newRow(\"Dimension 3 is valid\") << \"3\" << true;\n    QTest::newRow(\"Dimension -8 is invalid\") << \"-8\" << false;\n    QTest::newRow(\"Dimension 4*4/2-8 is invalid\") << \"0\" << false;\n    QTest::newRow(\"Text value is invalid for dimension\") << \"text\" << false;\n    QTest::newRow(\"String value is invalid for dimension\") << \"\\\"text\\\"\" << false;\n\n    QTest::newRow(\"Long dimension is valid\") << \"40000000000\" << true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_RegisterFileValidator::testAddressOffsetIsValid()\n//-----------------------------------------------------------------------------\nvoid tst_RegisterFileValidator::testAddressOffsetIsValid()\n{\n    QFETCH(QString, addressOffset);\n    QFETCH(bool, isValid);\n\n    QSharedPointer<RegisterFile> testRegisterFile(new RegisterFile(\"name\", addressOffset));\n\n    QSharedPointer<ExpressionParser> parser(new SystemVerilogExpressionParser());\n    QSharedPointer<ParameterValidator> parameterValidator(new ParameterValidator(parser,\n        QSharedPointer<QList<QSharedPointer<Choice> > >(), Document::Revision::Std22));\n    QSharedPointer<EnumeratedValueValidator> enumValidator(new EnumeratedValueValidator(parser));\n    QSharedPointer<FieldValidator> fieldValidator(new FieldValidator(parser, enumValidator, parameterValidator));\n    QSharedPointer<RegisterValidator> registerValidator(new RegisterValidator(parser, fieldValidator, parameterValidator));\n\n    RegisterFileValidator validator(parser, registerValidator, parameterValidator, Document::Revision::Std22);\n\n    QCOMPARE(validator.hasValidAddressOffset(testRegisterFile), isValid);\n\n    if (!isValid)\n    {\n        QVector<QString> foundErrors;\n        validator.findErrorsIn(foundErrors, testRegisterFile, \"test\", \"8\", \"32\");\n\n        QString expectedError = QObject::tr(\"Invalid address offset set for register file '%1' within %2\").\n            arg(testRegisterFile->name()).arg(\"test\");\n\n        if (errorIsNotFoundInErrorList(expectedError, foundErrors))\n        {\n            QFAIL(\"No error message found\");\n        }\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_RegisterFileValidator::testAddressOffsetIsValid_data()\n//-----------------------------------------------------------------------------\nvoid tst_RegisterFileValidator::testAddressOffsetIsValid_data()\n{\n    QTest::addColumn<QString>(\"addressOffset\");\n    QTest::addColumn<bool>(\"isValid\");\n\n    QTest::newRow(\"Address offset of 10 is valid\") << \"10\" << true;\n    QTest::newRow(\"Empty address offset is invalid\") << \"\" << false;\n    QTest::newRow(\"Address offset of -2 is invalid\") << \"-2\" << false;\n    QTest::newRow(\"Address offset of 20*80 is valid\") << \"20*80\" << true;\n    QTest::newRow(\"Text is invalid for address offset\") << \"text\" << false;\n    QTest::newRow(\"String is invalid for address offset\") << \"\\\"text\\\"\" << false;\n\n    QTest::newRow(\"Long address offset is valid\") << \"40000000000\" << true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_RegisterFileValidator::testRangeIsValid()\n//-----------------------------------------------------------------------------\nvoid tst_RegisterFileValidator::testRangeIsValid()\n{\n    QFETCH(QString, range);\n    QFETCH(bool, isValid);\n\n    QSharedPointer<RegisterFile> testRegisterFile(new RegisterFile(\"name\", \"0\", range));\n\n    QSharedPointer<ExpressionParser> parser(new SystemVerilogExpressionParser());\n    QSharedPointer<ParameterValidator> parameterValidator(new ParameterValidator(parser,\n        QSharedPointer<QList<QSharedPointer<Choice> > >(), Document::Revision::Std22));\n    QSharedPointer<EnumeratedValueValidator> enumValidator(new EnumeratedValueValidator(parser));\n    QSharedPointer<FieldValidator> fieldValidator(new FieldValidator(parser, enumValidator, parameterValidator));\n    QSharedPointer<RegisterValidator> registerValidator(new RegisterValidator(parser, fieldValidator, parameterValidator));\n\n    RegisterFileValidator validator(parser, registerValidator, parameterValidator, Document::Revision::Std22);\n\n    QCOMPARE(validator.hasValidRange(testRegisterFile), isValid);\n\n    if (!isValid)\n    {\n        QVector<QString> foundErrors;\n        validator.findErrorsIn(foundErrors, testRegisterFile, \"test\", \"8\", \"32\");\n\n        QString expectedError = QObject::tr(\"Invalid range specified for register file %1 within %2\").\n            arg(testRegisterFile->name()).arg(\"test\");\n\n        if (errorIsNotFoundInErrorList(expectedError, foundErrors))\n        {\n            QFAIL(\"No error message found\");\n        }\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_RegisterFileValidator::testRangeIsValid_data()\n//-----------------------------------------------------------------------------\nvoid tst_RegisterFileValidator::testRangeIsValid_data()\n{\n    QTest::addColumn<QString>(\"range\");\n    QTest::addColumn<bool>(\"isValid\");\n\n    QTest::newRow(\"Range of 10 is valid\") << \"10\" << true;\n    QTest::newRow(\"Empty range is invalid\") << \"\" << false;\n    QTest::newRow(\"Range of -2 is invalid\") << \"-2\" << false;\n    QTest::newRow(\"of 20*80 is valid\") << \"20*80\" << true;\n    QTest::newRow(\"Text is invalid for address offset\") << \"text\" << false;\n    QTest::newRow(\"String is invalid for address offset\") << \"\\\"text\\\"\" << false;\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_RegisterFileValidator::testMemoryArrayIsValid()\n//-----------------------------------------------------------------------------\nvoid tst_RegisterFileValidator::testMemoryArrayIsValid()\n{\n    QFETCH(QString, dimValue);\n    QFETCH(QString, indexVar);\n    QFETCH(QString, stride);\n    QFETCH(bool, validDim);\n    QFETCH(bool, validStride);\n\n    QSharedPointer<RegisterFile> testRegisterFile(new RegisterFile(\"test\", \"8\", \"8\"));\n\n    QSharedPointer<MemoryArray> testMemArray(new MemoryArray());\n\n    QSharedPointer<MemoryArray::Dimension> testDim(new MemoryArray::Dimension);\n    testDim->value_ = dimValue;\n    testDim->indexVar_ = indexVar;\n\n    if (dimValue.isEmpty() == false)\n    {\n        testMemArray->getDimensions()->append(testDim);\n    }\n\n    testMemArray->setStride(stride);\n\n    testRegisterFile->setMemoryArray(testMemArray);\n\n    QSharedPointer<ExpressionParser> parser(new SystemVerilogExpressionParser());\n    QSharedPointer<ParameterValidator> parameterValidator(new ParameterValidator(parser,\n        QSharedPointer<QList<QSharedPointer<Choice> > >(), Document::Revision::Std22));\n    QSharedPointer<EnumeratedValueValidator> enumValidator(new EnumeratedValueValidator(parser));\n    QSharedPointer<FieldValidator> fieldValidator(new FieldValidator(parser, enumValidator, parameterValidator));\n    QSharedPointer<RegisterValidator> registerValidator(new RegisterValidator(parser, fieldValidator, parameterValidator));\n\n    RegisterFileValidator validator(parser, registerValidator, parameterValidator, Document::Revision::Std22);\n\n    QCOMPARE(validator.hasValidMemoryArray(testRegisterFile), validDim && validStride);\n\n    if (!(validDim && validStride))\n    {\n        QStringList foundErrors;\n        validator.findErrorsIn(foundErrors, testRegisterFile, \"test\", \"8\", \"32\");\n\n        QString expectedError;\n\n        if (testMemArray->getDimensions()->isEmpty())\n        {\n            expectedError = QObject::tr(\"No dimensions defined for memory array in register file '%1' within %2\")\n                .arg(testRegisterFile->name()).arg(\"test\");\n        }\n\n        else if (!validDim)\n        {\n            expectedError = QObject::tr(\"One or more dimensions of the memory array in register file '%1' within %2 have an invalid value.\")\n                .arg(testRegisterFile->name()).arg(\"test\");\n        }\n\n        else if (!validStride)\n        {\n            expectedError = QObject::tr(\"Memory array in register file '%1' within %2 has an invalid stride value.\")\n                .arg(testRegisterFile->name()).arg(\"test\");\n        }\n\n        if (errorIsNotFoundInErrorList(expectedError, foundErrors))\n        {\n            QFAIL(\"No error message found\");\n        }\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_RegisterFileValidator::testMemoryArrayIsValid_data()\n//-----------------------------------------------------------------------------\nvoid tst_RegisterFileValidator::testMemoryArrayIsValid_data()\n{\n    QTest::addColumn<QString>(\"dimValue\");\n    QTest::addColumn<QString>(\"indexVar\");\n    QTest::addColumn<QString>(\"stride\");\n    QTest::addColumn<bool>(\"validDim\");\n    QTest::addColumn<bool>(\"validStride\");\n\n    QTest::newRow(\"Dimension with valid values is valid\") << \"8\" << \"i\" << \"8\" << true << true;\n    QTest::newRow(\"Dimension without stride is valid\") << \"8\" << \"i\" << \"\" << true << true;\n    QTest::newRow(\"Valid expression in dim is valid\") << \"1+1\" << \"index\" << \"\" << true << true;\n    QTest::newRow(\"Invalid expression in dim is not valid\") << \"a+a\" << \"index\" << \"\" << false << true;\n    QTest::newRow(\"Invalid value in dim is not valid\") << \"-1\" << \"index\" << \"\" << false << true;\n    QTest::newRow(\"Valid expression in stride is valid\") << \"1\" << \"index\" << \"1+1\" << true << true;\n    QTest::newRow(\"Invalid expression in stride is not valid\") << \"1\" << \"index\" << \"a+a\" << true << false;\n    QTest::newRow(\"Invalid value in stride is not valid\") << \"1\" << \"index\" << \"-1\" << true << false;\n    QTest::newRow(\"Dimension doesn't exist is invalid\") << \"\" << \"\" << \"\" << false << false;\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_RegisterFileValidator::testAccessPoliciesAreValid()\n//-----------------------------------------------------------------------------\nvoid tst_RegisterFileValidator::testAccessPoliciesAreValid()\n{\n    QSharedPointer<RegisterFile> testRegisterFile(new RegisterFile(\"test\", \"8\", \"8\"));\n\n    QSharedPointer<ModeReference> modeRef1(new ModeReference());\n    modeRef1->setPriority(0);\n    modeRef1->setReference(\"ref\");\n\n    QSharedPointer<ModeReference> modeRef2(new ModeReference());\n    modeRef2->setPriority(0);\n    modeRef2->setReference(\"ref1\");\n\n    QSharedPointer<AccessPolicy> accessPolicy1(new AccessPolicy());\n    QSharedPointer<AccessPolicy> accessPolicy2(new AccessPolicy());\n    accessPolicy1->getModeReferences()->append(modeRef1);\n    accessPolicy2->getModeReferences()->append(modeRef2);\n\n    testRegisterFile->getAccessPolicies()->append(accessPolicy1);\n    testRegisterFile->getAccessPolicies()->append(accessPolicy2);\n\n    QSharedPointer<ExpressionParser> parser(new SystemVerilogExpressionParser());\n    QSharedPointer<ParameterValidator> parameterValidator(new ParameterValidator(parser,\n        QSharedPointer<QList<QSharedPointer<Choice> > >(), Document::Revision::Std22));\n    QSharedPointer<EnumeratedValueValidator> enumValidator(new EnumeratedValueValidator(parser));\n    QSharedPointer<FieldValidator> fieldValidator(new FieldValidator(parser, enumValidator, parameterValidator));\n    QSharedPointer<RegisterValidator> registerValidator(new RegisterValidator(parser, fieldValidator, parameterValidator));\n\n    RegisterFileValidator validator(parser, registerValidator, parameterValidator, Document::Revision::Std22);\n\n    QSharedPointer<Component> dummyComponent(new Component(VLNV(VLNV::COMPONENT, \"vendor\", \"libray\", \"name\", \"1.0\"), Document::Revision::Std22));\n    QSharedPointer<Mode> mode1(new Mode(\"ref\"));\n    QSharedPointer<Mode> mode2(new Mode(\"ref1\"));\n    dummyComponent->getModes()->append(mode1);\n    dummyComponent->getModes()->append(mode2);\n\n    validator.componentChange(dummyComponent);\n\n    QStringList errors;\n\n    QStringList possibleErrors(QStringList()\n        << \"One or more mode references in access policies of register file test within test contain duplicate priority values.\"\n        << \"One or more mode references in access policies of register file test within test contain duplicate mode reference values.\"\n        << \"In register file test in test, multiple access policies are not allowed if one of them lacks a mode reference.\"\n    );\n\n    // Test duplicate mode reference priority.\n    validator.findErrorsIn(errors, testRegisterFile, \"test\", \"8\", \"32\");\n    QVERIFY(errors.contains(possibleErrors.first()));\n    QVERIFY(validator.hasValidAccessPolicies(testRegisterFile) == false);\n\n    // Test duplicate reference.\n    errors.clear();\n\n    modeRef2->setPriority(1);\n    modeRef2->setReference(\"ref\");\n\n    validator.findErrorsIn(errors, testRegisterFile, \"test\", \"8\", \"32\");\n    QVERIFY(errors.contains(possibleErrors.at(1)));\n    QVERIFY(validator.hasValidAccessPolicies(testRegisterFile) == false);\n\n    // Test invalid.\n    errors.clear();\n\n    modeRef2->setReference(\"ref2\");\n\n    validator.findErrorsIn(errors, testRegisterFile, \"test\", \"8\", \"32\");\n    QVERIFY(std::none_of(possibleErrors.cbegin(), possibleErrors.cend(), [&errors](QString const& str)\n        {\n            return errors.contains(str);\n        }));\n\n    QVERIFY(validator.hasValidAccessPolicies(testRegisterFile) == false);\n\n    // Test valid.\n    errors.clear();\n\n    modeRef2->setReference(\"ref1\");\n\n    validator.findErrorsIn(errors, testRegisterFile, \"test\", \"8\", \"32\");\n    QVERIFY(std::none_of(possibleErrors.cbegin(), possibleErrors.cend(), [&errors](QString const& str)\n        {\n            return errors.contains(str);\n        }));\n\n    QVERIFY(validator.hasValidAccessPolicies(testRegisterFile));\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_RegisterFileValidator::testRegisterDataIsValid()\n//-----------------------------------------------------------------------------\nvoid tst_RegisterFileValidator::testRegisterDataIsValid()\n{\n    QSharedPointer<RegisterFile> parentRegisterFile(new RegisterFile(\"parent\", \"0\", \"32\"));\n\n    QSharedPointer<Field> childField(new Field(\"childField\"));\n    childField->setBitOffset(\"4\");\n    childField->setBitWidth(\"4\");\n\n    QSharedPointer<Register> childRegister(new Register(\"childRegister\", \"8\", \"8\"));\n\n    parentRegisterFile->getRegisterData()->append(childRegister);\n\n    // Test no field error in child register.\n    QSharedPointer<ExpressionParser> parser(new SystemVerilogExpressionParser());\n    QSharedPointer<ParameterValidator> parameterValidator(new ParameterValidator(parser,\n        QSharedPointer<QList<QSharedPointer<Choice> > >(), Document::Revision::Std22));\n    QSharedPointer<EnumeratedValueValidator> enumValidator(new EnumeratedValueValidator(parser));\n    QSharedPointer<FieldValidator> fieldValidator(new FieldValidator(parser, enumValidator, parameterValidator));\n    QSharedPointer<RegisterValidator> registerValidator(new RegisterValidator(parser, fieldValidator, parameterValidator));\n\n    RegisterFileValidator validator(parser, registerValidator, parameterValidator, Document::Revision::Std22);\n\n    QStringList errors;\n\n    validator.findErrorsIn(errors, parentRegisterFile, \"test\", \"8\", \"32\");\n    QVERIFY(errors.contains(QString(\"Register childRegister must contain at least one field\")));\n    QVERIFY(validator.hasValidRegisterData(parentRegisterFile, \"8\", \"32\") == false);\n\n    // Test erroneous child register file.\n    QSharedPointer<RegisterFile> childRegisterFile(new RegisterFile(\"name with whitespace\", \"0\", \"8\"));\n    parentRegisterFile->getRegisterData()->clear();\n\n    parentRegisterFile->getRegisterData()->append(childRegisterFile);\n\n    errors.clear();\n    validator.findErrorsIn(errors, parentRegisterFile, \"test\", \"8\", \"32\");\n    QVERIFY(errors.contains(QString(\"Invalid name specified for register file 'name with whitespace' within register file 'parent' within test\")));\n    QVERIFY(validator.hasValidRegisterData(parentRegisterFile, \"8\", \"32\") == false);\n\n    // Test valid child register and register file.\n    errors.clear();\n    childRegister->getFields()->append(childField);\n    childRegisterFile->setName(\"validName\");\n\n    parentRegisterFile->getRegisterData()->append(childRegister);\n\n    validator.findErrorsIn(errors, parentRegisterFile, \"test\", \"8\", \"32\");\n    QCOMPARE(errors.size(), 0);\n    QVERIFY(validator.hasValidRegisterData(parentRegisterFile, \"8\", \"32\"));\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_RegisterFileValidator::testRegisterDataUniqueNames()\n//-----------------------------------------------------------------------------\nvoid tst_RegisterFileValidator::testRegisterDataUniqueNames()\n{\n    // Register and register file names must be unique in an address block or register file.\n    QFETCH(QString, registerOneName);\n    QFETCH(QString, registerTwoName);\n    QFETCH(QString, registerFileOneName);\n    QFETCH(QString, registerFileTwoName);\n    QFETCH(bool, isValid);\n\n    QString addressUnitBits(\"8\");\n\n    // Test no field error in child register.\n    QSharedPointer<ExpressionParser> parser(new SystemVerilogExpressionParser());\n    QSharedPointer<ParameterValidator> parameterValidator(new ParameterValidator(parser,\n        QSharedPointer<QList<QSharedPointer<Choice> > >(), Document::Revision::Std22));\n    QSharedPointer<EnumeratedValueValidator> enumValidator(new EnumeratedValueValidator(parser));\n    QSharedPointer<FieldValidator> fieldValidator(new FieldValidator(parser, enumValidator, parameterValidator));\n    QSharedPointer<RegisterValidator> registerValidator(new RegisterValidator(parser, fieldValidator, parameterValidator));\n\n    RegisterFileValidator validator(parser, registerValidator, parameterValidator, Document::Revision::Std22);\n\n    QSharedPointer<Field> testfield(new Field(\"testField\"));\n    testfield->setBitOffset(\"0\");\n    testfield->setBitWidth(\"8\");\n\n    QSharedPointer<Register> registerOne(new Register(registerOneName, \"0\", \"8\"));\n    QSharedPointer<Register> registerTwo(new Register(registerTwoName, \"1\", \"8\"));\n\n    registerOne->getFields()->append(testfield);\n    registerTwo->getFields()->append(testfield);\n\n    QSharedPointer<RegisterFile> registerFileOne(new RegisterFile(registerFileOneName, \"2\", \"1\"));\n    QSharedPointer<RegisterFile> registerFileTwo(new RegisterFile(registerFileTwoName, \"3\", \"1\"));\n\n    QSharedPointer<RegisterFile> parentRegisterFile(new RegisterFile(\"parent\", \"0\", \"50\"));\n\n    parentRegisterFile->getRegisterData()->append(registerOne);\n    parentRegisterFile->getRegisterData()->append(registerTwo);\n    parentRegisterFile->getRegisterData()->append(registerFileOne);\n    parentRegisterFile->getRegisterData()->append(registerFileTwo);\n\n    QCOMPARE(validator.hasValidRegisterData(parentRegisterFile, \"8\", \"32\"), isValid);\n\n    if (!isValid)\n    {\n        QStringList foundErrors;\n        validator.findErrorsIn(foundErrors, parentRegisterFile, \"test\", addressUnitBits, \"32\");\n        QStringList expectedErrors;\n\n        if (registerOneName == registerTwoName)\n        {\n            expectedErrors.append(QObject::tr(\"Name %1 of registers in register file '%2' within test is not unique.\")\n                .arg(registerOneName).arg(parentRegisterFile->name()));\n        }\n\n        if (registerFileOneName == registerFileTwoName)\n        {\n            expectedErrors.append(QObject::tr(\"Name %1 of register files in register file '%2' within test is not unique.\")\n                .arg(registerFileOneName).arg(parentRegisterFile->name()));\n        }\n\n        for (auto const& error : expectedErrors)\n        {\n            if (errorIsNotFoundInErrorList(error, foundErrors))\n            {\n                QFAIL(\"No error message found\");\n            }\n        }\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_RegisterFileValidator::testRegisterDataUniqueNames_data()\n//-----------------------------------------------------------------------------\nvoid tst_RegisterFileValidator::testRegisterDataUniqueNames_data()\n{\n    QTest::addColumn<QString>(\"registerOneName\");\n    QTest::addColumn<QString>(\"registerTwoName\");\n    QTest::addColumn<QString>(\"registerFileOneName\");\n    QTest::addColumn<QString>(\"registerFileTwoName\");\n    QTest::addColumn<bool>(\"isValid\");\n\n    QTest::addRow(\"Unique register and register file names is valid\") << \"reg1\" << \"reg2\" << \"regFile1\" << \"regFile2\" << true;\n    QTest::addRow(\"Non-unique register and unique register file names is invalid\") << \"reg\" << \"reg\" << \"regFile1\" << \"regFile2\" << false;\n    QTest::addRow(\"Unique register and non-unique register file names is invalid\") << \"reg1\" << \"reg2\" << \"regFile\" << \"regFile\" << false;\n    QTest::addRow(\"Non-unique register and non-unique register file names is invalid\") << \"reg\" << \"reg\" << \"regFile\" << \"regFile\" << false;\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_RegisterFileValidator::errorIsNotFoundInErrorList()\n//-----------------------------------------------------------------------------\nbool tst_RegisterFileValidator::errorIsNotFoundInErrorList(QString const& expectedError, QStringList const& errorList)\n{\n    if (!errorList.contains(expectedError))\n    {\n        qDebug() << \"The following error:\" << Qt::endl << expectedError << Qt::endl << \"was not found in error list:\";\n        for (auto const& error : errorList)\n        {\n            qDebug() << error;\n        }\n        return true;\n    }\n\n    return false;\n}\n\nQTEST_APPLESS_MAIN(tst_RegisterFileValidator)\n\n#include \"tst_RegisterFileValidator.moc\"\n"
  },
  {
    "path": "tests/IPXACTmodels/Component/tst_RegisterFileValidator.pri",
    "content": "# ----------------------------------------------------\n# This file is generated by the Qt Visual Studio Tools.\n# ------------------------------------------------------\n\nSOURCES += ./tst_RegisterFileValidator.cpp \n\t"
  },
  {
    "path": "tests/IPXACTmodels/Component/tst_RegisterFileValidator.pro",
    "content": "#-----------------------------------------------------------------------------\n# File: tst_RegisterFileValidator.pro\n#-----------------------------------------------------------------------------\n# Project: Kactus 2\n# Author: Anton Hagqvist\n# Date: 25.8.2023\n#\n# Description:\n# Qt project file template for running unit tests for a single module.\n#-----------------------------------------------------------------------------\n\nTEMPLATE = app\n\nTARGET = tst_RegisterFileValidator\n\nQT += core gui xml testlib\n\nCONFIG += c++11 testcase console\n\nlinux-g++ | linux-g++-64 | linux-g++-32 {\n LIBS += -L../../../executable \\\n     -lIPXACTmodels\n}\n\nwin64 | win32 {\n LIBS += -L../../../executable \\\n     -lIPXACTmodelsd\n}\n\nINCLUDEPATH += $$DESTDIR\nINCLUDEPATH += ../../../\n\nDEPENDPATH += .\nDEPENDPATH += ../../../\n\nOBJECTS_DIR += $$DESTDIR\n\nMOC_DIR += ./generatedFiles\nUI_DIR += ./generatedFiles\nRCC_DIR += ./generatedFiles\ninclude(tst_RegisterFileValidator.pri)\n"
  },
  {
    "path": "tests/IPXACTmodels/Component/tst_RegisterReader.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: tst_RegisterReader.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 29.09.2015\r\n//\r\n// Description:\r\n// Unit test for class RegisterReader.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include <IPXACTmodels/Component/RegisterReader.h>\r\n#include <IPXACTmodels/Component/Register.h>\r\n#include <IPXACTmodels/Component/RegisterFile.h>\r\n#include <IPXACTmodels/Component/AlternateRegister.h>\r\n#include <IPXACTmodels/Component/Field.h>\r\n#include <IPXACTmodels/Component/MemoryArray.h>\r\n\r\n#include <IPXACTmodels/common/VendorExtension.h>\r\n\r\n#include <QtTest>\r\n#include <QDomDocument>\r\n\r\nclass tst_RegisterReader : public QObject\r\n{\r\n    Q_OBJECT\r\n\r\npublic:\r\n    tst_RegisterReader();\r\n\r\nprivate slots:\r\n\r\n    void readSimpleRegister();\r\n    void readRegisterIsPresent();\r\n    void readRegisterDimension();\r\n    void readRegisterTypeIdentifier();\r\n    void readRegisterVolatile();\r\n    void readRegisterAccess();\r\n    void readRegisterFields();\r\n    void readRegisterAlternateRegisters();\r\n\r\n    void readRegisterMemoryArray2022();\r\n    void readRegisterDefinitionRef2022();\r\n    void readRegisterAccessPolicies2022();\r\n    \r\n    void readAlternateRegisters2022();\r\n\r\n    void readRegisterParameters();\r\n    void readRegisterVendorExtensions();\r\n\r\n    void readSimpleRegisterFile();\r\n    void readRegisterFileIsPresent();\r\n    void readRegisterFileDimension();\r\n    void readRegisterFileTypeIdentifier();\r\n    void readRegisterFileRegisterData();\r\n\r\n    void readRegisterFileDefinitionRef2022();\r\n    void readRegisterfileMemoryarray2022();\r\n    void readRegisterFileAccessPolicies2022();\r\n\r\n    void readRegisterFileParameters();\r\n    void readRegisterFileVendorExtensions();\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_RegisterReader::tst_RegisterReader()\r\n//-----------------------------------------------------------------------------\r\ntst_RegisterReader::tst_RegisterReader()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_RegisterReader::readSimpleRegister()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_RegisterReader::readSimpleRegister()\r\n{\r\n    QString documentContent(\r\n        \"<ipxact:register>\"\r\n            \"<ipxact:name>testRegister</ipxact:name>\"\r\n            \"<ipxact:displayName>displayed</ipxact:displayName>\"\r\n            \"<ipxact:description>described</ipxact:description>\"\r\n            \"<ipxact:addressOffset>offset</ipxact:addressOffset>\"\r\n            \"<ipxact:size>10</ipxact:size>\"\r\n            \"<ipxact:field>\"\r\n                \"<ipxact:name>simpleField</ipxact:name>\"\r\n                \"<ipxact:bitOffset>fieldOffset</ipxact:bitOffset>\"\r\n                \"<ipxact:bitWidth>fieldWidth</ipxact:bitWidth>\"\r\n            \"</ipxact:field>\"\r\n        \"</ipxact:register>\"\r\n        );\r\n\r\n    QDomDocument document;\r\n    document.setContent(documentContent);\r\n\r\n    QDomNode registerNode = document.firstChildElement(\"ipxact:register\");\r\n\r\n    QSharedPointer<Register> testRegister = RegisterReader::createRegisterfrom(registerNode, Document::Revision::Std14);\r\n\r\n    QCOMPARE(testRegister->name(), QString(\"testRegister\"));\r\n    QCOMPARE(testRegister->displayName(), QString(\"displayed\"));\r\n    QCOMPARE(testRegister->description(), QString(\"described\"));\r\n    QCOMPARE(testRegister->getAddressOffset(), QString(\"offset\"));\r\n    QCOMPARE(testRegister->getSize(), QString(\"10\"));\r\n\r\n    QCOMPARE(testRegister->getFields()->size(), 1);\r\n    QCOMPARE(testRegister->getFields()->first()->name(), QString(\"simpleField\"));\r\n    QCOMPARE(testRegister->getFields()->first()->getBitOffset(), QString(\"fieldOffset\"));\r\n    QCOMPARE(testRegister->getFields()->first()->getBitWidth(), QString(\"fieldWidth\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_RegisterReader::readRegisterIsPresent()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_RegisterReader::readRegisterIsPresent()\r\n{\r\n    QString documentContent(\r\n        \"<ipxact:register>\"\r\n            \"<ipxact:name>testRegister</ipxact:name>\"\r\n            \"<ipxact:isPresent>4-3</ipxact:isPresent>\"\r\n            \"<ipxact:addressOffset>offset</ipxact:addressOffset>\"\r\n            \"<ipxact:size>10</ipxact:size>\"\r\n            \"<ipxact:field>\"\r\n                \"<ipxact:name>simpleField</ipxact:name>\"\r\n                \"<ipxact:bitOffset>fieldOffset</ipxact:bitOffset>\"\r\n                \"<ipxact:bitWidth>fieldWidth</ipxact:bitWidth>\"\r\n            \"</ipxact:field>\"\r\n        \"</ipxact:register>\"\r\n        );\r\n\r\n    QDomDocument document;\r\n    document.setContent(documentContent);\r\n\r\n    QDomNode registerNode = document.firstChildElement(\"ipxact:register\");\r\n\r\n    QSharedPointer<Register> testRegister = RegisterReader::createRegisterfrom(registerNode, Document::Revision::Std14);\r\n\r\n    QCOMPARE(testRegister->name(), QString(\"testRegister\"));\r\n    QCOMPARE(testRegister->getIsPresent(), QString(\"4-3\"));\r\n\r\n    QCOMPARE(testRegister->getFields()->size(), 1);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_RegisterReader::readRegisterDimension()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_RegisterReader::readRegisterDimension()\r\n{\r\n    QString documentContent(\r\n        \"<ipxact:register>\"\r\n            \"<ipxact:name>testRegister</ipxact:name>\"\r\n            \"<ipxact:dim>16</ipxact:dim>\"\r\n            \"<ipxact:addressOffset>offset</ipxact:addressOffset>\"\r\n            \"<ipxact:size>10</ipxact:size>\"\r\n            \"<ipxact:field>\"\r\n                \"<ipxact:name>simpleField</ipxact:name>\"\r\n                \"<ipxact:bitOffset>fieldOffset</ipxact:bitOffset>\"\r\n                \"<ipxact:bitWidth>fieldWidth</ipxact:bitWidth>\"\r\n            \"</ipxact:field>\"\r\n        \"</ipxact:register>\"\r\n        );\r\n\r\n    QDomDocument document;\r\n    document.setContent(documentContent);\r\n\r\n    QDomNode registerNode = document.firstChildElement(\"ipxact:register\");\r\n\r\n    QSharedPointer<Register> testRegister = RegisterReader::createRegisterfrom(registerNode, Document::Revision::Std14);\r\n\r\n    QCOMPARE(testRegister->name(), QString(\"testRegister\"));\r\n    QCOMPARE(testRegister->getDimension(), QString(\"16\"));\r\n\r\n    QCOMPARE(testRegister->getFields()->size(), 1);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_RegisterReader::readRegisterTypeIdentifier()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_RegisterReader::readRegisterTypeIdentifier()\r\n{\r\n    QString documentContent(\r\n        \"<ipxact:register>\"\r\n            \"<ipxact:name>testRegister</ipxact:name>\"\r\n            \"<ipxact:addressOffset>offset</ipxact:addressOffset>\"\r\n            \"<ipxact:typeIdentifier>identifier</ipxact:typeIdentifier>\"\r\n            \"<ipxact:size>10</ipxact:size>\"\r\n            \"<ipxact:field>\"\r\n                \"<ipxact:name>simpleField</ipxact:name>\"\r\n                \"<ipxact:bitOffset>fieldOffset</ipxact:bitOffset>\"\r\n                \"<ipxact:bitWidth>fieldWidth</ipxact:bitWidth>\"\r\n            \"</ipxact:field>\"\r\n        \"</ipxact:register>\"\r\n        );\r\n\r\n    QDomDocument document;\r\n    document.setContent(documentContent);\r\n\r\n    QDomNode registerNode = document.firstChildElement(\"ipxact:register\");\r\n\r\n    QSharedPointer<Register> testRegister = RegisterReader::createRegisterfrom(registerNode, Document::Revision::Std14);\r\n\r\n    QCOMPARE(testRegister->name(), QString(\"testRegister\"));\r\n    QCOMPARE(testRegister->getTypeIdentifier(), QString(\"identifier\"));\r\n    QCOMPARE(testRegister->getVolatile(), QString(\"\"));\r\n\r\n    QCOMPARE(testRegister->getFields()->size(), 1);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_RegisterReader::readRegisterVolatile()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_RegisterReader::readRegisterVolatile()\r\n{\r\n    QString documentContent(\r\n        \"<ipxact:register>\"\r\n            \"<ipxact:name>testRegister</ipxact:name>\"\r\n            \"<ipxact:addressOffset>offset</ipxact:addressOffset>\"\r\n            \"<ipxact:size>10</ipxact:size>\"\r\n            \"<ipxact:volatile>true</ipxact:volatile>\"\r\n            \"<ipxact:field>\"\r\n                \"<ipxact:name>simpleField</ipxact:name>\"\r\n                \"<ipxact:bitOffset>fieldOffset</ipxact:bitOffset>\"\r\n                \"<ipxact:bitWidth>fieldWidth</ipxact:bitWidth>\"\r\n            \"</ipxact:field>\"\r\n        \"</ipxact:register>\"\r\n        );\r\n\r\n    QDomDocument document;\r\n    document.setContent(documentContent);\r\n\r\n    QDomNode registerNode = document.firstChildElement(\"ipxact:register\");\r\n\r\n    QSharedPointer<Register> testRegister = RegisterReader::createRegisterfrom(registerNode, Document::Revision::Std14);\r\n\r\n    QCOMPARE(testRegister->name(), QString(\"testRegister\"));\r\n    QCOMPARE(testRegister->getVolatile(), QString(\"true\"));\r\n\r\n    QCOMPARE(testRegister->getFields()->size(), 1);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_RegisterReader::readRegisterAccess()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_RegisterReader::readRegisterAccess()\r\n{\r\n    QString documentContent(\r\n        \"<ipxact:register>\"\r\n            \"<ipxact:name>testRegister</ipxact:name>\"\r\n            \"<ipxact:addressOffset>offset</ipxact:addressOffset>\"\r\n            \"<ipxact:size>10</ipxact:size>\"\r\n            \"<ipxact:access>writeOnce</ipxact:access>\"\r\n            \"<ipxact:field>\"\r\n                \"<ipxact:name>simpleField</ipxact:name>\"\r\n                \"<ipxact:bitOffset>fieldOffset</ipxact:bitOffset>\"\r\n                \"<ipxact:bitWidth>fieldWidth</ipxact:bitWidth>\"\r\n            \"</ipxact:field>\"\r\n        \"</ipxact:register>\"\r\n        );\r\n\r\n    QDomDocument document;\r\n    document.setContent(documentContent);\r\n\r\n    QDomNode registerNode = document.firstChildElement(\"ipxact:register\");\r\n\r\n    QSharedPointer<Register> testRegister = RegisterReader::createRegisterfrom(registerNode, Document::Revision::Std14);\r\n\r\n    QCOMPARE(testRegister->name(), QString(\"testRegister\"));\r\n    QCOMPARE(testRegister->getAccess(), AccessTypes::WRITEONCE);\r\n\r\n    QCOMPARE(testRegister->getFields()->size(), 1);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_RegisterReader::readRegisterFields()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_RegisterReader::readRegisterFields()\r\n{\r\n    QString documentContent(\r\n        \"<ipxact:register>\"\r\n            \"<ipxact:name>testRegister</ipxact:name>\"\r\n            \"<ipxact:addressOffset>offset</ipxact:addressOffset>\"\r\n            \"<ipxact:size>10</ipxact:size>\"\r\n            \"<ipxact:field>\"\r\n                \"<ipxact:name>simpleField</ipxact:name>\"\r\n                \"<ipxact:bitOffset>fieldOffset</ipxact:bitOffset>\"\r\n                \"<ipxact:bitWidth>fieldWidth</ipxact:bitWidth>\"\r\n            \"</ipxact:field>\"\r\n            \"<ipxact:field>\"\r\n                \"<ipxact:name>unsimplified</ipxact:name>\"\r\n                \"<ipxact:bitOffset>OtherOff</ipxact:bitOffset>\"\r\n                \"<ipxact:bitWidth>otherWidth</ipxact:bitWidth>\"\r\n            \"</ipxact:field>\"\r\n        \"</ipxact:register>\"\r\n        );\r\n\r\n    QDomDocument document;\r\n    document.setContent(documentContent);\r\n\r\n    QDomNode registerNode = document.firstChildElement(\"ipxact:register\");\r\n\r\n    QSharedPointer<Register> testRegister = RegisterReader::createRegisterfrom(registerNode, Document::Revision::Std14);\r\n\r\n    QCOMPARE(testRegister->name(), QString(\"testRegister\"));\r\n\r\n    QCOMPARE(testRegister->getFields()->size(), 2);\r\n    QCOMPARE(testRegister->getFields()->first()->name(), QString(\"simpleField\"));\r\n    QCOMPARE(testRegister->getFields()->first()->getBitOffset(), QString(\"fieldOffset\"));\r\n    QCOMPARE(testRegister->getFields()->first()->getBitWidth(), QString(\"fieldWidth\"));\r\n    QCOMPARE(testRegister->getFields()->last()->name(), QString(\"unsimplified\"));\r\n    QCOMPARE(testRegister->getFields()->last()->getBitOffset(), QString(\"OtherOff\"));\r\n    QCOMPARE(testRegister->getFields()->last()->getBitWidth(), QString(\"otherWidth\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_RegisterReader::readRegisterAlternateRegisters()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_RegisterReader::readRegisterAlternateRegisters()\r\n{\r\n    QString documentContent(\r\n        \"<ipxact:register>\"\r\n            \"<ipxact:name>testRegister</ipxact:name>\"\r\n            \"<ipxact:addressOffset>offset</ipxact:addressOffset>\"\r\n            \"<ipxact:size>10</ipxact:size>\"\r\n            \"<ipxact:field>\"\r\n                \"<ipxact:name>simpleField</ipxact:name>\"\r\n                \"<ipxact:bitOffset>fieldOffset</ipxact:bitOffset>\"\r\n                \"<ipxact:bitWidth>fieldWidth</ipxact:bitWidth>\"\r\n            \"</ipxact:field>\"\r\n            \"<ipxact:alternateRegisters>\"\r\n                \"<ipxact:alternateRegister>\"\r\n                    \"<ipxact:name>alteredBeast</ipxact:name>\"\r\n                    \"<ipxact:displayName>alteredDisplay</ipxact:displayName>\"\r\n                    \"<ipxact:description>alteredDescription</ipxact:description>\"\r\n                    \"<ipxact:isPresent>presence</ipxact:isPresent>\"\r\n                    \"<ipxact:alternateGroups>\"\r\n                        \"<ipxact:alternateGroup>wolf</ipxact:alternateGroup>\"\r\n                    \"</ipxact:alternateGroups>\"\r\n                    \"<ipxact:typeIdentifier>Volgarr</ipxact:typeIdentifier>\"\r\n                    \"<ipxact:volatile>false</ipxact:volatile>\"\r\n                    \"<ipxact:access>read-write</ipxact:access>\"\r\n                    \"<ipxact:field>\"\r\n                        \"<ipxact:name>Hades</ipxact:name>\"\r\n                        \"<ipxact:bitOffset>alternativeOffset</ipxact:bitOffset>\"\r\n                        \"<ipxact:bitWidth>alternativeWidth</ipxact:bitWidth>\"\r\n                    \"</ipxact:field>\"\r\n                    \"<ipxact:parameters>\"\r\n                        \"<ipxact:parameter parameterId=\\\"testID\\\">\"\r\n                            \"<ipxact:name>testParameter</ipxact:name>\"\r\n                            \"<ipxact:value>1</ipxact:value>\"\r\n                        \"</ipxact:parameter>\"\r\n                    \"</ipxact:parameters>\"\r\n                    \"<ipxact:vendorExtensions>\"\r\n                        \"<testExtension testExtensionAttribute=\\\"extension\\\">testValue</testExtension>\"\r\n                    \"</ipxact:vendorExtensions>\"\r\n                \"</ipxact:alternateRegister>\"\r\n            \"</ipxact:alternateRegisters>\"\r\n        \"</ipxact:register>\"\r\n        );\r\n\r\n    QDomDocument document;\r\n    document.setContent(documentContent);\r\n\r\n    QDomNode registerNode = document.firstChildElement(\"ipxact:register\");\r\n\r\n    QSharedPointer<Register> testRegister = RegisterReader::createRegisterfrom(registerNode, Document::Revision::Std14);\r\n\r\n    QCOMPARE(testRegister->name(), QString(\"testRegister\"));\r\n\r\n    QCOMPARE(testRegister->getFields()->size(), 1);\r\n\r\n    QCOMPARE(testRegister->getAlternateRegisters()->size(), 1);\r\n    QSharedPointer<AlternateRegister> alternateRegister = testRegister->getAlternateRegisters()->first();\r\n    QCOMPARE(alternateRegister->name(), QString(\"alteredBeast\"));\r\n    QCOMPARE(alternateRegister->displayName(), QString(\"alteredDisplay\"));\r\n    QCOMPARE(alternateRegister->description(), QString(\"alteredDescription\"));\r\n    QCOMPARE(alternateRegister->getIsPresent(), QString(\"presence\"));\r\n    QCOMPARE(alternateRegister->getTypeIdentifier(), QString(\"Volgarr\"));\r\n    QCOMPARE(alternateRegister->getVolatile(), QString(\"false\"));\r\n    QCOMPARE(alternateRegister->getAccess(), AccessTypes::READ_WRITE);\r\n\r\n    QCOMPARE(alternateRegister->getAlternateGroups()->size(), 1);\r\n    QCOMPARE(alternateRegister->getAlternateGroups()->first(), QString(\"wolf\"));\r\n\r\n    QCOMPARE(alternateRegister->getFields()->size(), 1);\r\n    QCOMPARE(alternateRegister->getFields()->first()->name(), QString(\"Hades\"));\r\n    QCOMPARE(alternateRegister->getFields()->first()->getBitOffset(), QString(\"alternativeOffset\"));\r\n    QCOMPARE(alternateRegister->getFields()->first()->getBitWidth(), QString(\"alternativeWidth\"));\r\n\r\n    QCOMPARE(alternateRegister->getParameters()->size(), 1);\r\n    QCOMPARE(alternateRegister->getParameters()->first()->name(), QString(\"testParameter\"));\r\n    QCOMPARE(alternateRegister->getParameters()->first()->getValueId(), QString(\"testID\"));\r\n    QCOMPARE(alternateRegister->getParameters()->first()->getValue(), QString(\"1\"));\r\n\r\n    QCOMPARE(alternateRegister->getVendorExtensions()->size(), 1);\r\n    QCOMPARE(alternateRegister->getVendorExtensions()->first()->type(), QString(\"testExtension\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_RegisterReader::readRegisterMemoryArray2022()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_RegisterReader::readRegisterMemoryArray2022()\r\n{\r\n     QString documentContent(\r\n        \"<ipxact:register>\"\r\n            \"<ipxact:name>testRegister</ipxact:name>\"\r\n            \"<ipxact:addressOffset>offset</ipxact:addressOffset>\"\r\n            \"<ipxact:array>\"\r\n                \"<ipxact:dim indexVar=\\\"testDim\\\">1+1</ipxact:dim>\"\r\n                \"<ipxact:dim>4</ipxact:dim>\"\r\n                \"<ipxact:stride>4</ipxact:stride>\"\r\n            \"</ipxact:array>\"\r\n            \"<ipxact:size>10</ipxact:size>\"\r\n            \"<ipxact:field>\"\r\n                \"<ipxact:name>simpleField</ipxact:name>\"\r\n                \"<ipxact:bitOffset>fieldOffset</ipxact:bitOffset>\"\r\n                \"<ipxact:bitWidth>fieldWidth</ipxact:bitWidth>\"\r\n            \"</ipxact:field>\"\r\n        \"</ipxact:register>\"\r\n        );\r\n\r\n     QDomDocument document;\r\n     document.setContent(documentContent);\r\n\r\n     QDomNode registerNode = document.firstChildElement(\"ipxact:register\");\r\n\r\n     QSharedPointer<Register> testRegister = RegisterReader::createRegisterfrom(registerNode, Document::Revision::Std22);\r\n     auto dimensions = testRegister->getMemoryArray()->getDimensions();\r\n     QCOMPARE(dimensions->size(), 2);\r\n     QCOMPARE(dimensions->first()->value_, QString(\"1+1\"));\r\n     QCOMPARE(dimensions->first()->indexVar_, QString(\"testDim\"));\r\n\r\n     QCOMPARE(dimensions->at(1)->value_, QString(\"4\"));\r\n     QCOMPARE(dimensions->at(1)->indexVar_, QString(\"\"));\r\n\r\n     QCOMPARE(testRegister->getMemoryArray()->getStride(), QString(\"4\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_RegisterReader::readRegisterDefinitionRef2022()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_RegisterReader::readRegisterDefinitionRef2022()\r\n{\r\n    QString documentContent(\r\n        \"<ipxact:register>\"\r\n            \"<ipxact:name>testRegister</ipxact:name>\"\r\n            \"<ipxact:addressOffset>offset</ipxact:addressOffset>\"\r\n            \"<ipxact:size>10</ipxact:size>\"\r\n            \"<ipxact:registerDefinitionRef typeDefinitions=\\\"testTypeDef\\\">testRegisterDef</ipxact:registerDefinitionRef>\"\r\n        \"</ipxact:register>\"\r\n        );\r\n\r\n     QDomDocument document;\r\n     document.setContent(documentContent);\r\n\r\n     QDomNode registerNode = document.firstChildElement(\"ipxact:register\");\r\n\r\n     QSharedPointer<Register> testRegister = RegisterReader::createRegisterfrom(registerNode, Document::Revision::Std22);\r\n\r\n     QCOMPARE(testRegister->getRegisterDefinitionReference(), QString(\"testRegisterDef\"));\r\n     QCOMPARE(testRegister->getTypeDefinitionsReference(), QString(\"testTypeDef\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_RegisterReader::readRegisterAccessPolicies2022()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_RegisterReader::readRegisterAccessPolicies2022()\r\n{\r\n    QString documentContent(\r\n        \"<ipxact:register>\"\r\n            \"<ipxact:name>testRegister</ipxact:name>\"\r\n            \"<ipxact:addressOffset>offset</ipxact:addressOffset>\"\r\n            \"<ipxact:size>10</ipxact:size>\"\r\n            \"<ipxact:accessPolicies>\"\r\n                \"<ipxact:accessPolicy>\"\r\n                    \"<ipxact:modeRef priority=\\\"0\\\">testMode</ipxact:modeRef>\"\r\n                    \"<ipxact:access>read-only</ipxact:access>\"\r\n                \"</ipxact:accessPolicy>\"\r\n                \"<ipxact:accessPolicy>\"\r\n                    \"<ipxact:modeRef priority=\\\"1\\\">testMode2</ipxact:modeRef>\"\r\n                    \"<ipxact:modeRef priority=\\\"2\\\">testMode3</ipxact:modeRef>\"\r\n                \"</ipxact:accessPolicy>\"\r\n            \"</ipxact:accessPolicies>\"\r\n            \"<ipxact:field>\"\r\n                \"<ipxact:name>simpleField</ipxact:name>\"\r\n                \"<ipxact:bitOffset>fieldOffset</ipxact:bitOffset>\"\r\n                \"<ipxact:bitWidth>fieldWidth</ipxact:bitWidth>\"\r\n            \"</ipxact:field>\"\r\n        \"</ipxact:register>\"\r\n        );\r\n\r\n     QDomDocument document;\r\n     document.setContent(documentContent);\r\n\r\n     QDomNode registerNode = document.firstChildElement(\"ipxact:register\");\r\n\r\n     QSharedPointer<Register> testRegister = RegisterReader::createRegisterfrom(registerNode, Document::Revision::Std22);\r\n\r\n     QCOMPARE(testRegister->getAccessPolicies()->size(), 2);\r\n     \r\n     auto accessPolicy1 = testRegister->getAccessPolicies()->first();\r\n     auto accessPolicy2 = testRegister->getAccessPolicies()->at(1);\r\n\r\n     QCOMPARE(accessPolicy1->getModeReferences()->size(), 1);\r\n     QCOMPARE(accessPolicy1->getModeReferences()->first()->getPriority(), 0);\r\n     QCOMPARE(accessPolicy1->getModeReferences()->first()->getReference(), QString(\"testMode\"));\r\n     QCOMPARE(accessPolicy1->getAccess(), AccessTypes::READ_ONLY);\r\n\r\n     QCOMPARE(accessPolicy2->getModeReferences()->size(), 2);\r\n     QCOMPARE(accessPolicy2->getModeReferences()->first()->getPriority(), 1);\r\n     QCOMPARE(accessPolicy2->getModeReferences()->first()->getReference(), QString(\"testMode2\"));\r\n     QCOMPARE(accessPolicy2->getModeReferences()->at(1)->getPriority(), 2);\r\n     QCOMPARE(accessPolicy2->getModeReferences()->at(1)->getReference(), QString(\"testMode3\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_RegisterReader::readAlternateRegistersModeRefs2022()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_RegisterReader::readAlternateRegisters2022()\r\n{\r\n    QString documentContent(\r\n        \"<ipxact:register>\"\r\n            \"<ipxact:name>testRegister</ipxact:name>\"\r\n            \"<ipxact:addressOffset>offset</ipxact:addressOffset>\"\r\n            \"<ipxact:size>10</ipxact:size>\"\r\n            \"<ipxact:field>\"\r\n                \"<ipxact:name>simpleField</ipxact:name>\"\r\n                \"<ipxact:bitOffset>fieldOffset</ipxact:bitOffset>\"\r\n                \"<ipxact:bitWidth>fieldWidth</ipxact:bitWidth>\"\r\n            \"</ipxact:field>\"\r\n            \"<ipxact:alternateRegisters>\"\r\n                \"<ipxact:alternateRegister>\"\r\n                    \"<ipxact:name>alteredBeast</ipxact:name>\"\r\n                    \"<ipxact:displayName>alteredDisplay</ipxact:displayName>\"\r\n                    \"<ipxact:shortDescription>testShortDescription</ipxact:shortDescription>\"\r\n                    \"<ipxact:description>alteredDescription</ipxact:description>\"\r\n                    \"<ipxact:modeRef priority=\\\"0\\\">testMode</ipxact:modeRef>\" //\r\n                    \"<ipxact:modeRef priority=\\\"1\\\">testMode2</ipxact:modeRef>\" //\r\n                    \"<ipxact:typeIdentifier>Volgarr</ipxact:typeIdentifier>\"\r\n                    \"<ipxact:volatile>false</ipxact:volatile>\"\r\n                    \"<ipxact:accessPolicies>\"\r\n                        \"<ipxact:accessPolicy>\"\r\n                            \"<ipxact:modeRef priority=\\\"0\\\">testMode</ipxact:modeRef>\"\r\n                            \"<ipxact:access>read-only</ipxact:access>\"\r\n                        \"</ipxact:accessPolicy>\"\r\n                        \"<ipxact:accessPolicy>\"\r\n                            \"<ipxact:modeRef priority=\\\"1\\\">testMode2</ipxact:modeRef>\"\r\n                            \"<ipxact:modeRef priority=\\\"2\\\">testMode3</ipxact:modeRef>\"\r\n                        \"</ipxact:accessPolicy>\"\r\n                    \"</ipxact:accessPolicies>\"\r\n                    \"<ipxact:field>\"\r\n                        \"<ipxact:name>Hades</ipxact:name>\"\r\n                        \"<ipxact:bitOffset>alternativeOffset</ipxact:bitOffset>\"\r\n                        \"<ipxact:bitWidth>alternativeWidth</ipxact:bitWidth>\"\r\n                    \"</ipxact:field>\"\r\n                    \"<ipxact:parameters>\"\r\n                        \"<ipxact:parameter parameterId=\\\"testID\\\">\"\r\n                            \"<ipxact:name>testParameter</ipxact:name>\"\r\n                            \"<ipxact:value>1</ipxact:value>\"\r\n                        \"</ipxact:parameter>\"\r\n                    \"</ipxact:parameters>\"\r\n                    \"<ipxact:vendorExtensions>\"\r\n                        \"<testExtension testExtensionAttribute=\\\"extension\\\">testValue</testExtension>\"\r\n                    \"</ipxact:vendorExtensions>\"\r\n                \"</ipxact:alternateRegister>\"\r\n            \"</ipxact:alternateRegisters>\"\r\n        \"</ipxact:register>\"\r\n        );\r\n\r\n    QDomDocument document;\r\n    document.setContent(documentContent);\r\n\r\n    QDomNode registerNode = document.firstChildElement(\"ipxact:register\");\r\n\r\n    QSharedPointer<Register> testRegister = RegisterReader::createRegisterfrom(registerNode, Document::Revision::Std22);\r\n    \r\n    QCOMPARE(testRegister->getFields()->size(), 1);\r\n    QCOMPARE(testRegister->getAlternateRegisters()->size(), 1);\r\n\r\n    auto alternateRegister = testRegister->getAlternateRegisters()->first();\r\n    QCOMPARE(alternateRegister->name(), QString(\"alteredBeast\"));\r\n    QCOMPARE(alternateRegister->displayName(), QString(\"alteredDisplay\"));\r\n    QCOMPARE(alternateRegister->shortDescription(), QString(\"testShortDescription\"));\r\n    QCOMPARE(alternateRegister->description(), QString(\"alteredDescription\"));\r\n    QCOMPARE(alternateRegister->getTypeIdentifier(), QString(\"Volgarr\"));\r\n    QCOMPARE(alternateRegister->getVolatile(), QString(\"false\"));\r\n    QCOMPARE(alternateRegister->getAccess(), AccessTypes::ACCESS_COUNT);\r\n\r\n    auto modeRefs = alternateRegister->getModeReferences();\r\n    QCOMPARE(modeRefs->size(), 2);\r\n    QCOMPARE(modeRefs->first()->getPriority(), 0);\r\n    QCOMPARE(modeRefs->first()->getReference(), QString(\"testMode\"));\r\n    QCOMPARE(modeRefs->at(1)->getPriority(), 1);\r\n    QCOMPARE(modeRefs->at(1)->getReference(), QString(\"testMode2\"));\r\n\r\n    auto accessPolicies = alternateRegister->getAccessPolicies();\r\n    QCOMPARE(accessPolicies->size(), 2);\r\n    \r\n    auto accessPolicy1 = alternateRegister->getAccessPolicies()->first();\r\n    auto accessPolicy2 = alternateRegister->getAccessPolicies()->at(1);\r\n\r\n    QCOMPARE(accessPolicy1->getModeReferences()->size(), 1);\r\n    QCOMPARE(accessPolicy1->getModeReferences()->first()->getPriority(), 0);\r\n    QCOMPARE(accessPolicy1->getModeReferences()->first()->getReference(), QString(\"testMode\"));\r\n    QCOMPARE(accessPolicy1->getAccess(), AccessTypes::READ_ONLY);\r\n\r\n    QCOMPARE(accessPolicy2->getModeReferences()->size(), 2);\r\n    QCOMPARE(accessPolicy2->getModeReferences()->first()->getPriority(), 1);\r\n    QCOMPARE(accessPolicy2->getModeReferences()->first()->getReference(), QString(\"testMode2\"));\r\n    QCOMPARE(accessPolicy2->getModeReferences()->at(1)->getPriority(), 2);\r\n    QCOMPARE(accessPolicy2->getModeReferences()->at(1)->getReference(), QString(\"testMode3\"));\r\n\r\n    QCOMPARE(alternateRegister->getFields()->size(), 1);\r\n    QCOMPARE(alternateRegister->getFields()->first()->name(), QString(\"Hades\"));\r\n    QCOMPARE(alternateRegister->getFields()->first()->getBitOffset(), QString(\"alternativeOffset\"));\r\n    QCOMPARE(alternateRegister->getFields()->first()->getBitWidth(), QString(\"alternativeWidth\"));\r\n\r\n    QCOMPARE(alternateRegister->getParameters()->size(), 1);\r\n    QCOMPARE(alternateRegister->getParameters()->first()->name(), QString(\"testParameter\"));\r\n    QCOMPARE(alternateRegister->getParameters()->first()->getValueId(), QString(\"testID\"));\r\n    QCOMPARE(alternateRegister->getParameters()->first()->getValue(), QString(\"1\"));\r\n\r\n    QCOMPARE(alternateRegister->getVendorExtensions()->size(), 1);\r\n    QCOMPARE(alternateRegister->getVendorExtensions()->first()->type(), QString(\"testExtension\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_RegisterReader::readRegisterParameters()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_RegisterReader::readRegisterParameters()\r\n{\r\n    QString documentContent(\r\n        \"<ipxact:register>\"\r\n            \"<ipxact:name>testRegister</ipxact:name>\"\r\n            \"<ipxact:addressOffset>offset</ipxact:addressOffset>\"\r\n            \"<ipxact:size>10</ipxact:size>\"\r\n            \"<ipxact:field>\"\r\n                \"<ipxact:name>simpleField</ipxact:name>\"\r\n                \"<ipxact:bitOffset>fieldOffset</ipxact:bitOffset>\"\r\n                \"<ipxact:bitWidth>fieldWidth</ipxact:bitWidth>\"\r\n            \"</ipxact:field>\"\r\n            \"<ipxact:parameters>\"\r\n                \"<ipxact:parameter parameterId=\\\"testID\\\">\"\r\n                    \"<ipxact:name>testParameter</ipxact:name>\"\r\n                    \"<ipxact:value>1</ipxact:value>\"\r\n                \"</ipxact:parameter>\"\r\n            \"</ipxact:parameters>\"\r\n        \"</ipxact:register>\"\r\n        );\r\n\r\n    QDomDocument document;\r\n    document.setContent(documentContent);\r\n\r\n    QDomNode registerNode = document.firstChildElement(\"ipxact:register\");\r\n\r\n    QSharedPointer<Register> testRegister = RegisterReader::createRegisterfrom(registerNode, Document::Revision::Std14);\r\n\r\n    QCOMPARE(testRegister->name(), QString(\"testRegister\"));\r\n\r\n    QCOMPARE(testRegister->getFields()->size(), 1);\r\n\r\n    QCOMPARE(testRegister->getParameters()->size(), 1);\r\n    QCOMPARE(testRegister->getParameters()->first()->getValueId(), QString(\"testID\"));\r\n    QCOMPARE(testRegister->getParameters()->first()->name(), QString(\"testParameter\"));\r\n    QCOMPARE(testRegister->getParameters()->first()->getValue(), QString(\"1\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_RegisterReader::readRegisterVendorExtensions()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_RegisterReader::readRegisterVendorExtensions()\r\n{\r\n    QString documentContent(\r\n        \"<ipxact:register>\"\r\n            \"<ipxact:name>testRegister</ipxact:name>\"\r\n            \"<ipxact:dim>16</ipxact:dim>\"\r\n            \"<ipxact:addressOffset>offset</ipxact:addressOffset>\"\r\n            \"<ipxact:size>10</ipxact:size>\"\r\n            \"<ipxact:field>\"\r\n                \"<ipxact:name>simpleField</ipxact:name>\"\r\n                \"<ipxact:bitOffset>fieldOffset</ipxact:bitOffset>\"\r\n                \"<ipxact:bitWidth>fieldWidth</ipxact:bitWidth>\"\r\n            \"</ipxact:field>\"\r\n            \"<ipxact:vendorExtensions>\"\r\n                \"<testExtension testExtensionAttribute=\\\"extension\\\">testValue</testExtension>\"\r\n            \"</ipxact:vendorExtensions>\"\r\n        \"</ipxact:register>\"\r\n        );\r\n\r\n    QDomDocument document;\r\n    document.setContent(documentContent);\r\n\r\n    QDomNode registerNode = document.firstChildElement(\"ipxact:register\");\r\n\r\n    QSharedPointer<Register> testRegister = RegisterReader::createRegisterfrom(registerNode, Document::Revision::Std14);\r\n\r\n    QCOMPARE(testRegister->name(), QString(\"testRegister\"));\r\n\r\n    QCOMPARE(testRegister->getFields()->size(), 1);\r\n\r\n    QCOMPARE(testRegister->getVendorExtensions()->size(), 1);\r\n    QCOMPARE(testRegister->getVendorExtensions()->first()->type(), QString(\"testExtension\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_RegisterReader::readSimpleRegisterFile()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_RegisterReader::readSimpleRegisterFile()\r\n{\r\n    QString documentContent(\r\n        \"<ipxact:registerFile>\"\r\n            \"<ipxact:name>testFile</ipxact:name>\"\r\n            \"<ipxact:displayName>displayed</ipxact:displayName>\"\r\n            \"<ipxact:description>described</ipxact:description>\"\r\n            \"<ipxact:addressOffset>fileOffset</ipxact:addressOffset>\"\r\n            \"<ipxact:range>8</ipxact:range>\"\r\n        \"</ipxact:registerFile>\"\r\n        );\r\n\r\n    QDomDocument document;\r\n    document.setContent(documentContent);\r\n\r\n    QDomNode registerFileNode = document.firstChildElement(\"ipxact:registerFile\");\r\n\r\n    QSharedPointer<RegisterFile> testRegisterFile = RegisterReader::createRegisterFileFrom(registerFileNode, Document::Revision::Std14);\r\n\r\n    QCOMPARE(testRegisterFile->name(), QString(\"testFile\"));\r\n    QCOMPARE(testRegisterFile->displayName(), QString(\"displayed\"));\r\n    QCOMPARE(testRegisterFile->description(), QString(\"described\"));\r\n    QCOMPARE(testRegisterFile->getAddressOffset(), QString(\"fileOffset\"));\r\n    QCOMPARE(testRegisterFile->getRange(), QString(\"8\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_RegisterReader::parseRegisterFileIsPresent()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_RegisterReader::readRegisterFileIsPresent()\r\n{\r\n    QString documentContent(\r\n        \"<ipxact:registerFile>\"\r\n            \"<ipxact:name>testFile</ipxact:name>\"\r\n            \"<ipxact:isPresent>14/2-7</ipxact:isPresent>\"\r\n            \"<ipxact:addressOffset>fileOffset</ipxact:addressOffset>\"\r\n            \"<ipxact:range>8</ipxact:range>\"\r\n        \"</ipxact:registerFile>\"\r\n        );\r\n\r\n    QDomDocument document;\r\n    document.setContent(documentContent);\r\n\r\n    QDomNode registerFileNode = document.firstChildElement(\"ipxact:registerFile\");\r\n\r\n    QSharedPointer<RegisterFile> testRegisterFile = RegisterReader::createRegisterFileFrom(registerFileNode, Document::Revision::Std14);\r\n\r\n    QCOMPARE(testRegisterFile->name(), QString(\"testFile\"));\r\n    QCOMPARE(testRegisterFile->getIsPresent(), QString(\"14/2-7\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_RegisterReader::()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_RegisterReader::readRegisterFileDimension()\r\n{\r\n    QString documentContent(\r\n        \"<ipxact:registerFile>\"\r\n            \"<ipxact:name>testFile</ipxact:name>\"\r\n            \"<ipxact:dim>DimensionProbability</ipxact:dim>\"\r\n            \"<ipxact:addressOffset>fileOffset</ipxact:addressOffset>\"\r\n            \"<ipxact:range>8</ipxact:range>\"\r\n        \"</ipxact:registerFile>\"\r\n        );\r\n\r\n    QDomDocument document;\r\n    document.setContent(documentContent);\r\n\r\n    QDomNode registerFileNode = document.firstChildElement(\"ipxact:registerFile\");\r\n\r\n    QSharedPointer<RegisterFile> testRegisterFile = RegisterReader::createRegisterFileFrom(registerFileNode, Document::Revision::Std14);\r\n\r\n    QCOMPARE(testRegisterFile->name(), QString(\"testFile\"));\r\n    QCOMPARE(testRegisterFile->getDimension(), QString(\"DimensionProbability\"));\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_RegisterReader::readRegisterFileTypeIdentifier()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_RegisterReader::readRegisterFileTypeIdentifier()\r\n{\r\n    QString documentContent(\r\n        \"<ipxact:registerFile>\"\r\n            \"<ipxact:name>testFile</ipxact:name>\"\r\n            \"<ipxact:addressOffset>fileOffset</ipxact:addressOffset>\"\r\n            \"<ipxact:typeIdentifier>papersPlease</ipxact:typeIdentifier>\"\r\n            \"<ipxact:range>8</ipxact:range>\"\r\n        \"</ipxact:registerFile>\"\r\n        );\r\n\r\n    QDomDocument document;\r\n    document.setContent(documentContent);\r\n\r\n    QDomNode registerFileNode = document.firstChildElement(\"ipxact:registerFile\");\r\n\r\n    QSharedPointer<RegisterFile> testRegisterFile = RegisterReader::createRegisterFileFrom(registerFileNode, Document::Revision::Std14);\r\n\r\n    QCOMPARE(testRegisterFile->name(), QString(\"testFile\"));\r\n    QCOMPARE(testRegisterFile->getTypeIdentifier(), QString(\"papersPlease\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_RegisterReader::readRegisterFileRegisterData()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_RegisterReader::readRegisterFileRegisterData()\r\n{\r\n    QString documentContent(\r\n        \"<ipxact:registerFile>\"\r\n            \"<ipxact:name>testFile</ipxact:name>\"\r\n            \"<ipxact:addressOffset>fileOffset</ipxact:addressOffset>\"\r\n            \"<ipxact:range>8</ipxact:range>\"\r\n            \"<ipxact:register>\"\r\n                \"<ipxact:name>testRegister</ipxact:name>\"\r\n                \"<ipxact:addressOffset>offset</ipxact:addressOffset>\"\r\n                \"<ipxact:size>10</ipxact:size>\"\r\n                \"<ipxact:field>\"\r\n                    \"<ipxact:name>simpleField</ipxact:name>\"\r\n                    \"<ipxact:bitOffset>fieldOffset</ipxact:bitOffset>\"\r\n                    \"<ipxact:bitWidth>fieldWidth</ipxact:bitWidth>\"\r\n                \"</ipxact:field>\"\r\n            \"</ipxact:register>\"\r\n            \"<ipxact:registerFile>\"\r\n                \"<ipxact:name>contained</ipxact:name>\"\r\n                \"<ipxact:addressOffset>containedOffset</ipxact:addressOffset>\"\r\n                \"<ipxact:range>containedRange</ipxact:range>\"\r\n            \"</ipxact:registerFile>\"\r\n        \"</ipxact:registerFile>\"\r\n        );\r\n\r\n    QDomDocument document;\r\n    document.setContent(documentContent);\r\n\r\n    QDomNode registerFileNode = document.firstChildElement(\"ipxact:registerFile\");\r\n\r\n    QSharedPointer<RegisterFile> testRegisterFile = RegisterReader::createRegisterFileFrom(registerFileNode, Document::Revision::Std14);\r\n\r\n    QCOMPARE(testRegisterFile->name(), QString(\"testFile\"));\r\n    \r\n    QCOMPARE(testRegisterFile->getRegisterData()->size(), 2);\r\n    \r\n    QSharedPointer<Register> containedRegister =\r\n        testRegisterFile->getRegisterData()->first().dynamicCast<Register>();\r\n    QCOMPARE(containedRegister.isNull(), false);\r\n    QCOMPARE(containedRegister->name(), QString(\"testRegister\"));\r\n    QCOMPARE(containedRegister->getAddressOffset(), QString(\"offset\"));\r\n    QCOMPARE(containedRegister->getSize(), QString(\"10\"));\r\n    QCOMPARE(containedRegister->getFields()->size(), 1);\r\n    QCOMPARE(containedRegister->getFields()->first()->name(), QString(\"simpleField\"));\r\n    QCOMPARE(containedRegister->getFields()->first()->getBitOffset(), QString(\"fieldOffset\"));\r\n    QCOMPARE(containedRegister->getFields()->first()->getBitWidth(), QString(\"fieldWidth\"));\r\n\r\n    QSharedPointer<RegisterFile> containedFile =\r\n        testRegisterFile->getRegisterData()->last().dynamicCast<RegisterFile>();\r\n    QCOMPARE(containedFile.isNull(), false);\r\n    QCOMPARE(containedFile->name(), QString(\"contained\"));\r\n    QCOMPARE(containedFile->getAddressOffset(), QString(\"containedOffset\"));\r\n    QCOMPARE(containedFile->getRange(), QString(\"containedRange\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_RegisterReader::readRegisterFileDefinitionRef2022()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_RegisterReader::readRegisterFileDefinitionRef2022()\r\n{\r\n    QString documentContent(\r\n        \"<ipxact:registerFile>\"\r\n            \"<ipxact:name>testFile</ipxact:name>\"\r\n            \"<ipxact:displayName>displayed</ipxact:displayName>\"\r\n            \"<ipxact:shortDescription>testShortDescription</ipxact:shortDescription>\"\r\n            \"<ipxact:description>described</ipxact:description>\"\r\n            \"<ipxact:addressOffset>fileOffset</ipxact:addressOffset>\"\r\n            \"<ipxact:registerFileDefinitionRef typeDefinitions=\\\"testTypeDefinitions\\\">testRegisterFileDefinition</ipxact:registerFileDefinitionRef>\"\r\n        \"</ipxact:registerFile>\"\r\n        );\r\n\r\n    QDomDocument document;\r\n    document.setContent(documentContent);\r\n\r\n    QDomNode registerFileNode = document.firstChildElement(\"ipxact:registerFile\");\r\n\r\n    QSharedPointer<RegisterFile> testRegisterFile = RegisterReader::createRegisterFileFrom(registerFileNode, Document::Revision::Std22);\r\n\r\n    QCOMPARE(testRegisterFile->shortDescription(), QString(\"testShortDescription\"));\r\n    QCOMPARE(testRegisterFile->getRegisterFileDefinitionReference(), QString(\"testRegisterFileDefinition\"));\r\n    QCOMPARE(testRegisterFile->getTypeDefinitionsReference(), QString(\"testTypeDefinitions\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_RegisterReader::readRegisterfileMemoryarray2022()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_RegisterReader::readRegisterfileMemoryarray2022()\r\n{\r\n    QString documentContent(\r\n        \"<ipxact:registerFile>\"\r\n            \"<ipxact:name>testFile</ipxact:name>\"\r\n            \"<ipxact:displayName>displayed</ipxact:displayName>\"\r\n            \"<ipxact:shortDescription>testShortDescription</ipxact:shortDescription>\"\r\n            \"<ipxact:description>described</ipxact:description>\"\r\n            \"<ipxact:array>\"\r\n                \"<ipxact:dim indexVar=\\\"testDim\\\">1+1</ipxact:dim>\"\r\n                \"<ipxact:dim>4</ipxact:dim>\"\r\n                \"<ipxact:stride>4</ipxact:stride>\"\r\n            \"</ipxact:array>\"\r\n            \"<ipxact:addressOffset>fileOffset</ipxact:addressOffset>\"\r\n            \"<ipxact:range>8</ipxact:range>\"\r\n        \"</ipxact:registerFile>\"\r\n    );\r\n\r\n    QDomDocument document;\r\n    document.setContent(documentContent);\r\n\r\n    QDomNode registerFileNode = document.firstChildElement(\"ipxact:registerFile\");\r\n\r\n    QSharedPointer<RegisterFile> testRegisterFile = RegisterReader::createRegisterFileFrom(registerFileNode, Document::Revision::Std22);\r\n\r\n    auto dimensions = testRegisterFile->getMemoryArray()->getDimensions();\r\n    QCOMPARE(dimensions->size(), 2);\r\n    QCOMPARE(dimensions->first()->value_, QString(\"1+1\"));\r\n    QCOMPARE(dimensions->first()->indexVar_, QString(\"testDim\"));\r\n\r\n    QCOMPARE(dimensions->at(1)->value_, QString(\"4\"));\r\n    QCOMPARE(dimensions->at(1)->indexVar_, QString(\"\"));\r\n\r\n    QCOMPARE(testRegisterFile->getMemoryArray()->getStride(), QString(\"4\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_RegisterReader::readRegisterFileAccessPolicies2022()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_RegisterReader::readRegisterFileAccessPolicies2022()\r\n{\r\n    QString documentContent(\r\n        \"<ipxact:registerFile>\"\r\n            \"<ipxact:name>testFile</ipxact:name>\"\r\n            \"<ipxact:displayName>displayed</ipxact:displayName>\"\r\n            \"<ipxact:shortDescription>testShortDescription</ipxact:shortDescription>\"\r\n            \"<ipxact:description>described</ipxact:description>\"\r\n            \"<ipxact:addressOffset>fileOffset</ipxact:addressOffset>\"\r\n            \"<ipxact:range>8</ipxact:range>\"\r\n            \"<ipxact:accessPolicies>\"\r\n                \"<ipxact:accessPolicy>\"\r\n                    \"<ipxact:modeRef priority=\\\"0\\\">testMode</ipxact:modeRef>\"\r\n                    \"<ipxact:access>read-only</ipxact:access>\"\r\n                \"</ipxact:accessPolicy>\"\r\n                \"<ipxact:accessPolicy>\"\r\n                    \"<ipxact:modeRef priority=\\\"1\\\">testMode2</ipxact:modeRef>\"\r\n                    \"<ipxact:modeRef priority=\\\"2\\\">testMode3</ipxact:modeRef>\"\r\n                \"</ipxact:accessPolicy>\"\r\n            \"</ipxact:accessPolicies>\"\r\n        \"</ipxact:registerFile>\"\r\n    );\r\n\r\n    QDomDocument document;\r\n    document.setContent(documentContent);\r\n\r\n    QDomNode registerFileNode = document.firstChildElement(\"ipxact:registerFile\");\r\n\r\n    QSharedPointer<RegisterFile> testRegisterFile = RegisterReader::createRegisterFileFrom(registerFileNode, Document::Revision::Std22);\r\n\r\n    QCOMPARE(testRegisterFile->getAccessPolicies()->size(), 2);\r\n\r\n    auto accessPolicy1 = testRegisterFile->getAccessPolicies()->first();\r\n    auto accessPolicy2 = testRegisterFile->getAccessPolicies()->at(1);\r\n\r\n    QCOMPARE(accessPolicy1->getModeReferences()->size(), 1);\r\n    QCOMPARE(accessPolicy1->getModeReferences()->first()->getPriority(), 0);\r\n    QCOMPARE(accessPolicy1->getModeReferences()->first()->getReference(), QString(\"testMode\"));\r\n    QCOMPARE(accessPolicy1->getAccess(), AccessTypes::READ_ONLY);\r\n\r\n    QCOMPARE(accessPolicy2->getModeReferences()->size(), 2);\r\n    QCOMPARE(accessPolicy2->getModeReferences()->first()->getPriority(), 1);\r\n    QCOMPARE(accessPolicy2->getModeReferences()->first()->getReference(), QString(\"testMode2\"));\r\n    QCOMPARE(accessPolicy2->getModeReferences()->at(1)->getPriority(), 2);\r\n    QCOMPARE(accessPolicy2->getModeReferences()->at(1)->getReference(), QString(\"testMode3\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_RegisterReader::readRegisterFileParameters()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_RegisterReader::readRegisterFileParameters()\r\n{\r\n    QString documentContent(\r\n        \"<ipxact:registerFile>\"\r\n            \"<ipxact:name>testFile</ipxact:name>\"\r\n            \"<ipxact:dim>DimensionProbability</ipxact:dim>\"\r\n            \"<ipxact:addressOffset>fileOffset</ipxact:addressOffset>\"\r\n            \"<ipxact:range>8</ipxact:range>\"\r\n            \"<ipxact:parameters>\"\r\n                \"<ipxact:parameter parameterId=\\\"testID\\\">\"\r\n                    \"<ipxact:name>testParameter</ipxact:name>\"\r\n                    \"<ipxact:value>1</ipxact:value>\"\r\n                \"</ipxact:parameter>\"\r\n            \"</ipxact:parameters>\"\r\n        \"</ipxact:registerFile>\"\r\n        );\r\n\r\n    QDomDocument document;\r\n    document.setContent(documentContent);\r\n\r\n    QDomNode registerFileNode = document.firstChildElement(\"ipxact:registerFile\");\r\n\r\n    QSharedPointer<RegisterFile> testRegisterFile = RegisterReader::createRegisterFileFrom(registerFileNode, Document::Revision::Std14);\r\n\r\n    QCOMPARE(testRegisterFile->name(), QString(\"testFile\"));\r\n\r\n    QCOMPARE(testRegisterFile->getParameters()->size(), 1);\r\n    QCOMPARE(testRegisterFile->getParameters()->first()->getValueId(), QString(\"testID\"));\r\n    QCOMPARE(testRegisterFile->getParameters()->first()->name(), QString(\"testParameter\"));\r\n    QCOMPARE(testRegisterFile->getParameters()->first()->getValue(), QString(\"1\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_RegisterReader::readRegisterFileVendorExtensions()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_RegisterReader::readRegisterFileVendorExtensions()\r\n{\r\n    QString documentContent(\r\n        \"<ipxact:registerFile>\"\r\n            \"<ipxact:name>testFile</ipxact:name>\"\r\n            \"<ipxact:dim>DimensionProbability</ipxact:dim>\"\r\n            \"<ipxact:addressOffset>fileOffset</ipxact:addressOffset>\"\r\n            \"<ipxact:range>8</ipxact:range>\"\r\n            \"<ipxact:vendorExtensions>\"\r\n                \"<testExtension testExtensionAttribute=\\\"extension\\\">testValue</testExtension>\"\r\n            \"</ipxact:vendorExtensions>\"\r\n        \"</ipxact:registerFile>\"\r\n        );\r\n\r\n    QDomDocument document;\r\n    document.setContent(documentContent);\r\n\r\n    QDomNode registerFileNode = document.firstChildElement(\"ipxact:registerFile\");\r\n\r\n    QSharedPointer<RegisterFile> testRegisterFile = RegisterReader::createRegisterFileFrom(registerFileNode, Document::Revision::Std14);\r\n\r\n    QCOMPARE(testRegisterFile->name(), QString(\"testFile\"));\r\n    \r\n    QCOMPARE(testRegisterFile->getVendorExtensions()->size(), 1);\r\n    QCOMPARE(testRegisterFile->getVendorExtensions()->first()->type(), QString(\"testExtension\"));\r\n}\r\n\r\nQTEST_APPLESS_MAIN(tst_RegisterReader)\r\n\r\n#include \"tst_RegisterReader.moc\"\r\n"
  },
  {
    "path": "tests/IPXACTmodels/Component/tst_RegisterReader.pri",
    "content": "# ----------------------------------------------------\r\n# This file is generated by the Qt Visual Studio Tools.\r\n# ------------------------------------------------------\r\n\r\nSOURCES += ./tst_RegisterReader.cpp \r\n"
  },
  {
    "path": "tests/IPXACTmodels/Component/tst_RegisterReader.pro",
    "content": "#-----------------------------------------------------------------------------\r\n# File: tst_RegisterReader.pro\r\n#-----------------------------------------------------------------------------\r\n# Project: Kactus 2\r\n# Author: Mikko Teuho\r\n# Date: 29.09.2015\r\n#\r\n# Description:\r\n# Qt project file template for running unit tests for register reader.\r\n#-----------------------------------------------------------------------------\r\n\r\nTEMPLATE = app\r\n\r\nTARGET = tst_RegisterReader\r\n\r\nQT += core xml testlib\r\nQT -= gui\r\n\r\nCONFIG += c++11 testcase console\r\n\r\nlinux-g++ | linux-g++-64 | linux-g++-32 {\r\n LIBS += -L../../../executable \\\r\n     -lIPXACTmodels\r\n}\r\nwin64 | win32 {\r\n LIBS += -L../../../executable \\\r\n     -lIPXACTmodelsd\r\n}\r\n\r\nINCLUDEPATH += $$DESTDIR\r\nINCLUDEPATH += ../../../\r\n\r\nDEPENDPATH += .\r\nDEPENDPATH += ../../../\r\n\r\nOBJECTS_DIR += $$DESTDIR\r\n\r\nMOC_DIR += ./generatedFiles\r\nUI_DIR += ./generatedFiles\r\nRCC_DIR += ./generatedFiles\r\ninclude(tst_RegisterReader.pri)\r\n"
  },
  {
    "path": "tests/IPXACTmodels/Component/tst_RegisterValidator.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: tst_RegisterValidator.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 19.11.2015\r\n//\r\n// Description:\r\n// Unit test for class RegisterValidator.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include <IPXACTmodels/Component/validators/RegisterValidator.h>\r\n#include <IPXACTmodels/Component/validators/FieldValidator.h>\r\n#include <IPXACTmodels/Component/validators/EnumeratedValueValidator.h>\r\n#include <IPXACTmodels/common/validators/ParameterValidator.h>\r\n\r\n#include <IPXACTmodels/Component/Register.h>\r\n#include <IPXACTmodels/Component/AlternateRegister.h>\r\n#include <IPXACTmodels/Component/Field.h>\r\n#include <IPXACTmodels/Component/EnumeratedValue.h>\r\n#include <IPXACTmodels/Component/WriteValueConstraint.h>\r\n#include <IPXACTmodels/Component/MemoryArray.h>\r\n#include <IPXACTmodels/Component/Component.h>\r\n#include <IPXACTmodels/Component/Mode.h>\r\n#include <IPXACTmodels/common/Parameter.h>\r\n\r\n#include <IPXACTmodels/generaldeclarations.h>\r\n\r\n#include <KactusAPI/include/SystemVerilogExpressionParser.h>\r\n#include <KactusAPI/include/ComponentParameterFinder.h>\r\n\r\n#include <QtTest>\r\n\r\nclass tst_RegisterValidator : public QObject\r\n{\r\n    Q_OBJECT\r\n\r\npublic:\r\n    tst_RegisterValidator();\r\n\r\nprivate slots:\r\n\r\n    void testNameIsValid();\r\n    void testNameIsValid_data();\r\n\r\n    void testIsPresentIsValid();\r\n    void testIsPresentIsValid_data();\r\n\r\n    void testDimensionIsValid();\r\n    void testDimensionIsValid_data();\r\n\r\n    void testAddressOffsetIsValid();\r\n    void testAddressOffsetIsValid_data();\r\n\r\n    void testSizeIsValid();\r\n    void testSizeIsValid_data();\r\n\r\n    void testRegisterAndFieldVolatileIsValid();\r\n    void testRegisterAndFieldVolatileIsValid_data();\r\n\r\n    void testRegisterAndFieldAccessAreValid();\r\n    void testRegisterAndFieldAccessAreValid_data();\r\n\r\n    void testFieldsAreValid();\r\n    void testFieldRangesAreValid();\r\n    void testFieldRangesAreValid_data();\r\n    void testFieldsAreWithinRegister();\r\n    void testFieldsAreWithinRegister_data();\r\n    void testFieldsHaveSimilarDefinitionGroups();\r\n    void testFieldsHaveSimilarDefinitionGroups_data();\r\n\r\n    void testAlternateRegisterIsValid();\r\n    void testAlternateRegisterIsValid_data();\r\n    void testMultipleAlternateRegistersAreValid();\r\n    void testAlternateRegisterParametersAreValid();\r\n\r\n    void testParametersAreValid();\r\n\r\n    void testRegisterMemoryArrayIsValid2022();\r\n    void testRegisterMemoryArrayIsValid2022_data();\r\n\r\n    void testRegisterAccessPoliciesAreValid2022();\r\n\r\n\r\n    void testModeRefsOfAlternativeRegisetrsAreValid2022();\r\n    void testAlternateRegisterAccessPoliciesAreValid2022();\r\n\r\nprivate:\r\n\r\n    bool errorIsNotFoundInErrorList(QString const& expectedError, QVector<QString> errorList);\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_RegisterValidator::tst_RegisterValidator()\r\n//-----------------------------------------------------------------------------\r\ntst_RegisterValidator::tst_RegisterValidator()\r\n{\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_RegisterValidator::testNameIsValid()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_RegisterValidator::testNameIsValid()\r\n{\r\n    QFETCH(QString, name);\r\n    QFETCH(bool, isValid);\r\n\r\n    QSharedPointer<Register> testRegister (new Register(name));\r\n\r\n    QSharedPointer<ExpressionParser> parser(new SystemVerilogExpressionParser());\r\n    QSharedPointer<ParameterValidator> parameterValidator(new ParameterValidator(parser,\r\n        QSharedPointer<QList<QSharedPointer<Choice> > > (), Document::Revision::Std14));\r\n    QSharedPointer<EnumeratedValueValidator> enumValidator (new EnumeratedValueValidator(parser));\r\n    QSharedPointer<FieldValidator> fieldValidator (new FieldValidator(parser, enumValidator, parameterValidator));\r\n    RegisterValidator validator(parser, fieldValidator, parameterValidator);\r\n    QCOMPARE(validator.hasValidName(testRegister), isValid);\r\n\r\n    if (!isValid)\r\n    {\r\n        QVector<QString> foundErrors;\r\n        validator.findErrorsIn(foundErrors, testRegister, \"test\");\r\n\r\n        QString expectedError = QObject::tr(\"Invalid name specified for register '%1' within %2\").\r\n            arg(testRegister->name(), \"test\");\r\n        if (errorIsNotFoundInErrorList(expectedError, foundErrors))\r\n        {\r\n            QFAIL(\"No error message found\");\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_RegisterValidator::testNameIsValid_data()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_RegisterValidator::testNameIsValid_data()\r\n{\r\n    QTest::addColumn<QString>(\"name\");\r\n    QTest::addColumn<bool>(\"isValid\");\r\n\r\n    QTest::newRow(\"Name test is valid\") << \"test\" << true;\r\n    QTest::newRow(\"Empty name is invalid\") << \"\" << false;\r\n    QTest::newRow(\"Name consisting of only white spaces is invalid\") << \"    \" << false;\r\n    QTest::newRow(\"Name consisting of characters and white spaces is valid\") << \"  test  \" << true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_RegisterValidator::testIsPresentIsValid()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_RegisterValidator::testIsPresentIsValid()\r\n{\r\n    QFETCH(QString, isPresent);\r\n    QFETCH(bool, isValid);\r\n\r\n    QSharedPointer<Register> testRegister (new Register(\"TestRegister\"));\r\n    testRegister->setIsPresent(isPresent);\r\n\r\n    QSharedPointer<ExpressionParser> parser(new SystemVerilogExpressionParser());\r\n    QSharedPointer<ParameterValidator> parameterValidator(new ParameterValidator(parser,\r\n        QSharedPointer<QList<QSharedPointer<Choice> > > (), Document::Revision::Std14));\r\n    QSharedPointer<EnumeratedValueValidator> enumValidator (new EnumeratedValueValidator(parser));\r\n    QSharedPointer<FieldValidator> fieldValidator (new FieldValidator(parser, enumValidator, parameterValidator));\r\n    RegisterValidator validator(parser, fieldValidator, parameterValidator);\r\n    QCOMPARE(validator.hasValidIsPresent(testRegister), isValid);\r\n\r\n    if (!isValid)\r\n    {\r\n        QVector<QString> foundErrors;\r\n        validator.findErrorsIn(foundErrors, testRegister, \"test\");\r\n\r\n        QString expectedError = QObject::tr(\"Invalid isPresent set for register '%1' within %2\").\r\n            arg(testRegister->name(), \"test\");\r\n        if (errorIsNotFoundInErrorList(expectedError, foundErrors))\r\n        {\r\n            QFAIL(\"No error message found\");\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_RegisterValidator::testIsPresentIsValid_data()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_RegisterValidator::testIsPresentIsValid_data()\r\n{\r\n    QTest::addColumn<QString>(\"isPresent\");\r\n    QTest::addColumn<bool>(\"isValid\");\r\n\r\n    QTest::newRow(\"IsPresent 1 is valid\") << \"1\" << true;\r\n    QTest::newRow(\"IsPresent 1*3-3 is valid\") << \"1*3-3\" << true;\r\n    QTest::newRow(\"IsPresent 2*100 is invalid\") << \"2*100\" << false;\r\n    QTest::newRow(\"IsPresent -14 is invalid\") << \"-14\" << false;\r\n    QTest::newRow(\"Real number isPresent  0.12 is invalid\") << \"0.12\" << false;\r\n    QTest::newRow(\"Text as isPresent is invalid\") << \"test\" << false;\r\n    QTest::newRow(\"String as isPresent is invalid\") << \"\\\"test\\\"\" << false;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_RegisterValidator::testDimensionIsValid()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_RegisterValidator::testDimensionIsValid()\r\n{\r\n    QFETCH(QString, dimension);\r\n    QFETCH(bool, isValid);\r\n\r\n    QSharedPointer<Register> testRegister (new Register(\"TestRegister\"));\r\n    testRegister->setDimension(dimension);\r\n\r\n    QSharedPointer<ExpressionParser> parser (new SystemVerilogExpressionParser());\r\n    QSharedPointer<ParameterValidator> parameterValidator(new ParameterValidator(parser,\r\n        QSharedPointer<QList<QSharedPointer<Choice> > > (), Document::Revision::Std14));\r\n    QSharedPointer<EnumeratedValueValidator> enumValidator (new EnumeratedValueValidator(parser));\r\n    QSharedPointer<FieldValidator> fieldValidator (new FieldValidator(parser, enumValidator, parameterValidator));\r\n    RegisterValidator validator(parser, fieldValidator, parameterValidator);\r\n\r\n    QCOMPARE(validator.hasValidDimensions(testRegister), isValid);\r\n\r\n    if (!isValid)\r\n    {\r\n        QVector<QString> foundErrors;\r\n        validator.findErrorsIn(foundErrors, testRegister, \"test\");\r\n\r\n        QString expectedError = QObject::tr(\"Invalid dimensions set for register '%1' within %2\").\r\n            arg(testRegister->name(), \"test\");\r\n\r\n        if (errorIsNotFoundInErrorList(expectedError, foundErrors))\r\n        {\r\n            QFAIL(\"No error message found\");\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_RegisterValidator::testDimensionIsValid_data()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_RegisterValidator::testDimensionIsValid_data()\r\n{\r\n    QTest::addColumn<QString>(\"dimension\");\r\n    QTest::addColumn<bool>(\"isValid\");\r\n\r\n    QTest::newRow(\"Dimension 3 is valid\") << \"3\" << true;\r\n    QTest::newRow(\"Dimension -8 is invalid\") << \"-8\" << false;\r\n    QTest::newRow(\"Dimension 4*4/2-8 is invalid\") << \"0\" << false;\r\n    QTest::newRow(\"Text value is invalid for dimension\") << \"text\" << false;\r\n    QTest::newRow(\"String value is invalid for dimension\") << \"\\\"text\\\"\" << false;\r\n\r\n    QTest::newRow(\"Long dimension is valid\") << \"40000000000\" << true;\r\n    //QTest::newRow(\"Really long dimension is not valid\") << \"40000000000000000000000000000000000000000000\" << false;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_RegisterValidator::testAddressOffsetIsValid()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_RegisterValidator::testAddressOffsetIsValid()\r\n{\r\n    QFETCH(QString, addressOffset);\r\n    QFETCH(bool, isValid);\r\n\r\n    QSharedPointer<Register> testRegister (new Register(\"testRegister\", addressOffset));\r\n\r\n    QSharedPointer<ExpressionParser> parser(new SystemVerilogExpressionParser());\r\n    QSharedPointer<ParameterValidator> parameterValidator(new ParameterValidator(parser,\r\n        QSharedPointer<QList<QSharedPointer<Choice> > > (), Document::Revision::Std14));\r\n    QSharedPointer<EnumeratedValueValidator> enumValidator (new EnumeratedValueValidator(parser));\r\n    QSharedPointer<FieldValidator> fieldValidator (new FieldValidator(parser, enumValidator, parameterValidator));\r\n    RegisterValidator validator(parser, fieldValidator, parameterValidator);\r\n    QCOMPARE(validator.hasValidAddressOffset(testRegister), isValid);\r\n\r\n    if (!isValid)\r\n    {\r\n        QVector<QString> foundErrors;\r\n        validator.findErrorsIn(foundErrors, testRegister, \"test\");\r\n\r\n        QString expectedError = QObject::tr(\"Invalid address offset set for register '%1' within %2\").\r\n            arg(testRegister->name()).arg(\"test\");\r\n\r\n        if (errorIsNotFoundInErrorList(expectedError, foundErrors))\r\n        {\r\n            QFAIL(\"No error message found\");\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_RegisterValidator::testAddressOffsetIsValid_data()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_RegisterValidator::testAddressOffsetIsValid_data()\r\n{\r\n    QTest::addColumn<QString>(\"addressOffset\");\r\n    QTest::addColumn<bool>(\"isValid\");\r\n\r\n    QTest::newRow(\"Address offset of 10 is valid\") << \"10\" << true;\r\n    QTest::newRow(\"Empty address offset is invalid\") << \"\" << false;\r\n    QTest::newRow(\"Address offset of -2 is invalid\") << \"-2\" << false;\r\n    QTest::newRow(\"Address offset of 20*80 is valid\") << \"20*80\" << true;\r\n    QTest::newRow(\"Text is invalid for address offset\") << \"text\" << false;\r\n    QTest::newRow(\"String is invalid for address offset\") << \"\\\"text\\\"\" << false;\r\n\r\n    QTest::newRow(\"Long address offset is valid\") << \"40000000000\" <<  true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_RegisterValidator::testSizeIsValid()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_RegisterValidator::testSizeIsValid()\r\n{\r\n    QFETCH(QString, size);\r\n    QFETCH(bool, isValid);\r\n\r\n    QSharedPointer<Register> testRegister (new Register(\"testRegister\", \"8\", size));\r\n\r\n    QSharedPointer<ExpressionParser> parser(new SystemVerilogExpressionParser());\r\n    QSharedPointer<ParameterValidator> parameterValidator(new ParameterValidator(parser,\r\n        QSharedPointer<QList<QSharedPointer<Choice> > > (), Document::Revision::Std14));\r\n    QSharedPointer<EnumeratedValueValidator> enumValidator (new EnumeratedValueValidator(parser));\r\n    QSharedPointer<FieldValidator> fieldValidator (new FieldValidator(parser, enumValidator, parameterValidator));\r\n    RegisterValidator validator(parser, fieldValidator, parameterValidator);\r\n    QCOMPARE(validator.hasValidSize(testRegister), isValid);\r\n\r\n    if (!isValid)\r\n    {\r\n        QVector<QString> foundErrors;\r\n        validator.findErrorsIn(foundErrors, testRegister, \"test\");\r\n\r\n        QString expectedError = QObject::tr(\"Invalid size specified for register '%1' within %2\").\r\n            arg(testRegister->name()).arg(\"test\");\r\n\r\n        if (errorIsNotFoundInErrorList(expectedError, foundErrors))\r\n        {\r\n            QFAIL(\"No error message found\");\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_RegisterValidator::testSizeIsValid_data()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_RegisterValidator::testSizeIsValid_data()\r\n{\r\n    QTest::addColumn<QString>(\"size\");\r\n    QTest::addColumn<bool>(\"isValid\");\r\n\r\n    QTest::newRow(\"Positive size is valid\") << \"10\" << true;\r\n    QTest::newRow(\"Empty size is invalid\") << \"\" << false;\r\n    QTest::newRow(\"Negative size is invalid\") << \"-2\" << false;\r\n    QTest::newRow(\"Size with expression is valid\") << \"20*80\" << true;\r\n    QTest::newRow(\"Size 0 is invalid\") << \"18/2-9\" << false;\r\n    QTest::newRow(\"Text is invalid for size\") << \"text\" << false;\r\n    QTest::newRow(\"String is invalid for size\") << \"\\\"text\\\"\" << false;\r\n\r\n    QTest::newRow(\"Long size is valid\") << \"40000000000\" << true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_RegisterValidator::testRegisterAndFieldVolatileIsValid()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_RegisterValidator::testRegisterAndFieldVolatileIsValid()\r\n{\r\n    QFETCH(bool, registerVolatile);\r\n    QFETCH(bool, fieldVolatile);\r\n    QFETCH(bool, isValid);\r\n\r\n    QSharedPointer<Field> testField(new Field(\"testField\"));\r\n    testField->setVolatile(fieldVolatile);\r\n    testField->setBitOffset(\"2\");\r\n    testField->setBitWidth(\"5\");\r\n\r\n    QSharedPointer<Register> testRegister(new Register(\"testRegister\"));\r\n    testRegister->setSize(\"100\");\r\n    testRegister->setVolatile(registerVolatile);\r\n    testRegister->getFields()->append(testField);\r\n\r\n    QSharedPointer<ExpressionParser> parser(new SystemVerilogExpressionParser());\r\n    QSharedPointer<ParameterValidator> parameterValidator(new ParameterValidator(parser,\r\n        QSharedPointer<QList<QSharedPointer<Choice> > > (), Document::Revision::Std14));\r\n    QSharedPointer<EnumeratedValueValidator> enumValidator (new EnumeratedValueValidator(parser));\r\n    QSharedPointer<FieldValidator> fieldValidator (new FieldValidator(parser, enumValidator, parameterValidator));\r\n    RegisterValidator validator(parser, fieldValidator, parameterValidator);\r\n    QCOMPARE(validator.hasValidFields(testRegister, testRegister->getSize()), isValid);\r\n\r\n    if (!isValid)\r\n    {\r\n        QVector<QString> foundErrors;\r\n        validator.findErrorsIn(foundErrors, testRegister, \"test\");\r\n\r\n        QString expectedError = QObject::tr(\"Volatile cannot be set to false in register %1, where contained \"\r\n            \"field %2 has volatile true\")\r\n            .arg(testRegister->name()).arg(testField->name());\r\n\r\n        if (errorIsNotFoundInErrorList(expectedError, foundErrors))\r\n        {\r\n            QFAIL(\"No error message found\");\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_RegisterValidator::testRegisterAndFieldVolatileIsValid_data()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_RegisterValidator::testRegisterAndFieldVolatileIsValid_data()\r\n{\r\n    QTest::addColumn<bool>(\"registerVolatile\");\r\n    QTest::addColumn<bool>(\"fieldVolatile\");\r\n    QTest::addColumn<bool>(\"isValid\");\r\n\r\n    QTest::newRow(\"Field: volatile = true in Register: volatile = true is valid\") << true << true << true;\r\n    QTest::newRow(\"Field: volatile = true in Register: volatile = false is invalid\") << false << true << false;\r\n    QTest::newRow(\"Field: volatile = false, register volatile is always valid\") << false << false << true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_RegisterValidator::testRegisterAndFieldAccessAreValid()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_RegisterValidator::testRegisterAndFieldAccessAreValid()\r\n{\r\n    QFETCH(QString, fieldAccess);\r\n    QFETCH(QString, registerAccess);\r\n    QFETCH(bool, isValid);\r\n\r\n    QSharedPointer<Field> testField(new Field(\"testField\"));\r\n    testField->setAccess(AccessTypes::str2Access(fieldAccess, AccessTypes::ACCESS_COUNT));\r\n    testField->setBitOffset(\"2\");\r\n    testField->setBitWidth(\"5\");\r\n\r\n    QSharedPointer<Register> testRegister(new Register(\"testRegister\"));\r\n    testRegister->setSize(\"100\");\r\n    testRegister->setAccess(AccessTypes::str2Access(registerAccess, AccessTypes::ACCESS_COUNT));\r\n    testRegister->getFields()->append(testField);\r\n\r\n    QSharedPointer<ExpressionParser> parser(new SystemVerilogExpressionParser());\r\n    QSharedPointer<ParameterValidator> parameterValidator(new ParameterValidator(parser,\r\n        QSharedPointer<QList<QSharedPointer<Choice> > > (), Document::Revision::Std14));\r\n    QSharedPointer<EnumeratedValueValidator> enumValidator (new EnumeratedValueValidator(parser));\r\n    QSharedPointer<FieldValidator> fieldValidator (new FieldValidator(parser, enumValidator, parameterValidator));\r\n    RegisterValidator validator(parser, fieldValidator, parameterValidator);\r\n    QCOMPARE(validator.hasValidFields(testRegister, testRegister->getSize()), isValid);\r\n\r\n    if (!isValid)\r\n    {\r\n        QVector<QString> foundErrors;\r\n        validator.findErrorsIn(foundErrors, testRegister, \"test\");\r\n\r\n        QString expectedError = QObject::tr(\"Access cannot be set to %1 in field %2, where containing register %3 \"\r\n            \"has access %4\").arg(AccessTypes::access2Str(testField->getAccess())).arg(testField->name())\r\n            .arg(testRegister->name()).arg(AccessTypes::access2Str(testRegister->getAccess()));\r\n\r\n        if (errorIsNotFoundInErrorList(expectedError, foundErrors))\r\n        {\r\n            QFAIL(\"No error message found\");\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_RegisterValidator::testRegisterAndFieldAccessAreValid_data()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_RegisterValidator::testRegisterAndFieldAccessAreValid_data()\r\n{\r\n    QTest::addColumn<QString>(\"fieldAccess\");\r\n    QTest::addColumn<QString>(\"registerAccess\");\r\n    QTest::addColumn<bool>(\"isValid\");\r\n\r\n    QTest::newRow(\"Field: access = read-write, Register: access = read-only is invalid\") << \"read-write\" <<\r\n        \"read-only\" << false;\r\n    QTest::newRow(\"Field: access = read-only, Register: access = read-only is valid\") << \"read-only\" <<\r\n        \"read-only\" << true;\r\n    QTest::newRow(\"Field: access = write-only, Register: access = read-only is invalid\") << \"write-only\" <<\r\n        \"read-only\" << false;\r\n    QTest::newRow(\"Field: access = read-writeOnce, Register: access = read-only is invalid\") << \"read-writeOnce\" <<\r\n        \"read-only\" << false;\r\n    QTest::newRow(\"Field: access = writeOnce, Register: access = read-only is invalid\") << \"writeOnce\" <<\r\n        \"read-only\" << false;\r\n\r\n    QTest::newRow(\"Field: access = read-write, Register: access = write-only is invalid\") << \"read-write\" <<\r\n        \"write-only\" << false;\r\n    QTest::newRow(\"Field: access = read-only, Register: access = write-only is invalid\") << \"read-only\" <<\r\n        \"write-only\" << false;\r\n    QTest::newRow(\"Field: access = write-only, Register: access = write-only is valid\") << \"write-only\" <<\r\n        \"write-only\" << true;\r\n    QTest::newRow(\"Field: access = read-writeOnce, Register: access = write-only is invalid\") <<\r\n        \"read-writeOnce\" << \"write-only\" << false;\r\n    QTest::newRow(\"Field: access = writeOnce, Register: access = write-only is valid\") << \"writeOnce\" <<\r\n        \"write-only\" << true;\r\n\r\n    QTest::newRow(\"Field: access = read-write, Register: access = read-writeOnce is invalid\") << \"read-write\" <<\r\n        \"read-writeOnce\" << false;\r\n    QTest::newRow(\"Field: access = read-only, Register: access = read-writeOnce is valid\") << \"read-only\" <<\r\n        \"read-writeOnce\" << true;\r\n    QTest::newRow(\"Field: access = write-only, Register: access = read-writeOnce is invalid\") << \"write-only\" <<\r\n        \"read-writeOnce\" << false;\r\n    QTest::newRow(\"Field: access = read-writeOnce, Register: access = read-writeOnce is valid\") <<\r\n        \"read-writeOnce\" << \"read-writeOnce\" << true;\r\n    QTest::newRow(\"Field: access = writeOnce, Register: access = read-writeOnce is valid\") << \"writeOnce\" <<\r\n        \"read-writeOnce\" << true;\r\n\r\n    QTest::newRow(\"Field: access = read-write, Register: access = writeOnce is invalid\") << \"read-write\" <<\r\n        \"writeOnce\" << false;\r\n    QTest::newRow(\"Field: access = read-only, Register: access = writeOnce is invalid\") << \"read-only\" <<\r\n        \"writeOnce\" << false;\r\n    QTest::newRow(\"Field: access = write-only, Register: access = writeOnce is invalid\") << \"write-only\" <<\r\n        \"writeOnce\" << false;\r\n    QTest::newRow(\"Field: access = read-writeOnce, Register: access = writeOnce is invalid\") << \"read-writeOnce\" <<\r\n        \"writeOnce\" << false;\r\n    QTest::newRow(\"Field: access = writeOnce, Register: access = writeOnce is valid\") << \"writeOnce\" <<\r\n        \"writeOnce\" << true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_RegisterValidator::testFieldsAreValid()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_RegisterValidator::testFieldsAreValid()\r\n{\r\n    QSharedPointer<ExpressionParser> parser (new SystemVerilogExpressionParser());\r\n    QSharedPointer<ParameterValidator> parameterValidator(new ParameterValidator(parser,\r\n        QSharedPointer<QList<QSharedPointer<Choice> > > (), Document::Revision::Std14));\r\n    QSharedPointer<EnumeratedValueValidator> enumValidator (new EnumeratedValueValidator(parser));\r\n    QSharedPointer<FieldValidator> fieldValidator (new FieldValidator(parser, enumValidator, parameterValidator));\r\n    RegisterValidator validator(parser, fieldValidator, parameterValidator);\r\n\r\n    QSharedPointer<Field> testField (new Field(\"Lagann\"));\r\n    testField->setBitWidth(\"1\");\r\n\r\n    QSharedPointer<Register> testRegister (new Register(\"Gurren\"));\r\n    testRegister->setSize(\"100\");\r\n    testRegister->getFields()->append(testField);\r\n\r\n    QCOMPARE(validator.hasValidFields(testRegister, testRegister->getSize()), false);\r\n\r\n    QVector<QString> foundErrors;\r\n    validator.findErrorsIn(foundErrors, testRegister, \"test\");\r\n\r\n    QString expectedError = QObject::tr(\"Invalid bit offset set for field %1 within %2\").\r\n        arg(testField->name()).arg(\"register \" + testRegister->name());\r\n\r\n    if (errorIsNotFoundInErrorList(expectedError, foundErrors))\r\n    {\r\n        QFAIL(\"No error message found\");\r\n    }\r\n\r\n    testField->setBitOffset(\"4+1\");\r\n    QCOMPARE(validator.hasValidFields(testRegister, testRegister->getSize()), true);\r\n\r\n    QSharedPointer<Field> otherField (new Field(*testField.data()));\r\n    testRegister->getFields()->append(otherField);\r\n    QCOMPARE(validator.hasValidFields(testRegister, testRegister->getSize()), false);\r\n\r\n    foundErrors.clear();\r\n    validator.findErrorsIn(foundErrors, testRegister, \"test\");\r\n\r\n    expectedError = QObject::tr(\"Name %1 of fields in %2 is not unique.\").\r\n        arg(testField->name()).arg(\"register \" + testRegister->name());\r\n\r\n    if (errorIsNotFoundInErrorList(expectedError, foundErrors))\r\n    {\r\n        QFAIL(\"No error message found\");\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_RegisterValidator::testFieldRangesAreValid()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_RegisterValidator::testFieldRangesAreValid()\r\n{\r\n    QFETCH(QString, firstOffset);\r\n    QFETCH(QString, firstWidth);\r\n    QFETCH(QString, firstAccess);\r\n    QFETCH(QString, secondOffset);\r\n    QFETCH(QString, secondWidth);\r\n    QFETCH(QString, secondAccess);\r\n    QFETCH(bool, isValid);\r\n\r\n    QSharedPointer<Field> fieldOne (new Field(\"FieldOne\"));\r\n    fieldOne->setBitOffset(firstOffset);\r\n    fieldOne->setBitWidth(firstWidth);\r\n    fieldOne->setAccess(AccessTypes::str2Access(firstAccess, AccessTypes::ACCESS_COUNT));\r\n\r\n    QSharedPointer<Field> fieldTwo (new Field(\"FieldTwo\"));\r\n    fieldTwo->setBitOffset(secondOffset);\r\n    fieldTwo->setBitWidth(secondWidth);\r\n    fieldTwo->setAccess(AccessTypes::str2Access(secondAccess, AccessTypes::ACCESS_COUNT));\r\n\r\n    QSharedPointer<Register> testRegister(new Register(\"TestRegister\"));\r\n    testRegister->setSize(\"100\");\r\n    testRegister->getFields()->append(fieldOne);\r\n    testRegister->getFields()->append(fieldTwo);\r\n    \r\n    QSharedPointer<ExpressionParser> parser (new SystemVerilogExpressionParser());\r\n    QSharedPointer<ParameterValidator> parameterValidator(new ParameterValidator(parser,\r\n        QSharedPointer<QList<QSharedPointer<Choice> > > (), Document::Revision::Std14));\r\n    QSharedPointer<EnumeratedValueValidator> enumValidator (new EnumeratedValueValidator(parser));\r\n    QSharedPointer<FieldValidator> fieldValidator (new FieldValidator(parser, enumValidator, parameterValidator));\r\n    RegisterValidator validator(parser, fieldValidator, parameterValidator);\r\n\r\n    QCOMPARE(validator.hasValidFields(testRegister, testRegister->getSize()), isValid);\r\n\r\n    if (!isValid)\r\n    {\r\n        QVector<QString> foundErrors;\r\n        validator.findErrorsIn(foundErrors, testRegister, \"test\");\r\n\r\n        QString expectedError = QObject::tr(\"Fields %1 and %2 overlap within register %3\")\r\n            .arg(fieldOne->name()).arg(fieldTwo->name()).arg(testRegister->name());\r\n\r\n        if (errorIsNotFoundInErrorList(expectedError, foundErrors))\r\n        {\r\n            QFAIL(\"No error message found\");\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_RegisterValidator::testFieldRangesAreValid_data()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_RegisterValidator::testFieldRangesAreValid_data()\r\n{\r\n    QTest::addColumn<QString>(\"firstOffset\");\r\n    QTest::addColumn<QString>(\"firstWidth\");\r\n    QTest::addColumn<QString>(\"firstAccess\");\r\n    QTest::addColumn<QString>(\"secondOffset\");\r\n    QTest::addColumn<QString>(\"secondWidth\");\r\n    QTest::addColumn<QString>(\"secondAccess\");\r\n    QTest::addColumn<bool>(\"isValid\");\r\n\r\n    QTest::newRow(\"Field1: offset 0, width 2 and field2: offset 2, width 2 are valid\") << \"0\" << \"2\" << \"\" <<\r\n        \"2\" << \"2\" << \"\" << true;\r\n    QTest::newRow(\"Field1: offset 0, width 2 and field2: offset 10, width 2 are valid\") << \"0\" << \"2\" << \"\" <<\r\n        \"10\" << \"2\" << \"\" << true;\r\n    QTest::newRow(\"Field1: offset 0, width 2 and field2: offset 1, width 2 are invalid\") << \"0\" << \"2\" << \"\" <<\r\n        \"1\" << \"2\" << \"\" << false;\r\n    QTest::newRow(\"Field1: offset 1, width 2 and field2: offset 1, width 2 are invalid\") << \"1\" << \"2\" << \"\" <<\r\n        \"1\" << \"2\" << \"\" << false;\r\n    QTest::newRow(\"Field1: offset 0, width 11 and field2: offset 4, width 3 are invalid\") << \"0\" << \"11\" << \"\" <<\r\n        \"4\" << \"3\" << \"\" << false;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_RegisterValidator::testFieldsAreWithinRegister()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_RegisterValidator::testFieldsAreWithinRegister()\r\n{\r\n    QFETCH(QString, bitOffset);\r\n    QFETCH(QString, bitWidth);\r\n    QFETCH(QString, registerSize);\r\n    QFETCH(bool, isValid);\r\n\r\n    QSharedPointer<Field> fieldOne (new Field(\"FieldOne\"));\r\n    fieldOne->setBitOffset(bitOffset);\r\n    fieldOne->setBitWidth(bitWidth);\r\n\r\n    QSharedPointer<Register> testRegister(new Register(\"TestRegister\"));\r\n    testRegister->setSize(registerSize);\r\n    testRegister->getFields()->append(fieldOne);\r\n\r\n    QSharedPointer<ExpressionParser> parser (new SystemVerilogExpressionParser());\r\n    QSharedPointer<ParameterValidator> parameterValidator(new ParameterValidator(parser,\r\n        QSharedPointer<QList<QSharedPointer<Choice> > > (), Document::Revision::Std14));\r\n    QSharedPointer<EnumeratedValueValidator> enumValidator (new EnumeratedValueValidator(parser));\r\n    QSharedPointer<FieldValidator> fieldValidator (new FieldValidator(parser, enumValidator, parameterValidator));\r\n    RegisterValidator validator(parser, fieldValidator, parameterValidator);\r\n\r\n    QCOMPARE(validator.hasValidFields(testRegister, testRegister->getSize()), isValid);\r\n\r\n    if (!isValid)\r\n    {\r\n        QVector<QString> foundErrors;\r\n        validator.findErrorsIn(foundErrors, testRegister, \"test\");\r\n\r\n        QString expectedError = QObject::tr(\"Field %1 is not contained within %2\").arg(fieldOne->name()).\r\n            arg(testRegister->name());\r\n\r\n        bool offsetValid = false;\r\n        bool bitwidthValid = false;\r\n        parser->parseExpression(bitOffset, &offsetValid);\r\n        parser->parseExpression(bitWidth, &bitwidthValid);\r\n        if (offsetValid == false)\r\n        {\r\n            expectedError = QObject::tr(\"Invalid bit offset set for field %1 within register %2\").\r\n                arg(fieldOne->name()).arg(testRegister->name());\r\n        }\r\n        else if (bitwidthValid == false)\r\n        {\r\n            expectedError = QObject::tr(\"Invalid bit width set for field %1 within register %2\").\r\n                arg(fieldOne->name()).arg(testRegister->name());\r\n        }\r\n\r\n        if (errorIsNotFoundInErrorList(expectedError, foundErrors))\r\n        {\r\n            QFAIL(\"No error message found\");\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_RegisterValidator::testFieldsAreWithinRegister_data()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_RegisterValidator::testFieldsAreWithinRegister_data()\r\n{\r\n    QTest::addColumn<QString>(\"bitOffset\");\r\n    QTest::addColumn<QString>(\"bitWidth\");\r\n    QTest::addColumn<QString>(\"registerSize\");\r\n    QTest::addColumn<bool>(\"isValid\");\r\n\r\n    QTest::newRow(\"Field: bitOffset 0, bitWidth 4 in register with size 10 is valid\") << \"0\" << \"4\" << \"10\" <<\r\n        true;\r\n    QTest::newRow(\"Field: bitOffset -2, bitWidth 4 in register with size 10 is invalid\") << \"-2\" << \"4\" << \"10\" <<\r\n        false;\r\n    QTest::newRow(\"Field: bitOffset 8, bitWidth 2 in register with size 2 is invalid\") << \"8\" << \"2\" << \"2\" << false;\r\n    QTest::newRow(\"Field: bitOffset 2, bitWidth 8 in register with size 4 is invalid\") << \"2\" << \"8\" << \"4\" << false;\r\n\r\n    QTest::newRow(\"Field with long bit offset is not within a small register\") <<\r\n        \"4000000000000000000000000000000000\" << \"0\" << \"10\" << false;\r\n    QTest::newRow(\"Field with long bit width is not within a small register\") <<\r\n        \"0\" << \"4000000000000000000000000000000000\" << \"10\" << false;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_RegisterValidator::testFieldsHaveSimilarDefinitionGroups()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_RegisterValidator::testFieldsHaveSimilarDefinitionGroups()\r\n{\r\n    QFETCH(QString, typeIdentifierOne);\r\n    QFETCH(QString, bitWidthOne);\r\n    QFETCH(bool, volatileOne);\r\n    QFETCH(QString, accessOne);\r\n    QFETCH(QString, enumeratedNameOne);\r\n    QFETCH(QString, enumeratedValueOne);\r\n    QFETCH(QString, writeConstraintMinimumOne);\r\n    QFETCH(QString, modifiedWriteValueOne);\r\n    QFETCH(QString, readActionOne);\r\n    QFETCH(bool, testableOne);\r\n    QFETCH(QString, reservedOne);\r\n\r\n    QFETCH(QString, typeIdentifierTwo);\r\n    QFETCH(QString, bitWidthTwo);\r\n    QFETCH(bool, volatileTwo);\r\n    QFETCH(QString, accessTwo);\r\n    QFETCH(QString, enumeratedNameTwo);\r\n    QFETCH(QString, enumeratedValueTwo);\r\n    QFETCH(QString, writeConstraintMinimumTwo);\r\n    QFETCH(QString, modifiedWriteValueTwo);\r\n    QFETCH(QString, readActionTwo);\r\n    QFETCH(bool, testableTwo);\r\n    QFETCH(QString, reservedTwo);\r\n\r\n    QFETCH(bool, isValid);\r\n\r\n    QSharedPointer<EnumeratedValue> enumOne (new EnumeratedValue(enumeratedNameOne, enumeratedValueOne));\r\n\r\n    QSharedPointer<WriteValueConstraint> constraintOne (new WriteValueConstraint());\r\n    constraintOne->setMinimum(writeConstraintMinimumOne);\r\n    constraintOne->setMaximum(\"20\");\r\n\r\n    QSharedPointer<Field> fieldOne (new Field(\"fieldOne\"));\r\n    fieldOne->setBitOffset(\"0\");\r\n    fieldOne->setBitOffset(\"2\");\r\n    fieldOne->setTypeIdentifier(typeIdentifierOne);\r\n    fieldOne->setBitWidth(bitWidthOne);\r\n    fieldOne->setVolatile(volatileOne);\r\n    fieldOne->setAccess(AccessTypes::str2Access(accessOne, AccessTypes::ACCESS_COUNT));\r\n    fieldOne->setModifiedWrite(General::str2ModifiedWrite(modifiedWriteValueOne));\r\n    fieldOne->setReadAction(General::str2ReadAction(readActionOne));\r\n    fieldOne->setTestable(testableOne);\r\n    fieldOne->setReserved(reservedOne);\r\n    fieldOne->setWriteConstraint(constraintOne);\r\n    fieldOne->getEnumeratedValues()->append(enumOne);\r\n\r\n    QSharedPointer<EnumeratedValue> enumTwo (new EnumeratedValue(enumeratedNameTwo, enumeratedValueTwo));\r\n\r\n    QSharedPointer<WriteValueConstraint> constraintTwo (new WriteValueConstraint());\r\n    constraintTwo->setMinimum(writeConstraintMinimumTwo);\r\n    constraintTwo->setMaximum(\"20\");\r\n\r\n    QSharedPointer<Field> fieldTwo (new Field(\"fieldTwo\"));\r\n    fieldTwo->setBitOffset(\"3\");\r\n    fieldTwo->setBitWidth(\"2\");\r\n    fieldTwo->setTypeIdentifier(typeIdentifierTwo);\r\n    fieldTwo->setBitWidth(bitWidthTwo);\r\n    fieldTwo->setVolatile(volatileTwo);\r\n    fieldTwo->setAccess(AccessTypes::str2Access(accessTwo, AccessTypes::ACCESS_COUNT));\r\n    fieldTwo->setModifiedWrite(General::str2ModifiedWrite(modifiedWriteValueTwo));\r\n    fieldTwo->setReadAction(General::str2ReadAction(readActionTwo));\r\n    fieldTwo->setTestable(testableTwo);\r\n    fieldTwo->setReserved(reservedTwo);\r\n    fieldTwo->setWriteConstraint(constraintTwo);\r\n    fieldTwo->getEnumeratedValues()->append(enumTwo);\r\n\r\n    QSharedPointer<Register> testRegister(new Register(\"TestRegister\"));\r\n    testRegister->setSize(\"100\");\r\n    testRegister->getFields()->append(fieldOne);\r\n    testRegister->getFields()->append(fieldTwo);\r\n\r\n    QSharedPointer<ExpressionParser> parser (new SystemVerilogExpressionParser());\r\n    QSharedPointer<ParameterValidator> parameterValidator(new ParameterValidator(parser,\r\n        QSharedPointer<QList<QSharedPointer<Choice> > > (), Document::Revision::Std14));\r\n    QSharedPointer<EnumeratedValueValidator> enumValidator (new EnumeratedValueValidator(parser));\r\n    QSharedPointer<FieldValidator> fieldValidator (new FieldValidator(parser, enumValidator, parameterValidator));\r\n    RegisterValidator validator(parser, fieldValidator, parameterValidator);\r\n\r\n    QCOMPARE(validator.hasValidFields(testRegister, testRegister->getSize()), isValid);\r\n\r\n    if (!isValid)\r\n    {\r\n        QVector<QString> foundErrors;\r\n        validator.findErrorsIn(foundErrors, testRegister, \"test\");\r\n\r\n        QString expectedError = QObject::tr(\"Fields %1 and %2 have type identifier %3, but different field \"\r\n            \"definitions within %4\").arg(fieldOne->name()).arg(fieldTwo->name())\r\n            .arg(fieldOne->getTypeIdentifier()).arg(\"register \" + testRegister->name());\r\n\r\n        if (errorIsNotFoundInErrorList(expectedError, foundErrors))\r\n        {\r\n            QFAIL(\"No error message found\");\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_RegisterValidator::testFieldsHaveSimilarDefinitionGroups_data()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_RegisterValidator::testFieldsHaveSimilarDefinitionGroups_data()\r\n{\r\n    QTest::addColumn<QString>(\"typeIdentifierOne\");\r\n    QTest::addColumn<QString>(\"bitWidthOne\");\r\n    QTest::addColumn<bool>(\"volatileOne\");\r\n    QTest::addColumn<QString>(\"accessOne\");\r\n    QTest::addColumn<QString>(\"enumeratedNameOne\");\r\n    QTest::addColumn<QString>(\"enumeratedValueOne\");\r\n    QTest::addColumn<QString>(\"modifiedWriteValueOne\");\r\n    QTest::addColumn<QString>(\"writeConstraintMinimumOne\");\r\n    QTest::addColumn<QString>(\"readActionOne\");\r\n    QTest::addColumn<bool>(\"testableOne\");\r\n    QTest::addColumn<QString>(\"reservedOne\");\r\n\r\n    QTest::addColumn<QString>(\"typeIdentifierTwo\");\r\n    QTest::addColumn<QString>(\"bitWidthTwo\");\r\n    QTest::addColumn<bool>(\"volatileTwo\");\r\n    QTest::addColumn<QString>(\"accessTwo\");\r\n    QTest::addColumn<QString>(\"enumeratedNameTwo\");\r\n    QTest::addColumn<QString>(\"enumeratedValueTwo\");\r\n    QTest::addColumn<QString>(\"modifiedWriteValueTwo\");\r\n    QTest::addColumn<QString>(\"writeConstraintMinimumTwo\");\r\n    QTest::addColumn<QString>(\"readActionTwo\");\r\n    QTest::addColumn<bool>(\"testableTwo\");\r\n    QTest::addColumn<QString>(\"reservedTwo\");\r\n\r\n    QTest::addColumn<bool>(\"isValid\");\r\n\r\n    QTest::newRow(\"Similar field definitions with same typeIdentifier are valid\") <<\r\n        \"identifier\" << \"1\" << false << \"\" << \"enum\" << \"2\" << \"\" << \"1\" << \"set\" << true << \"1\" <<\r\n        \"identifier\" << \"1\" << false << \"\" << \"enum\" << \"2\" << \"\" << \"1\" << \"set\" << true << \"1\" <<\r\n        true;\r\n    QTest::newRow(\"Similar field definitions with different typeIdentifier are valid\") <<\r\n        \"identifier\" << \"1\" << false << \"\" << \"enum\" << \"2\" << \"\" << \"1\" << \"set\" << true << \"1\" <<\r\n        \"identifier2\" << \"1\" << false << \"\" << \"enum\" << \"2\" << \"\" << \"1\" << \"set\" << true << \"1\" <<\r\n        true;\r\n    QTest::newRow(\"Different field definitions with empty typeIdentifier are valid\") <<\r\n        \"\" << \"1\" << false << \"\" << \"enum\" << \"2\" << \"\" << \"1\" << \"set\" << true << \"1\" <<\r\n        \"\" << \"2\" << false << \"\" << \"enum2\" << \"3\" << \"\" << \"2\" << \"set\" << true << \"0\" <<\r\n        true;\r\n    QTest::newRow(\"Different field definitions with different typeIdentifiers are valid\") <<\r\n        \"identifier1\" << \"1\" << false << \"\" << \"enum\" << \"2\" << \"\" << \"1\" << \"set\" << true << \"1\" <<\r\n        \"identifier2\" << \"2\" << false << \"\" << \"enum2\" << \"3\" << \"\" << \"2\" << \"set\" << true << \"0\" <<\r\n        true;\r\n\r\n    QTest::newRow(\"Different bitWidth is invalid\") <<\r\n        \"identifier\" << \"1\" << false << \"\" << \"enum\" << \"2\" << \"\" << \"1\" << \"set\" << true << \"1\" <<\r\n        \"identifier\" << \"2\" << false << \"\" << \"enum\" << \"2\" << \"\" << \"1\" << \"set\" << true << \"1\" <<\r\n        false;\r\n    QTest::newRow(\"Different volatile is invalid\") <<\r\n        \"identifier\" << \"1\" << false << \"\" << \"enum\" << \"2\" << \"\" << \"1\" << \"set\" << true << \"1\" <<\r\n        \"identifier\" << \"1\" << true << \"\" << \"enum\" << \"2\" << \"\" << \"1\" << \"set\" << true << \"1\" <<\r\n        false;\r\n    QTest::newRow(\"Different access is invalid\") <<\r\n        \"identifier\" << \"1\" << false << \"\" << \"enum\" << \"2\" << \"\" << \"1\" << \"set\" << true << \"1\" <<\r\n        \"identifier\" << \"1\" << false << \"read-write\" << \"enum\" << \"2\" << \"\" << \"1\" << \"set\" << true << \"1\" <<\r\n        false;\r\n    QTest::newRow(\"Different enumerated name is invalid\") <<\r\n        \"identifier\" << \"1\" << false << \"\" << \"enum\" << \"2\" << \"\" << \"1\" << \"set\" << true << \"1\" <<\r\n        \"identifier\" << \"1\" << false << \"\" << \"enum2\" << \"2\" << \"\" << \"1\" << \"set\" << true << \"1\" <<\r\n        false;\r\n    QTest::newRow(\"Different enumerated value is invalid\") <<\r\n        \"identifier\" << \"1\" << false << \"\" << \"enum\" << \"2\" << \"\" << \"1\" << \"set\" << true << \"1\" <<\r\n        \"identifier\" << \"1\" << false << \"\" << \"enum\" << \"3\" << \"\" << \"1\" << \"set\" << true << \"1\" <<\r\n        false;\r\n    QTest::newRow(\"Different modified write value is invalid\") <<\r\n        \"identifier\" << \"1\" << false << \"\" << \"enum\" << \"2\" << \"\" << \"1\" << \"set\" << true << \"1\" <<\r\n        \"identifier\" << \"1\" << false << \"\" << \"enum\" << \"2\" << \"oneToClear\" << \"1\" << \"set\" << true << \"1\" <<\r\n        false;\r\n    QTest::newRow(\"Different write constraint minimum is invalid\") <<\r\n        \"identifier\" << \"1\" << false << \"\" << \"enum\" << \"2\" << \"\" << \"1\" << \"set\" << true << \"1\" <<\r\n        \"identifier\" << \"1\" << false << \"\" << \"enum\" << \"2\" << \"\" << \"2\" << \"set\" << true << \"1\" <<\r\n        false;\r\n    QTest::newRow(\"Different read action is invalid\") <<\r\n        \"identifier\" << \"1\" << false << \"\" << \"enum\" << \"2\" << \"\" << \"1\" << \"set\" << true << \"1\" <<\r\n        \"identifier\" << \"1\" << false << \"\" << \"enum\" << \"2\" << \"\" << \"1\" << \"\" << true << \"1\" <<\r\n        false;\r\n    QTest::newRow(\"Different testable value is invalid\") <<\r\n        \"identifier\" << \"1\" << false << \"\" << \"enum\" << \"2\" << \"\" << \"1\" << \"\" << true << \"1\" <<\r\n        \"identifier\" << \"1\" << false << \"\" << \"enum\" << \"2\" << \"\" << \"1\" << \"\" << false << \"1\" <<\r\n        false;\r\n    QTest::newRow(\"Different reserved value is invalid\") <<\r\n        \"identifier\" << \"1\" << false << \"\" << \"enum\" << \"2\" << \"\" << \"1\" << \"\" << true << \"1\" <<\r\n        \"identifier\" << \"1\" << false << \"\" << \"enum\" << \"2\" << \"\" << \"1\" << \"\" << true << \"0+1\" <<\r\n        false;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_RegisterValidator::testAlternateRegisterIsValid()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_RegisterValidator::testAlternateRegisterIsValid()\r\n{\r\n    QFETCH(QString, name);\r\n    QFETCH(QString, isPresent);\r\n    QFETCH(QString, alternateGroup1);\r\n    QFETCH(QString, alternateGroup2);\r\n    QFETCH(bool, isValid);\r\n\r\n    QSharedPointer<Field> field (new Field(\"TestField\"));\r\n    field->setBitWidth(\"2\");\r\n    field->setBitOffset(\"4\");\r\n\r\n    QSharedPointer<AlternateRegister> testAlternateRegister(new AlternateRegister(name, alternateGroup1));\r\n    testAlternateRegister->setIsPresent(isPresent);\r\n    testAlternateRegister->getAlternateGroups()->append(alternateGroup2);\r\n    testAlternateRegister->getFields()->append(field);\r\n\r\n    QSharedPointer<Register> testRegister (new Register(\"testRegister\"));\r\n    testRegister->setSize(\"100\");\r\n    testRegister->getAlternateRegisters()->append(testAlternateRegister);\r\n\r\n    QSharedPointer<ExpressionParser> parser(new SystemVerilogExpressionParser());\r\n    //     QSharedPointer<ParameterFinder> finder (new ComponentParameterFinder(QSharedPointer<Component> ()));\r\n    QSharedPointer<ParameterValidator> parameterValidator(new ParameterValidator(parser,\r\n        QSharedPointer<QList<QSharedPointer<Choice> > > (), Document::Revision::Std14));\r\n    QSharedPointer<EnumeratedValueValidator> enumValidator (new EnumeratedValueValidator(parser));\r\n    QSharedPointer<FieldValidator> fieldValidator (new FieldValidator(parser, enumValidator, parameterValidator));\r\n    RegisterValidator validator(parser, fieldValidator, parameterValidator);\r\n    QCOMPARE(validator.hasValidAlternateRegisters(testRegister), isValid);\r\n\r\n    if (!isValid)\r\n    {\r\n        QVector<QString> foundErrors;\r\n        validator.findErrorsIn(foundErrors, testRegister, \"test\");\r\n\r\n        QString expectedError;\r\n        if (!validator.hasValidName(testAlternateRegister))\r\n        {\r\n            expectedError = QObject::tr(\"Invalid name specified for alternate register %1 within %2\").\r\n                arg(testAlternateRegister->name()).arg(\"register \" + testRegister->name());\r\n\r\n            if (errorIsNotFoundInErrorList(expectedError, foundErrors))\r\n            {\r\n                QFAIL(\"No error message found\");\r\n            }\r\n        }\r\n\r\n        if (!validator.hasValidIsPresent(testAlternateRegister))\r\n        {\r\n            expectedError = QObject::tr(\"Invalid isPresent set for alternate register %1 within %2\").\r\n                arg(testAlternateRegister->name()).arg(\"register \" + testRegister->name());\r\n\r\n            if (errorIsNotFoundInErrorList(expectedError, foundErrors))\r\n            {\r\n                QFAIL(\"No error message found\");\r\n            }\r\n        }\r\n\r\n        if (!validator.hasValidAlternateGroups(testAlternateRegister))\r\n        {\r\n            expectedError = QObject::tr(\"Alternate groups are not unique or not empty in alternate register %1 within %2\").\r\n                arg(testAlternateRegister->name()).arg(\"register \" + testRegister->name());\r\n\r\n            if (errorIsNotFoundInErrorList(expectedError, foundErrors))\r\n            {\r\n                QFAIL(\"No error message found\");\r\n            }\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_RegisterValidator::testAlternateRegisterIsValid_data()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_RegisterValidator::testAlternateRegisterIsValid_data()\r\n{\r\n    QTest::addColumn<QString>(\"name\");\r\n    QTest::addColumn<QString>(\"isPresent\");\r\n    QTest::addColumn<QString>(\"alternateGroup1\");\r\n    QTest::addColumn<QString>(\"alternateGroup2\");\r\n    QTest::addColumn<bool>(\"isValid\");\r\n\r\n    QTest::newRow(\"Alternate register without a name is invalid\") << \"\" << \"\" << \"alternate\" << \"beast\" << false;\r\n    QTest::newRow(\"Alternate register with name and alternate group is valid\") << \"Golden\" << \"\" << \"Axe\" << \"I\" <<\r\n        true;\r\n    QTest::newRow(\"Alternate register without alternate group is invalid\") << \"Vendetta\" << \"\" << \"\" << \"\" <<\r\n        false;\r\n    QTest::newRow(\"Alternate register with non-unique alternate groups is invalid\") << \"Baseball\" << \"\" <<\r\n        \"Stars\" << \"Stars\" << false;\r\n\r\n    QTest::newRow(\"IsPresent 1 is valid\") << \"Metal\" << \"1\" << \"Slug\" << \"SuperVehicle\" << true;\r\n    QTest::newRow(\"IsPresent 1*3-3 is valid\") << \"Metal\" << \"1*3-3\" << \"Slug\" << \"II\" << true;\r\n    QTest::newRow(\"IsPresent 2*100 is invalid\") << \"Metal\" << \"2*100\" << \"Slug\" << \"X\" << false;\r\n    QTest::newRow(\"IsPresent -14 is invalid\") << \"Metal\" << \"-14\" << \"Slug\" << \"3\" << false;\r\n    QTest::newRow(\"Real number isPresent  0.12 is invalid\") << \"Metal\" << \"0.12\" << \"Slug\" << \"4\" << false;\r\n    QTest::newRow(\"Text as isPresent is invalid\") << \"Metal\" << \"test\" << \"Slug\" << \"5\" << false;\r\n    QTest::newRow(\"String as isPresent is invalid\") << \"Metal\" << \"\\\"test\\\"\" << \"Slug\" << \"6\" << false;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_RegisterValidator::testMultipleAlternateRegistersAreValid()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_RegisterValidator::testMultipleAlternateRegistersAreValid()\r\n{\r\n    QSharedPointer<Field> field (new Field(\"TestField\"));\r\n    field->setBitOffset(\"4\");\r\n    field->setBitWidth(\"2\");\r\n\r\n    QSharedPointer<AlternateRegister> testAlternateRegister(new AlternateRegister(\"register1\", \"group\"));\r\n    testAlternateRegister->getFields()->append(field);\r\n    QSharedPointer<AlternateRegister> otherAlternateRegister(new AlternateRegister(\"register2\", \"group2\"));\r\n    otherAlternateRegister->getFields()->append(field);\r\n\r\n    QSharedPointer<Register> testRegister (new Register(\"testRegister\"));\r\n    testRegister->setSize(\"100\");\r\n    testRegister->getAlternateRegisters()->append(testAlternateRegister);\r\n    testRegister->getAlternateRegisters()->append(otherAlternateRegister);\r\n\r\n    QSharedPointer<ExpressionParser> parser(new SystemVerilogExpressionParser());\r\n    QSharedPointer<ParameterValidator> parameterValidator(new ParameterValidator(parser,\r\n        QSharedPointer<QList<QSharedPointer<Choice> > > (), Document::Revision::Std14));\r\n    QSharedPointer<EnumeratedValueValidator> enumValidator (new EnumeratedValueValidator(parser));\r\n    QSharedPointer<FieldValidator> fieldValidator (new FieldValidator(parser, enumValidator, parameterValidator));\r\n    RegisterValidator validator(parser, fieldValidator, parameterValidator);\r\n    QCOMPARE(validator.hasValidAlternateRegisters(testRegister), true);\r\n\r\n    QSharedPointer<AlternateRegister> thirdAlternateRegister(new AlternateRegister(*testAlternateRegister.data()));\r\n    testRegister->getAlternateRegisters()->append(thirdAlternateRegister);\r\n    QCOMPARE(validator.hasValidAlternateRegisters(testRegister), false);\r\n\r\n    QVector<QString> foundErrors;\r\n    validator.findErrorsIn(foundErrors, testRegister, \"test\");\r\n\r\n    QString expectedError = QObject::tr(\"Name %1 of alternate registers in %2 is not unique.\").\r\n        arg(thirdAlternateRegister->name()).arg(\"register \" + testRegister->name());\r\n\r\n    if (errorIsNotFoundInErrorList(expectedError, foundErrors))\r\n    {\r\n        QFAIL(\"No error message found\");\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_RegisterValidator::testAlternateRegisterParametersAreValid()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_RegisterValidator::testAlternateRegisterParametersAreValid()\r\n{\r\n    QSharedPointer<Parameter> testParameter (new Parameter());\r\n    testParameter->setValueId(\"Sanger\");\r\n    testParameter->setName(\"Daizengar\");\r\n    testParameter->setValue(\"20\");\r\n    testParameter->setType(\"int\");\r\n\r\n    QSharedPointer<Field> field (new Field(\"testField\"));\r\n    field->setBitOffset(\"2\");\r\n    field->setBitWidth(\"4\");\r\n\r\n    QSharedPointer<AlternateRegister> testAlternateRegister (new AlternateRegister(\"Alternate\"));\r\n    testAlternateRegister->getParameters()->append(testParameter);\r\n    testAlternateRegister->getFields()->append(field);\r\n\r\n    QSharedPointer<Register> testRegister (new Register(\"TestRegister\"));\r\n    testRegister->getAlternateRegisters()->append(testAlternateRegister);\r\n\r\n    QSharedPointer<ExpressionParser> parser(new SystemVerilogExpressionParser());\r\n    QSharedPointer<ParameterValidator> parameterValidator(new ParameterValidator(parser,\r\n        QSharedPointer<QList<QSharedPointer<Choice> > > (), Document::Revision::Std14));\r\n    QSharedPointer<EnumeratedValueValidator> enumValidator (new EnumeratedValueValidator(parser));\r\n    QSharedPointer<FieldValidator> fieldValidator (new FieldValidator(parser, enumValidator, parameterValidator));\r\n    RegisterValidator validator(parser, fieldValidator, parameterValidator);\r\n\r\n    QCOMPARE(validator.hasValidParameters(testAlternateRegister), true);\r\n\r\n    testParameter->setValue(\"\");\r\n    QCOMPARE(validator.hasValidParameters(testAlternateRegister), false);\r\n\r\n    QVector<QString> errorsFound;\r\n    validator.findErrorsIn(errorsFound, testRegister, \"test\");\r\n\r\n    QString expectedError = QObject::tr(\"No value specified for %1 %2 within alternate register %3 within register %4\").\r\n        arg(testParameter->elementName()).arg(testParameter->name()).arg(testAlternateRegister->name()).\r\n        arg(testRegister->name());\r\n\r\n    if (errorIsNotFoundInErrorList(expectedError, errorsFound))\r\n    {\r\n        QFAIL(\"Error was not found\");\r\n    }\r\n\r\n    QSharedPointer<Parameter> otherParameter (new Parameter(*testParameter.data()));\r\n    testParameter->setValue(\"1\");\r\n    otherParameter->setValue(\"2\");\r\n    testAlternateRegister->getParameters()->append(otherParameter);\r\n\r\n    QCOMPARE(validator.hasValidParameters(testAlternateRegister), false);\r\n\r\n    errorsFound.clear();\r\n    validator.findErrorsIn(errorsFound, testRegister, \"test\");\r\n    expectedError = QObject::tr(\"Name %1 of parameters in alternate register %2 within register %3 is not unique.\").\r\n        arg(otherParameter->name()).arg(testAlternateRegister->name()).arg(testRegister->name());\r\n    if (errorIsNotFoundInErrorList(expectedError, errorsFound))\r\n    {\r\n        QFAIL(\"Error was not found\");\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_RegisterValidator::testParametersAreValid()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_RegisterValidator::testParametersAreValid()\r\n{\r\n    QSharedPointer<Parameter> testParameter (new Parameter());\r\n    testParameter->setValueId(\"Sanger\");\r\n    testParameter->setName(\"Daizengar\");\r\n    testParameter->setValue(\"20\");\r\n    testParameter->setType(\"int\");\r\n\r\n    QSharedPointer<Register> testRegister (new Register(\"TestRegister\"));\r\n    testRegister->getParameters()->append(testParameter);\r\n\r\n    QSharedPointer<ExpressionParser> parser(new SystemVerilogExpressionParser());\r\n    QSharedPointer<ParameterValidator> parameterValidator(new ParameterValidator(parser,\r\n        QSharedPointer<QList<QSharedPointer<Choice> > > (), Document::Revision::Std14));\r\n    QSharedPointer<EnumeratedValueValidator> enumValidator (new EnumeratedValueValidator(parser));\r\n    QSharedPointer<FieldValidator> fieldValidator (new FieldValidator(parser, enumValidator, parameterValidator));\r\n    RegisterValidator validator(parser, fieldValidator, parameterValidator);\r\n\r\n    QCOMPARE(validator.hasValidParameters(testRegister), true);\r\n\r\n    testParameter->setValue(\"\");\r\n    QCOMPARE(validator.hasValidParameters(testRegister), false);\r\n\r\n    QVector<QString> errorsFound;\r\n    validator.findErrorsIn(errorsFound, testRegister, \"test\");\r\n\r\n    QString expectedError = QObject::tr(\"No value specified for %1 %2 within register %3\").\r\n        arg(testParameter->elementName()).arg(testParameter->name()).arg(testRegister->name());\r\n\r\n    if (errorIsNotFoundInErrorList(expectedError, errorsFound))\r\n    {\r\n        QFAIL(\"Error was not found\");\r\n    }\r\n\r\n    QSharedPointer<Parameter> otherParameter (new Parameter(*testParameter.data()));\r\n    testParameter->setValue(\"1\");\r\n    otherParameter->setValue(\"2\");\r\n    testRegister->getParameters()->append(otherParameter);\r\n\r\n    QCOMPARE(validator.hasValidParameters(testRegister), false);\r\n\r\n    errorsFound.clear();\r\n    validator.findErrorsIn(errorsFound, testRegister, \"test\");\r\n    expectedError = QObject::tr(\"Name %1 of parameters in register %2 is not unique.\").arg(otherParameter->name()).\r\n        arg(testRegister->name());\r\n    if (errorIsNotFoundInErrorList(expectedError, errorsFound))\r\n    {\r\n        QFAIL(\"Error was not found\");\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_RegisterValidator::testRegisterMemoryArrayIsValid2022()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_RegisterValidator::testRegisterMemoryArrayIsValid2022()\r\n{\r\n    QFETCH(QString, dimValue);\r\n    QFETCH(QString, indexVar);\r\n    QFETCH(QString, stride);\r\n    QFETCH(bool, validDim);\r\n    QFETCH(bool, validStride);\r\n\r\n    QSharedPointer<Register> testRegister(new Register(\"test\", \"8\", \"8\"));\r\n    \r\n    QSharedPointer<MemoryArray> testMemArray(new MemoryArray());\r\n\r\n    QSharedPointer<MemoryArray::Dimension> testDim(new MemoryArray::Dimension);\r\n    testDim->value_ = dimValue;\r\n    testDim->indexVar_ = indexVar;\r\n    \r\n    if (dimValue.isEmpty() == false)\r\n    {\r\n        testMemArray->getDimensions()->append(testDim);\r\n    }\r\n\r\n    testMemArray->setStride(stride);\r\n\r\n    testRegister->setMemoryArray(testMemArray);\r\n\r\n    QSharedPointer<ExpressionParser> parser(new SystemVerilogExpressionParser());\r\n    QSharedPointer<ParameterValidator> parameterValidator(new ParameterValidator(parser,\r\n        QSharedPointer<QList<QSharedPointer<Choice> > >(), Document::Revision::Std22));\r\n    QSharedPointer<EnumeratedValueValidator> enumValidator(new EnumeratedValueValidator(parser));\r\n    QSharedPointer<FieldValidator> fieldValidator(new FieldValidator(parser, enumValidator, parameterValidator));\r\n    RegisterValidator validator(parser, fieldValidator, parameterValidator, Document::Revision::Std22);\r\n\r\n    QCOMPARE(validator.hasValidMemoryArray(testRegister), validDim && validStride);\r\n\r\n    if (!(validDim && validStride))\r\n    {\r\n        QStringList foundErrors;\r\n        validator.findErrorsIn(foundErrors, testRegister, \"test\");\r\n\r\n        QString expectedError;\r\n\r\n        if (testMemArray->getDimensions()->isEmpty())\r\n        {\r\n            expectedError = \"No dimensions defined for memory array in register 'test' within test\";\r\n        }\r\n\r\n        else if (!validDim)\r\n        {\r\n            expectedError = \"One or more dimensions of the memory array in register 'test' within test have an invalid value.\";\r\n        }\r\n\r\n        else if (!validStride)\r\n        {\r\n            expectedError = \"Memory array in register 'test' within test has an invalid stride value.\";\r\n        }\r\n\r\n        if (errorIsNotFoundInErrorList(expectedError, foundErrors))\r\n        {\r\n            QFAIL(\"No error message found\");\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_RegisterValidator::testRegisterMemoryArrayIsValid2022_data()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_RegisterValidator::testRegisterMemoryArrayIsValid2022_data()\r\n{\r\n    QTest::addColumn<QString>(\"dimValue\");\r\n    QTest::addColumn<QString>(\"indexVar\");\r\n    QTest::addColumn<QString>(\"stride\");\r\n    QTest::addColumn<bool>(\"validDim\");\r\n    QTest::addColumn<bool>(\"validStride\");\r\n\r\n    QTest::newRow(\"Dimension with valid values is valid\") << \"8\" << \"i\" << \"8\" << true << true;\r\n    QTest::newRow(\"Dimension without stride is valid\") << \"8\" << \"i\" << \"\" << true << true;\r\n    QTest::newRow(\"Valid expression in dim is valid\") << \"1+1\" << \"index\" << \"\" << true << true;\r\n    QTest::newRow(\"Invalid expression in dim is not valid\") << \"a+a\" << \"index\" << \"\" << false << true;\r\n    QTest::newRow(\"Invalid value in dim is not valid\") << \"-1\" << \"index\" << \"\" << false << true;\r\n    QTest::newRow(\"Valid expression in stride is valid\") << \"1\" << \"index\" << \"1+1\" << true << true;\r\n    QTest::newRow(\"Invalid expression in stride is not valid\") << \"1\" << \"index\" << \"a+a\" << true << false;\r\n    QTest::newRow(\"Invalid value in stride is not valid\") << \"1\" << \"index\" << \"-1\" << true << false;\r\n    QTest::newRow(\"Dimension doesn't exist is invalid\") << \"\" << \"\" << \"\" << false << false;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_RegisterValidator::testRegisterAccessPolicies2022()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_RegisterValidator::testRegisterAccessPoliciesAreValid2022()\r\n{\r\n    QSharedPointer<Register> testRegister(new Register(\"test\", \"8\", \"8\"));\r\n\r\n    QSharedPointer<ModeReference> modeRef1(new ModeReference());\r\n    modeRef1->setPriority(0);\r\n    modeRef1->setReference(\"ref\");\r\n\r\n    QSharedPointer<ModeReference> modeRef2(new ModeReference());\r\n    modeRef2->setPriority(0);\r\n    modeRef2->setReference(\"ref1\");\r\n\r\n    QSharedPointer<AccessPolicy> accessPolicy1(new AccessPolicy());\r\n    QSharedPointer<AccessPolicy> accessPolicy2(new AccessPolicy());\r\n    accessPolicy1->getModeReferences()->append(modeRef1);\r\n    accessPolicy2->getModeReferences()->append(modeRef2);\r\n\r\n    testRegister->getAccessPolicies()->append(accessPolicy1);\r\n    testRegister->getAccessPolicies()->append(accessPolicy2);\r\n\r\n    QSharedPointer<ExpressionParser> parser(new SystemVerilogExpressionParser());\r\n    QSharedPointer<ParameterValidator> parameterValidator(new ParameterValidator(parser,\r\n        QSharedPointer<QList<QSharedPointer<Choice> > >(), Document::Revision::Std22));\r\n    QSharedPointer<EnumeratedValueValidator> enumValidator(new EnumeratedValueValidator(parser));\r\n    QSharedPointer<FieldValidator> fieldValidator(new FieldValidator(parser, enumValidator, parameterValidator));\r\n    RegisterValidator validator(parser, fieldValidator, parameterValidator, Document::Revision::Std22);\r\n    \r\n    QSharedPointer<Component> dummyComponent(new Component(VLNV(VLNV::COMPONENT, \"vendor\", \"library\", \"name\", \"version\"), Document::Revision::Std22));\r\n    QSharedPointer<Mode> mode1(new Mode(\"ref\"));\r\n    QSharedPointer<Mode> mode2(new Mode(\"ref1\"));\r\n    dummyComponent->getModes()->append(mode1);\r\n    dummyComponent->getModes()->append(mode2);\r\n\r\n    validator.componentChange(dummyComponent);\r\n\r\n    QStringList errors;\r\n\r\n    QStringList possibleErrors(QStringList()\r\n        << \"One or more mode references in access policies of register 'test' within test contain duplicate priority values.\"\r\n        << \"One or more mode references in access policies of register 'test' within test contain duplicate mode reference values.\"\r\n        << \"Mode reference in access policies of register 'test' within test has invalid or empty reference value 'ref2'.\"\r\n        << \"In register test in test, multiple access policies are not allowed if one of them lacks a mode reference.\"\r\n    );\r\n\r\n    // Test duplicate mode reference priority.\r\n    validator.findErrorsIn(errors, testRegister, \"test\");\r\n    QVERIFY(errors.contains(possibleErrors.first()));\r\n    QVERIFY(validator.hasValidAccessPolicies(testRegister) == false);\r\n\r\n    // Test duplicate reference.\r\n    errors.clear();\r\n\r\n    modeRef2->setPriority(1);\r\n    modeRef2->setReference(\"ref\");\r\n\r\n    validator.findErrorsIn(errors, testRegister, \"test\");\r\n    QVERIFY(errors.contains(possibleErrors.at(1)));\r\n    QVERIFY(validator.hasValidAccessPolicies(testRegister) == false);\r\n\r\n    // Test invalid mode ref.\r\n    errors.clear();\r\n\r\n    modeRef2->setReference(\"ref2\");\r\n\r\n    validator.findErrorsIn(errors, testRegister, \"test\");\r\n    QVERIFY(errors.contains(possibleErrors.at(2)));\r\n    \r\n    \r\n    // Test valid mode refs.\r\n    errors.clear();\r\n    modeRef2->setReference(\"ref1\");\r\n    \r\n    validator.findErrorsIn(errors, testRegister, \"test\");\r\n    QVERIFY(std::none_of(possibleErrors.cbegin(), possibleErrors.cend(), [&errors](QString const& str)\r\n        {\r\n            return errors.contains(str);\r\n        }));\r\n\r\n    QVERIFY(validator.hasValidAccessPolicies(testRegister));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_RegisterValidator::testModeRefsOfAlternativeRegisetrsAreValid2022()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_RegisterValidator::testModeRefsOfAlternativeRegisetrsAreValid2022()\r\n{\r\n    QSharedPointer<Field> registerField(new Field(\"regField\"));\r\n    registerField->setBitOffset(\"8\");\r\n    registerField->setTypeDefinitionsRef(\"testTypeDefinitions\");\r\n    registerField->setFieldDefinitionRef(\"testField\");\r\n\r\n    QSharedPointer<Field> altRegisterField(new Field(\"altRegField\"));\r\n    altRegisterField->setBitOffset(\"8\");\r\n    altRegisterField->setTypeDefinitionsRef(\"testTypeDefinitions2\");\r\n    altRegisterField->setFieldDefinitionRef(\"testField2\");\r\n\r\n    QSharedPointer<Register> testRegister(new Register(\"testRegister\", \"10\", \"32\"));\r\n    QSharedPointer<AlternateRegister> alternateRegister(new AlternateRegister(\"testAlternate\"));\r\n\r\n    testRegister->getFields()->append(registerField);\r\n    alternateRegister->getFields()->append(altRegisterField);\r\n\r\n    testRegister->getAlternateRegisters()->append(alternateRegister);\r\n\r\n    QSharedPointer<AlternateRegister> alternateRegister2(new AlternateRegister(*alternateRegister));\r\n    alternateRegister2->setName(\"testAlternate2\");\r\n\r\n    testRegister->getAlternateRegisters()->append(alternateRegister2);\r\n\r\n    QSharedPointer<ModeReference> modeRef1(new ModeReference());\r\n    modeRef1->setPriority(0);\r\n    modeRef1->setReference(\"testMode\");\r\n    \r\n    QSharedPointer<ModeReference> modeRef2(new ModeReference());\r\n    modeRef2->setPriority(1);\r\n    modeRef2->setReference(\"testMode2\");\r\n\r\n    QSharedPointer<ExpressionParser> parser(new SystemVerilogExpressionParser());\r\n    QSharedPointer<ParameterValidator> parameterValidator(new ParameterValidator(parser,\r\n        QSharedPointer<QList<QSharedPointer<Choice> > >(), Document::Revision::Std22));\r\n    QSharedPointer<EnumeratedValueValidator> enumValidator(new EnumeratedValueValidator(parser));\r\n    QSharedPointer<FieldValidator> fieldValidator(new FieldValidator(parser, enumValidator, parameterValidator));\r\n    RegisterValidator validator(parser, fieldValidator, parameterValidator, Document::Revision::Std22);\r\n\r\n    QSharedPointer<Component> dummyComponent(new Component(VLNV(VLNV::COMPONENT, \"vendor\", \"library\", \"name\", \"version\"), Document::Revision::Std22));\r\n    QSharedPointer<Mode> mode1(new Mode(\"testMode\"));\r\n    QSharedPointer<Mode> mode2(new Mode(\"testMode2\"));\r\n    dummyComponent->getModes()->append(mode1);\r\n    dummyComponent->getModes()->append(mode2);\r\n\r\n    validator.componentChange(dummyComponent);\r\n\r\n    QStringList errors;\r\n\r\n    // Test no mode refs = error\r\n    validator.findErrorsIn(errors, testRegister, \"test\");\r\n    QCOMPARE(errors.size(), 2);\r\n    QVERIFY(validator.hasValidAlternateRegisters(testRegister) == false);\r\n    QVERIFY(errors.contains(QString(\"Alternate register testAlternate within register testRegister must have at least one mode reference defined.\")));\r\n\r\n    errors.clear();\r\n\r\n    // test two valid mode refs\r\n    alternateRegister->getModeReferences()->append(modeRef1);\r\n    alternateRegister2->getModeReferences()->append(modeRef2);\r\n\r\n    validator.findErrorsIn(errors, testRegister, \"test\");\r\n    QVERIFY(errors.isEmpty());\r\n    QVERIFY(validator.hasValidAlternateRegisters(testRegister));\r\n\r\n    errors.clear();\r\n\r\n    // Test duplicate priority\r\n    modeRef1->setPriority(1);\r\n\r\n    validator.findErrorsIn(errors, testRegister, \"test\");\r\n    QCOMPARE(errors.size(), 1);\r\n    QVERIFY(validator.hasValidAlternateRegisters(testRegister) == false);\r\n    \r\n    errors.clear();\r\n    modeRef1->setPriority(0);\r\n\r\n    // Test duplicate reference\r\n    modeRef1->setReference(\"testMode2\");\r\n\r\n    validator.findErrorsIn(errors, testRegister, \"test\");\r\n    QCOMPARE(errors.size(), 1);\r\n    QVERIFY(validator.hasValidAlternateRegisters(testRegister) == false);\r\n\r\n    errors.clear();\r\n\r\n    // Test invalid reference value.\r\n    modeRef1->setReference(\"value with whitespace\");\r\n    validator.findErrorsIn(errors, testRegister, \"test\");\r\n    QCOMPARE(errors.size(), 1);\r\n    QVERIFY(errors.contains(\"Mode reference in alternate register testAlternate within register testRegister has invalid or empty reference value 'value with whitespace'.\"));\r\n    QVERIFY(validator.hasValidAlternateRegisters(testRegister) == false);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_RegisterValidator::testAlternateRegisterAccessPolicies2022()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_RegisterValidator::testAlternateRegisterAccessPoliciesAreValid2022()\r\n{\r\n    QSharedPointer<Register> testRegister(new Register(\"testRegister\", \"10\", \"32\"));\r\n    QSharedPointer<AlternateRegister> alternateRegister(new AlternateRegister(\"testAlternate\"));\r\n\r\n    QSharedPointer<Field> registerField(new Field(\"regField\"));\r\n    registerField->setBitOffset(\"8\");\r\n    registerField->setTypeDefinitionsRef(\"testTypeDefinitions\");\r\n    registerField->setFieldDefinitionRef(\"testField\");\r\n\r\n    QSharedPointer<Field> altRegisterField(new Field(\"altRegField\"));\r\n    altRegisterField->setBitOffset(\"8\");\r\n    altRegisterField->setTypeDefinitionsRef(\"testTypeDefinitions2\");\r\n    altRegisterField->setFieldDefinitionRef(\"testField2\");\r\n\r\n    testRegister->getFields()->append(registerField);\r\n    alternateRegister->getFields()->append(altRegisterField);\r\n\r\n    testRegister->getAlternateRegisters()->append(alternateRegister);\r\n\r\n    QSharedPointer<ModeReference> modeRef1(new ModeReference());\r\n    modeRef1->setPriority(0);\r\n    modeRef1->setReference(\"ref\");\r\n\r\n    QSharedPointer<ModeReference> modeRef2(new ModeReference());\r\n    modeRef2->setPriority(0);\r\n    modeRef2->setReference(\"ref1\");\r\n    \r\n    QSharedPointer<ModeReference> altRegisterModeRef(new ModeReference());\r\n    altRegisterModeRef->setPriority(1000);\r\n    altRegisterModeRef->setReference(\"superUnique\");\r\n\r\n    QSharedPointer<AccessPolicy> accessPolicy1(new AccessPolicy());\r\n    QSharedPointer<AccessPolicy> accessPolicy2(new AccessPolicy());\r\n    accessPolicy1->getModeReferences()->append(modeRef1);\r\n    accessPolicy2->getModeReferences()->append(modeRef2);\r\n\r\n    alternateRegister->getAccessPolicies()->append(accessPolicy1);\r\n    alternateRegister->getAccessPolicies()->append(accessPolicy2);\r\n    alternateRegister->getModeReferences()->append(altRegisterModeRef);\r\n\r\n    QSharedPointer<ExpressionParser> parser(new SystemVerilogExpressionParser());\r\n    QSharedPointer<ParameterValidator> parameterValidator(new ParameterValidator(parser,\r\n        QSharedPointer<QList<QSharedPointer<Choice> > >(), Document::Revision::Std22));\r\n    QSharedPointer<EnumeratedValueValidator> enumValidator(new EnumeratedValueValidator(parser));\r\n    QSharedPointer<FieldValidator> fieldValidator(new FieldValidator(parser, enumValidator, parameterValidator));\r\n    RegisterValidator validator(parser, fieldValidator, parameterValidator, Document::Revision::Std22);\r\n\r\n    QSharedPointer<Component> dummyComponent(new Component(VLNV(VLNV::COMPONENT, \"vendor\", \"library\", \"name\", \"version\"), Document::Revision::Std22));\r\n    QSharedPointer<Mode> mode1(new Mode(\"ref\"));\r\n    QSharedPointer<Mode> mode2(new Mode(\"ref1\"));\r\n    QSharedPointer<Mode> mode3(new Mode(\"superUnique\"));\r\n    dummyComponent->getModes()->append(mode1);\r\n    dummyComponent->getModes()->append(mode2);\r\n    dummyComponent->getModes()->append(mode3);\r\n\r\n    validator.componentChange(dummyComponent);\r\n\r\n    QStringList errors;\r\n\r\n    QStringList possibleErrors(QStringList()\r\n        << \"One or more mode references in access policies of alternate register testAlternate within register testRegister contain duplicate priority values.\"\r\n        << \"One or more mode references in access policies of alternate register testAlternate within register testRegister contain duplicate mode reference values.\"\r\n        << \"In register 'test' in test, multiple access policies are not allowed if one of them lacks a mode reference.\"\r\n    );\r\n\r\n    // Test duplicate mode reference priority.\r\n    validator.findErrorsIn(errors, testRegister, \"test\");\r\n    QVERIFY(errors.contains(possibleErrors.first()));\r\n    QVERIFY(validator.hasValidAlternateRegisters(testRegister) == false);\r\n\r\n    // Test duplicate reference.\r\n    errors.clear();\r\n\r\n    modeRef2->setPriority(1);\r\n    modeRef2->setReference(\"ref\");\r\n\r\n    validator.findErrorsIn(errors, testRegister, \"test\");\r\n    QVERIFY(errors.contains(possibleErrors.at(1)));\r\n    QVERIFY(validator.hasValidAlternateRegisters(testRegister) == false);\r\n\r\n    // Test valid mode ref.\r\n    errors.clear();\r\n\r\n    modeRef2->setReference(\"ref1\");\r\n\r\n    validator.findErrorsIn(errors, testRegister, \"test\");\r\n    QVERIFY(std::none_of(possibleErrors.cbegin(), possibleErrors.cend(), [&errors](QString const& str)\r\n        {\r\n            return errors.contains(str);\r\n        }));\r\n\r\n    QVERIFY(validator.hasValidAlternateRegisters(testRegister));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_RegisterValidator::errorIsNotFoundInErrorList()\r\n//-----------------------------------------------------------------------------\r\nbool tst_RegisterValidator::errorIsNotFoundInErrorList(QString const& expectedError, QVector<QString> errorList)\r\n{\r\n    if (!errorList.contains(expectedError))\r\n    {\r\n        qDebug() << \"The following error:\" << Qt::endl << expectedError << Qt::endl << \"was not found in error list:\";\r\n        for (auto& error : errorList)\r\n        {\r\n            qDebug() << error;\r\n        }\r\n        return true;\r\n    }\r\n\r\n    return false;\r\n}\r\n\r\nQTEST_APPLESS_MAIN(tst_RegisterValidator)\r\n\r\n#include \"tst_RegisterValidator.moc\"\r\n"
  },
  {
    "path": "tests/IPXACTmodels/Component/tst_RegisterValidator.pri",
    "content": "# ----------------------------------------------------\r\n# This file is generated by the Qt Visual Studio Tools.\r\n# ------------------------------------------------------\r\n\r\nSOURCES += ./tst_RegisterValidator.cpp \r\n\t"
  },
  {
    "path": "tests/IPXACTmodels/Component/tst_RegisterValidator.pro",
    "content": "#-----------------------------------------------------------------------------\r\n# File: tst_RegisterValidator.pro\r\n#-----------------------------------------------------------------------------\r\n# Project: Kactus 2\r\n# Author: Esko Pekkarinen\r\n# Date: 24.7.2014\r\n#\r\n# Description:\r\n# Qt project file template for running unit tests for a single module.\r\n#-----------------------------------------------------------------------------\r\n\r\nTEMPLATE = app\r\n\r\nTARGET = tst_RegisterValidator\r\n\r\nQT += core gui xml testlib\r\n\r\nCONFIG += c++11 testcase console\r\n\r\nlinux-g++ | linux-g++-64 | linux-g++-32 {\r\n LIBS += -L../../../executable \\\r\n     -lIPXACTmodels -lKactusAPI\r\n}\r\n\r\nwin64 | win32 {\r\n LIBS += -L../../../executable \\\r\n     -lIPXACTmodelsd -lKactusAPId\r\n}\r\n\r\nINCLUDEPATH += $$DESTDIR\r\nINCLUDEPATH += ../../../\r\n\r\nDEPENDPATH += .\r\nDEPENDPATH += ../../../\r\n\r\nOBJECTS_DIR += $$DESTDIR\r\n\r\nMOC_DIR += ./generatedFiles\r\nUI_DIR += ./generatedFiles\r\nRCC_DIR += ./generatedFiles\r\ninclude(tst_RegisterValidator.pri)\r\n"
  },
  {
    "path": "tests/IPXACTmodels/Component/tst_RegisterWriter.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: tst_RegisterWriter.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 28.09.2015\r\n//\r\n// Description:\r\n// Unit test for class RegisterWriter.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include <IPXACTmodels/Component/RegisterWriter.h>\r\n#include <IPXACTmodels/Component/Register.h>\r\n#include <IPXACTmodels/Component/RegisterFile.h>\r\n#include <IPXACTmodels/Component/AlternateRegister.h>\r\n\r\n#include <IPXACTmodels/Component/Field.h>\r\n#include <IPXACTmodels/Component/MemoryArray.h>\r\n#include <IPXACTmodels/common/Parameter.h>\r\n\r\n#include <IPXACTmodels/common/GenericVendorExtension.h>\r\n\r\n#include <QtTest>\r\n\r\nclass tst_RegisterWriter : public QObject\r\n{\r\n    Q_OBJECT\r\n\r\npublic:\r\n    tst_RegisterWriter();\r\n\r\nprivate slots:\r\n\r\n    void writeSimpleRegister();\r\n    void writeRegisterIsPresent();\r\n    void writeRegisterDimension();\r\n    void writeRegisterTypeIdentifier();\r\n    void writeRegisterVolatile();\r\n    void writeRegisterAccess();\r\n    void writeRegisterFields();\r\n    void writeRegisterAlternateRegisters();\r\n\r\n    void writeRegisterAlternateRegisters2022();\r\n\r\n    void writeRegisterMemoryArray2022();\r\n    void writeRegisterDefinitionReference2022();\r\n    void writeRegisterAccessPolicies2022();\r\n\r\n    void writeRegisterParameters();\r\n    void writeRegisterVendorExtensions();\r\n\r\n    void writeSimpleRegisterFile();\r\n    void writeRegisterFileIsPresent();\r\n    void writeRegisterFileDimension();\r\n    void writeRegisterFileTypeIdentifier();\r\n    void writeRegisterFileRegisterData();\r\n\r\n    void writeRegisterFileDefinitionReference2022();\r\n    void writeRegisterFileMemoryArray2022();\r\n    void writeRegisterFileAccessPolicies2022();\r\n\r\n    void writeRegisterFileParameters();\r\n    void writeRegisterFileVendorExtensions();\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_RegisterWriter::tst_RegisterWriter()\r\n//-----------------------------------------------------------------------------\r\ntst_RegisterWriter::tst_RegisterWriter()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_RegisterWriter::writeSimpleRegister()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_RegisterWriter::writeSimpleRegister()\r\n{\r\n    QString output;\r\n    QXmlStreamWriter xmlStreamWriter(&output);\r\n\r\n    QSharedPointer<Field> simpleField(new Field(\"simpleField\"));\r\n    simpleField->setBitOffset(\"fieldOffset\");\r\n    simpleField->setBitWidth(\"fieldWidth\");\r\n\r\n    QSharedPointer<Register> testRegister (new Register(\"testRegister\", \"offset\", \"10\"));\r\n    testRegister->setDisplayName(\"displayed\");\r\n    testRegister->setDescription(\"described\");\r\n    testRegister->getFields()->append(simpleField);\r\n\r\n    QString expectedOutput(\r\n        \"<ipxact:register>\"\r\n            \"<ipxact:name>testRegister</ipxact:name>\"\r\n            \"<ipxact:displayName>displayed</ipxact:displayName>\"\r\n            \"<ipxact:description>described</ipxact:description>\"\r\n            \"<ipxact:addressOffset>offset</ipxact:addressOffset>\"\r\n            \"<ipxact:size>10</ipxact:size>\"\r\n            \"<ipxact:field>\"\r\n                \"<ipxact:name>simpleField</ipxact:name>\"\r\n                \"<ipxact:bitOffset>fieldOffset</ipxact:bitOffset>\"\r\n                \"<ipxact:bitWidth>fieldWidth</ipxact:bitWidth>\"\r\n            \"</ipxact:field>\"\r\n        \"</ipxact:register>\"\r\n        );\r\n\r\n    RegisterWriter::writeRegisterData(xmlStreamWriter, testRegister, Document::Revision::Std14);\r\n    QCOMPARE(output, expectedOutput);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_RegisterWriter::writeRegisterIsPresent()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_RegisterWriter::writeRegisterIsPresent()\r\n{\r\n    QString output;\r\n    QXmlStreamWriter xmlStreamWriter(&output);\r\n\r\n    QSharedPointer<Field> simpleField(new Field(\"simpleField\"));\r\n    simpleField->setBitOffset(\"fieldOffset\");\r\n    simpleField->setBitWidth(\"fieldWidth\");\r\n\r\n    QSharedPointer<Register> testRegister (new Register(\"testRegister\", \"offset\", \"10\"));\r\n    testRegister->setIsPresent(\"4-3\");\r\n    testRegister->getFields()->append(simpleField);\r\n\r\n    QString expectedOutput(\r\n        \"<ipxact:register>\"\r\n            \"<ipxact:name>testRegister</ipxact:name>\"\r\n            \"<ipxact:isPresent>4-3</ipxact:isPresent>\"\r\n            \"<ipxact:addressOffset>offset</ipxact:addressOffset>\"\r\n            \"<ipxact:size>10</ipxact:size>\"\r\n            \"<ipxact:field>\"\r\n                \"<ipxact:name>simpleField</ipxact:name>\"\r\n                \"<ipxact:bitOffset>fieldOffset</ipxact:bitOffset>\"\r\n                \"<ipxact:bitWidth>fieldWidth</ipxact:bitWidth>\"\r\n            \"</ipxact:field>\"\r\n        \"</ipxact:register>\"\r\n        );\r\n\r\n    RegisterWriter::writeRegisterData(xmlStreamWriter, testRegister, Document::Revision::Std14);\r\n    QCOMPARE(output, expectedOutput);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_RegisterWriter::writeRegisterDimension()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_RegisterWriter::writeRegisterDimension()\r\n{\r\n    QString output;\r\n    QXmlStreamWriter xmlStreamWriter(&output);\r\n\r\n    QSharedPointer<Field> simpleField(new Field(\"simpleField\"));\r\n    simpleField->setBitOffset(\"fieldOffset\");\r\n    simpleField->setBitWidth(\"fieldWidth\");\r\n\r\n    QSharedPointer<Register> testRegister (new Register(\"testRegister\", \"offset\", \"10\"));\r\n    testRegister->setDimension(\"16\");\r\n    testRegister->getFields()->append(simpleField);\r\n\r\n    QString expectedOutput(\r\n        \"<ipxact:register>\"\r\n            \"<ipxact:name>testRegister</ipxact:name>\"\r\n            \"<ipxact:dim>16</ipxact:dim>\"\r\n            \"<ipxact:addressOffset>offset</ipxact:addressOffset>\"\r\n            \"<ipxact:size>10</ipxact:size>\"\r\n            \"<ipxact:field>\"\r\n                \"<ipxact:name>simpleField</ipxact:name>\"\r\n                \"<ipxact:bitOffset>fieldOffset</ipxact:bitOffset>\"\r\n                \"<ipxact:bitWidth>fieldWidth</ipxact:bitWidth>\"\r\n            \"</ipxact:field>\"\r\n        \"</ipxact:register>\"\r\n        );\r\n\r\n    RegisterWriter::writeRegisterData(xmlStreamWriter, testRegister, Document::Revision::Std14);\r\n    QCOMPARE(output, expectedOutput);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_RegisterWriter::writeRegisterTypeIdentifier()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_RegisterWriter::writeRegisterTypeIdentifier()\r\n{\r\n    QString output;\r\n    QXmlStreamWriter xmlStreamWriter(&output);\r\n\r\n    QSharedPointer<Field> simpleField(new Field(\"simpleField\"));\r\n    simpleField->setBitOffset(\"fieldOffset\");\r\n    simpleField->setBitWidth(\"fieldWidth\");\r\n\r\n    QSharedPointer<Register> testRegister (new Register(\"testRegister\", \"offset\", \"10\"));\r\n    testRegister->setTypeIdentifier(\"identifier\");\r\n    testRegister->getFields()->append(simpleField);\r\n\r\n    QString expectedOutput(\r\n        \"<ipxact:register>\"\r\n            \"<ipxact:name>testRegister</ipxact:name>\"\r\n            \"<ipxact:addressOffset>offset</ipxact:addressOffset>\"\r\n            \"<ipxact:typeIdentifier>identifier</ipxact:typeIdentifier>\"\r\n            \"<ipxact:size>10</ipxact:size>\"\r\n            \"<ipxact:field>\"\r\n                \"<ipxact:name>simpleField</ipxact:name>\"\r\n                \"<ipxact:bitOffset>fieldOffset</ipxact:bitOffset>\"\r\n                \"<ipxact:bitWidth>fieldWidth</ipxact:bitWidth>\"\r\n            \"</ipxact:field>\"\r\n        \"</ipxact:register>\"\r\n        );\r\n\r\n    RegisterWriter::writeRegisterData(xmlStreamWriter, testRegister, Document::Revision::Std14);\r\n    QCOMPARE(output, expectedOutput);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_RegisterWriter::writeRegisterVolatile()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_RegisterWriter::writeRegisterVolatile()\r\n{\r\n    QString output;\r\n    QXmlStreamWriter xmlStreamWriter(&output);\r\n\r\n    QSharedPointer<Field> simpleField(new Field(\"simpleField\"));\r\n    simpleField->setBitOffset(\"fieldOffset\");\r\n    simpleField->setBitWidth(\"fieldWidth\");\r\n\r\n    QSharedPointer<Register> testRegister (new Register(\"testRegister\", \"offset\", \"10\"));\r\n    testRegister->setVolatile(true);\r\n    testRegister->getFields()->append(simpleField);\r\n\r\n    QString expectedOutput(\r\n        \"<ipxact:register>\"\r\n            \"<ipxact:name>testRegister</ipxact:name>\"\r\n            \"<ipxact:addressOffset>offset</ipxact:addressOffset>\"\r\n            \"<ipxact:size>10</ipxact:size>\"\r\n            \"<ipxact:volatile>true</ipxact:volatile>\"\r\n            \"<ipxact:field>\"\r\n                \"<ipxact:name>simpleField</ipxact:name>\"\r\n                \"<ipxact:bitOffset>fieldOffset</ipxact:bitOffset>\"\r\n                \"<ipxact:bitWidth>fieldWidth</ipxact:bitWidth>\"\r\n            \"</ipxact:field>\"\r\n        \"</ipxact:register>\"\r\n        );\r\n\r\n    RegisterWriter::writeRegisterData(xmlStreamWriter, testRegister, Document::Revision::Std14);\r\n    QCOMPARE(output, expectedOutput);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_RegisterWriter::writeRegisterAccess()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_RegisterWriter::writeRegisterAccess()\r\n{\r\n    QString output;\r\n    QXmlStreamWriter xmlStreamWriter(&output);\r\n\r\n    QSharedPointer<Field> simpleField(new Field(\"simpleField\"));\r\n    simpleField->setBitOffset(\"fieldOffset\");\r\n    simpleField->setBitWidth(\"fieldWidth\");\r\n\r\n    QSharedPointer<Register> testRegister (new Register(\"testRegister\", \"offset\", \"10\"));\r\n    testRegister->getFields()->append(simpleField);\r\n    testRegister->setAccess(AccessTypes::WRITEONCE);\r\n\r\n    QString expectedOutput(\r\n        \"<ipxact:register>\"\r\n            \"<ipxact:name>testRegister</ipxact:name>\"\r\n            \"<ipxact:addressOffset>offset</ipxact:addressOffset>\"\r\n            \"<ipxact:size>10</ipxact:size>\"\r\n            \"<ipxact:access>writeOnce</ipxact:access>\"\r\n            \"<ipxact:field>\"\r\n                \"<ipxact:name>simpleField</ipxact:name>\"\r\n                \"<ipxact:bitOffset>fieldOffset</ipxact:bitOffset>\"\r\n                \"<ipxact:bitWidth>fieldWidth</ipxact:bitWidth>\"\r\n            \"</ipxact:field>\"\r\n        \"</ipxact:register>\"\r\n        );\r\n\r\n    RegisterWriter::writeRegisterData(xmlStreamWriter, testRegister, Document::Revision::Std14);\r\n    QCOMPARE(output, expectedOutput);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_RegisterWriter::writeRegisterFields()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_RegisterWriter::writeRegisterFields()\r\n{\r\n    QString output;\r\n    QXmlStreamWriter xmlStreamWriter(&output);\r\n\r\n    QSharedPointer<Field> simpleField(new Field(\"simpleField\"));\r\n    simpleField->setBitOffset(\"fieldOffset\");\r\n    simpleField->setBitWidth(\"fieldWidth\");\r\n\r\n    QSharedPointer<Field> otherField(new Field(\"unsimplified\"));\r\n    otherField->setBitOffset(\"OtherOff\");\r\n    otherField->setBitWidth(\"otherWidth\");\r\n\r\n    QSharedPointer<Register> testRegister (new Register(\"testRegister\", \"offset\", \"10\"));\r\n    testRegister->getFields()->append(simpleField);\r\n    testRegister->getFields()->append(otherField);\r\n\r\n    QString expectedOutput(\r\n        \"<ipxact:register>\"\r\n            \"<ipxact:name>testRegister</ipxact:name>\"\r\n            \"<ipxact:addressOffset>offset</ipxact:addressOffset>\"\r\n            \"<ipxact:size>10</ipxact:size>\"\r\n            \"<ipxact:field>\"\r\n                \"<ipxact:name>simpleField</ipxact:name>\"\r\n                \"<ipxact:bitOffset>fieldOffset</ipxact:bitOffset>\"\r\n                \"<ipxact:bitWidth>fieldWidth</ipxact:bitWidth>\"\r\n            \"</ipxact:field>\"\r\n            \"<ipxact:field>\"\r\n                \"<ipxact:name>unsimplified</ipxact:name>\"\r\n                \"<ipxact:bitOffset>OtherOff</ipxact:bitOffset>\"\r\n                \"<ipxact:bitWidth>otherWidth</ipxact:bitWidth>\"\r\n            \"</ipxact:field>\"\r\n        \"</ipxact:register>\"\r\n        );\r\n\r\n    RegisterWriter::writeRegisterData(xmlStreamWriter, testRegister, Document::Revision::Std14);\r\n    QCOMPARE(output, expectedOutput);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_RegisterWriter::writeAlternateRegister()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_RegisterWriter::writeRegisterAlternateRegisters()\r\n{\r\n    QString output;\r\n    QXmlStreamWriter xmlStreamWriter(&output);\r\n\r\n    QSharedPointer<Parameter> testParameter(new Parameter());\r\n    testParameter->setValueId(\"testID\");\r\n    testParameter->setName(\"testParameter\");\r\n    testParameter->setValue(\"1\");\r\n\r\n    QDomDocument document;\r\n    QDomElement extensionNode = document.createElement(\"testExtension\");\r\n    extensionNode.setAttribute(\"testExtensionAttribute\", \"extension\");\r\n    extensionNode.appendChild(document.createTextNode(\"testValue\"));\r\n    QSharedPointer<GenericVendorExtension> testExtension(new GenericVendorExtension(extensionNode));\r\n\r\n    QSharedPointer<Field> alternateField(new Field(\"Hades\"));\r\n    alternateField->setBitOffset(\"alternativeOffset\");\r\n    alternateField->setBitWidth(\"alternativeWidth\");\r\n\r\n    QSharedPointer<AlternateRegister> alternateRegister (new AlternateRegister(\"alteredBeast\", \"wolf\"));\r\n    alternateRegister->setDisplayName(\"alteredDisplay\");\r\n    alternateRegister->setDescription(\"alteredDescription\");\r\n    alternateRegister->setIsPresent(\"presence\");\r\n    alternateRegister->setTypeIdentifier(\"Volgarr\");\r\n    alternateRegister->setVolatile(false);\r\n    alternateRegister->setAccess(AccessTypes::READ_WRITE);\r\n    alternateRegister->getFields()->append(alternateField);\r\n\r\n    alternateRegister->getParameters()->append(testParameter);\r\n    alternateRegister->getVendorExtensions()->append(testExtension);\r\n\r\n    QSharedPointer<Field> simpleField(new Field(\"simpleField\"));\r\n    simpleField->setBitOffset(\"fieldOffset\");\r\n    simpleField->setBitWidth(\"fieldWidth\");\r\n\r\n    QSharedPointer<Register> testRegister (new Register(\"testRegister\", \"offset\", \"10\"));\r\n    testRegister->getFields()->append(simpleField);\r\n    testRegister->getAlternateRegisters()->append(alternateRegister);\r\n\r\n    QString expectedOutput(\r\n        \"<ipxact:register>\"\r\n            \"<ipxact:name>testRegister</ipxact:name>\"\r\n            \"<ipxact:addressOffset>offset</ipxact:addressOffset>\"\r\n            \"<ipxact:size>10</ipxact:size>\"\r\n            \"<ipxact:field>\"\r\n                \"<ipxact:name>simpleField</ipxact:name>\"\r\n                \"<ipxact:bitOffset>fieldOffset</ipxact:bitOffset>\"\r\n                \"<ipxact:bitWidth>fieldWidth</ipxact:bitWidth>\"\r\n            \"</ipxact:field>\"\r\n            \"<ipxact:alternateRegisters>\"\r\n                \"<ipxact:alternateRegister>\"\r\n                    \"<ipxact:name>alteredBeast</ipxact:name>\"\r\n                    \"<ipxact:displayName>alteredDisplay</ipxact:displayName>\"\r\n                    \"<ipxact:description>alteredDescription</ipxact:description>\"\r\n                    \"<ipxact:isPresent>presence</ipxact:isPresent>\"\r\n                    \"<ipxact:alternateGroups>\"\r\n                        \"<ipxact:alternateGroup>wolf</ipxact:alternateGroup>\"\r\n                    \"</ipxact:alternateGroups>\"\r\n                    \"<ipxact:typeIdentifier>Volgarr</ipxact:typeIdentifier>\"\r\n                    \"<ipxact:volatile>false</ipxact:volatile>\"\r\n                    \"<ipxact:access>read-write</ipxact:access>\"\r\n                    \"<ipxact:field>\"\r\n                        \"<ipxact:name>Hades</ipxact:name>\"\r\n                        \"<ipxact:bitOffset>alternativeOffset</ipxact:bitOffset>\"\r\n                        \"<ipxact:bitWidth>alternativeWidth</ipxact:bitWidth>\"\r\n                    \"</ipxact:field>\"\r\n                    \"<ipxact:parameters>\"\r\n                        \"<ipxact:parameter parameterId=\\\"testID\\\">\"\r\n                            \"<ipxact:name>testParameter</ipxact:name>\"\r\n                            \"<ipxact:value>1</ipxact:value>\"\r\n                        \"</ipxact:parameter>\"\r\n                    \"</ipxact:parameters>\"\r\n                    \"<ipxact:vendorExtensions>\"\r\n                        \"<testExtension testExtensionAttribute=\\\"extension\\\">testValue</testExtension>\"\r\n                    \"</ipxact:vendorExtensions>\"\r\n                \"</ipxact:alternateRegister>\"\r\n            \"</ipxact:alternateRegisters>\"\r\n        \"</ipxact:register>\"\r\n        );\r\n\r\n    RegisterWriter::writeRegisterData(xmlStreamWriter, testRegister, Document::Revision::Std14);\r\n    QCOMPARE(output, expectedOutput);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_RegisterWriter::writeRegisterAlternateRegisters2022()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_RegisterWriter::writeRegisterAlternateRegisters2022()\r\n{\r\n    QString output;\r\n    QXmlStreamWriter xmlStreamWriter(&output);\r\n    \r\n    QSharedPointer<ModeReference> modeRef1(new ModeReference());\r\n    modeRef1->setReference(\"testMode\");\r\n    modeRef1->setPriority(0);\r\n\r\n    QSharedPointer<ModeReference> modeRef2(new ModeReference());\r\n    modeRef2->setReference(\"testMode2\");\r\n    modeRef2->setPriority(1);\r\n\r\n    QSharedPointer<ModeReference> modeRef3(new ModeReference(*modeRef1));\r\n    modeRef3->setReference(\"testMode3\");\r\n    modeRef3->setPriority(2);\r\n\r\n\r\n    QSharedPointer<AccessPolicy> accessPolicy1(new AccessPolicy());\r\n    accessPolicy1->getModeReferences()->append(modeRef1);\r\n    accessPolicy1->setAccess(AccessTypes::READ_ONLY);\r\n\r\n    QSharedPointer<AccessPolicy> accessPolicy2(new AccessPolicy());\r\n    accessPolicy2->getModeReferences()->append(modeRef2);\r\n    accessPolicy2->getModeReferences()->append(modeRef3);\r\n\r\n    QSharedPointer<Parameter> testParameter(new Parameter());\r\n    testParameter->setValueId(\"testID\");\r\n    testParameter->setName(\"testParameter\");\r\n    testParameter->setValue(\"1\");\r\n\r\n    QDomDocument document;\r\n    QDomElement extensionNode = document.createElement(\"testExtension\");\r\n    extensionNode.setAttribute(\"testExtensionAttribute\", \"extension\");\r\n    extensionNode.appendChild(document.createTextNode(\"testValue\"));\r\n    QSharedPointer<GenericVendorExtension> testExtension(new GenericVendorExtension(extensionNode));\r\n\r\n    QSharedPointer<Field> altField(new Field(\"Hades\"));\r\n    altField->setBitOffset(\"alternativeOffset\");\r\n    altField->setBitWidth(\"alternativeWidth\");\r\n\r\n    QSharedPointer<AlternateRegister> testAlternateRegister(new AlternateRegister(\"alteredBeast\"));\r\n    testAlternateRegister->setDisplayName(\"alteredDisplay\");\r\n    testAlternateRegister->setShortDescription(\"testShortDescription\");\r\n    testAlternateRegister->setDescription(\"alteredDescription\");\r\n    \r\n    testAlternateRegister->getModeReferences()->append(modeRef1);\r\n    testAlternateRegister->getModeReferences()->append(modeRef2);\r\n    \r\n    testAlternateRegister->getAccessPolicies()->append(accessPolicy1);\r\n    testAlternateRegister->getAccessPolicies()->append(accessPolicy2);\r\n\r\n    testAlternateRegister->setVolatile(false);\r\n    testAlternateRegister->setTypeIdentifier(\"Volgarr\");\r\n    testAlternateRegister->getParameters()->append(testParameter);\r\n    testAlternateRegister->getVendorExtensions()->append(testExtension);\r\n\r\n    testAlternateRegister->getFields()->append(altField);\r\n\r\n    QSharedPointer<Field> simpleField(new Field(\"simpleField\"));\r\n    simpleField->setBitOffset(\"fieldOffset\");\r\n    simpleField->setBitWidth(\"fieldWidth\");\r\n\r\n    QSharedPointer<Register> testRegister (new Register(\"testRegister\", \"offset\", \"10\"));\r\n    testRegister->getFields()->append(simpleField);\r\n    testRegister->getAlternateRegisters()->append(testAlternateRegister);\r\n\r\n    QString expectedOutput(\r\n        \"<ipxact:register>\"\r\n            \"<ipxact:name>testRegister</ipxact:name>\"\r\n            \"<ipxact:addressOffset>offset</ipxact:addressOffset>\"\r\n            \"<ipxact:size>10</ipxact:size>\"\r\n            \"<ipxact:field>\"\r\n                \"<ipxact:name>simpleField</ipxact:name>\"\r\n                \"<ipxact:bitOffset>fieldOffset</ipxact:bitOffset>\"\r\n                \"<ipxact:bitWidth>fieldWidth</ipxact:bitWidth>\"\r\n            \"</ipxact:field>\"\r\n            \"<ipxact:alternateRegisters>\"\r\n                \"<ipxact:alternateRegister>\"\r\n                    \"<ipxact:name>alteredBeast</ipxact:name>\"\r\n                    \"<ipxact:displayName>alteredDisplay</ipxact:displayName>\"\r\n                    \"<ipxact:shortDescription>testShortDescription</ipxact:shortDescription>\"\r\n                    \"<ipxact:description>alteredDescription</ipxact:description>\"\r\n                    \"<ipxact:modeRef priority=\\\"0\\\">testMode</ipxact:modeRef>\"\r\n                    \"<ipxact:modeRef priority=\\\"1\\\">testMode2</ipxact:modeRef>\"\r\n                    \"<ipxact:typeIdentifier>Volgarr</ipxact:typeIdentifier>\"\r\n                    \"<ipxact:volatile>false</ipxact:volatile>\"\r\n                    \"<ipxact:accessPolicies>\"\r\n                        \"<ipxact:accessPolicy>\"\r\n                            \"<ipxact:modeRef priority=\\\"0\\\">testMode</ipxact:modeRef>\"\r\n                            \"<ipxact:access>read-only</ipxact:access>\"\r\n                        \"</ipxact:accessPolicy>\"\r\n                        \"<ipxact:accessPolicy>\"\r\n                            \"<ipxact:modeRef priority=\\\"1\\\">testMode2</ipxact:modeRef>\"\r\n                            \"<ipxact:modeRef priority=\\\"2\\\">testMode3</ipxact:modeRef>\"\r\n                        \"</ipxact:accessPolicy>\"\r\n                    \"</ipxact:accessPolicies>\"\r\n                    \"<ipxact:field>\"\r\n                        \"<ipxact:name>Hades</ipxact:name>\"\r\n                        \"<ipxact:bitOffset>alternativeOffset</ipxact:bitOffset>\"\r\n                        \"<ipxact:bitWidth>alternativeWidth</ipxact:bitWidth>\"\r\n                    \"</ipxact:field>\"\r\n                    \"<ipxact:parameters>\"\r\n                        \"<ipxact:parameter parameterId=\\\"testID\\\">\"\r\n                            \"<ipxact:name>testParameter</ipxact:name>\"\r\n                            \"<ipxact:value>1</ipxact:value>\"\r\n                        \"</ipxact:parameter>\"\r\n                    \"</ipxact:parameters>\"\r\n                    \"<ipxact:vendorExtensions>\"\r\n                        \"<testExtension testExtensionAttribute=\\\"extension\\\">testValue</testExtension>\"\r\n                    \"</ipxact:vendorExtensions>\"\r\n                \"</ipxact:alternateRegister>\"\r\n            \"</ipxact:alternateRegisters>\"\r\n        \"</ipxact:register>\"\r\n        );\r\n\r\n    RegisterWriter::writeRegisterData(xmlStreamWriter, testRegister, Document::Revision::Std22);\r\n    QCOMPARE(output, expectedOutput);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_RegisterWriter::writeRegisterMemoryArray2022()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_RegisterWriter::writeRegisterMemoryArray2022()\r\n{\r\n    QString output;\r\n    QXmlStreamWriter xmlStreamWriter(&output);\r\n\r\n    QSharedPointer<MemoryArray::Dimension> dim1(new MemoryArray::Dimension());\r\n    dim1->indexVar_ = \"testDim\";\r\n    dim1->value_ = \"1+1\";\r\n    \r\n    QSharedPointer<MemoryArray::Dimension> dim2(new MemoryArray::Dimension());\r\n    dim2->value_ = \"4\";\r\n\r\n    QSharedPointer<MemoryArray> memArray(new MemoryArray());\r\n    memArray->setStride(\"4\");\r\n    memArray->getDimensions()->append(dim1);\r\n    memArray->getDimensions()->append(dim2);\r\n\r\n    QSharedPointer<Field> simpleField(new Field(\"simpleField\"));\r\n    simpleField->setBitOffset(\"fieldOffset\");\r\n    simpleField->setBitWidth(\"fieldWidth\");\r\n\r\n    QSharedPointer<Register> testRegister(new Register(\"testRegister\", \"offset\", \"10\"));\r\n    testRegister->setDisplayName(\"displayed\");\r\n    testRegister->setShortDescription(\"testShortDesc\");\r\n    testRegister->setDescription(\"described\");\r\n    testRegister->getFields()->append(simpleField);\r\n    testRegister->setMemoryArray(memArray);\r\n\r\n    QString expectedOutput(\r\n        \"<ipxact:register>\"\r\n            \"<ipxact:name>testRegister</ipxact:name>\"\r\n            \"<ipxact:displayName>displayed</ipxact:displayName>\"\r\n            \"<ipxact:shortDescription>testShortDesc</ipxact:shortDescription>\"\r\n            \"<ipxact:description>described</ipxact:description>\"\r\n            \"<ipxact:array>\"\r\n                \"<ipxact:dim indexVar=\\\"testDim\\\">1+1</ipxact:dim>\"\r\n                \"<ipxact:dim>4</ipxact:dim>\"\r\n                \"<ipxact:stride>4</ipxact:stride>\"\r\n            \"</ipxact:array>\"\r\n            \"<ipxact:addressOffset>offset</ipxact:addressOffset>\"\r\n            \"<ipxact:size>10</ipxact:size>\"\r\n            \"<ipxact:field>\"\r\n                \"<ipxact:name>simpleField</ipxact:name>\"\r\n                \"<ipxact:bitOffset>fieldOffset</ipxact:bitOffset>\"\r\n                \"<ipxact:bitWidth>fieldWidth</ipxact:bitWidth>\"\r\n            \"</ipxact:field>\"\r\n        \"</ipxact:register>\"\r\n    );\r\n\r\n    RegisterWriter::writeRegisterData(xmlStreamWriter, testRegister, Document::Revision::Std22);\r\n    QCOMPARE(output, expectedOutput);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_RegisterWriter::writeRegisterDefinitionReference2022()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_RegisterWriter::writeRegisterDefinitionReference2022()\r\n{\r\n    QString output;\r\n    QXmlStreamWriter xmlStreamWriter(&output);\r\n\r\n    QSharedPointer<Register> testRegister(new Register(\"testRegister\", \"offset\"));\r\n    testRegister->setRegisterDefinitionReference(\"testRegisterDef\");\r\n    testRegister->setTypeDefinitionsReference(\"testTypeDefinitions\");\r\n\r\n    QString expectedOutput(\r\n        \"<ipxact:register>\"\r\n            \"<ipxact:name>testRegister</ipxact:name>\"\r\n            \"<ipxact:addressOffset>offset</ipxact:addressOffset>\"\r\n            \"<ipxact:registerDefinitionRef typeDefinitions=\\\"testTypeDefinitions\\\">testRegisterDef</ipxact:registerDefinitionRef>\"\r\n        \"</ipxact:register>\"\r\n    );\r\n\r\n    RegisterWriter::writeRegisterData(xmlStreamWriter, testRegister, Document::Revision::Std22);\r\n    QCOMPARE(output, expectedOutput);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_RegisterWriter::writeRegisterAccessPolicies2022()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_RegisterWriter::writeRegisterAccessPolicies2022()\r\n{\r\n    QString output;\r\n    QXmlStreamWriter xmlStreamWriter(&output);\r\n\r\n    QSharedPointer<ModeReference> modeRef1(new ModeReference());\r\n    modeRef1->setReference(\"testMode\");\r\n    modeRef1->setPriority(0);\r\n\r\n    QSharedPointer<AccessPolicy> accessPolicy1(new AccessPolicy());\r\n    accessPolicy1->getModeReferences()->append(modeRef1);\r\n    accessPolicy1->setAccess(AccessTypes::READ_ONLY);\r\n\r\n\r\n    QSharedPointer<ModeReference> modeRef2(new ModeReference());\r\n    modeRef2->setReference(\"testMode2\");\r\n    modeRef2->setPriority(1);\r\n\r\n    QSharedPointer<ModeReference> modeRef3(new ModeReference(*modeRef1));\r\n    modeRef3->setReference(\"testMode3\");\r\n    modeRef3->setPriority(2);\r\n\r\n    QSharedPointer<AccessPolicy> accessPolicy2(new AccessPolicy());\r\n    accessPolicy2->getModeReferences()->append(modeRef2);\r\n    accessPolicy2->getModeReferences()->append(modeRef3);\r\n\r\n    QSharedPointer<Field> simpleField(new Field(\"simpleField\"));\r\n    simpleField->setBitOffset(\"fieldOffset\");\r\n    simpleField->setBitWidth(\"fieldWidth\");\r\n\r\n    QSharedPointer<Register> testRegister(new Register(\"testRegister\", \"offset\", \"10\"));\r\n    testRegister->getFields()->append(simpleField);\r\n    testRegister->getAccessPolicies()->append(accessPolicy1);\r\n    testRegister->getAccessPolicies()->append(accessPolicy2);\r\n\r\n    QString expectedOutput(\r\n        \"<ipxact:register>\"\r\n            \"<ipxact:name>testRegister</ipxact:name>\"\r\n            \"<ipxact:addressOffset>offset</ipxact:addressOffset>\"\r\n            \"<ipxact:size>10</ipxact:size>\"\r\n            \"<ipxact:accessPolicies>\"\r\n                \"<ipxact:accessPolicy>\"\r\n                    \"<ipxact:modeRef priority=\\\"0\\\">testMode</ipxact:modeRef>\"\r\n                    \"<ipxact:access>read-only</ipxact:access>\"\r\n                \"</ipxact:accessPolicy>\"\r\n                \"<ipxact:accessPolicy>\"\r\n                    \"<ipxact:modeRef priority=\\\"1\\\">testMode2</ipxact:modeRef>\"\r\n                    \"<ipxact:modeRef priority=\\\"2\\\">testMode3</ipxact:modeRef>\"\r\n                \"</ipxact:accessPolicy>\"\r\n            \"</ipxact:accessPolicies>\"\r\n            \"<ipxact:field>\"\r\n                \"<ipxact:name>simpleField</ipxact:name>\"\r\n                \"<ipxact:bitOffset>fieldOffset</ipxact:bitOffset>\"\r\n                \"<ipxact:bitWidth>fieldWidth</ipxact:bitWidth>\"\r\n            \"</ipxact:field>\"\r\n        \"</ipxact:register>\"\r\n    );\r\n\r\n    RegisterWriter::writeRegisterData(xmlStreamWriter, testRegister, Document::Revision::Std22);\r\n    QCOMPARE(output, expectedOutput);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_RegisterWriter::writeRegisterParameters()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_RegisterWriter::writeRegisterParameters()\r\n{\r\n    QString output;\r\n    QXmlStreamWriter xmlStreamWriter(&output);\r\n\r\n    QSharedPointer<Field> simpleField(new Field(\"simpleField\"));\r\n    simpleField->setBitOffset(\"fieldOffset\");\r\n    simpleField->setBitWidth(\"fieldWidth\");\r\n\r\n    QSharedPointer<Parameter> testParameter(new Parameter());\r\n    testParameter->setValueId(\"testID\");\r\n    testParameter->setName(\"testParameter\");\r\n    testParameter->setValue(\"1\");\r\n\r\n    QSharedPointer<Register> testRegister (new Register(\"testRegister\", \"offset\", \"10\"));\r\n    testRegister->getFields()->append(simpleField);\r\n    testRegister->getParameters()->append(testParameter);\r\n\r\n    QString expectedOutput(\r\n        \"<ipxact:register>\"\r\n            \"<ipxact:name>testRegister</ipxact:name>\"\r\n            \"<ipxact:addressOffset>offset</ipxact:addressOffset>\"\r\n            \"<ipxact:size>10</ipxact:size>\"\r\n            \"<ipxact:field>\"\r\n                \"<ipxact:name>simpleField</ipxact:name>\"\r\n                \"<ipxact:bitOffset>fieldOffset</ipxact:bitOffset>\"\r\n                \"<ipxact:bitWidth>fieldWidth</ipxact:bitWidth>\"\r\n            \"</ipxact:field>\"\r\n            \"<ipxact:parameters>\"\r\n                \"<ipxact:parameter parameterId=\\\"testID\\\">\"\r\n                    \"<ipxact:name>testParameter</ipxact:name>\"\r\n                    \"<ipxact:value>1</ipxact:value>\"\r\n                \"</ipxact:parameter>\"\r\n            \"</ipxact:parameters>\"\r\n        \"</ipxact:register>\"\r\n        );\r\n\r\n    RegisterWriter::writeRegisterData(xmlStreamWriter, testRegister, Document::Revision::Std14);\r\n    QCOMPARE(output, expectedOutput);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_RegisterWriter::writeRegisterVendorExtensions()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_RegisterWriter::writeRegisterVendorExtensions()\r\n{\r\n    QString output;\r\n    QXmlStreamWriter xmlStreamWriter(&output);\r\n\r\n    QSharedPointer<Field> simpleField(new Field(\"simpleField\"));\r\n    simpleField->setBitOffset(\"fieldOffset\");\r\n    simpleField->setBitWidth(\"fieldWidth\");\r\n\r\n    QDomDocument document;\r\n    QDomElement extensionNode = document.createElement(\"testExtension\");\r\n    extensionNode.setAttribute(\"testExtensionAttribute\", \"extension\");\r\n    extensionNode.appendChild(document.createTextNode(\"testValue\"));\r\n\r\n    QSharedPointer<GenericVendorExtension> testExtension(new GenericVendorExtension(extensionNode));\r\n\r\n    QSharedPointer<Register> testRegister (new Register(\"testRegister\", \"offset\", \"10\"));\r\n    testRegister->setDimension(\"16\");\r\n    testRegister->getFields()->append(simpleField);\r\n    testRegister->getVendorExtensions()->append(testExtension);\r\n\r\n    QString expectedOutput(\r\n        \"<ipxact:register>\"\r\n            \"<ipxact:name>testRegister</ipxact:name>\"\r\n            \"<ipxact:dim>16</ipxact:dim>\"\r\n            \"<ipxact:addressOffset>offset</ipxact:addressOffset>\"\r\n            \"<ipxact:size>10</ipxact:size>\"\r\n            \"<ipxact:field>\"\r\n                \"<ipxact:name>simpleField</ipxact:name>\"\r\n                \"<ipxact:bitOffset>fieldOffset</ipxact:bitOffset>\"\r\n                \"<ipxact:bitWidth>fieldWidth</ipxact:bitWidth>\"\r\n            \"</ipxact:field>\"\r\n            \"<ipxact:vendorExtensions>\"\r\n                \"<testExtension testExtensionAttribute=\\\"extension\\\">testValue</testExtension>\"\r\n            \"</ipxact:vendorExtensions>\"\r\n        \"</ipxact:register>\"\r\n        );\r\n\r\n    RegisterWriter::writeRegisterData(xmlStreamWriter, testRegister, Document::Revision::Std14);\r\n    QCOMPARE(output, expectedOutput);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_RegisterWriter::writeSimpleRegisterFile()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_RegisterWriter::writeSimpleRegisterFile()\r\n{\r\n    QString output;\r\n    QXmlStreamWriter xmlStreamWriter(&output);\r\n\r\n    QSharedPointer<RegisterFile> testRegisterFile (new RegisterFile(\"testFile\", \"fileOffset\", \"8\"));\r\n    testRegisterFile->setDisplayName(\"displayed\");\r\n    testRegisterFile->setDescription(\"described\");\r\n\r\n    QString expectedOutput(\r\n        \"<ipxact:registerFile>\"\r\n            \"<ipxact:name>testFile</ipxact:name>\"\r\n            \"<ipxact:displayName>displayed</ipxact:displayName>\"\r\n            \"<ipxact:description>described</ipxact:description>\"\r\n            \"<ipxact:addressOffset>fileOffset</ipxact:addressOffset>\"\r\n            \"<ipxact:range>8</ipxact:range>\"\r\n        \"</ipxact:registerFile>\"\r\n        );\r\n\r\n    RegisterWriter::writeRegisterData(xmlStreamWriter, testRegisterFile, Document::Revision::Std14);\r\n    QCOMPARE(output, expectedOutput);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_RegisterWriter::writeRegisterFileIsPresent()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_RegisterWriter::writeRegisterFileIsPresent()\r\n{\r\n    QString output;\r\n    QXmlStreamWriter xmlStreamWriter(&output);\r\n\r\n    QSharedPointer<RegisterFile> testRegisterFile (new RegisterFile(\"testFile\", \"fileOffset\", \"8\"));\r\n    testRegisterFile->setIsPresent(\"14/2-7\");\r\n\r\n    QString expectedOutput(\r\n        \"<ipxact:registerFile>\"\r\n            \"<ipxact:name>testFile</ipxact:name>\"\r\n            \"<ipxact:isPresent>14/2-7</ipxact:isPresent>\"\r\n            \"<ipxact:addressOffset>fileOffset</ipxact:addressOffset>\"\r\n            \"<ipxact:range>8</ipxact:range>\"\r\n        \"</ipxact:registerFile>\"\r\n        );\r\n\r\n    RegisterWriter::writeRegisterData(xmlStreamWriter, testRegisterFile, Document::Revision::Std14);\r\n    QCOMPARE(output, expectedOutput);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_RegisterWriter::writeRegisterFileDimension()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_RegisterWriter::writeRegisterFileDimension()\r\n{\r\n    QString output;\r\n    QXmlStreamWriter xmlStreamWriter(&output);\r\n\r\n    QSharedPointer<RegisterFile> testRegisterFile (new RegisterFile(\"testFile\", \"fileOffset\", \"8\"));\r\n    testRegisterFile->setDimension(\"DimensionProbability\");\r\n\r\n    QString expectedOutput(\r\n        \"<ipxact:registerFile>\"\r\n            \"<ipxact:name>testFile</ipxact:name>\"\r\n            \"<ipxact:dim>DimensionProbability</ipxact:dim>\"\r\n            \"<ipxact:addressOffset>fileOffset</ipxact:addressOffset>\"\r\n            \"<ipxact:range>8</ipxact:range>\"\r\n        \"</ipxact:registerFile>\"\r\n        );\r\n\r\n    RegisterWriter::writeRegisterData(xmlStreamWriter, testRegisterFile, Document::Revision::Std14);\r\n    QCOMPARE(output, expectedOutput);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_RegisterWriter::writeRegisterFileTypeIdentifier()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_RegisterWriter::writeRegisterFileTypeIdentifier()\r\n{\r\n    QString output;\r\n    QXmlStreamWriter xmlStreamWriter(&output);\r\n\r\n    QSharedPointer<RegisterFile> testRegisterFile (new RegisterFile(\"testFile\", \"fileOffset\", \"8\"));\r\n    testRegisterFile->setTypeIdentifier(\"papersPlease\");\r\n\r\n    QString expectedOutput(\r\n        \"<ipxact:registerFile>\"\r\n            \"<ipxact:name>testFile</ipxact:name>\"\r\n            \"<ipxact:addressOffset>fileOffset</ipxact:addressOffset>\"\r\n            \"<ipxact:typeIdentifier>papersPlease</ipxact:typeIdentifier>\"\r\n            \"<ipxact:range>8</ipxact:range>\"\r\n        \"</ipxact:registerFile>\"\r\n        );\r\n\r\n    RegisterWriter::writeRegisterData(xmlStreamWriter, testRegisterFile, Document::Revision::Std14);\r\n    QCOMPARE(output, expectedOutput);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_RegisterWriter::writeRegisterFileRegisterData()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_RegisterWriter::writeRegisterFileRegisterData()\r\n{\r\n    QString output;\r\n    QXmlStreamWriter xmlStreamWriter(&output);\r\n\r\n    QSharedPointer<Field> simpleField(new Field(\"simpleField\"));\r\n    simpleField->setBitOffset(\"fieldOffset\");\r\n    simpleField->setBitWidth(\"fieldWidth\");\r\n\r\n    QSharedPointer<Register> testRegister (new Register(\"testRegister\", \"offset\", \"10\"));\r\n    testRegister->setDisplayName(\"displayed\");\r\n    testRegister->setDescription(\"described\");\r\n    testRegister->getFields()->append(simpleField);\r\n\r\n    QSharedPointer<RegisterFile> containedRegisterFile\r\n        (new RegisterFile(\"contained\", \"containedOffset\", \"containedRange\"));\r\n\r\n    QSharedPointer<RegisterFile> testRegisterFile (new RegisterFile(\"testFile\", \"fileOffset\", \"8\"));\r\n    testRegisterFile->getRegisterData()->append(testRegister);\r\n    testRegisterFile->getRegisterData()->append(containedRegisterFile);\r\n\r\n    QString expectedOutput(\r\n        \"<ipxact:registerFile>\"\r\n            \"<ipxact:name>testFile</ipxact:name>\"\r\n            \"<ipxact:addressOffset>fileOffset</ipxact:addressOffset>\"\r\n            \"<ipxact:range>8</ipxact:range>\"\r\n            \"<ipxact:register>\"\r\n                \"<ipxact:name>testRegister</ipxact:name>\"\r\n                \"<ipxact:displayName>displayed</ipxact:displayName>\"\r\n                \"<ipxact:description>described</ipxact:description>\"\r\n                \"<ipxact:addressOffset>offset</ipxact:addressOffset>\"\r\n                \"<ipxact:size>10</ipxact:size>\"\r\n                \"<ipxact:field>\"\r\n                    \"<ipxact:name>simpleField</ipxact:name>\"\r\n                    \"<ipxact:bitOffset>fieldOffset</ipxact:bitOffset>\"\r\n                    \"<ipxact:bitWidth>fieldWidth</ipxact:bitWidth>\"\r\n                \"</ipxact:field>\"\r\n            \"</ipxact:register>\"\r\n            \"<ipxact:registerFile>\"\r\n                \"<ipxact:name>contained</ipxact:name>\"\r\n                \"<ipxact:addressOffset>containedOffset</ipxact:addressOffset>\"\r\n                \"<ipxact:range>containedRange</ipxact:range>\"\r\n            \"</ipxact:registerFile>\"\r\n        \"</ipxact:registerFile>\"\r\n        );\r\n\r\n    RegisterWriter::writeRegisterData(xmlStreamWriter, testRegisterFile, Document::Revision::Std14);\r\n    QCOMPARE(output, expectedOutput);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_RegisterWriter::writeRegisterFileDefinitionReference2022()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_RegisterWriter::writeRegisterFileDefinitionReference2022()\r\n{\r\n    QString output;\r\n    QXmlStreamWriter xmlStreamWriter(&output);\r\n\r\n    QSharedPointer<RegisterFile> testRegisterFile(new RegisterFile(\"testFile\", \"fileOffset\"));\r\n    testRegisterFile->setDisplayName(\"displayed\");\r\n    testRegisterFile->setShortDescription(\"testShortDescription\");\r\n    testRegisterFile->setDescription(\"described\");\r\n\r\n    testRegisterFile->setRegisterFileDefinitionReference(\"testRegisterFileDefinition\");\r\n    testRegisterFile->setTypeDefinitionsReference(\"testTypeDefinitions\");\r\n\r\n    QString expectedOutput(\r\n        \"<ipxact:registerFile>\"\r\n            \"<ipxact:name>testFile</ipxact:name>\"\r\n            \"<ipxact:displayName>displayed</ipxact:displayName>\"\r\n            \"<ipxact:shortDescription>testShortDescription</ipxact:shortDescription>\"\r\n            \"<ipxact:description>described</ipxact:description>\"\r\n            \"<ipxact:addressOffset>fileOffset</ipxact:addressOffset>\"\r\n            \"<ipxact:registerFileDefinitionRef typeDefinitions=\\\"testTypeDefinitions\\\">testRegisterFileDefinition</ipxact:registerFileDefinitionRef>\"\r\n        \"</ipxact:registerFile>\"\r\n    );\r\n\r\n    RegisterWriter::writeRegisterData(xmlStreamWriter, testRegisterFile, Document::Revision::Std22);\r\n    QCOMPARE(output, expectedOutput);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_RegisterWriter::writeRegisterFileMemoryArray2022()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_RegisterWriter::writeRegisterFileMemoryArray2022()\r\n{\r\n    QString output;\r\n    QXmlStreamWriter xmlStreamWriter(&output);\r\n\r\n    QSharedPointer<MemoryArray::Dimension> dim1(new MemoryArray::Dimension());\r\n    dim1->indexVar_ = \"testDim\";\r\n    dim1->value_ = \"1+1\";\r\n\r\n    QSharedPointer<MemoryArray::Dimension> dim2(new MemoryArray::Dimension());\r\n    dim2->value_ = \"4\";\r\n\r\n    QSharedPointer<MemoryArray> memArray(new MemoryArray());\r\n    memArray->setStride(\"4\");\r\n    memArray->getDimensions()->append(dim1);\r\n    memArray->getDimensions()->append(dim2);\r\n\r\n    QSharedPointer<RegisterFile> testRegisterFile(new RegisterFile(\"testFile\", \"fileOffset\", \"8\"));\r\n    testRegisterFile->setMemoryArray(memArray);\r\n\r\n    QString expectedOutput(\r\n        \"<ipxact:registerFile>\"\r\n            \"<ipxact:name>testFile</ipxact:name>\"\r\n            \"<ipxact:array>\"\r\n                \"<ipxact:dim indexVar=\\\"testDim\\\">1+1</ipxact:dim>\"\r\n                \"<ipxact:dim>4</ipxact:dim>\"\r\n                \"<ipxact:stride>4</ipxact:stride>\"\r\n            \"</ipxact:array>\"\r\n            \"<ipxact:addressOffset>fileOffset</ipxact:addressOffset>\"\r\n            \"<ipxact:range>8</ipxact:range>\"\r\n        \"</ipxact:registerFile>\"\r\n    );\r\n\r\n    RegisterWriter::writeRegisterData(xmlStreamWriter, testRegisterFile, Document::Revision::Std22);\r\n    QCOMPARE(output, expectedOutput);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_RegisterWriter::writeRegisterFileAccessPolicies2022()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_RegisterWriter::writeRegisterFileAccessPolicies2022()\r\n{\r\n    QString output;\r\n    QXmlStreamWriter xmlStreamWriter(&output);\r\n\r\n    QSharedPointer<ModeReference> modeRef1(new ModeReference());\r\n    modeRef1->setReference(\"testMode\");\r\n    modeRef1->setPriority(0);\r\n\r\n    QSharedPointer<AccessPolicy> accessPolicy1(new AccessPolicy());\r\n    accessPolicy1->getModeReferences()->append(modeRef1);\r\n    accessPolicy1->setAccess(AccessTypes::READ_ONLY);\r\n\r\n\r\n    QSharedPointer<ModeReference> modeRef2(new ModeReference());\r\n    modeRef2->setReference(\"testMode2\");\r\n    modeRef2->setPriority(1);\r\n\r\n    QSharedPointer<ModeReference> modeRef3(new ModeReference(*modeRef1));\r\n    modeRef3->setReference(\"testMode3\");\r\n    modeRef3->setPriority(2);\r\n\r\n    QSharedPointer<AccessPolicy> accessPolicy2(new AccessPolicy());\r\n    accessPolicy2->getModeReferences()->append(modeRef2);\r\n    accessPolicy2->getModeReferences()->append(modeRef3);\r\n\r\n    QSharedPointer<RegisterFile> testRegisterFile(new RegisterFile(\"testFile\", \"fileOffset\", \"8\"));\r\n    testRegisterFile->getAccessPolicies()->append(accessPolicy1);\r\n    testRegisterFile->getAccessPolicies()->append(accessPolicy2);\r\n\r\n    QString expectedOutput(\r\n        \"<ipxact:registerFile>\"\r\n            \"<ipxact:name>testFile</ipxact:name>\"\r\n            \"<ipxact:addressOffset>fileOffset</ipxact:addressOffset>\"\r\n            \"<ipxact:range>8</ipxact:range>\"\r\n            \"<ipxact:accessPolicies>\"\r\n                \"<ipxact:accessPolicy>\"\r\n                    \"<ipxact:modeRef priority=\\\"0\\\">testMode</ipxact:modeRef>\"\r\n                    \"<ipxact:access>read-only</ipxact:access>\"\r\n                \"</ipxact:accessPolicy>\"\r\n                \"<ipxact:accessPolicy>\"\r\n                    \"<ipxact:modeRef priority=\\\"1\\\">testMode2</ipxact:modeRef>\"\r\n                    \"<ipxact:modeRef priority=\\\"2\\\">testMode3</ipxact:modeRef>\"\r\n                \"</ipxact:accessPolicy>\"\r\n            \"</ipxact:accessPolicies>\"\r\n        \"</ipxact:registerFile>\"\r\n    );\r\n\r\n    RegisterWriter::writeRegisterData(xmlStreamWriter, testRegisterFile, Document::Revision::Std22);\r\n    QCOMPARE(output, expectedOutput);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_RegisterWriter::writeRegisterFileParameters()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_RegisterWriter::writeRegisterFileParameters()\r\n{\r\n    QString output;\r\n    QXmlStreamWriter xmlStreamWriter(&output);\r\n\r\n    QSharedPointer<Parameter> testParameter(new Parameter());\r\n    testParameter->setValueId(\"testID\");\r\n    testParameter->setName(\"testParameter\");\r\n    testParameter->setValue(\"1\");\r\n\r\n    QSharedPointer<RegisterFile> testRegisterFile (new RegisterFile(\"testFile\", \"fileOffset\", \"8\"));\r\n    testRegisterFile->setDimension(\"DimensionProbability\");\r\n    testRegisterFile->getParameters()->append(testParameter);\r\n\r\n    QString expectedOutput(\r\n        \"<ipxact:registerFile>\"\r\n            \"<ipxact:name>testFile</ipxact:name>\"\r\n            \"<ipxact:dim>DimensionProbability</ipxact:dim>\"\r\n            \"<ipxact:addressOffset>fileOffset</ipxact:addressOffset>\"\r\n            \"<ipxact:range>8</ipxact:range>\"\r\n            \"<ipxact:parameters>\"\r\n                \"<ipxact:parameter parameterId=\\\"testID\\\">\"\r\n                    \"<ipxact:name>testParameter</ipxact:name>\"\r\n                    \"<ipxact:value>1</ipxact:value>\"\r\n                \"</ipxact:parameter>\"\r\n            \"</ipxact:parameters>\"\r\n        \"</ipxact:registerFile>\"\r\n        );\r\n\r\n    RegisterWriter::writeRegisterData(xmlStreamWriter, testRegisterFile, Document::Revision::Std14);\r\n    QCOMPARE(output, expectedOutput);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_RegisterWriter::writeRegisterFileVendorExtensions()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_RegisterWriter::writeRegisterFileVendorExtensions()\r\n{\r\n    QString output;\r\n    QXmlStreamWriter xmlStreamWriter(&output);\r\n\r\n    QDomDocument document;\r\n    QDomElement extensionNode = document.createElement(\"testExtension\");\r\n    extensionNode.setAttribute(\"testExtensionAttribute\", \"extension\");\r\n    extensionNode.appendChild(document.createTextNode(\"testValue\"));\r\n\r\n    QSharedPointer<GenericVendorExtension> testExtension(new GenericVendorExtension(extensionNode));\r\n\r\n    QSharedPointer<RegisterFile> testRegisterFile (new RegisterFile(\"testFile\", \"fileOffset\", \"8\"));\r\n    testRegisterFile->setDimension(\"DimensionProbability\");\r\n    testRegisterFile->getVendorExtensions()->append(testExtension);\r\n\r\n    QString expectedOutput(\r\n        \"<ipxact:registerFile>\"\r\n            \"<ipxact:name>testFile</ipxact:name>\"\r\n            \"<ipxact:dim>DimensionProbability</ipxact:dim>\"\r\n            \"<ipxact:addressOffset>fileOffset</ipxact:addressOffset>\"\r\n            \"<ipxact:range>8</ipxact:range>\"\r\n            \"<ipxact:vendorExtensions>\"\r\n                \"<testExtension testExtensionAttribute=\\\"extension\\\">testValue</testExtension>\"\r\n            \"</ipxact:vendorExtensions>\"\r\n        \"</ipxact:registerFile>\"\r\n        );\r\n\r\n    RegisterWriter::writeRegisterData(xmlStreamWriter, testRegisterFile, Document::Revision::Std14);\r\n    QCOMPARE(output, expectedOutput);\r\n}\r\n\r\nQTEST_APPLESS_MAIN(tst_RegisterWriter)\r\n\r\n#include \"tst_RegisterWriter.moc\"\r\n"
  },
  {
    "path": "tests/IPXACTmodels/Component/tst_RegisterWriter.pri",
    "content": "# ----------------------------------------------------\r\n# This file is generated by the Qt Visual Studio Tools.\r\n# ------------------------------------------------------\r\n\r\nSOURCES += ./tst_RegisterWriter.cpp \r\n"
  },
  {
    "path": "tests/IPXACTmodels/Component/tst_RegisterWriter.pro",
    "content": "#-----------------------------------------------------------------------------\r\n# File: tst_RegisterWriter.pro\r\n#-----------------------------------------------------------------------------\r\n# Project: Kactus 2\r\n# Author: Mikko Teuho\r\n# Date: 28.09.2015\r\n#\r\n# Description:\r\n# Qt project file template for running unit tests for register writer.\r\n#-----------------------------------------------------------------------------\r\n\r\nTEMPLATE = app\r\n\r\nTARGET = tst_RegisterWriter\r\n\r\nQT += core xml testlib\r\nQT -= gui\r\n\r\nCONFIG += c++11 testcase console\r\n\r\nlinux-g++ | linux-g++-64 | linux-g++-32 {\r\n LIBS += -L../../../executable \\\r\n     -lIPXACTmodels\r\n}\r\nwin64 | win32 {\r\n LIBS += -L../../../executable \\\r\n     -lIPXACTmodelsd\r\n}\r\n\r\nINCLUDEPATH += $$DESTDIR\r\nINCLUDEPATH += ../../../\r\n\r\nDEPENDPATH += .\r\nDEPENDPATH += ../../../\r\n\r\nOBJECTS_DIR += $$DESTDIR\r\n\r\nMOC_DIR += ./generatedFiles\r\nUI_DIR += ./generatedFiles\r\nRCC_DIR += ./generatedFiles\r\ninclude(tst_RegisterWriter.pri)\r\n"
  },
  {
    "path": "tests/IPXACTmodels/Component/tst_RemapStateReader.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: tst_RemapStateReader.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 23.09.2015\r\n//\r\n// Description:\r\n// Unit test for class RemapStateReader.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include <IPXACTmodels/Component/RemapStateReader.h>\r\n#include <IPXACTmodels/Component/RemapState.h>\r\n#include <IPXACTmodels/Component/RemapPort.h>\r\n\r\n#include <QtTest>\r\n\r\nclass tst_RemapStateReader : public QObject\r\n{\r\n    Q_OBJECT\r\n\r\npublic:\r\n    tst_RemapStateReader();\r\n\r\nprivate slots:\r\n\r\n    void readSimpleRemapState();\r\n    void readRemapPorts();\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_RemapStateReader::tst_RemapStateReader()\r\n//-----------------------------------------------------------------------------\r\ntst_RemapStateReader::tst_RemapStateReader()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_RemapStateReader::readSimpleRemapState()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_RemapStateReader::readSimpleRemapState()\r\n{\r\n    QString documentContent(\r\n        \"<ipxact:remapState>\"\r\n            \"<ipxact:name>testRemapState</ipxact:name>\"\r\n            \"<ipxact:displayName>testDisplay</ipxact:displayName>\"\r\n            \"<ipxact:description>testDescription</ipxact:description>\"\r\n        \"</ipxact:remapState>\"\r\n        );\r\n\r\n    QDomDocument document;\r\n    document.setContent(documentContent);\r\n\r\n    QDomNode remapStateNode = document.firstChildElement(\"ipxact:remapState\");\r\n\r\n    QSharedPointer<RemapState> testRemapState = RemapStateReader::createRemapStateFrom(remapStateNode);\r\n\r\n    QCOMPARE(testRemapState->name(), QString(\"testRemapState\"));\r\n    QCOMPARE(testRemapState->displayName(), QString(\"testDisplay\"));\r\n    QCOMPARE(testRemapState->description(), QString(\"testDescription\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_RemapStateReader::readRemapPorts()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_RemapStateReader::readRemapPorts()\r\n{\r\n    QString documentContent(\r\n        \"<ipxact:remapState>\"\r\n            \"<ipxact:name>testRemapState</ipxact:name>\"\r\n            \"<ipxact:remapPorts>\"\r\n                \"<ipxact:remapPort portRef=\\\"referencedPort\\\">\"\r\n                    \"<ipxact:value>newValue</ipxact:value>\"\r\n                \"</ipxact:remapPort>\"\r\n                \"<ipxact:remapPort portRef=\\\"Fuu\\\">\"\r\n                    \"<ipxact:portIndex>Mugen</ipxact:portIndex>\"\r\n                    \"<ipxact:value>Jin</ipxact:value>\"\r\n                \"</ipxact:remapPort>\"\r\n            \"</ipxact:remapPorts>\"\r\n        \"</ipxact:remapState>\"\r\n        );\r\n\r\n    QDomDocument document;\r\n    document.setContent(documentContent);\r\n\r\n    QDomNode remapStateNode = document.firstChildElement(\"ipxact:remapState\");\r\n\r\n    QSharedPointer<RemapState> testRemapState = RemapStateReader::createRemapStateFrom(remapStateNode);\r\n\r\n    QCOMPARE(testRemapState->name(), QString(\"testRemapState\"));\r\n\r\n    QCOMPARE(testRemapState->getRemapPorts()->size(), 2);\r\n    QCOMPARE(testRemapState->getRemapPorts()->first()->getPortNameRef(), QString(\"referencedPort\"));\r\n    QCOMPARE(testRemapState->getRemapPorts()->first()->getPortIndex(), QString(\"\"));\r\n    QCOMPARE(testRemapState->getRemapPorts()->first()->getValue(), QString(\"newValue\"));\r\n\r\n    QCOMPARE(testRemapState->getRemapPorts()->last()->getPortNameRef(), QString(\"Fuu\"));\r\n    QCOMPARE(testRemapState->getRemapPorts()->last()->getPortIndex(), QString(\"Mugen\"));\r\n    QCOMPARE(testRemapState->getRemapPorts()->last()->getValue(), QString(\"Jin\"));\r\n}\r\n\r\nQTEST_APPLESS_MAIN(tst_RemapStateReader)\r\n\r\n#include \"tst_RemapStateReader.moc\"\r\n"
  },
  {
    "path": "tests/IPXACTmodels/Component/tst_RemapStateReader.pri",
    "content": "# ----------------------------------------------------\r\n# This file is generated by the Qt Visual Studio Add-in.\r\n# ------------------------------------------------------\r\n\r\nSOURCES += ./tst_RemapStateReader.cpp\r\n"
  },
  {
    "path": "tests/IPXACTmodels/Component/tst_RemapStateReader.pro",
    "content": "#-----------------------------------------------------------------------------\r\n# File: tst_remapStateReader.pro\r\n#-----------------------------------------------------------------------------\r\n# Project: Kactus 2\r\n# Author: Mikko Teuho\r\n# Date: 23.09.2015\r\n#\r\n# Description:\r\n# Qt project file template for running unit tests for RemapStateReader.\r\n#-----------------------------------------------------------------------------\r\n\r\nTEMPLATE = app\r\n\r\nTARGET = tst_RemapStateReader\r\n\r\nQT += core xml testlib\r\nQT -= gui\r\n\r\nCONFIG += c++11 testcase console\r\n\r\nlinux-g++ | linux-g++-64 | linux-g++-32 {\r\n LIBS += -L../../../executable \\\r\n     -lIPXACTmodels\r\n}\r\nwin64 | win32 {\r\n LIBS += -L../../../x64/executable \\\r\n     -lIPXACTmodelsd\r\n}\r\n\r\nINCLUDEPATH += $$DESTDIR\r\nINCLUDEPATH += ../../../\r\n\r\nDEPENDPATH += .\r\nDEPENDPATH += ../../../\r\n\r\nOBJECTS_DIR += $$DESTDIR\r\n\r\nMOC_DIR += ./generatedFiles\r\nUI_DIR += ./generatedFiles\r\nRCC_DIR += ./generatedFiles\r\ninclude(tst_RemapStateReader.pri)\r\n"
  },
  {
    "path": "tests/IPXACTmodels/Component/tst_RemapStateValidator.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: tst_RemapStateValidator.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 27.11.2015\r\n//\r\n// Description:\r\n// Unit test for class RemapStateValidator.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include <KactusAPI/include/SystemVerilogExpressionParser.h>\r\n\r\n#include <IPXACTmodels/Component/validators/RemapStateValidator.h>\r\n\r\n#include <IPXACTmodels/Component/RemapState.h>\r\n#include <IPXACTmodels/Component/RemapPort.h>\r\n#include <IPXACTmodels/Component/Port.h>\r\n\r\n#include <QtTest>\r\n\r\nclass tst_RemapStateValidator : public QObject\r\n{\r\n    Q_OBJECT\r\n\r\npublic:\r\n    tst_RemapStateValidator();\r\n\r\nprivate slots:\r\n\r\n    void testNameIsValid();\r\n    void testNameIsValid_data();\r\n\r\n    void testHasValidRemapPorts();\r\n    void testHasValidRemapPorts_data();\r\n    void testRemapPortHasValidValue();\r\n    void testRemapPortHasValidValue_data();\r\n    void testRemapPortHasValidPortIndex();\r\n    void testRemapPortHasValidPortIndex_data();\r\n\r\nprivate:\r\n\r\n    bool errorIsNotFoundInErrorList(QString const& expectedError, QVector<QString> errorList);\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_RemapStateValidator::tst_RemapStateValidator()\r\n//-----------------------------------------------------------------------------\r\ntst_RemapStateValidator::tst_RemapStateValidator()\r\n{\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_RemapStateValidator::testNameIsValid()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_RemapStateValidator::testNameIsValid()\r\n{\r\n    QFETCH(QString, name);\r\n    QFETCH(bool, isValid);\r\n\r\n    QSharedPointer<RemapState> testState (new RemapState(name));\r\n\r\n    QSharedPointer<ExpressionParser> parser(new SystemVerilogExpressionParser());\r\n    RemapStateValidator validator(parser, QSharedPointer<QList<QSharedPointer<Port> > > ());\r\n    QCOMPARE(validator.hasValidName(testState), isValid);\r\n\r\n    if (!isValid)\r\n    {\r\n        QVector<QString> foundErrors;\r\n        validator.findErrorsIn(foundErrors, testState, \"test\");\r\n\r\n        QString expectedError = QObject::tr(\"Invalid name specified for remap state %1 within %2\").\r\n            arg(testState->name(), \"test\");\r\n        if (errorIsNotFoundInErrorList(expectedError, foundErrors))\r\n        {\r\n            QFAIL(\"No error message found\");\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_RemapStateValidator::testNameIsValid_data()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_RemapStateValidator::testNameIsValid_data()\r\n{\r\n    QTest::addColumn<QString>(\"name\");\r\n    QTest::addColumn<bool>(\"isValid\");\r\n\r\n    QTest::newRow(\"Name test is valid\") << \"test\" << true;\r\n    QTest::newRow(\"Empty name is invalid\") << \"\" << false;\r\n    QTest::newRow(\"Name consisting of only white spaces is invalid\") << \"    \" << false;\r\n    QTest::newRow(\"Name consisting of characters and white spaces is valid\") << \"  test  \" << true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_RemapStateValidator::testHasValidRemapPorts()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_RemapStateValidator::testHasValidRemapPorts()\r\n{\r\n    QFETCH(QString, portRef);\r\n    QFETCH(bool, createPort);\r\n    QFETCH(bool, isValid);\r\n\r\n    QSharedPointer<RemapPort> testRemapPort (new RemapPort(portRef));\r\n    testRemapPort->setValue(\"3\");\r\n\r\n    QSharedPointer<QList<QSharedPointer<Port> > > ports (new QList<QSharedPointer<Port> > ());\r\n    if (createPort)\r\n    {\r\n        if (portRef.isEmpty())\r\n        {\r\n            portRef = \"camploo\";\r\n        }\r\n        QSharedPointer<Port> newPort (new Port(portRef));\r\n        ports->append(newPort);\r\n    }\r\n\r\n    QSharedPointer<RemapState> testState (new RemapState(\"testState\"));\r\n    testState->getRemapPorts()->append(testRemapPort);\r\n    \r\n    QSharedPointer<ExpressionParser> parser(new SystemVerilogExpressionParser());\r\n    RemapStateValidator validator(parser, ports);\r\n    QCOMPARE(validator.hasValidRemapPorts(testState), isValid);\r\n\r\n    if (!isValid)\r\n    {\r\n        QVector<QString> foundErrors;\r\n        validator.findErrorsIn(foundErrors, testState, \"test\");\r\n\r\n        QString expectedError = QObject::tr(\"Invalid port %1 set for remap state %2\")\r\n            .arg(testRemapPort->getPortNameRef()).arg(testState->name());\r\n        if (errorIsNotFoundInErrorList(expectedError, foundErrors))\r\n        {\r\n            QFAIL(\"No error message found\");\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_RemapStateValidator::testHasValidRemapPorts_data()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_RemapStateValidator::testHasValidRemapPorts_data()\r\n{\r\n    QTest::addColumn<QString>(\"portRef\");\r\n    QTest::addColumn<bool>(\"createPort\");\r\n    QTest::addColumn<bool>(\"isValid\");\r\n\r\n    QTest::newRow(\"Remap port with a port reference to existing port is valid\") << \"reference\" << true << true;\r\n    QTest::newRow(\"Remap port with a portRef to non-existing port is not valid\") << \"reference\" << false << false;\r\n    QTest::newRow(\"Remap port without a portRef is not valid\") << \"\" << true << false;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_RemapStateValidator::testRemapPortHasValidValue()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_RemapStateValidator::testRemapPortHasValidValue()\r\n{\r\n    QFETCH(QString, remapPortValue);\r\n    QFETCH(bool, isValid);\r\n\r\n    QSharedPointer<QList<QSharedPointer<Port> > > ports (new QList<QSharedPointer<Port> > ());\r\n    QSharedPointer<Port> newPort (new Port(QLatin1String(\"Champloo\")));\r\n    ports->append(newPort);\r\n\r\n    QSharedPointer<RemapPort> testRemapPort (new RemapPort(newPort->name()));\r\n    testRemapPort->setValue(remapPortValue);\r\n\r\n    QSharedPointer<RemapState> testState (new RemapState(\"testState\"));\r\n    testState->getRemapPorts()->append(testRemapPort);\r\n\r\n    QSharedPointer<ExpressionParser> parser(new SystemVerilogExpressionParser());\r\n    RemapStateValidator validator(parser, ports);\r\n    QCOMPARE(validator.hasValidRemapPorts(testState), isValid);\r\n\r\n    if (!isValid)\r\n    {\r\n        QVector<QString> foundErrors;\r\n        validator.findErrorsIn(foundErrors, testState, \"test\");\r\n\r\n        QString expectedError = QObject::tr(\"Invalid value set for remap port %1 within remap state %2\")\r\n            .arg(testRemapPort->getPortNameRef()).arg(testState->name());\r\n        if (errorIsNotFoundInErrorList(expectedError, foundErrors))\r\n        {\r\n            QFAIL(\"No error message found\");\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_RemapStateValidator::testRemapPortHasValidValue_data()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_RemapStateValidator::testRemapPortHasValidValue_data()\r\n{\r\n    QTest::addColumn<QString>(\"remapPortValue\");\r\n    QTest::addColumn<bool>(\"isValid\");\r\n\r\n    QTest::newRow(\"0 is valid for remap port value\") << \"0\" << true;\r\n    QTest::newRow(\"12*2+13-5 is valid for remap port value\") << \"12*2+13-5\" << true;\r\n    QTest::newRow(\"-20 is not valid for remap port value\") << \"-20\" << false;\r\n    QTest::newRow(\"14-5*3 is not valid for remap port value\") << \"14-5*3\" << false;\r\n    QTest::newRow(\"Text is not valid for remap port value\") << \"text\" << false;\r\n    QTest::newRow(\"String is not valid for remap port value\") << \"\\\"text\\\"\" << false;\r\n    QTest::newRow(\"Empty value is not valid for remap port value\") << \"\" << false;\r\n\r\n    QTest::newRow(\"Long value is valid\") << \"40000000000\" << true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_RemapStateValidator::testRemapPortHasValidPortIndex()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_RemapStateValidator::testRemapPortHasValidPortIndex()\r\n{\r\n    QFETCH(QString, remapPortIndex);\r\n    QFETCH(QString, portLeftBound);\r\n    QFETCH(QString, portRightBound);\r\n    QFETCH(bool, isValid);\r\n\r\n    QSharedPointer<Port> newPort (new Port(\"testPort\"));\r\n    newPort->setLeftBound(portLeftBound);\r\n    newPort->setRightBound(portRightBound);\r\n\r\n    QSharedPointer<QList<QSharedPointer<Port> > > ports (new QList<QSharedPointer<Port> > ());\r\n    ports->append(newPort);\r\n\r\n    QSharedPointer<RemapPort> testRemapPort (new RemapPort(newPort->name()));\r\n    testRemapPort->setValue(\"3\");\r\n    testRemapPort->setPortIndex(remapPortIndex);\r\n\r\n    QSharedPointer<RemapState> testState (new RemapState(\"testRemapState\"));\r\n    testState->getRemapPorts()->append(testRemapPort);\r\n\r\n    QSharedPointer<ExpressionParser> parser(new SystemVerilogExpressionParser());\r\n    RemapStateValidator validator(parser, ports);\r\n    QCOMPARE(validator.hasValidRemapPorts(testState), isValid);\r\n\r\n    if (!isValid)\r\n    {\r\n        QVector<QString> foundErrors;\r\n        validator.findErrorsIn(foundErrors, testState, \"test\");\r\n\r\n        QString expectedError = QObject::tr(\"Invalid port index set for remap port %1 within remap state %2\")\r\n            .arg(testRemapPort->getPortNameRef()).arg(testState->name());\r\n        if (errorIsNotFoundInErrorList(expectedError, foundErrors))\r\n        {\r\n            QFAIL(\"No error message found\");\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_RemapStateValidator::testRemapPortHasValidPortIndex_data()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_RemapStateValidator::testRemapPortHasValidPortIndex_data()\r\n{\r\n    QTest::addColumn<QString>(\"remapPortIndex\");\r\n    QTest::addColumn<QString>(\"portLeftBound\");\r\n    QTest::addColumn<QString>(\"portRightBound\");\r\n    QTest::addColumn<bool>(\"isValid\");\r\n\r\n    QTest::newRow(\"0 is valid for remap port index with referenced port size 2\") << \"0\" << \"0\" << \"1\" << true;\r\n    QTest::newRow(\"String is not valid for remap port index\") << \"\\\"text\\\"\" << \"0\" << \"1\" << false;\r\n    QTest::newRow(\"Test is not valid for remap port index\") << \"text\" << \"0\" << \"1\" << false;\r\n    QTest::newRow(\"Negative index is not valid\") << \"-113\" << \"0\" << \"1\" << false;\r\n\r\n    QTest::newRow(\"Index is not valid for remap port with non vectored port\") << \"12\" << \"1\" << \"1\" << false;\r\n    QTest::newRow(\"Index is not valid if index is greater than port size\") << \"10\" << \"0\" << \"8\" << false;\r\n    QTest::newRow(\"Empty index with referenced port size > 0 is valid\") << \"\" << \"0\" << \"10\" << true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_RemapStateValidator::errorIsNotFoundInErrorList()\r\n//-----------------------------------------------------------------------------\r\nbool tst_RemapStateValidator::errorIsNotFoundInErrorList(QString const& expectedError,\r\n    QVector<QString> errorList)\r\n{\r\n    if (!errorList.contains(expectedError))\r\n    {\r\n        qDebug() << \"The following error:\" << Qt::endl << expectedError << Qt::endl << \"was not found in error list:\";\r\n        for (QString const& error : errorList)\r\n        {\r\n            qDebug() << error;\r\n        }\r\n        return true;\r\n    }\r\n\r\n    return false;\r\n}\r\n\r\nQTEST_APPLESS_MAIN(tst_RemapStateValidator)\r\n\r\n#include \"tst_RemapStateValidator.moc\"\r\n"
  },
  {
    "path": "tests/IPXACTmodels/Component/tst_RemapStateValidator.pri",
    "content": "# ----------------------------------------------------\r\n# This file is generated by the Qt Visual Studio Tools.\r\n# ------------------------------------------------------\r\n\r\nSOURCES += ./tst_RemapStateValidator.cpp \r\n\t"
  },
  {
    "path": "tests/IPXACTmodels/Component/tst_RemapStateValidator.pro",
    "content": "#-----------------------------------------------------------------------------\r\n# File: tst_RemapStateValidator.pro\r\n#-----------------------------------------------------------------------------\r\n# Project: Kactus 2\r\n# Author: Mikko Teuho\r\n# Date: 27.11.2015\r\n#\r\n# Description:\r\n# Qt project file template for running unit tests for RemapStateValidator.\r\n#-----------------------------------------------------------------------------\r\n\r\nTEMPLATE = app\r\n\r\nTARGET = tst_RemapStateValidator\r\n\r\nQT += core xml testlib\r\nQT -= gui\r\n\r\nCONFIG += c++11 testcase console\r\n\r\nlinux-g++ | linux-g++-64 | linux-g++-32 {\r\n LIBS += -L../../../executable \\\r\n     -lIPXACTmodels -lKactusAPI\r\n}\r\nwin64 | win32 {\r\n LIBS += -L../../../executable \\\r\n     -lIPXACTmodelsd -lKactusAPId\r\n}\r\n\r\nINCLUDEPATH += $$DESTDIR\r\nINCLUDEPATH += ../../../\r\n\r\nDEPENDPATH += .\r\nDEPENDPATH += ../../../\r\n\r\nOBJECTS_DIR += $$DESTDIR\r\n\r\nMOC_DIR += ./generatedFiles\r\nUI_DIR += ./generatedFiles\r\nRCC_DIR += ./generatedFiles\r\ninclude(tst_RemapStateValidator.pri)\r\n"
  },
  {
    "path": "tests/IPXACTmodels/Component/tst_RemapStateWriter.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: tst_RemapStateWriter.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 23.09.2015\r\n//\r\n// Description:\r\n// Unit test for class RemapStateWriter.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include <IPXACTmodels/Component/RemapStateWriter.h>\r\n#include <IPXACTmodels/Component/RemapState.h>\r\n#include <IPXACTmodels/Component/RemapPort.h>\r\n\r\n#include <QtTest>\r\n#include <QSharedPointer>\r\n\r\nclass tst_RemapStateWriter : public QObject\r\n{\r\n    Q_OBJECT\r\n\r\npublic:\r\n    tst_RemapStateWriter();\r\n\r\nprivate slots:\r\n\r\n    void initTestCase();\r\n    void cleanupTestCase();\r\n    void init();\r\n    void cleanup();\r\n\r\n    void writeSimpleRemapState();\r\n    void writeRemapPorts();\r\n\r\nprivate:\r\n\r\n    QSharedPointer<RemapState> testRemapState_;\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_RemapStateWriter::tst_RemapStateWriter()\r\n//-----------------------------------------------------------------------------\r\ntst_RemapStateWriter::tst_RemapStateWriter():\r\ntestRemapState_()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_RemapStateWriter::initTestCase()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_RemapStateWriter::initTestCase()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_RemapStateWriter::cleanupTestCase()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_RemapStateWriter::cleanupTestCase()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_RemapStateWriter::init()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_RemapStateWriter::init()\r\n{\r\n    testRemapState_ = QSharedPointer<RemapState>(new RemapState(\"testRemapState\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_RemapStateWriter::cleanup()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_RemapStateWriter::cleanup()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_RemapStateWriter::writeSimpleRemapState()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_RemapStateWriter::writeSimpleRemapState()\r\n{\r\n    QString output;\r\n    QXmlStreamWriter xmlStreamWriter(&output);\r\n\r\n    QString expectedOutput(\r\n        \"<ipxact:remapState>\"\r\n            \"<ipxact:name>testRemapState</ipxact:name>\"\r\n        \"</ipxact:remapState>\"\r\n        );\r\n\r\n    RemapStateWriter::writeRemapState(xmlStreamWriter, testRemapState_);\r\n    QCOMPARE(output, expectedOutput);\r\n\r\n    expectedOutput.clear();\r\n    output.clear();\r\n\r\n    testRemapState_->setDisplayName(\"testDisplay\");\r\n    testRemapState_->setDescription(\"testDescription\");\r\n    expectedOutput = \r\n        \"<ipxact:remapState>\"\r\n            \"<ipxact:name>testRemapState</ipxact:name>\"\r\n            \"<ipxact:displayName>testDisplay</ipxact:displayName>\"\r\n            \"<ipxact:description>testDescription</ipxact:description>\"\r\n        \"</ipxact:remapState>\"\r\n        ;\r\n\r\n    RemapStateWriter::writeRemapState(xmlStreamWriter, testRemapState_);\r\n    QCOMPARE(output, expectedOutput);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_RemapStateWriter::writeRemapPorts()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_RemapStateWriter::writeRemapPorts()\r\n{\r\n    QString output;\r\n    QXmlStreamWriter xmlStreamWriter(&output);\r\n\r\n    QSharedPointer<RemapPort> testRemapPort (new RemapPort(\"referencedPort\"));\r\n    testRemapPort->setValue(\"newValue\");\r\n\r\n    QSharedPointer<RemapPort> otherRemapPort (new RemapPort(\"Fuu\"));\r\n    otherRemapPort->setPortIndex(\"Mugen\");\r\n    otherRemapPort->setValue(\"Jin\");\r\n\r\n    testRemapState_->getRemapPorts()->append(testRemapPort);\r\n    testRemapState_->getRemapPorts()->append(otherRemapPort);\r\n\r\n    QString expectedOutput(\r\n        \"<ipxact:remapState>\"\r\n            \"<ipxact:name>testRemapState</ipxact:name>\"\r\n            \"<ipxact:remapPorts>\"\r\n                \"<ipxact:remapPort portRef=\\\"referencedPort\\\">\"\r\n                    \"<ipxact:value>newValue</ipxact:value>\"\r\n                \"</ipxact:remapPort>\"\r\n                \"<ipxact:remapPort portRef=\\\"Fuu\\\">\"\r\n                    \"<ipxact:portIndex>Mugen</ipxact:portIndex>\"\r\n                    \"<ipxact:value>Jin</ipxact:value>\"\r\n                \"</ipxact:remapPort>\"\r\n            \"</ipxact:remapPorts>\"\r\n        \"</ipxact:remapState>\"\r\n        );\r\n\r\n    RemapStateWriter::writeRemapState(xmlStreamWriter, testRemapState_);\r\n    QCOMPARE(output, expectedOutput);\r\n}\r\n\r\nQTEST_APPLESS_MAIN(tst_RemapStateWriter)\r\n\r\n#include \"tst_RemapStateWriter.moc\"\r\n"
  },
  {
    "path": "tests/IPXACTmodels/Component/tst_RemapStateWriter.pri",
    "content": "# ----------------------------------------------------\r\n# This file is generated by the Qt Visual Studio Add-in.\r\n# ------------------------------------------------------\r\n\r\nSOURCES += ./tst_RemapStateWriter.cpp \r\n"
  },
  {
    "path": "tests/IPXACTmodels/Component/tst_RemapStateWriter.pro",
    "content": "#-----------------------------------------------------------------------------\r\n# File: tst_RemapStateWriter.pro\r\n#-----------------------------------------------------------------------------\r\n# Project: Kactus 2\r\n# Author: Mikko Teuho\r\n# Date: 23.09.2015\r\n#\r\n# Description:\r\n# Qt project file template for running unit tests for remap state writer.\r\n#-----------------------------------------------------------------------------\r\n\r\nTEMPLATE = app\r\n\r\nTARGET = tst_RemapStateWriter\r\n\r\nQT += core xml testlib\r\nQT -= gui\r\n\r\nCONFIG += c++11 testcase console\r\n\r\nlinux-g++ | linux-g++-64 | linux-g++-32 {\r\n LIBS += -L../../../executable \\\r\n     -lIPXACTmodels\r\n}\r\nwin64 | win32 {\r\n LIBS += -L../../../x64/executable \\\r\n     -lIPXACTmodelsd\r\n}\r\n\r\nINCLUDEPATH += $$DESTDIR\r\nINCLUDEPATH += ../../../\r\n\r\nDEPENDPATH += .\r\nDEPENDPATH += ../../../\r\n\r\nOBJECTS_DIR += $$DESTDIR\r\n\r\nMOC_DIR += ./generatedFiles\r\nUI_DIR += ./generatedFiles\r\nRCC_DIR += ./generatedFiles\r\ninclude(tst_RemapStateWriter.pri)\r\n"
  },
  {
    "path": "tests/IPXACTmodels/Component/tst_ViewReader.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: tst_ViewReader.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 04.09.2015\r\n//\r\n// Description:\r\n// Unit test for class ViewReader.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include <IPXACTmodels/Component/View.h>\r\n#include <IPXACTmodels/Component/ViewReader.h>\r\n#include <IPXACTmodels/common/Document.h>\r\n\r\n#include <QtTest>\r\n\r\nclass tst_ViewReader : public QObject\r\n{\r\n    Q_OBJECT\r\n\r\npublic:\r\n    tst_ViewReader();\r\n\r\nprivate slots:\r\n\r\n    void testReadSimpleView();\r\n    void testReadView2022();\r\n\tvoid testReadIsPresent();\r\n\tvoid testReadEnvIdentifiers();\r\n\tvoid testReadMalformedEnvIdentifiers();\r\n\tvoid testReadMalformedEnvIdentifiers2();\r\n    void testReadComponentInstantiationRef();\r\n    void testReadDesignInstantiationRef();\r\n    void testReadDesignConfigurationInstantiationRef();\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ViewReader::tst_ViewReader()\r\n//-----------------------------------------------------------------------------\r\ntst_ViewReader::tst_ViewReader()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ViewReader::testReadSimpleView()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ViewReader::testReadSimpleView()\r\n{\r\n    QString documentContent(\r\n        \"<ipxact:view>\"\r\n            \"<ipxact:name>testView</ipxact:name>\"\r\n            \"<ipxact:displayName>viewDisplay</ipxact:displayName>\"\r\n            \"<ipxact:description>viewDescription</ipxact:description>\"\r\n        \"</ipxact:view>\"\r\n        );\r\n\r\n\r\n    QDomDocument document;\r\n    document.setContent(documentContent);\r\n\r\n    QDomNode viewNode = document.firstChildElement(\"ipxact:view\");\r\n\r\n    QSharedPointer<View> testView = ViewReader::createViewFrom(viewNode, Document::Revision::Std14);\r\n\r\n    QCOMPARE(testView->name(), QString(\"testView\"));\r\n    QCOMPARE(testView->displayName(), QString(\"viewDisplay\"));\r\n    QCOMPARE(testView->description(), QString(\"viewDescription\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ViewReader::testReadSimpleView2022()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ViewReader::testReadView2022()\r\n{\r\n    QString documentContent(\r\n        \"<ipxact:view>\"\r\n            \"<ipxact:name>testView</ipxact:name>\"\r\n            \"<ipxact:displayName>viewDisplay</ipxact:displayName>\"\r\n            \"<ipxact:shortDescription>short desc</ipxact:shortDescription>\"\r\n            \"<ipxact:description>viewDescription</ipxact:description>\"\r\n            \"<ipxact:isPresent>4-3</ipxact:isPresent>\"\r\n            \"<ipxact:vendorExtensions>\"\r\n                \"<testExtension vendorAttribute=\\\"extension\\\">testValue</testExtension>\"\r\n            \"</ipxact:vendorExtensions>\"\r\n        \"</ipxact:view>\"\r\n    );\r\n\r\n    QDomDocument document;\r\n    document.setContent(documentContent);\r\n\r\n    QDomNode viewNode = document.firstChildElement(\"ipxact:view\");\r\n\r\n    QSharedPointer<View> testView = ViewReader::createViewFrom(viewNode, Document::Revision::Std14);\r\n\r\n    QCOMPARE(testView->name(), QString(\"testView\"));\r\n    QCOMPARE(testView->displayName(), QString(\"viewDisplay\"));\r\n    QCOMPARE(testView->shortDescription(), QString(\"short desc\"));\r\n    QCOMPARE(testView->description(), QString(\"viewDescription\"));\r\n    QCOMPARE(testView->getIsPresent(), QString(\"4-3\"));\r\n    QCOMPARE(testView->getVendorExtensions()->size(), 0);\r\n\r\n    testView = ViewReader::createViewFrom(viewNode, Document::Revision::Std22);\r\n\r\n    QCOMPARE(testView->name(), QString(\"testView\"));\r\n    QCOMPARE(testView->displayName(), QString(\"viewDisplay\"));\r\n    QCOMPARE(testView->shortDescription(), QString(\"short desc\"));\r\n    QCOMPARE(testView->description(), QString(\"viewDescription\"));\r\n    QCOMPARE(testView->getIsPresent(), QString(\"\"));\r\n\r\n    auto vendorExtensions = testView->getVendorExtensions();\r\n\r\n    QCOMPARE(vendorExtensions->size(), 1);\r\n    QCOMPARE(vendorExtensions->first()->type(), QString(\"testExtension\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ViewReader::testReadIsPresent()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ViewReader::testReadIsPresent()\r\n{\r\n    QString documentContent(\r\n        \"<ipxact:view>\"\r\n            \"<ipxact:name>testView</ipxact:name>\"\r\n            \"<ipxact:isPresent>4-3</ipxact:isPresent>\"\r\n        \"</ipxact:view>\"\r\n        );\r\n\r\n\r\n    QDomDocument document;\r\n    document.setContent(documentContent);\r\n\r\n    QDomNode viewNode = document.firstChildElement(\"ipxact:view\");\r\n\r\n    QSharedPointer<View> testView = ViewReader::createViewFrom(viewNode, Document::Revision::Std14);\r\n\r\n    QCOMPARE(testView->name(), QString(\"testView\"));\r\n    QCOMPARE(testView->getIsPresent(), QString(\"4-3\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ViewReader::testReadEnvIdentifiers()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ViewReader::testReadEnvIdentifiers()\r\n{\r\n    QString documentContent(\r\n        \"<ipxact:view>\"\r\n            \"<ipxact:name>testView</ipxact:name>\"\r\n\t\t\t\"<ipxact:envIdentifier>environmentIdentifier:tool:vendorX</ipxact:envIdentifier>\"\r\n            \"<ipxact:envIdentifier>otherEnvironment:otherTool:vendorY</ipxact:envIdentifier>\"\r\n        \"</ipxact:view>\"\r\n        );\r\n\r\n\r\n    QDomDocument document;\r\n    document.setContent(documentContent);\r\n\r\n    QDomNode viewNode = document.firstChildElement(\"ipxact:view\");\r\n\r\n    QSharedPointer<View> testView = ViewReader::createViewFrom(viewNode, Document::Revision::Std14);\r\n\r\n    QCOMPARE(testView->name(), QString(\"testView\"));\r\n\r\n    QCOMPARE(testView->getEnvIdentifiers()->size(), 2);\r\n    QCOMPARE(testView->getEnvIdentifiers()->first()->toString(), QString(\"environmentIdentifier:tool:vendorX\"));\r\n    QCOMPARE(testView->getEnvIdentifiers()->last()->toString(), QString(\"otherEnvironment:otherTool:vendorY\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ViewReader::testReadMalformedEnvIdentifiers()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ViewReader::testReadMalformedEnvIdentifiers()\r\n{\r\n\tQString documentContent(\r\n\t\t\"<ipxact:view>\"\r\n\t\t\"<ipxact:name>testView</ipxact:name>\"\r\n\t\t\"<ipxact:envIdentifier>environmentIdentifier</ipxact:envIdentifier>\"\r\n\t\t\"<ipxact:envIdentifier>otherEnvironment</ipxact:envIdentifier>\"\r\n\t\t\"</ipxact:view>\"\r\n\t\t);\r\n\r\n\r\n\tQDomDocument document;\r\n\tdocument.setContent(documentContent);\r\n\r\n\tQDomNode viewNode = document.firstChildElement(\"ipxact:view\");\r\n\r\n\tQSharedPointer<View> testView = ViewReader::createViewFrom(viewNode, Document::Revision::Std14);\r\n\r\n\tQCOMPARE(testView->name(), QString(\"testView\"));\r\n\r\n\tQCOMPARE(testView->getEnvIdentifiers()->size(), 2);\r\n\tQCOMPARE(testView->getEnvIdentifiers()->first()->toString(), QString(\"environmentIdentifier::\"));\r\n\tQCOMPARE(testView->getEnvIdentifiers()->last()->toString(), QString(\"otherEnvironment::\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ViewReader::testReadMalformedEnvIdentifiers2()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ViewReader::testReadMalformedEnvIdentifiers2()\r\n{\r\n\tQString documentContent(\r\n\t\t\"<ipxact:view>\"\r\n\t\t\"<ipxact:name>testView</ipxact:name>\"\r\n\t\t\"<ipxact:envIdentifier>environmentIdentifier:tool</ipxact:envIdentifier>\"\r\n\t\t\"<ipxact:envIdentifier>otherEnvironment:otherTool</ipxact:envIdentifier>\"\r\n\t\t\"</ipxact:view>\"\r\n\t\t);\r\n\r\n\r\n\tQDomDocument document;\r\n\tdocument.setContent(documentContent);\r\n\r\n\tQDomNode viewNode = document.firstChildElement(\"ipxact:view\");\r\n\r\n\tQSharedPointer<View> testView = ViewReader::createViewFrom(viewNode, Document::Revision::Std14);\r\n\r\n\tQCOMPARE(testView->name(), QString(\"testView\"));\r\n\r\n\tQCOMPARE(testView->getEnvIdentifiers()->size(), 2);\r\n\tQCOMPARE(testView->getEnvIdentifiers()->first()->toString(), QString(\"environmentIdentifier:tool:\"));\r\n\tQCOMPARE(testView->getEnvIdentifiers()->last()->toString(), QString(\"otherEnvironment:otherTool:\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ViewReader::testReadComponentInstantiationRef()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ViewReader::testReadComponentInstantiationRef()\r\n{\r\n    QString documentContent(\r\n        \"<ipxact:view>\"\r\n            \"<ipxact:name>testView</ipxact:name>\"\r\n            \"<ipxact:componentInstantiationRef>instantiation</ipxact:componentInstantiationRef>\"\r\n        \"</ipxact:view>\"\r\n        );\r\n\r\n\r\n    QDomDocument document;\r\n    document.setContent(documentContent);\r\n\r\n    QDomNode viewNode = document.firstChildElement(\"ipxact:view\");\r\n\r\n    QSharedPointer<View> testView = ViewReader::createViewFrom(viewNode, Document::Revision::Std14);\r\n\r\n    QCOMPARE(testView->name(), QString(\"testView\"));\r\n    QCOMPARE(testView->getComponentInstantiationRef(), QString(\"instantiation\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ViewReader::testReadDesignInstantiationRef()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ViewReader::testReadDesignInstantiationRef()\r\n{\r\n    QString documentContent(\r\n        \"<ipxact:view>\"\r\n            \"<ipxact:name>testView</ipxact:name>\"\r\n            \"<ipxact:designInstantiationRef>instantiation</ipxact:designInstantiationRef>\"\r\n        \"</ipxact:view>\"\r\n        );\r\n\r\n\r\n    QDomDocument document;\r\n    document.setContent(documentContent);\r\n\r\n    QDomNode viewNode = document.firstChildElement(\"ipxact:view\");\r\n\r\n    QSharedPointer<View> testView = ViewReader::createViewFrom(viewNode, Document::Revision::Std14);\r\n\r\n    QCOMPARE(testView->name(), QString(\"testView\"));\r\n    QCOMPARE(testView->getDesignInstantiationRef(), QString(\"instantiation\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ViewReader::testReadDesignConfigurationInstantiationRef()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ViewReader::testReadDesignConfigurationInstantiationRef()\r\n{\r\n    QString documentContent(\r\n        \"<ipxact:view>\"\r\n            \"<ipxact:name>testView</ipxact:name>\"\r\n            \"<ipxact:designConfigurationInstantiationRef>instantiation</ipxact:designConfigurationInstantiationRef>\"\r\n        \"</ipxact:view>\"\r\n        );\r\n\r\n\r\n    QDomDocument document;\r\n    document.setContent(documentContent);\r\n\r\n    QDomNode viewNode = document.firstChildElement(\"ipxact:view\");\r\n\r\n    QSharedPointer<View> testView = ViewReader::createViewFrom(viewNode, Document::Revision::Std14);\r\n\r\n    QCOMPARE(testView->name(), QString(\"testView\"));\r\n    QCOMPARE(testView->getDesignConfigurationInstantiationRef(), QString(\"instantiation\"));\r\n}\r\n\r\nQTEST_APPLESS_MAIN(tst_ViewReader)\r\n\r\n#include \"tst_ViewReader.moc\"\r\n"
  },
  {
    "path": "tests/IPXACTmodels/Component/tst_ViewReader.pri",
    "content": "# ----------------------------------------------------\r\n# This file is generated by the Qt Visual Studio Tools.\r\n# ------------------------------------------------------\r\n\r\nSOURCES += ./tst_ViewReader.cpp \r\n"
  },
  {
    "path": "tests/IPXACTmodels/Component/tst_ViewReader.pro",
    "content": "#-----------------------------------------------------------------------------\r\n# File: ViewReader.pro\r\n#-----------------------------------------------------------------------------\r\n# Project: Kactus 2\r\n# Author: Mikko Teuho\r\n# Date: 04.09.2015\r\n#\r\n# Description:\r\n# Qt project file template for running unit tests for ViewReader.\r\n#-----------------------------------------------------------------------------\r\n\r\nTEMPLATE = app\r\n\r\nTARGET = tst_ViewReader\r\n\r\nQT += core xml testlib\r\nQT -= gui\r\n\r\nCONFIG += c++11 testcase console\r\n\r\nlinux-g++ | linux-g++-64 | linux-g++-32 {\r\n LIBS += -L../../../executable \\\r\n     -lIPXACTmodels \\\r\n}\r\nwin64 | win32 {\r\n LIBS += -L../../../executable \\\r\n     -lIPXACTmodelsd \\\r\n}\r\n\r\nINCLUDEPATH += $$DESTDIR\r\nINCLUDEPATH += ../../../\r\n\r\nDEPENDPATH += .\r\nDEPENDPATH += ../../../\r\n\r\nOBJECTS_DIR += $$DESTDIR\r\n\r\nMOC_DIR += ./generatedFiles\r\nUI_DIR += ./generatedFiles\r\nRCC_DIR += ./generatedFiles\r\ninclude(tst_ViewReader.pri)\r\n"
  },
  {
    "path": "tests/IPXACTmodels/Component/tst_ViewValidator.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// View: tst_ViewValidator.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Janne Virtanen\r\n// Date: 24.11.2015\r\n//\r\n// Description:\r\n// Unit test for class ViewValidator.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include <IPXACTmodels/Component/validators/ViewValidator.h>\r\n\r\n#include <IPXACTmodels/Component/View.h>\r\n#include <IPXACTmodels/Component/Model.h>\r\n\r\n#include <KactusAPI/include/SystemVerilogExpressionParser.h>\r\n\r\n#include <QtTest>\r\n\r\nclass tst_ViewValidator : public QObject\r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n    tst_ViewValidator();\r\n\r\nprivate slots:\r\n\tvoid baseCase();\r\n\tvoid nameFail();\r\n\tvoid presenceFail();\r\n\tvoid envId();\r\n\tvoid instantiationsNotExist();\r\n\tvoid instantiationsExist();\r\n\r\nprivate:\r\n\t\r\n    QSharedPointer<Model> model_;\r\n\r\n    QSharedPointer<ExpressionParser> parser_;\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ViewValidator::tst_ViewValidator()\r\n//-----------------------------------------------------------------------------\r\ntst_ViewValidator::tst_ViewValidator()\r\n{\r\n\tmodel_ = QSharedPointer<Model>( new Model );\r\n\r\n    parser_ = QSharedPointer<ExpressionParser>(new SystemVerilogExpressionParser());\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ViewValidator::baseCase()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ViewValidator::baseCase()\r\n{\r\n\tQSharedPointer<View> view( new View );\r\n\tViewValidator validator(parser_, model_);\r\n\r\n\tview->setName(\"joq\");\r\n\r\n\tQVector<QString> errorList;\r\n\tvalidator.findErrorsIn(errorList, view, \"test\");\r\n\r\n\tQCOMPARE( errorList.size(), 0 );\r\n\tQVERIFY( validator.validate(view) );\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ViewValidator::nameFail()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ViewValidator::nameFail()\r\n{\r\n\tQSharedPointer<View> view( new View );\r\n\tViewValidator validator(parser_, model_);\r\n\r\n\tview->setName(\" \\t\");\r\n\r\n\tQVector<QString> errorList;\r\n\tvalidator.findErrorsIn(errorList, view, \"test\");\r\n\r\n\tQCOMPARE( errorList.size(), 1 );\r\n\tQVERIFY( !validator.validate(view) );\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ViewValidator::presenceFail()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ViewValidator::presenceFail()\r\n{\r\n\tQSharedPointer<View> view( new View );\r\n\tViewValidator validator(parser_, model_);\r\n\r\n\tview->setName(\"esa\");\r\n\tview->setIsPresent(\"foo\");\r\n\r\n\tQVector<QString> errorList;\r\n\tvalidator.findErrorsIn(errorList, view, \"test\");\r\n\r\n\tQCOMPARE( errorList.size(), 1 );\r\n\tQVERIFY( !validator.validate(view) );\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ViewValidator::envId()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ViewValidator::envId()\r\n{\r\n\tQSharedPointer<View> view( new View );\r\n\tViewValidator validator(parser_, model_);\r\n\r\n\tview->setName(\"esa\");\r\n\r\n\tQStringList envIds;\r\n\tQSharedPointer<View::EnvironmentIdentifier> identifier1( new View::EnvironmentIdentifier );\r\n\tidentifier1->language = \"1\";\r\n\tidentifier1->tool = \"2\";\r\n\tidentifier1->vendorSpecific = \"3\";\r\n\tview->addEnvIdentifier(identifier1);\r\n\tQSharedPointer<View::EnvironmentIdentifier> identifier2( new View::EnvironmentIdentifier );\r\n\tidentifier2->language = \"[]\";\r\n\tidentifier2->tool = \"2\";\r\n\tidentifier2->vendorSpecific = \"3\";\r\n\tview->addEnvIdentifier(identifier2);\r\n\tQSharedPointer<View::EnvironmentIdentifier> identifier3( new View::EnvironmentIdentifier );\r\n\tidentifier3->language = \"%\";\r\n\tview->addEnvIdentifier(identifier3);\r\n\r\n\tQVector<QString> errorList;\r\n\tvalidator.findErrorsIn(errorList, view, \"test\");\r\n\r\n\tQCOMPARE( errorList.size(), 0 );\r\n\tQVERIFY( validator.validate(view) );\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ViewValidator::instantiationsNotExist()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ViewValidator::instantiationsNotExist()\r\n{\r\n\tQSharedPointer<View> view( new View );\r\n\tViewValidator validator(parser_, model_);\r\n\r\n\tview->setName(\"esa\");\r\n\r\n\tview->setComponentInstantiationRef(\"bogus\");\r\n\tview->setDesignInstantiationRef(\"inexisting\");\r\n\tview->setDesignConfigurationInstantiationRef(\"nil\");\r\n\r\n\tQVector<QString> errorList;\r\n\tvalidator.findErrorsIn(errorList, view, \"test\");\r\n\r\n\tQCOMPARE( errorList.size(), 3 );\r\n\tQVERIFY( !validator.validate(view) );\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ViewValidator::instantiationsExist()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ViewValidator::instantiationsExist()\r\n{\r\n\tQSharedPointer<ComponentInstantiation> cimp( new ComponentInstantiation(\"eka\") );\r\n\tmodel_->getComponentInstantiations()->append( cimp );\r\n\r\n\tQSharedPointer<DesignInstantiation> di( new DesignInstantiation(\"toka\") );\r\n\tmodel_->getDesignInstantiations()->append(di);\r\n\r\n\tQSharedPointer<DesignConfigurationInstantiation> dci( new DesignConfigurationInstantiation(\"kolmas\") );\r\n\tmodel_->getDesignConfigurationInstantiations()->append(dci);\r\n\r\n    QSharedPointer<View> view( new View );\r\n    view->setName(\"esa\");\r\n    view->setComponentInstantiationRef(cimp->name());\r\n    view->setDesignInstantiationRef(di->name());\r\n    view->setDesignConfigurationInstantiationRef(dci->name());\r\n\r\n    ViewValidator validator(parser_, model_);\r\n\r\n\tQVector<QString> errorList;\r\n\tvalidator.findErrorsIn(errorList, view, \"test\");\r\n\r\n\tQCOMPARE( errorList.size(), 0 );\r\n\tQVERIFY( validator.validate(view) );\r\n}\r\n\r\nQTEST_APPLESS_MAIN(tst_ViewValidator)\r\n\r\n#include \"tst_ViewValidator.moc\"\r\n"
  },
  {
    "path": "tests/IPXACTmodels/Component/tst_ViewValidator.pri",
    "content": "# ----------------------------------------------------\r\n# This file is generated by the Qt Visual Studio Tools.\r\n# ------------------------------------------------------\r\n\t\r\nSOURCES += ./tst_ViewValidator.cpp \r\n\t"
  },
  {
    "path": "tests/IPXACTmodels/Component/tst_ViewValidator.pro",
    "content": "#-----------------------------------------------------------------------------\r\n# View: tst_ViewValidator.pro\r\n#-----------------------------------------------------------------------------\r\n# Project: Kactus 2\r\n# Author: Janne Virtanen\r\n# Date: 24.11.2015\r\n#\r\n# Description:\r\n# Qt project View template for running unit tests for Enumerated Value Validator.\r\n#-----------------------------------------------------------------------------\r\n\r\nTEMPLATE = app\r\n\r\nTARGET = tst_ViewValidator\r\n\r\nQT += core xml testlib\r\nQT -= gui\r\n\r\nCONFIG += c++11 testcase console\r\n\r\nlinux-g++ | linux-g++-64 | linux-g++-32 {\r\n LIBS += -L../../../executable \\\r\n     -lIPXACTmodels -lKactusAPI\r\n}\r\n\r\nwin64 | win32 {\r\n LIBS += -L../../../executable \\\r\n     -lIPXACTmodelsd -lKactusAPId\r\n}\r\n\r\nINCLUDEPATH += $$DESTDIR\r\nINCLUDEPATH += ../../../\r\nINCLUDEPATH += ../../../KactusAPI/include\r\n\r\nDEPENDPATH += .\r\nDEPENDPATH += ../../../\r\n\r\nOBJECTS_DIR += $$DESTDIR\r\n\r\nMOC_DIR += ./generatedFiles\r\nUI_DIR += ./generatedFiles\r\nRCC_DIR += ./generatedFiles\r\ninclude(tst_ViewValidator.pri)\r\n"
  },
  {
    "path": "tests/IPXACTmodels/Component/tst_ViewWriter.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: tst_ViewWriter.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 03.09.2015\r\n//\r\n// Description:\r\n// Unit test for class ViewWriter.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include <IPXACTmodels/Component/View.h>\r\n#include <IPXACTmodels/Component/ViewWriter.h>\r\n\r\n#include <IPXACTmodels/common/GenericVendorExtension.h>\r\n\r\n#include <QtTest>\r\n#include <QDomDocument>\r\n\r\nclass tst_ViewWriter : public QObject\r\n{\r\n    Q_OBJECT\r\n\r\npublic:\r\n    tst_ViewWriter();\r\n\r\nprivate slots:\r\n\r\n    void initTestCase();\r\n    void cleanupTestCase();\r\n    void init();\r\n    void cleanup();\r\n\r\n    void testWriteViewNameGroup();\r\n    void testWriteIsPresent();\r\n    void testWriteEnvIdentifiers();\r\n    void testWriteComponentInstantiationRef();\r\n    void testWriteDesignInstantiationRef();\r\n    void testWriteDesignConfigurationInstantiationRef();\r\n    void testWriteVendorExtensions();\r\n\r\nprivate:\r\n\r\n    QSharedPointer<View> testView_;\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ViewWriter::tst_ViewWriter()\r\n//-----------------------------------------------------------------------------\r\ntst_ViewWriter::tst_ViewWriter():\r\ntestView_()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ViewWriter::initTestCase()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ViewWriter::initTestCase()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ViewWriter::cleanupTestCase()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ViewWriter::cleanupTestCase()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ViewWriter::init()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ViewWriter::init()\r\n{\r\n    testView_ = QSharedPointer<View>(new View(\"testView\", \"\", \"\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ViewWriter::cleanup()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ViewWriter::cleanup()\r\n{\r\n    testView_.clear();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ViewWriter::testWriteSimpleView()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ViewWriter::testWriteViewNameGroup()\r\n{\r\n    QString output;\r\n    QXmlStreamWriter xmlStreamWriter(&output);\r\n\r\n    QString expectedOutput(\r\n        \"<ipxact:view>\"\r\n            \"<ipxact:name>testView</ipxact:name>\"\r\n        \"</ipxact:view>\"\r\n        );\r\n\r\n    ViewWriter::writeView(xmlStreamWriter, testView_, Document::Revision::Std14);\r\n    QCOMPARE(output, expectedOutput);\r\n\r\n    expectedOutput.clear();\r\n    output.clear();\r\n\r\n    testView_->setDisplayName(\"testDisplay\");\r\n    expectedOutput = \r\n        \"<ipxact:view>\"\r\n            \"<ipxact:name>testView</ipxact:name>\"\r\n            \"<ipxact:displayName>testDisplay</ipxact:displayName>\"\r\n        \"</ipxact:view>\"\r\n        ;\r\n\r\n    ViewWriter::writeView(xmlStreamWriter, testView_, Document::Revision::Std14);\r\n    QCOMPARE(output, expectedOutput);\r\n\r\n    output.clear();\r\n    expectedOutput.clear();\r\n\r\n    testView_->setDescription(\"testDescription\");\r\n    testView_->setShortDescription(\"shortDescription\");\r\n    expectedOutput = \r\n        \"<ipxact:view>\"\r\n            \"<ipxact:name>testView</ipxact:name>\"\r\n            \"<ipxact:displayName>testDisplay</ipxact:displayName>\"\r\n            \"<ipxact:description>testDescription</ipxact:description>\"\r\n        \"</ipxact:view>\"\r\n        ;\r\n\r\n    ViewWriter::writeView(xmlStreamWriter, testView_, Document::Revision::Std14);\r\n    QCOMPARE(output, expectedOutput);\r\n\r\n    output.clear();\r\n    expectedOutput.clear();\r\n\r\n    expectedOutput = \r\n        \"<ipxact:view>\"\r\n            \"<ipxact:name>testView</ipxact:name>\"\r\n            \"<ipxact:displayName>testDisplay</ipxact:displayName>\"\r\n            \"<ipxact:shortDescription>shortDescription</ipxact:shortDescription>\"\r\n            \"<ipxact:description>testDescription</ipxact:description>\"\r\n        \"</ipxact:view>\"\r\n        ;\r\n\r\n    ViewWriter::writeView(xmlStreamWriter, testView_, Document::Revision::Std22);\r\n    QCOMPARE(output, expectedOutput);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ViewWriter::testWriteIsPresent()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ViewWriter::testWriteIsPresent()\r\n{\r\n    QString output;\r\n    QXmlStreamWriter xmlStreamWriter(&output);\r\n\r\n    testView_->setIsPresent(\"4-3\");\r\n\r\n    QString expectedOutput(\r\n        \"<ipxact:view>\"\r\n            \"<ipxact:name>testView</ipxact:name>\"\r\n            \"<ipxact:isPresent>4-3</ipxact:isPresent>\"\r\n        \"</ipxact:view>\"\r\n        );\r\n\r\n    ViewWriter::writeView(xmlStreamWriter, testView_, Document::Revision::Std14);\r\n\r\n    QCOMPARE(output, expectedOutput);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ViewWriter::testWriteEnvIdentifiers()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ViewWriter::testWriteEnvIdentifiers()\r\n{\r\n    QString output;\r\n    QXmlStreamWriter xmlStreamWriter(&output);\r\n\r\n\tQSharedPointer<View::EnvironmentIdentifier> identifier1( new View::EnvironmentIdentifier );\r\n\tidentifier1->language = \"language\";\r\n\tidentifier1->tool = \"tool\";\r\n\tidentifier1->vendorSpecific = \"vendor\";\r\n\ttestView_->addEnvIdentifier(identifier1);\r\n\r\n\tQSharedPointer<View::EnvironmentIdentifier> identifier2( new View::EnvironmentIdentifier );\r\n\tidentifier2->language = \"otherLanguage\";\r\n\tidentifier2->tool = \"otherTool\";\r\n\tidentifier2->vendorSpecific = \"otherVendor\";\r\n\ttestView_->addEnvIdentifier(identifier2);\r\n\r\n    QString expectedOutput(\r\n        \"<ipxact:view>\"\r\n            \"<ipxact:name>testView</ipxact:name>\"\r\n            \"<ipxact:envIdentifier>language:tool:vendor</ipxact:envIdentifier>\"\r\n            \"<ipxact:envIdentifier>otherLanguage:otherTool:otherVendor</ipxact:envIdentifier>\"\r\n        \"</ipxact:view>\"\r\n        );\r\n\r\n    ViewWriter::writeView(xmlStreamWriter, testView_, Document::Revision::Std14);\r\n\r\n    QCOMPARE(output, expectedOutput);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ViewWriter::testWriteComponentInstantiationRef()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ViewWriter::testWriteComponentInstantiationRef()\r\n{\r\n    QString output;\r\n    QXmlStreamWriter xmlStreamWriter(&output);\r\n\r\n    testView_->setComponentInstantiationRef(\"componentInstantiation\");\r\n\r\n    QString expectedOutput(\r\n        \"<ipxact:view>\"\r\n            \"<ipxact:name>testView</ipxact:name>\"\r\n            \"<ipxact:componentInstantiationRef>componentInstantiation</ipxact:componentInstantiationRef>\"\r\n        \"</ipxact:view>\"\r\n        );\r\n\r\n    ViewWriter::writeView(xmlStreamWriter, testView_, Document::Revision::Std14);\r\n\r\n    QCOMPARE(output, expectedOutput);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ViewWriter::testWriteDesignInstantiationRef()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ViewWriter::testWriteDesignInstantiationRef()\r\n{\r\n    QString output;\r\n    QXmlStreamWriter xmlStreamWriter(&output);\r\n\r\n    testView_->setDesignInstantiationRef(\"designInstantiation\");\r\n\r\n    QString expectedOutput(\r\n        \"<ipxact:view>\"\r\n            \"<ipxact:name>testView</ipxact:name>\"\r\n            \"<ipxact:designInstantiationRef>designInstantiation</ipxact:designInstantiationRef>\"\r\n        \"</ipxact:view>\"\r\n        );\r\n\r\n    ViewWriter::writeView(xmlStreamWriter, testView_, Document::Revision::Std14);\r\n\r\n    QCOMPARE(output, expectedOutput);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ViewWriter::testWriteDesignConfigurationInstantiationRef()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ViewWriter::testWriteDesignConfigurationInstantiationRef()\r\n{\r\n    QString output;\r\n    QXmlStreamWriter xmlStreamWriter(&output);\r\n\r\n    testView_->setDesignConfigurationInstantiationRef(\"instantiation\");\r\n\r\n    QString expectedOutput(\r\n        \"<ipxact:view>\"\r\n            \"<ipxact:name>testView</ipxact:name>\"\r\n            \"<ipxact:designConfigurationInstantiationRef>instantiation</ipxact:designConfigurationInstantiationRef>\"\r\n        \"</ipxact:view>\"\r\n        );\r\n\r\n    ViewWriter::writeView(xmlStreamWriter, testView_, Document::Revision::Std14);\r\n\r\n    QCOMPARE(output, expectedOutput);\r\n}\r\n\r\nQTEST_APPLESS_MAIN(tst_ViewWriter)\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ViewWriter::testWriteVendorExtensions()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ViewWriter::testWriteVendorExtensions()\r\n{\r\n    QDomDocument document;\r\n    QDomElement extensionNode = document.createElement(\"ulina\");\r\n    extensionNode.setAttribute(\"kolina\", \"eaa\");\r\n    extensionNode.appendChild(document.createTextNode(\"testValue\"));\r\n\r\n    QSharedPointer<GenericVendorExtension> testExtension(new GenericVendorExtension(extensionNode));\r\n\r\n    testView_->getVendorExtensions()->append(testExtension);\r\n    \r\n    QString expectedOutput14(\r\n        \"<ipxact:view>\"\r\n            \"<ipxact:name>testView</ipxact:name>\"\r\n        \"</ipxact:view>\");\r\n\r\n    QString expectedOutput22(\r\n        \"<ipxact:view>\"\r\n            \"<ipxact:name>testView</ipxact:name>\"\r\n            \"<ipxact:vendorExtensions>\"\r\n                \"<ulina kolina=\\\"eaa\\\">testValue</ulina>\"\r\n            \"</ipxact:vendorExtensions>\"\r\n        \"</ipxact:view>\");\r\n\r\n    QString output;\r\n    QXmlStreamWriter xmlStreamWriter(&output);\r\n\r\n    ViewWriter::writeView(xmlStreamWriter, testView_, Document::Revision::Std14);\r\n    QCOMPARE(output, expectedOutput14);\r\n\r\n    output.clear();\r\n\r\n    ViewWriter::writeView(xmlStreamWriter, testView_, Document::Revision::Std22);\r\n    QCOMPARE(output, expectedOutput22);\r\n}\r\n\r\n#include \"tst_ViewWriter.moc\"\r\n"
  },
  {
    "path": "tests/IPXACTmodels/Component/tst_ViewWriter.pri",
    "content": "# ----------------------------------------------------\r\n# This file is generated by the Qt Visual Studio Tools.\r\n# ------------------------------------------------------\r\n\r\nSOURCES += ./tst_ViewWriter.cpp\r\n"
  },
  {
    "path": "tests/IPXACTmodels/Component/tst_ViewWriter.pro",
    "content": "#-----------------------------------------------------------------------------\r\n# File: tst_ViewWriter.pro\r\n#-----------------------------------------------------------------------------\r\n# Project: Kactus 2\r\n# Author: Mikko Teuho\r\n# Date: 03.09.2015\r\n#\r\n# Description:\r\n# Qt project file template for running unit tests for View Writer.\r\n#-----------------------------------------------------------------------------\r\n\r\nTEMPLATE = app\r\n\r\nTARGET = tst_ViewWriter\r\n\r\nQT += core xml testlib\r\nQT -= gui\r\n\r\nCONFIG += c++11 testcase console\r\n\r\nlinux-g++ | linux-g++-64 | linux-g++-32 {\r\n LIBS += -L../../../executable \\\r\n     -lIPXACTmodels\r\n}\r\nwin64 | win32 {\r\n LIBS += -L../../../executable \\\r\n     -lIPXACTmodelsd\r\n}\r\n\r\nINCLUDEPATH += $$DESTDIR\r\nINCLUDEPATH += ../../../\r\n\r\nDEPENDPATH += .\r\nDEPENDPATH += ../../../\r\n\r\nOBJECTS_DIR += $$DESTDIR\r\n\r\nMOC_DIR += ./generatedFiles\r\nUI_DIR += ./generatedFiles\r\nRCC_DIR += ./generatedFiles\r\ninclude(tst_ViewWriter.pri)\r\n"
  },
  {
    "path": "tests/IPXACTmodels/Design/Design.pro",
    "content": "#-----------------------------------------------------------------------------\n# File: BusDefinition.pro\n#-----------------------------------------------------------------------------\n# Project: Kactus2\n# Author: Esko Pekkarinen\n# Date: 04.05.2018\n#\n# Description:\n# Qt project file template for running unit tests for Design.\n#-----------------------------------------------------------------------------\n\nTEMPLATE = subdirs\n\nCONFIG += testcase\nSUBDIRS += tst_DesignReader.pro \\\n\t       tst_DesignWriter.pro \\\n\t\t   tst_DesignValidator.pro\n"
  },
  {
    "path": "tests/IPXACTmodels/Design/tst_DesignReader.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: tst_DesignReader.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 25.08.2015\r\n//\r\n// Description:\r\n// Unit test for class DesignReader.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include <IPXACTmodels/Design/DesignReader.h>\r\n\r\n#include <IPXACTmodels/kactusExtensions/Kactus2Placeholder.h>\r\n\r\n#include <editors/common/ColumnTypes.h>\r\n\r\n#include <QtTest>\r\n#include <QDomNode>\r\n\r\nclass tst_DesignReader : public QObject\r\n{\r\n    Q_OBJECT\r\n\r\npublic:\r\n    tst_DesignReader();\r\n\r\nprivate slots:\r\n    void testReadMinimalDesign();\r\n    void testReadMinimal2022Design();\r\n\r\n    void testReadProcessingInstructions();\r\n\r\n    void testReadComponentInstances();\r\n    void testRead2022ComponentInstances();\r\n    void testReadComponentInstanceExtensions();\r\n\r\n    void testReadInterconnections();\r\n    void testRead2022Interconnections();\r\n    void testReadInterconnectionExtensions();\r\n\r\n    void testReadMonitorInterconnections();\r\n    void testRead2022MonitorInterconnections();\r\n\r\n    void testReadAdHocConnections();\r\n    void testRead2022AdHocConnections();\r\n    void testRead2022AdHocSubPortReferences();\r\n    void testReadAdHocConnectionExtensions();\r\n\r\n    void testReadParameters();\r\n    void testReadAssertions();\r\n    void testReadVendorExtensions();\r\n\r\n    void testReadColumns();\r\n    void testReadSWInstances();\r\n    void testReadPortAdHocVisibilitiesAndPositions();\r\n    void testReadApiConnections();\r\n    void testReadHierApiConnections();\r\n    void testReadComConnections();\r\n    void testReadHierComConnections();\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_DesignReader::tst_DesignReader()\r\n//-----------------------------------------------------------------------------\r\ntst_DesignReader::tst_DesignReader()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_DesignReader::testReadMinimalDesign()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_DesignReader::testReadMinimalDesign()\r\n{\r\n    QString documentContent(\r\n        \"<ipxact:design xmlns:xsi=\\\"http://www.w3.org/2001/XMLSchema-instance\\\" \" \r\n        \"xmlns:ipxact=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014\\\" \"\r\n        \"xmlns:kactus2=\\\"http://kactus2.cs.tut.fi\\\" \"\r\n        \"xsi:schemaLocation=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/ \"\r\n        \"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/index.xsd\\\">\"\r\n            \"<ipxact:vendor>tuni.fi</ipxact:vendor>\"\r\n            \"<ipxact:library>TestLibrary</ipxact:library>\"\r\n            \"<ipxact:name>TestDesign</ipxact:name>\"\r\n            \"<ipxact:version>0.1</ipxact:version>\"\r\n            \"<ipxact:description>TestDescription</ipxact:description>\"\r\n        \"</ipxact:design>\");\r\n\r\n\r\n    QDomDocument document;\r\n    document.setContent(documentContent);\r\n\r\n    QSharedPointer<Design> testDesign = DesignReader::createDesignFrom(document);\r\n\r\n    QCOMPARE(testDesign->getRevision(), Document::Revision::Std14);\r\n    QCOMPARE(testDesign->getVlnv().getVendor(), QString(\"tuni.fi\"));\r\n    QCOMPARE(testDesign->getVlnv().getLibrary(), QString(\"TestLibrary\"));\r\n    QCOMPARE(testDesign->getVlnv().getName(), QString(\"TestDesign\"));\r\n    QCOMPARE(testDesign->getVlnv().getVersion(), QString(\"0.1\"));\r\n    QCOMPARE(testDesign->getDescription(), QString(\"TestDescription\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_DesignReader::testReadMinimal2022Design()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_DesignReader::testReadMinimal2022Design()\r\n{\r\n    QString documentContent(\r\n        \"<ipxact:design xmlns:xsi=\\\"http://www.w3.org/2001/XMLSchema-instance\\\" \"\r\n        \"xmlns:ipxact=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2022\\\" \"\r\n        \"xmlns:kactus2=\\\"http://kactus2.cs.tut.fi\\\" \"\r\n        \"xsi:schemaLocation=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2022/ \"\r\n        \"http://www.accellera.org/XMLSchema/IPXACT/1685-2022/index.xsd\\\">\"\r\n        \"<ipxact:vendor>tuni.fi</ipxact:vendor>\"\r\n        \"<ipxact:library>TestLibrary</ipxact:library>\"\r\n        \"<ipxact:name>TestDesign</ipxact:name>\"\r\n        \"<ipxact:version>0.1</ipxact:version>\"\r\n        \"<ipxact:displayName>minimalDesign</ipxact:displayName>\"\r\n        \"<ipxact:shortDescription>brief</ipxact:shortDescription>\"\r\n        \"<ipxact:description>TestDescription</ipxact:description>\"\r\n        \"</ipxact:design>\");\r\n\r\n\r\n    QDomDocument document;\r\n    document.setContent(documentContent);\r\n\r\n    QSharedPointer<Design> testDesign = DesignReader::createDesignFrom(document);\r\n\r\n    QCOMPARE(testDesign->getRevision(), Document::Revision::Std22);\r\n    QCOMPARE(testDesign->getVlnv().getVendor(), QString(\"tuni.fi\"));\r\n    QCOMPARE(testDesign->getVlnv().getLibrary(), QString(\"TestLibrary\"));\r\n    QCOMPARE(testDesign->getVlnv().getName(), QString(\"TestDesign\"));\r\n    QCOMPARE(testDesign->getVlnv().getVersion(), QString(\"0.1\"));\r\n    QCOMPARE(testDesign->getDisplayName(), QString(\"minimalDesign\"));\r\n    QCOMPARE(testDesign->getShortDescription(), QString(\"brief\"));\r\n    QCOMPARE(testDesign->getDescription(), QString(\"TestDescription\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_DesignReader::testReadProcessingInstructions()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_DesignReader::testReadProcessingInstructions()\r\n{\r\n    QString documentContent(\r\n        \"<?xml version=\\\"1.0\\\"?>\"\r\n        \"<!-- Header comment -->\"\r\n        \"<?xml-stylesheet href=\\\"style.css\\\"?>\"\r\n        \"<ipxact:design xmlns:xsi=\\\"http://www.w3.org/2001/XMLSchema-instance\\\" \" \r\n        \"xmlns:ipxact=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014\\\" \"\r\n        \"xmlns:kactus2=\\\"http://kactus2.cs.tut.fi\\\" \"\r\n        \"xsi:schemaLocation=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/ \"\r\n        \"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/index.xsd\\\">\"\r\n            \"<ipxact:vendor>tuni.fi</ipxact:vendor>\"\r\n            \"<ipxact:library>TestLibrary</ipxact:library>\"\r\n            \"<ipxact:name>TestDesign</ipxact:name>\"\r\n            \"<ipxact:version>0.1</ipxact:version>\"\r\n        \"</ipxact:design>\");\r\n\r\n\r\n    QDomDocument document;\r\n    document.setContent(documentContent);\r\n\r\n    QSharedPointer<Design> testDesign = DesignReader::createDesignFrom(document);\r\n\r\n    QCOMPARE(testDesign->getXmlProcessingInstructions().count(), 1);\r\n\r\n    QPair<QString, QString> styleInstruction = testDesign->getXmlProcessingInstructions().first();\r\n    QCOMPARE(styleInstruction.first, QString(\"xml-stylesheet\"));\r\n    QCOMPARE(styleInstruction.second, QString(\"href=\\\"style.css\\\"\"));\r\n\r\n    QCOMPARE(testDesign->getTopComments().first(), QString(\" Header comment \"));\r\n    QCOMPARE(testDesign->getRevision(), Document::Revision::Std14);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_DesignReader::testReadComponentInstances()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_DesignReader::testReadComponentInstances()\r\n{\r\n    QString documentContent(\r\n        \"<ipxact:design xmlns:xsi=\\\"http://www.w3.org/2001/XMLSchema-instance\\\" \" \r\n        \"xmlns:ipxact=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014\\\" \"\r\n        \"xmlns:kactus2=\\\"http://kactus2.cs.tut.fi\\\" \"\r\n        \"xsi:schemaLocation=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/ \"\r\n        \"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/index.xsd\\\">\"\r\n            \"<ipxact:vendor>tuni.fi</ipxact:vendor>\"\r\n            \"<ipxact:library>TestLibrary</ipxact:library>\"\r\n            \"<ipxact:name>TestDesign</ipxact:name>\"\r\n            \"<ipxact:version>0.1</ipxact:version>\"\r\n            \"<ipxact:componentInstances>\"\r\n                \"<ipxact:componentInstance>\"\r\n                    \"<ipxact:instanceName>testInstance</ipxact:instanceName>\"\r\n                    \"<ipxact:displayName>displayName</ipxact:displayName>\"\r\n                    \"<ipxact:description>described</ipxact:description>\"\r\n                    \"<ipxact:isPresent>2-1</ipxact:isPresent>\"\r\n                    \"<ipxact:componentRef vendor=\\\"tuni.fi\\\" library=\\\"TestLibrary\\\" name=\\\"testComponent\\\"\"\r\n                        \" version=\\\"1.0\\\">\"\r\n                        \"<ipxact:configurableElementValues>\"\r\n                            \"<ipxact:configurableElementValue referenceId=\\\"testReferenceID\\\">10\"\r\n                                \"</ipxact:configurableElementValue>\"\r\n                        \"</ipxact:configurableElementValues>\"\r\n                    \"</ipxact:componentRef>\"\r\n                    \"<ipxact:vendorExtensions>\"\r\n                        \"<kactus2:uuid>testUUID</kactus2:uuid>\"\r\n                    \"</ipxact:vendorExtensions>\"\r\n                \"</ipxact:componentInstance>\"\r\n            \"</ipxact:componentInstances>\"\r\n        \"</ipxact:design>\");\r\n\r\n    QDomDocument document;\r\n    document.setContent(documentContent);\r\n\r\n    QSharedPointer<Design> testDesign = DesignReader::createDesignFrom(document);\r\n\r\n    QCOMPARE(testDesign->getComponentInstances()->size(), 1);\r\n\r\n    QSharedPointer<ComponentInstance> testInstance = testDesign->getComponentInstances()->first();\r\n\r\n    QCOMPARE(testInstance->getInstanceName(), QString(\"testInstance\"));\r\n    QCOMPARE(testInstance->displayName(), QString(\"displayName\"));\r\n    QCOMPARE(testInstance->description(), QString(\"described\"));\r\n    QCOMPARE(testInstance->getIsPresent(), QString(\"2-1\"));\r\n\r\n    QSharedPointer<ConfigurableVLNVReference> componentRef =\r\n        testDesign->getComponentInstances()->first()->getComponentRef();\r\n    QCOMPARE(componentRef->getVendor(), QString(\"tuni.fi\"));\r\n    QCOMPARE(componentRef->getLibrary(), QString(\"TestLibrary\"));\r\n    QCOMPARE(componentRef->getName(), QString(\"testComponent\"));\r\n    QCOMPARE(componentRef->getVersion(), QString(\"1.0\"));\r\n    QCOMPARE(componentRef->getConfigurableElementValues()->size(), 1);\r\n    QCOMPARE(componentRef->getConfigurableElementValues()->first()->getReferenceId(), QString(\"testReferenceID\"));\r\n    QCOMPARE(componentRef->getConfigurableElementValues()->first()->getConfigurableValue(), QString(\"10\"));\r\n\r\n    QCOMPARE(testInstance->getVendorExtensions()->size(), 1);\r\n    QCOMPARE(testInstance->getVendorExtensions()->first()->type(), QString(\"kactus2:uuid\"));\r\n    QCOMPARE(testDesign->getRevision(), Document::Revision::Std14);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_DesignReader::testRead2022ComponentInstances()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_DesignReader::testRead2022ComponentInstances()\r\n{\r\n    QString documentContent(\r\n        \"<ipxact:design xmlns:xsi=\\\"http://www.w3.org/2001/XMLSchema-instance\\\" \"\r\n        \"xmlns:ipxact=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2022\\\" \"\r\n        \"xmlns:kactus2=\\\"http://kactus2.cs.tut.fi\\\" \"\r\n        \"xsi:schemaLocation=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2022/ \"\r\n        \"http://www.accellera.org/XMLSchema/IPXACT/1685-2022/index.xsd\\\">\"\r\n            \"<ipxact:vendor>tuni.fi</ipxact:vendor>\"\r\n            \"<ipxact:library>TestLibrary</ipxact:library>\"\r\n            \"<ipxact:name>TestDesign</ipxact:name>\"\r\n            \"<ipxact:version>0.1</ipxact:version>\"\r\n            \"<ipxact:componentInstances>\"\r\n                \"<ipxact:componentInstance>\"\r\n                    \"<ipxact:instanceName>testInstance</ipxact:instanceName>\"\r\n                    \"<ipxact:displayName>displayName</ipxact:displayName>\"\r\n                    \"<ipxact:shortDescription>brief</ipxact:shortDescription>\"\r\n                    \"<ipxact:description>described</ipxact:description>\"\r\n                    \"<ipxact:componentRef vendor=\\\"tuni.fi\\\" library=\\\"TestLibrary\\\" name=\\\"testComponent\\\" version=\\\"1.0\\\">\"\r\n                        \"<ipxact:configurableElementValues>\"\r\n                            \"<ipxact:configurableElementValue referenceId=\\\"testReferenceID\\\">10</ipxact:configurableElementValue>\"\r\n                        \"</ipxact:configurableElementValues>\"\r\n                    \"</ipxact:componentRef>\"\r\n                    \"<ipxact:powerDomainLinks>\"\r\n                        \"<ipxact:powerDomainLink>\"\r\n                            \"<ipxact:externalPowerDomainReference>external</ipxact:externalPowerDomainReference>\"\r\n                            \"<ipxact:internalPowerDomainReference>internal</ipxact:internalPowerDomainReference>\"\r\n                            \"<ipxact:internalPowerDomainReference>second</ipxact:internalPowerDomainReference>\"\r\n                        \"</ipxact:powerDomainLink>\"\r\n                    \"</ipxact:powerDomainLinks>\"\r\n                    \"<ipxact:vendorExtensions>\"\r\n                        \"<kactus2:uuid>testUUID</kactus2:uuid>\"\r\n                    \"</ipxact:vendorExtensions>\"\r\n                \"</ipxact:componentInstance>\"\r\n            \"</ipxact:componentInstances>\"\r\n        \"</ipxact:design>\");\r\n\r\n    QDomDocument document;\r\n    document.setContent(documentContent);\r\n\r\n    QSharedPointer<Design> testDesign = DesignReader::createDesignFrom(document);\r\n\r\n    QCOMPARE(testDesign->getRevision(), Document::Revision::Std22);\r\n    QCOMPARE(testDesign->getComponentInstances()->size(), 1);\r\n\r\n    QSharedPointer<ComponentInstance> testInstance = testDesign->getComponentInstances()->first();\r\n\r\n    QCOMPARE(testInstance->getInstanceName(), QString(\"testInstance\"));\r\n    QCOMPARE(testInstance->displayName(), QString(\"displayName\"));\r\n    QCOMPARE(testInstance->shortDescription(), QString(\"brief\"));\r\n    QCOMPARE(testInstance->description(), QString(\"described\"));\r\n    QCOMPARE(testInstance->getIsPresent(), QString());\r\n\r\n    QSharedPointer<ConfigurableVLNVReference> componentRef =\r\n        testDesign->getComponentInstances()->first()->getComponentRef();\r\n    QCOMPARE(componentRef->getVendor(), QString(\"tuni.fi\"));\r\n    QCOMPARE(componentRef->getLibrary(), QString(\"TestLibrary\"));\r\n    QCOMPARE(componentRef->getName(), QString(\"testComponent\"));\r\n    QCOMPARE(componentRef->getVersion(), QString(\"1.0\"));\r\n    QCOMPARE(componentRef->getConfigurableElementValues()->size(), 1);\r\n    QCOMPARE(componentRef->getConfigurableElementValues()->first()->getReferenceId(), QString(\"testReferenceID\"));\r\n    QCOMPARE(componentRef->getConfigurableElementValues()->first()->getConfigurableValue(), QString(\"10\"));\r\n\r\n    QCOMPARE(testInstance->getVendorExtensions()->size(), 1);\r\n    QCOMPARE(testInstance->getVendorExtensions()->first()->type(), QString(\"kactus2:uuid\"));\r\n\r\n    QCOMPARE(testInstance->getPowerDomainLinks()->size(), 1);\r\n\r\n    auto powerDomainLink = testInstance->getPowerDomainLinks()->first();\r\n    QCOMPARE(powerDomainLink->externalReference_, QString(\"external\"));\r\n    QCOMPARE(powerDomainLink->internalReferences_.size(), 2);\r\n    QCOMPARE(powerDomainLink->internalReferences_.at(0), QString(\"internal\"));\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_DesignReader::testReadComponentInstanceExtensions()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_DesignReader::testReadComponentInstanceExtensions()\r\n{\r\n    QString documentContent(\r\n        \"<ipxact:design xmlns:xsi=\\\"http://www.w3.org/2001/XMLSchema-instance\\\" \" \r\n        \"xmlns:ipxact=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014\\\" \"\r\n        \"xmlns:kactus2=\\\"http://kactus2.cs.tut.fi\\\" \"\r\n        \"xsi:schemaLocation=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/ \"\r\n        \"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/index.xsd\\\">\"\r\n            \"<ipxact:vendor>tuni.fi</ipxact:vendor>\"\r\n            \"<ipxact:library>TestLibrary</ipxact:library>\"\r\n            \"<ipxact:name>TestDesign</ipxact:name>\"\r\n            \"<ipxact:version>0.1</ipxact:version>\"\r\n            \"<ipxact:componentInstances>\"\r\n                \"<ipxact:componentInstance>\"\r\n                    \"<ipxact:instanceName>testInstance</ipxact:instanceName>\"\r\n                    \"<ipxact:componentRef vendor=\\\"tuni.fi\\\" library=\\\"TestLibrary\\\" name=\\\"testComponent\\\"\"\r\n                        \" version=\\\"1.0\\\">\"\r\n                        \"<ipxact:configurableElementValues>\"\r\n                            \"<ipxact:configurableElementValue referenceId=\\\"testReferenceID\\\">10\"\r\n                            \"</ipxact:configurableElementValue>\"\r\n                        \"</ipxact:configurableElementValues>\"\r\n                    \"</ipxact:componentRef>\"\r\n                    \"<ipxact:vendorExtensions>\"\r\n                        \"<kactus2:position x=\\\"10\\\" y=\\\"10\\\"/>\"\r\n                        \"<kactus2:uuid>testUUID</kactus2:uuid>\"\r\n                        \"<kactus2:imported importRef=\\\"importSource\\\"/>\"\r\n                        \"<kactus2:portPositions>\"\r\n                            \"<kactus2:portPosition busRef=\\\"testInterface\\\" x=\\\"4\\\" y=\\\"4\\\"/>\"\r\n                        \"</kactus2:portPositions>\"\r\n                        \"<kactus2:adHocVisibilities>\"\r\n                            \"<kactus2:adHocVisible portName=\\\"adHocPort\\\" x=\\\"3\\\" y=\\\"3\\\"/>\"\r\n                        \"</kactus2:adHocVisibilities>\"\r\n                        \"<kactus2:apiInterfacePositions>\"\r\n                            \"<kactus2:apiInterfacePosition apiRef=\\\"apiInterface\\\" x=\\\"2\\\" y=\\\"2\\\"/>\"\r\n                        \"</kactus2:apiInterfacePositions>\"\r\n                        \"<kactus2:comInterfacePositions>\"\r\n                            \"<kactus2:comInterfacePosition comRef=\\\"comInterface\\\" x=\\\"1\\\" y=\\\"1\\\"/>\"\r\n                        \"</kactus2:comInterfacePositions>\"\r\n                        \"<kactus2:propertyValues>\"\r\n                            \"<kactus2:propertyValue name=\\\"testSWProperty\\\" value=\\\"8\\\"/>\"\r\n                        \"</kactus2:propertyValues>\"\r\n                    \"</ipxact:vendorExtensions>\"\r\n                \"</ipxact:componentInstance>\"\r\n            \"</ipxact:componentInstances>\"\r\n        \"</ipxact:design>\");\r\n\r\n    QDomDocument document;\r\n    document.setContent(documentContent);\r\n\r\n    QSharedPointer<Design> testDesign = DesignReader::createDesignFrom(document);\r\n\r\n    QCOMPARE(testDesign->getComponentInstances()->size(), 1);\r\n\r\n    QSharedPointer<ComponentInstance> testInstance = testDesign->getComponentInstances()->first();\r\n\r\n    QCOMPARE(testInstance->getInstanceName(), QString(\"testInstance\"));\r\n\r\n    QSharedPointer<ConfigurableVLNVReference> componentRef =\r\n        testDesign->getComponentInstances()->first()->getComponentRef();\r\n    QCOMPARE(componentRef->getName(), QString(\"testComponent\"));\r\n\r\n    QCOMPARE(testInstance->getVendorExtensions()->size(), 8);\r\n    QCOMPARE(testInstance->getUuid(), QString(\"testUUID\"));\r\n    QCOMPARE(testInstance->getPosition().x(), qreal(10));\r\n    QCOMPARE(testInstance->getPosition().y(), qreal(10));\r\n\r\n    QCOMPARE(testInstance->isImported(), true);\r\n    QCOMPARE(testInstance->getImportRef(), QString(\"importSource\"));\r\n\r\n    QCOMPARE(testInstance->getBusInterfacePositions().count(), 1);\r\n    QCOMPARE(testInstance->getBusInterfacePositions().firstKey(), QString(\"testInterface\"));\r\n    QCOMPARE(testInstance->getBusInterfacePositions().first().x(), qreal(4));\r\n    QCOMPARE(testInstance->getBusInterfacePositions().first().y(), qreal(4));\r\n\r\n    QCOMPARE(testInstance->getAdHocPortPositions().count(), 1);\r\n    QCOMPARE(testInstance->getAdHocPortPositions().firstKey(), QString(\"adHocPort\"));\r\n    QCOMPARE(testInstance->getAdHocPortPositions().first().x(), qreal(3));\r\n    QCOMPARE(testInstance->getAdHocPortPositions().first().y(), qreal(3));\r\n\r\n    QCOMPARE(testInstance->getApiInterfacePositions().count(), 1);\r\n    QCOMPARE(testInstance->getApiInterfacePositions().firstKey(), QString(\"apiInterface\"));\r\n    QCOMPARE(testInstance->getApiInterfacePositions().first().x(), qreal(2));\r\n    QCOMPARE(testInstance->getApiInterfacePositions().first().y(), qreal(2));\r\n\r\n    QCOMPARE(testInstance->getComInterfacePositions().count(), 1);\r\n    QCOMPARE(testInstance->getComInterfacePositions().firstKey(), QString(\"comInterface\"));\r\n    QCOMPARE(testInstance->getComInterfacePositions().first().x(), qreal(1));\r\n    QCOMPARE(testInstance->getComInterfacePositions().first().y(), qreal(1));\r\n\r\n    QCOMPARE(testInstance->getPropertyValues().count(), 1);\r\n    QCOMPARE(testInstance->getPropertyValues().firstKey(), QString(\"testSWProperty\"));\r\n    QCOMPARE(testInstance->getPropertyValues().first(), QString(\"8\"));\r\n    QCOMPARE(testDesign->getRevision(), Document::Revision::Std14);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_DesignReader::testReadInterconnections()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_DesignReader::testReadInterconnections()\r\n{\r\n    QString documentContent(\r\n        \"<ipxact:design xmlns:xsi=\\\"http://www.w3.org/2001/XMLSchema-instance\\\" \" \r\n        \"xmlns:ipxact=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014\\\" \"\r\n        \"xmlns:kactus2=\\\"http://kactus2.cs.tut.fi\\\" \"\r\n        \"xsi:schemaLocation=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/ \"\r\n        \"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/index.xsd\\\">\"\r\n           \"<ipxact:vendor>tuni.fi</ipxact:vendor>\"\r\n            \"<ipxact:library>TestLibrary</ipxact:library>\"\r\n            \"<ipxact:name>TestDesign</ipxact:name>\"\r\n            \"<ipxact:version>0.1</ipxact:version>\"\r\n            \"<ipxact:interconnections>\"\r\n                \"<ipxact:interconnection>\"\r\n                    \"<ipxact:name>testConnection</ipxact:name>\"\r\n                    \"<ipxact:displayName>interconnectionDisplay</ipxact:displayName>\"\r\n                    \"<ipxact:description>interconnectionDescription</ipxact:description>\"\r\n                    \"<ipxact:isPresent>4-3</ipxact:isPresent>\"\r\n                    \"<ipxact:activeInterface componentRef=\\\"startComponent\\\" busRef=\\\"startBus\\\">\"\r\n                        \"<ipxact:isPresent>1</ipxact:isPresent>\"\r\n                        \"<ipxact:description>interfaceDescription</ipxact:description>\"\r\n                        \"<ipxact:excludePorts>\"\r\n                            \"<ipxact:excludePort>testExcludePort</ipxact:excludePort>\"\r\n                        \"</ipxact:excludePorts>\"\r\n                        \"<ipxact:vendorExtensions>\"\r\n                            \"<testExtension testExtensionAttribute=\\\"extension\\\">testValue</testExtension>\"\r\n                        \"</ipxact:vendorExtensions>\"\r\n                    \"</ipxact:activeInterface>\"\r\n                    \"<ipxact:activeInterface componentRef=\\\"otherComponent\\\" busRef=\\\"otherBus\\\"/>\"\r\n                    \"<ipxact:hierInterface busRef=\\\"hierBusRef\\\">\"\r\n                        \"<ipxact:isPresent>2-1</ipxact:isPresent>\"\r\n                        \"<ipxact:description>hierDescription</ipxact:description>\"\r\n                        \"<ipxact:vendorExtensions>\"\r\n                            \"<testExtension testExtensionAttribute=\\\"extension\\\">testValue</testExtension>\"\r\n                        \"</ipxact:vendorExtensions>\"\r\n                    \"</ipxact:hierInterface>\"\r\n                    \"<ipxact:vendorExtensions>\"\r\n                        \"<testExtension testExtensionAttribute=\\\"extension\\\">testValue</testExtension>\"\r\n                    \"</ipxact:vendorExtensions>\"\r\n                \"</ipxact:interconnection>\"\r\n            \"</ipxact:interconnections>\"\r\n        \"</ipxact:design>\");\r\n\r\n    QDomDocument document;\r\n    document.setContent(documentContent);\r\n\r\n    QSharedPointer<Design> testDesign = DesignReader::createDesignFrom(document);\r\n\r\n    QCOMPARE(testDesign->getInterconnections()->size(), 1);\r\n    \r\n    QSharedPointer<Interconnection> testConnection = testDesign->getInterconnections()->first();\r\n\r\n    QCOMPARE(testConnection->name(), QString(\"testConnection\"));\r\n    QCOMPARE(testConnection->displayName(), QString(\"interconnectionDisplay\"));\r\n    QCOMPARE(testConnection->description(), QString(\"interconnectionDescription\"));\r\n    QCOMPARE(testConnection->getIsPresent(), QString(\"4-3\"));\r\n\r\n    QCOMPARE(testConnection->getStartInterface()->getComponentReference(), QString(\"startComponent\"));\r\n    QCOMPARE(testConnection->getStartInterface()->getBusReference(), QString(\"startBus\"));\r\n    QCOMPARE(testConnection->getStartInterface()->getIsPresent(), QString(\"1\"));\r\n    QCOMPARE(testConnection->getStartInterface()->getDescription(), QString(\"interfaceDescription\"));\r\n    QCOMPARE(testConnection->getStartInterface()->getExcludePorts()->size(), 1);\r\n    QCOMPARE(testConnection->getStartInterface()->getExcludePorts()->first(), QString(\"testExcludePort\"));\r\n    QCOMPARE(testConnection->getStartInterface()->getVendorExtensions()->size(), 1);\r\n    QCOMPARE(testConnection->getStartInterface()->getVendorExtensions()->first()->type(), QString(\"testExtension\"));\r\n\r\n    QCOMPARE(testConnection->getActiveInterfaces()->size(), 1);\r\n\r\n    QSharedPointer<ActiveInterface> active = testConnection->getActiveInterfaces()->first();\r\n    QCOMPARE(active->getComponentReference(), QString(\"otherComponent\"));\r\n    QCOMPARE(active->getBusReference(), QString(\"otherBus\"));\r\n    QCOMPARE(active->getIsPresent(), QString(\"\"));\r\n    QCOMPARE(active->getDescription(), QString(\"\"));\r\n    QCOMPARE(active->getExcludePorts()->size(), 0);\r\n    QCOMPARE(active->getVendorExtensions()->size(), 0);\r\n\r\n    QCOMPARE(testConnection->getHierInterfaces()->size(), 1);\r\n\r\n    QSharedPointer<HierInterface> hierarchy = testConnection->getHierInterfaces()->first();\r\n    QCOMPARE(hierarchy->getBusReference(), QString(\"hierBusRef\"));\r\n    QCOMPARE(hierarchy->getIsPresent(), QString(\"2-1\"));\r\n    QCOMPARE(hierarchy->getDescription(), QString(\"hierDescription\"));\r\n    QCOMPARE(hierarchy->getVendorExtensions()->size(), 1);\r\n    QCOMPARE(hierarchy->getVendorExtensions()->first()->type(), QString(\"testExtension\"));\r\n\r\n    QCOMPARE(testConnection->getVendorExtensions()->size(), 1);\r\n    QCOMPARE(testConnection->getVendorExtensions()->first()->type(), QString(\"testExtension\"));\r\n    QCOMPARE(testDesign->getRevision(), Document::Revision::Std14);\r\n}\r\n\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_DesignReader::testRead2022Interconnections()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_DesignReader::testRead2022Interconnections()\r\n{\r\n    QString documentContent(\r\n    \"<ipxact:design xmlns:xsi=\\\"http://www.w3.org/2001/XMLSchema-instance\\\" \"\r\n    \"xmlns:ipxact=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2022\\\" \"\r\n    \"xmlns:kactus2=\\\"http://kactus2.cs.tut.fi\\\" \"\r\n    \"xsi:schemaLocation=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2022/ \"\r\n     \"http://www.accellera.org/XMLSchema/IPXACT/1685-2022/index.xsd\\\">\"\r\n        \"<ipxact:vendor>tuni.fi</ipxact:vendor>\"\r\n        \"<ipxact:library>TestLibrary</ipxact:library>\"\r\n        \"<ipxact:name>TestDesign</ipxact:name>\"\r\n        \"<ipxact:version>0.1</ipxact:version>\"\r\n        \"<ipxact:interconnections>\"\r\n            \"<ipxact:interconnection>\"\r\n                \"<ipxact:name>testConnection</ipxact:name>\"\r\n                \"<ipxact:displayName>interconnectionDisplay</ipxact:displayName>\"\r\n                \"<ipxact:shortDescription>brief interconnect</ipxact:shortDescription>\"\r\n                \"<ipxact:description>interconnectionDescription</ipxact:description>\"\r\n                    \"<ipxact:activeInterface componentInstanceRef=\\\"startComponent\\\" busRef=\\\"startBus\\\">\"\r\n                    \"<ipxact:description>interfaceDescription</ipxact:description>\"\r\n                    \"<ipxact:excludePorts>\"\r\n                        \"<ipxact:excludePort>testExcludePort</ipxact:excludePort>\"\r\n                    \"</ipxact:excludePorts>\"\r\n                    \"<ipxact:vendorExtensions>\"\r\n                        \"<testExtension testExtensionAttribute=\\\"extension\\\">testValue</testExtension>\"\r\n                    \"</ipxact:vendorExtensions>\"\r\n                \"</ipxact:activeInterface>\"\r\n                \"<ipxact:activeInterface componentInstanceRef=\\\"otherComponent\\\" busRef=\\\"otherBus\\\"/>\"\r\n                \"<ipxact:hierInterface busRef=\\\"hierBusRef\\\">\"\r\n                    \"<ipxact:description>hierDescription</ipxact:description>\"\r\n                    \"<ipxact:vendorExtensions>\"\r\n                        \"<testExtension testExtensionAttribute=\\\"extension\\\">testValue</testExtension>\"\r\n                    \"</ipxact:vendorExtensions>\"\r\n                \"</ipxact:hierInterface>\"\r\n                \"<ipxact:vendorExtensions>\"\r\n                    \"<testExtension testExtensionAttribute=\\\"extension\\\">testValue</testExtension>\"\r\n                \"</ipxact:vendorExtensions>\"\r\n            \"</ipxact:interconnection>\"\r\n        \"</ipxact:interconnections>\"\r\n    \"</ipxact:design>\");\r\n\r\n    QDomDocument document;\r\n    document.setContent(documentContent);\r\n\r\n    QSharedPointer<Design> testDesign = DesignReader::createDesignFrom(document);\r\n\r\n    QCOMPARE(testDesign->getRevision(), Document::Revision::Std22);\r\n    QCOMPARE(testDesign->getInterconnections()->size(), 1);\r\n\r\n    QSharedPointer<Interconnection> testConnection = testDesign->getInterconnections()->first();\r\n\r\n    QCOMPARE(testConnection->name(), QString(\"testConnection\"));\r\n    QCOMPARE(testConnection->displayName(), QString(\"interconnectionDisplay\"));\r\n    QCOMPARE(testConnection->shortDescription(), QString(\"brief interconnect\"));\r\n    QCOMPARE(testConnection->description(), QString(\"interconnectionDescription\"));\r\n    QCOMPARE(testConnection->getIsPresent(), QString());\r\n\r\n    QCOMPARE(testConnection->getStartInterface()->getComponentReference(), QString(\"startComponent\"));\r\n    QCOMPARE(testConnection->getStartInterface()->getBusReference(), QString(\"startBus\"));\r\n    QCOMPARE(testConnection->getStartInterface()->getIsPresent(), QString());\r\n    QCOMPARE(testConnection->getStartInterface()->getDescription(), QString(\"interfaceDescription\"));\r\n    QCOMPARE(testConnection->getStartInterface()->getExcludePorts()->size(), 1);\r\n    QCOMPARE(testConnection->getStartInterface()->getExcludePorts()->first(), QString(\"testExcludePort\"));\r\n    QCOMPARE(testConnection->getStartInterface()->getVendorExtensions()->size(), 1);\r\n    QCOMPARE(testConnection->getStartInterface()->getVendorExtensions()->first()->type(), QString(\"testExtension\"));\r\n\r\n    QCOMPARE(testConnection->getActiveInterfaces()->size(), 1);\r\n\r\n    QSharedPointer<ActiveInterface> active = testConnection->getActiveInterfaces()->first();\r\n    QCOMPARE(active->getComponentReference(), QString(\"otherComponent\"));\r\n    QCOMPARE(active->getBusReference(), QString(\"otherBus\"));\r\n    QCOMPARE(active->getIsPresent(), QString());\r\n    QCOMPARE(active->getDescription(), QString(\"\"));\r\n    QCOMPARE(active->getExcludePorts()->size(), 0);\r\n    QCOMPARE(active->getVendorExtensions()->size(), 0);\r\n\r\n    QCOMPARE(testConnection->getHierInterfaces()->size(), 1);\r\n\r\n    QSharedPointer<HierInterface> hierarchy = testConnection->getHierInterfaces()->first();\r\n    QCOMPARE(hierarchy->getBusReference(), QString(\"hierBusRef\"));\r\n    QCOMPARE(hierarchy->getIsPresent(), QString());\r\n    QCOMPARE(hierarchy->getDescription(), QString(\"hierDescription\"));\r\n    QCOMPARE(hierarchy->getVendorExtensions()->size(), 1);\r\n    QCOMPARE(hierarchy->getVendorExtensions()->first()->type(), QString(\"testExtension\"));\r\n\r\n    QCOMPARE(testConnection->getVendorExtensions()->size(), 1);\r\n    QCOMPARE(testConnection->getVendorExtensions()->first()->type(), QString(\"testExtension\"));\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_DesignReader::testReadInterconnectionExtensions()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_DesignReader::testReadInterconnectionExtensions()\r\n{\r\n    QString documentContent(\r\n        \"<ipxact:design xmlns:xsi=\\\"http://www.w3.org/2001/XMLSchema-instance\\\" \" \r\n        \"xmlns:ipxact=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014\\\" \"\r\n        \"xmlns:kactus2=\\\"http://kactus2.cs.tut.fi\\\" \"\r\n        \"xsi:schemaLocation=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/ \"\r\n        \"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/index.xsd\\\">\"\r\n            \"<ipxact:vendor>tuni.fi</ipxact:vendor>\"\r\n            \"<ipxact:library>TestLibrary</ipxact:library>\"\r\n            \"<ipxact:name>TestDesign</ipxact:name>\"\r\n            \"<ipxact:version>0.1</ipxact:version>\"\r\n            \"<ipxact:interconnections>\"\r\n                \"<ipxact:interconnection>\"\r\n                    \"<ipxact:name>testActiveHier</ipxact:name>\"\r\n                    \"<ipxact:activeInterface componentRef=\\\"componentRef\\\" busRef=\\\"busRef\\\"/>\"\r\n                    \"<ipxact:hierInterface busRef=\\\"hierBusRef\\\">\"\r\n                        \"<ipxact:vendorExtensions>\"\r\n                            \"<kactus2:route>\"\r\n                                \"<kactus2:position x=\\\"1\\\" y=\\\"1\\\"/>\"\r\n                                \"<kactus2:position x=\\\"1\\\" y=\\\"2\\\"/>\"\r\n                            \"</kactus2:route>\"\r\n                        \"</ipxact:vendorExtensions>\"\r\n                    \"</ipxact:hierInterface>\"\r\n                    \"<ipxact:vendorExtensions>\"\r\n                        \"<kactus2:offPage/>\"\r\n                    \"</ipxact:vendorExtensions>\"\r\n                \"</ipxact:interconnection>\"\r\n            \"</ipxact:interconnections>\"\r\n        \"</ipxact:design>\");\r\n\r\n    QDomDocument document;\r\n    document.setContent(documentContent);\r\n\r\n    QSharedPointer<Design> testDesign = DesignReader::createDesignFrom(document);\r\n\r\n    QCOMPARE(testDesign->getInterconnections()->size(), 1);\r\n\r\n    QSharedPointer<Interconnection> interconnection = testDesign->getInterconnections()->first();\r\n    QCOMPARE(interconnection->name(), QString(\"testActiveHier\"));\r\n\r\n    QCOMPARE(interconnection->getStartInterface()->getComponentReference(), QString(\"componentRef\"));\r\n    QCOMPARE(interconnection->getStartInterface()->getBusReference(), QString(\"busRef\"));\r\n    QCOMPARE(interconnection->isOffPage(), true);\r\n\r\n    QCOMPARE(interconnection->getActiveInterfaces()->size(), 0);\r\n\r\n    QCOMPARE(interconnection->getHierInterfaces()->size(), 1);\r\n    QCOMPARE(interconnection->getHierInterfaces()->first()->getBusReference(), QString(\"hierBusRef\"));\r\n\r\n    QCOMPARE(interconnection->getHierInterfaces()->first()->getRoute().size(), 2);\r\n    QCOMPARE(interconnection->getHierInterfaces()->first()->getRoute().first().x(), qreal(1));\r\n    QCOMPARE(interconnection->getHierInterfaces()->first()->getRoute().first().x(), qreal(1));\r\n    QCOMPARE(interconnection->getHierInterfaces()->first()->getRoute().last().x(), qreal(1));\r\n    QCOMPARE(interconnection->getHierInterfaces()->first()->getRoute().last().y(), qreal(2));\r\n    QCOMPARE(testDesign->getRevision(), Document::Revision::Std14);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_DesignReader::testReadMonitorInterconnections()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_DesignReader::testReadMonitorInterconnections()\r\n{\r\n    QString documentContent(\r\n        \"<ipxact:design xmlns:xsi=\\\"http://www.w3.org/2001/XMLSchema-instance\\\" \" \r\n        \"xmlns:ipxact=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014\\\" \"\r\n        \"xmlns:kactus2=\\\"http://kactus2.cs.tut.fi\\\" \"\r\n        \"xsi:schemaLocation=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/ \"\r\n        \"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/index.xsd\\\">\"\r\n            \"<ipxact:vendor>tuni.fi</ipxact:vendor>\"\r\n            \"<ipxact:library>TestLibrary</ipxact:library>\"\r\n            \"<ipxact:name>TestDesign</ipxact:name>\"\r\n            \"<ipxact:version>0.1</ipxact:version>\"\r\n            \"<ipxact:interconnections>\"\r\n                \"<ipxact:monitorInterconnection>\"\r\n                    \"<ipxact:name>monitorInterconnection</ipxact:name>\"\r\n                    \"<ipxact:displayName>monitorDisplay</ipxact:displayName>\"\r\n                    \"<ipxact:description>monitorDescription</ipxact:description>\"\r\n                    \"<ipxact:isPresent>2-1</ipxact:isPresent>\"\r\n                    \"<ipxact:monitoredActiveInterface componentRef=\\\"componentRef\\\" busRef=\\\"busRef\\\"\"\r\n                        \" path=\\\"/path/to/test\\\">\"\r\n                        \"<ipxact:description>monitoredActiveDescription</ipxact:description>\"\r\n                        \"<ipxact:vendorExtensions>\"\r\n                            \"<testExtension testExtensionAttribute=\\\"extension\\\">testValue</testExtension>\"\r\n                        \"</ipxact:vendorExtensions>\"\r\n                    \"</ipxact:monitoredActiveInterface>\"\r\n                    \"<ipxact:monitorInterface componentRef=\\\"otherComponent\\\" busRef=\\\"otherBus\\\" \"\r\n                        \"path=\\\"/path/to/other/test\\\">\"\r\n                        \"<ipxact:description>monitorInterfaceDescription</ipxact:description>\"\r\n                        \"<ipxact:vendorExtensions>\"\r\n                            \"<testExtension testExtensionAttribute=\\\"extension\\\">testValue</testExtension>\"\r\n                        \"</ipxact:vendorExtensions>\"\r\n                        \"<ipxact:isPresent>1</ipxact:isPresent>\"\r\n                    \"</ipxact:monitorInterface>\"\r\n                \"</ipxact:monitorInterconnection>\"\r\n            \"</ipxact:interconnections>\"\r\n        \"</ipxact:design>\");\r\n\r\n    QDomDocument document;\r\n    document.setContent(documentContent);\r\n\r\n    QSharedPointer<Design> testDesign = DesignReader::createDesignFrom(document);\r\n\r\n    QCOMPARE(testDesign->getMonitorInterconnecions()->size(), 1);\r\n\r\n    QSharedPointer<MonitorInterconnection> monitorConnection = testDesign->getMonitorInterconnecions()->first();\r\n\r\n    QCOMPARE(monitorConnection->name(), QString(\"monitorInterconnection\"));\r\n    QCOMPARE(monitorConnection->displayName(), QString(\"monitorDisplay\"));\r\n    QCOMPARE(monitorConnection->description(), QString(\"monitorDescription\"));\r\n    QCOMPARE(monitorConnection->getIsPresent(), QString(\"2-1\"));\r\n\r\n    QSharedPointer<MonitorInterface> monitoredActive = monitorConnection->getMonitoredActiveInterface();\r\n\r\n    QCOMPARE(monitoredActive->getComponentReference(), QString(\"componentRef\"));\r\n    QCOMPARE(monitoredActive->getBusReference(), QString(\"busRef\"));\r\n    QCOMPARE(monitoredActive->getPath(), QString(\"/path/to/test\"));\r\n    QCOMPARE(monitoredActive->getDescription(), QString(\"monitoredActiveDescription\"));\r\n    QCOMPARE(monitoredActive->getVendorExtensions()->size(), 1);\r\n    QCOMPARE(monitoredActive->getVendorExtensions()->first()->type(), QString(\"testExtension\"));\r\n\r\n    QCOMPARE(monitorConnection->getMonitorInterfaces()->size(), 1);\r\n\r\n    QSharedPointer<MonitorInterface> monitorInterface = monitorConnection->getMonitorInterfaces()->first();\r\n\r\n    QCOMPARE(monitorInterface->getComponentReference(), QString(\"otherComponent\"));\r\n    QCOMPARE(monitorInterface->getBusReference(), QString(\"otherBus\"));\r\n    QCOMPARE(monitorInterface->getPath(), QString(\"/path/to/other/test\"));\r\n    QCOMPARE(monitorInterface->getDescription(), QString(\"monitorInterfaceDescription\"));\r\n    QCOMPARE(monitorInterface->getIsPresent(), QString(\"1\"));\r\n    QCOMPARE(monitorInterface->getVendorExtensions()->size(), 1);\r\n    QCOMPARE(monitorInterface->getVendorExtensions()->first()->type(), QString(\"testExtension\"));\r\n    QCOMPARE(testDesign->getRevision(), Document::Revision::Std14);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_DesignReader::testReadMonitorInterconnections()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_DesignReader::testRead2022MonitorInterconnections()\r\n{\r\n    QString documentContent(\r\n        \"<ipxact:design xmlns:xsi=\\\"http://www.w3.org/2001/XMLSchema-instance\\\" \"\r\n        \"xmlns:ipxact=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2022\\\" \"\r\n        \"xmlns:kactus2=\\\"http://kactus2.cs.tut.fi\\\" \"\r\n        \"xsi:schemaLocation=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2022/ \"\r\n        \"http://www.accellera.org/XMLSchema/IPXACT/1685-2022/index.xsd\\\">\"\r\n            \"<ipxact:vendor>tuni.fi</ipxact:vendor>\"\r\n            \"<ipxact:library>TestLibrary</ipxact:library>\"\r\n            \"<ipxact:name>TestDesign</ipxact:name>\"\r\n            \"<ipxact:version>0.1</ipxact:version>\"\r\n            \"<ipxact:interconnections>\"\r\n                \"<ipxact:monitorInterconnection>\"\r\n                    \"<ipxact:name>monitorInterconnection</ipxact:name>\"\r\n                    \"<ipxact:displayName>monitorDisplay</ipxact:displayName>\"\r\n                    \"<ipxact:shortDescription>brief monitor</ipxact:shortDescription>\"\r\n                    \"<ipxact:description>monitorDescription</ipxact:description>\"\r\n                    \"<ipxact:monitoredActiveInterface componentInstanceRef=\\\"componentRef\\\" busRef=\\\"busRef\\\" path=\\\"/path/to/test\\\">\"\r\n                        \"<ipxact:description>monitoredActiveDescription</ipxact:description>\"\r\n                            \"<ipxact:vendorExtensions>\"\r\n                                \"<testExtension testExtensionAttribute=\\\"extension\\\">testValue</testExtension>\"\r\n                            \"</ipxact:vendorExtensions>\"\r\n                        \"</ipxact:monitoredActiveInterface>\"\r\n                    \"<ipxact:monitorInterface componentInstanceRef=\\\"otherComponent\\\" busRef=\\\"otherBus\\\" path=\\\"/path/to/other/test\\\">\"\r\n                        \"<ipxact:description>monitorInterfaceDescription</ipxact:description>\"\r\n                        \"<ipxact:vendorExtensions>\"\r\n                            \"<testExtension testExtensionAttribute=\\\"extension\\\">testValue</testExtension>\"\r\n                        \"</ipxact:vendorExtensions>\"\r\n                    \"</ipxact:monitorInterface>\"\r\n                \"</ipxact:monitorInterconnection>\"\r\n            \"</ipxact:interconnections>\"\r\n        \"</ipxact:design>\");\r\n\r\n    QDomDocument document;\r\n    document.setContent(documentContent);\r\n\r\n    QSharedPointer<Design> testDesign = DesignReader::createDesignFrom(document);\r\n    \r\n    QCOMPARE(testDesign->getRevision(), Document::Revision::Std22);\r\n    QCOMPARE(testDesign->getMonitorInterconnecions()->size(), 1);\r\n\r\n    QSharedPointer<MonitorInterconnection> monitorConnection = testDesign->getMonitorInterconnecions()->first();\r\n\r\n    QCOMPARE(monitorConnection->name(), QString(\"monitorInterconnection\"));\r\n    QCOMPARE(monitorConnection->displayName(), QString(\"monitorDisplay\"));\r\n    QCOMPARE(monitorConnection->shortDescription(), QString(\"brief monitor\"));\r\n    QCOMPARE(monitorConnection->description(), QString(\"monitorDescription\"));\r\n    QCOMPARE(monitorConnection->getIsPresent(), QString());\r\n\r\n    QSharedPointer<MonitorInterface> monitoredActive = monitorConnection->getMonitoredActiveInterface();\r\n\r\n    QCOMPARE(monitoredActive->getComponentReference(), QString(\"componentRef\"));\r\n    QCOMPARE(monitoredActive->getBusReference(), QString(\"busRef\"));\r\n    QCOMPARE(monitoredActive->getPath(), QString(\"/path/to/test\"));\r\n    QCOMPARE(monitoredActive->getDescription(), QString(\"monitoredActiveDescription\"));\r\n    QCOMPARE(monitoredActive->getVendorExtensions()->size(), 1);\r\n    QCOMPARE(monitoredActive->getVendorExtensions()->first()->type(), QString(\"testExtension\"));\r\n\r\n    QCOMPARE(monitorConnection->getMonitorInterfaces()->size(), 1);\r\n\r\n    QSharedPointer<MonitorInterface> monitorInterface = monitorConnection->getMonitorInterfaces()->first();\r\n\r\n    QCOMPARE(monitorInterface->getComponentReference(), QString(\"otherComponent\"));\r\n    QCOMPARE(monitorInterface->getBusReference(), QString(\"otherBus\"));\r\n    QCOMPARE(monitorInterface->getPath(), QString(\"/path/to/other/test\"));\r\n    QCOMPARE(monitorInterface->getDescription(), QString(\"monitorInterfaceDescription\"));\r\n    QCOMPARE(monitorInterface->getIsPresent(), QString());\r\n    QCOMPARE(monitorInterface->getVendorExtensions()->size(), 1);\r\n    QCOMPARE(monitorInterface->getVendorExtensions()->first()->type(), QString(\"testExtension\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_DesignReader::testReadAdHocConnections()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_DesignReader::testReadAdHocConnections()\r\n{\r\n    QString documentContent(\r\n        \"<ipxact:design xmlns:xsi=\\\"http://www.w3.org/2001/XMLSchema-instance\\\" \" \r\n        \"xmlns:ipxact=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014\\\" \"\r\n        \"xmlns:kactus2=\\\"http://kactus2.cs.tut.fi\\\" \"\r\n        \"xsi:schemaLocation=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/ \"\r\n        \"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/index.xsd\\\">\"\r\n            \"<ipxact:vendor>tuni.fi</ipxact:vendor>\"\r\n            \"<ipxact:library>TestLibrary</ipxact:library>\"\r\n            \"<ipxact:name>TestDesign</ipxact:name>\"\r\n            \"<ipxact:version>0.1</ipxact:version>\"\r\n            \"<ipxact:adHocConnections>\"\r\n                \"<ipxact:adHocConnection>\"\r\n                    \"<ipxact:name>adHoc</ipxact:name>\"\r\n                    \"<ipxact:displayName>displayAd</ipxact:displayName>\"\r\n                    \"<ipxact:description>describeAd</ipxact:description>\"\r\n                    \"<ipxact:isPresent>4-3</ipxact:isPresent>\"\r\n                    \"<ipxact:tiedValue>default</ipxact:tiedValue>\"\r\n                    \"<ipxact:portReferences>\"\r\n                        \"<ipxact:internalPortReference componentRef=\\\"componentInstance\\\" portRef=\\\"internalPort\\\">\"\r\n                            \"<ipxact:isPresent>1</ipxact:isPresent>\"\r\n                            \"<ipxact:partSelect>\"\r\n                                \"<ipxact:range>\"\r\n                                    \"<ipxact:left>1</ipxact:left>\"\r\n                                    \"<ipxact:right>11</ipxact:right>\"\r\n                                \"</ipxact:range>\"\r\n                                \"<ipxact:indices>\"\r\n                                    \"<ipxact:index>8</ipxact:index>\"\r\n                                    \"<ipxact:index>4+4</ipxact:index>\"\r\n                                \"</ipxact:indices>\"\r\n                            \"</ipxact:partSelect>\"\r\n                        \"</ipxact:internalPortReference>\"\r\n                        \"<ipxact:externalPortReference portRef=\\\"externalPort\\\">\"\r\n                            \"<ipxact:isPresent>0</ipxact:isPresent>\"\r\n                            \"<ipxact:partSelect>\"\r\n                                \"<ipxact:range>\"\r\n                                    \"<ipxact:left>0</ipxact:left>\"\r\n                                    \"<ipxact:right>4</ipxact:right>\"\r\n                                \"</ipxact:range>\"\r\n                            \"</ipxact:partSelect>\"\r\n                        \"</ipxact:externalPortReference>\"\r\n                    \"</ipxact:portReferences>\"\r\n                    \"<ipxact:vendorExtensions>\"\r\n                        \"<testExtension testExtensionAttribute=\\\"extension\\\">testValue</testExtension>\"\r\n                    \"</ipxact:vendorExtensions>\"\r\n                \"</ipxact:adHocConnection>\"\r\n            \"</ipxact:adHocConnections>\"\r\n        \"</ipxact:design>\");\r\n\r\n    QDomDocument document;\r\n    document.setContent(documentContent);\r\n\r\n    QSharedPointer<Design> testDesign = DesignReader::createDesignFrom(document);\r\n\r\n    QCOMPARE(testDesign->getRevision(), Document::Revision::Std14);\r\n    QCOMPARE(testDesign->getAdHocConnections()->size(), 1);\r\n\r\n    QSharedPointer<AdHocConnection> adHocConnection = testDesign->getAdHocConnections()->first();\r\n\r\n    QCOMPARE(adHocConnection->name(), QString(\"adHoc\"));\r\n    QCOMPARE(adHocConnection->displayName(), QString(\"displayAd\"));\r\n    QCOMPARE(adHocConnection->description(), QString(\"describeAd\"));\r\n    QCOMPARE(adHocConnection->getIsPresent(), QString(\"4-3\"));\r\n    QCOMPARE(adHocConnection->getTiedValue(), QString(\"default\"));\r\n    QCOMPARE(adHocConnection->getVendorExtensions()->size(), 1);\r\n    QCOMPARE(adHocConnection->getVendorExtensions()->first()->type(), QString(\"testExtension\"));\r\n\r\n    QCOMPARE(adHocConnection->getInternalPortReferences()->size(), 1);\r\n\r\n    QSharedPointer<PortReference> internalRef = adHocConnection->getInternalPortReferences()->first();\r\n    QCOMPARE(internalRef->getComponentRef(), QString(\"componentInstance\"));\r\n    QCOMPARE(internalRef->getPortRef(), QString(\"internalPort\"));\r\n    QCOMPARE(internalRef->getIsPresent(), QString(\"1\"));\r\n\r\n    QSharedPointer<PartSelect> internalPartSelect = internalRef->getPartSelect();\r\n    QCOMPARE(internalPartSelect->getLeftRange(), QString(\"1\"));\r\n    QCOMPARE(internalPartSelect->getRightRange(), QString(\"11\"));\r\n    QCOMPARE(internalPartSelect->getIndices()->size(), 2);\r\n    QCOMPARE(internalPartSelect->getIndices()->first(), QString(\"8\"));\r\n    QCOMPARE(internalPartSelect->getIndices()->last(), QString(\"4+4\"));\r\n\r\n    QCOMPARE(adHocConnection->getExternalPortReferences()->size(), 1);\r\n\r\n    QSharedPointer<PortReference> externalRef = adHocConnection->getExternalPortReferences()->first();\r\n    QCOMPARE(externalRef->getPortRef(), QString(\"externalPort\"));\r\n    QCOMPARE(externalRef->getIsPresent(), QString(\"0\"));\r\n\r\n    QSharedPointer<PartSelect> externalPartSelect = externalRef->getPartSelect();\r\n    QCOMPARE(externalPartSelect->getLeftRange(), QString(\"0\"));\r\n    QCOMPARE(externalPartSelect->getRightRange(), QString(\"4\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_DesignReader::testReadAdHocConnections()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_DesignReader::testRead2022AdHocConnections()\r\n{\r\n    QString documentContent(\r\n        \"<ipxact:design xmlns:xsi=\\\"http://www.w3.org/2001/XMLSchema-instance\\\" \"\r\n        \"xmlns:ipxact=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2022\\\" \"\r\n        \"xmlns:kactus2=\\\"http://kactus2.cs.tut.fi\\\" \"\r\n        \"xsi:schemaLocation=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2022/ \"\r\n        \"http://www.accellera.org/XMLSchema/IPXACT/1685-2022/index.xsd\\\">\"\r\n            \"<ipxact:vendor>tuni.fi</ipxact:vendor>\"\r\n            \"<ipxact:library>TestLibrary</ipxact:library>\"\r\n            \"<ipxact:name>TestDesign</ipxact:name>\"\r\n            \"<ipxact:version>0.1</ipxact:version>\"\r\n            \"<ipxact:adHocConnections>\"\r\n                \"<ipxact:adHocConnection>\"\r\n                    \"<ipxact:name>adHoc</ipxact:name>\"\r\n                    \"<ipxact:displayName>displayAd</ipxact:displayName>\"\r\n                    \"<ipxact:shortDescription>shortAd</ipxact:shortDescription>\"\r\n                    \"<ipxact:description>describeAd</ipxact:description>\"\r\n                    \"<ipxact:tiedValue>default</ipxact:tiedValue>\"\r\n                    \"<ipxact:portReferences>\"\r\n                        \"<ipxact:internalPortReference componentInstanceRef=\\\"componentInstance\\\" portRef=\\\"internalPort\\\">\"\r\n                        \"<ipxact:partSelect>\"\r\n                            \"<ipxact:range>\"\r\n                                \"<ipxact:left>1</ipxact:left>\"\r\n                                \"<ipxact:right>11</ipxact:right>\"\r\n                            \"</ipxact:range>\"\r\n                            \"<ipxact:indices>\"\r\n                                \"<ipxact:index>8</ipxact:index>\"\r\n                                \"<ipxact:index>4+4</ipxact:index>\"\r\n                            \"</ipxact:indices>\"\r\n                        \"</ipxact:partSelect>\"\r\n                    \"</ipxact:internalPortReference>\"\r\n                    \"<ipxact:externalPortReference portRef=\\\"externalPort\\\">\"\r\n                        \"<ipxact:partSelect>\"\r\n                            \"<ipxact:range>\"\r\n                                \"<ipxact:left>0</ipxact:left>\"\r\n                                \"<ipxact:right>4</ipxact:right>\"\r\n                            \"</ipxact:range>\"\r\n                        \"</ipxact:partSelect>\"\r\n                    \"</ipxact:externalPortReference>\"\r\n                \"</ipxact:portReferences>\"\r\n                \"<ipxact:vendorExtensions>\"\r\n                    \"<testExtension testExtensionAttribute=\\\"extension\\\">testValue</testExtension>\"\r\n                \"</ipxact:vendorExtensions>\"\r\n                \"</ipxact:adHocConnection>\"\r\n            \"</ipxact:adHocConnections>\"\r\n        \"</ipxact:design>\");\r\n\r\n    QDomDocument document;\r\n    document.setContent(documentContent);\r\n\r\n    QSharedPointer<Design> testDesign = DesignReader::createDesignFrom(document);\r\n\r\n    QCOMPARE(testDesign->getRevision(), Document::Revision::Std22);\r\n    QCOMPARE(testDesign->getAdHocConnections()->size(), 1);\r\n\r\n    QSharedPointer<AdHocConnection> adHocConnection = testDesign->getAdHocConnections()->first();\r\n\r\n    QCOMPARE(adHocConnection->name(), QString(\"adHoc\"));\r\n    QCOMPARE(adHocConnection->displayName(), QString(\"displayAd\"));\r\n    QCOMPARE(adHocConnection->shortDescription(), QString(\"shortAd\"));\r\n    QCOMPARE(adHocConnection->description(), QString(\"describeAd\"));\r\n    QCOMPARE(adHocConnection->getIsPresent(), QString());\r\n    QCOMPARE(adHocConnection->getTiedValue(), QString(\"default\"));\r\n    QCOMPARE(adHocConnection->getVendorExtensions()->size(), 1);\r\n    QCOMPARE(adHocConnection->getVendorExtensions()->first()->type(), QString(\"testExtension\"));\r\n\r\n    QCOMPARE(adHocConnection->getInternalPortReferences()->size(), 1);\r\n\r\n    QSharedPointer<PortReference> internalRef = adHocConnection->getInternalPortReferences()->first();\r\n    QCOMPARE(internalRef->getComponentRef(), QString(\"componentInstance\"));\r\n    QCOMPARE(internalRef->getPortRef(), QString(\"internalPort\"));\r\n    QCOMPARE(internalRef->getIsPresent(), QString());\r\n\r\n    QSharedPointer<PartSelect> internalPartSelect = internalRef->getPartSelect();\r\n    QCOMPARE(internalPartSelect->getLeftRange(), QString(\"1\"));\r\n    QCOMPARE(internalPartSelect->getRightRange(), QString(\"11\"));\r\n    QCOMPARE(internalPartSelect->getIndices()->size(), 2);\r\n    QCOMPARE(internalPartSelect->getIndices()->first(), QString(\"8\"));\r\n    QCOMPARE(internalPartSelect->getIndices()->last(), QString(\"4+4\"));\r\n\r\n    QCOMPARE(adHocConnection->getExternalPortReferences()->size(), 1);\r\n\r\n    QSharedPointer<PortReference> externalRef = adHocConnection->getExternalPortReferences()->first();\r\n    QCOMPARE(externalRef->getPortRef(), QString(\"externalPort\"));\r\n    QCOMPARE(externalRef->getIsPresent(), QString());\r\n\r\n    QSharedPointer<PartSelect> externalPartSelect = externalRef->getPartSelect();\r\n    QCOMPARE(externalPartSelect->getLeftRange(), QString(\"0\"));\r\n    QCOMPARE(externalPartSelect->getRightRange(), QString(\"4\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_DesignReader::testReadAdHocConnections()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_DesignReader::testRead2022AdHocSubPortReferences()\r\n{\r\n    QString documentContent(\r\n        \"<ipxact:design xmlns:xsi=\\\"http://www.w3.org/2001/XMLSchema-instance\\\" \"\r\n        \"xmlns:ipxact=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2022\\\" \"\r\n        \"xmlns:kactus2=\\\"http://kactus2.cs.tut.fi\\\" \"\r\n        \"xsi:schemaLocation=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2022/ \"\r\n        \"http://www.accellera.org/XMLSchema/IPXACT/1685-2022/index.xsd\\\">\"\r\n            \"<ipxact:vendor>tuni.fi</ipxact:vendor>\"\r\n            \"<ipxact:library>TestLibrary</ipxact:library>\"\r\n            \"<ipxact:name>TestDesign</ipxact:name>\"\r\n            \"<ipxact:version>0.1</ipxact:version>\"\r\n            \"<ipxact:adHocConnections>\"\r\n                \"<ipxact:adHocConnection>\"\r\n                \"<ipxact:name>adHoc</ipxact:name>\"\r\n                \"<ipxact:tiedValue>default</ipxact:tiedValue>\"\r\n                \"<ipxact:portReferences>\"\r\n                    \"<ipxact:internalPortReference componentInstanceRef=\\\"componentInstance\\\" portRef=\\\"internalPort\\\">\"\r\n                    \"<ipxact:subPortReference subPortRef=\\\"subPort\\\" />\"\r\n                    \"<ipxact:subPortReference subPortRef=\\\"partPort\\\">\"\r\n                        \"<ipxact:partSelect>\"\r\n                            \"<ipxact:range>\"\r\n                                \"<ipxact:left>1</ipxact:left>\"\r\n                                \"<ipxact:right>1</ipxact:right>\"\r\n                            \"</ipxact:range>\"\r\n                            \"<ipxact:indices>\"\r\n                                \"<ipxact:index>1</ipxact:index>\"\r\n                            \"</ipxact:indices>\"\r\n                        \"</ipxact:partSelect>\"\r\n                    \"</ipxact:subPortReference>\"\r\n                    \"<ipxact:partSelect>\"\r\n                        \"<ipxact:range>\"\r\n                            \"<ipxact:left>7</ipxact:left>\"\r\n                            \"<ipxact:right>0</ipxact:right>\"\r\n                        \"</ipxact:range>\"\r\n                        \"<ipxact:indices>\"\r\n                            \"<ipxact:index>0</ipxact:index>\"\r\n                        \"</ipxact:indices>\"\r\n                    \"</ipxact:partSelect>\"\r\n                    \"</ipxact:internalPortReference>\"\r\n                    \"<ipxact:externalPortReference portRef=\\\"externalPort\\\">\"\r\n                        \"<ipxact:partSelect>\"\r\n                            \"<ipxact:range>\"\r\n                                \"<ipxact:left>0</ipxact:left>\"\r\n                                \"<ipxact:right>2</ipxact:right>\"\r\n                            \"</ipxact:range>\"\r\n                        \"</ipxact:partSelect>\"\r\n                        \"</ipxact:externalPortReference>\"\r\n                    \"</ipxact:portReferences>\"\r\n                \"</ipxact:adHocConnection>\"\r\n            \"</ipxact:adHocConnections>\"\r\n        \"</ipxact:design>\");\r\n\r\n    QDomDocument document;\r\n    document.setContent(documentContent);\r\n\r\n    QSharedPointer<Design> testDesign = DesignReader::createDesignFrom(document);\r\n\r\n    QCOMPARE(testDesign->getRevision(), Document::Revision::Std22);\r\n    QCOMPARE(testDesign->getAdHocConnections()->size(), 1);\r\n\r\n    QSharedPointer<AdHocConnection> adHocConnection = testDesign->getAdHocConnections()->first();\r\n\r\n    QCOMPARE(adHocConnection->name(), QString(\"adHoc\"));\r\n    QCOMPARE(adHocConnection->getTiedValue(), QString(\"default\"));\r\n\r\n    QCOMPARE(adHocConnection->getInternalPortReferences()->size(), 1);\r\n\r\n    QSharedPointer<PortReference> internalRef = adHocConnection->getInternalPortReferences()->first();\r\n    QCOMPARE(internalRef->getComponentRef(), QString(\"componentInstance\"));\r\n    QCOMPARE(internalRef->getPortRef(), QString(\"internalPort\"));\r\n    QCOMPARE(internalRef->getSubPortReferences()->size(), 2);\r\n\r\n    QSharedPointer<PortReference> subPortRef = internalRef->getSubPortReferences()->first();\r\n    QCOMPARE(subPortRef->getPortRef(), QString(\"subPort\"));\r\n\r\n    QSharedPointer<PortReference> partSubPortRef = internalRef->getSubPortReferences()->last();\r\n    QCOMPARE(partSubPortRef->getPortRef(), QString(\"partPort\"));\r\n\r\n\r\n    QSharedPointer<PartSelect> subPartSelect = partSubPortRef->getPartSelect();\r\n    QCOMPARE(subPartSelect->getLeftRange(), QString(\"1\"));\r\n    QCOMPARE(subPartSelect->getRightRange(), QString(\"1\"));\r\n    QCOMPARE(subPartSelect->getIndices()->size(), 1);\r\n    QCOMPARE(subPartSelect->getIndices()->first(), QString(\"1\"));\r\n\r\n    QSharedPointer<PartSelect> internalPartSelect = internalRef->getPartSelect();\r\n    QCOMPARE(internalPartSelect->getLeftRange(), QString(\"7\"));\r\n    QCOMPARE(internalPartSelect->getRightRange(), QString(\"0\"));\r\n    QCOMPARE(internalPartSelect->getIndices()->size(), 1);\r\n    QCOMPARE(internalPartSelect->getIndices()->first(), QString(\"0\"));\r\n\r\n    QCOMPARE(adHocConnection->getExternalPortReferences()->size(), 1);\r\n\r\n    QSharedPointer<PortReference> externalRef = adHocConnection->getExternalPortReferences()->first();\r\n    QCOMPARE(externalRef->getPortRef(), QString(\"externalPort\"));\r\n\r\n    QSharedPointer<PartSelect> externalPartSelect = externalRef->getPartSelect();\r\n    QCOMPARE(externalPartSelect->getLeftRange(), QString(\"0\"));\r\n    QCOMPARE(externalPartSelect->getRightRange(), QString(\"2\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_DesignReader::testReadAdHocConnectionExtensions()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_DesignReader::testReadAdHocConnectionExtensions()\r\n{\r\n    QString documentContent(\r\n        \"<ipxact:design xmlns:xsi=\\\"http://www.w3.org/2001/XMLSchema-instance\\\" \" \r\n        \"xmlns:ipxact=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014\\\" \"\r\n        \"xmlns:kactus2=\\\"http://kactus2.cs.tut.fi\\\" \"\r\n        \"xsi:schemaLocation=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/ \"\r\n        \"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/index.xsd\\\">\"\r\n            \"<ipxact:vendor>tuni.fi</ipxact:vendor>\"\r\n            \"<ipxact:library>TestLibrary</ipxact:library>\"\r\n            \"<ipxact:name>TestDesign</ipxact:name>\"\r\n            \"<ipxact:version>0.1</ipxact:version>\"\r\n            \"<ipxact:adHocConnections>\"\r\n                \"<ipxact:adHocConnection>\"\r\n                    \"<ipxact:name>adHoc</ipxact:name>\"\r\n                    \"<ipxact:portReferences>\"\r\n                        \"<ipxact:internalPortReference componentInstanceRef=\\\"componentInstance\\\" portRef=\\\"internalPort\\\"/>\"\r\n                        \"<ipxact:externalPortReference portRef=\\\"externalPort\\\"/>\"\r\n                    \"</ipxact:portReferences>\"\r\n                    \"<ipxact:vendorExtensions>\"\r\n                        \"<kactus2:offPage/>\"\r\n                        \"<kactus2:route>\"\r\n                            \"<kactus2:position x=\\\"1\\\" y=\\\"1\\\"/>\"\r\n                            \"<kactus2:position x=\\\"4\\\" y=\\\"1\\\"/>\"\r\n                            \"<kactus2:position x=\\\"4\\\" y=\\\"2\\\"/>\"\r\n                        \"</kactus2:route>\"\r\n                    \"</ipxact:vendorExtensions>\"\r\n                \"</ipxact:adHocConnection>\"\r\n            \"</ipxact:adHocConnections>\"\r\n        \"</ipxact:design>\");\r\n\r\n    QDomDocument document;\r\n    document.setContent(documentContent);\r\n\r\n    QSharedPointer<Design> testDesign = DesignReader::createDesignFrom(document);\r\n\r\n    QCOMPARE(testDesign->getAdHocConnections()->size(), 1);\r\n\r\n    QSharedPointer<AdHocConnection> adHocConnection = testDesign->getAdHocConnections()->first();\r\n    QCOMPARE(adHocConnection->name(), QString(\"adHoc\"));\r\n    QCOMPARE(adHocConnection->isOffPage(), true);\r\n\r\n    QCOMPARE(adHocConnection->getRoute().size(), 3);\r\n    QCOMPARE(adHocConnection->getRoute().at(0).x(), qreal(1));\r\n    QCOMPARE(adHocConnection->getRoute().at(0).y(), qreal(1));\r\n    QCOMPARE(adHocConnection->getRoute().at(1).x(), qreal(4));\r\n    QCOMPARE(adHocConnection->getRoute().at(1).y(), qreal(1));\r\n    QCOMPARE(adHocConnection->getRoute().at(2).x(), qreal(4));\r\n    QCOMPARE(adHocConnection->getRoute().at(2).y(), qreal(2));\r\n    QCOMPARE(testDesign->getRevision(), Document::Revision::Std14);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_DesignReader::testReadParameters()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_DesignReader::testReadParameters()\r\n{\r\n    QString documentContent(\r\n        \"<ipxact:design xmlns:xsi=\\\"http://www.w3.org/2001/XMLSchema-instance\\\" \" \r\n        \"xmlns:ipxact=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014\\\" \"\r\n        \"xmlns:kactus2=\\\"http://kactus2.cs.tut.fi\\\" \"\r\n        \"xsi:schemaLocation=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/ \"\r\n        \"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/index.xsd\\\">\"\r\n            \"<ipxact:vendor>tuni.fi</ipxact:vendor>\"\r\n            \"<ipxact:library>TestLibrary</ipxact:library>\"\r\n            \"<ipxact:name>TestDesign</ipxact:name>\"\r\n            \"<ipxact:version>0.1</ipxact:version>\"\r\n            \"<ipxact:description>TestDescription</ipxact:description>\"\r\n            \"<ipxact:parameters>\"\r\n                \"<ipxact:parameter parameterId=\\\"testID\\\">\"\r\n                    \"<ipxact:name>designParameter</ipxact:name>\"\r\n                    \"<ipxact:value>10+10</ipxact:value>\"\r\n                \"</ipxact:parameter>\"\r\n            \"</ipxact:parameters>\"\r\n        \"</ipxact:design>\");\r\n\r\n    QDomDocument document;\r\n    document.setContent(documentContent);\r\n\r\n    QSharedPointer<Design> testDesign = DesignReader::createDesignFrom(document);\r\n\r\n    QCOMPARE(testDesign->getParameters()->size(), 1);\r\n    QCOMPARE(testDesign->getParameters()->first()->name(), QString(\"designParameter\"));\r\n    QCOMPARE(testDesign->getParameters()->first()->getValueId(), QString(\"testID\"));\r\n    QCOMPARE(testDesign->getParameters()->first()->getValue(), QString(\"10+10\"));\r\n    QCOMPARE(testDesign->getRevision(), Document::Revision::Std14);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_DesignReader::testReadAssertions()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_DesignReader::testReadAssertions()\r\n{\r\n    QString documentContent(\r\n        \"<ipxact:design xmlns:xsi=\\\"http://www.w3.org/2001/XMLSchema-instance\\\" \" \r\n        \"xmlns:ipxact=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014\\\" \"\r\n        \"xmlns:kactus2=\\\"http://kactus2.cs.tut.fi\\\" \"\r\n        \"xsi:schemaLocation=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/ \"\r\n        \"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/index.xsd\\\">\"\r\n            \"<ipxact:vendor>tuni.fi</ipxact:vendor>\"\r\n            \"<ipxact:library>TestLibrary</ipxact:library>\"\r\n            \"<ipxact:name>TestDesign</ipxact:name>\"\r\n            \"<ipxact:version>0.1</ipxact:version>\"\r\n            \"<ipxact:description>TestDescription</ipxact:description>\"\r\n            \"<ipxact:assertions>\"\r\n                \"<ipxact:assertion>\"\r\n                    \"<ipxact:name>testAssertion</ipxact:name>\"\r\n                    \"<ipxact:displayName>assertionDisplay</ipxact:displayName>\"\r\n                    \"<ipxact:description>assertionDescription</ipxact:description>\"\r\n                    \"<ipxact:assert>13</ipxact:assert>\"\r\n                \"</ipxact:assertion>\"\r\n            \"</ipxact:assertions>\"\r\n        \"</ipxact:design>\");\r\n\r\n    QDomDocument document;\r\n    document.setContent(documentContent);\r\n\r\n    QSharedPointer<Design> testDesign = DesignReader::createDesignFrom(document);\r\n\r\n    QCOMPARE(testDesign->getAssertions()->size(), 1);\r\n    QCOMPARE(testDesign->getAssertions()->first()->name(), QString(\"testAssertion\"));\r\n    QCOMPARE(testDesign->getAssertions()->first()->displayName(), QString(\"assertionDisplay\"));\r\n    QCOMPARE(testDesign->getAssertions()->first()->description(), QString(\"assertionDescription\"));\r\n    QCOMPARE(testDesign->getAssertions()->first()->getAssert(), QString(\"13\"));\r\n    QCOMPARE(testDesign->getRevision(), Document::Revision::Std14);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_DesignReader::testReadVendorExtensions()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_DesignReader::testReadVendorExtensions()\r\n{\r\n    QString documentContent(\r\n        \"<ipxact:design xmlns:xsi=\\\"http://www.w3.org/2001/XMLSchema-instance\\\" \" \r\n        \"xmlns:ipxact=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014\\\" \"\r\n        \"xmlns:kactus2=\\\"http://kactus2.cs.tut.fi\\\" \"\r\n        \"xsi:schemaLocation=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/ \"\r\n        \"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/index.xsd\\\">\"\r\n            \"<ipxact:vendor>tuni.fi</ipxact:vendor>\"\r\n            \"<ipxact:library>TestLibrary</ipxact:library>\"\r\n            \"<ipxact:name>TestDesign</ipxact:name>\"\r\n            \"<ipxact:version>0.1</ipxact:version>\"\r\n            \"<ipxact:description>TestDescription</ipxact:description>\"\r\n            \"<ipxact:vendorExtensions>\"\r\n                \"<kactus2:version>3.0.0</kactus2:version>\"\r\n                \"<testExtension testExtensionAttribute=\\\"extension\\\">testValue</testExtension>\"                \r\n            \"</ipxact:vendorExtensions>\\n\"\r\n        \"</ipxact:design>\");\r\n\r\n    QDomDocument document;\r\n    document.setContent(documentContent);\r\n\r\n    QSharedPointer<Design> testDesign = DesignReader::createDesignFrom(document);\r\n\r\n    QCOMPARE(testDesign->getVendorExtensions()->size(), 2);\r\n    QCOMPARE(testDesign->getVendorExtensions()->last()->type(), QString(\"testExtension\"));\r\n    QCOMPARE(testDesign->getVersion(), QString(\"3.0.0\"));\r\n    QCOMPARE(testDesign->getRevision(), Document::Revision::Std14);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_DesignReader::testReadColumns()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_DesignReader::testReadColumns()\r\n{\r\n    QString documentContent(\r\n        \"<ipxact:design xmlns:xsi=\\\"http://www.w3.org/2001/XMLSchema-instance\\\" \" \r\n        \"xmlns:ipxact=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014\\\" \"\r\n        \"xmlns:kactus2=\\\"http://kactus2.cs.tut.fi\\\" \"\r\n        \"xsi:schemaLocation=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/ \"\r\n        \"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/index.xsd\\\">\"\r\n            \"<ipxact:vendor>tuni.fi</ipxact:vendor>\"\r\n            \"<ipxact:library>TestLibrary</ipxact:library>\"\r\n            \"<ipxact:name>TestDesign</ipxact:name>\"\r\n            \"<ipxact:version>0.1</ipxact:version>\"\r\n            \"<ipxact:description>TestDescription</ipxact:description>\"\r\n            \"<ipxact:vendorExtensions>\"\r\n                \"<kactus2:version>3.0.0</kactus2:version>\"\r\n                \"<kactus2:columnLayout>\"\r\n                    \"<kactus2:column name=\\\"testColumn\\\" contentType=\\\"2\\\" allowedItems=\\\"0\\\" \"\r\n                        \"minWidth=\\\"259\\\" width=\\\"259\\\"/>\"\r\n                    \"<kactus2:column name=\\\"otherColumn\\\" contentType=\\\"1\\\" allowedItems=\\\"0\\\" \"\r\n                        \"minWidth=\\\"259\\\" width=\\\"259\\\"/>\"\r\n                \"</kactus2:columnLayout>\"\r\n            \"</ipxact:vendorExtensions>\"\r\n        \"</ipxact:design>\");\r\n\r\n    QDomDocument document;\r\n    document.setContent(documentContent);\r\n\r\n    QSharedPointer<Design> testDesign = DesignReader::createDesignFrom(document);\r\n\r\n    QCOMPARE(testDesign->getVendorExtensions()->size(), 2);\r\n    QCOMPARE(testDesign->getVersion(), QString(\"3.0.0\"));\r\n\r\n    QList<QSharedPointer<ColumnDesc> > columnList = testDesign->getColumns();\r\n    QCOMPARE(columnList.size(), 2);\r\n\r\n    int firstColumnWidth = columnList.first()->getWidth();\r\n    QCOMPARE(columnList.first()->name(), QString(\"testColumn\"));\r\n    QCOMPARE(columnList.first()->getContentType(), ColumnTypes::COMPONENTS);\r\n    QVERIFY(columnList.first()->getAllowedItems() == 0);\r\n    QCOMPARE(firstColumnWidth, 259);\r\n\r\n    int secondColumnWidth = columnList.last()->getWidth();\r\n    QCOMPARE(columnList.last()->name(), QString(\"otherColumn\"));\r\n    QCOMPARE(columnList.last()->getContentType(), ColumnTypes::BUSES);\r\n    QVERIFY(columnList.last()->getAllowedItems() == 0);\r\n    QCOMPARE(secondColumnWidth, 259);\r\n    QCOMPARE(testDesign->getRevision(), Document::Revision::Std14);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_DesignReader::testReadSWInstances()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_DesignReader::testReadSWInstances()\r\n{\r\n    QString documentContent(\r\n        \"<ipxact:design xmlns:xsi=\\\"http://www.w3.org/2001/XMLSchema-instance\\\" \" \r\n        \"xmlns:ipxact=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014\\\" \"\r\n        \"xmlns:kactus2=\\\"http://kactus2.cs.tut.fi\\\" \"\r\n        \"xsi:schemaLocation=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/ \"\r\n        \"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/index.xsd\\\">\"\r\n            \"<ipxact:vendor>tuni.fi</ipxact:vendor>\"\r\n            \"<ipxact:library>TestLibrary</ipxact:library>\"\r\n            \"<ipxact:name>TestDesign</ipxact:name>\"\r\n            \"<ipxact:version>0.1</ipxact:version>\"\r\n            \"<ipxact:description>TestDescription</ipxact:description>\"\r\n            \"<ipxact:vendorExtensions>\"\r\n                \"<kactus2:version>3.0.0</kactus2:version>\"\r\n                \"<kactus2:swInstances>\"\r\n                    \"<kactus2:swInstance>\"\r\n                        \"<kactus2:instanceName>testInstance</kactus2:instanceName>\"\r\n                        \"<kactus2:displayName>testDisplay</kactus2:displayName>\"\r\n                        \"<kactus2:description>testDescription</kactus2:description>\"\r\n                        \"<kactus2:componentRef vendor=\\\"tuni.fi\\\" library=\\\"TestLibrary\\\" name=\\\"refComponent\\\"\"\r\n                            \" version=\\\"1.1\\\"/>\"\r\n                        \"<kactus2:fileSetRef>filesetRef</kactus2:fileSetRef>\"\r\n                        \"<kactus2:mapping hwRef=\\\"hwRef\\\"/>\"\r\n                        \"<kactus2:position x=\\\"1\\\" y=\\\"2\\\"/>\"\r\n                        \"<kactus2:imported importRef=\\\"importer\\\"/>\"\r\n                        \"<kactus2:draft/>\"\r\n                        \"<kactus2:propertyValues>\"\r\n                            \"<kactus2:propertyValue name=\\\"testProperty\\\" value=\\\"value\\\"/>\"\r\n                        \"</kactus2:propertyValues>\"\r\n                        \"<kactus2:apiInterfacePositions>\"\r\n                            \"<kactus2:apiInterfacePosition apiRef=\\\"newApi\\\" x=\\\"0\\\" y=\\\"1\\\"/>\"\r\n                        \"</kactus2:apiInterfacePositions>\"\r\n                        \"<kactus2:comInterfacePositions>\"\r\n                            \"<kactus2:comInterfacePosition comRef=\\\"newCom\\\" x=\\\"1\\\" y=\\\"1\\\"/>\"\r\n                        \"</kactus2:comInterfacePositions>\"\r\n                    \"</kactus2:swInstance>\"\r\n                \"</kactus2:swInstances>\"\r\n            \"</ipxact:vendorExtensions>\"\r\n        \"</ipxact:design>\");\r\n\r\n    QDomDocument document;\r\n    document.setContent(documentContent);\r\n\r\n    QSharedPointer<Design> testDesign = DesignReader::createDesignFrom(document);\r\n\r\n    QCOMPARE(testDesign->getComponentInstances()->size(), 1);\r\n    QCOMPARE(testDesign->getVersion(), QString(\"3.0.0\"));\r\n\r\n    QSharedPointer<ComponentInstance> swInstance = testDesign->getComponentInstances()->first();\r\n\r\n    QCOMPARE(swInstance->getInstanceName(), QString(\"testInstance\"));\r\n    QCOMPARE(swInstance->displayName(), QString(\"testDisplay\"));\r\n    QCOMPARE(swInstance->description(), QString(\"testDescription\"));\r\n\r\n    QCOMPARE(swInstance->getComponentRef()->getVendor(), QString(\"tuni.fi\"));\r\n    QCOMPARE(swInstance->getComponentRef()->getLibrary(), QString(\"TestLibrary\"));\r\n    QCOMPARE(swInstance->getComponentRef()->getName(), QString(\"refComponent\"));\r\n    QCOMPARE(swInstance->getComponentRef()->getVersion(), QString(\"1.1\"));\r\n\r\n    QCOMPARE(swInstance->getFileSetRef(), QString(\"filesetRef\"));\r\n    QCOMPARE(swInstance->getMapping(), QString(\"hwRef\"));\r\n    QCOMPARE(swInstance->getPosition().x(), qreal(1));\r\n    QCOMPARE(swInstance->getPosition().y(), qreal(2));\r\n    \r\n    QCOMPARE(swInstance->isImported(), true);\r\n    QCOMPARE(swInstance->getImportRef(), QString(\"importer\"));\r\n    \r\n    QCOMPARE(swInstance->isDraft(), true);\r\n    QCOMPARE(swInstance->getPropertyValues().count(), 1);\r\n    QCOMPARE(swInstance->getPropertyValues().firstKey(), QString(\"testProperty\"));\r\n    QCOMPARE(swInstance->getPropertyValues().first(), QString(\"value\"));\r\n    QCOMPARE(testDesign->getRevision(), Document::Revision::Std14);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_DesignReader::testReadPortAdHocVisibilitiesAndPositions()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_DesignReader::testReadPortAdHocVisibilitiesAndPositions()\r\n{\r\n    QString documentContent(\r\n        \"<ipxact:design xmlns:xsi=\\\"http://www.w3.org/2001/XMLSchema-instance\\\" \" \r\n        \"xmlns:ipxact=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014\\\" \"\r\n        \"xmlns:kactus2=\\\"http://kactus2.cs.tut.fi\\\" \"\r\n        \"xsi:schemaLocation=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/ \"\r\n        \"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/index.xsd\\\">\"\r\n            \"<ipxact:vendor>tuni.fi</ipxact:vendor>\"\r\n            \"<ipxact:library>TestLibrary</ipxact:library>\"\r\n            \"<ipxact:name>TestDesign</ipxact:name>\"\r\n            \"<ipxact:version>0.1</ipxact:version>\"\r\n            \"<ipxact:description>TestDescription</ipxact:description>\"\r\n            \"<ipxact:vendorExtensions>\"\r\n                \"<kactus2:version>3.0.0</kactus2:version>\"\r\n                \"<kactus2:adHocVisibilities>\"\r\n                    \"<kactus2:adHocVisible portName=\\\"testPort\\\" x=\\\"4\\\" y=\\\"25\\\"/>\"\r\n                \"</kactus2:adHocVisibilities>\"\r\n            \"</ipxact:vendorExtensions>\"\r\n        \"</ipxact:design>\");\r\n\r\n    QDomDocument document;\r\n    document.setContent(documentContent);\r\n\r\n    QSharedPointer<Design> testDesign = DesignReader::createDesignFrom(document);\r\n\r\n    QCOMPARE(testDesign->getVendorExtensions()->size(), 2);\r\n    QCOMPARE(testDesign->getVersion(), QString(\"3.0.0\"));\r\n\r\n    QSharedPointer<VendorExtension> adhocExtension = testDesign->getAdHocPortPositions();\r\n    QSharedPointer<Kactus2Group> adhocGroup = adhocExtension.dynamicCast<Kactus2Group>();\r\n\r\n    QMap<QString, QPointF> adHocPorts;\r\n    foreach (QSharedPointer<VendorExtension> extension, adhocGroup->getByType(\"kactus2:adHocVisible\"))\r\n    {\r\n        QSharedPointer<Kactus2Placeholder> portAdHocVisibility = extension.dynamicCast<Kactus2Placeholder>();\r\n\r\n        QString portName = portAdHocVisibility->getAttributeValue(\"portName\");\r\n        int positionX = portAdHocVisibility->getAttributeValue(\"x\").toInt();\r\n        int positionY = portAdHocVisibility->getAttributeValue(\"y\").toInt();\r\n\r\n        adHocPorts.insert(portName, QPointF(positionX, positionY));\r\n    }\r\n\r\n    QCOMPARE(adHocPorts.firstKey(), QString(\"testPort\"));\r\n    QCOMPARE(adHocPorts.first().x(), qreal(4));\r\n    QCOMPARE(adHocPorts.first().y(), qreal(25));\r\n    QCOMPARE(testDesign->getRevision(), Document::Revision::Std14);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_DesignReader::testReadApiDependencies()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_DesignReader::testReadApiConnections()\r\n{\r\n    QString documentContent(\r\n        \"<ipxact:design xmlns:xsi=\\\"http://www.w3.org/2001/XMLSchema-instance\\\" \" \r\n        \"xmlns:ipxact=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014\\\" \"\r\n        \"xmlns:kactus2=\\\"http://kactus2.cs.tut.fi\\\" \"\r\n        \"xsi:schemaLocation=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/ \"\r\n        \"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/index.xsd\\\">\"\r\n            \"<ipxact:vendor>tuni.fi</ipxact:vendor>\"\r\n            \"<ipxact:library>TestLibrary</ipxact:library>\"\r\n            \"<ipxact:name>TestDesign</ipxact:name>\"\r\n            \"<ipxact:version>0.1</ipxact:version>\"\r\n            \"<ipxact:description>TestDescription</ipxact:description>\"\r\n            \"<ipxact:vendorExtensions>\"\r\n                \"<kactus2:version>3.0.0</kactus2:version>\"\r\n                \"<kactus2:apiConnections>\"\r\n                    \"<kactus2:apiConnection>\"\r\n                        \"<ipxact:name>apiConnect</ipxact:name>\"\r\n                        \"<ipxact:displayName>connection</ipxact:displayName>\"\r\n                        \"<ipxact:description>described</ipxact:description>\"\r\n                        \"<kactus2:activeApiInterface componentRef=\\\"applicationOne\\\" apiRef=\\\"busOne\\\"/>\"\r\n                        \"<kactus2:activeApiInterface componentRef=\\\"applicationTwo\\\" apiRef=\\\"busTwo\\\"/>\"\r\n                        \"<kactus2:route offPage=\\\"false\\\">\"\r\n                            \"<kactus2:position x=\\\"1\\\" y=\\\"1\\\"/>\"\r\n                        \"</kactus2:route>\"\r\n                        \"<kactus2:imported/>\"\r\n                    \"</kactus2:apiConnection>\"\r\n                \"</kactus2:apiConnections>\"\r\n            \"</ipxact:vendorExtensions>\"\r\n        \"</ipxact:design>\");\r\n\r\n    QDomDocument document;\r\n    document.setContent(documentContent);\r\n\r\n    QSharedPointer<Design> testDesign = DesignReader::createDesignFrom(document);\r\n\r\n    QCOMPARE(testDesign->getVendorExtensions()->size(), 2);\r\n    QCOMPARE(testDesign->getVersion(), QString(\"3.0.0\"));\r\n\r\n    QList<QSharedPointer<ApiInterconnection> > apiConnections = testDesign->getApiConnections();\r\n    QCOMPARE(apiConnections.size(), 1);\r\n    QCOMPARE(apiConnections.first()->name(), QString(\"apiConnect\"));\r\n    QCOMPARE(apiConnections.first()->displayName(), QString(\"connection\"));\r\n    QCOMPARE(apiConnections.first()->description(), QString(\"described\"));\r\n\r\n    QCOMPARE(apiConnections.first()->getStartInterface()->getComponentReference(), QString(\"applicationOne\"));\r\n    QCOMPARE(apiConnections.first()->getStartInterface()->getBusReference(), QString(\"busOne\"));\r\n    QCOMPARE(apiConnections.first()->getActiveInterfaces()->first()->getComponentReference(), QString(\"applicationTwo\"));\r\n    QCOMPARE(apiConnections.first()->getActiveInterfaces()->first()->getBusReference(), QString(\"busTwo\"));\r\n\r\n    QCOMPARE(apiConnections.first()->isOffPage(), false);\r\n\r\n    QCOMPARE(apiConnections.first()->isImported(), true);\r\n    QCOMPARE(testDesign->getRevision(), Document::Revision::Std14);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_DesignReader::testReadHierApiConnections()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_DesignReader::testReadHierApiConnections()\r\n{\r\n    QString documentContent(\r\n        \"<ipxact:design xmlns:xsi=\\\"http://www.w3.org/2001/XMLSchema-instance\\\" \" \r\n        \"xmlns:ipxact=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014\\\" \"\r\n        \"xmlns:kactus2=\\\"http://kactus2.cs.tut.fi\\\" \"\r\n        \"xsi:schemaLocation=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/ \"\r\n        \"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/index.xsd\\\">\"\r\n            \"<ipxact:vendor>tuni.fi</ipxact:vendor>\"\r\n            \"<ipxact:library>TestLibrary</ipxact:library>\"\r\n            \"<ipxact:name>TestDesign</ipxact:name>\"\r\n            \"<ipxact:version>0.1</ipxact:version>\"\r\n            \"<ipxact:description>TestDescription</ipxact:description>\"\r\n            \"<ipxact:vendorExtensions>\"\r\n                \"<kactus2:version>3.0.0</kactus2:version>\"\r\n                \"<kactus2:apiConnections>\"\r\n                    \"<kactus2:apiConnection>\"\r\n                        \"<ipxact:name>hierApi</ipxact:name>\"\r\n                        \"<ipxact:displayName>display</ipxact:displayName>\"\r\n                        \"<ipxact:description>description</ipxact:description>\"\r\n                        \"<kactus2:activeApiInterface componentRef=\\\"applicationOne\\\" apiRef=\\\"busOne\\\"/>\"           \r\n                        \"<kactus2:hierApiInterface apiRef=\\\"topInterface\\\"/>\"      \r\n                    \"</kactus2:apiConnection>\"\r\n                \"</kactus2:apiConnections>\"\r\n            \"</ipxact:vendorExtensions>\"\r\n        \"</ipxact:design>\");\r\n\r\n    QDomDocument document;\r\n    document.setContent(documentContent);\r\n\r\n    QSharedPointer<Design> testDesign = DesignReader::createDesignFrom(document);\r\n\r\n    QCOMPARE(testDesign->getVendorExtensions()->size(), 2);\r\n    QCOMPARE(testDesign->getVersion(), QString(\"3.0.0\"));\r\n\r\n    QList<QSharedPointer<ApiInterconnection> > hierApiConnections = testDesign->getApiConnections();\r\n    QCOMPARE(hierApiConnections.size(), 1);\r\n    QCOMPARE(hierApiConnections.first()->name(), QString(\"hierApi\"));\r\n    QCOMPARE(hierApiConnections.first()->displayName(), QString(\"display\"));\r\n    QCOMPARE(hierApiConnections.first()->description(), QString(\"description\"));\r\n\r\n    QCOMPARE(hierApiConnections.first()->getEndInterface()->getBusReference(), QString(\"topInterface\"));\r\n    QCOMPARE(hierApiConnections.first()->getStartInterface()->getComponentReference(), QString(\"applicationOne\"));\r\n    QCOMPARE(hierApiConnections.first()->getStartInterface()->getBusReference(), QString(\"busOne\"));\r\n    QCOMPARE(testDesign->getRevision(), Document::Revision::Std14);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_DesignReader::testReadComConnections()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_DesignReader::testReadComConnections()\r\n{\r\n    QString documentContent(\r\n        \"<ipxact:design xmlns:xsi=\\\"http://www.w3.org/2001/XMLSchema-instance\\\" \" \r\n        \"xmlns:ipxact=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014\\\" \"\r\n        \"xmlns:kactus2=\\\"http://kactus2.cs.tut.fi\\\" \"\r\n        \"xsi:schemaLocation=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/ \"\r\n        \"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/index.xsd\\\">\"\r\n            \"<ipxact:vendor>tuni.fi</ipxact:vendor>\"\r\n            \"<ipxact:library>TestLibrary</ipxact:library>\"\r\n            \"<ipxact:name>TestDesign</ipxact:name>\"\r\n            \"<ipxact:version>0.1</ipxact:version>\"\r\n            \"<ipxact:description>TestDescription</ipxact:description>\"\r\n            \"<ipxact:vendorExtensions>\"\r\n                \"<kactus2:version>3.0.0</kactus2:version>\"\r\n                \"<kactus2:comConnections>\"\r\n                    \"<kactus2:comConnection>\"\r\n                        \"<ipxact:name>comConnect</ipxact:name>\"\r\n                        \"<ipxact:displayName>display</ipxact:displayName>\"\r\n                        \"<ipxact:description>description</ipxact:description>\"\r\n                        \"<kactus2:activeComInterface componentRef=\\\"applicationOne\\\" comRef=\\\"busOne\\\"/>\"\r\n                        \"<kactus2:activeComInterface componentRef=\\\"applicationTwo\\\" comRef=\\\"busTwo\\\"/>\"\r\n                        \"<kactus2:route offPage=\\\"false\\\">\"\r\n                            \"<kactus2:position x=\\\"1\\\" y=\\\"1\\\"/>\"\r\n                        \"</kactus2:route>\"\r\n                    \"</kactus2:comConnection>\"\r\n                \"</kactus2:comConnections>\"\r\n            \"</ipxact:vendorExtensions>\"\r\n        \"</ipxact:design>\");\r\n\r\n    QDomDocument document;\r\n    document.setContent(documentContent);\r\n\r\n    QSharedPointer<Design> testDesign = DesignReader::createDesignFrom(document);\r\n\r\n    QCOMPARE(testDesign->getVendorExtensions()->size(), 2);\r\n    QCOMPARE(testDesign->getVersion(), QString(\"3.0.0\"));\r\n\r\n    QList<QSharedPointer<ComInterconnection> > comConnections = testDesign->getComConnections();\r\n    QCOMPARE(comConnections.size(), 1);\r\n    QCOMPARE(comConnections.first()->name(), QString(\"comConnect\"));\r\n    QCOMPARE(comConnections.first()->displayName(), QString(\"display\"));\r\n    QCOMPARE(comConnections.first()->description(), QString(\"description\"));\r\n\r\n    QCOMPARE(comConnections.first()->getStartInterface()->getComponentReference(), QString(\"applicationOne\"));\r\n    QCOMPARE(comConnections.first()->getStartInterface()->getBusReference(), QString(\"busOne\"));\r\n    QCOMPARE(comConnections.first()->getActiveInterfaces()->first()->getComponentReference(), QString(\"applicationTwo\"));\r\n    QCOMPARE(comConnections.first()->getActiveInterfaces()->first()->getBusReference(), QString(\"busTwo\"));\r\n    QCOMPARE(testDesign->getRevision(), Document::Revision::Std14);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_DesignReader::testReadHierComConnections()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_DesignReader::testReadHierComConnections()\r\n{\r\n    QString documentContent(\r\n        \"<ipxact:design xmlns:xsi=\\\"http://www.w3.org/2001/XMLSchema-instance\\\" \" \r\n        \"xmlns:ipxact=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014\\\" \"\r\n        \"xmlns:kactus2=\\\"http://kactus2.cs.tut.fi\\\" \"\r\n        \"xsi:schemaLocation=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/ \"\r\n        \"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/index.xsd\\\">\"\r\n            \"<ipxact:vendor>tuni.fi</ipxact:vendor>\"\r\n            \"<ipxact:library>TestLibrary</ipxact:library>\"\r\n            \"<ipxact:name>TestDesign</ipxact:name>\"\r\n            \"<ipxact:version>0.1</ipxact:version>\"\r\n            \"<ipxact:description>TestDescription</ipxact:description>\"\r\n            \"<ipxact:vendorExtensions>\"\r\n                \"<kactus2:version>3.0.0</kactus2:version>\"\r\n                \"<kactus2:comConnections>\"\r\n                    \"<kactus2:comConnection>\"\r\n                        \"<ipxact:name>hierComConnection</ipxact:name>\"\r\n                        \"<ipxact:displayName>display</ipxact:displayName>\"\r\n                        \"<ipxact:description>description</ipxact:description>\"\r\n                        \"<kactus2:activeComInterface componentRef=\\\"applicationOne\\\" comRef=\\\"busOne\\\"/>\"\r\n                        \"<kactus2:hierComInterface comRef=\\\"topInterface\\\"/>\"\r\n                    \"</kactus2:comConnection>\"\r\n                \"</kactus2:comConnections>\"\r\n            \"</ipxact:vendorExtensions>\"\r\n        \"</ipxact:design>\");\r\n\r\n    QDomDocument document;\r\n    document.setContent(documentContent);\r\n\r\n    QSharedPointer<Design> testDesign = DesignReader::createDesignFrom(document);\r\n\r\n    QCOMPARE(testDesign->getVendorExtensions()->size(), 2);\r\n    QCOMPARE(testDesign->getVersion(), QString(\"3.0.0\"));\r\n\r\n    QList<QSharedPointer<ComInterconnection> > hierComConnections = testDesign->getComConnections();\r\n    QCOMPARE(hierComConnections.size(), 1);\r\n    QCOMPARE(hierComConnections.first()->name(), QString(\"hierComConnection\"));\r\n    QCOMPARE(hierComConnections.first()->displayName(), QString(\"display\"));\r\n    QCOMPARE(hierComConnections.first()->description(), QString(\"description\"));\r\n\r\n    QCOMPARE(hierComConnections.first()->getEndInterface()->getBusReference(), QString(\"topInterface\"));\r\n    QCOMPARE(hierComConnections.first()->getStartInterface()->getComponentReference(), QString(\"applicationOne\"));\r\n    QCOMPARE(hierComConnections.first()->getStartInterface()->getBusReference(), QString(\"busOne\"));\r\n    QCOMPARE(testDesign->getRevision(), Document::Revision::Std14);\r\n}\r\n\r\nQTEST_APPLESS_MAIN(tst_DesignReader)\r\n\r\n#include \"tst_DesignReader.moc\"\r\n"
  },
  {
    "path": "tests/IPXACTmodels/Design/tst_DesignReader.pri",
    "content": "# ----------------------------------------------------\r\n# This file is generated by the Qt Visual Studio Tools.\r\n# ------------------------------------------------------\r\n\r\nSOURCES += ./tst_DesignReader.cpp\r\n"
  },
  {
    "path": "tests/IPXACTmodels/Design/tst_DesignReader.pro",
    "content": "#-----------------------------------------------------------------------------\r\n# File: tst_DesignReader.pro\r\n#-----------------------------------------------------------------------------\r\n# Project: Kactus 2\r\n# Author: Esko Pekkarinen\r\n# Date: 24.7.2014\r\n#\r\n# Description:\r\n# Qt project file template for running unit tests for a single module.\r\n#-----------------------------------------------------------------------------\r\n\r\nTEMPLATE = app\r\n\r\nTARGET = tst_DesignReader\r\n\r\nQT += core gui xml testlib\r\n\r\nCONFIG += c++11 testcase console\r\n\r\nlinux-g++ | linux-g++-64 | linux-g++-32 {\r\n LIBS += -L../../../executable \\\r\n     -lIPXACTmodels\r\n\r\n}\r\nwin64 | win32 {\r\n LIBS += -L../../../executable \\\r\n     -lIPXACTmodelsd\r\n}\r\n\r\nDESTDIR = ./release\r\n\r\nINCLUDEPATH += $$DESTDIR\r\nINCLUDEPATH += ../../../\r\n\r\nDEPENDPATH += .\r\nDEPENDPATH += ../../../\r\n\r\nOBJECTS_DIR += $$DESTDIR\r\n\r\nMOC_DIR += ./generatedFiles\r\nUI_DIR += ./generatedFiles\r\nRCC_DIR += ./generatedFiles\r\ninclude(tst_DesignReader.pri)\r\n"
  },
  {
    "path": "tests/IPXACTmodels/Design/tst_DesignValidator.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: tst_DesignValidator.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Mikko Teuho\n// Date: 14.01.2016\n//\n// Description:\n// Unit test for class DesignValidator.\n//-----------------------------------------------------------------------------\n\n#include <IPXACTmodels/common/VLNV.h>\n#include <IPXACTmodels/common/ConfigurableVLNVReference.h>\n#include <IPXACTmodels/common/Parameter.h>\n#include <IPXACTmodels/common/Assertion.h>\n#include <IPXACTmodels/common/PartSelect.h>\n\n#include <IPXACTmodels/Component/Component.h>\n#include <IPXACTmodels/Component/BusInterface.h>\n#include <IPXACTmodels/Component/PortMap.h>\n#include <IPXACTmodels/Component/Port.h>\n\n#include <IPXACTmodels/Design/Design.h>\n#include <IPXACTmodels/Design/ComponentInstance.h>\n#include <IPXACTmodels/Design/Interconnection.h>\n#include <IPXACTmodels/Design/MonitorInterconnection.h>\n#include <IPXACTmodels/Design/AdHocConnection.h>\n#include <IPXACTmodels/Design/PortReference.h>\n\n#include <IPXACTmodels/Design/validator/DesignValidator.h>\n#include <IPXACTmodels/Design/validator/ComponentInstanceValidator.h>\n#include <IPXACTmodels/Design/validator/InterconnectionValidator.h>\n#include <IPXACTmodels/Design/validator/AdHocConnectionValidator.h>\n\n#include <KactusAPI/include/SystemVerilogExpressionParser.h>\n\n#include <tests/MockObjects/LibraryMock.h>\n\n#include <QtTest>\n\nclass tst_DesignValidator : public QObject\n{\n    Q_OBJECT\n\npublic:\n    tst_DesignValidator();\n\nprivate slots:\n\n    void testHasValidVLNV();\n    void testHasValidVLNV_data();\n\n    void testComponentInstanceHasValidName();\n    void testComponentInstanceHasValidName_data();\n\n    void testComponentInstanceHasValidIsPresent();\n    void testComponentInstanceHasValidIsPresent_data();\n\n    void testComponentInstanceHasValidComponentReference();\n    void testComponentInstanceHasValidComponentReference_data();\n\n    void testHasValidComponentInstances();\n    void testHasValidComponentInstances_data();\n\n    void testInterconnectionHasValidName();\n    void testInterconnectionHasValidName_data();\n\n    void testInterconnectionHasValidIsPresent();\n    void testInterconnectionHasValidIsPresent_data();\n\n    void testInterconnectionActiveInterfaceIsValid();\n    void testInterconnectionActiveInterfaceIsValid_data();\n\n    void testInterconnectionActiveInterfaceHasValidIsPresent();\n    void testInterconnectionActiveInterfaceHasValidIsPresent_data();\n\n    void testInterconnectionActiveInterfaceHasValidExcludePorts();\n    void testInterconnectionActiveInterfaceHasValidExcludePorts_data();\n\n    void testInterconnectionInterfacesAreValid();\n    void testInterconnectionInterfacesAreValid_data();\n\n    void testHasValidInterconnections();\n    void testHasValidInterconnections_data();\n\n    void testMonitorInterconnectionHasValidName();\n    void testMonitorInterconnectionHasValidName_data();\n\n    void testMonitorInterconnectionHasValidIsPresent();\n    void testMonitorInterconnectionHasValidIsPresent_data();\n\n    void testMonitorInterconnectionHasValidMonitoredActiveInterface();\n    void testMonitorInterconnectionHasValidMonitoredActiveInterface_data();\n\n    void testMonitorInterconnectionHasValidMonitorInterfaces();\n    void testMonitorInterconnectionHasValidMonitorInterfaces_data();\n\n    void testHasValidMonitorInterconnections();\n    void testHasValidMonitorInterconnections_data();\n\n    void testAdHocConnectionHasValidName();\n    void testAdHocConnectionHasValidName_data();\n\n    void testAdHocConnectionHasValidIsPresent();\n    void testAdHocConnectionHasValidIsPresent_data();\n\n    void testAdHocConnectionHasValidTiedValue();\n    void testAdHocConnectionHasValidTiedValue_data();\n\n    void testAdHocConnectionHasValidInternalPortReference();\n    void testAdHocConnectionHasValidInternalPortReference_data();\n\n    void testAdHocConnectionHasValidExternalPortReference();\n    void testAdHocConnectionHasValidExternalPortReference_data();\n\n    void testAdHocConnectionPortReferenceHasValidPartSelect();\n    void testAdHocConnectionPortReferenceHasValidPartSelect_data();\n\n    void testHasValidAdHocConnections();\n    void testHasValidAdHocConnections_data();\n\n    void testHasValidParameters();\n    void testHasValidParameters_data();\n\n    void testHasValidAssertions();\n    void testHasValidAssertions_data();\n\nprivate:\n\n    bool errorIsNotFoundInErrorList(QString const& expectedError, QVector<QString> errorList);\n\n    QSharedPointer<DesignValidator> createDesignValidator(LibraryInterface* library);\n\n    QSharedPointer<ComponentInstanceValidator> createComponentInstanceValidator(LibraryInterface* library);\n\n    QSharedPointer<InterconnectionValidator> createInterconnectionValidator(LibraryInterface* library);\n\n    QSharedPointer<AdHocConnectionValidator> createAdHocConnectionValidator(LibraryInterface* library);\n};\n\n//-----------------------------------------------------------------------------\n// Function: tst_DesignValidator::tst_DesignValidator()\n//-----------------------------------------------------------------------------\ntst_DesignValidator::tst_DesignValidator()\n{\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_DesignValidator::testHasValidVLNV()\n//-----------------------------------------------------------------------------\nvoid tst_DesignValidator::testHasValidVLNV()\n{\n    QFETCH(QString, vendor);\n    QFETCH(QString, library);\n    QFETCH(QString, name);\n    QFETCH(QString, version);\n    QFETCH(bool, isValid);\n\n    VLNV designVLNV(VLNV::DESIGN, vendor, library, name, version);\n    QSharedPointer<Design> testDesign (new Design(designVLNV, Document::Revision::Std14));\n\n    QSharedPointer<DesignValidator> validator = createDesignValidator(0);\n\n    QCOMPARE(validator->hasValidVLNV(testDesign), isValid);\n\n    if (!isValid)\n    {\n        QVector<QString> foundErrors;\n        validator->findErrorsIn(foundErrors, testDesign);\n\n        QString expectedError = QObject::tr(\"The type of the vlnv is invalid within design\");\n\n        if (vendor.isEmpty())\n        {\n            expectedError = QObject::tr(\"No vendor specified for vlnv within design\");\n        }\n        else if (library.isEmpty())\n        {\n            expectedError = QObject::tr(\"No library specified for vlnv within design\");\n        }\n        else if (name.isEmpty())\n        {\n            expectedError = QObject::tr(\"No name specified for vlnv within design\");\n        }\n        else if (version.isEmpty())\n        {\n            expectedError = QObject::tr(\"No version specified for vlnv within design\");\n        }\n\n        if (errorIsNotFoundInErrorList(expectedError, foundErrors))\n        {\n            QFAIL(\"No error message found\");\n        }\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_DesignValidator::testHasValidVLNV_data()\n//-----------------------------------------------------------------------------\nvoid tst_DesignValidator::testHasValidVLNV_data()\n{\n    QTest::addColumn<QString>(\"vendor\");\n    QTest::addColumn<QString>(\"library\");\n    QTest::addColumn<QString>(\"name\");\n    QTest::addColumn<QString>(\"version\");\n    QTest::addColumn<bool>(\"isValid\");\n\n    QTest::newRow(\"Design with all VLNVs is valid\") << \"Tengen\" << \"Toppa\" << \"Gurren\" << \"Lagann\" << true;\n    QTest::newRow(\"Design without vendor is not valid\") << \"\" << \"Toppa\" << \"Gurren\" << \"Lagann\" << false;\n    QTest::newRow(\"Design without library is not valid\") << \"Tengen\" << \"\" << \"Gurren\" << \"Lagann\" << false;\n    QTest::newRow(\"Design without name is not valid\") << \"Tengen\" << \"Toppa\" << \"\" << \"Lagann\" << false;\n    QTest::newRow(\"Design without version is not valid\") << \"Tengen\" << \"Toppa\" << \"Gurren\" << \"\" << false;\n    QTest::newRow(\"Empty VLNV is not valid\") << \"\" << \"\" << \"\" << \"\" << false;\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_DesignValidator::testComponentInstanceHasValidName()\n//-----------------------------------------------------------------------------\nvoid tst_DesignValidator::testComponentInstanceHasValidName()\n{\n    QFETCH(QString, name);\n    QFETCH(bool, isValid);\n\n    QSharedPointer<ComponentInstance> testInstance (new ComponentInstance());\n    testInstance->setInstanceName(name);\n\n    QSharedPointer<ComponentInstanceValidator> validator = createComponentInstanceValidator(0);\n\n    QCOMPARE(validator->hasValidName(testInstance), isValid);\n\n    if (!isValid)\n    {\n        QVector<QString> foundErrors;\n        validator->findErrorsIn(foundErrors, testInstance, \"test\");\n\n        QString expectedError = QObject::tr(\"Invalid instance name '%1' set for component instance within %2\")\n            .arg(name.trimmed()).arg(\"test\");\n\n        if (errorIsNotFoundInErrorList(expectedError, foundErrors))\n        {\n            QFAIL(\"No error message found\");\n        }\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_DesignValidator::testComponentInstanceHasValidName_data()\n//-----------------------------------------------------------------------------\nvoid tst_DesignValidator::testComponentInstanceHasValidName_data()\n{\n    QTest::addColumn<QString>(\"name\");\n    QTest::addColumn<bool>(\"isValid\");\n\n    QTest::newRow(\"Name test is valid\") << \"test\" << true;\n    QTest::newRow(\"Empty name is invalid\") << \"\" << false;\n    QTest::newRow(\"Name consisting of only white spaces is invalid\") << \"    \" << false;\n    QTest::newRow(\"Name consisting of characters and white spaces is valid\") << \"  test  \" << true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_DesignValidator::testComponentInstanceHasValidIsPresent()\n//-----------------------------------------------------------------------------\nvoid tst_DesignValidator::testComponentInstanceHasValidIsPresent()\n{\n    QFETCH(QString, isPresent);\n    QFETCH(bool, isValid);\n\n    QSharedPointer<ComponentInstance> testInstance (new ComponentInstance());\n    testInstance->setInstanceName(\"Yatagarasu\");\n    testInstance->setIsPresent(isPresent);\n\n    QSharedPointer<ComponentInstanceValidator> validator = createComponentInstanceValidator(0);\n\n    QCOMPARE(validator->hasValidIsPresent(testInstance), isValid);\n\n    if (!isValid)\n    {\n        QVector<QString> foundErrors;\n        validator->findErrorsIn(foundErrors, testInstance, \"test\");\n\n        QString expectedError = QObject::tr(\"Invalid isPresent set for component instance %1 within %2\")\n            .arg(testInstance->getInstanceName()).arg(\"test\");\n\n        if (errorIsNotFoundInErrorList(expectedError, foundErrors))\n        {\n            QFAIL(\"No error message found\");\n        }\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_DesignValidator::testComponentInstanceHasValidIsPresent_data()\n//-----------------------------------------------------------------------------\nvoid tst_DesignValidator::testComponentInstanceHasValidIsPresent_data()\n{\n    QTest::addColumn<QString>(\"isPresent\");\n    QTest::addColumn<bool>(\"isValid\");\n\n    QTest::newRow(\"IsPresent 1 is valid\") << \"1\" << true;\n    QTest::newRow(\"IsPresent 1*3-3 is valid\") << \"1*3-3\" << true;\n    QTest::newRow(\"IsPresent 2*100 is invalid\") << \"2*100\" << false;\n    QTest::newRow(\"IsPresent -14 is invalid\") << \"-14\" << false;\n    QTest::newRow(\"Real number isPresent  0.12 is invalid\") << \"0.12\" << false;\n    QTest::newRow(\"Text as isPresent is invalid\") << \"test\" << false;\n    QTest::newRow(\"String as isPresent is invalid\") << \"\\\"test\\\"\" << false;\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_DesignValidator::testComponentInstanceHasValidComponentReference()\n//-----------------------------------------------------------------------------\nvoid tst_DesignValidator::testComponentInstanceHasValidComponentReference()\n{\n    QFETCH(bool, referenceExists);\n    QFETCH(QString, vendor);\n    QFETCH(QString, library);\n    QFETCH(QString, name);\n    QFETCH(QString, version);\n    QFETCH(bool, addToLibrary);\n    QFETCH(bool, isValid);\n\n    LibraryMock* mockLibrary (new LibraryMock(this));\n\n    QSharedPointer<ComponentInstance> testInstance (new ComponentInstance());\n    testInstance->setInstanceName(\"Saitama\");\n\n    if (referenceExists)\n    {\n        QSharedPointer<ConfigurableVLNVReference> componentVLNV (new ConfigurableVLNVReference(\n            VLNV(VLNV::COMPONENT, vendor, library, name, version)));\n\n        testInstance->setComponentRef(componentVLNV);\n\n        if (addToLibrary)\n        {\n            QSharedPointer<Component> referencedComponent (new Component(*componentVLNV, Document::Revision::Std14));\n            mockLibrary->addComponent(referencedComponent);\n        }\n    }\n\n    QSharedPointer<ComponentInstanceValidator> validator = createComponentInstanceValidator(mockLibrary);\n\n    QCOMPARE(validator->hasValidComponentReference(testInstance), isValid);\n\n    if (!isValid)\n    {\n        QVector<QString> foundErrors;\n        validator->findErrorsIn(foundErrors, testInstance, \"test\");\n\n        QString expectedError = QObject::tr(\"The type of the vlnv is invalid within component reference in \"\n            \"component instance %1\").arg(testInstance->getInstanceName());\n\n        if (!referenceExists)\n        {\n            expectedError = QObject::tr(\"No component reference given in component instance %1 within %2\")\n                .arg(testInstance->getInstanceName()).arg(\"test\");\n        }\n        else if (vendor.isEmpty())\n        {\n            expectedError = QObject::tr(\"No vendor specified for vlnv within component reference in component \"\n                \"instance %1\").arg(testInstance->getInstanceName());\n        }\n        else if (library.isEmpty())\n        {\n            expectedError = QObject::tr(\"No library specified for vlnv within component reference in component \"\n                \"instance %1\").arg(testInstance->getInstanceName());\n        }\n        else if (name.isEmpty())\n        {\n            expectedError = QObject::tr(\"No name specified for vlnv within component reference in component \"\n                \"instance %1\").arg(testInstance->getInstanceName());\n        }\n        else if (version.isEmpty())\n        {\n            expectedError = QObject::tr(\"No version specified for vlnv within component reference in component \"\n                \"instance %1\").arg(testInstance->getInstanceName());\n        }\n        else if (!addToLibrary)\n        {\n            expectedError = QObject::tr(\"Component reference %1 in component instance %2 within %3 was not found \"\n                \"in the library\")\n                .arg(testInstance->getComponentRef()->toString()).arg(testInstance->getInstanceName()).arg(\"test\");\n        }\n\n        if (errorIsNotFoundInErrorList(expectedError, foundErrors))\n        {\n            QFAIL(\"No error message found\");\n        }\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_DesignValidator::testComponentInstanceHasValidComponentReference_data()\n//-----------------------------------------------------------------------------\nvoid tst_DesignValidator::testComponentInstanceHasValidComponentReference_data()\n{\n    QTest::addColumn<bool>(\"referenceExists\");\n    QTest::addColumn<QString>(\"vendor\");\n    QTest::addColumn<QString>(\"library\");\n    QTest::addColumn<QString>(\"name\");\n    QTest::addColumn<QString>(\"version\");\n    QTest::addColumn<bool>(\"addToLibrary\");\n    QTest::addColumn<bool>(\"isValid\");\n\n    QTest::newRow(\"Component instance with VLNV and referencing a component contained in library is valid\") <<\n        true << \"One\" << \"Punch\" << \"Man\" << \"2\" << true << true;\n\n    QTest::newRow(\"Component reference without vendor is not valid\") <<\n        true << \"\" << \"Punch\" << \"Man\" << \"2\" << true << false;\n    QTest::newRow(\"Component reference without library is not valid\") <<\n        true << \"One\" << \"\" << \"Man\" << \"2\" << true << false;\n    QTest::newRow(\"Component reference without name is not valid\") <<\n        true << \"One\" << \"Punch\" << \"\" << \"2\" << true << false;\n    QTest::newRow(\"Component reference without version is not valid\") <<\n        true << \"One\" << \"Punch\" << \"Man\" << \"\" << true << false;\n\n    QTest::newRow(\"Component instance without a component reference is not valid\") <<\n        false << \"\" << \"\" << \"\" << \"\" << false << false;\n    QTest::newRow(\"Component reference referencing design not found in library is not valid\") <<\n        true << \"One\" << \"Punch\" << \"Man\" << \"2\" << false << false;\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_DesignValidator::testHasValidComponentInstances()\n//-----------------------------------------------------------------------------\nvoid tst_DesignValidator::testHasValidComponentInstances()\n{\n    QFETCH(bool, instanceExists);\n    QFETCH(QString, name);\n    QFETCH(bool, componentReferenceExists);\n    QFETCH(bool, copyInstance);\n    QFETCH(bool, isValid);\n\n    LibraryMock* mockLibrary (new LibraryMock(this));\n\n    QSharedPointer<Design> testDesign (new Design(VLNV(VLNV::DESIGN, \"Samurai\", \"Champloo\", \"MugenJinFuu\", \"3\"),\n        Document::Revision::Std14));\n\n    QSharedPointer<ConfigurableVLNVReference> componentVLNV (\n        new ConfigurableVLNVReference(VLNV(VLNV::COMPONENT, \"One\", \"Punch\", \"Man\", \"Saitama\")));\n\n    QSharedPointer<ComponentInstance> testInstance (new ComponentInstance());\n    testInstance->setInstanceName(name);\n\n    if (instanceExists)\n    {\n        testDesign->getComponentInstances()->append(testInstance);\n\n        if (componentReferenceExists)\n        {\n            testInstance->setComponentRef(componentVLNV);\n            QSharedPointer<Component> testComponent (new Component(*componentVLNV, Document::Revision::Std14));\n            mockLibrary->addComponent(testComponent);\n        }\n\n        if (copyInstance)\n        {\n            QSharedPointer<ComponentInstance> otherInstance (new ComponentInstance(*testInstance.data()));\n            testDesign->getComponentInstances()->append(otherInstance);\n        }\n    }\n\n    QSharedPointer<DesignValidator> validator = createDesignValidator(mockLibrary);\n\n    QCOMPARE(validator->hasValidComponentInstances(testDesign), isValid);\n\n    if (!isValid)\n    {\n        QVector<QString> foundErrors;\n        validator->findErrorsIn(foundErrors, testDesign);\n\n        QString expectedError = QObject::tr(\"Component instance name '%1' within design %2 is not unique.\")\n            .arg(testInstance->getInstanceName()).arg(testDesign->getVlnv().toString());\n\n        if (name.isEmpty())\n        {\n            expectedError = QObject::tr(\"Invalid instance name '%1' set for component instance within design %2\")\n                .arg(testInstance->getInstanceName()).arg(testDesign->getVlnv().toString());\n        }\n        else if (!componentReferenceExists)\n        {\n            expectedError = QObject::tr(\"No component reference given in component instance %1 within design %2\")\n                .arg(testInstance->getInstanceName()).arg(testDesign->getVlnv().toString());\n        }\n\n        if (errorIsNotFoundInErrorList(expectedError, foundErrors))\n        {\n            QFAIL(\"No error message found\");\n        }\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_DesignValidator::testHasValidComponentInstances_data()\n//-----------------------------------------------------------------------------\nvoid tst_DesignValidator::testHasValidComponentInstances_data()\n{\n    QTest::addColumn<bool>(\"instanceExists\");\n    QTest::addColumn<QString>(\"name\");\n    QTest::addColumn<bool>(\"componentReferenceExists\");\n    QTest::addColumn<bool>(\"copyInstance\");\n    QTest::addColumn<bool>(\"isValid\");\n\n    QTest::newRow(\"Design without component instances is valid\") << false << \"\" << false << false << true;\n    QTest::newRow(\"Component instance with name and component reference is valid\") <<\n        true << \"Genos\" << true << false << true;\n\n    QTest::newRow(\"Component instance without name is not valid\") <<\n        true << \"\" << true << false << false; \n    QTest::newRow(\"Component instance without component reference is not valid\") <<\n        true << \"Genos\" << false << false << false;\n    QTest::newRow(\"Component instances with non-unique name is not valid\") <<\n        true << \"Genos\" << true << true << false;\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_DesignValidator::testInterconnectionHasValidName()\n//-----------------------------------------------------------------------------\nvoid tst_DesignValidator::testInterconnectionHasValidName()\n{\n    QFETCH(QString, name);\n    QFETCH(bool, isValid);\n\n    QSharedPointer<Interconnection> testInterconnection (new Interconnection());\n    testInterconnection->setName(name);\n\n    QSharedPointer<InterconnectionValidator> validator = createInterconnectionValidator(0);\n\n    QCOMPARE(validator->hasValidName(testInterconnection->name()), isValid);\n\n    if (!isValid)\n    {\n        QVector<QString> foundErrors;\n        validator->findErrorsInInterconnection(foundErrors, testInterconnection, \"test\");\n\n        QString expectedError = QObject::tr(\"Invalid name '%1' set for interconnection within %2\")\n            .arg(name.trimmed()).arg(\"test\");\n\n        if (errorIsNotFoundInErrorList(expectedError, foundErrors))\n        {\n            QFAIL(\"No error message found\");\n        }\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_DesignValidator::testInterconnectionHasValidName_data()\n//-----------------------------------------------------------------------------\nvoid tst_DesignValidator::testInterconnectionHasValidName_data()\n{\n    QTest::addColumn<QString>(\"name\");\n    QTest::addColumn<bool>(\"isValid\");\n\n    QTest::newRow(\"Name test is valid\") << \"test\" << true;\n    QTest::newRow(\"Empty name is invalid\") << \"\" << false;\n    QTest::newRow(\"Name consisting of only white spaces is invalid\") << \"    \" << false;\n    QTest::newRow(\"Name consisting of characters and white spaces is valid\") << \"  test  \" << true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_DesignValidator::testInterconnectionHasValidIsPresent()\n//-----------------------------------------------------------------------------\nvoid tst_DesignValidator::testInterconnectionHasValidIsPresent()\n{\n    QFETCH(QString, isPresent);\n    QFETCH(bool, isValid);\n\n    QSharedPointer<Interconnection> testConnection (new Interconnection());\n    testConnection->setName(\"Yatagarasu\");\n    testConnection->setIsPresent(isPresent);\n\n    QSharedPointer<InterconnectionValidator> validator = createInterconnectionValidator(0);\n\n    QCOMPARE(validator->hasValidIsPresent(testConnection->getIsPresent()), isValid);\n\n    if (!isValid)\n    {\n        QVector<QString> foundErrors;\n        validator->findErrorsInInterconnection(foundErrors, testConnection, \"test\");\n\n        QString expectedError = QObject::tr(\"Invalid isPresent set for interconnection '%1' within %2\")\n            .arg(testConnection->name()).arg(\"test\");\n\n        if (errorIsNotFoundInErrorList(expectedError, foundErrors))\n        {\n            QFAIL(\"No error message found\");\n        }\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_DesignValidator::testInterconnectionHasValidIsPresent_data()\n//-----------------------------------------------------------------------------\nvoid tst_DesignValidator::testInterconnectionHasValidIsPresent_data()\n{\n    QTest::addColumn<QString>(\"isPresent\");\n    QTest::addColumn<bool>(\"isValid\");\n\n    QTest::newRow(\"IsPresent 1 is valid\") << \"1\" << true;\n    QTest::newRow(\"IsPresent 1*3-3 is valid\") << \"1*3-3\" << true;\n    QTest::newRow(\"IsPresent 2*100 is invalid\") << \"2*100\" << false;\n    QTest::newRow(\"IsPresent -14 is invalid\") << \"-14\" << false;\n    QTest::newRow(\"Real number isPresent  0.12 is invalid\") << \"0.12\" << false;\n    QTest::newRow(\"Text as isPresent is invalid\") << \"test\" << false;\n    QTest::newRow(\"String as isPresent is invalid\") << \"\\\"test\\\"\" << false;\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_DesignValidator::testInterconnectionActiveInterfaceIsValid()\n//-----------------------------------------------------------------------------\nvoid tst_DesignValidator::testInterconnectionActiveInterfaceIsValid()\n{\n    QFETCH(bool, startInterfaceExists);\n    QFETCH(QString, componentReference);\n    QFETCH(bool, componentExists);\n    QFETCH(QString, busReference);\n    QFETCH(bool, busInterfaceExists);\n    QFETCH(bool, isValid);\n\n    LibraryMock* mockLibrary (new LibraryMock(this));\n\n    QSharedPointer<QList<QSharedPointer<ComponentInstance> > > containedInstances (\n        new QList<QSharedPointer<ComponentInstance> > ());\n\n    QSharedPointer<Interconnection> testConnection (new Interconnection());\n    testConnection->setName(\"Balduran\");\n\n    if (startInterfaceExists)\n    {\n        QSharedPointer<ActiveInterface> testInterface (new ActiveInterface(componentReference, busReference));\n        testConnection->setStartInterface(testInterface);\n\n        if (componentExists)\n        {\n            QSharedPointer<ConfigurableVLNVReference> componentVLNV (\n                new ConfigurableVLNVReference(VLNV(VLNV::COMPONENT, \"One\", \"Punch\", \"Man\", \"Saitama\")));\n\n            QSharedPointer<ComponentInstance> componentInstance (\n                new ComponentInstance(componentReference, componentVLNV));\n            if (componentReference.isEmpty())\n            {\n                componentInstance->setInstanceName(\"Baiken\");\n            }\n            containedInstances->append(componentInstance);\n\n            QSharedPointer<Component> referencedComponent (new Component(*componentVLNV, Document::Revision::Std14));\n            mockLibrary->addComponent(referencedComponent);\n\n            if (busInterfaceExists)\n            {\n                QSharedPointer<BusInterface> testBus (new BusInterface());\n                testBus->setName(busReference);\n                referencedComponent->getBusInterfaces()->append(testBus);\n            }\n        }\n    }\n\n    QSharedPointer<InterconnectionValidator> validator = createInterconnectionValidator(mockLibrary);\n    validator->changeComponentInstances(containedInstances);\n\n    QCOMPARE(validator->hasValidStartInterface(testConnection), isValid);\n\n    if (!isValid)\n    {\n        QVector<QString> foundErrors;\n        validator->findErrorsInInterconnection(foundErrors, testConnection, \"test\");\n\n        QString expectedError = QObject::tr(\"No component reference set for active interface in interconnection \"\n            \"'%1' within %2\").arg(testConnection->name()).arg(\"test\");\n\n        if (!startInterfaceExists)\n        {\n            expectedError = QObject::tr(\"No active interface set for interconnection '%1' within %2\")\n                .arg(testConnection->name()).arg(\"test\");\n        }\n        else if (!componentExists)\n        {\n            expectedError = QObject::tr(\"Component instance '%1' referenced by the active interface in \"\n                \"interconnection '%2' within %3 was not found\")\n                .arg(componentReference).arg(testConnection->name()).arg(\"test\");\n        }\n        else if (busReference.isEmpty())\n        {\n            expectedError = QObject::tr(\"No bus reference set for active interface in interconnection '%1' within \"\n                \"%2\").arg(testConnection->name()).arg(\"test\");\n        }\n        else if (!busInterfaceExists)\n        {\n            expectedError = QObject::tr(\"Bus interface '%1' referenced by the active interface in interconnection \"\n                \"'%2' within %3 was not found\")\n                .arg(busReference).arg(testConnection->name()).arg(\"test\");\n        }\n\n        if (errorIsNotFoundInErrorList(expectedError, foundErrors))\n        {\n            QFAIL(\"No error message found\");\n        }\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_DesignValidator::testInterconnectionActiveInterfaceIsValid_data()\n//-----------------------------------------------------------------------------\nvoid tst_DesignValidator::testInterconnectionActiveInterfaceIsValid_data()\n{\n    QTest::addColumn<bool>(\"startInterfaceExists\");\n    QTest::addColumn<QString>(\"componentReference\");\n    QTest::addColumn<bool>(\"componentExists\");\n    QTest::addColumn<QString>(\"busReference\");\n    QTest::addColumn<bool>(\"busInterfaceExists\");\n    QTest::addColumn<bool>(\"isValid\");\n\n    QTest::newRow(\"Active interface with component reference and bus reference is valid\") <<\n        true << \"Saitama\" << true << \"Genos\" << true << true;\n\n    QTest::newRow(\"Active interface without component reference is not valid\") <<\n        true << \"\" << true << \"Genos\" << true << false;\n    QTest::newRow(\"Active interface with component reference to non-existing component is not valid\") <<\n        true << \"Saitama\" << false << \"Genos\" << true << false;\n    QTest::newRow(\"Active interface without bus reference is not valid\") <<\n        true << \"Saitama\" << true << \"\" << true << false;\n    QTest::newRow(\"Active interface with bus reference to non-existing bus interface is not valid\") <<\n        true << \"Saitama\" << true << \"Genos\" << false << false;\n    QTest::newRow(\"Interconnection without active interface is not valid\") <<\n        false << \"\" << false << \"\" << false << false;\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_DesignValidator::testInterconnectionActiveInterfaceHasValidIsPresent()\n//-----------------------------------------------------------------------------\nvoid tst_DesignValidator::testInterconnectionActiveInterfaceHasValidIsPresent()\n{\n    QFETCH(QString, isPresent);\n    QFETCH(bool, isValid);\n\n    QSharedPointer<ActiveInterface> testInterface (new ActiveInterface(\"Saitama\", \"Genos\"));\n    testInterface->setIsPresent(isPresent);\n\n    QSharedPointer<Interconnection> testConnection (new Interconnection(\"OnePunchMan\", testInterface));\n\n    QSharedPointer<InterconnectionValidator> validator = createInterconnectionValidator(0);\n\n    QCOMPARE(validator->hasValidIsPresent(testInterface->getIsPresent()), isValid);\n\n    if (!isValid)\n    {\n        QVector<QString> foundErrors;\n        validator->findErrorsInInterconnection(foundErrors, testConnection, \"test\");\n\n        QString expectedError = QObject::tr(\"Invalid isPresent set for %1 within interconnection '%2'\")\n            .arg(\"active interface\").arg(testConnection->name());\n\n        if (errorIsNotFoundInErrorList(expectedError, foundErrors))\n        {\n            QFAIL(\"No error message found\");\n        }\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_DesignValidator::testInterconnectionActiveInterfaceHasValidIsPresent_data()\n//-----------------------------------------------------------------------------\nvoid tst_DesignValidator::testInterconnectionActiveInterfaceHasValidIsPresent_data()\n{\n    QTest::addColumn<QString>(\"isPresent\");\n    QTest::addColumn<bool>(\"isValid\");\n\n    QTest::newRow(\"IsPresent 1 is valid\") << \"1\" << true;\n    QTest::newRow(\"IsPresent 1*3-3 is valid\") << \"1*3-3\" << true;\n    QTest::newRow(\"IsPresent 2*100 is invalid\") << \"2*100\" << false;\n    QTest::newRow(\"IsPresent -14 is invalid\") << \"-14\" << false;\n    QTest::newRow(\"Real number isPresent  0.12 is invalid\") << \"0.12\" << false;\n    QTest::newRow(\"Text as isPresent is invalid\") << \"test\" << false;\n    QTest::newRow(\"String as isPresent is invalid\") << \"\\\"test\\\"\" << false;\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_DesignValidator::testInterconnectionActiveInterfaceHasValidExcludePorts()\n//-----------------------------------------------------------------------------\nvoid tst_DesignValidator::testInterconnectionActiveInterfaceHasValidExcludePorts()\n{\n    QFETCH(QString, portName);\n    QFETCH(bool, portExists);\n    QFETCH(bool, isValid);\n\n    QSharedPointer<ActiveInterface> testInterface (new ActiveInterface(\"Genos\", \"Sonic\"));\n\n    QSharedPointer<BusInterface> testBus (new BusInterface());\n    testBus->setName(testInterface->getBusReference());\n\n    QSharedPointer<ConfigurableVLNVReference> componentVLNV (\n        new ConfigurableVLNVReference(VLNV(VLNV::COMPONENT, \"One\", \"Punch\", \"Man\", \"Saitama\")));\n    QSharedPointer<Component> testComponent (new Component(*componentVLNV, Document::Revision::Std14));\n\n    testComponent->getBusInterfaces()->append(testBus);\n\n    QSharedPointer<ComponentInstance> testInstance (\n        new ComponentInstance(testInterface->getComponentReference(), componentVLNV));\n\n    QSharedPointer<QList<QSharedPointer<ComponentInstance> > > instances (\n        new QList<QSharedPointer<ComponentInstance> > ());\n    instances->append(testInstance);\n\n    LibraryMock mockLibrary (this);\n    mockLibrary.addComponent(testComponent);\n\n    if (!portName.isEmpty())\n    {\n        testInterface->getExcludePorts()->append(portName);\n\n        if (portExists)\n        {\n            QSharedPointer<PortMap::LogicalPort> testPort (new PortMap::LogicalPort());\n            testPort->name_ = portName;\n\n            QSharedPointer<PortMap> testMap (new PortMap());\n            testMap->setLogicalPort(testPort);\n\n            QSharedPointer<AbstractionType> testAbstraction (new AbstractionType());\n            testAbstraction->getPortMaps()->append(testMap);\n\n            testBus->getAbstractionTypes()->append(testAbstraction);\n        }\n    }\n\n    QSharedPointer<Interconnection> testConnection (new Interconnection(\"OnePunchMan\", testInterface));\n\n    QSharedPointer<InterconnectionValidator> validator = createInterconnectionValidator(&mockLibrary);\n    validator->changeComponentInstances(instances);\n\n    QCOMPARE(validator->hasValidStartInterface(testConnection), isValid);\n\n    if (!isValid)\n    {\n        QVector<QString> foundErrors;\n        validator->findErrorsInInterconnection(foundErrors, testConnection, \"test\");\n\n        QString expectedError = QObject::tr(\"Logical port referenced in active interface in interconnection '%1' \"\n            \"was not found in the port maps of the referenced bus interface %2\")\n            .arg(testConnection->name()).arg(testBus->name());\n\n        if (errorIsNotFoundInErrorList(expectedError, foundErrors))\n        {\n            QFAIL(\"No error message found\");\n        }\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_DesignValidator::testInterconnectionActiveInterfaceHasValidExcludePorts_data()\n//-----------------------------------------------------------------------------\nvoid tst_DesignValidator::testInterconnectionActiveInterfaceHasValidExcludePorts_data()\n{\n    QTest::addColumn<QString>(\"portName\");\n    QTest::addColumn<bool>(\"portExists\");\n    QTest::addColumn<bool>(\"isValid\");\n\n    QTest::newRow(\"Active interface without an exclude port is valid\") << \"\" << false << true;\n    QTest::newRow(\"Active interface exclude port referencing existing logical port is valid\") <<\n        \"One\" << true << true;\n    QTest::newRow(\"Active interface exclude port referencing non-existing logical port is not valid\") <<\n        \"One\" << false << false;\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_DesignValidator::testInterconnectionInterfacesAreValid()\n//-----------------------------------------------------------------------------\nvoid tst_DesignValidator::testInterconnectionInterfacesAreValid()\n{\n    QFETCH(bool, createActiveInterface);\n    QFETCH(bool, createHierInterface);\n    QFETCH(bool, copyInterface);\n    QFETCH(bool, isValid);\n\n    QSharedPointer<Interconnection> testConnection (new Interconnection());\n    testConnection->setName(\"Gygax\");\n\n    LibraryMock mockLibrary (this);\n\n    QSharedPointer<QList<QSharedPointer<ComponentInstance> > > instances (\n        new QList<QSharedPointer<ComponentInstance> > ());\n\n    QSharedPointer<ActiveInterface> startInterface(new ActiveInterface(\"StartComponent\", \"StartBus\"));\n\n    QSharedPointer<ConfigurableVLNVReference> startVLNV (\n        new ConfigurableVLNVReference(VLNV(VLNV::COMPONENT, \"One\", \"Punch\", \"Start\", \"1.0\")));\n    QSharedPointer<Component> startComponent (new Component(*startVLNV, Document::Revision::Std14));\n    mockLibrary.addComponent(startComponent);\n\n    QSharedPointer<ComponentInstance> startInstance (\n        new ComponentInstance(startInterface->getComponentReference(), startVLNV));\n\n    QSharedPointer<BusInterface> startBus(new BusInterface());\n    startBus->setName(startInterface->getBusReference());\n    startComponent->getBusInterfaces()->append(startBus);\n\n    testConnection->setStartInterface(startInterface);\n\n    QSharedPointer<ActiveInterface> testInterface (new ActiveInterface(\"Demi\", \"Lich\"));\n\n    if (createActiveInterface)\n    {\n        QSharedPointer<ConfigurableVLNVReference> componentVLNV (\n            new ConfigurableVLNVReference(VLNV(VLNV::COMPONENT, \"One\", \"Punch\", \"Man\", \"Saitama\")));\n        QSharedPointer<Component> testComponent (new Component(*componentVLNV, Document::Revision::Std14));\n\n        QSharedPointer<ComponentInstance> testInstance (\n            new ComponentInstance(testInterface->getComponentReference(), componentVLNV));\n        instances->append(testInstance);\n\n        QSharedPointer<BusInterface> testBus(new BusInterface());\n        testBus->setName(testInterface->getBusReference());\n\n        testComponent->getBusInterfaces()->append(testBus);\n\n        testConnection->getActiveInterfaces()->append(testInterface);\n\n        mockLibrary.addComponent(testComponent);\n\n        if (copyInterface)\n        {\n            QSharedPointer<ActiveInterface> otherInterface (new ActiveInterface(*testInterface.data()));\n            testConnection->getActiveInterfaces()->append(otherInterface);\n        }\n    }\n\n    QSharedPointer<HierInterface> hierInterface (new HierInterface(\"Wight\"));\n    if (createHierInterface)\n    {\n        testConnection->getHierInterfaces()->append(hierInterface);\n\n        if (copyInterface)\n        {\n            QSharedPointer<HierInterface> otherInterface (new HierInterface(*hierInterface.data()));\n            testConnection->getHierInterfaces()->append(otherInterface);\n        }\n    }\n\n    QSharedPointer<InterconnectionValidator> validator = createInterconnectionValidator(&mockLibrary);\n    validator->changeComponentInstances(instances);\n\n    QCOMPARE(validator->hasValidInterfaces(testConnection), isValid);\n\n    if (!isValid)\n    {\n        QVector<QString> foundErrors;\n        validator->findErrorsInInterconnection(foundErrors, testConnection, \"test\");\n\n        QString expectedError = QObject::tr(\"No active interfaces or hierarchical interfaces set for \"\n            \"interconnection '%1' within %2\").arg(testConnection->name()).arg(\"test\");\n\n        if (copyInterface && !createHierInterface)\n        {\n            expectedError = QObject::tr(\"Component reference '%1' and bus reference '%2' pair is not unique in \"\n                \"active interfaces of interconnection '%3' within %4.\")\n                .arg(testInterface->getComponentReference()).arg(testInterface->getBusReference())\n                .arg(testConnection->name()).arg(\"test\");\n        }\n        else if (copyInterface && createHierInterface)\n        {\n            expectedError = QObject::tr(\"Bus reference '%1' is not unique in hierarchical interfaces of \"\n                \"interconnection '%2' within %3.\")\n                .arg(hierInterface->getBusReference()).arg(testConnection->name()).arg(\"test\");\n        }\n\n        if (errorIsNotFoundInErrorList(expectedError, foundErrors))\n        {\n            QFAIL(\"No error message found\");\n        }\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_DesignValidator::testInterconnectionInterfacesAreValid_data()\n//-----------------------------------------------------------------------------\nvoid tst_DesignValidator::testInterconnectionInterfacesAreValid_data()\n{\n    QTest::addColumn<bool>(\"createActiveInterface\");\n    QTest::addColumn<bool>(\"createHierInterface\");\n    QTest::addColumn<bool>(\"copyInterface\");\n    QTest::addColumn<bool>(\"isValid\");\n\n    QTest::newRow(\"Interconnection with both an active interface and a hier interface is valid\") <<\n        true << true << false << true;\n    QTest::newRow(\"Interconnection with active interface is valid\") << true << false << false << true;\n    QTest::newRow(\"Interconnection with hier interface is valid\") << false << true << false << true;\n\n    QTest::newRow(\"Interconnection without active interface or hier interface is not valid\") <<\n        false << false << false << false;\n    QTest::newRow(\"Interconnection with interfaces referencing same component/bus interface pair is not valid\") <<\n        true << false << true << false;\n    QTest::newRow(\"Hierarchical interfaces referencing the same bus interface is not valid\") <<\n        false << true << true << false;\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_DesignValidator::testHasValidInterconnections()\n//-----------------------------------------------------------------------------\nvoid tst_DesignValidator::testHasValidInterconnections()\n{\n    QFETCH(bool, createInterconnection);\n    QFETCH(bool, startInterfaceExists);\n    QFETCH(bool, hierInterfaceExists);\n    QFETCH(bool, copyInterconnection);\n    QFETCH(bool, isValid);\n\n    QSharedPointer<Design> testDesign (new Design(VLNV(VLNV::DESIGN, \"Samurai\", \"Champloo\", \"MugenJinFuu\", \"3\"), \n        Document::Revision::Std14));\n\n    LibraryMock* mockLibrary (new LibraryMock(this));\n\n    QSharedPointer<Interconnection> testConnection (new Interconnection());\n    testConnection->setName(\"testConnection\");\n\n    if (createInterconnection)\n    {\n        if (startInterfaceExists)\n        {\n            QSharedPointer<ActiveInterface> activeInterface (new ActiveInterface(\"Space\", \"Dandy\"));\n\n            QSharedPointer<ConfigurableVLNVReference> componentVLNV (\n                new ConfigurableVLNVReference(VLNV(VLNV::COMPONENT, \"One\", \"Punch\", \"Man\", \"Saitama\")));\n            QSharedPointer<Component> testComponent (new Component(*componentVLNV, Document::Revision::Std14));\n            mockLibrary->addComponent(testComponent);\n\n            QSharedPointer<ComponentInstance> testInstance (\n                new ComponentInstance(activeInterface->getComponentReference(), componentVLNV));\n            testDesign->getComponentInstances()->append(testInstance);\n\n            QSharedPointer<BusInterface> testBus(new BusInterface());\n            testBus->setName(activeInterface->getBusReference());\n            testComponent->getBusInterfaces()->append(testBus);\n\n            testConnection->setStartInterface(activeInterface);\n        }\n\n        if (hierInterfaceExists)\n        {\n            QSharedPointer<HierInterface> hierarchical (new HierInterface(\"Bebop\"));\n            testConnection->getHierInterfaces()->append(hierarchical);\n        }\n\n        testDesign->getInterconnections()->append(testConnection);\n\n        if (copyInterconnection)\n        {\n            QSharedPointer<Interconnection> otherConnection (new Interconnection(*testConnection.data()));\n            testDesign->getInterconnections()->append(otherConnection);\n        }\n    }\n\n    QSharedPointer<DesignValidator> validator = createDesignValidator(mockLibrary);\n\n    QCOMPARE(validator->hasValidInterconnections(testDesign), isValid);\n\n    if (!isValid)\n    {\n        QVector<QString> foundErrors;\n        validator->findErrorsIn(foundErrors, testDesign);\n\n        QString expectedError = QObject::tr(\"Interconnection name %1 within design %2 is not unique\")\n            .arg(testConnection->name()).arg(testDesign->getVlnv().toString());\n\n        if (!startInterfaceExists)\n        {\n            expectedError = QObject::tr(\"No active interface set for interconnection '%1' within design %2\")\n                .arg(testConnection->name()).arg(testDesign->getVlnv().toString());\n        }\n        else if (!hierInterfaceExists)\n        {\n            expectedError = QObject::tr(\"No active interfaces or hierarchical interfaces set for interconnection \"\n                \"'%1' within design %2\" )\n                .arg(testConnection->name()).arg(testDesign->getVlnv().toString());\n        }\n\n        if (errorIsNotFoundInErrorList(expectedError, foundErrors))\n        {\n            QFAIL(\"No error message found\");\n        }\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_DesignValidator::testHasValidInterconnections_data()\n//-----------------------------------------------------------------------------\nvoid tst_DesignValidator::testHasValidInterconnections_data()\n{\n    QTest::addColumn<bool>(\"createInterconnection\");\n    QTest::addColumn<bool>(\"startInterfaceExists\");\n    QTest::addColumn<bool>(\"hierInterfaceExists\");\n    QTest::addColumn<bool>(\"copyInterconnection\");\n    QTest::addColumn<bool>(\"isValid\");\n\n    QTest::newRow(\"Design without interconnections is valid\") << false << false << false << false << true;\n    QTest::newRow(\"Interconnection with start interface and a hierarchical interface is valid\") <<\n        true << true << true << false << true;\n\n    QTest::newRow(\"Interconnection without a start interface is not valid\") <<\n        true << false << true << false << false;\n    QTest::newRow(\"Interconnection without a second interface is not valid\") <<\n        true << true << false << false << false;\n    QTest::newRow(\"Interconnections with non-unique names are not valid\") << true << true << true << true << false;\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_DesignValidator::testMonitorInterconnectionHasValidName()\n//-----------------------------------------------------------------------------\nvoid tst_DesignValidator::testMonitorInterconnectionHasValidName()\n{\n    QFETCH(QString, name);\n    QFETCH(bool, isValid);\n\n    QSharedPointer<MonitorInterconnection> testConnection (new MonitorInterconnection(name));    \n\n    QSharedPointer<InterconnectionValidator> validator = createInterconnectionValidator(0);\n\n    QCOMPARE(validator->hasValidName(testConnection->name()), isValid);\n\n    if (!isValid)\n    {\n        QVector<QString> foundErrors;\n        validator->findErrorsInMonitorInterconnection(foundErrors, testConnection, \"test\");\n\n        QString expectedError = QObject::tr(\"Invalid name '%1' set for monitor interconnection within %2\")\n            .arg(name.trimmed()).arg(\"test\");\n\n        if (errorIsNotFoundInErrorList(expectedError, foundErrors))\n        {\n            QFAIL(\"No error message found\");\n        }\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_DesignValidator::testMonitorInterconnectionHasValidName_data()\n//-----------------------------------------------------------------------------\nvoid tst_DesignValidator::testMonitorInterconnectionHasValidName_data()\n{\n    QTest::addColumn<QString>(\"name\");\n    QTest::addColumn<bool>(\"isValid\");\n\n    QTest::newRow(\"Name test is valid\") << \"test\" << true;\n    QTest::newRow(\"Empty name is invalid\") << \"\" << false;\n    QTest::newRow(\"Name consisting of only white spaces is invalid\") << \"    \" << false;\n    QTest::newRow(\"Name consisting of characters and white spaces is valid\") << \"  test  \" << true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_DesignValidator::testMonitorInterconnectionHasValidIsPresent()\n//-----------------------------------------------------------------------------\nvoid tst_DesignValidator::testMonitorInterconnectionHasValidIsPresent()\n{\n    QFETCH(QString, isPresent);\n    QFETCH(bool, isValid);\n\n    QSharedPointer<MonitorInterconnection> testConnection (new MonitorInterconnection(\"Yatagarasu\"));\n    testConnection->setIsPresent(isPresent);\n\n    QSharedPointer<InterconnectionValidator> validator = createInterconnectionValidator(0);\n\n    QCOMPARE(validator->hasValidIsPresent(testConnection->getIsPresent()), isValid);\n\n    if (!isValid)\n    {\n        QVector<QString> foundErrors;\n        validator->findErrorsInMonitorInterconnection(foundErrors, testConnection, \"test\");\n\n        QString expectedError = QObject::tr(\"Invalid isPresent set for monitor interconnection '%1' within %2\")\n            .arg(testConnection->name()).arg(\"test\");\n\n        if (errorIsNotFoundInErrorList(expectedError, foundErrors))\n        {\n            QFAIL(\"No error message found\");\n        }\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_DesignValidator::testMonitorInterconnectionHasValidIsPresent_data()\n//-----------------------------------------------------------------------------\nvoid tst_DesignValidator::testMonitorInterconnectionHasValidIsPresent_data()\n{\n    QTest::addColumn<QString>(\"isPresent\");\n    QTest::addColumn<bool>(\"isValid\");\n\n    QTest::newRow(\"IsPresent 1 is valid\") << \"1\" << true;\n    QTest::newRow(\"IsPresent 1*3-3 is valid\") << \"1*3-3\" << true;\n    QTest::newRow(\"IsPresent 2*100 is invalid\") << \"2*100\" << false;\n    QTest::newRow(\"IsPresent -14 is invalid\") << \"-14\" << false;\n    QTest::newRow(\"Real number isPresent  0.12 is invalid\") << \"0.12\" << false;\n    QTest::newRow(\"Text as isPresent is invalid\") << \"test\" << false;\n    QTest::newRow(\"String as isPresent is invalid\") << \"\\\"test\\\"\" << false;\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_DesignValidator::testMonitorInterconnectionHasValidMonitoredActiveInterface()\n//-----------------------------------------------------------------------------\nvoid tst_DesignValidator::testMonitorInterconnectionHasValidMonitoredActiveInterface()\n{\n    QFETCH(bool, startInterfaceExists);\n    QFETCH(QString, componentReference);\n    QFETCH(bool, instanceExists);\n    QFETCH(QString, busReference);\n    QFETCH(bool, busInterfaceExists);\n    QFETCH(bool, isValid);\n\n    LibraryMock* mockLibrary (new LibraryMock(this));\n\n    QSharedPointer<QList<QSharedPointer<ComponentInstance> > > containedInstances (\n        new QList<QSharedPointer<ComponentInstance> > ());\n\n    QSharedPointer<MonitorInterconnection> testConnection (new MonitorInterconnection(\"Balduran\"));\n    \n    if (startInterfaceExists)\n    {\n        QSharedPointer<MonitorInterface> testInterface (new MonitorInterface(componentReference, busReference));\n        testConnection->setMonitoredctiveInterface(testInterface);\n\n        if (instanceExists)\n        {\n            QSharedPointer<ConfigurableVLNVReference> componentVLNV (\n                new ConfigurableVLNVReference(VLNV(VLNV::COMPONENT, \"One\", \"Punch\", \"Man\", \"Saitama\")));\n\n            QSharedPointer<ComponentInstance> componentInstance (\n                new ComponentInstance(componentReference, componentVLNV));\n            if (componentReference.isEmpty())\n            {\n                componentInstance->setInstanceName(\"Baiken\");\n            }\n            containedInstances->append(componentInstance);\n\n            QSharedPointer<Component> referencedComponent (new Component(*componentVLNV, Document::Revision::Std14));\n            mockLibrary->addComponent(referencedComponent);\n\n            if (busInterfaceExists)\n            {\n                QSharedPointer<BusInterface> testBus (new BusInterface());\n                testBus->setName(busReference);\n                if (busReference.isEmpty())\n                {\n                    testBus->setName(\"TKL\");\n                }\n                referencedComponent->getBusInterfaces()->append(testBus);\n            }\n        }\n    }\n\n    QSharedPointer<InterconnectionValidator> validator = createInterconnectionValidator(mockLibrary);\n    validator->changeComponentInstances(containedInstances);\n\n    QCOMPARE(validator->hasValidMonitoredActiveInterface(testConnection), isValid);\n\n    if (!isValid)\n    {\n        QVector<QString> foundErrors;\n        validator->findErrorsInMonitorInterconnection(foundErrors, testConnection, \"test\");\n\n        QString expectedError = QObject::tr(\"No component reference set for monitored active interface in monitor \"\n            \"interconnection '%1' within %2\").arg(testConnection->name()).arg(\"test\");\n\n        if (!startInterfaceExists)\n        {\n            expectedError = QObject::tr(\"No monitored active interface set for monitor interconnection '%1' \"\n                \"within %2\").arg(testConnection->name()).arg(\"test\");\n        }\n        else if (!instanceExists)\n        {\n            expectedError = QObject::tr(\"Component instance '%1' referenced by the monitored active interface in \"\n                \"monitor interconnection '%2' within %3 was not found\")\n                .arg(componentReference).arg(testConnection->name()).arg(\"test\");\n        }\n        else if (busReference.isEmpty())\n        {\n            expectedError = QObject::tr(\"No bus reference set for monitored active interface in monitor \"\n                \"interconnection '%1' within %2\").arg(testConnection->name()).arg(\"test\");\n        }\n        else if (!busInterfaceExists)\n        {\n            expectedError = QObject::tr(\"Bus interface '%1' referenced by the monitored active interface in \"\n                \"monitor interconnection '%2' within %3 was not found\")\n                .arg(busReference).arg(testConnection->name()).arg(\"test\");\n        }\n\n        if (errorIsNotFoundInErrorList(expectedError, foundErrors))\n        {\n            QFAIL(\"No error message found\");\n        }\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_DesignValidator::testMonitorInterconnectionHasValidMonitoredActiveInterface_data()\n//-----------------------------------------------------------------------------\nvoid tst_DesignValidator::testMonitorInterconnectionHasValidMonitoredActiveInterface_data()\n{\n    QTest::addColumn<bool>(\"startInterfaceExists\");\n    QTest::addColumn<QString>(\"componentReference\");\n    QTest::addColumn<bool>(\"instanceExists\");\n    QTest::addColumn<QString>(\"busReference\");\n    QTest::addColumn<bool>(\"busInterfaceExists\");\n    QTest::addColumn<bool>(\"isValid\");\n\n    QTest::newRow(\"Monitored active interface with component and bus references to existing elements is valid\") <<\n        true << \"Space\" << true << \"Dandy\" << true << true;\n\n    QTest::newRow(\"Monitor interconnection without monitored active interface is not valid\") <<\n        false << \"\" << false << \"\" << false << false;\n    QTest::newRow(\"Monitored active interface without component instance reference is not valid\") <<\n        true << \"\" << true << \"Dandy\" << true << false;\n    QTest::newRow(\"Monitored active interface referencing non-existing component instance is not valid\") <<\n        true << \"Space\" << false << \"Dandy\" << true << false;\n    QTest::newRow(\"Monitored active interface without bus reference is not valid\") <<\n        true << \"Space\" << true << \"\" << true << false;\n    QTest::newRow(\"Monitored active interface referencing non-existing bus interface is not valid\") <<\n        true << \"Space\" << true << \"Dandy\" << false << false;\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_DesignValidator::testMonitorInterconnectionHasValidMonitorInterfaces()\n//-----------------------------------------------------------------------------\nvoid tst_DesignValidator::testMonitorInterconnectionHasValidMonitorInterfaces()\n{\n    QFETCH(bool, monitorInterfaceExists);\n    QFETCH(QString, componentReference);\n    QFETCH(bool, instanceExists);\n    QFETCH(QString, busReference);\n    QFETCH(bool, busInterfaceExists);\n    QFETCH(bool, copyInterface);\n    QFETCH(bool, isValid);\n\n    LibraryMock* mockLibrary (new LibraryMock(this));\n\n    QSharedPointer<QList<QSharedPointer<ComponentInstance> > > containedInstances (\n        new QList<QSharedPointer<ComponentInstance> > ());\n\n    QSharedPointer<MonitorInterconnection> testConnection (new MonitorInterconnection(\"Balduran\"));\n\n    QSharedPointer<MonitorInterface> testInterface (new MonitorInterface(componentReference, busReference));\n    if (monitorInterfaceExists)\n    {\n        testConnection->getMonitorInterfaces()->append(testInterface);\n\n        if (instanceExists)\n        {\n            QSharedPointer<ConfigurableVLNVReference> componentVLNV (\n                new ConfigurableVLNVReference(VLNV(VLNV::COMPONENT, \"One\", \"Punch\", \"Man\", \"Saitama\")));\n\n            QSharedPointer<ComponentInstance> componentInstance (\n                new ComponentInstance(componentReference, componentVLNV));\n            if (componentReference.isEmpty())\n            {\n                componentInstance->setInstanceName(\"Baiken\");\n            }\n            containedInstances->append(componentInstance);\n\n            QSharedPointer<Component> referencedComponent (new Component(*componentVLNV, Document::Revision::Std14));\n            mockLibrary->addComponent(referencedComponent);\n\n            if (busInterfaceExists)\n            {\n                QSharedPointer<BusInterface> testBus (new BusInterface());\n                testBus->setName(busReference);\n                if (busReference.isEmpty())\n                {\n                    testBus->setName(\"TKL\");\n                }\n                referencedComponent->getBusInterfaces()->append(testBus);\n            }\n        }\n\n        if (copyInterface)\n        {\n            QSharedPointer<MonitorInterface> otherInterface (new MonitorInterface(*testInterface.data()));\n            testConnection->getMonitorInterfaces()->append(otherInterface);\n        }\n    }\n\n    QSharedPointer<InterconnectionValidator> validator = createInterconnectionValidator(mockLibrary);\n    validator->changeComponentInstances(containedInstances);\n\n    QCOMPARE(validator->hasValidMonitorInterfaces(testConnection), isValid);\n\n    if (!isValid)\n    {\n        QVector<QString> foundErrors;\n        validator->findErrorsInMonitorInterconnection(foundErrors, testConnection, \"test\");\n\n        QString expectedError = QObject::tr(\"No component reference set for monitor interface in monitor \"\n            \"interconnection '%1' within %2\").arg(testConnection->name()).arg(\"test\");\n\n        if (!monitorInterfaceExists)\n        {\n            expectedError = QObject::tr(\"No monitor interfaces set for monitor interconnection '%1' within %2\")\n                .arg(testConnection->name()).arg(\"test\");\n        }\n        else if (!instanceExists)\n        {\n            expectedError = QObject::tr(\"Component instance '%1' referenced by the monitor interface in monitor \"\n                \"interconnection '%2' within %3 was not found\")\n                .arg(componentReference).arg(testConnection->name()).arg(\"test\");\n        }\n        else if (busReference.isEmpty())\n        {\n            expectedError = QObject::tr(\"No bus reference set for monitor interface in monitor interconnection \"\n                \"'%1' within %2\").arg(testConnection->name()).arg(\"test\");\n        }\n        else if (!busInterfaceExists)\n        {\n            expectedError = QObject::tr(\"Bus interface '%1' referenced by the monitor interface in monitor \"\n                \"interconnection '%2' within %3 was not found\")\n                .arg(busReference).arg(testConnection->name()).arg(\"test\");\n        }\n        else if (copyInterface)\n        {\n            expectedError = QObject::tr(\"Component reference '%1' and bus reference '%2' pair is not unique in \"\n                \"monitor interfaces of monitor interconnection '%3' within %4.\")\n                .arg(testInterface->getComponentReference()).arg(testInterface->getBusReference())\n                .arg(testConnection->name()).arg(\"test\");\n        }\n\n        if (errorIsNotFoundInErrorList(expectedError, foundErrors))\n        {\n            QFAIL(\"No error message found\");\n        }\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_DesignValidator::testMonitorInterconnectionHasValidMonitorInterfaces_data()\n//-----------------------------------------------------------------------------\nvoid tst_DesignValidator::testMonitorInterconnectionHasValidMonitorInterfaces_data()\n{\n    QTest::addColumn<bool>(\"monitorInterfaceExists\");\n    QTest::addColumn<QString>(\"componentReference\");\n    QTest::addColumn<bool>(\"instanceExists\");\n    QTest::addColumn<QString>(\"busReference\");\n    QTest::addColumn<bool>(\"busInterfaceExists\");\n    QTest::addColumn<bool>(\"copyInterface\");\n    QTest::addColumn<bool>(\"isValid\");\n\n    QTest::newRow(\"Monitor interface with component and bus references to existing elements is valid\") <<\n        true << \"Space\" << true << \"Dandy\" << true << false << true;\n\n    QTest::newRow(\"Monitor interconnection without monitor interface is not valid\") <<\n        false << \"\" << false << \"\" << false << false << false;\n    QTest::newRow(\"Monitor interface without component instance reference is not valid\") <<\n        true << \"\" << true << \"Dandy\" << true << false << false;\n    QTest::newRow(\"Monitor interface referencing non-existing component instance is not valid\") <<\n        true << \"Space\" << false << \"Dandy\" << true << false << false;\n    QTest::newRow(\"Monitor interface without bus reference is not valid\") <<\n        true << \"Space\" << true << \"\" << true << false << false;\n    QTest::newRow(\"Monitor interface referencing non-existing bus interface is not valid\") <<\n        true << \"Space\" << true << \"Dandy\" << false << false << false;\n\n    QTest::newRow(\"Monitor interface referencing non-unique component / bus reference pair is not valid\") <<\n        true << \"Space\" << true << \"Dandy\" << true << true << false;\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_DesignValidator::testHasValidMonitorInterconnections()\n//-----------------------------------------------------------------------------\nvoid tst_DesignValidator::testHasValidMonitorInterconnections()\n{\n    QFETCH(bool, createInterconnection);\n    QFETCH(bool, monitoredActiveInterfaceExists);\n    QFETCH(bool, monitorInterfaceExists);\n    QFETCH(bool, copyInterconnection);\n    QFETCH(bool, isValid);\n\n    QSharedPointer<Design> testDesign (new Design(VLNV(VLNV::DESIGN, \"Samurai\", \"Champloo\", \"MugenJinFuu\", \"3\"),\n        Document::Revision::Std14));\n\n    LibraryMock* mockLibrary (new LibraryMock(this));\n\n    QSharedPointer<MonitorInterconnection> testConnection (new MonitorInterconnection(\"testConnection\"));    \n\n    if (createInterconnection)\n    {\n        if (monitoredActiveInterfaceExists)\n        {\n            QSharedPointer<MonitorInterface> activeInterface (new MonitorInterface(\"Space\", \"Dandy\"));\n\n            QSharedPointer<ConfigurableVLNVReference> componentVLNV (\n                new ConfigurableVLNVReference(VLNV(VLNV::COMPONENT, \"One\", \"Punch\", \"Man\", \"Saitama\")));\n            QSharedPointer<Component> testComponent (new Component(*componentVLNV, Document::Revision::Std14));\n            mockLibrary->addComponent(testComponent);\n\n            QSharedPointer<ComponentInstance> testInstance (\n                new ComponentInstance(activeInterface->getComponentReference(), componentVLNV));\n            testDesign->getComponentInstances()->append(testInstance);\n\n            QSharedPointer<BusInterface> testBus(new BusInterface());\n            testBus->setName(activeInterface->getBusReference());\n            testComponent->getBusInterfaces()->append(testBus);\n\n            testConnection->setMonitoredctiveInterface(activeInterface);\n        }\n\n        if (monitorInterfaceExists)\n        {\n            QSharedPointer<MonitorInterface> monitorInterface (new MonitorInterface(\"Cowboy\", \"Bebop\"));\n\n            QSharedPointer<ConfigurableVLNVReference> componentVLNV(\n                new ConfigurableVLNVReference(VLNV(VLNV::COMPONENT, \"Spike\", \"Jet\", \"Faye\", \"Edward\")));\n            QSharedPointer<Component> testComponent (new Component(*componentVLNV, Document::Revision::Std14));\n            mockLibrary->addComponent(testComponent);\n\n            QSharedPointer<ComponentInstance> testInstance (\n                new ComponentInstance(monitorInterface->getComponentReference(), componentVLNV));\n            testDesign->getComponentInstances()->append(testInstance);\n\n            QSharedPointer<BusInterface> testBus(new BusInterface());\n            testBus->setName(monitorInterface->getBusReference());\n            testComponent->getBusInterfaces()->append(testBus);\n\n            testConnection->getMonitorInterfaces()->append(monitorInterface);\n        }\n\n        testDesign->getMonitorInterconnecions()->append(testConnection);\n\n        if (copyInterconnection)\n        {\n            QSharedPointer<MonitorInterconnection> otherConnection (\n                new MonitorInterconnection(*testConnection.data()));\n            testDesign->getMonitorInterconnecions()->append(otherConnection);\n        }\n    }\n\n    QSharedPointer<DesignValidator> validator = createDesignValidator(mockLibrary);\n\n    QCOMPARE(validator->hasValidMonitorInterconnections(testDesign), isValid);\n\n    if (!isValid)\n    {\n        QVector<QString> foundErrors;\n        validator->findErrorsIn(foundErrors, testDesign);\n\n        QString expectedError = QObject::tr(\"Monitor interconnection name %1 within design %2 is not unique\")\n            .arg(testConnection->name()).arg(testDesign->getVlnv().toString());\n\n        if (!monitoredActiveInterfaceExists)\n        {\n            expectedError = QObject::tr(\"No monitored active interface set for monitor interconnection '%1' \"\n                \"within design %2\").arg(testConnection->name()).arg(testDesign->getVlnv().toString());\n        }\n        else if (!monitorInterfaceExists)\n        {\n            expectedError = QObject::tr(\"No monitor interfaces set for monitor interconnection '%1' within design \"\n                \"%2\" ).arg(testConnection->name()).arg(testDesign->getVlnv().toString());\n        }\n\n        if (errorIsNotFoundInErrorList(expectedError, foundErrors))\n        {\n            QFAIL(\"No error message found\");\n        }\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_DesignValidator::testHasValidMonitorInterconnections_data()\n//-----------------------------------------------------------------------------\nvoid tst_DesignValidator::testHasValidMonitorInterconnections_data()\n{\n    QTest::addColumn<bool>(\"createInterconnection\");\n    QTest::addColumn<bool>(\"monitoredActiveInterfaceExists\");\n    QTest::addColumn<bool>(\"monitorInterfaceExists\");\n    QTest::addColumn<bool>(\"copyInterconnection\");\n    QTest::addColumn<bool>(\"isValid\");\n\n    QTest::newRow(\"Design without monitor interconnections is valid\") << false << false << false << false << true;\n    QTest::newRow(\"Monitor interconnection with monitored active interface and a monitor interface is valid\") <<\n        true << true << true << false << true;\n\n    QTest::newRow(\"Monitor interconnection without a monitored active interface is not valid\") <<\n        true << false << true << false << false;\n    QTest::newRow(\"Monitor interconnection without a monitor interface is not valid\") <<\n        true << true << false << false << false;\n    QTest::newRow(\"Monitor interconnections with non-unique names are not valid\") <<\n        true << true << true << true << false;\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_DesignValidator::testAdHocConnectionHasValidName()\n//-----------------------------------------------------------------------------\nvoid tst_DesignValidator::testAdHocConnectionHasValidName()\n{\n    QFETCH(QString, name);\n    QFETCH(bool, isValid);\n\n    QSharedPointer<AdHocConnection> testConnection (new AdHocConnection(name));\n\n    QSharedPointer<AdHocConnectionValidator> validator = createAdHocConnectionValidator(0);\n\n    QCOMPARE(validator->hasValidName(testConnection), isValid);\n\n    if (!isValid)\n    {\n        QVector<QString> foundErrors;\n        validator->findErrorsIn(foundErrors, testConnection, \"test\");\n\n        QString expectedError = QObject::tr(\"Invalid name '%1' set for ad hoc connection within %2\")\n            .arg(name.trimmed()).arg(\"test\");\n\n        if (errorIsNotFoundInErrorList(expectedError, foundErrors))\n        {\n            QFAIL(\"No error message found\");\n        }\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_DesignValidator::testAdHocConnectionHasValidName_data()\n//-----------------------------------------------------------------------------\nvoid tst_DesignValidator::testAdHocConnectionHasValidName_data()\n{\n    QTest::addColumn<QString>(\"name\");\n    QTest::addColumn<bool>(\"isValid\");\n\n    QTest::newRow(\"Name test is valid\") << \"test\" << true;\n    QTest::newRow(\"Empty name is invalid\") << \"\" << false;\n    QTest::newRow(\"Name consisting of only white spaces is invalid\") << \"    \" << false;\n    QTest::newRow(\"Name consisting of characters and white spaces is valid\") << \"  test  \" << true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_DesignValidator::testAdHocConnectionHasValidIsPresent()\n//-----------------------------------------------------------------------------\nvoid tst_DesignValidator::testAdHocConnectionHasValidIsPresent()\n{\n    QFETCH(QString, isPresent);\n    QFETCH(bool, isValid);\n\n    QSharedPointer<AdHocConnection> testConnection (new AdHocConnection(\"Yatagarasu\"));\n    testConnection->setIsPresent(isPresent);\n\n    QSharedPointer<AdHocConnectionValidator> validator = createAdHocConnectionValidator(0);\n\n    QCOMPARE(validator->hasValidIsPresent(testConnection->getIsPresent()), isValid);\n\n    if (!isValid)\n    {\n        QVector<QString> foundErrors;\n        validator->findErrorsIn(foundErrors, testConnection, \"test\");\n\n        QString expectedError = QObject::tr(\"Invalid isPresent set for ad hoc connection %1 within %2\")\n            .arg(testConnection->name()).arg(\"test\");\n\n        if (errorIsNotFoundInErrorList(expectedError, foundErrors))\n        {\n            QFAIL(\"No error message found\");\n        }\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_DesignValidator::testAdHocConnectionHasValidIsPresent_data()\n//-----------------------------------------------------------------------------\nvoid tst_DesignValidator::testAdHocConnectionHasValidIsPresent_data()\n{\n    QTest::addColumn<QString>(\"isPresent\");\n    QTest::addColumn<bool>(\"isValid\");\n\n    QTest::newRow(\"IsPresent 1 is valid\") << \"1\" << true;\n    QTest::newRow(\"IsPresent 1*3-3 is valid\") << \"1*3-3\" << true;\n    QTest::newRow(\"IsPresent 2*100 is invalid\") << \"2*100\" << false;\n    QTest::newRow(\"IsPresent -14 is invalid\") << \"-14\" << false;\n    QTest::newRow(\"Real number isPresent  0.12 is invalid\") << \"0.12\" << false;\n    QTest::newRow(\"Text as isPresent is invalid\") << \"test\" << false;\n    QTest::newRow(\"String as isPresent is invalid\") << \"\\\"test\\\"\" << false;\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_DesignValidator::testAdHocConnectionHasValidTiedValue()\n//-----------------------------------------------------------------------------\nvoid tst_DesignValidator::testAdHocConnectionHasValidTiedValue()\n{\n    QFETCH(QString, tiedValue);\n    QFETCH(bool, isValid);\n\n    QSharedPointer<AdHocConnection> testConnection (new AdHocConnection(\"Yatagarasu\"));\n    testConnection->setTiedValue(tiedValue);\n\n    QSharedPointer<AdHocConnectionValidator> validator = createAdHocConnectionValidator(0);\n\n    QCOMPARE(validator->hasValidTiedValue(testConnection), isValid);\n\n    if (!isValid)\n    {\n        QVector<QString> foundErrors;\n        validator->findErrorsIn(foundErrors, testConnection, \"test\");\n\n        QString expectedError = QObject::tr(\"Invalid tied value set for ad hoc connection %1 within %2\")\n            .arg(testConnection->name()).arg(\"test\");\n\n        if (errorIsNotFoundInErrorList(expectedError, foundErrors))\n        {\n            QFAIL(\"No error message found\");\n        }\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_DesignValidator::testAdHocConnectionHasValidTiedValue_data()\n//-----------------------------------------------------------------------------\nvoid tst_DesignValidator::testAdHocConnectionHasValidTiedValue_data()\n{\n    QTest::addColumn<QString>(\"tiedValue\");\n    QTest::addColumn<bool>(\"isValid\");\n\n    QTest::newRow(\"Tied value default is valid\") << \"default\" << true;\n    QTest::newRow(\"Tied value open is valid\") << \"open\" << true;\n    QTest::newRow(\"Numerical tied value is valid\") << \"1\" << true;\n    QTest::newRow(\"Hexadecimal tied value is valid\") << \"'h01\" << true;\n    QTest::newRow(\"Empty tied value is valid\") << \"\" << true;\n\n    QTest::newRow(\"Tied value of text is not valid\") << \"text\" << false;\n    QTest::newRow(\"Tied value of only white spaces is not valid\") << \"    \" << false;\n    QTest::newRow(\"Tied value consisting of characters and white spaces is not valid\") << \"  test  \" << false;\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_DesignValidator::testAdHocConnectionHasValidInternalPortReference()\n//-----------------------------------------------------------------------------\nvoid tst_DesignValidator::testAdHocConnectionHasValidInternalPortReference()\n{\n    QFETCH(QString, tiedValue);\n    QFETCH(QString, componentReference);\n    QFETCH(bool, instanceExists);\n    QFETCH(QString, portReference);\n    QFETCH(bool, portExists);\n    QFETCH(bool, portHasDefault);\n    QFETCH(bool, isValid);\n\n    QSharedPointer<AdHocConnection> testConnection (new AdHocConnection(\"Yatagarasu\"));\n    testConnection->setTiedValue(tiedValue);\n\n    QSharedPointer<PortReference> internalReference (new PortReference(portReference, componentReference));\n    testConnection->getInternalPortReferences()->append(internalReference);\n\n    QSharedPointer<QList<QSharedPointer<ComponentInstance> > > instances (\n        new QList<QSharedPointer<ComponentInstance> > ());\n\n    LibraryMock* mockLibrary (new LibraryMock(this));\n\n    if (instanceExists)\n    {\n        QSharedPointer<ConfigurableVLNVReference> componentVLNV (\n            new ConfigurableVLNVReference(VLNV(VLNV::COMPONENT, \"One\", \"Punch\", \"Man\", \"Saitama\")));\n        QSharedPointer<Component> testComponent (new Component(*componentVLNV, Document::Revision::Std14));\n        mockLibrary->addComponent(testComponent);\n\n        QSharedPointer<ComponentInstance> testInstance(new ComponentInstance(componentReference, componentVLNV));\n        if (componentReference.isEmpty())\n        {\n            testInstance->setInstanceName(\"testInstance\");\n        }\n        instances->append(testInstance);\n\n        if (portExists)\n        {\n            QSharedPointer<Port> testPort (new Port(portReference));\n            testComponent->getPorts()->append(testPort);\n\n            if (portHasDefault)\n            {\n                testPort->setDefaultValue(\"27\");\n            }\n        }\n    }\n\n    QSharedPointer<AdHocConnectionValidator> validator = createAdHocConnectionValidator(mockLibrary);\n    validator->changeComponentInstances(instances);\n\n    QCOMPARE(validator->hasValidPortReferences(testConnection), isValid);\n\n    if (!isValid)\n    {\n        QVector<QString> foundErrors;\n        validator->findErrorsIn(foundErrors, testConnection, \"test\");\n\n        QString expectedError = QObject::tr(\"No component reference set for internal port reference in ad hoc \"\n            \"connection %1 within %2\").arg(testConnection->name()).arg(\"test\");\n\n        if (!instanceExists)\n        {\n            expectedError = QObject::tr(\"Component instance %1 referenced by internal port reference in ad hoc \"\n                \"connection %2 within %3 was not found\")\n                .arg(componentReference).arg(testConnection->name()).arg(\"test\");\n        }\n        else if (portReference.isEmpty())\n        {\n            expectedError = QObject::tr(\"No port reference set for internal port reference in ad hoc connection \"\n                \"%1 within %2\").arg(testConnection->name()).arg(\"test\");\n        }\n        else if (!portExists)\n        {\n            expectedError = QObject::tr(\"Port '%1' referenced by the internal port reference  in ad hoc \"\n                \"connection %2 within %3 was not found\")\n                .arg(portReference).arg(testConnection->name()).arg(\"test\");\n        }\n        else if (!portHasDefault && instanceExists && !componentReference.isEmpty() && !portReference.isEmpty() &&\n            portExists)\n        {\n            expectedError = QObject::tr(\"No default value found for port '%1' referenced by internal port \"\n                \"reference in ad hoc connection %2 within %3\")\n                .arg(portReference).arg(testConnection->name()).arg(\"test\");\n        }\n\n        if (errorIsNotFoundInErrorList(expectedError, foundErrors))\n        {\n            QFAIL(\"No error message found\");\n        }\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_DesignValidator::testAdHocConnectionHasValidInternalPortReference_data()\n//-----------------------------------------------------------------------------\nvoid tst_DesignValidator::testAdHocConnectionHasValidInternalPortReference_data()\n{\n    QTest::addColumn<QString>(\"tiedValue\");\n    QTest::addColumn<QString>(\"componentReference\");\n    QTest::addColumn<bool>(\"instanceExists\");\n    QTest::addColumn<QString>(\"portReference\");\n    QTest::addColumn<bool>(\"portExists\");\n    QTest::addColumn<bool>(\"portHasDefault\");\n    QTest::addColumn<bool>(\"isValid\");\n\n    QTest::newRow(\"Internal port reference referencing existing component and port is valid\") <<\n        \"\" << \"Space\" << true << \"Dandy\" << true << false << true;\n    QTest::newRow(\"Tied value default and internal port referenced port with default value is valid\") << \n        \"default\" << \"Space\" << true << \"Dandy\" << true << true << true;\n\n    QTest::newRow(\"Tied value default and internal port referenced port without default value is not valid\") << \n        \"default\" << \"Space\" << true << \"Dandy\" << true << false << false;\n    QTest::newRow(\"Internal port reference without component reference is not valid\") <<\n        \"\" << \"\" << true << \"Dandy\" << true << false << false;\n    QTest::newRow(\"Internal port reference referencing non-existing component instance is not valid\") <<\n        \"\" << \"Space\" << false << \"Dandy\" << true << false << false;\n    QTest::newRow(\"Internal port reference without port reference is not valid\") <<\n        \"open\" << \"Space\" << true << \"\" << true << false << false;\n    QTest::newRow(\"Internal port reference referencing non-existing port is not valid\") <<\n        \"1\" << \"Space\" << true << \"Dandy\" << false << false << false;\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_DesignValidator::testAdHocConnectionHasValidExternalPortReference()\n//-----------------------------------------------------------------------------\nvoid tst_DesignValidator::testAdHocConnectionHasValidExternalPortReference()\n{\n    QFETCH(QString, portReference);\n    QFETCH(QString, isPresent);\n    QFETCH(bool, isValid);\n\n    QSharedPointer<AdHocConnection> testConnection (new AdHocConnection(\"Yatagarasu\"));\n\n    QSharedPointer<PortReference> externalReference (new PortReference(portReference));\n    externalReference->setIsPresent(isPresent);\n    testConnection->getExternalPortReferences()->append(externalReference);\n\n    QSharedPointer<AdHocConnectionValidator> validator = createAdHocConnectionValidator(0);\n\n    QCOMPARE(validator->hasValidPortReferences(testConnection), isValid);\n\n    if (!isValid)\n    {\n        QVector<QString> foundErrors;\n        validator->findErrorsIn(foundErrors, testConnection, \"test\");\n\n        QString expectedError = QObject::tr(\"Invalid isPresent set for external port reference within ad hoc \"\n            \"connection %1\").arg(testConnection->name());\n\n        if (portReference.isEmpty())\n        {\n            expectedError = QObject::tr(\"No port reference set for external port reference in ad hoc \"\n                \"connection %1 within %2\").arg(testConnection->name()).arg(\"test\");\n        }\n\n        if (errorIsNotFoundInErrorList(expectedError, foundErrors))\n        {\n            QFAIL(\"No error message found\");\n        }\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_DesignValidator::testAdHocConnectionHasValidExternalPortReference_data()\n//-----------------------------------------------------------------------------\nvoid tst_DesignValidator::testAdHocConnectionHasValidExternalPortReference_data()\n{\n    QTest::addColumn<QString>(\"portReference\");\n    QTest::addColumn<QString>(\"isPresent\");\n    QTest::addColumn<bool>(\"isValid\");\n\n    QTest::newRow(\"External port reference with port reference is valid\") << \"Baldurs\" << \"\" << true;\n    QTest::newRow(\"External port without port reference is not valid\") << \"\" << \"\" << false;\n\n    QTest::newRow(\"Port reference with isPresent 1 is valid\") << \"Baldurs\" << \"1\" << true;\n    QTest::newRow(\"Port reference with isPresent 1*3-3 is valid\") << \"Baldurs\" <<  \"1*3-3\" << true;\n    QTest::newRow(\"Port reference with isPresent 2*100 is invalid\") << \"Baldurs\" << \"2*100\" << false;\n    QTest::newRow(\"Port reference with isPresent -14 is invalid\") << \"Baldurs\" << \"-14\" << false;\n    QTest::newRow(\"Port reference with real number isPresent  0.12 is invalid\") << \"Baldurs\" << \"0.12\" << false;\n    QTest::newRow(\"Port reference with text as isPresent is invalid\") << \"Baldurs\" << \"test\" << false;\n    QTest::newRow(\"Port reference with string as isPresent is invalid\") << \"Baldurs\" << \"\\\"test\\\"\" << false;\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_DesignValidator::testAdHocConnectionPortReferenceHasValidPartSelect()\n//-----------------------------------------------------------------------------\nvoid tst_DesignValidator::testAdHocConnectionPortReferenceHasValidPartSelect()\n{\n    QFETCH(bool, partSelectExists);\n    QFETCH(QString, rangeLeft);\n    QFETCH(QString, rangeRight);\n    QFETCH(QString, index);\n    QFETCH(bool, isValid);\n\n    QSharedPointer<PortReference> externalReference (new PortReference(\"Namida\"));\n\n    if (partSelectExists)\n    {\n        QSharedPointer<PartSelect> testPart (new PartSelect(rangeLeft, rangeRight));\n        if (!index.isEmpty())\n        {\n            testPart->getIndices()->append(index);\n        }\n\n        externalReference->setPartSelect(testPart);\n    }\n\n    QSharedPointer<AdHocConnection> testConnection (new AdHocConnection(\"Yatagarasu\"));\n    testConnection->getExternalPortReferences()->append(externalReference);\n\n    QSharedPointer<AdHocConnectionValidator> validator = createAdHocConnectionValidator(0);\n\n    QCOMPARE(validator->hasValidPortReferences(testConnection), isValid);\n\n    if (!isValid)\n    {\n        QVector<QString> foundErrors;\n        validator->findErrorsIn(foundErrors, testConnection, \"test\");\n\n        QSharedPointer<ExpressionParser> parser (new SystemVerilogExpressionParser());\n        bool indexToIntOk = true;\n        bool leftToIntOk = true;\n\n        parser->parseExpression(index).toInt(&indexToIntOk);\n        int intLeft = parser->parseExpression(rangeLeft).toInt(&leftToIntOk);\n\n        QString expectedError (\"\");\n\n        if (rangeLeft.isEmpty() && rangeRight.isEmpty() && index.isEmpty())\n        {\n            expectedError = QObject::tr(\"No range or index set for part select in external port reference in ad \"\n                \"hoc connection %1 within %2\")\n                .arg(testConnection->name()).arg(\"test\");\n        }\n        else if (intLeft < 0 || !leftToIntOk)\n        {\n            expectedError = QObject::tr(\"Invalid left value '%1' set for external port reference part select \"\n                \"in ad hoc connection %2 within %3\")\n                .arg(rangeLeft).arg(testConnection->name()).arg(\"test\");\n        }\n\n        else if (rangeRight.isEmpty())\n        {\n            expectedError = QObject::tr(\"Invalid right value '%1' set for external port reference part select in \"\n                \"ad hoc connection %2 within %3\")\n                .arg(rangeRight).arg(testConnection->name()).arg(\"test\");\n        }\n        else if (!indexToIntOk)\n        {\n            expectedError = QObject::tr(\"Invalid index value '%1' set for external port reference part select in \"\n                \"ad hoc connection %2 within %3\")\n                .arg(index).arg(testConnection->name()).arg(\"test\");\n        }\n\n        if (errorIsNotFoundInErrorList(expectedError, foundErrors))\n        {\n            QFAIL(\"No error message found\");\n        }\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_DesignValidator::testAdHocConnectionPortReferenceHasValidPartSelect_data()\n//-----------------------------------------------------------------------------\nvoid tst_DesignValidator::testAdHocConnectionPortReferenceHasValidPartSelect_data()\n{\n    QTest::addColumn<bool>(\"partSelectExists\");\n    QTest::addColumn<QString>(\"rangeLeft\");\n    QTest::addColumn<QString>(\"rangeRight\");\n    QTest::addColumn<QString>(\"index\");\n    QTest::addColumn<bool>(\"isValid\");\n\n    QTest::newRow(\"Port reference without part select is valid\") << false << \"\" << \"\" << \"\" << true;\n    QTest::newRow(\"Part select with range is valid\") << true << \"4\" << \"10\" << \"\" << true;\n    QTest::newRow(\"Part select with index is valid\") << true << \"\" << \"\" << \"8\" << true;\n    QTest::newRow(\"Part select with range and index is valid\") << true << \"4\" << \"10\" << \"8\" << true;\n    \n    QTest::newRow(\"Part select with negative values is not valid\") << true << \"-2\" << \"4\" << \"\" << false;\n    QTest::newRow(\"Part select with text as values is not valid\") << true << \"4\" << \"10\" << \"text\" << false;\n    QTest::newRow(\"Part select without range and index is not valid\") << true << \"\" << \"\" << \"\" << false;\n    QTest::newRow(\"Part select range without left value is not valid\") << true << \"\" << \"10\" << \"\" << false;\n    QTest::newRow(\"Part select range without right value is not valid\") << true << \"4\" << \"\" << \"\" << false;\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_DesignValidator::testHasValidAdHocConnections()\n//-----------------------------------------------------------------------------\nvoid tst_DesignValidator::testHasValidAdHocConnections()\n{\n    QFETCH(bool, createAdHocConnection);\n    QFETCH(bool, internalPortReferenceExists);\n    QFETCH(bool, copyAdHocConenction);\n    QFETCH(bool, isValid);\n\n    QSharedPointer<Design> testDesign (new Design(VLNV(VLNV::DESIGN, \"Samurai\", \"Champloo\", \"MugenJinFuu\", \"3\"),\n        Document::Revision::Std14));\n\n    LibraryMock* mockLibrary (new LibraryMock(this));\n\n    QSharedPointer<AdHocConnection> testConnection (new AdHocConnection(\"AdHoc\"));\n\n    if (createAdHocConnection)\n    {\n        if (internalPortReferenceExists)\n        {\n            QSharedPointer<PortReference> testReference (new PortReference(\"Saitama\", \"Genos\"));\n\n            QSharedPointer<ConfigurableVLNVReference> componentVLNV (\n                new ConfigurableVLNVReference(VLNV(VLNV::COMPONENT, \"One\", \"Punch\", \"Man\", \"Saitama\")));\n            QSharedPointer<Component> testComponent (new Component(*componentVLNV, Document::Revision::Std14));\n            mockLibrary->addComponent(testComponent);\n\n            QSharedPointer<ComponentInstance> testInstance(\n                new ComponentInstance(testReference->getComponentRef(), componentVLNV));\n            testDesign->getComponentInstances()->append(testInstance);\n\n            QSharedPointer<Port> referencedPort (new Port(testReference->getPortRef()));\n            testComponent->getPorts()->append(referencedPort);\n\n            testConnection->getInternalPortReferences()->append(testReference);\n        }\n\n        testDesign->getAdHocConnections()->append(testConnection);\n\n        if (copyAdHocConenction)\n        {\n            QSharedPointer<AdHocConnection> otherConnection (new AdHocConnection(*testConnection.data()));\n            testDesign->getAdHocConnections()->append(otherConnection);\n        }\n    }\n\n    QSharedPointer<DesignValidator> validator = createDesignValidator(mockLibrary);\n\n    QCOMPARE(validator->hasValidAdHocConnections(testDesign), isValid);\n\n    if (!isValid)\n    {\n        QVector<QString> foundErrors;\n        validator->findErrorsIn(foundErrors, testDesign);\n\n        QString expectedError = QObject::tr(\"Ad hoc connection name %1 within design %2 is not unique\")\n            .arg(testConnection->name()).arg(testDesign->getVlnv().toString());\n\n        if (!internalPortReferenceExists)\n        {\n            expectedError = QObject::tr(\"No port references set for ad hoc connection %1 within design %2\")\n                .arg(testConnection->name()).arg(testDesign->getVlnv().toString());\n        }\n\n        if (errorIsNotFoundInErrorList(expectedError, foundErrors))\n        {\n            QFAIL(\"No error message found\");\n        }\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_DesignValidator::testHasValidAdHocConnections_data()\n//-----------------------------------------------------------------------------\nvoid tst_DesignValidator::testHasValidAdHocConnections_data()\n{\n    QTest::addColumn<bool>(\"createAdHocConnection\");\n    QTest::addColumn<bool>(\"internalPortReferenceExists\");\n    QTest::addColumn<bool>(\"copyAdHocConenction\");\n    QTest::addColumn<bool>(\"isValid\");\n\n    QTest::newRow(\"Design without ad hoc connections is valid\") << false << false << false << true;\n    QTest::newRow(\"Ad hoc connection with port reference is valid\") << true << true << false << true;\n\n    QTest::newRow(\"Ad hoc connection without port reference is not valid\") << true << false << false << false;\n    QTest::newRow(\"Ad hoc connections with non-unique names are not valid\") << true << true << true << false;\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_DesignValidator::testHasValidParameters()\n//-----------------------------------------------------------------------------\nvoid tst_DesignValidator::testHasValidParameters()\n{\n    QFETCH(QString, name);\n    QFETCH(QString, value);\n    QFETCH(bool, copyParameter);\n    QFETCH(bool, isValid);\n\n    QSharedPointer<Parameter> testParameter (new Parameter());\n    testParameter->setName(name);\n    testParameter->setValue(value);\n\n    QSharedPointer<Design> testDesign (new Design(VLNV(VLNV::DESIGN, \"Samurai\", \"Champloo\", \"MugenJinFuu\", \"3\"), \n        Document::Revision::Std14));\n\n    testDesign->getParameters()->append(testParameter);\n\n    if (copyParameter)\n    {\n        QSharedPointer<Parameter> otherParameter (new Parameter(*testParameter.data()));\n        testDesign->getParameters()->append(otherParameter);\n    }\n\n    QSharedPointer<DesignValidator> validator = createDesignValidator(0);\n\n    QCOMPARE(validator->hasValidParameters(testDesign), isValid);\n\n    if (!isValid)\n    {\n        QVector<QString> foundErrors;\n        validator->findErrorsIn(foundErrors, testDesign);\n\n        QString expectedError =\n            QObject::tr(\"No valid name specified for parameter %1 within design %2\")\n            .arg(name).arg(testDesign->getVlnv().toString());\n\n        if (value.isEmpty())\n        {\n            expectedError = QObject::tr(\"No value specified for parameter %1 within design %2\")\n                .arg(name).arg(testDesign->getVlnv().toString());\n        }\n        else if (copyParameter)\n        {\n            expectedError = QObject::tr(\"Parameter name %1 within design %2 is not unique.\")\n                .arg(name).arg(testDesign->getVlnv().toString());\n        }\n\n        if (errorIsNotFoundInErrorList(expectedError, foundErrors))\n        {\n            QFAIL(\"No error message found\");\n        }\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_DesignValidator::testHasValidParameters_data()\n//-----------------------------------------------------------------------------\nvoid tst_DesignValidator::testHasValidParameters_data()\n{\n    QTest::addColumn<QString>(\"name\");\n    QTest::addColumn<QString>(\"value\");\n    QTest::addColumn<bool>(\"copyParameter\");\n    QTest::addColumn<bool>(\"isValid\");\n\n    QTest::newRow(\"Parameter with name and value is valid\") << \"Gunmen\" << \"8\" << false << true;\n    QTest::newRow(\"Parameter without name is not valid\") << \"\" << \"8\" << false << false;\n    QTest::newRow(\"Parameter without value is not valid\") << \"Gunmen\" << \"\" << false << false;\n    QTest::newRow(\"Parameters with the same name is not valid\") << \"Gunmen\" << \"8\" << true << false;\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_DesignValidator::testHasValidAssertions()\n//-----------------------------------------------------------------------------\nvoid tst_DesignValidator::testHasValidAssertions()\n{\n    QFETCH(QString, name);\n    QFETCH(QString, assertValue);\n    QFETCH(bool, copyAssertion);\n    QFETCH(bool, isValid);\n\n    QSharedPointer<Assertion> testAssertion (new Assertion());\n    testAssertion->setName(name);\n    testAssertion->setAssert(assertValue);\n\n    QSharedPointer<Design> testDesign (new Design(VLNV(VLNV::DESIGN, \"Samurai\", \"Champloo\", \"MugenJinFuu\", \"3\"), \n        Document::Revision::Std14));\n    testDesign->getAssertions()->append(testAssertion);\n\n    if (copyAssertion)\n    {\n        QSharedPointer<Assertion> otherAssertion (new Assertion(*testAssertion.data()));\n        testDesign->getAssertions()->append(otherAssertion);\n    }\n\n    QSharedPointer<DesignValidator> validator = createDesignValidator(0);\n\n    QCOMPARE(validator->hasValidAssertions(testDesign), isValid);\n\n    if (!isValid)\n    {\n        QVector<QString> foundErrors;\n        validator->findErrorsIn(foundErrors, testDesign);\n\n        QString expectedError = QObject::tr(\"Invalid name set for assertion %1 within design %2\")\n            .arg(name).arg(testDesign->getVlnv().toString());\n\n        QSharedPointer<ExpressionParser> parser (new SystemVerilogExpressionParser());\n        bool assertOk = true;\n        int parsedAssert = parser->parseExpression(assertValue).toInt(&assertOk);\n\n        if (!assertOk || parsedAssert != 1)\n        {\n            expectedError = QObject::tr(\"Invalid assert set for assertion %1 within design %2\")\n                .arg(name).arg(testDesign->getVlnv().toString());\n        }\n        else if (copyAssertion)\n        {\n            expectedError = QObject::tr(\"Assertion name %1 within design %2 is not unique.\")\n                .arg(name).arg(testDesign->getVlnv().toString());\n        }\n\n        if (errorIsNotFoundInErrorList(expectedError, foundErrors))\n        {\n            QFAIL(\"No error message found\");\n        }\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_DesignValidator::testHasValidAssertions_data()\n//-----------------------------------------------------------------------------\nvoid tst_DesignValidator::testHasValidAssertions_data()\n{\n    QTest::addColumn<QString>(\"name\");\n    QTest::addColumn<QString>(\"assertValue\");\n    QTest::addColumn<bool>(\"copyAssertion\");\n    QTest::addColumn<bool>(\"isValid\");\n\n    QTest::newRow(\"Assertion with name and assert value of 1 is valid\") << \"Onibocho\" << \"1\" << false << true;\n    QTest::newRow(\"Assertion without name is not valid\") << \"\" << \"4-3\" << false << false;\n    QTest::newRow(\"Assertion with incorrect assert value is not valid\") << \"Onibocho\" << \"4*2\" << false << false;\n    QTest::newRow(\"Assertion with assert value 0 is not valid\") << \"Onibocho\" << \"1*2-2\" << false << false;\n    QTest::newRow(\"Assertion without assert value is not valid\") << \"Onibocho\" << \"\" << false << false;\n    QTest::newRow(\"Assertions with the same name is not valid\") << \"Onibocho\" << \"1\" << true << false;\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_DesignValidator::errorIsNotFoundInErrorList()\n//-----------------------------------------------------------------------------\nbool tst_DesignValidator::errorIsNotFoundInErrorList(QString const& expectedError, QVector<QString> errorList)\n{\n    if (!errorList.contains(expectedError))\n    {\n        qDebug() << \"The following error:\" << Qt::endl << expectedError << Qt::endl << \"was not found in error list:\";\n        foreach(QString error, errorList)\n        {\n            qDebug() << error;\n        }\n        return true;\n    }\n\n    return false;\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_DesignValidator::createDesignValidator()\n//-----------------------------------------------------------------------------\nQSharedPointer<DesignValidator> tst_DesignValidator::createDesignValidator(LibraryInterface* library)\n{\n    QSharedPointer<ExpressionParser> parser (new SystemVerilogExpressionParser());\n\n    QSharedPointer<DesignValidator> validator (new DesignValidator(parser, library));\n\n    return validator;\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_DesignValidator::createComponentInstanceValidator()\n//-----------------------------------------------------------------------------\nQSharedPointer<ComponentInstanceValidator> tst_DesignValidator::createComponentInstanceValidator(\n    LibraryInterface* library)\n{\n    QSharedPointer<ExpressionParser> parser (new SystemVerilogExpressionParser());\n\n    QSharedPointer<ComponentInstanceValidator> validator (new ComponentInstanceValidator(parser, library));\n\n    return validator;\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_DesignValidator::createInterconnectionValidator()\n//-----------------------------------------------------------------------------\nQSharedPointer<InterconnectionValidator> tst_DesignValidator::createInterconnectionValidator(\n    LibraryInterface* library)\n{\n    QSharedPointer<ExpressionParser> parser (new SystemVerilogExpressionParser());\n\n    QSharedPointer<InterconnectionValidator> validator (new InterconnectionValidator(parser, library));\n\n    return validator;\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_DesignValidator::createAdHocConnectionValidator()\n//-----------------------------------------------------------------------------\nQSharedPointer<AdHocConnectionValidator> tst_DesignValidator::createAdHocConnectionValidator(\n    LibraryInterface* library)\n{\n    QSharedPointer<ExpressionParser> parser (new SystemVerilogExpressionParser());\n\n    QSharedPointer<AdHocConnectionValidator> validator (new AdHocConnectionValidator(parser, library));\n\n    return validator;\n}\n\nQTEST_APPLESS_MAIN(tst_DesignValidator)\n\n#include \"tst_DesignValidator.moc\"\n"
  },
  {
    "path": "tests/IPXACTmodels/Design/tst_DesignValidator.pri",
    "content": "# ----------------------------------------------------\n# This file is generated by the Qt Visual Studio Tools.\n# ------------------------------------------------------\n\nHEADERS += ../../MockObjects/LibraryMock.h\nSOURCES += ../../MockObjects/LibraryMock.cpp \\\n    ./tst_DesignValidator.cpp "
  },
  {
    "path": "tests/IPXACTmodels/Design/tst_DesignValidator.pro",
    "content": "#-----------------------------------------------------------------------------\n# File: tst_DesignValidator.pro\n#-----------------------------------------------------------------------------\n# Project: Kactus 2\n# Author: Mikko Teuho\n# Date: 14.01.2016\n#\n# Description:\n# Qt project file template for running unit tests for design validator.\n#-----------------------------------------------------------------------------\n\nTEMPLATE = app\n\nTARGET = tst_DesignValidator\n\nQT += core gui xml testlib\n\nCONFIG += c++11 testcase console\n\nlinux-g++ | linux-g++-64 | linux-g++-32 {\n LIBS += -L../../../executable \\\n     -lIPXACTmodels -lKactusAPI\n\n}\nwin64 | win32 {\n LIBS += -L../../../executable \\\n     -lIPXACTmodelsd -lKactusAPId\n}\n\nDESTDIR = ./release\n\nINCLUDEPATH += $$DESTDIR\nINCLUDEPATH += ../../../\n\nDEPENDPATH += .\nDEPENDPATH += ../../../\n\nOBJECTS_DIR += $$DESTDIR\n\nMOC_DIR += ./generatedFiles\nUI_DIR += ./generatedFiles\nRCC_DIR += ./generatedFiles\n\ninclude(tst_DesignValidator.pri)\n"
  },
  {
    "path": "tests/IPXACTmodels/Design/tst_DesignWriter.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: tst_DesignWriter.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 17.08.2015\r\n//\r\n// Description:\r\n// Unit test for class DesignWriter.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include <IPXACTmodels/Design/DesignWriter.h>\r\n#include <IPXACTmodels/Design/Design.h>\r\n\r\n#include <IPXACTmodels/common/GenericVendorExtension.h>\r\n#include <IPXACTmodels/kactusExtensions/Kactus2Group.h>\r\n\r\n#include <editors/common/ColumnTypes.h>\r\n\r\n#include <QtTest>\r\n#include <QSharedPointer>\r\n\r\nclass tst_DesignWriter : public QObject\r\n{\r\n    Q_OBJECT\r\n\r\npublic:\r\n    tst_DesignWriter();\r\n\r\nprivate slots:\r\n    \r\n    void testWriteSimpleDesign();\r\n    void testWriteSimple2022Design();\r\n    void testWriteProcessingInstructions();\r\n\r\n    void testWriteComponentInstances();\r\n    void testWrite2022ComponentInstances();\r\n    void testWriteComponentInstanceExtensions();\r\n\r\n    void testWriteInterconnections();\r\n    void testWrite2022Interconnections();\r\n    void testWriteInterconnectionExtensions();\r\n\r\n    void testWriteMonitorInterconnections();\r\n    void testWrite2022MonitorInterconnections();\r\n\r\n    void testWriteAdHocConnections();\r\n    void testWrite2022AdHocConnections();\r\n    void testWrite2022SubPortReferences();\r\n    void testWriteAdHocConnectionExtensions();\r\n\r\n    void testWriteParameters();\r\n    void testWriteAssertions();\r\n    void testWriteVendorExtensions();\r\n\r\n    void testWriteColumns();\r\n    void testWritePortAdHocVisibilitiesAndPositions();\r\n    void testWriteApiDependencies();\r\n    void testWriteHierApiDependencies();\r\n    void testWriteComConnections();\r\n    void testWriteHierComConnections();\r\n\r\nprivate:\r\n\r\n    void compareOutputToExpected(QString const& output, QString const& expectedOutput);\r\n\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_DesignWriter::tst_DesignWriter()\r\n//-----------------------------------------------------------------------------\r\ntst_DesignWriter::tst_DesignWriter()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_DesignWriter::testSimpleDesign()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_DesignWriter::testWriteSimpleDesign()\r\n{\r\n    VLNV designVLNV(VLNV::DESIGN, \"tuni.fi\", \"TestLibrary\", \"TestDesign\", \"0.1\");\r\n    auto testDesign = QSharedPointer<Design>(new Design(designVLNV, Document::Revision::Std14));\r\n\r\n    QString output;\r\n    QXmlStreamWriter xmlStreamWriter(&output);\r\n\r\n    xmlStreamWriter.setAutoFormatting(true);\r\n    xmlStreamWriter.setAutoFormattingIndent(-1);\r\n\r\n    QString expectedOutput(\r\n        \"<?xml version=\\\"1.0\\\"?>\\n\"\r\n        \"<ipxact:design \"\r\n        \"xmlns:xsi=\\\"http://www.w3.org/2001/XMLSchema-instance\\\" \" \r\n        \"xmlns:ipxact=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014\\\" \"\r\n        \"xmlns:kactus2=\\\"http://kactus2.cs.tut.fi\\\" \"\r\n        \"xsi:schemaLocation=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014 \"\r\n        \"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/index.xsd\\\">\\n\"\r\n            \"\\t<ipxact:vendor>tuni.fi</ipxact:vendor>\\n\"\r\n            \"\\t<ipxact:library>TestLibrary</ipxact:library>\\n\"\r\n            \"\\t<ipxact:name>TestDesign</ipxact:name>\\n\"\r\n            \"\\t<ipxact:version>0.1</ipxact:version>\\n\"\r\n        \"</ipxact:design>\\n\"\r\n        );\r\n\r\n    DesignWriter::writeDesign(xmlStreamWriter, testDesign);\r\n\r\n    //compareOutputToExpected(output, expectedOutput);\r\n    QCOMPARE(output, expectedOutput);\r\n\r\n    expectedOutput.clear();\r\n    output.clear();\r\n\r\n    testDesign->setDescription(\"testDescription\");\r\n    expectedOutput = \r\n        \"<?xml version=\\\"1.0\\\"?>\\n\"\r\n        \"<ipxact:design \"\r\n        \"xmlns:xsi=\\\"http://www.w3.org/2001/XMLSchema-instance\\\" \" \r\n        \"xmlns:ipxact=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014\\\" \"\r\n        \"xmlns:kactus2=\\\"http://kactus2.cs.tut.fi\\\" \"\r\n        \"xsi:schemaLocation=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014 \"\r\n        \"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/index.xsd\\\">\\n\"\r\n            \"\\t<ipxact:vendor>tuni.fi</ipxact:vendor>\\n\"\r\n            \"\\t<ipxact:library>TestLibrary</ipxact:library>\\n\"\r\n            \"\\t<ipxact:name>TestDesign</ipxact:name>\\n\"\r\n            \"\\t<ipxact:version>0.1</ipxact:version>\\n\"\r\n            \"\\t<ipxact:description>testDescription</ipxact:description>\\n\"\r\n        \"</ipxact:design>\\n\"\r\n        ;\r\n\r\n    DesignWriter::writeDesign(xmlStreamWriter, testDesign);\r\n\r\n    compareOutputToExpected(output, expectedOutput);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_DesignWriter::testWriteSimple2022Design()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_DesignWriter::testWriteSimple2022Design()\r\n{\r\n    VLNV designVLNV(VLNV::DESIGN, \"tuni.fi\", \"TestLibrary\", \"TestDesign\", \"0.1\");\r\n    auto testDesign = QSharedPointer<Design>(new Design(designVLNV, Document::Revision::Std22));\r\n\r\n    testDesign->setDisplayName(\"display\");\r\n    testDesign->setShortDescription(\"brief\");\r\n    testDesign->setDescription(\"testDescription\");\r\n\r\n    QString output;\r\n    QXmlStreamWriter xmlStreamWriter(&output);\r\n\r\n    xmlStreamWriter.setAutoFormatting(true);\r\n    xmlStreamWriter.setAutoFormattingIndent(-1);\r\n\r\n    QString expectedOutput(\r\n        \"<?xml version=\\\"1.0\\\"?>\\n\"\r\n        \"<ipxact:design \"\r\n        \"xmlns:xsi=\\\"http://www.w3.org/2001/XMLSchema-instance\\\" \"\r\n        \"xmlns:ipxact=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2022\\\" \"\r\n        \"xmlns:kactus2=\\\"http://kactus2.cs.tut.fi\\\" \"\r\n        \"xsi:schemaLocation=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2022 \"\r\n        \"http://www.accellera.org/XMLSchema/IPXACT/1685-2022/index.xsd\\\">\\n\"\r\n        \"\\t<ipxact:vendor>tuni.fi</ipxact:vendor>\\n\"\r\n        \"\\t<ipxact:library>TestLibrary</ipxact:library>\\n\"\r\n        \"\\t<ipxact:name>TestDesign</ipxact:name>\\n\"\r\n        \"\\t<ipxact:version>0.1</ipxact:version>\\n\"\r\n        \"\\t<ipxact:displayName>display</ipxact:displayName>\\n\"\r\n        \"\\t<ipxact:shortDescription>brief</ipxact:shortDescription>\\n\"\r\n        \"\\t<ipxact:description>testDescription</ipxact:description>\\n\"\r\n        \"</ipxact:design>\\n\"\r\n    );\r\n\r\n    DesignWriter::writeDesign(xmlStreamWriter, testDesign);\r\n\r\n    compareOutputToExpected(output, expectedOutput);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_DesignWriter::testWriteProcessingInstructions()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_DesignWriter::testWriteProcessingInstructions()\r\n{\r\n    VLNV designVLNV(VLNV::DESIGN, \"tuni.fi\", \"TestLibrary\", \"TestDesign\", \"0.1\");\r\n    auto testDesign = QSharedPointer<Design>(new Design(designVLNV, Document::Revision::Std14));\r\n\r\n    testDesign->setTopComments(\"Header comment\");\r\n    testDesign->addXmlProcessingInstructions(\"xml-stylesheet\", \"href=\\\"style.css\\\"\");\r\n\r\n    QString output;\r\n    QXmlStreamWriter xmlStreamWriter(&output);\r\n\r\n    xmlStreamWriter.setAutoFormatting(true);\r\n    xmlStreamWriter.setAutoFormattingIndent(-1);\r\n\r\n    QString expectedOutput(\r\n        \"<?xml version=\\\"1.0\\\"?>\\n\"\r\n        \"<!--Header comment-->\\n\"\r\n        \"<?xml-stylesheet href=\\\"style.css\\\"?>\\n\"\r\n        \"<ipxact:design \"\r\n        \"xmlns:xsi=\\\"http://www.w3.org/2001/XMLSchema-instance\\\" \" \r\n        \"xmlns:ipxact=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014\\\" \"\r\n        \"xmlns:kactus2=\\\"http://kactus2.cs.tut.fi\\\" \"\r\n        \"xsi:schemaLocation=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014 \"\r\n        \"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/index.xsd\\\">\\n\"\r\n            \"\\t<ipxact:vendor>tuni.fi</ipxact:vendor>\\n\"\r\n            \"\\t<ipxact:library>TestLibrary</ipxact:library>\\n\"\r\n            \"\\t<ipxact:name>TestDesign</ipxact:name>\\n\"\r\n            \"\\t<ipxact:version>0.1</ipxact:version>\\n\"\r\n        \"</ipxact:design>\\n\"\r\n        );\r\n\r\n    DesignWriter::writeDesign(xmlStreamWriter, testDesign);\r\n\r\n    QCOMPARE(output, expectedOutput);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_DesignWriter::testWriteComponentInstances()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_DesignWriter::testWriteComponentInstances()\r\n{\r\n    VLNV designVLNV(VLNV::DESIGN, \"tuni.fi\", \"TestLibrary\", \"TestDesign\", \"0.1\");\r\n    auto testDesign = QSharedPointer<Design>(new Design(designVLNV, Document::Revision::Std14));\r\n\r\n    QString output;\r\n    QXmlStreamWriter xmlStreamWriter(&output);\r\n\r\n    xmlStreamWriter.setAutoFormatting(true);\r\n    xmlStreamWriter.setAutoFormattingIndent(-1);\r\n\r\n    QSharedPointer<ConfigurableVLNVReference> testComponentReference (\r\n        new ConfigurableVLNVReference(VLNV::COMPONENT, \"tuni.fi\", \"TestLibrary\", \"testComponent\", \"1.0\"));\r\n\r\n    QSharedPointer<ConfigurableElementValue> componentElement (\r\n        new ConfigurableElementValue(\"10\", \"testReferenceID\"));\r\n    testComponentReference->getConfigurableElementValues()->append(componentElement);\r\n\r\n    QSharedPointer<ComponentInstance> testComponentInstance(new ComponentInstance(\"testInstance\",\r\n        testComponentReference));\r\n    testComponentInstance->setDisplayName(\"displayName\");\r\n    testComponentInstance->setDescription(\"described\");\r\n    testComponentInstance->setPosition(QPointF(10, 10));\r\n    testComponentInstance->setUuid(\"testUUID\");\r\n    testComponentInstance->setIsPresent(\"2-1\");\r\n\r\n    testDesign->getComponentInstances()->append(testComponentInstance);\r\n\r\n    QString expectedOutput(\r\n        \"<?xml version=\\\"1.0\\\"?>\\n\"\r\n        \"<ipxact:design \"\r\n        \"xmlns:xsi=\\\"http://www.w3.org/2001/XMLSchema-instance\\\" \" \r\n        \"xmlns:ipxact=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014\\\" \"\r\n        \"xmlns:kactus2=\\\"http://kactus2.cs.tut.fi\\\" \"\r\n        \"xsi:schemaLocation=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014 \"\r\n        \"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/index.xsd\\\">\\n\"\r\n            \"\\t<ipxact:vendor>tuni.fi</ipxact:vendor>\\n\"\r\n            \"\\t<ipxact:library>TestLibrary</ipxact:library>\\n\"\r\n            \"\\t<ipxact:name>TestDesign</ipxact:name>\\n\"\r\n            \"\\t<ipxact:version>0.1</ipxact:version>\\n\"\r\n            \"\\t<ipxact:componentInstances>\\n\"\r\n                \"\\t\\t<ipxact:componentInstance>\\n\"\r\n                    \"\\t\\t\\t<ipxact:instanceName>testInstance</ipxact:instanceName>\\n\"\r\n                    \"\\t\\t\\t<ipxact:displayName>displayName</ipxact:displayName>\\n\"\r\n                    \"\\t\\t\\t<ipxact:description>described</ipxact:description>\\n\"\r\n                    \"\\t\\t\\t<ipxact:isPresent>2-1</ipxact:isPresent>\\n\"\r\n                    \"\\t\\t\\t<ipxact:componentRef vendor=\\\"tuni.fi\\\" library=\\\"TestLibrary\\\"\"\r\n                            \" name=\\\"testComponent\\\" version=\\\"1.0\\\">\\n\"\r\n                        \"\\t\\t\\t\\t<ipxact:configurableElementValues>\\n\"\r\n                            \"\\t\\t\\t\\t\\t<ipxact:configurableElementValue referenceId=\\\"testReferenceID\\\">10\"\r\n                                      \"</ipxact:configurableElementValue>\\n\"\r\n                        \"\\t\\t\\t\\t</ipxact:configurableElementValues>\\n\"\r\n                    \"\\t\\t\\t</ipxact:componentRef>\\n\"\r\n                    \"\\t\\t\\t<ipxact:vendorExtensions>\\n\"\r\n                        \"\\t\\t\\t\\t<kactus2:uuid>testUUID</kactus2:uuid>\\n\"\r\n                        \"\\t\\t\\t\\t<kactus2:position x=\\\"10\\\" y=\\\"10\\\"/>\\n\"\r\n                    \"\\t\\t\\t</ipxact:vendorExtensions>\\n\"\r\n                \"\\t\\t</ipxact:componentInstance>\\n\"\r\n            \"\\t</ipxact:componentInstances>\\n\"\r\n        \"</ipxact:design>\\n\"\r\n        );\r\n\r\n    DesignWriter::writeDesign(xmlStreamWriter, testDesign);\r\n\r\n    compareOutputToExpected(output, expectedOutput);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_DesignWriter::testWrite2022ComponentInstances()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_DesignWriter::testWrite2022ComponentInstances()\r\n{\r\n    VLNV designVLNV(VLNV::DESIGN, \"tuni.fi\", \"TestLibrary\", \"TestDesign\", \"0.1\");\r\n    auto testDesign = QSharedPointer<Design>(new Design(designVLNV, Document::Revision::Std22));\r\n\r\n    QString output;\r\n    QXmlStreamWriter xmlStreamWriter(&output);\r\n\r\n    xmlStreamWriter.setAutoFormatting(true);\r\n    xmlStreamWriter.setAutoFormattingIndent(-1);\r\n\r\n    QSharedPointer<ConfigurableVLNVReference> testComponentReference (\r\n        new ConfigurableVLNVReference(VLNV::COMPONENT, \"tuni.fi\", \"TestLibrary\", \"testComponent\", \"1.0\"));\r\n\r\n    QSharedPointer<ConfigurableElementValue> componentElement (\r\n        new ConfigurableElementValue(\"10\", \"testReferenceID\"));\r\n    testComponentReference->getConfigurableElementValues()->append(componentElement);\r\n\r\n    QSharedPointer<ComponentInstance> testComponentInstance(new ComponentInstance(\"testInstance\",\r\n        testComponentReference));\r\n    testComponentInstance->setDisplayName(\"displayName\");\r\n    testComponentInstance->setShortDescription(\"brief\");\r\n    testComponentInstance->setDescription(\"described\");\r\n    testComponentInstance->setPosition(QPointF(10, 10));\r\n    testComponentInstance->setUuid(\"testUUID\");\r\n\r\n    QSharedPointer<ComponentInstance::PowerDomainLink> firstLink(new ComponentInstance::PowerDomainLink({ \"ext\", QStringList(\"int\") }));\r\n    QSharedPointer<ComponentInstance::PowerDomainLink> secondLink(new ComponentInstance::PowerDomainLink({ \"outside\", QStringList{\"inside\", \"in\"}}));\r\n    testComponentInstance->getPowerDomainLinks()->append(firstLink);\r\n    testComponentInstance->getPowerDomainLinks()->append(secondLink);\r\n\r\n    testDesign->getComponentInstances()->append(testComponentInstance);\r\n\r\n    QString expectedOutput(\r\n        \"<?xml version=\\\"1.0\\\"?>\\n\"\r\n        \"<ipxact:design \"\r\n        \"xmlns:xsi=\\\"http://www.w3.org/2001/XMLSchema-instance\\\" \" \r\n        \"xmlns:ipxact=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2022\\\" \"\r\n        \"xmlns:kactus2=\\\"http://kactus2.cs.tut.fi\\\" \"\r\n        \"xsi:schemaLocation=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2022 \"\r\n        \"http://www.accellera.org/XMLSchema/IPXACT/1685-2022/index.xsd\\\">\\n\"\r\n            \"\\t<ipxact:vendor>tuni.fi</ipxact:vendor>\\n\"\r\n            \"\\t<ipxact:library>TestLibrary</ipxact:library>\\n\"\r\n            \"\\t<ipxact:name>TestDesign</ipxact:name>\\n\"\r\n            \"\\t<ipxact:version>0.1</ipxact:version>\\n\"\r\n            \"\\t<ipxact:componentInstances>\\n\"\r\n                \"\\t\\t<ipxact:componentInstance>\\n\"\r\n                    \"\\t\\t\\t<ipxact:instanceName>testInstance</ipxact:instanceName>\\n\"\r\n                    \"\\t\\t\\t<ipxact:displayName>displayName</ipxact:displayName>\\n\"\r\n                    \"\\t\\t\\t<ipxact:shortDescription>brief</ipxact:shortDescription>\\n\"\r\n                    \"\\t\\t\\t<ipxact:description>described</ipxact:description>\\n\"\r\n                    \"\\t\\t\\t<ipxact:componentRef vendor=\\\"tuni.fi\\\" library=\\\"TestLibrary\\\"\"\r\n                            \" name=\\\"testComponent\\\" version=\\\"1.0\\\">\\n\"\r\n                        \"\\t\\t\\t\\t<ipxact:configurableElementValues>\\n\"\r\n                            \"\\t\\t\\t\\t\\t<ipxact:configurableElementValue referenceId=\\\"testReferenceID\\\">10\"\r\n                                      \"</ipxact:configurableElementValue>\\n\"\r\n                        \"\\t\\t\\t\\t</ipxact:configurableElementValues>\\n\"\r\n                    \"\\t\\t\\t</ipxact:componentRef>\\n\"\r\n                    \"\\t\\t\\t<ipxact:powerDomainLinks>\\n\"\r\n                        \"\\t\\t\\t\\t<ipxact:powerDomainLink>\\n\"\r\n                            \"\\t\\t\\t\\t\\t<ipxact:externalPowerDomainReference>ext</ipxact:externalPowerDomainReference>\\n\"\r\n                            \"\\t\\t\\t\\t\\t<ipxact:internalPowerDomainReference>int</ipxact:internalPowerDomainReference>\\n\"\r\n                        \"\\t\\t\\t\\t</ipxact:powerDomainLink>\\n\"\r\n                        \"\\t\\t\\t\\t<ipxact:powerDomainLink>\\n\"\r\n                            \"\\t\\t\\t\\t\\t<ipxact:externalPowerDomainReference>outside</ipxact:externalPowerDomainReference>\\n\"\r\n                            \"\\t\\t\\t\\t\\t<ipxact:internalPowerDomainReference>inside</ipxact:internalPowerDomainReference>\\n\"\r\n                            \"\\t\\t\\t\\t\\t<ipxact:internalPowerDomainReference>in</ipxact:internalPowerDomainReference>\\n\"\r\n                        \"\\t\\t\\t\\t</ipxact:powerDomainLink>\\n\"\r\n                    \"\\t\\t\\t</ipxact:powerDomainLinks>\\n\"\r\n                    \"\\t\\t\\t<ipxact:vendorExtensions>\\n\"\r\n                        \"\\t\\t\\t\\t<kactus2:uuid>testUUID</kactus2:uuid>\\n\"\r\n                        \"\\t\\t\\t\\t<kactus2:position x=\\\"10\\\" y=\\\"10\\\"/>\\n\"\r\n                    \"\\t\\t\\t</ipxact:vendorExtensions>\\n\"\r\n                \"\\t\\t</ipxact:componentInstance>\\n\"\r\n            \"\\t</ipxact:componentInstances>\\n\"\r\n        \"</ipxact:design>\\n\"\r\n        );\r\n\r\n    DesignWriter::writeDesign(xmlStreamWriter, testDesign);\r\n\r\n    compareOutputToExpected(output, expectedOutput);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_DesignWriter::testWriteComponentInstanceExtensions()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_DesignWriter::testWriteComponentInstanceExtensions()\r\n{\r\n    VLNV designVLNV(VLNV::DESIGN, \"tuni.fi\", \"TestLibrary\", \"TestDesign\", \"0.1\");\r\n    auto testDesign = QSharedPointer<Design>(new Design(designVLNV, Document::Revision::Std14));\r\n\r\n    QString output;\r\n    QXmlStreamWriter xmlStreamWriter(&output);\r\n\r\n    xmlStreamWriter.setAutoFormatting(true);\r\n    xmlStreamWriter.setAutoFormattingIndent(-1);\r\n\r\n    QSharedPointer<ConfigurableVLNVReference> testComponentReference (\r\n        new ConfigurableVLNVReference(VLNV::COMPONENT, \"tuni.fi\", \"TestLibrary\", \"testComponent\", \"1.0\"));\r\n\r\n    QSharedPointer<ConfigurableElementValue> componentElement (\r\n        new ConfigurableElementValue(\"10\", \"testReferenceID\"));\r\n    testComponentReference->getConfigurableElementValues()->append(componentElement);\r\n\r\n    QSharedPointer<ComponentInstance> testComponentInstance(new ComponentInstance(\"testInstance\",\r\n        testComponentReference));\r\n    testComponentInstance->setPosition(QPointF(10, 10));\r\n    testComponentInstance->setUuid(\"testUUID\");\r\n\r\n    testComponentInstance->setComponentRef(testComponentReference);\r\n    testComponentInstance->setImportRef(\"importSource\");\r\n    testComponentInstance->updateBusInterfacePosition(\"testInterface\", QPointF(4,4));\r\n    testComponentInstance->updateAdHocPortPosition(\"adHocPort\", QPointF(3,3));\r\n    testComponentInstance->updateApiInterfacePosition(\"apiInterface\", QPointF(2,2));\r\n    testComponentInstance->updateComInterfacePosition(\"comInterface\", QPointF(1,1));\r\n    testComponentInstance->setFileSetRef(\"filesetRef\");\r\n    testComponentInstance->setMapping(\"hwRef\");\r\n\r\n    QSharedPointer<ComponentInstance> otherComponentInstance(new ComponentInstance(\"otherInstance\",\r\n        testComponentReference));\r\n    otherComponentInstance->setPosition(QPointF(1,1));\r\n    otherComponentInstance->setUuid(\"otherUUID\");\r\n    otherComponentInstance->setImported(true);\r\n\r\n    QMap<QString, QString> swProperties;\r\n    swProperties.insert(\"testSWProperty\", \"8\");\r\n    testComponentInstance->setPropertyValues(swProperties);\r\n\r\n    testDesign->getComponentInstances()->append(testComponentInstance);\r\n    testDesign->getComponentInstances()->append(otherComponentInstance);\r\n\r\n    QString expectedOutput(\r\n        \"<?xml version=\\\"1.0\\\"?>\\n\"\r\n        \"<ipxact:design \"\r\n        \"xmlns:xsi=\\\"http://www.w3.org/2001/XMLSchema-instance\\\" \" \r\n        \"xmlns:ipxact=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014\\\" \"\r\n        \"xmlns:kactus2=\\\"http://kactus2.cs.tut.fi\\\" \"\r\n        \"xsi:schemaLocation=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014 \"\r\n        \"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/index.xsd\\\">\\n\"\r\n            \"\\t<ipxact:vendor>tuni.fi</ipxact:vendor>\\n\"\r\n            \"\\t<ipxact:library>TestLibrary</ipxact:library>\\n\"\r\n            \"\\t<ipxact:name>TestDesign</ipxact:name>\\n\"\r\n            \"\\t<ipxact:version>0.1</ipxact:version>\\n\"\r\n            \"\\t<ipxact:componentInstances>\\n\"\r\n                \"\\t\\t<ipxact:componentInstance>\\n\"\r\n                    \"\\t\\t\\t<ipxact:instanceName>testInstance</ipxact:instanceName>\\n\"\r\n                    \"\\t\\t\\t<ipxact:componentRef vendor=\\\"tuni.fi\\\" library=\\\"TestLibrary\\\" name=\\\"testComponent\\\"\"\r\n                        \" version=\\\"1.0\\\">\\n\"\r\n                        \"\\t\\t\\t\\t<ipxact:configurableElementValues>\\n\"\r\n                            \"\\t\\t\\t\\t\\t<ipxact:configurableElementValue referenceId=\\\"testReferenceID\\\">10\"\r\n                                \"</ipxact:configurableElementValue>\\n\"\r\n                        \"\\t\\t\\t\\t</ipxact:configurableElementValues>\\n\"\r\n                    \"\\t\\t\\t</ipxact:componentRef>\\n\"\r\n                    \"\\t\\t\\t<ipxact:vendorExtensions>\\n\"\r\n                        \"\\t\\t\\t\\t<kactus2:uuid>testUUID</kactus2:uuid>\\n\"\r\n                        \"\\t\\t\\t\\t<kactus2:position x=\\\"10\\\" y=\\\"10\\\"/>\\n\"\r\n                        \"\\t\\t\\t\\t<kactus2:imported importRef=\\\"importSource\\\"/>\\n\"\r\n                        \"\\t\\t\\t\\t<kactus2:portPositions>\\n\"\r\n                            \"\\t\\t\\t\\t\\t<kactus2:portPosition busRef=\\\"testInterface\\\" x=\\\"4\\\" y=\\\"4\\\"/>\\n\"\r\n                        \"\\t\\t\\t\\t</kactus2:portPositions>\\n\"\r\n                        \"\\t\\t\\t\\t<kactus2:adHocVisibilities>\\n\"\r\n                            \"\\t\\t\\t\\t\\t<kactus2:adHocVisible portName=\\\"adHocPort\\\" x=\\\"3\\\" y=\\\"3\\\"/>\\n\"\r\n                        \"\\t\\t\\t\\t</kactus2:adHocVisibilities>\\n\"\r\n                        \"\\t\\t\\t\\t<kactus2:apiInterfacePositions>\\n\"\r\n                            \"\\t\\t\\t\\t\\t<kactus2:apiInterfacePosition apiRef=\\\"apiInterface\\\" x=\\\"2\\\" y=\\\"2\\\"/>\\n\"\r\n                        \"\\t\\t\\t\\t</kactus2:apiInterfacePositions>\\n\"\r\n                        \"\\t\\t\\t\\t<kactus2:comInterfacePositions>\\n\"\r\n                            \"\\t\\t\\t\\t\\t<kactus2:comInterfacePosition comRef=\\\"comInterface\\\" x=\\\"1\\\" y=\\\"1\\\"/>\\n\"\r\n                        \"\\t\\t\\t\\t</kactus2:comInterfacePositions>\\n\"\r\n                        \"\\t\\t\\t\\t<kactus2:fileSetRef>filesetRef</kactus2:fileSetRef>\\n\"\r\n                        \"\\t\\t\\t\\t<kactus2:mapping hwRef=\\\"hwRef\\\"/>\\n\"\r\n                        \"\\t\\t\\t\\t<kactus2:propertyValues>\\n\"\r\n                            \"\\t\\t\\t\\t\\t<kactus2:propertyValue name=\\\"testSWProperty\\\" value=\\\"8\\\"/>\\n\"\r\n                        \"\\t\\t\\t\\t</kactus2:propertyValues>\\n\"\r\n                    \"\\t\\t\\t</ipxact:vendorExtensions>\\n\"\r\n                \"\\t\\t</ipxact:componentInstance>\\n\"\r\n                \"\\t\\t<ipxact:componentInstance>\\n\"\r\n                    \"\\t\\t\\t<ipxact:instanceName>otherInstance</ipxact:instanceName>\\n\"\r\n                    \"\\t\\t\\t<ipxact:componentRef vendor=\\\"tuni.fi\\\" library=\\\"TestLibrary\\\" name=\\\"testComponent\\\"\"\r\n                        \" version=\\\"1.0\\\">\\n\"\r\n                        \"\\t\\t\\t\\t<ipxact:configurableElementValues>\\n\"\r\n                            \"\\t\\t\\t\\t\\t<ipxact:configurableElementValue referenceId=\\\"testReferenceID\\\">10\"\r\n                                \"</ipxact:configurableElementValue>\\n\"\r\n                        \"\\t\\t\\t\\t</ipxact:configurableElementValues>\\n\"\r\n                    \"\\t\\t\\t</ipxact:componentRef>\\n\"\r\n                    \"\\t\\t\\t<ipxact:vendorExtensions>\\n\"\r\n                        \"\\t\\t\\t\\t<kactus2:uuid>otherUUID</kactus2:uuid>\\n\"\r\n                        \"\\t\\t\\t\\t<kactus2:position x=\\\"1\\\" y=\\\"1\\\"/>\\n\"\r\n                        \"\\t\\t\\t\\t<kactus2:imported/>\\n\"\r\n                    \"\\t\\t\\t</ipxact:vendorExtensions>\\n\"\r\n                \"\\t\\t</ipxact:componentInstance>\\n\"\r\n            \"\\t</ipxact:componentInstances>\\n\"\r\n        \"</ipxact:design>\\n\"\r\n        );\r\n\r\n    DesignWriter::writeDesign(xmlStreamWriter, testDesign);\r\n\r\n    compareOutputToExpected(output, expectedOutput);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_DesignWriter::testWriteInterconnections()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_DesignWriter::testWriteInterconnections()\r\n{\r\n    VLNV designVLNV(VLNV::DESIGN, \"tuni.fi\", \"TestLibrary\", \"TestDesign\", \"0.1\");\r\n    auto testDesign = QSharedPointer<Design>(new Design(designVLNV, Document::Revision::Std14));\r\n\r\n    QString output;\r\n    QXmlStreamWriter xmlStreamWriter(&output);\r\n\r\n    xmlStreamWriter.setAutoFormatting(true);\r\n    xmlStreamWriter.setAutoFormattingIndent(-1);\r\n\r\n    QDomDocument document;\r\n    QDomElement extensionNode = document.createElement(\"testExtension\");\r\n    extensionNode.setAttribute(\"testExtensionAttribute\", \"extension\");\r\n    extensionNode.appendChild(document.createTextNode(\"testValue\"));\r\n    QSharedPointer<GenericVendorExtension> testExtension(new GenericVendorExtension(extensionNode));\r\n\r\n    QSharedPointer<ActiveInterface> testStartInterface(new ActiveInterface(\"componentRef\", \"busRef\"));\r\n    testStartInterface->setIsPresent(\"1\");\r\n    testStartInterface->setDescription(\"interfaceDescription\");\r\n    testStartInterface->getExcludePorts()->append(\"testExcludePort\");\r\n    testStartInterface->getVendorExtensions()->append(testExtension);\r\n\r\n    QSharedPointer<HierInterface> testHierInterface(new HierInterface(\"hierBusRef\"));\r\n    testHierInterface->setIsPresent(\"2-1\");\r\n    testHierInterface->setDescription(\"hierDescription\");\r\n    testHierInterface->getVendorExtensions()->append(testExtension);\r\n\r\n    QSharedPointer<ActiveInterface> testActiveInterface(new ActiveInterface(\"otherComponent\", \"otherBus\"));\r\n\r\n    QSharedPointer<Interconnection> testInterconnection(new Interconnection(\r\n        \"testActiveHierActive\", testStartInterface, \"interconnectionDisplay\", \"interconnectionDescription\"));\r\n    testInterconnection->setIsPresent(\"4-3\");\r\n    testInterconnection->getActiveInterfaces()->append(testActiveInterface);\r\n    testInterconnection->getHierInterfaces()->append(testHierInterface);\r\n    testInterconnection->getVendorExtensions()->append(testExtension);\r\n\r\n    testDesign->getInterconnections()->append(testInterconnection);\r\n\r\n    QString expectedOutput(\r\n        \"<?xml version=\\\"1.0\\\"?>\\n\"\r\n        \"<ipxact:design \"\r\n        \"xmlns:xsi=\\\"http://www.w3.org/2001/XMLSchema-instance\\\" \" \r\n        \"xmlns:ipxact=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014\\\" \"\r\n        \"xmlns:kactus2=\\\"http://kactus2.cs.tut.fi\\\" \"\r\n        \"xsi:schemaLocation=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014 \"\r\n        \"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/index.xsd\\\">\\n\"\r\n            \"\\t<ipxact:vendor>tuni.fi</ipxact:vendor>\\n\"\r\n            \"\\t<ipxact:library>TestLibrary</ipxact:library>\\n\"\r\n            \"\\t<ipxact:name>TestDesign</ipxact:name>\\n\"\r\n            \"\\t<ipxact:version>0.1</ipxact:version>\\n\"\r\n            \"\\t<ipxact:interconnections>\\n\"\r\n                \"\\t\\t<ipxact:interconnection>\\n\"\r\n                    \"\\t\\t\\t<ipxact:name>testActiveHierActive</ipxact:name>\\n\"\r\n                    \"\\t\\t\\t<ipxact:displayName>interconnectionDisplay</ipxact:displayName>\\n\"\r\n                    \"\\t\\t\\t<ipxact:description>interconnectionDescription</ipxact:description>\\n\"\r\n                    \"\\t\\t\\t<ipxact:isPresent>4-3</ipxact:isPresent>\\n\"\r\n                    \"\\t\\t\\t<ipxact:activeInterface componentRef=\\\"componentRef\\\" busRef=\\\"busRef\\\">\\n\"\r\n                        \"\\t\\t\\t\\t<ipxact:isPresent>1</ipxact:isPresent>\\n\"\r\n                        \"\\t\\t\\t\\t<ipxact:description>interfaceDescription</ipxact:description>\\n\"\r\n                        \"\\t\\t\\t\\t<ipxact:excludePorts>\\n\"\r\n                            \"\\t\\t\\t\\t\\t<ipxact:excludePort>testExcludePort</ipxact:excludePort>\\n\"\r\n                        \"\\t\\t\\t\\t</ipxact:excludePorts>\\n\"\r\n                        \"\\t\\t\\t\\t<ipxact:vendorExtensions>\\n\"\r\n                            \"\\t\\t\\t\\t\\t<testExtension testExtensionAttribute=\\\"extension\\\">testValue</testExtension>\\n\"\r\n                        \"\\t\\t\\t\\t</ipxact:vendorExtensions>\\n\"\r\n                    \"\\t\\t\\t</ipxact:activeInterface>\\n\"\r\n                    \"\\t\\t\\t<ipxact:activeInterface componentRef=\\\"otherComponent\\\" busRef=\\\"otherBus\\\"/>\\n\"\r\n                    \"\\t\\t\\t<ipxact:hierInterface busRef=\\\"hierBusRef\\\">\\n\"\r\n                        \"\\t\\t\\t\\t<ipxact:isPresent>2-1</ipxact:isPresent>\\n\"\r\n                        \"\\t\\t\\t\\t<ipxact:description>hierDescription</ipxact:description>\\n\"\r\n                        \"\\t\\t\\t\\t<ipxact:vendorExtensions>\\n\"\r\n                            \"\\t\\t\\t\\t\\t<testExtension testExtensionAttribute=\\\"extension\\\">testValue</testExtension>\\n\"\r\n                        \"\\t\\t\\t\\t</ipxact:vendorExtensions>\\n\"\r\n                    \"\\t\\t\\t</ipxact:hierInterface>\\n\"\r\n                    \"\\t\\t\\t<ipxact:vendorExtensions>\\n\"\r\n                        \"\\t\\t\\t\\t<testExtension testExtensionAttribute=\\\"extension\\\">testValue</testExtension>\\n\"\r\n                    \"\\t\\t\\t</ipxact:vendorExtensions>\\n\"\r\n                \"\\t\\t</ipxact:interconnection>\\n\"\r\n            \"\\t</ipxact:interconnections>\\n\"\r\n        \"</ipxact:design>\\n\"\r\n        );\r\n\r\n    DesignWriter::writeDesign(xmlStreamWriter, testDesign);\r\n\r\n    compareOutputToExpected(output, expectedOutput);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_DesignWriter::testWrite2022Interconnections()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_DesignWriter::testWrite2022Interconnections()\r\n{\r\n    VLNV designVLNV(VLNV::DESIGN, \"tuni.fi\", \"TestLibrary\", \"TestDesign\", \"0.1\");\r\n    auto testDesign = QSharedPointer<Design>(new Design(designVLNV, Document::Revision::Std22));\r\n\r\n    QString output;\r\n    QXmlStreamWriter xmlStreamWriter(&output);\r\n\r\n    xmlStreamWriter.setAutoFormatting(true);\r\n    xmlStreamWriter.setAutoFormattingIndent(-1);\r\n\r\n    QDomDocument document;\r\n    QDomElement extensionNode = document.createElement(\"testExtension\");\r\n    extensionNode.setAttribute(\"testExtensionAttribute\", \"extension\");\r\n    extensionNode.appendChild(document.createTextNode(\"testValue\"));\r\n    QSharedPointer<GenericVendorExtension> testExtension(new GenericVendorExtension(extensionNode));\r\n\r\n    QSharedPointer<ActiveInterface> testStartInterface(new ActiveInterface(\"componentRef\", \"busRef\"));\r\n    testStartInterface->setDescription(\"interfaceDescription\");\r\n    testStartInterface->getExcludePorts()->append(\"testExcludePort\");\r\n    testStartInterface->getVendorExtensions()->append(testExtension);\r\n\r\n    QSharedPointer<HierInterface> testHierInterface(new HierInterface(\"hierBusRef\"));\r\n    testHierInterface->setDescription(\"hierDescription\");\r\n    testHierInterface->getVendorExtensions()->append(testExtension);\r\n\r\n    QSharedPointer<ActiveInterface> testActiveInterface(new ActiveInterface(\"otherComponent\", \"otherBus\"));\r\n\r\n    QSharedPointer<Interconnection> testInterconnection(new Interconnection());\r\n    testInterconnection->setName(\"testActiveHierActive\");\r\n    testInterconnection->setDisplayName(\"connect\");\r\n    testInterconnection->setShortDescription(\"brief\");\r\n    testInterconnection->setDescription(\"interconnect description\");\r\n    testInterconnection->setStartInterface(testStartInterface);\r\n    testInterconnection->getActiveInterfaces()->append(testActiveInterface);\r\n    testInterconnection->getHierInterfaces()->append(testHierInterface);\r\n    testInterconnection->getVendorExtensions()->append(testExtension);\r\n\r\n    testDesign->getInterconnections()->append(testInterconnection);\r\n\r\n    QString expectedOutput(\r\n        \"<?xml version=\\\"1.0\\\"?>\\n\"\r\n        \"<ipxact:design \"\r\n        \"xmlns:xsi=\\\"http://www.w3.org/2001/XMLSchema-instance\\\" \" \r\n        \"xmlns:ipxact=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2022\\\" \"\r\n        \"xmlns:kactus2=\\\"http://kactus2.cs.tut.fi\\\" \"\r\n        \"xsi:schemaLocation=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2022 \"\r\n        \"http://www.accellera.org/XMLSchema/IPXACT/1685-2022/index.xsd\\\">\\n\"\r\n            \"\\t<ipxact:vendor>tuni.fi</ipxact:vendor>\\n\"\r\n            \"\\t<ipxact:library>TestLibrary</ipxact:library>\\n\"\r\n            \"\\t<ipxact:name>TestDesign</ipxact:name>\\n\"\r\n            \"\\t<ipxact:version>0.1</ipxact:version>\\n\"\r\n            \"\\t<ipxact:interconnections>\\n\"\r\n                \"\\t\\t<ipxact:interconnection>\\n\"\r\n                    \"\\t\\t\\t<ipxact:name>testActiveHierActive</ipxact:name>\\n\"\r\n                    \"\\t\\t\\t<ipxact:displayName>connect</ipxact:displayName>\\n\"\r\n                    \"\\t\\t\\t<ipxact:shortDescription>brief</ipxact:shortDescription>\\n\"\r\n                    \"\\t\\t\\t<ipxact:description>interconnect description</ipxact:description>\\n\"\r\n                    \"\\t\\t\\t<ipxact:activeInterface componentInstanceRef=\\\"componentRef\\\" busRef=\\\"busRef\\\">\\n\"\r\n                        \"\\t\\t\\t\\t<ipxact:description>interfaceDescription</ipxact:description>\\n\"\r\n                        \"\\t\\t\\t\\t<ipxact:excludePorts>\\n\"\r\n                            \"\\t\\t\\t\\t\\t<ipxact:excludePort>testExcludePort</ipxact:excludePort>\\n\"\r\n                        \"\\t\\t\\t\\t</ipxact:excludePorts>\\n\"\r\n                        \"\\t\\t\\t\\t<ipxact:vendorExtensions>\\n\"\r\n                            \"\\t\\t\\t\\t\\t<testExtension testExtensionAttribute=\\\"extension\\\">testValue</testExtension>\\n\"\r\n                        \"\\t\\t\\t\\t</ipxact:vendorExtensions>\\n\"\r\n                    \"\\t\\t\\t</ipxact:activeInterface>\\n\"\r\n                    \"\\t\\t\\t<ipxact:activeInterface componentInstanceRef=\\\"otherComponent\\\" busRef=\\\"otherBus\\\"/>\\n\"\r\n                    \"\\t\\t\\t<ipxact:hierInterface busRef=\\\"hierBusRef\\\">\\n\"\r\n                        \"\\t\\t\\t\\t<ipxact:description>hierDescription</ipxact:description>\\n\"\r\n                        \"\\t\\t\\t\\t<ipxact:vendorExtensions>\\n\"\r\n                            \"\\t\\t\\t\\t\\t<testExtension testExtensionAttribute=\\\"extension\\\">testValue</testExtension>\\n\"\r\n                        \"\\t\\t\\t\\t</ipxact:vendorExtensions>\\n\"\r\n                    \"\\t\\t\\t</ipxact:hierInterface>\\n\"\r\n                    \"\\t\\t\\t<ipxact:vendorExtensions>\\n\"\r\n                        \"\\t\\t\\t\\t<testExtension testExtensionAttribute=\\\"extension\\\">testValue</testExtension>\\n\"\r\n                    \"\\t\\t\\t</ipxact:vendorExtensions>\\n\"\r\n                \"\\t\\t</ipxact:interconnection>\\n\"\r\n            \"\\t</ipxact:interconnections>\\n\"\r\n        \"</ipxact:design>\\n\"\r\n        );\r\n\r\n    DesignWriter::writeDesign(xmlStreamWriter, testDesign);\r\n\r\n    compareOutputToExpected(output, expectedOutput);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_DesignWriter::testWriteInterconnectionExtensions()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_DesignWriter::testWriteInterconnectionExtensions()\r\n{\r\n    VLNV designVLNV(VLNV::DESIGN, \"tuni.fi\", \"TestLibrary\", \"TestDesign\", \"0.1\");\r\n    auto testDesign = QSharedPointer<Design>(new Design(designVLNV, Document::Revision::Std14));\r\n\r\n    QString output;\r\n    QXmlStreamWriter xmlStreamWriter(&output);\r\n\r\n    xmlStreamWriter.setAutoFormatting(true);\r\n    xmlStreamWriter.setAutoFormattingIndent(-1);\r\n\r\n    QSharedPointer<ActiveInterface> testStartInterface(new ActiveInterface(\"componentRef\", \"busRef\"));\r\n\r\n    QSharedPointer<HierInterface> testHierInterface(new HierInterface(\"hierBusRef\"));\r\n\r\n    QSharedPointer<Interconnection> testInterconnection(new Interconnection(\r\n        \"testActiveHierActive\", testStartInterface, \"\", \"\"));\r\n    testInterconnection->getHierInterfaces()->append(testHierInterface);\r\n    testInterconnection->setOffPage(true);\r\n\r\n    QList<QPointF> interconnectionRoute;\r\n    interconnectionRoute.append(QPointF(1,1));\r\n    interconnectionRoute.append(QPointF(1,2));\r\n    testHierInterface->setRoute(interconnectionRoute);\r\n\r\n    testDesign->getInterconnections()->append(testInterconnection);\r\n\r\n    QString expectedOutput(\r\n        \"<?xml version=\\\"1.0\\\"?>\\n\"\r\n        \"<ipxact:design \"\r\n        \"xmlns:xsi=\\\"http://www.w3.org/2001/XMLSchema-instance\\\" \" \r\n        \"xmlns:ipxact=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014\\\" \"\r\n        \"xmlns:kactus2=\\\"http://kactus2.cs.tut.fi\\\" \"\r\n        \"xsi:schemaLocation=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014 \"\r\n        \"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/index.xsd\\\">\\n\"\r\n            \"\\t<ipxact:vendor>tuni.fi</ipxact:vendor>\\n\"\r\n            \"\\t<ipxact:library>TestLibrary</ipxact:library>\\n\"\r\n            \"\\t<ipxact:name>TestDesign</ipxact:name>\\n\"\r\n            \"\\t<ipxact:version>0.1</ipxact:version>\\n\"\r\n            \"\\t<ipxact:interconnections>\\n\"\r\n                \"\\t\\t<ipxact:interconnection>\\n\"\r\n                    \"\\t\\t\\t<ipxact:name>testActiveHierActive</ipxact:name>\\n\"\r\n                    \"\\t\\t\\t<ipxact:activeInterface componentRef=\\\"componentRef\\\" busRef=\\\"busRef\\\"/>\\n\"\r\n                    \"\\t\\t\\t<ipxact:hierInterface busRef=\\\"hierBusRef\\\">\\n\"\r\n                        \"\\t\\t\\t\\t<ipxact:vendorExtensions>\\n\"\r\n                            \"\\t\\t\\t\\t\\t<kactus2:route>\\n\"\r\n                                \"\\t\\t\\t\\t\\t\\t<kactus2:position x=\\\"1\\\" y=\\\"1\\\"/>\\n\"\r\n                                \"\\t\\t\\t\\t\\t\\t<kactus2:position x=\\\"1\\\" y=\\\"2\\\"/>\\n\"\r\n                            \"\\t\\t\\t\\t\\t</kactus2:route>\\n\"\r\n                        \"\\t\\t\\t\\t</ipxact:vendorExtensions>\\n\"\r\n                    \"\\t\\t\\t</ipxact:hierInterface>\\n\"\r\n                    \"\\t\\t\\t<ipxact:vendorExtensions>\\n\"\r\n                        \"\\t\\t\\t\\t<kactus2:offPage/>\\n\"\r\n                    \"\\t\\t\\t</ipxact:vendorExtensions>\\n\"\r\n                \"\\t\\t</ipxact:interconnection>\\n\"\r\n            \"\\t</ipxact:interconnections>\\n\"\r\n        \"</ipxact:design>\\n\"\r\n        );\r\n\r\n    DesignWriter::writeDesign(xmlStreamWriter, testDesign);\r\n\r\n    compareOutputToExpected(output, expectedOutput);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_DesignWriter::testWriteMonitorInterconnections()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_DesignWriter::testWriteMonitorInterconnections()\r\n{\r\n    VLNV designVLNV(VLNV::DESIGN, \"tuni.fi\", \"TestLibrary\", \"TestDesign\", \"0.1\");\r\n    auto testDesign = QSharedPointer<Design>(new Design(designVLNV, Document::Revision::Std14));\r\n\r\n    QString output;\r\n    QXmlStreamWriter xmlStreamWriter(&output);\r\n\r\n    xmlStreamWriter.setAutoFormatting(true);\r\n    xmlStreamWriter.setAutoFormattingIndent(-1);\r\n\r\n    QDomDocument document;\r\n    QDomElement extensionNode = document.createElement(\"testExtension\");\r\n    extensionNode.setAttribute(\"testExtensionAttribute\", \"extension\");\r\n    extensionNode.appendChild(document.createTextNode(\"testValue\"));\r\n    QSharedPointer<GenericVendorExtension> testExtension(new GenericVendorExtension(extensionNode));\r\n\r\n    QSharedPointer<MonitorInterface> testActiveInterface (new MonitorInterface(\"componentRef\", \"busRef\"));\r\n    testActiveInterface->setPath(\"/path/to/test\");\r\n    testActiveInterface->setDescription(\"monitoredActiveDescription\");\r\n    testActiveInterface->getVendorExtensions()->append(testExtension);\r\n\r\n    QSharedPointer<MonitorInterface> testMonitorInterface (new MonitorInterface(\"otherComponent\", \"otherBus\"));\r\n    testMonitorInterface->setPath(\"/path/to/other/test\");\r\n    testMonitorInterface->setDescription(\"monitorInterfaceDescription\");\r\n    testMonitorInterface->setIsPresent(\"1\");\r\n    testMonitorInterface->getVendorExtensions()->append(testExtension);\r\n\r\n    QSharedPointer<MonitorInterconnection> testMonitorInterconnection (new MonitorInterconnection(\r\n        \"monitorInterconnection\", testActiveInterface, \"monitorDisplay\", \"monitorDescription\"));\r\n    testMonitorInterconnection->setIsPresent(\"2-1\");\r\n    testMonitorInterconnection->setMonitoredctiveInterface(testActiveInterface);\r\n    testMonitorInterconnection->getMonitorInterfaces()->append(testMonitorInterface);\r\n\r\n    testDesign->getMonitorInterconnecions()->append(testMonitorInterconnection);\r\n\r\n    QString expectedOutput(\r\n        \"<?xml version=\\\"1.0\\\"?>\\n\"\r\n        \"<ipxact:design \"\r\n        \"xmlns:xsi=\\\"http://www.w3.org/2001/XMLSchema-instance\\\" \" \r\n        \"xmlns:ipxact=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014\\\" \"\r\n        \"xmlns:kactus2=\\\"http://kactus2.cs.tut.fi\\\" \"\r\n        \"xsi:schemaLocation=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014 \"\r\n        \"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/index.xsd\\\">\\n\"\r\n            \"\\t<ipxact:vendor>tuni.fi</ipxact:vendor>\\n\"\r\n            \"\\t<ipxact:library>TestLibrary</ipxact:library>\\n\"\r\n            \"\\t<ipxact:name>TestDesign</ipxact:name>\\n\"\r\n            \"\\t<ipxact:version>0.1</ipxact:version>\\n\"\r\n            \"\\t<ipxact:interconnections>\\n\"\r\n                \"\\t\\t<ipxact:monitorInterconnection>\\n\"\r\n                    \"\\t\\t\\t<ipxact:name>monitorInterconnection</ipxact:name>\\n\"\r\n                    \"\\t\\t\\t<ipxact:displayName>monitorDisplay</ipxact:displayName>\\n\"\r\n                    \"\\t\\t\\t<ipxact:description>monitorDescription</ipxact:description>\\n\"\r\n                    \"\\t\\t\\t<ipxact:isPresent>2-1</ipxact:isPresent>\\n\"\r\n                    \"\\t\\t\\t<ipxact:monitoredActiveInterface componentRef=\\\"componentRef\\\" busRef=\\\"busRef\\\"\"\r\n                        \" path=\\\"/path/to/test\\\">\\n\"\r\n                        \"\\t\\t\\t\\t<ipxact:description>monitoredActiveDescription</ipxact:description>\\n\"\r\n                        \"\\t\\t\\t\\t<ipxact:vendorExtensions>\\n\"\r\n                            \"\\t\\t\\t\\t\\t<testExtension testExtensionAttribute=\\\"extension\\\">testValue</testExtension>\\n\"\r\n                        \"\\t\\t\\t\\t</ipxact:vendorExtensions>\\n\"\r\n                    \"\\t\\t\\t</ipxact:monitoredActiveInterface>\\n\"\r\n                    \"\\t\\t\\t<ipxact:monitorInterface componentRef=\\\"otherComponent\\\" busRef=\\\"otherBus\\\" \"\r\n                        \"path=\\\"/path/to/other/test\\\">\\n\"\r\n                        \"\\t\\t\\t\\t<ipxact:description>monitorInterfaceDescription</ipxact:description>\\n\"\r\n                        \"\\t\\t\\t\\t<ipxact:vendorExtensions>\\n\"\r\n                            \"\\t\\t\\t\\t\\t<testExtension testExtensionAttribute=\\\"extension\\\">testValue</testExtension>\\n\"\r\n                        \"\\t\\t\\t\\t</ipxact:vendorExtensions>\\n\"\r\n                        \"\\t\\t\\t\\t<ipxact:isPresent>1</ipxact:isPresent>\\n\"\r\n                    \"\\t\\t\\t</ipxact:monitorInterface>\\n\"\r\n                \"\\t\\t</ipxact:monitorInterconnection>\\n\"\r\n            \"\\t</ipxact:interconnections>\\n\"\r\n        \"</ipxact:design>\\n\"\r\n        );\r\n\r\n    DesignWriter::writeDesign(xmlStreamWriter, testDesign);\r\n\r\n    compareOutputToExpected(output, expectedOutput);\r\n}\r\n\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_DesignWriter::testWrite2022MonitorInterconnections()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_DesignWriter::testWrite2022MonitorInterconnections()\r\n{\r\n    VLNV designVLNV(VLNV::DESIGN, \"tuni.fi\", \"TestLibrary\", \"TestDesign\", \"0.1\");\r\n    auto testDesign = QSharedPointer<Design>(new Design(designVLNV, Document::Revision::Std22));\r\n\r\n    QString output;\r\n    QXmlStreamWriter xmlStreamWriter(&output);\r\n\r\n    xmlStreamWriter.setAutoFormatting(true);\r\n    xmlStreamWriter.setAutoFormattingIndent(-1);\r\n\r\n    QDomDocument document;\r\n    QDomElement extensionNode = document.createElement(\"testExtension\");\r\n    extensionNode.setAttribute(\"testExtensionAttribute\", \"extension\");\r\n    extensionNode.appendChild(document.createTextNode(\"testValue\"));\r\n    QSharedPointer<GenericVendorExtension> testExtension(new GenericVendorExtension(extensionNode));\r\n\r\n    QSharedPointer<MonitorInterface> testActiveInterface (new MonitorInterface(\"componentRef\", \"busRef\"));\r\n    testActiveInterface->setPath(\"/path/to/test\");\r\n    testActiveInterface->setDescription(\"monitoredActiveDescription\");\r\n    testActiveInterface->getVendorExtensions()->append(testExtension);\r\n\r\n    QSharedPointer<MonitorInterface> testMonitorInterface (new MonitorInterface(\"otherComponent\", \"otherBus\"));\r\n    testMonitorInterface->setPath(\"/path/to/other/test\");\r\n    testMonitorInterface->setDescription(\"monitorInterfaceDescription\");\r\n    testMonitorInterface->getVendorExtensions()->append(testExtension);\r\n\r\n    QSharedPointer<MonitorInterconnection> testMonitorInterconnection (new MonitorInterconnection(\r\n        \"monitorInterconnection\", testActiveInterface, \"monitorDisplay\", \"monitorDescription\"));\r\n    testMonitorInterconnection->setMonitoredctiveInterface(testActiveInterface);\r\n    testMonitorInterconnection->getMonitorInterfaces()->append(testMonitorInterface);\r\n\r\n    testDesign->getMonitorInterconnecions()->append(testMonitorInterconnection);\r\n\r\n    QString expectedOutput(\r\n        \"<?xml version=\\\"1.0\\\"?>\\n\"\r\n        \"<ipxact:design \"\r\n        \"xmlns:xsi=\\\"http://www.w3.org/2001/XMLSchema-instance\\\" \" \r\n        \"xmlns:ipxact=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2022\\\" \"\r\n        \"xmlns:kactus2=\\\"http://kactus2.cs.tut.fi\\\" \"\r\n        \"xsi:schemaLocation=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2022 \"\r\n        \"http://www.accellera.org/XMLSchema/IPXACT/1685-2022/index.xsd\\\">\\n\"\r\n            \"\\t<ipxact:vendor>tuni.fi</ipxact:vendor>\\n\"\r\n            \"\\t<ipxact:library>TestLibrary</ipxact:library>\\n\"\r\n            \"\\t<ipxact:name>TestDesign</ipxact:name>\\n\"\r\n            \"\\t<ipxact:version>0.1</ipxact:version>\\n\"\r\n            \"\\t<ipxact:interconnections>\\n\"\r\n                \"\\t\\t<ipxact:monitorInterconnection>\\n\"\r\n                    \"\\t\\t\\t<ipxact:name>monitorInterconnection</ipxact:name>\\n\"\r\n                    \"\\t\\t\\t<ipxact:displayName>monitorDisplay</ipxact:displayName>\\n\"\r\n                    \"\\t\\t\\t<ipxact:description>monitorDescription</ipxact:description>\\n\"\r\n                    \"\\t\\t\\t<ipxact:monitoredActiveInterface componentInstanceRef=\\\"componentRef\\\" busRef=\\\"busRef\\\"\"\r\n                        \" path=\\\"/path/to/test\\\">\\n\"\r\n                        \"\\t\\t\\t\\t<ipxact:description>monitoredActiveDescription</ipxact:description>\\n\"\r\n                        \"\\t\\t\\t\\t<ipxact:vendorExtensions>\\n\"\r\n                            \"\\t\\t\\t\\t\\t<testExtension testExtensionAttribute=\\\"extension\\\">testValue</testExtension>\\n\"\r\n                        \"\\t\\t\\t\\t</ipxact:vendorExtensions>\\n\"\r\n                    \"\\t\\t\\t</ipxact:monitoredActiveInterface>\\n\"\r\n                    \"\\t\\t\\t<ipxact:monitorInterface componentInstanceRef=\\\"otherComponent\\\" busRef=\\\"otherBus\\\" \"\r\n                        \"path=\\\"/path/to/other/test\\\">\\n\"\r\n                        \"\\t\\t\\t\\t<ipxact:description>monitorInterfaceDescription</ipxact:description>\\n\"\r\n                        \"\\t\\t\\t\\t<ipxact:vendorExtensions>\\n\"\r\n                            \"\\t\\t\\t\\t\\t<testExtension testExtensionAttribute=\\\"extension\\\">testValue</testExtension>\\n\"\r\n                        \"\\t\\t\\t\\t</ipxact:vendorExtensions>\\n\"\r\n                    \"\\t\\t\\t</ipxact:monitorInterface>\\n\"\r\n                \"\\t\\t</ipxact:monitorInterconnection>\\n\"\r\n            \"\\t</ipxact:interconnections>\\n\"\r\n        \"</ipxact:design>\\n\"\r\n        );\r\n\r\n    DesignWriter::writeDesign(xmlStreamWriter, testDesign);\r\n\r\n    compareOutputToExpected(output, expectedOutput);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_DesignWriter::testWriteAdHocConnections()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_DesignWriter::testWriteAdHocConnections()\r\n{\r\n    VLNV designVLNV(VLNV::DESIGN, \"tuni.fi\", \"TestLibrary\", \"TestDesign\", \"0.1\");\r\n    auto testDesign = QSharedPointer<Design>(new Design(designVLNV, Document::Revision::Std14));\r\n\r\n    QString output;\r\n    QXmlStreamWriter xmlStreamWriter(&output);\r\n\r\n    xmlStreamWriter.setAutoFormatting(true);\r\n    xmlStreamWriter.setAutoFormattingIndent(-1);\r\n\r\n    QDomDocument document;\r\n    QDomElement extensionNode = document.createElement(\"testExtension\");\r\n    extensionNode.setAttribute(\"testExtensionAttribute\", \"extension\");\r\n    extensionNode.appendChild(document.createTextNode(\"testValue\"));\r\n    QSharedPointer<GenericVendorExtension> testExtension(new GenericVendorExtension(extensionNode));\r\n\r\n    QSharedPointer<PartSelect> internalPartSelect (new PartSelect(\"1\", \"11\"));\r\n    internalPartSelect->getIndices()->append(\"8\");\r\n    internalPartSelect->getIndices()->append(\"4+4\");\r\n\r\n    QSharedPointer<PartSelect> externalPartSelect (new PartSelect(\"0\", \"4\"));\r\n\r\n    QSharedPointer<PortReference> testInternalPortRef (new PortReference(\"internalPort\", \"componentInstance\"));\r\n    testInternalPortRef->setIsPresent(\"1\");\r\n    testInternalPortRef->setPartSelect(internalPartSelect);\r\n\r\n    QSharedPointer<PortReference> testExternalPortRef (new PortReference(\"externalPort\"));\r\n    testExternalPortRef->setIsPresent(\"0\");\r\n    testExternalPortRef->setPartSelect(externalPartSelect);\r\n\r\n    QSharedPointer<AdHocConnection> testAdHocConnection (new AdHocConnection(\"adHoc\"));\r\n    testAdHocConnection->setDisplayName(\"displayAd\");\r\n    testAdHocConnection->setDescription(\"describeAd\");\r\n    testAdHocConnection->setTiedValue(\"default\");\r\n    testAdHocConnection->setIsPresent(\"4-3\");\r\n    testAdHocConnection->getInternalPortReferences()->append(testInternalPortRef);\r\n    testAdHocConnection->getExternalPortReferences()->append(testExternalPortRef);\r\n    testAdHocConnection->getVendorExtensions()->append(testExtension);\r\n\r\n    testDesign->getAdHocConnections()->append(testAdHocConnection);\r\n\r\n    QString expectedOutput(\r\n        \"<?xml version=\\\"1.0\\\"?>\\n\"\r\n        \"<ipxact:design \"\r\n        \"xmlns:xsi=\\\"http://www.w3.org/2001/XMLSchema-instance\\\" \" \r\n        \"xmlns:ipxact=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014\\\" \"\r\n        \"xmlns:kactus2=\\\"http://kactus2.cs.tut.fi\\\" \"\r\n        \"xsi:schemaLocation=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014 \"\r\n        \"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/index.xsd\\\">\\n\"\r\n            \"\\t<ipxact:vendor>tuni.fi</ipxact:vendor>\\n\"\r\n            \"\\t<ipxact:library>TestLibrary</ipxact:library>\\n\"\r\n            \"\\t<ipxact:name>TestDesign</ipxact:name>\\n\"\r\n            \"\\t<ipxact:version>0.1</ipxact:version>\\n\"\r\n            \"\\t<ipxact:adHocConnections>\\n\"\r\n                \"\\t\\t<ipxact:adHocConnection>\\n\"\r\n                    \"\\t\\t\\t<ipxact:name>adHoc</ipxact:name>\\n\"\r\n                    \"\\t\\t\\t<ipxact:displayName>displayAd</ipxact:displayName>\\n\"\r\n                    \"\\t\\t\\t<ipxact:description>describeAd</ipxact:description>\\n\"\r\n                    \"\\t\\t\\t<ipxact:isPresent>4-3</ipxact:isPresent>\\n\"\r\n                    \"\\t\\t\\t<ipxact:tiedValue>default</ipxact:tiedValue>\\n\"\r\n                    \"\\t\\t\\t<ipxact:portReferences>\\n\"\r\n                        \"\\t\\t\\t\\t<ipxact:internalPortReference componentRef=\\\"componentInstance\\\"\"\r\n                                \" portRef=\\\"internalPort\\\">\\n\"\r\n                            \"\\t\\t\\t\\t\\t<ipxact:isPresent>1</ipxact:isPresent>\\n\"\r\n                            \"\\t\\t\\t\\t\\t<ipxact:partSelect>\\n\"\r\n                                \"\\t\\t\\t\\t\\t\\t<ipxact:range>\\n\"\r\n                                    \"\\t\\t\\t\\t\\t\\t\\t<ipxact:left>1</ipxact:left>\\n\"\r\n                                    \"\\t\\t\\t\\t\\t\\t\\t<ipxact:right>11</ipxact:right>\\n\"\r\n                                \"\\t\\t\\t\\t\\t\\t</ipxact:range>\\n\"\r\n                                \"\\t\\t\\t\\t\\t\\t<ipxact:indices>\\n\"\r\n                                    \"\\t\\t\\t\\t\\t\\t\\t<ipxact:index>8</ipxact:index>\\n\"\r\n                                    \"\\t\\t\\t\\t\\t\\t\\t<ipxact:index>4+4</ipxact:index>\\n\"\r\n                                \"\\t\\t\\t\\t\\t\\t</ipxact:indices>\\n\"\r\n                            \"\\t\\t\\t\\t\\t</ipxact:partSelect>\\n\"\r\n                        \"\\t\\t\\t\\t</ipxact:internalPortReference>\\n\"\r\n                        \"\\t\\t\\t\\t<ipxact:externalPortReference portRef=\\\"externalPort\\\">\\n\"\r\n                            \"\\t\\t\\t\\t\\t<ipxact:isPresent>0</ipxact:isPresent>\\n\"\r\n                            \"\\t\\t\\t\\t\\t<ipxact:partSelect>\\n\"\r\n                                \"\\t\\t\\t\\t\\t\\t<ipxact:range>\\n\"\r\n                                    \"\\t\\t\\t\\t\\t\\t\\t<ipxact:left>0</ipxact:left>\\n\"\r\n                                    \"\\t\\t\\t\\t\\t\\t\\t<ipxact:right>4</ipxact:right>\\n\"\r\n                                \"\\t\\t\\t\\t\\t\\t</ipxact:range>\\n\"\r\n                            \"\\t\\t\\t\\t\\t</ipxact:partSelect>\\n\"\r\n                        \"\\t\\t\\t\\t</ipxact:externalPortReference>\\n\"\r\n                    \"\\t\\t\\t</ipxact:portReferences>\\n\"\r\n                    \"\\t\\t\\t<ipxact:vendorExtensions>\\n\"\r\n                        \"\\t\\t\\t\\t<testExtension testExtensionAttribute=\\\"extension\\\">testValue</testExtension>\\n\"\r\n                    \"\\t\\t\\t</ipxact:vendorExtensions>\\n\"\r\n                \"\\t\\t</ipxact:adHocConnection>\\n\"\r\n            \"\\t</ipxact:adHocConnections>\\n\"\r\n        \"</ipxact:design>\\n\"\r\n        );\r\n\r\n    DesignWriter::writeDesign(xmlStreamWriter, testDesign);\r\n\r\n    compareOutputToExpected(output, expectedOutput);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_DesignWriter::testWriteAdHocConnections()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_DesignWriter::testWrite2022AdHocConnections()\r\n{\r\n    VLNV designVLNV(VLNV::DESIGN, \"tuni.fi\", \"TestLibrary\", \"TestDesign\", \"0.1\");\r\n    auto testDesign = QSharedPointer<Design>(new Design(designVLNV, Document::Revision::Std22));\r\n\r\n    QString output;\r\n    QXmlStreamWriter xmlStreamWriter(&output);\r\n\r\n    xmlStreamWriter.setAutoFormatting(true);\r\n    xmlStreamWriter.setAutoFormattingIndent(-1);\r\n\r\n    QDomDocument document;\r\n    QDomElement extensionNode = document.createElement(\"testExtension\");\r\n    extensionNode.setAttribute(\"testExtensionAttribute\", \"extension\");\r\n    extensionNode.appendChild(document.createTextNode(\"testValue\"));\r\n    QSharedPointer<GenericVendorExtension> testExtension(new GenericVendorExtension(extensionNode));\r\n\r\n    QSharedPointer<PartSelect> internalPartSelect (new PartSelect(\"1\", \"11\"));\r\n    internalPartSelect->getIndices()->append(\"8\");\r\n    internalPartSelect->getIndices()->append(\"4+4\");\r\n\r\n    QSharedPointer<PartSelect> externalPartSelect (new PartSelect(\"0\", \"4\"));\r\n\r\n    QSharedPointer<PortReference> testInternalPortRef (new PortReference(\"internalPort\", \"componentInstance\"));\r\n    testInternalPortRef->setPartSelect(internalPartSelect);\r\n\r\n    QSharedPointer<PortReference> testExternalPortRef (new PortReference(\"externalPort\"));\r\n    testExternalPortRef->setPartSelect(externalPartSelect);\r\n\r\n    QSharedPointer<AdHocConnection> testAdHocConnection(new AdHocConnection(\"adHoc\"));\r\n    testAdHocConnection->setDisplayName(\"displayAd\");\r\n    testAdHocConnection->setShortDescription(\"shortAd\");\r\n    testAdHocConnection->setDescription(\"describeAd\");\r\n    testAdHocConnection->setTiedValue(\"default\");\r\n    testAdHocConnection->getInternalPortReferences()->append(testInternalPortRef);\r\n    testAdHocConnection->getExternalPortReferences()->append(testExternalPortRef);\r\n    testAdHocConnection->getVendorExtensions()->append(testExtension);\r\n\r\n    testDesign->getAdHocConnections()->append(testAdHocConnection);\r\n\r\n    QString expectedOutput(\r\n        \"<?xml version=\\\"1.0\\\"?>\\n\"\r\n        \"<ipxact:design \"\r\n        \"xmlns:xsi=\\\"http://www.w3.org/2001/XMLSchema-instance\\\" \" \r\n        \"xmlns:ipxact=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2022\\\" \"\r\n        \"xmlns:kactus2=\\\"http://kactus2.cs.tut.fi\\\" \"\r\n        \"xsi:schemaLocation=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2022 \"\r\n        \"http://www.accellera.org/XMLSchema/IPXACT/1685-2022/index.xsd\\\">\\n\"\r\n            \"\\t<ipxact:vendor>tuni.fi</ipxact:vendor>\\n\"\r\n            \"\\t<ipxact:library>TestLibrary</ipxact:library>\\n\"\r\n            \"\\t<ipxact:name>TestDesign</ipxact:name>\\n\"\r\n            \"\\t<ipxact:version>0.1</ipxact:version>\\n\"\r\n            \"\\t<ipxact:adHocConnections>\\n\"\r\n                \"\\t\\t<ipxact:adHocConnection>\\n\"\r\n                    \"\\t\\t\\t<ipxact:name>adHoc</ipxact:name>\\n\"\r\n                    \"\\t\\t\\t<ipxact:displayName>displayAd</ipxact:displayName>\\n\"\r\n                    \"\\t\\t\\t<ipxact:shortDescription>shortAd</ipxact:shortDescription>\\n\"\r\n                    \"\\t\\t\\t<ipxact:description>describeAd</ipxact:description>\\n\"\r\n                    \"\\t\\t\\t<ipxact:tiedValue>default</ipxact:tiedValue>\\n\"\r\n                    \"\\t\\t\\t<ipxact:portReferences>\\n\"\r\n                        \"\\t\\t\\t\\t<ipxact:internalPortReference componentInstanceRef=\\\"componentInstance\\\"\"\r\n                                \" portRef=\\\"internalPort\\\">\\n\"\r\n                            \"\\t\\t\\t\\t\\t<ipxact:partSelect>\\n\"\r\n                                \"\\t\\t\\t\\t\\t\\t<ipxact:range>\\n\"\r\n                                    \"\\t\\t\\t\\t\\t\\t\\t<ipxact:left>1</ipxact:left>\\n\"\r\n                                    \"\\t\\t\\t\\t\\t\\t\\t<ipxact:right>11</ipxact:right>\\n\"\r\n                                \"\\t\\t\\t\\t\\t\\t</ipxact:range>\\n\"\r\n                                \"\\t\\t\\t\\t\\t\\t<ipxact:indices>\\n\"\r\n                                    \"\\t\\t\\t\\t\\t\\t\\t<ipxact:index>8</ipxact:index>\\n\"\r\n                                    \"\\t\\t\\t\\t\\t\\t\\t<ipxact:index>4+4</ipxact:index>\\n\"\r\n                                \"\\t\\t\\t\\t\\t\\t</ipxact:indices>\\n\"\r\n                            \"\\t\\t\\t\\t\\t</ipxact:partSelect>\\n\"\r\n                        \"\\t\\t\\t\\t</ipxact:internalPortReference>\\n\"\r\n                        \"\\t\\t\\t\\t<ipxact:externalPortReference portRef=\\\"externalPort\\\">\\n\"\r\n                            \"\\t\\t\\t\\t\\t<ipxact:partSelect>\\n\"\r\n                                \"\\t\\t\\t\\t\\t\\t<ipxact:range>\\n\"\r\n                                    \"\\t\\t\\t\\t\\t\\t\\t<ipxact:left>0</ipxact:left>\\n\"\r\n                                    \"\\t\\t\\t\\t\\t\\t\\t<ipxact:right>4</ipxact:right>\\n\"\r\n                                \"\\t\\t\\t\\t\\t\\t</ipxact:range>\\n\"\r\n                            \"\\t\\t\\t\\t\\t</ipxact:partSelect>\\n\"\r\n                        \"\\t\\t\\t\\t</ipxact:externalPortReference>\\n\"\r\n                    \"\\t\\t\\t</ipxact:portReferences>\\n\"\r\n                    \"\\t\\t\\t<ipxact:vendorExtensions>\\n\"\r\n                        \"\\t\\t\\t\\t<testExtension testExtensionAttribute=\\\"extension\\\">testValue</testExtension>\\n\"\r\n                    \"\\t\\t\\t</ipxact:vendorExtensions>\\n\"\r\n                \"\\t\\t</ipxact:adHocConnection>\\n\"\r\n            \"\\t</ipxact:adHocConnections>\\n\"\r\n        \"</ipxact:design>\\n\"\r\n        );\r\n\r\n    DesignWriter::writeDesign(xmlStreamWriter, testDesign);\r\n\r\n    compareOutputToExpected(output, expectedOutput);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_DesignWriter::testWrite2022SubPortReferences()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_DesignWriter::testWrite2022SubPortReferences()\r\n{\r\n    VLNV designVLNV(VLNV::DESIGN, \"tuni.fi\", \"TestLibrary\", \"TestDesign\", \"0.1\");\r\n    auto testDesign = QSharedPointer<Design>(new Design(designVLNV, Document::Revision::Std22));\r\n\r\n    QString output;\r\n    QXmlStreamWriter xmlStreamWriter(&output);\r\n\r\n    xmlStreamWriter.setAutoFormatting(true);\r\n    xmlStreamWriter.setAutoFormattingIndent(-1);\r\n\r\n    QDomDocument document;\r\n    QDomElement extensionNode = document.createElement(\"testExtension\");\r\n    extensionNode.setAttribute(\"testExtensionAttribute\", \"extension\");\r\n    extensionNode.appendChild(document.createTextNode(\"testValue\"));\r\n    QSharedPointer<GenericVendorExtension> testExtension(new GenericVendorExtension(extensionNode));\r\n\r\n    QSharedPointer<PartSelect> internalPartSelect (new PartSelect(\"1\", \"11\"));\r\n    internalPartSelect->getIndices()->append(\"8\");\r\n    internalPartSelect->getIndices()->append(\"4+4\");\r\n\r\n    QSharedPointer<PartSelect> externalPartSelect (new PartSelect(\"0\", \"4\"));\r\n\r\n    QSharedPointer<PortReference> testInternalPortRef (new PortReference(\"internalPort\", \"componentInstance\"));\r\n    testInternalPortRef->setPartSelect(internalPartSelect);\r\n\r\n    QSharedPointer<PortReference> subPortRef(new PortReference(\"subPort\"));\r\n    testInternalPortRef->getSubPortReferences()->append(subPortRef);\r\n\r\n    QSharedPointer<PortReference> complexSubPortRef(new PortReference(\"complexPort\"));\r\n\r\n    QSharedPointer<PartSelect> subPartSelect(new PartSelect(\"1\", \"0\"));\r\n    complexSubPortRef->setPartSelect(subPartSelect);\r\n    testInternalPortRef->getSubPortReferences()->append(complexSubPortRef);\r\n\r\n    QSharedPointer<PortReference> testExternalPortRef (new PortReference(\"externalPort\"));\r\n    testExternalPortRef->setPartSelect(externalPartSelect);\r\n\r\n    QSharedPointer<AdHocConnection> testAdHocConnection(new AdHocConnection(\"adHoc\"));\r\n\r\n    testAdHocConnection->getInternalPortReferences()->append(testInternalPortRef);\r\n    testAdHocConnection->getExternalPortReferences()->append(testExternalPortRef);\r\n    testAdHocConnection->getVendorExtensions()->append(testExtension);\r\n\r\n    testDesign->getAdHocConnections()->append(testAdHocConnection);\r\n\r\n    QString expectedOutput(\r\n        \"<?xml version=\\\"1.0\\\"?>\\n\"\r\n        \"<ipxact:design \"\r\n        \"xmlns:xsi=\\\"http://www.w3.org/2001/XMLSchema-instance\\\" \" \r\n        \"xmlns:ipxact=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2022\\\" \"\r\n        \"xmlns:kactus2=\\\"http://kactus2.cs.tut.fi\\\" \"\r\n        \"xsi:schemaLocation=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2022 \"\r\n        \"http://www.accellera.org/XMLSchema/IPXACT/1685-2022/index.xsd\\\">\\n\"\r\n            \"\\t<ipxact:vendor>tuni.fi</ipxact:vendor>\\n\"\r\n            \"\\t<ipxact:library>TestLibrary</ipxact:library>\\n\"\r\n            \"\\t<ipxact:name>TestDesign</ipxact:name>\\n\"\r\n            \"\\t<ipxact:version>0.1</ipxact:version>\\n\"\r\n            \"\\t<ipxact:adHocConnections>\\n\"\r\n                \"\\t\\t<ipxact:adHocConnection>\\n\"\r\n                    \"\\t\\t\\t<ipxact:name>adHoc</ipxact:name>\\n\"\r\n                    \"\\t\\t\\t<ipxact:portReferences>\\n\"\r\n                        \"\\t\\t\\t\\t<ipxact:internalPortReference componentInstanceRef=\\\"componentInstance\\\"\"\r\n                                \" portRef=\\\"internalPort\\\">\\n\"\r\n                            \"\\t\\t\\t\\t\\t<ipxact:subPortReference subPortRef=\\\"subPort\\\"/>\\n\"\r\n                            \"\\t\\t\\t\\t\\t<ipxact:subPortReference subPortRef=\\\"complexPort\\\">\\n\"\r\n                                \"\\t\\t\\t\\t\\t\\t<ipxact:partSelect>\\n\"\r\n                                \"\\t\\t\\t\\t\\t\\t\\t<ipxact:range>\\n\"\r\n                                    \"\\t\\t\\t\\t\\t\\t\\t\\t<ipxact:left>1</ipxact:left>\\n\"\r\n                                    \"\\t\\t\\t\\t\\t\\t\\t\\t<ipxact:right>0</ipxact:right>\\n\"\r\n                                \"\\t\\t\\t\\t\\t\\t\\t</ipxact:range>\\n\"\r\n                            \"\\t\\t\\t\\t\\t\\t</ipxact:partSelect>\\n\"\r\n                            \"\\t\\t\\t\\t\\t</ipxact:subPortReference>\\n\"\r\n                            \"\\t\\t\\t\\t\\t<ipxact:partSelect>\\n\"\r\n                                \"\\t\\t\\t\\t\\t\\t<ipxact:range>\\n\"\r\n                                    \"\\t\\t\\t\\t\\t\\t\\t<ipxact:left>1</ipxact:left>\\n\"\r\n                                    \"\\t\\t\\t\\t\\t\\t\\t<ipxact:right>11</ipxact:right>\\n\"\r\n                                \"\\t\\t\\t\\t\\t\\t</ipxact:range>\\n\"\r\n                                \"\\t\\t\\t\\t\\t\\t<ipxact:indices>\\n\"\r\n                                    \"\\t\\t\\t\\t\\t\\t\\t<ipxact:index>8</ipxact:index>\\n\"\r\n                                    \"\\t\\t\\t\\t\\t\\t\\t<ipxact:index>4+4</ipxact:index>\\n\"\r\n                                \"\\t\\t\\t\\t\\t\\t</ipxact:indices>\\n\"\r\n                            \"\\t\\t\\t\\t\\t</ipxact:partSelect>\\n\"\r\n                        \"\\t\\t\\t\\t</ipxact:internalPortReference>\\n\"\r\n                        \"\\t\\t\\t\\t<ipxact:externalPortReference portRef=\\\"externalPort\\\">\\n\"\r\n                            \"\\t\\t\\t\\t\\t<ipxact:partSelect>\\n\"\r\n                                \"\\t\\t\\t\\t\\t\\t<ipxact:range>\\n\"\r\n                                    \"\\t\\t\\t\\t\\t\\t\\t<ipxact:left>0</ipxact:left>\\n\"\r\n                                    \"\\t\\t\\t\\t\\t\\t\\t<ipxact:right>4</ipxact:right>\\n\"\r\n                                \"\\t\\t\\t\\t\\t\\t</ipxact:range>\\n\"\r\n                            \"\\t\\t\\t\\t\\t</ipxact:partSelect>\\n\"\r\n                        \"\\t\\t\\t\\t</ipxact:externalPortReference>\\n\"\r\n                    \"\\t\\t\\t</ipxact:portReferences>\\n\"\r\n                    \"\\t\\t\\t<ipxact:vendorExtensions>\\n\"\r\n                        \"\\t\\t\\t\\t<testExtension testExtensionAttribute=\\\"extension\\\">testValue</testExtension>\\n\"\r\n                    \"\\t\\t\\t</ipxact:vendorExtensions>\\n\"\r\n                \"\\t\\t</ipxact:adHocConnection>\\n\"\r\n            \"\\t</ipxact:adHocConnections>\\n\"\r\n        \"</ipxact:design>\\n\"\r\n        );\r\n\r\n    DesignWriter::writeDesign(xmlStreamWriter, testDesign);\r\n\r\n    compareOutputToExpected(output, expectedOutput);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_DesignWriter::testWriteAdHocConnectionExtensions()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_DesignWriter::testWriteAdHocConnectionExtensions()\r\n{\r\n    VLNV designVLNV(VLNV::DESIGN, \"tuni.fi\", \"TestLibrary\", \"TestDesign\", \"0.1\");\r\n    auto testDesign = QSharedPointer<Design>(new Design(designVLNV, Document::Revision::Std14));\r\n\r\n    QString output;\r\n    QXmlStreamWriter xmlStreamWriter(&output);\r\n\r\n    xmlStreamWriter.setAutoFormatting(true);\r\n    xmlStreamWriter.setAutoFormattingIndent(-1);\r\n\r\n    QSharedPointer<PortReference> testInternalPortRef (new PortReference(\"internalPort\", \"componentInstance\"));\r\n\r\n    QSharedPointer<PortReference> testExternalPortRef (new PortReference(\"externalPort\"));\r\n\r\n    QSharedPointer<AdHocConnection> testAdHocConnection (new AdHocConnection(\"adHoc\"));\r\n    testAdHocConnection->getInternalPortReferences()->append(testInternalPortRef);\r\n    testAdHocConnection->getExternalPortReferences()->append(testExternalPortRef);\r\n    testAdHocConnection->setOffPage(true);\r\n\r\n    QList<QPointF> adHocRoute;\r\n    adHocRoute.append(QPointF(1,1));\r\n    adHocRoute.append(QPointF(4,1));\r\n    adHocRoute.append(QPointF(4,2));\r\n    testAdHocConnection->setRoute(adHocRoute);\r\n\r\n    testDesign->getAdHocConnections()->append(testAdHocConnection);\r\n\r\n    QString expectedOutput(\r\n        \"<?xml version=\\\"1.0\\\"?>\\n\"\r\n        \"<ipxact:design \"\r\n        \"xmlns:xsi=\\\"http://www.w3.org/2001/XMLSchema-instance\\\" \" \r\n        \"xmlns:ipxact=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014\\\" \"\r\n        \"xmlns:kactus2=\\\"http://kactus2.cs.tut.fi\\\" \"\r\n        \"xsi:schemaLocation=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014 \"\r\n        \"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/index.xsd\\\">\\n\"\r\n            \"\\t<ipxact:vendor>tuni.fi</ipxact:vendor>\\n\"\r\n            \"\\t<ipxact:library>TestLibrary</ipxact:library>\\n\"\r\n            \"\\t<ipxact:name>TestDesign</ipxact:name>\\n\"\r\n            \"\\t<ipxact:version>0.1</ipxact:version>\\n\"\r\n            \"\\t<ipxact:adHocConnections>\\n\"\r\n                \"\\t\\t<ipxact:adHocConnection>\\n\"\r\n                    \"\\t\\t\\t<ipxact:name>adHoc</ipxact:name>\\n\"\r\n                    \"\\t\\t\\t<ipxact:portReferences>\\n\"\r\n                        \"\\t\\t\\t\\t<ipxact:internalPortReference componentRef=\\\"componentInstance\\\"\"\r\n                            \" portRef=\\\"internalPort\\\"/>\\n\"\r\n                        \"\\t\\t\\t\\t<ipxact:externalPortReference portRef=\\\"externalPort\\\"/>\\n\"\r\n                    \"\\t\\t\\t</ipxact:portReferences>\\n\"\r\n                    \"\\t\\t\\t<ipxact:vendorExtensions>\\n\"\r\n                        \"\\t\\t\\t\\t<kactus2:offPage/>\\n\"\r\n                        \"\\t\\t\\t\\t<kactus2:route>\\n\"\r\n                            \"\\t\\t\\t\\t\\t<kactus2:position x=\\\"1\\\" y=\\\"1\\\"/>\\n\"\r\n                            \"\\t\\t\\t\\t\\t<kactus2:position x=\\\"4\\\" y=\\\"1\\\"/>\\n\"\r\n                            \"\\t\\t\\t\\t\\t<kactus2:position x=\\\"4\\\" y=\\\"2\\\"/>\\n\"\r\n                        \"\\t\\t\\t\\t</kactus2:route>\\n\"\r\n                    \"\\t\\t\\t</ipxact:vendorExtensions>\\n\"\r\n                \"\\t\\t</ipxact:adHocConnection>\\n\"\r\n            \"\\t</ipxact:adHocConnections>\\n\"\r\n        \"</ipxact:design>\\n\"\r\n        );\r\n\r\n    DesignWriter::writeDesign(xmlStreamWriter, testDesign);\r\n\r\n    compareOutputToExpected(output, expectedOutput);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_DesignWriter::testWriteParameters()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_DesignWriter::testWriteParameters()\r\n{\r\n    VLNV designVLNV(VLNV::DESIGN, \"tuni.fi\", \"TestLibrary\", \"TestDesign\", \"0.1\");\r\n    auto testDesign = QSharedPointer<Design>(new Design(designVLNV, Document::Revision::Std14));\r\n\r\n    QSharedPointer<Parameter> testParameter(new Parameter());\r\n    testParameter->setValueId(\"testID\");\r\n    testParameter->setName(\"testParameter\");\r\n    testParameter->setValue(\"1\");\r\n\r\n    testDesign->getParameters()->append(testParameter);\r\n\r\n    QString output;\r\n    QXmlStreamWriter xmlStreamWriter(&output);\r\n\r\n    xmlStreamWriter.setAutoFormatting(true);\r\n    xmlStreamWriter.setAutoFormattingIndent(-1);\r\n\r\n    DesignWriter::writeDesign(xmlStreamWriter, testDesign);\r\n\r\n    QString expectedOutput(\r\n        \"<?xml version=\\\"1.0\\\"?>\\n\"\r\n        \"<ipxact:design \"\r\n            \"xmlns:xsi=\\\"http://www.w3.org/2001/XMLSchema-instance\\\" \" \r\n            \"xmlns:ipxact=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014\\\" \"\r\n            \"xmlns:kactus2=\\\"http://kactus2.cs.tut.fi\\\" \"\r\n            \"xsi:schemaLocation=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014 \"\r\n            \"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/index.xsd\\\">\\n\"\r\n            \"\\t<ipxact:vendor>tuni.fi</ipxact:vendor>\\n\"\r\n            \"\\t<ipxact:library>TestLibrary</ipxact:library>\\n\"\r\n            \"\\t<ipxact:name>TestDesign</ipxact:name>\\n\"\r\n            \"\\t<ipxact:version>0.1</ipxact:version>\\n\"\r\n            \"\\t<ipxact:parameters>\\n\"\r\n                \"\\t\\t<ipxact:parameter parameterId=\\\"testID\\\">\\n\"\r\n                \"\\t\\t\\t<ipxact:name>testParameter</ipxact:name>\\n\"\r\n                \"\\t\\t\\t<ipxact:value>1</ipxact:value>\\n\"\r\n                \"\\t\\t</ipxact:parameter>\\n\"\r\n            \"\\t</ipxact:parameters>\\n\"\r\n        \"</ipxact:design>\\n\"\r\n        );\r\n\r\n    compareOutputToExpected(output, expectedOutput);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_DesignWriter::testWriteAssertions()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_DesignWriter::testWriteAssertions()\r\n{\r\n    VLNV designVLNV(VLNV::DESIGN, \"tuni.fi\", \"TestLibrary\", \"TestDesign\", \"0.1\");\r\n    auto testDesign = QSharedPointer<Design>(new Design(designVLNV, Document::Revision::Std14));\r\n\r\n    QSharedPointer<Assertion> testAssertion(new Assertion());\r\n    testAssertion->setName(\"testAssertion\");\r\n    testAssertion->setDisplayName(\"assertionDisplay\");\r\n    testAssertion->setDescription(\"assertionDescription\");\r\n    testAssertion->setAssert(\"13\");\r\n\r\n    testDesign->getAssertions()->append(testAssertion);\r\n\r\n    QString output;\r\n    QXmlStreamWriter xmlStreamWriter(&output);\r\n\r\n    xmlStreamWriter.setAutoFormatting(true);\r\n    xmlStreamWriter.setAutoFormattingIndent(-1);\r\n\r\n    DesignWriter::writeDesign(xmlStreamWriter, testDesign);\r\n\r\n    QString expectedOutput(\r\n        \"<?xml version=\\\"1.0\\\"?>\\n\"\r\n        \"<ipxact:design \"\r\n            \"xmlns:xsi=\\\"http://www.w3.org/2001/XMLSchema-instance\\\" \" \r\n            \"xmlns:ipxact=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014\\\" \"\r\n            \"xmlns:kactus2=\\\"http://kactus2.cs.tut.fi\\\" \"\r\n            \"xsi:schemaLocation=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014 \"\r\n            \"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/index.xsd\\\">\\n\"\r\n            \"\\t<ipxact:vendor>tuni.fi</ipxact:vendor>\\n\"\r\n            \"\\t<ipxact:library>TestLibrary</ipxact:library>\\n\"\r\n            \"\\t<ipxact:name>TestDesign</ipxact:name>\\n\"\r\n            \"\\t<ipxact:version>0.1</ipxact:version>\\n\"\r\n            \"\\t<ipxact:assertions>\\n\"\r\n                \"\\t\\t<ipxact:assertion>\\n\"\r\n                    \"\\t\\t\\t<ipxact:name>testAssertion</ipxact:name>\\n\"\r\n                    \"\\t\\t\\t<ipxact:displayName>assertionDisplay</ipxact:displayName>\\n\"\r\n                    \"\\t\\t\\t<ipxact:description>assertionDescription</ipxact:description>\\n\"\r\n                    \"\\t\\t\\t<ipxact:assert>13</ipxact:assert>\\n\"\r\n                \"\\t\\t</ipxact:assertion>\\n\"\r\n            \"\\t</ipxact:assertions>\\n\"\r\n        \"</ipxact:design>\\n\"\r\n        );\r\n\r\n    compareOutputToExpected(output, expectedOutput);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_DesignWriter::testWriteVendorExtensions()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_DesignWriter::testWriteVendorExtensions()\r\n{\r\n    VLNV designVLNV(VLNV::DESIGN, \"tuni.fi\", \"TestLibrary\", \"TestDesign\", \"0.1\");\r\n    auto testDesign = QSharedPointer<Design>(new Design(designVLNV, Document::Revision::Std14));\r\n\r\n    QDomDocument document;\r\n    QDomElement extensionNode = document.createElement(\"testExtension\");\r\n    extensionNode.setAttribute(\"testExtensionAttribute\", \"extension\");\r\n    extensionNode.appendChild(document.createTextNode(\"testValue\"));\r\n\r\n    QSharedPointer<GenericVendorExtension> testExtension(new GenericVendorExtension(extensionNode));\r\n\r\n    testDesign->getVendorExtensions()->append(testExtension);\r\n    testDesign->setVersion(\"3.0.0\");\r\n\r\n    QString output;\r\n    QXmlStreamWriter xmlStreamWriter(&output);\r\n\r\n    xmlStreamWriter.setAutoFormatting(true);\r\n    xmlStreamWriter.setAutoFormattingIndent(-1);\r\n\r\n    DesignWriter::writeDesign(xmlStreamWriter, testDesign);\r\n\r\n    QString expectedOutput(\r\n        \"<?xml version=\\\"1.0\\\"?>\\n\"\r\n        \"<ipxact:design \"\r\n            \"xmlns:xsi=\\\"http://www.w3.org/2001/XMLSchema-instance\\\" \" \r\n            \"xmlns:ipxact=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014\\\" \"\r\n            \"xmlns:kactus2=\\\"http://kactus2.cs.tut.fi\\\" \"\r\n            \"xsi:schemaLocation=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014 \"\r\n            \"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/index.xsd\\\">\\n\"\r\n            \"\\t<ipxact:vendor>tuni.fi</ipxact:vendor>\\n\"\r\n            \"\\t<ipxact:library>TestLibrary</ipxact:library>\\n\"\r\n            \"\\t<ipxact:name>TestDesign</ipxact:name>\\n\"\r\n            \"\\t<ipxact:version>0.1</ipxact:version>\\n\"\r\n            \"\\t<ipxact:vendorExtensions>\\n\"\r\n                \"\\t\\t<testExtension testExtensionAttribute=\\\"extension\\\">testValue</testExtension>\\n\"\r\n                \"\\t\\t<kactus2:version>3.0.0</kactus2:version>\\n\"\r\n            \"\\t</ipxact:vendorExtensions>\\n\"\r\n        \"</ipxact:design>\\n\"\r\n        );\r\n\r\n    compareOutputToExpected(output, expectedOutput);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_DesignWriter::testWriteColumns()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_DesignWriter::testWriteColumns()\r\n{\r\n    VLNV designVLNV(VLNV::DESIGN, \"tuni.fi\", \"TestLibrary\", \"TestDesign\", \"0.1\");\r\n    auto testDesign = QSharedPointer<Design>(new Design(designVLNV, Document::Revision::Std14));\r\n\r\n    QSharedPointer<ColumnDesc> testColumn (new ColumnDesc(\"testColumn\", ColumnTypes::COMPONENTS));\r\n    QSharedPointer<ColumnDesc> otherColumn (new ColumnDesc(\"otherColumn\", ColumnTypes::BUSES));\r\n\r\n    QSharedPointer<Kactus2Group> columnLayout(new Kactus2Group(\"kactus2:columnLayout\"));\r\n    columnLayout->addToGroup(testColumn);\r\n    columnLayout->addToGroup(otherColumn);\r\n\r\n    testDesign->getVendorExtensions()->append(columnLayout);\r\n\r\n    QString output;\r\n    QXmlStreamWriter xmlStreamWriter(&output);\r\n\r\n    xmlStreamWriter.setAutoFormatting(true);\r\n    xmlStreamWriter.setAutoFormattingIndent(-1);\r\n\r\n    DesignWriter::writeDesign(xmlStreamWriter, testDesign);\r\n\r\n    QString expectedOutput(\r\n        \"<?xml version=\\\"1.0\\\"?>\\n\"\r\n        \"<ipxact:design \"\r\n        \"xmlns:xsi=\\\"http://www.w3.org/2001/XMLSchema-instance\\\" \" \r\n        \"xmlns:ipxact=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014\\\" \"\r\n        \"xmlns:kactus2=\\\"http://kactus2.cs.tut.fi\\\" \"\r\n        \"xsi:schemaLocation=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014 \"\r\n        \"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/index.xsd\\\">\\n\"\r\n            \"\\t<ipxact:vendor>tuni.fi</ipxact:vendor>\\n\"\r\n            \"\\t<ipxact:library>TestLibrary</ipxact:library>\\n\"\r\n            \"\\t<ipxact:name>TestDesign</ipxact:name>\\n\"\r\n            \"\\t<ipxact:version>0.1</ipxact:version>\\n\"\r\n            \"\\t<ipxact:vendorExtensions>\\n\"\r\n                \"\\t\\t<kactus2:columnLayout>\\n\"\r\n                    \"\\t\\t\\t<kactus2:column name=\\\"testColumn\\\" contentType=\\\"2\\\" allowedItems=\\\"0\\\" \"\r\n                        \"minWidth=\\\"259\\\" width=\\\"259\\\" x=\\\"0\\\"/>\\n\"\r\n                    \"\\t\\t\\t<kactus2:column name=\\\"otherColumn\\\" contentType=\\\"1\\\" allowedItems=\\\"0\\\" \"\r\n                        \"minWidth=\\\"259\\\" width=\\\"259\\\" x=\\\"0\\\"/>\\n\"\r\n                \"\\t\\t</kactus2:columnLayout>\\n\"\r\n            \"\\t</ipxact:vendorExtensions>\\n\"\r\n        \"</ipxact:design>\\n\"\r\n        );\r\n\r\n    compareOutputToExpected(output, expectedOutput);\r\n\r\n    output.clear();\r\n\r\n    testDesign->removeColumn(otherColumn);\r\n\r\n    DesignWriter::writeDesign(xmlStreamWriter, testDesign);\r\n\r\n    expectedOutput =\r\n        \"<?xml version=\\\"1.0\\\"?>\\n\"\r\n        \"<ipxact:design \"\r\n        \"xmlns:xsi=\\\"http://www.w3.org/2001/XMLSchema-instance\\\" \" \r\n        \"xmlns:ipxact=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014\\\" \"\r\n        \"xmlns:kactus2=\\\"http://kactus2.cs.tut.fi\\\" \"\r\n        \"xsi:schemaLocation=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014 \"\r\n        \"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/index.xsd\\\">\\n\"\r\n            \"\\t<ipxact:vendor>tuni.fi</ipxact:vendor>\\n\"\r\n            \"\\t<ipxact:library>TestLibrary</ipxact:library>\\n\"\r\n            \"\\t<ipxact:name>TestDesign</ipxact:name>\\n\"\r\n            \"\\t<ipxact:version>0.1</ipxact:version>\\n\"\r\n            \"\\t<ipxact:vendorExtensions>\\n\"\r\n                \"\\t\\t<kactus2:columnLayout>\\n\"\r\n                    \"\\t\\t\\t<kactus2:column name=\\\"testColumn\\\" contentType=\\\"2\\\" allowedItems=\\\"0\\\" \"\r\n                        \"minWidth=\\\"259\\\" width=\\\"259\\\" x=\\\"0\\\"/>\\n\"\r\n                \"\\t\\t</kactus2:columnLayout>\\n\"\r\n            \"\\t</ipxact:vendorExtensions>\\n\"\r\n        \"</ipxact:design>\\n\"\r\n        ;\r\n\r\n    compareOutputToExpected(output, expectedOutput);\r\n\r\n    output.clear();\r\n\r\n    QSharedPointer<Design> otherDesign (new Design(*testDesign));\r\n\r\n    DesignWriter::writeDesign(xmlStreamWriter, otherDesign);\r\n    compareOutputToExpected(output, expectedOutput);\r\n\r\n    output.clear();\r\n    QSharedPointer<Design> newDesign (new Design(VLNV(), Document::Revision::Std14));\r\n    newDesign = otherDesign;\r\n\r\n    DesignWriter::writeDesign(xmlStreamWriter, otherDesign);\r\n    compareOutputToExpected(output, expectedOutput);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_DesignWriter::testWritePortAdHocVisibilitiesAndPositions()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_DesignWriter::testWritePortAdHocVisibilitiesAndPositions()\r\n{\r\n    VLNV designVLNV(VLNV::DESIGN, \"tuni.fi\", \"TestLibrary\", \"TestDesign\", \"0.1\");\r\n    auto testDesign = QSharedPointer<Design>(new Design(designVLNV, Document::Revision::Std14));\r\n\r\n    QPointF portPosition;\r\n    portPosition.setX(4);\r\n    portPosition.setY(25);\r\n\r\n    QMap<QString, QPointF> adHocPositions;\r\n    adHocPositions.insert(\"testPort\", portPosition);\r\n    testDesign->setAdHocPortPositions(adHocPositions);\r\n\r\n    QString output;\r\n    QXmlStreamWriter xmlStreamWriter(&output);\r\n\r\n    xmlStreamWriter.setAutoFormatting(true);\r\n    xmlStreamWriter.setAutoFormattingIndent(-1);\r\n\r\n    DesignWriter::writeDesign(xmlStreamWriter, testDesign);\r\n\r\n    QString expectedOutput(\r\n        \"<?xml version=\\\"1.0\\\"?>\\n\"\r\n        \"<ipxact:design \"\r\n        \"xmlns:xsi=\\\"http://www.w3.org/2001/XMLSchema-instance\\\" \" \r\n        \"xmlns:ipxact=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014\\\" \"\r\n        \"xmlns:kactus2=\\\"http://kactus2.cs.tut.fi\\\" \"\r\n        \"xsi:schemaLocation=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014 \"\r\n        \"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/index.xsd\\\">\\n\"\r\n            \"\\t<ipxact:vendor>tuni.fi</ipxact:vendor>\\n\"\r\n            \"\\t<ipxact:library>TestLibrary</ipxact:library>\\n\"\r\n            \"\\t<ipxact:name>TestDesign</ipxact:name>\\n\"\r\n            \"\\t<ipxact:version>0.1</ipxact:version>\\n\"\r\n            \"\\t<ipxact:vendorExtensions>\\n\"\r\n                \"\\t\\t<kactus2:adHocVisibilities>\\n\"\r\n                    \"\\t\\t\\t<kactus2:adHocVisible portName=\\\"testPort\\\" x=\\\"4\\\" y=\\\"25\\\"/>\\n\"\r\n                \"\\t\\t</kactus2:adHocVisibilities>\\n\"\r\n            \"\\t</ipxact:vendorExtensions>\\n\"\r\n        \"</ipxact:design>\\n\"\r\n        );\r\n\r\n    compareOutputToExpected(output, expectedOutput);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_DesignWriter::testWriteApiDependencies()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_DesignWriter::testWriteApiDependencies()\r\n{\r\n    VLNV designVLNV(VLNV::DESIGN, \"tuni.fi\", \"TestLibrary\", \"TestDesign\", \"0.1\");\r\n    auto testDesign = QSharedPointer<Design>(new Design(designVLNV, Document::Revision::Std14));\r\n\r\n    QSharedPointer<ActiveInterface> testStartInterface(new ActiveInterface(\"applicationOne\", \"busOne\"));\r\n    QSharedPointer<ActiveInterface> testEndInterface(new ActiveInterface(\"applicationTwo\", \"busTwo\"));\r\n\r\n    QPointF pointOne;\r\n    pointOne.setX(1);\r\n    pointOne.setY(1);\r\n    QList<QPointF> points;\r\n    points.append(pointOne);\r\n\r\n    QSharedPointer<ApiInterconnection> testApiConnection(new ApiInterconnection(\"apiConnect\", \"connection\",\r\n        \"described\", testStartInterface, testEndInterface));\r\n    \r\n    QList<QSharedPointer<ApiInterconnection> > apiConnections;\r\n    apiConnections.append(testApiConnection);\r\n\r\n    testDesign->setApiConnections(apiConnections);\r\n\r\n    QString output;\r\n    QXmlStreamWriter xmlStreamWriter(&output);\r\n\r\n    xmlStreamWriter.setAutoFormatting(true);\r\n    xmlStreamWriter.setAutoFormattingIndent(-1);\r\n\r\n    DesignWriter::writeDesign(xmlStreamWriter, testDesign);\r\n\r\n    QString expectedOutput(\r\n        \"<?xml version=\\\"1.0\\\"?>\\n\"\r\n        \"<ipxact:design \"\r\n        \"xmlns:xsi=\\\"http://www.w3.org/2001/XMLSchema-instance\\\" \" \r\n        \"xmlns:ipxact=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014\\\" \"\r\n        \"xmlns:kactus2=\\\"http://kactus2.cs.tut.fi\\\" \"\r\n        \"xsi:schemaLocation=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014 \"\r\n        \"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/index.xsd\\\">\\n\"\r\n            \"\\t<ipxact:vendor>tuni.fi</ipxact:vendor>\\n\"\r\n            \"\\t<ipxact:library>TestLibrary</ipxact:library>\\n\"\r\n            \"\\t<ipxact:name>TestDesign</ipxact:name>\\n\"\r\n            \"\\t<ipxact:version>0.1</ipxact:version>\\n\"\r\n            \"\\t<ipxact:vendorExtensions>\\n\"\r\n                \"\\t\\t<kactus2:apiConnections>\\n\"\r\n                    \"\\t\\t\\t<kactus2:apiConnection>\\n\"\r\n                        \"\\t\\t\\t\\t<ipxact:name>apiConnect</ipxact:name>\\n\"\r\n                        \"\\t\\t\\t\\t<ipxact:displayName>connection</ipxact:displayName>\\n\"\r\n                        \"\\t\\t\\t\\t<ipxact:description>described</ipxact:description>\\n\"\r\n                        \"\\t\\t\\t\\t<kactus2:activeApiInterface componentRef=\\\"applicationOne\\\" apiRef=\\\"busOne\\\"/>\\n\"\r\n                        \"\\t\\t\\t\\t<kactus2:activeApiInterface componentRef=\\\"applicationTwo\\\" apiRef=\\\"busTwo\\\"/>\\n\"\r\n                        /*\"\\t\\t\\t\\t<kactus2:route offPage=\\\"false\\\">\\n\"\r\n                            \"\\t\\t\\t\\t\\t<kactus2:position x=\\\"1\\\" y=\\\"1\\\"/>\\n\"\r\n                        \"\\t\\t\\t\\t</kactus2:route>\\n\"*/\r\n                    \"\\t\\t\\t</kactus2:apiConnection>\\n\"\r\n                \"\\t\\t</kactus2:apiConnections>\\n\"\r\n            \"\\t</ipxact:vendorExtensions>\\n\"\r\n        \"</ipxact:design>\\n\"\r\n        );\r\n\r\n    compareOutputToExpected(output, expectedOutput);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_DesignWriter::testWriteHierApiDependencies()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_DesignWriter::testWriteHierApiDependencies()\r\n{\r\n    VLNV designVLNV(VLNV::DESIGN, \"tuni.fi\", \"TestLibrary\", \"TestDesign\", \"0.1\");\r\n    auto testDesign = QSharedPointer<Design>(new Design(designVLNV, Document::Revision::Std14));\r\n\r\n    QSharedPointer<ActiveInterface> testInterface(new ActiveInterface(\"applicationOne\", \"busOne\"));\r\n\r\n    QSharedPointer<HierInterface> topInterface(new HierInterface(\"topInterface\"));\r\n    \r\n    QSharedPointer<ApiInterconnection> testHierApi(new ApiInterconnection(\"hierApi\", \"display\", \"description\", \r\n        topInterface, testInterface));\r\n    \r\n    QList<QSharedPointer<ApiInterconnection> > hierApiList;\r\n    hierApiList.append(testHierApi);\r\n\r\n    testDesign->setApiConnections(hierApiList);\r\n\r\n    QString output;\r\n    QXmlStreamWriter xmlStreamWriter(&output);\r\n\r\n    xmlStreamWriter.setAutoFormatting(true);\r\n    xmlStreamWriter.setAutoFormattingIndent(-1);\r\n\r\n    DesignWriter::writeDesign(xmlStreamWriter, testDesign);\r\n\r\n    QString expectedOutput(\r\n        \"<?xml version=\\\"1.0\\\"?>\\n\"\r\n        \"<ipxact:design \"\r\n        \"xmlns:xsi=\\\"http://www.w3.org/2001/XMLSchema-instance\\\" \" \r\n        \"xmlns:ipxact=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014\\\" \"\r\n        \"xmlns:kactus2=\\\"http://kactus2.cs.tut.fi\\\" \"\r\n        \"xsi:schemaLocation=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014 \"\r\n        \"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/index.xsd\\\">\\n\"\r\n            \"\\t<ipxact:vendor>tuni.fi</ipxact:vendor>\\n\"\r\n            \"\\t<ipxact:library>TestLibrary</ipxact:library>\\n\"\r\n            \"\\t<ipxact:name>TestDesign</ipxact:name>\\n\"\r\n            \"\\t<ipxact:version>0.1</ipxact:version>\\n\"\r\n            \"\\t<ipxact:vendorExtensions>\\n\"\r\n                \"\\t\\t<kactus2:apiConnections>\\n\"\r\n                    \"\\t\\t\\t<kactus2:apiConnection>\\n\"\r\n                        \"\\t\\t\\t\\t<ipxact:name>hierApi</ipxact:name>\\n\"\r\n                        \"\\t\\t\\t\\t<ipxact:displayName>display</ipxact:displayName>\\n\"\r\n                        \"\\t\\t\\t\\t<ipxact:description>description</ipxact:description>\\n\"\r\n                        \"\\t\\t\\t\\t<kactus2:activeApiInterface componentRef=\\\"applicationOne\\\" apiRef=\\\"busOne\\\"/>\\n\"\r\n                        \"\\t\\t\\t\\t<kactus2:hierApiInterface apiRef=\\\"topInterface\\\"/>\\n\"\r\n                    \"\\t\\t\\t</kactus2:apiConnection>\\n\"\r\n                \"\\t\\t</kactus2:apiConnections>\\n\"\r\n            \"\\t</ipxact:vendorExtensions>\\n\"\r\n        \"</ipxact:design>\\n\"\r\n        );\r\n\r\n    compareOutputToExpected(output, expectedOutput);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_DesignWriter::testWriteComConnections()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_DesignWriter::testWriteComConnections()\r\n{\r\n    VLNV designVLNV(VLNV::DESIGN, \"tuni.fi\", \"TestLibrary\", \"TestDesign\", \"0.1\");\r\n    auto testDesign = QSharedPointer<Design>(new Design(designVLNV, Document::Revision::Std14));\r\n\r\n    QSharedPointer<ActiveInterface> testStartInterface(new ActiveInterface(\"applicationOne\", \"busOne\"));\r\n    QSharedPointer<ActiveInterface> testEndInterface(new ActiveInterface(\"applicationTwo\", \"busTwo\"));\r\n\r\n    QSharedPointer<ComInterconnection> testComConnection(new ComInterconnection(\"comConnect\", \"display\",\r\n        \"description\", testStartInterface, testEndInterface));\r\n\r\n    QList<QSharedPointer<ComInterconnection> > comConnectionList;\r\n    comConnectionList.append(testComConnection);\r\n\r\n    testDesign->setComConnections(comConnectionList);\r\n\r\n    QString output;\r\n    QXmlStreamWriter xmlStreamWriter(&output);\r\n\r\n    xmlStreamWriter.setAutoFormatting(true);\r\n    xmlStreamWriter.setAutoFormattingIndent(-1);\r\n\r\n    DesignWriter::writeDesign(xmlStreamWriter, testDesign);\r\n\r\n    QString expectedOutput(\r\n        \"<?xml version=\\\"1.0\\\"?>\\n\"\r\n        \"<ipxact:design \"\r\n        \"xmlns:xsi=\\\"http://www.w3.org/2001/XMLSchema-instance\\\" \" \r\n        \"xmlns:ipxact=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014\\\" \"\r\n        \"xmlns:kactus2=\\\"http://kactus2.cs.tut.fi\\\" \"\r\n        \"xsi:schemaLocation=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014 \"\r\n        \"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/index.xsd\\\">\\n\"\r\n            \"\\t<ipxact:vendor>tuni.fi</ipxact:vendor>\\n\"\r\n            \"\\t<ipxact:library>TestLibrary</ipxact:library>\\n\"\r\n            \"\\t<ipxact:name>TestDesign</ipxact:name>\\n\"\r\n            \"\\t<ipxact:version>0.1</ipxact:version>\\n\"\r\n            \"\\t<ipxact:vendorExtensions>\\n\"\r\n                \"\\t\\t<kactus2:comConnections>\\n\"\r\n                    \"\\t\\t\\t<kactus2:comConnection>\\n\"\r\n                        \"\\t\\t\\t\\t<ipxact:name>comConnect</ipxact:name>\\n\"\r\n                        \"\\t\\t\\t\\t<ipxact:displayName>display</ipxact:displayName>\\n\"\r\n                        \"\\t\\t\\t\\t<ipxact:description>description</ipxact:description>\\n\"\r\n                        \"\\t\\t\\t\\t<kactus2:activeComInterface componentRef=\\\"applicationOne\\\" comRef=\\\"busOne\\\"/>\\n\"\r\n                        \"\\t\\t\\t\\t<kactus2:activeComInterface componentRef=\\\"applicationTwo\\\" comRef=\\\"busTwo\\\"/>\\n\"\r\n                    \"\\t\\t\\t</kactus2:comConnection>\\n\"\r\n                \"\\t\\t</kactus2:comConnections>\\n\"\r\n            \"\\t</ipxact:vendorExtensions>\\n\"\r\n        \"</ipxact:design>\"\r\n        );\r\n\r\n    compareOutputToExpected(output, expectedOutput);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_DesignWriter::testWriteHierComConnections()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_DesignWriter::testWriteHierComConnections()\r\n{\r\n    VLNV designVLNV(VLNV::DESIGN, \"tuni.fi\", \"TestLibrary\", \"TestDesign\", \"0.1\");\r\n    auto testDesign = QSharedPointer<Design>(new Design(designVLNV, Document::Revision::Std14));\r\n\r\n    QSharedPointer<ActiveInterface> testInterface(new ActiveInterface(\"applicationOne\", \"busOne\"));\r\n\r\n    QSharedPointer<HierInterface> topInterface(new HierInterface(\"topInterface\"));\r\n\r\n    QSharedPointer<ComInterconnection> testHierComConnection(new ComInterconnection(\"hierComConnection\",\r\n        \"display\", \"description\", topInterface, testInterface));\r\n\r\n    QList<QSharedPointer<ComInterconnection> > hierComList;\r\n    hierComList.append(testHierComConnection);\r\n\r\n    testDesign->setComConnections(hierComList);\r\n\r\n    QString output;\r\n    QXmlStreamWriter xmlStreamWriter(&output);\r\n\r\n    xmlStreamWriter.setAutoFormatting(true);\r\n    xmlStreamWriter.setAutoFormattingIndent(-1);\r\n\r\n    DesignWriter::writeDesign(xmlStreamWriter, testDesign);\r\n\r\n    QString expectedOutput(\r\n        \"<?xml version=\\\"1.0\\\"?>\\n\"\r\n        \"<ipxact:design \"\r\n        \"xmlns:xsi=\\\"http://www.w3.org/2001/XMLSchema-instance\\\" \" \r\n        \"xmlns:ipxact=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014\\\" \"\r\n        \"xmlns:kactus2=\\\"http://kactus2.cs.tut.fi\\\" \"\r\n        \"xsi:schemaLocation=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014 \"\r\n        \"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/index.xsd\\\">\\n\"\r\n            \"\\t<ipxact:vendor>tuni.fi</ipxact:vendor>\\n\"\r\n            \"\\t<ipxact:library>TestLibrary</ipxact:library>\\n\"\r\n            \"\\t<ipxact:name>TestDesign</ipxact:name>\\n\"\r\n            \"\\t<ipxact:version>0.1</ipxact:version>\\n\"\r\n            \"\\t<ipxact:vendorExtensions>\\n\"\r\n                \"\\t\\t<kactus2:comConnections>\\n\"\r\n                    \"\\t\\t\\t<kactus2:comConnection>\\n\"\r\n                        \"\\t\\t\\t\\t<ipxact:name>hierComConnection</ipxact:name>\\n\"\r\n                        \"\\t\\t\\t\\t<ipxact:displayName>display</ipxact:displayName>\\n\"\r\n                        \"\\t\\t\\t\\t<ipxact:description>description</ipxact:description>\\n\"\r\n                        \"\\t\\t\\t\\t<kactus2:activeComInterface componentRef=\\\"applicationOne\\\" comRef=\\\"busOne\\\"/>\\n\"\r\n                        \"\\t\\t\\t\\t<kactus2:hierComInterface comRef=\\\"topInterface\\\"/>\\n\"\r\n                    \"\\t\\t\\t</kactus2:comConnection>\\n\"\r\n                \"\\t\\t</kactus2:comConnections>\\n\"\r\n            \"\\t</ipxact:vendorExtensions>\\n\"\r\n        \"</ipxact:design>\\n\"\r\n        );\r\n\r\n    compareOutputToExpected(output, expectedOutput);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_DesignWriter::compareOutputToExpected()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_DesignWriter::compareOutputToExpected(QString const& output, QString const& expectedOutput)\r\n{\r\n    VLNV designVLNV(VLNV::DESIGN, \"tuni.fi\", \"TestLibrary\", \"TestDesign\", \"0.1\");\r\n    auto testDesign = QSharedPointer<Design>(new Design(designVLNV, Document::Revision::Std14));\r\n\r\n    if (!output.contains(expectedOutput))\r\n    {\r\n        QStringList outputLines = output.split(\"\\n\");\r\n        QStringList expectedLines = expectedOutput.split(\"\\n\");\r\n\r\n        QVERIFY(outputLines.count() >= expectedLines.count());\r\n\r\n        int lineOffset = outputLines.indexOf(expectedLines.first());\r\n        if (lineOffset == -1)\r\n        {\r\n            QCOMPARE(output, expectedOutput);\r\n        }\r\n        else\r\n        {\r\n            int lineCount = expectedLines.count();\r\n            for (int i = 0; i < lineCount; ++i)\r\n            {\r\n                QCOMPARE(outputLines.at(i + lineOffset), expectedLines.at(i));\r\n            }\r\n        }\r\n    }\r\n    else if (output.count(expectedOutput) != 1)\r\n    {\r\n        QVERIFY2(false, QString(expectedOutput + \" was found \" + QString::number(output.count(expectedOutput)) +\r\n            \" times in output.\").toLocal8Bit());\r\n    }\r\n}\r\n\r\nQTEST_APPLESS_MAIN(tst_DesignWriter)\r\n\r\n#include \"tst_DesignWriter.moc\"\r\n"
  },
  {
    "path": "tests/IPXACTmodels/Design/tst_DesignWriter.pri",
    "content": "# ----------------------------------------------------\r\n# This file is generated by the Qt Visual Studio Tools.\r\n# ------------------------------------------------------\r\n\r\nSOURCES += ./tst_DesignWriter.cpp \r\n"
  },
  {
    "path": "tests/IPXACTmodels/Design/tst_DesignWriter.pro",
    "content": "#-----------------------------------------------------------------------------\r\n# File: tst_DesignWriter.pro\r\n#-----------------------------------------------------------------------------\r\n# Project: Kactus 2\r\n# Author: Esko Pekkarinen\r\n# Date: 24.7.2014\r\n#\r\n# Description:\r\n# Qt project file for running unit tests for design writer.\r\n#-----------------------------------------------------------------------------\r\n\r\nTEMPLATE = app\r\n\r\nTARGET = tst_DesignWriter\r\n\r\nQT += core gui xml testlib\r\n\r\nCONFIG += c++11 testcase console\r\n\r\nlinux-g++ | linux-g++-64 | linux-g++-32 {\r\n LIBS += -L../../../executable \\\r\n     -lIPXACTmodels\r\n\r\n}\r\nwin64 | win32 {\r\n LIBS += -L../../../executable \\\r\n     -lIPXACTmodelsd\r\n}\r\n\r\nDESTDIR = ./release\r\n\r\nINCLUDEPATH += $$DESTDIR\r\nINCLUDEPATH += ../../../\r\n\r\nDEPENDPATH += .\r\nDEPENDPATH += ../../../\r\n\r\nOBJECTS_DIR += $$DESTDIR\r\n\r\nMOC_DIR += ./generatedFiles\r\nUI_DIR += ./generatedFiles\r\nRCC_DIR += ./generatedFiles\r\ninclude(tst_DesignWriter.pri)\r\n"
  },
  {
    "path": "tests/IPXACTmodels/DesignConfiguration/DesignConfiguration.pro",
    "content": "#-----------------------------------------------------------------------------\n# File: BusDefinition.pro\n#-----------------------------------------------------------------------------\n# Project: Kactus2\n# Author: Esko Pekkarinen\n# Date: 04.05.2018\n#\n# Description:\n# Qt project file template for running unit tests for Design Configuration.\n#-----------------------------------------------------------------------------\n\nTEMPLATE = subdirs\n\nCONFIG += testcase\nSUBDIRS += tst_DesignConfigurationReader.pro \\\n\t       tst_DesignConfigurationWriter.pro \\\n\t\t   tst_DesignConfigurationValidator.pro\n"
  },
  {
    "path": "tests/IPXACTmodels/DesignConfiguration/tst_DesignConfigurationReader.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: tst_DesignConfigurationReader.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 11.08.2015\r\n//\r\n// Description:\r\n// Unit test for class DesignConfigurationReader.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include <IPXACTmodels/DesignConfiguration/DesignConfigurationReader.h>\r\n\r\n#include <QtTest>\r\n#include <QDomNode>\r\n\r\nclass tst_DesignConfigurationReader : public QObject\r\n{\r\n    Q_OBJECT\r\n\r\npublic:\r\n    tst_DesignConfigurationReader();\r\n\r\nprivate slots:\r\n\r\n    void testReadSimpleDesignConfiguration();\r\n    void testRead2022DesignConfiguration();\r\n\r\n    void testReadTopComments();\r\n    void testProcessingInstructionsAreParsed();\r\n\r\n    void testReadDesignReference();\r\n    void testReadGeneratorChainConfigurations();\r\n\r\n    void testReadInterconnectionConfigurations();\r\n    void testRead2022InterconnectionConfigurations();\r\n\r\n    void testReadViewConfigurations();\r\n    void testRead2022ViewConfigurations();\r\n    \r\n    void testReadParameters();\r\n    void testReadAssertions();\r\n    void testReadVendorExtensions();\r\n\r\n    void testReadViewOverrides();\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_DesignConfigurationReader::tst_DesignConfigurationReader()\r\n//-----------------------------------------------------------------------------\r\ntst_DesignConfigurationReader::tst_DesignConfigurationReader()\r\n{\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_DesignConfigurationReader::readSimpleDesignConfiguration()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_DesignConfigurationReader::testReadSimpleDesignConfiguration()\r\n{\r\n    QString documentContent(\r\n        \"<ipxact:designConfiguration xmlns:xsi=\\\"http://www.w3.org/2001/XMLSchema-instance\\\" \" \r\n        \"xmlns:ipxact=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014\\\" \"\r\n        \"xmlns:kactus2=\\\"http://kactus2.cs.tut.fi\\\" \"\r\n        \"xsi:schemaLocation=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/ \"\r\n        \"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/index.xsd\\\">\"\r\n            \"<ipxact:vendor>tuni.fi</ipxact:vendor>\"\r\n            \"<ipxact:library>TestLibrary</ipxact:library>\"\r\n            \"<ipxact:name>TestDesignConfiguration</ipxact:name>\"\r\n            \"<ipxact:version>0.1</ipxact:version>\"\r\n            \"<ipxact:description>TestDescription</ipxact:description>\"\r\n        \"</ipxact:designConfiguration>\");\r\n\r\n    QDomDocument document;\r\n    document.setContent(documentContent);\r\n\r\n    QSharedPointer<DesignConfiguration> testDesignConfiguration =\r\n        DesignConfigurationReader::createDesignConfigurationFrom(document);\r\n\r\n    QCOMPARE(testDesignConfiguration->getRevision(), Document::Revision::Std14);\r\n    QCOMPARE(testDesignConfiguration->getVlnv().getVendor(), QString(\"tuni.fi\"));\r\n    QCOMPARE(testDesignConfiguration->getVlnv().getLibrary(), QString(\"TestLibrary\"));\r\n    QCOMPARE(testDesignConfiguration->getVlnv().getName(), QString(\"TestDesignConfiguration\"));\r\n    QCOMPARE(testDesignConfiguration->getVlnv().getVersion(), QString(\"0.1\"));\r\n\r\n    QCOMPARE(testDesignConfiguration->getDescription(), QString(\"TestDescription\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_DesignConfigurationReader::readTopComments()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_DesignConfigurationReader::testRead2022DesignConfiguration()\r\n{\r\n    QString documentContent(\r\n        \"<ipxact:designConfiguration xmlns:xsi=\\\"http://www.w3.org/2001/XMLSchema-instance\\\" \"\r\n        \"xmlns:ipxact=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2022\\\" \"\r\n        \"xmlns:kactus2=\\\"http://kactus2.cs.tut.fi\\\" \"\r\n        \"xsi:schemaLocation=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2022/ \"\r\n        \"http://www.accellera.org/XMLSchema/IPXACT/1685-2022/index.xsd\\\">\"\r\n            \"<ipxact:vendor>tuni.fi</ipxact:vendor>\"\r\n            \"<ipxact:library>TestLibrary</ipxact:library>\"\r\n            \"<ipxact:name>TestDesignConfiguration</ipxact:name>\"\r\n            \"<ipxact:version>1.2022</ipxact:version>\"\r\n            \"<ipxact:shortDescription>Short</ipxact:shortDescription>\"\r\n            \"<ipxact:description>Full description</ipxact:description>\"\r\n        \"</ipxact:designConfiguration>\");\r\n\r\n    QDomDocument document;\r\n    document.setContent(documentContent);\r\n\r\n    QSharedPointer<DesignConfiguration> testDesignConfiguration =\r\n        DesignConfigurationReader::createDesignConfigurationFrom(document);\r\n\r\n    QCOMPARE(testDesignConfiguration->getRevision(), Document::Revision::Std22);\r\n    QCOMPARE(testDesignConfiguration->getVlnv().getVendor(), QString(\"tuni.fi\"));\r\n    QCOMPARE(testDesignConfiguration->getVlnv().getLibrary(), QString(\"TestLibrary\"));\r\n    QCOMPARE(testDesignConfiguration->getVlnv().getName(), QString(\"TestDesignConfiguration\"));\r\n    QCOMPARE(testDesignConfiguration->getVlnv().getVersion(), QString(\"1.2022\"));\r\n\r\n    QCOMPARE(testDesignConfiguration->getShortDescription(), QString(\"Short\"));\r\n    QCOMPARE(testDesignConfiguration->getDescription(), QString(\"Full description\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_DesignConfigurationReader::readTopComments()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_DesignConfigurationReader::testReadTopComments()\r\n{\r\n    QString documentContent(\r\n        \"<?xml version=\\\"1.0\\\"?>\"\r\n        \"<!--testComment 1-->\"\r\n        \"<!--testComment 2-->\"\r\n        \"<!--testComment 3-->\"\r\n        \"<ipxact:designConfiguration xmlns:xsi=\\\"http://www.w3.org/2001/XMLSchema-instance\\\" \" \r\n        \"xmlns:ipxact=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014\\\" \"\r\n        \"xmlns:kactus2=\\\"http://kactus2.cs.tut.fi\\\" \"\r\n        \"xsi:schemaLocation=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/ \"\r\n        \"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/index.xsd\\\">\"\r\n            \"<ipxact:vendor>tuni.fi</ipxact:vendor>\"\r\n            \"<ipxact:library>TestLibrary</ipxact:library>\"\r\n            \"<ipxact:name>TestDesignConfiguration</ipxact:name>\"\r\n            \"<ipxact:version>0.1</ipxact:version>\"\r\n            \"<ipxact:description>TestDescription</ipxact:description>\"\r\n        \"</ipxact:designConfiguration>\");\r\n\r\n    QDomDocument document;\r\n    document.setContent(documentContent);\r\n\r\n    QSharedPointer<DesignConfiguration> testDesignConfiguration =\r\n        DesignConfigurationReader::createDesignConfigurationFrom(document);\r\n\r\n    QCOMPARE(testDesignConfiguration->getRevision(), Document::Revision::Std14);\r\n    QCOMPARE(testDesignConfiguration->getTopComments().size(), 3);\r\n    QCOMPARE(testDesignConfiguration->getTopComments().first(), QString(\"testComment 1\"));\r\n    QCOMPARE(testDesignConfiguration->getTopComments().last(), QString(\"testComment 3\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_DesignConfigurationReader::testProcessingInstructionsAreParsed()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_DesignConfigurationReader::testProcessingInstructionsAreParsed()\r\n{\r\n    QString documentContent(\r\n        \"<?xml version=\\\"1.0\\\"?>\"\r\n        \"<?xml-stylesheet href=\\\"style.css\\\"?>\"\r\n        \"<ipxact:designConfiguration xmlns:xsi=\\\"http://www.w3.org/2001/XMLSchema-instance\\\" \" \r\n        \"xmlns:ipxact=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014\\\" \"\r\n        \"xmlns:kactus2=\\\"http://kactus2.cs.tut.fi\\\" \"\r\n        \"xsi:schemaLocation=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/ \"\r\n        \"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/index.xsd\\\">\"\r\n            \"<ipxact:vendor>tuni.fi</ipxact:vendor>\"\r\n            \"<ipxact:library>TestLibrary</ipxact:library>\"\r\n            \"<ipxact:name>TestDesignConfiguration</ipxact:name>\"\r\n            \"<ipxact:version>0.1</ipxact:version>\"\r\n            \"<ipxact:description>TestDescription</ipxact:description>\"\r\n        \"</ipxact:designConfiguration>\");\r\n\r\n    QDomDocument document;\r\n    document.setContent(documentContent);\r\n\r\n    QSharedPointer<DesignConfiguration> testDesignConfiguration =\r\n        DesignConfigurationReader::createDesignConfigurationFrom(document);\r\n\r\n    QCOMPARE(testDesignConfiguration->getRevision(), Document::Revision::Std14);\r\n    QCOMPARE(testDesignConfiguration->getXmlProcessingInstructions().count(), 1);\r\n\r\n    QPair<QString, QString> styleInstruction = testDesignConfiguration->getXmlProcessingInstructions().first();\r\n    QCOMPARE(styleInstruction.first, QString(\"xml-stylesheet\"));\r\n    QCOMPARE(styleInstruction.second, QString(\"href=\\\"style.css\\\"\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_DesignConfigurationReader::testReadDesignReference()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_DesignConfigurationReader::testReadDesignReference()\r\n{\r\n    QString documentContent(\r\n        \"<?xml version=\\\"1.0\\\"?>\"\r\n        \"<ipxact:designConfiguration \"\r\n        \"xmlns:xsi=\\\"http://www.w3.org/2001/XMLSchema-instance\\\" \" \r\n        \"xmlns:ipxact=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014\\\" \"\r\n        \"xmlns:kactus2=\\\"http://kactus2.cs.tut.fi\\\" \"\r\n        \"xsi:schemaLocation=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/ \"\r\n        \"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/index.xsd\\\">\"\r\n            \"<ipxact:vendor>tuni.fi</ipxact:vendor>\"\r\n            \"<ipxact:library>TestLibrary</ipxact:library>\"\r\n            \"<ipxact:name>TestDesignConfiguration</ipxact:name>\"\r\n            \"<ipxact:version>0.1</ipxact:version>\"\r\n            \"<ipxact:designRef vendor=\\\"tuni.fi\\\" library=\\\"TestLibrary\\\" name=\\\"DesignReference\\\" version=\\\"1.1\\\"/>\"\r\n        \"</ipxact:designConfiguration>\"\r\n        );\r\n\r\n    QDomDocument document;\r\n    document.setContent(documentContent);\r\n\r\n    QSharedPointer<DesignConfiguration> testDesignConfiguration =\r\n        DesignConfigurationReader::createDesignConfigurationFrom(document);\r\n\r\n    QCOMPARE(testDesignConfiguration->getRevision(), Document::Revision::Std14);\r\n    QCOMPARE(testDesignConfiguration->getDesignRef().getVendor(), QString(\"tuni.fi\"));\r\n    QCOMPARE(testDesignConfiguration->getDesignRef().getLibrary(), QString(\"TestLibrary\"));\r\n    QCOMPARE(testDesignConfiguration->getDesignRef().getName(), QString(\"DesignReference\"));\r\n    QCOMPARE(testDesignConfiguration->getDesignRef().getVersion(), QString(\"1.1\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_DesignConfigurationReader::testReadGeneratorChainConfigurations()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_DesignConfigurationReader::testReadGeneratorChainConfigurations()\r\n{\r\n    QString documentContent(\r\n        \"<?xml version=\\\"1.0\\\"?>\"\r\n        \"<ipxact:designConfiguration \"\r\n        \"xmlns:xsi=\\\"http://www.w3.org/2001/XMLSchema-instance\\\" \" \r\n        \"xmlns:ipxact=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014\\\" \"\r\n        \"xmlns:kactus2=\\\"http://kactus2.cs.tut.fi\\\" \"\r\n        \"xsi:schemaLocation=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/ \"\r\n        \"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/index.xsd\\\">\\n\"\r\n            \"<ipxact:vendor>tuni.fi</ipxact:vendor>\"\r\n            \"<ipxact:library>TestLibrary</ipxact:library>\"\r\n            \"<ipxact:name>TestDesignConfiguration</ipxact:name>\"\r\n            \"<ipxact:version>0.1</ipxact:version>\"\r\n            \"<ipxact:generatorChainConfiguration vendor=\\\"tuni.fi\\\" library=\\\"TestLibrary\\\" name=\\\"testGenCon\\\" \"\r\n                \"version=\\\"1.0\\\">\"\r\n                \"<ipxact:configurableElementValues>\"\r\n                    \"<ipxact:configurableElementValue referenceId=\\\"testReferenceID\\\">12\"\r\n                    \"</ipxact:configurableElementValue>\"\r\n                \"</ipxact:configurableElementValues>\"\r\n            \"</ipxact:generatorChainConfiguration>\"\r\n            \"<ipxact:generatorChainConfiguration vendor=\\\"tuni.fi\\\" library=\\\"TestLibrary\\\" name=\\\"testGenCon2\\\" \"\r\n                \"version=\\\"1.5\\\">\"\r\n                \"<ipxact:configurableElementValues>\"\r\n                    \"<ipxact:configurableElementValue referenceId=\\\"testReferenceID2\\\">20\"\r\n                    \"</ipxact:configurableElementValue>\"\r\n                \"</ipxact:configurableElementValues>\"\r\n            \"</ipxact:generatorChainConfiguration>\"\r\n        \"</ipxact:designConfiguration>\"\r\n        );\r\n\r\n    QDomDocument document;\r\n    document.setContent(documentContent);\r\n\r\n    QSharedPointer<DesignConfiguration> testDesignConfiguration =\r\n        DesignConfigurationReader::createDesignConfigurationFrom(document);\r\n\r\n    QCOMPARE(testDesignConfiguration->getRevision(), Document::Revision::Std14);\r\n    QCOMPARE(testDesignConfiguration->getGeneratorChainConfs()->size(), 2);\r\n    QCOMPARE(testDesignConfiguration->getGeneratorChainConfs()->first()->getVendor(), QString(\"tuni.fi\"));\r\n    QCOMPARE(testDesignConfiguration->getGeneratorChainConfs()->first()->getLibrary(), QString(\"TestLibrary\"));\r\n    QCOMPARE(testDesignConfiguration->getGeneratorChainConfs()->first()->getName(), QString(\"testGenCon\"));\r\n    QCOMPARE(testDesignConfiguration->getGeneratorChainConfs()->first()->getVersion(), QString(\"1.0\"));\r\n\r\n    QCOMPARE(testDesignConfiguration->getGeneratorChainConfs()->first()->getConfigurableElementValues()->size(), 1);\r\n\r\n    QSharedPointer<ConfigurableElementValue> testConfElement = testDesignConfiguration->getGeneratorChainConfs()->\r\n        first()->getConfigurableElementValues()->first();\r\n\r\n    QCOMPARE(testConfElement->getReferenceId(), QString(\"testReferenceID\"));\r\n    QCOMPARE(testConfElement->getConfigurableValue(), QString(\"12\"));\r\n\r\n    QCOMPARE(testDesignConfiguration->getGeneratorChainConfs()->last()->getVendor(), QString(\"tuni.fi\"));\r\n    QCOMPARE(testDesignConfiguration->getGeneratorChainConfs()->last()->getLibrary(), QString(\"TestLibrary\"));\r\n    QCOMPARE(testDesignConfiguration->getGeneratorChainConfs()->last()->getName(), QString(\"testGenCon2\"));\r\n    QCOMPARE(testDesignConfiguration->getGeneratorChainConfs()->last()->getVersion(), QString(\"1.5\"));\r\n\r\n    QCOMPARE(testDesignConfiguration->getGeneratorChainConfs()->last()->getConfigurableElementValues()->size(), 1);\r\n\r\n    QSharedPointer<ConfigurableElementValue> otherConfElement = testDesignConfiguration->getGeneratorChainConfs()->\r\n        last()->getConfigurableElementValues()->first();\r\n\r\n    QCOMPARE(otherConfElement->getReferenceId(), QString(\"testReferenceID2\"));\r\n    QCOMPARE(otherConfElement->getConfigurableValue(), QString(\"20\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_DesignConfigurationReader::testReadInterconnectionConfigurations()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_DesignConfigurationReader::testReadInterconnectionConfigurations()\r\n{\r\n    QString documentContent(\r\n        \"<?xml version=\\\"1.0\\\"?>\"\r\n        \"<ipxact:designConfiguration \"\r\n        \"xmlns:xsi=\\\"http://www.w3.org/2001/XMLSchema-instance\\\" \" \r\n        \"xmlns:ipxact=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014\\\" \"\r\n        \"xmlns:kactus2=\\\"http://kactus2.cs.tut.fi\\\" \"\r\n        \"xsi:schemaLocation=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/ \"\r\n        \"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/index.xsd\\\">\"\r\n            \"<ipxact:vendor>tuni.fi</ipxact:vendor>\"\r\n            \"<ipxact:library>TestLibrary</ipxact:library>\"\r\n            \"<ipxact:name>TestDesignConfiguration</ipxact:name>\"\r\n            \"<ipxact:version>0.1</ipxact:version>\"\r\n            \"<ipxact:interconnectionConfiguration>\"\r\n                \"<ipxact:isPresent>0</ipxact:isPresent>\"\r\n                \"<ipxact:interconnectionRef>testInterconnectionReference</ipxact:interconnectionRef>\"\r\n                \"<ipxact:abstractorInstances>\"\r\n                    \"<ipxact:isPresent>1</ipxact:isPresent>\"\r\n                    \"<ipxact:interfaceRef componentRef=\\\"testComponent\\\" busRef=\\\"testBus\\\">\"\r\n                        \"<ipxact:isPresent>1</ipxact:isPresent>\"\r\n                    \"</ipxact:interfaceRef>\"\r\n                    \"<ipxact:abstractorInstance>\"\r\n                        \"<ipxact:instanceName>testAbstractorInstance</ipxact:instanceName>\"\r\n                        \"<ipxact:displayName>abstractorDisplay</ipxact:displayName>\"\r\n                        \"<ipxact:description>abstractorDescription</ipxact:description>\"\r\n                        \"<ipxact:abstractorRef vendor=\\\"tuni.fi\\\" library=\\\"TestLibrary\\\" name=\\\"testAbstractor\\\" \"\r\n                        \"version=\\\"1.1\\\">\"\r\n                            \"<ipxact:configurableElementValues>\"\r\n                                \"<ipxact:configurableElementValue referenceId=\\\"testReferenceID\\\">12\"\r\n                                \"</ipxact:configurableElementValue>\"\r\n                            \"</ipxact:configurableElementValues>\"\r\n                        \"</ipxact:abstractorRef>\"\r\n                        \"<ipxact:viewName>abstractorView</ipxact:viewName>\"\r\n                    \"</ipxact:abstractorInstance>\"\r\n                \"</ipxact:abstractorInstances>\"\r\n            \"</ipxact:interconnectionConfiguration>\"\r\n        \"</ipxact:designConfiguration>\\n\"\r\n        );\r\n\r\n    QDomDocument document;\r\n    document.setContent(documentContent);\r\n\r\n    QSharedPointer<DesignConfiguration> testDesignConfiguration =\r\n        DesignConfigurationReader::createDesignConfigurationFrom(document);\r\n\r\n    QCOMPARE(testDesignConfiguration->getRevision(), Document::Revision::Std14);\r\n    QCOMPARE(testDesignConfiguration->getInterconnectionConfs()->size(), 1);\r\n\r\n    QSharedPointer<InterconnectionConfiguration> testInterconnectionConf =\r\n        testDesignConfiguration->getInterconnectionConfs()->first();\r\n\r\n    QCOMPARE(testInterconnectionConf->getIsPresent(), QString(\"0\"));\r\n    QCOMPARE(testInterconnectionConf->getInterconnectionReference(), QString(\"testInterconnectionReference\"));\r\n    QCOMPARE(testInterconnectionConf->getAbstractorInstances()->size(), 1);\r\n\r\n    QSharedPointer<MultipleAbstractorInstances> testMultipleAbsInstance = \r\n        testInterconnectionConf->getAbstractorInstances()->first();\r\n    QCOMPARE(testMultipleAbsInstance->getIsPresent(), QString(\"1\"));\r\n    QCOMPARE(testMultipleAbsInstance->getInterfaceReferences()->size(), 1);\r\n    QCOMPARE(testMultipleAbsInstance->getAbstractorInstances()->size(), 1);\r\n\r\n    QSharedPointer<InterfaceRef> testInterfaceRef = testMultipleAbsInstance->getInterfaceReferences()->first();\r\n    QCOMPARE(testInterfaceRef->getComponentRef(), QString(\"testComponent\"));\r\n    QCOMPARE(testInterfaceRef->getBusRef(), QString(\"testBus\"));\r\n    QCOMPARE(testInterfaceRef->getIsPresent(), QString(\"1\"));\r\n\r\n    QSharedPointer<AbstractorInstance> testAbstractorInstance =\r\n        testMultipleAbsInstance->getAbstractorInstances()->first();\r\n    QCOMPARE(testAbstractorInstance->getInstanceName(), QString(\"testAbstractorInstance\"));\r\n    QCOMPARE(testAbstractorInstance->getDisplayName(), QString(\"abstractorDisplay\"));\r\n    QCOMPARE(testAbstractorInstance->getDescription(), QString(\"abstractorDescription\"));\r\n    QCOMPARE(testAbstractorInstance->getViewName(), QString(\"abstractorView\"));\r\n\r\n    QCOMPARE(testAbstractorInstance->getAbstractorRef()->getVendor(), QString(\"tuni.fi\"));\r\n    QCOMPARE(testAbstractorInstance->getAbstractorRef()->getLibrary(), QString(\"TestLibrary\"));\r\n    QCOMPARE(testAbstractorInstance->getAbstractorRef()->getName(), QString(\"testAbstractor\"));\r\n    QCOMPARE(testAbstractorInstance->getAbstractorRef()->getVersion(), QString(\"1.1\"));\r\n    QCOMPARE(testAbstractorInstance->getAbstractorRef()->getConfigurableElementValues()->size(), 1);\r\n\r\n    QSharedPointer<ConfigurableElementValue> abstractorRefCEV =\r\n        testAbstractorInstance->getAbstractorRef()->getConfigurableElementValues()->first();\r\n\r\n    QCOMPARE(abstractorRefCEV->getReferenceId(), QString(\"testReferenceID\"));\r\n    QCOMPARE(abstractorRefCEV->getConfigurableValue(), QString(\"12\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_DesignConfigurationReader::testRead2022InterconnectionConfigurations()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_DesignConfigurationReader::testRead2022InterconnectionConfigurations()\r\n{\r\n    QString documentContent(\r\n        \"<?xml version=\\\"1.0\\\"?>\"\r\n        \"<ipxact:designConfiguration \"\r\n        \"xmlns:xsi=\\\"http://www.w3.org/2001/XMLSchema-instance\\\" \"\r\n        \"xmlns:ipxact=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2022\\\" \"\r\n        \"xmlns:kactus2=\\\"http://kactus2.cs.tut.fi\\\" \"\r\n        \"xsi:schemaLocation=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2022/ \"\r\n        \"http://www.accellera.org/XMLSchema/IPXACT/1685-2022/index.xsd\\\">\"\r\n            \"<ipxact:vendor>tuni.fi</ipxact:vendor>\"\r\n            \"<ipxact:library>TestLibrary</ipxact:library>\"\r\n            \"<ipxact:name>TestDesignConfiguration</ipxact:name>\"\r\n            \"<ipxact:version>0.1</ipxact:version>\"\r\n                \"<ipxact:interconnectionConfiguration>\"\r\n                    \"<ipxact:interconnectionRef>testInterconnectionReference</ipxact:interconnectionRef>\"\r\n                    \"<ipxact:abstractorInstances>\"\r\n                    \"<ipxact:interfaceRef componentRef=\\\"testComponent\\\" busRef=\\\"testBus\\\">\"\r\n                        \"<ipxact:vendorExtensions>\"\r\n                            \"<interfaceExtension testAttribute=\\\"extension\\\">testValue</interfaceExtension>\"\r\n                        \"</ipxact:vendorExtensions>\"\r\n                    \"</ipxact:interfaceRef>\"\r\n                    \"<ipxact:abstractorInstance>\"\r\n                        \"<ipxact:instanceName>testAbstractorInstance</ipxact:instanceName>\"\r\n                        \"<ipxact:displayName>abstractorDisplay</ipxact:displayName>\"\r\n                        \"<ipxact:shortDescription>short</ipxact:shortDescription>\"\r\n                        \"<ipxact:description>abstractorDescription</ipxact:description>\"\r\n                        \"<ipxact:abstractorRef vendor=\\\"tuni.fi\\\" library=\\\"TestLibrary\\\" name=\\\"testAbstractor\\\" version=\\\"1.1\\\">\"\r\n                            \"<ipxact:configurableElementValues>\"\r\n                                \"<ipxact:configurableElementValue referenceId=\\\"testReferenceID\\\">12\"\r\n                                \"</ipxact:configurableElementValue>\"\r\n                            \"</ipxact:configurableElementValues>\"\r\n                        \"</ipxact:abstractorRef>\"\r\n                        \"<ipxact:viewName>abstractorView</ipxact:viewName>\"\r\n                        \"<ipxact:vendorExtensions>\"\r\n                            \"<abstractorExtension testAttribute=\\\"extension\\\">testValue</abstractorExtension>\"\r\n                        \"</ipxact:vendorExtensions>\"\r\n                    \"</ipxact:abstractorInstance>\"\r\n                \"</ipxact:abstractorInstances>\"\r\n                \"<ipxact:vendorExtensions>\"\r\n                    \"<interconnectExtension testAttribute=\\\"extension\\\">testValue</interconnectExtension>\"\r\n                \"</ipxact:vendorExtensions>\"\r\n            \"</ipxact:interconnectionConfiguration>\"\r\n        \"</ipxact:designConfiguration>\\n\"\r\n    );\r\n\r\n    QDomDocument document;\r\n    document.setContent(documentContent);\r\n\r\n    QSharedPointer<DesignConfiguration> testDesignConfiguration =\r\n        DesignConfigurationReader::createDesignConfigurationFrom(document);\r\n\r\n    QCOMPARE(testDesignConfiguration->getRevision(), Document::Revision::Std22);\r\n    QCOMPARE(testDesignConfiguration->getInterconnectionConfs()->size(), 1);\r\n\r\n    QSharedPointer<InterconnectionConfiguration> testInterconnectionConf =\r\n        testDesignConfiguration->getInterconnectionConfs()->first();\r\n\r\n    QCOMPARE(testInterconnectionConf->getIsPresent(), QString());\r\n    QCOMPARE(testInterconnectionConf->getInterconnectionReference(), QString(\"testInterconnectionReference\"));\r\n    QCOMPARE(testInterconnectionConf->getAbstractorInstances()->size(), 1);\r\n    QCOMPARE(testInterconnectionConf->getVendorExtensions()->count(), 1);\r\n    QCOMPARE(testInterconnectionConf->getVendorExtensions()->first()->type(), QString(\"interconnectExtension\"));\r\n\r\n    QSharedPointer<MultipleAbstractorInstances> testMultipleAbsInstance =\r\n        testInterconnectionConf->getAbstractorInstances()->first();\r\n    QCOMPARE(testMultipleAbsInstance->getIsPresent(), QString());\r\n    QCOMPARE(testMultipleAbsInstance->getInterfaceReferences()->size(), 1);\r\n    QCOMPARE(testMultipleAbsInstance->getAbstractorInstances()->size(), 1);\r\n\r\n    QSharedPointer<InterfaceRef> testInterfaceRef = testMultipleAbsInstance->getInterfaceReferences()->first();\r\n    QCOMPARE(testInterfaceRef->getComponentRef(), QString(\"testComponent\"));\r\n    QCOMPARE(testInterfaceRef->getBusRef(), QString(\"testBus\"));\r\n    QCOMPARE(testInterfaceRef->getIsPresent(), QString());\r\n    QCOMPARE(testInterfaceRef->getVendorExtensions()->count(), 1);\r\n    QCOMPARE(testInterfaceRef->getVendorExtensions()->first()->type(), QString(\"interfaceExtension\"));\r\n\r\n    QSharedPointer<AbstractorInstance> testAbstractorInstance =\r\n        testMultipleAbsInstance->getAbstractorInstances()->first();\r\n    QCOMPARE(testAbstractorInstance->getInstanceName(), QString(\"testAbstractorInstance\"));\r\n    QCOMPARE(testAbstractorInstance->getDisplayName(), QString(\"abstractorDisplay\"));\r\n    QCOMPARE(testAbstractorInstance->getShortDescription(), QString(\"short\"));\r\n    QCOMPARE(testAbstractorInstance->getDescription(), QString(\"abstractorDescription\"));\r\n    QCOMPARE(testAbstractorInstance->getViewName(), QString(\"abstractorView\"));\r\n    QCOMPARE(testAbstractorInstance->getVendorExtensions()->count(), 1);\r\n    QCOMPARE(testAbstractorInstance->getVendorExtensions()->first()->type(), QString(\"abstractorExtension\"));\r\n\r\n    QCOMPARE(testAbstractorInstance->getAbstractorRef()->getVendor(), QString(\"tuni.fi\"));\r\n    QCOMPARE(testAbstractorInstance->getAbstractorRef()->getLibrary(), QString(\"TestLibrary\"));\r\n    QCOMPARE(testAbstractorInstance->getAbstractorRef()->getName(), QString(\"testAbstractor\"));\r\n    QCOMPARE(testAbstractorInstance->getAbstractorRef()->getVersion(), QString(\"1.1\"));\r\n    QCOMPARE(testAbstractorInstance->getAbstractorRef()->getConfigurableElementValues()->size(), 1);\r\n\r\n    QSharedPointer<ConfigurableElementValue> abstractorRefCEV =\r\n        testAbstractorInstance->getAbstractorRef()->getConfigurableElementValues()->first();\r\n\r\n    QCOMPARE(abstractorRefCEV->getReferenceId(), QString(\"testReferenceID\"));\r\n    QCOMPARE(abstractorRefCEV->getConfigurableValue(), QString(\"12\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_DesignConfigurationReader::testReadViewConfigurations()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_DesignConfigurationReader::testReadViewConfigurations()\r\n{\r\n    QString documentContent(\r\n        \"<?xml version=\\\"1.0\\\"?>\"\r\n        \"<ipxact:designConfiguration \"\r\n        \"xmlns:xsi=\\\"http://www.w3.org/2001/XMLSchema-instance\\\" \" \r\n        \"xmlns:ipxact=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014\\\" \"\r\n        \"xmlns:kactus2=\\\"http://kactus2.cs.tut.fi\\\" \"\r\n        \"xsi:schemaLocation=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/ \"\r\n        \"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/index.xsd\\\">\"\r\n            \"<ipxact:vendor>tuni.fi</ipxact:vendor>\"\r\n            \"<ipxact:library>TestLibrary</ipxact:library>\"\r\n            \"<ipxact:name>TestDesignConfiguration</ipxact:name>\"\r\n            \"<ipxact:version>0.1</ipxact:version>\"\r\n            \"<ipxact:viewConfiguration>\"\r\n                \"<ipxact:instanceName>testViewConfig</ipxact:instanceName>\"\r\n                \"<ipxact:isPresent>1</ipxact:isPresent>\"\r\n                \"<ipxact:view viewRef=\\\"referenceToTestView\\\">\"\r\n                    \"<ipxact:configurableElementValues>\"\r\n                        \"<ipxact:configurableElementValue referenceId=\\\"testReferenceID\\\">2\"\r\n                        \"</ipxact:configurableElementValue>\"\r\n                    \"</ipxact:configurableElementValues>\"\r\n                \"</ipxact:view>\"\r\n            \"</ipxact:viewConfiguration>\"\r\n            \"<ipxact:description>Design description</ipxact:description>\"\r\n        \"</ipxact:designConfiguration>\"\r\n        );\r\n\r\n    QDomDocument document;\r\n    document.setContent(documentContent);\r\n\r\n    QSharedPointer<DesignConfiguration> testDesignConfiguration =\r\n        DesignConfigurationReader::createDesignConfigurationFrom(document);\r\n\r\n    QCOMPARE(testDesignConfiguration->getRevision(), Document::Revision::Std14);\r\n    QCOMPARE(testDesignConfiguration->getDescription(), QString(\"Design description\"));\r\n    QCOMPARE(testDesignConfiguration->getViewConfigurations()->size(), 1);\r\n\r\n    QSharedPointer<ViewConfiguration> testViewConfiguration =\r\n        testDesignConfiguration->getViewConfigurations()->first();\r\n\r\n    QCOMPARE(testViewConfiguration->getInstanceName(), QString(\"testViewConfig\"));\r\n    QCOMPARE(testViewConfiguration->getIsPresent(), QString(\"1\"));\r\n    QCOMPARE(testViewConfiguration->getViewReference(), QString(\"referenceToTestView\"));\r\n    QCOMPARE(testViewConfiguration->getViewConfigurableElements()->size(), 1);\r\n\r\n    QSharedPointer<ConfigurableElementValue> testConfigurableElementValue =\r\n        testViewConfiguration->getViewConfigurableElements()->first();\r\n\r\n    QCOMPARE(testConfigurableElementValue->getConfigurableValue(), QString(\"2\"));\r\n    QCOMPARE(testConfigurableElementValue->getReferenceId(), QString(\"testReferenceID\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_DesignConfigurationReader::testRead2022ViewConfigurations()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_DesignConfigurationReader::testRead2022ViewConfigurations()\r\n{\r\n    QString documentContent(\r\n        \"<?xml version=\\\"1.0\\\"?>\"\r\n        \"<ipxact:designConfiguration \"\r\n        \"xmlns:xsi=\\\"http://www.w3.org/2001/XMLSchema-instance\\\" \"\r\n        \"xmlns:ipxact=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2022\\\" \"\r\n        \"xmlns:kactus2=\\\"http://kactus2.cs.tut.fi\\\" \"\r\n        \"xsi:schemaLocation=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2022/ \"\r\n        \"http://www.accellera.org/XMLSchema/IPXACT/1685-2022/index.xsd\\\">\"\r\n            \"<ipxact:vendor>tuni.fi</ipxact:vendor>\"\r\n            \"<ipxact:library>TestLibrary</ipxact:library>\"\r\n            \"<ipxact:name>TestDesignConfiguration</ipxact:name>\"\r\n            \"<ipxact:version>0.1</ipxact:version>\"\r\n            \"<ipxact:viewConfiguration>\"\r\n                \"<ipxact:instanceName>testViewConfig</ipxact:instanceName>\"\r\n                \"<ipxact:view viewRef=\\\"referenceToTestView\\\">\"\r\n                    \"<ipxact:configurableElementValues>\"\r\n                        \"<ipxact:configurableElementValue referenceId=\\\"testReferenceID\\\">2\"\r\n                    \"</ipxact:configurableElementValue>\"\r\n                    \"</ipxact:configurableElementValues>\"\r\n                \"</ipxact:view>\"\r\n                \"<ipxact:vendorExtensions>\"\r\n                    \"<viewExtension testAttribute=\\\"extension\\\">testValue</viewExtension>\"\r\n                \"</ipxact:vendorExtensions>\"\r\n            \"</ipxact:viewConfiguration>\"\r\n        \"</ipxact:designConfiguration>\"\r\n    );\r\n\r\n    QDomDocument document;\r\n    document.setContent(documentContent);\r\n\r\n    QSharedPointer<DesignConfiguration> testDesignConfiguration =\r\n        DesignConfigurationReader::createDesignConfigurationFrom(document);\r\n\r\n    QCOMPARE(testDesignConfiguration->getRevision(), Document::Revision::Std22);\r\n    QCOMPARE(testDesignConfiguration->getViewConfigurations()->size(), 1);\r\n\r\n    QSharedPointer<ViewConfiguration> testViewConfiguration =\r\n        testDesignConfiguration->getViewConfigurations()->first();\r\n\r\n    QCOMPARE(testViewConfiguration->getInstanceName(), QString(\"testViewConfig\"));\r\n    QCOMPARE(testViewConfiguration->getIsPresent(), QString());\r\n    QCOMPARE(testViewConfiguration->getViewReference(), QString(\"referenceToTestView\"));\r\n    QCOMPARE(testViewConfiguration->getViewConfigurableElements()->size(), 1);\r\n    QCOMPARE(testViewConfiguration->getVendorExtensions()->count(), 1);\r\n    QCOMPARE(testViewConfiguration->getVendorExtensions()->first()->type(), QString(\"viewExtension\"));\r\n\r\n    QSharedPointer<ConfigurableElementValue> testConfigurableElementValue =\r\n        testViewConfiguration->getViewConfigurableElements()->first();\r\n\r\n    QCOMPARE(testConfigurableElementValue->getConfigurableValue(), QString(\"2\"));\r\n    QCOMPARE(testConfigurableElementValue->getReferenceId(), QString(\"testReferenceID\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_DesignConfigurationReader::readParameters()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_DesignConfigurationReader::testReadParameters()\r\n{\r\n    QString documentContent(\r\n        \"<?xml version=\\\"1.0\\\"?>\"\r\n        \"<ipxact:designConfiguration \"\r\n        \"xmlns:xsi=\\\"http://www.w3.org/2001/XMLSchema-instance\\\" \" \r\n        \"xmlns:ipxact=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014\\\" \"\r\n        \"xmlns:kactus2=\\\"http://kactus2.cs.tut.fi\\\" \"\r\n        \"xsi:schemaLocation=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/ \"\r\n        \"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/index.xsd\\\">\"\r\n            \"<ipxact:vendor>tuni.fi</ipxact:vendor>\"\r\n            \"<ipxact:library>TestLibrary</ipxact:library>\"\r\n            \"<ipxact:name>TestDesignConfiguration</ipxact:name>\"\r\n            \"<ipxact:version>0.1</ipxact:version>\"\r\n            \"<ipxact:parameters>\"\r\n                \"<ipxact:parameter parameterId=\\\"testID\\\">\"\r\n                    \"<ipxact:name>testParameter</ipxact:name>\"\r\n                    \"<ipxact:value>1</ipxact:value>\"\r\n                \"</ipxact:parameter>\"\r\n            \"</ipxact:parameters>\"\r\n        \"</ipxact:designConfiguration>\");\r\n\r\n    QDomDocument document;\r\n    document.setContent(documentContent);\r\n\r\n    QSharedPointer<DesignConfiguration> testDesignConfiguration =\r\n        DesignConfigurationReader::createDesignConfigurationFrom(document);\r\n\r\n    QCOMPARE(testDesignConfiguration->getRevision(), Document::Revision::Std14);\r\n    QCOMPARE(testDesignConfiguration->getParameters()->size(), 1);\r\n    QCOMPARE(testDesignConfiguration->getParameters()->first()->getValue(), QString(\"1\"));\r\n    QCOMPARE(testDesignConfiguration->getParameters()->first()->getValueId(), QString(\"testID\"));\r\n    QCOMPARE(testDesignConfiguration->getParameters()->first()->name(), QString(\"testParameter\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_DesignConfigurationReader::testReadAssertions()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_DesignConfigurationReader::testReadAssertions()\r\n{\r\n    QString documentContent(\r\n        \"<?xml version=\\\"1.0\\\"?>\"\r\n        \"<ipxact:designConfiguration \"\r\n        \"xmlns:xsi=\\\"http://www.w3.org/2001/XMLSchema-instance\\\" \" \r\n        \"xmlns:ipxact=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014\\\" \"\r\n        \"xmlns:kactus2=\\\"http://kactus2.cs.tut.fi\\\" \"\r\n        \"xsi:schemaLocation=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/ \"\r\n        \"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/index.xsd\\\">\"\r\n            \"<ipxact:vendor>tuni.fi</ipxact:vendor>\"\r\n            \"<ipxact:library>TestLibrary</ipxact:library>\"\r\n            \"<ipxact:name>TestDesignConfiguration</ipxact:name>\"\r\n            \"<ipxact:version>0.1</ipxact:version>\"\r\n            \"<ipxact:assertions>\"\r\n                \"<ipxact:assertion>\"\r\n                    \"<ipxact:name>testAssertion</ipxact:name>\"\r\n                    \"<ipxact:displayName>assertionDisplay</ipxact:displayName>\"\r\n                    \"<ipxact:description>assertionDescription</ipxact:description>\"\r\n                    \"<ipxact:assert>13</ipxact:assert>\"\r\n                \"</ipxact:assertion>\"\r\n            \"</ipxact:assertions>\"\r\n        \"</ipxact:designConfiguration>\"\r\n        );\r\n\r\n    QDomDocument document;\r\n    document.setContent(documentContent);\r\n\r\n    QSharedPointer<DesignConfiguration> testDesignConfiguration =\r\n        DesignConfigurationReader::createDesignConfigurationFrom(document);\r\n\r\n    QCOMPARE(testDesignConfiguration->getRevision(), Document::Revision::Std14);\r\n    QCOMPARE(testDesignConfiguration->getAssertions()->size(), 1);\r\n    QCOMPARE(testDesignConfiguration->getAssertions()->first()->name(), QString(\"testAssertion\"));\r\n    QCOMPARE(testDesignConfiguration->getAssertions()->first()->displayName(), QString(\"assertionDisplay\"));\r\n    QCOMPARE(testDesignConfiguration->getAssertions()->first()->description(), QString(\"assertionDescription\"));\r\n    QCOMPARE(testDesignConfiguration->getAssertions()->first()->getAssert(), QString(\"13\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_DesignConfigurationReader::testReadVendorExtensions()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_DesignConfigurationReader::testReadVendorExtensions()\r\n{\r\n    QString documentContent(\r\n        \"<?xml version=\\\"1.0\\\"?>\"\r\n        \"<ipxact:designConfiguration \"\r\n        \"xmlns:xsi=\\\"http://www.w3.org/2001/XMLSchema-instance\\\" \" \r\n        \"xmlns:ipxact=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014\\\" \"\r\n        \"xmlns:kactus2=\\\"http://kactus2.cs.tut.fi\\\" \"\r\n        \"xsi:schemaLocation=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/ \"\r\n        \"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/index.xsd\\\">\"\r\n            \"<ipxact:vendor>tuni.fi</ipxact:vendor>\"\r\n            \"<ipxact:library>TestLibrary</ipxact:library>\"\r\n            \"<ipxact:name>TestDesignConfiguration</ipxact:name>\"\r\n            \"<ipxact:version>0.1</ipxact:version>\"\r\n            \"<ipxact:vendorExtensions>\"                \r\n                \"<kactus2:version>3.0.0</kactus2:version>\"\r\n                \"<testExtension testExtensionAttribute=\\\"extension\\\">testValue</testExtension>\"\r\n            \"</ipxact:vendorExtensions>\"\r\n        \"</ipxact:designConfiguration>\"\r\n        );\r\n\r\n    QDomDocument document;\r\n    document.setContent(documentContent);\r\n\r\n    QSharedPointer<DesignConfiguration> testDesignConfiguration =\r\n        DesignConfigurationReader::createDesignConfigurationFrom(document);\r\n\r\n    QCOMPARE(testDesignConfiguration->getRevision(), Document::Revision::Std14);\r\n    QCOMPARE(testDesignConfiguration->getVendorExtensions()->size(), 2);\r\n    QCOMPARE(testDesignConfiguration->getVendorExtensions()->last()->type(), QString(\"testExtension\"));\r\n    QCOMPARE(testDesignConfiguration->getVersion(), QString(\"3.0.0\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_DesignConfigurationReader::testReadViewOverrides()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_DesignConfigurationReader::testReadViewOverrides()\r\n{\r\n    QString documentContent(\r\n        \"<?xml version=\\\"1.0\\\"?>\"\r\n        \"<ipxact:designConfiguration \"\r\n        \"xmlns:xsi=\\\"http://www.w3.org/2001/XMLSchema-instance\\\" \" \r\n        \"xmlns:ipxact=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014\\\" \"\r\n        \"xmlns:kactus2=\\\"http://kactus2.cs.tut.fi\\\" \"\r\n        \"xsi:schemaLocation=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/ \"\r\n        \"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/index.xsd\\\">\"\r\n            \"<ipxact:vendor>tuni.fi</ipxact:vendor>\"\r\n            \"<ipxact:library>TestLibrary</ipxact:library>\"\r\n            \"<ipxact:name>TestDesignConfiguration</ipxact:name>\"\r\n            \"<ipxact:version>0.1</ipxact:version>\"\r\n            \"<ipxact:vendorExtensions>\"\r\n                \"<kactus2:version>3.0.0</kactus2:version>\"\r\n                \"<kactus2:viewOverrides>\"\r\n                    \"<kactus2:instanceView id=\\\"instanceId\\\" viewName=\\\"testView\\\"/>\"\r\n                    \"<kactus2:instanceView id=\\\"otherId\\\" viewName=\\\"otherView\\\"/>\"\r\n                \"</kactus2:viewOverrides>\"\r\n            \"</ipxact:vendorExtensions>\"\r\n        \"</ipxact:designConfiguration>\"\r\n        );\r\n\r\n    QDomDocument document;\r\n    document.setContent(documentContent);\r\n\r\n    QSharedPointer<DesignConfiguration> testDesignConfiguration =\r\n        DesignConfigurationReader::createDesignConfigurationFrom(document);\r\n\r\n    QCOMPARE(testDesignConfiguration->getRevision(), Document::Revision::Std14);\r\n    QCOMPARE(testDesignConfiguration->getVendorExtensions()->size(), 2);\r\n\r\n    QCOMPARE(testDesignConfiguration->getKactus2ViewOverrides().count(), 2);\r\n    QCOMPARE(testDesignConfiguration->getKactus2ViewOverrides().firstKey(), QString(\"instanceId\"));\r\n    QCOMPARE(testDesignConfiguration->getKactus2ViewOverrides().first(), QString(\"testView\"));\r\n    QCOMPARE(testDesignConfiguration->getKactus2ViewOverrides().lastKey(), QString(\"otherId\"));\r\n    QCOMPARE(testDesignConfiguration->getKactus2ViewOverrides().last(), QString(\"otherView\"));\r\n}\r\n\r\nQTEST_APPLESS_MAIN(tst_DesignConfigurationReader)\r\n\r\n#include \"tst_DesignConfigurationReader.moc\"\r\n"
  },
  {
    "path": "tests/IPXACTmodels/DesignConfiguration/tst_DesignConfigurationReader.pri",
    "content": "# ----------------------------------------------------\r\n# This file is generated by the Qt Visual Studio Add-in.\r\n# ------------------------------------------------------\r\n\r\nSOURCES += ./tst_DesignConfigurationReader.cpp\r\n"
  },
  {
    "path": "tests/IPXACTmodels/DesignConfiguration/tst_DesignConfigurationReader.pro",
    "content": "#-----------------------------------------------------------------------------\r\n# File: DesignConfigurationReader.pro\r\n#-----------------------------------------------------------------------------\r\n# Project: Kactus 2\r\n# Author: Mikko Teuho\r\n# Date: 11.08.2015\r\n#\r\n# Description:\r\n# Qt project file for running unit tests for a designConfigurationReader.\r\n#-----------------------------------------------------------------------------\r\n\r\nTEMPLATE = app\r\n\r\nTARGET = tst_DesignConfigurationReader\r\n\r\nQT += core xml testlib\r\nQT -= gui\r\n\r\nCONFIG += c++11 testcase console\r\n\r\nlinux-g++ | linux-g++-64 | linux-g++-32 {\r\n LIBS += -L../../../executable \\\r\n     -lIPXACTmodels\r\n\r\n}\r\nwin64 | win32 {\r\n LIBS += -L../../../executable \\\r\n     -lIPXACTmodelsd\r\n}\r\n\r\nDESTDIR = ./release\r\n\r\nINCLUDEPATH += $$DESTDIR\r\nINCLUDEPATH += ../../../\r\n\r\nDEPENDPATH += .\r\n\r\nOBJECTS_DIR += $$DESTDIR\r\n\r\nMOC_DIR += ./generatedFiles\r\nUI_DIR += ./generatedFiles\r\nRCC_DIR += ./generatedFiles\r\ninclude(tst_DesignConfigurationReader.pri)\r\n"
  },
  {
    "path": "tests/IPXACTmodels/DesignConfiguration/tst_DesignConfigurationValidator.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: tst_DesignConfigurationValidator.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Mikko Teuho\n// Date: 11.01.2016\n//\n// Description:\n// Unit test for class DesignConfigurationValidator.\n//-----------------------------------------------------------------------------\n\n#include <IPXACTmodels/common/VLNV.h>\n#include <IPXACTmodels/common/ConfigurableVLNVReference.h>\n#include <IPXACTmodels/common/Parameter.h>\n#include <IPXACTmodels/common/Assertion.h>\n\n#include <IPXACTmodels/Component/Component.h>\n#include <IPXACTmodels/Component/BusInterface.h>\n#include <IPXACTmodels/Component/View.h>\n\n#include <IPXACTmodels/Design/Design.h>\n#include <IPXACTmodels/Design/ComponentInstance.h>\n\n#include <IPXACTmodels/DesignConfiguration/DesignConfiguration.h>\n#include <IPXACTmodels/DesignConfiguration/InterconnectionConfiguration.h>\n#include <IPXACTmodels/DesignConfiguration/MultipleAbstractorInstances.h>\n#include <IPXACTmodels/DesignConfiguration/AbstractorInstance.h>\n#include <IPXACTmodels/DesignConfiguration/InterfaceRef.h>\n#include <IPXACTmodels/DesignConfiguration/ViewConfiguration.h>\n\n#include <IPXACTmodels/DesignConfiguration/validators/DesignConfigurationValidator.h>\n#include <IPXACTmodels/DesignConfiguration/validators/InterconnectionConfigurationValidator.h>\n#include <IPXACTmodels/DesignConfiguration/validators/ViewConfigurationValidator.h>\n\n#include <KactusAPI/include/SystemVerilogExpressionParser.h>\n\n#include <tests/MockObjects/LibraryMock.h>\n\n#include <QtTest>\n\nclass tst_DesignConfigurationValidator : public QObject\n{\n    Q_OBJECT\n\npublic:\n    tst_DesignConfigurationValidator();\n\nprivate slots:\n\n    void testHasValidVLNV();\n    void testHasValidVLNV_data();\n\n    void testHasValidDesignReference();\n    void testHasValidDesignReference_data();\n\n    void testHasValidGeneratorChainConfigurations();\n    void testHasValidGeneratorChainConfigurations_data();\n\n    void testInterconnectionConfigurationHasValidInterconnectionReference();\n    void testInterconnectionConfigurationHasValidInterconnectionReference_data();\n\n    void testInterconnectionConfigurationHasValidIsPresent();\n    void testInterconnectionConfigurationHasValidIsPresent_data();\n\n    void testInterconnectionConfigurationHasValidAbstractorInstance();\n    void testInterconnectionConfigurationHasValidAbstractorInstance_data();\n\n    void testInterconnectionConfigurationHasValidAbstractorIsPresent();\n    void testInterconnectionConfigurationHasValidAbstractorIsPresent_data();\n\n    void testInterconnectionConfigurationHasValidInterfaceReference();\n    void testInterconnectionConfigurationHasValidInterfaceReference_data();\n\n    void testInterconnectionConfigurationInterfaceHasValidIsPresent();\n    void testInterconnectionConfigurationInterfaceHasValidIsPresent_data();\n\n    void testHasValidInterconnectionConfigurations();\n    void testHasValidInterconnectionConfigurations_data();\n\n    void testViewConfigurationHasValidName();\n    void testViewConfigurationHasValidName_data();\n\n    void testViewConfigurationHasValidIsPresent();\n    void testViewConfigurationHasValidIsPresent_data();\n\n    void testViewConfigurationHasValidViewReference();\n\tvoid testViewConfigurationHasValidViewReference_data();\n\n    void testHasValidViewConfigurations();\n    void testHasValidViewConfigurations_data();\n\n    void testHasValidParameters();\n    void testHasValidParameters_data();\n\n    void testHasValidAssertions();\n    void testHasValidAssertions_data();\n\nprivate:\n\n    bool errorIsNotFoundInErrorList(QString const& expectedError, QVector<QString> errorList);\n\n    QSharedPointer<DesignConfigurationValidator> createDesignConfigurationValidator(LibraryInterface* library);\n\n    QSharedPointer<InterconnectionConfigurationValidator> createInterconnectionConfigurationValidator(\n        LibraryInterface* library);\n\n    QSharedPointer<ViewConfigurationValidator> createViewConfigurationValidator(LibraryInterface* library);\n};\n\n//-----------------------------------------------------------------------------\n// Function: tst_DesignConfigurationValidator::tst_DesignConfigurationValidator()\n//-----------------------------------------------------------------------------\ntst_DesignConfigurationValidator::tst_DesignConfigurationValidator()\n{\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_DesignConfigurationValidator::testHasValidVLNV()\n//-----------------------------------------------------------------------------\nvoid tst_DesignConfigurationValidator::testHasValidVLNV()\n{\n    QFETCH(QString, vendor);\n    QFETCH(QString, library);\n    QFETCH(QString, name);\n    QFETCH(QString, version);\n    QFETCH(bool, isValid);\n\n    VLNV designConfigurationVLNV(VLNV::DESIGNCONFIGURATION, vendor, library, name, version);\n    QSharedPointer<DesignConfiguration> testConfiguration (new DesignConfiguration(designConfigurationVLNV, Document::Revision::Std14));\n\n    QSharedPointer<DesignConfigurationValidator> validator = createDesignConfigurationValidator(0);\n    QCOMPARE(validator->hasValidVLNV(testConfiguration), isValid);\n\n    if (!isValid)\n    {\n        QVector<QString> foundErrors;\n        validator->findErrorsIn(foundErrors, testConfiguration);\n\n        QString expectedError = QObject::tr(\"The type of the vlnv is invalid within design configuration\");\n\n        if (vendor.isEmpty())\n        {\n            expectedError = QObject::tr(\"No vendor specified for vlnv within design configuration\");\n        }\n        else if (library.isEmpty())\n        {\n            expectedError = QObject::tr(\"No library specified for vlnv within design configuration\");\n        }\n        else if (name.isEmpty())\n        {\n            expectedError = QObject::tr(\"No name specified for vlnv within design configuration\");\n        }\n        else if (version.isEmpty())\n        {\n            expectedError = QObject::tr(\"No version specified for vlnv within design configuration\");\n        }\n\n        if (errorIsNotFoundInErrorList(expectedError, foundErrors))\n        {\n            QFAIL(\"No error message found\");\n        }\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_DesignConfigurationValidator::testHasValidVLNV_data()\n//-----------------------------------------------------------------------------\nvoid tst_DesignConfigurationValidator::testHasValidVLNV_data()\n{\n    QTest::addColumn<QString>(\"vendor\");\n    QTest::addColumn<QString>(\"library\");\n    QTest::addColumn<QString>(\"name\");\n    QTest::addColumn<QString>(\"version\");\n    QTest::addColumn<bool>(\"isValid\");\n\n    QTest::newRow(\"Design configuration with all VLNVs is valid\") <<\n        \"Tengen\" << \"Toppa\" << \"Gurren\" << \"Lagann\" << true;\n    QTest::newRow(\"Design configuration without vendor is not valid\") <<\n        \"\" << \"Toppa\" << \"Gurren\" << \"Lagann\" << false;\n    QTest::newRow(\"Design configuration without library is not valid\") <<\n        \"Tengen\" << \"\" << \"Gurren\" << \"Lagann\" << false;\n    QTest::newRow(\"Design configuration without name is not valid\") <<\n        \"Tengen\" << \"Toppa\" << \"\" << \"Lagann\" << false;\n    QTest::newRow(\"Design configuration without version is not valid\") <<\n        \"Tengen\" << \"Toppa\" << \"Gurren\" << \"\" << false;\n    QTest::newRow(\"Empty VLNV is not valid\") << \"\" << \"\" << \"\" << \"\" << false;\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_DesignConfigurationValidator::testHasValidDesignReference()\n//-----------------------------------------------------------------------------\nvoid tst_DesignConfigurationValidator::testHasValidDesignReference()\n{\n    QFETCH(bool, referenceExists);\n    QFETCH(QString, vendor);\n    QFETCH(QString, library);\n    QFETCH(QString, name);\n    QFETCH(QString, version);\n    QFETCH(bool, addToLibrary);\n    QFETCH(bool, isValid);\n\n    LibraryMock* mockLibrary (new LibraryMock(this));\n\n    QSharedPointer<DesignConfiguration> testConfiguration (new DesignConfiguration(\n        VLNV(VLNV::DESIGNCONFIGURATION, \"Samurai\", \"Champloo\", \"MugenJinFuu\", \"3.0\"), Document::Revision::Std14));\n\n    VLNV designReference (VLNV::DESIGN, vendor, library, name, version);\n    \n    if (referenceExists)\n    {\n        testConfiguration->setDesignRef(designReference);\n\n        if (addToLibrary)\n        {\n            QSharedPointer<Design> referencedDesign (new Design(designReference, Document::Revision::Std14));\n            mockLibrary->addComponent(referencedDesign);\n        }\n    }\n\n    QSharedPointer<DesignConfigurationValidator> validator = createDesignConfigurationValidator(mockLibrary);\n\n    QCOMPARE(validator->hasValidDesignReference(testConfiguration), isValid);\n\n    if (!isValid)\n    {\n        QVector<QString> foundErrors;\n        validator->findErrorsIn(foundErrors, testConfiguration);\n\n        QString expectedError = QObject::tr(\"The type of the vlnv is invalid within design reference\");\n\n        if (vendor.isEmpty())\n        {\n            expectedError = QObject::tr(\"No vendor specified for vlnv within design reference\");\n        }\n        else if (library.isEmpty())\n        {\n            expectedError = QObject::tr(\"No library specified for vlnv within design reference\");\n        }\n        else if (name.isEmpty())\n        {\n            expectedError = QObject::tr(\"No name specified for vlnv within design reference\");\n        }\n        else if (version.isEmpty())\n        {\n            expectedError = QObject::tr(\"No version specified for vlnv within design reference\");\n        }\n        else if (!addToLibrary)\n        {\n            expectedError = QObject::tr(\"Design reference %1 within design configuration %2 was not found in the \"\n                \"library\").arg(designReference.toString()).arg(testConfiguration->getVlnv().toString());\n        }\n\n        if (errorIsNotFoundInErrorList(expectedError, foundErrors))\n        {\n            QFAIL(\"No error message found\");\n        }\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_DesignConfigurationValidator::testHasValidDesignReference_data()\n//-----------------------------------------------------------------------------\nvoid tst_DesignConfigurationValidator::testHasValidDesignReference_data()\n{\n    QTest::addColumn<bool>(\"referenceExists\");\n    QTest::addColumn<QString>(\"vendor\");\n    QTest::addColumn<QString>(\"library\");\n    QTest::addColumn<QString>(\"name\");\n    QTest::addColumn<QString>(\"version\");\n    QTest::addColumn<bool>(\"addToLibrary\");\n    QTest::addColumn<bool>(\"isValid\");\n\n    QTest::newRow(\"Design configuration without a design reference is valid\") <<\n        false << \"\" << \"\" << \"\" << \"\" << false << true;\n\n    QTest::newRow(\"Design reference with VLNV and referencing a design contained in library is valid\") <<\n        true << \"Tengen\" << \"Toppa\" << \"Gurren\" << \"Lagann\" << true << true;\n    QTest::newRow(\"Design reference without vendor is not valid\") <<\n        true << \"\" << \"Toppa\" << \"Gurren\" << \"Lagann\" << true << false;\n    QTest::newRow(\"Design reference without library is not valid\") <<\n        true << \"Tengen\" << \"\" << \"Gurren\" << \"Lagann\" << true << false;\n    QTest::newRow(\"Design reference without name is not valid\") <<\n        true << \"Tengen\" << \"Toppa\" << \"\" << \"Lagann\" << true << false;\n    QTest::newRow(\"Design reference without version is not valid\") <<\n        true << \"Tengen\" << \"Toppa\" << \"Gurren\" << \"\" << true << false;\n\n    QTest::newRow(\"Design reference referencing design not found in library is not valid\") <<\n        true << \"Tengen\" << \"Toppa\" << \"Gurren\" << \"Lagann\" << false << false;\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_DesignConfigurationValidator::testHasValidGeneratorChainConfigurations()\n//-----------------------------------------------------------------------------\nvoid tst_DesignConfigurationValidator::testHasValidGeneratorChainConfigurations()\n{\n    QFETCH(bool, referenceExists);\n    QFETCH(QString, vendor);\n    QFETCH(QString, library);\n    QFETCH(QString, name);\n    QFETCH(QString, version);\n    QFETCH(bool, copyChain);\n    QFETCH(bool, isValid);\n\n    QSharedPointer<DesignConfiguration> testConfiguration (new DesignConfiguration(\n        VLNV(VLNV::DESIGNCONFIGURATION, \"Samurai\", \"Champloo\", \"MugenJinFuu\", \"3.0\"), Document::Revision::Std14));\n\n    QSharedPointer<ConfigurableVLNVReference> chainVLNV (\n        new ConfigurableVLNVReference(VLNV::GENERATORCHAIN, vendor, library, name, version));\n\n    if (referenceExists)\n    {\n        testConfiguration->getGeneratorChainConfs()->append(chainVLNV);\n\n        if (copyChain)\n        {\n            QSharedPointer<ConfigurableVLNVReference> otherChain (new ConfigurableVLNVReference(*chainVLNV.data()));\n            testConfiguration->getGeneratorChainConfs()->append(otherChain);\n        }\n    }\n\n    QSharedPointer<DesignConfigurationValidator> validator = createDesignConfigurationValidator(0);\n\n    QCOMPARE(validator->hasValidGeneratorChainConfigurations(testConfiguration), isValid);\n\n    if (!isValid)\n    {\n        QVector<QString> foundErrors;\n        validator->findErrorsIn(foundErrors, testConfiguration);\n\n        QString expectedError = QObject::tr(\"The type of the generator chain configuration is invalid within \"\n            \"design configuration %1.\").arg(testConfiguration->getVlnv().toString());\n\n        if (vendor.isEmpty())\n        {\n            expectedError = QObject::tr(\"No vendor specified for vlnv within generator chain configuration\");\n        }\n        else if (library.isEmpty())\n        {\n            expectedError = QObject::tr(\"No library specified for vlnv within generator chain configuration\");\n        }\n        else if (name.isEmpty())\n        {\n            expectedError = QObject::tr(\"No name specified for vlnv within generator chain configuration\");\n        }\n        else if (version.isEmpty())\n        {\n            expectedError = QObject::tr(\"No version specified for vlnv within generator chain configuration\");\n        }\n        else if (copyChain)\n        {\n            expectedError = QObject::tr(\"Generator chain configuration %1 is not unique within design \"\n                \"configuration %2.\").arg(chainVLNV->toString()).arg(testConfiguration->getVlnv().toString());\n        }\n\n        if (errorIsNotFoundInErrorList(expectedError, foundErrors))\n        {\n            QFAIL(\"No error message found\");\n        }\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_DesignConfigurationValidator::testHasValidGeneratorChainConfigurations_data()\n//-----------------------------------------------------------------------------\nvoid tst_DesignConfigurationValidator::testHasValidGeneratorChainConfigurations_data()\n{\n    QTest::addColumn<bool>(\"referenceExists\");\n    QTest::addColumn<QString>(\"vendor\");\n    QTest::addColumn<QString>(\"library\");\n    QTest::addColumn<QString>(\"name\");\n    QTest::addColumn<QString>(\"version\");\n    QTest::addColumn<bool>(\"copyChain\");\n    QTest::addColumn<bool>(\"isValid\");\n\n    QTest::newRow(\"Design configuration without generator chains is valid\") <<\n        false << \"\" << \"\" << \"\" << \"\" << false << true;\n    QTest::newRow(\"Generator chain with VLNV is valid\") <<\n        true << \"Evangelion\" << \"Shin\" << \"Geki\" << \"jouban\" << false << true;\n\n    QTest::newRow(\"Generator chain without vendor is not valid\") <<\n        true << \"\" << \"Shin\" << \"Geki\" << \"jouban\" << false << false;\n    QTest::newRow(\"Generator chain without library is not valid\") <<\n        true << \"Evangelion\" << \"\" << \"Geki\" << \"jouban\" << false << false;\n    QTest::newRow(\"Generator chain without name is not valid\") <<\n        true << \"Evangelion\" << \"Shin\" << \"\" << \"jouban\" << false << false;\n    QTest::newRow(\"Generator chain without version is not valid\") <<\n        true << \"Evangelion\" << \"Shin\" << \"Geki\" << \"\" << false << false;\n    \n    QTest::newRow(\"Generator chains referencing the same generator chain is not valid\") <<\n        true << \"Evangelion\" << \"Shin\" << \"Geki\" << \"jouban\" << true << false;\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_DesignConfigurationValidator::testInterconnectionConfigurationHasValidInterconnectionReference()\n//-----------------------------------------------------------------------------\nvoid tst_DesignConfigurationValidator::testInterconnectionConfigurationHasValidInterconnectionReference()\n{\n    QFETCH(QString, interconnectionName);\n    QFETCH(bool, referenceOk);\n    QFETCH(bool, isValid);\n\n    QSharedPointer<Design> testDesign (new Design(VLNV(VLNV::DESIGN, \"vendor\", \"library\", \"design\", \"1\"),\n        Document::Revision::Std14));\n\n    QSharedPointer<InterconnectionConfiguration> testConfiguration (new InterconnectionConfiguration());\n    testConfiguration->setInterconnectionReference(interconnectionName);\n    \n    if (referenceOk)\n    {\n        QSharedPointer<Interconnection> testConnection (new Interconnection());\n\n        if (interconnectionName.isEmpty())\n        {\n            testConnection->setName(\"Champloo\");\n        }\n        else\n        {\n            testConnection->setName(interconnectionName);\n        }\n\n        testDesign->getInterconnections()->append(testConnection);\n    }\n\n    QSharedPointer<InterconnectionConfigurationValidator> validator =\n        createInterconnectionConfigurationValidator(0);\n    validator->designChanged(testDesign);\n\n    QCOMPARE(validator->hasValidInterconnectionReference(testConfiguration), isValid);\n\n    if (!isValid)\n    {\n        QVector<QString> foundErrors;\n        validator->findErrorsIn(foundErrors, testConfiguration, \"test\");\n\n        QString expectedError = QObject::tr(\"Invalid interconnection reference '%1' given for interconnection \"\n            \"configuration within %2.\")\n            .arg(interconnectionName).arg(\"test\");\n\n        if (errorIsNotFoundInErrorList(expectedError, foundErrors))\n        {\n            QFAIL(\"No error message found\");\n        }\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_DesignConfigurationValidator::testInterconnectionConfigurationHasValidInterconnectionReference_data()\n//-----------------------------------------------------------------------------\nvoid tst_DesignConfigurationValidator::testInterconnectionConfigurationHasValidInterconnectionReference_data()\n{\n    QTest::addColumn<QString>(\"interconnectionName\");\n    QTest::addColumn<bool>(\"referenceOk\");\n    QTest::addColumn<bool>(\"isValid\");\n\n    QTest::newRow(\"Interconnection configuration referencing existing interconnection is valid\") <<\n        \"Baldur\" << true << true;\n    QTest::newRow(\"Empty interconnection reference is not valid\") << \"\" << true << false;\n    QTest::newRow(\"Interconnection configuration referencing a non-existing interconnection is not valid\") <<\n        \"Baldur\" << false << false;\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_DesignConfigurationValidator::testInterconnectionConfigurationHasValidIsPresent()\n//-----------------------------------------------------------------------------\nvoid tst_DesignConfigurationValidator::testInterconnectionConfigurationHasValidIsPresent()\n{\n    QFETCH(QString, isPresent);\n    QFETCH(bool, isValid);\n\n    QSharedPointer<InterconnectionConfiguration> testConfiguration (new InterconnectionConfiguration());\n    testConfiguration->setInterconnectionReference(\"deCarabas\");\n    testConfiguration->setIsPresent(isPresent);\n\n    QSharedPointer<InterconnectionConfigurationValidator> validator =\n        createInterconnectionConfigurationValidator(0);\n\n    QCOMPARE(validator->hasValidIsPresent(testConfiguration->getIsPresent()), isValid);\n\n    if (!isValid)\n    {\n        QVector<QString> foundErrors;\n        validator->findErrorsIn(foundErrors, testConfiguration, \"test\");\n\n        QString expectedError = QObject::tr(\"Invalid isPresent set for interconnection configuration %1 within %2\")\n            .arg(testConfiguration->getInterconnectionReference()).arg(\"test\");\n\n        if (errorIsNotFoundInErrorList(expectedError, foundErrors))\n        {\n            QFAIL(\"No error message found\");\n        }\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_DesignConfigurationValidator::testInterconnectionConfigurationHasValidIsPresent_data()\n//-----------------------------------------------------------------------------\nvoid tst_DesignConfigurationValidator::testInterconnectionConfigurationHasValidIsPresent_data()\n{\n    QTest::addColumn<QString>(\"isPresent\");\n    QTest::addColumn<bool>(\"isValid\");\n\n    QTest::newRow(\"IsPresent 1 is valid\") << \"1\" << true;\n    QTest::newRow(\"IsPresent 1*3-3 is valid\") << \"1*3-3\" << true;\n    QTest::newRow(\"IsPresent 2*100 is invalid\") << \"2*100\" << false;\n    QTest::newRow(\"IsPresent -14 is invalid\") << \"-14\" << false;\n    QTest::newRow(\"Real number isPresent  0.12 is invalid\") << \"0.12\" << false;\n    QTest::newRow(\"Text as isPresent is invalid\") << \"test\" << false;\n    QTest::newRow(\"String as isPresent is invalid\") << \"\\\"test\\\"\" << false;\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_DesignConfigurationValidator::testInterconnectionConfigurationHasValidAbstractorInstance()\n//-----------------------------------------------------------------------------\nvoid tst_DesignConfigurationValidator::testInterconnectionConfigurationHasValidAbstractorInstance()\n{\n    QFETCH(QString, instanceName);\n    QFETCH(QString, abstractorVendor);\n    QFETCH(QString, abstractorLibrary);\n    QFETCH(QString, abstractorName);\n    QFETCH(QString, abstractorVersion);\n    QFETCH(QString, viewName);\n    QFETCH(bool, copyInstance);\n    QFETCH(bool, isValid);\n\n    QSharedPointer<ConfigurableVLNVReference> abstractorRef (new ConfigurableVLNVReference(\n        VLNV::ABSTRACTOR, abstractorVendor, abstractorLibrary, abstractorName, abstractorVersion));\n\n    QSharedPointer<AbstractorInstance> testInstance (new AbstractorInstance());\n    testInstance->setInstanceName(instanceName);\n    testInstance->setAbstractorRef(abstractorRef);\n    testInstance->setViewName(viewName);\n\n    QSharedPointer<MultipleAbstractorInstances> testMultipleInstance (new MultipleAbstractorInstances());\n    testMultipleInstance->getAbstractorInstances()->append(testInstance);\n\n    if (copyInstance)\n    {\n        QSharedPointer<AbstractorInstance> otherInstance (new AbstractorInstance(*testInstance.data()));\n        testMultipleInstance->getAbstractorInstances()->append(otherInstance);\n    }\n\n    QSharedPointer<InterconnectionConfiguration> testConfiguration (new InterconnectionConfiguration());\n    testConfiguration->setInterconnectionReference(\"Samurai\");\n    testConfiguration->getAbstractorInstances()->append(testMultipleInstance);\n\n    QSharedPointer<InterconnectionConfigurationValidator> validator =\n        createInterconnectionConfigurationValidator(0);\n\n    QCOMPARE(validator->hasValidMultipleAbstractorInstances(testConfiguration), isValid);\n\n    if (!isValid)\n    {\n        QVector<QString> foundErrors;\n        validator->findErrorsIn(foundErrors, testConfiguration, \"test\");\n\n        QString expectedError = QObject::tr(\"Invalid instance name '%1' set for abstractor instance within \"\n            \"interconnection configuration %2\")\n            .arg(instanceName).arg(testConfiguration->getInterconnectionReference());\n\n        if (abstractorVendor.isEmpty())\n        {\n            expectedError = QObject::tr(\"No vendor specified for vlnv within abstractor instance %1\").\n                arg(instanceName);\n        }\n        else if (abstractorLibrary.isEmpty())\n        {\n            expectedError = QObject::tr(\"No library specified for vlnv within abstractor instance %1\").\n                arg(instanceName);\n        }\n        else if (abstractorName.isEmpty())\n        {\n            expectedError = QObject::tr(\"No name specified for vlnv within abstractor instance %1\").\n                arg(instanceName);\n        }\n        else if (abstractorVersion.isEmpty())\n        {\n            expectedError = QObject::tr(\"No version specified for vlnv within abstractor instance %1\").\n                arg(instanceName);\n        }\n        else if (viewName.isEmpty())\n        {\n            expectedError = QObject::tr(\"Invalid view name '%1' set for abstractor instance %2 within \"\n                \"interconnection configuration %3\")\n                .arg(viewName).arg(instanceName).arg(testConfiguration->getInterconnectionReference());\n        }\n        else if (copyInstance)\n        {\n            expectedError = QObject::tr(\"Abstractor instance name '%1' within interconnection configuration %2 is \"\n                \"not unique.\")\n                .arg(instanceName).arg(testConfiguration->getInterconnectionReference());\n        }\n\n        if (errorIsNotFoundInErrorList(expectedError, foundErrors))\n        {\n            QFAIL(\"No error message found\");\n        }\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_DesignConfigurationValidator::testInterconnectionConfigurationHasValidAbstractorInstance_data()\n//-----------------------------------------------------------------------------\nvoid tst_DesignConfigurationValidator::testInterconnectionConfigurationHasValidAbstractorInstance_data()\n{\n    QTest::addColumn<QString>(\"instanceName\");\n    QTest::addColumn<QString>(\"abstractorVendor\");\n    QTest::addColumn<QString>(\"abstractorLibrary\");\n    QTest::addColumn<QString>(\"abstractorName\");\n    QTest::addColumn<QString>(\"abstractorVersion\");\n    QTest::addColumn<QString>(\"viewName\");\n    QTest::addColumn<bool>(\"copyInstance\");\n    QTest::addColumn<bool>(\"isValid\");\n\n    QTest::newRow(\"Abstractor instance with name, abstractor reference and view name is valid\") <<\n        \"Infinity\" << \"Yu-Jing\" << \"JSA\" << \"O-yoroi\" << \"Kidobutai\" << \"HMG\" << false << true;\n    QTest::newRow(\"Abstractor instance without name is not valid\") <<\n        \"\" << \"Yu-Jing\" << \"JSA\" << \"O-yoroi\" << \"Kidobutai\" << \"HMG\" << false << false;\n\n    QTest::newRow(\"Abstractor instance without referenced abstractor vendor is not valid\") <<\n        \"Infinity\" << \"\" << \"JSA\" << \"O-yoroi\" << \"Kidobutai\" << \"HMG\" << false << false;\n    QTest::newRow(\"Abstractor instance without referenced abstractor library is not valid\") <<\n        \"Infinity\" << \"Yu-Jing\" << \"\" << \"O-yoroi\" << \"Kidobutai\" << \"HMG\" << false << false;\n    QTest::newRow(\"Abstractor instance without referenced abstractor name is not valid\") <<\n        \"Infinity\" << \"Yu-Jing\" << \"JSA\" << \"\" << \"Kidobutai\" << \"HMG\" << false << false;\n    QTest::newRow(\"Abstractor instance without referenced abstractor version is not valid\") <<\n        \"Infinity\" << \"Yu-Jing\" << \"JSA\" << \"O-yoroi\" << \"\" << \"HMG\" << false << false;\n\n    QTest::newRow(\"Abstractor instance without view name is not valid\") <<\n        \"Infinity\" << \"Yu-Jing\" << \"JSA\" << \"O-yoroi\" << \"Kidobutai\" << \"\" << false << false;\n\n    QTest::newRow(\"Abstractor instance with non-unique instance name is not valid\") <<\n        \"Infinity\" << \"Yu-Jing\" << \"JSA\" << \"O-yoroi\" << \"Kidobutai\" << \"HMG\" << true << false;\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_DesignConfigurationValidator::testInterconnectionConfigurationHasValidAbstractorIsPresent()\n//-----------------------------------------------------------------------------\nvoid tst_DesignConfigurationValidator::testInterconnectionConfigurationHasValidAbstractorIsPresent()\n{\n    QFETCH(QString, isPresent);\n    QFETCH(bool, isValid);\n\n    QSharedPointer<ConfigurableVLNVReference> abstractorRef (new ConfigurableVLNVReference(VLNV::ABSTRACTOR,\n        QLatin1String(\"Yu-Jing\"), QLatin1String(\"JSA\"), QLatin1String(\"O-yoroi\"), QLatin1String(\"Kidobutai\")));\n\n    QSharedPointer<AbstractorInstance> testInstance (new AbstractorInstance());\n    testInstance->setInstanceName(\"Infinity\");\n    testInstance->setAbstractorRef(abstractorRef);\n    testInstance->setViewName(\"HMG\");\n\n    QSharedPointer<MultipleAbstractorInstances> testMultipleInstance (new MultipleAbstractorInstances());\n    testMultipleInstance->getAbstractorInstances()->append(testInstance);\n    testMultipleInstance->setIsPresent(isPresent);\n\n    QSharedPointer<InterconnectionConfiguration> testConfiguration (new InterconnectionConfiguration());\n    testConfiguration->setInterconnectionReference(\"Samurai\");\n    testConfiguration->getAbstractorInstances()->append(testMultipleInstance);\n\n    QSharedPointer<InterconnectionConfigurationValidator> validator =\n        createInterconnectionConfigurationValidator(0);\n\n    QCOMPARE(validator->hasValidMultipleAbstractorInstances(testConfiguration), isValid);\n\n    if (!isValid)\n    {\n        QVector<QString> foundErrors;\n        validator->findErrorsIn(foundErrors, testConfiguration, \"test\");\n\n        QString expectedError = QObject::tr(\"Invalid isPresent set for abstractor instance group within \"\n            \"interconnection configuration %1\").arg(testConfiguration->getInterconnectionReference());\n\n        if (errorIsNotFoundInErrorList(expectedError, foundErrors))\n        {\n            QFAIL(\"No error message found\");\n        }\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_DesignConfigurationValidator::testInterconnectionConfigurationHasValidAbstractorIsPresent_data()\n//-----------------------------------------------------------------------------\nvoid tst_DesignConfigurationValidator::testInterconnectionConfigurationHasValidAbstractorIsPresent_data()\n{\n    QTest::addColumn<QString>(\"isPresent\");\n    QTest::addColumn<bool>(\"isValid\");\n\n    QTest::newRow(\"IsPresent 1 is valid\") << \"1\" << true;\n    QTest::newRow(\"IsPresent 1*3-3 is valid\") << \"1*3-3\" << true;\n    QTest::newRow(\"IsPresent 2*100 is invalid\") << \"2*100\" << false;\n    QTest::newRow(\"IsPresent -14 is invalid\") << \"-14\" << false;\n    QTest::newRow(\"Real number isPresent  0.12 is invalid\") << \"0.12\" << false;\n    QTest::newRow(\"Text as isPresent is invalid\") << \"test\" << false;\n    QTest::newRow(\"String as isPresent is invalid\") << \"\\\"test\\\"\" << false;\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_DesignConfigurationValidator::testInterconnectionConfigurationHasValidInterfaceReference()\n//-----------------------------------------------------------------------------\nvoid tst_DesignConfigurationValidator::testInterconnectionConfigurationHasValidInterfaceReference()\n{\n    QFETCH(bool, interfaceRefExists);\n    QFETCH(QString, componentReference);\n    QFETCH(bool, componentInstanceExists);\n    QFETCH(QString, busReference);\n    QFETCH(bool, busInterfaceExists);\n    QFETCH(bool, isValid);\n\n    QSharedPointer<Design> testDesign (new Design(VLNV(VLNV::DESIGN, \"vendor\", \"library\", \"design\", \"version\"),\n        Document::Revision::Std14));\n\n    QSharedPointer<ConfigurableVLNVReference> abstractorRef (new ConfigurableVLNVReference(VLNV::ABSTRACTOR,\n        QLatin1String(\"Yu-Jing\"), QLatin1String(\"JSA\"), QLatin1String(\"O-yoroi\"), QLatin1String(\"Kidobutai\")));\n\n    QSharedPointer<AbstractorInstance> testInstance (new AbstractorInstance());\n    testInstance->setInstanceName(\"Infinity\");\n    testInstance->setAbstractorRef(abstractorRef);\n    testInstance->setViewName(\"HMG\");\n\n    QSharedPointer<MultipleAbstractorInstances> testMultipleInstance (new MultipleAbstractorInstances());\n    testMultipleInstance->getAbstractorInstances()->append(testInstance);\n\n    if (interfaceRefExists)\n    {\n        QSharedPointer<InterfaceRef> interfaceReference (new InterfaceRef());\n        interfaceReference->setComponentRef(componentReference);\n        interfaceReference->setBusRef(busReference);\n\n        testMultipleInstance->getInterfaceReferences()->append(interfaceReference);\n    }\n\n    QSharedPointer<ConfigurableVLNVReference> componentVLNV (\n        new ConfigurableVLNVReference(VLNV::COMPONENT, \"Baldurs\", \"Gate\", \"Shadows\", \"Amn\"));\n\n    if (componentInstanceExists)\n    {\n        QSharedPointer<ComponentInstance> componentInstance (\n            new ComponentInstance(componentReference, componentVLNV));\n\n        testDesign->getComponentInstances()->append(componentInstance);\n    }\n\n    LibraryMock* mockLibrary (new LibraryMock(this));\n\n    if (busInterfaceExists)\n    {\n        QSharedPointer<BusInterface> testInterface (new BusInterface());\n        testInterface->setName(busReference);\n\n        QSharedPointer<Component> testComponent (new Component(*componentVLNV, Document::Revision::Std14));\n        testComponent->getBusInterfaces()->append(testInterface);\n\n        mockLibrary->addComponent(testComponent);\n    }\n\n    QSharedPointer<InterconnectionConfiguration> testConfiguration (new InterconnectionConfiguration());\n    testConfiguration->setInterconnectionReference(\"Samurai\");\n    testConfiguration->getAbstractorInstances()->append(testMultipleInstance);\n\n    QSharedPointer<InterconnectionConfigurationValidator> validator =\n        createInterconnectionConfigurationValidator(mockLibrary);\n    validator->designChanged(testDesign);\n\n    QCOMPARE(validator->hasValidMultipleAbstractorInstances(testConfiguration), isValid);\n\n    if (!isValid)\n    {\n        QVector<QString> foundErrors;\n        validator->findErrorsIn(foundErrors, testConfiguration, \"test\");\n\n        QString expectedError = QObject::tr(\"Invalid component instance reference '%1' set for abstractor \"\n            \"instance group within interconnection configuration %2\")\n            .arg(componentReference).arg(testConfiguration->getInterconnectionReference());\n\n        if (busReference.isEmpty() || !busInterfaceExists)\n        {\n            expectedError = QObject::tr(\"Invalid bus interface reference '%1' set for abstractor \"\n                \"instance group within interconnection configuration %2\")\n                .arg(busReference).arg(testConfiguration->getInterconnectionReference());\n        }\n\n        if (errorIsNotFoundInErrorList(expectedError, foundErrors))\n        {\n            QFAIL(\"No error message found\");\n        }\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_DesignConfigurationValidator::testInterconnectionConfigurationHasValidInterfaceReference_data()\n//-----------------------------------------------------------------------------\nvoid tst_DesignConfigurationValidator::testInterconnectionConfigurationHasValidInterfaceReference_data()\n{\n    QTest::addColumn<bool>(\"interfaceRefExists\");\n    QTest::addColumn<QString>(\"componentReference\");\n    QTest::addColumn<bool>(\"componentInstanceExists\");\n    QTest::addColumn<QString>(\"busReference\");\n    QTest::addColumn<bool>(\"busInterfaceExists\");\n    QTest::addColumn<bool>(\"isValid\");\n\n    QTest::newRow(\"Non-existing interface reference is valid\") <<\n        false << \"\" << false << \"\" << false << true;\n    QTest::newRow(\"Interface reference with component and bus reference is valid\") <<\n        true << \"Space\" << true << \"Dandy\" << true << true;\n\n    QTest::newRow(\"Interface reference without component reference is not valid\") <<\n        true << \"\" << true << \"Dandy\" << true << false;\n    QTest::newRow(\"Interface reference with component reference to non-existing instance is not valid\") <<\n        true << \"Space\" << false << \"Dandy\" << true << false;\n    QTest::newRow(\"Interface reference without bus reference is not valid\") <<\n        true << \"Space\" << true << \"\" << true << false;\n    QTest::newRow(\"Interface reference with bus reference to non-existing bus is not valid\") <<\n        true << \"Space\" << true << \"Dandy\" << false << false;\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_DesignConfigurationValidator::testInterconnectionConfigurationInterfaceHasValidIsPresent()\n//-----------------------------------------------------------------------------\nvoid tst_DesignConfigurationValidator::testInterconnectionConfigurationInterfaceHasValidIsPresent()\n{\n    QFETCH(QString, isPresent);\n    QFETCH(bool, isValid);\n\n    QSharedPointer<Design> testDesign (new Design(VLNV(VLNV::DESIGN, \"Guilty\", \"Gear\", \"Heavy\", \"day\"),\n        Document::Revision::Std14));\n\n    QSharedPointer<ConfigurableVLNVReference> abstractorRef (new ConfigurableVLNVReference(VLNV::ABSTRACTOR,\n        QLatin1String(\"Yu-Jing\"), QLatin1String(\"JSA\"), QLatin1String(\"O-yoroi\"), QLatin1String(\"Kidobutai\")));\n\n    QSharedPointer<AbstractorInstance> testInstance (new AbstractorInstance());\n    testInstance->setInstanceName(\"Infinity\");\n    testInstance->setAbstractorRef(abstractorRef);\n    testInstance->setViewName(\"HMG\");\n\n    QSharedPointer<MultipleAbstractorInstances> testMultipleInstance (new MultipleAbstractorInstances());\n    testMultipleInstance->getAbstractorInstances()->append(testInstance);\n\n    QSharedPointer<InterfaceRef> interfaceReference (new InterfaceRef());\n    interfaceReference->setComponentRef(QLatin1String(\"Space\"));\n    interfaceReference->setBusRef(QLatin1String(\"Dandy\"));\n    interfaceReference->setIsPresent(isPresent);\n\n    testMultipleInstance->getInterfaceReferences()->append(interfaceReference);\n\n    QSharedPointer<ConfigurableVLNVReference> componentVLNV (\n        new ConfigurableVLNVReference(VLNV::COMPONENT, \"Vendor\", \"Library\", \"Name\", \"Version\"));\n\n    QSharedPointer<ComponentInstance> componentInstance (\n        new ComponentInstance(interfaceReference->getComponentRef(), componentVLNV));\n\n    testDesign->getComponentInstances()->append(componentInstance);\n\n    QSharedPointer<BusInterface> testInterface (new BusInterface());\n    testInterface->setName(interfaceReference->getBusRef());\n\n    QSharedPointer<Component> testComponent (new Component(*componentVLNV, Document::Revision::Std14));\n    testComponent->getBusInterfaces()->append(testInterface);\n\n    QSharedPointer<InterconnectionConfiguration> testConfiguration (new InterconnectionConfiguration());\n    testConfiguration->setInterconnectionReference(\"Samurai\");\n    testConfiguration->getAbstractorInstances()->append(testMultipleInstance);\n\n    LibraryMock* mockLibrary (new LibraryMock(this));\n    mockLibrary->addComponent(testComponent);\n\n    QSharedPointer<InterconnectionConfigurationValidator> validator =\n        createInterconnectionConfigurationValidator(mockLibrary);\n    validator->designChanged(testDesign);\n\n    QCOMPARE(validator->hasValidMultipleAbstractorInstances(testConfiguration), isValid);\n\n    if (!isValid)\n    {\n        QVector<QString> foundErrors;\n        validator->findErrorsIn(foundErrors, testConfiguration, \"test\");\n\n        QString expectedError = QObject::tr(\"Invalid isPresent set for interface reference in abstractor instance \"\n            \"group within interconnection configuration %1\")\n            .arg(testConfiguration->getInterconnectionReference());\n\n        if (errorIsNotFoundInErrorList(expectedError, foundErrors))\n        {\n            QFAIL(\"No error message found\");\n        }\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_DesignConfigurationValidator::testInterconnectionConfigurationInterfaceHasValidIsPresent_data()\n//-----------------------------------------------------------------------------\nvoid tst_DesignConfigurationValidator::testInterconnectionConfigurationInterfaceHasValidIsPresent_data()\n{\n    QTest::addColumn<QString>(\"isPresent\");\n    QTest::addColumn<bool>(\"isValid\");\n\n    QTest::newRow(\"IsPresent 1 is valid\") << \"1\" << true;\n    QTest::newRow(\"IsPresent 1*3-3 is valid\") << \"1*3-3\" << true;\n    QTest::newRow(\"IsPresent 2*100 is invalid\") << \"2*100\" << false;\n    QTest::newRow(\"IsPresent -14 is invalid\") << \"-14\" << false;\n    QTest::newRow(\"Real number isPresent  0.12 is invalid\") << \"0.12\" << false;\n    QTest::newRow(\"Text as isPresent is invalid\") << \"test\" << false;\n    QTest::newRow(\"String as isPresent is invalid\") << \"\\\"test\\\"\" << false;\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_DesignConfigurationValidator::testHasValidInterconnectionConfigurations()\n//-----------------------------------------------------------------------------\nvoid tst_DesignConfigurationValidator::testHasValidInterconnectionConfigurations()\n{\n    QFETCH(bool, createInterconncetionConfiguration);\n    QFETCH(bool, interconnectionReferenceExists);\n    QFETCH(bool, copyInterconnectionConfiguration);\n    QFETCH(bool, multipleAbstractorInstanceExists);\n    QFETCH(bool, abstractorInstanceExists);\n    QFETCH(bool, isValid);\n\n    LibraryMock* mockLibrary (new LibraryMock(this));\n\n    VLNV designVLNV (VLNV::DESIGN, \"Guilty\", \"Gear\", \"Xrd\", \"Revelator\");\n\n    QSharedPointer<Design> testDesign (new Design(designVLNV, Document::Revision::Std14));\n    mockLibrary->addComponent(testDesign);\n\n    QSharedPointer<DesignConfiguration> testConfiguration (new DesignConfiguration(\n        VLNV(VLNV::DESIGNCONFIGURATION, \"Samurai\", \"Champloo\", \"MugenJinFuu\", \"3.0\"), Document::Revision::Std14));\n    testConfiguration->setDesignRef(designVLNV);\n\n    QSharedPointer<InterconnectionConfiguration> interconnectionConfiguration (new InterconnectionConfiguration());\n\n    if (createInterconncetionConfiguration)\n    {\n        if (interconnectionReferenceExists)\n        {\n            interconnectionConfiguration->setInterconnectionReference(QLatin1String(\"Evangelion\"));\n            QSharedPointer<Interconnection> interconnection (new Interconnection());\n            interconnection->setName(interconnectionConfiguration->getInterconnectionReference());\n\n            testDesign->getInterconnections()->append(interconnection);\n        }\n\n        if (multipleAbstractorInstanceExists)\n        {\n            QSharedPointer<MultipleAbstractorInstances> multipleInstance (new MultipleAbstractorInstances());\n            interconnectionConfiguration->getAbstractorInstances()->append(multipleInstance);\n\n            if (abstractorInstanceExists)\n            {\n                QSharedPointer<ConfigurableVLNVReference> abstractorRef (new ConfigurableVLNVReference(\n                    VLNV::ABSTRACTOR, QLatin1String(\"Tengen\"), QLatin1String(\"Toppa\"),\n                    QLatin1String(\"Gurren\"), QLatin1String(\"Lagann\")));\n\n                QSharedPointer<AbstractorInstance> testInstance (new AbstractorInstance());\n                testInstance->setInstanceName(\"Space\");\n                testInstance->setAbstractorRef(abstractorRef);\n                testInstance->setViewName(\"Dandy\");\n\n                multipleInstance->getAbstractorInstances()->append(testInstance);\n            }\n        }\n\n        testConfiguration->getInterconnectionConfs()->append(interconnectionConfiguration);\n\n        if (copyInterconnectionConfiguration)\n        {\n            QSharedPointer<InterconnectionConfiguration> otherConfiguration (\n                new InterconnectionConfiguration(*interconnectionConfiguration.data()));\n            testConfiguration->getInterconnectionConfs()->append(otherConfiguration);\n        }\n    }\n\n    QSharedPointer<DesignConfigurationValidator> validator = createDesignConfigurationValidator(mockLibrary);\n\n    QCOMPARE(validator->hasValidInterconnectionConfigurations(testConfiguration), isValid);\n\n    if (!isValid)\n    {\n        QVector<QString> foundErrors;\n        validator->findErrorsIn(foundErrors, testConfiguration);\n\n        QString expectedError = QObject::tr(\"Invalid interconnection reference '%1' given for interconnection \"\n            \"configuration within design configuration %2.\")\n            .arg(interconnectionConfiguration->getInterconnectionReference())\n            .arg(testConfiguration->getVlnv().toString());\n\n        if (copyInterconnectionConfiguration)\n        {\n            expectedError = QObject::tr(\"Interconnection reference '%1' set for interconnection configuration \"\n                \"within design configuration %2 is not unique.\")\n                .arg(interconnectionConfiguration->getInterconnectionReference())\n                .arg(testConfiguration->getVlnv().toString());\n        }\n        else if (!multipleAbstractorInstanceExists)\n        {\n            expectedError = QObject::tr(\"No abstractor instances found in interconnection configuration '%1' \"\n                \"within design configuration %2\")\n                .arg(interconnectionConfiguration->getInterconnectionReference())\n                .arg(testConfiguration->getVlnv().toString());\n        }\n        else if (!abstractorInstanceExists)\n        {\n            expectedError = QObject::tr(\"No abstractor instances found in abstractor instance group within \"\n                \"interconnection configuration %2\")\n                .arg(interconnectionConfiguration->getInterconnectionReference());\n        }\n\n        if (errorIsNotFoundInErrorList(expectedError, foundErrors))\n        {\n            QFAIL(\"No error message found\");\n        }\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_DesignConfigurationValidator::testHasValidInterconnectionConfigurations_data()\n//-----------------------------------------------------------------------------\nvoid tst_DesignConfigurationValidator::testHasValidInterconnectionConfigurations_data()\n{\n    QTest::addColumn<bool>(\"createInterconncetionConfiguration\");\n    QTest::addColumn<bool>(\"interconnectionReferenceExists\");\n    QTest::addColumn<bool>(\"copyInterconnectionConfiguration\");\n    QTest::addColumn<bool>(\"multipleAbstractorInstanceExists\");\n    QTest::addColumn<bool>(\"abstractorInstanceExists\");\n    QTest::addColumn<bool>(\"isValid\");\n\n    QTest::newRow(\"Design configuration without interconnection configurations is valid\") <<\n        false << false << false << false << false << true;\n    QTest::newRow(\"Configuration with interconnection reference and abstractor instance is valid\") <<\n        true << true << false << true << true << true;\n\n    QTest::newRow(\"Configuration without interconnection reference is not valid\") <<\n        true << false << false << true << true << false;\n    QTest::newRow(\"Configurations with non-unique interconnection reference is not valid\") <<\n        true << true << true << true << true << false;\n    QTest::newRow(\"Configuration without multiple abstractor instances is not valid\") << \n        true << true << false << false << false << false;\n    QTest::newRow(\"Configuration without abstractor instance is not valid\") <<\n        true << true << false << true << false << false;\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_DesignConfigurationValidator::testViewConfigurationHasValidName()\n//-----------------------------------------------------------------------------\nvoid tst_DesignConfigurationValidator::testViewConfigurationHasValidName()\n{\n    QFETCH(QString, name);\n    QFETCH(bool, isValid);\n\n    QSharedPointer<ComponentInstance> testInstance (new ComponentInstance());\n    testInstance->setInstanceName(name);\n\n    QSharedPointer<QList<QSharedPointer<ComponentInstance> > > instances\n        (new QList<QSharedPointer<ComponentInstance> > ());\n    instances->append(testInstance);\n\n    QSharedPointer<ViewConfiguration> testConfiguration (new ViewConfiguration(name));\n\n    QSharedPointer<ViewConfigurationValidator> validator =\n        createViewConfigurationValidator(0);\n    validator->changeComponentInstances(instances);\n\n    QCOMPARE(validator->hasValidName(testConfiguration), isValid);\n\n    if (!isValid)\n    {\n        QVector<QString> foundErrors;\n        validator->findErrorsIn(foundErrors, testConfiguration, \"test\");\n\n        QString expectedError = QObject::tr(\"Invalid name '%1' set for view configuration within %2\")\n            .arg(name).arg(\"test\");\n\n        if (errorIsNotFoundInErrorList(expectedError, foundErrors))\n        {\n            QFAIL(\"No error message found\");\n        }\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_DesignConfigurationValidator::testViewConfigurationHasValidName_data()\n//-----------------------------------------------------------------------------\nvoid tst_DesignConfigurationValidator::testViewConfigurationHasValidName_data()\n{\n    QTest::addColumn<QString>(\"name\");\n    QTest::addColumn<bool>(\"isValid\");\n\n    QTest::newRow(\"Name test is valid\") << \"test\" << true;\n    QTest::newRow(\"Empty name is invalid\") << \"\" << false;\n    QTest::newRow(\"Name consisting of only white spaces is invalid\") << \"    \" << false;\n    QTest::newRow(\"Name consisting of characters and white spaces is invalid\") << \"  test  \" << false;\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_DesignConfigurationValidator::testViewConfigurationHasValidIsPresent()\n//-----------------------------------------------------------------------------\nvoid tst_DesignConfigurationValidator::testViewConfigurationHasValidIsPresent()\n{\n    QFETCH(QString, isPresent);\n    QFETCH(bool, isValid);\n\n    QSharedPointer<ViewConfiguration> testConfiguration (new ViewConfiguration(\"Karasu\"));\n    testConfiguration->setIsPresent(isPresent);\n\n    QSharedPointer<ViewConfigurationValidator> validator =\n        createViewConfigurationValidator(0);\n\n    QCOMPARE(validator->hasValidIsPresent(testConfiguration), isValid);\n\n    if (!isValid)\n    {\n        QVector<QString> foundErrors;\n        validator->findErrorsIn(foundErrors, testConfiguration, \"test\");\n\n        QString expectedError = QObject::tr(\"Invalid isPresent set for view configuration %1 within %2\")\n            .arg(testConfiguration->getInstanceName()).arg(\"test\");\n\n        if (errorIsNotFoundInErrorList(expectedError, foundErrors))\n        {\n            QFAIL(\"No error message found\");\n        }\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_DesignConfigurationValidator::testViewConfigurationHasValidIsPresent_data()\n//-----------------------------------------------------------------------------\nvoid tst_DesignConfigurationValidator::testViewConfigurationHasValidIsPresent_data()\n{\n    QTest::addColumn<QString>(\"isPresent\");\n    QTest::addColumn<bool>(\"isValid\");\n\n    QTest::newRow(\"IsPresent 1 is valid\") << \"1\" << true;\n    QTest::newRow(\"IsPresent 1*3-3 is valid\") << \"1*3-3\" << true;\n    QTest::newRow(\"IsPresent 2*100 is invalid\") << \"2*100\" << false;\n    QTest::newRow(\"IsPresent -14 is invalid\") << \"-14\" << false;\n    QTest::newRow(\"Real number isPresent  0.12 is invalid\") << \"0.12\" << false;\n    QTest::newRow(\"Text as isPresent is invalid\") << \"test\" << false;\n    QTest::newRow(\"String as isPresent is invalid\") << \"\\\"test\\\"\" << false;\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_DesignConfigurationValidator::testViewConfigurationHasValidViewReference()\n//-----------------------------------------------------------------------------\nvoid tst_DesignConfigurationValidator::testViewConfigurationHasValidViewReference()\n{\n    QFETCH(QString, viewReference);\n    QFETCH(bool, viewExists);\n    QFETCH(bool, isValid);\n\n    LibraryMock* mockLibrary (new LibraryMock(this));\n\n    QSharedPointer<ViewConfiguration> testConfiguration (new ViewConfiguration(\"Karasu\"));\n    testConfiguration->setViewReference(viewReference);\n    testConfiguration->setInstanceName(\"instantKill\");\n\n\tQSharedPointer<ViewConfiguration> testSWConfiguration (new ViewConfiguration(\"SwViewConfiguration\"));\n\ttestSWConfiguration->setViewReference(viewReference);\n\ttestSWConfiguration->setInstanceName(\"swUser\");\n\n    QSharedPointer<QList<QSharedPointer<ComponentInstance> > > instances\n        (new QList<QSharedPointer<ComponentInstance> > ());\n\n    if (viewExists)\n    {\n\t\tQSharedPointer<View> testView (new View(viewReference));\n        if (viewReference.isEmpty())\n        {\n\t\t\ttestView->setName(\"Champloo\");\n        }\n\n        QSharedPointer<ConfigurableVLNVReference> componentVLNV\n            (new ConfigurableVLNVReference(VLNV(VLNV::COMPONENT, \"vendor\", \"library\", \"testComponent\", \"1\")));\n\n        QSharedPointer<Component> testComponent (new Component(*componentVLNV, Document::Revision::Std14));\n\t\ttestComponent->getViews()->append(testView);\n\n        mockLibrary->addComponent(testComponent);\n\n        QSharedPointer<ComponentInstance> testInstance (\n            new ComponentInstance(testConfiguration->getInstanceName(), componentVLNV));\n\n\t\tinstances->append(testInstance);\n\n\t\tQSharedPointer<ComponentInstance> testSWInstance (\n\t\t\tnew ComponentInstance(testSWConfiguration->getInstanceName(), componentVLNV));\n\n\t\tinstances->append(testSWInstance);\n    }\n\n    QSharedPointer<ViewConfigurationValidator> validator = createViewConfigurationValidator(mockLibrary);\n    validator->changeComponentInstances(instances);\n\n\tQCOMPARE(validator->hasValidViewReference(testConfiguration), isValid);\n\tQCOMPARE(validator->hasValidViewReference(testSWConfiguration), isValid);\n\n    if (!isValid)\n    {\n        QVector<QString> foundErrors;\n\t\tvalidator->findErrorsIn(foundErrors, testConfiguration, \"test\");\n\t\tvalidator->findErrorsIn(foundErrors, testSWConfiguration, \"swtest\");\n\n        QString expectedError = QObject::tr(\"Invalid view reference '%1' set for view configuration %2 within %3\")\n            .arg(viewReference).arg(testConfiguration->getInstanceName()).arg(\"test\");\n\n        if (errorIsNotFoundInErrorList(expectedError, foundErrors))\n        {\n            QFAIL(\"No error message found\");\n        }\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_DesignConfigurationValidator::testViewConfigurationHasValidViewReference_data()\n//-----------------------------------------------------------------------------\nvoid tst_DesignConfigurationValidator::testViewConfigurationHasValidViewReference_data()\n{\n    QTest::addColumn<QString>(\"viewReference\");\n    QTest::addColumn<bool>(\"viewExists\");\n    QTest::addColumn<bool>(\"isValid\");\n\n    QTest::newRow(\"View configuration with a view reference to an existing view is valid\") <<\n        \"Shishigami\" << true << true;\n    QTest::newRow(\"View configuration without a view reference is not valid\") << \"\" << true << false;\n    QTest::newRow(\"View configuration referencing non-existing view is not valid\") <<\n\t\t\"Shishigami\" << false << false;\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_DesignConfigurationValidator::testHasValidViewConfigurations()\n//-----------------------------------------------------------------------------\nvoid tst_DesignConfigurationValidator::testHasValidViewConfigurations()\n{\n    QFETCH(bool, createViewConfiguration);\n    QFETCH(QString, instanceName);\n    QFETCH(QString, viewReference);\n    QFETCH(bool, copyConfiguration);\n    QFETCH(bool, isValid);\n\n    QSharedPointer<Design> referencedDesign (\n        new Design(VLNV(VLNV::DESIGN, \"Evangelion\", \"Shin\", \"Geki\", \"jouban\"), Document::Revision::Std14));\n\n    LibraryMock* mockLibrary (new LibraryMock(this));\n    mockLibrary->addComponent(referencedDesign);\n\n    QSharedPointer<DesignConfiguration> testConfiguration (new DesignConfiguration(\n        VLNV(VLNV::DESIGNCONFIGURATION, \"Samurai\", \"Champloo\", \"MugenJinFuu\", \"3.0\"), Document::Revision::Std14));\n    testConfiguration->setDesignRef(referencedDesign->getVlnv());\n\n    QSharedPointer<ConfigurableVLNVReference> componentVLNV\n        (new ConfigurableVLNVReference(VLNV(VLNV::COMPONENT, \"vendor\", \"library\", \"testComponent\", \"1\")));\n\n    if (createViewConfiguration)\n    {\n        QSharedPointer<ViewConfiguration> viewConfiguration (new ViewConfiguration(instanceName));\n        viewConfiguration->setViewReference(viewReference);\n        testConfiguration->getViewConfigurations()->append(viewConfiguration);\n\n        QSharedPointer<View> testView (new View(viewReference));\n        if (viewReference.isEmpty())\n        {\n            testView->setName(\"SaederKrupp\");\n        }\n\n        QSharedPointer<Component> testComponent (new Component(*componentVLNV, Document::Revision::Std14));\n        testComponent->getViews()->append(testView);\n\n        mockLibrary->addComponent(testComponent);\n\n        QSharedPointer<ComponentInstance> testInstance (new ComponentInstance(instanceName, componentVLNV));\n        referencedDesign->getComponentInstances()->append(testInstance);\n\n        if (copyConfiguration)\n        {\n            QSharedPointer<ViewConfiguration> otherView (new ViewConfiguration(*viewConfiguration.data()));\n            testConfiguration->getViewConfigurations()->append(otherView);\n        }\n    }\n\n    QSharedPointer<DesignConfigurationValidator> validator = createDesignConfigurationValidator(mockLibrary);\n\n    QCOMPARE(validator->hasValidViewConfigurations(testConfiguration), isValid);\n\n    if (!isValid)\n    {\n        QVector<QString> foundErrors;\n        validator->findErrorsIn(foundErrors, testConfiguration);\n\n        QString expectedError = QObject::tr(\"Invalid name '%1' set for view configuration within design \"\n            \"configuration %2\")\n            .arg(instanceName).arg(testConfiguration->getVlnv().toString());\n\n        if (viewReference.isEmpty())\n        {\n            expectedError = QObject::tr(\"Invalid view reference '%1' set for view configuration %2 within design \"\n                \"configuration %3\")\n                .arg(viewReference).arg(instanceName).arg(testConfiguration->getVlnv().toString());\n        }\n        else if (copyConfiguration)\n        {\n            expectedError = QObject::tr(\"View configuration name '%1' within design configuration %2 is not \"\n                \"unique.\")\n                .arg(instanceName).arg(testConfiguration->getVlnv().toString());\n        }\n\n        if (errorIsNotFoundInErrorList(expectedError, foundErrors))\n        {\n            QFAIL(\"No error message found\");\n        }\n    }}\n\n//-----------------------------------------------------------------------------\n// Function: tst_DesignConfigurationValidator::testHasValidViewConfigurations_data()\n//-----------------------------------------------------------------------------\nvoid tst_DesignConfigurationValidator::testHasValidViewConfigurations_data()\n{\n    QTest::addColumn<bool>(\"createViewConfiguration\");\n    QTest::addColumn<QString>(\"instanceName\");\n    QTest::addColumn<QString>(\"viewReference\");\n    QTest::addColumn<bool>(\"copyConfiguration\");\n    QTest::addColumn<bool>(\"isValid\");\n\n    QTest::newRow(\"Design configuration without view configurations is valid\") <<\n        false << \"\" << \"\" << false << true;\n    QTest::newRow(\"View configuration with name and view reference is valid\") <<\n        true << \"Bang\" << \"Shishigami\" << false << true;\n\n    QTest::newRow(\"View configuration without name is not valid\") <<\n        true << \"\" << \"Shishigami\" << false << false;\n    QTest::newRow(\"View configuration without view reference is not valid\") <<\n        true << \"Bang\" << \"\" << false << false;\n    QTest::newRow(\"View configurations with non-unique name is not valid\") <<\n        true << \"Bang\" << \"Shishigami\" << true << false;\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_DesignConfigurationValidator::testHasValidParameters()\n//-----------------------------------------------------------------------------\nvoid tst_DesignConfigurationValidator::testHasValidParameters()\n{\n    QFETCH(QString, name);\n    QFETCH(QString, value);\n    QFETCH(bool, copyParameter);\n    QFETCH(bool, isValid);\n\n    QSharedPointer<Parameter> testParameter (new Parameter());\n    testParameter->setName(name);\n    testParameter->setValue(value);\n\n    QSharedPointer<DesignConfiguration> testConfiguration (new DesignConfiguration(\n        VLNV(VLNV::DESIGNCONFIGURATION, \"Samurai\", \"Champloo\", \"MugenJinFuu\", \"3.0\"), Document::Revision::Std14));\n\n    testConfiguration->getParameters()->append(testParameter);\n\n    if (copyParameter)\n    {\n        QSharedPointer<Parameter> otherParameter (new Parameter(*testParameter.data()));\n        testConfiguration->getParameters()->append(otherParameter);\n    }\n\n    QSharedPointer<DesignConfigurationValidator> validator = createDesignConfigurationValidator(0);\n\n    QCOMPARE(validator->hasValidParameters(testConfiguration), isValid);\n\n    if (!isValid)\n    {\n        QVector<QString> foundErrors;\n        validator->findErrorsIn(foundErrors, testConfiguration);\n\n        QString expectedError =\n            QObject::tr(\"No valid name specified for parameter %1 within design configuration %2\")\n            .arg(name).arg(testConfiguration->getVlnv().toString());\n\n        if (value.isEmpty())\n        {\n            expectedError = QObject::tr(\"No value specified for parameter %1 within design configuration %2\")\n                .arg(name).arg(testConfiguration->getVlnv().toString());\n        }\n        else if (copyParameter)\n        {\n            expectedError = QObject::tr(\"Parameter name %1 within design configuration %2 is not unique.\")\n                .arg(name).arg(testConfiguration->getVlnv().toString());\n        }\n\n        if (errorIsNotFoundInErrorList(expectedError, foundErrors))\n        {\n            QFAIL(\"No error message found\");\n        }\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_DesignConfigurationValidator::testHasValidParameters_data()\n//-----------------------------------------------------------------------------\nvoid tst_DesignConfigurationValidator::testHasValidParameters_data()\n{\n    QTest::addColumn<QString>(\"name\");\n    QTest::addColumn<QString>(\"value\");\n    QTest::addColumn<bool>(\"copyParameter\");\n    QTest::addColumn<bool>(\"isValid\");\n\n    QTest::newRow(\"Parameter with name and value is valid\") << \"Gunmen\" << \"8\" << false << true;\n    QTest::newRow(\"Parameter without name is not valid\") << \"\" << \"8\" << false << false;\n    QTest::newRow(\"Parameter without value is not valid\") << \"Gunmen\" << \"\" << false << false;\n    QTest::newRow(\"Parameters with the same name is not valid\") << \"Gunmen\" << \"8\" << true << false;\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_DesignConfigurationValidator::testHasValidAssertions()\n//-----------------------------------------------------------------------------\nvoid tst_DesignConfigurationValidator::testHasValidAssertions()\n{\n    QFETCH(QString, name);\n    QFETCH(QString, assertValue);\n    QFETCH(bool, copyAssertion);\n    QFETCH(bool, isValid);\n\n    QSharedPointer<Assertion> testAssertion (new Assertion());\n    testAssertion->setName(name);\n    testAssertion->setAssert(assertValue);\n\n    QSharedPointer<DesignConfiguration> testConfiguration (\n        new DesignConfiguration(VLNV(VLNV::DESIGNCONFIGURATION, \"Samurai\", \"Champloo\", \"MugenJinFuu\", \"3.0\"), Document::Revision::Std14));\n    testConfiguration->getAssertions()->append(testAssertion);\n\n    if (copyAssertion)\n    {\n        QSharedPointer<Assertion> otherAssertion (new Assertion(*testAssertion.data()));\n        testConfiguration->getAssertions()->append(otherAssertion);\n    }\n\n    QSharedPointer<DesignConfigurationValidator> validator = createDesignConfigurationValidator(0);\n\n    QCOMPARE(validator->hasValidAssertions(testConfiguration), isValid);\n\n    if (!isValid)\n    {\n        QVector<QString> foundErrors;\n        validator->findErrorsIn(foundErrors, testConfiguration);\n\n        QString expectedError = QObject::tr(\"Invalid name set for assertion %1 within design configuration %2\")\n            .arg(name).arg(testConfiguration->getVlnv().toString());\n\n        QSharedPointer<ExpressionParser> parser (new SystemVerilogExpressionParser());\n        bool assertOk = true;\n        int parsedAssert = parser->parseExpression(assertValue).toInt(&assertOk);\n\n        if (!assertOk || parsedAssert != 1)\n        {\n            expectedError = QObject::tr(\"Invalid assert set for assertion %1 within design configuration %2\")\n                .arg(name).arg(testConfiguration->getVlnv().toString());\n        }\n        else if (copyAssertion)\n        {\n            expectedError = QObject::tr(\"Assertion name %1 within design configuration %2 is not unique.\")\n                .arg(name).arg(testConfiguration->getVlnv().toString());\n        }\n\n        if (errorIsNotFoundInErrorList(expectedError, foundErrors))\n        {\n            QFAIL(\"No error message found\");\n        }\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_DesignConfigurationValidator::testHasValidAssertions_data()\n//-----------------------------------------------------------------------------\nvoid tst_DesignConfigurationValidator::testHasValidAssertions_data()\n{\n    QTest::addColumn<QString>(\"name\");\n    QTest::addColumn<QString>(\"assertValue\");\n    QTest::addColumn<bool>(\"copyAssertion\");\n    QTest::addColumn<bool>(\"isValid\");\n\n    QTest::newRow(\"Assertion with name and assert value of 1 is valid\") << \"Onibocho\" << \"1\" << false << true;\n    QTest::newRow(\"Assertion without name is not valid\") << \"\" << \"4-3\" << false << false;\n    QTest::newRow(\"Assertion with incorrect assert value is not valid\") << \"Onibocho\" << \"4*2\" << false << false;\n    QTest::newRow(\"Assertion with assert value 0 is not valid\") << \"Onibocho\" << \"1*2-2\" << false << false;\n    QTest::newRow(\"Assertion without assert value is not valid\") << \"Onibocho\" << \"\" << false << false;\n    QTest::newRow(\"Assertions with the same name is not valid\") << \"Onibocho\" << \"1\" << true << false;\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_DesignConfigurationValidator::errorIsNotFoundInErrorList()\n//-----------------------------------------------------------------------------\nbool tst_DesignConfigurationValidator::errorIsNotFoundInErrorList(QString const& expectedError,\n    QVector<QString> errorList)\n{\n    if (!errorList.contains(expectedError))\n    {\n        qDebug() << \"The following error:\" << Qt::endl << expectedError << Qt::endl << \"was not found in error list:\";\n        for (QString error : errorList)\n        {\n            qDebug() << error;\n        }\n        return true;\n    }\n\n    return false;\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_DesignConfigurationValidator::createDesignConfigurationValidator()\n//-----------------------------------------------------------------------------\nQSharedPointer<DesignConfigurationValidator> tst_DesignConfigurationValidator::createDesignConfigurationValidator(\n    LibraryInterface* library)\n{\n    QSharedPointer<QList<QSharedPointer<MonitorInterconnection> > > monitorConnections\n        (new QList<QSharedPointer<MonitorInterconnection> > ());\n    QSharedPointer<QList<QSharedPointer<ComponentInstance> > > componentInstances;\n\n    QSharedPointer<ExpressionParser> parser (new SystemVerilogExpressionParser());\n\n    QSharedPointer<DesignConfigurationValidator> validator (new DesignConfigurationValidator(parser, library));\n\n    return validator;\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_DesignConfigurationValidator::createInterconnectionConfigurationValidator()\n//-----------------------------------------------------------------------------\nQSharedPointer<InterconnectionConfigurationValidator> tst_DesignConfigurationValidator::\n    createInterconnectionConfigurationValidator(LibraryInterface* library)\n{\n    QSharedPointer<ExpressionParser> parser (new SystemVerilogExpressionParser());\n\n    QSharedPointer<InterconnectionConfigurationValidator> validator (\n        new InterconnectionConfigurationValidator(parser, library));\n\n    return validator;\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_DesignConfigurationValidator::createViewConfigurationValidator()\n//-----------------------------------------------------------------------------\nQSharedPointer<ViewConfigurationValidator> tst_DesignConfigurationValidator::createViewConfigurationValidator(\n    LibraryInterface* library)\n{\n    QSharedPointer<ExpressionParser> parser (new SystemVerilogExpressionParser());\n\n    QSharedPointer<ViewConfigurationValidator> validator (new ViewConfigurationValidator(library, parser));\n\n    return validator;\n}\n\nQTEST_APPLESS_MAIN(tst_DesignConfigurationValidator)\n\n#include \"tst_DesignConfigurationValidator.moc\"\n"
  },
  {
    "path": "tests/IPXACTmodels/DesignConfiguration/tst_DesignConfigurationValidator.pri",
    "content": "# ----------------------------------------------------\n# This file is generated by the Qt Visual Studio Tools.\n# ------------------------------------------------------\n\nHEADERS += ../../MockObjects/LibraryMock.h \nSOURCES += ../../MockObjects/LibraryMock.cpp \\\n    ./tst_DesignConfigurationValidator.cpp \n   "
  },
  {
    "path": "tests/IPXACTmodels/DesignConfiguration/tst_DesignConfigurationValidator.pro",
    "content": "#-----------------------------------------------------------------------------\n# File: tst_DesignConfigurationValidator.pro\n#-----------------------------------------------------------------------------\n# Project: Kactus 2\n# Author: Mikko Teuho\n# Date: 11.01.2016\n#\n# Description:\n# Qt project file for running unit tests for DesignConfigurationValidator.\n#-----------------------------------------------------------------------------\n\nTEMPLATE = app\n\nTARGET = tst_DesignConfigurationValidator\n\nQT += core gui xml testlib\n\nCONFIG += c++11 testcase console\n\nlinux-g++ | linux-g++-64 | linux-g++-32 {\n LIBS += -L../../../executable \\\n     -lIPXACTmodels -lKactusAPI\n\n}\nwin64 | win32 {\n LIBS += -L../../../executable \\\n     -lIPXACTmodelsd -lKactusAPId\n}\n\nDESTDIR = ./release\n\nINCLUDEPATH += $$DESTDIR\nINCLUDEPATH += ../../../\n\nDEPENDPATH += .\n\nOBJECTS_DIR += $$DESTDIR\n\nMOC_DIR += ./generatedFiles\nUI_DIR += ./generatedFiles\nRCC_DIR += ./generatedFiles\ninclude(tst_DesignConfigurationValidator.pri)\n"
  },
  {
    "path": "tests/IPXACTmodels/DesignConfiguration/tst_DesignConfigurationWriter.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: tst_DesignConfigurationWriter.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 3.8.2015\r\n//\r\n// Description:\r\n// Unit test for class DesignConfiguration.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include <QtTest>\r\n#include <QXmlStreamWriter>\r\n\r\n#include <IPXACTmodels/DesignConfiguration/DesignConfigurationWriter.h>\r\n#include <IPXACTmodels/DesignConfiguration/DesignConfiguration.h>\r\n\r\n#include <IPXACTmodels/common/GenericVendorExtension.h>\r\n\r\n#include <QDomElement>\r\n\r\nclass tst_DesignConfigurationWriter : public QObject\r\n{\r\n    Q_OBJECT\r\n\r\npublic:\r\n    tst_DesignConfigurationWriter();\r\n\r\nprivate slots:\r\n\r\n    void init();\r\n    void cleanup();\r\n\r\n    void testSimpleDesignConfiguration();\r\n    void test2022DesignConfiguration();\r\n\r\n    void testTopCommentsAreWritten();\r\n    void testProcessingInstructionsAreWritten();\r\n\r\n    void testDesignReference();\r\n    void testGeneratorChainConfiguration();\r\n\r\n    void testInterconnectionConfiguration();\r\n    void test2022InterconnectionConfiguration();\r\n\r\n    void testViewConfigurations();\r\n    void test2022ViewConfigurations();\r\n\r\n    void testParameters();\r\n    void testAssertion();\r\n    void testVendorExtensions();\r\n\r\n    void testWriteViewOverrides();\r\n\r\nprivate:\r\n\r\n    void compareOutputToExpected(QString const& output, QString const& expectedOutput);\r\n\r\n    QSharedPointer<DesignConfiguration> designConfiguration_;\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_DesignConfigurationWriter::tst_DesignConfigurationWriter()\r\n//-----------------------------------------------------------------------------\r\ntst_DesignConfigurationWriter::tst_DesignConfigurationWriter():\r\ndesignConfiguration_()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_DesignConfigurationWriter::init()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_DesignConfigurationWriter::init()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_DesignConfigurationWriter::cleanup()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_DesignConfigurationWriter::cleanup()\r\n{\r\n    designConfiguration_.clear();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_DesignConfigurationWriter::testSimpleDesignConfiguration()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_DesignConfigurationWriter::testSimpleDesignConfiguration()\r\n{\r\n    VLNV vlnv(VLNV::DESIGNCONFIGURATION, \"tuni.fi\", \"TestLibrary\", \"TestDesignConfiguration\", \"0.1\");\r\n    designConfiguration_ = QSharedPointer<DesignConfiguration>(new DesignConfiguration(vlnv, Document::Revision::Std14));\r\n    designConfiguration_->setDescription(\"TestDescription\");\r\n\r\n    QString output;\r\n    QXmlStreamWriter xmlStreamWriter(&output);\r\n    \r\n    xmlStreamWriter.setAutoFormatting(true);\r\n    xmlStreamWriter.setAutoFormattingIndent(-1);\r\n\r\n    \r\n    DesignConfigurationWriter::writeDesignConfiguration(xmlStreamWriter, designConfiguration_);\r\n\r\n    QString expectedOutput = \r\n        \"<?xml version=\\\"1.0\\\"?>\\n\"\r\n        \"<ipxact:designConfiguration \"\r\n        \"xmlns:xsi=\\\"http://www.w3.org/2001/XMLSchema-instance\\\" \" \r\n        \"xmlns:ipxact=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014\\\" \"\r\n        \"xmlns:kactus2=\\\"http://kactus2.cs.tut.fi\\\" \"\r\n        \"xsi:schemaLocation=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014 \"\r\n        \"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/index.xsd\\\"\"\r\n        \">\\n\"\r\n        \"\\t<ipxact:vendor>tuni.fi</ipxact:vendor>\\n\"\r\n        \"\\t<ipxact:library>TestLibrary</ipxact:library>\\n\"\r\n        \"\\t<ipxact:name>TestDesignConfiguration</ipxact:name>\\n\"\r\n        \"\\t<ipxact:version>0.1</ipxact:version>\\n\"\r\n        \"\\t<ipxact:description>TestDescription</ipxact:description>\\n\"\r\n        \"</ipxact:designConfiguration>\\n\";\r\n\r\n    compareOutputToExpected(output, expectedOutput);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_DesignConfigurationWriter::test2022DesignConfiguration()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_DesignConfigurationWriter::test2022DesignConfiguration()\r\n{\r\n    VLNV vlnv(VLNV::DESIGNCONFIGURATION, \"tuni.fi\", \"TestLibrary\", \"TestDesignConfiguration\", \"0.1\");\r\n    designConfiguration_ = QSharedPointer<DesignConfiguration>(new DesignConfiguration(vlnv, Document::Revision::Std22));\r\n    designConfiguration_->setShortDescription(\"Short\");\r\n    designConfiguration_->setDescription(\"TestDescription\");\r\n\r\n    QString output;\r\n    QXmlStreamWriter xmlStreamWriter(&output);\r\n\r\n    xmlStreamWriter.setAutoFormatting(true);\r\n    xmlStreamWriter.setAutoFormattingIndent(-1);\r\n\r\n    DesignConfigurationWriter::writeDesignConfiguration(xmlStreamWriter, designConfiguration_);\r\n\r\n    QString expectedOutput =\r\n        \"<?xml version=\\\"1.0\\\"?>\\n\"\r\n        \"<ipxact:designConfiguration \"\r\n        \"xmlns:xsi=\\\"http://www.w3.org/2001/XMLSchema-instance\\\" \"\r\n        \"xmlns:ipxact=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2022\\\" \"\r\n        \"xmlns:kactus2=\\\"http://kactus2.cs.tut.fi\\\" \"\r\n        \"xsi:schemaLocation=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2022 \"\r\n        \"http://www.accellera.org/XMLSchema/IPXACT/1685-2022/index.xsd\\\"\"\r\n        \">\\n\"\r\n        \"\\t<ipxact:vendor>tuni.fi</ipxact:vendor>\\n\"\r\n        \"\\t<ipxact:library>TestLibrary</ipxact:library>\\n\"\r\n        \"\\t<ipxact:name>TestDesignConfiguration</ipxact:name>\\n\"\r\n        \"\\t<ipxact:version>0.1</ipxact:version>\\n\"\r\n        \"\\t<ipxact:shortDescription>Short</ipxact:shortDescription>\\n\"\r\n        \"\\t<ipxact:description>TestDescription</ipxact:description>\\n\"\r\n        \"</ipxact:designConfiguration>\\n\";\r\n\r\n    compareOutputToExpected(output, expectedOutput);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_DesignConfigurationWriter::testTopCommentsAreWritten()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_DesignConfigurationWriter::testTopCommentsAreWritten()\r\n{\r\n    VLNV vlnv(VLNV::DESIGNCONFIGURATION, \"tuni.fi\", \"TestLibrary\", \"TestDesignConfiguration\", \"0.1\");\r\n    designConfiguration_ = QSharedPointer<DesignConfiguration>(new DesignConfiguration(vlnv, Document::Revision::Std14));\r\n    designConfiguration_->setTopComments(\"Comments\");\r\n\r\n    QString output;\r\n    QXmlStreamWriter xmlStreamWriter(&output);\r\n\r\n    xmlStreamWriter.setAutoFormatting(true);\r\n    xmlStreamWriter.setAutoFormattingIndent(-1);\r\n\r\n    DesignConfigurationWriter::writeDesignConfiguration(xmlStreamWriter, designConfiguration_);\r\n\r\n    QString expectedOutput(\r\n        \"<?xml version=\\\"1.0\\\"?>\\n\"\r\n        \"<!--Comments-->\\n\"\r\n        \"<ipxact:designConfiguration \"\r\n        \"xmlns:xsi=\\\"http://www.w3.org/2001/XMLSchema-instance\\\" \" \r\n        \"xmlns:ipxact=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014\\\" \"\r\n        \"xmlns:kactus2=\\\"http://kactus2.cs.tut.fi\\\" \"\r\n        \"xsi:schemaLocation=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014 \"\r\n        \"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/index.xsd\\\"\"\r\n        \">\\n\"\r\n        \"\\t<ipxact:vendor>tuni.fi</ipxact:vendor>\\n\"\r\n        \"\\t<ipxact:library>TestLibrary</ipxact:library>\\n\"\r\n        \"\\t<ipxact:name>TestDesignConfiguration</ipxact:name>\\n\"\r\n        \"\\t<ipxact:version>0.1</ipxact:version>\\n\"\r\n        \"</ipxact:designConfiguration>\\n\");\r\n    QCOMPARE(output, expectedOutput);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_DesignConfigurationWriter::testProcessingInstructionsAreWritten()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_DesignConfigurationWriter::testProcessingInstructionsAreWritten()\r\n{\r\n    VLNV vlnv(VLNV::DESIGNCONFIGURATION, \"tuni.fi\", \"TestLibrary\", \"TestDesignConfiguration\", \"0.1\");\r\n    designConfiguration_ = QSharedPointer<DesignConfiguration>(new DesignConfiguration(vlnv, Document::Revision::Std14));\r\n    designConfiguration_->addXmlProcessingInstructions(\"xml-stylesheet\", \"href=\\\"style.css\\\"\");\r\n\r\n    QString output;\r\n    QXmlStreamWriter xmlStreamWriter(&output);\r\n\r\n    xmlStreamWriter.setAutoFormatting(true);\r\n    xmlStreamWriter.setAutoFormattingIndent(-1);\r\n\r\n    DesignConfigurationWriter::writeDesignConfiguration(xmlStreamWriter, designConfiguration_);\r\n\r\n    QString expectedOutput(\r\n        \"<?xml version=\\\"1.0\\\"?>\\n\"\r\n        \"<?xml-stylesheet href=\\\"style.css\\\"?>\\n\"\r\n        \"<ipxact:designConfiguration \"\r\n        \"xmlns:xsi=\\\"http://www.w3.org/2001/XMLSchema-instance\\\" \" \r\n        \"xmlns:ipxact=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014\\\" \"\r\n        \"xmlns:kactus2=\\\"http://kactus2.cs.tut.fi\\\" \"\r\n        \"xsi:schemaLocation=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014 \"\r\n        \"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/index.xsd\\\">\\n\"\r\n            \"\\t<ipxact:vendor>tuni.fi</ipxact:vendor>\\n\"\r\n            \"\\t<ipxact:library>TestLibrary</ipxact:library>\\n\"\r\n            \"\\t<ipxact:name>TestDesignConfiguration</ipxact:name>\\n\"\r\n            \"\\t<ipxact:version>0.1</ipxact:version>\\n\"\r\n        \"</ipxact:designConfiguration>\\n\");\r\n    QCOMPARE(output, expectedOutput);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_DesignConfigurationWriter::testDesignReference()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_DesignConfigurationWriter::testDesignReference()\r\n{\r\n    VLNV vlnv(VLNV::DESIGNCONFIGURATION, \"tuni.fi\", \"TestLibrary\", \"TestDesignConfiguration\", \"0.1\");\r\n    designConfiguration_ = QSharedPointer<DesignConfiguration>(new DesignConfiguration(vlnv, Document::Revision::Std14));\r\n    designConfiguration_->setDescription(\"This is design\");\r\n\r\n    VLNV designReference(VLNV::DESIGN, \"tuni.fi\", \"TestLibrary\", \"DesignReference\", \"1.1\");\r\n    designConfiguration_->setDesignRef(designReference);\r\n\r\n    QString output;\r\n    QXmlStreamWriter xmlStreamWriter(&output);\r\n\r\n    xmlStreamWriter.setAutoFormatting(true);\r\n    xmlStreamWriter.setAutoFormattingIndent(-1);\r\n\r\n    DesignConfigurationWriter::writeDesignConfiguration(xmlStreamWriter, designConfiguration_);\r\n\r\n    QString expectedOutput(\r\n        \"<?xml version=\\\"1.0\\\"?>\\n\"\r\n        \"<ipxact:designConfiguration \"\r\n        \"xmlns:xsi=\\\"http://www.w3.org/2001/XMLSchema-instance\\\" \" \r\n        \"xmlns:ipxact=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014\\\" \"\r\n        \"xmlns:kactus2=\\\"http://kactus2.cs.tut.fi\\\" \"\r\n        \"xsi:schemaLocation=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014 \"\r\n        \"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/index.xsd\\\"\"\r\n        \">\\n\"\r\n        \"\\t<ipxact:vendor>tuni.fi</ipxact:vendor>\\n\"\r\n        \"\\t<ipxact:library>TestLibrary</ipxact:library>\\n\"\r\n        \"\\t<ipxact:name>TestDesignConfiguration</ipxact:name>\\n\"\r\n        \"\\t<ipxact:version>0.1</ipxact:version>\\n\"\r\n        \"\\t<ipxact:designRef vendor=\\\"tuni.fi\\\" library=\\\"TestLibrary\\\" name=\\\"DesignReference\\\" version=\\\"1.1\\\"/>\\n\"\r\n        \"\\t<ipxact:description>This is design</ipxact:description>\\n\"\r\n        \"</ipxact:designConfiguration>\\n\");\r\n\r\n    compareOutputToExpected(output, expectedOutput);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_DesignConfigurationWriter::testGeneratorChainConfiguration()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_DesignConfigurationWriter::testGeneratorChainConfiguration()\r\n{\r\n    VLNV vlnv(VLNV::DESIGNCONFIGURATION, \"tuni.fi\", \"TestLibrary\", \"TestDesignConfiguration\", \"0.1\");\r\n    designConfiguration_ = QSharedPointer<DesignConfiguration>(new DesignConfiguration(vlnv, Document::Revision::Std14));\r\n\r\n    QSharedPointer<ConfigurableVLNVReference> generatorChainConf (\r\n        new ConfigurableVLNVReference(VLNV::GENERATORCHAIN, \"tuni.fi\", \"TestLibrary\", \"testGenCon\", \"1.0\"));\r\n\r\n    QSharedPointer<ConfigurableElementValue> generatorChainConfigurable (\r\n        new ConfigurableElementValue(\"10\", \"testReferenceID\"));\r\n    generatorChainConf->getConfigurableElementValues()->append(generatorChainConfigurable);\r\n\r\n    designConfiguration_->getGeneratorChainConfs()->append(generatorChainConf);\r\n\r\n    QString output;\r\n    QXmlStreamWriter xmlStreamWriter(&output);\r\n\r\n    xmlStreamWriter.setAutoFormatting(true);\r\n    xmlStreamWriter.setAutoFormattingIndent(-1);\r\n\r\n    DesignConfigurationWriter::writeDesignConfiguration(xmlStreamWriter, designConfiguration_);\r\n\r\n    QString expectedOutput(\r\n        \"<?xml version=\\\"1.0\\\"?>\\n\"\r\n        \"<ipxact:designConfiguration \"\r\n        \"xmlns:xsi=\\\"http://www.w3.org/2001/XMLSchema-instance\\\" \" \r\n        \"xmlns:ipxact=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014\\\" \"\r\n        \"xmlns:kactus2=\\\"http://kactus2.cs.tut.fi\\\" \"\r\n        \"xsi:schemaLocation=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014 \"\r\n        \"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/index.xsd\\\"\"\r\n        \">\\n\"\r\n        \"\\t<ipxact:vendor>tuni.fi</ipxact:vendor>\\n\"\r\n        \"\\t<ipxact:library>TestLibrary</ipxact:library>\\n\"\r\n        \"\\t<ipxact:name>TestDesignConfiguration</ipxact:name>\\n\"\r\n        \"\\t<ipxact:version>0.1</ipxact:version>\\n\"\r\n        \"\\t<ipxact:generatorChainConfiguration vendor=\\\"tuni.fi\\\" library=\\\"TestLibrary\\\" name=\\\"testGenCon\\\" \"\r\n            \"version=\\\"1.0\\\">\\n\"\r\n            \"\\t\\t<ipxact:configurableElementValues>\\n\"\r\n                \"\\t\\t\\t<ipxact:configurableElementValue referenceId=\\\"testReferenceID\\\">10\"\r\n                    \"</ipxact:configurableElementValue>\\n\"\r\n            \"\\t\\t</ipxact:configurableElementValues>\\n\"\r\n            \"\\t</ipxact:generatorChainConfiguration>\\n\"\r\n        \"</ipxact:designConfiguration>\\n\");\r\n\r\n    compareOutputToExpected(output, expectedOutput);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_DesignConfigurationWriter::testInterconnectionConfiguration()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_DesignConfigurationWriter::testInterconnectionConfiguration()\r\n{\r\n    VLNV vlnv(VLNV::DESIGNCONFIGURATION, \"tuni.fi\", \"TestLibrary\", \"TestDesignConfiguration\", \"0.1\");\r\n    designConfiguration_ = QSharedPointer<DesignConfiguration>(new DesignConfiguration(vlnv, Document::Revision::Std14));\r\n\r\n    QSharedPointer<ConfigurableVLNVReference> testAbstractorRef (\r\n        new ConfigurableVLNVReference(VLNV::ABSTRACTOR, \"tuni.fi\", \"TestLibrary\", \"testAbstractor\", \"1.1\"));\r\n    QSharedPointer<ConfigurableElementValue> abstractorCEV (new ConfigurableElementValue(\"12\", \"testReferenceID\"));\r\n    testAbstractorRef->getConfigurableElementValues()->append(abstractorCEV);\r\n\r\n    QSharedPointer<AbstractorInstance> testAbstractorInstance (new AbstractorInstance());\r\n    testAbstractorInstance->setInstanceName(\"testAbstractorInstance\");\r\n    testAbstractorInstance->setDisplayName(\"abstractorDisplay\");\r\n    testAbstractorInstance->setDescription(\"abstractorDescription\");\r\n    testAbstractorInstance->setViewName(\"abstractorView\");\r\n    testAbstractorInstance->setAbstractorRef(testAbstractorRef);\r\n\r\n    QSharedPointer<InterfaceRef> testInterfaceReference(new InterfaceRef());\r\n    testInterfaceReference->setComponentRef(\"testComponent\");\r\n    testInterfaceReference->setBusRef(\"testBus\");\r\n    testInterfaceReference->setIsPresent(\"1\");\r\n\r\n    QSharedPointer<MultipleAbstractorInstances> multipleAbstractors (new MultipleAbstractorInstances());\r\n    multipleAbstractors->setIsPresent(\"1\");\r\n    multipleAbstractors->getInterfaceReferences()->append(testInterfaceReference);\r\n    multipleAbstractors->getAbstractorInstances()->append(testAbstractorInstance);\r\n\r\n    QSharedPointer<InterconnectionConfiguration> testInterconnectionConfig (new InterconnectionConfiguration());\r\n    testInterconnectionConfig->setIsPresent(\"0\");\r\n    testInterconnectionConfig->setInterconnectionReference(\"testInterconnectionReference\");\r\n    testInterconnectionConfig->getAbstractorInstances()->append(multipleAbstractors);\r\n\r\n    designConfiguration_->getInterconnectionConfs()->append(testInterconnectionConfig);\r\n\r\n    QString output;\r\n    QXmlStreamWriter xmlStreamWriter(&output);\r\n\r\n    xmlStreamWriter.setAutoFormatting(true);\r\n    xmlStreamWriter.setAutoFormattingIndent(-1);\r\n\r\n    DesignConfigurationWriter::writeDesignConfiguration(xmlStreamWriter, designConfiguration_);\r\n\r\n    QString expectedOutput(\r\n        \"<?xml version=\\\"1.0\\\"?>\\n\"\r\n        \"<ipxact:designConfiguration \"\r\n        \"xmlns:xsi=\\\"http://www.w3.org/2001/XMLSchema-instance\\\" \" \r\n        \"xmlns:ipxact=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014\\\" \"\r\n        \"xmlns:kactus2=\\\"http://kactus2.cs.tut.fi\\\" \"\r\n        \"xsi:schemaLocation=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014 \"\r\n        \"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/index.xsd\\\"\"\r\n        \">\\n\"\r\n        \"\\t<ipxact:vendor>tuni.fi</ipxact:vendor>\\n\"\r\n        \"\\t<ipxact:library>TestLibrary</ipxact:library>\\n\"\r\n        \"\\t<ipxact:name>TestDesignConfiguration</ipxact:name>\\n\"\r\n        \"\\t<ipxact:version>0.1</ipxact:version>\\n\"\r\n        \"\\t<ipxact:interconnectionConfiguration>\\n\"\r\n            \"\\t\\t<ipxact:isPresent>0</ipxact:isPresent>\\n\"\r\n            \"\\t\\t<ipxact:interconnectionRef>testInterconnectionReference</ipxact:interconnectionRef>\\n\"\r\n            \"\\t\\t<ipxact:abstractorInstances>\\n\"\r\n                \"\\t\\t\\t<ipxact:isPresent>1</ipxact:isPresent>\\n\"\r\n                \"\\t\\t\\t<ipxact:interfaceRef componentRef=\\\"testComponent\\\" busRef=\\\"testBus\\\">\\n\"\r\n                    \"\\t\\t\\t\\t<ipxact:isPresent>1</ipxact:isPresent>\\n\"\r\n                \"\\t\\t\\t</ipxact:interfaceRef>\\n\"\r\n                \"\\t\\t\\t<ipxact:abstractorInstance>\\n\"\r\n                    \"\\t\\t\\t\\t<ipxact:instanceName>testAbstractorInstance</ipxact:instanceName>\\n\"\r\n                    \"\\t\\t\\t\\t<ipxact:displayName>abstractorDisplay</ipxact:displayName>\\n\"\r\n                    \"\\t\\t\\t\\t<ipxact:description>abstractorDescription</ipxact:description>\\n\"\r\n                    \"\\t\\t\\t\\t<ipxact:abstractorRef vendor=\\\"tuni.fi\\\" library=\\\"TestLibrary\\\" name=\\\"testAbstractor\\\" \"\r\n                        \"version=\\\"1.1\\\">\\n\"\r\n                        \"\\t\\t\\t\\t\\t<ipxact:configurableElementValues>\\n\"\r\n                            \"\\t\\t\\t\\t\\t\\t<ipxact:configurableElementValue referenceId=\\\"testReferenceID\\\">12\"\r\n                                        \"</ipxact:configurableElementValue>\\n\"\r\n                        \"\\t\\t\\t\\t\\t</ipxact:configurableElementValues>\\n\"\r\n                    \"\\t\\t\\t\\t</ipxact:abstractorRef>\\n\"\r\n                    \"\\t\\t\\t\\t<ipxact:viewName>abstractorView</ipxact:viewName>\\n\"\r\n                \"\\t\\t\\t</ipxact:abstractorInstance>\\n\"\r\n            \"\\t\\t</ipxact:abstractorInstances>\\n\"\r\n        \"\\t</ipxact:interconnectionConfiguration>\\n\"\r\n        \"</ipxact:designConfiguration>\\n\"\r\n        );\r\n\r\n    compareOutputToExpected(output, expectedOutput);\r\n}\r\n\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_DesignConfigurationWriter::test2022InterconnectionConfiguration()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_DesignConfigurationWriter::test2022InterconnectionConfiguration()\r\n{\r\n    VLNV vlnv(VLNV::DESIGNCONFIGURATION, \"tuni.fi\", \"TestLibrary\", \"TestDesignConfiguration\", \"0.1\");\r\n    designConfiguration_ = QSharedPointer<DesignConfiguration>(new DesignConfiguration(vlnv, Document::Revision::Std22));\r\n\r\n    QSharedPointer<ConfigurableVLNVReference> testAbstractorRef(\r\n        new ConfigurableVLNVReference(VLNV::ABSTRACTOR, \"tuni.fi\", \"TestLibrary\", \"testAbstractor\", \"1.1\"));\r\n    QSharedPointer<ConfigurableElementValue> abstractorCEV(new ConfigurableElementValue(\"12\", \"testReferenceID\"));\r\n    testAbstractorRef->getConfigurableElementValues()->append(abstractorCEV);\r\n\r\n    QSharedPointer<AbstractorInstance> testAbstractorInstance(new AbstractorInstance());\r\n    testAbstractorInstance->setInstanceName(\"testAbstractorInstance\");\r\n    testAbstractorInstance->setDisplayName(\"abstractorDisplay\");\r\n    testAbstractorInstance->setShortDescription(\"brief\");\r\n    testAbstractorInstance->setDescription(\"abstractorDescription\");\r\n    testAbstractorInstance->setViewName(\"abstractorView\");\r\n    testAbstractorInstance->setAbstractorRef(testAbstractorRef);\r\n    testAbstractorInstance->getVendorExtensions()->append(QSharedPointer<VendorExtension>(\r\n        new Kactus2Value(\"abstractorExtension\", \"On\")));\r\n\r\n    QSharedPointer<InterfaceRef> testInterfaceReference(new InterfaceRef());\r\n    testInterfaceReference->setComponentRef(\"testComponent\");\r\n    testInterfaceReference->setBusRef(\"testBus\");\r\n    testInterfaceReference->getVendorExtensions()->append(QSharedPointer<VendorExtension>(\r\n        new Kactus2Value(\"interfaceExtension\", \"On\")));\r\n\r\n    QSharedPointer<MultipleAbstractorInstances> multipleAbstractors(new MultipleAbstractorInstances());\r\n    multipleAbstractors->getInterfaceReferences()->append(testInterfaceReference);\r\n    multipleAbstractors->getAbstractorInstances()->append(testAbstractorInstance);\r\n\r\n    QSharedPointer<InterconnectionConfiguration> testInterconnectionConfig(new InterconnectionConfiguration());\r\n    testInterconnectionConfig->setInterconnectionReference(\"testInterconnectionReference\");\r\n    testInterconnectionConfig->getAbstractorInstances()->append(multipleAbstractors);\r\n    testInterconnectionConfig->getVendorExtensions()->append(QSharedPointer<VendorExtension>(\r\n        new Kactus2Value(\"interconnectExtension\", \"On\")));\r\n\r\n    designConfiguration_->getInterconnectionConfs()->append(testInterconnectionConfig);\r\n\r\n    QString output;\r\n    QXmlStreamWriter xmlStreamWriter(&output);\r\n\r\n    xmlStreamWriter.setAutoFormatting(true);\r\n    xmlStreamWriter.setAutoFormattingIndent(-1);\r\n\r\n    DesignConfigurationWriter::writeDesignConfiguration(xmlStreamWriter, designConfiguration_);\r\n\r\n    QString expectedOutput(\r\n        \"<?xml version=\\\"1.0\\\"?>\\n\"\r\n        \"<ipxact:designConfiguration \"\r\n        \"xmlns:xsi=\\\"http://www.w3.org/2001/XMLSchema-instance\\\" \"\r\n        \"xmlns:ipxact=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2022\\\" \"\r\n        \"xmlns:kactus2=\\\"http://kactus2.cs.tut.fi\\\" \"\r\n        \"xsi:schemaLocation=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2022 \"\r\n        \"http://www.accellera.org/XMLSchema/IPXACT/1685-2022/index.xsd\\\"\"\r\n        \">\\n\"\r\n        \"\\t<ipxact:vendor>tuni.fi</ipxact:vendor>\\n\"\r\n        \"\\t<ipxact:library>TestLibrary</ipxact:library>\\n\"\r\n        \"\\t<ipxact:name>TestDesignConfiguration</ipxact:name>\\n\"\r\n        \"\\t<ipxact:version>0.1</ipxact:version>\\n\"\r\n        \"\\t<ipxact:interconnectionConfiguration>\\n\"\r\n        \"\\t\\t<ipxact:interconnectionRef>testInterconnectionReference</ipxact:interconnectionRef>\\n\"\r\n        \"\\t\\t<ipxact:abstractorInstances>\\n\"\r\n        \"\\t\\t\\t<ipxact:interfaceRef componentRef=\\\"testComponent\\\" busRef=\\\"testBus\\\">\\n\"\r\n        \"\\t\\t\\t\\t<ipxact:vendorExtensions>\\n\"\r\n        \"\\t\\t\\t\\t\\t<interfaceExtension>On</interfaceExtension>\\n\"\r\n        \"\\t\\t\\t\\t</ipxact:vendorExtensions>\\n\"\r\n        \"\\t\\t\\t</ipxact:interfaceRef>\\n\"\r\n        \"\\t\\t\\t<ipxact:abstractorInstance>\\n\"\r\n        \"\\t\\t\\t\\t<ipxact:instanceName>testAbstractorInstance</ipxact:instanceName>\\n\"\r\n        \"\\t\\t\\t\\t<ipxact:displayName>abstractorDisplay</ipxact:displayName>\\n\"\r\n        \"\\t\\t\\t\\t<ipxact:shortDescription>brief</ipxact:shortDescription>\\n\"\r\n        \"\\t\\t\\t\\t<ipxact:description>abstractorDescription</ipxact:description>\\n\"\r\n        \"\\t\\t\\t\\t<ipxact:abstractorRef vendor=\\\"tuni.fi\\\" library=\\\"TestLibrary\\\" name=\\\"testAbstractor\\\" \"\r\n        \"version=\\\"1.1\\\">\\n\"\r\n        \"\\t\\t\\t\\t\\t<ipxact:configurableElementValues>\\n\"\r\n        \"\\t\\t\\t\\t\\t\\t<ipxact:configurableElementValue referenceId=\\\"testReferenceID\\\">12\"\r\n        \"</ipxact:configurableElementValue>\\n\"\r\n        \"\\t\\t\\t\\t\\t</ipxact:configurableElementValues>\\n\"\r\n        \"\\t\\t\\t\\t</ipxact:abstractorRef>\\n\"\r\n        \"\\t\\t\\t\\t<ipxact:viewName>abstractorView</ipxact:viewName>\\n\"\r\n        \"\\t\\t\\t\\t<ipxact:vendorExtensions>\\n\"\r\n        \"\\t\\t\\t\\t\\t<abstractorExtension>On</abstractorExtension>\\n\"\r\n        \"\\t\\t\\t\\t</ipxact:vendorExtensions>\\n\"\r\n        \"\\t\\t\\t</ipxact:abstractorInstance>\\n\"\r\n        \"\\t\\t</ipxact:abstractorInstances>\\n\"\r\n        \"\\t\\t<ipxact:vendorExtensions>\\n\"\r\n        \"\\t\\t\\t<interconnectExtension>On</interconnectExtension>\\n\"\r\n        \"\\t\\t</ipxact:vendorExtensions>\\n\"\r\n        \"\\t</ipxact:interconnectionConfiguration>\\n\"\r\n        \"</ipxact:designConfiguration>\\n\"\r\n    );\r\n\r\n    compareOutputToExpected(output, expectedOutput);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_DesignConfigurationWriter::testViewConfiguration()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_DesignConfigurationWriter::testViewConfigurations()\r\n{\r\n    VLNV vlnv(VLNV::DESIGNCONFIGURATION, \"tuni.fi\", \"TestLibrary\", \"TestDesignConfiguration\", \"0.1\");\r\n    designConfiguration_ = QSharedPointer<DesignConfiguration>(new DesignConfiguration(vlnv, Document::Revision::Std14));\r\n\r\n    QSharedPointer<ViewConfiguration> testViewConfiguration (new ViewConfiguration(\"testViewConfig\"));\r\n    testViewConfiguration->setIsPresent(\"1\");\r\n    testViewConfiguration->setViewReference(\"referenceToTestView\");\r\n\r\n    QSharedPointer<ConfigurableElementValue> viewConfigCEV (new ConfigurableElementValue(\"2\", \"testReferenceID\"));\r\n    testViewConfiguration->getViewConfigurableElements()->append(viewConfigCEV);\r\n\r\n    designConfiguration_->getViewConfigurations()->append(testViewConfiguration);\r\n\r\n    QString output;\r\n    QXmlStreamWriter xmlStreamWriter(&output);\r\n\r\n    xmlStreamWriter.setAutoFormatting(true);\r\n    xmlStreamWriter.setAutoFormattingIndent(-1);\r\n\r\n    DesignConfigurationWriter::writeDesignConfiguration(xmlStreamWriter, designConfiguration_);\r\n\r\n    QString expectedOutput(\r\n        \"<?xml version=\\\"1.0\\\"?>\\n\"\r\n        \"<ipxact:designConfiguration \"\r\n        \"xmlns:xsi=\\\"http://www.w3.org/2001/XMLSchema-instance\\\" \" \r\n        \"xmlns:ipxact=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014\\\" \"\r\n        \"xmlns:kactus2=\\\"http://kactus2.cs.tut.fi\\\" \"\r\n        \"xsi:schemaLocation=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014 \"\r\n        \"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/index.xsd\\\"\"\r\n        \">\\n\"\r\n        \"\\t<ipxact:vendor>tuni.fi</ipxact:vendor>\\n\"\r\n        \"\\t<ipxact:library>TestLibrary</ipxact:library>\\n\"\r\n        \"\\t<ipxact:name>TestDesignConfiguration</ipxact:name>\\n\"\r\n        \"\\t<ipxact:version>0.1</ipxact:version>\\n\"\r\n        \"\\t<ipxact:viewConfiguration>\\n\"\r\n            \"\\t\\t<ipxact:instanceName>testViewConfig</ipxact:instanceName>\\n\"\r\n            \"\\t\\t<ipxact:isPresent>1</ipxact:isPresent>\\n\"\r\n            \"\\t\\t<ipxact:view viewRef=\\\"referenceToTestView\\\">\\n\"\r\n                \"\\t\\t\\t<ipxact:configurableElementValues>\\n\"\r\n                    \"\\t\\t\\t\\t<ipxact:configurableElementValue referenceId=\\\"testReferenceID\\\">2\"\r\n                        \"</ipxact:configurableElementValue>\\n\"\r\n                \"\\t\\t\\t</ipxact:configurableElementValues>\\n\"\r\n            \"\\t\\t</ipxact:view>\\n\"\r\n        \"\\t</ipxact:viewConfiguration>\\n\"\r\n        \"</ipxact:designConfiguration>\\n\"\r\n        );\r\n\r\n    compareOutputToExpected(output, expectedOutput);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_DesignConfigurationWriter::test2022ViewConfigurations()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_DesignConfigurationWriter::test2022ViewConfigurations()\r\n{\r\n    VLNV vlnv(VLNV::DESIGNCONFIGURATION, \"tuni.fi\", \"TestLibrary\", \"TestDesignConfiguration\", \"0.1\");\r\n    designConfiguration_ = QSharedPointer<DesignConfiguration>(new DesignConfiguration(vlnv, Document::Revision::Std22));\r\n\r\n    QSharedPointer<ViewConfiguration> testViewConfiguration(new ViewConfiguration(\"testViewConfig\"));\r\n    testViewConfiguration->setViewReference(\"referenceToTestView\");\r\n    testViewConfiguration->getVendorExtensions()->append(QSharedPointer<VendorExtension>(\r\n        new Kactus2Value(\"viewExtension\", \"Yes\")));\r\n\r\n    QSharedPointer<ConfigurableElementValue> viewConfigCEV(new ConfigurableElementValue(\"2\", \"testReferenceID\"));\r\n    testViewConfiguration->getViewConfigurableElements()->append(viewConfigCEV);\r\n\r\n    designConfiguration_->getViewConfigurations()->append(testViewConfiguration);\r\n\r\n    QString output;\r\n    QXmlStreamWriter xmlStreamWriter(&output);\r\n\r\n    xmlStreamWriter.setAutoFormatting(true);\r\n    xmlStreamWriter.setAutoFormattingIndent(-1);\r\n\r\n    DesignConfigurationWriter::writeDesignConfiguration(xmlStreamWriter, designConfiguration_);\r\n\r\n    QString expectedOutput(\r\n        \"<?xml version=\\\"1.0\\\"?>\\n\"\r\n        \"<ipxact:designConfiguration \"\r\n        \"xmlns:xsi=\\\"http://www.w3.org/2001/XMLSchema-instance\\\" \"\r\n        \"xmlns:ipxact=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2022\\\" \"\r\n        \"xmlns:kactus2=\\\"http://kactus2.cs.tut.fi\\\" \"\r\n        \"xsi:schemaLocation=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2022 \"\r\n        \"http://www.accellera.org/XMLSchema/IPXACT/1685-2022/index.xsd\\\"\"\r\n        \">\\n\"\r\n        \"\\t<ipxact:vendor>tuni.fi</ipxact:vendor>\\n\"\r\n        \"\\t<ipxact:library>TestLibrary</ipxact:library>\\n\"\r\n        \"\\t<ipxact:name>TestDesignConfiguration</ipxact:name>\\n\"\r\n        \"\\t<ipxact:version>0.1</ipxact:version>\\n\"\r\n        \"\\t<ipxact:viewConfiguration>\\n\"\r\n        \"\\t\\t<ipxact:instanceName>testViewConfig</ipxact:instanceName>\\n\"\r\n        \"\\t\\t<ipxact:view viewRef=\\\"referenceToTestView\\\">\\n\"\r\n        \"\\t\\t\\t<ipxact:configurableElementValues>\\n\"\r\n        \"\\t\\t\\t\\t<ipxact:configurableElementValue referenceId=\\\"testReferenceID\\\">2</ipxact:configurableElementValue>\\n\"\r\n        \"\\t\\t\\t</ipxact:configurableElementValues>\\n\"\r\n        \"\\t\\t</ipxact:view>\\n\"\r\n        \"\\t\\t<ipxact:vendorExtensions>\\n\"\r\n        \"\\t\\t\\t<viewExtension>Yes</viewExtension>\\n\"\r\n        \"\\t\\t</ipxact:vendorExtensions>\\n\"\r\n        \"\\t</ipxact:viewConfiguration>\\n\"\r\n        \"</ipxact:designConfiguration>\\n\"\r\n    );\r\n\r\n    compareOutputToExpected(output, expectedOutput);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_DesignConfigurationWriter::testParameters()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_DesignConfigurationWriter::testParameters()\r\n{\r\n    VLNV vlnv(VLNV::DESIGNCONFIGURATION, \"tuni.fi\", \"TestLibrary\", \"TestDesignConfiguration\", \"0.1\");\r\n    designConfiguration_ = QSharedPointer<DesignConfiguration>(new DesignConfiguration(vlnv, Document::Revision::Std14));\r\n\r\n    QSharedPointer<Parameter> testParameter(new Parameter());\r\n    testParameter->setValueId(\"testID\");\r\n    testParameter->setName(\"testParameter\");\r\n    testParameter->setValue(\"1\");\r\n\r\n    designConfiguration_->getParameters()->append(testParameter);\r\n\r\n    QString output;\r\n    QXmlStreamWriter xmlStreamWriter(&output);\r\n\r\n    xmlStreamWriter.setAutoFormatting(true);\r\n    xmlStreamWriter.setAutoFormattingIndent(-1);\r\n\r\n    DesignConfigurationWriter::writeDesignConfiguration(xmlStreamWriter, designConfiguration_);\r\n\r\n    QString expectedOutput(\r\n        \"<?xml version=\\\"1.0\\\"?>\\n\"\r\n        \"<ipxact:designConfiguration \"\r\n        \"xmlns:xsi=\\\"http://www.w3.org/2001/XMLSchema-instance\\\" \" \r\n        \"xmlns:ipxact=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014\\\" \"\r\n        \"xmlns:kactus2=\\\"http://kactus2.cs.tut.fi\\\" \"\r\n        \"xsi:schemaLocation=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014 \"\r\n        \"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/index.xsd\\\"\"\r\n        \">\\n\"\r\n        \"\\t<ipxact:vendor>tuni.fi</ipxact:vendor>\\n\"\r\n        \"\\t<ipxact:library>TestLibrary</ipxact:library>\\n\"\r\n        \"\\t<ipxact:name>TestDesignConfiguration</ipxact:name>\\n\"\r\n        \"\\t<ipxact:version>0.1</ipxact:version>\\n\"\r\n        \"\\t<ipxact:parameters>\\n\"\r\n            \"\\t\\t<ipxact:parameter parameterId=\\\"testID\\\">\\n\"\r\n                \"\\t\\t\\t<ipxact:name>testParameter</ipxact:name>\\n\"\r\n                \"\\t\\t\\t<ipxact:value>1</ipxact:value>\\n\"\r\n            \"\\t\\t</ipxact:parameter>\\n\"\r\n        \"\\t</ipxact:parameters>\\n\"\r\n        \"</ipxact:designConfiguration>\\n\"\r\n        );\r\n\r\n    compareOutputToExpected(output, expectedOutput);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_DesignConfigurationWriter::testAssertion()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_DesignConfigurationWriter::testAssertion()\r\n{\r\n    VLNV vlnv(VLNV::DESIGNCONFIGURATION, \"tuni.fi\", \"TestLibrary\", \"TestDesignConfiguration\", \"0.1\");\r\n    designConfiguration_ = QSharedPointer<DesignConfiguration>(new DesignConfiguration(vlnv, Document::Revision::Std14));\r\n\r\n    QSharedPointer<Assertion> testAssertion(new Assertion());\r\n    testAssertion->setName(\"testAssertion\");\r\n    testAssertion->setDisplayName(\"assertionDisplay\");\r\n    testAssertion->setDescription(\"assertionDescription\");\r\n    testAssertion->setAssert(\"13\");\r\n\r\n    designConfiguration_->getAssertions()->append(testAssertion);\r\n\r\n    QString output;\r\n    QXmlStreamWriter xmlStreamWriter(&output);\r\n\r\n    xmlStreamWriter.setAutoFormatting(true);\r\n    xmlStreamWriter.setAutoFormattingIndent(-1);\r\n\r\n    DesignConfigurationWriter::writeDesignConfiguration(xmlStreamWriter, designConfiguration_);\r\n\r\n    QString expectedOutput(\r\n        \"<?xml version=\\\"1.0\\\"?>\\n\"\r\n        \"<ipxact:designConfiguration \"\r\n        \"xmlns:xsi=\\\"http://www.w3.org/2001/XMLSchema-instance\\\" \" \r\n        \"xmlns:ipxact=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014\\\" \"\r\n        \"xmlns:kactus2=\\\"http://kactus2.cs.tut.fi\\\" \"\r\n        \"xsi:schemaLocation=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014 \"\r\n        \"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/index.xsd\\\"\"\r\n        \">\\n\"\r\n        \"\\t<ipxact:vendor>tuni.fi</ipxact:vendor>\\n\"\r\n        \"\\t<ipxact:library>TestLibrary</ipxact:library>\\n\"\r\n        \"\\t<ipxact:name>TestDesignConfiguration</ipxact:name>\\n\"\r\n        \"\\t<ipxact:version>0.1</ipxact:version>\\n\"\r\n        \"\\t<ipxact:assertions>\\n\"\r\n            \"\\t\\t<ipxact:assertion>\\n\"\r\n                \"\\t\\t\\t<ipxact:name>testAssertion</ipxact:name>\\n\"\r\n                \"\\t\\t\\t<ipxact:displayName>assertionDisplay</ipxact:displayName>\\n\"\r\n                \"\\t\\t\\t<ipxact:description>assertionDescription</ipxact:description>\\n\"\r\n                \"\\t\\t\\t<ipxact:assert>13</ipxact:assert>\\n\"\r\n            \"\\t\\t</ipxact:assertion>\\n\"\r\n        \"\\t</ipxact:assertions>\\n\"\r\n        \"</ipxact:designConfiguration>\\n\"\r\n        );\r\n\r\n    compareOutputToExpected(output, expectedOutput);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_DesignConfigurationWriter::testVendorExtensions()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_DesignConfigurationWriter::testVendorExtensions()\r\n{\r\n    VLNV vlnv(VLNV::DESIGNCONFIGURATION, \"tuni.fi\", \"TestLibrary\", \"TestDesignConfiguration\", \"0.1\");\r\n    designConfiguration_ = QSharedPointer<DesignConfiguration>(new DesignConfiguration(vlnv, Document::Revision::Std14));\r\n\r\n    QDomDocument document;\r\n    QDomElement extensionNode = document.createElement(\"testExtension\");\r\n    extensionNode.setAttribute(\"testExtensionAttribute\", \"extension\");\r\n    extensionNode.appendChild(document.createTextNode(\"testValue\"));\r\n\r\n    QSharedPointer<GenericVendorExtension> testExtension(new GenericVendorExtension(extensionNode));\r\n\r\n    designConfiguration_->getVendorExtensions()->append(testExtension);\r\n    designConfiguration_->setVersion(\"3.0.0\");\r\n\r\n    QString output;\r\n    QXmlStreamWriter xmlStreamWriter(&output);\r\n\r\n    xmlStreamWriter.setAutoFormatting(true);\r\n    xmlStreamWriter.setAutoFormattingIndent(-1);\r\n\r\n    DesignConfigurationWriter::writeDesignConfiguration(xmlStreamWriter, designConfiguration_);\r\n\r\n    QString expectedOutput(\r\n        \"<?xml version=\\\"1.0\\\"?>\\n\"\r\n        \"<ipxact:designConfiguration \"\r\n        \"xmlns:xsi=\\\"http://www.w3.org/2001/XMLSchema-instance\\\" \" \r\n        \"xmlns:ipxact=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014\\\" \"\r\n        \"xmlns:kactus2=\\\"http://kactus2.cs.tut.fi\\\" \"\r\n        \"xsi:schemaLocation=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014 \"\r\n        \"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/index.xsd\\\"\"\r\n        \">\\n\"\r\n        \"\\t<ipxact:vendor>tuni.fi</ipxact:vendor>\\n\"\r\n        \"\\t<ipxact:library>TestLibrary</ipxact:library>\\n\"\r\n        \"\\t<ipxact:name>TestDesignConfiguration</ipxact:name>\\n\"\r\n        \"\\t<ipxact:version>0.1</ipxact:version>\\n\"\r\n        \"\\t<ipxact:vendorExtensions>\\n\"\r\n            \"\\t\\t<testExtension testExtensionAttribute=\\\"extension\\\">testValue</testExtension>\\n\"\r\n            \"\\t\\t<kactus2:version>3.0.0</kactus2:version>\\n\"\r\n        \"\\t</ipxact:vendorExtensions>\\n\"\r\n        \"</ipxact:designConfiguration>\\n\"\r\n        );\r\n\r\n    compareOutputToExpected(output, expectedOutput);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_DesignConfigurationWriter::testWriteViewOverrides()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_DesignConfigurationWriter::testWriteViewOverrides()\r\n{\r\n    VLNV vlnv(VLNV::DESIGNCONFIGURATION, \"tuni.fi\", \"TestLibrary\", \"TestDesignConfiguration\", \"0.1\");\r\n    designConfiguration_ = QSharedPointer<DesignConfiguration>(new DesignConfiguration(vlnv, Document::Revision::Std14));\r\n\r\n    QMap<QString, QString> viewOverrides;\r\n    viewOverrides.insert(\"instanceId\", \"testView\");\r\n    viewOverrides.insert(\"otherId\", \"otherView\");\r\n\r\n    designConfiguration_->setVersion(\"3.0.0\");\r\n    designConfiguration_->setKactus2ViewOverrides(viewOverrides);\r\n\r\n    QString output;\r\n    QXmlStreamWriter xmlStreamWriter(&output);\r\n\r\n    xmlStreamWriter.setAutoFormatting(true);\r\n    xmlStreamWriter.setAutoFormattingIndent(-1);\r\n\r\n    DesignConfigurationWriter::writeDesignConfiguration(xmlStreamWriter, designConfiguration_);\r\n\r\n    QString expectedOutput(\r\n        \"<?xml version=\\\"1.0\\\"?>\\n\"\r\n        \"<ipxact:designConfiguration \"\r\n        \"xmlns:xsi=\\\"http://www.w3.org/2001/XMLSchema-instance\\\" \" \r\n        \"xmlns:ipxact=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014\\\" \"\r\n        \"xmlns:kactus2=\\\"http://kactus2.cs.tut.fi\\\" \"\r\n        \"xsi:schemaLocation=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014 \"\r\n        \"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/index.xsd\\\">\\n\"\r\n            \"\\t<ipxact:vendor>tuni.fi</ipxact:vendor>\\n\"\r\n            \"\\t<ipxact:library>TestLibrary</ipxact:library>\\n\"\r\n            \"\\t<ipxact:name>TestDesignConfiguration</ipxact:name>\\n\"\r\n            \"\\t<ipxact:version>0.1</ipxact:version>\\n\"\r\n            \"\\t<ipxact:vendorExtensions>\\n\"\r\n                \"\\t\\t<kactus2:version>3.0.0</kactus2:version>\\n\"\r\n                \"\\t\\t<kactus2:viewOverrides>\\n\"\r\n                    \"\\t\\t\\t<kactus2:instanceView id=\\\"instanceId\\\" viewName=\\\"testView\\\"/>\\n\"\r\n                    \"\\t\\t\\t<kactus2:instanceView id=\\\"otherId\\\" viewName=\\\"otherView\\\"/>\\n\"\r\n                \"\\t\\t</kactus2:viewOverrides>\\n\"\r\n            \"\\t</ipxact:vendorExtensions>\\n\"\r\n        \"</ipxact:designConfiguration>\\n\"\r\n        );\r\n\r\n    compareOutputToExpected(output, expectedOutput);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_DesignConfigurationWriter::compareOutputToExpected()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_DesignConfigurationWriter::compareOutputToExpected(QString const& output, QString const& expectedOutput)\r\n{\r\n    if (!output.contains(expectedOutput))\r\n    {\r\n        QStringList outputLines = output.split(\"\\n\");\r\n        QStringList expectedLines = expectedOutput.split(\"\\n\");\r\n\r\n        QVERIFY(outputLines.count() >= expectedLines.count());\r\n\r\n        int lineOffset = outputLines.indexOf(expectedLines.first());\r\n        if (lineOffset == -1)\r\n        {\r\n            QCOMPARE(output, expectedOutput);\r\n        }\r\n        else\r\n        {\r\n            int lineCount = expectedLines.count();\r\n            for (int i = 0; i < lineCount; ++i)\r\n            {\r\n                QCOMPARE(outputLines.at(i + lineOffset), expectedLines.at(i));\r\n            }\r\n        }\r\n    }\r\n    else if (output.count(expectedOutput) != 1)\r\n    {\r\n        QVERIFY2(false, QString(expectedOutput + \" was found \" + QString::number(output.count(expectedOutput)) +\r\n            \" times in output.\").toLocal8Bit());\r\n    }\r\n}\r\n\r\nQTEST_APPLESS_MAIN(tst_DesignConfigurationWriter)\r\n\r\n#include \"tst_DesignConfigurationWriter.moc\"\r\n"
  },
  {
    "path": "tests/IPXACTmodels/DesignConfiguration/tst_DesignConfigurationWriter.pri",
    "content": "# ----------------------------------------------------\r\n# This file is generated by the Qt Visual Studio Add-in.\r\n# ------------------------------------------------------\r\n\r\nSOURCES += ./tst_DesignConfigurationWriter.cpp\r\n"
  },
  {
    "path": "tests/IPXACTmodels/DesignConfiguration/tst_DesignConfigurationWriter.pro",
    "content": "#-----------------------------------------------------------------------------\r\n# File: DesignConfigurationWriter.pro\r\n#-----------------------------------------------------------------------------\r\n# Project: Kactus 2\r\n# Author: Mikko Teuho\r\n# Date: 3.8.2015\r\n#\r\n# Description:\r\n# Qt project file for running unit tests for design configuration writer.\r\n#-----------------------------------------------------------------------------\r\n\r\nTEMPLATE = app\r\n\r\nTARGET = tst_DesignConfigurationWriter\r\n\r\nQT += core xml testlib\r\nQT -= gui\r\n\r\nCONFIG += c++11 testcase console\r\n\r\nlinux-g++ | linux-g++-64 | linux-g++-32 {\r\n LIBS += -L../../../executable \\\r\n     -lIPXACTmodels\r\n\r\n}\r\nwin64 | win32 {\r\n LIBS += -L../../../executable \\\r\n     -lIPXACTmodelsd\r\n}\r\n\r\nDESTDIR = ./release\r\n\r\nINCLUDEPATH += $$DESTDIR\r\nINCLUDEPATH += ../../../\r\n\r\nDEPENDPATH += .\r\n\r\nOBJECTS_DIR += $$DESTDIR\r\n\r\nMOC_DIR += ./generatedFiles\r\nUI_DIR += ./generatedFiles\r\nRCC_DIR += ./generatedFiles\r\ninclude(tst_DesignConfigurationWriter.pri)\r\n"
  },
  {
    "path": "tests/IPXACTmodels/IPXACTmodels.pro",
    "content": "#-----------------------------------------------------------------------------\r\n# File: IPXACTmodels.pro\r\n#-----------------------------------------------------------------------------\r\n# Project: Kactus 2\r\n# Author: Esko Pekkarinen\r\n# Date: 24.27.2014\r\n#\r\n# Description:\r\n# Qt project file template for running unit tests in IPXACTmodels.\r\n#-----------------------------------------------------------------------------\r\n\r\nTEMPLATE = subdirs\r\n\r\nCONFIG += testcase\r\nSUBDIRS += AbstractionDefinition\\AbstractionDefinition.pro \\\r\n\t\t   BusDefinition\\BusDefinition.pro \\\r\n\t\t   Catalog\\Catalog.pro\\\r\n\t\t   DesignConfiguration\\DesignConfiguration.pro \\\r\n\t\t   Design\\Design.pro \\\r\n\t\t   Component\\Component.pro \\\r\n\t\t   KactusExtensions\\KactusExtensions.pro \r\n"
  },
  {
    "path": "tests/IPXACTmodels/KactusExtensions/KactusExtensions.pro",
    "content": "#-----------------------------------------------------------------------------\n# File: BusDefinition.pro\n#-----------------------------------------------------------------------------\n# Project: Kactus2\n# Author: Esko Pekkarinen\n# Date: 04.05.2018\n#\n# Description:\n# Qt project file template for running unit tests for BusDefinition.\n#-----------------------------------------------------------------------------\n\nTEMPLATE = subdirs\n\nCONFIG += testcase\nSUBDIRS += tst_ComDefinitionWriter.pro \\\n\t\t   tst_ComDefinitionReader.pro \\\n\t\t   tst_ComDefinitionValidator.pro \\\n\t\t   tst_ApiDefinitionWriter.pro \\\n\t\t   tst_ApiDefinitionReader.pro \\\n\t\t   tst_ApiDefinitionValidator.pro \n"
  },
  {
    "path": "tests/IPXACTmodels/KactusExtensions/tst_ApiDefinitionReader.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: tst_ApiDefinitionReader.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Janne Virtanen\n// Date: 28.01.2016\n//\n// Description:\n// Unit test for class ApiDefinitionReader.\n//-----------------------------------------------------------------------------\n\n#include <IPXACTmodels/kactusExtensions/ApiDefinitionReader.h>\n#include <IPXACTmodels/kactusExtensions/ApiDefinition.h>\n\n#include <QtTest>\n\nclass tst_ApiDefinitionReader : public QObject\n{\n    Q_OBJECT\n\npublic:\n\ttst_ApiDefinitionReader();\n\nprivate slots:\n\tvoid baseCase();\n};\n\n//-----------------------------------------------------------------------------\n// Function: tst_ApiDefinitionReader::tst_ApiDefinitionReader()\n//-----------------------------------------------------------------------------\ntst_ApiDefinitionReader::tst_ApiDefinitionReader()\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_ApiDefinitionReader::baseCase()\n//-----------------------------------------------------------------------------\nvoid tst_ApiDefinitionReader::baseCase()\n{\n\tQString documentContent(\n\t\t\"<?xml version=\\\"1.0\\\"?>\"\n\t\t\"<kactus2:apiDefinition xmlns:xsi=\\\"http://www.w3.org/2001/XMLSchema-instance\\\"\"\n\t\t\" xmlns:ipxact=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014\\\"\"\n\t\t\" xmlns:kactus2=\\\"http://kactus2.cs.tut.fi\\\"\"\n\t\t\" xsi:schemaLocation=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/\"\n\t\t\" http://www.accellera.org/XMLSchema/IPXACT/1685-2014/index.xsd\\\">\"\n\t\t\"<ipxact:vendor>me</ipxact:vendor>\"\n\t\t\"<ipxact:library>kurjasto</ipxact:library>\"\n\t\t\"<ipxact:name>def</ipxact:name>\"\n\t\t\"<ipxact:version>0.11</ipxact:version>\"\n\t\t\"<kactus2:comDefinitionRef vendor=\\\"he\\\" library=\\\"s-lib\\\" name=\\\"cdef\\\" version=\\\"1.337\\\"/>\"\n\t\t\"<kactus2:dataTypes><kactus2:dataType name=\\\"new item\\\"/></kactus2:dataTypes>\"\n\t\t\"<kactus2:functions>\"\n\t\t\"<kactus2:function name=\\\"hjjhjh\\\" description=\\\"yryry\\\">\"\n\t\t\"<kactus2:returnValue type=\\\"void\\\" description=\\\"lolol\\\"/>\"\n\t\t\"</kactus2:function>\"\n        \"</kactus2:functions>\"\n        \"<ipxact:vendorExtensions>\"\n        \"<testExtension vendorAttribute=\\\"extension\\\">testValue</testExtension>\"\n        \"<kactus2:version>3.0.0</kactus2:version>\"\n        \"</ipxact:vendorExtensions>\"\n\t\t\"</kactus2:apiDefinition>\\n\"\n\t\t);\n\n    QDomDocument document;\n    document.setContent(documentContent);\n\n    QSharedPointer<ApiDefinition> testApiDefinition = ApiDefinitionReader::createApiDefinitionFrom(document);\n\n\tQCOMPARE(testApiDefinition->getVlnv().getVendor(), QString(\"me\"));\n\tQCOMPARE(testApiDefinition->getVlnv().getLibrary(), QString(\"kurjasto\"));\n\tQCOMPARE(testApiDefinition->getVlnv().getName(), QString(\"def\"));\n\tQCOMPARE(testApiDefinition->getVlnv().getVersion(), QString(\"0.11\"));\n\n\tQCOMPARE(testApiDefinition->getComDefinitionRef().getVendor(), QString(\"he\"));\n\tQCOMPARE(testApiDefinition->getComDefinitionRef().getLibrary(), QString(\"s-lib\"));\n\tQCOMPARE(testApiDefinition->getComDefinitionRef().getName(), QString(\"cdef\"));\n\tQCOMPARE(testApiDefinition->getComDefinitionRef().getVersion(), QString(\"1.337\"));\n\n\tQCOMPARE(testApiDefinition->getDataTypes()->first(), QString(\"new item\"));\n\n\tQCOMPARE(testApiDefinition->getFunctions()->first()->name(), QString(\"hjjhjh\"));\n\tQCOMPARE(testApiDefinition->getFunctions()->first()->getDescription(), QString(\"yryry\"));\n\tQCOMPARE(testApiDefinition->getFunctions()->first()->getReturnValueType(), QString(\"void\"));\n    QCOMPARE(testApiDefinition->getFunctions()->first()->getReturnValueDescription(), QString(\"lolol\"));\n\n    QCOMPARE(testApiDefinition->getVendorExtensions()->size(), 2);\n    QCOMPARE(testApiDefinition->getVendorExtensions()->last()->type(), QString(\"testExtension\"));\n    QCOMPARE(testApiDefinition->getVendorExtensions()->first()->type(), QString(\"kactus2:version\"));\n}\n\nQTEST_APPLESS_MAIN(tst_ApiDefinitionReader)\n\n#include \"tst_ApiDefinitionReader.moc\"\n"
  },
  {
    "path": "tests/IPXACTmodels/KactusExtensions/tst_ApiDefinitionReader.pri",
    "content": "# ----------------------------------------------------\r\n# This file is generated by the Qt Visual Studio Add-in.\r\n# ------------------------------------------------------\r\n\r\nSOURCES += ./tst_ApiDefinitionReader.cpp\r\n  "
  },
  {
    "path": "tests/IPXACTmodels/KactusExtensions/tst_ApiDefinitionReader.pro",
    "content": "#-----------------------------------------------------------------------------\r\n# File: tst_ApiDefinitionReader.pro\r\n#-----------------------------------------------------------------------------\r\n# Project: Kactus 2\r\n# Author: Janne Virtanen\r\n# Date: 28.01.2016\r\n#\r\n# Description:\r\n# Qt project file template for running unit tests for ApiDefinition reader.\r\n#-----------------------------------------------------------------------------\r\n\r\nTEMPLATE = app\r\n\r\nTARGET = tst_ApiDefinitionReader\r\n\r\nQT += core xml testlib\r\nQT -= gui\r\n\r\nCONFIG += c++11 testcase console\r\n\r\nlinux-g++ | linux-g++-64 | linux-g++-32 {\r\n LIBS += -L../../../executable \\\r\n     -lIPXACTmodels\r\n\r\n}\r\nwin64 | win32 {\r\n LIBS += -L../../../executable \\\r\n     -lIPXACTmodelsd\r\n}\r\n\r\nDESTDIR = ./release\r\n\r\nINCLUDEPATH += $$DESTDIR\r\nINCLUDEPATH += ../../../\r\n\r\nDEPENDPATH += .\r\nDEPENDPATH += ../../../\r\n\r\nOBJECTS_DIR += $$DESTDIR\r\n\r\nMOC_DIR += ./generatedFiles\r\nUI_DIR += ./generatedFiles\r\nRCC_DIR += ./generatedFiles\r\ninclude(tst_ApiDefinitionReader.pri)\r\n"
  },
  {
    "path": "tests/IPXACTmodels/KactusExtensions/tst_ApiDefinitionValidator.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: tst_ApiDefinitionValidator.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Janne Virtanen\r\n// Date: 28.01.2016\r\n//\r\n// Description:\r\n// Unit test for class ApiDefinitionValidator.\r\n//-----------------------------------------------------------------------------\r\n\r\n\r\n#include <IPXACTmodels/kactusExtensions/ApiDefinition.h>\r\n#include <IPXACTmodels/kactusExtensions/validators/ApiDefinitionValidator.h>\r\n\r\n#include <QtTest>\r\n\r\nclass tst_ApiDefinitionValidator : public QObject\r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n    tst_ApiDefinitionValidator();\r\n\r\nprivate slots:\r\n\tvoid baseCase();\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ApiDefinitionValidator::tst_ApiDefinitionValidator()\r\n//-----------------------------------------------------------------------------\r\ntst_ApiDefinitionValidator::tst_ApiDefinitionValidator()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ApiDefinitionValidator::baseCase()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ApiDefinitionValidator::baseCase()\r\n{\r\n\tQSharedPointer<ApiDefinition> apiDefinition(new ApiDefinition(\r\n\t\tVLNV(VLNV::APIDEFINITION, \"me\", \"kurjasto\", \"def\", \"0.11\"), Document::Revision::Std14));\r\n\r\n\r\n\tQVector<QString> errorList;\r\n    ApiDefinitionValidator validator;\r\n\tvalidator.findErrorsIn(errorList, apiDefinition);\r\n\r\n\tQVERIFY(validator.validate(apiDefinition));\r\n    QCOMPARE(errorList.size(), 0);\r\n}\r\n\r\nQTEST_APPLESS_MAIN(tst_ApiDefinitionValidator)\r\n\r\n#include \"tst_ApiDefinitionValidator.moc\"\r\n"
  },
  {
    "path": "tests/IPXACTmodels/KactusExtensions/tst_ApiDefinitionValidator.pri",
    "content": "# ----------------------------------------------------\r\n# This file is generated by the Qt Visual Studio Add-in.\r\n# ------------------------------------------------------\r\n\r\nSOURCES += ./tst_ApiDefinitionValidator.cpp\r\n"
  },
  {
    "path": "tests/IPXACTmodels/KactusExtensions/tst_ApiDefinitionValidator.pro",
    "content": "#-----------------------------------------------------------------------------\r\n# File: tst_ApiDefinitionValidator.pro\r\n#-----------------------------------------------------------------------------\r\n# Project: Kactus 2\r\n# Author: Janne Virtanen\r\n# Date: 28.01.2016\r\n#\r\n# Description:\r\n# Qt project file template for running unit tests for ApiDefinition Validator.\r\n#-----------------------------------------------------------------------------\r\n\r\nTEMPLATE = app\r\n\r\nTARGET = tst_ApiDefinitionValidator\r\n\r\nQT += core gui xml testlib\r\nCONFIG += c++11 testcase console\r\n\r\nlinux-g++ | linux-g++-64 | linux-g++-32 {\r\n LIBS += -L../../../executable \\\r\n     -lIPXACTmodels\r\n\r\n}\r\nwin64 | win32 {\r\n LIBS += -L../../../executable \\\r\n     -lIPXACTmodelsd\r\n}\r\n\r\nDESTDIR = ./release\r\n\r\nINCLUDEPATH += $$DESTDIR\r\nINCLUDEPATH += ../../../\r\n\r\nDEPENDPATH += .\r\nDEPENDPATH += ../../../\r\n\r\nOBJECTS_DIR += $$DESTDIR\r\n\r\nMOC_DIR += ./generatedFiles\r\nUI_DIR += ./generatedFiles\r\nRCC_DIR += ./generatedFiles\r\ninclude(tst_ApiDefinitionValidator.pri)\r\n"
  },
  {
    "path": "tests/IPXACTmodels/KactusExtensions/tst_ApiDefinitionWriter.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: tst_ApiDefinitionWriter.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Janne Virtanen\r\n// Date: 11.12.2015\r\n//\r\n// Description:\r\n// Unit test for class ApiDefinitionWriter.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include <IPXACTmodels/kactusExtensions/ApiDefinitionWriter.h>\r\n\r\n#include <IPXACTmodels/common/GenericVendorExtension.h>\r\n\r\n#include <QtTest>\r\n\r\nclass tst_ApiDefinitionWriter : public QObject\r\n{\r\n    Q_OBJECT\r\n\r\npublic:\r\n\ttst_ApiDefinitionWriter();\r\n\r\nprivate slots:\r\n\tvoid init();\r\n\tvoid cleanup();\r\n\r\n\tvoid baseCase();\r\n\r\nprivate:\r\n\r\n\tQSharedPointer<ApiDefinition> testApiDefinition_;\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ApiDefinitionWriter::tst_ApiDefinitionWriter()\r\n//-----------------------------------------------------------------------------\r\ntst_ApiDefinitionWriter::tst_ApiDefinitionWriter()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ApiDefinitionWriter::init()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ApiDefinitionWriter::init()\r\n{\r\n\ttestApiDefinition_ = QSharedPointer<ApiDefinition>(new ApiDefinition(VLNV(), Document::Revision::Std14));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ApiDefinitionWriter::cleanup()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ApiDefinitionWriter::cleanup()\r\n{\r\n\ttestApiDefinition_.clear();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ApiDefinitionWriter::baseCase()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ApiDefinitionWriter::baseCase()\r\n{\r\n\tQString output;\r\n\tQXmlStreamWriter xmlStreamWriter(&output);\r\n\r\n\ttestApiDefinition_->setVlnv(VLNV(VLNV::APIDEFINITION,\"me\",\"kurjasto\",\"def\",\"0.11\"));\r\n\ttestApiDefinition_->setComDefinitionRef(VLNV(VLNV::COMDEFINITION,\"he\",\"s-lib\",\"cdef\",\"1.337\"));\r\n\ttestApiDefinition_->getDataTypes()->append(\"new item\");\r\n\r\n\tQSharedPointer<ApiFunction> func( new ApiFunction );\r\n\tfunc->setName(\"hjjhjh\");\r\n\tfunc->setDescription(\"yryry\");\r\n\tfunc->setReturnValueType(\"void\");\r\n\tfunc->setReturnValueDescription(\"lolol\");\r\n\r\n    testApiDefinition_->getFunctions()->append(func);\r\n\r\n    QDomDocument document;\r\n    QDomElement extensionNode = document.createElement(\"testExtension\");\r\n    extensionNode.setAttribute(\"testExtensionAttribute\", \"extension\");\r\n    extensionNode.appendChild(document.createTextNode(\"testValue\"));\r\n\r\n    QSharedPointer<GenericVendorExtension> testExtension(new GenericVendorExtension(extensionNode));\r\n\r\n    testApiDefinition_->getVendorExtensions()->append(testExtension);\r\n    testApiDefinition_->setVersion(\"3.0.0\");\r\n\r\n\tQString expectedOutput(\r\n\t\t\"<?xml version=\\\"1.0\\\"?>\"\r\n\t\t\"<kactus2:apiDefinition xmlns:xsi=\\\"http://www.w3.org/2001/XMLSchema-instance\\\"\"\r\n\t\t\" xmlns:ipxact=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014\\\"\"\r\n\t\t\" xmlns:kactus2=\\\"http://kactus2.cs.tut.fi\\\"\"\r\n\t\t\" xsi:schemaLocation=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014\"\r\n\t\t\" http://www.accellera.org/XMLSchema/IPXACT/1685-2014/index.xsd\\\">\"\r\n\t\t\"<ipxact:vendor>me</ipxact:vendor>\"\r\n\t\t\"<ipxact:library>kurjasto</ipxact:library>\"\r\n\t\t\"<ipxact:name>def</ipxact:name>\"\r\n\t\t\"<ipxact:version>0.11</ipxact:version>\"\r\n\t\t\"<kactus2:comDefinitionRef vendor=\\\"he\\\" library=\\\"s-lib\\\" name=\\\"cdef\\\" version=\\\"1.337\\\"/>\"\r\n\t\t\"<kactus2:dataTypes><kactus2:dataType name=\\\"new item\\\"/></kactus2:dataTypes>\"\r\n\t\t\"<kactus2:functions>\"\r\n\t\t\"<kactus2:function name=\\\"hjjhjh\\\" description=\\\"yryry\\\">\"\r\n\t\t\"<kactus2:returnValue type=\\\"void\\\" description=\\\"lolol\\\"/>\"\r\n\t\t\"</kactus2:function>\"\r\n        \"</kactus2:functions>\"\r\n        \"<ipxact:vendorExtensions>\"\r\n        \"<testExtension testExtensionAttribute=\\\"extension\\\">testValue</testExtension>\"\r\n        \"<kactus2:version>3.0.0</kactus2:version>\"\r\n        \"</ipxact:vendorExtensions>\"\r\n\t\t\"</kactus2:apiDefinition>\\n\"\r\n\t\t);\r\n\r\n\tApiDefinitionWriter::writeApiDefinition(xmlStreamWriter, testApiDefinition_);\r\n\tQCOMPARE(output, expectedOutput);\r\n}\r\n\r\nQTEST_APPLESS_MAIN(tst_ApiDefinitionWriter)\r\n\r\n#include \"tst_ApiDefinitionWriter.moc\"\r\n"
  },
  {
    "path": "tests/IPXACTmodels/KactusExtensions/tst_ApiDefinitionWriter.pri",
    "content": "# ----------------------------------------------------\r\n# This file is generated by the Qt Visual Studio Add-in.\r\n# ------------------------------------------------------\r\n\r\nSOURCES += ./tst_ApiDefinitionWriter.cpp \r\n "
  },
  {
    "path": "tests/IPXACTmodels/KactusExtensions/tst_ApiDefinitionWriter.pro",
    "content": "#-----------------------------------------------------------------------------\r\n# File: tst_ApiDefinitionWriter.pro\r\n#-----------------------------------------------------------------------------\r\n# Project: Kactus 2\r\n# Author: Janne Virtanen\r\n# Date: 11.12.2015\r\n#\r\n# Description:\r\n# Qt project file template for running unit tests for ApiDefinition writer.\r\n#-----------------------------------------------------------------------------\r\n\r\nTEMPLATE = app\r\n\r\nTARGET = tst_ApiDefinitionWriter\r\n\r\nQT += core xml testlib\r\nQT -= gui\r\n\r\nCONFIG += c++11 testcase console\r\n\r\nlinux-g++ | linux-g++-64 | linux-g++-32 {\r\n LIBS += -L../../../executable \\\r\n     -lIPXACTmodels\r\n\r\n}\r\nwin64 | win32 {\r\n LIBS += -L../../../executable \\\r\n     -lIPXACTmodelsd\r\n}\r\n\r\nDESTDIR = ./release\r\n\r\nINCLUDEPATH += $$DESTDIR\r\nINCLUDEPATH += ../../../\r\n\r\nDEPENDPATH += .\r\nDEPENDPATH += ../../../\r\n\r\nOBJECTS_DIR += $$DESTDIR\r\n\r\nMOC_DIR += ./generatedFiles\r\nUI_DIR += ./generatedFiles\r\nRCC_DIR += ./generatedFiles\r\ninclude(tst_ApiDefinitionWriter.pri)\r\n"
  },
  {
    "path": "tests/IPXACTmodels/KactusExtensions/tst_ComDefinitionReader.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: tst_ComDefinitionReader.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Janne Virtanen\n// Date: 28.01.2016\n//\n// Description:\n// Unit test for class ComDefinitionReader.\n//-----------------------------------------------------------------------------\n\n#include <IPXACTmodels/kactusExtensions/ComDefinitionReader.h>\n#include <IPXACTmodels/kactusExtensions/ComDefinition.h>\n\n#include <QtTest>\n\nclass tst_ComDefinitionReader : public QObject\n{\n    Q_OBJECT\n\npublic:\n\ttst_ComDefinitionReader();\n\nprivate slots:\n    void testProperty();\n    void allFields();\n};\n\n//-----------------------------------------------------------------------------\n// Function: tst_ComDefinitionReader::tst_ComDefinitionReader()\n//-----------------------------------------------------------------------------\ntst_ComDefinitionReader::tst_ComDefinitionReader()\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_ComDefinitionReader::testProperty()\n//-----------------------------------------------------------------------------\nvoid tst_ComDefinitionReader::testProperty()\n{\n    QString documentContent(\n        \"<?xml version=\\\"1.0\\\"?>\"\n        \"<kactus2:comDefinition xmlns:xsi=\\\"http://www.w3.org/2001/XMLSchema-instance\\\"\"\n        \" xmlns:ipxact=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014\\\"\"\n        \" xmlns:kactus2=\\\"http://kactus2.cs.tut.fi\\\"\"\n        \" xsi:schemaLocation=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/\"\n        \" http://www.accellera.org/XMLSchema/IPXACT/1685-2014/index.xsd\\\">\"\n            \"<kactus2:properties>\"\n                \"<kactus2:property name=\\\"default_target\\\" required=\\\"true\\\" propertyType=\\\"string\\\" defaultValue=\\\"moon\\\" description=\\\"Where stuff is sent by default.\\\"/>\"\n            \"</kactus2:properties>\"\n        \"</kactus2:comDefinition>\\n\"\n        );\n\n    QDomDocument document;\n    document.setContent(documentContent);\n\n    QSharedPointer<ComDefinition> testComDefinition = ComDefinitionReader::createComDefinitionFrom(document);\n\n    QCOMPARE(testComDefinition->getProperties().size(), 1);\n\n    QSharedPointer<ComProperty> prop = testComDefinition->getProperties().first();\n\n    QCOMPARE(prop->name(), QString(\"default_target\"));\n    QCOMPARE(prop->isRequired(), true);\n    QCOMPARE(prop->getType(), QString(\"string\"));\n    QCOMPARE(prop->getDefaultValue(), QString(\"moon\"));\n    QCOMPARE(prop->getDescription(), QString(\"Where stuff is sent by default.\"));\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_ComDefinitionReader::allFields()\n//-----------------------------------------------------------------------------\nvoid tst_ComDefinitionReader::allFields()\n{\n    QString documentContent(\n        \"<?xml version=\\\"1.0\\\"?>\"\n        \"<kactus2:comDefinition xmlns:xsi=\\\"http://www.w3.org/2001/XMLSchema-instance\\\"\"\n        \" xmlns:ipxact=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014\\\"\"\n        \" xmlns:kactus2=\\\"http://kactus2.cs.tut.fi\\\"\"\n        \" xsi:schemaLocation=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014/\"\n        \" http://www.accellera.org/XMLSchema/IPXACT/1685-2014/index.xsd\\\">\"\n            \"<ipxact:vendor>me</ipxact:vendor>\"\n            \"<ipxact:library>kurjasto</ipxact:library>\"\n            \"<ipxact:name>def</ipxact:name>\"\n            \"<ipxact:version>0.11</ipxact:version>\"\n            \"<kactus2:transferTypes/>\"\n            \"<kactus2:properties>\"\n                \"<kactus2:property name=\\\"max_transfer_size\\\" required=\\\"true\\\" propertyType=\\\"integer\\\" defaultValue=\\\"128\\\" description=\\\"Maximum size of a single transfer\\\"/>\"\n            \"</kactus2:properties>\"\n            \"<ipxact:vendorExtensions>\"\n                \"<testExtension vendorAttribute=\\\"extension\\\">testValue</testExtension>\"\n                \"<kactus2:version>3.0.0</kactus2:version>\"\n            \"</ipxact:vendorExtensions>\"\n        \"</kactus2:comDefinition>\\n\"\n        );\n\n    QDomDocument document;\n    document.setContent(documentContent);\n\n    QSharedPointer<ComDefinition> testComDefinition = ComDefinitionReader::createComDefinitionFrom(document);\n\n    QCOMPARE(testComDefinition->getVlnv().getVendor(), QString(\"me\"));\n    QCOMPARE(testComDefinition->getVlnv().getLibrary(), QString(\"kurjasto\"));\n    QCOMPARE(testComDefinition->getVlnv().getName(), QString(\"def\"));\n    QCOMPARE(testComDefinition->getVlnv().getVersion(), QString(\"0.11\"));\n\n    QCOMPARE(testComDefinition->getProperties().size(), 1);\n\n    QSharedPointer<ComProperty> prop = testComDefinition->getProperties().first();\n\n    QCOMPARE(prop->name(), QString(\"max_transfer_size\"));\n    QCOMPARE(prop->isRequired(), true);\n    QCOMPARE(prop->getType(), QString(\"integer\"));\n    QCOMPARE(prop->getDefaultValue(), QString(\"128\"));\n    QCOMPARE(prop->getDescription(), QString(\"Maximum size of a single transfer\"));\n\n    QCOMPARE(testComDefinition->getVendorExtensions()->size(), 2);\n    QCOMPARE(testComDefinition->getVendorExtensions()->last()->type(), QString(\"testExtension\"));\n    QCOMPARE(testComDefinition->getVendorExtensions()->first()->type(), QString(\"kactus2:version\"));\n}\n\nQTEST_APPLESS_MAIN(tst_ComDefinitionReader)\n\n#include \"tst_ComDefinitionReader.moc\"\n"
  },
  {
    "path": "tests/IPXACTmodels/KactusExtensions/tst_ComDefinitionReader.pri",
    "content": "# ----------------------------------------------------\r\n# This file is generated by the Qt Visual Studio Tools.\r\n# ------------------------------------------------------\r\n\r\nSOURCES += ./tst_ComDefinitionReader.cpp\r\n   "
  },
  {
    "path": "tests/IPXACTmodels/KactusExtensions/tst_ComDefinitionReader.pro",
    "content": "#-----------------------------------------------------------------------------\r\n# File: tst_ComDefinitionReader.pro\r\n#-----------------------------------------------------------------------------\r\n# Project: Kactus 2\r\n# Author: Janne Virtanen\r\n# Date: 28.01.2016\r\n#\r\n# Description:\r\n# Qt project file template for running unit tests for ComDefinition reader.\r\n#-----------------------------------------------------------------------------\r\n\r\nTEMPLATE = app\r\n\r\nTARGET = tst_ComDefinitionReader\r\n\r\nQT += core xml testlib\r\nQT -= gui\r\n\r\nCONFIG += c++11 testcase console\r\n\r\nlinux-g++ | linux-g++-64 | linux-g++-32 {\r\n LIBS += -L../../../executable \\\r\n     -lIPXACTmodels\r\n\r\n}\r\nwin64 | win32 {\r\n LIBS += -L../../../executable \\\r\n     -lIPXACTmodelsd\r\n}\r\n\r\nDESTDIR = ./release\r\n\r\nINCLUDEPATH += $$DESTDIR\r\nINCLUDEPATH += ../../../\r\n\r\nDEPENDPATH += .\r\nDEPENDPATH += ../../../\r\n\r\nOBJECTS_DIR += $$DESTDIR\r\n\r\nMOC_DIR += ./generatedFiles\r\nUI_DIR += ./generatedFiles\r\nRCC_DIR += ./generatedFiles\r\ninclude(tst_ComDefinitionReader.pri)\r\n"
  },
  {
    "path": "tests/IPXACTmodels/KactusExtensions/tst_ComDefinitionValidator.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: tst_ComDefinitionValidator.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Janne Virtanen\r\n// Date: 28.01.2016\r\n//\r\n// Description:\r\n// Unit test for class ComDefinitionValidator.\r\n//-----------------------------------------------------------------------------\r\n\r\n\r\n#include <IPXACTmodels/kactusExtensions/ComDefinition.h>\r\n#include <IPXACTmodels/kactusExtensions/validators/ComDefinitionValidator.h>\r\n\r\n#include <QtTest>\r\n\r\nclass tst_ComDefinitionValidator : public QObject\r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n    tst_ComDefinitionValidator();\r\n\r\nprivate slots:\r\n\tvoid baseCase();\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ComDefinitionValidator::tst_ComDefinitionValidator()\r\n//-----------------------------------------------------------------------------\r\ntst_ComDefinitionValidator::tst_ComDefinitionValidator()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ComDefinitionValidator::baseCase()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ComDefinitionValidator::baseCase()\r\n{\r\n\tQSharedPointer<ComDefinition> comDefinition(new ComDefinition(\r\n\t\tVLNV(VLNV::COMDEFINITION, \"me\", \"kurjasto\", \"def\", \"0.11\"), Document::Revision::Std14));\r\n\r\n\tQVector<QString> errorList;\r\n    ComDefinitionValidator validator;\r\n\tvalidator.findErrorsIn(errorList, comDefinition);\r\n\r\n\tQVERIFY(validator.validate(comDefinition));\r\n    QCOMPARE(errorList.size(), 0);\r\n}\r\n\r\nQTEST_APPLESS_MAIN(tst_ComDefinitionValidator)\r\n\r\n#include \"tst_ComDefinitionValidator.moc\"\r\n"
  },
  {
    "path": "tests/IPXACTmodels/KactusExtensions/tst_ComDefinitionValidator.pri",
    "content": "# ----------------------------------------------------\r\n# This file is generated by the Qt Visual Studio Add-in.\r\n# ------------------------------------------------------\r\n\r\nSOURCES += ./tst_ComDefinitionValidator.cpp\r\n"
  },
  {
    "path": "tests/IPXACTmodels/KactusExtensions/tst_ComDefinitionValidator.pro",
    "content": "#-----------------------------------------------------------------------------\r\n# File: tst_ComDefinitionValidator.pro\r\n#-----------------------------------------------------------------------------\r\n# Project: Kactus 2\r\n# Author: Janne Virtanen\r\n# Date: 28.01.2016\r\n#\r\n# Description:\r\n# Qt project file template for running unit tests for ComDefinition Validator.\r\n#-----------------------------------------------------------------------------\r\n\r\nTEMPLATE = app\r\n\r\nTARGET = tst_ComDefinitionValidator\r\n\r\nQT += core xml testlib\r\nQT -= gui\r\n\r\nCONFIG += c++11 testcase console\r\n\r\nlinux-g++ | linux-g++-64 | linux-g++-32 {\r\n LIBS += -L../../../executable \\\r\n     -lIPXACTmodels\r\n\r\n}\r\nwin64 | win32 {\r\n LIBS += -L../../../executable \\\r\n     -lIPXACTmodelsd\r\n}\r\n\r\nDESTDIR = ./release\r\n\r\nINCLUDEPATH += $$DESTDIR\r\nINCLUDEPATH += ../../../\r\n\r\nDEPENDPATH += .\r\nDEPENDPATH += ../../../\r\n\r\nOBJECTS_DIR += $$DESTDIR\r\n\r\nMOC_DIR += ./generatedFiles\r\nUI_DIR += ./generatedFiles\r\nRCC_DIR += ./generatedFiles\r\ninclude(tst_ComDefinitionValidator.pri)\r\n"
  },
  {
    "path": "tests/IPXACTmodels/KactusExtensions/tst_ComDefinitionWriter.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: tst_ComDefinitionWriter.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Janne Virtanen\r\n// Date: 11.12.2015\r\n//\r\n// Description:\r\n// Unit test for class ComDefinitionWriter.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include <IPXACTmodels/kactusExtensions/ComDefinitionWriter.h>\r\n\r\n#include <IPXACTmodels/common/GenericVendorExtension.h>\r\n\r\n#include <QtTest>\r\n\r\nclass tst_ComDefinitionWriter : public QObject\r\n{\r\n    Q_OBJECT\r\n\r\npublic:\r\n\ttst_ComDefinitionWriter();\r\n\r\nprivate slots:\r\n\tvoid init();\r\n\tvoid cleanup();\r\n\r\n    void testProperty();\r\n\tvoid allFields();\r\n\r\nprivate:\r\n\r\n\tQSharedPointer<ComDefinition> testComDefinition_;\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ComDefinitionWriter::tst_ComDefinitionWriter()\r\n//-----------------------------------------------------------------------------\r\ntst_ComDefinitionWriter::tst_ComDefinitionWriter()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ComDefinitionWriter::init()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ComDefinitionWriter::init()\r\n{\r\n\ttestComDefinition_ = QSharedPointer<ComDefinition>(new ComDefinition(VLNV(), Document::Revision::Std14));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ComDefinitionWriter::cleanup()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ComDefinitionWriter::cleanup()\r\n{\r\n\ttestComDefinition_.clear();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ComDefinitionWriter::testProperty()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ComDefinitionWriter::testProperty()\r\n{\r\n    QString output;\r\n    QXmlStreamWriter xmlStreamWriter(&output);\r\n\r\n    testComDefinition_->setVlnv(VLNV(VLNV::APIDEFINITION,\"me\",\"kurjasto\",\"def\",\"0.11\"));\r\n\r\n    auto prop = QSharedPointer<ComProperty>( new ComProperty );\r\n    testComDefinition_->setProperties({ prop });\r\n\r\n    prop->setName(\"max_transfer_size\");\r\n    prop->setRequired( true);\r\n    prop->setType(\"integer\");\r\n    prop->setDefaultValue(\"128\");\r\n    prop->setDescription(\"Maximum size of a single transfer\");\r\n\r\n    QString expectedOutput(\r\n        \"<?xml version=\\\"1.0\\\"?>\"\r\n        \"<kactus2:comDefinition xmlns:xsi=\\\"http://www.w3.org/2001/XMLSchema-instance\\\"\"\r\n        \" xmlns:ipxact=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014\\\"\"\r\n        \" xmlns:kactus2=\\\"http://kactus2.cs.tut.fi\\\"\"\r\n        \" xsi:schemaLocation=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014\"\r\n        \" http://www.accellera.org/XMLSchema/IPXACT/1685-2014/index.xsd\\\">\"\r\n        \"<ipxact:vendor>me</ipxact:vendor>\"\r\n        \"<ipxact:library>kurjasto</ipxact:library>\"\r\n        \"<ipxact:name>def</ipxact:name>\"\r\n        \"<ipxact:version>0.11</ipxact:version>\"\r\n        \"<kactus2:transferTypes/>\"\r\n        \"<kactus2:properties>\"\r\n        \"<kactus2:property name=\\\"max_transfer_size\\\" required=\\\"true\\\" \"\r\n        \"propertyType=\\\"integer\\\" defaultValue=\\\"128\\\" \"\r\n        \"description=\\\"Maximum size of a single transfer\\\"/>\"\r\n        \"</kactus2:properties>\"\r\n        \"</kactus2:comDefinition>\\n\"\r\n        );\r\n\r\n    ComDefinitionWriter::writeComDefinition(xmlStreamWriter, testComDefinition_);\r\n    QCOMPARE(output, expectedOutput);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_ComDefinitionWriter::allFields()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_ComDefinitionWriter::allFields()\r\n{\r\n\tQString output;\r\n\tQXmlStreamWriter xmlStreamWriter(&output);\r\n\r\n\ttestComDefinition_->setVlnv(VLNV(VLNV::APIDEFINITION,\"me\",\"kurjasto\",\"def\",\"0.11\"));\r\n\r\n\tauto prop = QSharedPointer<ComProperty>( new ComProperty );\r\n\ttestComDefinition_->setProperties({prop});\r\n\r\n\tprop->setName(\"max_transfer_size\");\r\n\tprop->setRequired( true);\r\n\tprop->setType(\"integer\");\r\n\tprop->setDefaultValue(\"128\");\r\n    prop->setDescription(\"Maximum size of a single transfer\");\r\n\r\n    QDomDocument document;\r\n    QDomElement extensionNode = document.createElement(\"testExtension\");\r\n    extensionNode.setAttribute(\"vendorAttribute\", \"extension\");\r\n    extensionNode.appendChild(document.createTextNode(\"testValue\"));\r\n\r\n    QSharedPointer<GenericVendorExtension> testExtension(new GenericVendorExtension(extensionNode));\r\n    QSharedPointer<QList<QSharedPointer<VendorExtension> > > vendorExtensions = testComDefinition_->getVendorExtensions();\r\n    vendorExtensions->append(testExtension);\r\n\r\n\tQString expectedOutput(\r\n\t\t\"<?xml version=\\\"1.0\\\"?>\"\r\n\t\t\"<kactus2:comDefinition xmlns:xsi=\\\"http://www.w3.org/2001/XMLSchema-instance\\\"\"\r\n\t\t\" xmlns:ipxact=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014\\\"\"\r\n\t\t\" xmlns:kactus2=\\\"http://kactus2.cs.tut.fi\\\"\"\r\n\t\t\" xsi:schemaLocation=\\\"http://www.accellera.org/XMLSchema/IPXACT/1685-2014\"\r\n\t\t\" http://www.accellera.org/XMLSchema/IPXACT/1685-2014/index.xsd\\\">\"\r\n\t\t\"<ipxact:vendor>me</ipxact:vendor>\"\r\n\t\t\"<ipxact:library>kurjasto</ipxact:library>\"\r\n\t\t\"<ipxact:name>def</ipxact:name>\"\r\n\t\t\"<ipxact:version>0.11</ipxact:version>\"\r\n\t\t\"<kactus2:transferTypes/>\"\r\n\t\t\"<kactus2:properties>\"\r\n\t\t\"<kactus2:property name=\\\"max_transfer_size\\\" required=\\\"true\\\" \"\r\n\t\t\"propertyType=\\\"integer\\\" defaultValue=\\\"128\\\" \"\r\n\t\t\"description=\\\"Maximum size of a single transfer\\\"/>\"\r\n        \"</kactus2:properties>\"\r\n        \"<ipxact:vendorExtensions>\"\r\n        \"<testExtension vendorAttribute=\\\"extension\\\">testValue</testExtension>\"\r\n        \"</ipxact:vendorExtensions>\"\r\n\t\t\"</kactus2:comDefinition>\\n\"\r\n\t\t);\r\n\r\n    ComDefinitionWriter::writeComDefinition(xmlStreamWriter, testComDefinition_);\r\n\tQCOMPARE(output, expectedOutput);\r\n}\r\n\r\nQTEST_APPLESS_MAIN(tst_ComDefinitionWriter)\r\n\r\n#include \"tst_ComDefinitionWriter.moc\"\r\n"
  },
  {
    "path": "tests/IPXACTmodels/KactusExtensions/tst_ComDefinitionWriter.pri",
    "content": "# ----------------------------------------------------\r\n# This file is generated by the Qt Visual Studio Add-in.\r\n# ------------------------------------------------------\r\n\r\nSOURCES += ./tst_ComDefinitionWriter.cpp\r\n"
  },
  {
    "path": "tests/IPXACTmodels/KactusExtensions/tst_ComDefinitionWriter.pro",
    "content": "#-----------------------------------------------------------------------------\r\n# File: tst_ComDefinitionWriter.pro\r\n#-----------------------------------------------------------------------------\r\n# Project: Kactus 2\r\n# Author: Janne Virtanen\r\n# Date: 11.12.2015\r\n#\r\n# Description:\r\n# Qt project file template for running unit tests for ComDefinition writer.\r\n#-----------------------------------------------------------------------------\r\n\r\nTEMPLATE = app\r\n\r\nTARGET = tst_ComDefinitionWriter\r\n\r\nQT += core xml testlib\r\nQT -= gui\r\n\r\nCONFIG += c++11 testcase console\r\n\r\nlinux-g++ | linux-g++-64 | linux-g++-32 {\r\n LIBS += -L../../../executable \\\r\n     -lIPXACTmodels\r\n\r\n}\r\nwin64 | win32 {\r\n LIBS += -L../../../executable \\\r\n     -lIPXACTmodelsd\r\n}\r\n\r\nDESTDIR = ./release\r\n\r\nINCLUDEPATH += $$DESTDIR\r\nINCLUDEPATH += ../../../\r\n\r\nDEPENDPATH += .\r\nDEPENDPATH += ../../../\r\n\r\nOBJECTS_DIR += $$DESTDIR\r\n\r\nMOC_DIR += ./generatedFiles\r\nUI_DIR += ./generatedFiles\r\nRCC_DIR += ./generatedFiles\r\ninclude(tst_ComDefinitionWriter.pri)\r\n"
  },
  {
    "path": "tests/KactusAPI/KactusAPI.pro",
    "content": "#-----------------------------------------------------------------------------\n# File: KactusAPI.pro\n#-----------------------------------------------------------------------------\n# Project: Kactus2\n# Author: Esko Pekkarinen\n# Date: 16.10.2023\n#\n# Description:\n# Qt project file template for running unit tests for Kactus2 API.\n#-----------------------------------------------------------------------------\n\nTEMPLATE = subdirs\n\nCONFIG += testcase\nSUBDIRS += \\\n            tst_ModeConditionParser.pro \n"
  },
  {
    "path": "tests/KactusAPI/tst_ModeConditionParser.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: tst_ModeConditionParser.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Esko Pekkarinen\n// Date: 16.10.2023\n//\n// Description:\n// Unit test for class ModeConditionParser.\n//-----------------------------------------------------------------------------\n\n#include <QtTest>\n#include <QSharedPointer>\n\n#include <KactusAPI/include/ModeConditionParser.h>\n\n#include <KactusAPI/include/ComponentParameterFinder.h>\n#include <KactusAPI/include/ParameterCache.h>\n\n#include <IPXACTmodels/Component/Component.h>\n#include <IPXACTmodels/Component/Mode.h>\n\n#include <IPXACTmodels/common/Parameter.h>\n\n\nclass tst_ModeConditionParser : public QObject\n{\n    Q_OBJECT\n\npublic:\n    tst_ModeConditionParser();\n\nprivate slots:\n\n    void testParsePortCondition();\n    void testParsePortCondition_data();\n\n    void testParseFieldCondition();\n    void testParseFieldCondition_data();\n\n    void testParseModeReference();\n    void testParseModeReference_data();\n\n};\n\n//-----------------------------------------------------------------------------\n// Function: tst_ModeConditionParser::tst_ModeConditionParser()\n//-----------------------------------------------------------------------------\ntst_ModeConditionParser::tst_ModeConditionParser()\n{\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_ModeConditionParser::testParsePortCondition()\n//-----------------------------------------------------------------------------\nvoid tst_ModeConditionParser::testParsePortCondition()\n{\n    QFETCH(QString, expression);\n    QFETCH(bool, expectedValid);\n\n    QSharedPointer<Component> testComponent(new Component(VLNV(), Document::Revision::Std22));\n\n    QSharedPointer<Parameter> testParameter(new Parameter());\n    testParameter->setName(QStringLiteral(\"Limit\"));\n    testParameter->setValueId(QStringLiteral(\"LIMIT\"));\n    testParameter->setValue(QStringLiteral(\"'2'b2\"));\n    testComponent->getParameters()->append(testParameter);\n\n    QSharedPointer<Mode> targetMode(new Mode());\n    targetMode->setName(QStringLiteral(\"reset\"));\n    targetMode->setCondition(QStringLiteral(\"1\"));\n\n    QSharedPointer<PortSlice> targetPort(new PortSlice());\n    targetPort->setName(QStringLiteral(\"external_reset\"));\n    targetPort->setPortRef(QStringLiteral(\"rst_button\"));\n    targetMode->getPortSlices()->append(targetPort);\n\n    testComponent->getModes()->append(targetMode);\n\n    ModeConditionParser parser(QSharedPointer<ParameterFinder>(new ComponentParameterFinder(testComponent)),\n        targetMode->getPortSlices(), targetMode->getFieldSlices(), testComponent->getModes());\n\n    bool valid = false;\n    QString result = parser.parseExpression(expression, &valid);\n\n    QCOMPARE(valid, expectedValid);\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_ModeConditionParser::testParseConstant_data()\n//-----------------------------------------------------------------------------\nvoid tst_ModeConditionParser::testParsePortCondition_data()\n{\n    QTest::addColumn<QString>(\"expression\");\n    QTest::addColumn<bool>(\"expectedValid\");\n\n    QTest::newRow(\"Empty reference is invalid\") << \"$ipxact_port_value()\" << false;\n    QTest::newRow(\"Reference to non-existent port is invalid\") << \"$ipxact_port_value(none)\" << false;\n\n    QTest::newRow(\"Reference to existing port slice is valid\") << \"$ipxact_port_value(external_reset)\" << true;\n    QTest::newRow(\"Reference within expression is valid\") << \"$ipxact_port_value(external_reset) == 1'b1\" << true; \n    QTest::newRow(\"Reference within parametrized expression is valid\") <<\n        \"$ipxact_port_value(external_reset) > LIMIT\" << true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_ModeConditionParser::testParseFieldCondition()\n//-----------------------------------------------------------------------------\nvoid tst_ModeConditionParser::testParseFieldCondition()\n{\n    QFETCH(QString, expression);\n    QFETCH(bool, expectedValid);\n\n    QSharedPointer<Component> testComponent(new Component(VLNV(), Document::Revision::Std22));\n\n    QSharedPointer<Parameter> testParameter(new Parameter());\n    testParameter->setName(QStringLiteral(\"Limit\"));\n    testParameter->setValueId(QStringLiteral(\"LIMIT\"));\n    testParameter->setValue(QStringLiteral(\"'2'b2\"));\n    testComponent->getParameters()->append(testParameter);\n\n    QSharedPointer<Mode> targetMode(new Mode());\n    targetMode->setName(QStringLiteral(\"reset\"));\n    targetMode->setCondition(QStringLiteral(\"1\"));\n\n    QSharedPointer<FieldSlice> targetPort(new FieldSlice());\n    targetPort->setName(QStringLiteral(\"enable_reg\"));\n    targetMode->getFieldSlices()->append(targetPort);\n\n    testComponent->getModes()->append(targetMode);\n\n    ModeConditionParser parser(QSharedPointer<ParameterFinder>(new ComponentParameterFinder(testComponent)),\n        targetMode->getPortSlices(), targetMode->getFieldSlices(), testComponent->getModes());\n\n    bool valid = false;\n    QString result = parser.parseExpression(expression, &valid);\n\n    QCOMPARE(valid, expectedValid);\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_ModeConditionParser::testParseFieldCondition_data()\n//-----------------------------------------------------------------------------\nvoid tst_ModeConditionParser::testParseFieldCondition_data()\n{\n    QTest::addColumn<QString>(\"expression\");\n    QTest::addColumn<bool>(\"expectedValid\");\n\n    QTest::newRow(\"Empty reference is invalid\") << \"$ipxact_field_value()\" << false;\n    QTest::newRow(\"Reference to non-existent field is invalid\") << \"$ipxact_field_value(none)\" << false;\n\n     QTest::newRow(\"Reference to existing port slice is valid\") << \"$ipxact_field_value(enable_reg)\" << true;\n     QTest::newRow(\"Reference within expression is valid\") << \"$ipxact_field_value(enable_reg) == 1'b1\" << true;\n     QTest::newRow(\"Reference within parametrized expression is valid\") <<\n         \"$ipxact_field_value(enable_reg) > LIMIT\" << true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_ModeConditionParser::testParseModeReference()\n//-----------------------------------------------------------------------------\nvoid tst_ModeConditionParser::testParseModeReference()\n{   \n    QFETCH(QString, expression);\n    QFETCH(bool, expectedValid);\n\n    QSharedPointer<Component> testComponent(new Component(VLNV(), Document::Revision::Std22));\n\n    QSharedPointer<Parameter> testParameter(new Parameter());\n    testParameter->setName(QStringLiteral(\"Limit\"));\n    testParameter->setValueId(QStringLiteral(\"LIMIT\"));\n    testParameter->setValue(QStringLiteral(\"12\"));\n    testComponent->getParameters()->append(testParameter);\n\n    QSharedPointer<Mode> targetMode(new Mode());\n    targetMode->setName(QStringLiteral(\"reset\"));\n    targetMode->setCondition(QStringLiteral(\"1\"));\n    testComponent->getModes()->append(targetMode);\n\n    ModeConditionParser parser(QSharedPointer<ParameterFinder>(new ComponentParameterFinder(testComponent)),\n       targetMode->getPortSlices(), targetMode->getFieldSlices(), testComponent->getModes());\n\n    bool valid = false;\n    QString result = parser.parseExpression(expression, &valid);\n\n    QCOMPARE(valid, expectedValid);\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_ModeConditionParser::testParseConstant_data()\n//-----------------------------------------------------------------------------\nvoid tst_ModeConditionParser::testParseModeReference_data()\n{\n    QTest::addColumn<QString>(\"expression\");\n    QTest::addColumn<bool>(\"expectedValid\");\n\n    QTest::newRow(\"Empty reference is invalid\") << \"$ipxact_mode_condition()\" << false;\n    QTest::newRow(\"Reference to non-existent mode is invalid\") << \"$ipxact_mode_condition(none)\" << false;\n\n    QTest::newRow(\"Reference to existing mode is valid\") << \"$ipxact_mode_condition(reset)\" << true;\n    QTest::newRow(\"Reference within expression is valid\") << \"$ipxact_mode_condition(reset) == 1\" << true;\n    QTest::newRow(\"Reference within parametrized expression is valid\") << \n        \"$ipxact_mode_condition(reset) < LIMIT\" << true;\n}\n\nQTEST_MAIN(tst_ModeConditionParser)\n\n#include \"tst_ModeConditionParser.moc\"\n"
  },
  {
    "path": "tests/KactusAPI/tst_ModeConditionParser.pri",
    "content": "# ----------------------------------------------------\n# This file is generated by the Qt Visual Studio Add-in.\n# ------------------------------------------------------\n\nSOURCES += ./tst_ModeConditionParser.cpp\n"
  },
  {
    "path": "tests/KactusAPI/tst_ModeConditionParser.pro",
    "content": "#-----------------------------------------------------------------------------\n# File: tst_ModeConditionParser.pro\n#-----------------------------------------------------------------------------\n# Project: Kactus2\n# Author: Esko Pekkarinen\n# Date: 16.10.2023\n#\n# Description:\n# Qt project file for running unit tests for ModeConditionParser.\n#-----------------------------------------------------------------------------\n\nTEMPLATE = app\n\nTARGET = tst_ModeConditionParser\n\nQT += core xml testlib\nQT -= gui widgets\nCONFIG += c++17 testcase console\n\nwin32:CONFIG(release, debug|release) {\n    LIBS += -L$$PWD/../../executable/ -lIPXACTmodels -lKactusAPI\n    DESTDIR = ./release\n}\nelse:win32:CONFIG(debug, debug|release) {\n    LIBS += -L$$PWD/../../executable/ -lIPXACTmodelsd -lKactusAPId\n    DESTDIR = ./debug\n}\nelse:unix {\n    LIBS += -L$$PWD/../../executable/ -lIPXACTmodels -lKactusAPI\n    DESTDIR = ./release\n}\n\nINCLUDEPATH += $$PWD/../../\nINCLUDEPATH += $$PWD/../../executable\nINCLUDEPATH += $$DESTDIR\n\nDEPENDPATH += $$PWD/../../\nDEPENDPATH += $$PWD/../../executable\nDEPENDPATH += .\n\nOBJECTS_DIR += $$DESTDIR\n\nMOC_DIR += ./generatedFiles\nUI_DIR += ./generatedFiles\nRCC_DIR += ./generatedFiles\ninclude(tst_ModeConditionParser.pri)\n"
  },
  {
    "path": "tests/MockObjects/DesignWidgetFactoryMock.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: DesignWidgetFactoryMock.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 11.02.2015\r\n//\r\n// Description:\r\n// Mock class for design widget factory.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"DesignWidgetFactoryMock.h\"\r\n#include \"HWDesignWidgetMock.h\"\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignWidgetFactoryMock::DesignWidgetFactoryMock()\r\n//-----------------------------------------------------------------------------\r\nDesignWidgetFactoryMock::DesignWidgetFactoryMock(LibraryInterface* libInterface):\r\nlibInterface_(libInterface)\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignWidgetFactoryMock::DesignWidgetFactoryMock()\r\n//-----------------------------------------------------------------------------\r\nDesignWidgetFactoryMock::~DesignWidgetFactoryMock()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: DesignWidgetFactoryMock::makeHWDesignWidget()\r\n//-----------------------------------------------------------------------------\r\nDesignWidget* DesignWidgetFactoryMock::makeHWDesignWidget(QWidget* parent )\r\n{\r\n    DesignWidget* hwMockDesign (new HWDesignWidgetMock(libInterface_, parent));\r\n\r\n    return hwMockDesign;\r\n}\r\n"
  },
  {
    "path": "tests/MockObjects/DesignWidgetFactoryMock.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: DesignWidgetFactoryMock.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 11.02.2015\r\n//\r\n// Description:\r\n// Mock class for design widget factory.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef DESIGNWIDGETFACTORYMOCK_H\r\n#define DESIGNWIDGETFACTORYMOCK_H\r\n\r\n#include <editors/common/DesignWidgetFactory.h>\r\n#include <editors/common/DesignWidget.h>\r\n\r\n#include <KactusAPI/include/LibraryInterface.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Mock class for constructing design widgets.\r\n//-----------------------------------------------------------------------------\r\nclass DesignWidgetFactoryMock : public DesignWidgetFactory\r\n{\r\n\r\npublic:\r\n    /*!\r\n     *  Constructor.\r\n     */\r\n    DesignWidgetFactoryMock(LibraryInterface* libInterface);\r\n\r\n    /*!\r\n     *  Destructor.\r\n     */\r\n    ~DesignWidgetFactoryMock();\r\n\r\n    /*!\r\n     *  Make the hardware design widget.\r\n     */\r\n    virtual DesignWidget* makeHWDesignWidget(QWidget* parent /* = 0 */);\r\n\r\nprivate:\r\n    // Disable copying.\r\n    DesignWidgetFactoryMock(DesignWidgetFactoryMock const& rhs);\r\n    DesignWidgetFactoryMock& operator=(DesignWidgetFactoryMock const& rhs);\r\n\r\n    LibraryInterface* libInterface_;\r\n};\r\n\r\n#endif // DESIGNWIDGETFACTORYIMPLEMENTATION_H\r\n"
  },
  {
    "path": "tests/MockObjects/HWDesignWidgetMock.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: HWDesignWidgetMock.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 11.02.2015\r\n//\r\n// Description:\r\n// Mock class for hardware design widget.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"HWDesignWidgetMock.h\"\r\n\r\n#include <editors/HWDesign/HWDesignDiagram.h>\r\n#include <editors/common/StickyNote/StickyNote.h>\r\n\r\n#include <common/GenericEditProvider.h>\r\n\r\n#include <KactusAPI/include/LibraryInterface.h>\r\n\r\n#include <IPXACTmodels/Component/Component.h>\r\n#include <IPXACTmodels/Component/Model.h>\r\n#include <IPXACTmodels/Component/View.h>\r\n\r\n#include <IPXACTmodels/Design/Design.h>\r\n\r\n#include <IPXACTmodels/DesignConfiguration/DesignConfiguration.h>\r\n\r\n#include <QFileInfo>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HWDesignWidgetMock::HWDesignWidgetMock()\r\n//-----------------------------------------------------------------------------\r\nHWDesignWidgetMock::HWDesignWidgetMock(LibraryInterface *lh, QWidget* parent): DesignWidget(lh, parent)\r\n{\r\n\t// update the supported windows \r\n\tsupportedWindows_ = (supportedWindows_ | CONFIGURATIONWINDOW |\r\n\t\tCONNECTIONWINDOW | INTERFACEWINDOW |INSTANCEWINDOW | ADHOC_WINDOW);\r\n\r\n    setDiagram(new HWDesignDiagram(lh, getEditProvider(), QSharedPointer<MultipleParameterFinder>(), \r\n        QSharedPointer<ListParameterFinder>(), this));\r\n    getDiagram()->setProtection(false);\r\n    getDiagram()->setMode(MODE_SELECT);\r\n    \r\n\taddVisibilityControl(\"Bus Widths\", false);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HWDesignWidgetMock::~HWDesignWidgetMock()\r\n//-----------------------------------------------------------------------------\r\nHWDesignWidgetMock::~HWDesignWidgetMock()\r\n{\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HWDesignWidgetMock::setDesign()\r\n//-----------------------------------------------------------------------------\r\nbool HWDesignWidgetMock::setDesign(VLNV const& vlnv, QString const& viewName)\r\n{\t\r\n\tdisconnect(getDiagram(), SIGNAL(contentChanged()),\r\n\t\tthis, SIGNAL(contentChanged()));\r\n\r\n\t// if vlnv and view name was defined which means that an existing component is opened\r\n\tif (vlnv.isValid() && !viewName.isEmpty()) {\r\n\r\n\t\t// if vlnv is writeSucceeded and the type is component\r\n\t\tif (vlnv.isValid() && vlnv.getType() == VLNV::COMPONENT) {\r\n\r\n\t\t\t// create model \r\n            QSharedPointer<Component> comp = getLibHandler()->getModel(vlnv).staticCast<Component>();\r\n\r\n\t\t\tif (comp == 0)\r\n            {\r\n\t\t\t\treturn false;\r\n            }\r\n\r\n\t\t\tif (!setDesign(comp, viewName))\r\n            {\r\n                return false;\r\n            }\r\n\t\t}\r\n\t}\r\n\r\n\t// if vlnv was writeSucceeded but view is empty then should create a new design for the component\r\n\telse if (vlnv.isValid() && viewName.isEmpty()) {\r\n\t\tQ_ASSERT(getLibHandler()->contains(vlnv));\r\n\t\tQ_ASSERT(getLibHandler()->getDocumentType(vlnv) == VLNV::COMPONENT);\r\n\r\n\t\tQSharedPointer<Component> comp = getLibHandler()->getModel(vlnv).staticCast<Component>();\r\n\r\n\t\t// get the directory path where the component's xml file is located\r\n\t\tconst QString xmlPath = getLibHandler()->getPath(vlnv);\r\n\t\tQFileInfo xmlInfo(xmlPath);\r\n\t\tconst QString dirPath = xmlInfo.absolutePath();\r\n\r\n\t\tcreateDesignForComponent(comp, dirPath);\r\n\t}\r\n\r\n\t// if vlnv was not defined (a new hierarchical component is created)\r\n\telse {\r\n\t\tif (!createEmptyDesign(vlnv))\r\n        {\r\n            return false;\r\n        }\r\n\t}\r\n\r\n\t// disable the save at startup\r\n\tconnect(getDiagram(), SIGNAL(contentChanged()),\r\n\t\t    this, SIGNAL(contentChanged()), Qt::UniqueConnection);\r\n\tconnect(getDiagram(), SIGNAL(modeChanged(DrawMode)),\r\n\t\t    this, SIGNAL(modeChanged(DrawMode)), Qt::UniqueConnection);\r\n\tsetModified(false);\r\n\t\r\n\tsetDocumentType(TabDocument::DocumentType::HW_DESIGN);\r\n\tsetDocumentName(QString(\"%1 (%2)\").arg(getIdentifyingVLNV().getName()).arg(getIdentifyingVLNV().getVersion()));\r\n\r\n\temit clearItemSelection();\r\n\r\n    return true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HWDesignWidgetMock::setDesign()\r\n//-----------------------------------------------------------------------------\r\nbool HWDesignWidgetMock::setDesign(QSharedPointer<Component> comp, const QString& viewName)\r\n{\r\n    QSharedPointer<View> targetView;    \r\n    foreach (QSharedPointer<View> view, *comp->getViews())\r\n    {\r\n        if (view->name() == viewName)\r\n        {\r\n            targetView = view;\r\n        }\r\n    }\r\n\r\n\r\n    if (!targetView || !targetView->isHierarchical())\r\n    {\r\n        return false;\r\n    }\r\n\r\n    VLNV designVLNV = comp->getHierRef(viewName);\r\n\r\n    // Check for a valid VLNV type.\r\n    designVLNV.setType(getLibHandler()->getDocumentType(designVLNV));\r\n\r\n    if (!designVLNV.isValid())\r\n    {\r\n        emit errorMessage(tr(\"Component %1 did not contain a hierarchical view\").arg(comp->getVlnv().getName()));\r\n        return false;\r\n    }\r\n\r\n    QSharedPointer<Design> design;\r\n    QSharedPointer<DesignConfiguration> designConf;\r\n\r\n    // if the component contains a direct reference to a design\r\n    if (designVLNV.getType() == VLNV::DESIGN)\r\n    {\r\n        design = getLibHandler()->getModel(designVLNV).staticCast<Design>();\r\n    }\r\n    // if component had reference to a design configuration\r\n    else if (designVLNV.getType() == VLNV::DESIGNCONFIGURATION)\r\n    {\r\n        designConf = getLibHandler()->getModel(designVLNV).staticCast<DesignConfiguration>();\r\n\r\n        designVLNV = designConf->getDesignRef();\r\n\r\n        if (designVLNV.isValid())\r\n        {\r\n            design = getLibHandler()->getModel(designVLNV).staticCast<Design>();\r\n        }\r\n\r\n        // if design configuration did not contain a reference to a design.\r\n        if (!design)\r\n        {\r\n            emit errorMessage(tr(\"Component %1 did not contain a hierarchical view\").arg(\r\n                comp->getVlnv().getName()));\r\n            return false;;\r\n        }\r\n    }\r\n\r\n    if (!getDiagram()->setDesign(comp, targetView->name(), design, designConf))\r\n    {\r\n        return false;\r\n    }\r\n\r\n    DesignWidget::setDesign(comp, viewName);\r\n\tsetDocumentName(QString(\"%1 (%2)\").arg(getIdentifyingVLNV().getName()).arg(getIdentifyingVLNV().getVersion()));\r\n\r\n    return true;\r\n}\r\n\r\nbool HWDesignWidgetMock::saveAs()\r\n{\r\n    return false;\r\n}\r\n\r\nvoid HWDesignWidgetMock::keyPressEvent(QKeyEvent *event)\r\n{\r\n\r\n}\r\n\r\nQSharedPointer<Component> HWDesignWidgetMock::createEmptyDesign(VLNV const& prevlnv) {\r\n    \r\n\tVLNV vlnv;\r\n\tQString path;\r\n\r\n\tif (prevlnv.isValid() && getLibHandler()->contains(prevlnv)) {\r\n\t\tvlnv = prevlnv;\r\n\t\tpath = getLibHandler()->getPath(prevlnv);\r\n\t\tQFileInfo info(path);\r\n\t\tpath = info.absolutePath();\r\n\t}\r\n\telse {\r\n        Q_ASSERT(false);\r\n\t}\r\n\r\n\tQSharedPointer<Component> newComponent;\r\n\t\r\n\tif (getLibHandler()->contains(prevlnv))\r\n    {\r\n\t\t// find the component\r\n\t\tnewComponent = getLibHandler()->getModel(prevlnv).staticCast<Component>();\r\n\r\n\t\tQ_ASSERT_X(newComponent, \"HWDesignWidgetMock::createEmptyDesign\",\r\n\t\t\t\"The selected library item has to be component\");\r\n\t}\r\n\telse {\r\n\t\t// create the component \r\n\t\tnewComponent = QSharedPointer<Component>(new Component(vlnv, Document::Revision::Std14));\r\n\t}\r\n\r\n    getLibHandler()->writeModelToFile(path, newComponent);\r\n\r\n\tcreateDesignForComponent(newComponent, path);\r\n\r\n    return newComponent;\r\n}\r\n\r\nvoid HWDesignWidgetMock::createDesignForComponent(QSharedPointer<Component> component, const QString& dirPath)\r\n{\r\n\tVLNV vlnv = component->getVlnv();\r\n\r\n\t// create a unique vlnv for the design\r\n\tVLNV designVLNV(VLNV::DESIGN, vlnv.getVendor(), vlnv.getLibrary(),\r\n\t\tvlnv.getName().remove(\".comp\") + \".design\", vlnv.getVersion());\r\n\tint runningNumber = 1;\r\n\tQString version = designVLNV.getVersion();\r\n\t// if vlnv is reserved then add \"(<number>)\" to end of version field\r\n\twhile (getLibHandler()->contains(designVLNV)) {\r\n\t\t++runningNumber;\r\n\t\tdesignVLNV.setVersion(version + \"(\" + QString::number(runningNumber) + \")\");\r\n\t}\r\n\r\n\t// create a unique vlnv for the design configuration\r\n\tVLNV desConfVLNV(VLNV::DESIGNCONFIGURATION, vlnv.getVendor(), vlnv.getLibrary(),\r\n\t\tvlnv.getName().remove(\".comp\") + \".designcfg\", vlnv.getVersion());\r\n\trunningNumber = 1;\r\n\tversion = desConfVLNV.getVersion();\r\n\t// if vlnv is reserved then add \"(<number>)\" to end of version field\r\n\twhile (getLibHandler()->contains(desConfVLNV)) {\r\n\t\t++runningNumber;\r\n\t\tdesConfVLNV.setVersion(version + \"(\" + QString::number(runningNumber) + \")\");\r\n\t}\r\n\r\n\t// the name of the view to create\r\n\tQString viewName = tr(\"structural\");\r\n\r\n\t// and a hierarchical view for it\r\n\tQSharedPointer<View> hierView(new View(viewName));\r\n    hierView->setDesignConfigurationInstantiationRef(\"config\");\r\n\t//hierView->addEnvIdentifier(\"\");\r\n\tcomponent->getViews()->append(hierView);\r\n\r\n    QSharedPointer<DesignConfigurationInstantiation> configurationInstantiation(new \r\n        DesignConfigurationInstantiation(\"config\"));\r\n    configurationInstantiation->setDesignConfigurationReference(\r\n        QSharedPointer<ConfigurableVLNVReference>(new ConfigurableVLNVReference(desConfVLNV)));\r\n\r\n\t// create the design configuration\r\n\tQSharedPointer<DesignConfiguration> designConf(new DesignConfiguration(desConfVLNV, Document::Revision::Std14));\r\n\tdesignConf->setDesignRef(designVLNV);\r\n\r\n\tQSharedPointer<Design> newDesign = QSharedPointer<Design>(new Design(designVLNV, Document::Revision::Std14));\r\n\r\n\tgetLibHandler()->writeModelToFile(dirPath, newDesign);\r\n\tgetLibHandler()->writeModelToFile(dirPath, designConf);\r\n    getLibHandler()->writeModelToFile(component);\r\n\r\n\tsetDesign(component, viewName);\r\n}\r\n\r\nvoid HWDesignWidgetMock::onVhdlGenerate()\r\n{\r\n\r\n}\r\n\r\nvoid HWDesignWidgetMock::onQuartusGenerate()\r\n{\r\n\r\n}\r\n\r\nvoid HWDesignWidgetMock::onModelsimGenerate()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HWDesignWidgetMock::onDeleteSelectedItems()\r\n//-----------------------------------------------------------------------------\r\nvoid HWDesignWidgetMock::onDeleteSelectedItems()\r\n{\r\n    \r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: addColumn()\r\n//-----------------------------------------------------------------------------\r\nvoid HWDesignWidgetMock::addColumn()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: getSupportedDrawModes()\r\n//-----------------------------------------------------------------------------\r\nunsigned int HWDesignWidgetMock::getSupportedDrawModes() const\r\n{\r\n    if (isProtected())\r\n    {\r\n        // Force to selection mode in read-only mode.\r\n        return MODE_SELECT;        \r\n    }\r\n    else\r\n    {\r\n        return (MODE_SELECT | MODE_CONNECT | MODE_INTERFACE | MODE_DRAFT | MODE_TOGGLE_OFFPAGE | MODE_LABEL);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: HWDesignWidgetMock::getImplementation()\r\n//-----------------------------------------------------------------------------\r\nKactusAttribute::Implementation HWDesignWidgetMock::getImplementation() const\r\n{\r\n    return KactusAttribute::HW;\r\n}\r\n"
  },
  {
    "path": "tests/MockObjects/HWDesignWidgetMock.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: HWDesignWidgetMock.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 11.02.2015\r\n//\r\n// Description:\r\n// Mock class for hardware design widget.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef HWDESIGNWIDGETMOCK_H\r\n#define HWDESIGNWIDGETMOCK_H\r\n\r\n#include <IPXACTmodels/common/VLNV.h>\r\n\r\n#include <editors/HWDesign/HWDesignDiagram.h>\r\n#include <editors/common/DesignWidget.h>\r\n\r\n#include <QString>\r\n#include <QKeyEvent>\r\n#include <QSharedPointer>\r\n\r\nclass LibraryInterface;\r\nclass VLNV;\r\nclass Component;\r\nclass HWComponentItem;\r\nclass BusPortItem;\r\nclass DesignConfiguration;\r\n\r\n/*! \\brief HWDesignWidgetMock is used to edit and view one design\r\n *\r\n */\r\nclass HWDesignWidgetMock : public DesignWidget\r\n{\r\n    Q_OBJECT\r\n\r\npublic:\r\n\r\n    HWDesignWidgetMock(LibraryInterface *lh, QWidget *parent = 0);\r\n\r\n\t//! \\brief The destructor\r\n\tvirtual ~HWDesignWidgetMock();\r\n\r\n\t/*! \\brief Set the design to be displayed in the block diagram\r\n\t *\r\n\t * \\param vlnv VLNV of the design to open\r\n\t * \\param viewName Name of the view to open within component.\r\n\t *\r\n\t*/\r\n\tvirtual bool setDesign(VLNV const& vlnv, QString const& viewName);\r\n    \r\n    /*!\r\n     *  Called when a new column is requested to be added to the design.\r\n     */\r\n    virtual void addColumn();\r\n\r\n    /*!\r\n     *  Returns the supported draw modes.\r\n     */\r\n    virtual unsigned int getSupportedDrawModes() const;\r\n\r\n    /*!\r\n     *  Returns the implementation attribute.\r\n     */\r\n    virtual KactusAttribute::Implementation getImplementation() const;\r\n\r\nsignals:\r\n    /*! \\brief Emitted when user wants to refresh this widget\r\n\t *\r\n\t * \\param designWidget Pointer to this HWDesignWidgetMock instance\r\n\t *\r\n\t*/\r\n\tvoid refresh(const HWDesignWidgetMock* designWidget);\r\n\r\npublic slots:\r\n    //! \\brief Saves the design as new object\r\n\tvirtual bool saveAs();\r\n\r\n\t//! \\brief Called when user clicks the generate top-vhdl icon\r\n\tvoid onVhdlGenerate();\r\n\r\n\t//! \\brief Called when user clicks the generate quartus project icon\r\n\tvoid onQuartusGenerate();\r\n\r\n\t//! \\brief Called when user clicks the generate modelsim icon\r\n\tvoid onModelsimGenerate();\r\n\r\n    virtual void onDeleteSelectedItems();\r\n\r\nprotected:\r\n    void keyPressEvent(QKeyEvent *event);\r\n\r\nprivate:\r\n    HWDesignWidgetMock(const HWDesignWidgetMock &);\r\n    HWDesignWidgetMock &operator=(const HWDesignWidgetMock &);\r\n\r\n    /*! \\brief Create an empty hierarchical component\r\n     *\r\n     * \\return Pointer to the created component.\r\n    */\r\n    QSharedPointer<Component> createEmptyDesign(VLNV const& prevlnv);\r\n\r\n    bool setDesign(QSharedPointer<Component> comp, const QString& viewName);\r\n\r\n\t/*! \\brief Create an empty design and configuration for a component.\r\n\t *\r\n\t * \\param component Pointer to the component to create the design for.\r\n\t * \\param dirPath File path to the directory to create the design and\r\n\t * configuration to.\r\n\t *\r\n\t*/\r\n\tvoid createDesignForComponent(QSharedPointer<Component> component, const QString& dirPath);\r\n\r\n};\r\n\r\n#endif // HWDESIGNWIDGETMOCK_H\r\n"
  },
  {
    "path": "tests/MockObjects/LibraryMock.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: LibraryMock.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Esko Pekkarinen\r\n// Date: 06.08.2014\r\n//\r\n// Description:\r\n// Mock of the IP-XACT library to use in unit tests.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"LibraryMock.h\"\r\n\r\n#include <IPXACTmodels/common/Document.h>\r\n#include <IPXACTmodels/common/VLNV.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LibraryMock::LibraryMock()\r\n//-----------------------------------------------------------------------------\r\nLibraryMock::LibraryMock(QObject* parent):\r\n    QObject(parent),\r\n        components_(),\r\n        paths_()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LibraryMock::()\r\n//-----------------------------------------------------------------------------\r\nLibraryMock::~LibraryMock()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LibraryMock::addComponent()\r\n//-----------------------------------------------------------------------------\r\nvoid LibraryMock::addComponent(QSharedPointer<Document> component)\r\n{\r\n    components_.insert(component->getVlnv(), component);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LibraryMock::clear()\r\n//-----------------------------------------------------------------------------\r\nvoid LibraryMock::clear()\r\n{\r\n    components_.clear();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LibraryMock::getModel()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<Document> LibraryMock::getModel(const VLNV& vlnv)\r\n{\r\n    return components_.value(vlnv, QSharedPointer<Document>(0));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LibraryMock::getModelReadOnly()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<Document const> LibraryMock::getModelReadOnly(const VLNV& vlnv)\r\n{\r\n    return components_.value(vlnv, QSharedPointer<Document>(0));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LibraryMock::contains()\r\n//-----------------------------------------------------------------------------\r\nbool LibraryMock::contains(const VLNV& vlnv) const\r\n{\r\n    return components_.contains(vlnv);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LibraryMock::getPath()\r\n//-----------------------------------------------------------------------------\r\nconst QString LibraryMock::getPath(const VLNV& vlnv) const\r\n{\r\n    return paths_.value(vlnv);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LibraryMock::getDirectoryPath()\r\n//-----------------------------------------------------------------------------\r\nQString LibraryMock::getDirectoryPath(const VLNV& /*vlnv*/) const\r\n{\r\n    return QString();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LibraryMock::writeModelToFile()\r\n//-----------------------------------------------------------------------------\r\nbool LibraryMock::writeModelToFile(const QString& path, QSharedPointer<Document> model)\r\n{\r\n    paths_.insert(model->getVlnv(), path);\r\n    return true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LibraryMock::writeModelToFile()\r\n//-----------------------------------------------------------------------------\r\nbool LibraryMock::writeModelToFile(QSharedPointer<Document> /*model*/)\r\n{\r\n    return false;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LibraryMock::searchForIPXactFiles()\r\n//-----------------------------------------------------------------------------\r\nvoid LibraryMock::searchForIPXactFiles()\r\n{\r\n    \r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LibraryMock::getNeededVLNVs()\r\n//-----------------------------------------------------------------------------\r\nvoid LibraryMock::getNeededVLNVs(const VLNV& /*vlnv*/, QList<VLNV>& /*list*/)\r\n{\r\n    \r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LibraryMock::getDependencyFiles()\r\n//-----------------------------------------------------------------------------\r\nvoid LibraryMock::getDependencyFiles(const VLNV& /*vlnv*/, QStringList& /*list*/)\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LibraryMock::getHierarchicalDependencyFiles()\r\n//-----------------------------------------------------------------------------\r\nvoid LibraryMock::getHierarchicalDependencyFiles(const VLNV& /*vlnv*/, QStringList& /*list*/)\r\n{\r\n    \r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LibraryMock::getTreeRoot()\r\n//-----------------------------------------------------------------------------\r\nLibraryItem const* LibraryMock::getTreeRoot() const\r\n{\r\n    return 0;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LibraryMock::getDocumentType()\r\n//-----------------------------------------------------------------------------\r\nVLNV::IPXactType LibraryMock::getDocumentType(const VLNV& vlnv)\r\n{\r\n    if ( components_.keys().contains(vlnv) )\r\n    {\r\n        return vlnv.getType();\r\n    }\r\n    else\r\n    {\r\n        return VLNV::INVALID;\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LibraryMock::referenceCount()\r\n//-----------------------------------------------------------------------------\r\nint LibraryMock::referenceCount(const VLNV& /*vlnv*/) const\r\n{\r\n    return 0;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LibraryMock::getOwners()\r\n//-----------------------------------------------------------------------------\r\nint LibraryMock::getOwners(QList<VLNV>& /*list*/, const VLNV& /*vlnvToSearch*/) const\r\n{\r\n    return 0;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LibraryMock::getChildren()\r\n//-----------------------------------------------------------------------------\r\nint LibraryMock::getChildren(QList<VLNV>& /*list*/, const VLNV& /*vlnvToSearch*/) const\r\n{\r\n    return 0;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LibraryMock::getDesignVLNV()\r\n//-----------------------------------------------------------------------------\r\nVLNV LibraryMock::getDesignVLNV(const VLNV& /*hierarchyRef*/)\r\n{\r\n    return VLNV();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LibraryMock::getDesign()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<Design> LibraryMock::getDesign(const VLNV& hierarchyRef)\r\n{\r\n    return components_.value(hierarchyRef, QSharedPointer<Document>(0)).dynamicCast<Design>();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LibraryMock::isValid()\r\n//-----------------------------------------------------------------------------\r\nbool LibraryMock::isValid(const VLNV& /*vlnv*/)\r\n{\r\n    return false;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LibraryMock::getAllVLNVs()\r\n//-----------------------------------------------------------------------------\r\nQList<VLNV> LibraryMock::getAllVLNVs() const\r\n{\r\n    return components_.keys();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LibraryMock::onCheckLibraryIntegrity()\r\n//-----------------------------------------------------------------------------\r\nvoid LibraryMock::onCheckLibraryIntegrity()\r\n{\r\n    Q_ASSERT(false);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LibraryMock::onSelectionChanged()\r\n//-----------------------------------------------------------------------------\r\nvoid LibraryMock::onSelectionChanged(const VLNV& /*vlnv*/)\r\n{\r\n    Q_ASSERT(false);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LibraryMock::onClearSelection()\r\n//-----------------------------------------------------------------------------\r\nvoid LibraryMock::onClearSelection()\r\n{\r\n    Q_ASSERT(false);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LibraryMock::onEditItem()\r\n//-----------------------------------------------------------------------------\r\nvoid LibraryMock::onEditItem(const VLNV& /*vlnv*/)\r\n{\r\n    Q_ASSERT(false);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LibraryMock::onOpenDesign()\r\n//-----------------------------------------------------------------------------\r\nvoid LibraryMock::onOpenDesign(const VLNV& /*vlnv*/,  QString const& /*viewName*/)\r\n{\r\n    Q_ASSERT(false);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LibraryMock::onCreateNewItem()\r\n//-----------------------------------------------------------------------------\r\nvoid LibraryMock::onCreateNewItem(const VLNV& /*vlnv*/)\r\n{\r\n    Q_ASSERT(false);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LibraryMock::onCreateDesign()\r\n//-----------------------------------------------------------------------------\r\nvoid LibraryMock::onCreateDesign(const VLNV& /*vlnv*/)\r\n{\r\n    Q_ASSERT(false);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LibraryMock::removeObject()\r\n//-----------------------------------------------------------------------------\r\nvoid LibraryMock::removeObject(const VLNV& /*vlnv*/)\r\n{\r\n    Q_ASSERT(false);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LibraryMock::removeObjects()\r\n//-----------------------------------------------------------------------------\r\nvoid LibraryMock::removeObjects(const QList<VLNV>& /*vlnvList*/)\r\n{\r\n    Q_ASSERT(false);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LibraryMock::beginSave()\r\n//-----------------------------------------------------------------------------\r\nvoid LibraryMock::beginSave()\r\n{\r\n    Q_ASSERT(false);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: LibraryMock::endSave()\r\n//-----------------------------------------------------------------------------\r\nvoid LibraryMock::endSave()\r\n{\r\n   Q_ASSERT(false);\r\n}\r\n"
  },
  {
    "path": "tests/MockObjects/LibraryMock.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: LibraryMock.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Esko Pekkarinen\r\n// Date: 06.08.2014\r\n//\r\n// Description:\r\n// Mock of the IP-XACT library to use in unit tests.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef LIBRARYMOCK_H\r\n#define LIBRARYMOCK_H\r\n\r\n#include <KactusAPI/include/LibraryInterface.h>\r\n\r\n#include <IPXACTmodels/Design/Design.h>\r\n\r\nclass LibraryMock : public QObject, public LibraryInterface\r\n{\r\n    Q_OBJECT\r\npublic:\r\n\r\n\t//! The constructor.\r\n\tLibraryMock(QObject* parent);\r\n\r\n\t//! The destructor.\r\n\tvirtual ~LibraryMock();\r\n\r\n    /*!\r\n     *  Method description.\r\n     *\r\n     *    @param [in]    Description.\r\n     *\r\n     *    @return Description.\r\n     */\r\n    void addComponent(QSharedPointer<Document> component);\r\n\r\n    /*!\r\n     *  Method description.\r\n     *\r\n     *    @param [in]    Description.\r\n     *\r\n     *    @return Description.\r\n     */\r\n    void clear();\r\n\r\n    /*!\r\n    *  Method description.\r\n    *\r\n    *    @param [in]    Description.\r\n    *\r\n    *    @return Description.\r\n    */\r\n    virtual QSharedPointer<Document> getModel(const VLNV& vlnv);\r\n\r\n    /*!\r\n    *  Method description.\r\n    *\r\n    *    @param [in]    Description.\r\n    *\r\n    *    @return Description.\r\n    */\r\n    virtual QSharedPointer<Document const> getModelReadOnly(const VLNV& vlnv);\r\n\r\n    /*!\r\n    *  Method description.\r\n    *\r\n    *    @param [in]    Description.\r\n    *\r\n    *    @return Description.\r\n    */\r\n    virtual bool contains(const VLNV& vlnv) const;\r\n\r\n    /*!\r\n    *  Method description.\r\n    *\r\n    *    @param [in]    Description.\r\n    *\r\n    *    @return Description.\r\n    */\r\n    virtual const QString getPath(const VLNV& vlnv) const;\r\n\r\n    /*!\r\n    *  Method description.\r\n    *\r\n    *    @param [in]    Description.\r\n    *\r\n    *    @return Description.\r\n    */\r\n    virtual QString getDirectoryPath(const VLNV& vlnv) const;\r\n\r\n    /*!\r\n    *  Method description.\r\n    *\r\n    *    @param [in]    Description.\r\n    *\r\n    *    @return Description.\r\n    */\r\n    virtual bool writeModelToFile(const QString& path, QSharedPointer<Document> model);\r\n\r\n    /*!\r\n    *  Method description.\r\n    *\r\n    *    @param [in]    Description.\r\n    *\r\n    *    @return Description.\r\n    */\r\n    virtual bool writeModelToFile(QSharedPointer<Document> model);\r\n\r\n    /*!\r\n    *  Method description.\r\n    *\r\n    *    @param [in]    Description.\r\n    *\r\n    *    @return Description.\r\n    */\r\n    virtual void searchForIPXactFiles();\r\n\r\n    /*!\r\n    *  Method description.\r\n    *\r\n    *    @param [in]    Description.\r\n    *\r\n    *    @return Description.\r\n    */\r\n    virtual void getNeededVLNVs(const VLNV& vlnv, QList<VLNV>& list);\r\n\r\n    /*!\r\n    *  Method description.\r\n    *\r\n    *    @param [in]    Description.\r\n    *\r\n    *    @return Description.\r\n    */\r\n    virtual void getDependencyFiles(const VLNV& vlnv, QStringList& list);\r\n\r\n    /*!\r\n    *  Method description.\r\n    *\r\n    *    @param [in]    Description.\r\n    *\r\n    *    @return Description.\r\n    */\r\n    virtual void getHierarchicalDependencyFiles(const VLNV& vlnv, QStringList& list);\r\n\r\n    /*!\r\n    *  Method description.\r\n    *\r\n    *    @param [in]    Description.\r\n    *\r\n    *    @return Description.\r\n    */\r\n    virtual LibraryItem const* getTreeRoot() const;\r\n\r\n    /*!\r\n    *  Method description.\r\n    *\r\n    *    @param [in]    Description.\r\n    *\r\n    *    @return Description.\r\n    */\r\n    virtual VLNV::IPXactType getDocumentType(const VLNV& vlnv);\r\n\r\n    /*!\r\n    *  Method description.\r\n    *\r\n    *    @param [in]    Description.\r\n    *\r\n    *    @return Description.\r\n    */\r\n    virtual int referenceCount(const VLNV& vlnv) const;\r\n\r\n    /*!\r\n    *  Method description.\r\n    *\r\n    *    @param [in]    Description.\r\n    *\r\n    *    @return Description.\r\n    */\r\n    virtual int getOwners(QList<VLNV>& list, const VLNV& vlnvToSearch) const;\r\n\r\n    /*!\r\n    *  Method description.\r\n    *\r\n    *    @param [in]    Description.\r\n    *\r\n    *    @return Description.\r\n    */\r\n    virtual int getChildren(QList<VLNV>& list, const VLNV& vlnvToSearch) const;\r\n\r\n    /*!\r\n    *  Method description.\r\n    *\r\n    *    @param [in]    Description.\r\n    *\r\n    *    @return Description.\r\n    */\r\n    virtual VLNV getDesignVLNV(const VLNV& hierarchyRef);\r\n\r\n    /*!\r\n    *  Method description.\r\n    *\r\n    *    @param [in]    Description.\r\n    *\r\n    *    @return Description.\r\n    */\r\n    virtual QSharedPointer<Design> getDesign(const VLNV& hierarchyRef);\r\n\r\n    /*!\r\n    *  Method description.\r\n    *\r\n    *    @param [in]    Description.\r\n    *\r\n    *    @return Description.\r\n    */\r\n    virtual bool isValid(const VLNV& vlnv);\r\n   \r\n    /*!\r\n     *  Gets all the VLVNs currently in the library.\r\n     *\r\n     *    @return All current VLNVs.\r\n     */\r\n    virtual QList<VLNV> getAllVLNVs() const;\r\n\r\npublic slots:\r\n\r\n    /*!\r\n    *  Method description.\r\n    *\r\n    *    @param [in]    Description.\r\n    *\r\n    *    @return Description.\r\n    */\r\n    virtual void onCheckLibraryIntegrity();\r\n\r\n    /*!\r\n    *  Method description.\r\n    *\r\n    *    @param [in]    Description.\r\n    *\r\n    *    @return Description.\r\n    */\r\n    virtual void onSelectionChanged(const VLNV& vlnv);\r\n\r\n    /*!\r\n    *  Method description.\r\n    *\r\n    *    @param [in]    Description.\r\n    *\r\n    *    @return Description.\r\n    */\r\n    virtual void onClearSelection();\r\n\r\n    /*!\r\n    *  Method description.\r\n    *\r\n    *    @param [in]    Description.\r\n    *\r\n    *    @return Description.\r\n    */\r\n    virtual void onEditItem(const VLNV& vlnv);\r\n\r\n    /*!\r\n    *  Method description.\r\n    *\r\n    *    @param [in]    Description.\r\n    *\r\n    *    @return Description.\r\n    */\r\n    virtual void onOpenDesign(const VLNV& vlnv, QString const& viewName);\r\n\r\n    /*!\r\n    *  Method description.\r\n    *\r\n    *    @param [in]    Description.\r\n    *\r\n    *    @return Description.\r\n    */\r\n    virtual void onCreateNewItem(const VLNV& vlnv);\r\n\r\n    /*!\r\n    *  Method description.\r\n    *\r\n    *    @param [in]    Description.\r\n    *\r\n    *    @return Description.\r\n    */\r\n    virtual void onCreateDesign(const VLNV& vlnv);\r\n\r\n    /*!\r\n    *  Method description.\r\n    *\r\n    *    @param [in]    Description.\r\n    *\r\n    *    @return Description.\r\n    */\r\n    virtual void removeObject(const VLNV& vlnv);\r\n\r\n    /*!\r\n    *  Method description.\r\n    *\r\n    *    @param [in]    Description.\r\n    *\r\n    *    @return Description.\r\n    */\r\n    virtual void removeObjects(const QList<VLNV>& vlnvList);\r\n\r\n    /*!\r\n    *  Method description.\r\n    *\r\n    *    @param [in]    Description.\r\n    *\r\n    *    @return Description.\r\n    */\r\n    virtual void beginSave();\r\n\r\n    /*!\r\n    *  Method description.\r\n    *\r\n    *    @param [in]    Description.\r\n    *\r\n    *    @return Description.\r\n    */\r\n    virtual void endSave();\r\n\r\nprivate:\r\n\r\n    //! Disable copying.\r\n    LibraryMock(LibraryMock const& rhs);\r\n    LibraryMock& operator=(LibraryMock const& rhs);\r\n\r\n    //! The components in the library.\r\n    QMap<VLNV, QSharedPointer<Document> > components_;\r\n\r\n    //! The paths to components in the library.\r\n    QMap<VLNV, QString > paths_;\r\n\r\n};\r\n\r\n#endif // LIBRARYMOCK_H\r\n"
  },
  {
    "path": "tests/MockObjects/PluginMock.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: PluginMock.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Esko Pekkarinen\n// Date: 23.04.2018\n//\n// Description:\n// <Short description of the class/file contents>\n//-----------------------------------------------------------------------------\n\n#include \"PluginMock.h\"\n\n#include <KactusAPI/include/IPluginUtility.h>\n\n//-----------------------------------------------------------------------------\n// Function: PluginMock::PluginMock()\n//-----------------------------------------------------------------------------\nPluginMock::PluginMock()\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: PluginMock::~PluginMock()\n//-----------------------------------------------------------------------------\nPluginMock::~PluginMock()\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: PluginMock::getName()\n//-----------------------------------------------------------------------------\nQString PluginMock::getName() const\n{\n    return QStringLiteral(\"PluginMock\");\n}\n\n//-----------------------------------------------------------------------------\n// Function: PluginMock::getVersion()\n//-----------------------------------------------------------------------------\nQString PluginMock::getVersion() const\n{\n    return QStringLiteral(\"1.0\");\n}\n\n//-----------------------------------------------------------------------------\n// Function: PluginMock::getDescription()\n//-----------------------------------------------------------------------------\nQString PluginMock::getDescription() const\n{\n    return QStringLiteral(\"Mock object for plugins.\");\n}\n\n//-----------------------------------------------------------------------------\n// Function: PluginMock::getVendor()\n//-----------------------------------------------------------------------------\nQString PluginMock::getVendor() const\n{\n    return QStringLiteral(\"tut.fi\");\n}\n\n//-----------------------------------------------------------------------------\n// Function: PluginMock::getLicense()\n//-----------------------------------------------------------------------------\nQString PluginMock::getLicense() const\n{\n    return QStringLiteral(\"LGLP2\");\n}\n\n//-----------------------------------------------------------------------------\n// Function: PluginMock::getLicenseHolder()\n//-----------------------------------------------------------------------------\nQString PluginMock::getLicenseHolder() const\n{\n    return QStringLiteral(\"Public\");\n}\n\n//-----------------------------------------------------------------------------\n// Function: PluginMock::getSettingsWidget()546582\n//-----------------------------------------------------------------------------\nQWidget* PluginMock::getSettingsWidget()\n{\n    return 0;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PluginMock::getSettingsModel()\n//-----------------------------------------------------------------------------\nPluginSettingsModel* PluginMock::getSettingsModel()\n{\n    return 0;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PluginMock::getProgramRequirements()\n//-----------------------------------------------------------------------------\nQList<IPlugin::ExternalProgramRequirement> PluginMock::getProgramRequirements()\n{\n    QList<IPlugin::ExternalProgramRequirement> noRequirements;\n    return noRequirements;\n}\n\n//-----------------------------------------------------------------------------\n// Function: PluginMock::getCommand()\n//-----------------------------------------------------------------------------\nQString PluginMock::getCommand() const\n{\n    return QStringLiteral(\"mock\");\n}\n\n//-----------------------------------------------------------------------------\n// Function: PluginMock::process()\n//-----------------------------------------------------------------------------\nvoid PluginMock::process(QStringList const& arguments, IPluginUtility* utility)\n{\n    utility->printInfo(arguments.join(QLatin1Char(' ')));\n}\n\n//-----------------------------------------------------------------------------\n// Function: PluginMock::getOutputFormat()\n//-----------------------------------------------------------------------------\nQString PluginMock::getOutputFormat() const\n{\n    return QString();\n}\n\n//-----------------------------------------------------------------------------\n// Function: PluginMock::runGenerator()\n//-----------------------------------------------------------------------------\nvoid PluginMock::runGenerator(IPluginUtility* utility, QSharedPointer<Component> component, QSharedPointer<Design> design, QSharedPointer<DesignConfiguration> designConfiguration, QString const& viewName, QString const& outputDirectory)\n{\n}\n"
  },
  {
    "path": "tests/MockObjects/PluginMock.h",
    "content": "//-----------------------------------------------------------------------------\n// File: PluginMock.h\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Esko Pekkarinen\n// Date: 23.04.2018\n//\n// Description:\n// <Short description of the class/file contents>\n//-----------------------------------------------------------------------------\n\n#ifndef PLUGINMOCK_H\n#define PLUGINMOCK_H\n\n#include <KactusAPI/include/IPlugin.h>\n#include <KactusAPI/include/CLIGenerator.h>\n\nclass PluginMock : public IPlugin, public CLIGenerator\n{\npublic:\n\n    //! The constructor.\n    PluginMock();\n\n    //! The destructor.\n    virtual ~PluginMock();\n\n    virtual QString getName() const;\n\n    virtual QString getVersion() const;\n\n    virtual QString getDescription() const;\n\n    virtual QString getVendor() const;\n\n    virtual QString getLicense() const;\n\n    virtual QString getLicenseHolder() const;\n\n    virtual QWidget* getSettingsWidget();\n\n    virtual PluginSettingsModel* getSettingsModel();\n\n    virtual QList<IPlugin::ExternalProgramRequirement> getProgramRequirements();\n\n    virtual QString getCommand() const;\n\n    virtual void process(QStringList const& arguments, IPluginUtility* utility);\n\n    QString getOutputFormat() const override;\n\n    void runGenerator(IPluginUtility* utility, QSharedPointer<Component> component, QSharedPointer<Design> design, QSharedPointer<DesignConfiguration> designConfiguration, QString const& viewName, QString const& outputDirectory) override;\n\nprivate:\n\n    // Disable copying.\n    PluginMock(PluginMock const& rhs);\n    PluginMock& operator=(PluginMock const& rhs);\n\n};\n\n#endif // PLUGINMOCK_H\n\n"
  },
  {
    "path": "tests/Plugins/CppSourceAnalyzer/tst_CppSourceAnalyzer.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: tst_CppSourceAnalyzer.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Anton Hagqvist\n// Date: 11.06.2024\n//\n// Description:\n// Unit test for CppSourceAnalyzer.\n//-----------------------------------------------------------------------------\n\n#include <Plugins/CppSourceAnalyzer/CppSourceAnalyzer.h>\n#include <IPXACTmodels/Component/Component.h>\n\n#include <QtTest>\n#include <QList>\n#include <QFile>\n\nclass tst_CppSourceAnalyzer : public QObject\n{\n    Q_OBJECT\n\npublic:\n    tst_CppSourceAnalyzer();\n\n\nprivate slots:\n    void cleanup();\n\n    void testGetDependencies();\n\n    void testRemoveComments();\n\nprivate:\n\n    CppSourceAnalyzer analyzer;\n\n};\n\ntst_CppSourceAnalyzer::tst_CppSourceAnalyzer()\n{\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_CppSourceAnalyzer::cleanup()\n//-----------------------------------------------------------------------------\nvoid tst_CppSourceAnalyzer::cleanup()\n{\n    QFile sampleFile(\"sample.c\");\n    if (sampleFile.exists())\n    {\n        sampleFile.remove();\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_CppSourceAnalyzer::testCase1()\n//-----------------------------------------------------------------------------\nvoid tst_CppSourceAnalyzer::testGetDependencies()\n{\n    QString source =\n        \"#include <stdio.h>\\n\"\n        \"\\n\"\n        \"#include \\\"file2.h\\\"\\n\"\n        \"\\n\"\n        \"int main() {\\n\"\n        \"// this is a comment\\n\"\n        \"/* this is a\\n\"\n        \"multiline comment*/\\n\"\n        \"    return 0;\\n\"\n        \"}\";\n    \n    QFile sampleFile(\"sample.c\");\n    sampleFile.open(QFile::ReadWrite);\n    QTextStream stream(&sampleFile);\n    stream << source;\n    sampleFile.close();\n\n    auto deps = analyzer.getFileDependencies(nullptr, \"\", \"sample.c\");\n\n    QVERIFY(deps.size() == 2);\n    QVERIFY(deps.first().filename == \"stdio.h\");\n    QVERIFY(deps.last().filename == \"file2.h\");\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_CppSourceAnalyzer::testRemoveComments()\n//-----------------------------------------------------------------------------\nvoid tst_CppSourceAnalyzer::testRemoveComments()\n{\n    QString source =\n        \"#include <stdio.h>\\n\"\n        \"\\n\"\n        \"#include \\\"file2.h\\\"\\n\"\n        \"\\n\"\n        \"int main() {\\n\"\n        \"// this is a comment\\n\"\n        \"/* this is a\\n\"\n        \"multiline comment*/\\n\"\n        \"    printf(\\\"this is a string\\\");\\n\"\n        \"    return 0;\\n\"\n        \"}\";\n\n    QString target = \n        \"#include <stdio.h>\\n\"\n        \"#include \\\"file2.h\\\"\\n\"\n        \"\\n\\n\"\n        \"int main() {\\n\"\n        \"\\n\\n\"\n        \"printf();\\n\"\n        \"return 0;\\n\"\n        \"}\\n\";\n\n    QFile sampleFile(\"sample.c\");\n    sampleFile.open(QFile::ReadWrite);\n    QTextStream stream(&sampleFile);\n    stream << source;\n    sampleFile.close();\n\n    QFile newFile(\"sample.c\");\n    newFile.open(QIODevice::ReadOnly | QIODevice::Text);\n\n    QString parsedSource = analyzer.getSourceData(newFile);\n    QCOMPARE(parsedSource, target);\n}\n\nQTEST_APPLESS_MAIN(tst_CppSourceAnalyzer)\n\n#include \"tst_CppSourceAnalyzer.moc\"\n"
  },
  {
    "path": "tests/Plugins/CppSourceAnalyzer/tst_CppSourceAnalyzer.pri",
    "content": "#-----------------------------------------------------------------------------\n# File: tst_CppSourceAnalyzer.pri\n#-----------------------------------------------------------------------------\n# Project: Kactus2\n# Author: Anton Hagqvist\n# Date: 11.06.2024\n#\n# Description:\n# CppSourceAnalyzerTest includes\n#-----------------------------------------------------------------------------\n\nHEADERS += ../../../Plugins/CppSourceAnalyzer/CppSourceAnalyzer.h\n\nSOURCES += ./tst_CppSourceAnalyzer.cpp \\\n    ../../../Plugins/CppSourceAnalyzer/CppSourceAnalyzer.cpp\n"
  },
  {
    "path": "tests/Plugins/CppSourceAnalyzer/tst_CppSourceAnalyzer.pro",
    "content": "#-----------------------------------------------------------------------------\n# File: tst_CppSourceAnalyzer.pro\n#-----------------------------------------------------------------------------\n# Project: Kactus2\n# Author: Anton Hagqvist\n# Date: 11.06.2024\n#\n# Description:\n# Qt project file template for running unit tests for CppSourceAnalyzer.\n#-----------------------------------------------------------------------------\n\nTEMPLATE = app\n\nTARGET = tst_CppSourceAnalyzer\n\nQT += core xml gui testlib widgets\nCONFIG += c++17 testcase console\n\nwin32:CONFIG(release, debug|release) {\n    LIBS += -L$$PWD/../../../executable/ -lIPXACTmodels\n    LIBS += -L$$PWD/../../../executable/ -lKactusAPI\n    DESTDIR = ./release\n}\nelse:win32:CONFIG(debug, debug|release) {\n    LIBS += -L$$PWD/../../../executable/ -lIPXACTmodelsd\n    LIBS += -L$$PWD/../../../executable/ -lKactusAPId\n    DESTDIR = ./debug\n}\nelse:unix {\n    LIBS += -L$$PWD/../../../executable/ -lIPXACTmodels\n    LIBS += -L$$PWD/../../../executable/ -lKactusAPI\n    DESTDIR = ./release\n}\n\nDESTDIR = ./release\n\nINCLUDEPATH += $$DESTDIR\nINCLUDEPATH += $$PWD/../../../\nINCLUDEPATH += $$PWD/../../../executable\n\nDEPENDPATH += $$PWD/../../../\nDEPENDPATH += $$PWD/../../../executable\nDEPENDPATH += .\n\nOBJECTS_DIR += $$DESTDIR\n\nMOC_DIR += ./generatedFiles\nUI_DIR += ./generatedFiles\nRCC_DIR += ./generatedFiles\ninclude(tst_CppSourceAnalyzer.pri)\n"
  },
  {
    "path": "tests/Plugins/LinuxDeviceTreeGenerator/tst_LinuxDeviceTreeGenerator.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: tst_LinuxDeviceTreeGenerator.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 08.05.2018\n//\n// Description:\n// Unit test for class LinuxDeviceTreeGenerator.\n//-----------------------------------------------------------------------------\n\n#include <QtTest>\n\n#include <IPXACTmodels/common/VLNV.h>\n#include <IPXACTmodels/common/ConfigurableVLNVReference.h>\n\n#include <IPXACTmodels/Component/Component.h>\n#include <IPXACTmodels/Component/View.h>\n#include <IPXACTmodels/Component/DesignInstantiation.h>\n#include <IPXACTmodels/Component/MemoryMap.h>\n#include <IPXACTmodels/Component/AddressBlock.h>\n#include <IPXACTmodels/Component/AddressSpace.h>\n#include <IPXACTmodels/Component/BusInterface.h>\n#include <IPXACTmodels/Component/InitiatorInterface.h>\n#include <IPXACTmodels/Component/TargetInterface.h>\n#include <IPXACTmodels/Component/MirroredTargetInterface.h>\n#include <IPXACTmodels/Component/TransparentBridge.h>\n#include <IPXACTmodels/Component/Cpu.h>\n\n#include <IPXACTmodels/Component/Channel.h>\n\n#include <IPXACTmodels/Design/Design.h>\n\n#include <editors/MemoryDesigner/MasterSlavePathSearch.h>\n\n#include <Plugins/LinuxDeviceTree/LinuxDeviceTreeGenerator.h>\n\n#include <tests/MockObjects/LibraryMock.h>\n\nclass tst_LinuxDeviceTreeGenerator : public QObject\n{\n    Q_OBJECT\n\npublic:\n    tst_LinuxDeviceTreeGenerator();\n\nprivate slots:\n\n    void init();\n    void cleanup();\n\n    void testWriteSimpleCPU();\n\n    void testWriteSimpleConnection();\n\n    void testConnectToMemory();\n    void testConnectToMemoryAndMap();\n\n    void testWriteSingleConnectionWithMultipleCPUs();\n    void testWriteMultipleCPUs();\n\n    void testSingleCPUInMultipleMasterInterfaces();\n\n    void testAddressChange();\n    void testAddressChangeInMirroredSlave();\n\n    void testCPUInMiddleOfPath();\n\n    void testBusPath();\n\n    void testHierarchicalPath();\n\n    void testMemoryInAddressBlock();\nprivate:\n\n    QString runGenerator(QString const& activeView, bool generateAddressBlocks = false);\n\n    QString getFileContent(QString const& fileName);\n\n    QSharedPointer<AddressSpace> createAddressSpace(QString const& spaceName, QString const& range,\n        QString const& width, QSharedPointer<Component> containingComponent) const;\n\n    QSharedPointer<Cpu> createCPU(QString const& cpuName, QString const& spaceReference,\n        QSharedPointer<Component> containingComponent) const;\n\n    QSharedPointer<BusInterface> createMasterBusInterface(QString const& busName,\n        QSharedPointer<AddressSpace> referencedSpace, QSharedPointer<Component> containingComponent) const;\n\n    QSharedPointer<BusInterface> createSlaveBusInterface(QString const& busName,\n        QSharedPointer<MemoryMap> referencedMap, QSharedPointer<Component> containingComponent) const;\n\n    QSharedPointer<BusInterface> createMirroredSlaveBusInterface(QString const& busName,\n        QString const& remapAddress, QString const& remapRange, QSharedPointer<Component> containingComponent)\n        const;\n\n    QSharedPointer<BusInterface> createMirroredMasterBusInterface(QString const& busName,\n        QSharedPointer<Component> containingComponent) const;\n\n    QSharedPointer<BusInterface> createBusInterface(QString const& busName, General::InterfaceMode mode,\n        QSharedPointer<Component> containingComponent) const;\n\n    QSharedPointer<Channel> createChannel(QString const& channelName, QStringList const& channeledInterfaces,\n        QSharedPointer<Component> containingComponent) const;\n\n    QSharedPointer<MemoryMap> createMemoryMap(QString const& mapName,\n        QSharedPointer<Component> containingComponent) const;\n\n    void createBlockForMap(QString const& blockName, QString const& blockBaseAddress, QString const& blockWidth,\n        QString const& blockRange, QSharedPointer<MemoryMap> targetMap);\n\n    QSharedPointer<ComponentInstance> createComponentInstance(VLNV const& vlnv, QString const& name,\n        QString const& id, QSharedPointer<Design> design) const;\n\n    void createInterconnection(QSharedPointer<ActiveInterface> startInterface,\n        QSharedPointer<ActiveInterface> endInterface, QSharedPointer<Design> design);\n\n    void createHierarchicalConnection(QSharedPointer<HierInterface> startInterface,\n        QSharedPointer<ActiveInterface> endInterface, QSharedPointer<Design> design);\n\n    //-----------------------------------------------------------------------------\n    // Data.\n    //-----------------------------------------------------------------------------\n\n    QSharedPointer<Component> topComponent_;\n\n    QSharedPointer<View> hierarchicalView_;\n\n    QSharedPointer<Design> design_;\n\n    LibraryMock* library_;\n};\n\n//-----------------------------------------------------------------------------\n// Function: tst_LinuxDeviceTreeGenerator::tst_LinuxDeviceTreeGenerator()\n//-----------------------------------------------------------------------------\ntst_LinuxDeviceTreeGenerator::tst_LinuxDeviceTreeGenerator():\ntopComponent_(),\nhierarchicalView_(),\ndesign_(),\nlibrary_(new LibraryMock(this))\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_LinuxDeviceTreeGenerator::init()\n//-----------------------------------------------------------------------------\nvoid tst_LinuxDeviceTreeGenerator::init()\n{\n    VLNV vlnv(VLNV::COMPONENT, \"Test\", \"TestLibrary\", \"TopComponent\", \"1.0\");\n    topComponent_ = QSharedPointer<Component>(new Component(vlnv, Document::Revision::Std14));\n\n    VLNV designVlnv(VLNV::DESIGN, \"Test\", \"TestLibrary\", \"TestDesign\", \"1.0\");\n    design_ = QSharedPointer<Design>(new Design(designVlnv, Document::Revision::Std14));\n    library_->addComponent(design_);\n\n    hierarchicalView_ = QSharedPointer<View>(new View(\"hierarchical\"));\n    hierarchicalView_->setDesignInstantiationRef(\"design\");\n    topComponent_->getViews()->append(hierarchicalView_);\n\n    QSharedPointer<DesignInstantiation> designInstantiation(new DesignInstantiation(\"design\"));\n    designInstantiation->setDesignReference(QSharedPointer<ConfigurableVLNVReference>(\n        new ConfigurableVLNVReference(design_->getVlnv())));\n    topComponent_->getDesignInstantiations()->append(designInstantiation);\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_LinuxDeviceTreeGenerator::cleanup()\n//-----------------------------------------------------------------------------\nvoid tst_LinuxDeviceTreeGenerator::cleanup()\n{\n    library_->clear();\n\n    QFile outputFile(\"./TopComponent_0.dts\");\n    outputFile.remove();\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_LinuxDeviceTreeGenerator::testWriteSimpleCPU()\n//-----------------------------------------------------------------------------\nvoid tst_LinuxDeviceTreeGenerator::testWriteSimpleCPU()\n{\n    QString output = runGenerator(\"hierarchical\");\n    QString expectedOutput = \"\";\n\n    QCOMPARE(output, expectedOutput);\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_LinuxDeviceTreeGenerator::testWriteSimpleConnection()\n//-----------------------------------------------------------------------------\nvoid tst_LinuxDeviceTreeGenerator::testWriteSimpleConnection()\n{\n    VLNV cpuVLNV(VLNV::COMPONENT, \"Test\", \"TestLibrary\", \"testCPU\", \"1.0\");\n    QSharedPointer<Component> cpuComponent (new Component(cpuVLNV, Document::Revision::Std14));\n\n    QSharedPointer<AddressSpace> testSpace =\n        createAddressSpace(QStringLiteral(\"testSpace\"), \"16\", \"16\", cpuComponent);\n    QSharedPointer<Cpu> testCPU = createCPU(\"testCPU\", testSpace->name(), cpuComponent);\n\n    QSharedPointer<BusInterface> cpuBus = createMasterBusInterface(\"topBus\", testSpace, cpuComponent);\n\n    VLNV mapVlnv(VLNV::COMPONENT, \"Test\", \"TestLibrary\", \"MapComponent\", \"1.0\");\n    QSharedPointer<Component> mapComponent (new Component(mapVlnv, Document::Revision::Std14));\n\n    library_->addComponent(cpuComponent);\n    library_->addComponent(mapComponent);\n\n    QSharedPointer<MemoryMap> testMap = createMemoryMap(\"testMap\", mapComponent);\n    QSharedPointer<BusInterface> mapBus = createSlaveBusInterface(\"mapBus\", testMap, mapComponent);\n\n    QSharedPointer<ComponentInstance> cpuInstance =\n        createComponentInstance(cpuVLNV, \"cpuInstance\", \"cpuID\", design_);\n    QSharedPointer<ComponentInstance> mapInstance =\n        createComponentInstance(mapVlnv, \"mapInstance\", \"mapID\", design_);\n\n    QSharedPointer<ActiveInterface> cpuInterface(\n        new ActiveInterface(cpuInstance->getInstanceName(), cpuBus->name()));\n    QSharedPointer<ActiveInterface> mapInterface(\n        new ActiveInterface(mapInstance->getInstanceName(), mapBus->name()));\n\n    createInterconnection(cpuInterface, mapInterface, design_);\n\n    QString output = runGenerator(hierarchicalView_->name());\n\n    QString expectedOutput =\n        \"/dts-v1/;\\n\\n\"\n        \"/ {\\n\"\n        \"\\t#address-cells = <1>;\\n\"\n        \"\\t#size-cells = <1>;\\n\"\n        \"\\tmodel = \\\"Test,TestDesign\\\";\\n\"\n        \"\\tcompatible = \\\"Test,TestDesign\\\";\\n\"\n        \"\\n\"\n            \"\\tcpus {\\n\"\n                \"\\t\\t#address-cells = <1>;\\n\"\n                \"\\t\\t#size-cells = <0>;\\n\\n\"\n                \"\\t\\t// 'testCPU' in component Test:TestLibrary:testCPU:1.0\\n\"\n                \"\\t\\tcpu@0 {\\n\"\n                    \"\\t\\t\\treg = <0>;\\n\"\n                \"\\t\\t};\\n\"\n            \"\\t};\\n\\n\"\n            \"\\t// Memory map 'testMap' in instance 'mapInstance' of component Test:TestLibrary:MapComponent:1.0\\n\"\n            \"\\ttestMap@0 {\\n\"\n                \"\\t\\t#address-cells = <1>;\\n\"\n                \"\\t\\t#size-cells = <1>;\\n\"\n                \"\\t\\treg = <0x0 0x1>;\\n\"\n            \"\\t};\\n\\n\"\n        \"};\\n\\n\";\n\n    QCOMPARE(output, expectedOutput);\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_LinuxDeviceTreeGenerator::testConnectToMemory()\n//-----------------------------------------------------------------------------\nvoid tst_LinuxDeviceTreeGenerator::testConnectToMemory()\n{\n    VLNV cpuVLNV(VLNV::COMPONENT, \"Test\", \"TestLibrary\", \"testCPU\", \"1.0\");\n    VLNV mapVlnv(VLNV::COMPONENT, \"Test\", \"TestLibrary\", \"MapComponent\", \"1.0\");\n\n    QSharedPointer<Component> cpuComponent(new Component(cpuVLNV, Document::Revision::Std14));\n    QSharedPointer<Component> mapComponent(new Component(mapVlnv, Document::Revision::Std14));\n\n    library_->addComponent(cpuComponent);\n    library_->addComponent(mapComponent);\n\n    QSharedPointer<AddressSpace> testSpace =\n        createAddressSpace(QStringLiteral(\"testSpace\"), \"16\", \"16\", cpuComponent);\n    QSharedPointer<Cpu> testCPU = createCPU(\"testCPU\", testSpace->name(), cpuComponent);\n\n    QSharedPointer<AddressBlock> newBlock(new AddressBlock(\"memoryBlock\"));\n    newBlock->setUsage(General::MEMORY);\n    newBlock->setBaseAddress(\"0\");\n    newBlock->setWidth(\"8\");\n    newBlock->setRange(\"16\");\n\n    QSharedPointer<MemoryMap> testMap = createMemoryMap(\"testMap\", mapComponent);\n    testMap->getMemoryBlocks()->append(newBlock);\n\n    QSharedPointer<BusInterface> cpuBus = createMasterBusInterface(\"topBus\", testSpace, cpuComponent);\n    QSharedPointer<BusInterface> mapBus = createSlaveBusInterface(\"mapBus\", testMap, mapComponent);\n\n    QSharedPointer<ComponentInstance> cpuInstance =\n        createComponentInstance(cpuVLNV, \"cpuInstance\", \"cpuID\", design_);\n    QSharedPointer<ComponentInstance> mapInstance =\n        createComponentInstance(mapVlnv, \"mapInstance\", \"mapID\", design_);\n\n    QSharedPointer<ActiveInterface> cpuInterface(\n        new ActiveInterface(cpuInstance->getInstanceName(), cpuBus->name()));\n    QSharedPointer<ActiveInterface> mapInterface(\n        new ActiveInterface(mapInstance->getInstanceName(), mapBus->name()));\n\n    createInterconnection(cpuInterface, mapInterface, design_);\n\n    QString output = runGenerator(hierarchicalView_->name());\n\n    QString expectedOutput =\n        \"/dts-v1/;\\n\\n\"\n        \"/ {\\n\"        \n        \"\\t#address-cells = <1>;\\n\"\n        \"\\t#size-cells = <1>;\\n\"\n        \"\\tmodel = \\\"Test,TestDesign\\\";\\n\"\n        \"\\tcompatible = \\\"Test,TestDesign\\\";\\n\"\n        \"\\n\"\n            \"\\tcpus {\\n\"\n                \"\\t\\t#address-cells = <1>;\\n\"\n                \"\\t\\t#size-cells = <0>;\\n\\n\"\n                \"\\t\\t// 'testCPU' in component Test:TestLibrary:testCPU:1.0\\n\"\n                \"\\t\\tcpu@0 {\\n\"\n                    \"\\t\\t\\treg = <0>;\\n\"\n                \"\\t\\t};\\n\"\n            \"\\t};\\n\\n\"\n            \"\\t// Memory map 'testMap' in instance 'mapInstance' of component Test:TestLibrary:MapComponent:1.0\\n\"\n            \"\\tmemory@0 {\\n\"\n                \"\\t\\tdevice_type = \\\"memory\\\";\\n\"\n                \"\\t\\t#address-cells = <1>;\\n\"\n                \"\\t\\t#size-cells = <1>;\\n\"\n                \"\\t\\treg = <0x0 0x10>;\\n\"\n            \"\\t};\\n\\n\"\n        \"};\\n\\n\";\n\n    QCOMPARE(output, expectedOutput);\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_LinuxDeviceTreeGenerator::testConnectToMemoryAndMap()\n//-----------------------------------------------------------------------------\nvoid tst_LinuxDeviceTreeGenerator::testConnectToMemoryAndMap()\n{\n    VLNV cpuVLNV(VLNV::COMPONENT, \"Test\", \"TestLibrary\", \"testCPU\", \"1.0\");\n    VLNV mapVlnv(VLNV::COMPONENT, \"Test\", \"TestLibrary\", \"MapComponent\", \"1.0\");\n    VLNV notMemoryVLNV(VLNV::COMPONENT, \"Test\", \"TestLibrary\", \"notMemoryComponent\", \"1.0\");\n\n    QSharedPointer<Component> cpuComponent(new Component(cpuVLNV, Document::Revision::Std14));\n    QSharedPointer<Component> mapComponent(new Component(mapVlnv, Document::Revision::Std14));\n    QSharedPointer<Component> notMemoryComponent(new Component(notMemoryVLNV, Document::Revision::Std14));\n\n    library_->addComponent(cpuComponent);\n    library_->addComponent(mapComponent);\n    library_->addComponent(notMemoryComponent);\n\n    QSharedPointer<AddressSpace> testSpace =\n        createAddressSpace(QStringLiteral(\"testSpace\"), \"16\", \"16\", cpuComponent);\n    QSharedPointer<Cpu> testCPU = createCPU(\"testCPU\", testSpace->name(), cpuComponent);\n\n    QSharedPointer<AddressBlock> newBlock(new AddressBlock(\"memoryBlock\"));\n    newBlock->setUsage(General::MEMORY);\n    newBlock->setBaseAddress(\"0\");\n    newBlock->setWidth(\"8\");\n    newBlock->setRange(\"16\");\n\n    QSharedPointer<MemoryMap> testMap = createMemoryMap(\"testMap\", mapComponent);\n    testMap->getMemoryBlocks()->append(newBlock);\n    QSharedPointer<MemoryMap> notMemory = createMemoryMap(\"notMemory\", notMemoryComponent);\n\n    QSharedPointer<BusInterface> cpuBus = createMasterBusInterface(\"topBus\", testSpace, cpuComponent);\n    QSharedPointer<BusInterface> mapBus = createSlaveBusInterface(\"mapBus\", testMap, mapComponent);\n    QSharedPointer<BusInterface> notMemoryBus = createSlaveBusInterface(\"notMemoryBus\", notMemory, notMemoryComponent);\n\n    QSharedPointer<ComponentInstance> cpuInstance =\n        createComponentInstance(cpuVLNV, \"cpuInstance\", \"cpuID\", design_);\n    QSharedPointer<ComponentInstance> mapInstance =\n        createComponentInstance(mapVlnv, \"mapInstance\", \"mapID\", design_);\n    QSharedPointer<ComponentInstance> notMemoryInstance =\n        createComponentInstance(notMemoryVLNV, \"notMemoryInstance\", \"notMemoryID\", design_);\n\n    QSharedPointer<ActiveInterface> cpuInterface(\n        new ActiveInterface(cpuInstance->getInstanceName(), cpuBus->name()));\n    QSharedPointer<ActiveInterface> mapInterface(\n        new ActiveInterface(mapInstance->getInstanceName(), mapBus->name()));\n    QSharedPointer<ActiveInterface> notMapInterface(\n        new ActiveInterface(notMemoryInstance->getInstanceName(), notMemoryBus->name()));\n\n    createInterconnection(cpuInterface, mapInterface, design_);\n    createInterconnection(cpuInterface, notMapInterface, design_);\n\n    QString output = runGenerator(hierarchicalView_->name());\n\n    QString expectedOutput =\n        \"/dts-v1/;\\n\\n\"\n        \"/ {\\n\"        \n        \"\\t#address-cells = <1>;\\n\"\n        \"\\t#size-cells = <1>;\\n\"\n        \"\\tmodel = \\\"Test,TestDesign\\\";\\n\"\n        \"\\tcompatible = \\\"Test,TestDesign\\\";\\n\"\n        \"\\n\"\n            \"\\tcpus {\\n\"\n                \"\\t\\t#address-cells = <1>;\\n\"\n                \"\\t\\t#size-cells = <0>;\\n\\n\"\n                \"\\t\\t// 'testCPU' in component Test:TestLibrary:testCPU:1.0\\n\"\n                \"\\t\\tcpu@0 {\\n\"\n                    \"\\t\\t\\treg = <0>;\\n\"\n                \"\\t\\t};\\n\"\n            \"\\t};\\n\\n\"\n            \"\\t// Memory map 'notMemory' in instance 'notMemoryInstance' of component Test:TestLibrary:notMemoryComponent:1.0\\n\"\n            \"\\tnotMemory@0 {\\n\"\n                \"\\t\\t#address-cells = <1>;\\n\"\n                \"\\t\\t#size-cells = <1>;\\n\"\n                \"\\t\\treg = <0x0 0x1>;\\n\"\n            \"\\t};\\n\\n\"\n            \"\\t// Memory map 'testMap' in instance 'mapInstance' of component Test:TestLibrary:MapComponent:1.0\\n\"\n            \"\\tmemory@0 {\\n\"\n                \"\\t\\tdevice_type = \\\"memory\\\";\\n\"\n                \"\\t\\t#address-cells = <1>;\\n\"\n                \"\\t\\t#size-cells = <1>;\\n\"\n                \"\\t\\treg = <0x0 0x10>;\\n\"\n            \"\\t};\\n\\n\"\n        \"};\\n\\n\";\n\n    QCOMPARE(output, expectedOutput);\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_LinuxDeviceTreeGenerator::testWriteSingleConnectionWithMultipleCPUs()\n//-----------------------------------------------------------------------------\nvoid tst_LinuxDeviceTreeGenerator::testWriteSingleConnectionWithMultipleCPUs()\n{\n    VLNV cpuVLNV(VLNV::COMPONENT, \"Test\", \"TestLibrary\", \"testCPU\", \"1.0\");\n    VLNV mapVlnv(VLNV::COMPONENT, \"Test\", \"TestLibrary\", \"MapComponent\", \"1.0\");\n\n    QSharedPointer<Component> cpuComponent(new Component(cpuVLNV, Document::Revision::Std14));\n    QSharedPointer<Component> mapComponent(new Component(mapVlnv, Document::Revision::Std14));\n\n    library_->addComponent(cpuComponent);\n    library_->addComponent(mapComponent);\n\n    QSharedPointer<AddressSpace> testSpace =\n        createAddressSpace(QStringLiteral(\"testSpace\"), \"16\", \"16\", cpuComponent);\n    QSharedPointer<Cpu> testCPU = createCPU(\"testCPU\", testSpace->name(), cpuComponent);\n    QSharedPointer<Cpu> secondTestCPU = createCPU(\"secondTestCPU\", testSpace->name(), cpuComponent);\n\n    QSharedPointer<BusInterface> cpuBus = createMasterBusInterface(\"topBus\", testSpace, cpuComponent);\n\n    QSharedPointer<MemoryMap> testMap = createMemoryMap(\"testMap\", mapComponent);\n    QSharedPointer<BusInterface> mapBus = createSlaveBusInterface(\"mapBus\", testMap, mapComponent);\n\n    QSharedPointer<ComponentInstance> cpuInstance =\n        createComponentInstance(cpuVLNV, \"cpuInstance\", \"cpuID\", design_);\n    QSharedPointer<ComponentInstance> mapInstance =\n        createComponentInstance(mapVlnv, \"mapInstance\", \"mapID\", design_);\n\n    QSharedPointer<ActiveInterface> cpuInterface(\n        new ActiveInterface(cpuInstance->getInstanceName(), cpuBus->name()));\n    QSharedPointer<ActiveInterface> mapInterface(\n        new ActiveInterface(mapInstance->getInstanceName(), mapBus->name()));\n\n    createInterconnection(cpuInterface, mapInterface, design_);\n\n    QString output = runGenerator(hierarchicalView_->name());\n\n    QString expectedOutput =\n        \"/dts-v1/;\\n\\n\"\n        \"/ {\\n\"\n        \"\\t#address-cells = <1>;\\n\"\n        \"\\t#size-cells = <1>;\\n\"\n        \"\\tmodel = \\\"Test,TestDesign\\\";\\n\"\n        \"\\tcompatible = \\\"Test,TestDesign\\\";\\n\"\n        \"\\n\"\n            \"\\tcpus {\\n\"\n                \"\\t\\t#address-cells = <1>;\\n\"\n                \"\\t\\t#size-cells = <0>;\\n\\n\"\n                \"\\t\\t// 'testCPU' in component Test:TestLibrary:testCPU:1.0\\n\"\n                \"\\t\\tcpu@0 {\\n\"\n                    \"\\t\\t\\treg = <0>;\\n\"\n                \"\\t\\t};\\n\"\n                \"\\t\\t// 'secondTestCPU' in component Test:TestLibrary:testCPU:1.0\\n\"\n                \"\\t\\tcpu@1 {\\n\"\n                    \"\\t\\t\\treg = <1>;\\n\"\n                \"\\t\\t};\\n\"\n            \"\\t};\\n\\n\"\n            \"\\t// Memory map 'testMap' in instance 'mapInstance' of component Test:TestLibrary:MapComponent:1.0\\n\"\n            \"\\ttestMap@0 {\\n\"\n                \"\\t\\t#address-cells = <1>;\\n\"\n                \"\\t\\t#size-cells = <1>;\\n\"\n                \"\\t\\treg = <0x0 0x1>;\\n\"\n            \"\\t};\\n\\n\"\n        \"};\\n\\n\";\n\n    QCOMPARE(output, expectedOutput);\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_LinuxDeviceTreeGenerator::testWriteMultipleCPUs()\n//-----------------------------------------------------------------------------\nvoid tst_LinuxDeviceTreeGenerator::testWriteMultipleCPUs()\n{\n    //! 1st CPU\n    VLNV cpuVLNV(VLNV::COMPONENT, \"Test\", \"TestLibrary\", \"testCPU\", \"1.0\");\n    QSharedPointer<Component> cpuComponent(new Component(cpuVLNV, Document::Revision::Std14));\n\n    QSharedPointer<AddressSpace> testSpace =\n        createAddressSpace(QStringLiteral(\"testSpace\"), \"16\", \"16\", cpuComponent);\n    QSharedPointer<Cpu> testCPU = createCPU(\"testCPU\", testSpace->name(), cpuComponent);\n    QSharedPointer<BusInterface> cpuBus = createMasterBusInterface(\"CPUBus\", testSpace, cpuComponent);\n\n    //! 2nd CPU\n    VLNV cpuVLNV2(VLNV::COMPONENT, \"Test\", \"TestLibrary\", \"testCPU2\", \"1.0\");\n    QSharedPointer<Component> secondCpuComponent(new Component(cpuVLNV2, Document::Revision::Std14));\n\n    QSharedPointer<AddressSpace> secondCPUSpace =\n        createAddressSpace(QStringLiteral(\"secondCPUSpace\"), \"16\", \"16\", secondCpuComponent);\n    QSharedPointer<Cpu> secondTestCPU = createCPU(\"secondTestCPU\", secondCPUSpace->name(), secondCpuComponent);\n    QSharedPointer<BusInterface> secondCpuBus =\n        createMasterBusInterface(\"secondCPUBus\", secondCPUSpace, secondCpuComponent);\n\n    //! 1st Map\n    VLNV mapVlnv(VLNV::COMPONENT, \"Test\", \"TestLibrary\", \"MapComponent\", \"1.0\");\n    QSharedPointer<Component> mapComponent(new Component(mapVlnv, Document::Revision::Std14));\n\n    QSharedPointer<MemoryMap> testMap = createMemoryMap(\"testMap\", mapComponent);\n    QSharedPointer<BusInterface> mapBus = createSlaveBusInterface(\"mapBus\", testMap, mapComponent);\n\n    //! 2nd Map\n    VLNV secondMapVlnv(VLNV::COMPONENT, \"Test\", \"TestLibrary\", \"SecondMapComponent\", \"1.0\");\n    QSharedPointer<Component> secondMapComponent(new Component(secondMapVlnv, Document::Revision::Std14));\n\n    QSharedPointer<MemoryMap> secondTestMap = createMemoryMap(\"secondTestMap\", secondMapComponent);\n    QSharedPointer<BusInterface> secondMapBus =\n        createSlaveBusInterface(\"secondMapBus\", secondTestMap, secondMapComponent);\n\n    library_->addComponent(cpuComponent);\n    library_->addComponent(secondCpuComponent);\n    library_->addComponent(mapComponent);\n    library_->addComponent(secondMapComponent);\n\n    QSharedPointer<ComponentInstance> cpuInstance =\n        createComponentInstance(cpuVLNV, \"cpuInstance\", \"cpuID\", design_);\n    QSharedPointer<ComponentInstance> mapInstance =\n        createComponentInstance(mapVlnv, \"mapInstance\", \"mapID\", design_);\n    QSharedPointer<ComponentInstance> secondCpuInstance =\n        createComponentInstance(cpuVLNV2, \"secondCpuInstance\", \"secondCpuID\", design_);\n    QSharedPointer<ComponentInstance> secondMapInstance =\n        createComponentInstance(secondMapVlnv, \"secondMapInstance\", \"secondMapID\", design_);\n\n    QSharedPointer<ActiveInterface> cpuInterface(\n        new ActiveInterface(cpuInstance->getInstanceName(), cpuBus->name()));\n    QSharedPointer<ActiveInterface> mapInterface(\n        new ActiveInterface(mapInstance->getInstanceName(), mapBus->name()));\n    QSharedPointer<ActiveInterface> secondCpuInterface(\n        new ActiveInterface(secondCpuInstance->getInstanceName(), secondCpuBus->name()));\n    QSharedPointer<ActiveInterface> secondMapInterface(\n        new ActiveInterface(secondMapInstance->getInstanceName(), secondMapBus->name()));\n\n    createInterconnection(cpuInterface, mapInterface, design_);\n    createInterconnection(secondCpuInterface, secondMapInterface, design_);\n\n    QString output0 = runGenerator(hierarchicalView_->name());\n\n    QString expectedOutput0 =\n        \"/dts-v1/;\\n\\n\"\n        \"/ {\\n\"\n        \"\\t#address-cells = <1>;\\n\"\n        \"\\t#size-cells = <1>;\\n\"\n        \"\\tmodel = \\\"Test,TestDesign\\\";\\n\"\n        \"\\tcompatible = \\\"Test,TestDesign\\\";\\n\"\n        \"\\n\"\n        \"\\tcpus {\\n\"\n        \"\\t\\t#address-cells = <1>;\\n\"\n        \"\\t\\t#size-cells = <0>;\\n\\n\"\n                \"\\t\\t// 'testCPU' in component Test:TestLibrary:testCPU:1.0\\n\"\n        \"\\t\\tcpu@0 {\\n\"\n        \"\\t\\t\\treg = <0>;\\n\"\n        \"\\t\\t};\\n\"\n        \"\\t};\\n\\n\"\n        \"\\t// Memory map 'testMap' in instance 'mapInstance' of component Test:TestLibrary:MapComponent:1.0\\n\"\n        \"\\ttestMap@0 {\\n\"\n        \"\\t\\t#address-cells = <1>;\\n\"\n        \"\\t\\t#size-cells = <1>;\\n\"\n        \"\\t\\treg = <0x0 0x1>;\\n\"\n        \"\\t};\\n\\n\"\n        \"};\\n\\n\";\n        \n    QCOMPARE(output0, expectedOutput0);\n\n    QString expectedOutputFile1 =\n        \"/dts-v1/;\\n\\n\"\n        \"/ {\\n\"\n        \"\\t#address-cells = <1>;\\n\"\n        \"\\t#size-cells = <1>;\\n\"\n        \"\\tmodel = \\\"Test,TestDesign\\\";\\n\"\n        \"\\tcompatible = \\\"Test,TestDesign\\\";\\n\"\n        \"\\n\"\n        \"\\tcpus {\\n\"\n        \"\\t\\t#address-cells = <1>;\\n\"\n        \"\\t\\t#size-cells = <0>;\\n\\n\"\n        \"\\t\\t// 'secondTestCPU' in component Test:TestLibrary:testCPU2:1.0\\n\"\n        \"\\t\\tcpu@0 {\\n\"\n        \"\\t\\t\\treg = <0>;\\n\"\n        \"\\t\\t};\\n\"\n        \"\\t};\\n\\n\"\n        \"\\t// Memory map 'secondTestMap' in instance 'secondMapInstance' of component Test:TestLibrary:SecondMapComponent:1.0\\n\"\n        \"\\tsecondTestMap@0 {\\n\"\n        \"\\t\\t#address-cells = <1>;\\n\"\n        \"\\t\\t#size-cells = <1>;\\n\"\n        \"\\t\\treg = <0x0 0x1>;\\n\"\n        \"\\t};\\n\\n\"\n        \"};\\n\\n\";\n\n    QString output1 = getFileContent(\"TopComponent_1.dts\");\n    QCOMPARE(output1, expectedOutputFile1);\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_LinuxDeviceTreeGenerator::testSingleCPUInMultipleMasterInterfaces()\n//-----------------------------------------------------------------------------\nvoid tst_LinuxDeviceTreeGenerator::testSingleCPUInMultipleMasterInterfaces()\n{\n    VLNV cpuVLNV(VLNV::COMPONENT, \"Test\", \"TestLibrary\", \"testCPU\", \"1.0\");\n    VLNV mapVlnv(VLNV::COMPONENT, \"Test\", \"TestLibrary\", \"MapComponent\", \"1.0\");\n\n    QSharedPointer<Component> cpuComponent(new Component(cpuVLNV, Document::Revision::Std14));\n    QSharedPointer<Component> mapComponent(new Component(mapVlnv, Document::Revision::Std14));\n\n    QSharedPointer<AddressSpace> testSpace =\n        createAddressSpace(QStringLiteral(\"testSpace\"), \"16\", \"16\", cpuComponent);\n    QSharedPointer<AddressSpace> secondTestSpace =\n        createAddressSpace(QStringLiteral(\"testSpace2\"), \"8\", \"8\", cpuComponent);\n\n    QSharedPointer<MemoryMap> testMap = createMemoryMap(\"testMap\", mapComponent);\n\n    QSharedPointer<Cpu> testCPU = createCPU(\"testCPU\", \"\", cpuComponent);\n    testCPU->setAddressSpaceRefs(cpuComponent->getAddressSpaceNames());\n\n    QSharedPointer<BusInterface> cpuBus = createMasterBusInterface(\"cpuBus\", testSpace, cpuComponent);\n    QSharedPointer<BusInterface> cpu2B = createMasterBusInterface(\"cpuTwoBus\", secondTestSpace, cpuComponent);\n    QSharedPointer<BusInterface> mapBus = createSlaveBusInterface(\"mapBus\", testMap, mapComponent);\n\n    library_->addComponent(cpuComponent);\n    library_->addComponent(mapComponent);\n\n    QSharedPointer<ComponentInstance> cpuInstance =\n        createComponentInstance(cpuVLNV, \"cpuInstance\", \"cpuID\", design_);\n    QSharedPointer<ComponentInstance> mapInstance =\n        createComponentInstance(mapVlnv, \"mapInstance\", \"mapID\", design_);\n    QSharedPointer<ComponentInstance> secondMapInstance =\n        createComponentInstance(mapVlnv, \"secondMapInstance\", \"secondMapID\", design_);\n\n    QSharedPointer<ActiveInterface> cpuInterface(\n        new ActiveInterface(cpuInstance->getInstanceName(), cpuBus->name()));\n    QSharedPointer<ActiveInterface> secondCPUInterface(\n        new ActiveInterface(cpuInstance->getInstanceName(), cpu2B->name()));\n    QSharedPointer<ActiveInterface> mapInterface(\n        new ActiveInterface(mapInstance->getInstanceName(), mapBus->name()));\n    QSharedPointer<ActiveInterface> map9S(\n        new ActiveInterface(secondMapInstance->getInstanceName(), mapBus->name()));\n\n    createInterconnection(cpuInterface, mapInterface, design_);\n    createInterconnection(secondCPUInterface, map9S, design_);\n\n    QString output = runGenerator(hierarchicalView_->name());\n\n    QString expectedOutput =\n        \"/dts-v1/;\\n\\n\"\n        \"/ {\\n\"\n        \"\\t#address-cells = <1>;\\n\"\n        \"\\t#size-cells = <1>;\\n\"\n        \"\\tmodel = \\\"Test,TestDesign\\\";\\n\"\n        \"\\tcompatible = \\\"Test,TestDesign\\\";\\n\"\n        \"\\n\"\n            \"\\tcpus {\\n\"\n                \"\\t\\t#address-cells = <1>;\\n\"\n                \"\\t\\t#size-cells = <0>;\\n\\n\"\n                \"\\t\\t// 'testCPU' in component Test:TestLibrary:testCPU:1.0\\n\"\n                \"\\t\\tcpu@0 {\\n\"\n                    \"\\t\\t\\treg = <0>;\\n\"\n                \"\\t\\t};\\n\"\n            \"\\t};\\n\\n\"\n            \"\\t// Memory map 'testMap' in instance 'mapInstance' of component Test:TestLibrary:MapComponent:1.0\\n\"\n            \"\\ttestMap@0 {\\n\"\n                \"\\t\\t#address-cells = <1>;\\n\"\n                \"\\t\\t#size-cells = <1>;\\n\"\n                \"\\t\\treg = <0x0 0x1>;\\n\"\n            \"\\t};\\n\"\n            \"\\n\"\n            \"\\t// Memory map 'testMap' in instance 'secondMapInstance' of component Test:TestLibrary:MapComponent:1.0\\n\"\n            \"\\ttestMap@0 {\\n\"\n                \"\\t\\t#address-cells = <1>;\\n\"\n                \"\\t\\t#size-cells = <1>;\\n\"\n                \"\\t\\treg = <0x0 0x1>;\\n\"\n            \"\\t};\\n\\n\"\n        \"};\\n\\n\";\n\n    QCOMPARE(output, expectedOutput);\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_LinuxDeviceTreeGenerator::testAddressChange()\n//-----------------------------------------------------------------------------\nvoid tst_LinuxDeviceTreeGenerator::testAddressChange()\n{\n    VLNV cpuVLNV(VLNV::COMPONENT, \"Test\", \"TestLibrary\", \"testCPU\", \"1.0\");\n    QSharedPointer<Component> cpuComponent(new Component(cpuVLNV, Document::Revision::Std14));\n\n    QSharedPointer<AddressSpace> testSpace =\n        createAddressSpace(QStringLiteral(\"testSpace\"), \"16\", \"16\", cpuComponent);\n    QSharedPointer<Cpu> testCPU = createCPU(\"testCPU\", testSpace->name(), cpuComponent);\n\n    QSharedPointer<BusInterface> cpuBus = createMasterBusInterface(\"topBus\", testSpace, cpuComponent);\n    cpuBus->getMaster()->setBaseAddress(QString(\"10\"));\n\n    VLNV mapVlnv(VLNV::COMPONENT, \"Test\", \"TestLibrary\", \"MapComponent\", \"1.0\");\n    QSharedPointer<Component> mapComponent(new Component(mapVlnv, Document::Revision::Std14));\n\n    library_->addComponent(cpuComponent);\n    library_->addComponent(mapComponent);\n\n    QSharedPointer<MemoryMap> testMap = createMemoryMap(\"testMap\", mapComponent);\n    createBlockForMap(QString(\"testBlock\"), QString(\"0\"), QString(\"8\"), QString(\"16\"), testMap);\n\n    QSharedPointer<BusInterface> mapBus = createSlaveBusInterface(\"mapBus\", testMap, mapComponent);\n\n    QSharedPointer<ComponentInstance> cpuInstance =\n        createComponentInstance(cpuVLNV, \"cpuInstance\", \"cpuID\", design_);\n    QSharedPointer<ComponentInstance> mapInstance =\n        createComponentInstance(mapVlnv, \"mapInstance\", \"mapID\", design_);\n\n    QSharedPointer<ActiveInterface> cpuInterface(\n        new ActiveInterface(cpuInstance->getInstanceName(), cpuBus->name()));\n    QSharedPointer<ActiveInterface> mapInterface(\n        new ActiveInterface(mapInstance->getInstanceName(), mapBus->name()));\n\n    createInterconnection(cpuInterface, mapInterface, design_);\n\n    QString output = runGenerator(hierarchicalView_->name());\n\n    QString expectedOutput =\n        \"/dts-v1/;\\n\\n\"\n        \"/ {\\n\"\n        \"\\t#address-cells = <1>;\\n\"\n        \"\\t#size-cells = <1>;\\n\"\n        \"\\tmodel = \\\"Test,TestDesign\\\";\\n\"\n        \"\\tcompatible = \\\"Test,TestDesign\\\";\\n\"\n        \"\\n\"\n            \"\\tcpus {\\n\"\n                \"\\t\\t#address-cells = <1>;\\n\"\n                \"\\t\\t#size-cells = <0>;\\n\\n\"\n                \"\\t\\t// 'testCPU' in component Test:TestLibrary:testCPU:1.0\\n\"\n                \"\\t\\tcpu@0 {\\n\"\n                    \"\\t\\t\\treg = <0>;\\n\"\n                \"\\t\\t};\\n\"\n            \"\\t};\\n\\n\"\n            \"\\t// Memory map 'testMap' in instance 'mapInstance' of component Test:TestLibrary:MapComponent:1.0\\n\"\n            \"\\ttestMap@a {\\n\"\n                \"\\t\\t#address-cells = <1>;\\n\"\n                \"\\t\\t#size-cells = <1>;\\n\"\n                \"\\t\\treg = <0xa 0x10>;\\n\"\n            \"\\t};\\n\\n\"\n        \"};\\n\\n\";\n\n    QCOMPARE(output, expectedOutput);\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_LinuxDeviceTreeGenerator::testAddressChangeInMirroredSlave()\n//-----------------------------------------------------------------------------\nvoid tst_LinuxDeviceTreeGenerator::testAddressChangeInMirroredSlave()\n{\n    VLNV cpuVLNV(VLNV::COMPONENT, \"Test\", \"TestLibrary\", \"testCPU\", \"1.0\");\n    VLNV mapVlnv(VLNV::COMPONENT, \"Test\", \"TestLibrary\", \"MapComponent\", \"1.0\");\n    VLNV channelVLNV(VLNV::COMPONENT, \"Test\", \"TestLibrary\", \"channelComponent\", \"1.0\");\n\n    QSharedPointer<Component> cpuComponent(new Component(cpuVLNV, Document::Revision::Std14));\n    QSharedPointer<Component> mapComponent(new Component(mapVlnv, Document::Revision::Std14));\n    QSharedPointer<Component> channelComponent(new Component(channelVLNV, Document::Revision::Std14));\n\n    QSharedPointer<AddressSpace> testSpace =\n        createAddressSpace(QStringLiteral(\"testSpace\"), \"16\", \"16\", cpuComponent);\n    QSharedPointer<Cpu> testCPU = createCPU(\"testCPU\", testSpace->name(), cpuComponent);\n\n    QSharedPointer<MemoryMap> testMap = createMemoryMap(\"testMap\", mapComponent);\n    createBlockForMap(QString(\"testBlock\"), QString(\"0\"), QString(\"8\"), QString(\"16\"), testMap);\n\n    QSharedPointer<BusInterface> cpuBus = createMasterBusInterface(\"topBus\", testSpace, cpuComponent);\n    cpuBus->getMaster()->setBaseAddress(QString(\"10\"));\n    QSharedPointer<BusInterface> mapBus = createSlaveBusInterface(\"mapBus\", testMap, mapComponent);\n\n    QSharedPointer<BusInterface> mirrorSlaveBus =\n        createMirroredSlaveBusInterface(\"mirrorSlave\", \"1000\", \"100\", channelComponent);\n    QSharedPointer<BusInterface> mirrorMasterBus =\n        createMirroredMasterBusInterface(\"mirrorMaster\", channelComponent);\n\n    QSharedPointer<Channel> mirrorChannel =\n        createChannel(\"mirrorChannel\", channelComponent->getBusInterfaceNames(), channelComponent);\n\n    library_->addComponent(cpuComponent);\n    library_->addComponent(mapComponent);\n    library_->addComponent(channelComponent);\n\n    QSharedPointer<ComponentInstance> cpuInstance =\n        createComponentInstance(cpuVLNV, \"cpuInstance\", \"cpuID\", design_);\n    QSharedPointer<ComponentInstance> mapInstance =\n        createComponentInstance(mapVlnv, \"mapInstance\", \"mapID\", design_);\n    QSharedPointer<ComponentInstance> channelInstance =\n        createComponentInstance(channelVLNV, \"channelInstance\", \"channelID\", design_);\n\n    QSharedPointer<ActiveInterface> cpuInterface(\n        new ActiveInterface(cpuInstance->getInstanceName(), cpuBus->name()));\n    QSharedPointer<ActiveInterface> mapInterface(\n        new ActiveInterface(mapInstance->getInstanceName(), mapBus->name()));\n    QSharedPointer<ActiveInterface> mirrorSlaveInterface(\n        new ActiveInterface(channelInstance->getInstanceName(), mirrorSlaveBus->name()));\n    QSharedPointer<ActiveInterface> mirrorMasterInterface(\n        new ActiveInterface(channelInstance->getInstanceName(), mirrorMasterBus->name()));\n\n    createInterconnection(cpuInterface, mirrorMasterInterface, design_);\n    createInterconnection(mirrorSlaveInterface, mapInterface, design_);\n\n    QString output = runGenerator(hierarchicalView_->name());\n\n    QString expectedOutput =\n        \"/dts-v1/;\\n\\n\"\n        \"/ {\\n\"\n        \"\\t#address-cells = <1>;\\n\"\n        \"\\t#size-cells = <1>;\\n\"\n        \"\\tmodel = \\\"Test,TestDesign\\\";\\n\"\n        \"\\tcompatible = \\\"Test,TestDesign\\\";\\n\"\n        \"\\n\"\n            \"\\tcpus {\\n\"\n                \"\\t\\t#address-cells = <1>;\\n\"\n                \"\\t\\t#size-cells = <0>;\\n\\n\"\n                \"\\t\\t// 'testCPU' in component Test:TestLibrary:testCPU:1.0\\n\"\n                \"\\t\\tcpu@0 {\\n\"\n                    \"\\t\\t\\treg = <0>;\\n\"\n                \"\\t\\t};\\n\"\n            \"\\t};\\n\\n\"\n        \"\\t// Instance 'channelInstance' of channel component Test:TestLibrary:channelComponent:1.0\\n\"\n        \"\\tchannelComponent {\\n\"\n            \"\\t\\tcompatible = \\\"simple-bus\\\";\\n\"\n            \"\\t\\t#address-cells = <1>;\\n\"\n            \"\\t\\t#size-cells = <1>;\\n\"\n            \"\\n\"\n            \"\\t\\t// Memory map 'testMap' in instance 'mapInstance' of component Test:TestLibrary:MapComponent:1.0\\n\"\n                \"\\t\\ttestMap@3f2 {\\n\"\n                \"\\t\\t\\t#address-cells = <1>;\\n\"\n                \"\\t\\t\\t#size-cells = <1>;\\n\"\n                \"\\t\\t\\treg = <0x3f2 0x64>;\\n\"\n                \"\\t\\t};\\n\\n\"\n            \"\\t};\\n\\n\"\n        \"};\\n\\n\";\n\n    QCOMPARE(output, expectedOutput);\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_LinuxDeviceTreeGenerator::testCPUInMiddleOfPath()\n//-----------------------------------------------------------------------------\nvoid tst_LinuxDeviceTreeGenerator::testCPUInMiddleOfPath()\n{\n    //! First component: space, no CPU.\n    VLNV startVLNV(VLNV::COMPONENT, \"Test\", \"TestLibrary\", \"testStart\", \"1.0\");\n    QSharedPointer<Component> startComponent(new Component(startVLNV, Document::Revision::Std14));\n\n    QSharedPointer<AddressSpace> startSpace =\n        createAddressSpace(QStringLiteral(\"startSpace\"), \"8\", \"8\", startComponent);\n\n    QSharedPointer<BusInterface> startBus = createMasterBusInterface(\"startBus\", startSpace, startComponent);\n\n    //! Second component: bridged slave-master, space, CPU.\n    VLNV cpuVLNV(VLNV::COMPONENT, \"Test\", \"TestLibrary\", \"testCPU\", \"1.0\");\n\n    QSharedPointer<Component> cpuComponent(new Component(cpuVLNV, Document::Revision::Std14));\n\n    QSharedPointer<AddressSpace> testSpace =\n        createAddressSpace(QStringLiteral(\"testSpace\"), \"16\", \"16\", cpuComponent);\n\n    QSharedPointer<Cpu> testCPU = createCPU(\"testCPU\", testSpace->name(), cpuComponent);\n\n    QSharedPointer<BusInterface> bridgedCpuBus = createMasterBusInterface(\"topBus\", testSpace, cpuComponent);\n    QSharedPointer<BusInterface> bridgedSlaveBus =\n        createSlaveBusInterface(\"bridgeSlave\", QSharedPointer<MemoryMap>(), cpuComponent);\n\n    QSharedPointer<TransparentBridge> slaveCPUBridge(new TransparentBridge(bridgedCpuBus->name()));\n    bridgedSlaveBus->getSlave()->getBridges()->append(slaveCPUBridge);\n\n    //! Third component: slave map.\n    VLNV mapVlnv(VLNV::COMPONENT, \"Test\", \"TestLibrary\", \"MapComponent\", \"1.0\");\n    QSharedPointer<Component> mapComponent(new Component(mapVlnv, Document::Revision::Std14));\n\n    QSharedPointer<MemoryMap> testMap = createMemoryMap(\"testMap\", mapComponent);\n    createBlockForMap(QString(\"testBlock\"), QString(\"0\"), QString(\"16\"), QString(\"32\"), testMap);\n\n    QSharedPointer<BusInterface> mapBus = createSlaveBusInterface(\"mapBus\", testMap, mapComponent);\n\n    library_->addComponent(startComponent);\n    library_->addComponent(cpuComponent);\n    library_->addComponent(mapComponent);\n\n    QSharedPointer<ComponentInstance> startInstance =\n        createComponentInstance(startVLNV, \"startInstance\", \"startID\", design_);\n\n    QSharedPointer<ComponentInstance> cpuInstance =\n        createComponentInstance(cpuVLNV, \"cpuInstance\", \"cpuID\", design_);\n\n    QSharedPointer<ComponentInstance> mapInstance =\n        createComponentInstance(mapVlnv, \"mapInstance\", \"mapID\", design_);\n\n    QSharedPointer<ActiveInterface> startInterface(\n        new ActiveInterface(startInstance->getInstanceName(), startBus->name()));\n\n    QSharedPointer<ActiveInterface> bridgeSlaveInterface(\n        new ActiveInterface(cpuInstance->getInstanceName(), bridgedSlaveBus->name()));\n\n    QSharedPointer<ActiveInterface> cpuInterface(\n        new ActiveInterface(cpuInstance->getInstanceName(), bridgedCpuBus->name()));\n\n    QSharedPointer<ActiveInterface> mapInterface(\n        new ActiveInterface(mapInstance->getInstanceName(), mapBus->name()));\n\n    createInterconnection(startInterface, bridgeSlaveInterface, design_);\n    createInterconnection(cpuInterface, mapInterface, design_);\n\n    QString output = runGenerator(hierarchicalView_->name());\n\n    QString expectedOutput =\n        \"/dts-v1/;\\n\\n\"\n        \"/ {\\n\"\n        \"\\t#address-cells = <1>;\\n\"\n        \"\\t#size-cells = <1>;\\n\"\n        \"\\tmodel = \\\"Test,TestDesign\\\";\\n\"\n        \"\\tcompatible = \\\"Test,TestDesign\\\";\\n\"\n        \"\\n\"\n            \"\\tcpus {\\n\"\n                \"\\t\\t#address-cells = <1>;\\n\"\n                \"\\t\\t#size-cells = <0>;\\n\\n\"\n                \"\\t\\t// 'testCPU' in component Test:TestLibrary:testCPU:1.0\\n\"\n                \"\\t\\tcpu@0 {\\n\"\n                    \"\\t\\t\\treg = <0>;\\n\"\n                \"\\t\\t};\\n\"\n            \"\\t};\\n\\n\"\n            \"\\t// Memory map 'testMap' in instance 'mapInstance' of component Test:TestLibrary:MapComponent:1.0\\n\"\n            \"\\ttestMap@0 {\\n\"\n                \"\\t\\t#address-cells = <1>;\\n\"\n                \"\\t\\t#size-cells = <1>;\\n\"\n                \"\\t\\treg = <0x0 0x20>;\\n\"\n            \"\\t};\\n\\n\"\n        \"};\\n\\n\";\n\n    QCOMPARE(output, expectedOutput);\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_LinuxDeviceTreeGenerator::testBusPath()\n//-----------------------------------------------------------------------------\nvoid tst_LinuxDeviceTreeGenerator::testBusPath()\n{\n    VLNV cpuVLNV(VLNV::COMPONENT, QLatin1String(\"Test\"), QLatin1String(\"TestLibrary\"), QLatin1String(\"testCPU\"),\n        QLatin1String(\"1.0\"));\n    VLNV axiBusVLNV(VLNV::COMPONENT, QLatin1String(\"Test\"), QLatin1String(\"TestLibrary\"), QLatin1String(\"axe\"),\n        QLatin1String(\"1.0\"));\n    VLNV periphBusVLNV(VLNV::COMPONENT, QLatin1String(\"Test\"), QLatin1String(\"TestLibrary\"),\n        QLatin1String(\"periph_bus_wrap\"), QLatin1String(\"1.0\"));\n    VLNV mapVlnv(VLNV::COMPONENT, QLatin1String(\"Test\"), QLatin1String(\"TestLibrary\"),\n        QLatin1String(\"MapComponent\"), QLatin1String(\"1.0\"));\n\n    QSharedPointer<Component> cpuComponent(new Component(cpuVLNV, Document::Revision::Std14));\n    QSharedPointer<Component> axiComponent(new Component(axiBusVLNV, Document::Revision::Std14));\n    QSharedPointer<Component> periphBusComponent(new Component(periphBusVLNV, Document::Revision::Std14));\n    QSharedPointer<Component> mapComponent(new Component(mapVlnv, Document::Revision::Std14));\n\n    library_->addComponent(cpuComponent);\n    library_->addComponent(axiComponent);\n    library_->addComponent(periphBusComponent);\n    library_->addComponent(mapComponent);\n\n    QSharedPointer<AddressSpace> testSpace =\n        createAddressSpace(QLatin1String(\"testSpace\"), QLatin1String(\"16\"), QLatin1String(\"16\"), cpuComponent);\n    QSharedPointer<Cpu> testCPU = createCPU(QLatin1String(\"testCPU\"), testSpace->name(), cpuComponent);\n    QSharedPointer<BusInterface> cpuBus =\n        createMasterBusInterface(QLatin1String(\"topBus\"), testSpace, cpuComponent);\n\n    QSharedPointer<BusInterface> axiMaster =\n        createMasterBusInterface(QLatin1String(\"axiMaster\"), QSharedPointer<AddressSpace>(), axiComponent);\n    QSharedPointer<BusInterface> axiSlave =\n        createSlaveBusInterface(QLatin1String(\"axiSlave\"), QSharedPointer<MemoryMap>(), axiComponent);\n    QSharedPointer<TransparentBridge> axiSlaveBridge(new TransparentBridge(axiMaster->name()));\n    axiSlave->getSlave()->getBridges()->append(axiSlaveBridge);\n\n    QSharedPointer<BusInterface> wrapMaster =\n        createMasterBusInterface(QLatin1String(\"wrapMaster\"), QSharedPointer<AddressSpace>(), periphBusComponent);\n    QSharedPointer<BusInterface> wrapSlave =\n        createSlaveBusInterface(QLatin1String(\"wrapSlave\"), QSharedPointer<MemoryMap>(), periphBusComponent);\n    QSharedPointer<TransparentBridge> wrapBridge(new TransparentBridge(wrapMaster->name()));\n    wrapSlave->getSlave()->getBridges()->append(wrapBridge);\n\n    QSharedPointer<MemoryMap> testMap = createMemoryMap(\"testMap\", mapComponent);\n    QSharedPointer<BusInterface> mapBus = createSlaveBusInterface(\"mapBus\", testMap, mapComponent);\n\n    QSharedPointer<ComponentInstance> cpuInstance =\n        createComponentInstance(cpuVLNV, \"cpuInstance\", \"cpuID\", design_);\n    QSharedPointer<ComponentInstance> axiInstance =\n        createComponentInstance(axiBusVLNV, \"axiInstance\", \"axiID\", design_);\n    QSharedPointer<ComponentInstance> wrapInstance =\n        createComponentInstance(periphBusVLNV, \"wrapInstance\", \"wrapID\", design_);\n    QSharedPointer<ComponentInstance> mapInstance =\n        createComponentInstance(mapVlnv, \"mapInstance_0\", \"mapID\", design_);\n    QSharedPointer<ComponentInstance> secondMapInstance =\n        createComponentInstance(mapVlnv, \"mapInstance_1\", \"mapID\", design_);\n\n    QSharedPointer<ActiveInterface> cpuInterface(\n        new ActiveInterface(cpuInstance->getInstanceName(), cpuBus->name()));\n    QSharedPointer<ActiveInterface> axiMasterInterface(\n        new ActiveInterface(axiInstance->getInstanceName(), axiMaster->name()));\n    QSharedPointer<ActiveInterface> axiSlaveInterface(\n        new ActiveInterface(axiInstance->getInstanceName(), axiSlave->name()));\n    QSharedPointer<ActiveInterface> wrapMasterInterface(\n        new ActiveInterface(wrapInstance->getInstanceName(), wrapMaster->name()));\n    QSharedPointer<ActiveInterface> wrapSlaveInterface(\n        new ActiveInterface(wrapInstance->getInstanceName(), wrapSlave->name()));\n    QSharedPointer<ActiveInterface> mapInterface(\n        new ActiveInterface(mapInstance->getInstanceName(), mapBus->name()));\n    QSharedPointer<ActiveInterface> secondMapInterface(\n        new ActiveInterface(secondMapInstance->getInstanceName(), mapBus->name()));\n\n    createInterconnection(cpuInterface, axiSlaveInterface, design_);\n    createInterconnection(axiMasterInterface, wrapSlaveInterface, design_);\n    createInterconnection(wrapMasterInterface, mapInterface, design_);\n    createInterconnection(wrapMasterInterface, secondMapInterface, design_);\n\n    QString output = runGenerator(hierarchicalView_->name());\n\n    QString expectedOutput =\n        \"/dts-v1/;\\n\\n\"\n        \"/ {\\n\"\n        \"\\t#address-cells = <1>;\\n\"\n        \"\\t#size-cells = <1>;\\n\"\n        \"\\tmodel = \\\"Test,TestDesign\\\";\\n\"\n        \"\\tcompatible = \\\"Test,TestDesign\\\";\\n\"\n        \"\\n\"\n            \"\\tcpus {\\n\"\n                \"\\t\\t#address-cells = <1>;\\n\"\n                \"\\t\\t#size-cells = <0>;\\n\\n\"\n                \"\\t\\t// 'testCPU' in component Test:TestLibrary:testCPU:1.0\\n\"\n                \"\\t\\tcpu@0 {\\n\"\n                    \"\\t\\t\\treg = <0>;\\n\"\n                \"\\t\\t};\\n\"\n            \"\\t};\\n\"\n            \"\\n\"\n            \"\\t// Instance 'axiInstance' of bridge component Test:TestLibrary:axe:1.0\\n\"\n            \"\\taxe {\\n\"\n                \"\\t\\tcompatible = \\\"simple-bus\\\";\\n\"\n                \"\\t\\t#address-cells = <1>;\\n\"\n                \"\\t\\t#size-cells = <1>;\\n\"\n                \"\\n\"\n                \"\\t\\t// Instance 'wrapInstance' of bridge component Test:TestLibrary:periph_bus_wrap:1.0\\n\"\n                \"\\t\\tperiph_bus_wrap {\\n\"\n                    \"\\t\\t\\tcompatible = \\\"simple-bus\\\";\\n\"\n                    \"\\t\\t\\t#address-cells = <1>;\\n\"\n                    \"\\t\\t\\t#size-cells = <1>;\\n\"\n                    \"\\n\"\n                    \"\\t\\t\\t// Memory map 'testMap' in instance 'mapInstance_0' of component Test:TestLibrary:MapComponent:1.0\\n\"\n                    \"\\t\\t\\ttestMap@0 {\\n\"\n                        \"\\t\\t\\t\\t#address-cells = <1>;\\n\"\n                        \"\\t\\t\\t\\t#size-cells = <1>;\\n\"\n                        \"\\t\\t\\t\\treg = <0x0 0x1>;\\n\"\n                    \"\\t\\t\\t};\\n\"\n                    \"\\n\"\n                    \"\\t\\t\\t// Memory map 'testMap' in instance 'mapInstance_1' of component Test:TestLibrary:MapComponent:1.0\\n\"\n                    \"\\t\\t\\ttestMap@0 {\\n\"\n                        \"\\t\\t\\t\\t#address-cells = <1>;\\n\"\n                        \"\\t\\t\\t\\t#size-cells = <1>;\\n\"\n                        \"\\t\\t\\t\\treg = <0x0 0x1>;\\n\"\n                    \"\\t\\t\\t};\\n\"\n                    \"\\n\"\n                \"\\t\\t};\\n\"\n                \"\\n\"\n            \"\\t};\\n\"\n            \"\\n\"\n        \"};\\n\\n\";\n\n    QCOMPARE(output, expectedOutput);\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_LinuxDeviceTreeGenerator::testHierarchicalPath()\n//-----------------------------------------------------------------------------\nvoid tst_LinuxDeviceTreeGenerator::testHierarchicalPath()\n{\n    VLNV middleComponentVLNV(VLNV::COMPONENT, \"Test\", \"TestLibrary\", \"hierarchicalComponent\", \"1.0\");\n    QSharedPointer<Component> middleComponent = QSharedPointer<Component>(new Component(middleComponentVLNV, \n        Document::Revision::Std14));\n\n    VLNV middleDesignVLNV(VLNV::DESIGN, \"Test\", \"TestLibrary\", \"hierarchicalDesign\", \"1.0\");\n    QSharedPointer<Design> middleDesign = QSharedPointer<Design>(new Design(middleDesignVLNV, Document::Revision::Std14));\n\n    library_->addComponent(middleDesign);\n    library_->addComponent(middleComponent);\n\n    QSharedPointer<View> middleView = QSharedPointer<View>(new View(\"hierarchical\"));\n    middleView->setDesignInstantiationRef(\"design\");\n    middleComponent->getViews()->append(middleView);\n\n    QSharedPointer<DesignInstantiation> middleDesignInstantiation(new DesignInstantiation(\"design\"));\n    middleDesignInstantiation->setDesignReference(QSharedPointer<ConfigurableVLNVReference>(\n        new ConfigurableVLNVReference(middleDesign->getVlnv())));\n    middleComponent->getDesignInstantiations()->append(middleDesignInstantiation);\n\n    QSharedPointer<AddressSpace> middleSpace =\n        createAddressSpace(QStringLiteral(\"middleSpace\"), \"0\", \"0\", middleComponent);\n\n    QSharedPointer<BusInterface> middleBus = createMasterBusInterface(\"middleBus\", middleSpace, middleComponent);\n\n    VLNV cpuVLNV(VLNV::COMPONENT, \"Test\", \"TestLibrary\", \"testCPU\", \"1.0\");\n    QSharedPointer<Component> cpuComponent(new Component(cpuVLNV, Document::Revision::Std14));\n\n    QSharedPointer<AddressSpace> testSpace =\n        createAddressSpace(QStringLiteral(\"testSpace\"), \"16\", \"16\", cpuComponent);\n    QSharedPointer<Cpu> testCPU = createCPU(\"testCPU\", testSpace->name(), cpuComponent);\n\n    QSharedPointer<BusInterface> cpuBus = createMasterBusInterface(\"cpuBus\", testSpace, cpuComponent);\n\n    VLNV mapVlnv(VLNV::COMPONENT, \"Test\", \"TestLibrary\", \"MapComponent\", \"1.0\");\n    QSharedPointer<Component> mapComponent(new Component(mapVlnv, Document::Revision::Std14));\n\n    library_->addComponent(cpuComponent);\n    library_->addComponent(mapComponent);\n\n    QSharedPointer<MemoryMap> testMap = createMemoryMap(\"testMap\", mapComponent);\n    QSharedPointer<BusInterface> mapBus = createSlaveBusInterface(\"mapBus\", testMap, mapComponent);\n\n    QSharedPointer<ComponentInstance> cpuInstance =\n        createComponentInstance(cpuVLNV, \"cpuInstance\", \"cpuID\", middleDesign);\n    QSharedPointer<ComponentInstance> middleIInstance =\n        createComponentInstance(middleComponentVLNV, \"middleInstance\", \"middleID\", design_);\n    QSharedPointer<ComponentInstance> mapInstance =\n        createComponentInstance(mapVlnv, \"mapInstance\", \"mapID\", design_);\n\n    QSharedPointer<ActiveInterface> middleInterface(\n        new ActiveInterface(middleIInstance->getInstanceName(), middleBus->name()));\n    QSharedPointer<ActiveInterface> cpuInterface(\n        new ActiveInterface(cpuInstance->getInstanceName(), cpuBus->name()));\n    QSharedPointer<ActiveInterface> mapInterface(\n        new ActiveInterface(mapInstance->getInstanceName(), mapBus->name()));\n\n    createHierarchicalConnection(middleInterface, cpuInterface, middleDesign);\n    createInterconnection(middleInterface, mapInterface, design_);\n\n    QString output = runGenerator(hierarchicalView_->name());\n\n    QString expectedOutput =\n        \"/dts-v1/;\\n\\n\"\n        \"/ {\\n\"\n        \"\\t#address-cells = <1>;\\n\"\n        \"\\t#size-cells = <1>;\\n\"\n        \"\\tmodel = \\\"Test,TestDesign\\\";\\n\"\n        \"\\tcompatible = \\\"Test,TestDesign\\\";\\n\"\n        \"\\n\"\n            \"\\tcpus {\\n\"\n                \"\\t\\t#address-cells = <1>;\\n\"\n                \"\\t\\t#size-cells = <0>;\\n\\n\"\n                \"\\t\\t// 'testCPU' in component Test:TestLibrary:testCPU:1.0\\n\"\n                \"\\t\\tcpu@0 {\\n\"\n                    \"\\t\\t\\treg = <0>;\\n\"\n                \"\\t\\t};\\n\"\n            \"\\t};\\n\\n\"\n            \"\\t// Memory map 'testMap' in instance 'mapInstance' of component Test:TestLibrary:MapComponent:1.0\\n\"\n            \"\\ttestMap@0 {\\n\"\n                \"\\t\\t#address-cells = <1>;\\n\"\n                \"\\t\\t#size-cells = <1>;\\n\"\n                \"\\t\\treg = <0x0 0x1>;\\n\"\n            \"\\t};\\n\\n\"\n        \"};\\n\\n\";\n\n    QCOMPARE(output, expectedOutput);\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_LinuxDeviceTreeGenerator::testMemoryInAddressBlock()\n//-----------------------------------------------------------------------------\nvoid tst_LinuxDeviceTreeGenerator::testMemoryInAddressBlock()\n{\n    VLNV cpuVLNV(VLNV::COMPONENT, \"Test\", \"TestLibrary\", \"testCPU\", \"1.0\");\n    QSharedPointer<Component> cpuComponent(new Component(cpuVLNV, Document::Revision::Std14));\n\n    QSharedPointer<AddressSpace> testSpace =\n        createAddressSpace(QStringLiteral(\"testSpace\"), \"16\", \"16\", cpuComponent);\n    QSharedPointer<Cpu> testCPU = createCPU(\"testCPU\", testSpace->name(), cpuComponent);\n\n    QSharedPointer<BusInterface> cpuBus = createMasterBusInterface(\"topBus\", testSpace, cpuComponent);\n\n    VLNV mapVlnv(VLNV::COMPONENT, \"Test\", \"TestLibrary\", \"MapComponent\", \"1.0\");\n    QSharedPointer<Component> mapComponent(new Component(mapVlnv, Document::Revision::Std14));\n\n    library_->addComponent(cpuComponent);\n    library_->addComponent(mapComponent);\n\n    QSharedPointer<MemoryMap> testMap = createMemoryMap(\"testMap\", mapComponent);\n    createBlockForMap(\"testBlock\", \"0\", \"32\", \"8\", testMap);\n    testMap->getMemoryBlocks()->first().dynamicCast<AddressBlock>()->setUsage(General::MEMORY);\n    createBlockForMap(\"extraBlock\", \"8\", \"32\", \"8\", testMap);\n\n    QSharedPointer<BusInterface> mapBus = createSlaveBusInterface(\"mapBus\", testMap, mapComponent);\n\n    QSharedPointer<ComponentInstance> cpuInstance =\n        createComponentInstance(cpuVLNV, \"cpuInstance\", \"cpuID\", design_);\n    QSharedPointer<ComponentInstance> mapInstance =\n        createComponentInstance(mapVlnv, \"mapInstance\", \"mapID\", design_);\n\n    QSharedPointer<ActiveInterface> cpuInterface(\n        new ActiveInterface(cpuInstance->getInstanceName(), cpuBus->name()));\n    QSharedPointer<ActiveInterface> mapInterface(\n        new ActiveInterface(mapInstance->getInstanceName(), mapBus->name()));\n\n    createInterconnection(cpuInterface, mapInterface, design_);\n\n    QString output = runGenerator(hierarchicalView_->name(), true);\n\n    QString expectedOutput =\n        \"/dts-v1/;\\n\\n\"\n        \"/ {\\n\"\n        \"\\t#address-cells = <1>;\\n\"\n        \"\\t#size-cells = <1>;\\n\"\n        \"\\tmodel = \\\"Test,TestDesign\\\";\\n\"\n        \"\\tcompatible = \\\"Test,TestDesign\\\";\\n\"\n        \"\\n\"\n        \"\\tcpus {\\n\"\n        \"\\t\\t#address-cells = <1>;\\n\"\n        \"\\t\\t#size-cells = <0>;\\n\\n\"\n        \"\\t\\t// 'testCPU' in component Test:TestLibrary:testCPU:1.0\\n\"\n        \"\\t\\tcpu@0 {\\n\"\n        \"\\t\\t\\treg = <0>;\\n\"\n        \"\\t\\t};\\n\"\n        \"\\t};\\n\\n\"\n        \"\\t// Memory map 'testMap' in instance 'mapInstance' of component Test:TestLibrary:MapComponent:1.0\\n\"\n        \"\\ttestMap@0 {\\n\"\n        \"\\t\\t#address-cells = <1>;\\n\"\n        \"\\t\\t#size-cells = <1>;\\n\"\n        \"\\t\\treg = <0x0 0x10>;\\n\"\n        \"\\n\"\n        \"\\t\\t// Address block 'testBlock'\\n\"\n        \"\\t\\ttestBlock@0 {\\n\"\n        \"\\t\\t\\tcompatible = \\\"Test,testBlock\\\";\\n\"\n        \"\\t\\t\\tstatus = \\\"okay\\\";\\n\"       \n        \"\\t\\t\\tdevice_type = \\\"memory\\\";\\n\"\n        \"\\t\\t};\\n\\n\"\n        \"\\t\\t// Address block 'extraBlock'\\n\"\n        \"\\t\\textraBlock@8 {\\n\"\n        \"\\t\\t\\tcompatible = \\\"Test,extraBlock\\\";\\n\"\n        \"\\t\\t\\tstatus = \\\"okay\\\";\\n\"\n        \"\\t\\t};\\n\"\n        \"\\t};\\n\\n\"\n        \"};\\n\\n\";\n\n    QCOMPARE(output, expectedOutput);\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_LinuxDeviceTreeGenerator::runGenerator()\n//-----------------------------------------------------------------------------\nQString tst_LinuxDeviceTreeGenerator::runGenerator(QString const& activeView, bool generateAddressBlocks)\n{\n    LinuxDeviceTreeGenerator generator(library_);\n    QString outPutFileName = \"TopComponent_0.dts\";\n\n    auto cpuContainers = LinuxDeviceTreeCPUDetails::getCPUContainers(topComponent_->getVlnv().getName(),\n        topComponent_, activeView, library_);\n\n    generator.generate(topComponent_, activeView, generateAddressBlocks, cpuContainers, \"./\");\n\n    return getFileContent(outPutFileName);\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_LinuxDeviceTreeGenerator::getFileContent()\n//-----------------------------------------------------------------------------\nQString tst_LinuxDeviceTreeGenerator::getFileContent(QString const& fileName)\n{\n    QFile outputFile(\"./\" + fileName);\n\n    outputFile.open(QIODevice::ReadOnly);\n    QString output = outputFile.readAll();\n    outputFile.close();\n\n    return output;\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_LinuxDeviceTreeGenerator::createAddressSpace()\n//-----------------------------------------------------------------------------\nQSharedPointer<AddressSpace> tst_LinuxDeviceTreeGenerator::createAddressSpace(QString const& spaceName,\n    QString const& range, QString const& width, QSharedPointer<Component> containingComponent) const\n{\n    QSharedPointer<AddressSpace> newSpace(new AddressSpace(spaceName, range, width));\n\n    containingComponent->getAddressSpaces()->append(newSpace);\n\n    return newSpace;\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_LinuxDeviceTreeGenerator::createCPU()\n//-----------------------------------------------------------------------------\nQSharedPointer<Cpu> tst_LinuxDeviceTreeGenerator::createCPU(QString const& cpuName, QString const& spaceReference,\n    QSharedPointer<Component> containingComponent) const\n{\n    QSharedPointer<Cpu> newCPU(new Cpu(cpuName));\n\n    QSharedPointer<Cpu::AddressSpaceRef> newSpaceReference(new Cpu::AddressSpaceRef(spaceReference));\n    newCPU->getAddressSpaceReferences()->append(newSpaceReference);\n\n    containingComponent->getCpus()->append(newCPU);\n\n    return newCPU;\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_LinuxDeviceTreeGenerator::createMasterBusInterface()\n//-----------------------------------------------------------------------------\nQSharedPointer<BusInterface> tst_LinuxDeviceTreeGenerator::createMasterBusInterface(QString const& busName,\n    QSharedPointer<AddressSpace> referencedSpace, QSharedPointer<Component> containingComponent) const\n{\n    QSharedPointer<BusInterface> newMasterBus = createBusInterface(busName, General::MASTER, containingComponent);\n\n    if (referencedSpace)\n    {\n        QSharedPointer<InitiatorInterface> newMasterInterface(new InitiatorInterface());\n        newMasterInterface->setAddressSpaceRef(referencedSpace->name());\n        newMasterBus->setMaster(newMasterInterface);\n    }\n\n    return newMasterBus;\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_LinuxDeviceTreeGenerator::createSlaveBusInterface()\n//-----------------------------------------------------------------------------\nQSharedPointer<BusInterface> tst_LinuxDeviceTreeGenerator::createSlaveBusInterface(QString const& busName,\n    QSharedPointer<MemoryMap> referencedMap, QSharedPointer<Component> containingComponent) const\n{\n    QSharedPointer<BusInterface> newSlaveBus = createBusInterface(busName, General::SLAVE, containingComponent);\n\n    QSharedPointer<TargetInterface> newSlaveInterface(new TargetInterface());\n\n    if (referencedMap)\n    {\n        newSlaveInterface->setMemoryMapRef(referencedMap->name());\n    }\n\n    newSlaveBus->setSlave(newSlaveInterface);\n\n    return newSlaveBus;\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_LinuxDeviceTreeGenerator::createMirroredSlaveBusInterface()\n//-----------------------------------------------------------------------------\nQSharedPointer<BusInterface> tst_LinuxDeviceTreeGenerator::createMirroredSlaveBusInterface(QString const& busName,\n    QString const& remapAddress, QString const& remapRange, QSharedPointer<Component> containingComponent) const\n{\n    QSharedPointer<BusInterface> newMirrorSlaveBus =\n        createBusInterface(busName, General::MIRRORED_SLAVE, containingComponent);\n\n    QSharedPointer<MirroredTargetInterface> newMirrorSlaveInterface(new MirroredTargetInterface());\n    newMirrorSlaveInterface->setRange(remapRange);\n    newMirrorSlaveInterface->setRemapAddress(remapAddress);\n\n    newMirrorSlaveBus->setMirroredSlave(newMirrorSlaveInterface);\n\n    return newMirrorSlaveBus;\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_LinuxDeviceTreeGenerator::createMirroredMasterBusInterface()\n//-----------------------------------------------------------------------------\nQSharedPointer<BusInterface> tst_LinuxDeviceTreeGenerator::createMirroredMasterBusInterface(QString const& busName,\n    QSharedPointer<Component> containingComponent) const\n{\n    QSharedPointer<BusInterface> newMirrorMasterBus =\n        createBusInterface(busName, General::MIRRORED_MASTER, containingComponent);\n\n    return newMirrorMasterBus;\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_LinuxDeviceTreeGenerator::createBusInterface()\n//-----------------------------------------------------------------------------\nQSharedPointer<BusInterface> tst_LinuxDeviceTreeGenerator::createBusInterface(QString const& busName,\n    General::InterfaceMode mode, QSharedPointer<Component> containingComponent) const\n{\n    QSharedPointer<BusInterface> newBus(new BusInterface());\n    newBus->setName(busName);\n    newBus->setInterfaceMode(mode);\n\n    containingComponent->getBusInterfaces()->append(newBus);\n\n    return newBus;\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_LinuxDeviceTreeGenerator::createChannel()\n//-----------------------------------------------------------------------------\nQSharedPointer<Channel> tst_LinuxDeviceTreeGenerator::createChannel(QString const& channelName,\n    QStringList const& channeledInterfaces, QSharedPointer<Component> containingComponent) const\n{\n    QSharedPointer<Channel> newChannel(new Channel());\n    newChannel->setName(channelName);\n    newChannel->setInterfaces(channeledInterfaces);\n\n    containingComponent->getChannels()->append(newChannel);\n    return newChannel;\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_LinuxDeviceTreeGenerator::createMemoryMap()\n//-----------------------------------------------------------------------------\nQSharedPointer<MemoryMap> tst_LinuxDeviceTreeGenerator::createMemoryMap(QString const& mapName,\n    QSharedPointer<Component> containingComponent) const\n{\n    QSharedPointer<MemoryMap> newMap(new MemoryMap(mapName));\n\n    containingComponent->getMemoryMaps()->append(newMap);\n\n    return newMap;\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_LinuxDeviceTreeGenerator::createBlockForMap()\n//-----------------------------------------------------------------------------\nvoid tst_LinuxDeviceTreeGenerator::createBlockForMap(QString const& blockName, QString const& blockBaseAddress,\n    QString const& blockWidth, QString const& blockRange, QSharedPointer<MemoryMap> targetMap)\n{\n    QSharedPointer<AddressBlock> newBlock(new AddressBlock(blockName));\n    newBlock->setBaseAddress(blockBaseAddress);\n    newBlock->setWidth(blockWidth);\n    newBlock->setRange(blockRange);\n\n    targetMap->getMemoryBlocks()->append(newBlock);\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_LinuxDeviceTreeGenerator::createComponentInstance()\n//-----------------------------------------------------------------------------\nQSharedPointer<ComponentInstance> tst_LinuxDeviceTreeGenerator::createComponentInstance(VLNV const& vlnv,\n    QString const& name, QString const& id, QSharedPointer<Design> design) const\n{\n    QSharedPointer<ConfigurableVLNVReference> vlnvReference(new ConfigurableVLNVReference(vlnv));\n\n    QSharedPointer<ComponentInstance> newInstance(new ComponentInstance(name, vlnvReference));\n    newInstance->setUuid(id);\n\n    design->getComponentInstances()->append(newInstance);\n\n    return newInstance;\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_LinuxDeviceTreeGenerator::createInterconnection()\n//-----------------------------------------------------------------------------\nvoid tst_LinuxDeviceTreeGenerator::createInterconnection(QSharedPointer<ActiveInterface> startInterface,\n    QSharedPointer<ActiveInterface> endInterface, QSharedPointer<Design> design)\n{\n    QSharedPointer<Interconnection> newConnection(new Interconnection());\n    \n    newConnection->setStartInterface(startInterface);\n    newConnection->getActiveInterfaces()->append(endInterface);\n    \n    design->getInterconnections()->append(newConnection);\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_LinuxDeviceTreeGenerator::createHierarchicalConnection()\n//-----------------------------------------------------------------------------\nvoid tst_LinuxDeviceTreeGenerator::createHierarchicalConnection(QSharedPointer<HierInterface> startInterface,\n    QSharedPointer<ActiveInterface> endInterface, QSharedPointer<Design> design)\n{\n    QSharedPointer<Interconnection> newConnection(new Interconnection());\n\n    newConnection->setStartInterface(endInterface);\n    newConnection->getHierInterfaces()->append(startInterface);\n\n    design->getInterconnections()->append(newConnection);\n}\n\nQTEST_APPLESS_MAIN(tst_LinuxDeviceTreeGenerator)\n\n#include \"tst_LinuxDeviceTreeGenerator.moc\"\n"
  },
  {
    "path": "tests/Plugins/LinuxDeviceTreeGenerator/tst_LinuxDeviceTreeGenerator.pri",
    "content": "# ----------------------------------------------------\n# This file is generated by the Qt Visual Studio Tools.\n# ------------------------------------------------------\n\n# This is a reminder that you are using a generated .pro file.\n# Remove it when you are finished editing this file.\nmessage(\"You are running qmake on a generated .pro file. This may not work!\")\n\n\nHEADERS += ../../../editors/MemoryDesigner/ConnectivityComponent.h \\\n    ../../../editors/MemoryDesigner/ConnectivityConnection.h \\\n    ../../../editors/MemoryDesigner/ConnectivityGraph.h \\\n    ../../../editors/MemoryDesigner/ConnectivityGraphFactory.h \\\n    ../../../editors/MemoryDesigner/ConnectivityInterface.h \\\n    ../../../Plugins/LinuxDeviceTree/LinuxDeviceTreeGenerator.h \\\n    ../../../Plugins/LinuxDeviceTree/LinuxDeviceTreeGenerator_global.h \\\n    ../../../editors/MemoryDesigner/MasterSlavePathSearch.h \\\n    ../../../editors/MemoryDesigner/MemoryConnectionAddressCalculator.h \\\n    ../../../editors/MemoryDesigner/MemoryDesignerConstants.h \\\n    ../../../editors/MemoryDesigner/MemoryItem.h \\\n    ../../MockObjects/LibraryMock.h \\\n    ../../../Plugins/common/CpuRoutesContainer.h \\\n    ../../../Plugins/common/SingleCpuRoutesContainer.h \\\n    ../../../Plugins/common/ConnectivityGraphUtilities.h \\\n    ../../../Plugins/LinuxDeviceTree/CPUSelection/LinuxDeviceTreeCpuRoutesContainer.h \\\n    ../../../Plugins/LinuxDeviceTree/CPUSelection/LinuxDeviceTreeCPUDetails.h\nSOURCES += ../../../editors/MemoryDesigner/ConnectivityComponent.cpp \\\n    ../../../editors/MemoryDesigner/ConnectivityConnection.cpp \\\n    ../../../editors/MemoryDesigner/ConnectivityGraph.cpp \\\n    ../../../editors/MemoryDesigner/ConnectivityGraphFactory.cpp \\\n    ../../../editors/MemoryDesigner/ConnectivityInterface.cpp \\\n    ../../MockObjects/LibraryMock.cpp \\\n    ../../../Plugins/common/CpuRoutesContainer.cpp \\\n    ../../../Plugins/common/SingleCpuRoutesContainer.cpp \\\n    ../../../Plugins/common/ConnectivityGraphUtilities.cpp \\\n    ../../../Plugins/LinuxDeviceTree/LinuxDeviceTreeGenerator.cpp \\\n    ../../../editors/MemoryDesigner/MasterSlavePathSearch.cpp \\\n    ../../../editors/MemoryDesigner/MemoryConnectionAddressCalculator.cpp \\\n    ../../../editors/MemoryDesigner/MemoryDesignerConstants.cpp \\\n    ../../../editors/MemoryDesigner/MemoryItem.cpp \\\n    ./tst_LinuxDeviceTreeGenerator.cpp \\\n    ../../../Plugins/LinuxDeviceTree/CPUSelection/LinuxDeviceTreeCpuRoutesContainer.cpp \\\n    ../../../Plugins/LinuxDeviceTree/CPUSelection/LinuxDeviceTreeCPUDetails.cpp\n"
  },
  {
    "path": "tests/Plugins/LinuxDeviceTreeGenerator/tst_LinuxDeviceTreeGenerator.pro",
    "content": "#-----------------------------------------------------------------------------\n# File: tst_LinuxDeviceTreeGenerator.pro\n#-----------------------------------------------------------------------------\n# Project: Kactus 2\n# Author: Mikko Teuho\n# Date: 08.05.2018\n#\n# Description:\n# Qt project file template for running unit tests for a LinuxDeviceTreeGenerator.\n#-----------------------------------------------------------------------------\n\nTEMPLATE = app\n\nTARGET = tst_LinuxDeviceTreeGenerator\n\nQT += core xml gui testlib widgets\nCONFIG += c++11 testcase console\n\nDEFINES += LINUXDEVICETREEGENERATOR_LIB\n\nwin32:CONFIG(release, debug|release) {\n    LIBS += -L$$PWD/../../../executable/ -lIPXACTmodels\n    LIBS += -L$$PWD/../../../executable/ -lKactusAPI\n    DESTDIR = ./release\n}\nelse:win32:CONFIG(debug, debug|release) {\n    LIBS += -L$$PWD/../../../executable/ -lIPXACTmodelsd\n    LIBS += -L$$PWD/../../../executable/ -lKactusAPId\n    DESTDIR = ./debug\n}\nelse:unix {\n    LIBS += -L$$PWD/../../../executable/ -lIPXACTmodels\n    LIBS += -L$$PWD/../../../executable/ -lKactusAPI\n    DESTDIR = ./release\n}\n\nINCLUDEPATH += $$PWD/../../../\nINCLUDEPATH += $$PWD/../../../executable\nINCLUDEPATH += $$DESTDIR\n\nDEPENDPATH += $$PWD/../../../\nDEPENDPATH += $$PWD/../../../executable\nDEPENDPATH += .\n\nOBJECTS_DIR += $$DESTDIR\n\nMOC_DIR += ./generatedFiles\nUI_DIR += ./generatedFiles\nRCC_DIR += ./generatedFiles\ninclude(tst_LinuxDeviceTreeGenerator.pri)\n"
  },
  {
    "path": "tests/Plugins/MakefileGenerator/tst_MakefileGenerator.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: tst_MakefileGenerator.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Janne Virtanen\r\n// Date: 02.09.2014\r\n//\r\n// Description:\r\n// Unit test for classes MakefileParser and MakefileGenerator.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include <QtTest>\r\n\r\n#include <IPXACTmodels/kactusExtensions/SystemView.h>\r\n#include <IPXACTmodels/kactusExtensions/ApiInterface.h>\r\n\r\n#include <tests/MockObjects/LibraryMock.h>\r\n\r\n#include <Plugins/MakefileGenerator/SWStackParser.h>\r\n#include <Plugins/MakefileGenerator/MakefileParser.h>\r\n#include <Plugins/MakefileGenerator/MakefileGenerator.h>\r\n#include <Plugins/PluginSystem/GeneratorPlugin/MessagePasser.h>\r\n#include <KactusAPI/include/PluginUtilityAdapter.h>\r\n#include <common/NameGenerationPolicy.h>\r\n\r\n#include <QRegularExpression>\r\n\r\nclass tst_MakefileGenerator : public QObject\r\n{\r\n    Q_OBJECT\r\n\r\npublic:\r\n    tst_MakefileGenerator();\r\n\r\nprivate slots:\r\n\r\n    void cleanupTestCase();\r\n\r\n    void baseCase();\r\n\r\n\t// Overrides.\r\n    void fileBuildOverride();\r\n    void fileSetBuildOverride();\r\n    void fileFlagReplace();\r\n    void fileSetFlagReplace();\r\n    void swSWViewFlagReplace();\r\n\r\n\t// Hardware and references.\r\n    void hwBuilder();\r\n    void hwBuilderWithNosoftInsta();\r\n    void hwRef();\r\n    void hwandswRef();\r\n    void instanceFiles();\r\n\r\n\t// Multiple things.\r\n    void multipleFiles();\r\n    void multipleFileSets();\r\n    void multipleComponents();\r\n    void multipleHardWare();\r\n\tvoid multipleHardWareMedRefs();\r\n\tvoid multipleInstances();\r\n\r\n\t// Missing things.\r\n\tvoid noHardWare();\r\n\tvoid noFilesComponent();\r\n\tvoid noFileType();\r\n\r\n\t// API usage.\r\n    void apiUsage();\r\n    void threeLevelStack();\r\n    void fullCircularapiUsage();\r\n\tvoid circularapiUsage();\r\n\r\n\t// Conflicts.\r\n\tvoid sameFile();\r\n\tvoid sameFileSeparateExe();\r\n\tvoid sameFileDiffCompiler();\r\n\tvoid sameFileDiffFlags();\r\n\r\n\t// Generation.\r\n\tvoid basicGeneration();\r\n\tvoid multiObjectGeneration();\r\n\tvoid multiFileGeneration();\r\n\tvoid noCompiler();\r\n\tvoid allTheWay();\r\n\r\nprivate:\r\n    void getFile(QSharedPointer<File>& file, QSharedPointer<Component> component, QString fileName);\r\n\r\n    QSharedPointer<Component> createSW(QString swName, QString hwInstanceName, QSharedPointer<Design> design, QString softInstaName,\r\n\t\t QSharedPointer<DesignConfiguration> desgconf, QSharedPointer<ComponentInstantiation>& softInsta, QString ComponentInstanceName);\r\n\r\n    QSharedPointer<FileSet> addFileSet(QSharedPointer<Component> component, QString fileSetName, QSharedPointer<ComponentInstantiation> insta);\r\n\r\n    QSharedPointer<File> addFileToSet(QSharedPointer<FileSet> fileSet, QString fileName, QString fileType=\"cSource\", bool isInclude=false);\r\n\r\n    void createSWView(QSharedPointer<ComponentInstantiation> softInsta, QString softInstaName, QSharedPointer<Component> sw);\r\n\r\n    QSharedPointer<Component> createHW(QString const& hwInstanceName, QSharedPointer<Design> design, QString const& hardInstaName,\r\n\t\t QSharedPointer<DesignConfiguration> designConfig, QSharedPointer<ComponentInstantiation>& hardInsta, QString const& hwName=\"hardware\");\r\n\r\n    QSharedPointer<Component> createDesign(QSharedPointer<Design> &design, QSharedPointer<DesignConfiguration> &desgconf);\r\n\r\n    void verifyOutputContains(QString instanceName, QString const& expectedOutput);\r\n\r\n    void setFileBuilder(QSharedPointer<File> file, QString command, QString flags, bool replace);\r\n\r\n    void addFileSetBuilder(QSharedPointer<FileSet> fileSet, QString command, QString fileType, QString flags, bool replace);\r\n\r\n\tvoid addCmd2Insta(QSharedPointer<ComponentInstantiation> insta, QString command, QString fileType, QString flags, bool replace);\r\n\r\n\tvoid addAPI(QSharedPointer<Component> asw, QString name, DependencyDirection dir);\r\n\r\n\tvoid addAPIConnection(QSharedPointer<Design> design, QString com1, QString bus1, QString com2, QString bus2);\r\n\r\n    //! The test mock for library interface.\r\n    LibraryMock library_;\r\n\r\n    //! Output directory for the generator\r\n    QString outputDir_;\r\n\r\n    MessagePasser messageChannel_;\r\n\r\n    //! Mock utility to be used in tests\r\n    PluginUtilityAdapter utilityMock_;    \r\n};\r\n\r\ntst_MakefileGenerator::tst_MakefileGenerator(): library_( this ), outputDir_(\"testOutput\"), messageChannel_(), \r\n    utilityMock_(&library_, &messageChannel_, QString(), 0)\r\n{\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_MakefileGenerator::cleanupTestCase()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_MakefileGenerator::cleanupTestCase()\r\n{\r\n   QDir outputDirectory(outputDir_);\r\n   outputDirectory.removeRecursively();\r\n}\r\n\r\n// A rather basic and secure case testing that all the needed lines come for one file.\r\nvoid tst_MakefileGenerator::baseCase()\r\n{\r\n    QSharedPointer<Design> design;\r\n    QSharedPointer<DesignConfiguration> desgconf;\r\n    QSharedPointer<Component> topComponent = createDesign(design, desgconf);\r\n\r\n    QSharedPointer<ComponentInstantiation> hardInsta;\r\n    QSharedPointer<ComponentInstantiation> softInsta;\r\n\r\n    createHW(\"hardware_0\", design, \"firmware\", desgconf, hardInsta);\r\n    addCmd2Insta(hardInsta, \"gcc\", \"cSource\", \"-hw\", false);\r\n\r\n    QSharedPointer<Component> sw = createSW(\"software\", \"hardware_0\", design, \"default\", desgconf, softInsta, \"software_0\");\r\n\r\n    QString fileSetName = \"someFileSet\";\r\n    QSharedPointer<FileSet> fileSet = addFileSet(sw, fileSetName, softInsta);\r\n\r\n    addFileToSet(fileSet, \"array.c\");\r\n    addCmd2Insta(softInsta, \"gcc\", \"cSource\", \"-sw\", false);\r\n\r\n    SWStackParser stackParser(&library_, topComponent, design, desgconf);\r\n\tstackParser.parse(\"tsydemi\");\r\n\tMakefileParser makeParser( &library_, stackParser );\r\n\tmakeParser.parse( topComponent );\r\n\r\n\tQSharedPointer<QList<QSharedPointer<MakeFileData> > > datas = makeParser.getParsedData();\r\n\tQCOMPARE( datas->size(), 1 );\r\n\tQSharedPointer<MakeFileData> data = datas->first();\r\n\tQCOMPARE( data->swObjects.size(), 1 );\r\n\r\n\tQCOMPARE( data->swObjects.first()->fileName, QString(\"array.c\") );\r\n\tQCOMPARE( data->swObjects.first()->compiler, QString(\"gcc\") );\r\n\tQCOMPARE( data->swObjects.first()->flags, QString(\" -sw -hw\") );\r\n\tQCOMPARE( data->name, QString(\"software_0\") );\r\n}\r\n\r\n// Case used to test if file builder properly overrides other builders.\r\nvoid tst_MakefileGenerator::fileBuildOverride()\r\n{\r\n    QSharedPointer<Design> design;\r\n    QSharedPointer<DesignConfiguration> desgconf;\r\n    QSharedPointer<Component> topComponent = createDesign(design, desgconf);\r\n\r\n    QSharedPointer<ComponentInstantiation> hardInsta;\r\n    QSharedPointer<ComponentInstantiation> softInsta;\r\n\r\n    QString hwInstanceName = \"hardware_0\";\r\n    QString hardInstaName = \"firmware\";\r\n\tcreateHW(hwInstanceName, design, hardInstaName, desgconf, hardInsta);\r\n\taddCmd2Insta(hardInsta, \"gcc\", \"cSource\", \"\", false);\r\n\r\n    QString ComponentInstanceName = \"software_0\";\r\n    QString softInstaName = \"default\";\r\n\r\n    QSharedPointer<Component> sw = createSW(\"software\", hwInstanceName, design, softInstaName, desgconf, softInsta,ComponentInstanceName);\r\n\r\n    QString fileSetName = \"someFileSet\";\r\n    QSharedPointer<FileSet> fileSet = addFileSet(sw, fileSetName, softInsta);\r\n\r\n    QSharedPointer<File> file = addFileToSet(fileSet, \"array.c\");\r\n    addCmd2Insta(softInsta, \"gcc -o\", \"cSource\", \"-sw\", false);\r\n\r\n    setFileBuilder(file, \"python\", \"-l\", false);\r\n\r\n    SWStackParser stackParser(&library_, topComponent, design, desgconf);\r\n\tstackParser.parse(\"tsydemi\");\r\n\tMakefileParser makeParser(&library_, stackParser );\r\n\tmakeParser.parse( topComponent );\r\n\r\n\tQSharedPointer<QList<QSharedPointer<MakeFileData> > > datas = makeParser.getParsedData();\r\n\tQCOMPARE( datas->size(), 1 );\r\n\tQSharedPointer<MakeFileData> data = datas->first();\r\n\tQCOMPARE( data->swObjects.size(), 1 );\r\n\r\n\tQCOMPARE( data->swObjects.first()->compiler, QString(\"python\") );\r\n\tQCOMPARE( data->swObjects.first()->flags.trimmed(), QString(\"-l -sw\") );\r\n\tQCOMPARE( data->componentInstantiationFlags.contains(\"-sw\"), true );\r\n}\r\n\r\n// Case used to test if file set builder properly overrides other builders.\r\nvoid tst_MakefileGenerator::fileSetBuildOverride()\r\n{\r\n    QSharedPointer<Design> design;\r\n    QSharedPointer<DesignConfiguration> desgconf;\r\n    QSharedPointer<Component> topComponent = createDesign(design, desgconf);\r\n\r\n    QSharedPointer<ComponentInstantiation> hardInsta;\r\n    QSharedPointer<ComponentInstantiation> softInsta;\r\n\r\n    QString hwInstanceName = \"hardware_0\";\r\n    QString hardInstaName = \"firmware\";\r\n\tcreateHW(hwInstanceName, design, hardInstaName, desgconf, hardInsta);\r\n\taddCmd2Insta(hardInsta, \"gcc\", \"cSource\", \"\", false);\r\n\r\n    QString ComponentInstanceName = \"software_0\";\r\n    QString softInstaName = \"default\";\r\n\r\n    QSharedPointer<Component> sw = createSW(\"software\", hwInstanceName, design, softInstaName, desgconf, softInsta,ComponentInstanceName);\r\n\r\n    QString fileSetName = \"someFileSet\";\r\n    QSharedPointer<FileSet> fileSet = addFileSet(sw, fileSetName, softInsta);\r\n\r\n    addFileToSet(fileSet, \"array.c\");\r\n    addCmd2Insta(softInsta, \"gcc -o\", \"cSource\", \"-sw\", false);\r\n    addFileSetBuilder(fileSet, \"javac -beef\", \"cSource\", \"-lrt\", false);\r\n\r\n    SWStackParser stackParser(&library_, topComponent, design, desgconf);\r\n\tstackParser.parse(\"tsydemi\");\r\n\tMakefileParser makeParser(&library_, stackParser );\r\n\tmakeParser.parse( topComponent );\r\n\r\n\tQSharedPointer<QList<QSharedPointer<MakeFileData> > > datas = makeParser.getParsedData();\r\n\tQCOMPARE( datas->size(), 1 );\r\n\tQSharedPointer<MakeFileData> data = datas->first();\r\n\tQCOMPARE( data->swObjects.size(), 1 );\r\n\r\n\tQCOMPARE( data->swObjects.first()->compiler, QString(\"javac -beef\") );\r\n\tQCOMPARE( data->swObjects.first()->flags.simplified(), QString(\"-lrt -sw\") );\r\n\tQCOMPARE( data->componentInstantiationFlags.contains(\"-sw\"), true );\r\n}\r\n\r\n// Case used to test if file flags properly replace other flags if needed.\r\nvoid tst_MakefileGenerator::fileFlagReplace()\r\n{\r\n    QSharedPointer<Design> design;\r\n    QSharedPointer<DesignConfiguration> desgconf;\r\n    QSharedPointer<Component> topComponent = createDesign(design, desgconf);\r\n\r\n    QString hwInstanceName = \"hardware_0\";\r\n    QString hardInstaName = \"firmware\";\r\n\r\n    QSharedPointer<ComponentInstantiation> hardInsta;\r\n    QSharedPointer<ComponentInstantiation> softInsta;\r\n\r\n\tcreateHW(hwInstanceName, design, hardInstaName, desgconf, hardInsta);\r\n\taddCmd2Insta(hardInsta, \"gcc\", \"cSource\", \"\", false);\r\n\r\n    QString ComponentInstanceName = \"software_0\";\r\n    QString softInstaName = \"default\";\r\n\r\n    QSharedPointer<Component> sw = createSW(\"software\", hwInstanceName, design, softInstaName, desgconf, softInsta,ComponentInstanceName);\r\n\r\n    QString fileSetName = \"someFileSet\";\r\n    QSharedPointer<FileSet> fileSet = addFileSet(sw, fileSetName, softInsta);\r\n\r\n    QSharedPointer<File> file = addFileToSet(fileSet, \"array.c\");\r\n    addCmd2Insta(softInsta, \"gcc\", \"cSource\", \"-sw\", false);\r\n\r\n    setFileBuilder(file, \"\", \"-u\", true);\r\n\r\n    SWStackParser stackParser(&library_, topComponent, design, desgconf);\r\n\tstackParser.parse(\"tsydemi\");\r\n\tMakefileParser makeParser(&library_, stackParser );\r\n\tmakeParser.parse( topComponent );\r\n\r\n\tQSharedPointer<QList<QSharedPointer<MakeFileData> > > datas = makeParser.getParsedData();\r\n\tQCOMPARE( datas->size(), 1 );\r\n\tQSharedPointer<MakeFileData> data = datas->first();\r\n\tQCOMPARE( data->swObjects.size(), 1 );\r\n\r\n\tQCOMPARE( data->swObjects.first()->compiler, QString(\"gcc\") );\r\n\tQCOMPARE( data->swObjects.first()->flags.simplified(), QString(\"-u\") );\r\n\tQCOMPARE( data->componentInstantiationFlags.contains(\"-sw\"), true );\r\n}\r\n\r\n// Case used to test if file set flags properly replace other flags if needed.\r\nvoid tst_MakefileGenerator::fileSetFlagReplace()\r\n{\r\n    QSharedPointer<Design> design;\r\n    QSharedPointer<DesignConfiguration> desgconf;\r\n    QSharedPointer<Component> topComponent = createDesign(design, desgconf);\r\n\r\n    QSharedPointer<ComponentInstantiation> hardInsta;\r\n    QSharedPointer<ComponentInstantiation> softInsta;\r\n\r\n    QString hwInstanceName = \"hardware_0\";\r\n    QString hardInstaName = \"firmware\";\r\n\tcreateHW(hwInstanceName, design, hardInstaName, desgconf, hardInsta);\r\n\taddCmd2Insta(hardInsta, \"gcc\", \"cSource\", \"\", false);\r\n\r\n    QString ComponentInstanceName = \"software_0\";\r\n    QString softInstaName = \"default\";\r\n\r\n    QSharedPointer<Component> sw = createSW(\"software\", hwInstanceName, design, softInstaName, desgconf, softInsta,ComponentInstanceName);\r\n\r\n    QString fileSetName = \"someFileSet\";\r\n    QSharedPointer<FileSet> fileSet = addFileSet(sw, fileSetName, softInsta);\r\n\r\n    addFileToSet(fileSet, \"array.c\");\r\n    addCmd2Insta(softInsta, \"gcc\", \"cSource\", \"-sw\", false);\r\n    addFileSetBuilder(fileSet, \"javac -beef\", \"cSource\", \"-lrt\", true);\r\n\r\n    SWStackParser stackParser(&library_, topComponent, design, desgconf);\r\n\tstackParser.parse(\"tsydemi\");\r\n\tMakefileParser makeParser(&library_, stackParser );\r\n\tmakeParser.parse( topComponent );\r\n\r\n\tQSharedPointer<QList<QSharedPointer<MakeFileData> > > datas = makeParser.getParsedData();\r\n\tQCOMPARE( datas->size(), 1 );\r\n\tQSharedPointer<MakeFileData> data = datas->first();\r\n\tQCOMPARE( data->swObjects.size(), 1 );\r\n\r\n\tQCOMPARE( data->swObjects.first()->compiler, QString(\"javac -beef\") );\r\n\tQCOMPARE( data->swObjects.first()->flags.simplified(), QString(\"-lrt\") );\r\n\tQCOMPARE( data->componentInstantiationFlags.contains(\"-sw\"), true );\r\n}\r\n\r\n// Software view of the software component should be able to replace flags of hardware component.\r\nvoid tst_MakefileGenerator::swSWViewFlagReplace()\r\n{\r\n    QSharedPointer<Design> design;\r\n    QSharedPointer<DesignConfiguration> desgconf;\r\n    QSharedPointer<Component> topComponent = createDesign(design, desgconf);\r\n\r\n    QSharedPointer<ComponentInstantiation> hardInsta;\r\n    QSharedPointer<ComponentInstantiation> softInsta;\r\n\r\n    QString hwInstanceName = \"hardware_0\";\r\n    QString hardInstaName = \"firmware\";\r\n\tcreateHW(hwInstanceName, design, hardInstaName, desgconf, hardInsta);\r\n\taddCmd2Insta(hardInsta, \"gcc\", \"cSource\", \"\", false);\r\n\r\n    QString ComponentInstanceName = \"software_0\";\r\n    QString softInstaName = \"default\";\r\n\r\n    QSharedPointer<Component> sw = createSW(\"software\", hwInstanceName, design, softInstaName, desgconf, softInsta,ComponentInstanceName);\r\n\r\n    QSharedPointer<FileSet> fileSet = addFileSet(sw, \"someFileSet\", softInsta);\r\n\r\n    addFileToSet(fileSet, \"array.c\");\r\n\r\n    addCmd2Insta(hardInsta, \"gcc\", \"cSource\", \"-hw\", false);\r\n    addCmd2Insta(softInsta, \"gcc\", \"cSource\", \"-sw\", true);\r\n\r\n    SWStackParser stackParser(&library_, topComponent, design, desgconf);\r\n\tstackParser.parse(\"tsydemi\");\r\n\tMakefileParser makeParser(&library_, stackParser );\r\n\tmakeParser.parse( topComponent );\r\n\r\n\tQSharedPointer<QList<QSharedPointer<MakeFileData> > > datas = makeParser.getParsedData();\r\n\tQCOMPARE( datas->size(), 1 );\r\n\tQSharedPointer<MakeFileData> data = datas->first();\r\n\tQCOMPARE( data->swObjects.size(), 1 );\r\n\r\n\tQCOMPARE( data->hardPart->buildCmd->getCommand(), QString(\"gcc\") );\r\n\tQCOMPARE( data->componentInstantiationFlags.contains(\"-sw\"), true );\r\n}\r\n\r\n// See if hardware builder is taken account properly.\r\nvoid tst_MakefileGenerator::hwBuilder()\r\n{\r\n    QSharedPointer<Design> design;\r\n    QSharedPointer<DesignConfiguration> desgconf;\r\n    QSharedPointer<Component> topComponent = createDesign(design, desgconf);\r\n\r\n    QSharedPointer<ComponentInstantiation> hardInsta;\r\n    QSharedPointer<ComponentInstantiation> softInsta;\r\n\r\n    QString hwInstanceName = \"hardware_0\";\r\n    QString hardInstaName = \"firmware\";\r\n\tcreateHW(hwInstanceName, design, hardInstaName, desgconf, hardInsta);\r\n\r\n    QString ComponentInstanceName = \"software_0\";\r\n    QString softInstaName = \"default\";\r\n\r\n    QSharedPointer<Component> sw = createSW(\"software\", hwInstanceName, design, softInstaName, desgconf, softInsta,ComponentInstanceName);\r\n\r\n    QSharedPointer<FileSet> fileSet = addFileSet(sw, \"someFileSet\", softInsta);\r\n\r\n    QSharedPointer<File> file = addFileToSet(fileSet, \"array.c\");\r\n    addFileSetBuilder(fileSet, \"\", \"cSource\", \"-lrt\", false);\r\n\r\n    addCmd2Insta(hardInsta, \"super_asm\", \"cSource\", \"-hw\", false);\r\n    addCmd2Insta(softInsta, \"\", \"cSource\", \"-sw\", false);\r\n\r\n    setFileBuilder(file, \"\", \"-u\", false);\r\n\r\n    SWStackParser stackParser(&library_, topComponent, design, desgconf);\r\n\tstackParser.parse(\"tsydemi\");\r\n\tMakefileParser makeParser(&library_, stackParser );\r\n\tmakeParser.parse( topComponent );\r\n\r\n\tQSharedPointer<QList<QSharedPointer<MakeFileData> > > datas = makeParser.getParsedData();\r\n\tQCOMPARE( datas->size(), 1 );\r\n\tQSharedPointer<MakeFileData> data = datas->first();\r\n\tQCOMPARE( data->swObjects.size(), 1 );\r\n\r\n\tQCOMPARE( data->swObjects.first()->compiler, QString(\"super_asm\") );\r\n\tQCOMPARE( data->swObjects.first()->flags.simplified(), QString(\"-u -lrt -sw -hw\") );\r\n}\r\n\r\n// No software view in software components means no makefile.\r\nvoid tst_MakefileGenerator::hwBuilderWithNosoftInsta()\r\n{\r\n    QSharedPointer<Design> design;\r\n    QSharedPointer<DesignConfiguration> desgconf;\r\n    QSharedPointer<Component> topComponent = createDesign(design, desgconf);\r\n\r\n    QSharedPointer<ComponentInstantiation> hardInsta;\r\n    QSharedPointer<ComponentInstantiation> softInsta;\r\n\r\n    QString hwInstanceName = \"hardware_0\";\r\n    QString hardInstaName = \"firmware\";\r\n\tcreateHW(hwInstanceName, design, hardInstaName, desgconf, hardInsta);\r\n\taddCmd2Insta(hardInsta, \"gcc\", \"cSource\", \"\", false);\r\n\r\n    QString ComponentInstanceName = \"software_0\";\r\n    QString softInstaName = \"default\";\r\n\r\n    QSharedPointer<Component> sw = createSW(\"software\", hwInstanceName, design, softInstaName, desgconf, softInsta,ComponentInstanceName);\r\n\r\n    QSharedPointer<FileSet> fileSet = addFileSet(sw, \"someFileSet\", softInsta);\r\n\r\n    QSharedPointer<File> file = addFileToSet(fileSet, \"array.c\");\r\n    addFileSetBuilder(fileSet, \"\", \"cSource\", \"-lrt\", false);\r\n\r\n    addCmd2Insta(hardInsta, \"super_asm\", \"cSource\", \"-hw\", false);\r\n\r\n    setFileBuilder(file, \"\", \"-u\", false);\r\n\r\n    SWStackParser stackParser(&library_, topComponent, design, desgconf);\r\n\tstackParser.parse(\"tsydemi\");\r\n\r\n\tQCOMPARE( stackParser.getParsedData()->size(), 0 );\r\n\r\n\tMakefileParser makeParser(&library_, stackParser );\r\n\tmakeParser.parse( topComponent );\r\n\r\n\tQCOMPARE( makeParser.getParsedData()->size(), 0 );\r\n}\r\n\r\n// See if file set of hardware references work.\r\nvoid tst_MakefileGenerator::hwRef()\r\n{\r\n    QSharedPointer<Design> design;\r\n    QSharedPointer<DesignConfiguration> desgconf;\r\n    QSharedPointer<Component> topComponent = createDesign(design, desgconf);\r\n\r\n    QSharedPointer<ComponentInstantiation> hardInsta;\r\n    QSharedPointer<ComponentInstantiation> softInsta;\r\n\r\n    QString hwInstanceName = \"hardware_0\";\r\n    QString hardInstaName = \"firmware\";\r\n    QSharedPointer<Component> hw = createHW(hwInstanceName, design, hardInstaName, desgconf, hardInsta);\r\n\r\n    QString ComponentInstanceName = \"software_0\";\r\n    QString softInstaName = \"default\";\r\n\r\n    createSW(\"software\", hwInstanceName, design, softInstaName, desgconf, softInsta,ComponentInstanceName);\r\n\r\n    QSharedPointer<FileSet> fileSet = addFileSet(hw, \"someFileSet\", hardInsta);\r\n\r\n    addFileToSet(fileSet, \"array.c\");\r\n    addFileSetBuilder(fileSet, \"\", \"cSource\", \"-lrt\", false);\r\n\r\n    addCmd2Insta(hardInsta, \"super_asm\", \"cSource\", \"-hw\", false);\r\n    addCmd2Insta(softInsta, \"\", \"cSource\", \"-sw\", false);\r\n\r\n    QSharedPointer<File> file;\r\n    getFile(file, hw, \"array.c\");\r\n    setFileBuilder(file, \"\", \"-u\", false);\r\n\r\n    SWStackParser stackParser(&library_, topComponent, design, desgconf);\r\n\tstackParser.parse(\"tsydemi\");\r\n\tMakefileParser makeParser( &library_, stackParser );\r\n\tmakeParser.parse( topComponent );\r\n\r\n\tQSharedPointer<QList<QSharedPointer<MakeFileData> > > datas = makeParser.getParsedData();\r\n\tQCOMPARE( datas->size(), 1 );\r\n\tQSharedPointer<MakeFileData> data = datas->first();\r\n\tQCOMPARE( data->swObjects.size(), 1 );\r\n\r\n\tQCOMPARE( data->swObjects.first()->compiler, QString(\"super_asm\") );\r\n\tQCOMPARE( data->swObjects.first()->flags.simplified(), QString(\"-u -lrt -hw\") );\r\n}\r\n\r\n// See if hardware's own file set references function, while there are those of software component.\r\nvoid tst_MakefileGenerator::hwandswRef()\r\n{\r\n    QSharedPointer<Design> design;\r\n    QSharedPointer<DesignConfiguration> desgconf;\r\n    QSharedPointer<Component> topComponent = createDesign(design, desgconf);\r\n\r\n    QSharedPointer<ComponentInstantiation> hardInsta;\r\n    QSharedPointer<ComponentInstantiation> softInsta;\r\n\r\n    QString hwInstanceName = \"hardware_0\";\r\n    QString hardInstaName = \"firmware\";\r\n    QSharedPointer<Component> hw = createHW(hwInstanceName, design, hardInstaName, desgconf, hardInsta);\r\n\r\n    QString ComponentInstanceName = \"software_0\";\r\n    QString softInstaName = \"default\";\r\n\r\n    QSharedPointer<FileSet> hfileSet = addFileSet(hw, \"hardFileSet\", hardInsta);\r\n\r\n    addFileToSet(hfileSet, \"harray.c\");\r\n    addFileSetBuilder(hfileSet, \"\", \"cSource\", \"-hset\", false);\r\n    addCmd2Insta(hardInsta, \"super_asm\", \"cSource\", \"-hw\", false);\r\n\r\n    QSharedPointer<File> hfile;\r\n    getFile(hfile, hw, \"harray.c\");\r\n    setFileBuilder(hfile, \"\", \"-hu\", false);\r\n\r\n    QSharedPointer<Component> sw = createSW(\"software\", hwInstanceName, design, softInstaName, desgconf, softInsta,ComponentInstanceName);\r\n\r\n    QString sfileSetName = \"softFileSet\";\r\n    addFileSet(sw, sfileSetName, softInsta);\r\n\r\n    QSharedPointer<FileSet> sfileSet = sw->getFileSet(sfileSetName);\r\n    addFileToSet(sfileSet, \"sarray.c\");\r\n    addFileSetBuilder(sfileSet, \"\", \"cSource\", \"-sset\", false);\r\n    addCmd2Insta(softInsta, \"\", \"cSource\", \"-sw\", false);\r\n\r\n    QSharedPointer<File> sfile;\r\n    getFile(sfile, sw, \"sarray.c\");\r\n    setFileBuilder(sfile, \"\", \"-su\", false);\r\n\r\n    SWStackParser stackParser(&library_, topComponent, design, desgconf);\r\n\tstackParser.parse(\"tsydemi\");\r\n\tMakefileParser makeParser( &library_, stackParser );\r\n\tmakeParser.parse( topComponent );\r\n\r\n\tQSharedPointer<QList<QSharedPointer<MakeFileData> > > datas = makeParser.getParsedData();\r\n\tQCOMPARE( datas->size(), 1 );\r\n\tQSharedPointer<MakeFileData> data = datas->first();\r\n\tQCOMPARE( data->swObjects.size(), 2 );\r\n\r\n\tQCOMPARE( data->swObjects.first()->compiler, QString(\"super_asm\") );\r\n\tQCOMPARE( data->swObjects.first()->fileName, QString(\"sarray.c\") );\r\n\tQCOMPARE( data->swObjects.first()->flags.simplified(), QString(\"-su -sset -sw -hw\") );\r\n\tQCOMPARE( data->swObjects.last()->compiler, QString(\"super_asm\") );\r\n\tQCOMPARE( data->swObjects.last()->fileName, QString(\"harray.c\") );\r\n\tQCOMPARE( data->swObjects.last()->flags.simplified(), QString(\"-hu -hset -hw\") );\r\n\r\n\tQCOMPARE( data->hardPart->buildCmd->getCommand(), QString(\"super_asm\") );\r\n\tQCOMPARE( data->hardPart->buildCmd->getFlags(), QString(\"-hw\") );\r\n\tQCOMPARE( data->componentInstantiationFlags.contains(\"-sw\"), true );\r\n}\r\n\r\n// Instance specific files must be included to the makefile.\r\nvoid tst_MakefileGenerator::instanceFiles()\r\n{\r\n    QSharedPointer<Design> design;\r\n    QSharedPointer<DesignConfiguration> desgconf;\r\n    QSharedPointer<Component> topComponent = createDesign(design, desgconf);\r\n\r\n    QSharedPointer<ComponentInstantiation> hardInsta;\r\n    QSharedPointer<ComponentInstantiation> softInsta;\r\n\r\n    QString hwInstanceName = \"hardware_0\";\r\n    QString hardInstaName = \"firmware\";\r\n    createHW(hwInstanceName, design, hardInstaName, desgconf, hardInsta);\r\n\r\n    QString ComponentInstanceName = \"software_0\";\r\n    QString softInstaName = \"default\";\r\n\r\n    QSharedPointer<Component> sw = createSW(\"software\", hwInstanceName, design, softInstaName, desgconf, softInsta, ComponentInstanceName);\r\n\r\n    QString fileSetName = \"someFileSet\";\r\n    addFileSet(sw, fileSetName, softInsta);\r\n    QSharedPointer<FileSet> fileSet = sw->getFileSet(fileSetName);\r\n    addFileToSet(fileSet, \"array.c\");\r\n\r\n    QString topFileSetName = NameGenerationPolicy::instanceFilesetName( \"sysview\", \"software_0\" );\r\n\tQSharedPointer<FileSet> topFileSet = addFileSet(topComponent, topFileSetName, QSharedPointer<ComponentInstantiation>());\r\n    addFileToSet(topFileSet, \"array.h\", \"cSource\", true);\r\n\t\r\n\tQSharedPointer<ComponentInstance> referrringInstance = design->getComponentInstances()->first();\r\n\treferrringInstance->setFileSetRef( topFileSetName );\r\n\r\n    QString topFileSetName2 = \"testFileSet\";\r\n    QSharedPointer<FileSet> topFileSet2 = addFileSet(topComponent, topFileSetName2, QSharedPointer<ComponentInstantiation>());\r\n    addFileToSet(topFileSet2, \"joku.h\", \"cSource\", true);\r\n\r\n    addCmd2Insta(hardInsta, \"gcc\", \"cSource\", \"-hw\", false);\r\n    addCmd2Insta(softInsta, \"gcc\", \"cSource\", \"-sw\", false);\r\n\r\n    SWStackParser stackParser(&library_, topComponent, design, desgconf);\r\n\tstackParser.parse(\"tsydemi\");\r\n\tMakefileParser makeParser( &library_, stackParser );\r\n\tmakeParser.parse( topComponent );\r\n\r\n\tQSharedPointer<QList<QSharedPointer<MakeFileData> > > datas = makeParser.getParsedData();\r\n\tQCOMPARE( datas->size(), 1 );\r\n    QVERIFY( stackParser.getParsedData()->first()->instanceFileSet );\r\n}\r\n\r\n// Generate makefile with multiple source and header files.\r\nvoid tst_MakefileGenerator::multipleFiles()\r\n{\r\n    QSharedPointer<Design> design;\r\n    QSharedPointer<DesignConfiguration> desgconf;\r\n    QSharedPointer<Component> topComponent = createDesign(design, desgconf);\r\n\r\n    QSharedPointer<ComponentInstantiation> hardInsta;\r\n    QSharedPointer<ComponentInstantiation> softInsta;\r\n\r\n    QString hwInstanceName = \"hardware_0\";\r\n    QString hardInstaName = \"firmware\";\r\n    createHW(hwInstanceName, design, hardInstaName, desgconf, hardInsta);\r\n\r\n    QString ComponentInstanceName = \"software_0\";\r\n    QString softInstaName = \"default\";\r\n\r\n    QSharedPointer<Component> sw = createSW(\"software\", hwInstanceName, design, softInstaName, desgconf, softInsta,ComponentInstanceName);\r\n\r\n    QString fileSetName = \"someFileSet\";\r\n    addFileSet(sw, fileSetName, softInsta);\r\n\r\n    QSharedPointer<FileSet> fileSet = sw->getFileSet(fileSetName);\r\n    addFileToSet(fileSet, \"array.c\");\r\n    addFileToSet(fileSet, \"support.c\");\r\n    addFileToSet(fileSet, \"additional.c\");\r\n    addFileToSet(fileSet, \"hiterbehn.c\");\r\n    addFileToSet(fileSet, \"array.h\", \"cSource\", true);\r\n    addFileToSet(fileSet, \"support.h\", \"cSource\", true);\r\n\r\n    addCmd2Insta(hardInsta, \"gcc\", \"cSource\", \"-hw\", false);\r\n    addCmd2Insta(softInsta, \"gcc\", \"cSource\", \"-sw\", false);\r\n\r\n    QSharedPointer<File> file;\r\n    getFile(file, sw, \"support.c\");\r\n    setFileBuilder(file, \"continental\", \"-y\", false);\r\n\r\n    SWStackParser stackParser(&library_, topComponent, design, desgconf);\r\n\tstackParser.parse(\"tsydemi\");\r\n\tMakefileParser makeParser(&library_, stackParser );\r\n\tmakeParser.parse( topComponent );\r\n\r\n\tQSharedPointer<QList<QSharedPointer<MakeFileData> > > datas = makeParser.getParsedData();\r\n\tQCOMPARE( datas->size(), 1 );\r\n\tQSharedPointer<MakeFileData> data = datas->first();\r\n\tQCOMPARE( data->swObjects.size(), 4 );\r\n\r\n\tQCOMPARE( data->swObjects.at(0)->compiler, QString(\"gcc\" ) );\r\n\tQCOMPARE( data->swObjects.at(0)->fileName, QString(\"array.c\") );\r\n\tQCOMPARE( data->swObjects.at(0)->flags.simplified(), QString(\"-sw -hw\") );\r\n\tQCOMPARE( data->swObjects.at(1)->compiler, QString(\"continental\" ) );\r\n\tQCOMPARE( data->swObjects.at(1)->fileName, QString(\"support.c\") );\r\n\tQCOMPARE( data->swObjects.at(1)->flags.simplified(), QString(\"-y -sw -hw\") );\r\n\tQCOMPARE( data->swObjects.at(2)->fileName, QString(\"additional.c\") );\r\n\tQCOMPARE( data->swObjects.at(3)->fileName, QString(\"hiterbehn.c\") );\r\n}\r\n\r\n// Generate makefile when multiple file sets are featured.\r\nvoid tst_MakefileGenerator::multipleFileSets()\r\n{\r\n    QSharedPointer<Design> design;\r\n    QSharedPointer<DesignConfiguration> desgconf;\r\n    QSharedPointer<Component> topComponent = createDesign(design, desgconf);\r\n\r\n    QMap<QString,QString> activeViews;\r\n    QSharedPointer<ComponentInstantiation> hardInsta;\r\n    QSharedPointer<ComponentInstantiation> softInsta;\r\n\r\n    QString hwInstanceName = \"hardware_0\";\r\n    QString hardInstaName = \"firmware\";\r\n    createHW(hwInstanceName, design, hardInstaName, desgconf, hardInsta);\r\n\r\n    QString ComponentInstanceName = \"software_0\";\r\n    QString softInstaName = \"default\";\r\n\r\n    QSharedPointer<Component> sw = createSW(\"software\", hwInstanceName, design, softInstaName, desgconf, softInsta,ComponentInstanceName);\r\n\r\n    QSharedPointer<FileSet> afileSet = addFileSet(sw, \"alphaFileSet\", softInsta);\r\n    QSharedPointer<FileSet> bfileSet = addFileSet(sw, \"betaFileSet\", softInsta);\r\n\r\n    addFileToSet(afileSet, \"array.c\");\r\n    addFileToSet(afileSet, \"support.c\");\r\n    addFileToSet(bfileSet, \"additional.c\");\r\n    addFileToSet(bfileSet, \"hiterbehn.c\");\r\n    addFileToSet(afileSet, \"array.h\", \"cSource\", true);\r\n    addFileToSet(bfileSet, \"support.h\", \"cSource\", true);\r\n\r\n    addCmd2Insta(hardInsta, \"gcc\", \"cSource\", \"-hw\", false);\r\n    addCmd2Insta(softInsta, \"gcc\", \"cSource\", \"-sw\", false);\r\n\r\n    QSharedPointer<File> file;\r\n    getFile(file, sw, \"support.c\");\r\n    setFileBuilder(file, \"continental\", \"-y\", false);\r\n\r\n    SWStackParser stackParser(&library_, topComponent, design, desgconf);\r\n\tstackParser.parse(\"tsydemi\");\r\n\tMakefileParser makeParser( &library_, stackParser );\r\n\tmakeParser.parse( topComponent );\r\n\r\n\tQSharedPointer<QList<QSharedPointer<MakeFileData> > > datas = makeParser.getParsedData();\r\n\tQCOMPARE( datas->size(), 1 );\r\n\tQSharedPointer<MakeFileData> data = datas->first();\r\n\tQCOMPARE( data->swObjects.size(), 4 );\r\n\r\n\tQCOMPARE( data->swObjects.at(0)->compiler, QString(\"gcc\" ) );\r\n\tQCOMPARE( data->swObjects.at(0)->fileName, QString(\"array.c\") );\r\n\tQCOMPARE( data->swObjects.at(0)->flags.simplified(), QString(\"-sw -hw\") );\r\n\tQCOMPARE( data->swObjects.at(1)->compiler, QString(\"continental\" ) );\r\n\tQCOMPARE( data->swObjects.at(1)->fileName, QString(\"support.c\") );\r\n\tQCOMPARE( data->swObjects.at(1)->flags.simplified(), QString(\"-y -sw -hw\") );\r\n\tQCOMPARE( data->swObjects.at(2)->fileName, QString(\"additional.c\") );\r\n\tQCOMPARE( data->swObjects.at(3)->fileName, QString(\"hiterbehn.c\") );\r\n}\r\n\r\n// Generate makefile when multiple components are featured.\r\nvoid tst_MakefileGenerator::multipleComponents()\r\n{\r\n    QSharedPointer<Design> design;\r\n    QSharedPointer<DesignConfiguration> desgconf;\r\n    QSharedPointer<Component> topComponent = createDesign(design, desgconf);\r\n\r\n    QSharedPointer<ComponentInstantiation> hardInsta;\r\n    QSharedPointer<ComponentInstantiation> asoftInsta;\r\n    QSharedPointer<ComponentInstantiation> bsoftInsta;\r\n\r\n    QString hwInstanceName = \"hardware_0\";\r\n    QString hardInstaName = \"firmware\";\r\n    createHW(hwInstanceName, design, hardInstaName, desgconf, hardInsta);\r\n\r\n    QSharedPointer<Component> asw = createSW(\"testware\", hwInstanceName, design, \"default\", desgconf, asoftInsta,\"testware_0\");\r\n    QSharedPointer<Component> bsw = createSW(\"stackware\", hwInstanceName, design, \"default\", desgconf, bsoftInsta,\"stackware_0\");\r\n\r\n    QSharedPointer<FileSet> afileSet = addFileSet(asw, \"alphaFileSet\", asoftInsta);\r\n    QSharedPointer<FileSet> bfileSet = addFileSet(bsw, \"betaFileSet\", bsoftInsta);\r\n\r\n    addFileToSet(afileSet, \"array.c\");\r\n    addFileToSet(afileSet, \"support.c\");\r\n    addFileToSet(bfileSet, \"additional.c\");\r\n    addFileToSet(bfileSet, \"hiterbehn.c\");\r\n    addFileToSet(afileSet, \"array.h\", \"cSource\", true);\r\n    addFileToSet(bfileSet, \"support.h\", \"cSource\", true);\r\n\r\n\taddCmd2Insta(hardInsta, \"hopo\", \"cSource\", \"-hw\", false);\r\n\taddCmd2Insta(asoftInsta, \"\", \"cSource\", \"-amw\", false);\r\n    addCmd2Insta(bsoftInsta, \"asm-meister\", \"cSource\", \"-bmw\", false);\r\n\r\n    QSharedPointer<File> file;\r\n    getFile(file, asw, \"support.c\");\r\n    setFileBuilder(file, \"continental\", \"-y\", false);\r\n\r\n    SWStackParser stackParser(&library_, topComponent, design, desgconf);\r\n\tstackParser.parse(\"tsydemi\");\r\n\tMakefileParser makeParser(&library_, stackParser );\r\n\tmakeParser.parse(topComponent);\r\n\r\n\tQSharedPointer<QList<QSharedPointer<MakeFileData> > > datas = makeParser.getParsedData();\r\n\tQCOMPARE( datas->size(), 2 );\r\n\tQSharedPointer<MakeFileData> data1 = datas->first();\r\n\tQCOMPARE( data1->swObjects.size(), 2 );\r\n\tQCOMPARE( data1->componentInstantiationFlags.contains(\"-amw\"), true );\r\n\tQCOMPARE( data1->name, QString(\"testware_0\") );\r\n\r\n\tQCOMPARE( data1->swObjects.at(0)->compiler, QString(\"hopo\" ) );\r\n\tQCOMPARE( data1->swObjects.at(0)->fileName, QString(\"array.c\") );\r\n\tQCOMPARE( data1->swObjects.at(0)->flags.simplified(), QString(\"-amw -hw\") );\r\n\tQCOMPARE( data1->swObjects.at(1)->compiler, QString(\"continental\" ) );\r\n\tQCOMPARE( data1->swObjects.at(1)->fileName, QString(\"support.c\") );\r\n\tQCOMPARE( data1->swObjects.at(1)->flags.simplified(), QString(\"-y -amw -hw\") );\r\n\r\n\tQSharedPointer<MakeFileData> data2 = datas->last();\r\n\tQCOMPARE( data2->swObjects.size(), 2 );\r\n\tQCOMPARE( data2->componentInstantiationFlags.contains(\"-bmw\"), true );\r\n\tQCOMPARE( data2->name, QString(\"stackware_0\") );\r\n\r\n\tQCOMPARE( data2->swObjects.at(0)->fileName, QString(\"additional.c\") );\r\n\tQCOMPARE( data2->swObjects.at(0)->compiler, QString(\"asm-meister\" ) );\r\n\tQCOMPARE( data2->swObjects.at(0)->flags.simplified(), QString(\"-bmw -hw\") );\r\n\tQCOMPARE( data2->swObjects.at(1)->fileName, QString(\"hiterbehn.c\") );\r\n\tQCOMPARE( data2->swObjects.at(1)->compiler, QString(\"asm-meister\" ) );\r\n\tQCOMPARE( data2->swObjects.at(1)->flags.simplified(), QString(\"-bmw -hw\") );\r\n}\r\n\r\n// Must work if there is multiple hardware where instances are mapped to.\r\nvoid tst_MakefileGenerator::multipleHardWare()\r\n{\r\n    QSharedPointer<Design> design;\r\n    QSharedPointer<DesignConfiguration> desgconf;\r\n    QSharedPointer<Component> topComponent = createDesign(design, desgconf);\r\n\r\n    QSharedPointer<ComponentInstantiation> ahardInsta;\r\n    QSharedPointer<ComponentInstantiation> bhardInsta;\r\n    QSharedPointer<ComponentInstantiation> asoftInsta;\r\n    QSharedPointer<ComponentInstantiation> bsoftInsta;\r\n\r\n    createHW(\"Lenit_0\", design, \"firmware\", desgconf, ahardInsta, \"Lenit\");\r\n    createHW(\"MAR_0\", design, \"firmware\", desgconf, bhardInsta, \"MAR\");\r\n\r\n    QSharedPointer<Component> asw = createSW(\"testware\", \"Lenit_0\", design, \"default\", desgconf, asoftInsta,\"testware_0\");\r\n    QSharedPointer<Component> bsw = createSW(\"stackware\", \"MAR_0\", design, \"default\", desgconf, bsoftInsta,\"stackware_0\");\r\n\r\n    QSharedPointer<FileSet> afileSet = addFileSet(asw, \"alphaFileSet\", asoftInsta);\r\n    QSharedPointer<FileSet> bfileSet = addFileSet(bsw, \"betaFileSet\", bsoftInsta);\r\n\r\n    addFileToSet(afileSet, \"array.c\");\r\n    addFileToSet(afileSet, \"support.c\");\r\n    addFileToSet(afileSet, \"array.h\", \"cSource\", true);\r\n\r\n    addFileToSet(bfileSet, \"additional.c\");\r\n    addFileToSet(bfileSet, \"hiterbehn.c\");\r\n    addFileToSet(bfileSet, \"support.h\", \"cSource\", true);\r\n\r\n    addCmd2Insta(ahardInsta, \"hopo\", \"cSource\", \"-ahw\", false);\r\n    addCmd2Insta(bhardInsta, \"juu -f\", \"cSource\", \"-bhw\", false);\r\n\r\n\taddCmd2Insta(asoftInsta, \"\", \"cSource\", \"\", false);\r\n    addCmd2Insta(bsoftInsta, \"asm-meister\", \"cSource\", \"-bmw\", false);\r\n\r\n    QSharedPointer<File> file;\r\n    getFile(file, asw, \"support.c\");\r\n    setFileBuilder(file, \"continental\", \"-y\", false);\r\n\r\n    SWStackParser stackParser(&library_, topComponent, design, desgconf);\r\n\tstackParser.parse(\"tsydemi\");\r\n\tMakefileParser makeParser(&library_, stackParser );\r\n\tmakeParser.parse( topComponent );\r\n\r\n\tQSharedPointer<QList<QSharedPointer<MakeFileData> > > datas = makeParser.getParsedData();\r\n\tQCOMPARE( datas->size(), 2 );\r\n\tQSharedPointer<MakeFileData> data1 = datas->first();\r\n\tQCOMPARE( data1->swObjects.size(), 2 );\r\n\tQCOMPARE( data1->name, QString(\"testware_0\") );\r\n\tQCOMPARE( data1->hardPart->buildCmd->getCommand(), QString(\"hopo\") );\r\n\tQCOMPARE( data1->hardPart->buildCmd->getFlags(), QString(\"-ahw\") );\r\n\r\n\tQCOMPARE( data1->swObjects.at(0)->compiler, QString(\"hopo\" ) );\r\n\tQCOMPARE( data1->swObjects.at(0)->fileName, QString(\"array.c\") );\r\n\tQCOMPARE( data1->swObjects.at(0)->flags.simplified(), QString(\"-ahw\") );\r\n\tQCOMPARE( data1->swObjects.at(1)->compiler, QString(\"continental\" ) );\r\n\tQCOMPARE( data1->swObjects.at(1)->fileName, QString(\"support.c\") );\r\n\tQCOMPARE( data1->swObjects.at(1)->flags.simplified(), QString(\"-y -ahw\") );\r\n\r\n\tQSharedPointer<MakeFileData> data2 = datas->last();\r\n\tQCOMPARE( data2->swObjects.size(), 2 );\r\n\tQCOMPARE( data2->componentInstantiationFlags.contains(\"-bmw\"), true );\r\n\tQCOMPARE( data2->name, QString(\"stackware_0\") );\r\n\tQCOMPARE( data2->hardPart->buildCmd->getCommand(), QString(\"juu -f\") );\r\n\tQCOMPARE( data2->hardPart->buildCmd->getFlags(), QString(\"-bhw\") );\r\n\tQCOMPARE( data2->componentInstantiationFlags.contains(\"-bmw\"), true );\r\n\r\n\tQCOMPARE( data2->swObjects.at(0)->fileName, QString(\"additional.c\") );\r\n\tQCOMPARE( data2->swObjects.at(0)->compiler, QString(\"asm-meister\" ) );\r\n\tQCOMPARE( data2->swObjects.at(0)->flags.simplified(), QString(\"-bmw -bhw\") );\r\n\tQCOMPARE( data2->swObjects.at(1)->fileName, QString(\"hiterbehn.c\") );\r\n\tQCOMPARE( data2->swObjects.at(1)->compiler, QString(\"asm-meister\" ) );\r\n\tQCOMPARE( data2->swObjects.at(1)->flags.simplified(), QString(\"-bmw -bhw\") );\r\n}\r\n\r\n// Multiple hardware, along with their references to their own files.\r\nvoid tst_MakefileGenerator::multipleHardWareMedRefs()\r\n{\r\n    QSharedPointer<Design> design;\r\n    QSharedPointer<DesignConfiguration> desgconf;\r\n    QSharedPointer<Component> topComponent = createDesign(design, desgconf);\r\n\r\n    QSharedPointer<ComponentInstantiation> ahardInsta;\r\n    QSharedPointer<ComponentInstantiation> bhardInsta;\r\n    QSharedPointer<ComponentInstantiation> asoftInsta;\r\n    QSharedPointer<ComponentInstantiation> bsoftInsta;\r\n\r\n    QSharedPointer<Component> hw = createHW(\"Lenit_0\", design, \"firmware\", desgconf, ahardInsta, \"Lenit\");\r\n    createHW(\"MAR_0\", design, \"firmware\", desgconf, bhardInsta, \"MAR\");\r\n\r\n    QSharedPointer<Component> asw = createSW(\"testware\", \"Lenit_0\", design, \"default\", desgconf, asoftInsta,\"testware_0\");\r\n    QSharedPointer<Component> bsw = createSW(\"stackware\", \"MAR_0\", design, \"default\", desgconf, bsoftInsta,\"stackware_0\");\r\n\r\n    QSharedPointer<FileSet> afileSet = addFileSet(asw, \"alphaFileSet\", asoftInsta);\r\n    QSharedPointer<FileSet> bfileSet = addFileSet(bsw, \"betaFileSet\", bsoftInsta);\r\n\r\n    addFileToSet(afileSet, \"array.c\");\r\n    addFileToSet(afileSet, \"support.c\");\r\n    addFileToSet(afileSet, \"array.h\", \"cSource\", true);\r\n\r\n    QString hfileSetName = \"hardFileSet\";\r\n    QSharedPointer<FileSet> hfileSet = addFileSet(hw, hfileSetName, ahardInsta);\r\n\r\n    addFileToSet(hfileSet, \"harray.c\");\r\n    addFileSetBuilder(hfileSet, \"\", \"cSource\", \"-hset\", false);\r\n\r\n    addFileToSet(bfileSet, \"additional.c\");\r\n    addFileToSet(bfileSet, \"hiterbehn.c\");\r\n    addFileToSet(bfileSet, \"support.h\", \"cSource\", true);\r\n\r\n    addCmd2Insta(ahardInsta, \"hopo\", \"cSource\", \"-ahw\", false);\r\n    addCmd2Insta(bhardInsta, \"juu\", \"cSource\", \"-bhw\", false);\r\n\r\n\taddCmd2Insta(asoftInsta, \"\", \"cSource\", \"\", false);\r\n    addCmd2Insta(bsoftInsta, \"asm-meister\", \"cSource\", \"-bmw\", false);\r\n\r\n    QSharedPointer<File> file;\r\n    getFile(file, asw, \"support.c\");\r\n    setFileBuilder(file, \"continental\", \"-y\", false);\r\n\r\n\tSWStackParser stackParser(&library_, topComponent, design, desgconf);\r\n\tstackParser.parse(\"tsydemi\");\r\n\tMakefileParser makeParser(&library_, stackParser );\r\n\tmakeParser.parse( topComponent );\r\n\r\n\tQSharedPointer<QList<QSharedPointer<MakeFileData> > > datas = makeParser.getParsedData();\r\n\tQCOMPARE( datas->size(), 2 );\r\n\tQSharedPointer<MakeFileData> data1 = datas->first();\r\n\tQCOMPARE( data1->swObjects.size(), 3 );\r\n\tQCOMPARE( data1->name, QString(\"testware_0\") );\r\n\r\n\tQCOMPARE( data1->swObjects.at(0)->fileName, QString(\"array.c\") );\r\n\tQCOMPARE( data1->swObjects.at(1)->fileName, QString(\"support.c\") );\r\n\tQCOMPARE( data1->swObjects.at(2)->fileName, QString(\"harray.c\") );\r\n\r\n\tQSharedPointer<MakeFileData> data2 = datas->last();\r\n\tQCOMPARE( data2->swObjects.size(), 2 );\r\n\tQCOMPARE( data2->name, QString(\"stackware_0\") );\r\n\r\n\tQCOMPARE( data2->swObjects.at(0)->fileName, QString(\"additional.c\") );\r\n\tQCOMPARE( data2->swObjects.at(1)->fileName, QString(\"hiterbehn.c\") );\r\n}\r\n\r\n// Must work with multiple instances of the same component.\r\nvoid tst_MakefileGenerator::multipleInstances()\r\n{\r\n\tQSharedPointer<Design> design;\r\n\tQSharedPointer<DesignConfiguration> desgconf;\r\n\tQSharedPointer<Component> topComponent = createDesign(design, desgconf);\r\n\r\n\tQSharedPointer<ComponentInstantiation> hardInsta;\r\n\tQSharedPointer<ComponentInstantiation> softInsta;\r\n\r\n\tQString hwInstanceName = \"hardware_0\";\r\n\tQString hardInstaName = \"firmware\";\r\n\tcreateHW(hwInstanceName, design, hardInstaName, desgconf, hardInsta);\r\n\r\n\tQSharedPointer<Component> sw = createSW(\"stackware\", hwInstanceName, design, \"default\", desgconf, softInsta,\r\n        \"stackware_0\");\r\n\r\n\tQSharedPointer<ConfigurableVLNVReference> swvlvnv( new ConfigurableVLNVReference(sw->getVlnv()) );\r\n\tQSharedPointer<ComponentInstance> softInstance(new ComponentInstance);\r\n\tsoftInstance->setInstanceName(\"stackware_1\");\r\n\tsoftInstance->setComponentRef(swvlvnv);\r\n\tsoftInstance->setMapping(hwInstanceName);\r\n\r\n\tdesgconf->addViewConfiguration(\"stackware_1\",sw->getViews()->first()->name());\r\n\r\n\tQSharedPointer<QList<QSharedPointer<ComponentInstance> > > ComponentInstances = design->getComponentInstances();\r\n\tComponentInstances->append(softInstance);\r\n\tdesign->setComponentInstances(ComponentInstances);\r\n\tlibrary_.writeModelToFile(\"testOutput/stackware\",sw);\r\n\r\n\tQSharedPointer<FileSet> fileSet = addFileSet(sw, \"FileSet\", softInsta);\r\n\r\n\taddFileToSet(fileSet, \"additional.c\");\r\n\taddFileToSet(fileSet, \"hiterbehn.c\");\r\n\taddFileToSet(fileSet, \"array.h\", \"cSource\", true);\r\n\taddFileToSet(fileSet, \"support.h\", \"cSource\", true);\r\n\r\n\taddCmd2Insta(hardInsta, \"hopo\", \"cSource\", \"-hw\", false);\r\n\taddCmd2Insta(softInsta, \"asm-meister\", \"cSource\", \"-bmw\", false);\r\n\r\n\tSWStackParser stackParser(&library_, topComponent, design, desgconf);\r\n\tstackParser.parse(\"tsydemi\");\r\n\tMakefileParser makeParser(&library_, stackParser );\r\n\tmakeParser.parse( topComponent );\r\n\r\n\tQSharedPointer<QList<QSharedPointer<MakeFileData> > > datas = makeParser.getParsedData();\r\n\tQCOMPARE( datas->size(), 2 );\r\n\tQSharedPointer<MakeFileData> data1 = datas->first();\r\n\tQCOMPARE( data1->swObjects.size(), 2 );\r\n\tQCOMPARE( data1->name, QString(\"stackware_0\") );\r\n\r\n\tQSharedPointer<MakeFileData> data2 = datas->last();\r\n\tQCOMPARE( data2->swObjects.size(), 2 );\r\n\tQCOMPARE( data2->name, QString(\"stackware_1\") );\r\n}\r\n\r\n// No hardware means no stuff.\r\nvoid tst_MakefileGenerator::noHardWare()\r\n{\r\n    QSharedPointer<Design> design;\r\n    QSharedPointer<DesignConfiguration> desgconf;\r\n    QSharedPointer<Component> topComponent = createDesign(design, desgconf);\r\n\r\n    QSharedPointer<ComponentInstantiation> softInsta;\r\n\r\n    QSharedPointer<Component> sw = createSW(\"software\", \"\", design, \"default\", desgconf, softInsta,\"software_0\");\r\n\r\n    QString fileSetName = \"someFileSet\";\r\n    addFileSet(sw, fileSetName, softInsta);\r\n\r\n    QSharedPointer<FileSet> fileSet = sw->getFileSet(fileSetName);\r\n    addFileToSet(fileSet, \"array.c\");\r\n    addCmd2Insta(softInsta, \"gcc\", \"cSource\", \"-sw\", false);\r\n\r\n\tSWStackParser stackParser(&library_, topComponent, design, desgconf);\r\n\tstackParser.parse(\"tsydemi\");\r\n\tMakefileParser makeParser(&library_, stackParser );\r\n\tmakeParser.parse( topComponent );\r\n\r\n    MakefileGenerator generator( makeParser, &utilityMock_, stackParser.getGeneralFileSet() );\r\n\tgenerator.generate(outputDir_, outputDir_);\r\n\tQSharedPointer<QList<QSharedPointer<MakeFileData> > > datas = makeParser.getParsedData();\r\n\tQCOMPARE( datas->size(), 0 );\r\n}\r\n\r\n// Yield no makefile, if no files are present.\r\nvoid tst_MakefileGenerator::noFilesComponent()\r\n{\r\n\tQSharedPointer<Design> design;\r\n\tQSharedPointer<DesignConfiguration> desgconf;\r\n\tQSharedPointer<Component> topComponent = createDesign(design, desgconf);\r\n\r\n\tQSharedPointer<ComponentInstantiation> hardInsta;\r\n\tQSharedPointer<ComponentInstantiation> asoftInsta;\r\n\tQSharedPointer<ComponentInstantiation> bsoftInsta;\r\n\r\n\tQString hwInstanceName = \"hardware_0\";\r\n\tQString hardInstaName = \"firmware\";\r\n\tcreateHW(hwInstanceName, design, hardInstaName, desgconf, hardInsta);\r\n\r\n\tQSharedPointer<Component> asw = createSW(\"whatware\", hwInstanceName, design, \"default\", desgconf, asoftInsta,\"whatware_0\");\r\n\tQSharedPointer<Component> bsw = createSW(\"stackware\", hwInstanceName, design, \"default\", desgconf, bsoftInsta,\"stackware_0\");\r\n\r\n\tQSharedPointer<FileSet> afileSet = addFileSet(asw, \"alphaFileSet\", asoftInsta);\r\n\tQSharedPointer<FileSet> bfileSet = addFileSet(bsw, \"betaFileSet\", bsoftInsta);\r\n\r\n\taddFileToSet(bfileSet, \"additional.c\");\r\n\taddFileToSet(bfileSet, \"hiterbehn.c\");\r\n\taddFileToSet(bfileSet, \"support.h\", \"cSource\", true);\r\n\r\n\taddCmd2Insta(hardInsta, \"hopo\", \"cSource\", \"-hw\", false);\r\n\taddCmd2Insta(bsoftInsta, \"asm-meister\", \"cSource\", \"-bmw\", false);\r\n\r\n\tSWStackParser stackParser(&library_, topComponent, design, desgconf);\r\n\tstackParser.parse(\"tsydemi\");\r\n\tMakefileParser makeParser( &library_, stackParser );\r\n\tmakeParser.parse( topComponent );\r\n\r\n\tQSharedPointer<QList<QSharedPointer<MakeFileData> > > datas = makeParser.getParsedData();\r\n\tQCOMPARE( datas->size(), 1 );\r\n\tQSharedPointer<MakeFileData> data = datas->first();\r\n\tQCOMPARE( data->swObjects.size(), 2 );\r\n\r\n\tQCOMPARE( data->swObjects.at(0)->fileName, QString(\"additional.c\") );\r\n\tQCOMPARE( data->swObjects.at(1)->fileName, QString(\"hiterbehn.c\") );\r\n}\r\n\r\n// File with unsupported file does not appear in our lists.\r\nvoid tst_MakefileGenerator::noFileType()\r\n{\r\n\tQSharedPointer<Design> design;\r\n\tQSharedPointer<DesignConfiguration> desgconf;\r\n\tQSharedPointer<Component> topComponent = createDesign(design, desgconf);\r\n\r\n\tQSharedPointer<ComponentInstantiation> hardInsta;\r\n\tQSharedPointer<ComponentInstantiation> softInsta;\r\n\r\n\tQString hwInstanceName = \"hardware_0\";\r\n\tQString hardInstaName = \"firmware\";\r\n\tcreateHW(hwInstanceName, design, hardInstaName, desgconf, hardInsta);\r\n\r\n\tQString ComponentInstanceName = \"software_0\";\r\n\tQString softInstaName = \"default\";\r\n\r\n\tQSharedPointer<Component> sw = createSW(\"software\", hwInstanceName, design, softInstaName, desgconf, softInsta,ComponentInstanceName);\r\n\r\n\tQString fileSetName = \"someFileSet\";\r\n\taddFileSet(sw, fileSetName, softInsta);\r\n\r\n\tQSharedPointer<FileSet> fileSet = sw->getFileSet(fileSetName);\r\n\taddFileToSet(fileSet, \"hiterbehn.c\", \"topSecret\");\r\n\taddFileToSet(fileSet, \"array.c\");\r\n\taddFileToSet(fileSet, \"support.h\", \"cSource\", true);\r\n\r\n\taddCmd2Insta(hardInsta, \"gcc\", \"cSource\", \"-hw\", false);\r\n\taddCmd2Insta(softInsta, \"gcc\", \"cSource\", \"-sw\", false);\r\n\r\n\tSWStackParser stackParser(&library_, topComponent, design, desgconf);\r\n\tstackParser.parse(\"tsydemi\");\r\n\tMakefileParser makeParser(&library_, stackParser );\r\n\tmakeParser.parse( topComponent );\r\n\r\n\tQSharedPointer<QList<QSharedPointer<MakeFileData> > > datas = makeParser.getParsedData();\r\n\tQCOMPARE( datas->size(), 1 );\r\n\tQSharedPointer<MakeFileData> data = datas->first();\r\n\tQCOMPARE( data->swObjects.size(), 1 );\r\n\r\n\tQCOMPARE( data->swObjects.at(0)->fileName, QString(\"array.c\") );\r\n}\r\n\r\n// Must include API dependencies to the makefile.\r\nvoid tst_MakefileGenerator::apiUsage()\r\n{\r\n    QSharedPointer<Design> design;\r\n    QSharedPointer<DesignConfiguration> desgconf;\r\n    QSharedPointer<Component> topComponent = createDesign(design, desgconf);\r\n\r\n    QSharedPointer<ComponentInstantiation> hardInsta;\r\n    QSharedPointer<ComponentInstantiation> asoftInsta;\r\n\tQSharedPointer<ComponentInstantiation> bsoftInsta;\r\n\r\n    QString hwInstanceName = \"hardware_0\";\r\n    QString hardInstaName = \"firmware\";\r\n    createHW(hwInstanceName, design, hardInstaName, desgconf, hardInsta);\r\n\r\n\tQSharedPointer<Component> asw = createSW(\"testware\", hwInstanceName, design, \"default\", desgconf, asoftInsta,\"testware_0\");\r\n\taddAPI(asw, \"apina\", DEPENDENCY_REQUESTER);\r\n\r\n\tQSharedPointer<Component> bsw = createSW(\"stackware\", hwInstanceName, design, \"default\", desgconf, bsoftInsta,\"stackware_0\");\r\n\taddAPI(bsw, \"banaani\", DEPENDENCY_PROVIDER);\r\n\r\n\taddAPIConnection(design,\"testware_0\",\"apina\",\"stackware_0\",\"banaani\");\r\n\r\n    QSharedPointer<FileSet> afileSet = addFileSet(asw, \"alphaFileSet\", asoftInsta);\r\n\tQSharedPointer<FileSet> bfileSet = addFileSet(bsw, \"betaFileSet\", bsoftInsta);\r\n\r\n\taddCmd2Insta(hardInsta, \"gcc\", \"cSource\", \"\", false);\r\n\taddCmd2Insta(asoftInsta, \"\", \"cSource\", \"\", false);\r\n\taddCmd2Insta(bsoftInsta, \"\", \"cSource\", \"\", false);\r\n\r\n    addFileToSet(afileSet, \"array.c\");\r\n    addFileToSet(afileSet, \"support.c\");\r\n    addFileToSet(afileSet, \"array.h\", \"cSource\", true);\r\n    \r\n    addFileToSet(bfileSet, \"additional.c\");\r\n    addFileToSet(bfileSet, \"hiterbehn.c\");\r\n    addFileToSet(bfileSet, \"support.h\", \"cSource\", true);\r\n\r\n    SWStackParser stackParser(&library_, topComponent, design, desgconf);\r\n\tstackParser.parse(\"tsydemi\");\r\n\tMakefileParser makeParser(&library_, stackParser );\r\n\tmakeParser.parse(topComponent);\r\n\r\n\tQSharedPointer<QList<QSharedPointer<MakeFileData> > > datas = makeParser.getParsedData();\r\n\tQCOMPARE(datas->size(), 1);\r\n\tQSharedPointer<MakeFileData> data = datas->first();\r\n\tQCOMPARE(data->swObjects.size(), 4);\r\n\r\n\tQCOMPARE(data->swObjects.at(0)->fileName, QString(\"array.c\"));\r\n\tQCOMPARE(data->swObjects.at(1)->fileName, QString(\"support.c\"));\r\n\tQCOMPARE(data->swObjects.at(2)->fileName, QString(\"additional.c\"));\r\n\tQCOMPARE(data->swObjects.at(3)->fileName, QString(\"hiterbehn.c\"));\r\n}\r\n\r\n// A more complex situation with API dependency.\r\nvoid tst_MakefileGenerator::threeLevelStack()\r\n{\r\n    QSharedPointer<Design> design;\r\n    QSharedPointer<DesignConfiguration> desgconf;\r\n    QSharedPointer<Component> topComponent = createDesign(design, desgconf);\r\n\r\n    QSharedPointer<ComponentInstantiation> hardInsta;\r\n    QSharedPointer<ComponentInstantiation> asoftInsta;\r\n    QSharedPointer<ComponentInstantiation> bsoftInsta;\r\n    QSharedPointer<ComponentInstantiation> gsoftInsta;\r\n\r\n    QString hwInstanceName = \"hardware_0\";\r\n    QString hardInstaName = \"firmware\";\r\n    createHW(hwInstanceName, design, hardInstaName, desgconf, hardInsta);\r\n\r\n\tQSharedPointer<Component> asw = createSW(\"testware\", hwInstanceName, design, \"default\", desgconf, asoftInsta,\"testware_0\");\r\n\taddAPI(asw, \"apina\", DEPENDENCY_REQUESTER);\r\n\r\n\tQSharedPointer<Component> bsw = createSW(\"stackware\", hwInstanceName, design, \"default\", desgconf, bsoftInsta,\"stackware_0\");\r\n\taddAPI(bsw, \"banaani\", DEPENDENCY_PROVIDER);\r\n\r\n    QSharedPointer<Component> gsw = createSW(\"driver\", hwInstanceName, design, \"default\", desgconf, gsoftInsta,\"driver_0\");\r\n\r\n\taddAPI(bsw, \"stackDriver\", DEPENDENCY_REQUESTER);\r\n\taddAPI(gsw, \"driverStack\", DEPENDENCY_PROVIDER);\r\n\r\n\taddAPIConnection(design, \"testware_0\",\"apina\",\"stackware_0\",\"banaani\");\r\n\taddAPIConnection(design, \"stackware_0\",\"stackDriver\",\"driver_0\",\"driverStack\");\r\n\r\n    QSharedPointer<FileSet> afileSet = addFileSet(asw, \"alphaFileSet\", asoftInsta);\r\n    QSharedPointer<FileSet> bfileSet = addFileSet(bsw, \"betaFileSet\", bsoftInsta);\r\n\tQSharedPointer<FileSet> cfileSet = addFileSet(gsw, \"gamaFileSet\", gsoftInsta);\r\n\r\n\taddCmd2Insta(hardInsta, \"gcc\", \"cSource\", \"\", false);\r\n\taddCmd2Insta(asoftInsta, \"\", \"cSource\", \"\", false);\r\n\taddCmd2Insta(bsoftInsta, \"\", \"cSource\", \"\", false);\r\n\taddCmd2Insta(gsoftInsta, \"\", \"cSource\", \"\", false);\r\n\r\n    addFileToSet(afileSet, \"array.c\");\r\n    addFileToSet(afileSet, \"support.c\");\r\n    addFileToSet(bfileSet, \"additional.c\");\r\n    addFileToSet(bfileSet, \"hiterbehn.c\");\r\n    addFileToSet(afileSet, \"array.h\", \"cSource\", true);\r\n    addFileToSet(bfileSet, \"support.h\", \"cSource\", true);\r\n\r\n    addFileToSet(cfileSet, \"ok.c\");\r\n    addFileToSet(cfileSet, \"ok.h\", \"cSource\", true);\r\n\r\n    SWStackParser stackParser(&library_, topComponent, design, desgconf);\r\n\tstackParser.parse(\"tsydemi\");\r\n\tMakefileParser makeParser(&library_, stackParser );\r\n\tmakeParser.parse( topComponent );\r\n\r\n\tQSharedPointer<QList<QSharedPointer<MakeFileData> > > datas = makeParser.getParsedData();\r\n\tQCOMPARE( datas->size(), 1 );\r\n\tQSharedPointer<MakeFileData> data = datas->first();\r\n\tQCOMPARE( data->swObjects.size(), 5 );\r\n\r\n\tQCOMPARE( data->swObjects.at(0)->fileName, QString(\"array.c\") );\r\n\tQCOMPARE( data->swObjects.at(1)->fileName, QString(\"support.c\") );\r\n\tQCOMPARE( data->swObjects.at(2)->fileName, QString(\"additional.c\") );\r\n\tQCOMPARE( data->swObjects.at(3)->fileName, QString(\"hiterbehn.c\") );\r\n\tQCOMPARE( data->swObjects.at(4)->fileName, QString(\"ok.c\") );\r\n}\r\n\r\n// If no top level in the stack, there can be no build!\r\nvoid tst_MakefileGenerator::fullCircularapiUsage()\r\n{\r\n    QSharedPointer<Design> design;\r\n    QSharedPointer<DesignConfiguration> desgconf;\r\n    QSharedPointer<Component> topComponent = createDesign(design, desgconf);\r\n\r\n    QSharedPointer<ComponentInstantiation> hardInsta;\r\n    QSharedPointer<ComponentInstantiation> asoftInsta;\r\n    QSharedPointer<ComponentInstantiation> bsoftInsta;\r\n    QSharedPointer<ComponentInstantiation> gsoftInsta;\r\n\r\n    QString hwInstanceName = \"hardware_0\";\r\n    QString hardInstaName = \"firmware\";\r\n    createHW(hwInstanceName, design, hardInstaName, desgconf, hardInsta);\r\n\r\n\tQSharedPointer<Component> asw = createSW(\"topware\", hwInstanceName, design, \"default\", desgconf, asoftInsta,\"topware_0\");\r\n\taddAPI(asw, \"apina\", DEPENDENCY_REQUESTER);\r\n\r\n\tQSharedPointer<Component> bsw = createSW(\"stackware\", hwInstanceName, design, \"default\", desgconf, bsoftInsta,\"stackware_0\");\r\n\taddAPI(bsw, \"banaani\", DEPENDENCY_PROVIDER);\r\n\r\n\tQSharedPointer<Component> gsw = createSW(\"driver\", hwInstanceName, design, \"default\", desgconf, gsoftInsta,\"driver_0\");\r\n\taddAPI(bsw, \"stackDriver\", DEPENDENCY_REQUESTER);\r\n\taddAPI(gsw, \"driverStack\", DEPENDENCY_PROVIDER);\r\n\taddAPI(gsw, \"bottomUp\", DEPENDENCY_REQUESTER);\r\n\taddAPI(asw, \"upBottom\", DEPENDENCY_PROVIDER);\r\n\r\n\taddAPIConnection(design, \"topware_0\",\"apina\",\"stackware_0\",\"banaani\");\r\n\taddAPIConnection(design, \"stackware_0\",\"stackDriver\",\"driver_0\",\"driverStack\");\r\n\taddAPIConnection(design, \"topware_0\",\"upBottom\",\"driver_0\",\"bottomUp\");\r\n\r\n\taddCmd2Insta(hardInsta, \"gcc\", \"cSource\", \"\", false);\r\n\taddCmd2Insta(asoftInsta, \"\", \"cSource\", \"\", false);\r\n\taddCmd2Insta(bsoftInsta, \"\", \"cSource\", \"\", false);\r\n\taddCmd2Insta(gsoftInsta, \"\", \"cSource\", \"\", false);\r\n\r\n    QSharedPointer<FileSet> afileSet = addFileSet(asw, \"alphaFileSet\", asoftInsta);\r\n    QSharedPointer<FileSet> bfileSet = addFileSet(bsw, \"betaFileSet\", bsoftInsta);\r\n    QSharedPointer<FileSet> cfileSet = addFileSet(gsw, \"gamaFileSet\", gsoftInsta);\r\n\r\n    addFileToSet(afileSet, \"array.c\");\r\n    addFileToSet(afileSet, \"support.c\");\r\n    addFileToSet(bfileSet, \"additional.c\");\r\n    addFileToSet(bfileSet, \"hiterbehn.c\");\r\n    addFileToSet(afileSet, \"array.h\", \"cSource\", true);\r\n    addFileToSet(bfileSet, \"support.h\", \"cSource\", true);\r\n\r\n    addFileToSet(cfileSet, \"ok.c\");\r\n    addFileToSet(cfileSet, \"ok.h\", \"cSource\", true);\r\n\r\n    SWStackParser stackParser(&library_, topComponent, design, desgconf);\r\n\tstackParser.parse(\"tsydemi\");\r\n\tMakefileParser makeParser(&library_, stackParser );\r\n\tmakeParser.parse( topComponent );\r\n\r\n\tQSharedPointer<QList<QSharedPointer<MakeFileData> > > datas = makeParser.getParsedData();\r\n\tQCOMPARE( datas->size(), 0 );\r\n}\r\n\r\n// Must be able to handle circular dependencies in lower levels.\r\nvoid tst_MakefileGenerator::circularapiUsage()\r\n{\r\n    QSharedPointer<Design> design;\r\n    QSharedPointer<DesignConfiguration> desgconf;\r\n    QSharedPointer<Component> topComponent = createDesign(design, desgconf);\r\n\r\n    QSharedPointer<ComponentInstantiation> hardInsta;\r\n    QSharedPointer<ComponentInstantiation> asoftInsta;\r\n    QSharedPointer<ComponentInstantiation> bsoftInsta;\r\n    QSharedPointer<ComponentInstantiation> gsoftInsta;\r\n\r\n    QString hwInstanceName = \"hardware_0\";\r\n    QString hardInstaName = \"firmware\";\r\n    createHW(hwInstanceName, design, hardInstaName, desgconf, hardInsta);\r\n\r\n    QSharedPointer<Component> asw = createSW(\"testware\", hwInstanceName, design, \"default\", desgconf, asoftInsta,\"testware_0\");\r\n\taddAPI(asw, \"apina\", DEPENDENCY_REQUESTER);\r\n\r\n\tQSharedPointer<Component> bsw = createSW(\"stackware\", hwInstanceName, design, \"default\", desgconf, bsoftInsta,\"stackware_0\");\r\n\taddAPI(bsw, \"banaani\", DEPENDENCY_PROVIDER);\r\n\r\n    QSharedPointer<Component> gsw = createSW(\"driver\", hwInstanceName, design, \"default\", desgconf, gsoftInsta,\"driver_0\");\r\n\r\n    QSharedPointer<ApiInterface> stackDriver = QSharedPointer<ApiInterface>(new ApiInterface );\r\n\taddAPI(bsw, \"stackDriver\", DEPENDENCY_REQUESTER);\r\n\r\n\tQSharedPointer<ApiInterface> driverStack = QSharedPointer<ApiInterface>(new ApiInterface );\r\n\taddAPI(gsw, \"driverStack\", DEPENDENCY_PROVIDER);\r\n\r\n\tQSharedPointer<ApiInterface> bottomUp = QSharedPointer<ApiInterface>(new ApiInterface );\r\n\taddAPI(gsw, \"bottomUp\", DEPENDENCY_REQUESTER);\r\n\r\n\tQSharedPointer<ApiInterface> upBottom = QSharedPointer<ApiInterface>(new ApiInterface );\r\n\taddAPI(bsw, \"upBottom\", DEPENDENCY_PROVIDER);;\r\n\r\n\taddAPIConnection(design, \"testware_0\",\"apina\",\"stackware_0\",\"banaani\");\r\n\taddAPIConnection(design, \"stackware_0\",\"stackDriver\",\"driver_0\",\"driverStack\");\r\n\taddAPIConnection(design, \"stackware_0\",\"upBottom\",\"driver_0\",\"bottomUp\");\r\n\r\n\taddCmd2Insta(hardInsta, \"gcc\", \"cSource\", \"\", false);\r\n\taddCmd2Insta(asoftInsta, \"\", \"cSource\", \"\", false);\r\n\taddCmd2Insta(bsoftInsta, \"\", \"cSource\", \"\", false);\r\n\taddCmd2Insta(gsoftInsta, \"\", \"cSource\", \"\", false);\r\n\r\n    QSharedPointer<FileSet> afileSet = addFileSet(asw, \"alphaFileSet\", asoftInsta);\r\n    QSharedPointer<FileSet> bfileSet = addFileSet(bsw, \"betaFileSet\", bsoftInsta);\r\n    QSharedPointer<FileSet> cfileSet = addFileSet(gsw, \"gamaFileSet\", gsoftInsta);\r\n\r\n    addFileToSet(afileSet, \"array.c\");\r\n\taddFileToSet(afileSet, \"support.c\");\r\n\taddFileToSet(afileSet, \"array.h\", \"cSource\", true);\r\n\r\n    addFileToSet(bfileSet, \"additional.c\");\r\n    addFileToSet(bfileSet, \"hiterbehn.c\");\r\n    addFileToSet(bfileSet, \"support.h\", \"cSource\", true);\r\n\r\n    addFileToSet(cfileSet, \"ok.c\");\r\n    addFileToSet(cfileSet, \"ok.h\", \"cSource\", true);\r\n\r\n    SWStackParser stackParser(&library_, topComponent, design, desgconf);\r\n\tstackParser.parse(\"tsydemi\");\r\n\tMakefileParser makeParser(&library_, stackParser );\r\n\tmakeParser.parse( topComponent );\r\n\r\n\tQSharedPointer<QList<QSharedPointer<MakeFileData> > > datas = makeParser.getParsedData();\r\n\tQCOMPARE( datas->size(), 1 );\r\n\r\n\tQSharedPointer<MakeFileData> data = datas->first();\r\n\tQCOMPARE( data->swObjects.size(), 5 );\r\n\r\n\tQCOMPARE( data->swObjects.at(0)->fileName, QString(\"array.c\") );\r\n\tQCOMPARE( data->swObjects.at(1)->fileName, QString(\"support.c\") );\r\n\tQCOMPARE( data->swObjects.at(2)->fileName, QString(\"additional.c\") );\r\n\tQCOMPARE( data->swObjects.at(3)->fileName, QString(\"hiterbehn.c\") );\r\n\tQCOMPARE( data->swObjects.at(4)->fileName, QString(\"ok.c\") );\r\n}\r\n\r\n// Same file in separate executables should not cause conflict\r\nvoid tst_MakefileGenerator::sameFileSeparateExe()\r\n{\r\n\tQSharedPointer<Design> design;\r\n\tQSharedPointer<DesignConfiguration> desgconf;\r\n\tQSharedPointer<Component> topComponent = createDesign(design, desgconf);\r\n\r\n\tQSharedPointer<ComponentInstantiation> hardInsta;\r\n\tQSharedPointer<ComponentInstantiation> asoftInsta;\r\n\tQSharedPointer<ComponentInstantiation> bsoftInsta;\r\n\r\n\tQString hwInstanceName = \"hardware_0\";\r\n\tQString hardInstaName = \"firmware\";\r\n\tcreateHW(hwInstanceName, design, hardInstaName, desgconf, hardInsta);\r\n\r\n\tQSharedPointer<Component> asw = createSW(\"testware\", hwInstanceName, design, \"default\", desgconf, asoftInsta,\"testware_0\");\r\n\tQSharedPointer<Component> bsw = createSW(\"stackware\", hwInstanceName, design, \"default\", desgconf, bsoftInsta,\"stackware_0\");\r\n\r\n\tQSharedPointer<FileSet> afileSet = addFileSet(asw, \"alphaFileSet\", asoftInsta);\r\n\tQSharedPointer<FileSet> bfileSet = addFileSet(bsw, \"betaFileSet\", bsoftInsta);\r\n\r\n\taddCmd2Insta(hardInsta, \"gcc\", \"cSource\", \"\", false);\r\n\taddCmd2Insta(asoftInsta, \"\", \"cSource\", \"\", false);\r\n\taddCmd2Insta(bsoftInsta, \"\", \"cSource\", \"\", false);\r\n\r\n\taddFileToSet(afileSet, \"array.c\");\r\n\taddFileToSet(afileSet, \"support.c\");\r\n\taddFileToSet(bfileSet, \"array.c\");\r\n\taddFileToSet(bfileSet, \"support.c\");\r\n\r\n\taddCmd2Insta(hardInsta, \"hopo\", \"cSource\", \"-hw\", false);\r\n\taddCmd2Insta(bsoftInsta, \"asm-meister\", \"cSource\", \"-bmw\", false);\r\n\r\n\tSWStackParser stackParser(&library_, topComponent, design, desgconf);\r\n\tstackParser.parse(\"tsydemi\");\r\n\tMakefileParser makeParser(&library_, stackParser );\r\n\tmakeParser.parse( topComponent );\r\n\r\n\tQCOMPARE( makeParser.getParsedData()->first()->conflicts.size(), 0 );\r\n\tQCOMPARE( makeParser.getParsedData()->last()->conflicts.size(), 0 );\r\n}\r\n\r\n// Must detect if the same file is used by multiple component instances or file sets!\r\nvoid tst_MakefileGenerator::sameFileDiffCompiler()\r\n{\r\n\tQSharedPointer<Design> design;\r\n\tQSharedPointer<DesignConfiguration> desgconf;\r\n\tQSharedPointer<Component> topComponent = createDesign(design, desgconf);\r\n\r\n\tQSharedPointer<ComponentInstantiation> hardInsta;\r\n\tQSharedPointer<ComponentInstantiation> softInsta;\r\n\r\n\tQString hwInstanceName = \"hardware_0\";\r\n\tQString hardInstaName = \"firmware\";\r\n\tcreateHW(hwInstanceName, design, hardInstaName, desgconf, hardInsta);\r\n\r\n\tQString ComponentInstanceName = \"software_0\";\r\n\tQString softInstaName = \"default\";\r\n\r\n\tQSharedPointer<Component> sw = createSW(\"software\", hwInstanceName, design, softInstaName, desgconf, softInsta,ComponentInstanceName);\r\n\r\n\tQSharedPointer<FileSet> afileSet = addFileSet(sw, \"alphaFileSet\", softInsta);\r\n\tQSharedPointer<FileSet> bfileSet = addFileSet(sw, \"betaFileSet\", softInsta);\r\n\r\n\taddCmd2Insta(hardInsta, \"gcc\", \"cSource\", \"\", false);\r\n\taddCmd2Insta(softInsta, \"\", \"cSource\", \"\", false);\r\n\r\n\taddFileToSet(afileSet, \"array.c\");\r\n\taddFileToSet(afileSet, \"support.c\");\r\n\taddFileToSet(bfileSet, \"array.c\");\r\n\taddFileToSet(bfileSet, \"support.c\");\r\n\r\n\taddCmd2Insta(softInsta, \"gcc\", \"cSource\", \"-sw\", false);\r\n\r\n\taddFileSetBuilder(afileSet, \"javac -beef\", \"cSource\", \"-lrt -pthread\", false);\r\n\taddFileSetBuilder(bfileSet, \"\", \"cSource\", \"-pthread -lrt\", false);\r\n\r\n\tSWStackParser stackParser(&library_, topComponent, design, desgconf);\r\n\tstackParser.parse(\"tsydemi\");\r\n\tMakefileParser makeParser(&library_, stackParser );\r\n\tmakeParser.parse( topComponent );\r\n\r\n\tQVector<QSet<QSharedPointer<MakeObjectData> > > conflicts = makeParser.getParsedData()->first()->conflicts;\r\n\r\n\tQCOMPARE( conflicts.size(), 2 );\r\n\r\n\tQCOMPARE( conflicts.first().size(), 2 );\r\n\tQCOMPARE( conflicts.last().size(), 2 );\r\n\tQSharedPointer<MakeObjectData> eka = *(conflicts.first().begin());\r\n\tQSharedPointer<MakeObjectData> toka = *(conflicts.first().begin()++);\r\n\tQCOMPARE( eka->path, toka->path );\r\n\tQCOMPARE( eka->fileName, toka->fileName );\r\n\r\n\tQCOMPARE( eka->fileName, QString(\"array.c\") );\r\n\r\n\teka = *(conflicts.last().begin());\r\n\ttoka = *(conflicts.last().begin()++);\r\n\tQCOMPARE( eka->path, toka->path );\r\n\tQCOMPARE( eka->fileName, toka->fileName );\r\n\r\n\tQCOMPARE( eka->fileName, QString(\"support.c\") );\r\n}\r\n\r\n// Must detect if the same file is used by multiple component instances or file sets!\r\nvoid tst_MakefileGenerator::sameFileDiffFlags()\r\n{\r\n\tQSharedPointer<Design> design;\r\n\tQSharedPointer<DesignConfiguration> desgconf;\r\n\tQSharedPointer<Component> topComponent = createDesign(design, desgconf);\r\n\r\n\tQSharedPointer<ComponentInstantiation> hardInsta;\r\n\tQSharedPointer<ComponentInstantiation> softInsta;\r\n\r\n\tQString hwInstanceName = \"hardware_0\";\r\n\tQString hardInstaName = \"firmware\";\r\n\tcreateHW(hwInstanceName, design, hardInstaName, desgconf, hardInsta);\r\n\r\n\tQString ComponentInstanceName = \"software_0\";\r\n\tQString softInstaName = \"default\";\r\n\r\n\tQSharedPointer<Component> sw = createSW(\"software\", hwInstanceName, design, softInstaName, desgconf,\r\n\t\tsoftInsta,ComponentInstanceName);\r\n\r\n\tQSharedPointer<FileSet> afileSet = addFileSet(sw, \"alphaFileSet\", softInsta);\r\n\tQSharedPointer<FileSet> bfileSet = addFileSet(sw, \"betaFileSet\", softInsta);\r\n\r\n\taddFileToSet(afileSet, \"array.c\");\r\n\taddFileToSet(afileSet, \"support.c\");\r\n\taddFileToSet(bfileSet, \"array.c\");\r\n\taddFileToSet(bfileSet, \"support.c\");\r\n\r\n\taddCmd2Insta(hardInsta, \"gcc\", \"cSource\", \"-hw\", false);\r\n\taddCmd2Insta(softInsta, \"gcc\", \"cSource\", \"-sw\", false);\r\n\r\n\taddFileSetBuilder(afileSet, \"javac -beef\", \"cSource\", \"-lrt -pthread\", false);\r\n\taddFileSetBuilder(bfileSet, \"javac -beef\", \"cSource\", \"-pthread\", false);\r\n\r\n\tSWStackParser stackParser(&library_, topComponent, design, desgconf);\r\n\tstackParser.parse(\"tsydemi\");\r\n\tMakefileParser makeParser(&library_, stackParser );\r\n\tmakeParser.parse( topComponent );\r\n\r\n\tQVector<QSet<QSharedPointer<MakeObjectData> > > conflicts = makeParser.getParsedData()->first()->conflicts;\r\n\r\n\tQCOMPARE( conflicts.size(), 2 );\r\n\r\n\tQCOMPARE( conflicts.first().size(), 2 );\r\n\tQCOMPARE( conflicts.last().size(), 2 );\r\n\tQSharedPointer<MakeObjectData> eka = *(conflicts.first().begin());\r\n\tQSharedPointer<MakeObjectData> toka = *(conflicts.first().begin()++);\r\n\tQCOMPARE( eka->path, toka->path );\r\n\tQCOMPARE( eka->fileName, toka->fileName );\r\n\r\n\tQCOMPARE( eka->fileName, QString(\"array.c\") );\r\n\r\n\teka = *(conflicts.last().begin());\r\n\ttoka = *(conflicts.last().begin()++);\r\n\tQCOMPARE( eka->path, toka->path );\r\n\tQCOMPARE( eka->fileName, toka->fileName );\r\n\r\n\tQCOMPARE( eka->fileName, QString(\"support.c\") );\r\n}\r\n\r\n// Conflict is reported even if the file is actually completely same.\r\nvoid tst_MakefileGenerator::sameFile()\r\n{\r\n\tQSharedPointer<Design> design;\r\n\tQSharedPointer<DesignConfiguration> desgconf;\r\n\tQSharedPointer<Component> topComponent = createDesign(design, desgconf);\r\n\r\n\tQSharedPointer<ComponentInstantiation> hardInsta;\r\n\tQSharedPointer<ComponentInstantiation> softInsta;\r\n\r\n\tQString hwInstanceName = \"hardware_0\";\r\n\tQString hardInstaName = \"firmware\";\r\n\tcreateHW(hwInstanceName, design, hardInstaName, desgconf, hardInsta);\r\n\r\n\tQString ComponentInstanceName = \"software_0\";\r\n\tQString softInstaName = \"default\";\r\n\r\n\tQSharedPointer<Component> sw = createSW(\"software\", hwInstanceName, design, softInstaName, desgconf,\r\n\t\tsoftInsta,ComponentInstanceName);\r\n\r\n\tQSharedPointer<FileSet> afileSet = addFileSet(sw, \"alphaFileSet\", softInsta);\r\n\tQSharedPointer<FileSet> bfileSet = addFileSet(sw, \"betaFileSet\", softInsta);\r\n\r\n\taddFileToSet(afileSet, \"array.c\");\r\n\taddFileToSet(afileSet, \"support.c\", \"cSource\", true);\r\n\taddFileToSet(bfileSet, \"array.c\");\r\n\taddFileToSet(bfileSet, \"support.c\", \"cSource\", true);\r\n\r\n\taddCmd2Insta(hardInsta, \"gcc\", \"cSource\", \"-hw\", false);\r\n\taddCmd2Insta(softInsta, \"gcc\", \"cSource\", \"-sw\", false);\r\n\r\n\taddFileSetBuilder(afileSet, \"javac -beef\", \"cSource\", \"-lrt -pthread\", false);\r\n\taddFileSetBuilder(bfileSet, \"javac -beef\", \"cSource\", \"-lrt -pthread\", false);\r\n\r\n\tSWStackParser stackParser(&library_, topComponent, design, desgconf);\r\n\tstackParser.parse(\"tsydemi\");\r\n\tMakefileParser makeParser( &library_, stackParser );\r\n\tmakeParser.parse( topComponent );\r\n\r\n\tQVector<QSet<QSharedPointer<MakeObjectData> > > conflicts = makeParser.getParsedData()->first()->conflicts;\r\n\r\n\tQCOMPARE(conflicts.size(), 1);\r\n}\r\n\r\n// See if a really basic generation case works.\r\nvoid tst_MakefileGenerator::basicGeneration()\r\n{\r\n    QSharedPointer<Design> design;\r\n    QSharedPointer<DesignConfiguration> desgconf;\r\n    QSharedPointer<Component> topComponent = createDesign(design, desgconf);\r\n\r\n\tSWStackParser stackParser(&library_, topComponent, design, desgconf);\r\n\tMakefileParser makeParser( &library_, stackParser );\r\n\tQSharedPointer<QList<QSharedPointer<MakeFileData> > > datas = makeParser.getParsedData();\r\n\tQSharedPointer<MakeFileData> makeData = QSharedPointer<MakeFileData>( new MakeFileData );\r\n\tdatas->append(makeData);\r\n\r\n\tmakeData->hardPart = QSharedPointer<StackPart>( new StackPart );\r\n\tmakeData->hardPart->buildCmd = QSharedPointer<FileBuilder>( new FileBuilder );\r\n\tmakeData->hardPart->buildCmd->setCommand(\"gcc\");\r\n\tmakeData->name = \"software_0\";\r\n\tmakeData->hardPart->buildCmd->setFlags(\"-joku\");\r\n\tmakeData->componentInstantiationFlags.append(\"-jotain\");\r\n\tmakeData->makeName = makeData->name + \".mak\";\r\n\r\n\tQSharedPointer<MakeObjectData> mod( new MakeObjectData );\r\n\tmakeData->swObjects.append( mod );\r\n\tmod->fileName = \"array.c\";\r\n\tmod->compiler = \"gcc\";\r\n\tmod->flags = \"-sw -hw\";\r\n\r\n\tMakefileGenerator generator( makeParser, &utilityMock_, stackParser.getGeneralFileSet() );\r\n\tgenerator.generate(outputDir_,outputDir_);\r\n\r\n\tverifyOutputContains(\"software_0\", \"_OBJ= array.c.o\");\r\n\tverifyOutputContains(\"software_0\", \"OBJ= $(patsubst %,$(ODIR)/%,$(_OBJ))\");\r\n\tverifyOutputContains(\"software_0\", \"ODIR= obj\");\r\n\tverifyOutputContains(\"software_0\", \"ENAME= software_0\");\r\n\tverifyOutputContains(\"software_0\", \"EFLAGS= $(INCLUDES) $(DEBUG_FLAGS) $(PROFILE_FLAGS) -joku -jotain\");\r\n\tverifyOutputContains(\"software_0\", \"EBUILDER= gcc\");\r\n\tverifyOutputContains(\"software_0\", \"$(ENAME): $(OBJ)\\n\\t$(EBUILDER) -o $(ENAME) $(OBJ) $(EFLAGS)\");\r\n\tverifyOutputContains(\"software_0\", \"gcc \" + DEFAULT_OBJECT_FLAGS + \" $(ODIR)/array.c.o /array.c $(INCLUDES)\" +\r\n\t\t\" $(DEBUG_FLAGS) $(PROFILE_FLAGS) -sw -hw\");\r\n}\r\n\r\n// Must be able to generate multiple objects.\r\nvoid tst_MakefileGenerator::multiObjectGeneration()\r\n{\r\n    QSharedPointer<Design> design;\r\n    QSharedPointer<DesignConfiguration> desgconf;\r\n    QSharedPointer<Component> topComponent = createDesign(design, desgconf);\r\n\r\n\tSWStackParser stackParser(&library_, topComponent, design, desgconf);\r\n\tMakefileParser makeParser( &library_, stackParser );\r\n\tQSharedPointer<QList<QSharedPointer<MakeFileData> > > datas = makeParser.getParsedData();\r\n\tQSharedPointer<MakeFileData> makeData = QSharedPointer<MakeFileData>( new MakeFileData );\r\n\tdatas->append(makeData);\r\n\r\n\tmakeData->hardPart = QSharedPointer<StackPart>( new StackPart );\r\n\tmakeData->hardPart->buildCmd = QSharedPointer<FileBuilder>( new FileBuilder() );\r\n\tmakeData->hardPart->buildCmd->setCommand(\"gcc\");\r\n    makeData->name = \"software_0\";\r\n    makeData->makeName = makeData->name + \".mak\";\r\n\r\n\tQSharedPointer<MakeObjectData> mod1( new MakeObjectData );\r\n\tmakeData->swObjects.append( mod1 );\r\n\tmod1->fileName = \"array.c\";\r\n\tmod1->compiler = \"gcc\";\r\n\tmod1->flags = \"-sw -hw\";\r\n\r\n\tQSharedPointer<MakeObjectData> mod2( new MakeObjectData );\r\n\tmakeData->swObjects.append( mod2 );\r\n\tmod2->fileName = \"support.c\";\r\n\tmod2->compiler = \"super-asm\";\r\n\tmod2->flags = \"-a -b\";\r\n\r\n\tMakefileGenerator generator( makeParser, &utilityMock_, stackParser.getGeneralFileSet() );\r\n\tgenerator.generate(outputDir_,outputDir_);\r\n\r\n\tverifyOutputContains(\"software_0\", \"_OBJ= array.c.o support.c.o\");\r\n\tverifyOutputContains(\"software_0\", \"gcc \" + DEFAULT_OBJECT_FLAGS + \r\n\t\t\" $(ODIR)/array.c.o /array.c $(INCLUDES) $(DEBUG_FLAGS) $(PROFILE_FLAGS) -sw -hw\");\r\n\tverifyOutputContains(\"software_0\", \"super-asm \" + DEFAULT_OBJECT_FLAGS + \r\n\t\t\" $(ODIR)/support.c.o /support.c $(INCLUDES) $(DEBUG_FLAGS) $(PROFILE_FLAGS) -a -b\");\r\n}\r\n\r\n// Must be able to generate multiple files.\r\nvoid tst_MakefileGenerator::multiFileGeneration()\r\n{\r\n    QSharedPointer<Design> design;\r\n    QSharedPointer<DesignConfiguration> desgconf;\r\n    QSharedPointer<Component> topComponent = createDesign(design, desgconf);\r\n\r\n\tSWStackParser stackParser(&library_, topComponent, design, desgconf);\r\n\tMakefileParser makeParser( &library_, stackParser );\r\n\tQSharedPointer<QList<QSharedPointer<MakeFileData> > > datas = makeParser.getParsedData();\r\n\tQSharedPointer<MakeFileData> makeData1 = QSharedPointer<MakeFileData>( new MakeFileData );\r\n\tdatas->append(makeData1);\r\n\r\n\tmakeData1->hardPart = QSharedPointer<StackPart>( new StackPart );\r\n\tmakeData1->hardPart->buildCmd = QSharedPointer<FileBuilder>( new FileBuilder() );\r\n\tmakeData1->hardPart->buildCmd->setCommand(\"gcc\");\r\n\tmakeData1->name = \"software_0\";\r\n\tmakeData1->hardPart->buildCmd->setFlags(\"-joku\");\r\n    makeData1->componentInstantiationFlags.append(\"-jotain\");\r\n    makeData1->makeName = makeData1->name + \".mak\";\r\n\r\n\tQSharedPointer<MakeObjectData> mod1( new MakeObjectData );\r\n\tmakeData1->swObjects.append( mod1 );\r\n\tmod1->fileName = \"array.c\";\r\n\tmod1->compiler = \"gcc\";\r\n\tmod1->flags = \"-sw -hw\";\r\n\r\n\tQSharedPointer<MakeFileData> makeData2 = QSharedPointer<MakeFileData>( new MakeFileData );\r\n\tdatas->append(makeData2);\r\n\r\n\tmakeData2->hardPart = QSharedPointer<StackPart>(new StackPart);\r\n\tmakeData2->hardPart->buildCmd = QSharedPointer<FileBuilder>(new FileBuilder());\r\n\tmakeData2->hardPart->buildCmd->setCommand(\"j33\");\r\n\tmakeData2->name = \"testware_0\";\r\n\tmakeData2->hardPart->buildCmd->setFlags(\"-yks\");\r\n\tmakeData2->componentInstantiationFlags.append(\"-kaks\");\r\n\tmakeData2->makeName = makeData2->name + \".mak\";\r\n\r\n\tQSharedPointer<MakeObjectData> mod2( new MakeObjectData );\r\n\tmakeData2->swObjects.append( mod2 );\r\n\tmod2->fileName = \"support.c\";\r\n\tmod2->compiler = \"super-asm\";\r\n\tmod2->flags = \"-a -b\";\r\n\r\n\tMakefileGenerator generator( makeParser, &utilityMock_, stackParser.getGeneralFileSet() );\r\n\tgenerator.generate(outputDir_,outputDir_);\r\n\r\n\tverifyOutputContains(\"software_0\", \"_OBJ= array.c.o\");\r\n\tverifyOutputContains(\"software_0\", \"EFLAGS= $(INCLUDES) $(DEBUG_FLAGS) $(PROFILE_FLAGS) -joku -jotain\");\r\n\tverifyOutputContains(\"software_0\", \"ENAME= software_0\");\r\n\tverifyOutputContains(\"software_0\", \"EBUILDER= gcc\");\r\n\tverifyOutputContains(\"software_0\", \"gcc \" + DEFAULT_OBJECT_FLAGS +\r\n\t\t\" $(ODIR)/array.c.o /array.c $(INCLUDES) $(DEBUG_FLAGS) $(PROFILE_FLAGS) -sw -hw\");\r\n\r\n\tverifyOutputContains(\"testware_0\", \"_OBJ= support.c.o\");\r\n\tverifyOutputContains(\"testware_0\", \"EFLAGS= $(INCLUDES) $(DEBUG_FLAGS) $(PROFILE_FLAGS) -yks -kaks\");\r\n\tverifyOutputContains(\"testware_0\", \"ENAME= testware_0\");\r\n\tverifyOutputContains(\"testware_0\", \"EBUILDER= j33\");\r\n\tverifyOutputContains(\"testware_0\", \"super-asm \" + DEFAULT_OBJECT_FLAGS +\r\n\t\t\" $(ODIR)/support.c.o /support.c $(INCLUDES) $(DEBUG_FLAGS) $(PROFILE_FLAGS) -a -b\");\r\n}\r\n\r\n// File with no compiler must not be in makefile!\r\nvoid tst_MakefileGenerator::noCompiler()\r\n{\r\n    QSharedPointer<Design> design;\r\n    QSharedPointer<DesignConfiguration> desgconf;\r\n    QSharedPointer<Component> topComponent = createDesign(design, desgconf);\r\n\r\n\tSWStackParser stackParser(&library_, topComponent, design, desgconf);\r\n\tMakefileParser makeParser( &library_, stackParser );\r\n\tQSharedPointer<QList<QSharedPointer<MakeFileData> > > datas = makeParser.getParsedData();\r\n\tQSharedPointer<MakeFileData> makeData = QSharedPointer<MakeFileData>( new MakeFileData );\r\n\tdatas->append(makeData);\r\n\r\n\tmakeData->hardPart = QSharedPointer<StackPart>( new StackPart );\r\n\tmakeData->hardPart->buildCmd = QSharedPointer<FileBuilder>( new FileBuilder() );\r\n\tmakeData->hardPart->buildCmd->setCommand(\"gcc\");\r\n\tmakeData->name = \"software_0\";\r\n\r\n\tQSharedPointer<MakeObjectData> mod1( new MakeObjectData );\r\n\tmakeData->swObjects.append( mod1 );\r\n\tmod1->fileName = \"joku.c\";\r\n\tmod1->compiler = \"\";\r\n\tmod1->flags = \"-sw -hw\";\r\n\r\n\tQSharedPointer<MakeObjectData> mod2( new MakeObjectData );\r\n\tmakeData->swObjects.append( mod2 );\r\n\tmod2->fileName = \"array.c\";\r\n\tmod2->compiler = \"gcc\";\r\n\tmod2->flags = \"-sw -hw\";\r\n\r\n\tMakefileGenerator generator( makeParser, &utilityMock_, stackParser.getGeneralFileSet() );\r\n\tgenerator.generate(outputDir_,outputDir_);\r\n\r\n\tverifyOutputContains(\"software_0\", \"_OBJ= array.c.o\");\r\n}\r\n\r\n// A case used to test if correct makefile comes from original parsing results.\r\nvoid tst_MakefileGenerator::allTheWay()\r\n{\r\n\tQSharedPointer<Design> design;\r\n\tQSharedPointer<DesignConfiguration> desgconf;\r\n\tQSharedPointer<Component> topComponent = createDesign(design, desgconf);\r\n\r\n\tQSharedPointer<ComponentInstantiation> hardInsta;\r\n\tQSharedPointer<ComponentInstantiation> softInsta;\r\n\r\n\tcreateHW(\"hardware_0\", design, \"firmware\", desgconf, hardInsta);\r\n\taddCmd2Insta(hardInsta, \"gcc\", \"cSource\", \"-hw\", false);\r\n\r\n\tQSharedPointer<Component> sw = createSW(\"software\", \"hardware_0\", design, \"default\", desgconf, softInsta, \"software_0\");\r\n\r\n\tQString fileSetName = \"someFileSet\";\r\n\tQSharedPointer<FileSet> fileSet = addFileSet(sw, fileSetName, softInsta);\r\n\r\n\taddFileToSet(fileSet, \"array.c\");\r\n\taddCmd2Insta(softInsta, \"gcc\", \"cSource\", \"-sw\", false);\r\n\r\n\tSWStackParser stackParser(&library_, topComponent, design, desgconf);\r\n\tstackParser.parse(\"tsydemi\");\r\n\r\n\tMakefileParser makeParser( &library_, stackParser );\r\n\tmakeParser.parse( topComponent );\r\n\r\n\tMakefileGenerator generator( makeParser, &utilityMock_, stackParser.getGeneralFileSet() );\r\n\tgenerator.generate(outputDir_,outputDir_);\r\n\r\n\tverifyOutputContains(\"software_0\", \"_OBJ= array.c.o\");\r\n\tverifyOutputContains(\"software_0\", \"OBJ= $(patsubst %,$(ODIR)/%,$(_OBJ))\");\r\n\tverifyOutputContains(\"software_0\", \"ODIR= obj\");\r\n\tverifyOutputContains(\"software_0\", \"ENAME= software_0\");\r\n\tverifyOutputContains(\"software_0\", \"EFLAGS= $(INCLUDES) $(DEBUG_FLAGS) $(PROFILE_FLAGS)\");\r\n\tverifyOutputContains(\"software_0\", \"EBUILDER= gcc\");\r\n\tverifyOutputContains(\"software_0\", \"$(ENAME): $(OBJ)\\n\\t$(EBUILDER) -o $(ENAME) $(OBJ) $(EFLAGS)\");\r\n\tverifyOutputContains(\"software_0\", \"gcc \" + DEFAULT_OBJECT_FLAGS +\r\n\t\t\" $(ODIR)/array.c.o /array.c $(INCLUDES) $(DEBUG_FLAGS) $(PROFILE_FLAGS) -sw -hw\");\r\n}\r\n\r\nQSharedPointer<Component> tst_MakefileGenerator::createDesign(QSharedPointer<Design>& design,\r\n    QSharedPointer<DesignConfiguration>& desgconf)\r\n{\r\n    VLNV designVLNV(VLNV::DESIGN, \"vendor\", \"lib\", \"design\", \"1.0\");\r\n    design = QSharedPointer<Design>(new Design(designVLNV, Document::Revision::Std14));\r\n\r\n    VLNV configurationVLNV(VLNV::DESIGNCONFIGURATION, \"vendor\", \"lib\", \"design-conf\", \"1.0\");\r\n    desgconf = QSharedPointer<DesignConfiguration>(new DesignConfiguration(configurationVLNV, Document::Revision::Std14));\r\n    desgconf->setDesignRef(designVLNV);\r\n\r\n    VLNV topVLNV(VLNV::COMPONENT,\"vendor\",\"lib\",\"master-plan\",\"1.0\");\r\n    QSharedPointer<Component> topComponent = QSharedPointer<Component>(new Component(topVLNV, Document::Revision::Std14));\r\n    topComponent->setImplementation(KactusAttribute::SYSTEM);\r\n    \r\n    library_.addComponent(topComponent);\r\n    library_.writeModelToFile(outputDir_ + \"/master-plan\",topComponent);\r\n\r\n    outputDir_ = QFileInfo(library_.getPath(topVLNV)).absolutePath();\r\n\r\n    QSharedPointer<SystemView> systemView( new SystemView(\"sysview\") );\r\n    systemView->setHierarchyRef(configurationVLNV);\r\n\t\r\n    QList<QSharedPointer<SystemView> > systemViews;\r\n\tsystemViews.append(systemView);\r\n\ttopComponent->setSystemViews(systemViews);\r\n\r\n    return topComponent;\r\n}\r\n\r\nQSharedPointer<File> tst_MakefileGenerator::addFileToSet(QSharedPointer<FileSet> fileSet, QString fileName,\r\n    QString fileType/*=\"cSource\"*/, bool isInclude/*=false*/)\r\n{\r\n    QSettings settings;\r\n\r\n    QSharedPointer<File> file = fileSet->addFile(fileName, settings);\r\n    file->addFileType(fileType);\r\n    file->setIncludeFile(isInclude);\r\n\r\n\treturn file;\r\n}\r\n\r\nQSharedPointer<Component> tst_MakefileGenerator::createSW(QString swName, QString hwInstanceName,\r\n    QSharedPointer<Design> design, QString softInstaName,  QSharedPointer<DesignConfiguration> desgconf,\r\n    QSharedPointer<ComponentInstantiation>& softInsta, QString ComponentInstanceName)\r\n{\r\n    VLNV swvlvnv(VLNV::COMPONENT,\"vendor\",\"lib\",swName,\"1.0\");\r\n\tQSharedPointer<ConfigurableVLNVReference> swvlvnv2( new ConfigurableVLNVReference( swvlvnv ) );\r\n    QSharedPointer<Component> swComponent = QSharedPointer<Component>(new Component(swvlvnv, Document::Revision::Std14));\r\n    QSharedPointer<ComponentInstance> softInstance( new ComponentInstance );\r\n    softInstance->setInstanceName(ComponentInstanceName);\r\n    softInstance->setComponentRef(swvlvnv2);\r\n    softInstance->setMapping(hwInstanceName);\r\n\r\n    QSharedPointer<QList<QSharedPointer<ComponentInstance> > > ComponentInstances = design->getComponentInstances();\r\n    ComponentInstances->append(softInstance);\r\n    design->setComponentInstances(ComponentInstances);\r\n    library_.addComponent(swComponent);\r\n    library_.writeModelToFile(\"testOutput/\" + swName, swComponent);\r\n\r\n    softInsta = QSharedPointer<ComponentInstantiation>(new ComponentInstantiation);\r\n    softInsta->setName(softInstaName);\r\n    swComponent->getComponentInstantiations()->append(softInsta);\r\n\r\n    QSharedPointer<View> softView = QSharedPointer<View>(new View);\r\n    softView->setName(softInstaName + \"_view\");\r\n    softView->setComponentInstantiationRef(softInstaName);\r\n    swComponent->getViews()->append(softView);\r\n\r\n\tdesgconf->addViewConfiguration(ComponentInstanceName, softView->name());\r\n\r\n    return swComponent;\r\n}\r\n\r\nQSharedPointer<Component> tst_MakefileGenerator::createHW(QString const& hwInstanceName,\r\n    QSharedPointer<Design> design, QString const& hardInstaName, QSharedPointer<DesignConfiguration> designConfig, \r\n    QSharedPointer<ComponentInstantiation>& hardInsta, QString const& hwName/*=\"hardware\"*/)\r\n{\r\n\tVLNV hwVLNV(VLNV::COMPONENT, \"vendor\", \"lib\", hwName, \"1.0\");\r\n    QSharedPointer<Component> hwComponent = QSharedPointer<Component>(new Component(hwVLNV, Document::Revision::Std14));\r\n   \r\n    QSharedPointer<ConfigurableVLNVReference> vlnvRef(new ConfigurableVLNVReference(hwVLNV));\r\n    QSharedPointer<ComponentInstance> hwInstance(new ComponentInstance(hwInstanceName, vlnvRef));\r\n    hwInstance->setDescription(\"esim\");\r\n    hwInstance->setUuid(hwInstanceName);\r\n\r\n    QSharedPointer<QList<QSharedPointer<ComponentInstance> > > instances = design->getComponentInstances();\r\n    instances->append(hwInstance);\r\n    library_.addComponent(hwComponent);\r\n    library_.writeModelToFile(\"testOutput/\" + hwName, hwComponent);\r\n\r\n    hardInsta = QSharedPointer<ComponentInstantiation>(new ComponentInstantiation);\r\n    hardInsta->setName(hardInstaName);\r\n    hwComponent->getComponentInstantiations()->append(hardInsta);\r\n\r\n    QSharedPointer<View> hardView = QSharedPointer<View>(new View);\r\n    hardView->setName(hardInstaName + \"_view\");\r\n    hardView->setComponentInstantiationRef(hardInstaName);\r\n    hwComponent->getViews()->append(hardView);\r\n\r\n\tdesignConfig->addViewConfiguration(hwInstanceName, hardView->name());\r\n\r\n    return hwComponent;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_MakefileGenerator::verifyOutputContains()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_MakefileGenerator::verifyOutputContains(QString instanceName, QString const& expectedOutput)\r\n{\r\n    QFile outputFile(outputDir_ + \"/\" + instanceName + MAKEFILE_FRAGMENT_SUFFIX);\r\n\r\n    QVERIFY(outputFile.open(QIODevice::ReadOnly));\r\n\r\n    QString outputString = outputFile.readAll();\r\n    outputFile.close();\r\n\r\n    outputString = outputString.replace( QRegularExpression(\"[ ]+\"), \" \" );\r\n\r\n    if (!outputString.contains(expectedOutput))\r\n    {\r\n        QStringList outputLines = outputString.split(\"\\n\");\r\n        QStringList expectedLines = expectedOutput.split(\"\\n\");\r\n\r\n        QVERIFY(outputLines.count() >= expectedLines.count());\r\n\r\n        int lineOffset = outputLines.indexOf(expectedLines.first());\r\n\r\n        if (lineOffset == -1)\r\n        {\r\n            QCOMPARE(outputString, expectedOutput);\r\n        }\r\n        else\r\n        {\r\n            int lineCount = expectedLines.count();\r\n            for (int i = 0; i < lineCount; i++)\r\n            {\r\n                QCOMPARE(outputLines.at(i + lineOffset), expectedLines.at(i));\r\n            }\r\n        }\r\n    }\r\n    else if(outputString.count(expectedOutput) != 1)\r\n    {\r\n        QVERIFY2(false, QString(expectedOutput + \" was found \" +\r\n            QString::number(outputString.count(expectedOutput)) + \" times in output.\").toLocal8Bit());\r\n    }\r\n}\r\n\r\nvoid tst_MakefileGenerator::getFile(QSharedPointer<File>& file, QSharedPointer<Component> component, QString fileName)\r\n{\r\n    foreach( QSharedPointer<FileSet> fset, *component->getFileSets())\r\n    {\r\n        foreach( QSharedPointer<File> possibleFile, *fset->getFiles())\r\n        {\r\n            if ( possibleFile->name() == fileName )\r\n            {\r\n                file = possibleFile;\r\n                return;\r\n            }\r\n        }\r\n    }\r\n}\r\n\r\nvoid tst_MakefileGenerator::addCmd2Insta(QSharedPointer<ComponentInstantiation> insta, QString command, QString fileType,\r\n    QString flags, bool replace)\r\n{\r\n    QSharedPointer<FileBuilder> cmd = QSharedPointer<FileBuilder>(new FileBuilder());\r\n    cmd->setCommand(command);\r\n    cmd->setFileType(fileType);\r\n    cmd->setFlags(flags);\r\n\r\n    if (replace)\r\n    {\r\n        cmd->setReplaceDefaultFlags(\"1\");\r\n    }\r\n    else\r\n    {\r\n        cmd->setReplaceDefaultFlags(\"0\");\r\n    }\r\n\r\n\tinsta->getDefaultFileBuilders()->append(cmd);\r\n}\r\n\r\nQSharedPointer<FileSet> tst_MakefileGenerator::addFileSet(QSharedPointer<Component> component, QString fileSetName,\r\n    QSharedPointer<ComponentInstantiation> insta)\r\n{\r\n    QSharedPointer<FileSet> fileSet(new FileSet(fileSetName, \"sourceFiles\"));\r\n\r\n\tif (insta)\r\n\t{\r\n\t\tinsta->getFileSetReferences()->append(QSharedPointer<FileSetRef>(new FileSetRef(fileSetName)));\r\n\t}\r\n\t\r\n\tcomponent->getFileSets()->append(fileSet);\r\n\r\n    return fileSet;\r\n}\r\n\r\nvoid tst_MakefileGenerator::addFileSetBuilder(QSharedPointer<FileSet> fileSet, QString command, QString fileType, QString flags, bool replace)\r\n{\r\n    QSharedPointer<QList<QSharedPointer<FileBuilder> > > filebuilderList = fileSet->getDefaultFileBuilders();\r\n    QSharedPointer<FileBuilder> fileBuilder = QSharedPointer<FileBuilder>(new FileBuilder);\r\n    fileBuilder->setCommand(command);\r\n    fileBuilder->setFileType(fileType);\r\n    fileBuilder->setFlags(flags);\r\n    fileBuilder->setReplaceDefaultFlags(\"false\");\r\n\r\n\tif (replace)\r\n\t{\r\n\t\tfileBuilder->setReplaceDefaultFlags(\"true\");\r\n\t}\r\n\r\n\tfilebuilderList->append(fileBuilder);\r\n}\r\n\r\nvoid tst_MakefileGenerator::setFileBuilder(QSharedPointer<File> file, QString command, QString flags, bool replace)\r\n{\r\n    QSharedPointer<BuildCommand> buildCmd( new BuildCommand() );\r\n    buildCmd->setCommand(command);\r\n    buildCmd->setFlags(flags);\r\n    buildCmd->setReplaceDefaultFlags(\"false\");\r\n\r\n\tif ( replace )\r\n\t{\r\n\t\tbuildCmd->setReplaceDefaultFlags(\"true\");\r\n\t}\r\n\r\n    file->setBuildcommand( buildCmd );\r\n}\r\n\r\nvoid tst_MakefileGenerator::addAPI(QSharedPointer<Component> asw, QString name, DependencyDirection dir)\r\n{\r\n\tQSharedPointer<ApiInterface> apina = QSharedPointer<ApiInterface>(new ApiInterface );\r\n\tQList<QSharedPointer<ApiInterface> > apit = asw->getApiInterfaces();\r\n\tapina->setDependencyDirection(dir);\r\n\tapina->setName(name);\r\n\tapit.append(apina);\r\n\tasw->setApiInterfaces( apit );\r\n}\r\n\r\nvoid tst_MakefileGenerator::addAPIConnection(QSharedPointer<Design> design, QString com1,\r\n\tQString bus1, QString com2, QString bus2)\r\n{\r\n\tQList<QSharedPointer<ApiInterconnection> > deps = design->getApiConnections();\r\n\tQSharedPointer<ApiInterconnection> dependency1( new ApiInterconnection );\r\n\tQSharedPointer<ActiveInterface> air1( new ActiveInterface(com1, bus1));\r\n\tQSharedPointer<ActiveInterface> air2( new ActiveInterface(com2, bus2));\r\n\tdependency1->setStartInterface(air1);\r\n\tdependency1->getActiveInterfaces()->append(air2);\r\n\tdeps.append(dependency1);\r\n\tdesign->setApiConnections(deps);\r\n}\r\n\r\nQTEST_APPLESS_MAIN(tst_MakefileGenerator)\r\n\r\n#include \"tst_MakefileGenerator.moc\"\r\n"
  },
  {
    "path": "tests/Plugins/MakefileGenerator/tst_MakefileGenerator.pri",
    "content": "# ----------------------------------------------------\r\n# This file is generated by the Qt Visual Studio Tools.\r\n# ------------------------------------------------------\r\n\r\nHEADERS += ../../../KactusAPI/include/PluginUtilityAdapter.h \\\r\n    ../../../KactusAPI/include/SystemVerilogSyntax.h \\\r\n    ../../../Plugins/MakefileGenerator/MakeCommon.h \\\r\n    ../../../Plugins/MakefileGenerator/MakefileGenerator.h \\\r\n    ../../../Plugins/MakefileGenerator/MakefileParser.h \\\r\n    ../../../common/NameGenerationPolicy.h \\\r\n    ../../../Plugins/MakefileGenerator/SWStackParser.h \\\r\n    ../../MockObjects/LibraryMock.h \\\r\n    ../../../Plugins/PluginSystem/GeneratorPlugin/MessagePasser.h\r\nSOURCES += ../../../KactusAPI/plugins/PluginUtilityAdapter.cpp \\\r\n    ../../MockObjects/LibraryMock.cpp \\\r\n    ../../../Plugins/MakefileGenerator/MakefileGenerator.cpp \\\r\n    ../../../Plugins/MakefileGenerator/MakefileParser.cpp \\\r\n    ../../../Plugins/PluginSystem/GeneratorPlugin/MessagePasser.cpp \\\r\n    ../../../common/NameGenerationPolicy.cpp \\\r\n    ../../../Plugins/MakefileGenerator/SWStackParser.cpp \\\r\n    ./tst_MakefileGenerator.cpp\r\n"
  },
  {
    "path": "tests/Plugins/MakefileGenerator/tst_MakefileGenerator.pro",
    "content": "#-----------------------------------------------------------------------------\r\n# File: unittest.pro\r\n#-----------------------------------------------------------------------------\r\n# Project: Kactus 2\r\n# Author: Janne Virtanen\r\n# Date: 24.7.2014\r\n#\r\n# Description:\r\n# Qt project file template for running unit tests for a single module.\r\n#-----------------------------------------------------------------------------\r\n\r\nTEMPLATE = app\r\n\r\nTARGET = tst_MakefileGenerator\r\n\r\nQT += core xml testlib widgets\r\nQT -= gui\r\n\r\nCONFIG += c++11 testcase console\r\n\r\nwin32:CONFIG(release, debug|release) {\r\n    LIBS += -L$$PWD/../../../executable/ -lIPXACTmodels\r\n    LIBS += -L$$PWD/../../../executable/ -lKactusAPI\r\n    DESTDIR = ./release\r\n}\r\nelse:win32:CONFIG(debug, debug|release) {\r\n    LIBS += -L$$PWD/../../../executable/ -lIPXACTmodelsd\r\n    LIBS += -L$$PWD/../../../executable/ -lKactusAPId\r\n    DESTDIR = ./debug\r\n}\r\nelse:unix {\r\n    LIBS += -L$$PWD/../../../executable/ -lIPXACTmodels\r\n    LIBS += -L$$PWD/../../../executable/ -lKactusAPI\r\n    DESTDIR = ./release\r\n}\r\n\r\nINCLUDEPATH += $$PWD/../../../\r\nINCLUDEPATH += $$PWD/../../../executable\r\nINCLUDEPATH += $$PWD/../../../KactusAPI/include\r\nINCLUDEPATH += $$DESTDIR\r\n\r\nDEPENDPATH += $$PWD/../../../\r\nDEPENDPATH += $$PWD/../../../executable\r\nDEPENDPATH += .\r\n\r\nINCLUDEPATH += $$DESTDIR\r\n\r\nDEPENDPATH += .\r\n\r\nOBJECTS_DIR += $$DESTDIR\r\n\r\nMOC_DIR += ./generatedFiles\r\nUI_DIR += ./generatedFiles\r\nRCC_DIR += ./generatedFiles\r\ninclude(tst_MakefileGenerator.pri)\r\n"
  },
  {
    "path": "tests/Plugins/MemoryMapHeaderGenerator/tst_MemoryMapHeaderGenerator.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: tst_MemoryMapHeaderGenerator.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 05.05.2015\r\n//\r\n// Description:\r\n// Unit test for class MemoryMapHeaderGenerator.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include <QtTest>\r\n\r\n#include <Plugins/MemoryMapHeaderGenerator/memorymapheadergenerator.h>\r\n#include <KactusAPI/include/PluginUtilityAdapter.h>\r\n#include <Plugins/PluginSystem/GeneratorPlugin/MessagePasser.h>\r\n\r\n#include <tests/MockObjects/LibraryMock.h>\r\n\r\n#include <IPXACTmodels/Design/Design.h>\r\n#include <IPXACTmodels/Design/ComponentInstance.h>\r\n#include <IPXACTmodels/Design/Interconnection.h>\r\n\r\n#include <IPXACTmodels/DesignConfiguration/DesignConfiguration.h>\r\n\r\n#include <IPXACTmodels/Component/AddressBlock.h>\r\n#include <IPXACTmodels/Component/AddressSpace.h>\r\n#include <IPXACTmodels/Component/BusInterface.h>\r\n#include <IPXACTmodels/Component/Channel.h>\r\n#include <IPXACTmodels/Component/Cpu.h>\r\n#include <IPXACTmodels/Component/InitiatorInterface.h>\r\n#include <IPXACTmodels/Component/MemoryMap.h>\r\n#include <IPXACTmodels/Component/MemoryMapBase.h>\r\n#include <IPXACTmodels/Component/MirroredTargetInterface.h>\r\n#include <IPXACTmodels/Component/Register.h>\r\n#include <IPXACTmodels/Component/RegisterBase.h>\r\n#include <IPXACTmodels/Component/TargetInterface.h>\r\n#include <IPXACTmodels/Component/TransparentBridge.h>\r\n\r\n#include <IPXACTmodels/kactusExtensions/SystemView.h>\r\n\r\n\r\n#include <QFile>\r\n\r\nclass tst_MemoryMapHeaderGenerator : public QObject\r\n{\r\n    Q_OBJECT\r\n\r\npublic:\r\n    tst_MemoryMapHeaderGenerator();\r\n\r\nprivate slots:\r\n\r\n    void initTestCase();\r\n    void cleanupTestCase();\r\n    void init();\r\n    void cleanup();\r\n    \r\n    void testLocalMemoryMapHeaderGeneration();\r\n    void testGenerationWithHexadecimalRegisterOffset();\r\n    void testGenerationWithReferencingRegisterOffset();\r\n    void testLocalMemoryMapAddressBlockIsMemoryOrReserved();\r\n\r\n    void testDesignMemoryMapHeaderGeneration();\r\n    void testMemoryMapHeaderGenerationInDesignWithMultipleSlaves();\r\n    void testDesignMemoryMapHeaderWithReferences();\r\n    void testDesignMemoryMapHeaderWithMasterReference();\r\n    void testDesignMemoryMapHeaderWithConfigurableElements();\r\n\r\n    void testDesignMemoryMapHeaderWithChannel();\r\n    void testChannelDesignWithReferences();\r\n\r\n    void testDesignMemoryMapHeaderWithBridge();\r\n    void testDesignMemoryMapHeaderWithOpaqueBridge();\r\n\r\n    //void testSystemMemoryMapHeaderGeneration();\r\n\r\nprivate:\r\n\r\n    MemoryMapHeaderGenerator* createTestGenerator();\r\n\r\n    QSharedPointer<Register> createTestRegister(QString const& registerName, QString const& addressOffset);\r\n\r\n    QSharedPointer<AddressBlock> createTestAddressBlock(QString const& addressName,\r\n        QList<QSharedPointer<Register> > addressBlockRegisters);\r\n    \r\n    QSharedPointer<AddressSpace> createTestAddressSpace(QString const& spaceName,\r\n        QSharedPointer<MemoryMap> localMemoryMap);\r\n\r\n    QSharedPointer<MemoryMap> createTestMemoryMap(QString const& memoryMapName,\r\n        QList<QSharedPointer<AddressBlock> > addressBlocks);\r\n\r\n    QSharedPointer<Parameter> createTestParameter(QString const& paramName, QString const& paramID,\r\n        QString const& value);\r\n\r\n    QSharedPointer<Component> createTestMasterComponent(QString const& componentName,\r\n        QString const& instanceBaseAddress);\r\n\r\n    QSharedPointer<Component> createTestSlaveComponent(QString const& componentName, QString const& registerOffset);\r\n\r\n    QSharedPointer<Design> createTestHWDesign(QString const& designName, QSharedPointer<Component> masterComponent,\r\n        QSharedPointer<Component> slaveComponent);\r\n\r\n    QSharedPointer<Component> createTestChannelComponent(QString const& componentName,\r\n        QString const& mirroredMasterBaseAddress, QString const& mirroredSlaveRemap,\r\n        QString const& mirroredSlaveRange);\r\n\r\n    QSharedPointer<Design> createTestMiddleDesign(QString const& designName,\r\n        QSharedPointer<Component> masterComponent, QSharedPointer<Component> slaveComponent,\r\n        QSharedPointer<Component> middleComponent);\r\n\r\n    QSharedPointer<Component> createTestBridgeComponent(QString const& componentName,\r\n        QString const& masterBaseAddress, QString const& bridgeReference);\r\n\r\n    void addConfigurableElementValueToInstance(QSharedPointer<ComponentInstance> instance,\r\n        QString const& referenceID, QString const& configurableValue);\r\n\r\n    void readOutPutFile();\r\n\r\n    MemoryMapHeaderGenerator* headerGenerator_;\r\n\r\n    QSharedPointer<Component> topComponent_;\r\n\r\n    LibraryMock library_;\r\n\r\n    QString targetPath_;\r\n\r\n    QString output_;\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_MemoryMapHeaderGenerator::tst_MemoryMapHeaderGenerator()\r\n//-----------------------------------------------------------------------------\r\ntst_MemoryMapHeaderGenerator::tst_MemoryMapHeaderGenerator():\r\nheaderGenerator_(), topComponent_(), library_(this), targetPath_(\"./generatorOutput.h\"), output_()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_MemoryMapHeaderGenerator::initTestCase()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_MemoryMapHeaderGenerator::initTestCase()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_MemoryMapHeaderGenerator::cleanupTestCase()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_MemoryMapHeaderGenerator::cleanupTestCase()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_MemoryMapHeaderGenerator::init()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_MemoryMapHeaderGenerator::init()\r\n{\r\n    VLNV vlnv(VLNV::COMPONENT, \"Test\", \"TestLibrary\", \"TestComponent\", \"1.0\");\r\n    topComponent_ = QSharedPointer<Component>(new Component(vlnv, Document::Revision::Std14));\r\n\r\n    library_.clear();\r\n\r\n    headerGenerator_ = createTestGenerator();\r\n\r\n    if (QFile::exists(targetPath_))\r\n    {\r\n        QWARN(\"Output file already exists.\");\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_MemoryMapHeaderGenerator::cleanup()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_MemoryMapHeaderGenerator::cleanup()\r\n{\r\n    topComponent_.clear();\r\n    output_.clear();\r\n\r\n    delete headerGenerator_;\r\n    headerGenerator_ = 0;\r\n    \r\n    QFile::remove(targetPath_);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_MemoryMapHeaderGenerator::testLocalMemoryMapHeaderGeneration()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_MemoryMapHeaderGenerator::testLocalMemoryMapHeaderGeneration()\r\n{\r\n    QSharedPointer<Register> headerRegister1 = createTestRegister(\"headerReg\", \"4\");\r\n    QSharedPointer<Register> headerRegister2 = createTestRegister(\"headerReg2\", \"10\");\r\n    QSharedPointer<Register> headerRegister3 = createTestRegister(\"headerReg3\", \"24\");\r\n\r\n    QList<QSharedPointer<Register> > registerList;\r\n    registerList.append(headerRegister1);\r\n    registerList.append(headerRegister2);\r\n\r\n    QList<QSharedPointer<Register> > otherRegisterList;\r\n    otherRegisterList.append(headerRegister3);\r\n\r\n    QList<QSharedPointer<AddressBlock> > addressBlocks;\r\n    QSharedPointer<AddressBlock> addressBlock = createTestAddressBlock(\"localAddressBlock\", registerList);\r\n    QSharedPointer<AddressBlock> otherAddressBlock = createTestAddressBlock(\"otherAddressBlock\", otherRegisterList);\r\n    QSharedPointer<AddressBlock> thirdAddressBlock = createTestAddressBlock(\"thirdBlock\",\r\n        QList<QSharedPointer<Register> > ());\r\n    addressBlocks.append(addressBlock);\r\n    addressBlocks.append(otherAddressBlock);\r\n    addressBlocks.append(thirdAddressBlock);\r\n\r\n    QSharedPointer<MemoryMap> localMemoryMap = createTestMemoryMap(\"localMemoryMap\", addressBlocks);\r\n\r\n    QSharedPointer<QList<QSharedPointer<AddressSpace> > > addressSpaceList(new QList<QSharedPointer<AddressSpace> >());\r\n    QSharedPointer<AddressSpace> localAddressSpace = createTestAddressSpace(\"addressSpace1\", localMemoryMap);\r\n    addressSpaceList->append(localAddressSpace);\r\n\r\n    topComponent_->setAddressSpaces(addressSpaceList);\r\n\r\n    QFileInfo saveFileInfo (targetPath_);\r\n\r\n    headerGenerator_->setLocalSaveFileOptions(localMemoryMap, saveFileInfo, \"swView\");\r\n\r\n    QWidget parentWidget;\r\n\r\n    MessagePasser messageChannel;\r\n    PluginUtilityAdapter adapter(&library_, &messageChannel, QString(), &parentWidget);\r\n\r\n    QSignalSpy generatorSpy(&messageChannel, SIGNAL(noticeMessage(QString const&)));\r\n\r\n    headerGenerator_->runGenerator(&adapter, topComponent_, QSharedPointer<Design>(),\r\n        QSharedPointer<DesignConfiguration>());\r\n\r\n    QCOMPARE(generatorSpy.count(), 4);\r\n\r\n    auto locale = QLocale::system();\r\n\r\n    QString initialMessage = generatorSpy.first().at(0).toString();\r\n    QCOMPARE(initialMessage, QString(\"Running %1 %2.\").arg(headerGenerator_->getName(),\r\n        headerGenerator_->getVersion()));\r\n    QString generatorStartMessage = generatorSpy.at(1).first().toString();\r\n    QCOMPARE(generatorStartMessage, QString(\"Generation started %1 %2\").arg(locale.toString(QDate::currentDate(), locale.dateFormat(QLocale::ShortFormat)))\r\n        .arg(locale.toString(QTime::currentTime(), locale.timeFormat(QLocale::ShortFormat))));\r\n    QString writingFinishedMessage = generatorSpy.at(2).first().toString();\r\n    QCOMPARE(writingFinishedMessage, QString(\"Finished writing file generatorOutput.h.\"));\r\n    QString generatorFinishedMessage = generatorSpy.at(3).first().toString();\r\n    QCOMPARE(generatorFinishedMessage, QString(\"Generation complete.\"));\r\n\r\n    readOutPutFile();\r\n\r\n    QString headerDefine = \"__\" + topComponent_->getVlnv().toString(\"_\") + \"_\" + localMemoryMap->name() + \"_h\";\r\n    headerDefine = headerDefine.toUpper();\r\n\r\n    QString expectedOutput(\r\n        \"/*\\n\"\r\n        \" * File: generatorOutput.h\\n\"\r\n        \" * Created on: \" + QDate::currentDate().toString(\"dd.MM.yyyy\") + \"\\n\"\r\n        \" * Generated by: \\n\"\r\n        \" *\\n\"\r\n        \" * Description:\\n\"\r\n        \" * Header file generated by Kactus2 from local memory map \\\"\" + localMemoryMap->name() + \"\\\".\\n\"\r\n        \" * This file contains addresses of the memories and registers defined in the local memory map.\\n\"\r\n        \" * Source component: \" + topComponent_->getVlnv().toString(\":\") + \".\\n\"\r\n        \"*/\\n\"\r\n        \"\\n\"\r\n        \"#ifndef \" + headerDefine + \"\\n\"\r\n        \"#define \" + headerDefine + \"\\n\"\r\n        \"\\n\"\r\n        \"/*\\n\"\r\n        \" * Address block: \" + addressBlock->name() + \"\\n\"\r\n        \"*/\\n\"\r\n        \"/*\\n\"\r\n        \" * Register name: \" + headerRegister1->name() + \"\\n\"\r\n        \" * Offset: 4\\n\"\r\n        \"*/\\n\"\r\n        \"#define \" + headerRegister1->name().toUpper() + \" 0x4\\n\"\r\n        \"/*\\n\"\r\n        \" * Register name: \" + headerRegister2->name() + \"\\n\"\r\n        \" * Offset: 10\\n\"\r\n        \"*/\\n\"\r\n        \"#define \" + headerRegister2->name().toUpper() + \" 0xa\\n\"\r\n        \"\\n\"\r\n        \"/*\\n\"\r\n        \" * Address block: \" + otherAddressBlock->name() + \"\\n\"\r\n        \"*/\\n\"\r\n        \"/*\\n\"\r\n        \" * Register name: \" + headerRegister3->name() + \"\\n\"\r\n        \" * Offset: 24\\n\"\r\n        \"*/\\n\"\r\n        \"#define \" + headerRegister3->name().toUpper() + \" 0x18\\n\"\r\n        \"\\n\"\r\n        \"/*\\n\"\r\n        \" * Address block: \" + thirdAddressBlock->name() + \"\\n\"\r\n        \"*/\\n\"\r\n        \"\\n\"\r\n        \"#endif /* \" + headerDefine + \" */\\n\"\r\n        );\r\n\r\n    if (!output_.contains(expectedOutput))\r\n    {\r\n        QStringList outputLines = output_.split(\"\\n\");\r\n        QStringList expectedLines = expectedOutput.split(\"\\n\");\r\n\r\n        QVERIFY(outputLines.count() >= expectedLines.count());\r\n\r\n        int lineOffset = outputLines.indexOf(expectedLines.first());\r\n        if (lineOffset == -1)\r\n        {\r\n            readOutPutFile();\r\n            QCOMPARE(output_, expectedOutput);\r\n        }\r\n        else\r\n        {\r\n            int lineCount = expectedLines.count();\r\n            for (int i = 0; i < lineCount; ++i)\r\n            {\r\n                QCOMPARE(outputLines.at(i + lineOffset), expectedLines.at(i));\r\n            }\r\n        }\r\n    }\r\n    else if (output_.count(expectedOutput) != 1)\r\n    {\r\n        QVERIFY2(false, QString(expectedOutput + \" was found \" + QString::number(output_.count(expectedOutput)) +\r\n            \" times in output.\").toLocal8Bit());\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_MemoryMapHeaderGenerator::testGenerationWithHexadecimalNumber()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_MemoryMapHeaderGenerator::testGenerationWithHexadecimalRegisterOffset()\r\n{\r\n    QSharedPointer<Register> headerRegister1 = createTestRegister(\"headerReg\", \"'ha\");\r\n\r\n    QList<QSharedPointer<Register> > registerList;\r\n    registerList.append(headerRegister1);\r\n\r\n    QList<QSharedPointer<AddressBlock> > addressBlocks;\r\n    QSharedPointer<AddressBlock> addressBlock = createTestAddressBlock(\"localAddressBlock\", registerList);\r\n    addressBlocks.append(addressBlock);\r\n\r\n    QSharedPointer<MemoryMap> localMemoryMap = createTestMemoryMap(\"localMemoryMap\", addressBlocks);\r\n\r\n    QSharedPointer<QList<QSharedPointer<AddressSpace> > > addressSpaceList(new QList<QSharedPointer<AddressSpace> >());\r\n    QSharedPointer<AddressSpace> localAddressSpace = createTestAddressSpace(\"addressSpace1\", localMemoryMap);\r\n    addressSpaceList->append(localAddressSpace);\r\n\r\n    topComponent_->setAddressSpaces(addressSpaceList);\r\n\r\n    QFileInfo saveFileInfo (targetPath_);\r\n\r\n    headerGenerator_->setLocalSaveFileOptions(localMemoryMap, saveFileInfo, \"swView\");\r\n\r\n    QWidget parentWidget;\r\n\r\n    MessagePasser messageChannel;\r\n    PluginUtilityAdapter adapter(&library_, &messageChannel, QString(), &parentWidget);\r\n\r\n    headerGenerator_->runGenerator(&adapter, topComponent_, QSharedPointer<Design>(), QSharedPointer<DesignConfiguration>());\r\n\r\n    readOutPutFile();\r\n\r\n    QString headerDefine = \"__\" + topComponent_->getVlnv().toString(\"_\") + \"_\" + localMemoryMap->name() + \"_h\";\r\n    headerDefine = headerDefine.toUpper();\r\n\r\n    QString expectedOutput(\r\n        \"/*\\n\"\r\n        \" * File: generatorOutput.h\\n\"\r\n        \" * Created on: \" + QDate::currentDate().toString(\"dd.MM.yyyy\") + \"\\n\"\r\n        \" * Generated by: \\n\"\r\n        \" *\\n\"\r\n        \" * Description:\\n\"\r\n        \" * Header file generated by Kactus2 from local memory map \\\"\" + localMemoryMap->name() + \"\\\".\\n\"\r\n        \" * This file contains addresses of the memories and registers defined in the local memory map.\\n\"\r\n        \" * Source component: \" + topComponent_->getVlnv().toString(\":\") + \".\\n\"\r\n        \"*/\\n\"\r\n        \"\\n\"\r\n        \"#ifndef \" + headerDefine + \"\\n\"\r\n        \"#define \" + headerDefine + \"\\n\"\r\n        \"\\n\"\r\n        \"/*\\n\"\r\n        \" * Address block: \" + addressBlock->name() + \"\\n\"\r\n        \"*/\\n\"\r\n        \"/*\\n\"\r\n        \" * Register name: \" + headerRegister1->name() + \"\\n\"\r\n        \" * Offset: 'ha\\n\"\r\n        \"*/\\n\"\r\n        \"#define \" + headerRegister1->name().toUpper() + \" 0xa\\n\"\r\n        \"\\n\"\r\n        \"#endif /* \" + headerDefine + \" */\\n\"\r\n    );\r\n\r\n    if (!output_.contains(expectedOutput))\r\n    {\r\n        QStringList outputLines = output_.split(\"\\n\");\r\n        QStringList expectedLines = expectedOutput.split(\"\\n\");\r\n\r\n        QVERIFY(outputLines.count() >= expectedLines.count());\r\n\r\n        int lineOffset = outputLines.indexOf(expectedLines.first());\r\n        if (lineOffset == -1)\r\n        {\r\n            readOutPutFile();\r\n            QCOMPARE(output_, expectedOutput);\r\n        }\r\n        else\r\n        {\r\n            int lineCount = expectedLines.count();\r\n            for (int i = 0; i < lineCount; ++i)\r\n            {\r\n                QCOMPARE(outputLines.at(i + lineOffset), expectedLines.at(i));\r\n            }\r\n        }\r\n    }\r\n    else if (output_.count(expectedOutput) != 1)\r\n    {\r\n        QVERIFY2(false, QString(expectedOutput + \" was found \" + QString::number(output_.count(expectedOutput)) +\r\n            \" times in output.\").toLocal8Bit());\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_MemoryMapHeaderGenerator::testGenerationWithReferencingRegisterOffset()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_MemoryMapHeaderGenerator::testGenerationWithReferencingRegisterOffset()\r\n{\r\n    QSharedPointer<Parameter> referencedParameter = createTestParameter(\"testParameter\", \"Param_ID\", \"40\");\r\n    topComponent_->getParameters()->append(referencedParameter);\r\n\r\n    QSharedPointer<Register> headerRegister1 = createTestRegister(\"headerReg\", \"Param_ID\");\r\n    QSharedPointer<Register> headerRegister2 = createTestRegister(\"headerReg2\", \"Param_ID * 2\");\r\n    QSharedPointer<Register> headerRegister3 = createTestRegister(\"headerReg3\", \"'h4 + Param_ID\");\r\n\r\n    QList<QSharedPointer<Register> > registerList;\r\n    registerList.append(headerRegister1);\r\n    registerList.append(headerRegister2);\r\n    registerList.append(headerRegister3);\r\n\r\n    QList<QSharedPointer<AddressBlock> > addressBlocks;\r\n    QSharedPointer<AddressBlock> addressBlock = createTestAddressBlock(\"localAddressBlock\", registerList);\r\n    addressBlocks.append(addressBlock);\r\n\r\n    QSharedPointer<MemoryMap> localMemoryMap = createTestMemoryMap(\"localMemoryMap\", addressBlocks);\r\n\r\n    QSharedPointer<QList<QSharedPointer<AddressSpace> > > addressSpaceList(new QList<QSharedPointer<AddressSpace> >());\r\n    QSharedPointer<AddressSpace> localAddressSpace = createTestAddressSpace(\"addressSpace1\", localMemoryMap);\r\n    addressSpaceList->append(localAddressSpace);\r\n\r\n    topComponent_->setAddressSpaces(addressSpaceList);\r\n\r\n    QFileInfo saveFileInfo (targetPath_);\r\n\r\n    headerGenerator_->setLocalSaveFileOptions(localMemoryMap, saveFileInfo, \"swView\");\r\n\r\n    QWidget parentWidget;\r\n    MessagePasser messageChannel;\r\n    PluginUtilityAdapter adapter(&library_, &messageChannel, QString(), &parentWidget);\r\n\r\n    headerGenerator_->runGenerator(&adapter, topComponent_, QSharedPointer<Design>(), QSharedPointer<DesignConfiguration>());\r\n\r\n    readOutPutFile();\r\n\r\n    QString headerDefine = \"__\" + topComponent_->getVlnv().toString(\"_\") + \"_\" + localMemoryMap->name() + \"_h\";\r\n    headerDefine = headerDefine.toUpper();\r\n\r\n    QString expectedOutput(\r\n        \"/*\\n\"\r\n        \" * File: generatorOutput.h\\n\"\r\n        \" * Created on: \" + QDate::currentDate().toString(\"dd.MM.yyyy\") + \"\\n\"\r\n        \" * Generated by: \\n\"\r\n        \" *\\n\"\r\n        \" * Description:\\n\"\r\n        \" * Header file generated by Kactus2 from local memory map \\\"\" + localMemoryMap->name() + \"\\\".\\n\"\r\n        \" * This file contains addresses of the memories and registers defined in the local memory map.\\n\"\r\n        \" * Source component: \" + topComponent_->getVlnv().toString(\":\") + \".\\n\"\r\n        \"*/\\n\"\r\n        \"\\n\"\r\n        \"#ifndef \" + headerDefine + \"\\n\"\r\n        \"#define \" + headerDefine + \"\\n\"\r\n        \"\\n\"\r\n        \"/*\\n\"\r\n        \" * Address block: \" + addressBlock->name() + \"\\n\"\r\n        \"*/\\n\"\r\n        \"/*\\n\"\r\n        \" * Register name: \" + headerRegister1->name() + \"\\n\"\r\n        \" * Offset: testParameter = 0x28\\n\"\r\n        \"*/\\n\"\r\n        \"#define \" + headerRegister1->name().toUpper() + \" 0x28\\n\"\r\n        \"/*\\n\"\r\n        \" * Register name: \" + headerRegister2->name() + \"\\n\"\r\n        \" * Offset: testParameter * 2 = 0x50\\n\"\r\n        \"*/\\n\"\r\n        \"#define \" + headerRegister2->name().toUpper() + \" 0x50\\n\"\r\n         \"/*\\n\"\r\n        \" * Register name: \" + headerRegister3->name() + \"\\n\"\r\n        \" * Offset: 'h4 + testParameter = 0x2c\\n\"\r\n        \"*/\\n\"\r\n        \"#define \" + headerRegister3->name().toUpper() + \" 0x2c\\n\"\r\n        \"\\n\"\r\n        \"#endif /* \" + headerDefine + \" */\\n\"\r\n    );\r\n\r\n    if (!output_.contains(expectedOutput))\r\n    {\r\n        QStringList outputLines = output_.split(\"\\n\");\r\n        QStringList expectedLines = expectedOutput.split(\"\\n\");\r\n\r\n        QVERIFY(outputLines.count() >= expectedLines.count());\r\n\r\n        int lineOffset = outputLines.indexOf(expectedLines.first());\r\n        if (lineOffset == -1)\r\n        {\r\n            readOutPutFile();\r\n            QCOMPARE(output_, expectedOutput);\r\n        }\r\n        else\r\n        {\r\n            int lineCount = expectedLines.count();\r\n            for (int i = 0; i < lineCount; ++i)\r\n            {\r\n                QCOMPARE(outputLines.at(i + lineOffset), expectedLines.at(i));\r\n            }\r\n        }\r\n    }\r\n    else if (output_.count(expectedOutput) != 1)\r\n    {\r\n        QVERIFY2(false, QString(expectedOutput + \" was found \" + QString::number(output_.count(expectedOutput)) +\r\n            \" times in output.\").toLocal8Bit());\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_MemoryMapHeaderGenerator::testLocalMemoryMapAddressBlockIsMemory()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_MemoryMapHeaderGenerator::testLocalMemoryMapAddressBlockIsMemoryOrReserved()\r\n{\r\n    QSharedPointer<Parameter> referencedParameter = createTestParameter(\"refParam\", \"ID\", \"14\");\r\n    topComponent_->getParameters()->append(referencedParameter);\r\n\r\n    QSharedPointer<AddressBlock> memoryAddressBlock = createTestAddressBlock(\"headerOne\",\r\n        QList<QSharedPointer<Register> > ());\r\n    memoryAddressBlock->setUsage(General::MEMORY);\r\n    memoryAddressBlock->setWidth(\"4 * 8\");\r\n    memoryAddressBlock->setRange(\"8\");\r\n    memoryAddressBlock->setBaseAddress(\"ID + 2\");\r\n\r\n    QSharedPointer<AddressBlock> reservedAddressBlock = createTestAddressBlock(\"headerTwo\",\r\n        QList<QSharedPointer<Register> > ());\r\n    reservedAddressBlock->setUsage(General::RESERVED);\r\n    reservedAddressBlock->setWidth(\"16\");\r\n    reservedAddressBlock->setRange(\"ID * ID\");\r\n\r\n    QList<QSharedPointer<AddressBlock> > addressList;\r\n    addressList.append(memoryAddressBlock);\r\n    addressList.append(reservedAddressBlock);\r\n\r\n    QSharedPointer<MemoryMap> localMemoryMap = createTestMemoryMap(\"localMap\", addressList);\r\n\r\n    QSharedPointer<AddressSpace> localAddressSpace = createTestAddressSpace(\"localSpace\", localMemoryMap);\r\n    QSharedPointer<QList<QSharedPointer<AddressSpace> > > addressSpaceList(new QList<QSharedPointer<AddressSpace> >());\r\n    addressSpaceList->append(localAddressSpace);\r\n\r\n    topComponent_->setAddressSpaces(addressSpaceList);\r\n\r\n    QFileInfo saveFileInfo (targetPath_);\r\n\r\n    headerGenerator_->setLocalSaveFileOptions(localMemoryMap, saveFileInfo, \"swView\");\r\n\r\n    QWidget parentWidget;\r\n    MessagePasser messageChannel;\r\n    PluginUtilityAdapter adapter(&library_, &messageChannel, QString(), &parentWidget);\r\n\r\n    headerGenerator_->runGenerator(&adapter, topComponent_, QSharedPointer<Design>(), QSharedPointer<DesignConfiguration>());\r\n\r\n    readOutPutFile();\r\n\r\n    QString headerDefine = \"__\" + topComponent_->getVlnv().toString(\"_\") + \"_\" + localMemoryMap->name() + \"_h\";\r\n    headerDefine = headerDefine.toUpper();\r\n\r\n    QString expectedOutput(\r\n        \"/*\\n\"\r\n        \" * File: generatorOutput.h\\n\"\r\n        \" * Created on: \" + QDate::currentDate().toString(\"dd.MM.yyyy\") + \"\\n\"\r\n        \" * Generated by: \\n\"\r\n        \" *\\n\"\r\n        \" * Description:\\n\"\r\n        \" * Header file generated by Kactus2 from local memory map \\\"\" + localMemoryMap->name() + \"\\\".\\n\"\r\n        \" * This file contains addresses of the memories and registers defined in the local memory map.\\n\"\r\n        \" * Source component: \" + topComponent_->getVlnv().toString(\":\") + \".\\n\"\r\n        \"*/\\n\"\r\n        \"\\n\"\r\n        \"#ifndef \" + headerDefine + \"\\n\"\r\n        \"#define \" + headerDefine + \"\\n\"\r\n        \"\\n\"\r\n        \"/*\\n\"\r\n        \" * Memory block name: \" + memoryAddressBlock->name() + \"\\n\"\r\n        \" * Width: 32 = \" + memoryAddressBlock->getWidth() + \"\\n\"\r\n        \" * Range: \" + memoryAddressBlock->getRange() + \"\\n\"\r\n        \"*/\\n\"\r\n        \"#define \" + memoryAddressBlock->name().toUpper() + \"_START 0x10 // refParam + 2\" +\r\n            \"\\n\"\r\n        \"#define \" + memoryAddressBlock->name().toUpper() + \"_END 0x17\\n\"\r\n        \"\\n\"\r\n         \"/*\\n\"\r\n         \" * Reserved block name: \" + reservedAddressBlock->name() + \"\\n\"\r\n         \" * Width: 16\\n\"\r\n         \" * Range: 196 = refParam * refParam\\n\"\r\n         \"*/\\n\"\r\n         \"#define \" + reservedAddressBlock->name().toUpper() + \"_START 0x\" +\r\n             reservedAddressBlock->getBaseAddress() + \"\\n\"\r\n         \"#define \" + reservedAddressBlock->name().toUpper() + \"_END 0xc3\\n\"\r\n         \"\\n\"\r\n         \"#endif /* \" + headerDefine + \" */\\n\"\r\n        );\r\n\r\n    if (!output_.contains(expectedOutput))\r\n    {\r\n        QStringList outputLines = output_.split(\"\\n\");\r\n        QStringList expectedLines = expectedOutput.split(\"\\n\");\r\n\r\n        QVERIFY(outputLines.count() >= expectedLines.count());\r\n\r\n        int lineOffset = outputLines.indexOf(expectedLines.first());\r\n        if (lineOffset == -1)\r\n        {\r\n            readOutPutFile();\r\n            QCOMPARE(output_, expectedOutput);\r\n        }\r\n        else\r\n        {\r\n            int lineCount = expectedLines.count();\r\n            for (int i = 0; i < lineCount; ++i)\r\n            {\r\n                QCOMPARE(outputLines.at(i + lineOffset), expectedLines.at(i));\r\n            }\r\n        }\r\n    }\r\n    else if (output_.count(expectedOutput) != 1)\r\n    {\r\n        QVERIFY2(false, QString(expectedOutput + \" was found \" + QString::number(output_.count(expectedOutput)) +\r\n            \" times in output.\").toLocal8Bit());\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_MemoryMapHeaderGenerator::testDesignMemoryMapHeaderGeneration()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_MemoryMapHeaderGenerator::testDesignMemoryMapHeaderGeneration()\r\n{\r\n    QSharedPointer<Component> masterComponent = createTestMasterComponent(\"masterComponent\", \"8\");\r\n    QSharedPointer<Component> slaveComponent = createTestSlaveComponent(\"slaveComponent\", \"4\");\r\n    QSharedPointer<Design> headerDesign = createTestHWDesign(\"testDesign\", masterComponent, slaveComponent);\r\n\r\n    library_.addComponent(masterComponent);\r\n    library_.writeModelToFile(\"C:/Test/TestLibrary/TestComponent/1.0/masterComponent.1.0.xml\", topComponent_);\r\n    library_.addComponent(slaveComponent);\r\n    library_.writeModelToFile(\"C:/Test/TestLibrary/TestComponent/1.0/slaveComponent.1.0.xml\", topComponent_);\r\n    library_.addComponent(headerDesign);\r\n    library_.writeModelToFile(\"C:/Test/TestLibrary/TestComponent/1.0/testDesign.1.0.xml\", topComponent_);\r\n    \r\n    QSharedPointer<View> headerTestView(new View(\"headerView\"));\r\n    headerTestView->setDesignInstantiationRef(\"testInstantiation\");\r\n    \r\n    QSharedPointer<DesignInstantiation> testInstatiation(new DesignInstantiation(\"testInstantiation\"));\r\n    testInstatiation->setDesignReference(QSharedPointer<ConfigurableVLNVReference>(\r\n        new ConfigurableVLNVReference(headerDesign->getVlnv())));\r\n\r\n    topComponent_->getDesignInstantiations()->append(testInstatiation); \r\n\r\n    topComponent_->getViews()->append(headerTestView);\r\n\r\n    QFileInfo saveFileInfo (targetPath_);\r\n\r\n\theaderGenerator_->setGlobalSaveFileOptions(masterComponent, \"masterInstance_0\", \"masterID\",\r\n\t\tmasterComponent->getBusInterfaceNames().at(0), saveFileInfo);\r\n\r\n    QWidget parentWidget;\r\n    MessagePasser messageChannel;\r\n    PluginUtilityAdapter adapter(&library_, &messageChannel, QString(), &parentWidget);\r\n\r\n    QSignalSpy generatorSpy(&messageChannel, SIGNAL(noticeMessage(QString const&)));\r\n\r\n    headerGenerator_->runGenerator(&adapter, topComponent_, headerDesign, QSharedPointer<DesignConfiguration>());\r\n\r\n    QCOMPARE(generatorSpy.count(), 4);\r\n\r\n    auto locale = QLocale::system();\r\n\r\n    QString initialMessage = generatorSpy.first().at(0).toString();\r\n    QCOMPARE(initialMessage, QString(\"Running %1 %2.\").arg(headerGenerator_->getName(),\r\n        headerGenerator_->getVersion()));\r\n    QString generatorStartMessage = generatorSpy.at(1).first().toString();\r\n    QCOMPARE(generatorStartMessage, QString(\"Generation started %1 %2\").arg(locale.toString(QDate::currentDate(), locale.dateFormat(QLocale::ShortFormat)))\r\n        .arg(locale.toString(QTime::currentTime(), locale.timeFormat(QLocale::ShortFormat))));\r\n    QString writingFinishedMessage = generatorSpy.at(2).first().toString();\r\n    QCOMPARE(writingFinishedMessage, QString(\"Finished writing file generatorOutput.h.\"));\r\n    QString generatorFinishedMessage = generatorSpy.at(3).first().toString();\r\n    QCOMPARE(generatorFinishedMessage, QString(\"Generation complete.\"));\r\n\r\n\r\n    readOutPutFile();\r\n\r\n    QString headerDefine = \"__MASTERINSTANCE_0_\" + masterComponent->getBusInterfaceNames().at(0).toUpper() + \"_H\";\r\n\r\n    QString expectedOutput(\r\n        \"/*\\n\"\r\n        \" * File: generatorOutput.h\\n\"\r\n        \" * Created on: \" + QDate::currentDate().toString(\"dd.MM.yyyy\") + \"\\n\"\r\n        \" * Generated by: \\n\"\r\n        \" *\\n\"\r\n        \" * Description:\\n\"\r\n        \" * Header file generated by Kactus2 for instance \\\"masterInstance_0\\\" interface \\\"masterBusInterface\\\".\\n\"\r\n        \" * This file contains addresses of the memories and registers defined in the memory maps of connected \"\r\n            \"components.\\n\"\r\n        \" * Source component: \" + masterComponent->getVlnv().toString(\":\") + \".\\n\"\r\n        \"*/\\n\"\r\n        \"\\n\"\r\n        \"#ifndef \" + headerDefine + \"\\n\"\r\n        \"#define \" + headerDefine + \"\\n\"\r\n        \"\\n\"\r\n        \"/*\\n\"\r\n        \" * Instance: slaveInstance_0 Interface: slaveBusInterface\\n\"\r\n        \" * Instance base address: 0x8\\n\"\r\n        \" * Source component: \" + slaveComponent->getVlnv().toString(\":\") + \"\\n\"\r\n        \" * The defines for the memory map \\\"slaveMemoryMap\\\":\\n\"\r\n        \"*/\\n\"\r\n        \"\\n\"\r\n        \"/*\\n\"\r\n        \" * Address block: slaveAddressBlock\\n\"\r\n        \"*/\\n\"\r\n        \"/*\\n\"\r\n        \" * Register name: slaveRegister\\n\"\r\n        \" * Offset: 0x4\\n\"\r\n        \"*/\\n\"\r\n        \"#define SLAVEINSTANCE_0_SLAVEREGISTER 0xc\\n\"\r\n        \"\\n\"\r\n        \"#endif /* \" + headerDefine + \" */\"\r\n        );\r\n\r\n    if (!output_.contains(expectedOutput))\r\n    {\r\n        QStringList outputLines = output_.split(\"\\n\");\r\n        QStringList expectedLines = expectedOutput.split(\"\\n\");\r\n\r\n        QVERIFY(outputLines.count() >= expectedLines.count());\r\n\r\n        int lineOffset = outputLines.indexOf(expectedLines.first());\r\n        if (lineOffset == -1)\r\n        {\r\n            readOutPutFile();\r\n            QCOMPARE(output_, expectedOutput);\r\n        }\r\n        else\r\n        {\r\n            int lineCount = expectedLines.count();\r\n            for (int i = 0; i < lineCount; ++i)\r\n            {\r\n                QCOMPARE(outputLines.at(i + lineOffset), expectedLines.at(i));\r\n            }\r\n        }\r\n    }\r\n    else if (output_.count(expectedOutput) != 1)\r\n    {\r\n        QVERIFY2(false, QString(expectedOutput + \" was found \" + QString::number(output_.count(expectedOutput)) +\r\n            \" times in output.\").toLocal8Bit());\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_MemoryMapHeaderGenerator::testDesignMemoryMapHeaderGenerationWithMultipleSlaves()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_MemoryMapHeaderGenerator::testMemoryMapHeaderGenerationInDesignWithMultipleSlaves()\r\n{\r\n    QSharedPointer<Component> masterComponent = createTestMasterComponent(\"masterComponent\", \"0\");\r\n    QSharedPointer<Component> slaveComponent = createTestSlaveComponent(\"slaveComponent\", \"4\");\r\n    QSharedPointer<Component> slaveComponentTwo = createTestSlaveComponent(\"slaveComponentTwo\", \"8\");\r\n\r\n    QSharedPointer<Design> headerDesign (new Design(VLNV(VLNV::DESIGN, \"TUT\", \"TestLibrary\", \"headerDesign\",\r\n        \"1.0\"), Document::Revision::Std14));\r\n\r\n    library_.addComponent(masterComponent);\r\n    library_.writeModelToFile(\"C:/Test/TestLibrary/TestComponent/1.0/masterComponent.1.0.xml\", topComponent_);\r\n    library_.addComponent(slaveComponent);\r\n    library_.writeModelToFile(\"C:/Test/TestLibrary/TestComponent/1.0/slaveComponent.1.0.xml\", topComponent_);\r\n    library_.addComponent(slaveComponentTwo);\r\n    library_.writeModelToFile(\"C:/Test/TestLibrary/TestComponent/1.0/slaveComponentTwo.1.0.xml\", topComponent_);\r\n    library_.addComponent(headerDesign);\r\n    library_.writeModelToFile(\"C:/Test/TestLibrary/TestComponent/1.0/testDesign.1.0.xml\", topComponent_);\r\n\r\n    QSharedPointer<ComponentInstance> masterInstance (new ComponentInstance(\"masterInstance_0\", \r\n        QSharedPointer<ConfigurableVLNVReference>(new ConfigurableVLNVReference(masterComponent->getVlnv())))); \r\n    masterInstance->setUuid(\"masterID\");\r\n\r\n    QSharedPointer<ComponentInstance> slaveInstanceOne (new ComponentInstance(\"slaveInstance_0\", \r\n        QSharedPointer<ConfigurableVLNVReference>(new ConfigurableVLNVReference(slaveComponent->getVlnv())))); \r\n    slaveInstanceOne->setUuid(\"slaveID_0\");\r\n\r\n    QSharedPointer<ComponentInstance> slaveInstanceTwo (new ComponentInstance(\"slaveInstance_1\",\r\n        QSharedPointer<ConfigurableVLNVReference>(new ConfigurableVLNVReference(slaveComponent->getVlnv()))));\r\n    slaveInstanceTwo->setUuid(\"slaveID_1\");\r\n\r\n    QSharedPointer<ComponentInstance> slaveInstanceThree (new ComponentInstance(\"slaveInstanceTwo_0\",\r\n        QSharedPointer<ConfigurableVLNVReference>(new ConfigurableVLNVReference(slaveComponentTwo->getVlnv()))));\r\n    slaveInstanceThree->setUuid(\"slaveIDTwo_0\");\r\n    \r\n    QSharedPointer<QList<QSharedPointer<ComponentInstance> > > componentInstances(\r\n        new QList<QSharedPointer<ComponentInstance> >());\r\n    componentInstances->append(masterInstance);\r\n    componentInstances->append(slaveInstanceOne);\r\n    componentInstances->append(slaveInstanceTwo);\r\n    componentInstances->append(slaveInstanceThree);\r\n    headerDesign->setComponentInstances(componentInstances);\r\n\r\n    QSharedPointer<ActiveInterface> interfaceMaster (\r\n        new ActiveInterface(masterInstance->getInstanceName(), masterComponent->getBusInterfaceNames().at(0)));\r\n    QSharedPointer<ActiveInterface> interfaceSlaveOne (new ActiveInterface(\r\n        slaveInstanceOne->getInstanceName(), slaveComponent->getBusInterfaceNames().at(0)));\r\n    QSharedPointer<ActiveInterface> interfaceSlaveTwo (new ActiveInterface(\r\n        slaveInstanceTwo->getInstanceName(), slaveComponent->getBusInterfaceNames().at(0)));\r\n    QSharedPointer<ActiveInterface> interfaceSlaveThree (new ActiveInterface(\r\n        slaveInstanceThree->getInstanceName(), slaveComponent->getBusInterfaceNames().at(0)));\r\n\r\n    QSharedPointer<Interconnection> masterSlaveOneConnection(\r\n        new Interconnection(\"masterSlaveOne\", interfaceMaster));\r\n    masterSlaveOneConnection->getActiveInterfaces()->append(interfaceSlaveOne);\r\n\r\n    QSharedPointer<Interconnection> masterSlaveTwoConnection(new Interconnection(\r\n        \"masterSlaveTwo\", interfaceMaster));\r\n    masterSlaveTwoConnection->getActiveInterfaces()->append(interfaceSlaveTwo);\r\n\r\n    QSharedPointer<Interconnection> masterSlaveThreeConnection(new Interconnection(\r\n        \"msaterSlaveThree\", interfaceMaster));\r\n    masterSlaveThreeConnection->getActiveInterfaces()->append(interfaceSlaveThree);\r\n\r\n    QSharedPointer<QList<QSharedPointer<Interconnection> > >  interconnectionList = \r\n        headerDesign->getInterconnections();\r\n    interconnectionList->append(masterSlaveOneConnection);\r\n    interconnectionList->append(masterSlaveTwoConnection);\r\n    interconnectionList->append(masterSlaveThreeConnection);\r\n    \r\n    QSharedPointer<View> headerTestView(new View(\"headerView\"));\r\n    \r\n    headerTestView->setDesignInstantiationRef(\"testInstantiation\");\r\n    \r\n    QSharedPointer<DesignInstantiation> testInstatiation(new DesignInstantiation(\"testInstantiation\"));\r\n    testInstatiation->setDesignReference(QSharedPointer<ConfigurableVLNVReference>(\r\n        new ConfigurableVLNVReference(headerDesign->getVlnv())));\r\n\r\n    topComponent_->getViews()->append(headerTestView);\r\n    topComponent_->getDesignInstantiations()->append(testInstatiation);\r\n\r\n    QFileInfo saveFileInfo (targetPath_);\r\n\r\n\theaderGenerator_->setGlobalSaveFileOptions(masterComponent, \"masterInstance_0\", \"masterID\",\r\n\t\tmasterComponent->getBusInterfaceNames().at(0), saveFileInfo);\r\n\r\n    QWidget parentWidget;\r\n\r\n    MessagePasser messageChannel;\r\n    PluginUtilityAdapter adapter(&library_, &messageChannel, QString(), &parentWidget);\r\n\r\n    headerGenerator_->runGenerator(&adapter, topComponent_, headerDesign, QSharedPointer<DesignConfiguration>());\r\n\r\n    readOutPutFile();\r\n\r\n    QString headerDefine = \"__MASTERINSTANCE_0_\" + masterComponent->getBusInterfaceNames().at(0).toUpper() + \"_H\";\r\n\r\n    QString expectedOutput(\r\n        \"/*\\n\"\r\n        \" * File: generatorOutput.h\\n\"\r\n        \" * Created on: \" + QDate::currentDate().toString(\"dd.MM.yyyy\") + \"\\n\"\r\n        \" * Generated by: \\n\"\r\n        \" *\\n\"\r\n        \" * Description:\\n\"\r\n        \" * Header file generated by Kactus2 for instance \\\"masterInstance_0\\\" interface \\\"masterBusInterface\\\".\\n\"\r\n        \" * This file contains addresses of the memories and registers defined in the memory maps of connected \"\r\n            \"components.\\n\"\r\n        \" * Source component: \" + masterComponent->getVlnv().toString(\":\") + \".\\n\"\r\n        \"*/\\n\"\r\n        \"\\n\"\r\n        \"#ifndef \" + headerDefine + \"\\n\"\r\n        \"#define \" + headerDefine + \"\\n\"\r\n        \"\\n\"\r\n        \"/*\\n\"\r\n        \" * Instance: \" + slaveInstanceOne->getInstanceName() + \" Interface: \" +\r\n            slaveComponent->getBusInterfaceNames().at(0) + \"\\n\"\r\n        \" * Instance base address: 0x0\\n\"\r\n        \" * Source component: \" + slaveComponent->getVlnv().toString(\":\") + \"\\n\"\r\n        \" * The defines for the memory map \\\"slaveMemoryMap\\\":\\n\"\r\n        \"*/\\n\"\r\n        \"\\n\"\r\n        \"/*\\n\"\r\n        \" * Address block: slaveAddressBlock\\n\"\r\n        \"*/\\n\"\r\n        \"/*\\n\"\r\n        \" * Register name: slaveRegister\\n\"\r\n        \" * Offset: 0x4\\n\"\r\n        \"*/\\n\"\r\n        \"#define \" + slaveInstanceOne->getInstanceName().toUpper() + \"_SLAVEREGISTER 0x4\\n\"\r\n        \"\\n\"\r\n        \"/*\\n\"\r\n        \" * Instance: \" + slaveInstanceTwo->getInstanceName() + \" Interface: \" +\r\n            slaveComponent->getBusInterfaceNames().at(0) + \"\\n\"\r\n        \" * Instance base address: 0x0\\n\"\r\n        \" * Source component: \" + slaveComponent->getVlnv().toString(\":\") + \"\\n\"\r\n        \" * The defines for the memory map \\\"slaveMemoryMap\\\":\\n\"\r\n        \"*/\\n\"\r\n        \"\\n\"\r\n        \"/*\\n\"\r\n        \" * Address block: slaveAddressBlock\\n\"\r\n        \"*/\\n\"\r\n        \"/*\\n\"\r\n        \" * Register name: slaveRegister\\n\"\r\n        \" * Offset: 0x4\\n\"\r\n        \"*/\\n\"\r\n        \"#define \" + slaveInstanceTwo->getInstanceName().toUpper() + \"_SLAVEREGISTER 0x4\\n\"\r\n        \"\\n\"\r\n        \"/*\\n\"\r\n        \" * Instance: \" + slaveInstanceThree->getInstanceName() + \" Interface: \" +\r\n            slaveComponentTwo->getBusInterfaceNames().at(0) + \"\\n\"\r\n        \" * Instance base address: 0x0\\n\"\r\n        \" * Source component: \" + slaveComponentTwo->getVlnv().toString(\":\") + \"\\n\"\r\n        \" * The defines for the memory map \\\"slaveMemoryMap\\\":\\n\"\r\n        \"*/\\n\"\r\n        \"\\n\"\r\n        \"/*\\n\"\r\n        \" * Address block: slaveAddressBlock\\n\"\r\n        \"*/\\n\"\r\n        \"/*\\n\"\r\n        \" * Register name: slaveRegister\\n\"\r\n        \" * Offset: 0x8\\n\"\r\n        \"*/\\n\"\r\n        \"#define \" + slaveInstanceThree->getInstanceName().toUpper() + \"_SLAVEREGISTER 0x8\\n\"\r\n        \"\\n\"\r\n        );\r\n\r\n    if (!output_.contains(expectedOutput))\r\n    {\r\n        QStringList outputLines = output_.split(\"\\n\");\r\n        QStringList expectedLines = expectedOutput.split(\"\\n\");\r\n\r\n        QVERIFY(outputLines.count() >= expectedLines.count());\r\n\r\n        int lineOffset = outputLines.indexOf(expectedLines.first());\r\n        if (lineOffset == -1)\r\n        {\r\n            readOutPutFile();\r\n            QCOMPARE(output_, expectedOutput);\r\n        }\r\n        else\r\n        {\r\n            int lineCount = expectedLines.count();\r\n            for (int i = 0; i < lineCount; ++i)\r\n            {\r\n                QCOMPARE(outputLines.at(i + lineOffset), expectedLines.at(i));\r\n            }\r\n        }\r\n    }\r\n    else if (output_.count(expectedOutput) != 1)\r\n    {\r\n        QVERIFY2(false, QString(expectedOutput + \" was found \" + QString::number(output_.count(expectedOutput)) +\r\n            \" times in output.\").toLocal8Bit());\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_MemoryMapHeaderGenerator::testDesignMemoryMapHeaderWithReferences()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_MemoryMapHeaderGenerator::testDesignMemoryMapHeaderWithReferences()\r\n{\r\n    QSharedPointer<Parameter> masterParameter = createTestParameter(\"masterParameter\", \"param_ID\", \"14\");\r\n    QSharedPointer<Parameter> slaveParameter = createTestParameter(\"slaveParameter\", \"param_ID\", \"10\");\r\n\r\n    QSharedPointer<Component> masterComponent = createTestMasterComponent(\"masterComponent\", \"8\");\r\n    QSharedPointer<Component> slaveComponent = createTestSlaveComponent(\"slaveComponent\", \"4 * param_ID\");\r\n    QSharedPointer<Design> headerDesign = createTestHWDesign(\"testDesign\", masterComponent, slaveComponent);\r\n\r\n    masterComponent->getParameters()->append(masterParameter);\r\n    slaveComponent->getParameters()->append(slaveParameter);\r\n\r\n    library_.addComponent(masterComponent);\r\n    library_.writeModelToFile(\"C:/Test/TestLibrary/TestComponent/1.0/masterComponent.1.0.xml\", topComponent_);\r\n    library_.addComponent(slaveComponent);\r\n    library_.writeModelToFile(\"C:/Test/TestLibrary/TestComponent/1.0/slaveComponent.1.0.xml\", topComponent_);\r\n    library_.addComponent(headerDesign);\r\n    library_.writeModelToFile(\"C:/Test/TestLibrary/TestComponent/1.0/testDesign.1.0.xml\", topComponent_);\r\n    \r\n    QSharedPointer<View> headerTestView(new View(\"headerView\"));\r\n    headerTestView->setDesignInstantiationRef(\"testInstantiation\");\r\n\r\n    QSharedPointer<DesignInstantiation> testInstatiation(new DesignInstantiation(\"testInstantiation\"));\r\n    testInstatiation->setDesignReference(QSharedPointer<ConfigurableVLNVReference>(\r\n        new ConfigurableVLNVReference(headerDesign->getVlnv())));\r\n\r\n    topComponent_->getViews()->append(headerTestView);\r\n    topComponent_->getDesignInstantiations()->append(testInstatiation);\r\n\r\n    QFileInfo saveFileInfo (targetPath_);\r\n\r\n\theaderGenerator_->setGlobalSaveFileOptions(masterComponent, \"masterInstance_0\", \"masterID\",\r\n\t\tmasterComponent->getBusInterfaceNames().at(0), saveFileInfo);\r\n\r\n    QWidget parentWidget;\r\n    MessagePasser messageChannel;\r\n    PluginUtilityAdapter adapter(&library_, &messageChannel, QString(), &parentWidget);\r\n\r\n\r\n    headerGenerator_->runGenerator(&adapter, topComponent_, headerDesign, QSharedPointer<DesignConfiguration>());\r\n\r\n    readOutPutFile();\r\n\r\n    QString headerDefine = \"__MASTERINSTANCE_0_\" + masterComponent->getBusInterfaceNames().at(0).toUpper() + \"_H\";\r\n\r\n    QString expectedOutput(\r\n        \"/*\\n\"\r\n        \" * File: generatorOutput.h\\n\"\r\n        \" * Created on: \" + QDate::currentDate().toString(\"dd.MM.yyyy\") + \"\\n\"\r\n        \" * Generated by: \\n\"\r\n        \" *\\n\"\r\n        \" * Description:\\n\"\r\n        \" * Header file generated by Kactus2 for instance \\\"masterInstance_0\\\" interface \\\"masterBusInterface\\\".\\n\"\r\n        \" * This file contains addresses of the memories and registers defined in the memory maps of connected \"\r\n            \"components.\\n\"\r\n        \" * Source component: \" + masterComponent->getVlnv().toString(\":\") + \".\\n\"\r\n        \"*/\\n\"\r\n        \"\\n\"\r\n        \"#ifndef \" + headerDefine + \"\\n\"\r\n        \"#define \" + headerDefine + \"\\n\"\r\n        \"\\n\"\r\n        \"/*\\n\"\r\n        \" * Instance: slaveInstance_0 Interface: slaveBusInterface\\n\"\r\n        \" * Instance base address: 0x8\\n\"\r\n        \" * Source component: \" + slaveComponent->getVlnv().toString(\":\") + \"\\n\"\r\n        \" * The defines for the memory map \\\"slaveMemoryMap\\\":\\n\"\r\n        \"*/\\n\"\r\n        \"\\n\"\r\n        \"/*\\n\"\r\n        \" * Address block: slaveAddressBlock\\n\"\r\n        \"*/\\n\"\r\n        \"/*\\n\"\r\n        \" * Register name: slaveRegister\\n\"\r\n        \" * Offset: 4 * slaveParameter = 0x28\\n\"\r\n        \"*/\\n\"\r\n        \"#define SLAVEINSTANCE_0_SLAVEREGISTER 0x30\\n\"\r\n        \"\\n\"\r\n        \"#endif /* \" + headerDefine + \" */\"\r\n        );\r\n\r\n    if (!output_.contains(expectedOutput))\r\n    {\r\n        QStringList outputLines = output_.split(\"\\n\");\r\n        QStringList expectedLines = expectedOutput.split(\"\\n\");\r\n\r\n        QVERIFY(outputLines.count() >= expectedLines.count());\r\n\r\n        int lineOffset = outputLines.indexOf(expectedLines.first());\r\n        if (lineOffset == -1)\r\n        {\r\n            readOutPutFile();\r\n            QCOMPARE(output_, expectedOutput);\r\n        }\r\n        else\r\n        {\r\n            int lineCount = expectedLines.count();\r\n            for (int i = 0; i < lineCount; ++i)\r\n            {\r\n                QCOMPARE(outputLines.at(i + lineOffset), expectedLines.at(i));\r\n            }\r\n        }\r\n    }\r\n    else if (output_.count(expectedOutput) != 1)\r\n    {\r\n        QVERIFY2(false, QString(expectedOutput + \" was found \" + QString::number(output_.count(expectedOutput)) +\r\n            \" times in output.\").toLocal8Bit());\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_MemoryMapHeaderGenerator::testDesignMemoryMapHeaderWithMasterReference()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_MemoryMapHeaderGenerator::testDesignMemoryMapHeaderWithMasterReference()\r\n{\r\n    QSharedPointer<Parameter> masterParameter = createTestParameter(\"masterParameter\", \"master_ID\", \"14\");\r\n    QSharedPointer<Parameter> slaveParameter = createTestParameter(\"slaveParameter\", \"param_ID\", \"10\");\r\n    QSharedPointer<Parameter> slaveParameterZero = createTestParameter(\"slaveZero\", \"zero_ID\", \"2\");\r\n\r\n    QSharedPointer<Component> masterComponent = createTestMasterComponent(\"masterComponent\", \"master_ID + 4\");\r\n    QSharedPointer<Component> slaveComponent = createTestSlaveComponent(\"slaveComponent\", \"zero_ID * param_ID\");\r\n    QSharedPointer<Design> headerDesign = createTestHWDesign(\"testDesign\", masterComponent, slaveComponent);\r\n\r\n    masterComponent->getParameters()->append(masterParameter);\r\n    slaveComponent->getParameters()->append(slaveParameter);\r\n    slaveComponent->getParameters()->append(slaveParameterZero);\r\n\r\n    library_.addComponent(masterComponent);\r\n    library_.writeModelToFile(\"C:/Test/TestLibrary/TestComponent/1.0/masterComponent.1.0.xml\", topComponent_);\r\n    library_.addComponent(slaveComponent);\r\n    library_.writeModelToFile(\"C:/Test/TestLibrary/TestComponent/1.0/slaveComponent.1.0.xml\", topComponent_);\r\n    library_.addComponent(headerDesign);\r\n    library_.writeModelToFile(\"C:/Test/TestLibrary/TestComponent/1.0/testDesign.1.0.xml\", topComponent_);\r\n    \r\n    QSharedPointer<View> headerTestView(new View(\"headerView\"));\r\n    headerTestView->setDesignInstantiationRef(\"testInstantiation\");\r\n\r\n    QSharedPointer<DesignInstantiation> testInstatiation(new DesignInstantiation(\"testInstantiation\"));\r\n    testInstatiation->setDesignReference(QSharedPointer<ConfigurableVLNVReference>(\r\n        new ConfigurableVLNVReference(headerDesign->getVlnv())));\r\n\r\n    topComponent_->getViews()->append(headerTestView);\r\n    topComponent_->getDesignInstantiations()->append(testInstatiation);\r\n\r\n    QFileInfo saveFileInfo (targetPath_);\r\n\r\n\theaderGenerator_->setGlobalSaveFileOptions(masterComponent, \"masterInstance_0\", \"masterID\",\r\n\t\tmasterComponent->getBusInterfaceNames().at(0), saveFileInfo);\r\n\r\n    QWidget parentWidget;\r\n    MessagePasser messageChannel;\r\n    PluginUtilityAdapter adapter(&library_, &messageChannel, QString(), &parentWidget);\r\n\r\n        headerGenerator_->runGenerator(&adapter, topComponent_, headerDesign, QSharedPointer<DesignConfiguration>());\r\n\r\n    readOutPutFile();\r\n\r\n    QString headerDefine = \"__MASTERINSTANCE_0_\" + masterComponent->getBusInterfaceNames().at(0).toUpper() + \"_H\";\r\n\r\n    QString expectedOutput(\r\n        \"/*\\n\"\r\n        \" * File: generatorOutput.h\\n\"\r\n        \" * Created on: \" + QDate::currentDate().toString(\"dd.MM.yyyy\") + \"\\n\"\r\n        \" * Generated by: \\n\"\r\n        \" *\\n\"\r\n        \" * Description:\\n\"\r\n        \" * Header file generated by Kactus2 for instance \\\"masterInstance_0\\\" interface \\\"masterBusInterface\\\".\\n\"\r\n        \" * This file contains addresses of the memories and registers defined in the memory maps of connected \"\r\n            \"components.\\n\"\r\n        \" * Source component: \" + masterComponent->getVlnv().toString(\":\") + \".\\n\"\r\n        \"*/\\n\"\r\n        \"\\n\"\r\n        \"#ifndef \" + headerDefine + \"\\n\"\r\n        \"#define \" + headerDefine + \"\\n\"\r\n        \"\\n\"\r\n        \"/*\\n\"\r\n        \" * Instance: slaveInstance_0 Interface: slaveBusInterface\\n\"\r\n        \" * Instance base address: 0x12\\n\"\r\n        \" * Source component: \" + slaveComponent->getVlnv().toString(\":\") + \"\\n\"\r\n        \" * The defines for the memory map \\\"slaveMemoryMap\\\":\\n\"\r\n        \"*/\\n\"\r\n        \"\\n\"\r\n        \"/*\\n\"\r\n        \" * Address block: slaveAddressBlock\\n\"\r\n        \"*/\\n\"\r\n        \"/*\\n\"\r\n        \" * Register name: slaveRegister\\n\"\r\n        \" * Offset: slaveZero * slaveParameter = 0x14\\n\"\r\n        \"*/\\n\"\r\n        \"#define SLAVEINSTANCE_0_SLAVEREGISTER 0x26\\n\"\r\n        \"\\n\"\r\n        \"#endif /* \" + headerDefine + \" */\"\r\n        );\r\n\r\n    if (!output_.contains(expectedOutput))\r\n    {\r\n        QStringList outputLines = output_.split(\"\\n\");\r\n        QStringList expectedLines = expectedOutput.split(\"\\n\");\r\n\r\n        QVERIFY(outputLines.count() >= expectedLines.count());\r\n\r\n        int lineOffset = outputLines.indexOf(expectedLines.first());\r\n        if (lineOffset == -1)\r\n        {\r\n            readOutPutFile();\r\n            QCOMPARE(output_, expectedOutput);\r\n        }\r\n        else\r\n        {\r\n            int lineCount = expectedLines.count();\r\n            for (int i = 0; i < lineCount; ++i)\r\n            {\r\n                QCOMPARE(outputLines.at(i + lineOffset), expectedLines.at(i));\r\n            }\r\n        }\r\n    }\r\n    else if (output_.count(expectedOutput) != 1)\r\n    {\r\n        QVERIFY2(false, QString(expectedOutput + \" was found \" + QString::number(output_.count(expectedOutput)) +\r\n            \" times in output.\").toLocal8Bit());\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_MemoryMapHeaderGenerator::testDesignMemoryMapHeaderWithConfigurableElements()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_MemoryMapHeaderGenerator::testDesignMemoryMapHeaderWithConfigurableElements()\r\n{\r\n    QSharedPointer<Parameter> slaveParameter = createTestParameter(\"slaveParameter\", \"param_ID\", \"10\");\r\n    QSharedPointer<Parameter> otherSlaveParameter = createTestParameter(\"otherParameter\", \"other_ID\", \"14\");\r\n\r\n    QSharedPointer<Component> masterComponent = createTestMasterComponent(\"masterComponent\", \"0\");\r\n\r\n    QSharedPointer<Component> slaveComponent (new Component(VLNV(VLNV::COMPONENT, \"TUT\", \"TestLibrary\",\r\n        \"slaveComponent\", \"1.0\"), Document::Revision::Std14));\r\n\r\n    QSharedPointer<Register> slaveRegister = createTestRegister(\"slaveRegister\", \"param_ID * 6\");\r\n    QSharedPointer<Register> otherSlaveRegister = createTestRegister(\"otherRegister\", \"other_ID + 2\");\r\n    QList<QSharedPointer<Register> > slaveRegisterList;\r\n    slaveRegisterList.append(slaveRegister);\r\n    slaveRegisterList.append(otherSlaveRegister);\r\n\r\n    QSharedPointer<AddressBlock> slaveAddress = createTestAddressBlock(\"slaveAddress\", slaveRegisterList);\r\n    QList<QSharedPointer<AddressBlock> > slaveAddressList;\r\n    slaveAddressList.append(slaveAddress);\r\n\r\n    QSharedPointer<MemoryMap> slaveMemory = createTestMemoryMap(\"slaveMemory\", slaveAddressList);\r\n\r\n    QSharedPointer<BusInterface> slaveBus (new BusInterface());\r\n    slaveBus->setName(\"slaveBusInterface\");\r\n    QSharedPointer<TargetInterface> enslavedInterface(new TargetInterface);\r\n    enslavedInterface->setMemoryMapRef(slaveMemory->name());\r\n    slaveBus->setSlave(enslavedInterface);\r\n\r\n    slaveComponent->getMemoryMaps()->append(slaveMemory);\r\n\r\n    slaveComponent->getBusInterfaces()->append(slaveBus);\r\n\r\n    slaveComponent->getParameters()->append(slaveParameter);\r\n    slaveComponent->getParameters()->append(otherSlaveParameter);\r\n\r\n    QSharedPointer<Design> headerDesign (new Design(VLNV(VLNV::DESIGN, \"TUT\", \"TestLibrary\", \"testDesign\", \"1.0\"), \r\n        Document::Revision::Std14));\r\n\r\n    QSharedPointer<DesignConfiguration> headerDesignConfiguration (new DesignConfiguration(VLNV(\r\n        VLNV::DESIGNCONFIGURATION, \"TUT\", \"TestLibrary\", \"testDesignConfiguration\", \"1.0\"), Document::Revision::Std14));\r\n\r\n    QSharedPointer<ComponentInstance> masterInstance (new ComponentInstance(\"masterInstance_0\",\r\n        QSharedPointer<ConfigurableVLNVReference>(new ConfigurableVLNVReference(masterComponent->getVlnv()))));\r\n    masterInstance->setUuid(\"masterID\");\r\n\r\n    QSharedPointer<ComponentInstance> slaveInstance (new ComponentInstance(\"slaveInstance_0\",\r\n        QSharedPointer<ConfigurableVLNVReference>(new ConfigurableVLNVReference(slaveComponent->getVlnv()))));\r\n    slaveInstance->setUuid(\"slaveID\");\r\n\r\n    addConfigurableElementValueToInstance(slaveInstance, \"param_ID\", \"4\");\r\n    addConfigurableElementValueToInstance(slaveInstance, \"other_ID\", \"param_ID + 20\");\r\n\r\n    headerDesign->getComponentInstances()->append(masterInstance);\r\n    headerDesign->getComponentInstances()->append(slaveInstance);\r\n\r\n    QSharedPointer<ActiveInterface> interfaceMaster(\r\n        new ActiveInterface(masterInstance->getInstanceName(), masterComponent->getBusInterfaceNames().at(0)));\r\n    QSharedPointer<ActiveInterface> interfaceSlave (\r\n        new ActiveInterface(slaveInstance->getInstanceName(), slaveComponent->getBusInterfaceNames().at(0)));\r\n\r\n    QSharedPointer<Interconnection> masterSlaveConnection(new Interconnection(\"masterSlaveConnection\", interfaceMaster));\r\n    masterSlaveConnection->getActiveInterfaces()->append(interfaceSlave);\r\n\r\n    headerDesign->getInterconnections()->append(masterSlaveConnection);\r\n\r\n    library_.addComponent(masterComponent);\r\n    library_.writeModelToFile(\"C:/Test/TestLibrary/TestComponent/1.0/masterComponent.1.0.xml\", topComponent_);\r\n    library_.addComponent(slaveComponent);\r\n    library_.writeModelToFile(\"C:/Test/TestLibrary/TestComponent/1.0/slaveComponent.1.0.xml\", topComponent_);\r\n    library_.addComponent(headerDesign);\r\n    library_.writeModelToFile(\"C:/Test/TestLibrary/TestComponent/1.0/testDesign.1.0.xml\", topComponent_);\r\n    library_.addComponent(headerDesignConfiguration);\r\n    library_.writeModelToFile(\"C:/Test/TestLibrary/TestComponent/1.0/testDesignConfiguration.1.0.xml\",\r\n        topComponent_);\r\n\r\n    QSharedPointer<View> headerTestView(new View(\"headerView\"));\r\n    headerTestView->setDesignInstantiationRef(\"testInstantiation\");\r\n\r\n    QSharedPointer<DesignInstantiation> testInstatiation(new DesignInstantiation(\"testInstantiation\"));\r\n    testInstatiation->setDesignReference(QSharedPointer<ConfigurableVLNVReference>(\r\n        new ConfigurableVLNVReference(headerDesign->getVlnv())));\r\n\r\n    topComponent_->getViews()->append(headerTestView);\r\n    topComponent_->getDesignInstantiations()->append(testInstatiation);\r\n\r\n    QFileInfo saveFileInfo (targetPath_);\r\n\r\n    headerGenerator_->setGlobalSaveFileOptions(masterComponent, \"masterInstance_0\", \"masterID\",\r\n        masterComponent->getBusInterfaceNames().at(0), saveFileInfo);\r\n\r\n    QWidget parentWidget;\r\n    MessagePasser messageChannel;\r\n    PluginUtilityAdapter adapter(&library_, &messageChannel, QString(), &parentWidget);\r\n\r\n\r\n    headerGenerator_->runGenerator(&adapter, topComponent_, headerDesign, headerDesignConfiguration);\r\n\r\n    readOutPutFile();\r\n\r\n    QString headerDefine = \"__MASTERINSTANCE_0_\" + masterComponent->getBusInterfaceNames().at(0).toUpper() + \"_H\";\r\n\r\n    QString expectedOutput(\r\n        \"/*\\n\"\r\n        \" * File: generatorOutput.h\\n\"\r\n        \" * Created on: \" + QDate::currentDate().toString(\"dd.MM.yyyy\") + \"\\n\"\r\n        \" * Generated by: \\n\"\r\n        \" *\\n\"\r\n        \" * Description:\\n\"\r\n        \" * Header file generated by Kactus2 for instance \\\"masterInstance_0\\\" interface \\\"masterBusInterface\\\".\\n\"\r\n        \" * This file contains addresses of the memories and registers defined in the memory maps of connected \"\r\n            \"components.\\n\"\r\n        \" * Source component: \" + masterComponent->getVlnv().toString(\":\") + \".\\n\"\r\n        \"*/\\n\"\r\n        \"\\n\"\r\n        \"#ifndef \" + headerDefine + \"\\n\"\r\n        \"#define \" + headerDefine + \"\\n\"\r\n        \"\\n\"\r\n        \"/*\\n\"\r\n        \" * Instance: slaveInstance_0 Interface: slaveBusInterface\\n\"\r\n        \" * Instance base address: 0x0\\n\"\r\n        \" * Source component: \" + slaveComponent->getVlnv().toString(\":\") + \"\\n\"\r\n        \" * The defines for the memory map \\\"slaveMemory\\\":\\n\"\r\n        \"*/\\n\"\r\n        \"\\n\"\r\n        \"/*\\n\"\r\n        \" * Address block: slaveAddress\\n\"\r\n        \"*/\\n\"\r\n        \"/*\\n\"\r\n        \" * Register name: slaveRegister\\n\"\r\n        \" * Offset: slaveParameter * 6 = 0x18\\n\"\r\n        \"*/\\n\"\r\n        \"#define SLAVEINSTANCE_0_SLAVEREGISTER 0x18\\n\"\r\n        \"/*\\n\"\r\n        \" * Register name: otherRegister\\n\"\r\n        \" * Offset: otherParameter + 2 = 0x1a\\n\"\r\n        \"*/\\n\"\r\n        \"#define SLAVEINSTANCE_0_OTHERREGISTER 0x1a\\n\"\r\n        \"\\n\"\r\n        \"#endif /* \" + headerDefine + \" */\"\r\n        );\r\n\r\n    if (!output_.contains(expectedOutput))\r\n    {\r\n        QStringList outputLines = output_.split(\"\\n\");\r\n        QStringList expectedLines = expectedOutput.split(\"\\n\");\r\n\r\n        QVERIFY(outputLines.count() >= expectedLines.count());\r\n\r\n        int lineOffset = outputLines.indexOf(expectedLines.first());\r\n        if (lineOffset == -1)\r\n        {\r\n            readOutPutFile();\r\n            QCOMPARE(output_, expectedOutput);\r\n        }\r\n        else\r\n        {\r\n            int lineCount = expectedLines.count();\r\n            for (int i = 0; i < lineCount; ++i)\r\n            {\r\n                QCOMPARE(outputLines.at(i + lineOffset), expectedLines.at(i));\r\n            }\r\n        }\r\n    }\r\n    else if (output_.count(expectedOutput) != 1)\r\n    {\r\n        QVERIFY2(false, QString(expectedOutput + \" was found \" + QString::number(output_.count(expectedOutput)) +\r\n            \" times in output.\").toLocal8Bit());\r\n    }\r\n\r\n    // Check that the parameters were not changed.\r\n    QCOMPARE(slaveParameter->getValue(), QString(\"10\"));\r\n    QCOMPARE(otherSlaveParameter->getValue(), QString(\"14\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_MemoryMapHeaderGenerator::testDesignMemoryMapHeaderWithChannel()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_MemoryMapHeaderGenerator::testDesignMemoryMapHeaderWithChannel()\r\n{\r\n    QSharedPointer<Component> masterComponent = createTestMasterComponent(\"masterComponent\", \"4\");\r\n    QSharedPointer<Component> slaveComponent = createTestSlaveComponent(\"slaveComponent\", \"8\");\r\n    QSharedPointer<Component> channelComponent = createTestChannelComponent(\"channelComponent\", \"0\", \"4\", \"32\");\r\n    QSharedPointer<Design> headerDesign = createTestMiddleDesign(\"channelDesign\", masterComponent, slaveComponent,\r\n        channelComponent);\r\n\r\n    library_.addComponent(masterComponent);\r\n    library_.writeModelToFile(\"C:/Test/TestLibrary/TestComponent/1.0/masterComponent.1.0.xml\", topComponent_);\r\n    library_.addComponent(slaveComponent);\r\n    library_.writeModelToFile(\"C:/Test/TestLibrary/TestComponent/1.0/slaveComponent.1.0.xml\", topComponent_);\r\n    library_.addComponent(channelComponent);\r\n    library_.writeModelToFile(\"C:/Test/TestLibrary/TestComponent/1.0/channelComponent.1.0.xml\", topComponent_);\r\n    library_.addComponent(headerDesign);\r\n    library_.writeModelToFile(\"C:/Test/TestLibrary/TestComponent/1.0/channelDesign.1.0.xml\", topComponent_);\r\n\r\n    QSharedPointer<View> headerTestView(new View(\"headerView\"));\r\n    headerTestView->setDesignInstantiationRef(\"testInstantiation\");\r\n\r\n    QSharedPointer<DesignInstantiation> testInstatiation(new DesignInstantiation(\"testInstantiation\"));\r\n    testInstatiation->setDesignReference(QSharedPointer<ConfigurableVLNVReference>(\r\n        new ConfigurableVLNVReference(headerDesign->getVlnv())));\r\n\r\n    topComponent_->getViews()->append(headerTestView);\r\n    topComponent_->getDesignInstantiations()->append(testInstatiation);\r\n\r\n    QFileInfo saveFileInfo (targetPath_);\r\n\r\n    headerGenerator_->setGlobalSaveFileOptions(masterComponent, \"masterInstance_0\", \"masterID\",\r\n        masterComponent->getBusInterfaceNames().at(0), saveFileInfo);\r\n\r\n    QWidget parentWidget;\r\n    MessagePasser messageChannel;\r\n    PluginUtilityAdapter adapter(&library_, &messageChannel, QString(), &parentWidget);\r\n\r\n\r\n    headerGenerator_->runGenerator(&adapter, topComponent_, headerDesign, QSharedPointer<DesignConfiguration>());\r\n\r\n    readOutPutFile();\r\n\r\n    QString headerDefine = \"__MASTERINSTANCE_0_\" + masterComponent->getBusInterfaceNames().at(0).toUpper() + \"_H\";\r\n\r\n    QString expectedOutput(\r\n        \"/*\\n\"\r\n        \" * File: generatorOutput.h\\n\"\r\n        \" * Created on: \" + QDate::currentDate().toString(\"dd.MM.yyyy\") + \"\\n\"\r\n        \" * Generated by: \\n\"\r\n        \" *\\n\"\r\n        \" * Description:\\n\"\r\n        \" * Header file generated by Kactus2 for instance \\\"masterInstance_0\\\" interface \\\"masterBusInterface\\\".\\n\"\r\n        \" * This file contains addresses of the memories and registers defined in the memory maps of connected \"\r\n            \"components.\\n\"\r\n        \" * Source component: \" + masterComponent->getVlnv().toString(\":\") + \".\\n\"\r\n        \"*/\\n\"\r\n        \"\\n\"\r\n        \"#ifndef \" + headerDefine + \"\\n\"\r\n        \"#define \" + headerDefine + \"\\n\"\r\n        \"\\n\"\r\n        \"/*\\n\"\r\n        \" * Instance: slaveInstance_0 Interface: slaveBusInterface\\n\"\r\n        \" * Instance base address: 0x8\\n\"\r\n        \" * Source component: \" + slaveComponent->getVlnv().toString(\":\") + \"\\n\"\r\n        \" * The defines for the memory map \\\"slaveMemoryMap\\\":\\n\"\r\n        \"*/\\n\"\r\n        \"\\n\"\r\n        \"/*\\n\"\r\n        \" * Address block: slaveAddressBlock\\n\"\r\n        \"*/\\n\"\r\n        \"/*\\n\"\r\n        \" * Register name: slaveRegister\\n\"\r\n        \" * Offset: 0x8\\n\"\r\n        \"*/\\n\"\r\n        \"#define SLAVEINSTANCE_0_SLAVEREGISTER 0x10\\n\"\r\n        \"\\n\"\r\n        \"#endif /* \" + headerDefine + \" */\\n\"\r\n        );\r\n\r\n    if (!output_.contains(expectedOutput))\r\n    {\r\n        QStringList outputLines = output_.split(\"\\n\");\r\n        QStringList expectedLines = expectedOutput.split(\"\\n\");\r\n\r\n        QVERIFY(outputLines.count() >= expectedLines.count());\r\n\r\n        int lineOffset = outputLines.indexOf(expectedLines.first());\r\n        if (lineOffset == -1)\r\n        {\r\n            readOutPutFile();\r\n            QCOMPARE(output_, expectedOutput);\r\n        }\r\n        else\r\n        {\r\n            int lineCount = expectedLines.count();\r\n            for (int i = 0; i < lineCount; ++i)\r\n            {\r\n                QCOMPARE(outputLines.at(i + lineOffset), expectedLines.at(i));\r\n            }\r\n        }\r\n    }\r\n    else if (output_.count(expectedOutput) != 1)\r\n    {\r\n        QVERIFY2(false, QString(expectedOutput + \" was found \" + QString::number(output_.count(expectedOutput)) +\r\n            \" times in output.\").toLocal8Bit());\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_MemoryMapHeaderGenerator::testChannelDesignWithReferences()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_MemoryMapHeaderGenerator::testChannelDesignWithReferences()\r\n{\r\n    QSharedPointer<Parameter> masterParameter = createTestParameter(\"masterParameter\", \"master_ID\", \"2\");\r\n    QSharedPointer<Parameter> slaveParameter = createTestParameter(\"slaveParameter\", \"param_ID\", \"4\");\r\n    QSharedPointer<Parameter> otherSlaveParameter = createTestParameter(\"otherParameter\", \"other_ID\", \"8\");\r\n\r\n    QSharedPointer<Component> masterComponent = createTestMasterComponent(\"masterComponent\", \"4\");\r\n    QSharedPointer<Component> slaveComponent = createTestSlaveComponent(\"slaveComponent\", \"param_ID\");\r\n    QSharedPointer<Component> channelComponent = createTestChannelComponent(\"channelComponent\",\r\n        \"master_ID\", \"param_ID+3\", \"other_ID*master_ID\");\r\n    QSharedPointer<Design> headerDesign = createTestMiddleDesign(\"channelDesign\", masterComponent, slaveComponent,\r\n        channelComponent);\r\n\r\n    channelComponent->getParameters()->append(masterParameter);\r\n    channelComponent->getParameters()->append(slaveParameter);\r\n    channelComponent->getParameters()->append(otherSlaveParameter);\r\n\r\n    slaveComponent->getParameters()->append(slaveParameter);\r\n\r\n    library_.addComponent(masterComponent);\r\n    library_.writeModelToFile(\"C:/Test/TestLibrary/TestComponent/1.0/masterComponent.1.0.xml\", topComponent_);\r\n    library_.addComponent(slaveComponent);\r\n    library_.writeModelToFile(\"C:/Test/TestLibrary/TestComponent/1.0/slaveComponent.1.0.xml\", topComponent_);\r\n    library_.addComponent(channelComponent);\r\n    library_.writeModelToFile(\"C:/Test/TestLibrary/TestComponent/1.0/channelComponent.1.0.xml\", topComponent_);\r\n    library_.addComponent(headerDesign);\r\n    library_.writeModelToFile(\"C:/Test/TestLibrary/TestComponent/1.0/channelDesign.1.0.xml\", topComponent_);\r\n\r\n    QSharedPointer<View> headerTestView(new View(\"headerView\"));\r\n    headerTestView->setDesignInstantiationRef(\"testInstantiation\");\r\n\r\n    QSharedPointer<DesignInstantiation> testInstatiation(new DesignInstantiation(\"testInstantiation\"));\r\n    testInstatiation->setDesignReference(QSharedPointer<ConfigurableVLNVReference>(\r\n        new ConfigurableVLNVReference(headerDesign->getVlnv())));\r\n\r\n    topComponent_->getViews()->append(headerTestView);\r\n    topComponent_->getDesignInstantiations()->append(testInstatiation);\r\n\r\n    QFileInfo saveFileInfo (targetPath_);\r\n\r\n    headerGenerator_->setGlobalSaveFileOptions(masterComponent, \"masterInstance_0\", \"masterID\",\r\n        masterComponent->getBusInterfaceNames().at(0), saveFileInfo);\r\n\r\n    QWidget parentWidget;\r\n    MessagePasser messageChannel;\r\n    PluginUtilityAdapter adapter(&library_, &messageChannel, QString(), &parentWidget);\r\n\r\n    headerGenerator_->runGenerator(&adapter, topComponent_, headerDesign, QSharedPointer<DesignConfiguration>());\r\n\r\n    readOutPutFile();\r\n\r\n    QString headerDefine = \"__MASTERINSTANCE_0_\" + masterComponent->getBusInterfaceNames().at(0).toUpper() + \"_H\";\r\n\r\n    QString expectedOutput(\r\n        \"/*\\n\"\r\n        \" * File: generatorOutput.h\\n\"\r\n        \" * Created on: \" + QDate::currentDate().toString(\"dd.MM.yyyy\") + \"\\n\"\r\n        \" * Generated by: \\n\"\r\n        \" *\\n\"\r\n        \" * Description:\\n\"\r\n        \" * Header file generated by Kactus2 for instance \\\"masterInstance_0\\\" interface \\\"masterBusInterface\\\".\\n\"\r\n        \" * This file contains addresses of the memories and registers defined in the memory maps of connected \"\r\n            \"components.\\n\"\r\n        \" * Source component: \" + masterComponent->getVlnv().toString(\":\") + \".\\n\"\r\n        \"*/\\n\"\r\n        \"\\n\"\r\n        \"#ifndef \" + headerDefine + \"\\n\"\r\n        \"#define \" + headerDefine + \"\\n\"\r\n        \"\\n\"\r\n        \"/*\\n\"\r\n        \" * Instance: slaveInstance_0 Interface: slaveBusInterface\\n\"\r\n        \" * Instance base address: 0xb\\n\"\r\n        \" * Source component: \" + slaveComponent->getVlnv().toString(\":\") + \"\\n\"\r\n        \" * The defines for the memory map \\\"slaveMemoryMap\\\":\\n\"\r\n        \"*/\\n\"\r\n        \"\\n\"\r\n        \"/*\\n\"\r\n        \" * Address block: slaveAddressBlock\\n\"\r\n        \"*/\\n\"\r\n        \"/*\\n\"\r\n        \" * Register name: slaveRegister\\n\"\r\n        \" * Offset: slaveParameter = 0x4\\n\"\r\n        \"*/\\n\"\r\n        \"#define SLAVEINSTANCE_0_SLAVEREGISTER 0xf\\n\"\r\n        \"\\n\"\r\n        \"#endif /* \" + headerDefine + \" */\\n\"\r\n        );\r\n\r\n    if (!output_.contains(expectedOutput))\r\n    {\r\n        QStringList outputLines = output_.split(\"\\n\");\r\n        QStringList expectedLines = expectedOutput.split(\"\\n\");\r\n\r\n        QVERIFY(outputLines.count() >= expectedLines.count());\r\n\r\n        int lineOffset = outputLines.indexOf(expectedLines.first());\r\n        if (lineOffset == -1)\r\n        {\r\n            readOutPutFile();\r\n            QCOMPARE(output_, expectedOutput);\r\n        }\r\n        else\r\n        {\r\n            int lineCount = expectedLines.count();\r\n            for (int i = 0; i < lineCount; ++i)\r\n            {\r\n                QCOMPARE(outputLines.at(i + lineOffset), expectedLines.at(i));\r\n            }\r\n        }\r\n    }\r\n    else if (output_.count(expectedOutput) != 1)\r\n    {\r\n        QVERIFY2(false, QString(expectedOutput + \" was found \" + QString::number(output_.count(expectedOutput)) +\r\n            \" times in output.\").toLocal8Bit());\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_MemoryMapHeaderGenerator::testDesignMemoryMapHeaderWithBridge()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_MemoryMapHeaderGenerator::testDesignMemoryMapHeaderWithBridge()\r\n{\r\n    QSharedPointer<Component> masterComponent = createTestMasterComponent(\"masterComponent\", \"4\");\r\n    QSharedPointer<Component> slaveComponent = createTestSlaveComponent(\"slaveComponent\", \"4\");\r\n    QSharedPointer<Component> bridgeComponent = createTestBridgeComponent(\"bridgeComponent\", \"16\", \"\");\r\n\r\n    QSharedPointer<Design> headerDesign = createTestMiddleDesign(\"bridgeDesign\", masterComponent, slaveComponent,\r\n        bridgeComponent);\r\n\r\n    library_.addComponent(masterComponent);\r\n    library_.writeModelToFile(\"C:/Test/TestLibrary/TestComponent/1.0/masterComponent.1.0.xml\", topComponent_);\r\n    library_.addComponent(slaveComponent);\r\n    library_.writeModelToFile(\"C:/Test/TestLibrary/TestComponent/1.0/slaveComponent.1.0.xml\", topComponent_);\r\n    library_.addComponent(bridgeComponent);\r\n    library_.writeModelToFile(\"C:/Test/TestLibrary/TestComponent/1.0/bridgeComponent.1.0.xml\", topComponent_);\r\n    library_.addComponent(headerDesign);\r\n    library_.writeModelToFile(\"C:/Test/TestLibrary/TestComponent/1.0/bridgeDesign.1.0.xml\", topComponent_);\r\n    \r\n    QSharedPointer<View> headerTestView(new View(\"headerView\"));\r\n    headerTestView->setDesignInstantiationRef(\"testInstantiation\");\r\n\r\n    QSharedPointer<DesignInstantiation> testInstatiation(new DesignInstantiation(\"testInstantiation\"));\r\n    testInstatiation->setDesignReference(QSharedPointer<ConfigurableVLNVReference>(\r\n        new ConfigurableVLNVReference(headerDesign->getVlnv())));\r\n\r\n    topComponent_->getViews()->append(headerTestView);\r\n    topComponent_->getDesignInstantiations()->append(testInstatiation);\r\n\r\n    QFileInfo saveFileInfo (targetPath_);\r\n\r\n    headerGenerator_->setGlobalSaveFileOptions(masterComponent, \"masterInstance_0\", \"masterID\",\r\n        masterComponent->getBusInterfaceNames().at(0), saveFileInfo);\r\n\r\n    QWidget parentWidget;\r\n    MessagePasser messageChannel;\r\n    PluginUtilityAdapter adapter(&library_, &messageChannel, QString(), &parentWidget);\r\n\r\n    headerGenerator_->runGenerator(&adapter, topComponent_, headerDesign, QSharedPointer<DesignConfiguration>());\r\n\r\n    readOutPutFile();\r\n\r\n    QString headerDefine = \"__MASTERINSTANCE_0_\" + masterComponent->getBusInterfaceNames().at(0).toUpper() + \"_H\";\r\n\r\n    QString expectedOutput(\r\n        \"/*\\n\"\r\n        \" * File: generatorOutput.h\\n\"\r\n        \" * Created on: \" + QDate::currentDate().toString(\"dd.MM.yyyy\") + \"\\n\"\r\n        \" * Generated by: \\n\"\r\n        \" *\\n\"\r\n        \" * Description:\\n\"\r\n        \" * Header file generated by Kactus2 for instance \\\"masterInstance_0\\\" interface \\\"masterBusInterface\\\".\\n\"\r\n        \" * This file contains addresses of the memories and registers defined in the memory maps of connected \"\r\n            \"components.\\n\"\r\n        \" * Source component: \" + masterComponent->getVlnv().toString(\":\") + \".\\n\"\r\n        \"*/\\n\"\r\n        \"\\n\"\r\n        \"#ifndef \" + headerDefine + \"\\n\"\r\n        \"#define \" + headerDefine + \"\\n\"\r\n        \"\\n\"\r\n        \"/*\\n\"\r\n        \" * Instance: slaveInstance_0 Interface: slaveBusInterface\\n\"\r\n        \" * Instance base address: 0x14\\n\"\r\n        \" * Source component: \" + slaveComponent->getVlnv().toString(\":\") + \"\\n\"\r\n        \" * The defines for the memory map \\\"slaveMemoryMap\\\":\\n\"\r\n        \"*/\\n\"\r\n        \"\\n\"\r\n        \"/*\\n\"\r\n        \" * Address block: slaveAddressBlock\\n\"\r\n        \"*/\\n\"\r\n        \"/*\\n\"\r\n        \" * Register name: slaveRegister\\n\"\r\n        \" * Offset: 0x4\\n\"\r\n        \"*/\\n\"\r\n        \"#define SLAVEINSTANCE_0_SLAVEREGISTER 0x18\\n\"\r\n        \"\\n\"\r\n        \"#endif /* \" + headerDefine + \" */\\n\"\r\n        );\r\n\r\n    if (!output_.contains(expectedOutput))\r\n    {\r\n        QStringList outputLines = output_.split(\"\\n\");\r\n        QStringList expectedLines = expectedOutput.split(\"\\n\");\r\n\r\n        QVERIFY(outputLines.count() >= expectedLines.count());\r\n\r\n        int lineOffset = outputLines.indexOf(expectedLines.first());\r\n        if (lineOffset == -1)\r\n        {\r\n            readOutPutFile();\r\n            QCOMPARE(output_, expectedOutput);\r\n        }\r\n        else\r\n        {\r\n            int lineCount = expectedLines.count();\r\n            for (int i = 0; i < lineCount; ++i)\r\n            {\r\n                QCOMPARE(outputLines.at(i + lineOffset), expectedLines.at(i));\r\n            }\r\n        }\r\n    }\r\n    else if (output_.count(expectedOutput) != 1)\r\n    {\r\n        QVERIFY2(false, QString(expectedOutput + \" was found \" + QString::number(output_.count(expectedOutput)) +\r\n            \" times in output.\").toLocal8Bit());\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_MemoryMapHeaderGenerator::testDesignMemoryMapHeaderWithOpaqueBridge()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_MemoryMapHeaderGenerator::testDesignMemoryMapHeaderWithOpaqueBridge()\r\n{\r\n\r\n   /* QSharedPointer<Component> masterComponent = createTestMasterComponent(\"masterComponent\", \"0\");\r\n    QSharedPointer<Component> slaveComponent = createTestSlaveComponent(\"slaveComponent\", \"2\");\r\n\r\n    QSharedPointer<MemoryMap> opaqueMemoryMap = createTestMemoryMap(\"opaqueMemoryMap\",\r\n        QList<QSharedPointer<AddressBlock> > ());\r\n    \r\n    QSharedPointer<> opaqueSubspace (new SubspaceMap());\r\n    opaqueSubspace->setBaseAddress(\"16\");\r\n\r\n    QList<QSharedPointer<MemoryMapItem> > opaqueItems;\r\n    opaqueItems.append(opaqueSubspace);\r\n    opaqueMemoryMap->setItems(opaqueItems);\r\n\r\n    QSharedPointer<Component> bridgeComponent = createTestBridgeComponent(\"opqueBridge\", \"4\", true,\r\n        opaqueMemoryMap->name());\r\n\r\n    bridgeComponent->getMemoryMaps()->append(opaqueMemoryMap);\r\n\r\n    QSharedPointer<Design> headerDesign = createTestMiddleDesign(\"bridgeDesign\", masterComponent, slaveComponent,\r\n        bridgeComponent);\r\n\r\n    library_.addComponent(masterComponent);\r\n    library_.writeModelToFile(\"C:/Test/TestLibrary/TestComponent/1.0/masterComponent.1.0.xml\", topComponent_);\r\n    library_.addComponent(slaveComponent);\r\n    library_.writeModelToFile(\"C:/Test/TestLibrary/TestComponent/1.0/slaveComponent.1.0.xml\", topComponent_);\r\n    library_.addComponent(bridgeComponent);\r\n    library_.writeModelToFile(\"C:/Test/TestLibrary/TestComponent/1.0/bridgeComponent.1.0.xml\", topComponent_);\r\n    library_.addComponent(headerDesign);\r\n    library_.writeModelToFile(\"C:/Test/TestLibrary/TestComponent/1.0/bridgeDesign.1.0.xml\", topComponent_);\r\n\r\n    QSharedPointer<View> headerTestView(new View(\"headerView\"));\r\n    headerTestView->setDesignInstantiationRef(\"testInstantiation\");\r\n\r\n    QSharedPointer<DesignInstantiation> testInstatiation(new DesignInstantiation(\"testInstantiation\"));\r\n    testInstatiation->setDesignReference(QSharedPointer<ConfigurableVLNVReference>(\r\n        new ConfigurableVLNVReference(headerDesign->getVlnv())));\r\n\r\n    topComponent_->getViews()->append(headerTestView);\r\n\r\n    QFileInfo saveFileInfo (targetPath_);\r\n\r\n    headerGenerator_->setGlobalSaveFileOptions(topComponent_, \"masterInstance_0\", \"masterID\",\r\n        masterComponent->getBusInterfaceNames().at(0), saveFileInfo);\r\n\r\n    QWidget parentWidget;\r\n    PluginUtilityAdapter adapter(&library_, &parentWidget, \"\", this);\r\n\r\n    QSignalSpy errorMessageSignals(&adapter, SIGNAL(errorMessage(QString const&)));\r\n\r\n    headerGenerator_->runGenerator(&adapter, topComponent_, headerDesign, QSharedPointer<DesignConfiguration>()\r\n\r\n    QCOMPARE(errorMessageSignals.count(), 1);\r\n    QString errorMessage = errorMessageSignals.first().first().toString();\r\n    QString expectedErrorMessage(\"An opaque bridge was found in interface bridgeSlaveBusInterface in instance \"\r\n        \"channelInstance_0. Currently, opaque bridges are handled as transparent bridges.\");\r\n    QCOMPARE(errorMessage, expectedErrorMessage);\r\n\r\n    readOutPutFile();\r\n\r\n    QString headerDefine = \"__MASTERINSTANCE_0_\" + masterComponent->getBusInterfaceNames().at(0).toUpper() + \"_H\";\r\n\r\n    QString expectedOutput(\r\n        \"/*\\n\"\r\n        \" * File: generatorOutput.h\\n\"\r\n        );\r\n\r\n    if (!output_.contains(expectedOutput))\r\n    {\r\n        QStringList outputLines = output_.split(\"\\n\");\r\n        QStringList expectedLines = expectedOutput.split(\"\\n\");\r\n\r\n        QVERIFY(outputLines.count() >= expectedLines.count());\r\n\r\n        int lineOffset = outputLines.indexOf(expectedLines.first());\r\n        if (lineOffset == -1)\r\n        {\r\n            readOutPutFile();\r\n            QCOMPARE(output_, expectedOutput);\r\n        }\r\n        else\r\n        {\r\n            int lineCount = expectedLines.count();\r\n            for (int i = 0; i < lineCount; ++i)\r\n            {\r\n                QCOMPARE(outputLines.at(i + lineOffset), expectedLines.at(i));\r\n            }\r\n        }\r\n    }\r\n    else if (output_.count(expectedOutput) != 1)\r\n    {\r\n        QVERIFY2(false, QString(expectedOutput + \" was found \" + QString::number(output_.count(expectedOutput)) +\r\n            \" times in output.\").toLocal8Bit());\r\n    }*/\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_MemoryMapHeaderGenerator::testSystemMemoryMapHeaderGeneration()\r\n//-----------------------------------------------------------------------------\r\n/*\r\nvoid tst_MemoryMapHeaderGenerator::testSystemMemoryMapHeaderGeneration()\r\n{\r\n    QSharedPointer<Component> masterComponent = createTestMasterComponent(\"masterComponent\", \"0\");\r\n    QSharedPointer<Component> slaveComponent = createTestSlaveComponent(\"slaveComponent\", \"8\");\r\n    QSharedPointer<Design> hwDesign = createTestHWDesign(\"hwDesign\", masterComponent, slaveComponent);\r\n    QSharedPointer<DesignConfiguration> hwDesignConfiguration (new DesignConfiguration(VLNV(\r\n        VLNV::DESIGNCONFIGURATION, \"TUT\", \"TestLibrary\", \"hwDesignConfiguration\", \"1.0\")));\r\n\r\n    QSharedPointer<Design> systemDesign (new Design(VLNV(VLNV::DESIGN, \"TUT\", \"TestLibrary\", \"systemDesign\",\r\n        \"1.0\")));\r\n    QSharedPointer<DesignConfiguration> systemDesignConfiguration (new DesignConfiguration(VLNV(\r\n        VLNV::DESIGNCONFIGURATION, \"TUT\", \"TestLibrary\", \"systemDesignConfiguration\", \"1.0\")));\r\n\r\n    library_.addComponent(masterComponent);\r\n    library_.writeModelToFile(\"C:/Test/TestLibrary/TestComponent/1.0/masterComponent.1.0.xml\", topComponent_);\r\n    library_.addComponent(slaveComponent);\r\n    library_.writeModelToFile(\"C:/Test/TestLibrary/TestComponent/1.0/slaveComponent.1.0.xml\", topComponent_);\r\n    library_.addComponent(hwDesign);\r\n    library_.writeModelToFile(\"C:/Test/TestLibrary/TestComponent/1.0/hwDesign.1.0.xml\", topComponent_);\r\n    library_.addComponent(hwDesignConfiguration);\r\n    library_.writeModelToFile(\"C:/Test/TestLibrary/TestComponent/1.0/hwDesignConfiguration.1.0.xml\", topComponent_);\r\n    library_.addComponent(systemDesign);\r\n    library_.writeModelToFile(\"C:/Test/TestLibrary/TestComponent/1.0/systemDesign.1.0.xml\", topComponent_);\r\n    library_.addComponent(systemDesignConfiguration);\r\n    library_.writeModelToFile(\"C:/Test/TestLibrary/TestComponent/1.0/systemDesignConfiguration.1.0.xml\",\r\n        topComponent_);\r\n\r\n    View* hwDesignView = new View(\"headerView\");\r\n    hwDesignView->setHierarchyRef(*hwDesignConfiguration->getVlnv());\r\n    topComponent_->addView(hwDesignView);\r\n\r\n    SystemView* systemDesignView = new SystemView(\"systemView\");\r\n    systemDesignView->setHierarchyRef(*systemDesignConfiguration->getVlnv());\r\n    systemDesignView->setHWViewRef(hwDesignView->name());\r\n    topComponent_->addSystemView(systemDesignView);\r\n\r\n       QFileInfo saveFileInfo (targetPath_);\r\n\r\n    headerGenerator_->setGlobalSaveFileOptions(topComponent_, \"masterInstance_0\", \"masterID\",\r\n        masterComponent->getBusInterfaceNames().at(0), saveFileInfo);\r\n\r\n    QWidget parentWidget;\r\n    PluginUtilityAdapter adapter(&library_, &parentWidget, \"\", this);\r\n\r\n    headerGenerator_->runGenerator(&adapter, topComponent_, systemDesignConfiguration, systemDesign);\r\n\r\n    readOutPutFile();\r\n\r\n    QString headerDefine = \"__MASTERINSTANCE_0_\" + masterComponent->getBusInterfaceNames().at(0).toUpper() + \"_H\";\r\n\r\n    QString expectedOutput(\r\n        \"abc\"\r\n        );\r\n\r\n    if (!outPut_.contains(expectedOutput))\r\n    {\r\n        QStringList outputLines = outPut_.split(\"\\n\");\r\n        QStringList expectedLines = expectedOutput.split(\"\\n\");\r\n\r\n        QVERIFY(outputLines.count() >= expectedLines.count());\r\n\r\n        int lineOffset = outputLines.indexOf(expectedLines.first());\r\n        if (lineOffset == -1)\r\n        {\r\n            readOutPutFile();\r\n            QCOMPARE(outPut_, expectedOutput);\r\n        }\r\n        else\r\n        {\r\n            int lineCount = expectedLines.count();\r\n            for (int i = 0; i < lineCount; ++i)\r\n            {\r\n                QCOMPARE(outputLines.at(i + lineOffset), expectedLines.at(i));\r\n            }\r\n        }\r\n    }\r\n    else if (outPut_.count(expectedOutput) != 1)\r\n    {\r\n        QVERIFY2(false, QString(expectedOutput + \" was found \" + QString::number(outPut_.count(expectedOutput)) +\r\n            \" times in output.\").toLocal8Bit());\r\n    }\r\n}*/\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_MemoryMapHeaderGenerator::createTestGenerator()\r\n//-----------------------------------------------------------------------------\r\nMemoryMapHeaderGenerator* tst_MemoryMapHeaderGenerator::createTestGenerator()\r\n{\r\n    library_.writeModelToFile(\"C:/Test/TestLibrary/TestComponent/1.0/TestComponent.1.0.xml\", topComponent_);\r\n    library_.addComponent(topComponent_);\r\n\r\n    MemoryMapHeaderGenerator* generator = new MemoryMapHeaderGenerator();\r\n\r\n    return generator;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_MemoryMapHeaderGenerator::createTestRegister()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<Register> tst_MemoryMapHeaderGenerator::createTestRegister(QString const& registerName,\r\n    QString const& addressOffset)\r\n{\r\n    QSharedPointer<Register> newRegister (new Register());\r\n    newRegister->setName(registerName);\r\n    newRegister->setAddressOffset(addressOffset);\r\n    newRegister->setSize(\"16\");\r\n\r\n    return newRegister;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_MemoryMapHeaderGenerator::createTestAddressBlock()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<AddressBlock> tst_MemoryMapHeaderGenerator::createTestAddressBlock(QString const& addressName,\r\n    QList<QSharedPointer<Register> > addressBlockRegisters)\r\n{\r\n    QSharedPointer<AddressBlock> newAddressBlock (new AddressBlock());\r\n    newAddressBlock->setName(addressName);\r\n    newAddressBlock->setBaseAddress(\"0\");\r\n    newAddressBlock->setRange(\"16\");\r\n    newAddressBlock->setWidth(\"32\");\r\n    newAddressBlock->setUsage(General::REGISTER);\r\n    QSharedPointer<QList<QSharedPointer<RegisterBase> > > registerModelRef =newAddressBlock->getRegisterData();\r\n\r\n    foreach(QSharedPointer<Register> targetRegister, addressBlockRegisters)\r\n    {\r\n        registerModelRef->append(targetRegister);\r\n    }\r\n\r\n    return newAddressBlock;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_MemoryMapHeaderGenerator::createTestMemoryMap()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<MemoryMap> tst_MemoryMapHeaderGenerator::createTestMemoryMap(QString const& memoryMapName,\r\n    QList<QSharedPointer<AddressBlock> > addressBlocks)\r\n{\r\n    QSharedPointer<MemoryMap> newMemoryMap (new MemoryMap());\r\n    newMemoryMap->setName(memoryMapName);\r\n    newMemoryMap->setAddressUnitBits(\"8\");\r\n\r\n    QSharedPointer<QList<QSharedPointer<MemoryBlockBase> > > newMemoryMapItems = newMemoryMap->getMemoryBlocks();\r\n\r\n    foreach (QSharedPointer<AddressBlock> newAddressBlock, addressBlocks)\r\n    {\r\n        newMemoryMapItems->append(newAddressBlock);\r\n    }\r\n\r\n    return newMemoryMap;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_MemoryMapHeaderGenerator::createTestAddressSpace()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<AddressSpace> tst_MemoryMapHeaderGenerator::createTestAddressSpace(QString const& spaceName,\r\n    QSharedPointer<MemoryMap> localMemoryMap)\r\n{\r\n    QSharedPointer<AddressSpace> newAddressSpace(new AddressSpace());\r\n    newAddressSpace->setName(spaceName);\r\n    newAddressSpace->setLocalMemoryMap(localMemoryMap);\r\n\r\n    return newAddressSpace;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_MemoryMapHeaderGenerator::createTestParameter()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<Parameter> tst_MemoryMapHeaderGenerator::createTestParameter(QString const& paramName,\r\n    QString const& paramID, QString const& value)\r\n{\r\n    QSharedPointer<Parameter> newParameter(new Parameter);\r\n    newParameter->setName(paramName);\r\n    newParameter->setValueId(paramID);\r\n    newParameter->setValue(value);\r\n\r\n    return newParameter;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_MemoryMapHeaderGenerator::createTestMasterComponent()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<Component> tst_MemoryMapHeaderGenerator::createTestMasterComponent(QString const& componentName,\r\n    QString const& instanceBaseAddress)\r\n{\r\n    QSharedPointer<Component> newMaster (new Component(VLNV(VLNV::COMPONENT, \"TUT\", \"TestLibrary\", componentName,\r\n        \"1.0\"), Document::Revision::Std14));\r\n\r\n    QSharedPointer<AddressSpace> localAddressSpace = createTestAddressSpace(\"localSpace\", QSharedPointer<MemoryMap> ());\r\n    QSharedPointer<QList<QSharedPointer<AddressSpace> > > addressSpaceList(new QList<QSharedPointer<AddressSpace> >());\r\n    addressSpaceList->append(localAddressSpace);\r\n\r\n    newMaster->setAddressSpaces(addressSpaceList);\r\n\r\n    QStringList addressSpaceRefs;\r\n    addressSpaceRefs.append(localAddressSpace->name());\r\n\r\n    QSharedPointer<Cpu> masterCpu (new Cpu());\r\n    masterCpu->setAddressSpaceRefs(addressSpaceRefs);\r\n    \r\n    newMaster->getCpus()->append(masterCpu);\r\n\r\n    QSharedPointer<BusInterface> masterBus (new BusInterface());\r\n    masterBus->setName(\"masterBusInterface\");\r\n    QSharedPointer<InitiatorInterface> interfaceMaster(new InitiatorInterface);\r\n    interfaceMaster->setBaseAddress(instanceBaseAddress);\r\n    interfaceMaster->setAddressSpaceRef(localAddressSpace->name());\r\n    masterBus->setMaster(interfaceMaster);\r\n    masterBus->setInterfaceMode(General::MASTER);\r\n\r\n    newMaster->getBusInterfaces()->append(masterBus);\r\n\r\n    return newMaster;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_MemoryMapHeaderGenerator::createSlaveComponent()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<Component> tst_MemoryMapHeaderGenerator::createTestSlaveComponent(QString const& componentName,\r\n    QString const& registerOffset)\r\n{\r\n    QSharedPointer<Component> newSlave (new Component(VLNV(VLNV::COMPONENT, \"TUT\", \"TestLibrary\", componentName,\r\n        \"1.0\"), Document::Revision::Std14));\r\n\r\n    QSharedPointer<Register> slaveRegister = createTestRegister(\"slaveRegister\", registerOffset);\r\n    QList<QSharedPointer<Register> > componentRegisters;\r\n    componentRegisters.append(slaveRegister);\r\n\r\n    QSharedPointer<AddressBlock> slaveAddressBlock = createTestAddressBlock(\"slaveAddressBlock\",\r\n        componentRegisters);\r\n    QList<QSharedPointer<AddressBlock> > addressBlocks;\r\n    addressBlocks.append(slaveAddressBlock);\r\n\r\n    QSharedPointer<MemoryMap> slaveMemoryMap = createTestMemoryMap(\"slaveMemoryMap\", addressBlocks);\r\n    \r\n    newSlave->getMemoryMaps()->append(slaveMemoryMap);\r\n\r\n    QSharedPointer<BusInterface> slaveBus (new BusInterface());\r\n    slaveBus->setName(\"slaveBusInterface\");\r\n    QSharedPointer<TargetInterface> interfaceSlave(new TargetInterface);\r\n    interfaceSlave->setMemoryMapRef(slaveMemoryMap->name());\r\n    slaveBus->setSlave(interfaceSlave);\r\n\r\n    newSlave->getBusInterfaces()->append(slaveBus);\r\n\r\n    return newSlave;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_MemoryMapHeaderGenerator::createTestDesign()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<Design> tst_MemoryMapHeaderGenerator::createTestHWDesign(QString const& designName,\r\n    QSharedPointer<Component> masterComponent, QSharedPointer<Component> slaveComponent)\r\n{\r\n    QSharedPointer<Design> newDesign(new Design(VLNV(VLNV::DESIGN, \"TUT\", \"TestLibrary\", designName, \"1.0\"),\r\n        Document::Revision::Std14));\r\n\r\n    QSharedPointer<ComponentInstance> masterInstance (new ComponentInstance(\"masterInstance_0\",\r\n        QSharedPointer<ConfigurableVLNVReference>(new ConfigurableVLNVReference(masterComponent->getVlnv()))));\r\n    masterInstance->setUuid(\"masterID\");\r\n\r\n    QSharedPointer<ComponentInstance> slaveInstance (new ComponentInstance(\"slaveInstance_0\",\r\n        QSharedPointer<ConfigurableVLNVReference>(new ConfigurableVLNVReference(slaveComponent->getVlnv()))));\r\n    slaveInstance->setUuid(\"slaveID\");\r\n    \r\n    newDesign->getComponentInstances()->append(masterInstance);\r\n    newDesign->getComponentInstances()->append(slaveInstance);\r\n\r\n    QSharedPointer<ActiveInterface> interfaceMaster (\r\n        new ActiveInterface(masterInstance->getInstanceName(), masterComponent->getBusInterfaceNames().at(0)));\r\n    QSharedPointer<ActiveInterface> interfaceSlave (\r\n        new ActiveInterface(slaveInstance->getInstanceName(), slaveComponent->getBusInterfaceNames().at(0)));\r\n\r\n    QSharedPointer<Interconnection> masterSlaveConnection(\r\n        new Interconnection(\"masterSlaveConnection\", interfaceMaster));\r\n    masterSlaveConnection->getActiveInterfaces()->append(interfaceSlave);\r\n\r\n    newDesign->getInterconnections()->append(masterSlaveConnection);\r\n\r\n    return newDesign;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_MemoryMapHeaderGenerator::createTestChannelComponent()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<Component> tst_MemoryMapHeaderGenerator::createTestChannelComponent(QString const& componentName,\r\n    QString const& mirroredMasterBaseAddress, QString const& mirroredSlaveRemap, QString const& mirroredSlaveRange)\r\n{\r\n    QSharedPointer<Component> newChannelComponent (new Component(VLNV(VLNV::COMPONENT, \"TUT\", \"TestLibrary\",\r\n        componentName, \"1.0\"), Document::Revision::Std14));\r\n\r\n    QSharedPointer<Register> localRegister = createTestRegister(\"mirroredRegister\", \"4\");\r\n    QList<QSharedPointer<Register> > localRegisterList;\r\n    localRegisterList.append(localRegister);\r\n\r\n    QSharedPointer<AddressBlock> mirroredAddressBlock = createTestAddressBlock(\"mirroredAddressBlock\",\r\n        localRegisterList);\r\n    QList<QSharedPointer<AddressBlock> > localAddressBlockList;\r\n    localAddressBlockList.append(mirroredAddressBlock);\r\n\r\n    QSharedPointer<MemoryMap> localMemoryMap = createTestMemoryMap(\"localMasterMemory\", localAddressBlockList);\r\n\r\n    QSharedPointer<AddressSpace> localAddressSpace = createTestAddressSpace(\"localAddressSpace\", localMemoryMap);\r\n    QSharedPointer<QList<QSharedPointer<AddressSpace> > > addressSpaceList(new QList<QSharedPointer<AddressSpace> >());\r\n    addressSpaceList->append(localAddressSpace);\r\n\r\n    newChannelComponent->setAddressSpaces(addressSpaceList);\r\n\r\n    // Create mirrored master interface.\r\n    QSharedPointer<BusInterface> mirroredMasterBus(new BusInterface);\r\n    mirroredMasterBus->setName(\"mirroredMasterInterface\");\r\n    QSharedPointer<InitiatorInterface> mirroredMasterInterface(new InitiatorInterface);\r\n    mirroredMasterInterface->setBaseAddress(mirroredMasterBaseAddress);\r\n    mirroredMasterInterface->setAddressSpaceRef(localAddressSpace->name());\r\n    mirroredMasterBus->setMaster(mirroredMasterInterface);\r\n    mirroredMasterBus->setInterfaceMode(General::MIRRORED_MASTER);\r\n\r\n    // Create mirrored slave interface.\r\n    QSharedPointer<MirroredTargetInterface> interfaceMirroredSlave (new MirroredTargetInterface());\r\n    QSharedPointer<MirroredTargetInterface::RemapAddress> remapAddress(\r\n        new MirroredTargetInterface::RemapAddress(mirroredSlaveRemap));\r\n    interfaceMirroredSlave->getRemapAddresses()->append(remapAddress);\r\n    interfaceMirroredSlave->setRange(mirroredSlaveRange);\r\n\r\n    QSharedPointer<BusInterface> mirroredSlaveBus(new BusInterface);\r\n    mirroredSlaveBus->setName(\"mirroredSlaveInterface\");\r\n    mirroredSlaveBus->setMirroredSlave(interfaceMirroredSlave);\r\n    mirroredSlaveBus->setInterfaceMode(General::MIRRORED_SLAVE);\r\n\r\n    newChannelComponent->getBusInterfaces()->append(mirroredMasterBus);\r\n    newChannelComponent->getBusInterfaces()->append(mirroredSlaveBus);\r\n\r\n    QStringList interfaceNames;\r\n    interfaceNames.append(mirroredMasterBus->name());\r\n    interfaceNames.append(mirroredSlaveBus->name());\r\n\r\n    QSharedPointer<Channel> masterSlaveChannel (new Channel());\r\n    masterSlaveChannel->setName(\"masterSlaveChannel\");\r\n    masterSlaveChannel->setInterfaces(interfaceNames);\r\n\r\n    newChannelComponent->getChannels()->append(masterSlaveChannel);\r\n\r\n    return newChannelComponent;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_MemoryMapHeaderGenerator::createTestChannelDesign()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<Design> tst_MemoryMapHeaderGenerator::createTestMiddleDesign(QString const& designName,\r\n    QSharedPointer<Component> masterComponent, QSharedPointer<Component> slaveComponent,\r\n    QSharedPointer<Component> middleComponent)\r\n{\r\n    QSharedPointer<Design> newDesign(new Design(VLNV(VLNV::DESIGN, \"TUT\", \"TestLibrary\", designName, \"1.0\"), \r\n        Document::Revision::Std14));\r\n\r\n    QSharedPointer<ComponentInstance> masterInstance (new ComponentInstance(\"masterInstance_0\",\r\n        QSharedPointer<ConfigurableVLNVReference>(new ConfigurableVLNVReference(masterComponent->getVlnv()))));\r\n    masterInstance->setUuid(\"masterID\");\r\n\r\n    QSharedPointer<ComponentInstance> slaveInstance (new ComponentInstance(\"slaveInstance_0\",\r\n        QSharedPointer<ConfigurableVLNVReference>(new ConfigurableVLNVReference(slaveComponent->getVlnv()))));\r\n    slaveInstance->setUuid(\"slaveID\");\r\n\r\n    QSharedPointer<ComponentInstance> channelInstance (new ComponentInstance(\"channelInstance_0\",\r\n        QSharedPointer<ConfigurableVLNVReference>(new ConfigurableVLNVReference(middleComponent->getVlnv()))));\r\n    channelInstance->setUuid(\"middleID\");\r\n\r\n    QSharedPointer<QList<QSharedPointer<ComponentInstance> > > componentInstances = newDesign->getComponentInstances();\r\n    componentInstances->append(masterInstance);\r\n    componentInstances->append(slaveInstance);\r\n    componentInstances->append(channelInstance);    \r\n\r\n    QSharedPointer<ActiveInterface> interfaceMaster (new ActiveInterface(masterInstance->getInstanceName(),\r\n        masterComponent->getBusInterfaceNames().at(0)));\r\n    QSharedPointer<ActiveInterface> interfaceMiddleFirst (new ActiveInterface(channelInstance->getInstanceName(),\r\n        middleComponent->getBusInterfaceNames().at(0)));\r\n    QSharedPointer<ActiveInterface> interfaceMiddleSecond (new ActiveInterface(channelInstance->getInstanceName(),\r\n        middleComponent->getBusInterfaceNames().at(1)));\r\n    QSharedPointer<ActiveInterface> interfaceSlave (new ActiveInterface(slaveInstance->getInstanceName(), \r\n        slaveComponent->getBusInterfaceNames().at(0)));\r\n\r\n    QSharedPointer<Interconnection> masterMiddleConnect(new Interconnection(\"masterMirrored\", interfaceMaster));\r\n    masterMiddleConnect->getActiveInterfaces()->append(interfaceMiddleFirst);\r\n\r\n    QSharedPointer<Interconnection> middleSlaveConnect(new Interconnection(\"mirroredSlave\", interfaceMiddleSecond));\r\n    middleSlaveConnect->getActiveInterfaces()->append(interfaceSlave);\r\n\r\n    newDesign->getInterconnections()->append(masterMiddleConnect);\r\n    newDesign->getInterconnections()->append(middleSlaveConnect);\r\n\r\n    return newDesign;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_MemoryMapHeaderGenerator::createTestBridgeComponent()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<Component> tst_MemoryMapHeaderGenerator::createTestBridgeComponent(QString const& componentName,\r\n    QString const& masterBaseAddress, QString const& bridgeReference)\r\n{\r\n    QSharedPointer<Component> newBridgeComponent (new Component(VLNV(VLNV::COMPONENT, \"TUT\", \"TestLibrary\",\r\n        componentName, \"1.0\"), Document::Revision::Std14));\r\n\r\n    QSharedPointer<Register> masterRegister = createTestRegister(\"bridgeMasterRegister\", \"4\");\r\n    QList<QSharedPointer<Register> > masterRegisterList;\r\n    masterRegisterList.append(masterRegister);\r\n\r\n    QSharedPointer<AddressBlock> masterAddressBlock = createTestAddressBlock(\"bridgeMasterAddressBlock\",\r\n        masterRegisterList);\r\n    QList<QSharedPointer<AddressBlock> > masterAddressBlockList;\r\n    masterAddressBlockList.append(masterAddressBlock);\r\n\r\n    QSharedPointer<MemoryMap> masterMemory = createTestMemoryMap(\"bridgeMasterMemory\", masterAddressBlockList);\r\n\r\n    QSharedPointer<AddressSpace> masterAddressSpace = createTestAddressSpace(\"bridgetMasterSpace\", masterMemory);\r\n\r\n    newBridgeComponent->getAddressSpaces()->append(masterAddressSpace);\r\n\r\n    // Create master bus interface.\r\n    QSharedPointer<InitiatorInterface> bridgeMasterInterface(new InitiatorInterface);\r\n    bridgeMasterInterface->setBaseAddress(masterBaseAddress);\r\n    bridgeMasterInterface->setAddressSpaceRef(masterAddressSpace->name());\r\n\r\n    QSharedPointer<BusInterface> bridgeMasterBus(new BusInterface);\r\n    bridgeMasterBus->setName(\"bridgeMasterBusInterface\");\r\n    bridgeMasterBus->setMaster(bridgeMasterInterface);\r\n    bridgeMasterBus->setInterfaceMode(General::MASTER);\r\n\r\n    // Create slave bus interface.\r\n    QSharedPointer<TargetInterface> bridgeSlaveInterface (new TargetInterface);\r\n    if (!bridgeReference.isEmpty())\r\n    {\r\n        bridgeSlaveInterface->setMemoryMapRef(bridgeReference);\r\n    }\r\n\r\n    QSharedPointer<TransparentBridge> bridge(new TransparentBridge());\r\n    bridge->setMasterRef(bridgeMasterBus->name());\r\n    //bridge->opaque_ = bridgeIsOpaque;\r\n\r\n    bridgeSlaveInterface->getBridges()->append(bridge); // setBridges(slaveInterfaceBridges);\r\n\r\n    QSharedPointer<BusInterface> bridgeSlaveBus (new BusInterface);\r\n    bridgeSlaveBus->setName(\"bridgeSlaveBusInterface\");\r\n    bridgeSlaveBus->setSlave(bridgeSlaveInterface);\r\n    bridgeSlaveBus->setInterfaceMode(General::SLAVE);\r\n\r\n    newBridgeComponent->getBusInterfaces()->append(bridgeSlaveBus);\r\n    newBridgeComponent->getBusInterfaces()->append(bridgeMasterBus);\r\n\r\n    return newBridgeComponent;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_MemoryMapHeaderGenerator::addConfigurableElementValueToInstance()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_MemoryMapHeaderGenerator::addConfigurableElementValueToInstance(\r\n    QSharedPointer<ComponentInstance> instance, QString const& referenceID, QString const& configurableValue)\r\n{\r\n    QSharedPointer<ConfigurableElementValue> configurable (\r\n        new ConfigurableElementValue(configurableValue, referenceID));\r\n    instance->getConfigurableElementValues()->append(configurable);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_MemoryMapHeaderGenerator::readOutPutFile()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_MemoryMapHeaderGenerator::readOutPutFile()\r\n{\r\n    QFile outputFile(targetPath_);\r\n    QVERIFY(outputFile.open(QIODevice::ReadOnly));\r\n\r\n    output_ = outputFile.readAll();\r\n    outputFile.close();\r\n}\r\n\r\n//QTEST_APPLESS_MAIN(tst_MemoryMapHeaderGenerator)\r\nQTEST_MAIN(tst_MemoryMapHeaderGenerator)\r\n\r\n#include \"tst_MemoryMapHeaderGenerator.moc\"\r\n"
  },
  {
    "path": "tests/Plugins/MemoryMapHeaderGenerator/tst_MemoryMapHeaderGenerator.pri",
    "content": "# ----------------------------------------------------\r\n# This file is generated by the Qt Visual Studio Tools.\r\n# ------------------------------------------------------\r\n\r\n# This is a reminder that you are using a generated .pro file.\r\n# Remove it when you are finished editing this file.\r\nmessage(\"You are running qmake on a generated .pro file. This may not work!\")\r\n\r\n\r\nHEADERS += ../../../Plugins/MemoryMapHeaderGenerator/BaseMemoryMapHeaderWriter.h \\\r\n    ../../../Plugins/MemoryMapHeaderGenerator/GlobalMemoryMapHeaderWriter.h \\\r\n    ../../../Plugins/MemoryMapHeaderGenerator/LocalMemoryMapHeaderWriter.h \\\r\n    ../../../KactusAPI/include/ParameterFinder.h \\\r\n    ../../../KactusAPI/include/PluginUtilityAdapter.h \\\r\n    ../../../Plugins/MemoryMapHeaderGenerator/SystemMemoryMapHeaderWriter.h \\\r\n    ../../../KactusAPI/include/utils.h \\\r\n    ../../MockObjects/LibraryMock.h \\\r\n    ../../../Plugins/PluginSystem/GeneratorPlugin/MessagePasser.h \\\r\n    ../../../Plugins/MemoryMapHeaderGenerator/fileSaveDialog/filesavedialog.h \\\r\n    ../../../Plugins/MemoryMapHeaderGenerator/fileSaveDialog/filesavedialogview.h \\\r\n    ../../../Plugins/MemoryMapHeaderGenerator/globalheadersavemodel.h \\\r\n    ../../../Plugins/MemoryMapHeaderGenerator/localheadersavedelegate.h \\\r\n    ../../../Plugins/MemoryMapHeaderGenerator/localheadersavemodel.h \\\r\n    ../../../Plugins/MemoryMapHeaderGenerator/memorymapheadergenerator.h \\\r\n    ../../../Plugins/MemoryMapHeaderGenerator/systemheadersavemodel.h \\\r\n    ../../../common/widgets/viewSelector/viewselector.h \\\r\n    ../../../editors/MemoryDesigner/MemoryItem.h \\\r\n    ../../../editors/MemoryDesigner/ConnectivityInterface.h \\\r\n    ../../../editors/MemoryDesigner/ConnectivityComponent.h \\\r\n    ../../../Plugins/common/CpuRoutesContainer.h \\\r\n    ../../../Plugins/common/ConnectivityGraphUtilities.h \\\r\n    ../../../Plugins/common/SingleCpuRoutesContainer.h \\\r\n    ../../../editors/MemoryDesigner/ConnectivityGraphFactory.h \\\r\n    ../../../editors/MemoryDesigner/ConnectivityConnection.h \\\r\n    ../../../editors/MemoryDesigner/ConnectivityGraph.h \\\r\n    ../../../editors/MemoryDesigner/MasterSlavePathSearch.h\r\nSOURCES += ../../../Plugins/MemoryMapHeaderGenerator/BaseMemoryMapHeaderWriter.cpp \\\r\n    ../../../Plugins/MemoryMapHeaderGenerator/GlobalMemoryMapHeaderWriter.cpp \\\r\n    ../../MockObjects/LibraryMock.cpp \\\r\n    ../../../Plugins/MemoryMapHeaderGenerator/LocalMemoryMapHeaderWriter.cpp \\\r\n    ../../../Plugins/PluginSystem/GeneratorPlugin/MessagePasser.cpp \\\r\n    ../../../KactusAPI/plugins/PluginUtilityAdapter.cpp \\\r\n    ../../../Plugins/MemoryMapHeaderGenerator/SystemMemoryMapHeaderWriter.cpp \\\r\n    ../../../Plugins/MemoryMapHeaderGenerator/fileSaveDialog/filesavedialog.cpp \\\r\n    ../../../Plugins/MemoryMapHeaderGenerator/fileSaveDialog/filesavedialogview.cpp \\\r\n    ../../../Plugins/MemoryMapHeaderGenerator/globalheadersavemodel.cpp \\\r\n    ../../../Plugins/MemoryMapHeaderGenerator/localheadersavedelegate.cpp \\\r\n    ../../../Plugins/MemoryMapHeaderGenerator/localheadersavemodel.cpp \\\r\n    ../../../Plugins/MemoryMapHeaderGenerator/memorymapheadergenerator.cpp \\\r\n    ../../../Plugins/MemoryMapHeaderGenerator/systemheadersavemodel.cpp \\\r\n    ../../../KactusAPI/utilities/utils.cpp \\\r\n    ../../../common/widgets/viewSelector/viewselector.cpp \\\r\n    ./tst_MemoryMapHeaderGenerator.cpp \\\r\n    ../../../editors/MemoryDesigner/MemoryItem.cpp \\\r\n    ../../../editors/MemoryDesigner/ConnectivityInterface.cpp \\\r\n    ../../../editors/MemoryDesigner/ConnectivityComponent.cpp \\\r\n    ../../../Plugins/common/CpuRoutesContainer.cpp \\\r\n    ../../../Plugins/common/ConnectivityGraphUtilities.cpp \\\r\n    ../../../Plugins/common/SingleCpuRoutesContainer.cpp \\\r\n    ../../../editors/MemoryDesigner/ConnectivityGraphFactory.cpp \\\r\n    ../../../editors/MemoryDesigner/ConnectivityConnection.cpp \\\r\n    ../../../editors/MemoryDesigner/ConnectivityGraph.cpp \\\r\n    ../../../editors/MemoryDesigner/MasterSlavePathSearch.cpp\r\n"
  },
  {
    "path": "tests/Plugins/MemoryMapHeaderGenerator/tst_MemoryMapHeaderGenerator.pro",
    "content": "#-----------------------------------------------------------------------------\r\n# File: tst_MemoryMapHeaderGenerator.pro\r\n#-----------------------------------------------------------------------------\r\n# Project: Kactus 2\r\n# Author: Mikko Teuho\r\n# Date: 05.05.2015\r\n#\r\n# Description:\r\n# Qt project file for running unit tests for memory map header generator.\r\n#-----------------------------------------------------------------------------\r\n\r\nTEMPLATE = app\r\n\r\nTARGET = tst_MemoryMapHeaderGenerator\r\n\r\nQT += core xml gui testlib widgets\r\nCONFIG += c++11 testcase console\r\n\r\nDEFINES += MEMORYMAPHEADERGENERATOR_LIB\r\n\r\nQMAKE_EXPORTED_VARIABLES += MAKE_TESTARGS\r\nMAKE_TESTARGS.name = TESTARGS\r\nMAKE_TESTARGS.value = \"-platform offscreen\"\r\n\r\nwin32:CONFIG(release, debug|release) {\r\n    LIBS += -L$$PWD/../../../executable/ -lIPXACTmodels\r\n    LIBS += -L$$PWD/../../../executable/ -lKactusAPI\r\n    DESTDIR = ./release\r\n}\r\nelse:win32:CONFIG(debug, debug|release) {\r\n    LIBS += -L$$PWD/../../../executable/ -lIPXACTmodelsd\r\n    LIBS += -L$$PWD/../../../executable/ -lKactusAPId\r\n    DESTDIR = ./debug\r\n}\r\nelse:unix {\r\n    LIBS += -L$$PWD/../../../executable/ -lIPXACTmodels -lKactusAPI\r\n    DESTDIR = ./release\r\n}\r\n\r\nINCLUDEPATH += $$PWD/../../../\r\nINCLUDEPATH += $$PWD/../../../executable\r\nINCLUDEPATH += $$PWD/../../../executable/Plugins\r\nINCLUDEPATH += $$PWD/../../../executable/Plugins/MemoryMapHeaderGenerator\r\nINCLUDEPATH += $$PWD/../../../KactusAPI/include\r\nINCLUDEPATH += $$DESTDIR\r\n\r\nDEPENDPATH += $$PWD/../../../\r\nDEPENDPATH += $$PWD/../../../executable\r\nDEPENDPATH += $$PWD/../../../executable/Plugins\r\nDEPENDPATH += $$PWD/../../../executable/Plugins/MemoryMapHeaderGenerator\r\nDEPENDPATH += .\r\n\r\nOBJECTS_DIR += $$DESTDIR\r\n\r\nMOC_DIR += ./generatedFiles\r\nUI_DIR += ./generatedFiles\r\nRCC_DIR += ./generatedFiles\r\ninclude(tst_MemoryMapHeaderGenerator.pri)\r\n"
  },
  {
    "path": "tests/Plugins/MemoryViewGenerator/tst_MemoryViewGenerator.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: tst_MemoryViewGenerator.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Esko Pekkarinen\r\n// Date: 25.04.2016\r\n//\r\n// Description:\r\n// Unit test for class MemoryViewGenerator.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include <QtTest>\r\n\r\n#include <Plugins/MemoryViewGenerator/MemoryViewGenerator.h>\r\n#include <KactusAPI/include/PluginUtilityAdapter.h>\r\n\r\n#include <tests/MockObjects/LibraryMock.h>\r\n\r\n#include <IPXACTmodels/Component/AddressBlock.h>\r\n#include <IPXACTmodels/Component/AddressSpace.h>\r\n#include <IPXACTmodels/Component/BusInterface.h>\r\n#include <IPXACTmodels/Component/Channel.h>\r\n#include <IPXACTmodels/Component/Component.h>\r\n#include <IPXACTmodels/Component/Field.h>\r\n#include <IPXACTmodels/Component/InitiatorInterface.h>\r\n#include <IPXACTmodels/Component/MemoryMap.h>\r\n#include <IPXACTmodels/Component/MemoryRemap.h>\r\n#include <IPXACTmodels/Component/MirroredTargetInterface.h>\r\n#include <IPXACTmodels/Component/Register.h>\r\n#include <IPXACTmodels/Component/RemapState.h>\r\n#include <IPXACTmodels/Component/TargetInterface.h>\r\n#include <IPXACTmodels/Component/TransparentBridge.h>\r\n\r\n#include <IPXACTmodels/designConfiguration/DesignConfiguration.h>\r\n\r\nclass tst_MemoryViewGenerator : public QObject\r\n{\r\n    Q_OBJECT\r\n\r\npublic:\r\n    tst_MemoryViewGenerator();\r\n\r\nprivate slots:\r\n\r\n    void init();\r\n    void cleanup();\r\n    \r\n    void testConnectedSlaveAddressBlocksAreWritten();\r\n\r\n    void testMultipleReferencesToSameDesign();\r\n  \r\n    void testConnectedSlaveRegistersAndFieldsAreWritten();\r\n   \r\n    void testConnectedRegisterDimensionsAreWritten();\r\n   \r\n    void testMasterOffsetIsCalculated();\r\n\r\n    void testRegisterWithLongFields();\r\n\r\n    void testExpressionsWithoutReferences();\r\n\r\n    void testIsPresent();\r\n\r\n    void testRemapOnBusComponent();\r\n\r\n    void testMultipleChannels();\r\n\r\n    void testHierarchicalDesign();\r\n\r\n    void testActiveViewConfiguration();\r\n\r\n    void testMasterInHierarchy();\r\n\r\n    void testRemapStatesOnSlave();\r\n\r\n    void testSegmentsWithinAddressSpace();\r\n\r\n    void testMultipleConnectionsFromMaster();\r\n\r\n    void testBridge();\r\n\r\n    void testIdenticalHierarchies();\r\n\r\n    void testParameterOverrideAtInstance();\r\n\r\nprivate:\r\n    \r\n    QString runGenerator();\r\n\r\n    QSharedPointer<Component> createMasterComponent(VLNV masterVLNV);\r\n\r\n    QSharedPointer<AddressSpace> createAddressSpace(QSharedPointer<Component> containingComponent,\r\n        QString const& name);\r\n\r\n    void connectMasterAndSlaveInstance();\r\n\r\n    void createMasterAndSlaveInstances(VLNV masterVLNV, VLNV slaveVLNV);\r\n\r\n    QSharedPointer<Component> createSlaveComponent(VLNV slaveVLNV);\r\n\r\n    void createComponentInstance(VLNV const& vlnv, QString const& name, QString const& id, QSharedPointer<Design> design);\r\n\r\n    void createInterconnection(QString const& instance1, QString const& interface1, QString const& instance2,\r\n        QString const& interface2, QSharedPointer<Design> design);\r\n\r\n    void createHierarchicalConnection(QString const& topInterface, QString const& componentInstance, \r\n        QString const& componentInterface, QSharedPointer<Design> design);\r\n\r\n    QSharedPointer<AddressBlock> addAddressBlock(QString const& name, QString const& baseAddress, QString const& range,\r\n        QString const& width, QSharedPointer<MemoryMap> containingMemoryMap);\r\n\r\n    void addHierarchyReference(QSharedPointer<Component> hierarchicalComponent, VLNV designVLNV);\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    LibraryMock* library_;\r\n\r\n    QSharedPointer<Component> topComponent_;\r\n\r\n    QSharedPointer<Design> design_;\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_MemoryViewGenerator::tst_MemoryViewGenerator()\r\n//-----------------------------------------------------------------------------\r\ntst_MemoryViewGenerator::tst_MemoryViewGenerator(): library_(new LibraryMock(this)), topComponent_(), design_()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_MemoryViewGenerator::init()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_MemoryViewGenerator::init()\r\n{        \r\n    VLNV vlnv(VLNV::COMPONENT, \"Test\", \"TestLibrary\", \"TopComponent\", \"1.0\");\r\n    topComponent_ = QSharedPointer<Component>(new Component(vlnv, Document::Revision::Std14));\r\n\r\n    VLNV designVlnv(VLNV::DESIGN, \"Test\", \"TestLibrary\", \"TestDesign\", \"1.0\");\r\n    design_ = QSharedPointer<Design>(new Design(designVlnv, Document::Revision::Std14));\r\n    library_->addComponent(design_);\r\n    \r\n    QSharedPointer<View> hierarchicalView(new View(\"hierarchical\"));\r\n    hierarchicalView->setDesignInstantiationRef(\"design\");\r\n    topComponent_->getViews()->append(hierarchicalView);\r\n\r\n    QSharedPointer<DesignInstantiation> designInstantiation(new DesignInstantiation(\"design\"));\r\n    designInstantiation->setDesignReference(QSharedPointer<ConfigurableVLNVReference>(\r\n        new ConfigurableVLNVReference(design_->getVlnv())));\r\n    topComponent_->getDesignInstantiations()->append(designInstantiation);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_MemoryViewGenerator::cleanup()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_MemoryViewGenerator::cleanup()\r\n{\r\n    library_->clear();\r\n\r\n    QFile outputFile(\"./output.csv\");\r\n    outputFile.remove();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_MemoryViewGenerator::testConnectedSlaveAddressBlocksAreWritten()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_MemoryViewGenerator::testConnectedSlaveAddressBlocksAreWritten()\r\n{\r\n    VLNV masterVLNV(VLNV::COMPONENT, \"tut.fi\", \"TestLib\", \"TestMaster\", \"1.0\");\r\n    VLNV slaveVLNV(VLNV::COMPONENT, \"tut.fi\", \"TestLib\", \"TestSlave\", \"1.0\");\r\n\r\n    createMasterComponent(masterVLNV);\r\n\r\n    QSharedPointer<Component> slaveComponent = createSlaveComponent(slaveVLNV);\r\n\r\n    QSharedPointer<MemoryMap> slaveMemoryMap(new MemoryMap(\"slaveMemoryMap\"));\r\n    slaveComponent->getMemoryMaps()->append(slaveMemoryMap);\r\n\r\n    addAddressBlock(\"firstBlock\", \"0\", \"8\", \"32\", slaveMemoryMap);\r\n    addAddressBlock(\"secondBlock\", \"8\", \"4\", \"32\", slaveMemoryMap);\r\n\r\n    createMasterAndSlaveInstances(masterVLNV, slaveVLNV);\r\n    connectMasterAndSlaveInstance();\r\n\r\n    QString output = runGenerator();\r\n\r\n    QCOMPARE(output, QString(\"Identifier;Type;Address;Range (AUB);Width (bits);Size (bits);Offset (bits);\\n\"\r\n        \"tut.fi.TestLib.TestMaster.1.0.masterID.masterInstance.masterIf_space;addressSpace;0x0;;;;;\\n\"\r\n        \"tut.fi.TestLib.TestSlave.1.0.slaveID.slaveInstance.slaveMemoryMap;memoryMap;0x0;;;;;\\n\"\r\n        \"tut.fi.TestLib.TestSlave.1.0.slaveID.slaveInstance.slaveMemoryMap.firstBlock;addressBlock;0x0;8;32;;;\\n\"\r\n        \"tut.fi.TestLib.TestSlave.1.0.slaveID.slaveInstance.slaveMemoryMap.secondBlock;addressBlock;0x8;4;32;;;\\n\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_MemoryViewGenerator::testMultipleReferencesToSameDesign()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_MemoryViewGenerator::testMultipleReferencesToSameDesign()\r\n{\r\n    QSharedPointer<View> hierarchicalView = topComponent_->getViews()->first();\r\n    hierarchicalView->setDesignConfigurationInstantiationRef(\"config\");\r\n\r\n    VLNV configVLNV(VLNV::DESIGNCONFIGURATION, \"tut.fi\", \"TestLib\", \"TestConfiguration\", \"1.0\");\r\n\r\n    QSharedPointer<DesignConfiguration> designConfiguration(new DesignConfiguration(configVLNV, Document::Revision::Std14));\r\n    designConfiguration->setDesignRef(design_->getVlnv());\r\n    library_->addComponent(designConfiguration);\r\n\r\n    QSharedPointer<DesignConfigurationInstantiation> configInstantiation(\r\n        new DesignConfigurationInstantiation(\"config\"));\r\n    configInstantiation->setDesignConfigurationReference(QSharedPointer<ConfigurableVLNVReference>(\r\n        new ConfigurableVLNVReference(configVLNV)));\r\n\r\n    topComponent_->getDesignConfigurationInstantiations()->append(configInstantiation);\r\n\r\n    VLNV masterVLNV(VLNV::COMPONENT, \"tut.fi\", \"TestLib\", \"TestMaster\", \"1.0\");\r\n    VLNV slaveVLNV(VLNV::COMPONENT, \"tut.fi\", \"TestLib\", \"TestSlave\", \"1.0\");\r\n\r\n    createMasterComponent(masterVLNV);\r\n\r\n    QSharedPointer<Component> slaveComponent = createSlaveComponent(slaveVLNV);\r\n\r\n    QSharedPointer<MemoryMap> slaveMemoryMap(new MemoryMap(\"slaveMemoryMap\"));\r\n    slaveComponent->getMemoryMaps()->append(slaveMemoryMap);\r\n\r\n    addAddressBlock(\"firstBlock\", \"0\", \"8\", \"32\", slaveMemoryMap);\r\n    addAddressBlock(\"secondBlock\", \"8\", \"4\", \"32\", slaveMemoryMap);\r\n\r\n    createMasterAndSlaveInstances(masterVLNV, slaveVLNV);\r\n    connectMasterAndSlaveInstance();\r\n\r\n    QString output = runGenerator();\r\n\r\n    QCOMPARE(output, QString(\"Identifier;Type;Address;Range (AUB);Width (bits);Size (bits);Offset (bits);\\n\"\r\n        \"tut.fi.TestLib.TestMaster.1.0.masterID.masterInstance.masterIf_space;addressSpace;0x0;;;;;\\n\"\r\n        \"tut.fi.TestLib.TestSlave.1.0.slaveID.slaveInstance.slaveMemoryMap;memoryMap;0x0;;;;;\\n\"\r\n        \"tut.fi.TestLib.TestSlave.1.0.slaveID.slaveInstance.slaveMemoryMap.firstBlock;addressBlock;0x0;8;32;;;\\n\"\r\n        \"tut.fi.TestLib.TestSlave.1.0.slaveID.slaveInstance.slaveMemoryMap.secondBlock;addressBlock;0x8;4;32;;;\\n\"\r\n    ));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_MemoryViewGenerator::testConnectedSlaveRegistersAndFieldsAreWritten()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_MemoryViewGenerator::testConnectedSlaveRegistersAndFieldsAreWritten()\r\n{\r\n    VLNV masterVLNV(VLNV::COMPONENT, \"tut.fi\", \"TestLib\", \"TestMaster\", \"1.0\");\r\n    VLNV slaveVLNV(VLNV::COMPONENT, \"tut.fi\", \"TestLib\", \"TestSlave\", \"1.0\");\r\n\r\n    createMasterComponent(masterVLNV);\r\n\r\n    QSharedPointer<Component> slaveComponent = createSlaveComponent(slaveVLNV);\r\n\r\n    QSharedPointer<MemoryMap> slaveMemoryMap(new MemoryMap(\"slaveMemoryMap\"));\r\n    slaveComponent->getMemoryMaps()->append(slaveMemoryMap);\r\n\r\n    QSharedPointer<AddressBlock> slaveAddressBlock = addAddressBlock(\"slaveBlock\", \"0\", \"8\", \"32\", slaveMemoryMap);\r\n\r\n    QSharedPointer<Register> firstRegister(new Register(\"firstRegister\", \"0\", \"32\"));\r\n    slaveAddressBlock->getRegisterData()->append(firstRegister);\r\n\r\n    QSharedPointer<Register> secondRegister(new Register(\"secondRegister\", \"2\", \"32\"));\r\n    slaveAddressBlock->getRegisterData()->append(secondRegister);\r\n\r\n    QSharedPointer<Field> firstField(new Field(\"firstField\"));\r\n    firstField->setBitWidth(\"16\");\r\n    firstField->setBitOffset(\"1\");\r\n\r\n    QSharedPointer<Field> secondField(new Field(\"secondField\"));\r\n    secondField->setBitWidth(\"1\");\r\n    secondField->setBitOffset(\"0\");\r\n\r\n    secondRegister->getFields()->append(firstField);\r\n    secondRegister->getFields()->append(secondField);\r\n\r\n    createMasterAndSlaveInstances(masterVLNV, slaveVLNV);\r\n    connectMasterAndSlaveInstance();\r\n\r\n    QString output = runGenerator();\r\n\r\n    QCOMPARE(output, QString(\"Identifier;Type;Address;Range (AUB);Width (bits);Size (bits);Offset (bits);\\n\"\r\n        \"tut.fi.TestLib.TestMaster.1.0.masterID.masterInstance.masterIf_space;addressSpace;0x0;;;;;\\n\"\r\n        \"tut.fi.TestLib.TestSlave.1.0.slaveID.slaveInstance.slaveMemoryMap;memoryMap;0x0;;;;;\\n\"\r\n        \"tut.fi.TestLib.TestSlave.1.0.slaveID.slaveInstance.slaveMemoryMap.slaveBlock;addressBlock;0x0;8;32;;;\\n\"\r\n        \"tut.fi.TestLib.TestSlave.1.0.slaveID.slaveInstance.slaveMemoryMap.slaveBlock.firstRegister;register;0x0;;;32;0;\\n\"\r\n        \"tut.fi.TestLib.TestSlave.1.0.slaveID.slaveInstance.slaveMemoryMap.slaveBlock.firstRegister.HARD;reset;0x0;;;;;\\n\"\r\n        \"tut.fi.TestLib.TestSlave.1.0.slaveID.slaveInstance.slaveMemoryMap.slaveBlock.secondRegister;register;0x2;;;32;2;\\n\"\r\n        \"tut.fi.TestLib.TestSlave.1.0.slaveID.slaveInstance.slaveMemoryMap.slaveBlock.secondRegister.secondField;field;0x2;;1;;0;\\n\"\r\n        \"tut.fi.TestLib.TestSlave.1.0.slaveID.slaveInstance.slaveMemoryMap.slaveBlock.secondRegister.firstField;field;0x2;;16;;1;\\n\"\r\n        \"tut.fi.TestLib.TestSlave.1.0.slaveID.slaveInstance.slaveMemoryMap.slaveBlock.secondRegister.HARD;reset;0x0;;;;;\\n\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_MemoryViewGenerator::testConnectedRegisterDimensionsAreWritten()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_MemoryViewGenerator::testConnectedRegisterDimensionsAreWritten()\r\n{\r\n    VLNV masterVLNV(VLNV::COMPONENT, \"tut.fi\", \"TestLib\", \"TestMaster\", \"1.0\");\r\n    VLNV slaveVLNV(VLNV::COMPONENT, \"tut.fi\", \"TestLib\", \"TestSlave\", \"1.0\");\r\n\r\n    createMasterComponent(masterVLNV);\r\n\r\n    QSharedPointer<Component> slaveComponent = createSlaveComponent(slaveVLNV);\r\n\r\n    QSharedPointer<MemoryMap> slaveMemoryMap(new MemoryMap(\"slaveMemoryMap\"));\r\n    slaveMemoryMap->setAddressUnitBits(\"32\");\r\n    slaveComponent->getMemoryMaps()->append(slaveMemoryMap);\r\n\r\n    QSharedPointer<AddressBlock> slaveAddressBlock = addAddressBlock(\"slaveBlock\", \"0\", \"8\", \"32\", slaveMemoryMap);\r\n\r\n    QSharedPointer<Register> firstRegister(new Register(\"firstRegister\", \"0\", \"32\"));\r\n    firstRegister->setDimension(\"2\");\r\n    slaveAddressBlock->getRegisterData()->append(firstRegister);\r\n\r\n    QSharedPointer<Field> firstField(new Field(\"firstField\"));\r\n    firstField->setBitWidth(\"16\");\r\n    firstField->setBitOffset(\"1\");\r\n\r\n    firstRegister->getFields()->append(firstField);\r\n\r\n    createMasterAndSlaveInstances(masterVLNV, slaveVLNV);\r\n    connectMasterAndSlaveInstance();\r\n\r\n    QString output = runGenerator();\r\n\r\n    QCOMPARE(output, QString(\"Identifier;Type;Address;Range (AUB);Width (bits);Size (bits);Offset (bits);\\n\"\r\n        \"tut.fi.TestLib.TestMaster.1.0.masterID.masterInstance.masterIf_space;addressSpace;0x0;;;;;\\n\"\r\n        \"tut.fi.TestLib.TestSlave.1.0.slaveID.slaveInstance.slaveMemoryMap;memoryMap;0x0;;;;;\\n\"\r\n        \"tut.fi.TestLib.TestSlave.1.0.slaveID.slaveInstance.slaveMemoryMap.slaveBlock;addressBlock;0x0;8;32;;;\\n\"\r\n        \"tut.fi.TestLib.TestSlave.1.0.slaveID.slaveInstance.slaveMemoryMap.slaveBlock.firstRegister[0];register;0x0;;;32;0;\\n\"\r\n        \"tut.fi.TestLib.TestSlave.1.0.slaveID.slaveInstance.slaveMemoryMap.slaveBlock.firstRegister[0].firstField;field;0x0;;16;;1;\\n\"\r\n        \"tut.fi.TestLib.TestSlave.1.0.slaveID.slaveInstance.slaveMemoryMap.slaveBlock.firstRegister[0].HARD;reset;0x0;;;;;\\n\"\r\n        \"tut.fi.TestLib.TestSlave.1.0.slaveID.slaveInstance.slaveMemoryMap.slaveBlock.firstRegister[1];register;0x1;;;32;0;\\n\"\r\n        \"tut.fi.TestLib.TestSlave.1.0.slaveID.slaveInstance.slaveMemoryMap.slaveBlock.firstRegister[1].firstField;field;0x1;;16;;1;\\n\"\r\n        \"tut.fi.TestLib.TestSlave.1.0.slaveID.slaveInstance.slaveMemoryMap.slaveBlock.firstRegister[1].HARD;reset;0x0;;;;;\\n\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_MemoryViewGenerator::testMasterOffsetIsCalculated()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_MemoryViewGenerator::testMasterOffsetIsCalculated()\r\n{\r\n    VLNV masterVLNV(VLNV::COMPONENT, \"tut.fi\", \"TestLib\", \"TestMaster\", \"1.0\");\r\n    VLNV slaveVLNV(VLNV::COMPONENT, \"tut.fi\", \"TestLib\", \"TestSlave\", \"1.0\");\r\n\r\n    QSharedPointer<Component> masterComponent = createMasterComponent(masterVLNV);\r\n\r\n    QSharedPointer<BusInterface> masterInterface = masterComponent->getBusInterface(\"masterIf\");\r\n    masterInterface->getMaster()->setBaseAddress(\"256\");\r\n\r\n    QSharedPointer<Component> slaveComponent = createSlaveComponent(slaveVLNV);\r\n\r\n    QSharedPointer<MemoryMap> slaveMemoryMap(new MemoryMap(\"slaveMemoryMap\"));\r\n    slaveComponent->getMemoryMaps()->append(slaveMemoryMap);\r\n\r\n    QSharedPointer<AddressBlock> slaveAddressBlock = addAddressBlock(\"slaveBlock\", \"16\", \"8\", \"32\", slaveMemoryMap);\r\n\r\n    QSharedPointer<Register> firstRegister(new Register(\"firstRegister\", \"8\", \"32\"));\r\n    slaveAddressBlock->getRegisterData()->append(firstRegister);\r\n\r\n    QSharedPointer<Field> firstField(new Field(\"firstField\"));\r\n    firstField->setBitWidth(\"16\");\r\n    firstField->setBitOffset(\"0\");\r\n\r\n    firstRegister->getFields()->append(firstField);\r\n\r\n    createMasterAndSlaveInstances(masterVLNV, slaveVLNV);\r\n    connectMasterAndSlaveInstance();\r\n\r\n    QString output = runGenerator();\r\n\r\n    QCOMPARE(output, QString(\"Identifier;Type;Address;Range (AUB);Width (bits);Size (bits);Offset (bits);\\n\"\r\n        \"tut.fi.TestLib.TestMaster.1.0.masterID.masterInstance.masterIf_space;addressSpace;0x100;;;;;\\n\"\r\n        \"tut.fi.TestLib.TestSlave.1.0.slaveID.slaveInstance.slaveMemoryMap;memoryMap;0x100;;;;;\\n\"\r\n        \"tut.fi.TestLib.TestSlave.1.0.slaveID.slaveInstance.slaveMemoryMap.slaveBlock;addressBlock;0x110;8;32;;;\\n\"\r\n        \"tut.fi.TestLib.TestSlave.1.0.slaveID.slaveInstance.slaveMemoryMap.slaveBlock.firstRegister;register;0x118;;;32;8;\\n\"\r\n        \"tut.fi.TestLib.TestSlave.1.0.slaveID.slaveInstance.slaveMemoryMap.slaveBlock.firstRegister.firstField;field;0x118;;16;;0;\\n\"\r\n        \"tut.fi.TestLib.TestSlave.1.0.slaveID.slaveInstance.slaveMemoryMap.slaveBlock.firstRegister.HARD;reset;0x100;;;;;\\n\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_MemoryViewGenerator::testRegisterWithLongFields()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_MemoryViewGenerator::testRegisterWithLongFields()\r\n{\r\n    VLNV masterVLNV(VLNV::COMPONENT, \"tut.fi\", \"TestLib\", \"TestMaster\", \"1.0\");\r\n    VLNV slaveVLNV(VLNV::COMPONENT, \"tut.fi\", \"TestLib\", \"TestSlave\", \"1.0\");\r\n\r\n    createMasterComponent(masterVLNV);\r\n\r\n    QSharedPointer<Component> slaveComponent = createSlaveComponent(slaveVLNV);\r\n\r\n    QSharedPointer<MemoryMap> slaveMemoryMap(new MemoryMap(\"slaveMemoryMap\"));\r\n    slaveMemoryMap->setAddressUnitBits(\"16\");\r\n    slaveComponent->getMemoryMaps()->append(slaveMemoryMap);\r\n\r\n    QSharedPointer<AddressBlock> slaveAddressBlock = addAddressBlock(\"slaveBlock\", \"0\", \"8\", \"16\", slaveMemoryMap);\r\n\r\n    QSharedPointer<Register> firstRegister(new Register(\"firstRegister\", \"0\", \"32\"));\r\n    firstRegister->setDimension(\"2\");\r\n    slaveAddressBlock->getRegisterData()->append(firstRegister);\r\n\r\n    QSharedPointer<Register> secondRegister(new Register(\"secondRegister\", \"4\", \"64\"));\r\n    slaveAddressBlock->getRegisterData()->append(secondRegister);\r\n\r\n    QSharedPointer<Field> firstField(new Field(\"firstField\"));\r\n    firstField->setBitWidth(\"16\");\r\n    firstField->setBitOffset(\"0\");\r\n    secondRegister->getFields()->append(firstField);\r\n\r\n    QSharedPointer<Field> secondField(new Field(\"secondField\"));\r\n    secondField->setBitWidth(\"16\");\r\n    secondField->setBitOffset(\"16\");\r\n    secondRegister->getFields()->append(secondField);\r\n\r\n    QSharedPointer<Field> thirdField(new Field(\"thirdField\"));\r\n    thirdField->setBitWidth(\"4\");\r\n    thirdField->setBitOffset(\"40\");\r\n    secondRegister->getFields()->append(thirdField);\r\n\r\n    createMasterAndSlaveInstances(masterVLNV, slaveVLNV);\r\n\r\n    connectMasterAndSlaveInstance();\r\n\r\n    QString output = runGenerator();\r\n\r\n    QCOMPARE(output, QString(\"Identifier;Type;Address;Range (AUB);Width (bits);Size (bits);Offset (bits);\\n\"\r\n        \"tut.fi.TestLib.TestMaster.1.0.masterID.masterInstance.masterIf_space;addressSpace;0x0;;;;;\\n\"\r\n        \"tut.fi.TestLib.TestSlave.1.0.slaveID.slaveInstance.slaveMemoryMap;memoryMap;0x0;;;;;\\n\"\r\n        \"tut.fi.TestLib.TestSlave.1.0.slaveID.slaveInstance.slaveMemoryMap.slaveBlock;addressBlock;0x0;8;16;;;\\n\"\r\n        \"tut.fi.TestLib.TestSlave.1.0.slaveID.slaveInstance.slaveMemoryMap.slaveBlock.firstRegister[0];register;0x0;;;32;0;\\n\"\r\n        \"tut.fi.TestLib.TestSlave.1.0.slaveID.slaveInstance.slaveMemoryMap.slaveBlock.firstRegister[0].HARD;reset;0x0;;;;;\\n\"\r\n        \"tut.fi.TestLib.TestSlave.1.0.slaveID.slaveInstance.slaveMemoryMap.slaveBlock.firstRegister[1];register;0x2;;;32;0;\\n\"\r\n        \"tut.fi.TestLib.TestSlave.1.0.slaveID.slaveInstance.slaveMemoryMap.slaveBlock.firstRegister[1].HARD;reset;0x0;;;;;\\n\"\r\n        \"tut.fi.TestLib.TestSlave.1.0.slaveID.slaveInstance.slaveMemoryMap.slaveBlock.secondRegister;register;0x4;;;64;4;\\n\"\r\n        \"tut.fi.TestLib.TestSlave.1.0.slaveID.slaveInstance.slaveMemoryMap.slaveBlock.secondRegister.firstField;field;0x4;;16;;0;\\n\"\r\n        \"tut.fi.TestLib.TestSlave.1.0.slaveID.slaveInstance.slaveMemoryMap.slaveBlock.secondRegister.secondField;field;0x5;;16;;16;\\n\"\r\n        \"tut.fi.TestLib.TestSlave.1.0.slaveID.slaveInstance.slaveMemoryMap.slaveBlock.secondRegister.thirdField;field;0x6;;4;;40;\\n\"\r\n        \"tut.fi.TestLib.TestSlave.1.0.slaveID.slaveInstance.slaveMemoryMap.slaveBlock.secondRegister.HARD;reset;0x0;;;;;\\n\"\r\n    ));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_MemoryViewGenerator::testExpressionsWithoutReferences()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_MemoryViewGenerator::testExpressionsWithoutReferences()\r\n{\r\n    VLNV masterVLNV(VLNV::COMPONENT, \"tut.fi\", \"TestLib\", \"TestMaster\", \"1.0\");\r\n    VLNV slaveVLNV(VLNV::COMPONENT, \"tut.fi\", \"TestLib\", \"TestSlave\", \"1.0\");\r\n\r\n    createMasterComponent(masterVLNV);\r\n\r\n    QSharedPointer<Component> slaveComponent = createSlaveComponent(slaveVLNV);\r\n\r\n    QSharedPointer<MemoryMap> slaveMemoryMap(new MemoryMap(\"slaveMemoryMap\"));\r\n    slaveMemoryMap->setAddressUnitBits(\"4+4\");\r\n    slaveComponent->getMemoryMaps()->append(slaveMemoryMap);\r\n\r\n    QSharedPointer<AddressBlock> slaveAddressBlock = addAddressBlock(\"slaveBlock\", \"2+2\", \"2*6\", \"4*4\", slaveMemoryMap);\r\n\r\n    QSharedPointer<Register> firstRegister(new Register(\"firstRegister\", \"1+1\", \"2*8\"));\r\n    slaveAddressBlock->getRegisterData()->append(firstRegister);\r\n \r\n    QSharedPointer<Field> firstField(new Field(\"firstField\"));\r\n    firstField->setBitWidth(\"4+4+4+4\");\r\n    firstField->setBitOffset(\"1+2\");\r\n    firstRegister->getFields()->append(firstField);\r\n\r\n    QSharedPointer<Register> secondRegister(new Register(\"secondRegister\", \"'h4\", \"'d16\"));\r\n    secondRegister->setDimension(\"1+1\");\r\n    slaveAddressBlock->getRegisterData()->append(secondRegister);\r\n\r\n    createMasterAndSlaveInstances(masterVLNV, slaveVLNV);\r\n    connectMasterAndSlaveInstance();\r\n\r\n    QString output = runGenerator();\r\n\r\n    QCOMPARE(output, QString(\"Identifier;Type;Address;Range (AUB);Width (bits);Size (bits);Offset (bits);\\n\"\r\n        \"tut.fi.TestLib.TestMaster.1.0.masterID.masterInstance.masterIf_space;addressSpace;0x0;;;;;\\n\"\r\n        \"tut.fi.TestLib.TestSlave.1.0.slaveID.slaveInstance.slaveMemoryMap;memoryMap;0x0;;;;;\\n\"\r\n        \"tut.fi.TestLib.TestSlave.1.0.slaveID.slaveInstance.slaveMemoryMap.slaveBlock;addressBlock;0x4;12;16;;;\\n\"\r\n        \"tut.fi.TestLib.TestSlave.1.0.slaveID.slaveInstance.slaveMemoryMap.slaveBlock.firstRegister;register;0x6;;;16;2;\\n\"\r\n        \"tut.fi.TestLib.TestSlave.1.0.slaveID.slaveInstance.slaveMemoryMap.slaveBlock.firstRegister.firstField;field;0x6;;16;;3;\\n\"\r\n        \"tut.fi.TestLib.TestSlave.1.0.slaveID.slaveInstance.slaveMemoryMap.slaveBlock.firstRegister.HARD;reset;0x0;;;;;\\n\"\r\n        \"tut.fi.TestLib.TestSlave.1.0.slaveID.slaveInstance.slaveMemoryMap.slaveBlock.secondRegister[0];register;0x8;;;16;4;\\n\"\r\n        \"tut.fi.TestLib.TestSlave.1.0.slaveID.slaveInstance.slaveMemoryMap.slaveBlock.secondRegister[0].HARD;reset;0x0;;;;;\\n\"\r\n        \"tut.fi.TestLib.TestSlave.1.0.slaveID.slaveInstance.slaveMemoryMap.slaveBlock.secondRegister[1];register;0xa;;;16;4;\\n\"\r\n        \"tut.fi.TestLib.TestSlave.1.0.slaveID.slaveInstance.slaveMemoryMap.slaveBlock.secondRegister[1].HARD;reset;0x0;;;;;\\n\"\r\n    ));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_MemoryViewGenerator::testIsPresent()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_MemoryViewGenerator::testIsPresent()\r\n{\r\n    VLNV masterVLNV(VLNV::COMPONENT, \"tut.fi\", \"TestLib\", \"TestMaster\", \"1.0\");\r\n    VLNV slaveVLNV(VLNV::COMPONENT, \"tut.fi\", \"TestLib\", \"TestSlave\", \"1.0\");\r\n\r\n    createMasterComponent(masterVLNV);\r\n\r\n    QSharedPointer<Component> slaveComponent = createSlaveComponent(slaveVLNV);\r\n\r\n    QSharedPointer<MemoryMap> slaveMemoryMap(new MemoryMap(\"slaveMemoryMap\"));\r\n    slaveComponent->getMemoryMaps()->append(slaveMemoryMap);\r\n\r\n    QSharedPointer<MemoryMap> nonPresentMemoryMap(new MemoryMap(\"nonPresentMemoryMap\"));\r\n    nonPresentMemoryMap->setIsPresent(\"0\");\r\n    slaveComponent->getMemoryMaps()->append(nonPresentMemoryMap);\r\n\r\n    QSharedPointer<AddressBlock> slaveAddressBlock = addAddressBlock(\"slaveBlock\", \"0\", \"8\", \"32\", slaveMemoryMap);\r\n    slaveAddressBlock->setIsPresent(\"true\");\r\n\r\n    QSharedPointer<AddressBlock> nonPresentBlock = addAddressBlock(\"nonPresentBlock\", \"0\", \"8\", \"32\", slaveMemoryMap);\r\n    nonPresentBlock->setIsPresent(\"false\");\r\n\r\n    QSharedPointer<Register> firstRegister(new Register(\"firstRegister\", \"0\", \"32\"));\r\n    slaveAddressBlock->getRegisterData()->append(firstRegister);\r\n\r\n    QSharedPointer<Register> nonPresentRegister(new Register(\"nonPresentRegister\", \"2\", \"32\"));\r\n    nonPresentRegister->setIsPresent(\"1-1\");\r\n    slaveAddressBlock->getRegisterData()->append(nonPresentRegister);\r\n\r\n    QSharedPointer<Field> nonPresentField(new Field(\"nonPresentField\"));\r\n    nonPresentField->setIsPresent(\"false\");\r\n    nonPresentField->setBitWidth(\"1\");\r\n    nonPresentField->setBitOffset(\"0\");\r\n\r\n    createMasterAndSlaveInstances(masterVLNV, slaveVLNV);\r\n    connectMasterAndSlaveInstance();\r\n\r\n    QString output = runGenerator();\r\n\r\n    QCOMPARE(output, QString(\"Identifier;Type;Address;Range (AUB);Width (bits);Size (bits);Offset (bits);\\n\"\r\n        \"tut.fi.TestLib.TestMaster.1.0.masterID.masterInstance.masterIf_space;addressSpace;0x0;;;;;\\n\"\r\n        \"tut.fi.TestLib.TestSlave.1.0.slaveID.slaveInstance.slaveMemoryMap;memoryMap;0x0;;;;;\\n\"\r\n        \"tut.fi.TestLib.TestSlave.1.0.slaveID.slaveInstance.slaveMemoryMap.slaveBlock;addressBlock;0x0;8;32;;;\\n\"\r\n        \"tut.fi.TestLib.TestSlave.1.0.slaveID.slaveInstance.slaveMemoryMap.slaveBlock.firstRegister;register;0x0;;;32;0;\\n\"\r\n        \"tut.fi.TestLib.TestSlave.1.0.slaveID.slaveInstance.slaveMemoryMap.slaveBlock.firstRegister.HARD;reset;0x0;;;;;\\n\"\r\n    ));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_MemoryViewGenerator::testRemapOnBusComponent()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_MemoryViewGenerator::testRemapOnBusComponent()\r\n{\r\n    VLNV masterVLNV(VLNV::COMPONENT, \"tut.fi\", \"TestLib\", \"TestMaster\", \"1.0\");\r\n    VLNV busVLNV(VLNV::COMPONENT, \"tut.fi\", \"TestLib\", \"TestBus\", \"1.0\");\r\n    VLNV slaveVLNV(VLNV::COMPONENT, \"tut.fi\", \"TestLib\", \"TestSlave\", \"1.0\");\r\n\r\n    QSharedPointer<Component> masterComponent = createMasterComponent(masterVLNV);\r\n    masterComponent->getBusInterface(\"masterIf\")->getMaster()->setBaseAddress(\"4\");\r\n\r\n    QSharedPointer<Component> slaveComponent = createSlaveComponent(slaveVLNV);\r\n\r\n    QSharedPointer<MemoryMap> slaveMemoryMap(new MemoryMap(\"slaveMemoryMap\"));\r\n    slaveComponent->getMemoryMaps()->append(slaveMemoryMap);\r\n    QSharedPointer<AddressBlock> slaveAddressBlock = addAddressBlock(\"slaveBlock\", \"0\", \"8\", \"32\", slaveMemoryMap);\r\n\r\n    QSharedPointer<Component> busComponent(new Component(busVLNV, Document::Revision::Std14));\r\n    library_->addComponent(busComponent);\r\n\r\n    QSharedPointer<BusInterface> mirroredMasterInterface(new BusInterface());\r\n    mirroredMasterInterface->setName(\"mirroredMasterIf\");\r\n    mirroredMasterInterface->setInterfaceMode(General::MIRRORED_MASTER);\r\n    busComponent->getBusInterfaces()->append(mirroredMasterInterface);\r\n\r\n    QSharedPointer<BusInterface> mirroredSlaveInterface(new BusInterface());\r\n    mirroredSlaveInterface->setName(\"mirroredSlaveIf\");\r\n    mirroredSlaveInterface->setInterfaceMode(General::MIRRORED_SLAVE);\r\n    mirroredSlaveInterface->getMirroredSlave()->setRemapAddress(\"'h10\");\r\n    busComponent->getBusInterfaces()->append(mirroredSlaveInterface);\r\n\r\n    QStringList channelInterfaces;\r\n    channelInterfaces << \"mirroredMasterIf\" << \"mirroredSlaveIf\";\r\n\r\n    QSharedPointer<Channel> testChannel(new Channel());\r\n    testChannel->setName(\"testChannel\");\r\n    testChannel->setInterfaces(channelInterfaces);\r\n    busComponent->getChannels()->append(testChannel);\r\n\r\n    createComponentInstance(busVLNV, \"busInstance\", \"busID\", design_);\r\n\r\n    createMasterAndSlaveInstances(masterVLNV, slaveVLNV);\r\n\r\n    createInterconnection(\"masterInstance\", \"masterIf\", \"busInstance\", \"mirroredMasterIf\", design_);\r\n    createInterconnection(\"slaveInstance\", \"slaveIf\", \"busInstance\", \"mirroredSlaveIf\", design_);\r\n\r\n    QString output = runGenerator();\r\n\r\n    QCOMPARE(output, QString(\"Identifier;Type;Address;Range (AUB);Width (bits);Size (bits);Offset (bits);\\n\"\r\n        \"tut.fi.TestLib.TestMaster.1.0.masterID.masterInstance.masterIf_space;addressSpace;0x14;;;;;\\n\"\r\n        \"tut.fi.TestLib.TestSlave.1.0.slaveID.slaveInstance.slaveMemoryMap;memoryMap;0x14;;;;;\\n\"\r\n        \"tut.fi.TestLib.TestSlave.1.0.slaveID.slaveInstance.slaveMemoryMap.slaveBlock;addressBlock;0x14;8;32;;;\\n\"\r\n    ));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_MemoryViewGenerator::testMultipleChannels()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_MemoryViewGenerator::testMultipleChannels()\r\n{\r\n    VLNV masterVLNV(VLNV::COMPONENT, \"tut.fi\", \"TestLib\", \"TestMaster\", \"1.0\");\r\n    VLNV busVLNV(VLNV::COMPONENT, \"tut.fi\", \"TestLib\", \"TestBus\", \"1.0\");\r\n    VLNV slaveVLNV(VLNV::COMPONENT, \"tut.fi\", \"TestLib\", \"TestSlave\", \"1.0\");\r\n\r\n    QSharedPointer<Component> masterComponent = createMasterComponent(masterVLNV);\r\n    masterComponent->getBusInterface(\"masterIf\")->getMaster()->setBaseAddress(\"8\");\r\n\r\n    QSharedPointer<Component> slaveComponent = createSlaveComponent(slaveVLNV);\r\n    \r\n    QSharedPointer<MemoryMap> slaveMemoryMap(new MemoryMap(\"slaveMemoryMap\"));\r\n    slaveComponent->getMemoryMaps()->append(slaveMemoryMap);\r\n    QSharedPointer<AddressBlock> slaveAddressBlock = addAddressBlock(\"slaveBlock\", \"0\", \"8\", \"32\", slaveMemoryMap);\r\n\r\n\r\n    QSharedPointer<Component> busComponent(new Component(busVLNV, Document::Revision::Std14));\r\n    library_->addComponent(busComponent);\r\n\r\n    QSharedPointer<BusInterface> mirroredMasterInterface(new BusInterface());\r\n    mirroredMasterInterface->setName(\"mirroredMasterIf\");\r\n    mirroredMasterInterface->setInterfaceMode(General::MIRRORED_MASTER);\r\n    busComponent->getBusInterfaces()->append(mirroredMasterInterface);\r\n\r\n    QSharedPointer<BusInterface> mirroredSlaveInterface(new BusInterface());\r\n    mirroredSlaveInterface->setName(\"mirroredSlaveIf\");\r\n    mirroredSlaveInterface->setInterfaceMode(General::MIRRORED_SLAVE);\r\n    mirroredSlaveInterface->getMirroredSlave()->setRemapAddress(\"8\");\r\n    busComponent->getBusInterfaces()->append(mirroredSlaveInterface);\r\n\r\n    QSharedPointer<BusInterface> duplicateSlaveInterface(new BusInterface());\r\n    duplicateSlaveInterface->setName(\"duplicateSlaveIf\");\r\n    duplicateSlaveInterface->setInterfaceMode(General::MIRRORED_SLAVE);\r\n    duplicateSlaveInterface->getMirroredSlave()->setRemapAddress(\"16\");\r\n    busComponent->getBusInterfaces()->append(duplicateSlaveInterface);\r\n\r\n    QStringList channelInterfaces;\r\n    channelInterfaces << \"mirroredMasterIf\" << \"mirroredSlaveIf\" << \"duplicateSlaveIf\";\r\n\r\n    QSharedPointer<Channel> testChannel(new Channel());\r\n    testChannel->setName(\"testChannel\");\r\n    testChannel->setInterfaces(channelInterfaces);\r\n    busComponent->getChannels()->append(testChannel);\r\n\r\n    createComponentInstance(busVLNV, \"busInstance\", \"busID\", design_);\r\n\r\n    createMasterAndSlaveInstances(masterVLNV, slaveVLNV);\r\n\r\n    createComponentInstance(slaveVLNV, \"duplicateSlave\", \"duplicateID\", design_);\r\n\r\n    createInterconnection(\"masterInstance\", \"masterIf\", \"busInstance\", \"mirroredMasterIf\", design_);\r\n    createInterconnection(\"slaveInstance\", \"slaveIf\", \"busInstance\", \"mirroredSlaveIf\", design_);\r\n    createInterconnection(\"duplicateSlave\", \"slaveIf\", \"busInstance\", \"duplicateSlaveIf\", design_);\r\n\r\n    QString output = runGenerator();\r\n\r\n    QCOMPARE(output, QString(\"Identifier;Type;Address;Range (AUB);Width (bits);Size (bits);Offset (bits);\\n\"\r\n        \"tut.fi.TestLib.TestMaster.1.0.masterID.masterInstance.masterIf_space;addressSpace;0x10;;;;;\\n\"\r\n        \"tut.fi.TestLib.TestSlave.1.0.slaveID.slaveInstance.slaveMemoryMap;memoryMap;0x10;;;;;\\n\"\r\n        \"tut.fi.TestLib.TestSlave.1.0.slaveID.slaveInstance.slaveMemoryMap.slaveBlock;addressBlock;0x10;8;32;;;\\n\"\r\n        \"tut.fi.TestLib.TestMaster.1.0.masterID.masterInstance.masterIf_space;addressSpace;0x18;;;;;\\n\"\r\n        \"tut.fi.TestLib.TestSlave.1.0.duplicateID.duplicateSlave.slaveMemoryMap;memoryMap;0x18;;;;;\\n\"\r\n        \"tut.fi.TestLib.TestSlave.1.0.duplicateID.duplicateSlave.slaveMemoryMap.slaveBlock;addressBlock;0x18;8;32;;;\\n\"\r\n        ));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_MemoryViewGenerator::testHierarchicalDesign()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_MemoryViewGenerator::testHierarchicalDesign()\r\n{\r\n    VLNV masterVLNV(VLNV::COMPONENT, \"tut.fi\", \"TestLib\", \"TestMaster\", \"1.0\");\r\n    VLNV hierarchicalSlaveVLNV(VLNV::COMPONENT, \"tut.fi\", \"TestLib\", \"HierarchicalSlave\", \"1.0\");\r\n    VLNV slaveVLNV(VLNV::COMPONENT, \"tut.fi\", \"TestLib\", \"TestSlave\", \"1.0\");\r\n    VLNV designVLNV(VLNV::DESIGN, \"tut.fi\", \"TestLib\", \"SlaveDesign\", \"1.0\");\r\n    \r\n    QSharedPointer<Component> masterComponent = createMasterComponent(masterVLNV);\r\n    masterComponent->getBusInterface(\"masterIf\")->getMaster()->setBaseAddress(\"2\");\r\n\r\n    QSharedPointer<Component> hierarchicalComponent(new Component(hierarchicalSlaveVLNV, Document::Revision::Std14));\r\n    QSharedPointer<BusInterface> slaveIf(new BusInterface());\r\n    slaveIf->setName(\"slaveIf\");\r\n    slaveIf->setInterfaceMode(General::SLAVE);\r\n    hierarchicalComponent->getBusInterfaces()->append(slaveIf);\r\n\r\n    library_->addComponent(hierarchicalComponent);\r\n\r\n    QSharedPointer<Component> slaveComponent = createSlaveComponent(slaveVLNV);\r\n\r\n    QSharedPointer<MemoryMap> slaveMemoryMap(new MemoryMap(\"slaveMemoryMap\"));\r\n    slaveComponent->getMemoryMaps()->append(slaveMemoryMap);\r\n    QSharedPointer<AddressBlock> slaveAddressBlock = addAddressBlock(\"slaveBlock\", \"0\", \"8\", \"32\", slaveMemoryMap);\r\n\r\n    QSharedPointer<Design> slaveDesign(new Design(designVLNV, Document::Revision::Std14));\r\n    library_->addComponent(slaveDesign);\r\n\r\n    createComponentInstance(slaveVLNV, \"slaveInstance\", \"slaveID\", slaveDesign);\r\n\r\n    createHierarchicalConnection(\"slaveIf\", \"slaveInstance\", \"slaveIf\", slaveDesign);\r\n\r\n    addHierarchyReference(hierarchicalComponent, designVLNV);\r\n\r\n\r\n    createComponentInstance(masterVLNV, \"masterInstance\", \"masterID\", design_);\r\n    createComponentInstance(hierarchicalSlaveVLNV, \"hierarchicalInstance\", \"hierID\", design_);\r\n\r\n    createInterconnection(\"masterInstance\", \"masterIf\", \"hierarchicalInstance\", \"slaveIf\", design_);\r\n\r\n    QString output = runGenerator();\r\n\r\n    QCOMPARE(output, QString(\"Identifier;Type;Address;Range (AUB);Width (bits);Size (bits);Offset (bits);\\n\"\r\n        \"tut.fi.TestLib.TestMaster.1.0.masterID.masterInstance.masterIf_space;addressSpace;0x2;;;;;\\n\"\r\n        \"tut.fi.TestLib.TestSlave.1.0.slaveID.slaveInstance.slaveMemoryMap;memoryMap;0x2;;;;;\\n\"\r\n        \"tut.fi.TestLib.TestSlave.1.0.slaveID.slaveInstance.slaveMemoryMap.slaveBlock;addressBlock;0x2;8;32;;;\\n\"\r\n    ));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_MemoryViewGenerator::testActiveViewConfiguration()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_MemoryViewGenerator::testActiveViewConfiguration()\r\n{\r\n    VLNV masterVLNV(VLNV::COMPONENT, \"tut.fi\", \"TestLib\", \"TestMaster\", \"1.0\");\r\n    VLNV hierarchicalSlaveVLNV(VLNV::COMPONENT, \"tut.fi\", \"TestLib\", \"HierarchicalSlave\", \"1.0\");\r\n    VLNV slaveVLNV(VLNV::COMPONENT, \"tut.fi\", \"TestLib\", \"TestSlave\", \"1.0\");\r\n    VLNV designConfigVLNV(VLNV::DESIGNCONFIGURATION, \"tut.fi\", \"TestLib\", \"SlaveDesignConfig\", \"1.0\");\r\n    VLNV designVLNV(VLNV::DESIGN, \"tut.fi\", \"TestLib\", \"SlaveDesign\", \"1.0\");\r\n\r\n    QSharedPointer<Component> masterComponent = createMasterComponent(masterVLNV);\r\n\r\n    QSharedPointer<Component> hierarchicalComponent(new Component(hierarchicalSlaveVLNV, Document::Revision::Std14));\r\n    QSharedPointer<BusInterface> hierarchicalIf(new BusInterface());\r\n    hierarchicalIf->setName(\"slaveIf\");\r\n    hierarchicalIf->setInterfaceMode(General::SLAVE);    \r\n    hierarchicalIf->getSlave()->setMemoryMapRef(\"hierarchicalMemoryMap\");\r\n    hierarchicalComponent->getBusInterfaces()->append(hierarchicalIf);\r\n\r\n    library_->addComponent(hierarchicalComponent);\r\n\r\n    QSharedPointer<MemoryMap> hierarchicalMemoryMap(new MemoryMap(\"hierarchicalMemoryMap\"));\r\n    hierarchicalComponent->getMemoryMaps()->append(hierarchicalMemoryMap);\r\n    addAddressBlock(\"hierarchicalBlock\", \"8\", \"16\", \"32\", hierarchicalMemoryMap);\r\n\r\n    QSharedPointer<Component> slaveComponent = createSlaveComponent(slaveVLNV);\r\n\r\n    QSharedPointer<MemoryMap> slaveMemoryMap(new MemoryMap(\"slaveMemoryMap\"));\r\n    slaveComponent->getMemoryMaps()->append(slaveMemoryMap);\r\n    QSharedPointer<AddressBlock> slaveAddressBlock = addAddressBlock(\"slaveBlock\", \"0\", \"8\", \"32\", slaveMemoryMap);\r\n\r\n    QSharedPointer<DesignConfiguration> slaveDesignConfig(new DesignConfiguration(designConfigVLNV, Document::Revision::Std14));\r\n    slaveDesignConfig->setDesignRef(design_->getVlnv());\r\n\r\n    QSharedPointer<ViewConfiguration> activeView(new ViewConfiguration());\r\n    activeView->setInstanceName(\"hierarchicalInstance\");\r\n    activeView->setViewReference(\"hierarchical\");\r\n    slaveDesignConfig->getViewConfigurations()->append(activeView);\r\n\r\n    library_->addComponent(slaveDesignConfig);\r\n\r\n    QSharedPointer<Design> slaveDesign(new Design(designVLNV, Document::Revision::Std14));\r\n    library_->addComponent(slaveDesign);\r\n\r\n    createComponentInstance(slaveVLNV, \"slaveInstance\", \"slaveID\", slaveDesign);\r\n\r\n    createHierarchicalConnection(\"slaveIf\", \"slaveInstance\", \"slaveIf\", slaveDesign);\r\n\r\n    topComponent_->getViews()->first()->setDesignConfigurationInstantiationRef(\"instantiation\");\r\n\r\n    QSharedPointer<DesignConfigurationInstantiation> hierarchyInstantiation(\r\n        new DesignConfigurationInstantiation(\"instantiation\"));\r\n    hierarchyInstantiation->setDesignConfigurationReference(QSharedPointer<ConfigurableVLNVReference>(\r\n        new ConfigurableVLNVReference(designConfigVLNV)));\r\n    topComponent_->getDesignConfigurationInstantiations()->append(hierarchyInstantiation);\r\n\r\n    QSharedPointer<View> flatView(new View(\"flat\"));\r\n    hierarchicalComponent->getViews()->append(flatView);\r\n\r\n    QSharedPointer<View> hierarchicalView(new View(\"hierarchical\"));\r\n    hierarchicalView->setDesignInstantiationRef(\"instantiation\");\r\n    hierarchicalComponent->getViews()->append(hierarchicalView);\r\n\r\n    QSharedPointer<DesignInstantiation> designInstantiation(new DesignInstantiation(\"instantiation\"));\r\n    designInstantiation->setDesignReference(QSharedPointer<ConfigurableVLNVReference>(\r\n        new ConfigurableVLNVReference(designVLNV)));\r\n    hierarchicalComponent->getDesignInstantiations()->append(designInstantiation);\r\n\r\n    createComponentInstance(masterVLNV, \"masterInstance\", \"masterID\", design_);\r\n    createComponentInstance(hierarchicalSlaveVLNV, \"hierarchicalInstance\", \"hierarchyID\", design_);\r\n\r\n    createInterconnection(\"masterInstance\", \"masterIf\", \"hierarchicalInstance\", \"slaveIf\", design_);\r\n\r\n    QString output = runGenerator();\r\n\r\n    QCOMPARE(output, QString(\"Identifier;Type;Address;Range (AUB);Width (bits);Size (bits);Offset (bits);\\n\"\r\n        \"tut.fi.TestLib.TestMaster.1.0.masterID.masterInstance.masterIf_space;addressSpace;0x0;;;;;\\n\"\r\n        \"tut.fi.TestLib.TestSlave.1.0.slaveID.slaveInstance.slaveMemoryMap;memoryMap;0x0;;;;;\\n\"\r\n        \"tut.fi.TestLib.TestSlave.1.0.slaveID.slaveInstance.slaveMemoryMap.slaveBlock;addressBlock;0x0;8;32;;;\\n\"\r\n        ));\r\n\r\n    activeView->setViewReference(\"flat\");\r\n    output = runGenerator();\r\n\r\n    QCOMPARE(output, QString(\"Identifier;Type;Address;Range (AUB);Width (bits);Size (bits);Offset (bits);\\n\"\r\n        \"tut.fi.TestLib.TestMaster.1.0.masterID.masterInstance.masterIf_space;addressSpace;0x0;;;;;\\n\"\r\n        \"tut.fi.TestLib.HierarchicalSlave.1.0.hierarchyID.hierarchicalInstance.hierarchicalMemoryMap;memoryMap;0x0;;;;;\\n\"\r\n        \"tut.fi.TestLib.HierarchicalSlave.1.0.hierarchyID.hierarchicalInstance.hierarchicalMemoryMap.hierarchicalBlock;addressBlock;0x8;16;32;;;\\n\"\r\n        ));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_MemoryViewGenerator::testMasterInHierarchy()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_MemoryViewGenerator::testMasterInHierarchy()\r\n{\r\n    VLNV topConfigurationVLNV(VLNV::DESIGNCONFIGURATION, \"tut.fi\", \"TestLib\", \"TopConfig\", \"1.0\");\r\n    VLNV masterVLNV(VLNV::COMPONENT, \"tut.fi\", \"TestLib\", \"TestMaster\", \"1.0\");\r\n    VLNV slaveVLNV(VLNV::COMPONENT, \"tut.fi\", \"TestLib\", \"TestSlave\", \"1.0\");\r\n    VLNV masterConfigVLNV(VLNV::DESIGNCONFIGURATION, \"tut.fi\", \"TestLib\", \"MasterConfiguration\", \"1.0\");\r\n    VLNV masterDesignVLNV(VLNV::DESIGN, \"tut.fi\", \"TestLib\", \"MasterDesign\", \"1.0\");\r\n    VLNV subMasterVLNV(VLNV::COMPONENT, \"tut.fi\", \"TestLib\", \"SubMaster\", \"1.0\");\r\n\r\n    QSharedPointer<DesignConfiguration> topConfig(new DesignConfiguration(topConfigurationVLNV, Document::Revision::Std14));\r\n    topConfig->setDesignRef(design_->getVlnv());\r\n    topConfig->addViewConfiguration(\"master\", \"hier\");\r\n    library_->addComponent(topConfig);\r\n\r\n    topComponent_->getViews()->first()->setDesignConfigurationInstantiationRef(\"topDesign\");\r\n\r\n    QSharedPointer<DesignConfigurationInstantiation> topInstantiation(\r\n        new DesignConfigurationInstantiation(\"topDesign\"));\r\n    QSharedPointer<ConfigurableVLNVReference> topDesignReference(new ConfigurableVLNVReference(topConfigurationVLNV));\r\n    topInstantiation->setDesignConfigurationReference(topDesignReference);\r\n    topComponent_->getDesignConfigurationInstantiations()->append(topInstantiation);\r\n\r\n    QSharedPointer<Component> masterComponent = createMasterComponent(masterVLNV);\r\n    QSharedPointer<View> hierarchyView(new View(\"hierarchical\"));\r\n    masterComponent->getViews()->append(hierarchyView);\r\n\r\n    QSharedPointer<DesignConfigurationInstantiation> hierarchyInstance(\r\n        new DesignConfigurationInstantiation(\"masterDesignConfig\"));\r\n    QSharedPointer<ConfigurableVLNVReference> masterConfigReference(new ConfigurableVLNVReference(masterConfigVLNV));\r\n    hierarchyInstance->setDesignConfigurationReference(masterConfigReference);\r\n\r\n    hierarchyView->setDesignConfigurationInstantiationRef(\"masterDesignConfig\");\r\n    masterComponent->getDesignConfigurationInstantiations()->append(hierarchyInstance);\r\n\r\n    QSharedPointer<Component> slaveComponent = createSlaveComponent(slaveVLNV);\r\n\r\n    QSharedPointer<MemoryMap> slaveMemoryMap(new MemoryMap(\"slaveMemoryMap\"));\r\n    slaveComponent->getMemoryMaps()->append(slaveMemoryMap);\r\n\r\n    QSharedPointer<AddressBlock> slaveAddressBlock = addAddressBlock(\"slaveBlock\", \"8\", \"8\", \"32\", slaveMemoryMap);\r\n\r\n    createMasterAndSlaveInstances(masterVLNV, slaveVLNV);\r\n    connectMasterAndSlaveInstance();\r\n\r\n    QSharedPointer<DesignConfiguration> masterConfiguration(new DesignConfiguration(masterConfigVLNV, Document::Revision::Std14));\r\n    masterConfiguration->setDesignRef(masterDesignVLNV);\r\n    library_->addComponent(masterConfiguration);\r\n\r\n    QSharedPointer<Design> masterDesign(new Design(masterDesignVLNV, Document::Revision::Std14));\r\n    library_->addComponent(masterDesign);\r\n\r\n    QSharedPointer<Component> subMaster = createMasterComponent(subMasterVLNV);\r\n    subMaster->getBusInterface(\"masterIf\")->getMaster()->setBaseAddress(\"2\");\r\n    library_->addComponent(subMaster);\r\n\r\n    createComponentInstance(subMasterVLNV, \"master\", \"masterID\", masterDesign);\r\n    createHierarchicalConnection(\"masterIf\", \"master\", \"masterIf\", masterDesign);\r\n\r\n    QString output = runGenerator();\r\n\r\n    QCOMPARE(output, QString(\"Identifier;Type;Address;Range (AUB);Width (bits);Size (bits);Offset (bits);\\n\"\r\n        \"tut.fi.TestLib.SubMaster.1.0.masterID.master.masterIf_space;addressSpace;0x2;;;;;\\n\"\r\n        \"tut.fi.TestLib.TestSlave.1.0.slaveID.slaveInstance.slaveMemoryMap;memoryMap;0x2;;;;;\\n\"\r\n        \"tut.fi.TestLib.TestSlave.1.0.slaveID.slaveInstance.slaveMemoryMap.slaveBlock;addressBlock;0xa;8;32;;;\\n\"\r\n    ));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_MemoryViewGenerator::testRemapStatesOnSlave()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_MemoryViewGenerator::testRemapStatesOnSlave()\r\n{\r\n    VLNV masterVLNV(VLNV::COMPONENT, \"tut.fi\", \"TestLib\", \"TestMaster\", \"1.0\");\r\n    VLNV slaveVLNV(VLNV::COMPONENT, \"tut.fi\", \"TestLib\", \"TestSlave\", \"1.0\");\r\n\r\n    createMasterComponent(masterVLNV);\r\n\r\n    QSharedPointer<Component> slaveComponent = createSlaveComponent(slaveVLNV);\r\n\r\n    QSharedPointer<MemoryMap> slaveMemoryMap(new MemoryMap(\"slaveMemoryMap\"));\r\n    slaveComponent->getMemoryMaps()->append(slaveMemoryMap);\r\n\r\n    QSharedPointer<AddressBlock> slaveAddressBlock = addAddressBlock(\"slaveBlock\", \"0\", \"8\", \"32\", slaveMemoryMap);\r\n\r\n    QSharedPointer<Register> firstRegister(new Register(\"firstRegister\", \"0\", \"32\"));\r\n    slaveAddressBlock->getRegisterData()->append(firstRegister);\r\n\r\n    QSharedPointer<RemapState> testState(new RemapState(\"testState\"));\r\n    slaveComponent->getRemapStates()->append(testState);\r\n\r\n    QSharedPointer<MemoryRemap> testRemap(new MemoryRemap(\"testRemap\"));\r\n    testRemap->setRemapState(\"testState\");\r\n    slaveMemoryMap->getMemoryRemaps()->append(testRemap);\r\n\r\n    QSharedPointer<AddressBlock> remapAddressBlock(new AddressBlock(\"remapAddressBlock\"));\r\n    remapAddressBlock->setBaseAddress(\"16\");\r\n    remapAddressBlock->setRange(\"4\");\r\n    remapAddressBlock->setWidth(\"32\");\r\n    \r\n    testRemap->getMemoryBlocks()->append(remapAddressBlock);\r\n\r\n    QSharedPointer<Register> remapRegister(new Register(\"remapRegister\", \"0\", \"32\"));\r\n    remapAddressBlock->getRegisterData()->append(remapRegister);\r\n\r\n    createMasterAndSlaveInstances(masterVLNV, slaveVLNV);\r\n    connectMasterAndSlaveInstance();\r\n\r\n    QString output = runGenerator();\r\n\r\n    QCOMPARE(output, QString(\"Identifier;Type;Address;Range (AUB);Width (bits);Size (bits);Offset (bits);\\n\"\r\n        \"tut.fi.TestLib.TestMaster.1.0.masterID.masterInstance.masterIf_space;addressSpace;0x0;;;;;\\n\"\r\n        \"tut.fi.TestLib.TestSlave.1.0.slaveID.slaveInstance.slaveMemoryMap;memoryMap;0x0;;;;;\\n\"\r\n        \"tut.fi.TestLib.TestSlave.1.0.slaveID.slaveInstance.slaveMemoryMap.slaveBlock;addressBlock;0x0;8;32;;;\\n\"\r\n        \"tut.fi.TestLib.TestSlave.1.0.slaveID.slaveInstance.slaveMemoryMap.slaveBlock.firstRegister;register;0x0;;;32;0;\\n\"\r\n        \"tut.fi.TestLib.TestSlave.1.0.slaveID.slaveInstance.slaveMemoryMap.slaveBlock.firstRegister.HARD;reset;0x0;;;;;\\n\"\r\n        \"tut.fi.TestLib.TestSlave.1.0.slaveID.slaveInstance.testRemap;memoryRemap;0x0;;;;;\\n\"\r\n        \"tut.fi.TestLib.TestSlave.1.0.slaveID.slaveInstance.testRemap.remapAddressBlock;addressBlock;0x10;4;32;;;\\n\"\r\n        \"tut.fi.TestLib.TestSlave.1.0.slaveID.slaveInstance.testRemap.remapAddressBlock.remapRegister;register;0x10;;;32;0;\\n\"\r\n        \"tut.fi.TestLib.TestSlave.1.0.slaveID.slaveInstance.testRemap.remapAddressBlock.remapRegister.HARD;reset;0x0;;;;;\\n\"\r\n    ));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_MemoryViewGenerator::testSegmentsWithinAddressSpace()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_MemoryViewGenerator::testSegmentsWithinAddressSpace()\r\n{\r\n    VLNV masterVLNV(VLNV::COMPONENT, \"tut.fi\", \"TestLib\", \"TestMaster\", \"1.0\");\r\n    VLNV slaveVLNV(VLNV::COMPONENT, \"tut.fi\", \"TestLib\", \"TestSlave\", \"1.0\");\r\n\r\n    QSharedPointer<Component> masterComponent = createMasterComponent(masterVLNV);\r\n    masterComponent->getBusInterface(\"masterIf\")->getMaster()->setAddressSpaceRef(\"masterAddressSpace\");\r\n    createComponentInstance(masterVLNV, \"masterInstance\", \"masterID\", design_);\r\n\r\n    QSharedPointer<AddressSpace> masterSpace(new AddressSpace(\"masterAddressSpace\"));\r\n    masterComponent->getAddressSpaces()->append(masterSpace);\r\n\r\n    QSharedPointer<Segment> firstSegment(new Segment(\"firstSegment\"));\r\n    firstSegment->setRange(\"2\");    \r\n    firstSegment->setOffset(\"8\");\r\n    \r\n    masterSpace->getSegments()->append(firstSegment);\r\n\r\n    QSharedPointer<Segment> secondSegment(new Segment(\"secondSegment\"));\r\n    secondSegment->setRange(\"'h10\");    \r\n    secondSegment->setOffset(\"'h10\");\r\n\r\n    masterSpace->getSegments()->append(secondSegment);\r\n\r\n    QSharedPointer<Segment> disabledSegment(new Segment(\"disabledSegment\"));\r\n    disabledSegment->setIsPresent(\"0\");\r\n    disabledSegment->setRange(\"8\");    \r\n    disabledSegment->setOffset(\"10\");\r\n    \r\n    masterSpace->getSegments()->append(disabledSegment);\r\n\r\n    QSharedPointer<Component> slaveComponent = createSlaveComponent(slaveVLNV);\r\n    QSharedPointer<MemoryMap> slaveMemoryMap(new MemoryMap(\"slaveMemoryMap\"));\r\n    slaveComponent->getMemoryMaps()->append(slaveMemoryMap);\r\n\r\n    createMasterAndSlaveInstances(masterVLNV, slaveVLNV);\r\n    connectMasterAndSlaveInstance();\r\n\r\n    QString output = runGenerator();\r\n\r\n    QCOMPARE(output, QString(\"Identifier;Type;Address;Range (AUB);Width (bits);Size (bits);Offset (bits);\\n\"\r\n        \"tut.fi.TestLib.TestMaster.1.0.masterID.masterInstance.masterAddressSpace;addressSpace;0x0;;;;;\\n\"\r\n        \"tut.fi.TestLib.TestMaster.1.0.masterID.masterInstance.masterAddressSpace.firstSegment;segment;0x0;2;;;8;\\n\"\r\n        \"tut.fi.TestLib.TestMaster.1.0.masterID.masterInstance.masterAddressSpace.secondSegment;segment;0x0;16;;;16;\\n\"\r\n        \"tut.fi.TestLib.TestSlave.1.0.slaveID.slaveInstance.slaveMemoryMap;memoryMap;0x0;;;;;\\n\"\r\n    ));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_MemoryViewGenerator::testMultipleConnectionsFromMaster()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_MemoryViewGenerator::testMultipleConnectionsFromMaster()\r\n{\r\n    VLNV masterVLNV(VLNV::COMPONENT, \"tut.fi\", \"TestLib\", \"TestMaster\", \"1.0\");\r\n    VLNV slaveVLNV(VLNV::COMPONENT, \"tut.fi\", \"TestLib\", \"TestSlave\", \"1.0\");\r\n\r\n    createMasterComponent(masterVLNV);\r\n\r\n    QSharedPointer<Component> slaveComponent = createSlaveComponent(slaveVLNV);\r\n\r\n    QSharedPointer<MemoryMap> slaveMemoryMap(new MemoryMap(\"slaveMemoryMap\"));\r\n    slaveComponent->getMemoryMaps()->append(slaveMemoryMap);\r\n\r\n    QSharedPointer<AddressBlock> slaveAddressBlock = addAddressBlock(\"slaveBlock\", \"0\", \"8\", \"32\", slaveMemoryMap);\r\n\r\n    createComponentInstance(masterVLNV, \"master\", \"masterID\", design_);\r\n    createComponentInstance(slaveVLNV, \"slave1\", \"slave1_id\", design_);\r\n    createComponentInstance(slaveVLNV, \"slave2\", \"slave2_id\", design_);\r\n\r\n    createInterconnection(\"master\", \"masterIf\", \"slave1\", \"slaveIf\", design_);\r\n    createInterconnection(\"master\", \"masterIf\", \"slave2\", \"slaveIf\", design_);\r\n\r\n    QString output = runGenerator();\r\n\r\n    QCOMPARE(output, QString(\"Identifier;Type;Address;Range (AUB);Width (bits);Size (bits);Offset (bits);\\n\"\r\n        \"tut.fi.TestLib.TestMaster.1.0.masterID.master.masterIf_space;addressSpace;0x0;;;;;\\n\"\r\n        \"tut.fi.TestLib.TestSlave.1.0.slave1_id.slave1.slaveMemoryMap;memoryMap;0x0;;;;;\\n\"\r\n        \"tut.fi.TestLib.TestSlave.1.0.slave1_id.slave1.slaveMemoryMap.slaveBlock;addressBlock;0x0;8;32;;;\\n\"\r\n        \"tut.fi.TestLib.TestMaster.1.0.masterID.master.masterIf_space;addressSpace;0x0;;;;;\\n\"\r\n        \"tut.fi.TestLib.TestSlave.1.0.slave2_id.slave2.slaveMemoryMap;memoryMap;0x0;;;;;\\n\"\r\n        \"tut.fi.TestLib.TestSlave.1.0.slave2_id.slave2.slaveMemoryMap.slaveBlock;addressBlock;0x0;8;32;;;\\n\"\r\n        ));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_MemoryViewGenerator::testBridge()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_MemoryViewGenerator::testBridge()\r\n{\r\n    VLNV masterVLNV(VLNV::COMPONENT, \"tut.fi\", \"TestLib\", \"TestMaster\", \"1.0\");\r\n    VLNV bridgeVLNV(VLNV::COMPONENT, \"tut.fi\", \"TestLib\", \"TestBridge\", \"1.0\");\r\n    VLNV slaveVLNV(VLNV::COMPONENT, \"tut.fi\", \"TestLib\", \"TestSlave\", \"1.0\");\r\n\r\n    createMasterComponent(masterVLNV);\r\n\r\n    QSharedPointer<Component> bridgeComponent(new Component(bridgeVLNV, Document::Revision::Std14));\r\n\r\n    QSharedPointer<BusInterface> bridgeMaster(new BusInterface());\r\n    bridgeMaster->setName(\"bridgeMaster\");\r\n    bridgeMaster->setInterfaceMode(General::MASTER);\r\n    bridgeComponent->getBusInterfaces()->append(bridgeMaster);\r\n    \r\n    QSharedPointer<BusInterface> bridgeSlave(new BusInterface());\r\n    bridgeSlave->setName(\"bridgeSlave\");\r\n    bridgeSlave->setInterfaceMode(General::SLAVE);\r\n    \r\n    QSharedPointer<TransparentBridge> bridge(new TransparentBridge());\r\n    bridge->setMasterRef(\"bridgeMaster\");\r\n    bridgeSlave->getSlave()->getBridges()->append(bridge);\r\n\r\n    bridgeComponent->getBusInterfaces()->append(bridgeSlave);\r\n    library_->addComponent(bridgeComponent);\r\n\r\n    QSharedPointer<Component> slaveComponent = createSlaveComponent(slaveVLNV);\r\n\r\n    QSharedPointer<MemoryMap> slaveMemoryMap(new MemoryMap(\"slaveMemoryMap\"));\r\n    slaveComponent->getMemoryMaps()->append(slaveMemoryMap);\r\n\r\n    QSharedPointer<AddressBlock> slaveAddressBlock = addAddressBlock(\"slaveBlock\", \"0\", \"8\", \"32\", slaveMemoryMap);\r\n\r\n    createComponentInstance(masterVLNV, \"master\", \"masterID\", design_);\r\n    createComponentInstance(bridgeVLNV, \"bridge\", \"bridgeID\", design_);\r\n    createComponentInstance(slaveVLNV, \"slave\", \"slaveID\", design_);\r\n    \r\n    createInterconnection(\"master\", \"masterIf\", \"bridge\", \"bridgeSlave\", design_);\r\n    createInterconnection(\"bridge\", \"bridgeMaster\", \"slave\", \"slaveIf\", design_);\r\n    \r\n    QString output = runGenerator();\r\n\r\n    QCOMPARE(output, QString(\"Identifier;Type;Address;Range (AUB);Width (bits);Size (bits);Offset (bits);\\n\"\r\n        \"tut.fi.TestLib.TestMaster.1.0.masterID.master.masterIf_space;addressSpace;0x0;;;;;\\n\"\r\n        \"tut.fi.TestLib.TestSlave.1.0.slaveID.slave.slaveMemoryMap;memoryMap;0x0;;;;;\\n\"\r\n        \"tut.fi.TestLib.TestSlave.1.0.slaveID.slave.slaveMemoryMap.slaveBlock;addressBlock;0x0;8;32;;;\\n\"\r\n        ));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_MemoryViewGenerator::testIdenticalHierarchies()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_MemoryViewGenerator::testIdenticalHierarchies()\r\n{\r\n    VLNV masterVLNV(VLNV::COMPONENT, \"tut.fi\", \"TestLib\", \"TestMaster\", \"1.0\");\r\n    VLNV busVLNV(VLNV::COMPONENT, \"tut.fi\", \"TestLib\", \"TestBridge\", \"1.0\");\r\n    VLNV slaveVLNV(VLNV::COMPONENT, \"tut.fi\", \"TestLib\", \"TestSlave\", \"1.0\");\r\n    VLNV subDesign(VLNV::DESIGN, \"tut.fi\", \"TestLib\", \"SubDesign\", \"1.0\");\r\n    VLNV subSlave(VLNV::COMPONENT, \"tut.fi\", \"TestLib\", \"SubSlave\", \"1.0\");\r\n\r\n    createMasterComponent(masterVLNV);\r\n\r\n    QSharedPointer<Component> busComponent(new Component(busVLNV, Document::Revision::Std14));\r\n    library_->addComponent(busComponent);\r\n\r\n    QSharedPointer<BusInterface> mirroredMasterInterface(new BusInterface());\r\n    mirroredMasterInterface->setName(\"mirroredMasterIf\");\r\n    mirroredMasterInterface->setInterfaceMode(General::MIRRORED_MASTER);\r\n    busComponent->getBusInterfaces()->append(mirroredMasterInterface);\r\n\r\n    QSharedPointer<BusInterface> mirroredSlaveInterface(new BusInterface());\r\n    mirroredSlaveInterface->setName(\"mirroredSlaveIf\");\r\n    mirroredSlaveInterface->setInterfaceMode(General::MIRRORED_SLAVE);\r\n    mirroredSlaveInterface->getMirroredSlave()->setRemapAddress(\"8\");\r\n    busComponent->getBusInterfaces()->append(mirroredSlaveInterface);\r\n\r\n    QSharedPointer<BusInterface> duplicateSlaveInterface(new BusInterface());\r\n    duplicateSlaveInterface->setName(\"duplicateSlaveIf\");\r\n    duplicateSlaveInterface->setInterfaceMode(General::MIRRORED_SLAVE);\r\n    duplicateSlaveInterface->getMirroredSlave()->setRemapAddress(\"16\");\r\n    busComponent->getBusInterfaces()->append(duplicateSlaveInterface);\r\n\r\n    QStringList channelInterfaces;\r\n    channelInterfaces << \"mirroredMasterIf\" << \"mirroredSlaveIf\" << \"duplicateSlaveIf\";\r\n\r\n    QSharedPointer<Channel> testChannel(new Channel());\r\n    testChannel->setName(\"testChannel\");\r\n    testChannel->setInterfaces(channelInterfaces);\r\n    busComponent->getChannels()->append(testChannel);\r\n\r\n    QSharedPointer<Component> hierarchicalSlave(new Component(slaveVLNV, Document::Revision::Std14));\r\n    library_->addComponent(hierarchicalSlave);\r\n\r\n    QSharedPointer<BusInterface> hierarchicalSlaveInterface(new BusInterface());\r\n    hierarchicalSlaveInterface->setName(\"hierarchicalSlaveIf\");\r\n    hierarchicalSlaveInterface->setInterfaceMode(General::SLAVE);\r\n    hierarchicalSlave->getBusInterfaces()->append(hierarchicalSlaveInterface);\r\n\r\n    QSharedPointer<Design> slaveDesign(new Design(subDesign, Document::Revision::Std14));\r\n    library_->addComponent(slaveDesign);\r\n\r\n    createComponentInstance(subSlave, \"subSlave\", \"subID\", slaveDesign);\r\n    createHierarchicalConnection(\"hierarchicalSlaveIf\", \"subSlave\", \"slaveIf\", slaveDesign);\r\n\r\n    QSharedPointer<Component> slaveComponent = createSlaveComponent(subSlave);\r\n\r\n    QSharedPointer<MemoryMap> slaveMemoryMap(new MemoryMap(\"slaveMemoryMap\"));\r\n    slaveComponent->getMemoryMaps()->append(slaveMemoryMap);\r\n\r\n    QSharedPointer<AddressBlock> slaveAddressBlock = addAddressBlock(\"slaveBlock\", \"0\", \"8\", \"32\", slaveMemoryMap);\r\n\r\n    addHierarchyReference(hierarchicalSlave, subDesign);\r\n\r\n    createComponentInstance(masterVLNV, \"master\", \"masterID\", design_);\r\n    createComponentInstance(busVLNV, \"busInstance\", \"busID\", design_);\r\n    createComponentInstance(slaveVLNV, \"slave1\", \"slave1_id\", design_);\r\n    createComponentInstance(slaveVLNV, \"slave2\", \"slave2_id\", design_);\r\n\r\n    createInterconnection(\"master\", \"masterIf\", \"busInstance\", \"mirroredMasterIf\", design_);\r\n    createInterconnection(\"slave1\", \"hierarchicalSlaveIf\", \"busInstance\", \"mirroredSlaveIf\", design_);\r\n    createInterconnection(\"slave2\", \"hierarchicalSlaveIf\", \"busInstance\", \"duplicateSlaveIf\", design_);\r\n\r\n    QString output = runGenerator();\r\n\r\n    QCOMPARE(output, QString(\"Identifier;Type;Address;Range (AUB);Width (bits);Size (bits);Offset (bits);\\n\"\r\n        \"tut.fi.TestLib.TestMaster.1.0.masterID.master.masterIf_space;addressSpace;0x8;;;;;\\n\"\r\n        \"tut.fi.TestLib.SubSlave.1.0.subID.subSlave.slaveMemoryMap;memoryMap;0x8;;;;;\\n\"\r\n        \"tut.fi.TestLib.SubSlave.1.0.subID.subSlave.slaveMemoryMap.slaveBlock;addressBlock;0x8;8;32;;;\\n\"\r\n        \"tut.fi.TestLib.TestMaster.1.0.masterID.master.masterIf_space;addressSpace;0x10;;;;;\\n\"\r\n        \"tut.fi.TestLib.SubSlave.1.0.subID.subSlave.slaveMemoryMap;memoryMap;0x10;;;;;\\n\"\r\n        \"tut.fi.TestLib.SubSlave.1.0.subID.subSlave.slaveMemoryMap.slaveBlock;addressBlock;0x10;8;32;;;\\n\"\r\n        ));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_MemoryViewGenerator::testParameterOverrideAtInstance()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_MemoryViewGenerator::testParameterOverrideAtInstance()\r\n{\r\n    VLNV masterVLNV(VLNV::COMPONENT, \"tut.fi\", \"TestLib\", \"TestMaster\", \"1.0\");\r\n    VLNV slaveVLNV(VLNV::COMPONENT, \"tut.fi\", \"TestLib\", \"TestSlave\", \"1.0\");\r\n\r\n    createMasterComponent(masterVLNV);\r\n\r\n    QSharedPointer<Component> slaveComponent = createSlaveComponent(slaveVLNV);\r\n\r\n    QSharedPointer<Parameter> slaveParameter(new Parameter());\r\n    slaveParameter->setName(\"data_width\");\r\n    slaveParameter->setValueId(\"id\");\r\n    slaveParameter->setValue(\"8\");\r\n    slaveParameter->setValueResolve(\"user\");\r\n    slaveComponent->getParameters()->append(slaveParameter);\r\n\r\n    QSharedPointer<MemoryMap> slaveMemoryMap(new MemoryMap(\"slaveMemoryMap\"));\r\n    slaveComponent->getMemoryMaps()->append(slaveMemoryMap);\r\n\r\n    QSharedPointer<AddressBlock> slaveAddressBlock = addAddressBlock(\"slaveBlock\", \"0\", \"8\", \"id\", slaveMemoryMap);\r\n\r\n    QSharedPointer<Register> firstRegister(new Register(\"firstRegister\", \"0\", \"id\"));\r\n    slaveAddressBlock->getRegisterData()->append(firstRegister);\r\n\r\n    QSharedPointer<Field> firstField(new Field(\"firstField\"));\r\n    firstField->setBitWidth(\"id\");\r\n    firstField->setBitOffset(\"1\");\r\n\r\n    firstRegister->getFields()->append(firstField);\r\n\r\n    createMasterAndSlaveInstances(masterVLNV, slaveVLNV);\r\n    connectMasterAndSlaveInstance();\r\n\r\n    QSharedPointer<ComponentInstance> slaveInstance = design_->getComponentInstances()->last();\r\n\r\n    QSharedPointer<ConfigurableElementValue> parameterOverride(new ConfigurableElementValue(\"32\", \"id\"));\r\n    slaveInstance->getConfigurableElementValues()->append(parameterOverride);\r\n\r\n    QString output = runGenerator();\r\n\r\n    QCOMPARE(output, QString(\"Identifier;Type;Address;Range (AUB);Width (bits);Size (bits);Offset (bits);\\n\"\r\n        \"tut.fi.TestLib.TestMaster.1.0.masterID.masterInstance.masterIf_space;addressSpace;0x0;;;;;\\n\"\r\n        \"tut.fi.TestLib.TestSlave.1.0.slaveID.slaveInstance.slaveMemoryMap;memoryMap;0x0;;;;;\\n\"\r\n        \"tut.fi.TestLib.TestSlave.1.0.slaveID.slaveInstance.slaveMemoryMap.slaveBlock;addressBlock;0x0;8;32;;;\\n\"\r\n        \"tut.fi.TestLib.TestSlave.1.0.slaveID.slaveInstance.slaveMemoryMap.slaveBlock.firstRegister;register;0x0;;;32;0;\\n\"\r\n        \"tut.fi.TestLib.TestSlave.1.0.slaveID.slaveInstance.slaveMemoryMap.slaveBlock.firstRegister.firstField;field;0x0;;32;;1;\\n\"\r\n        \"tut.fi.TestLib.TestSlave.1.0.slaveID.slaveInstance.slaveMemoryMap.slaveBlock.firstRegister.HARD;reset;0x0;;;;;\\n\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_MemoryViewGenerator::runGenerator()\r\n//-----------------------------------------------------------------------------\r\nQString tst_MemoryViewGenerator::runGenerator()\r\n{\r\n    MemoryViewGenerator generator(library_);\r\n    generator.generate(topComponent_, \"\", \"output.csv\");\r\n\r\n    QFile outputFile(\"./output.csv\");\r\n\r\n    outputFile.open(QIODevice::ReadOnly);\r\n    QString output = outputFile.readAll();\r\n    outputFile.close();\r\n\r\n    return output;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_MemoryViewGenerator::createMasterComponent()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<Component> tst_MemoryViewGenerator::createMasterComponent(VLNV masterVLNV)\r\n{\r\n    QSharedPointer<Component> masterComponent(new Component(masterVLNV, Document::Revision::Std14));\r\n    QSharedPointer<BusInterface> masterIf(new BusInterface());\r\n    masterIf->setName(\"masterIf\");\r\n    masterIf->setInterfaceMode(General::MASTER);\r\n    masterComponent->getBusInterfaces()->append(masterIf);\r\n\r\n    QSharedPointer<AddressSpace> masterSpace = createAddressSpace(masterComponent, masterIf->name() + \"_space\");\r\n    QSharedPointer<InitiatorInterface> masterInterfaceData(new InitiatorInterface());\r\n    masterInterfaceData->setAddressSpaceRef(masterSpace->name());\r\n\r\n    masterIf->setMaster(masterInterfaceData);\r\n\r\n    library_->addComponent(masterComponent);\r\n\r\n    return masterComponent;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_MemoryViewGenerator::createAddressSpace()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<AddressSpace> tst_MemoryViewGenerator::createAddressSpace(\r\n    QSharedPointer<Component> containingComponent, QString const& name)\r\n{\r\n    QSharedPointer<AddressSpace> newAddressSpace(new AddressSpace(name));\r\n\r\n    containingComponent->getAddressSpaces()->append(newAddressSpace);\r\n\r\n    return newAddressSpace;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_MemoryViewGenerator::createSlaveComponent()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<Component> tst_MemoryViewGenerator::createSlaveComponent(VLNV slaveVLNV)\r\n{\r\n    QSharedPointer<Component> slaveComponent(new Component(slaveVLNV, Document::Revision::Std14));\r\n\r\n    QSharedPointer<BusInterface> slaveIf(new BusInterface());\r\n    slaveIf->setName(\"slaveIf\");\r\n    slaveIf->setInterfaceMode(General::SLAVE);\r\n    slaveIf->getSlave()->setMemoryMapRef(\"slaveMemoryMap\");\r\n    slaveComponent->getBusInterfaces()->append(slaveIf);\r\n\r\n    library_->addComponent(slaveComponent);\r\n\r\n    return slaveComponent;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_MemoryViewGenerator::createMasterAndSlaveInstances()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_MemoryViewGenerator::createMasterAndSlaveInstances(VLNV masterVLNV, VLNV slaveVLNV)\r\n{\r\n    createComponentInstance(masterVLNV, \"masterInstance\", \"masterID\", design_);\r\n    createComponentInstance(slaveVLNV, \"slaveInstance\", \"slaveID\", design_);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_MemoryViewGenerator::connectMasterAndSlaveInstance()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_MemoryViewGenerator::connectMasterAndSlaveInstance()\r\n{\r\n    QSharedPointer<Interconnection> masterSlaveConnection(new Interconnection());\r\n\r\n    QSharedPointer<ActiveInterface> masterInterface(new ActiveInterface(\"masterInstance\", \"masterIf\"));\r\n    masterSlaveConnection->setStartInterface(masterInterface);\r\n\r\n    QSharedPointer<ActiveInterface> slaveInterface(new ActiveInterface(\"slaveInstance\", \"slaveIf\"));\r\n    masterSlaveConnection->getActiveInterfaces()->append(slaveInterface);\r\n    design_->getInterconnections()->append(masterSlaveConnection);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_MemoryViewGenerator::createComponentInstance()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_MemoryViewGenerator::createComponentInstance(VLNV const& vlnv, QString const& name,\r\n    QString const& id, QSharedPointer<Design> design)\r\n{\r\n    QSharedPointer<ConfigurableVLNVReference> vlnvReference(new ConfigurableVLNVReference(vlnv));\r\n\r\n    QSharedPointer<ComponentInstance> newInstance(new ComponentInstance(name, vlnvReference));\r\n    newInstance->setUuid(id);\r\n\r\n    design->getComponentInstances()->append(newInstance);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_MemoryViewGenerator::createInterconnection()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_MemoryViewGenerator::createInterconnection(QString const& instance1, QString const& interface1,\r\n    QString const& instance2, QString const& interface2, QSharedPointer<Design> design)\r\n{\r\n    QSharedPointer<Interconnection> connection(new Interconnection());\r\n\r\n    QSharedPointer<ActiveInterface> slaveInterface(new ActiveInterface(instance1, interface1));\r\n    connection->setStartInterface(slaveInterface);\r\n\r\n    QSharedPointer<ActiveInterface> mirroredSlave(new ActiveInterface(instance2, interface2));\r\n    connection->getActiveInterfaces()->append(mirroredSlave);\r\n\r\n    design_->getInterconnections()->append(connection);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_MemoryViewGenerator::createHierarchicalConnection()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_MemoryViewGenerator::createHierarchicalConnection(QString const& topInterface,\r\n    QString const& componentInstance, QString const& componentInterface, QSharedPointer<Design> design)\r\n{\r\n    QSharedPointer<Interconnection> hierarchicalConnection(new Interconnection());\r\n    QSharedPointer<ActiveInterface> startInterface(new ActiveInterface(componentInstance, componentInterface));\r\n    hierarchicalConnection->setStartInterface(startInterface);\r\n\r\n    QSharedPointer<HierInterface> hierInterface(new HierInterface(topInterface));\r\n    hierarchicalConnection->getHierInterfaces()->append(hierInterface);\r\n    design->getInterconnections()->append(hierarchicalConnection);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_MemoryViewGenerator::addAddressBlock()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<AddressBlock> tst_MemoryViewGenerator::addAddressBlock(QString const& name,\r\n    QString const& baseAddress, QString const& range, QString const& width, \r\n    QSharedPointer<MemoryMap> containingMemoryMap)\r\n{\r\n    QSharedPointer<AddressBlock> block(new AddressBlock(name, baseAddress));\r\n    block->setRange(range);\r\n    block->setWidth(width);\r\n    containingMemoryMap->getMemoryBlocks()->append(block);\r\n\r\n    return block;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_MemoryViewGenerator::addHierarchyReference()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_MemoryViewGenerator::addHierarchyReference(QSharedPointer<Component> hierarchicalComponent, \r\n    VLNV designVLNV)\r\n{\r\n    QSharedPointer<DesignInstantiation> hierarchyInstantiation(new DesignInstantiation(\"instantiation\"));\r\n    hierarchyInstantiation->setDesignReference(QSharedPointer<ConfigurableVLNVReference>(\r\n        new ConfigurableVLNVReference(designVLNV)));\r\n    hierarchicalComponent->getDesignInstantiations()->append(hierarchyInstantiation);\r\n\r\n    QSharedPointer<View> hierarchicalView(new View(\"hierarchical\"));\r\n    hierarchicalView->setDesignInstantiationRef(\"instantiation\");\r\n    hierarchicalComponent->getViews()->append(hierarchicalView);\r\n}\r\n\r\nQTEST_APPLESS_MAIN(tst_MemoryViewGenerator)\r\n\r\n#include \"tst_MemoryViewGenerator.moc\"\r\n"
  },
  {
    "path": "tests/Plugins/MemoryViewGenerator/tst_MemoryViewGenerator.pri",
    "content": "# ----------------------------------------------------\r\n# This file is generated by the Qt Visual Studio Tools.\r\n# ------------------------------------------------------\r\n\r\nHEADERS += ../../../editors/MemoryDesigner/ConnectivityComponent.h \\\r\n    ../../../editors/MemoryDesigner/ConnectivityConnection.h \\\r\n    ../../../editors/MemoryDesigner/ConnectivityGraph.h \\\r\n    ../../../editors/MemoryDesigner/ConnectivityGraphFactory.h \\\r\n    ../../../editors/MemoryDesigner/ConnectivityInterface.h \\\r\n    ../../../Plugins/PluginSystem/GeneratorPlugin/GenerationControl.h \\\r\n    ../../../editors/MemoryDesigner/MasterSlavePathSearch.h \\\r\n    ../../../editors/MemoryDesigner/MemoryItem.h \\\r\n    ../../../Plugins/MemoryViewGenerator/MemoryViewGenerator.h \\\r\n    ../../../Plugins/common/HDLParser/MetaComponent.h \\\r\n    ../../../Plugins/common/HDLParser/MetaDesign.h \\\r\n    ../../../Plugins/common/HDLParser/MetaInstance.h \\\r\n    ../../../Plugins/PluginSystem/GeneratorPlugin/OutputControl.h \\\r\n    ../../../Plugins/PluginSystem/GeneratorPlugin/ViewSelection.h \\\r\n    ../../MockObjects/LibraryMock.h \\\r\n    ../../../Plugins/MemoryViewGenerator/MemoryViewGeneratorPlugin.h \\\r\n    ../../../IPXACTmodels/utilities/ComponentSearch.h\r\nSOURCES += ../../../editors/MemoryDesigner/ConnectivityComponent.cpp \\\r\n    ../../../editors/MemoryDesigner/ConnectivityConnection.cpp \\\r\n    ../../../editors/MemoryDesigner/ConnectivityGraph.cpp \\\r\n    ../../../editors/MemoryDesigner/ConnectivityGraphFactory.cpp \\\r\n    ../../../editors/MemoryDesigner/ConnectivityInterface.cpp \\\r\n    ../../../Plugins/PluginSystem/GeneratorPlugin/GenerationControl.cpp \\\r\n    ../../MockObjects/LibraryMock.cpp \\\r\n    ../../../editors/MemoryDesigner/MasterSlavePathSearch.cpp \\\r\n    ../../../editors/MemoryDesigner/MemoryItem.cpp \\\r\n    ../../../Plugins/MemoryViewGenerator/MemoryViewGenerator.cpp \\\r\n    ../../../Plugins/MemoryViewGenerator/MemoryViewGeneratorPlugin.cpp \\\r\n    ../../../Plugins/common/HDLParser/MetaComponent.cpp \\\r\n    ../../../Plugins/common/HDLParser/MetaDesign.cpp \\\r\n    ../../../Plugins/common/HDLParser/MetaInstance.cpp \\\r\n    ../../../Plugins/PluginSystem/GeneratorPlugin/OutputControl.cpp \\\r\n    ../../../Plugins/PluginSystem/GeneratorPlugin/ViewSelection.cpp \\\r\n    ./tst_MemoryViewGenerator.cpp \\\r\n    ../../../IPXACTmodels/utilities/ComponentSearch.cpp\r\n"
  },
  {
    "path": "tests/Plugins/MemoryViewGenerator/tst_MemoryViewGenerator.pro",
    "content": "#-----------------------------------------------------------------------------\r\n# File: tst_MemoryViewGenerator.pro\r\n#-----------------------------------------------------------------------------\r\n# Project: Kactus 2\r\n# Author: Esko Pekkarinen\r\n# Date: 25.4.2016\r\n#\r\n# Description:\r\n# Qt project file template for running unit tests for a MemoryViewGenerator.\r\n#-----------------------------------------------------------------------------\r\n\r\nTEMPLATE = app\r\n\r\nTARGET = tst_MemoryViewGenerator\r\n\r\nQT += core xml testlib widgets\r\nCONFIG += c++11 testcase console\r\n\r\nDEFINES += MEMORYVIEWGENERATOR_LIB\r\n\r\nQMAKE_EXPORTED_VARIABLES += MAKE_TESTARGS\r\nMAKE_TESTARGS.name = TESTARGS\r\nMAKE_TESTARGS.value = \"-platform offscreen\"\r\n\r\nwin32:CONFIG(release, debug|release) {\r\n    LIBS += -L$$PWD/../../../executable/ -lIPXACTmodels\r\n    LIBS += -L$$PWD/../../../executable/ -lKactusAPI\r\n    DESTDIR = ./release\r\n}\r\nelse:win32:CONFIG(debug, debug|release) {\r\n    LIBS += -L$$PWD/../../../executable/ -lIPXACTmodelsd\r\n    LIBS += -L$$PWD/../../../executable/ -lKactusAPId\r\n    DESTDIR = ./debug\r\n}\r\nelse:unix {\r\n    LIBS += -L$$PWD/../../../executable/ -lIPXACTmodels\r\n    LIBS += -L$$PWD/../../../executable/ -lKactusAPI\r\n    DESTDIR = ./release\r\n}\r\n\r\nINCLUDEPATH += $$PWD/../../../\r\nINCLUDEPATH += $$PWD/../../../executable\r\nINCLUDEPATH += $$PWD/../../../KactusAPI/include\r\nINCLUDEPATH += $$DESTDIR\r\n\r\nDEPENDPATH += $$PWD/../../../\r\nDEPENDPATH += $$PWD/../../../executable\r\nDEPENDPATH += .\r\n\r\nOBJECTS_DIR += $$DESTDIR\r\n\r\nMOC_DIR += ./generatedFiles\r\nUI_DIR += ./generatedFiles\r\nRCC_DIR += ./generatedFiles\r\ninclude(tst_MemoryViewGenerator.pri)\r\n"
  },
  {
    "path": "tests/Plugins/Plugins.pro",
    "content": "#-----------------------------------------------------------------------------\r\n# File: subdirs.pro\r\n#-----------------------------------------------------------------------------\r\n# Project: Kactus 2\r\n# Author: Esko Pekkarinen\r\n# Date: 24.27.2014\r\n#\r\n# Description:\r\n# Qt project file template for running unit tests for all plugins.\r\n#-----------------------------------------------------------------------------\r\n\r\nTEMPLATE = subdirs\r\n\r\nCONFIG += c++11 testcase\r\n\r\nSUBDIRS += VerilogGenerator/VerilogGenerator.pro \\\r\n\t\t\tMakefileGenerator/tst_MakefileGenerator.pro \\\r\n\t\t\tVHDLimport/VHDLimport.pro \\\r\n\t\t\tVerilogImport/VerilogImport.pro \\\r\n\t\t    VerilogIncludeImport/tst_VerilogIncludeImport.pro \\\r\n\t\t\tVerilogSourceAnalyzer/tst_VerilogSourceAnalyzer.pro \\\r\n\t\t\tMemoryMapHeaderGenerator/tst_MemoryMapHeaderGenerator.pro \\\r\n#\t\t\tMemoryViewGenerator/tst_MemoryViewGenerator.pro \\\r\n\t\t\tQuartusProjectGenerator/tst_QuartusProjectGenerator.pro \\\r\n\t\t\tLinuxDeviceTreeGenerator/tst_LinuxDeviceTreeGenerator.pro\r\n"
  },
  {
    "path": "tests/Plugins/QuartusProjectGenerator/tst_QuartusProjectGenerator.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: tst_QuartusProjectGenerator.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Mikko Teuho\r\n// Date: 29.05.2015\r\n//\r\n// Description:\r\n// Unit test for class QuartusGenerator.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include <Plugins/QuartusProjectGenerator/QuartusGenerator.h>\r\n\r\n#include <tests/MockObjects/LibraryMock.h>\r\n\r\n#include <KactusAPI/include/IPluginUtility.h>\r\n\r\n#include <IPXACTmodels/DesignConfiguration/DesignConfiguration.h>\r\n\r\n#include <IPXACTmodels/Component/Component.h>\r\n#include <IPXACTmodels/Design/ComponentInstance.h>\r\n#include <IPXACTmodels/Design/Design.h>\r\n#include <IPXACTmodels/Component/FileSet.h>\r\n#include <IPXACTmodels/Component/File.h>\r\n#include <IPXACTmodels/Component/View.h>\r\n#include <IPXACTmodels/Component/Model.h>\r\n\r\n#include <QtTest>\r\n#include <QDateTime>\r\n\r\nclass tst_QuartusProjectGenerator : public QObject, public IPluginUtility\r\n{\r\n    Q_OBJECT\r\n\r\npublic:\r\n    tst_QuartusProjectGenerator();\r\n\r\n    virtual void printError(QString const& message);\r\n\r\n    virtual void printInfo(QString const& message);\r\n\r\n    virtual LibraryInterface* getLibraryInterface();\r\n\r\n    virtual QWidget* getParentWidget();\r\n\r\n    virtual QString getKactusVersion() const;\r\n\r\nprivate slots:\r\n\r\n    void init();\r\n    void cleanup();\r\n\r\n    void testGeneratorWithoutFilesets();\r\n\r\n    void testGeneratorWithDesignContainingTopComponentVerilogFile();\r\n    void testGeneratorWithDesignContainingInstances();\r\n\r\n    void testGeneratorWithConfiguredViews();\r\n    void testGeneratorInInstancesWithoutActiveViews();\r\n\r\n\r\nprivate:\r\n\r\n    void readOutputFile(QString const& fileType);\r\n\r\n    void compareOutputToExpected(QString const& fileType, QString const& expectedOutput);\r\n\r\n    QString getQuartusHeader(QString const& currentTime);\r\n\r\n    QSharedPointer<Component> createTestComponent(QString const& componentName);\r\n\r\n    QSharedPointer<Design> createTestDesign(QString const& designName,\r\n        QList<QSharedPointer<Component> > containedComponents);\r\n\r\n    QSharedPointer<DesignConfiguration> createTestDesignConfiguration(QString const& name,\r\n        QSharedPointer<Design> referencedDesign);\r\n\r\n    QSharedPointer<FileSet> createTestFileset (QString const& filesetName, QStringList filesToAdd);\r\n\r\n    QSharedPointer<QFile> createEmptyFile(QString const& fileName);\r\n\r\n    void setViewOverridesForDesignConfiguration(QSharedPointer<DesignConfiguration> testDesignConfiguration,\r\n        QSharedPointer<QList<QSharedPointer<ComponentInstance> > > componentInstances);\r\n\r\n    void setFileTypesForFileSet(QSharedPointer<FileSet> selectedFileset, QSharedPointer<QStringList> fileTypes);\r\n \r\n    QString projectFile() const;\r\n\r\n    QString settingsFile() const;\r\n\r\n    QSharedPointer<Component> topComponent_;\r\n\r\n    LibraryMock library_;\r\n\r\n    QWidget* generatorParentWidget_;\r\n\r\n    QuartusGenerator* quartusGenerator_;\r\n\r\n    QString targetPath_;\r\n\r\n    QString targetEntity_;\r\n\r\n    QString output_;\r\n\r\n    QString generatorInformation_;\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_QuartusProjectGenerator::tst_QuartusProjectGenerator()\r\n//-----------------------------------------------------------------------------\r\ntst_QuartusProjectGenerator::tst_QuartusProjectGenerator():\r\n    topComponent_(), generatorParentWidget_(new QWidget), library_(this), quartusGenerator_(), targetPath_(\"./\"),\r\n    targetEntity_(\"generatorOutput\"), output_(), generatorInformation_(\"test generator\")\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_QuartusProjectGenerator::printError()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_QuartusProjectGenerator::printError(QString const& message)\r\n{\r\n        // TODO.\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_QuartusProjectGenerator::printInfo()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_QuartusProjectGenerator::printInfo(QString const& message)\r\n{\r\n    // TODO.\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_QuartusProjectGenerator::getLibraryInterface()\r\n//-----------------------------------------------------------------------------\r\nLibraryInterface* tst_QuartusProjectGenerator::getLibraryInterface()\r\n{\r\n    return &library_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_QuartusProjectGenerator::getParentWidget()\r\n//-----------------------------------------------------------------------------\r\nQWidget* tst_QuartusProjectGenerator::getParentWidget()\r\n{\r\n    return generatorParentWidget_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_QuartusProjectGenerator::getKactusVersion()\r\n//-----------------------------------------------------------------------------\r\nQString tst_QuartusProjectGenerator::getKactusVersion() const\r\n{\r\n    return QString();\r\n}\r\n\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_QuartusProjectGenerator::init()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_QuartusProjectGenerator::init()\r\n{\r\n    library_.clear();\r\n\r\n    quartusGenerator_ = new QuartusGenerator(this);\r\n\r\n    topComponent_ = createTestComponent(\"topComponent\");\r\n\r\n    if (QFile::exists(targetEntity_ + projectFile()))\r\n    {\r\n        QWARN(\"Quartus project file already exists.\");\r\n    }\r\n\r\n    if (QFile::exists(targetEntity_ + settingsFile()))\r\n    {\r\n        QWARN(\"Quartus settings file already exists.\");\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_QuartusProjectGenerator::cleanup()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_QuartusProjectGenerator::cleanup()\r\n{\r\n    topComponent_.clear();\r\n    output_.clear();\r\n\r\n    delete quartusGenerator_;\r\n    quartusGenerator_ = 0;\r\n\r\n    QFile::remove(targetEntity_ + projectFile());\r\n    QFile::remove(targetEntity_ + settingsFile());\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_QuartusProjectGenerator::testGeneratorWithoutFilesets()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_QuartusProjectGenerator::testGeneratorWithoutFilesets()\r\n{\r\n    QString currentTime = QDateTime::currentDateTime().toString(QString(\"hh:mm:ss dd.MM.yyyy\"));\r\n    quartusGenerator_->replaceTime(currentTime);\r\n\r\n    quartusGenerator_->generateProject(targetPath_, targetEntity_, generatorInformation_);\r\n\r\n    QString expectedProjectOutput( getQuartusHeader(currentTime) + \r\n        \"QUARTUS_VERSION = \\\"10.0\\\"\\n\"\r\n        \"\\n\"\r\n        \"# Revisions\\n\"\r\n        \"\\n\"\r\n        \"PROJECT_REVISION = \\\"generatorOutput\\\"\");\r\n\r\n    compareOutputToExpected(projectFile(), expectedProjectOutput);\r\n\r\n    QString expectedSettingsOutput ( getQuartusHeader(currentTime) +\r\n        \"set_global_assignment -name TOP_LEVEL_ENTITY generatorOutput\\n\"\r\n        \"set_global_assignment -name ORIGINAL_QUARTUS_VERSION \\\"10.0 SP1\\\"\");\r\n\r\n    compareOutputToExpected(settingsFile(), expectedSettingsOutput);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_QuartusProjectGenerator::testGeneratorWithDesignContainingTopComponentVerilogFile()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_QuartusProjectGenerator::testGeneratorWithDesignContainingTopComponentVerilogFile()\r\n{\r\n    QSharedPointer<Design> quartusDesign = createTestDesign(\"quartusDesign\", QList<QSharedPointer<Component> > ());\r\n\r\n    QSharedPointer<QFile> topVerilogFile = createEmptyFile(\"topComponentVerilog.v\");\r\n\r\n    QStringList filesForTopComponent;\r\n    filesForTopComponent.append(topVerilogFile->fileName());\r\n\r\n    QSharedPointer<FileSet> topComponentFileSet = createTestFileset(\"verilogFileSet\", filesForTopComponent);\r\n    topComponent_->getFileSets()->append(topComponentFileSet);\r\n\r\n\tQSharedPointer<ComponentInstantiation> cimpTop( new ComponentInstantiation(\"TOP-INSTANTIATION\") );\r\n\tcimpTop->getFileSetReferences()->append(QSharedPointer<FileSetRef>(new FileSetRef(topComponentFileSet->name())));\r\n\ttopComponent_->getComponentInstantiations()->append(cimpTop);\r\n\r\n\tQSharedPointer<DesignInstantiation> dist( new DesignInstantiation(\"joku\" ));\r\n\ttopComponent_->getDesignInstantiations()->append(dist);\r\n\tQSharedPointer<ConfigurableVLNVReference> desgref( new ConfigurableVLNVReference(quartusDesign->getVlnv()) );\r\n\tdist->setDesignReference( desgref );\r\n\r\n\tQSharedPointer<View> quartusTestView (new View(\"quartusView\"));\r\n\tquartusTestView->setDesignInstantiationRef(dist->name());\r\n\tquartusTestView->setComponentInstantiationRef(cimpTop->name());\r\n\ttopComponent_->getViews()->append(quartusTestView);\r\n\r\n    QString currentTime = QDateTime::currentDateTime().toString(QString(\"hh:mm:ss dd.MM.yyyy\"));\r\n    quartusGenerator_->replaceTime(currentTime);\r\n\r\n    quartusGenerator_->parseFiles(topComponent_, quartusTestView);\r\n    quartusGenerator_->generateProject(targetPath_, targetEntity_, generatorInformation_);\r\n\r\n    QString expectedProjectOutput( getQuartusHeader(currentTime) + \r\n        \"QUARTUS_VERSION = \\\"10.0\\\"\\n\"\r\n        \"\\n\"\r\n        \"# Revisions\\n\"\r\n        \"\\n\"\r\n        \"PROJECT_REVISION = \\\"generatorOutput\\\"\");\r\n\r\n    compareOutputToExpected(projectFile(), expectedProjectOutput);\r\n\r\n    QString expectedSettingsOutput ( getQuartusHeader(currentTime) +\r\n        \"set_global_assignment -name TOP_LEVEL_ENTITY generatorOutput\\n\"\r\n        \"set_global_assignment -name ORIGINAL_QUARTUS_VERSION \\\"10.0 SP1\\\"\\n\"\r\n        \"set_global_assignment -name VERILOG_FILE \" + QFileInfo(*topVerilogFile).absoluteFilePath() + \"\\n\"\r\n        );\r\n\r\n    compareOutputToExpected(settingsFile(), expectedSettingsOutput);\r\n\r\n    QFile::remove(topVerilogFile->fileName());\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_QuartusProjectGenerator::testGeneratorWithDesignContainingInstances()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_QuartusProjectGenerator::testGeneratorWithDesignContainingInstances()\r\n{\r\n    QSharedPointer<Component> componentOne = createTestComponent(\"componentOne\");\r\n    QSharedPointer<QFile> componentOneVhdlFile = createEmptyFile(\"componentOneVHDL.vhdl\");\r\n\r\n    QStringList componentOneFiles;\r\n    componentOneFiles.append(componentOneVhdlFile->fileName());\r\n    QSharedPointer<FileSet> componentOneFileset = createTestFileset(\"vhdlFiles\", componentOneFiles);\r\n    componentOne->getFileSets()->append(componentOneFileset);\r\n\r\n\tQSharedPointer<ComponentInstantiation> cimpOne( new ComponentInstantiation(\"ONE-INSTANTIATION\") );\r\n\tcimpOne->getFileSetReferences()->append(QSharedPointer<FileSetRef>(new FileSetRef(componentOneFileset->name())));\r\n\tcomponentOne->getComponentInstantiations()->append(cimpOne);\r\n\r\n\tQSharedPointer<View> componentOneView (new View(\"vhdlView\"));\r\n\tcomponentOneView->setComponentInstantiationRef(cimpOne->name());\r\n\tcomponentOne->getViews()->append(componentOneView);\r\n\r\n    QSharedPointer<Component> componentTwo = createTestComponent(\"componentTwo\");\r\n    QSharedPointer<QFile> componentTwoQipFile = createEmptyFile(\"componentTwoQip.qip\");\r\n\r\n    QStringList componentTwoFiles;\r\n    componentTwoFiles.append(componentTwoQipFile->fileName());\r\n    QSharedPointer<FileSet> componentTwoFileset = createTestFileset(\"qipFiles\", componentTwoFiles);\r\n    componentTwo->getFileSets()->append(componentTwoFileset);\r\n\r\n\tQSharedPointer<ComponentInstantiation> cimpTwo( new ComponentInstantiation(\"TWO-INSTANTIATION\") );\r\n\tcimpTwo->getFileSetReferences()->append(QSharedPointer<FileSetRef>(new FileSetRef(componentTwoFileset->name())));\r\n\tcomponentTwo->getComponentInstantiations()->append(cimpTwo);\r\n\r\n\tQSharedPointer<View> componentTwoView (new View(\"qipView\"));\r\n    componentTwoView->setComponentInstantiationRef(cimpTwo->name());\r\n    componentTwo->getViews()->append(componentTwoView);\r\n\r\n    QSharedPointer<Component> componentThree = createTestComponent(\"componentThree\");\r\n    QSharedPointer<QFile> componentThreeSdcFile = createEmptyFile(\"componentThreeSdc.sdc\");\r\n\r\n    QStringList componentThreeFiles;\r\n    componentThreeFiles.append(componentThreeSdcFile->fileName());\r\n    QSharedPointer<FileSet> componentThreeFileSet = createTestFileset(\"sdcFiles\", componentThreeFiles);\r\n    componentThree->getFileSets()->append(componentThreeFileSet);\r\n\r\n\tQSharedPointer<View> componentThreeView (new View(\"sdcView\"));\r\n\tQSharedPointer<ComponentInstantiation> cimpThree( new ComponentInstantiation(\"THREE-INSTANTIATION\") );\r\n\tcimpThree->getFileSetReferences()->append(QSharedPointer<FileSetRef>(new FileSetRef(componentThreeFileSet->name())));\r\n\tcomponentThreeView->setComponentInstantiationRef(cimpThree->name());\r\n\tcomponentThree->getViews()->append(componentThreeView);\r\n\tcomponentThree->getComponentInstantiations()->append(cimpThree);\r\n\r\n    QList<QSharedPointer<Component> > componentsInDesign;\r\n    componentsInDesign.append(componentOne);\r\n    componentsInDesign.append(componentTwo);\r\n    componentsInDesign.append(componentThree);\r\n\r\n    QSharedPointer<Design> quartusDesign = createTestDesign(\"quartusDesign\", componentsInDesign);\r\n\r\n    QSharedPointer<DesignConfiguration> quartusDesignConf = createTestDesignConfiguration(\"quartusDesignConf\",\r\n        quartusDesign);\r\n\r\n    QSharedPointer<QFile> topVerilogFile = createEmptyFile(\"topComponentVerilog.v\");\r\n\r\n    QStringList topComponentFiles;\r\n    topComponentFiles.append(topVerilogFile->fileName());\r\n    QSharedPointer<FileSet> topComponentFileSet = createTestFileset(\"topFiles\", topComponentFiles);\r\n    topComponent_->getFileSets()->append(topComponentFileSet);\r\n\r\n\tQSharedPointer<DesignInstantiation> des( new DesignInstantiation(\"design\" ) );\r\n\tQSharedPointer<ConfigurableVLNVReference> desRef( new ConfigurableVLNVReference( quartusDesign->getVlnv() ) );\r\n\tdes->setDesignReference( desRef );\r\n\ttopComponent_->getDesignInstantiations()->append(des);\r\n\r\n\tQSharedPointer<DesignConfigurationInstantiation> disg( new DesignConfigurationInstantiation(\"desgonf\" ) );\r\n\tQSharedPointer<ConfigurableVLNVReference> desgConfRef( new ConfigurableVLNVReference( quartusDesignConf->getVlnv() ) );\r\n\tdisg->setDesignConfigurationReference( desgConfRef );\r\n\ttopComponent_->getDesignConfigurationInstantiations()->append(disg);\r\n\r\n\tQSharedPointer<ComponentInstantiation> cimpTop( new ComponentInstantiation(\"TOP-INSTANTIATION\") );\r\n\tcimpTop->getFileSetReferences()->append(QSharedPointer<FileSetRef>(new FileSetRef(topComponentFileSet->name())));\r\n\ttopComponent_->getComponentInstantiations()->append(cimpTop);\r\n\r\n\tQSharedPointer<View> quartusDesignView (new View(\"quartusView\"));\r\n\tquartusDesignView->setDesignInstantiationRef(des->name());\r\n\tquartusDesignView->setDesignConfigurationInstantiationRef(disg->name());\r\n\tquartusDesignView->setComponentInstantiationRef(cimpTop->name());\r\n\ttopComponent_->getViews()->append(quartusDesignView);\r\n\r\n    QString currentTime = QDateTime::currentDateTime().toString(QString(\"hh:mm:ss dd.MM.yyyy\"));\r\n    quartusGenerator_->replaceTime(currentTime);\r\n\r\n    quartusGenerator_->parseFiles(topComponent_, quartusDesignView);\r\n    quartusGenerator_->generateProject(targetPath_, targetEntity_, generatorInformation_);\r\n\r\n    QString expectedProjectOutput( getQuartusHeader(currentTime) + \r\n        \"QUARTUS_VERSION = \\\"10.0\\\"\\n\"\r\n        \"\\n\"\r\n        \"# Revisions\\n\"\r\n        \"\\n\"\r\n        \"PROJECT_REVISION = \\\"generatorOutput\\\"\");\r\n\r\n    compareOutputToExpected(projectFile(), expectedProjectOutput);\r\n\r\n    QString expectedSettingsOutput ( getQuartusHeader(currentTime) +\r\n        \"set_global_assignment -name TOP_LEVEL_ENTITY generatorOutput\\n\"\r\n        \"set_global_assignment -name ORIGINAL_QUARTUS_VERSION \\\"10.0 SP1\\\"\\n\"\r\n        \"set_global_assignment -name VHDL_FILE \" + QFileInfo(*componentOneVhdlFile).absoluteFilePath() + \"\\n\"\r\n        \"set_global_assignment -name QIP_FILE \" + QFileInfo(*componentTwoQipFile).absoluteFilePath() + \"\\n\"\r\n        \"set_global_assignment -name SDC_FILE \" + QFileInfo(*componentThreeSdcFile).absoluteFilePath() + \"\\n\"\r\n        \"set_global_assignment -name VERILOG_FILE \" + QFileInfo(*topVerilogFile).absoluteFilePath() + \"\\n\"\r\n        );\r\n\r\n    compareOutputToExpected(settingsFile(), expectedSettingsOutput);\r\n\r\n    QFile::remove(topVerilogFile->fileName());\r\n    QFile::remove(componentOneVhdlFile->fileName());\r\n    QFile::remove(componentTwoQipFile->fileName());\r\n    QFile::remove(componentThreeSdcFile->fileName());\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_QuartusProjectGenerator::testGeneratorWithConfiguredViews()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_QuartusProjectGenerator::testGeneratorWithConfiguredViews()\r\n{\r\n    QSharedPointer<Component> componentOne = createTestComponent(\"componentOne\");\r\n    QSharedPointer<QFile> componentOneVhdlFile = createEmptyFile(\"componentOneVHDL.vhdl\");\r\n\r\n    QStringList componentOneFiles;\r\n    componentOneFiles.append(componentOneVhdlFile->fileName());\r\n    QSharedPointer<FileSet> componentOneFileset = createTestFileset(\"vhdlFiles\", componentOneFiles);\r\n    componentOne->getFileSets()->append(componentOneFileset);\r\n\r\n    QSharedPointer<View> componentOneView (new View(\"vhdlView\"));\r\n\tQSharedPointer<ComponentInstantiation> cimpOne( new ComponentInstantiation(\"ONE-INSTANTIATION\") );\r\n\tcimpOne->getFileSetReferences()->append(QSharedPointer<FileSetRef>(new FileSetRef(componentOneFileset->name())));\r\n    componentOneView->setComponentInstantiationRef(cimpOne->name());\r\n\tcomponentOne->getViews()->append(componentOneView);\r\n\tcomponentOne->getComponentInstantiations()->append(cimpOne);\r\n\r\n    QSharedPointer<QFile> componentOneVerilogFile = createEmptyFile(\"changingWithView.v\");\r\n\r\n    componentOneFiles.clear();\r\n    componentOneFiles.append(componentOneVerilogFile->fileName());\r\n    componentOneFiles.append(componentOneVhdlFile->fileName());\r\n    QSharedPointer<FileSet> componentOneOtherFileset = createTestFileset(\"otherFiles\", componentOneFiles);\r\n    componentOne->getFileSets()->append(componentOneOtherFileset);\r\n\r\n\tQSharedPointer<View> componentOneOtherView (new View(\"restView\"));\r\n\tQSharedPointer<ComponentInstantiation> cimpOneOther( new ComponentInstantiation(\"ONE-OTHER-INSTANTIATION\") );\r\n\tcimpOneOther->getFileSetReferences()->append(QSharedPointer<FileSetRef>(new FileSetRef(componentOneOtherFileset->name())));\r\n\tcomponentOneOtherView->setComponentInstantiationRef(cimpOneOther->name());\r\n\tcomponentOne->getViews()->append(componentOneOtherView);\r\n\tcomponentOne->getComponentInstantiations()->append(cimpOneOther);\r\n\r\n    QSharedPointer<Component> componentTwo = createTestComponent(\"componentTwo\");\r\n    QSharedPointer<QFile> componentTwoQipFile = createEmptyFile(\"componentTwoQip.qip\");\r\n\r\n    QStringList componentTwoFiles;\r\n    componentTwoFiles.append(componentTwoQipFile->fileName());\r\n    QSharedPointer<FileSet> componentTwoFileset = createTestFileset(\"qipFiles\", componentTwoFiles);\r\n    componentTwo->getFileSets()->append(componentTwoFileset);\r\n\r\n\tQSharedPointer<View> componentTwoView (new View(\"qipView\"));\r\n\tQSharedPointer<ComponentInstantiation> cimpTwo( new ComponentInstantiation(\"TWO-INSTANTIATION\") );\r\n\tcimpTwo->getFileSetReferences()->append(QSharedPointer<FileSetRef>(new FileSetRef(componentTwoFileset->name())));\r\n\tcomponentTwoView->setComponentInstantiationRef(cimpTwo->name());\r\n\tcomponentTwo->getViews()->append(componentTwoView);\r\n\tcomponentTwo->getComponentInstantiations()->append(cimpTwo);\r\n\r\n    QSharedPointer<View> componentTwoOtherView (new View(\"componentTwoEmptyView\"));\r\n    componentTwo->getViews()->append(componentTwoView);\r\n\r\n    QList<QSharedPointer<Component> > componentsInDesign;\r\n    componentsInDesign.append(componentOne);\r\n    componentsInDesign.append(componentTwo);\r\n\r\n    QSharedPointer<Design> quartusDesign = createTestDesign(\"quartusDesign\", componentsInDesign);\r\n    QSharedPointer<DesignConfiguration> quartusDesignConf = createTestDesignConfiguration(\"quartusDesignConf\",\r\n        quartusDesign);\r\n\r\n    setViewOverridesForDesignConfiguration(quartusDesignConf, quartusDesign->getComponentInstances());\r\n\r\n\tQSharedPointer<DesignInstantiation> des( new DesignInstantiation(\"design\" ) );\r\n\tQSharedPointer<ConfigurableVLNVReference> desRef( new ConfigurableVLNVReference( quartusDesign->getVlnv() ) );\r\n\tdes->setDesignReference( desRef );\r\n\ttopComponent_->getDesignInstantiations()->append(des);\r\n\r\n\tQSharedPointer<DesignConfigurationInstantiation> disg( new DesignConfigurationInstantiation(\"desgonf\" ) );\r\n\tQSharedPointer<ConfigurableVLNVReference> desgConfRef( new ConfigurableVLNVReference( quartusDesignConf->getVlnv() ) );\r\n\tdisg->setDesignConfigurationReference( desgConfRef );\r\n\ttopComponent_->getDesignConfigurationInstantiations()->append(disg);\r\n\r\n\tQSharedPointer<View> quartusDesignView (new View(\"quartusView\"));\r\n\tquartusDesignView->setDesignInstantiationRef(des->name());\r\n\tquartusDesignView->setDesignConfigurationInstantiationRef(disg->name());\r\n    topComponent_->getViews()->append(quartusDesignView);\r\n\r\n    QString currentTime = QDateTime::currentDateTime().toString(QString(\"hh:mm:ss dd.MM.yyyy\"));\r\n    quartusGenerator_->replaceTime(currentTime);\r\n\r\n    quartusGenerator_->parseFiles(topComponent_, quartusDesignView);\r\n    quartusGenerator_->generateProject(targetPath_, targetEntity_, generatorInformation_);\r\n\r\n    QString expectedProjectOutput( getQuartusHeader(currentTime) + \r\n        \"QUARTUS_VERSION = \\\"10.0\\\"\\n\"\r\n        \"\\n\"\r\n        \"# Revisions\\n\"\r\n        \"\\n\"\r\n        \"PROJECT_REVISION = \\\"generatorOutput\\\"\");\r\n\r\n    compareOutputToExpected(projectFile(), expectedProjectOutput);\r\n\r\n    QString expectedSettingsOutput ( getQuartusHeader(currentTime) +\r\n        \"set_global_assignment -name TOP_LEVEL_ENTITY generatorOutput\\n\"\r\n        \"set_global_assignment -name ORIGINAL_QUARTUS_VERSION \\\"10.0 SP1\\\"\\n\"\r\n        \"set_global_assignment -name VERILOG_FILE \" + QFileInfo(*componentOneVerilogFile).absoluteFilePath() + \"\\n\"\r\n        \"set_global_assignment -name VHDL_FILE \" + QFileInfo(*componentOneVhdlFile).absoluteFilePath() + \"\\n\"\r\n        );\r\n\r\n    compareOutputToExpected(settingsFile(), expectedSettingsOutput);\r\n\r\n    QFile::remove(componentOneVhdlFile->fileName());\r\n    QFile::remove(componentTwoQipFile->fileName());\r\n    QFile::remove(componentOneVerilogFile->fileName());\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_QuartusProjectGenerator::testGeneratorInInstancesWithoutActiveViews()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_QuartusProjectGenerator::testGeneratorInInstancesWithoutActiveViews()\r\n{\r\n    QSharedPointer<Component> componentOne = createTestComponent(\"componentOne\");\r\n    QSharedPointer<QFile> componentOneVhdlFile = createEmptyFile(\"componentOneVHDL.vhdl\");\r\n\r\n    QStringList componentOneFiles;\r\n    componentOneFiles.append(componentOneVhdlFile->fileName());\r\n    QSharedPointer<FileSet> componentOneFileset = createTestFileset(\"vhdlFiles\", componentOneFiles);\r\n    componentOne->getFileSets()->append(componentOneFileset);\r\n\r\n    QSharedPointer<QFile> componentOneVerilogFile = createEmptyFile(\"componentOneVerilog.v\");\r\n\r\n    componentOneFiles.clear();\r\n    componentOneFiles.append(componentOneVerilogFile->fileName());\r\n    componentOneFiles.append(componentOneVhdlFile->fileName());\r\n    QSharedPointer<FileSet> componentOneOtherFileset = createTestFileset(\"otherFiles\", componentOneFiles);\r\n    componentOne->getFileSets()->append(componentOneOtherFileset);\r\n\r\n    QSharedPointer<Component> componentTwo = createTestComponent(\"componentTwo\");\r\n    QSharedPointer<QFile> componentTwoQipFile = createEmptyFile(\"componentTwoQip.qip\");\r\n\r\n    QStringList componentTwoFiles;\r\n    componentTwoFiles.append(componentTwoQipFile->fileName());\r\n    QSharedPointer<FileSet> componentTwoFileset = createTestFileset(\"qipFiles\", componentTwoFiles);\r\n    componentTwo->getFileSets()->append(componentTwoFileset);\r\n\r\n    componentTwoFiles.append(componentOneVerilogFile->fileName());\r\n    componentTwoFiles.append(componentOneVhdlFile->fileName());\r\n    QSharedPointer<FileSet> componentTwoOtherFileset = createTestFileset(\"allFiles\", componentTwoFiles);\r\n    componentTwo->getFileSets()->append(componentTwoOtherFileset);\r\n\r\n\tQSharedPointer<ComponentInstantiation> cimpTwo( new ComponentInstantiation(\"Two-INSTANTIATION\") );\r\n\tcimpTwo->getFileSetReferences()->append(QSharedPointer<FileSetRef>(new FileSetRef(componentTwoFileset->name())));\r\n\tcomponentTwo->getComponentInstantiations()->append(cimpTwo);\r\n\r\n\tQSharedPointer<View> componentTwoView (new View(\"qipView\"));\r\n\tcomponentTwoView->setComponentInstantiationRef(cimpTwo->name());\r\n\tcomponentTwo->getViews()->append(componentTwoView);\r\n\r\n    QSharedPointer<View> componentTwoOtherView (new View(\"componentTwoEmptyView\"));\r\n    componentTwo->getViews()->append(componentTwoOtherView);\r\n\r\n    QList<QSharedPointer<Component> > componentsInDesign;\r\n    componentsInDesign.append(componentOne);\r\n    componentsInDesign.append(componentTwo);\r\n\r\n    QSharedPointer<QStringList> fileTypes( new QStringList );\r\n    fileTypes->append(\"vhdlSource\");\r\n    fileTypes->append(\"verilogSource\");\r\n    setFileTypesForFileSet(componentOneFileset, fileTypes);\r\n    setFileTypesForFileSet(componentOneOtherFileset, fileTypes);\r\n    setFileTypesForFileSet(componentTwoFileset, fileTypes);\r\n    setFileTypesForFileSet(componentTwoOtherFileset, fileTypes);\r\n\r\n    QSharedPointer<Design> quartusDesign = createTestDesign(\"quartusDesign\", componentsInDesign);\r\n    QSharedPointer<DesignConfiguration> quartusDesignConf = createTestDesignConfiguration(\"quartusDesignConf\",\r\n        quartusDesign);\r\n\r\n\tQSharedPointer<QList<QSharedPointer<ViewConfiguration> > > viewConfigurations( new QList<QSharedPointer<ViewConfiguration> > );\r\n    foreach (QSharedPointer<ComponentInstance> instance, *quartusDesign->getComponentInstances())\r\n    {\r\n        viewConfigurations->append(QSharedPointer<ViewConfiguration>( new ViewConfiguration( instance->getInstanceName() ) ) );\r\n    }\r\n    quartusDesignConf->setViewConfigurations(viewConfigurations);\r\n\r\n\tQSharedPointer<DesignConfigurationInstantiation> disg( new DesignConfigurationInstantiation(\"DESG-CONF-INSTANTIATION\") );\r\n\ttopComponent_->getDesignConfigurationInstantiations()->append(disg);\r\n\tQSharedPointer<ConfigurableVLNVReference> designConfRef( new ConfigurableVLNVReference( quartusDesignConf->getVlnv() ) );\r\n\tdisg->setDesignConfigurationReference( designConfRef );\r\n\r\n\tQSharedPointer<DesignInstantiation> dis( new DesignInstantiation(\"DESIGN-INSTANTIATION\") );\r\n\ttopComponent_->getDesignInstantiations()->append(dis);\r\n\tQSharedPointer<ConfigurableVLNVReference> designRef( new ConfigurableVLNVReference( quartusDesign->getVlnv() ) );\r\n\tdis->setDesignReference( designRef );\r\n\r\n\tQSharedPointer<View> quartusDesignView (new View(\"quartusView\"));\r\n\tquartusDesignView->setDesignConfigurationInstantiationRef(disg->name());\r\n\tquartusDesignView->setComponentInstantiationRef(dis->name());\r\n\ttopComponent_->getViews()->append(quartusDesignView);\r\n\r\n    QString currentTime = QDateTime::currentDateTime().toString(QString(\"hh:mm:ss dd.MM.yyyy\"));\r\n    quartusGenerator_->replaceTime(currentTime);\r\n\r\n    quartusGenerator_->parseFiles(topComponent_, quartusDesignView);\r\n    quartusGenerator_->generateProject(targetPath_, targetEntity_, generatorInformation_);\r\n\r\n    QString expectedProjectOutput( getQuartusHeader(currentTime) + \r\n        \"QUARTUS_VERSION = \\\"10.0\\\"\\n\"\r\n        \"\\n\"\r\n        \"# Revisions\\n\"\r\n        \"\\n\"\r\n        \"PROJECT_REVISION = \\\"generatorOutput\\\"\");\r\n\r\n    compareOutputToExpected(projectFile(), expectedProjectOutput);\r\n\r\n    QString expectedSettingsOutput ( getQuartusHeader(currentTime) +\r\n        \"set_global_assignment -name TOP_LEVEL_ENTITY generatorOutput\\n\"\r\n        \"set_global_assignment -name ORIGINAL_QUARTUS_VERSION \\\"10.0 SP1\\\"\\n\"\r\n        \"set_global_assignment -name VHDL_FILE \" + QFileInfo(*componentOneVhdlFile).absoluteFilePath() + \"\\n\"\r\n        \"set_global_assignment -name VERILOG_FILE \" + QFileInfo(*componentOneVerilogFile).absoluteFilePath() + \"\\n\"\r\n        \"set_global_assignment -name QIP_FILE \" + QFileInfo(*componentTwoQipFile).absoluteFilePath() + \"\\n\"\r\n        );\r\n\r\n    compareOutputToExpected(settingsFile(), expectedSettingsOutput);\r\n\r\n    QFile::remove(componentOneVhdlFile->fileName());\r\n    QFile::remove(componentTwoQipFile->fileName());\r\n    QFile::remove(componentOneVerilogFile->fileName());\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_QuartusProjectGenerator::readOutputFile()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_QuartusProjectGenerator::readOutputFile(QString const& fileType)\r\n{\r\n    output_.clear();\r\n\r\n    QFile outputFile (targetPath_ + targetEntity_ + fileType);\r\n\r\n    QVERIFY(outputFile.open(QIODevice::ReadOnly));\r\n\r\n    output_ = outputFile.readAll();\r\n    outputFile.close();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_QuartusProjectGenerator::compareOutputToExpected()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_QuartusProjectGenerator::compareOutputToExpected(QString const& fileType, QString const& expectedOutput)\r\n{\r\n    readOutputFile(fileType);\r\n\r\n    if (!output_.contains(expectedOutput))\r\n    {\r\n        QStringList outputLines = output_.split(\"\\n\");\r\n        QStringList expectedLines = expectedOutput.split(\"\\n\");\r\n\r\n        QVERIFY(outputLines.count() >= expectedLines.count());\r\n\r\n        int lineOffset = outputLines.indexOf(expectedLines.first());\r\n        if (lineOffset == -1)\r\n        {\r\n            readOutputFile(fileType);\r\n            QCOMPARE(output_, expectedOutput);\r\n        }\r\n        else\r\n        {\r\n            int lineCount = expectedLines.count();\r\n            for (int i = 0; i < lineCount; i++)\r\n            {\r\n                QCOMPARE(outputLines.at(i + lineOffset), expectedLines.at(i));\r\n            }\r\n        }\r\n    }\r\n    else if (output_.count(expectedOutput) != 1)\r\n    {\r\n        QVERIFY2(false, QString(expectedOutput + \" was found \" + QString::number(output_.count(expectedOutput)) +\r\n            \" times in output.\").toLocal8Bit());\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_QuartusProjectGenerator::getQuartusHeader()\r\n//-----------------------------------------------------------------------------\r\nQString tst_QuartusProjectGenerator::getQuartusHeader(QString const& currentTime)\r\n{\r\n    QString header(\r\n        \"# ----------------------------------------------------------- #\\n\"\r\n        \"\\n\"\r\n        \"# Quartus project generated by Kactus2\\n\"\r\n        \"# Date created \" + currentTime + \"\\n\"\r\n        \"# This file was generated with \" + generatorInformation_ + \"\\n\"\r\n        \"\\n\"\r\n        \"# ----------------------------------------------------------- #\\n\"\r\n        \"\\n\");\r\n\r\n    return header;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_QuartusProjectGenerator::createTestComponent()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<Component> tst_QuartusProjectGenerator::createTestComponent(QString const& componentName)\r\n{\r\n    VLNV newVlnv(VLNV::COMPONENT, \"TUT\", \"TestLibrary\", componentName, \"1.0\");\r\n    QSharedPointer<Component> newComponent = QSharedPointer<Component>(new Component(newVlnv, Document::Revision::Std14));\r\n\r\n    library_.writeModelToFile(QFileInfo(\".\").absoluteFilePath() + \"/\", newComponent);\r\n    library_.addComponent(newComponent);\r\n\r\n    return newComponent;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_QuartusProjectGenerator::createTestDesign()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<Design> tst_QuartusProjectGenerator::createTestDesign(QString const& designName,\r\n    QList<QSharedPointer<Component> > containedComponents)\r\n{\r\n    VLNV designVLNV(VLNV::DESIGN, \"TUT\", \"TestLibrary\", designName, \"1.0\");\r\n    QSharedPointer<Design> newDesign = QSharedPointer<Design>(new Design(designVLNV, Document::Revision::Std14));\r\n\r\n    library_.writeModelToFile(QFileInfo(\".\").absoluteFilePath() + \"/\", newDesign);\r\n    library_.addComponent(newDesign);\r\n\r\n    QSharedPointer<QList<QSharedPointer<ComponentInstance> > > componentInstances(\r\n        new QList<QSharedPointer<ComponentInstance> >());\r\n    QMap<QString, int> usedInstances;\r\n    for (auto const& currentComponent : containedComponents)\r\n    {\r\n        int instanceNumber = usedInstances.value(currentComponent->getVlnv().getName(), 0);\r\n        QString instanceName = currentComponent->getVlnv().getName() + \"_\" + QString::number(instanceNumber);\r\n        \r\n\t\tQSharedPointer<ConfigurableVLNVReference> vlnvRef(new ConfigurableVLNVReference(currentComponent->getVlnv()));\r\n        QSharedPointer<ComponentInstance> newInstance (new ComponentInstance(instanceName, vlnvRef));\r\n        newInstance->setUuid(instanceName + \"ID\");\r\n\r\n        componentInstances->append(newInstance);\r\n        \r\n        usedInstances.insert(currentComponent->getVlnv().getName(), instanceNumber + 1);\r\n    }\r\n    newDesign->setComponentInstances(componentInstances);\r\n\r\n    return newDesign;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_QuartusProjectGenerator::createTestDesignConfiguration()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<DesignConfiguration> tst_QuartusProjectGenerator::createTestDesignConfiguration(QString const& name,\r\n    QSharedPointer<Design> referencedDesign)\r\n{\r\n    VLNV designConfigurationVLNV(VLNV::DESIGNCONFIGURATION, \"TUT\", \"TestLibrary\", name, \"1.0\");\r\n    QSharedPointer<DesignConfiguration> newDesignConfiguration =\r\n        QSharedPointer<DesignConfiguration>(new DesignConfiguration(designConfigurationVLNV, Document::Revision::Std14));\r\n\r\n    library_.writeModelToFile(QFileInfo(\".\").absoluteFilePath() + \"/\", newDesignConfiguration);\r\n    library_.addComponent(newDesignConfiguration);\r\n\r\n    newDesignConfiguration->setDesignRef(referencedDesign->getVlnv());\r\n\r\n    for (auto const& currentInstance : *referencedDesign->getComponentInstances())\r\n    {\r\n        VLNV componentReference = *currentInstance->getComponentRef();\r\n        QSharedPointer<Component> referencedComponent =\r\n            library_.getModel(componentReference).dynamicCast<Component>();\r\n\r\n        if (referencedComponent && referencedComponent->getModel()->getViews()->size() > 0)\r\n        {\r\n            newDesignConfiguration->addViewConfiguration(currentInstance->getInstanceName(),\r\n                referencedComponent->getViews()->at(0)->name());\r\n        }\r\n    }\r\n\r\n    return newDesignConfiguration;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_QuartusProjectGenerator::createTestFileset()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<FileSet> tst_QuartusProjectGenerator::createTestFileset(QString const& filesetName, QStringList filesToAdd)\r\n{\r\n    QSharedPointer<FileSet> newFileSet (new FileSet(filesetName));\r\n\r\n    for (auto const& fileName : filesToAdd)\r\n    {\r\n        QSharedPointer<File> newFileForFileSet (new File(fileName));\r\n\r\n        newFileSet->addFile(newFileForFileSet);\r\n    }\r\n\r\n    return newFileSet;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_QuartusProjectGenerator::createEmptyFile()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<QFile> tst_QuartusProjectGenerator::createEmptyFile(QString const& fileName)\r\n{\r\n    QSharedPointer<QFile> newFile(new QFile(fileName));\r\n    newFile->open(QFile::WriteOnly);\r\n    newFile->close();\r\n\r\n    return newFile;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_QuartusProjectGenerator::setViewOverridesForDesignConfiguration()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_QuartusProjectGenerator::setViewOverridesForDesignConfiguration( QSharedPointer<DesignConfiguration> testDesignConfiguration,\r\n\tQSharedPointer<QList<QSharedPointer<ComponentInstance> > > componentInstances)\r\n{\r\n    QMap<QString, QString> viewOverrides;\r\n    for (auto const& instance : *componentInstances)\r\n    {\r\n        VLNV componentReferenceVLNV = *instance->getComponentRef();\r\n        QSharedPointer<Component> referencedComponent =\r\n            library_.getModel(componentReferenceVLNV).dynamicCast<Component>();\r\n\r\n\t\tif (referencedComponent && referencedComponent->getModel()->getViews()->size() > 1)\r\n\t\t{\r\n            viewOverrides.insert(instance->getUuid(), referencedComponent->getViews()->at(1)->name());\r\n        }\r\n    }\r\n\r\n    testDesignConfiguration->setKactus2ViewOverrides(viewOverrides);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_QuartusProjectGenerator::setFileTypesForFileSet()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_QuartusProjectGenerator::setFileTypesForFileSet(QSharedPointer<FileSet> selectedFileset, QSharedPointer<QStringList> fileTypes)\r\n{\r\n    QSharedPointer<QList<FileType> > fileTypeObjs(new QList<FileType>());\r\n\r\n    for (auto const& fileType : *fileTypes)\r\n    {\r\n        fileTypeObjs->append(FileType(fileType));\r\n    }\r\n\r\n    for (auto const& currentFile : *selectedFileset->getFiles())\r\n    {\r\n        currentFile->setFileTypes(fileTypeObjs);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_QuartusProjectGenerator::projectFile()\r\n//-----------------------------------------------------------------------------\r\nQString tst_QuartusProjectGenerator::projectFile() const\r\n{\r\n    static const QString PROJECTFILE(\".qpf\");\r\n    return PROJECTFILE;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_QuartusProjectGenerator::settingsFile()\r\n//-----------------------------------------------------------------------------\r\nQString tst_QuartusProjectGenerator::settingsFile() const\r\n{\r\n    static const QString SETTINGSFILE(\".qsf\");\r\n    return SETTINGSFILE;\r\n}\r\n\r\n//QTEST_APPLESS_MAIN(tst_QuartusProjectGenerator)\r\nQTEST_MAIN(tst_QuartusProjectGenerator)\r\n\r\n#include \"tst_QuartusProjectGenerator.moc\"\r\n"
  },
  {
    "path": "tests/Plugins/QuartusProjectGenerator/tst_QuartusProjectGenerator.pri",
    "content": "# ----------------------------------------------------\r\n# This file is generated by the Qt Visual Studio Tools.\r\n# ------------------------------------------------------\r\n\r\nHEADERS += ../../MockObjects/LibraryMock.h \\\r\n    ../../../Plugins/QuartusProjectGenerator/QuartusGenerator.h \\\r\n    ../../../IPXACTmodels/utilities/ComponentSearch.h \\\r\n\t../../../IPXACTmodels/utilities/Search.h\r\nSOURCES += ../../MockObjects/LibraryMock.cpp \\\r\n    ../../../Plugins/QuartusProjectGenerator/QuartusGenerator.cpp \\\r\n    ./tst_QuartusProjectGenerator.cpp \\\r\n    ../../../IPXACTmodels/utilities/ComponentSearch.cpp\r\n"
  },
  {
    "path": "tests/Plugins/QuartusProjectGenerator/tst_QuartusProjectGenerator.pro",
    "content": "#-----------------------------------------------------------------------------\r\n# File: tst_QuatusGenerator.pro\r\n#-----------------------------------------------------------------------------\r\n# Project: Kactus 2\r\n# Author: Mikko Teuho\r\n# Date: 29.5.2015\r\n#\r\n# Description:\r\n# Qt project file template for running unit tests for quartus generator.\r\n#-----------------------------------------------------------------------------\r\n\r\nTEMPLATE = app\r\n\r\nTARGET = tst_QuartusProjectGenerator\r\n\r\nQT += core xml gui testlib widgets\r\nCONFIG += c++11 testcase console\r\n\r\nQMAKE_EXPORTED_VARIABLES += MAKE_TESTARGS\r\nMAKE_TESTARGS.name = TESTARGS\r\nMAKE_TESTARGS.value = \"-platform offscreen\"\r\n\r\nwin32:CONFIG(release, debug|release) {\r\n    LIBS += -L$$PWD/../../../executable/ -lIPXACTmodels\r\n    LIBS += -L$$PWD/../../../executable/ -lKactusAPI\r\n    DESTDIR = ./release\r\n}\r\nelse:win32:CONFIG(debug, debug|release) {\r\n    LIBS += -L$$PWD/../../../executable/ -lIPXACTmodelsd\r\n    LIBS += -L$$PWD/../../../executable/ -lKactusAPId\r\n    DESTDIR = ./debug\r\n}\r\nelse:unix {\r\n    LIBS += -L$$PWD/../../../executable/ -lIPXACTmodels\r\n    LIBS += -L$$PWD/../../../executable/ -lKactusAPI\r\n    DESTDIR = ./release\r\n}\r\n\r\nINCLUDEPATH += $$DESTDIR\r\nINCLUDEPATH += ../../../\r\nINCLUDEPATH += $$PWD/../../../KactusAPI/include\r\n\r\nDEPENDPATH += .\r\nDEPENDPATH += ../../../\r\n\r\nOBJECTS_DIR += $$DESTDIR\r\n\r\nMOC_DIR += ./generatedFiles\r\nUI_DIR += ./generatedFiles\r\nRCC_DIR += ./generatedFiles\r\ninclude(tst_QuartusProjectGenerator.pri)\r\n"
  },
  {
    "path": "tests/Plugins/VHDLimport/VHDLimport.pro",
    "content": "#-----------------------------------------------------------------------------\r\n# File: VHDLimport.pro\r\n#-----------------------------------------------------------------------------\r\n# Project: Kactus2\r\n# Author: Esko Pekkarinen\r\n# Date: 19.09.2014\r\n#\r\n# Description:\r\n# Qt project file template for running unit tests for VHDLimport.\r\n#-----------------------------------------------------------------------------\r\n\r\nTEMPLATE = subdirs\r\n\r\nCONFIG += testcase\r\nSUBDIRS += tst_VHDLPortParser.pro \\\r\n\t\t   tst_VHDLGenericParser.pro \\\r\n\t\t   tst_VHDLimport.pro \r"
  },
  {
    "path": "tests/Plugins/VHDLimport/tst_VHDLGenericParser.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: tst_Module.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Esko Pekkarinen\r\n// Date: 22.09.2014\r\n//\r\n// Description:\r\n// Unit test for class VHDLGenericParser.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include <QtTest>\r\n#include <QObject>\r\n\r\n#include <Plugins/VHDLimport/VHDLGenericParser.h>\r\n\r\n#include <IPXACTmodels/Component/Component.h>\r\n\r\nclass tst_VHDLGenericParser : public QObject\r\n{\r\n    Q_OBJECT\r\n\r\npublic:\r\n    tst_VHDLGenericParser();\r\n\r\nprivate slots:\r\n    void init();\r\n\r\n    void testGenericIsParsed();\r\n    void testGenericIsParsed_data();\r\n    \r\n    void testMultipleGenericsAreParsed();\r\n    void testMultipleGenericsAreParsed_data();\r\n    \r\n    void testCommentedGenericIsNotParsed();\r\n    \r\n    void testModelParametersAreNotParsedOutsideEntity();\r\n\r\n    void testCommentedSemicolonIsIgnored();\r\n\r\nprivate:\r\n        \r\n    void runParser(QString const& fileContent);\r\n   \r\n\r\n    //! The parser to test.\r\n    VHDLGenericParser parser_;\r\n\r\n    //! The component to add parsed component instantiation to.\r\n\tQSharedPointer<Component> importComponent_;\r\n\r\n\t//! The component instantiation to add parsed module parameters to.\r\n\tQSharedPointer<ComponentInstantiation> importComponentInstantiation_;\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_VHDLGenericParser::tst_VHDLGenericParser()\r\n//-----------------------------------------------------------------------------\r\ntst_VHDLGenericParser::tst_VHDLGenericParser(): parser_(this), importComponent_(new Component(VLNV(), Document::Revision::Std14))\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_VHDLGenericParser::init()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_VHDLGenericParser::init()\r\n{\r\n\timportComponent_ = QSharedPointer<Component>(new Component(VLNV(), Document::Revision::Std14));\r\n\r\n\timportComponentInstantiation_ = QSharedPointer<ComponentInstantiation>( new ComponentInstantiation );\r\n\timportComponentInstantiation_->setName(\"module_parameter_instantiation\");\r\n\timportComponent_->getComponentInstantiations()->append(importComponentInstantiation_);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_VHDLGenericParser::testGenericIsParsed()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_VHDLGenericParser::testGenericIsParsed()\r\n{\r\n    QFETCH(QString, fileContent);\r\n    QFETCH(QString, expectedName);\r\n    QFETCH(QString, expectedDataType);\r\n    QFETCH(QString, expectedType);\r\n    QFETCH(QString, expectedDefaultValue);\r\n    QFETCH(QString, expectedDescription);\r\n\r\n    runParser(fileContent);\r\n\r\n    QCOMPARE(importComponentInstantiation_->getModuleParameters()->count(), 1);\r\n    QCOMPARE(importComponent_->getParameters()->count(), 1);\r\n\r\n    QSharedPointer<ModuleParameter> createdModelParamter =\r\n\t\timportComponentInstantiation_->getModuleParameters()->first();\r\n    QSharedPointer<Parameter> equivalentParameter = importComponent_->getParameters()->first();\r\n\r\n    QCOMPARE(createdModelParamter->name(), expectedName);\r\n    QCOMPARE(createdModelParamter->getDataType(), expectedDataType);\r\n    QCOMPARE(createdModelParamter->getType(), expectedType);\r\n    QCOMPARE(createdModelParamter->getValue(), equivalentParameter->getValueId());\r\n    QCOMPARE(createdModelParamter->description(), expectedDescription);\r\n\r\n    QCOMPARE(equivalentParameter->name(), expectedName);\r\n    QCOMPARE(equivalentParameter->getType(), expectedType);\r\n    QCOMPARE(equivalentParameter->getValue(), expectedDefaultValue);\r\n    QCOMPARE(equivalentParameter->description(), expectedDescription);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_VHDLGenericParser::testWellFormedGenericIsParsed_data()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_VHDLGenericParser::testGenericIsParsed_data()\r\n{\r\n    QTest::addColumn<QString>(\"fileContent\");\r\n    QTest::addColumn<QString>(\"expectedName\");\r\n    QTest::addColumn<QString>(\"expectedDataType\");\r\n    QTest::addColumn<QString>(\"expectedType\");\r\n    QTest::addColumn<QString>(\"expectedDefaultValue\");\r\n    QTest::addColumn<QString>(\"expectedDescription\");\r\n\r\n    QTest::newRow(\"name and type\") << \r\n        \"entity test is\\n\"\r\n        \"    generic (\\n\"\r\n        \"        freq : integer\\n\"\r\n        \"   );\"\r\n        \"end test;\"\r\n        << \"freq\" << \"integer\" << \"int\" << \"\" << \"\";\r\n\r\n    QTest::newRow(\"name, type and default value on a single line\") << \r\n        \"entity test is\\n\"\r\n        \"    generic (dataWidth_g : integer := 16);\"\r\n        \"end test;\"\r\n        << \"dataWidth_g\" << \"integer\" << \"int\" << \"16\" << \"\";\r\n\r\n    QTest::newRow(\"name type, default value and description\") << \r\n        \"entity test is\\n\"\r\n        \"    generic (\\n\"\r\n        \"        outputFile : string := \\\"target.out\\\" -- Some file name\\n\"\r\n        \"   );\"\r\n        \"end test;\"\r\n        << \"outputFile\" << \"string\" << \"string\" << \"\\\"target.out\\\"\" << \"Some file name\";\r\n\r\n    QTest::newRow(\"name, type and default value on a separate lines\") << \r\n        \"entity test is\\n\"\r\n        \"    generic (\\n\"\r\n        \"freq \\n\"\r\n        \": \\n\"\r\n        \"integer \\n\"\r\n        \":= 500000 --Freq for core.\\n\"\r\n        \");\"\r\n        \"end test;\"\r\n        << \"freq\" << \"integer\" << \"int\" << \"500000\" << \"Freq for core.\";\r\n\r\n    QTest::newRow(\"Integer with defined range\") <<\r\n        \"entity test is\\n\"\r\n        \"    generic (dataWidth_g : natural range 0 to 32 := 16);\"\r\n        \"end test;\"\r\n        << \"dataWidth_g\" << \"natural\" << \"int\" << \"16\" << \"\";\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_VHDLGenericParser::runParser()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_VHDLGenericParser::runParser(QString const& fileContent)\r\n{\r\n    parser_.import(fileContent, importComponent_, importComponentInstantiation_);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_VHDLGenericParser::testMultipleGenericsAreParsed()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_VHDLGenericParser::testMultipleGenericsAreParsed()\r\n{\r\n    QFETCH(QString, fileContent);\r\n    QFETCH(int, expectedNumberOfGenerics);\r\n\r\n    runParser(fileContent);\r\n\r\n    QCOMPARE(importComponentInstantiation_->getModuleParameters()->count(), expectedNumberOfGenerics);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_VHDLGenericParser::testMultipleGenericsAreParsed_data()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_VHDLGenericParser::testMultipleGenericsAreParsed_data()\r\n{\r\n    QTest::addColumn<QString>(\"fileContent\");\r\n    QTest::addColumn<int>(\"expectedNumberOfGenerics\");\r\n\r\n    QTest::newRow(\"three standard generics\") << \r\n        \"entity test is\\n\"\r\n        \"   generic (\\n\"\r\n        \"       local_memory_start_addr : integer := 16#1000#;\\n\"\r\n        \"       local_memory_addr_bits  : integer := 12;\\n\"\r\n        \"       code_file               : string  := \\\"master.tbl\\\"\"\r\n        \"   );\\n\"\r\n        \"end test;\"\r\n        << 3;\r\n\r\n    QTest::newRow(\"three generics on a single line\") << \r\n        \"entity test is\\n\"\r\n        \"   generic (local_memory_start_addr : integer := 16#1000#;local_memory_addr_bits  : integer := 12;  width_g\t: integer := 8);\\n\"\r\n        \"end test;\"\r\n        << 3;\r\n\r\n    QTest::newRow(\"four generics with unusual whitespaces\") << \r\n        \"entity test is\\n\"\r\n        \"generic (local_memory_start_addr\\n\" \r\n        \": integer := 16#1000#;local_memory_addr_bits  :\\n\"\r\n        \"integer := 12;code_file :string:=\\\"master.tbl\\\"\\n\"\r\n        \";  width_g\t: integer \\n\"\r\n        \":= 8)\\n\"\r\n        \";\\n\"\r\n        \"end test;\"\r\n        << 4;\r\n\r\n    QTest::newRow(\"only first generics are parsed from multiple generic declarations\") << \r\n        \"entity test is\\n\"\r\n        \"   generic (\\n\"\r\n        \"       local_memory_start_addr : integer := 16#1000#;\\n\"\r\n        \"       local_memory_addr_bits  : integer := 12\\n\"\r\n        \"   );\\n\"\r\n        \"   generic (\\n\"\r\n        \"       extra1 : integer := 1;\\n\"\r\n        \"       extra2  : integer;\\n\"\r\n        \"       extra3  : integer\\n\"\r\n        \"   );\\n\"\r\n        \"end test;\"\r\n        << 2;\r\n\r\n    QTest::newRow(\"multiple definitions\") << \r\n        \"entity test is\\n\"\r\n        \"   generic (\\n\"\r\n        \"       dataWidth_g, addressWidth_g, ackWidth_g : integer\\n\"\r\n        \"   );\\n\"\r\n        \"end test;\"\r\n        << 3;\r\n\r\n    QTest::newRow(\"comments along generics\") << \r\n        \"entity test is\\n\"\r\n        \"   generic (--here there be generics\\n\"\r\n        \"       local_memory_start_addr : integer := 16#1000#;\\n\"\r\n        \"-- first comment\\n\"\r\n        \"-- second comment\\n\"\r\n        \"       local_memory_addr_bits  : integer := 12\\n\"\r\n        \"-- last comment\\n\"\r\n        \"   );\\n\"\r\n        \"end test;\"\r\n        << 2;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_VHDLGenericParser::testCommentedGenericIsNotParsed()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_VHDLGenericParser::testCommentedGenericIsNotParsed()\r\n{\r\n    QString fileContent =\r\n        \"entity test is\\n\"\r\n        \"   generic (\\n\"\r\n        \"--       dataWidth_g : integer\\n\"\r\n        \"   );\\n\"\r\n        \"end test;\";\r\n\r\n    runParser(fileContent);\r\n\r\n    QCOMPARE(importComponentInstantiation_->getModuleParameters()->count(), 0);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_VHDLGenericParser::testModelParametersAreNotParsedOutsideEntity()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_VHDLGenericParser::testModelParametersAreNotParsedOutsideEntity()\r\n{\r\n    QString fileContent(\r\n        \"entity empty is\\n\"\r\n        \"end empty;\\n\"\r\n        \"\\n\"\r\n        \"architecture structural of empty is\\n\"\r\n        \"\\n\"\r\n        \"component dut\"\r\n        \"   generic (\\n\"        \r\n        \"       local_memory_addr_bits  : integer := 12;\\n\"\r\n        \"       local_memory_data_bits  : integer := 32\\n\"\r\n        \"   );\\n\"\r\n        \"end dut;\\n\"\r\n        \"\\n\"\r\n        \"end structural;\\n\");\r\n\r\n    runParser(fileContent);\r\n\r\n    QCOMPARE(importComponentInstantiation_->getModuleParameters()->count(), 0);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_VHDLGenericParser::testCommentedSemicolonIsIgnored()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_VHDLGenericParser::testCommentedSemicolonIsIgnored()\r\n{\r\n    QString fileContent(\r\n        \"entity test is\\n\"\r\n        \"   generic (\\n\"\r\n        \"       dataWidth_g : integer := 16;\\n\"\r\n        \"       num_bits : integer := 2**dataWidth_g; -- dataWidth_g(15);\\n\"\r\n        \"       byteWidth_g : integer := dataWidth_g / 8\"\r\n        \"   );\\n\"\r\n        \"end test;\"\r\n    );\r\n\r\n    runParser(fileContent);\r\n\r\n    QCOMPARE(importComponentInstantiation_->getModuleParameters()->count(), 3);\r\n    QCOMPARE(importComponent_->getParameters()->count(), 3);\r\n\r\n    QSharedPointer<ModuleParameter> bitParameter =\r\n        importComponentInstantiation_->getModuleParameters()->at(1);\r\n\r\n    QCOMPARE(bitParameter->name(), QString(\"num_bits\"));\r\n    QCOMPARE(bitParameter->getDataType(), QString(\"integer\"));\r\n    QCOMPARE(bitParameter->getType(), QString(\"int\"));\r\n    QCOMPARE(bitParameter->description(), QString(\"dataWidth_g(15);\"));\r\n\r\n\r\n    QSharedPointer<ModuleParameter> byteParameter =\r\n        importComponentInstantiation_->getModuleParameters()->last();\r\n \r\n    QCOMPARE(byteParameter->name(), QString(\"byteWidth_g\"));\r\n    QCOMPARE(byteParameter->getDataType(), QString(\"integer\"));\r\n    QCOMPARE(byteParameter->getType(), QString(\"int\"));\r\n    \r\n }\r\n\r\n\r\nQTEST_APPLESS_MAIN(tst_VHDLGenericParser)\r\n\r\n#include \"tst_VHDLGenericParser.moc\"\r\n"
  },
  {
    "path": "tests/Plugins/VHDLimport/tst_VHDLGenericParser.pri",
    "content": "# ----------------------------------------------------\r\n# This file is generated by the Qt Visual Studio Add-in.\r\n# ------------------------------------------------------\r\n\r\nHEADERS += ../../../Plugins/VHDLimport/VHDLGenericParser.h\r\nSOURCES += ./tst_VHDLGenericParser.cpp \\\r\n    ../../../Plugins/VHDLimport/VHDLGenericParser.cpp\r\n"
  },
  {
    "path": "tests/Plugins/VHDLimport/tst_VHDLGenericParser.pro",
    "content": "#-----------------------------------------------------------------------------\r\n# File: tst_VHDLGenericParser.pro\r\n#-----------------------------------------------------------------------------\r\n# Project: Kactus 2\r\n# Author: Esko Pekkarinen\r\n# Date: 22.09.2014\r\n#\r\n# Description:\r\n# Qt project file template for running unit tests for VHDLGenericParser.\r\n#-----------------------------------------------------------------------------\r\n\r\nTEMPLATE = app\r\n\r\nTARGET = tst_VHDLGenericParser\r\n\r\nQT += core xml testlib\r\nCONFIG += c++11 testcase console\r\n\r\nwin32:CONFIG(release, debug|release) {\r\n    LIBS += -L$$PWD/../../../executable/ -lIPXACTmodel\r\n    LIBS += -L$$PWD/../../../executable/ -lKactusAPI\r\n    DESTDIR = ./release\r\n}\r\nelse:win32:CONFIG(debug, debug|release) {\r\n    LIBS += -L$$PWD/../../../executable/ -lIPXACTmodelsd\r\n    LIBS += -L$$PWD/../../../executable/ -lKactusAPId\r\n    DESTDIR = ./debug\r\n}\r\nelse:unix {\r\n    LIBS += -L$$PWD/../../../executable/ -lIPXACTmodels\r\n    LIBS += -L$$PWD/../../../executable/ -lKactusAPI\r\n    DESTDIR = ./release\r\n}\r\n\r\nINCLUDEPATH += $$DESTDIR\r\nINCLUDEPATH += ../../../\r\nINCLUDEPATH += $$PWD/../../../KactusAPI/include\r\n\r\nDEPENDPATH += .\r\nDEPENDPATH += ../../../\r\n\r\n\r\nMOC_DIR += ./generatedFiles\r\nUI_DIR += ./generatedFiles\r\nRCC_DIR += ./generatedFiles\r\ninclude(tst_VHDLGenericParser.pri)\r\n"
  },
  {
    "path": "tests/Plugins/VHDLimport/tst_VHDLPortParser.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: tst_VHDLPortParser.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Esko Pekkarinen\r\n// Date: 22.09.2014\r\n//\r\n// Description:\r\n// Unit test for class VHDLPortParser.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include <QtTest>\r\n#include <QObject>\r\n#include <QSharedPointer>\r\n\r\n#include <IPXACTmodels/Component/Component.h>\r\n\r\n#include <Plugins/VHDLimport/VHDLPortParser.h>\r\n\r\nQ_DECLARE_METATYPE(DirectionTypes::Direction)\r\n\r\nclass tst_VHDLPortParser : public QObject\r\n{\r\n    Q_OBJECT\r\n\r\npublic:\r\n    tst_VHDLPortParser();\r\n\r\nprivate slots:\r\n    void init();\r\n\r\n    //! Test cases:\r\n    void testPortIsParsed();\r\n    void testPortIsParsed_data();\r\n    \r\n    void testMultiplePortsAreParsed();\r\n    void testMultiplePortsAreParsed_data();\r\n\r\n    void testCommentedPortIsNotParsed();\r\n\r\n    void testPortsAreNotParsedOutsideEntity();\r\n\r\nprivate:\r\n\r\n    void runParser(QString const& fileContent);\r\n   \r\n    //! The parser to test.\r\n    VHDLPortParser parser_;\r\n\r\n    //! Test component to add parsed ports to.\r\n\tQSharedPointer<Component> importComponent_;\r\n\tQSharedPointer<ComponentInstantiation> importComponentInstantiation_;\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_VHDLPortParser::tst_VHDLPortParser()\r\n//-----------------------------------------------------------------------------\r\ntst_VHDLPortParser::tst_VHDLPortParser() : parser_(this), importComponent_(new Component(VLNV(), Document::Revision::Std14))\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_VHDLPortParser::init()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_VHDLPortParser::init()\r\n{\r\n\timportComponent_ = QSharedPointer<Component>(new Component(VLNV(), Document::Revision::Std14));\r\n\r\n\timportComponentInstantiation_ = QSharedPointer<ComponentInstantiation>( new ComponentInstantiation );\r\n\timportComponent_->getModel()->getComponentInstantiations()->append(importComponentInstantiation_);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_VhdlPortParser::testPortIsParsed()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_VHDLPortParser::testPortIsParsed()\r\n{\r\n    QFETCH(QString, fileContent);\r\n    QFETCH(QString, expectedName);\r\n    QFETCH(DirectionTypes::Direction, expectedDirection);    \r\n\tQFETCH(QString, leftBound);\r\n\tQFETCH(QString, rightBound);\r\n    QFETCH(QString, expectedType);    \r\n    QFETCH(QString, expectedTypeDefinition);    \r\n    QFETCH(QString, expectedDefaultValue);\r\n    QFETCH(QString, expectedDescription);\r\n\r\n    runParser(fileContent);\r\n\r\n    QVERIFY(importComponent_->getPorts()->count() >= 1);\r\n\r\n    QSharedPointer<Port> createdPort = importComponent_->getPorts()->first();\r\n    QCOMPARE(createdPort->name(), expectedName);\r\n    QCOMPARE(createdPort->getDirection(), expectedDirection);\r\n\tQCOMPARE(createdPort->getLeftBound(), leftBound);\r\n\tQCOMPARE(createdPort->getRightBound(), rightBound);\r\n    QCOMPARE(createdPort->getTypeName(), expectedType);    \r\n    QCOMPARE(createdPort->getTypeDefinition(expectedType), expectedTypeDefinition);   \r\n    QCOMPARE(createdPort->getDefaultValue(), expectedDefaultValue);\r\n    QCOMPARE(createdPort->description(), expectedDescription);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_VhdlPortParser::testPortIsParsed_data()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_VHDLPortParser::testPortIsParsed_data()\r\n{\r\n    QTest::addColumn<QString>(\"fileContent\");\r\n    QTest::addColumn<QString>(\"expectedName\");    \r\n    QTest::addColumn<DirectionTypes::Direction>(\"expectedDirection\");\r\n\tQTest::addColumn<QString>(\"leftBound\");\r\n\tQTest::addColumn<QString>(\"rightBound\");\r\n    QTest::addColumn<QString>(\"expectedType\");   \r\n    QTest::addColumn<QString>(\"expectedTypeDefinition\"); \r\n    QTest::addColumn<QString>(\"expectedDefaultValue\");\r\n    QTest::addColumn<QString>(\"expectedDescription\");\r\n\r\n    QTest::newRow(\"name, type and direction\") << \r\n        \"entity test is\\n\"\r\n        \"   port (\\n\"\r\n        \"       clk : in std_logic \\n\"\r\n        \"   );\\n\"\r\n        \"end test;\"\r\n        << \"clk\" << DirectionTypes::IN << \"\" << \"\" << \"std_logic\" << \"IEEE.std_logic_1164.all\" << \"\" << \"\";\r\n\r\n    QTest::newRow(\"name, type and direction on a single line\") << \r\n        \"entity test is\\n\"\r\n        \"   port (clk : in std_logic);\\n\"\r\n        \"end test;\"\r\n        << \"clk\" << DirectionTypes::IN << \"\" << \"\" << \"std_logic\" << \"IEEE.std_logic_1164.all\" << \"\" << \"\";\r\n\r\n    QTest::newRow(\"name type, direction and default value\") << \r\n        \"entity test is\\n\"\r\n        \"   port (enable : in std_logic := '1');\\n\"\r\n        \"end test;\"\r\n        << \"enable\" << DirectionTypes::IN << \"\" << \"\" << \"std_logic\" << \"IEEE.std_logic_1164.all\" << \"'1'\" << \"\";\r\n\r\n    QTest::newRow(\"name type, direction, default value and description\") <<\r\n        \"entity test is\\n\"\r\n        \"   port (data : out std_logic_vector(31 downto 0) := (others => '0'); -- data from ip\\n\"\r\n        \"   clk : in std_logic \\n\"\r\n        \");\\n\"\r\n        \"end test;\"\r\n        << \"data\" << DirectionTypes::OUT << \"31\" << \"0\" << \"std_logic_vector\" << \"IEEE.std_logic_1164.all\"\r\n        << \"(others => '0')\" << \"data from ip\";\r\n\r\n    QTest::newRow(\"name type, direction and default value on separate lines\") << \r\n        \"entity test is\\n\"\r\n        \"port (clk\\n\"\r\n        \":\\n\"\r\n        \"in\\n\"\r\n        \"std_ulogic := '1' --       Clk from top.\\n\"\r\n        \");\\n\"\r\n        \"end test;\"\r\n        << \"clk\" << DirectionTypes::IN << \"\" << \"\" << \"std_ulogic\" << \"IEEE.std_logic_1164.all\"\r\n        << \"'1'\" << \"Clk from top.\";\r\n\r\n    QTest::newRow(\"port after comment.\") << \r\n        \"entity test is\\n\"\r\n        \"    port (\\n\"\r\n        \"            -- DCT signals\\n\"\r\n        \"        i_clk : in std_logic\\n\"\r\n        \");\\n\"\r\n        \"end test;\"\r\n        << \"i_clk\" << DirectionTypes::IN << \"\" << \"\" << \"std_logic\" << \"IEEE.std_logic_1164.all\" << \"\" << \"\";\r\n\r\n    QTest::newRow(\"Standard type: string.\") << \r\n        \"entity test is\\n\"\r\n        \"   port (\\n\"\r\n        \"       sim_name : in string  \\n\"\r\n        \"   );\\n\"\r\n        \"end test;\"\r\n        << \"sim_name\" << DirectionTypes::IN << \"\" << \"\" << \"string\" << \"\" << \"\" << \"\";\r\n\r\n    QTest::newRow(\"Numeric type: unsigned.\") << \r\n        \"entity test is\\n\"\r\n        \"   port (\\n\"\r\n        \"       count : in unsigned  \\n\"\r\n        \"   );\\n\"\r\n        \"end test;\"\r\n        << \"count\" << DirectionTypes::IN << \"\" << \"\" << \"unsigned\" << \"IEEE.numeric_std.all\" << \"\" << \"\";\r\n\r\n    QTest::newRow(\"Numeric type: signed.\") << \r\n        \"entity test is\\n\"\r\n        \"   port (\\n\"\r\n        \"       multiplicand : in signed  \\n\"\r\n        \"   );\\n\"\r\n        \"end test;\"\r\n        << \"multiplicand\" << DirectionTypes::IN << \"\" << \"\" << \"signed\" << \"IEEE.numeric_std.all\" << \"\" << \"\";\r\n\r\n    QTest::newRow(\"Expression in left vector bound\") <<\r\n        \"entity test is\\n\"\r\n        \"   port (data : out std_logic_vector((18-8) downto 0)\\n\"\r\n        \");\\n\"\r\n        \"end test;\"\r\n        << \"data\" << DirectionTypes::OUT << \"(18-8)\" << \"0\" << \"std_logic_vector\" << \"IEEE.std_logic_1164.all\"\r\n        << \"\" << \"\";\r\n\r\n    QTest::newRow(\"Expression in right vector bound\") <<\r\n        \"entity test is\\n\"\r\n        \"   port (data : out std_logic_vector(0 to (10 + 5))\\n\"\r\n        \");\\n\"\r\n        \"end test;\"\r\n        << \"data\" << DirectionTypes::OUT << \"0\" << \"(10 + 5)\" << \"std_logic_vector\" << \"IEEE.std_logic_1164.all\"\r\n        << \"\" << \"\";\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_VHDLPortParser::runParser()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_VHDLPortParser::runParser(QString const& fileContent)\r\n{\r\n    parser_.import(fileContent, importComponent_, importComponentInstantiation_);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_VhdlPortParser::testMultiplePortsAreParsed()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_VHDLPortParser::testMultiplePortsAreParsed()\r\n{\r\n    QFETCH(QString, fileContent);\r\n    QFETCH(int, expectedNumberOfPorts);\r\n\r\n    runParser(fileContent);\r\n\r\n    QCOMPARE(importComponent_->getPorts()->count(), expectedNumberOfPorts);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_VhdlPortParser::testMultiplePortsAreParsed_data()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_VHDLPortParser::testMultiplePortsAreParsed_data()\r\n{\r\n    QTest::addColumn<QString>(\"fileContent\");\r\n    QTest::addColumn<int>(\"expectedNumberOfPorts\");\r\n\r\n    QTest::newRow(\"three standard ports\") << \r\n        \"entity test is\\n\"\r\n        \"   port (\\n\"\r\n        \"       clk : in std_logic;\\n\"\r\n        \"       enable : in std_logic := '1';\\n\"\r\n        \"       data : out std_logic\\n\"\r\n        \"   );\\n\"\r\n        \"end test;\"\r\n        << 3;\r\n\r\n    QTest::newRow(\"three ports on a single line\") << \r\n        \"entity test is\\n\"\r\n        \"   port (clk : in std_logic;enable : in std_logic := '1';data : out std_logic);\\n\"\r\n        \"end test;\"\r\n        << 3;\r\n\r\n    QTest::newRow(\"four ports with unusual whitespaces\") << \r\n        \"entity test is\\n\"\r\n        \"port (clk:       in\\n\"\r\n        \"std_logic;addr: in\\n\"\r\n        \"   std_logic_vector(11 \\n\"\r\n        \"downto 0);      data:\\n\"\r\n        \"out std_logic_vector(\\n\"\r\n        \"31 downto 0);intr   : out std_logic)\\n\"\r\n        \";\\n\"\r\n        \"end test;\"\r\n        << 4;\r\n\r\n    QTest::newRow(\"only first ports are parsed from multiple port declarations\") << \r\n        \"entity test is\\n\"\r\n        \"   port (\\n\"\r\n        \"       clk : in std_logic;\\n\"        \r\n        \"       data : out std_logic_vector(31 downto 0)\\n\"\r\n        \"   );\\n\"\r\n        \"   port (\\n\"\r\n        \"       extra1 : in std_logic_vector(11 downto 0);\\n\"\r\n        \"       extra2 : in std_logic;\\n\"        \r\n        \"       extra3 : out std_logic_vector(31 downto 0)\\n\"     \r\n        \"   );\\n\"\r\n        \"end test;\"\r\n        << 2;\r\n\r\n    QTest::newRow(\"multiple definitions\") << \r\n        \"entity test is\\n\"\r\n        \"   port (\\n\"\r\n        \"       clk, enable, serial_data : in std_logic\\n\"\r\n        \"   );\\n\"\r\n        \"end test;\"\r\n        << 3;\r\n\r\n    QTest::newRow(\"empty ports\") << \r\n        \"entity test is\\n\"\r\n        \"   port (\\n\"\r\n        \"   );\\n\"\r\n        \"end test;\"\r\n        << 0;\r\n\r\n    QTest::newRow(\"empty entity\") << \r\n        \"entity test is\\n\"\r\n        \"end test;\"\r\n        << 0;\r\n\r\n    QTest::newRow(\"Comments between ports.\") << \r\n        \"entity test is\\n\"\r\n        \"   port (-- Ports are declared here.\\n\"        \r\n        \"-- Clock to test.\\n\"\r\n        \"       clk   : in  std_logic;\\n\"\r\n        \"    -- Reset to test.\\n\"\r\n        \"    -- Remember to connect.\\n\"\r\n        \"       rst_n : in  std_logic;\\n\"     \r\n        \"       data  : out std_logic_vector(31 downto 0)\\n\"\r\n        \"-- End of all ports.\\n\"\r\n        \"   );\\n\"\r\n        \"end test;\"\r\n        << 3;\r\n\r\n    QTest::newRow(\"Vector before port whose name begins with word port.\") <<\r\n        \"ENTITY test IS\\n\"\r\n        \"port (\\n\"\r\n        \"      data : in std_logic_vector(15 downto 0);\\n\"\r\n        \"      port_out : out std_logic\\n\"\r\n        \");\"\r\n        \"END test;\"\r\n        << 2;\r\n\r\n    QTest::newRow(\"Last port is parsed with lots of comments preceding\") <<\r\n        \"entity DIG_TOP is\\n\"\r\n        \"\\n\"\r\n        \"  port(\\n\"\r\n        \"--    cfg_comp_12_analog_hyst_pos_in      : in  std_logic_vector(8 - 1 downto 0);\\n\"\r\n        \"--    cfg_comp_12_analog_hyst_neg_in      : in  std_logic_vector(8 - 1 downto 0);\\n\"\r\n        \"--    cfg_comp_13_analog_hyst_neg_in      : in  std_logic_vector(8 - 1 downto 0);\\n\"\r\n        \"--    cfg_comp_14_analog_hyst_pos_in      : in  std_logic_vector(8 - 1 downto 0);\\n\"\r\n        \"--    cfg_comp_14_analog_hyst_neg_in      : in  std_logic_vector(8 - 1 downto 0);\\n\"\r\n        \"--    cfg_comp_15_analog_hyst_pos_in      : in  std_logic_vector(8 - 1 downto 0);\\n\"\r\n        \"--    cfg_comp_15_analog_hyst_neg_in      : in  std_logic_vector(8 - 1 downto 0);\\n\"\r\n        \"--    cfg_comp_16_analog_hyst_pos_in      : in  std_logic_vector(8 - 1 downto 0);\\n\"\r\n        \"\\n\"\r\n        \"    --clk, rstb\\n\"\r\n        \"    clk_in     : in std_logic;\\n\"\r\n        \"    rstb_in    : in std_logic\\n\"\r\n        \"  );\\n\"\r\n        \"end DIG_TOP;\\n\"\r\n        << 2;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_VhdlPortParser::testCommentedPortIsNotParsed()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_VHDLPortParser::testCommentedPortIsNotParsed()\r\n{\r\n    QString fileContent =\r\n        \"entity test is\\n\"\r\n        \"   port (\\n\"\r\n        \"--       clk : in std_logic\\n\"\r\n        \"   );\\n\"\r\n        \"end test;\";\r\n\r\n    runParser(fileContent);\r\n\r\n    QCOMPARE(importComponent_->getPorts()->count(), 0);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_VHDLPortParser::testPortsAreNotParsedOutsideEntity()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_VHDLPortParser::testPortsAreNotParsedOutsideEntity()\r\n{\r\n    QString fileContent(\r\n        \"entity empty is\\n\"\r\n        \"end empty;\\n\"\r\n        \"\\n\"\r\n        \"architecture structural of empty is\\n\"\r\n        \"\\n\"\r\n        \"component dut\"\r\n        \"   port (\\n\"\r\n        \"       clk : in std_logic\\n\"\r\n        \"   );\\n\"\r\n        \"end dut;\\n\"\r\n        \"\\n\"\r\n        \"end structural;\\n\");\r\n\r\n    runParser(fileContent);\r\n\r\n    QCOMPARE(importComponent_->getPorts()->count(), 0);\r\n}\r\n\r\nQTEST_APPLESS_MAIN(tst_VHDLPortParser)\r\n\r\n#include \"tst_VHDLPortParser.moc\"\r\n"
  },
  {
    "path": "tests/Plugins/VHDLimport/tst_VHDLPortParser.pri",
    "content": "# ----------------------------------------------------\r\n# This file is generated by the Qt Visual Studio Add-in.\r\n# ------------------------------------------------------\r\n\r\nHEADERS += ../../../Plugins/VHDLimport/VHDLPortParser.h\r\nSOURCES += ../../../Plugins/VHDLimport/VHDLPortParser.cpp \\\r\n    ./tst_VHDLPortParser.cpp\r\n"
  },
  {
    "path": "tests/Plugins/VHDLimport/tst_VHDLPortParser.pro",
    "content": "#-----------------------------------------------------------------------------\r\n# File: tst_VHDLPortParser.pro\r\n#-----------------------------------------------------------------------------\r\n# Project: Kactus 2\r\n# Author: Esko Pekkarinen\r\n# Date: 22.09.2014\r\n#\r\n# Description:\r\n# Qt project file template for running unit tests for VHDLPortParser.\r\n#-----------------------------------------------------------------------------\r\n\r\nTEMPLATE = app\r\n\r\nTARGET = tst_VHDLPortParser\r\n\r\nQT += core xml testlib\r\nCONFIG += c++11 testcase console\r\n\r\nwin32:CONFIG(release, debug|release) {\r\n    LIBS += -L$$PWD/../../../executable/ -lIPXACTmodels\r\n    LIBS += -L$$PWD/../../../executable/ -lKactusAPI\r\n    DESTDIR = ./release\r\n}\r\nelse:win32:CONFIG(debug, debug|release) {\r\n    LIBS += -L$$PWD/../../../executable/ -lIPXACTmodelsd\r\n    LIBS += -L$$PWD/../../../executable/ -lKactusAPId\r\n    DESTDIR = ./debug\r\n}\r\nelse:unix {\r\n    LIBS += -L$$PWD/../../../executable/ -lIPXACTmodels\r\n    LIBS += -L$$PWD/../../../executable/ -lKactusAPI\r\n    DESTDIR = ./release\r\n}\r\n\r\nINCLUDEPATH += $$DESTDIR\r\nINCLUDEPATH += ../../../\r\nINCLUDEPATH += $$PWD/../../../KactusAPI/include\r\n\r\nDEPENDPATH += .\r\nDEPENDPATH += ../../../\r\n\r\nOBJECTS_DIR += $$DESTDIR\r\nMOC_DIR += ./generatedFiles\r\nUI_DIR += ./generatedFiles\r\nRCC_DIR += ./generatedFiles\r\ninclude(tst_VHDLPortParser.pri)\r\n"
  },
  {
    "path": "tests/Plugins/VHDLimport/tst_VHDLimport.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: tst_VHDLimport.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Esko Pekkarinen\r\n// Date: 05.09.2014\r\n//\r\n// Description:\r\n// Unit test for class VHDLimport.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include <QtTest>\r\n\r\n#include <IPXACTmodels/Component/Component.h>\r\n#include <IPXACTmodels/Component/Port.h>\r\n#include <IPXACTmodels/Component/Model.h>\r\n#include <IPXACTmodels/common/ModuleParameter.h>\r\n#include <IPXACTmodels/generaldeclarations.h>\r\n\r\n#include <Plugins/VHDLimport/VHDLimport.h>\r\n\r\n#include <KactusAPI/include/ImportColors.h>\r\n#include <KactusAPI/include/ImportHighlighter.h>\r\n\r\n#include <QPlainTextEdit>\r\n#include <QSharedPointer>\r\n#include <common/NameGenerationPolicy.h>\r\n\r\n\r\nQ_DECLARE_METATYPE(QSharedPointer<ModuleParameter>)\r\n\r\nclass tst_VHDLimport : public QObject\r\n{\r\n    Q_OBJECT\r\n\r\npublic:\r\n    tst_VHDLimport();\r\n\r\nprivate slots:\r\n    void init();\r\n    void cleanup();\r\n\r\n    //! Testcases:\r\n    void testSupportedFileTypes();\r\n\r\n    void nothingParsedFromMalformedEntity();\r\n    void nothingParsedFromMalformedEntity_data();\r\n\r\n    void testEntityIsFound();\r\n    void testEntityIsFound_data();\r\n    \r\n    void testPortIsHighlighted();\r\n    void testPortIsHighlighted_data();\r\n\r\n    void testGenericIsHighlighted();\r\n    void testGenericIsHighlighted_data();\r\n\r\n    void testFontInsideEntityIsBlack();\r\n    void testFontInsideEntityIsBlack_data();\r\n\r\n    void testModelParameterIsAssignedToPort();\r\n    void testModelParameterIsAssignedToPort_data();\r\n    void testModelParameterAsPortBoundary();\r\n\r\n    void testModelParameterIsAssignedToModelParameter();\r\n\r\n    void testPortsAndModelParametersAreNotParsedOutsideEntity();\r\n     \r\n    void testParameterNotFoundInFileIsRemoved();\r\n    void testExistingModelParameterIdDoesNotChange();\r\n\r\n    void testExistingPortIsSetAsPhantom();\r\n    void testExistingPortIsOverriden();\r\n\r\n    void testModelNameAndEnvironmentIsImportedToView();\r\n    void testArchitecturePrecedesConfigurationForModelName();\r\n    void testConfigurationIsImportedToViewIfNoArchitectureAvailable();\r\n\r\n    void testMultipleEntities();\r\n    void testMultipleEntities_data();\r\n\r\nprivate:\r\n\r\n    void runParser(QString& input, int const& entityNumber = 0);\r\n\r\n    QString getEntityDeclaration(QString const& input, int const& entityNumber);\r\n\r\n    QPlainTextEdit displayEditor_;\r\n\r\n    VHDLimport parser_;\r\n    \r\n    ImportHighlighter* highlighter_;\r\n\r\n    QSharedPointer<Component> importComponent_;\r\n\r\n    QSignalSpy* createdPorts_;\r\n    QSignalSpy* createdGenerics_;\r\n\r\n    QSignalSpy* removedPorts_;\r\n    QSignalSpy* removedGenerics_;\r\n    \r\n    void verifyNotHighlightedAfterDeclartion(const int declarationStartIndex, \r\n        const int declarationLength, QColor const& highlightColor) const;\r\n\r\n    void verifyDeclarationIsHighlighted(const int declarationStartIndex, const int \r\n        declarationLength, QColor const& expectedHighlight) const;\r\n\r\n    void verifyNotHighlightedBeforeDeclaration(int declarationStartIndex, QColor const& highlightColor);\r\n\r\n    void verifySectionFontColorIs(int startIndex, int endIndex, QColor const& expectedFontColor);\r\n   \r\n\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_VHDLimport::tst_VHDLimport()\r\n//-----------------------------------------------------------------------------\r\ntst_VHDLimport::tst_VHDLimport(): displayEditor_(), parser_(), \r\n    highlighter_(new ImportHighlighter(&displayEditor_, this)),\r\n    createdPorts_(0), createdGenerics_(0), importComponent_(0)\r\n{\r\n    qRegisterMetaType<QSharedPointer<Port> >();\r\n    qRegisterMetaType<QSharedPointer<ModuleParameter> >();\r\n\r\n    parser_.setHighlighter(highlighter_);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_VHDLimport::init()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_VHDLimport::init()\r\n{\r\n    importComponent_ = QSharedPointer<Component>(new Component(VLNV(), Document::Revision::Std14));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_VHDLimport::cleanup()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_VHDLimport::cleanup()\r\n{\r\n \r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_VHDLimport::testSupportedFileTypes()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_VHDLimport::testSupportedFileTypes()\r\n{\r\n    QStringList supportedTypes = parser_.getSupportedFileTypes();\r\n\r\n    QVERIFY(supportedTypes.contains(\"vhdlSource\"));\r\n    QVERIFY(supportedTypes.contains(\"vhdlSource-93\"));\r\n    QVERIFY(supportedTypes.contains(\"vhdlSource-87\"));\r\n    QCOMPARE(supportedTypes.count(), 3);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_VHDLimport::nothingParsedFromMalformedEntity()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_VHDLimport::nothingParsedFromMalformedEntity()\r\n{\r\n    QFETCH(QString, fileContent);\r\n\r\n    runParser(fileContent);\r\n\r\n\tQVERIFY(!importComponent_->hasPorts());\r\n\tQCOMPARE(importComponent_->getComponentInstantiations()->size(), 0);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_VHDLimport::nothingParsedFromMalformedEntity_data()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_VHDLimport::nothingParsedFromMalformedEntity_data()\r\n{\r\n    QTest::addColumn<QString>(\"fileContent\");\r\n\r\n    QTest::newRow(\"empty file\") << \"\";\r\n\r\n    QTest::newRow(\"no entity defined\") << \r\n        \"architecture rtl of empty is\\n\"\r\n        \"begin\\n\"\r\n        \"end;\";\r\n\r\n    /*QTest::newRow(\"no begin of ports\") << \r\n        \"entity test is\"\r\n        \"   clk: in std_logic\\n\"\r\n        \");\\n\"\r\n        \"end test;\";*/\r\n\r\n    QTest::newRow(\"no closing bracket for ports\") << \r\n        \"entity noPortBracket is\"\r\n        \"port (\\n\"\r\n        \"   clk: in std_logic\\n\"\r\n        \"-- no closing bracket after ports.\\n\"\r\n        \"end noPortBracket;\";\r\n\r\n    /*QTest::newRow(\"no begin of generics\") << \r\n        \"entity test is\"\r\n        \"   local_memory_addr_bits  : integer\\n\"\r\n        \");\\n\"\r\n        \"end test;\";*/\r\n\r\n    QTest::newRow(\"no closing bracket for generics\") << \r\n        \"entity noGenericBracket is\"\r\n        \"generic (\\n\"\r\n        \"   local_memory_addr_bits  : integer\\n\"\r\n        \"-- no closing bracket after generics.\\n\"\r\n        \"end noGenericBracket;\";\r\n\r\n    QTest::newRow(\"no end for entity\") << \r\n        \"entity noBracket is\"\r\n        \"generic (\\n\"\r\n        \"   local_memory_addr_bits  : integer\\n\"\r\n        \");\\n\"\r\n        \"port (\\n\"\r\n        \"   clk: in std_logic\\n\"\r\n        \");\";\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_VHDLimport::testEntityIsFound()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_VHDLimport::testEntityIsFound()\r\n{\r\n    QFETCH(QString, fileContent);\r\n\r\n    runParser(fileContent);\r\n\r\n    QCOMPARE(importComponent_->getComponentInstantiations()->size(), 1);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_VHDLimport::testEntityIsFound_data()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_VHDLimport::testEntityIsFound_data()\r\n{\r\n    QTest::addColumn<QString>(\"fileContent\");\r\n\r\n    QTest::newRow(\"empty entity\") << \"entity emtpyEntity is\\n\"\r\n        \"end emtpyEntity;\\n\";\r\n\r\n    QTest::newRow(\"No name in end declaration\") << \"entity testEntity is\\n\"\r\n        \"port (\\n\"\r\n        \"   clk: in std_logic\\n\"\r\n        \");\\n\"\r\n        \"end entity;\\n\";\r\n\r\n    QTest::newRow(\"No keyword entity in end declaration\") << \"entity testEntity is\\n\"\r\n        \"port (\\n\"\r\n        \"   clk: in std_logic\\n\"\r\n        \");\\n\"\r\n        \"end testEntity;\\n\";\r\n\r\n    QTest::newRow(\"No name or keyword entity in end declaration\") << \"entity testEntity is\\n\"\r\n        \"port (\\n\"\r\n        \"   clk: in std_logic\\n\"\r\n        \");\\n\"\r\n        \"end;\\n\";\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_VHDLimport::runParser()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_VHDLimport::runParser(QString& input, int const& selectedComponent /* = 0 */)\r\n{\r\n    QString inspect = input.replace(\"\\r\\n\", \"\\n\");\r\n\r\n    QString entityDeclaration = getEntityDeclaration(inspect, selectedComponent);\r\n\r\n    displayEditor_.setPlainText(inspect);\r\n    parser_.import(inspect, entityDeclaration, importComponent_);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VHDLimport::getEntityDeclaration()\r\n//-----------------------------------------------------------------------------\r\nQString tst_VHDLimport::getEntityDeclaration(QString const& input, int const& entityNumber)\r\n{\r\n    QStringList fileEntities;\r\n\r\n    QRegularExpression entityExpression(\"ENTITY\\\\s+(\\\\w+)\\\\s+IS\\\\s+.*END(?:\\\\s+ENTITY)?(?:\\\\s+\\\\1)?\\\\s*[;]\",\r\n        QRegularExpression::CaseInsensitiveOption | QRegularExpression::DotMatchesEverythingOption);\r\n\r\n    QRegularExpressionMatchIterator matchIterator = entityExpression.globalMatch(input);\r\n    while (matchIterator.hasNext())\r\n    {\r\n        QRegularExpressionMatch match = matchIterator.next();\r\n        if (match.hasMatch())\r\n        {\r\n            fileEntities.append(match.captured());\r\n        }\r\n    }\r\n\r\n    if (!fileEntities.isEmpty() && fileEntities.size() > entityNumber)\r\n    {\r\n        return fileEntities.at(entityNumber);\r\n    }\r\n    else\r\n    {\r\n        return input;\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_VHDLimport::testPortHighlight()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_VHDLimport::testPortIsHighlighted()\r\n{\r\n    QFETCH(QString, fileContent);\r\n    QFETCH(QString, portDeclaration);\r\n\r\n    runParser(fileContent);\r\n\r\n    int begin = fileContent.indexOf(portDeclaration);\r\n        \r\n    verifyNotHighlightedBeforeDeclaration(begin, ImportColors::PORT);\r\n    verifyDeclarationIsHighlighted(begin, portDeclaration.length(), ImportColors::PORT);\r\n    verifyNotHighlightedAfterDeclartion(begin, portDeclaration.length(), ImportColors::PORT);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_VHDLimport::testPortHighlight()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_VHDLimport::testPortIsHighlighted_data()\r\n{\r\n    QTest::addColumn<QString>(\"fileContent\");\r\n    QTest::addColumn<QString>(\"portDeclaration\");\r\n    \r\n    QTest::newRow(\"simplest possible port declaration\") <<\r\n        \"entity test is\\n\"\r\n        \"    port (\\n\"\r\n        \"        clk : in std_logic\\n\"\r\n        \"   );\\n\"\r\n        \"end test;\"\r\n        << \"clk : in std_logic\";\r\n\r\n    QTest::newRow(\"port declaration with default value\") <<\r\n        \"entity test is\\n\"\r\n        \"    port (\\n\"\r\n        \"        clk : in std_logic := '1'\\n\"\r\n        \"   );\\n\"\r\n        \"end test;\"\r\n        << \"clk : in std_logic := '1'\";\r\n\r\n    QTest::newRow(\"port declaration with description\") <<\r\n        \"entity test is\\n\"\r\n        \"    port (\\n\"\r\n        \"        clk : in std_logic -- Clk from top\\n\"\r\n        \"   );\\n\"\r\n        \"end test;\"\r\n        << \"clk : in std_logic -- Clk from top\";\r\n\r\n    QTest::newRow(\"port declaration followed by another port\") <<\r\n        \"entity test is\\n\"\r\n        \"    port (\\n\"\r\n        \"        clk : in std_logic; -- Clk from top\\n\"\r\n        \"        enable : in std_logic\\n\"\r\n        \"   );\\n\"\r\n        \"end test;\"\r\n        << \"clk : in std_logic; -- Clk from top\";\r\n\r\n    QTest::newRow(\"port declaration with multiple ports\") <<\r\n        \"entity test is\\n\"\r\n        \"    port (\\n\"\r\n        \"        clk, enable : in std_logic -- One bit ports\\n\"\r\n        \"   );\\n\"\r\n        \"end test;\"\r\n        << \"clk, enable : in std_logic -- One bit ports\";\r\n\r\n    QTest::newRow(\"name type, direction and default value on separate lines\") << \r\n        \"entity test is\\n\"\r\n        \"port (clk\\n\"\r\n        \":\\n\"\r\n        \"in\\n\"\r\n        \"std_logic := '1' -- Clk from top.\\n\"\r\n        \");\\n\"\r\n        \"end test;\"\r\n        << \r\n        \"clk\\n\"\r\n        \":\\n\"\r\n        \"in\\n\"\r\n        \"std_logic := '1' -- Clk from top.\";\r\n\r\n    QTest::newRow(\"Double comment line\") << \r\n        \"entity test is\\n\"\r\n        \"    port ( \\n\"\r\n        \"        clk       : IN     std_logic;\\n\"\r\n        \"      --first comment.\\n\"\r\n        \"      --second comment.\\n\"\r\n        \"      -- third comment.\\n\"\r\n        \"        rst_n     : IN     std_logic\\n\"\r\n        \"    );\\n\"\r\n        \"end test;\"\r\n        << \r\n        \"clk       : IN     std_logic\";\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_VHDLimport::verifyNotHighlightedBeforeDeclaration()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_VHDLimport::verifyNotHighlightedBeforeDeclaration(int declarationStartIndex, QColor const& highlightColor)\r\n{\r\n    QTextCursor cursor = displayEditor_.textCursor();\r\n    cursor.setPosition(declarationStartIndex);\r\n\r\n    QVERIFY2(cursor.charFormat().background().color() != highlightColor, \r\n        \"Highlight for imported declaration should not begin before declaration.\");\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_VHDLimport::verifyDeclarationIsHighlighed()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_VHDLimport::verifyDeclarationIsHighlighted(const int declarationStartIndex, \r\n    const int declarationLength, QColor const& expectedHighlight) const\r\n{\r\n    QTextCursor cursor = displayEditor_.textCursor();\r\n\r\n    for (int i = 1; i <= declarationLength; i++)\r\n    {\r\n        cursor.setPosition(declarationStartIndex + i);\r\n        QVERIFY2(cursor.charFormat().background().color() == expectedHighlight,\r\n            \"Highlight is not applied to declaration.\");\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_VHDLimport::verifyNotHighlightedAfterDeclartion()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_VHDLimport::verifyNotHighlightedAfterDeclartion(const int declarationStartIndex, \r\n    const int declarationLength, QColor const& highlightColor) const\r\n{\r\n    QTextCursor cursor = displayEditor_.textCursor();\r\n\r\n    cursor.setPosition(declarationStartIndex + declarationLength + 1);\r\n    QVERIFY2(cursor.charFormat().background().color() != highlightColor,\r\n        \"Highlight for imported declaration should end after declaration.\");\r\n}\r\n\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_VHDLimport::testGenericIsHighlighted()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_VHDLimport::testGenericIsHighlighted()\r\n{\r\n    QFETCH(QString, fileContent);\r\n    QFETCH(int, declarationStartIndex);\r\n    QFETCH(int, declarationLength);\r\n\r\n    runParser(fileContent);\r\n\r\n    verifyNotHighlightedBeforeDeclaration(declarationStartIndex, ImportColors::MODELPARAMETER);\r\n    verifyDeclarationIsHighlighted(declarationStartIndex, declarationLength, ImportColors::MODELPARAMETER);\r\n    verifyNotHighlightedAfterDeclartion(declarationStartIndex, declarationLength, ImportColors::MODELPARAMETER);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_VHDLimport::testGenericIsHighlighted_data()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_VHDLimport::testGenericIsHighlighted_data()\r\n{\r\n    QTest::addColumn<QString>(\"fileContent\");\r\n    QTest::addColumn<int>(\"declarationStartIndex\");\r\n    QTest::addColumn<int>(\"declarationLength\");\r\n\r\n    QTest::newRow(\"simplest possible generic declaration\") <<\r\n        \"entity test is\\n\"\r\n        \"    generic (\\n\"\r\n        \"        freq : integer\\n\"\r\n        \"   );\"\r\n        \"end test;\"\r\n        << 37 << 14;\r\n\r\n    QTest::newRow(\"generic declaration with default value\") <<\r\n        \"entity test is\\n\"\r\n        \"    generic (\\n\"\r\n        \"        dataWidth_g : integer := 16);\"\r\n        \"end test;\"\r\n        << 37 << 27;\r\n\r\n    QTest::newRow(\"generic declaration with description\") <<\r\n        \"entity test is\\n\"\r\n        \"    generic (\\n\"\r\n        \"        outputFile : string := \\\"target.out\\\" -- Some file name\\n\"\r\n        \"   );\"\r\n        \"end test;\"\r\n        << 37 << 53;\r\n\r\n    QTest::newRow(\"generic declaration followed by another generic\") <<\r\n        \"entity test is\\n\"\r\n        \"    generic (\\n\"\r\n        \"        local_memory_start_addr : integer := 16#1000#;\\n\"\r\n        \"        local_memory_addr_bits  : integer := 12\\n\"\r\n        \"   );\\n\"\r\n        \"end test;\"\r\n        << 37 << 45;\r\n\r\n    QTest::newRow(\"generic declaration with multiple generic\") <<\r\n        \"entity test is\\n\"\r\n        \"    generic (\\n\"\r\n        \"        freq, dataWidth : integer --Configuration\\n\"\r\n        \"   );\\n\"\r\n        \"end test;\"\r\n        << 37 << 41;\r\n\r\n    QTest::newRow(\"name type and default value on separate lines\") << \r\n        \"entity test is\\n\"\r\n        \"generic (local_memory_start_addr\\n\" \r\n        \": integer \\n\"\r\n        \":= 16#1000#\\n\"\r\n        \")\\n\"\r\n        \";\\n\"\r\n        \"end test;\"\r\n        << 24 << 46;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_VHDLimport::testFontInsideEntityIsBlackAndOutsideEntityGray()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_VHDLimport::testFontInsideEntityIsBlack()\r\n{\r\n    QFETCH(QString, fileContent);\r\n    QFETCH(QString, entity);\r\n\r\n    runParser(fileContent);\r\n\r\n    int entityBegin = fileContent.indexOf(entity);\r\n    int entityEnd = fileContent.indexOf(entity) + entity.length();\r\n\r\n    verifySectionFontColorIs(entityBegin, entityEnd, QColor(\"black\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_VHDLimport::testFontInsideEntityIsBlackAndOutsideEntityGray_data()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_VHDLimport::testFontInsideEntityIsBlack_data()\r\n{\r\n    QTest::addColumn<QString>(\"fileContent\");\r\n    QTest::addColumn<QString>(\"entity\");\r\n\r\n    QTest::newRow(\"Library usage and empty entity\") <<\r\n        \"-- Comment on first line.\\n\"\r\n        \"library IEEE;\\n\"\r\n        \"ENTITY test IS\\n\"        \r\n        \"end test;\\n\"\r\n        \"begin rtl of test\\n\"\r\n        <<  \r\n        \"ENTITY test IS\\n\"        \r\n        \"end test;\\n\";\r\n\r\n    QTest::newRow(\"Windows newline\") <<\r\n        \"-- Comment.\\r\\n\"\r\n        \"entity test is\\r\\n\"\r\n        \"end test;\\r\\n\"\r\n        \"begin rtl of test\\r\\n\"\r\n        \"end rtl;\\r\\n\"\r\n        << \r\n        \"entity test is\\n\"\r\n        \"end test;\\n\";\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_VHDLimport::verifySectionFontColorIs()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_VHDLimport::verifySectionFontColorIs(int startIndex, int endIndex, QColor const& expectedFontColor)\r\n{\r\n    QTextCursor cursor = displayEditor_.textCursor();\r\n\r\n    int sectionLength = endIndex - startIndex;\r\n    for (int i = 0; i < sectionLength; i++)\r\n    {\r\n        cursor.setPosition(startIndex + i);\r\n        QVERIFY2(cursor.charFormat().foreground().color() == expectedFontColor,\r\n            \"Highlight is not applied to declaration.\");\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_VHDLimport::testModelParameterIsAssignedToPort()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_VHDLimport::testModelParameterIsAssignedToPort()\r\n{\r\n    QFETCH(QString, fileContent);\r\n    QFETCH(int, expectedParameterCount);\r\n    QFETCH(QString, expectedLeft);\r\n    QFETCH(QString, expectedRight);\r\n\r\n    runParser(fileContent);\r\n\r\n    QCOMPARE(importComponent_->getPorts()->count(), 1);\r\n    QSharedPointer<Port> createdPort = importComponent_->getPorts()->first();\r\n\r\n    QCOMPARE(importComponent_->getModel()->getComponentInstantiations()->count(), 1);\r\n    QCOMPARE(importComponent_->getModel()->getComponentInstantiations()->first()->getModuleParameters()->count(), \r\n        expectedParameterCount);\r\n    QCOMPARE(importComponent_->getParameters()->count(), expectedParameterCount);\r\n\r\n\r\n    unsigned int i = 1;\r\n    for (auto parameter : *importComponent_->getParameters())\r\n    {\r\n        QString pattern(\"$\" + QString::number(i));\r\n        expectedLeft.replace(pattern, parameter->getValueId());\r\n        expectedRight.replace(pattern, parameter->getValueId());\r\n        ++i;\r\n    }\r\n\r\n    QCOMPARE(createdPort->getLeftBound(), expectedLeft);\r\n    QCOMPARE(createdPort->getRightBound(), expectedRight);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_VHDLimport::testModelParameterIsAssignedToPort_data()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_VHDLimport::testModelParameterIsAssignedToPort_data()\r\n{\r\n    QTest::addColumn<QString>(\"fileContent\");\r\n    QTest::addColumn<int>(\"expectedParameterCount\");\r\n    QTest::addColumn<QString>(\"expectedLeft\");\r\n    QTest::addColumn<QString>(\"expectedRight\");\r\n\r\n    QTest::newRow(\"Parametrized port width.\") <<\r\n        \"entity test is\\n\"\r\n        \"   generic (\\n\"\r\n        \"       dataWidth_g : integer := 31\\n\"\r\n        \"   );\\n\"\r\n        \"   port (\\n\"\r\n        \"       data : out std_logic_vector(dataWidth_g downto 0)\\n\"\r\n        \"   );\\n\"\r\n        \"end test;\"\r\n        << 1 << \"$1\" << \"0\" ;\r\n\r\n    QTest::newRow(\"Parametrized port width with subtraction.\") <<\r\n        \"entity test is\\n\"\r\n        \"   generic (\\n\"\r\n        \"       dataWidth_g : integer := 16\\n\"\r\n        \"   );\\n\"\r\n        \"   port (\\n\"\r\n        \"       data : out std_logic_vector(dataWidth_g-1 downto 0)\\n\"\r\n        \"   );\\n\"\r\n        \"end test;\"\r\n        << 1 << \"$1-1\" << \"0\" ;\r\n\r\n    QTest::newRow(\"Parametrized port width with equation of generics.\") <<\r\n        \"entity test is\\n\"\r\n        \"   generic (\\n\"        \r\n        \"       addrWidth_g : integer := 8;\\n\"\r\n        \"       dataWidth_g : integer := 16\\n\"\r\n        \"   );\\n\"\r\n        \"   port (\\n\"\r\n        \"       data : out std_logic_vector(dataWidth_g+addrWidth_g-1 downto 0)\\n\"\r\n        \"   );\\n\"\r\n        \"end test;\"\r\n        << 2 << \"$2+$1-1\" << \"0\";\r\n\r\n    QTest::newRow(\"Parametrized port width with parentheses.\") <<\r\n        \"entity test is\\n\"\r\n        \"   generic (\\n\"\r\n        \"       addrWidth_g : integer := 8;\\n\"\r\n        \"       dataWidth_g : integer := 16\\n\"\r\n        \"   );\\n\"\r\n        \"   port (\\n\"\r\n        \"       data : out std_logic_vector((dataWidth_g/2)*addrWidth_g DOWNTO 0)\\n\"        \r\n        \"   );\\n\"\r\n        \"end test;\"\r\n        << 2 << \"($2/2)*$1\" << \"0\";\r\n\r\n    QTest::newRow(\"Parametrized port width with power of two.\") <<\r\n        \"entity test is\\n\"\r\n        \"   generic (\\n\"\r\n        \"       max_g : integer := 8\\n\"\r\n        \"   );\\n\"\r\n        \"   port (\\n\"\r\n        \"       data : out std_logic_vector(max_g**2-1 downto 0)\\n\"\r\n        \"   );\\n\"\r\n        \"end test;\"\r\n        << 1 << \"$1**2-1\" << \"0\" ;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_VHDLimport::testModelParameterAsPortBoundary()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_VHDLimport::testModelParameterAsPortBoundary()\r\n{\r\n    QString fileContent = \r\n        \"entity test is\\n\"\r\n        \"   generic (\\n\"        \r\n        \"       dataWidth_g : integer := 8\\n\"\r\n        \"   );\\n\"\r\n        \"   port (\\n\"\r\n        \"       data : out std_logic_vector(dataWidth_g-1 downto 0)\\n\"\r\n        \"   );\\n\"\r\n        \"end test;\";\r\n\r\n    runParser(fileContent);\r\n\r\n\tQSharedPointer<Port> createdPort = importComponent_->getPorts()->first();\r\n\r\n\tQSharedPointer<ComponentInstantiation> componentInstantiation = importComponent_->\r\n\t\tgetComponentInstantiations()->first();\r\n\tQSharedPointer<ModuleParameter> createdGeneric = componentInstantiation->getModuleParameters()->first();\r\n    QSharedPointer<Parameter> equivalentParameter = importComponent_->getParameters()->first();\r\n\r\n    QCOMPARE(createdGeneric->getValue(), equivalentParameter->getValueId());\r\n\tQCOMPARE(createdPort->getLeftBound(), QString(\"%1-1\").arg(equivalentParameter->getValueId()));\r\n\tQCOMPARE(createdPort->getRightBound(), QString(\"0\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_VHDLimport::testModelParameterIsAssignedToModelParameter()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_VHDLimport::testModelParameterIsAssignedToModelParameter()\r\n{\r\n    QString fileContent(\r\n        \"entity test is\\n\"\r\n        \"   generic (\\n\"\r\n        \"       width_g : integer := 8;\\n\"\r\n        \"       dataWidth_g : integer := width_g\\n\"        \r\n        \"   );\\n\"\r\n        \"end test;\");\r\n\r\n    runParser(fileContent);\r\n\r\n    QVERIFY2(!importComponent_->getComponentInstantiations()->isEmpty(), \"Did not create a component instantiation.\");\r\n\r\n    //! Check value reference chain dataWidth_g (MP) -> dataWidth_g (P) -> width_g (P).\r\n    QSharedPointer<ModuleParameter> createdGeneric = \r\n        importComponent_->getComponentInstantiations()->first()->getModuleParameters()->last();\r\n    QCOMPARE(createdGeneric->getValue(), importComponent_->getParameters()->last()->getValueId());\r\n    QCOMPARE(importComponent_->getParameters()->last()->getValue(), \r\n        importComponent_->getParameters()->first()->getValueId());\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_VHDLimport::testPortsAndModelParametersAreNotParsedOutsideEntity()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_VHDLimport::testPortsAndModelParametersAreNotParsedOutsideEntity()\r\n{\r\n    QString fileContent(\r\n        \"entity empty is\\n\"\r\n        \"end empty;\\n\"\r\n        \"\\n\"\r\n        \"architecture structural of empty is\\n\"\r\n        \"\\n\"\r\n        \"component dut\"\r\n        \"   generic (\\n\"        \r\n        \"       local_memory_addr_bits  : integer := 12\\n\"\r\n        \"   );\\n\"\r\n        \"   port (\\n\"\r\n        \"       clk : in std_logic\\n\"\r\n        \"   );\\n\"\r\n        \"end dut;\\n\"\r\n        \"\\n\"\r\n        \"end structural;\\n\");\r\n\r\n    runParser(fileContent);\r\n\r\n    QCOMPARE(importComponent_->getPorts()->count(), 0);\r\n    QCOMPARE(importComponent_->getComponentInstantiations()->first()->getModuleParameters()->count(), 0);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_VHDLimport::testParameterNotFoundInFileIsRemoved()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_VHDLimport::testParameterNotFoundInFileIsRemoved()\r\n{\r\n    QSharedPointer<ModuleParameter> existingParameter(new ModuleParameter());\r\n    existingParameter->setName(\"oldParameter\");\r\n\r\n\tQSharedPointer<ComponentInstantiation> importComponentInstantiation( new ComponentInstantiation );\r\n\timportComponentInstantiation->setName(NameGenerationPolicy::componentInstantiationName(\"vhdl\"));\r\n\timportComponentInstantiation->getModuleParameters()->append(existingParameter);\r\n\timportComponent_->getModel()->getComponentInstantiations()->append(importComponentInstantiation);\r\n\r\n    QString fileContent = \r\n        \"entity test is\\n\"\r\n        \"   generic (\\n\"        \r\n        \"       dataWidth_g : integer := 8\\n\"\r\n        \"   );\\n\"\r\n        \"end test;\";\r\n\r\n    runParser(fileContent);\r\n\r\n    QSharedPointer<ModuleParameter> importedParameter = importComponent_->getComponentInstantiations()\r\n\t\t->first()->getModuleParameters()->first();\r\n    QCOMPARE(importedParameter->name(), QString(\"dataWidth_g\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_VHDLimport::testExistingModelParameterIdDoesNotChange()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_VHDLimport::testExistingModelParameterIdDoesNotChange()\r\n{\r\n    QSharedPointer<ModuleParameter> existingParameter(new ModuleParameter());\r\n    existingParameter->setName(\"dataWidth_g\");\r\n    existingParameter->setValueId(\"existingId\");\r\n\r\n\tQSharedPointer<ComponentInstantiation> importComponentInstantiation( new ComponentInstantiation );\r\n\timportComponentInstantiation->setName(NameGenerationPolicy::componentInstantiationName(\"vhdl\"));\r\n\timportComponentInstantiation->getModuleParameters()->append(existingParameter);\r\n\timportComponent_->getModel()->getComponentInstantiations()->append(importComponentInstantiation);\r\n\r\n    QString fileContent = \r\n        \"entity test is\\n\"\r\n        \"   generic (\\n\"        \r\n        \"       dataWidth_g : integer := 8\\n\"\r\n        \"   );\\n\"\r\n        \"end test;\";\r\n\r\n    runParser(fileContent);\r\n\r\n\tQSharedPointer<ModuleParameter> importedParameter = importComponent_->getComponentInstantiations()\r\n\t\t->first()->getModuleParameters()->first();\r\n    QCOMPARE(importedParameter->getValueId(), QString(\"existingId\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_VHDLimport::testExistingPortIsSetAsPhantom()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_VHDLimport::testExistingPortIsSetAsPhantom()\r\n{\r\n    QSharedPointer<Port> existingPort(new Port(\"oldPort\"));\r\n    existingPort->setDirection(DirectionTypes::IN);\r\n    importComponent_->getPorts()->append(existingPort);\r\n\r\n    QString input =  \r\n        \"entity test is\\n\"\r\n        \"   port (\\n\"\r\n        \"       newPort : out std_logic\\n\"\r\n        \"   );\\n\"\r\n        \"end test;\\n\";\r\n\r\n    runParser(input);\r\n\r\n    QCOMPARE(importComponent_->getPorts()->count(), 2);\r\n    QSharedPointer<Port> importedPort = importComponent_->getPort(\"oldPort\");\r\n    QCOMPARE(importedPort->getDirection(), DirectionTypes::DIRECTION_PHANTOM);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_VHDLimport::testExistingPortIsOverriden()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_VHDLimport::testExistingPortIsOverriden()\r\n{\r\n    QSharedPointer<Port> existingPort(new Port(\"oldPort\"));\r\n    existingPort->setDirection(DirectionTypes::OUT);\r\n    existingPort->setTypeDefinition(\"std_logic\", \"IEEE.std_logic_1164.all\");\r\n    importComponent_->getPorts()->append(existingPort);\r\n\r\n    QString input =  \r\n        \"entity test is\\n\"\r\n        \"   port (\\n\"\r\n        \"       oldPort : in std_logic\\n\"\r\n        \"   );\\n\"\r\n        \"end test;\\n\";\r\n\r\n    runParser(input);\r\n\r\n    QCOMPARE(importComponent_->getPorts()->count(), 1);\r\n    QCOMPARE(importComponent_->getPort(\"oldPort\")->getDirection(), DirectionTypes::IN);\r\n    QCOMPARE(importComponent_->getPort(\"oldPort\")->getTypeDefinition(\"std_logic\"), QString(\"IEEE.std_logic_1164.all\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_VHDLimport::testModelNameAndEnvironmentIsImportedToView()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_VHDLimport::testModelNameAndEnvironmentIsImportedToView()\r\n{\r\n    QString fileContent(\r\n        \"entity testbench is\\n\"\r\n        \"end entity testbench;\\n\"\r\n        \"\\n\"\r\n        \"ARCHITECTURE structural OF testbench IS\\n\"\r\n        \"\\n\"\r\n        \"component dut\"\r\n        \"   port (\\n\"\r\n        \"       clk : in std_logic\\n\"\r\n        \"   );\\n\"\r\n        \"END dut;\\n\"\r\n        \"\\n\"\r\n        \"END ARCHITECTURE structural;\\n\");\r\n\r\n    runParser(fileContent);\r\n\r\n    QVERIFY2(importComponent_->hasView(\"flat_vhdl\"), \"No view 'flat' found in component.\");\r\n\r\n\r\n\tQSharedPointer<ComponentInstantiation> cimp = importComponent_->getComponentInstantiations()->first();\r\n\r\n    QCOMPARE(cimp->getModuleName(), QString(\"testbench\"));\r\n    QCOMPARE(cimp->getArchitectureName(), QString(\"structural\"));\r\n    QCOMPARE(cimp->getLanguage(), QString(\"VHDL\"));\r\n\tQCOMPARE(importComponent_->getViews()->first()->getEnvIdentifiers()->first()->language, QString(\"VHDL\"));\r\n\tQCOMPARE(importComponent_->getViews()->first()->getEnvIdentifiers()->first()->tool, QString(\"Kactus2\"));\r\n\r\n    QString architecture = \"ARCHITECTURE structural OF testbench\";\r\n    QString modelNameSection = \"structural OF testbench\";\r\n\r\n    verifySectionFontColorIs(fileContent.indexOf(architecture), architecture.length(), QColor(\"black\"));\r\n    verifyDeclarationIsHighlighted(fileContent.indexOf(modelNameSection), modelNameSection.length(), \r\n        ImportColors::VIEWNAME);    \r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_VHDLimport::testArchitecturePrecedesConfigurationForModelName()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_VHDLimport::testArchitecturePrecedesConfigurationForModelName()\r\n{\r\n    QString fileContent(\r\n        \"entity testbench is\\n\"\r\n        \"end testbench;\\n\"\r\n        \"\\n\"\r\n        \"ARCHITECTURE structural OF testbench IS\\n\"\r\n        \"\\n\"\r\n        \"component Dut\"\r\n        \"   port (\\n\"\r\n        \"       clk : in std_logic\\n\"\r\n        \"   );\\n\"\r\n        \"END Dut;\\n\"\r\n        \"\\n\"\r\n        \"END ARCHITECTURE structural;\\n\"\r\n        \"\\n\"\r\n        \"CONFIGURATION behavioral OF testbench is\\n\"\r\n        \"    FOR default_architecture\\n\"\r\n        \"         FOR ALL : Dut USE ENTITY WORK.half_adder(rtl)\\n\"\r\n        \"    END FOR;\"\r\n        \"end CONFIGURATION behavioral;\\n\");\r\n\r\n    runParser(fileContent);\r\n\r\n    QVERIFY2(importComponent_->hasView(\"flat_vhdl\"), \"No view 'flat' found in component.\");\r\n    QCOMPARE(importComponent_->getComponentInstantiations()->first()->getModuleName(), QString(\"testbench\"));\r\n    QCOMPARE(importComponent_->getComponentInstantiations()->first()->getArchitectureName(), QString(\"structural\"));\r\n\r\n    QString architecture = \"ARCHITECTURE structural OF testbench IS\";\r\n    QString modelNameSection = \"structural OF testbench\";\r\n\r\n    verifySectionFontColorIs(fileContent.indexOf(architecture), architecture.length(), QColor(\"black\"));\r\n    verifyDeclarationIsHighlighted(fileContent.indexOf(modelNameSection), modelNameSection.length(), \r\n        ImportColors::VIEWNAME);    \r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_VHDLimport::testConfigurationIsImportedToViewIfNoArchitectureAvailable()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_VHDLimport::testConfigurationIsImportedToViewIfNoArchitectureAvailable()\r\n{\r\n    QString fileContent(\r\n        \"entity testbench is\\n\"\r\n        \"end testbench;\\n\"\r\n        \"\\n\"\r\n        \"CONFIGURATION behavioral OF testbench is\\n\"\r\n        \"    FOR default_architecture\\n\"\r\n        \"         FOR ALL : Dut USE ENTITY WORK.half_adder(rtl)\\n\"\r\n        \"    END FOR;\"\r\n        \"end CONFIGURATION behavioral;\\n\");\r\n\r\n    runParser(fileContent);\r\n\r\n    QVERIFY2(importComponent_->hasView(\"flat_vhdl\"), \"No view 'flat' found in component.\");\r\n    QCOMPARE(importComponent_->getComponentInstantiations()->first()->getModuleName(), QString(\"behavioral\"));\r\n\r\n    QString configuration = \"CONFIGURATION behavioral OF testbench\";\r\n    QString modelNameSection = \"behavioral\";\r\n\r\n    verifySectionFontColorIs(fileContent.indexOf(configuration), configuration.length(), QColor(\"black\"));\r\n    verifyDeclarationIsHighlighted(fileContent.indexOf(modelNameSection), modelNameSection.length(), \r\n        ImportColors::VIEWNAME);    \r\n}\r\n\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_VHDLimport::testMultipleEntities()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_VHDLimport::testMultipleEntities()\r\n{\r\n    QFETCH(QString, fileContent);\r\n    QFETCH(int, entityNumber);\r\n    QFETCH(QString, entityName);\r\n\r\n    runParser(fileContent, entityNumber);\r\n\r\n    QCOMPARE(importComponent_->getComponentInstantiations()->size(), 1);\r\n\r\n    QSharedPointer<ComponentInstantiation> entityInstantiation =\r\n        importComponent_->getComponentInstantiations()->first();\r\n\r\n    QCOMPARE(entityInstantiation->getModuleName(), entityName);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_VHDLimport::testMultipleEntities_data()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_VHDLimport::testMultipleEntities_data()\r\n{\r\n    QTest::addColumn<QString>(\"fileContent\");\r\n    QTest::addColumn<int>(\"entityNumber\");\r\n    QTest::addColumn<QString>(\"entityName\");\r\n\r\n    QTest::newRow(\"select first entity\") <<\r\n        \"entity firstEntity is\\n\"\r\n        \"generic (\\n\"\r\n        \"   local_memory_addr_bits  : integer\\n\"\r\n        \");\\n\"\r\n        \"port (\\n\"\r\n        \"   clk: in std_logic\\n\"\r\n        \");\\n\"\r\n        \"end firstEntity;\\n\"\r\n        \"\\n\"\r\n        \"entity secondEntity is\\n\"\r\n        \"generic (\\n\"\r\n        \"   local_memory_addr_bits  : integer\\n\"\r\n        \");\\n\"\r\n        \"port (\\n\"\r\n        \"   clk: in std_logic\\n\"\r\n        \");\\n\"\r\n        \"end secondEntity;\\n\" <<\r\n        0 << \"firstEntity\";\r\n\r\n    QTest::newRow(\"select second entity\") <<\r\n        \"entity firstEntity is\\n\"\r\n        \"generic (\\n\"\r\n        \"   local_memory_addr_bits  : integer\\n\"\r\n        \");\\n\"\r\n        \"port (\\n\"\r\n        \"   clk: in std_logic\\n\"\r\n        \");\\n\"\r\n        \"end firstEntity;\\n\"\r\n        \"\\n\"\r\n        \"entity secondEntity is\\n\"\r\n        \"generic (\\n\"\r\n        \"   local_memory_addr_bits  : integer\\n\"\r\n        \");\\n\"\r\n        \"port (\\n\"\r\n        \"   clk: in std_logic\\n\"\r\n        \");\\n\"\r\n        \"end secondEntity;\\n\" <<\r\n        1 << \"secondEntity\";\r\n}\r\n\r\nQTEST_MAIN(tst_VHDLimport)\r\n\r\n#include \"tst_VHDLimport.moc\"\r\n"
  },
  {
    "path": "tests/Plugins/VHDLimport/tst_VHDLimport.pri",
    "content": "# ----------------------------------------------------\r\n# This file is generated by the Qt Visual Studio Tools.\r\n# ------------------------------------------------------\r\n\r\n# This is a reminder that you are using a generated .pro file.\r\n# Remove it when you are finished editing this file.\r\nmessage(\"You are running qmake on a generated .pro file. This may not work!\")\r\n\r\n\r\nHEADERS += ../../../KactusAPI/include/ImportHighlighter.h \\\r\n    ../../../common/NameGenerationPolicy.h \\\r\n    ../../../Plugins/VHDLimport/VHDLSyntax.h \\\r\n    ../../../Plugins/VHDLimport/vhdlimport_global.h \\\r\n    ../../../Plugins/VHDLimport/VHDLGenericParser.h \\\r\n    ../../../Plugins/VHDLimport/VHDLPortParser.h \\\r\n    ../../../Plugins/VHDLimport/VHDLimport.h\r\nSOURCES += ../../../KactusAPI/plugins/ImportHighlighter.cpp \\\r\n    ../../../common/NameGenerationPolicy.cpp \\\r\n    ../../../Plugins/VHDLimport/VHDLGenericParser.cpp \\\r\n    ../../../Plugins/VHDLimport/VHDLPortParser.cpp \\\r\n    ../../../Plugins/VHDLimport/VHDLimport.cpp \\\r\n    ./tst_VHDLimport.cpp\r\n"
  },
  {
    "path": "tests/Plugins/VHDLimport/tst_VHDLimport.pro",
    "content": "#-----------------------------------------------------------------------------\r\n# File: tst_VHDLimport.pro\r\n#-----------------------------------------------------------------------------\r\n# Project: Kactus 2\r\n# Author: Esko Pekkarinen\r\n# Date: 05.09.2014\r\n#\r\n# Description:\r\n# Qt project file template for running unit tests for VHDLimport.\r\n#-----------------------------------------------------------------------------\r\n\r\nTEMPLATE = app\r\n\r\nTARGET = tst_VHDLimport\r\n\r\nQT += core xml gui widgets testlib\r\nCONFIG += c++11 testcase\r\n\r\nDEFINES += VHDLIMPORT_LIB\r\n\r\nQMAKE_EXPORTED_VARIABLES += MAKE_TESTARGS\r\nMAKE_TESTARGS.name = TESTARGS\r\nMAKE_TESTARGS.value = \"-platform offscreen\"\r\n\r\nwin32:CONFIG(release, debug|release) {\r\n    LIBS += -L$$PWD/../../../executable/ -lIPXACTmodels\r\n    LIBS += -L$$PWD/../../../executable/ -lKactusAPI\r\n    DESTDIR = ./release\r\n}\r\nelse:win32:CONFIG(debug, debug|release) {\r\n    LIBS += -L$$PWD/../../../executable/ -lIPXACTmodelsd\r\n    LIBS += -L$$PWD/../../../executable/ -lKactusAPId\r\n    DESTDIR = ./debug\r\n}\r\nelse:unix {\r\n    LIBS += -L$$PWD/../../../executable/ -lIPXACTmodels\r\n    LIBS += -L$$PWD/../../../executable/ -lKactusAPI\r\n    DESTDIR = ./release\r\n}\r\n\r\nINCLUDEPATH += $$DESTDIR\r\nINCLUDEPATH += ../../../\r\nINCLUDEPATH += $$PWD/../../../KactusAPI/include\r\n\r\nDEPENDPATH += .\r\nDEPENDPATH += ../../../\r\n\r\nOBJECTS_DIR += $$DESTDIR\r\n\r\nMOC_DIR += ./generatedFiles\r\nUI_DIR += ./generatedFiles\r\nRCC_DIR += ./generatedFiles\r\ninclude(tst_VHDLimport.pri)\r\n"
  },
  {
    "path": "tests/Plugins/VerilogGenerator/VerilogGenerator.pro",
    "content": "#-----------------------------------------------------------------------------\r\n# File: VerilogGenerator.pro\r\n#-----------------------------------------------------------------------------\r\n# Project: Kactus2\r\n# Author: Esko Pekkarinen\r\n# Date: 28.07.2014\r\n#\r\n# Description:\r\n# Qt project file for running unit tests for Verilog generation.\r\n#-----------------------------------------------------------------------------\r\n\r\nTEMPLATE = subdirs\r\n\r\nCONFIG += testcase\r\nSUBDIRS += tst_VerilogWriterFactory.pro \\\r\n          tst_VerilogHeaderWriter.pro \\\r\n          tst_InterfaceDirectionNameSorter.pro \\\r\n          tst_CommentWriter.pro \\\r\n          tst_ImplementationSelection.pro\r\n"
  },
  {
    "path": "tests/Plugins/VerilogGenerator/tst_CommentWriter.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: tst_CommentWriter.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Esko Pekkarinen\r\n// Date: 08.08.2014\r\n//\r\n// Description:\r\n// Unit test for class CommentWriter.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include <QtTest>\r\n\r\n#include <Plugins/VerilogGenerator/CommentWriter/CommentWriter.h>\r\n\r\nclass tst_CommentWriter : public QObject\r\n{\r\n    Q_OBJECT\r\n\r\npublic:\r\n    tst_CommentWriter();\r\n\r\nprivate slots:\r\n    void testWritesNothing();\r\n    void testWritesOneLineComment();\r\n    void testWritesMultilineComment();\r\n    void testSplitsLines();\r\n    void testSplitsLines_data();\r\n    void testEmptyLines();\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_CommentWriter::tst_CommentWriter()\r\n//-----------------------------------------------------------------------------\r\ntst_CommentWriter::tst_CommentWriter()\r\n{\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_CommentWriter::testWritesNothing()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_CommentWriter::testWritesNothing()\r\n{\r\n    CommentWriter writer(\"\");\r\n\r\n    QString output;\r\n    QTextStream outputStream(&output);\r\n\r\n    writer.write(outputStream);\r\n\r\n    QVERIFY(output.isEmpty());\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_CommentWriter::testWritesOneLineComment()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_CommentWriter::testWritesOneLineComment()\r\n{\r\n    CommentWriter writer(\"One line comment.\");\r\n\r\n    QString output;\r\n    QTextStream outputStream(&output);\r\n\r\n    writer.write(outputStream);\r\n\r\n    QCOMPARE(output, QString(\"// One line comment.\\n\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_CommentWriter::testWritesMultilineComment()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_CommentWriter::testWritesMultilineComment()\r\n{\r\n    CommentWriter writer(\"Multi\\nline\\ncomment.\");\r\n\r\n    QString output;\r\n    QTextStream outputStream(&output);\r\n\r\n    writer.write(outputStream);\r\n\r\n    QCOMPARE(output, QString(\"// Multi\\n\"\r\n        \"// line\\n\"\r\n        \"// comment.\\n\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_CommentWriter::testSplitsLines()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_CommentWriter::testSplitsLines()\r\n{\r\n    QFETCH(int, lineLength);\r\n    QFETCH(QString, comment);\r\n    QFETCH(QString, expectedOutput);\r\n\r\n    CommentWriter writer(comment);\r\n    writer.setLineLength(lineLength);\r\n\r\n    QString output;\r\n    QTextStream outputStream(&output);\r\n\r\n    writer.write(outputStream);\r\n\r\n    QCOMPARE(output, expectedOutput);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_CommentWriter::testSplitsLines_data()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_CommentWriter::testSplitsLines_data()\r\n{\r\n    QTest::addColumn<int>(\"lineLength\");\r\n    QTest::addColumn<QString>(\"comment\");\r\n    QTest::addColumn<QString>(\"expectedOutput\");\r\n\r\n    QTest::newRow(\"Short comment on one line\") << 100 << \"A comment.\" << \"// A comment.\\n\";\r\n    QTest::newRow(\"Two lines\") << 5 << \"Split here.\" << \"// Split\\n// here.\\n\";\r\n    QTest::newRow(\"Word on a single line\") << 1 << \"Unsplittable.\" << \"// Unsplittable.\\n\";\r\n    QTest::newRow(\"Every word on own line\") << 1 << \"One two three four.\" << \"// One\\n// two\\n// three\\n// four.\\n\";\r\n    QTest::newRow(\"Two words per line\") << 10 << \"First two, other two.\" << \"// First two,\\n// other two.\\n\";\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_CommentWriter::testEmptyLines()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_CommentWriter::testEmptyLines()\r\n{\r\n    CommentWriter writer(\"First paragraph.\\n\\nSecond paragraph.\");\r\n\r\n    QString output;\r\n    QTextStream outputStream(&output);\r\n\r\n    writer.write(outputStream);\r\n\r\n    QCOMPARE(output, QString(\"// First paragraph.\\n\"\r\n        \"// \\n\"\r\n        \"// Second paragraph.\\n\"));\r\n}\r\n\r\nQTEST_APPLESS_MAIN(tst_CommentWriter)\r\n\r\n#include \"tst_CommentWriter.moc\"\r\n"
  },
  {
    "path": "tests/Plugins/VerilogGenerator/tst_CommentWriter.pri",
    "content": "# ----------------------------------------------------\r\n# This file is generated by the Qt Visual Studio Add-in.\r\n# ------------------------------------------------------\r\n\r\nHEADERS += ../../../Plugins/VerilogGenerator/CommentWriter/CommentWriter.h \\\r\n\t../../../Plugins/VerilogGenerator/common/Writer.h\r\nSOURCES += ./tst_CommentWriter.cpp \\\r\n\t../../../Plugins/VerilogGenerator/CommentWriter/CommentWriter.cpp\r\n"
  },
  {
    "path": "tests/Plugins/VerilogGenerator/tst_CommentWriter.pro",
    "content": "#-----------------------------------------------------------------------------\r\n# File: tst_CommentWriter.pro\r\n#-----------------------------------------------------------------------------\r\n# Project: Kactus 2\r\n# Author: Esko Pekkarinen\r\n# Date: 08.08.2014\r\n#\r\n# Description:\r\n# Qt project file template for running unit tests for class CommentWriter.\r\n#-----------------------------------------------------------------------------\r\n\r\nTEMPLATE = app\r\n\r\nTARGET = tst_CommentWriter\r\n\r\nQT += core xml gui testlib\r\nCONFIG += c++11 testcase console\r\n\r\nDEFINES += VERILOGGENERATORPLUGIN_LIB\r\n\r\nwin32:CONFIG(release, debug|release) {\r\n    LIBS += -L$$PWD/../../../executable/ -lIPXACTmodels\r\n    DESTDIR = ./release\r\n}\r\nelse:win32:CONFIG(debug, debug|release) {\r\n    LIBS += -L$$PWD/../../../executable/ -lIPXACTmodelsd\r\n    DESTDIR = ./debug\r\n}\r\nelse:unix {\r\n    LIBS += -L$$PWD/../../../executable/ -lIPXACTmodels\r\n    DESTDIR = ./release\r\n}\r\n\r\nINCLUDEPATH += $$PWD/../../../\r\nINCLUDEPATH += $$DESTDIR\r\n\r\nDEPENDPATH += $$PWD/../../../\r\nDEPENDPATH += .\r\n\r\nOBJECTS_DIR += $$DESTDIR\r\n\r\nMOC_DIR += ./generatedFiles\r\nUI_DIR += ./generatedFiles\r\nRCC_DIR += ./generatedFiles\r\ninclude(tst_CommentWriter.pri)\r\n"
  },
  {
    "path": "tests/Plugins/VerilogGenerator/tst_ImplementationSelection.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: tst_ImplementationSelection.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Janne Virtanen\n// Date: 19.01.2017\n//\n// Description:\n// Unit test for Verilog implementation selection.\n//-----------------------------------------------------------------------------\n\n#include <QtTest>\n\n#include <tests/MockObjects/LibraryMock.h>\n\n#include <Plugins/VerilogImport/VerilogSyntax.h>\n\nclass tst_ImplementationSelection : public QObject\n{\n    Q_OBJECT\n\npublic:\n    tst_ImplementationSelection();\n\nprivate slots:\n    void initTestCase();\n    void cleanupTestCase();\n    void init();\n    void cleanup();\n\n    // Test cases:\n\n\tvoid testImplementationSelection();\n    void testImplementationSelectionWithEvilComments();\n\tvoid testImplementationSelectionWithTag();\n\tvoid testImplementationSelectionWithoutParameters();\n\tvoid testImplementationSelectionWithoutPorts();\n\tvoid testImplementationSelectionWithInstantiation();\n\tvoid testImplementationSelectionWithPostModule();\n\tvoid testImplementationSelectionWithTooManyModules();\n\tvoid testImplementationSelectionWithNoModuleHeaderStart();\n\tvoid testImplementationSelectionWithNoModuleHeaderEnd();\n\tvoid testImplementationSelectionWithNoModuleEnd();\n\nprivate:\n\n    // The ouputs from implementation selection.\n    QString implementation;\n    QString postModule;\n    QString error;\n\n    //! The test mock for library interface.\n    LibraryMock library_;\n};\n\n//-----------------------------------------------------------------------------\n// Function: tst_ImplementationSelection::tst_ImplementationSelection()\n//-----------------------------------------------------------------------------\ntst_ImplementationSelection::tst_ImplementationSelection(): library_(this)\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_ImplementationSelection::initTestCase()\n//-----------------------------------------------------------------------------\nvoid tst_ImplementationSelection::initTestCase()\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_ImplementationSelection::cleanupTestCase()\n//-----------------------------------------------------------------------------\nvoid tst_ImplementationSelection::cleanupTestCase()\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_ImplementationSelection::init()\n//-----------------------------------------------------------------------------\nvoid tst_ImplementationSelection::init()\n{\n    library_.clear();\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_ImplementationSelection::cleanup()\n//-----------------------------------------------------------------------------\nvoid tst_ImplementationSelection::cleanup()\n{\n    QFile::remove(\"./generatorOutput.v\");\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_ImplementationSelection::testImplementationSelection()\n//-----------------------------------------------------------------------------\nvoid tst_ImplementationSelection::testImplementationSelection()\n{\n\tQString content = QString(\n\t\t\"module TestComponent #(\\n\"\n\t\t\"    parameter                              dataWidth        = 8,\\n\"\n\t\t\"    parameter                              freq             = 100000\\n\"\n\t\t\") (\\n\"\n\t\t\"    // These ports are not in any interface\\n\"         \n\t\t\"    input                               clk,\\n\"\n\t\t\"    input          [7:0]                dataIn,\\n\"\n\t\t\"    input                               rst_n,\\n\"\n\t\t\"    output         [7:0]                dataOut\\n\"\n\t\t\");\\n\"\n\t\t\"foo\\n\"\n\t\t\"bar\\n\"\n\t\t\"endmodule\\n\"\n\t\t); \n\n\t\n\n\n\tVerilogSyntax::selectImplementation(content, implementation, postModule, error);\n\n\timplementation = implementation.trimmed();\n\n\tQCOMPARE(implementation,QString(\"foo\\nbar\"));\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_ImplementationSelection::testImplementationSelectionWithEvilComments()\n//-----------------------------------------------------------------------------\nvoid tst_ImplementationSelection::testImplementationSelectionWithEvilComments()\n{\n    QString content = QString(\n        \"module TestComponent #(\\n\"\n        \"    parameter                              dataWidth        = 8, // module ending );\\n\"\n        \"    parameter                              freq             = 100000 /* ending module header );\\n\"\n        \") (\\n\"\n        \"    // These ports are not in any interface\\n\"         \n        \"    input                               clk,\\n\"\n        \"    input          [7:0]                dataIn,\\n\"\n        \"    input                               rst_n,\\n\"\n        \"    output         [7:0]                dataOut\\n\"\n        \");\\n\"\n        \"foo\\n\"\n        \"bar\\n\"\n        \"endmodule\\n\"\n        ); \n\n    VerilogSyntax::selectImplementation(content, implementation, postModule, error);\n    implementation = implementation.trimmed();\n\n    QCOMPARE(implementation,QString(\"foo\\nbar\"));\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_ImplementationSelection::testImplementationSelectionWithTag()\n//-----------------------------------------------------------------------------\nvoid tst_ImplementationSelection::testImplementationSelectionWithTag()\n{\n\tQString content = QString(\n\t\t\"module TestComponent #(\\n\"\n\t\t\"    parameter                              dataWidth        = 8,\\n\"\n\t\t\"    parameter                              freq             = 100000\\n\"\n\t\t\") (\\n\"\n\t\t\"    // These ports are not in any interface\\n\"         \n\t\t\"    input                               clk,\\n\"\n\t\t\"    input          [7:0]                dataIn,\\n\"\n\t\t\"    input                               rst_n,\\n\"\n\t\t\"    output         [7:0]                dataOut\\n\"\n\t\t\");\\n\" \n\t\t\"// \" + VerilogSyntax::TAG_OVERRIDE + \"\\n\"\n\t\t\"foo\\n\"\n\t\t\"bar\\n\"\n\t\t\"endmodule\\n\"\n\t\t); \n\n    VerilogSyntax::selectImplementation(content, implementation, postModule, error);\n\n\timplementation = implementation.trimmed();\n\n\tQCOMPARE(implementation,QString(\"foo\\nbar\"));\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_ImplementationSelection::testImplementationSelectionWithoutParameters()\n//-----------------------------------------------------------------------------\nvoid tst_ImplementationSelection::testImplementationSelectionWithoutParameters()\n{\n\tQString content = QString(\n\t\t\"module TestComponent(\\n\"\n\t\t\"    // These ports are not in any interface\\n\"         \n\t\t\"    input                               clk,\\n\"\n\t\t\"    input          [7:0]                dataIn,\\n\"\n\t\t\"    input                               rst_n,\\n\"\n\t\t\"    output         [7:0]                dataOut\\n\"\n\t\t\");\\n\"\n\t\t\"dataOut <= rst_n & clk\\n\"\n\t\t\"bar\\n\"\n\t\t\"baz\\n\"\n\t\t\"endmodule\\n\"\n\t\t); \n\n    VerilogSyntax::selectImplementation(content, implementation, postModule, error);\n\n\timplementation = implementation.trimmed();\n\n\tQCOMPARE(implementation,QString(\"dataOut <= rst_n & clk\\nbar\\nbaz\"));\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_ImplementationSelection::testImplementationSelectionWithoutPorts()\n//-----------------------------------------------------------------------------\nvoid tst_ImplementationSelection::testImplementationSelectionWithoutPorts()\n{\n\tQString content = QString(\n\t\t\"module TestComponent();\\n\"\n\t\t\"dataOut <= rst_n & clk\\n\"\n\t\t\"endmodule\\n\"\n\t\t); \n\n    VerilogSyntax::selectImplementation(content, implementation, postModule, error);\n\timplementation = implementation.trimmed();\n\n\tQCOMPARE(implementation,QString(\"dataOut <= rst_n & clk\"));\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_ImplementationSelection::testImplementationSelectionWithInstantiation()\n//-----------------------------------------------------------------------------\nvoid tst_ImplementationSelection::testImplementationSelectionWithInstantiation()\n{\n\tQString content = QString(\n\t\t\"module TestComponent #(\\n\"\n\t\t\"    parameter                              dataWidth        = 8,\\n\"\n\t\t\"    parameter                              freq             = 100000\\n\"\n\t\t\") (\\n\"\n\t\t\"    // These ports are not in any interface\\n\"         \n\t\t\"    input                               clk,\\n\"\n\t\t\"    input          [7:0]                dataIn,\\n\"\n\t\t\"    input                               rst_n,\\n\"\n\t\t\"    output         [7:0]                dataOut\\n\"\n\t\t\");\\n\");\n\n\tQString expectedImplementation = QString(\n\t\t\"foo\\n\"\n\t\t\"bar\\n\"\n\t\t\"\\n\"\n\t\t\"// IP-XACT VLNV: tut.fi:ip.hw:TestIntitializer:1.0\\n\"\n\t\t\"TestIntitializer #(\\n\"\n\t\t\".WAIT_TIME           (2100))\\n\"\n\t\t\"TestIntitializer_0(\\n\"\n\t\t\"// These ports are not in any interface\\n\"\n\t\t\".done                (SampleHW_0_done_to_TestIntitializer_0_done),\\n\"\n\t\t\".clk                 (TestIntitializer_0_clk_to_SampleHW_0_clk),\\n\"\n\t\t\".rst                 (SampleHW_0_rst_to_TestIntitializer_0_rst),\\n\"\n\t\t\".start\\n\"\n\t\t\");\");\n\n\tQString actualImplementation;\n\n\tVerilogSyntax::selectImplementation(content + expectedImplementation + \"endmodule\",\n        actualImplementation, postModule, error);\n\n\tactualImplementation = actualImplementation.trimmed();\n\n\tQCOMPARE(actualImplementation,expectedImplementation);\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_ImplementationSelection::testImplementationSelectionWithPostModule()\n//-----------------------------------------------------------------------------\nvoid tst_ImplementationSelection::testImplementationSelectionWithPostModule()\n{\n\tQString content = QString(\n\t\t\"module TestComponent #(\\n\"\n\t\t\"    parameter                              dataWidth        = 8,\\n\"\n\t\t\"    parameter                              freq             = 100000\\n\"\n\t\t\") (\\n\"\n\t\t\"    // These ports are not in any interface\\n\"         \n\t\t\"    input                               clk,\\n\"\n\t\t\"    input          [7:0]                dataIn,\\n\"\n\t\t\"    input                               rst_n,\\n\"\n\t\t\"    output         [7:0]                dataOut\\n\"\n\t\t\");\\n\"\n\t\t\"foo\\n\"\n\t\t\"bar\\n\"\n\t\t\"endmodule\"\n\t\t); \n\n\tQString expectedPostModule = QString(\n\t\t\"lrem ipsum\\n\"\n\t\t\"    parameter                              bbb        = 64,\\n\"\n\t\t\"    parameter                              two        = bbb * 2 \\n\"\n\t\t\"// Bogus copy paste stuff\\n\"\n\t\t\"foo\\n\"\n\t\t\"bar\"\n\t\t); \n\n    QString actualPostModule;\n\n\tVerilogSyntax::selectImplementation(content + \"\\n\" + expectedPostModule,\n        implementation, actualPostModule, error);\n\n\timplementation = implementation.trimmed();\n\tactualPostModule = actualPostModule.trimmed();\n\n\tQCOMPARE(implementation,QString(\"foo\\nbar\"));\n\tQCOMPARE(actualPostModule,expectedPostModule);\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_ImplementationSelection::testImplementationSelectionWithTooManyModules()\n//-----------------------------------------------------------------------------\nvoid tst_ImplementationSelection::testImplementationSelectionWithTooManyModules()\n{\n\tQString content = QString(\n\t\t\"module TestComponent #(\\n\"\n\t\t\"    parameter                              dataWidth        = 8,\\n\"\n\t\t\"    parameter                              freq             = 100000\\n\"\n\t\t\") (\\n\"\n\t\t\"    // These ports are not in any interface\\n\"         \n\t\t\"    input                               clk,\\n\"\n\t\t\"    input          [7:0]                dataIn,\\n\"\n\t\t\"    input                               rst_n,\\n\"\n\t\t\"    output         [7:0]                dataOut\\n\"\n\t\t\");\\n\"\n\t\t\"foo\\n\"\n\t\t\"bar\\n\"\n\t\t\"endmodule\"\n\t\t); \n\n\tQString extraModule = QString(\n\t\t\"module MasterComponent #(\\n\"\n\t\t\"    parameter                              bbb        = 64,\\n\"\n\t\t\"    parameter                              two        = bbb * 2 \\n\"\n\t\t\") (\\n\"        \n\t\t\"    input          [7:0]                iii,\\n\"\n\t\t\"    output         [7:0]                aaa\\n\"\n\t\t\");\\n\"\n\t\t\"foo\\n\"\n\t\t\"bar\\n\"\n\t\t\"endmodule\"\n\t\t); \n\n    bool success = VerilogSyntax::selectImplementation(content + \"\\n\" + extraModule,\n        implementation, postModule, error);\n\n\tQVERIFY(!success);\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_ImplementationSelection::testImplementationSelectionWithNoModuleHeaderStart()\n//-----------------------------------------------------------------------------\nvoid tst_ImplementationSelection::testImplementationSelectionWithNoModuleHeaderStart()\n{\n\tQString content = QString(\n\t\t\"TestComponent #(\\n\"\n\t\t\"    parameter                              dataWidth        = 8,\\n\"\n\t\t\"    parameter                              freq             = 100000\\n\"\n\t\t\") (\\n\"\n\t\t\"    // These ports are not in any interface\\n\"         \n\t\t\"    input                               clk,\\n\"\n\t\t\"    input          [7:0]                dataIn,\\n\"\n\t\t\"    input                               rst_n,\\n\"\n\t\t\"    output         [7:0]                dataOut\\n\"\n\t\t\");\\n\"\n\t\t\"foo\\n\"\n\t\t\"bar\\n\"\n\t\t\"endmodule\\n\"\n\t\t); \n\n    bool success = VerilogSyntax::selectImplementation(content, implementation, postModule, error);\n\n\tQVERIFY(!success);\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_ImplementationSelection::testImplementationSelectionWithNoModuleHeaderEnd()\n//-----------------------------------------------------------------------------\nvoid tst_ImplementationSelection::testImplementationSelectionWithNoModuleHeaderEnd()\n{\n\tQString content = QString(\n\t\t\"module TestComponent #(\\n\"\n\t\t\"    parameter                              dataWidth        = 8,\\n\"\n\t\t\"    parameter                              freq             = 100000\\n\"\n\t\t\") (\\n\"\n\t\t\"    // These ports are not in any interface\\n\"         \n\t\t\"    input                               clk,\\n\"\n\t\t\"    input          [7:0]                dataIn,\\n\"\n\t\t\"    input                               rst_n,\\n\"\n\t\t\"    output         [7:0]                dataOut\\n\"\n\t\t\"\\n\"\n\t\t\"foo\\n\"\n\t\t\"bar\\n\"\n\t\t\"endmodule\\n\"\n\t\t); \n\t\n    bool success =  VerilogSyntax::selectImplementation(content, implementation, postModule, error);\n\n\tQVERIFY(!success);\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_ImplementationSelection::testImplementationSelectionWithNoModuleEnd()\n//-----------------------------------------------------------------------------\nvoid tst_ImplementationSelection::testImplementationSelectionWithNoModuleEnd()\n{\n\tQString content = QString(\n\t\t\"module TestComponent #(\\n\"\n\t\t\"    parameter                              dataWidth        = 8,\\n\"\n\t\t\"    parameter                              freq             = 100000\\n\"\n\t\t\") (\\n\"\n\t\t\"    // These ports are not in any interface\\n\"         \n\t\t\"    input                               clk,\\n\"\n\t\t\"    input          [7:0]                dataIn,\\n\"\n\t\t\"    input                               rst_n,\\n\"\n\t\t\"    output         [7:0]                dataOut\\n\"\n\t\t\");\\n\"\n\t\t\"\\n\"\n\t\t\"foo\\n\"\n\t\t\"bar\\n\"\n\t\t); \n\n    bool success = VerilogSyntax::selectImplementation(content, implementation, postModule, error);\n\n\tQVERIFY(!success);\n}\n\nQTEST_APPLESS_MAIN(tst_ImplementationSelection)\n\n#include \"tst_ImplementationSelection.moc\"\n"
  },
  {
    "path": "tests/Plugins/VerilogGenerator/tst_ImplementationSelection.pri",
    "content": "# ----------------------------------------------------\n# This file is generated by the Qt Visual Studio Add-in.\n# ------------------------------------------------------\n\nHEADERS += ../../../Plugins/VerilogImport/VerilogSyntax.h \\\n    ../../MockObjects/LibraryMock.h\nSOURCES += ../../MockObjects/LibraryMock.cpp \\\n    ../../../Plugins/VerilogImport/VerilogSyntax.cpp \\\n    ./tst_ImplementationSelection.cpp\n"
  },
  {
    "path": "tests/Plugins/VerilogGenerator/tst_ImplementationSelection.pro",
    "content": "#-----------------------------------------------------------------------------\n# File: tst_ImplementationSelection.pro\n#-----------------------------------------------------------------------------\n# Project: Kactus2\n# Author: Janne Virtanen\n# Date: 19.01.2017\n#\n# Description:\n# Qt project file for running unit tests for Verilog implementation selection.\n#-----------------------------------------------------------------------------\n\nTEMPLATE = app\n\nTARGET = tst_ImplementationSelection\n\nQT += core xml gui testlib\nCONFIG += c++11 testcase console\n\nwin32:CONFIG(release, debug|release) {\n    LIBS += -L$$PWD/../../../executable/ -lIPXACTmodels\n    DESTDIR = ./release\n}\nelse:win32:CONFIG(debug, debug|release) {\n    LIBS += -L$$PWD/../../../executable/ -lIPXACTmodelsd\n    DESTDIR = ./debug\n}\nelse:unix {\n    LIBS += -L$$PWD/../../../executable/ -lIPXACTmodels\n    DESTDIR = ./release\n}\n\nINCLUDEPATH += $$PWD/../../../\nINCLUDEPATH += $$PWD/../../../executable\nINCLUDEPATH += $$PWD/../../../executable/Plugins\nINCLUDEPATH += $$DESTDIR\n\nDEPENDPATH += $$PWD/../../../\nDEPENDPATH += $$PWD/../../../executable\nDEPENDPATH += $$PWD/../../../executable/Plugins\nDEPENDPATH += .\n\nOBJECTS_DIR += $$DESTDIR\n\nMOC_DIR += ./generatedFiles\nUI_DIR += ./generatedFiles\nRCC_DIR += ./generatedFiles\ninclude(tst_ImplementationSelection.pri)\n"
  },
  {
    "path": "tests/Plugins/VerilogGenerator/tst_InterfaceDirectionNameSorter.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: tst_InterfaceDirectionNameSorter.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Esko Pekkarinen\r\n// Date: 05.08.2014\r\n//\r\n// Description:\r\n// Unit test for class InterfaceDirectionNameSorter.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include <QtTest>\r\n\r\n#include <Plugins/common/PortSorter/InterfaceDirectionNameSorter.h>\r\n\r\n#include <IPXACTmodels/Component/Component.h>\r\n#include <IPXACTmodels/Component/BusInterface.h>\r\n#include <IPXACTmodels/Component/Port.h>\r\n#include <IPXACTmodels/Component/PortMap.h>\r\n\r\nclass tst_InterfaceDirectionNameSorter : public QObject\r\n{\r\n    Q_OBJECT\r\n\r\npublic:\r\n    tst_InterfaceDirectionNameSorter();\r\n\r\nprivate slots:\r\n    void init();\r\n    void cleanup();\r\n    void testNullComponent();\r\n    void testComponentWithNoPorts();\r\n    void testPortsOrderedByName();\r\n    void testPortsOrderedByDirectionThenName();\r\n    void testPortsOrderedByInterfaceThenDirection();\r\n\r\nprivate:    \r\n    void addPort(QString portName, DirectionTypes::Direction direction = DirectionTypes::IN);\r\n    void addInterface( QString const& interfaceName );\r\n    void mapPortToInterface( QString const& portName, QString const& interfaceName );\r\n   \r\n    QSharedPointer<Component> component_;\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_InterfaceDirectionNameSorter::tst_InterfaceDirectionNameSorter()\r\n//-----------------------------------------------------------------------------\r\ntst_InterfaceDirectionNameSorter::tst_InterfaceDirectionNameSorter()\r\n{\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_InterfaceDirectionNameSorter::init()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_InterfaceDirectionNameSorter::init()\r\n{\r\n    component_ = QSharedPointer<Component>(new Component(VLNV(), Document::Revision::Std14));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_InterfaceDirectionNameSorter::cleanup()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_InterfaceDirectionNameSorter::cleanup()\r\n{\r\n    component_.clear();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_InterfaceDirectionNameSorter::testNullComponent()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_InterfaceDirectionNameSorter::testNullComponent()\r\n{\r\n   InterfaceDirectionNameSorter sorter;\r\n\r\n   QStringList sorted = sorter.sortedPortNames(QSharedPointer<Component>(0));\r\n\r\n   QVERIFY(sorted.isEmpty());\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_InterfaceDirectionNameSorter::testComponentWithNoPorts()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_InterfaceDirectionNameSorter::testComponentWithNoPorts()\r\n{\r\n    InterfaceDirectionNameSorter sorter;\r\n\r\n    QVERIFY(sorter.sortedPortNames(component_).isEmpty());\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_InterfaceDirectionNameSorter::testPortsOrderedByName()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_InterfaceDirectionNameSorter::testPortsOrderedByName()\r\n{\r\n    addPort(\"c\");\r\n    addPort(\"C\");\r\n    addPort(\"B\");\r\n    addPort(\"b\");\r\n    addPort(\"a\");\r\n    addPort(\"x\");\r\n    addPort(\"z\");\r\n    addPort(\"\");\r\n\r\n    InterfaceDirectionNameSorter sorter;\r\n\r\n    QStringList expectedNames;\r\n    expectedNames << \"\" << \"a\" << \"B\" << \"b\" << \"C\" << \"c\" << \"x\" << \"z\";\r\n    QCOMPARE(sorter.sortedPortNames(component_), expectedNames);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_InterfaceDirectionNameSorter::addPort()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_InterfaceDirectionNameSorter::addPort(QString portName, DirectionTypes::Direction direction)\r\n{\r\n    QSharedPointer<Port> newPort (new Port(portName));\r\n    newPort->setDirection(direction);\r\n    newPort->setAllLogicalDirectionsAllowed(true);\r\n    component_->getPorts()->append(newPort);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_InterfaceDirectionNameSorter::testPortsOrderedByDirection()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_InterfaceDirectionNameSorter::testPortsOrderedByDirectionThenName()\r\n{\r\n    addPort(\"a_inout\", DirectionTypes::INOUT);\r\n    addPort(\"k_out\", DirectionTypes::OUT);\r\n    addPort(\"j_out\", DirectionTypes::OUT);\r\n    addPort(\"i_out\", DirectionTypes::OUT);\r\n    addPort(\"x_in\", DirectionTypes::IN);\r\n    \r\n    addPort(\"phantom\", DirectionTypes::DIRECTION_PHANTOM);\r\n    addPort(\"invalid\", DirectionTypes::DIRECTION_INVALID);\r\n\r\n    InterfaceDirectionNameSorter sorter;\r\n\r\n    QStringList expectedNames;\r\n    expectedNames  << \"x_in\" << \"i_out\" << \"j_out\" << \"k_out\" << \"a_inout\" << \"phantom\" << \"invalid\";\r\n    QCOMPARE( sorter.sortedPortNames(component_), expectedNames);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_InterfaceDirectionNameSorter::testPortsOrderedByInterfaceThenDirection()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_InterfaceDirectionNameSorter::testPortsOrderedByInterfaceThenDirection()\r\n{\r\n    addInterface(\"firstInterface\");\r\n    addInterface(\"secondInterface\");\r\n    addInterface(\"thirdInterface\");\r\n\r\n    addPort(\"k_none\");\r\n\r\n    addPort(\"z_several\");\r\n    mapPortToInterface(\"z_several\", \"firstInterface\");\r\n    mapPortToInterface(\"z_several\", \"thirdInterface\");    \r\n\r\n    addPort(\"x_1st\", DirectionTypes::INOUT);\r\n    mapPortToInterface(\"x_1st\", \"firstInterface\");\r\n    addPort(\"y_1st\", DirectionTypes::OUT);\r\n    mapPortToInterface(\"y_1st\", \"firstInterface\");\r\n    addPort(\"z_1st\", DirectionTypes::IN);\r\n    mapPortToInterface(\"z_1st\", \"firstInterface\");\r\n\r\n    addPort(\"a_2nd\", DirectionTypes::OUT);\r\n    mapPortToInterface(\"a_2nd\", \"secondInterface\");\r\n   \r\n    addPort(\"i_3rd\", DirectionTypes::OUT);\r\n    mapPortToInterface(\"i_3rd\", \"thirdInterface\");\r\n\r\n    InterfaceDirectionNameSorter sorter;\r\n\r\n    QStringList expectedNames;\r\n    expectedNames << \"z_1st\" << \"y_1st\" << \"x_1st\" << \"a_2nd\" << \"i_3rd\" << \"z_several\" << \"k_none\";\r\n    QCOMPARE(sorter.sortedPortNames(component_), expectedNames);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_InterfaceDirectionNameSorter::addInterface()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_InterfaceDirectionNameSorter::addInterface( QString const& interfaceName )\r\n{\r\n    QSharedPointer<BusInterface> busIf = QSharedPointer<BusInterface>(new BusInterface());\r\n    busIf->setName(interfaceName);\r\n\r\n    QSharedPointer<AbstractionType> abstraction(new AbstractionType());\r\n    abstraction->setAbstractionRef(QSharedPointer<ConfigurableVLNVReference>(new ConfigurableVLNVReference()));\r\n\r\n    busIf->getAbstractionTypes()->append(abstraction);\r\n\r\n    component_->getBusInterfaces()->append(busIf);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_InterfaceDirectionNameSorter::mapPortToInterface()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_InterfaceDirectionNameSorter::mapPortToInterface( QString const& portName, QString const& interfaceName )\r\n{\r\n    QSharedPointer<PortMap> portMap = QSharedPointer<PortMap>(new PortMap());\r\n\r\n    QSharedPointer<PortMap::LogicalPort> theLogical (new PortMap::LogicalPort());\r\n    theLogical->name_ = portName.toUpper();\r\n    portMap->setLogicalPort(theLogical);\r\n\r\n    QSharedPointer<PortMap::PhysicalPort> thePhysical (new PortMap::PhysicalPort());\r\n    thePhysical->name_ = portName;\r\n    portMap->setPhysicalPort(thePhysical);\r\n\r\n    QSharedPointer<QList<QSharedPointer<PortMap> > > portMapList =\r\n        component_->getBusInterface(interfaceName)->getAbstractionTypes()->first()->getPortMaps();\r\n\r\n    if (!portMapList)\r\n    {\r\n        QSharedPointer<QList<QSharedPointer<PortMap> > > newPortMapList (new QList<QSharedPointer<PortMap> > ());\r\n\r\n        if (component_->getBusInterface(interfaceName)->getAbstractionTypes()->isEmpty())\r\n        {\r\n            QSharedPointer<AbstractionType> testAbstraction (new AbstractionType());\r\n            component_->getBusInterface(interfaceName)->getAbstractionTypes()->append(testAbstraction);\r\n        }\r\n\r\n        portMapList = component_->getBusInterface(interfaceName)->getAbstractionTypes()->first()->getPortMaps();\r\n    }\r\n\r\n    portMapList->append(portMap);\r\n}\r\n\r\nQTEST_APPLESS_MAIN(tst_InterfaceDirectionNameSorter)\r\n\r\n#include \"tst_InterfaceDirectionNameSorter.moc\"\r\n"
  },
  {
    "path": "tests/Plugins/VerilogGenerator/tst_InterfaceDirectionNameSorter.pri",
    "content": "# ----------------------------------------------------\r\n# This file is generated by the Qt Visual Studio Add-in.\r\n# ------------------------------------------------------\r\n\r\nHEADERS += ../../../Plugins/common/PortSorter/InterfaceDirectionNameSorter.h\r\nSOURCES += ../../../Plugins/common/PortSorter/InterfaceDirectionNameSorter.cpp \\\r\n    ./tst_InterfaceDirectionNameSorter.cpp\r\n"
  },
  {
    "path": "tests/Plugins/VerilogGenerator/tst_InterfaceDirectionNameSorter.pro",
    "content": "#-----------------------------------------------------------------------------\r\n# File: tst_InterfaceDirectionNameSorter.pro\r\n#-----------------------------------------------------------------------------\r\n# Project: Kactus 2\r\n# Author: Esko Pekkarinen\r\n# Date: 05.08.2014\r\n#\r\n# Description:\r\n# Qt project file for running unit tests for class InterfaceDirectionNameSorter.\r\n#-----------------------------------------------------------------------------\r\n\r\nTEMPLATE = app\r\n\r\nTARGET = tst_InterfaceDirectionNameSorter\r\n\r\nQT += core xml gui testlib\r\nCONFIG += c++11 testcase console\r\n\r\nDEFINES += VERILOGGENERATORPLUGIN_LIB\r\n\r\nwin32:CONFIG(release, debug|release) {\r\n    LIBS += -L$$PWD/../../../executable/ -lIPXACTmodels\r\n    DESTDIR = ./release\r\n}\r\nelse:win32:CONFIG(debug, debug|release) {\r\n    LIBS += -L$$PWD/../../../executable/ -lIPXACTmodelsd\r\n    DESTDIR = ./debug\r\n}\r\nelse:unix {\r\n    LIBS += -L$$PWD/../../../executable/ -lIPXACTmodels\r\n    DESTDIR = ./release\r\n}\r\n\r\nINCLUDEPATH += $$PWD/../../../\r\nINCLUDEPATH += $$PWD/../../../executable\r\nINCLUDEPATH += $$DESTDIR\r\n\r\nDEPENDPATH += $$PWD/../../../\r\nDEPENDPATH += $$PWD/../../../executable\r\nDEPENDPATH += .\r\n\r\nOBJECTS_DIR += $$DESTDIR\r\n\r\nMOC_DIR += ./generatedFiles\r\nUI_DIR += ./generatedFiles\r\nRCC_DIR += ./generatedFiles\r\ninclude(tst_InterfaceDirectionNameSorter.pri)\r\n"
  },
  {
    "path": "tests/Plugins/VerilogGenerator/tst_VerilogHeaderWriter.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: tst_VerilogHeaderWriter.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Esko Pekkarinen\r\n// Date: 04.08.2014\r\n//\r\n// Description:\r\n// Unit test for class VerilogHeaderWriter.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include <QtTest>\r\n\r\n#include <Plugins/VerilogGenerator/VerilogHeaderWriter/VerilogHeaderWriter.h>\r\n\r\nclass tst_VerilogHeaderWriter : public QObject\r\n{\r\n    Q_OBJECT\r\n\r\npublic:\r\n    tst_VerilogHeaderWriter();\r\n\r\nprivate slots:\r\n    void init();\r\n    void cleanup();\r\n    void testVlnv();\r\n    void testVlnv_data();\r\n    void testGenerationTime();\r\n    void testDescription();\r\n    void testDescription_data();\r\n    void testVersion();\r\n\r\nprivate:\r\n    void compareLineByLine(QString const& expectedOutput);\r\n   \r\n    QString outputString_;\r\n\r\n    QTextStream outputStream_;\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_VerilogHeaderWriter::tst_VerilogHeaderWriter()\r\n//-----------------------------------------------------------------------------\r\ntst_VerilogHeaderWriter::tst_VerilogHeaderWriter() : outputString_(), outputStream_()\r\n{\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_VerilogHeaderWriter::init()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_VerilogHeaderWriter::init()\r\n{\r\n    outputStream_.setString(&outputString_);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_VerilogHeaderWriter::cleanup()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_VerilogHeaderWriter::cleanup()\r\n{\r\n    outputString_.clear();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_VerilogHeaderWriter::()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_VerilogHeaderWriter::testVlnv()\r\n{\r\n    QFETCH(QString, vendor);\r\n    QFETCH(QString, library);\r\n    QFETCH(QString, name);\r\n    QFETCH(QString, version);\r\n\r\n    VLNV vlnv(VLNV::COMPONENT, vendor, library, name, version);\r\n    QDateTime generationTime(QDate(2014, 4, 1), QTime(14,14,14));\r\n\r\n    VerilogHeaderWriter writer(vlnv, \"\", \"\", \"\", \"\", \"\");\r\n    writer.write(outputStream_, \"output.v\", generationTime);\r\n\r\n    compareLineByLine(QString(\r\n        \"//-----------------------------------------------------------------------------\\n\"\r\n        \"// File          : output.v\\n\"\r\n        \"// Creation date : 01.04.2014\\n\"\r\n        \"// Creation time : 14:14:14\\n\"\r\n        \"// Description   : \\n\"\r\n        \"// Created by    : \\n\"\r\n        \"// Tool : Kactus2 \\n\"\r\n        \"// Plugin : Verilog generator \\n\"\r\n        \"// This file was generated based on IP-XACT component \" + vendor + \":\" + library + \":\" + name + \":\"\r\n        + version + \"\\n\"\r\n        \"// whose XML file is \\n\"\r\n        \"//-----------------------------------------------------------------------------\\n\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_VerilogHeaderWriter::testVlnv_data()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_VerilogHeaderWriter::testVlnv_data()\r\n{\r\n    QTest::addColumn<QString>(\"vendor\");\r\n    QTest::addColumn<QString>(\"library\");\r\n    QTest::addColumn<QString>(\"name\");\r\n    QTest::addColumn<QString>(\"version\");\r\n\r\n    QTest::newRow(\"all empty\") << \"\" << \"\" << \"\" << \"\";\r\n    QTest::newRow(\"common\") << \"Test\" << \"TestLib\" << \"Component\" << \"1.0\";\r\n    QTest::newRow(\"numbers\") << \"L4Factory\" << \"Lib932\" << \"IP11\" << \"1.1.1.1.1\";\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_VerilogHeaderWriter::testGenerationTime()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_VerilogHeaderWriter::testGenerationTime()\r\n{\r\n    VLNV vlnv(VLNV::COMPONENT, \"Tester\", \"TestLibrary\", \"TestComponent\", \"0.1\");\r\n\r\n    QDateTime generationTime(QDate(2014, 1, 14), QTime(12, 0, 40));\r\n\r\n    VerilogHeaderWriter writer(vlnv, \"\", \"\", \"\", \"\", \"\");\r\n    writer.write(outputStream_, \"TestComponent.v\", generationTime);       \r\n\r\n    compareLineByLine(QString(\r\n        \"//-----------------------------------------------------------------------------\\n\"\r\n        \"// File          : TestComponent.v\\n\"\r\n        \"// Creation date : 14.01.2014\\n\"\r\n        \"// Creation time : 12:00:40\\n\"\r\n        \"// Description   : \\n\"\r\n        \"// Created by    : \\n\"\r\n        \"// Tool : Kactus2 \\n\"\r\n        \"// Plugin : Verilog generator \\n\"\r\n        \"// This file was generated based on IP-XACT component Tester:TestLibrary:TestComponent:0.1\\n\"\r\n        \"// whose XML file is \\n\"\r\n        \"//-----------------------------------------------------------------------------\\n\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_VerilogHeaderWriter::testGenerationTime()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_VerilogHeaderWriter::testDescription()\r\n{\r\n    QFETCH(QString, description);\r\n    QFETCH(QString, expectedOutput);\r\n\r\n    VLNV vlnv(VLNV::COMPONENT, \"Tester\", \"TestLibrary\", \"TestComponent\", \"0.1\");\r\n\r\n    QDateTime generationTime(QDate(2014, 4, 14), QTime(14, 14, 14));\r\n\r\n    VerilogHeaderWriter writer(vlnv, \"\", \"\", description, \"\", \"\");\r\n    writer.write(outputStream_, \"TestComponent.v\", generationTime);       \r\n\r\n    compareLineByLine(expectedOutput);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_VerilogHeaderWriter::testDescription_data()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_VerilogHeaderWriter::testDescription_data()\r\n{\r\n    QTest::addColumn<QString>(\"description\");\r\n    QTest::addColumn<QString>(\"expectedOutput\");\r\n\r\n    QTest::newRow(\"empty description\") << \"\" \r\n        <<\r\n        \"//-----------------------------------------------------------------------------\\n\"\r\n        \"// File          : TestComponent.v\\n\"\r\n        \"// Creation date : 14.04.2014\\n\"\r\n        \"// Creation time : 14:14:14\\n\"\r\n        \"// Description   : \\n\"\r\n        \"// Created by    : \\n\"\r\n        \"// Tool : Kactus2 \\n\"\r\n        \"// Plugin : Verilog generator \\n\"\r\n        \"// This file was generated based on IP-XACT component Tester:TestLibrary:TestComponent:0.1\\n\"\r\n        \"// whose XML file is \\n\"\r\n        \"//-----------------------------------------------------------------------------\\n\";\r\n\r\n    QTest::newRow(\"One-line description\") << \"Component description.\" \r\n        <<\r\n        \"//-----------------------------------------------------------------------------\\n\"\r\n        \"// File          : TestComponent.v\\n\"\r\n        \"// Creation date : 14.04.2014\\n\"\r\n        \"// Creation time : 14:14:14\\n\"\r\n        \"// Description   : Component description.\\n\"\r\n        \"// Created by    : \\n\"\r\n        \"// Tool : Kactus2 \\n\"\r\n        \"// Plugin : Verilog generator \\n\"\r\n        \"// This file was generated based on IP-XACT component Tester:TestLibrary:TestComponent:0.1\\n\"\r\n        \"// whose XML file is \\n\"\r\n        \"//-----------------------------------------------------------------------------\\n\";\r\n\r\n    QTest::newRow(\"Multiline description\") << \"Component description\\n\"\r\n        \"on several\\n\"\r\n        \"separate\\n\"\r\n        \"lines.\" \r\n        <<\r\n        \"//-----------------------------------------------------------------------------\\n\"\r\n        \"// File          : TestComponent.v\\n\"\r\n        \"// Creation date : 14.04.2014\\n\"\r\n        \"// Creation time : 14:14:14\\n\"\r\n        \"// Description   : Component description\\n\"\r\n        \"//                 on several\\n\"\r\n        \"//                 separate\\n\"\r\n        \"//                 lines.\\n\"\r\n        \"// Created by    : \\n\"\r\n        \"// Tool : Kactus2 \\n\"\r\n        \"// Plugin : Verilog generator \\n\"\r\n        \"// This file was generated based on IP-XACT component Tester:TestLibrary:TestComponent:0.1\\n\"\r\n        \"// whose XML file is \\n\"\r\n        \"//-----------------------------------------------------------------------------\\n\";\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_VerilogHeaderWriter::testVersion()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_VerilogHeaderWriter::testVersion()\r\n{\r\n    VLNV vlnv(VLNV::COMPONENT, \"Tester\", \"TestLibrary\", \"TestComponent\", \"0.1\");\r\n\r\n    QDateTime generationTime(QDate(2020, 12, 15), QTime(23, 9, 50));\r\n\r\n    VerilogHeaderWriter writer(vlnv, \"\", \"\", \"\", \"toolVersion\", \"generatorVersion\");\r\n    writer.write(outputStream_, \"TestComponent.v\", generationTime);       \r\n\r\n    compareLineByLine(QString(\r\n        \"//-----------------------------------------------------------------------------\\n\"\r\n        \"// File          : TestComponent.v\\n\"\r\n        \"// Creation date : 15.12.2020\\n\"\r\n        \"// Creation time : 23:09:50\\n\"\r\n        \"// Description   : \\n\"\r\n        \"// Created by    : \\n\"\r\n        \"// Tool : Kactus2 toolVersion\\n\"\r\n        \"// Plugin : Verilog generator generatorVersion\\n\"\r\n        \"// This file was generated based on IP-XACT component Tester:TestLibrary:TestComponent:0.1\\n\"\r\n        \"// whose XML file is \\n\"\r\n        \"//-----------------------------------------------------------------------------\\n\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_VerilogGenerator::compareLineByLine()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_VerilogHeaderWriter::compareLineByLine(QString const& expectedOutput)\r\n{\r\n    QStringList outputLines = outputString_.split(\"\\n\");\r\n    QStringList expectedLines = expectedOutput.split(\"\\n\");\r\n\r\n    int lineCount = qMin(outputLines.count(), expectedLines.count());\r\n    for (int i = 0; i < lineCount; i++)\r\n    {\r\n        QCOMPARE(outputLines.at(i), expectedLines.at(i));\r\n    }\r\n}\r\n\r\nQTEST_APPLESS_MAIN(tst_VerilogHeaderWriter)\r\n\r\n#include \"tst_VerilogHeaderWriter.moc\"\r\n"
  },
  {
    "path": "tests/Plugins/VerilogGenerator/tst_VerilogHeaderWriter.pri",
    "content": "# ----------------------------------------------------\r\n# This file is generated by the Qt Visual Studio Add-in.\r\n# ------------------------------------------------------\r\n\r\nHEADERS += ../../../Plugins/VerilogGenerator/VerilogHeaderWriter/VerilogHeaderWriter.h\r\nSOURCES += ./tst_VerilogHeaderWriter.cpp \\\r\n\t   ../../../Plugins/VerilogGenerator/VerilogHeaderWriter/VerilogHeaderWriter.cpp\r\n"
  },
  {
    "path": "tests/Plugins/VerilogGenerator/tst_VerilogHeaderWriter.pro",
    "content": "#-----------------------------------------------------------------------------\r\n# File: tst_VerilogHeaderWriter.pro\r\n#-----------------------------------------------------------------------------\r\n# Project: Kactus 2\r\n# Author: Esko Pekkarinen\r\n# Date: 04.08.2014\r\n#\r\n# Description:\r\n# Qt project file for running unit tests for VerilogHeaderWriter.\r\n#-----------------------------------------------------------------------------\r\n\r\nTEMPLATE = app\r\n\r\nTARGET = tst_VerilogHeaderWriter\r\n\r\nQT += core xml gui testlib\r\nCONFIG += c++11 testcase console\r\n\r\nDEFINES += VERILOGGENERATORPLUGIN_LIB\r\n\r\nwin32:CONFIG(release, debug|release) {\r\n    LIBS += -L$$PWD/../../../executable/ -lIPXACTmodels\r\n    DESTDIR = ./release\r\n}\r\nelse:win32:CONFIG(debug, debug|release) {\r\n    LIBS += -L$$PWD/../../../executable/ -lIPXACTmodelsd\r\n    DESTDIR = ./debug\r\n}\r\nelse:unix {\r\n    LIBS += -L$$PWD/../../../executable/ -lIPXACTmodels\r\n    DESTDIR = ./release\r\n}\r\n\r\nINCLUDEPATH += $$PWD/../../../\r\nINCLUDEPATH += $$DESTDIR\r\n\r\nDEPENDPATH += $$PWD/../../../\r\nDEPENDPATH += .\r\n\r\nOBJECTS_DIR += $$DESTDIR\r\n\r\nMOC_DIR += ./generatedFiles\r\nUI_DIR += ./generatedFiles\r\nRCC_DIR += ./generatedFiles\r\ninclude(tst_VerilogHeaderWriter.pri)\r\n"
  },
  {
    "path": "tests/Plugins/VerilogGenerator/tst_VerilogWriterFactory.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: tst_VerilogWriterFactory.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Janne Virtanen\n// Date: 26.01.2017\n//\n// Description:\n// Unit test for class VerilogWriterFactory.\n//-----------------------------------------------------------------------------\n\n#include <QtTest>\n\n#include <Plugins/VerilogGenerator/VerilogWriterFactory/VerilogWriterFactory.h>\n\n#include <Plugins/PluginSystem/GeneratorPlugin/MessagePasser.h>\n\n#include <tests/MockObjects/LibraryMock.h>\n\n#include <Plugins/common/HDLParser/MetaDesign.h>\n#include <Plugins/common/HDLParser/MetaComponent.h>\n#include <Plugins/VerilogImport/VerilogSyntax.h>\n#include <Plugins/PluginSystem/GeneratorPlugin/GenerationControl.h>\n\n#include <IPXACTmodels/AbstractionDefinition/AbstractionDefinition.h>\n#include <IPXACTmodels/AbstractionDefinition/PortAbstraction.h>\n#include <IPXACTmodels/AbstractionDefinition/TransactionalPort.h>\n#include <IPXACTmodels/AbstractionDefinition/TransactionalAbstraction.h>\n#include <IPXACTmodels/AbstractionDefinition/WireAbstraction.h>\n#include <IPXACTmodels/AbstractionDefinition/WirePort.h>\n#include <IPXACTmodels/BusDefinition/BusDefinition.h>\n#include <IPXACTmodels/common/Parameter.h>\n#include <IPXACTmodels/common/TransactionalTypes.h>\n#include <IPXACTmodels/Component/Port.h>\n#include <IPXACTmodels/Component/Component.h>\n#include <IPXACTmodels/Component/BusInterface.h>\n#include <IPXACTmodels/Component/PortMap.h>\n\nclass tst_VerilogWriterFactory : public QObject\n{\n    Q_OBJECT\n\npublic:\n    tst_VerilogWriterFactory();\n\nprivate slots:\n    void initTestCase();\n    void cleanupTestCase();\n    void init();\n    void cleanup();\n\n    // Hierarchy test cases:\n    void testTopLevelComponent();\n\n    void testFileHeaderIsPrinted();\n\n    void testHierarchicalConnections();\n    void testInstanceSlicedHierarchicalConnections();\n    void testTopSlicedHierarchicalConnections();\n\n    void testMasterToSlaveInterconnection();\n    void testOneBitSlicing();\n    void testPhysicalSlicedMasterToSlaveInterconnection();\n    void testLogicalSlicedMasterToSlaveInterconnection();\n    void testLogicalSlicedMasterToMultiplePortsInSlave();\n    void testHierarchicalInOutConnectionWithMultiplePorts();\n    void testPortSlicedMasterToSlaveInterconnection();\n    void testMasterToMultipleSlavesInterconnections();\n\n    void testLogicalInvertBetweenInstances();\n    void testLogicalInvertInHierarchicalConnection();\n\n    void testAdhocConnectionBetweenComponentInstances();    \n    void testPartSelectedAdhocConnectionBetweenComponentInstances();\n    void testAdhocInOutConnectionBetweenComponentInstances();\n    void testAdhocTieOffInComponentInstance();\n    void testHierarchicalAdhocConnection();\n    void testHierarchicalAdhocInOutConnection();\n    void testHierarchicalAdHocTieOffValues();\n    \n    void testDescriptionAndVLNVIsPrintedAboveInstance();\n    void testDescriptionAndVLNVIsPrintedAboveInstance_data();\n    void testInstanceParametersAreWritten();\n\n    void testAdhocConnectionToInterfacePorts();\n\n    // Flat test cases:\n    void testFlatComponent();\n    void testFlatComponentWithTypedParameter();\n\n    void testDoNotWriteTransactionalPorts();\n    void testDoNotWriteTransactionalInterfaces();\n\n    void testDoNotWriteTransactionalConnections();\n\n\tvoid testGenerationWithImplementation();\n\tvoid testGenerationWithImplementationWithTag();\n\tvoid testGenerationWithImplementationWithPostModule();\n\nprivate slots:\n\n    void gatherErrorMessage(QString const& errorMessage);\n\nprivate:\n\n    QSharedPointer<MetaInterconnection> addInterconnectToDesign(QSharedPointer<MetaInterface> first,\n        QSharedPointer<MetaInterface> second,\n        QString name);\n\n    QSharedPointer<MetaWire> addWireToDesign(QString name, QString leftBound, QString rightBound, \n        QSharedPointer<MetaInterconnection> mInterconnect = QSharedPointer<MetaInterconnection>());\n\n    QSharedPointer<MetaPort> addPort(QString const& portName, int portSize, DirectionTypes::Direction direction, \n        QSharedPointer<MetaComponent> component,\n        QSharedPointer<MetaInterface> mInterface = QSharedPointer<MetaInterface>());\n\n    QSharedPointer<MetaPort> addTransactional(QString const& portName, TransactionalTypes::Initiative initiative,\n        QSharedPointer<MetaComponent> component,\n        QSharedPointer<MetaInterface> containingInterface = QSharedPointer<MetaInterface>());\n\n    QSharedPointer<Parameter> addParameter(QString const& name, QString const& value, \n        QSharedPointer<MetaComponent> mComponent);\n\n    void runGenerator(bool useDesign);\n\n    void createPortAssignment(QSharedPointer<MetaPort> mPort, QSharedPointer<MetaWire> wire, bool up,\n        QString const& logicalLeft, QString const& logicalRight, QString const& physicalLeft, \n        QString const& physicalRight);\n\n    QSharedPointer<Component> addTestComponentToLibrary(VLNV vlnv);\n\n    QSharedPointer<MetaInstance> addInstanceToDesign(QString instanceName, QSharedPointer<Component> component);\n\n    void addInterfacesToInstance(QSharedPointer<MetaInstance> mInstance);\n\n    void createInterface(QSharedPointer<MetaPort> port, QString const& interfaceName,\n        QSharedPointer<MetaInstance> component);\n    \n    QSharedPointer<MetaInterface> addInterfaceToComponent(QString const& interfaceName,\n        QSharedPointer<MetaInstance> component);\n\n    QSharedPointer<MetaInstance> addSender(QString const& instanceName);\n\n    QSharedPointer<MetaInstance> addReceiver(QString const& instanceName);\n\n    QSharedPointer<Component> createComponent(QString const& componentName);\n\n    QSharedPointer<Design> createDesignForComponent(QString const& designName, QSharedPointer<Component> component);\n\n    QSharedPointer<BusDefinition> createBusDefinition(QString const& definitionName);\n\n    QSharedPointer<AbstractionDefinition> createAbstractionDefinition(QString const& definitionName);\n\n    QSharedPointer<Port> addPortToComponent(QString const& portName, QSharedPointer<Component> containingComponent,\n        TransactionalTypes::Initiative newInitiative = TransactionalTypes::Initiative::INITIATIVE_INVALID,\n        DirectionTypes::Direction newDirection = DirectionTypes::DIRECTION_INVALID);\n\n    QSharedPointer<BusInterface> addBusInterfaceToComponent(QString const& busName,\n        QSharedPointer<Component> containingComponent, General::InterfaceMode busMode,\n        QSharedPointer<BusDefinition> busDefinition, QSharedPointer<AbstractionDefinition> abstraction,\n        QString const& systemGroup = \"\");\n\n    QSharedPointer<PortAbstraction> addLogicalPortToAbstraction(QString const& portName,\n        QSharedPointer<AbstractionDefinition> containingAbstraction, General::InterfaceMode busMode,\n        TransactionalTypes::Initiative logicalInitiative = TransactionalTypes::Initiative::INITIATIVE_INVALID,\n        DirectionTypes::Direction logicalDirection = DirectionTypes::DIRECTION_INVALID,\n        QString const& systemGroup = \"\");\n\n    void mapPortsToBusInterface(QSharedPointer<BusInterface> containingBus, QSharedPointer<Port> physicalPort,\n        QSharedPointer<PortAbstraction> logicalPort);\n\n    void mapMultiplePortsToBusInterface(QSharedPointer<BusInterface> containingBus,\n        QList<QSharedPointer<Port> > physicalPorts, QSharedPointer<PortAbstraction> logicalPort);\n\n    QSharedPointer<ComponentInstance> addInstanceToDesign(QSharedPointer<Design> containingDesign,\n        QSharedPointer<Component> instancedComponent);\n\n    QSharedPointer<Interconnection> addInterconnectionToDesign(QString const& interconnectionName,\n        QSharedPointer<Design> containingDesign, QString const& startInterfaceName,\n        QString const& startInstanceName, QString const& secondInterfaceName, QString const& secondInstanceName);\n\n    QSharedPointer<Interconnection> addHierarchicalInterconnectionToDesign(QString const& interconnectionName,\n        QSharedPointer<Design> containingDesign, QString const& topInterface, QString const& targetInterfaceName,\n        QString const& targetInstanceName);\n\n    QSharedPointer<MetaInterconnection> addConnectionToDesign();\n\n    void addDefaultPortAssignmentToPort(QSharedPointer<MetaPort> port, QString tieOff, bool up);\n\n    void verifyOutputContains(QString const& expectedOutput);\n\n    void compareOutputTo(QString const& expectedOutput);\n\n    QSharedPointer<MetaInstance> topComponent_;\n    QSharedPointer<MetaDesign> design_;\n\n    QSharedPointer<MetaComponent> flatComponent_;\n\n    //! The generator output as a string.\n    QString output_;\n    \n    //! The time of the generator run.\n    QDateTime generationTime_;\n\n    //! The test mock for library interface.\n    LibraryMock library_;\n\n    QStringList errorMessages_;\n};\n\n//-----------------------------------------------------------------------------\n// Function: tst_VerilogWriterFactory::tst_VerilogWriterFactory()\n//-----------------------------------------------------------------------------\ntst_VerilogWriterFactory::tst_VerilogWriterFactory(): output_(), generationTime_(), library_(this),\nerrorMessages_()\n{\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_VerilogWriterFactory::initTestCase()\n//-----------------------------------------------------------------------------\nvoid tst_VerilogWriterFactory::initTestCase()\n{\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_VerilogWriterFactory::cleanupTestCase()\n//-----------------------------------------------------------------------------\nvoid tst_VerilogWriterFactory::cleanupTestCase()\n{\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_VerilogWriterFactory::init()\n//-----------------------------------------------------------------------------\nvoid tst_VerilogWriterFactory::init()\n{\n    VLNV vlnv(VLNV::COMPONENT, \"Test\", \"TestLibrary\", \"TestComponent\", \"1.0\");\n    QSharedPointer<Component> component = QSharedPointer<Component>(new Component(vlnv, Document::Revision::Std14));\n\n    MessagePasser messages;\n\n    topComponent_ =  QSharedPointer<MetaInstance>(new MetaInstance(QSharedPointer<ComponentInstance>(),\n        &library_, &messages, component, QSharedPointer<View>()));\n\n    design_ = QSharedPointer<MetaDesign>(new MetaDesign(&library_,&messages,\n        QSharedPointer<Design>(), QSharedPointer<DesignInstantiation>(),\n        QSharedPointer<DesignConfiguration>(),\n        topComponent_));\n\n    flatComponent_ = QSharedPointer<MetaComponent>(\n        new MetaComponent(&messages, component, QSharedPointer<View>()));\n\n    library_.clear();\n    errorMessages_.clear();\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_VerilogWriterFactory::cleanup()\n//-----------------------------------------------------------------------------\nvoid tst_VerilogWriterFactory::cleanup()\n{\n    topComponent_.clear();\n\n    output_.clear();\n\n    QFile::remove(\"TestComponent.v\");\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_VerilogWriterFactory::testTopLevelComponent()\n//-----------------------------------------------------------------------------\nvoid tst_VerilogWriterFactory::testTopLevelComponent()\n{\n    addPort(\"clk\", 1, DirectionTypes::IN, topComponent_);\n    addPort(\"rst_n\", 1, DirectionTypes::IN, topComponent_);\n    addPort(\"dataOut\", 8, DirectionTypes::OUT, topComponent_);\n    addPort(\"dataIn\", 8, DirectionTypes::IN, topComponent_);\n    addParameter(\"dataWidth\", \"8\", topComponent_);\n    addParameter(\"freq\", \"100000\", topComponent_);\n\n    runGenerator(true);\n\n    verifyOutputContains(QString(\n        \"module TestComponent #(\\n\"\n        \"    parameter                              dataWidth        = 8,\\n\"\n        \"    parameter                              freq             = 100000\\n\"\n        \") (\\n\"\n        \"    // These ports are not in any interface\\n\"         \n        \"    input                               clk,\\n\"\n        \"    input                [7:0]          dataIn,\\n\"\n        \"    input                               rst_n,\\n\"\n        \"    output               [7:0]          dataOut\\n\"\n        \");\\n\"\n        \"\\n\"\n        \"    // Assignments for the ports of the encompassing component:\\n\"\n        \"\\n\"\n        \"\\n\"\n        \"\\n\"\n        \"endmodule\\n\"\n        ));\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_VerilogWriterFactory::addPort()\n//-----------------------------------------------------------------------------\nQSharedPointer<MetaPort> tst_VerilogWriterFactory::addPort(QString const& portName, int portSize, \n    DirectionTypes::Direction direction, QSharedPointer<MetaComponent> component,\n    QSharedPointer<MetaInterface> mInterface /*= QSharedPointer<MetaInterface>()*/)\n{\n    QSharedPointer<Port> port = QSharedPointer<Port>(new Port(portName));\n    port->setDirection(direction);\n    port->setPortSize(portSize);\n\n    QSharedPointer<MetaPort> gp(new MetaPort);\n    gp->isWire_ = true;\n    gp->isTransactional_ = false;\n    gp->port_ = port;\n    gp->vectorBounds_.first = QString::number(portSize-1);\n    gp->vectorBounds_.second = \"0\";\n\n    component->getPorts()->insert(portName,gp);\n    component->getComponent()->getPorts()->append(port);\n\n    if (mInterface)\n    {\n        mInterface->ports_.insert(portName,gp);\n\n        QSharedPointer<PortMap> pm(new PortMap);\n        QSharedPointer<PortMap::PhysicalPort> pp(new PortMap::PhysicalPort);\n        pp->name_ = portName;\n        pm->setPhysicalPort(pp);\n\n        mInterface->interface_->getAbstractionTypes()->first()->getPortMaps()->append(pm);\n    }\n\n    return gp;\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_VerilogWriterFactory::addParameter()\n//-----------------------------------------------------------------------------\nQSharedPointer<Parameter> tst_VerilogWriterFactory::addParameter(QString const& name, QString const& value,\n    QSharedPointer<MetaComponent> mComponent)\n{\n    QSharedPointer<Parameter> parameter = QSharedPointer<Parameter>(new Parameter());\n    parameter->setName(name);\n    parameter->setValue(value);\n\n    mComponent->getMetaParameters()->append(parameter);\n\n    return parameter;\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_VerilogWriterFactory::runGenerator()\n//-----------------------------------------------------------------------------\nvoid tst_VerilogWriterFactory::runGenerator(bool useDesign)\n{\n    GenerationSettings settings;\n    settings.generateInterfaces_ = false;\n\n    MessagePasser messages;\n\n    VerilogWriterFactory factory(&library_, &messages, &settings, \"bogusToolVersion\", \"bogusGeneratorVersion\");\n    QString outputPath = \".\";\n    QSharedPointer<GenerationOutput> document;\n\n\tif (useDesign)\n    {\n        QList<QSharedPointer<MetaDesign> > ds;\n        ds.append(design_);\n\t\tdocument = factory.prepareDesign(ds).first();\n\t}\n\telse\n\t{\n\t\tdocument = factory.prepareComponent(outputPath, flatComponent_);\n\t}\n\n    generationTime_ =  QDateTime::currentDateTime();\n\n    document->write(\".\");\n\n    output_ = document->fileContent_;\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_VerilogWriterFactory::testFileHeaderIsPrinted()\n//-----------------------------------------------------------------------------\nvoid tst_VerilogWriterFactory::testFileHeaderIsPrinted()\n{    \n    topComponent_->getComponent()->setDescription(\"Component description\\nspanning multiple\\nlines.\");\n    library_.writeModelToFile(\"C:/Test/TestLibrary/TestComponent/1.0/TestComponent.1.0.xml\", topComponent_->getComponent());\n    \t\n    QCoreApplication::setOrganizationName(\"TUT\");\n    QCoreApplication::setApplicationName(\"TestRunner\");\n    QSettings settings;\n    settings.setValue(\"General/Username\", \"testUser\");\n\n    runGenerator(false);\n\n    verifyOutputContains(QString(\n        \"//-----------------------------------------------------------------------------\\n\"\n        \"// File          : TestComponent.v\\n\"\n        \"// Creation date : \" + generationTime_.date().toString(\"dd.MM.yyyy\") + \"\\n\"\n        \"// Creation time : \" + generationTime_.time().toString(\"hh:mm:ss\") + \"\\n\"\n        \"// Description   : Component description\\n\"\n        \"//                 spanning multiple\\n\"\n        \"//                 lines.\\n\"\n\t\t\"// Created by    : testUser\\n\"\n\t\t\"// Tool : Kactus2 bogusToolVersion\\n\"\n\t\t\"// Plugin : Verilog generator bogusGeneratorVersion\\n\"\n\t\t\"// This file was generated based on IP-XACT component Test:TestLibrary:TestComponent:1.0\\n\"\n        \"// whose XML file is C:/Test/TestLibrary/TestComponent/1.0/TestComponent.1.0.xml\\n\"\n        \"//-----------------------------------------------------------------------------\\n\"));\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_VerilogWriterFactory::testHierarchicalConnections()\n//-----------------------------------------------------------------------------\nvoid tst_VerilogWriterFactory::testHierarchicalConnections()\n{\n    QSharedPointer<MetaInterface> topClockIf = addInterfaceToComponent(\"clk_if\", topComponent_);\n    QSharedPointer<MetaInterface> topDataIf = addInterfaceToComponent(\"data_bus\", topComponent_);\n\n    QSharedPointer<MetaPort> topClock = addPort(\"top_clk\", 1, DirectionTypes::IN, topComponent_, topClockIf);\n    QSharedPointer<MetaPort> topData = addPort(\"data_to_instance\", 8, DirectionTypes::IN, topComponent_, topDataIf);\n    QSharedPointer<MetaPort> topEnable = addPort(\"enable_to_instance\", 1, DirectionTypes::IN, topComponent_, topDataIf);\n    QSharedPointer<MetaPort> topFull = addPort(\"full_from_instance\", 1, DirectionTypes::OUT, topComponent_, topDataIf);\n\n    VLNV instanceVlnv(VLNV::COMPONENT, \"Test\", \"TestLibrary\", \"TestInstance\", \"1.0\");\n    QSharedPointer<Component> comp = addTestComponentToLibrary(instanceVlnv);\n    QSharedPointer<MetaInstance> mInstance = addInstanceToDesign(\"instance1\", comp);\n    addInterfacesToInstance(mInstance);\n\n    QSharedPointer<MetaInterface> instanceClockIf = mInstance->getInterfaces()->value(\"clk_if\");\n    QSharedPointer<MetaInterface> instanceDataIf = mInstance->getInterfaces()->value(\"data_if\");\n\n    QSharedPointer<MetaInterconnection> mI0 = addInterconnectToDesign(topClockIf, instanceClockIf, \"clock_connection\");\n    mI0->hierIfs_.append(topClockIf);\n    QSharedPointer<MetaInterconnection> mI1 = addInterconnectToDesign(topDataIf, instanceDataIf, \"data_connection\");\n    mI1->hierIfs_.append(topDataIf);\n\n    QSharedPointer<MetaWire> gw0 = addWireToDesign(\"clk_wire\",\"0\",\"0\",mI0);\n    gw0->hierPorts_.append(topClock);\n    QSharedPointer<MetaWire> gw1 = addWireToDesign(\"data_wire\",\"7\",\"0\",mI1);\n    gw1->hierPorts_.append(topData);\n    QSharedPointer<MetaWire> gw2 = addWireToDesign(\"enable_wire\",\"0\",\"0\",mI1);\n    gw2->hierPorts_.append(topEnable);\n    QSharedPointer<MetaWire> gw3 = addWireToDesign(\"full_wire\",\"0\",\"0\",mI1);\n    gw3->hierPorts_.append(topFull);\n\n    createPortAssignment(mInstance->getPorts()->value(\"clk\"), gw0, true, \"0\", \"0\", \"0\", \"0\");\n    createPortAssignment(mInstance->getPorts()->value(\"data_in\"), gw1, true, \"7\", \"0\", \"7\", \"0\");\n    createPortAssignment(mInstance->getPorts()->value(\"enable\"), gw2, true, \"0\", \"0\", \"0\", \"0\");\n    createPortAssignment(mInstance->getPorts()->value(\"full\"), gw3, true, \"0\", \"0\", \"0\", \"0\");\n\n    createPortAssignment(topClock, gw0, false, \"0\", \"0\", \"0\", \"0\");\n    createPortAssignment(topData, gw1, false, \"7\", \"0\", \"7\", \"0\");\n    createPortAssignment(topEnable, gw2, false, \"0\", \"0\", \"0\", \"0\");\n    createPortAssignment(topFull, gw3, false, \"0\", \"0\", \"0\", \"0\");\n\n    runGenerator(true);\n\n    verifyOutputContains(QString(\n        \"module TestComponent(\\n\"\n        \"    // Interface: clk_if\\n\"\n        \"    input                               top_clk,\\n\"\n        \"\\n\"\n        \"    // Interface: data_bus\\n\"\n        \"    input                [7:0]          data_to_instance,\\n\"\n        \"    input                               enable_to_instance,\\n\"\n        \"    output                              full_from_instance\\n\"\n        \");\\n\"\n        \"\\n\"\n        \"    // clock_connection wires:\\n\"\n        \"    wire       clk_wire;\\n\"\n        \"    // data_connection wires:\\n\"\n        \"    wire [7:0] data_wire;\\n\"\n        \"    wire       enable_wire;\\n\"\n        \"    wire       full_wire;\\n\"\n        \"\\n\"\n        \"    // instance1 port wires:\\n\"\n        \"    wire       instance1_clk;\\n\"\n        \"    wire [7:0] instance1_data_in;\\n\"\n        \"    wire       instance1_enable;\\n\"\n        \"    wire       instance1_full;\\n\"\n        \"\\n\"\n        \"    // Assignments for the ports of the encompassing component:\\n\"\n        \"    assign data_wire = data_to_instance;\\n\"\n        \"    assign enable_wire = enable_to_instance;\\n\"\n        \"    assign full_from_instance = full_wire;\\n\"\n        \"    assign clk_wire = top_clk;\\n\"\n        \"\\n\"\n        \"    // instance1 assignments:\\n\"\n        \"    assign instance1_clk = clk_wire;\\n\"\n        \"    assign instance1_data_in = data_wire;\\n\"\n        \"    assign instance1_enable = enable_wire;\\n\"\n        \"    assign full_wire = instance1_full;\\n\"\n        \"\\n\"\n        \"    // IP-XACT VLNV: Test:TestLibrary:TestInstance:1.0\\n\"\n        \"    TestInstance instance1(\\n\"\n        \"        // Interface: clk_if\\n\"\n        \"        .clk                 (instance1_clk),\\n\"\n        \"        // Interface: data_if\\n\"\n        \"        .data_in             (instance1_data_in),\\n\"\n        \"        .enable              (instance1_enable),\\n\"\n        \"        .full                (instance1_full),\\n\"\n        \"        // These ports are not in any interface\\n\"\n        \"        .data_out            ());\\n\"\n        \"\\n\"\n        \"\\n\"\n        \"endmodule\"));\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_VerilogWriterFactory::testInstanceSlicedHierarchicalConnections()\n//-----------------------------------------------------------------------------\nvoid tst_VerilogWriterFactory::testInstanceSlicedHierarchicalConnections()\n{\n    QSharedPointer<MetaInterface> topDataIf = addInterfaceToComponent(\"data_if\", topComponent_);\n\n    QSharedPointer<MetaPort> topiData = addPort(\"data_to_instance\", 8, DirectionTypes::IN, topComponent_, topDataIf);\n    QSharedPointer<MetaPort> topoData = addPort(\"data_from_instance\", 8, DirectionTypes::OUT, topComponent_, topDataIf);\n\n    VLNV instanceVlnv(VLNV::COMPONENT, \"Test\", \"TestLibrary\", \"TestInstance\", \"1.0\");\n    QSharedPointer<Component> comp = addTestComponentToLibrary(instanceVlnv);\n    QSharedPointer<MetaInstance> mInstance = addInstanceToDesign(\"instance1\", comp);\n\n    QSharedPointer<MetaInterface> instanceDataIf = addInterfaceToComponent(\"data_if\", mInstance);\n    QSharedPointer<MetaPort> idata1Port = addPort(\"idata1\", 4, DirectionTypes::IN, mInstance, instanceDataIf);\n    QSharedPointer<MetaPort> idata2Port = addPort(\"idata2\", 4, DirectionTypes::IN, mInstance, instanceDataIf);\n    QSharedPointer<MetaPort> odata1Port = addPort(\"odata1\", 4, DirectionTypes::OUT, mInstance, instanceDataIf);\n    QSharedPointer<MetaPort> odata2Port = addPort(\"odata2\", 4, DirectionTypes::OUT, mInstance, instanceDataIf);\n\n    QSharedPointer<MetaInterconnection> mI1 = addInterconnectToDesign(topDataIf, instanceDataIf, \"data_connection\");\n    mI1->hierIfs_.append(topDataIf);\n\n    QSharedPointer<MetaWire> imWire = addWireToDesign(\"idata_wire\",\"7\",\"0\",mI1);\n    imWire->hierPorts_.append(topiData);\n    QSharedPointer<MetaWire> omWire = addWireToDesign(\"odata_wire\",\"7\",\"0\",mI1);\n    omWire->hierPorts_.append(topoData);\n\n    createPortAssignment(idata1Port, imWire, true, \"3\", \"0\", \"3\", \"0\");\n    createPortAssignment(idata2Port, imWire, true, \"7\", \"4\", \"3\", \"0\");\n    createPortAssignment(odata1Port, omWire, true, \"3\", \"0\", \"3\", \"0\");\n    createPortAssignment(odata2Port, omWire, true, \"7\", \"4\", \"3\", \"0\");\n\n    createPortAssignment(topComponent_->getPorts()->value(\"data_to_instance\"), imWire, false, \"7\", \"0\", \"7\", \"0\");\n    createPortAssignment(topComponent_->getPorts()->value(\"data_from_instance\"), omWire, false, \"7\", \"0\", \"7\", \"0\");\n\n    runGenerator(true);\n\n    verifyOutputContains(\"input                [7:0]          data_to_instance\");\n    verifyOutputContains(\"output               [7:0]          data_from_instance\");\n\n    verifyOutputContains(\"wire [7:0] idata_wire;\");\n    verifyOutputContains(\"wire [7:0] odata_wire;\");\n\n    verifyOutputContains(\"wire [3:0] instance1_idata1;\");\n    verifyOutputContains(\"wire [3:0] instance1_idata2\");\n    verifyOutputContains(\"wire [3:0] instance1_odata1;\");\n    verifyOutputContains(\"wire [3:0] instance1_odata2\");\n\n    verifyOutputContains(\"assign data_from_instance = odata_wire;\");\n    verifyOutputContains(\"assign idata_wire = data_to_instance;\");\n\n    verifyOutputContains(\"assign instance1_idata1 = idata_wire[3:0];\");\n    verifyOutputContains(\"assign instance1_idata2[3:0] = idata_wire[7:4];\");\n    verifyOutputContains(\"assign odata_wire[3:0] = instance1_odata1;\");\n    verifyOutputContains(\"assign odata_wire[7:4] = instance1_odata2[3:0];\");\n\n    verifyOutputContains(\n        \"    TestInstance instance1(\\n\"\n        \"        // Interface: data_if\\n\"\n        \"        .idata1              (instance1_idata1),\\n\"\n        \"        .idata2              (instance1_idata2),\\n\"\n        \"        .odata1              (instance1_odata1),\\n\"\n        \"        .odata2              (instance1_odata2)\");\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_VerilogWriterFactory::testTopSlicedHierarchicalConnections()\n//-----------------------------------------------------------------------------\nvoid tst_VerilogWriterFactory::testTopSlicedHierarchicalConnections()\n{\n    QSharedPointer<MetaInterface> topDataIf = addInterfaceToComponent(\"data_if\", topComponent_);\n\n    QSharedPointer<MetaPort> topiData1 = addPort(\"data_to_instance1\", 4, DirectionTypes::IN, topComponent_, topDataIf);\n    QSharedPointer<MetaPort> topiData2 = addPort(\"data_to_instance2\", 4, DirectionTypes::IN, topComponent_, topDataIf);\n    QSharedPointer<MetaPort> topoData1 = addPort(\"data_from_instance1\", 4, DirectionTypes::OUT, topComponent_, topDataIf);\n    QSharedPointer<MetaPort> topoData2 = addPort(\"data_from_instance2\", 4, DirectionTypes::OUT, topComponent_, topDataIf);\n\n    VLNV instanceVlnv(VLNV::COMPONENT, \"Test\", \"TestLibrary\", \"TestInstance\", \"1.0\");\n    QSharedPointer<Component> comp = addTestComponentToLibrary(instanceVlnv);\n    QSharedPointer<MetaInstance> mInstance = addInstanceToDesign(\"instance1\", comp);\n\n    QSharedPointer<MetaInterface> instanceDataIf = addInterfaceToComponent(\"data_if\", mInstance);\n    QSharedPointer<MetaPort> idataPort = addPort(\"idata\", 8, DirectionTypes::IN, mInstance, instanceDataIf);\n    QSharedPointer<MetaPort> odataPort = addPort(\"odata\", 8, DirectionTypes::OUT, mInstance, instanceDataIf);\n\n    QSharedPointer<MetaInterconnection> mI1 = addInterconnectToDesign(topDataIf, instanceDataIf, \"data_connection\");\n    mI1->hierIfs_.append(topDataIf);\n\n    QSharedPointer<MetaWire> imWire = addWireToDesign(\"idata_wire\",\"7\",\"0\",mI1);\n    imWire->hierPorts_.append(topiData1);\n    imWire->hierPorts_.append(topiData2);\n\n    QSharedPointer<MetaWire> omWire = addWireToDesign(\"odata_wire\",\"7\",\"0\",mI1);\n    omWire->hierPorts_.append(topoData1);\n    omWire->hierPorts_.append(topoData2);\n\n    createPortAssignment(idataPort, imWire, true, \"7\", \"0\", \"7\", \"0\");\n    createPortAssignment(odataPort, omWire, true, \"7\", \"0\", \"7\", \"0\");\n\n    createPortAssignment(topiData1, imWire, false, \"3\", \"0\", \"3\", \"0\");\n    createPortAssignment(topiData2, imWire, false, \"7\", \"4\", \"3\", \"0\");\n    createPortAssignment(topoData1, omWire, false, \"3\", \"0\", \"3\", \"0\");\n    createPortAssignment(topoData2, omWire, false, \"7\", \"4\", \"3\", \"0\");\n\n    runGenerator(true);\n\n    verifyOutputContains(\"input                [3:0]          data_to_instance1\");\n    verifyOutputContains(\"input                [3:0]          data_to_instance2\");\n    verifyOutputContains(\"output               [3:0]          data_from_instance1\");\n    verifyOutputContains(\"output               [3:0]          data_from_instance2\");\n\n    verifyOutputContains(\"wire [7:0] idata_wire;\");\n    verifyOutputContains(\"wire [7:0] odata_wire;\");\n\n    verifyOutputContains(\"wire [7:0] instance1_idata;\");\n    verifyOutputContains(\"wire [7:0] instance1_odata;\");\n\n    verifyOutputContains(\"assign data_from_instance1 = odata_wire[3:0];\");\n    verifyOutputContains(\"assign data_from_instance2[3:0] = odata_wire[7:4];\");\n    verifyOutputContains(\"assign idata_wire[3:0] = data_to_instance1;\");\n    verifyOutputContains(\"assign idata_wire[7:4] = data_to_instance2[3:0];\");\n\n    verifyOutputContains(\"assign instance1_idata = idata_wire;\");\n    verifyOutputContains(\"assign odata_wire = instance1_odata;\");\n\n    verifyOutputContains(\n        \"    TestInstance instance1(\\n\"\n        \"        // Interface: data_if\\n\"\n        \"        .idata               (instance1_idata),\\n\"\n        \"        .odata               (instance1_odata)\");\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_VerilogWriterFactory::addInterconnectToDesign()\n//-----------------------------------------------------------------------------\nQSharedPointer<MetaInterconnection> tst_VerilogWriterFactory::addInterconnectToDesign(\n    QSharedPointer<MetaInterface> first, QSharedPointer<MetaInterface> second, QString name)\n{\n    QSharedPointer<MetaInterconnection> mInterconnect(new MetaInterconnection);\n    design_->getInterconnections()->append(mInterconnect);\n    mInterconnect->name_ = name;\n\n    first->upInterconnection_ = mInterconnect;\n    second->upInterconnection_ = mInterconnect;\n\n    return mInterconnect;\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_VerilogWriterFactory::addWireToDesign()\n//-----------------------------------------------------------------------------\nQSharedPointer<MetaWire> tst_VerilogWriterFactory::addWireToDesign(QString name,\n    QString leftBound, QString rightBound, QSharedPointer<MetaInterconnection> mInterconnect)\n{\n    QSharedPointer<MetaWire> gw(new MetaWire);\n    gw->name_ = name;\n    gw->bounds_.first = leftBound;\n    gw->bounds_.second = rightBound;\n\n    if (mInterconnect)\n    {\n        mInterconnect->wires_.insert(gw->name_,gw);\n    }\n    else\n    {\n        design_->getAdHocWires()->append(gw);\n    }\n\n    return gw;\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_VerilogWriterFactory::createPortAssignment()\n//-----------------------------------------------------------------------------\nvoid tst_VerilogWriterFactory::createPortAssignment(QSharedPointer<MetaPort> mPort,\n    QSharedPointer<MetaWire> wire,\n    bool up,\n    QString const& logicalLeft,\n    QString const& logicalRight,\n    QString const& physicalLeft,\n    QString const& physicalRight)\n{\n    QSharedPointer<MetaPortAssignment> mpa(new MetaPortAssignment);\n    mpa->logicalBounds_.first = logicalLeft;\n    mpa->logicalBounds_.second = logicalRight;\n    mpa->physicalBounds_.first = physicalLeft;\n    mpa->physicalBounds_.second = physicalRight;\n    mpa->wire_ = wire;\n    mpa->invert_ = false;\n\n    if (up)\n    {\n        mPort->upAssignments_.insert(wire->name_, mpa);\n    }\n    else\n    {\n        mPort->downAssignments_.insert(wire->name_, mpa);\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_VerilogWriterFactory::addInterfaceToComponent()\n//-----------------------------------------------------------------------------\nQSharedPointer<MetaInterface> tst_VerilogWriterFactory::addInterfaceToComponent(QString const& interfaceName,\n    QSharedPointer<MetaInstance> component)\n{\n    QSharedPointer<MetaInterface> mInterface(new MetaInterface());\n    component->getInterfaces()->insert(interfaceName,mInterface);\n\n    QSharedPointer<BusInterface> bi = QSharedPointer<BusInterface>(new BusInterface);\n    bi->setName(interfaceName);\n    mInterface->interface_ = bi;\n    component->getComponent()->getBusInterfaces()->append(bi);\n\n    QSharedPointer<AbstractionType> at = QSharedPointer<AbstractionType>(new AbstractionType);\n    bi->getAbstractionTypes()->append(at);\n\n    return mInterface;\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_VerilogWriterFactory::addTestComponentToLibrary()\n//-----------------------------------------------------------------------------\nQSharedPointer<Component> tst_VerilogWriterFactory::addTestComponentToLibrary(VLNV vlnv)\n{\n    QSharedPointer<Component> instanceComponent(new Component(vlnv, Document::Revision::Std14));\n\n    library_.addComponent(instanceComponent);\n\n\treturn instanceComponent;\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_VerilogWriterFactory::addInstanceToDesign()\n//-----------------------------------------------------------------------------\nQSharedPointer<MetaInstance> tst_VerilogWriterFactory::addInstanceToDesign(QString instanceName,\n    QSharedPointer<Component> component)\n{\n    QSharedPointer<ConfigurableVLNVReference> componentVLNV (new ConfigurableVLNVReference(component->getVlnv()));\n    QSharedPointer<ComponentInstance> instance (new ComponentInstance(instanceName, componentVLNV));\n\n    MessagePasser messages;\n\n    QSharedPointer<MetaInstance> mInstance(new MetaInstance(instance,\n        &library_, &messages, component, QSharedPointer<View>()));\n    mInstance->parseInstance();\n\n    design_->getInstances()->insert(instanceName, mInstance);\n\n\treturn mInstance;\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_VerilogWriterFactory::addInterfacesToInstance()\n//-----------------------------------------------------------------------------\nvoid tst_VerilogWriterFactory::addInterfacesToInstance(QSharedPointer<MetaInstance> mInstance)\n{\n    QSharedPointer<MetaInterface> mClkInterface = addInterfaceToComponent(\"clk_if\", mInstance);\n\n    QSharedPointer<MetaPort> mPort = addPort(\"clk\", 1, DirectionTypes::IN, mInstance, mClkInterface);\n\n    QSharedPointer<MetaInterface> mDataInterface = addInterfaceToComponent(\"data_if\", mInstance);\n\n    mPort = addPort(\"data_in\", 8, DirectionTypes::IN, mInstance, mDataInterface);\n    mPort = addPort(\"enable\", 1, DirectionTypes::IN, mInstance, mDataInterface);\n    mPort = addPort(\"full\", 1, DirectionTypes::OUT, mInstance, mDataInterface);\n\n    mPort = addPort(\"data_out\", 8, DirectionTypes::OUT, mInstance);\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_VerilogWriterFactory::testMasterToSlaveInterconnection()\n//-----------------------------------------------------------------------------\nvoid tst_VerilogWriterFactory::testMasterToSlaveInterconnection()\n{\n    QSharedPointer<MetaInstance> senderInstance = addSender(\"sender\");\n    QSharedPointer<MetaInstance> receiverInstance = addReceiver(\"receiver\");\n\n    QSharedPointer<MetaInterface> senderIf = senderInstance->getInterfaces()->value(\"data_if\");\n    QSharedPointer<MetaInterface> recvIf = receiverInstance->getInterfaces()->value(\"data_if\");\n\n    QSharedPointer<MetaInterconnection> mInterconnect = \n        addInterconnectToDesign(senderIf, recvIf, \"data_connection\");\n\n    QSharedPointer<MetaWire> dataWire = addWireToDesign(\"sender_to_receiver_DATA\",\"7\",\"0\",mInterconnect);\n    QSharedPointer<MetaWire> enaWire = addWireToDesign(\"sender_to_receiver_ENABLE\",\"0\",\"0\",mInterconnect);\n\n    createPortAssignment(receiverInstance->getPorts()->value(\"data_in\"), dataWire, true, \"7\", \"0\", \"7\", \"0\");\n    createPortAssignment(receiverInstance->getPorts()->value(\"enable_in\"), enaWire, true, \"0\", \"0\", \"0\", \"0\");\n\n    createPortAssignment(senderInstance->getPorts()->value(\"data_out\"), dataWire, true, \"7\", \"0\", \"7\", \"0\");\n    createPortAssignment(senderInstance->getPorts()->value(\"enable_out\"), enaWire, true, \"0\", \"0\", \"0\", \"0\");\n\n    runGenerator(true);\n\n    verifyOutputContains(\"wire [7:0] sender_to_receiver_DATA;\");\n    verifyOutputContains(\"wire       sender_to_receiver_ENABLE;\");\n\n    verifyOutputContains(\"wire [7:0] receiver_data_in;\");\n    verifyOutputContains(\"wire       receiver_enable_in;\");\n    verifyOutputContains(\"wire [7:0] sender_data_out;\");\n    verifyOutputContains(\"wire       sender_enable_out;\");\n\n    verifyOutputContains(\"assign receiver_data_in = sender_to_receiver_DATA;\");\n    verifyOutputContains(\"assign receiver_enable_in = sender_to_receiver_ENABLE;\");\n    verifyOutputContains(\"assign sender_to_receiver_DATA = sender_data_out;\");\n    verifyOutputContains(\"assign sender_to_receiver_ENABLE = sender_enable_out;\");\n\n    verifyOutputContains(\n        \"    TestReceiver receiver(\\n\"\n        \"        // Interface: data_if\\n\"\n        \"        .data_in             (receiver_data_in),\\n\"\n        \"        .enable_in           (receiver_enable_in)\");\n\n    verifyOutputContains(\n        \"    TestSender sender(\\n\"\n        \"        // Interface: data_if\\n\"\n        \"        .data_out            (sender_data_out),\\n\"\n        \"        .enable_out          (sender_enable_out)\");\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_VerilogWriterFactory::testOneBitSlicing()\n//-----------------------------------------------------------------------------\nvoid tst_VerilogWriterFactory::testOneBitSlicing()\n{\n    QSharedPointer<MetaInstance> senderInstance = addSender(\"sender\");\n    QSharedPointer<MetaInstance> receiverInstance = addReceiver(\"receiver\");\n\n    QSharedPointer<MetaInterface> senderIf = senderInstance->getInterfaces()->value(\"data_if\");\n    QSharedPointer<MetaInterface> recvIf = receiverInstance->getInterfaces()->value(\"data_if\");\n\n    QSharedPointer<MetaInterconnection> mInterconnect =\n        addInterconnectToDesign(senderIf, recvIf, \"data_connection\");\n\n    QSharedPointer<MetaWire> dataWire = addWireToDesign(\"sender_to_receiver_DATA\",\"7\",\"0\",mInterconnect);\n\n    createPortAssignment(receiverInstance->getPorts()->value(\"data_in\"), dataWire, true, \"5\", \"5\", \"7\", \"7\");\n\n    createPortAssignment(senderInstance->getPorts()->value(\"data_out\"), dataWire, true, \"5\", \"5\", \"6\", \"6\");\n\n    runGenerator(true);\n\n    verifyOutputContains(\"wire [7:0] sender_to_receiver_DATA;\");\n\n    verifyOutputContains(\"wire [7:0] receiver_data_in;\");\n    verifyOutputContains(\"wire [7:0] sender_data_out;\");\n\n    verifyOutputContains(\"assign receiver_data_in[7] = sender_to_receiver_DATA[5];\");\n    verifyOutputContains(\"assign sender_to_receiver_DATA[5] = sender_data_out[6];\");\n\n    verifyOutputContains(\n        \"    TestReceiver receiver(\\n\"\n        \"        // Interface: data_if\\n\"\n        \"        .data_in             (receiver_data_in),\\n\"\n        \"        .enable_in           ()\");\n\n    verifyOutputContains(\n        \"    TestSender sender(\\n\"\n        \"        // Interface: data_if\\n\"\n        \"        .data_out            (sender_data_out),\\n\"\n        \"        .enable_out          ()\");\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_VerilogWriterFactory::testPhysicalSlicedMasterToSlaveInterconnection()\n//-----------------------------------------------------------------------------\nvoid tst_VerilogWriterFactory::testPhysicalSlicedMasterToSlaveInterconnection()\n{\n    QSharedPointer<MetaInstance> senderInstance = addSender(\"sender\");\n    QSharedPointer<MetaInstance> receiverInstance = addReceiver(\"receiver\");\n\n    QSharedPointer<MetaInterface> senderIf = senderInstance->getInterfaces()->value(\"data_if\");\n    QSharedPointer<MetaInterface> recvIf = receiverInstance->getInterfaces()->value(\"data_if\");\n\n    QSharedPointer<MetaInterconnection> mInterconnect =\n        addInterconnectToDesign(senderIf, recvIf, \"data_connection\");\n\n    QSharedPointer<MetaWire> dataWire = addWireToDesign(\"sender_to_receiver_DATA\",\"7\",\"0\",mInterconnect);\n    QSharedPointer<MetaWire> enaWire = addWireToDesign(\"sender_to_receiver_ENABLE\",\"0\",\"0\",mInterconnect);\n\n    createPortAssignment(receiverInstance->getPorts()->value(\"data_in\"), dataWire, true, \"7\", \"4\", \"7\", \"4\");\n    createPortAssignment(receiverInstance->getPorts()->value(\"data_in\"), dataWire, true, \"3\", \"0\", \"3\", \"0\");\n    createPortAssignment(receiverInstance->getPorts()->value(\"enable_in\"), enaWire, true, \"0\", \"0\", \"0\", \"0\");\n\n    createPortAssignment(senderInstance->getPorts()->value(\"data_out\"), dataWire, true, \"7\", \"4\", \"7\", \"4\");\n    createPortAssignment(senderInstance->getPorts()->value(\"data_out\"), dataWire, true, \"3\", \"0\", \"3\", \"0\");\n    createPortAssignment(senderInstance->getPorts()->value(\"enable_out\"), enaWire, true, \"0\", \"0\", \"0\", \"0\");\n\n    runGenerator(true);\n\n    verifyOutputContains(\"wire [7:0] sender_to_receiver_DATA;\");\n    verifyOutputContains(\"wire       sender_to_receiver_ENABLE;\");\n\n    verifyOutputContains(\"wire [7:0] receiver_data_in;\");\n    verifyOutputContains(\"wire       receiver_enable_in;\");\n    verifyOutputContains(\"wire [7:0] sender_data_out;\");\n    verifyOutputContains(\"wire       sender_enable_out;\");\n\n    verifyOutputContains(\"assign receiver_data_in[3:0] = sender_to_receiver_DATA[3:0];\");\n    verifyOutputContains(\"assign receiver_data_in[7:4] = sender_to_receiver_DATA[7:4];\");\n    verifyOutputContains(\"assign receiver_enable_in = sender_to_receiver_ENABLE;\");\n    verifyOutputContains(\"assign sender_to_receiver_DATA[3:0] = sender_data_out[3:0];\");\n    verifyOutputContains(\"assign sender_to_receiver_DATA[7:4] = sender_data_out[7:4];\");\n    verifyOutputContains(\"assign sender_to_receiver_ENABLE = sender_enable_out;\");\n\n    verifyOutputContains(\n        \"    TestReceiver receiver(\\n\"\n        \"        // Interface: data_if\\n\"\n        \"        .data_in             (receiver_data_in),\\n\"\n        \"        .enable_in           (receiver_enable_in)\");\n\n    verifyOutputContains(\n        \"    TestSender sender(\\n\"\n        \"        // Interface: data_if\\n\"\n        \"        .data_out            (sender_data_out),\\n\"\n        \"        .enable_out          (sender_enable_out)\");\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_VerilogWriterFactory::testLogicalSlicedMasterToSlaveInterconnection()\n//-----------------------------------------------------------------------------\nvoid tst_VerilogWriterFactory::testLogicalSlicedMasterToSlaveInterconnection()\n{\n    QSharedPointer<MetaInstance> senderInstance = addSender(\"sender\");\n    QSharedPointer<MetaInstance> receiverInstance = addReceiver(\"receiver\");\n\n    QSharedPointer<MetaInterface> senderIf = senderInstance->getInterfaces()->value(\"data_if\");\n    QSharedPointer<MetaInterface> recvIf = receiverInstance->getInterfaces()->value(\"data_if\");\n\n    QSharedPointer<MetaInterconnection> mInterconnect =\n        addInterconnectToDesign(senderIf, recvIf, \"data_connection\");\n\n    QSharedPointer<MetaWire> dataWire1 = addWireToDesign(\"sender_to_receiver_DATA1\",\"3\",\"0\",mInterconnect);\n    QSharedPointer<MetaWire> dataWire2 = addWireToDesign(\"sender_to_receiver_DATA2\",\"3\",\"0\",mInterconnect);\n    QSharedPointer<MetaWire> enaWire = addWireToDesign(\"sender_to_receiver_ENABLE\",\"0\",\"0\",mInterconnect);\n\n    createPortAssignment(receiverInstance->getPorts()->value(\"data_in\"), dataWire1, true, \"3\", \"0\", \"3\", \"0\");\n    createPortAssignment(receiverInstance->getPorts()->value(\"data_in\"), dataWire2, true, \"3\", \"0\", \"7\", \"4\");\n    createPortAssignment(receiverInstance->getPorts()->value(\"enable_in\"), enaWire, true, \"0\", \"0\", \"0\", \"0\");\n\n    createPortAssignment(senderInstance->getPorts()->value(\"data_out\"), dataWire1, true, \"3\", \"0\", \"3\", \"0\");\n    createPortAssignment(senderInstance->getPorts()->value(\"data_out\"), dataWire2, true, \"3\", \"0\", \"7\", \"4\");\n    createPortAssignment(senderInstance->getPorts()->value(\"enable_out\"), enaWire, true, \"0\", \"0\", \"0\", \"0\");\n\n    runGenerator(true);\n\n    verifyOutputContains(\"wire [3:0] sender_to_receiver_DATA1;\");\n    verifyOutputContains(\"wire [3:0] sender_to_receiver_DATA2;\");\n    verifyOutputContains(\"wire       sender_to_receiver_ENABLE;\");\n\n    verifyOutputContains(\"wire [7:0] receiver_data_in;\");\n    verifyOutputContains(\"wire       receiver_enable_in;\");\n    verifyOutputContains(\"wire [7:0] sender_data_out;\");\n    verifyOutputContains(\"wire       sender_enable_out;\");\n\n    verifyOutputContains(\"assign receiver_data_in[3:0] = sender_to_receiver_DATA1;\");\n    verifyOutputContains(\"assign receiver_data_in[7:4] = sender_to_receiver_DATA2;\");\n    verifyOutputContains(\"assign receiver_enable_in = sender_to_receiver_ENABLE;\");\n    verifyOutputContains(\"assign sender_to_receiver_DATA1 = sender_data_out[3:0];\");\n    verifyOutputContains(\"assign sender_to_receiver_DATA2 = sender_data_out[7:4];\");\n    verifyOutputContains(\"assign sender_to_receiver_ENABLE = sender_enable_out;\");\n\n    verifyOutputContains(\n        \"    TestReceiver receiver(\\n\"\n        \"        // Interface: data_if\\n\"\n        \"        .data_in             (receiver_data_in),\\n\"\n        \"        .enable_in           (receiver_enable_in)\");\n\n    verifyOutputContains(\n        \"    TestSender sender(\\n\"\n        \"        // Interface: data_if\\n\"\n        \"        .data_out            (sender_data_out),\\n\"\n        \"        .enable_out          (sender_enable_out)\");\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_VerilogWriterFactory::testLogicalSlicedMasterToMultiplePortsInSlave()\n//-----------------------------------------------------------------------------\nvoid tst_VerilogWriterFactory::testLogicalSlicedMasterToMultiplePortsInSlave()\n{\n    QSharedPointer<Component> topComponent = createComponent(\"topComponent\");\n    QSharedPointer<Design> topDesign = createDesignForComponent(\"topDesign\", topComponent);\n\n    QSharedPointer<BusDefinition> busDefinition = createBusDefinition(\"testBus\");\n    QSharedPointer<AbstractionDefinition> abstractionDefinition = createAbstractionDefinition(\"testAbstraction\");\n\n    QSharedPointer<PortAbstraction> logicalData = addLogicalPortToAbstraction(\"DATA\", abstractionDefinition,\n        General::SYSTEM, TransactionalTypes::Initiative::INITIATIVE_INVALID, DirectionTypes::IN);\n\n    QSharedPointer<Component> instanceComponent = createComponent(\"Receiver\");\n\n    QSharedPointer<BusInterface> topBus = addBusInterfaceToComponent(\n        \"topBus\", topComponent, General::SYSTEM, busDefinition, abstractionDefinition);\n    QSharedPointer<BusInterface> instanceBus = addBusInterfaceToComponent(\n        \"instanceBus\", instanceComponent, General::SYSTEM, busDefinition, abstractionDefinition);\n\n\n    QSharedPointer<Port> topPort = addPortToComponent(\n        \"topPort\", topComponent, TransactionalTypes::Initiative::INITIATIVE_INVALID, DirectionTypes::IN);\n    QSharedPointer<Port> dataPort0 = addPortToComponent(\n        \"data0\", instanceComponent, TransactionalTypes::Initiative::INITIATIVE_INVALID, DirectionTypes::IN);\n    QSharedPointer<Port> dataPort1 = addPortToComponent(\n        \"data1\", instanceComponent, TransactionalTypes::Initiative::INITIATIVE_INVALID, DirectionTypes::IN);\n    QSharedPointer<Port> dataPort2 = addPortToComponent(\n        \"data2\", instanceComponent, TransactionalTypes::Initiative::INITIATIVE_INVALID, DirectionTypes::IN);\n\n    topPort->setLeftBound(\"2\");\n    topPort->setRightBound(\"0\");\n\n    dataPort0->setLeftBound(\"0\");\n    dataPort0->setRightBound(\"0\");\n    dataPort1->setLeftBound(\"0\");\n    dataPort1->setRightBound(\"0\");\n    dataPort2->setLeftBound(\"0\");\n    dataPort2->setRightBound(\"0\");\n\n    mapPortsToBusInterface(topBus, topPort, logicalData);\n\n    QList<QSharedPointer<Port> > dataPorts;\n    dataPorts.append(dataPort0);\n    dataPorts.append(dataPort1);\n    dataPorts.append(dataPort2);\n\n    mapMultiplePortsToBusInterface(instanceBus, dataPorts, logicalData);\n\n    QSharedPointer<ComponentInstance> targetInstance = addInstanceToDesign(topDesign, instanceComponent);\n\n    QSharedPointer<Interconnection> wireConnection = addHierarchicalInterconnectionToDesign(\n        \"wireConnection\", topDesign, topBus->name(), instanceBus->name(), targetInstance->getInstanceName());\n\n    MessagePasser messages;\n\n    connect(&messages, SIGNAL(errorMessage(const QString&)),\n        this, SLOT(gatherErrorMessage(QString const&)), Qt::UniqueConnection);\n\n    GenerationTuple input;\n    input.component = topComponent;\n    input.design = topDesign;\n    input.messages = &messages;\n\n    QList<QSharedPointer<MetaDesign> > designs =\n        MetaDesign::parseHierarchy(&library_, input, topComponent->getViews()->first());\n\n    QCOMPARE(designs.size(), 1);\n\n    design_ = designs.first();\n    runGenerator(true);\n\n    output_;\n\n    verifyOutputContains(\"input                [2:0]          topPort\");\n\n    verifyOutputContains(\"wire [2:0] wireConnection_DATA;\");\n\n    verifyOutputContains(\"wire       Receiver_instance_data0;\");\n\n    verifyOutputContains(\"assign wireConnection_DATA = topPort;\");\n    verifyOutputContains(\"assign Receiver_instance_data0 = wireConnection_DATA[0];\");\n    verifyOutputContains(\"assign Receiver_instance_data1 = wireConnection_DATA[1];\");\n    verifyOutputContains(\"assign Receiver_instance_data2 = wireConnection_DATA[2];\");\n\n    verifyOutputContains(\n        \"    Receiver Receiver_instance(\\n\"\n        \"        // Interface: instanceBus\\n\"\n        \"        .data0               (Receiver_instance_data0),\\n\"\n        \"        .data1               (Receiver_instance_data1),\\n\"\n        \"        .data2               (Receiver_instance_data2));\");\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_VerilogWriterFactory::testHierarchicalInOutConnectionWithMultiplePorts()\n//-----------------------------------------------------------------------------\nvoid tst_VerilogWriterFactory::testHierarchicalInOutConnectionWithMultiplePorts()\n{\n    QSharedPointer<Component> topComponent = createComponent(\"topComponent\");\n    QSharedPointer<Design> topDesign = createDesignForComponent(\"topDesign\", topComponent);\n\n    QString systemName(\"external_pad\");\n    QStringList systemGroups;\n    systemGroups.append(systemName);\n\n    QSharedPointer<BusDefinition> busDefinition = createBusDefinition(\"testBus\");\n    busDefinition->setSystemGroupNames(systemGroups);\n    QSharedPointer<AbstractionDefinition> abstractionDefinition = createAbstractionDefinition(\"testAbstraction\");\n\n    QSharedPointer<PortAbstraction> logicalCSN = addLogicalPortToAbstraction(\"CSN\", abstractionDefinition,\n        General::SYSTEM, TransactionalTypes::Initiative::INITIATIVE_INVALID, DirectionTypes::INOUT, systemName);\n    QSharedPointer<PortAbstraction> logicalDATA = addLogicalPortToAbstraction(\"DATA\", abstractionDefinition,\n        General::SYSTEM, TransactionalTypes::Initiative::INITIATIVE_INVALID, DirectionTypes::INOUT, systemName);\n    QSharedPointer<PortAbstraction> logicalSCK = addLogicalPortToAbstraction(\"SCK\", abstractionDefinition,\n        General::SYSTEM, TransactionalTypes::Initiative::INITIATIVE_INVALID, DirectionTypes::INOUT, systemName);\n\n    logicalCSN->getWire()->getSystemPorts()->first()->setWidth(\"2\");\n    logicalCSN->getWire()->getSystemPorts()->first()->setPresence(PresenceTypes::REQUIRED);\n    logicalDATA->getWire()->getSystemPorts()->first()->setWidth(\"4\");\n    logicalDATA->getWire()->getSystemPorts()->first()->setPresence(PresenceTypes::REQUIRED);\n    logicalSCK->getWire()->getSystemPorts()->first()->setWidth(\"1\");\n    logicalSCK->getWire()->getSystemPorts()->first()->setPresence(PresenceTypes::REQUIRED);\n\n    QSharedPointer<Port> topPortDATA0 = addPortToComponent(\n        \"topPortDATA0\", topComponent, TransactionalTypes::Initiative::INITIATIVE_INVALID, DirectionTypes::INOUT);\n    topPortDATA0->setTypeName(\"wire\");\n    topPortDATA0->setPortSize(1);\n\n    QSharedPointer<Port> topPortDATA1 = addPortToComponent(\n        \"topPortDATA1\", topComponent, TransactionalTypes::Initiative::INITIATIVE_INVALID, DirectionTypes::INOUT);\n    topPortDATA1->setTypeName(\"wire\");\n    topPortDATA1->setPortSize(1);\n\n    QSharedPointer<Port> topPortDATA2 = addPortToComponent(\n        \"topPortDATA2\", topComponent, TransactionalTypes::Initiative::INITIATIVE_INVALID, DirectionTypes::INOUT);\n    topPortDATA2->setTypeName(\"wire\");\n    topPortDATA2->setPortSize(1);\n\n    QSharedPointer<Port> topPortDATA3 = addPortToComponent(\n        \"topPortDATA3\", topComponent, TransactionalTypes::Initiative::INITIATIVE_INVALID, DirectionTypes::INOUT);\n    topPortDATA3->setTypeName(\"wire\");\n    topPortDATA3->setPortSize(1);\n\n    QSharedPointer<Port> topPortCSN1 = addPortToComponent(\n        \"topPortCSN1\", topComponent, TransactionalTypes::Initiative::INITIATIVE_INVALID, DirectionTypes::INOUT);\n    topPortCSN1->setTypeName(\"wire\");\n    topPortCSN1->setPortSize(1);\n\n    QSharedPointer<Port> topPortCSN2 = addPortToComponent(\n        \"topPortCSN2\", topComponent, TransactionalTypes::Initiative::INITIATIVE_INVALID, DirectionTypes::INOUT);\n    topPortCSN2->setTypeName(\"wire\");\n    topPortCSN2->setPortSize(1);\n\n    QSharedPointer<Port> topPortCLK = addPortToComponent(\n        \"topPortCLK\", topComponent, TransactionalTypes::Initiative::INITIATIVE_INVALID, DirectionTypes::INOUT);\n    topPortCLK->setTypeName(\"wire\");\n    topPortCLK->setPortSize(1);\n\n    QSharedPointer<BusInterface> topBus = addBusInterfaceToComponent(\n        \"topBus\", topComponent, General::SYSTEM, busDefinition, abstractionDefinition, systemName);\n\n    QList<QSharedPointer<Port> > csnPorts;\n    csnPorts.append(topPortCSN1);\n    csnPorts.append(topPortCSN2);\n\n    QList<QSharedPointer<Port> > dataPorts;\n    dataPorts.append(topPortDATA0);\n    dataPorts.append(topPortDATA1);\n    dataPorts.append(topPortDATA2);\n    dataPorts.append(topPortDATA3);\n\n    QList<QSharedPointer<Port> > sckPorts;\n    sckPorts.append(topPortCLK);\n\n    mapMultiplePortsToBusInterface(topBus, csnPorts, logicalCSN);\n    mapMultiplePortsToBusInterface(topBus, dataPorts, logicalDATA);\n    mapMultiplePortsToBusInterface(topBus, sckPorts, logicalSCK);\n\n    QSharedPointer<Component> instanceComponent = createComponent(\"Receiver\");\n\n    QSharedPointer<Port> instanceCSN0 = addPortToComponent(\n        \"instanceCSN0\", instanceComponent, TransactionalTypes::Initiative::INITIATIVE_INVALID, DirectionTypes::INOUT);\n    instanceCSN0->setTypeName(\"wire\");\n    instanceCSN0->setPortSize(1);\n\n    QSharedPointer<Port> instanceCSN1 = addPortToComponent(\n        \"instanceCSN1\", instanceComponent, TransactionalTypes::Initiative::INITIATIVE_INVALID, DirectionTypes::INOUT);\n    instanceCSN1->setTypeName(\"wire\");\n    instanceCSN1->setPortSize(1);\n\n    QSharedPointer<Port> instanceDATA0 = addPortToComponent(\n        \"instanceDATA0\", instanceComponent, TransactionalTypes::Initiative::INITIATIVE_INVALID, DirectionTypes::INOUT);\n    instanceDATA0->setTypeName(\"wire\");\n    instanceDATA0->setPortSize(1);\n\n    QSharedPointer<Port> instanceDATA1 = addPortToComponent(\n        \"instanceDATA1\", instanceComponent, TransactionalTypes::Initiative::INITIATIVE_INVALID, DirectionTypes::INOUT);\n    instanceDATA1->setTypeName(\"wire\");\n    instanceDATA1->setPortSize(1);\n\n    QSharedPointer<Port> instanceDATA2 = addPortToComponent(\n        \"instanceDATA2\", instanceComponent, TransactionalTypes::Initiative::INITIATIVE_INVALID, DirectionTypes::INOUT);\n    instanceDATA2->setTypeName(\"wire\");\n    instanceDATA2->setPortSize(1);\n\n    QSharedPointer<Port> instanceDATA3 = addPortToComponent(\n        \"instanceDATA3\", instanceComponent, TransactionalTypes::Initiative::INITIATIVE_INVALID, DirectionTypes::INOUT);\n    instanceDATA3->setTypeName(\"wire\");\n    instanceDATA3->setPortSize(1);\n\n    QSharedPointer<Port> instanceSCK = addPortToComponent(\n        \"instanceSCK\", instanceComponent, TransactionalTypes::Initiative::INITIATIVE_INVALID, DirectionTypes::INOUT);\n    instanceSCK->setTypeName(\"wire\");\n    instanceSCK->setPortSize(1);\n\n    QSharedPointer<BusInterface> instanceBus = addBusInterfaceToComponent(\n        \"pads\", instanceComponent, General::SYSTEM, busDefinition, abstractionDefinition, systemName);\n\n    QList<QSharedPointer<Port> > instanceCSNPorts;\n    instanceCSNPorts.append(instanceCSN0);\n    instanceCSNPorts.append(instanceCSN1);\n\n    QList<QSharedPointer<Port> > instanceDATAPorts;\n    instanceDATAPorts.append(instanceDATA0);\n    instanceDATAPorts.append(instanceDATA1);\n    instanceDATAPorts.append(instanceDATA2);\n    instanceDATAPorts.append(instanceDATA3);\n\n    QList<QSharedPointer<Port> > instanceSCKPorts;\n    instanceSCKPorts.append(instanceSCK);\n\n    mapMultiplePortsToBusInterface(instanceBus, instanceCSNPorts, logicalCSN);\n    mapMultiplePortsToBusInterface(instanceBus, instanceDATAPorts, logicalDATA);\n    mapMultiplePortsToBusInterface(instanceBus, instanceSCKPorts, logicalSCK);\n\n    QSharedPointer<ComponentInstance> targetInstance = addInstanceToDesign(topDesign, instanceComponent);\n\n    QSharedPointer<Interconnection> wireConnection = addHierarchicalInterconnectionToDesign(\n        \"wireConnection\", topDesign, topBus->name(), instanceBus->name(), targetInstance->getInstanceName());\n\n    MessagePasser messages;\n\n    connect(&messages, SIGNAL(errorMessage(const QString&)),\n        this, SLOT(gatherErrorMessage(QString const&)), Qt::UniqueConnection);\n\n    GenerationTuple input;\n    input.component = topComponent;\n    input.design = topDesign;\n    input.messages = &messages;\n\n    QList<QSharedPointer<MetaDesign> > designs =\n        MetaDesign::parseHierarchy(&library_, input, topComponent->getViews()->first());\n\n    QCOMPARE(designs.size(), 1);\n\n    design_ = designs.first();\n    runGenerator(true);\n\n    output_;\n\n    verifyOutputContains(\n        \"    Receiver Receiver_instance(\\n\"\n        \"        // Interface: pads\\n\"\n        \"        .instanceCSN0        (topPortCSN1),\\n\"\n        \"        .instanceCSN1        (topPortCSN2),\\n\"\n        \"        .instanceDATA0       (topPortDATA0),\\n\"\n        \"        .instanceDATA1       (topPortDATA1),\\n\"\n        \"        .instanceDATA2       (topPortDATA2),\\n\"\n        \"        .instanceDATA3       (topPortDATA3),\\n\"\n        \"        .instanceSCK         (topPortCLK));\");\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_VerilogWriterFactory::testPortSlicedMasterToSlaveInterconnection()\n//-----------------------------------------------------------------------------\nvoid tst_VerilogWriterFactory::testPortSlicedMasterToSlaveInterconnection()\n{\n    QSharedPointer<MetaInstance> senderInstance = addSender(\"sender\");\n    QSharedPointer<MetaInstance> receiverInstance = addReceiver(\"receiver\");\n\n    QSharedPointer<MetaInterface> senderIf = senderInstance->getInterfaces()->value(\"data_if\");\n    addPort(\"data_out2\", 4, DirectionTypes::OUT, senderInstance, senderIf);\n    QSharedPointer<MetaInterface> recvIf = receiverInstance->getInterfaces()->value(\"data_if\");\n    addPort(\"data_in2\", 4, DirectionTypes::IN, receiverInstance, recvIf);\n\n    QSharedPointer<MetaInterconnection> mInterconnect =\n        addInterconnectToDesign(senderIf, recvIf, \"data_connection\");\n\n    QSharedPointer<MetaWire> dataWire = addWireToDesign(\"sender_to_receiver_DATA\",\"7\",\"0\",mInterconnect);\n    QSharedPointer<MetaWire> enaWire = addWireToDesign(\"sender_to_receiver_ENABLE\",\"0\",\"0\",mInterconnect);\n\n    createPortAssignment(receiverInstance->getPorts()->value(\"data_in\"), dataWire, true, \"7\", \"4\", \"3\", \"0\");\n    createPortAssignment(receiverInstance->getPorts()->value(\"data_in2\"), dataWire, true, \"3\", \"0\", \"3\", \"0\");\n    createPortAssignment(receiverInstance->getPorts()->value(\"enable_in\"), enaWire, true, \"0\", \"0\", \"0\", \"0\");\n\n    createPortAssignment(senderInstance->getPorts()->value(\"data_out\"), dataWire, true, \"7\", \"4\", \"3\", \"0\");\n    createPortAssignment(senderInstance->getPorts()->value(\"data_out2\"), dataWire, true, \"3\", \"0\", \"3\", \"0\");\n    createPortAssignment(senderInstance->getPorts()->value(\"enable_out\"), enaWire, true, \"0\", \"0\", \"0\", \"0\");\n\n    runGenerator(true);\n\n    verifyOutputContains(\"wire [7:0] sender_to_receiver_DATA;\");\n    verifyOutputContains(\"wire       sender_to_receiver_ENABLE;\");\n\n    verifyOutputContains(\"wire [7:0] receiver_data_in;\");\n    verifyOutputContains(\"wire [3:0] receiver_data_in2;\");\n    verifyOutputContains(\"wire       receiver_enable_in;\");\n    verifyOutputContains(\"wire [7:0] sender_data_out;\");\n    verifyOutputContains(\"wire [3:0] sender_data_out2;\");\n    verifyOutputContains(\"wire       sender_enable_out;\");\n\n    verifyOutputContains(\"assign receiver_data_in[3:0] = sender_to_receiver_DATA[7:4];\");\n    verifyOutputContains(\"assign receiver_data_in2 = sender_to_receiver_DATA[3:0];\");\n    verifyOutputContains(\"assign receiver_enable_in = sender_to_receiver_ENABLE;\");\n    verifyOutputContains(\"assign sender_to_receiver_DATA[7:4] = sender_data_out[3:0];\");\n    verifyOutputContains(\"assign sender_to_receiver_DATA[3:0] = sender_data_out2;\");\n    verifyOutputContains(\"assign sender_to_receiver_ENABLE = sender_enable_out;\");\n\n    verifyOutputContains(\n        \"    TestReceiver receiver(\\n\"\n        \"        // Interface: data_if\\n\"\n        \"        .data_in             (receiver_data_in),\\n\"\n        \"        .data_in2            (receiver_data_in2),\\n\"\n        \"        .enable_in           (receiver_enable_in)\");\n\n    verifyOutputContains(\n        \"    TestSender sender(\\n\"\n        \"        // Interface: data_if\\n\"\n        \"        .data_out            (sender_data_out),\\n\"\n        \"        .data_out2           (sender_data_out2),\\n\"\n        \"        .enable_out          (sender_enable_out)\");\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_VerilogWriterFactory::addSender()\n//-----------------------------------------------------------------------------\nQSharedPointer<MetaInstance> tst_VerilogWriterFactory::addSender(QString const& instanceName)\n{\n    VLNV senderVLNV(VLNV::COMPONENT, \"Test\", \"TestLibrary\", \"TestSender\", \"1.0\");\n    QSharedPointer<Component> comp = addTestComponentToLibrary(senderVLNV);\n    QSharedPointer<MetaInstance> mInstance = addInstanceToDesign(instanceName, comp);\n\n    QSharedPointer<MetaInterface> mInterface = addInterfaceToComponent(\"data_if\", mInstance);\n    mInterface->interface_->setInterfaceMode(General::MASTER);    \n    QSharedPointer<MetaPort> mPort = addPort(\"enable_out\", 1, DirectionTypes::OUT, mInstance, mInterface);\n    mPort = addPort(\"data_out\", 8, DirectionTypes::OUT, mInstance, mInterface);\n\n\treturn mInstance;\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_VerilogWriterFactory::addReceiver()\n//-----------------------------------------------------------------------------\nQSharedPointer<MetaInstance> tst_VerilogWriterFactory::addReceiver(QString const& instanceName)\n{\n    VLNV receiverVLNV(VLNV::COMPONENT, \"Test\", \"TestLibrary\", \"TestReceiver\", \"1.0\");\n    QSharedPointer<Component> comp = addTestComponentToLibrary(receiverVLNV);\n    QSharedPointer<MetaInstance> mInstance = addInstanceToDesign(instanceName, comp);\n\n    QSharedPointer<MetaInterface> mInterface = addInterfaceToComponent(\"data_if\", mInstance);\n    mInterface->interface_->setInterfaceMode(General::SLAVE);    \n    QSharedPointer<MetaPort> gp = addPort(\"enable_in\", 1, DirectionTypes::IN, mInstance, mInterface);\n    gp = addPort(\"data_in\", 8, DirectionTypes::IN, mInstance, mInterface);\n\n    return mInstance;\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_VerilogWriterFactory::testMasterToMultipleSlavesInterconnections()\n//-----------------------------------------------------------------------------\nvoid tst_VerilogWriterFactory::testMasterToMultipleSlavesInterconnections()\n{\n    QSharedPointer<MetaInstance> senderInstance = addSender(\"sender\");\n    QSharedPointer<MetaInstance> receiverInstance1 = addReceiver(\"receiver1\");\n    QSharedPointer<MetaInstance> receiverInstance2 = addReceiver(\"receiver2\");\n\n    QSharedPointer<MetaInterface> senderIf = senderInstance->getInterfaces()->value(\"data_if\");\n    QSharedPointer<MetaInterface> recvIf1 = receiverInstance1->getInterfaces()->value(\"data_if\");\n    QSharedPointer<MetaInterface> recvIf2 = receiverInstance2->getInterfaces()->value(\"data_if\");\n\n    QSharedPointer<MetaInterconnection> data_connection =\n        addInterconnectToDesign(senderIf, recvIf1, \"data_connection\");\n    QSharedPointer<MetaInterconnection> ena_connection =\n        addInterconnectToDesign(senderIf, recvIf2, \"ena_connection\");\n\n    QSharedPointer<MetaWire> dataWire = addWireToDesign(\"sender_to_receiver_DATA\",\"7\",\"0\",data_connection);\n    QSharedPointer<MetaWire> enaWire = addWireToDesign(\"sender_to_receiver_ENABLE\",\"0\",\"0\",ena_connection);\n\n    createPortAssignment(receiverInstance1->getPorts()->value(\"data_in\"), dataWire, true, \"7\", \"0\", \"7\", \"0\");\n    createPortAssignment(receiverInstance1->getPorts()->value(\"enable_in\"), enaWire, true, \"0\", \"0\", \"0\", \"0\");\n    createPortAssignment(receiverInstance2->getPorts()->value(\"data_in\"), dataWire, true, \"7\", \"0\", \"7\", \"0\");\n    createPortAssignment(receiverInstance2->getPorts()->value(\"enable_in\"), enaWire, true, \"0\", \"0\", \"0\", \"0\");\n\n    createPortAssignment(senderInstance->getPorts()->value(\"data_out\"), dataWire, true, \"7\", \"0\", \"7\", \"0\");\n    createPortAssignment(senderInstance->getPorts()->value(\"enable_out\"), enaWire, true, \"0\", \"0\", \"0\", \"0\");\n\n    runGenerator(true);\n\n    verifyOutputContains(\"wire [7:0] sender_to_receiver_DATA;\");\n    verifyOutputContains(\"wire       sender_to_receiver_ENABLE;\");\n\n    verifyOutputContains(\"wire [7:0] receiver1_data_in;\");\n    verifyOutputContains(\"wire       receiver1_enable_in;\");\n    verifyOutputContains(\"wire [7:0] receiver2_data_in;\");\n    verifyOutputContains(\"wire       receiver2_enable_in;\");\n    verifyOutputContains(\"wire [7:0] sender_data_out;\");\n    verifyOutputContains(\"wire       sender_enable_out;\");\n\n    verifyOutputContains(\"assign receiver1_data_in = sender_to_receiver_DATA;\");\n    verifyOutputContains(\"assign receiver1_enable_in = sender_to_receiver_ENABLE;\");\n    verifyOutputContains(\"assign receiver2_data_in = sender_to_receiver_DATA;\");\n    verifyOutputContains(\"assign receiver2_enable_in = sender_to_receiver_ENABLE;\");\n    verifyOutputContains(\"assign sender_to_receiver_DATA = sender_data_out;\");\n    verifyOutputContains(\"assign sender_to_receiver_ENABLE = sender_enable_out;\");\n\n    verifyOutputContains(\n        \"    TestReceiver receiver1(\\n\"\n        \"        // Interface: data_if\\n\"\n        \"        .data_in             (receiver1_data_in),\\n\"\n        \"        .enable_in           (receiver1_enable_in)\");\n\n    verifyOutputContains(\n        \"    TestReceiver receiver2(\\n\"\n        \"        // Interface: data_if\\n\"\n        \"        .data_in             (receiver2_data_in),\\n\"\n        \"        .enable_in           (receiver2_enable_in)\");\n\n    verifyOutputContains(\n        \"    TestSender sender(\\n\"\n        \"        // Interface: data_if\\n\"\n        \"        .data_out            (sender_data_out),\\n\"\n        \"        .enable_out          (sender_enable_out)\");\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_VerilogWriterFactory::testLogicalInvertBetweenInstances()\n//-----------------------------------------------------------------------------\nvoid tst_VerilogWriterFactory::testLogicalInvertBetweenInstances()\n{\n    QSharedPointer<MetaInstance> senderInstance = addSender(\"sender\");\n    QSharedPointer<MetaInstance> receiverInstance1 = addReceiver(\"receiver1\");\n   \n    QSharedPointer<MetaInterface> senderIf = senderInstance->getInterfaces()->value(\"data_if\");\n    QSharedPointer<MetaInterface> recvIf1 = receiverInstance1->getInterfaces()->value(\"data_if\");\n\n    QSharedPointer<MetaInterconnection> enable_connection =\n        addInterconnectToDesign(senderIf, recvIf1, \"enable_connection\");\n\n    QSharedPointer<MetaWire> enableWire = addWireToDesign(\"sender_to_receiver_ENABLE\", \"0\", \"0\", enable_connection);\n    QSharedPointer<MetaWire> dataWire = addWireToDesign(\"sender_to_receiver_DATA_LSB\", \"0\", \"0\", enable_connection);\n\n    createPortAssignment(senderInstance->getPorts()->value(\"enable_out\"), enableWire, true, \"0\", \"0\", \"0\", \"0\");\n    createPortAssignment(senderInstance->getPorts()->value(\"data_out\"), dataWire, true, \"0\", \"0\", \"0\", \"0\");\n    senderInstance->getPorts()->value(\"data_out\")->upAssignments_.first()->invert_ = true;\n\n    createPortAssignment(receiverInstance1->getPorts()->value(\"enable_in\"), enableWire, true, \"0\", \"0\", \"0\", \"0\");\n    receiverInstance1->getPorts()->value(\"enable_in\")->upAssignments_.first()->invert_ = true;\n\n    createPortAssignment(receiverInstance1->getPorts()->value(\"data_in\"), dataWire, true, \"0\", \"0\", \"0\", \"0\");\n\n    runGenerator(true);\n\n    verifyOutputContains(\"wire       sender_to_receiver_ENABLE;\");\n    verifyOutputContains(\"wire       receiver1_enable_in;\");\n    verifyOutputContains(\"wire       sender_enable_out;\");\n\n    verifyOutputContains(\"wire       sender_to_receiver_DATA_LSB;\");\n    verifyOutputContains(\"wire [7:0] receiver1_data_in;\");\n    verifyOutputContains(\"wire [7:0] sender_data_out;\");\n\n    verifyOutputContains(\"assign receiver1_enable_in = ~sender_to_receiver_ENABLE;\");\n    verifyOutputContains(\"assign sender_to_receiver_ENABLE = sender_enable_out;\");\n\n    verifyOutputContains(\"assign sender_to_receiver_DATA_LSB = ~sender_data_out[0];\");\n    verifyOutputContains(\"assign receiver1_data_in[0] = sender_to_receiver_DATA_LSB;\");\n\n    verifyOutputContains(\n        \"    TestReceiver receiver1(\\n\"\n        \"        // Interface: data_if\\n\"\n        \"        .data_in             (receiver1_data_in),\\n\"\n        \"        .enable_in           (receiver1_enable_in)\");\n\n    verifyOutputContains(\n        \"    TestSender sender(\\n\"\n        \"        // Interface: data_if\\n\"\n        \"        .data_out            (sender_data_out),\\n\"\n        \"        .enable_out          (sender_enable_out)\");\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_VerilogWriterFactory::testLogicalInvertInHierarchicalConnection()\n//-----------------------------------------------------------------------------\nvoid tst_VerilogWriterFactory::testLogicalInvertInHierarchicalConnection()\n{\n    QSharedPointer<MetaInterface> topDataIf = addInterfaceToComponent(\"data_bus\", topComponent_);\n\n    QSharedPointer<MetaPort> topEnable = addPort(\"enable_to_instance\", 1, DirectionTypes::IN, topComponent_, topDataIf);\n    QSharedPointer<MetaPort> topFull = addPort(\"full_from_instance\", 1, DirectionTypes::OUT, topComponent_, topDataIf);\n\n    VLNV instanceVlnv(VLNV::COMPONENT, \"Test\", \"TestLibrary\", \"TestInstance\", \"1.0\");\n    QSharedPointer<Component> comp = addTestComponentToLibrary(instanceVlnv);\n    QSharedPointer<MetaInstance> mInstance = addInstanceToDesign(\"instance1\", comp);\n    addInterfacesToInstance(mInstance);\n\n    QSharedPointer<MetaInterface> instanceDataIf = mInstance->getInterfaces()->value(\"data_if\");\n\n    QSharedPointer<MetaInterconnection> mI1 = addInterconnectToDesign(topDataIf, instanceDataIf, \"data_connection\");\n    mI1->hierIfs_.append(topDataIf);\n\n    QSharedPointer<MetaWire> gw2 = addWireToDesign(\"enable_wire\", \"0\", \"0\", mI1);\n    gw2->hierPorts_.append(topEnable);\n    QSharedPointer<MetaWire> gw3 = addWireToDesign(\"full_wire\", \"0\", \"0\", mI1);\n    gw3->hierPorts_.append(topFull);\n\n    createPortAssignment(mInstance->getPorts()->value(\"enable\"), gw2, true, \"0\", \"0\", \"0\", \"0\");\n    mInstance->getPorts()->value(\"enable\")->upAssignments_.first()->invert_ = true;\n\n    createPortAssignment(mInstance->getPorts()->value(\"full\"), gw3, true, \"0\", \"0\", \"0\", \"0\");\n    mInstance->getPorts()->value(\"full\")->upAssignments_.first()->invert_ = true;\n\n    createPortAssignment(topEnable, gw2, false, \"0\", \"0\", \"0\", \"0\");\n    createPortAssignment(topFull, gw3, false, \"0\", \"0\", \"0\", \"0\");\n\n    runGenerator(true);\n\n    verifyOutputContains(QString(\n        \"module TestComponent(\\n\"\n        \"    // Interface: data_bus\\n\"\n        \"    input                               enable_to_instance,\\n\"\n        \"    output                              full_from_instance\\n\"\n        \");\\n\"\n        \"\\n\"\n        \"    // data_connection wires:\\n\"\n        \"    wire       enable_wire;\\n\"\n        \"    wire       full_wire;\\n\"\n        \"\\n\"\n        \"    // instance1 port wires:\\n\"        \n        \"    wire       instance1_enable;\\n\"\n        \"    wire       instance1_full;\\n\"\n        \"\\n\"\n        \"    // Assignments for the ports of the encompassing component:\\n\"\n        \"    assign enable_wire = enable_to_instance;\\n\"\n        \"    assign full_from_instance = full_wire;\\n\"\n        \"\\n\"\n        \"    // instance1 assignments:\\n\"\n        \"    assign instance1_enable = ~enable_wire;\\n\"\n        \"    assign full_wire = ~instance1_full;\\n\"\n        \"\\n\"\n        \"    // IP-XACT VLNV: Test:TestLibrary:TestInstance:1.0\\n\"\n        \"    TestInstance instance1(\\n\"\n        \"        // Interface: clk_if\\n\"\n        \"        .clk                 (),\\n\"\n        \"        // Interface: data_if\\n\"\n        \"        .data_in             (),\\n\"\n        \"        .enable              (instance1_enable),\\n\"\n        \"        .full                (instance1_full),\\n\"\n        \"        // These ports are not in any interface\\n\"\n        \"        .data_out            ());\\n\"\n        \"\\n\"\n        \"\\n\"\n        \"endmodule\"));\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_VerilogWriterFactory::testAdhocConnectionBetweenComponentInstances()\n//-----------------------------------------------------------------------------\nvoid tst_VerilogWriterFactory::testAdhocConnectionBetweenComponentInstances()\n{\n    QSharedPointer<MetaInstance> senderInstance = addSender(\"sender\");\n    QSharedPointer<MetaInstance> receiverInstance1 = addReceiver(\"receiver1\");\n    QSharedPointer<MetaInstance> receiverInstance2 = addReceiver(\"receiver2\");\n\n    QSharedPointer<MetaWire> dataWire = addWireToDesign(\"dataAdHoc\",\"7\",\"0\");\n    QSharedPointer<MetaWire> enaWire = addWireToDesign(\"enableAdHoc\",\"0\",\"0\");\n\n    createPortAssignment(receiverInstance1->getPorts()->value(\"data_in\"), dataWire, true, \"7\", \"0\", \"7\", \"0\");\n    createPortAssignment(receiverInstance1->getPorts()->value(\"enable_in\"), enaWire, true, \"0\", \"0\", \"0\", \"0\");\n    createPortAssignment(receiverInstance2->getPorts()->value(\"data_in\"), dataWire, true, \"7\", \"0\", \"7\", \"0\");\n    createPortAssignment(receiverInstance2->getPorts()->value(\"enable_in\"), enaWire, true, \"0\", \"0\", \"0\", \"0\");\n\n    createPortAssignment(senderInstance->getPorts()->value(\"data_out\"), dataWire, true, \"7\", \"0\", \"7\", \"0\");\n    createPortAssignment(senderInstance->getPorts()->value(\"enable_out\"), enaWire, true, \"0\", \"0\", \"0\", \"0\");\n\n    runGenerator(true);\n\n    verifyOutputContains(\"wire [7:0] dataAdHoc;\");\n    verifyOutputContains(\"wire       enableAdHoc;\");\n\n    verifyOutputContains(\"wire [7:0] receiver1_data_in;\");\n    verifyOutputContains(\"wire       receiver1_enable_in;\");\n    verifyOutputContains(\"wire [7:0] receiver2_data_in;\");\n    verifyOutputContains(\"wire       receiver2_enable_in;\");\n    verifyOutputContains(\"wire [7:0] sender_data_out;\");\n    verifyOutputContains(\"wire       sender_enable_out;\");\n\n    verifyOutputContains(\"assign receiver1_data_in = dataAdHoc;\");\n    verifyOutputContains(\"assign receiver1_enable_in = enableAdHoc;\");\n    verifyOutputContains(\"assign receiver2_data_in = dataAdHoc;\");\n    verifyOutputContains(\"assign receiver2_enable_in = enableAdHoc;\");\n    verifyOutputContains(\"assign dataAdHoc = sender_data_out;\");\n    verifyOutputContains(\"assign enableAdHoc = sender_enable_out;\");\n\n    verifyOutputContains(\n        \"    TestReceiver receiver1(\\n\"\n        \"        // Interface: data_if\\n\"\n        \"        .data_in             (receiver1_data_in),\\n\"\n        \"        .enable_in           (receiver1_enable_in)\");\n\n    verifyOutputContains(\n        \"    TestReceiver receiver2(\\n\"\n        \"        // Interface: data_if\\n\"\n        \"        .data_in             (receiver2_data_in),\\n\"\n        \"        .enable_in           (receiver2_enable_in)\");\n\n    verifyOutputContains(\n        \"    TestSender sender(\\n\"\n        \"        // Interface: data_if\\n\"\n        \"        .data_out            (sender_data_out),\\n\"\n        \"        .enable_out          (sender_enable_out)\");\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_VerilogWriterFactory::testPartSelectedAdhocConnectionBetweenComponentInstances()\n//-----------------------------------------------------------------------------\nvoid tst_VerilogWriterFactory::testPartSelectedAdhocConnectionBetweenComponentInstances()\n{\n    QSharedPointer<MetaInstance> senderInstance = addSender(\"sender\");\n    QSharedPointer<MetaInstance> receiverInstance1 = addReceiver(\"receiver1\");\n    QSharedPointer<MetaInstance> receiverInstance2 = addReceiver(\"receiver2\");\n\n    QSharedPointer<MetaWire> dataWire1 = addWireToDesign(\"dataAdHoc1\",\"3\",\"0\");\n    QSharedPointer<MetaWire> dataWire2 = addWireToDesign(\"dataAdHoc2\",\"3\",\"0\");\n\n    createPortAssignment(receiverInstance1->getPorts()->value(\"data_in\"), dataWire1, true, \"3\", \"0\", \"3\", \"0\");\n    createPortAssignment(receiverInstance2->getPorts()->value(\"data_in\"), dataWire2, true, \"3\", \"0\", \"3\", \"0\");\n\n    createPortAssignment(senderInstance->getPorts()->value(\"data_out\"), dataWire1, true, \"3\", \"0\", \"3\", \"0\");\n    createPortAssignment(senderInstance->getPorts()->value(\"data_out\"), dataWire2, true, \"3\", \"0\", \"7\", \"4\");\n\n    runGenerator(true);\n\n    verifyOutputContains(\"wire [3:0] dataAdHoc1;\");\n    verifyOutputContains(\"wire [3:0] dataAdHoc2;\");\n\n    verifyOutputContains(\"wire [7:0] receiver1_data_in;\");\n    verifyOutputContains(\"wire [7:0] receiver2_data_in;\");\n    verifyOutputContains(\"wire [7:0] sender_data_out;\");\n\n    verifyOutputContains(\"assign receiver1_data_in[3:0] = dataAdHoc1;\");\n    verifyOutputContains(\"assign receiver2_data_in[3:0] = dataAdHoc2;\");\n    verifyOutputContains(\"assign dataAdHoc1 = sender_data_out[3:0];\");\n    verifyOutputContains(\"assign dataAdHoc2 = sender_data_out[7:4];\");\n\n    verifyOutputContains(\n        \"    TestReceiver receiver1(\\n\"\n        \"        // Interface: data_if\\n\"\n        \"        .data_in             (receiver1_data_in),\\n\"\n        \"        .enable_in           ()\");\n\n    verifyOutputContains(\n        \"    TestReceiver receiver2(\\n\"\n        \"        // Interface: data_if\\n\"\n        \"        .data_in             (receiver2_data_in),\\n\"\n        \"        .enable_in           ()\");\n\n    verifyOutputContains(\n        \"    TestSender sender(\\n\"\n        \"        // Interface: data_if\\n\"\n        \"        .data_out            (sender_data_out),\\n\"\n        \"        .enable_out          ()\");\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_VerilogWriterFactory::testAdhocInOutConnectionBetweenComponentInstances()\n//-----------------------------------------------------------------------------\nvoid tst_VerilogWriterFactory::testAdhocInOutConnectionBetweenComponentInstances()\n{\n    QSharedPointer<MetaInstance> senderInstance = addSender(\"sender\");\n    QSharedPointer<MetaInstance> receiverInstance1 = addReceiver(\"receiver1\");\n    QSharedPointer<MetaInstance> receiverInstance2 = addReceiver(\"receiver2\");\n\n    QSharedPointer<MetaWire> dataWire = addWireToDesign(\"dataAdHoc\",\"7\",\"0\");\n    QSharedPointer<MetaWire> enaWire = addWireToDesign(\"enableAdHoc\",\"0\",\"0\");\n\n    createPortAssignment(receiverInstance1->getPorts()->value(\"data_in\"), dataWire, true, \"7\", \"0\", \"7\", \"0\");\n    createPortAssignment(receiverInstance2->getPorts()->value(\"data_in\"), dataWire, true, \"7\", \"0\", \"7\", \"0\");\n    createPortAssignment(senderInstance->getPorts()->value(\"data_out\"), dataWire, true, \"7\", \"0\", \"7\", \"0\");\n\n    receiverInstance1->getPorts()->first()->port_->setDirection(DirectionTypes::INOUT);\n    receiverInstance2->getPorts()->first()->port_->setDirection(DirectionTypes::INOUT);\n    senderInstance->getPorts()->first()->port_->setDirection(DirectionTypes::INOUT);\n\n    runGenerator(true);\n\n    verifyOutputContains(\"wire [7:0] dataAdHoc;\");\n    verifyOutputContains(\"wire       enableAdHoc;\");\n\n    verifyOutputContains(\n        \"    TestReceiver receiver1(\\n\"\n        \"        // Interface: data_if\\n\"\n        \"        .enable_in           (),\\n\"\n        \"        .data_in             (dataAdHoc)\");\n\n    verifyOutputContains(\n        \"    TestReceiver receiver2(\\n\"\n        \"        // Interface: data_if\\n\"\n        \"        .enable_in           (),\\n\"\n        \"        .data_in             (dataAdHoc)\");\n\n    verifyOutputContains(\n        \"    TestSender sender(\\n\"\n        \"        // Interface: data_if\\n\"\n        \"        .enable_out          (),\\n\"\n        \"        .data_out            (dataAdHoc)\");\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_VerilogWriterFactory::testAdhocTieOffInComponentInstance()\n//-----------------------------------------------------------------------------\nvoid tst_VerilogWriterFactory::testAdhocTieOffInComponentInstance()\n{\n    VLNV tieOffVLNV(VLNV::COMPONENT, \"Test\", \"TestLibrary\", \"TestTieOff\", \"1.0\");\n\tQSharedPointer<Component> tieOffComponent(new Component(tieOffVLNV, Document::Revision::Std14));\n\n    QSharedPointer<MetaInstance> mInstance = addInstanceToDesign(\"tieOffer\", tieOffComponent);\n\n    QString defaultName = \"defaultValue\";\n    QString zeroName = \"zeroTieOff\";\n    QString oneName = \"oneTieOff\";\n    QString naName = \"n/aTieOff\";\n    QString numberedName = \"numberedTieOff\";\n    QString outName = \"tieOffOut\";\n    QString inOutName = \"tieOffInOut\";\n    QString unusedName = \"unusedPort\";\n    QString slicedName = \"slicedTieOff\";\n\n    QSharedPointer<MetaPort> defaultPort = addPort(defaultName, 4, DirectionTypes::IN, mInstance);\n    defaultPort->defaultValue_ = \"15\";\n    addPort(zeroName, 2, DirectionTypes::IN, mInstance);\n    addPort(oneName, 4, DirectionTypes::IN, mInstance);\n    addPort(naName, 0, DirectionTypes::IN, mInstance);\n    addPort(numberedName, 10, DirectionTypes::IN, mInstance);\n    addPort(outName, 2, DirectionTypes::OUT, mInstance);\n    addPort(inOutName, 10, DirectionTypes::INOUT, mInstance);\n    addPort(unusedName, 1, DirectionTypes::IN, mInstance);\n    QSharedPointer<MetaPort> slicedPort = addPort(slicedName, 5, DirectionTypes::IN, mInstance);\n\n    QSharedPointer<MetaPortAssignment> mpa1(new MetaPortAssignment);\n    mpa1->defaultValue_ = \"2\";\n    mpa1->physicalBounds_.first = \"4\";\n    mpa1->physicalBounds_.second = \"3\";\n    mpa1->invert_ = false;\n\n    QSharedPointer<MetaPortAssignment> mpa0(new MetaPortAssignment);\n    mpa0->defaultValue_ = \"7\";\n    mpa0->physicalBounds_.first = \"2\";\n    mpa0->physicalBounds_.second = \"0\";\n    mpa0->invert_ = false;\n\n    slicedPort->upAssignments_.insert(\"eka\", mpa1);\n    slicedPort->upAssignments_.insert(\"toka\", mpa0);\n\n    library_.addComponent(tieOffComponent);\n\n    addDefaultPortAssignmentToPort(mInstance->getPorts()->value(zeroName),\"0\", true);\n    addDefaultPortAssignmentToPort(mInstance->getPorts()->value(oneName),\"1\", true);\n    addDefaultPortAssignmentToPort(mInstance->getPorts()->value(naName),\"abc\", true);\n    addDefaultPortAssignmentToPort(mInstance->getPorts()->value(numberedName),\"12\", true);\n    addDefaultPortAssignmentToPort(mInstance->getPorts()->value(outName),\"0\", true);\n    addDefaultPortAssignmentToPort(mInstance->getPorts()->value(inOutName),\"1\", true);\n\n    runGenerator(true);\n\n    verifyOutputContains(\n        \"module TestComponent();\\n\"\n        \"\\n\"\n        \"    // tieOffer port wires:\\n\"\n        \"    wire [-1:0] tieOffer_n/aTieOff;\\n\"\n        \"    wire [9:0] tieOffer_numberedTieOff;\\n\"\n        \"    wire [3:0] tieOffer_oneTieOff;\\n\"\n        \"    wire [4:0] tieOffer_slicedTieOff;\\n\"\n        \"    wire [1:0] tieOffer_tieOffOut;\\n\"\n        \"    wire [1:0] tieOffer_zeroTieOff;\\n\"\n        \"\\n\"\n        \"    // tieOffer assignments:\\n\"\n        \"    assign tieOffer_n/aTieOff[-1:0] = abc;\\n\"\n        \"    assign tieOffer_numberedTieOff[9:0] = 12;\\n\"\n        \"    assign tieOffer_oneTieOff[3:0] = 1;\\n\"\n        \"    assign tieOffer_slicedTieOff[4:3] = 2;\\n\"\n        \"    assign tieOffer_slicedTieOff[2:0] = 7;\\n\"\n        \"    assign tieOffer_zeroTieOff[1:0] = 0;\\n\"\n        \"\\n\"\n        \"    // IP-XACT VLNV: Test:TestLibrary:TestTieOff:1.0\\n\"\n        \"    TestTieOff tieOffer(\\n\"\n        \"        // These ports are not in any interface\\n\"\n        \"        .defaultValue        (4'b1111),\\n\"\n        \"        .n/aTieOff           (tieOffer_n/aTieOff),\\n\"\n        \"        .numberedTieOff      (tieOffer_numberedTieOff),\\n\"\n        \"        .oneTieOff           (tieOffer_oneTieOff),\\n\"\n        \"        .slicedTieOff        (tieOffer_slicedTieOff),\\n\"\n        \"        .unusedPort          (),\\n\"\n        \"        .zeroTieOff          (tieOffer_zeroTieOff),\\n\"\n        \"        .tieOffOut           (tieOffer_tieOffOut),\\n\"\n        \"        .tieOffInOut         ());\\n\"\n        \"\\n\"\n        \"\\n\"\n        \"endmodule\");\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_VerilogWriterFactory::addDefaultPortAssignmentToPort()\n//-----------------------------------------------------------------------------\nvoid tst_VerilogWriterFactory::addDefaultPortAssignmentToPort(QSharedPointer<MetaPort> port,\n    QString tieOff, bool up)\n{\n    QSharedPointer<MetaPortAssignment> mpa(new MetaPortAssignment);\n    mpa->defaultValue_ = tieOff;\n    mpa->physicalBounds_ = port->vectorBounds_;\n    mpa->invert_ = false;\n\n    if (up)\n    {\n        port->upAssignments_.insert(\"eka\", mpa);\n    }\n    else\n    {\n        port->downAssignments_.insert(\"eka\", mpa);\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_VerilogWriterFactory::testHierarchicalAdhocConnection()\n//-----------------------------------------------------------------------------\nvoid tst_VerilogWriterFactory::testHierarchicalAdhocConnection()\n{\n    QSharedPointer<MetaPort> topEna = addPort(\"enable_from_sender\", 1, DirectionTypes::OUT, topComponent_);\n    QSharedPointer<MetaPort> topData = addPort(\"data_from_sender\", 8, DirectionTypes::OUT, topComponent_);\n\n    QSharedPointer<MetaInstance> senderInstance = addSender(\"sender\");;\n\n    QSharedPointer<MetaWire> dataWire = addWireToDesign(\"dataAdHoc\",\"7\",\"0\");\n    dataWire->hierPorts_.append(topData);\n    QSharedPointer<MetaWire> enaWire = addWireToDesign(\"enableAdHoc\",\"0\",\"0\");\n    enaWire->hierPorts_.append(topEna);\n\n    createPortAssignment(topData, dataWire, false, \"7\", \"0\", \"7\", \"0\");\n    createPortAssignment(topEna, enaWire, false, \"0\", \"0\", \"0\", \"0\");\n    createPortAssignment(senderInstance->getPorts()->value(\"data_out\"), dataWire, true, \"7\", \"0\", \"7\", \"0\");\n    createPortAssignment(senderInstance->getPorts()->value(\"enable_out\"), enaWire, true, \"0\", \"0\", \"0\", \"0\");\n\n    runGenerator(true);\n\n    verifyOutputContains(\"output               [7:0]          data_from_sender\");\n    verifyOutputContains(\"output                              enable_from_sender\");\n\n    verifyOutputContains(\"wire [7:0] dataAdHoc;\");\n    verifyOutputContains(\"wire       enableAdHoc;\");\n\n    verifyOutputContains(\"wire [7:0] sender_data_out;\");\n    verifyOutputContains(\"wire       sender_enable_out;\");\n\n    verifyOutputContains(\"assign data_from_sender = dataAdHoc;\");\n    verifyOutputContains(\"assign enable_from_sender = enableAdHoc;\");\n\n    verifyOutputContains(\"assign dataAdHoc = sender_data_out;\");\n    verifyOutputContains(\"assign enableAdHoc = sender_enable_out;\");\n\n    verifyOutputContains(\n        \"    TestSender sender(\\n\"\n        \"        // Interface: data_if\\n\"\n        \"        .data_out            (sender_data_out),\\n\"\n        \"        .enable_out          (sender_enable_out)\");\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_VerilogWriterFactory::testHierarchicalAdhocInOutConnection()\n//-----------------------------------------------------------------------------\nvoid tst_VerilogWriterFactory::testHierarchicalAdhocInOutConnection()\n{\n    QSharedPointer<MetaPort> topData = addPort(\"data_from_sender\", 8, DirectionTypes::INOUT, topComponent_);\n\n    QSharedPointer<MetaInstance> senderInstance = addSender(\"sender\");\n\n    senderInstance->getPorts()->first()->port_->setDirection(DirectionTypes::INOUT);\n\n    QSharedPointer<MetaWire> dataWire = addWireToDesign(\"dataAdHoc\",\"7\",\"0\");\n    dataWire->hierPorts_.append(topData);\n\n    createPortAssignment(topData, dataWire, false, \"7\", \"0\", \"7\", \"0\");\n    createPortAssignment(senderInstance->getPorts()->value(\"data_out\"), dataWire, true, \"7\", \"0\", \"7\", \"0\");\n\n    runGenerator(true);\n\n    verifyOutputContains(\"inout                [7:0]          data_from_sender\");\n\n    verifyOutputContains(\n        \"    TestSender sender(\\n\"\n        \"        // Interface: data_if\\n\"\n        \"        .enable_out          (),\\n\"\n        \"        .data_out            (data_from_sender[7:0])\");\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_VerilogWriterFactory::testHierarchicalAdHocTieOffValues()\n//-----------------------------------------------------------------------------\nvoid tst_VerilogWriterFactory::testHierarchicalAdHocTieOffValues()\n{\n    QString defaultName = \"defaultTieOff\";\n    QString zeroName = \"zeroTieOff\";\n    QString oneName = \"oneTieOff\";\n    QString naName = \"n/aTieOff\";\n    QString numberedName = \"numberedTieOff\";\n    QString inName = \"tieOffIn\";\n    QString inOutName = \"inOutTieOff\";\n    QString slicedName = \"slicedTieOff\";\n\n    QSharedPointer<MetaPort> defaultPort = addPort(defaultName, 5, DirectionTypes::OUT, topComponent_);\n    defaultPort->defaultValue_ = \"7\";\n    addPort(zeroName, 2, DirectionTypes::OUT, topComponent_);\n    addPort(oneName, 4, DirectionTypes::OUT, topComponent_);\n    addPort(naName, 0, DirectionTypes::OUT, topComponent_);\n    addPort(numberedName, 10, DirectionTypes::OUT, topComponent_);\n    addPort(inName, 2, DirectionTypes::IN, topComponent_);\n    addPort(inOutName, 10, DirectionTypes::INOUT, topComponent_);\n    QSharedPointer<MetaPort> slicedPort = addPort(slicedName, 5, DirectionTypes::OUT, topComponent_);\n\n    QSharedPointer<MetaPortAssignment> mpa1(new MetaPortAssignment);\n    mpa1->defaultValue_ = \"2\";\n    mpa1->physicalBounds_.first = \"4\";\n    mpa1->physicalBounds_.second = \"3\";\n    mpa1->invert_ = false;\n\n    QSharedPointer<MetaPortAssignment> mpa0(new MetaPortAssignment);\n    mpa0->defaultValue_ = \"7\";\n    mpa0->physicalBounds_.first = \"2\";\n    mpa0->physicalBounds_.second = \"0\";\n    mpa0->invert_ = false;\n\n    slicedPort->downAssignments_.insert(\"eka\", mpa1);\n    slicedPort->downAssignments_.insert(\"toka\", mpa0);\n\n    addDefaultPortAssignmentToPort(topComponent_->getPorts()->value(zeroName),\"0\", false);\n    addDefaultPortAssignmentToPort(topComponent_->getPorts()->value(oneName),\"1\", false);\n    addDefaultPortAssignmentToPort(topComponent_->getPorts()->value(naName),\"abc\", false);\n    addDefaultPortAssignmentToPort(topComponent_->getPorts()->value(numberedName),\"12\", false);\n    addDefaultPortAssignmentToPort(topComponent_->getPorts()->value(inName),\"0\", false);\n    addDefaultPortAssignmentToPort(topComponent_->getPorts()->value(inOutName),\"1\", false);\n\n    runGenerator(true);\n\n    verifyOutputContains(\n        \"module TestComponent(\\n\"\n        \"    // These ports are not in any interface\\n\"\n        \"    input                [1:0]          tieOffIn,\\n\"\n        \"    output               [4:0]          defaultTieOff,\\n\"\n        \"    output               [-1:0]         n/aTieOff,\\n\"\n        \"    output               [9:0]          numberedTieOff,\\n\"\n        \"    output               [3:0]          oneTieOff,\\n\"\n        \"    output               [4:0]          slicedTieOff,\\n\"\n        \"    output               [1:0]          zeroTieOff,\\n\"\n        \"    inout                [9:0]          inOutTieOff\\n\"\n        \");\\n\"\n        \"\\n\"\n        \"    // Assignments for the ports of the encompassing component:\\n\"\n        \"    assign inOutTieOff[9:0] = 1;\\n\"\n        \"    assign n/aTieOff[-1:0] = abc;\\n\"\n        \"    assign numberedTieOff[9:0] = 12;\\n\"\n        \"    assign oneTieOff[3:0] = 1;\\n\"\n        \"    assign slicedTieOff[4:3] = 2;\\n\"\n        \"    assign slicedTieOff[2:0] = 7;\\n\"\n        \"    assign zeroTieOff[1:0] = 0;\\n\"\n        \"\\n\"\n        \"    assign defaultTieOff = 7;\\n\"\n        \"\\n\"\n        \"\\n\"\n        \"endmodule\");\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_ComponentInstanceVerilogWriter::testDescriptionAndVLNVIsPrintedAboveInstance()\n//-----------------------------------------------------------------------------\nvoid tst_VerilogWriterFactory::testDescriptionAndVLNVIsPrintedAboveInstance()\n{\n    QFETCH(QString, description);\n    QFETCH(QString, expectedOutput);\n    \n    QSharedPointer<ConfigurableVLNVReference> instanceVLNV(\n\t\tnew ConfigurableVLNVReference(VLNV::COMPONENT, \"Test\", \"TestLibrary\", \"TestComponent\", \"1.0\"));\n\n\tQSharedPointer<Component> comp = addTestComponentToLibrary(*instanceVLNV);\n\n    QSharedPointer<MetaInstance> mInstance = addInstanceToDesign(\"instance1\", comp);\n    mInstance->getComponentInstance()->setDescription(description);\n\n    runGenerator(true);\n\n    verifyOutputContains(expectedOutput);\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_ComponentInstanceVerilogWriter::testDescriptionAndVLNVIsPrintedAboveInstance_data()\n//-----------------------------------------------------------------------------\nvoid tst_VerilogWriterFactory::testDescriptionAndVLNVIsPrintedAboveInstance_data()\n{\n    QTest::addColumn<QString>(\"description\");\n    QTest::addColumn<QString>(\"expectedOutput\");\n\n    QTest::newRow(\"empty description\") << \"\" <<\n        \"    // IP-XACT VLNV: Test:TestLibrary:TestComponent:1.0\\n\"\n        \"    TestComponent instance1(\";\n    QTest::newRow(\"one line description\") << \"Instance description.\" << \n        \"    // Instance description.\\n\"\n        \"    // IP-XACT VLNV: Test:TestLibrary:TestComponent:1.0\\n\"\n        \"    TestComponent instance1(\";\n\n    QTest::newRow(\"multiline description\") << \n        \"Description on\\n\" \n        \"multiple\\n\" \n        \"lines.\" \n        << \n        \"    // Description on\\n\"\n        \"    // multiple\\n\"\n        \"    // lines.\\n\"\n        \"    // IP-XACT VLNV: Test:TestLibrary:TestComponent:1.0\\n\"\n        \"    TestComponent instance1(\";\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_VerilogWriterFactory::testInstanceParametersAreWritten()\n//-----------------------------------------------------------------------------\nvoid tst_VerilogWriterFactory::testInstanceParametersAreWritten()\n{\n    QSharedPointer<View> activeView(new View(\"rtl\"));\n    activeView->setComponentInstantiationRef(\"instance1\");\n\n    QSharedPointer<MetaInstance> sender = addSender(\"sender\");\n\n    QSharedPointer<Parameter> parameter(new Parameter());\n    parameter->setValueId(\"parameterId\");\n    parameter->setName(\"testParameter\");\n    parameter->setValue(\"2\");\n    parameter->setValueResolve(\"user\");\n\n    sender->getParameters()->append(parameter);\n\n    runGenerator(true);\n\n    verifyOutputContains(\n        \"    TestSender #(\\n\"\n        \"        .testParameter       (2))\\n\"\n        \"    sender(\");\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_VerilogWriterFactory::testAdhocConnectionToInterfacePorts()\n//-----------------------------------------------------------------------------\nvoid tst_VerilogWriterFactory::testAdhocConnectionToInterfacePorts()\n{\n    //QSharedPointer<MetaInterface> topDataIf = addInterfaceToComponent(\"data_bus\", topComponent_);\n\n    QSharedPointer<MetaPort> topData = addPort(\"data_to_instance\", 8, DirectionTypes::IN, topComponent_);\n    QSharedPointer<MetaPort> topEnable = addPort(\"enable_to_instance\", 1, DirectionTypes::IN, topComponent_);\n    QSharedPointer<MetaPort> topFull = addPort(\"full_from_instance\", 1, DirectionTypes::OUT, topComponent_);\n\n    VLNV instanceVlnv(VLNV::COMPONENT, \"Test\", \"TestLibrary\", \"TestInstance\", \"1.0\");\n    QSharedPointer<Component> comp = addTestComponentToLibrary(instanceVlnv);\n    QSharedPointer<MetaInstance> mInstance = addInstanceToDesign(\"instance1\", comp);\n\n    QSharedPointer<MetaInterface> dataIf = addInterfaceToComponent(\"data_bus\", mInstance);\n    QSharedPointer<MetaPort> instanceData = addPort(\"data_in\", 8, DirectionTypes::IN, mInstance, dataIf);\n    QSharedPointer<MetaPort> instanceEnable = addPort(\"enable_in\", 1, DirectionTypes::IN, mInstance, dataIf);\n    QSharedPointer<MetaPort> instanceFull = addPort(\"full_out\", 1, DirectionTypes::OUT, mInstance, dataIf);\n\n    QSharedPointer<MetaWire> gw1 = addWireToDesign(\"data_wire\", \"7\", \"0\");\n    gw1->hierPorts_.append(topData);\n    QSharedPointer<MetaWire> gw2 = addWireToDesign(\"enable_wire\", \"0\", \"0\");\n    gw2->hierPorts_.append(topEnable);\n    QSharedPointer<MetaWire> gw3 = addWireToDesign(\"full_wire\", \"0\", \"0\");\n    gw3->hierPorts_.append(topFull);\n\n    createPortAssignment(mInstance->getPorts()->value(\"data_in\"), gw1, true, \"7\", \"0\", \"7\", \"0\");\n    createPortAssignment(mInstance->getPorts()->value(\"enable_in\"), gw2, true, \"0\", \"0\", \"0\", \"0\");\n    createPortAssignment(mInstance->getPorts()->value(\"full_out\"), gw3, true, \"0\", \"0\", \"0\", \"0\");\n\n    createPortAssignment(topData, gw1, false, \"7\", \"0\", \"7\", \"0\");\n    createPortAssignment(topEnable, gw2, false, \"0\", \"0\", \"0\", \"0\");\n    createPortAssignment(topFull, gw3, false, \"0\", \"0\", \"0\", \"0\");\n\n    runGenerator(true);\n\n    verifyOutputContains(QString(\n        \"module TestComponent(\\n\"\n        \"    // These ports are not in any interface\\n\"\n        \"    input                [7:0]          data_to_instance,\\n\"\n        \"    input                               enable_to_instance,\\n\"\n        \"    output                              full_from_instance\\n\"\n        \");\\n\"\n        \"\\n\"\n        \"    // Ad-hoc wires:\\n\"\n        \"    wire [7:0] data_wire;\\n\"\n        \"    wire       enable_wire;\\n\"\n        \"    wire       full_wire;\\n\"\n        \"\\n\"\n        \"    // instance1 port wires:\\n\"\n        \"    wire [7:0] instance1_data_in;\\n\"\n        \"    wire       instance1_enable_in;\\n\"\n        \"    wire       instance1_full_out;\\n\"\n        \"\\n\"\n        \"    // Assignments for the ports of the encompassing component:\\n\"\n        \"    assign data_wire = data_to_instance;\\n\"\n        \"    assign enable_wire = enable_to_instance;\\n\"\n        \"    assign full_from_instance = full_wire;\\n\"\n        \"\\n\"\n        \"    // instance1 assignments:\\n\"\n        \"    assign instance1_data_in = data_wire;\\n\"\n        \"    assign instance1_enable_in = enable_wire;\\n\"\n        \"    assign full_wire = instance1_full_out;\\n\"\n        \"\\n\"\n        \"    // IP-XACT VLNV: Test:TestLibrary:TestInstance:1.0\\n\"\n        \"    TestInstance instance1(\\n\"\n        \"        // Interface: data_bus\\n\"        \n        \"        .data_in             (instance1_data_in),\\n\"\n        \"        .enable_in           (instance1_enable_in),\\n\"\n        \"        .full_out            (instance1_full_out));\\n\"        \n        \"\\n\"\n        \"\\n\"\n        \"endmodule\"));\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_VerilogWriterFactory::testFlatComponent()\n//-----------------------------------------------------------------------------\nvoid tst_VerilogWriterFactory::testFlatComponent()\n{\n    addPort(\"clk\", 1, DirectionTypes::IN, flatComponent_);\n    addPort(\"rst_n\", 1, DirectionTypes::IN, flatComponent_);\n    addPort(\"dataOut\", 8, DirectionTypes::OUT, flatComponent_);\n    addPort(\"dataIn\", 8, DirectionTypes::IN, flatComponent_);\n    addParameter(\"dataWidth\", \"8\", flatComponent_);\n    addParameter(\"freq\", \"100000\", flatComponent_);\n\n    runGenerator(false);\n\n    verifyOutputContains(QString(\n        \"module TestComponent #(\\n\"\n        \"    parameter                              dataWidth        = 8,\\n\"\n        \"    parameter                              freq             = 100000\\n\"\n        \") (\\n\"\n        \"    // These ports are not in any interface\\n\"         \n        \"    input                               clk,\\n\"\n        \"    input                [7:0]          dataIn,\\n\"\n        \"    input                               rst_n,\\n\"\n        \"    output               [7:0]          dataOut\\n\"\n        \");\\n\"\n        \"\\n\"\n        \"// \" + VerilogSyntax::TAG_OVERRIDE + \"\\n\"\n        \"endmodule\\n\"\n        ));\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_VerilogWriterFactory::testFlatComponentWithTypedParameter()\n//-----------------------------------------------------------------------------\nvoid tst_VerilogWriterFactory::testFlatComponentWithTypedParameter()\n{\n    QSharedPointer<Parameter> testParameter = addParameter(\"dataWidth\", \"8\", flatComponent_);\n    testParameter->setAttribute(QStringLiteral(\"dataType\"), \"integer\");\n    addParameter(\"freq\", \"100000\", flatComponent_);\n\n    runGenerator(false);\n\n    verifyOutputContains(QString(\n        \"module TestComponent #(\\n\"\n        \"    parameter integer                      dataWidth        = 8,\\n\"\n        \"    parameter                              freq             = 100000\\n\"\n        \") ();\\n\"\n        \"\\n\"\n        \"// \" + VerilogSyntax::TAG_OVERRIDE + \"\\n\"\n        \"endmodule\\n\"\n        ));\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_VerilogWriterFactory::testDoNotWriteTransactionalPorts()\n//-----------------------------------------------------------------------------\nvoid tst_VerilogWriterFactory::testDoNotWriteTransactionalPorts()\n{\n    addTransactional(\"provide\", TransactionalTypes::Initiative::PROVIDES, flatComponent_);\n    addTransactional(\"require\", TransactionalTypes::Initiative::REQUIRES, flatComponent_);\n    addTransactional(\"both\", TransactionalTypes::Initiative::BOTH, flatComponent_);\n    addTransactional(\"phantom\", TransactionalTypes::Initiative::PHANTOM, flatComponent_);\n    addPort(\"dataIn\", 8, DirectionTypes::IN, flatComponent_);\n\n    runGenerator(false);\n\n    verifyOutputContains(QString(\n        \"module TestComponent(\\n\"\n        \"    // These ports are not in any interface\\n\"\n        \"    input                [7:0]          dataIn\\n\"\n        \");\\n\"\n        \"\\n\"\n        \"// \" + VerilogSyntax::TAG_OVERRIDE + \"\\n\"\n        \"endmodule\\n\"\n    ));\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_VerilogWriterFactory::testDoNotWriteTransactionalInterfaces()\n//-----------------------------------------------------------------------------\nvoid tst_VerilogWriterFactory::testDoNotWriteTransactionalInterfaces()\n{\n    QSharedPointer<MetaInterface> transactionalInterface =\n        addInterfaceToComponent(\"transactionalInterface\", topComponent_);\n    QSharedPointer<MetaInterface> wireInterface = addInterfaceToComponent(\"wireInterface\", topComponent_);\n\n    addTransactional(\"provide\", TransactionalTypes::Initiative::PROVIDES, topComponent_, transactionalInterface);\n    addTransactional(\"require\", TransactionalTypes::Initiative::REQUIRES, topComponent_, transactionalInterface);\n    addTransactional(\"both\", TransactionalTypes::Initiative::BOTH, topComponent_, transactionalInterface);\n    addTransactional(\"phantom\", TransactionalTypes::Initiative::PHANTOM, topComponent_, transactionalInterface);\n    addPort(\"clk\", 1, DirectionTypes::IN, flatComponent_, wireInterface);\n    addPort(\"rst_n\", 1, DirectionTypes::IN, flatComponent_, wireInterface);\n    addTransactional(\"otherBoat\", TransactionalTypes::Initiative::BOTH, topComponent_, wireInterface);\n    addPort(\"dataIn\", 8, DirectionTypes::IN, flatComponent_);\n\n    runGenerator(false);\n\n    verifyOutputContains(QString(\n        \"module TestComponent(\\n\"\n        \"    // Interface: wireInterface\\n\"\n        \"    input                               clk,\\n\"\n        \"    input                               rst_n,\\n\"\n        \"\\n\"\n        \"    // These ports are not in any interface\\n\"\n        \"    input                [7:0]          dataIn\\n\"\n        \");\\n\"\n        \"\\n\"\n        \"// \" + VerilogSyntax::TAG_OVERRIDE + \"\\n\"\n        \"endmodule\\n\"\n    ));\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_VerilogWriterFactory::addTransactional()\n//-----------------------------------------------------------------------------\nQSharedPointer<MetaPort> tst_VerilogWriterFactory::addTransactional(QString const& portName,\n    TransactionalTypes::Initiative initiative, QSharedPointer<MetaComponent> component,\n    QSharedPointer<MetaInterface> containingInterface /* = QSharedPointer<MetaInterface>() */)\n{\n    QSharedPointer<Transactional> portTransactional(new Transactional());\n    portTransactional->setInitiative(TransactionalTypes::initiativeToString(initiative));\n\n    QSharedPointer<Port> port = QSharedPointer<Port>(new Port(portName));\n    port->setTransactional(portTransactional);\n\n    QSharedPointer<MetaPort> newMetaPort(new MetaPort);\n    newMetaPort->isWire_ = false;\n    newMetaPort->isTransactional_ = true;\n    newMetaPort->port_ = port;\n    \n    component->getPorts()->insert(portName, newMetaPort);\n    component->getComponent()->getPorts()->append(port);\n\n    if (containingInterface)\n    {\n        containingInterface->ports_.insert(portName, newMetaPort);\n\n        QSharedPointer<PortMap> newPortMap(new PortMap);\n        QSharedPointer<PortMap::PhysicalPort> portMapPhysicalPort(new PortMap::PhysicalPort);\n        portMapPhysicalPort->name_ = portName;\n        newPortMap->setPhysicalPort(portMapPhysicalPort);\n\n        containingInterface->interface_->getAbstractionTypes()->first()->getPortMaps()->append(newPortMap);\n    }\n\n    return newMetaPort;\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_VerilogWriterFactory::testDoNotWriteTransactionalConnections()\n//-----------------------------------------------------------------------------\nvoid tst_VerilogWriterFactory::testDoNotWriteTransactionalConnections()\n{\n    QSharedPointer<Component> topComponent = createComponent(\"topComponent\");\n    QSharedPointer<Design> topDesign = createDesignForComponent(\"topDesign\", topComponent);\n\n    QSharedPointer<BusDefinition> busDefinition = createBusDefinition(\"testBus\");\n    QSharedPointer<AbstractionDefinition> abstractionDefinition = createAbstractionDefinition(\"testAbstraction\");\n\n    QSharedPointer<PortAbstraction> logicalProvider = addLogicalPortToAbstraction(\n        \"logicalTransactional\", abstractionDefinition, General::MASTER, TransactionalTypes::Initiative::PROVIDES);\n    QSharedPointer<PortAbstraction> logicalRequirer = addLogicalPortToAbstraction(\n        \"logicalTransactional\", abstractionDefinition, General::SLAVE, TransactionalTypes::Initiative::REQUIRES);\n\n    QSharedPointer<PortAbstraction> logicalIn = addLogicalPortToAbstraction(\"logicalWire\", abstractionDefinition,\n        General::MASTER, TransactionalTypes::Initiative::INITIATIVE_INVALID, DirectionTypes::IN);\n    QSharedPointer<PortAbstraction> logicalOut = addLogicalPortToAbstraction(\"logicalWire\", abstractionDefinition,\n        General::SLAVE, TransactionalTypes::Initiative::INITIATIVE_INVALID, DirectionTypes::OUT);\n\n    QSharedPointer<Component> transactionProviderComponent = createComponent(\"TestProvider\");\n    QSharedPointer<Component> transactionRequirerComponent = createComponent(\"TestRequirer\");\n\n    QSharedPointer<BusInterface> providerBus = addBusInterfaceToComponent(\n        \"providerBus\", transactionProviderComponent, General::MASTER, busDefinition, abstractionDefinition);\n    QSharedPointer<BusInterface> requirerBus = addBusInterfaceToComponent(\n        \"requirerBus\", transactionRequirerComponent, General::SLAVE, busDefinition, abstractionDefinition);\n\n    QSharedPointer<BusInterface> wireInBus = addBusInterfaceToComponent(\n        \"wireInBus\", transactionProviderComponent, General::MASTER, busDefinition, abstractionDefinition);\n    QSharedPointer<BusInterface> wireOutBus = addBusInterfaceToComponent(\n        \"wireOutBus\", transactionRequirerComponent, General::SLAVE, busDefinition, abstractionDefinition);\n\n    QSharedPointer<Port> providerPort =\n        addPortToComponent(\"providerPort\", transactionProviderComponent, TransactionalTypes::Initiative::PROVIDES);\n    QSharedPointer<Port> requirerPort =\n        addPortToComponent(\"requirerPort\", transactionRequirerComponent, TransactionalTypes::Initiative::REQUIRES);\n\n    QSharedPointer<Port> wireInPort = addPortToComponent(\n        \"wireInPort\", transactionProviderComponent, TransactionalTypes::Initiative::INITIATIVE_INVALID, DirectionTypes::IN);\n    QSharedPointer<Port> wireOutPort = addPortToComponent(\n        \"wireOutPort\", transactionRequirerComponent, TransactionalTypes::Initiative::INITIATIVE_INVALID, DirectionTypes::OUT);\n\n    mapPortsToBusInterface(providerBus, providerPort, logicalProvider);\n    mapPortsToBusInterface(requirerBus, requirerPort, logicalRequirer);\n\n    mapPortsToBusInterface(wireInBus, wireInPort, logicalIn);\n    mapPortsToBusInterface(wireOutBus, wireOutPort, logicalOut);\n\n    QSharedPointer<ComponentInstance> providerInstance =\n        addInstanceToDesign(topDesign, transactionProviderComponent);\n    QSharedPointer<ComponentInstance> requirerInstance =\n        addInstanceToDesign(topDesign, transactionRequirerComponent);\n\n    QSharedPointer<Interconnection> transactionalConnection = addInterconnectionToDesign(\"transactionalConnection\",\n        topDesign, providerBus->name(), providerInstance->getInstanceName(), requirerBus->name(),\n        requirerInstance->getInstanceName());\n\n    QSharedPointer<Interconnection> wireConnection = addInterconnectionToDesign(\"wireConnection\", topDesign,\n        wireInBus->name(), providerInstance->getInstanceName(), wireOutBus->name(),\n        requirerInstance->getInstanceName());\n\n    MessagePasser messages;\n\n    connect(&messages, SIGNAL(errorMessage(const QString&)),\n        this, SLOT(gatherErrorMessage(QString const&)), Qt::UniqueConnection);\n\n    GenerationTuple input;\n    input.component = topComponent;\n    input.design = topDesign;\n    input.messages = &messages;\n\n    QList<QSharedPointer<MetaDesign> > designs =\n        MetaDesign::parseHierarchy(&library_, input, topComponent->getViews()->first());\n\n    QCOMPARE(designs.size(), 1);\n\n    design_ = designs.first();\n    runGenerator(true);\n\n    output_;\n\n    QCOMPARE(errorMessages_.isEmpty(), true);\n\n    verifyOutputContains(\"module topComponent();\\n\\n\"\n        \"    // wireConnection wires:\\n\"\n        \"    wire       wireConnection_logicalWire;\");\n\n    verifyOutputContains(\"    // TestProvider_instance port wires:\\n\"\n        \"    wire       TestProvider_instance_wireInPort;\\n\"\n        \"    // TestRequirer_instance port wires:\\n\"\n        \"    wire       TestRequirer_instance_wireOutPort;\");\n\n    verifyOutputContains(\"    // TestProvider_instance assignments:\\n\"\n        \"    assign TestProvider_instance_wireInPort = wireConnection_logicalWire;\\n\"\n        \"    // TestRequirer_instance assignments:\\n\"\n        \"    assign wireConnection_logicalWire = TestRequirer_instance_wireOutPort;\");\n\n    verifyOutputContains(\"    // IP-XACT VLNV: Test:TestLibrary:TestProvider:1.0\\n\"\n        \"    TestProvider TestProvider_instance(\\n\"\n        \"        // Interface: wireInBus\\n\"\n        \"        .wireInPort          (TestProvider_instance_wireInPort));\");\n\n    verifyOutputContains(\"    // IP-XACT VLNV: Test:TestLibrary:TestRequirer:1.0\\n\"\n        \"    TestRequirer TestRequirer_instance(\\n\"\n        \"        // Interface: wireOutBus\\n\"\n        \"        .wireOutPort         (TestRequirer_instance_wireOutPort));\");\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_VerilogWriterFactory::createComponent()\n//-----------------------------------------------------------------------------\nQSharedPointer<Component> tst_VerilogWriterFactory::createComponent(QString const& componentName)\n{\n    VLNV providerVLNV(VLNV::COMPONENT, \"Test\", \"TestLibrary\", componentName, \"1.0\");\n    QSharedPointer<Component> transactionProviderComponent = addTestComponentToLibrary(providerVLNV);\n\n    return transactionProviderComponent;\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_VerilogWriterFactory::createDesignForComponent()\n//-----------------------------------------------------------------------------\nQSharedPointer<Design> tst_VerilogWriterFactory::createDesignForComponent(QString const& designName,\n    QSharedPointer<Component> component)\n{\n    VLNV designVLNV(VLNV::DESIGN, \"Test\", \"TestLibrary\", designName, \"1.0\");\n    QSharedPointer<Design> newDesign(new Design(designVLNV, Document::Revision::Std14));\n    library_.addComponent(newDesign);\n\n    QSharedPointer<DesignInstantiation> newDesignInstantiation(new DesignInstantiation(\"designInstantiation\"));\n    component->getDesignInstantiations()->append(newDesignInstantiation);\n\n    QSharedPointer<View> newView(new View(\"hierarchical\"));\n    newView->setDesignInstantiationRef(newDesignInstantiation->name());\n    component->getViews()->append(newView);\n\n    return newDesign;\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_VerilogWriterFactory::createBusDefinition()\n//-----------------------------------------------------------------------------\nQSharedPointer<BusDefinition> tst_VerilogWriterFactory::createBusDefinition(QString const& definitionName)\n{\n    VLNV busVLNV(VLNV::BUSDEFINITION, \"Test\", \"TestLibrary\", definitionName, \"1.0\");\n    QSharedPointer<BusDefinition> newBus(new BusDefinition(busVLNV, Document::Revision::Std14));\n    library_.addComponent(newBus);\n\n    return newBus;\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_VerilogWriterFactory::createAbstractionDefinition()\n//-----------------------------------------------------------------------------\nQSharedPointer<AbstractionDefinition> tst_VerilogWriterFactory::createAbstractionDefinition(\n    QString const& definitionName)\n{\n    VLNV abstractionVLNV(VLNV::BUSDEFINITION, \"Test\", \"TestLibrary\", definitionName, \"1.0\");\n    QSharedPointer<AbstractionDefinition> newAbstraction(new AbstractionDefinition(abstractionVLNV, Document::Revision::Std14));\n    library_.addComponent(newAbstraction);\n\n    return newAbstraction;\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_VerilogWriterFactory::addPortToComponent()\n//-----------------------------------------------------------------------------\nQSharedPointer<Port> tst_VerilogWriterFactory::addPortToComponent(QString const& portName,\n    QSharedPointer<Component> containingComponent, TransactionalTypes::Initiative newInitiative,\n    DirectionTypes::Direction newDirection)\n{\n    QSharedPointer<Port> newPort = QSharedPointer<Port>(new Port(portName));\n\n    if (newDirection != DirectionTypes::DIRECTION_INVALID)\n    {\n        QSharedPointer<Wire> newPortWire(new Wire());\n        newPortWire->setDirection(newDirection);\n\n        newPort->setWire(newPortWire);\n    }\n    else if (newInitiative != TransactionalTypes::Initiative::INITIATIVE_INVALID)\n    {\n        QSharedPointer<Transactional> newPortTransactional(new Transactional());\n        newPortTransactional->setInitiative(TransactionalTypes::initiativeToString(newInitiative));\n\n        newPort->setTransactional(newPortTransactional);\n    }\n\n    containingComponent->getPorts()->append(newPort);\n    return newPort;\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_VerilogWriterFactory::addBusInterfaceToComponent()\n//-----------------------------------------------------------------------------\nQSharedPointer<BusInterface> tst_VerilogWriterFactory::addBusInterfaceToComponent(QString const& busName,\n    QSharedPointer<Component> containingComponent, General::InterfaceMode busMode,\n    QSharedPointer<BusDefinition> busDefinition, QSharedPointer<AbstractionDefinition> abstraction,\n    QString const& systemGroup /* = \"\" */)\n{\n    const ConfigurableVLNVReference busVLNV(busDefinition->getVlnv());\n    QSharedPointer<ConfigurableVLNVReference> abstractionVLNV(\n        new ConfigurableVLNVReference(abstraction->getVlnv()));\n\n    QSharedPointer<BusInterface> newInterface(new BusInterface());\n    newInterface->setName(busName);\n    newInterface->setInterfaceMode(busMode);\n    newInterface->setBusType(busVLNV);\n\n    if (!systemGroup.isEmpty())\n    {\n        newInterface->setSystem(systemGroup);\n    }\n\n    QSharedPointer<AbstractionType> newAbstractionType(new AbstractionType());\n    newAbstractionType->setAbstractionRef(abstractionVLNV);\n\n    newInterface->getAbstractionTypes()->append(newAbstractionType);\n\n    containingComponent->getBusInterfaces()->append(newInterface);\n    return newInterface;\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_VerilogWriterFactory::addLogicalPortToAbstraction()\n//-----------------------------------------------------------------------------\nQSharedPointer<PortAbstraction> tst_VerilogWriterFactory::addLogicalPortToAbstraction(QString const& portName,\n    QSharedPointer<AbstractionDefinition> containingAbstraction, General::InterfaceMode busMode,\n    TransactionalTypes::Initiative logicalInitiative /* = TransactionalTypes::Initiative::INITIATIVE_INVALID */,\n    DirectionTypes::Direction logicalDirection /* = DirectionTypes::DIRECTION_INVALID */,\n    QString const& systemGroup /* = \"\" */)\n{\n    QSharedPointer<PortAbstraction> newLogical = containingAbstraction->getPort(portName);\n    if (!newLogical)\n    {\n        newLogical = QSharedPointer<PortAbstraction>(new PortAbstraction());\n        newLogical->setName(portName);\n\n        containingAbstraction->getLogicalPorts()->append(newLogical);\n    }\n\n    if (logicalDirection != DirectionTypes::DIRECTION_INVALID)\n    {\n        QSharedPointer<WireAbstraction> newWireAbstraction = newLogical->getWire();\n        if (!newWireAbstraction)\n        {\n            newWireAbstraction = QSharedPointer<WireAbstraction>(new WireAbstraction());\n            newLogical->setWire(newWireAbstraction);\n        }\n\n        QSharedPointer<WirePort> newWirePort(new WirePort());\n        if (busMode == General::MASTER)\n        {\n            newWireAbstraction->setMasterPort(newWirePort);\n        }\n        else if (busMode == General::SLAVE)\n        {\n            newWireAbstraction->setSlavePort(newWirePort);\n        }\n        else if (busMode == General::SYSTEM)\n        {\n            newWirePort->setSystemGroup(systemGroup);\n            newWireAbstraction->addSystemPort(newWirePort);\n        }\n    }\n    else if (logicalInitiative != TransactionalTypes::Initiative::INITIATIVE_INVALID)\n    {\n        QSharedPointer<TransactionalAbstraction> newTransactionalAbstraction = newLogical->getTransactional();\n        if (!newTransactionalAbstraction)\n        {\n            newTransactionalAbstraction = QSharedPointer<TransactionalAbstraction>(new TransactionalAbstraction());\n            newLogical->setTransactional(newTransactionalAbstraction);\n        }\n\n        QSharedPointer<TransactionalPort> newTransactionalPort(new TransactionalPort());\n        if (busMode == General::MASTER)\n        {\n            newTransactionalAbstraction->setMasterPort(newTransactionalPort);\n        }\n        else if (busMode == General::SLAVE)\n        {\n            newTransactionalAbstraction->setSlavePort(newTransactionalPort);\n        }\n        else if (busMode == General::SYSTEM)\n        {\n            newTransactionalPort->setSystemGroup(systemGroup);\n            newTransactionalAbstraction->addSystemPort(newTransactionalPort);\n        }\n    }\n\n    return newLogical;\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_VerilogWriterFactory::mapPortsToBusInterface()\n//-----------------------------------------------------------------------------\nvoid tst_VerilogWriterFactory::mapPortsToBusInterface(QSharedPointer<BusInterface> containingBus,\n    QSharedPointer<Port> physicalPort, QSharedPointer<PortAbstraction> logicalPort)\n{\n    QSharedPointer<PortMap> newPortMap(new PortMap());\n\n    QSharedPointer<PortMap::PhysicalPort> newPhysical(new PortMap::PhysicalPort(physicalPort->name()));\n    QSharedPointer<PortMap::LogicalPort> newLogical(new PortMap::LogicalPort(logicalPort->name()));\n\n    newPortMap->setPhysicalPort(newPhysical);\n    newPortMap->setLogicalPort(newLogical);\n\n    containingBus->getAbstractionTypes()->first()->getPortMaps()->append(newPortMap);\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_VerilogWriterFactory::mapMultiplePortsToBusInterface()\n//-----------------------------------------------------------------------------\nvoid tst_VerilogWriterFactory::mapMultiplePortsToBusInterface(QSharedPointer<BusInterface> containingBus,\n    QList<QSharedPointer<Port> > physicalPorts, QSharedPointer<PortAbstraction> logicalPort)\n{\n    int logicalIndex = 0;\n\n    for (auto port : physicalPorts)\n    {\n        QSharedPointer<PortMap> newPortMap(new PortMap());\n\n        QSharedPointer<PortMap::PhysicalPort> newPhysical(new PortMap::PhysicalPort(port->name()));\n        QSharedPointer<PortMap::LogicalPort> newLogical(new PortMap::LogicalPort(logicalPort->name()));\n\n        QString logicalLeft = QString::number(logicalIndex);\n\n        int portLeft = port->getLeftBound().toInt();\n        int portRight = port->getRightBound().toInt();\n\n        int portWidth = abs(portLeft - portRight) + 1;\n\n        QString rangeLeft(QString::number(logicalIndex));\n        QString rangeRight(QString::number(logicalIndex + portWidth - 1));\n\n        logicalIndex = logicalIndex + portWidth;\n\n        QSharedPointer<Range> newRange(new Range(rangeLeft, rangeRight));\n        newLogical->range_ = newRange;\n\n        newPortMap->setPhysicalPort(newPhysical);\n        newPortMap->setLogicalPort(newLogical);\n\n        containingBus->getAbstractionTypes()->first()->getPortMaps()->append(newPortMap);\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_VerilogWriterFactory::addInstanceToDesign()\n//-----------------------------------------------------------------------------\nQSharedPointer<ComponentInstance> tst_VerilogWriterFactory::addInstanceToDesign(\n    QSharedPointer<Design> containingDesign, QSharedPointer<Component> instancedComponent)\n{\n    QSharedPointer<ConfigurableVLNVReference> newConfigurableVLNV(\n        new ConfigurableVLNVReference(instancedComponent->getVlnv()));\n\n    QString instanceName = instancedComponent->getVlnv().getName() + \"_instance\";\n    QSharedPointer<ComponentInstance> newComponentInstance(\n        new ComponentInstance(instanceName, newConfigurableVLNV));\n\n    containingDesign->getComponentInstances()->append(newComponentInstance);\n    return newComponentInstance;\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_VerilogWriterFactory::addInterconnectionToDesign()\n//-----------------------------------------------------------------------------\nQSharedPointer<Interconnection> tst_VerilogWriterFactory::addInterconnectionToDesign(\n    QString const& interconnectionName, QSharedPointer<Design> containingDesign, QString const& startInterfaceName,\n    QString const& startInstanceName, QString const& secondInterfaceName, QString const& secondInstanceName)\n{\n    QSharedPointer<ActiveInterface> startInterface(new ActiveInterface(startInstanceName, startInterfaceName));\n    QSharedPointer<ActiveInterface> secondInterface(new ActiveInterface(secondInstanceName, secondInterfaceName));\n\n    QSharedPointer<Interconnection> newInterconnection(new Interconnection(interconnectionName, startInterface));\n    newInterconnection->getActiveInterfaces()->append(secondInterface);\n\n    containingDesign->getInterconnections()->append(newInterconnection);\n    return newInterconnection;\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_VerilogWriterFactory::addHierarchicalInterconnectionToDesign()\n//-----------------------------------------------------------------------------\nQSharedPointer<Interconnection> tst_VerilogWriterFactory::addHierarchicalInterconnectionToDesign(\n    QString const& interconnectionName, QSharedPointer<Design> containingDesign, QString const& topInterface,\n    QString const& targetInterfaceName, QString const& targetInstanceName)\n{\n    QSharedPointer<HierInterface> startInterface(new HierInterface(topInterface));\n    QSharedPointer<ActiveInterface> secondInterface(new ActiveInterface(targetInstanceName, targetInterfaceName));\n\n    QSharedPointer<Interconnection> newInterconnection(new Interconnection(interconnectionName, secondInterface));\n    newInterconnection->getHierInterfaces()->append(startInterface);\n\n    containingDesign->getInterconnections()->append(newInterconnection);\n    return newInterconnection;\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_VerilogWriterFactory::gatherErrorMessage()\n//-----------------------------------------------------------------------------\nvoid tst_VerilogWriterFactory::gatherErrorMessage(QString const& errorMessage)\n{\n    errorMessages_.append(errorMessage);\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_VerilogWriterFactory::testGenerationWithImplementation()\n//-----------------------------------------------------------------------------\nvoid tst_VerilogWriterFactory::testGenerationWithImplementation()\n{\n\tQString contentBefore(\n\t\t\"module TestComponent #(\\n\"\n\t\t\"    parameter                              dataWidth        = 8,\\n\"\n\t\t\"    parameter                              freq             = 100000\\n\"\n\t\t\") (\\n\"\n\t\t\"    // These ports are not in any interface\\n\"         \n\t\t\"    input                               clk,\\n\"\n\t\t\"    input          [7:0]                dataIn,\\n\"\n\t\t\"    input                               rst_n,\\n\"\n\t\t\"    output         [7:0]                dataOut\\n\"\n\t\t\");\\n\"\n\t\t\"assign adr_slave_1 = adr_master;\\n\"\n\t\t\"assign cyc_slave_1 = cyc_master;\\n\"\n\t\t\"endmodule\\n\"\n\t\t);\n\n\tQFile existingFile(\"TestComponent.v\");\n\n\texistingFile.open(QIODevice::WriteOnly);\n\tQTextStream outputStream(&existingFile);\n\n\toutputStream << contentBefore;\n\n\texistingFile.close();\n\n\taddPort(\"clk\", 1, DirectionTypes::IN, flatComponent_);\n\taddPort(\"rst_n\", 1, DirectionTypes::IN, flatComponent_);\n\taddPort(\"dataOut\", 8, DirectionTypes::OUT, flatComponent_);\n\taddPort(\"dataIn\", 8, DirectionTypes::IN, flatComponent_);\n\taddParameter(\"dataWidth\", \"8\", flatComponent_);\n\taddParameter(\"freq\", \"100000\", flatComponent_);\n\n\trunGenerator(false);\n\n\tQString contentAfter(\n\t\t\"module TestComponent #(\\n\"\n\t\t\"    parameter                              dataWidth        = 8,\\n\"\n\t\t\"    parameter                              freq             = 100000\\n\"\n\t\t\") (\\n\"\n\t\t\"    // These ports are not in any interface\\n\"         \n\t\t\"    input                               clk,\\n\"\n\t\t\"    input                [7:0]          dataIn,\\n\"\n\t\t\"    input                               rst_n,\\n\"\n\t\t\"    output               [7:0]          dataOut\\n\"\n\t\t\");\\n\"\n\t\t\"\\n\"\n\t\t\"// \" + VerilogSyntax::TAG_OVERRIDE + \"\\n\"\n\t\t\"assign adr_slave_1 = adr_master;\\n\"\n\t\t\"assign cyc_slave_1 = cyc_master;\\n\"\n\t\t\"endmodule\\n\"\n\t\t);\n\n\tverifyOutputContains(contentAfter);\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_VerilogWriterFactory::testGenerationWithImplementationWithTag()\n//-----------------------------------------------------------------------------\nvoid tst_VerilogWriterFactory::testGenerationWithImplementationWithTag()\n{\n\tQString content(\n\t\t\"module TestComponent #(\\n\"\n\t\t\"    parameter                              dataWidth        = 8,\\n\"\n\t\t\"    parameter                              freq             = 100000\\n\"\n\t\t\") (\\n\"\n\t\t\"    // These ports are not in any interface\\n\"         \n\t\t\"    input                               clk,\\n\"\n\t\t\"    input                [7:0]          dataIn,\\n\"\n\t\t\"    input                               rst_n,\\n\"\n\t\t\"    output               [7:0]          dataOut\\n\"\n\t\t\");\\n\"\n\t\t\"\\n\"\n\t\t\"// \" + VerilogSyntax::TAG_OVERRIDE + \"\\n\"\n\t\t\"foo\\n\"\n\t\t\"bar\\n\"\n\t\t\"endmodule\\n\"\n\t\t);\n\n\tQFile existingFile(\"TestComponent.v\");\n\n\texistingFile.open(QIODevice::WriteOnly);\n\tQTextStream outputStream(&existingFile);\n\n\toutputStream << content;\n\n\texistingFile.close();\n\n\taddPort(\"clk\", 1, DirectionTypes::IN, flatComponent_);\n\taddPort(\"rst_n\", 1, DirectionTypes::IN, flatComponent_);\n\taddPort(\"dataOut\", 8, DirectionTypes::OUT, flatComponent_);\n\taddPort(\"dataIn\", 8, DirectionTypes::IN, flatComponent_);\n\taddParameter(\"dataWidth\", \"8\", flatComponent_);\n\taddParameter(\"freq\", \"100000\", flatComponent_);\n\n\trunGenerator(false);\n\n\tverifyOutputContains(content);\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_VerilogWriterFactory::testGenerationWithImplementationWithPostModule()\n//-----------------------------------------------------------------------------\nvoid tst_VerilogWriterFactory::testGenerationWithImplementationWithPostModule()\n{\n\tQString content(\n\t\t\"module TestComponent #(\\n\"\n\t\t\"    parameter                              dataWidth        = 8,\\n\"\n\t\t\"    parameter                              freq             = 100000\\n\"\n\t\t\") (\\n\"\n\t\t\"    // These ports are not in any interface\\n\"         \n\t\t\"    input                               clk,\\n\"\n\t\t\"    input                [7:0]          dataIn,\\n\"\n\t\t\"    input                               rst_n,\\n\"\n\t\t\"    output               [7:0]          dataOut\\n\"\n\t\t\");\\n\"\n\t\t\"\\n\"\n\t\t\"// \" + VerilogSyntax::TAG_OVERRIDE + \"\\n\"\n\t\t\"foo\\n\"\n\t\t\"bar\\n\"\n\t\t\"endmodule\\n\"\n\t\t\"additional stuff\\n\"\n\t\t\"more stuff\"\n\t\t);\n\n\tQFile existingFile(\"TestComponent.v\");\n\n\texistingFile.open(QIODevice::WriteOnly);\n\tQTextStream outputStream(&existingFile);\n\n\toutputStream << content;\n\n\texistingFile.close();\n\n\taddPort(\"clk\", 1, DirectionTypes::IN, flatComponent_);\n\taddPort(\"rst_n\", 1, DirectionTypes::IN, flatComponent_);\n\taddPort(\"dataOut\", 8, DirectionTypes::OUT, flatComponent_);\n\taddPort(\"dataIn\", 8, DirectionTypes::IN, flatComponent_);\n\taddParameter(\"dataWidth\", \"8\", flatComponent_);\n\taddParameter(\"freq\", \"100000\", flatComponent_);\n\n\trunGenerator(false);\n\n\tverifyOutputContains(content);\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_VerilogWriterFactory::verifyOutputContains()\n//-----------------------------------------------------------------------------\nvoid tst_VerilogWriterFactory::verifyOutputContains(QString const& expectedOutput)\n{\n    if (!output_.contains(expectedOutput))\n    {\n        QStringList outputLines = output_.split(\"\\n\");\n        QStringList expectedLines = expectedOutput.split(\"\\n\");\n\n        QVERIFY(outputLines.count() >= expectedLines.count());\n\n        int lineOffset = outputLines.indexOf(expectedLines.first());\n\n        if (lineOffset == -1)\n        {\n            compareOutputTo(expectedOutput);\n        }\n        else\n        {\n            int lineCount = expectedLines.count();\n            for (int i = 0; i < lineCount; i++)\n            {\n                QCOMPARE(outputLines.at(i + lineOffset), expectedLines.at(i));\n            }\n        }\n    }\n    else if(output_.count(expectedOutput) != 1)\n    {\n        QVERIFY2(false, QString(expectedOutput + \" was found \" + QString::number(output_.count(expectedOutput))\n            + \" times in output.\").toLocal8Bit());\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: tst_VerilogWriterFactory::compareLineByLine()\n//-----------------------------------------------------------------------------\nvoid tst_VerilogWriterFactory::compareOutputTo(QString const& expectedOutput)\n{\n    QCOMPARE(output_, expectedOutput);\n}\n\nQTEST_APPLESS_MAIN(tst_VerilogWriterFactory)\n\n#include \"tst_VerilogWriterFactory.moc\"\n"
  },
  {
    "path": "tests/Plugins/VerilogGenerator/tst_VerilogWriterFactory.pri",
    "content": "# ----------------------------------------------------\n# This file is generated by the Qt Visual Studio Tools.\n# ------------------------------------------------------\n\n# This is a reminder that you are using a generated .pro file.\n# Remove it when you are finished editing this file.\nmessage(\"You are running qmake on a generated .pro file. This may not work!\")\n\n\nHEADERS += ../../../Plugins/VerilogGenerator/CommentWriter/CommentWriter.h \\\n    ../../../Plugins/VerilogGenerator/ComponentInstanceVerilogWriter/ComponentInstanceVerilogWriter.h \\\n    ../../../IPXACTmodels/utilities/ComponentSearch.h \\\n    ../../../Plugins/VerilogGenerator/ComponentVerilogWriter/ComponentVerilogWriter.h \\\n    ../../../Plugins/PluginSystem/GeneratorPlugin/GenerationControl.h \\\n    ../../../Plugins/common/HDLParser/HDLParserCommon.h \\\n    ../../../Plugins/PluginSystem/GeneratorPlugin/IWriterFactory.h \\\n    ../../../Plugins/common/PortSorter/InterfaceDirectionNameSorter.h \\\n    ../../../Plugins/common/HDLParser/MetaComponent.h \\\n    ../../../Plugins/common/HDLParser/MetaDesign.h \\\n    ../../../Plugins/common/HDLParser/MetaInstance.h \\\n    ../../../Plugins/VerilogGenerator/ModelParameterVerilogWriter/ModelParameterVerilogWriter.h \\\n    ../../../Plugins/PluginSystem/GeneratorPlugin/OutputControl.h \\\n    ../../../Plugins/common/PortSorter/PortSorter.h \\\n    ../../../Plugins/VerilogGenerator/TextBodyWriter/TextBodyWriter.h \\\n    ../../../editors/common/TopComponentParameterFinder.h \\\n    ../../../Plugins/VerilogGenerator/VerilogAssignmentWriter/VerilogAssignmentWriter.h \\\n    ../../../Plugins/VerilogGenerator/VerilogWriterFactory/VerilogDocument.h \\\n    ../../../Plugins/VerilogGenerator/VerilogHeaderWriter/VerilogHeaderWriter.h \\\n    ../../../Plugins/VerilogGenerator/VerilogInterconnectionWriter/VerilogInterconnectionWriter.h \\\n    ../../../Plugins/VerilogGenerator/VerilogPortWriter/VerilogPortWriter.h \\\n    ../../../Plugins/VerilogImport/VerilogSyntax.h \\\n    ../../../Plugins/VerilogGenerator/VerilogPortWriter/VerilogTopDefaultWriter.h \\\n    ../../../Plugins/VerilogGenerator/VerilogWireWriter/VerilogWireWriter.h \\\n    ../../../Plugins/VerilogGenerator/VerilogWriterFactory/VerilogWriterFactory.h \\\n    ../../../Plugins/VerilogGenerator/common/Writer.h \\\n    ../../../Plugins/VerilogGenerator/common/WriterGroup.h \\\n    ../../MockObjects/LibraryMock.h \\\n    ../../../Plugins/PluginSystem/GeneratorPlugin/MessagePasser.h\nSOURCES += ../../../Plugins/VerilogGenerator/CommentWriter/CommentWriter.cpp \\\n    ../../../Plugins/VerilogGenerator/ComponentInstanceVerilogWriter/ComponentInstanceVerilogWriter.cpp \\\n    ../../../IPXACTmodels/utilities/ComponentSearch.cpp \\\n    ../../../Plugins/VerilogGenerator/ComponentVerilogWriter/ComponentVerilogWriter.cpp \\\n    ../../../Plugins/common/PortSorter/InterfaceDirectionNameSorter.cpp \\\n    ../../MockObjects/LibraryMock.cpp \\\n    ../../../Plugins/PluginSystem/GeneratorPlugin/MessagePasser.cpp \\\n    ../../../Plugins/common/HDLParser/MetaComponent.cpp \\\n    ../../../Plugins/common/HDLParser/MetaDesign.cpp \\\n    ../../../Plugins/common/HDLParser/MetaInstance.cpp \\\n    ../../../Plugins/VerilogGenerator/ModelParameterVerilogWriter/ModelParameterVerilogWriter.cpp \\\n    ../../../Plugins/PluginSystem/GeneratorPlugin/OutputControl.cpp \\\n    ../../../Plugins/VerilogGenerator/TextBodyWriter/TextBodyWriter.cpp \\\n    ../../../editors/common/TopComponentParameterFinder.cpp \\\n    ../../../Plugins/VerilogGenerator/VerilogAssignmentWriter/VerilogAssignmentWriter.cpp \\\n    ../../../Plugins/VerilogGenerator/VerilogWriterFactory/VerilogDocument.cpp \\\n    ../../../Plugins/VerilogGenerator/VerilogHeaderWriter/VerilogHeaderWriter.cpp \\\n    ../../../Plugins/VerilogGenerator/VerilogInterconnectionWriter/VerilogInterconnectionWriter.cpp \\\n    ../../../Plugins/VerilogGenerator/VerilogPortWriter/VerilogPortWriter.cpp \\\n    ../../../Plugins/VerilogImport/VerilogSyntax.cpp \\\n    ../../../Plugins/VerilogGenerator/VerilogPortWriter/VerilogTopDefaultWriter.cpp \\\n    ../../../Plugins/VerilogGenerator/VerilogWireWriter/VerilogWireWriter.cpp \\\n    ../../../Plugins/VerilogGenerator/VerilogWriterFactory/VerilogWriterFactory.cpp \\\n    ../../../Plugins/VerilogGenerator/common/WriterGroup.cpp \\\n    ./tst_VerilogWriterFactory.cpp\n"
  },
  {
    "path": "tests/Plugins/VerilogGenerator/tst_VerilogWriterFactory.pro",
    "content": "#-----------------------------------------------------------------------------\n# File: unittest.pro\n#-----------------------------------------------------------------------------\n# Project: Kactus2\n# Author: Janne Virtanen\n# Date: 26.01.2017\n#\n# Description:\n# Qt project file for running unit tests for VerilogWriterFactory.\n#-----------------------------------------------------------------------------\n\nTEMPLATE = app\n\nTARGET = tst_VerilogWriterFactory\n\nQT += core xml gui testlib\nCONFIG += c++11 testcase console\n\nDEFINES += VERILOGGENERATORPLUGIN_LIB\n\nwin32:CONFIG(release, debug|release) {\n    LIBS += -L$$PWD/../../../executable/ -lIPXACTmodels\n    LIBS += -L$$PWD/../../../executable/ -lKactusAPI\n    DESTDIR = ./release\n}\nelse:win32:CONFIG(debug, debug|release) {\n    LIBS += -L$$PWD/../../../executable/ -lIPXACTmodelsd\n    LIBS += -L$$PWD/../../../executable/ -lKactusAPId\n    DESTDIR = ./debug\n}\nelse:unix {\n    LIBS += -L$$PWD/../../../executable/ -lIPXACTmodels\n    LIBS += -L$$PWD/../../../executable/ -lKactusAPI\n    DESTDIR = ./release\n}\n\nINCLUDEPATH += $$PWD/../../../\nINCLUDEPATH += $$PWD/../../../executable\nINCLUDEPATH += $$PWD/../../../executable/Plugins\nINCLUDEPATH += $$PWD/../../../KactusAPI/include\nINCLUDEPATH += $$DESTDIR\n\nDEPENDPATH += $$PWD/../../../\nDEPENDPATH += $$PWD/../../../executable\nDEPENDPATH += $$PWD/../../../executable/Plugins\nDEPENDPATH += .\n\nOBJECTS_DIR += $$DESTDIR\n\nMOC_DIR += ./generatedFiles\nUI_DIR += ./generatedFiles\nRCC_DIR += ./generatedFiles\ninclude(tst_VerilogWriterFactory.pri)\n"
  },
  {
    "path": "tests/Plugins/VerilogImport/VerilogImport.pro",
    "content": "######################################################################\r\n# Automatically generated by qmake (3.0) to syys 25 13:28:24 2014\r\n######################################################################\r\n\r\nTEMPLATE = subdirs\r\n\r\nCONFIG += testcase\r\n\r\nSUBDIRS += tst_HDLParser.pro \\\r\n           tst_VerilogPortParser.pro \\\r\n           tst_VerilogParameterParser.pro\\\r\n           tst_VerilogImporter.pro\r\n"
  },
  {
    "path": "tests/Plugins/VerilogImport/tst_HDLParser.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: tst_HDLParser.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Janne Virtanen\r\n// Date: 31.8.2016\r\n//\r\n// Description:\r\n// Unit test suite for HDL parsing.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include <QtTest>\r\n\r\n#include <IPXACTmodels/AbstractionDefinition/AbstractionDefinition.h>\r\n#include <IPXACTmodels/AbstractionDefinition/PortAbstraction.h>\r\n#include <IPXACTmodels/AbstractionDefinition/WireAbstraction.h>\r\n#include <IPXACTmodels/AbstractionDefinition/WirePort.h>\r\n\r\n#include <IPXACTmodels/Component/Component.h>\r\n#include <IPXACTmodels/Component/BusInterface.h>\r\n#include <IPXACTmodels/Component/Model.h>\r\n#include <IPXACTmodels/Component/Port.h>\r\n#include <IPXACTmodels/Component/PortMap.h>\r\n#include <IPXACTmodels/Component/ComponentInstantiation.h>\r\n\r\n#include <IPXACTmodels/common/ModuleParameter.h>\r\n#include <IPXACTmodels/common/VLNV.h>\r\n\r\n#include <IPXACTmodels/Design/Design.h>\r\n#include <IPXACTmodels/DesignConfiguration/DesignConfiguration.h>\r\n#include <IPXACTmodels/Design/ComponentInstance.h>\r\n\r\n#include <tests/MockObjects/LibraryMock.h>\r\n\r\n#include <Plugins/common/HDLParser/MetaComponent.h>\r\n#include <Plugins/common/HDLParser/MetaDesign.h>\r\n\r\n#include <Plugins/PluginSystem/GeneratorPlugin/MessagePasser.h>\r\n\r\nclass tst_HDLParser : public QObject\r\n{\r\n    Q_OBJECT\r\n\r\npublic:\r\n    tst_HDLParser();\r\n\r\nprivate slots:\r\n    void initTestCase();\r\n    void cleanupTestCase();\r\n    void init();\r\n    void cleanup();\r\n\r\n    // Hierarchy test cases:\r\n    void testTopLevelComponent();\r\n    void testTopLevelComponentExpressions();\r\n\r\n    void testHierarchicalConnections();\r\n    void testHierarchicalConnectionsWithExpressions();\r\n\r\n    //void testPortMapping();\r\n\r\n    void testMasterToSlaveInterconnection();\r\n    void testEmptyBounds();\r\n    void testMasterToSlaveInterconnectionWithExpressions();\r\n    void testMasterToMultipleSlavesInterconnections();\r\n    void testInterconnectionToVaryingSizeLogicalMaps();\r\n    void testSlicedInterconnection();\r\n    //void testAbsDefDefault();\r\n    void testPortDefaultValueInComponentInstance();\r\n    void testHierarchicalPortDefaultValue();\r\n\r\n    void testAdhocConnectionBetweenComponentInstances();    \r\n    void testAdhocConnectionToVaryingSizePorts();    \r\n    void testAdhocConnectionWithPartSelect();\r\n    void testAdhocTieOffInComponentInstance();\r\n    void testHierarchicalAdhocConnection();\r\n    void testAdHocConnectionBetweenMultipleComponentInstances();\r\n\r\n    void testInstanceParametersAreCulled();\r\n    void testDesignParametersAreUtilized();\r\n\tvoid testTopComponentParametersAreUtilized();\r\n\r\n    // Flat test cases:\r\n    void testFlatComponent();\r\n    void testFlatComponentExpressions();\r\n\r\n    void testParameterSorting();\r\n    void testParameterSorting2();\r\n    void testParameterSorting3();\r\n\r\nprivate:\r\n\r\n    QSharedPointer<Port> addPort(QString const& portName, int portSize, DirectionTypes::Direction direction, \r\n        QSharedPointer<Component> component);\r\n\r\n    void addParameter(QString const& name, QString const& value, QString const& valueID, QSharedPointer<Component> component);\r\n    void addParameter(QString const& name, QString const& value, QString const& valueID, QSharedPointer<Design> design);\r\n\r\n    void addModuleParameter(QString const& name, QString const& value, QString const& valueID, QSharedPointer<Component> component);\r\n\r\n    void createHierarchicalConnection(QString const& topInterfaceRef, QString const& instanceInterfaceRef);\r\n\r\n    QSharedPointer<View> addTestComponentToLibrary(VLNV vlnv);\r\n\r\n    QSharedPointer<ComponentInstance> addInstanceToDesign(QString instanceName, VLNV instanceVlnv, QSharedPointer<View> activeView);\r\n\r\n    QSharedPointer<PortMap> mapPortToInterface(QString const& portName, QString const& logicalName, \r\n        QString const& interfaceName, QSharedPointer<Component> component);\r\n\r\n    QSharedPointer<PortMap> mapPortToInterface(QString const& portName, int left, int right, \r\n        QString const& logicalName, QString const& interfaceName, QSharedPointer<Component> component);\r\n    \r\n    QSharedPointer<BusInterface> addInterfaceToComponent(QString const& interfaceName, QSharedPointer<Component> component, QSharedPointer<ConfigurableVLNVReference> absRef);\r\n\r\n    QSharedPointer<View> addSenderComponentToLibrary(VLNV senderVLNV, General::InterfaceMode mode, bool createInterfaces = true);\r\n\r\n    QSharedPointer<View> addReceiverComponentToLibrary(VLNV receiverVLNV, General::InterfaceMode mode, bool createInterfaces = true);    \r\n\r\n    void setReceiverComponentDataWidth(VLNV receiverVLNV, int dataWidth);\r\n\r\n    void addConnectionToDesign(QString fromInstance, QString fromInterface, QString toInstance, QString toInterface);\r\n\r\n    QSharedPointer<AdHocConnection> addAdhocConnection(QString const& connectionName, QString const& sourceInstance, QString const& sourcePort,\r\n        QString const& targetInstance, QString const& targetPort);\r\n\r\n    void addTieOffAdhocConnectionToInstancePort(QString const& tieOffValue, QString const& instanceName,\r\n        QString const& portName, QString const& connectionName);\r\n\r\n    void addTieOffConnectionToTopComponentPort(QString const& tieOffValue, QString const& portName,\r\n        QString const& connectionName);\r\n\r\n    void addHierAdhocConnection(QString const& topPort, QString const& targetInstance, QString const& targetPort);\r\n   \r\n    //! The top level component used in the tests.\r\n    QSharedPointer<Component> topComponent_;\r\n    \r\n    //! The design used in the tests.\r\n    QSharedPointer<Design> design_;\r\n\r\n\t//! The design configuration used in the tests.\r\n    QSharedPointer<DesignConfiguration> designConf_;\r\n\r\n    //! Channel for generation messages.\r\n    MessagePasser messageChannel_;\r\n\r\n    //! The above three bundled together.\r\n    GenerationTuple input_;\r\n\r\n    //! The abstraction definitions used in the tests.\r\n    QSharedPointer<ConfigurableVLNVReference> clkAbstractionVLNV_;\r\n    QSharedPointer<AbstractionDefinition> clkAbstractionDefinition_;\r\n    QSharedPointer<ConfigurableVLNVReference> dataAbstractionVLNV_;\r\n    QSharedPointer<AbstractionDefinition> dataAbstractionDefinition_;\r\n\r\n    //! The view of the top component chosen as the active view.\r\n\tQSharedPointer<View> topView_;\r\n\r\n    //! The test mock for library interface.\r\n    LibraryMock library_;\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_HDLParser::tst_HDLParser()\r\n//-----------------------------------------------------------------------------\r\ntst_HDLParser::tst_HDLParser(): \r\ntopComponent_(), \r\n    design_(), \r\n    designConf_(),\r\n    messageChannel_(),\r\n    input_(), \r\n    clkAbstractionVLNV_(),\r\n    clkAbstractionDefinition_(),\r\n    dataAbstractionVLNV_(),\r\n    dataAbstractionDefinition_(),\r\n    topView_(), \r\n    library_(this)\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_HDLParser::initTestCase()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_HDLParser::initTestCase()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_HDLParser::cleanupTestCase()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_HDLParser::cleanupTestCase()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_HDLParser::init()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_HDLParser::init()\r\n{\r\n    VLNV vlnv(VLNV::COMPONENT, \"Test\", \"TestLibrary\", \"TestComponent\", \"1.0\");\r\n    topComponent_ = QSharedPointer<Component>(new Component(vlnv, Document::Revision::Std14));\r\n\r\n    topView_ = QSharedPointer<View>(new View(\"topView\"));\r\n    topComponent_->getViews()->append(topView_);\r\n\r\n    QSharedPointer<ConfigurableVLNVReference> designVlnv(\r\n        new ConfigurableVLNVReference(VLNV::DESIGN, \"Test\", \"TestLibrary\", \"TestDesign\", \"1.0\"));\r\n    design_ = QSharedPointer<Design>(new Design(*designVlnv, Document::Revision::Std14));\r\n\r\n    QSharedPointer<DesignInstantiation> di(new DesignInstantiation);\r\n    di->setName(\"TestDesignInstantiation\");\r\n    topView_->setDesignInstantiationRef(di->name());\r\n    di->setDesignReference(designVlnv);\r\n    topComponent_->getDesignInstantiations()->append(di);\r\n\r\n\tVLNV designConfVlnv(VLNV::DESIGNCONFIGURATION, \"Test\", \"TestLibrary\", \"TestDesignConfiguration\", \"1.0\");\r\n\tdesignConf_ = QSharedPointer<DesignConfiguration>(new DesignConfiguration(designConfVlnv, Document::Revision::Std14));\r\n    designConf_->setDesignRef(*designVlnv);\r\n\r\n    input_.component = topComponent_;\r\n    input_.design = design_;\r\n    input_.designConfiguration = designConf_;\r\n    input_.messages = &messageChannel_;\r\n\r\n    clkAbstractionVLNV_ = QSharedPointer<ConfigurableVLNVReference>(new ConfigurableVLNVReference(\r\n        VLNV::ABSTRACTIONDEFINITION, \"Test\", \"TestLibrary\", \"clkAbsDef\", \"1.0\"));\r\n\r\n    clkAbstractionDefinition_ =  \r\n        QSharedPointer<AbstractionDefinition>(new AbstractionDefinition(*clkAbstractionVLNV_, Document::Revision::Std14));\r\n\r\n    dataAbstractionVLNV_ = QSharedPointer<ConfigurableVLNVReference>(new ConfigurableVLNVReference(\r\n        VLNV::ABSTRACTIONDEFINITION, \"Test\", \"TestLibrary\", \"dataAbsDef\", \"1.0\"));\r\n\r\n    dataAbstractionDefinition_ =  \r\n        QSharedPointer<AbstractionDefinition>(new AbstractionDefinition(*dataAbstractionVLNV_, Document::Revision::Std14));\r\n\r\n    QSharedPointer<PortAbstraction> logicalPort(new PortAbstraction());\r\n    logicalPort->setName(\"CLK\");\r\n    logicalPort->setWire(QSharedPointer<WireAbstraction>(new WireAbstraction()));\r\n    clkAbstractionDefinition_->getLogicalPorts()->append(logicalPort);\r\n\r\n    logicalPort = QSharedPointer<PortAbstraction>(new PortAbstraction());\r\n    logicalPort->setName(\"DATA\");\r\n    logicalPort->setWire(QSharedPointer<WireAbstraction>(new WireAbstraction()));\r\n    dataAbstractionDefinition_->getLogicalPorts()->append(logicalPort);\r\n    logicalPort = QSharedPointer<PortAbstraction>(new PortAbstraction());\r\n    logicalPort->setName(\"ENABLE\");\r\n    logicalPort->setWire(QSharedPointer<WireAbstraction>(new WireAbstraction()));\r\n    dataAbstractionDefinition_->getLogicalPorts()->append(logicalPort);\r\n    logicalPort = QSharedPointer<PortAbstraction>(new PortAbstraction());\r\n    logicalPort->setName(\"FULL\");\r\n    logicalPort->setWire(QSharedPointer<WireAbstraction>(new WireAbstraction()));\r\n    dataAbstractionDefinition_->getLogicalPorts()->append(logicalPort);\r\n\r\n    library_.clear();\r\n    library_.addComponent(dataAbstractionDefinition_);\r\n    library_.addComponent(clkAbstractionDefinition_);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_HDLParser::cleanup()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_HDLParser::cleanup()\r\n{\r\n    topComponent_.clear();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_HDLParser::testTopLevelComponent()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_HDLParser::testTopLevelComponent()\r\n{\r\n    addPort(\"clk\", 1, DirectionTypes::IN, topComponent_);\r\n    addPort(\"rst_n\", 1, DirectionTypes::IN, topComponent_);\r\n    addPort(\"dataOut\", 8, DirectionTypes::OUT, topComponent_);\r\n    addPort(\"dataIn\", 8, DirectionTypes::IN, topComponent_);\r\n    addModuleParameter(\"dataWidth\", \"8\", \"firstParameter\", topComponent_);\r\n    addModuleParameter(\"freq\", \"100000\", \"secondParameter\", topComponent_);\r\n\r\n    QList<QSharedPointer<MetaDesign> > designs = MetaDesign::parseHierarchy\r\n        (&library_, input_, topView_);\r\n\r\n    QCOMPARE(designs.size(), 1);\r\n    QSharedPointer<MetaDesign> design = designs.first();\r\n\r\n    QVERIFY(design->getTopInstance());\r\n    QSharedPointer<MetaInstance> mInstance = design->getTopInstance();\r\n\r\n    QCOMPARE(mInstance->getModuleParameters()->size(), 2);\r\n    QCOMPARE(mInstance->getModuleParameters()->value(0)->name(), QString(\"dataWidth\"));\r\n    QCOMPARE(mInstance->getModuleParameters()->value(0)->getValue(), QString(\"8\"));\r\n    QCOMPARE(mInstance->getModuleParameters()->value(1)->name(), QString(\"freq\"));\r\n    QCOMPARE(mInstance->getModuleParameters()->value(1)->getValue(), QString(\"100000\"));\r\n\r\n    QCOMPARE(mInstance->getPorts()->size(), 4);\r\n    QCOMPARE(mInstance->getPorts()->value(\"clk\")->port_->getDirection(), DirectionTypes::IN);\r\n\r\n    QCOMPARE(mInstance->getPorts()->value(\"dataIn\")->port_->getDirection(), DirectionTypes::IN);\r\n    QCOMPARE(mInstance->getPorts()->value(\"dataIn\")->vectorBounds_.first, QString(\"7\"));\r\n    QCOMPARE(mInstance->getPorts()->value(\"dataIn\")->vectorBounds_.second, QString(\"0\"));\r\n\r\n    QCOMPARE(mInstance->getPorts()->value(\"rst_n\")->port_->getDirection(), DirectionTypes::IN);\r\n\r\n    QCOMPARE(mInstance->getPorts()->value(\"dataOut\")->port_->getDirection(), DirectionTypes::OUT);\r\n    QCOMPARE(mInstance->getPorts()->value(\"dataOut\")->vectorBounds_.first, QString(\"7\"));\r\n    QCOMPARE(mInstance->getPorts()->value(\"dataOut\")->vectorBounds_.second, QString(\"0\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_HDLParser::testTopLevelComponentExpressions()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_HDLParser::testTopLevelComponentExpressions()\r\n{\r\n    addParameter(\"module\", \"10\", \"firstParameter\", topComponent_);\r\n    addParameter(\"freq\", \"firstParameter*3.14\", \"secondParameter\", topComponent_);\r\n\r\n    QSharedPointer<Port> port = QSharedPointer<Port>(new Port(\"clk\"));\r\n    port->setDirection(DirectionTypes::IN);\r\n    port->setLeftBound(\"secondParameter*2\");\r\n    port->setRightBound(\"2+5\");\r\n    topComponent_->getPorts()->append(port);\r\n\r\n    QList<QSharedPointer<MetaDesign> > designs = MetaDesign::parseHierarchy\r\n        (&library_, input_, topView_);\r\n\r\n    QCOMPARE(designs.size(), 1);\r\n    QSharedPointer<MetaDesign> design = designs.first();\r\n\r\n    QVERIFY(design->getTopInstance());\r\n    QSharedPointer<MetaInstance> mInstance = design->getTopInstance();\r\n\r\n    QCOMPARE(mInstance->getParameters()->size(), 2);\r\n    QCOMPARE(mInstance->getParameters()->value(0)->name(), QString(\"module\"));\r\n    QCOMPARE(mInstance->getParameters()->value(0)->getValue(), QString(\"10\"));\r\n    QCOMPARE(mInstance->getParameters()->value(1)->name(), QString(\"freq\"));\r\n    QCOMPARE(mInstance->getParameters()->value(1)->getValue(), QString(\"31.40\"));\r\n\r\n    QCOMPARE(mInstance->getPorts()->size(), 1);\r\n    QCOMPARE(mInstance->getPorts()->value(\"clk\")->port_->getDirection(), DirectionTypes::IN);\r\n    QCOMPARE(mInstance->getPorts()->value(\"clk\")->vectorBounds_.first, QString(\"62.80\"));\r\n    QCOMPARE(mInstance->getPorts()->value(\"clk\")->vectorBounds_.second, QString(\"7\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_HDLParser::addPort()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<Port> tst_HDLParser::addPort(QString const& portName, int portSize, \r\n    DirectionTypes::Direction direction, QSharedPointer<Component> component)\r\n{\r\n    QSharedPointer<Port> port = QSharedPointer<Port>(new Port(portName));\r\n    port->setDirection(direction);\r\n    port->setPortSize(portSize);\r\n    component->getPorts()->append(port);\r\n\r\n    return port;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_HDLParser::addParameter()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_HDLParser::addParameter(QString const& name, QString const& value, QString const& valueID, QSharedPointer<Component> component)\r\n{\r\n    QSharedPointer<Parameter> parameter = QSharedPointer<Parameter>(new Parameter());\r\n    parameter->setName(name);\r\n    parameter->setValue(value);\r\n    parameter->setValueId(valueID);\r\n    parameter->setValueResolve(\"user\");\r\n\r\n    component->getParameters()->append(parameter);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_HDLParser::addParameter()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_HDLParser::addParameter(QString const& name, QString const& value, QString const& valueID, QSharedPointer<Design> design)\r\n{\r\n    QSharedPointer<Parameter> parameter = QSharedPointer<Parameter>(new Parameter());\r\n    parameter->setName(name);\r\n    parameter->setValue(value);\r\n    parameter->setValueId(valueID);\r\n    parameter->setValueResolve(\"user\");\r\n\r\n    design->getParameters()->append(parameter);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_HDLParser::addModuleParameter()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_HDLParser::addModuleParameter(QString const& name, QString const& value, QString const& valueID, QSharedPointer<Component> component)\r\n{\r\n    QSharedPointer<ModuleParameter> parameter = QSharedPointer<ModuleParameter>(new ModuleParameter());\r\n    parameter->setName(name);\r\n    parameter->setValue(value);\r\n    parameter->setValueId(valueID);\r\n    parameter->setValueResolve(\"user\");\r\n\r\n    if (component->getComponentInstantiations()->isEmpty())\r\n    {\r\n        QSharedPointer<ComponentInstantiation> newInstantiation (new ComponentInstantiation(\"testInstantiation\"));\r\n        newInstantiation->getModuleParameters()->append(parameter);\r\n        component->getComponentInstantiations()->append(newInstantiation);\r\n\r\n        topView_->setComponentInstantiationRef(newInstantiation->name());\r\n    }\r\n    else\r\n    {\r\n        component->getComponentInstantiations()->first()->getModuleParameters()->append(parameter);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_HDLParser::testHierarchicalConnections()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_HDLParser::testHierarchicalConnections()\r\n{\r\n    addPort(\"top_clk\", 1, DirectionTypes::IN, topComponent_);\r\n    addPort(\"data_to_instance\", 8, DirectionTypes::IN, topComponent_);\r\n    addPort(\"enable_to_instance\", 1, DirectionTypes::IN, topComponent_);\r\n    addPort(\"full_from_instance\", 1, DirectionTypes::OUT, topComponent_);\r\n\r\n    addInterfaceToComponent(\"clk_if\", topComponent_, clkAbstractionVLNV_);\r\n    addInterfaceToComponent(\"data_bus\", topComponent_, dataAbstractionVLNV_);\r\n    \r\n    mapPortToInterface(\"top_clk\", \"CLK\", \"clk_if\", topComponent_);\r\n    mapPortToInterface(\"data_to_instance\", \"DATA\", \"data_bus\", topComponent_);\r\n    mapPortToInterface(\"enable_to_instance\", \"ENABLE\", \"data_bus\", topComponent_);\r\n    mapPortToInterface(\"full_from_instance\", \"FULL\", \"data_bus\", topComponent_);\r\n\r\n    createHierarchicalConnection(\"clk_if\", \"clk\");\r\n    createHierarchicalConnection(\"data_bus\", \"data\");\r\n\r\n    VLNV instanceVlnv(VLNV::COMPONENT, \"Test\", \"TestLibrary\", \"TestInstance\", \"1.0\");\r\n    QSharedPointer<View> activeView = addTestComponentToLibrary(instanceVlnv);\r\n    addInstanceToDesign(\"instance1\", instanceVlnv, activeView);\r\n\r\n    QList<QSharedPointer<MetaDesign> > designs = MetaDesign::parseHierarchy\r\n        (&library_, input_, topView_);\r\n\r\n    QCOMPARE(designs.size(), 1);\r\n    QSharedPointer<MetaDesign> design = designs.first();\r\n\r\n    QCOMPARE(design->getInstances()->size(), 1);\r\n\r\n    QSharedPointer<MetaInstance> mInstance = design->getInstances()->value(\"instance1\");\r\n    QCOMPARE(mInstance->getInterfaces()->size(), 2);\r\n\r\n    QSharedPointer<MetaInterface> mInterface = mInstance->getInterfaces()->value(\"clk\");\r\n    QCOMPARE(mInterface->ports_.size(), 1);\r\n\r\n    QSharedPointer<MetaPort> mPort = mInterface->ports_.value(\"clk\");\r\n    QSharedPointer<MetaPortAssignment> mpa = mPort->upAssignments_.value(\"CLK\");\r\n    QCOMPARE(mpa->wire_->hierPorts_.first()->port_->name(), QString(\"top_clk\"));\r\n\r\n    mInterface = mInstance->getInterfaces()->value(\"data\");\r\n    QCOMPARE(mInterface->ports_.size(), 3);\r\n\r\n    mPort = mInterface->ports_.value(\"data_in\");\r\n    mpa = mPort->upAssignments_.value(\"DATA\");\r\n    QCOMPARE(mpa->wire_->hierPorts_.first()->port_->name(), QString(\"data_to_instance\"));\r\n\r\n    mPort = mInterface->ports_.value(\"enable\");\r\n    mpa = mPort->upAssignments_.value(\"ENABLE\");\r\n    QCOMPARE(mpa->wire_->hierPorts_.first()->port_->name(), QString(\"enable_to_instance\"));\r\n\r\n    mPort = mInterface->ports_.value(\"full\");\r\n    mpa = mPort->upAssignments_.value(\"FULL\");\r\n    QCOMPARE(mpa->wire_->hierPorts_.first()->port_->name(), QString(\"full_from_instance\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_HDLParser::createHierarchicalConnection()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_HDLParser::createHierarchicalConnection(QString const& topInterfaceRef, \r\n    QString const& instanceInterfaceRef)\r\n{\r\n    QSharedPointer<Interconnection> hierachicalConnection(new Interconnection());\r\n    QSharedPointer<ActiveInterface> instanceInterface(new ActiveInterface(\"instance1\", instanceInterfaceRef));\r\n    hierachicalConnection->setStartInterface(instanceInterface);\r\n    \r\n    QSharedPointer<HierInterface> topInterface(new HierInterface(topInterfaceRef));\r\n    hierachicalConnection->getHierInterfaces()->append(topInterface);\r\n   \r\n    design_->getInterconnections()->append(hierachicalConnection);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_HDLParser::testHierarchicalConnectionsWithExpressions()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_HDLParser::testHierarchicalConnectionsWithExpressions()\r\n{\r\n    QSharedPointer<Port> clkPort (new Port(\"top_clk\"));\r\n    clkPort->setDirection(DirectionTypes::IN);\r\n    clkPort->setLeftBound(\"2+2\");\r\n    clkPort->setRightBound(\"0\");\r\n    topComponent_->getPorts()->append(clkPort);\r\n\r\n    addInterfaceToComponent(\"clk_if\", topComponent_, clkAbstractionVLNV_);;\r\n\r\n    mapPortToInterface(\"top_clk\", \"CLK\", \"clk_if\", topComponent_);\r\n\r\n    createHierarchicalConnection(\"clk_if\", \"instanceInterface\");\r\n\r\n    VLNV instanceVlnv(VLNV::COMPONENT, \"Test\", \"TestLibrary\", \"TestInstance\", \"1.0\");\r\n\r\n    QSharedPointer<Component> instanceComponent(new Component(instanceVlnv, Document::Revision::Std14));\r\n\r\n    QSharedPointer<Parameter> componentParameter (new Parameter());\r\n    componentParameter->setName(\"componentParameter\");\r\n    componentParameter->setValue(\"1\");\r\n\tcomponentParameter->setValueId(\"instant_ID\");\r\n\tcomponentParameter->setValueResolve(\"user\");\r\n\tinstanceComponent->getParameters()->append(componentParameter);\r\n\r\n    QSharedPointer<Port> instanceClkPort (new Port(\"instance_clk\"));\r\n    instanceClkPort->setDirection(DirectionTypes::IN); \r\n    instanceClkPort->setLeftBound(componentParameter->getValueId() + \"*2\");\r\n    instanceClkPort->setRightBound(\"4-2*2\");\r\n    instanceComponent->getPorts()->append(instanceClkPort);\r\n\r\n    addInterfaceToComponent(\"instanceInterface\", instanceComponent, clkAbstractionVLNV_);\r\n    mapPortToInterface(\"instance_clk\", \"CLK\", \"instanceInterface\", instanceComponent);\r\n\r\n\tlibrary_.addComponent(instanceComponent);\r\n\r\n\tQSharedPointer<View> activeView(new View(\"rtl\"));\r\n\tactiveView->setComponentInstantiationRef(\"instance1\");\r\n\r\n\tQSharedPointer<ComponentInstantiation> instantiation(new ComponentInstantiation(\"instance1\"));\r\n\tinstanceComponent->getComponentInstantiations()->append(instantiation);\r\n\tinstanceComponent->getViews()->append(activeView);\r\n\r\n    addInstanceToDesign(\"instance1\", instanceVlnv, activeView);\r\n\r\n    QList<QSharedPointer<MetaDesign> > designs = MetaDesign::parseHierarchy\r\n        (&library_, input_, topView_);\r\n\r\n    QCOMPARE(designs.size(), 1);\r\n    QSharedPointer<MetaDesign> design = designs.first();\r\n\r\n    QCOMPARE(design->getInstances()->size(), 1);\r\n\r\n    QSharedPointer<MetaInstance> mInstance = design->getInstances()->value(\"instance1\");\r\n    QCOMPARE(mInstance->getInterfaces()->size(), 1);\r\n    QCOMPARE(mInstance->getParameters()->size(), 1);\r\n\r\n    QCOMPARE(mInstance->getParameters()->value(0)->name(), QString(\"componentParameter\"));\r\n    QCOMPARE(mInstance->getParameters()->value(0)->getValue(), QString(\"1\"));\r\n\r\n    QSharedPointer<MetaInterface> mInterface = mInstance->getInterfaces()->value(\"instanceInterface\");\r\n    QCOMPARE(mInterface->ports_.size(), 1);\r\n\r\n    QSharedPointer<MetaPort> mPort = mInterface->ports_.value(\"instance_clk\");\r\n    QSharedPointer<MetaPortAssignment> mpa = mPort->upAssignments_.value(\"CLK\");\r\n    QCOMPARE(mpa->wire_->hierPorts_.first()->port_->name(), QString(\"top_clk\"));\r\n    QCOMPARE(mpa->logicalBounds_.first, QString(\"2\"));\r\n    QCOMPARE(mpa->logicalBounds_.second, QString(\"0\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_HDLParser::addInterfaceToComponent()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<BusInterface> tst_HDLParser::addInterfaceToComponent(QString const& interfaceName,\r\n    QSharedPointer<Component> component,\r\n    QSharedPointer<ConfigurableVLNVReference> absRef)\r\n{\r\n    QSharedPointer<BusInterface> busInterface(new BusInterface());\r\n    busInterface->setName(interfaceName);\r\n    component->getBusInterfaces()->append(busInterface);\r\n\r\n    QSharedPointer<AbstractionType> testAbstraction (new AbstractionType());\r\n    testAbstraction->setAbstractionRef(absRef);\r\n    busInterface->getAbstractionTypes()->append(testAbstraction);\r\n\r\n    return busInterface;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_HDLParser:::mapPortToInterface()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<PortMap> tst_HDLParser::mapPortToInterface(QString const& portName, QString const& logicalName, \r\n    QString const& interfaceName, QSharedPointer<Component> component)\r\n{\r\n\tQSharedPointer<Port> port = component->getPort(portName);\r\n\r\n    QSharedPointer<PortMap> portMap(new PortMap());\r\n\tQSharedPointer<PortMap::LogicalPort> logPort(new PortMap::LogicalPort(logicalName));\r\n\tQSharedPointer<PortMap::PhysicalPort> physPort(new PortMap::PhysicalPort(portName));\r\n\r\n    QSharedPointer<PartSelect> physicalPart (new PartSelect(port->getLeftBound(), port->getRightBound()));\r\n    physPort->partSelect_ = physicalPart;\r\n\r\n    portMap->setLogicalPort(logPort);\r\n    portMap->setPhysicalPort(physPort);\r\n\r\n    QSharedPointer<BusInterface> containingBusIf = component->getBusInterface(interfaceName);\r\n    QSharedPointer<QList<QSharedPointer<PortMap> > > portMaps = \r\n        containingBusIf->getAbstractionTypes()->first()->getPortMaps();\r\n\r\n    portMaps->append(portMap);\r\n\r\n    return portMap;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_HDLParser::mapPortToInterface()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<PortMap> tst_HDLParser::mapPortToInterface(QString const& portName, int left, int right, QString const& logicalName, \r\n    QString const& interfaceName, QSharedPointer<Component> component)\r\n{\r\n\tQSharedPointer<PortMap> portMap(new PortMap());\r\n\tQSharedPointer<PortMap::LogicalPort> logPort(new PortMap::LogicalPort(logicalName));\r\n\tQSharedPointer<PortMap::PhysicalPort> physPort(new PortMap::PhysicalPort(portName));\r\n\t\r\n    QSharedPointer<PartSelect> physicalPart (new PartSelect(QString::number(left), QString::number(right)));\r\n    physPort->partSelect_ = physicalPart;\r\n\r\n\tportMap->setLogicalPort(logPort);\r\n\tportMap->setPhysicalPort(physPort);\r\n\r\n    QSharedPointer<BusInterface> containingBus = component->getBusInterface(interfaceName);\r\n    QSharedPointer<QList<QSharedPointer<PortMap> > > portMaps = \r\n        containingBus->getAbstractionTypes()->first()->getPortMaps();\r\n\r\n    if (!portMaps)\r\n    {\r\n        QSharedPointer<QList<QSharedPointer<PortMap> > > newPortMapList (new QList<QSharedPointer<PortMap> > ());\r\n\r\n        if (containingBus->getAbstractionTypes()->isEmpty())\r\n        {\r\n            QSharedPointer<AbstractionType> testAbstraction (new AbstractionType());\r\n            containingBus->getAbstractionTypes()->append(testAbstraction);\r\n\r\n            if (logicalName == \"CLK\")\r\n            {\r\n                testAbstraction->setAbstractionRef(clkAbstractionVLNV_);\r\n            }\r\n            else\r\n            {\r\n                testAbstraction->setAbstractionRef(dataAbstractionVLNV_);\r\n            }\r\n        }\r\n   \r\n        portMaps = containingBus->getAbstractionTypes()->first()->getPortMaps();\r\n    }\r\n    \r\n    portMaps->append(portMap);\r\n\r\n    return portMap;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_HDLParser::addTestComponentToLibrary()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<View> tst_HDLParser::addTestComponentToLibrary(VLNV vlnv)\r\n{\r\n    QSharedPointer<Component> instanceComponent(new Component(vlnv, Document::Revision::Std14));\r\n    addPort(\"clk\", 1, DirectionTypes::IN, instanceComponent);\r\n    addPort(\"data_in\", 8, DirectionTypes::IN, instanceComponent);\r\n    addPort(\"data_out\", 8, DirectionTypes::OUT, instanceComponent);\r\n    addPort(\"enable\", 1, DirectionTypes::IN, instanceComponent);\r\n\taddPort(\"full\", 1, DirectionTypes::OUT, instanceComponent);\r\n\r\n\tQSharedPointer<View> activeView(new View());\r\n\tactiveView->setName(\"rtl\");\r\n\tactiveView->setComponentInstantiationRef(\"instance1\");\r\n\r\n\tQSharedPointer<ComponentInstantiation> instantiation(new ComponentInstantiation(\"instance1\"));\r\n\tinstanceComponent->getComponentInstantiations()->append(instantiation);\r\n\tinstanceComponent->getViews()->append(activeView);\r\n\r\n    addInterfaceToComponent(\"clk\", instanceComponent, clkAbstractionVLNV_);\r\n\r\n    mapPortToInterface(\"clk\", \"CLK\", \"clk\", instanceComponent);\r\n\r\n    addInterfaceToComponent(\"data\", instanceComponent, dataAbstractionVLNV_);\r\n\r\n    mapPortToInterface(\"data_in\", \"DATA\", \"data\", instanceComponent);\r\n    mapPortToInterface(\"enable\", \"ENABLE\", \"data\", instanceComponent);\r\n    mapPortToInterface(\"full\", \"FULL\", \"data\", instanceComponent);\r\n\r\n    library_.addComponent(instanceComponent);\r\n\r\n\treturn activeView;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_HDLParser::addInstanceToDesign()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<ComponentInstance> tst_HDLParser::addInstanceToDesign(QString instanceName, VLNV instanceVlnv, QSharedPointer<View> activeView)\r\n{\r\n    QSharedPointer<ConfigurableVLNVReference> componentVLNV (new ConfigurableVLNVReference(instanceVlnv));\r\n    QSharedPointer<ComponentInstance> instance (new ComponentInstance(instanceName, componentVLNV));\r\n\r\n    design_->getComponentInstances()->append(instance);\r\n\r\n\tif (activeView)\r\n\t{\r\n\t\tdesignConf_->addViewConfiguration(instanceName, activeView->name());\r\n\t}\r\n\r\n\treturn instance;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_HDLParser::testPortMapping()\r\n//-----------------------------------------------------------------------------\r\n/*void tst_HDLParser::testPortMapping()\r\n{\r\n    QSharedPointer<ConfigurableVLNVReference> abstractionVLNV(new ConfigurableVLNVReference(\r\n        VLNV::ABSTRACTIONDEFINITION, \"Test\", \"TestLibrary\", \"absDef\", \"1.0\"));\r\n\r\n    QSharedPointer<AbstractionDefinition> testAbstractionDefinition(new AbstractionDefinition());\r\n    testAbstractionDefinition->setVlnv(*abstractionVLNV.data());\r\n    library_.addComponent(testAbstractionDefinition);\r\n\r\n    QSharedPointer<PortAbstraction> logicalPortHigh (new PortAbstraction());\r\n    logicalPortHigh->setName(\"CUSTOM_HIGH\");\r\n    testAbstractionDefinition->getLogicalPorts()->append(logicalPortHigh);\r\n\r\n    QSharedPointer<PortAbstraction> logicalPortLow (new PortAbstraction());\r\n    logicalPortLow->setName(\"CUSTOM_LOW\");\r\n    testAbstractionDefinition->getLogicalPorts()->append(logicalPortLow);\r\n\r\n    VLNV senderVLNV(VLNV::COMPONENT, \"Test\", \"TestLibrary\", \"TestSender\", \"1.0\");\r\n\r\n    QSharedPointer<Component> senderComponent(new Component(senderVLNV));\r\n    addPort(\"test_out\", 8, DirectionTypes::OUT, senderComponent);\r\n\r\n    QSharedPointer<BusInterface> testIf = addInterfaceToComponent(\"data_bus\", senderComponent, abstractionVLNV);\r\n    testIf->setInterfaceMode(General::MASTER);    \r\n\r\n    QSharedPointer<PortMap> enableLowPortMap(new PortMap());\r\n    QSharedPointer<PortMap::LogicalPort> logPortLow(new PortMap::LogicalPort(\"CUSTOM_HIGH\"));\r\n    QSharedPointer<PortMap::PhysicalPort> physPortLow(new PortMap::PhysicalPort(\"test_out\"));\r\n    enableLowPortMap->setLogicalPort(logPortLow);\r\n    enableLowPortMap->setPhysicalPort(physPortLow);\r\n\r\n    QSharedPointer<PartSelect> lowPart (new PartSelect(\"7\", \"4\"));\r\n    physPortLow->partSelect_ = lowPart;\r\n\r\n    QSharedPointer<Range> lowRange (new Range(\"3\", \"0\"));\r\n    logPortLow->range_ = lowRange;\r\n\r\n    QSharedPointer<PortMap> enableHighPortMap(new PortMap());\r\n    QSharedPointer<PortMap::LogicalPort> logPortHigh(new PortMap::LogicalPort(\"CUSTOM_LOW\"));\r\n    QSharedPointer<PortMap::PhysicalPort> physPortHigh(new PortMap::PhysicalPort(\"test_out\"));\r\n    enableHighPortMap->setLogicalPort(logPortHigh);\r\n    enableHighPortMap->setPhysicalPort(physPortHigh);\r\n\r\n    QSharedPointer<PartSelect> highPart (new PartSelect(\"3\", \"0\"));\r\n    physPortHigh->partSelect_ = highPart;\r\n\r\n    QSharedPointer<Range> highRange (new Range(\"3\", \"0\"));\r\n    logPortHigh->range_ = highRange;\r\n\r\n    QSharedPointer<AbstractionType> senderEnableAbstraction (new AbstractionType());\r\n    testIf->getAbstractionTypes()->append(senderEnableAbstraction);\r\n\r\n    QSharedPointer<QList<QSharedPointer<PortMap> > > portMaps = testIf->getPortMaps();\r\n    portMaps->append(enableLowPortMap);\r\n    portMaps->append(enableHighPortMap);\r\n\r\n    QSharedPointer<View> sendView(new View(\"rtl\"));\r\n    sendView->setComponentInstantiationRef(\"instance1\");\r\n\r\n    QSharedPointer<ComponentInstantiation> instantiation(new ComponentInstantiation(\"instance1\"));\r\n    senderComponent->getComponentInstantiations()->append(instantiation);\r\n    senderComponent->getViews()->append(sendView);\r\n\r\n    library_.addComponent(senderComponent);\r\n    addInstanceToDesign(\"sender\", senderVLNV, sendView);\r\n\r\n    QList<QSharedPointer<MetaDesign> > designs = MetaDesign::parseHierarchy\r\n        (&library_, input_, topView_);\r\n\r\n    QCOMPARE(designs.size(), 1);\r\n    QSharedPointer<MetaDesign> design = designs.first();\r\n\r\n    QCOMPARE(design->getInstances()->size(), 1);\r\n    QSharedPointer<MetaInstance> mInstance0 = design->getInstances()->value(\"sender\");\r\n\r\n    QVERIFY(mInstance0->getInterfaces()->size() > 0);\r\n    QVERIFY(mInstance0->getInterfaces()->first()->ports_.size() > 0);\r\n\r\n    QSharedPointer<MetaPort> mPort = mInstance0->getInterfaces()->first()->ports_.value(\"test_out\");\r\n    QSharedPointer<MetaPortAssignment> mpa = mPort->upAssignments_.value(\"CUSTOM_HIGH\");\r\n    QCOMPARE(mpa->logicalBounds_.first, QString(\"3\"));\r\n    QCOMPARE(mpa->logicalBounds_.second, QString(\"0\"));\r\n    QCOMPARE(mpa->physicalBounds_.first, QString(\"7\"));\r\n    QCOMPARE(mpa->physicalBounds_.second, QString(\"4\"));\r\n\r\n    mpa = mPort->upAssignments_.value(\"CUSTOM_LOW\");\r\n    QCOMPARE(mpa->logicalBounds_.first, QString(\"3\"));\r\n    QCOMPARE(mpa->logicalBounds_.second, QString(\"0\"));\r\n    QCOMPARE(mpa->physicalBounds_.first, QString(\"3\"));\r\n    QCOMPARE(mpa->physicalBounds_.second, QString(\"0\"));\r\n}*/\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_HDLParser::testMasterToSlaveInterconnection()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_HDLParser::testMasterToSlaveInterconnection()\r\n{\r\n    VLNV senderVLNV(VLNV::COMPONENT, \"Test\", \"TestLibrary\", \"TestSender\", \"1.0\");\r\n    QSharedPointer<View> activeView = addSenderComponentToLibrary(senderVLNV, General::MASTER);\r\n    addInstanceToDesign(\"sender\", senderVLNV, activeView);\r\n\r\n    VLNV receiverVLNV(VLNV::COMPONENT, \"Test\", \"TestLibrary\", \"TestReceiver\", \"1.0\");\r\n    activeView = addReceiverComponentToLibrary(receiverVLNV, General::SLAVE);\r\n    addInstanceToDesign(\"receiver\", receiverVLNV, activeView);\r\n\r\n    addConnectionToDesign(\"sender\", \"data_bus\", \"receiver\", \"data_bus\");\r\n\r\n    QList<QSharedPointer<MetaDesign> > designs = MetaDesign::parseHierarchy\r\n        (&library_, input_, topView_);\r\n\r\n    QCOMPARE(designs.size(), 1);\r\n    QSharedPointer<MetaDesign> design = designs.first();\r\n\r\n    QCOMPARE(design->getInstances()->size(), 2);\r\n\r\n    QSharedPointer<MetaInstance> mInstance = design->getInstances()->value(\"sender\");\r\n    QCOMPARE(mInstance->getInterfaces()->size(), 1);\r\n\r\n    QSharedPointer<MetaInterface> mInterface = mInstance->getInterfaces()->value(\"data_bus\");\r\n\r\n    QSharedPointer<MetaPort> mPort = mInterface->ports_.value(\"data_out\");\r\n    QSharedPointer<MetaPortAssignment> mpa = mPort->upAssignments_.value(\"DATA\");\r\n    QCOMPARE(mpa->logicalBounds_.first, QString(\"7\"));\r\n    QCOMPARE(mpa->logicalBounds_.second, QString(\"0\"));\r\n    QCOMPARE(mInterface->ports_.size(), 2);\r\n\r\n    mPort = mInterface->ports_.value(\"enable_out\");\r\n    mpa = mPort->upAssignments_.value(\"ENABLE\");\r\n    QCOMPARE(mpa->logicalBounds_.first, QString(\"0\"));\r\n    QCOMPARE(mpa->logicalBounds_.second, QString(\"0\"));\r\n\r\n    mInstance = design->getInstances()->value(\"receiver\");\r\n    QCOMPARE(mInstance->getInterfaces()->size(), 1);\r\n\r\n    mInterface = mInstance->getInterfaces()->value(\"data_bus\");\r\n    QCOMPARE(mInterface->ports_.size(), 2);\r\n\r\n    mPort = mInterface->ports_.value(\"data_in\");\r\n    mpa = mPort->upAssignments_.value(\"DATA\");\r\n    QCOMPARE(mpa->logicalBounds_.first, QString(\"7\"));\r\n    QCOMPARE(mpa->logicalBounds_.second, QString(\"0\"));\r\n\r\n    mPort = mInterface->ports_.value(\"enable_in\");\r\n    mpa = mPort->upAssignments_.value(\"ENABLE\");\r\n    QCOMPARE(mpa->logicalBounds_.first, QString(\"0\"));\r\n    QCOMPARE(mpa->logicalBounds_.second, QString(\"0\"));\r\n    \r\n    QCOMPARE(design->getInterconnections()->size(), 1);\r\n    QSharedPointer<MetaInterconnection> mInterconnect = design->getInterconnections()->first();\r\n\r\n    QCOMPARE(mInterconnect->wires_.size(), 2);\r\n    QSharedPointer<MetaWire> mWire = mInterconnect->wires_.first();\r\n    QCOMPARE(mWire->hierPorts_.size(), 0);\r\n    QCOMPARE(mWire->bounds_.first, QString(\"7\"));\r\n    QCOMPARE(mWire->bounds_.second, QString(\"0\"));\r\n\r\n    mWire = mInterconnect->wires_.last();\r\n    QCOMPARE(mWire->hierPorts_.size(), 0);\r\n    QCOMPARE(mWire->bounds_.first, QString(\"0\"));\r\n    QCOMPARE(mWire->bounds_.second, QString(\"0\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_HDLParser::testEmptyBounds()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_HDLParser::testEmptyBounds()\r\n{\r\n    VLNV senderVLNV(VLNV::COMPONENT, \"Test\", \"TestLibrary\", \"TestSender\", \"1.0\");\r\n    QSharedPointer<Component> senderComponent(new Component(senderVLNV, Document::Revision::Std14));\r\n\r\n    QSharedPointer<View> senderView(new View(\"view\"));\r\n    senderComponent->getViews()->append(senderView);\r\n\r\n    QSharedPointer<ComponentInstantiation> sendCimp(new ComponentInstantiation(\"senderCimp\"));\r\n    senderView->setComponentInstantiationRef(sendCimp->name());\r\n    senderComponent->getComponentInstantiations()->append(sendCimp);\r\n\r\n    QSharedPointer<Port> senderPort = QSharedPointer<Port>(new Port(\"data_out\"));\r\n    senderPort->setDirection(DirectionTypes::OUT); \r\n    senderPort->setLeftBound(\"\");\r\n    senderPort->setRightBound(\"\");\r\n    senderComponent->getPorts()->append(senderPort);\r\n\r\n    addInterfaceToComponent(\"data_bus\", senderComponent, dataAbstractionVLNV_);\r\n    senderComponent->getBusInterface(\"data_bus\")->setInterfaceMode(General::MASTER);\r\n\r\n    mapPortToInterface(\"data_out\", \"DATA\", \"data_bus\", senderComponent);\r\n    QSharedPointer<PortMap> dataMap = \r\n        senderComponent->getBusInterface(\"data_bus\")->getAbstractionTypes()->first()->getPortMaps()->first();\r\n    QSharedPointer<PortMap::LogicalPort> logPort = dataMap->getLogicalPort();\r\n    logPort->range_ = QSharedPointer<Range>(new Range(\"\",\"\"));\r\n\r\n    library_.addComponent(senderComponent);\r\n    addInstanceToDesign(\"sender\", senderVLNV, senderView);\r\n\r\n    VLNV receiverVLNV(VLNV::COMPONENT, \"Test\", \"TestLibrary\", \"TestReceiver\", \"1.0\");\r\n    QSharedPointer<Component> receiverComponent(new Component(receiverVLNV, Document::Revision::Std14));\r\n\r\n    QSharedPointer<View> receiverView(new View(\"view\"));\r\n    receiverComponent->getViews()->append(receiverView);\r\n\r\n    QSharedPointer<ComponentInstantiation> recvCimp(new ComponentInstantiation(\"recvCimp\"));\r\n    receiverView->setComponentInstantiationRef(recvCimp->name());\r\n    receiverComponent->getComponentInstantiations()->append(recvCimp);\r\n\r\n    QSharedPointer<Port> receiverPort = QSharedPointer<Port>(new Port(\"data_in\"));\r\n    receiverPort->setDirection(DirectionTypes::IN); \r\n    receiverPort->setLeftBound(\"\");\r\n    receiverPort->setRightBound(\"\");\r\n    receiverComponent->getPorts()->append(receiverPort);\r\n\r\n    addInterfaceToComponent(\"data_bus\", receiverComponent, dataAbstractionVLNV_);\r\n    receiverComponent->getBusInterface(\"data_bus\")->setInterfaceMode(General::SLAVE);\r\n    mapPortToInterface(\"data_in\", \"DATA\", \"data_bus\", receiverComponent);\r\n\r\n    library_.addComponent(receiverComponent);\r\n    addInstanceToDesign(\"receiver\", receiverVLNV, receiverView);\r\n\r\n    addConnectionToDesign(\"sender\", \"data_bus\", \"receiver\", \"data_bus\");\r\n\r\n    QList<QSharedPointer<MetaDesign> > designs = MetaDesign::parseHierarchy\r\n        (&library_, input_, topView_);\r\n\r\n    QCOMPARE(designs.size(), 1);\r\n    QSharedPointer<MetaDesign> design = designs.first();\r\n\r\n    QCOMPARE(design->getInstances()->size(), 2);\r\n\r\n    QSharedPointer<MetaInstance> mInstance = design->getInstances()->value(\"sender\");\r\n    QCOMPARE(mInstance->getInterfaces()->size(), 1);\r\n\r\n    QSharedPointer<MetaInterface> mInterface = mInstance->getInterfaces()->value(\"data_bus\");\r\n    QCOMPARE(mInterface->ports_.size(), 1);\r\n\r\n    QSharedPointer<MetaPort> mPort = mInterface->ports_.value(\"data_out\");\r\n    QSharedPointer<MetaPortAssignment> mpa = mPort->upAssignments_.value(\"DATA\");\r\n    QCOMPARE(mpa->logicalBounds_.first, QString(\"0\"));\r\n    QCOMPARE(mpa->logicalBounds_.second, QString(\"0\"));\r\n\r\n    mInstance = design->getInstances()->value(\"receiver\");\r\n    QCOMPARE(mInstance->getInterfaces()->size(), 1);\r\n\r\n    mInterface = mInstance->getInterfaces()->value(\"data_bus\");\r\n    QCOMPARE(mInterface->ports_.size(), 1);\r\n\r\n    mPort = mInterface->ports_.value(\"data_in\");\r\n    mpa = mPort->upAssignments_.value(\"DATA\");\r\n    QCOMPARE(mpa->logicalBounds_.first, QString(\"0\"));\r\n    QCOMPARE(mpa->logicalBounds_.second, QString(\"0\"));\r\n\r\n    QCOMPARE(design->getInterconnections()->size(), 1);\r\n    QSharedPointer<MetaInterconnection> mInterconnect = design->getInterconnections()->first();\r\n\r\n    QCOMPARE(mInterconnect->wires_.size(), 1);\r\n    QSharedPointer<MetaWire> mWire = mInterconnect->wires_.first();\r\n    QCOMPARE(mWire->hierPorts_.size(), 0);\r\n    QCOMPARE(mWire->bounds_.first, QString(\"0\"));\r\n    QCOMPARE(mWire->bounds_.second, QString(\"0\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_HDLParser::testMasterToSlaveInterconnectionWithExpressions()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_HDLParser::testMasterToSlaveInterconnectionWithExpressions()\r\n{\r\n    VLNV senderVLNV(VLNV::COMPONENT, \"Test\", \"TestLibrary\", \"TestSender\", \"1.0\");\r\n    QSharedPointer<Component> senderComponent(new Component(senderVLNV, Document::Revision::Std14));\r\n\r\n\tQSharedPointer<View> senderView(new View(\"view\"));\r\n\tsenderComponent->getViews()->append(senderView);\r\n\r\n\tQSharedPointer<ComponentInstantiation> sendCimp(new ComponentInstantiation(\"senderCimp\"));\r\n\tsenderView->setComponentInstantiationRef(sendCimp->name());\r\n\tsenderComponent->getComponentInstantiations()->append(sendCimp);\r\n\r\n    QSharedPointer<Port> senderPort = QSharedPointer<Port>(new Port(\"data_out\"));\r\n    senderPort->setDirection(DirectionTypes::OUT);\r\n    senderPort->setLeftBound(\"20-2\");\r\n    senderPort->setRightBound(\"0\");\r\n    senderComponent->getPorts()->append(senderPort);\r\n\r\n    addInterfaceToComponent(\"data_bus\", senderComponent, dataAbstractionVLNV_);\r\n    senderComponent->getBusInterface(\"data_bus\")->setInterfaceMode(General::MASTER);\r\n\r\n    mapPortToInterface(\"data_out\", \"DATA\", \"data_bus\", senderComponent);\r\n    QSharedPointer<PortMap> dataMap = \r\n        senderComponent->getBusInterface(\"data_bus\")->getAbstractionTypes()->first()->getPortMaps()->first();\r\n    QSharedPointer<PortMap::LogicalPort> logPort = dataMap->getLogicalPort();\r\n    logPort->range_ = QSharedPointer<Range>(new Range(\"7*2\",\"0\"));\r\n\r\n    library_.addComponent(senderComponent);\r\n    addInstanceToDesign(\"sender\", senderVLNV, senderView);\r\n\r\n    VLNV receiverVLNV(VLNV::COMPONENT, \"Test\", \"TestLibrary\", \"TestReceiver\", \"1.0\");\r\n\tQSharedPointer<Component> receiverComponent(new Component(receiverVLNV, Document::Revision::Std14));\r\n\r\n\tQSharedPointer<View> receiverView(new View(\"view\"));\r\n\treceiverComponent->getViews()->append(receiverView);\r\n\r\n\tQSharedPointer<ComponentInstantiation> recvCimp(new ComponentInstantiation(\"recvCimp\"));\r\n\treceiverView->setComponentInstantiationRef(recvCimp->name());\r\n\treceiverComponent->getComponentInstantiations()->append(recvCimp);\r\n\r\n    QSharedPointer<Port> receiverPort = QSharedPointer<Port>(new Port(\"data_in\"));\r\n    receiverPort->setDirection(DirectionTypes::IN);\r\n    receiverPort->setLeftBound(\"7+1\");\r\n    receiverPort->setRightBound(\"0\");\r\n    receiverComponent->getPorts()->append(receiverPort);\r\n\r\n    addInterfaceToComponent(\"data_bus\", receiverComponent, dataAbstractionVLNV_);\r\n    receiverComponent->getBusInterface(\"data_bus\")->setInterfaceMode(General::SLAVE);\r\n    mapPortToInterface(\"data_in\", \"DATA\", \"data_bus\", receiverComponent);\r\n\r\n    library_.addComponent(receiverComponent);\r\n    addInstanceToDesign(\"receiver\", receiverVLNV, receiverView);\r\n\r\n    addConnectionToDesign(\"sender\", \"data_bus\", \"receiver\", \"data_bus\");\r\n\r\n    QList<QSharedPointer<MetaDesign> > designs = MetaDesign::parseHierarchy\r\n        (&library_, input_, topView_);\r\n\r\n    QCOMPARE(designs.size(), 1);\r\n    QSharedPointer<MetaDesign> design = designs.first();\r\n\r\n    QCOMPARE(design->getInstances()->size(), 2);\r\n\r\n    QSharedPointer<MetaInstance> mInstance = design->getInstances()->value(\"sender\");\r\n    QCOMPARE(mInstance->getInterfaces()->size(), 1);\r\n\r\n    QSharedPointer<MetaInterface> mInterface = mInstance->getInterfaces()->value(\"data_bus\");\r\n    QCOMPARE(mInterface->ports_.size(), 1);\r\n\r\n    QSharedPointer<MetaPort> mPort = mInterface->ports_.value(\"data_out\");\r\n    QSharedPointer<MetaPortAssignment> mpa = mPort->upAssignments_.value(\"DATA\");\r\n    QCOMPARE(mpa->logicalBounds_.first, QString(\"14\"));\r\n    QCOMPARE(mpa->logicalBounds_.second, QString(\"0\"));\r\n\r\n    mInstance = design->getInstances()->value(\"receiver\");\r\n    QCOMPARE(mInstance->getInterfaces()->size(), 1);\r\n\r\n    mInterface = mInstance->getInterfaces()->value(\"data_bus\");\r\n    QCOMPARE(mInterface->ports_.size(), 1);\r\n\r\n    mPort = mInterface->ports_.value(\"data_in\");\r\n    mpa = mPort->upAssignments_.value(\"DATA\");\r\n    QCOMPARE(mpa->logicalBounds_.first, QString(\"8\"));\r\n    QCOMPARE(mpa->logicalBounds_.second, QString(\"0\"));\r\n\r\n    QCOMPARE(design->getInterconnections()->size(), 1);\r\n    QSharedPointer<MetaInterconnection> mInterconnect = design->getInterconnections()->first();\r\n\r\n    QCOMPARE(mInterconnect->wires_.size(), 1);\r\n    QSharedPointer<MetaWire> mWire = mInterconnect->wires_.first();\r\n    QCOMPARE(mWire->hierPorts_.size(), 0);\r\n    QCOMPARE(mWire->bounds_.first, QString(\"14\"));\r\n    QCOMPARE(mWire->bounds_.second, QString(\"0\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_HDLParser::addSenderComponentToLibrary()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<View> tst_HDLParser::addSenderComponentToLibrary(VLNV senderVLNV, General::InterfaceMode mode,\r\n    bool createInterfaces /*= true*/)\r\n{\r\n    QSharedPointer<Component> senderComponent(new Component(senderVLNV, Document::Revision::Std14));\r\n    addPort(\"enable_out\", 1, DirectionTypes::OUT, senderComponent);\r\n    addPort(\"data_out\", 8, DirectionTypes::OUT, senderComponent);\r\n\r\n    if (createInterfaces)\r\n    {\r\n        addInterfaceToComponent(\"data_bus\", senderComponent, dataAbstractionVLNV_);\r\n        senderComponent->getBusInterface(\"data_bus\")->setInterfaceMode(mode);    \r\n        mapPortToInterface(\"data_out\", \"DATA\", \"data_bus\", senderComponent);\r\n        QSharedPointer<PortMap> dataMap = \r\n            senderComponent->getBusInterface(\"data_bus\")->getAbstractionTypes()->first()->getPortMaps()->first();\r\n        QSharedPointer<PortMap::LogicalPort> logPort = dataMap->getLogicalPort();\r\n\t    logPort->range_ = QSharedPointer<Range>(new Range(\"7\",\"0\"));\r\n\r\n\t    mapPortToInterface(\"enable_out\", \"ENABLE\", \"data_bus\", senderComponent);\r\n    }\r\n\r\n\tQSharedPointer<View> activeView(new View());\r\n\tactiveView->setName(\"rtl\");\r\n\tactiveView->setComponentInstantiationRef(\"instance1\");\r\n\r\n\tQSharedPointer<ComponentInstantiation> instantiation(new ComponentInstantiation(\"instance1\"));\r\n\tsenderComponent->getComponentInstantiations()->append(instantiation);\r\n\tsenderComponent->getViews()->append(activeView);\r\n\r\n    library_.addComponent(senderComponent);\r\n\r\n\treturn activeView;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_HDLParser::addReceiverComponentToLibrary()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<View> tst_HDLParser::addReceiverComponentToLibrary(VLNV receiverVLNV, General::InterfaceMode mode,\r\n    bool createInterfaces /*= true*/)\r\n{\r\n    QSharedPointer<Component> receiverComponent(new Component(receiverVLNV, Document::Revision::Std14));\r\n    addPort(\"enable_in\", 1, DirectionTypes::IN, receiverComponent);\r\n    addPort(\"data_in\", 8, DirectionTypes::IN, receiverComponent);\r\n\r\n    if (createInterfaces)\r\n    {\r\n        addInterfaceToComponent(\"data_bus\", receiverComponent, dataAbstractionVLNV_);\r\n        receiverComponent->getBusInterface(\"data_bus\")->setInterfaceMode(mode);    \r\n        mapPortToInterface(\"data_in\", \"DATA\", \"data_bus\", receiverComponent);\r\n\r\n        mapPortToInterface(\"enable_in\", \"ENABLE\", \"data_bus\", receiverComponent);\r\n    }\r\n\r\n\tQSharedPointer<View> activeView(new View());\r\n\tactiveView->setName(\"rtl\");\r\n\tactiveView->setComponentInstantiationRef(\"instance1\");\r\n\r\n\tQSharedPointer<ComponentInstantiation> instantiation(new ComponentInstantiation(\"instance1\"));\r\n\treceiverComponent->getComponentInstantiations()->append(instantiation);\r\n\treceiverComponent->getViews()->append(activeView);\r\n\r\n\tlibrary_.addComponent(receiverComponent);\r\n\r\n\treturn activeView;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_HDLParser::addConnectionToDesign()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_HDLParser::addConnectionToDesign(QString fromInstance, QString fromInterface, \r\n    QString toInstance, QString toInterface)\r\n{\r\n    QSharedPointer<ActiveInterface> firstInterface(new ActiveInterface(fromInstance, fromInterface));\r\n    QSharedPointer<ActiveInterface> secondInterface(new ActiveInterface(toInstance, toInterface));\r\n\r\n    QSharedPointer<Interconnection> connection(new Interconnection(fromInstance + \"_to_\" + toInstance, firstInterface));\r\n    connection->setStartInterface(firstInterface);\r\n    connection->getActiveInterfaces()->append(secondInterface);\r\n\r\n    design_->getInterconnections()->append(connection);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_HDLParser::testMasterToMultipleSlavesInterconnections()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_HDLParser::testMasterToMultipleSlavesInterconnections()\r\n{\r\n    VLNV senderVLNV(VLNV::COMPONENT, \"Test\", \"TestLibrary\", \"TestSender\", \"1.0\");\r\n    QSharedPointer<View> sendView = addSenderComponentToLibrary(senderVLNV, General::MASTER);\r\n    addInstanceToDesign(\"sender\", senderVLNV, sendView);\r\n\r\n    VLNV receiverVLNV(VLNV::COMPONENT, \"Test\", \"TestLibrary\", \"TestReceiver\", \"1.0\");\r\n    QSharedPointer<View> recvView = addReceiverComponentToLibrary(receiverVLNV, General::SLAVE);\r\n    addInstanceToDesign(\"receiver1\", receiverVLNV, recvView);\r\n    addInstanceToDesign(\"receiver2\", receiverVLNV, recvView);\r\n\r\n    addConnectionToDesign(\"sender\", \"data_bus\", \"receiver1\", \"data_bus\");\r\n    addConnectionToDesign(\"sender\", \"data_bus\", \"receiver2\", \"data_bus\");\r\n\r\n    QList<QSharedPointer<MetaDesign> > designs = MetaDesign::parseHierarchy(&library_, input_, topView_);\r\n\r\n    QCOMPARE(designs.size(), 1);\r\n    QSharedPointer<MetaDesign> design = designs.first();\r\n\r\n    QCOMPARE(design->getInstances()->size(), 3);\r\n\r\n    QSharedPointer<MetaInstance> mInstance = design->getInstances()->value(\"receiver1\");\r\n    QCOMPARE(mInstance->getInterfaces()->size(), 1);\r\n\r\n    QSharedPointer<MetaInterface> mInterface = mInstance->getInterfaces()->value(\"data_bus\");\r\n    QCOMPARE(mInterface->ports_.size(), 2);\r\n\r\n    QSharedPointer<MetaPort> mPort = mInterface->ports_.value(\"data_in\");\r\n    QSharedPointer<MetaPortAssignment> mpa = mPort->upAssignments_.value(\"DATA\");\r\n    QCOMPARE(mpa->logicalBounds_.first, QString(\"7\"));\r\n    QCOMPARE(mpa->logicalBounds_.second, QString(\"0\"));\r\n\r\n    mPort = mInterface->ports_.value(\"enable_in\");\r\n    mpa = mPort->upAssignments_.value(\"ENABLE\");\r\n    QCOMPARE(mpa->logicalBounds_.first, QString(\"0\"));\r\n    QCOMPARE(mpa->logicalBounds_.second, QString(\"0\"));\r\n\r\n    mInstance = design->getInstances()->value(\"receiver2\");\r\n    QCOMPARE(mInstance->getInterfaces()->size(), 1);\r\n\r\n    mInterface = mInstance->getInterfaces()->value(\"data_bus\");\r\n    QCOMPARE(mInterface->ports_.size(), 2);\r\n\r\n    mPort = mInterface->ports_.value(\"data_in\");\r\n    mpa = mPort->upAssignments_.value(\"DATA\");\r\n    QCOMPARE(mpa->logicalBounds_.first, QString(\"7\"));\r\n    QCOMPARE(mpa->logicalBounds_.second, QString(\"0\"));\r\n\r\n    mPort = mInterface->ports_.value(\"enable_in\");\r\n    mpa = mPort->upAssignments_.value(\"ENABLE\");\r\n    QCOMPARE(mpa->logicalBounds_.first, QString(\"0\"));\r\n    QCOMPARE(mpa->logicalBounds_.second, QString(\"0\"));\r\n\r\n    QCOMPARE(design->getInterconnections()->size(), 1);\r\n    QSharedPointer<MetaInterconnection> mInterconnect = design->getInterconnections()->first();\r\n\r\n    QCOMPARE(mInterconnect->wires_.size(), 2);\r\n    QSharedPointer<MetaWire> mWire = mInterconnect->wires_.first();\r\n    QCOMPARE(mWire->hierPorts_.size(), 0);\r\n    QCOMPARE(mWire->bounds_.first, QString(\"7\"));\r\n    QCOMPARE(mWire->bounds_.second, QString(\"0\"));\r\n\r\n    mWire = mInterconnect->wires_.last();\r\n    QCOMPARE(mWire->hierPorts_.size(), 0);\r\n    QCOMPARE(mWire->bounds_.first, QString(\"0\"));\r\n    QCOMPARE(mWire->bounds_.second, QString(\"0\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_HDLParser::testInterconnectionToVaryingSizeLogicalMaps()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_HDLParser::testInterconnectionToVaryingSizeLogicalMaps()\r\n{\r\n    VLNV senderVLNV(VLNV::COMPONENT, \"Test\", \"TestLibrary\", \"TestSender\", \"1.0\");\r\n    QSharedPointer<View> sendView = addSenderComponentToLibrary(senderVLNV, General::MASTER);\r\n    addInstanceToDesign(\"sender\", senderVLNV, sendView);\r\n\r\n    VLNV oneBitReceiverVLNV(VLNV::COMPONENT, \"Test\", \"TestLibrary\", \"TestReceiver\", \"1.0\");\r\n    QSharedPointer<View> recvView1 = addReceiverComponentToLibrary(oneBitReceiverVLNV, General::SLAVE);\r\n    setReceiverComponentDataWidth(oneBitReceiverVLNV, 1);\r\n    addInstanceToDesign(\"oneBitReceiver\", oneBitReceiverVLNV, recvView1);\r\n    \r\n    VLNV fourBitReceiverVLNV(VLNV::COMPONENT, \"Test\", \"TestLibrary\", \"TestReceiver4bit\", \"1.0\");\r\n    QSharedPointer<View> recvView2 = addReceiverComponentToLibrary(fourBitReceiverVLNV, General::SLAVE);\r\n    setReceiverComponentDataWidth(fourBitReceiverVLNV, 4);\r\n    addInstanceToDesign(\"fourBitReceiver\", fourBitReceiverVLNV, recvView2);\r\n\r\n    VLNV sixteenBitReceiverVLNV(VLNV::COMPONENT, \"Test\", \"TestLibrary\", \"TestReceiver16bit\", \"1.0\");\r\n    QSharedPointer<View> recvView3 = addReceiverComponentToLibrary(sixteenBitReceiverVLNV, General::SLAVE);\r\n    setReceiverComponentDataWidth(sixteenBitReceiverVLNV, 16);\r\n    addInstanceToDesign(\"sixteenBitReceiver\", sixteenBitReceiverVLNV, recvView3);\r\n\r\n    addConnectionToDesign(\"sender\", \"data_bus\", \"oneBitReceiver\", \"data_bus\");\r\n    addConnectionToDesign(\"sender\", \"data_bus\", \"fourBitReceiver\", \"data_bus\");\r\n    addConnectionToDesign(\"sender\", \"data_bus\", \"sixteenBitReceiver\", \"data_bus\");\r\n\r\n    QList<QSharedPointer<MetaDesign> > designs = MetaDesign::parseHierarchy\r\n        (&library_, input_, topView_);\r\n\r\n    QCOMPARE(designs.size(), 1);\r\n    QSharedPointer<MetaDesign> design = designs.first();\r\n\r\n    QCOMPARE(design->getInstances()->size(), 4);\r\n\r\n    QSharedPointer<MetaInstance> mInstance0 = design->getInstances()->value(\"sender\");\r\n    QSharedPointer<MetaInstance> mInstance1 = design->getInstances()->value(\"oneBitReceiver\");\r\n    QSharedPointer<MetaInstance> mInstance2 = design->getInstances()->value(\"fourBitReceiver\");\r\n    QSharedPointer<MetaInstance> mInstance3 = design->getInstances()->value(\"sixteenBitReceiver\");\r\n\r\n    QCOMPARE(mInstance0->getInterfaces()->first()->ports_.size(), 2);\r\n    QCOMPARE(mInstance1->getInterfaces()->first()->ports_.size(), 2);\r\n    QCOMPARE(mInstance2->getInterfaces()->first()->ports_.size(), 2);\r\n    QCOMPARE(mInstance3->getInterfaces()->first()->ports_.size(), 2);\r\n\r\n    QSharedPointer<MetaPort> mPort = mInstance0->getInterfaces()->first()->ports_.value(\"data_out\");\r\n    QSharedPointer<MetaPortAssignment> mpa = mPort->upAssignments_.value(\"DATA\");\r\n    QCOMPARE(mpa->logicalBounds_.first, QString(\"7\"));\r\n    QCOMPARE(mpa->logicalBounds_.second, QString(\"0\"));\r\n\r\n    mPort = mInstance1->getInterfaces()->first()->ports_.value(\"data_in\");\r\n    mpa = mPort->upAssignments_.value(\"DATA\");\r\n    QCOMPARE(mpa->logicalBounds_.first, QString(\"0\"));\r\n    QCOMPARE(mpa->logicalBounds_.second, QString(\"0\"));\r\n\r\n    mPort = mInstance2->getInterfaces()->first()->ports_.value(\"data_in\");\r\n    mpa = mPort->upAssignments_.value(\"DATA\");\r\n    QCOMPARE(mpa->logicalBounds_.first, QString(\"3\"));\r\n    QCOMPARE(mpa->logicalBounds_.second, QString(\"0\"));\r\n\r\n    mPort = mInstance3->getInterfaces()->first()->ports_.value(\"data_in\");\r\n    mpa = mPort->upAssignments_.value(\"DATA\");\r\n    QCOMPARE(mpa->logicalBounds_.first, QString(\"15\"));\r\n    QCOMPARE(mpa->logicalBounds_.second, QString(\"0\"));\r\n\r\n    QCOMPARE(design->getInterconnections()->size(), 1);\r\n    QSharedPointer<MetaInterconnection> mInterconnect = design->getInterconnections()->first();\r\n\r\n    QCOMPARE(mInterconnect->wires_.size(), 2);\r\n    QSharedPointer<MetaWire> mWire = mInterconnect->wires_.first();\r\n    QCOMPARE(mWire->hierPorts_.size(), 0);\r\n    QCOMPARE(mWire->bounds_.first, QString(\"15\"));\r\n    QCOMPARE(mWire->bounds_.second, QString(\"0\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_HDLParser::setComponentDataWidth()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_HDLParser::setReceiverComponentDataWidth(VLNV receiverVLNV, int dataWidth)\r\n{\r\n    QSharedPointer<Component> component = library_.getModel(receiverVLNV).dynamicCast<Component>();\r\n    QSharedPointer<Port> componentPort = component->getPort(\"data_in\");\r\n    componentPort->setLeftBound(QString::number(dataWidth - 1));\r\n    componentPort->setRightBound(QString::number(0));\r\n\r\n\tQSharedPointer<PortMap> dataMap = \r\n        component->getBusInterface(\"data_bus\")->getAbstractionTypes()->first()->getPortMaps()->first();\r\n\r\n    QSharedPointer<PortMap::LogicalPort> logPort = dataMap->getLogicalPort();\r\n    if (!logPort)\r\n    {\r\n        QSharedPointer<PortMap::LogicalPort> newLogicalPort (new PortMap::LogicalPort());\r\n        dataMap->setLogicalPort(newLogicalPort);\r\n        logPort = newLogicalPort;\r\n    }\r\n\r\n    logPort->range_ = QSharedPointer<Range>(new Range(QString::number(dataWidth-1), \"0\"));\r\n\r\n\tdataMap->setLogicalPort(logPort);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_HDLParser::testSlicedInterconnection()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_HDLParser::testSlicedInterconnection()\r\n{\r\n\tVLNV senderVLNV(VLNV::COMPONENT, \"Test\", \"TestLibrary\", \"TestSender\", \"1.0\");\r\n\r\n    QSharedPointer<Component> senderComponent(new Component(senderVLNV, Document::Revision::Std14));\r\n    addPort(\"enable_out_low\", 1, DirectionTypes::OUT, senderComponent);\r\n    addPort(\"enable_out_high\", 1, DirectionTypes::OUT, senderComponent);\r\n\r\n    addInterfaceToComponent(\"data_bus\", senderComponent, dataAbstractionVLNV_);\r\n    QSharedPointer<BusInterface> enableIf = senderComponent->getBusInterface(\"data_bus\");\r\n    enableIf->setInterfaceMode(General::MASTER);    \r\n\r\n\tQSharedPointer<PortMap> enableLowPortMap(new PortMap());\r\n\tQSharedPointer<PortMap::LogicalPort> logPortLow(new PortMap::LogicalPort(\"ENABLE\"));\r\n\tQSharedPointer<PortMap::PhysicalPort> physPortLow(new PortMap::PhysicalPort(\"enable_out_low\"));\r\n    enableLowPortMap->setLogicalPort(logPortLow);\r\n\tenableLowPortMap->setPhysicalPort(physPortLow);\r\n\r\n    QSharedPointer<PartSelect> lowPart (new PartSelect(\"0\", \"0\"));\r\n    physPortLow->partSelect_ = lowPart;\r\n\r\n    QSharedPointer<Range> lowRange (new Range(\"0\", \"0\"));\r\n    logPortLow->range_ = lowRange;\r\n\r\n\tQSharedPointer<PortMap> enableHighPortMap(new PortMap());\r\n\tQSharedPointer<PortMap::LogicalPort> logPortHigh(new PortMap::LogicalPort(\"ENABLE\"));\r\n\tQSharedPointer<PortMap::PhysicalPort> physPortHigh(new PortMap::PhysicalPort(\"enable_out_high\"));\r\n    enableHighPortMap->setLogicalPort(logPortHigh);\r\n    enableHighPortMap->setPhysicalPort(physPortHigh);\r\n\r\n    QSharedPointer<PartSelect> highPart (new PartSelect(\"0\", \"0\"));\r\n    physPortHigh->partSelect_ = highPart;\r\n\r\n    QSharedPointer<Range> highRange (new Range(\"1\", \"1\"));\r\n    logPortHigh->range_ = highRange;\r\n\r\n    QSharedPointer<AbstractionType> senderEnableAbstraction (new AbstractionType());\r\n    enableIf->getAbstractionTypes()->append(senderEnableAbstraction);\r\n\r\n    QSharedPointer<QList<QSharedPointer<PortMap> > > portMaps =\r\n        enableIf->getAbstractionTypes()->first()->getPortMaps();\r\n    portMaps->append(enableLowPortMap);\r\n\tportMaps->append(enableHighPortMap);\r\n\r\n\tQSharedPointer<View> sendView(new View(\"rtl\"));\r\n\tsendView->setComponentInstantiationRef(\"instance1\");\r\n\r\n\tQSharedPointer<ComponentInstantiation> instantiation(new ComponentInstantiation(\"instance1\"));\r\n\tsenderComponent->getComponentInstantiations()->append(instantiation);\r\n\tsenderComponent->getViews()->append(sendView);\r\n\r\n    library_.addComponent(senderComponent);\r\n    addInstanceToDesign(\"sender\", senderVLNV, sendView);\r\n\r\n    VLNV receiver(VLNV::COMPONENT, \"Test\", \"TestLibrary\", \"TestReceiver\", \"1.0\");\r\n    QSharedPointer<View> recvView = addReceiverComponentToLibrary(receiver, General::SLAVE);\r\n    QSharedPointer<Component> receiverComponent = library_.getModel(receiver).dynamicCast<Component>();\r\n    QSharedPointer<PortMap> enableMap =\r\n        receiverComponent->getBusInterface(\"data_bus\")->getAbstractionTypes()->first()->getPortMaps()->last();\r\n    enableMap->getLogicalPort()->range_ = QSharedPointer<Range>(new Range(\"1\", \"0\"));\r\n\r\n\taddInstanceToDesign(\"receiver\", receiver, recvView);\r\n\r\n\tQSharedPointer<ConfigurableVLNVReference> abstractionVLNV(new ConfigurableVLNVReference(\r\n\t\tVLNV::ABSTRACTIONDEFINITION, \"Test\", \"TestLibrary\", \"absDef\", \"1.0\"));\r\n\r\n\tQSharedPointer<AbstractionDefinition> testAbstractionDefinition(new AbstractionDefinition(*abstractionVLNV, Document::Revision::Std14));\r\n\tlibrary_.addComponent(testAbstractionDefinition);\r\n\r\n\tQSharedPointer<PortAbstraction> logicalPort (new PortAbstraction());\r\n\tlogicalPort->setName(\"ENABLE\");\r\n\tQSharedPointer<WireAbstraction> wire(new WireAbstraction);\r\n\tlogicalPort->setWire(wire);\r\n\tQSharedPointer<WirePort> wp(new WirePort);\r\n\twp->setWidth(\"2\");\r\n\twire->setSlavePort(wp);\r\n\twire->setMasterPort(wp);\r\n\r\n\ttestAbstractionDefinition->getLogicalPorts()->append(logicalPort);\r\n\r\n\tenableIf->getAbstractionTypes()->first()->setAbstractionRef(abstractionVLNV);\r\n\treceiverComponent->getBusInterface(\"data_bus\")->getAbstractionTypes()->first()->setAbstractionRef(abstractionVLNV);\r\n\r\n    addConnectionToDesign(\"sender\", \"data_bus\", \"receiver\", \"data_bus\");\r\n\r\n    QList<QSharedPointer<MetaDesign> > designs = MetaDesign::parseHierarchy\r\n        (&library_, input_, topView_);\r\n\r\n    QCOMPARE(designs.size(), 1);\r\n    QSharedPointer<MetaDesign> design = designs.first();\r\n\r\n    QCOMPARE(design->getInstances()->size(), 2);\r\n\r\n    QSharedPointer<MetaInstance> mInstance0 = design->getInstances()->value(\"sender\");\r\n    QSharedPointer<MetaInstance> mInstance1 = design->getInstances()->value(\"receiver\");\r\n\r\n    QVERIFY(mInstance0->getInterfaces()->first()->ports_.size() > 0);\r\n    QVERIFY(mInstance1->getInterfaces()->first()->ports_.size() > 0);\r\n\r\n    QSharedPointer<MetaPort> mPort = mInstance0->getInterfaces()->first()->ports_.value(\"enable_out_high\");\r\n    QSharedPointer<MetaPortAssignment> mpa = mPort->upAssignments_.value(\"ENABLE\");\r\n    QCOMPARE(mpa->logicalBounds_.first, QString(\"1\"));\r\n    QCOMPARE(mpa->logicalBounds_.second, QString(\"1\"));\r\n\r\n    mPort = mInstance0->getInterfaces()->first()->ports_.value(\"enable_out_low\");\r\n    mpa = mPort->upAssignments_.value(\"ENABLE\");\r\n    QCOMPARE(mpa->logicalBounds_.first, QString(\"0\"));\r\n    QCOMPARE(mpa->logicalBounds_.second, QString(\"0\"));\r\n\r\n    mPort = mInstance1->getInterfaces()->first()->ports_.value(\"enable_in\");\r\n    mpa = mPort->upAssignments_.value(\"ENABLE\");\r\n    QCOMPARE(mpa->logicalBounds_.first, QString(\"1\"));\r\n    QCOMPARE(mpa->logicalBounds_.second, QString(\"0\"));\r\n\r\n    QCOMPARE(design->getInterconnections()->size(), 1);\r\n    QSharedPointer<MetaInterconnection> mInterconnect = design->getInterconnections()->first();\r\n\r\n    QVERIFY(mInterconnect->wires_.size() > 0);\r\n    QSharedPointer<MetaWire> mWire = mInterconnect->wires_.last();\r\n    QCOMPARE(mWire->hierPorts_.size(), 0);\r\n    QCOMPARE(mWire->bounds_.first, QString(\"1\"));\r\n    QCOMPARE(mWire->bounds_.second, QString(\"0\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_HDLParser::testAbsDefDefault()\r\n//-----------------------------------------------------------------------------\r\n/*void tst_HDLParser::testAbsDefDefault()\r\n{\r\n    VLNV senderVLNV(VLNV::COMPONENT, \"Test\", \"TestLibrary\", \"TestSender\", \"1.0\");\r\n\r\n    QSharedPointer<Component> senderComponent(new Component(senderVLNV));\r\n    addPort(\"enable_out_low\", 1, DirectionTypes::OUT, senderComponent);\r\n    addPort(\"enable_out_high\", 1, DirectionTypes::OUT, senderComponent);\r\n\r\n    addInterfaceToComponent(\"data_bus\", senderComponent, dataAbstractionVLNV_);\r\n    QSharedPointer<BusInterface> enableIf = senderComponent->getBusInterface(\"data_bus\");\r\n    enableIf->setInterfaceMode(General::MASTER);    \r\n\r\n    QSharedPointer<AbstractionType> senderEnableAbstraction (new AbstractionType());\r\n    enableIf->getAbstractionTypes()->append(senderEnableAbstraction);\r\n\r\n    QSharedPointer<View> sendView(new View(\"rtl\"));\r\n    sendView->setComponentInstantiationRef(\"instance1\");\r\n\r\n    QSharedPointer<ComponentInstantiation> instantiation(new ComponentInstantiation(\"instance1\"));\r\n    senderComponent->getComponentInstantiations()->append(instantiation);\r\n    senderComponent->getViews()->append(sendView);\r\n\r\n    library_.addComponent(senderComponent);\r\n    addInstanceToDesign(\"sender\", senderVLNV, sendView);\r\n\r\n    VLNV receiver(VLNV::COMPONENT, \"Test\", \"TestLibrary\", \"TestReceiver\", \"1.0\");\r\n    QSharedPointer<View> recvView = addReceiverComponentToLibrary(receiver, General::SLAVE);\r\n    QSharedPointer<Component> receiverComponent = library_.getModel(receiver).dynamicCast<Component>();\r\n    QSharedPointer<PortMap> enableMap = receiverComponent->getBusInterface(\"data_bus\")->getPortMaps()->last();\r\n    enableMap->getLogicalPort()->range_ = QSharedPointer<Range>(new Range(\"2\", \"0\"));\r\n\r\n    addInstanceToDesign(\"receiver\", receiver, recvView);\r\n\r\n    QSharedPointer<ConfigurableVLNVReference> abstractionVLNV(new ConfigurableVLNVReference(\r\n        VLNV::ABSTRACTIONDEFINITION, \"Test\", \"TestLibrary\", \"absDef\", \"1.0\"));\r\n\r\n    QSharedPointer<AbstractionDefinition> testAbstractionDefinition(new AbstractionDefinition());\r\n    testAbstractionDefinition->setVlnv(*abstractionVLNV.data());\r\n    library_.addComponent(testAbstractionDefinition);\r\n\r\n    QSharedPointer<PortAbstraction> logicalPort (new PortAbstraction());\r\n    logicalPort->setName(\"ENABLE\");\r\n    QSharedPointer<WireAbstraction> wire(new WireAbstraction);\r\n    logicalPort->setWire(wire);\r\n    wire->setDefaultValue(\"5\");\r\n    QSharedPointer<WirePort> wp(new WirePort);\r\n    wp->setWidth(\"2\");\r\n    wire->setSlavePort(wp);\r\n    wire->setMasterPort(wp);\r\n\r\n    testAbstractionDefinition->getLogicalPorts()->append(logicalPort);\r\n\r\n    enableIf->getAbstractionTypes()->first()->setAbstractionRef(abstractionVLNV);\r\n    receiverComponent->getBusInterface(\"data_bus\")->getAbstractionTypes()->first()->setAbstractionRef(abstractionVLNV);\r\n\r\n    addConnectionToDesign(\"sender\", \"data_bus\", \"receiver\", \"data_bus\");\r\n\r\n    QList<QSharedPointer<MetaDesign> > designs = MetaDesign::parseHierarchy\r\n        (&library_, input_, topView_);\r\n\r\n    QCOMPARE(designs.size(), 1);\r\n    QSharedPointer<MetaDesign> design = designs.first();\r\n\r\n    QCOMPARE(design->getInstances()->size(), 2);\r\n\r\n    QSharedPointer<MetaInstance> mInstance = design->getInstances()->value(\"receiver\");\r\n\r\n    QVERIFY(mInstance->getInterfaces()->first()->ports_.size() > 0);\r\n\r\n    QSharedPointer<MetaPort> mPort = mInstance->getInterfaces()->first()->ports_.value(\"enable_in\");\r\n    QSharedPointer<MetaPortAssignment> mpa = mPort->upAssignments_.value(\"ENABLE\");\r\n    QCOMPARE(mpa->logicalBounds_.first, QString(\"2\"));\r\n    QCOMPARE(mpa->logicalBounds_.second, QString(\"0\"));\r\n    QCOMPARE(mpa->defaultValue_, QString(\"5\"));\r\n}*/\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_HDLParser::testPortDefaultValueInComponentInstance()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_HDLParser::testPortDefaultValueInComponentInstance()\r\n{\r\n    VLNV tieOffVLNV(VLNV::COMPONENT, \"Test\", \"TestLibrary\", \"TestTieOff\", \"1.0\");\r\n    QSharedPointer<Component> tieOffComponent(new Component(tieOffVLNV, Document::Revision::Std14));\r\n\r\n    QSharedPointer<View> activeView(new View(\"rtl\"));\r\n    activeView->setComponentInstantiationRef(\"instance1\");\r\n\r\n    QSharedPointer<ComponentInstantiation> instantiation(new ComponentInstantiation(\"instance1\"));\r\n    tieOffComponent->getComponentInstantiations()->append(instantiation);\r\n    tieOffComponent->getViews()->append(activeView);\r\n\r\n    QString instanceName = \"tieOffer\";\r\n\r\n    QString unconnnectedIn = \"unconnnectedIn\";\r\n    QString unconnnectedInOut = \"unconnnectedInOut\";\r\n    QString unconnnectedOut = \"unconnnectedOut\";\r\n\r\n    addPort(unconnnectedIn, 1, DirectionTypes::IN, tieOffComponent);\r\n    addPort(unconnnectedInOut, 2, DirectionTypes::INOUT, tieOffComponent);\r\n    addPort(unconnnectedOut, 3, DirectionTypes::OUT, tieOffComponent);\r\n\r\n    addInterfaceToComponent(\"data_bus\", tieOffComponent, dataAbstractionVLNV_);\r\n\r\n    mapPortToInterface(\"unconnnectedIn\", \"DATA\", \"data_bus\", tieOffComponent);\r\n    mapPortToInterface(\"unconnnectedInOut\", \"ENABLE\", \"data_bus\", tieOffComponent);\r\n    mapPortToInterface(\"unconnnectedOut\", \"FULL\", \"data_bus\", tieOffComponent);\r\n\r\n    library_.addComponent(tieOffComponent);\r\n\r\n    addInstanceToDesign(instanceName, tieOffVLNV, activeView);\r\n\r\n    QSharedPointer<Port> defaultPort1 = tieOffComponent->getPort(\"unconnnectedIn\");\r\n    defaultPort1->setDefaultValue(\"1\");\r\n    QSharedPointer<Port> defaultPort2 = tieOffComponent->getPort(\"unconnnectedInOut\");\r\n    defaultPort2->setDefaultValue(\"35\");\r\n    QSharedPointer<Port> defaultPort3 = tieOffComponent->getPort(\"unconnnectedOut\");\r\n    defaultPort3->setDefaultValue(\"23\");\r\n\r\n    QList<QSharedPointer<MetaDesign> > designs = MetaDesign::parseHierarchy\r\n        (&library_, input_, topView_);\r\n\r\n    QCOMPARE(designs.size(), 1);\r\n    QSharedPointer<MetaDesign> design = designs.first();\r\n    QCOMPARE(design->getInstances()->size(), 1);\r\n\r\n    QSharedPointer<MetaInstance> mInstance = design->getInstances()->value(\"tieOffer\");\r\n    QCOMPARE(mInstance->getPorts()->size(), 3);\r\n\r\n    QSharedPointer<MetaPort> mPort = mInstance->getPorts()->value(\"unconnnectedIn\");\r\n    QCOMPARE(mPort->defaultValue_, QString(\"1\"));\r\n    QCOMPARE(mPort->upAssignments_.size(), 0);\r\n    //QCOMPARE(mPort->downAssignments_.size(), 0);\r\n\r\n    mPort = mInstance->getPorts()->value(\"unconnnectedInOut\");\r\n    QCOMPARE(mPort->defaultValue_, QString(\"35\"));\r\n    QCOMPARE(mPort->upAssignments_.size(), 0);\r\n    //QCOMPARE(mPort->downAssignments_.size(), 0);\r\n\r\n    mPort = mInstance->getPorts()->value(\"unconnnectedOut\");\r\n    QCOMPARE(mPort->defaultValue_, QString(\"23\"));\r\n    QCOMPARE(mPort->upAssignments_.size(), 0);\r\n    //QCOMPARE(mPort->downAssignments_.size(), 0);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_HDLParser::testHierarchicalPortDefaultValue()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_HDLParser::testHierarchicalPortDefaultValue()\r\n{\r\n    QSharedPointer<View> activeView(new View(\"rtl\"));\r\n    activeView->setComponentInstantiationRef(\"instance1\");\r\n\r\n    QSharedPointer<ComponentInstantiation> instantiation(new ComponentInstantiation(\"instance1\"));\r\n    topComponent_->getComponentInstantiations()->append(instantiation);\r\n    topComponent_->getViews()->append(activeView);\r\n\r\n    QString instanceName = \"tieOffer\";\r\n\r\n    QString unconnnectedIn = \"unconnnectedIn\";\r\n    QString unconnnectedInOut = \"unconnnectedInOut\";\r\n    QString unconnnectedOut = \"unconnnectedOut\";\r\n\r\n    addPort(unconnnectedIn, 1, DirectionTypes::IN, topComponent_);\r\n    addPort(unconnnectedInOut, 2, DirectionTypes::INOUT, topComponent_);\r\n    addPort(unconnnectedOut, 3, DirectionTypes::OUT, topComponent_);\r\n\r\n    addInterfaceToComponent(\"data_bus\", topComponent_, dataAbstractionVLNV_);\r\n\r\n    mapPortToInterface(\"unconnnectedIn\", \"DATA\", \"data_bus\", topComponent_);\r\n    mapPortToInterface(\"unconnnectedInOut\", \"ENABLE\", \"data_bus\", topComponent_);\r\n    mapPortToInterface(\"unconnnectedOut\", \"FULL\", \"data_bus\", topComponent_);;\r\n\r\n    QSharedPointer<Port> defaultPort1 = topComponent_->getPort(\"unconnnectedIn\");\r\n    defaultPort1->setDefaultValue(\"1\");\r\n    QSharedPointer<Port> defaultPort2 = topComponent_->getPort(\"unconnnectedInOut\");\r\n    defaultPort2->setDefaultValue(\"35\");\r\n    QSharedPointer<Port> defaultPort3 = topComponent_->getPort(\"unconnnectedOut\");\r\n    defaultPort3->setDefaultValue(\"23\");\r\n\r\n    QList<QSharedPointer<MetaDesign> > designs = MetaDesign::parseHierarchy\r\n        (&library_, input_, topView_);\r\n\r\n    QCOMPARE(designs.size(), 1);\r\n    QSharedPointer<MetaDesign> design = designs.first();\r\n    QVERIFY(design->getTopInstance());\r\n\r\n    QSharedPointer<MetaInstance> mInstance = design->getTopInstance();\r\n    QCOMPARE(mInstance->getPorts()->size(), 3);\r\n\r\n    QSharedPointer<MetaPort> mPort = mInstance->getPorts()->value(\"unconnnectedIn\");\r\n    QCOMPARE(mPort->defaultValue_, QString(\"1\"));\r\n    //QCOMPARE(mPort->upAssignments_.size(), 0);\r\n    QCOMPARE(mPort->downAssignments_.size(), 0);\r\n\r\n    mPort = mInstance->getPorts()->value(\"unconnnectedInOut\");\r\n    QCOMPARE(mPort->defaultValue_, QString(\"35\"));\r\n    //QCOMPARE(mPort->upAssignments_.size(), 0);\r\n    QCOMPARE(mPort->downAssignments_.size(), 0);\r\n\r\n    mPort = mInstance->getPorts()->value(\"unconnnectedOut\");\r\n    QCOMPARE(mPort->defaultValue_, QString(\"23\"));\r\n    //QCOMPARE(mPort->upAssignments_.size(), 0);\r\n    QCOMPARE(mPort->downAssignments_.size(), 0);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_HDLParser::testAdhocConnectionBetweenComponentInstances()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_HDLParser::testAdhocConnectionBetweenComponentInstances()\r\n{\r\n    VLNV senderVLNV(VLNV::COMPONENT, \"Test\", \"TestLibrary\", \"TestSender\", \"1.0\");\r\n    QSharedPointer<View> senderView = addSenderComponentToLibrary(senderVLNV, General::MASTER, false);\r\n    addInstanceToDesign(\"sender\", senderVLNV, senderView);\r\n\r\n    VLNV receiverVLNV(VLNV::COMPONENT, \"Test\", \"TestLibrary\", \"TestReceiver\", \"1.0\");\r\n    QSharedPointer<View> receiverView = addReceiverComponentToLibrary(receiverVLNV, General::SLAVE, false);\r\n    addInstanceToDesign(\"receiver1\", receiverVLNV, receiverView);\r\n    addInstanceToDesign(\"receiver2\", receiverVLNV, receiverView);\r\n\r\n    addAdhocConnection(\"enableAdHoc\", \"sender\", \"enable_out\", \"receiver1\", \"enable_in\");\r\n    addAdhocConnection(\"enableAdHoc\", \"sender\", \"enable_out\", \"receiver2\", \"enable_in\");\r\n    addAdhocConnection(\"dataAdHoc\", \"sender\", \"data_out\", \"receiver1\", \"data_in\");\r\n\r\n    QList<QSharedPointer<MetaDesign> > designs = MetaDesign::parseHierarchy\r\n        (&library_, input_, topView_);\r\n\r\n    QCOMPARE(designs.size(), 1);\r\n    QSharedPointer<MetaDesign> design = designs.first();\r\n\r\n    QCOMPARE(design->getInstances()->size(), 3);\r\n\r\n    QSharedPointer<MetaInstance> mInstance = design->getInstances()->value(\"sender\");\r\n\r\n    QSharedPointer<MetaPort> mPort = mInstance->getPorts()->value(\"data_out\");\r\n    QSharedPointer<MetaPortAssignment> mpa = mPort->upAssignments_.value(\"dataAdHoc\");\r\n    QCOMPARE(mpa->physicalBounds_.first, QString(\"7\"));\r\n    QCOMPARE(mpa->physicalBounds_.second, QString(\"0\"));\r\n\r\n    mPort = mInstance->getPorts()->value(\"enable_out\");\r\n    mpa = mPort->upAssignments_.value(\"enableAdHoc\");\r\n    QCOMPARE(mpa->physicalBounds_.first, QString(\"0\"));\r\n    QCOMPARE(mpa->physicalBounds_.second, QString(\"0\"));\r\n\r\n    mInstance = design->getInstances()->value(\"receiver1\");\r\n\r\n    mPort = mInstance->getPorts()->value(\"data_in\");\r\n    mpa = mPort->upAssignments_.value(\"dataAdHoc\");\r\n    QCOMPARE(mpa->physicalBounds_.first, QString(\"7\"));\r\n    QCOMPARE(mpa->physicalBounds_.second, QString(\"0\"));\r\n\r\n    mPort = mInstance->getPorts()->value(\"enable_in\");\r\n    mpa = mPort->upAssignments_.value(\"enableAdHoc\");\r\n    QCOMPARE(mpa->physicalBounds_.first, QString(\"0\"));\r\n    QCOMPARE(mpa->physicalBounds_.second, QString(\"0\"));\r\n\r\n    mInstance = design->getInstances()->value(\"receiver2\");\r\n\r\n    mPort = mInstance->getPorts()->value(\"enable_in\");\r\n    mpa = mPort->upAssignments_.value(\"enableAdHoc\");\r\n    QCOMPARE(mpa->physicalBounds_.first, QString(\"0\"));\r\n    QCOMPARE(mpa->physicalBounds_.second, QString(\"0\"));\r\n\r\n    QCOMPARE(design->getAdHocWires()->size(), 2);\r\n    QSharedPointer<MetaWire> mWire = design->getAdHocWires()->first();\r\n\r\n    QCOMPARE(mWire->hierPorts_.size(), 0);\r\n    QCOMPARE(mWire->bounds_.first, QString(\"0\"));\r\n    QCOMPARE(mWire->bounds_.second, QString(\"0\"));\r\n\r\n    mWire = design->getAdHocWires()->last();\r\n    QCOMPARE(mWire->hierPorts_.size(), 0);\r\n    QCOMPARE(mWire->bounds_.first, QString(\"7\"));\r\n    QCOMPARE(mWire->bounds_.second, QString(\"0\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_HDLParser::testAdhocConnectionToVaryingSizePorts()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_HDLParser::testAdhocConnectionToVaryingSizePorts()\r\n{\r\n    QSharedPointer<View> activeView(new View(\"rtl\"));\r\n    activeView->setComponentInstantiationRef(\"instance1\");\r\n\r\n    VLNV senderVLNV(VLNV::COMPONENT, \"Test\", \"TestLibrary\", \"TestSender\", \"1.0\");\r\n    QSharedPointer<Component> senderComponent(new Component(senderVLNV, Document::Revision::Std14));\r\n    library_.addComponent(senderComponent);\r\n    addInstanceToDesign(\"sender\", senderVLNV, activeView);\r\n    senderComponent->getViews()->append(activeView);\r\n\r\n    QSharedPointer<Port> senderPort = QSharedPointer<Port>(new Port(\"data_out\"));\r\n    senderPort->setDirection(DirectionTypes::OUT);\r\n    senderPort->setLeftBound(\"16\");\r\n    senderPort->setRightBound(\"4\");\r\n    senderComponent->getPorts()->append(senderPort);\r\n\r\n    VLNV receiverVLNV(VLNV::COMPONENT, \"Test\", \"TestLibrary\", \"TestReceiver\", \"1.0\");\r\n    QSharedPointer<View> receiverView = addReceiverComponentToLibrary(receiverVLNV, General::SLAVE);\r\n    addInstanceToDesign(\"receiver\", receiverVLNV, receiverView);\r\n\r\n    addAdhocConnection(\"dataAdHoc\", \"sender\", \"data_out\", \"receiver\", \"data_in\");\r\n\r\n    QList<QSharedPointer<MetaDesign> > designs = MetaDesign::parseHierarchy\r\n        (&library_, input_, topView_);\r\n\r\n    QCOMPARE(designs.size(), 1);\r\n    QSharedPointer<MetaDesign> design = designs.first();\r\n\r\n    QCOMPARE(design->getInstances()->size(), 2);\r\n\r\n    QSharedPointer<MetaInstance> mInstance = design->getInstances()->value(\"sender\");\r\n\r\n    QSharedPointer<MetaPort> mPort = mInstance->getPorts()->value(\"data_out\");\r\n    QSharedPointer<MetaPortAssignment> mpa = mPort->upAssignments_.value(\"dataAdHoc\");\r\n    QCOMPARE(mpa->physicalBounds_.first, QString(\"16\"));\r\n    QCOMPARE(mpa->physicalBounds_.second, QString(\"4\"));\r\n    QCOMPARE(mpa->logicalBounds_.first, QString(\"12\"));\r\n    QCOMPARE(mpa->logicalBounds_.second, QString(\"0\"));\r\n\r\n    QCOMPARE(design->getAdHocWires()->size(), 1);\r\n    QSharedPointer<MetaWire> mWire = design->getAdHocWires()->first();\r\n\r\n    mWire = design->getAdHocWires()->last();\r\n    QCOMPARE(mWire->bounds_.first, QString(\"12\"));\r\n    QCOMPARE(mWire->bounds_.second, QString(\"0\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_HDLParser::testAdhocConnectionWithPartSelect()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_HDLParser::testAdhocConnectionWithPartSelect()\r\n{\r\n    QSharedPointer<View> senderView(new View(\"rtl\"));\r\n    senderView->setComponentInstantiationRef(\"instance1\");\r\n\r\n    VLNV senderVLNV(VLNV::COMPONENT, \"Test\", \"TestLibrary\", \"TestSender\", \"1.0\");\r\n    QSharedPointer<Component> senderComponent(new Component(senderVLNV, Document::Revision::Std14));\r\n    library_.addComponent(senderComponent);\r\n    addInstanceToDesign(\"sender\", senderVLNV, senderView);\r\n    senderComponent->getViews()->append(senderView);\r\n\r\n    QSharedPointer<Port> senderPort = QSharedPointer<Port>(new Port(\"data_out\"));\r\n    senderPort->setDirection(DirectionTypes::OUT);\r\n    senderPort->setLeftBound(\"16\");\r\n    senderPort->setRightBound(\"4\");\r\n    senderComponent->getPorts()->append(senderPort);\r\n\r\n    QSharedPointer<View> receiverView(new View(\"rtl\"));\r\n\r\n    VLNV receiverVLNV(VLNV::COMPONENT, \"Test\", \"TestLibrary\", \"TestReceiver\", \"1.0\");\r\n    QSharedPointer<Component> receiverComponent(new Component(receiverVLNV, Document::Revision::Std14));\r\n    library_.addComponent(receiverComponent);\r\n    addInstanceToDesign(\"receiver\", receiverVLNV, receiverView);\r\n    receiverComponent->getViews()->append(receiverView);\r\n\r\n    QSharedPointer<Port> receiverPort = QSharedPointer<Port>(new Port(\"data_in\"));\r\n    receiverPort->setDirection(DirectionTypes::IN);\r\n    receiverPort->setLeftBound(\"7\");\r\n    receiverPort->setRightBound(\"0\");\r\n    receiverComponent->getPorts()->append(receiverPort);\r\n\r\n    QSharedPointer<AdHocConnection> connection = addAdhocConnection(\"dataAdHoc\", \"sender\", \"data_out\", \"receiver\", \"data_in\");\r\n\r\n    QSharedPointer<PartSelect> ps1(new PartSelect);\r\n    ps1->setLeftRange(\"8\");\r\n    ps1->setRightRange(\"3\");\r\n    connection->getInternalPortReferences()->first()->setPartSelect(ps1);\r\n\r\n    QSharedPointer<PartSelect> ps2(new PartSelect);\r\n    ps2->setLeftRange(\"2\");\r\n    ps2->setRightRange(\"0\");\r\n    connection->getInternalPortReferences()->last()->setPartSelect(ps2);\r\n\r\n    QList<QSharedPointer<MetaDesign> > designs = MetaDesign::parseHierarchy\r\n        (&library_, input_, topView_);\r\n\r\n    QCOMPARE(designs.size(), 1);\r\n    QSharedPointer<MetaDesign> design = designs.first();\r\n\r\n    QCOMPARE(design->getInstances()->size(), 2);\r\n\r\n    QSharedPointer<MetaInstance> mInstance1 = design->getInstances()->value(\"sender\");\r\n\r\n    QSharedPointer<MetaPort> mPort1 = mInstance1->getPorts()->value(\"data_out\");\r\n    QSharedPointer<MetaPortAssignment> mpa1 = mPort1->upAssignments_.value(\"dataAdHoc\");\r\n    QCOMPARE(mpa1->physicalBounds_.first, QString(\"8\"));\r\n    QCOMPARE(mpa1->physicalBounds_.second, QString(\"3\"));\r\n    QCOMPARE(mpa1->logicalBounds_.first, QString(\"5\"));\r\n    QCOMPARE(mpa1->logicalBounds_.second, QString(\"0\"));\r\n\r\n    QSharedPointer<MetaInstance> mInstance2 = design->getInstances()->value(\"receiver\");\r\n\r\n    QSharedPointer<MetaPort> mPort2 = mInstance2->getPorts()->value(\"data_in\");\r\n    QSharedPointer<MetaPortAssignment> mpa2 = mPort2->upAssignments_.value(\"dataAdHoc\");\r\n    QCOMPARE(mpa2->physicalBounds_.first, QString(\"2\"));\r\n    QCOMPARE(mpa2->physicalBounds_.second, QString(\"0\"));\r\n    QCOMPARE(mpa2->logicalBounds_.first, QString(\"2\"));\r\n    QCOMPARE(mpa2->logicalBounds_.second, QString(\"0\"));\r\n\r\n    QCOMPARE(design->getAdHocWires()->size(), 1);\r\n    QSharedPointer<MetaWire> mWire = design->getAdHocWires()->first();\r\n\r\n    mWire = design->getAdHocWires()->last();\r\n    QCOMPARE(mWire->bounds_.first, QString(\"5\"));\r\n    QCOMPARE(mWire->bounds_.second, QString(\"0\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_HDLParser::testAdhocTieOffInComponentInstance()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_HDLParser::testAdhocTieOffInComponentInstance()\r\n{\r\n    VLNV tieOffVLNV(VLNV::COMPONENT, \"Test\", \"TestLibrary\", \"TestTieOff\", \"1.0\");\r\n\tQSharedPointer<Component> tieOffComponent(new Component(tieOffVLNV, Document::Revision::Std14));\r\n\r\n\tQSharedPointer<View> activeView(new View(\"rtl\"));\r\n\tactiveView->setComponentInstantiationRef(\"instance1\");\r\n\r\n\tQSharedPointer<ComponentInstantiation> instantiation(new ComponentInstantiation(\"instance1\"));\r\n\ttieOffComponent->getComponentInstantiations()->append(instantiation);\r\n\ttieOffComponent->getViews()->append(activeView);\r\n\r\n    QString instanceName = \"tieOffer\";\r\n\r\n    QString portDefaultName = \"portDefault\";\r\n    QString defaultValueName = \"defaultValue\";\r\n    QString zeroName = \"zeroTieOff\";\r\n    QString oneName = \"oneTieOff\";\r\n    QString naName = \"n/aTieOff\";\r\n    QString numberedName = \"numberedTieOff\";\r\n    QString outName = \"tieOffOut\";\r\n    QString inOutName = \"tieOffInOut\";\r\n    QString openName = \"openTieOff\";\r\n    QString expressionName = \"expressionTieOff\";\r\n\r\n    QSharedPointer<Port> portDefault = addPort(portDefaultName, 4, DirectionTypes::OUT, tieOffComponent);\r\n    portDefault->setDefaultValue(\"20\");\r\n    QSharedPointer<Port> defaultPort = addPort(defaultValueName, 4, DirectionTypes::IN, tieOffComponent);\r\n    defaultPort->setDefaultValue(\"35\");\r\n\r\n    addPort(zeroName, 2, DirectionTypes::IN, tieOffComponent);\r\n    addPort(oneName, 4, DirectionTypes::IN, tieOffComponent);\r\n    addPort(naName, 0, DirectionTypes::IN, tieOffComponent);\r\n    addPort(numberedName, 10, DirectionTypes::IN, tieOffComponent);\r\n    addPort(outName, 2, DirectionTypes::OUT, tieOffComponent);\r\n    addPort(inOutName, 10, DirectionTypes::INOUT, tieOffComponent);\r\n    addPort(openName, 1, DirectionTypes::IN, tieOffComponent);\r\n    addPort(expressionName, 1, DirectionTypes::IN, tieOffComponent);\r\n\r\n    library_.addComponent(tieOffComponent);\r\n\r\n    addInstanceToDesign(instanceName, tieOffVLNV, activeView);\r\n\r\n    QSharedPointer<Parameter> expressionParameter (new Parameter());\r\n    expressionParameter->setName(\"expName\");\r\n    expressionParameter->setValueId(\"expID\");\r\n    expressionParameter->setValue(\"5\");\r\n    tieOffComponent->getParameters()->append(expressionParameter);\r\n\r\n    addTieOffAdhocConnectionToInstancePort(\"default\", instanceName, defaultValueName, \"default_connection\");\r\n    addTieOffAdhocConnectionToInstancePort(\"0\", instanceName, zeroName, \"zero_connection\");\r\n    addTieOffAdhocConnectionToInstancePort(\"1\", instanceName, oneName, \"one_connection\");\r\n    addTieOffAdhocConnectionToInstancePort(\"abc\", instanceName, naName, \"n/a_connection\");\r\n    addTieOffAdhocConnectionToInstancePort(\"12\", instanceName, numberedName, \"number_connection\");\r\n    addTieOffAdhocConnectionToInstancePort(\"0\", instanceName, outName, \"out_connection\");\r\n    addTieOffAdhocConnectionToInstancePort(\"1\", instanceName, inOutName, \"inOut_connection\");\r\n    addTieOffAdhocConnectionToInstancePort(\"open\", instanceName, openName, \"open_connection\");\r\n    addTieOffAdhocConnectionToInstancePort(\"expID - 4\", instanceName, expressionName, \"expression_connection\");\r\n\r\n    QList<QSharedPointer<MetaDesign> > designs = MetaDesign::parseHierarchy\r\n        (&library_, input_, topView_);\r\n\r\n    QCOMPARE(designs.size(), 1);\r\n    QSharedPointer<MetaDesign> design = designs.first();\r\n    QCOMPARE(design->getInstances()->size(), 1);\r\n\r\n    QSharedPointer<MetaInstance> mInstance = design->getInstances()->value(\"tieOffer\");\r\n    QCOMPARE(mInstance->getPorts()->size(), 10);\r\n\r\n    QSharedPointer<MetaPort> mPort = mInstance->getPorts()->value(portDefaultName);\r\n    QCOMPARE(mPort->defaultValue_, QString(\"20\"));\r\n\r\n    mPort = mInstance->getPorts()->value(defaultValueName);\r\n    QCOMPARE(mPort->upAssignments_.first()->defaultValue_, QString(\"35\"));\r\n    QVERIFY(!mPort->upAssignments_.first()->wire_);\r\n    mPort = mInstance->getPorts()->value(\"expressionTieOff\");\r\n    QCOMPARE(mPort->upAssignments_.first()->defaultValue_, QString(\"expID - 4\"));\r\n    QVERIFY(!mPort->upAssignments_.first()->wire_);\r\n    mPort = mInstance->getPorts()->value(\"n/aTieOff\");\r\n    QCOMPARE(mPort->upAssignments_.first()->defaultValue_, QString(\"abc\"));\r\n    QVERIFY(!mPort->upAssignments_.first()->wire_);\r\n    mPort = mInstance->getPorts()->value(\"numberedTieOff\");\r\n    QCOMPARE(mPort->upAssignments_.first()->defaultValue_, QString(\"12\"));\r\n    QVERIFY(!mPort->upAssignments_.first()->wire_);\r\n    mPort = mInstance->getPorts()->value(\"oneTieOff\");\r\n    QCOMPARE(mPort->upAssignments_.first()->defaultValue_, QString(\"1\"));\r\n    QVERIFY(!mPort->upAssignments_.first()->wire_);\r\n    mPort = mInstance->getPorts()->value(\"openTieOff\");\r\n    QVERIFY(mPort->upAssignments_.size() < 1);\r\n    mPort = mInstance->getPorts()->value(\"zeroTieOff\");\r\n    QCOMPARE(mPort->upAssignments_.first()->defaultValue_, QString(\"0\"));\r\n    QVERIFY(!mPort->upAssignments_.first()->wire_);\r\n    mPort = mInstance->getPorts()->value(\"tieOffOut\");\r\n    QCOMPARE(mPort->upAssignments_.first()->defaultValue_, QString(\"0\"));\r\n    QVERIFY(!mPort->upAssignments_.first()->wire_);\r\n    mPort = mInstance->getPorts()->value(\"tieOffInOut\");\r\n    QCOMPARE(mPort->upAssignments_.first()->defaultValue_, QString(\"1\"));\r\n    QVERIFY(!mPort->upAssignments_.first()->wire_);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_HDLParser::addAdhocConnection()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<AdHocConnection> tst_HDLParser::addAdhocConnection(QString const& connectionName, \r\n    QString const& sourceInstance, QString const& sourcePort, \r\n    QString const& targetInstance, QString const& targetPort)\r\n{\r\n    QSharedPointer<QList<QSharedPointer<PortReference> > > internalRefs(\r\n        new QList<QSharedPointer<PortReference> >());\r\n\r\n    QSharedPointer<QList<QSharedPointer<AdHocConnection> > > adHocConnections = design_->getAdHocConnections();\r\n    for (int i = 0; i < adHocConnections->size(); i++)\r\n    {\r\n        if (adHocConnections->value(i)->name() == connectionName)\r\n        {\r\n            internalRefs  = adHocConnections->value(i)->getInternalPortReferences();\r\n            adHocConnections->removeAt(i);\r\n            break;\r\n        }\r\n    }\r\n\r\n    QSharedPointer<PortReference> fromRef(new PortReference(sourcePort, sourceInstance));\r\n    QSharedPointer<PortReference> toRef(new PortReference(targetPort, targetInstance));\r\n    \r\n    if (internalRefs->isEmpty())\r\n    {\r\n        internalRefs->append(fromRef);        \r\n    }\r\n    internalRefs->append(toRef);\r\n\r\n    QSharedPointer<AdHocConnection> connection(new AdHocConnection(connectionName));\r\n    connection->setInternalPortReferences(internalRefs);\r\n\r\n    design_->getAdHocConnections()->append(connection);\r\n\r\n    return connection;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_HDLParser::addTieOffAdhocConnectionToInstancePort()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_HDLParser::addTieOffAdhocConnectionToInstancePort(QString const& tieOffValue,\r\n    QString const& instanceName, QString const& portName, QString const& connectionName)\r\n{\r\n    QSharedPointer<PortReference> referencedPort(new PortReference(portName, instanceName));\r\n\r\n    QSharedPointer<AdHocConnection> connection(new AdHocConnection(connectionName));\r\n    connection->setTiedValue(tieOffValue);\r\n    connection->getInternalPortReferences()->append(referencedPort);\r\n\r\n    design_->getAdHocConnections()->append(connection);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_HDLParser::testHierarchicalAdhocConnection()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_HDLParser::testHierarchicalAdhocConnection()\r\n{\r\n    addPort(\"data_from_sender\", 8, DirectionTypes::OUT, topComponent_);\r\n\r\n    VLNV senderVLNV(VLNV::COMPONENT, \"Test\", \"TestLibrary\", \"TestSender\", \"1.0\");\r\n    QSharedPointer<View> activeView = addSenderComponentToLibrary(senderVLNV, General::MASTER);\r\n    addInstanceToDesign(\"sender\", senderVLNV, activeView);\r\n\r\n    addHierAdhocConnection(\"data_from_sender\", \"sender\", \"data_out\");\r\n\r\n    QList<QSharedPointer<MetaDesign> > designs = MetaDesign::parseHierarchy\r\n        (&library_, input_, topView_);\r\n\r\n    QCOMPARE(designs.size(), 1);\r\n    QSharedPointer<MetaDesign> design = designs.first();\r\n\r\n    QCOMPARE(design->getInstances()->size(), 1);\r\n\r\n    QCOMPARE(design->getAdHocWires()->size(), 1);\r\n\r\n    QSharedPointer<MetaWire> mWire = design->getAdHocWires()->first();\r\n\r\n    QSharedPointer<MetaInstance> mInstance = design->getInstances()->last();\r\n\r\n    /*QSharedPointer<MetaPort> mPort = mInstance->getPorts()->value(\"data_out\");\r\n    QSharedPointer<MetaPortAssignment> mpa = mPort->upAssignments_.last();\r\n    QCOMPARE(mpa->wire_, mWire);\r\n\r\n    QSharedPointer<MetaPort> hierPort = design->getTopInstance()->getPorts()->first();\r\n    QCOMPARE(mpa->wire_->hierPorts_.first(), hierPort);\r\n    QSharedPointer<MetaPortAssignment> hierAssignment = hierPort->downAssignments_.first();\r\n    QCOMPARE(hierAssignment->wire_, mWire);\r\n    QCOMPARE(hierAssignment->wire_->hierPorts_.first(), hierPort);*/\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_HDLParser::addHierAdhocConnection()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_HDLParser::addHierAdhocConnection(QString const& topPort, \r\n    QString const& targetInstance, QString const& targetPort)\r\n{    \r\n    QSharedPointer<PortReference> topComponentReference(new PortReference(topPort));\r\n\r\n    QSharedPointer<PortReference> instancePortReference(new PortReference(targetPort, targetInstance));\r\n\r\n    QSharedPointer<AdHocConnection> connection(new AdHocConnection(topPort + \"_to_\" + targetPort));\r\n    connection->getExternalPortReferences()->append(topComponentReference);\r\n    connection->getInternalPortReferences()->append(instancePortReference);\r\n\r\n    design_->getAdHocConnections()->append(connection);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_HDLParser::testAdHocConnectionBetweenMultipleComponentInstances()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_HDLParser::testAdHocConnectionBetweenMultipleComponentInstances()\r\n{\r\n    VLNV senderVLNV(VLNV::COMPONENT, \"Test\", \"TestLibrary\", \"TestSender\", \"1.0\");\r\n    QSharedPointer<Component> senderComponent(new Component(senderVLNV, Document::Revision::Std14));\r\n\r\n    QSharedPointer<Port> senderPort = QSharedPointer<Port>(new Port(\"data_out\"));\r\n    senderPort->setDirection(DirectionTypes::OUT);\r\n    senderPort->setLeftBound(\"7\");\r\n    senderPort->setRightBound(\"0\");\r\n    senderComponent->getPorts()->append(senderPort);\r\n\r\n    addInterfaceToComponent(\"data_bus\", senderComponent, dataAbstractionVLNV_);\r\n    senderComponent->getBusInterface(\"data_bus\")->setInterfaceMode(General::MASTER);\r\n\r\n    mapPortToInterface(\"data_out\", \"DATA\", \"data_bus\", senderComponent);\r\n\r\n\tQSharedPointer<View> view1(new View(\"view1\"));\r\n\tsenderComponent->getViews()->append(view1);\r\n\tQSharedPointer<ComponentInstantiation> instantiation1(new ComponentInstantiation(\"instance1\"));\r\n\tview1->setComponentInstantiationRef(instantiation1->name());\r\n\tsenderComponent->getComponentInstantiations()->append(instantiation1);\r\n\r\n    library_.addComponent(senderComponent);\r\n    addInstanceToDesign(\"sender\", senderVLNV, view1);\r\n\r\n    VLNV receiverVLNV(VLNV::COMPONENT, \"Test\", \"TestLibrary\", \"TestReceiver\", \"1.0\");\r\n    QSharedPointer<Component> receiverComponent(new Component(receiverVLNV, Document::Revision::Std14));\r\n\r\n    QSharedPointer<Port> receiverPort = QSharedPointer<Port>(new Port(\"data_in\"));\r\n    receiverPort->setDirection(DirectionTypes::IN);\r\n    receiverPort->setLeftBound(\"7\");\r\n    receiverPort->setRightBound(\"0\");\r\n    receiverComponent->getPorts()->append(receiverPort);\r\n\r\n    addInterfaceToComponent(\"data_bus\", receiverComponent, dataAbstractionVLNV_);\r\n    receiverComponent->getBusInterface(\"data_bus\")->setInterfaceMode(General::SLAVE);\r\n    mapPortToInterface(\"data_in\", \"DATA\", \"data_bus\", receiverComponent);\r\n\r\n\tlibrary_.addComponent(receiverComponent);\r\n\tQSharedPointer<View> view2(new View(\"view2\"));\r\n\treceiverComponent->getViews()->append(view2);\r\n\tQSharedPointer<ComponentInstantiation> instantiation2(new ComponentInstantiation(\"instance2\"));\r\n\tview2->setComponentInstantiationRef(instantiation2->name());\r\n\treceiverComponent->getComponentInstantiations()->append(instantiation2);\r\n\r\n    addInstanceToDesign(\"receiver1\", receiverVLNV, view2);\r\n    addInstanceToDesign(\"receiver2\", receiverVLNV, view2);\r\n\r\n    QSharedPointer<AdHocConnection> multiConnection(new AdHocConnection(\"dataAdHoc\"));\r\n\r\n    QSharedPointer<PortReference> startReference(new PortReference(\"data_out\", \"sender\"));\r\n    QSharedPointer<PortReference> endReference1(new PortReference(\"data_in\", \"receiver1\"));\r\n    QSharedPointer<PortReference> endReference2(new PortReference(\"data_in\", \"receiver2\"));\r\n\r\n    multiConnection->getInternalPortReferences()->append(startReference);\r\n    multiConnection->getInternalPortReferences()->append(endReference1);\r\n    multiConnection->getInternalPortReferences()->append(endReference2);\r\n\r\n    design_->getAdHocConnections()->append(multiConnection);\r\n\r\n    QList<QSharedPointer<MetaDesign> > designs = MetaDesign::parseHierarchy\r\n        (&library_, input_, topView_);\r\n\r\n    QCOMPARE(designs.size(), 1);\r\n    QSharedPointer<MetaDesign> design = designs.first();\r\n\r\n    QCOMPARE(design->getInstances()->size(), 3);\r\n\r\n    QCOMPARE(design->getAdHocWires()->size(), 1);\r\n    QSharedPointer<MetaWire> mWire = design->getAdHocWires()->first();\r\n    mWire = design->getAdHocWires()->last();\r\n    QCOMPARE(mWire->hierPorts_.size(), 0);\r\n    QCOMPARE(mWire->bounds_.first, QString(\"7\"));\r\n    QCOMPARE(mWire->bounds_.second, QString(\"0\"));\r\n\r\n    QSharedPointer<MetaInstance> mInstance = design->getInstances()->value(\"sender\");\r\n\r\n    QSharedPointer<MetaPort> mPort = mInstance->getPorts()->value(\"data_out\");\r\n    QSharedPointer<MetaPortAssignment> mpa = mPort->upAssignments_.value(\"dataAdHoc\");\r\n    /*QCOMPARE(mpa->physicalBounds_.first, QString(\"7\"));\r\n    QCOMPARE(mpa->physicalBounds_.second, QString(\"0\"));\r\n    QCOMPARE(mpa->wire_, mWire);\r\n\r\n    mInstance = design->getInstances()->value(\"receiver1\");\r\n\r\n    mPort = mInstance->getPorts()->value(\"data_in\");\r\n    mpa = mPort->upAssignments_.value(\"dataAdHoc\");\r\n    QCOMPARE(mpa->physicalBounds_.first, QString(\"7\"));\r\n    QCOMPARE(mpa->physicalBounds_.second, QString(\"0\"));\r\n    QCOMPARE(mpa->wire_, mWire);\r\n\r\n    mInstance = design->getInstances()->value(\"receiver2\");\r\n\r\n    mPort = mInstance->getPorts()->value(\"data_in\");\r\n    mpa = mPort->upAssignments_.value(\"dataAdHoc\");\r\n    QCOMPARE(mpa->physicalBounds_.first, QString(\"7\"));\r\n    QCOMPARE(mpa->physicalBounds_.second, QString(\"0\"));\r\n    QCOMPARE(mpa->wire_, mWire);*/\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_HDLParser::testInstanceParametersAreCulled()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_HDLParser::testInstanceParametersAreCulled()\r\n{\r\n\tQSharedPointer<View> activeView(new View(\"rtl\"));\r\n\tactiveView->setComponentInstantiationRef(\"instance1\");\r\n\r\n    VLNV senderVLNV(VLNV::COMPONENT, \"Test\", \"TestLibrary\", \"TestSender\", \"1.0\");    \r\n    QSharedPointer<Component> senderComponent(new Component(senderVLNV, Document::Revision::Std14));\r\n    library_.addComponent(senderComponent);\r\n    QSharedPointer<ComponentInstance> instace = addInstanceToDesign(\"sender\", senderVLNV, activeView);\r\n\r\n    QSharedPointer<Parameter> componentParameter(new Parameter());\r\n    componentParameter->setValueId(\"parameterId2\");\r\n    componentParameter->setName(\"componentParameter\");\r\n    componentParameter->setValue(\"3\");\r\n    componentParameter->setValueResolve(\"user\");\r\n\r\n    senderComponent->getParameters()->append(componentParameter);\r\n\r\n    QSharedPointer<ModuleParameter> moduleParameter(new ModuleParameter());\r\n    moduleParameter->setValueId(\"parameterId\");\r\n    moduleParameter->setName(\"moduleParameter\");\r\n    moduleParameter->setValue(\"1\");\r\n    moduleParameter->setValueResolve(\"user\");\r\n\r\n    QSharedPointer<ComponentInstantiation> instantiation(new ComponentInstantiation(\"instance1\"));\r\n    instantiation->getModuleParameters()->append(moduleParameter);\r\n\r\n    senderComponent->getComponentInstantiations()->append(instantiation);\r\n    senderComponent->getViews()->append(activeView);\r\n    \r\n    QSharedPointer<ConfigurableElementValue> parameterOverride(new ConfigurableElementValue());\r\n    parameterOverride->setReferenceId(\"parameterId2\");\r\n    parameterOverride->setConfigurableValue(\"2\");\r\n\r\n    instace->getConfigurableElementValues()->append(parameterOverride);\r\n\r\n    QList<QSharedPointer<MetaDesign> > designs = MetaDesign::parseHierarchy\r\n        (&library_, input_, topView_);\r\n\r\n    QCOMPARE(designs.size(), 1);\r\n    QSharedPointer<MetaDesign> design = designs.first();\r\n\r\n    QCOMPARE(design->getInstances()->size(), 1);\r\n\r\n    QSharedPointer<MetaInstance> mInstance = design->getInstances()->value(\"sender\");\r\n    QCOMPARE(mInstance->getParameters()->size(), 1);\r\n    QCOMPARE(mInstance->getModuleParameters()->size(), 1);\r\n\r\n    QCOMPARE(mInstance->getParameters()->value(0)->name(), QString(\"componentParameter\"));\r\n    QCOMPARE(mInstance->getParameters()->value(0)->getValue(), QString(\"2\"));\r\n    QCOMPARE(mInstance->getModuleParameters()->value(0)->name(), QString(\"moduleParameter\"));\r\n    QCOMPARE(mInstance->getModuleParameters()->value(0)->getValue(), QString(\"1\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_HDLParser::testDesignParametersAreUtilized()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_HDLParser::testDesignParametersAreUtilized()\r\n{\r\n    QSharedPointer<View> activeView(new View(\"rtl\"));\r\n    activeView->setComponentInstantiationRef(\"instance1\");\r\n\r\n    VLNV senderVLNV(VLNV::COMPONENT, \"Test\", \"TestLibrary\", \"TestSender\", \"1.0\");    \r\n    QSharedPointer<Component> senderComponent(new Component(senderVLNV, Document::Revision::Std14));\r\n    library_.addComponent(senderComponent);\r\n    QSharedPointer<ComponentInstance> senderInstance = addInstanceToDesign(\"sender\", senderVLNV, activeView);\r\n\r\n    addParameter(\"designParameter\", \"1337\", \"designParameterId\", design_);\r\n\r\n    addParameter(\"instanceParameter\", \"1\", \"parameterId\", senderComponent);\r\n\r\n    QSharedPointer<ConfigurableElementValue> parameterOverride(new ConfigurableElementValue());\r\n    parameterOverride->setReferenceId(\"parameterId\");\r\n    parameterOverride->setConfigurableValue(\"designParameterId\");\r\n\r\n    senderInstance->getConfigurableElementValues()->append(parameterOverride);\r\n\r\n    QList<QSharedPointer<MetaDesign> > designs = MetaDesign::parseHierarchy\r\n        (&library_, input_, topView_);\r\n\r\n    QCOMPARE(designs.size(), 1);\r\n    QSharedPointer<MetaDesign> design = designs.first();\r\n\r\n    QCOMPARE(design->getInstances()->size(), 1);\r\n\r\n    QSharedPointer<MetaInstance> mInstance = design->getInstances()->value(\"sender\");\r\n    QCOMPARE(mInstance->getParameters()->size(), 1);\r\n\r\n    QCOMPARE(mInstance->getParameters()->value(0)->name(), QString(\"instanceParameter\"));\r\n    QCOMPARE(mInstance->getParameters()->value(0)->getValue(), QString(\"1337\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_HDLParser::testTopComponentParametersAreUtilized()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_HDLParser::testTopComponentParametersAreUtilized()\r\n{\r\n    QSharedPointer<View> activeView(new View(\"rtl\"));\r\n    activeView->setComponentInstantiationRef(\"instance1\");\r\n\r\n    VLNV senderVLNV(VLNV::COMPONENT, \"Test\", \"TestLibrary\", \"TestSender\", \"1.0\");    \r\n    QSharedPointer<Component> senderComponent(new Component(senderVLNV, Document::Revision::Std14));\r\n    library_.addComponent(senderComponent);\r\n    QSharedPointer<ComponentInstance> senderInstance = addInstanceToDesign(\"sender\", senderVLNV, activeView);\r\n\r\n    addParameter(\"componentParameter\", \"55\", \"componentParameterId\", topComponent_);\r\n\r\n    QSharedPointer<ConfigurableElementValue> designParameterOverride(new ConfigurableElementValue());\r\n    designParameterOverride->setReferenceId(\"designParameterId\");\r\n    designParameterOverride->setConfigurableValue(\"componentParameterId\");\r\n\r\n    topComponent_->getModel()->getDesignInstantiations()->first()->getDesignReference()->\r\n        getConfigurableElementValues()->append(designParameterOverride);\r\n\r\n    addParameter(\"designParameter\", \"1337\", \"designParameterId\", design_);\r\n\r\n    addParameter(\"instanceParameter\", \"1\", \"parameterId\", senderComponent);\r\n\r\n    QSharedPointer<ConfigurableElementValue> componentParameterOverride(new ConfigurableElementValue());\r\n    componentParameterOverride->setReferenceId(\"parameterId\");\r\n    componentParameterOverride->setConfigurableValue(\"designParameterId\");\r\n\r\n    senderInstance->getConfigurableElementValues()->append(componentParameterOverride);\r\n\r\n    QList<QSharedPointer<MetaDesign> > designs = MetaDesign::parseHierarchy\r\n        (&library_, input_, topView_);\r\n\r\n    QCOMPARE(designs.size(), 1);\r\n    QSharedPointer<MetaDesign> design = designs.first();\r\n\r\n    QCOMPARE(design->getInstances()->size(), 1);\r\n\r\n    QSharedPointer<MetaInstance> mInstance = design->getInstances()->value(\"sender\");\r\n    QCOMPARE(mInstance->getParameters()->size(), 1);\r\n\r\n    QCOMPARE(mInstance->getParameters()->value(0)->name(), QString(\"instanceParameter\"));\r\n    QCOMPARE(mInstance->getParameters()->value(0)->getValue(), QString(\"55\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_HDLParser::testFlatComponent()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_HDLParser::testFlatComponent()\r\n{\r\n    addPort(\"clk\", 1, DirectionTypes::IN, topComponent_);\r\n    addPort(\"rst_n\", 1, DirectionTypes::IN, topComponent_);\r\n    addPort(\"dataOut\", 8, DirectionTypes::OUT, topComponent_);\r\n    addPort(\"dataIn\", 8, DirectionTypes::IN, topComponent_);\r\n    addModuleParameter(\"dataWidth\", \"8\", \"firstParameter\", topComponent_);\r\n    addModuleParameter(\"freq\", \"100000\", \"secondParameter\", topComponent_);\r\n\r\n    MessagePasser messages;\r\n    QSharedPointer<MetaComponent> flatComponent =\r\n        QSharedPointer<MetaComponent>(new MetaComponent(&messages, topComponent_, topView_));\r\n    flatComponent->formatComponent();\r\n\r\n    QCOMPARE(flatComponent->getModuleParameters()->size(), 2);\r\n    QCOMPARE(flatComponent->getModuleParameters()->value(0)->name(), QString(\"dataWidth\"));\r\n    QCOMPARE(flatComponent->getModuleParameters()->value(0)->getValue(), QString(\"8\"));\r\n    QCOMPARE(flatComponent->getModuleParameters()->value(1)->name(), QString(\"freq\"));\r\n    QCOMPARE(flatComponent->getModuleParameters()->value(1)->getValue(), QString(\"100000\"));\r\n\r\n    QCOMPARE(flatComponent->getPorts()->size(), 4);\r\n    QCOMPARE(flatComponent->getPorts()->value(\"clk\")->port_->getDirection(), DirectionTypes::IN);\r\n\r\n    QCOMPARE(flatComponent->getPorts()->value(\"dataIn\")->port_->getDirection(), DirectionTypes::IN);\r\n    QCOMPARE(flatComponent->getPorts()->value(\"dataIn\")->vectorBounds_.first, QString(\"7\"));\r\n    QCOMPARE(flatComponent->getPorts()->value(\"dataIn\")->vectorBounds_.second, QString(\"0\"));\r\n\r\n    QCOMPARE(flatComponent->getPorts()->value(\"rst_n\")->port_->getDirection(), DirectionTypes::IN);\r\n\r\n    QCOMPARE(flatComponent->getPorts()->value(\"dataOut\")->port_->getDirection(), DirectionTypes::OUT);\r\n    QCOMPARE(flatComponent->getPorts()->value(\"dataOut\")->vectorBounds_.first, QString(\"7\"));\r\n    QCOMPARE(flatComponent->getPorts()->value(\"dataOut\")->vectorBounds_.second, QString(\"0\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_HDLParser::testFlatComponentExpressions()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_HDLParser::testFlatComponentExpressions()\r\n{\r\n    addModuleParameter(\"module\", \"10\", \"firstParameter\", topComponent_);\r\n    addModuleParameter(\"freq\", \"firstParameter*3.14\", \"secondParameter\", topComponent_);\r\n\r\n    QSharedPointer<Port> port = QSharedPointer<Port>(new Port(\"clk\"));\r\n    port->setDirection(DirectionTypes::IN);\r\n    port->setLeftBound(\"secondParameter*2\");\r\n    port->setRightBound(\"2+5\");\r\n    topComponent_->getPorts()->append(port);\r\n\r\n    MessagePasser messages;\r\n    QSharedPointer<MetaComponent> flatComponent =\r\n        QSharedPointer<MetaComponent>(new MetaComponent(&messages, topComponent_, topView_));\r\n    flatComponent->formatComponent();\r\n\r\n    QCOMPARE(flatComponent->getModuleParameters()->size(), 2);\r\n    QCOMPARE(flatComponent->getModuleParameters()->value(0)->name(), QString(\"module\"));\r\n    QCOMPARE(flatComponent->getModuleParameters()->value(0)->getValue(), QString(\"10\"));\r\n    QCOMPARE(flatComponent->getModuleParameters()->value(1)->name(), QString(\"freq\"));\r\n    QCOMPARE(flatComponent->getModuleParameters()->value(1)->getValue(), QString(\"module*3.14\"));\r\n\r\n    QCOMPARE(flatComponent->getPorts()->size(), 1);\r\n    QCOMPARE(flatComponent->getPorts()->value(\"clk\")->port_->getDirection(), DirectionTypes::IN);\r\n    QCOMPARE(flatComponent->getPorts()->value(\"clk\")->vectorBounds_.first, QString(\"freq*2\"));\r\n    QCOMPARE(flatComponent->getPorts()->value(\"clk\")->vectorBounds_.second, QString(\"2+5\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_HDLParser::testParameterSorting()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_HDLParser::testParameterSorting()\r\n{\r\n    QSharedPointer<ModuleParameter> moduleParameterFirst(new ModuleParameter());\r\n    moduleParameterFirst->setName(\"moduleParameterFirst\");\r\n    moduleParameterFirst->setValue(\"1\");\r\n    moduleParameterFirst->setValueId(\"firstParameter\");\r\n    moduleParameterFirst->setValueResolve(\"user\");\r\n\r\n    QSharedPointer<ModuleParameter> moduleParameterSecond(new ModuleParameter());\r\n    moduleParameterSecond->setName(\"moduleParameterSecond\");\r\n    moduleParameterSecond->setValue(\"firstParameter\");\r\n    moduleParameterSecond->setValueId(\"secondParameter\");\r\n    moduleParameterSecond->setValueResolve(\"user\");\r\n\r\n    QSharedPointer<ModuleParameter> moduleParameterThird(new ModuleParameter());\r\n    moduleParameterThird->setName(\"moduleParameterThird\");\r\n    moduleParameterThird->setValue(\"secondParameter\");\r\n    moduleParameterThird->setValueId(\"thirdParameter\");\r\n    moduleParameterThird->setValueResolve(\"user\");\r\n\r\n    QSharedPointer<QList<QSharedPointer<Parameter> > > parameters(new  QList<QSharedPointer<Parameter> >);\r\n    parameters->append(moduleParameterThird);\r\n    parameters->append(moduleParameterFirst);\r\n    parameters->append(moduleParameterSecond);\r\n\r\n    MetaComponent::sortParameters(parameters);\r\n\r\n    QCOMPARE(parameters->size(), 3);\r\n\r\n    QCOMPARE(parameters->at(0)->name(), QString(\"moduleParameterFirst\"));\r\n    QCOMPARE(parameters->at(0)->getValue(), QString(\"1\"));\r\n    QCOMPARE(parameters->at(1)->name(), QString(\"moduleParameterSecond\"));\r\n    QCOMPARE(parameters->at(1)->getValue(), QString(\"firstParameter\"));\r\n    QCOMPARE(parameters->at(2)->name(), QString(\"moduleParameterThird\"));\r\n    QCOMPARE(parameters->at(2)->getValue(), QString(\"secondParameter\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_HDLParser::testParameterSorting2()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_HDLParser::testParameterSorting2()\r\n{\r\n    QSharedPointer<ModuleParameter> moduleParameterFirst(new ModuleParameter());\r\n    moduleParameterFirst->setName(\"moduleParameterFirst\");\r\n    moduleParameterFirst->setValue(\"secondParameter + fourthParameter\");\r\n    moduleParameterFirst->setValueId(\"firstParameter\");\r\n    moduleParameterFirst->setValueResolve(\"user\");\r\n\r\n    QSharedPointer<ModuleParameter> moduleParameterSecond(new ModuleParameter());\r\n    moduleParameterSecond->setName(\"moduleParameterSecond\");\r\n    moduleParameterSecond->setValue(\"1\");\r\n    moduleParameterSecond->setValueId(\"secondParameter\");\r\n    moduleParameterSecond->setValueResolve(\"user\");\r\n\r\n    QSharedPointer<ModuleParameter> moduleParameterThird(new ModuleParameter());\r\n    moduleParameterThird->setName(\"moduleParameterThird\");\r\n    moduleParameterThird->setValue(\"firstParameter\");\r\n    moduleParameterThird->setValueId(\"thirdParameter\");\r\n    moduleParameterThird->setValueResolve(\"user\");\r\n\r\n    QSharedPointer<ModuleParameter> moduleParameterFourth(new ModuleParameter());\r\n    moduleParameterFourth->setName(\"moduleParameterFourth\");\r\n    moduleParameterFourth->setValue(\"4\");\r\n    moduleParameterFourth->setValueId(\"fourthParameter\");\r\n    moduleParameterFourth->setValueResolve(\"user\");\r\n\r\n    QSharedPointer<QList<QSharedPointer<Parameter> > > parameters(new  QList<QSharedPointer<Parameter> >);\r\n    parameters->append(moduleParameterFirst);\r\n    parameters->append(moduleParameterSecond);\r\n    parameters->append(moduleParameterThird);\r\n    parameters->append(moduleParameterFourth);\r\n\r\n    MetaComponent::sortParameters(parameters);\r\n\r\n    QCOMPARE(parameters->size(), 4);\r\n\r\n    QCOMPARE(parameters->at(0)->name(), QString(\"moduleParameterFourth\"));\r\n    QCOMPARE(parameters->at(0)->getValue(), QString(\"4\"));\r\n    QCOMPARE(parameters->at(1)->name(), QString(\"moduleParameterSecond\"));\r\n    QCOMPARE(parameters->at(1)->getValue(), QString(\"1\"));\r\n    QCOMPARE(parameters->at(2)->name(), QString(\"moduleParameterFirst\"));\r\n    QCOMPARE(parameters->at(2)->getValue(), QString(\"secondParameter + fourthParameter\"));\r\n    QCOMPARE(parameters->at(3)->name(), QString(\"moduleParameterThird\"));\r\n    QCOMPARE(parameters->at(3)->getValue(), QString(\"firstParameter\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_HDLParser::testParameterSorting3()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_HDLParser::testParameterSorting3()\r\n{\r\n    QSharedPointer<ModuleParameter> moduleParameterFirst(new ModuleParameter());\r\n    moduleParameterFirst->setName(\"moduleParameterFirst\");\r\n    moduleParameterFirst->setValue(\"1\");\r\n    moduleParameterFirst->setValueId(\"firstParameter\");\r\n    moduleParameterFirst->setValueResolve(\"user\");\r\n\r\n    QSharedPointer<ModuleParameter> moduleParameterSecond(new ModuleParameter());\r\n    moduleParameterSecond->setName(\"moduleParameterSecond\");\r\n    moduleParameterSecond->setValue(\"55\");\r\n    moduleParameterSecond->setValueId(\"secondParameter\");\r\n    moduleParameterSecond->setValueResolve(\"user\");\r\n\r\n    QSharedPointer<ModuleParameter> moduleParameterThird(new ModuleParameter());\r\n    moduleParameterThird->setName(\"moduleParameterThird\");\r\n    moduleParameterThird->setValue(\"fifthParameter + secondParameter\");\r\n    moduleParameterThird->setValueId(\"thirdParameter\");\r\n    moduleParameterThird->setValueResolve(\"user\");\r\n\r\n    QSharedPointer<ModuleParameter> moduleParameterFourth(new ModuleParameter());\r\n    moduleParameterFourth->setName(\"moduleParameterFourth\");\r\n    moduleParameterFourth->setValue(\"12\");\r\n    moduleParameterFourth->setValueId(\"fourthParameter\");\r\n    moduleParameterFourth->setValueResolve(\"user\");\r\n\r\n    QSharedPointer<ModuleParameter> moduleParameterFifth(new ModuleParameter());\r\n    moduleParameterFifth->setName(\"moduleParameterFifth\");\r\n    moduleParameterFifth->setValue(\"fourthParameter - firstParameter\");\r\n    moduleParameterFifth->setValueId(\"fifthParameter\");\r\n    moduleParameterFifth->setValueResolve(\"user\");\r\n    \r\n    QSharedPointer<QList<QSharedPointer<Parameter> > > parameters(new  QList<QSharedPointer<Parameter> >);\r\n    parameters->append(moduleParameterFirst);\r\n    parameters->append(moduleParameterSecond);\r\n    parameters->append(moduleParameterThird);\r\n    parameters->append(moduleParameterFourth);\r\n    parameters->append(moduleParameterFifth);\r\n    \r\n    MetaComponent::sortParameters(parameters);\r\n\r\n    QCOMPARE(parameters->size(), 5);\r\n\r\n    QCOMPARE(parameters->at(0)->name(), QString(\"moduleParameterFirst\"));\r\n    QCOMPARE(parameters->at(0)->getValue(), QString(\"1\"));\r\n    QCOMPARE(parameters->at(1)->name(), QString(\"moduleParameterFourth\"));\r\n    QCOMPARE(parameters->at(1)->getValue(), QString(\"12\"));\r\n    QCOMPARE(parameters->at(2)->name(), QString(\"moduleParameterFifth\"));\r\n    QCOMPARE(parameters->at(2)->getValue(), QString(\"fourthParameter - firstParameter\"));\r\n    QCOMPARE(parameters->at(3)->name(), QString(\"moduleParameterSecond\"));\r\n    QCOMPARE(parameters->at(3)->getValue(), QString(\"55\"));\r\n    QCOMPARE(parameters->at(4)->name(), QString(\"moduleParameterThird\"));\r\n    QCOMPARE(parameters->at(4)->getValue(), QString(\"fifthParameter + secondParameter\"));\r\n}\r\n\r\nQTEST_APPLESS_MAIN(tst_HDLParser)\r\n\r\n#include \"tst_HDLParser.moc\"\r\n"
  },
  {
    "path": "tests/Plugins/VerilogImport/tst_HDLParser.pri",
    "content": "# ----------------------------------------------------\r\n# This file is generated by the Qt Visual Studio Tools.\r\n# ------------------------------------------------------\r\n\r\n# This is a reminder that you are using a generated .pro file.\r\n# Remove it when you are finished editing this file.\r\nmessage(\"You are running qmake on a generated .pro file. This may not work!\")\r\n\r\n\r\nHEADERS += ../../../IPXACTmodels/utilities/ComponentSearch.h \\\r\n    ../../../Plugins/common/HDLParser/HDLParserCommon.h \\\r\n    ../../../Plugins/common/HDLParser/MetaComponent.h \\\r\n    ../../../Plugins/common/HDLParser/MetaDesign.h \\\r\n    ../../../Plugins/common/HDLParser/MetaInstance.h \\\r\n    ../../../Plugins/VerilogGenerator/ModelParameterVerilogWriter/ModelParameterVerilogWriter.h \\\r\n    ../../../Plugins/common/PortSorter/PortSorter.h \\\r\n    ../../../IPXACTmodels/utilities/Search.h \\\r\n    ../../../editors/common/TopComponentParameterFinder.h \\\r\n    ../../MockObjects/LibraryMock.h \\\r\n    ../../../Plugins/PluginSystem/GeneratorPlugin/MessagePasser.h\r\nSOURCES += ../../../IPXACTmodels/utilities/ComponentSearch.cpp \\\r\n    ../../MockObjects/LibraryMock.cpp \\\r\n    ../../../Plugins/PluginSystem/GeneratorPlugin/MessagePasser.cpp \\\r\n    ../../../Plugins/common/HDLParser/MetaComponent.cpp \\\r\n    ../../../Plugins/common/HDLParser/MetaDesign.cpp \\\r\n    ../../../Plugins/common/HDLParser/MetaInstance.cpp \\\r\n    ../../../editors/common/TopComponentParameterFinder.cpp \\\r\n    ./tst_HDLParser.cpp\r\n"
  },
  {
    "path": "tests/Plugins/VerilogImport/tst_HDLParser.pro",
    "content": "#-----------------------------------------------------------------------------\r\n# File: unittest.pro\r\n#-----------------------------------------------------------------------------\r\n# Project: Kactus2\r\n# Author: Janne Virtanen\r\n# Date: 31.8.2016\r\n#\r\n# Description:\r\n# Qt project file for running unit tests for HDL Parser.\r\n#-----------------------------------------------------------------------------\r\n\r\nTEMPLATE = app\r\n\r\nTARGET = tst_HDLParser\r\n\r\nQT += core xml testlib\r\nCONFIG += c++11 testcase console\r\n\r\nwin32:CONFIG(release, debug|release) {\r\n    LIBS += -L$$PWD/../../../executable/ -lIPXACTmodels\r\n    LIBS += -L$$PWD/../../../executable/ -lKactusAPI\r\n    DESTDIR = ./release\r\n}\r\nelse:win32:CONFIG(debug, debug|release) {\r\n    LIBS += -L$$PWD/../../../executable/ -lIPXACTmodelsd\r\n    LIBS += -L$$PWD/../../../executable/ -lKactusAPId\r\n    DESTDIR = ./debug\r\n}\r\nelse:unix {\r\n    LIBS += -L$$PWD/../../../executable/ -lIPXACTmodels\r\n    LIBS += -L$$PWD/../../../executable/ -lKactusAPI\r\n    DESTDIR = ./release\r\n}\r\n\r\nINCLUDEPATH += $$PWD/../../../\r\nINCLUDEPATH += $$PWD/../../../executable\r\nINCLUDEPATH += $$PWD/../../../executable/Plugins\r\nINCLUDEPATH += $$PWD/../../../KactusAPI/include\r\nINCLUDEPATH += $$DESTDIR\r\n\r\nDEPENDPATH += $$PWD/../../../\r\nDEPENDPATH += $$PWD/../../../executable\r\nDEPENDPATH += $$PWD/../../../executable/Plugins\r\nDEPENDPATH += .\r\n\r\nOBJECTS_DIR += $$DESTDIR\r\n\r\nMOC_DIR += ./generatedFiles\r\nUI_DIR += ./generatedFiles\r\nRCC_DIR += ./generatedFiles\r\ninclude(tst_HDLParser.pri)\r\n"
  },
  {
    "path": "tests/Plugins/VerilogImport/tst_VerilogImporter.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: tst_VerilogImporter.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Esko Pekkarinen\r\n// Date: 23.09.2014\r\n//\r\n// Description:\r\n// Unit test for class VerilogImporter.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include <QtTest>\r\n#include <QSharedPointer>\r\n#include <QTextCursor>\r\n#include <QPlainTextEdit>\r\n\r\n#include <IPXACTmodels/Component/Component.h>\r\n#include <IPXACTmodels/Component/Model.h>\r\n\r\n#include <Plugins/VerilogImport/VerilogImporter.h>\r\n#include <Plugins/VerilogImport/VerilogSyntax.h>\r\n#include <ImportColors.h>\r\n#include <common/NameGenerationPolicy.h>\r\n\r\n#include <IPXactSystemVerilogParser.h>\r\n#include <ComponentParameterFinder.h>\r\n\r\n#include <ImportHighlighter.h>\r\n\r\nclass tst_VerilogImporter : public QObject\r\n{\r\n    Q_OBJECT\r\n\r\npublic:\r\n    tst_VerilogImporter();\r\n\r\nprivate slots:\r\n    void init();\r\n\r\n    //! Test cases:\r\n    void testFileTypes();\r\n\r\n    void testNothingIsParsedFromMalformedInput();\r\n    void testNothingIsParsedFromMalformedInput_data();\r\n\r\n    void testPortIsHighlighted();\r\n    void testPortIsHighlighted_data();\r\n\r\n    void testParameterIsHighlighted();\r\n    void testParameterIsHighlighted_data();\r\n\r\n    void testModuleIsHighlighted();\r\n    void testModuleIsHighlighted_data();\r\n\r\n    void testParameterInPortDeclaration();\r\n    void testParameterInPortDeclaration_data();\r\n\r\n    void testParameterInParameterDeclaration();\r\n\r\n    void testParameterInParameterArray();\r\n    void testParameterInParameterBitWidth();\r\n\r\n    void testMacroInParameterArray();\r\n    void testMacroInParameterBitWidth();\r\n    void testMacroInParameterValue();\r\n\r\n    void testSemicolonInComments(); //<! Issue #203.\r\n    void testAfterAssignComments();\r\n    void testAfterAssignCommentsSemicolon();\r\n    void testMultiLineComments();\r\n\r\n    void testParameterNotFoundInFileIsRemoved();\r\n    void testExistingModelParameterIdDoesNotChange();\r\n    void testExistingParameterIsUpdated();\r\n\r\n    void testExistingPortIsSetAsPhantom();\r\n    void testExistingPortIsOverriden();\r\n\r\n    void testModelNameAndEnvironmentIsImportedToView();\r\n    void testModelNameAndEnvironmentIsImportedToView_data();\r\n\r\n    void testComponentInstantiationAndViewExistsAfterImport();\r\n\r\n    void testMultipleModelsInOneFile();\r\n    void testMultipleModelsInOneFile_data();\r\n\r\nprivate:\r\n\r\n    QString getModuleDeclaration(QString const& input, int const& moduleNumber = 0);\r\n\r\n    void runParser(QString const& input, QString const& componentDeclaration = \"\");\r\n\r\n    void verifyNotHighlightedBeforeDeclaration(int declarationStartIndex, QColor const& highlightColor);\r\n\r\n    void verifyDeclarationIsHighlighted(const int declarationStartIndex, \r\n        const int declarationLength, QColor const& expectedHighlight) const;\r\n\r\n    void verifyNotHighlightedAfterDeclartion(const int declarationStartIndex, \r\n        const int declarationLength, QColor const& highlightColor) const;\r\n\r\n    void verifySectionFontColorIs(int startIndex, int endIndex, QColor const& expectedFontColor);\r\n     \r\n    QString parameterUuid() const;\r\n\r\n\tQSharedPointer<Component> importComponent_;\r\n\r\n    QPlainTextEdit displayEditor_;\r\n\r\n    ImportHighlighter* highlighter_;\r\n\r\n    VerilogImporter importer_;\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_VerilogImporter::tst_VerilogImporter()\r\n//-----------------------------------------------------------------------------\r\ntst_VerilogImporter::tst_VerilogImporter(): importComponent_(0), displayEditor_(), \r\n    highlighter_(new ImportHighlighter(&displayEditor_, this))\r\n{\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_VerilogImporter::init()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_VerilogImporter::init()\r\n{\r\n    importComponent_ = QSharedPointer<Component>(new Component(VLNV(), Document::Revision::Std14));\r\n    importer_.setHighlighter(highlighter_);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_VerilogImporter::testFileTypes()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_VerilogImporter::testFileTypes()\r\n{\r\n    VerilogImporter importer;\r\n\r\n    QStringList supportedFileTypes = importer.getSupportedFileTypes();\r\n\r\n    QVERIFY(supportedFileTypes.contains(\"verilogSource\"));\r\n    QVERIFY(supportedFileTypes.contains(\"verilogSource-95\"));\r\n    QVERIFY(supportedFileTypes.contains(\"verilogSource-2001\"));\r\n    QVERIFY(supportedFileTypes.contains(\"systemVerilogSource\"));\r\n\r\n    QCOMPARE(supportedFileTypes.count(), 4);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_VerilogImporter::testNothingIsParsedFromMalformedInput()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_VerilogImporter::testNothingIsParsedFromMalformedInput()\r\n{\r\n    QFETCH(QString, input);\r\n\r\n    runParser(input);\r\n\r\n\tQCOMPARE(importComponent_->getPorts()->size(), 0);\r\n\tQCOMPARE(importComponent_->getModel()->getComponentInstantiations()->count(), 0);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_VerilogImporter::testNothingIsParsedFromMalformedInput_data()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_VerilogImporter::testNothingIsParsedFromMalformedInput_data()\r\n{\r\n    QTest::addColumn<QString>(\"input\");\r\n    QTest::addColumn<int>(\"moduleNumber\");\r\n\r\n    QTest::newRow(\"empty input\") << \"\";\r\n\r\n    QTest::newRow(\"empty module name\") <<\r\n        \"module (input clk);\\n\"\r\n        \"endmodule\";\r\n\r\n    QTest::newRow(\"no module ending\") <<\r\n        \"module broken(input clk);\\n\";\r\n    \r\n    QTest::newRow(\"Commented out module\") <<\r\n        \"//module test(input clk);\\n\"\r\n        \"//endmodule\\n\";\r\n\r\n\t// TODO: Make work!\r\n    /*QTest::newRow(\"No semicolon after ports\") <<\r\n        \"module test (\\n\"\r\n        \"    input clk,\\n\"\r\n        \"    input rst\\n\"\r\n        \") // Missing semicolon.\\n\"\r\n        \"endmodule\";*/\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_VerilogImporter::getModuleDeclaration()\r\n//-----------------------------------------------------------------------------\r\nQString tst_VerilogImporter::getModuleDeclaration(QString const& input, int const& moduleNumber /* = 0 */)\r\n{\r\n    QStringList fileComponents = importer_.getFileComponents(input);\r\n    return fileComponents.at(moduleNumber);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_VerilogImporter::runParser()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_VerilogImporter::runParser(QString const& input, QString const& componentDeclaration /* = \"\" */)\r\n{\r\n    displayEditor_.setPlainText(input);\r\n\r\n    QSharedPointer<ParameterFinder> finder(new ComponentParameterFinder(importComponent_));\r\n    QSharedPointer<ExpressionParser> expressionParser(new IPXactSystemVerilogParser(finder));\r\n\r\n    importer_.setExpressionParser(expressionParser);\r\n\r\n    QString importedModule = componentDeclaration;\r\n    if (importedModule.isEmpty())\r\n    {\r\n        importedModule = input;\r\n    }\r\n\r\n    importer_.import(input, importedModule, importComponent_);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_VerilogImporter::testPortHighlight()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_VerilogImporter::testPortIsHighlighted()\r\n{\r\n    QFETCH(QString, fileContent);\r\n    QFETCH(QString, portDeclaration);\r\n\r\n    runParser(fileContent);\r\n\r\n    QVERIFY2(importComponent_->getPorts()->size() != 0, \"No ports parsed from input.\");\r\n\r\n    int begin = fileContent.indexOf(portDeclaration);\r\n    \r\n    verifyNotHighlightedBeforeDeclaration(begin, ImportColors::PORT);\r\n    verifyDeclarationIsHighlighted(begin, portDeclaration.length(), ImportColors::PORT);\r\n    verifyNotHighlightedAfterDeclartion(begin, portDeclaration.length(), ImportColors::PORT);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_VerilogImporter::testPortHighlight()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_VerilogImporter::testPortIsHighlighted_data()\r\n{\r\n    QTest::addColumn<QString>(\"fileContent\");\r\n    QTest::addColumn<QString>(\"portDeclaration\");\r\n\r\n    QTest::newRow(\"Simplest possible port declaration\") <<\r\n        \"module test (\\n\"\r\n        \"        input clk\\n\"\r\n        \"   );\\n\"\r\n        \"endmodule\"\r\n        << \"input clk\";   \r\n\r\n    QTest::newRow(\"Port declaration with description\") <<\r\n        \"module test (\\n\"\r\n        \"        input clk // Clk from top\\n\"\r\n        \"   );\\n\"\r\n        \"endmodule\"\r\n        << \"input clk // Clk from top\";\r\n    \r\n    QTest::newRow(\"Port declaration followed by another port\") <<\r\n        \"module TEST(\\n\"\r\n        \"        input clk, // Clk from top\\n\"\r\n        \"        input enable\\n\"\r\n        \"   );\\n\"\r\n        \"endmodule\"\r\n        << \"input clk, // Clk from top\";\r\n    \r\n    QTest::newRow(\"Port declaration with multiple ports\") <<\r\n        \"module test (\\n\"\r\n        \"        input clk, enable //One bit ports\\n\"\r\n        \"   );\\n\"\r\n        \"endmodule\"\r\n        << \"input clk, enable //One bit ports\";\r\n    \r\n    QTest::newRow(\"Direction, type and name on separate lines\") << \r\n        \"module test (input\\n\"\r\n        \"reg\\n\"\r\n        \"clk // Clk from top.\\n\"\r\n        \");\\n\"\r\n        \"endmodule;\"\r\n        << \r\n        \"input\\n\"\r\n        \"reg\\n\"\r\n        \"clk // Clk from top.\";\r\n    \r\n    QTest::newRow(\"Double comment line\") << \r\n        \"module test (\\n\"\r\n        \"    input clk,\\n\"\r\n        \"    // first comment.\\n\"\r\n        \"    //second comment.\\n\"\r\n        \"    // third comment.\\n\"\r\n        \"    input rst_n\\n\"\r\n        \"    );\\n\"\r\n        \"endmodule;\"\r\n        << \r\n        \"input clk,\";\r\n\r\n    QTest::newRow(\"Conditional port\") << \r\n        \"module test (\\n\"\r\n        \"    input clk\\n\"\r\n        \"    `ifdef EXTERNAL_RESET\\n\"\r\n        \"    ,input rst_n\\n\"\r\n        \"    `endif\\n\"\r\n        \"    );\\n\"\r\n        \"endmodule;\"\r\n        << \r\n        \"input clk\";\r\n\r\n    QTest::newRow(\"Conditional port with comments\") << \r\n        \"module test (\\n\"\r\n        \"    input clk // clock description\\n\"\r\n        \"    `ifdef EXTERNAL_RESET\\n\"\r\n        \"    ,input rst_n\\n\"\r\n        \"    `endif\\n\"\r\n        \"    );\\n\"\r\n        \"endmodule;\"\r\n        << \r\n        \"input clk // clock description\";\r\n\r\n    QTest::newRow(\"Simplest possible 1995-style port declaration\") <<\r\n        \"module test (clk);\"\r\n        \"   input clk;\\n\"\r\n        \"endmodule\"\r\n        << \"input clk;\";\r\n\r\n    QTest::newRow(\"1995-style port declaration followed by another port\") <<\r\n        \"module TEST(clk, enable);\\n\"\r\n        \"        input clk; // Clk from top\\n\"\r\n        \"        input enable;\\n\"\r\n        \"endmodule\"\r\n        << \"input clk; // Clk from top\";\r\n\r\n\r\n    QTest::newRow(\"1995-stype port declarations with multiple ports\") <<\r\n        \"module test (clk, enable);\\n\"\r\n        \"        input clk, enable; //One bit ports\\n\"\r\n        \"endmodule\"\r\n        << \"input clk, enable; //One bit ports\";\r\n\r\n    QTest::newRow(\"1995-stype port with direction and name on separate lines\") << \r\n        \"module test (clk);\\n\"\r\n        \"input\\n\"        \r\n        \"clk ; // Clk from top.\\n\"\r\n        \"endmodule;\"\r\n        << \r\n        \"input\\n\"        \r\n        \"clk ; // Clk from top.\";\r\n        \r\n    QTest::newRow(\"1995-style ports with double comment line\") << \r\n        \"module test (clk, rst_n); \\n\"\r\n        \"    input clk;\\n\"\r\n        \"    // first comment.\\n\"\r\n        \"    //second comment.\\n\"\r\n        \"    // third comment.\\n\"\r\n        \"    input rst_n\\n\"\r\n        \"\\n\"\r\n        \"endmodule;\"\r\n        << \r\n        \"input clk;\";\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_VerilogImporter::verifyNotHighlightedBeforeDeclaration()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_VerilogImporter::verifyNotHighlightedBeforeDeclaration(int declarationStartIndex, \r\n    QColor const& highlightColor)\r\n{\r\n    QTextCursor cursor = displayEditor_.textCursor();\r\n    cursor.setPosition(declarationStartIndex);\r\n\r\n    if (cursor.atBlockStart())\r\n    {\r\n        cursor.setPosition(declarationStartIndex - 1);\r\n    }\r\n\r\n    QColor appliedColor = cursor.charFormat().background().color();\r\n\r\n    QVERIFY2(appliedColor != highlightColor, \"Highlight applied before declaration.\");\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_VerilogImporter::verifyDeclarationIsHighlighed()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_VerilogImporter::verifyDeclarationIsHighlighted(const int declarationStartIndex, \r\n    const int declarationLength, QColor const& expectedHighlight) const\r\n{\r\n    QTextCursor cursor = displayEditor_.textCursor();\r\n\r\n    for (int i = 1; i <= declarationLength; i++)\r\n    {\r\n        cursor.setPosition(declarationStartIndex + i);\r\n\r\n        QColor appliedColor = cursor.charFormat().background().color();\r\n\r\n        if (appliedColor != expectedHighlight)\r\n        {\r\n            QString correctlyHighligted(displayEditor_.toPlainText().mid(declarationStartIndex, i - 1));\r\n            QString errorMessage(\"Highlight ended after '\" + correctlyHighligted + \"'\");\r\n\r\n            QFAIL(errorMessage.toLocal8Bit());           \r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_VerilogImporter::verifyNotHighlightedAfterDeclartion()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_VerilogImporter::verifyNotHighlightedAfterDeclartion(const int declarationStartIndex, \r\n    const int declarationLength, QColor const& highlightColor) const\r\n{\r\n    QTextCursor cursor = displayEditor_.textCursor();\r\n    cursor.setPosition(declarationStartIndex + declarationLength + 1);\r\n\r\n    QColor appliedColor = cursor.charFormat().background().color();\r\n\r\n    QVERIFY2(appliedColor != highlightColor, \"Highlight applied after declaration.\");\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_VerilogImporter::testParameterIsHighlighted()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_VerilogImporter::testParameterIsHighlighted()\r\n{\r\n    QFETCH(QString, fileContent);\r\n    QFETCH(QString, parameterDeclaration);\r\n\r\n    runParser(fileContent);\r\n\r\n\tQSharedPointer<ComponentInstantiation> importComponentInstantiation =\r\n\t\timportComponent_->getModel()->getComponentInstantiations()->first();\r\n\r\n    QVERIFY2(importComponentInstantiation->getModuleParameters()->count() != 0, \"No parameters parsed from input.\");\r\n\r\n    int begin = fileContent.indexOf(parameterDeclaration);\r\n\r\n    verifyNotHighlightedBeforeDeclaration(begin, ImportColors::MODELPARAMETER);\r\n    verifyDeclarationIsHighlighted(begin, parameterDeclaration.length(), ImportColors::MODELPARAMETER);\r\n    verifyNotHighlightedAfterDeclartion(begin, parameterDeclaration.length(), ImportColors::MODELPARAMETER);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_VerilogImporter::testParameterIsHighlighted_data()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_VerilogImporter::testParameterIsHighlighted_data()\r\n{\r\n    QTest::addColumn<QString>(\"fileContent\");\r\n    QTest::addColumn<QString>(\"parameterDeclaration\");\r\n\r\n    QTest::newRow(\"Simplest possible parameter declaration\") <<\r\n        \"module test #(parameter size = 8) (\\n\"\r\n        \"   );\\n\"\r\n        \"endmodule\"\r\n        << \"parameter size = 8\";   \r\n\r\n    QTest::newRow(\"Parameter declaration with description\") <<\r\n        \"module test #(\\n\"\r\n        \"    parameter size = 8 // Size of ports.\\n\"\r\n        \") ();\\n\"\r\n        \"endmodule\"\r\n        << \"parameter size = 8 // Size of ports.\";  \r\n\r\n    QTest::newRow(\"Parameter declaration followed by another parameter\") <<\r\n        \"module test #(\\n\"\r\n        \"    parameter size = 8, // Size of ports.\\n\"\r\n        \"    parameter width = 16\"\r\n        \") ();\\n\"\r\n        \"endmodule\"\r\n        << \"parameter size = 8, // Size of ports.\";  \r\n  \r\n    QTest::newRow(\"Parameter declaration with multiple parameters\") <<\r\n        \"module test #(\\n\"\r\n        \"    parameter size = 8, width = 16, dimension = 1 // Constants for ports.\\n\"\r\n        \") ();\\n\"\r\n        \"endmodule\"\r\n        << \"parameter size = 8, width = 16, dimension = 1 // Constants for ports.\";\r\n\r\n    QTest::newRow(\"Type, name and value on separate lines\") << \r\n        \"module test #(\\n\"\r\n        \"    parameter\\n\"\r\n        \"size \\n\"\r\n        \"= 8 // Line breaks.\\n\"\r\n        \") ();\\n\"\r\n        \"endmodule\"\r\n        << \r\n        \"parameter\\n\"\r\n        \"size \\n\"\r\n        \"= 8 // Line breaks.\";\r\n                \r\n    QTest::newRow(\"Double comment line\") << \r\n        \"module test #(\\n\"\r\n        \"    parameter size = 8,\\n\"\r\n        \"    // First comment line.\\n\"\r\n        \"    // Second comment line.\\n\"\r\n        \"    parameter width = 16\"\r\n        \") ();\\n\"\r\n        \"endmodule\"\r\n        << \r\n        \"parameter size = 8,\";\r\n \r\n    QTest::newRow(\"Parameter followed by port declaration\") << \r\n        \"module test #(\\n\"\r\n        \"    parameter size = 8\\n\"\r\n        \") (\\n\"\r\n        \"    input wire [size-1:0] data_in);\\n\"\r\n        \"endmodule\"\r\n        << \r\n        \"parameter size = 8\";\r\n\r\n    QTest::newRow(\"Simplest possible 1995-style parameter declaration\") <<\r\n        \"module test ();\"\r\n        \"   parameter size = 8;\\n\"\r\n        \"endmodule\"\r\n        << \"parameter size = 8;\";\r\n\r\n    QTest::newRow(\"1995-style parameter declaration followed by another parameter\") <<\r\n        \"module test ();\"\r\n        \"   parameter size = 8; // Size of ports.\\n\"\r\n        \"   parameter width = 16;\"\r\n        \"endmodule\"\r\n        << \"parameter size = 8; // Size of ports.\";\r\n       \r\n    QTest::newRow(\"1995-stype parameter declarations with multiple parameter\") <<\r\n        \"module test ();\\n\"\r\n        \"        parameter size = 8, width = 16; // Port sizes.\\n\"\r\n        \"endmodule\"\r\n        << \"parameter size = 8, width = 16; // Port sizes.\";\r\n\r\n    QTest::newRow(\"1995-stype parameter with type, name and value on separate lines\") << \r\n        \"module test ();\"\r\n        \"   parameter\\n\"\r\n        \"size\\n\"\r\n        \"= 8; // Port size.\\n\"\r\n        \"endmodule\"\r\n        << \r\n        \"parameter\\n\"\r\n        \"size\\n\"\r\n        \"= 8; // Port size.\";\r\n    \r\n    QTest::newRow(\"1995-style parameter with double comment line\") << \r\n        \"module test();\\n\"\r\n        \"    parameter size = 8;\\n\"\r\n        \"    // First comment line.\\n\"\r\n        \"    // Second comment line.\\n\"\r\n        \"    parameter width = 16;\"\r\n        \"endmodule\"\r\n        << \r\n        \"parameter size = 8;\";\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_VerilogImporter::testParameterInPortDeclaration()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_VerilogImporter::testParameterInPortDeclaration()\r\n{\r\n    QFETCH(QString, fileContent);\r\n    QFETCH(QString, expectedLeftBoundExpression);\r\n    QFETCH(QString, expectedRightBoundExpression);\r\n\r\n    runParser(fileContent);\r\n\r\n\tQSharedPointer<ComponentInstantiation> importComponentInstantiation =\r\n\t\timportComponent_->getModel()->getComponentInstantiations()->first();\r\n\r\n    QVERIFY2(importComponent_->getPorts()->size() != 0, \"No ports parsed from input.\");\r\n  \r\n    QSharedPointer<Port> createdPort = importComponent_->getPorts()->first();\r\n\r\n    QRegularExpression leftRule(expectedLeftBoundExpression);\r\n    QVERIFY(leftRule.match(createdPort->getLeftBound()).hasMatch());\r\n\r\n    QRegularExpression rightRule(expectedRightBoundExpression);\r\n    QVERIFY(rightRule.match(createdPort->getRightBound()).hasMatch());\r\n\r\n    QCOMPARE(importComponent_->getParameters()->last()->getUsageCount(), 2);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_VerilogImporter::testParameterInPortDeclaration_data()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_VerilogImporter::testParameterInPortDeclaration_data()\r\n{\r\n    QTest::addColumn<QString>(\"fileContent\");\r\n    QTest::addColumn<QString>(\"expectedLeftBoundExpression\");\r\n    QTest::addColumn<QString>(\"expectedRightBoundExpression\");\r\n\r\n    QTest::newRow(\"Parameter as left port bound\") <<\r\n        \"module test #(parameter left = 4) (\\n\"\r\n        \"   input [left:0] data\\n\"\r\n        \");\\n\"\r\n        \"endmodule\"\r\n        << parameterUuid() << \"0\";\r\n\r\n    QTest::newRow(\"Parameter as right port bound\") <<\r\n        \"module test #(parameter right = 4) (\\n\"\r\n        \"   input [0:right] data\\n\"\r\n        \");\\n\"\r\n        \"endmodule\"\r\n        << \"0\" << parameterUuid();\r\n\r\n    QTest::newRow(\"Parameters in left bound equation\") <<\r\n        \"module test #(\\n\"\r\n        \"   parameter data_bits = 32,\\n\"\r\n        \"   parameter addr_bits = 8\\n\"\r\n        \")(\\n\"\r\n        \"   input [data_bits + addr_bits:0] bus\\n\"\r\n        \");\\n\"\r\n        \"endmodule\"\r\n        << parameterUuid() + \" \\\\+ \" + parameterUuid() << \"0\";\r\n\r\n    QTest::newRow(\"Parameters and constants in left bound equation\") <<\r\n        \"module test #(\\n\"\r\n        \"   parameter data_bits = 8,\\n\"\r\n        \"   parameter data_bus_count = 3\"        \r\n        \")(\\n\"\r\n        \"   input [data_bits ** data_bus_count - 1:0] data_bus\\n\"\r\n        \");\\n\"\r\n        \"endmodule\"\r\n        << parameterUuid() + \" \\\\*\\\\* \" + parameterUuid() + \" - 1\" << \"0\";\r\n\r\n    QTest::newRow(\"Parameters in other parameters\") <<\r\n        \"module test #(\\n\"\r\n        \"   parameter data_bits = 8,\\n\"\r\n        \"   parameter addr_bits = 4,\\n\"\r\n        \"   parameter port_width = data_bits + addr_bits\"        \r\n        \")(\\n\"\r\n        \"   input [port_width - 1:0] data_bus\\n\"\r\n        \");\\n\"\r\n        \"endmodule\"\r\n        << parameterUuid() + \" - 1\" << \"0\";\r\n\r\n    QTest::newRow(\"Parameters with similar names\") <<\r\n        \"module test #(\\n\"\r\n        \"   parameter data = 8,\\n\"\r\n        \"   parameter data_bits = 4\\n\"\r\n        \")(\\n\"\r\n        \"   input [data_bits-1:0] data_bus\\n\"\r\n        \");\\n\"\r\n        \"endmodule\"\r\n        << parameterUuid() + \"-1\" << \"0\";\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_VerilogImporter::testParameterInParameterDeclaration()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_VerilogImporter::testParameterInParameterDeclaration()\r\n{\r\n    runParser(\r\n        \"module test #(\\n\"\r\n        \"   parameter first = 4,\\n\"\r\n        \"   parameter second = first)\\n\"\r\n        \"();\\n\"\r\n        \"endmodule\");\r\n\r\n\tQSharedPointer<ComponentInstantiation> importComponentInstantiation =\r\n\t\timportComponent_->getModel()->getComponentInstantiations()->first();\r\n\r\n    QSharedPointer<ModuleParameter> first = importComponentInstantiation->getModuleParameters()->first();\r\n    QSharedPointer<ModuleParameter> second = importComponentInstantiation->getModuleParameters()->last();\r\n\r\n    QSharedPointer<Parameter> firstParameter = importComponent_->getParameters()->first();\r\n    QSharedPointer<Parameter> secondParameter = importComponent_->getParameters()->last();\r\n\r\n    QCOMPARE(first->getValue(), firstParameter->getValueId());\r\n    QCOMPARE(second->getValue(), secondParameter->getValueId());\r\n\r\n    QCOMPARE(secondParameter->getValue(), firstParameter->getValueId());\r\n    QCOMPARE(firstParameter->getValue(), QString(\"4\"));\r\n\r\n    QCOMPARE(firstParameter->getUsageCount(), 2);\r\n    QCOMPARE(secondParameter->getUsageCount(), 1);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_VerilogImporter::testParameterInParameterArray()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_VerilogImporter::testParameterInParameterArray()\r\n{\r\n    runParser(\r\n        \"module test #(\\n\"\r\n        \"   parameter arraySize = 4,\\n\"\r\n        \"   parameter arrayOffset = 0,\\n\"\r\n        \"   parameter bit [arraySize-1:arrayOffset] [7:0] second = 0)\\n\"\r\n        \"();\\n\"\r\n        \"endmodule\");\r\n\r\n\tQSharedPointer<ComponentInstantiation> importComponentInstantiation =\r\n\t\timportComponent_->getModel()->getComponentInstantiations()->first();\r\n\r\n    QSharedPointer<ModuleParameter> first = importComponentInstantiation->getModuleParameters()->first();\r\n    QSharedPointer<ModuleParameter> second = importComponentInstantiation->getModuleParameters()->at(1);\r\n    QSharedPointer<ModuleParameter> last = importComponentInstantiation->getModuleParameters()->last();\r\n\r\n    QSharedPointer<Parameter> firstParameter = importComponent_->getParameters()->first();\r\n    QSharedPointer<Parameter> secondParameter = importComponent_->getParameters()->at(1);\r\n\r\n    QCOMPARE(last->getArrayLeft(), firstParameter->getValueId() + \"-1\");\r\n    QCOMPARE(last->getArrayRight(), secondParameter->getValueId());\r\n    QCOMPARE(last->getVectorLeft(), QString(\"7\"));\r\n    QCOMPARE(last->getVectorRight(), QString(\"0\"));\r\n    QCOMPARE(firstParameter->getUsageCount(), 3);\r\n    QCOMPARE(secondParameter->getUsageCount(), 3);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_VerilogImporter::testParameterInParameterBitWidth()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_VerilogImporter::testParameterInParameterBitWidth()\r\n{\r\n    runParser(\r\n        \"module test #(\\n\"\r\n        \"   parameter bitWidthLeft = 10,\\n\"\r\n        \"   parameter bitWidthRight = 2,\\n\"\r\n        \"   parameter bit [bitWidthLeft-1:bitWidthRight] newValue = 1)\\n\"\r\n        \"();\\n\"\r\n        \"endmodule\");\r\n\r\n\tQSharedPointer<ComponentInstantiation> importComponentInstantiation =\r\n\t\timportComponent_->getModel()->getComponentInstantiations()->first();\r\n\r\n    QSharedPointer<ModuleParameter> first = importComponentInstantiation->getModuleParameters()->first();\r\n    QSharedPointer<ModuleParameter> second = importComponentInstantiation->getModuleParameters()->at(1);\r\n    QSharedPointer<ModuleParameter> last = importComponentInstantiation->getModuleParameters()->last();\r\n\r\n    QSharedPointer<Parameter> firstParameter = importComponent_->getParameters()->first();\r\n    QSharedPointer<Parameter> secondParameter = importComponent_->getParameters()->at(1);\r\n\r\n    QCOMPARE(last->getArrayLeft(), QString(\"\"));\r\n    QCOMPARE(last->getArrayRight(), QString(\"\"));\r\n    QCOMPARE(last->getVectorLeft(), firstParameter->getValueId() + \"-1\");\r\n    QCOMPARE(last->getVectorRight(), secondParameter->getValueId());\r\n\r\n    QCOMPARE(firstParameter->getUsageCount(), 3);\r\n    QCOMPARE(secondParameter->getUsageCount(), 3);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_VerilogImporter::testMacroInParameterArray()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_VerilogImporter::testMacroInParameterArray()\r\n{\r\n    QSharedPointer<Parameter> sizeMacro(new Parameter);\r\n    sizeMacro->setName(\"SIZE\");\r\n    sizeMacro->setValue(\"2\");\r\n\r\n    QSharedPointer<Parameter> offsetMacro(new Parameter);\r\n    offsetMacro->setName(\"OFFSET\");\r\n    offsetMacro->setValue(\"0\");\r\n\r\n    importComponent_->getParameters()->append(sizeMacro);\r\n    importComponent_->getParameters()->append(offsetMacro);\r\n\r\n    runParser(\r\n        \"module test #(\\n\"\r\n        \"   parameter bit [`SIZE:`OFFSET] [7:0] second = '{8'h0,8'h0,8'h0})\\n\"\r\n        \"();\\n\"\r\n        \"endmodule\");\r\n\r\n\tQSharedPointer<ComponentInstantiation> importComponentInstantiation =\r\n\t\timportComponent_->getModel()->getComponentInstantiations()->first();\r\n\r\n    QSharedPointer<ModuleParameter> parameter = importComponentInstantiation->getModuleParameters()->first();\r\n\r\n    QCOMPARE(parameter->getArrayLeft(), sizeMacro->getValueId());\r\n    QCOMPARE(parameter->getArrayRight(), offsetMacro->getValueId());\r\n    QCOMPARE(parameter->getVectorLeft(), QString(\"7\"));\r\n    QCOMPARE(parameter->getVectorRight(), QString(\"0\"));\r\n\r\n    QCOMPARE(sizeMacro->getUsageCount(), 2);\r\n    QCOMPARE(offsetMacro->getUsageCount(), 2);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_VerilogImporter::testMacroInParameterBitWidth()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_VerilogImporter::testMacroInParameterBitWidth()\r\n{\r\n    QSharedPointer<Parameter> leftMacro(new Parameter);\r\n    leftMacro->setName(\"BIT_LEFT\");\r\n    leftMacro->setValue(\"8\");\r\n\r\n    QSharedPointer<Parameter> rightMacro(new Parameter);\r\n    rightMacro->setName(\"BIT_RIGHT\");\r\n    rightMacro->setValue(\"1\");\r\n\r\n    importComponent_->getParameters()->append(leftMacro);\r\n    importComponent_->getParameters()->append(rightMacro);\r\n\r\n    runParser(\r\n        \"module test #(\\n\"\r\n        \"   parameter bit [0:2] [`BIT_LEFT:`BIT_RIGHT] valueHolder = 8'h0\\n\"\r\n        \") ();\\n\"\r\n        \"endmodule\");\r\n\r\n\tQSharedPointer<ComponentInstantiation> importComponentInstantiation =\r\n\t\timportComponent_->getModel()->getComponentInstantiations()->first();\r\n\r\n    QSharedPointer<ModuleParameter> parameter = importComponentInstantiation->getModuleParameters()->first();\r\n\r\n    QCOMPARE(parameter->getArrayLeft(), QString(\"0\"));\r\n    QCOMPARE(parameter->getArrayRight(), QString(\"2\"));\r\n    QCOMPARE(parameter->getVectorLeft(), leftMacro->getValueId());\r\n    QCOMPARE(parameter->getVectorRight(), rightMacro->getValueId());\r\n\r\n    QCOMPARE(leftMacro->getUsageCount(), 2);\r\n    QCOMPARE(rightMacro->getUsageCount(), 2);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_VerilogImporter::testMacroInParameterValue()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_VerilogImporter::testMacroInParameterValue()\r\n{\r\n    QSharedPointer<Parameter> valueMacro(new Parameter);\r\n    valueMacro->setName(\"MAX_VALUE\");\r\n    valueMacro->setValue(\"1\");\r\n\r\n    QSharedPointer<Parameter> similarMacro(new Parameter);\r\n    similarMacro->setName(\"MAX\");\r\n    similarMacro->setValue(\"128\");\r\n\r\n    importComponent_->getParameters()->append(similarMacro);\r\n    importComponent_->getParameters()->append(valueMacro);\r\n\r\n    runParser(\r\n        \"module test #(\\n\"\r\n        \"   parameter int valueHolder = `MAX_VALUE)\\n\"\r\n        \"();\\n\"\r\n        \"endmodule\");\r\n\r\n\tQSharedPointer<ComponentInstantiation> importComponentInstantiation =\r\n\t\timportComponent_->getModel()->getComponentInstantiations()->first();\r\n\r\n    QSharedPointer<ModuleParameter> moduleParameter = importComponentInstantiation->getModuleParameters()->first();\r\n\r\n    QSharedPointer<Parameter> parameter = importComponent_->getParameters()->last();\r\n\r\n    QCOMPARE(moduleParameter->getValue(), parameter->getValueId());\r\n    QCOMPARE(parameter->getValue(), valueMacro->getValueId());\r\n\r\n    QCOMPARE(valueMacro->getUsageCount(), 1);\r\n    QCOMPARE(similarMacro->getUsageCount(), 0);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_VerilogImporter::testSemicolonInComments()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_VerilogImporter::testSemicolonInComments()\r\n{\r\n    runParser(\r\n        \"module test #(\\n\"\r\n        \"   parameter first = 4,\\n\"\r\n        \"   parameter second = first) (\\n\"\r\n        \"   //inputs \\n\"\r\n        \"input   test_input,\\n\"\r\n        \"//output test_output;\\n\"\r\n        \");\\n\"\r\n        \"endmodule\");\r\n\r\n\tQSharedPointer<ComponentInstantiation> importComponentInstantiation =\r\n\t\timportComponent_->getModel()->getComponentInstantiations()->first();\r\n\r\n    QCOMPARE(importComponentInstantiation->getModuleParameters()->count(), 2);\r\n    QCOMPARE(importComponent_->getPorts()->count(), 1);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_VerilogImporter::testAfterInputCommentsSemicolon()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_VerilogImporter::testAfterAssignComments()\r\n{\r\n    runParser(\r\n        \"module test(input x1,\\n\"\r\n        \"            input x2,\\n\"\r\n        \"            input x3,\\n\"\r\n        \"            output y1,\\n\"\r\n        \"            output y2,\\n\"\r\n        \"            output y3\\n\"\r\n        \"            );\\n\"\r\n        \"   assign      y1 = x1;\\n\"\r\n        \"   assign      y2 = x2;    // output z\\n\"\r\n        \"   assign      y3 = x3;\\n\"\r\n        \"endmodule // test\");\r\n\r\n    QSharedPointer<ComponentInstantiation> importComponentInstantiation =\r\n        importComponent_->getModel()->getComponentInstantiations()->first();\r\n\r\n    QCOMPARE(importComponent_->getPorts()->count(), 6);\r\n    QCOMPARE(importComponent_->getPorts()->at(0)->name(), QString(\"x1\"));\r\n    QCOMPARE(importComponent_->getPorts()->at(1)->name(), QString(\"x2\"));\r\n    QCOMPARE(importComponent_->getPorts()->at(2)->name(), QString(\"x3\"));\r\n    QCOMPARE(importComponent_->getPorts()->at(3)->name(), QString(\"y1\"));\r\n    QCOMPARE(importComponent_->getPorts()->at(4)->name(), QString(\"y2\"));\r\n    QCOMPARE(importComponent_->getPorts()->at(5)->name(), QString(\"y3\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_VerilogImporter::testAfterAssignCommentsSemicolon()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_VerilogImporter::testAfterAssignCommentsSemicolon()\r\n{\r\n    runParser(\r\n        \"module test(input x1,\\n\"\r\n        \"            input x2,\\n\"\r\n        \"            input x3,   // output xz;\\n\"\r\n        \"            output y1,\\n\"\r\n        \"            output y2,\\n\"\r\n        \"            output y3\\n\"\r\n        \"            );\\n\"\r\n        \"   assign      y1 = x1;\\n\"\r\n        \"   assign      y2 = x2;    // output z;\\n\"\r\n        \"   assign      y3 = x3;\\n\"\r\n        \"endmodule // test\");\r\n\r\n    QSharedPointer<ComponentInstantiation> secondImportComponentInstantiation =\r\n        importComponent_->getModel()->getComponentInstantiations()->first();\r\n\r\n    QCOMPARE(importComponent_->getPorts()->count(), 6);\r\n    QCOMPARE(importComponent_->getPorts()->at(0)->name(), QString(\"x1\"));\r\n    QCOMPARE(importComponent_->getPorts()->at(1)->name(), QString(\"x2\"));\r\n    QCOMPARE(importComponent_->getPorts()->at(2)->name(), QString(\"x3\"));\r\n    QCOMPARE(importComponent_->getPorts()->at(3)->name(), QString(\"y1\"));\r\n    QCOMPARE(importComponent_->getPorts()->at(4)->name(), QString(\"y2\"));\r\n    QCOMPARE(importComponent_->getPorts()->at(5)->name(), QString(\"y3\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_VerilogImporter::testMultiLineComments()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_VerilogImporter::testMultiLineComments()\r\n{\r\n    runParser(\r\n        \"module test(input x1,\\n\"\r\n        \"            input x2,\\n\"\r\n        \"            input x3,   // output xz;\\n\"\r\n        \"/*            output y1,\\n\"\r\n        \"            output y2,*/\\n\"\r\n        \"            output y3\\n\"\r\n        \"            );\\n\"\r\n        \"/*   assign      y1 = x1;\\n\"\r\n        \"   assign      y2 = x2;    // output z;*/\\n\"\r\n        \"   assign      y3 = x3;\\n\"\r\n        \"endmodule // test\");\r\n\r\n    QSharedPointer<ComponentInstantiation> secondImportComponentInstantiation =\r\n        importComponent_->getModel()->getComponentInstantiations()->first();\r\n\r\n    QCOMPARE(importComponent_->getPorts()->count(), 4);\r\n    QCOMPARE(importComponent_->getPorts()->at(0)->name(), QString(\"x1\"));\r\n    QCOMPARE(importComponent_->getPorts()->at(1)->name(), QString(\"x2\"));\r\n    QCOMPARE(importComponent_->getPorts()->at(2)->name(), QString(\"x3\"));\r\n    QCOMPARE(importComponent_->getPorts()->at(3)->name(), QString(\"y3\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_VerilogImporter::testParameterNotFoundInFileIsRemoved()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_VerilogImporter::testParameterNotFoundInFileIsRemoved()\r\n{\r\n    QSharedPointer<ModuleParameter> existingParameter(new ModuleParameter());\r\n\texistingParameter->setName(\"oldParameter\");\r\n\r\n    QString fileContent = \r\n        \"module test #(\\n\"\r\n        \"   parameter dataWidth_g = 8\\n\"\r\n        \"   )();\\n\"\r\n        \"endmodule\";\r\n\r\n\trunParser(fileContent);\r\n\r\n\tQSharedPointer<ComponentInstantiation> importComponentInstantiation =\r\n\t\timportComponent_->getModel()->getComponentInstantiations()->first();\r\n\r\n\timportComponentInstantiation->getModuleParameters()->append(existingParameter);\r\n\r\n\trunParser(fileContent);\r\n\r\n    QCOMPARE(importComponentInstantiation->getModuleParameters()->count(), 1);\r\n    QSharedPointer<ModuleParameter> importedParameter = importComponentInstantiation->getModuleParameters()->first();\r\n    QCOMPARE(importedParameter->name(), QString(\"dataWidth_g\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_VerilogImporter::testExistingModelParameterIdDoesNotChange()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_VerilogImporter::testExistingModelParameterIdDoesNotChange()\r\n{\r\n    QSharedPointer<ModuleParameter> existingParameter(new ModuleParameter());\r\n    existingParameter->setName(\"dataWidth_g\");\r\n\texistingParameter->setValueId(\"existingId\");\r\n\r\n\tQSharedPointer<View> importView = QSharedPointer<View>(new View);\r\n\tQSharedPointer<ComponentInstantiation> importComponentInstantiation(new ComponentInstantiation());\r\n\timportComponentInstantiation->setName(NameGenerationPolicy::componentInstantiationName(\"verilog\"));\r\n\timportComponentInstantiation->getModuleParameters()->append(existingParameter);\r\n\r\n\timportComponent_->getModel()->getComponentInstantiations()->append(importComponentInstantiation);\r\n\timportView->setComponentInstantiationRef(importComponentInstantiation->name());\r\n\timportComponent_->getViews()->append(importView);\r\n\r\n    QString fileContent = \r\n        \"module test #(\\n\"\r\n        \"   parameter dataWidth_g = 8\\n\"\r\n        \"   )();\\n\"\r\n        \"endmodule\";\r\n\r\n\trunParser(fileContent);\r\n\r\n    QSharedPointer<ModuleParameter> importedParameter = importComponentInstantiation->getModuleParameters()->first();\r\n    QCOMPARE(importedParameter->getValueId(), QString(\"existingId\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_VerilogImporter::testExistingParameterIsUpdated()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_VerilogImporter::testExistingParameterIsUpdated()\r\n{\r\n    QSharedPointer<Parameter> existingParameter(new ModuleParameter());\r\n    existingParameter->setName(\"data_width\");\r\n    existingParameter->setValue(\"0\");\r\n    importComponent_->getParameters()->append(existingParameter);\r\n\r\n    QString fileContent = \r\n        \"module test #(\\n\"\r\n        \"   parameter data_width = 8\\n\"\r\n        \"   )();\\n\"\r\n        \"endmodule\";\r\n\r\n    runParser(fileContent);\r\n\r\n    QSharedPointer<ComponentInstantiation> importComponentInstantiation =\r\n        importComponent_->getModel()->getComponentInstantiations()->first();\r\n    \r\n    QCOMPARE(importComponentInstantiation->getModuleParameters()->count(), 1);\r\n    QCOMPARE(importComponent_->getParameters()->count(), 1);\r\n    QCOMPARE(importComponent_->getParameters()->first()->getValue(), QString(\"8\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_VerilogImporter::testExistingPortIsSetAsPhantom()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_VerilogImporter::testExistingPortIsSetAsPhantom()\r\n{\r\n    QSharedPointer<Port> existingPort(new Port(\"oldPort\"));\r\n    existingPort->setDirection(DirectionTypes::IN);\r\n    importComponent_->getPorts()->append(existingPort);\r\n\r\n    QString input =  \r\n        \"module test(\\n\"\r\n        \"    input newPort\\n\"\r\n        \");\\n\"\r\n        \"endmodule\\n\";\r\n\r\n    runParser(input);\r\n\r\n    QCOMPARE(importComponent_->getPorts()->count(), 2);\r\n    QCOMPARE(importComponent_->getPort(\"oldPort\")->getDirection(), DirectionTypes::DIRECTION_PHANTOM);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_VerilogImporter::testExistingPortIsOverriden()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_VerilogImporter::testExistingPortIsOverriden()\r\n{\r\n    QSharedPointer<Port> existingPort(new Port(\"oldPort\"));\r\n    existingPort->setDirection(DirectionTypes::OUT);\r\n    importComponent_->getPorts()->append(existingPort);\r\n\r\n    QString input =  \r\n        \"module test(\\n\"\r\n        \"    input myType oldPort\\n\"\r\n        \");\\n\"\r\n        \"endmodule\\n\";\r\n\r\n    runParser(input);\r\n\r\n    QCOMPARE(importComponent_->getPorts()->count(), 1);\r\n    QCOMPARE(importComponent_->getPort(\"oldPort\")->getDirection(), DirectionTypes::IN);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_VerilogImporter::testModuleIsHighlighted()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_VerilogImporter::testModuleIsHighlighted()\r\n{\r\n    QFETCH(QString, fileContent);\r\n    QFETCH(QString, module);\r\n\r\n    runParser(fileContent);\r\n\r\n    int begin = fileContent.indexOf(module);\r\n\r\n    verifySectionFontColorIs(begin, module.length(), QColor(\"black\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_VerilogImporter::testModuleIsHighlighted_data()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_VerilogImporter::testModuleIsHighlighted_data()\r\n{\r\n    QTest::addColumn<QString>(\"fileContent\");\r\n    QTest::addColumn<QString>(\"module\");\r\n   \r\n    QTest::newRow(\"Empty module\") <<\r\n        \"module basic();\\n\"\r\n        \"endmodule\\n\"\r\n        <<\r\n        \"module basic();\\n\"\r\n        \"endmodule\\n\";\r\n\r\n    QTest::newRow(\"Comment before and after module\") <<\r\n        \"// Testbench for another module.\\n\"\r\n        \"module tb();\\n\"\r\n        \"endmodule\\n\"\r\n        \"// Testbench ends here.\\n\"\r\n        <<\r\n        \"module tb();\\n\"\r\n        \"endmodule\\n\";\r\n\r\n    QTest::newRow(\"Ports and parameters\") <<\r\n        \"// File header for half_adder.\\n\"\r\n        \"module half_adder(\\n\"        \r\n        \"    // inputs:\\n\"\r\n        \"    input bit1,\\n\"\r\n        \"    input bit2,\\n\"\r\n        \"    // outputs:\\n\"\r\n        \"    output sum,\\n\"\r\n        \"    output carry\\n\"\r\n        \");\\n\"\r\n        \"    xor(sum, bit1, bit2);\\n\"\r\n        \"    and(carry, bit1, bit2);\\n\"\r\n        \"endmodule\\n\"\r\n        \"\\n\"\r\n        <<\r\n        \"module half_adder(\\n\"        \r\n        \"    // inputs:\\n\"\r\n        \"    input bit1,\\n\"\r\n        \"    input bit2,\\n\"\r\n        \"    // outputs:\\n\"\r\n        \"    output sum,\\n\"\r\n        \"    output carry\\n\"\r\n        \");\\n\"\r\n        \"    xor(sum, bit1, bit2);\\n\"\r\n        \"    and(carry, bit1, bit2);\\n\"\r\n        \"endmodule\\n\";\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_VerilogImporter::verifySectionFontColorIs()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_VerilogImporter::verifySectionFontColorIs(int startIndex, int endIndex, QColor const& expectedFontColor)\r\n{\r\n    QTextCursor cursor = displayEditor_.textCursor();\r\n\r\n    int sectionLength = endIndex - startIndex;\r\n\r\n    for (int i = 0; i < sectionLength; i++)\r\n    {\r\n        cursor.setPosition(startIndex + i);\r\n        QColor fontColor = cursor.charFormat().foreground().color();\r\n        \r\n        if (fontColor != expectedFontColor)\r\n        {\r\n            QString errorMessage(\"Font color is \" + fontColor.name() +\" not \" + expectedFontColor.name() + \r\n                \" as expected after '\" + displayEditor_.toPlainText().mid(startIndex, i) + \"'\");\r\n            QFAIL(errorMessage.toLocal8Bit());\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_VerilogImporter::testModelNameAndEnvironmentIsImportedToView()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_VerilogImporter::testModelNameAndEnvironmentIsImportedToView()\r\n{\r\n    QFETCH(QString, fileContent);\r\n    QFETCH(QString, modelName);\r\n\r\n    runParser(fileContent, getModuleDeclaration(fileContent));\r\n\r\n\tQSharedPointer<ComponentInstantiation> importComponentInstantiation =\r\n\t\timportComponent_->getModel()->getComponentInstantiations()->first();\r\n\r\n\tQCOMPARE(importComponent_->getFlatViews().count(), 1);\r\n\r\n    QCOMPARE(importComponentInstantiation->getModuleName(), modelName);\r\n    QCOMPARE(importComponentInstantiation->getLanguage(), QString(\"Verilog\"));\r\n\tQCOMPARE(importComponent_->getViews()->first()->getEnvIdentifiers()->first()->language, QString(\"Verilog\"));\r\n\tQCOMPARE(importComponent_->getViews()->first()->getEnvIdentifiers()->first()->tool, VerilogSyntax::TOOL_NAME);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_VerilogImporter::testModelNameAndEnvironmentIsImportedToView_data()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_VerilogImporter::testModelNameAndEnvironmentIsImportedToView_data()\r\n{\r\n    QTest::addColumn<QString>(\"fileContent\");\r\n    QTest::addColumn<QString>(\"modelName\");\r\n\r\n    QTest::newRow(\"Empty module\") <<\r\n        \"module basic();\\n\"\r\n        \"endmodule\\n\"\r\n        <<\r\n        \"basic\";\r\n    \r\n    QTest::newRow(\"Module without port brackets\") <<\r\n        \"module tb;\\n\"\r\n        \"endmodule\\n\"\r\n        <<\r\n        \"tb\";\r\n\r\n    QTest::newRow(\"Macromodule keyword\") <<\r\n        \"macromodule tb;\\n\"\r\n        \"endmodule\\n\"\r\n        <<\r\n        \"tb\";\r\n\r\n    QTest::newRow(\"Ports and parameters\") <<\r\n        \"// File header for half_adder.\\n\"\r\n        \"module half_adder(\\n\"        \r\n        \"    // inputs:\\n\"\r\n        \"    input bit1,\\n\"\r\n        \"    input bit2,\\n\"\r\n        \"    // outputs:\\n\"\r\n        \"    output sum,\\n\"\r\n        \"    output carry\\n\"\r\n        \");\\n\"\r\n        \"    xor(sum, bit1, bit2);\\n\"\r\n        \"    and(carry, bit1, bit2);\\n\"\r\n        \"endmodule\\n\"\r\n        \"\\n\"\r\n        <<\r\n        \"half_adder\";\r\n\r\n    QTest::newRow(\"Keyword module in comments before module declaration\") <<\r\n        \"// module comment \\n\"\r\n        \"module real_name();\\n\"\r\n        \"endmodule\\n\"\r\n        <<\r\n        \"real_name\";\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_VerilogImporter::testComponentInstantiationAndViewExistsAfterImport()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_VerilogImporter::testComponentInstantiationAndViewExistsAfterImport()\r\n{\r\n    QCOMPARE(importComponent_->getViews()->size(), 0);\r\n    QCOMPARE(importComponent_->getComponentInstantiations()->size(), 0);\r\n\r\n    QString fileContent = \r\n        \"module test #(\\n\"\r\n        \"   parameter dataWidth_g = 8\\n\"\r\n        \"   )();\\n\"\r\n        \"endmodule\";\r\n\r\n    runParser(fileContent);\r\n\r\n    QCOMPARE(importComponent_->getViews()->size(), 1);\r\n    QCOMPARE(importComponent_->getComponentInstantiations()->size(), 1);\r\n\r\n    QSharedPointer<View> importedView = importComponent_->getViews()->first();\r\n    QSharedPointer<ComponentInstantiation> importedInstantiation =\r\n        importComponent_->getComponentInstantiations()->first();\r\n\r\n    QCOMPARE(importedView->getComponentInstantiationRef(), importedInstantiation->name());\r\n    QCOMPARE(importedInstantiation->getModuleParameters()->size(), 1);\r\n    QCOMPARE(importedInstantiation->getModuleParameters()->first()->name(), QString(\"dataWidth_g\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_VerilogImporter::testMultipleModelsInOneFile()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_VerilogImporter::testMultipleModelsInOneFile()\r\n{\r\n    QFETCH(QString, fileContent);\r\n    QFETCH(QString, modelName);\r\n    QFETCH(int, moduleNumber);\r\n\r\n    runParser(fileContent, getModuleDeclaration(fileContent, moduleNumber));\r\n\r\n    QSharedPointer<ComponentInstantiation> importComponentInstantiation =\r\n        importComponent_->getModel()->getComponentInstantiations()->first();\r\n\r\n    QCOMPARE(importComponentInstantiation->getModuleName(), modelName);\r\n    QCOMPARE(importComponentInstantiation->getLanguage(), QString(\"Verilog\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_VerilogImporter::testMultipleModelsInOneFile_data()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_VerilogImporter::testMultipleModelsInOneFile_data()\r\n{\r\n    QTest::addColumn<QString>(\"fileContent\");\r\n    QTest::addColumn<QString>(\"modelName\");\r\n    QTest::addColumn<int>(\"moduleNumber\");\r\n\r\n    QTest::newRow(\"Select first module\") <<\r\n        \"module firstModule();\\n\"\r\n        \"    // inputs:\\n\"\r\n        \"    input bit1,\\n\"\r\n        \"    // outputs:\\n\"\r\n        \"    output sum,\\n\"\r\n        \"endmodule\\n\"\r\n        \"module secondModule();\\n\"\r\n        \"    // inputs:\\n\"\r\n        \"    input bit2,\\n\"\r\n        \"    // outputs:\\n\"\r\n        \"    output clk,\\n\"\r\n        \"endmodule\\n\"\r\n        <<\r\n        \"firstModule\"\r\n        << 0;\r\n\r\n    QTest::newRow(\"Select second module\") <<\r\n        \"module firstModule();\\n\"\r\n        \"    // inputs:\\n\"\r\n        \"    input bit1,\\n\"\r\n        \"    // outputs:\\n\"\r\n        \"    output sum,\\n\"\r\n        \"endmodule\\n\"\r\n        \"module secondModule();\\n\"\r\n        \"    // inputs:\\n\"\r\n        \"    input bit2,\\n\"\r\n        \"    // outputs:\\n\"\r\n        \"    output clk,\\n\"\r\n        \"endmodule\\n\"\r\n        <<\r\n        \"secondModule\"\r\n        << 1;\r\n\r\n    QTest::newRow(\"Select third module\") <<\r\n        \"module firstModule();\\n\"\r\n        \"    // inputs:\\n\"\r\n        \"    input bit1,\\n\"\r\n        \"endmodule\\n\"\r\n        \"module secondModule();\\n\"\r\n        \"    // inputs:\\n\"\r\n        \"    input bit2,\\n\"\r\n        \"endmodule\\n\"\r\n        \"module thirdModule();\\n\"\r\n        \"    // inputs:\\n\"\r\n        \"    input bit3,\\n\"\r\n        \"endmodule\\n\"\r\n        <<\r\n        \"thirdModule\"\r\n        << 2;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_VerilogImporter::parameterUuid()\r\n//-----------------------------------------------------------------------------\r\nQString tst_VerilogImporter::parameterUuid() const\r\n{\r\n    return \"uuid_[0-9a-f]{8}_[0-9a-f]{4}_[0-9a-f]{4}_[0-9a-f]{4}_[0-9a-f]{12}\";\r\n}\r\n\r\nQTEST_MAIN(tst_VerilogImporter)\r\n\r\n#include \"tst_VerilogImporter.moc\"\r\n"
  },
  {
    "path": "tests/Plugins/VerilogImport/tst_VerilogImporter.pri",
    "content": "# ----------------------------------------------------\r\n# This file is generated by the Qt Visual Studio Tools.\r\n# ------------------------------------------------------\r\n\r\n# This is a reminder that you are using a generated .pro file.\r\n# Remove it when you are finished editing this file.\r\nmessage(\"You are running qmake on a generated .pro file. This may not work!\")\r\n\r\n\r\nHEADERS += ../../../KactusAPI/include/ExpressionParser.h \\\r\n    ../../../KactusAPI/include/ExpressionSupport.h \\\r\n    ../../../KactusAPI/include/ImportColors.h \\\r\n    ../../../common/NameGenerationPolicy.h \\\r\n    ../../../IPXACTmodels/utilities/Search.h \\\r\n    ../../../Plugins/VerilogImport/VerilogInstanceParser.h \\\r\n    ../../../Plugins/VerilogImport/VerilogParameterParser.h \\\r\n    ../../../Plugins/VerilogImport/VerilogPortParser.h \\\r\n    ../../../common/expressions/utilities.h \\\r\n    ../../../KactusAPI/include/ImportHighlighter.h \\\r\n    ../../../Plugins/VerilogImport/VerilogImporter.h\r\nSOURCES += ../../../KactusAPI/plugins/ImportHighlighter.cpp \\\r\n    ../../../common/NameGenerationPolicy.cpp \\\r\n    ../../../Plugins/VerilogImport/VerilogImporter.cpp \\\r\n    ../../../Plugins/VerilogImport/VerilogInstanceParser.cpp \\\r\n    ../../../Plugins/VerilogImport/VerilogParameterParser.cpp \\\r\n    ../../../Plugins/VerilogImport/VerilogPortParser.cpp \\\r\n    ../../../Plugins/VerilogImport/VerilogSyntax.cpp \\\r\n    ../../../common/expressions/utilities.cpp \\\r\n    ./tst_VerilogImporter.cpp\r\n"
  },
  {
    "path": "tests/Plugins/VerilogImport/tst_VerilogImporter.pro",
    "content": "#-----------------------------------------------------------------------------\r\n# File: tst_VerilogImporter.pro\r\n#-----------------------------------------------------------------------------\r\n# Project: Kactus 2\r\n# Author: Esko Pekkarinen\r\n# Date: 23.09.2014\r\n#\r\n# Description:\r\n# Qt project file template for running unit tests for VerilogImporter.\r\n#-----------------------------------------------------------------------------\r\n\r\nTEMPLATE = app\r\n\r\nTARGET = tst_VerilogImporter\r\n\r\nQT += core xml gui widgets testlib\r\nCONFIG += c++11 testcase\r\n\r\nDEFINES += VERILOGIMPORT_LIB\r\n\r\nQMAKE_EXPORTED_VARIABLES += MAKE_TESTARGS\r\nMAKE_TESTARGS.name = TESTARGS\r\nMAKE_TESTARGS.value = \"-platform offscreen\"\r\n\r\nwin32:CONFIG(release, debug|release) {\r\n    LIBS += -L$$PWD/../../../executable/ -lIPXACTmodels\r\n    LIBS += -L$$PWD/../../../executable/ -lKactusAPI\r\n    DESTDIR = ./release\r\n}\r\nelse:win32:CONFIG(debug, debug|release) {\r\n    LIBS += -L$$PWD/../../../executable/ -lIPXACTmodelsd\r\n    LIBS += -L$$PWD/../../../executable/ -lKactusAPId\r\n    DESTDIR = ./debug\r\n}\r\nelse:unix {\r\n    LIBS += -L$$PWD/../../../executable/ -lIPXACTmodels\r\n    LIBS += -L$$PWD/../../../executable/ -lKactusAPI\r\n    DESTDIR = ./release\r\n}\r\n\r\nINCLUDEPATH += $$DESTDIR\r\nINCLUDEPATH += $$PWD/../../../KactusAPI/include/\r\nINCLUDEPATH += ../../../\r\n\r\nDEPENDPATH += .\r\nDEPENDPATH += ../../../\r\n\r\nOBJECTS_DIR += $$DESTDIR\r\n\r\nMOC_DIR += ./generatedFiles\r\nUI_DIR += ./generatedFiles\r\nRCC_DIR += ./generatedFiles\r\ninclude(tst_VerilogImporter.pri)\r\n"
  },
  {
    "path": "tests/Plugins/VerilogImport/tst_VerilogParameterParser.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: tst_VerilogParameterParser.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Janne Virtanen\r\n// Date: 25.09.2014\r\n//\r\n// Description:\r\n// Unit test for class VerilogParameterParser.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include <QtTest>\r\n#include <Plugins/VerilogImport/VerilogParameterParser.h>\r\n\r\n#include <IPXACTmodels/Component/Component.h>\r\n#include <IPXACTmodels/Component/Model.h>\r\n\r\nclass tst_VerilogParameterParser : public QObject\r\n{\r\n    Q_OBJECT\r\n\r\npublic:\r\n    tst_VerilogParameterParser();\r\n\r\nprivate slots:\r\n    void noParameters();\r\n    void noPorts();\r\n\r\n    void singleLineHeader();\r\n    void multiLineHeader();\r\n    void multiLineComments();\r\n    void evilMultiLineComment();\r\n    void commentLines();\r\n    void multiDeclaration();\r\n    void multiLineDeclarations();\r\n\r\n    void oneParameter();\r\n    void threeParameter();\r\n    void spacedParameters();\r\n\r\n    void describedParameters();\r\n    void oneUnDescribed();\r\n    void multiLineDescribed();\r\n    void describedParentheses();\r\n    void evilDescription();\r\n\tvoid testStringValue();\r\n\r\n    void otherParameterAsParameterValue();\r\n    void testAnsiArrayValue();\r\n    void testAnsiArrayValue_data();\r\n\r\n    void oldParameter();\r\n    void multipleOldParameters();\r\n    void variantOldParameters();\r\n    void multiOldParameters();\r\n    void oldWithEndModule();\r\n    void doubleMultiOldParameters();       \r\n    void testOldArrayValue();\r\n    void testOldArrayValue_data();\r\n\r\n    void parametersToComponent();\r\n    void oldParametersToComponent();\r\n\r\n    void operations();\r\n    void oldOperations();\r\n    void bases();\r\n    void braces();\r\n    void twoDimensional();\r\n    void closerOnLine();\r\n    void closerOnLineDescribedparentheses();\r\n    void closerOnLineDescribedparentheses2();\r\n    void parenthesesInPorts();\r\n    void customCase();\r\n\r\nprivate:\r\n\tvoid verifyParameter( QSharedPointer<Parameter> parameter,\r\n\t\tQString name, QString value, QString description );\r\n\r\n};\r\n\r\nvoid tst_VerilogParameterParser::verifyParameter( QSharedPointer<Parameter> parameter,\r\n\tQString name, QString value, QString description )\r\n{\r\n\tQCOMPARE(parameter->name(), name);\r\n\tQCOMPARE(parameter->getValue(), value);\r\n\tQCOMPARE(parameter->description(), description);\r\n}\r\n\r\ntst_VerilogParameterParser::tst_VerilogParameterParser()\r\n{\r\n}\r\n\r\nvoid tst_VerilogParameterParser::noParameters()\r\n{\r\n    QString input = \"module shifter();\\n\"\r\n        \"endmodule\";\r\n\r\n    VerilogParameterParser parser;\r\n    QStringList declarations = parser.findDeclarations(input);\r\n    QCOMPARE( declarations.size(), 0 );\r\n}\r\n\r\nvoid tst_VerilogParameterParser::noPorts()\r\n{\r\n    QString input = \"module shifter #(parameter ok joku=12);\\n\"\r\n        \"endmodule\";\r\n\r\n    VerilogParameterParser parser;\r\n    QStringList declarations = parser.findDeclarations(input);\r\n    QCOMPARE( declarations[0], QString( \"parameter ok joku=12\") );\r\n}\r\n\r\nvoid tst_VerilogParameterParser::singleLineHeader()\r\n{\r\n    QString input = \"module shifter #(parameter ok joku=12) (\\n\"\r\n        \"input reset_n, //reset async active low\\n\"\r\n        \"input clk, //input clock\\n\"\r\n        \"input data_ena, //serial data enable\\n\"\r\n        \"input serial_data, //serial data input\\n\"\r\n        \"output reg [width-1:0] parallel_data //parallel data out\\n\"\r\n        \");\\n\"\r\n        \"always @ (posedge clk, negedge reset_n)\\n\"\r\n        \"if(!reset_n) parallel_data <= 0; //could not do \\\"widthd0\\\"\\n\"\r\n        \"else if (data_ena)\\n\"\r\n        \"parallel_data <= {serial_data, parallel_data[width-1:1]};\\n\"\r\n        \"endmodule\";\r\n\r\n    VerilogParameterParser parser;\r\n    QStringList declarations = parser.findDeclarations(input);\r\n    QCOMPARE( declarations.size(), 1 );\r\n    QCOMPARE( declarations[0], QString( \"parameter ok joku=12\") );\r\n}\r\n\r\nvoid tst_VerilogParameterParser::multiLineHeader()\r\n{\r\n    QString input = \"module shifter #(\\n\"\r\n        \"parameter ok width=8, count=6\\n\"                \r\n        \") (\\n\"\r\n        \"input reset_n, //reset async active low\\n\"\r\n        \"input clk, //input clock\\n\"\r\n        \"input data_ena, //serial data enable\\n\"\r\n        \"input serial_data, //serial data input\\n\"\r\n        \"output reg [width-1:0] parallel_data //parallel data out\\n\"\r\n        \");\\n\"\r\n        \"always @ (posedge clk, negedge reset_n)\\n\"\r\n        \"if(!reset_n) parallel_data <= 0; //could not do \\\"widthd0\\\"\\n\"\r\n        \"else if (data_ena)\\n\"\r\n        \"parallel_data <= {serial_data, parallel_data[width-1:1]};\\n\"\r\n        \"endmodule\";\r\n\r\n    VerilogParameterParser parser;\r\n    QStringList declarations = parser.findDeclarations(input);\r\n    QCOMPARE( declarations.size(), 1 );\r\n    QCOMPARE(declarations[0], QString(\"parameter ok width=8, count=6\") );\r\n}\r\n\r\nvoid tst_VerilogParameterParser::multiLineComments()\r\n{\r\n    QString input = \"module shifter #(\\n\"\r\n        \"parameter ok joku=8,\\n\"\r\n        \"/*uliuli uli*/\\n\"\r\n        \"esa=6,\\n\"\r\n        \"parameter joku=22,\\n\"\r\n        \"/*ULINA\\n\"\r\n        \"KALINA*/\\n\"\r\n        \"jaa joku=1234\\n\"\r\n        \") (\\n\"\r\n        \"input reset_n, //reset async active low\\n\"\r\n        \"input clk, //input clock\\n\"\r\n        \"input data_ena, //serial data enable\\n\"\r\n        \"input serial_data, //serial data input\\n\"\r\n        \"/*APINOITA\\n\"\r\n        \"PITKIN OITA\\n\"\r\n        \"usrujsjjrr*/\\n\"\r\n        \"output reg [width-1:0] parallel_data //parallel data out \\n\"\r\n        \");\\n\"\r\n        \"always @ (posedge clk, negedge reset_n)\\n\"\r\n        \"if(!reset_n) parallel_data <= 0; //could not do \\\"widthd0\\\"\\n\"\r\n        \"else if (data_ena)\\n\"\r\n        \"parallel_data <= {serial_data, parallel_data[width-1:1]};\\n\"\r\n        \"endmodule\";\r\n\r\n    VerilogParameterParser parser;\r\n    QStringList declarations = parser.findDeclarations(input);\r\n    QCOMPARE( declarations.size(), 2 );\r\n    QCOMPARE(declarations[0], QString(\"parameter ok joku=8,\\n\\nesa=6,\") );\r\n    QCOMPARE(declarations[1], QString(\"parameter joku=22,\\n\\njaa joku=1234\"));\r\n}\r\n\r\nvoid tst_VerilogParameterParser::evilMultiLineComment()\r\n{\r\n    QString input = \"module shifter #(\\n\"\r\n        \"parameter uus,\\n\"\r\n        \"parameter x\\n\"\r\n        \") (\\n\"\r\n        \"input reset_n, //reset async active low\\n\"\r\n        \"input clk, //input clock\\n\"\r\n        \"output reg [width-1:0] parallel_data //parallel data out \\n\"\r\n        \");/*APINOITA\\n\"\r\n        \"PITKIN OITA\\n\"\r\n        \"usrujsjjrr*/\\n\"\r\n        \"endmodule\";\r\n\r\n    VerilogParameterParser parser;\r\n    QStringList declarations = parser.findDeclarations(input);\r\n    QCOMPARE( declarations.size(), 2 );\r\n    QCOMPARE(declarations[0], QString(\"parameter uus,\") );\r\n    QCOMPARE(declarations[1], QString(\"parameter x\"));\r\n}\r\n\r\nvoid tst_VerilogParameterParser::commentLines()\r\n{\r\n    QString input = \"module shifter #(\\n\"\r\n        \"parameter ok joku=8, //herpaderp\\n\"\r\n        \"//uliuli uli\\n\"\r\n        \"esa=6,\\n\"\r\n        \"parameter joku=22,\\n\"\r\n        \"//ULINA\\n\"\r\n        \"//KALINA\\n\"\r\n        \"jaa joku=1234\\n\"\r\n        \") (\\n\"\r\n        \"input reset_n, //reset async active low\\n\"\r\n        \"input clk, //input clock\\n\"\r\n        \"input data_ena, //serial data enable\\n\"\r\n        \"input serial_data, //serial data input\\n\"\r\n        \"//APINOITA\\n\"\r\n        \"//PITKIN OITA\\n\"\r\n        \"//usrujsjjrr\\n\"\r\n        \"output reg [width-1:0] parallel_data //parallel data out \\n\"\r\n        \");\\n\"\r\n        \"always @ (posedge clk, negedge reset_n)\\n\"\r\n        \"if(!reset_n) parallel_data <= 0; //could not do \\\"widthd0\\\"\\n\"\r\n        \"else if (data_ena)\\n\"\r\n        \"parallel_data <= {serial_data, parallel_data[width-1:1]};\\n\"\r\n        \"endmodule\";\r\n\r\n    VerilogParameterParser parser;\r\n    QStringList declarations = parser.findDeclarations(input);\r\n    QCOMPARE( declarations.size(), 2 );\r\n    QCOMPARE(declarations[0], QString(\"parameter ok joku=8, //herpaderp\\nesa=6,\") );\r\n    QCOMPARE(declarations[1], QString(\"parameter joku=22,\\njaa joku=1234\"));\r\n}\r\n\r\nvoid tst_VerilogParameterParser::multiDeclaration()\r\n{\r\n    QString input = \"module shifter #(parameter ok joku=12, esa = 3, jari = 123);\\n\";\r\n\r\n    VerilogParameterParser parser;\r\n    QStringList declarations = parser.findDeclarations(input);\r\n    QCOMPARE(declarations.size(), 1);\r\n    QCOMPARE(declarations[0], QString( \"parameter ok joku=12, esa = 3, jari = 123\"));\r\n}\r\n\r\nvoid tst_VerilogParameterParser::multiLineDeclarations()\r\n{\r\n    QString input = \"module shifter #(parameter ok joku=12,\\n\"\r\n        \"esa = 3,\\n\"\r\n        \"jari = 123,\\n\"\r\n        \"parameter singed def[1:4] jees=1234, horspo = 567);\\n\";\r\n\r\n    VerilogParameterParser parser;\r\n    QStringList declarations = parser.findDeclarations(input);\r\n    QCOMPARE(declarations.size(), 2);\r\n    QCOMPARE( declarations[0], QString( \"parameter ok joku=12,\\nesa = 3,\\njari = 123,\") );\r\n    QCOMPARE( declarations[1], QString( \"parameter singed def[1:4] jees=1234, horspo = 567\") );\r\n}\r\n\r\nvoid tst_VerilogParameterParser::oneParameter()\r\n{\r\n    QString input = \"module shifter #(\\n\"\r\n        \"parameter ok joku=8\\n\"\r\n        \") (\\n\"\r\n        \"); endmodule\\n\";\r\n\r\n    VerilogParameterParser parser;\r\n    QString description;\r\n    QString type;\r\n    QStringList declarations = parser.findDeclarations(input);\r\n    QCOMPARE(declarations.size(), 1);\r\n\r\n    QList<QSharedPointer<ModuleParameter> > parameters = parser.parseParameters(declarations[0]);\r\n    QCOMPARE(parameters.size(), 1);\r\n    verifyParameter( parameters[0], \"joku\", \"8\", \"\");\r\n}\r\n\r\nvoid tst_VerilogParameterParser::threeParameter()\r\n{\r\n    QString input = \"module shifter #(\\n\"\r\n        \"parameter ok joku=8,\\n\"\r\n        \"parameter int esa=6,\\n\"\r\n        \"parameter joku=22\\n\"\r\n        \") (\\n\"\r\n        \"); endmodule\\n\";\r\n\r\n    VerilogParameterParser parser;\r\n    QStringList declarations = parser.findDeclarations(input);\r\n    QCOMPARE(declarations.size(), 3);\r\n\r\n    QList<QSharedPointer<ModuleParameter> > parameters = parser.parseParameters(declarations[0]);\r\n    verifyParameter( parameters[0], \"joku\", \"8\", \"\");\r\n    parameters.append(parser.parseParameters(declarations[1]));\r\n    verifyParameter( parameters[1], \"esa\", \"6\", \"\");\r\n    parameters.append(parser.parseParameters(declarations[2]));\r\n    verifyParameter( parameters[2], \"joku\", \"22\", \"\");\r\n}\r\n\r\nvoid tst_VerilogParameterParser::spacedParameters()\r\n{\r\n    QString input = \"module shifter #(\\n\"\r\n        \"parameter ok joku =8,\\n\"\r\n        \"parameter esa= 6,\\n\"\r\n        \"parameter hopo = 22\\n\"\r\n        \") (\\n\"\r\n        \"); endmodule\\n\";\r\n\r\n    VerilogParameterParser parser;\r\n    QStringList declarations = parser.findDeclarations(input);\r\n    QCOMPARE(declarations.size(), 3);\r\n\r\n    QList<QSharedPointer<ModuleParameter> > parameters = parser.parseParameters(declarations[0]);\r\n    verifyParameter( parameters[0], \"joku\", \"8\", \"\");\r\n    parameters.append(parser.parseParameters(declarations[1]));\r\n    verifyParameter( parameters[1], \"esa\", \"6\", \"\");\r\n    parameters.append(parser.parseParameters(declarations[2]));\r\n    verifyParameter( parameters[2], \"hopo\", \"22\", \"\");\r\n}\r\n\r\nvoid tst_VerilogParameterParser::describedParameters()\r\n{\r\n    QString input = \"module shifter #(\\n\"\r\n        \"parameter ok joku =8,//seli\\n\"\r\n        \"parameter int juu =98, //evo\\n\"\r\n        \"parameter esa= 6, // epeli\\n\"\r\n        \"parameter hopo = 22 // o olololo ollllooo \\n\"\r\n        \") (\\n\"\r\n        \"); endmodule\\n\";\r\n\r\n    VerilogParameterParser parser;\r\n    QStringList declarations = parser.findDeclarations(input);\r\n    QCOMPARE(declarations.size(), 4);\r\n\r\n    QList<QSharedPointer<ModuleParameter> > parameters = parser.parseParameters(declarations[0]);\r\n    verifyParameter( parameters[0], \"joku\", \"8\", \"seli\");\r\n    parameters.append(parser.parseParameters(declarations[1]));\r\n    verifyParameter( parameters[1], \"juu\", \"98\", \"evo\");\r\n    parameters.append(parser.parseParameters(declarations[2]));\r\n    verifyParameter( parameters[2], \"esa\", \"6\", \"epeli\");\r\n    parameters.append(parser.parseParameters(declarations[3]));\r\n    verifyParameter( parameters[3], \"hopo\", \"22\", \"o olololo ollllooo\");\r\n}\r\n\r\nvoid tst_VerilogParameterParser::oneUnDescribed()\r\n{\r\n    QString input = \"module shifter #(\\n\"\r\n        \"parameter ok joku =8,//joku\\n\"\r\n        \"parameter int juu =98,\\n\"\r\n        \"parameter esa= 6 // epeli\\n\"\r\n        \") (\\n\"\r\n        \"); endmodule\\n\";\r\n\r\n    VerilogParameterParser parser;\r\n    QStringList declarations = parser.findDeclarations(input);\r\n\r\n    QList<QSharedPointer<ModuleParameter> > parameters = parser.parseParameters(declarations[0]);\r\n    verifyParameter( parameters[0], \"joku\", \"8\", \"joku\");\r\n    parameters.append(parser.parseParameters(declarations[1]));\r\n    verifyParameter( parameters[1], \"juu\", \"98\", \"\");\r\n    parameters.append(parser.parseParameters(declarations[2]));\r\n    verifyParameter( parameters[2], \"esa\", \"6\", \"epeli\");\r\n}\r\n\r\nvoid tst_VerilogParameterParser::multiLineDescribed()\r\n{\r\n    QString input = \"module shifter #(\\n\"\r\n        \"parameter char joku =8, juu =98,\\n\"\r\n        \"esa= 6 // epeli\\n\"\r\n        \") (\\n\"\r\n        \"); endmodule\\n\";\r\n\r\n    VerilogParameterParser parser;\r\n    QStringList declarations = parser.findDeclarations(input);\r\n\r\n    QList<QSharedPointer<ModuleParameter> > parameters = parser.parseParameters(declarations[0]);\r\n    verifyParameter( parameters[0], \"joku\", \"8\", \"epeli\");\r\n    verifyParameter( parameters[1], \"juu\", \"98\", \"epeli\");\r\n    verifyParameter( parameters[2], \"esa\", \"6\", \"epeli\");\r\n}\r\n\r\nvoid tst_VerilogParameterParser::describedParentheses()\r\n{\r\n    QString input = \"module shifter #(\\n\"\r\n        \"parameter esa= 6 , // epeli\\n\"\r\n        \"parameter hopo = 22 // o (olololo ollllooo) \\n\"\r\n        \") (\\n\"\r\n        \"); endmodule\\n\";\r\n\r\n    VerilogParameterParser parser;\r\n    QStringList declarations = parser.findDeclarations(input);\r\n\r\n    QList<QSharedPointer<ModuleParameter> > parameters = parser.parseParameters(declarations[0]);\r\n    verifyParameter( parameters[0], \"esa\", \"6\", \"epeli\");\r\n    parameters.append(parser.parseParameters(declarations[1]));\r\n    verifyParameter( parameters[1], \"hopo\", \"22\", \"o (olololo ollllooo)\");\r\n}\r\n\r\nvoid tst_VerilogParameterParser::evilDescription()\r\n{\r\n    QString input = \"module shifter #(\\n\"\r\n        \"parameter DATAWIDTH= 32 // module declaration ends here );\\n\"\r\n        \"parameter AUB = DATAWIDTH/4 // (oon); \\n\"\r\n        \") (\\n\"\r\n        \"); endmodule\\n\";\r\n\r\n    VerilogParameterParser parser;\r\n    QStringList declarations = parser.findDeclarations(input);\r\n\r\n    QList<QSharedPointer<ModuleParameter> > parameters = parser.parseParameters(declarations[0]);\r\n    verifyParameter( parameters[0], \"DATAWIDTH\", \"32\", \"module declaration ends here );\");\r\n    parameters.append(parser.parseParameters(declarations[1]));\r\n    verifyParameter( parameters[1], \"AUB\", \"DATAWIDTH/4\", \"(oon);\");\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_VerilogParameterParser::testStringValue()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_VerilogParameterParser::testStringValue()\r\n{\r\n\tQString input = \"module shifter #(\\n\"\r\n\t\t\"parameter type = \\\"barrel\\\", // \\\"barrel\\\" or \\\"arithmetic\\\"\\n\"\r\n\t\t\"parameter DATAWIDTH = 8 \\n\"\r\n\t\t\") (\\n\"\r\n\t\t\"); endmodule\\n\";\r\n\r\n\tVerilogParameterParser parser;\r\n\tQStringList declarations = parser.findDeclarations(input);\r\n\r\n\tQList<QSharedPointer<ModuleParameter> > parameters = parser.parseParameters(declarations[0]);\r\n\tverifyParameter(parameters[0], \"type\", \"\\\"barrel\\\"\", \"\\\"barrel\\\" or \\\"arithmetic\\\"\");\r\n\tparameters.append(parser.parseParameters(declarations[1]));\r\n\tverifyParameter(parameters[1], \"DATAWIDTH\", \"8\", \"\");\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_VerilogParameterParser::otherParameterAsParameterValue()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_VerilogParameterParser::otherParameterAsParameterValue()\r\n{\r\n    QSharedPointer<Component> targetComponent(new Component(VLNV(), Document::Revision::Std14));\r\n\r\n    QString input = \"module test #(\\n\"\r\n        \"parameter first = 1,\\n\"\r\n        \"parameter second = first\\n\"\r\n        \") ();\\n\"\r\n\t\t\"endmodule\";\r\n\r\n\tQSharedPointer<ComponentInstantiation> instance( new ComponentInstantiation );\r\n\tinstance->setName(\"module_parameter_instantiation\");\r\n\ttargetComponent->getComponentInstantiations()->append(instance);\r\n\r\n    VerilogParameterParser parser;\r\n\tparser.import(input, targetComponent, instance);\r\n\r\n    verifyParameter(targetComponent->getParameters()->at(1), \"second\", targetComponent->getParameters()->at(0)->getValueId(), \"\");\r\n\r\n    QCOMPARE(instance->getModuleParameters()->at(0)->getValue(), targetComponent->getParameters()->at(0)->getValueId());\r\n    QCOMPARE(instance->getModuleParameters()->at(1)->getValue(), targetComponent->getParameters()->at(1)->getValueId());\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_VerilogParameterParser::testArrayValue()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_VerilogParameterParser::testAnsiArrayValue()\r\n{\r\n    QFETCH(QString, input);\r\n    QFETCH(QString, expectedValue);\r\n\r\n    VerilogParameterParser parser;\r\n    QStringList declarations = parser.findDeclarations(input);\r\n\r\n    QList<QSharedPointer<ModuleParameter> > parameters = parser.parseParameters(declarations[0]);\r\n    verifyParameter(parameters[0], \"bits\", expectedValue, \"Array of bit vectors.\");\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_VerilogParameterParser::testAnsiArrayValue_data()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_VerilogParameterParser::testAnsiArrayValue_data()\r\n{\r\n    QTest::addColumn<QString>(\"input\");\r\n    QTest::addColumn<QString>(\"expectedValue\");\r\n\r\n    QTest::newRow(\"Array on a single rows\")\r\n        << \"module arrayTest #(\\n\"\r\n        \"parameter [15:0] bits = {4'h0,4'h4,4'h8,4'hF} // Array of bit vectors.\\n\"\r\n        \") ();\\n\"\r\n        \"endmodule\"\r\n        << \"{4'h0,4'h4,4'h8,4'hF}\";\r\n\r\n    QTest::newRow(\"Array on multiple rows\")\r\n        << \"module arrayTest #(\\n\"\r\n        \"parameter [15:0] bits = {4'h0,\\n\"\r\n        \"4'h4,\\n\"\r\n        \"4'h8,\\n\"\r\n        \"4'hF} // Array of bit vectors.\\n\"\r\n        \") ();\\n\"\r\n        \"endmodule\"\r\n        << \"{4'h0, 4'h4, 4'h8, 4'hF}\";\r\n\r\n    QTest::newRow(\"Array on multiple rows with trailing comments\")\r\n        << \"module arrayTest #(\\n\"\r\n        \"parameter [15:0] bits = {4'h0, // Comment #2\\n\"\r\n        \"4'h4, // Comment #2.\\n\"\r\n        \"4'h8,\\n\"\r\n        \"4'hF} // Array of bit vectors.\\n\"\r\n        \") ();\\n\"\r\n        \"endmodule\"\r\n        << \"{4'h0, 4'h4, 4'h8, 4'hF}\";\r\n\r\n    QTest::newRow(\"Empty array\")\r\n        << \"module arrayTest #(\\n\"\r\n        \"parameter [15:0] bits = {} // Array of bit vectors.\\n\"\r\n        \") ();\\n\"\r\n        \"endmodule\"\r\n        << \"{}\";\r\n}\r\n\r\nvoid tst_VerilogParameterParser::oldParameter()\r\n{\r\n    QString input = \"module shifter (\"\r\n    \");\\n\"\r\n    \"parameter evo joku=9; // ulina\\n\";\r\n\r\n    VerilogParameterParser parser;\r\n    QStringList declarations = parser.findDeclarations(input);\r\n\r\n    QList<QSharedPointer<ModuleParameter> > parameters = parser.parseParameters(declarations[0]);\r\n    verifyParameter( parameters[0], \"joku\", \"9\", \"ulina\");\r\n}\r\n\r\nvoid tst_VerilogParameterParser::multipleOldParameters()\r\n{\r\n    QString input = \"module shifter (\\n\"\r\n        \"ok tttt=8\\n\"\r\n        \");\\n\"\r\n        \"parameter joku=8; \\n\"\r\n        \"parameter jou olololoo= 1234; //hopotus\\n\"\r\n        \"parameter juuuuu = 22;//hapatus\";\r\n\r\n    VerilogParameterParser parser;\r\n    QStringList declarations = parser.findDeclarations(input);\r\n\r\n    QList<QSharedPointer<ModuleParameter> > parameters = parser.parseParameters(declarations[0]);\r\n    verifyParameter( parameters[0], \"joku\", \"8\", \"\");\r\n    parameters.append(parser.parseParameters(declarations[1]));\r\n    verifyParameter( parameters[1], \"olololoo\", \"1234\", \"hopotus\");\r\n    parameters.append(parser.parseParameters(declarations[2]));\r\n    verifyParameter( parameters[2], \"juuuuu\", \"22\", \"hapatus\");\r\n}\r\n\r\nvoid tst_VerilogParameterParser::variantOldParameters()\r\n{\r\n    QString input = \"module shifter (\\n\"\r\n        \"ok tttt=8\\n\"\r\n        \");\\n\"\r\n        \"parameter signed\trange[12:99] joku=8; \\n\"\r\n        \"parameter range[8:9] olololoo= 1234; //hopotus\\n\"\r\n        \"parameter horspo juuuuu = 22//hapatus\";\r\n\r\n    VerilogParameterParser parser;\r\n    QStringList declarations = parser.findDeclarations(input);\r\n\r\n    QList<QSharedPointer<ModuleParameter> > parameters = parser.parseParameters(declarations[0]);\r\n    verifyParameter( parameters[0], \"joku\", \"8\", \"\");\r\n    parameters.append(parser.parseParameters(declarations[1]));\r\n    verifyParameter( parameters[1], \"olololoo\", \"1234\", \"hopotus\");\r\n    parameters.append(parser.parseParameters(declarations[2]));\r\n    verifyParameter( parameters[2], \"juuuuu\", \"22\", \"hapatus\");\r\n}\r\n\r\nvoid tst_VerilogParameterParser::multiOldParameters()\r\n{\r\n    QString input = \"module shifter (\\n\"\r\n        \"ok tttt=8\\n\"\r\n        \");\\n\"\r\n        \"parameter joku=8, \\n\"\r\n        \"//vali spiikki \\n\"\r\n        \"olololoo= 1234, //hopotus\\n\"\r\n        \"juuuuu = 22;//hapatus\";\r\n\r\n    VerilogParameterParser parser;\r\n    QStringList declarations = parser.findDeclarations(input);\r\n    QList<QSharedPointer<ModuleParameter> > parameters = parser.parseParameters(declarations[0]);\r\n\r\n    verifyParameter( parameters[0], \"joku\", \"8\", \"hapatus\");\r\n    verifyParameter( parameters[1], \"olololoo\", \"1234\", \"hapatus\");\r\n    verifyParameter( parameters[2], \"juuuuu\", \"22\", \"hapatus\");\r\n}\r\n\r\nvoid tst_VerilogParameterParser::oldWithEndModule()\r\n{\r\n    QString input = \"module shifter (\\n\"\r\n        \"ok tttt=8\\n\"\r\n        \");\\n\"\r\n        \"parameter joku=8, \\n\"\r\n        \"//vali spiikki \\n\"\r\n        \"olololoo= 1234, //hopotus\\n\"\r\n        \"juuuuu = 22;//hapatus\\n\"\r\n        \"endmodule\";\r\n\r\n    VerilogParameterParser parser;\r\n    QStringList declarations = parser.findDeclarations(input);\r\n    QList<QSharedPointer<ModuleParameter> > parameters = parser.parseParameters(declarations[0]);\r\n\r\n    verifyParameter( parameters[0], \"joku\", \"8\", \"hapatus\");\r\n    verifyParameter( parameters[1], \"olololoo\", \"1234\", \"hapatus\");\r\n    verifyParameter( parameters[2], \"juuuuu\", \"22\", \"hapatus\");\r\n}\r\n\r\nvoid tst_VerilogParameterParser::doubleMultiOldParameters()\r\n{\r\n    QString input = \"module shifter (\\n\"\r\n        \"ok tttt=8\\n\"\r\n        \");\\n\"\r\n        \"parameter joku=8, \\n\"\r\n        \"//vali spiikki \\n\"\r\n        \"olololoo= 1234, //hopotus\\n\"\r\n        \"juuuuu = 22;//hapatus\\n\"\r\n        \"parameter signed def[6:5] seppox = 5,\\n\"\r\n        \"jari = 1234,\\n\"\r\n        \"jorma = 7\";\r\n\r\n    VerilogParameterParser parser;\r\n    QStringList declarations = parser.findDeclarations(input);\r\n\r\n    QList<QSharedPointer<ModuleParameter> > parameters = parser.parseParameters(declarations[0]);\r\n    verifyParameter( parameters[0], \"joku\", \"8\", \"hapatus\");\r\n    verifyParameter( parameters[1], \"olololoo\", \"1234\", \"hapatus\");\r\n    verifyParameter( parameters[2], \"juuuuu\", \"22\", \"hapatus\");\r\n    \r\n    parameters.append(parser.parseParameters(declarations[1]));\r\n    verifyParameter( parameters[3], \"seppox\", \"5\", \"\");\r\n    verifyParameter( parameters[4], \"jari\", \"1234\", \"\");\r\n    verifyParameter( parameters[5], \"jorma\", \"7\", \"\");\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_VerilogParameterParser::testOldArrayValue()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_VerilogParameterParser::testOldArrayValue()\r\n{\r\n    QFETCH(QString, input);\r\n    QFETCH(QString, expectedValue);\r\n\r\n    VerilogParameterParser parser;\r\n    QStringList declarations = parser.findDeclarations(input);\r\n\r\n    QList<QSharedPointer<ModuleParameter> > parameters = parser.parseParameters(declarations[0]);\r\n    verifyParameter(parameters[0], \"bits\", expectedValue, \"Array of bit vectors.\");\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_VerilogParameterParser::testOldArrayValue_data()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_VerilogParameterParser::testOldArrayValue_data()\r\n{\r\n    QTest::addColumn<QString>(\"input\");\r\n    QTest::addColumn<QString>(\"expectedValue\");\r\n\r\n    QTest::newRow(\"Array on a single rows\")\r\n        << \"module arrayTest();\\n\"\r\n        \"parameter [15:0] bits = {4'h0,4'h4,4'h8,4'hF}; // Array of bit vectors.\\n\"\r\n        \"endmodule\"\r\n        << \"{4'h0,4'h4,4'h8,4'hF}\";\r\n\r\n    QTest::newRow(\"Array on multiple rows\")\r\n        << \"module arrayTest();\\n\"\r\n        \"parameter [15:0] bits = {4'h0,\\n\"\r\n        \"4'h4,\\n\"\r\n        \"4'h8,\\n\"\r\n        \"4'hF}; // Array of bit vectors.\\n\"\r\n        \"endmodule\"\r\n        << \"{4'h0, 4'h4, 4'h8, 4'hF}\";\r\n\r\n    QTest::newRow(\"Array on multiple rows with trailing comments\")\r\n        << \"module arrayTest();\\n\"\r\n        \"parameter [15:0] bits = {4'h0, // Comment #1.\\n\"\r\n        \"4'h4,\\n\"\r\n        \"4'h8, // Comment #2\\n\"\r\n        \"4'hF}; // Array of bit vectors.\\n\"        \r\n        << \"{4'h0, 4'h4, 4'h8, 4'hF}\";\r\n\r\n    QTest::newRow(\"Empty array\")\r\n        << \"module arrayTest();\\n\"\r\n        \"parameter [15:0] bits = {}; // Array of bit vectors.\\n\"\r\n        \"endmodule\"\r\n        << \"{}\";\r\n}\r\n\r\nvoid tst_VerilogParameterParser::parametersToComponent()\r\n{\r\n    QString input = \"module shifter #(\\n\"\r\n        \"parameter ok joku =8,//seli\\n\"\r\n        \"parameter int juu =98, //evo\\n\"\r\n        \"parameter esa= 6, // epeli\\n\"\r\n        \" hopo = 22 // o olololo ollllooo \\n\"\r\n        \") ();\\n\"\r\n        \"endmodule\";\r\n\r\n    VLNV swvlvnv(VLNV::COMPONENT,\"kyytto\",\"raision kirjasto\",\"swName\",\"1.0\");\r\n\tQSharedPointer<Component> sw = QSharedPointer<Component>(new Component(swvlvnv, Document::Revision::Std14));\r\n\r\n\tQSharedPointer<ComponentInstantiation> instance( new ComponentInstantiation );\r\n\tinstance->setName(\"module_parameter_instantiation\");\r\n\tsw->getComponentInstantiations()->append(instance);\r\n\r\n    VerilogParameterParser parser;\r\n    parser.import(input, sw, instance);\r\n\r\n    QCOMPARE(instance->getModuleParameters()->size(), 4);\r\n    QCOMPARE(sw->getParameters()->size(), 4);\r\n    verifyParameter( sw->getParameters()->at(0), \"joku\", \"8\", \"seli\");\r\n    verifyParameter( sw->getParameters()->at(1), \"juu\", \"98\", \"evo\");\r\n    verifyParameter( sw->getParameters()->at(2), \"esa\", \"6\", \"o olololo ollllooo\");\r\n    verifyParameter( sw->getParameters()->at(3), \"hopo\", \"22\", \"o olololo ollllooo\");\r\n\r\n    QCOMPARE(instance->getModuleParameters()->at(0)->getValue(),  sw->getParameters()->at(0)->getValueId());\r\n    QCOMPARE(instance->getModuleParameters()->at(1)->getValue(),  sw->getParameters()->at(1)->getValueId());\r\n    QCOMPARE(instance->getModuleParameters()->at(2)->getValue(),  sw->getParameters()->at(2)->getValueId());\r\n    QCOMPARE(instance->getModuleParameters()->at(3)->getValue(),  sw->getParameters()->at(3)->getValueId());\r\n\r\n}\r\n\r\nvoid tst_VerilogParameterParser::oldParametersToComponent()\r\n{\r\n    QString input = \"module shifter ()\\n\"\r\n        \"parameter ok joku =8;//seli\\n\"\r\n        \"parameter int juu =98; //evo\\n\"\r\n        \"parameter esa= 6, // epeli\\n\"\r\n        \" hopo = 22; // o olololo ollllooo \\n\";\r\n\r\n    VLNV swvlvnv(VLNV::COMPONENT,\"kyytto\",\"raision kirjasto\",\"swName\",\"1.0\");\r\n    QSharedPointer<Component> sw = QSharedPointer<Component>(new Component(swvlvnv, Document::Revision::Std14));\r\n\r\n\tQSharedPointer<ComponentInstantiation> instance( new ComponentInstantiation );\r\n\tinstance->setName(\"module_parameter_instantiation\");\r\n\tsw->getComponentInstantiations()->append(instance);\r\n\r\n    VerilogParameterParser parser;\r\n    parser.import(input, sw, instance);\r\n\r\n    QCOMPARE( sw->getParameters()->size(), 4 );\r\n    QCOMPARE( instance->getModuleParameters()->size(), 4 );\r\n    verifyParameter( sw->getParameters()->at(0), \"joku\", \"8\", \"seli\");\r\n    verifyParameter( sw->getParameters()->at(1), \"juu\", \"98\", \"evo\");\r\n    verifyParameter( sw->getParameters()->at(2), \"esa\", \"6\", \"o olololo ollllooo\");\r\n    verifyParameter( sw->getParameters()->at(3), \"hopo\", \"22\", \"o olololo ollllooo\");\r\n\r\n    QCOMPARE(instance->getModuleParameters()->at(0)->getValue(),  sw->getParameters()->at(0)->getValueId());\r\n    QCOMPARE(instance->getModuleParameters()->at(1)->getValue(),  sw->getParameters()->at(1)->getValueId());\r\n    QCOMPARE(instance->getModuleParameters()->at(2)->getValue(),  sw->getParameters()->at(2)->getValueId());\r\n    QCOMPARE(instance->getModuleParameters()->at(3)->getValue(),  sw->getParameters()->at(3)->getValueId());\r\n}\r\n\r\nvoid tst_VerilogParameterParser::operations()\r\n{\r\n    QString input = \"module shifter #(\\n\"\r\n        \"parameter ok joku = 8 + 9,//seli\\n\"\r\n        \"parameter esa= 6-5, // epeli\\n\"\r\n        \"parameter int juu = 98 + 7 / ( foo*bar ), //ev(o)\\n\"\r\n        \"parameter hopo = (22)-(((7*6))) // o olololo ollllooo \\n\"\r\n        \") ();\\n\"\r\n        \"endmodule\";\r\n\r\n    VerilogParameterParser parser;\r\n    QStringList declarations = parser.findDeclarations(input);\r\n    QCOMPARE( declarations.size(), 4 );\r\n\r\n    QList<QSharedPointer<ModuleParameter> > parameters = parser.parseParameters(declarations[0]);\r\n    verifyParameter( parameters[0], \"joku\", \"8 + 9\", \"seli\");\r\n    parameters.append(parser.parseParameters(declarations[1]));\r\n    verifyParameter( parameters[1], \"esa\", \"6-5\", \"epeli\");\r\n    parameters.append(parser.parseParameters(declarations[2]));\r\n    verifyParameter( parameters[2], \"juu\", \"98 + 7 / ( foo*bar )\", \"ev(o)\");\r\n    parameters.append(parser.parseParameters(declarations[3]));\r\n    verifyParameter( parameters[3], \"hopo\", \"(22)-(((7*6)))\", \"o olololo ollllooo\");\r\n}\r\n\r\nvoid tst_VerilogParameterParser::oldOperations()\r\n{\r\n    QString input = \"module shifter ();\\n\"\r\n        \"parameter ok joku = 8 + 9;//seli\\n\"\r\n        \"parameter esa= 6-5 ;// epeli\\n\"\r\n        \"parameter int juu = 98 + 7 / ( foo*bar ); //evo\\n\"\r\n        \"parameter hopo = (22)-(((7*6))); // o olololo ollllooo \\n\"\r\n        \"endmodule\\n\";\r\n\r\n    VerilogParameterParser parser;\r\n    QStringList declarations = parser.findDeclarations(input);\r\n\r\n    QList<QSharedPointer<ModuleParameter> > parameters = parser.parseParameters(declarations[0]);\r\n    verifyParameter( parameters[0], \"joku\", \"8 + 9\", \"seli\");\r\n    parameters.append(parser.parseParameters(declarations[1]));\r\n    verifyParameter( parameters[1], \"esa\", \"6-5\", \"epeli\");\r\n    parameters.append(parser.parseParameters(declarations[2]));\r\n    verifyParameter( parameters[2], \"juu\", \"98 + 7 / ( foo*bar )\", \"evo\");\r\n    parameters.append(parser.parseParameters(declarations[3]));\r\n    verifyParameter( parameters[3], \"hopo\", \"(22)-(((7*6)))\", \"o olololo ollllooo\");\r\n}\r\n\r\nvoid tst_VerilogParameterParser::bases()\r\n{\r\n    QString input = \"module shifter #(\\n\"\r\n        \"parameter ok joku = 8'0009,//seli\\n\"\r\n        \"parameter esa= 6'000-5'h6666, // epeli\\n\"\r\n        \"parameter int juu = '98 / ( foo*bar ) ,//evo\\n\"\r\n        \"parameter hopo = '23 -'98, // o olololo ollllooo \\n\"\r\n        \") ();\\n\"\r\n        \"endmodule\";\r\n\r\n    VerilogParameterParser parser;\r\n    QStringList declarations = parser.findDeclarations(input);\r\n\r\n    QList<QSharedPointer<ModuleParameter> > parameters = parser.parseParameters(declarations[0]);\r\n    verifyParameter( parameters[0], \"joku\", \"8'0009\", \"seli\");\r\n    parameters.append(parser.parseParameters(declarations[1]));\r\n    verifyParameter( parameters[1], \"esa\", \"6'000-5'h6666\", \"epeli\");\r\n    parameters.append(parser.parseParameters(declarations[2]));\r\n    verifyParameter( parameters[2], \"juu\", \"'98 / ( foo*bar )\", \"evo\");\r\n    parameters.append(parser.parseParameters(declarations[3]));\r\n    verifyParameter( parameters[3], \"hopo\", \"'23 -'98\", \"o olololo ollllooo\");\r\n}\r\n\r\nvoid tst_VerilogParameterParser::braces()\r\n{\r\n    QString input = \"module shifter #(\\n\"\r\n        \"parameter ok joku = {8'0009},//seli\\n\"\r\n        \"parameter esa= {6'000-5'h6666}, // epeli\\n\"\r\n        \"parameter int juu = {'98} / { foo*bar } //evo\\n\"\r\n        \") ();\\n\"\r\n        \"endmodule\";\r\n\r\n    VerilogParameterParser parser;\r\n    QStringList declarations = parser.findDeclarations(input);\r\n\r\n    QList<QSharedPointer<ModuleParameter> > parameters = parser.parseParameters(declarations[0]);\r\n    verifyParameter( parameters[0], \"joku\", \"{8'0009}\", \"seli\");\r\n    parameters.append(parser.parseParameters(declarations[1]));\r\n    verifyParameter( parameters[1], \"esa\", \"{6'000-5'h6666}\", \"epeli\");\r\n    parameters.append(parser.parseParameters(declarations[2]));\r\n    verifyParameter( parameters[2], \"juu\", \"{'98} / { foo*bar }\", \"evo\");\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_VerilogParameterParser::twoDimensional()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_VerilogParameterParser::twoDimensional()\r\n{\r\n    QString input = \"module shifter #(\\n\"\r\n        \"parameter bit          [7:0] shift_type      = '{3'b001}, //joku\\n\"\r\n        \"parameter bit [count:0][1:0] mask            = '{2'b00},\\n\"\r\n        \") ();\\n\"\r\n        \"endmodule\";\r\n\r\n    VerilogParameterParser parser;\r\n    QStringList declarations = parser.findDeclarations(input);\r\n\r\n    QList<QSharedPointer<ModuleParameter> > parameters = parser.parseParameters(declarations[0]);\r\n\r\n    verifyParameter( parameters[0], \"shift_type\", \"'{3'b001}\", \"joku\");\r\n    QCOMPARE(parameters[0]->getVectorLeft(), QString(\"7\"));\r\n    QCOMPARE(parameters[0]->getVectorRight(), QString(\"0\"));\r\n    QCOMPARE(parameters[0]->getArrayLeft(),QString(\"\"));\r\n    QCOMPARE(parameters[0]->getArrayRight(),QString(\"\"));\r\n\r\n    parameters.append(parser.parseParameters(declarations[1]));\r\n    verifyParameter( parameters[1], \"mask\", \"'{2'b00}\", \"\");\r\n    QCOMPARE(parameters[1]->getArrayLeft(),QString(\"count\"));\r\n    QCOMPARE(parameters[1]->getArrayRight(),QString(\"0\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_VerilogParameterParser::closerOnLine()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_VerilogParameterParser::closerOnLine()\r\n{\r\n    QString input = \"module shifter #(\\n\"\r\n        \"parameter bit [count:1][2:0] shift_type      = '{3'b001}, //joku\\n\"\r\n        \"parameter bit [count:1][1:0] mask             = '{2'b00} ) //hopo\\n\"\r\n        \"();\\n\"\r\n        \"endmodule\";\r\n\r\n    VerilogParameterParser parser;\r\n    QStringList declarations = parser.findDeclarations(input);\r\n    QCOMPARE( declarations.size(), 2 );\r\n\r\n    QList<QSharedPointer<ModuleParameter> > parameters = parser.parseParameters(declarations[0]);\r\n    verifyParameter( parameters[0], \"shift_type\", \"'{3'b001}\", \"joku\");\r\n    QCOMPARE(parameters[0]->getVectorLeft(), QString(\"2\"));\r\n    QCOMPARE(parameters[0]->getVectorRight(), QString(\"0\"));\r\n    QCOMPARE(parameters[0]->getArrayLeft(), QString(\"count\"));\r\n    QCOMPARE(parameters[0]->getArrayRight(), QString(\"1\"));\r\n\r\n    parameters.append(parser.parseParameters(declarations[1]));\r\n    verifyParameter( parameters[1], \"mask\", \"'{2'b00}\", \"\");\r\n    QCOMPARE(parameters[1]->getVectorLeft(), QString(\"1\"));\r\n    QCOMPARE(parameters[1]->getVectorRight(), QString(\"0\"));\r\n    QCOMPARE(parameters[1]->getArrayLeft(),QString(\"count\"));\r\n    QCOMPARE(parameters[1]->getArrayRight(),QString(\"1\"));\r\n\r\n}\r\n\r\nvoid tst_VerilogParameterParser::closerOnLineDescribedparentheses()\r\n{\r\n    QString input = \"module shifter #(\\n\"\r\n        \"parameter esa= 6 ,// epeli\\n\"\r\n        \"parameter hopo = 22) // o (olololo ollllooo) \\n\"\r\n        \"();\\n\"\r\n        \"endmodule\";\r\n\r\n    VerilogParameterParser parser;\r\n    QStringList declarations = parser.findDeclarations(input);\r\n\r\n    QList<QSharedPointer<ModuleParameter> > parameters = parser.parseParameters(declarations[0]);\r\n    verifyParameter( parameters[0], \"esa\", \"6\", \"epeli\");\r\n    parameters.append(parser.parseParameters(declarations[1]));\r\n    verifyParameter( parameters[1], \"hopo\", \"22\", \"\");\r\n}\r\n\r\nvoid tst_VerilogParameterParser::closerOnLineDescribedparentheses2()\r\n{\r\n    QString input = \"module shifter #(\\n\"\r\n        \"parameter esa= 6 ,// epeli\\n\"\r\n        \"parameter hopo = 22) // o (olololo ollllooo) \\n\"\r\n        \"();\\n\"\r\n        \"endmodule\";\r\n\r\n    VerilogParameterParser parser;\r\n    QStringList declarations = parser.findDeclarations(input);\r\n\r\n    QList<QSharedPointer<ModuleParameter> > parameters = parser.parseParameters(declarations[0]);\r\n    verifyParameter( parameters[0], \"esa\", \"6\", \"epeli\");\r\n    parameters.append(parser.parseParameters(declarations[1]));\r\n    verifyParameter( parameters[1], \"hopo\", \"22\", \"\");\r\n}\r\n\r\nvoid tst_VerilogParameterParser::parenthesesInPorts()\r\n{\r\n    QString input = \"module shifter #(\\n\"\r\n        \"parameter esa= 6, // epeli\\n\"\r\n        \"parameter hopo = 22) // o (olololo ollllooo) \\n\"\r\n        \"(\\n\"\r\n        \"//joo (hkhk jkhk)\\n\"\r\n        \");\\n\"\r\n        \"endmodule\";\r\n\r\n    VerilogParameterParser parser;\r\n    QStringList declarations = parser.findDeclarations(input);\r\n\r\n    QList<QSharedPointer<ModuleParameter> > parameters = parser.parseParameters(declarations[0]);\r\n    verifyParameter( parameters[0], \"esa\", \"6\", \"epeli\");\r\n    parameters.append(parser.parseParameters(declarations[1]));\r\n    verifyParameter( parameters[1], \"hopo\", \"22\", \"\");\r\n}\r\n\r\nvoid tst_VerilogParameterParser::customCase()\r\n{\r\n    QString input = \"module verilog_bug1  # (\\n\"\r\n        \"PARAMETER_A    = 2,    // Number of external semaphore register in the design\\n\"\r\n        \"PARAMETER_B    = 0,    // Enables the KEYRAMEN (DSCON[11]) bit in the register map\\n\"\r\n        \"parameter PARAMETER_C    = 32)   // System data bus width (only valid values are 8, 16, and 32)\\n\"\r\n        \"(\\n\"\r\n        \"\\n\"\r\n        \"input        input1,                // * VDD3 Power-on-reset event\\n\"\r\n        \"\\n\"\r\n        \"output logic        input2            // * Enable the external source of the wakeup_src_mv input.\\n\"\r\n        \"`ifdef USE_INPUT3\\n\"\r\n        \", output logic [31:0] input3            // * Signals added for testchip debug\\n\"\r\n        \"`endif\\n\"\r\n        \");\\n\"\r\n        \"\\n\"\r\n    \"endmodule\";\r\n\r\n    VerilogParameterParser parser;\r\n    QStringList declarations = parser.findDeclarations(input);\r\n\r\n    QList<QSharedPointer<ModuleParameter> > parameters = parser.parseParameters(declarations[0]);\r\n    verifyParameter( parameters[0], \"PARAMETER_C\", \"32\", \"\");\r\n}\r\n\r\nQTEST_APPLESS_MAIN(tst_VerilogParameterParser)\r\n\r\n#include \"tst_VerilogParameterParser.moc\"\r\n"
  },
  {
    "path": "tests/Plugins/VerilogImport/tst_VerilogParameterParser.pri",
    "content": "# ----------------------------------------------------\r\n# This file is generated by the Qt Visual Studio Tools.\r\n# ------------------------------------------------------\r\n\r\nHEADERS += ../../../KactusAPI/include/ExpressionParser.h \\\r\n    ../../../Plugins/VerilogImport/VerilogParameterParser.h \\\r\n    ../../../Plugins/VerilogImport/VerilogSyntax.h \\\r\n    ../../../common/expressions/utilities.h\r\nSOURCES += ../../../Plugins/VerilogImport/VerilogParameterParser.cpp \\\r\n    ../../../Plugins/VerilogImport/VerilogSyntax.cpp \\\r\n    ../../../common/expressions/utilities.cpp \\\r\n    ./tst_VerilogParameterParser.cpp\r\n"
  },
  {
    "path": "tests/Plugins/VerilogImport/tst_VerilogParameterParser.pro",
    "content": "#-----------------------------------------------------------------------------\r\n# File: tst_VerilogParameterParser.pro\r\n#-----------------------------------------------------------------------------\r\n# Project: Kactus 2\r\n# Author: Esko Pekkarinen\r\n# Date: 24.7.2014\r\n#\r\n# Description:\r\n# Qt project file template for running unit tests for a single module.\r\n#-----------------------------------------------------------------------------\r\n\r\nTEMPLATE = app\r\n\r\nTARGET = tst_VerilogParameterParser\r\n\r\nQT += core xml gui testlib\r\nCONFIG += c++11 testcase console\r\n\r\nwin32:CONFIG(release, debug|release) {\r\n    LIBS += -L$$PWD/../../../executable/ -lIPXACTmodels\r\n    DESTDIR = ./release\r\n}\r\nelse:win32:CONFIG(debug, debug|release) {\r\n    LIBS += -L$$PWD/../../../executable/ -lIPXACTmodelsd\r\n    DESTDIR = ./debug\r\n}\r\nelse:unix {\r\n    LIBS += -L$$PWD/../../../executable/ -lIPXACTmodels\r\n    DESTDIR = ./release\r\n}\r\n\r\nINCLUDEPATH += $$DESTDIR\r\nINCLUDEPATH += ../../..\r\nINCLUDEPATH += $$PWD/../../../KactusAPI/include\r\n\r\nDEPENDPATH += .\r\nDEPENDPATH += ../../../\r\n\r\nOBJECTS_DIR += $$DESTDIR\r\n\r\nMOC_DIR += ./generatedFiles\r\nUI_DIR += ./generatedFiles\r\nRCC_DIR += ./generatedFiles\r\ninclude(tst_VerilogParameterParser.pri)\r\n"
  },
  {
    "path": "tests/Plugins/VerilogImport/tst_VerilogPortParser.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: tst_VerilogPortParser.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Esko Pekkarinen\r\n// Date: 24.09.2014\r\n//\r\n// Description:\r\n// Unit test for class VerilogPortParser.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include <QTest> \r\n\r\n#include <Plugins/VerilogImport/VerilogPortParser.h>\r\n\r\n#include <KactusAPI/include/ParameterFinder.h>\r\n#include <KactusAPI/include/ComponentParameterFinder.h>\r\n#include <KactusAPI/include/IPXactSystemVerilogParser.h>\r\n\r\n#include <IPXACTmodels/Component/Component.h>\r\n\r\nQ_DECLARE_METATYPE(DirectionTypes::Direction)\r\n\r\nclass tst_VerilogPortParser : public QObject\r\n{\r\n    Q_OBJECT\r\n\r\npublic:\r\n    tst_VerilogPortParser();\r\n\r\n    private slots:\r\n        void init();\r\n\r\n        // Test cases:\r\n        void testNothingIsParsedFromMalformedInput();\r\n        void testNothingIsParsedFromMalformedInput_data();\r\n\r\n        void testVerilog2001PortIsParsed();\r\n        void testVerilog2001PortIsParsed_data();\r\n\r\n        void testVerilog1995PortIsParsed();\r\n        void testVerilog1995PortIsParsed_data();\r\n\r\n        void testMultiplePortsAreParsed();\r\n        void testMultiplePortsAreParsed_data();\r\n\r\n        void testMultipleVerilog1995PortsAreParsed();\r\n        void testMultipleVerilog1995PortsAreParsed_data();\r\n\r\n        void testPortsInSubmodulesAreNotParsed();\r\n        void testPortsInSubmodulesAreNotParsed_data();\r\n\r\n        void testEquationAsPortBound();\r\n        void testEquationAsPortBound_data();\r\n\r\n        void testArrayPort();\r\n        void testArrayPort_data();\r\n\r\n        void testMacroInBoundsIsParsed();\r\n        void testMacroInBoundsIsParsed_data();\r\nprivate:\r\n\r\n    void runParser(QString const& input);   \r\n\r\n\tQSharedPointer<Component> importComponent_;\r\n\tQSharedPointer<ComponentInstantiation> importComponentInstantiation_;\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_VerilogPortParser::tst_VerilogPortParser()\r\n//-----------------------------------------------------------------------------\r\ntst_VerilogPortParser::tst_VerilogPortParser(): importComponent_(new Component(VLNV(), Document::Revision::Std14))\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_VerilogPortParser::init()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_VerilogPortParser::init()\r\n{\r\n\timportComponent_ = QSharedPointer<Component>(new Component(VLNV(), Document::Revision::Std14));\r\n\r\n\timportComponentInstantiation_ = QSharedPointer<ComponentInstantiation>( new ComponentInstantiation );\r\n\timportComponent_->getModel()->getComponentInstantiations()->append(importComponentInstantiation_);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_VerilogPortParser::testNothingIsParsedFromMalformedInput()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_VerilogPortParser::testNothingIsParsedFromMalformedInput()\r\n{\r\n    QFETCH(QString, input);\r\n\r\n    runParser(input);\r\n\r\n    QCOMPARE(importComponent_->getPorts()->count(), 0);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_VerilogPortParser::testNothingIsParsedFromMalformedInput_data()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_VerilogPortParser::testNothingIsParsedFromMalformedInput_data()\r\n{\r\n    QTest::addColumn<QString>(\"input\");\r\n\r\n    QTest::newRow(\"empty input\") << \"\";\r\n\r\n    QTest::newRow(\"no module declared\") << \"// Comment line.\";\r\n\r\n    QTest::newRow(\"module without parathesis around port declarations\") << \r\n        \"module test\\n\"\r\n        \"input clk\\n\"\r\n        \"endmodule\";\r\n\r\n    QTest::newRow(\"module without closing parathesis for port declarations\") << \r\n        \"module test(\\n\"\r\n        \"input clk\\n\"\r\n        \"endmodule\";\r\n\r\n    QTest::newRow(\"module without endmodule\") << \r\n        \"module test(\\n\"\r\n        \"    input clk\\n\"\r\n        \");\";\r\n\r\n    QTest::newRow(\"Unknown direction\") <<\r\n        \"module test (\\n\"\r\n        \"    in data\\n\"\r\n        \");\\n\"\r\n        \"endmodule\";\r\n\r\n\r\n    QTest::newRow(\"Illegal characters in port name\") <<\r\n        \"module test (\\n\"\r\n        \"    input data%for\\n\"\r\n        \");\\n\"\r\n        \"endmodule\";\r\n\r\n    QTest::newRow(\"Signed 1995-style port.\") <<\r\n        \"module test (data);\\n\"\r\n        \"    output wire signed [2:0] data; // 2's complement data.\\n\"\r\n        \"\\n\"\r\n        \"endmodule\";\r\n\r\n    QTest::newRow(\"Port after endmodule\") <<\r\n        \"module test (data);\\n\"\r\n        \"endmodule\\n\"\r\n        \"    input data;\";\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_VerilogPortParser::runParser()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_VerilogPortParser::runParser(QString const& input)\r\n{\r\n    QSharedPointer<ParameterFinder> finder(new ComponentParameterFinder(importComponent_));\r\n    QSharedPointer<ExpressionParser> expressionParser(new IPXactSystemVerilogParser(finder));\r\n\r\n    VerilogPortParser parser;\r\n    parser.setExpressionParser(expressionParser);\r\n\r\n    parser.import(input, importComponent_);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_VerilogPortParser::testPortIsParsed()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_VerilogPortParser::testVerilog2001PortIsParsed()\r\n{\r\n    QFETCH(QString, input);\r\n    QFETCH(QString, expectedPortName);\r\n    QFETCH(QString, expectedType);\r\n    QFETCH(DirectionTypes::Direction, expectedDirection);\r\n    QFETCH(QString, expectedLeft);\r\n    QFETCH(QString, expectedRight);\r\n    QFETCH(QString, expectedDescription);\r\n\r\n    runParser(input);\r\n\r\n    QCOMPARE(importComponent_->getPorts()->count(), 1);\r\n\r\n    QSharedPointer<Port> createdPort = importComponent_->getPorts()->first();\r\n\r\n    QCOMPARE(createdPort->name(), expectedPortName);\r\n    QCOMPARE(createdPort->getTypeName(), expectedType);\r\n    QCOMPARE(createdPort->getDirection(), expectedDirection);\r\n    QCOMPARE(createdPort->getLeftBound(), expectedLeft);\r\n    QCOMPARE(createdPort->getRightBound(), expectedRight);\r\n    QCOMPARE(createdPort->description(), expectedDescription);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_VerilogPortParser::testPortIsParsed_data()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_VerilogPortParser::testVerilog2001PortIsParsed_data()\r\n{\r\n    QTest::addColumn<QString>(\"input\");\r\n    QTest::addColumn<QString>(\"expectedPortName\");\r\n    QTest::addColumn<QString>(\"expectedType\");\r\n    QTest::addColumn<DirectionTypes::Direction>(\"expectedDirection\");\r\n    QTest::addColumn<QString>(\"expectedLeft\");\r\n    QTest::addColumn<QString>(\"expectedRight\");\r\n    QTest::addColumn<QString>(\"expectedDescription\");\r\n\r\n    QTest::newRow(\"Simplest possible port\") <<\r\n        \"module test (\\n\"\r\n        \"    input clk\\n\"\r\n        \");\\n\"\r\n        \"endmodule\"\r\n        << \"clk\" << \"\" << DirectionTypes::IN << \"\" << \"\" << \"\";\r\n\r\n    QTest::newRow(\"Typed port\") <<\r\n        \"module test (\\n\"\r\n        \"    output reg data\\n\"\r\n        \");\\n\"\r\n        \"endmodule\"\r\n        << \"data\" << \"reg\" <<  DirectionTypes::OUT << \"\" << \"\" << \"\";\r\n\r\n    QTest::newRow(\"Little-endian port\") <<\r\n        \"module test (\\n\"\r\n        \"    input [7:0] data\\n\"\r\n        \");\\n\"\r\n        \"endmodule\"\r\n        << \"data\" << \"\" <<  DirectionTypes::IN << \"7\" << \"0\" << \"\";\r\n\r\n    QTest::newRow(\"Big-endian port\") <<\r\n        \"module test (\\n\"\r\n        \"    input [0:7] data\\n\"\r\n        \");\\n\"\r\n        \"endmodule\"\r\n        << \"data\" << \"\" <<  DirectionTypes::IN << \"0\" << \"7\" << \"\";\r\n\r\n    QTest::newRow(\"Typed four-bit port\") <<\r\n        \"module test (\\n\"\r\n        \"    inout tri [3:0] data\\n\"\r\n        \");\\n\"\r\n        \"endmodule\"\r\n        << \"data\" << \"tri\" <<  DirectionTypes::INOUT << \"3\" << \"0\" << \"\";\r\n\r\n    QTest::newRow(\"Comment as a description.\") <<\r\n        \"module test (\\n\"\r\n        \"    input rst_n // Active low reset.\\n\"\r\n        \");\\n\"\r\n        \"endmodule\"\r\n        << \"rst_n\" << \"\" <<  DirectionTypes::IN << \"\" << \"\" << \"Active low reset.\";\r\n\r\n    QTest::newRow(\"Signed port.\") <<\r\n        \"module test (\\n\"\r\n        \"    output wire signed [2:0] data // 2's complement data.\\n\"\r\n        \");\\n\"\r\n        \"endmodule\"\r\n        << \"data\" << \"\" <<  DirectionTypes::OUT << \"2\" << \"0\" << \"2's complement data.\";\r\n\r\n    QTest::newRow(\"Additional whitespaces in port declaration\") <<\r\n        \"module test (output \\n\"\r\n        \"reg\\n\"\r\n        \"\\n\"\r\n        \"    [1:0] \\n\"\r\n        \"    cs    //Chip select\\n\"\r\n        \");\\n\"\r\n        \"endmodule\"\r\n        << \"cs\" << \"reg\" <<  DirectionTypes::OUT << \"1\" << \"0\" << \"Chip select\";\r\n\r\n    QTest::newRow(\"Module with parameters.\") <<\r\n        \"module test #(parameter id = 1) (\\n\"\r\n        \"    input clk\\n\"\r\n        \");\\n\"\r\n        \"endmodule\"\r\n        << \"clk\" << \"\" <<  DirectionTypes::IN << \"\" << \"\" << \"\";\r\n\r\n    QTest::newRow(\"Port type with keyword wire.\") <<\r\n        \"module test (\\n\"\r\n        \"    output wire logic [2:0] cs\\n\"\r\n        \");\\n\"\r\n        \"endmodule\"\r\n        << \"cs\" << \"logic\" << DirectionTypes::OUT << \"2\" << \"0\" << \"\";\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_VerilogPortParser::testVerilog1995PortIsParsed()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_VerilogPortParser::testVerilog1995PortIsParsed()\r\n{\r\n    QFETCH(QString, input);\r\n    QFETCH(QString, expectedPortName);\r\n    QFETCH(QString, expectedType);\r\n    QFETCH(DirectionTypes::Direction, expectedDirection);\r\n    QFETCH(QString, expectedLeft);\r\n    QFETCH(QString, expectedRight);\r\n    QFETCH(QString, expectedDescription);\r\n\r\n    runParser(input);\r\n\r\n    QCOMPARE(importComponent_->getPorts()->count(), 1);\r\n\r\n    QSharedPointer<Port> createdPort = importComponent_->getPorts()->first();\r\n\r\n    QCOMPARE(createdPort->name(), expectedPortName);\r\n    QCOMPARE(createdPort->getTypeName(), expectedType);\r\n    QCOMPARE(createdPort->getDirection(), expectedDirection);\r\n    QCOMPARE(createdPort->getLeftBound(), expectedLeft);\r\n    QCOMPARE(createdPort->getRightBound(), expectedRight);\r\n    QCOMPARE(createdPort->description(), expectedDescription);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_VerilogPortParser::testVerilog1995PortIsParsed()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_VerilogPortParser::testVerilog1995PortIsParsed_data()\r\n{\r\n    QTest::addColumn<QString>(\"input\");\r\n    QTest::addColumn<QString>(\"expectedPortName\");\r\n    QTest::addColumn<QString>(\"expectedType\");\r\n    QTest::addColumn<DirectionTypes::Direction>(\"expectedDirection\");\r\n    QTest::addColumn<QString>(\"expectedLeft\");\r\n    QTest::addColumn<QString>(\"expectedRight\");\r\n    QTest::addColumn<QString>(\"expectedDescription\");\r\n\r\n    QTest::newRow(\"Simplest possible port\") <<\r\n        \"module test (clk);\\n\"\r\n        \"    input clk;\\n\"\r\n        \"\\n\"\r\n        \"endmodule\"\r\n        << \"clk\" << \"\" << DirectionTypes::IN << \"\" << \"\" << \"\";\r\n\r\n    QTest::newRow(\"Little-endian port\") <<\r\n    \"module test (data);\\n\"\r\n    \"    input reg [7:0] data;\\n\"\r\n    \"\\n\"\r\n    \"endmodule\"\r\n    << \"data\" << \"reg\" <<  DirectionTypes::IN << \"7\" << \"0\" << \"\";\r\n\r\n    QTest::newRow(\"Big-endian port\") <<\r\n    \"module test (data);\\n\"\r\n    \"    input [0:7] data;\\n\"\r\n    \"\\n\"\r\n    \"endmodule\"\r\n    << \"data\" << \"\" <<  DirectionTypes::IN << \"0\" << \"7\" << \"\";\r\n    \r\n    QTest::newRow(\"Comment as a description.\") <<\r\n    \"module test (rst_n);\\n\"\r\n    \"    input wire rst_n; // Active low reset.\\n\"\r\n    \"\\n\"\r\n    \"endmodule\"\r\n    << \"rst_n\" << \"\" <<  DirectionTypes::IN << \"\" << \"\" << \"Active low reset.\";\r\n\r\n    QTest::newRow(\"Additional whitespaces in port declaration\") <<\r\n    \"module test (cs);output \\n\"\r\n    \"\\n\"\r\n    \"    [1:0] \\n\"\r\n    \"    cs  ;  //Chip select\\n\"\r\n    \"\\n\"\r\n    \"endmodule\"\r\n    << \"cs\" << \"\" <<  DirectionTypes::OUT << \"1\" << \"0\" << \"Chip select\";\r\n\r\n    QTest::newRow(\"Module with parameters.\") <<\r\n    \"module test (clk);\\n\"\r\n    \"    parameter size = 8;\"\r\n    \"    input clk;\\n\"\r\n    \"\\n\"\r\n    \"endmodule\"\r\n    << \"clk\" << \"\" <<  DirectionTypes::IN << \"\" << \"\" << \"\";\r\n\r\n    QTest::newRow(\"Keywords in comments within implementation.\") <<\r\n        \"module test (data);\\n\"        \r\n        \"    input data;\\n\"\r\n        \"\\n\"\r\n        \"wire data;   // Data input\\n\"\r\n        \"wire data_out;  // Data output\\n\"\r\n        \"\\n\"\r\n        \"endmodule\"\r\n        << \"data\" << \"\" <<  DirectionTypes::IN << \"\" << \"\" << \"\";\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_VerilogPortParser::testMultiplePortsAreParsed()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_VerilogPortParser::testMultiplePortsAreParsed()\r\n{\r\n    QFETCH(QString, input);\r\n    QFETCH(QStringList, expectedPorts);\r\n\r\n    runParser(input);\r\n\r\n    QCOMPARE(importComponent_->getPortNames(), expectedPorts);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_VerilogPortParser::testMultiplePortsAreParsed_data()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_VerilogPortParser::testMultiplePortsAreParsed_data()\r\n{\r\n    QTest::addColumn<QString>(\"input\");\r\n    QTest::addColumn<QStringList>(\"expectedPorts\");\r\n\r\n    QTest::newRow(\"Three basic ports\") <<\r\n        \"module test (\\n\"\r\n        \"    input clk,\\n\"\r\n        \"    input rst_n,\\n\"\r\n        \"    output reg [7:0] data\\n\"\r\n        \");\\n\"\r\n        \"endmodule\"\r\n        << QString(\"clk, rst_n, data\").split(\", \");\r\n\r\n    QTest::newRow(\"Comments among ports\") <<\r\n        \"module test ( // Ports are declared here.\\n\"\r\n        \"    input clk,\\n\"  \r\n        \"    // Comment between ports.\\n\"\r\n        \"    input rst_n\\n\"\r\n        \"    // End ports.\\n\"\r\n        \");\\n\"\r\n        \"endmodule\" \r\n        << QString(\"clk, rst_n\").split(\", \");\r\n\r\n    QTest::newRow(\"Multiple declarations at once\") <<\r\n        \"module test (\\n\"\r\n        \"    input clk, rst_n, enable,\\n\" \r\n        \"    output full, ack\\n\" \r\n        \");\\n\"\r\n        \"endmodule\"\r\n        << QString(\"clk, rst_n, enable, full, ack\").split(\", \");\r\n\r\n    // TODO: Syntactical error. What is the correct behavior?\r\n    QTest::newRow(\"last port with tailing colon\") << \r\n        \"module test(\\n\"\r\n        \"    input clk,\\n\"\r\n        \"    input rst,\\n\"\r\n        \"    input enable,\\n\"\r\n        \");\\n\"\r\n        \"endmodule\"\r\n        << QString(\"clk, rst, enable\").split(\", \");\r\n\r\n    QTest::newRow(\"Commented out ports\") << \r\n        \"module test(\\n\"\r\n        \"    //input clk,\\n\"\r\n        \"    //input rst,\\n\"\r\n        \"    input enable\\n\"\r\n        \");\\n\"\r\n        \"endmodule\"\r\n        << QString(\"enable\").split(\", \");\r\n\r\n    QTest::newRow(\"Commented out ports using multiline comment\") << \r\n        \"module test(\\n\"\r\n        \"    input clk,\\n\"        \r\n        \"    input rst,\\n\"\r\n        \"/* COMMENT OUT FOR SYNTHESIS\\n\"\r\n        \"    output sim_value,\\n\"\r\n        \"    output sim_debug,\\n\"\r\n        \"*/\\n\"\r\n        \"    input enable \\n\"\r\n        \");\\n\"\r\n        \"endmodule\"\r\n        << QString(\"clk, rst, enable\").split(\", \");\r\n\r\n    QTest::newRow(\"Misplaced comma\") << \r\n        \"module test(\\n\"\r\n        \"    input clk,\\n\" \r\n        \"    input rst\\n\"\r\n        \"    ,input enable \\n\"\r\n        \");\\n\"\r\n        \"endmodule\"\r\n        << QString(\"clk, rst, enable\").split(\", \");\r\n\r\n        QTest::newRow(\"Conditional ports\") << \r\n        \"module test(\\n\"\r\n        \"    `ifdef SYNCHRONOUS\\n\"\r\n        \"    input clk,\\n\" \r\n        \"    `endif\\n\"\r\n        \"    input rst\\n\"\r\n        \"    `ifdef ENABLE_PIN\\n\"\r\n        \"    ,input enable \\n\"\r\n        \"    `endif\\n\"\r\n        \");\\n\"\r\n        \"endmodule\"\r\n        << QString(\"clk, rst, enable\").split(\", \");\r\n\r\n        QTest::newRow(\"Conditional port and comma on next line\") << \r\n            \"module test(\\n\"\r\n            \"    input clk\\n\" \r\n            \"    `ifdef EXTERNAL_RESET\\n\"\r\n            \"    ,input rst // reset\\n\"\r\n            \"    `endif\\n\"\r\n            \"    `ifdef ENABLE_PIN\\n\"\r\n            \"    ,input enable\\n\"\r\n            \"    `endif\\n\"\r\n            \");\\n\"\r\n            \"endmodule\"\r\n            << QString(\"clk, rst, enable\").split(\", \");\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_VerilogPortParser::testMultipleVerilog1995PortsAreParsed()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_VerilogPortParser::testMultipleVerilog1995PortsAreParsed()\r\n{\r\n    testMultiplePortsAreParsed();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_VerilogPortParser::testMultipleVerilog1995PortsAreParsed_data()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_VerilogPortParser::testMultipleVerilog1995PortsAreParsed_data()\r\n{\r\n    QTest::addColumn<QString>(\"input\");\r\n    QTest::addColumn<QStringList>(\"expectedPorts\");\r\n\r\n    QTest::newRow(\"Three basic ports\") <<\r\n        \"module test (clk, rst_n, data);\\n\"\r\n        \"    input clk;\\n\"\r\n        \"    input rst_n;\\n\"\r\n        \"    output [7:0] data;\\n\"\r\n        \"\\n\"\r\n        \"endmodule\"\r\n        << QString(\"clk, rst_n, data\").split(\", \");\r\n    \r\n    QTest::newRow(\"Comments among ports\") <<\r\n        \"module test ( // Ports are declared here.\\n\"\r\n        \"clk, // Only names declared here.\\n\"\r\n        \"rst_n);\"\r\n        \"    // Declare also direction for ports.\\n\"\r\n        \"    input clk;\\n\"  \r\n        \"    // Comment between ports.\\n\"\r\n        \"    input rst_n;\\n\"\r\n        \"    // End ports.\\n\"\r\n        \"\\n\"\r\n        \"endmodule\" \r\n        << QString(\"clk, rst_n\").split(\", \");\r\n    \r\n    QTest::newRow(\"Multiple declarations at once\") <<\r\n        \"module test (clk, rst_n, enable, full, ack);\\n\"\r\n        \"    input clk, rst_n, enable;\\n\" \r\n        \"    output full, ack;\\n\" \r\n        \"\\n\"\r\n        \"endmodule\"\r\n        << QString(\"clk, rst_n, enable, full, ack\").split(\", \");\r\n\r\n    QTest::newRow(\"last port without tailing semicolon\") << \r\n        \"module test(clk, rst, enable);\\n\"\r\n        \"    input clk;\\n\"\r\n        \"    input rst;\\n\"\r\n        \"    input enable\\n\"\r\n        \"\\n\"\r\n        \"endmodule\"\r\n        << QString(\"clk, rst\").split(\", \");\r\n\r\n    QTest::newRow(\"Commented out ports\") << \r\n        \"module test(//clk, rst, \\n\"\r\n        \"            enable);\\n\"\r\n        \"    //input clk;\\n\"\r\n        \"    //input rst;\\n\"\r\n        \"    input enable;\\n\"\r\n        \"\\n\"\r\n        \"endmodule\"\r\n        << QString(\"enable\").split(\", \");\r\n\r\n    QTest::newRow(\"Commented out ports using multiline commments\") << \r\n        \"module test(clk, rst, /* sim_value, sim_debug, */ enable);\\n\"\r\n        \"    input clk;\\n\"\r\n        \"    input rst;\\n\"\r\n        \"/* COMMENT OUT FOR SYNTHESIS\\n\"\r\n        \"    output sim_value;\\n\"\r\n        \"    output sim_debug;\\n\"\r\n        \"*/\\n\"\r\n        \"    input enable;\\n\"\r\n        \"\\n\"\r\n        \"endmodule\"\r\n        << QString(\"clk, rst, enable\").split(\", \");    \r\n    \r\n    QTest::newRow(\"Port definition in port list commments\") << \r\n        \"module test(clk, // input mask,\\n\"\r\n        \"rst,\\n\"\r\n        \"enable);\\n\"\r\n        \"    input clk;\\n\"\r\n        \"    input rst;\\n\"\r\n        \"    input enable;\\n\"\r\n        \"\\n\"\r\n        \"endmodule\"\r\n        << QString(\"clk, rst, enable\").split(\", \");   \r\n\r\n    QTest::newRow(\"C\") << \r\n        \"module  multiport (\\n\"\r\n        \"\\n\"\r\n        \"// output ports\\n\"\r\n        \"port1,                         // Comment on port\\n\"\r\n        \"port2,                         // Comment\\n\"\r\n        \"port3,                         // Comment\\n\"\r\n        \"port4,                         // Comment\\n\"\r\n        \"port5,                         // Comment\\n\"\r\n        \"port6,                         // Comment\\n\"\r\n        \"port7,                         // Comment\\n\"\r\n        \"port8,                         // Comment\\n\"\r\n        \"port9,                         // Comment\\n\"\r\n        \"port10,                        // Comment on port\\n\"\r\n        \"port11,                        // Comment\\n\"\r\n        \"port12,                        // Comment\\n\"\r\n        \"port13,                        // Comment\\n\"\r\n        \"port14,                        // Comment\\n\"\r\n        \"port15,                        // Comment\\n\"\r\n        \"port16,                        // Comment\\n\"\r\n        \"port17,                        // Comment\\n\"\r\n        \"port18,                        // Comment\\n\"\r\n        \"port19,                        // Comment\\n\"\r\n        \"port20,                        // Comment on port\\n\"\r\n        \"port21,                        // Comment\\n\"\r\n        \"port22,                        // Comment\\n\"\r\n        \"port23,                        // Comment\\n\"\r\n        \"port24,                        // Comment\\n\"\r\n        \"port25,                        // Comment\\n\"\r\n        \"port26,                        // Comment\\n\"\r\n        \"port27,                        // Comment\\n\"\r\n        \"\\n\"\r\n        \"// input ports\\n\"\r\n        \"port28,                        // Comment\\n\"\r\n        \"port29,                        // Comment\\n\"\r\n        \"port30,                        // Comment on port\\n\"\r\n        \"port31,                        // Comment\\n\"\r\n        \"port32,                        // Comment\\n\"\r\n        \"port33,                        // Comment\\n\"\r\n        \"port34,                        // Comment\\n\"\r\n        \"port35,                        // Comment\\n\"\r\n        \"port36,                        // Comment\\n\"\r\n        \"port37,                        // Comment\\n\"\r\n        \"port38,                        // Comment\\n\"\r\n        \"port39,                        // Comment\\n\"\r\n        \"port40,                        // Comment on port\\n\"\r\n        \"port41,                        // Comment\\n\"\r\n        \"port42,                        // Comment\\n\"\r\n        \"port43,                        // Comment\\n\"\r\n        \"port44,                        // Comment\\n\"\r\n        \"port45,                        // Comment\\n\"\r\n        \"port46,                        // Comment\\n\"\r\n        \"port47,                        // Comment\\n\"\r\n        \"port48,                        // Comment\\n\"\r\n        \"port49,                        // Comment\\n\"\r\n        \"port50                         // Comment on last port\\n\"\r\n        \");\\n\"\r\n        \"\\n\"\r\n        \"//=============================================================================\\n\"\r\n        \"// output ports\\n\"\r\n        \"//=============================================================================\\n\"\r\n        \"output               port1;    // Comment on port\\n\"\r\n        \"output               port2;    // Comment\\n\"\r\n        \"output         [1:0] port3;    // Comment\\n\"\r\n        \"output               port4;    // Comment\\n\"\r\n        \"output         [2:0] port5;    // Comment\\n\"\r\n        \"output         [3:0] port6;    // Comment\\n\"\r\n        \"output         [4:0] port7;    // Comment\\n\"\r\n        \"output               port8;    // Comment\\n\"\r\n        \"output         [5:0] port9;    // Comment\\n\"\r\n        \"output         [6:0] port10;   // Comment on port\\n\"\r\n        \"output               port11;   // Comment\\n\"\r\n        \"output         [7:0] port12;   // Comment\\n\"\r\n        \"output               port13;   // Comment\\n\"\r\n        \"output         [8:0] port14;   // Comment\\n\"\r\n        \"output         [9:0] port15;   // Comment\\n\"\r\n        \"output        [10:0] port16;   // Comment\\n\"\r\n        \"output               port17;   // Comment\\n\"\r\n        \"output  [`PARAM-1:0] port18;   // Comment\\n\"\r\n        \"output               port19;   // Comment\\n\"\r\n        \"output               port20;   // Comment on port\\n\"\r\n        \"output               port21;   // Comment\\n\"\r\n        \"output               port22;   // Comment\\n\"\r\n        \"output               port23;   // Comment\\n\"\r\n        \"output               port24;   // Comment\\n\"\r\n        \"output               port25;   // Comment\\n\"\r\n        \"output               port26;   // Comment\\n\"\r\n        \"output               port27;   // Comment\\n\"\r\n        \"\\n\"\r\n        \"//=============================================================================\\n\"\r\n        \"// input ports\\n\"\r\n        \"//=============================================================================\\n\"\r\n        \"input                port28;   // Comment\\n\"\r\n        \"input                port29;   // Comment\\n\"\r\n        \"input                port30;   // Comment on port\\n\"\r\n        \"input                port31;   // Comment\\n\"\r\n        \"input                port32;   // Comment\\n\"\r\n        \"input                port33;   // Comment\\n\"\r\n        \"input                port34;   // Comment\\n\"\r\n        \"input                port35;   // Comment\\n\"\r\n        \"input                port36;   // Comment\\n\"\r\n        \"input                port37;   // Comment\\n\"\r\n        \"input                port38;   // Comment\\n\"\r\n        \"input                port39;   // Comment\\n\"\r\n        \"input                port40;   // Comment on port\\n\"\r\n        \"input                port41;   // Comment\\n\"\r\n        \"input                port42;   // Comment\\n\"\r\n        \"input                port43;   // Comment\\n\"\r\n        \"input                port44;   // Comment\\n\"\r\n        \"input                port45;   // Comment\\n\"\r\n        \"input                port46;   // Comment\\n\"\r\n        \"input                port47;   // Comment\\n\"\r\n        \"input                port48;   // Comment\\n\"\r\n        \"input                port49;   // Comment\\n\"\r\n        \"input                port50;   // Comment on last port\\n\"\r\n        \"\\n\"\r\n        \"//=============================================================================\\n\"\r\n        \"// Module implementation ... \\n\"\r\n        \"//=============================================================================\\n\"\r\n        \"endmodule\"\r\n\r\n        << QString(\"port1, port2, port3, port4, port5, port6, port7, port8, port9, port10, \"\r\n        \"port11, port12, port13, port14, port15, port16, port17, port18, port19, port20, \"\r\n        \"port21, port22, port23, port24, port25, port26, port27, port28, port29, port30, \"\r\n        \"port31, port32, port33, port34, port35, port36, port37, port38, port39, port40, \"\r\n        \"port41, port42, port43, port44, port45, port46, port47, port48, port49, port50\").split(\", \");\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_VerilogPortParser::testPortsInSubmodulesAreNotParsed()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_VerilogPortParser::testPortsInSubmodulesAreNotParsed()\r\n{\r\n    testMultiplePortsAreParsed();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_VerilogPortParser::testPortsInSubmodulesAreNotParsed()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_VerilogPortParser::testPortsInSubmodulesAreNotParsed_data()\r\n{\r\n    QTest::addColumn<QString>(\"input\");\r\n    QTest::addColumn<QStringList>(\"expectedPorts\");\r\n\r\n    QTest::newRow(\"Instantiation of submodule\") <<\r\n        \"module tb_half_adder();\\n\"\r\n        \"    wire A;\\n\"\r\n        \"    wire B;\\n\"\r\n        \"    wire result_out;\\n\"\r\n        \"    wire carry_out;\\n\"\r\n        \"\\n\"\r\n        \"    half_adder dut(\\n\"\r\n        \"        .in1(A),\\n\"\r\n        \"        .in2(B),\\n\"\r\n        \"        .sum(result_out),\\n\"\r\n        \"        .carry(carry_out)\\n\"\r\n        \"    );\\n\"    \r\n        \"// ... \\n\"\r\n        \"\\n\"\r\n        \"endmodule\"\r\n        << QStringList();\r\n\r\n    QTest::newRow(\"Instantiation of multiple submodules\") <<\r\n        \"module full_adder(\\n\"\r\n        \"    input A, B, carry_in,\\n\"\r\n        \"    output sum, carry_out\\n\"\r\n        \");\\n\"                \r\n        \"    wire ha1_ha2_sum;\\n\"\r\n        \"    wire c1;\\n\"\r\n        \"    wire c2;\\n\"\r\n        \"\\n\"\r\n        \"    half_adder ha1(\\n\"\r\n        \"        .in1(A),\\n\"\r\n        \"        .in2(B),\\n\"\r\n        \"        .sum(ha1_ha2_sum),\\n\"\r\n        \"        .carry(c1)\\n\"\r\n        \"    );\\n\"    \r\n        \"\\n\"\r\n        \"    half_adder ha2(\\n\"\r\n        \"        .in1(ha1_ha2_sum),\\n\"\r\n        \"        .in2(carry_in),\\n\"\r\n        \"        .sum(sum),\\n\"\r\n        \"        .carry(c2)\\n\"\r\n        \"    );\\n\"   \r\n        \"\\n\"\r\n        \"    or (carry_out, c1, c2);\"\r\n        \"\\n\"\r\n        \"endmodule\"\r\n        << QString(\"A, B, carry_in, sum, carry_out\").split(\", \");\r\n\r\n    QTest::newRow(\"Instantiation of multiple submodules using 1995 style module\") <<\r\n        \"module full_adder(A, B, carry_in, sum, carry_out);\\n\"                \r\n        \"    input A, B, carry_in;\\n\"\r\n        \"    output sum, carry_out;\\n\"\r\n        \"\\n\"\r\n        \"    wire ha1_ha2_sum;\\n\"\r\n        \"    wire c1;\\n\"\r\n        \"    wire c2;\\n\"\r\n        \"\\n\"\r\n        \"    half_adder ha1(\\n\"\r\n        \"        .in1(A),\\n\"\r\n        \"        .in2(B),\\n\"\r\n        \"        .sum(ha1_ha2_sum),\\n\"\r\n        \"        .carry(c1)\\n\"\r\n        \"    );\\n\"    \r\n        \"\\n\"\r\n        \"    half_adder ha2(\\n\"\r\n        \"        .in1(ha1_ha2_sum),\\n\"\r\n        \"        .in2(carry_in),\\n\"\r\n        \"        .sum(sum),\\n\"\r\n        \"        .carry(c2)\\n\"\r\n        \"    );\\n\"   \r\n        \"\\n\"\r\n        \"    or (carry_out, c1, c2);\"\r\n        \"\\n\"\r\n        \"endmodule\"\r\n        << QString(\"A, B, carry_in, sum, carry_out\").split(\", \");\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_VerilogPortParser::testEquationAsPortBound()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_VerilogPortParser::testEquationAsPortBound()\r\n{\r\n    QFETCH(QString, fileContent);\r\n    QFETCH(QString, expectedLeftExpression);\r\n    QFETCH(QString, expectedRightExpression);\r\n\r\n    runParser(fileContent);\r\n\r\n    QVERIFY2(importComponent_->getPorts()->count() != 0, \"No ports parsed from input.\");\r\n\r\n    QSharedPointer<Port> createdPort = importComponent_->getPorts()->first();\r\n    QCOMPARE(createdPort->getLeftBound(), expectedLeftExpression);\r\n    QCOMPARE(createdPort->getRightBound(), expectedRightExpression);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_VerilogPortParser::testEquationAsPortBound_data()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_VerilogPortParser::testEquationAsPortBound_data()\r\n{\r\n    QTest::addColumn<QString>(\"fileContent\");\r\n    QTest::addColumn<QString>(\"expectedLeftExpression\");\r\n    QTest::addColumn<QString>(\"expectedRightExpression\");\r\n\r\n    QTest::newRow(\"Subtraction\") <<\r\n        \"module test(\\n\"\r\n        \"    input [2-1:0] data\\n\"\r\n        \");\\n\"\r\n        \"endmodule\\n\"\r\n        << \"2-1\" << \"0\";\r\n\r\n    QTest::newRow(\"Both bounds with multiply\") <<\r\n        \"module test(\\n\"\r\n        \"    input [2*4-1:2*1] data\\n\"\r\n        \");\\n\"\r\n        \"endmodule\\n\"\r\n        << \"2*4-1\" << \"2*1\";\r\n\r\n    QTest::newRow(\"Power of two\") <<\r\n        \"module test(\\n\"\r\n        \"    input [2**4:0] data\\n\"\r\n        \");\\n\"\r\n        \"endmodule\\n\"\r\n        << \"2**4\" << \"0\";\r\n\r\n    QTest::newRow(\"Power of zero\") <<\r\n        \"module test(\\n\"\r\n        \"    input [8**0:0] data\\n\"\r\n        \");\\n\"\r\n        \"endmodule\\n\"\r\n        << \"8**0\" << \"0\";\r\n\r\n    QTest::newRow(\"Multiple operations in mixed order\") <<\r\n        \"module test(\\n\"\r\n        \"    input [32-2**4+2*4:0] data\\n\"\r\n        \");\\n\"\r\n        \"endmodule\\n\"\r\n        << \"32-2**4+2*4\" << \"0\";\r\n\r\n    QTest::newRow(\"Division\") <<\r\n        \"module test(\\n\"\r\n        \"    input [32/2:0/2] data\\n\"\r\n        \");\\n\"\r\n        \"endmodule\\n\"\r\n        << \"32/2\" << \"0/2\";\r\n\r\n    QTest::newRow(\"Division by zero results zero\") <<\r\n        \"module test(\\n\"\r\n        \"    input [32/0:0] data\\n\"\r\n        \");\\n\"\r\n        \"endmodule\\n\"\r\n        << \"32/0\" << \"0\";\r\n\r\n    QTest::newRow(\"Ternary operation in width\") <<\r\n        \"module test(\\n\"\r\n        \"    input [1?15:0:0] data\\n\"\r\n        \");\\n\"\r\n        \"endmodule\\n\"\r\n        << \"1?15:0\" << \"0\";\r\n\r\n    QTest::newRow(\"Nested ternary operation in width\") <<\r\n        \"module test(\\n\"\r\n        \"    input [1?2?3:0:0:0] data\\n\"\r\n        \");\\n\"\r\n        \"endmodule\\n\"\r\n        << \"1?2?3:0:0\" << \"0\";\r\n\r\n    QTest::newRow(\"Ternary operation in left and right bound\") <<\r\n        \"module test(\\n\"\r\n        \"    input [1?2:0:0?2:0] data\\n\"\r\n        \");\\n\"\r\n        \"endmodule\\n\"\r\n        << \"1?2:0\" << \"0?2:0\";\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_VerilogPortParser::testArrayPort()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_VerilogPortParser::testArrayPort()\r\n{\r\n    QSharedPointer<Parameter> macroDefinition(new Parameter());\r\n    macroDefinition->setName(\"WIDTH\");\r\n    macroDefinition->setValue(\"16\");\r\n    macroDefinition->setValueId(\"macroId\");\r\n    importComponent_->getParameters()->append(macroDefinition);\r\n\r\n    QFETCH(QString, fileContent);\r\n    QFETCH(QString, expectedLeftExpression);\r\n    QFETCH(QString, expectedRightExpression);\r\n\r\n    runParser(fileContent);\r\n\r\n    QVERIFY2(importComponent_->getPorts()->count() != 0, \"No ports parsed from input.\");\r\n\r\n    QSharedPointer<Port> createdPort = importComponent_->getPorts()->first();\r\n    QCOMPARE(createdPort->getArrayLeft(), expectedLeftExpression);\r\n    QCOMPARE(createdPort->getArrayRight(), expectedRightExpression);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_VerilogPortParser::testArrayPort_data()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_VerilogPortParser::testArrayPort_data()\r\n{\r\n    QTest::addColumn<QString>(\"fileContent\");\r\n    QTest::addColumn<QString>(\"expectedLeftExpression\");\r\n    QTest::addColumn<QString>(\"expectedRightExpression\");\r\n\r\n    QTest::newRow(\"No array bounds, only vector bounds\") <<\r\n        \"module test(\\n\"\r\n        \"    input bit [7:0] data\\n\"\r\n        \");\\n\"\r\n        \"endmodule\\n\"\r\n        << \"\" << \"\";\r\n\r\n    QTest::newRow(\"Constants as array bounds\") <<\r\n        \"module test(\\n\"\r\n        \"    input bit [7:0] [0:0] data\\n\"\r\n        \");\\n\"\r\n        \"endmodule\\n\"\r\n        << \"7\" << \"0\";\r\n\r\n    QTest::newRow(\"Expression as array bounds\") <<\r\n        \"module test(\\n\"\r\n        \"    input bit [2**4:1] [0:0] data\\n\"\r\n        \");\\n\"\r\n        \"endmodule\\n\"\r\n        << \"2**4\" << \"1\";\r\n\r\n    QTest::newRow(\"Expression with parenthesis as array bounds\") <<\r\n        \"module test(\\n\"\r\n        \"    input bit [2*(8+8-1):1] [0:0] data\\n\"\r\n        \");\\n\"\r\n        \"endmodule\\n\"\r\n        << \"2*(8+8-1)\" << \"1\";\r\n\r\n    QTest::newRow(\"Macro in left array bound\") <<\r\n        \"module test(\\n\"\r\n        \"    input [`WIDTH:0] [7:0] data\\n\"\r\n        \");\\n\"\r\n        \"endmodule\\n\"\r\n        << \"macroId\" << \"0\";\r\n\r\n    QTest::newRow(\"Macro in left v expression\") <<\r\n        \"module test(\\n\"\r\n        \"    input [8+`WIDTH:0] [7:0] data\\n\"\r\n        \");\\n\"\r\n        \"endmodule\\n\"\r\n        << \"8+macroId\" << \"0\";\r\n\r\n    QTest::newRow(\"Macro in right array bound\") <<\r\n        \"module test(\\n\"\r\n        \"    input [0:`WIDTH] [7:0] data\\n\"\r\n        \");\\n\"\r\n        \"endmodule\\n\"\r\n        << \"0\" << \"macroId\";\r\n\r\n    QTest::newRow(\"Macro in right array expression\") <<\r\n        \"module test(\\n\"\r\n        \"    input [0:2*`WIDTH] [7:0] data\\n\"\r\n        \");\\n\"\r\n        \"endmodule\\n\"\r\n        << \"0\" << \"2*macroId\";\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_VerilogPortParser::testMacroInBoundsIsParsed()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_VerilogPortParser::testMacroInBoundsIsParsed()\r\n{\r\n    QSharedPointer<Parameter> macroDefinition(new Parameter());\r\n    macroDefinition->setName(\"WIDTH\");\r\n    macroDefinition->setValue(\"16\");\r\n    macroDefinition->setValueId(\"macroId\");\r\n    importComponent_->getParameters()->append(macroDefinition);\r\n\r\n    QFETCH(QString, fileContent);\r\n    QFETCH(QString, expectedLeftExpression);\r\n    QFETCH(QString, expectedRightExpression);\r\n\r\n    runParser(fileContent);\r\n\r\n    QVERIFY2(importComponent_->getPorts()->count() != 0, \"No ports parsed from input.\");\r\n\r\n    QSharedPointer<Port> createdPort = importComponent_->getPorts()->first();\r\n    QCOMPARE(createdPort->getLeftBound(), expectedLeftExpression);\r\n    QCOMPARE(createdPort->getRightBound(), expectedRightExpression);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_VerilogPortParser::testMacroInBoundsIsParsed_data()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_VerilogPortParser::testMacroInBoundsIsParsed_data()\r\n{\r\n    QTest::addColumn<QString>(\"fileContent\");\r\n    QTest::addColumn<QString>(\"expectedLeftExpression\");\r\n    QTest::addColumn<QString>(\"expectedRightExpression\");\r\n\r\n    QTest::newRow(\"Macro in left vector bound\") <<\r\n        \"module test(\\n\"\r\n        \"    input [`WIDTH:0] data\\n\"\r\n        \");\\n\"\r\n        \"endmodule\\n\"\r\n        << \"macroId\" << \"0\";\r\n\r\n    QTest::newRow(\"Macro in left vector expression\") <<\r\n        \"module test(\\n\"\r\n        \"    input [8+`WIDTH:0] data\\n\"\r\n        \");\\n\"\r\n        \"endmodule\\n\"\r\n        << \"8+macroId\" << \"0\";\r\n\r\n    QTest::newRow(\"Macro in right vector bound\") <<\r\n        \"module test(\\n\"\r\n        \"    input [0:`WIDTH] data\\n\"\r\n        \");\\n\"\r\n        \"endmodule\\n\"\r\n        << \"0\" << \"macroId\";\r\n\r\n    QTest::newRow(\"Macro in right vector expression\") <<\r\n        \"module test(\\n\"\r\n        \"    input [0:2*`WIDTH] data\\n\"\r\n        \");\\n\"\r\n        \"endmodule\\n\"\r\n        << \"0\" << \"2*macroId\";\r\n}\r\n\r\nQTEST_APPLESS_MAIN(tst_VerilogPortParser)\r\n\r\n#include \"tst_VerilogPortParser.moc\"\r\n"
  },
  {
    "path": "tests/Plugins/VerilogImport/tst_VerilogPortParser.pri",
    "content": "# ----------------------------------------------------\r\n# This file is generated by the Qt Visual Studio Tools.\r\n# ------------------------------------------------------\r\n\r\n# This is a reminder that you are using a generated .pro file.\r\n# Remove it when you are finished editing this file.\r\nmessage(\"You are running qmake on a generated .pro file. This may not work!\")\r\n\r\n\r\nHEADERS += ../../../Plugins/VerilogImport/VerilogPortParser.h \\\r\n    ../../../Plugins/VerilogImport/VerilogSyntax.h \\\r\n    ../../../common/expressions/utilities.h\r\nSOURCES += ../../../Plugins/VerilogImport/VerilogPortParser.cpp \\\r\n    ./tst_VerilogPortParser.cpp \\\r\n    ../../../common/expressions/utilities.cpp\r\n"
  },
  {
    "path": "tests/Plugins/VerilogImport/tst_VerilogPortParser.pro",
    "content": "#-----------------------------------------------------------------------------\r\n# File: tst_VerilogPortParser.pro\r\n#-----------------------------------------------------------------------------\r\n# Project: Kactus 2\r\n# Author: Esko Pekkarinen\r\n# Date: 24.09.2014\r\n#\r\n# Description:\r\n# Qt project file template for running unit tests for a VerilogPortParser.\r\n#-----------------------------------------------------------------------------\r\n\r\nTEMPLATE = app\r\n\r\nTARGET = tst_VerilogPortParser\r\n\r\nQT += core xml gui testlib\r\nCONFIG += c++11 testcase console\r\n\r\nwin32:CONFIG(release, debug|release) {\r\n    LIBS += -L$$PWD/../../../executable/ -lIPXACTmodels\r\n    LIBS += -L$$PWD/../../../executable/ -lKactusAPI\r\n    DESTDIR = ./release\r\n}\r\nelse:win32:CONFIG(debug, debug|release) {\r\n    LIBS += -L$$PWD/../../../executable/ -lIPXACTmodelsd\r\n    LIBS += -L$$PWD/../../../executable/ -lKactusAPId\r\n    DESTDIR = ./debug\r\n}\r\nelse:unix {\r\n    LIBS += -L$$PWD/../../../executable/ -lIPXACTmodels\r\n    LIBS += -L$$PWD/../../../executable/ -lKactusAPI\r\n    DESTDIR = ./release\r\n}\r\n\r\nINCLUDEPATH += $$DESTDIR\r\nINCLUDEPATH += $$PWD/../../../KactusAPI/include\r\nINCLUDEPATH += ../../../\r\n\r\nDEPENDPATH += .\r\nDEPENDPATH += ../../../\r\n\r\nOBJECTS_DIR += $$DESTDIR\r\n\r\nMOC_DIR += ./generatedFiles\r\nUI_DIR += ./generatedFiles\r\nRCC_DIR += ./generatedFiles\r\ninclude(tst_VerilogPortParser.pri)\r\n"
  },
  {
    "path": "tests/Plugins/VerilogIncludeImport/tst_VerilogIncludeImport.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: tst_VerilogIncludeImport.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Esko Pekkarinen\r\n// Date: 30.03.2015\r\n//\r\n// Description:\r\n// Unit test for class VerilogIncludeImport.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include <QtTest>\r\n\r\n#include <QPlainTextEdit>\r\n\r\n#include <Plugins/VerilogIncludeImport/VerilogIncludeImport.h>\r\n#include <KactusAPI/include/ImportColors.h>\r\n\r\n#include <KactusAPI/include/ImportHighlighter.h>\r\n\r\n#include <IPXACTmodels/Component/Component.h>\r\n#include <IPXACTmodels/Component/Model.h>\r\n#include <IPXACTmodels/common/Parameter.h>\r\n\r\nclass tst_VerilogIncludeImport : public QObject\r\n{\r\n    Q_OBJECT\r\n\r\npublic:\r\n    tst_VerilogIncludeImport();\r\n\r\nprivate slots:\r\n    void init();\r\n    void testFileTypes();\r\n\r\n    void testNothingIsParsedFromMalformedInput();\r\n    void testNothingIsParsedFromMalformedInput_data();\r\n\r\n    void testDefineIsParsed();\r\n    void testDefineIsParsed_data();\r\n\r\n    void testMultipleDefinitions();\r\n    void testMultipleDefinitions_data();\r\n    \r\n    void testDefinitionWithArgumentsIsNotParsed();\r\n    void testDefinitionWithArgumentsIsNotParsed_data();\r\n\r\n    void testParameterIsParsed();\r\n    void testParameterIsParsed_data();\r\n\r\n    void testMultipleParameters();\r\n    void testMultipleParameters_data();\r\n\r\n    void testDefineIsHighlighted();\r\n    void testDefineIsHighlighted_data();\r\n\r\n    void testWithoutHighlighter();\r\n\r\n    void testExistingParameterIsUpdated();\r\n\r\nprivate:\r\n    void runParser(QString const& input);\r\n\r\n    void verifyNotHighlightedBeforeDeclaration(int declarationStartIndex, QColor const& highlightColor);\r\n\r\n    void verifyDeclarationIsHighlighted(const int declarationStartIndex,\r\n        const int declarationLength, QColor const& expectedHighlight) const;\r\n\r\n    void verifyNotHighlightedAfterDeclartion(const int declarationStartIndex,\r\n        const int declarationLength, QColor const& highlightColor) const;\r\n\r\n    QSharedPointer<Component> importComponent_;\r\n\r\n    QPlainTextEdit displayEditor_;\r\n\r\n    ImportHighlighter* highlighter_;\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_VerilogIncludeImport::tst_VerilogIncludeImport()\r\n//-----------------------------------------------------------------------------\r\ntst_VerilogIncludeImport::tst_VerilogIncludeImport(): importComponent_(0), displayEditor_(), \r\n    highlighter_(new ImportHighlighter(&displayEditor_, this))\r\n{\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_VerilogIncludeImport::init()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_VerilogIncludeImport::init()\r\n{\r\n    importComponent_ = QSharedPointer<Component>(new Component(VLNV(), Document::Revision::Std14));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_VerilogImporter::testFileTypes()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_VerilogIncludeImport::testFileTypes()\r\n{\r\n    VerilogIncludeImport importer;\r\n\r\n    QStringList supportedFileTypes = importer.getSupportedFileTypes();\r\n\r\n    QVERIFY(supportedFileTypes.contains(\"verilogSource\"));\r\n    QVERIFY(supportedFileTypes.contains(\"verilogSource-95\"));\r\n    QVERIFY(supportedFileTypes.contains(\"verilogSource-2001\"));\r\n    QVERIFY(supportedFileTypes.contains(\"systemVerilogSource\"));\r\n    QCOMPARE(supportedFileTypes.count(), 4);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_VerilogIncludeImport::testNothingIsParsedFromMalformedInput()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_VerilogIncludeImport::testNothingIsParsedFromMalformedInput()\r\n{\r\n    QFETCH(QString, input);\r\n\r\n    runParser(input);\r\n\r\n    QCOMPARE(importComponent_->getParameters()->count(), 0);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_VerilogIncludeImport::testNothingIsParsedFromMalformedInput_data()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_VerilogIncludeImport::testNothingIsParsedFromMalformedInput_data()\r\n{\r\n    QTest::addColumn<QString>(\"input\");\r\n\r\n    QTest::newRow(\"Empty input\") << \"\";\r\n    QTest::newRow(\"Commented out definition\") << \"//`define ZERO 0\\n\";\r\n    QTest::newRow(\"IFDEF is not a definition\") << \"//`ifdef ENABLE\\n\";\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_VerilogIncludeImport::testDefineIsParsed()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_VerilogIncludeImport::testDefineIsParsed()\r\n{\r\n    QFETCH(QString, input);\r\n    QFETCH(QString, expectedName);\r\n    QFETCH(QString, expectedValue);\r\n    QFETCH(QString, expectedDescription);\r\n\r\n    runParser(input);\r\n\r\n    QCOMPARE(importComponent_->getParameters()->count(), 1);\r\n\r\n    QSharedPointer<Parameter> createdParameter = importComponent_->getParameters()->first();\r\n    QCOMPARE(createdParameter->name(), expectedName);\r\n    QCOMPARE(createdParameter->getValue(), expectedValue);\r\n    QCOMPARE(createdParameter->description(), expectedDescription);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_VerilogIncludeImport::testDefineIsParsed_data()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_VerilogIncludeImport::testDefineIsParsed_data()\r\n{\r\n    QTest::addColumn<QString>(\"input\");\r\n    QTest::addColumn<QString>(\"expectedName\");\r\n    QTest::addColumn<QString>(\"expectedValue\");\r\n    QTest::addColumn<QString>(\"expectedDescription\");\r\n\r\n    QTest::newRow(\"Name and value\") << \"`define ZERO 0\\n\" << \"ZERO\" << \"0\" << \"\";\r\n    QTest::newRow(\"Value with whitespace\") <<  \r\n        \"`define BASIC_STRING \\\"Test string\\\"\\n\" << \"BASIC_STRING\" << \"\\\"Test string\\\"\" << \"\";\r\n    QTest::newRow(\"Value on multiple lines\") <<  \r\n        \"`define LONG_STRING \\\"Test string \\\\\\n\"\r\n                              \"spanning multiple \\\\\\n\"\r\n                              \"lines.\\\"\\n\" << \"LONG_STRING\" << \"\\\"Test string spanning multiple lines.\\\"\" << \"\";\r\n    QTest::newRow(\"Define without value gets default value one\") << \"`define DEFAULT \\n\" << \"DEFAULT\" << \"1\" << \"\";\r\n    QTest::newRow(\"Value with trailing comment\") <<  \r\n        \"`define COMMENTED 1 // Define description is given in comments.\\n\" \r\n        << \"COMMENTED\" << \"1\" << \"Define description is given in comments.\";\r\n    QTest::newRow(\"Only define, but no value\") <<\r\n        \"`define ENABLE_FEATURE            // Enables feature X.\\n\"\r\n        << \"ENABLE_FEATURE\" << \"1\" << \"Enables feature X.\";\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_VerilogIncludeImport::testMultipleDefinitions()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_VerilogIncludeImport::testMultipleDefinitions()\r\n{\r\n    QFETCH(QString, input);\r\n    QFETCH(int, defineCount);\r\n\r\n    runParser(input);\r\n\r\n    QCOMPARE(importComponent_->getParameters()->count(), defineCount);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_VerilogIncludeImport::testMultipleDefinitions_data()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_VerilogIncludeImport::testMultipleDefinitions_data()\r\n{\r\n    QTest::addColumn<QString>(\"input\");\r\n    QTest::addColumn<int>(\"defineCount\");\r\n\r\n    QTest::newRow(\"Definitions on separate lines\") << \r\n        \"`define ZERO 0\\n\"\r\n        \"`define ONE 1\\n\"\r\n        << 2;\r\n\r\n    QTest::newRow(\"Definitions on same line\") << \r\n        \"`define ZERO 0 `define ONE 1\\n\"\r\n        << 1;\r\n\r\n    QTest::newRow(\"Definitions and single-line comments mixed\") << \r\n        \"`define ZERO 0\\n\"\r\n        \"// `define ONE 1\\n\"\r\n        \"`define TWO 2\\n\"\r\n        << 2;\r\n\r\n    QTest::newRow(\"Definitions and multi-line comments mixed\") << \r\n        \"`define ZERO 0\\n\"\r\n        \"/* `define ONE 1\\n\"\r\n        \"`define TWO 2\\n\"\r\n        \"*/\"\r\n        << 1;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_VerilogIncludeImport::testDefinitionWithArgumentsIsNotParsed()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_VerilogIncludeImport::testDefinitionWithArgumentsIsNotParsed()\r\n{\r\n    QFETCH(QString, input);\r\n\r\n    runParser(input);\r\n\r\n    QCOMPARE(importComponent_->getParameters()->count(), 0);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_VerilogIncludeImport::testDefinitionWithArgumentsIsNotParsed_data()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_VerilogIncludeImport::testDefinitionWithArgumentsIsNotParsed_data()\r\n{\r\n    QTest::addColumn<QString>(\"input\");\r\n\r\n    QTest::newRow(\"Simple max macro with arguments\") << \"`define max(a,b) ((a) > (b) ? (a) : (b))\\n\\n\";\r\n    QTest::newRow(\"Whitespace between macro name and argument parenthesis\") \r\n        << \"`define max (a,b) ((a) > (b) ? (a) : (b))\\n\\n\";\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_VerilogImporter::testParameterIsParsed()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_VerilogIncludeImport::testParameterIsParsed()\r\n{\r\n    QFETCH(QString, input);\r\n    QFETCH(QString, expectedName);\r\n    QFETCH(QString, expectedType);\r\n    QFETCH(QString, expectedValue);\r\n    QFETCH(QString, expectedDescription);\r\n\r\n    runParser(input);\r\n\r\n    QCOMPARE(importComponent_->getParameters()->count(), 1);\r\n\r\n    QSharedPointer<Parameter> createdParameter = importComponent_->getParameters()->first();\r\n    QCOMPARE(createdParameter->name(), expectedName);\r\n    QCOMPARE(createdParameter->getValue(), expectedValue);\r\n    QCOMPARE(createdParameter->description(), expectedDescription);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_VerilogImporter::testParameterIsParsed_data()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_VerilogIncludeImport::testParameterIsParsed_data()\r\n{\r\n    QTest::addColumn<QString>(\"input\");\r\n    QTest::addColumn<QString>(\"expectedName\");\r\n    QTest::addColumn<QString>(\"expectedType\");\r\n    QTest::addColumn<QString>(\"expectedValue\");\r\n    QTest::addColumn<QString>(\"expectedDescription\");\r\n\r\n    QTest::newRow(\"Name and value\") << \"parameter basic_parameter = 1;\\n\" << \"basic_parameter\" << \"\" << \"1\" << \"\";\r\n    QTest::newRow(\"Name, type and value\") << \"parameter bit logic_one = '1;\\n\" << \"logic_one\" << \"bit\" << \"'1\" << \"\";\r\n\r\n    QTest::newRow(\"Name, type, value and description\") <<\r\n        \"parameter bit logic_one = '1; // Logical one.\\n\" << \"logic_one\" << \"bit\" << \"'1\" << \"Logical one.\";\r\n\r\n    QTest::newRow(\"Name and value, followed by ifdef section\") << \r\n        \"parameter bit logic_one = '1;\\n\" \r\n        \"`ifdef FEATURE_EN // Comment for ifdef.\"\r\n        \"`endif // FEATURE_EN\"\r\n        << \"logic_one\" << \"bit\" << \"'1\" << \"\";\r\n\r\n    QTest::newRow(\"Function in value\") <<\r\n        \"parameter          VECT_WIDTH = $clog2(VECT_COUNT + 1);\\n\"\r\n        << \"VECT_WIDTH\" << \"\" << \"$clog2(VECT_COUNT + 1)\" << \"\";\r\n\r\n    QTest::newRow(\"Bit array type\") <<\r\n        \"parameter bit [VECT_COUNT-1:0] VECT_WIDTH =           'hFFFF0000;\\n\"\r\n        << \"VECT_WIDTH\" << \"bit\" << \"'hFFFF0000\" << \"\";\r\n\r\n    QTest::newRow(\"Complex value in vector\") <<\r\n        \"parameter bit [`B_LEN-1:0]  VECT_RST_VAL    =\\n\"\r\n        \"                              BASE_BITS'(BASE_COUNT >> RESET_VALUE_BITS);\"\r\n        << \"VECT_RST_VAL\" << \"bit\" << \"BASE_BITS'(BASE_COUNT >> RESET_VALUE_BITS)\" << \"\";\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_VerilogIncludeImport::testMultipleParameters()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_VerilogIncludeImport::testMultipleParameters()\r\n{\r\n    QFETCH(QString, input);\r\n    QFETCH(int, parameterCount);\r\n\r\n    runParser(input);\r\n\r\n    QCOMPARE(importComponent_->getParameters()->count(), parameterCount);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_VerilogIncludeImport::testMultipleParameters_data()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_VerilogIncludeImport::testMultipleParameters_data()\r\n{\r\n    QTest::addColumn<QString>(\"input\");\r\n    QTest::addColumn<int>(\"parameterCount\");\r\n\r\n    QTest::newRow(\"Parameters on separate lines\") <<\r\n        \"parameter bit logic_one = '1;\\n\"\r\n        \"parameter bit logic_zero = '0;\\n\"\r\n        << 2;\r\n\r\n    QTest::newRow(\"Parameter in comments on the same line\") <<\r\n        \"parameter bit logic_one = '1; // parameter bit logic_zero = '0; \\n\"\r\n        << 1;\r\n\r\n    QTest::newRow(\"Definitions and single-line comments mixed\") <<\r\n        \"parameter bit logic_one = '1;\\n\"\r\n        \"// parameter bit logic_comment = '1;\\n\"\r\n        \"parameter bit logic_zero = '0;\\n\"\r\n        << 2;\r\n\r\n    QTest::newRow(\"Parameters within ifdefs are imported\") <<\r\n        \"parameter data_width = 32;\\n\"\r\n        \"parameter address_width = '8;\\n\"\r\n        \"`ifdef DEBUG_EN\\n\"\r\n        \"parameter bit logic_one = '1;\\n\"\r\n        \"parameter bit logic_zero = '0;\\n\"\r\n        \"`endif // DEBUG_EN\"\r\n        << 4;\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_VerilogImporter::testDefineIsHighlighted()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_VerilogIncludeImport::testDefineIsHighlighted()\r\n{\r\n    QFETCH(QString, input);\r\n    QFETCH(QString, defineDeclaration);\r\n\r\n    runParser(input);\r\n\r\n    QVERIFY2(importComponent_->getParameters()->count() != 0, \"No parameters parsed from input.\");\r\n\r\n    int begin = input.indexOf(defineDeclaration);\r\n\r\n    verifyNotHighlightedBeforeDeclaration(begin, ImportColors::MODELPARAMETER);\r\n    verifyDeclarationIsHighlighted(begin, defineDeclaration.length(), ImportColors::MODELPARAMETER);\r\n    verifyNotHighlightedAfterDeclartion(begin, defineDeclaration.length(), ImportColors::MODELPARAMETER);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_VerilogIncludeImport::testDefineIsHighlighted_data()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_VerilogIncludeImport::testDefineIsHighlighted_data()\r\n{\r\n    QTest::addColumn<QString>(\"input\");\r\n    QTest::addColumn<QString>(\"defineDeclaration\");\r\n\r\n    QTest::newRow(\"Name and value\") << \"`define ZERO 0\\n\\n\" << \"`define ZERO 0\\n\";\r\n    QTest::newRow(\"Value on multiple lines\") <<  \r\n        \"`define LONG_STRING \\\"Test string \\\\\\n\"\r\n        \"spanning multiple \\\\\\n\"\r\n        \"lines.\\\"\\n\\n\" << \"`define LONG_STRING \\\"Test string \\\\\\n\"\r\n        \"spanning multiple \\\\\\n\"\r\n        \"lines.\\\"\\n\";\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_VerilogIncludeImport::testWithoutHighlighter()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_VerilogIncludeImport::testWithoutHighlighter()\r\n{\r\n    QString input = \"`define ZERO 0\\n\\n\";\r\n\r\n    VerilogIncludeImport parser;\r\n    parser.import(input, input, importComponent_);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_VerilogIncludeImport::testExistingParameterIsUpdated()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_VerilogIncludeImport::testExistingParameterIsUpdated()\r\n{\r\n    QSharedPointer<Parameter> existingParameter(new Parameter());\r\n    existingParameter->setName(\"EXISTING\");\r\n    existingParameter->setValue(\"1\");\r\n    existingParameter->setDescription(\"This parameter has already been defined\");\r\n    importComponent_->getParameters()->append(existingParameter);\r\n\r\n    runParser(\"`define EXISTING 2 // This parameter has been updated.\\n\\n\");\r\n\r\n    QCOMPARE(importComponent_->getParameters()->count(), 1);\r\n    QCOMPARE(importComponent_->getParameters()->first()->description(), \r\n        QString(\"This parameter has been updated.\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_VerilogIncludeImport::runParser()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_VerilogIncludeImport::runParser(QString const& input)\r\n{\r\n    displayEditor_.setPlainText(input);\r\n\r\n    VerilogIncludeImport parser;\r\n    parser.setHighlighter(highlighter_);\r\n\r\n    parser.import(input, input, importComponent_);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_VerilogIncludeImport::verifyNotHighlightedBeforeDeclaration()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_VerilogIncludeImport::verifyNotHighlightedBeforeDeclaration(int declarationStartIndex, \r\n    QColor const& highlightColor)\r\n{\r\n    QTextCursor cursor = displayEditor_.textCursor();\r\n    cursor.setPosition(declarationStartIndex);\r\n\r\n    if (cursor.atBlockStart())\r\n    {\r\n        cursor.setPosition(qMax(declarationStartIndex - 1, 0));\r\n    }\r\n\r\n    QColor appliedColor = cursor.charFormat().background().color();\r\n\r\n    QVERIFY2(appliedColor != highlightColor, \"Highlight applied before declaration.\");\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_VerilogIncludeImport::verifyDeclarationIsHighlighed()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_VerilogIncludeImport::verifyDeclarationIsHighlighted(const int declarationStartIndex, \r\n    const int declarationLength, QColor const& expectedHighlight) const\r\n{\r\n    QTextCursor cursor = displayEditor_.textCursor();\r\n\r\n    for (int i = 1; i <= declarationLength; i++)\r\n    {\r\n        cursor.setPosition(declarationStartIndex + i);\r\n\r\n        QColor appliedColor = cursor.charFormat().background().color();\r\n\r\n        if (appliedColor != expectedHighlight)\r\n        {\r\n            QString correctlyHighligted(displayEditor_.toPlainText().mid(declarationStartIndex, i - 1));\r\n            QString errorMessage(\"Highlight ended after '\" + correctlyHighligted + \"'\");\r\n\r\n            QFAIL(errorMessage.toLocal8Bit());           \r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_VerilogIncludeImport::verifyNotHighlightedAfterDeclartion()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_VerilogIncludeImport::verifyNotHighlightedAfterDeclartion(const int declarationStartIndex, \r\n    const int declarationLength, QColor const& highlightColor) const\r\n{\r\n    QTextCursor cursor = displayEditor_.textCursor();\r\n    cursor.setPosition(declarationStartIndex + declarationLength + 1);\r\n\r\n    QColor appliedColor = cursor.charFormat().background().color();\r\n\r\n    QVERIFY2(appliedColor != highlightColor, \"Highlight applied after declaration.\");\r\n}\r\n\r\nQTEST_MAIN(tst_VerilogIncludeImport)\r\n\r\n#include \"tst_VerilogIncludeImport.moc\"\r\n"
  },
  {
    "path": "tests/Plugins/VerilogIncludeImport/tst_VerilogIncludeImport.pri",
    "content": "# ----------------------------------------------------\r\n# This file is generated by the Qt Visual Studio Tools.\r\n# ------------------------------------------------------\r\n\r\n# This is a reminder that you are using a generated .pro file.\r\n# Remove it when you are finished editing this file.\r\nmessage(\"You are running qmake on a generated .pro file. This may not work!\")\r\n\r\n\r\nHEADERS += ../../../IPXACTmodels/utilities/Search.h \\\r\n    ../../../Plugins/VerilogImport/VerilogParameterParser.h \\\r\n    ../../../common/expressions/utilities.h \\\r\n    ../../../Plugins/VerilogIncludeImport/verilogincludeimport_global.h \\\r\n    ../../../Plugins/VerilogIncludeImport/VerilogIncludeImport.h \\\r\n    ../../../KactusAPI/include/ImportHighlighter.h\r\nSOURCES += ../../../Plugins/VerilogIncludeImport/VerilogIncludeImport.cpp \\\r\n    ../../../Plugins/VerilogImport/VerilogParameterParser.cpp \\\r\n    ../../../Plugins/VerilogImport/VerilogSyntax.cpp \\\r\n    ../../../common/expressions/utilities.cpp \\\r\n    ./tst_VerilogIncludeImport.cpp \\\r\n    ../../../KactusAPI/plugins/ImportHighlighter.cpp\r\n"
  },
  {
    "path": "tests/Plugins/VerilogIncludeImport/tst_VerilogIncludeImport.pro",
    "content": "#-----------------------------------------------------------------------------\r\n# File: tst_VerilogIncludeImport.pro\r\n#-----------------------------------------------------------------------------\r\n# Project: Kactus 2\r\n# Author: Esko Pekkarinen\r\n# Date: 24.7.2014\r\n#\r\n# Description:\r\n# Qt project file template for running unit tests for a single module.\r\n#-----------------------------------------------------------------------------\r\n\r\nTEMPLATE = app\r\n\r\nTARGET = tst_VerilogIncludeImport\r\n\r\nDEFINES += VERILOGINCLUDEIMPORT_LIB\r\n\r\nQT += core xml gui testlib widgets\r\nCONFIG += c++11 testcase console\r\n\r\nQMAKE_EXPORTED_VARIABLES += MAKE_TESTARGS\r\nMAKE_TESTARGS.name = TESTARGS\r\nMAKE_TESTARGS.value = \"-platform offscreen\"\r\n\r\nwin32:CONFIG(release, debug|release) {\r\n    LIBS += -L$$PWD/../../../executable/ -lIPXACTmodels\r\n    LIBS += -L$$PWD/../../../executable/ -lKactusAPI\r\n    DESTDIR = ./release\r\n}\r\nelse:win32:CONFIG(debug, debug|release) {\r\n    LIBS += -L$$PWD/../../../executable/ -lIPXACTmodelsd\r\n    LIBS += -L$$PWD/../../../executable/ -lKactusAPId\r\n    DESTDIR = ./debug\r\n}\r\nelse:unix {\r\n    LIBS += -L$$PWD/../../../executable/ -lIPXACTmodels\r\n    LIBS += -L$$PWD/../../../executable/ -lKactusAPI\r\n    DESTDIR = ./release\r\n}\r\n\r\nINCLUDEPATH += $$DESTDIR\r\nINCLUDEPATH += ../../../\r\nINCLUDEPATH += $$PWD/../../../KactusAPI/include\r\n\r\nDEPENDPATH += .\r\nDEPENDPATH += ../../../\r\n\r\nOBJECTS_DIR += $$DESTDIR\r\n\r\nMOC_DIR += ./generatedFiles\r\nUI_DIR += ./generatedFiles\r\nRCC_DIR += ./generatedFiles\r\ninclude(tst_VerilogIncludeImport.pri)\r\n"
  },
  {
    "path": "tests/Plugins/VerilogSourceAnalyzer/tst_VerilogSourceAnalyzer.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: tst_VerilogSourceAnalyzer.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Esko Pekkarinen\r\n// Date: 07.04.2015\r\n//\r\n// Description:\r\n// Unit test for class VerilogSourceAnalyzer.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include <QtTest>\r\n\r\n#include <Plugins/VerilogSourceAnalyzer/VerilogSourceAnalyzer.h>\r\n\r\nclass tst_VerilogSourceAnalyzer : public QObject\r\n{\r\n    Q_OBJECT\r\n\r\npublic:\r\n    tst_VerilogSourceAnalyzer();\r\n\r\nprivate slots:\r\n    void cleanup();\r\n\r\n    void testFileTypes();\r\n\r\n    void testCalculateHashForNonexistingFile();\r\n    void testCalculateHash();\r\n    void testCalculateHash_data();\r\n\r\n    void testFileInclude();\r\n    void testFileInclude_data();\r\n\r\n    void testFileIncludeFromFilesetReturnsRelativePath();\r\n\r\n    void testAbsoluteFilePath();\r\n\r\n    void testSimilarFileNamesInFilesets();\r\n\r\n\tvoid testSubmoduleInstance();\r\n\tvoid testSubmoduleInstance_data();\r\n\r\n\tvoid testSubmodulesAreSearchedInFilesets();\r\n\r\n\tvoid testMultipleModulesInFilesetFile();\r\n\r\n\tvoid testNamedProcessIsNotSubmodule();\r\n\r\nprivate:\r\n    \r\n    void writeTestFile(QString const& content, QString const& fileName);\r\n\r\n\tQStringList testFiles_;\r\n};\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_VerilogSourceAnalyzer::tst_VerilogSourceAnalyzer()\r\n//-----------------------------------------------------------------------------\r\ntst_VerilogSourceAnalyzer::tst_VerilogSourceAnalyzer(): testFiles_()\r\n{\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_VerilogSourceAnalyzer::cleanupTestCase()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_VerilogSourceAnalyzer::cleanup()\r\n{\r\n\tfor (auto& testFileName : testFiles_)\r\n\t{\r\n\t\tQFile testInpuFile(testFileName);\r\n\t\tif (testInpuFile.exists())\r\n\t\t{\r\n\t\t\ttestInpuFile.remove();\r\n\t\t}\r\n\t}\r\n\r\n\ttestFiles_.clear();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_VerilogSourceAnalyzer::testFileTypes()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_VerilogSourceAnalyzer::testFileTypes()\r\n{\r\n    VerilogSourceAnalyzer analyzer;\r\n\r\n    QStringList supportedFileTypes = analyzer.getSupportedFileTypes();\r\n\r\n    QVERIFY(supportedFileTypes.contains(\"verilogSource\"));\r\n    QVERIFY(supportedFileTypes.contains(\"verilogSource-95\"));\r\n    QVERIFY(supportedFileTypes.contains(\"verilogSource-2001\"));\r\n    QVERIFY(supportedFileTypes.contains(\"systemVerilogSource\"));\r\n    QCOMPARE(supportedFileTypes.count(), 4);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_VerilogSourceAnalyzer::testCalculateHashForNonexistingFile()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_VerilogSourceAnalyzer::testCalculateHashForNonexistingFile()\r\n{\r\n    VerilogSourceAnalyzer analyzer;\r\n    QString fileHash = analyzer.calculateHash(\"noFile.v\");\r\n    \r\n    QVERIFY(fileHash.isEmpty());\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_VerilogSourceAnalyzer::testCalculateHash()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_VerilogSourceAnalyzer::testCalculateHash()\r\n{   \r\n    QFETCH(QString, input);\r\n    QFETCH(QString, equivalentInput);\r\n\r\n    writeTestFile(input, \"test.v\");\r\n\r\n    QCryptographicHash sha1Hash(QCryptographicHash::Sha1);\r\n    sha1Hash.addData(equivalentInput.toLatin1());\r\n    QString expectedHash = sha1Hash.result().toHex();\r\n\r\n    VerilogSourceAnalyzer analyzer;\r\n    QString fileHash = analyzer.calculateHash(\"test.v\");\r\n\r\n    QVERIFY(fileHash == expectedHash);\r\n\r\n    QVERIFY(QFile::remove(\"test.v\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_VerilogSourceAnalyzer::testCalculateHash_data()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_VerilogSourceAnalyzer::testCalculateHash_data()\r\n{\r\n    QTest::addColumn<QString>(\"input\");\r\n    QTest::addColumn<QString>(\"equivalentInput\");\r\n\r\n    QTest::newRow(\"module declaration\") << \r\n        \"module test(input clk);\\n\"\r\n        \"endmodule\\n\\n\\n\" << \r\n        \"module test(input clk); endmodule\";\r\n\r\n    QTest::newRow(\"module declaration with whitespaces\") << \r\n        \"module   test    (input     clk);    \\n\\n\\n\\n\"\r\n        \"endmodule\\n\" << \r\n        \"module test (input clk); endmodule\";\r\n\r\n    QTest::newRow(\"module declaration with comments\") << \r\n        \"// Module starts here.\\n\"\r\n        \"module test(\\n\"\r\n        \"// Ports:\\n\"\r\n        \"input clk);\\n\"\r\n        \"endmodule\\n\"\r\n        \"// Module ends here.\\n\" << \r\n        \"module test( input clk); endmodule\";\r\n\r\n    QTest::newRow(\"module declaration with multi-line comment\") << \r\n        \"/* Module test:*/\\n\"\r\n        \"module test(\\n\"\r\n        \"/* Port are defined on the following lines:\\n\"\r\n        \"*/\\n\"\r\n        \"input clk);\\n\"\r\n        \"endmodule\\n\"\r\n        << \r\n        \"module test( input clk); endmodule\";\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_VerilogSourceAnalyzer::testFileInclude()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_VerilogSourceAnalyzer::testFileInclude()\r\n{\r\n    QFETCH(QString, input);\r\n    QFETCH(int, expectedDependencyCount);\r\n    QFETCH(QString, firstDependentFileName);\r\n\r\n    QSharedPointer<Component> targetComponent(new Component(VLNV(), Document::Revision::Std14));\r\n\r\n    writeTestFile(input, \"test.v\");\r\n\r\n    VerilogSourceAnalyzer analyzer;\r\n\r\n    QList<FileDependencyDesc> dependencies = analyzer.getFileDependencies(targetComponent.data(), \".\", \"test.v\");\r\n\r\n    QCOMPARE(dependencies.count(), expectedDependencyCount);\r\n    \r\n    if (expectedDependencyCount > 0)\r\n    {   \r\n        FileDependencyDesc includeDependency = dependencies.first();\r\n        QCOMPARE(includeDependency.filename, firstDependentFileName);\r\n    }\r\n\r\n    QVERIFY(QFile::remove(\"test.v\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_VerilogSourceAnalyzer::testFileInclude_data()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_VerilogSourceAnalyzer::testFileInclude_data()\r\n{\r\n    QTest::addColumn<QString>(\"input\");\r\n    QTest::addColumn<int>(\"expectedDependencyCount\");\r\n    QTest::addColumn<QString>(\"firstDependentFileName\");\r\n\r\n    QTest::newRow(\"empty input\") << \"\" << 0 << \"\";\r\n    \r\n    QTest::newRow(\"single include in quotes\") << \"`include \\\"definitions.v\\\"\" << 1 << \"definitions.v\";\r\n    \r\n    QTest::newRow(\"multiple includes in quotes\") << \r\n        \"`include \\\"globals.v\\\"\\n\"\r\n        \"`include \\\"variables.v\\\"\\n\"\r\n        \"`include \\\"parameters.v\\\"\\n\"\r\n        << 3 << \"globals.v\";\r\n\r\n    QTest::newRow(\"single include in angle brackets\") << \"`include <definitions.v>\" << 1 << \"definitions.v\";\r\n\r\n    QTest::newRow(\"multiple includes in angle brackets\") << \r\n        \"`include <globals.v>\\n\"\r\n        \"`include <variables.v>\\n\"\r\n        \"`include <parameters.v>\\n\"\r\n        << 3 << \"globals.v\";\r\n\r\n   QTest::newRow(\"includes in comments\") << \r\n       \"//`include \\\"globals.v\\\"\\n\"\r\n       \"`include \\\"variables.v\\\"\\n\"\r\n       \"/*`include \\\"parameters.v\\\"\\n\"\r\n       \"`include \\\"other.v\\\"*/\"\r\n       << 1 << \"variables.v\";\r\n\r\n   QString absolutePath = QFileInfo(\"test.v\").absoluteFilePath();\r\n   QString unixPath = absolutePath.replace('\\\\', '/');\r\n   QTest::newRow(\"full path\") << \"`include \\\"\" + absolutePath + \"\\\"\" << 1 << \"test.v\";\r\n   QTest::newRow(\"full unix path\") << \"`include \\\"\" + unixPath + \"\\\"\" << 1 << \"test.v\";\r\n\r\n   QTest::newRow(\"relative path include\") << \"`include \\\"global/definitions.v\\\"\" << 1 << \"global/definitions.v\";\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_VerilogSourceAnalyzer::testFileIncludeWithRelativePath()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_VerilogSourceAnalyzer::testFileIncludeFromFilesetReturnsRelativePath()\r\n{\r\n    QSharedPointer<Component> targetComponent(new Component(VLNV(), Document::Revision::Std14));\r\n\r\n\tQSharedPointer<FileSet> targetFileSet(new FileSet(\"includes\"));\r\n\tQSharedPointer<File> targetFile(new File((QStringLiteral(\"../includes/globals.v\"))));\r\n\ttargetFile->addFileType(\"verilogSource\");\r\n\t\r\n\ttargetFileSet->addFile(targetFile);\r\n\ttargetComponent->getFileSets()->append( targetFileSet );\r\n\r\n    writeTestFile(\"`include \\\"globals.v\\\"\\n\", \"test.v\");\r\n\r\n    QDir componentDirectory(QFileInfo(\"test.v\").absolutePath());\r\n    componentDirectory.mkpath(\"ipxact\");\r\n    componentDirectory.cd(\"ipxact\");\r\n\r\n    VerilogSourceAnalyzer analyzer;\r\n\r\n    QList<FileDependencyDesc> dependencies = analyzer.getFileDependencies(targetComponent.data(), \r\n        componentDirectory.absolutePath(), \"../test.v\");\r\n\r\n    QCOMPARE(dependencies.count(), 1);\r\n\r\n    FileDependencyDesc includeDependency = dependencies.first();\r\n    QCOMPARE(includeDependency.filename, QString(\"includes/globals.v\"));\r\n\r\n    QVERIFY(QFile::remove(\"test.v\"));\r\n\r\n    componentDirectory.cdUp();\r\n    QVERIFY(componentDirectory.rmdir(\"ipxact\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_VerilogSourceAnalyzer::testAbsoluteFilePath()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_VerilogSourceAnalyzer::testAbsoluteFilePath()\r\n{\r\n   QSharedPointer<Component> targetComponent(new Component(VLNV(), Document::Revision::Std14));\r\n\r\n    writeTestFile(\"`include \\\"globals.v\\\"\\n\", \"test.v\");\r\n\r\n    VerilogSourceAnalyzer analyzer;\r\n\r\n    QList<FileDependencyDesc> dependencies = analyzer.getFileDependencies(targetComponent.data(), \r\n        \".\", QFileInfo(\"test.v\").absoluteFilePath());\r\n\r\n    QCOMPARE(dependencies.count(), 1);\r\n\r\n    FileDependencyDesc includeDependency = dependencies.first();\r\n    QCOMPARE(includeDependency.filename, QString(\"globals.v\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_VerilogSourceAnalyzer::testSimilarFileNamesInFilesets()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_VerilogSourceAnalyzer::testSimilarFileNamesInFilesets()\r\n{\r\n    QSettings settings;\r\n\r\n    QSharedPointer<Component> targetComponent(new Component(VLNV(), Document::Revision::Std14));\r\n\r\n\tQSharedPointer<QList<QSharedPointer<FileSet> > > fileSets = targetComponent->getFileSets();\r\n\tQSharedPointer<FileSet> wrongFileSet( new FileSet(\"wrong\") );\r\n\tQSharedPointer<FileSet> targetFileSet( new FileSet(\"includes\") );\r\n\twrongFileSet->addFile(\"../includes/m_globals.v\", settings);\r\n\ttargetFileSet->addFile(\"globals.v\", settings);\r\n\tfileSets->append( wrongFileSet );\r\n\tfileSets->append( targetFileSet );\r\n\r\n    writeTestFile(\"`include \\\"globals.v\\\"\\n\", \"test.v\");\r\n\r\n    VerilogSourceAnalyzer analyzer;\r\n\r\n    QList<FileDependencyDesc> dependencies = analyzer.getFileDependencies(targetComponent.data(), \r\n        \".\", \"test.v\");\r\n\r\n    QCOMPARE(dependencies.count(), 1);\r\n\r\n    FileDependencyDesc includeDependency = dependencies.first();\r\n    QCOMPARE(includeDependency.filename, QString(\"globals.v\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_VerilogSourceAnalyzer::testSubmoduleInstance()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_VerilogSourceAnalyzer::testSubmoduleInstance()\r\n{\r\n\tQFETCH(QString, input);\r\n\tQFETCH(QStringList, fileNames);\r\n\r\n\tQSharedPointer<Component> targetComponent(new Component(VLNV(), Document::Revision::Std14));\r\n\r\n\twriteTestFile(input, \"test.v\");\r\n\r\n\tVerilogSourceAnalyzer analyzer;\r\n\r\n\tQList<FileDependencyDesc> dependencies = analyzer.getFileDependencies(targetComponent.data(),\r\n\t\t\".\", QFileInfo(\"test.v\").absoluteFilePath());\r\n\r\n\tfor (auto& instantiationDependency : dependencies)\r\n\t{\r\n\t\tQString moduleName = instantiationDependency.filename;\r\n\t\t//moduleName.remove(QRegularExpression(\".(s)?v$\"));\r\n\t\tmoduleName.remove(QRegularExpression(\"\\\\s*\\\\(Verilog module\\\\)$\"));\r\n\t\tQString error = \"No instance \" + moduleName + \" found with file \" + instantiationDependency.filename;\t\t\r\n\t\tQVERIFY2(fileNames.contains(instantiationDependency.filename), error.toLocal8Bit());\r\n\t\tQCOMPARE(instantiationDependency.description, QString(\"Submodule instantiation of module \" + moduleName));\r\n\t}\r\n\r\n\tQCOMPARE(dependencies.count(), fileNames.count());\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_VerilogSourceAnalyzer::testFileInclude_data()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_VerilogSourceAnalyzer::testSubmoduleInstance_data()\r\n{\r\n\tQTest::addColumn<QString>(\"input\");\t\r\n\tQTest::addColumn<QStringList>(\"fileNames\");\r\n\r\n\tQTest::newRow(\"Simple submodule, no ports\") <<\r\n\t\t\"module test(input clk);\\n\"\r\n\t\t\"\\n\"\r\n\t\t\"submodule sub_i();\\n\"\t\t\r\n\t\t\"endmodule\\n\"\r\n\t\t<< QStringList(\"submodule (Verilog module)\");\r\n\r\n\tQTest::newRow(\"Simple submodule, no port connections\") <<\r\n\t\t\"module test(input clk);\\n\"\r\n\t\t\"\\n\"\r\n\t\t\"submodule sub_i;\\n\"\r\n\t\t\"endmodule\\n\"\r\n\t\t<< QStringList(\"submodule (Verilog module)\");\r\n\r\n\tQTest::newRow(\"Simple submodule, one port\") << \r\n\t\t\"module test(input clk);\\n\"\r\n\t\t\"\\n\"\r\n\t\t\"submodule sub_i(\\n\"\r\n\t\t\"    .clk(clk)\\n\"\r\n\t\t\");\\n\"\r\n\t\t\"endmodule\\n\"\r\n\t\t<< QStringList(\"submodule (Verilog module)\");\r\n\r\n\tQTest::newRow(\"Simple submodule, multiple ports\") <<\r\n\t\t\"module test(input clk, input rst, output enable);\\n\"\r\n\t\t\"\\n\"\r\n\t\t\"submodule sub_i(\\n\"\r\n\t\t\"    .clk(clk),\\n\"\r\n\t\t\"    .reset(rst)\\n\"\r\n\t\t\");\\n\"\r\n\t\t\"endmodule\\n\"\r\n\t\t<< QStringList(\"submodule (Verilog module)\");\r\n\r\n\tQTest::newRow(\"Simple submodule with parameter and wire declarations\") <<\r\n\t\t\"module test(input clk, input rst, output enable);\\n\"\r\n\t\t\"\\n\"\r\n\t\t\"localparam TWENTY = 10 * 2;\"\r\n\t\t\"localparam DATA_WIDTH = TWENTY + 12;\"\r\n\t\t\"\\n\"\r\n\t\t\"logic [31:0] connector;\\n\"\r\n\t\t\"logic        simple_wire;\\n\"\r\n\t\t\"logic [DATA_WIDTH-1:0] wide_wire;\\n\"\r\n\t\t\"\\n\"\r\n\t\t\"submodule sub_i(\\n\"\r\n\t\t\"    .clk(clk),\\n\"\r\n\t\t\"    .reset(rst)\\n\"\r\n\t\t\");\\n\"\r\n\t\t\"endmodule\\n\"\r\n\t\t<< QStringList(\"submodule (Verilog module)\");\r\n\r\n\tQTest::newRow(\"Simple submodule with preceding assignments\") <<\r\n\t\t\"module test(input clk, output enable);\\n\"\r\n\t\t\"\\n\"\r\n\t\t\"logic clock_carrier;\\n\"\r\n\t\t\"logic enable_carrier;\\n\"\r\n\t\t\"\\n\"\r\n\t\t\"assign clock_carrier = clk;\\n\"\r\n\t\t\"assign enable = enable_carrier;\\n\"\r\n\t\t\"\\n\"\r\n\t\t\"submodule sub_i(\\n\"\r\n\t\t\"    .clk(clk),\\n\"\r\n\t\t\"    .enable(enable_carrier)\\n\"\r\n\t\t\");\"\r\n\t\t\"endmodule\\n\"\r\n\t\t<< QStringList(\"submodule (Verilog module)\");\r\n\r\n\tQTest::newRow(\"Multiple submodules with logic\") <<\r\n\t\t\"module top(input logic clk, reset, enable,\\n\"\r\n\t\t\"           output logic RE,\\n\"\r\n\t\t\"           output logic WE,\\n\"\r\n\t\t\"           output types::addr_t addr,\\n\"\r\n\t\t\"           output types::rdata_t rdata,\\n\"\r\n\t\t\"           output types::wdata_t wdata);\\n\"\r\n\t\t\"\\n\"\r\n\t\t\"  logic en_data_gen, en_data_gen_b;\\n\"\r\n\t\t\"\\n\"\r\n\t\t\"  intf #(.nmasters(2), .nslaves(2)) bus(.clk,.reset);\\n\"\r\n\t\t\"  data_gen m1(.enable(en_data_gen_b),.bus(bus.master[0].mport));\\n\"\r\n\t\t\"  master m0(.bus(bus.master[1].mport));\\n\"\r\n\t\t\"  slave #(.asize(7)) s0(.bus(bus.slave[0].mport));\\n\"\r\n\t\t\"  slave #(.asize(7)) s1(.bus(bus.slave[1].mport));\\n\"\r\n\t\t\"  counter c0(.clk,.reset,.enable,.q(en_data_gen));\\n\"\r\n\t\t\"\\n\"\r\n\t\t\"  assign addr = bus.addr_a;\\n\"\r\n\t\t\"  assign rdata = bus.rdata_a;\\n\"\r\n\t\t\"  assign wdata = bus.wdata_a;\\n\"\r\n\t\t\"  assign RE = bus.RE_a;\\n\"\r\n\t\t\"  assign WE = bus.WE_a;\\n\"\r\n\t\t\"  assign en_data_gen_b = !en_data_gen;\\n\"\r\n\t\t\"\\n\"\r\n\t\t\"endmodule: top\\n\"\r\n\t\t<< QStringList({ \"intf (Verilog module)\", \"data_gen (Verilog module)\", \r\n\t\t\t\"master (Verilog module)\", \"slave (Verilog module)\", \"counter (Verilog module)\" });\r\n\r\n\tQTest::newRow(\"Instantiating same submodule multiple times\") <<\r\n\t\t\"module ripple_adder(X, Y, S, Co);\\n\"\r\n\t\t\" input [3:0] X, Y;// Two 4-bit inputs\\n\"\r\n\t\t\" output [3:0] S;\\n\"\r\n\t\t\" output Co;\\n\"\r\n\t\t\" wire w1, w2, w3;\\n\"\r\n\t\t\"\\n\"\r\n\t\t\"//Instantiating 4 1-bit full adders\\n\"\r\n\t\t\"fulladder u1(X[0], Y[0], 1'b0, S[0], w1);\\n\"\r\n\t\t\"fulladder u2(X[1], Y[1], w1, S[1], w2);\\n\"\r\n\t\t\"fulladder u3(X[2], Y[2], w2, S[2], w3);\\n\"\r\n\t\t\"fulladder u4(X[3], Y[3], w3, S[3], Co);\\n\"\r\n\t\t\"endmodule\"\r\n\t\t<< QStringList(\"fulladder (Verilog module)\");\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_VerilogSourceAnalyzer::testSubmodulesAreSearchedInFilesets()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_VerilogSourceAnalyzer::testSubmodulesAreSearchedInFilesets()\r\n{\r\n\tQSharedPointer<Component> targetComponent(new Component(VLNV(), Document::Revision::Std14));\r\n\r\n\twriteTestFile(\r\n\t\t\"module test();\\n\"\r\n\t\t\"\\n\"\r\n\t\t\"johnson john_i();\\n\"\t\t\r\n\t\t\"endmodule\\n\", \r\n\t\t\"top.v\");\r\n\r\n\tVerilogSourceAnalyzer analyzer;\r\n\r\n\tQList<FileDependencyDesc> dependencies = analyzer.getFileDependencies(targetComponent.data(),\r\n\t\t\".\", QFileInfo(\"top.v\").absoluteFilePath());\r\n\r\n\tQCOMPARE(dependencies.count(), 1);\r\n\tQCOMPARE(dependencies.first().filename, \"johnson (Verilog module)\");\r\n\r\n\twriteTestFile(\r\n\t\t\"module johnson();\\n\"\r\n\t\t\"endmodule\\n\",\r\n\t\t\"johnson_counter.v\");\r\n\r\n\tQSharedPointer<File> submoduleFile(new File(\"johnson_counter.v\", \"verilogSource\"));\r\n\tQSharedPointer<FileSet> rtlFileSet(new FileSet(\"rtl\"));\r\n\trtlFileSet->addFile(submoduleFile);\r\n\ttargetComponent->getFileSets()->append(rtlFileSet);\r\n\r\n\tQList<FileDependencyDesc> filesetDependencies = analyzer.getFileDependencies(targetComponent.data(),\r\n\t\t\".\", QFileInfo(\"top.v\").absoluteFilePath());\r\n\r\n\tQCOMPARE(filesetDependencies.count(), 1);\r\n\tQCOMPARE(filesetDependencies.first().filename, \"johnson_counter.v\");\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_VerilogSourceAnalyzer::testMultipleModulesInFilesetFile()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_VerilogSourceAnalyzer::testMultipleModulesInFilesetFile()\r\n{\r\n\tQSharedPointer<Component> targetComponent(new Component(VLNV(), Document::Revision::Std14));\r\n\r\n\twriteTestFile(\r\n\t\t\"module test();\\n\"\r\n\t\t\"\\n\"\r\n\t\t\"johnson john_i();\\n\"\r\n\t\t\"endmodule\\n\",\r\n\t\t\"top.v\");\r\n\r\n\twriteTestFile(\r\n\t\t\"module counter();\\n\"\r\n\t\t\"endmodule\\n\"\r\n\t\t\"\\n\"\r\n\t\t\"module reverse_counter();\\n\"\r\n\t\t\"endmodule\\n\"\r\n\t\t\"\\n\"\r\n\t\t\"module johnson();\\n\"\r\n\t\t\"endmodule\\n\",\r\n\t\t\"counters.v\");\r\n\r\n\tQSharedPointer<File> submoduleFile(new File(\"counters.v\", \"verilogSource\"));\r\n\tQSharedPointer<FileSet> rtlFileSet(new FileSet(\"rtl\"));\r\n\trtlFileSet->addFile(submoduleFile);\r\n\ttargetComponent->getFileSets()->append(rtlFileSet);\r\n\r\n\tVerilogSourceAnalyzer analyzer;\r\n\tQList<FileDependencyDesc> filesetDependencies = analyzer.getFileDependencies(targetComponent.data(),\r\n\t\t\".\", QFileInfo(\"top.v\").absoluteFilePath());\r\n\r\n\tQCOMPARE(filesetDependencies.count(), 1);\r\n\tQCOMPARE(filesetDependencies.first().filename, \"counters.v\");\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_VerilogSourceAnalyzer::testNamedProcessIsNotSubmodule()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_VerilogSourceAnalyzer::testNamedProcessIsNotSubmodule()\r\n{\r\n\tQSharedPointer<Component> targetComponent(new Component(VLNV(), Document::Revision::Std14));\r\n\r\n\twriteTestFile(\r\n\t\t\"module johnson #(\\n\"\r\n\t\t\"    parameter WIDTH = 4\\n\"\r\n\t\t\")(\\n\"\r\n\t\t\"    input logic clk,\\n\"\r\n\t\t\"    input logic rst_n\"\r\n\t\t\"    output logic [WIDTH-1:0] count_out\"\r\n\t\t\");\"\r\n\t\t\"always_ff @(posedge clk or negedge rstn_i) begin : count\\n\"\r\n\t\t\"    if (~rst_n) begin\\n\"\r\n\t\t\"        count_out <= 0;\\n\"\r\n\t\t\"    end else begin\\n\"\r\n\t\t\"        count_out[WIDTH-1] <= ~count_out[0];\\n\"\r\n\t\t\"        for (int i = 0; i < WIDTH-1; i=i+i) begin\\n\"\r\n\t\t\"            count_out[i] <= count_out[i+1];\\n\"\r\n\t\t\"        end\\n\"\r\n\t\t\"    end\\n\"\r\n\t\t\"end\"\r\n\t\t\"endmodule\\n\",\r\n\t\t\"johnson.v\");\r\n\r\n\tVerilogSourceAnalyzer analyzer;\r\n\tQList<FileDependencyDesc> filesetDependencies = analyzer.getFileDependencies(targetComponent.data(),\r\n\t\t\".\", QFileInfo(\"johnson.v\").absoluteFilePath());\r\n\r\n\tQCOMPARE(filesetDependencies.count(), 0);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: tst_VerilogSourceAnalyzer::writeTestFile()\r\n//-----------------------------------------------------------------------------\r\nvoid tst_VerilogSourceAnalyzer::writeTestFile(QString const& content, QString const& fileName)\r\n{\r\n    QFile inputFile(fileName, this);\r\n    QVERIFY(inputFile.open(QIODevice::WriteOnly));\r\n    inputFile.write(content.toLatin1());\r\n    inputFile.close();\r\n\r\n\ttestFiles_.append(fileName);\r\n}\r\n\r\nQTEST_MAIN(tst_VerilogSourceAnalyzer)\r\n\r\n#include \"tst_VerilogSourceAnalyzer.moc\"\r\n"
  },
  {
    "path": "tests/Plugins/VerilogSourceAnalyzer/tst_VerilogSourceAnalyzer.pri",
    "content": "# ----------------------------------------------------\r\n# This file is generated by the Qt Visual Studio Add-in.\r\n# ------------------------------------------------------\r\n\r\nHEADERS += ../../../Plugins/VerilogSourceAnalyzer/VerilogSourceAnalyzer.h\r\nSOURCES += ./tst_VerilogSourceAnalyzer.cpp \\\r\n    ../../../Plugins/VerilogSourceAnalyzer/VerilogSourceAnalyzer.cpp\r\n"
  },
  {
    "path": "tests/Plugins/VerilogSourceAnalyzer/tst_VerilogSourceAnalyzer.pro",
    "content": "#-----------------------------------------------------------------------------\r\n# File: tst_VerilogSourceAnalyzer.pro\r\n#-----------------------------------------------------------------------------\r\n# Project: Kactus 2\r\n# Author: Esko Pekkarinen\r\n# Date: 07.04.2015\r\n#\r\n# Description:\r\n# Qt project file for running unit tests for VerilogSourceAnalyzer.\r\n#-----------------------------------------------------------------------------\r\n\r\nTEMPLATE = app\r\n\r\nTARGET = tst_VerilogSourceAnalyzer\r\n\r\nDEFINES += VERILOGSOURCEANALYZER_LIB\r\n\r\nQT += core xml gui testlib widgets\r\nCONFIG += c++11 testcase console\r\n\r\nQMAKE_EXPORTED_VARIABLES += MAKE_TESTARGS\r\nMAKE_TESTARGS.name = TESTARGS\r\nMAKE_TESTARGS.value = \"-platform offscreen\"\r\n\r\nwin32:CONFIG(release, debug|release) {\r\n    LIBS += -L$$PWD/../../../executable/ -lIPXACTmodels\r\n    LIBS += -L$$PWD/../../../executable/ -lKactusAPI\r\n    DESTDIR = ./release\r\n}\r\nelse:win32:CONFIG(debug, debug|release) {\r\n    LIBS += -L$$PWD/../../../executable/ -lIPXACTmodelsd\r\n    LIBS += -L$$PWD/../../../executable/ -lKactusAPId\r\n    DESTDIR = ./debug\r\n}\r\nelse:unix {\r\n    LIBS += -L$$PWD/../../../executable/ -lIPXACTmodels\r\n    LIBS += -L$$PWD/../../../executable/ -lKactusAPI\r\n    DESTDIR = ./release\r\n}\r\n\r\nINCLUDEPATH += $$DESTDIR\r\nINCLUDEPATH += ../../../\r\nINCLUDEPATH += $$PWD/../../../KactusAPI/include\r\n\r\nDEPENDPATH += .\r\nDEPENDPATH += ../../../\r\n\r\nOBJECTS_DIR += $$DESTDIR\r\n\r\nMOC_DIR += ./generatedFiles\r\nUI_DIR += ./generatedFiles\r\nRCC_DIR += ./generatedFiles\r\ninclude(tst_VerilogSourceAnalyzer.pri)\r\n"
  },
  {
    "path": "tests/configure_msvc_solution.bat",
    "content": "@echo off\r\nREM -----------------------------------------------------------------------------\r\nREM  File: configure_msvc_solution.bat\r\nREM -----------------------------------------------------------------------------\r\nREM  Project: Kactus 2\r\nREM  Author: Esko Pekkarinen\r\nREM  Date: 24.27.2014\r\nREM \r\nREM  Description:\r\nREM  Regenerates the visual studio project and solution files for all unit tests.\r\nREM -----------------------------------------------------------------------------\r\nqmake -tp vc -r\r\n"
  },
  {
    "path": "tests/library/tst_LibraryHandler.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: tst_LibraryHandler.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Esko Pekkarinen\n// Date: 30.03.2018\n//\n// Description:\n// Unit test for class LibraryHandler.\n//-----------------------------------------------------------------------------\n\n#include <QtTest>\n#include <QDebug>\n\n#include <Plugins/PluginSystem/GeneratorPlugin/MessagePasser.h>\n#include <KactusAPI/include/LibraryHandler.h>\n\nvoid noMessageOutput(QtMsgType type, const QMessageLogContext &context, const QString &msg) {}\n\nclass tst_LibraryHandler : public QObject\n{\n    Q_OBJECT\n\npublic:\n    tst_LibraryHandler();\n\nprivate:\n\n    LibraryHandler* createLibraryHandler();\n    \n    void setupTestLibrary();\n\n    MessagePasser messageChannel_;\n\nprivate slots:\n\n    void initTestcase();\n\n    void testLibraryDoesNotContainItem();\n\n    void testLibraryContainsItem();\n\n    void testLibraryGetModel();\n\n    void testDocumentsInLocationAreRead();\n\n\n};\n\ntst_LibraryHandler::tst_LibraryHandler()\n{\n\n}\n\nvoid tst_LibraryHandler::initTestcase()\n{\n    qInstallMessageHandler(noMessageOutput);\n    LibraryHandler::initialize(&messageChannel_, this);\n}\n\nvoid tst_LibraryHandler::setupTestLibrary()\n{\n    QCoreApplication::setOrganizationDomain(QStringLiteral(\"tut.fi\"));\n    QCoreApplication::setOrganizationName(QStringLiteral(\"TUT\"));\n    QCoreApplication::setApplicationName(QStringLiteral(\"Kactus2_tests\"));\n\n    QSettings settings;\n    settings.setPath(QSettings::IniFormat, QSettings::UserScope, \"tests.ini\");\n    settings.setValue(\"Library/ActiveLocations\", QStringList(\"D:/Data/kactus_test_libraries/\"));\n}\n\nLibraryHandler* tst_LibraryHandler::createLibraryHandler()\n{\n    return LibraryHandler::getInstance();\n}\n\nvoid tst_LibraryHandler::testLibraryDoesNotContainItem()\n{\n    QScopedPointer<LibraryHandler> library(createLibraryHandler());\n\n    //setupTestLibrary();\n\n    VLNV nonExistingItem(VLNV::COMPONENT, QStringLiteral(\"tut.fi:testLibrary:noItem:0\"));\n\n    bool result = true;\n    QBENCHMARK\n    {\n        result = library->contains(nonExistingItem);\n    }\n\n    QVERIFY(result == false);\n}\n\nvoid tst_LibraryHandler::testLibraryContainsItem()\n{\n    QScopedPointer<LibraryHandler> library(createLibraryHandler());\n\n    //setupTestLibrary();\n    library->searchForIPXactFiles();\n\n    VLNV validItem(VLNV::COMPONENT, QStringLiteral(\"tut.fi:cpu.logic:alu:1.0\"));\n\n    bool result = false;\n    QBENCHMARK\n    {\n        result = library->contains(validItem) ;\n    }\n\n    QVERIFY(result == true);\n}\n\nvoid tst_LibraryHandler::testLibraryGetModel()\n{\n    QScopedPointer<LibraryHandler> library(createLibraryHandler());\n\n    //setupTestLibrary();\n    library->searchForIPXactFiles();\n\n    VLNV validItem(VLNV::COMPONENT, QStringLiteral(\"tut.fi:cpu.logic:alu:1.0\"));\n\n    QSharedPointer<Document> model;\n    QBENCHMARK\n    {\n        model = library->getModel(validItem);\n    }\n\n    QVERIFY(model.isNull() == false);\n}\n\nvoid tst_LibraryHandler::testDocumentsInLocationAreRead()\n{\n    QScopedPointer<LibraryHandler> library(createLibraryHandler());\n\n    QVERIFY(library->getAllVLNVs().count() == 0);\n\n    setupTestLibrary();\n\n    QBENCHMARK\n    {\n        library->searchForIPXactFiles();\n    }\n\n    QVERIFY(library->getAllVLNVs().count() == 1338);\n}\n\n\nQTEST_APPLESS_MAIN(tst_LibraryHandler)\n\n#include \"tst_LibraryHandler.moc\"\n"
  },
  {
    "path": "tests/library/tst_LibraryHandler.pri",
    "content": "# ----------------------------------------------------\n# This file is generated by the Qt Visual Studio Tools.\n# ------------------------------------------------------\n\n# This is a reminder that you are using a generated .pro file.\n# Remove it when you are finished editing this file.\nmessage(\"You are running qmake on a generated .pro file. This may not work!\")\n\n\nHEADERS += ../../editors/ComponentEditor/common/ComponentParameterFinder.h \\\n    ../../common/ui/ConsoleMediator.h \\\n    ../../library/DocumentFileAccess.h \\\n    ../../library/DocumentValidator.h \\\n    ../../editors/ComponentEditor/common/ExpressionParser.h \\\n    ../../editors/ComponentEditor/common/IPXactSystemVerilogParser.h \\\n    ../../library/LibraryInterface.h \\\n    ../../library/LibraryItemSelectionFactory.h \\\n    ../../common/dialogs/LibrarySettingsDialog/LibrarySettingsColumns.h \\\n    ../../common/widgets/assistedLineEdit/LineContentAssistWidget.h \\\n    ../../editors/ComponentEditor/common/ListParameterFinder.h \\\n    ../../common/ui/MessageMediator.h \\\n    ../../common/dialogs/ObjectExportDialog/ObjectSelectionListItem.h \\\n    ../../editors/ComponentEditor/common/SystemVerilogExpressionParser.h \\\n    ../../library/TableViewDialog.h \\\n    ../../common/widgets/vlnvEditor/VLNVContentMatcher.h \\\n    ../../common/widgets/vlnvEditor/VLNVDataTree.h \\\n    ../../common/widgets/assistedLineEdit/AssistedLineEdit.h \\\n    ../../common/widgets/kactusAttributeEditor/KactusAttributeEditor.h \\\n    ../../library/LibraryErrorModel.h \\\n    ../../library/LibraryHandler.h \\\n    ../../library/LibraryItem.h \\\n    ../../library/LibraryLoader.h \\\n    ../../common/widgets/LibrarySelectorWidget/LibrarySelectorWidget.h \\\n    ../../common/dialogs/LibrarySettingsDialog/LibrarySettingsDialog.h \\\n    ../../library/LibraryTreeModel.h \\\n    ../../Plugins/PluginSystem/GeneratorPlugin/MessagePasser.h \\\n    ../../common/dialogs/ObjectExportDialog/ObjectExportDialog.h \\\n    ../../common/dialogs/ObjectExportDialog/ObjectSelectionDialog.h \\\n    ../../editors/ComponentEditor/common/ParameterCache.h \\\n    ../../library/HierarchyView/hierarchyitem.h \\\n    ../../library/HierarchyView/hierarchymodel.h \\\n    ../../common/widgets/LibrarySelectorWidget/LibraryPathEditor/librarypatheditor.h \\\n    ../../common/widgets/LibrarySelectorWidget/LibraryPathSelector/librarypathselector.h \\\n    ../../common/validators/LibraryPathValidator/librarypathvalidator.h \\\n    ../../common/dialogs/LibrarySettingsDialog/librarysettingsdelegate.h \\\n    ../../common/dialogs/newObjectDialog/newobjectdialog.h \\\n    ../../common/dialogs/ObjectRemoveDialog/objectremovedialog.h \\\n    ../../common/widgets/vlnvEditor/vlnveditor.h\nSOURCES += ../../common/widgets/assistedLineEdit/AssistedLineEdit.cpp \\\n    ../../editors/ComponentEditor/common/ComponentParameterFinder.cpp \\\n    ../../common/ui/ConsoleMediator.cpp \\\n    ../../library/DocumentFileAccess.cpp \\\n    ../../library/DocumentValidator.cpp \\\n    ../../editors/ComponentEditor/common/IPXactSystemVerilogParser.cpp \\\n    ../../common/widgets/kactusAttributeEditor/KactusAttributeEditor.cpp \\\n    ../../library/LibraryErrorModel.cpp \\\n    ../../library/LibraryHandler.cpp \\\n    ../../library/LibraryItem.cpp \\\n    ../../library/LibraryItemSelectionFactory.cpp \\\n    ../../library/LibraryLoader.cpp \\\n    ../../common/widgets/LibrarySelectorWidget/LibrarySelectorWidget.cpp \\\n    ../../common/dialogs/LibrarySettingsDialog/LibrarySettingsDialog.cpp \\\n    ../../library/LibraryTreeModel.cpp \\\n    ../../common/widgets/assistedLineEdit/LineContentAssistWidget.cpp \\\n    ../../editors/ComponentEditor/common/ListParameterFinder.cpp \\\n    ../../Plugins/PluginSystem/GeneratorPlugin/MessagePasser.cpp \\\n    ../../common/dialogs/ObjectExportDialog/ObjectExportDialog.cpp \\\n    ../../common/dialogs/ObjectExportDialog/ObjectSelectionDialog.cpp \\\n    ../../common/dialogs/ObjectExportDialog/ObjectSelectionListItem.cpp \\\n    ../../editors/ComponentEditor/common/ParameterCache.cpp \\\n    ../../editors/ComponentEditor/common/SystemVerilogExpressionParser.cpp \\\n    ../../library/TableViewDialog.cpp \\\n    ../../common/widgets/vlnvEditor/VLNVContentMatcher.cpp \\\n    ../../common/widgets/vlnvEditor/VLNVDataTree.cpp \\\n    ../../library/HierarchyView/hierarchyitem.cpp \\\n    ../../library/HierarchyView/hierarchymodel.cpp \\\n    ../../common/widgets/LibrarySelectorWidget/LibraryPathEditor/librarypatheditor.cpp \\\n    ../../common/widgets/LibrarySelectorWidget/LibraryPathSelector/librarypathselector.cpp \\\n    ../../common/validators/LibraryPathValidator/librarypathvalidator.cpp \\\n    ../../common/dialogs/LibrarySettingsDialog/librarysettingsdelegate.cpp \\\n    ../../common/dialogs/newObjectDialog/newobjectdialog.cpp \\\n    ../../common/dialogs/ObjectRemoveDialog/objectremovedialog.cpp \\\n    ../../common/widgets/vlnvEditor/vlnveditor.cpp \\\n    ./tst_LibraryHandler.cpp\n"
  },
  {
    "path": "tests/library/tst_LibraryHandler.pro",
    "content": "#-----------------------------------------------------------------------------\n# File: unittest.pro\n#-----------------------------------------------------------------------------\n# Project: Kactus 2\n# Author: Esko Pekkarinen\n# Date: 24.7.2014\n#\n# Description:\n# Qt project file template for running unit tests for a single module.\n#-----------------------------------------------------------------------------\n\nTEMPLATE = app\n\nTARGET = tst_LibraryHandler\n\nQT += core xml gui testlib widgets\nCONFIG += testcase console c++14\n\nQMAKE_EXPORTED_VARIABLES += MAKE_TESTARGS\nMAKE_TESTARGS.name = TESTARGS\nMAKE_TESTARGS.value = \"-platform offscreen\"\n\nwin32:CONFIG(release, debug|release) {\n    LIBS += -L$$PWD/../../x64/executable/ -lIPXACTmodels\n    DESTDIR = ./release\n}\nelse:win32:CONFIG(debug, debug|release) {\n    LIBS += -L$$PWD/../../x64/executable/ -lIPXACTmodelsd\n    DESTDIR = ./debug\n}\nelse:unix {\n    LIBS += -L$$PWD/../../executable/ -lIPXACTmodels \n    DESTDIR = ./release\n}\n\nINCLUDEPATH += $$PWD/../../\nINCLUDEPATH += $$PWD/../../executable\nINCLUDEPATH += $$DESTDIR\n\nDEPENDPATH += $$PWD/../../\nDEPENDPATH += $$PWD/../../executable\nDEPENDPATH += .\n\nINCLUDEPATH += $$DESTDIR\n\nDEPENDPATH += .\n\nOBJECTS_DIR += $$DESTDIR\n\nMOC_DIR += ./generatedFiles\nUI_DIR += ./generatedFiles\nRCC_DIR += ./generatedFiles\n\ninclude(tst_LibraryHandler.pri)\n"
  },
  {
    "path": "tests/pro_templates/subdirs.pro",
    "content": "#-----------------------------------------------------------------------------\r\n# File: subdirs.pro\r\n#-----------------------------------------------------------------------------\r\n# Project: Kactus2\r\n# Author: Esko Pekkarinen\r\n# Date: 24.7.2014\r\n#\r\n# Description:\r\n# Qt project file template for running unit tests in subdirectories.\r\n#-----------------------------------------------------------------------------\r\n\r\nTEMPLATE = subdirs\r\n\r\nCONFIG += testcase\r\nSUBDIRS += <subdir/subproject.pro>\r\n"
  },
  {
    "path": "tests/pro_templates/tst_Module.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: tst_<Module>.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: <Name>\r\n// Date: <Date in the format dd.mm.yyyy>\r\n//\r\n// Description:\r\n// Unit test for class <Module>.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include <QtTest>\r\n\r\nclass tst_<Module> : public QObject\r\n{\r\n    Q_OBJECT\r\n\r\npublic:\r\n    tst_<Module>();\r\n\r\nprivate slots:\r\n    void testCase1();\r\n};\r\n\r\ntst_<Module>::tst_<Module>()\r\n{\r\n}\r\n\r\nvoid tst_<Module>::testCase1()\r\n{\r\n    QVERIFY2(false, \"Failing here on purpose.\");\r\n}\r\n\r\nQTEST_APPLESS_MAIN(tst_<Module>)\r\n\r\n#include \"tst_<Module>.moc\"\r\n"
  },
  {
    "path": "tests/pro_templates/tst_Module.pri",
    "content": "#-----------------------------------------------------------------------------\r\n# File: tst_<Module>.pri\r\n#-----------------------------------------------------------------------------\r\n# Project: Kactus2\r\n# Author: Esko Pekkarinen\r\n# Date: 28.03.2018\r\n#\r\n# Description:\r\n# Qt project include file template.\r\n#-----------------------------------------------------------------------------\r\n\r\nSOURCES += ./tst_<Module>.cpp"
  },
  {
    "path": "tests/pro_templates/tst_Module.pro",
    "content": "#-----------------------------------------------------------------------------\r\n# File: tst_<Module>.pro\r\n#-----------------------------------------------------------------------------\r\n# Project: Kactus2\r\n# Author: Esko Pekkarinen\r\n# Date: 28.03.2018\r\n#\r\n# Description:\r\n# Qt project file template for running unit tests for a single module.\r\n#-----------------------------------------------------------------------------\r\n\r\nTEMPLATE = app\r\n\r\nTARGET = tst_<Module>\r\n\r\nQT += core xml gui testlib\r\nCONFIG += c++11 testcase console\r\n\r\n# Remove the following, if IP-XACT models library is not needed.\r\nlinux-g++ | linux-g++-64 | linux-g++-32 {\r\n LIBS += -L../../../x64/executable \\\r\n     -lIPXACTmodels \r\n}\r\nwin64 | win32 {\r\n LIBS += -L../../../x64/executable \\\r\n     -lIPXACTmodelsd\r\n}\r\n\r\nDESTDIR = ./release\r\n\r\nINCLUDEPATH += $$DESTDIR\r\n\r\nDEPENDPATH += .\r\n\r\nOBJECTS_DIR += $$DESTDIR\r\n\r\nMOC_DIR += ./generatedFiles\r\nUI_DIR += ./generatedFiles\r\nRCC_DIR += ./generatedFiles\r\ninclude(tst_<Module>.pri)\r\n"
  },
  {
    "path": "tests/test_all.pro",
    "content": "#-----------------------------------------------------------------------------\r\n# File: test_all.pro\r\n#-----------------------------------------------------------------------------\r\n# Project: Kactus 2\r\n# Author: Esko Pekkarinen\r\n# Date: 24.27.2014\r\n#\r\n# Description:\r\n# Qt project file for running all unit tests.\r\n#-----------------------------------------------------------------------------\r\n\r\nTEMPLATE = subdirs\r\n\r\nCONFIG += testcase\r\n\r\nSUBDIRS += IPXACTmodels/IPXACTmodels.pro \\\r\n\t\tKactusAPI/KactusAPI.pro \\\r\n\t\tCore/Core.pro \\\r\n\t\tPlugins/Plugins.pro\r\n        \r\n"
  },
  {
    "path": "version.h",
    "content": "/*-----------------------------------------------------------\r\n  VERSION CONTROL BUILD SYSTEM\r\n  This header file was created by VERBUILD v1.0.1\r\n  -----------------------------------------------------------\r\n  help : verbuild -?\r\n  info : http://www.yeamaec.com\r\n         yeamaec@hanafos.com ,krkim@yeamaec.com\r\n-----------------------------------------------------------*/\r\n\r\n#ifndef VERSIONNO__H\r\n#define VERSIONNO__H\r\n\r\n#define VERSION_FULL           3.14.39.0\r\n\r\n#define VERSION_BASEYEAR       0\r\n#define VERSION_DATE           \"2026-04-30\"\r\n#define VERSION_TIME           \"09:30:45\"\r\n\r\n#define VERSION_MAJOR          3\r\n#define VERSION_MINOR          14\r\n#define VERSION_BUILDNO        39\r\n#define VERSION_EXTEND         0\r\n\r\n#define VERSION_FILE           3,14,39,0\r\n#define VERSION_PRODUCT        3,14,39,0\r\n#define VERSION_FILESTR        \"3,14,39,0\"\r\n#define VERSION_PRODUCTSTR     \"3,14,39,0\"\r\n\r\n#endif\r\n"
  },
  {
    "path": "wizards/BusInterfaceWizard/BusInterfaceWizard.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: BusInterfaceWizard.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Esko Pekkarinen\r\n// Date: 25.11.2013\r\n//\r\n// Description:\r\n// Wizard for generating bus interface from a set of ports.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"BusInterfaceWizard.h\"\r\n\r\n#include <QLabel>\r\n#include <QVBoxLayout>\r\n\r\n#include \"BusInterfaceWizardIntroPage.h\"\r\n#include \"BusInterfaceWizardGeneralOptionsPage.h\"\r\n#include \"BusInterfaceWizardBusDefinitionPage.h\"\r\n#include \"BusInterfaceWizardAbsDefinitionPage.h\"\r\n#include \"BusInterfaceWizardPortMapPage.h\"\r\n#include \"BusInterfaceWizardConclusionPage.h\"\r\n\r\n#include <KactusAPI/include/ComponentParameterFinder.h>\r\n#include <KactusAPI/include/ExpressionFormatter.h>\r\n#include <KactusAPI/include/IPXactSystemVerilogParser.h>\r\n#include <KactusAPI/include/BusInterfaceInterfaceFactory.h>\r\n#include <KactusAPI/include/BusInterfaceInterface.h>\r\n#include <KactusAPI/include/AbstractionTypeInterface.h>\r\n#include <KactusAPI/include/PortMapInterface.h>\r\n\r\n#include <IPXACTmodels/common/validators/ParameterValidator.h>\r\n#include <IPXACTmodels/Component/Component.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusInterfaceWizard::BusInterfaceWizard()\r\n//-----------------------------------------------------------------------------\r\nBusInterfaceWizard::BusInterfaceWizard(QSharedPointer<Component> component, QSharedPointer<BusInterface> busIf,\r\n    LibraryInterface* handler, QStringList portNames, QWidget* parent, VLNV absDefVLNV,\r\n    bool descriptionAsLogicalName) :\r\n QWizard(parent)\r\n{\r\n    setWindowTitle(tr(\"Bus Interface Wizard\"));\r\n    setWizardStyle(ModernStyle);\r\n    setOption(NoCancelButton, true);\r\n    setOption(NoDefaultButton, true);\r\n    setOption(HaveFinishButtonOnEarlyPages, false);\r\n    resize(800, 800);\r\n\r\n    QSharedPointer<ParameterFinder> parameterFinder(new ComponentParameterFinder(component));\r\n    QSharedPointer<ExpressionFormatter> expressionFormatter(new ExpressionFormatter(parameterFinder));\r\n    QSharedPointer<IPXactSystemVerilogParser> expressionParser(new IPXactSystemVerilogParser(parameterFinder));\r\n\r\n    QSharedPointer<ParameterValidator> parameterValidator(new ParameterValidator(\r\n        expressionParser, component->getChoices(), component->getRevision()));\r\n\r\n    BusInterfaceWizardAbsDefinitionPage::SignalNamingPolicy namingPolicy =\r\n        BusInterfaceWizardAbsDefinitionPage::NAME;\r\n\r\n    if (descriptionAsLogicalName)\r\n    {\r\n        namingPolicy = BusInterfaceWizardAbsDefinitionPage::DESCRIPTION;\r\n    }\r\n\r\n    BusInterfaceInterface* busInterface = BusInterfaceInterfaceFactory::createBusInterface(\r\n        parameterFinder, expressionFormatter, expressionParser, component, handler);\r\n\r\n    AbstractionTypeInterface const* absTypeInterface = busInterface->getAbstractionTypeInterface();\r\n    if (absTypeInterface)\r\n    {\r\n        PortMapInterface* portMapInterface = absTypeInterface->getPortMapInterface();\r\n        if (portMapInterface)\r\n        {\r\n            auto optionsPage = new BusInterfaceWizardGeneralOptionsPage(\r\n                component, busIf, handler, !absDefVLNV.isValid(), parameterFinder, expressionFormatter,\r\n                expressionParser, busInterface, this);\r\n            auto portMapsPage = new BusInterfaceWizardPortMapPage(component, busIf, handler, portNames,\r\n                expressionParser, parameterFinder, busInterface, portMapInterface, this);\r\n\r\n            connect(optionsPage, SIGNAL(increaseReferences(QString)),\r\n                this, SIGNAL(increaseReferences(QString)), Qt::UniqueConnection);\r\n            connect(optionsPage, SIGNAL(decreaseReferences(QString)),\r\n                this, SIGNAL(decreaseReferences(QString)), Qt::UniqueConnection);\r\n\r\n            connect(optionsPage, SIGNAL(busNameChanged(std::string const&)), portMapsPage, SIGNAL(busNameChanged(std::string const&)), Qt::UniqueConnection);\r\n\r\n            setPage(PAGE_INTRO, new BusInterfaceWizardIntroPage(this));\r\n            setPage(PAGE_GENERALOPTIONS, optionsPage);\r\n            setPage(PAGE_BUSDEFINITION, new BusInterfaceWizardBusDefinitionEditorPage(\r\n                component, busIf, handler, absDefVLNV.isValid(), this));\r\n            setPage(PAGE_ABSDEFINITION, new BusInterfaceWizardAbsDefinitionPage(\r\n                component, busIf, handler, portNames, this, absDefVLNV, expressionParser, namingPolicy));\r\n            setPage(PAGE_PORTMAPS, portMapsPage);\r\n            setPage(PAGE_SUMMARY, new BusInterfaceWizardConclusionPage(busIf, portNames, this));\r\n        }\r\n    }\r\n}\r\n"
  },
  {
    "path": "wizards/BusInterfaceWizard/BusInterfaceWizard.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: BusInterfaceWizard.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Esko Pekkarinen\r\n// Date: 25.11.2013\r\n//\r\n// Description:\r\n// Wizard for generating bus interface from a set of ports.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef BUSINTERFACEWIZARD_H\r\n#define BUSINTERFACEWIZARD_H\r\n\r\n#include <IPXACTmodels/common/VLNV.h>\r\n\r\n#include <QWizard>\r\n#include <QSharedPointer>\r\n\r\nclass BusInterface;\r\nclass BusInterfaceValidator;\r\nclass Component;\r\nclass LibraryInterface;\r\nclass ExpressionParser;\r\nclass ParameterValidator;\r\nclass IPXactSystemVerilogParser;\r\nclass BusInterfaceInterface;\r\nclass FileSetInterface;\r\nclass MemoryMapInterface;\r\nclass AbstractionTypeInterface;\r\nclass PortMapInterface;\r\nclass TransparentBridgeInterface;\r\nclass PortMapValidator;\r\nclass ParameterFinder;\r\nclass ExpressionFormatter;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Bus wizard dialog.\r\n//-----------------------------------------------------------------------------\r\nclass BusInterfaceWizard : public QWizard\r\n{\r\n    Q_OBJECT\r\n\r\npublic:\r\n    \r\n    //! Enumeration for the wizard pages.\r\n    enum Pages\r\n    {\r\n        PAGE_INTRO = 0,\r\n        PAGE_GENERALOPTIONS,\r\n        PAGE_BUSDEFINITION,\r\n        PAGE_ABSDEFINITION,\r\n        PAGE_PORTMAPS,\r\n        PAGE_SUMMARY\r\n\t };    \r\n\r\n    /*!\r\n     *  The constructor.\r\n     *\r\n     *    @param [in] component                   The component for which the wizard is run.\r\n     *    @param [in] busIf                       The bus interface for which the wizard is run.\r\n     *    @param [in] handler                     Pointer to the instance which manages the library.\r\n     *    @param [in] portNames                   Names of the physical ports used to generate the interface.\r\n     *    @param [in] parent                      The parent widget.\r\n     *    @param [in] absDefVLNV                  VLNV of the fixed abstraction definition of the bus interface.\r\n     *                                              If invalid, VLNV can be chosen freely on general page.\r\n     *    @param [in] descriptionAsLogicalName    Logical signal naming selection.\r\n     */\r\n    BusInterfaceWizard(QSharedPointer<Component> component,  \r\n        QSharedPointer<BusInterface> busIf,\r\n        LibraryInterface* handler, QStringList portNames,         \r\n        QWidget* parent = 0, \r\n        VLNV absDefVLNV = VLNV(), \r\n        bool descriptionAsLogicalName = false);\r\n\r\n\t /*!\r\n\t *  Destructor.\r\n\t */\r\n\t ~BusInterfaceWizard() final = default;\r\n\r\nsignals:\r\n\r\n     /*!\r\n      *  Increase the number of references made to a specific parameter.\r\n      *\r\n      *    @param [in] id  The id of the parameter whose reference count is to be increased.\r\n      */\r\n     void increaseReferences(QString id);\r\n\r\n     /*!\r\n      *  Decrease the number of references made to a specific parameter.\r\n      *\r\n      *    @param [in] id  The id of the parameter whose reference count is to be decreased.\r\n      */\r\n     void decreaseReferences(QString id);\r\n\r\nprivate:\r\n    // Disable copying.\r\n    BusInterfaceWizard(BusInterfaceWizard const& rhs);\r\n    BusInterfaceWizard& operator=(BusInterfaceWizard const& rhs);\r\n};\r\n\r\n#endif // BUSINTERFACEWIZARD_H\r\n"
  },
  {
    "path": "wizards/BusInterfaceWizard/BusInterfaceWizardAbsDefinitionPage.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: BusInterfaceWizardAbsDefinitionPage.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Esko Pekkarinen\n// Date: 25.11.2013\n//\n// Description:\n// Bus interface wizard page for editing bus and abstraction definitions.\n//-----------------------------------------------------------------------------\n\n#include \"BusInterfaceWizardAbsDefinitionPage.h\"\n\n#include \"BusInterfaceWizard.h\"\n\n#include <editors/AbstractionDefinitionEditor/absdefgroup.h>\n#include <editors/ComponentEditor/ports/portsdelegate.h>\n#include <KactusAPI/include/ExpressionParser.h>\n\n#include <KactusAPI/include/LibraryInterface.h>\n\n#include <IPXACTmodels/AbstractionDefinition/AbstractionDefinition.h>\n\n#include <IPXACTmodels/BusDefinition/BusDefinition.h>\n#include <IPXACTmodels/BusDefinition/BusDefinition.h>\n\n#include <IPXACTmodels/AbstractionDefinition/PortAbstraction.h>\n#include <IPXACTmodels/AbstractionDefinition/WireAbstraction.h>\n#include <IPXACTmodels/AbstractionDefinition/WirePort.h>\n\n#include <IPXACTmodels/Component/Component.h>\n#include <IPXACTmodels/Component/BusInterface.h>\n#include <IPXACTmodels/Component/Port.h>\n#include <IPXACTmodels/Component/PortMap.h>\n#include <IPXACTmodels/common/Vector.h>\n#include <IPXACTmodels/common/VLNV.h>\n\n#include <QVBoxLayout>\n#include <QLabel>\n#include <QMessageBox>\n#include <QPushButton>\n\n//-----------------------------------------------------------------------------\n// Function: BusInterfaceWizardAbsDefinitionPage::BusInterfaceWizardAbsDefinitionPage()\n//-----------------------------------------------------------------------------\nBusInterfaceWizardAbsDefinitionPage::BusInterfaceWizardAbsDefinitionPage(QSharedPointer<Component> component,\n    QSharedPointer<BusInterface> busIf, LibraryInterface* lh, QStringList physicalPorts,\n    BusInterfaceWizard* parent, VLNV& absDefVLNV, QSharedPointer<ExpressionParser> expressionParser,\n    SignalNamingPolicy namingPolicy /* = NAME */):\nQWizardPage(parent),\n    handler_(lh),\n    component_(component),\n    busIf_(busIf),\n    absDefVLNV_(absDefVLNV),\n    physicalPorts_(physicalPorts),\n    editor_(this, handler_, nullptr, component->getRevision()),\n    portNamesPolicy_(namingPolicy),\n    portMappings_(),\n    hasChanged_(false),\n    mappingMode_(NO_GENERATION),\n    expressionParser_(expressionParser)\n{       \n    setTitle(tr(\"Abstraction Definition\"));\n    setSubTitle(tr(\"Verify the logical signals in the abstraction definition.\"));\n    setFinalPage(false);\n\n    connect(&editor_, SIGNAL(portRenamed(QString const&, QString const&)), \n        this, SLOT(portRenamed(QString const&, QString const&)), Qt::UniqueConnection);\n    connect(&editor_, SIGNAL(portRemoved(QString const&, const General::InterfaceMode)), \n        this, SLOT(portRemoved(QString const&, const General::InterfaceMode)), Qt::UniqueConnection);\n    \n    setupLayout();    \n}\n\n//-----------------------------------------------------------------------------\n// Function: BusInterfaceWizardAbsDefinitionPage::nextId()\n//-----------------------------------------------------------------------------\nint BusInterfaceWizardAbsDefinitionPage::nextId() const\n{\n    return BusInterfaceWizard::PAGE_PORTMAPS;\n}\n\n//-----------------------------------------------------------------------------\n// Function: BusInterfaceWizardAbsDefinitionPage::initializePage()\n//-----------------------------------------------------------------------------\nvoid BusInterfaceWizardAbsDefinitionPage::initializePage()\n{   \n    VLNV abstractionReference;\n    if (busIf_->getAbstractionTypes() && busIf_->getAbstractionTypes()->size() == 1 &&\n        busIf_->getAbstractionTypes()->first()->getAbstractionRef())\n    {\n        abstractionReference = *busIf_->getAbstractionTypes()->first()->getAbstractionRef().data();\n    }\n\n    QSharedPointer<AbstractionDefinition> absDef;\n    bool newAbsDef = false;\n    if (abstractionReference.isValid())\n    {\n        absDef = handler_->getModel<AbstractionDefinition>(abstractionReference);\n\n        newAbsDef = (absDefVLNV_.isValid() && abstractionReference == absDefVLNV_);\n    }\n\n    portMappings_.clear();\n    \n    if (newAbsDef && absDef)\n    {\n        mappingMode_ = GENERATE_ALL;\n        createLogicalPortsAndMappings(physicalPorts_, absDef);\n    }\n    else if (absDef && absDef->getPortNames(busIf_->getInterfaceMode()).size() == 1)\n    {\n        mappingMode_ = GENERATE_SINGLE;\n        QString logicalSignal = absDef->getPortNames(busIf_->getInterfaceMode()).first();\n        createLogicalMappings(physicalPorts_, logicalSignal, \n            absDef->getPortDirection(logicalSignal, busIf_->getInterfaceMode(), busIf_->getSystem()));\n    }\n    else\n    {\n        mappingMode_ = NO_GENERATION;\n    }\n\n    editor_.setAbsDef(absDef);\n    editor_.setProtection(!newAbsDef);   \n}\n\n//-----------------------------------------------------------------------------\n// Function: BusInterfaceWizardAbsDefinitionPage::validatePage()\n//-----------------------------------------------------------------------------\nbool BusInterfaceWizardAbsDefinitionPage::validatePage()\n{    \n    QVector<QString> errors;\n    bool valid = editor_.validate(errors);\n\n    if (!valid)\n    {\n        QMessageBox warningDialog(QMessageBox::Warning, tr(\"Warning\"),\n            tr(\"Bus definition has the following error(s):\\n\") + QStringList(errors.toList()).join(\"\\n\"),\n            QMessageBox::Ok, this);        \n        warningDialog.exec();\n        return false;\n    }\n    \n    if (busIf_->getAbstractionTypes() && busIf_->getAbstractionTypes()->size() == 1 &&\n        busIf_->getAbstractionTypes()->first()->getAbstractionRef() && absDefVLNV_.isValid() &&\n        *busIf_->getAbstractionTypes()->first()->getAbstractionRef().data() == absDefVLNV_)\n    {\n        editor_.save();\n    }\n    \n    createPortMaps();\n\n    return true;\n}\n\n//-----------------------------------------------------------------------------\n// Function: BusInterfaceWizardAbsDefinitionPage::portRenamed()\n//-----------------------------------------------------------------------------\nvoid BusInterfaceWizardAbsDefinitionPage::portRenamed(QString const& oldName, QString const& newName)\n{\n    for (QMap<QString, QString>::iterator i = portMappings_.begin(); i != portMappings_.end(); i++)\n    {\n        if (QString::compare(i.value(), oldName) == 0)\n        {\n            portMappings_.insert(i.key(), newName);\n        }\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: BusInterfaceWizardAbsDefinitionPage::portRemoved()\n//-----------------------------------------------------------------------------\nvoid BusInterfaceWizardAbsDefinitionPage::portRemoved(QString const& portName, const General::InterfaceMode mode)\n{\n    if (mode == busIf_->getInterfaceMode() || mode == General::INTERFACE_MODE_COUNT)\n    {\n        QStringList removeable;\n        for (QMap<QString, QString>::iterator i = portMappings_.begin(); i != portMappings_.end(); i++)\n        {\n            if (QString::compare(i.value(), portName) == 0 && !removeable.contains(i.key()))\n            {\n                removeable.append(i.key());\n            }\n        }\n\n        for (QString const& port : removeable)\n        {\n            portMappings_.remove(port);\n        }\n    }       \n}\n\n//-----------------------------------------------------------------------------\n// Function: BusInterfaceWizardAbsDefinitionPage::setupLayout()\n//-----------------------------------------------------------------------------\nvoid BusInterfaceWizardAbsDefinitionPage::setupLayout()\n{\n    QVBoxLayout* topLayout = new QVBoxLayout(this);\n    topLayout->addWidget(&editor_);\n}\n\n//-----------------------------------------------------------------------------\n// Function: BusInterfaceWizardAbsDefinitionPage::createLogicalPortsAndMappings()\n//-----------------------------------------------------------------------------\nvoid BusInterfaceWizardAbsDefinitionPage::createLogicalPortsAndMappings(QStringList const& physPorts, \n    QSharedPointer<AbstractionDefinition> absDef)\n{\n    QSharedPointer<QList<QSharedPointer<PortAbstraction> > > logicalPorts = absDef->getLogicalPorts(); \n    logicalPorts->clear();\n\n    for (QString const& port : physPorts)\n    {\n        QSharedPointer<Port> physPort = component_->getPort(port);\n        DirectionTypes::Direction portDirection = physPort->getDirection();\n        int portWidth = getPortSize(physPort);\n\n        QSharedPointer<PortAbstraction> absPort(0);\n\n        QRegularExpression indexExp(\"\\\\[(\\\\d+)\\\\]\");\n        QString absPortName = physPort->name().toUpper();        \n        if (portNamesPolicy_ == DESCRIPTION)\n        {\n            absPortName = physPort->description().toUpper();\n            absPortName.remove(indexExp);\n            absPort = findPortByName(absPortName, logicalPorts);\n        }\n\n        if (!absPort.isNull())\n        {\n            int index = indexExp.match(absPortName).captured(1).toInt(); //!< On failed capture, index = 0.\n            int masterPortWidth =\n                expressionParser_->parseExpression(absPort->getWire()->getMasterPort()->getWidth()).toInt();\n            int physicalPortSize = index + getPortSize(physPort);\n            int newSize = qMax(masterPortWidth, physicalPortSize);\n\n            absPort->getWire()->getMasterPort()->setWidth(QString::number(newSize));\n            absPort->getWire()->getSlavePort()->setWidth(QString::number(newSize));\n        }\n        else\n        {\n            absPort = createAbsPort(absPortName, portDirection, portWidth);\n            logicalPorts->append(absPort);\n        }               \n        portMappings_.insert(port, absPortName);\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: BusInterfaceWizardAbsDefinitionPage::createLogicalMappings()\n//-----------------------------------------------------------------------------\nvoid BusInterfaceWizardAbsDefinitionPage::createLogicalMappings(QStringList const& physPorts, \n    QString const& logicalPort, DirectionTypes::Direction logicalDirection)\n{\n    for (QString const& physPort : physPorts)\n    {\n        DirectionTypes::Direction physDirection = component_->getPort(physPort)->getDirection();\n        if (logicalDirection == DirectionTypes::INOUT || physDirection == DirectionTypes::INOUT ||\n            logicalDirection == physDirection )\n        {\n            portMappings_.insert(physPort, logicalPort);\n        }        \n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: BusInterfaceWizardAbsDefinitionPage::createPortMaps()\n//-----------------------------------------------------------------------------\nvoid BusInterfaceWizardAbsDefinitionPage::createPortMaps()\n{\n    QList<QSharedPointer<PortMap> > portMaps;            \n    if (mappingMode_ != NO_GENERATION && busIf_->getAbstractionTypes() &&\n        busIf_->getAbstractionTypes()->size() == 1 && busIf_->getAbstractionTypes()->first()->getAbstractionRef())\n    {\n        QSharedPointer<Document> libComp =  \n            handler_->getModel(*busIf_->getAbstractionTypes()->first()->getAbstractionRef());\n        QSharedPointer<AbstractionDefinition> absDef = libComp.dynamicCast<AbstractionDefinition>();\n        if (absDef)\n        {\n            int logicalMax = 0;\n            for (QString const& port : physicalPorts_)\n            {\n                QString logicalName = portMappings_.value(port);\n\n                // Map only to logical signals that are defined.\n                if (absDef->hasPort(logicalName, busIf_->getInterfaceMode()))\n                {\n                    QSharedPointer<Port> physPort = component_->getPort(port);\n                    int portWidth = getPortSize(physPort);\n\n                    if (portWidth < 1)\n                    {\n                        portWidth = 1;\n                    }\n\n                    // By default, map whole port aligned to logical bit 0.                                        \n                    int lowerLogical = 0;\n                    int higherLogical = portWidth - 1;\n\n                    // Use bit index in description to map to logical signal, if logical signals\n                    // are generated from the physical ports and index is found in description.\n                    QRegularExpression indexExp(\"\\\\[(\\\\d+)\\\\]\");                    \n                    if ( (mappingMode_ == GENERATE_SINGLE || portNamesPolicy_ == DESCRIPTION) && \n                        physPort->description().contains(indexExp))\n                    {\n                        lowerLogical = indexExp.match(physPort->description()).captured(1).toInt();\n                        higherLogical += lowerLogical;                       \n                    }\n                    // If all ports are mapped to a single logical port, map them in ascending bit order.\n                    else if (mappingMode_ == GENERATE_SINGLE)\n                    {\n                        lowerLogical = logicalMax;\n                        higherLogical = lowerLogical + portWidth - 1;\n                        logicalMax = lowerLogical + portWidth;\n                    }\n\n                    QString absWidth = absDef->getPort(logicalName)->getWire()->getWidth(\n                        busIf_->getInterfaceMode(), busIf_->getSystem());\n                    if (absWidth.isEmpty() || higherLogical < absWidth.toInt())\n                    {\n                        QSharedPointer<PortMap> portMap(new PortMap());\n\n                        QSharedPointer<PortMap::LogicalPort> logicalPort(new PortMap::LogicalPort());\n                        logicalPort->name_ = logicalName;\n                        logicalPort->range_ = QSharedPointer<Range>(new Range(QString::number(higherLogical), \n                            QString::number(lowerLogical)));\n                        portMap->setLogicalPort(logicalPort);\n\n                        QSharedPointer<PortMap::PhysicalPort> physicalPort(new PortMap::PhysicalPort(port));\n\n                        physicalPort->partSelect_ = \n                            QSharedPointer<PartSelect>(new PartSelect(QString::number(portWidth - 1),\n                            QStringLiteral(\"0\")));\n                        portMap->setPhysicalPort(physicalPort);\n                        portMaps.append(portMap);\n                    }\n                }\n            }\n        }\n    }\n\n    if (busIf_->getAbstractionTypes() && busIf_->getAbstractionTypes()->first()->getAbstractionRef())\n    {\n        QSharedPointer<QList<QSharedPointer<PortMap> > > busIfPortMaps = \n            busIf_->getAbstractionTypes()->first()->getPortMaps();\n        busIfPortMaps->clear();\n        busIfPortMaps->append(portMaps);\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: BusInterfaceWizardAbsDefinitionPage::createAbsPort()\n//-----------------------------------------------------------------------------\nQSharedPointer<PortAbstraction> BusInterfaceWizardAbsDefinitionPage::createAbsPort(QString const& portName, \n    DirectionTypes::Direction portDirection, int portWidth)\n{\n    QSharedPointer<PortAbstraction> absPort(new PortAbstraction());\n    absPort->setLogicalName(portName);\n    absPort->setWire(QSharedPointer<WireAbstraction>(new WireAbstraction()));\n\n    if (busIf_->getInterfaceMode() == General::MASTER || busIf_->getInterfaceMode() == General::MIRRORED_MASTER || busIf_->getInterfaceMode() == General::INITIATOR || busIf_->getInterfaceMode() == General::MIRRORED_INITIATOR)\n    {\n        QSharedPointer<WirePort> masterPort(new WirePort());\n        masterPort->setDirection(portDirection);\n\n        QSharedPointer<WirePort> slavePort(new WirePort());\n        slavePort->setDirection(DirectionTypes::convert2Mirrored(portDirection));\n\n        absPort->getWire()->setMasterPort(masterPort);\n        absPort->getWire()->setSlavePort(slavePort);\n\n        if (portWidth > 0)\n        {    \n            masterPort->setWidth(QString::number(portWidth));\n            slavePort->setWidth(QString::number(portWidth));\n        }\n    } \n    else if (busIf_->getInterfaceMode() == General::SLAVE || busIf_->getInterfaceMode() == General::MIRRORED_SLAVE || busIf_->getInterfaceMode() == General::TARGET || busIf_->getInterfaceMode() == General::MIRRORED_TARGET)\n    {\n        QSharedPointer<WirePort> slavePort(new WirePort());\n        slavePort->setDirection(portDirection);\n\n        QSharedPointer<WirePort> masterPort(new WirePort());\n        masterPort->setDirection(DirectionTypes::convert2Mirrored(portDirection));\n\n        absPort->getWire()->setSlavePort(slavePort);\n        absPort->getWire()->setMasterPort(masterPort);\n\n        if (portWidth > 0)\n        {\n            masterPort->setWidth(QString::number(portWidth));\n            slavePort->setWidth(QString::number(portWidth));\n        }\n    }\n    else //if(busIf_->getInterfaceMode() == General::SYSTEM || \n         //busIf_->getInterfaceMode() == General::MIRROREDSYSTEM)\n    {\n        QSharedPointer<WirePort> systemPort(new WirePort());\n        systemPort->setDirection(portDirection);\n\n        absPort->getWire()->addSystemPort(systemPort);\n\n        if (portWidth > 0)\n        {\n            systemPort->setWidth(QString::number(portWidth));\n        }\n    }\n\t\n    return absPort;\n}\n\n//-----------------------------------------------------------------------------\n// Function: BusInterfaceWizardAbsDefinitionPage::findPortByName()\n//-----------------------------------------------------------------------------\nQSharedPointer<PortAbstraction> BusInterfaceWizardAbsDefinitionPage::findPortByName(QString const& portName, \n    QSharedPointer<QList<QSharedPointer<PortAbstraction> > > ports)\n{\n    for (auto const& port : *ports)\n    {\n        if (QString::compare(portName, port->getLogicalName()) == 0)\n        {\n            return port;\n        }\n    }\n    return QSharedPointer<PortAbstraction>(0);\n}\n\n//-----------------------------------------------------------------------------\n// Function: BusInterfaceWizardAbsDefinitionPage::getPortSize()\n//-----------------------------------------------------------------------------\nint BusInterfaceWizardAbsDefinitionPage::getPortSize(QSharedPointer<Port> targetPort) const\n{\n    int portLeftBound = expressionParser_->parseExpression(targetPort->getLeftBound()).toInt();\n    int portRightBound = expressionParser_->parseExpression(targetPort->getRightBound()).toInt();\n\n    return abs(portLeftBound - portRightBound) + 1;\n}"
  },
  {
    "path": "wizards/BusInterfaceWizard/BusInterfaceWizardAbsDefinitionPage.h",
    "content": "//-----------------------------------------------------------------------------\n// File: BusInterfaceWizardBusDefinitionPage.h\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Esko Pekkarinen\n// Date: 23.05.2023\n//\n// Description:\n// Bus interface wizard page for editing bus and abstraction definitions.\n//-----------------------------------------------------------------------------\n\n#ifndef BUSINTERFACEWIZARD_ABSDEFINITION_PAGE_H\n#define BUSINTERFACEWIZARD_ABSDEFINITION_PAGE_H\n\n#include <editors/AbstractionDefinitionEditor/AbstractionDefinitionEditor.h>\n\n#include <IPXACTmodels/generaldeclarations.h>\n#include <IPXACTmodels/common/DirectionTypes.h>\n\n#include <QWizardPage>\n#include <QMap>\n#include <QPushButton>\n\nclass AbstractionDefinition;\nclass BusDefinition;\nclass BusInterface;\nclass BusInterfaceWizard;\nclass Component;\nclass ExpressionParser;\nclass LibraryInterface;\nclass Port;\nclass PortAbstraction;\nclass VLNV;\n\n//-----------------------------------------------------------------------------\n//! Abstraction editor page for the interface wizard.\n//-----------------------------------------------------------------------------\nclass BusInterfaceWizardAbsDefinitionPage : public QWizardPage\n{\n    Q_OBJECT\npublic:\n\n    //! Selection for signal naming source.\n    enum SignalNamingPolicy\n    {\n        NAME = 0,\n        DESCRIPTION\n    };\n\n    /*!\n     *  The constructor.\n     *\n     *    @param [in] component       The component whose bus interface is being edited.\n     *    @param [in] busIf           The bus interface being edited.\n     *    @param [in] lh              The component library handler.\n     *    @param [in] physicalPorts   Physical ports used in logical signal generation.\n     *    @param [in] parent          The parent wizard.\n     *    @param [in] absDefVLNV      VLNV of the editable abstraction defintion.\n     *    @param [in] namingPolicy    Policy for naming generated logical signals.\n     */\n    BusInterfaceWizardAbsDefinitionPage(QSharedPointer<Component> component,\n        QSharedPointer<BusInterface> busIf, LibraryInterface* lh, \n        QStringList physicalPorts,\n        BusInterfaceWizard* parent,\n        VLNV& absDefVLNV,\n        QSharedPointer<ExpressionParser> expressionParser,\n        SignalNamingPolicy namingPolicy = NAME);\n\n    /*!\n     *  Destructor.\n     */\n    ~BusInterfaceWizardAbsDefinitionPage() final = default;\n\n    // Disable copying.\n    BusInterfaceWizardAbsDefinitionPage(BusInterfaceWizardAbsDefinitionPage const& rhs) = delete;\n    BusInterfaceWizardAbsDefinitionPage& operator=(BusInterfaceWizardAbsDefinitionPage const& rhs) = delete;\n\n    /*!\n     *  Returns the ID of the next page.\n     */\n    virtual int nextId() const;\n\n    /*!\n     *  Initializes the page.\n     */\n    virtual void initializePage();\n\n    /*!\n     *  Validates the page.\n     */\n    virtual bool validatePage();\n\npublic slots:\n\n    //! Handler for port abstraction renaming.\n    virtual void portRenamed(QString const& oldName, QString const& newName);\n\n    //! Handler for port abstraction removal.\n    virtual void portRemoved(QString const& portName, const General::InterfaceMode mode);\n\nprivate:\n\n    /*!\n    *  Sets the page layout.\n    */\n    void setupLayout();\n\n    /*!\n     *  Creates the logical ports to the abstraction definition and initial mapping of physical ports to the\n     *  created logical ports. \n     *\n     *    @param [in] physPorts   The physical ports from which the logical ports are generated. \n     *    @param [in] absDef      The abstraction definition to create the ports to.\n     */\n    void createLogicalPortsAndMappings(QStringList const& physPorts, QSharedPointer<AbstractionDefinition> absDef);\n\n    /*!\n     *  Creates initial mapping of physical ports to a single logical port.\n     *\n     *    @param [in] physPorts       The physical ports to map.\n     *    @param [in] logicalPort     The logical port to map to.\n     *    @param [in] logicalPort     The direction of the logical port.\n     */\n    void createLogicalMappings(QStringList const& physPorts, QString const& logicalPort, \n        DirectionTypes::Direction logicalDirection);\n\n    /*!\n     *  Creates port maps to the bus interface based on the initial mapping.     \n     */\n    void createPortMaps();\n\n    /*!\n     *  Finds a logical port by name.\n     *\n     *    @param [in] portName    The name of the port to find.\n     *    @param [in] ports       The group of ports to search.\n     *\n     *    @return The searched port or 0 if port was not found in the group.\n     */\n    QSharedPointer<PortAbstraction> findPortByName(QString const& portName, \n        QSharedPointer<QList<QSharedPointer<PortAbstraction> > > ports);\n\n\n    /*!\n     *  Creates a port abstraction.\n     *\n     *    @param [in] portName        Name of the port.\n     *    @param [in] portDirection   Direction of the port.\n     *    @param [in] portWidth       Width of the port.\n     *\n     *    @return The created port.\n     */\n    QSharedPointer<PortAbstraction> createAbsPort(QString const& portName, DirectionTypes::Direction portDirection,\n        int portWidth );\n\n    /*!\n     *  Get the size of a port.\n     *\n     *    @param [in] targetPort  The port whose size is being searched for.\n     *\n     *    @return The size of the port.\n     */\n    int getPortSize(QSharedPointer<Port> targetPort) const;\n\n    //-----------------------------------------------------------------------------\n    // Data.\n    //-----------------------------------------------------------------------------\n\n    //! The library handler.\n    LibraryInterface* handler_;\n\n    //! The component whose bus interface is being edited.\n    QSharedPointer<Component> component_;\n\n    //! The bus interface being edited.\n    QSharedPointer<BusInterface> busIf_;\n\n    //! The abstraction definition VLNV.\n    VLNV absDefVLNV_;\n\n    //! The limited set of physical ports to show in the port maps.\n    QStringList physicalPorts_;\n\n    //! The editor for bus and abstraction definition.\n    AbstractionDefinitionEditor editor_;\n\n    //! The source for logical signal names.\n    SignalNamingPolicy portNamesPolicy_;\n\n    //! Mapping for logic signal generation. Physical port names as keys and generated abstract signals as values.\n    QMap<QString, QString > portMappings_;\n\n    //! Flag for indicating changes on the page. \n    bool hasChanged_;\n\n    //! Enumeration for port mapping generation.\n    enum PortMapGenerationMode\n    {\n        NO_GENERATION = 0,\n        GENERATE_SINGLE,\n        GENERATE_ALL\n    };\n\n    //! The active mode for generation.\n    PortMapGenerationMode mappingMode_;\n\n    //! The used expression parser.\n    QSharedPointer<ExpressionParser> expressionParser_;\n\n};\n\n#endif // BUSINTERFACEWIZARD_ABSDEFINITION_PAGE_H\n"
  },
  {
    "path": "wizards/BusInterfaceWizard/BusInterfaceWizardBusDefinitionPage.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: BusInterfaceWizardBusDefinitionPage.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Esko Pekkarinen\r\n// Date: 25.11.2013\r\n//\r\n// Description:\r\n// Bus interface wizard page for editing bus and abstraction definitions.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"BusInterfaceWizardBusDefinitionPage.h\"\r\n\r\n#include \"BusInterfaceWizard.h\"\r\n\r\n#include <editors/BusDefinitionEditor/busdefgroup.h>\r\n#include <editors/ComponentEditor/ports/portsdelegate.h>\r\n#include <KactusAPI/include/ExpressionParser.h>\r\n\r\n#include <KactusAPI/include/LibraryInterface.h>\r\n\r\n#include <IPXACTmodels/AbstractionDefinition/AbstractionDefinition.h>\r\n\r\n#include <IPXACTmodels/BusDefinition/BusDefinition.h>\r\n#include <IPXACTmodels/BusDefinition/BusDefinition.h>\r\n\r\n#include <IPXACTmodels/AbstractionDefinition/PortAbstraction.h>\r\n#include <IPXACTmodels/AbstractionDefinition/WireAbstraction.h>\r\n#include <IPXACTmodels/AbstractionDefinition/WirePort.h>\r\n\r\n#include <IPXACTmodels/Component/Component.h>\r\n#include <IPXACTmodels/Component/BusInterface.h>\r\n#include <IPXACTmodels/Component/Port.h>\r\n#include <IPXACTmodels/Component/PortMap.h>\r\n#include <IPXACTmodels/common/Vector.h>\r\n#include <IPXACTmodels/common/VLNV.h>\r\n\r\n#include <QVBoxLayout>\r\n#include <QLabel>\r\n#include <QMessageBox>\r\n#include <QPushButton>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusInterfaceWizardBusDefinitionPage::BusInterfaceWizardBusDefinitionPage()\r\n//-----------------------------------------------------------------------------\r\nBusInterfaceWizardBusDefinitionEditorPage::BusInterfaceWizardBusDefinitionEditorPage(QSharedPointer<Component> component,\r\n    QSharedPointer<BusInterface> busIf, LibraryInterface* lh, bool editable, BusInterfaceWizard* parent):\r\nQWizardPage(parent),\r\n    handler_(lh),\r\n    component_(component),\r\n    busIf_(busIf),\r\n    editor_(this, handler_, nullptr),\r\n    editable_(editable)\r\n{       \r\n    setTitle(tr(\"Bus Definition\"));\r\n    setSubTitle(tr(\"Verify the options in the bus definition.\"));\r\n    setFinalPage(false);\r\n\r\n    connect(&editor_, SIGNAL(portRenamed(QString const&, QString const&)), \r\n        this, SLOT(portRenamed(QString const&, QString const&)), Qt::UniqueConnection);\r\n    connect(&editor_, SIGNAL(portRemoved(QString const&, const General::InterfaceMode)), \r\n        this, SLOT(portRemoved(QString const&, const General::InterfaceMode)), Qt::UniqueConnection);\r\n    \r\n    setupLayout();    \r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusInterfaceWizardBusDefinitionPage::nextId()\r\n//-----------------------------------------------------------------------------\r\nint BusInterfaceWizardBusDefinitionEditorPage::nextId() const\r\n{\r\n    return BusInterfaceWizard::PAGE_ABSDEFINITION;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusInterfaceWizardBusDefinitionPage::initializePage()\r\n//-----------------------------------------------------------------------------\r\nvoid BusInterfaceWizardBusDefinitionEditorPage::initializePage()\r\n{   \r\n    editor_.setBusDef(handler_->getModel<BusDefinition>(busIf_->getBusType()));\r\n    editor_.setProtection(!editable_);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusInterfaceWizardBusDefinitionPage::validatePage()\r\n//-----------------------------------------------------------------------------\r\nbool BusInterfaceWizardBusDefinitionEditorPage::validatePage()\r\n{    \r\n    QVector<QString> errors;\r\n    bool valid = editor_.validate(errors);\r\n\r\n    if (!valid)\r\n    {\r\n        QMessageBox warningDialog(QMessageBox::Warning, tr(\"Warning\"),\r\n            tr(\"Bus definition has the following error(s):\\n\") + QStringList(errors.toList()).join(\"\\n\"),\r\n            QMessageBox::Ok, this);        \r\n        warningDialog.exec();\r\n        return false;\r\n    }\r\n\r\n    editor_.save();\r\n\r\n    return true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusInterfaceWizardBusDefinitionPage::setupLayout()\r\n//-----------------------------------------------------------------------------\r\nvoid BusInterfaceWizardBusDefinitionEditorPage::setupLayout()\r\n{\r\n    QVBoxLayout* topLayout = new QVBoxLayout(this);\r\n    topLayout->addWidget(&editor_);\r\n}\r\n"
  },
  {
    "path": "wizards/BusInterfaceWizard/BusInterfaceWizardBusDefinitionPage.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: BusInterfaceWizardBusDefinitionPage.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Esko Pekkarinen\r\n// Date: 25.11.2013\r\n//\r\n// Description:\r\n// Bus interface wizard page for editing bus and abstraction definitions.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef BUSINTERFACEWIZARDBUSDEFINITIONPAGE_H\r\n#define BUSINTERFACEWIZARDBUSDEFINITIONPAGE_H\r\n\r\n#include <editors/BusDefinitionEditor/BusDefinitionEditor.h>\r\n\r\n#include <IPXACTmodels/generaldeclarations.h>\r\n#include <IPXACTmodels/common/DirectionTypes.h>\r\n\r\n#include <QWizardPage>\r\n#include <QMap>\r\n#include <QPushButton>\r\n\r\nclass AbstractionDefinition;\r\nclass BusDefinition;\r\nclass BusInterface;\r\nclass BusInterfaceWizard;\r\nclass Component;\r\nclass ExpressionParser;\r\nclass LibraryInterface;\r\nclass Port;\r\nclass PortAbstraction;\r\nclass VLNV;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Bus editor page for the interface wizard.\r\n//-----------------------------------------------------------------------------\r\nclass BusInterfaceWizardBusDefinitionEditorPage : public QWizardPage\r\n{\r\n    Q_OBJECT\r\npublic:\r\n\r\n    /*!\r\n     *  The constructor.\r\n     *\r\n     *    @param [in] component       The component whose bus interface is being edited.\r\n     *    @param [in] busIf           The bus interface being edited.\r\n     *    @param [in] lh              The component library handler.\r\n     *    @param [in] parent          The parent wizard.\r\n     */\r\n    BusInterfaceWizardBusDefinitionEditorPage(QSharedPointer<Component> component,\r\n        QSharedPointer<BusInterface> busIf, LibraryInterface* lh, bool editable,\r\n        BusInterfaceWizard* parent);\r\n\r\n    /*!\r\n     *  Destructor.\r\n     */\r\n    ~BusInterfaceWizardBusDefinitionEditorPage() final = default;\r\n\r\n    // Disable copying.\r\n    BusInterfaceWizardBusDefinitionEditorPage(BusInterfaceWizardBusDefinitionEditorPage const& rhs) = delete;\r\n    BusInterfaceWizardBusDefinitionEditorPage& operator=(BusInterfaceWizardBusDefinitionEditorPage const& rhs) = delete;\r\n\r\n    /*!\r\n     *  Returns the ID of the next page.\r\n     */\r\n    virtual int nextId() const;\r\n\r\n    /*!\r\n     *  Initializes the page.\r\n     */\r\n    virtual void initializePage();\r\n\r\n    /*!\r\n     *  Validates the page.\r\n     */\r\n    virtual bool validatePage();\r\n\r\nprivate:\r\n\r\n    /*!\r\n    *  Sets the page layout.\r\n    */\r\n    void setupLayout();\r\n\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! The library handler.\r\n    LibraryInterface* handler_;\r\n\r\n    //! The component whose bus interface is being edited.\r\n    QSharedPointer<Component> component_;\r\n\r\n    //! The bus interface being edited.\r\n    QSharedPointer<BusInterface> busIf_;\r\n\r\n    //! The editor for bus and abstraction definition.\r\n    BusDefinitionEditor editor_;\r\n\r\n    //! Flag for indicating changes on the page. \r\n    bool editable_ = false;\r\n};\r\n\r\n#endif // BUSINTERFACEWIZARDBUSDEFINITIONPAGE_H\r\n"
  },
  {
    "path": "wizards/BusInterfaceWizard/BusInterfaceWizardConclusionPage.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: BusInterfaceWizardConclusionPage.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Esko Pekkarinen\r\n// Date: 13.12.2013\r\n//\r\n// Description:\r\n// Bus interface wizard page for summary.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"BusInterfaceWizardConclusionPage.h\"\r\n#include \"BusInterfaceWizard.h\"\r\n\r\n#include <IPXACTmodels/Component/BusInterface.h>\r\n#include <IPXACTmodels/Component/PortMap.h>\r\n\r\n#include <QFormLayout>\r\n#include <QVBoxLayout>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusInterfaceWizardConclusionPage::BusInterfaceWizardConclusionPage()\r\n//-----------------------------------------------------------------------------\r\nBusInterfaceWizardConclusionPage::BusInterfaceWizardConclusionPage(QSharedPointer<BusInterface> busIf,\r\n    QStringList portNames, BusInterfaceWizard *parent):\r\nQWizardPage(parent),\r\nbusIf_(busIf),\r\nports_(portNames),\r\nnameLabel_(this),\r\nmodeLabel_(this),\r\nbusDefLabel_(this),\r\nabsDefLabel_(this)\r\n{\r\n    setTitle(tr(\"Summary\"));\r\n    setSubTitle(tr(\"You have successfully completed the interface wizard. Verify the choices by clicking Finish.\"));\r\n    setFinalPage(true);\r\n\r\n    setupLayout();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusInterfaceWizardConclusionPage::~BusInterfaceWizardConclusionPage()\r\n//-----------------------------------------------------------------------------\r\nBusInterfaceWizardConclusionPage::~BusInterfaceWizardConclusionPage()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusInterfaceWizardConclusionPage::nextId()\r\n//-----------------------------------------------------------------------------\r\nint BusInterfaceWizardConclusionPage::nextId() const\r\n{\r\n    // This is the final page of the wizard.\r\n    return -1;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusInterfaceWizardConclusionPage::initializePage()\r\n//-----------------------------------------------------------------------------\r\nvoid BusInterfaceWizardConclusionPage::initializePage()\r\n{\r\n    // Set label texts.\r\n    nameLabel_.setText(busIf_->name());\r\n    modeLabel_.setText(General::interfaceMode2Str(busIf_->getInterfaceMode()));\r\n    busDefLabel_.setText(busIf_->getBusType().toString());\r\n\r\n    QString abstractionText(\"\");\r\n    if (busIf_->getAbstractionTypes())\r\n    {\r\n        foreach (QSharedPointer<AbstractionType> abstraction, *busIf_->getAbstractionTypes())\r\n        {\r\n            if (abstraction->getAbstractionRef())\r\n            {\r\n                QString abstractionVLNVText = abstraction->getAbstractionRef()->toString();\r\n                abstractionText.append(abstractionVLNVText);\r\n\r\n                QStringList mappedPorts;\r\n\r\n                foreach (QSharedPointer<PortMap> portMap, *abstraction->getPortMaps())\r\n                {\r\n                    if (portMap->getPhysicalPort() && ports_.contains(portMap->getPhysicalPort()->name_))\r\n                    {\r\n                        mappedPorts.append(portMap->getPhysicalPort()->name_);\r\n                    }\r\n                }\r\n\r\n                abstractionText.append(\" (\" + QString::number(mappedPorts.size()) + \"/\" +\r\n                    QString::number(ports_.size()) + \" ports mapped)\");\r\n\r\n                if (abstraction != busIf_->getAbstractionTypes()->last())\r\n                {\r\n                    abstractionText.append(\"\\n\");\r\n                }\r\n            }\r\n        }\r\n    }\r\n\r\n    absDefLabel_.setText(abstractionText);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusInterfaceWizardConclusionPage::setupLayout()\r\n//-----------------------------------------------------------------------------\r\nvoid BusInterfaceWizardConclusionPage::setupLayout()\r\n{\r\n    QVBoxLayout* topLaout = new QVBoxLayout(this);\r\n\r\n    QString summary = tr(\"The bus interface will be created with the following details.<br><br>\");\r\n    topLaout->addWidget(new QLabel(summary));\r\n\r\n    QFormLayout* detailsLayout = new QFormLayout();\r\n    detailsLayout->addRow(tr(\"Name:\"), &nameLabel_);\r\n    detailsLayout->addRow(tr(\"Mode:\"), &modeLabel_);\r\n    detailsLayout->addRow(tr(\"Bus Definition:\"), &busDefLabel_);\r\n    detailsLayout->addRow(tr(\"Abstraction Definition(s):\"), &absDefLabel_);\r\n\r\n    topLaout->addLayout(detailsLayout);\r\n}"
  },
  {
    "path": "wizards/BusInterfaceWizard/BusInterfaceWizardConclusionPage.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: BusInterfaceWizardConclusionPage.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Esko Pekkarinen\r\n// Date: 13.12.2013\r\n//\r\n// Description:\r\n// Bus interface wizard page for summary.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef BUSINTERFACEWIZARDCONCLUSIONSPAGE_H\r\n#define BUSINTERFACEWIZARDCONCLUSIONSPAGE_H\r\n\r\n#include \"BusInterfaceWizard.h\"\r\n\r\n#include <QLabel>\r\n#include <QWizardPage>\r\n\r\nclass BusInteface;\r\n//-----------------------------------------------------------------------------\r\n//! Summary page for the interface wizard.\r\n//-----------------------------------------------------------------------------\r\nclass BusInterfaceWizardConclusionPage : public QWizardPage\r\n{\r\n    Q_OBJECT\r\n\r\npublic:\r\n\r\n    /*!\r\n     *  The constructor.\r\n     *\r\n     *    @param [in] busIf   The bus interface being edited.\r\n     *    @param [in] ports   The ports selected to the wizard.\r\n     *    @param [in] parent  The parent wizard.\r\n     */\r\n    BusInterfaceWizardConclusionPage(QSharedPointer<BusInterface> busIf, QStringList ports,\r\n        BusInterfaceWizard* parent);\r\n\r\n    /*!\r\n     *  The destructor.\r\n     */\r\n    ~BusInterfaceWizardConclusionPage();\r\n\r\n    /*!\r\n     *  Returns the ID of the next page.\r\n     */\r\n    virtual int nextId() const;\r\n\r\n    /*!\r\n     *  Initializes the page.\r\n     */\r\n    virtual void initializePage();\r\n\r\nprivate:\r\n    \r\n    // Disable copying.\r\n    BusInterfaceWizardConclusionPage(BusInterfaceWizardConclusionPage const& rhs);\r\n    BusInterfaceWizardConclusionPage& operator=(BusInterfaceWizardConclusionPage const& rhs);\r\n\r\n    /*!\r\n     *  Sets the page layout.\r\n     */\r\n    void setupLayout();\r\n\r\n    //-----------------------------------------------------------------------------\r\n    //! Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! The bus interface being edited.\r\n    QSharedPointer<BusInterface> busIf_;\r\n\r\n    //! The ports selected to the wizard.\r\n    QStringList ports_;\r\n\r\n    //! Label for bus interface name.\r\n    QLabel nameLabel_;\r\n\r\n    //! Label for bus interface mode.\r\n    QLabel modeLabel_;\r\n\r\n    //! Label for bus interface bus definition.\r\n    QLabel busDefLabel_;\r\n\r\n    //! Label for bus interface abstraction definition.\r\n    QLabel absDefLabel_;\r\n};\r\n\r\n#endif // BUSINTERFACEWIZARDCONCLUSIONSPAGE_H\r\n"
  },
  {
    "path": "wizards/BusInterfaceWizard/BusInterfaceWizardGeneralOptionsPage.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: BusInterfaceWizardGeneralOptionsPage.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Esko Pekkarinen\r\n// Date: 25.11.2013\r\n//\r\n// Description:\r\n// Bus interface wizard page for bus interface general options.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"BusInterfaceWizardGeneralOptionsPage.h\"\r\n#include \"BusInterfaceWizard.h\"\r\n\r\n#include <editors/common/ExpressionSet.h>\r\n\r\n#include <IPXACTmodels/Component/Component.h>\r\n#include <IPXACTmodels/Component/validators/BusInterfaceValidator.h>\r\n#include <IPXACTmodels/Component/validators/AbstractionTypeValidator.h>\r\n\r\n#include <KactusAPI/include/BusInterfaceInterface.h>\r\n#include <KactusAPI/include/AbstractionTypeInterface.h>\r\n\r\n#include <KactusAPI/include/LibraryInterface.h>\r\n\r\n#include <QVBoxLayout>\r\n#include <QLabel>\r\n#include <QMessageBox>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusInterfaceWizardVLNVSelectionPage::BusInterfaceWizardVLNVSelectionPage()\r\n//-----------------------------------------------------------------------------\r\nBusInterfaceWizardGeneralOptionsPage::BusInterfaceWizardGeneralOptionsPage(QSharedPointer<Component> component,\r\n    QSharedPointer<BusInterface> busIf, LibraryInterface* lh, bool absDefEditable,\r\n    QSharedPointer<ParameterFinder> parameterFinder, QSharedPointer<ExpressionFormatter> expressionFormatter,\r\n    QSharedPointer<ExpressionParser> expressionParser, BusInterfaceInterface* busInterface,\r\n    BusInterfaceWizard* parent):\r\nQWizardPage(parent),\r\ncomponent_(component),\r\nbusIf_(busIf),\r\nhandler_(lh),\r\ngeneralTab_(new BusIfGeneralTab(lh, busIf, component, ExpressionSet({ parameterFinder, expressionParser, expressionFormatter }),\r\n    busInterface, busIf->name().toStdString(), this, parent)),\r\nbusInterface_(busInterface)\r\n{\r\n    setTitle(tr(\"Bus interface general options\"));\r\n    setSubTitle(tr(\"Setup the general options for the bus interface.\"));\r\n    setFinalPage(false);\r\n\r\n    generalTab_->setBusTypesLock(!absDefEditable);\r\n\r\n    connect(generalTab_, SIGNAL(contentChanged()), this, SIGNAL(completeChanged()), Qt::UniqueConnection);\r\n    connect(generalTab_, SIGNAL(increaseReferences(QString)),\r\n        this, SIGNAL(increaseReferences(QString)), Qt::UniqueConnection);\r\n    connect(generalTab_, SIGNAL(decreaseReferences(QString)),\r\n        this, SIGNAL(decreaseReferences(QString)), Qt::UniqueConnection);\r\n\r\n    connect(generalTab_, SIGNAL(nameChanged(std::string const&)), this, SIGNAL(busNameChanged(std::string const&)), Qt::UniqueConnection);\r\n\r\n    setupLayout();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusInterfaceWizardVLNVSelectionPage::nextId()\r\n//-----------------------------------------------------------------------------\r\nint BusInterfaceWizardGeneralOptionsPage::nextId() const\r\n{\r\n    return BusInterfaceWizard::PAGE_BUSDEFINITION;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusInterfaceWizardVLNVSelectionPage::initializePage()\r\n//-----------------------------------------------------------------------------\r\nvoid BusInterfaceWizardGeneralOptionsPage::initializePage()\r\n{\r\n    generalTab_->refresh();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusInterfaceWizardVLNVSelectionPage::isComplete()\r\n//-----------------------------------------------------------------------------\r\nbool BusInterfaceWizardGeneralOptionsPage::isComplete() const\r\n{\r\n    if (component_->hasInterface(busIf_->name()) && component_->getBusInterface(busIf_->name()) != busIf_)\r\n    {\r\n        return false;\r\n    }        \r\n\r\n    return mandatoryFieldsAreFilledIn();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusInterfaceWizardGeneralOptionsPage::mandatoryFieldsAreFilledIn()\r\n//-----------------------------------------------------------------------------\r\nbool BusInterfaceWizardGeneralOptionsPage::mandatoryFieldsAreFilledIn() const\r\n{\r\n    return !busIf_->name().isEmpty() &&\r\n        busIf_->getInterfaceMode() != General::INTERFACE_MODE_COUNT &&\r\n        handler_->contains(busIf_->getBusType()) && \r\n        abstractionReferenceIsFound();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusInterfaceWizardGeneralOptionsPage::abstractionReferenceIsFound()\r\n//-----------------------------------------------------------------------------\r\nbool BusInterfaceWizardGeneralOptionsPage::abstractionReferenceIsFound() const\r\n{\r\n    AbstractionTypeInterface* abstractionInterface = busInterface_->getAbstractionTypeInterface();\r\n\r\n    General::InterfaceMode busMode = busInterface_->getActiveMode(busIf_->name().toStdString());\r\n    QString systemGroup = busInterface_->getActiveSystemGroup(busIf_->name().toStdString());\r\n\r\n    abstractionInterface->setAbstractionTypes(busIf_->getAbstractionTypes(), busMode, systemGroup);\r\n\r\n    if (abstractionInterface->itemCount() == 0)\r\n    {\r\n        return false;\r\n    }\r\n\r\n    for (int i = 0; i < abstractionInterface->itemCount(); ++i)\r\n    {\r\n        bool abstractionHasReference = abstractionInterface->hasAbstractionReference(i);\r\n\r\n        if (!abstractionHasReference)\r\n        {\r\n            return false;\r\n        }\r\n\r\n        bool referenceExists = handler_->contains(*abstractionInterface->getAbstractionReference(i));\r\n        bool viewReferencesAreValid = abstractionInterface->hasValidViewReferences(i);\r\n\r\n        if (!referenceExists || !viewReferencesAreValid)\r\n        {\r\n            return false;\r\n        }\r\n    }\r\n\r\n    return true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusInterfaceWizardVLNVSelectionPage::setupLayout()\r\n//-----------------------------------------------------------------------------\r\nvoid BusInterfaceWizardGeneralOptionsPage::setupLayout()\r\n{\r\n    QVBoxLayout* topLayout = new QVBoxLayout(this);    \r\n    topLayout->addWidget(generalTab_);\r\n}\r\n"
  },
  {
    "path": "wizards/BusInterfaceWizard/BusInterfaceWizardGeneralOptionsPage.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: BusInterfaceWizardGeneralOptionsPage.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Esko Pekkarinen\r\n// Date: 25.11.2013\r\n//\r\n// Description:\r\n// Bus interface wizard page for bus interface general options.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef BUSINTERFACEWIZARDGENERALOPTIONSPAGE_H\r\n#define BUSINTERFACEWIZARDGENERALOPTIONSPAGE_H\r\n\r\n#include <editors/ComponentEditor/busInterfaces/general/busifgeneraltab.h>\r\n#include <KactusAPI/include/LibraryInterface.h>\r\n\r\n#include <KactusAPI/include/ParameterFinder.h>\r\n#include <KactusAPI/include/ExpressionFormatter.h>\r\n\r\n#include <QWizardPage>\r\n\r\nclass BusInterface;\r\nclass BusInterfaceWizard;\r\nclass Component;\r\nclass LibraryInterface;\r\nclass ExpressionParser;\r\nclass AbstractionTypeValidator;\r\nclass BusInterfaceInterface;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! General options page for the interface wizard.\r\n//-----------------------------------------------------------------------------\r\nclass BusInterfaceWizardGeneralOptionsPage : public QWizardPage\r\n{\r\n    Q_OBJECT\r\n\r\npublic:\r\n\r\n    /*!\r\n     *  The constructor.\r\n     *\r\n     *    @param [in] component               The component whose bus interface is being edited.\r\n     *    @param [in] busIf                   The bus interface being edited.\r\n     *    @param [in] lh                      The component library handler.\r\n     *    @param [in] absDefEditable          The editability of abstract definition.\r\n     *    @param [in] parameterFinder         The parameter finder.\r\n     *    @param [in] expressionFormatter     The expression formatter.\r\n     *    @param [in] busValidator            Validator for bus interfaces.\r\n     *    @param [in] busInterface            Interface for accessing bus interfaces.\r\n     *    @param [in] parent                  The parent wizard.\r\n     */\r\n    BusInterfaceWizardGeneralOptionsPage(QSharedPointer<Component> component,\r\n        QSharedPointer<BusInterface> busIf,\r\n        LibraryInterface* lh,\r\n        bool absDefEditable,\r\n        QSharedPointer<ParameterFinder> parameterFinder,\r\n        QSharedPointer<ExpressionFormatter> expressionFormatter,\r\n        QSharedPointer<ExpressionParser> expressionParser,\r\n        BusInterfaceInterface* busInterface,\r\n        BusInterfaceWizard* parent);\r\n\r\n    /*!\r\n     *  Destructor.\r\n     */\r\n    ~BusInterfaceWizardGeneralOptionsPage() final = default;\r\n\r\n    /*!\r\n     *  Returns the ID of the next page.\r\n     */\r\n    virtual int nextId() const;\r\n\r\n    /*!\r\n     *  Initializes the page.\r\n     */\r\n    void initializePage();\r\n\r\n    /*!\r\n     * Checks if all the required fields on the page are valid.\r\n     *\r\n     *    @return True, if all fields are valid, otherwise false.\r\n     */\r\n    virtual bool isComplete() const;    \r\n\r\nsignals:\r\n\r\n    /*!\r\n     *  Increase the number of references made to a specific parameter.\r\n     *\r\n     *    @param [in] id  The id of the parameter whose reference count is to be increased.\r\n     */\r\n    void increaseReferences(QString id);\r\n\r\n    /*!\r\n     *  Decrease the number of references made to a specific parameter.\r\n     *\r\n     *    @param [in] id  The id of the parameter whose reference count is to be decreased.\r\n     */\r\n    void decreaseReferences(QString id);\r\n\r\n    /*!\r\n     *  Inform of a change in the name of the bus interface.\r\n     *\t\r\n     *    @param [in] busName     The new name of the bus interface.\r\n     */\r\n    void busNameChanged(std::string const& busName);\r\n\r\nprivate:\r\n    // Disable copying.\r\n    BusInterfaceWizardGeneralOptionsPage(BusInterfaceWizardGeneralOptionsPage const& rhs);\r\n    BusInterfaceWizardGeneralOptionsPage& operator=(BusInterfaceWizardGeneralOptionsPage const& rhs);\r\n\r\n    /*!\r\n     *  Checks if all the mandatory fields are filled in.\r\n     *\r\n     *    @return True, if mandatory fields are filled, otherwise false.\r\n     */\r\n    bool mandatoryFieldsAreFilledIn() const;\r\n\r\n    /*!\r\n     * Sets the page layout.\r\n     */\r\n    void setupLayout();\r\n   \r\n    /*!\r\n     *  Check if a valid reference to an existing abstraction definition is found.\r\n     *\r\n     *    @return True, if a valid abstraction definition is found, false otherwise.\r\n     */\r\n    bool abstractionReferenceIsFound() const;\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! The component whose bus interface is being edited.\r\n    QSharedPointer<Component> component_;\r\n\r\n    //! The bus interface being edited.\r\n    QSharedPointer<BusInterface> busIf_;\r\n\r\n    //! The library handler.\r\n    LibraryInterface* handler_;\r\n\r\n    //! Editor for bus interface general options.\r\n    BusIfGeneralTab* generalTab_;\r\n\r\n    //! Interface for accessing bus interfaces.\r\n    BusInterfaceInterface* busInterface_;\r\n};\r\n\r\n#endif // BUSINTERFACEWIZARDGENERALOPTIONSPAGE_H\r\n"
  },
  {
    "path": "wizards/BusInterfaceWizard/BusInterfaceWizardIntroPage.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: BusInterfaceWizardIntroPage\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Esko Pekkarinen\r\n// Date: 13.12.2013\r\n//\r\n// Description:\r\n// Bus interface wizard page for introduction.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"BusInterfaceWizardIntroPage.h\"\r\n#include \"BusInterfaceWizard.h\"\r\n\r\n#include <QVBoxLayout>\r\n#include <QLabel>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusInterfaceWizardIntroPage::BusInterfaceWizardIntroPage()\r\n//-----------------------------------------------------------------------------\r\nBusInterfaceWizardIntroPage::BusInterfaceWizardIntroPage(QWidget *parent):\r\nQWizardPage(parent)\r\n{\r\n    setTitle(tr(\"Introduction\"));\r\n    setSubTitle(tr(\"This wizard will guide you through creating a new interface to the component.\"));\r\n    setFinalPage(false);\r\n    \r\n    setupLayout();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusInterfaceWizardIntroPage::~BusInterfaceWizardIntroPage()\r\n//-----------------------------------------------------------------------------\r\nBusInterfaceWizardIntroPage::~BusInterfaceWizardIntroPage()\r\n{\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusInterfaceWizardIntroPage::nextId()\r\n//-----------------------------------------------------------------------------\r\nint BusInterfaceWizardIntroPage::nextId() const\r\n{\r\n    return BusInterfaceWizard::PAGE_GENERALOPTIONS;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusInterfaceWizardIntroPage::setupLayout()\r\n//-----------------------------------------------------------------------------\r\nvoid BusInterfaceWizardIntroPage::setupLayout()\r\n{\r\n    QVBoxLayout* topLayout = new QVBoxLayout(this);\r\n\r\n    QString infoText = tr(\"This wizard contains the following steps:\");\r\n    infoText += \"<ul><li>\" + tr(\"Bus Interface General Information\");\r\n    infoText += \"<li>\" + tr(\"Bus Definition Editor\");\r\n    infoText += \"<li>\" + tr(\"Abstraction Definition Editor\");\r\n    infoText += \"<li>\" + tr(\"Port Maps\");\r\n    infoText += \"<li>\" + tr(\"Summary\") + \"</ul>\";\r\n\r\n    QLabel* introTextLabel = new QLabel(infoText);\r\n    \r\n    topLayout->addWidget(introTextLabel);\r\n}\r\n\r\n\r\n"
  },
  {
    "path": "wizards/BusInterfaceWizard/BusInterfaceWizardIntroPage.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: BusInterfaceWizardIntroPage.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Esko Pekkarinen\r\n// Date: 13.12.2013\r\n//\r\n// Description:\r\n// Bus interface wizard page for introduction.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef BUSINTERFACEWIZARDINTROPAGE_H\r\n#define BUSINTERFACEWIZARDINTROPAGE_H\r\n\r\n#include <QWizardPage>\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Introduction page for the interface wizard.\r\n//-----------------------------------------------------------------------------\r\nclass BusInterfaceWizardIntroPage : public QWizardPage\r\n{\r\n    Q_OBJECT\r\n\r\npublic:\r\n    /*!\r\n     *  The constructor.\r\n     */\r\n    BusInterfaceWizardIntroPage(QWidget *parent);\r\n\r\n    /*!\r\n     *  The destructor.\r\n     */\r\n    ~BusInterfaceWizardIntroPage();\r\n\r\n    /*!\r\n     *  Returns the ID of the next page.\r\n     */\r\n    virtual int nextId() const;\r\n\r\nprivate:\r\n    // Disable copying.\r\n    BusInterfaceWizardIntroPage(BusInterfaceWizardIntroPage const& rhs);\r\n    BusInterfaceWizardIntroPage& operator=(BusInterfaceWizardIntroPage const& rhs);\r\n\r\n    /*!\r\n     *  Sets the page layout.\r\n     */\r\n    void setupLayout();\r\n};\r\n\r\n#endif // BUSINTERFACEWIZARDINTROPAGE_H\r\n\r\n"
  },
  {
    "path": "wizards/BusInterfaceWizard/BusInterfaceWizardPortMapPage.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: BusInterfaceWizardPortMapPage.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Esko Pekkarinen\r\n// Date: 25.11.2013\r\n//\r\n// Description:\r\n// Bus interface wizard page for defining port maps.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"BusInterfaceWizardPortMapPage.h\"\r\n\r\n#include \"BusInterfaceWizard.h\"\r\n\r\n#include <IPXACTmodels/Component/Component.h>\r\n#include <IPXACTmodels/Component/BusInterface.h>\r\n#include <IPXACTmodels/Component/FileSet.h>\r\n#include <IPXACTmodels/Component/validators/BusInterfaceValidator.h>\r\n#include <IPXACTmodels/Component/validators/AbstractionTypeValidator.h>\r\n\r\n#include <KactusAPI/include/BusInterfaceInterface.h>\r\n#include <KactusAPI/include/AbstractionTypeInterface.h>\r\n#include <KactusAPI/include/BusInterfaceInterface.h>\r\n\r\n#include <KactusAPI/include/LibraryInterface.h>\r\n\r\n#include <QVBoxLayout>\r\n#include <QLabel>\r\n#include <QMessageBox>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusInterfaceWizardPortMapPage::BusInterfaceWizardPortMapPage()\r\n//-----------------------------------------------------------------------------\r\nBusInterfaceWizardPortMapPage::BusInterfaceWizardPortMapPage(QSharedPointer<Component> component,\r\n    QSharedPointer<BusInterface> busIf, LibraryInterface* lh, QStringList physicalPorts,\r\n    QSharedPointer<ExpressionParser> expressionParser, QSharedPointer<ParameterFinder> parameterFinder,\r\n    BusInterfaceInterface* busInterface, PortMapInterface* portMapInterface, BusInterfaceWizard* parent):\r\nQWizardPage(parent),\r\nbusIf_(busIf),\r\nhandler_(lh),\r\nportMapTab_(handler_, component, busInterface, busIf_->name().toStdString(), expressionParser, parameterFinder,\r\n    portMapInterface, this),\r\nbusInterface_(busInterface)\r\n{\r\n    setTitle(tr(\"Port Maps\"));\r\n    setSubTitle(tr(\"Create port maps for interface %1.\").arg(busIf->name()));\r\n    setFinalPage(false);\r\n    \r\n    portMapTab_.setPhysicalPorts(physicalPorts);\r\n\r\n    connect(&portMapTab_, SIGNAL(errorMessage(QString const&)),\r\n        this, SLOT(showErrorMessage(QString const&)), Qt::UniqueConnection);    \r\n    connect(&portMapTab_, SIGNAL(contentChanged()), this, SIGNAL(completeChanged()), Qt::UniqueConnection);\r\n\r\n    connect(this, SIGNAL(busNameChanged(std::string const&)), &portMapTab_, SLOT(changeBusName(std::string const&)), Qt::UniqueConnection);\r\n\r\n    setupLayout();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusInterfaceWizardPortMapPage::~BusInterfaceWizardPortMapPage()\r\n//-----------------------------------------------------------------------------\r\nBusInterfaceWizardPortMapPage::~BusInterfaceWizardPortMapPage()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusInterfaceWizardPortMapPage::nextId()\r\n//-----------------------------------------------------------------------------\r\nint BusInterfaceWizardPortMapPage::nextId() const\r\n{\r\n    return BusInterfaceWizard::PAGE_SUMMARY;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusInterfaceWizardPortMapPage::initializePage()\r\n//-----------------------------------------------------------------------------\r\nvoid BusInterfaceWizardPortMapPage::initializePage()\r\n{\r\n    portMapTab_.setAbstractionDefinitions();\r\n    portMapTab_.refresh();    \r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusInterfaceWizardPortMapPage::isComplete()\r\n//-----------------------------------------------------------------------------\r\nbool BusInterfaceWizardPortMapPage::isComplete() const\r\n{\r\n    return busInterface_->validateBusInterface(busIf_->name().toStdString());\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusInterfaceWizardPortMapPage::showErrorMessage()\r\n//-----------------------------------------------------------------------------\r\nvoid BusInterfaceWizardPortMapPage::showErrorMessage(QString const& msg)\r\n{\r\n    QMessageBox warningDialog(QMessageBox::Warning, tr(\"Warning\"), msg, QMessageBox::Ok, this);\r\n    warningDialog.exec();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: BusInterfaceWizardPortMapPage::setupLayout()\r\n//-----------------------------------------------------------------------------\r\nvoid BusInterfaceWizardPortMapPage::setupLayout()\r\n{\r\n    QVBoxLayout* topLayout = new QVBoxLayout(this);\r\n    topLayout->addWidget(&portMapTab_);\r\n}\r\n"
  },
  {
    "path": "wizards/BusInterfaceWizard/BusInterfaceWizardPortMapPage.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: BusInterfaceWizardPortMapPage.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Esko Pekkarinen\r\n// Date: 25.11.2013\r\n//\r\n// Description:\r\n// Bus interface wizard page for defining port maps.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef BUSINTERFACEWIZARDPORTMAPPAGE_H\r\n#define BUSINTERFACEWIZARDPORTMAPPAGE_H\r\n\r\n#include <editors/ComponentEditor/busInterfaces/portmaps/BusInterfacePortMapTab.h>\r\n\r\n#include <QWizardPage>\r\n#include <QLabel>\r\n#include <QTextEdit>\r\n\r\nclass BusInterface;\r\nclass BusInterfaceWizard;\r\nclass BusInterfaceValidator;\r\nclass Component;\r\nclass LibraryInterface;\r\nclass ExpressionParser;\r\nclass ParameterFinder;\r\nclass ExpressionFormatter;\r\nclass PortMapInterface;\r\nclass BusInterfaceInterface;\r\nclass PortMapInterface;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Port map page for the bus interface wizard.\r\n//-----------------------------------------------------------------------------\r\nclass BusInterfaceWizardPortMapPage : public QWizardPage\r\n{\r\n    Q_OBJECT\r\npublic:\r\n\r\n\r\n    /*!\r\n     *  The constructor.\r\n     *\r\n     *    @param [in] component           The component whose bus interface is being edited.\r\n     *    @param [in] busIf               The bus interface being edited.\r\n     *    @param [in] lh                  The component library handler.\r\n     *    @param [in] physicalPorts       The physical ports selected for mapping.\r\n     *    @param [in] expressionParser    The used expression parser.\r\n     *    @param [in] parameterFinder     The used parameter finder.\r\n     *    @param [in] busInterface        Interface for accessing bus interfaces.\r\n     *    @param [in] portMapInterface    Interface for accessing port maps.\r\n     *    @param [in] parent              The parent wizard.\r\n     */\r\n    BusInterfaceWizardPortMapPage(QSharedPointer<Component> component,\r\n        QSharedPointer<BusInterface> busIf,\r\n        LibraryInterface* lh,\r\n        QStringList physicalPorts,\r\n        QSharedPointer<ExpressionParser> expressionParser,\r\n        QSharedPointer<ParameterFinder> parameterFinder,\r\n        BusInterfaceInterface* busInterface,\r\n        PortMapInterface* portMapInterface,\r\n        BusInterfaceWizard* parent);\r\n\r\n    /*!\r\n     *  The destructor.\r\n     */\r\n    ~BusInterfaceWizardPortMapPage();\r\n\r\n    /*!\r\n     *  Returns the ID of the next page.\r\n     */\r\n    virtual int nextId() const;\r\n\r\n    /*!\r\n     *  Initializes the page.\r\n     */\r\n    virtual void initializePage();\r\n    \r\n    /*!\r\n     * Checks if all the required fields on the page are valid.\r\n     *\r\n     *    @return True, if all fields are valid, otherwise false.\r\n     */\r\n    virtual bool isComplete() const;\r\n\r\nsignals:\r\n\r\n    /*!\r\n     *  Inform of a change in the bus interface name.\r\n     *\t\r\n     *    @param [in] busName     The new name of the bus interface.\r\n     */\r\n    void busNameChanged(std::string const& busName);\r\n\r\nprivate slots:\r\n    \r\n    //! Handler for error messages.\r\n    virtual void showErrorMessage(QString const& msg);\r\n\r\nprivate:\r\n    // Disable copying.\r\n    BusInterfaceWizardPortMapPage(BusInterfaceWizardPortMapPage const& rhs);\r\n    BusInterfaceWizardPortMapPage& operator=(BusInterfaceWizardPortMapPage const& rhs);\r\n\r\n    /*!\r\n    *  Sets the page layout.\r\n    */\r\n    void setupLayout();\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! The component whose interface is being edited.\r\n    QSharedPointer<Component> component_;\r\n\r\n    //! The target bus interface.\r\n    QSharedPointer<BusInterface> busIf_;\r\n\r\n    //! The library interface.\r\n    LibraryInterface* handler_;\r\n\r\n    //! The widget for editing port maps.\r\n    BusInterfacePortMapTab portMapTab_;\r\n\r\n    //! Interface for accessing bus interfaces.\r\n    BusInterfaceInterface* busInterface_;\r\n};\r\n\r\n#endif // BUSINTERFACEWIZARDPORTMAPPAGE_H\r\n"
  },
  {
    "path": "wizards/ComponentWizard/ComponentWizard.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ComponentWizard.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Joni-Matti Maatta\r\n// Date: 06.06.2013\r\n//\r\n// Description:\r\n// Component wizard dialog.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"ComponentWizard.h\"\r\n#include \"ComponentWizardPages.h\"\r\n\r\n#include \"ComponentWizardIntroPage.h\"\r\n#include \"ComponentWizardDependencyPage.h\"\r\n#include \"ComponentWizardGeneralInfoPage.h\"\r\n#include \"ComponentWizardImportPage.h\"\r\n#include \"ComponentWizardViewsPage.h\"\r\n#include \"ComponentWizardConclusionPage.h\"\r\n\r\n#include <KactusAPI/include/BusInterfaceInterface.h>\r\n#include <KactusAPI/include/BusInterfaceInterfaceFactory.h>\r\n#include <KactusAPI/include/IPXactSystemVerilogParser.h>\r\n#include <KactusAPI/include/FileSetInterface.h>\r\n#include <KactusAPI/include/FileInterface.h>\r\n#include <KactusAPI/include/FileBuilderInterface.h>\r\n#include <editors/ComponentEditor/referenceCounter/ParameterReferenceCounter.h>\r\n\r\n#include <IPXACTmodels/Component/Component.h>\r\n#include <IPXACTmodels/Component/validators/FileValidator.h>\r\n#include <IPXACTmodels/Component/validators/FileSetValidator.h>\r\n\r\n#include <QLabel>\r\n#include <QVBoxLayout>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentWizard::ComponentWizard()\r\n//-----------------------------------------------------------------------------\r\nComponentWizard::ComponentWizard(QSharedPointer<Component> component, QString const& basePath,\r\n    LibraryInterface* handler, QWidget* parent):\r\nQWizard(parent),\r\noriginalComponent_(component),\r\nworkingComponent_(component),\r\nparameterFinder_(new ComponentParameterFinder(workingComponent_)),\r\nexpressionFormatter_(new ExpressionFormatter(parameterFinder_)),\r\nreferenceCounter_(new ParameterReferenceCounter(parameterFinder_))\r\n{\r\n    setPixmap(QWizard::LogoPixmap, QPixmap(\":icons/common/graphics/hw-component.png\"));\r\n\tsetWindowTitle(tr(\"Component Wizard for %1\").arg(component->getVlnv().toString()));\r\n    setWizardStyle(ModernStyle);\r\n    resize(800, 1000);\r\n\r\n    setOption(NoBackButtonOnStartPage, true);\r\n    setOption(NoCancelButton, true);\r\n    setOption(NoDefaultButton, true);\r\n    setOption(HaveFinishButtonOnEarlyPages, true);\r\n\r\n    QSharedPointer<IPXactSystemVerilogParser> parser(new IPXactSystemVerilogParser(parameterFinder_));\r\n\r\n    BusInterfaceInterface* busInterface = BusInterfaceInterfaceFactory::createBusInterface(\r\n        parameterFinder_, expressionFormatter_, parser, component, handler);\r\n\r\n    ComponentWizardImportPage* importPage = new ComponentWizardImportPage(component, handler, \r\n        parameterFinder_, expressionFormatter_, busInterface, this);\r\n\r\n    ComponentWizardConclusionPage* conclusionPage = new ComponentWizardConclusionPage(component, handler,\r\n        expressionFormatter_, this);\r\n\r\n    FileSetInterface* fileSetInterface = createFileSetInterface(parser);\r\n\r\n    setPage(ComponentWizardPages::INTRO, new ComponentWizardIntroPage(component, this));\r\n    setPage(ComponentWizardPages::GENERAL, new ComponentWizardGeneralInfoPage(component, this));    \r\n    setPage(ComponentWizardPages::FILE_DEPENDENCY, new ComponentWizardDependencyPage(\r\n        component, parameterFinder_, basePath, fileSetInterface, this));\r\n    setPage(ComponentWizardPages::IMPORT, importPage);\r\n    setPage(ComponentWizardPages::VIEWS, new ComponentWizardViewsPage(\r\n        handler, parameterFinder_, expressionFormatter_, this));\r\n    setPage(ComponentWizardPages::CONCLUSION, conclusionPage);\r\n\r\n    connect(importPage, SIGNAL(componentChanged(QSharedPointer<Component>)), \r\n        this, SLOT(onComponentChanged(QSharedPointer<Component>)), Qt::UniqueConnection);\r\n\r\n    connect(importPage, SIGNAL(componentChanged(QSharedPointer<Component>)), \r\n        conclusionPage, SLOT(onComponentChanged(QSharedPointer<Component>)), Qt::UniqueConnection);\r\n\r\n    connect(importPage, SIGNAL(increaseReferences(QString)),\r\n        referenceCounter_.data(), SLOT(increaseReferenceCount(QString)), Qt::UniqueConnection);\r\n    connect(importPage, SIGNAL(decreaseReferences(QString)),\r\n        referenceCounter_.data(), SLOT(decreaseReferenceCount(QString)), Qt::UniqueConnection);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentWizard::~ComponentWizard()\r\n//-----------------------------------------------------------------------------\r\nComponentWizard::~ComponentWizard()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentWizard::getComponent()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<Component> ComponentWizard::getComponent()\r\n{\r\n    return workingComponent_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentWizard::cleanupPage()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentWizard::cleanupPage(int id)\r\n{\r\n    if (id == ComponentWizardPages::IMPORT)\r\n    {\r\n        workingComponent_ = originalComponent_;\r\n\r\n        parameterFinder_->setComponent(workingComponent_);\r\n    }\r\n\r\n    QWizard::cleanupPage(id);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentWizard::onComponentChanged()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentWizard::onComponentChanged(QSharedPointer<Component> component)\r\n{\r\n    workingComponent_ = component;\r\n\r\n    parameterFinder_->setComponent(workingComponent_);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentWizard::createFileSetInterface()\r\n//-----------------------------------------------------------------------------\r\nFileSetInterface* ComponentWizard::createFileSetInterface(QSharedPointer<ExpressionParser> parser)\r\n{\r\n    QSharedPointer<FileValidator> fileValidator(new FileValidator(parser));\r\n    QSharedPointer<FileSetValidator> fileSetValidator(new FileSetValidator(fileValidator, parser));\r\n\r\n    FileInterface* newFileInterface = new FileInterface(fileValidator, parser, expressionFormatter_);\r\n    FileBuilderInterface* newBuilderInterface = new FileBuilderInterface(parser, expressionFormatter_);\r\n\r\n    FileSetInterface* newFileSetInterface = new FileSetInterface(\r\n        fileSetValidator, parser, expressionFormatter_, newFileInterface, newBuilderInterface);\r\n\r\n    return newFileSetInterface;\r\n}\r\n"
  },
  {
    "path": "wizards/ComponentWizard/ComponentWizard.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ComponentWizard.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Joni-Matti Maatta\r\n// Date: 06.06.2013\r\n//\r\n// Description:\r\n// Component wizard dialog.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef COMPONENTWIZARD_H\r\n#define COMPONENTWIZARD_H\r\n\r\n#include <KactusAPI/include/ComponentParameterFinder.h>\r\n#include <KactusAPI/include/ExpressionFormatter.h>\r\n\r\n#include <QWizard>\r\n\r\nclass Component;\r\nclass LibraryInterface;\r\nclass ReferenceCounter;\r\nclass FileSetInterface;\r\nclass ExpressionParser;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Component wizard dialog.\r\n//-----------------------------------------------------------------------------\r\nclass ComponentWizard : public QWizard\r\n{\r\n    Q_OBJECT\r\n\r\npublic:\r\n \r\n    /*!\r\n     *  Constructor.\r\n     *\r\n     *    @param [in] component   The component for which the wizard is run.\r\n     *    @param [in] basePath    The base path where the component XML will be located.\r\n     *    @param [in] handler\t    Pointer to the instance which manages the library.\r\n     *    @param [in] parent      The parent widget.\r\n     */\r\n    ComponentWizard(QSharedPointer<Component> component,\r\n        QString const& basePath,\r\n        LibraryInterface* handler,\r\n        QWidget* parent);\r\n\r\n    /*!\r\n     *  Destructor.\r\n     */\r\n    ~ComponentWizard();\r\n\r\n    /*!\r\n     *  Returns the component.\r\n     */\r\n    QSharedPointer<Component> getComponent();\r\n\r\nprotected:\r\n\r\n    /*!\r\n     *  Called when back has been selected on a wizard page.\r\n     *\r\n     *    @param [in] id  The id of the page.\r\n     */\r\n    virtual void cleanupPage(int id);\r\n\r\nprivate slots:\r\n\r\n    /*!\r\n     *  Called when a new component has been imported.\r\n     *\r\n     *    @param [in] component   The newly imported component.\r\n     */\r\n    virtual void onComponentChanged(QSharedPointer<Component> component);\r\n\r\nprivate:\r\n    // Disable copying.\r\n    ComponentWizard(ComponentWizard const& rhs);\r\n    ComponentWizard& operator=(ComponentWizard const& rhs);\r\n\r\n    /*!\r\n     *  Create an interface for accessing file sets.\r\n     *\r\n     *    @param [in] parser  Expression parser.\r\n     *\r\n     *    @return Interface for accessing file sets.\r\n     */\r\n    FileSetInterface* createFileSetInterface(QSharedPointer<ExpressionParser> parser);\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! The original component before import.\r\n    QSharedPointer<Component> originalComponent_;\r\n\r\n    //! The working copy of a component after import.\r\n    QSharedPointer<Component> workingComponent_;\r\n\r\n    //! The parameter finder used for finding parameters with parameter ids.\r\n    QSharedPointer <ComponentParameterFinder> parameterFinder_;\r\n\r\n    //! The expression formatter, used for showing the expressions as names instead of ids.\r\n    QSharedPointer<ExpressionFormatter> expressionFormatter_;\r\n\r\n    //! The counter that changes the amount of references to parameters.\r\n    QSharedPointer<ReferenceCounter> referenceCounter_;\r\n};\r\n\r\n#endif // COMPONENTWIZARD_H\r\n"
  },
  {
    "path": "wizards/ComponentWizard/ComponentWizardConclusionPage.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ComponentWizardConclusionPage.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Joni-Matti Maatta\r\n// Date: 06.06.2013\r\n//\r\n// Description:\r\n// Conclusion page for the component wizard.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"ComponentWizardConclusionPage.h\"\r\n\r\n#include <common/widgets/summaryLabel/summarylabel.h>\r\n\r\n#include <KactusAPI/include/LibraryInterface.h>\r\n\r\n#include <wizards/common/ComponentDiffWidget/ComponentDiffWidget.h>\r\n#include <wizards/common/ComponentComparator/ComponentComparator.h>\r\n#include <wizards/common/IPXactDiff.h>\r\n\r\n#include <IPXACTmodels/Component/Component.h>\r\n#include <IPXACTmodels/Component/FileSet.h>\r\n\r\n#include <QFormLayout>\r\n#include <QGroupBox>\r\n#include <QHBoxLayout>\r\n#include <QLabel>\r\n#include <QSharedPointer>\r\n\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentWizardConclusionPage::ComponentWizardConclusionPage()\r\n//-----------------------------------------------------------------------------\r\nComponentWizardConclusionPage::ComponentWizardConclusionPage(QSharedPointer<Component> component, \r\n    LibraryInterface* lh, QSharedPointer<ExpressionFormatter> expressionFormatter, QWidget* parent):\r\nQWizardPage(parent),\r\noriginalComponent_(component),\r\nworkingComponent_(component),\r\nhandler_(lh),\r\nsummaryWidget_(this),\r\nvlnvLabel_(new QLabel(this)),\r\nhierarchyLabel_(new QLabel(this)),\r\nfirmnessLabel_(new QLabel(this)),\r\ndirectoryLabel_(new QLabel(this)),\r\nauthorLabel_(new QLabel(this)),\r\nfilesetsLabel_(new QLabel(this)),\r\nparametersLabel_(new QLabel(this)),\r\nportsLabel_(new QLabel(this)),\r\nviewsLabel_(new QLabel(this)),\r\ndescriptionLabel_(new QLabel(this)),\r\npreviewBox_(lh, this),\r\ndiffView_(new ComponentDiffWidget(expressionFormatter, this))\r\n{\r\n    setTitle(tr(\"Summary\"));\r\n    setSubTitle(tr(\"You have successfully completed the wizard. Verify the choices by clicking Finish.\"));\r\n    setFinalPage(true);\r\n    \r\n    //previewBox_.setFixedWidth(300);\r\n\r\n    directoryLabel_->setWordWrap(true);\r\n    descriptionLabel_->setWordWrap(true);\r\n    \r\n    setupLayout();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentWizardConclusionPage::~ComponentWizardConclusionPage()\r\n//-----------------------------------------------------------------------------\r\nComponentWizardConclusionPage::~ComponentWizardConclusionPage()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentWizardConclusionPage::nextId()\r\n//-----------------------------------------------------------------------------\r\nint ComponentWizardConclusionPage::nextId() const\r\n{\r\n    // The wizard ends here.\r\n    return -1;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentWizardConclusionPage::initializePage()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentWizardConclusionPage::initializePage()\r\n{\r\n    updateComponentDetails();\r\n    previewBox_.setComponent(workingComponent_);\r\n    diffView_->setComponents(originalComponent_, workingComponent_);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ImportWizardConclusionPage::onComponentChanged()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentWizardConclusionPage::onComponentChanged(QSharedPointer<Component> component)\r\n{\r\n    workingComponent_ = component;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentWizardConclusionPage::updateComponentDetails()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentWizardConclusionPage::updateComponentDetails()\r\n{\r\n    vlnvLabel_->setText(workingComponent_->getVlnv().toString());        \r\n\r\n    if (workingComponent_->getImplementation() == KactusAttribute::HW)\r\n    {\r\n        hierarchyLabel_->setText(KactusAttribute::hierarchyToString(workingComponent_->getHierarchy()));\r\n        firmnessLabel_->setText(KactusAttribute::firmnessToString(workingComponent_->getFirmness()));\r\n    }\r\n\r\n    QString xmlPath = handler_->getPath(workingComponent_->getVlnv());\r\n    directoryLabel_->setText(xmlPath);  \r\n    authorLabel_->setText(workingComponent_->getAuthor());\r\n    descriptionLabel_->setText(workingComponent_->getDescription());\r\n\r\n    if (workingComponent_->getFileSets()->isEmpty())\r\n    {\r\n        filesetsLabel_->setText(\"No file sets specified.\");\r\n    }\r\n    else\r\n    {\r\n        QString fileSets = \"\";\r\n\r\n        foreach (QSharedPointer<FileSet> fileSet,  *workingComponent_->getFileSets())\r\n        {         \r\n            fileSets.append(tr(\"%1,  %2 file(s)<br>\").arg(fileSet->name()).arg(fileSet->getFiles()->count()));\r\n        }\r\n\r\n        filesetsLabel_->setText(fileSets.left(fileSets.lastIndexOf(\"<br\")));\r\n    }\r\n\r\n    if (workingComponent_->getImplementation() == KactusAttribute::HW)\r\n    {\r\n        ComponentComparator comparator;\r\n        QList<QSharedPointer<IPXactDiff> > diff = comparator.diff(originalComponent_, workingComponent_);        \r\n\r\n        DiffSummary parameterSummary = creteSummaryFor(\"parameter\", diff);\r\n        parametersLabel_->setText(tr(\"%1 created, %2 removed, %3 modified.\").arg(\r\n            QString::number(parameterSummary.added), QString::number(parameterSummary.removed),\r\n            QString::number(parameterSummary.modified)));     \r\n\r\n        DiffSummary portSummary = creteSummaryFor(\"port\", diff);\r\n        portsLabel_->setText(tr(\"%1 created, %2 removed, %3 modified.\").arg(QString::number(portSummary.added),\r\n            QString::number(portSummary.removed), QString::number(portSummary.modified)));     \r\n\r\n        DiffSummary viewSummary = creteSummaryFor(\"view\", diff);\r\n        viewsLabel_->setText(tr(\"%1 created, %2 removed, %3 modified.\").arg(QString::number(viewSummary.added),\r\n            QString::number(viewSummary.removed), QString::number(viewSummary.modified)));           \r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentWizardConclusionPage::creteSummaryFor()\r\n//-----------------------------------------------------------------------------\r\nComponentWizardConclusionPage::DiffSummary ComponentWizardConclusionPage::creteSummaryFor(QString const& element,\r\n    QList<QSharedPointer<IPXactDiff> > const& diffs) const\r\n{\r\n    DiffSummary summary;\r\n\r\n    foreach(QSharedPointer<IPXactDiff> diff, diffs)\r\n    {\r\n        if (diff->element() == element)\r\n        {\r\n            if (diff->changeType() == IPXactDiff::ADD)\r\n            {\r\n                summary.added++;\r\n            }\r\n            else if (diff->changeType() == IPXactDiff::REMOVE)\r\n            {\r\n                summary.removed++;\r\n            }\r\n            else if(diff->changeType() == IPXactDiff::MODIFICATION)\r\n            {\r\n                summary.modified++;\r\n            }\r\n        }\r\n    }\r\n\r\n    return summary;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentWizardConclusionPage::setupLayout()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentWizardConclusionPage::setupLayout()\r\n{\r\n    QFormLayout* leftLayout = new QFormLayout();\r\n\r\n    leftLayout->addRow(tr(\"<b>VLNV:</b>\"), vlnvLabel_);\r\n\r\n    if (originalComponent_->getImplementation() == KactusAttribute::HW)\r\n    {\r\n        leftLayout->addRow(tr(\"<b>Product Hierarchy:</b>\"), hierarchyLabel_);\r\n        leftLayout->addRow(tr(\"<b>Firmness:</b>\"), firmnessLabel_);\r\n    }\r\n\r\n    leftLayout->addRow(tr(\"<b>File location:</b>\"), directoryLabel_);\r\n    leftLayout->addRow(tr(\"<b>Author:</b>\"), authorLabel_);\r\n    leftLayout->addRow(tr(\"<b>Description:</b>\"), descriptionLabel_);\r\n    leftLayout->addRow(tr(\"<b>File sets:</b>\"), filesetsLabel_);\r\n\r\n    if (originalComponent_->getImplementation() == KactusAttribute::HW)\r\n    {\r\n        leftLayout->addRow(tr(\"<b>Parameters:</b>\"), parametersLabel_);\r\n        leftLayout->addRow(tr(\"<b>Ports:</b>\"), portsLabel_);\r\n        leftLayout->addRow(tr(\"<b>Views:</b>\"), viewsLabel_);\r\n    }\r\n\r\n    QGridLayout* layout = new QGridLayout(this);\r\n\r\n    SummaryLabel* summaryLabel = new SummaryLabel(tr(\"Summary\"), this);\r\n    layout->addWidget(summaryLabel, 0, 0, 1, 2, Qt::AlignCenter);    \r\n\r\n    layout->addLayout(leftLayout, 1, 0, 1, 1);\r\n    layout->addWidget(&previewBox_, 1, 1, 1, 1);\r\n\r\n    QWidget* detailsLabel = new SummaryLabel(tr(\"Details\"), this);\r\n    layout->addWidget(detailsLabel, 2, 0, 1, 2, Qt::AlignCenter);\r\n    layout->addWidget(diffView_, 3, 0, 1, 2);\r\n          \r\n    layout->setColumnStretch(0, 1);\r\n    layout->setColumnStretch(1, 1);\r\n\r\n    bool showDetails = originalComponent_->getImplementation() == KactusAttribute::HW;\r\n    detailsLabel->setVisible(showDetails);\r\n    diffView_->setVisible(showDetails);  \r\n}\r\n"
  },
  {
    "path": "wizards/ComponentWizard/ComponentWizardConclusionPage.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ComponentWizardConclusionPage.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Joni-Matti Maatta\r\n// Date: 06.06.2013\r\n//\r\n// Description:\r\n// Conclusion page for the component wizard.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef COMPONENTWIZARDCONCLUSIONPAGE_H\r\n#define COMPONENTWIZARDCONCLUSIONPAGE_H\r\n\r\n#include <common/widgets/componentPreviewBox/ComponentPreviewBox.h>\r\n\r\n#include <KactusAPI/include/ExpressionFormatter.h>\r\n\r\n#include <QWizardPage>\r\n#include <QLabel>\r\n\r\nclass LibraryInterface;\r\nclass ComponentDiffWidget;\r\nclass IPXactDiff;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Conclusion page for the component wizard.\r\n//-----------------------------------------------------------------------------\r\nclass ComponentWizardConclusionPage : public QWizardPage\r\n{\r\n    Q_OBJECT\r\npublic:\r\n    /*!\r\n    *  Constructor.\r\n    *\r\n    *    @param [in] component                The initial component to create.\r\n    *    @param [in] lh                       The library interface.\r\n    *    @param [in] expressionFormatter      The expression formatter.\r\n    *    @param [in] parent                   The parent wizard.\r\n    */\r\n    ComponentWizardConclusionPage(QSharedPointer<Component> component,\r\n        LibraryInterface* lh,\r\n        QSharedPointer<ExpressionFormatter> expressionFormatter,\r\n        QWidget* parent);\r\n\r\n    /*!\r\n     *  Destructor.\r\n     */\r\n    ~ComponentWizardConclusionPage();\r\n\r\n    /*!\r\n     *  Returns the ID of the next page.\r\n     */\r\n    virtual int nextId() const;\r\n\r\n    /*!\r\n     *  Initializes the page.\r\n     */\r\n    virtual void initializePage();\r\n    \r\n\r\npublic slots:\r\n\r\n    virtual void onComponentChanged(QSharedPointer<Component> component);\r\n\r\nprivate:\r\n    // Disable copying.\r\n    ComponentWizardConclusionPage(ComponentWizardConclusionPage const& rhs);\r\n    ComponentWizardConclusionPage& operator=(ComponentWizardConclusionPage const& rhs);\r\n\r\n    //! Struct for capturing change counts in elements.\r\n    struct DiffSummary\r\n    {\r\n        int added;\r\n        int removed;\r\n        int modified;\r\n\r\n        DiffSummary() : added(0), removed(0), modified(0) {};\r\n    };\r\n\r\n    /*!\r\n     *  Updates the component details e.g. number of created ports.          \r\n     */\r\n    void updateComponentDetails();\r\n\r\n    /*!\r\n     *  Creates a summary of changes in given element.\r\n     *\r\n     *    @param [in] element     The name of the element to summarize.\r\n     *    @param [in] diffs       List of changes to the component.\r\n     *\r\n     *    @return Summary of changes of the given element.\r\n     */\r\n    DiffSummary creteSummaryFor(QString const& element, QList<QSharedPointer<IPXactDiff> > const& diffs) const;\r\n\r\n    //! Sets the page layout.\r\n    void setupLayout();\r\n    \r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! The original component.\r\n    QSharedPointer<Component> originalComponent_;\r\n\r\n    //! The created component.\r\n    QSharedPointer<Component> workingComponent_;\r\n\r\n    //! Pointer to the library manager.\r\n    LibraryInterface* handler_;\r\n\r\n    //! Widget for summary labels.\r\n    QWidget summaryWidget_;\r\n\r\n    //! Label for VLNV vendor.\r\n    QLabel* vlnvLabel_; \r\n\r\n    //! Label for Kactus attribute hierarchy.\r\n    QLabel* hierarchyLabel_;\r\n\r\n    //! Label for Kactus attribute firmness.\r\n    QLabel* firmnessLabel_;\r\n\r\n    //! Label for the xml path.\r\n    QLabel* directoryLabel_;\r\n\r\n    //! Label for author.\r\n    QLabel* authorLabel_;\r\n\r\n    //! Label for the component filesets.\r\n    QLabel* filesetsLabel_;\r\n\r\n    //! Label for the created parameters.\r\n    QLabel* parametersLabel_;\r\n\r\n    //! Label for the created ports.\r\n    QLabel* portsLabel_;\r\n\r\n    //! Label for the created views.\r\n    QLabel* viewsLabel_;\r\n\r\n    //! Label for the component description.\r\n    QLabel* descriptionLabel_;\r\n\r\n    //! The component preview box.\r\n    ComponentPreviewBox previewBox_;\r\n\r\n    //! The widget for displaying changes in the component.\r\n    ComponentDiffWidget* diffView_;\r\n};\r\n\r\n#endif // COMPONENTWIZARDCONCLUSIONPAGE_H\r\n"
  },
  {
    "path": "wizards/ComponentWizard/ComponentWizardDependencyPage.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ComponentWizardDependencyPage.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Joni-Matti Maatta\r\n// Date: 06.06.2013\r\n//\r\n// Description:\r\n// Dependency analysis page for the component wizard.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"ComponentWizardDependencyPage.h\"\r\n\r\n#include \"ComponentWizardPages.h\"\r\n\r\n#include <editors/ComponentEditor/fileSet/filesetsdelegate.h>\r\n#include <KactusAPI/include/FileSetInterface.h>\r\n\r\n#include <IPXACTmodels/kactusExtensions/KactusAttribute.h>\r\n#include <IPXACTmodels/Component/Component.h>\r\n\r\n#include <QLabel>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentWizardDependencyPage::ComponentWizardDependencyPage()\r\n//-----------------------------------------------------------------------------\r\nComponentWizardDependencyPage::ComponentWizardDependencyPage(QSharedPointer<Component> component,\r\n    QSharedPointer<ParameterFinder> parameterFinder, QString const& componentPath,\r\n    FileSetInterface* fileSetInterface, QWidget* parent):\r\nQWizardPage(parent),\r\ncomponent_(component),\r\nsplitter_(Qt::Vertical, this),\r\nview_(&splitter_),\r\nmodel_(fileSetInterface, parameterFinder, this),\r\nproxy_(this),\r\neditor_(component_, componentPath, &splitter_),\r\nfileSetInterface_(fileSetInterface),\r\navailableFileSets_(component->getFileSets())\r\n{\r\n    fileSetInterface_->setFileSets(availableFileSets_);\r\n\r\n    setTitle(tr(\"File Sets & Dependency Analysis\"));\r\n    setSubTitle(tr(\"Add files to the component by specifying the source directories, check \"\r\n        \"file dependencies and create file sets.\"));\r\n    setFinalPage(true);\r\n\r\n    // Set file set view and editor settings.\r\n    proxy_.setSourceModel(&model_);\r\n\r\n    view_.setModel(&proxy_);\r\n    view_.setItemDelegate(new FileSetsDelegate(this));\r\n    view_.setItemsDraggable(false);\r\n    view_.setAllowImportExport(false);\r\n\r\n    editor_.setCompact(true);\r\n    editor_.setDependenciesEditable(false);\r\n\r\n    // Create a container widget for the file set view and its label.\r\n    QWidget* container = new QWidget(this);\r\n    \r\n    QVBoxLayout* containerLayout = new QVBoxLayout(container);\r\n    containerLayout->addWidget(new QLabel(tr(\"File sets:\"), container));\r\n    containerLayout->addWidget(&view_, 1);\r\n    containerLayout->setContentsMargins(0, 0, 0, 0);\r\n\r\n    QWidget* container2 = new QWidget(this);\r\n\r\n    QVBoxLayout* containerLayout2 = new QVBoxLayout(container2);\r\n    containerLayout2->addWidget(new QLabel(tr(\"Dependency analysis:\"), container2));\r\n    containerLayout2->addWidget(&editor_, 1);\r\n    containerLayout2->setContentsMargins(0, 0, 0, 0);\r\n\r\n    // Configure the splitter.\r\n    splitter_.addWidget(container);\r\n    splitter_.addWidget(container2);\r\n    splitter_.setStretchFactor(1, 1);\r\n\r\n    QList<int> sizes;\r\n    sizes << 150 << 300;\r\n    splitter_.setSizes(sizes);\r\n\r\n    QVBoxLayout* layout = new QVBoxLayout(this);\r\n    layout->addWidget(&splitter_);\r\n\r\n    connect(&editor_, SIGNAL(fileSetAdded(FileSet*)),\r\n            &model_, SLOT(onFileSetAdded(FileSet*)), Qt::UniqueConnection);\r\n\r\n    connect(&model_, SIGNAL(contentChanged()), &editor_, SLOT(refresh()), Qt::UniqueConnection);\r\n\r\n    connect(&editor_, SIGNAL(scanStarted()), this, SIGNAL(completeChanged()), Qt::UniqueConnection);\r\n    connect(&editor_, SIGNAL(scanCompleted()), this, SIGNAL(completeChanged()), Qt::UniqueConnection);\r\n\r\n    connect(&view_, SIGNAL(addItem(const QModelIndex&)),\r\n            &model_, SLOT(onAddItem(const QModelIndex&)), Qt::UniqueConnection);\r\n    connect(&view_, SIGNAL(removeItem(const QModelIndex&)),\r\n            &model_, SLOT(onRemoveItem(const QModelIndex&)), Qt::UniqueConnection);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentWizardDependencyPage::~ComponentWizardDependencyPage()\r\n//-----------------------------------------------------------------------------\r\nComponentWizardDependencyPage::~ComponentWizardDependencyPage()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentWizardDependencyPage::nextId()\r\n//-----------------------------------------------------------------------------\r\nint ComponentWizardDependencyPage::nextId() const\r\n{\r\n    if (component_->getImplementation() == KactusAttribute::HW)\r\n    {\r\n        return ComponentWizardPages::IMPORT;\r\n    }\r\n    else\r\n    {\r\n        return ComponentWizardPages::CONCLUSION;\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentWizardDependencyPage::initializePage()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentWizardDependencyPage::initializePage()\r\n{\r\n    // Clear file sets.\r\n    component_->getFileSets()->clear();\r\n\r\n    fileSetInterface_->setFileSets(availableFileSets_);\r\n\r\n    model_.refresh();\r\n\r\n    // Start the scan.\r\n    editor_.scan();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentWizardDependencyPage::isComplete()\r\n//-----------------------------------------------------------------------------\r\nbool ComponentWizardDependencyPage::isComplete() const\r\n{\r\n    return !editor_.isScanning();\r\n}\r\n"
  },
  {
    "path": "wizards/ComponentWizard/ComponentWizardDependencyPage.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ComponentWizardDependencyPage.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Joni-Matti Maatta\r\n// Date: 06.06.2013\r\n//\r\n// Description:\r\n// Dependency analysis page for the component wizard.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef COMPONENTWIZARDDEPENDENCYPAGE_H\r\n#define COMPONENTWIZARDDEPENDENCYPAGE_H\r\n\r\n#include <common/views/EditableTableView/editabletableview.h>\r\n\r\n#include <editors/ComponentEditor/fileSet/filesetsmodel.h>\r\n#include <editors/ComponentEditor/fileSet/dependencyAnalysis/FileDependencyEditor.h>\r\n\r\n#include <QWizardPage>\r\n#include <QSortFilterProxyModel>\r\n#include <QSplitter>\r\n\r\nclass ParameterFinder;\r\nclass FileSetInterface;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Files page for the component wizard.\r\n//-----------------------------------------------------------------------------\r\nclass ComponentWizardDependencyPage : public QWizardPage\r\n{\r\npublic:\r\n\r\n    /*!\r\n     *  The constructor.\r\n     *\r\n     *    @param [in] component           The component.\r\n     *    @param [in] parameterFinder     Finder used to identify parameters.\r\n     *    @param [in] componentPath       Path to the component.\r\n     *    @param [in] fileSetInterface    Interface for accessing file sets.\r\n     *    @param [in] parent              The parent wizard.\r\n     */\r\n    ComponentWizardDependencyPage(QSharedPointer<Component> component,\r\n        QSharedPointer<ParameterFinder> parameterFinder,\r\n        QString const& componentPath,\r\n        FileSetInterface* fileSetInterface,\r\n        QWidget* parent);\r\n\r\n    /*!\r\n     *  Destructor.\r\n     */\r\n    ~ComponentWizardDependencyPage();\r\n\r\n    /*!\r\n     *  Returns the ID of the next page.\r\n     */\r\n    virtual int nextId() const;\r\n\r\n    /*!\r\n     *  Initializes the page.\r\n     */\r\n    virtual void initializePage();\r\n\r\n    /*!\r\n     *  Returns true if the scan has finished; otherwise false.\r\n     */\r\n    virtual bool isComplete() const;\r\n\r\nprivate:\r\n    // Disable copying.\r\n    ComponentWizardDependencyPage(ComponentWizardDependencyPage const& rhs);\r\n    ComponentWizardDependencyPage& operator=(ComponentWizardDependencyPage const& rhs);\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! The target component.\r\n    QSharedPointer<Component> component_;\r\n\r\n    //! Splitter for the fileset table and dependency graph.\r\n    QSplitter splitter_;\r\n\r\n    //! \\brief The view to display the file sets.\r\n    EditableTableView view_;\r\n\r\n    //! \\brief The model that manages the file set objects for the view.\r\n    FileSetsModel model_;\r\n\r\n    //! \\brief The proxy to do the sorting\r\n    QSortFilterProxyModel proxy_;\r\n\r\n    //! The source directories editor.\r\n    FileDependencyEditor editor_;\r\n\r\n    //! Interface for accessing file sets.\r\n    FileSetInterface* fileSetInterface_;\r\n\r\n    //! List of editable file sets.\r\n    QSharedPointer<QList<QSharedPointer<FileSet> > > availableFileSets_;\r\n};\r\n\r\n#endif // COMPONENTWIZARDDEPENDENCYPAGE_H\r\n"
  },
  {
    "path": "wizards/ComponentWizard/ComponentWizardGeneralInfoPage.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ComponentWizardGeneralInfoPage.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Esko Pekkarinen\r\n// Date: 25.06.2013\r\n//\r\n// Description:\r\n// General component information page for the component wizard.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"ComponentWizardGeneralInfoPage.h\"\r\n#include \"ComponentWizardPages.h\"\r\n\r\n#include <IPXACTmodels/Component/Component.h>\r\n\r\n#include <QFormLayout>\r\n#include <QSettings>\r\n\r\n#include <KactusAPI/include/utils.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentWizardGeneralInfoPage::ComponentWizardGeneralInfoPage()\r\n//-----------------------------------------------------------------------------\r\nComponentWizardGeneralInfoPage::ComponentWizardGeneralInfoPage(QSharedPointer<Component> component,\r\n    QWidget* parent):\r\nQWizardPage(parent),\r\ncomponent_(component),\r\nauthorEditor_(this),\r\ndescriptionEditor_(this)\r\n{\r\n    setTitle(tr(\"General information\"));\r\n    setSubTitle(tr(\"Fill in the general information of the component to create.\"));\r\n    setFinalPage(true);\r\n\r\n     Q_ASSERT(component);\r\n\r\n    // Pre-assign username to author field.\r\n    QSettings settings;\r\n    authorEditor_.setText(settings.value(\"General/Username\", Utils::getCurrentUser()).toString());\r\n\r\n    setupLayout();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentWizardGeneralInfoPage::~ComponentWizardGeneralInfoPage()\r\n//-----------------------------------------------------------------------------\r\nComponentWizardGeneralInfoPage::~ComponentWizardGeneralInfoPage()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentWizardGeneralInfoPage::nextId()\r\n//-----------------------------------------------------------------------------\r\nint ComponentWizardGeneralInfoPage::nextId() const\r\n{\r\n    return ComponentWizardPages::FILE_DEPENDENCY;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentWizardGeneralInfoPage::isComplete()\r\n//-----------------------------------------------------------------------------\r\nbool ComponentWizardGeneralInfoPage::isComplete() const\r\n{\r\n\treturn true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentWizardGeneralInfoPage::validatePage()\r\n//-----------------------------------------------------------------------------\r\nbool ComponentWizardGeneralInfoPage::validatePage()\r\n{\r\n    component_->setDescription(descriptionEditor_.toPlainText());\r\n    component_->setAuthor(authorEditor_.text());\r\n\r\n    return true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentWizardGeneralInfoPage::setupLayout()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentWizardGeneralInfoPage::setupLayout()\r\n{\r\n    QVBoxLayout* topLayout = new QVBoxLayout(this);\r\n\r\n    QFormLayout* formLayout = new QFormLayout();     \r\n    formLayout->addRow(tr(\"&Author:\"), &authorEditor_);\r\n    formLayout->addRow(tr(\"&Description:\"), &descriptionEditor_);\r\n\r\n    topLayout->addLayout(formLayout);  \r\n}\r\n"
  },
  {
    "path": "wizards/ComponentWizard/ComponentWizardGeneralInfoPage.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ComponentWizardGeneralInfoPage.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Esko Pekkarinen\r\n// Date: 25.06.2013\r\n//\r\n// Description:\r\n// General component information page for the component wizard.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef COMPONENTWIZARDGENERALINFOPAGE_H\r\n#define COMPONENTWIZARDGENERALINFOPAGE_H\r\n\r\n#include <QWizardPage>\r\n#include <QSharedPointer>\r\n#include <QLineEdit>\r\n#include <QTextEdit>\r\n\r\nclass LibraryInterface;\r\nclass Component;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Intro page for the component wizard.\r\n//-----------------------------------------------------------------------------\r\nclass ComponentWizardGeneralInfoPage : public QWizardPage\r\n{\r\n    Q_OBJECT\r\n\r\npublic:\r\n \r\n   /*!\r\n     *  Constructor.\r\n     *\r\n     *\t\t@param [in, out] component Pointer to the component being edited.\r\n     *    @param [in] parent The parent widget.\r\n     */\r\n    ComponentWizardGeneralInfoPage(QSharedPointer<Component> component, QWidget* parent);\r\n\r\n    /*!\r\n     *  Destructor.\r\n     */\r\n    ~ComponentWizardGeneralInfoPage();\r\n\r\n    /*!\r\n     *  Returns the ID of the next page.\r\n     */\r\n    virtual int nextId() const;\r\n\r\n    /*!\r\n     *  Check if the settings on the page are valid and user can move to next page.\r\n     *\r\n     *    @return True if all settings are valid, otherwise false.\r\n     */\r\n    virtual bool isComplete() const;\r\n\r\n\r\n    /*!\r\n     *  Assigns the input values to the component when next is clicked.\r\n     */\r\n    virtual bool validatePage();\r\n\r\nprivate:\r\n\t// Disable copying.\r\n\tComponentWizardGeneralInfoPage(ComponentWizardGeneralInfoPage const& rhs);\r\n\tComponentWizardGeneralInfoPage& operator=(ComponentWizardGeneralInfoPage const& rhs);\r\n\r\n    /*!\r\n     *   Creates layout for the page.\r\n     */\r\n    void setupLayout();\r\n\r\n\t//-----------------------------------------------------------------------------\r\n\t// Data.\r\n\t//-----------------------------------------------------------------------------\r\n\r\n    //! The component created in the wizard.\r\n    QSharedPointer<Component> component_;\r\n\r\n    //! Editor for inputting author of the component.\r\n    QLineEdit authorEditor_;\r\n\r\n    //! Editor for inputting a description for the component.\r\n    QTextEdit descriptionEditor_;\r\n};\r\n\r\n#endif // COMPONENTWIZARDGENERALINFOPAGE_H\r\n"
  },
  {
    "path": "wizards/ComponentWizard/ComponentWizardImportPage.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ComponentWizardImportPage.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Joni-Matti Maatta\r\n// Date: 06.06.2013\r\n//\r\n// Description:\r\n// Import page for the component wizard.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"ComponentWizardImportPage.h\"\r\n#include \"ComponentWizardPages.h\"\r\n\r\n#include <wizards/ComponentWizard/ImportEditor.h>\r\n\r\n#include <IPXACTmodels/Component/Component.h>\r\n\r\n#include <IPXACTmodels/kactusExtensions/Kactus2Group.h>\r\n#include <IPXACTmodels/kactusExtensions/Kactus2Value.h>\r\n\r\n#include <QVBoxLayout>\r\n#include <QLineEdit>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentWizardVhdlImportPage::ComponentWizardVhdlImportPage()\r\n//-----------------------------------------------------------------------------\r\nComponentWizardImportPage::ComponentWizardImportPage(QSharedPointer<Component> component,\r\n    LibraryInterface* handler, QSharedPointer<ComponentParameterFinder> parameterFinder,\r\n    QSharedPointer<ExpressionFormatter> expressionFormatter, BusInterfaceInterface* busInterface, QWidget* parent):\r\nQWizardPage(parent),\r\neditor_(new ImportEditor(component, handler, parameterFinder, expressionFormatter, busInterface, this))\r\n{\r\n    setTitle(tr(\"Import source file\"));\r\n    setSubTitle(tr(\"Choose the top-level file to import into component.\\n\"\r\n        \"Any model parameter not found in the input file will be removed. Any port not found \"\r\n        \"in the input file will be set as phantom.\"));\r\n    setFinalPage(true);\r\n\r\n    QVBoxLayout* layout = new QVBoxLayout(this);\r\n    layout->addWidget(editor_);\r\n\r\n    connect(editor_, SIGNAL(contentChanged()), this, SIGNAL(completeChanged()), Qt::UniqueConnection);\r\n\r\n    connect(editor_, SIGNAL(componentChanged(QSharedPointer<Component>)),\r\n        this, SLOT(onComponentChange(QSharedPointer<Component>)), Qt::UniqueConnection);\r\n\r\n    connect(editor_, SIGNAL(increaseReferences(QString)),\r\n        this, SIGNAL(increaseReferences(QString)), Qt::UniqueConnection);\r\n    connect(editor_, SIGNAL(decreaseReferences(QString)),\r\n        this, SIGNAL(decreaseReferences(QString)), Qt::UniqueConnection);\r\n\r\n    registerField(InstanceData::VERILOGINSTANCES, this);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentWizardVhdlImportPage::~ComponentWizardVhdlImportPage()\r\n//-----------------------------------------------------------------------------\r\nComponentWizardImportPage::~ComponentWizardImportPage()\r\n{\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentWizardVhdlImportPage::nextId()\r\n//-----------------------------------------------------------------------------\r\nint ComponentWizardImportPage::nextId() const\r\n{\r\n    return ComponentWizardPages::VIEWS;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentWizardVhdlImportPage::initializePage()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentWizardImportPage::initializePage()\r\n{\t\r\n    editor_->initializeFileSelection();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentWizardVhdlImportPage::isComplete()\r\n//-----------------------------------------------------------------------------\r\nbool ComponentWizardImportPage::isComplete() const\r\n{\r\n\treturn true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentWizardImportPage::onComponentChange()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentWizardImportPage::onComponentChange(QSharedPointer<Component> newComponent)\r\n{\r\n    QVector<InstanceData::instanceData> verilogInstances = getVerilogInstancesFromComponent(newComponent);\r\n    setField(InstanceData::VERILOGINSTANCES, QVariant::fromValue(verilogInstances));\r\n\r\n    emit componentChanged(newComponent);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentWizardImportPage::getVerilogInstances()\r\n//-----------------------------------------------------------------------------\r\nQVector<InstanceData::instanceData> ComponentWizardImportPage::getVerilogInstancesFromComponent(\r\n    QSharedPointer<Component> newComponent) const\r\n{\r\n    for (auto componentExtension : *newComponent->getVendorExtensions())\r\n    {\r\n        if (componentExtension->type() == InstanceData::VERILOGINSTANCES)\r\n        {\r\n            QSharedPointer<Kactus2Group> verilogInstanceGroup = componentExtension.dynamicCast<Kactus2Group>();\r\n            if (verilogInstanceGroup)\r\n            {\r\n                newComponent->getVendorExtensions()->removeAll(componentExtension);\r\n                return getVerilogInstancesFromExtension(verilogInstanceGroup);\r\n            }\r\n        }\r\n    }\r\n\r\n    return QVector<InstanceData::instanceData>();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentWizardImportPage::getVerilogInstancesFromExtension()\r\n//-----------------------------------------------------------------------------\r\nQVector<InstanceData::instanceData> ComponentWizardImportPage::getVerilogInstancesFromExtension(\r\n    QSharedPointer<Kactus2Group> instancesGroup) const\r\n{\r\n    QVector<InstanceData::instanceData> instances;\r\n\r\n    for (auto extension : instancesGroup->getByType(InstanceData::SINGLEINSTANCE))\r\n    {\r\n        QSharedPointer<Kactus2Group> extensionGroup = extension.dynamicCast<Kactus2Group>();\r\n        if (extensionGroup)\r\n        {\r\n            InstanceData::instanceData newInstance;\r\n\r\n            if (auto vlnvString = getInstanceString(InstanceData::COMPONENTVLNV, extensionGroup); vlnvString.isEmpty() == false)\r\n            {\r\n                newInstance.componentVLNV_ = VLNV(VLNV::COMPONENT, vlnvString);\r\n            }\r\n\r\n            newInstance.instanceName_ = getInstanceString(InstanceData::INSTANCENAME, extensionGroup);\r\n            newInstance.moduleName_ = getInstanceString(InstanceData::MODULENAME, extensionGroup);\r\n            newInstance.parameters_ =\r\n                getInstanceStringPairs(InstanceData::PARAMETERS, InstanceData::SINGLEPARAMETER, extensionGroup);\r\n            newInstance.portConnections_ =\r\n                getInstanceStringPairs(InstanceData::CONNECTIONS, InstanceData::SINGLECONNECTION, extensionGroup);\r\n\r\n            instances.append(newInstance);\r\n        }\r\n    }\r\n\r\n    return instances;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentWizardImportPage::getInstanceString()\r\n//-----------------------------------------------------------------------------\r\nQString ComponentWizardImportPage::getInstanceString(QString const& stringID,\r\n    QSharedPointer<Kactus2Group> extensionGroup) const\r\n{\r\n    QList<QSharedPointer<VendorExtension> > stringExtensionList = extensionGroup->getByType(stringID);\r\n    if (!stringExtensionList.isEmpty())\r\n    {\r\n        QSharedPointer<Kactus2Value> stringValue = stringExtensionList.first().dynamicCast<Kactus2Value>();\r\n        if (stringValue)\r\n        {\r\n            return stringValue->value();\r\n        }\r\n    }\r\n\r\n    return QString();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentWizardImportPage::getInstanceStringPairs()\r\n//-----------------------------------------------------------------------------\r\nQVector<QPair<QString, QString> > ComponentWizardImportPage::getInstanceStringPairs(QString const& itemGroupID,\r\n    QString const& itemID, QSharedPointer<Kactus2Group> extensionGroup) const\r\n{\r\n    QVector<QPair<QString, QString> > instanceItems;\r\n\r\n    QList<QSharedPointer<VendorExtension> > groupExtensions = extensionGroup->getByType(itemGroupID);\r\n    if (groupExtensions.size() == 1)\r\n    {\r\n        QSharedPointer<Kactus2Group> itemGroup = groupExtensions.first().dynamicCast<Kactus2Group>();\r\n        if (itemGroup)\r\n        {\r\n            QList<QSharedPointer<VendorExtension> > nameValueExtensions = itemGroup->getByType(itemID);\r\n            for (auto singleNameValueExtension : nameValueExtensions)\r\n            {\r\n                QSharedPointer<Kactus2Group> nameValueGroup = singleNameValueExtension.dynamicCast<Kactus2Group>();\r\n                if (nameValueGroup)\r\n                {\r\n                    QPair<QString, QString> newNameValue;\r\n                    newNameValue.first = getSingleValueFromGroup(InstanceData::SUBITEMNAME, nameValueGroup);\r\n                    newNameValue.second = getSingleValueFromGroup(InstanceData::SUBITEMVALUE, nameValueGroup);\r\n\r\n                    instanceItems.append(newNameValue);\r\n                }\r\n            }\r\n        }\r\n    }\r\n\r\n    return instanceItems;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentWizardImportPage::getSingleValueFromGroup()\r\n//-----------------------------------------------------------------------------\r\nQString ComponentWizardImportPage::getSingleValueFromGroup(QString const& valueID,\r\n    QSharedPointer<Kactus2Group> extensionGroup) const\r\n{\r\n    QList<QSharedPointer<VendorExtension> > valueExtensions = extensionGroup->getByType(valueID);\r\n    if (valueExtensions.size() == 1)\r\n    {\r\n        QSharedPointer<Kactus2Value> value = valueExtensions.first().dynamicCast<Kactus2Value>();\r\n        if (value)\r\n        {\r\n            return value->value();\r\n        }\r\n    }\r\n\r\n    return QString();\r\n}\r\n"
  },
  {
    "path": "wizards/ComponentWizard/ComponentWizardImportPage.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ComponentWizardImportPage.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Joni-Matti Maatta\r\n// Date: 06.06.2013\r\n//\r\n// Description:\r\n// Import page for the component wizard.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef COMPONENTWIZARDVHDLIMPORTPAGE_H\r\n#define COMPONENTWIZARDVHDLIMPORTPAGE_H\r\n\r\n#include <KactusAPI/include/ComponentParameterFinder.h>\r\n#include <KactusAPI/include/ExpressionFormatter.h>\r\n\r\n#include <wizards/ComponentWizard/InstanceData.h>\r\n\r\n#include <QWizardPage>\r\n#include <QSharedPointer>\r\n#include <QVariant>\r\n\r\nclass Component;\r\nclass LibraryInterface;\r\nclass ImportEditor;\r\nclass Kactus2Value;\r\nclass Kactus2Group;\r\nclass BusInterfaceInterface;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Import page for the component wizard.\r\n//-----------------------------------------------------------------------------\r\nclass ComponentWizardImportPage : public QWizardPage\r\n{\r\n    Q_OBJECT        \r\npublic:\r\n\r\n    /*!\r\n     *  The constructor.\r\n     *\r\n     *    @param [in] component               Pointer to the component being edited.\r\n     *    @param [in] handler                 Pointer to the instance which manages the library.\r\n     *    @param [in] parameterFinder         The parameter finder.\r\n     *    @param [in] expressionFormatter     The expression formatter.\r\n     *    @param [in] busInterface            Interface for accessing bus interfaces.\r\n     *    @param [in] parent                  The parent wizard.\r\n     */\r\n    ComponentWizardImportPage(QSharedPointer<Component> component,\r\n        LibraryInterface* handler,\r\n        QSharedPointer <ComponentParameterFinder> parameterFinder,\r\n        QSharedPointer<ExpressionFormatter> expressionFormatter,\r\n        BusInterfaceInterface* busInterface,\r\n        QWidget* parent);\r\n\r\n    /*!\r\n     *  Destructor.\r\n     */\r\n    ~ComponentWizardImportPage();\r\n\r\n    /*!\r\n     *  Returns the ID of the next page.\r\n     */\r\n    virtual int nextId() const;\r\n\r\n    /*!\r\n     *  Initialize the page to contain correct files to select the top-vhdl.\r\n     */\r\n    virtual void initializePage();\r\n\r\n\r\n    /*!\r\n     *  Check if the settings on the page are valid and user can move to next page.\r\n     *\r\n     *    @return True if all settings are valid, otherwise false.\r\n     */\r\n    virtual bool isComplete() const;\r\n\r\nsignals:\r\n\r\n     //! Emitted when a new component has been imported.\r\n    void componentChanged(QSharedPointer<Component>);\r\n\r\n    /*!\r\n     *  Increase the number of references to the selected parameter.\r\n     *\r\n     *    @param [in] id      The selected parameter.\r\n     */\r\n    void increaseReferences(QString const& id);\r\n\r\n    /*!\r\n     *  Decrease the number of references to the selected parameter.\r\n     *\r\n     *    @param [in] id      The selected parameter.\r\n     */\r\n    void decreaseReferences(QString const& id);\r\n\r\nprivate slots:\r\n\r\n    /*!\r\n     *  Handle the change in imported component.\r\n     *\r\n     *    @param [in] newComponent    The new component.\r\n     */\r\n    void onComponentChange(QSharedPointer<Component> newComponent);\r\n\r\nprivate:\r\n\t// Disable copying.\r\n\tComponentWizardImportPage(ComponentWizardImportPage const& rhs);\r\n\tComponentWizardImportPage& operator=(ComponentWizardImportPage const& rhs);\r\n    \r\n    /*!\r\n     *  Get the list of imported instances from the selected component.\r\n     *\r\n     *    @param [in] newComponent    The selected component.\r\n     *\r\n     *    @return List of imported instances from the selected component.\r\n     */\r\n    QVector<InstanceData::instanceData> getVerilogInstancesFromComponent(QSharedPointer<Component> newComponent)\r\n        const;\r\n\r\n    /*!\r\n     *  Get the list of imported instances from the selected vendor extension.\r\n     *\r\n     *    @param [in] instancesGroup  Extension group for component instances.\r\n     *\r\n     *    @return List of imported instances from the selected extension group.\r\n     */\r\n    QVector<InstanceData::instanceData> getVerilogInstancesFromExtension(\r\n        QSharedPointer<Kactus2Group> instancesGroup) const;\r\n\r\n    /*!\r\n     *  Get the string for the selected instance parameter.\r\n     *\r\n     *    @param [in] stringID        ID of the selected parameter.\r\n     *    @param [in] extensionGroup  Vendor extension group containing the instance.\r\n     *\r\n     *    @return Instance data matching the ID.\r\n     */\r\n    QString getInstanceString(QString const& stringID, QSharedPointer<Kactus2Group> extensionGroup) const;\r\n\r\n    /*!\r\n     *  Get the string pairs for the selected instance parameter pair.\r\n     *\r\n     *    @param [in] itemGroupID     ID of the selected item group.\r\n     *    @param [in] itemID          ID of the item pair.\r\n     *    @param [in] extensionGroup  Vendor extension group for the parameter pairs.\r\n     *\r\n     *    @return Parameter pair data for the selected ID.\r\n     */\r\n    QVector<QPair<QString, QString> > getInstanceStringPairs(QString const& itemGroupID, QString const& itemID,\r\n        QSharedPointer<Kactus2Group> extensionGroup) const;\r\n\r\n    /*!\r\n     *  Get a single value from the selected extension group.\r\n     *\r\n     *    @param [in] valueID         ID of the selected item.\r\n     *    @param [in] extensionGroup  Vendor extension group for the parameter pairs.\r\n     *\r\n     *    @return Value of the selected ID.\r\n     */\r\n    QString getSingleValueFromGroup(QString const& valueID, QSharedPointer<Kactus2Group> extensionGroup) const;\r\n\r\n\t//-----------------------------------------------------------------------------\r\n\t// Data.\r\n\t//-----------------------------------------------------------------------------\r\n\r\n\t//! Editor to set the generics and ports.\r\n\tImportEditor* editor_;\r\n};\r\n\r\n#endif // COMPONENTWIZARDVHDLIMPORTPAGE_H\r\n"
  },
  {
    "path": "wizards/ComponentWizard/ComponentWizardIntroPage.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ComponentWizardIntroPage.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Joni-Matti Maatta\r\n// Date: 06.06.2013\r\n//\r\n// Description:\r\n// Intro page for the component wizard.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"ComponentWizardIntroPage.h\"\r\n\r\n#include \"ComponentWizardPages.h\"\r\n\r\n#include <QVBoxLayout>\r\n\r\n#include <IPXACTmodels/kactusExtensions/KactusAttribute.h>\r\n#include <IPXACTmodels/Component/Component.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentWizardIntroPage::ComponentWizardIntroPage()\r\n//-----------------------------------------------------------------------------\r\nComponentWizardIntroPage::ComponentWizardIntroPage(QSharedPointer<Component> component, QWidget* parent):\r\nQWizardPage(parent),\r\ninfoLabel_(this)\r\n{\r\n    setTitle(tr(\"Introduction\"));\r\n    setSubTitle(tr(\"This wizard will guide you through the basic steps of creating a component.\"));\r\n    setFinalPage(true);\r\n\r\n    QString infoText = tr(\"This wizard contains the following steps:\");\r\n    infoText += \"<ul><li>\" + tr(\"Component General Information\");\r\n    infoText += \"<li>\" + tr(\"File Sets & Dependency Analysis\");\r\n\r\n    if (component->getImplementation() == KactusAttribute::HW)\r\n    {\r\n        infoText += \"<li>\" + tr(\"Import elements from file.\");\r\n        infoText += \"<li>\" + tr(\"Setup views.\");\r\n    }\r\n\r\n    infoText += \"<li>\" + tr(\"Summary\") + \"</ul>\";\r\n    infoText += \"<br>\" + tr(\"The wizard can be skipped by clicking Finish.\");\r\n\r\n    infoLabel_.setText(infoText);\r\n    infoLabel_.setWordWrap(true);\r\n\r\n    QVBoxLayout* layout = new QVBoxLayout(this);\r\n    layout->addWidget(&infoLabel_);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentWizardIntroPage::~ComponentWizardIntroPage()\r\n//-----------------------------------------------------------------------------\r\nComponentWizardIntroPage::~ComponentWizardIntroPage()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentWizardIntroPage::nextId()\r\n//-----------------------------------------------------------------------------\r\nint ComponentWizardIntroPage::nextId() const\r\n{\r\n    return ComponentWizardPages::GENERAL;\r\n}\r\n"
  },
  {
    "path": "wizards/ComponentWizard/ComponentWizardIntroPage.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ComponentWizardIntroPage.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Joni-Matti Maatta\r\n// Date: 06.06.2013\r\n//\r\n// Description:\r\n// Intro page for the component wizard.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef COMPONENTWIZARDINTROPAGE_H\r\n#define COMPONENTWIZARDINTROPAGE_H\r\n\r\n#include <QWizardPage>\r\n#include <QLabel>\r\n\r\nclass Component;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Intro page for the component wizard.\r\n//-----------------------------------------------------------------------------\r\nclass ComponentWizardIntroPage : public QWizardPage\r\n{\r\npublic:\r\n\r\n    /*!\r\n     *  Constructor.\r\n     *\r\n     *\t\t@param [in, out] component  The component being edited.\r\n     *    @param [in] parent          The parent widget.\r\n     */\r\n    ComponentWizardIntroPage(QSharedPointer<Component> component, QWidget* parent);\r\n\r\n    /*!\r\n     *  Destructor.\r\n     */\r\n    ~ComponentWizardIntroPage();\r\n\r\n    /*!\r\n     *  Returns the ID of the next page.\r\n     */\r\n    virtual int nextId() const;\r\n\r\nprivate:\r\n    // Disable copying.\r\n    ComponentWizardIntroPage(ComponentWizardIntroPage const& rhs);\r\n    ComponentWizardIntroPage& operator=(ComponentWizardIntroPage const& rhs);\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! The label for information.\r\n    QLabel infoLabel_;\r\n};\r\n\r\n#endif // COMPONENTWIZARDINTROPAGE_H\r\n"
  },
  {
    "path": "wizards/ComponentWizard/ComponentWizardPages.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ComponentWizardPages.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Esko Pekkarinen\r\n// Date: 10.09.2014\r\n//\r\n// Description:\r\n// Component wizard page enumerations.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef COMPONENTWIZARDPAGES_H\r\n#define COMPONENTWIZARDPAGES_H\r\n\r\n\r\nnamespace ComponentWizardPages\r\n{\r\n    //! Enumeration for component wizard pages.\r\n    enum Page\r\n    {\r\n        INTRO = 0,\r\n        GENERAL,        \r\n        FILE_DEPENDENCY,\r\n        IMPORT,\r\n        VIEWS,\r\n        CONCLUSION\r\n\t };\r\n\r\n};\r\n\r\n#endif // COMPONENTWIZARDPAGES_H\r\n"
  },
  {
    "path": "wizards/ComponentWizard/ComponentWizardViewsPage.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ComponentWizardViewsPage.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Esko Pekkarinen\r\n// Date: 09.10.2014\r\n//\r\n// Description:\r\n// Component wizard page for setting up views.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"ComponentWizardViewsPage.h\"\r\n#include \"ComponentWizardPages.h\"\r\n#include \"ComponentWizard.h\"\r\n#include \"ViewListModel.h\"\r\n\r\n#include <editors/ComponentEditor/views/vieweditor.h>\r\n#include <KactusAPI/include/IPXactSystemVerilogParser.h>\r\n\r\n#include <KactusAPI/include/LibraryInterface.h>\r\n\r\n#include <IPXACTmodels/common/validators/ParameterValidator.h>\r\n#include <IPXACTmodels/Component/Component.h>\r\n#include <IPXACTmodels/Component/View.h>\r\n#include <IPXACTmodels/Component/ComponentInstantiation.h>\r\n#include <IPXACTmodels/Component/DesignInstantiation.h>\r\n#include <IPXACTmodels/Component/DesignConfigurationInstantiation.h>\r\n\r\n#include <KactusAPI/include/ComponentInstantiationParameterFinder.h>\r\n#include <KactusAPI/include/MultipleParameterFinder.h>\r\n#include <KactusAPI/include/ModuleParameterInterface.h>\r\n\r\n#include <QPushButton>\r\n#include <QVBoxLayout>\r\n#include <QHBoxLayout>\r\n#include <QDialogButtonBox>\r\n\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentWizardViewsPage::ComponentWizardViewsPage()\r\n//-----------------------------------------------------------------------------\r\nComponentWizardViewsPage::ComponentWizardViewsPage(LibraryInterface* lh,\r\n    QSharedPointer<ParameterFinder> parameterFinder, QSharedPointer<ExpressionFormatter> expressionFormatter,\r\n    ComponentWizard* parent):\r\nQWizardPage(parent),\r\nlibrary_(lh),\r\nparent_(parent),\r\neditorTabs_(new QTabWidget(this)),\r\naddButton_(new QPushButton(QIcon(\":/icons/common/graphics/add.png\"), QString(), this)),\r\nremoveButton_(new QPushButton(QIcon(\":/icons/common/graphics/remove.png\"), QString(), this)),\r\nviewList_(new QListView(this)),\r\nviewModel_(new ViewListModel(this)),\r\nparameterFinder_(parameterFinder),\r\nexpressionFormatter_(expressionFormatter),\r\nvalidator_(QSharedPointer<ExpressionParser>(new IPXactSystemVerilogParser(parameterFinder)),\r\n           parent_->getComponent()->getModel())\r\n{\r\n    setTitle(tr(\"Views\"));\r\n    setSubTitle(tr(\"Setup the view(s) for the component.\\n\"\r\n        \"Views specify different representations of the component for e.g. simulation and synthesis.\"));\r\n    setFinalPage(true);\r\n\r\n    addButton_->setToolTip(tr(\"Add new view\"));\r\n    removeButton_->setToolTip(tr(\"Remove selection\"));\r\n\r\n    viewList_->setSelectionMode(QAbstractItemView::SingleSelection);\r\n    viewList_->setModel(viewModel_);\r\n    \r\n    setupLayout();\r\n\r\n    connect(addButton_, SIGNAL(clicked()), this, SLOT(onViewAdded()), Qt::UniqueConnection);\r\n    connect(removeButton_, SIGNAL(clicked()), this, SLOT(onViewRemoved()), Qt::UniqueConnection);\r\n    connect(viewList_, SIGNAL(clicked(QModelIndex const&)), \r\n        this, SLOT(onViewSelected(QModelIndex const&)), Qt::UniqueConnection);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentWizardViewsPage::nextId()\r\n//-----------------------------------------------------------------------------\r\nint ComponentWizardViewsPage::nextId() const\r\n{\r\n    return ComponentWizardPages::CONCLUSION;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentWizardViewsPage::initializePage()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentWizardViewsPage::initializePage()\r\n{   \r\n   editorTabs_->clear();\r\n\r\n   QSharedPointer<Component> component = parent_->getComponent();\r\n   viewModel_->setComponent(component);\r\n   \r\n   validator_.componentChange(component->getModel());\r\n\r\n   foreach(QSharedPointer<View> view, *component->getViews())\r\n   {\r\n       createEditorForView(component, view);\r\n   }\r\n\r\n   removeButton_->setEnabled(parent_->getComponent()->getViews()->count() > 1);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentWizardViewsPage::isComplete()\r\n//-----------------------------------------------------------------------------\r\nbool ComponentWizardViewsPage::isComplete() const\r\n{\r\n    return true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentWizardViewsPage::onViewEdited()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentWizardViewsPage::onViewEdited()\r\n{    \r\n    int currentIndex = editorTabs_->currentIndex();\r\n\r\n    editorTabs_->setTabText(currentIndex, parent_->getComponent()->getViewNames().at(currentIndex));\r\n    updateIconForTab(currentIndex);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentWizardViewsPage::onViewAdded()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentWizardViewsPage::onViewAdded()\r\n{\r\n    viewModel_->addView();\r\n\r\n    QSharedPointer<Component> component = parent_->getComponent(); \r\n    QSharedPointer<View> createdView = component->getViews()->last();\r\n\r\n    createEditorForView(component, createdView);\r\n\r\n    removeButton_->setEnabled(true);\r\n\r\n    emit completeChanged();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentWizardViewsPage::onViewRemoved()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentWizardViewsPage::onViewRemoved()\r\n{\r\n    QModelIndexList selectedIndexes = viewList_->selectionModel()->selectedIndexes();\r\n    if (selectedIndexes.isEmpty())\r\n    {\r\n        return;\r\n    }\r\n\r\n    QModelIndex selectedIndex = selectedIndexes.first();\r\n    QString selectedView = parent_->getComponent()->getViewNames().at(selectedIndex.row());    \r\n    \r\n    removeEditorsForView(selectedView);\r\n\r\n    viewModel_->removeView(selectedIndex);\r\n\r\n    removeButton_->setEnabled(parent_->getComponent()->getViews()->count() > 1);\r\n\r\n    emit completeChanged();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentWizardViewsPage::onViewSelected()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentWizardViewsPage::onViewSelected(QModelIndex const& index)\r\n{\r\n    if (index.isValid())\r\n    {\r\n        editorTabs_->setCurrentIndex(index.row());\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentWizardViewsPage::createEditorForView()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentWizardViewsPage::createEditorForView(QSharedPointer<Component> component, QSharedPointer<View> view)\r\n{\r\n    QSharedPointer<ComponentInstantiationParameterFinder> instantiationParameterFinder(\r\n        new ComponentInstantiationParameterFinder(QSharedPointer<ComponentInstantiation>()));\r\n\r\n    QSharedPointer<MultipleParameterFinder> combinedInstantiationFinder =\r\n        QSharedPointer<MultipleParameterFinder>(new MultipleParameterFinder);\r\n    combinedInstantiationFinder->addFinder(parameterFinder_);\r\n    combinedInstantiationFinder->addFinder(instantiationParameterFinder);\r\n\r\n    QSharedPointer<IPXactSystemVerilogParser> expressionParser(\r\n        new IPXactSystemVerilogParser(combinedInstantiationFinder));\r\n\r\n    QSharedPointer<ExpressionFormatter> moduleFormatter(new ExpressionFormatter(combinedInstantiationFinder));\r\n\r\n    QSharedPointer<ParameterValidator> validator(\r\n        new ParameterValidator(expressionParser, component->getChoices(), component->getRevision()));\r\n    ModuleParameterInterface* moduleParameterInterface = new ModuleParameterInterface(\r\n        validator, expressionParser, moduleFormatter, instantiationParameterFinder);\r\n\r\n    ViewEditor* editor = new ViewEditor(\r\n        component, view, library_, combinedInstantiationFinder, moduleFormatter, moduleParameterInterface, this);\r\n    int editorIndex = editorTabs_->addTab(editor, view->name());\r\n\r\n    updateIconForTab(editorIndex);\r\n\r\n    connect(editor, SIGNAL(contentChanged()), this, SLOT(onViewEdited()), Qt::UniqueConnection);\r\n    connect(editor, SIGNAL(contentChanged()), this, SIGNAL(completeChanged()), Qt::UniqueConnection);    \r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentWizardViewsPage::updateIconForTab()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentWizardViewsPage::updateIconForTab(int tabIndex) const\r\n{\r\n    QSharedPointer<View> viewInTab = parent_->getComponent()->getViews()->at(tabIndex);\r\n    if (validator_.validate(viewInTab))\r\n    {\r\n        editorTabs_->setTabIcon(tabIndex, QIcon());\r\n    }\r\n    else\r\n    {\r\n        editorTabs_->setTabIcon(tabIndex, QIcon(\":icons/common/graphics/exclamation.png\"));\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentWizardViewsPage::removeEditorsForView()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentWizardViewsPage::removeEditorsForView(QString const& viewName)\r\n{\r\n    for(int i = 0; i < editorTabs_->count(); i++)\r\n    {\r\n        if (editorTabs_->tabText(i) == viewName)\r\n        {         \r\n            QWidget* removedEditor = editorTabs_->widget(i);\r\n            editorTabs_->removeTab(i);\r\n            delete removedEditor;\r\n            i--;\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentWizardViewsPage::setupLayout()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentWizardViewsPage::setupLayout()\r\n{\r\n    viewList_->setMaximumHeight(75);\r\n    editorTabs_->setContentsMargins(2, 2, 2, 2);\r\n\r\n    QVBoxLayout* topLayout = new QVBoxLayout(this);\r\n\r\n    QDialogButtonBox* viewListButtons = new QDialogButtonBox(Qt::Vertical, this);\r\n    viewListButtons->addButton(addButton_, QDialogButtonBox::ActionRole);\r\n    viewListButtons->addButton(removeButton_, QDialogButtonBox::ActionRole);\r\n    \r\n    QGroupBox* viewsBox = new QGroupBox(tr(\"Component views\"), this);\r\n    QHBoxLayout* viewsLayout = new QHBoxLayout(viewsBox);\r\n    viewsLayout->addWidget(viewList_);\r\n    viewsLayout->addWidget(viewListButtons);\r\n\r\n    topLayout->addWidget(viewsBox);\r\n    topLayout->addWidget(editorTabs_, 1);\r\n}\r\n"
  },
  {
    "path": "wizards/ComponentWizard/ComponentWizardViewsPage.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ComponentWizardViewsPage.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Esko Pekkarinen\r\n// Date: 09.10.2014\r\n//\r\n// Description:\r\n// Component wizard page for setting up views.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef COMPONENTWIZARDVIEWSPAGE_H\r\n#define COMPONENTWIZARDVIEWSPAGE_H\r\n\r\n#include <QWizardPage>\r\n#include <QSharedPointer>\r\n#include <QTabWidget>\r\n#include <QListView>\r\n\r\n#include <KactusAPI/include/ParameterFinder.h>\r\n#include <KactusAPI/include/ExpressionFormatter.h>\r\n\r\n#include <IPXACTmodels/Component/validators/ViewValidator.h>\r\n\r\nclass Component;\r\nclass ComponentWizard;\r\nclass LibraryInterface;\r\nclass View;\r\nclass ComponentInstantiation;\r\nclass DesignInstantiation;\r\nclass DesignConfigurationInstantiation;\r\nclass ViewListModel;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Component wizard page for setting up views.\r\n//-----------------------------------------------------------------------------\r\nclass ComponentWizardViewsPage : public QWizardPage\r\n{\r\n    Q_OBJECT\r\npublic:\r\n\r\n    /*!\r\n     *  The Constructor.\r\n     *\r\n     *    @param [in] lh                      The library interface.\r\n     *    @param [in] parameterFinder         The parameter finder.\r\n     *    @param [in] expressionFormatter     The expression formatter.\r\n     *    @param [in] parent                  The parent wizard.\r\n     */\r\n    ComponentWizardViewsPage(LibraryInterface* lh, QSharedPointer<ParameterFinder> parameterFinder,\r\n        QSharedPointer<ExpressionFormatter> expressionFormatter, ComponentWizard* parent);\r\n\r\n    /*!\r\n     *  The destructor.\r\n     */\r\n    ~ComponentWizardViewsPage() = default;\r\n\r\n    /*!\r\n    *  Returns the ID of the next page.\r\n    */\r\n    virtual int nextId() const;\r\n\r\n    /*!\r\n    *  Initializes the page.\r\n    */\r\n    virtual void initializePage();\r\n    \r\n    /*!\r\n     *  Returns true if the page is complete and next can be selected.\r\n     */\r\n    virtual bool isComplete() const;\r\n\r\nprivate slots:\r\n\r\n    //! Called when a view has been edited.\r\n    virtual void onViewEdited();\r\n\r\n    //! Called when an new view should be added.\r\n    void onViewAdded();\r\n\r\n    //! Called when a view should be removed.\r\n    void onViewRemoved();\r\n\r\n\r\n    /*!\r\n     *  Called when a view is selected from the list.\r\n     *\r\n     *    @param [in] index   The index of the selected view.\r\n     */\r\n    void onViewSelected(QModelIndex const& index);\r\n\r\nprivate:\r\n    // Disable copying.\r\n    ComponentWizardViewsPage(ComponentWizardViewsPage const& rhs);\r\n    ComponentWizardViewsPage& operator=(ComponentWizardViewsPage const& rhs);\r\n\r\n    /*!\r\n     *  Updates the icon for a given tab according to editor validity.\r\n     *\r\n     *    @param [in] tabIndex   The index of the tab to update.\r\n     */\r\n    void updateIconForTab(int tabIndex) const;\r\n\r\n    /*!\r\n     *  Creates an editor for a given view.\r\n     *\r\n     *    @param [in] component   The component whose view the editor is for.\r\n     *    @param [in] view        The view for which to create an editor.\r\n     */\r\n    void createEditorForView(QSharedPointer<Component> component, QSharedPointer<View> view);\r\n\r\n    /*!\r\n     *  Removes all editors for a given view.\r\n     *\r\n     *    @param [in] viewName   The name of the view whose editors to remove.\r\n     */\r\n    void removeEditorsForView(QString const& viewName);\r\n\r\n    //! Sets the page layout.\r\n    void setupLayout();\r\n\r\n    /*!\r\n     *  Finds a design instantiation referenced by a view.\r\n     *\r\n     *    @param [in] component   The component containing the view.\r\n     *    @param [in] targetView  The selected view.\r\n     *\r\n     *    @return A design instantiation referenced by a view.\r\n     */\r\n    QSharedPointer<DesignInstantiation> getReferencedDesignInstantiation(QSharedPointer<Component> component,\r\n        QSharedPointer<View> targetView) const;\r\n\r\n    /*!\r\n     *  Finds a design configuration instantiation referenced by a view.\r\n     *\r\n     *    @param [in] component   The component containing the view.\r\n     *    @param [in] targetView  The selected view.\r\n     *\r\n     *    @return A component design configuration referenced by a view.\r\n     */\r\n    QSharedPointer<DesignConfigurationInstantiation> getReferencedDesignConfigurationInstantiation(\r\n        QSharedPointer<Component> component, QSharedPointer<View> targetView) const;\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! The library interface.\r\n    LibraryInterface* library_;\r\n\r\n    //! The parent wizard.\r\n    ComponentWizard* parent_;\r\n\r\n    //! The child widget for holding tabs for different views.\r\n    QTabWidget* editorTabs_;\r\n\r\n    //! The button for adding new views.\r\n    QPushButton* addButton_;\r\n\r\n    //! The button for removing the selected view.\r\n    QPushButton* removeButton_;\r\n\r\n    //! The widget displaying the list of views in a component.\r\n    QListView* viewList_;\r\n\r\n    //! The model for view list.\r\n    ViewListModel* viewModel_;\r\n\r\n    //! Parameter finder, finds the desired parameters.\r\n    QSharedPointer<ParameterFinder> parameterFinder_;\r\n\r\n    //! Expression formatter, formats referencing expressions to show names.\r\n    QSharedPointer<ExpressionFormatter> expressionFormatter_;\r\n\r\n    //! Validator for views.\r\n    ViewValidator validator_;\r\n};\r\n\r\n#endif // COMPONENTWIZARDVIEWSPAGE_H\r\n"
  },
  {
    "path": "wizards/ComponentWizard/ImportEditor.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ImportEditor.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Antti Kamppi\r\n// Date: 10.6.2013\r\n//\r\n// Description:\r\n// Used to parse source files and generating IP-XACT packages of them.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"ImportEditor.h\"\r\n\r\n#include <common/widgets/FileSelector/fileselector.h>\r\n\r\n#include <KactusAPI/include/LibraryHandler.h>\r\n\r\n#include <KactusAPI/include/IPXactSystemVerilogParser.h>\r\n#include <editors/ComponentEditor/ports/PortsImportSummaryEditor.h>\r\n\r\n#include <KactusAPI/include/PluginManager.h>\r\n#include <KactusAPI/include/PortsInterface.h>\r\n\r\n#include <KactusAPI/include/ImportRunner.h>\r\n\r\n#include <IPXACTmodels/Component/Component.h>\r\n#include <IPXACTmodels/Component/FileSet.h>\r\n\r\n#include <IPXACTmodels/Component/validators/PortValidator.h>\r\n\r\n#include <QApplication>\r\n#include <QHBoxLayout>\r\n#include <QVBoxLayout>\r\n#include <QLabel>\r\n#include <QDesktopServices>\r\n#include <QFileDialog>\r\n#include <QFormLayout>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ImportEditor::ImportEditor()\r\n//-----------------------------------------------------------------------------\r\nImportEditor::ImportEditor(QSharedPointer<Component> component, \r\n    LibraryInterface* handler,\r\n    QSharedPointer<ComponentParameterFinder> parameterFinder,\r\n    QSharedPointer<ExpressionFormatter> expressionFormatter, \r\n    BusInterfaceInterface* busInterface,\r\n    QWidget *parent):\r\nQWidget(parent),\r\nsplitter_(Qt::Vertical, this),\r\ncomponentXmlPath_(handler->getPath(component->getVlnv())),\r\ncomponent_(component),\r\nimportComponent_(new Component(*component_)),\r\nselectedSourceFile_(),\r\nportEditor_(0),\r\nfileSelector_(new FileSelector(component, this)),\r\neditButton_(new QPushButton(QIcon(\":/icons/common/graphics/edit.png\"), tr(\"Edit file\"), this)),\r\nrefreshButton_(new QPushButton(QIcon(\":/icons/common/graphics/refresh.png\"), tr(\"Refresh\"), this)),\r\nbrowseButton_(new QPushButton(this)),\r\ncomponentSelector_(new QComboBox(this)),\r\nsourceDisplayTabs_(new QTabWidget(this)),\r\nrunner_(new ImportRunner(parameterFinder, sourceDisplayTabs_, this)),\r\nmessageBox_(new QLabel(this)),\r\ncomponentViews_(component->getViews())\r\n{\r\n    componentSelector_->setDisabled(true);\r\n\r\n    browseButton_->setIcon(QIcon(\":icons/common/graphics/opened-folder.png\"));\r\n    browseButton_->setToolTip(tr(\"Browse\"));\r\n\r\n    QSharedPointer<ExpressionParser> expressionParser(new IPXactSystemVerilogParser(parameterFinder));\r\n\r\n    QSharedPointer<PortValidator> portValidator (new PortValidator(expressionParser, componentViews_));\r\n\r\n    ExpressionSet expressions{ parameterFinder, expressionParser, expressionFormatter };\r\n\r\n    auto ports = QSharedPointer<PortsInterface>(new PortsInterface(portValidator, expressions.parser, expressions.formatter));\r\n    ports->setPorts(component->getPorts());\r\n\r\n\tportEditor_ = new PortsImportSummaryEditor(importComponent_, handler, expressions, portValidator, ports, busInterface, &splitter_);\r\n\r\n    // CSV import/export is disabled in the wizard.\r\n\r\n    runner_->setExpressionParser(expressionParser);\r\n    runner_->loadPlugins(PluginManager::getInstance());\r\n\r\n    connect(portEditor_, SIGNAL(contentChanged()), this, SIGNAL(contentChanged()), Qt::UniqueConnection);\r\n\r\n    connect(fileSelector_, SIGNAL(fileSelected(const QString&, QSharedPointer<FileSet>)), this,\r\n\t\tSLOT(onFileSelected(const QString&, QSharedPointer<FileSet>)), Qt::UniqueConnection);\r\n\r\n    connect(refreshButton_, SIGNAL(clicked()),this, SLOT(onRefresh()), Qt::UniqueConnection);\r\n    connect(editButton_, SIGNAL(clicked()), this, SLOT(onOpenEditor()), Qt::UniqueConnection);\r\n    connect(browseButton_, SIGNAL(clicked()), this, SLOT(onBrowseFile()), Qt::UniqueConnection);\r\n\r\n    connect(runner_, SIGNAL(noticeMessage(QString const&)), \r\n        messageBox_, SLOT(setText(QString const&)), Qt::UniqueConnection);\r\n\r\n    connect(componentSelector_, SIGNAL(currentIndexChanged(int)),\r\n        this, SLOT(onChangeSelectedComponent(int)), Qt::UniqueConnection);\r\n\r\n    connect(portEditor_, SIGNAL(decreaseReferences(QString)),\r\n        this, SIGNAL(decreaseReferences(QString)), Qt::UniqueConnection);\r\n    connect(portEditor_, SIGNAL(increaseReferences(QString)),\r\n        this, SIGNAL(increaseReferences(QString)), Qt::UniqueConnection);\r\n\r\n    setupLayout();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ImportEditor::~ImportEditor()\r\n//-----------------------------------------------------------------------------\r\nImportEditor::~ImportEditor()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ImportEditor::initializeFileSelection()\r\n//-----------------------------------------------------------------------------\r\nvoid ImportEditor::initializeFileSelection()\r\n{\r\n    QStringList possibleFileTypes = runner_->importFileTypes();\r\n\r\n    fileSelector_->clearFilters();\r\n\r\n    QStringList possibleSuffixes = fileExtensionsForTypes(possibleFileTypes);\r\n    foreach(QString possibleFileSuffix, possibleSuffixes)\r\n    {\r\n        fileSelector_->addFilter(possibleFileSuffix);\r\n    }\r\n\r\n    onRefresh();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ImportEditor::checkEditorValidity()\r\n//-----------------------------------------------------------------------------\r\nbool ImportEditor::checkEditorValidity() const\r\n{\r\n    return portEditor_->isValid();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ImportEditor::onFileSelected()\r\n//-----------------------------------------------------------------------------\r\nvoid ImportEditor::onFileSelected(QString const& filePath, QSharedPointer<FileSet> fileSet)\r\n{\r\n    selectedSourceFile_ = filePath;\r\n\tselectedFileSet_ = fileSet;\r\n\r\n    onRefresh();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ImportEditor::onOpenEditor()\r\n//-----------------------------------------------------------------------------\r\nvoid ImportEditor::onOpenEditor() \r\n{\r\n    if (!selectedSourceFile_.isEmpty())\r\n    {\r\n        QDesktopServices::openUrl(QUrl::fromLocalFile(selectedFileAbsolutePath()));\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ImportEditor::onBrowseFile()\r\n//-----------------------------------------------------------------------------\r\nvoid ImportEditor::onBrowseFile()\r\n{\r\n    QString path = selectedSourceFile_;\r\n    if (path.isEmpty())\r\n    {\r\n        path = QFileInfo(componentXmlPath_).absolutePath();\r\n    }\r\n    else\r\n    {\r\n\t\tpath = QFileInfo(General::getAbsolutePath(componentXmlPath_, selectedSourceFile_)).canonicalPath();\r\n    }\r\n\r\n    QFileDialog browseDialog(this, tr(\"Select file to import\"), path, getFileBrowsingFilters());\r\n    if (browseDialog.exec() == QDialog::Accepted)\r\n    {\r\n        QStringList selectedFiles = browseDialog.selectedFiles();\r\n        if (!selectedFiles.isEmpty())\r\n        {\r\n            QFileInfo componentFileInfo(componentXmlPath_);\r\n            QString componentFolderPath = componentFileInfo.absolutePath();\r\n\r\n            QDir componentDirectory(componentFolderPath);\r\n\r\n            QString relativePath = componentDirectory.relativeFilePath(selectedFiles.first());\r\n\r\n            if (!fileExistsInFileSelector(relativePath))\r\n            {\r\n                fileSelector_->addItem(relativePath);\r\n            }\r\n\r\n            fileSelector_->selectFile(relativePath);\r\n            onFileSelected(relativePath, QSharedPointer<FileSet>());\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ImportEditor::getFileBrowsingFilters()\r\n//-----------------------------------------------------------------------------\r\nQString ImportEditor::getFileBrowsingFilters() const\r\n{\r\n    QStringList possibleFileTypes = runner_->importFileTypes();\r\n    QStringList possibleSuffixes = fileExtensionsForTypes(possibleFileTypes);\r\n\r\n    QStringList filters;\r\n    for (auto suffix : possibleSuffixes)\r\n    {\r\n        if (!suffix.isEmpty())\r\n        {\r\n            filters.append(suffix.prepend(QLatin1String(\"*.\")));\r\n        }\r\n    }\r\n\r\n    return filters.join(' ');\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ImportEditor::fileExistsInFileSelector()\r\n//-----------------------------------------------------------------------------\r\nbool ImportEditor::fileExistsInFileSelector(QString const& filePath) const\r\n{\r\n    for (int i = 0; i < fileSelector_->count(); ++i)\r\n    {\r\n        if (fileSelector_->itemText(i).compare(filePath) == 0)\r\n        {\r\n            return true;\r\n        }\r\n    }\r\n\r\n    return false;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ImportEditor::onRefresh()\r\n//-----------------------------------------------------------------------------\r\nvoid ImportEditor::onRefresh() \r\n{\r\n    changeAvailableComponents();\r\n}\r\n\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ImportEditor::changeAvailableComponents()\r\n//-----------------------------------------------------------------------------\r\nvoid ImportEditor::changeAvailableComponents()\r\n{\r\n    QString currentComponent = componentSelector_->currentText();\r\n    componentSelector_->clear();\r\n\r\n    QStringList componentNames =\r\n        runner_->constructComponentDataFromFile(selectedSourceFile_, componentXmlPath_, component_);\r\n    if (!componentNames.isEmpty())\r\n    {\r\n        componentSelector_->setDisabled(false);\r\n\r\n        componentSelector_->addItems(componentNames);\r\n\r\n        componentSelector_->setCurrentIndex(0);\r\n    }\r\n    else\r\n    {\r\n        componentSelector_->setDisabled(true);\r\n        onChangeSelectedComponent(0);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ImportEditor::onChangeSelectedComponent()\r\n//-----------------------------------------------------------------------------\r\nvoid ImportEditor::onChangeSelectedComponent(int index)\r\n{\r\n    QString componentName = componentSelector_->itemText(index);\r\n\r\n    importComponent_ = runner_->run(componentName, selectedSourceFile_, componentXmlPath_, component_);\r\n\r\n    portEditor_->setComponent(importComponent_);\r\n\r\n    componentViews_ = importComponent_->getViews();\r\n\r\n    if (selectedFileSet_)\r\n    {\r\n        foreach(QSharedPointer<ComponentInstantiation> componentInstantiation,\r\n            *importComponent_->getComponentInstantiations())\r\n        {\r\n            auto fileSetRefsAsStrings = componentInstantiation->getFileSetReferenceStrings();\r\n\r\n            if (fileSetRefsAsStrings.contains(selectedFileSet_->name()))\r\n            {\r\n                QSharedPointer<FileSetRef> newFileSetRef(new FileSetRef());\r\n                newFileSetRef->setReference(selectedFileSet_->name());\r\n                componentInstantiation->getFileSetReferences()->append(newFileSetRef);\r\n            }\r\n        }\r\n    }\r\n\r\n    emit componentChanged(importComponent_);\r\n    emit contentChanged();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ImportEditor::fileSuffixesForTypes()\r\n//-----------------------------------------------------------------------------\r\nQStringList ImportEditor::fileExtensionsForTypes(QStringList possibleFileTypes) const\r\n{\r\n    QStringList fileSuffixes;\r\n\r\n    QSettings settings;\r\n    settings.beginGroup(\"FileTypes\");\r\n\r\n    foreach (QString const& fileType, possibleFileTypes)\r\n    {\r\n        settings.beginGroup(fileType);\r\n\r\n        QStringList fileTypeExtensions = settings.value(\"Extensions\").toString().split(';');\r\n        foreach (QString const& extension, fileTypeExtensions)\r\n        {\r\n            if (!fileSuffixes.contains(extension))\r\n            {\r\n                fileSuffixes.append(extension);\r\n            }\r\n        }\r\n        settings.endGroup();\r\n    }\r\n\r\n    settings.endGroup();\r\n\r\n    return fileSuffixes;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ImportEditor::selectedFileAbsolutePath()\r\n//-----------------------------------------------------------------------------\r\nQString ImportEditor::selectedFileAbsolutePath() const\r\n{\r\n    return General::getAbsolutePath(componentXmlPath_, selectedSourceFile_);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ImportEditor::setupLayout()\r\n//-----------------------------------------------------------------------------\r\nvoid ImportEditor::setupLayout()\r\n{\r\n    sourceDisplayTabs_->setMinimumHeight(300);\r\n\r\n\tQVBoxLayout* topLayout = new QVBoxLayout(this);    \r\n    topLayout->addWidget(&splitter_);\r\n    topLayout->addWidget(messageBox_);\r\n    topLayout->setContentsMargins(0, 0, 0, 0);\r\n    \r\n    QWidget* sourceWidget = new QWidget(this);\r\n    QVBoxLayout* sourceLayout = new QVBoxLayout(sourceWidget);    \r\n\r\n    sourceLayout->setContentsMargins(0, 0, 0, 0);\r\n\r\n    QLabel* selectorLabel = new QLabel(tr(\"Select top-level file to import:\"), this);\r\n    QLabel* entityLabel = new QLabel(tr(\"Select component to import:\"), this);\r\n\r\n    QHBoxLayout* buttonLayout = new QHBoxLayout();\r\n    buttonLayout->addWidget(browseButton_);\r\n    buttonLayout->addWidget(editButton_);\r\n    buttonLayout->addWidget(refreshButton_);\r\n\r\n    QGridLayout* upperLayout = new QGridLayout();\r\n    upperLayout->addWidget(selectorLabel, 0, 0);\r\n    upperLayout->addWidget(fileSelector_, 0, 1, 1, 3);\r\n    upperLayout->addWidget(entityLabel, 1, 0);\r\n    upperLayout->addWidget(componentSelector_, 1, 1, 1, 3);\r\n    upperLayout->addLayout(buttonLayout, 0, 4, Qt::AlignRight);\r\n\r\n    sourceLayout->addLayout(upperLayout);\r\n    sourceLayout->addWidget(sourceDisplayTabs_);\r\n\r\n    splitter_.addWidget(sourceWidget);\r\n    splitter_.addWidget(portEditor_);\r\n    splitter_.setStretchFactor(0, 60);\r\n    splitter_.setStretchFactor(1, 40);\r\n}\r\n"
  },
  {
    "path": "wizards/ComponentWizard/ImportEditor.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ImportEditor.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Antti Kamppi\r\n// Date: 10.6.2013\r\n//\r\n// Description:\r\n// Used to parse source files and generating IP-XACT packages of them.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef VHDLIMPORTEDITOR_H\r\n#define VHDLIMPORTEDITOR_H\r\n\r\n#include <KactusAPI/include/ComponentParameterFinder.h>\r\n#include <KactusAPI/include/ExpressionFormatter.h>\r\n\r\n#include <QPushButton>\r\n#include <QSharedPointer>\r\n#include <QSplitter>\r\n#include <QString>\r\n#include <QTabWidget>\r\n#include <QWidget>\r\n#include <QComboBox>\r\n\r\nclass FileSet;\r\nclass Component;\r\nclass FileSelector;\r\nclass ImportRunner;\r\nclass LibraryInterface;\r\nclass PortsImportSummaryEditor;\r\nclass View;\r\nclass BusInterfaceInterface;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Used to parse source files and generating IP-XACT packages of them.\r\n//-----------------------------------------------------------------------------\r\nclass ImportEditor : public QWidget\r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\r\n\t/*!\r\n\t *  The constructor.\r\n\t *\r\n\t *    @param [in] component               The component being edited.\r\n\t *    @param [in] handler                 The instance which manages the library.\r\n\t *    @param [in] parameterFinder         The parameter finder.\r\n\t *    @param [in] expressionFormatter     The expression formatter.\r\n     *    @param [in] busInterface            Interface for accessing bus interfaces.\r\n\t *    @param [in] parent                  The owner of this widget.\r\n\t */\r\n\tImportEditor(QSharedPointer<Component> component,\r\n        LibraryInterface* handler,\r\n        QSharedPointer <ComponentParameterFinder> parameterFinder,\r\n        QSharedPointer<ExpressionFormatter> expressionFormatter,\r\n        BusInterfaceInterface* busInterface,\r\n        QWidget *parent);\r\n\t\r\n\t//! The destructor.\r\n\t~ImportEditor();\r\n\r\n\t/*!\r\n     *  Initialize the combo box to select the top-level vhdl vfile.\r\n\t * \r\n\t *  Display all available VHDL files and if one was previously selected and still available, keep it as\r\n     *  selected.\r\n\t */\r\n\tvoid initializeFileSelection();\r\n\r\n\t/*!\r\n\t *  Checks the validity of model parameter and port editors.\r\n\t *\r\n\t *    @return False if contents of either editor is not valid.\r\n\t */\r\n\tbool checkEditorValidity() const;\r\n\r\nsignals:\r\n\r\n\t//! Emitted when the contents of the editors change.\r\n\tvoid contentChanged();\r\n\r\n    //! Emitted when a new component is imported.\r\n    void componentChanged(QSharedPointer<Component>);\r\n\r\n    /*!\r\n     *  Increase the number of references to the selected parameter.\r\n     *\r\n     *    @param [in] id      The selected parameter.\r\n     */\r\n    void increaseReferences(QString const& id);\r\n\r\n    /*!\r\n     *  Decrease the number of references to the selected parameter.\r\n     *\r\n     *    @param [in] id      The selected parameter.\r\n     */\r\n    void decreaseReferences(QString const& id);\r\n\r\nprivate slots:\r\n\r\n    //! Called when a source file has been selected.\r\n    void onFileSelected(QString const& filePath, QSharedPointer<FileSet> fileSet);\r\n\r\n    //! Called when the selected source file should be opened in an editor.\r\n    void onOpenEditor();\r\n\r\n    //! Called when the source file should be re-parsed.\r\n    void onRefresh();\r\n\r\n    /*!\r\n     *  Handles the file browsing.\r\n     */\r\n    void onBrowseFile();\r\n\r\n    /*!\r\n     *  Handle the change in the imported component.\r\n     *\r\n     *    @param [in] index   Index of the new component.\r\n     */\r\n    void onChangeSelectedComponent(int index);\r\n\r\nprivate:\r\n\t\r\n\t//! No copying.\r\n\tImportEditor(const ImportEditor& other);    \r\n\r\n\t//! No assignment.\r\n\tImportEditor& operator=(const ImportEditor& other);\r\n\r\n    /*!\r\n     *  Finds the file extensions for given file types.\r\n     *\r\n     *    @param [in] possibleFileTypes   The file types whose extensions to find.\r\n     *\r\n     *    @return The file extensions for the file types.\r\n     */\r\n    QStringList fileExtensionsForTypes(QStringList possibleFileTypes) const;\r\n\r\n    /*!\r\n     *  Gets the absolute path to the selected source file.\r\n     *\r\n     *    @return The absolute path to the selected source file.\r\n     */\r\n    QString selectedFileAbsolutePath() const;\r\n\r\n    /*!\r\n     *  Scrolls the source displayer to the first highlighted line, if any.\r\n     */\r\n    void scrollSourceDisplayToFirstHighlight() const;\r\n\r\n    //! Creates the layout for the editor.            \r\n    void setupLayout();\r\n\r\n    /*!\r\n     *  Get the filters for file browsing.\r\n     *\r\n     *    @return List of filters combined with white space.\r\n     */\r\n    QString getFileBrowsingFilters() const;\r\n\r\n    /*!\r\n     *  Check if a file exists in the file selector.\r\n     *\r\n     *    @param [in] filePath    Path of the selected file.\r\n     *\r\n     *    @return True, if the file exists in the file selector, false otherwise.\r\n     */\r\n    bool fileExistsInFileSelector(QString const& filePath) const;\r\n\r\n    /*!\r\n     *  Change the available importable components.\r\n     */\r\n    void changeAvailableComponents();\r\n\r\n    //-----------------------------------------------------------------------------\r\n    //! Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! Splitter for source file view and editors.\r\n    QSplitter splitter_;\r\n\r\n\t//! Path to the XML file containing the target component.\r\n\tQString componentXmlPath_;\r\n\r\n    //! The original component.\r\n    QSharedPointer<Component> component_;\r\n\r\n    //! The imported component.\r\n    QSharedPointer<Component> importComponent_ ;\r\n\r\n    //! Top-level source file relative path from component XML file.\r\n    QString selectedSourceFile_;\r\n\r\n\t//! The file set where the selectedSourceFile_ belongs to.\r\n\tQSharedPointer<FileSet> selectedFileSet_;\r\n\r\n\t//! Editor for the imported ports.\r\n\tPortsImportSummaryEditor* portEditor_;\r\n\r\n    //! Used to select the top-level source file.\r\n    FileSelector* fileSelector_;\r\n\r\n    //! Button for opening an editor for the selected source file.\r\n    QPushButton* editButton_;\r\n\r\n    //! Button for refreshing ports and model parameters from the selected file.\r\n    QPushButton* refreshButton_;\r\n\r\n    //! Button for browsing the imported file.\r\n    QPushButton* browseButton_;\r\n\r\n    //! Used to selected the imported component.\r\n    QComboBox* componentSelector_;\r\n\r\n    //! Tabs for displaying imported source files.\r\n    QTabWidget* sourceDisplayTabs_;\r\n\r\n    //! Runner for all available import parsers.\r\n    ImportRunner* runner_;\r\n\r\n    //! Widget for showing notifications from import plugins.\r\n    QWidget* messageBox_;\r\n\r\n    //! The available component views.\r\n    QSharedPointer<QList<QSharedPointer<View> > > componentViews_;\r\n};\r\n\r\n#endif // VHDLIMPORTEDITOR_H\r\n"
  },
  {
    "path": "wizards/ComponentWizard/InstanceData.h",
    "content": "//-----------------------------------------------------------------------------\n// File: InstanceData.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 10.04.2019\n//\n// Description:\n// Model containing the parsed instance data.\n//-----------------------------------------------------------------------------\n\n#ifndef INSTANCEDATA_H\n#define INSTANCEDATA_H\n\n#include <IPXACTmodels/common/VLNV.h>\n\n#include <QString>\n#include <QVector>\n#include <QMetaType>\n\n//-----------------------------------------------------------------------------\n//! Model containing the parsed instance data.\n//-----------------------------------------------------------------------------\nnamespace InstanceData\n{\n    //! The parsed instance data.\n    struct instanceData\n    {\n        //! VLNV\n        VLNV componentVLNV_;\n\n        //! Name.\n        QString instanceName_;\n\n        //! Module name.\n        QString moduleName_;\n\n        //! Contained parameters.\n        QVector<QPair<QString, QString> > parameters_;\n\n        //! Contained port connections.\n        QVector<QPair<QString, QString> > portConnections_;\n    };\n\n    //! Reserved vocabulary for instance data.\n    const QString VERILOGINSTANCES(\"verilogInstances\");\n    const QString SINGLEINSTANCE(\"instance\");\n\n    const QString COMPONENTVLNV(\"componentVLNV\");\n    const QString INSTANCENAME(\"instanceName\");\n    const QString MODULENAME(\"moduleName\");\n    const QString PARAMETERS(\"parameters\");\n    const QString SINGLEPARAMETER(\"parameter\");\n    const QString CONNECTIONS(\"connections\");\n    const QString SINGLECONNECTION(\"connection\");\n\n    const QString SUBITEMNAME(\"subItemName\");\n    const QString SUBITEMVALUE(\"subItemValue\");\n};\n\nQ_DECLARE_METATYPE(QVector<InstanceData::instanceData>)\n\n#endif // INSTANCEDATA_H\n"
  },
  {
    "path": "wizards/ComponentWizard/ViewListModel.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ViewListModel.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Esko Pekkarinen\r\n// Date: 10.10.2014\r\n//\r\n// Description:\r\n// Model for listing component views.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"ViewListModel.h\"\r\n\r\n#include <IPXACTmodels/Component/Component.h>\r\n#include <IPXACTmodels/Component/View.h>\r\n\r\n#include <common/KactusColors.h>\r\n\r\n#include <QIcon>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ViewListModel::ViewListModel()\r\n//-----------------------------------------------------------------------------\r\nViewListModel::ViewListModel(QObject *parent): QAbstractListModel(parent), component_()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ViewListModel::~ViewListModel()\r\n//-----------------------------------------------------------------------------\r\nViewListModel::~ViewListModel()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ViewListModel::setComponent()\r\n//-----------------------------------------------------------------------------\r\nvoid ViewListModel::setComponent(QSharedPointer<Component> component)\r\n{\r\n    beginResetModel();\r\n    component_ = component;\r\n    endResetModel();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ViewListModel::rowCount()\r\n//-----------------------------------------------------------------------------\r\nint ViewListModel::rowCount(QModelIndex const& parent) const {\r\n\t\r\n\tif (parent.isValid() || component_.isNull())\r\n    {\r\n\t\treturn 0;\r\n    }\r\n\r\n\treturn component_->getViews()->count();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ViewListModel::data()\r\n//-----------------------------------------------------------------------------\r\nQVariant ViewListModel::data(QModelIndex const& index, int role) const\r\n{\r\n\tif (!index.isValid() || component_.isNull() || index.row() < 0 || index.row() >= component_->getViews()->count())\r\n    {\r\n\t\treturn QVariant();\r\n    }\r\n\r\n    QString viewName = component_->getViewNames().at(index.row());  \r\n\r\n\tif (role == Qt::DisplayRole)\r\n    {\r\n        if (viewName.isEmpty())\r\n        {\r\n            viewName = \"<unnamed>\";\r\n        }\r\n\r\n        return viewName;        \r\n\t}\r\n    else if (role == Qt::DecorationRole)\r\n    {\r\n        QStringList hierViews = component_->getHierViews();\r\n        if (hierViews.contains(viewName))\r\n        {\r\n            return QIcon(\":icons/common/graphics/hierarchy.png\");\r\n        }\r\n        else\r\n        {\r\n            return QVariant();\r\n        }\r\n    }\r\n    else if(role == Qt::ForegroundRole)\r\n    {\r\n        if (component_->getViewNames().count(viewName) > 1 || viewName.isEmpty())\r\n        {\r\n            return KactusColors::ERROR;\r\n        }\r\n        else\r\n        {\r\n            return KactusColors::REGULAR_TEXT;\r\n        }\r\n    }\r\n\telse\r\n    {\r\n\t\treturn QVariant();\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ViewListModel::addView()\r\n//-----------------------------------------------------------------------------\r\nvoid ViewListModel::addView()\r\n{\r\n    if (component_.isNull())\r\n    {\r\n        return;\r\n    }\r\n\r\n    int endOfList = component_->getViews()->count();\r\n\r\n\tbeginInsertRows(QModelIndex(), endOfList, endOfList);\r\n    QSharedPointer<View> newView(new View());\r\n\tcomponent_->getViews()->append(newView);    \r\n\tendInsertRows();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ViewListModel::removeView()\r\n//-----------------------------------------------------------------------------\r\nvoid ViewListModel::removeView(QModelIndex const& index)\r\n{\r\n\tif (!index.isValid() || component_.isNull())\r\n    {\r\n\t\treturn;\r\n    }\r\n    \r\n    beginResetModel();\r\n    component_->getViews()->removeAt(index.row());\r\n\tendResetModel();\r\n}\r\n"
  },
  {
    "path": "wizards/ComponentWizard/ViewListModel.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ViewListModel.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus2\r\n// Author: Esko Pekkarinen\r\n// Date: 10.10.2014\r\n//\r\n// Description:\r\n// Model for listing component views.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef VIEWLISTMODEL_H\r\n#define VIEWLISTMODEL_H\r\n\r\n#include <QAbstractListModel>\r\n#include <QSharedPointer>\r\n\r\nclass Component;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Model for listing component views.\r\n//-----------------------------------------------------------------------------\r\nclass ViewListModel : public QAbstractListModel\r\n{\r\n\tQ_OBJECT\r\n\r\npublic:\r\n\r\n\t/*!\r\n\t *  The constructor.\r\n\t *\r\n\t *    @param [in] parent   The parent object.\r\n\t */\r\n\tViewListModel(QObject *parent);\r\n\t\r\n\t//! The destructor\r\n\tvirtual ~ViewListModel();\r\n\r\n    /*!\r\n     *  Sets the component whose views to list.\r\n     *\r\n     *    @param [in] component   The component whose views to list in the model.\r\n     */\r\n    void setComponent(QSharedPointer<Component> component);\r\n\r\n\t/*!\r\n\t *  Returns the number of rows in the model.\r\n\t *\r\n\t *    @param [in] parent   The parent index whose row count to return. Should always be invalid in list.\r\n\t *\r\n\t *    @return The number of rows in the model.\r\n\t */\r\n\tint rowCount(const QModelIndex& parent = QModelIndex()) const;\r\n\t\r\n\t/*!\r\n\t *  Returns the data in the model.\r\n\t *\r\n\t *    @param [in] index   The index whose data to fetch.\r\n\t *    @param [in] role    The role of the data to fetch.\r\n\t *\r\n\t *    @return The model data for the given role.\r\n\t */\r\n\tQVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const;\r\n\r\n\r\npublic slots:\r\n\r\n\t//! Adds a new view to the component and the list.\r\n\tvirtual void addView();\r\n\r\n\t//! Removes all the views with same name as the view in given model index.\r\n\tvirtual void removeView(const QModelIndex& index);\r\n\r\nprivate:\r\n\r\n\t//! \\brief No copying\r\n\tViewListModel(const ViewListModel& other);\r\n\r\n\t//! No assignment\r\n\tViewListModel& operator=(const ViewListModel& other);\r\n\r\n    //! The component whose views to list.\r\n    QSharedPointer<Component> component_;\r\n};\r\n\r\n#endif // VIEWLISTMODEL_H\r\n"
  },
  {
    "path": "wizards/ImportWizard/ImportInstancesEditor/ImportInstancesColumns.h",
    "content": "//-----------------------------------------------------------------------------\n// File: ImportInstancesColumns.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 16.04.2019\n//\n// Description:\n// Common declarations for imported component instances.\n//-----------------------------------------------------------------------------\n\nnamespace ImportInstancesColumns\n{\n    //! The editable columns in the import instances editor.\n    enum columns\n    {\n        INSTANCE = 0,\n        VLNV,\n        PATH,\n        XML_PATH,\n        COLUMN_COUNT\n    };\n}\n"
  },
  {
    "path": "wizards/ImportWizard/ImportInstancesEditor/ImportInstancesDelegate.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: ImportInstancesDelegate.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 16.04.2019\n//\n// Description:\n// Delegate that provides editing for imported instances.\n//-----------------------------------------------------------------------------\n\n#include \"ImportInstancesDelegate.h\"\n\n#include <wizards/ImportWizard/ImportInstancesEditor/ImportInstancesColumns.h>\n\n#include <KactusAPI/include/LibraryInterface.h>\n\n#include <IPXACTmodels/Component/Component.h>\n#include <IPXACTmodels/common/VLNV.h>\n\n#include <QLineEdit>\n#include <QFileInfo>\n\nnamespace\n{\n    QString const NEWCOMPONENTTEXT(\"<New component>\");\n};\n\n//-----------------------------------------------------------------------------\n// Function: ImportInstancesDelegate::ImportInstancesDelegate()\n//-----------------------------------------------------------------------------\nImportInstancesDelegate::ImportInstancesDelegate(QSharedPointer<const Component> workingComponent,\n    QString const& defaultPath, LibraryInterface* libraryAccess, QObject* parent):\nQStyledItemDelegate(parent),\ninstanceComponentMatches_(),\ninstanceData_(),\nworkingComponent_(workingComponent),\ndefaultPath_(defaultPath),\nlibraryAccess_(libraryAccess)\n{\n\n}\n\n//-----------------------------------------------------------------------------\n// Function: ImportInstancesDelegate::setupVLNVEditor()\n//-----------------------------------------------------------------------------\nvoid ImportInstancesDelegate::setupVLNVEditors(\n    QMultiMap<QString, QSharedPointer<const Component>> instanceComponentMatches,\n    QVector<InstanceData::instanceData> const& newInstances)\n{\n    instanceComponentMatches_ = instanceComponentMatches;\n    instanceData_ = newInstances;\n}\n\n//-----------------------------------------------------------------------------\n// Function: ImportInstancesDelegate::createEditor()\n//-----------------------------------------------------------------------------\nQWidget* ImportInstancesDelegate::createEditor(QWidget* parent, QStyleOptionViewItem const& option,\n    QModelIndex const& index) const\n{\n    if (index.column() == ImportInstancesColumns::VLNV)\n    {\n        return createVLNVSelector(index, parent);\n    }\n\n    return QStyledItemDelegate::createEditor(parent, option, index);\n}\n\n//-----------------------------------------------------------------------------\n// Function: ImportInstancesDelegate::createVLNVSelector()\n//-----------------------------------------------------------------------------\nQComboBox* ImportInstancesDelegate::createVLNVSelector(QModelIndex const& selectionIndex, QWidget* parent) const\n{\n    QComboBox* combo = new QComboBox(parent);\n    combo->addItem(NEWCOMPONENTTEXT);\n\n    QModelIndex const& instanceNameIndex =\n        selectionIndex.sibling(selectionIndex.row(), ImportInstancesColumns::INSTANCE);\n    QString instanceName = instanceNameIndex.data(Qt::DisplayRole).toString();\n\n    QList<QSharedPointer<Component const> > componentMatches = instanceComponentMatches_.values(instanceName);\n    for (auto component : componentMatches)\n    {\n        combo->addItem(component->getVlnv().toString());\n    }\n\n    return combo;\n}\n\n//-----------------------------------------------------------------------------\n// Function: ImportInstancesDelegate::setEditorData()\n//-----------------------------------------------------------------------------\nvoid ImportInstancesDelegate::setEditorData(QWidget* editor, QModelIndex const& index) const \n{\n    if (index.column() == ImportInstancesColumns::VLNV)\n    {\n        QString itemVLNV = index.data(Qt::DisplayRole).toString();\n        QComboBox* vlnvCombo = qobject_cast<QComboBox*>(editor);\n\n        int comboIndex = vlnvCombo->findText(itemVLNV);\n        if (comboIndex < 0 && !itemVLNV.isEmpty())\n        {\n            vlnvCombo->addItem(itemVLNV);\n            vlnvCombo->setCurrentIndex(vlnvCombo->findText(itemVLNV));\n        }\n        else\n        {\n            vlnvCombo->setCurrentIndex(comboIndex);\n        }\n    }\n\n    QStyledItemDelegate::setEditorData(editor, index);\n}\n\n//-----------------------------------------------------------------------------\n// Function: ImportInstancesDelegate::setModelData()\n//-----------------------------------------------------------------------------\nvoid ImportInstancesDelegate::setModelData(QWidget* editor, QAbstractItemModel* model,\n    QModelIndex const& index) const \n{\n    if (index.column() == ImportInstancesColumns::VLNV)\n    {\n        QComboBox* vlnvCombo = qobject_cast<QComboBox*>(editor);\n        QString newVLNVText = vlnvCombo->currentText();\n        QString oldVLNVText = index.data(Qt::DisplayRole).toString();\n\n        if (newVLNVText.compare(NEWCOMPONENTTEXT) == 0)\n        {\n            QModelIndex instanceNameIndex = index.sibling(index.row(), ImportInstancesColumns::INSTANCE);\n            QString instanceName = instanceNameIndex.data(Qt::DisplayRole).toString();\n\n            VLNV newVLNV = workingComponent_->getVlnv();\n            newVLNV.setName(instanceName);\n            newVLNV.setVersion(QStringLiteral(\"1.0\"));\n\n            newVLNVText = newVLNV.toString();\n        }\n\n        if (newVLNVText.compare(oldVLNVText) != 0)\n        {\n            model->setData(index, newVLNVText, Qt::DisplayRole);\n\n            setNewXMLPath(index, newVLNVText, model);\n        }\n    }\n    else if (index.column() == ImportInstancesColumns::PATH || index.column() == ImportInstancesColumns::XML_PATH)\n    {\n        QLineEdit* pathEditor = qobject_cast<QLineEdit*>(editor);\n        if (pathEditor)\n        {\n            QString path = pathEditor->text();\n\n            if (index.column() == ImportInstancesColumns::PATH && !path.isEmpty())\n            {\n                QFileInfo fileInfo(path);\n                if (!fileInfo.exists() || !fileInfo.isFile())\n                {\n                    return;\n                }\n                else\n                {\n                    emit checkForNewLibraryLocation(path);\n                }\n            }\n            else if (index.column() == ImportInstancesColumns::XML_PATH)\n            {\n                if (path.isEmpty())\n                {\n                    return;\n                }\n                else\n                {\n                    emit checkForNewLibraryLocation(path);\n                }\n            }\n\n            emit changeIndexItemTooltip(index, path);\n        }\n    }\n    \n    QStyledItemDelegate::setModelData(editor, model, index);\n}\n\n//-----------------------------------------------------------------------------\n// Function: ImportInstancesDelegate::setNewXMLPath()\n//-----------------------------------------------------------------------------\nvoid ImportInstancesDelegate::setNewXMLPath(QModelIndex const& vlnvIndex, QString const& newVLNVText,\n    QAbstractItemModel* model) const\n{\n    QModelIndex xmlPathIndex = vlnvIndex.sibling(vlnvIndex.row(), ImportInstancesColumns::XML_PATH);\n    QModelIndex const& instanceNameIndex = vlnvIndex.sibling(vlnvIndex.row(), ImportInstancesColumns::INSTANCE);\n    QString instanceName = instanceNameIndex.data(Qt::DisplayRole).toString();\n\n    QString newXMLPath(\"\");\n    bool itemIsEditable = false;\n\n    for (auto component : instanceComponentMatches_.values(instanceName))\n    {\n        if (newVLNVText.compare(component->getVlnv().toString()) == 0)\n        {\n            newXMLPath = libraryAccess_->getPath(component->getVlnv());\n            break;\n        }\n    }\n\n    if (newXMLPath.isEmpty())\n    {\n        VLNV newItemVLNV = workingComponent_->getVlnv();\n        newItemVLNV.setName(getModuleNameForInstance(instanceName));\n        newItemVLNV.setVersion(QStringLiteral(\"1.0\"));\n\n        QString newItemFileName =\n            newItemVLNV.getName() + QLatin1Char('.') + newItemVLNV.getVersion() + QLatin1String(\".xml\");\n        newXMLPath =\n            defaultPath_ + newItemVLNV.toString(QStringLiteral(\"/\")) + QLatin1Char('/') + newItemFileName;\n\n        itemIsEditable = true;\n    }\n\n    model->setData(xmlPathIndex, newXMLPath);\n    emit changeItemEditableStatus(xmlPathIndex, itemIsEditable);\n}\n\n//-----------------------------------------------------------------------------\n// Function: ImportInstancesDelegate::getModuleNameForInstance()\n//-----------------------------------------------------------------------------\nQString ImportInstancesDelegate::getModuleNameForInstance(QString const& instanceName) const\n{\n    for (auto const& instance : instanceData_)\n    {\n        if (instance.instanceName_.compare(instanceName) == 0)\n        {\n            return instance.moduleName_;\n        }\n    }\n\n    return QString(\"\");\n}\n"
  },
  {
    "path": "wizards/ImportWizard/ImportInstancesEditor/ImportInstancesDelegate.h",
    "content": "//-----------------------------------------------------------------------------\n// File: ImportInstancesDelegate.h\n//-----------------------------------------------------------------------------\n// Project: Kactus2\n// Author: Mikko Teuho\n// Date: 16.04.2019\n//\n// Description:\n// Delegate that provides editing for imported instances.\n//-----------------------------------------------------------------------------\n\n#ifndef IMPORTINSTANCSEDELEGATE_H\n#define IMPORTINSTANCSEDELEGATE_H\n\n#include <wizards/ComponentWizard/InstanceData.h>\n\n#include <QStyledItemDelegate>\n#include <QComboBox>\n\nclass Component;\nclass LibraryInterface;\n\n//-----------------------------------------------------------------------------\n//! Delegate that provides editing for imported instances.\n//-----------------------------------------------------------------------------\nclass ImportInstancesDelegate : public QStyledItemDelegate\n{\n\tQ_OBJECT\n\npublic:\n\n\t/*!\n\t *  The constructor.\n\t *\n     *    @param [in] workingComponent    The imported component.\n     *    @param [in] defaultPath         The default library path.\n     *    @param [in] libraryAccess       The library interface.\n     *    @param [in] parent              The parent of the object.\n\t */\n    ImportInstancesDelegate(QSharedPointer<const Component> workingComponent, QString const& defaultPath,\n        LibraryInterface* libraryAccess, QObject* parent = 0);\n\n\t/*!\n     *  The destructor.\n     */\n    ~ImportInstancesDelegate() = default;\n\n    /*!\n     *  Setup the options for the VLNV editor.\n     *\n     *    @param [in] instanceComponentMatches    The possible component modules for each component instance.\n     *    @param [in] newInstances                List of imported component instances.\n     */\n    void setupVLNVEditors(QMultiMap< QString, QSharedPointer<const Component> > instanceComponentMatches,\n        QVector<InstanceData::instanceData> const& newInstances);\n\n\t/*!\n     *  Create a new editor for the given item\n\t *\n\t *    @param [in] parent   Owner for the editor.\n\t *    @param [in] option   Contains options for the editor.\n\t *    @param [in] index    Model index identifying the item.\n\t *\n\t *    @return Pointer to the editor to be used to edit the item.\n     */\n\tvirtual QWidget* createEditor(QWidget* parent, QStyleOptionViewItem const& option, QModelIndex const& index)\n        const;\n\n\t/*!\n     *  Set the data for the editor.\n\t *\n\t *    @param [in] editor  Pointer to the editor where the data is to be set.\n\t *    @param [in] index   Model index identifying the item that's data is to be set.\n     */\n\tvirtual void setEditorData(QWidget* editor, QModelIndex const& index) const;\n\n\t/*!\n     *  Save the data from the editor to the model.\n\t *\n\t *    @param [in] editor   Pointer to the editor that contains the data to store.\n\t *    @param [in] model    Model that contains the data structure where data is to be saved to.\n\t *    @param [in] index    Model index identifying the item that's data is to be saved.\n     */\n\tvirtual void setModelData(QWidget* editor, QAbstractItemModel* model, QModelIndex const& index) const;\n\n\n    //! No copying. No assignment.\n    ImportInstancesDelegate(const ImportInstancesDelegate& other) = delete;\n    ImportInstancesDelegate& operator=(const ImportInstancesDelegate& other) = delete;\n\nsignals:\n\n    /*!\n     *  Change the status of the indexed item.\n     *\n     *    @param [in] index       Index of the selected item.\n     *    @param [in] isEditable  New status of the indexed item.\n     */\n    void changeItemEditableStatus(QModelIndex const& index, bool isEditable) const;\n\n    /*!\n     *  Check if the selected path is located in a new library location.\n     *\n     *    @param [in] newPath     The selected path.\n     */\n    void checkForNewLibraryLocation(QString const& newPath) const;\n\n    /*!\n     *  Change the tooltip of the indexed item.\n     *\n     *    @param [in] index       The index of the selected item.\n     *    @param [in] newText     The new tooltip.\n     */\n    void changeIndexItemTooltip(QModelIndex const& index, QString const& newText) const;\n\nprivate:\n\n    /*!\n     *  Create the selection widget for VLNVs.\n     *\n     *    @param [in] selectionIndex              Index of the item selector.\n     *    @param [in] parent                      Parent item of the editor.\n     *\n     *    @return Combobox for VLNVs.\n     */\n    QComboBox* createVLNVSelector(QModelIndex const& selectionIndex, QWidget* parent) const;\n\n    /*!\n     *  Set a new XML path for the selected VLNV.\n     *\n     *    @param [in] vlnvIndex       Index of the VLNV.\n     *    @param [in] newVLNVText     The VLNV in string.\n     *    @param [in] model           Model containing the data.\n     */\n    void setNewXMLPath(QModelIndex const& vlnvIndex, QString const& newVLNVText, QAbstractItemModel* model) const;\n\n    /*!\n     *  Get the name of the instanced module.\n     *\n     *    @param [in] instanceName    Name of the selected component instance.\n     */\n    QString getModuleNameForInstance(QString const& instanceName) const;\n\n    //-----------------------------------------------------------------------------\n    // Data.\n    //-----------------------------------------------------------------------------\n\n    //! List of possible components for each component instance.\n    QMultiMap<QString, QSharedPointer<const Component> > instanceComponentMatches_;\n\n    //! List of instanced components.\n    QVector<InstanceData::instanceData> instanceData_;\n\n    //! The imported component.\n    QSharedPointer<const Component> workingComponent_;\n\n    //! The default library path.\n    QString defaultPath_;\n\n    //! The library interface.\n    LibraryInterface* libraryAccess_;\n};\n\n#endif // AUTOCONNECTORCONNECTIONDELEGATE_H\n"
  },
  {
    "path": "wizards/ImportWizard/ImportInstancesEditor/ImportInstancesEditor.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: ImportInstancesEditor.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Mikko Teuho\n// Date: 02.04.2019\n//\n// Description:\n// Used to generate IP-XACT component instances from parsed source files.\n//-----------------------------------------------------------------------------\n\n#include \"ImportInstancesEditor.h\"\n\n#include <common/dialogs/LibrarySettingsDialog/LibrarySettingsDialog.h>\n\n#include <KactusAPI/include/LibraryInterface.h>\n\n#include <wizards/ImportWizard/ImportInstancesEditor/ImportInstancesColumns.h>\n#include <wizards/ImportWizard/ImportInstancesEditor/ImportInstancesDelegate.h>\n\n#include <IPXACTmodels/Component/Component.h>\n#include <IPXACTmodels/common/Document.h>\n\n#include <IPXACTmodels/Component/FileSet.h>\n#include <IPXACTmodels/Component/File.h>\n\n#include <QHeaderView>\n#include <QSettings>\n#include <QMenu>\n#include <QFileInfo>\n#include <QFileDialog>\n#include <QMessageBox>\n#include <QTextStream>\n\n//-----------------------------------------------------------------------------\n// Function: ImportInstancesEditor::ImportInstancesEditor()\n//-----------------------------------------------------------------------------\nImportInstancesEditor::ImportInstancesEditor(QSharedPointer<Component> workingComponent,\n    LibraryInterface* libraryAccess, QWidget* parent) :\nQTableWidget(parent),\nworkingComponent_(workingComponent),\ndefaultPath_(\"\"),\ninstanceDelegate_(),\nlibraryAccess_(libraryAccess),\nbrowseXMLFileAction_(QString(tr(\"Browse\")), this),\nbrowseImportFileAction_(QString(tr(\"Browse\")), this),\nselectedItem_(),\nlibraryLocations_()\n// instances_()\n{\n    QSettings settings(this);\n    defaultPath_ = settings.value(\"Library/DefaultLocation\", QString()).toString();\n\n    setActiveLibraryLocations(settings);\n\n    instanceDelegate_ = new ImportInstancesDelegate(workingComponent, defaultPath_, libraryAccess, this);\n\n    setColumnCount(ImportInstancesColumns::COLUMN_COUNT);\n    verticalHeader()->hide();\n    horizontalHeader()->setSectionResizeMode(QHeaderView::Interactive);\n    horizontalHeader()->setStretchLastSection(true);\n\n    QStringList horizontalHeaders;\n    horizontalHeaders.insert(ImportInstancesColumns::INSTANCE, QString(tr(\"Instance\")));\n    horizontalHeaders.insert(ImportInstancesColumns::VLNV, QString(tr(\"VLNV\")));\n    horizontalHeaders.insert(ImportInstancesColumns::PATH, QString(tr(\"Path\")));\n    horizontalHeaders.insert(ImportInstancesColumns::XML_PATH, QString(tr(\"XML path\")));\n\n    setHorizontalHeaderLabels(horizontalHeaders);\n\n    setItemDelegate(instanceDelegate_);\n\n    connect(instanceDelegate_, SIGNAL(changeItemEditableStatus(QModelIndex const&, bool)),\n        this, SLOT(changeItemEditableStatus(QModelIndex const&, bool)), Qt::UniqueConnection);\n    connect(instanceDelegate_, SIGNAL(checkForNewLibraryLocation(QString const&)),\n        this, SLOT(onCheckForNewLibraryLocation(QString const&)), Qt::UniqueConnection);\n    connect(instanceDelegate_, SIGNAL(changeIndexItemTooltip(QModelIndex const&, QString const&)),\n        this, SLOT(onChangeIndexItemTooltip(QModelIndex const&, QString const&)), Qt::UniqueConnection);\n\n    connect(&browseImportFileAction_, SIGNAL(triggered()), this, SLOT(onBrowseImportFile()), Qt::UniqueConnection);\n    connect(&browseXMLFileAction_, SIGNAL(triggered()), this, SLOT(onBrowseXMLFile()), Qt::UniqueConnection);\n}\n\n//-----------------------------------------------------------------------------\n// Function: ImportInstancesEditor::setActiveLibraryLocations()\n//-----------------------------------------------------------------------------\nvoid ImportInstancesEditor::setActiveLibraryLocations(QSettings const& settings)\n{\n    libraryLocations_.clear();\n    QStringList activeLocations = settings.value(\"Library/ActiveLocations\", QStringList()).toStringList();\n\n    foreach(QString location, activeLocations)\n    {\n        if (!QFileInfo(location).isAbsolute())\n        {\n            QString fullLocation = QFileInfo(location).absoluteFilePath();\n            libraryLocations_.append(fullLocation);\n        }\n        else\n        {\n            libraryLocations_.append(location);\n        }\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: ImportInstancesEditor::setupInstances()\n//-----------------------------------------------------------------------------\nvoid ImportInstancesEditor::setupInstances(QVector<InstanceData::instanceData> const& newInstances)\n{\n    clearContents();\n    setRowCount(newInstances.count());\n    if (!newInstances.isEmpty())\n    {\n        for (int i = 0; i < newInstances.size(); ++i)\n        {\n            InstanceData::instanceData const& instance = newInstances.at(i);\n            createInstanceNameItem(instance.instanceName_, i);\n        }\n\n        createInstancePathItems(newInstances);\n        createInstanceVLNVItems(newInstances);\n    }\n\n    horizontalHeader()->stretchLastSection();\n\n    for (int i = 0; i < ImportInstancesColumns::COLUMN_COUNT; ++i)\n    {\n        if (i < ImportInstancesColumns::PATH)\n        {\n            resizeColumnToContents(i);\n        }\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: ImportInstancesEditor::createInstanceNameItem()\n//-----------------------------------------------------------------------------\nvoid ImportInstancesEditor::createInstanceNameItem(QString const& instanceName, int const& instanceRow)\n{\n    QTableWidgetItem* newItem = new QTableWidgetItem(instanceName);\n\n    newItem->setFlags(newItem->flags() & ~Qt::ItemIsEnabled);\n    newItem->setToolTip(instanceName);\n\n    setItem(instanceRow, ImportInstancesColumns::INSTANCE, newItem);\n}\n\n//-----------------------------------------------------------------------------\n// Function: ImportInstancesEditor::createInstancePathItems()\n//-----------------------------------------------------------------------------\nvoid ImportInstancesEditor::createInstancePathItems(QVector<InstanceData::instanceData> const& instances)\n{\n    QMultiMap<QString, QString> instanceFilePaths = getPossibleFilePaths(instances);\n\n    for (int i = 0; i < instances.size(); ++i)\n    {\n        InstanceData::instanceData const& singleInstance = instances.at(i);\n        QList<QString> filePaths = instanceFilePaths.values(singleInstance.instanceName_);\n        QString selectedFile(\"\");\n        if (!filePaths.isEmpty())\n        {\n            selectedFile = filePaths.first();\n        }\n\n        QTableWidgetItem* newPathItem = new QTableWidgetItem(selectedFile);\n        newPathItem->setToolTip(selectedFile);\n\n        setItem(i, ImportInstancesColumns::PATH, newPathItem);\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: ImportInstancesEditor::getPossibleFilePaths()\n//-----------------------------------------------------------------------------\nQMultiMap<QString, QString> ImportInstancesEditor::getPossibleFilePaths(\n    QVector<InstanceData::instanceData> const& instances) const\n{\n    QMultiMap<QString, QString> instanceFilePaths;\n\n    QString componentPath = libraryAccess_->getPath(workingComponent_->getVlnv());\n\n    QRegularExpression moduleExpression(QStringLiteral(\"module\\\\s+(\\\\w+)\"));\n\n    QVector<QSharedPointer<File> > verilogFiles = getCompatibleComponentFiles(workingComponent_);\n    for (auto file : verilogFiles)\n    {\n        QString absoluteFilePath = General::getAbsolutePath(componentPath, file->name());\n        QString fileText = readInputFile(file->name(), componentPath);\n\n        QRegularExpressionMatch moduleMatch = moduleExpression.match(fileText);\n        if (moduleMatch.hasMatch())\n        {\n            QString moduleName = moduleMatch.captured(1);\n\n            for (auto const& singleInstance : instances)\n            {\n                if (moduleName.compare(singleInstance.moduleName_, Qt::CaseInsensitive) == 0)\n                {\n                    instanceFilePaths.insert(singleInstance.instanceName_, absoluteFilePath);\n                }\n            }\n        }\n    }\n\n    return instanceFilePaths;\n}\n\n//-----------------------------------------------------------------------------\n// Function: ImportInstancesEditor::getCompatibleComponentFiles()\n//-----------------------------------------------------------------------------\nQVector<QSharedPointer<File> > ImportInstancesEditor::getCompatibleComponentFiles(\n    QSharedPointer<Component> component) const\n{\n    QVector < QSharedPointer<File> > verilogFiles;\n\n    for (auto fileSet : *component->getFileSets())\n    {\n        for (auto singleFile : *fileSet->getFiles())\n        {\n            if (fileIsVerilogFile(singleFile))\n            {\n                verilogFiles.append(singleFile);\n            }\n        }\n    }\n\n    return verilogFiles;\n}\n\n//-----------------------------------------------------------------------------\n// Function: ImportInstancesEditor::readInputFile()\n//-----------------------------------------------------------------------------\nQString ImportInstancesEditor::readInputFile(QString const& relativePath, QString const& basePath) const\n{\n    QString fileContent = \"\";\n\n    QString absoluteFilePath = General::getAbsolutePath(basePath, relativePath);\n\n    QFile importFile(absoluteFilePath);\n    if (QFileInfo(absoluteFilePath).exists() && importFile.open(QIODevice::ReadOnly))\n    {\n        QTextStream stream(&importFile);\n        fileContent = stream.readAll();\n        fileContent.replace(\"\\r\\n\", \"\\n\");\n        importFile.close();\n    }\n    else\n    {\n        fileContent = tr(\"<File %1 not found in the file sets.>\").arg(relativePath);\n    }\n\n    return fileContent;\n}\n\n//-----------------------------------------------------------------------------\n// Function: ImportInstancesEditor::fileIsVerilogFile()\n//-----------------------------------------------------------------------------\nbool ImportInstancesEditor::fileIsVerilogFile(QSharedPointer<File> file) const\n{\n    for (auto const& fileType : *file->getFileTypes())\n    {\n        if (fileType.type_.contains(QStringLiteral(\"verilog\"), Qt::CaseInsensitive))\n        {\n            return true;\n        }\n    }\n\n    return false;\n}\n\n//-----------------------------------------------------------------------------\n// Function: ImportInstancesEditor::createInstanceVLNVItem()\n//-----------------------------------------------------------------------------\nvoid ImportInstancesEditor::createInstanceVLNVItems(QVector<InstanceData::instanceData> const& instances)\n{\n    QMultiMap< QString, QSharedPointer<const Component> > instanceComponentMatches;\n    for (auto const& vlnv : libraryAccess_->getAllVLNVs())\n    {\n        QSharedPointer<const Component> componentCandidate = getComponentFromVLNV(vlnv);\n        if (componentCandidate)\n        {\n            for (auto const& singleInstance : instances)\n            {\n\t\t\t\tif (vlnv == singleInstance.componentVLNV_ &&\n\t\t\t\t\tinstanceDataMatchesComponentPorts(singleInstance, componentCandidate))\n                {\n                    instanceComponentMatches.insert(singleInstance.instanceName_, componentCandidate);\n                }\n            }\n        }\n    }\n\n    instanceDelegate_->setupVLNVEditors(instanceComponentMatches, instances);\n\n    for (int i = 0; i < instances.size(); ++i)\n    {\n        InstanceData::instanceData const& singleInstance = instances.at(i);\n\n        VLNV newItemVLNV;\n        QString itemVLNVText(\"\");\n        QString vlnvPath(\"\");\n        QList<QSharedPointer<const Component> > possibleComponents =\n            instanceComponentMatches.values(singleInstance.instanceName_);\n\n        bool pathIsEditable = true;\n\n        if (possibleComponents.isEmpty())\n        {\n            newItemVLNV = workingComponent_->getVlnv();\n            newItemVLNV.setName(singleInstance.moduleName_);\n            newItemVLNV.setVersion(QStringLiteral(\"1.0\"));\n\n            QString newItemFileName =\n                newItemVLNV.getName() + QLatin1Char('.') + newItemVLNV.getVersion() + QLatin1String(\".xml\");\n            vlnvPath =\n                defaultPath_ + QLatin1Char('/') + newItemVLNV.toString(QStringLiteral(\"/\")) + QLatin1Char('/') + newItemFileName;\n        }\n        else\n        {\n            newItemVLNV = possibleComponents.first()->getVlnv();\n            vlnvPath = libraryAccess_->getPath(newItemVLNV);\n            pathIsEditable = false;\n        }\n\n        itemVLNVText = newItemVLNV.toString();\n\n        QTableWidgetItem* newVLNVItem = new QTableWidgetItem(itemVLNVText);\n        QTableWidgetItem* newPathItem = new QTableWidgetItem(vlnvPath);\n        newVLNVItem->setToolTip(itemVLNVText);\n        newPathItem->setToolTip(vlnvPath);\n\n        if (!pathIsEditable)\n        {\n            newPathItem->setFlags(newPathItem->flags() & ~Qt::ItemIsEnabled);\n        }\n\n        setItem(i, ImportInstancesColumns::VLNV, newVLNVItem);\n        setItem(i, ImportInstancesColumns::XML_PATH, newPathItem);\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: ImportInstancesEditor::getComponentFromVLNV()\n//-----------------------------------------------------------------------------\nQSharedPointer<const Component> ImportInstancesEditor::getComponentFromVLNV(VLNV const& componentVLNV) const\n{\n    QSharedPointer<const Document> document = libraryAccess_->getModelReadOnly(componentVLNV);\n    if (componentVLNV.getType() == VLNV::COMPONENT && document)\n    {\n        QSharedPointer<const Component> possibleComponent = document.dynamicCast<const Component>();\n        return possibleComponent;\n    }\n\n    return QSharedPointer<const Component>();\n}\n\n//-----------------------------------------------------------------------------\n// Function: ImportInstancesEditor::instanceDataMatchesComponentPorts()\n//-----------------------------------------------------------------------------\nbool ImportInstancesEditor::instanceDataMatchesComponentPorts(InstanceData::instanceData const& instance,\n    QSharedPointer<const Component> component) const\n{\n    if (instance.portConnections_.isEmpty())\n    {\n        return true;\n    }\n\n    if (!component->getPorts()->isEmpty())\n    {\n        for (auto const& instancePort : instance.portConnections_)\n        {\n            if (!component->getPortNames().contains(instancePort.first))\n            {\n                return false;\n            }\n        }\n\n        return true;\n    }\n\n    return false;\n}\n\n//-----------------------------------------------------------------------------\n// Function: ImportInstancesEditor::changeItemEditableStatus()\n//-----------------------------------------------------------------------------\nvoid ImportInstancesEditor::changeItemEditableStatus(QModelIndex const& index, bool isEditable)\n{\n    QTableWidgetItem* indexedItem = itemFromIndex(index);\n\n    if (isEditable)\n    {\n        indexedItem->setFlags(indexedItem->flags() | Qt::ItemIsEnabled);\n    }\n    else\n    {\n        indexedItem->setFlags(indexedItem->flags() & ~Qt::ItemIsEnabled);\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: ImportInstancesEditor::contextMenuEvent()\n//-----------------------------------------------------------------------------\nvoid ImportInstancesEditor::contextMenuEvent(QContextMenuEvent* event)\n{\n    QModelIndex index = indexAt(event->pos());\n    selectedItem_  = itemFromIndex(index);\n\n    if (selectedItem_ && selectedItem_->flags() & Qt::ItemIsEnabled)\n    {\n        QMenu menu(this);\n        if (index.column() == ImportInstancesColumns::PATH)\n        {\n            menu.addAction(&browseImportFileAction_);\n        }\n        else if (index.column() == ImportInstancesColumns::XML_PATH)\n        {\n            menu.addAction(&browseXMLFileAction_);\n        }\n\n        menu.exec(event->globalPos());\n        event->accept();\n    }\n\n    QTableWidget::contextMenuEvent(event);\n}\n\n//-----------------------------------------------------------------------------\n// Function: ImportInstancesEditor::onBrowseImportFile()\n//-----------------------------------------------------------------------------\nvoid ImportInstancesEditor::onBrowseImportFile()\n{\n    QTableWidgetItem* instanceItem = item(selectedItem_->row(), ImportInstancesColumns::INSTANCE);\n    QString instanceName = instanceItem->text();\n\n    QString currentPath = getCurrentPath();\n\n    QString targetPath = QFileDialog::getOpenFileName(\n        NULL, tr(\"Select verilog file for instance %1\").arg(instanceName), currentPath, tr(\"(*.v *.sv)\"));\n    if (targetPath.size() < 1)\n    {\n        return;\n    }\n\n    setTargetPath(targetPath);\n}\n\n//-----------------------------------------------------------------------------\n// Function: ImportInstancesEditor::getCurrentPath()\n//-----------------------------------------------------------------------------\nQString ImportInstancesEditor::getCurrentPath() const\n{\n    QString currentPath = selectedItem_->data(Qt::DisplayRole).toString();\n    if (currentPath.size() < 1)\n    {\n        currentPath = defaultPath_;\n    }\n\n    return currentPath;\n}\n\n//-----------------------------------------------------------------------------\n// Function: ImportInstancesEditor::setTargetPath()\n//-----------------------------------------------------------------------------\nvoid ImportInstancesEditor::setTargetPath(QString const& targetPath)\n{\n    QString targetDirectory = QFileInfo(targetPath).absolutePath();\n\n    if (targetDirectory.size() < 1)\n    {\n        targetDirectory = \".\";\n    }\n\n    onCheckForNewLibraryLocation(targetDirectory);\n\n    selectedItem_->setText(targetPath);\n    selectedItem_->setToolTip(targetPath);\n    selectedItem_ = nullptr;\n}\n\n//-----------------------------------------------------------------------------\n// Function: ImportInstancesEditor::onCheckForNewLibraryLocation()\n//-----------------------------------------------------------------------------\nvoid ImportInstancesEditor::onCheckForNewLibraryLocation(QString const& newPath)\n{\n    QSettings settings(this);\n    while (!pathExistsInActiveLibraries(newPath))\n    {\n        QMessageBox warningDialog(QMessageBox::Warning, \"Warning\",\n            \"Chosen path is not in any active library. Do you want to configure libraries?\",\n            QMessageBox::Yes | QMessageBox::Cancel, this);\n\n        warningDialog.setDetailedText(\n            newPath + \"\\nis not in any of the active libraries:\\n\" + libraryLocations_.join(\"\\n\"));\n\n        if (warningDialog.exec() == QMessageBox::Yes)\n        {\n            LibrarySettingsDialog dialog(settings, this);\n            dialog.exec();\n            setActiveLibraryLocations(settings);\n        }\n        else //if( msg == QMessageBox::Cancel )\n        {\n            return;\n        }\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: ImportInstancesEditor::onChangeIndexItemTooltip()\n//-----------------------------------------------------------------------------\nvoid ImportInstancesEditor::onChangeIndexItemTooltip(QModelIndex const& index, QString const& newText)\n{\n    QTableWidgetItem* indexedItem = item(index.row(), index.column());\n    indexedItem->setToolTip(newText);\n}\n\n//-----------------------------------------------------------------------------\n// Function: ImportInstancesEditor::onBrowseXMLFile()\n//-----------------------------------------------------------------------------\nvoid ImportInstancesEditor::onBrowseXMLFile()\n{\n    QString currentPath = getCurrentPath();\n\n    QString targetPath = QFileDialog::getSaveFileName(NULL, tr(\"Save the XML to...\"),\n        currentPath, tr(\"(*.xml)\"));\n\n    if (targetPath.size() < 1)\n    {\n        return;\n    }\n\n    setTargetPath(targetPath);\n}\n\n//-----------------------------------------------------------------------------\n// Function: ImportInstancesEditor::pathExistsInActiveLibraries()\n//-----------------------------------------------------------------------------\nbool ImportInstancesEditor::pathExistsInActiveLibraries(QString const& path) const\n{\n    //! Problem with folders like:\n    //! .../verilogTests/example.v\n    //! .../verilogTests2/example.v\n\n    for (auto const& libraryPath : libraryLocations_)\n    {\n        if (path.startsWith(libraryPath))\n        {\n            return true;\n        }\n    }\n\n    return false;\n}\n"
  },
  {
    "path": "wizards/ImportWizard/ImportInstancesEditor/ImportInstancesEditor.h",
    "content": "//-----------------------------------------------------------------------------\n// File: ImportInstancesEditor.h\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Mikko Teuho\n// Date: 02.04.2019\n//\n// Description:\n// Used to generate IP-XACT component instances from parsed source files.\n//-----------------------------------------------------------------------------\n\n#ifndef IMPORTINSTANCESEDITOR_H\n#define IMPORTINSTANCESEDITOR_H\n\n#include <wizards/ComponentWizard/InstanceData.h>\n\n#include <IPXACTmodels/common/VLNV.h>\n\n#include <QTableWidget>\n#include <QContextMenuEvent>\n#include <QAction>\n#include <QSettings>\n\nclass LibraryInterface;\nclass Component;\nclass File;\nclass ImportInstancesDelegate;\n\n//-----------------------------------------------------------------------------\n//! Used to generate IP-XACT component instances from parsed source files.\n//-----------------------------------------------------------------------------\nclass ImportInstancesEditor : public QTableWidget\n{\n\tQ_OBJECT\n\npublic:\n\n\t/*!\n\t *  The constructor.\n\t *\n\t *    @param [in] workingComponent    The importedComponent.\n\t *    @param [in] libraryAccess       The instance which manages the library.\n\t *    @param [in] parent              The owner of this widget.\n\t */\n    ImportInstancesEditor(QSharedPointer<Component> workingComponent, LibraryInterface* libraryAccess,\n        QWidget* parent);\n\n\t/*!\n     *  The destructor.\n     */\n    ~ImportInstancesEditor() = default;\n\n    /*!\n     *  Setup the imported component instances.\n     *\n     *    @param [in] newInstances    The new imported instances.\n     */\n    void setupInstances(QVector<InstanceData::instanceData> const& newInstances);\n\n    //! No copying. No assignment.\n    ImportInstancesEditor(const ImportInstancesEditor& other) = delete;\n    ImportInstancesEditor& operator=(const ImportInstancesEditor& other) = delete;\n\npublic slots:\n\n    /*!\n     *  Change the status of the indexed item.\n     *\n     *    @param [in] index       Index of the selected item.\n     *    @param [in] isEditable  New status for the selected item.\n     */\n    void changeItemEditableStatus(QModelIndex const& index, bool isEditable);\n\n    /*!\n     *  Check if the selected path is in a new library location.\n     *\n     *    @param [in] newPath     The selected path.\n     */\n    void onCheckForNewLibraryLocation(QString const& newPath);\n\n    /*!\n     *  Handle the tooltip change in the selected item.\n     *\n     *    @param [in] index       Index of the selected item.\n     *    @param [in] newText     New text for the selected item.\n     */\n    void onChangeIndexItemTooltip(QModelIndex const& index, QString const& newText);\n\nprotected:\n\n    /*!\n     *  The context menu handler.\n     *\n     *    @param [in] event   The context menu event.\n     */\n    virtual void contextMenuEvent(QContextMenuEvent* event);\n\nprivate slots:\n\n    /*!\n     *  Handle the browsing of an imported file.\n     */\n    void onBrowseImportFile();\n\n    /*!\n     *  Handle the browsing of an imported XML file.\n     */\n    void onBrowseXMLFile();\n\nprivate:\n\t\n    /*!\n     *  Create a table item for the instance name.\n     *\n     *    @param [in] instanceName    Name of the instance.\n     *    @param [in] instanceRow     Row of the instance.\n     */\n    void createInstanceNameItem(QString const& instanceName, int const& instanceRow);\n\n    /*!\n     *  Create table items for the import files of the instances.\n     *\n     *    @param [in] instances   List of imported instances.\n     */\n    void createInstancePathItems(QVector<InstanceData::instanceData> const& instances);\n\n    /*!\n     *  Get the possible file paths for the imported instances.\n     *\n     *    @param [in] instances   List of imported instances.\n     *\n     *    @return List of instance name file path pairs.\n     */\n    QMultiMap<QString, QString> getPossibleFilePaths(QVector<InstanceData::instanceData> const& instances) const;\n\n    /*!\n     *  Get the importable files of the selected component.\n     *\n     *    @param [in] component   The selected component.\n     *\n     *    @return List importable component files.\n     */\n    QVector<QSharedPointer<File> > getCompatibleComponentFiles(QSharedPointer<Component> component) const;\n\n    /*!\n     *  Read the selected file.\n     *\n     *    @param [in] relativePath    Relative path of the selected file.\n     *    @param [in] basePath        File path to the containing component.\n     *\n     *    @return The contents of the selected file.\n     */\n    QString readInputFile(QString const& relativePath, QString const& basePath) const;\n\n    /*!\n     *  Check if the selected file is a verilog file.\n     *\n     *    @param [in] file    The selected file.\n     *\n     *    @return True, if the selected file is verilog, false otherwise.\n     */\n    bool fileIsVerilogFile(QSharedPointer<File> file) const;\n\n    /*!\n     *  Create VLNV items for the selected component instances.\n     *\n     *    @param [in] instances   List of the selected component instances.\n     */\n    void createInstanceVLNVItems(QVector<InstanceData::instanceData> const& instances);\n\n    /*!\n     *  Check if the selected instance data matches ports of the selected component.\n     *\n     *    @param [in] instance    The selected instance data.\n     *    @param [in] component   The compared component.\n     *\n     *    @return True, if the instance data matches component ports, false otherwise.\n     */\n    bool instanceDataMatchesComponentPorts(InstanceData::instanceData const& instance,\n        QSharedPointer<const Component> component) const;\n\n    /*!\n     *  Get the component from the selected VLNV.\n     *\n     *    @param [in] componentVLNV   The selected VLNV.\n     *\n     *    @return Component matching the selected VLNV.\n     */\n    QSharedPointer<const Component> getComponentFromVLNV(VLNV const& componentVLNV) const;\n\n    /*!\n     *  Set the active library locations.\n     *\n     *    @param [in] settings    The settings.\n     */\n    void setActiveLibraryLocations(QSettings const& settings);\n\n    /*!\n     *  Check if the selected path exists in the active libraries.\n     *\n     *    @param [in] path    The selected path.\n     *\n     *    @return True, if the path exists in the active libraries, false otherwise.\n     */\n    bool pathExistsInActiveLibraries(QString const& path) const;\n\n    /*!\n     *  Get the path of the currently selected item.\n     *\n     *    @return The path of the currently selected item.\n     */\n    QString getCurrentPath() const;\n\n    /*!\n     *  Set a new path for the currently selected item.\n     *\n     *    @param [in] targetPath  The new path.\n     */\n    void setTargetPath(QString const& targetPath);\n\n    //-----------------------------------------------------------------------------\n    //! Data.\n    //-----------------------------------------------------------------------------\n\n    //! The imported component.\n    QSharedPointer<Component> workingComponent_;\n\n    //! Default library path.\n    QString defaultPath_;\n\n    //! Delegate for the editors.\n    ImportInstancesDelegate* instanceDelegate_;\n\n    //! Interface to the library.\n    LibraryInterface* libraryAccess_;\n\n    //! Action for browsing XML files.\n    QAction browseXMLFileAction_;\n\n    //! Action for browsing import files.\n    QAction browseImportFileAction_;\n\n    //! The currently selected item.\n    QTableWidgetItem* selectedItem_;\n\n    //! Active library locations.\n    QStringList libraryLocations_;\n};\n\n#endif // IMPORTINSTANCESEDITOR_H\n"
  },
  {
    "path": "wizards/ImportWizard/ImportWizard.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ImportWizard.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Esko Pekkarinen\r\n// Date: 15.10.2014\r\n//\r\n// Description:\r\n// Wizard for component import.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"ImportWizard.h\"\r\n#include \"ImportWizardPages.h\"\r\n#include \"ImportWizardIntroPage.h\"\r\n#include \"ImportWizardImportPage.h\"\r\n\r\n#include <wizards/ComponentWizard/ComponentWizardConclusionPage.h>\r\n#include <wizards/ImportWizard/ImportWizardInstancesPage.h>\r\n\r\n#include <KactusAPI/include/BusInterfaceInterface.h>\r\n#include <KactusAPI/include/BusInterfaceInterfaceFactory.h>\r\n#include <KactusAPI/include/MultipleParameterFinder.h>\r\n#include <KactusAPI/include/ExpressionFormatter.h>\r\n#include <KactusAPI/include/IPXactSystemVerilogParser.h>\r\n\r\n#include <IPXACTmodels/Component/Component.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ImportWizard::ImportWizard()\r\n//-----------------------------------------------------------------------------\r\nImportWizard::ImportWizard(QSharedPointer<Component> component, LibraryInterface* handler, QWidget* parent):\r\nQWizard(parent),\r\nworkingComponent_(new Component(*component)),\r\nupdatingFinder_(new ComponentParameterFinder(workingComponent_)),\r\nreferenceCounter_(new ParameterReferenceCounter(updatingFinder_))\r\n{\r\n    QSharedPointer<MultipleParameterFinder> multiFinder(new MultipleParameterFinder());\r\n    QSharedPointer<ParameterFinder> notImportedFinder(new ComponentParameterFinder(workingComponent_));\r\n    multiFinder->addFinder(notImportedFinder);\r\n    multiFinder->addFinder(updatingFinder_);\r\n\r\n    setPixmap(QWizard::LogoPixmap, QPixmap(\":icons/common/graphics/import.png\"));\r\n\tsetWindowTitle(tr(\"Import Wizard for %1\").arg(component->getVlnv().toString()));\r\n    setWizardStyle(ModernStyle);\r\n    resize(800, 1000);\r\n\r\n    setOption(NoBackButtonOnStartPage, true);\r\n    setOption(HaveFinishButtonOnEarlyPages, false);\r\n\r\n    QSharedPointer<ExpressionFormatter> singleExpressionFormatter(new ExpressionFormatter(updatingFinder_));\r\n    QSharedPointer<ExpressionFormatter> multipleExpressionFormatter(new ExpressionFormatter(multiFinder));\r\n\r\n    QSharedPointer<ExpressionParser> parser(new IPXactSystemVerilogParser(multiFinder));\r\n\r\n    BusInterfaceInterface* busInterface = BusInterfaceInterfaceFactory::createBusInterface(\r\n        multiFinder, multipleExpressionFormatter, parser, component, handler);\r\n\r\n    ImportWizardImportPage* importPage = new ImportWizardImportPage(workingComponent_, handler, \r\n        updatingFinder_, singleExpressionFormatter, busInterface, this);\r\n\r\n    ImportWizardInstancesPage* importInstancesPage =\r\n        new ImportWizardInstancesPage(workingComponent_, handler, this);\r\n\r\n    ComponentWizardConclusionPage* finalPage = new ComponentWizardConclusionPage(workingComponent_, handler,\r\n        multipleExpressionFormatter, this);\r\n\r\n    setPage(ImportWizardPages::INTRO, new ImportWizardIntroPage(this));\r\n    setPage(ImportWizardPages::IMPORT, importPage);\r\n    setPage(ImportWizardPages::INSTANCES, importInstancesPage);\r\n    setPage(ImportWizardPages::CONCLUSION, finalPage);\r\n\r\n    connect(importPage, SIGNAL(componentChanged(QSharedPointer<Component>)), \r\n        this, SLOT(onComponentChanged(QSharedPointer<Component>)), Qt::UniqueConnection);\r\n    connect(importPage, SIGNAL(componentChanged(QSharedPointer<Component>)), \r\n        finalPage, SLOT(onComponentChanged(QSharedPointer<Component>)), Qt::UniqueConnection);\r\n\r\n    connect(importPage, SIGNAL(increaseReferences(QString)),\r\n        referenceCounter_.data(), SLOT(increaseReferenceCount(QString)), Qt::UniqueConnection);\r\n    connect(importPage, SIGNAL(decreaseReferences(QString)),\r\n        referenceCounter_.data(), SLOT(decreaseReferenceCount(QString)), Qt::UniqueConnection);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ImportWizard::~ImportWizard()\r\n//-----------------------------------------------------------------------------\r\nImportWizard::~ImportWizard()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ImportWizard::getComponent()\r\n//-----------------------------------------------------------------------------\r\nQSharedPointer<Component> ImportWizard::getComponent()\r\n{\r\n    return workingComponent_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ImportWizard::onComponentChanged()\r\n//-----------------------------------------------------------------------------\r\nvoid ImportWizard::onComponentChanged(QSharedPointer<Component> component)\r\n{\r\n    workingComponent_ = component;\r\n    updatingFinder_->setComponent(workingComponent_);\r\n}\r\n"
  },
  {
    "path": "wizards/ImportWizard/ImportWizard.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ImportWizard.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Esko Pekkarinen\r\n// Date: 15.10.2014\r\n//\r\n// Description:\r\n// Wizard for component import.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef IMPORTWIZARD_H\r\n#define IMPORTWIZARD_H\r\n\r\n#include <KactusAPI/include/ComponentParameterFinder.h>\r\n#include <editors/ComponentEditor/referenceCounter/ParameterReferenceCounter.h>\r\n\r\n#include <QWizard>\r\n#include <QSharedPointer>\r\n\r\nclass Component;\r\nclass LibraryInterface;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Component wizard dialog.\r\n//-----------------------------------------------------------------------------\r\nclass ImportWizard : public QWizard\r\n{\r\n    Q_OBJECT\r\n\r\npublic:\r\n \r\n    /*!\r\n     *  Constructor.\r\n     *\r\n     *    @param [in] component  The component for which the wizard is run.\r\n     *    @param [in] handler\t   The library handle.\r\n     *    @param [in] parent     The parent widget.\r\n     */\r\n    ImportWizard(QSharedPointer<Component> component, LibraryInterface* handler, QWidget* parent);\r\n\r\n    /*!\r\n     *  The destructor.\r\n     */\r\n    ~ImportWizard();\r\n\r\n    /*!\r\n     *  Returns the component after import modifications.\r\n     */\r\n    QSharedPointer<Component> getComponent();\r\n\r\nprivate slots:\r\n\r\n    /*!\r\n     *  Called when a new component has been imported.\r\n     *\r\n     *    @param [in] component   The newly imported component.\r\n     */\r\n    virtual void onComponentChanged(QSharedPointer<Component> component);\r\n\r\nprivate:\r\n    // Disable copying.\r\n    ImportWizard(ImportWizard const& rhs);\r\n    ImportWizard& operator=(ImportWizard const& rhs);\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! The working copy of a component after import.\r\n    QSharedPointer<Component> workingComponent_;\r\n\r\n    //! Parameter finder, finds the desired parameters.\r\n    QSharedPointer <ComponentParameterFinder> updatingFinder_;\r\n\r\n    //! The counter that changes the amount of references to parameters.\r\n    QSharedPointer<ReferenceCounter> referenceCounter_;\r\n};\r\n\r\n#endif // ImportWizard_H\r\n"
  },
  {
    "path": "wizards/ImportWizard/ImportWizardImportPage.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ImportWizardImportPage.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Esko Pekkarinen\r\n// Date: 15.10.2014\r\n//\r\n// Description:\r\n// Import wizard page for importing elements from a file.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"ImportWizardImportPage.h\"\r\n#include \"ImportWizardPages.h\"\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ImportWizardImportPage::ImportWizardImportPage()\r\n//-----------------------------------------------------------------------------\r\nImportWizardImportPage::ImportWizardImportPage(QSharedPointer<Component> component, LibraryInterface* handler,\r\n    QSharedPointer<ComponentParameterFinder> parameterFinder,\r\n    QSharedPointer<ExpressionFormatter> expressionFormatter, BusInterfaceInterface* busInterface, QWidget* parent):\r\nComponentWizardImportPage(component, handler, parameterFinder, expressionFormatter, busInterface, parent)\r\n{\r\n    setFinalPage(false);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ImportWizardImportPage::~ImportWizardImportPage()\r\n//-----------------------------------------------------------------------------\r\nImportWizardImportPage::~ImportWizardImportPage()\r\n{\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ImportWizardImportPage::nextId()\r\n//-----------------------------------------------------------------------------\r\nint ImportWizardImportPage::nextId() const\r\n{\r\n    return ImportWizardPages::INSTANCES;\r\n}\r\n"
  },
  {
    "path": "wizards/ImportWizard/ImportWizardImportPage.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ImportWizardImportPage.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Esko Pekkarinen\r\n// Date: 15.10.2014\r\n//\r\n// Description:\r\n// Import wizard page for importing elements from a file.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef ImportWizardVHDLIMPORTPAGE_H\r\n#define ImportWizardVHDLIMPORTPAGE_H\r\n\r\n#include <wizards/ComponentWizard/ComponentWizardImportPage.h>\r\n\r\n#include <KactusAPI/include/ParameterFinder.h>\r\n#include <KactusAPI/include/ExpressionFormatter.h>\r\n\r\n#include <QWizardPage>\r\n#include <QSharedPointer>\r\n\r\nclass Component;\r\nclass LibraryInterface;\r\nclass ImportEditor;\r\nclass BusInterfaceInterface;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Import wizard page for importing elements from a file.\r\n//-----------------------------------------------------------------------------\r\nclass ImportWizardImportPage : public ComponentWizardImportPage\r\n{\r\n    Q_OBJECT\r\npublic:\r\n    /*!\r\n     *  The Constructor.\r\n     *\r\n     *    @param [in] component               Pointer to the component to import to.\r\n     *    @param [in] handler                 The library handle.\r\n     *    @param [in] parameterFinder         The parameter finder.\r\n     *    @param [in] expressionFormatter     The expression formatter.\r\n     *    @param [in] busInterface            Interface for accessing bus interfaces.\r\n     *    @param [in] parent                  The parent wizard.\r\n     */\r\n    ImportWizardImportPage(QSharedPointer<Component> component,\r\n        LibraryInterface* handler,\r\n        QSharedPointer <ComponentParameterFinder> parameterFinder,\r\n        QSharedPointer<ExpressionFormatter> expressionFormatter,\r\n        BusInterfaceInterface* busInterface,\r\n        QWidget* parent);\r\n\r\n    //! The destructor.\r\n    ~ImportWizardImportPage();\r\n\r\n    //!  Returns the ID of the next page.\r\n    virtual int nextId() const;\r\n\r\nprivate:\r\n\t// Disable copying.\r\n\tImportWizardImportPage(ImportWizardImportPage const& rhs);\r\n\tImportWizardImportPage& operator=(ImportWizardImportPage const& rhs);\r\n\r\n};\r\n\r\n#endif // ImportWizardVHDLIMPORTPAGE_H\r\n"
  },
  {
    "path": "wizards/ImportWizard/ImportWizardInstancesPage.cpp",
    "content": "//-----------------------------------------------------------------------------\n// File: ImportWizardInstancesPage.cpp\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Mikko Teuho\n// Date: 02.04.2019\n//\n// Description:\n// Import wizard page for importing instance elements from a file.\n//-----------------------------------------------------------------------------\n\n#include \"ImportWizardInstancesPage.h\"\n\n#include <wizards/ComponentWizard/InstanceData.h>\n#include <wizards/ImportWizard/ImportWizardPages.h>\n#include <wizards/ImportWizard/ImportInstancesEditor/ImportInstancesEditor.h>\n\n#include <QVBoxLayout>\n\n//-----------------------------------------------------------------------------\n// Function: ImportWizardInstancesPage::ImportWizardInstancesPage()\n//-----------------------------------------------------------------------------\nImportWizardInstancesPage::ImportWizardInstancesPage(QSharedPointer<Component> workingComponent,\n    LibraryInterface* libraryAccess, QWidget* parent):\nQWizardPage(parent),\neditor_(new ImportInstancesEditor(workingComponent, libraryAccess, this))\n{\n    setTitle(tr(\"Design from the imported source file\"));\n    setSubTitle(tr(\"Finds the implemented component instances in the imported source file.\"));\n    setFinalPage(false);\n\n    QVBoxLayout* pageLayout = new QVBoxLayout(this);\n    pageLayout->addWidget(editor_);\n}\n\n//-----------------------------------------------------------------------------\n// Function: ImportWizardInstancesPage::initializePage()\n//-----------------------------------------------------------------------------\nvoid ImportWizardInstancesPage::initializePage()\n{\n    QWizardPage::initializePage();\n\n    QVariant instancesVariant = field(InstanceData::VERILOGINSTANCES);\n    if (instancesVariant.canConvert<QVector<InstanceData::instanceData> >())\n    {\n        QVector<InstanceData::instanceData> instances =\n            instancesVariant.value<QVector<InstanceData::instanceData> >();\n\n        editor_->setupInstances(instances);\n    }\n}\n\n//-----------------------------------------------------------------------------\n// Function: ImportWizardInstancesPage::nextId()\n//-----------------------------------------------------------------------------\nint ImportWizardInstancesPage::nextId() const\n{\n    return ImportWizardPages::CONCLUSION;\n}\n"
  },
  {
    "path": "wizards/ImportWizard/ImportWizardInstancesPage.h",
    "content": "//-----------------------------------------------------------------------------\n// File: ImportWizardInstancesPage.h\n//-----------------------------------------------------------------------------\n// Project: Kactus 2\n// Author: Mikko Teuho\n// Date: 02.04.2019\n//\n// Description:\n// Import wizard page for importing instance elements from a file.\n//-----------------------------------------------------------------------------\n\n#ifndef IMPORTWIZARDINSTANCESPAGE_H\n#define IMPORTWIZARDINSTANCESPAGE_H\n\n#include <QWizardPage>\n\nclass Component;\nclass ImportInstancesEditor;\nclass LibraryInterface;\n\n//-----------------------------------------------------------------------------\n//! Import wizard page for importing instance elements from a file.\n//-----------------------------------------------------------------------------\nclass ImportWizardInstancesPage : public QWizardPage\n{\n    Q_OBJECT\npublic:\n\n    /*!\n     *  The Constructor.\n     *\n     *    @param [in] workingComponent    Pointer to the component to import to.\n     *    @param [in] libraryAccess       The library handle.\n     *    @param [in] parent              The parent wizard.\n     */\n    ImportWizardInstancesPage(QSharedPointer<Component> workingComponent, LibraryInterface* libraryAccess,\n        QWidget* parent);\n\n    /*!\n     *  The destructor.\n     */\n    ~ImportWizardInstancesPage() = default;\n\n    /*!\n     *  Initialize the page.\n     */\n    virtual void initializePage();\n\n    /*!\n     *  Returns the ID of the next page.\n     */\n    virtual int nextId() const;\n\n    // Disable copying.\n    ImportWizardInstancesPage(ImportWizardInstancesPage const& rhs) = delete;\n    ImportWizardInstancesPage& operator=(ImportWizardInstancesPage const& rhs) = delete;\n\nprivate:\n\n    //! Editor for import instances.\n    ImportInstancesEditor* editor_;\n};\n\n#endif // IMPORTWIZARDINSTANCESPAGE_H\n"
  },
  {
    "path": "wizards/ImportWizard/ImportWizardIntroPage.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ImportWizardIntroPage.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Esko Pekkarinen\r\n// Date: 27.10.2014\r\n//\r\n// Description:\r\n// Intro page for the import wizard.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"ImportWizardIntroPage.h\"\r\n\r\n#include \"ImportWizardPages.h\"\r\n\r\n#include <QVBoxLayout>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ImportWizardIntroPage::ImportWizardIntroPage()\r\n//-----------------------------------------------------------------------------\r\nImportWizardIntroPage::ImportWizardIntroPage(QWidget* parent)\r\n    : QWizardPage(parent),\r\n      infoLabel_(this)\r\n{\r\n    setTitle(tr(\"Introduction\"));\r\n    setSubTitle(tr(\"This wizard will guide you through the steps of importing file contents to a component.\"));\r\n\r\n    QString infoText = tr(\"This wizard contains the following steps:\");    \r\n    infoText += \"<ul><li>\" + tr(\"Import elements from file.\");\r\n    infoText += \"<li>\" + tr(\"Summary\") + \"</ul>\";\r\n\r\n    infoLabel_.setText(infoText);\r\n    infoLabel_.setWordWrap(true);\r\n\r\n    QVBoxLayout* layout = new QVBoxLayout(this);\r\n    layout->addWidget(&infoLabel_);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ImportWizardIntroPage::~ImportWizardIntroPage()\r\n//-----------------------------------------------------------------------------\r\nImportWizardIntroPage::~ImportWizardIntroPage()\r\n{\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ImportWizardIntroPage::nextId()\r\n//-----------------------------------------------------------------------------\r\nint ImportWizardIntroPage::nextId() const\r\n{\r\n    return ImportWizardPages::IMPORT;\r\n}\r\n"
  },
  {
    "path": "wizards/ImportWizard/ImportWizardIntroPage.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ImportWizardIntroPage.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Esko Pekkarinen\r\n// Date: 27.10.2014\r\n//\r\n// Description:\r\n// Intro page for the import wizard.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef COMPONENTWIZARDINTROPAGE_H\r\n#define COMPONENTWIZARDINTROPAGE_H\r\n\r\n#include <QWizardPage>\r\n#include <QLabel>\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Intro page for the import wizard.\r\n//-----------------------------------------------------------------------------\r\nclass ImportWizardIntroPage : public QWizardPage\r\n{\r\npublic:\r\n    /*!\r\n     *  Constructor.\r\n     *\r\n     *    @param [in] parent          The parent widget.\r\n     */\r\n    ImportWizardIntroPage(QWidget* parent);\r\n\r\n    /*!\r\n     *  Destructor.\r\n     */\r\n    ~ImportWizardIntroPage();\r\n\r\n    /*!\r\n     *  Returns the ID of the next page.\r\n     */\r\n    virtual int nextId() const;\r\n\r\nprivate:\r\n    // Disable copying.\r\n    ImportWizardIntroPage(ImportWizardIntroPage const& rhs);\r\n    ImportWizardIntroPage& operator=(ImportWizardIntroPage const& rhs);\r\n\r\n    //-----------------------------------------------------------------------------\r\n    // Data.\r\n    //-----------------------------------------------------------------------------\r\n\r\n    //! The label for information.\r\n    QLabel infoLabel_;\r\n};\r\n\r\n#endif // COMPONENTWIZARDINTROPAGE_H\r\n"
  },
  {
    "path": "wizards/ImportWizard/ImportWizardPages.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ImportWizardPages.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Esko Pekkarinen\r\n// Date: 15.10.2014\r\n//\r\n// Description:\r\n// Import wizard page enumerations.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef IMPORTWIZARDPAGES_H\r\n#define IMPORTWIZARDPAGES_H\r\n\r\n\r\nnamespace ImportWizardPages\r\n{\r\n    //! Enumeration for component wizard pages.\r\n    enum Page\r\n    {\r\n        INTRO = 0,\r\n        IMPORT,\r\n        INSTANCES,\r\n        CONCLUSION\r\n\t };\r\n\r\n};\r\n\r\n#endif // IMPORTWIZARDPAGES_H\r\n"
  },
  {
    "path": "wizards/common/ComponentComparator/ComponentComparator.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ComponentComparator.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Esko Pekkarinen\r\n// Date: 16.10.2014\r\n//\r\n// Description:\r\n// Comparator for finding differences in components.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"ComponentComparator.h\"\r\n#include <wizards/common/VLNVComparator/VLNVComparator.h>\r\n#include <wizards/common/ParameterComparator/ParameterComparator.h>\r\n#include <wizards/common/PortComparator/PortComparator.h>\r\n#include <wizards/common/ViewComparator/ViewComparator.h>\r\n\r\n#include <IPXACTmodels/Component/Component.h>\r\n#include <IPXACTmodels/common/VLNV.h>\r\n#include <IPXACTmodels/Component/Port.h>\r\n#include <IPXACTmodels/Component/View.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentComparator::ComponentComparator()\r\n//-----------------------------------------------------------------------------\r\nComponentComparator::ComponentComparator()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentComparator::~ComponentComparator()\r\n//-----------------------------------------------------------------------------\r\nComponentComparator::~ComponentComparator()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentComparator::diff()\r\n//-----------------------------------------------------------------------------\r\nQList<QSharedPointer<IPXactDiff> > ComponentComparator::diff(QSharedPointer<const Component> reference, \r\n    QSharedPointer<const Component> subject) const\r\n{\r\n    return IPXactElementComparator::diff(reference, subject);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentComparator::compareVLNVs()\r\n//-----------------------------------------------------------------------------\r\nbool ComponentComparator::compareVLNVs(QSharedPointer<const Component> referenceComponent,\r\n    QSharedPointer<const Component> subjectComponent) const\r\n{   \r\n    QSharedPointer<VLNV> referenceVLNV(new VLNV(referenceComponent->getVlnv()));\r\n    QSharedPointer<VLNV> subjectVLNV(new VLNV(subjectComponent->getVlnv()));\r\n\r\n    VLNVComparator vlnvComparator;\r\n    return vlnvComparator.compare(referenceVLNV, subjectVLNV);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentComparator::compareParameters()\r\n//-----------------------------------------------------------------------------\r\nbool ComponentComparator::compareParameters(QSharedPointer<const Component> referenceComponent, \r\n    QSharedPointer<const Component> subjectComponent) const\r\n{\r\n    ParameterComparator parameterComparator;\r\n    return parameterComparator.compare(*referenceComponent->getParameters(), *subjectComponent->getParameters());\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentComparator::comparePorts()\r\n//-----------------------------------------------------------------------------\r\nbool ComponentComparator::comparePorts(QSharedPointer<const Component> first, \r\n    QSharedPointer<const Component> second) const\r\n{\r\n    PortComparator portComparator;\r\n    return portComparator.compare(*first->getPorts().data(), *second->getPorts().data());\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentComparator::compareViews()\r\n//-----------------------------------------------------------------------------\r\nbool ComponentComparator::compareViews(QSharedPointer<const Component> first,\r\n    QSharedPointer<const Component> second) const\r\n{\r\n    ViewComparator viewComparator;\r\n    return viewComparator.compare(*first->getViews().data(), *second->getViews().data());\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentComparator::elementType()\r\n//-----------------------------------------------------------------------------\r\nQString ComponentComparator::elementType() const\r\n{\r\n    return QObject::tr(\"component\");\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentComparator::compareFields()\r\n//-----------------------------------------------------------------------------\r\nbool ComponentComparator::compareFields(QSharedPointer<const Component> first,\r\n    QSharedPointer<const Component> second) const\r\n{\r\n    return compareVLNVs(first, second) &&\r\n        comparePorts(first, second) &&\r\n        compareViews(first, second);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentComparator::diffFields()\r\n//-----------------------------------------------------------------------------\r\nQList<QSharedPointer<IPXactDiff> > ComponentComparator::diffFields(QSharedPointer<const Component> reference, \r\n    QSharedPointer<const Component> subject) const\r\n{\r\n    QList<QSharedPointer<IPXactDiff> > diffResult;\r\n\r\n    if (!compareVLNVs(reference, subject))\r\n    {\r\n        VLNVComparator vlnvComparator;\r\n        QSharedPointer<VLNV> referenceVLNV(new VLNV(reference->getVlnv()));\r\n        QSharedPointer<VLNV> otherVLNV(new VLNV(subject->getVlnv()));\r\n        diffResult.append(vlnvComparator.diff(referenceVLNV, otherVLNV));\r\n    }\r\n\r\n    if (!compareParameters(reference, subject))\r\n    {\r\n        ParameterComparator parameterComparator;\r\n        diffResult.append(parameterComparator.diff(*reference->getParameters(), *subject->getParameters()));\r\n    }\r\n\r\n    if (!comparePorts(reference, subject))\r\n    {\r\n        PortComparator portComparator;\r\n        diffResult.append(portComparator.diff(*reference->getPorts().data(), *subject->getPorts().data()));\r\n    }\r\n\r\n    if (!compareViews(reference, subject))\r\n    {\r\n        ViewComparator viewComparator;\r\n        diffResult.append(viewComparator.diff(*reference->getViews().data(), *subject->getViews().data()));\r\n    }\r\n\r\n    return diffResult;\r\n}\r\n"
  },
  {
    "path": "wizards/common/ComponentComparator/ComponentComparator.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ComponentComparator.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Esko Pekkarinen\r\n// Date: 16.10.2014\r\n//\r\n// Description:\r\n// Comparator for finding differences in components.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef COMPONENTCOMPARATOR_H\r\n#define COMPONENTCOMPARATOR_H\r\n\r\n#include <wizards/common/IPXactDiff.h>\r\n#include <wizards/common/IPXactElementComparator.h>\r\n\r\n#include <QSharedPointer>\r\n\r\nclass Component;\r\nclass ModelParameter;\r\nclass Parameter;\r\nclass VLNV;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Comparator for finding differences in components.\r\n//-----------------------------------------------------------------------------\r\nclass ComponentComparator : public IPXactElementComparator<Component>\r\n{\r\npublic:\r\n\r\n\t//! The constructor.\r\n\tComponentComparator();\r\n\r\n\t//! The destructor.\r\n\t~ComponentComparator();\r\n\r\n    /*!\r\n     *  Compares the sub-elements of two components.\r\n     *\r\n     *    @param [in] first    The first components.\r\n     *    @param [in] second   The second components.\r\n     *\r\n     *    @return True, if the sub-elements are similar, otherwise false.\r\n     */\r\n    bool compareFields(QSharedPointer<const Component> first, QSharedPointer<const Component> second) const;\r\n\r\n    /*!\r\n     *  Finds the differences between the two given components.\r\n     *\r\n     *    @param [in] reference   The component to compare to.\r\n     *    @param [in] subject     The component to compare against the reference.\r\n     *\r\n     *    @return Set of differences between the reference and subject.\r\n     */\r\n    virtual QList<QSharedPointer<IPXactDiff> > diff(QSharedPointer<const Component> reference,\r\n        QSharedPointer<const Component> subject) const;\r\n    \r\n    /*!\r\n     *  Finds the differences between the sub-elements of two given elements.\r\n     *\r\n     *    @param [in] reference   The reference element to compare to.\r\n     *    @param [in] subject     The element to compare against the reference.\r\n     *\r\n     *    @return Set of differences between the sub-elements of reference and subject.\r\n     */\r\n    QList<QSharedPointer<IPXactDiff> > diffFields(QSharedPointer<const Component> reference, \r\n        QSharedPointer<const Component> subject) const;\r\n    \r\n    /*!\r\n     *  Returns the type for the element.\r\n     *\r\n     *    @return The element type.\r\n     */\r\n    virtual QString elementType() const;\r\n\r\nprivate:\r\n\r\n\t// Disable copying.\r\n\tComponentComparator(ComponentComparator const& rhs);\r\n\tComponentComparator& operator=(ComponentComparator const& rhs);\r\n\r\n    /*!\r\n     *  Compares the VLNVs in the given components.\r\n     *\r\n     *    @param [in] referenceComponent  The reference component to compare to.\r\n     *    @param [in] subjectComponent    The subject component to compare against the reference.\r\n     *\r\n     *    @return True, if the VLVNs are similar, otherwise false.\r\n     */\r\n    bool compareVLNVs(QSharedPointer<const Component> referenceComponent, \r\n        QSharedPointer<const Component> subjectComponent) const;\r\n\r\n    /*!\r\n     *  Compares the parameters in the given components.\r\n     *\r\n     *    @param [in] referenceComponent  The reference component to compare to.\r\n     *    @param [in] subjectComponent    The subject component to compare against the reference.\r\n     *\r\n     *    @return True, if the parameters are similar, otherwise false.\r\n     */  \r\n    bool compareParameters(QSharedPointer<const Component> referenceComponent, \r\n        QSharedPointer<const Component> subjectComponent) const;\r\n    \r\n    /*!\r\n     *  Compares the ports in the given components.\r\n     *\r\n     *    @param [in] referenceComponent  The reference component to compare to.\r\n     *    @param [in] subjectComponent    The subject component to compare against the reference.\r\n     *\r\n     *    @return True, if the ports are similar, otherwise false.\r\n     */  \r\n    bool comparePorts(QSharedPointer<const Component> first, QSharedPointer<const Component>second) const;\r\n    \r\n    /*!\r\n     *  Compares the views in the given components.\r\n     *\r\n     *    @param [in] referenceComponent  The reference component to compare to.\r\n     *    @param [in] subjectComponent    The subject component to compare against the reference.\r\n     *\r\n     *    @return True, if the views are similar, otherwise false.\r\n     */  \r\n    bool compareViews(QSharedPointer<const Component> first, QSharedPointer<const Component> second) const;\r\n};\r\n\r\n#endif // COMPONENTCOMPARATOR_H\r\n"
  },
  {
    "path": "wizards/common/ComponentDiffWidget/ComponentDiffWidget.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ComponentDiffWidget.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Esko Pekkarinen\r\n// Date: 17.10.2014\r\n//\r\n// Description:\r\n// Tree widget for displaying differences of two components.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"ComponentDiffWidget.h\"\r\n\r\n#include <IPXACTmodels/Component/Component.h>\r\n\r\n#include <common/KactusColors.h>\r\n\r\n#include <wizards/common/ComponentComparator/ComponentComparator.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentDiffWidget::ComponentDiffWidget()\r\n//-----------------------------------------------------------------------------\r\nComponentDiffWidget::ComponentDiffWidget(QSharedPointer<ExpressionFormatter> expressionFormatter, QWidget *parent)\r\n    : QTreeWidget (parent),\r\n      expressionFormatter_(expressionFormatter)\r\n{\r\n    QStringList labels;\r\n    labels << \"Name\" << \"Changed element\" << \"Previous value\" << \"Updated value\";\r\n    setHeaderLabels(labels);\r\n\r\n    setColumnCount(labels.count());    \r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentDiffWidget::~ComponentDiffWidget()\r\n//-----------------------------------------------------------------------------\r\nComponentDiffWidget::~ComponentDiffWidget()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentDiffWidget::setComponents()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentDiffWidget::setComponents(QSharedPointer<const Component> reference, \r\n    QSharedPointer<const Component> subject)\r\n{\r\n    clear();\r\n\r\n    ComponentComparator comparator;\r\n    QList<QSharedPointer<IPXactDiff> > diffs = comparator.diff(reference, subject);\r\n\r\n    if (nothingChanged(diffs))\r\n    {\r\n        return;\r\n    }\r\n\r\n    QMap<QString, QTreeWidgetItem*> topItems = createTopLevelItems(diffs);\r\n\r\n    foreach(QSharedPointer<IPXactDiff> diff, diffs)\r\n    {\r\n        QTreeWidgetItem* parentItem = topItems.value(diff->element());\r\n\r\n        if (diff->changeType() == IPXactDiff::ADD)\r\n        {    \r\n            addAddItem(diff->name(), parentItem);\r\n        }\r\n        else if (diff->changeType() == IPXactDiff::REMOVE)\r\n        {    \r\n            addRemoveItem(diff->name(), parentItem);\r\n        }\r\n        else if (diff->changeType() == IPXactDiff::MODIFICATION)\r\n        {              \r\n            addModificationItem(diff, parentItem);\r\n        }\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentDiffWidget::nothingChanged()\r\n//-----------------------------------------------------------------------------\r\nbool ComponentDiffWidget::nothingChanged(QList<QSharedPointer<IPXactDiff> > const& diffs)\r\n{\r\n    return diffs.count() == 1 && diffs.first()->changeType() == IPXactDiff::NO_CHANGE;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentDiffWidget::createTopLevelItems()\r\n//-----------------------------------------------------------------------------\r\nQMap<QString, QTreeWidgetItem*> ComponentDiffWidget::createTopLevelItems(QList<QSharedPointer<IPXactDiff> > const& diffs)\r\n{\r\n    QMap<QString, QTreeWidgetItem*> topItems;\r\n\r\n    QStringList topElements;\r\n    topElements << \"view\" << \"model parameter\" << \"port\" << \"parameter\";\r\n\r\n    foreach(QSharedPointer<IPXactDiff> diff, diffs)\r\n    {\r\n        if (topElements.contains(diff->element()) && !topItems.contains(diff->element()))\r\n        {\r\n            topItems.insert(diff->element(), createTopLevelItemForElement(diff->element()));\r\n        }\r\n    }\r\n\r\n    return topItems;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentDiffWidget::createTopLevelItemForElement()\r\n//-----------------------------------------------------------------------------\r\nQTreeWidgetItem* ComponentDiffWidget::createTopLevelItemForElement(QString const& elementName)\r\n{\r\n    QTreeWidgetItem* item = new QTreeWidgetItem();\r\n    QString containerName = elementName.at(0).toUpper() + elementName.mid(1) + \"s\";\r\n    item->setText(ITEM_NAME, containerName);\r\n\r\n    for (int i = 0; i < COLUMN_COUNT; i++)\r\n    {\r\n        item->setBackground(i, KactusColors::STRONG_FIELD);\r\n    }            \r\n    addTopLevelItem(item);\r\n    return item;        \r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentDiffWidget::createAddItem()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentDiffWidget::addAddItem(QString const& name, QTreeWidgetItem* parent)\r\n{\r\n    QTreeWidgetItem* addItem = new QTreeWidgetItem(parent);\r\n    addItem->setText(ITEM_NAME, name);\r\n    addItem->setIcon(ITEM_NAME, QIcon(\":/icons/common/graphics/add.png\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentDiffWidget::createRemoveItem()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentDiffWidget::addRemoveItem(QString const& name, QTreeWidgetItem* parent)\r\n{\r\n    QTreeWidgetItem* removeItem = new QTreeWidgetItem(parent);\r\n    removeItem->setText(ITEM_NAME, name);\r\n    removeItem->setIcon(ITEM_NAME, QIcon(\":/icons/common/graphics/remove.png\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentDiffWidget::addModificationItem()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentDiffWidget::addModificationItem(QSharedPointer<IPXactDiff> diff, QTreeWidgetItem* parent)\r\n{\r\n    QList<IPXactDiff::Modification> changelist = diff->getChangeList();\r\n    if (changelist.size() == 1)\r\n    {                       \r\n        addSingleLevelModificationItem(diff->name(), changelist.first(), parent);\r\n    }\r\n    else\r\n    {\r\n        addMultiLevelModificationItem(diff->name(), changelist, parent);\r\n    }\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentDiffWidget::createSingleLevelModificationItem()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentDiffWidget::addSingleLevelModificationItem(QString const& name, \r\n    IPXactDiff::Modification const& modification, QTreeWidgetItem* parent)\r\n{\r\n    QTreeWidgetItem* modificationItem = createModificationItem(modification, parent);\r\n    modificationItem->setText(ITEM_NAME, name);  \r\n    modificationItem->setIcon(ITEM_NAME, QIcon(\":/icons/common/graphics/star.png\"));\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentDiffWidget::createModificationItem()\r\n//-----------------------------------------------------------------------------\r\nQTreeWidgetItem* ComponentDiffWidget::createModificationItem(IPXactDiff::Modification const& modification, \r\n    QTreeWidgetItem* parent) const\r\n{\r\n    QTreeWidgetItem* modificationItem = new QTreeWidgetItem(parent);\r\n    modificationItem->setText(CHANGE_ELEMENT, modification.modifiedElement);\r\n    modificationItem->setText(PREVIOUS_VALUE,\r\n        expressionFormatter_->formatReferringExpression(modification.previousValue));\r\n    modificationItem->setText(UPDATED_VALUE,\r\n        expressionFormatter_->formatReferringExpression(modification.newValue));\r\n\r\n    return modificationItem;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ComponentDiffWidget::createMultiLevelModificationItem()\r\n//-----------------------------------------------------------------------------\r\nvoid ComponentDiffWidget::addMultiLevelModificationItem(QString const& name, \r\n    QList<IPXactDiff::Modification> changelist, QTreeWidgetItem* parent)\r\n{\r\n    QTreeWidgetItem* child = new QTreeWidgetItem(parent);\r\n    child->setText(ITEM_NAME, name);  \r\n    child->setIcon(ITEM_NAME, QIcon(\":/icons/common/graphics/star.png\"));\r\n    child->setText(CHANGE_ELEMENT, \"[multiple changes]\");\r\n\r\n    foreach(IPXactDiff::Modification modification, changelist)\r\n    {\r\n        child->addChild(createModificationItem(modification, child));\r\n    }\r\n}\r\n"
  },
  {
    "path": "wizards/common/ComponentDiffWidget/ComponentDiffWidget.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ComponentDiffWidget.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Esko Pekkarinen\r\n// Date: 17.10.2014\r\n//\r\n// Description:\r\n// Tree widget for displaying differences of two components.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef COMPONENTDIFFWIDGET_H\r\n#define COMPONENTDIFFWIDGET_H\r\n\r\n#include <QTreeWidget>\r\n\r\n#include <wizards/common/IPXactDiff.h>\r\n\r\n#include <KactusAPI/include/ExpressionFormatter.h>\r\n\r\nclass Component;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Tree widget for displaying differences of two components.\r\n//-----------------------------------------------------------------------------\r\nclass ComponentDiffWidget : public QTreeWidget \r\n{\r\n    Q_OBJECT\r\npublic:\r\n\r\n    //! Enumeration of the tree columns.\r\n    enum COLUMNS\r\n    {\r\n        ITEM_NAME = 0,\r\n        CHANGE_ELEMENT,\r\n        PREVIOUS_VALUE,\r\n        UPDATED_VALUE,\r\n        COLUMN_COUNT\r\n    };\r\n\r\n\t/*!\r\n\t *  The constructor.\r\n\t *\r\n\t *    @param [in] expressionFormatter     Pointer to the expression formatter.\r\n\t *    @param [in] parent                  Pointer to the parent item.\r\n\t */\r\n\tComponentDiffWidget(QSharedPointer <ExpressionFormatter> expressionFormatter, QWidget *parent);\r\n\r\n\t//! The destructor.\r\n\t~ComponentDiffWidget();\r\n\r\n    /*!\r\n     *  Sets the components to diff in the view.\r\n     *\r\n     *    @param [in] reference   The reference component to compare to.\r\n     *    @param [in] subject     The component to compare against the reference.\r\n     */\r\n    void setComponents(QSharedPointer<const Component> reference, QSharedPointer<const Component> subject);\r\n\r\n\r\nprivate:\r\n\r\n\t// Disable copying.\r\n\tComponentDiffWidget(ComponentDiffWidget const& rhs);\r\n\tComponentDiffWidget& operator=(ComponentDiffWidget const& rhs);\r\n    \r\n    /*!\r\n     *  Checks if a list of diffs shows no change.\r\n     *\r\n     *    @param [in] diffs   The list to check.\r\n     *\r\n     *    @return True, if nothing has changed, otherwise false.\r\n     */\r\n    bool nothingChanged(QList<QSharedPointer<IPXactDiff> > const& diffs);\r\n\r\n    /*!\r\n     *  Creates the top level items in the tree.\r\n     *\r\n     *    @param [in] diffs   The diffs to display in the tree.\r\n     *\r\n     *    @return Top level items indexed by their element type.\r\n     */\r\n    QMap<QString, QTreeWidgetItem*> createTopLevelItems(QList<QSharedPointer<IPXactDiff> > const& diffs);\r\n\r\n    /*!\r\n     *  Creates a top level item for a given element.\r\n     *\r\n     *    @param [in] elementName   The name of the element.\r\n     *\r\n     *    @return The created item.\r\n     */\r\n    QTreeWidgetItem* createTopLevelItemForElement(QString const& elementName);\r\n\r\n    /*!\r\n     *  Adds an item to the tree indicating an added element.\r\n     *\r\n     *    @param [in] name        The name of the added element.\r\n     *    @param [in] parent      The parent item.\r\n     */\r\n    void addAddItem(QString const& name, QTreeWidgetItem* parent);\r\n    \r\n    /*!\r\n     *  Adds an item to the tree indicating a removed element.\r\n     *\r\n     *    @param [in] name        The name of the removed element.\r\n     *    @param [in] parent      The parent item.\r\n     */\r\n    void addRemoveItem(QString const& name, QTreeWidgetItem* parent);\r\n\r\n    /*!\r\n     *  Adds an item to the tree indicating a modified element.\r\n     *\r\n     *    @param [in] name        The name of the modified element.\r\n     *    @param [in] parent      The parent item.\r\n     */\r\n    void addModificationItem(QSharedPointer<IPXactDiff> diff, QTreeWidgetItem* parent);\r\n\r\n    /*!\r\n     *  Adds an item to the tree indicating an modified element with a single modified sub-element.\r\n     *\r\n     *    @param [in] name            The name of the modified element.\r\n     *    @param [in] modification    The modification to the element.\r\n     *    @param [in] parent          The parent item.\r\n     */\r\n    void addSingleLevelModificationItem(QString const& name, IPXactDiff::Modification const& modification, \r\n        QTreeWidgetItem* parent);\r\n\r\n    /*!\r\n     *  Creates an item to indicate a modified sub-element.\r\n     *\r\n     *    @param [in] modification    The modification to the element.\r\n     *    @param [in] parent          The parent item.\r\n\r\n     *\r\n     *    @return Item for a modified sub-element.\r\n     */\r\n    QTreeWidgetItem* createModificationItem(IPXactDiff::Modification const& modification,\r\n        QTreeWidgetItem* parent = 0) const;\r\n\r\n    /*!\r\n     *  Adds an item to the tree indicating an modified element with multiple modified sub-elements.\r\n     *\r\n     *    @param [in] name            The name of the modified element.\r\n     *    @param [in] changelist      The modifications to the element.\r\n     *    @param [in] parent          The parent item.\r\n     */\r\n    void addMultiLevelModificationItem(QString const& name, QList<IPXactDiff::Modification> changelist, \r\n        QTreeWidgetItem* parent);\r\n\r\n    //! Expression formatter, formats the referencing expressions.\r\n    QSharedPointer<ExpressionFormatter> expressionFormatter_;\r\n};\r\n\r\n#endif // COMPONENTDIFFWIDGET_H\r\n"
  },
  {
    "path": "wizards/common/IPXactDiff.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: IPXactDiff.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Esko Pekkarinen\r\n// Date: 17.10.2014\r\n//\r\n// Description:\r\n// Class for capturing changes in IP-XACT elements.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"IPXactDiff.h\"\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: IPXactDiff::IPXactDiff()\r\n//-----------------------------------------------------------------------------\r\nIPXactDiff::IPXactDiff(QString const& element, QString const& name):element_(element), name_(name), \r\n    changeType_(NO_CHANGE), modifications_()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: IPXactDiff::~IPXactDiff()\r\n//-----------------------------------------------------------------------------\r\nIPXactDiff::~IPXactDiff()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: IPXactDiff::id()\r\n//-----------------------------------------------------------------------------\r\nQString IPXactDiff::name() const\r\n{\r\n    return name_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: IPXactDiff::element()\r\n//-----------------------------------------------------------------------------\r\nQString IPXactDiff::element() const\r\n{\r\n    return element_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: IPXactDiff::type()\r\n//-----------------------------------------------------------------------------\r\nIPXactDiff::DiffType IPXactDiff::changeType() const\r\n{\r\n    return changeType_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: IPXactDiff::setType()\r\n//-----------------------------------------------------------------------------\r\nvoid IPXactDiff::setChangeType(DiffType type)\r\n{\r\n    changeType_ = type;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: IPXactDiff::modifications()\r\n//-----------------------------------------------------------------------------\r\nQList<IPXactDiff::Modification> IPXactDiff::getChangeList() const\r\n{\r\n    return modifications_;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: IPXactDiff::addModificationIfChanged()\r\n//-----------------------------------------------------------------------------\r\nvoid IPXactDiff::checkForChange(QString const& element, QString const& referenceValue, QString const& subjectValue)\r\n{\r\n    if (referenceValue != subjectValue)\r\n    {\r\n        Modification modification;\r\n        modification.modifiedElement = element;\r\n        modification.previousValue = referenceValue;\r\n        modification.newValue = subjectValue;\r\n\r\n        modifications_.append(modification);\r\n    }\r\n}\r\n"
  },
  {
    "path": "wizards/common/IPXactDiff.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: IPXactDiff.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Esko Pekkarinen\r\n// Date: 17.10.2014\r\n//\r\n// Description:\r\n// Class for capturing changes in IP-XACT elements.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef IPXACTDIFF_H\r\n#define IPXACTDIFF_H\r\n\r\n#include <QString>\r\n#include <QList>\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Class for capturing changes in IP-XACT elements.\r\n//-----------------------------------------------------------------------------\r\nclass IPXactDiff\r\n{\r\npublic:\r\n    \r\n    //! The different change types.\r\n    enum DiffType \r\n    {\r\n        ADD = 0,        //<! Element added.\r\n        REMOVE,         //<! Element removed.\r\n        MODIFICATION,   //<! Element modified.\r\n        NO_CHANGE       //<! Element unchanged.\r\n    };\r\n    \r\n    //! Struct for storing modifications.\r\n    struct Modification\r\n    {\r\n        //! The name of the modified element e.g. default value.\r\n        QString modifiedElement;\r\n\r\n        //! The previous value of the element.\r\n        QString previousValue;\r\n\r\n        //! The modified value of the element.\r\n        QString newValue;\r\n    };\r\n\r\n    /*!\r\n     *  The constructor.\r\n     *\r\n     *    @param [in] element     The identifier for the IP-XACT element.\r\n     *    @param [in] name        The name of the element.\r\n     */\r\n    IPXactDiff(QString const& element, QString const& name = \"\");\r\n\r\n    //! The destructor.\r\n    ~IPXactDiff();\r\n    \r\n    /*!\r\n     *  Returns the identifier for the element.\r\n     *\r\n     *    @return The identifier for the element.\r\n     */\r\n    QString element() const;\r\n\r\n    /*!\r\n     *  Returns the name of the element.\r\n     *\r\n     *    @return The name of the element.\r\n     */\r\n    QString name() const;\r\n\r\n    /*!\r\n     *  Returns the change type.\r\n     *\r\n     *    @return The change type.\r\n     */\r\n    IPXactDiff::DiffType changeType() const;\r\n\r\n    /*!\r\n     *  Sets the change type.\r\n     *\r\n     *    @param [in] type   The type to set.\r\n     */\r\n    void setChangeType(DiffType type);\r\n\r\n    /*!\r\n     *  Gets the modifications in the contained elements.\r\n     *\r\n     *    @return The modifications to contained elements.\r\n     */\r\n    QList<Modification> getChangeList() const;\r\n\r\n    /*!\r\n     *  Checks if the given element has changed. If the element has changed, stores the modification.\r\n     *\r\n     *    @param [in] element         The name of the contained element.\r\n     *    @param [in] referenceValue  The value in the reference element.\r\n     *    @param [in] subjectValue    The value in the subject element.\r\n     */\r\n    void checkForChange(QString const& element, QString const& referenceValue, QString const& subjectValue);\r\n\r\nprivate:\r\n\r\n    //! Disable copying.\r\n    IPXactDiff(IPXactDiff const& rhs);\r\n    IPXactDiff& operator=(IPXactDiff const& rhs);\r\n\r\n    //! The element identifier e.g. port.\r\n    QString element_;\r\n\r\n    //! The name of the element e.g. clk.\r\n    QString name_;\r\n\r\n    //! The type of the change.\r\n    IPXactDiff::DiffType changeType_;\r\n\r\n    //! The modifications to the element.\r\n    QList<Modification> modifications_;\r\n};\r\n\r\n#endif // IPXACTDIFF_H\r\n"
  },
  {
    "path": "wizards/common/IPXactElementComparator.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: IPXactElementComparator.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Esko Pekkarinen\r\n// Date: 17.10.2014\r\n//\r\n// Description:\r\n// Base class for all IP-XACT element comparators.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef IPXACTELEMENTCOMPARATOR_H\r\n#define IPXACTELEMENTCOMPARATOR_H\r\n\r\n#include <QSharedPointer>\r\n#include \"IPXactDiff.h\"\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Base class for all IP-XACT element comparators.\r\n//-----------------------------------------------------------------------------\r\ntemplate <class T>\r\nclass IPXactElementComparator \r\n{\r\npublic:\r\n\r\n\t//! The destructor.\r\n    virtual ~IPXactElementComparator();\r\n\r\n    /*!\r\n     *  Compares the two elements.\r\n     *\r\n     *    @param [in] first    The first element.\r\n     *    @param [in] second   The second element.\r\n     *\r\n     *    @return True, if the elements are similar, otherwise false.\r\n     */\r\n    virtual bool compare(QSharedPointer<const T> first, QSharedPointer<const T> second) const;\r\n\r\n    /*!\r\n     *  Compares the sub-elements of two elements.\r\n     *\r\n     *    @param [in] first    The first elements.\r\n     *    @param [in] second   The second elements.\r\n     *\r\n     *    @return True, if the sub-elements are similar, otherwise false.\r\n     */\r\n    virtual bool compareFields(QSharedPointer<const T> first, QSharedPointer<const T> second) const = 0;\r\n\r\n    /*!\r\n     *  Finds the differences between the two given elements.\r\n     *\r\n     *    @param [in] reference   The reference element to compare to.\r\n     *    @param [in] subject     The element to compare against the reference.\r\n     *\r\n     *    @return Set of differences between the reference and subject.\r\n     */\r\n    virtual QList<QSharedPointer<IPXactDiff> > diff(QSharedPointer<const T> reference, \r\n        QSharedPointer<const T> subject) const;\r\n\r\n    /*!\r\n     *  Finds the differences between the sub-elements of two given elements.\r\n     *\r\n     *    @param [in] reference   The reference element to compare to.\r\n     *    @param [in] subject     The element to compare against the reference.\r\n     *\r\n     *    @return Set of differences between the sub-elements of reference and subject.\r\n     */\r\n    virtual QList<QSharedPointer<IPXactDiff> > diffFields(QSharedPointer<const T> first, \r\n        QSharedPointer<const T> second) const = 0;\r\n\r\n    /*!\r\n     *  Returns the type for the element.\r\n     *\r\n     *    @return The element type.\r\n     */\r\n    virtual QString elementType() const = 0;\r\n\r\nprotected:\r\n\r\n    /*!\r\n     *  Creates a diff result for an added element.     \r\n     *\r\n     *    @return Diff result for added element.\r\n     */\r\n    virtual QList<QSharedPointer<IPXactDiff> > addDiff() const;\r\n    \r\n    /*!\r\n     *  Creates a diff result for a removed element.     \r\n     *\r\n     *    @return Diff result for removed element.\r\n     */\r\n    virtual QList<QSharedPointer<IPXactDiff> > removeDiff() const;\r\n    \r\n    /*!\r\n     *  Creates a diff result for an unchanged element.     \r\n     *\r\n     *    @return Diff result for unchanged element.\r\n     */\r\n    virtual QList<QSharedPointer<IPXactDiff> > noChangeDiff() const;\r\n};\r\n\r\n#include \"IPXactElementComparator.inl\"\r\n\r\n#endif // IPXACTELEMENTCOMPARATOR_H\r\n"
  },
  {
    "path": "wizards/common/IPXactElementComparator.inl",
    "content": "//-----------------------------------------------------------------------------\r\n// File: IPXactElementComparator.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Esko Pekkarinen\r\n// Date: 17.10.2014\r\n//\r\n// Description:\r\n// Base class for all IP-XACT element comparators.\r\n//-----------------------------------------------------------------------------\r\n//-----------------------------------------------------------------------------\r\n// Function: IPXactElementComparator<T>::~IPXactElementComparator()\r\n//-----------------------------------------------------------------------------\r\ntemplate <class T>\r\nIPXactElementComparator<T>::~IPXactElementComparator()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: IPXactElementComparator<T>::compare()\r\n//-----------------------------------------------------------------------------\r\ntemplate <class T>\r\nbool IPXactElementComparator<T>::compare(QSharedPointer<const T> first, QSharedPointer<const T> second) const\r\n{\r\n    if (first == second)\r\n    {\r\n        return true;\r\n    }\r\n\r\n    if (first.isNull() || second.isNull())\r\n    {\r\n        return false;\r\n    }\r\n\r\n    return compareFields(first, second);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: IPXactElementComparator<T>::diff()\r\n//-----------------------------------------------------------------------------\r\ntemplate <class T>\r\nQList<QSharedPointer<IPXactDiff> > IPXactElementComparator<T>::diff(QSharedPointer<const T> reference, \r\n    QSharedPointer<const T> subject) const\r\n{\r\n    if (compare(reference, subject))\r\n    {\r\n        return noChangeDiff();\r\n    } \r\n\r\n    if (subject.isNull())\r\n    {\r\n        return removeDiff();\r\n    }    \r\n\r\n    if (reference.isNull())\r\n    { \r\n        return addDiff();\r\n    }\r\n\r\n    return diffFields(reference, subject);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: IPXactElementComparator::addDiff()\r\n//-----------------------------------------------------------------------------\r\ntemplate <class T>\r\nQList<QSharedPointer<IPXactDiff> > IPXactElementComparator<T>::addDiff() const\r\n{\r\n    QList<QSharedPointer<IPXactDiff> > addList;\r\n\r\n    QSharedPointer<IPXactDiff> add(new IPXactDiff(elementType()));\r\n    add->setChangeType(IPXactDiff::ADD);    \r\n    addList.append(add);\r\n\r\n    return addList;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: IPXactElementComparator::removeDiff()\r\n//-----------------------------------------------------------------------------\r\ntemplate <class T>\r\nQList<QSharedPointer<IPXactDiff> > IPXactElementComparator<T>::removeDiff() const\r\n{\r\n    QList<QSharedPointer<IPXactDiff> > removeList;\r\n\r\n    QSharedPointer<IPXactDiff> removeDiff(new IPXactDiff(elementType()));\r\n    removeDiff->setChangeType(IPXactDiff::REMOVE);    \r\n    removeList.append(removeDiff);\r\n\r\n    return removeList;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: IPXactElementComparator::noChangeDiff()\r\n//-----------------------------------------------------------------------------\r\ntemplate <class T>\r\nQList<QSharedPointer<IPXactDiff> > IPXactElementComparator<T>::noChangeDiff() const\r\n{\r\n    QList<QSharedPointer<IPXactDiff> > noChangeList;\r\n\r\n    QSharedPointer<IPXactDiff> unchangedDiff(new IPXactDiff(elementType()));\r\n    unchangedDiff->setChangeType(IPXactDiff::NO_CHANGE);    \r\n    noChangeList.append(unchangedDiff);\r\n\r\n    return noChangeList;\r\n}\r\n"
  },
  {
    "path": "wizards/common/ListComparator.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ListComparator.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Esko Pekkarinen\r\n// Date: 24.10.2014\r\n//\r\n// Description:\r\n// Base class for all IP-XACT comparators comparing lists of elements.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef LISTCOMPARATOR_H\r\n#define LISTCOMPARATOR_H\r\n\r\n#include \"IPXactElementComparator.h\"\r\n#include \"IPXactDiff.h\"\r\n\r\n#include <QSharedPointer>\r\n#include <QList>\r\n#include <QMap>\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Base class for all IP-XACT comparators comparing lists of elements.\r\n//-----------------------------------------------------------------------------\r\ntemplate <class T>\r\nclass ListComparator : public IPXactElementComparator<T>\r\n{\r\npublic:\r\n    \r\n    //! The destructor.\r\n    virtual ~ListComparator();\r\n\r\n    /*!\r\n     *  Compares the two lists of elements.\r\n     *\r\n     *    @param [in] first    The first lists.\r\n     *    @param [in] second   The second lists.\r\n     *\r\n     *    @return True, if the lists are similar, otherwise false.\r\n     */\r\n    virtual bool compare(QList<QSharedPointer<T> > const first, QList<QSharedPointer<T> > const second) const;    \r\n    \r\n    /*!\r\n     *  Finds the differences between the two given lists.\r\n     *\r\n     *    @param [in] references   The reference lists to compare to.\r\n     *    @param [in] subjects     The lists to compare against the reference.\r\n     *\r\n     *    @return Set of differences between the references and subjects.\r\n     */\r\n    virtual QList<QSharedPointer<IPXactDiff> > diff(QList<QSharedPointer<T> > const references, \r\n        QList<QSharedPointer<T> > const subjects) const;\r\n\r\n    /*!\r\n     *  Returns the type for the element.\r\n     *\r\n     *    @return The element type.\r\n     */\r\n    virtual QString elementType() const = 0;\r\n\r\nprotected:\r\n\r\n    /*!\r\n     *  Creates a map of elements where the name of the element is the key.\r\n     *\r\n     *    @param [in] list   The elements to include in the map.\r\n     *\r\n     *    @return Map of elements.\r\n     */\r\n    virtual QMap<QString, QSharedPointer<const T> > mapByName(QList<QSharedPointer<T> > const list) const;\r\n\r\n};\r\n\r\n#include \"ListComparator.inl\"\r\n\r\n#endif // LISTCOMPARATOR_H\r\n"
  },
  {
    "path": "wizards/common/ListComparator.inl",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ListComparator.inl\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Esko Pekkarinen\r\n// Date: 24.10.2014\r\n//\r\n// Description:\r\n// Base class for all IP-XACT comparators comparing lists of elements.\r\n//-----------------------------------------------------------------------------\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ListComparator<T>::~ListComparator()\r\n//-----------------------------------------------------------------------------\r\ntemplate <class T>\r\nListComparator<T>::~ListComparator()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ListComparator<T>::compare()\r\n//-----------------------------------------------------------------------------\r\ntemplate <class T>\r\nbool ListComparator<T>::compare(QList<QSharedPointer<T> > const first,\r\n    QList<QSharedPointer<T> > const second) const\r\n{\r\n    if (first.count() != second.count())\r\n    {\r\n        return false;\r\n    }\r\n\r\n    QMap<QString, QSharedPointer<const T> > const sortedSubjects = mapByName(second);\r\n\r\n    foreach(QSharedPointer<const T> reference, first)\r\n    {    \r\n        if (!sortedSubjects.contains(reference->name()))\r\n        {\r\n            return false;\r\n        }\r\n\r\n        if (!IPXactElementComparator<T>::compare(reference, sortedSubjects.value(reference->name())))\r\n        {\r\n            return false;\r\n        }\r\n    }\r\n\r\n    return true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ListComparator<T>::diff()\r\n//-----------------------------------------------------------------------------\r\ntemplate <class T>\r\nQList<QSharedPointer<IPXactDiff> > ListComparator<T>::diff(QList<QSharedPointer<T> > const references, \r\n    QList<QSharedPointer<T> > const subjects) const\r\n{\r\n    QList<QSharedPointer<IPXactDiff> > diffResult;\r\n\r\n    QMap<QString, QSharedPointer<const T> > subjectMap = mapByName(subjects);\r\n\r\n    foreach(QSharedPointer<const T> reference, references)\r\n    {    \r\n        if (subjectMap.contains(reference->name()))\r\n        {\r\n            QSharedPointer<const T> subject = subjectMap.value(reference->name());\r\n            if (!IPXactElementComparator<T>::compare(reference, subject))\r\n            {\r\n                diffResult.append(IPXactElementComparator<T>::diff(reference, subject));\r\n            }\r\n        }\r\n        else\r\n        {\r\n            QSharedPointer<IPXactDiff> remove(new IPXactDiff(elementType(), reference->name()));\r\n            remove->setChangeType(IPXactDiff::REMOVE);\r\n            diffResult.append(remove);\r\n        }\r\n    }\r\n\r\n    QMap<QString, QSharedPointer<const T> > referenceMap = mapByName(references);\r\n\r\n    foreach(QSharedPointer<const T> subject, subjects)\r\n    {    \r\n        if (!referenceMap.contains(subject->name()))\r\n        {\r\n            QSharedPointer<IPXactDiff> add(new IPXactDiff(elementType(), subject->name()));\r\n            add->setChangeType(IPXactDiff::ADD);\r\n            diffResult.append(add);\r\n        }\r\n    }\r\n\r\n    if (diffResult.isEmpty())\r\n    {\r\n        QSharedPointer<IPXactDiff> noChange(new IPXactDiff(elementType()));\r\n        noChange->setChangeType(IPXactDiff::NO_CHANGE);\r\n        diffResult.append(noChange);\r\n    }\r\n\r\n    return diffResult;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ListComparator<T>::mapByName()\r\n//-----------------------------------------------------------------------------\r\ntemplate <class T> \r\nQMap<QString, QSharedPointer<const T> > ListComparator<T>::mapByName(QList<QSharedPointer<T> > const list) const\r\n{\r\n    QMap<QString, QSharedPointer<const T> > mappedResult;\r\n\r\n    foreach(QSharedPointer<const T> element, list)\r\n    {\r\n        mappedResult.insert(element->name(), element);\r\n    }\r\n\r\n    return mappedResult;\r\n}\r\n"
  },
  {
    "path": "wizards/common/ModuleParameterComparator/ModuleParameterComparator.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ModuleParameterComparator.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Esko Pekkarinen\r\n// Date: 17.10.2014\r\n//\r\n// Description:\r\n// Comparator for finding differences in lists of module parameters.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"ModuleParameterComparator.h\"\r\n\r\n#include <IPXACTmodels/common/ModuleParameter.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ModuleParameterComparator::ModuleParameterComparator()\r\n//-----------------------------------------------------------------------------\r\nModuleParameterComparator::ModuleParameterComparator()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ModuleParameterComparator::()\r\n//-----------------------------------------------------------------------------\r\nModuleParameterComparator::~ModuleParameterComparator()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ModuleParameterComparator::compare()\r\n//-----------------------------------------------------------------------------\r\nbool ModuleParameterComparator::compare(QSharedPointer<ModuleParameter> first, \r\n    QSharedPointer<ModuleParameter> second) const\r\n{\r\n    return IPXactElementComparator::compare(first, second);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ModuleParameterComparator::compareFields()\r\n//-----------------------------------------------------------------------------\r\nbool ModuleParameterComparator::compareFields(QSharedPointer<const ModuleParameter> first, \r\n    QSharedPointer<const ModuleParameter> second) const\r\n{\r\n    return first->getValue() == second->getValue() &&\r\n        first->getDataType() == second->getDataType() &&\r\n        first->getUsageType() == second->getUsageType();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ModuleParameterComparator::compare()\r\n//-----------------------------------------------------------------------------\r\nbool ModuleParameterComparator::compare(QList<QSharedPointer<ModuleParameter> > const references,\r\n    QList<QSharedPointer<ModuleParameter> > const subjects)\r\n{\r\n    return ListComparator::compare(references, subjects);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ModuleParameterComparator::diffFields()\r\n//-----------------------------------------------------------------------------\r\nQList<QSharedPointer<IPXactDiff> > ModuleParameterComparator::diffFields(\r\n    QSharedPointer<const ModuleParameter> reference, QSharedPointer<const ModuleParameter> subject) const\r\n{\r\n    QList<QSharedPointer<IPXactDiff> > diffResult;\r\n\r\n    QSharedPointer<IPXactDiff> modification(new IPXactDiff(elementType(), reference->name()));\r\n    modification->setChangeType(IPXactDiff::MODIFICATION);\r\n\r\n    modification->checkForChange(\"description\", reference->description(), subject->description());\r\n    modification->checkForChange(\"type\", reference->getType(), subject->getType());\r\n    modification->checkForChange(\"value\", reference->getValue(), subject->getValue());\r\n    modification->checkForChange(\"data type\", reference->getDataType(), subject->getDataType());\r\n    modification->checkForChange(\"minimum value\", reference->getMinimumValue(), subject->getMinimumValue());\r\n    modification->checkForChange(\"maximum value\", reference->getMaximumValue(), subject->getMaximumValue());\r\n    modification->checkForChange(\"usage type\", reference->getUsageType(), subject->getUsageType());\r\n    modification->checkForChange(\"resolve\", reference->getValueResolve(), subject->getValueResolve());\r\n\r\n    diffResult.append(modification);\r\n    return diffResult;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ModuleParameterComparator::elementType()\r\n//-----------------------------------------------------------------------------\r\nQString ModuleParameterComparator::elementType() const\r\n{\r\n    return \"model parameter\";\r\n}\r\n"
  },
  {
    "path": "wizards/common/ModuleParameterComparator/ModuleParameterComparator.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ModuleParameterComparator.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Esko Pekkarinen\r\n// Date: 17.10.2014\r\n//\r\n// Description:\r\n// Comparator for finding differences in lists of module parameters.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef MODULEPARAMETERCOMPARATOR_H\r\n#define MODULEPARAMETERCOMPARATOR_H\r\n\r\n#include <QList>\r\n#include <QSharedPointer>\r\n\r\n#include <wizards/common/IPXactDiff.h>\r\n#include <wizards/common/ListComparator.h>\r\n\r\nclass ModuleParameter;\r\n//-----------------------------------------------------------------------------\r\n//! Comparator for finding differences in lists of model parameters.\r\n//-----------------------------------------------------------------------------\r\nclass ModuleParameterComparator : public ListComparator<ModuleParameter>\r\n{\r\npublic:\r\n    //! The constructor.\r\n    ModuleParameterComparator();\r\n\r\n    //! The destructor.\r\n    ~ModuleParameterComparator();\r\n\r\n    /*!\r\n     *  Finds the differences between the two given module parameters.\r\n     *\r\n     *    @param [in] reference   The reference module parameter to compare to.\r\n     *    @param [in] subject     The module parameter to compare against the reference.\r\n     *\r\n     *    @return Set of differences between the reference and subject.\r\n     */\r\n    virtual bool compare(QSharedPointer<ModuleParameter> first, QSharedPointer<ModuleParameter> second) const;\r\n    \r\n    /*!\r\n     *  Compares the sub-elements of two module parameters.\r\n     *\r\n     *    @param [in] first    The first module parameters.\r\n     *    @param [in] second   The second module parameters.\r\n     *\r\n     *    @return True, if the sub-elements are similar, otherwise false.\r\n     */\r\n    virtual bool compareFields(QSharedPointer<const ModuleParameter> first, \r\n        QSharedPointer<const ModuleParameter> second) const;\r\n\r\n    /*!\r\n     *  Compares the two lists of module parameters.\r\n     *\r\n     *    @param [in] first    The first lists.\r\n     *    @param [in] second   The second lists.\r\n     *\r\n     *    @return True, if the lists are similar, otherwise false.\r\n     */\r\n    bool compare(QList<QSharedPointer<ModuleParameter> > const first, \r\n        QList<QSharedPointer<ModuleParameter> > const second) ;\r\n    \r\n    /*!\r\n     *  Finds the differences between the sub-elements of two given module parameters.\r\n     *\r\n     *    @param [in] reference   The reference module parameter to compare to.\r\n     *    @param [in] subject     The module parameter to compare against the reference.\r\n     *\r\n     *    @return Set of differences between the sub-elements of reference and subject.\r\n     */\r\n    virtual QList<QSharedPointer<IPXactDiff> > diffFields(QSharedPointer<const ModuleParameter> reference,\r\n        QSharedPointer<const ModuleParameter> subject) const;\r\n    \r\n    /*!\r\n     *  Returns the type for the element.\r\n     *\r\n     *    @return The element type.\r\n     */\r\n    virtual QString elementType() const;\r\n\r\nprivate:\r\n\r\n    //! Disable copying.\r\n    ModuleParameterComparator(ModuleParameterComparator const& rhs);\r\n    ModuleParameterComparator& operator=(ModuleParameterComparator const& rhs);\r\n\r\n};\r\n\r\n#endif // MODULEPARAMETERCOMPARATOR_H\r\n"
  },
  {
    "path": "wizards/common/ParameterComparator/ParameterComparator.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ParameterComparator.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Esko Pekkarinen\r\n// Date: 01.04.2015\r\n//\r\n// Description:\r\n// Comparator for finding differences in lists of model parameters.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"ParameterComparator.h\"\r\n\r\n#include <IPXACTmodels/common/Parameter.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ParameterComparator::ParameterComparator()\r\n//-----------------------------------------------------------------------------\r\nParameterComparator::ParameterComparator()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ParameterComparator::ParameterComparator()\r\n//-----------------------------------------------------------------------------\r\nParameterComparator::~ParameterComparator()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ParameterComparator::compare()\r\n//-----------------------------------------------------------------------------\r\nbool ParameterComparator::compare(QSharedPointer<Parameter> first, QSharedPointer<Parameter> second) const\r\n{\r\n    return IPXactElementComparator::compare(first, second);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ParameterComparator::compareFields()\r\n//-----------------------------------------------------------------------------\r\nbool ParameterComparator::compareFields(QSharedPointer<const Parameter> first, \r\n    QSharedPointer<const Parameter> second) const\r\n{\r\n    return first->getValue() == second->getValue();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ParameterComparator::compare()\r\n//-----------------------------------------------------------------------------\r\nbool ParameterComparator::compare(QList<QSharedPointer<Parameter> > const references,\r\n    QList<QSharedPointer<Parameter> > const subjects)\r\n{\r\n    return ListComparator::compare(references, subjects);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ParameterComparator::diffFields()\r\n//-----------------------------------------------------------------------------\r\nQList<QSharedPointer<IPXactDiff> > ParameterComparator::diffFields(QSharedPointer<const Parameter> reference, \r\n    QSharedPointer<const Parameter> subject) const\r\n{\r\n    QList<QSharedPointer<IPXactDiff> > diffResult;\r\n\r\n    QSharedPointer<IPXactDiff> modification(new IPXactDiff(elementType(), reference->name()));\r\n    modification->setChangeType(IPXactDiff::MODIFICATION);\r\n\r\n    modification->checkForChange(\"description\", reference->description(), subject->description());\r\n    modification->checkForChange(\"type\", reference->getType(), subject->getType());\r\n    modification->checkForChange(\"value\", reference->getValue(), subject->getValue());\r\n    modification->checkForChange(\"minimum value\", reference->getMinimumValue(), subject->getMinimumValue());\r\n    modification->checkForChange(\"maximum value\", reference->getMaximumValue(), subject->getMaximumValue());\r\n    modification->checkForChange(\"resolve\", reference->getValueResolve(), subject->getValueResolve());\r\n\r\n    diffResult.append(modification);\r\n    return diffResult;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ParameterComparator::elementType()\r\n//-----------------------------------------------------------------------------\r\nQString ParameterComparator::elementType() const\r\n{\r\n    return \"parameter\";\r\n}\r\n"
  },
  {
    "path": "wizards/common/ParameterComparator/ParameterComparator.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ParameterComparator.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Esko Pekkarinen\r\n// Date: 17.10.2014\r\n//\r\n// Description:\r\n// Comparator for finding differences in lists of model parameters.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef PARAMETERCOMPARATOR_H\r\n#define PARAMETERCOMPARATOR_H\r\n\r\n#include <QList>\r\n#include <QSharedPointer>\r\n\r\n#include <wizards/common/IPXactDiff.h>\r\n#include <wizards/common/ListComparator.h>\r\n\r\nclass Parameter;\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Comparator for finding differences in lists of model parameters.\r\n//-----------------------------------------------------------------------------\r\nclass ParameterComparator : public ListComparator<Parameter>\r\n{\r\npublic:\r\n    //! The constructor.\r\n    ParameterComparator();\r\n\r\n    //! The destructor.\r\n    virtual ~ParameterComparator();\r\n\r\n    /*!\r\n     *  Finds the differences between the two given model parameters.\r\n     *\r\n     *    @param [in] reference   The reference model parameter to compare to.\r\n     *    @param [in] subject     The model parameters to compare against the reference.\r\n     *\r\n     *    @return Set of differences between the reference and subject.\r\n     */\r\n    virtual bool compare(QSharedPointer<Parameter> first, QSharedPointer<Parameter> second) const;\r\n    \r\n    /*!\r\n     *  Compares the sub-elements of two model parameters.\r\n     *\r\n     *    @param [in] first    The first model parameters.\r\n     *    @param [in] second   The second model parameters.\r\n     *\r\n     *    @return True, if the sub-elements are similar, otherwise false.\r\n     */\r\n    virtual bool compareFields(QSharedPointer<const Parameter> first, \r\n        QSharedPointer<const Parameter> second) const;\r\n\r\n    /*!\r\n     *  Compares the two lists of model parameters.\r\n     *\r\n     *    @param [in] first    The first lists.\r\n     *    @param [in] second   The second lists.\r\n     *\r\n     *    @return True, if the lists are similar, otherwise false.\r\n     */\r\n    bool compare(QList<QSharedPointer<Parameter> > const first, QList<QSharedPointer<Parameter> > const second);\r\n    \r\n    /*!\r\n     *  Finds the differences between the sub-elements of two given model parameters.\r\n     *\r\n     *    @param [in] reference   The reference model parameter to compare to.\r\n     *    @param [in] subject     The model parameter to compare against the reference.\r\n     *\r\n     *    @return Set of differences between the sub-elements of reference and subject.\r\n     */\r\n    virtual QList<QSharedPointer<IPXactDiff> > diffFields(QSharedPointer<const Parameter> reference,\r\n        QSharedPointer<const Parameter> subject) const;\r\n    \r\n    /*!\r\n     *  Returns the type for the element.\r\n     *\r\n     *    @return The element type.\r\n     */\r\n    virtual QString elementType() const;\r\n\r\nprivate:\r\n\r\n    //! Disable copying.\r\n    ParameterComparator(ParameterComparator const& rhs);\r\n    ParameterComparator& operator=(ParameterComparator const& rhs);\r\n\r\n};\r\n\r\n#endif // PARAMETERCOMPARATOR_H\r\n"
  },
  {
    "path": "wizards/common/PortComparator/PortComparator.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: PortComparator.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Esko Pekkarinen\r\n// Date: 24.10.2014\r\n//\r\n// Description:\r\n// Comparator for finding differences in ports.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"PortComparator.h\"\r\n\r\n#include <IPXACTmodels/Component/Port.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PortComparator::PortComparator()\r\n//-----------------------------------------------------------------------------\r\nPortComparator::PortComparator()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PortComparator::~PortComparator()\r\n//-----------------------------------------------------------------------------\r\nPortComparator::~PortComparator()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PortComparator::compare()\r\n//-----------------------------------------------------------------------------\r\nbool PortComparator::compare(QSharedPointer<const Port> first, QSharedPointer<const Port> second) const\r\n{\r\n    return IPXactElementComparator::compare(first, second);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PortComparator::compareFields()\r\n//-----------------------------------------------------------------------------\r\nbool PortComparator::compareFields(QSharedPointer<const Port> first, QSharedPointer<const Port> second) const\r\n{\r\n    return first->name() == second->name() &&       \r\n        first->getTypeName() == second->getTypeName() &&\r\n        first->getTypeDefinitions() == second->getTypeDefinitions() &&\r\n        first->getDefaultValue() == second->getDefaultValue() &&\r\n        first->getDirection() == second->getDirection() &&\r\n        first->getLeftBound() == second->getLeftBound() &&\r\n        first->getRightBound() == second->getRightBound();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PortComparator::compare()\r\n//-----------------------------------------------------------------------------\r\nbool PortComparator::compare(QList<QSharedPointer<Port> > const first, \r\n    QList<QSharedPointer<Port> > const second) const\r\n{\r\n    return ListComparator::compare(first, second);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PortComparator::diff()\r\n//-----------------------------------------------------------------------------\r\nQList<QSharedPointer<IPXactDiff> > PortComparator::diff(QSharedPointer<const Port> reference,\r\n    QSharedPointer<const Port> subject) const\r\n{\r\n    return IPXactElementComparator::diff(reference, subject);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PortComparator::diffFields()\r\n//-----------------------------------------------------------------------------\r\nQList<QSharedPointer<IPXactDiff> > PortComparator::diffFields(QSharedPointer<const Port> reference, \r\n    QSharedPointer<const Port> subject) const\r\n{\r\n    QSharedPointer<IPXactDiff> portDiff(new IPXactDiff(elementType(), reference->name()));\r\n    portDiff->setChangeType(IPXactDiff::MODIFICATION);\r\n\r\n    portDiff->checkForChange(\"type name\", reference->getTypeName(), subject->getTypeName());\r\n    portDiff->checkForChange(\"type definitions\", reference->getTypeDefinitions().join(\", \"), \r\n        subject->getTypeDefinitions().join(\", \"));\r\n\r\n    portDiff->checkForChange(\"default value\", reference->getDefaultValue(), subject->getDefaultValue());\r\n\r\n    portDiff->checkForChange(\"direction\", DirectionTypes::direction2Str(reference->getDirection()), \r\n        DirectionTypes::direction2Str(subject->getDirection()));\r\n\r\n    portDiff->checkForChange(\"left bound\", reference->getLeftBound(), subject->getLeftBound());\r\n    portDiff->checkForChange(\"right bound\", reference->getRightBound(), subject->getRightBound());\r\n\r\n    QList<QSharedPointer<IPXactDiff> > list;\r\n    list.append(portDiff);\r\n    return list;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PortComparator::diff()\r\n//-----------------------------------------------------------------------------\r\nQList<QSharedPointer<IPXactDiff> > PortComparator::diff(QList<QSharedPointer<Port> > const references, \r\n    QList<QSharedPointer<Port> > const subjects) const\r\n{\r\n    return ListComparator::diff(references, subjects);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: PortComparator::elementType()\r\n//-----------------------------------------------------------------------------\r\nQString PortComparator::elementType() const\r\n{\r\n    return QObject::tr(\"port\");\r\n}\r\n"
  },
  {
    "path": "wizards/common/PortComparator/PortComparator.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: PortComparator.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Esko Pekkarinen\r\n// Date: 24.10.2014\r\n//\r\n// Description:\r\n// Comparator for finding differences in ports.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef PORTCOMPARATOR_H\r\n#define PORTCOMPARATOR_H\r\n\r\n#include <wizards/common/ListComparator.h>\r\n#include <wizards/common/IPXactDiff.h>\r\n\r\n#include <QSharedPointer>\r\n\r\nclass Port;\r\n//-----------------------------------------------------------------------------\r\n//! Comparator for finding differences in ports.\r\n//-----------------------------------------------------------------------------\r\nclass PortComparator : public ListComparator<Port>\r\n{\r\npublic:\r\n\r\n    //! The constructor.    \r\n    PortComparator();\r\n\r\n    //! The destructor.\r\n    virtual ~PortComparator();\r\n    \r\n    /*!\r\n     *  Compares the two ports.\r\n     *\r\n     *    @param [in] first    The first port.\r\n     *    @param [in] second   The second port.\r\n     *\r\n     *    @return True, if the ports are similar, otherwise false.\r\n     */\r\n    virtual bool compare(QSharedPointer<const Port> first, QSharedPointer<const Port> second) const;\r\n\r\n    /*!\r\n     *  Compares the sub-elements of two ports.\r\n     *\r\n     *    @param [in] first    The first port.\r\n     *    @param [in] second   The second port.\r\n     *\r\n     *    @return True, if the sub-elements are similar, otherwise false.\r\n     */\r\n    bool compareFields(QSharedPointer<const Port> first, QSharedPointer<const Port> second) const;\r\n\r\n    /*!\r\n     *  Compares the two lists of ports.\r\n     *\r\n     *    @param [in] first    The first list.\r\n     *    @param [in] second   The second list.\r\n     *\r\n     *    @return True, if the lists are similar, otherwise false.\r\n     */\r\n    virtual bool compare(QList<QSharedPointer<Port> > const first, QList<QSharedPointer<Port> > const second) const;\r\n\r\n    /*!\r\n     *  Finds the differences between the two ports.\r\n     *\r\n     *    @param [in] reference   The port to compare to.\r\n     *    @param [in] subject     The port to compare against the reference.\r\n     *\r\n     *    @return Set of differences between the reference and subject.\r\n     */\r\n    virtual QList<QSharedPointer<IPXactDiff> > diff(QSharedPointer<const Port> reference, \r\n        QSharedPointer<const Port> subject) const;\r\n\r\n    /*!\r\n     *  Finds the differences between the sub-elements of two given ports.\r\n     *\r\n     *    @param [in] reference   The reference port to compare to.\r\n     *    @param [in] subject     The port to compare against the reference.\r\n     *\r\n     *    @return Set of differences between the sub-elements of reference and subject.\r\n     */\r\n    virtual QList<QSharedPointer<IPXactDiff> > diffFields(QSharedPointer<const Port> reference, \r\n        QSharedPointer<const Port> subject) const;\r\n\r\n    /*!\r\n     *  Finds the differences between the two given lists.\r\n     *\r\n     *    @param [in] reference   The reference lists to compare to.\r\n     *    @param [in] subject     The lists to compare against the reference.\r\n     *\r\n     *    @return Set of differences between the reference and subject.\r\n     */\r\n    virtual QList<QSharedPointer<IPXactDiff> > diff(QList<QSharedPointer<Port> > const reference, \r\n        QList<QSharedPointer<Port> > const subject) const;\r\n    \r\n    /*!\r\n     *  Returns the type for the element.\r\n     *\r\n     *    @return The element type.\r\n     */\r\n    virtual QString elementType() const;\r\n\r\n};\r\n\r\n#endif // PORTCOMPARATOR_H\r\n"
  },
  {
    "path": "wizards/common/VLNVComparator/VLNVComparator.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: VLNVComparator.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Esko Pekkarinen\r\n// Date: 17.10.2014\r\n//\r\n// Description:\r\n// Comparator for finding differences in VLVN elements.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"VLNVComparator.h\"\r\n\r\n#include <IPXACTmodels/common/VLNV.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VLNVComparator::VLNVComparator()\r\n//-----------------------------------------------------------------------------\r\nVLNVComparator::VLNVComparator()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VLNVComparator::~VLNVComparator()\r\n//-----------------------------------------------------------------------------\r\nVLNVComparator::~VLNVComparator()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VLNVComparator::elementType()\r\n//-----------------------------------------------------------------------------\r\nQString VLNVComparator::elementType() const\r\n{\r\n    return \"vlnv\";\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VLNVComparator::compareFields()\r\n//-----------------------------------------------------------------------------\r\nbool VLNVComparator::compareFields(QSharedPointer<const VLNV> first, QSharedPointer<const VLNV> second) const\r\n{\r\n    return *first == *second;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: VLNVComparator::diffFields()\r\n//-----------------------------------------------------------------------------\r\nQList<QSharedPointer<IPXactDiff> > VLNVComparator::diffFields(QSharedPointer<const VLNV> reference, \r\n    QSharedPointer<const VLNV> subject) const\r\n{   \r\n    if (reference->isEmpty())\r\n    {\r\n        return addDiff();    \r\n    }\r\n\r\n    if (subject->isEmpty())\r\n    {\r\n        return removeDiff();\r\n    }\r\n\r\n    QList<QSharedPointer<IPXactDiff> > changeDiff;\r\n\r\n    QSharedPointer<IPXactDiff> vlnvDiff(new IPXactDiff(elementType()));\r\n    vlnvDiff->setChangeType(IPXactDiff::MODIFICATION);\r\n\r\n    vlnvDiff->checkForChange(\"vlnv\", reference->toString(), subject->toString());\r\n\r\n    changeDiff.append(vlnvDiff);\r\n    return changeDiff;\r\n}\r\n"
  },
  {
    "path": "wizards/common/VLNVComparator/VLNVComparator.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: VLNVComparator.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Esko Pekkarinen\r\n// Date: 17.10.2014\r\n//\r\n// Description:\r\n// Comparator for finding differences in VLVN elements.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef VLNVCOMPARATOR_H\r\n#define VLNVCOMPARATOR_H\r\n\r\n#include <wizards/common/IPXactDiff.h>\r\n#include <wizards/common/IPXactElementComparator.h>\r\n\r\n#include <QList>\r\n\r\nclass VLNV;\r\n//-----------------------------------------------------------------------------\r\n//! Comparator for finding differences in VLVN elements.\r\n//-----------------------------------------------------------------------------\r\nclass VLNVComparator : public IPXactElementComparator<VLNV>\r\n{\r\npublic:\r\n\r\n\t//! The constructor.\r\n\tVLNVComparator();\r\n\r\n\t//! The destructor.\r\n\t~VLNVComparator();\r\n    \r\n    /*!\r\n     *  Compares the two VLNV elements.\r\n     *\r\n     *    @param [in] first    The first VLNV.\r\n     *    @param [in] second   The second VLNV.\r\n     *\r\n     *    @return True, if the VLNVs are similar, otherwise false.\r\n     */\r\n    virtual bool compareFields(QSharedPointer<const VLNV> first, QSharedPointer<const VLNV> second) const;\r\n\r\n    /*!\r\n     *  Finds the differences between the two given VLNVs.\r\n     *\r\n     *    @param [in] reference   The VLNVs to compare to.\r\n     *    @param [in] subject     The VLNVs to compare against the reference.\r\n     *\r\n     *    @return Set of differences between the reference and subject.\r\n     */\r\n    virtual QList<QSharedPointer<IPXactDiff> > diffFields(QSharedPointer<const VLNV> reference, \r\n        QSharedPointer<const VLNV> subject) const;\r\n    \r\n    /*!\r\n     *  Returns the type for the element.\r\n     *\r\n     *    @return The element type.\r\n     */\r\n     virtual QString elementType() const;\r\n\r\nprivate:\r\n\r\n\t//! Disable copying.\r\n\tVLNVComparator(VLNVComparator const& rhs);\r\n\tVLNVComparator& operator=(VLNVComparator const& rhs);\r\n};\r\n\r\n#endif // VLNVCOMPARATOR_H\r\n"
  },
  {
    "path": "wizards/common/ViewComparator/ViewComparator.cpp",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ViewComparator.cpp\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Esko Pekkarinen\r\n// Date: 21.10.2014\r\n//\r\n// Description:\r\n// Comparator for finding differences in views.\r\n//-----------------------------------------------------------------------------\r\n\r\n#include \"ViewComparator.h\"\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ViewComparator::ViewComparator()\r\n//-----------------------------------------------------------------------------\r\nViewComparator::ViewComparator()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ViewComparator::~ViewComparator()\r\n//-----------------------------------------------------------------------------\r\nViewComparator::~ViewComparator()\r\n{\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ViewComparator::compare()\r\n//-----------------------------------------------------------------------------\r\nbool ViewComparator::compare(QSharedPointer<const View> first, QSharedPointer<const View> second) const\r\n{\r\n    return IPXactElementComparator::compare(first, second);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ViewComparator::compareFields()\r\n//-----------------------------------------------------------------------------\r\nbool ViewComparator::compareFields(QSharedPointer<const View> first, QSharedPointer<const View> second) const\r\n{\r\n    return first->name() == second->name() &&\r\n        first->isHierarchical() == second->isHierarchical() &&  \r\n        compareLists(first->getEnvIdentifiers(), second->getEnvIdentifiers()) && \r\n        first->getComponentInstantiationRef() == second->getComponentInstantiationRef() &&\r\n        first->getDesignInstantiationRef() == second->getDesignInstantiationRef() &&\r\n        first->getDesignConfigurationInstantiationRef() == second->getDesignConfigurationInstantiationRef();\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ViewComparator::compare()\r\n//-----------------------------------------------------------------------------\r\nbool ViewComparator::compare(QList<QSharedPointer<View> > const first, \r\n    QList<QSharedPointer<View> > const second) const\r\n{\r\n    return ListComparator::compare(first, second);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ViewComparator::diff()\r\n//-----------------------------------------------------------------------------\r\nQList<QSharedPointer<IPXactDiff> > ViewComparator::diff(QSharedPointer<const View> reference,\r\n    QSharedPointer<const View> subject) const\r\n{\r\n    return IPXactElementComparator::diff(reference, subject);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ViewComparator::diffFields()\r\n//-----------------------------------------------------------------------------\r\nQList<QSharedPointer<IPXactDiff> > ViewComparator::diffFields(QSharedPointer<const View> reference, \r\n    QSharedPointer<const View> subject) const\r\n{\r\n    QSharedPointer<IPXactDiff> add(new IPXactDiff(elementType(), reference->name()));\r\n    add->setChangeType(IPXactDiff::MODIFICATION);\r\n\r\n    QStringList references;\r\n\tQStringList subjects;\r\n\r\n\tforeach (QSharedPointer<View::EnvironmentIdentifier> identifier, *reference->getEnvIdentifiers())\r\n\t{\r\n\t\treferences.append(identifier->toString());\r\n\t}\r\n\r\n\tforeach (QSharedPointer<View::EnvironmentIdentifier> identifier, *subject->getEnvIdentifiers())\r\n\t{\r\n\t\tsubjects.append(identifier->toString());\r\n\t}\r\n\r\n    QString refIds = references.join(QStringLiteral(\", \"));\r\n    QString subIds = subjects.join(QStringLiteral(\", \"));\r\n\r\n    add->checkForChange(\"environment identifiers\", refIds, subIds );\r\n    add->checkForChange(\"component instantiation reference\", reference->getComponentInstantiationRef(),\r\n        subject->getComponentInstantiationRef());\r\n\r\n    add->checkForChange(\"hierarchy\", viewHierarchyType(reference), viewHierarchyType(subject));\r\n\r\n    add->checkForChange(\"design instantiation reference\", reference->getDesignInstantiationRef(),\r\n        subject->getDesignInstantiationRef());\r\n    add->checkForChange(\"design configuration instantiation reference\",\r\n        reference->getDesignConfigurationInstantiationRef(), subject->getDesignConfigurationInstantiationRef());    \r\n\r\n    QList<QSharedPointer<IPXactDiff> > list;\r\n    list.append(add);\r\n    return list;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ViewComparator::diff()\r\n//-----------------------------------------------------------------------------\r\nQList<QSharedPointer<IPXactDiff> > ViewComparator::diff(QList<QSharedPointer<View> > const references, \r\n    QList<QSharedPointer<View> > const subjects) const\r\n{\r\n    return ListComparator::diff(references, subjects);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ViewComparator::compareLists()\r\n//-----------------------------------------------------------------------------\r\nbool ViewComparator::compareLists(QSharedPointer<QList<QSharedPointer<View::EnvironmentIdentifier> > > first,\r\n\tQSharedPointer<QList<QSharedPointer<View::EnvironmentIdentifier> > > second) const\r\n{\r\n    if (first->size() != second->size())\r\n    {\r\n        return false;\r\n    }\r\n\r\n\tfor (int i = 0; i < first->size(); ++i)\r\n\t{\r\n\t\tQSharedPointer<View::EnvironmentIdentifier> item1 = first->at(i);\r\n\t\tQSharedPointer<View::EnvironmentIdentifier> item2 = second->at(i);\r\n\r\n\t\tif (item1->language != item2->language ||\r\n\t\t\titem1->tool != item2->tool ||\r\n\t\t\titem1->vendorSpecific != item2->vendorSpecific )\r\n\t\t{\r\n\t\t\treturn false;\r\n\t\t}\r\n\t}\r\n\r\n    return true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ViewComparator::hierarchyType()\r\n//-----------------------------------------------------------------------------\r\nQString ViewComparator::viewHierarchyType(QSharedPointer<const View> view) const\r\n{\r\n    if (view->isHierarchical())\r\n    {\r\n        return QObject::tr(\"hierarchical\");\r\n    }\t\r\n    else\r\n    {\r\n        return QObject::tr(\"non-hierarchical\");\r\n    }    \r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function: ViewComparator::elementType()\r\n//-----------------------------------------------------------------------------\r\nQString ViewComparator::elementType() const\r\n{\r\n    return QObject::tr(\"view\");\r\n}\r\n"
  },
  {
    "path": "wizards/common/ViewComparator/ViewComparator.h",
    "content": "//-----------------------------------------------------------------------------\r\n// File: ViewComparator.h\r\n//-----------------------------------------------------------------------------\r\n// Project: Kactus 2\r\n// Author: Esko Pekkarinen\r\n// Date: 21.10.2014\r\n//\r\n// Description:\r\n// Comparator for finding differences in views.\r\n//-----------------------------------------------------------------------------\r\n\r\n#ifndef VIEWCOMPARATOR_H\r\n#define VIEWCOMPARATOR_H\r\n\r\n#include <wizards/common/ListComparator.h>\r\n#include <wizards/common/IPXactDiff.h>\r\n\r\n#include <IPXACTmodels/Component/View.h>\r\n\r\n//-----------------------------------------------------------------------------\r\n//! Comparator for finding differences in views.\r\n//-----------------------------------------------------------------------------\r\nclass ViewComparator : public ListComparator<View>\r\n{\r\npublic:\r\n\r\n    //! The constructor.    \r\n    ViewComparator();\r\n\r\n    //! The destructor.\r\n    virtual ~ViewComparator();\r\n    \r\n    /*!\r\n     *  Compares the two views.\r\n     *\r\n     *    @param [in] first    The first view.\r\n     *    @param [in] second   The second view.\r\n     *\r\n     *    @return True, if the ports are similar, otherwise false.\r\n     */\r\n    virtual bool compare(QSharedPointer<const View> first, QSharedPointer<const View> second) const;\r\n\r\n    /*!\r\n     *  Compares the sub-elements of two views.\r\n     *\r\n     *    @param [in] first    The first view.\r\n     *    @param [in] second   The second view.\r\n     *\r\n     *    @return True, if the sub-elements are similar, otherwise false.\r\n     */\r\n    bool compareFields(QSharedPointer<const View> first, QSharedPointer<const View> second) const;\r\n\r\n    /*!\r\n     *  Compares the two lists of views.\r\n     *\r\n     *    @param [in] first    The first lists.\r\n     *    @param [in] second   The second lists.\r\n     *\r\n     *    @return True, if the lists are similar, otherwise false.\r\n     */\r\n    virtual bool compare(QList<QSharedPointer<View> > const first, QList<QSharedPointer<View> > const second) const;\r\n\r\n    /*!\r\n     *  Finds the differences between two views.\r\n     *\r\n     *    @param [in] reference   The view to compare to.\r\n     *    @param [in] subject     The view to compare against the reference.\r\n     *\r\n     *    @return Set of differences between the reference and subject.\r\n     */\r\n    virtual QList<QSharedPointer<IPXactDiff> > diff(QSharedPointer<const View> reference, \r\n        QSharedPointer<const View> subject) const;\r\n\r\n    /*!\r\n     *  Finds the differences between the sub-elements of two given views.\r\n     *\r\n     *    @param [in] reference   The reference view to compare to.\r\n     *    @param [in] subject     The view to compare against the reference.\r\n     *\r\n     *    @return Set of differences between the sub-elements of reference and subject.\r\n     */\r\n    virtual QList<QSharedPointer<IPXactDiff> > diffFields(QSharedPointer<const View> reference, \r\n        QSharedPointer<const View> subject) const;\r\n\r\n    /*!\r\n     *  Finds the differences between the two given lists.\r\n     *\r\n     *    @param [in] reference   The reference lists to compare to.\r\n     *    @param [in] subject     The lists to compare against the reference.\r\n     *\r\n     *    @return Set of differences between the reference and subject.\r\n     */\r\n    virtual QList<QSharedPointer<IPXactDiff> > diff(QList<QSharedPointer<View> > const reference, \r\n        QList<QSharedPointer<View> > const subject) const;\r\n    \r\n    /*!\r\n     *  Returns the type for the element.\r\n     *\r\n     *    @return The element type.\r\n     */\r\n    virtual QString elementType() const;\r\n\r\nprivate:\r\n\r\n    /*!\r\n     *  Compares two string lists.\r\n     *\r\n     *    @param [in] first    The first list.\r\n     *    @param [in] second   The second list.\r\n     *\r\n     *    @return True, if the lists contain the same strings in any order, otherwise false.\r\n     */\r\n    bool compareLists(QSharedPointer<QList<QSharedPointer<View::EnvironmentIdentifier> > > first,\r\n\t\tQSharedPointer<QList<QSharedPointer<View::EnvironmentIdentifier> > > second) const;\r\n\r\n    /*!\r\n     *  Gets the type for a given view.\r\n     *\r\n     *    @param [in] view    The view whose type to get.\r\n     *\r\n     *    @return The type (hierarchical/non-hierarchical) of the view.\r\n     */\r\n    QString viewHierarchyType(QSharedPointer<const View> view) const;\r\n};\r\n\r\n#endif // VIEWCOMPARATOR_H\r\n"
  }
]